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 a2acf29c3..aa3f65077 100644 --- a/.gitignore +++ b/.gitignore @@ -46,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 deleted file mode 100644 index 3ee29e99e..000000000 --- a/CONTRIBUTING.md +++ /dev/null @@ -1,162 +0,0 @@ -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. - -This document is meant to be a set of tips and guidelines for contributing 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. - -- [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. - -- [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? - -Basic knowledge of C, particularly arrays and pointers, is extremely useful. Knowledge of MIPS is not required initially, you can pick it up as you work through some decompilation. - -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. - -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. - -### Environment Setup - -Get started by following the [installation guide in the readme](https://github.com/zeldaret/mm/blob/master/README.md#installation). -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. - -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 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. - -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. - -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. - -Style Guide & Conventions -------------------------- - -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. - -### Naming Scheme - -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` - -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: - -```c -#ifdef NON_MATCHING -void CollisionCheck_SpawnWaterDroplets(GlobalContext* globalCtx, Vec3f* v) { - // ... -} -#else -#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. - -`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 - -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. - -Documenting is more than just adding comments. Documenting also includes: - -- Renaming functions, variables, and struct members -- 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. - -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. - - -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. -- 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. - -Feel free to reach out on the Discord if you have any questions about these steps or encounter any issues. - -### 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`. - -Each PR needs a review from one reviewer and the project lead. - -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. - -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. - -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. diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 000000000..94b8cdfa2 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,42 @@ +FROM ubuntu:22.04 as build +ENV TZ=UTC + +# Install Required Dependencies +RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone && \ + apt-get update && apt-get install -y \ + curl \ + build-essential \ + binutils-mips-linux-gnu \ + pkg-config \ + python3 \ + python3-pip \ + git \ + wget \ + unzip \ + vbindiff \ + vim \ + clang-tidy-11 \ + clang-format-11 \ + libpng-dev && \ + apt clean && \ + rm -rf /var/lib/apt/lists/* + +# Install practicerom +RUN curl https://practicerom.com/public/packages/debian/pgp.pub | \ + apt-key add - && echo deb http://practicerom.com/public/packages/debian staging main >/etc/apt/sources.list.d/practicerom.list && apt update + +RUN apt-get install -y practicerom-dev + +COPY requirements.txt requirements.txt + +RUN python3 -m pip install --no-cache-dir -r requirements.txt + +ENV LANG C.UTF-8 + +RUN mkdir /mm + +WORKDIR /mm + +RUN git config --global --add safe.directory /mm + +ENTRYPOINT ["/bin/bash", "-c"] diff --git a/Jenkinsfile b/Jenkinsfile index 3ebfd3614..29c3721b2 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -20,6 +20,12 @@ pipeline { sh 'bash -c "tools/reloc_spec_check.sh"' } } + stage('Install Python dependencies') { + steps { + echo 'Installing Python dependencies' + sh 'python3 -m pip install -r requirements.txt' + } + } stage('Copy ROM') { steps { echo 'Setting up ROM...' @@ -36,6 +42,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)"' @@ -48,7 +64,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') { @@ -56,6 +72,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 7326b88a7..e4729002c 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 @@ -45,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 @@ -86,29 +98,45 @@ 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 MKLDSCRIPT := tools/buildtools/mkldscript YAZ0 := tools/buildtools/yaz0 ZAPD := tools/ZAPD/ZAPD.out +FADO := tools/fado/fado.elf OPTFLAGS := -O2 -g3 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 := -d -r -z -Mreg-names=32 +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 @@ -116,11 +144,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 #### @@ -161,9 +185,11 @@ O_FILES := $(foreach f,$(S_FILES:.s=.o),build/$f) \ $(foreach f,$(C_FILES:.c=.o),build/$f) \ $(foreach f,$(BASEROM_FILES),build/$f.o) +OVL_RELOC_FILES := $(shell $(CPP) $(CPPFLAGS) $(SPEC) | grep -o '[^"]*_reloc.o' ) + # Automatic dependency files -# (Only asm_processor dependencies are handled for now) -DEP_FILES := $(O_FILES:.o=.asmproc.d) +# (Only asm_processor dependencies and reloc dependencies are handled for now) +DEP_FILES := $(O_FILES:.o=.asmproc.d) $(OVL_RELOC_FILES:.o=.d) # create build directories $(shell mkdir -p build/baserom $(foreach dir,$(SRC_DIRS) $(ASM_DIRS) $(ASSET_BIN_DIRS),build/$(dir))) @@ -229,19 +255,30 @@ 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 +$(ELF): $(TEXTURE_FILES_OUT) $(ASSET_FILES_OUT) $(O_FILES) $(OVL_RELOC_FILES) build/ldscript.txt build/undefined_syms.txt $(LD) -T build/undefined_syms.txt -T build/ldscript.txt --no-check-sections --accept-unknown-input-arch --emit-relocs -Map build/mm.map -o $@ +## Order-only prerequisites +# These ensure e.g. the O_FILES are built before the OVL_RELOC_FILES. +# The intermediate phony targets avoid quadratically-many dependencies between the targets and prerequisites. + +o_files: $(O_FILES) +$(OVL_RELOC_FILES): | o_files + +asset_files: $(TEXTURE_FILES_OUT) $(ASSET_FILES_OUT) +$(O_FILES): | asset_files + +.PHONY: o_files asset_files #### Main commands #### @@ -263,6 +300,8 @@ setup: $(MAKE) -C tools python3 tools/fixbaserom.py python3 tools/extract_baserom.py + +assets: python3 extract_assets.py -j $(N_THREADS) ## Assembly generation @@ -278,6 +317,7 @@ diff-init: uncompressed init: $(MAKE) distclean $(MAKE) setup + $(MAKE) assets $(MAKE) disasm $(MAKE) all $(MAKE) diff-init @@ -287,16 +327,18 @@ init: build/undefined_syms.txt: undefined_syms.txt $(CPP) $(CPPFLAGS) $< > build/undefined_syms.txt -build/ldscript.txt: $(SPEC) - $(CPP) $(CPPFLAGS) $< > build/spec - $(MKLDSCRIPT) build/spec $@ +build/$(SPEC): $(SPEC) + $(CPP) $(CPPFLAGS) $< > $@ + +build/ldscript.txt: build/$(SPEC) + $(MKLDSCRIPT) $< $@ build/asm/%.o: asm/%.s $(AS) $(ASFLAGS) $< -o $@ build/assets/%.o: assets/%.c $(CC) -c $(CFLAGS) $(MIPS_VERSION) $(OPTFLAGS) -o $@ $< - $(OBJCOPY) -O binary $@ $@.bin + $(OBJCOPY_BIN) $(RM_MDEBUG) build/baserom/%.o: baserom/% @@ -308,31 +350,31 @@ build/data/%.o: data/%.s build/src/overlays/%.o: src/overlays/%.c $(CC_CHECK) $< $(CC) -c $(CFLAGS) $(MIPS_VERSION) $(OPTFLAGS) -o $@ $< - @$(OBJDUMP) $(OBJDUMP_FLAGS) $@ > $(@:.o=.s) -# TODO: `() || true` is currently necessary to suppress `Error 1 (ignored)` make warnings caused by `test`, but this will go away if -# the following is moved to a separate rule that is only run once when all the required objects have been compiled. - $(ZAPD) bovl -eh -i $@ -cfg $< --outputpath $(@D)/$(notdir $(@D))_reloc.s - (test -f $(@D)/$(notdir $(@D))_reloc.s && $(AS) $(ASFLAGS) $(@D)/$(notdir $(@D))_reloc.s -o $(@D)/$(notdir $(@D))_reloc.o) || true + @$(OBJDUMP) -d $@ > $(@:.o=.s) $(RM_MDEBUG) +build/src/overlays/%_reloc.o: build/$(SPEC) + $(FADO) $$(tools/buildtools/reloc_prereq $< $(notdir $*)) -n $(notdir $*) -o $(@:.o=.s) -M $(@:.o=.d) + $(AS) $(ASFLAGS) $(@:.o=.s) -o $@ + build/src/%.o: src/%.c $(CC_CHECK) $< $(CC) -c $(CFLAGS) $(MIPS_VERSION) $(OPTFLAGS) -o $@ $< - @$(OBJDUMP) $(OBJDUMP_FLAGS) $@ > $(@:.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) $(OBJDUMP_FLAGS) $@ > $(@:.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) $(OBJDUMP_FLAGS) $@ > $(@:.o=.s) + $(OBJDUMP_CMD) $(RM_MDEBUG) # Build C files from assets diff --git a/README.md b/README.md index c3ce27e97..9d746db2a 100644 --- a/README.md +++ b/README.md @@ -17,17 +17,18 @@ ```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` **This repo does not include any assets or assembly code necessary for compiling the ROM. A prior copy of the game is required to extract the required assets.** @@ -36,8 +37,7 @@ Please refer to the following for more information: - [Website](https://zelda64.dev/) - [Discord](https://discord.zelda64.dev/) -- [How to Contribute](CONTRIBUTING.md) - +- [How to Contribute](docs/CONTRIBUTING.md) ## Installation @@ -47,11 +47,13 @@ For Windows 10, install WSL and a distribution by following this [Windows Subsystem for Linux Installation Guide](https://docs.microsoft.com/en-us/windows/wsl/install-win10). We recommend using Debian or Ubuntu 20.04 Linux distributions. - ### MacOS Preparation is covered in a [separate document](docs/BUILDING_MACOS.md). +### Docker + +Preparation is covered in [Building Docker](docs/BUILDING_DOCKER.md). ### Linux (Native or under WSL / VM) @@ -127,26 +129,19 @@ md5sum: WARNING: 1 computed checksum did NOT match This means that something is wrong with the ROM's contents. Either the baserom files are incorrect due to a bad ROM, or some of the code is not matching. -Running `make init` will also make the `./expected` directory and copy all of the files there, which will be useful when running the diff script. The diff script is useful in decompiling functions and can be ran with this command: `./tools/asm-differ/diff.py -wmo3 ` +Running `make init` will also make the `./expected` directory and copy all of the files there, which will be useful when running the diff script. The diff script is useful in decompiling functions and can be run with this command: `./tools/asm-differ/diff.py -wmo3 ` -**Note**: to speed up the build, you can pass `-jN` to `make setup` and `make`, where N is the number of threads to use in the build, e.g. `make -j4`. The generally-accepted wisdom is to use the number of virtual cores your computer has, which is the output of `nproc` (which should be installed as part of `coreutils`). +**Note**: to speed up the build, you can pass `-jN` to `make setup` and `make`, where N is the number of threads to use in the build, e.g. `make -j4`. The generally-accepted wisdom is to use the number of virtual cores your computer has, which is the output of `nproc` (which should be installed as part of `coreutils`). The disadvantage that the ordering of the terminal output is scrambled, so for debugging it is best to stick to one thread (i.e. not pass `-jN`). (`-j` also exists, which uses unlimited jobs, but is generally slower.) - ## Contributing All contributions are welcome. This is a group effort, and even small contributions can make a difference. -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](docs/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 index d48335ec7..76db7e32c 100644 --- a/assets/xml/code/sub_s.xml +++ b/assets/xml/code/sub_s.xml @@ -1,6 +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 9d5a9901a..7e4d2d201 100644 --- a/assets/xml/objects/gameplay_dangeon_keep.xml +++ b/assets/xml/objects/gameplay_dangeon_keep.xml @@ -67,7 +67,7 @@ - + @@ -87,7 +87,7 @@ - + diff --git a/assets/xml/objects/gameplay_field_keep.xml b/assets/xml/objects/gameplay_field_keep.xml index 45fa3eccd..596101814 100644 --- a/assets/xml/objects/gameplay_field_keep.xml +++ b/assets/xml/objects/gameplay_field_keep.xml @@ -12,14 +12,14 @@ - - - - - - - - + + + + + + + + diff --git a/assets/xml/objects/gameplay_keep.xml b/assets/xml/objects/gameplay_keep.xml index 86f48d61d..4f1ad1841 100644 --- a/assets/xml/objects/gameplay_keep.xml +++ b/assets/xml/objects/gameplay_keep.xml @@ -786,17 +786,17 @@ - - - - - - - - - - - + + + + + + + + + + + @@ -810,17 +810,17 @@ - - - - - - - - - - - + + + + + + + + + + + @@ -828,16 +828,18 @@ - - - - - + + + + + - - - - + + + + + + @@ -854,8 +856,8 @@ - - + + @@ -871,7 +873,7 @@ - + @@ -891,11 +893,11 @@ - - - - - + + + + + @@ -924,12 +926,14 @@ - + + - + + @@ -940,13 +944,13 @@ - - - - - - - + + + + + + + @@ -970,16 +974,16 @@ - - - - - - - - - - + + + + + + + + + + @@ -993,84 +997,84 @@ - - - - - - - + + + + + + + - - + + - - - - - - - - - + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -1085,7 +1089,7 @@ - + @@ -1110,12 +1114,12 @@ - - - - - - + + + + + + @@ -1148,30 +1152,30 @@ - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + @@ -1180,7 +1184,7 @@ - + @@ -1283,32 +1287,41 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -1341,11 +1354,11 @@ - - - - - + + + + + diff --git a/assets/xml/objects/object_ah.xml b/assets/xml/objects/object_ah.xml index 3644f2a90..1bf479e86 100644 --- a/assets/xml/objects/object_ah.xml +++ b/assets/xml/objects/object_ah.xml @@ -53,6 +53,6 @@ - + diff --git a/assets/xml/objects/object_ahg.xml b/assets/xml/objects/object_ahg.xml index 7d4c2c741..7eb4c7126 100644 --- a/assets/xml/objects/object_ahg.xml +++ b/assets/xml/objects/object_ahg.xml @@ -48,6 +48,6 @@ - + diff --git a/assets/xml/objects/object_al.xml b/assets/xml/objects/object_al.xml index d0f6a6cbb..db348868a 100644 --- a/assets/xml/objects/object_al.xml +++ b/assets/xml/objects/object_al.xml @@ -1,71 +1,71 @@  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/assets/xml/objects/object_am.xml b/assets/xml/objects/object_am.xml index b0737cb50..1f738d39b 100644 --- a/assets/xml/objects/object_am.xml +++ b/assets/xml/objects/object_am.xml @@ -34,7 +34,7 @@ - + diff --git a/assets/xml/objects/object_an1.xml b/assets/xml/objects/object_an1.xml index 2c212923d..2db214bd3 100644 --- a/assets/xml/objects/object_an1.xml +++ b/assets/xml/objects/object_an1.xml @@ -81,7 +81,7 @@ - + diff --git a/assets/xml/objects/object_and.xml b/assets/xml/objects/object_and.xml index 17cff4597..00c8d7585 100644 --- a/assets/xml/objects/object_and.xml +++ b/assets/xml/objects/object_and.xml @@ -67,7 +67,7 @@ - + diff --git a/assets/xml/objects/object_ani.xml b/assets/xml/objects/object_ani.xml index f039e0114..34fb49f0d 100644 --- a/assets/xml/objects/object_ani.xml +++ b/assets/xml/objects/object_ani.xml @@ -21,7 +21,7 @@ - + @@ -36,13 +36,13 @@ - + - + diff --git a/assets/xml/objects/object_aob.xml b/assets/xml/objects/object_aob.xml index 3325e9b53..50de06ea0 100644 --- a/assets/xml/objects/object_aob.xml +++ b/assets/xml/objects/object_aob.xml @@ -22,7 +22,7 @@ - + diff --git a/assets/xml/objects/object_az.xml b/assets/xml/objects/object_az.xml index d4382673f..81207b06b 100644 --- a/assets/xml/objects/object_az.xml +++ b/assets/xml/objects/object_az.xml @@ -50,7 +50,7 @@ - + @@ -121,7 +121,7 @@ - + diff --git a/assets/xml/objects/object_bai.xml b/assets/xml/objects/object_bai.xml index 4225bec84..813065876 100644 --- a/assets/xml/objects/object_bai.xml +++ b/assets/xml/objects/object_bai.xml @@ -47,7 +47,7 @@ - + diff --git a/assets/xml/objects/object_bal.xml b/assets/xml/objects/object_bal.xml index a16e2fb1f..2cdfc5c3a 100644 --- a/assets/xml/objects/object_bal.xml +++ b/assets/xml/objects/object_bal.xml @@ -68,7 +68,7 @@ - + diff --git a/assets/xml/objects/object_bat.xml b/assets/xml/objects/object_bat.xml index 35a5c158d..5a685024e 100644 --- a/assets/xml/objects/object_bat.xml +++ b/assets/xml/objects/object_bat.xml @@ -1,17 +1,21 @@  + - - - - - - - - - - - - - + + + + + + + + + + + + + + + + diff --git a/assets/xml/objects/object_bb.xml b/assets/xml/objects/object_bb.xml index 3bd04c90e..e03cdb0e2 100644 --- a/assets/xml/objects/object_bb.xml +++ b/assets/xml/objects/object_bb.xml @@ -3,7 +3,7 @@ - + @@ -42,6 +42,6 @@ - + diff --git a/assets/xml/objects/object_bba.xml b/assets/xml/objects/object_bba.xml index 144c685e4..0b22866e7 100644 --- a/assets/xml/objects/object_bba.xml +++ b/assets/xml/objects/object_bba.xml @@ -18,7 +18,7 @@ - + @@ -41,7 +41,7 @@ - + diff --git a/assets/xml/objects/object_bee.xml b/assets/xml/objects/object_bee.xml index 8f1d704cf..735d191f3 100644 --- a/assets/xml/objects/object_bee.xml +++ b/assets/xml/objects/object_bee.xml @@ -23,6 +23,6 @@ - + diff --git a/assets/xml/objects/object_bg.xml b/assets/xml/objects/object_bg.xml index 0602f987d..fe294cb33 100644 --- a/assets/xml/objects/object_bg.xml +++ b/assets/xml/objects/object_bg.xml @@ -51,7 +51,7 @@ - + @@ -107,6 +107,6 @@ - + diff --git a/assets/xml/objects/object_bh.xml b/assets/xml/objects/object_bh.xml index 84f3050c0..3e33fb739 100644 --- a/assets/xml/objects/object_bh.xml +++ b/assets/xml/objects/object_bh.xml @@ -1,18 +1,18 @@  - - - - - - - - - - - - - - + + + + + + + + + + + + + + diff --git a/assets/xml/objects/object_bigokuta.xml b/assets/xml/objects/object_bigokuta.xml index 21ead0501..d8df44ddc 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_bigslime.xml b/assets/xml/objects/object_bigslime.xml index 5b7530add..84a6eec61 100644 --- a/assets/xml/objects/object_bigslime.xml +++ b/assets/xml/objects/object_bigslime.xml @@ -65,30 +65,30 @@ - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/assets/xml/objects/object_bji.xml b/assets/xml/objects/object_bji.xml index b41ac1546..bef54b0e5 100644 --- a/assets/xml/objects/object_bji.xml +++ b/assets/xml/objects/object_bji.xml @@ -3,21 +3,23 @@ - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + @@ -36,22 +38,27 @@ - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + diff --git a/assets/xml/objects/object_bjt.xml b/assets/xml/objects/object_bjt.xml index 6266711ab..27529206f 100644 --- a/assets/xml/objects/object_bjt.xml +++ b/assets/xml/objects/object_bjt.xml @@ -1,23 +1,28 @@  - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/assets/xml/objects/object_bob.xml b/assets/xml/objects/object_bob.xml index f942c84db..13edbe6fe 100644 --- a/assets/xml/objects/object_bob.xml +++ b/assets/xml/objects/object_bob.xml @@ -15,7 +15,7 @@ - + diff --git a/assets/xml/objects/object_boj.xml b/assets/xml/objects/object_boj.xml index ed42d9031..cfb10e97a 100644 --- a/assets/xml/objects/object_boj.xml +++ b/assets/xml/objects/object_boj.xml @@ -75,7 +75,7 @@ - + diff --git a/assets/xml/objects/object_boss01.xml b/assets/xml/objects/object_boss01.xml index 6a10080a3..89cc97a7e 100644 --- a/assets/xml/objects/object_boss01.xml +++ b/assets/xml/objects/object_boss01.xml @@ -113,7 +113,7 @@ - + @@ -183,7 +183,7 @@ - + diff --git a/assets/xml/objects/object_boss02.xml b/assets/xml/objects/object_boss02.xml index 0370e1ae2..8a80a57f2 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 75ce1d3c9..da17bf406 100644 --- a/assets/xml/objects/object_boss03.xml +++ b/assets/xml/objects/object_boss03.xml @@ -65,7 +65,7 @@ - + @@ -130,7 +130,7 @@ - + diff --git a/assets/xml/objects/object_boss04.xml b/assets/xml/objects/object_boss04.xml index d5d0f728a..d98083a64 100644 --- a/assets/xml/objects/object_boss04.xml +++ b/assets/xml/objects/object_boss04.xml @@ -1,30 +1,46 @@  + - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/assets/xml/objects/object_boss05.xml b/assets/xml/objects/object_boss05.xml index b401ae2be..95bb16edd 100644 --- a/assets/xml/objects/object_boss05.xml +++ b/assets/xml/objects/object_boss05.xml @@ -24,7 +24,7 @@ - + @@ -72,7 +72,7 @@ - + diff --git a/assets/xml/objects/object_boss07.xml b/assets/xml/objects/object_boss07.xml index 15a2e162d..91234f758 100644 --- a/assets/xml/objects/object_boss07.xml +++ b/assets/xml/objects/object_boss07.xml @@ -47,7 +47,7 @@ - + @@ -116,7 +116,7 @@ - + @@ -184,7 +184,7 @@ - + diff --git a/assets/xml/objects/object_boss_hakugin.xml b/assets/xml/objects/object_boss_hakugin.xml index 62d6fb91f..3444dc041 100644 --- a/assets/xml/objects/object_boss_hakugin.xml +++ b/assets/xml/objects/object_boss_hakugin.xml @@ -73,7 +73,7 @@ - + diff --git a/assets/xml/objects/object_box.xml b/assets/xml/objects/object_box.xml index fb1fb3fd5..4413ecd7a 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 7ccf12bce..81cdb9991 100644 --- a/assets/xml/objects/object_bsb.xml +++ b/assets/xml/objects/object_bsb.xml @@ -72,7 +72,7 @@ - + diff --git a/assets/xml/objects/object_bsmask.xml b/assets/xml/objects/object_bsmask.xml index e776cde1a..ea94aa89e 100644 --- a/assets/xml/objects/object_bsmask.xml +++ b/assets/xml/objects/object_bsmask.xml @@ -1,28 +1,36 @@  + - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/assets/xml/objects/object_cne.xml b/assets/xml/objects/object_cne.xml index fccbf539f..a4c8b28e2 100644 --- a/assets/xml/objects/object_cne.xml +++ b/assets/xml/objects/object_cne.xml @@ -18,7 +18,7 @@ - + diff --git a/assets/xml/objects/object_cow.xml b/assets/xml/objects/object_cow.xml index 535d5dd85..6895d6217 100644 --- a/assets/xml/objects/object_cow.xml +++ b/assets/xml/objects/object_cow.xml @@ -30,7 +30,7 @@ - + @@ -50,7 +50,7 @@ - + diff --git a/assets/xml/objects/object_crow.xml b/assets/xml/objects/object_crow.xml index de51da580..10fc23543 100644 --- a/assets/xml/objects/object_crow.xml +++ b/assets/xml/objects/object_crow.xml @@ -19,6 +19,6 @@ - + diff --git a/assets/xml/objects/object_cs.xml b/assets/xml/objects/object_cs.xml index 803d2b02c..fe614582b 100644 --- a/assets/xml/objects/object_cs.xml +++ b/assets/xml/objects/object_cs.xml @@ -89,7 +89,7 @@ - + diff --git a/assets/xml/objects/object_d_hsblock.xml b/assets/xml/objects/object_d_hsblock.xml index e9f90c011..b43647dc3 100644 --- a/assets/xml/objects/object_d_hsblock.xml +++ b/assets/xml/objects/object_d_hsblock.xml @@ -1,10 +1,11 @@  + - - - - - - + + + + + + diff --git a/assets/xml/objects/object_d_lift.xml b/assets/xml/objects/object_d_lift.xml index bcd707d68..475f7fd3e 100644 --- a/assets/xml/objects/object_d_lift.xml +++ b/assets/xml/objects/object_d_lift.xml @@ -3,9 +3,9 @@ - - - - + + + + diff --git a/assets/xml/objects/object_dai.xml b/assets/xml/objects/object_dai.xml index f613a9ab8..b547897f8 100644 --- a/assets/xml/objects/object_dai.xml +++ b/assets/xml/objects/object_dai.xml @@ -81,6 +81,6 @@ - + diff --git a/assets/xml/objects/object_daiku.xml b/assets/xml/objects/object_daiku.xml index 57124bd28..17d8ddbf0 100644 --- a/assets/xml/objects/object_daiku.xml +++ b/assets/xml/objects/object_daiku.xml @@ -65,7 +65,7 @@ - + diff --git a/assets/xml/objects/object_death.xml b/assets/xml/objects/object_death.xml index 7d3e1e596..77d4ccd4a 100644 --- a/assets/xml/objects/object_death.xml +++ b/assets/xml/objects/object_death.xml @@ -75,7 +75,7 @@ - + diff --git a/assets/xml/objects/object_dekubaba.xml b/assets/xml/objects/object_dekubaba.xml index b82cfb94b..eb80e770b 100644 --- a/assets/xml/objects/object_dekubaba.xml +++ b/assets/xml/objects/object_dekubaba.xml @@ -20,7 +20,7 @@ - + diff --git a/assets/xml/objects/object_dekunuts.xml b/assets/xml/objects/object_dekunuts.xml index 2e9529d4c..909231a77 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 7b1ff8c20..8db9c7c4a 100644 --- a/assets/xml/objects/object_dinofos.xml +++ b/assets/xml/objects/object_dinofos.xml @@ -61,7 +61,7 @@ - + diff --git a/assets/xml/objects/object_dnk.xml b/assets/xml/objects/object_dnk.xml index 4e07a455c..bec6ce45d 100644 --- a/assets/xml/objects/object_dnk.xml +++ b/assets/xml/objects/object_dnk.xml @@ -1,4 +1,5 @@  + @@ -33,17 +34,17 @@ - - - - - - - - - - - + + + + + + + + + + + diff --git a/assets/xml/objects/object_dno.xml b/assets/xml/objects/object_dno.xml index a320be10f..664663628 100644 --- a/assets/xml/objects/object_dno.xml +++ b/assets/xml/objects/object_dno.xml @@ -81,6 +81,6 @@ - + diff --git a/assets/xml/objects/object_dnp.xml b/assets/xml/objects/object_dnp.xml index 376368578..d9494909c 100644 --- a/assets/xml/objects/object_dnp.xml +++ b/assets/xml/objects/object_dnp.xml @@ -81,7 +81,7 @@ - + diff --git a/assets/xml/objects/object_dnq.xml b/assets/xml/objects/object_dnq.xml index 830e6d8e4..92d818a4b 100644 --- a/assets/xml/objects/object_dnq.xml +++ b/assets/xml/objects/object_dnq.xml @@ -88,7 +88,7 @@ - + diff --git a/assets/xml/objects/object_dns.xml b/assets/xml/objects/object_dns.xml index d42f68f54..e5d91326f 100644 --- a/assets/xml/objects/object_dns.xml +++ b/assets/xml/objects/object_dns.xml @@ -38,7 +38,7 @@ - + diff --git a/assets/xml/objects/object_dnt.xml b/assets/xml/objects/object_dnt.xml index 6a2b0058d..96b793849 100644 --- a/assets/xml/objects/object_dnt.xml +++ b/assets/xml/objects/object_dnt.xml @@ -84,7 +84,7 @@ - + diff --git a/assets/xml/objects/object_dodongo.xml b/assets/xml/objects/object_dodongo.xml index f63a27467..df70802d0 100644 --- a/assets/xml/objects/object_dodongo.xml +++ b/assets/xml/objects/object_dodongo.xml @@ -58,7 +58,7 @@ - + diff --git a/assets/xml/objects/object_dog.xml b/assets/xml/objects/object_dog.xml index 89eba9c96..0e3d318b4 100644 --- a/assets/xml/objects/object_dog.xml +++ b/assets/xml/objects/object_dog.xml @@ -17,7 +17,7 @@ - + @@ -60,6 +60,6 @@ - + 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 c5f4ee726..1b6c29597 100644 --- a/assets/xml/objects/object_drs.xml +++ b/assets/xml/objects/object_drs.xml @@ -16,6 +16,6 @@ - + diff --git a/assets/xml/objects/object_ds2.xml b/assets/xml/objects/object_ds2.xml index 1f1fd9d20..1794c4bf8 100644 --- a/assets/xml/objects/object_ds2.xml +++ b/assets/xml/objects/object_ds2.xml @@ -27,6 +27,6 @@ - + diff --git a/assets/xml/objects/object_ds2n.xml b/assets/xml/objects/object_ds2n.xml index 8cee6b22e..7e7d45f0c 100644 --- a/assets/xml/objects/object_ds2n.xml +++ b/assets/xml/objects/object_ds2n.xml @@ -1,55 +1,93 @@  + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/assets/xml/objects/object_dt.xml b/assets/xml/objects/object_dt.xml index 78ad8046e..8b2a90217 100644 --- a/assets/xml/objects/object_dt.xml +++ b/assets/xml/objects/object_dt.xml @@ -61,7 +61,7 @@ - + diff --git a/assets/xml/objects/object_dy_obj.xml b/assets/xml/objects/object_dy_obj.xml index 8dd90375a..a64bc975b 100644 --- a/assets/xml/objects/object_dy_obj.xml +++ b/assets/xml/objects/object_dy_obj.xml @@ -91,6 +91,6 @@ - + diff --git a/assets/xml/objects/object_efc_tw.xml b/assets/xml/objects/object_efc_tw.xml index 4d4c1029c..709224f9d 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 46d3e0089..9cda7f0a3 100644 --- a/assets/xml/objects/object_eg.xml +++ b/assets/xml/objects/object_eg.xml @@ -70,7 +70,7 @@ - + diff --git a/assets/xml/objects/object_f53_obj.xml b/assets/xml/objects/object_f53_obj.xml index 8fef96ac8..424d7c003 100644 --- a/assets/xml/objects/object_f53_obj.xml +++ b/assets/xml/objects/object_f53_obj.xml @@ -4,7 +4,7 @@ - + diff --git a/assets/xml/objects/object_fall2.xml b/assets/xml/objects/object_fall2.xml index 4e58e9fd3..25439a50a 100644 --- a/assets/xml/objects/object_fall2.xml +++ b/assets/xml/objects/object_fall2.xml @@ -11,7 +11,11 @@ - + + + + + @@ -25,5 +29,6 @@ + diff --git a/assets/xml/objects/object_famos.xml b/assets/xml/objects/object_famos.xml index 4466f9b30..d12a94d66 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 f0d3b8111..bb630781c 100644 --- a/assets/xml/objects/object_fb.xml +++ b/assets/xml/objects/object_fb.xml @@ -55,7 +55,7 @@ - + diff --git a/assets/xml/objects/object_firefly.xml b/assets/xml/objects/object_firefly.xml index 84018ddd8..4c6aacd16 100644 --- a/assets/xml/objects/object_firefly.xml +++ b/assets/xml/objects/object_firefly.xml @@ -49,6 +49,6 @@ - + diff --git a/assets/xml/objects/object_fish.xml b/assets/xml/objects/object_fish.xml index 9da78b6ab..f01639fbf 100644 --- a/assets/xml/objects/object_fish.xml +++ b/assets/xml/objects/object_fish.xml @@ -35,7 +35,7 @@ - + @@ -73,7 +73,7 @@ - + @@ -131,7 +131,7 @@ - + diff --git a/assets/xml/objects/object_fr.xml b/assets/xml/objects/object_fr.xml index cb02087ba..0cd28760e 100644 --- a/assets/xml/objects/object_fr.xml +++ b/assets/xml/objects/object_fr.xml @@ -62,6 +62,6 @@ - + diff --git a/assets/xml/objects/object_fsn.xml b/assets/xml/objects/object_fsn.xml index f90bf4e4d..dd67874f0 100644 --- a/assets/xml/objects/object_fsn.xml +++ b/assets/xml/objects/object_fsn.xml @@ -53,7 +53,8 @@ - + + @@ -102,7 +103,7 @@ - + diff --git a/assets/xml/objects/object_fu.xml b/assets/xml/objects/object_fu.xml index 4094355ae..19404f90e 100644 --- a/assets/xml/objects/object_fu.xml +++ b/assets/xml/objects/object_fu.xml @@ -47,6 +47,6 @@ - + diff --git a/assets/xml/objects/object_fu_kaiten.xml b/assets/xml/objects/object_fu_kaiten.xml index bce80f68c..37a7ec4bc 100644 --- a/assets/xml/objects/object_fu_kaiten.xml +++ b/assets/xml/objects/object_fu_kaiten.xml @@ -12,6 +12,7 @@ - + + diff --git a/assets/xml/objects/object_fwall.xml b/assets/xml/objects/object_fwall.xml index 1f7fb575b..1bbb5d572 100644 --- a/assets/xml/objects/object_fwall.xml +++ b/assets/xml/objects/object_fwall.xml @@ -1,6 +1,24 @@  - + + + + + + + + + + + + + + + + + + + diff --git a/assets/xml/objects/object_ge1.xml b/assets/xml/objects/object_ge1.xml index 2f6aac2dd..ead4263dc 100644 --- a/assets/xml/objects/object_ge1.xml +++ b/assets/xml/objects/object_ge1.xml @@ -1,63 +1,83 @@  + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/assets/xml/objects/object_geldb.xml b/assets/xml/objects/object_geldb.xml index 6338b48d6..5590677ea 100644 --- a/assets/xml/objects/object_geldb.xml +++ b/assets/xml/objects/object_geldb.xml @@ -71,7 +71,7 @@ - + diff --git a/assets/xml/objects/object_gg.xml b/assets/xml/objects/object_gg.xml index 17c21c93a..f7483e338 100644 --- a/assets/xml/objects/object_gg.xml +++ b/assets/xml/objects/object_gg.xml @@ -71,7 +71,7 @@ - + diff --git a/assets/xml/objects/object_gi_arrow.xml b/assets/xml/objects/object_gi_arrow.xml index ab3bcbde9..5fcfeb6eb 100644 --- a/assets/xml/objects/object_gi_arrow.xml +++ b/assets/xml/objects/object_gi_arrow.xml @@ -1,7 +1,13 @@  + + + + - - - + + + + + diff --git a/assets/xml/objects/object_gi_arrowcase.xml b/assets/xml/objects/object_gi_arrowcase.xml index ae10b4faa..87d8c29fb 100644 --- a/assets/xml/objects/object_gi_arrowcase.xml +++ b/assets/xml/objects/object_gi_arrowcase.xml @@ -1,12 +1,20 @@  + + + + - - - - - - - - + + + + + + + + + + + + diff --git a/assets/xml/objects/object_gi_bean.xml b/assets/xml/objects/object_gi_bean.xml index e19b48d14..ed9d2b7a6 100644 --- a/assets/xml/objects/object_gi_bean.xml +++ b/assets/xml/objects/object_gi_bean.xml @@ -1,5 +1,11 @@  + + + + - + + + diff --git a/assets/xml/objects/object_gi_bigbomb.xml b/assets/xml/objects/object_gi_bigbomb.xml index 27d2a0741..042736edc 100644 --- a/assets/xml/objects/object_gi_bigbomb.xml +++ b/assets/xml/objects/object_gi_bigbomb.xml @@ -1,10 +1,17 @@  + - - - - - - + + + + + + + + + + + + diff --git a/assets/xml/objects/object_gi_bomb_1.xml b/assets/xml/objects/object_gi_bomb_1.xml index 98af21873..174927ca6 100644 --- a/assets/xml/objects/object_gi_bomb_1.xml +++ b/assets/xml/objects/object_gi_bomb_1.xml @@ -1,5 +1,11 @@  + + + + - + + + diff --git a/assets/xml/objects/object_gi_bomb_2.xml b/assets/xml/objects/object_gi_bomb_2.xml index ecd07c048..f5b3af67f 100644 --- a/assets/xml/objects/object_gi_bomb_2.xml +++ b/assets/xml/objects/object_gi_bomb_2.xml @@ -1,5 +1,11 @@  + + + + - + + + diff --git a/assets/xml/objects/object_gi_bombpouch.xml b/assets/xml/objects/object_gi_bombpouch.xml index 06eff7ced..2e9969cbd 100644 --- a/assets/xml/objects/object_gi_bombpouch.xml +++ b/assets/xml/objects/object_gi_bombpouch.xml @@ -1,12 +1,20 @@  + + + + - - - - - - - - + + + + + + + + + + + + diff --git a/assets/xml/objects/object_gi_bosskey.xml b/assets/xml/objects/object_gi_bosskey.xml index ae5ac2e75..5d4bda5c0 100644 --- a/assets/xml/objects/object_gi_bosskey.xml +++ b/assets/xml/objects/object_gi_bosskey.xml @@ -1,6 +1,12 @@  + + + + - - + + + + diff --git a/assets/xml/objects/object_gi_bottle.xml b/assets/xml/objects/object_gi_bottle.xml index 95a7b8bce..e978697ab 100644 --- a/assets/xml/objects/object_gi_bottle.xml +++ b/assets/xml/objects/object_gi_bottle.xml @@ -1,6 +1,12 @@  + + + + - - + + + + diff --git a/assets/xml/objects/object_gi_bottle_04.xml b/assets/xml/objects/object_gi_bottle_04.xml index f215d4059..ab90eb89d 100644 --- a/assets/xml/objects/object_gi_bottle_04.xml +++ b/assets/xml/objects/object_gi_bottle_04.xml @@ -1,12 +1,21 @@  + - - - - - - - - + + + + + + + + + + + + + + + + diff --git a/assets/xml/objects/object_gi_bottle_15.xml b/assets/xml/objects/object_gi_bottle_15.xml index afea0f6ca..486e042a9 100644 --- a/assets/xml/objects/object_gi_bottle_15.xml +++ b/assets/xml/objects/object_gi_bottle_15.xml @@ -1,10 +1,15 @@  + - - - - - - + + + + + + + + + + diff --git a/assets/xml/objects/object_gi_bottle_16.xml b/assets/xml/objects/object_gi_bottle_16.xml index 7ee7f3640..ab736f087 100644 --- a/assets/xml/objects/object_gi_bottle_16.xml +++ b/assets/xml/objects/object_gi_bottle_16.xml @@ -1,8 +1,13 @@  + - - - - + + + + + + + + diff --git a/assets/xml/objects/object_gi_bottle_21.xml b/assets/xml/objects/object_gi_bottle_21.xml index 779b474cd..32cbd8e75 100644 --- a/assets/xml/objects/object_gi_bottle_21.xml +++ b/assets/xml/objects/object_gi_bottle_21.xml @@ -1,9 +1,14 @@  + - - - - - + + + + + + + + + diff --git a/assets/xml/objects/object_gi_bottle_22.xml b/assets/xml/objects/object_gi_bottle_22.xml index d61397014..bbc2ea452 100644 --- a/assets/xml/objects/object_gi_bottle_22.xml +++ b/assets/xml/objects/object_gi_bottle_22.xml @@ -1,10 +1,15 @@  + - - - - - - + + + + + + + + + + diff --git a/assets/xml/objects/object_gi_bottle_red.xml b/assets/xml/objects/object_gi_bottle_red.xml index c2f189dce..b52781d8d 100644 --- a/assets/xml/objects/object_gi_bottle_red.xml +++ b/assets/xml/objects/object_gi_bottle_red.xml @@ -1,8 +1,13 @@  + - - - - + + + + + + + + diff --git a/assets/xml/objects/object_gi_bow.xml b/assets/xml/objects/object_gi_bow.xml index b7d62e12d..f5ba88dfa 100644 --- a/assets/xml/objects/object_gi_bow.xml +++ b/assets/xml/objects/object_gi_bow.xml @@ -1,8 +1,13 @@  + - - - - + + + + + + + + diff --git a/assets/xml/objects/object_gi_camera.xml b/assets/xml/objects/object_gi_camera.xml index 81641ca30..5e94bf88b 100644 --- a/assets/xml/objects/object_gi_camera.xml +++ b/assets/xml/objects/object_gi_camera.xml @@ -1,9 +1,14 @@  + - - - - - + + + + + + + + + diff --git a/assets/xml/objects/object_gi_compass.xml b/assets/xml/objects/object_gi_compass.xml index 49f7cf87e..9c724fc59 100644 --- a/assets/xml/objects/object_gi_compass.xml +++ b/assets/xml/objects/object_gi_compass.xml @@ -1,6 +1,12 @@  + + + + - - + + + + diff --git a/assets/xml/objects/object_gi_fieldmap.xml b/assets/xml/objects/object_gi_fieldmap.xml index bdb77ad0b..f4d6369a9 100644 --- a/assets/xml/objects/object_gi_fieldmap.xml +++ b/assets/xml/objects/object_gi_fieldmap.xml @@ -1,9 +1,14 @@  + - - - - - + + + + + + + + + diff --git a/assets/xml/objects/object_gi_fish.xml b/assets/xml/objects/object_gi_fish.xml index 339f2d144..7c9f4be1f 100644 --- a/assets/xml/objects/object_gi_fish.xml +++ b/assets/xml/objects/object_gi_fish.xml @@ -1,5 +1,11 @@  + + + + - + + + diff --git a/assets/xml/objects/object_gi_ghost.xml b/assets/xml/objects/object_gi_ghost.xml index 813ba7d4e..3ea6ca582 100644 --- a/assets/xml/objects/object_gi_ghost.xml +++ b/assets/xml/objects/object_gi_ghost.xml @@ -1,11 +1,21 @@  + + + + - - - - - - - + + + + + + + + + + + + + diff --git a/assets/xml/objects/object_gi_glasses.xml b/assets/xml/objects/object_gi_glasses.xml index 571f0ea6d..e089e2c8d 100644 --- a/assets/xml/objects/object_gi_glasses.xml +++ b/assets/xml/objects/object_gi_glasses.xml @@ -1,6 +1,12 @@  + + + + - - + + + + diff --git a/assets/xml/objects/object_gi_gold_dust.xml b/assets/xml/objects/object_gi_gold_dust.xml index ed787b2b2..523134bae 100644 --- a/assets/xml/objects/object_gi_gold_dust.xml +++ b/assets/xml/objects/object_gi_gold_dust.xml @@ -1,8 +1,13 @@  + - - - - + + + + + + + + diff --git a/assets/xml/objects/object_gi_golonmask.xml b/assets/xml/objects/object_gi_golonmask.xml index c845fd0bd..87e65396e 100644 --- a/assets/xml/objects/object_gi_golonmask.xml +++ b/assets/xml/objects/object_gi_golonmask.xml @@ -1,9 +1,14 @@  + - - - - - + + + + + + + + + diff --git a/assets/xml/objects/object_gi_heart.xml b/assets/xml/objects/object_gi_heart.xml index 0917876aa..1d9e72459 100644 --- a/assets/xml/objects/object_gi_heart.xml +++ b/assets/xml/objects/object_gi_heart.xml @@ -1,5 +1,11 @@  + + + + - + + + diff --git a/assets/xml/objects/object_gi_hearts.xml b/assets/xml/objects/object_gi_hearts.xml index 442ba21c7..0f5387cae 100644 --- a/assets/xml/objects/object_gi_hearts.xml +++ b/assets/xml/objects/object_gi_hearts.xml @@ -1,7 +1,13 @@  + + + + - - - + + + + + diff --git a/assets/xml/objects/object_gi_hookshot.xml b/assets/xml/objects/object_gi_hookshot.xml index 37a0b4642..54dbcdd74 100644 --- a/assets/xml/objects/object_gi_hookshot.xml +++ b/assets/xml/objects/object_gi_hookshot.xml @@ -1,8 +1,13 @@  + - - - - + + + + + + + + diff --git a/assets/xml/objects/object_gi_insect.xml b/assets/xml/objects/object_gi_insect.xml index a7c3107ea..bba46991d 100644 --- a/assets/xml/objects/object_gi_insect.xml +++ b/assets/xml/objects/object_gi_insect.xml @@ -1,6 +1,12 @@  + + + + - - + + + + diff --git a/assets/xml/objects/object_gi_key.xml b/assets/xml/objects/object_gi_key.xml index bf4cdb727..2f4511f1d 100644 --- a/assets/xml/objects/object_gi_key.xml +++ b/assets/xml/objects/object_gi_key.xml @@ -1,5 +1,11 @@  + + + + - + + + diff --git a/assets/xml/objects/object_gi_ki_tan_mask.xml b/assets/xml/objects/object_gi_ki_tan_mask.xml index 313576631..3898630da 100644 --- a/assets/xml/objects/object_gi_ki_tan_mask.xml +++ b/assets/xml/objects/object_gi_ki_tan_mask.xml @@ -1,7 +1,15 @@  + + + + - - - + + + + + + + diff --git a/assets/xml/objects/object_gi_liquid.xml b/assets/xml/objects/object_gi_liquid.xml index bec768cfe..ed26c4267 100644 --- a/assets/xml/objects/object_gi_liquid.xml +++ b/assets/xml/objects/object_gi_liquid.xml @@ -1,19 +1,29 @@  + + + + - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + diff --git a/assets/xml/objects/object_gi_loach.xml b/assets/xml/objects/object_gi_loach.xml index c9c81f0b9..4ffcbfe73 100644 --- a/assets/xml/objects/object_gi_loach.xml +++ b/assets/xml/objects/object_gi_loach.xml @@ -1,10 +1,15 @@  + - - - - - - + + + + + + + + + + diff --git a/assets/xml/objects/object_gi_longsword.xml b/assets/xml/objects/object_gi_longsword.xml index 6be60d411..5385b9639 100644 --- a/assets/xml/objects/object_gi_longsword.xml +++ b/assets/xml/objects/object_gi_longsword.xml @@ -1,5 +1,11 @@  + + + + - + + + diff --git a/assets/xml/objects/object_gi_m_arrow.xml b/assets/xml/objects/object_gi_m_arrow.xml index 6351783b5..595ad25d6 100644 --- a/assets/xml/objects/object_gi_m_arrow.xml +++ b/assets/xml/objects/object_gi_m_arrow.xml @@ -1,9 +1,17 @@  + + + + - - - - - + + + + + + + + + diff --git a/assets/xml/objects/object_gi_magicmushroom.xml b/assets/xml/objects/object_gi_magicmushroom.xml index ae6cbeb49..1d26dfa63 100644 --- a/assets/xml/objects/object_gi_magicmushroom.xml +++ b/assets/xml/objects/object_gi_magicmushroom.xml @@ -1,9 +1,14 @@  + - - - - - + + + + + + + + + diff --git a/assets/xml/objects/object_gi_magicpot.xml b/assets/xml/objects/object_gi_magicpot.xml index 2abd48eef..459f010f4 100644 --- a/assets/xml/objects/object_gi_magicpot.xml +++ b/assets/xml/objects/object_gi_magicpot.xml @@ -1,6 +1,12 @@  + + + + - - + + + + diff --git a/assets/xml/objects/object_gi_map.xml b/assets/xml/objects/object_gi_map.xml index 250bb4613..c0cb2e070 100644 --- a/assets/xml/objects/object_gi_map.xml +++ b/assets/xml/objects/object_gi_map.xml @@ -1,7 +1,17 @@  + + + + - - - + + + + + + + + + diff --git a/assets/xml/objects/object_gi_mask03.xml b/assets/xml/objects/object_gi_mask03.xml index 561ddef83..3bc62ba8e 100644 --- a/assets/xml/objects/object_gi_mask03.xml +++ b/assets/xml/objects/object_gi_mask03.xml @@ -1,13 +1,20 @@  + - - - - - - - - - + + + + + + + + + + + + + + + diff --git a/assets/xml/objects/object_gi_mask05.xml b/assets/xml/objects/object_gi_mask05.xml index 307a3b2f4..c6bf0baad 100644 --- a/assets/xml/objects/object_gi_mask05.xml +++ b/assets/xml/objects/object_gi_mask05.xml @@ -1,11 +1,18 @@  + - - - - - - - + + + + + + + + + + + + + diff --git a/assets/xml/objects/object_gi_mask06.xml b/assets/xml/objects/object_gi_mask06.xml index 256d9a91e..7d24b1d92 100644 --- a/assets/xml/objects/object_gi_mask06.xml +++ b/assets/xml/objects/object_gi_mask06.xml @@ -1,10 +1,17 @@  + - - - - - - + + + + + + + + + + + + diff --git a/assets/xml/objects/object_gi_mask09.xml b/assets/xml/objects/object_gi_mask09.xml index d6db047d5..76efc6922 100644 --- a/assets/xml/objects/object_gi_mask09.xml +++ b/assets/xml/objects/object_gi_mask09.xml @@ -1,12 +1,19 @@  + - - - - - - - - + + + + + + + + + + + + + + diff --git a/assets/xml/objects/object_gi_mask10.xml b/assets/xml/objects/object_gi_mask10.xml index adb3ee1d2..e7083f94b 100644 --- a/assets/xml/objects/object_gi_mask10.xml +++ b/assets/xml/objects/object_gi_mask10.xml @@ -1,10 +1,15 @@  + - - - - - - + + + + + + + + + + diff --git a/assets/xml/objects/object_gi_mask11.xml b/assets/xml/objects/object_gi_mask11.xml index 46de5c2cd..e7b175b4d 100644 --- a/assets/xml/objects/object_gi_mask11.xml +++ b/assets/xml/objects/object_gi_mask11.xml @@ -1,14 +1,21 @@  + - - - - - - - - - - + + + + + + + + + + + + + + + + diff --git a/assets/xml/objects/object_gi_mask12.xml b/assets/xml/objects/object_gi_mask12.xml index dced8d8eb..2f1508b9d 100644 --- a/assets/xml/objects/object_gi_mask12.xml +++ b/assets/xml/objects/object_gi_mask12.xml @@ -1,8 +1,13 @@  + - - - - + + + + + + + + diff --git a/assets/xml/objects/object_gi_mask13.xml b/assets/xml/objects/object_gi_mask13.xml index b6d2c7733..8f5e7bf8f 100644 --- a/assets/xml/objects/object_gi_mask13.xml +++ b/assets/xml/objects/object_gi_mask13.xml @@ -1,9 +1,14 @@  + - - - - - + + + + + + + + + diff --git a/assets/xml/objects/object_gi_mask14.xml b/assets/xml/objects/object_gi_mask14.xml index a3c96bb9d..0b9b5be28 100644 --- a/assets/xml/objects/object_gi_mask14.xml +++ b/assets/xml/objects/object_gi_mask14.xml @@ -1,10 +1,15 @@  + - - - - - - + + + + + + + + + + diff --git a/assets/xml/objects/object_gi_mask15.xml b/assets/xml/objects/object_gi_mask15.xml index bc612c075..1f29f1bef 100644 --- a/assets/xml/objects/object_gi_mask15.xml +++ b/assets/xml/objects/object_gi_mask15.xml @@ -1,9 +1,14 @@  + - - - - - + + + + + + + + + diff --git a/assets/xml/objects/object_gi_mask16.xml b/assets/xml/objects/object_gi_mask16.xml index 57124d4d4..4a0650cdd 100644 --- a/assets/xml/objects/object_gi_mask16.xml +++ b/assets/xml/objects/object_gi_mask16.xml @@ -1,11 +1,16 @@  + - - - - - - - + + + + + + + + + + + diff --git a/assets/xml/objects/object_gi_mask17.xml b/assets/xml/objects/object_gi_mask17.xml index a509ca27e..a4df99986 100644 --- a/assets/xml/objects/object_gi_mask17.xml +++ b/assets/xml/objects/object_gi_mask17.xml @@ -1,13 +1,20 @@  + - - - - - - - - - + + + + + + + + + + + + + + + diff --git a/assets/xml/objects/object_gi_mask18.xml b/assets/xml/objects/object_gi_mask18.xml index 8e1c8ca54..ad0364290 100644 --- a/assets/xml/objects/object_gi_mask18.xml +++ b/assets/xml/objects/object_gi_mask18.xml @@ -1,12 +1,19 @@  + - - - - - - - - + + + + + + + + + + + + + + diff --git a/assets/xml/objects/object_gi_mask20.xml b/assets/xml/objects/object_gi_mask20.xml index 8b87c44fa..f04bb157e 100644 --- a/assets/xml/objects/object_gi_mask20.xml +++ b/assets/xml/objects/object_gi_mask20.xml @@ -1,11 +1,18 @@  + - - - - - - - + + + + + + + + + + + + + diff --git a/assets/xml/objects/object_gi_mask21.xml b/assets/xml/objects/object_gi_mask21.xml index 175d22b85..4696963ad 100644 --- a/assets/xml/objects/object_gi_mask21.xml +++ b/assets/xml/objects/object_gi_mask21.xml @@ -1,8 +1,13 @@  + - - - - + + + + + + + + diff --git a/assets/xml/objects/object_gi_mask22.xml b/assets/xml/objects/object_gi_mask22.xml index 7b3a49e53..54b0c5595 100644 --- a/assets/xml/objects/object_gi_mask22.xml +++ b/assets/xml/objects/object_gi_mask22.xml @@ -1,13 +1,20 @@  + - - - - - - - - - + + + + + + + + + + + + + + + diff --git a/assets/xml/objects/object_gi_mask23.xml b/assets/xml/objects/object_gi_mask23.xml index 458b7c825..6efa0147b 100644 --- a/assets/xml/objects/object_gi_mask23.xml +++ b/assets/xml/objects/object_gi_mask23.xml @@ -1,8 +1,13 @@  + - - - - + + + + + + + + diff --git a/assets/xml/objects/object_gi_melody.xml b/assets/xml/objects/object_gi_melody.xml index d7617e7a6..4d4696528 100644 --- a/assets/xml/objects/object_gi_melody.xml +++ b/assets/xml/objects/object_gi_melody.xml @@ -1,11 +1,14 @@  + - - - - - - - + + + + + + + + + diff --git a/assets/xml/objects/object_gi_milk.xml b/assets/xml/objects/object_gi_milk.xml index 137dae777..0e2c37efa 100644 --- a/assets/xml/objects/object_gi_milk.xml +++ b/assets/xml/objects/object_gi_milk.xml @@ -1,7 +1,15 @@  + + + + - - - + + + + + + + diff --git a/assets/xml/objects/object_gi_mssa.xml b/assets/xml/objects/object_gi_mssa.xml index 6b61b00f5..ce1ae8c42 100644 --- a/assets/xml/objects/object_gi_mssa.xml +++ b/assets/xml/objects/object_gi_mssa.xml @@ -1,10 +1,15 @@  + - - - - - - + + + + + + + + + + diff --git a/assets/xml/objects/object_gi_nuts.xml b/assets/xml/objects/object_gi_nuts.xml index 073e7db8f..d142cc8bd 100644 --- a/assets/xml/objects/object_gi_nuts.xml +++ b/assets/xml/objects/object_gi_nuts.xml @@ -1,6 +1,14 @@  + + + + - - + + + + + + diff --git a/assets/xml/objects/object_gi_nutsmask.xml b/assets/xml/objects/object_gi_nutsmask.xml index e34a593f2..c6df5804a 100644 --- a/assets/xml/objects/object_gi_nutsmask.xml +++ b/assets/xml/objects/object_gi_nutsmask.xml @@ -1,9 +1,14 @@  + - - - - - + + + + + + + + + diff --git a/assets/xml/objects/object_gi_ocarina.xml b/assets/xml/objects/object_gi_ocarina.xml index 7b968a491..5856529e6 100644 --- a/assets/xml/objects/object_gi_ocarina.xml +++ b/assets/xml/objects/object_gi_ocarina.xml @@ -1,7 +1,15 @@  + + + + - - - + + + + + + + diff --git a/assets/xml/objects/object_gi_purse.xml b/assets/xml/objects/object_gi_purse.xml index 49cf9fd37..d24da1add 100644 --- a/assets/xml/objects/object_gi_purse.xml +++ b/assets/xml/objects/object_gi_purse.xml @@ -1,17 +1,24 @@  + - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + diff --git a/assets/xml/objects/object_gi_rabit_mask.xml b/assets/xml/objects/object_gi_rabit_mask.xml index 172c080f1..16f536976 100644 --- a/assets/xml/objects/object_gi_rabit_mask.xml +++ b/assets/xml/objects/object_gi_rabit_mask.xml @@ -1,7 +1,15 @@  + + + + - - - + + + + + + + diff --git a/assets/xml/objects/object_gi_reserve00.xml b/assets/xml/objects/object_gi_reserve00.xml index 1527a2630..3476ab719 100644 --- a/assets/xml/objects/object_gi_reserve00.xml +++ b/assets/xml/objects/object_gi_reserve00.xml @@ -1,11 +1,20 @@  + - - - - - - - + + + + + + + + + + + + + + + diff --git a/assets/xml/objects/object_gi_reserve01.xml b/assets/xml/objects/object_gi_reserve01.xml index c31c76698..5c6bb4d18 100644 --- a/assets/xml/objects/object_gi_reserve01.xml +++ b/assets/xml/objects/object_gi_reserve01.xml @@ -1,14 +1,21 @@  + - - - - - - - - - - + + + + + + + + + + + + + + + + diff --git a/assets/xml/objects/object_gi_reserve_b_00.xml b/assets/xml/objects/object_gi_reserve_b_00.xml index 1c1e54390..1e2c37821 100644 --- a/assets/xml/objects/object_gi_reserve_b_00.xml +++ b/assets/xml/objects/object_gi_reserve_b_00.xml @@ -1,8 +1,13 @@  + - - - - + + + + + + + + diff --git a/assets/xml/objects/object_gi_reserve_b_01.xml b/assets/xml/objects/object_gi_reserve_b_01.xml index 574763ee9..2bd1b2af2 100644 --- a/assets/xml/objects/object_gi_reserve_b_01.xml +++ b/assets/xml/objects/object_gi_reserve_b_01.xml @@ -1,10 +1,15 @@  + - - - - - - + + + + + + + + + + diff --git a/assets/xml/objects/object_gi_reserve_c_00.xml b/assets/xml/objects/object_gi_reserve_c_00.xml index 86c6b15fb..f9cca9676 100644 --- a/assets/xml/objects/object_gi_reserve_c_00.xml +++ b/assets/xml/objects/object_gi_reserve_c_00.xml @@ -1,9 +1,14 @@  + - - - - - + + + + + + + + + diff --git a/assets/xml/objects/object_gi_reserve_c_01.xml b/assets/xml/objects/object_gi_reserve_c_01.xml index da1530970..b88f74df5 100644 --- a/assets/xml/objects/object_gi_reserve_c_01.xml +++ b/assets/xml/objects/object_gi_reserve_c_01.xml @@ -1,8 +1,13 @@  + - - - - + + + + + + + + diff --git a/assets/xml/objects/object_gi_rupy.xml b/assets/xml/objects/object_gi_rupy.xml index 69cd8bf5c..98d5714d6 100644 --- a/assets/xml/objects/object_gi_rupy.xml +++ b/assets/xml/objects/object_gi_rupy.xml @@ -1,18 +1,26 @@  + + + + - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + diff --git a/assets/xml/objects/object_gi_schedule.xml b/assets/xml/objects/object_gi_schedule.xml index e5025a993..9350bdcc3 100644 --- a/assets/xml/objects/object_gi_schedule.xml +++ b/assets/xml/objects/object_gi_schedule.xml @@ -1,11 +1,16 @@  + - - - - - - - + + + + + + + + + + + diff --git a/assets/xml/objects/object_gi_seahorse.xml b/assets/xml/objects/object_gi_seahorse.xml index f35e2edc9..acc1e184d 100644 --- a/assets/xml/objects/object_gi_seahorse.xml +++ b/assets/xml/objects/object_gi_seahorse.xml @@ -1,12 +1,19 @@  + - - - - - - - - + + + + + + + + + + + + + + diff --git a/assets/xml/objects/object_gi_shield_2.xml b/assets/xml/objects/object_gi_shield_2.xml index eb9fec8d2..e3b990bcf 100644 --- a/assets/xml/objects/object_gi_shield_2.xml +++ b/assets/xml/objects/object_gi_shield_2.xml @@ -1,10 +1,15 @@  + - - - - - - + + + + + + + + + + diff --git a/assets/xml/objects/object_gi_shield_3.xml b/assets/xml/objects/object_gi_shield_3.xml index 8e011bb92..19f23203b 100644 --- a/assets/xml/objects/object_gi_shield_3.xml +++ b/assets/xml/objects/object_gi_shield_3.xml @@ -1,10 +1,15 @@  + - - - - - - + + + + + + + + + + diff --git a/assets/xml/objects/object_gi_soldout.xml b/assets/xml/objects/object_gi_soldout.xml index 8a733af02..109a65072 100644 --- a/assets/xml/objects/object_gi_soldout.xml +++ b/assets/xml/objects/object_gi_soldout.xml @@ -1,6 +1,11 @@  + - - + + + + + + diff --git a/assets/xml/objects/object_gi_soul.xml b/assets/xml/objects/object_gi_soul.xml index 945670888..942062535 100644 --- a/assets/xml/objects/object_gi_soul.xml +++ b/assets/xml/objects/object_gi_soul.xml @@ -1,8 +1,16 @@  + + + + - - - - + + + + + + + + diff --git a/assets/xml/objects/object_gi_stick.xml b/assets/xml/objects/object_gi_stick.xml index c038af357..859e4f641 100644 --- a/assets/xml/objects/object_gi_stick.xml +++ b/assets/xml/objects/object_gi_stick.xml @@ -1,5 +1,11 @@  + + + + - + + + diff --git a/assets/xml/objects/object_gi_stonemask.xml b/assets/xml/objects/object_gi_stonemask.xml index 9d3b62b8c..497ace2df 100644 --- a/assets/xml/objects/object_gi_stonemask.xml +++ b/assets/xml/objects/object_gi_stonemask.xml @@ -1,8 +1,13 @@  + - - - - + + + + + + + + diff --git a/assets/xml/objects/object_gi_sutaru.xml b/assets/xml/objects/object_gi_sutaru.xml index 3b991123e..1a425dd2a 100644 --- a/assets/xml/objects/object_gi_sutaru.xml +++ b/assets/xml/objects/object_gi_sutaru.xml @@ -1,6 +1,12 @@  + + + + - - + + + + diff --git a/assets/xml/objects/object_gi_sword_1.xml b/assets/xml/objects/object_gi_sword_1.xml index a03de82d5..3f1bd41c0 100644 --- a/assets/xml/objects/object_gi_sword_1.xml +++ b/assets/xml/objects/object_gi_sword_1.xml @@ -1,9 +1,14 @@  + - - - - - + + + + + + + + + diff --git a/assets/xml/objects/object_gi_sword_2.xml b/assets/xml/objects/object_gi_sword_2.xml index 045936ef2..6a2bb445b 100644 --- a/assets/xml/objects/object_gi_sword_2.xml +++ b/assets/xml/objects/object_gi_sword_2.xml @@ -1,9 +1,14 @@  + - - - - - + + + + + + + + + diff --git a/assets/xml/objects/object_gi_sword_3.xml b/assets/xml/objects/object_gi_sword_3.xml index 79a207991..b347c33cf 100644 --- a/assets/xml/objects/object_gi_sword_3.xml +++ b/assets/xml/objects/object_gi_sword_3.xml @@ -1,9 +1,14 @@  + - - - - - + + + + + + + + + diff --git a/assets/xml/objects/object_gi_sword_4.xml b/assets/xml/objects/object_gi_sword_4.xml index b5c826dc3..7732259c6 100644 --- a/assets/xml/objects/object_gi_sword_4.xml +++ b/assets/xml/objects/object_gi_sword_4.xml @@ -1,9 +1,14 @@  + - - - - - + + + + + + + + + diff --git a/assets/xml/objects/object_gi_truth_mask.xml b/assets/xml/objects/object_gi_truth_mask.xml index 52fdaaf65..cbc818cea 100644 --- a/assets/xml/objects/object_gi_truth_mask.xml +++ b/assets/xml/objects/object_gi_truth_mask.xml @@ -1,8 +1,16 @@  + + + + - - - - + + + + + + + + diff --git a/assets/xml/objects/object_gi_zoramask.xml b/assets/xml/objects/object_gi_zoramask.xml index c5ba218b4..7deefdf71 100644 --- a/assets/xml/objects/object_gi_zoramask.xml +++ b/assets/xml/objects/object_gi_zoramask.xml @@ -1,11 +1,16 @@  + - - - - - - - + + + + + + + + + + + diff --git a/assets/xml/objects/object_giant.xml b/assets/xml/objects/object_giant.xml index 8698d176b..491cd0cb0 100644 --- a/assets/xml/objects/object_giant.xml +++ b/assets/xml/objects/object_giant.xml @@ -68,7 +68,7 @@ - + diff --git a/assets/xml/objects/object_gk.xml b/assets/xml/objects/object_gk.xml index 3fde40f94..b36aef153 100644 --- a/assets/xml/objects/object_gk.xml +++ b/assets/xml/objects/object_gk.xml @@ -42,7 +42,7 @@ - + diff --git a/assets/xml/objects/object_gla.xml b/assets/xml/objects/object_gla.xml index ae80c7dfc..7463cd2e0 100644 --- a/assets/xml/objects/object_gla.xml +++ b/assets/xml/objects/object_gla.xml @@ -65,7 +65,7 @@ - + diff --git a/assets/xml/objects/object_gmo.xml b/assets/xml/objects/object_gmo.xml index 7490a661e..eaee120b3 100644 --- a/assets/xml/objects/object_gmo.xml +++ b/assets/xml/objects/object_gmo.xml @@ -11,6 +11,6 @@ - + diff --git a/assets/xml/objects/object_grasshopper.xml b/assets/xml/objects/object_grasshopper.xml index 35120e0c9..3ef7b8e64 100644 --- a/assets/xml/objects/object_grasshopper.xml +++ b/assets/xml/objects/object_grasshopper.xml @@ -58,7 +58,7 @@ - + diff --git a/assets/xml/objects/object_ha.xml b/assets/xml/objects/object_ha.xml index 4f595b6be..94973c809 100644 --- a/assets/xml/objects/object_ha.xml +++ b/assets/xml/objects/object_ha.xml @@ -63,7 +63,7 @@ - + @@ -130,6 +130,6 @@ - + diff --git a/assets/xml/objects/object_hakugin_obj.xml b/assets/xml/objects/object_hakugin_obj.xml index 412d0bdd3..b4badbd1d 100644 --- a/assets/xml/objects/object_hakugin_obj.xml +++ b/assets/xml/objects/object_hakugin_obj.xml @@ -6,37 +6,37 @@ - + - + - + - + - + - + - + diff --git a/assets/xml/objects/object_harfgibud.xml b/assets/xml/objects/object_harfgibud.xml index a97e42c00..61e1fc457 100644 --- a/assets/xml/objects/object_harfgibud.xml +++ b/assets/xml/objects/object_harfgibud.xml @@ -5,23 +5,25 @@ - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + @@ -35,47 +37,51 @@ - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + @@ -91,25 +97,27 @@ - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + diff --git a/assets/xml/objects/object_hata.xml b/assets/xml/objects/object_hata.xml index 3f5e12a38..9271520b7 100644 --- a/assets/xml/objects/object_hata.xml +++ b/assets/xml/objects/object_hata.xml @@ -34,6 +34,6 @@ - + diff --git a/assets/xml/objects/object_hintnuts.xml b/assets/xml/objects/object_hintnuts.xml index a500981a7..483623988 100644 --- a/assets/xml/objects/object_hintnuts.xml +++ b/assets/xml/objects/object_hintnuts.xml @@ -27,7 +27,7 @@ - + diff --git a/assets/xml/objects/object_horse_link_child.xml b/assets/xml/objects/object_horse_link_child.xml index 506135e0c..60178badb 100644 --- a/assets/xml/objects/object_horse_link_child.xml +++ b/assets/xml/objects/object_horse_link_child.xml @@ -76,7 +76,7 @@ - + diff --git a/assets/xml/objects/object_hs.xml b/assets/xml/objects/object_hs.xml index 0d36c4ff1..19ea49b6b 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_icefloe.xml b/assets/xml/objects/object_icefloe.xml index cb9b321a3..2427052af 100644 --- a/assets/xml/objects/object_icefloe.xml +++ b/assets/xml/objects/object_icefloe.xml @@ -1,7 +1,7 @@  - - - + + + diff --git a/assets/xml/objects/object_ik.xml b/assets/xml/objects/object_ik.xml index 0b68303da..352b82487 100644 --- a/assets/xml/objects/object_ik.xml +++ b/assets/xml/objects/object_ik.xml @@ -1,106 +1,105 @@  + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/assets/xml/objects/object_ikana_obj.xml b/assets/xml/objects/object_ikana_obj.xml index 66398991b..e0490a349 100644 --- a/assets/xml/objects/object_ikana_obj.xml +++ b/assets/xml/objects/object_ikana_obj.xml @@ -9,23 +9,23 @@ - - + + - + - - + + - + - - + + @@ -38,8 +38,8 @@ - - + + @@ -51,11 +51,11 @@ - - - - - + + + + + diff --git a/assets/xml/objects/object_ikn_demo.xml b/assets/xml/objects/object_ikn_demo.xml index 56f8fd0e9..53d5c65a1 100644 --- a/assets/xml/objects/object_ikn_demo.xml +++ b/assets/xml/objects/object_ikn_demo.xml @@ -43,7 +43,7 @@ - + @@ -63,7 +63,7 @@ - + @@ -89,7 +89,7 @@ - + diff --git a/assets/xml/objects/object_iknv_obj.xml b/assets/xml/objects/object_iknv_obj.xml index 1e10d813c..58926c0e3 100644 --- a/assets/xml/objects/object_iknv_obj.xml +++ b/assets/xml/objects/object_iknv_obj.xml @@ -33,6 +33,7 @@ + @@ -58,7 +59,7 @@ - + diff --git a/assets/xml/objects/object_in.xml b/assets/xml/objects/object_in.xml index 3874e4834..15b2382aa 100644 --- a/assets/xml/objects/object_in.xml +++ b/assets/xml/objects/object_in.xml @@ -112,7 +112,7 @@ - + diff --git a/assets/xml/objects/object_in2.xml b/assets/xml/objects/object_in2.xml index 4457defae..bcd04091b 100644 --- a/assets/xml/objects/object_in2.xml +++ b/assets/xml/objects/object_in2.xml @@ -66,7 +66,7 @@ - + diff --git a/assets/xml/objects/object_jg.xml b/assets/xml/objects/object_jg.xml index 17889995f..c3e1ac18a 100644 --- a/assets/xml/objects/object_jg.xml +++ b/assets/xml/objects/object_jg.xml @@ -108,11 +108,11 @@ - + - + diff --git a/assets/xml/objects/object_js.xml b/assets/xml/objects/object_js.xml index 92f14da0b..1335b8287 100644 --- a/assets/xml/objects/object_js.xml +++ b/assets/xml/objects/object_js.xml @@ -39,7 +39,7 @@ - + diff --git a/assets/xml/objects/object_jso.xml b/assets/xml/objects/object_jso.xml index 33816a797..a397311c4 100644 --- a/assets/xml/objects/object_jso.xml +++ b/assets/xml/objects/object_jso.xml @@ -49,7 +49,7 @@ - + @@ -114,7 +114,7 @@ - + diff --git a/assets/xml/objects/object_ka.xml b/assets/xml/objects/object_ka.xml index 36dceb0ca..69ea2d929 100644 --- a/assets/xml/objects/object_ka.xml +++ b/assets/xml/objects/object_ka.xml @@ -58,7 +58,7 @@ - + diff --git a/assets/xml/objects/object_kaizoku_obj.xml b/assets/xml/objects/object_kaizoku_obj.xml index 8dd96770a..6a7457e1c 100644 --- a/assets/xml/objects/object_kaizoku_obj.xml +++ b/assets/xml/objects/object_kaizoku_obj.xml @@ -2,8 +2,8 @@ - - + + diff --git a/assets/xml/objects/object_kamejima.xml b/assets/xml/objects/object_kamejima.xml index 9b45ad478..e8368051d 100644 --- a/assets/xml/objects/object_kamejima.xml +++ b/assets/xml/objects/object_kamejima.xml @@ -1,5 +1,8 @@  + + + @@ -66,7 +69,7 @@ - + diff --git a/assets/xml/objects/object_kbt.xml b/assets/xml/objects/object_kbt.xml index aad49e946..102aed91d 100644 --- a/assets/xml/objects/object_kbt.xml +++ b/assets/xml/objects/object_kbt.xml @@ -68,7 +68,7 @@ - + diff --git a/assets/xml/objects/object_keikoku_demo.xml b/assets/xml/objects/object_keikoku_demo.xml index 994b682f3..3a0a20b65 100644 --- a/assets/xml/objects/object_keikoku_demo.xml +++ b/assets/xml/objects/object_keikoku_demo.xml @@ -1,21 +1,65 @@  + + - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/assets/xml/objects/object_kgy.xml b/assets/xml/objects/object_kgy.xml index 0e2d3be2c..5bbf17793 100644 --- a/assets/xml/objects/object_kgy.xml +++ b/assets/xml/objects/object_kgy.xml @@ -67,7 +67,7 @@ - + diff --git a/assets/xml/objects/object_kin2_obj.xml b/assets/xml/objects/object_kin2_obj.xml index 93e55786c..e0ae09106 100644 --- a/assets/xml/objects/object_kin2_obj.xml +++ b/assets/xml/objects/object_kin2_obj.xml @@ -1,34 +1,34 @@  - - - - + + + + - + - - + + - - + + - + - - - - - - - - - - + + + + + + + + + + diff --git a/assets/xml/objects/object_kitan.xml b/assets/xml/objects/object_kitan.xml index 05d090d93..edc2e5cc6 100644 --- a/assets/xml/objects/object_kitan.xml +++ b/assets/xml/objects/object_kitan.xml @@ -49,6 +49,6 @@ - + diff --git a/assets/xml/objects/object_knight.xml b/assets/xml/objects/object_knight.xml index 0459cb062..fa0e900e4 100644 --- a/assets/xml/objects/object_knight.xml +++ b/assets/xml/objects/object_knight.xml @@ -171,7 +171,7 @@ - + @@ -200,7 +200,7 @@ - + diff --git a/assets/xml/objects/object_kz.xml b/assets/xml/objects/object_kz.xml index 2b714be38..55f980ad2 100644 --- a/assets/xml/objects/object_kz.xml +++ b/assets/xml/objects/object_kz.xml @@ -75,7 +75,7 @@ - + diff --git a/assets/xml/objects/object_lastday.xml b/assets/xml/objects/object_lastday.xml index 9988ec1f8..e447edfbf 100644 --- a/assets/xml/objects/object_lastday.xml +++ b/assets/xml/objects/object_lastday.xml @@ -1,5 +1,8 @@  + + + diff --git a/assets/xml/objects/object_link_boy.xml b/assets/xml/objects/object_link_boy.xml index b0a85ece5..68ec00737 100644 --- a/assets/xml/objects/object_link_boy.xml +++ b/assets/xml/objects/object_link_boy.xml @@ -76,6 +76,6 @@ - + diff --git a/assets/xml/objects/object_link_child.xml b/assets/xml/objects/object_link_child.xml index 51145033c..5ad903048 100644 --- a/assets/xml/objects/object_link_child.xml +++ b/assets/xml/objects/object_link_child.xml @@ -151,6 +151,6 @@ - + diff --git a/assets/xml/objects/object_link_goron.xml b/assets/xml/objects/object_link_goron.xml index 2fe3906fb..39686b4f7 100644 --- a/assets/xml/objects/object_link_goron.xml +++ b/assets/xml/objects/object_link_goron.xml @@ -35,7 +35,7 @@ - + @@ -62,7 +62,7 @@ - + @@ -72,7 +72,7 @@ - + @@ -80,7 +80,7 @@ - + @@ -103,6 +103,6 @@ - + diff --git a/assets/xml/objects/object_link_nuts.xml b/assets/xml/objects/object_link_nuts.xml index e3dab39da..eb072c940 100644 --- a/assets/xml/objects/object_link_nuts.xml +++ b/assets/xml/objects/object_link_nuts.xml @@ -74,6 +74,6 @@ - + diff --git a/assets/xml/objects/object_link_zora.xml b/assets/xml/objects/object_link_zora.xml index d36aaa420..9a973c56a 100644 --- a/assets/xml/objects/object_link_zora.xml +++ b/assets/xml/objects/object_link_zora.xml @@ -56,7 +56,14 @@ - + + + + + + + + @@ -84,6 +91,6 @@ - + diff --git a/assets/xml/objects/object_ma1.xml b/assets/xml/objects/object_ma1.xml index 3d0ea1fcc..b0b1435bc 100644 --- a/assets/xml/objects/object_ma1.xml +++ b/assets/xml/objects/object_ma1.xml @@ -1,96 +1,116 @@  + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/assets/xml/objects/object_ma2.xml b/assets/xml/objects/object_ma2.xml index a61eff4e0..0d528b37b 100644 --- a/assets/xml/objects/object_ma2.xml +++ b/assets/xml/objects/object_ma2.xml @@ -1,85 +1,101 @@  + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 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 1ee3741bb..087fcc9e0 100644 --- a/assets/xml/objects/object_mk.xml +++ b/assets/xml/objects/object_mk.xml @@ -40,6 +40,6 @@ - + diff --git a/assets/xml/objects/object_mm.xml b/assets/xml/objects/object_mm.xml index baac5425d..43e8e930b 100644 --- a/assets/xml/objects/object_mm.xml +++ b/assets/xml/objects/object_mm.xml @@ -54,7 +54,7 @@ - + diff --git a/assets/xml/objects/object_mnk.xml b/assets/xml/objects/object_mnk.xml index c6e23399d..d585972c0 100644 --- a/assets/xml/objects/object_mnk.xml +++ b/assets/xml/objects/object_mnk.xml @@ -23,7 +23,7 @@ - + @@ -104,7 +104,7 @@ - + @@ -121,6 +121,6 @@ - + diff --git a/assets/xml/objects/object_ms.xml b/assets/xml/objects/object_ms.xml index a4a36e149..93828c76f 100644 --- a/assets/xml/objects/object_ms.xml +++ b/assets/xml/objects/object_ms.xml @@ -27,6 +27,6 @@ - + diff --git a/assets/xml/objects/object_mu.xml b/assets/xml/objects/object_mu.xml index 925cb74e9..1f246b07b 100644 --- a/assets/xml/objects/object_mu.xml +++ b/assets/xml/objects/object_mu.xml @@ -56,7 +56,7 @@ - + diff --git a/assets/xml/objects/object_nb.xml b/assets/xml/objects/object_nb.xml index e8a695b52..511fddd6c 100644 --- a/assets/xml/objects/object_nb.xml +++ b/assets/xml/objects/object_nb.xml @@ -41,6 +41,6 @@ - + diff --git a/assets/xml/objects/object_niw.xml b/assets/xml/objects/object_niw.xml index e49426560..157d2b302 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_nnh.xml b/assets/xml/objects/object_nnh.xml index 1bb833cf0..f7f546e25 100644 --- a/assets/xml/objects/object_nnh.xml +++ b/assets/xml/objects/object_nnh.xml @@ -1,10 +1,15 @@  + + - - - - - - + + + + + + + + + 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 6c3af0778..0f331cbce 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 0f79703b5..75217e04e 100644 --- a/assets/xml/objects/object_ob.xml +++ b/assets/xml/objects/object_ob.xml @@ -76,7 +76,7 @@ - + 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 e71f65a1c..cad1c57bd 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 b31660e6a..dbcdb8473 100644 --- a/assets/xml/objects/object_osn.xml +++ b/assets/xml/objects/object_osn.xml @@ -110,8 +110,8 @@ - + - + diff --git a/assets/xml/objects/object_ot.xml b/assets/xml/objects/object_ot.xml index 49a8d89ce..ae3b42d22 100644 --- a/assets/xml/objects/object_ot.xml +++ b/assets/xml/objects/object_ot.xml @@ -48,7 +48,7 @@ - + diff --git a/assets/xml/objects/object_owl.xml b/assets/xml/objects/object_owl.xml index 6c9d79883..5560e3347 100644 --- a/assets/xml/objects/object_owl.xml +++ b/assets/xml/objects/object_owl.xml @@ -57,7 +57,7 @@ - + @@ -90,6 +90,6 @@ - + diff --git a/assets/xml/objects/object_pamera.xml b/assets/xml/objects/object_pamera.xml index 6b457ab8b..61dc17694 100644 --- a/assets/xml/objects/object_pamera.xml +++ b/assets/xml/objects/object_pamera.xml @@ -1,26 +1,28 @@  - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + @@ -38,29 +40,31 @@ - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/assets/xml/objects/object_ph.xml b/assets/xml/objects/object_ph.xml index 2e8a8eb29..fcf03b765 100644 --- a/assets/xml/objects/object_ph.xml +++ b/assets/xml/objects/object_ph.xml @@ -39,6 +39,6 @@ - + diff --git a/assets/xml/objects/object_po.xml b/assets/xml/objects/object_po.xml index 2cc6e5cbd..98dbc61b1 100644 --- a/assets/xml/objects/object_po.xml +++ b/assets/xml/objects/object_po.xml @@ -48,6 +48,6 @@ - + diff --git a/assets/xml/objects/object_po_composer.xml b/assets/xml/objects/object_po_composer.xml index ae8ef56e3..c45cf9039 100644 --- a/assets/xml/objects/object_po_composer.xml +++ b/assets/xml/objects/object_po_composer.xml @@ -53,6 +53,6 @@ - + diff --git a/assets/xml/objects/object_po_fusen.xml b/assets/xml/objects/object_po_fusen.xml index 5885b89a3..a25c9d960 100644 --- a/assets/xml/objects/object_po_fusen.xml +++ b/assets/xml/objects/object_po_fusen.xml @@ -27,6 +27,6 @@ - + diff --git a/assets/xml/objects/object_po_sisters.xml b/assets/xml/objects/object_po_sisters.xml index f42fe1664..e2e57a31a 100644 --- a/assets/xml/objects/object_po_sisters.xml +++ b/assets/xml/objects/object_po_sisters.xml @@ -1,53 +1,70 @@  + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/assets/xml/objects/object_pp.xml b/assets/xml/objects/object_pp.xml index 1ac690935..dc51c202c 100644 --- a/assets/xml/objects/object_pp.xml +++ b/assets/xml/objects/object_pp.xml @@ -1,131 +1,153 @@  + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/assets/xml/objects/object_pr.xml b/assets/xml/objects/object_pr.xml index 95fc4743c..52429cb18 100644 --- a/assets/xml/objects/object_pr.xml +++ b/assets/xml/objects/object_pr.xml @@ -40,7 +40,7 @@ - + @@ -55,7 +55,7 @@ - + diff --git a/assets/xml/objects/object_ps.xml b/assets/xml/objects/object_ps.xml index f341e95a4..689d78fb5 100644 --- a/assets/xml/objects/object_ps.xml +++ b/assets/xml/objects/object_ps.xml @@ -33,7 +33,7 @@ - + diff --git a/assets/xml/objects/object_pst.xml b/assets/xml/objects/object_pst.xml index 3649877ea..d2b5323d6 100644 --- a/assets/xml/objects/object_pst.xml +++ b/assets/xml/objects/object_pst.xml @@ -1,14 +1,15 @@  + - - - - - - - - - - + + + + + + + + + + diff --git a/assets/xml/objects/object_raf.xml b/assets/xml/objects/object_raf.xml index 26c0741ec..2322740d5 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 ce32e20cc..af47a3437 100644 --- a/assets/xml/objects/object_rat.xml +++ b/assets/xml/objects/object_rat.xml @@ -1,28 +1,38 @@  + - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/assets/xml/objects/object_rb.xml b/assets/xml/objects/object_rb.xml index 72b3e6cb6..cd0e9c274 100644 --- a/assets/xml/objects/object_rb.xml +++ b/assets/xml/objects/object_rb.xml @@ -48,6 +48,6 @@ - + diff --git a/assets/xml/objects/object_rd.xml b/assets/xml/objects/object_rd.xml index 854ded388..cb16e492f 100644 --- a/assets/xml/objects/object_rd.xml +++ b/assets/xml/objects/object_rd.xml @@ -45,7 +45,7 @@ - + @@ -105,7 +105,7 @@ - + diff --git a/assets/xml/objects/object_rotlift.xml b/assets/xml/objects/object_rotlift.xml index 403f7d3dd..da5db27d7 100644 --- a/assets/xml/objects/object_rotlift.xml +++ b/assets/xml/objects/object_rotlift.xml @@ -1,16 +1,20 @@  + - - - - - - - - - - - - + + + + + + + + + + + + + + + diff --git a/assets/xml/objects/object_rs.xml b/assets/xml/objects/object_rs.xml index 01099db47..5334f4fb8 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 f2d3fd2b0..08f182bb9 100644 --- a/assets/xml/objects/object_ru2.xml +++ b/assets/xml/objects/object_ru2.xml @@ -68,7 +68,7 @@ - + diff --git a/assets/xml/objects/object_rz.xml b/assets/xml/objects/object_rz.xml index a75e033f0..d8740403a 100644 --- a/assets/xml/objects/object_rz.xml +++ b/assets/xml/objects/object_rz.xml @@ -66,6 +66,6 @@ - + diff --git a/assets/xml/objects/object_sb.xml b/assets/xml/objects/object_sb.xml index 359cff20d..026b3389b 100644 --- a/assets/xml/objects/object_sb.xml +++ b/assets/xml/objects/object_sb.xml @@ -24,7 +24,7 @@ - + diff --git a/assets/xml/objects/object_sdn.xml b/assets/xml/objects/object_sdn.xml index 219436b02..8271480be 100644 --- a/assets/xml/objects/object_sdn.xml +++ b/assets/xml/objects/object_sdn.xml @@ -44,23 +44,23 @@ - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + diff --git a/assets/xml/objects/object_sekihig.xml b/assets/xml/objects/object_sekihig.xml index dab91d71b..bb995bed4 100644 --- a/assets/xml/objects/object_sekihig.xml +++ b/assets/xml/objects/object_sekihig.xml @@ -1,16 +1,16 @@  - - - - - + + + + + - - - - - - + + + + + + diff --git a/assets/xml/objects/object_sekihil.xml b/assets/xml/objects/object_sekihil.xml index e3c7bcc42..fb9903875 100644 --- a/assets/xml/objects/object_sekihil.xml +++ b/assets/xml/objects/object_sekihil.xml @@ -1,16 +1,16 @@  - + - + - - - - - - - + + + + + + + diff --git a/assets/xml/objects/object_sekihin.xml b/assets/xml/objects/object_sekihin.xml index f2982169b..104f5f133 100644 --- a/assets/xml/objects/object_sekihin.xml +++ b/assets/xml/objects/object_sekihin.xml @@ -1,17 +1,17 @@  - - - - + + + + - + - - - - - - + + + + + + diff --git a/assets/xml/objects/object_sekihiz.xml b/assets/xml/objects/object_sekihiz.xml index 0f8ef7c43..9563d8b42 100644 --- a/assets/xml/objects/object_sekihiz.xml +++ b/assets/xml/objects/object_sekihiz.xml @@ -1,9 +1,9 @@  - - - - - + + + + + diff --git a/assets/xml/objects/object_shn.xml b/assets/xml/objects/object_shn.xml index 1b94600ab..c4b256f68 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_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 c9935b64f..78413a9de 100644 --- a/assets/xml/objects/object_skb.xml +++ b/assets/xml/objects/object_skb.xml @@ -55,7 +55,7 @@ - + diff --git a/assets/xml/objects/object_snowman.xml b/assets/xml/objects/object_snowman.xml index 91b650a75..dd5f42c17 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 57599fdce..29cd1fab1 100644 --- a/assets/xml/objects/object_ssh.xml +++ b/assets/xml/objects/object_ssh.xml @@ -58,7 +58,7 @@ - + diff --git a/assets/xml/objects/object_st.xml b/assets/xml/objects/object_st.xml index 2dabce2f8..cbb01d3c5 100644 --- a/assets/xml/objects/object_st.xml +++ b/assets/xml/objects/object_st.xml @@ -33,8 +33,8 @@ - - + + @@ -64,7 +64,7 @@ - + diff --git a/assets/xml/objects/object_sth.xml b/assets/xml/objects/object_sth.xml index c7a0ffd25..b176cd8cc 100644 --- a/assets/xml/objects/object_sth.xml +++ b/assets/xml/objects/object_sth.xml @@ -37,6 +37,6 @@ - + diff --git a/assets/xml/objects/object_stk.xml b/assets/xml/objects/object_stk.xml index 68e8ae26b..a6f00c89b 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..d526bbc5c 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_tab.xml b/assets/xml/objects/object_tab.xml index 9a63c2ed3..0a984b284 100644 --- a/assets/xml/objects/object_tab.xml +++ b/assets/xml/objects/object_tab.xml @@ -57,7 +57,7 @@ - + diff --git a/assets/xml/objects/object_tanron4.xml b/assets/xml/objects/object_tanron4.xml index 2c988e74b..491e9a587 100644 --- a/assets/xml/objects/object_tanron4.xml +++ b/assets/xml/objects/object_tanron4.xml @@ -25,6 +25,6 @@ - + diff --git a/assets/xml/objects/object_taru.xml b/assets/xml/objects/object_taru.xml index 763fe1b2e..4a23d2923 100644 --- a/assets/xml/objects/object_taru.xml +++ b/assets/xml/objects/object_taru.xml @@ -1,12 +1,12 @@  - - - + + + - - - + + + diff --git a/assets/xml/objects/object_test3.xml b/assets/xml/objects/object_test3.xml index 6b0a5349c..efd018995 100644 --- a/assets/xml/objects/object_test3.xml +++ b/assets/xml/objects/object_test3.xml @@ -63,6 +63,6 @@ - + diff --git a/assets/xml/objects/object_thiefbird.xml b/assets/xml/objects/object_thiefbird.xml index e7cb3ac91..5a4cec335 100644 --- a/assets/xml/objects/object_thiefbird.xml +++ b/assets/xml/objects/object_thiefbird.xml @@ -1,66 +1,84 @@  + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/assets/xml/objects/object_tite.xml b/assets/xml/objects/object_tite.xml index 681b732e8..351b4f56a 100644 --- a/assets/xml/objects/object_tite.xml +++ b/assets/xml/objects/object_tite.xml @@ -49,6 +49,6 @@ - + diff --git a/assets/xml/objects/object_tk.xml b/assets/xml/objects/object_tk.xml index 0c0ea3831..b11b47488 100644 --- a/assets/xml/objects/object_tk.xml +++ b/assets/xml/objects/object_tk.xml @@ -60,6 +60,6 @@ - + diff --git a/assets/xml/objects/object_tl.xml b/assets/xml/objects/object_tl.xml index 6397283af..7f0cfd756 100644 --- a/assets/xml/objects/object_tl.xml +++ b/assets/xml/objects/object_tl.xml @@ -10,7 +10,7 @@ - + @@ -55,7 +55,7 @@ - + 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 45d3da100..e19f2c540 100644 --- a/assets/xml/objects/object_toryo.xml +++ b/assets/xml/objects/object_toryo.xml @@ -48,6 +48,6 @@ - + diff --git a/assets/xml/objects/object_trt.xml b/assets/xml/objects/object_trt.xml index a0d83076e..c7fb81321 100644 --- a/assets/xml/objects/object_trt.xml +++ b/assets/xml/objects/object_trt.xml @@ -89,6 +89,6 @@ - + diff --git a/assets/xml/objects/object_tru.xml b/assets/xml/objects/object_tru.xml index dd0e6d20c..138723ceb 100644 --- a/assets/xml/objects/object_tru.xml +++ b/assets/xml/objects/object_tru.xml @@ -102,7 +102,7 @@ - + diff --git a/assets/xml/objects/object_tsn.xml b/assets/xml/objects/object_tsn.xml index 761a6e0d7..d610b185e 100644 --- a/assets/xml/objects/object_tsn.xml +++ b/assets/xml/objects/object_tsn.xml @@ -47,7 +47,7 @@ - + diff --git a/assets/xml/objects/object_uch.xml b/assets/xml/objects/object_uch.xml index a58af5654..d82bf5b10 100644 --- a/assets/xml/objects/object_uch.xml +++ b/assets/xml/objects/object_uch.xml @@ -1,46 +1,64 @@  + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/assets/xml/objects/object_um.xml b/assets/xml/objects/object_um.xml index 5717124a7..aac86a9a7 100644 --- a/assets/xml/objects/object_um.xml +++ b/assets/xml/objects/object_um.xml @@ -10,26 +10,31 @@ - + + + - + - + + + + @@ -49,31 +54,35 @@ - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -85,7 +94,19 @@ - + + + + + + + + + + + + + @@ -100,6 +121,6 @@ - + diff --git a/assets/xml/objects/object_utubo.xml b/assets/xml/objects/object_utubo.xml index a1f499eb6..4ce3d64f0 100644 --- a/assets/xml/objects/object_utubo.xml +++ b/assets/xml/objects/object_utubo.xml @@ -42,7 +42,7 @@ - + diff --git a/assets/xml/objects/object_vm.xml b/assets/xml/objects/object_vm.xml index b6c1cdfa2..bf13f3b40 100644 --- a/assets/xml/objects/object_vm.xml +++ b/assets/xml/objects/object_vm.xml @@ -25,6 +25,6 @@ - + diff --git a/assets/xml/objects/object_wallmaster.xml b/assets/xml/objects/object_wallmaster.xml index fba2bc246..afe3843e3 100644 --- a/assets/xml/objects/object_wallmaster.xml +++ b/assets/xml/objects/object_wallmaster.xml @@ -65,7 +65,7 @@ - + diff --git a/assets/xml/objects/object_warp1.xml b/assets/xml/objects/object_warp1.xml index 814334792..6ac25e827 100644 --- a/assets/xml/objects/object_warp1.xml +++ b/assets/xml/objects/object_warp1.xml @@ -32,7 +32,7 @@ - + diff --git a/assets/xml/objects/object_wdhand.xml b/assets/xml/objects/object_wdhand.xml index bcd5b0ce3..311d9299f 100644 --- a/assets/xml/objects/object_wdhand.xml +++ b/assets/xml/objects/object_wdhand.xml @@ -23,6 +23,6 @@ - + diff --git a/assets/xml/objects/object_wf.xml b/assets/xml/objects/object_wf.xml index 4775552e2..b6c5b640d 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 d9c8a1589..2928083aa 100644 --- a/assets/xml/objects/object_wiz.xml +++ b/assets/xml/objects/object_wiz.xml @@ -8,7 +8,7 @@ - + @@ -40,11 +40,11 @@ - + - + @@ -97,6 +97,6 @@ - + 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 1a8503a6e..3bbfc7cce 100644 --- a/assets/xml/objects/object_yb.xml +++ b/assets/xml/objects/object_yb.xml @@ -56,6 +56,6 @@ - + diff --git a/assets/xml/objects/object_zl1.xml b/assets/xml/objects/object_zl1.xml index 04d4ae406..2b8a101bc 100644 --- a/assets/xml/objects/object_zl1.xml +++ b/assets/xml/objects/object_zl1.xml @@ -74,7 +74,7 @@ - + diff --git a/assets/xml/objects/object_zl4.xml b/assets/xml/objects/object_zl4.xml index dafdef8cd..73ebb8606 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 f6f1b95e5..c35d5aecb 100644 --- a/assets/xml/objects/object_zm.xml +++ b/assets/xml/objects/object_zm.xml @@ -55,7 +55,7 @@ - + diff --git a/assets/xml/objects/object_zo.xml b/assets/xml/objects/object_zo.xml index 8fc22ae46..0cd5c8546 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 bc4d61c6a..8d27f260f 100644 --- a/assets/xml/objects/object_zob.xml +++ b/assets/xml/objects/object_zob.xml @@ -67,7 +67,7 @@ - + diff --git a/assets/xml/objects/object_zod.xml b/assets/xml/objects/object_zod.xml index 3e0b6567a..2616dbcdf 100644 --- a/assets/xml/objects/object_zod.xml +++ b/assets/xml/objects/object_zod.xml @@ -44,7 +44,7 @@ - + diff --git a/assets/xml/objects/object_zog.xml b/assets/xml/objects/object_zog.xml index 627bb676a..1ede14ad2 100644 --- a/assets/xml/objects/object_zog.xml +++ b/assets/xml/objects/object_zog.xml @@ -9,17 +9,17 @@ - - - - - - - - - - - + + + + + + + + + + + @@ -107,6 +107,6 @@ - + diff --git a/assets/xml/objects/object_zoraegg.xml b/assets/xml/objects/object_zoraegg.xml index 367d2df76..175c6aeb2 100644 --- a/assets/xml/objects/object_zoraegg.xml +++ b/assets/xml/objects/object_zoraegg.xml @@ -22,7 +22,7 @@ - + diff --git a/assets/xml/objects/object_zos.xml b/assets/xml/objects/object_zos.xml index 1f5a2a542..016831ac5 100644 --- a/assets/xml/objects/object_zos.xml +++ b/assets/xml/objects/object_zos.xml @@ -62,7 +62,7 @@ - + diff --git a/assets/xml/objects/object_zov.xml b/assets/xml/objects/object_zov.xml index abbc52268..440782f10 100644 --- a/assets/xml/objects/object_zov.xml +++ b/assets/xml/objects/object_zov.xml @@ -76,6 +76,6 @@ - + diff --git a/assets/xml/overlays/ovl_Effect_Ss_Fhg_Flash.xml b/assets/xml/overlays/ovl_Effect_Ss_Fhg_Flash.xml new file mode 100644 index 000000000..0c23d17cd --- /dev/null +++ b/assets/xml/overlays/ovl_Effect_Ss_Fhg_Flash.xml @@ -0,0 +1,6 @@ + + + + + + diff --git a/assets/xml/overlays/ovl_En_Bigslime.xml b/assets/xml/overlays/ovl_En_Bigslime.xml index 9526daea6..fe92a87fb 100644 --- a/assets/xml/overlays/ovl_En_Bigslime.xml +++ b/assets/xml/overlays/ovl_En_Bigslime.xml @@ -1,20 +1,14 @@ - + - - - - - - diff --git a/assets/xml/overlays/ovl_En_Bom.xml b/assets/xml/overlays/ovl_En_Bom.xml index 08902add6..15bfa097c 100644 --- a/assets/xml/overlays/ovl_En_Bom.xml +++ b/assets/xml/overlays/ovl_En_Bom.xml @@ -1,9 +1,20 @@ + - - - - - + + + + + + + + + + + + + + + diff --git a/assets/xml/overlays/ovl_En_Sth2.xml b/assets/xml/overlays/ovl_En_Sth2.xml new file mode 100644 index 000000000..23140ad71 --- /dev/null +++ b/assets/xml/overlays/ovl_En_Sth2.xml @@ -0,0 +1,14 @@ + + + + + + + + + + + + + + diff --git a/assets/xml/overlays/ovl_En_Syateki_Okuta.xml b/assets/xml/overlays/ovl_En_Syateki_Okuta.xml index 0f4de7c4e..0e5054c19 100644 --- a/assets/xml/overlays/ovl_En_Syateki_Okuta.xml +++ b/assets/xml/overlays/ovl_En_Syateki_Okuta.xml @@ -1,13 +1,13 @@ - - - - - - - - + + + + + + + + diff --git a/assets/xml/overlays/ovl_Obj_Jgame_Light.xml b/assets/xml/overlays/ovl_Obj_Jgame_Light.xml new file mode 100644 index 000000000..e6b740aca --- /dev/null +++ b/assets/xml/overlays/ovl_Obj_Jgame_Light.xml @@ -0,0 +1,12 @@ + + + + + + + + + + + + diff --git a/assets/xml/overlays/ovl_Obj_Toudai.xml b/assets/xml/overlays/ovl_Obj_Toudai.xml new file mode 100644 index 000000000..989c47a72 --- /dev/null +++ b/assets/xml/overlays/ovl_Obj_Toudai.xml @@ -0,0 +1,7 @@ + + + + + + + diff --git a/assets/xml/overlays/ovl_Oceff_Wipe7.xml b/assets/xml/overlays/ovl_Oceff_Wipe7.xml new file mode 100644 index 000000000..682bd0c98 --- /dev/null +++ b/assets/xml/overlays/ovl_Oceff_Wipe7.xml @@ -0,0 +1,10 @@ + + + + + + + + + + diff --git a/docs/BUILDING_DOCKER.md b/docs/BUILDING_DOCKER.md new file mode 100644 index 000000000..5fa7b4865 --- /dev/null +++ b/docs/BUILDING_DOCKER.md @@ -0,0 +1,47 @@ +# Building using Docker + +## Dependencies + +You will need [Docker](https://docs.docker.com/get-docker/) Follow the instructions for your operating system. + +## 1. Clone the Repository + +You will need to prepare a local version of the project with a copied base ROM (see steps [2](../README.md#2-clone-the-repository) and [4](../README.md#4-prepare-a-base-rom) of the Linux instructions). + +## 2. Create the Docker image + +From inside your local project, run the following command: + +```bash +docker build . -t mm +``` + +This will build a docker image with the name of `mm`, to verify the image was made you can run the command + +```bash +docker image ls +``` + +and look for `mm` under the "REPOSITORY" column. + +## 3. Start the container + +To start the container, you can mount your local filesystem into the Docker container and run an interactive bash session. + +```bash +docker run -it --rm --mount type=bind,source="$(pwd)",destination=/mm mm /bin/bash +``` + +- The `-it` flags Keep STDIN open even if not attached to the container and allocates a pseudo-tty terminal. +- The `--rm` flags causes Docker to automatically remove the container when it exits. +- The `--mount` flag allows you to mount volumes and host-directories in a container. By specifying the type to be a bind, we are saying there are files to be mounted from the host machine (the one that runs your docker daemon) onto the container. Source is specifying where we are mounting the files from in this case, we want the `mm` folder created earlier. The $(pwd) sub-command expands to the current working directory. The destination takes as its value the path where the file or directory is mounted in the container. This makes it so that the image should rarely change and will reduce the need to rebuild with any change to the codebase. + +## 4. Setup and Build the ROM + +Once inside the container, you will need to set the repository as a trusted repository with the following command: + +```bash +git config --global --add safe.directory /mm +``` + +After that continue with step [5. Make and Build the ROM](../README.md#5-make-and-build-the-rom) of the Linux instructions to setup and build the ROM, or run any other command you need. diff --git a/docs/BUILDING_MACOS.md b/docs/BUILDING_MACOS.md index 77f1d839e..8a5aa20a3 100644 --- a/docs/BUILDING_MACOS.md +++ b/docs/BUILDING_MACOS.md @@ -2,7 +2,6 @@ **N.B. C++17 is required to build the asset processing program that we use (ZAPD), so check your OS version can support this before proceeding** - ## Dependencies For macOS, use Homebrew to install the following dependencies: @@ -23,59 +22,66 @@ brew install coreutils make python3 libpng bash clang-format@11 (The repository expects Homebrew-installed programs to be either linked correctly in `$PATH` etc. or in their default locations.) - ## Building mips-linux-binutils The following instructions are written for MacOS users but should apply to any Unix-like system, with maybe some modifications at the end regarding the bash_profile. Create destination dir for binutils + ```bash sudo mkdir -p /opt/cross ``` Create and enter local working dir + ```bash mkdir ~/binutils-tmp cd ~/binutils-tmp ``` Get and extract binutils source + ```bash wget https://ftp.gnu.org/gnu/binutils/binutils-2.35.tar.bz2 tar xjf binutils-2.35.tar.bz2 ``` + (You may find this command does not work: if so, just access the URL in a browser and save it to `~/binutils-tmp`.) Create and enter a build directory + ```bash mkdir build-binutils cd build-binutils ``` Configure the build + ```bash ../binutils-2.35/configure --target=mips-linux-gnu --prefix=/opt/cross --disable-gprof --disable-gdb --disable-werror ``` Make and install binutils + ```bash make -j sudo make install ``` Edit your `~/.bash_profile`/`~/.zsh_profile` (or whichever shell you use) to add the new binutils binaries to the system PATH + ```bash echo "export PATH=$PATH:/opt/cross/bin" >> ~/.bash_profile ``` Reload ~/.bash_profile (or just launch a new terminal tab) + ```bash source ~/.bash_profile ``` If this worked, you can now delete the temporary directory `~/binutils-tmp`. - ## Final note Apple's version of `make` is very out-of-date, so you should use the brew-installed `gmake` in place of `make` in this repo from now on. diff --git a/docs/CONTRIBUTING.md b/docs/CONTRIBUTING.md new file mode 100644 index 000000000..493486e79 --- /dev/null +++ b/docs/CONTRIBUTING.md @@ -0,0 +1,149 @@ +# 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. + +This document is meant to be a set of tips and guidelines for contributing 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 + +- [Installation guide](https://github.com/zeldaret/mm/blob/master/README.md#installation) - Instructions for getting this repository set up and built on your machine. +- [Style Guide](STYLE.md) - Description of the project style that we ask contributors to adhere to. +- [Code Review Guidelines](REVIEWING.md) - These are the guidelines that reviewers will be using when reviewing your code. Good to be familiar with these before submitting your code. + +- [Zelda 64 Reverse Engineering Website](https://zelda64.dev/mm) - Our homepage, with FAQ and progress graph :chart_with_upwards_trend:. +- [MM decomp tutorial](tutorial/contents.md) Detailed tutorial for learning in general how decomp works and how to decompile a small, simple file. +- [Introduction to OOT decomp](https://github.com/zeldaret/oot/blob/master/docs/tutorial/contents.md) - The tutorial the MM one was based on. For OOT, but largely applicable to MM as well. Covers slightly different topics, including how to get your data OK with `vbindiff`. +- The `#resources` channel on the Discord contains many more links on specific details of decompiling IDO MIPS code. + +## Getting Started + +### What should I know to take part? + +Basic knowledge of C, particularly arrays and pointers, is extremely useful. Knowledge of MIPS is not required initially, you can pick it up as you work through some decompilation. + +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 [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*. + +**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 + +Get started by following the [installation guide in the readme](https://github.com/zeldaret/mm/blob/master/README.md#installation). +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. Actors are good for a first file because they are generally small, self-contained systems. + +We recommend that you [join the Discord](https://discord.zelda64.dev/) to say hello and get suggestions on where to start on the `#mm-decomp` channel. + +We track who is working on what on some Google Sheets available in the Discord. Once you've decided on or been recommended a good first file, mark it as Reserved. + +The workflow is: + +- Reserve a file, +- decompile it, +- submit a PR, +- repeat while addressing review comments. + +The expectation is that one reservation goes to one file which ends up in a one file PR, although naturally some files are more sensibly worked on as a group, for example two actors that work together. This also does not apply to large asset files like `gameplay_keep`: you can just reserve the parts that are used in your files. + +If possible, we expect reserved files to be completed. If you find you cannot complete a file, because it is intractable for one reason or another, or real-life circumstances get in the way, please talk to one of the leads in Discord; we may find someone else interested in helping you finish, or who is happy to take over the file from you completely. If you unreserve a file on which you have useful progress, please leave a link to your branch in the Notes column on the Google Sheet that the next person who works on the file can use. + +## Style Guide & Conventions + +See the [Style Guide](STYLE.md). + +## `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: + +```c +#ifdef NON_MATCHING +void CollisionCheck_SpawnWaterDroplets(PlayState* play, Vec3f* v) { + // ... +} +#else +void CollisionCheck_SpawnWaterDroplets(PlayState* play, Vec3f* v); +#pragma GLOBAL_ASM("asm/non_matchings/code/z_collision_check/CollisionCheck_SpawnWaterDroplets.s") +#endif +``` + +Before PRing with a `NON_MATCHING`, you can try + +- using the [decomp-permuter](https://github.com/simonlindholm/decomp-permuter) to find a closer match, +- Asking in `#mm-decomp-help` in Discord; the easiest way to allow other people to play around with the function you are stuck on is to make a scratch on [decomp.me](http://decomp.me). + +`NON_EQUIVALENT` can be used with the same syntax as `NON_MATCHING`, but it is used to mark sections of code which do not match *and* do not have the same behavior as the original code. + +## 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. +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: + +- Renaming functions, variables, and struct members +- 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 files from `code/` and `boot/` should be documented. When documentation on a file has been started it should be as complete as reasonable. + +See the [Style Guide](STYLE.md) for more details on documentation style. + +## 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. + +- `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. +- Comments and variables have correct spelling. + +Feel free to reach out on the Discord if you have any questions about these steps or encounter any issues. + +### Pull Request Process + +After opening a PR, the Jenkins agent will test formatting, the contents of the spec, build the rom and check for warnings. +If there is an error, double-check that you can successfully + +```bash +make disasm +./extract_assets.py -f +make clean +make +``` + +locally. If the build is `OK`, the next thing to check is that all added/modified files were `git add`-ed to your commit. The final check before posting on Discord for help is that there are no new warnings added to the code causing Jenkins to fail. You can check this by running: `tools/warnings_count/check_new_warnings.sh`. + +Each PR needs a review from two reviewers, at least one a project lead, and final approval from Kenix. + +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. + +Once all comments is addressed and all reviewers have approved, the PR will be merged. + +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/docs/REVIEWING.md b/docs/REVIEWING.md new file mode 100644 index 000000000..8b70f2711 --- /dev/null +++ b/docs/REVIEWING.md @@ -0,0 +1,58 @@ +# 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](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..4ac0525db --- /dev/null +++ b/docs/STYLE.md @@ -0,0 +1,249 @@ +# 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. + +## Play2 + +In some particular instances, IDO requires the function argument `play` to be cast to a second variable of the same type to match. In these particular instances, the function argument should be renamed to `play2` and than this `play2` just assigned to a stack variable called `play`. This cast should occur before the actor `THIS` cast is made. For example in `z_en_firefly.c` +```c +void EnFirefly_Update(Actor* thisx, PlayState* play2) { + PlayState* play = play2; + 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, PlayState* play) { + 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/tools.md b/docs/tools.md index 6fec9caf8..149fba9ae 100644 --- a/docs/tools.md +++ b/docs/tools.md @@ -286,6 +286,6 @@ We use a [Google Sheet](https://docs.google.com/spreadsheets/d/1X83YCPRa532v-Zo0 - **Function size statistics**: Intended as a crude estimate of how hard a file will be. Beginners should look for small largest function size and total size; the columns give a rough estimate of the distribution of function sizes without getting unnecessarily statistically descriptive. As you become more experienced, you should work on larger files to leave the smaller ones for other beginners. - **Description**: What the file is. It's helpful if you can fill this in if you know! They should be synchronised with the short top-of-file descriptions. - **Status**: (Free)/Reserved/PR/Merged. To be kept up-to-date by the reserver. -- **Reserved**: To reserve a file, put your Discord name in the "Reserved" column. It is common courtesy to not work on a file that is being worked on by another contributor, so ensure the "Reserved" column is blank before working on a file. If it is not, you can ask the reserver(s) if they want to release it or collaborate on it, but don't expect them to agree. More information on what is expected when you reserve a file is available in the [CONTRIBUTING.md](../CONTRIBUTING.md). +- **Reserved**: To reserve a file, put your Discord name in the "Reserved" column. It is common courtesy to not work on a file that is being worked on by another contributor, so ensure the "Reserved" column is blank before working on a file. If it is not, you can ask the reserver(s) if they want to release it or collaborate on it, but don't expect them to agree. More information on what is expected when you reserve a file is available in the [CONTRIBUTING.md](CONTRIBUTING.md). - **Interested**: If you would like to work on a file, but don't want to reserve it, or would be interested in collaboration, etc. You should talk to any Interested people if you want to work on the file. - **Notes**: Any other useful information: partial progress by someone unable to finish the file, other files it works with, etc. diff --git a/docs/tutorial/advanced_control_flow.md b/docs/tutorial/advanced_control_flow.md index 4952f7586..3ad2a9d4f 100644 --- a/docs/tutorial/advanced_control_flow.md +++ b/docs/tutorial/advanced_control_flow.md @@ -16,15 +16,15 @@ Again our example will be taken from a small NPC: this time, `EnMs` (Bean Seller #define THIS ((EnMs*)thisx) -void EnMs_Init(Actor* thisx, GlobalContext* globalCtx); -void EnMs_Destroy(Actor* thisx, GlobalContext* globalCtx); -void EnMs_Update(Actor* thisx, GlobalContext* globalCtx); -void EnMs_Draw(Actor* thisx, GlobalContext* globalCtx); +void EnMs_Init(Actor* thisx, PlayState* play); +void EnMs_Destroy(Actor* thisx, PlayState* play); +void EnMs_Update(Actor* thisx, PlayState* play); +void EnMs_Draw(Actor* thisx, PlayState* play); -void func_80952734(EnMs* this, GlobalContext* globalCtx); -void func_809527F8(EnMs* this, GlobalContext* globalCtx); -void func_809529AC(EnMs* this, GlobalContext* globalCtx); -void func_80952A1C(EnMs *this, GlobalContext *globalCtx); +void func_80952734(EnMs* this, PlayState* play); +void func_809527F8(EnMs* this, PlayState* play); +void func_809529AC(EnMs* this, PlayState* play); +void func_80952A1C(EnMs* this, PlayState* play); const ActorInit En_Ms_InitVars = { ACTOR_EN_MS, @@ -56,13 +56,13 @@ extern InitChainEntry D_80952BCC[]; extern AnimationHeader D_060005EC; extern FlexSkeletonHeader D_06003DC0; -void EnMs_Init(Actor* thisx, GlobalContext* globalCtx) { +void EnMs_Init(Actor* thisx, PlayState* play) { EnMs* this = THIS; Actor_ProcessInitChain(thisx, D_80952BCC); - SkelAnime_InitFlex(globalCtx, &this->skelAnime, &D_06003DC0, &D_060005EC, this->jointTable, this->morphTable, 9); - Collider_InitCylinder(globalCtx, &this->collider); - Collider_SetCylinderType1(globalCtx, &this->collider, &this->actor, &D_80952BA0); + SkelAnime_InitFlex(play, &this->skelAnime, &D_06003DC0, &D_060005EC, this->jointTable, this->morphTable, 9); + Collider_InitCylinder(play, &this->collider); + Collider_SetCylinderType1(play, &this->collider, &this->actor, &D_80952BA0); ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 35.0f); Actor_SetScale(&this->actor, 0.015f); this->actor.colChkInfo.mass = 0xFF; @@ -72,13 +72,13 @@ void EnMs_Init(Actor* thisx, GlobalContext* globalCtx) { this->actor.gravity = -1.0f; } -void EnMs_Destroy(Actor* thisx, GlobalContext* globalCtx) { +void EnMs_Destroy(Actor* thisx, PlayState* play) { EnMs* this = THIS; - Collider_DestroyCylinder(globalCtx, &this->collider); + Collider_DestroyCylinder(play, &this->collider); } -void func_80952734(EnMs* this, GlobalContext* globalCtx) { +void func_80952734(EnMs* this, PlayState* play) { s16 temp_v1 = this->actor.yawTowardsPlayer - this->actor.shape.rot.y; if (gSaveContext.save.inventory.items[10] == ITEM_NONE) { @@ -87,40 +87,40 @@ void func_80952734(EnMs* this, GlobalContext* globalCtx) { this->actor.textId = 0x932; } - if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state) != 0) { + if (Actor_ProcessTalkRequest(&this->actor, &play->state) != 0) { this->actionFunc = func_809527F8; return; } if (this->actor.xzDistToPlayer < 90.0f) { if (ABS_ALT(temp_v1) < 0x2000) { - func_800B8614(&this->actor, globalCtx, 90.0f); + func_800B8614(&this->actor, play, 90.0f); } } } #pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ms/func_809527F8.s") -void func_809529AC(EnMs *this, GlobalContext *globalCtx) { - if (Actor_HasParent(&this->actor, globalCtx)) { +void func_809529AC(EnMs* this, PlayState* play) { + if (Actor_HasParent(&this->actor, play)) { this->actor.textId = 0; - func_800B8500(&this->actor, globalCtx, this->actor.xzDistToPlayer, this->actor.playerHeightRel, 0); + func_800B8500(&this->actor, play, this->actor.xzDistToPlayer, this->actor.playerHeightRel, 0); this->actionFunc = func_80952A1C; } else { - Actor_PickUp(&this->actor, globalCtx, 0x35, this->actor.xzDistToPlayer, this->actor.playerHeightRel); + Actor_PickUp(&this->actor, play, 0x35, this->actor.xzDistToPlayer, this->actor.playerHeightRel); } } -void func_80952A1C(EnMs *this, GlobalContext *globalCtx) { - if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { - func_80151938(globalCtx, 0x936U); +void func_80952A1C(EnMs* this, PlayState* play) { + if (Actor_ProcessTalkRequest(&this->actor, &play->state)) { + func_80151938(play, 0x936U); this->actionFunc = func_809527F8; } else { - func_800B8500(&this->actor, globalCtx, this->actor.xzDistToPlayer, this->actor.playerHeightRel, -1); + func_800B8500(&this->actor, play, this->actor.xzDistToPlayer, this->actor.playerHeightRel, -1); } } -void EnMs_Update(Actor* thisx, GlobalContext* globalCtx) { +void EnMs_Update(Actor* thisx, PlayState* play) { s32 pad; EnMs* this = THIS; @@ -128,16 +128,16 @@ void EnMs_Update(Actor* thisx, GlobalContext* globalCtx) { this->actor.targetArrowOffset = 500.0f; Actor_SetScale(&this->actor, 0.015f); SkelAnime_Update(&this->skelAnime); - this->actionFunc(this, globalCtx); + this->actionFunc(this, play); Collider_UpdateCylinder(&this->actor, &this->collider); - CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + CollisionCheck_SetOC(play, &play->colChkCtx, &this->collider.base); } -void EnMs_Draw(Actor* thisx, GlobalContext* globalCtx) { +void EnMs_Draw(Actor* thisx, PlayState* play) { EnMs* this = THIS; - func_8012C28C(globalCtx->state.gfxCtx); - SkelAnime_DrawFlexOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, NULL, + func_8012C28C(play->state.gfxCtx); + SkelAnime_DrawFlexOpa(play, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, NULL, NULL, &this->actor); } @@ -152,54 +152,54 @@ $ ../mips_to_c/mips_to_c.py asm/non_matchings/overlays/ovl_En_Ms/func_809527F8.s ``` ```C -void func_809527F8(EnMs *this, GlobalContext *globalCtx) { +void func_809527F8(EnMs* this, PlayState* play) { u8 temp_v0; u8 temp_v0_2; - temp_v0 = Message_GetState(&globalCtx->msgCtx); + temp_v0 = Message_GetState(&play->msgCtx); if (temp_v0 != 4) { if (temp_v0 != 5) { - if ((temp_v0 == 6) && (Message_ShouldAdvance(globalCtx) != 0)) { + if ((temp_v0 == 6) && (Message_ShouldAdvance(play) != 0)) { this->actionFunc = func_80952734; return; } // Duplicate return node #17. Try simplifying control flow for better match return; } - if (Message_ShouldAdvance(globalCtx) != 0) { - func_801477B4(globalCtx); - Actor_PickUp((Actor *) this, globalCtx, 0x35, this->actor.xzDistToPlayer, this->actor.playerHeightRel); + if (Message_ShouldAdvance(play) != 0) { + func_801477B4(play); + Actor_PickUp((Actor *) this, play, 0x35, this->actor.xzDistToPlayer, this->actor.playerHeightRel); this->actionFunc = func_809529AC; return; } // Duplicate return node #17. Try simplifying control flow for better match return; } - if (Message_ShouldAdvance(globalCtx) != 0) { - temp_v0_2 = globalCtx->msgCtx.choiceIndex; + if (Message_ShouldAdvance(play) != 0) { + temp_v0_2 = play->msgCtx.choiceIndex; if (temp_v0_2 != 0) { if (temp_v0_2 != 1) { } func_8019F230(); - func_80151938(globalCtx, 0x934U); + func_80151938(play, 0x934U); // Duplicate return node #17. Try simplifying control flow for better match return; } - func_801477B4(globalCtx); + func_801477B4(play); if ((s32) gSaveContext.save.playerData.rupees < 0xA) { play_sound(0x4806U); - func_80151938(globalCtx, 0x935U); + func_80151938(play, 0x935U); return; } if ((s32) gSaveContext.save.inventory.ammo[gItemSlots[0xA]] >= 0x14) { play_sound(0x4806U); - func_80151938(globalCtx, 0x937U); + func_80151938(play, 0x937U); return; } func_8019F208(); - Actor_PickUp((Actor *) this, globalCtx, 0x35, 90.0f, 10.0f); - func_801159EC(-0xA); + Actor_PickUp((Actor *) this, play, 0x35, 90.0f, 10.0f); + Rupees_ChangeBy(-0xA); this->actionFunc = func_809529AC; } } @@ -208,10 +208,10 @@ void func_809527F8(EnMs *this, GlobalContext *globalCtx) { which is long, messy, and contains some rather nasty-looking control flow, including horrors like ```C - temp_v0 = Message_GetState(&globalCtx->msgCtx); + temp_v0 = Message_GetState(&play->msgCtx); if (temp_v0 != 4) { if (temp_v0 != 5) { - if ((temp_v0 == 6) && (Message_ShouldAdvance(globalCtx) != 0)) { + if ((temp_v0 == 6) && (Message_ShouldAdvance(play) != 0)) { this->actionFunc = func_80952734; return; } @@ -220,8 +220,7 @@ which is long, messy, and contains some rather nasty-looking control flow, inclu } ``` -If you read the OoT tutorial, you'll know these nested negated ifs all using the same variable are a good indicator that there's a switch. The problem is working out how to write it. - +If you read the OoT tutorial, you'll know these nested negated ifs all using the same variable are a good indicator that there's a switch. The problem is working out how to write it. ## Goto-only mode @@ -234,11 +233,11 @@ For didactic purposes, we'll use a feature of mips2c called goto-only mode to ex instead will produce ```C -void func_809527F8(EnMs *this, GlobalContext *globalCtx) { +void func_809527F8(EnMs* this, PlayState* play) { u8 temp_v0; u8 temp_v0_2; - temp_v0 = Message_GetState(&globalCtx->msgCtx); + temp_v0 = Message_GetState(&play->msgCtx); if (temp_v0 == 4) { goto block_7; } @@ -248,24 +247,24 @@ void func_809527F8(EnMs *this, GlobalContext *globalCtx) { if (temp_v0 != 6) { goto block_17; } - if (Message_ShouldAdvance(globalCtx) == 0) { + if (Message_ShouldAdvance(play) == 0) { goto block_17; } this->actionFunc = func_80952734; return; block_5: - if (Message_ShouldAdvance(globalCtx) == 0) { + if (Message_ShouldAdvance(play) == 0) { goto block_17; } - func_801477B4(globalCtx); - Actor_PickUp((Actor *) this, globalCtx, 0x35, this->actor.xzDistToPlayer, this->actor.playerHeightRel); + func_801477B4(play); + Actor_PickUp((Actor *) this, play, 0x35, this->actor.xzDistToPlayer, this->actor.playerHeightRel); this->actionFunc = func_809529AC; return; block_7: - if (Message_ShouldAdvance(globalCtx) == 0) { + if (Message_ShouldAdvance(play) == 0) { goto block_17; } - temp_v0_2 = globalCtx->msgCtx.choiceIndex; + temp_v0_2 = play->msgCtx.choiceIndex; if (temp_v0_2 == 0) { goto block_11; } @@ -274,35 +273,36 @@ block_7: } goto block_16; block_11: - func_801477B4(globalCtx); + func_801477B4(play); if ((s32) gSaveContext.save.playerData.rupees >= 0xA) { goto block_13; } play_sound(0x4806U); - func_80151938(globalCtx, 0x935U); + func_80151938(play, 0x935U); return; block_13: if ((s32) gSaveContext.save.inventory.ammo[gItemSlots[0xA]] < 0x14) { goto block_15; } play_sound(0x4806U); - func_80151938(globalCtx, 0x937U); + func_80151938(play, 0x937U); return; block_15: func_8019F208(); - Actor_PickUp((Actor *) this, globalCtx, 0x35, 90.0f, 10.0f); - func_801159EC(-0xA); + Actor_PickUp((Actor *) this, play, 0x35, 90.0f, 10.0f); + Rupees_ChangeBy(-0xA); this->actionFunc = func_809529AC; return; block_16: func_8019F230(); - func_80151938(globalCtx, 0x934U); + func_80151938(play, 0x934U); block_17: return; } ``` which in many ways looks worse: you can see why the use of gotos in code is strongly discouraged. However, if you throw this in `diff.py`, you'll find it's rather closer than you'd have thought. Goto-only mode has the advantages that + - code is always in the right order: mips2c has not had to reorder anything to get the ifs to work out - it is often possible to get quite close with gotos, then start removing them, checking the matching status at each point. This is usually easier than trying to puzzle out the way it's trying to jump out of an `if ( || )` or similar. - if you're trying to keep track of where you are in the code, the gotos mean that it is closer to the assembly in the first place. @@ -316,7 +316,7 @@ The simplest sort of block label to eliminate is one that is only used once, and goto block_13; } play_sound(0x4806U); - func_80151938(globalCtx, 0x935U); + func_80151938(play, 0x935U); return; block_13: ``` @@ -326,7 +326,7 @@ Currently, this says to jump over the code block `play_sound...` if the conditio ```C if (gSaveContext.save.playerData.rupees < 0xA) { play_sound(0x4806U); - func_80151938(globalCtx, 0x935U); + func_80151938(play, 0x935U); return; } ``` @@ -336,11 +336,11 @@ Likewise, one can do this with `block_15`. If you examine appropriate part of the diff, you will usually find that such eliminations make no, or very little, difference to the compiled code. ```C -void func_809527F8(EnMs *this, GlobalContext *globalCtx) { +void func_809527F8(EnMs* this, PlayState* play) { u8 temp_v0; u8 temp_v0_2; - temp_v0 = Message_GetState(&globalCtx->msgCtx); + temp_v0 = Message_GetState(&play->msgCtx); if (temp_v0 == 4) { goto block_7; } @@ -350,24 +350,24 @@ void func_809527F8(EnMs *this, GlobalContext *globalCtx) { if (temp_v0 != 6) { goto block_17; } - if (Message_ShouldAdvance(globalCtx) == 0) { + if (Message_ShouldAdvance(play) == 0) { goto block_17; } this->actionFunc = func_80952734; return; block_5: - if (Message_ShouldAdvance(globalCtx) == 0) { + if (Message_ShouldAdvance(play) == 0) { goto block_17; } - func_801477B4(globalCtx); - Actor_PickUp((Actor *) this, globalCtx, 0x35, this->actor.xzDistToPlayer, this->actor.playerHeightRel); + func_801477B4(play); + Actor_PickUp((Actor *) this, play, 0x35, this->actor.xzDistToPlayer, this->actor.playerHeightRel); this->actionFunc = func_809529AC; return; block_7: - if (Message_ShouldAdvance(globalCtx) == 0) { + if (Message_ShouldAdvance(play) == 0) { goto block_17; } - temp_v0_2 = globalCtx->msgCtx.choiceIndex; + temp_v0_2 = play->msgCtx.choiceIndex; if (temp_v0_2 == 0) { goto block_11; } @@ -376,27 +376,27 @@ block_7: } goto block_16; block_11: - func_801477B4(globalCtx); + func_801477B4(play); if (gSaveContext.save.playerData.rupees < 0xA) { play_sound(0x4806U); - func_80151938(globalCtx, 0x935U); + func_80151938(play, 0x935U); return; } if (gSaveContext.save.inventory.ammo[gItemSlots[0xA]] >= 0x14) { play_sound(0x4806U); - func_80151938(globalCtx, 0x937U); + func_80151938(play, 0x937U); return; } func_8019F208(); - Actor_PickUp((Actor *) this, globalCtx, 0x35, 90.0f, 10.0f); - func_801159EC(-0xA); + Actor_PickUp((Actor *) this, play, 0x35, 90.0f, 10.0f); + Rupees_ChangeBy(-0xA); this->actionFunc = func_809529AC; return; block_16: func_8019F230(); - func_80151938(globalCtx, 0x934U); + func_80151938(play, 0x934U); block_17: return; } @@ -404,13 +404,12 @@ block_17: We can't apply this rule any more, so we need to move on to the next: `block_17` just contains a `return`. So we can replace it by `return` everywhere it appears. - ```C -void func_809527F8(EnMs *this, GlobalContext *globalCtx) { +void func_809527F8(EnMs* this, PlayState* play) { u8 temp_v0; u8 temp_v0_2; - temp_v0 = Message_GetState(&globalCtx->msgCtx); + temp_v0 = Message_GetState(&play->msgCtx); if (temp_v0 == 4) { goto block_7; } @@ -420,24 +419,24 @@ void func_809527F8(EnMs *this, GlobalContext *globalCtx) { if (temp_v0 != 6) { return; } - if (Message_ShouldAdvance(globalCtx) == 0) { + if (Message_ShouldAdvance(play) == 0) { return; } this->actionFunc = func_80952734; return; block_5: - if (Message_ShouldAdvance(globalCtx) == 0) { + if (Message_ShouldAdvance(play) == 0) { return; } - func_801477B4(globalCtx); - Actor_PickUp((Actor *) this, globalCtx, 0x35, this->actor.xzDistToPlayer, this->actor.playerHeightRel); + func_801477B4(play); + Actor_PickUp((Actor *) this, play, 0x35, this->actor.xzDistToPlayer, this->actor.playerHeightRel); this->actionFunc = func_809529AC; return; block_7: - if (Message_ShouldAdvance(globalCtx) == 0) { + if (Message_ShouldAdvance(play) == 0) { return; } - temp_v0_2 = globalCtx->msgCtx.choiceIndex; + temp_v0_2 = play->msgCtx.choiceIndex; if (temp_v0_2 == 0) { goto block_11; } @@ -446,27 +445,27 @@ block_7: } goto block_16; block_11: - func_801477B4(globalCtx); + func_801477B4(play); if (gSaveContext.save.playerData.rupees < 0xA) { play_sound(0x4806U); - func_80151938(globalCtx, 0x935U); + func_80151938(play, 0x935U); return; } if (gSaveContext.save.inventory.ammo[gItemSlots[0xA]] >= 0x14) { play_sound(0x4806U); - func_80151938(globalCtx, 0x937U); + func_80151938(play, 0x937U); return; } func_8019F208(); - Actor_PickUp((Actor *) this, globalCtx, 0x35, 90.0f, 10.0f); - func_801159EC(-0xA); + Actor_PickUp((Actor *) this, play, 0x35, 90.0f, 10.0f); + Rupees_ChangeBy(-0xA); this->actionFunc = func_809529AC; return; block_16: func_8019F230(); - func_80151938(globalCtx, 0x934U); + func_80151938(play, 0x934U); } ``` @@ -475,7 +474,7 @@ Our next rule is about non-crossing blocks. If two code blocks do not contain an Now let's start thinking about switches. A good indicator of a switch in goto-only mode is something like ```C - temp_v0_2 = globalCtx->msgCtx.choiceIndex; + temp_v0_2 = play->msgCtx.choiceIndex; if (temp_v0_2 == 0) { goto block_11; } @@ -486,6 +485,7 @@ Now let's start thinking about switches. A good indicator of a switch in goto-on ``` because + - there are multiple ifs that are simple numeric comparisons of the same argument - the goto blocks are in the same order as the ifs - there is one last goto at the end that triggers if none of the ifs does: this sounds an awful lot like a `default`! @@ -493,24 +493,24 @@ because So let us rewrite the entire second half as a switch: ```C - switch (globalCtx->msgCtx.choiceIndex) { + switch (play->msgCtx.choiceIndex) { case 0: - func_801477B4(globalCtx); + func_801477B4(play); if (gSaveContext.save.playerData.rupees < 0xA) { play_sound(0x4806U); - func_80151938(globalCtx, 0x935U); + func_80151938(play, 0x935U); return; } if (gSaveContext.save.inventory.ammo[gItemSlots[0xA]] >= 0x14) { play_sound(0x4806U); - func_80151938(globalCtx, 0x937U); + func_80151938(play, 0x937U); return; } func_8019F208(); - Actor_PickUp((Actor *) this, globalCtx, 0x35, 90.0f, 10.0f); - func_801159EC(-0xA); + Actor_PickUp((Actor *) this, play, 0x35, 90.0f, 10.0f); + Rupees_ChangeBy(-0xA); this->actionFunc = func_809529AC; return; break; @@ -518,30 +518,31 @@ So let us rewrite the entire second half as a switch: case 1: default: func_8019F230(); - func_80151938(globalCtx, 0x934U); + func_80151938(play, 0x934U); break; } ``` -There's a couple of other obvious things here: +There's a couple of other obvious things here: + - the last `return` in `case 0` is unnecessary since there is no other code after the switch, so breaking is equivalent to the return` - a common pattern everywhere, a sequence of ifs with returns as the last thing inside is the same as an if-else chain, so we can rewrite these as ```C - switch (globalCtx->msgCtx.choiceIndex) { + switch (play->msgCtx.choiceIndex) { case 0: - func_801477B4(globalCtx); + func_801477B4(play); if (gSaveContext.save.playerData.rupees < 0xA) { play_sound(0x4806U); - func_80151938(globalCtx, 0x935U); + func_80151938(play, 0x935U); } else if (gSaveContext.save.inventory.ammo[gItemSlots[0xA]] >= 0x14) { play_sound(0x4806U); - func_80151938(globalCtx, 0x937U); + func_80151938(play, 0x937U); } else { func_8019F208(); - Actor_PickUp((Actor *) this, globalCtx, 0x35, 90.0f, 10.0f); - func_801159EC(-0xA); + Actor_PickUp((Actor *) this, play, 0x35, 90.0f, 10.0f); + Rupees_ChangeBy(-0xA); this->actionFunc = func_809529AC; } break; @@ -549,7 +550,7 @@ There's a couple of other obvious things here: case 1: default: func_8019F230(); - func_80151938(globalCtx, 0x934U); + func_80151938(play, 0x934U); break; } ``` @@ -557,7 +558,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 (Message_ShouldAdvance(globalCtx) == 0) { + if (Message_ShouldAdvance(play) == 0) { return; } ``` @@ -565,10 +566,10 @@ Well, at least the bottom half looks respectable now. Again, there is no code af can be swapped round and made to wrap the switch. This leaves us with ```C -void func_809527F8(EnMs *this, GlobalContext *globalCtx) { +void func_809527F8(EnMs* this, PlayState* play) { u8 temp_v0; - temp_v0 = Message_GetState(&globalCtx->msgCtx); + temp_v0 = Message_GetState(&play->msgCtx); if (temp_v0 == 4) { goto block_7; } @@ -578,35 +579,35 @@ void func_809527F8(EnMs *this, GlobalContext *globalCtx) { if (temp_v0 != 6) { return; } - if (Message_ShouldAdvance(globalCtx) == 0) { + if (Message_ShouldAdvance(play) == 0) { return; } this->actionFunc = func_80952734; return; block_5: - if (Message_ShouldAdvance(globalCtx) == 0) { + if (Message_ShouldAdvance(play) == 0) { return; } - func_801477B4(globalCtx); - Actor_PickUp((Actor *) this, globalCtx, 0x35, this->actor.xzDistToPlayer, this->actor.playerHeightRel); + func_801477B4(play); + Actor_PickUp((Actor *) this, play, 0x35, this->actor.xzDistToPlayer, this->actor.playerHeightRel); this->actionFunc = func_809529AC; return; block_7: - if (Message_ShouldAdvance(globalCtx) != 0) { - switch (globalCtx->msgCtx.choiceIndex) { + if (Message_ShouldAdvance(play) != 0) { + switch (play->msgCtx.choiceIndex) { case 0: - func_801477B4(globalCtx); + func_801477B4(play); if (gSaveContext.save.playerData.rupees < 0xA) { play_sound(0x4806U); - func_80151938(globalCtx, 0x935U); + func_80151938(play, 0x935U); } else if (gSaveContext.save.inventory.ammo[gItemSlots[0xA]] >= 0x14) { play_sound(0x4806U); - func_80151938(globalCtx, 0x937U); + func_80151938(play, 0x937U); } else { func_8019F208(); - Actor_PickUp((Actor *) this, globalCtx, 0x35, 90.0f, 10.0f); - func_801159EC(-0xA); + Actor_PickUp((Actor *) this, play, 0x35, 90.0f, 10.0f); + Rupees_ChangeBy(-0xA); this->actionFunc = func_809529AC; } break; @@ -614,7 +615,7 @@ block_7: case 1: default: func_8019F230(); - func_80151938(globalCtx, 0x934U); + func_80151938(play, 0x934U); break; } } @@ -622,8 +623,9 @@ block_7: ``` Now, the top of the function also looks like a switch: + ```C - temp_v0 = Message_GetState(&globalCtx->msgCtx); + temp_v0 = Message_GetState(&play->msgCtx); if (temp_v0 == 4) { goto block_7; } @@ -640,37 +642,37 @@ Interestingly, this time the blocks are the other way round. Also, the last stat Putting all this together, we write down a function with no gotos in it: ```C -void func_809527F8(EnMs *this, GlobalContext *globalCtx) { - switch (Message_GetState(&globalCtx->msgCtx)) { +void func_809527F8(EnMs* this, PlayState* play) { + switch (Message_GetState(&play->msgCtx)) { case 6: this->actionFunc = func_80952734; break; case 5: - if (Message_ShouldAdvance(globalCtx) == 0) { + if (Message_ShouldAdvance(play) == 0) { return; } - func_801477B4(globalCtx); - Actor_PickUp((Actor *) this, globalCtx, 0x35, this->actor.xzDistToPlayer, this->actor.playerHeightRel); + func_801477B4(play); + Actor_PickUp((Actor *) this, play, 0x35, this->actor.xzDistToPlayer, this->actor.playerHeightRel); this->actionFunc = func_809529AC; break; case 4: - if (Message_ShouldAdvance(globalCtx) != 0) { - switch (globalCtx->msgCtx.choiceIndex) { + if (Message_ShouldAdvance(play) != 0) { + switch (play->msgCtx.choiceIndex) { case 0: - func_801477B4(globalCtx); + func_801477B4(play); if (gSaveContext.save.playerData.rupees < 0xA) { play_sound(0x4806U); - func_80151938(globalCtx, 0x935U); + func_80151938(play, 0x935U); } else if (gSaveContext.save.inventory.ammo[gItemSlots[0xA]] >= 0x14) { play_sound(0x4806U); - func_80151938(globalCtx, 0x937U); + func_80151938(play, 0x937U); } else { func_8019F208(); - Actor_PickUp((Actor *) this, globalCtx, 0x35, 90.0f, 10.0f); - func_801159EC(-0xA); + Actor_PickUp((Actor *) this, play, 0x35, 90.0f, 10.0f); + Rupees_ChangeBy(-0xA); this->actionFunc = func_809529AC; } break; @@ -678,7 +680,7 @@ void func_809527F8(EnMs *this, GlobalContext *globalCtx) { case 1: default: func_8019F230(); - func_80151938(globalCtx, 0x934U); + func_80151938(play, 0x934U); break; } } @@ -693,36 +695,36 @@ void func_809527F8(EnMs *this, GlobalContext *globalCtx) { Lastly, we can simplify `case 5` to replace the return in the if by the rest of the code, and we end up with ```C -void func_809527F8(EnMs *this, GlobalContext *globalCtx) { - switch (Message_GetState(&globalCtx->msgCtx)) { +void func_809527F8(EnMs* this, PlayState* play) { + switch (Message_GetState(&play->msgCtx)) { case 6: this->actionFunc = func_80952734; break; case 5: - if (Message_ShouldAdvance(globalCtx) != 0) { - func_801477B4(globalCtx); - Actor_PickUp((Actor *) this, globalCtx, 0x35, this->actor.xzDistToPlayer, this->actor.playerHeightRel); + if (Message_ShouldAdvance(play) != 0) { + func_801477B4(play); + Actor_PickUp((Actor *) this, play, 0x35, this->actor.xzDistToPlayer, this->actor.playerHeightRel); this->actionFunc = func_809529AC; } break; case 4: - if (Message_ShouldAdvance(globalCtx) != 0) { - switch (globalCtx->msgCtx.choiceIndex) { + if (Message_ShouldAdvance(play) != 0) { + switch (play->msgCtx.choiceIndex) { case 0: - func_801477B4(globalCtx); + func_801477B4(play); if (gSaveContext.save.playerData.rupees < 0xA) { play_sound(0x4806U); - func_80151938(globalCtx, 0x935U); + func_80151938(play, 0x935U); } else if (gSaveContext.save.inventory.ammo[gItemSlots[0xA]] >= 0x14) { play_sound(0x4806U); - func_80151938(globalCtx, 0x937U); + func_80151938(play, 0x937U); } else { func_8019F208(); - Actor_PickUp((Actor *) this, globalCtx, 0x35, 90.0f, 10.0f); - func_801159EC(-0xA); + Actor_PickUp((Actor *) this, play, 0x35, 90.0f, 10.0f); + Rupees_ChangeBy(-0xA); this->actionFunc = func_809529AC; } break; @@ -730,7 +732,7 @@ void func_809527F8(EnMs *this, GlobalContext *globalCtx) { case 1: default: func_8019F230(); - func_80151938(globalCtx, 0x934U); + func_80151938(play, 0x934U); break; } } @@ -742,6 +744,6 @@ void func_809527F8(EnMs *this, GlobalContext *globalCtx) { } ``` -And this matches! +And this matches! We will not document this now, although even with so few function named it seems pretty clear that it's to do with buying beans (and indeed, Magic Beans cost 10 Rupees and have Get Item ID `0x35`) You might like to try to match this function without using goto-only mode, to compare. It is also an interesting exercise to see what each elimination does to the diff: sometimes it will stray surprisingly far for a small change. diff --git a/docs/tutorial/beginning_decomp.md b/docs/tutorial/beginning_decomp.md index 13e5941fc..eadfa9adc 100644 --- a/docs/tutorial/beginning_decomp.md +++ b/docs/tutorial/beginning_decomp.md @@ -6,7 +6,6 @@ Open the C file and the H file with your actor's name from the appropriate direc Each actor has associated to it a data file and one assembly file per function. During the process, we will transfer the contents of all or most of these into the main C file. VSCode's search feature usually makes it quite easy to find the appropriate files without troubling the directory tree. - ## Anatomy of the C file The actor file starts off looking like: @@ -21,10 +20,10 @@ The actor file starts off looking like: #define THIS ((EnRecepgirl*)thisx) // --------------- 3 --------------- -void EnRecepgirl_Init(Actor* thisx, GlobalContext* globalCtx); -void EnRecepgirl_Destroy(Actor* thisx, GlobalContext* globalCtx); -void EnRecepgirl_Update(Actor* thisx, GlobalContext* globalCtx); -void EnRecepgirl_Draw(Actor* thisx, GlobalContext* globalCtx); +void EnRecepgirl_Init(Actor* thisx, PlayState* play); +void EnRecepgirl_Destroy(Actor* thisx, PlayState* play); +void EnRecepgirl_Update(Actor* thisx, PlayState* play); +void EnRecepgirl_Draw(Actor* thisx, PlayState* play); // --------------- 4 --------------- #if 0 @@ -102,7 +101,6 @@ It is currently divided into six sections as follows: 6. List of functions. Each `#pragma GLOBAL_ASM` is letting the compiler use the corresponding assembly file while we do not have decompiled C code for that function. The majority of the decompilation work is converting these functions into C that it looks like a human wrote. - ## Header file The header file looks like this at the moment: @@ -115,7 +113,7 @@ The header file looks like this at the moment: struct EnRecepgirl; -typedef void (*EnRecepgirlActionFunc)(struct EnRecepgirl*, GlobalContext*); +typedef void (*EnRecepgirlActionFunc)(struct EnRecepgirl*, PlayState*); typedef struct EnRecepgirl { /* 0x0000 */ Actor actor; @@ -133,15 +131,15 @@ The struct currently contains a variable that is the `Actor` struct, which all a The header file is also used to declare structs and other information about the actor that is needed by other files (e.g. by other actors): one can simply `#include` the header rather than `extern`ing it. - ## Order of decompilation The general rule for order of decompilation is + - Start with `Init`, because it usually contains the most information about the structure of the actor. You can also do `Destroy`, which is generally simpler than `Init`. - Next, decompile any other functions from the actor you have found in `Init`. You generally start with the action functions, because they return nothing and all take the same arguments, ```C -void func_80whatever(EnRecepgirl* this, GlobalContext* globalCtx); +void func_80whatever(EnRecepgirl* this, PlayState* play); ``` - Decompile each action function in turn until you run out. Along the way, do any other functions in the actor for which you have discovered the argument types. (You are probably better doing depth-first on action functions than breadth-first: it's normally easier to follow along one branch of the actions than be thinking about several at once.) @@ -158,20 +156,19 @@ The above is a rough ordering for the beginner. As you become more experienced, Associated to each actor is a `.data` file, containing data that the actor uses. This ranges from spawn positions, to animation information, to even assets that we have to extract from the ROM. Since the structure of the data is very inconsistent between actors, automatic importing has been very limited, so the vast majority must be done manually. -There are two ways of transfering the data into an actor: we can either -- import it all naively as words (`s32`s), which will still allow it to compile, and sort out the actual types later, or +There are two ways of transfering the data into an actor: we can either + +- import it all naively as words (`s32`s), which will still allow it to compile, and sort out the actual types later, or - we can extern each piece of data as we come across it, and come back to it later when we have a better idea of what it is. We will concentrate on the second here; the other is covered in [the document about data](data.md). Thankfully this means we essentially don't have to do anything to the data yet. Nevertheless, it is often quite helpful to copy over at least some of the data and leave it commented out for later replacement. *Data must go in the same order as in the data file, and data is "all or nothing": you cannot only import some of it*. - **WARNING** The way in which the data was extracted from the ROM means that there are sometimes "fake symbols" in the data, which have to be removed to avoid confusing the compiler. Thankfully it will turn out that this is not the case here. (Sometimes it is useful to import the data in the middle of doing functions: you just have to choose an appropriate moment.) Some actors also have a `.bss` file. This is just data that is initialised to 0, and can be imported immediately once you know what type it is, by declaring it without giving it a value. (bss is a significant problem for code files, but not *usually* for actors.) - ## Init The Init function sets up the various components of the actor when it is first loaded. It is hence usually very useful for finding out what is in the actor struct, and so we usually start with it. (Some people like starting with Destroy, which is usually shorter and simpler, but gives some basic information about the actor, but Init is probably best for beginners.) @@ -183,15 +180,19 @@ The first stage of decompilation is done by a program called mips_to_c, often re The web version of mips2c can be found [here](https://simonsoftware.se/other/mips_to_c.py). This was [covered in the OoT tutorial](https://github.com/zeldaret/oot/blob/master/docs/tutorial/beginning_decomp.md). We shall instead use the repository. Clone [the mips_to_c repository](https://github.com/matt-kempster/mips_to_c) into a separate directory (we will assume on the same level as the `mm/` directory). Since it's Python, we don't have to do any compilation or anything in the mips_to_c directory. Since the actor depends on the rest of the codebase, we can't expect to get much intelligible out of mips2c without giving it some context. We make this using a Python script in the `tools` directory called `m2ctx.py`, so run + ``` $ ./tools/m2ctx.py ``` + from the main directory of the repository. In this case, the C file is `src/overlays/actors/ovl_En_Recepgirl/z_en_recepgirl.c`. This generates a file called `ctx.c` in the main directory of the repository. To get mips_to_c to decompile a function, the bare minimum is to run + ``` $ ../mips_to_c/mips_to_c.py ``` + (from the root directory of `mm`). We can tell mips2c to use the context file we just generated by adding `--context ctx.c`. If we have data, mips2c may be able to assist with that as well. In this case, we want the assembly file for `EnRecepgirl_Init`. You can copy the path to the file in VSCode or similar, or just tab-complete it once you know the directory structure well enough: it turns out to be `asm/non_matchings/overlays/ovl_En_Recepgirl/EnRecepgirl_Init.s`. @@ -199,6 +200,7 @@ In this case, we want the assembly file for `EnRecepgirl_Init`. You can copy the **N.B.** You want the file in `nonmatchings`! the files in the other directories in `asm/` are the *unsplit* asm, which can be used, but is less convenient (you would need to include the rodata, for example, and it will do the whole file at once. This is sometimes useful, but we'll go one function at a time today to keep things simple). We shall also include the data file, which is located at `data/overlays/ovl_En_Recepgirl/ovl_En_Recepgirl.data.s`. Hence the whole command will be + ``` $ ../mips_to_c/mips_to_c.py asm/non_matchings/overlays/ovl_En_Recepgirl/EnRecepgirl_Init.s data/ovl_En_Recepgirl/ovl_En_Recepgirl.data.s --context ctx.c ? func_80C10148(EnRecepgirl *); // extern @@ -207,14 +209,14 @@ static void *D_80C106B0[4] = {(void *)0x600F8F0, (void *)0x600FCF0, (void *)0x60 static s32 D_80C106C8 = 0; InitChainEntry D_80C106C0[2]; // unable to generate initializer -void EnRecepgirl_Init(EnRecepgirl *this, GlobalContext *globalCtx) { +void EnRecepgirl_Init(EnRecepgirl* this, PlayState* play) { EnRecepgirl* this = (EnRecepgirl *) thisx; void **temp_s0; void **phi_s0; Actor_ProcessInitChain((Actor *) this, D_80C106C0); ActorShape_Init(&this->actor.shape, -60.0f, NULL, 0.0f); - SkelAnime_InitFlex(globalCtx, (SkelAnime *) this->unk_144, &D_06011B60, (AnimationHeader *) &D_06009890, this + 0x188, this + 0x218, 0x18); + SkelAnime_InitFlex(play, (SkelAnime *) this->unk_144, &D_06011B60, (AnimationHeader *) &D_06009890, this + 0x188, this + 0x218, 0x18); phi_s0 = D_80C106B0; if (D_80C106C8 == 0) { do { @@ -225,7 +227,7 @@ void EnRecepgirl_Init(EnRecepgirl *this, GlobalContext *globalCtx) { D_80C106C8 = 1; } this->unk_2AC = 2; - if (Flags_GetSwitch(globalCtx, (s32) this->actor.params) != 0) { + if (Flags_GetSwitch(play, (s32) this->actor.params) != 0) { this->actor.textId = 0x2ADC; } else { this->actor.textId = 0x2AD9; @@ -233,6 +235,7 @@ void EnRecepgirl_Init(EnRecepgirl *this, GlobalContext *globalCtx) { func_80C10148(this); } ``` + Comment out the `GLOBAL_ASM` line for `Init`, and paste all of this into the file just underneath it: ```C @@ -244,14 +247,14 @@ static void *D_80C106B0[4] = {(void *)0x600F8F0, (void *)0x600FCF0, (void *)0x60 static s32 D_80C106C8 = 0; InitChainEntry D_80C106C0[2]; // unable to generate initializer -void EnRecepgirl_Init(Actor *thisx, GlobalContext *globalCtx) { +void EnRecepgirl_Init(Actor* thisx, PlayState* play) { EnRecepgirl* this = (EnRecepgirl *) thisx; void **temp_s0; void **phi_s0; Actor_ProcessInitChain((Actor *) this, D_80C106C0); ActorShape_Init(&this->actor.shape, -60.0f, NULL, 0.0f); - SkelAnime_InitFlex(globalCtx, (SkelAnime *) this->unk_144, &D_06011B60, (AnimationHeader *) &D_06009890, this + 0x188, this + 0x218, 0x18); + SkelAnime_InitFlex(play, (SkelAnime *) this->unk_144, &D_06011B60, (AnimationHeader *) &D_06009890, this + 0x188, this + 0x218, 0x18); phi_s0 = D_80C106B0; if (D_80C106C8 == 0) { do { @@ -262,7 +265,7 @@ void EnRecepgirl_Init(Actor *thisx, GlobalContext *globalCtx) { D_80C106C8 = 1; } this->unk_2AC = 2; - if (Flags_GetSwitch(globalCtx, (s32) this->actor.params) != 0) { + if (Flags_GetSwitch(play, (s32) this->actor.params) != 0) { this->actor.textId = 0x2ADC; } else { this->actor.textId = 0x2AD9; @@ -271,6 +274,7 @@ void EnRecepgirl_Init(Actor *thisx, GlobalContext *globalCtx) { } [...] ``` + Typically for all but the simplest functions, there is a lot that needs fixing before we are anywhere near seeing how close we are to the original code. You will notice that mips2c creates a lot of temporary variables. Usually most of these will turn out to not be real, and we need to remove the right ones to get the code to match. @@ -300,14 +304,14 @@ static void *D_80C106B0[4] = {(void *)0x600F8F0, (void *)0x600FCF0, (void *)0x60 static s32 D_80C106C8 = 0; InitChainEntry D_80C106C0[2]; // unable to generate initializer -void EnRecepgirl_Init(Actor *thisx, GlobalContext *globalCtx) { +void EnRecepgirl_Init(Actor* thisx, PlayState* play) { EnRecepgirl* this = THIS; void **temp_s0; void **phi_s0; Actor_ProcessInitChain(&this->actor, D_80C106C0); ActorShape_Init(&this->actor.shape, -60.0f, NULL, 0.0f); - SkelAnime_InitFlex(globalCtx, (SkelAnime *) this->unk_144, &D_06011B60, (AnimationHeader *) &D_06009890, this + 0x188, this + 0x218, 0x18); + SkelAnime_InitFlex(play, (SkelAnime *) this->unk_144, &D_06011B60, (AnimationHeader *) &D_06009890, this + 0x188, this + 0x218, 0x18); phi_s0 = D_80C106B0; if (D_80C106C8 == 0) { do { @@ -318,7 +322,7 @@ void EnRecepgirl_Init(Actor *thisx, GlobalContext *globalCtx) { D_80C106C8 = 1; } this->unk_2AC = 2; - if (Flags_GetSwitch(globalCtx, (s32) this->actor.params) != 0) { + if (Flags_GetSwitch(play, (s32) this->actor.params) != 0) { this->actor.textId = 0x2ADC; } else { this->actor.textId = 0x2AD9; @@ -364,7 +368,6 @@ extern s32 D_80C106C8; **N.B.** As is covered in more detail in [the document about data](data.md), the data *must* be declared in the same order in C as it was in the data assembly file: notice that the order in this example is `En_Recepgirl_InitVars`, `D_80C106B0`, `D_80C106C0`, `D_80C106C8`, the same as in `data/ovl_En_Recepgirl/ovl_En_Recepgirl.data.s`. - In the next sections, we shall sort out the various initialisation functions that occur in Init. This actor contains several of the most common ones, but it does not have, for example, a collider. The process is similar to what we discuss below, or you can check the OoT tutorial. ### Init chains - + Almost always, one of the first items in `Init` is a function that looks like ```C @@ -381,25 +384,28 @@ Actor_ProcessInitChain(&this->actor, D_80C106C0); which initialises common properties of actor using an InitChain, which is usually somewhere near the top of the data, in this case in the variable `D_80C106C0`. This is already included in the `#if`'d out data at the top if the file, so we don't have to do anything for now. We can correct the mips2c output for the extern, though: I actually did this when moving the rest of the data in the previous section. - ### SkelAnime This is the combined system that handles actors' skeletons and their animations. It is the other significant part of most actor structs. We see its initialisation in this part of the code: + ```C Actor_ProcessInitChain(&this->actor, D_80C106C0); ActorShape_Init(&this->actor.shape, -60.0f, NULL, 0.0f); - SkelAnime_InitFlex(globalCtx, (SkelAnime *) this->unk_144, &D_06011B60, (AnimationHeader *) &D_06009890, this + 0x188, this + 0x218, 0x18); + SkelAnime_InitFlex(play, (SkelAnime *) this->unk_144, &D_06011B60, (AnimationHeader *) &D_06009890, this + 0x188, this + 0x218, 0x18); phi_s0 = D_80C106B0; ``` An actor with SkelAnime has three structs in the Actor struct that handle it: one called SkelAnime, and two arrays of `Vec3s`, called `jointTable` and `morphTable`. Usually, although not always, they are next to one another. -There are two different sorts of SkelAnime, although for decompilation purposes there is not much difference between them. Looking at the prototype of `SkelAnime_InitFlex` from `functions.h` (or even the definition in `z_skelanime.c`), +There are two different sorts of SkelAnime, although for decompilation purposes there is not much difference between them. Looking at the prototype of `SkelAnime_InitFlex` from `functions.h` (or even the definition in `z_skelanime.c`), + ```C -void SkelAnime_InitFlex(GlobalContext* globalCtx, SkelAnime* skelAnime, FlexSkeletonHeader* skeletonHeaderSeg, +void SkelAnime_InitFlex(PlayState* play, SkelAnime* skelAnime, FlexSkeletonHeader* skeletonHeaderSeg, AnimationHeader* animation, Vec3s* jointTable, Vec3s* morphTable, s32 limbCount); ``` + we can read off the types of the various arguments: + - The `SkelAnime` struct is at `this + 0x144` - The `jointTable` is at `this + 0x188` - The `morphTable` is at `this + 0x218` @@ -407,6 +413,7 @@ we can read off the types of the various arguments: - Because of how SkelAnime works, this means that the `jointTable` and `morphTable` both have `24` elements Looking in `z64animation.h`, we find that `SkelAnime` has size `0x44`, and looking in `z64math.h`, that `Vec3s` has size `0x6`. Since ` 0x144 + 0x44 = 0x188 `, `jointTable` is immediately after the `SkelAnime`, and since `0x188 + 0x6 * 0x18 = 0x218`, `morphTable` is immediately after the `jointTable`. Finally, `0x218 + 0x6 * 0x18 = 0x2A8`, and we have filled all the space between the `actor` and `actionFunc`. Therefore the struct now looks like + ```C typedef struct EnRecepgirl { /* 0x0000 */ Actor actor; @@ -428,36 +435,46 @@ extern AnimationHeader D_06009890; extern UNK_TYPE D_0600A280; extern FlexSkeletonHeader D_06011B60; ``` + As with the data, these externed symbols should be kept in increasing address order. They are both passed to the function as pointers, so need `&` to pass the address instead of the actual data. Hence we end up with + ```C - SkelAnime_InitFlex(globalCtx, &this->skelAnime, &D_06011B60, &D_06009890, this->jointTable, this->morphTable, 24); + SkelAnime_InitFlex(play, &this->skelAnime, &D_06011B60, &D_06009890, this->jointTable, this->morphTable, 24); ``` + note that `this->jointTable` and `this->morphTable` are arrays, so are already effectively pointers and don't need a `&`. ### More struct variables: a brief detour into reading some assembly This function also gives us information about other things in the struct. The only other reference to `this` (rather than `this->actor` or similar) is in + ```C this->unk_2AC = 2; ``` + This doesn't tell us much except that at `this + 0x2AC` is a number of some kind. What sort of number? For that we will have to look in the assembly code. This will probably look quite intimidating the first time, but it's usually not too bad if you use functions as signposts: IDO will never change the order of function calls, and tends to keep code between functions in roughly the same place, so you can usually guess where you are. In this case, we are looking for `this + 0x2AC`. `0x2AC` is not a very common number, so hopefully the only mention of it is in referring to this struct variable. Indeed, if we search the file, we find that the only instruction mentioning `0x2AC` is here: + ```mips /* 0000B0 80C10080 24090002 */ addiu $t1, $zero, 2 /* 0000B4 80C10084 A24902AC */ sb $t1, 0x2ac($s2) ``` + `addiu` ("add unsigned immediate") adds the last two things and puts the result in the register in the first position. So this says `$t1 = 0 + 2`. The next instruction, `sb` ("store byte") puts the value in the register in the first position in the memory location in the second, which in this case says `$s2 + 0x2ac = $t1`. We can go and find out what is in `$s2` is: it is set *all* the way at the top of the function, in this line: + ```mips /* 000008 80C0FFD8 00809025 */ move $s2, $a0 ``` + This simply copies the contents of the second register into the first one. In this case, it is copying the contents of the function's first argument into `$s2` (because it wants to use it later, and the `$a` registers are assumed to be cleared after a function call). In this case, the first argument is a pointer to `this` (well, `thisx`, but the struct starts with an `Actor`, so it's the same address). So line `B4` of the asm really is saving `2` into the memory location `this + 0x2AC`. Anyway, this tells us that the variable is a byte of some kind, so `s8` or `u8`: if it was an `s16/u16` it would have said `sh`, and if it was an `s32/u32` it would have said `sw`. Unfortunately this is all we can determine from this function: MIPS does not have separate instructions for saving signed and unsigned bytes. At this point you have two options: guess based on statistics/heuristics, or go and look in the other functions in the actor to find out more information. The useful statistic here is that `u8` is far more common than `s8`, but let's look in the other functions, since we're pretty confident after finding `0x2ac` so easily in `Init`. So, let us grep the actor's assembly folder: + ``` $ grep -r '0x2ac' asm/non_matchings/overlays/ovl_En_Recepgirl/ asm/non_matchings/overlays/ovl_En_Recepgirl/EnRecepgirl_Draw.s:/* 00065C 80C1062C 921902AC */ lbu $t9, 0x2ac($s0) @@ -468,7 +485,9 @@ asm/non_matchings/overlays/ovl_En_Recepgirl/func_80C100DC.s:/* 00015C 80C1012C 9 asm/non_matchings/overlays/ovl_En_Recepgirl/func_80C100DC.s:/* 000164 80C10134 A09902AC */ sb $t9, 0x2ac($a0) asm/non_matchings/overlays/ovl_En_Recepgirl/EnRecepgirl_Init.s:/* 0000B4 80C10084 A24902AC */ sb $t1, 0x2ac($s2) ``` + in which we clearly see `lbu` ("load byte unsigned"), and hence this variable really is a `u8`. Hence we can add this to the actor struct too: + ```C typedef struct EnRecepgirl { /* 0x0000 */ Actor actor; @@ -484,17 +503,18 @@ typedef struct EnRecepgirl { You might think that was a lot of work for one variable, but it's pretty quick when you know what to do. Obviously this would be more difficult with a more common number, but it's often still worth trying. Removing some of the declarations for data that we have accounted for, the function now looks like this: + ```C ? func_80C10148(EnRecepgirl *); // extern -void EnRecepgirl_Init(Actor *thisx, GlobalContext *globalCtx) { +void EnRecepgirl_Init(Actor* thisx, PlayState* play) { EnRecepgirl* this = THIS; void **temp_s0; void **phi_s0; 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(play, &this->skelAnime, &D_06011B60, &D_06009890, this->jointTable, this->morphTable, 24); phi_s0 = D_80C106B0; if (D_80C106C8 == 0) { @@ -507,7 +527,7 @@ void EnRecepgirl_Init(Actor *thisx, GlobalContext *globalCtx) { } this->unk_2AC = 2; - if (Flags_GetSwitch(globalCtx, (s32) this->actor.params) != 0) { + if (Flags_GetSwitch(play, (s32) this->actor.params) != 0) { this->actor.textId = 0x2ADC; } else { this->actor.textId = 0x2AD9; @@ -520,35 +540,37 @@ We have one significant problem and a few minor ones left. ### Casts and boolean functions -mips2c likes casting a lot: this is useful for getting types, less so when the type is changed automatically, such as in `Flags_GetSwitch(globalCtx, (s32) this->actor.params)`. Also, if we look at this function's definition, we discover it will only return `true` or `false`, so we can remove the `!= 0`. +mips2c likes casting a lot: this is useful for getting types, less so when the type is changed automatically, such as in `Flags_GetSwitch(play, (s32) this->actor.params)`. Also, if we look at this function's definition, we discover it will only return `true` or `false`, so we can remove the `!= 0`. ### Functions called One minor problem is what `func_80C10148` is: C needs a prototype to compile it properly. mips2c has offered us `? func_80C10148(EnRecepgirl *); // extern`, but this is obviously incomplete: there's no `?` type in C! We shall guess for now that this function returns `void`, for two reasons: + 1. It's not used as a condition in a conditional or anything 2. It's not used to assign a value To this experience will add a third reason: -3. This is probably a setup function for an actionFunc, which are usually either `void (*)(ActorType*)` or `void (*)(ActorType*, GlobalContext*)`. +3. This is probably a setup function for an actionFunc, which are usually either `void (*)(ActorType*)` or `void (*)(ActorType*, PlayState*)`. The upshot of all this is to remove mips2c's `? func_80C10148(EnRecepgirl *); // extern`, and add a `void func_80C10148(EnRecepgirl* this);` underneath the declarations for the main four functions: + ```C -void EnRecepgirl_Init(Actor* thisx, GlobalContext* globalCtx); -void EnRecepgirl_Destroy(Actor* thisx, GlobalContext* globalCtx); -void EnRecepgirl_Update(Actor* thisx, GlobalContext* globalCtx); -void EnRecepgirl_Draw(Actor* thisx, GlobalContext* globalCtx); +void EnRecepgirl_Init(Actor* thisx, PlayState* play); +void EnRecepgirl_Destroy(Actor* thisx, PlayState* play); +void EnRecepgirl_Update(Actor* thisx, PlayState* play); +void EnRecepgirl_Draw(Actor* thisx, PlayState* play); void func_80C10148(EnRecepgirl* this); ``` (we usually leave a blank line after the main four, and put all further declarations in address order). - ### Loops Loops are often some of the hardest things to decompile, because there are many ways to write a loop, only some of which will generate the same assembly. mips2c has had a go at the one in this function, but it usually struggles with loops: don't expect it to get a loop correct, well, at all. The code in question is + ```C void **temp_s0; void **phi_s0; @@ -567,46 +589,55 @@ The code in question is ``` `D_80C106B0` is the array that mips2c has declared above the function, a set of 8-digit hex numbers starting `0x06`. These are likely to be *segmented pointers*, but this is not a very useful piece of information yet. `D_80C106C0` is the InitChain, though, and it seems pretty unlikely that it would be seriously involved in any sort of loop. Indeed, if you tried to compile this now, you would get an error: + ``` cfe: Error: src/overlays/actors/ovl_En_Recepgirl/z_en_recepgirl.c, line 61: Unacceptable operand of == or != } while (temp_s0 != D_80C106C0); -------------------------^ ``` + so this can't possibly be right. So what on earth is this loop doing? Probably the best thing to do is manually unroll it and see what it's doing each time. -0. `phi_s0 = D_80C106B0`, aka `&D_80C106B0[0]`, to `temp_s0 = D_80C106B0 + 4`, i.e. `&D_80C106B0[1]`. But then `temp_s0->unk-4` is 4 backwards from `&D_80C106B0[1]`, which is back at `&D_80C106B0[0]`; the `->` means to look at what is at this address, so `temp_s0->unk-4` is `D_80C106B0[0]`. Equally, `*phi_s0` is the thing at `&D_80C106B0[0]`, i.e. `D_80C106B0[0]`. So the actual thing the first pass does is +1. `phi_s0 = D_80C106B0`, aka `&D_80C106B0[0]`, to `temp_s0 = D_80C106B0 + 4`, i.e. `&D_80C106B0[1]`. But then `temp_s0->unk-4` is 4 backwards from `&D_80C106B0[1]`, which is back at `&D_80C106B0[0]`; the `->` means to look at what is at this address, so `temp_s0->unk-4` is `D_80C106B0[0]`. Equally, `*phi_s0` is the thing at `&D_80C106B0[0]`, i.e. `D_80C106B0[0]`. So the actual thing the first pass does is + ```C D_80C106B0[0] = Lib_SegmentedToVirtual(D_80C106B0[0]); ``` + it then proceeds to set `phi_s0 = &D_80C106B0[1]` for the next iteration. -1. We go through the same reasoning and find the inside of the loop is +2. We go through the same reasoning and find the inside of the loop is + ```C temp_s0 = &D_80C106B0[2]; D_80C106B0[1] = Lib_SegmentedToVirtual(D_80C106B0[1]); phi_s0 = &D_80C106B0[2]; ``` -2. +3. + ```C temp_s0 = &D_80C106B0[3]; D_80C106B0[2] = Lib_SegmentedToVirtual(D_80C106B0[2]); phi_s0 = &D_80C106B0[3]; ``` -3. +4. + ```C temp_s0 = &D_80C106B0[4]; D_80C106B0[3] = Lib_SegmentedToVirtual(D_80C106B0[3]); phi_s0 = &D_80C106B0[4]; ``` + But now, `&D_80C106B0[4] = D_80C106B0 + 4 * 4 = D_80C106B0 + 0x10`, and `0x10` after this array's starting address is `D_80C106C0`, i.e. the InitChhain. Hence at this point the looping ends. So what this loop actually does is run `Lib_SegmentedToVirtual` on each element of the array `D_80C106B0`. At this point, I confess that I guessed what this loop does, and rewrote it how I would have written it, namely how one usually iterates over an array: + ```C s32 i; [...] @@ -625,12 +656,12 @@ Hence we end up with void func_80C10148(EnRecepgirl* this); [...] -void EnRecepgirl_Init(Actor *thisx, GlobalContext *globalCtx) { +void EnRecepgirl_Init(Actor* thisx, PlayState* play) { EnRecepgirl* this = THIS; 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(play, &this->skelAnime, &D_06011B60, &D_06009890, this->jointTable, this->morphTable, 24); if (D_80C106C8 == 0) { for (i = 0; i < 4; i++) { @@ -641,7 +672,7 @@ void EnRecepgirl_Init(Actor *thisx, GlobalContext *globalCtx) { this->unk_2AC = 2; - if (Flags_GetSwitch(globalCtx, this->actor.params)) { + if (Flags_GetSwitch(play, this->actor.params)) { this->actor.textId = 0x2ADC; } else { this->actor.textId = 0x2AD9; @@ -650,6 +681,7 @@ void EnRecepgirl_Init(Actor *thisx, GlobalContext *globalCtx) { func_80C10148(this); } ``` + as our first guess. This doesn't look unreasonable... the question is, does it match? ## Diff @@ -659,9 +691,11 @@ Once preliminary cleanup and struct filling is done, most time spent matching fu In order to use `diff.py` with the symbol names, we need a copy of the code to compare against. In MM this is done as part of `make init`, and you can regenerate the `expected` directory (which is simply a known-good copy of `build` directory) by running `make diff-init`, which will check for an OK ROM and copy the build directory over. (Of course you need an OK ROM to do this; worst-case, you can checkout master and do a complete rebuild to get it). (You need to remake `expected` if you want to diff a function you have renamed: `diff.py` looks in the mapfiles for the function name, which won't work if the name has changed!) Now, we run diff on the function name: in the main directory, + ``` $ ./diff.py -mwo3 EnRecepgirl_Init ``` + (To see what these arguments do, run it with `./diff.py -h` or look in the scripts documentation.) ![FeelsOKMan completely white diff](images/EnRecepgirl_Init_diff_matching.png) diff --git a/docs/tutorial/contents.md b/docs/tutorial/contents.md index 0435becb4..bb703f5c7 100644 --- a/docs/tutorial/contents.md +++ b/docs/tutorial/contents.md @@ -1,12 +1,15 @@ # Getting started ## [Introduction to decomp](introduction.md) + - What we are doing - Structure of the code ## Pre-decompilation + +- [Introduction to git](intro_to_git.md) - Building the repo (follow the instructions in the [README.md](../../README.md)) -- Most of us use VSCode. Some useful information is [here](vscode.md). +- Most of us use VSCode. Some useful information is [here](vscode.md). - Choosing a first actor (You want something small that has simple interactions with the environment. A simple NPC can also work, and is what we will use as an illustration for most of the tutorial. There is a collection of actors we think are suitable for beginners on the spreadsheet or Trello) @@ -35,15 +38,17 @@ - [Documenting a decompiled file](documenting.md) ## [Object Decompilation](object_decomp.md) + - Object files - How we decompile objects ## After Decompilation -- See the [CONTRIBUTING.md](../../CONTRIBUTING.md) for most of the details for submitting PRs. Remember to format again after making adjustments from reviews! +- See the [CONTRIBUTING.md](../CONTRIBUTING.md) for most of the details for submitting PRs. Remember to format again after making adjustments from reviews! - More information about specific preparations is in [this document](merging.md). ## Appendices + - [Types, Structs and Padding](types_structs_padding.md) (a miscellany of useful stuff) - [Advanced control flow](advanced_control_flow.md) (an example of a more complex function which mips2c is not so good at) - [Using the diff script and the permuter](diff_and_permuter.md) (using the diff script and the permuter to match something) diff --git a/docs/tutorial/data.md b/docs/tutorial/data.md index 972451b07..0a19113e4 100644 --- a/docs/tutorial/data.md +++ b/docs/tutorial/data.md @@ -5,16 +5,20 @@ ## Table of Contents -- [Data first](#data-first) -- [Extern and data last](#extern-and-data-last) -- [Segmented pointers and object symbols](#segmented-pointers-and-object-symbols) -- [Fake symbols](#fake-symbols) -- [Inlining](#inlining) +- [Data](#data) + - [Table of Contents](#table-of-contents) + - [Data first](#data-first) + - [Extern and data last](#extern-and-data-last) + - [Segmented pointers and object symbols](#segmented-pointers-and-object-symbols) + - [Fake symbols](#fake-symbols) + - [Inlining](#inlining) +- [Finally: .bss](#finally-bss) Each actor's data is stored in a separate file. EnRecepgirl's data is in `data/overlays/ovl_En_Recepgirl/ovl_En_Recepgirl.data.s`, for example. At some point in the decompilation process we need to convert this raw data into recognisable information for the C to use. -There are two main ways to do this: either -1. import the data first and type it later, or +There are two main ways to do this: either + +1. import the data first and type it later, or 2. wait until the data appears in functions, extern it, then import it at the end Sometimes something between these two is appropriate: wait until the largest or strangest bits of data appear in functions, get some typing information out of that, and then import it, but for now, let's stick to both of these. @@ -25,16 +29,18 @@ Both approaches have their advantages and disadvantages. This way is good for smaller actors with little data. The OoT tutorial [covers this in plenty of detail](https://github.com/zeldaret/oot/blob/master/docs/tutorial/data.md), and the process in MM is essentially identical, so we won't go over it here. - ## Extern and data last Externing is explained in detail in the document about the [Init function](beginning_decomp.md). To summarize, every time a `D_address` appears that is in the data file, we put a + ```C extern UNK_TYPE D_address; ``` + at the top of the file, in the same order that the data appears in the data file. We can also give it a type if we know what the type actually is (e.g. for colliders, initchains, etc.), and convert the actual data and place it commented-out under the corresponding line. This means we don't have to do everything at once at the end. Once we have decompiled enough things to know what the data is, we can import it. The advantage of doing it this way is we should know what type everything is already: in our work on EnRecepgirl, for example, we ended up with the following data at the top of the file + ```C #if 0 const ActorInit En_Recepgirl_InitVars = { @@ -61,11 +67,13 @@ static s32 D_80C106C8 = 0; #endif ``` + and the main thing we need to understand is `D_80C106B0` *Before doing anything else, make sure `make` gives `OK`.* First, we tell the compiler to ignore the original data file. To do this, open the file called `spec` in the main directory of the repository, and search for the actor name. You will find a section that looks like + ``` beginseg name "ovl_En_Recepgirl" @@ -75,7 +83,9 @@ beginseg include "build/data/ovl_En_Recepgirl/ovl_En_Recepgirl.reloc.o" endseg ``` + We will eventually remove both of the bottom two lines and replace them with our own reloc file, but for now, just comment out the data line: + ``` beginseg name "ovl_En_Recepgirl" @@ -87,6 +97,7 @@ endseg ``` Next remove all the externs, and uncomment their corresponding commented data: + ```C const ActorInit En_Recepgirl_InitVars = { ACTOR_EN_RECEPGIRL, @@ -111,20 +122,22 @@ static InitChainEntry D_80C106C0[] = { static s32 D_80C106C8 = 0; ``` -That should be everything, and we should now be able to `make` without the data file with no issues. - +That should be everything, and we should now be able to `make` without the data file with no issues. ## Segmented pointers and object symbols The game has a convenient system that allows it to sometimes effectively use offsets into a file instead of raw memory addresses to reference things. This is done by setting a file address to a *segment*. A segmented address is of the form `0x0XYYYYYY`, where `X` is the segment number. There are 16 available segments, and actors always set segment 6 to their object file, which is a file containing assets (skeleton, animations, textures, etc.) that they use. This is what all those `D_06...` are, and it is also what the entries in `D_80C106B0` are: they are currently raw numbers instead of symbols, though, and we would like to replace them. -There is an obvious problem here, which is that is that these symbols have to be defined *somewhere*, or the linker will complain (indeed, if we change the ones in the array to `D_...`, even if we extern them, we get +There is an obvious problem here, which is that is that these symbols have to be defined *somewhere*, or the linker will complain (indeed, if we change the ones in the array to `D_...`, even if we extern them, we get + ``` mips-linux-gnu-ld: build/src/overlays/actors/ovl_En_Recepgirl/z_en_recepgirl.o:(.data+0x20): undefined reference to `D_0600F8F0' -```` +``` + As we'd expect, of course: we didn't fulfil our promise that they were defined elsewhere.) For actors which have yet to be decompiled, this is mitigated by use of the file `undefined_syms.txt`, which feeds the linker the raw addresses to use as the symbol definitions. However, we want to replace these segmented addresses with proper object symbols whenever possible. In `En_Recepgirl_InitVars`, we can see that this actor uses the object `OBJECT_BG`: + ```c const ActorInit En_Recepgirl_InitVars = { ACTOR_EN_RECEPGIRL, @@ -135,6 +148,7 @@ const ActorInit En_Recepgirl_InitVars = { ``` If we open up `assets/objects/object_bg.h`, we can see a bunch of different names corresponding to every asset in the object. You may notice that some of these names look a bit familiar; `object_bg_Tex_00F8F0` seems very close to the segmented address `(void*)0x600F8F0`. This is the proper object symbol for this segmented address, so we should `#include` this header in our actor and use these object symbols like so: + ```c static void* D_80C106B0[4] = { object_bg_Tex_00F8F0, object_bg_Tex_00FCF0, object_bg_Tex_0100F0, object_bg_Tex_00FCF0 }; ``` @@ -143,21 +157,19 @@ After replacing every segmented pointer with an object symbol, you should go ahe We will come back and name these later when we do the object. - ## Fake symbols Some symbols in the data have been decompiled wrongly, being incorrectly separated from the previous symbol due to how it was accessed by the actor's functions. However, most of these have now been fixed. Some more detail is given in [Types, structs and padding](types_structs_padding.md) If you are unsure, ask! - ## Inlining After the file is finished, it is possible to move some static data into functions. This requires that: + 1. The data is used in only one function 2. The ordering of the data can be maintained Additionally, we prefer to keep larger data (more than a line or two) out of functions anyway. - # Finally: .bss A .bss contains data that is uninitialised (actually initialised to `0`). For most actors all you need to do is declare it at the top of the actor file without giving it a value, once you find out what type it is. In `code`, it's much more of a problem. diff --git a/docs/tutorial/diff_and_permuter.md b/docs/tutorial/diff_and_permuter.md index aa72999d1..2b5d41e30 100644 --- a/docs/tutorial/diff_and_permuter.md +++ b/docs/tutorial/diff_and_permuter.md @@ -51,7 +51,7 @@ You can keep the diff open in the terminal, and it will refresh when the C file In this case, we see that various branches are happening in the wrong place. Here I fear experience is necessary: notice that the function has three blocks that look quite similar, and three separate conditionals that depend on the same variable. This is a good indicator of a switch. Changing the function to use a switch, ```C -void EnJj_Init(Actor* thisx, GlobalContext* globalCtx) { +void EnJj_Init(Actor* thisx, PlayState* play) { EnJj* this = THIS; s32 sp4C; @@ -64,7 +64,7 @@ void EnJj_Init(Actor* thisx, GlobalContext* globalCtx) { switch (temp_v0) { case -1: - SkelAnime_InitFlex(globalCtx, &this->skelAnime, &D_0600B9A8, &D_06001F4C, this->jointTable, + SkelAnime_InitFlex(play, &this->skelAnime, &D_0600B9A8, &D_06001F4C, this->jointTable, this->morphTable, 22); Animation_PlayLoop(&this->skelAnime, &D_06001F4C); this->unk_30A = 0; @@ -78,24 +78,24 @@ void EnJj_Init(Actor* thisx, GlobalContext* globalCtx) { func_80A87800(this, func_80A87C30); } this->childActor = Actor_SpawnAsChild( - &globalCtx->actorCtx, &this->dyna.actor, globalCtx, ACTOR_EN_JJ, this->dyna.actor.world.pos.x - 10.0f, + &play->actorCtx, &this->dyna.actor, play, ACTOR_EN_JJ, this->dyna.actor.world.pos.x - 10.0f, this->dyna.actor.world.pos.y, this->dyna.actor.world.pos.z, 0, this->dyna.actor.world.rot.y, 0, 0); DynaPolyActor_Init(&this->dyna, 0); CollisionHeader_GetVirtual(&D_06000A1C, &sp4C); this->dyna.bgId = - DynaPoly_SetBgActor(globalCtx, &globalCtx->colCtx.dyna, &this->dyna.actor, sp4C); - Collider_InitCylinder(globalCtx, &this->collider); - Collider_SetCylinder(globalCtx, &this->collider, &this->dyna.actor, &D_80A88CB4); + DynaPoly_SetBgActor(play, &play->colCtx.dyna, &this->dyna.actor, sp4C); + Collider_InitCylinder(play, &this->collider); + Collider_SetCylinder(play, &this->collider, &this->dyna.actor, &D_80A88CB4); this->dyna.actor.colChkInfo.mass = 0xFF; break; case 0: DynaPolyActor_Init(&this->dyna, 0); CollisionHeader_GetVirtual(&D_06001830, &sp4C); - // temp_a1_2 = &globalCtx->colCtx.dyna; + // temp_a1_2 = &play->colCtx.dyna; // sp44 = temp_a1_2; this->dyna.bgId = - DynaPoly_SetBgActor(globalCtx, &globalCtx->colCtx.dyna, &this->dyna.actor, sp4C); - func_8003ECA8(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); + DynaPoly_SetBgActor(play, &play->colCtx.dyna, &this->dyna.actor, sp4C); + func_8003ECA8(play, &play->colCtx.dyna, this->dyna.bgId); this->dyna.actor.update = func_80A87F44; this->dyna.actor.draw = NULL; Actor_SetScale(&this->dyna.actor, 0.087f); @@ -104,7 +104,7 @@ void EnJj_Init(Actor* thisx, GlobalContext* globalCtx) { DynaPolyActor_Init(&this->dyna, 0); CollisionHeader_GetVirtual(&D_0600BA8C, &sp4C); this->dyna.bgId = - DynaPoly_SetBgActor(globalCtx, &globalCtx->colCtx.dyna, &this->dyna.actor, sp4C); + DynaPoly_SetBgActor(play, &play->colCtx.dyna, &this->dyna.actor, sp4C); this->dyna.actor.update = func_80A87F44; this->dyna.actor.draw = NULL; Actor_SetScale(&this->dyna.actor, 0.087f); @@ -123,10 +123,10 @@ we see that the diff is nearly correct (note that `-3` lets you compare current ![Init diff 2](images/init_diff2.png) -except we still have some stack issues. Now that `temp_v0` is only used once, it looks fake. Eliminating it actually seems to make the stack worse. To fix this, we employ something that we have evidence that the developers did: namely, we make a copy of `globalCtx` (the theory is that they actually used `gameState` as an argument of the main 4 functions, just like we used `Actor* thisx` as the first argument.) The quick way to do this is to change the top of the function to +except we still have some stack issues. Now that `temp_v0` is only used once, it looks fake. Eliminating it actually seems to make the stack worse. To fix this, we employ something that we have evidence that the developers did: namely, we make a copy of `play` (the theory is that they actually used `gameState` as an argument of the main 4 functions, just like we used `Actor* thisx` as the first argument.) The quick way to do this is to change the top of the function to ```C -void EnJj_Init(Actor* thisx, GlobalContext* globalCtx2) { - GlobalContext* globalCtx = globalCtx2; +void EnJj_Init(Actor* thisx, PlayState* play2) { + PlayState* play = play2; EnJj* this = THIS; ... ``` diff --git a/docs/tutorial/disassembly_quirks.md b/docs/tutorial/disassembly_quirks.md index dacfb78d8..34a01a6f3 100644 --- a/docs/tutorial/disassembly_quirks.md +++ b/docs/tutorial/disassembly_quirks.md @@ -10,12 +10,10 @@ Variables must be renamed in `tools/disasm/variables.txt`. It may also be necess You can avoid having to redisassemble every time by running `rename_global_asm.py`, which will rename the individual functions' assembly files in `asm/nonmatchings/` to the name of the function they contain. - ## Fake and incorrect symbols TODO - ## Resplitting a file The files `boot` and `code` are each divided up into dozens of separate files, that are all joined together into one text, data, rodata and bss section when building the ROM. As such, it has been necessary to guess where the file boundaries are, and not every file contains the correct functions or the correct data (rodata is mostly the exception since it is automatically split). @@ -31,6 +29,3 @@ To change a split for a file, find its entry in `tools/disasm/files.txt`, and ch to the file will extract it correctly as a separate file. It also is necessary to make a new C file and move the `GLOBAL_ASM` declaration into it. Unfortunately you essentially have to redisassemble after telling the disassembler to resplit a file. - - -## diff --git a/docs/tutorial/documenting.md b/docs/tutorial/documenting.md index a5e64d2a9..2e98e1efd 100644 --- a/docs/tutorial/documenting.md +++ b/docs/tutorial/documenting.md @@ -17,14 +17,12 @@ If you want to use `diff.py` after renaming anything, particularly functions, re Finally, *if you are not sure what something does, either ask or leave it unnamed: it will be less confusing later if things are unnamed than if they are wrongly named* - ## Renaming things Because MM needs to regenerate the assembly code, it is necessary to tell the disassembler the names of functions and variables, so it knows what symbols to assign in the code. This is done via `functions.txt` and `variables.txt`. The best way to rename functions and symbols is via global rename in an editor like VSCode. The next best way is to run `tools/rename_sym.sh`. You should be careful with this script: it has no error-checking! Renaming symbols in theory requires re-disassembly. This can often be avoided in the case of functions by running `tools/rename_global_asm.py`, which will rename any individual functions' assembly files with the wrong names, so that the `GLOBAL_ASM`s can spot them. Renaming variables *may* require redisassembly (and if fake symbols are removed, it *will*). - ## EnRecepgirl Currently, the file looks like this: @@ -40,15 +38,15 @@ Large code block, click to show #define THIS ((EnRecepgirl*)thisx) -void EnRecepgirl_Init(Actor* thisx, GlobalContext* globalCtx); -void EnRecepgirl_Destroy(Actor* thisx, GlobalContext* globalCtx); -void EnRecepgirl_Update(Actor* thisx, GlobalContext* globalCtx); -void EnRecepgirl_Draw(Actor* thisx, GlobalContext* globalCtx); +void EnRecepgirl_Init(Actor* thisx, PlayState* play); +void EnRecepgirl_Destroy(Actor* thisx, PlayState* play); +void EnRecepgirl_Update(Actor* thisx, PlayState* play); +void EnRecepgirl_Draw(Actor* thisx, PlayState* play); void func_80C10148(EnRecepgirl* this); -void func_80C1019C(EnRecepgirl* this, GlobalContext* globalCtx); +void func_80C1019C(EnRecepgirl* this, PlayState* play); void func_80C10290(EnRecepgirl* this); -void func_80C102D4(EnRecepgirl * this, GlobalContext * globalCtx); +void func_80C102D4(EnRecepgirl* this, PlayState* play); const ActorInit En_Recepgirl_InitVars = { ACTOR_EN_RECEPGIRL, @@ -73,13 +71,13 @@ static InitChainEntry D_80C106C0[] = { static s32 D_80C106C8 = 0; // #pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Recepgirl/EnRecepgirl_Init.s") -void EnRecepgirl_Init(Actor* thisx, GlobalContext* globalCtx) { +void EnRecepgirl_Init(Actor* thisx, PlayState* play) { EnRecepgirl* this = THIS; s32 i; Actor_ProcessInitChain(&this->actor, D_80C106C0); ActorShape_Init(&this->actor.shape, -60.0f, NULL, 0.0f); - SkelAnime_InitFlex(globalCtx, &this->skelAnime, &object_bg_Skel_011B60, &object_bg_Anim_009890, this->jointTable, this->morphTable, 24); + SkelAnime_InitFlex(play, &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++) { @@ -90,7 +88,7 @@ void EnRecepgirl_Init(Actor* thisx, GlobalContext* globalCtx) { this->unk_2AC = 2; - if (Flags_GetSwitch(globalCtx, this->actor.params)) { + if (Flags_GetSwitch(play, this->actor.params)) { this->actor.textId = 0x2ADC; } else { this->actor.textId = 0x2AD9; @@ -100,7 +98,7 @@ void EnRecepgirl_Init(Actor* thisx, GlobalContext* globalCtx) { } // #pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Recepgirl/EnRecepgirl_Destroy.s") -void EnRecepgirl_Destroy(Actor* thisx, GlobalContext* globalCtx) { +void EnRecepgirl_Destroy(Actor* thisx, PlayState* play) { } // #pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Recepgirl/func_80C100DC.s") @@ -127,7 +125,7 @@ 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) { +void func_80C1019C(EnRecepgirl* this, PlayState* play) { if (SkelAnime_Update(&this->skelAnime) != 0) { if (this->skelAnime.animation == &object_bg_Anim_00A280) { Animation_MorphToPlayOnce(&this->skelAnime, &object_bg_Anim_00AD98, 5.0f); @@ -136,13 +134,13 @@ void func_80C1019C(EnRecepgirl* this, GlobalContext* globalCtx) { } } - if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state) != 0) { + if (Actor_ProcessTalkRequest(&this->actor, &play->state) != 0) { func_80C10290(this); } else if (Actor_IsFacingPlayer(&this->actor, 0x2000)) { - func_800B8614(&this->actor, globalCtx, 60.0f); - if (Player_GetMask(globalCtx) == 2) { + func_800B8614(&this->actor, play, 60.0f); + if (Player_GetMask(play) == 2) { this->actor.textId = 0x2367; - } else if (Flags_GetSwitch(globalCtx, this->actor.params)) { + } else if (Flags_GetSwitch(play, this->actor.params)) { this->actor.textId = 0x2ADC; } else { this->actor.textId = 0x2AD9; @@ -157,7 +155,7 @@ void func_80C10290(EnRecepgirl *this) { } // #pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Recepgirl/func_80C102D4.s") -void func_80C102D4(EnRecepgirl *this, GlobalContext *globalCtx) { +void func_80C102D4(EnRecepgirl* this, PlayState* play) { u8 temp_v0_2; if (SkelAnime_Update(&this->skelAnime) != 0) { @@ -176,16 +174,16 @@ void func_80C102D4(EnRecepgirl *this, GlobalContext *globalCtx) { } } - temp_v0_2 = Message_GetState(&globalCtx->msgCtx); + temp_v0_2 = Message_GetState(&play->msgCtx); if (temp_v0_2 == 2) { this->actor.textId = 0x2ADC; func_80C10148(this); return; } - if ((temp_v0_2 == 5) && (Message_ShouldAdvance(globalCtx) != 0)) { + if ((temp_v0_2 == 5) && (Message_ShouldAdvance(play) != 0)) { if (this->actor.textId == 0x2AD9) { - Flags_SetSwitch(globalCtx, this->actor.params); + Flags_SetSwitch(play, this->actor.params); Animation_MorphToPlayOnce(&this->skelAnime, &object_bg_Anim_00AD98, 10.0f); if ((gSaveContext.save.weekEventReg[63] & 0x80)) { this->actor.textId = 0x2ADF; @@ -205,23 +203,23 @@ void func_80C102D4(EnRecepgirl *this, GlobalContext *globalCtx) { this->actor.textId = 0x2AE0; } } - func_80151938(globalCtx, this->actor.textId); + func_80151938(play, this->actor.textId); } } // #pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Recepgirl/EnRecepgirl_Update.s") -void EnRecepgirl_Update(Actor *thisx, GlobalContext *globalCtx) { +void EnRecepgirl_Update(Actor* thisx, PlayState* play) { s32 pad; EnRecepgirl* this = THIS; Vec3s sp30; - this->actionFunc(this, globalCtx); - func_800E9250(globalCtx, &this->actor, &this->unk_2AE, &sp30, this->actor.focus.pos); + this->actionFunc(this, play); + Actor_TrackPlayer(play, &this->actor, &this->unk_2AE, &sp30, this->actor.focus.pos); func_80C100DC(this); } // #pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Recepgirl/func_80C10558.s") -s32 func_80C10558(GlobalContext *globalCtx, s32 limbIndex, Gfx **dList, Vec3f *pos, Vec3s *rot, Actor *thisx) { +s32 func_80C10558(PlayState* play, s32 limbIndex, Gfx **dList, Vec3f *pos, Vec3s *rot, Actor *thisx) { EnRecepgirl* this = THIS; if (limbIndex == 5) { @@ -231,28 +229,28 @@ s32 func_80C10558(GlobalContext *globalCtx, s32 limbIndex, Gfx **dList, Vec3f *p } // #pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Recepgirl/func_80C10590.s") -void func_80C10590(GlobalContext *globalCtx, s32 limbIndex, Actor *thisx) { +void func_80C10590(PlayState* play, 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); } } // #pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Recepgirl/EnRecepgirl_Draw.s") -void EnRecepgirl_Draw(Actor *thisx, GlobalContext *globalCtx) { +void EnRecepgirl_Draw(Actor* thisx, PlayState* play) { EnRecepgirl* this = THIS; - OPEN_DISPS(globalCtx->state.gfxCtx); + OPEN_DISPS(play->state.gfxCtx); - func_8012C28C(globalCtx->state.gfxCtx); + func_8012C28C(play->state.gfxCtx); gSPSegment(POLY_OPA_DISP++, 0x08, D_80C106B0[this->unk_2AC]); - SkelAnime_DrawTransformFlexOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, func_80C10558, NULL, func_80C10590, &this->actor); + SkelAnime_DrawTransformFlexOpa(play, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, func_80C10558, NULL, func_80C10590, &this->actor); - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->state.gfxCtx); } ``` @@ -262,12 +260,15 @@ void EnRecepgirl_Draw(Actor *thisx, GlobalContext *globalCtx) { (We can delete the `GLOBAL_ASM` lines now.) The worst part of documentation is finding somewhere to start. We have a decent place to start here, though, in that we already know the function (or rather, the use) of a couple of the functions, namely the LimbDraws. So we can rename `func_80C10558` to `EnRecepgirl_OverrideLimbDraw` and `func_80C10590` to `EnRecepgirl_TransformLimbDraw`. Remember to do a global rename so that the functions in the assembly are renamed, use `rename_global_asm`, + ``` $ ./tools/rename_global_asm.py asm/non_matchings/overlays/ovl_En_Recepgirl/func_80C10558.s --> asm/non_matchings/overlays/ovl_En_Recepgirl/EnRecepgirl_OverrideLimbDraw.s asm/non_matchings/overlays/ovl_En_Recepgirl/func_80C10590.s --> asm/non_matchings/overlays/ovl_En_Recepgirl/EnRecepgirl_UnkLimbDraw.s ``` + as well as the mentions in this chunk of `functions.txt`: + ``` 0x80C0FFD0:("EnRecepgirl_Init",), 0x80C100CC:("EnRecepgirl_Destroy",), @@ -283,13 +284,15 @@ as well as the mentions in this chunk of `functions.txt`: ``` That's probably as much as we can do on functions for now. Next let's think about some of the variables. We have essentially 3 sorts of variable here + - struct variables - data/bss - intrafunction/stack variables -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 typedef struct EnRecepgirl { /* 0x000 */ Actor actor; @@ -303,12 +306,15 @@ typedef struct EnRecepgirl { ``` Let's start with `unk_2AC`. This is set to `2` in `Init`, something interesting happens to it in `func_80C100DC`, but it is used in the `Draw`, here: + ```C gSPSegment(POLY_OPA_DISP++, 0x08, D_80C106B0[this->unk_2AC]); ``` + So it is used as an index into the array `D_80C106B0`, and the element with that index is placed on segment `8`. So we need to work out what this array is to name `unk_2AC`. As we discussed last time, `D_80C106B0` is an array of [segmented pointers](data.md#segmented-pointers). Since they are in segment `6`, they are in the actor's object file. Which object? The InitVars tell us: namely, + ```C const ActorInit En_Recepgirl_InitVars = { ACTOR_EN_RECEPGIRL, @@ -316,8 +322,8 @@ const ActorInit En_Recepgirl_InitVars = { FLAGS, OBJECT_BG, ``` -the fourth element is the object (it is actually an enum, but the file itself has the same name as the object enum). So, we need to look at the object file. We are very lucky that a custom tool has been written for such a thing: Z64Utils. +the fourth element is the object (it is actually an enum, but the file itself has the same name as the object enum). So, we need to look at the object file. We are very lucky that a custom tool has been written for such a thing: Z64Utils. ## Z64Utils @@ -336,14 +342,17 @@ Go to "Analysis -> Find Dlists" and press OK (the defaults are usually fine). Th ![Z64Utils, with an analyzed object](images/z64utils_object_analyzed.png) We will talk about what all these types of data are next time, but for now, all we want to know is what + ```C static void* D_80C106B0[4] = { object_bg_Tex_00F8F0, object_bg_Tex_00FCF0, object_bg_Tex_0100F0, object_bg_Tex_00FCF0 }; ``` + actually are. We know they are set on segment 8, so we need to find where the skeleton uses them. We know from `object_bg_Skel_011B60` that this is at `0x06011B60`, so scroll down to it, right-click on it, and choose "Open in Skeleton Viewer". Pick an animation that we know it uses (sometimes Z64Utils misidentifies other things for animations), such as `object_bg_Anim_000968`, and you will get this error: ![Z64Utils, error when viewing skeleton](images/z64utils_skeleton_error.png) It needs something to be set to segment `8`. Well, that's good, we know that the code does that! Let's find out what. Z64Utils tells you the address, so we can look up the displaylist that wants it: the relevant block is + ```C [...] // Multi Command Macro Found (6 instructions) @@ -374,11 +383,13 @@ so we see that segment `8` is expecting a texture (we'll go into more detail abo But what sort of textures? This is an NPC, so what textures on the model would it want to change? The answer is of course the eyes: most NPCs have eye textures, with some sort of routine for changing them to appear to blink. We can set the different textures onto segment `8` and see which is which, but this is enough to know that `D_80C106B0` can be `sEyeTextures` (`s` for `static`: they essentially have to be static so that we can name them like this without the names clashing), and that `unk_2AC` is `eyeTexIndex` (these names are not completely standard, but it's best to be as consistent as possible). **N.B.** static data should not be renamed in the assembly or `variables.txt`, since assembly has no notion of file locality and there can be symbol clashes. Therefore it should only be renamed in its respective file, not globally. + ```C static TexturePtr sEyeTextures[] = { object_bg_Tex_00F8F0, object_bg_Tex_00FCF0, object_bg_Tex_0100F0, object_bg_Tex_00FCF0 }; ``` And now it's rather more obvious what + ```C void func_80C100DC(EnRecepgirl* this) { if (this->eyeTexIndex != 0) { @@ -391,11 +402,13 @@ void func_80C100DC(EnRecepgirl* this) { } } ``` + is doing: it's running a kind of blink routine. This is slightly nonstandard: usually there is a separate timer, but this one simply perturbs the index away from `0` every frame with a 2% chance. This sort of function is usually called `Blink` or `UpdateEyes`. Since it is explicitly called in `Update`, we'll call it `UpdateEyes`, but either is fine; we'll standardise later. We have two other pieces of data. There is a suggested name for the InitChain in the code already; just replace it and replace the first line in the definition. This leaves one piece of data unnamed, `D_80C106C8`. This is initially set to `0`, checked in `Init` to decide whether to run the loop, and then set to `1` after the loop is finished: + ```C if (D_80C106C8 == 0) { for (i = 0; i < 4; i++) { @@ -404,15 +417,17 @@ This leaves one piece of data unnamed, `D_80C106C8`. This is initially set to `0 D_80C106C8 = 1; } ``` + What is this doing? We need to understand that to name this variable. -The N64's processors cannot use segmented addresses: they need actual RAM addresses. Therefore the segmented addresses have to be converted before being placed on a segment: this is what `Lib_SegmentedToVirtual` does. So (somewhat unusually) this loop is modifying the addresses in the actor's actual data in RAM. Having converted the addresses once, it wouldn't make any sense to convert them again, but `Init` would run every time an instantiation of the actor is created. Therefore `D_80C106C8` is present to ensure that the addresses only get converted once: it is really a boolean that indicates if the addresses have been converted. So let's call it `texturesDesegmented`, and replace its values by `true` and `false`. +The N64's processors cannot use segmented addresses: they need actual RAM addresses. Therefore the segmented addresses have to be converted before being placed on a segment: this is what `Lib_SegmentedToVirtual` does. So (somewhat unusually) this loop is modifying the addresses in the actor's actual data in RAM. Having converted the addresses once, it wouldn't make any sense to convert them again, but `Init` would run every time an instantiation of the actor is created. Therefore `D_80C106C8` is present to ensure that the addresses only get converted once: it is really a boolean that indicates if the addresses have been converted. So let's call it `sTexturesDesegmented`, and replace its values by `true` and `false`. Finally, clearly `4` is linked to the data over which we're iterating: namely it's the size of the array. We have a macro for this, `ARRAY_COUNT(sEyeTextures)`. We've got one struct variable left. To find out what it does, we can look at a function that uses it, for example + ```C -s32 EnRecepgirl_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, +s32 EnRecepgirl_OverrideLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, Actor* thisx) { EnRecepgirl* this = THIS; @@ -422,15 +437,16 @@ s32 EnRecepgirl_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** return false; } -void EnRecepgirl_UnkLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Actor* thisx) { +void EnRecepgirl_UnkLimbDraw(PlayState* play, 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); } } ``` + It is used to do a rotation of whatever limb `5` is. (The `+=` is because `rot->x` is the base rotation of the limb, and we have to add the same thing to it every frame to keep the angle changed and constant.) We can use Z64Utils to : setting segment `8` to one of what we know now are the eye textures, we can view the model in the skeleton viewer. The limb numbers in the object are one smaller than those in the actor (the root limb is only a concept for the code, not the object), so we find limb 4: ![Z64Utils highlighting a limb](images/z64utils_skeleton_head.png) @@ -449,7 +465,7 @@ void func_80C10148(EnRecepgirl* this) { this->actionFunc = func_80C1019C; } -void func_80C1019C(EnRecepgirl* this, GlobalContext* globalCtx) { +void func_80C1019C(EnRecepgirl* this, PlayState* play) { if (SkelAnime_Update(&this->skelAnime) != 0) { if (this->skelAnime.animation == &object_bg_Anim_00A280) { Animation_MorphToPlayOnce(&this->skelAnime, &object_bg_Anim_00AD98, 5.0f); @@ -458,13 +474,13 @@ void func_80C1019C(EnRecepgirl* this, GlobalContext* globalCtx) { } } - if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state) != 0) { + if (Actor_ProcessTalkRequest(&this->actor, &play->state) != 0) { func_80C10290(this); } else if (Actor_IsFacingPlayer(&this->actor, 0x2000)) { - func_800B8614(&this->actor, globalCtx, 60.0f); - if (Player_GetMask(globalCtx) == PLAYER_MASK_KAFEIS_MASK) { + func_800B8614(&this->actor, play, 60.0f); + if (Player_GetMask(play) == PLAYER_MASK_KAFEIS_MASK) { this->actor.textId = 0x2367; // "... doesn't Kafei want to break off his engagement ... ?" - } else if (Flags_GetSwitch(globalCtx, this->actor.params)) { + } else if (Flags_GetSwitch(play, this->actor.params)) { this->actor.textId = 0x2ADC; // hear directions again? } else { this->actor.textId = 0x2AD9; // "Welcome..." @@ -477,7 +493,7 @@ void func_80C10290(EnRecepgirl* this) { this->actionFunc = func_80C102D4; } -void func_80C102D4(EnRecepgirl* this, GlobalContext* globalCtx) { +void func_80C102D4(EnRecepgirl* this, PlayState* play) { u8 temp_v0_2; if (SkelAnime_Update(&this->skelAnime)) { @@ -496,13 +512,13 @@ void func_80C102D4(EnRecepgirl* this, GlobalContext* globalCtx) { } } - temp_v0_2 = Message_GetState(&globalCtx->msgCtx); + temp_v0_2 = Message_GetState(&play->msgCtx); if (temp_v0_2 == 2) { this->actor.textId = 0x2ADC; // hear directions again? func_80C10148(this); - } else if ((temp_v0_2 == 5) && (Message_ShouldAdvance(globalCtx) != 0)) { + } else if ((temp_v0_2 == 5) && (Message_ShouldAdvance(play) != 0)) { if (this->actor.textId == 0x2AD9) { // "Welcome..." - Flags_SetSwitch(globalCtx, this->actor.params); + Flags_SetSwitch(play, this->actor.params); Animation_MorphToPlayOnce(&this->skelAnime, &object_bg_Anim_00AD98, 10.0f); if (gSaveContext.save.weekEventReg[63] & 0x80) { // showed Couple's Mask to meeting this->actor.textId = 0x2ADF; // Mayor's office is on the left (meeting ended) @@ -524,21 +540,22 @@ void func_80C102D4(EnRecepgirl* this, GlobalContext* globalCtx) { this->actor.textId = 0x2AE0; // drawing room on the right, don't go in without an appointment } } - func_80151938(globalCtx, this->actor.textId); + func_80151938(play, this->actor.textId); } } ``` -All this branching is to make the conversation look more diverse and interesting. Notably, though, `func_80C1019C` is set to start with, and is only changed when `Actor_ProcessTalkRequest(&this->actor, &globalCtx->state) != 0`. This is something to do with talking. The other function handles the rest of the conversation, and hands back to the first if `Message_GetState(&globalCtx->msgCtx) == 2`. This function is *something* to do with the text state, which will require `z_message` to be decomped. However, observation in-game will reveal this is something to do with ending dialogue. So we can conclude that the action functions are `EnRecepgirl_Wait` and `EnRecepgirl_Talk`. The setup functions are thus `EnRecepgirl_SetupWait` and `EnRecepgirl_SetupTalk`. +All this branching is to make the conversation look more diverse and interesting. Notably, though, `func_80C1019C` is set to start with, and is only changed when `Actor_ProcessTalkRequest(&this->actor, &play->state) != 0`. This is something to do with talking. The other function handles the rest of the conversation, and hands back to the first if `Message_GetState(&play->msgCtx) == 2`. This function is *something* to do with the text state, which will require `z_message` to be decomped. However, observation in-game will reveal this is something to do with ending dialogue. So we can conclude that the action functions are `EnRecepgirl_Wait` and `EnRecepgirl_Talk`. The setup functions are thus `EnRecepgirl_SetupWait` and `EnRecepgirl_SetupTalk`. + +For more complex actors, we have a tool called `graphovl.py` that can produce function flow graphs for actors: running -For more complex actors, we have a tool called `graphovl.py` that can produce function flow graphs for actors: running ``` $ ./tools/graphovl/graphovl.py En_Recepgirl ``` + produces ![EnRecepgirl's function flow graph](images/En_Recepgirl.gv.png) - ## Miscellaneous other documentation We like to make macros for reading an actor's `params` (indeed, this is required even if you don't know what the params are for). A simple example is `ObjTree`, which has the following code in its `Init` function: @@ -551,7 +568,7 @@ We like to make macros for reading an actor's `params` (indeed, this is required Actor_SetScale(&this->dyna.actor, 0.1f); DynaPolyActor_Init(&this->dyna, 1); CollisionHeader_GetVirtual(&object_tree_Colheader_001B2C, &colHeader); - this->dyna.bgId = DynaPoly_SetBgActor(globalCtx, &globalCtx->colCtx.dyna, &this->dyna.actor, colHeader); + this->dyna.bgId = DynaPoly_SetBgActor(play, &play->colCtx.dyna, &this->dyna.actor, colHeader); } ``` @@ -571,13 +588,12 @@ Notice that we use `thisx`: this makes the form of every one of these macros the Actor_SetScale(&this->dyna.actor, 0.1f); DynaPolyActor_Init(&this->dyna, 1); CollisionHeader_GetVirtual(&object_tree_Colheader_001B2C, &colHeader); - this->dyna.bgId = DynaPoly_SetBgActor(globalCtx, &globalCtx->colCtx.dyna, &this->dyna.actor, colHeader); + this->dyna.bgId = DynaPoly_SetBgActor(play, &play->colCtx.dyna, &this->dyna.actor, colHeader); } ``` Much clearer! - We have now essentially documented this as far as we can without the object, so we'd better do that next. Next: [Analysing object files](object_decomp.md) diff --git a/docs/tutorial/draw_functions.md b/docs/tutorial/draw_functions.md index eae1c121e..ccc738219 100644 --- a/docs/tutorial/draw_functions.md +++ b/docs/tutorial/draw_functions.md @@ -12,33 +12,32 @@ This document will be a bit different: we will look at the draw functions in EnR Unless it is completely invisible, an actor usually has a draw function as one of the main four actor functions. Hence its prototype looks like ```C -void EnRecepgirl_Draw(Actor* thisx, GlobalContext* globalCtx); +void EnRecepgirl_Draw(Actor* thisx, PlayState* play); ``` From now on, the process is rather different from the decompilation process used for the other functions. Here is the output of mips2c after sorting out the actor struct from Init, and with the arguments set back to `Actor* thisx`: ```C -s32 func_80C10558(GlobalContext *globalCtx, s32 limbIndex, Gfx **dList, Vec3f *pos, Vec3s *rot, Actor *actor); // extern -void func_80C10590(GlobalContext *globalCtx, s32 limbIndex, Actor *actor); // extern +s32 func_80C10558(PlayState* play, s32 limbIndex, Gfx **dList, Vec3f *pos, Vec3s *rot, Actor *actor); // extern +void func_80C10590(PlayState* play, s32 limbIndex, Actor *actor); // extern void *D_80C106B0[4] = {(void *)0x600F8F0, (void *)0x600FCF0, (void *)0x60100F0, (void *)0x600FCF0}; -void EnRecepgirl_Draw(Actor *thisx, GlobalContext *globalCtx) { +void EnRecepgirl_Draw(Actor* thisx, PlayState* play) { EnRecepgirl* this = (EnRecepgirl *) thisx; GraphicsContext *sp30; Gfx *temp_v1; GraphicsContext *temp_a0; - temp_a0 = globalCtx->state.gfxCtx; + temp_a0 = play->state.gfxCtx; sp30 = temp_a0; func_8012C28C(temp_a0); temp_v1 = sp30->polyOpa.p; sp30->polyOpa.p = temp_v1 + 8; temp_v1->words.w0 = 0xDB060020; temp_v1->words.w1 = (u32) D_80C106B0[this->unk_2AC]; - SkelAnime_DrawTransformFlexOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, (s32) this->skelAnime.dListCount, func_80C10558, NULL, func_80C10590, (Actor *) this); + SkelAnime_DrawTransformFlexOpa(play, this->skelAnime.skeleton, this->skelAnime.jointTable, (s32) this->skelAnime.dListCount, func_80C10558, NULL, func_80C10590, (Actor *) this); } ``` - Notable features are the GraphicsContext temps, and blocks of the form ```C @@ -54,14 +53,15 @@ Each of these blocks converts into a graphics macro. They are usually (but not a For our purposes, we only need one of the programs this provides: `gfxdis.f3dex2`. - Graphics are actually 64-bit on the Nintendo 64. This code block is a result of instructions telling the processor what to do with the graphics pointer. There are two main types of graphics pointer (there are a couple of others used in `code`, but actors will only use these two), + - polyOpa ("opaque") for solid textures - polyXlu ("Xlucent" i.e. "translucent") for translucent textures Our example is polyOpa, not surprisingly since our receptionist is solid. `words.w0` and `words.w1` contain the actual graphics instruction, in hex format. Usually, `w0` is constant and `w1` contains the arguments. To find out what sort of macro we are dealing with, we use `gfxdis.f3dex2`. `w1` is variable, but we need to give the program a constant placeholder. A common word to use is 12345678, so in this case we run + ``` gfxdis.f3dex2 -x -g "POLY_OPA_DISP++" -d DB06002012345678 ``` @@ -73,6 +73,7 @@ gfxdis.f3dex2 -x -g "POLY_OPA_DISP++" -d DB06002012345678 Our standard now is to use decimal colors. If you have a constant second argument rather than a variable one, you can also use `-dc` to get decimal colors instead of the default hex. The output looks like + ``` gSPSegment(POLY_OPA_DISP++, 0x08, 0x12345678); ``` @@ -90,48 +91,53 @@ You repeat this for every block in the function. If you have worked on OoT, you will be aware of the functions `Graph_OpenDisps` and `Graph_CloseDisps`, and might be surprised to see them missing here. These functions are actually a debug feature: the `OPEN_DISPS` and `CLOSE_DISPS` macros still exist, but they don't expand to functions. Of course this means you have to guess where they go. A sensible guess for `OPEN_DISPS` is where the `gfxCtx` temp assignment first happens; `CLOSE_DISPS` is a bit harder, although it's basically just a `}`, so it *shouldn't* matter as much. It's sensible to eliminate all the `gfxCtx` temps and reintroduce as needed. Also remember to change the prototype and function definition back! + ```C -s32 func_80C10558(GlobalContext *globalCtx, s32 limbIndex, Gfx **dList, Vec3f *pos, Vec3s *rot, Actor *actor); +s32 func_80C10558(PlayState* play, s32 limbIndex, Gfx **dList, Vec3f *pos, Vec3s *rot, Actor *actor); #pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Recepgirl/func_80C10558.s") -void func_80C10590(GlobalContext *globalCtx, s32 limbIndex, Actor *actor); +void func_80C10590(PlayState* play, s32 limbIndex, Actor *actor); #pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Recepgirl/func_80C10590.s") // #pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Recepgirl/EnRecepgirl_Draw.s") -void EnRecepgirl_Draw(Actor *thisx, GlobalContext *globalCtx) { +void EnRecepgirl_Draw(Actor* thisx, PlayState* play) { EnRecepgirl* this = THIS; - OPEN_DISPS(globalCtx->state.gfxCtx); + OPEN_DISPS(play->state.gfxCtx); - func_8012C28C(globalCtx->state.gfxCtx); + func_8012C28C(play->state.gfxCtx); gSPSegment(POLY_OPA_DISP++, 0x08, D_80C106B0[this->unk_2AC]); - SkelAnime_DrawTransformFlexOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, func_80C10558, NULL, func_80C10590, &this->actor); + SkelAnime_DrawTransformFlexOpa(play, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, func_80C10558, NULL, func_80C10590, &this->actor); - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->state.gfxCtx); } ``` And this matches. The last two functions in the actor are used as arguments in `SkelAnime_DrawTransformFlexOpa`. This is a `SkelAnime` function, except unlike the OoT ones, it has three function callback arguments instead of two: in `functions.h` or `z_skelanime.c`, we find + ```C -void SkelAnime_DrawTransformFlexOpa(GlobalContext* globalCtx, void** skeleton, Vec3s* jointTable, s32 dListCount, +void SkelAnime_DrawTransformFlexOpa(PlayState* play, void** skeleton, Vec3s* jointTable, s32 dListCount, OverrideLimbDrawOpa overrideLimbDraw, PostLimbDrawOpa postLimbDraw, TransformLimbDrawOpa transformLimbDraw, Actor* actor) ``` + The typedefs of the callbacks it uses are in `z64animation.h`: + ```C -typedef s32 (*OverrideLimbDrawOpa)(struct GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, +typedef s32 (*OverrideLimbDrawOpa)(struct PlayState* play, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, struct Actor* thisx); -typedef void (*PostLimbDrawOpa)(struct GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, +typedef void (*PostLimbDrawOpa)(struct PlayState* play, s32 limbIndex, Gfx** dList, Vec3s* rot, struct Actor* thisx); [...] -typedef void (*TransformLimbDrawOpa)(struct GlobalContext* globalCtx, s32 limbIndex, struct Actor* thisx); +typedef void (*TransformLimbDrawOpa)(struct PlayState* play, s32 limbIndex, struct Actor* thisx); ``` + which is where mips2c got them from. In this case, only two of them are used, and it is these that are the last functions standing between us and a decompiled actor. @@ -139,17 +145,20 @@ In this case, only two of them are used, and it is these that are the last funct ## OverrideLimbDraw, PostLimbDraw, TransformLimbDraw Well, we don't have a PostLimbDraw here, but as we see from the prototype, it's much the same as the OverrideLimbDraw but without the `pos` argument and no return value. + ```C -s32 func_80C10558(GlobalContext *globalCtx, s32 limbIndex, Gfx **dList, Vec3f *pos, Vec3s *rot, Actor *actor) { +s32 func_80C10558(PlayState* play, s32 limbIndex, Gfx **dList, Vec3f *pos, Vec3s *rot, Actor *actor) { if (limbIndex == 5) { rot->x += actor->unk2B0; } return 0; } ``` + Only two things to do here: we need to use `EnRecepgirl` to get to `actor + 0x2B0`, and the return value is used as a boolean, so we replace `0` by `false` (`true` means "don't draw the limb", and is hardly ever used). + ```C -s32 func_80C10558(GlobalContext *globalCtx, s32 limbIndex, Gfx **dList, Vec3f *pos, Vec3s *rot, Actor *thisx) { +s32 func_80C10558(PlayState* play, s32 limbIndex, Gfx **dList, Vec3f *pos, Vec3s *rot, Actor *thisx) { EnRecepgirl* this = THIS; if (limbIndex == 5) { @@ -160,25 +169,29 @@ s32 func_80C10558(GlobalContext *globalCtx, s32 limbIndex, Gfx **dList, Vec3f *p ``` As for the TransformLimbDraw, it has a much simpler prototype. mips2c gives + ```C -void func_80C10590(GlobalContext *globalCtx, s32 limbIndex, Actor *actor) { +void func_80C10590(PlayState* play, 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: + +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) { +void func_80C10590(PlayState* play, 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); } } ``` @@ -186,8 +199,9 @@ void func_80C10590(GlobalContext *globalCtx, s32 limbIndex, Actor *thisx) { ## Some more examples: ObjTree Since EnRecepgirl was a bit light on graphics macros, we will look at an example that has a few more. A nice simple one is `ObjTree_Draw`: the original mips2c output is + ```C -void ObjTree_Draw(Actor *thisx, GlobalContext *globalCtx) { +void ObjTree_Draw(Actor* thisx, PlayState* play) { s16 sp36; s16 sp34; Gfx *sp28; @@ -201,46 +215,52 @@ void ObjTree_Draw(Actor *thisx, GlobalContext *globalCtx) { sp36 = (s16) (s32) (f32) thisx->shape.rot.x; sp34 = (s16) (s32) (f32) thisx->shape.rot.z; - temp_a0 = globalCtx->state.gfxCtx; + temp_a0 = play->state.gfxCtx; temp_s0 = temp_a0; func_8012C28C(temp_a0); temp_v0 = temp_s0->polyOpa.p; temp_s0->polyOpa.p = temp_v0 + 8; temp_v0->words.w0 = 0xDA380003; sp28 = temp_v0; - sp28->words.w1 = Matrix_NewMtx(globalCtx->state.gfxCtx); + sp28->words.w1 = Matrix_NewMtx(play->state.gfxCtx); temp_v0_2 = temp_s0->polyOpa.p; 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; sp20 = temp_v0_3; - sp20->words.w1 = Matrix_NewMtx(globalCtx->state.gfxCtx); + sp20->words.w1 = Matrix_NewMtx(play->state.gfxCtx); temp_v0_4 = temp_s0->polyOpa.p; temp_s0->polyOpa.p = temp_v0_4 + 8; temp_v0_4->words.w1 = (u32) &D_060007C8; temp_v0_4->words.w0 = 0xDE000000; } ``` + We can see there are four blocks here, although only two different macros: + ```C temp_v0 = temp_s0->polyOpa.p; temp_s0->polyOpa.p = temp_v0 + 8; temp_v0->words.w0 = 0xDA380003; sp28 = temp_v0; - sp28->words.w1 = Matrix_NewMtx(globalCtx->state.gfxCtx); + sp28->words.w1 = Matrix_NewMtx(play->state.gfxCtx); ``` + gfxdis gives + ``` $ gfxdis.f3dex2 -x -g POLY_OPA_DISP++ -d DA38000312345678 gSPMatrix(POLY_OPA_DISP++, 0x12345678, G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); ``` + so it becomes + ```C -gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); +gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); ``` ```C @@ -249,11 +269,14 @@ gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH temp_v0_2->words.w1 = (u32) &D_06000680; temp_v0_2->words.w0 = 0xDE000000; ``` + ``` $ gfxdis.f3dex2 -x -g POLY_OPA_DISP++ -d DE00000012345678 gSPDisplayList(POLY_OPA_DISP++, 0x12345678); ``` + so this one is + ```C gSPDisplayList(POLY_OPA_DISP++, D_06000680); ``` @@ -263,34 +286,38 @@ gSPDisplayList(POLY_OPA_DISP++, D_06000680); temp_s0->polyOpa.p = temp_v0_3 + 8; temp_v0_3->words.w0 = 0xDA380003; sp20 = temp_v0_3; - sp20->words.w1 = Matrix_NewMtx(globalCtx->state.gfxCtx); + sp20->words.w1 = Matrix_NewMtx(play->state.gfxCtx); ``` + This is the same as the first one. Indeed, it's identical. + ```C temp_v0_4 = temp_s0->polyOpa.p; temp_s0->polyOpa.p = temp_v0_4 + 8; temp_v0_4->words.w1 = (u32) &D_060007C8; temp_v0_4->words.w0 = 0xDE000000; ``` + This is the same as the second one, but with a different second word. Tidying up and inserting `OPEN_DISPS` and `CLOSE_DISPS`, we end up with + ```C -void ObjTree_Draw(Actor* thisx, GlobalContext* globalCtx) { +void ObjTree_Draw(Actor* thisx, PlayState* play) { s16 sp36 = (f32) thisx->shape.rot.x; s16 sp34 = (f32) thisx->shape.rot.z; - OPEN_DISPS(globalCtx->state.gfxCtx); + OPEN_DISPS(play->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); + func_8012C28C(play->state.gfxCtx); + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_OPA_DISP++, D_06000680); - Matrix_InsertRotation(sp36, 0, sp34, MTXMODE_APPLY); - gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + Matrix_RotateZYX(sp36, 0, sp34, MTXMODE_APPLY); + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_OPA_DISP++, D_060007C8); - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->state.gfxCtx); } ``` diff --git a/docs/tutorial/intro_to_git.md b/docs/tutorial/intro_to_git.md new file mode 100644 index 000000000..59262a2d5 --- /dev/null +++ b/docs/tutorial/intro_to_git.md @@ -0,0 +1,402 @@ +# Introduction to git for decomp + +`git` is a version control system: it allows you to keep different versions of files at the same time. It does this using a tree system: + +- A *repository* is directory containing files managed by git. +- A repository has one or more *branches*. A branch can be thought of as a pointer to a specific commit. +- A *commit* is one set of changes, the most basic "unit" when working with git. The key point about git is that it is possible to have several commits based on the same one +- A *remote* is another copy of the same repository, usually on another computer or the Internet. + +For example, + +```bash +Remote +---o---o---o---o + +Local + master + v +---o---o---o---o + \ + o---o + ^ + A +``` + +Each `o` is a commit. The lines show the commit that each commit was based on: we can see in the local there is one commit with two commits based on it. The local has two branches, `master` and `A`, and they currently both point to the commits furthest along their respective chains. + +Throughout this guide, stuff in `SCREAMING_SNAKE_CASE` represents fields for you to fill in with the appropriate text, e.g. FILE should be replaced with a particular filename. + +## Setting up git + +If you are on an ordinary Linux distribution (i.e. not Arch or similar) or WSL, you probably already have git installed, and if not, can get it by running `sudo apt install git` in a terminal window. + +git commits are signed with the committer's name and email (if you don't want an actual email address attached to it, GitHub will generate a fake one for you). To set these up for any repository you work on, run + +```bash +git config --global user.name "NAME" +git config --global user.email "EMAIL_ADDRESS" +``` + +(omitting `--global` will set these only for the repository in the current folder). + +To make a new repository in a directory: + +```bash +git init +``` + +The repository is considered to have the same name as the directory in which it lives. + +The default branch is set to be called `master`. If you want to call it something else, do + +```bash +git init -b DEFAULT_BRANCH_NAME +``` + +Usually when working on decomp you will instead be cloning a repository from GitHub, though. + +## Cloning a repository from GitHub + +```bash +git clone REMOTE_URL +``` + +This will clone the repository associated with that URL into a subdirectory of the one you are currently in, with a name based on the repository name. For example, + +```bash +git clone git@github.com:zeldaret/mm.git +``` + +will clone the MM repository into the subdirectory `mm`. + +git will automatically name the original remote as `origin`, so for decomp you probably want to use a different name so your own fork on GitHub is `origin`. You can do this: + +```bash +git clone -o REMOTE_NAME REMOTE_URL +``` + +so + +```bash +git clone -o upstream git@github.com:zeldaret/mm.git +``` + +## Configuring remotes + +View all remotes associated to this repository. Each remote has a name and an address. + +```bash +git remote -v +``` + +Rename remote `OLD` to `NEW` + +```bash +git remote rename OLD NEW +``` + +Add a new remote + +```bash +git remote add NAME URL +``` + +For example, a typical workflow to get a repository from GitHub is to fork it, then + +```bash +git clone -o upstream git@github.com:zeldaret/mm.git +cd mm +git add git@github.com:yourgithubaccount/mm.git +``` + +## Managing branches + +You should always work on a branch, to retain a clean copy of the repository that you know works on the master/main branch, and to enable you to switch between unrelated work easily. + +To list the branches you currently have: + +```bash +git branch +``` + +To make a new branch: + +```bash +git branch NEW_BRANCH_NAME +``` + +To change branch: + +```bash +git checkout BRANCH_NAME +``` + +To make a new branch and change to it in one command: + +```bash +git checkout -b NEW_BRANCH_NAME +``` + +To delete a branch (e.g. if definitely no longer needed) + +```bash +git branch -d BRANCH_NAME +``` + +## Committing + +To make git remember your changes, you need to make a commit. Ordinarily a commit applies to only files that are *staged*. + +To add files to staging: + +```bash +git add FILES +``` + +To commit staged files: + +```bash +git commit +``` + +This will open a text editor to write a commit message. It is generally expected that commit messages are informative and short. If you want to write the commit message in the terminal instead, + +```bash +git commit -m "COMMIT_MESSAGE" +``` + +To unstage a file (but keep the changes) + +```bash +git reset FILE +``` + +(To unstage everything, `git reset`) + +To revert a file to its state at the last commit: + +```bash +git reset --hard FILE +``` + +## Merging and Rebasing + +Having worked separately on a branch A, you often want to incorporate changes from branch B into branch A. Considering the tree/commit structure, there are two possible ways to do this: + +- Stick the two branches back together at their current commits. This is called *merging* B into A: diagrammatically, + +```bash +---o---o---o---o A + \ + o---o---o B +``` + +to + +```bash +---o---o---o---o---m A + \ / + o-----o-----o B +``` + +where `m` is a *merge commit*. + +- Go back to the common ancestor of A and B, take all the commits on A since then, and attempt to apply them to the tip of B. This is called *rebasing* A on B. + +```bash +---o---o---o---o A + \ + o---o---o B +``` + +to + +```bash +---o + \ + o---o---o---o---o---o A + ^ + B +``` + +(Notice that in neither case is B itself destroyed.) + +Both have advantages and disadvantages. + +- Merging is conceptually simpler, but generates an additional commit. +- Rebasing results in cleaner history and is usually easier to do because there are fewer changes in each commit, but makes it much harder to follow what has changed between commits before and after: *you should not rebase a branch other people are looking at* (e.g. in GitHub reviews, but also in other collaboration). + +If you realise you have made a mistake while still merging, you can run + +```bash +git merge --abort +``` + +or + +```bash +git rebase --abort +``` + +as appropriate to stop attempting to merge/rebase. + +As such, if you only want to learn one of these, learn merging. + +### Conflict resolution + +If the two branches have both touched the same or nearby lines, git will not know which you want to keep. It will therefore pause the merge/rebase and tell you to decide. You will find a section of the file that looks like this: + +```bash +<<<<<<< A +Some code +======= +Some other code +>>>>>>> B +``` + +from which you should pick one (or combine parts of both as appropriate), then delete the rest. (You definitely do not want the git artefacts left in!) + +Notice also that the changes are applied in opposite ways in each case: merging B into A, the incoming changes are from B, whereas when rebasing, they come from A. *This means the conflict resolution in one is in the opposite order from the other.* + +## Keeping up to date with remotes + +To update git's information about remotes: + +```bash +git fetch REMOTE_NAME +``` + +Not specifying `REMOTE_NAME` will fetch from the remote with the branch that tracks the current one. + +To fetch a remote branch's changes and merge them into the current branch: + +```bash +git pull REMOTE_NAME BRANCH_NAME +``` + +To fetch and rebase the current branch on a remote branch: + +```bash +git pull --rebase REMOTE_NAME BRANCH_NAME +``` + +It's generally better to use fetch and then merge/rebase separately, though, at least until you're more experienced with git. + +To update a remote with changes from the current branch: + +```bash +git push +``` + +To send changes ignoring any changes to the remote branch since local and remote went out of sync, + +```bash +git push --force +``` + +To push a new branch to a remote and set up a branch that *tracks* it on there, you need to specify which remote to push it to: + +```bash +git branch -u REMOTE_NAME +``` + +## Stashing + +You may want to store your current changes without actually committing thhem, for example if you're halfway through something but want new changes from a remote. Running + +```bash +git stash +``` + +will save changes to a "stash" that can be applied later, even to a different branch, with + +```bash +git stash apply +``` + +which keeps the stash, or + +```bash +git stash pop +``` + +which applies, and deletes it if application was successful. + +You can also name and delete stashes and so on. + +## Repository information + +To get general information about what branch you are on, staged and modified files: + +```bash +git status +``` + +This will also indicate any files with merge conflicts. + +To see a line-by-line description of the changes currently made: + +```bash +git diff +``` + +(you can also diff 2 branches or 2 commits) + +git's most general and powerful information command is `log`, which is far too extensive to cover here. + +## GitHub + +Things are a little different on GitHub compared to working locally. + +To make your own copy of a repository, click `Fork`. + +Most repositories do not let people push to them directly. Instead, you make a Pull Request (PR) for merging your branch into one of theirs: this also allows other people to review your work. A Pull Request cannot be merged unless it has no conflicting files. We also use a continuous integration system called Jenkins to ensure that the branch's files are correctly formatted, the it builds the rom correctly, and produces no new warnings; this will usually automatically run whenever you push new changes. + +*A branch used for a PR is a public branch, so do not rebase it.* Apart from the usual problems with other people looking at your changes, it will detach all the GitHub review comments from where they are in the code. + +It is possible to fix merge conflicts on GitHub, but not recommended. GitHub can do a few other git-related things, but most of the time it's just simpler to do it locally. + +### Fetch and Merge + +To fetch and merge on GitHub, navigate to your personal fork of the repository `(e.g. github.com//mm)`. On this page there is a bar that will state whether or not the repository is up to date or not. If it is not up to date it will inform what is different. On the right side of that bar there is a drop down menu labeled "Fetch upstream", you can click this and there will be a button to "Fetch and Merge". Once this is done a `git pull` can be done locally to get all the new changes. + +### Code Reviews + +GitHub has the ability to review changes in a pull request one file at a time. When reviewing, you can review specific changes or comment on the file overall. To start a review: + +- Go to the repository and click "Pull Requests" + +- Click on a pull request to review + +On the conversation tab you can leave general comments and reply to any other comments that have been made. + +On the "Files changed" tab you will see the files changed in the pull request. You can change the format of the diff view in this tab by clicking the gear and choosing the unified or split view. + +To leave a comment, hover over the line of code where you'd like to add a comment, and click the blue "+" icon. To comment on a block of multiple lines, click and drag the range of lines you wish to comment, then click the blue icon. + +Optionally, to suggest a specific change to the line(s) , click the `+/-` icon then edit the text within the suggestion block. + +Once finished, click the "Review changes" and type a comment summarizing proposed changes and comments. + +### Giving credit to others + +If you want to credit other people who have contributed to a PR you have made, you can use the "Co-authored-by" + +```bash +NORMAL_COMMIT_MESSAGE + +Co-authored-by: GITHUB_USERNAME +``` + +Note the blank line and the `<>` around the email. More information on precisely how to do this can be found in GitHub's own docs: + +## More information + +This guide has only covered the basics that are required to work with git on a decomp repository. For more information + +- Run a command with `--help` +- Ask in Discord +- consult a reference such as https://git-scm.com/docs or https://www.atlassian.com/git/tutorials + +*Always ask or research before doing anything drastic, git is sophisticated enough that usually it has a way to resolve problems itself* diff --git a/docs/tutorial/introduction.md b/docs/tutorial/introduction.md index 6178019c8..2115faace 100644 --- a/docs/tutorial/introduction.md +++ b/docs/tutorial/introduction.md @@ -40,13 +40,13 @@ glabel func_809529AC and turn it into compilable C code: ```C -void func_809529AC(EnMs *this, GlobalContext *globalCtx) { - if (Actor_HasParent(&this->actor, globalCtx)) { +void func_809529AC(EnMs* this, PlayState* play) { + if (Actor_HasParent(&this->actor, play)) { this->actor.textId = 0; - func_800B8500(&this->actor, globalCtx, this->actor.xzDistToPlayer, this->actor.playerHeightRel, 0); + func_800B8500(&this->actor, play, this->actor.xzDistToPlayer, this->actor.playerHeightRel, 0); this->actionFunc = func_80952A1C; } else { - Actor_PickUp(&this->actor, globalCtx, 0x35, this->actor.xzDistToPlayer, this->actor.playerHeightRel); + Actor_PickUp(&this->actor, play, 0x35, this->actor.xzDistToPlayer, this->actor.playerHeightRel); } } ``` @@ -73,12 +73,14 @@ A lot of work has already been done on the code to bring it into a format that i An *actor* is any thing in the game that moves or performs actions or interactions: Link is an actor, enemies are actors, NPCs are actors, props like grass are actors. The vast majority of actors are *overlays*, which means they are loaded only when the game needs them. -In the code, each actor is associated to several files: there is +In the code, each actor is associated to several files: there is + - the main .c file, e.g. `src/overlays/actors/ovl_En_Ms/z_en_ms.c` - the actor's Header file, e.g. `src/overlays/actors/ovl_En_Ms/z_en_ms.h` -- various .o files that tell the `make` script how to incorporate it into building the ROM, +- various .o files that tell the `make` script how to incorporate it into building the ROM, + +and then for undecompiled actors, various assembly (.s) files, generally including: -and then for undecompiled actors, various assembly (.s) files, generally including: - one for the actor's *data* (this usually includes things like its collision information about how to draw it, and various other stuff that is used in it), e.g. `data/overlays/actors/ovl_En_Ms.data.s` - one for each function in the actor, e.g. `asm/non_matchings/overlays/actors/ovl_En_Ms/func_809529AC.s` diff --git a/docs/tutorial/merging.md b/docs/tutorial/merging.md index 79e1386cc..b7745b509 100644 --- a/docs/tutorial/merging.md +++ b/docs/tutorial/merging.md @@ -3,7 +3,6 @@ - Up: [Contents](contents.md) - Previous: [Documenting](documenting.md) - ## Preparing to PR ### Change the `spec` @@ -73,7 +72,6 @@ Run the formatting script `format.sh`, to format the C files in the standard way To make sure the PR builds correctly with the current master, you need to merge `upstream/master` before you make the PR. This tends to break things, that you have to fix to get it to compile correctly again. - ## Pull Requests Push commits to your fork of the repository on GitHub, and then open a pull request. Name the PR something sensible, like @@ -87,7 +85,6 @@ and so on, although these four tend to cover most cases. Feel free to add a comm Please also update the status of the file on Trello/the spreadsheet. - ### Reviews Pull requests may be reviewed by anyone (who knows enough about the conventions of the project), and all must be reviewed and approved by two leads and one extra contributor. diff --git a/docs/tutorial/object_decomp.md b/docs/tutorial/object_decomp.md index f210dd446..90ed70405 100644 --- a/docs/tutorial/object_decomp.md +++ b/docs/tutorial/object_decomp.md @@ -74,7 +74,6 @@ The first argument of `gsDPLoadTextureBlock` tells you the offset, the second th The following is a list of the texture formats the Nintendo 64 supports, with their gfxdis names and ZAPD format names. - | Format name | Typing in `gsDPLoadTextureBlock` | "Format" in xml | | ----------------------------------------------- | -------------------------------- | --------------- | | 4-bit intensity (I) | `G_IM_FMT_I, G_IM_SIZ_4b` | i4 | @@ -111,6 +110,7 @@ If in doubt, look at completed objects in the repo, and if still in doubt, ask. ## Tools We are very fortunate that several nice tools have been written recently that are excellent for documenting asset files: + - [Z64Utils](https://github.com/Random06457/Z64Utils/releases), for looking at displaylists, textures they reference, the skeleton, animations, etc. - [Texture64](https://github.com/queueRAM/Texture64/releases), for looking at textures in all the common N64 formats (needed since Z64Utils cannot interpret textures not explicitly referenced in displaylists currently) @@ -149,6 +149,7 @@ For CI4 and CI8 textures, you might see improper-looking textures like so: ![An improper-looking CI8 texture](images/broken_texture.png) The reason this happens is because ZAPD couldn't determine the TLUT for the texture, so it couldn't use the proper palette. To fix this, you can supply a `TlutOffset` to the texture like so: + ```xml ``` @@ -157,4 +158,4 @@ The reason this happens is because ZAPD couldn't determine the TLUT for the text Texture animations are new to Majora's Mask, and they can be pretty tricky to understand. Luckily, there's some extensive documentation on how they're structured [here](https://github.com/zeldaret/mm/blob/master/tools/ZAPD/ZAPD/ZTextureAnimation.cpp). One useful thing to remember is that empty texture animations take the form of `00 00 00 06 00 00 00 00`. The process that automatically generated all the object XMLs sometimes failed to recognize this as an empty texture animation, so it puts it in various blobs or fails to account for it at all. -Next: [The merging process](merging.md) \ No newline at end of file +Next: [The merging process](merging.md) diff --git a/docs/tutorial/object_decomp_example.md b/docs/tutorial/object_decomp_example.md index 798167e68..d1cc4738a 100644 --- a/docs/tutorial/object_decomp_example.md +++ b/docs/tutorial/object_decomp_example.md @@ -15,6 +15,7 @@ In the resulting window, go to "Analysis -> Find Dlists" and press OK (the defau ![Finding object_dns's SkeletonHeader in Z64Utils](images/z64utils_dns_skeletonheader.png) When you open the Skeleton Viewer, you'll see a list of animations off to the side. Selecting one of them will display an error that says something like `RENDER ERROR AT 0x06001A98! (Could not read 0x80 bytes at address 08000000)`. This is because one of the display lists in the skeleton is expecting something to be set at segment 8. From the actor, we know that it's expecting the eye textures to be loaded into segment 8 like so: + ```c static TexturePtr D_8092DE1C[] = { &D_060028E8, &D_06002968, &D_060029E8, &D_06002968 }; [...] @@ -32,6 +33,7 @@ Now that we've gotten around the error, we can see what each limb in the skeleto Note that some limbs don't actually render anything, so sometimes clicking on a limb will not turn anything red; this may indicate a "Root" limb that has no associated display list, or it may indicate something like an eye limb that doesn't have the right textures loaded to display anything in Z64Utils. It may be useful to skip ahead to [Step #5](#step-5-naming-limb-display-lists) to learn how to check if the limb has a display list. If it doesn't have a display list, then it's a "Root" limb that will never be highlighted. We can now start naming the skeleton and individual limbs. Since we know this particular skeleton is the King's Chamber Deku Guard, we can name the skeleton `gKingsChamberDekuGuardSkel`. For the LimbNone name, we can call it something like `KINGS_CHAMBER_DEKU_GUARD_LIMB_NONE`, and we can name the LimbMax similarly. For the EnumName, we can name it `KingsChamberDekuGuardLimbs`. For each individual limb, we can name them based on what we see in Z64Utils; just make sure to update both the Name and the EnumName. After naming everything, we have something that looks like this: + ```xml @@ -49,22 +51,26 @@ We can now start naming the skeleton and individual limbs. Since we know this pa ``` Now we can run `./extract_assets.py -s objects/object_dns` to extract the object again, this time with our new names. What can we do with this? Quite a bit actually. In `z_en_dns.h`, we can add this to the top of the file to start using these new names in our code: + ```c #include "objects/object_dns/object_dns.h" ``` Now, we can redefine the `jointTable` and `morphTable` in terms of the limb enum we defined before, like so: + ```c /* 0x22A */ Vec3s jointTable[KINGS_CHAMBER_DEKU_GUARD_LIMB_MAX]; /* 0x278 */ Vec3s morphTable[KINGS_CHAMBER_DEKU_GUARD_LIMB_MAX]; ``` We can also use our new skeleton name and limb enum when initialization the skeleton like so: + ```c -SkelAnime_Init(globalCtx, &this->skelAnime, &gKingsChamberDekuGuardSkel, NULL, this->jointTable, this->morphTable, KINGS_CHAMBER_DEKU_GUARD_LIMB_MAX); +SkelAnime_Init(play, &this->skelAnime, &gKingsChamberDekuGuardSkel, NULL, this->jointTable, this->morphTable, KINGS_CHAMBER_DEKU_GUARD_LIMB_MAX); ``` Lastly, we can use our limb enum in `EnDns_PostLimbDraw`. Where the code originally had: + ```c if (limbIndex == 2) { [...] @@ -72,6 +78,7 @@ if (limbIndex == 2) { ``` We can instead write: + ```c if (limbIndex == KINGS_CHAMBER_DEKU_GUARD_LIMB_HEAD) { [...] @@ -81,11 +88,13 @@ if (limbIndex == KINGS_CHAMBER_DEKU_GUARD_LIMB_HEAD) { ## Step 2: Naming the animations Now that we have the skeleton figured out, it's time to name all the animations. In the Skeleton Viewer, you can hit the "play" button on any animation to see what it looks like. Note that some objects have multiple skeletons, and selecting an animation that is associated with a different skeleton than the one you're looking at can cause odd behavior. Try to give each animation a descriptive name based on what it looks like. If you're struggling; + - Try viewing the animation in game. In what contexts does this animation play? - Try analyzing the code for the actor to see when the animation is used. Is this animation ever referenced? - If you're still really struggling, Majora's Mask 3D contains the original animation names for the majority of animations in the game. These original names can help you figure out what the developers were originally intending. Explaining how to find these animations in MM3D is outside of the scope of this document, so just ask in Discord if you want to try this. After naming the animations, the end result will look something like this: + ```xml @@ -99,8 +108,9 @@ After naming the animations, the end result will look something like this: ``` Once again, we can run `./extract_assets.py -s objects/object_dns` to extract the object, and we can update the animation names in `z_en_dns.c` to use our new names like so: + ```c -static AnimationInfoS sAnimations[] = { +static AnimationInfoS sAnimationInfo[] = { { &gKingsChamberDekuGuardIdleAnim, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, { &gKingsChamberDekuGuardIdleAnim, 1.0f, 0, -1, ANIMMODE_LOOP, -4 }, { &gKingsChamberDekuGuardWalkAnim, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, @@ -117,16 +127,19 @@ static AnimationInfoS sAnimations[] = { ## Step 3: Identifying the blob In the XML, you may notice undefined blobs like this: + ```xml ``` You might already have an idea as to what this is based on what you've seen before. Recall that the eye textures are referenced in the actor's code like this: + ```c static TexturePtr D_8092DE1C[] = { &D_060028E8, &D_06002968, &D_060029E8, &D_06002968 }; ``` Do you notice how the "28E8" in `D_060028E8` also appears as the Offset in that blob? That's because the blob is just the eye textures; the process for automatically creating the XML wasn't able to figure it out on its own, so we'll need to do it ourselves. But how should we define these textures in the XML? Recall that the eye textures were loaded into segment 8; let's take a look in `object_dns.c` and see if we can find something that uses this segment. This display list has the answer: + ```c Gfx object_dns_DL_001A50[] = { [...] @@ -137,6 +150,7 @@ Gfx object_dns_DL_001A50[] = { ``` Using `0x08000000` with `gsDPLoadTextureBlock` signals that this display list is expecting a texture in segment 8. What kind of texture is it expecting? We can look at the arguments after the `0x08000000`. It's looking for an RBGA16 texture with dimensions of 8x8, so we can define these textures in the XML like so: + ```xml @@ -144,6 +158,7 @@ Using `0x08000000` with `gsDPLoadTextureBlock` signals that this display list is ``` Now, we just have to name them. In [Step #1](#step-1-naming-the-skeleton-and-limbs), we set segment 8 to one of the eye textures; we can use that same technique with the other two eye textures to see what they are. Like most NPCs, these various eye textures are used for handling blinking, so we can name them based on how open the eye is: + ```xml @@ -151,6 +166,7 @@ Now, we just have to name them. In [Step #1](#step-1-naming-the-skeleton-and-lim ``` Like with previous steps, we can run `./extract_assets.py -s objects/object_dns` and then update `z_en_dns.c` with our new names: + ```c static TexturePtr sEyeTextures[] = { gKingsChamberDekuGuardEyeOpenTex, @@ -165,6 +181,7 @@ Note that this step might be tricky to do if multiple things in the actor use th ## Step #4: Naming anything else in the actor For some actors, there may be a few other things left to name that are directly referenced in the actor's code. In our case, there is one display list that we still need to name: + ```c gSPDisplayList(POLY_OPA_DISP++, &D_06002C48); ``` @@ -178,11 +195,13 @@ We can see this is the guard's Deku Flower: ![Showing the guard's Deku Flower in Z64Utils](images/z64utils_dns_deku_flower.png) We can name the display list as such in the XML: + ```xml ``` Then, like all steps before, we can run `./extract_assets.py -s objects/object_dns` and then update `z_en_dns.c` with our new name: + ```c gSPDisplayList(POLY_OPA_DISP++, gKingsChamberDekuGuardDekuFlower); ``` @@ -194,6 +213,7 @@ Now that we've named everything that's used externally by the actor, we just nee ![Showing the head limb's display list in Z64Utils](images/z64utils_dns_limb_dlist.png) Another way is to simply check `object_dns.c`. Each limb lists its own display list like this: + ```c StandardLimb gKingsChamberDekuGuardHeadLimb = { { 0, 1300, 0 }, KINGS_CHAMBER_DEKU_GUARD_LIMB_STALK - 1, KINGS_CHAMBER_DEKU_GUARD_LIMB_LEFT_FOOT - 1, @@ -202,6 +222,7 @@ StandardLimb gKingsChamberDekuGuardHeadLimb = { ``` Either way you go about it, you should be able to name all the limb display lists like so: + ```xml @@ -222,6 +243,7 @@ Run `./extract_assets.py -s objects/object_dns` once again, since it will help i ### Step #6: Naming remaining textures With every display list named, it's now a lot easier to name the remaining textures. In the `assets/objects/object_dns/` folder, you can see all the textures in the object as various PNG files. For some of the textures, just looking at them will give you a good idea as to what they should be named. For other textures, it may help to see how the texture is used in the object's display lists. Let's take a look at `object_dns_Tex_002868`, which is only used in one display list: + ```c Gfx gKingsChamberDekuGuardSnoutDL[] = { [...] @@ -240,6 +262,7 @@ Now, rebuild the game using [the steps described here](object_decomp.md#building ![Our custom mouth texture being shown in-game](images/custom_texture_in_game.png) This confirms our suspicion that this is indeed the mouth texture, so we can name it as such. We can use similar strategies to name all the other textures like so: + ```xml @@ -249,10 +272,11 @@ This confirms our suspicion that this is indeed the mouth texture, so we can nam ### Step #7: Finishing up If you have any other unnamed assets, now's the time to identify them. Otherwise, finish up the file by putting a comment at the top above the `` node: + ```xml ``` -And we're done! Hopefully, you found this example helpful when decompiling your own objects. \ No newline at end of file +And we're done! Hopefully, you found this example helpful when decompiling your own objects. diff --git a/docs/tutorial/other_functions.md b/docs/tutorial/other_functions.md index 796939dd8..255ae9eb4 100644 --- a/docs/tutorial/other_functions.md +++ b/docs/tutorial/other_functions.md @@ -10,6 +10,7 @@ At this point we have a choice to make. Either we could follow the main function ## Destroy Destroy will be a dead end, but we might as well do it now. Usually we would regenerate the context first and apply it to mips2c as with `Init`, but if we look at the assembly... + ```mips glabel EnRecepgirl_Destroy /* 0000FC 80C100CC AFA40000 */ sw $a0, ($sp) @@ -17,24 +18,30 @@ glabel EnRecepgirl_Destroy /* 000104 80C100D4 03E00008 */ jr $ra /* 000108 80C100D8 00000000 */ nop ``` + It doesn't seem to do anything. Indeed, chucking it in mips2c, + ``` $ ../mips_to_c/mips_to_c.py asm/non_matchings/overlays/ovl_En_Recepgirl/EnRecepgirl_Destroy.s void EnRecepgirl_Destroy(s32 arg0, ? arg1) { } ``` + so it really does do nothing. It is worth staying on this briefly to understand what is is doing, though. Even with no context, mips2c knows it takes two arguments because it does two saves onto the stack: the calling convention the N64 uses requires the first four arguments be saved from the registers onto the stack, since the registers are expected to be cleared when a function call happens. It's done a bad job of guessing what they are, but that's to be expected: the assembly only tells us they're words. Thankfully we already know in this case, so we can just replace the `GLOBAL_ASM` by + ```C -void EnRecepgirl_Destroy(Actor* thisx, GlobalContext* globalCtx) { +void EnRecepgirl_Destroy(Actor* thisx, PlayState* play) { } ``` + and cross this function off. ## `func_80C10148` We don't really have a choice now, we have to look at this function. Remake the context (no need to change the function type this time), and run mips2c on the function's assembly file: + ``` $ ../mips_to_c/mips_to_c.py asm/non_matchings/overlays/ovl_En_Recepgirl/func_80C10148.s data/ovl_En_Recepgirl/ovl_En_Recepgirl.data.s --context ctx.c extern AnimationHeader D_0600AD98; @@ -53,16 +60,21 @@ void func_80C10148(EnRecepgirl *this) { ``` This gives us some information immediately: `D_0600AD98` is an `AnimationHeader`, and `func_80C1019C` is set as the action function. This means that we know its type, even though mips2c does not: looking in the header, we see the typedef is + ```C -typedef void (*EnRecepgirlActionFunc)(struct EnRecepgirl*, GlobalContext*); +typedef void (*EnRecepgirlActionFunc)(struct EnRecepgirl*, PlayState*); ``` + and so we prototype `func_80C1019C` as + ```C -void func_80C1019C(EnRecepgirl* this, GlobalContext* globalCtx); +void func_80C1019C(EnRecepgirl* this, PlayState* play); ``` + at the top (were it above the function we're currently working on, the prototype could eventually be replaced by the function definition itself, but since it isn't, it goes at the top with the others). -There are several rather odd things going on here: +There are several rather odd things going on here: + - `temp_a0` is only used once. As such it's probably fake. - There's a weird `this = this` that does nothing - `if (&D_06001384 == this->skelAnime.animation)` is a bit of a funny way to write the condition: it seems more likely it would be the other way round. @@ -70,10 +82,11 @@ There are several rather odd things going on here: - `func_80C1019C` is already a pointer, so the `&` is ineffectual. Our style is to not use `&` on function pointers. If we tackle these, we end up with + ```C void func_80C10148(EnRecepgirl* this); -void func_80C1019C(EnRecepgirl* this, GlobalContext* globalCtx); +void func_80C1019C(EnRecepgirl* this, PlayState* play); [...] @@ -92,18 +105,19 @@ void func_80C10148(EnRecepgirl *this) { this->actionFunc = func_80C1019C; } ``` + This is a common type of function called a setup (action) function. It runs once and prepares the ground for its corresponding actionfunction to run, whereas the actionfunction is usually run every frame by `Update` (but more on that later). Running `make`, we get OK again. Again we have only one way to go - ## `func_80C1019C` Remake the context and run mips2c on this function's assembly file. We get + ```C ? func_80C10290(EnRecepgirl *); // extern -void func_80C1019C(EnRecepgirl *this, GlobalContext *globalCtx) { +void func_80C1019C(EnRecepgirl* this, PlayState* play) { SkelAnime *sp24; SkelAnime *temp_a0; @@ -116,17 +130,17 @@ void func_80C1019C(EnRecepgirl *this, GlobalContext *globalCtx) { Animation_ChangeTransitionRepeat(temp_a0, &D_06009890, -4.0f); } } - if (Actor_ProcessTalkRequest((Actor *) this, globalCtx) != 0) { + if (Actor_ProcessTalkRequest((Actor *) this, play) != 0) { func_80C10290(this); return; } if (Actor_IsFacingPlayer((Actor *) this, 0x2000) != 0) { - func_800B8614((Actor *) this, globalCtx, 60.0f); - if (Player_GetMask(globalCtx) == 2) { + func_800B8614((Actor *) this, play, 60.0f); + if (Player_GetMask(play) == 2) { this->actor.textId = 0x2367; return; } - if (Flags_GetSwitch(globalCtx, (s32) this->actor.params) != 0) { + if (Flags_GetSwitch(play, (s32) this->actor.params) != 0) { this->actor.textId = 0x2ADC; return; } @@ -135,7 +149,9 @@ void func_80C1019C(EnRecepgirl *this, GlobalContext *globalCtx) { } } ``` + This is a bit juicier! We can do some preliminary cleanup, then worry about the control flow. + - `sp24` does nothing, so is almost certainly fake. - `temp_a0` is used in 3 different places, but they're all right next to one another and are unlikely to be required since there's no nontrivial calculation or anything happening. Let's remove it too and see what happens. - We've got another reversed comparison, `&D_0600A280 == this->skelAnime.animation`. @@ -145,9 +161,10 @@ This is a bit juicier! We can do some preliminary cleanup, then worry about the - Prototype `func_80C10290`: it is reasonable to guess it's another setup function, so `void func_80C10290(EnRecepgirl* this);`. Changing all these, we end up with + ```C void func_80C10148(EnRecepgirl* this); -void func_80C1019C(EnRecepgirl* this, GlobalContext* globalCtx); +void func_80C1019C(EnRecepgirl* this, PlayState* play); void func_80C10290(EnRecepgirl* this); [...] @@ -160,7 +177,7 @@ extern FlexSkeletonHeader D_06011B60; [...] -void func_80C1019C(EnRecepgirl *this, GlobalContext *globalCtx) { +void func_80C1019C(EnRecepgirl* this, PlayState* play) { if (SkelAnime_Update(&this->skelAnime) != 0) { if (&D_0600A280 == this->skelAnime.animation) { Animation_MorphToPlayOnce(&this->skelAnime, &D_0600AD98, 5.0f); @@ -168,17 +185,17 @@ void func_80C1019C(EnRecepgirl *this, GlobalContext *globalCtx) { Animation_ChangeTransitionRepeat(&this->skelAnime, &D_06009890, -4.0f); } } - if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state) != 0) { + if (Actor_ProcessTalkRequest(&this->actor, &play->state) != 0) { func_80C10290(this); return; } if (Actor_IsFacingPlayer(&this->actor, 0x2000) != 0) { - func_800B8614(&this->actor, globalCtx, 60.0f); - if (Player_GetMask(globalCtx) == 2) { + func_800B8614(&this->actor, play, 60.0f); + if (Player_GetMask(play) == 2) { this->actor.textId = 0x2367; return; } - if (Flags_GetSwitch(globalCtx, this->actor.params)) { + if (Flags_GetSwitch(play, this->actor.params)) { this->actor.textId = 0x2ADC; return; } @@ -187,14 +204,17 @@ void func_80C1019C(EnRecepgirl *this, GlobalContext *globalCtx) { } } ``` + If we look with diff.py, we find this matches. But we can replace some of the `return`s by `else`s: generally, we use elses unless + - After an `Actor_Kill` - Sometimes after setting an actionfunction - There's no way to avoid an early return Here, it's debatable whether to keep the first, since `func_80C10290` is likely a setup function. The latter two should be changed to elses, though. For now, let's replace all of them. This leaves us with + ```C -void func_80C1019C(EnRecepgirl* this, GlobalContext* globalCtx) { +void func_80C1019C(EnRecepgirl* this, PlayState* play) { if (SkelAnime_Update(&this->skelAnime) != 0) { if (this->skelAnime.animation == &D_0600A280) { Animation_MorphToPlayOnce(&this->skelAnime, &D_0600AD98, 5.0f); @@ -203,13 +223,13 @@ void func_80C1019C(EnRecepgirl* this, GlobalContext* globalCtx) { } } - if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state) != 0) { + if (Actor_ProcessTalkRequest(&this->actor, &play->state) != 0) { func_80C10290(this); } else if (Actor_IsFacingPlayer(&this->actor, 0x2000)) { - func_800B8614(&this->actor, globalCtx, 60.0f); - if (Player_GetMask(globalCtx) == 2) { + func_800B8614(&this->actor, play, 60.0f); + if (Player_GetMask(play) == 2) { this->actor.textId = 0x2367; - } else if (Flags_GetSwitch(globalCtx, this->actor.params)) { + } else if (Flags_GetSwitch(play, this->actor.params)) { this->actor.textId = 0x2ADC; } else { this->actor.textId = 0x2AD9; @@ -217,7 +237,9 @@ void func_80C1019C(EnRecepgirl* this, GlobalContext* globalCtx) { } } ``` + which still matches. Lastly, we have an enum for the output of `Player_GetMask` and other mask-related things: in `z64player.h` we find + ```C typedef enum { /* 0x00 */ PLAYER_MASK_NONE, @@ -227,24 +249,24 @@ typedef enum { /* 0x19 */ PLAYER_MASK_MAX } PlayerMask; ``` -and so we can write the last if as `Player_GetMask(globalCtx) == PLAYER_MASK_KAFEIS_MASK`. +and so we can write the last if as `Player_GetMask(play) == PLAYER_MASK_KAFEIS_MASK`. Again, we have no choice in what to do next. - ## `func_80C10290` Remaking the context and running mips2c gives + ```C -void func_80C102D4(EnRecepgirl *, GlobalContext *); // extern +void func_80C102D4(EnRecepgirl*, PlayState*); // extern void func_80C10290(EnRecepgirl *this) { Animation_MorphToPlayOnce(&this->skelAnime, &D_0600A280, -4.0f); this->actionFunc = func_80C102D4; } ``` -so all we have to do is add the function prototype for the newest action function. Not surprisingly, this matches without changing anything. +so all we have to do is add the function prototype for the newest action function. Not surprisingly, this matches without changing anything. ## `func_80C102D4` @@ -256,7 +278,7 @@ Large code block, click to show ```C extern AnimationHeader D_06000968; -void func_80C102D4(EnRecepgirl *this, GlobalContext *globalCtx) { +void func_80C102D4(EnRecepgirl* this, PlayState* play) { SkelAnime *sp20; AnimationHeader *temp_v0; SkelAnime *temp_a0; @@ -282,16 +304,16 @@ void func_80C102D4(EnRecepgirl *this, GlobalContext *globalCtx) { Animation_MorphToPlayOnce(sp20, &D_0600A280, -4.0f); } } - temp_v0_2 = Message_GetState(&globalCtx->msgCtx); + temp_v0_2 = Message_GetState(&play->msgCtx); if (temp_v0_2 == 2) { this->actor.textId = 0x2ADC; func_80C10148(this); return; } - if (((temp_v0_2 & 0xFF) == 5) && (Message_ShouldAdvance(globalCtx) != 0)) { + if (((temp_v0_2 & 0xFF) == 5) && (Message_ShouldAdvance(play) != 0)) { temp_v0_3 = this->actor.textId; if (temp_v0_3 == 0x2AD9) { - Flags_SetSwitch(globalCtx, (s32) this->actor.params); + Flags_SetSwitch(play, (s32) this->actor.params); Animation_MorphToPlayOnce(sp20, &D_0600AD98, 10.0f); if ((*(&gSaveContext + 0xF37) & 0x80) != 0) { this->actor.textId = 0x2ADF; @@ -312,7 +334,7 @@ void func_80C102D4(EnRecepgirl *this, GlobalContext *globalCtx) { this->actor.textId = 0x2AE0; } } - func_80151938(globalCtx, this->actor.textId); + func_80151938(play, this->actor.textId); } } ``` @@ -320,8 +342,9 @@ void func_80C102D4(EnRecepgirl *this, GlobalContext *globalCtx) { Well, this is a big one! We get one more extern, for `D_06000968`. A lot of the temps used in the conditionals look fake, with the exception of `temp_v0_2`: because the function is only called once but the temp is used twice, the temp must be real. Removing the others and switching the `animation` conditionals, + ```C -void func_80C102D4(EnRecepgirl *this, GlobalContext *globalCtx) { +void func_80C102D4(EnRecepgirl* this, PlayState* play) { u8 temp_v0_2; if (SkelAnime_Update(&this->skelAnime) != 0) { @@ -340,16 +363,16 @@ void func_80C102D4(EnRecepgirl *this, GlobalContext *globalCtx) { } } - temp_v0_2 = Message_GetState(&globalCtx->msgCtx); + temp_v0_2 = Message_GetState(&play->msgCtx); if (temp_v0_2 == 2) { this->actor.textId = 0x2ADC; func_80C10148(this); return; } - if (((temp_v0_2 & 0xFF) == 5) && (Message_ShouldAdvance(globalCtx) != 0)) { + if (((temp_v0_2 & 0xFF) == 5) && (Message_ShouldAdvance(play) != 0)) { if (this->actor.textId == 0x2AD9) { - Flags_SetSwitch(globalCtx, this->actor.params); + Flags_SetSwitch(play, this->actor.params); Animation_MorphToPlayOnce(&this->skelAnime, &D_0600AD98, 10.0f); if ((*(&gSaveContext + 0xF37) & 0x80) != 0) { this->actor.textId = 0x2ADF; @@ -369,15 +392,18 @@ void func_80C102D4(EnRecepgirl *this, GlobalContext *globalCtx) { this->actor.textId = 0x2AE0; } } - func_80151938(globalCtx, this->actor.textId); + func_80151938(play, this->actor.textId); } } ``` + There remains one thing we need to fix before trying to compile it, namely `*(&gSaveContext + 0xF37) & 0x80`. This is really a funny way of writing an array access, because mips2c will get confused about arrays in structs. Opening up `z64save.h`, we find in the `SaveContext` struct that + ```C /* 0x0EF8 */ u8 weekEventReg[100]; // "week_event_reg" /* 0x0F5C */ u32 mapsVisited; // "area_arrival" ``` + so it's somewhere in `weekEventReg`. `0xF37 - 0xEF8 = 0x3F = 63`, and it's a byte array, so the access is actually `gSaveContext.save.weekEventReg[63] & 0x80`. Now it will compile. We also don't use `!= 0` for flag comparisons: just `if (gSaveContext.save.weekEventReg[63] & 0x80)` will do. Running `./diff.py -mwo3 func_80C102D4` and scrolling down, we discover that this doesn't match! @@ -385,19 +411,22 @@ Running `./diff.py -mwo3 func_80C102D4` and scrolling down, we discover that thi ![First run of diff.py on func_80C102D4](images/func_80C102D4_diff1.png) The yellow shows registers that don't match, the different colours on the registers help you to estimate where the problems are. Usually it's best to start at the top and work down if possible: any regalloc problems at the top tend to propagate most of the way down. In our case, the first problem is + ``` 3f0: andi t0,v0,0xff r 153 3f0: andi t1,v0,0xff ``` + somehow we skipped over `t0`. Where is this in the code? The `153` in the middle is the line number in the C file (the `3f0`s are the offsets into the assembly file), we have `--source` if you want to see the code explicitly, or you can do it the old-fashioned way, and work it out from nearby function calls. In this case, `func_80C10148` is run straight after, and the only place that is called is + ```C - temp_v0_2 = Message_GetState(&globalCtx->msgCtx); + temp_v0_2 = Message_GetState(&play->msgCtx); if (temp_v0_2 == 2) { this->actor.textId = 0x2ADC; func_80C10148(this); return; } - if (((temp_v0_2 & 0xFF) == 5) && (Message_ShouldAdvance(globalCtx) != 0)) { + if (((temp_v0_2 & 0xFF) == 5) && (Message_ShouldAdvance(play) != 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: @@ -408,63 +437,72 @@ Notice that indeed the subsequent regalloc, which might have looked like a bigge And now we've run out of functions. Time for `Update`. - ## Update Update runs every frame and usually is responsible for the actor's common logic updates: for example, updating timers, blinking, updating collision, running the `actionFunc`, and so on, either directly or through other functions it calls. A lot of subsidiary functions that are not common to every state (e.g. updating position, or the text when talking, etc.) are carried out by one of the action functions we have already decomped. Remake the context and run mips2c: + ```C ? func_80C100DC(EnRecepgirl *); // extern -void EnRecepgirl_Update(Actor *thisx, GlobalContext *globalCtx) { +void EnRecepgirl_Update(Actor* thisx, PlayState* play) { EnRecepgirl* this = (EnRecepgirl *) thisx; ? 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); + this->actionFunc(this, play); + Actor_TrackPlayer(play, (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); } ``` + If we search for `func_80C100DC`, we find that this is the only time it is used. Hence we can be almost certain that its prototype is `void func_80C100DC(EnRecepgirl* this);`. This function occurs above `Update`, so you can put the prototype next to the `GLOBAL_ASM` and remove it when we decompile that function. Change the function and the prototype back to `Actor* thisx`, and add the casting temp: + ```C void func_80C100DC(EnRecepgirl *); #pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Recepgirl/func_80C100DC.s") [...] -void EnRecepgirl_Update(Actor *thisx, GlobalContext *globalCtx) { +void EnRecepgirl_Update(Actor* thisx, PlayState* play) { EnRecepgirl* this = THIS; ? 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); + this->actionFunc(this, play); + Actor_TrackPlayer(play, &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(PlayState* play, Actor* actor, Vec3s* headRot, Vec3s* torsoRot, Vec3f focusPos) ``` + So mips2c has made a bit of a mess here: + - the third argument should be a `Vec3s`. Hence `this + 0x2AE` is a `Vec3s*`, and so `this->unk_2AE` is a `Vec3s` - `&sp30` is a `Vec3s*`, so `sp30` is a `Vec3s` (it's clearly not used for anything, just used to "dump" a side-effect of the function) - The last argument is supposed to be an actual `Vec3f` Fixing all of this, we end up with + ```C -void EnRecepgirl_Update(EnRecepgirl *this, GlobalContext *globalCtx) { +void EnRecepgirl_Update(EnRecepgirl* this, PlayState* play) { EnRecepgirl* this = THIS; Vec3s sp30; - this->actionFunc(this, globalCtx); - func_800E9250(globalCtx, &this->actor, &this->unk_2AE, &sp30, this->actor.focus.pos); + this->actionFunc(this, play); + Actor_TrackPlayer(play, &this->actor, &this->unk_2AE, &sp30, this->actor.focus.pos); func_80C100DC(this); } ``` + and can fill in the top end of the struct: + ```C typedef struct EnRecepgirl { /* 0x0000 */ Actor actor; @@ -482,21 +520,22 @@ It's entirely possible that `unk_2AD` is not real, and is just padding: see [Typ ![EnRecepgirl_Update's stack difference](images/EnRecepgirl_stack_diff.png) -So `sp30` is in the wrong place: it's `4` too high on the stack in ours. This is because the main four functions do not actually take `GlobalContext`: they really take `Gamestate` and recast it with a temp, just like `EnRecepgirl* this = THIS;`. We haven't implemented this in the repo yet, though, so for now, it suffices to put a pad on the stack where it would go instead: experience has shown when it matters, it goes above the actor recast, so we end up with +So `sp30` is in the wrong place: it's `4` too high on the stack in ours. This is because the main four functions do not actually take `PlayState`: they really take `Gamestate` and recast it with a temp, just like `EnRecepgirl* this = THIS;`. We haven't implemented this in the repo yet, though, so for now, it suffices to put a pad on the stack where it would go instead: experience has shown when it matters, it goes above the actor recast, so we end up with ```C -void EnRecepgirl_Update(Actor *thisx, GlobalContext *globalCtx) { +void EnRecepgirl_Update(Actor* thisx, PlayState* play) { s32 pad; EnRecepgirl* this = THIS; Vec3s sp30; - this->actionFunc(this, globalCtx); - func_800E9250(globalCtx, &this->actor, &this->unk_2AE, &sp30, this->actor.focus.pos); + this->actionFunc(this, play); + Actor_TrackPlayer(play, &this->actor, &this->unk_2AE, &sp30, this->actor.focus.pos); func_80C100DC(this); } ``` + and this now matches. -**N.B.** sometimes using an actual `GlobalContext* globalCtx` temp is required for matching: add it to your bag o' matching memes. +**N.B.** sometimes using an actual `PlayState* play` temp is required for matching: add it to your bag o' matching memes. ### *Some remarks about the function stack @@ -516,6 +555,7 @@ Anyway, back to EnRecepgirl. 4 functions to go... ## `func_80C100DC` This is the final non-draw function. You know what to do now: remake the context and run mips2c: + ```C void func_80C100DC(EnRecepgirl *this) { u8 temp_t6; @@ -547,24 +587,30 @@ Well, it's still *pretty* close. But the registers are all wrong. Firstly, `temp ![func_80C100DC, second diff](images/func_80C100DC_diff2.png) It's not obvious that did much: it even looks a bit worse. + ```C temp_v0 = this->unk_2AC; temp_t6 = temp_v0 + 1; if (temp_v0 != 0) { this->unk_2AC = temp_t6; ``` + may remind you of that loop we decompiled, where mips2c unnecessarily made two temps. Let's walk through what this does. + - First, it saves the value of `this->unk_2AC` into `v0` - Then, it adds one to it and stores it in `t6`. - It checks if the first saved value is zero - If it is, it sets `this->unk_2AC` to the incremented value and carries on. Well, if we allow ourselves to bend the order of operations a little, there's a much simpler way to write this with no temps, namely + ```C if (this->unk_2AC != 0) { this->unk_2AC++; ``` + So let's try removing both temps: + ```C void func_80C100DC(EnRecepgirl *this) { if (this->unk_2AC != 0) { @@ -586,6 +632,7 @@ void func_80C100DC(EnRecepgirl *this) { There we go. Even though this matches, it is not quite according to our style: remember what was said earlier about early returns. Here, both of them can be removed and replaced by a single else without affecting matching: + ```C void func_80C100DC(EnRecepgirl *this) { if (this->unk_2AC != 0) { @@ -598,6 +645,7 @@ void func_80C100DC(EnRecepgirl *this) { } } ``` + and this is how we prefer it to be written. With that, the last remaining function is `EnJj_Draw`. Draw functions have an extra layer of macroing that is required, so we shall cover them separately. diff --git a/docs/tutorial/types_structs_padding.md b/docs/tutorial/types_structs_padding.md index dc72e0100..93492d3e1 100644 --- a/docs/tutorial/types_structs_padding.md +++ b/docs/tutorial/types_structs_padding.md @@ -1,10 +1,10 @@ # Types, structs, and padding Reminders: + - In N64 MIPS, 1 word is 4 bytes (yes, the N64 is meant to be 64-bit, but it mostly isn't used like it in MM or OoT) - A byte is 8 bits, or 2 hex digits - ## Types The following are the common data types used everywhere: @@ -14,7 +14,7 @@ The following are the common data types used everywhere: | char | 1 byte | character | | u8 | 1 byte | unsigned byte | | s8 | 1 byte | signed byte | -| u16 | 2 bytes | unsigned short | +| u16 | 2 bytes | unsigned short | | s16 | 2 bytes | signed short | | u32 | 4 bytes/1 word | unsigned int | | s32 | 4 bytes/1 word | signed int | @@ -27,16 +27,18 @@ A pointer is sometimes mistaken for an `s32`. The last two, marked with `^`, are `s32` is the default thing to use in the absence of any other information about the data. Useful data for guessing types: + - `u8` is about 7 times more common than `s8` - `s16` is about 16 times more common than `u16` - `s32` is about 8 times more common than `u32` Another useful thing to put here: the typedef for an action function is -```C -typedef void (*ActorNameActionFunc)(struct ActorName*, GlobalContext*); -``` -where you replace `ActorName` by the actual actor name as used elsewhere in the actor, e.g. `EnRecepgirl`. In MM these typedefs have been automatically generated, so you don't need to constantly copy from here or another actor any more. +```C +typedef void (*ActorNameActionFunc)(struct ActorName*, PlayState*); +``` + +where you replace `ActorName` by the actual actor name as used elsewhere in the actor, e.g. `EnRecepgirl`. In MM these typedefs have been automatically generated, so you don't need to constantly copy from here or another actor any more. ## Some Common Structs @@ -45,8 +47,8 @@ Here are the usual names and the sizes of some of the most common structs used i | ----------------------- | --------------------- | --------------- | | `Actor` | `actor` | 0x144 | | `DynaPolyActor` | `dyna` | 0x15C | -| `Vec3f` | | 0xC | -| `Vec3s` | | 0x6 | +| `Vec3f` | | 0xC | +| `Vec3s` | | 0x6 | | `SkelAnime` | `skelAnime` | 0x44 | | `Vec3s[limbCount]` | `jointTable` | 0x6 * limbCount | | `Vec3s[limbCount]` | `morphTable` | 0x6 * limbCount | @@ -59,7 +61,6 @@ Here are the usual names and the sizes of some of the most common structs used i Note that `Actor` and `DynaPolyActor` have changed size from OoT. - ## Padding ### Alignment @@ -70,7 +71,7 @@ The clearest example of this is that variables with types that are 1 word in siz ### Struct padding -In actor structs, this manifests as some of the char arrays not being completely replaced by actual variables. +In actor structs, this manifests as some of the char arrays not being completely replaced by actual variables. ```C typedef struct EnRecepgirl { @@ -123,7 +124,8 @@ Each section is 0x10/16-aligned (qword aligned), i.e. each new section begins at #### Padding at the end of .text (function instructions) In function instructions, this manifests as a set of `nop`s at the end of the last function: for example, in EnRecepGirl, -``` + +```mips /* 0006B0 80C10680 27BD0038 */ addiu $sp, $sp, 0x38 /* 0006B4 80C10684 03E00008 */ jr $ra /* 0006B8 80C10688 00000000 */ nop @@ -139,7 +141,8 @@ Once the rest of the functions match, this is automatic. So you never need to wo In data, the last entry may contain up to 3 words of 0s as padding. These can safely be removed when migrating data, but make sure that you don't remove something that actually is accessed by the function and happens to be 0! For example, in `ObjTree` we found that the last symbol in the data, -``` + +```mips glabel D_80B9A5BC /* 00006C 80B9A5BC */ .word 0x08000000 /* 000070 80B9A5C0 */ .word 0x00000000 @@ -147,6 +150,7 @@ glabel D_80B9A5BC /* 000078 80B9A5C8 */ .word 0x00000000 /* 00007C 80B9A5CC */ .word 0x00000000 ``` + had 2 words of padding: only the first 3 words are actually used in the `CollisionCheckInfoInit2`. ### Padding within the .data section diff --git a/docs/tutorial/vscode.md b/docs/tutorial/vscode.md index 91f2f659c..288bf0e48 100644 --- a/docs/tutorial/vscode.md +++ b/docs/tutorial/vscode.md @@ -1,6 +1,6 @@ # VSCode -A lot of people on this project use VSCode as their coding environment. +A lot of people on this project use VSCode as their coding environment. ## Extensions @@ -13,10 +13,7 @@ There are a number of useful extensions available to make work more efficient: - ~~bracket pair colorizer 2~~ (now obsolete due to VSCode's built-in bracket colouring) - Better MIPS Support - - - -## Useful stuff to know: +## Useful stuff to know - Ctrl + Alt + Up/Down (on Windows, on Linux it's Ctrl + Shift + Up/Down or Shift + Alt + Up/Down) gives multicursors across consecutive lines. If you want several cursors in a more diverse arrangement, middle clicking works, at least on Windows. - Alt + Up/Down moves lines up/down. diff --git a/include/PR/gbi.h b/include/PR/gbi.h index ace2cd2e8..2c29420ea 100644 --- a/include/PR/gbi.h +++ b/include/PR/gbi.h @@ -17,24 +17,24 @@ # define F3DEX_GBI # endif #define G_NOOP 0x00 -#define G_RDPHALF_2 0xf1 -#define G_SETOTHERMODE_H 0xe3 -#define G_SETOTHERMODE_L 0xe2 -#define G_RDPHALF_1 0xe1 -#define G_SPNOOP 0xe0 -#define G_ENDDL 0xdf -#define G_DL 0xde -#define G_LOAD_UCODE 0xdd -#define G_MOVEMEM 0xdc -#define G_MOVEWORD 0xdb -#define G_MTX 0xda -#define G_GEOMETRYMODE 0xd9 -#define G_POPMTX 0xd8 -#define G_TEXTURE 0xd7 -#define G_DMA_IO 0xd6 -#define G_SPECIAL_1 0xd5 -#define G_SPECIAL_2 0xd4 -#define G_SPECIAL_3 0xd3 +#define G_RDPHALF_2 0xF1 +#define G_SETOTHERMODE_H 0xE3 +#define G_SETOTHERMODE_L 0xE2 +#define G_RDPHALF_1 0xE1 +#define G_SPNOOP 0xE0 +#define G_ENDDL 0xDF +#define G_DL 0xDE +#define G_LOAD_UCODE 0xDD +#define G_MOVEMEM 0xDC +#define G_MOVEWORD 0xDB +#define G_MTX 0xDA +#define G_GEOMETRYMODE 0xD9 +#define G_POPMTX 0xD8 +#define G_TEXTURE 0xD7 +#define G_DMA_IO 0xD6 +#define G_SPECIAL_1 0xD5 +#define G_SPECIAL_2 0xD4 +#define G_SPECIAL_3 0xD3 #define G_VTX 0x01 #define G_MODIFYVTX 0x02 @@ -89,38 +89,38 @@ #define G_SPRITE2D_DRAW (G_IMMFIRST-2) /* RDP commands: */ -#define G_NOOP 0xc0 /* 0 */ +#define G_NOOP 0xC0 /* 0 */ #endif /* F3DEX_GBI_2 */ /* RDP commands: */ -#define G_SETCIMG 0xff /* -1 */ -#define G_SETZIMG 0xfe /* -2 */ -#define G_SETTIMG 0xfd /* -3 */ -#define G_SETCOMBINE 0xfc /* -4 */ -#define G_SETENVCOLOR 0xfb /* -5 */ -#define G_SETPRIMCOLOR 0xfa /* -6 */ -#define G_SETBLENDCOLOR 0xf9 /* -7 */ -#define G_SETFOGCOLOR 0xf8 /* -8 */ -#define G_SETFILLCOLOR 0xf7 /* -9 */ -#define G_FILLRECT 0xf6 /* -10 */ -#define G_SETTILE 0xf5 /* -11 */ -#define G_LOADTILE 0xf4 /* -12 */ -#define G_LOADBLOCK 0xf3 /* -13 */ -#define G_SETTILESIZE 0xf2 /* -14 */ -#define G_LOADTLUT 0xf0 /* -16 */ -#define G_RDPSETOTHERMODE 0xef /* -17 */ -#define G_SETPRIMDEPTH 0xee /* -18 */ -#define G_SETSCISSOR 0xed /* -19 */ -#define G_SETCONVERT 0xec /* -20 */ -#define G_SETKEYR 0xeb /* -21 */ -#define G_SETKEYGB 0xea /* -22 */ -#define G_RDPFULLSYNC 0xe9 /* -23 */ -#define G_RDPTILESYNC 0xe8 /* -24 */ -#define G_RDPPIPESYNC 0xe7 /* -25 */ -#define G_RDPLOADSYNC 0xe6 /* -26 */ -#define G_TEXRECTFLIP 0xe5 /* -27 */ -#define G_TEXRECT 0xe4 /* -28 */ +#define G_SETCIMG 0xFF /* -1 */ +#define G_SETZIMG 0xFE /* -2 */ +#define G_SETTIMG 0xFD /* -3 */ +#define G_SETCOMBINE 0xFC /* -4 */ +#define G_SETENVCOLOR 0xFB /* -5 */ +#define G_SETPRIMCOLOR 0xFA /* -6 */ +#define G_SETBLENDCOLOR 0xF9 /* -7 */ +#define G_SETFOGCOLOR 0xF8 /* -8 */ +#define G_SETFILLCOLOR 0xF7 /* -9 */ +#define G_FILLRECT 0xF6 /* -10 */ +#define G_SETTILE 0xF5 /* -11 */ +#define G_LOADTILE 0xF4 /* -12 */ +#define G_LOADBLOCK 0xF3 /* -13 */ +#define G_SETTILESIZE 0xF2 /* -14 */ +#define G_LOADTLUT 0xF0 /* -16 */ +#define G_RDPSETOTHERMODE 0xEF /* -17 */ +#define G_SETPRIMDEPTH 0xEE /* -18 */ +#define G_SETSCISSOR 0xED /* -19 */ +#define G_SETCONVERT 0xEC /* -20 */ +#define G_SETKEYR 0xEB /* -21 */ +#define G_SETKEYGB 0xEA /* -22 */ +#define G_RDPFULLSYNC 0xE9 /* -23 */ +#define G_RDPTILESYNC 0xE8 /* -24 */ +#define G_RDPPIPESYNC 0xE7 /* -25 */ +#define G_RDPLOADSYNC 0xE6 /* -26 */ +#define G_TEXRECTFLIP 0xE5 /* -27 */ +#define G_TEXRECT 0xE4 /* -28 */ /* @@ -131,14 +131,14 @@ * These id's are -56, -52, -54, -50, -55, -51, -53, -49, ... * edge, shade, texture, zbuff bits: estz */ -#define G_TRI_FILL 0xc8 /* fill triangle: 11001000 */ -#define G_TRI_SHADE 0xcc /* shade triangle: 11001100 */ -#define G_TRI_TXTR 0xca /* texture triangle: 11001010 */ -#define G_TRI_SHADE_TXTR 0xce /* shade, texture triangle: 11001110 */ -#define G_TRI_FILL_ZBUFF 0xc9 /* fill, zbuff triangle: 11001001 */ -#define G_TRI_SHADE_ZBUFF 0xcd /* shade, zbuff triangle: 11001101 */ -#define G_TRI_TXTR_ZBUFF 0xcb /* texture, zbuff triangle: 11001011 */ -#define G_TRI_SHADE_TXTR_ZBUFF 0xcf /* shade, txtr, zbuff trngl: 11001111 */ +#define G_TRI_FILL 0xC8 /* fill triangle: 11001000 */ +#define G_TRI_SHADE 0xCC /* shade triangle: 11001100 */ +#define G_TRI_TXTR 0xCA /* texture triangle: 11001010 */ +#define G_TRI_SHADE_TXTR 0xCE /* shade, texture triangle: 11001110 */ +#define G_TRI_FILL_ZBUFF 0xC9 /* fill, zbuff triangle: 11001001 */ +#define G_TRI_SHADE_ZBUFF 0xCD /* shade, zbuff triangle: 11001101 */ +#define G_TRI_TXTR_ZBUFF 0xCB /* texture, zbuff triangle: 11001011 */ +#define G_TRI_SHADE_TXTR_ZBUFF 0xCF /* shade, txtr, zbuff trngl: 11001111 */ /* * A TRI_FILL triangle is just the edges. You need to set the DP @@ -178,13 +178,13 @@ /* gets added to RDP command, in order to test for addres fixup: */ #define G_RDP_ADDR_FIXUP 3 /* |RDP cmds| <= this, do addr fixup */ #ifdef _LANGUAGE_ASSEMBLY -#define G_RDP_TEXRECT_CHECK ((-1*G_TEXRECTFLIP)& 0xff) +#define G_RDP_TEXRECT_CHECK ((-1*G_TEXRECTFLIP)& 0xFF) #endif /* macros for command parsing: */ #define GDMACMD(x) (x) #define GIMMCMD(x) (G_IMMFIRST-(x)) -#define GRDPCMD(x) (0xff-(x)) +#define GRDPCMD(x) (0xFF-(x)) #define G_DMACMDSIZ 128 #define G_IMMCMDSIZ 64 @@ -211,11 +211,12 @@ * Note : this number is NOT the viewport z-scale constant. * See the comment next to G_MAXZ for more info. */ -#define G_MAXFBZ 0x3fff /* 3b exp, 11b mantissa */ +#define G_MAXFBZ 0x3FFF /* 3b exp, 11b mantissa */ -#define GPACK_RGBA5551(r, g, b, a) ((((r)<<8) & 0xf800) | \ - (((g)<<3) & 0x7c0) | \ - (((b)>>2) & 0x3e) | ((a) & 0x1)) +#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 @@ -588,7 +590,7 @@ #define ZMODE_OPA 0 #define ZMODE_INTER 0x400 #define ZMODE_XLU 0x800 -#define ZMODE_DEC 0xc00 +#define ZMODE_DEC 0xC00 #define CVG_X_ALPHA 0x1000 #define ALPHA_CVG_SEL 0x2000 #define FORCE_BL 0x4000 @@ -1073,7 +1075,7 @@ typedef struct { * but we don't have the ucode to do that... * */ -#define G_MAXZ 0x03ff /* 10 bits of integer screen-Z precision */ +#define G_MAXZ 0x03FF /* 10 bits of integer screen-Z precision */ /* * The viewport structure elements have 2 bits of fraction, necessary @@ -1129,17 +1131,17 @@ typedef union { # define G_MV_LOOKATX 0x84 # define G_MV_L0 0x86 # define G_MV_L1 0x88 -# define G_MV_L2 0x8a -# define G_MV_L3 0x8c -# define G_MV_L4 0x8e +# define G_MV_L2 0x8A +# define G_MV_L3 0x8C +# define G_MV_L4 0x8E # define G_MV_L5 0x90 # define G_MV_L6 0x92 # define G_MV_L7 0x94 # define G_MV_TXTATT 0x96 -# define G_MV_MATRIX_1 0x9e /* NOTE: this is in moveword table */ +# define G_MV_MATRIX_1 0x9E /* NOTE: this is in moveword table */ # define G_MV_MATRIX_2 0x98 -# define G_MV_MATRIX_3 0x9a -# define G_MV_MATRIX_4 0x9c +# define G_MV_MATRIX_3 0x9A +# define G_MV_MATRIX_4 0x9C #endif /* F3DEX_GBI_2 */ /* @@ -1155,22 +1157,22 @@ typedef union { #define G_MW_CLIP 0x04 #define G_MW_SEGMENT 0x06 #define G_MW_FOG 0x08 -#define G_MW_LIGHTCOL 0x0a +#define G_MW_LIGHTCOL 0x0A #ifdef F3DEX_GBI_2 -# define G_MW_FORCEMTX 0x0c +# define G_MW_FORCEMTX 0x0C #else /* F3DEX_GBI_2 */ -# define G_MW_POINTS 0x0c +# define G_MW_POINTS 0x0C #endif /* F3DEX_GBI_2 */ -#define G_MW_PERSPNORM 0x0e +#define G_MW_PERSPNORM 0x0E /* * These are offsets from the address in the dmem table */ #define G_MWO_NUMLIGHT 0x00 #define G_MWO_CLIP_RNX 0x04 -#define G_MWO_CLIP_RNY 0x0c +#define G_MWO_CLIP_RNY 0x0C #define G_MWO_CLIP_RPX 0x14 -#define G_MWO_CLIP_RPY 0x1c +#define G_MWO_CLIP_RPY 0x1C #define G_MWO_SEGMENT_0 0x00 #define G_MWO_SEGMENT_1 0x01 #define G_MWO_SEGMENT_2 0x02 @@ -1181,30 +1183,30 @@ typedef union { #define G_MWO_SEGMENT_7 0x07 #define G_MWO_SEGMENT_8 0x08 #define G_MWO_SEGMENT_9 0x09 -#define G_MWO_SEGMENT_A 0x0a -#define G_MWO_SEGMENT_B 0x0b -#define G_MWO_SEGMENT_C 0x0c -#define G_MWO_SEGMENT_D 0x0d -#define G_MWO_SEGMENT_E 0x0e -#define G_MWO_SEGMENT_F 0x0f +#define G_MWO_SEGMENT_A 0x0A +#define G_MWO_SEGMENT_B 0x0B +#define G_MWO_SEGMENT_C 0x0C +#define G_MWO_SEGMENT_D 0x0D +#define G_MWO_SEGMENT_E 0x0E +#define G_MWO_SEGMENT_F 0x0F #define G_MWO_FOG 0x00 #define G_MWO_aLIGHT_1 0x00 #define G_MWO_bLIGHT_1 0x04 #ifdef F3DEX_GBI_2 #define G_MWO_aLIGHT_2 0x18 -#define G_MWO_bLIGHT_2 0x1c +#define G_MWO_bLIGHT_2 0x1C #define G_MWO_aLIGHT_3 0x30 #define G_MWO_bLIGHT_3 0x34 #define G_MWO_aLIGHT_4 0x48 -#define G_MWO_bLIGHT_4 0x4c +#define G_MWO_bLIGHT_4 0x4C #define G_MWO_aLIGHT_5 0x60 #define G_MWO_bLIGHT_5 0x64 #define G_MWO_aLIGHT_6 0x78 -#define G_MWO_bLIGHT_6 0x7c +#define G_MWO_bLIGHT_6 0x7C #define G_MWO_aLIGHT_7 0x90 #define G_MWO_bLIGHT_7 0x94 -#define G_MWO_aLIGHT_8 0xa8 -#define G_MWO_bLIGHT_8 0xac +#define G_MWO_aLIGHT_8 0xA8 +#define G_MWO_bLIGHT_8 0xAC #else #define G_MWO_aLIGHT_2 0x20 #define G_MWO_bLIGHT_2 0x24 @@ -1214,33 +1216,33 @@ typedef union { #define G_MWO_bLIGHT_4 0x64 #define G_MWO_aLIGHT_5 0x80 #define G_MWO_bLIGHT_5 0x84 -#define G_MWO_aLIGHT_6 0xa0 -#define G_MWO_bLIGHT_6 0xa4 -#define G_MWO_aLIGHT_7 0xc0 -#define G_MWO_bLIGHT_7 0xc4 -#define G_MWO_aLIGHT_8 0xe0 -#define G_MWO_bLIGHT_8 0xe4 +#define G_MWO_aLIGHT_6 0xA0 +#define G_MWO_bLIGHT_6 0xA4 +#define G_MWO_aLIGHT_7 0xC0 +#define G_MWO_bLIGHT_7 0xC4 +#define G_MWO_aLIGHT_8 0xE0 +#define G_MWO_bLIGHT_8 0xE4 #endif #define G_MWO_MATRIX_XX_XY_I 0x00 #define G_MWO_MATRIX_XZ_XW_I 0x04 #define G_MWO_MATRIX_YX_YY_I 0x08 -#define G_MWO_MATRIX_YZ_YW_I 0x0c +#define G_MWO_MATRIX_YZ_YW_I 0x0C #define G_MWO_MATRIX_ZX_ZY_I 0x10 #define G_MWO_MATRIX_ZZ_ZW_I 0x14 #define G_MWO_MATRIX_WX_WY_I 0x18 -#define G_MWO_MATRIX_WZ_WW_I 0x1c +#define G_MWO_MATRIX_WZ_WW_I 0x1C #define G_MWO_MATRIX_XX_XY_F 0x20 #define G_MWO_MATRIX_XZ_XW_F 0x24 #define G_MWO_MATRIX_YX_YY_F 0x28 -#define G_MWO_MATRIX_YZ_YW_F 0x2c +#define G_MWO_MATRIX_YZ_YW_F 0x2C #define G_MWO_MATRIX_ZX_ZY_F 0x30 #define G_MWO_MATRIX_ZZ_ZW_F 0x34 #define G_MWO_MATRIX_WX_WY_F 0x38 -#define G_MWO_MATRIX_WZ_WW_F 0x3c +#define G_MWO_MATRIX_WZ_WW_F 0x3C #define G_MWO_POINT_RGBA 0x10 #define G_MWO_POINT_ST 0x14 #define G_MWO_POINT_XYSCREEN 0x18 -#define G_MWO_POINT_ZSCREEN 0x1c +#define G_MWO_POINT_ZSCREEN 0x1C /* * Light structure. @@ -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 @@ -2102,14 +2373,14 @@ _DW({ \ Gfx *_g = (Gfx *)(pkt); \ \ _g->words.w0 = _SHIFTL(G_CULLDL, 24, 8) | \ - ((0x0f & (vstart))*40); \ - _g->words.w1 = (unsigned int)((0x0f & ((vend)+1))*40); \ + ((0x0FF& (vstart))*40); \ + _g->words.w1 = (unsigned int)((0x0F & ((vend)+1))*40); \ } #define gsSPCullDisplayList(vstart,vend) \ { \ - _SHIFTL(G_CULLDL, 24, 8) | ((0x0f & (vstart))*40), \ - ((0x0f & ((vend)+1))*40) \ + _SHIFTL(G_CULLDL, 24, 8) | ((0x0F & (vstart))*40), \ + ((0x0F & ((vend)+1))*40) \ } #endif @@ -2122,17 +2393,17 @@ _DW({ \ * Clipping Macros */ #define FR_NEG_FRUSTRATIO_1 0x00000001 -#define FR_POS_FRUSTRATIO_1 0x0000ffff +#define FR_POS_FRUSTRATIO_1 0x0000FFFF #define FR_NEG_FRUSTRATIO_2 0x00000002 -#define FR_POS_FRUSTRATIO_2 0x0000fffe +#define FR_POS_FRUSTRATIO_2 0x0000FFFE #define FR_NEG_FRUSTRATIO_3 0x00000003 -#define FR_POS_FRUSTRATIO_3 0x0000fffd +#define FR_POS_FRUSTRATIO_3 0x0000FFFD #define FR_NEG_FRUSTRATIO_4 0x00000004 -#define FR_POS_FRUSTRATIO_4 0x0000fffc +#define FR_POS_FRUSTRATIO_4 0x0000FFFC #define FR_NEG_FRUSTRATIO_5 0x00000005 -#define FR_POS_FRUSTRATIO_5 0x0000fffb +#define FR_POS_FRUSTRATIO_5 0x0000FFFB #define FR_NEG_FRUSTRATIO_6 0x00000006 -#define FR_POS_FRUSTRATIO_6 0x0000fffa +#define FR_POS_FRUSTRATIO_6 0x0000FFFA /* * r should be one of: FRUSTRATIO_1, FRUSTRATIO_2, FRUSTRATIO_3, ... FRUSTRATIO_6 */ @@ -2596,18 +2867,18 @@ _DW({ \ gsSPLookAtY((char *)(la)+16) #define gDPSetHilite1Tile(pkt, tile, hilite, width, height) \ - gDPSetTileSize(pkt, tile, (hilite)->h.x1 & 0xfff, (hilite)->h.y1 & 0xfff, \ - ((((width)-1)*4)+(hilite)->h.x1) & 0xfff, ((((height)-1)*4)+(hilite)->h.y1) & 0xfff) + gDPSetTileSize(pkt, tile, (hilite)->h.x1 & 0xFFF, (hilite)->h.y1 & 0xFFF, \ + ((((width)-1)*4)+(hilite)->h.x1) & 0xFFF, ((((height)-1)*4)+(hilite)->h.y1) & 0xFFF) #define gsDPSetHilite1Tile(tile, hilite, width, height) \ - gsDPSetTileSize(tile, (hilite)->h.x1 & 0xfff, (hilite)->h.y1 & 0xfff, \ - ((((width)-1)*4)+(hilite)->h.x1) & 0xfff, ((((height)-1)*4)+(hilite)->h.y1) & 0xfff) + gsDPSetTileSize(tile, (hilite)->h.x1 & 0xFFF, (hilite)->h.y1 & 0xFFF, \ + ((((width)-1)*4)+(hilite)->h.x1) & 0xFFF, ((((height)-1)*4)+(hilite)->h.y1) & 0xFFF) #define gDPSetHilite2Tile(pkt, tile, hilite, width, height) \ - gDPSetTileSize(pkt, tile, (hilite)->h.x2 & 0xfff, (hilite)->h.y2 & 0xfff, \ - ((((width)-1)*4)+(hilite)->h.x2) & 0xfff, ((((height)-1)*4)+(hilite)->h.y2) & 0xfff) + gDPSetTileSize(pkt, tile, (hilite)->h.x2 & 0xFFF, (hilite)->h.y2 & 0xFFF, \ + ((((width)-1)*4)+(hilite)->h.x2) & 0xFFF, ((((height)-1)*4)+(hilite)->h.y2) & 0xFFF) #define gsDPSetHilite2Tile(tile, hilite, width, height) \ - gsDPSetTileSize(tile, (hilite)->h.x2 & 0xfff, (hilite)->h.y2 & 0xfff, \ - ((((width)-1)*4)+(hilite)->h.x2) & 0xfff, ((((height)-1)*4)+(hilite)->h.y2) & 0xfff) + gsDPSetTileSize(tile, (hilite)->h.x2 & 0xFFF, (hilite)->h.y2 & 0xFFF, \ + ((((width)-1)*4)+(hilite)->h.x2) & 0xFFF, ((((height)-1)*4)+(hilite)->h.y2) & 0xFFF) /* * FOG macros @@ -3608,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); \ @@ -3623,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 */ @@ -3976,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, \ @@ -3998,7 +4269,7 @@ _DW({ \ (ult)<> 28) #define SEGMENT_ADDR(num, off) (((num) << 24) + (off)) diff --git a/include/PR/ultratypes.h b/include/PR/ultratypes.h index 0e6f4cf39..8b4e1a82c 100644 --- a/include/PR/ultratypes.h +++ b/include/PR/ultratypes.h @@ -27,6 +27,10 @@ typedef void* TexturePtr; typedef long int Mtx_t[4][4]; typedef union { Mtx_t m; + struct { + u16 intPart[4][4]; + u16 fracPart[4][4]; + }; long long int forc_structure_alignment; } Mtx; // size = 0x40 @@ -34,10 +38,10 @@ typedef float MtxF_t[4][4]; typedef union { MtxF_t mf; struct { - float xx, xy, xz, xw, - yx, yy, yz, yw, - zx, zy, zz, zw, - wx, wy, wz, ww; + float xx, yx, zx, wx, + xy, yy, zy, wy, + xz, yz, zz, wz, + xw, yw, zw, ww; }; } MtxF; // size = 0x40 diff --git a/include/color.h b/include/color.h index 438d857ad..b0b4d2cb0 100644 --- a/include/color.h +++ b/include/color.h @@ -19,6 +19,12 @@ typedef struct { /* 0x3 */ u8 a; } Color_RGBA8; // size = 0x4 +typedef struct { + /* 0x0 */ s16 r; + /* 0x2 */ s16 g; + /* 0x4 */ s16 b; +} Color_RGB16; // size = 0x6 + // only use when necessary for alignment purposes typedef union { struct { diff --git a/include/functions.h b/include/functions.h index 522fac154..65d1b8b18 100644 --- a/include/functions.h +++ b/include/functions.h @@ -1,5 +1,5 @@ -#ifndef _FUNCTIONS_H_ -#define _FUNCTIONS_H_ +#ifndef FUNCTIONS_H +#define FUNCTIONS_H #include "z64.h" @@ -104,12 +104,7 @@ void FaultDrawer_SetInputCallback(FaultDrawerCallback callback); void FaultDrawer_Init(void); void func_80084940(void); void func_80084968(void); -void Load_Relocate(u32 allocatedVRamAddr, OverlayRelocationSection* overlayInfo, u32 vRamStart); -s32 Load_LoadOverlay(u32 vRomStart, u32 vRomEnd, u32 vRamStart, u32 allocatedVRamAddr, u32 allocatedBytes); -void* Load_AllocateAndLoad(u32 vRomStart, u32 vRomEnd, u32 vRamStart); -void Load2_Relocate(u32 allocatedVRamAddr, OverlayRelocationSection* overlayInfo, u32 vRamStart); -s32 Load2_LoadOverlay(u32 vRomStart, u32 vRomEnd, u32 vRamStart, u32 vRamEnd, u32 allocatedVRamAddr); -void* Overlay_AllocateAndLoad(u32 vRomStart, u32 vRomEnd, u32 vRamStart, u32 vRamEnd); + void PadUtils_Init(Input* input); void func_80085150(void); void PadUtils_ResetPressRel(Input* input); @@ -132,24 +127,10 @@ void StackCheck_Cleanup(StackEntry* entry); StackStatus StackCheck_GetState(StackEntry* entry); u32 StackCheck_CheckAll(void); u32 StackCheck_Check(StackEntry* entry); -void GfxPrint_InitDlist(GfxPrint* printer); -void GfxPrint_SetColor(GfxPrint* printer, u32 r, u32 g, u32 b, u32 a); -void GfxPrint_SetPosPx(GfxPrint* printer, s32 x, s32 y); -void GfxPrint_SetPos(GfxPrint* printer, s32 x, s32 y); -void GfxPrint_SetBasePosPx(GfxPrint* printer, s32 x, s32 y); -void GfxPrint_PrintCharImpl(GfxPrint* printer, u8 c); -void GfxPrint_PrintChar(GfxPrint* printer, u8 c); -void GfxPrint_PrintStringWithSize(GfxPrint* printer, const void* buffer, size_t charSize, size_t charCount); -void GfxPrint_PrintString(GfxPrint* printer, const char* str); -GfxPrint* GfxPrint_Callback(GfxPrint* printer, const char* str, size_t size); -void GfxPrint_Init(GfxPrint* printer); -void GfxPrint_Destroy(GfxPrint* printer); -void GfxPrint_Open(GfxPrint* printer, Gfx* dList); -Gfx* GfxPrint_Close(GfxPrint* printer); -s32 GfxPrint_VPrintf(GfxPrint* printer, const char* fmt, va_list args); -s32 GfxPrint_Printf(GfxPrint* printer, const char* fmt, ...); -void MtxConv_F2L(MatrixInternal* m1, MtxF* m2); -void MtxConv_L2F(MtxF* m1, MatrixInternal* m2); + +void MtxConv_F2L(Mtx* m1, MtxF* m2); +void MtxConv_L2F(MtxF* m1, Mtx* m2); + void __assert(const char* file, u32 lineNum); // void func_800862B4(void); void* SystemArena_MallocMin1(u32 size); @@ -191,7 +172,7 @@ f64 func_80086D6C(f64 param_1); s32 func_80086D8C(f32 param_1); s32 func_80086DAC(f64 param_1); -s32 Rand_Next(void); +u32 Rand_Next(void); void Rand_Seed(u32 seed); f32 Rand_ZeroOne(void); f32 Rand_Centered(void); @@ -220,7 +201,7 @@ OSIntMask osSetIntMask(OSIntMask im); // OSIntMask osGetIntMask(void); // void osVoiceSetWord(void); // void guScale(void); -f32 __sinf(f32 __x); +f32 sinf(f32 __x); s16 sins(u16 x); OSTask* _VirtualToPhysicalTask(OSTask* intp); void osSpTaskLoad(OSTask* intp); @@ -377,7 +358,7 @@ void __osRestoreInt(OSIntMask im); void __osViInit(void); void __osViSwapContext(void); OSMesgQueue* osPiGetCmdQueue(void); -f32 __cosf(f32 __x); +f32 cosf(f32 __x); s32 osEPiReadIo(OSPiHandle* pihandle, u32 devAddr, u32* data); void osViSetSpecialFeatures(u32 func); s16 coss(u16 x); @@ -450,27 +431,27 @@ s32 __osStrcmp(const char* str1, const char* str2); char* __osStrcpy(char* dst, const char* src); void* __osMemcpy(void* dst, void* src, size_t size); -// void EnItem00_SetObject(EnItem00* this, GlobalContext* globalCtx, f32* shadowOffset, f32* shadowScale); -// void EnItem00_Init(Actor* thisx, GlobalContext* globalCtx); -// void EnItem00_Destroy(Actor* thisx, GlobalContext* globalCtx); -// void EnItem00_WaitForHeartObject(EnItem00* this, GlobalContext* globalCtx); -// void func_800A640C(EnItem00* this, GlobalContext* globalCtx); -// void func_800A6650(EnItem00* this, GlobalContext* globalCtx); -// void func_800A6780(EnItem00* this, GlobalContext* globalCtx); -// void func_800A6A40(EnItem00* this, GlobalContext* globalCtx); -// void EnItem00_Update(Actor* thisx, GlobalContext* globalCtx); -// void EnItem00_Draw(Actor* thisx, GlobalContext* globalCtx); -// void EnItem00_DrawRupee(EnItem00* this, GlobalContext* globalCtx); -// void EnItem00_DrawSprite(EnItem00* this, GlobalContext* globalCtx); -// void EnItem00_DrawHeartContainer(EnItem00* this, GlobalContext* globalCtx); -// void EnItem00_DrawHeartPiece(EnItem00* this, GlobalContext* globalCtx); +// void EnItem00_SetObject(EnItem00* this, PlayState* play, f32* shadowOffset, f32* shadowScale); +// void EnItem00_Init(Actor* thisx, PlayState* play); +// void EnItem00_Destroy(Actor* thisx, PlayState* play); +// void EnItem00_WaitForHeartObject(EnItem00* this, PlayState* play); +// void func_800A640C(EnItem00* this, PlayState* play); +// void func_800A6650(EnItem00* this, PlayState* play); +// void func_800A6780(EnItem00* this, PlayState* play); +// void func_800A6A40(EnItem00* this, PlayState* play); +// void EnItem00_Update(Actor* thisx, PlayState* play); +// void EnItem00_Draw(Actor* thisx, PlayState* play); +// void EnItem00_DrawRupee(EnItem00* this, PlayState* play); +// void EnItem00_DrawSprite(EnItem00* this, PlayState* play); +// void EnItem00_DrawHeartContainer(EnItem00* this, PlayState* play); +// void EnItem00_DrawHeartPiece(EnItem00* this, PlayState* play); // s16 func_800A7650(s16 dropId); -Actor* Item_DropCollectible(GlobalContext* globalCtx, Vec3f* spawnPos, u32 params); -Actor* Item_DropCollectible2(GlobalContext* globalCtx, Vec3f* spawnPos, s32 params); -void Item_DropCollectibleRandom(GlobalContext* globalCtx, Actor* fromActor, Vec3f* spawnPos, s16 params); +Actor* Item_DropCollectible(PlayState* play, Vec3f* spawnPos, u32 params); +Actor* Item_DropCollectible2(PlayState* play, Vec3f* spawnPos, s32 params); +void Item_DropCollectibleRandom(PlayState* play, Actor* fromActor, Vec3f* spawnPos, s16 params); s32 func_800A8150(s32 index); s32 func_800A817C(s32 index); -s32 func_800A81A4(GlobalContext* globalCtx, s32 a1, s32 a2); +s32 Item_CanDropBigFairy(PlayState* play, s32 index, s32 collectibleFlag); void EffectBlure_AddVertex(EffectBlure* this, Vec3f* p1, Vec3f* p2); void EffectBlure_AddSpace(EffectBlure* this); void EffectBlure_Init1(void* thisx, void* initParamsx); @@ -486,168 +467,166 @@ void EffectSpark_Init(void* thisx, void* initParamsx); void EffectSpark_Destroy(void* thisx); s32 EffectSpark_Update(void* thisx); void EffectSpark_Draw(void* thisx, GraphicsContext* gfxCtx); -void func_800AE2A0(GlobalContext* globalCtx, Color_RGBA8* color, s16 arg2, s16 arg3); -void func_800AE434(GlobalContext* globalCtx, Color_RGBA8* color, s16 arg2, s16 arg3); -void func_800AE5A0(GlobalContext* globalCtx); -void func_800AE5E4(GlobalContext* globalCtx, Color_RGBA8* color, s16 arg2, s16 arg3); -void func_800AE778(GlobalContext* globalCtx, Color_RGBA8* color, s16 arg2, s16 arg3); -void func_800AE8EC(GlobalContext* globalCtx); +void func_800AE2A0(PlayState* play, Color_RGBA8* color, s16 arg2, s16 arg3); +void func_800AE434(PlayState* play, Color_RGBA8* color, s16 arg2, s16 arg3); +void func_800AE5A0(PlayState* play); +void func_800AE5E4(PlayState* play, Color_RGBA8* color, s16 arg2, s16 arg3); +void func_800AE778(PlayState* play, Color_RGBA8* color, s16 arg2, s16 arg3); +void func_800AE8EC(PlayState* play); void func_800AE930(CollisionContext* colCtx, EffectTireMark* this, Vec3f* pos, f32 arg3, s16 angle, CollisionPoly* colPoly, s32 arg6); void func_800AEF44(EffectTireMark* this); void EffectTireMark_Init(void* thisx, void* initParamsx); void EffectTireMark_Destroy(void* thisx); s32 EffectTireMark_Update(void* thisx); void EffectTireMark_Draw(void* thisx, GraphicsContext* gfxCtx); -GlobalContext* Effect_GetGlobalCtx(void); +PlayState* Effect_GetPlayState(void); void* Effect_GetByIndex(s32 index); -void Effect_Init(GlobalContext* globalCtx); -void Effect_Add(GlobalContext* globalCtx, s32* pIndex, s32 type, u8 arg3, u8 arg4, void* initParams); +void Effect_Init(PlayState* play); +void Effect_Add(PlayState* play, s32* pIndex, s32 type, u8 arg3, u8 arg4, void* initParams); void Effect_DrawAll(GraphicsContext* gfxCtx); -void Effect_UpdateAll(GlobalContext* globalCtx); -void Effect_Destroy(GlobalContext* globalCtx, s32 index); -void Effect_DestroyAll(GlobalContext* globalCtx); -void EffectSS_Init(GlobalContext* globalCtx, s32 numEntries); -void EffectSS_Clear(GlobalContext* globalCtx); +void Effect_UpdateAll(PlayState* play); +void Effect_Destroy(PlayState* play, s32 index); +void Effect_DestroyAll(PlayState* play); +void EffectSS_Init(PlayState* play, s32 numEntries); +void EffectSS_Clear(PlayState* play); EffectSs* EffectSS_GetTable(void); void EffectSS_Delete(EffectSs* param_1); void EffectSS_ResetEntry(EffectSs* particle); s32 EffectSS_FindFreeSpace(s32 priority, s32* tableEntry); -void EffectSS_Copy(GlobalContext* globalCtx, EffectSs* particle); -void EffectSs_Spawn(GlobalContext* globalCtx, s32 type, s32 priority, void* initParams); -void EffectSS_UpdateParticle(GlobalContext* globalCtx, s32 index); -void EffectSS_UpdateAllParticles(GlobalContext* globalCtx); -void EffectSS_DrawParticle(GlobalContext* globalCtx, s32 index); -void EffectSS_DrawAllParticles(GlobalContext* globalCtx); +void EffectSS_Copy(PlayState* play, EffectSs* particle); +void EffectSs_Spawn(PlayState* play, s32 type, s32 priority, void* initParams); +void EffectSS_UpdateParticle(PlayState* play, s32 index); +void EffectSS_UpdateAllParticles(PlayState* play); +void EffectSS_DrawParticle(PlayState* play, s32 index); +void EffectSS_DrawAllParticles(PlayState* play); s16 func_800B096C(s16 param_1, s16 param_2, s32 param_3); s16 func_800B09D0(s16 a0, s16 a1, f32 a2); u8 func_800B0A24(u8 a0, u8 a1, f32 a2); -void EffectSs_DrawGEffect(GlobalContext* globalCtx, EffectSs* this, void* texture); -void EffectSsDust_Spawn(GlobalContext* globalCtx, u16 drawFlags, Vec3f* pos, Vec3f* velocity, Vec3f* accel, Color_RGBA8* primColor, Color_RGBA8* envColor, s16 scale, s16 scaleStep, s16 life, u8 updateMode); -void func_800B0DE0(GlobalContext* globalCtx, Vec3f* pos, Vec3f* velocity, Vec3f* accel, Color_RGBA8* primColor, Color_RGBA8* envColor, s16 scale, s16 scaleStep); -void func_800B0E48(GlobalContext* globalCtx, Vec3f* pos, Vec3f* velocity, Vec3f* accel, Color_RGBA8* primColor, Color_RGBA8* envColor, s16 scale, s16 scaleStep); -void func_800B0EB0(GlobalContext* globalCtx, Vec3f* pos, Vec3f* velocity, Vec3f* accel, Color_RGBA8* primColor, Color_RGBA8* envColor, s16 scale, s16 scaleStep, s16 life); -void func_800B0F18(GlobalContext* globalCtx, Vec3f* pos, Vec3f* velocity, Vec3f* accel, Color_RGBA8* primColor, Color_RGBA8* envColor, s16 scale, s16 scaleStep, s16 life); -void func_800B0F80(GlobalContext* globalCtx, Vec3f* pos, Vec3f* velocity, Vec3f* accel, Color_RGBA8* primColor, Color_RGBA8* envColor, s16 scale, s16 scaleStep, s16 life); -void func_800B0FE8(GlobalContext* globalCtx, Vec3f* pos, Vec3f* velocity, Vec3f* accel, Color_RGBA8* primColor, Color_RGBA8* envColor, s16 scale, s16 scaleStep); -void func_800B1054(GlobalContext* globalCtx, Vec3f* pos, Vec3f* velocity, Vec3f* accel, Color_RGBA8* primColor, Color_RGBA8* envColor, s16 scale, s16 scaleStep); -void func_800B10C0(GlobalContext* globalCtx, Vec3f* pos, Vec3f* velocity, Vec3f* accel); -void func_800B1130(GlobalContext* globalCtx, Vec3f* pos, Vec3f* velocity, Vec3f* accel); -void func_800B11A0(GlobalContext* globalCtx, Vec3f* pos, Vec3f* velocity, Vec3f* accel, s16 scale, s16 scaleStep); -void func_800B1210(GlobalContext* globalCtx, Vec3f* pos, Vec3f* velocity, Vec3f* accel, s16 scale, s16 scaleStep); -void func_800B1280(GlobalContext* globalCtx, Vec3f* pos, Vec3f* velocity, Vec3f* accel, s16 scale, s16 scaleStep, s16 life); -void func_800B12F0(GlobalContext* globalCtx, Vec3f* pos, Vec3f* velocity, Vec3f* accel, s16 scale, s16 scaleStep, s16 life); -void func_800B1360(GlobalContext* globalCtx, Vec3f* pos, Vec3f* velocity, Vec3f* accel, Color_RGBA8* primColor, Color_RGBA8* envColor); -void func_800B139C(GlobalContext* globalCtx, Vec3f* pos, Vec3f* velocity, Vec3f* accel, Color_RGBA8* primColor, Color_RGBA8* envColor); +void EffectSs_DrawGEffect(PlayState* play, EffectSs* this, void* texture); +void EffectSsDust_Spawn(PlayState* play, u16 drawFlags, Vec3f* pos, Vec3f* velocity, Vec3f* accel, Color_RGBA8* primColor, Color_RGBA8* envColor, s16 scale, s16 scaleStep, s16 life, u8 updateMode); +void func_800B0DE0(PlayState* play, Vec3f* pos, Vec3f* velocity, Vec3f* accel, Color_RGBA8* primColor, Color_RGBA8* envColor, s16 scale, s16 scaleStep); +void func_800B0E48(PlayState* play, Vec3f* pos, Vec3f* velocity, Vec3f* accel, Color_RGBA8* primColor, Color_RGBA8* envColor, s16 scale, s16 scaleStep); +void func_800B0EB0(PlayState* play, Vec3f* pos, Vec3f* velocity, Vec3f* accel, Color_RGBA8* primColor, Color_RGBA8* envColor, s16 scale, s16 scaleStep, s16 life); +void func_800B0F18(PlayState* play, Vec3f* pos, Vec3f* velocity, Vec3f* accel, Color_RGBA8* primColor, Color_RGBA8* envColor, s16 scale, s16 scaleStep, s16 life); +void func_800B0F80(PlayState* play, Vec3f* pos, Vec3f* velocity, Vec3f* accel, Color_RGBA8* primColor, Color_RGBA8* envColor, s16 scale, s16 scaleStep, s16 life); +void func_800B0FE8(PlayState* play, Vec3f* pos, Vec3f* velocity, Vec3f* accel, Color_RGBA8* primColor, Color_RGBA8* envColor, s16 scale, s16 scaleStep); +void func_800B1054(PlayState* play, Vec3f* pos, Vec3f* velocity, Vec3f* accel, Color_RGBA8* primColor, Color_RGBA8* envColor, s16 scale, s16 scaleStep); +void func_800B10C0(PlayState* play, Vec3f* pos, Vec3f* velocity, Vec3f* accel); +void func_800B1130(PlayState* play, Vec3f* pos, Vec3f* velocity, Vec3f* accel); +void func_800B11A0(PlayState* play, Vec3f* pos, Vec3f* velocity, Vec3f* accel, s16 scale, s16 scaleStep); +void func_800B1210(PlayState* play, Vec3f* pos, Vec3f* velocity, Vec3f* accel, s16 scale, s16 scaleStep); +void func_800B1280(PlayState* play, Vec3f* pos, Vec3f* velocity, Vec3f* accel, s16 scale, s16 scaleStep, s16 life); +void func_800B12F0(PlayState* play, Vec3f* pos, Vec3f* velocity, Vec3f* accel, s16 scale, s16 scaleStep, s16 life); +void func_800B1360(PlayState* play, Vec3f* pos, Vec3f* velocity, Vec3f* accel, Color_RGBA8* primColor, Color_RGBA8* envColor); +void func_800B139C(PlayState* play, Vec3f* pos, Vec3f* velocity, Vec3f* accel, Color_RGBA8* primColor, Color_RGBA8* envColor); void func_800B13D8(Vec3f* srcPos, f32 randScale, Vec3f* newPos, Vec3f* velocity, Vec3f* accel); -void func_800B14D4(GlobalContext* globalCtx, f32 randScale, Vec3f* srcPos); -void func_800B1598(GlobalContext* globalCtx, f32 randScale, Vec3f* srcPos); -void EffectSsKiraKira_SpawnSmallYellow(GlobalContext* globalCtx, Vec3f* pos, Vec3f* velocity, Vec3f* accel); -void EffectSsKiraKira_SpawnSmall(GlobalContext* globalCtx, Vec3f* pos, Vec3f* velocity, Vec3f* accel, Color_RGBA8* primColor, Color_RGBA8* envColor); -void EffectSsGSpk_SpawnSmall(GlobalContext* globalCtx, Actor* actor, Vec3f* pos, Vec3f* velocity, Vec3f* accel, Color_RGBA8* primColor, Color_RGBA8* envColor); -void EffectSsKiraKira_SpawnDispersed(GlobalContext* globalCtx, Vec3f* pos, Vec3f* velocity, Vec3f* accel, Color_RGBA8* primColor, Color_RGBA8* envColor, s16 scale, s32 life); -// void EffectSsKiraKira_SpawnFocused(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE4 param_5, UNK_TYPE4 param_6, UNK_TYPE2 param_7, UNK_TYPE4 param_8); +void func_800B14D4(PlayState* play, f32 randScale, Vec3f* srcPos); +void func_800B1598(PlayState* play, f32 randScale, Vec3f* srcPos); +void EffectSsKirakira_SpawnSmallYellow(PlayState* play, Vec3f* pos, Vec3f* velocity, Vec3f* accel); +void EffectSsKirakira_SpawnSmall(PlayState* play, Vec3f* pos, Vec3f* velocity, Vec3f* accel, Color_RGBA8* primColor, Color_RGBA8* envColor); +void EffectSsGSpk_SpawnSmall(PlayState* play, Actor* actor, Vec3f* pos, Vec3f* velocity, Vec3f* accel, Color_RGBA8* primColor, Color_RGBA8* envColor); +void EffectSsKirakira_SpawnDispersed(PlayState* play, Vec3f* pos, Vec3f* velocity, Vec3f* accel, Color_RGBA8* primColor, Color_RGBA8* envColor, s16 scale, s32 life); +// void EffectSsKirakira_SpawnFocused(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE4 param_5, UNK_TYPE4 param_6, UNK_TYPE2 param_7, UNK_TYPE4 param_8); // void EffectSsBomb2_SpawnFade(UNK_TYPE4 uParm1, Vec3f* pzParm2, Vec3f* pzParm3, Vec3f* pzParm4); -void EffectSsBomb2_SpawnLayered(GlobalContext* globalCtx, Vec3f* pos, Vec3f* velocity, Vec3f* accel, s16 scale, s16 scaleStep); +void EffectSsBomb2_SpawnLayered(PlayState* play, Vec3f* pos, Vec3f* velocity, Vec3f* accel, s16 scale, s16 scaleStep); // void EffectSsBlast_Spawn(UNK_TYPE4 uParm1, Vec3f* pzParm2, Vec3f* pzParm3, Vec3f* pzParm4, Color_RGBA8* param_5, Color_RGBA8* param_6, UNK_TYPE2 param_7, UNK_TYPE2 param_8, UNK_TYPE2 param_9, UNK_TYPE2 param_10); -void EffectSsBlast_SpawnWhiteCustomScale(GlobalContext* globalCtx, Vec3f* pos, Vec3f* velocity, Vec3f* accel, s16 scale, +void EffectSsBlast_SpawnWhiteCustomScale(PlayState* play, Vec3f* pos, Vec3f* velocity, Vec3f* accel, s16 scale, s16 scaleStep, s16 life); // void EffectSsBlast_SpawnShockwave(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE4 param_5, UNK_TYPE4 param_6, UNK_TYPE2 param_7); -void EffectSsBlast_SpawnWhiteShockwave(GlobalContext* globalCtx, Vec3f* arg1, Vec3f* arg2, Vec3f* arg3); +void EffectSsBlast_SpawnWhiteShockwave(PlayState* play, Vec3f* arg1, Vec3f* arg2, Vec3f* arg3); // void EffectSsGSpk_SpawnAccel(UNK_TYPE4 uParm1, UNK_TYPE4 uParm2, Vec3f* pzParm3, Vec3f* pzParm4, Vec3f* param_5, Color_RGBA8* param_6, Color_RGBA8* param_7, UNK_TYPE2 param_8, UNK_TYPE2 param_9); // void EffectSsGSpk_SpawnNoAccel(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE4 param_5, UNK_TYPE4 param_6, UNK_TYPE4 param_7, UNK_TYPE2 param_8, UNK_TYPE2 param_9); -void EffectSsGSpk_SpawnFuse(GlobalContext* globalCtx, Actor* actor, Vec3f* pos, Vec3f* velocity, Vec3f* accel); +void EffectSsGSpk_SpawnFuse(PlayState* play, Actor* actor, Vec3f* pos, Vec3f* velocity, Vec3f* accel); // void EffectSsGSpk_SpawnRandColor(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE4 param_5, UNK_TYPE2 param_6, UNK_TYPE2 param_7); // void EffectSsGSpk_SpawnSmall(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE4 param_5, UNK_TYPE4 param_6, UNK_TYPE4 param_7); -void EffectSsDFire_Spawn(GlobalContext* globalCtx, Vec3f* pos, Vec3f* velocity, Vec3f* accel, s16 scale, s16 scaleStep, s16 alpha, s16 fadeDelay, s16 life, s32 arg9); -void EffectSsBubble_Spawn(GlobalContext* globalCtx, Vec3f* pos, f32 yPosOffset, f32 yPosRandScale, f32 xzPosRandScale, f32 scale); -void EffectSsGRipple_Spawn(GlobalContext* globalCtx, Vec3f* pos, s16 radius, s16 radiusMax, s16 life); -void EffectSsGSplash_Spawn(GlobalContext* globalCtx, Vec3f* pos, Color_RGBA8* primColor, Color_RGBA8* envColor, s16 type, s16 scale); -// void EffectSsGFire_Spawn(UNK_TYPE4 uParm1, Vec3f* pzParm2); +void EffectSsDFire_Spawn(PlayState* play, Vec3f* pos, Vec3f* velocity, Vec3f* accel, s16 scale, s16 scaleStep, s16 alpha, s16 fadeDelay, s16 life, s32 arg9); +void EffectSsBubble_Spawn(PlayState* play, Vec3f* pos, f32 yPosOffset, f32 yPosRandScale, f32 xzPosRandScale, f32 scale); +void EffectSsGRipple_Spawn(PlayState* play, Vec3f* pos, s16 radius, s16 radiusMax, s16 life); +void EffectSsGSplash_Spawn(PlayState* play, Vec3f* pos, Color_RGBA8* primColor, Color_RGBA8* envColor, s16 type, s16 scale); +void EffectSsGFire_Spawn(PlayState* play, Vec3f* pos); // void EffectSsLightning_Spawn(UNK_TYPE4 uParm1, Vec3f* pzParm2, Color_RGBA8* pzParm3, Color_RGBA8* pzParm4, UNK_TYPE2 param_5, UNK_TYPE2 param_6, UNK_TYPE2 param_7, UNK_TYPE2 param_8); -// void EffectSsDtBubble_SpawnColorProfile(UNK_TYPE4 param_1, Vec3f* param_2, Vec3f* param_3, Vec3f* param_4, UNK_TYPE2 param_5, UNK_TYPE2 param_6, UNK_TYPE2 param_7, UNK_TYPE2 param_8); -void EffectSsDtBubble_SpawnCustomColor(GlobalContext* globalCtx, Vec3f* pos, Vec3f* velocity, Vec3f* accel, Color_RGBA8* primColor, Color_RGBA8* envColor, s16 scale, s16 life, s16 randXZ); -void EffectSsHahen_Spawn(GlobalContext* globalCtx, Vec3f* pos, Vec3f* velocity, Vec3f* accel, s16 unused, s16 scale, s16 objId, s16 life, Gfx* dList); -void EffectSsHahen_SpawnBurst(GlobalContext* globalCtx, Vec3f* pos, f32 burstScale, s16 unused, s16 scale, s16 randScaleRange, s16 count, s16 objId, s16 life, Gfx* dList); +void EffectSsDtBubble_SpawnColorProfile(PlayState* play, Vec3f* pos, Vec3f* velocity, Vec3f* accel, s16 scale, s16 life, s16 colorProfile, s16 randXZ); +void EffectSsDtBubble_SpawnCustomColor(PlayState* play, Vec3f* pos, Vec3f* velocity, Vec3f* accel, Color_RGBA8* primColor, Color_RGBA8* envColor, s16 scale, s16 life, s16 randXZ); +void EffectSsHahen_Spawn(PlayState* play, Vec3f* pos, Vec3f* velocity, Vec3f* accel, s16 flags, s16 scale, s16 objId, s16 life, Gfx* dList); +void EffectSsHahen_SpawnBurst(PlayState* play, Vec3f* pos, f32 burstScale, s16 flags, s16 scale, s16 randScaleRange, s16 count, s16 objId, s16 life, Gfx* dList); // void func_800B2364(void); // void EffectSsStick_Spawn(UNK_TYPE4 uParm1, UNK_PTR puParm2, UNK_TYPE2 uParm3); // void EffectSsSibuki_Spawn(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE2 param_5, UNK_TYPE2 param_6, UNK_TYPE2 param_7); -void EffectSsSibuki_SpawnBurst(GlobalContext* globalCtx, Vec3f* pos); -void EffectSsStone1_Spawn(GlobalContext* globalCtx, Vec3f* arg1, s32 arg2); -// void EffectSsHitMark_Spawn(UNK_TYPE4 uParm1, UNK_TYPE4 uParm2, UNK_TYPE2 uParm3, Vec3f* pzParm4); -void EffectSsHitMark_SpawnFixedScale(GlobalContext* globalCtx, s32 type, Vec3f* pos); -void EffectSsHitMark_SpawnCustomScale(GlobalContext* globalCtx, s32 type, s16 scale, Vec3f* pos); -// void EffectSsFhgFlash_SpawnShock(UNK_TYPE4 uParm1, UNK_TYPE4 uParm2, Vec3f* pzParm3, UNK_TYPE2 uParm4, UNK_TYPE1 param_5); +void EffectSsSibuki_SpawnBurst(PlayState* play, Vec3f* pos); +void EffectSsStone1_Spawn(PlayState* play, Vec3f* pos, s32 reg0); +void EffectSsHitmark_SpawnFixedScale(PlayState* play, s32 type, Vec3f* pos); +void EffectSsHitmark_SpawnCustomScale(PlayState* play, s32 type, s16 scale, Vec3f* pos); +void EffectSsFhgFlash_SpawnShock(PlayState* play, Actor* actor, Vec3f* pos, s16 scale, u8 params); // void EffectSsKFire_Spawn(UNK_TYPE4 uParm1, Vec3f* pzParm2, Vec3f* pzParm3, Vec3f* pzParm4, UNK_TYPE2 param_5, UNK_TYPE1 param_6); -void EffectSsSolderSrchBall_Spawn(GlobalContext* globalCtx, Vec3f* pos, Vec3f* velocity, Vec3f* accel, s16 unused, s16* linkDetected, s16 drawFlag); -void EffectSsKakera_Spawn(GlobalContext* globalCtx, Vec3f* pos, Vec3f* velocity, Vec3f* arg3, s16 gravity, s16 arg5, s16 arg6, s16 arg7, s16 arg8, s16 scale, s16 arg10, s16 arg11, s32 life, s16 colorIdx, s16 objId, Gfx* dList); +void EffectSsSolderSrchBall_Spawn(PlayState* play, Vec3f* pos, Vec3f* velocity, Vec3f* accel, s16 unused, s16* linkDetected, s16 drawFlag); +void EffectSsKakera_Spawn(PlayState* play, Vec3f* pos, Vec3f* velocity, Vec3f* arg3, s16 gravity, s16 arg5, s16 arg6, s16 arg7, s16 arg8, s16 scale, s16 arg10, s16 arg11, s32 life, s16 colorIdx, s16 objId, Gfx* dList); // void EffectSsIcePiece_Spawn(UNK_TYPE4 uParm1, Vec3f* pzParm2, UNK_TYPE4 uParm3, Vec3f* pzParm4, Vec3f* param_5, UNK_TYPE4 param_6); // void EffectSsIcePiece_SpawnBurst(void); -// void EffectSsEnIce_SpawnFlyingVec3f(UNK_TYPE4 uParm1, Actor* pzParm2, Vec3f* pzParm3, Color_RGBA8* pzParm4, Color_RGBA8* param_5, UNK_TYPE4 param_6); -// void func_800B2B44(void); +void func_800B2B44(PlayState* play, Actor* actor, Vec3f* arg2, f32 arg3); // void func_800B2B7C(void); -void EffectSsEnIce_Spawn(GlobalContext* globalCtx, Vec3f* pos, f32 scale, Vec3f* velocity, Vec3f* accel, Color_RGBA8* primColor, Color_RGBA8* envColor, s32 life); +void EffectSsEnIce_Spawn(PlayState* play, Vec3f* pos, f32 scale, Vec3f* velocity, Vec3f* accel, Color_RGBA8* primColor, Color_RGBA8* envColor, s32 life); // void EffectSsFireTail_Spawn(UNK_TYPE4 uParm1, UNK_TYPE4 uParm2, Vec3f* pzParm3, UNK_TYPE4 uParm4, Vec3f* param_5, UNK_TYPE2 param_6, Color_RGBA8* param_7, Color_RGBA8* param_8, UNK_TYPE2 param_9, UNK_TYPE2 param_10, UNK_TYPE4 param_11); // void EffectSsFireTail_SpawnFlame(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE2 param_5, UNK_TYPE4 param_6); // void EffectSsFireTail_SpawnFlameOnPlayer(void); -void EffectSsEnFire_SpawnVec3f(GlobalContext* globalCtx, Actor* actor, Vec3f* pos, s16 scale, s16 arg4, s16 flags, s16 bodyPart); +void EffectSsEnFire_SpawnVec3f(PlayState* play, Actor* actor, Vec3f* pos, s16 scale, s16 params, s16 flags, s16 bodyPart); // void EffectSsEnFire_SpawnVec3s(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE2 param_5, UNK_TYPE2 param_6, UNK_TYPE2 param_7); -void EffectSsExtra_Spawn(GlobalContext* globalCtx, Vec3f* pos, Vec3f* velocity, Vec3f* accel, s16 scale, s16 scoreIdx); -void EffectSsDeadDb_Spawn(GlobalContext* globalCtx, Vec3f* pos, Vec3f* velocity, Vec3f* accel, Color_RGBA8* prim, Color_RGBA8* env, s16 scale, s16 scaleStep, s32 unk); -void func_800B3030(GlobalContext* globalCtx, Vec3f* pos, Vec3f* velocity, Vec3f* accel, s16 scale, s16 scaleStep, s32 colorIndex); -void EffectSsDeadDd_Spawn(GlobalContext* globalCtx, Vec3f* pos, Vec3f* velocity, Vec3f* accel, Color_RGBA8* prim, Color_RGBA8* env, s16 scale, s16 scaleStep, s16 alphaStep, s32 life); +void EffectSsExtra_Spawn(PlayState* play, Vec3f* pos, Vec3f* velocity, Vec3f* accel, s16 scale, s16 scoreIdx); +void EffectSsDeadDb_Spawn(PlayState* play, Vec3f* pos, Vec3f* velocity, Vec3f* accel, Color_RGBA8* prim, Color_RGBA8* env, s16 scale, s16 scaleStep, s32 unk); +void func_800B3030(PlayState* play, Vec3f* pos, Vec3f* velocity, Vec3f* accel, s16 scale, s16 scaleStep, s32 colorIndex); +void EffectSsDeadDd_Spawn(PlayState* play, Vec3f* pos, Vec3f* velocity, Vec3f* accel, Color_RGBA8* prim, Color_RGBA8* env, s16 scale, s16 scaleStep, s16 alphaStep, s32 life); // void EffectSsDeadDs_Spawn(UNK_TYPE4 uParm1, Vec3f* pzParm2, Vec3f* pzParm3, Vec3f* pzParm4, UNK_TYPE2 param_5, UNK_TYPE2 param_6, UNK_TYPE2 param_7, UNK_TYPE4 param_8); -void func_800B31BC(GlobalContext* globalCtx, Vec3f* pos, s16 scale, s16 scaleStep, s16 alpha, s32 life); -void EffectSsIceSmoke_Spawn(GlobalContext* globalCtx, Vec3f* pos, Vec3f* velocity, Vec3f* accel, s16 scale); -void EffectSsIceBlock_Spawn(GlobalContext* globalCtx, Vec3f* pos, Vec3f* velocity, Vec3f* accel, s16 scale); +void func_800B31BC(PlayState* play, Vec3f* pos, s16 scale, s16 scaleStep, s16 alpha, s32 life); +void EffectSsIceSmoke_Spawn(PlayState* play, Vec3f* pos, Vec3f* velocity, Vec3f* accel, s16 scale); +void EffectSsIceBlock_Spawn(PlayState* play, Vec3f* pos, Vec3f* velocity, Vec3f* accel, s16 scale); void FlagSet_Update(GameState* gameState); void FlagSet_Draw(GameState* gameState); void Overlay_LoadGameState(GameStateOverlay* gameState); void Overlay_FreeGameState(GameStateOverlay* gameState); void ActorShape_Init(ActorShape* actorShape, f32 yOffset, ActorShadowFunc shadowDraw, f32 shadowScale); -void ActorShadow_DrawCircle(Actor* actor, Lights* lights, GlobalContext* globalCtx); -void ActorShadow_DrawSquare(Actor* actor, Lights* lights, GlobalContext* globalCtx); -void ActorShadow_DrawWhiteCircle(Actor* actor, Lights* lights, GlobalContext* globalCtx); -void ActorShadow_DrawHorse(Actor* actor, Lights* lights, GlobalContext* globalCtx); +void ActorShadow_DrawCircle(Actor* actor, Lights* lights, PlayState* play); +void ActorShadow_DrawSquare(Actor* actor, Lights* lights, PlayState* play); +void ActorShadow_DrawWhiteCircle(Actor* actor, Lights* lights, PlayState* play); +void ActorShadow_DrawHorse(Actor* actor, Lights* lights, PlayState* play); -void ActorShadow_DrawFeet(Actor* actor, Lights* mapper, GlobalContext* globalCtx); +void ActorShadow_DrawFeet(Actor* actor, Lights* mapper, PlayState* play); void Actor_SetFeetPos(Actor* actor, s32 limbIndex, s32 leftFootIndex, Vec3f* leftFootPos, s32 rightFootIndex, Vec3f* rightFootPos); -void func_800B4AEC(GlobalContext* globalCtx, Actor* actor, f32 y); -void func_800B4B50(Actor* actor, Lights* mapper, GlobalContext* globalCtx); -void Actor_GetProjectedPos(GlobalContext* globalCtx, Vec3f* arg1, Vec3f* arg2, f32* arg3); +void func_800B4AEC(PlayState* play, Actor* actor, f32 y); +void func_800B4B50(Actor* actor, Lights* mapper, PlayState* play); +void Actor_GetProjectedPos(PlayState* play, Vec3f* worldPos, Vec3f* projectedPos, f32* invW); -void Actor_DrawZTarget(TargetContext* targetCtx, GlobalContext* globalCtx); +void Actor_DrawZTarget(TargetContext* targetCtx, PlayState* play); -s32 Flags_GetSwitch(GlobalContext* globalCtx, s32 flag); -void Flags_SetSwitch(GlobalContext* globalCtx, s32 flag); -void Flags_UnsetSwitch(GlobalContext* globalCtx, s32 flag); -s32 Flags_GetTreasure(GlobalContext* globalCtx, s32 flag); -void Flags_SetTreasure(GlobalContext* globalCtx, s32 flag); -void Flags_SetAllTreasure(GlobalContext* globalCtx, s32 flag); -s32 Flags_GetAllTreasure(GlobalContext* globalCtx); -s32 Flags_GetClear(GlobalContext* globalCtx, s32 roomNumber); -void Flags_SetClear(GlobalContext* globalCtx, s32 roomNumber); -void Flags_UnsetClear(GlobalContext* globalCtx, s32 roomNumber); -s32 Flags_GetClearTemp(GlobalContext* globalCtx, s32 roomNumber); -void Flags_SetClearTemp(GlobalContext* globalCtx, s32 roomNumber); -void Flags_UnsetClearTemp(GlobalContext* globalCtx, s32 roomNumber); -s32 Flags_GetCollectible(GlobalContext* globalCtx, s32 flag); -void Flags_SetCollectible(GlobalContext* globalCtx, s32 flag); +s32 Flags_GetSwitch(PlayState* play, s32 flag); +void Flags_SetSwitch(PlayState* play, s32 flag); +void Flags_UnsetSwitch(PlayState* play, s32 flag); +s32 Flags_GetTreasure(PlayState* play, s32 flag); +void Flags_SetTreasure(PlayState* play, s32 flag); +void Flags_SetAllTreasure(PlayState* play, s32 flag); +s32 Flags_GetAllTreasure(PlayState* play); +s32 Flags_GetClear(PlayState* play, s32 roomNumber); +void Flags_SetClear(PlayState* play, s32 roomNumber); +void Flags_UnsetClear(PlayState* play, s32 roomNumber); +s32 Flags_GetClearTemp(PlayState* play, s32 roomNumber); +void Flags_SetClearTemp(PlayState* play, s32 roomNumber); +void Flags_UnsetClearTemp(PlayState* play, s32 roomNumber); +s32 Flags_GetCollectible(PlayState* play, s32 flag); +void Flags_SetCollectible(PlayState* play, s32 flag); void TitleCard_InitBossName(GameState* gameState, TitleCardContext* titleCtx, TexturePtr texture, s16 x, s16 y, u8 width, u8 height); -s32 func_800B648C(GlobalContext* globalCtx, s32 arg1, s32 arg2, f32 arg3, Vec3f* arg4); -f32 func_800B64FC(GlobalContext* globalCtx, f32 arg1, Vec3f* arg2, u32* arg3); -void* func_800B6584(GlobalContext* globalCtx, s16 id, void* arg2, size_t size); -void* func_800B6608(GlobalContext* globalCtx, s16 id); -void* func_800B6680(GlobalContext* globalCtx, s16 id); +s32 func_800B648C(PlayState* play, s32 arg1, s32 arg2, f32 arg3, Vec3f* arg4); +f32 func_800B64FC(PlayState* play, f32 arg1, Vec3f* arg2, u32* arg3); +void* func_800B6584(PlayState* play, s16 id, void* arg2, size_t size); +void* func_800B6608(PlayState* play, s16 id); +void* func_800B6680(PlayState* play, s16 id); void Actor_MarkForDeath(Actor* actor); void Actor_SetWorldToHome(Actor* actor); void Actor_SetFocus(Actor* actor, f32 height); void Actor_SetWorldRotToShape(Actor* actor); void Actor_SetShapeRotToWorld(Actor* actor); void Actor_SetScale(Actor* actor, f32 scale); -void Actor_SetObjectDependency(GlobalContext* globalCtx, Actor* actor); +void Actor_SetObjectDependency(PlayState* play, Actor* actor); void Actor_SetMovementScale(s32 scale); void Actor_UpdatePos(Actor* actor); void Actor_UpdateVelocityWithGravity(Actor* actor); @@ -669,19 +648,19 @@ f32 Actor_XZDistanceBetweenActors(Actor* actor1, Actor* actor2); f32 Actor_XZDistanceToPoint(Actor* actor, Vec3f* point); void Actor_OffsetOfPointInActorCoords(Actor* actor, Vec3f* offset, Vec3f* point); f32 Actor_HeightDiff(Actor* actor1, Actor* actor2); -void func_800B6F20(GlobalContext* globalCtx, Input* input, f32 arg2, s16 arg3); +void func_800B6F20(PlayState* play, Input* input, f32 arg2, s16 arg3); f32 Player_GetHeight(Player* player); f32 Player_GetRunSpeedLimit(Player* player); s32 func_800B7118(Player* player); s32 func_800B7128(Player* player); -s32 func_800B715C(GlobalContext* globalCtx); -void Actor_SetCameraHorseSetting(GlobalContext* globalCtx, Player* player); -void Actor_MountHorse(GlobalContext* globalCtx, Player* player, Actor* horse); -s32 func_800B724C(GlobalContext* globalCtx, Actor* actor, u8 csMode); -u32 func_800B7298(GlobalContext* globalCtx, Actor* actor, u8 csMode); +s32 func_800B715C(PlayState* play); +void Actor_SetCameraHorseSetting(PlayState* play, Player* player); +void Actor_MountHorse(PlayState* play, Player* player, Actor* horse); +s32 func_800B724C(PlayState* play, Actor* actor, u8 csMode); +u32 func_800B7298(PlayState* play, Actor* actor, u8 csMode); void func_800B72F8(DynaPolyActor* dyna, f32 extraPushForce, s16 yRotation); -s32 Player_IsFacingActor(Actor* actor, s16 maxAngleDiff, GlobalContext* globalCtx); +s32 Player_IsFacingActor(Actor* actor, s16 maxAngleDiff, PlayState* play); s32 Actor_ActorBIsFacingActorA(Actor* actorA, Actor* actorB, s16 maxAngleDiff); s32 Actor_IsFacingPlayer(Actor* actor, s16 angle); s32 Actor_ActorAIsFacingActorB(Actor* actorA, Actor* actorB, s16 maxAngleDiff); @@ -689,48 +668,48 @@ s32 Actor_IsFacingAndNearPlayer(Actor* actor, f32 range, s16 maxAngleDiff); s32 Actor_ActorAIsFacingAndNearActorB(Actor* actorA, Actor* actorB, f32 range, s16 maxAngleDiff); void func_800B75A0(CollisionPoly* poly, Vec3f* normal, s16* azimuth); -void Actor_UpdateBgCheckInfo(GlobalContext* globalCtx, Actor* actor, f32 wallCheckHeight, f32 wallCheckRadius, f32 ceilingCheckHeight, u32 flags); +void Actor_UpdateBgCheckInfo(PlayState* play, Actor* actor, f32 wallCheckHeight, f32 wallCheckRadius, f32 ceilingCheckHeight, u32 flags); Hilite* Hilite_DrawOpa(Vec3f* object, Vec3f* eye, Vec3f* lightDir, GraphicsContext* gfxCtx); -void func_800B8050(Actor* actor, GlobalContext* globalCtx, s32 flag); -void func_800B8118(Actor* actor, GlobalContext* globalCtx, s32 flag); +void func_800B8050(Actor* actor, PlayState* play, s32 flag); +void func_800B8118(Actor* actor, PlayState* play, s32 flag); PosRot* Actor_GetFocus(PosRot* dest, Actor* actor); PosRot* Actor_GetWorld(PosRot* dest, Actor* actor); PosRot* Actor_GetWorldPosShapeRot(PosRot* dest, Actor* actor); s32 func_800B83F8(Actor* actor, Player* player, s32 flag); s32 Actor_ProcessTalkRequest(Actor* actor, GameState* gameState); -s32 func_800B8500(Actor* actor, GlobalContext* globalCtx, f32 xzRange, f32 yRange, s32 exchangeItemId); -s32 func_800B85E0(Actor* actor, GlobalContext* globalCtx, f32 radius, s32 exchangeItemId); -s32 func_800B8614(Actor* actor, GlobalContext* globalCtx, f32 radius); -s32 func_800B863C(Actor* actor, GlobalContext* globalCtx); -s32 Actor_TextboxIsClosing(Actor* actor, GlobalContext* globalCtx); -s32 Actor_ChangeFocus(Actor* actor1, GlobalContext* globalCtx, Actor* actor2); -s32 Player_GetExchangeItemId(GlobalContext* globalCtx); +s32 func_800B8500(Actor* actor, PlayState* play, f32 xzRange, f32 yRange, PlayerActionParam exchangeItemId); +s32 func_800B85E0(Actor* actor, PlayState* play, f32 radius, PlayerActionParam exchangeItemId); +s32 func_800B8614(Actor* actor, PlayState* play, f32 radius); +s32 func_800B863C(Actor* actor, PlayState* play); +s32 Actor_TextboxIsClosing(Actor* actor, PlayState* play); +s32 Actor_ChangeFocus(Actor* actor1, PlayState* play, Actor* actor2); +s32 Player_GetExchangeItemId(PlayState* play); s32 func_800B8718(Actor* actor, GameState* gameState); -s32 func_800B874C(Actor* actor, GlobalContext* globalCtx, f32 xzRange, f32 yRange); -s32 func_800B8804(Actor* actor, GlobalContext* globalCtx, f32 xzRange); -s32 func_800B886C(Actor* actor, GlobalContext* globalCtx); -void Actor_GetScreenPos(GlobalContext* globalCtx, Actor* actor, s16* x, s16* y); -s32 func_800B8934(GlobalContext* globalCtx, Actor* actor); -s32 Actor_HasParent(Actor* actor, GlobalContext* globalCtx); -s32 Actor_PickUp(Actor* actor, GlobalContext* globalCtx, s32 getItemId, f32 xzRange, f32 yRange); -s32 Actor_PickUpNearby(Actor* actor, GlobalContext* globalCtx, s32 getItemId); -s32 Actor_LiftActor(Actor* actor, GlobalContext* globalCtx); -s32 Actor_PickUpFar(Actor* actor, GlobalContext* globalCtx, s32 getItemId); -s32 Actor_HasNoParent(Actor* actor, GlobalContext* globalCtx); -void func_800B8C20(Actor* actorA, Actor* actorB, GlobalContext* globalCtx); -void func_800B8C50(Actor* actor, GlobalContext* globalCtx); -s32 Actor_HasRider(GlobalContext* globalCtx, Actor* horse); -s32 Actor_SetRideActor(GlobalContext* globalCtx, Actor* horse, s32 mountSide); -s32 Actor_HasNoRider(GlobalContext* globalCtx, Actor* horse); -void func_800B8D10(GlobalContext* globalCtx, Actor* actor, f32 arg2, s16 arg3, f32 arg4, u32 arg5, u32 arg6); -void func_800B8D50(GlobalContext* globalCtx, Actor* actor, f32 arg2, s16 yaw, f32 arg4, u32 arg5); -void func_800B8D98(GlobalContext* globalCtx, Actor* actor, f32 arg2, s16 arg3, f32 arg4); -void func_800B8DD4(GlobalContext* globalCtx, Actor* actor, f32 arg2, s16 arg3, f32 arg4, u32 arg5); -void func_800B8E1C(GlobalContext* globalCtx, Actor* actor, f32 arg2, s16 arg3, f32 arg4); +s32 func_800B874C(Actor* actor, PlayState* play, f32 xzRange, f32 yRange); +s32 func_800B8804(Actor* actor, PlayState* play, f32 xzRange); +s32 func_800B886C(Actor* actor, PlayState* play); +void Actor_GetScreenPos(PlayState* play, Actor* actor, s16* x, s16* y); +s32 Actor_OnScreen(PlayState* play, Actor* actor); +s32 Actor_HasParent(Actor* actor, PlayState* play); +s32 Actor_PickUp(Actor* actor, PlayState* play, s32 getItemId, f32 xzRange, f32 yRange); +s32 Actor_PickUpNearby(Actor* actor, PlayState* play, s32 getItemId); +s32 Actor_LiftActor(Actor* actor, PlayState* play); +s32 Actor_PickUpFar(Actor* actor, PlayState* play, s32 getItemId); +s32 Actor_HasNoParent(Actor* actor, PlayState* play); +void func_800B8C20(Actor* actorA, Actor* actorB, PlayState* play); +void func_800B8C50(Actor* actor, PlayState* play); +s32 Actor_HasRider(PlayState* play, Actor* horse); +s32 Actor_SetRideActor(PlayState* play, Actor* horse, s32 mountSide); +s32 Actor_HasNoRider(PlayState* play, Actor* horse); +void func_800B8D10(PlayState* play, Actor* actor, f32 arg2, s16 arg3, f32 arg4, u32 arg5, u32 arg6); +void func_800B8D50(PlayState* play, Actor* actor, f32 arg2, s16 yaw, f32 arg4, u32 arg5); +void func_800B8D98(PlayState* play, Actor* actor, f32 arg2, s16 arg3, f32 arg4); +void func_800B8DD4(PlayState* play, Actor* actor, f32 arg2, s16 arg3, f32 arg4, u32 arg5); +void func_800B8E1C(PlayState* play, Actor* actor, f32 arg2, s16 arg3, f32 arg4); void func_800B8E58(Player* player, u16 sfxId); void Actor_PlaySfxAtPos(Actor* actor, u16 sfxId); -void func_800B8EF4(GlobalContext* globalCtx, Actor* actor); +void func_800B8EF4(PlayState* play, Actor* actor); void func_800B8F98(Actor* actor, u16 sfxId); void func_800B8FC0(Actor* actor, u16 sfxId); void func_800B8FE8(Actor* actor, u16 sfxId); @@ -738,54 +717,54 @@ void func_800B9010(Actor* actor, u16 sfxId); void func_800B9038(Actor* actor, s32 timer); void func_800B9084(Actor* actor); void func_800B9098(Actor* actor); -s32 func_800B90AC(GlobalContext* globalCtx, Actor* actor, CollisionPoly* polygon, s32 index, s32 arg4); -void func_800B90F4(GlobalContext* globalCtx); +s32 func_800B90AC(PlayState* play, Actor* actor, CollisionPoly* polygon, s32 index, s32 arg4); +void func_800B90F4(PlayState* play); void func_800B9120(ActorContext* actorCtx); -void Actor_InitContext(GlobalContext* globalCtx, ActorContext* actorCtx, ActorEntry* actorEntry); -void Actor_UpdateAll(GlobalContext* globalCtx, ActorContext* actorCtx); -s32 Actor_RecordUndrawnActor(GlobalContext* globalCtx, Actor* actor); -void Actor_DrawAll(GlobalContext* globalCtx, ActorContext* actorCtx); -void func_800BA6FC(GlobalContext* globalCtx, ActorContext* actorCtx); -void func_800BA798(GlobalContext* globalCtx, ActorContext* actorCtx); -void Actor_CleanupContext(ActorContext* actorCtx, GlobalContext* globalCtx); -Actor* Actor_Spawn(ActorContext* actorCtx, GlobalContext* globalCtx, s16 actorId, f32 posX, f32 posY, f32 posZ, s16 rotX, s16 rotY, s16 rotZ, s32 params); -Actor* Actor_SpawnAsChildAndCutscene(ActorContext* actorCtx, GlobalContext* globalCtx, s16 index, f32 x, f32 y, f32 z, s16 rotX, s16 rotY, s16 rotZ, s32 params, u32 cutscene, s32 arg11, Actor* parent); -Actor* Actor_SpawnAsChild(ActorContext* actorCtx, Actor* parent, GlobalContext* globalCtx, s16 actorId, f32 posX, f32 posY, f32 posZ, s16 rotX, s16 rotY, s16 rotZ, s32 params); -void Actor_SpawnTransitionActors(GlobalContext* globalCtx, ActorContext* actorCtx); -void Enemy_StartFinishingBlow(GlobalContext* globalCtx, Actor* actor); +void Actor_InitContext(PlayState* play, ActorContext* actorCtx, ActorEntry* actorEntry); +void Actor_UpdateAll(PlayState* play, ActorContext* actorCtx); +s32 Actor_RecordUndrawnActor(PlayState* play, Actor* actor); +void Actor_DrawAll(PlayState* play, ActorContext* actorCtx); +void func_800BA6FC(PlayState* play, ActorContext* actorCtx); +void func_800BA798(PlayState* play, ActorContext* actorCtx); +void Actor_CleanupContext(ActorContext* actorCtx, PlayState* play); +Actor* Actor_Spawn(ActorContext* actorCtx, PlayState* play, s16 actorId, f32 posX, f32 posY, f32 posZ, s16 rotX, s16 rotY, s16 rotZ, s32 params); +Actor* Actor_SpawnAsChildAndCutscene(ActorContext* actorCtx, PlayState* play, s16 index, f32 x, f32 y, f32 z, s16 rotX, s16 rotY, s16 rotZ, s32 params, u32 cutscene, s32 arg11, Actor* parent); +Actor* Actor_SpawnAsChild(ActorContext* actorCtx, Actor* parent, PlayState* play, s16 actorId, f32 posX, f32 posY, f32 posZ, s16 rotX, s16 rotY, s16 rotZ, s32 params); +void Actor_SpawnTransitionActors(PlayState* play, ActorContext* actorCtx); +void Enemy_StartFinishingBlow(PlayState* play, Actor* actor); s16 func_800BBAC0(s16 arg0[2], s16 arg1, s16 arg2, s16 arg3); s16 func_800BBB74(s16 arg0[2], s16 arg1, s16 arg2, s16 arg3); -void Actor_SpawnBodyParts(Actor* actor, GlobalContext* globalCtx, s32 arg2, Gfx** dList); -void Actor_SpawnFloorDustRing(GlobalContext* globalCtx, Actor* actor, Vec3f* posXZ, f32 radius, s32 countMinusOne, f32 randAccelWeight, s16 scale, s16 scaleStep, u8 useLighting); -void func_800BBFB0(GlobalContext* globalCtx, Vec3f* position, f32 arg2, s32 arg3, s16 arg4, s16 scaleStep, u8 arg6); -void func_800BC154(GlobalContext* globalCtx, ActorContext* actorCtx, Actor* actor, u8 actorCategory); +void Actor_SpawnBodyParts(Actor* actor, PlayState* play, s32 arg2, Gfx** dList); +void Actor_SpawnFloorDustRing(PlayState* play, Actor* actor, Vec3f* posXZ, f32 radius, s32 countMinusOne, f32 randAccelWeight, s16 scale, s16 scaleStep, u8 useLighting); +void func_800BBFB0(PlayState* play, Vec3f* position, f32 arg2, s32 arg3, s16 arg4, s16 scaleStep, u8 arg6); +void func_800BC154(PlayState* play, ActorContext* actorCtx, Actor* actor, u8 actorCategory); s32 func_800BC188(s32 index); -Actor* func_800BC270(GlobalContext* globalCtx, Actor* actor, f32 arg2, s32 arg3); -Actor* func_800BC444(GlobalContext* globalCtx, Actor* actor, f32 arg2); -s16 Actor_TestFloorInDirection(Actor* actor, GlobalContext* globalCtx, f32 distance, s16 angle); -s32 Actor_IsTargeted(GlobalContext* globalCtx, Actor* actor); -s32 Actor_OtherIsTargeted(GlobalContext* globalCtx, Actor* actor); -void func_800BC620(Vec3f* arg0, Vec3f* arg1, u8 alpha, GlobalContext* globalCtx); -void func_800BC770(GlobalContext* globalCtx, s16 y, s16 countdown); -void func_800BC7D8(GlobalContext* globalCtx, s16 y, s16 countdown, s16 speed); -void func_800BC848(Actor* actor, GlobalContext* globalCtx, s16 y, s16 countdown); -void Actor_DrawDoorLock(GlobalContext* globalCtx, s32 frame, s32 type); +Actor* func_800BC270(PlayState* play, Actor* actor, f32 arg2, s32 arg3); +Actor* func_800BC444(PlayState* play, Actor* actor, f32 arg2); +s16 Actor_TestFloorInDirection(Actor* actor, PlayState* play, f32 distance, s16 angle); +s32 Actor_IsTargeted(PlayState* play, Actor* actor); +s32 Actor_OtherIsTargeted(PlayState* play, Actor* actor); +void func_800BC620(Vec3f* arg0, Vec3f* arg1, u8 alpha, PlayState* play); +void func_800BC770(PlayState* play, s16 y, s16 countdown); +void func_800BC7D8(PlayState* play, s16 y, s16 countdown, s16 speed); +void func_800BC848(Actor* actor, PlayState* play, s16 y, s16 countdown); +void Actor_DrawDoorLock(PlayState* play, s32 frame, s32 type); void Actor_SetColorFilter(Actor* actor, u16 colorFlag, u16 colorIntensityMax, u16 xluFlag, u16 duration); -Hilite* func_800BCBF4(Vec3f* arg0, GlobalContext* globalCtx); -Hilite* func_800BCC68(Vec3f* arg0, GlobalContext* globalCtx); +Hilite* func_800BCBF4(Vec3f* arg0, PlayState* play); +Hilite* func_800BCC68(Vec3f* arg0, PlayState* play); void Actor_GetClosestPosOnPath(Vec3s* points, s32 numPoints, Vec3f* srcPos, Vec3f* dstPos, s32 isPathLoop); -s32 func_800BD2B4(GlobalContext* globalCtx, Actor* actor, s16* arg2, f32 arg3, u16 (*textIdCallback)(GlobalContext*, Actor*), s16 (*arg5)(GlobalContext*, Actor*)); +s32 func_800BD2B4(PlayState* play, Actor* actor, s16* arg2, f32 arg3, u16 (*textIdCallback)(PlayState*, Actor*), s16 (*arg5)(PlayState*, Actor*)); void func_800BD888(Actor* actor, struct_800BD888_arg1* arg1, s16 arg2, s16 arg3); -void func_800BD9E0(GlobalContext* globalCtx, SkelAnime* skelAnime, OverrideLimbDraw overrideLimbDraw, PostLimbDraw postLimbDraw, Actor* actor, s16 alpha); -void func_800BDAA0(GlobalContext* globalCtx, SkelAnime* skelAnime, OverrideLimbDraw overrideLimbDraw, PostLimbDraw postLimbDraw, Actor* actor, s16 alpha); -void Actor_ChangeAnimationByInfo(SkelAnime* skelAnime, AnimationInfo* animation, s32 index); -void Actor_Noop(Actor* actor, GlobalContext* globalCtx); +void func_800BD9E0(PlayState* play, SkelAnime* skelAnime, OverrideLimbDraw overrideLimbDraw, PostLimbDraw postLimbDraw, Actor* actor, s16 alpha); +void func_800BDAA0(PlayState* play, SkelAnime* skelAnime, OverrideLimbDraw overrideLimbDraw, PostLimbDraw postLimbDraw, Actor* actor, s16 alpha); +void Actor_ChangeAnimationByInfo(SkelAnime* skelAnime, AnimationInfo* animationInfo, s32 animIndex); +void Actor_Noop(Actor* actor, PlayState* play); -void Gfx_DrawDListOpa(GlobalContext* globalCtx, Gfx* dlist); -void Gfx_DrawDListXlu(GlobalContext* globalCtx, Gfx* dlist); +void Gfx_DrawDListOpa(PlayState* play, Gfx* dlist); +void Gfx_DrawDListXlu(PlayState* play, Gfx* dlist); -Actor* Actor_FindNearby(GlobalContext* globalCtx, Actor* inActor, s16 actorId, u8 actorCategory, f32 distance); -s32 func_800BE184(GlobalContext* globalCtx, Actor* actor, f32 xzDist, s16 arg3, s16 arg4, s16 arg5); +Actor* Actor_FindNearby(PlayState* play, Actor* inActor, s16 actorId, u8 actorCategory, f32 distance); +s32 func_800BE184(PlayState* play, Actor* actor, f32 xzDist, s16 arg3, s16 arg4, s16 arg5); u8 Actor_ApplyDamage(Actor* actor); void Actor_SetDropFlag(Actor* actor, ColliderInfo* colInfo); void Actor_SetDropFlagJntSph(Actor* actor, ColliderJntSph* jntSphere); @@ -794,9 +773,9 @@ void func_800BE3D0(Actor* actor, s16 angle, Vec3s* arg2); void func_800BE504(Actor* actor, ColliderCylinder* collider); void func_800BE568(Actor* actor, ColliderSphere* collider); void func_800BE5CC(Actor* actor, ColliderJntSph* collider, s32 colliderIndex); -s32 func_800BE63C(struct EnBox* chest); -void Actor_DrawDamageEffects(GlobalContext* globalCtx, Actor* actor, Vec3f limbPos[], s16 limbPosCount, f32 effectScale, f32 frozenSteamScale, f32 effectAlpha, u8 type); -void Actor_SpawnIceEffects(GlobalContext* globalCtx, Actor* actor, Vec3f limbPos[], s32 limbPosCount, s32 effectsPerLimb, f32 scale, f32 scaleRange); +s32 Actor_IsSmallChest(struct EnBox* chest); +void Actor_DrawDamageEffects(PlayState* play, Actor* actor, Vec3f limbPos[], s16 limbPosCount, f32 effectScale, f32 frozenSteamScale, f32 effectAlpha, u8 type); +void Actor_SpawnIceEffects(PlayState* play, Actor* actor, Vec3f limbPos[], s32 limbPosCount, s32 effectsPerLimb, f32 scale, f32 scaleRange); void ActorOverlayTable_FaultPrint(void* arg0, void* arg1); void* ActorOverlayTable_FaultAddrConv(void* arg0, void* arg1); @@ -807,8 +786,8 @@ void SSNode_SetValue(SSNode* node, s16* polyIndex, u16 next); void SSList_SetNull(SSList* head); void SSNodeList_SetSSListHead(SSNodeList* list, SSList* ssList, s16* polyIndex); void DynaSSNodeList_SetSSListHead(DynaSSNodeList* list, SSList* ssList, s16* polyIndex); -void DynaSSNodeList_Init(GlobalContext* globalCtx, DynaSSNodeList* list); -void DynaSSNodeList_Alloc(GlobalContext* globalCtx, DynaSSNodeList* list, u32 numNodes); +void DynaSSNodeList_Init(PlayState* play, DynaSSNodeList* list); +void DynaSSNodeList_Alloc(PlayState* play, DynaSSNodeList* list, u32 numNodes); void DynaSSNodeList_ResetCount(DynaSSNodeList* list); u16 DynaSSNodeList_GetNextNodeIdx(DynaSSNodeList* list); void BgCheck_Vec3sToVec3f(Vec3s* vertex, Vec3f* vector); @@ -827,24 +806,24 @@ void BgCheck_GetSubdivisionMinBounds(CollisionContext* colCtx, Vec3f* pos, s32* void BgCheck_GetSubdivisionMaxBounds(CollisionContext* colCtx, Vec3f* pos, s32* sx, s32* sy, s32* sz); void BgCheck_GetPolySubdivisionBounds(CollisionContext* colCtx, Vec3s* vtxList, CollisionPoly* polyList, s32* subdivMinX, s32* subdivMinY, s32* subdivMinZ, s32* subdivMaxX, s32* subdivMaxY, s32* subdivMaxZ, s16 polyId); s32 BgCheck_PolyIntersectsSubdivision(Vec3f* min, Vec3f* max, CollisionPoly* polyList, Vec3s* vtxList, s16 polyId); -u32 BgCheck_InitStaticLookup(CollisionContext* colCtx, GlobalContext* globalCtx, StaticLookup* lookupTbl); -s32 BgCheck_IsSmallMemScene(GlobalContext* globalCtx); +u32 BgCheck_InitStaticLookup(CollisionContext* colCtx, PlayState* play, StaticLookup* lookupTbl); +s32 BgCheck_IsSmallMemScene(PlayState* play); s32 BgCheck_TryGetCustomMemsize(s32 sceneId, u32* memSize); void BgCheck_SetSubdivisionDimension(f32 min, s32 subdivAmount, f32* max, f32* subdivLength, f32* subdivLengthInv); -s32 BgCheck_GetSpecialSceneMaxObjects(GlobalContext* globalCtx, s32* maxNodes, s32* maxPolygons, s32* maxVertices); -void BgCheck_Allocate(CollisionContext* colCtx, GlobalContext* globalCtx, CollisionHeader* colHeader); +s32 BgCheck_GetSpecialSceneMaxObjects(PlayState* play, s32* maxNodes, s32* maxPolygons, s32* maxVertices); +void BgCheck_Allocate(CollisionContext* colCtx, PlayState* play, CollisionHeader* colHeader); void BgCheck_SetContextFlags(CollisionContext* colCtx, u32 flags); void BgCheck_UnsetContextFlags(CollisionContext* colCtx, u32 flags); CollisionHeader* BgCheck_GetCollisionHeader(CollisionContext* colCtx, s32 bgId); -f32 BgCheck_RaycastFloorImpl(GlobalContext* globalCtx, CollisionContext* colCtx, u16 xpFlags, CollisionPoly** outPoly, s32* outBgId, Vec3f* pos, Actor* actor, u32 arg7, f32 chkDist, s32 arg9); +f32 BgCheck_RaycastFloorImpl(PlayState* play, CollisionContext* colCtx, u16 xpFlags, CollisionPoly** outPoly, s32* outBgId, Vec3f* pos, Actor* actor, u32 arg7, f32 chkDist, s32 arg9); f32 BgCheck_CameraRaycastFloor1(CollisionContext* colCtx, CollisionPoly** outPoly, Vec3f* pos); f32 BgCheck_EntityRaycastFloor1(CollisionContext* colCtx, CollisionPoly** outPoly, Vec3f* pos); -f32 BgCheck_EntityRaycastFloor2(GlobalContext* globalCtx, CollisionContext* colCtx, CollisionPoly** outPoly, Vec3f* pos); -f32 BgCheck_EntityRaycastFloor2_1(GlobalContext* globalCtx, CollisionContext* colCtx, CollisionPoly** outPoly, Vec3f* pos); +f32 BgCheck_EntityRaycastFloor2(PlayState* play, CollisionContext* colCtx, CollisionPoly** outPoly, Vec3f* pos); +f32 BgCheck_EntityRaycastFloor2_1(PlayState* play, CollisionContext* colCtx, CollisionPoly** outPoly, Vec3f* pos); f32 BgCheck_EntityRaycastFloor3(CollisionContext* colCtx, CollisionPoly** outPoly, s32* bgId, Vec3f* pos); f32 BgCheck_EntityRaycastFloor5(CollisionContext* colCtx, CollisionPoly** outPoly, s32* outBgId, Actor* actor, Vec3f* pos); -f32 BgCheck_EntityRaycastFloor5_2(GlobalContext* globalCtx, CollisionContext* colCtx, CollisionPoly** outPoly, s32* bgId, Actor* actor, Vec3f* pos); -f32 BgCheck_EntityRaycastFloor5_3(GlobalContext* globalCtx, CollisionContext* colCtx, CollisionPoly** outPoly, s32* bgId, Actor* actor, Vec3f* pos); +f32 BgCheck_EntityRaycastFloor5_2(PlayState* play, CollisionContext* colCtx, CollisionPoly** outPoly, s32* bgId, Actor* actor, Vec3f* pos); +f32 BgCheck_EntityRaycastFloor5_3(PlayState* play, CollisionContext* colCtx, CollisionPoly** outPoly, s32* bgId, Actor* actor, Vec3f* pos); f32 BgCheck_EntityRaycastFloor6(CollisionContext* colCtx, CollisionPoly** outPoly, s32* bgId, Actor* actor, Vec3f* pos, f32 chkDist); f32 BgCheck_EntityRaycastFloor7(CollisionContext* colCtx, CollisionPoly** outPoly, s32* bgId, Actor* actor, Vec3f* pos); f32 BgCheck_AnyRaycastFloor1(CollisionContext* colCtx, CollisionPoly* outPoly, Vec3f* pos); @@ -873,7 +852,7 @@ s32 BgCheck_SphVsFirstPolyImpl(CollisionContext* colCtx, u16 xpFlags, CollisionP s32 BgCheck_SphVsFirstPoly(CollisionContext* colCtx, Vec3f* center, f32 radius); s32 BgCheck_SphVsFirstWall(CollisionContext* colCtx, Vec3f* center, f32 radius); void SSNodeList_Init(SSNodeList* this); -void SSNodeList_Alloc(GlobalContext* globalCtx, SSNodeList* this, s32 tblMax, s32 numPolys); +void SSNodeList_Alloc(PlayState* play, SSNodeList* this, s32 tblMax, s32 numPolys); SSNode* SSNodeList_GetNextNode(SSNodeList* this); u16 SSNodeList_GetNextNodeIdx(SSNodeList* this); void ScaleRotPos_Init(ScaleRotPos* srp); @@ -883,42 +862,46 @@ void DynaLookup_ResetLists(DynaLookup* dynaLookup); void DynaLookup_Reset(DynaLookup* dynaLookup); void DynaLookup_ResetVtxStartIndex(u16* vtxStartIndex); void DynaLookup_ResetWaterBoxStartIndex(u16* waterBoxStartIndex); -void BgActor_Init(GlobalContext* globalCtx, BgActor* bgActor); +void BgActor_Init(PlayState* play, BgActor* bgActor); void BgActor_SetActor(BgActor* bgActor, Actor* actor, CollisionHeader* colHeader); s32 BgActor_IsTransformUnchanged(BgActor* bgActor); void DynaPoly_NullPolyList(CollisionPoly** polyList); -void DynaPoly_AllocPolyList(GlobalContext* globalCtx, CollisionPoly** polyList, s32 numPolys); +void DynaPoly_AllocPolyList(PlayState* play, CollisionPoly** polyList, s32 numPolys); void DynaPoly_NullVtxList(Vec3s** vtxList); -void DynaPoly_AllocVtxList(GlobalContext* globalCtx, Vec3s** vtxList, s32 numVtx); +void DynaPoly_AllocVtxList(PlayState* play, Vec3s** vtxList, s32 numVtx); void DynaPoly_InitWaterBoxList(DynaWaterBoxList* waterBoxList); -void DynaPoly_AllocWaterBoxList(GlobalContext* globalCtx, DynaWaterBoxList* waterBoxList, s32 numWaterBoxes); -void DynaPoly_SetBgActorPrevTransform(GlobalContext* globalCtx, BgActor* bgActor); +void DynaPoly_AllocWaterBoxList(PlayState* play, DynaWaterBoxList* waterBoxList, s32 numWaterBoxes); +void DynaPoly_SetBgActorPrevTransform(PlayState* play, BgActor* bgActor); s32 DynaPoly_IsBgIdBgActor(s32 bgId); -void DynaPoly_Init(GlobalContext* globalCtx, DynaCollisionContext* dyna); -void DynaPoly_Alloc(GlobalContext* globalCtx, DynaCollisionContext* dyna); -s32 DynaPoly_SetBgActor(GlobalContext* globalCtx, DynaCollisionContext* dyna, Actor* actor, CollisionHeader* colHeader); +void DynaPoly_Init(PlayState* play, DynaCollisionContext* dyna); +void DynaPoly_Alloc(PlayState* play, DynaCollisionContext* dyna); +s32 DynaPoly_SetBgActor(PlayState* play, DynaCollisionContext* dyna, Actor* actor, CollisionHeader* colHeader); DynaPolyActor* DynaPoly_GetActor(CollisionContext* colCtx, s32 bgId); -void func_800C62BC(GlobalContext* globalCtx, DynaCollisionContext* dyna, s32 bgId); -void func_800C6314(GlobalContext* globalCtx, DynaCollisionContext* dyna, s32 bgId); -void func_800C636C(GlobalContext* globalCtx, DynaCollisionContext* dyna, s32 bgId); -void func_800C63C4(GlobalContext* globalCtx, DynaCollisionContext* dyna, s32 bgId); -void func_800C641C(GlobalContext* globalCtx, DynaCollisionContext* dyna, s32 bgId); -void func_800C6474(GlobalContext* globalCtx, DynaCollisionContext* dyna, s32 bgId); -void DynaPoly_DeleteBgActor(GlobalContext* globalCtx, DynaCollisionContext* dyna, s32 bgId); +void func_800C62BC(PlayState* play, DynaCollisionContext* dyna, s32 bgId); +void func_800C6314(PlayState* play, DynaCollisionContext* dyna, s32 bgId); +void func_800C636C(PlayState* play, DynaCollisionContext* dyna, s32 bgId); +void func_800C63C4(PlayState* play, DynaCollisionContext* dyna, s32 bgId); +void func_800C641C(PlayState* play, DynaCollisionContext* dyna, s32 bgId); +void func_800C6474(PlayState* play, DynaCollisionContext* dyna, s32 bgId); +void DynaPoly_DeleteBgActor(PlayState* play, DynaCollisionContext* dyna, s32 bgId); void BgCheck_CalcWaterboxDimensions(Vec3f* minPos, Vec3f* maxXPos, Vec3f* maxZPos, Vec3s* minPosOut, s16* xLength, s16* zLength); -void DynaPoly_ExpandSRT(GlobalContext* globalCtx, DynaCollisionContext* dyna, s32 bgId, s32* vtxStartIndex, s32* polyStartIndex, s32* waterBoxStartIndex); -void BgCheck_ResetFlagsIfLoadedActor(GlobalContext* globalCtx, DynaCollisionContext* dyna, Actor* actor); -void DynaPoly_Setup(GlobalContext* globalCtx, DynaCollisionContext* dyna); +void DynaPoly_ExpandSRT(PlayState* play, DynaCollisionContext* dyna, s32 bgId, s32* vtxStartIndex, s32* polyStartIndex, s32* waterBoxStartIndex); +void BgCheck_ResetFlagsIfLoadedActor(PlayState* play, DynaCollisionContext* dyna, Actor* actor); +void DynaPoly_Setup(PlayState* play, DynaCollisionContext* dyna); void func_800C756C(DynaCollisionContext* dyna, s32* numPolygons, s32* numVertices, s32* numWaterBoxes); -void DynaPoly_UpdateBgActorTransforms(GlobalContext* globalCtx, DynaCollisionContext* dyna); +void DynaPoly_UpdateBgActorTransforms(PlayState* play, DynaCollisionContext* dyna); void CollisionHeader_SegmentedToVirtual(CollisionHeader* header); void CollisionHeader_GetVirtual(CollisionHeader* meshSegPtr, CollisionHeader** param_2); -void BgCheck_InitCollisionHeaders(CollisionContext* colCtx, GlobalContext* globalCtx); -u32 SurfaceType_GetData(CollisionContext* colCtx, CollisionPoly* poly, s32 bgId, s32 dataIdx); -u32 SurfaceType_GetCamDataIndex(CollisionContext* colCtx, CollisionPoly* poly, s32 bgId); -u16 SurfaceType_GetCameraSType(CollisionContext* colCtx, CollisionPoly* poly, s32 bgId); -u16 SurfaceType_GetNumCameras(CollisionContext* colCtx, CollisionPoly* poly, s32 bgId); -Vec3s* SurfaceType_GetCamPosData(CollisionContext* colCtx, CollisionPoly* poly, s32 bgId); +void BgCheck_InitCollisionHeaders(CollisionContext* colCtx, PlayState* play); + +u32 SurfaceType_GetBgCamIndex(CollisionContext* colCtx, CollisionPoly* poly, s32 bgId); +u16 BgCheck_GetBgCamSettingImpl(CollisionContext* colCtx, u32 bgCamIndex, s32 bgId); +u16 BgCheck_GetBgCamSetting(CollisionContext* colCtx, CollisionPoly* poly, s32 bgId); +u16 BgCheck_GetBgCamCountImpl(CollisionContext* colCtx, u32 bgCamIndex, s32 bgId); +u16 BgCheck_GetBgCamCount(CollisionContext* colCtx, CollisionPoly* poly, s32 bgId); +Vec3s* BgCheck_GetBgCamFuncDataImpl(CollisionContext* colCtx, s32 bgCamIndex, s32 bgId); +Vec3s* BgCheck_GetBgCamFuncData(CollisionContext* colCtx, CollisionPoly* poly, s32 bgId); + u32 SurfaceType_GetSceneExitIndex(CollisionContext* colCtx, CollisionPoly* poly, s32 bgId); u32 func_800C99D4(CollisionContext* colCtx, CollisionPoly* poly, s32 bgId); u32 func_800C99FC(CollisionContext* colCtx, CollisionPoly* poly, s32 bgId); @@ -945,23 +928,23 @@ s32 func_800C9DDC(CollisionContext* colCtx, CollisionPoly* poly, s32 bgId); u32 SurfaceType_GetConveyorSpeed(CollisionContext* colCtx, CollisionPoly* poly, s32 bgId); u32 SurfaceType_GetConveyorDirection(CollisionContext* colCtx, CollisionPoly* poly, s32 bgId); u32 SurfaceType_IsWallDamage(CollisionContext* colCtx, CollisionPoly* poly, s32 bgId); -s32 WaterBox_GetSurfaceImpl(GlobalContext* globalCtx, CollisionContext* colCtx, f32 x, f32 z, f32* ySurface, WaterBox** outWaterBox, s32* bgId); -s32 WaterBox_GetSurface1(GlobalContext* globalCtx, CollisionContext* colCtx, f32 x, f32 z, f32* ySurface, WaterBox** outWaterBox); -s32 WaterBox_GetSurface1_2(GlobalContext* globalCtx, CollisionContext* colCtx, f32 x, f32 z, f32* ySurface, WaterBox** outWaterBox); -s32 WaterBox_GetSurface2(GlobalContext* globalCtx, CollisionContext* colCtx, Vec3f* pos, f32 surfaceChkDist, WaterBox** outWaterBox, s32* bgId); +s32 WaterBox_GetSurfaceImpl(PlayState* play, CollisionContext* colCtx, f32 x, f32 z, f32* ySurface, WaterBox** outWaterBox, s32* bgId); +s32 WaterBox_GetSurface1(PlayState* play, CollisionContext* colCtx, f32 x, f32 z, f32* ySurface, WaterBox** outWaterBox); +s32 WaterBox_GetSurface1_2(PlayState* play, CollisionContext* colCtx, f32 x, f32 z, f32* ySurface, WaterBox** outWaterBox); +s32 WaterBox_GetSurface2(PlayState* play, CollisionContext* colCtx, Vec3f* pos, f32 surfaceChkDist, WaterBox** outWaterBox, s32* bgId); f32 func_800CA568(CollisionContext* colCtx, s32 waterBoxId, s32 bgId); -u16 WaterBox_GetCameraSType(CollisionContext* colCtx, WaterBox* waterBox, s32 bgId); -void func_800CA6B8(CollisionContext* colCtx, WaterBox* waterBox); +u16 WaterBox_GetBgCamSetting(CollisionContext* colCtx, WaterBox* waterBox, s32 bgId); +void WaterBox_GetSceneBgCamSetting(CollisionContext* colCtx, WaterBox* waterBox); u32 WaterBox_GetLightSettingIndex(CollisionContext* colCtx, WaterBox* waterBox); -s32 func_800CA6F0(GlobalContext* globalCtx, CollisionContext* colCtx, f32 x, f32 z, f32* ySurface, WaterBox** outWaterBox, s32* bgId); -s32 func_800CA9D0(GlobalContext* globalCtx, CollisionContext* colCtx, f32 x, f32 z, f32* ySurface, WaterBox** outWaterBox); +s32 func_800CA6F0(PlayState* play, CollisionContext* colCtx, f32 x, f32 z, f32* ySurface, WaterBox** outWaterBox, s32* bgId); +s32 func_800CA9D0(PlayState* play, CollisionContext* colCtx, f32 x, f32 z, f32* ySurface, WaterBox** outWaterBox); s32 func_800CAA14(CollisionPoly* polyA, CollisionPoly* polyB, Vec3f* pointA, Vec3f* pointB, Vec3f* closestPoint); void BgCheck2_UpdateActorPosition(CollisionContext* colCtx, s32 index, Actor* actor); void BgCheck2_UpdateActorYRotation(CollisionContext* colCtx, s32 index, Actor* actor); void BgCheck2_AttachToMesh(CollisionContext* colCtx, Actor* actor, s32 index); u32 BgCheck2_UpdateActorAttachedToMesh(CollisionContext* colCtx, s32 index, Actor* actor); void DynaPolyActor_Init(DynaPolyActor* dynaActor, s32 flags); -void DynaPolyActor_LoadMesh(GlobalContext* globalCtx, DynaPolyActor* dynaActor, CollisionHeader* meshHeader); +void DynaPolyActor_LoadMesh(PlayState* play, DynaPolyActor* dynaActor, CollisionHeader* meshHeader); void DynaPolyActor_ResetState(DynaPolyActor* dynaActor); void DynaPolyActor_SetRidingFallingState(DynaPolyActor* dynaActor); void DynaPolyActor_SetRidingMovingState(DynaPolyActor* dynaActor); @@ -975,40 +958,8 @@ s32 DynaPolyActor_IsInRidingMovingState(DynaPolyActor* dynaActor); s32 DynaPolyActor_IsInRidingRotatingState(DynaPolyActor* dynaActor); s32 DynaPolyActor_IsInSwitchPressedState(DynaPolyActor* dynaActor); s32 DynaPolyActor_IsInHeavySwitchPressedState(DynaPolyActor* dynaActor); -s32 DynaPolyActor_ValidateMove(GlobalContext* globalCtx, DynaPolyActor* dynaActor, s16 startRadius, s16 endRadius, s16 startHeight); -f32 Camera_fabsf(f32 f); -f32 Camera_LengthVec3f(Vec3f* v); -// void func_800CB270(void); -f32 Camera_Lerpf(f32 b, f32 a, f32 t, f32 minDist); -s16 Camera_Lerps(s16 b, s16 a, f32 t, s16 minDist); -// void func_800CB42C(void); -void Camera_LerpVec3f(Vec3f* b, Vec3f* a, f32 tXZ, f32 tY, f32 minDist); -void func_800CB544(Camera* camera); -// void func_800CB584(void); -// void func_800CB5DC(void); -// void func_800CB60C(void); -// void func_800CB674(void); -// void func_800CB6C8(void); -f32 func_800CB700(Camera* camera); -// void func_800CB780(void); -// void func_800CB7CC(void); -// void func_800CB7F8(void); -// void func_800CB828(void); -// void func_800CB854(void); -// void func_800CB880(void); -// void func_800CB8C8(void); -// void func_800CB8F4(void); -// void func_800CB924(void); -// void func_800CB950(void); -// void func_800CBA08(void); -// void func_800CBA34(void); -// void func_800CBA7C(void); -// void func_800CBAAC(void); -// void func_800CBAD4(void); -// void func_800CBB58(void); -// void func_800CBB88(void); -// void func_800CBC00(void); -// void func_800CBC30(void); +s32 DynaPolyActor_ValidateMove(PlayState* play, DynaPolyActor* dynaActor, s16 startRadius, s16 endRadius, s16 startHeight); + // void func_800CBC84(void); // void func_800CBFA4(void); // void func_800CC000(void); @@ -1018,10 +969,10 @@ f32 func_800CB700(Camera* camera); // void func_800CC488(void); // void func_800CC56C(void); // void func_800CC5C8(void); -// void func_800CC740(void); -// void func_800CC7A8(void); -// void func_800CC804(void); -// void func_800CC874(void); +// void Camera_GetBgCamOrActorCsCamSetting(void); +// void Camera_GetBgCamOrActorCsCamFuncData(void); +// void Camera_GetBgCamIndex(void); +// void Camera_GetWaterBoxBgCamSetting(void); // void func_800CC938(void); // void func_800CC958(void); // void func_800CC9C0(void); @@ -1118,12 +1069,12 @@ s32 Camera_ModeSPEC6(Camera* camera); s32 Camera_ModeSPEC7(Camera* camera); s32 Camera_ModeSPEC8(Camera* camera); s32 Camera_ModeSPEC9(Camera* camera); -Camera* Camera_Alloc(View* view, CollisionContext* bg, GlobalContext* globalCtx); +Camera* Camera_Alloc(View* view, CollisionContext* bg, PlayState* play); void Camera_Free(Camera* camera); -void Camera_Init(Camera* camera, View* view, CollisionContext* bg, GlobalContext* globalCtx); +void Camera_Init(Camera* camera, View* view, CollisionContext* bg, PlayState* play); // void func_800DDFE0(void); -void func_800DE0EC(Camera* camera, Actor* actor); -// s32 func_800DE308(Camera* camera, UNK_TYPE2 uParm2); +void Camera_InitPlayerSettings(Camera* camera, Player* player); +s32 Camera_ChangeStatus(Camera* camera, s16 status); // void func_800DE324(void); // void func_800DE62C(void); // void func_800DE840(void); @@ -1135,24 +1086,24 @@ u32 Camera_SetMode(Camera* camera, s16 mode, s8 param_3); s32 Camera_ChangeMode(Camera* camera, s16 mode); // void func_800DF86C(void); // void func_800DF8EC(void); -s32 func_800DFAC8(Camera* camera, s16 param_2); +s32 Camera_ChangeSetting(Camera* camera, s16 setting); u32 Camera_ChangeDataIdx(Camera* camera, u32 camDataIdx); // void func_800DFC1C(void); // void func_800DFC40(void); s32 Camera_GetInputDirYaw(Camera* camera); -void func_800DFC90(Vec3s* arg0, Camera* camera); +void Camera_GetCamDir(Vec3s* dst, Camera* camera); s16 Camera_GetCamDirPitch(Camera* camera); s16 Camera_GetCamDirYaw(Camera* camera); -void func_800DFD04(Camera* camera, s32 arg1, s32 arg2, s32 arg3); -// void func_800DFD78(void); +void Camera_AddQuake(Camera* camera, s32 arg1, s16 y, s32 countdown); +s32 Camera_SetViewParam(Camera* camera, s32 viewFlag, void* param); // UNK_TYPE4 func_800DFEF0(s32 param_1, u16 param_2); // UNK_TYPE4 func_800DFF18(Camera* iParm1, UNK_TYPE2 uParm2); // UNK_TYPE4 func_800DFF34(s32 param_1); // UNK_TYPE4 func_800DFF44(void); s16 Camera_SetFlags(Camera* iParm1, s16 flags); s16 Camera_ClearFlags(Camera* camera, s16 flags); -s32 func_800DFFAC(Camera* camera, Actor* doorActor, s16 bgCamDataId, f32 arg3, s16 timer1, s16 timer2, s16 timer3); -// UNK_TYPE4 func_800E007C(Camera* param_1, Camera* param_2); +s32 Camera_ChangeDoorCam(Camera* camera, Actor* doorActor, s16 bgCamDataId, f32 arg3, s16 timer1, s16 timer2, s16 timer3); +s32 Camera_Copy(Camera* dstCamera, Camera* srcCamera); // UNK_TYPE4 func_800E01AC(void); Vec3f* Camera_GetQuakeOffset(Vec3f* dst, Camera* camera); // void func_800E01DC(s32 param_1, u32 param_2, UNK_TYPE4 param_3, UNK_TYPE4 param_4, UNK_TYPE2 param_5, UNK_TYPE2 param_6); @@ -1167,221 +1118,221 @@ void DamageTable_Clear(DamageTable* damageTable); f32 CollisionCheck_GetDamageAndEffectOnBumper(Collider* at, ColliderInfo* atInfo, Collider* ac, ColliderInfo* acInfo, u32* effect); f32 CollisionCheck_ApplyBumperDefense(f32 damage, ColliderInfo* ac); s32 CollisionCheck_GetToucherDamage(Collider* at, ColliderInfo* atInfo, Collider* ac, ColliderInfo* acInfo); -s32 Collider_InitBase(GlobalContext* globalCtx, Collider* collider); -s32 Collider_DestroyBase(GlobalContext* globalCtx, Collider* collider); -s32 Collider_SetBaseToActor(GlobalContext* globalCtx, Collider* collider, ColliderInitToActor* src); -s32 Collider_SetBaseType1(GlobalContext* globalCtx, Collider* collider, Actor* actor, ColliderInitType1* src); -s32 Collider_SetBase(GlobalContext* globalCtx, Collider* collider, Actor* actor, ColliderInit* src); -void Collider_ResetATBase(GlobalContext* globalCtx, Collider* collider); -void Collider_ResetACBase(GlobalContext* globalCtx, Collider* collider); -void Collider_ResetOCBase(GlobalContext* globalCtx, Collider* collider); -s32 Collider_InitTouch(GlobalContext* globalCtx, ColliderTouch* touch); -s32 Collider_DestroyTouch(GlobalContext* globalCtx, ColliderTouch* touch); -s32 Collider_SetTouch(GlobalContext* globalCtx, ColliderTouch* touch, ColliderTouchInit* src); -void Collider_ResetATInfoUnk(GlobalContext* globalCtx, ColliderInfo* info); -s32 Collider_InitBump(GlobalContext* globalCtx, ColliderBump* bump); -s32 Collider_DestroyBump(GlobalContext* globalCtx, ColliderBump* bump); -s32 Collider_SetBump(GlobalContext* globalCtx, ColliderBump* bump, ColliderBumpInit* src); -s32 Collider_InitInfo(GlobalContext* globalCtx, ColliderInfo* info); -s32 Collider_DestroyInfo(GlobalContext* globalCtx, ColliderInfo* info); -s32 Collider_SetInfo(GlobalContext* globalCtx, ColliderInfo* info, ColliderInfoInit* src); -void Collider_ResetATInfo(GlobalContext* globalCtx, ColliderInfo* info); -void Collider_ResetACInfo(GlobalContext* globalCtx, ColliderInfo* info); -void Collider_ResetOCInfo(GlobalContext* globalCtx, ColliderInfo* info); -s32 Collider_InitJntSphElementDim(GlobalContext* globalCtx, ColliderJntSphElementDim* dim); -s32 Collider_DestroyJntSphElementDim(GlobalContext* globalCtx, ColliderJntSphElementDim* dim); -s32 Collider_SetJntSphElementDim(GlobalContext* globalCtx, ColliderJntSphElementDim* dest, ColliderJntSphElementDimInit* src); -s32 Collider_InitJntSphElement(GlobalContext* globalCtx, ColliderJntSphElement* element); -s32 Collider_DestroyJntSphElement(GlobalContext* globalCtx, ColliderJntSphElement* element); -s32 Collider_SetJntSphElement(GlobalContext* globalCtx, ColliderJntSphElement* dest, ColliderJntSphElementInit* src); -s32 Collider_ResetJntSphElementAT(GlobalContext* globalCtx, ColliderJntSphElement* collider); -s32 Collider_ResetJntSphElementAC(GlobalContext* globalCtx, ColliderJntSphElement* collider); -s32 Collider_ResetJntSphElementOC(GlobalContext* globalCtx, ColliderJntSphElement* collider); -s32 Collider_InitJntSph(GlobalContext* globalCtx, ColliderJntSph* collider); -s32 Collider_FreeJntSph(GlobalContext* globalCtx, ColliderJntSph* collider); -s32 Collider_DestroyJntSph(GlobalContext* globalCtx, ColliderJntSph* collider); -s32 Collider_SetJntSphToActor(GlobalContext* globalCtx, ColliderJntSph* collider, ColliderJntSphInitToActor* src); -s32 Collider_SetJntSphAllocType1(GlobalContext* globalCtx, ColliderJntSph* sphereGroup, Actor* actor, ColliderJntSphInitType1* src); -s32 Collider_SetJntSph(GlobalContext* globalCtx, ColliderJntSph* sphereGroup, Actor* actor, ColliderJntSphInit* src, ColliderJntSphElement* elements); -s32 Collider_InitAndSetJntSph(GlobalContext* globalCtx, ColliderJntSph* sphereGroup, Actor* actor, ColliderJntSphInit* src, ColliderJntSphElement* elements); -s32 Collider_ResetJntSphAT(GlobalContext* globalCtx, Collider* collider); -s32 Collider_ResetJntSphAC(GlobalContext* globalCtx, Collider* collider); -s32 Collider_ResetJntSphOC(GlobalContext* globalCtx, Collider* collider); -s32 Collider_InitCylinderDim(GlobalContext* globalCtx, Cylinder16* dim); -s32 Collider_DestroyCylinderDim(GlobalContext* globalCtx, Cylinder16* dim); -s32 Collider_SetCylinderDim(GlobalContext* globalCtx, Cylinder16* dim, Cylinder16* src); -s32 Collider_InitCylinder(GlobalContext* globalCtx, ColliderCylinder* collider); -s32 Collider_DestroyCylinder(GlobalContext* globalCtx, ColliderCylinder* collider); -s32 Collider_SetCylinderToActor(GlobalContext* globalCtx, ColliderCylinder* collider, ColliderCylinderInitToActor* src); -s32 Collider_SetCylinderType1(GlobalContext* globalCtx, ColliderCylinder* collider, Actor* actor, ColliderCylinderInitType1* src); -s32 Collider_SetCylinder(GlobalContext* globalCtx, ColliderCylinder* collider, Actor* actor, ColliderCylinderInit* src); -s32 Collider_InitAndSetCylinder(GlobalContext* globalCtx, ColliderCylinder* collider, Actor* actor, ColliderCylinderInit* src); -s32 Collider_ResetCylinderAT(GlobalContext* globalCtx, Collider* collider); -s32 Collider_ResetCylinderAC(GlobalContext* globalCtx, Collider* collider); -s32 Collider_ResetCylinderOC(GlobalContext* globalCtx, Collider* collider); -s32 Collider_InitTrisElementDim(GlobalContext* globalCtx, TriNorm* dim); -s32 Collider_DestroyTrisElementDim(GlobalContext* globalCtx, TriNorm* dim); -s32 Collider_SetTrisElementDim(GlobalContext* globalCtx, TriNorm* dim, ColliderTrisElementDimInit* src); -s32 Collider_InitTrisElement(GlobalContext* globalCtx, ColliderTrisElement* element); -s32 Collider_DestroyTrisElement(GlobalContext* globalCtx, ColliderTrisElement* element); -s32 Collider_SetTrisElement(GlobalContext* globalCtx, ColliderTrisElement* element, ColliderTrisElementInit* src); -s32 Collider_ResetTrisElementAT(GlobalContext* globalCtx, ColliderTrisElement* element); -s32 Collider_ResetTrisElementAC(GlobalContext* globalCtx, ColliderTrisElement* element); -s32 Collider_ResetTrisElementOC(GlobalContext* globalCtx, ColliderTrisElement* element); -s32 Collider_InitTris(GlobalContext* globalCtx, ColliderTris* tris); -s32 Collider_FreeTris(GlobalContext* globalCtx, ColliderTris* tris); -s32 Collider_DestroyTris(GlobalContext* globalCtx, ColliderTris* tris); -s32 Collider_SetTrisAllocType1(GlobalContext* globalCtx, ColliderTris* tris, Actor* actor, ColliderTrisInitType1* src); -s32 Collider_SetTris(GlobalContext* globalCtx, ColliderTris* triGroup, Actor* actor, ColliderTrisInit* src, ColliderTrisElement* tris); -s32 Collider_InitAndSetTris(GlobalContext* globalCtx, ColliderTris* tris, Actor* actor, ColliderTrisInit* src, ColliderTrisElement* elements); -s32 Collider_ResetTrisAT(GlobalContext* globalCtx, Collider* collider); -s32 Collider_ResetTrisAC(GlobalContext* globalCtx, Collider* collider); -s32 Collider_ResetTrisOC(GlobalContext* globalCtx, Collider* collider); -s32 Collider_InitQuadDim(GlobalContext* globalCtx, ColliderQuadDim* dim); -s32 Collider_DestroyQuadDim(GlobalContext* globalCtx, ColliderQuadDim* dim); -s32 Collider_ResetQuadACDist(GlobalContext* globalCtx, ColliderQuadDim* dim); +s32 Collider_InitBase(PlayState* play, Collider* collider); +s32 Collider_DestroyBase(PlayState* play, Collider* collider); +s32 Collider_SetBaseToActor(PlayState* play, Collider* collider, ColliderInitToActor* src); +s32 Collider_SetBaseType1(PlayState* play, Collider* collider, Actor* actor, ColliderInitType1* src); +s32 Collider_SetBase(PlayState* play, Collider* collider, Actor* actor, ColliderInit* src); +void Collider_ResetATBase(PlayState* play, Collider* collider); +void Collider_ResetACBase(PlayState* play, Collider* collider); +void Collider_ResetOCBase(PlayState* play, Collider* collider); +s32 Collider_InitTouch(PlayState* play, ColliderTouch* touch); +s32 Collider_DestroyTouch(PlayState* play, ColliderTouch* touch); +s32 Collider_SetTouch(PlayState* play, ColliderTouch* touch, ColliderTouchInit* src); +void Collider_ResetATInfoUnk(PlayState* play, ColliderInfo* info); +s32 Collider_InitBump(PlayState* play, ColliderBump* bump); +s32 Collider_DestroyBump(PlayState* play, ColliderBump* bump); +s32 Collider_SetBump(PlayState* play, ColliderBump* bump, ColliderBumpInit* src); +s32 Collider_InitInfo(PlayState* play, ColliderInfo* info); +s32 Collider_DestroyInfo(PlayState* play, ColliderInfo* info); +s32 Collider_SetInfo(PlayState* play, ColliderInfo* info, ColliderInfoInit* src); +void Collider_ResetATInfo(PlayState* play, ColliderInfo* info); +void Collider_ResetACInfo(PlayState* play, ColliderInfo* info); +void Collider_ResetOCInfo(PlayState* play, ColliderInfo* info); +s32 Collider_InitJntSphElementDim(PlayState* play, ColliderJntSphElementDim* dim); +s32 Collider_DestroyJntSphElementDim(PlayState* play, ColliderJntSphElementDim* dim); +s32 Collider_SetJntSphElementDim(PlayState* play, ColliderJntSphElementDim* dest, ColliderJntSphElementDimInit* src); +s32 Collider_InitJntSphElement(PlayState* play, ColliderJntSphElement* element); +s32 Collider_DestroyJntSphElement(PlayState* play, ColliderJntSphElement* element); +s32 Collider_SetJntSphElement(PlayState* play, ColliderJntSphElement* dest, ColliderJntSphElementInit* src); +s32 Collider_ResetJntSphElementAT(PlayState* play, ColliderJntSphElement* collider); +s32 Collider_ResetJntSphElementAC(PlayState* play, ColliderJntSphElement* collider); +s32 Collider_ResetJntSphElementOC(PlayState* play, ColliderJntSphElement* collider); +s32 Collider_InitJntSph(PlayState* play, ColliderJntSph* collider); +s32 Collider_FreeJntSph(PlayState* play, ColliderJntSph* collider); +s32 Collider_DestroyJntSph(PlayState* play, ColliderJntSph* collider); +s32 Collider_SetJntSphToActor(PlayState* play, ColliderJntSph* collider, ColliderJntSphInitToActor* src); +s32 Collider_SetJntSphAllocType1(PlayState* play, ColliderJntSph* sphereGroup, Actor* actor, ColliderJntSphInitType1* src); +s32 Collider_SetJntSph(PlayState* play, ColliderJntSph* sphereGroup, Actor* actor, ColliderJntSphInit* src, ColliderJntSphElement* elements); +s32 Collider_InitAndSetJntSph(PlayState* play, ColliderJntSph* sphereGroup, Actor* actor, ColliderJntSphInit* src, ColliderJntSphElement* elements); +s32 Collider_ResetJntSphAT(PlayState* play, Collider* collider); +s32 Collider_ResetJntSphAC(PlayState* play, Collider* collider); +s32 Collider_ResetJntSphOC(PlayState* play, Collider* collider); +s32 Collider_InitCylinderDim(PlayState* play, Cylinder16* dim); +s32 Collider_DestroyCylinderDim(PlayState* play, Cylinder16* dim); +s32 Collider_SetCylinderDim(PlayState* play, Cylinder16* dim, Cylinder16* src); +s32 Collider_InitCylinder(PlayState* play, ColliderCylinder* collider); +s32 Collider_DestroyCylinder(PlayState* play, ColliderCylinder* collider); +s32 Collider_SetCylinderToActor(PlayState* play, ColliderCylinder* collider, ColliderCylinderInitToActor* src); +s32 Collider_SetCylinderType1(PlayState* play, ColliderCylinder* collider, Actor* actor, ColliderCylinderInitType1* src); +s32 Collider_SetCylinder(PlayState* play, ColliderCylinder* collider, Actor* actor, ColliderCylinderInit* src); +s32 Collider_InitAndSetCylinder(PlayState* play, ColliderCylinder* collider, Actor* actor, ColliderCylinderInit* src); +s32 Collider_ResetCylinderAT(PlayState* play, Collider* collider); +s32 Collider_ResetCylinderAC(PlayState* play, Collider* collider); +s32 Collider_ResetCylinderOC(PlayState* play, Collider* collider); +s32 Collider_InitTrisElementDim(PlayState* play, TriNorm* dim); +s32 Collider_DestroyTrisElementDim(PlayState* play, TriNorm* dim); +s32 Collider_SetTrisElementDim(PlayState* play, TriNorm* dim, ColliderTrisElementDimInit* src); +s32 Collider_InitTrisElement(PlayState* play, ColliderTrisElement* element); +s32 Collider_DestroyTrisElement(PlayState* play, ColliderTrisElement* element); +s32 Collider_SetTrisElement(PlayState* play, ColliderTrisElement* element, ColliderTrisElementInit* src); +s32 Collider_ResetTrisElementAT(PlayState* play, ColliderTrisElement* element); +s32 Collider_ResetTrisElementAC(PlayState* play, ColliderTrisElement* element); +s32 Collider_ResetTrisElementOC(PlayState* play, ColliderTrisElement* element); +s32 Collider_InitTris(PlayState* play, ColliderTris* tris); +s32 Collider_FreeTris(PlayState* play, ColliderTris* tris); +s32 Collider_DestroyTris(PlayState* play, ColliderTris* tris); +s32 Collider_SetTrisAllocType1(PlayState* play, ColliderTris* tris, Actor* actor, ColliderTrisInitType1* src); +s32 Collider_SetTris(PlayState* play, ColliderTris* triGroup, Actor* actor, ColliderTrisInit* src, ColliderTrisElement* tris); +s32 Collider_InitAndSetTris(PlayState* play, ColliderTris* tris, Actor* actor, ColliderTrisInit* src, ColliderTrisElement* elements); +s32 Collider_ResetTrisAT(PlayState* play, Collider* collider); +s32 Collider_ResetTrisAC(PlayState* play, Collider* collider); +s32 Collider_ResetTrisOC(PlayState* play, Collider* collider); +s32 Collider_InitQuadDim(PlayState* play, ColliderQuadDim* dim); +s32 Collider_DestroyQuadDim(PlayState* play, ColliderQuadDim* dim); +s32 Collider_ResetQuadACDist(PlayState* play, ColliderQuadDim* dim); void Collider_SetQuadMidpoints(ColliderQuadDim* dim); -s32 Collider_SetQuadDim(GlobalContext* globalCtx, ColliderQuadDim* dim, ColliderQuadDimInit* init); -s32 Collider_InitQuad(GlobalContext* globalCtx, ColliderQuad* collider); -s32 Collider_DestroyQuad(GlobalContext* globalCtx, ColliderQuad* collider); -s32 Collider_SetQuadType1(GlobalContext* globalCtx, ColliderQuad* collider, Actor* actor, ColliderQuadInitType1* src); -s32 Collider_SetQuad(GlobalContext* globalCtx, ColliderQuad* collider, Actor* actor, ColliderQuadInit* src); -s32 Collider_InitAndSetQuad(GlobalContext* globalCtx, ColliderQuad* collider, Actor* actor, ColliderQuadInit* src); -s32 Collider_ResetQuadAT(GlobalContext* globalCtx, Collider* collider); -s32 Collider_ResetQuadAC(GlobalContext* globalCtx, Collider* collider); -s32 Collider_ResetQuadOC(GlobalContext* globalCtx, Collider* collider); -s32 Collider_QuadSetNearestAC(GlobalContext* globalCtx, ColliderQuad* quad, Vec3f* hitPos); -s32 Collider_InitSphere(GlobalContext* globalCtx, ColliderSphere* collider); -s32 Collider_DestroySphere(GlobalContext* globalCtx, ColliderSphere* collider); -s32 Collider_SetSphere(GlobalContext* globalCtx, ColliderSphere* collider, Actor* actor, ColliderSphereInit* src); -s32 Collider_InitAndSetSphere(GlobalContext* globalCtx, ColliderSphere* collider, Actor* actor, ColliderSphereInit* src); -s32 Collider_ResetSphereAT(GlobalContext* globalCtx, Collider* collider); -s32 Collider_ResetSphereAC(GlobalContext* globalCtx, Collider* collider); -s32 Collider_ResetSphereOC(GlobalContext* globalCtx, Collider* collider); -s32 Collider_InitLine(GlobalContext* globalCtx, OcLine* line); -s32 Collider_DestroyLine(GlobalContext* globalCtx, OcLine* line); -s32 Collider_SetLinePoints(GlobalContext* globalCtx, OcLine* line, Vec3f* a, Vec3f* b); -s32 Collider_SetLine(GlobalContext* globalCtx, OcLine* line, OcLine* src); -s32 Collider_ResetLineOC(GlobalContext* globalCtx, OcLine* line); -void CollisionCheck_InitContext(GlobalContext* globalCtx, CollisionCheckContext* colCtxt); -void CollisionCheck_DestroyContext(GlobalContext* globalCtx, CollisionCheckContext* colCtxt); -void CollisionCheck_ClearContext(GlobalContext* globalCtx, CollisionCheckContext* colCtxt); -void CollisionCheck_EnableSAC(GlobalContext* globalCtx, CollisionCheckContext* colCtxt); -void CollisionCheck_DisableSAC(GlobalContext* globalCtx, CollisionCheckContext* colCtxt); -s32 CollisionCheck_SetAT(GlobalContext* globalCtx, CollisionCheckContext* colCtxt, Collider* collider); -s32 CollisionCheck_SetAT_SAC(GlobalContext* globalCtx, CollisionCheckContext* colCtxt, Collider* collider, s32 index); -s32 CollisionCheck_SetAC(GlobalContext* globalCtx, CollisionCheckContext* colCtxt, Collider* collider); -s32 CollisionCheck_SetAC_SAC(GlobalContext* globalCtx, CollisionCheckContext* colCtxt, Collider* collider, s32 index); -s32 CollisionCheck_SetOC(GlobalContext* globalCtx, CollisionCheckContext* colCtxt, Collider* collider); -s32 CollisionCheck_SetOC_SAC(GlobalContext* globalCtx, CollisionCheckContext* colCtxt, Collider* collider, s32 index); -s32 CollisionCheck_SetOCLine(GlobalContext* globalCtx, CollisionCheckContext* colCtxt, OcLine* line); +s32 Collider_SetQuadDim(PlayState* play, ColliderQuadDim* dim, ColliderQuadDimInit* init); +s32 Collider_InitQuad(PlayState* play, ColliderQuad* collider); +s32 Collider_DestroyQuad(PlayState* play, ColliderQuad* collider); +s32 Collider_SetQuadType1(PlayState* play, ColliderQuad* collider, Actor* actor, ColliderQuadInitType1* src); +s32 Collider_SetQuad(PlayState* play, ColliderQuad* collider, Actor* actor, ColliderQuadInit* src); +s32 Collider_InitAndSetQuad(PlayState* play, ColliderQuad* collider, Actor* actor, ColliderQuadInit* src); +s32 Collider_ResetQuadAT(PlayState* play, Collider* collider); +s32 Collider_ResetQuadAC(PlayState* play, Collider* collider); +s32 Collider_ResetQuadOC(PlayState* play, Collider* collider); +s32 Collider_QuadSetNearestAC(PlayState* play, ColliderQuad* quad, Vec3f* hitPos); +s32 Collider_InitSphere(PlayState* play, ColliderSphere* collider); +s32 Collider_DestroySphere(PlayState* play, ColliderSphere* collider); +s32 Collider_SetSphere(PlayState* play, ColliderSphere* collider, Actor* actor, ColliderSphereInit* src); +s32 Collider_InitAndSetSphere(PlayState* play, ColliderSphere* collider, Actor* actor, ColliderSphereInit* src); +s32 Collider_ResetSphereAT(PlayState* play, Collider* collider); +s32 Collider_ResetSphereAC(PlayState* play, Collider* collider); +s32 Collider_ResetSphereOC(PlayState* play, Collider* collider); +s32 Collider_InitLine(PlayState* play, OcLine* line); +s32 Collider_DestroyLine(PlayState* play, OcLine* line); +s32 Collider_SetLinePoints(PlayState* play, OcLine* line, Vec3f* a, Vec3f* b); +s32 Collider_SetLine(PlayState* play, OcLine* line, OcLine* src); +s32 Collider_ResetLineOC(PlayState* play, OcLine* line); +void CollisionCheck_InitContext(PlayState* play, CollisionCheckContext* colCtxt); +void CollisionCheck_DestroyContext(PlayState* play, CollisionCheckContext* colCtxt); +void CollisionCheck_ClearContext(PlayState* play, CollisionCheckContext* colCtxt); +void CollisionCheck_EnableSAC(PlayState* play, CollisionCheckContext* colCtxt); +void CollisionCheck_DisableSAC(PlayState* play, CollisionCheckContext* colCtxt); +s32 CollisionCheck_SetAT(PlayState* play, CollisionCheckContext* colCtxt, Collider* collider); +s32 CollisionCheck_SetAT_SAC(PlayState* play, CollisionCheckContext* colCtxt, Collider* collider, s32 index); +s32 CollisionCheck_SetAC(PlayState* play, CollisionCheckContext* colCtxt, Collider* collider); +s32 CollisionCheck_SetAC_SAC(PlayState* play, CollisionCheckContext* colCtxt, Collider* collider, s32 index); +s32 CollisionCheck_SetOC(PlayState* play, CollisionCheckContext* colCtxt, Collider* collider); +s32 CollisionCheck_SetOC_SAC(PlayState* play, CollisionCheckContext* colCtxt, Collider* collider, s32 index); +s32 CollisionCheck_SetOCLine(PlayState* play, CollisionCheckContext* colCtxt, OcLine* line); s32 CollisionCheck_SkipTouch(ColliderInfo* info); s32 CollisionCheck_SkipBump(ColliderInfo* info); s32 CollisionCheck_NoSharedFlags(ColliderInfo* toucher, ColliderInfo* bumper); -void CollisionCheck_NoBlood(GlobalContext* globalCtx, Collider* collider, Vec3f* v); -void CollisionCheck_BlueBlood(GlobalContext* globalCtx, Collider* collider, Vec3f* v); -void CollisionCheck_GreenBlood(GlobalContext* globalCtx, Collider* collider, Vec3f* v); -void CollisionCheck_WaterBurst(GlobalContext* globalCtx, Collider* collider, Vec3f* v); -void CollisionCheck_RedBlood(GlobalContext* globalCtx, Collider* collider, Vec3f* v); -void CollisionCheck_RedBloodUnused(GlobalContext* globalCtx, Collider* collider, Vec3f* v); -void CollisionCheck_HitSolid(GlobalContext* globalCtx, ColliderInfo* info, Collider* collider, Vec3f* hitPos); +void CollisionCheck_NoBlood(PlayState* play, Collider* collider, Vec3f* v); +void CollisionCheck_BlueBlood(PlayState* play, Collider* collider, Vec3f* v); +void CollisionCheck_GreenBlood(PlayState* play, Collider* collider, Vec3f* v); +void CollisionCheck_WaterBurst(PlayState* play, Collider* collider, Vec3f* v); +void CollisionCheck_RedBlood(PlayState* play, Collider* collider, Vec3f* v); +void CollisionCheck_RedBloodUnused(PlayState* play, Collider* collider, Vec3f* v); +void CollisionCheck_HitSolid(PlayState* play, ColliderInfo* info, Collider* collider, Vec3f* hitPos); s32 CollisionCheck_SwordHitAudio(Collider* at, ColliderInfo* acInfo); -void CollisionCheck_HitEffects(GlobalContext* globalCtx, Collider* at, ColliderInfo* atInfo, Collider* ac, ColliderInfo* acInfo, Vec3f* hitPos); +void CollisionCheck_HitEffects(PlayState* play, Collider* at, ColliderInfo* atInfo, Collider* ac, ColliderInfo* acInfo, Vec3f* hitPos); void CollisionCheck_SetBounce(Collider* at, Collider* ac); -s32 CollisionCheck_SetATvsAC(GlobalContext* globalCtx, Collider* at, ColliderInfo* atInfo, Vec3f* atPos, Collider* ac, ColliderInfo* acInfo, Vec3f* acPos, Vec3f* hitPos); +s32 CollisionCheck_SetATvsAC(PlayState* play, Collider* at, ColliderInfo* atInfo, Vec3f* atPos, Collider* ac, ColliderInfo* acInfo, Vec3f* acPos, Vec3f* hitPos); void CollisionCheck_TrisAvgPoint(ColliderTrisElement* tri, Vec3f* avg); void CollisionCheck_QuadAvgPoint(ColliderQuad* quad, Vec3f* avg); -void CollisionCheck_AC_JntSphVsJntSph(GlobalContext* globalCtx, CollisionCheckContext* colCtxt, Collider* colAT, Collider* colAC); -void CollisionCheck_AC_JntSphVsCyl(GlobalContext* globalCtx, CollisionCheckContext* colCtxt, Collider* colAT, Collider* colAC); -void CollisionCheck_AC_JntSphVsTris(GlobalContext* globalCtx, CollisionCheckContext* colCtxt, Collider* colAT, Collider* colAC); -void CollisionCheck_AC_JntSphVsQuad(GlobalContext* globalCtx, CollisionCheckContext* colCtxt, Collider* colAT, Collider* colAC); -void CollisionCheck_AC_JntSphVsSphere(GlobalContext* globalCtx, CollisionCheckContext* colCtxt, Collider* colAT, Collider* colAC); -void CollisionCheck_AC_CylVsJntSph(GlobalContext* globalCtx, CollisionCheckContext* colCtxt, Collider* colAT, Collider* colAC); -void CollisionCheck_AC_CylVsCyl(GlobalContext* globalCtx, CollisionCheckContext* colCtxt, Collider* colAT, Collider* colAC); -void CollisionCheck_AC_CylVsTris(GlobalContext* globalCtx, CollisionCheckContext* colCtxt, Collider* colAT, Collider* colAC); -void CollisionCheck_AC_CylVsQuad(GlobalContext* globalCtx, CollisionCheckContext* colCtxt, Collider* colAT, Collider* colAC); -void CollisionCheck_AC_CylVsSphere(GlobalContext* globalCtx, CollisionCheckContext* colCtxt, Collider* colAT, Collider* colAC); -void CollisionCheck_AC_TrisVsJntSph(GlobalContext* globalCtx, CollisionCheckContext* colCtxt, Collider* colAT, Collider* colAC); -void CollisionCheck_AC_TrisVsCyl(GlobalContext* globalCtx, CollisionCheckContext* colCtxt, Collider* colAT, Collider* colAC); -void CollisionCheck_AC_TrisVsTris(GlobalContext* globalCtx, CollisionCheckContext* colCtxt, Collider* colAT, Collider* colAC); -void CollisionCheck_AC_TrisVsQuad(GlobalContext* globalCtx, CollisionCheckContext* colCtxt, Collider* colAT, Collider* colAC); -void CollisionCheck_AC_TrisVsSphere(GlobalContext* globalCtx, CollisionCheckContext* colCtxt, Collider* colAT, Collider* colAC); -void CollisionCheck_AC_QuadVsJntSph(GlobalContext* globalCtx, CollisionCheckContext* colCtxt, Collider* colAT, Collider* colAC); -void CollisionCheck_AC_QuadVsCyl(GlobalContext* globalCtx, CollisionCheckContext* colCtxt, Collider* colAT, Collider* colAC); -void CollisionCheck_AC_QuadVsTris(GlobalContext* globalCtx, CollisionCheckContext* colCtxt, Collider* colAT, Collider* colAC); -void CollisionCheck_AC_QuadVsQuad(GlobalContext* globalCtx, CollisionCheckContext* colCtxt, Collider* colAT, Collider* colAC); -void CollisionCheck_AC_QuadVsSphere(GlobalContext* globalCtx, CollisionCheckContext* colCtxt, Collider* colAT, Collider* colAC); -void CollisionCheck_AC_SphereVsJntSph(GlobalContext* globalCtx, CollisionCheckContext* colCtxt, Collider* colAT, Collider* colAC); -void CollisionCheck_AC_SphereVsCylinder(GlobalContext* globalCtx, CollisionCheckContext* colCtxt, Collider* colAT, Collider* colAC); -void CollisionCheck_AC_SphereVsTris(GlobalContext* globalCtx, CollisionCheckContext* colCtxt, Collider* colAT, Collider* colAC); -void CollisionCheck_AC_SphereVsQuad(GlobalContext* globalCtx, CollisionCheckContext* colCtxt, Collider* colAT, Collider* colAC); -void CollisionCheck_AC_SphereVsSphere(GlobalContext* globalCtx, CollisionCheckContext* colCtxt, Collider* colAT, Collider* colAC); -void CollisionCheck_SetJntSphHitFX(GlobalContext* globalCtx, CollisionCheckContext* colCtxt, Collider* collider); -void CollisionCheck_SetCylHitFX(GlobalContext* globalCtx, CollisionCheckContext* colCtxt, Collider* collider); -void CollisionCheck_SetTrisHitFX(GlobalContext* globalCtx, CollisionCheckContext* colCtxt, Collider* collider); -void CollisionCheck_SetQuadHitFX(GlobalContext* globalCtx, CollisionCheckContext* colCtxt, Collider* collider); -void CollisionCheck_SetSphereHitFX(GlobalContext* globalCtx, CollisionCheckContext* colCtxt, Collider* collider); -void CollisionCheck_SetHitEffects(GlobalContext* globalCtx, CollisionCheckContext* colCtxt); -void CollisionCheck_AC(GlobalContext* globalCtx, CollisionCheckContext* colCtxt, Collider* colAT); -void CollisionCheck_AT(GlobalContext* globalCtx, CollisionCheckContext* colCtxt); +void CollisionCheck_AC_JntSphVsJntSph(PlayState* play, CollisionCheckContext* colCtxt, Collider* colAT, Collider* colAC); +void CollisionCheck_AC_JntSphVsCyl(PlayState* play, CollisionCheckContext* colCtxt, Collider* colAT, Collider* colAC); +void CollisionCheck_AC_JntSphVsTris(PlayState* play, CollisionCheckContext* colCtxt, Collider* colAT, Collider* colAC); +void CollisionCheck_AC_JntSphVsQuad(PlayState* play, CollisionCheckContext* colCtxt, Collider* colAT, Collider* colAC); +void CollisionCheck_AC_JntSphVsSphere(PlayState* play, CollisionCheckContext* colCtxt, Collider* colAT, Collider* colAC); +void CollisionCheck_AC_CylVsJntSph(PlayState* play, CollisionCheckContext* colCtxt, Collider* colAT, Collider* colAC); +void CollisionCheck_AC_CylVsCyl(PlayState* play, CollisionCheckContext* colCtxt, Collider* colAT, Collider* colAC); +void CollisionCheck_AC_CylVsTris(PlayState* play, CollisionCheckContext* colCtxt, Collider* colAT, Collider* colAC); +void CollisionCheck_AC_CylVsQuad(PlayState* play, CollisionCheckContext* colCtxt, Collider* colAT, Collider* colAC); +void CollisionCheck_AC_CylVsSphere(PlayState* play, CollisionCheckContext* colCtxt, Collider* colAT, Collider* colAC); +void CollisionCheck_AC_TrisVsJntSph(PlayState* play, CollisionCheckContext* colCtxt, Collider* colAT, Collider* colAC); +void CollisionCheck_AC_TrisVsCyl(PlayState* play, CollisionCheckContext* colCtxt, Collider* colAT, Collider* colAC); +void CollisionCheck_AC_TrisVsTris(PlayState* play, CollisionCheckContext* colCtxt, Collider* colAT, Collider* colAC); +void CollisionCheck_AC_TrisVsQuad(PlayState* play, CollisionCheckContext* colCtxt, Collider* colAT, Collider* colAC); +void CollisionCheck_AC_TrisVsSphere(PlayState* play, CollisionCheckContext* colCtxt, Collider* colAT, Collider* colAC); +void CollisionCheck_AC_QuadVsJntSph(PlayState* play, CollisionCheckContext* colCtxt, Collider* colAT, Collider* colAC); +void CollisionCheck_AC_QuadVsCyl(PlayState* play, CollisionCheckContext* colCtxt, Collider* colAT, Collider* colAC); +void CollisionCheck_AC_QuadVsTris(PlayState* play, CollisionCheckContext* colCtxt, Collider* colAT, Collider* colAC); +void CollisionCheck_AC_QuadVsQuad(PlayState* play, CollisionCheckContext* colCtxt, Collider* colAT, Collider* colAC); +void CollisionCheck_AC_QuadVsSphere(PlayState* play, CollisionCheckContext* colCtxt, Collider* colAT, Collider* colAC); +void CollisionCheck_AC_SphereVsJntSph(PlayState* play, CollisionCheckContext* colCtxt, Collider* colAT, Collider* colAC); +void CollisionCheck_AC_SphereVsCylinder(PlayState* play, CollisionCheckContext* colCtxt, Collider* colAT, Collider* colAC); +void CollisionCheck_AC_SphereVsTris(PlayState* play, CollisionCheckContext* colCtxt, Collider* colAT, Collider* colAC); +void CollisionCheck_AC_SphereVsQuad(PlayState* play, CollisionCheckContext* colCtxt, Collider* colAT, Collider* colAC); +void CollisionCheck_AC_SphereVsSphere(PlayState* play, CollisionCheckContext* colCtxt, Collider* colAT, Collider* colAC); +void CollisionCheck_SetJntSphHitFX(PlayState* play, CollisionCheckContext* colCtxt, Collider* collider); +void CollisionCheck_SetCylHitFX(PlayState* play, CollisionCheckContext* colCtxt, Collider* collider); +void CollisionCheck_SetTrisHitFX(PlayState* play, CollisionCheckContext* colCtxt, Collider* collider); +void CollisionCheck_SetQuadHitFX(PlayState* play, CollisionCheckContext* colCtxt, Collider* collider); +void CollisionCheck_SetSphereHitFX(PlayState* play, CollisionCheckContext* colCtxt, Collider* collider); +void CollisionCheck_SetHitEffects(PlayState* play, CollisionCheckContext* colCtxt); +void CollisionCheck_AC(PlayState* play, CollisionCheckContext* colCtxt, Collider* colAT); +void CollisionCheck_AT(PlayState* play, CollisionCheckContext* colCtxt); s32 CollisionCheck_GetMassType(u8 mass); -void CollisionCheck_SetOCvsOC(GlobalContext* globalCtx, Collider* left, ColliderInfo* leftInfo, Vec3f* leftPos, Collider* right, ColliderInfo* rightInfo, Vec3f* rightPos, f32 overlap); -void CollisionCheck_OC_JntSphVsJntSph(GlobalContext* globalCtx, CollisionCheckContext* colCtxt, Collider* l, Collider* r); -void CollisionCheck_OC_JntSphVsCyl(GlobalContext* globalCtx, CollisionCheckContext* colCtxt, Collider* l, Collider* r); -void CollisionCheck_OC_JntSphVsSphere(GlobalContext* globalCtx, CollisionCheckContext* colCtxt, Collider* l, Collider* r); -void CollisionCheck_OC_CylVsJntSph(GlobalContext* globalCtx, CollisionCheckContext* colCtxt, Collider* l, Collider* r); -void CollisionCheck_OC_CylVsCyl(GlobalContext* globalCtx, CollisionCheckContext* colCtxt, Collider* l, Collider* r); -void CollisionCheck_OC_CylVsSphere(GlobalContext* globalCtx, CollisionCheckContext* colCtxt, Collider* l, Collider* r); -void CollisionCheck_OC_SphereVsJntSph(GlobalContext* globalCtx, CollisionCheckContext* colCtxt, Collider* l, Collider* r); -void CollisionCheck_OC_SphereVsCyl(GlobalContext* globalCtx, CollisionCheckContext* colCtxt, Collider* l, Collider* r); -void CollisionCheck_OC_SphereVsSphere(GlobalContext* globalCtx, CollisionCheckContext* colCtxt, Collider* l, Collider* r); +void CollisionCheck_SetOCvsOC(PlayState* play, Collider* left, ColliderInfo* leftInfo, Vec3f* leftPos, Collider* right, ColliderInfo* rightInfo, Vec3f* rightPos, f32 overlap); +void CollisionCheck_OC_JntSphVsJntSph(PlayState* play, CollisionCheckContext* colCtxt, Collider* l, Collider* r); +void CollisionCheck_OC_JntSphVsCyl(PlayState* play, CollisionCheckContext* colCtxt, Collider* l, Collider* r); +void CollisionCheck_OC_JntSphVsSphere(PlayState* play, CollisionCheckContext* colCtxt, Collider* l, Collider* r); +void CollisionCheck_OC_CylVsJntSph(PlayState* play, CollisionCheckContext* colCtxt, Collider* l, Collider* r); +void CollisionCheck_OC_CylVsCyl(PlayState* play, CollisionCheckContext* colCtxt, Collider* l, Collider* r); +void CollisionCheck_OC_CylVsSphere(PlayState* play, CollisionCheckContext* colCtxt, Collider* l, Collider* r); +void CollisionCheck_OC_SphereVsJntSph(PlayState* play, CollisionCheckContext* colCtxt, Collider* l, Collider* r); +void CollisionCheck_OC_SphereVsCyl(PlayState* play, CollisionCheckContext* colCtxt, Collider* l, Collider* r); +void CollisionCheck_OC_SphereVsSphere(PlayState* play, CollisionCheckContext* colCtxt, Collider* l, Collider* r); s32 CollisionCheck_SkipOC(Collider* collider); s32 CollisionCheck_Incompatible(Collider* left, Collider* right); -void CollisionCheck_OC(GlobalContext* globalCtx, CollisionCheckContext* colCtxt); +void CollisionCheck_OC(PlayState* play, CollisionCheckContext* colCtxt); void CollisionCheck_InitInfo(CollisionCheckInfo* info); void CollisionCheck_ResetDamage(CollisionCheckInfo* info); void CollisionCheck_SetInfoNoDamageTable(CollisionCheckInfo* info, CollisionCheckInfoInit* init); void CollisionCheck_SetInfo(CollisionCheckInfo* info, DamageTable* damageTable, CollisionCheckInfoInit* init); void CollisionCheck_SetInfo2(CollisionCheckInfo* info, DamageTable* damageTable, CollisionCheckInfoInit2* init); void CollisionCheck_SetInfoGetDamageTable(CollisionCheckInfo* info, s32 index, CollisionCheckInfoInit2* init); -void CollisionCheck_ApplyDamage(GlobalContext* globalCtx, CollisionCheckContext* colCtxt, Collider* collider, ColliderInfo* info); -void CollisionCheck_ApplyDamageJntSph(GlobalContext* globalCtx, CollisionCheckContext* colCtxt, Collider* collider); -void CollisionCheck_ApplyDamageCyl(GlobalContext* globalCtx, CollisionCheckContext* colCtxt, Collider* collider); -void CollisionCheck_ApplyDamageTris(GlobalContext* globalCtx, CollisionCheckContext* colCtxt, Collider* collider); -void CollisionCheck_ApplyDamageQuad(GlobalContext* globalCtx, CollisionCheckContext* colCtxt, Collider* collider); -void CollisionCheck_ApplyDamageSphere(GlobalContext* globalCtx, CollisionCheckContext* colCtxt, Collider* collider); -void CollisionCheck_Damage(GlobalContext* globalCtx, CollisionCheckContext* colCtxt); -s32 CollisionCheck_LineOC_JntSph(GlobalContext* globalCtx, CollisionCheckContext* colChkCtx, Collider* collider, Vec3f* a, Vec3f* b); -s32 CollisionCheck_LineOC_Cyl(GlobalContext* globalCtx, CollisionCheckContext* colChkCtx, Collider* collider, Vec3f* a, Vec3f* b); -s32 CollisionCheck_LineOC_Sphere(GlobalContext* globalCtx, CollisionCheckContext* colChkCtx, Collider* collider, Vec3f* a, Vec3f* b); -s32 CollisionCheck_LineOC(GlobalContext* globalCtx, CollisionCheckContext* colChkCtx, Vec3f* a, Vec3f* b, Actor** exclusions, s32 numExclusions); -s32 CollisionCheck_LineOCCheckAll(GlobalContext* globalCtx, CollisionCheckContext* colCtxt, Vec3f* a, Vec3f* b); -s32 CollisionCheck_LineOCCheck(GlobalContext* globalCtx, CollisionCheckContext* colCtxt, Vec3f* a, Vec3f* b, Actor** exclusions, s32 numExclusions); +void CollisionCheck_ApplyDamage(PlayState* play, CollisionCheckContext* colCtxt, Collider* collider, ColliderInfo* info); +void CollisionCheck_ApplyDamageJntSph(PlayState* play, CollisionCheckContext* colCtxt, Collider* collider); +void CollisionCheck_ApplyDamageCyl(PlayState* play, CollisionCheckContext* colCtxt, Collider* collider); +void CollisionCheck_ApplyDamageTris(PlayState* play, CollisionCheckContext* colCtxt, Collider* collider); +void CollisionCheck_ApplyDamageQuad(PlayState* play, CollisionCheckContext* colCtxt, Collider* collider); +void CollisionCheck_ApplyDamageSphere(PlayState* play, CollisionCheckContext* colCtxt, Collider* collider); +void CollisionCheck_Damage(PlayState* play, CollisionCheckContext* colCtxt); +s32 CollisionCheck_LineOC_JntSph(PlayState* play, CollisionCheckContext* colChkCtx, Collider* collider, Vec3f* a, Vec3f* b); +s32 CollisionCheck_LineOC_Cyl(PlayState* play, CollisionCheckContext* colChkCtx, Collider* collider, Vec3f* a, Vec3f* b); +s32 CollisionCheck_LineOC_Sphere(PlayState* play, CollisionCheckContext* colChkCtx, Collider* collider, Vec3f* a, Vec3f* b); +s32 CollisionCheck_LineOC(PlayState* play, CollisionCheckContext* colChkCtx, Vec3f* a, Vec3f* b, Actor** exclusions, s32 numExclusions); +s32 CollisionCheck_LineOCCheckAll(PlayState* play, CollisionCheckContext* colCtxt, Vec3f* a, Vec3f* b); +s32 CollisionCheck_LineOCCheck(PlayState* play, CollisionCheckContext* colCtxt, Vec3f* a, Vec3f* b, Actor** exclusions, s32 numExclusions); void Collider_UpdateCylinder(Actor* actor, ColliderCylinder* collider); void Collider_SetCylinderPosition(ColliderCylinder* collider, Vec3s* pos); void Collider_SetQuadVertices(ColliderQuad* collider, Vec3f* a, Vec3f* b, Vec3f* c, Vec3f* d); void Collider_SetTrisVertices(ColliderTris* collider, s32 index, Vec3f* a, Vec3f* b, Vec3f* c); -void Collider_SetTrisDim(GlobalContext* globalCtx, ColliderTris* collider, s32 index, ColliderTrisElementDimInit* init); +void Collider_SetTrisDim(PlayState* play, ColliderTris* collider, s32 index, ColliderTrisElementDimInit* init); void Collider_UpdateSpheres(s32 limb, ColliderJntSph* collider); void Collider_UpdateSpheresElement(ColliderJntSph* collider, s32 index, Actor* actor); void Collider_UpdateSphere(s32 limb, ColliderSphere* collider); -void CollisionCheck_SpawnRedBlood(GlobalContext* globalCtx, Vec3f* v); -void CollisionCheck_SpawnWaterDroplets(GlobalContext* globalCtx, Vec3f* v); -void CollisionCheck_SpawnShieldParticles(GlobalContext* globalCtx, Vec3f* v); -void CollisionCheck_SpawnShieldParticlesMetal(GlobalContext* globalCtx, Vec3f* v); -void CollisionCheck_SpawnShieldParticlesMetalSound(GlobalContext* globalCtx, Vec3f* v, Vec3f* pos); -void CollisionCheck_SpawnShieldParticlesMetal2(GlobalContext* globalCtx, Vec3f* v); -void CollisionCheck_SpawnShieldParticlesWood(GlobalContext* globalCtx, Vec3f* v, Vec3f* pos); +void CollisionCheck_SpawnRedBlood(PlayState* play, Vec3f* v); +void CollisionCheck_SpawnWaterDroplets(PlayState* play, Vec3f* v); +void CollisionCheck_SpawnShieldParticles(PlayState* play, Vec3f* v); +void CollisionCheck_SpawnShieldParticlesMetal(PlayState* play, Vec3f* v); +void CollisionCheck_SpawnShieldParticlesMetalSound(PlayState* play, Vec3f* v, Vec3f* pos); +void CollisionCheck_SpawnShieldParticlesMetal2(PlayState* play, Vec3f* v); +void CollisionCheck_SpawnShieldParticlesWood(PlayState* play, Vec3f* v, Vec3f* pos); s32 CollisionCheck_CylSideVsLineSeg(f32 radius, f32 height, f32 offset, Vec3f* actorPos, Vec3f* itemPos, Vec3f* itemProjPos, Vec3f* out1, Vec3f* out2); -void func_800E8EA0(GlobalContext* globalCtx, Actor* actor, u16 textId); -s32 nop_800E8ED0(UNK_TYPE4 param_1); -void nop_800E8EE0(UNK_TYPE4 param_1); -s32 nop_800E8EEC(UNK_TYPE4 param_1); -void nop_800E8EFC(UNK_TYPE4 param_1); -s32 func_800E8F08(Vec3s* param_1, Vec3s* param_2); -s32 func_800E8FA4(Actor* actor, Vec3f* param_2, Vec3s* param_3, Vec3s* param_4); -s32 func_800E9138(GlobalContext* globalCtx, Actor* actor, Vec3s* param_3, Vec3s* param_4, f32 param_5); -s32 func_800E9250(GlobalContext* globalCtx, Actor* actor, Vec3s* param_3, Vec3s* param_4, Vec3f param_5); +void Actor_ContinueText(PlayState* play, Actor* actor, u16 textId); +s32 Flags_GetEventChkInf(s32 flag); +void Flags_SetEventChkInf(s32 flag); +s32 Flags_GetInfTable(s32 flag); +void Flags_SetInfTable(s32 flag); +s32 Actor_TrackNone(Vec3s* headRot, Vec3s* torsoRot); +s32 Actor_TrackPoint(Actor* actor, Vec3f* target, Vec3s* headRot, Vec3s* torsoRot); +s32 Actor_TrackPlayerSetFocusHeight(PlayState* play, Actor* actor, Vec3s* headRot, Vec3s* torsoRot, f32 focusPosYAdj); +s32 Actor_TrackPlayer(PlayState* play, Actor* actor, Vec3s* headRot, Vec3s* torsoRot, Vec3f focusPos); void SaveContext_Init(void); void GameInfo_Init(void); // void DebugDisplay_Init(void); @@ -1393,65 +1344,43 @@ DebugDispObject* DebugDisplay_AddObject(f32 posX, f32 posY, f32 posZ, s16 rotX, // void func_800E9E94(void); void func_800E9F78(GraphicsContext* gfxCtx); -void Cutscene_Init(GlobalContext* globalCtx, CutsceneContext* csCtx); -void Cutscene_Start(GlobalContext* globalCtx, CutsceneContext* csCtx); -void Cutscene_End(GlobalContext* globalCtx, CutsceneContext* csCtx); -void Cutscene_Update1(GlobalContext* globalCtx, CutsceneContext* csCtx); -void Cutscene_Update2(GlobalContext* globalCtx, CutsceneContext* csCtx); -void func_800EDBE0(GlobalContext* globalCtx); -void func_800EDDB0(GlobalContext* globalCtx); -void Cutscene_LoadCutsceneData(GlobalContext* globalCtx, u8 csIndex); -void Cutscene_ActorTranslate(Actor* actor, GlobalContext* globalCtx, s32 actorActionIndex); -void Cutscene_ActorTranslateAndYaw(Actor* actor, GlobalContext* globalCtx, s32 actorActionIndex); -void Cutscene_ActorTranslateAndYawSmooth(Actor* actor, GlobalContext* globalCtx, s32 actorActionIndex); -void Cutscene_ActorTranslateXZAndYawSmooth(Actor* actor, GlobalContext* globalCtx, s32 actorActionIndex); -s32 Cutscene_GetSceneSetupIndex(GlobalContext* globalCtx); -s32 Cutscene_GetActorActionIndex(GlobalContext* globalCtx, u16 actorActionCmd); -s32 Cutscene_CheckActorAction(GlobalContext* globalCtx, u16 actorActionCmd); -u8 Cutscene_IsPlaying(GlobalContext* globalCtx); +void Cutscene_Init(PlayState* play, CutsceneContext* csCtx); +void Cutscene_Start(PlayState* play, CutsceneContext* csCtx); +void Cutscene_End(PlayState* play, CutsceneContext* csCtx); +void Cutscene_Update1(PlayState* play, CutsceneContext* csCtx); +void Cutscene_Update2(PlayState* play, CutsceneContext* csCtx); +void func_800EDBE0(PlayState* play); +void func_800EDDB0(PlayState* play); +void Cutscene_LoadCutsceneData(PlayState* play, u8 csIndex); +void Cutscene_ActorTranslate(Actor* actor, PlayState* play, s32 actorActionIndex); +void Cutscene_ActorTranslateAndYaw(Actor* actor, PlayState* play, s32 actorActionIndex); +void Cutscene_ActorTranslateAndYawSmooth(Actor* actor, PlayState* play, s32 actorActionIndex); +void Cutscene_ActorTranslateXZAndYawSmooth(Actor* actor, PlayState* play, s32 actorActionIndex); +s32 Cutscene_GetSceneSetupIndex(PlayState* play); +s32 Cutscene_GetActorActionIndex(PlayState* play, u16 actorActionCmd); +s32 Cutscene_CheckActorAction(PlayState* play, u16 actorActionCmd); +u8 Cutscene_IsPlaying(PlayState* play); -void GetItem_Draw(GlobalContext* globalCtx, s16 index); -void func_800EE364(GlobalContext* globalCtx, s16 index); -void func_800EE400(GlobalContext* globalCtx, s16 index); -void func_800EE5FC(GlobalContext* globalCtx, s16 index); -void func_800EE7D8(GlobalContext* globalCtx, s16 index); -void func_800EE940(GlobalContext* globalCtx, s16 index); -void func_800EEA48(GlobalContext* globalCtx, s16 index); -void func_800EEC18(GlobalContext* globalCtx, s16 index); -void func_800EED20(GlobalContext* globalCtx, s16 index); -void func_800EEE34(GlobalContext* globalCtx, s16 index); -void func_800EEF4C(GlobalContext* globalCtx, s16 index); -void func_800EF054(GlobalContext* globalCtx, s16 index); -void func_800EF0F0(GlobalContext* globalCtx, s16 index); -void func_800EF1F4(GlobalContext* globalCtx, s16 index); -void func_800EF2AC(GlobalContext* globalCtx, s16 index); -void func_800EF364(GlobalContext* globalCtx, s16 index); -void func_800EF4D4(GlobalContext* globalCtx, s16 index); -void func_800EF65C(GlobalContext* globalCtx, s16 index); -void func_800EF780(GlobalContext* globalCtx, s16 index); -void func_800EF89C(GlobalContext* globalCtx, s16 index); -void func_800EF984(GlobalContext* globalCtx, s16 index); -void func_800EFAB8(GlobalContext* globalCtx, s16 index); -void func_800EFBFC(GlobalContext* globalCtx, s16 index); -void func_800EFD44(GlobalContext* globalCtx, s16 index); -void EffFootmark_Init(GlobalContext* globalCtx); -void EffFootmark_Add(GlobalContext* globalCtx, MtxF* displayMatrix, Actor* actor, u8 id, Vec3f* location, u16 size, u8 red, u8 green, u8 blue, u16 alpha, u16 alphaChange, u16 fadeoutDelay); -void EffFootmark_Update(GlobalContext* globalCtx); -void EffFootmark_Draw(GlobalContext* globalCtx); -void SoundSource_InitAll(GlobalContext* globalCtx); -void SoundSource_UpdateAll(GlobalContext* globalCtx); -void SoundSource_PlaySfxAtFixedWorldPos(GlobalContext* globalCtx, Vec3f* worldPos, u32 duration, u16 sfxId); -void SoundSource_PlaySfxEachFrameAtFixedWorldPos(GlobalContext* globalCtx, Vec3f* worldPos, u32 duration, u16 sfxId); -u16 ElfMessage_GetFirstCycleHint(GlobalContext* globalCtx); +void GetItem_Draw(PlayState* play, s16 drawId); -u16 Text_GetFaceReaction(GlobalContext* globalCtx, u32 reactionSet); -void EnvFlags_UnsetAll(GlobalContext* globalCtx); -void EnvFlags_Set(GlobalContext* globalCtx, s16 flag); -void EnvFlags_Unset(GlobalContext* globalCtx, s16 flag); -s32 EnvFlags_Get(GlobalContext* globalCtx, s16 flag); +void EffFootmark_Init(PlayState* play); +void EffFootmark_Add(PlayState* play, MtxF* displayMatrix, Actor* actor, u8 id, Vec3f* location, u16 size, u8 red, u8 green, u8 blue, u16 alpha, u16 alphaChange, u16 fadeoutDelay); +void EffFootmark_Update(PlayState* play); +void EffFootmark_Draw(PlayState* play); +void SoundSource_InitAll(PlayState* play); +void SoundSource_UpdateAll(PlayState* play); +void SoundSource_PlaySfxAtFixedWorldPos(PlayState* play, Vec3f* worldPos, u32 duration, u16 sfxId); +void SoundSource_PlaySfxEachFrameAtFixedWorldPos(PlayState* play, Vec3f* worldPos, u32 duration, u16 sfxId); +u16 ElfMessage_GetFirstCycleHint(PlayState* play); + +u16 Text_GetFaceReaction(PlayState* play, u32 reactionSet); +void EnvFlags_UnsetAll(PlayState* play); +void EnvFlags_Set(PlayState* play, s16 flag); +void EnvFlags_Unset(PlayState* play, s16 flag); +s32 EnvFlags_Get(PlayState* play, s16 flag); s16 func_800F1460(s16 param_1); ActorCutscene* ActorCutscene_GetCutsceneImpl(s16 index); -void ActorCutscene_Init(GlobalContext* globalCtx, ActorCutscene* cutscenes, s32 num); +void ActorCutscene_Init(PlayState* play, ActorCutscene* cutscenes, s32 num); void func_800F15D8(Camera* camera); // void ActorCutscene_ClearWaiting(void); // void ActorCutscene_ClearNextCutscenes(void); @@ -1468,102 +1397,94 @@ s16 ActorCutscene_GetCurrentIndex(void); ActorCutscene* ActorCutscene_GetCutscene(s16 index); s16 ActorCutscene_GetAdditionalCutscene(s16 index); s16 ActorCutscene_GetLength(s16 index); -s32 func_800F2138(s8 arg0); +s32 func_800F2138(s32 arg0); s32 func_800F2178(s16 arg0); -s16 ActorCutscene_GetCurrentCamera(s16 index); +s16 ActorCutscene_GetCurrentSubCamId(s16 index); s16 func_800F21CC(void); s32 func_800F22C4(s16 param_1, Actor* actor); void ActorCutscene_SetReturnCamera(s16 index); -// void func_800F23E0(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE4 param_5, UNK_TYPE4 param_6); -f32 func_800F2478(f32 target, TransformData* transData, s32 refIdx); -void SkelCurve_Clear(SkelAnimeCurve* skelCurve); -s32 SkelCurve_Init(GlobalContext* globalCtx, SkelAnimeCurve* skelCurve, SkelCurveLimbList* limbListSeg, TransformUpdateIndex* transUpdIdx); -void SkelCurve_Destroy(GlobalContext* globalCtx, SkelAnimeCurve* skelCurve); -void SkelCurve_SetAnim(SkelAnimeCurve* skelCurve, TransformUpdateIndex* transUpdIdx, f32 arg2, f32 animFinalFrame, f32 animCurFrame, f32 animSpeed); -s32 SkelCurve_Update(GlobalContext* globalCtx, SkelAnimeCurve* skelCurve); -void SkelCurve_Draw(Actor* actor, GlobalContext* globalCtx, SkelAnimeCurve* skelCurve, OverrideCurveLimbDraw overrideLimbDraw, PostCurveLimbDraw postLimbDraw, s32 lod, Actor* thisx); void FireObj_SetPosition(FireObj* fire, Vec3f* pos); -void FireObj_Draw(GlobalContext* globalCtx, FireObj* fire); -void FireObj_Init(GlobalContext* globalCtx, FireObj* fire, FireObjInitParams* init, Actor* actor); -void FireObj_Destroy(GlobalContext* globalCtx, FireObj* fire); +void FireObj_Draw(PlayState* play, FireObj* fire); +void FireObj_Init(PlayState* play, FireObj* fire, FireObjInitParams* init, Actor* actor); +void FireObj_Destroy(PlayState* play, FireObj* fire); void FireObj_SetState2(FireObj* fire, f32 dynamicSizeStep, u8 newState); -void FireObj_Update(GlobalContext* globalCtx, FireObj* fire, Actor* actor); -s32 func_800F3940(GlobalContext* globalCtx); +void FireObj_Update(PlayState* play, FireObj* fire, Actor* actor); +s32 func_800F3940(PlayState* play); // void func_800F39B4(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE4 param_5); // void func_800F3A64(void); -void func_800F3B2C(GlobalContext* globalCtx); +void func_800F3B2C(PlayState* play); // void func_800F3B68(void); // void func_800F3C44(void); // void func_800F3ED4(void); void func_800F40A0(GameState* gameState, Player* player); void func_800F415C(Actor* actor, Vec3f* arg1, s16 arg2); -UNK_TYPE func_800F41E4(GlobalContext* globalCtx, ActorContext* actorCtx); +UNK_TYPE func_800F41E4(PlayState* play, ActorContext* actorCtx); -void func_800F4A10(GlobalContext* globalCtx); -void KaleidoSetup_Update(GlobalContext* globalCtx); -void KaleidoSetup_Init(GlobalContext* globalCtx); -void KaleidoSetup_Destroy(GlobalContext* globalCtx); +void func_800F4A10(PlayState* play); +void KaleidoSetup_Update(PlayState* play); +void KaleidoSetup_Init(PlayState* play); +void KaleidoSetup_Destroy(PlayState* play); -void Font_LoadChar(GlobalContext* globalCtx, u16 codePointIndex, s32 offset); -void Font_LoadCharNES(GlobalContext* globalCtx, u8 codePointIndex, s32 offset); +void Font_LoadChar(PlayState* play, u16 codePointIndex, s32 offset); +void Font_LoadCharNES(PlayState* play, u8 codePointIndex, s32 offset); void Font_LoadMessageBoxEndIcon(Font* font, u16 icon); void Font_LoadOrderedFont(Font* font); // void func_800F5090(void); // void func_800F50D4(void); -void Kankyo_Init(GlobalContext* globalCtx, EnvironmentContext* envCtx); +void Kankyo_Init(PlayState* play, EnvironmentContext* envCtx); u32 func_800F5954(u8* param_1, u32 param_2, u32 param_3, u8 param_4, u8 param_5); f32 Environment_LerpWeight(u16 max, u16 min, u16 val); // void func_800F5B10(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE2 param_5); // void func_800F5CD0(void); -void func_800F6834(GlobalContext* globalCtx, s32 waterLightsIndex); +void func_800F6834(PlayState* play, s32 waterLightsIndex); // void func_800F694C(void); // void func_800F6A04(void); // void func_800F6A40(void); // void func_800F6AB8(void); -void func_800F6B44(GlobalContext* globalCtx, EnvironmentContext* envCtx, s32 iParm3, s32 iParm4, s16* param_5); +void func_800F6B44(PlayState* play, EnvironmentContext* envCtx, s32 iParm3, s32 iParm4, s16* param_5); // void func_800F6CEC(void); // void func_800F6EA4(void); -// UNK_TYPE4 Kankyo_IsSceneUpsideDown(GlobalContext* globalCtx); -void func_800F6FF8(GlobalContext* globalCtx, EnvironmentContext* envCtx, LightContext* lightCtx); +// UNK_TYPE4 Kankyo_IsSceneUpsideDown(PlayState* play); +void func_800F6FF8(PlayState* play, EnvironmentContext* envCtx, LightContext* lightCtx); // void func_800F8554(void); // void func_800F88C4(void); // void func_800F8970(void); // void func_800F8A9C(void); -// void func_800F8CD4(GlobalContext* globalCtx, EnvironmentContext* envCtx, LightContext* lightCtx, s32 param_4, UNK_TYPE4 param_5, UNK_TYPE4 param_6); +// void func_800F8CD4(PlayState* play, EnvironmentContext* envCtx, LightContext* lightCtx, s32 param_4, UNK_TYPE4 param_5, UNK_TYPE4 param_6); // void func_800F8D84(void); // void func_800F9728(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE4 param_5, UNK_TYPE4 param_6, UNK_TYPE4 param_7); -void func_800F9824(GlobalContext* globalCtx, EnvironmentContext* envCtx, View* view, GraphicsContext* gfxCtx, Vec3f vec, f32 arg5, f32 arg6, s8 arg7, s8 arg8); +void func_800F9824(PlayState* play, EnvironmentContext* envCtx, View* view, GraphicsContext* gfxCtx, Vec3f vec, f32 arg5, f32 arg6, s8 arg7, s8 arg8); // void func_800FA39C(void); // void func_800FA3C4(void); // void func_800FA9FC(void); -void func_800FAAB4(GlobalContext* globalCtx, u8 arg1); +void func_800FAAB4(PlayState* play, u8 arg1); // void func_800FAC20(void); // void func_800FAF74(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE1 param_5); // void func_800FB010(void); -void Environment_AddLightningBolts(GlobalContext* globalCtx, u8 num); +void Environment_AddLightningBolts(PlayState* play, u8 num); // void func_800FB388(void); -void func_800FB758(GlobalContext* globalCtx); +void func_800FB758(PlayState* play); // void func_800FB9B4(void); // void func_800FBCBC(void); -void Kankyo_InitGameOverLights(GlobalContext* globalCtx); -void Kankyo_FadeInGameOverLights(GlobalContext* globalCtx); -void Kankyo_FadeOutGameOverLights(GlobalContext* globalCtx); +void Kankyo_InitGameOverLights(PlayState* play); +void Kankyo_FadeInGameOverLights(PlayState* play); +void Kankyo_FadeOutGameOverLights(PlayState* play); // void func_800FC3DC(void); void func_800FC444(GraphicsContext* gfxCtx, u8 arg1, u8 arg2, u8 arg3, u8 arg4, UNK_TYPE arg5); // void func_800FC64C(void); -s32 func_800FD2B4(GlobalContext* globalCtx, f32 arg1, f32 arg2, f32 arg3, f32 arg4); +s32 func_800FD2B4(PlayState* play, f32 arg1, f32 arg2, f32 arg3, f32 arg4); void func_800FD538(Color_RGB8* param_1, Color_RGB8* param_2, f32 param_3, Vec3s* param_4); -void func_800FD59C(GlobalContext* globalCtx, Color_RGB8* pzParm2, f32 fParm3); -void func_800FD5E0(GlobalContext* globalCtx, Color_RGB8* pzParm2, f32 fParm3); -void func_800FD654(GlobalContext* globalCtx, Color_RGB8* pzParm2, f32 fParm3); -void func_800FD698(GlobalContext* globalCtx, s16 arg1, s16 arg2, f32 arg3); +void func_800FD59C(PlayState* play, Color_RGB8* pzParm2, f32 fParm3); +void func_800FD5E0(PlayState* play, Color_RGB8* pzParm2, f32 fParm3); +void func_800FD654(PlayState* play, Color_RGB8* pzParm2, f32 fParm3); +void func_800FD698(PlayState* play, s16 arg1, s16 arg2, f32 arg3); // u32 get_days_elapsed(void); // void reset_days_elapsed(void); // u32 get_current_day(void); void func_800FD750(u16 seqId); // void func_800FD768(void); -void func_800FD78C(GlobalContext* globalCtx); -void func_800FD858(GlobalContext* globalCtx); +void func_800FD78C(PlayState* play); +void func_800FD858(PlayState* play); void func_800FD928(s32 param_1); // void func_800FD980(void); // void func_800FDAF8(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE4 param_5); @@ -1573,19 +1494,19 @@ void func_800FD928(s32 param_1); void func_800FE484(void); void func_800FE498(void); // void func_800FE4A8(void); -u32 func_800FE4B8(GlobalContext* globalCtx); +u32 func_800FE4B8(PlayState* play); // void func_800FE590(void); // void func_800FE5D0(void); // UNK_TYPE4 func_800FE610(void); -u32 func_800FE620(GlobalContext* globalCtx); +u32 func_800FE620(PlayState* play); void func_800FE658(f32 arg0); // UNK_TYPE4 func_800FE6F8(UNK_TYPE4 param_1, s16 param_2, s16 param_3); // void func_800FE778(void); // void func_800FE788(void); // void func_800FE798(void); void func_800FE7A8(Color_RGBA8* inColor, Color_RGBA8* outColor); -s32 func_800FE9B4(GlobalContext* globalCtx); -void func_800FEA50(GlobalContext* globalCtx); +s32 func_800FE9B4(PlayState* play); +void func_800FEA50(PlayState* play); void func_800FEAB0(void); // void func_800FEAC0(void); void func_800FEAF4(EnvironmentContext* envCtx); @@ -1650,7 +1571,7 @@ void Color_RGBA8_Copy(Color_RGBA8* dst, Color_RGBA8* src); void func_801000A4(u16 sfxId); void func_801000CC(u16 sfxId); void Lib_PlaySfxAtPos(Vec3f* pos, u16 sfxId); -void Lib_Vec3f_TranslateAndRotateY(Vec3f* translation, s16 a, Vec3f* src, Vec3f* dst); +void Lib_Vec3f_TranslateAndRotateY(Vec3f* translation, s16 rotAngle, Vec3f* src, Vec3f* dst); void Lib_LerpRGB(Color_RGB8* a, Color_RGB8* b, f32 t, Color_RGB8* dst); f32 Math_Vec3f_StepTo(Vec3f* start, Vec3f* target, f32 speed); void Lib_Nop801004FC(void); @@ -1658,13 +1579,13 @@ void* Lib_SegmentedToVirtual(void* ptr); void* Lib_SegmentedToVirtualNull(void* ptr); void* Lib_PhysicalToVirtual(void* ptr); void* Lib_PhysicalToVirtualNull(void* ptr); -void LifeMeter_Init(GlobalContext* globalCtx); -void LifeMeter_UpdateColors(GlobalContext* globalCtx); -s32 LifeMeter_SaveInterfaceHealth(GlobalContext* globalCtx); -s32 LifeMeter_IncreaseInterfaceHealth(GlobalContext* globalCtx); -s32 LifeMeter_DecreaseInterfaceHealth(GlobalContext* globalCtx); -void LifeMeter_Draw(GlobalContext* globalCtx); -void LifeMeter_UpdateSizeAndBeep(GlobalContext* globalCtx); +void LifeMeter_Init(PlayState* play); +void LifeMeter_UpdateColors(PlayState* play); +s32 LifeMeter_SaveInterfaceHealth(PlayState* play); +s32 LifeMeter_IncreaseInterfaceHealth(PlayState* play); +s32 LifeMeter_DecreaseInterfaceHealth(PlayState* play); +void LifeMeter_Draw(PlayState* play); +void LifeMeter_UpdateSizeAndBeep(PlayState* play); bool LifeMeter_IsCritical(void); void Lights_PointSetInfo(LightInfo* info, s16 x, s16 y, s16 z, u8 r, u8 g, u8 b, s16 radius, s32 type); void Lights_PointNoGlowSetInfo(LightInfo* info, s16 x, s16 y, s16 z, u8 r, u8 g, u8 b, s16 radius); @@ -1676,23 +1597,23 @@ void Lights_Reset(Lights* lights, u8 r, u8 g, u8 b); void Lights_Draw(Lights* lights, GraphicsContext* gfxCtx); Light* Lights_FindSlot(Lights* lights); void Lights_BindPointWithReference(Lights* lights, LightParams* params, Vec3f* pos); -void Lights_BindPoint(Lights* lights, LightParams* params, GlobalContext* globalCtx); +void Lights_BindPoint(Lights* lights, LightParams* params, PlayState* play); void Lights_BindDirectional(Lights* lights, LightParams* params, void* unused); -void Lights_BindAll(Lights* lights, LightNode* listHead, Vec3f* refPos, GlobalContext* globalCtx); +void Lights_BindAll(Lights* lights, LightNode* listHead, Vec3f* refPos, PlayState* play); LightNode* Lights_FindBufSlot(); void Lights_FreeNode(LightNode* light); -void LightContext_Init(GlobalContext* globalCtx, LightContext* lightCtx); +void LightContext_Init(PlayState* play, LightContext* lightCtx); void LightContext_SetAmbientColor(LightContext* lightCtx, u8 r, u8 g, u8 b); void func_80102544(LightContext* lightCtx, u8 a1, u8 a2, u8 a3, s16 numLights, s16 sp16); Lights* LightContext_NewLights(LightContext* lightCtx, GraphicsContext* gfxCtx); -void LightContext_InitList(GlobalContext* globalCtx, LightContext* lightCtx); -void LightContext_DestroyList(GlobalContext* globalCtx, LightContext* lightCtx); -LightNode* LightContext_InsertLight(GlobalContext* globalCtx, LightContext* lightCtx, LightInfo* info); -void LightContext_RemoveLight(GlobalContext* globalCtx, LightContext* lightCtx, LightNode* light); +void LightContext_InitList(PlayState* play, LightContext* lightCtx); +void LightContext_DestroyList(PlayState* play, LightContext* lightCtx); +LightNode* LightContext_InsertLight(PlayState* play, LightContext* lightCtx, LightInfo* info); +void LightContext_RemoveLight(PlayState* play, LightContext* lightCtx, LightNode* light); Lights* Lights_NewAndDraw(GraphicsContext* gfxCtx, u8 ambientR, u8 ambientG, u8 ambientB, u8 numLights, u8 r, u8 g, u8 b, s8 x, s8 y, s8 z); Lights* Lights_New(GraphicsContext* gfxCtx, u8 ambientR, u8 ambientG, u8 ambientB); -void Lights_GlowCheck(GlobalContext* globalCtx); -void Lights_DrawGlow(GlobalContext* globalCtx); +void Lights_GlowCheck(PlayState* play); +void Lights_DrawGlow(PlayState* play); void* ZeldaArena_Malloc(size_t size); void* ZeldaArena_MallocR(size_t size); void* ZeldaArena_Realloc(void* oldPtr, size_t newSize); @@ -1708,7 +1629,7 @@ u8 ZeldaArena_IsInitialized(); // void func_80102EA4(void); void func_80102EB4(u32 param_1); void func_80102ED0(u32 param_1); -// void func_80102EF0(void); +s32 func_80102EF0(PlayState* play); // void func_80102F9C(void); // void func_80103090(void); // void func_801030B4(void); @@ -1721,25 +1642,25 @@ void func_80102ED0(u32 param_1); // void func_801045AC(void); // void func_80104AE8(void); // void func_80104C80(void); -void func_80104CF4(GlobalContext* globalCtx); +void func_80104CF4(PlayState* play); // void func_80104F34(void); -// void func_80105294(void); -// void func_80105318(void); +s32 func_80105294(void); +s16 func_80105318(void); // void func_80105328(void); // void func_8010534C(void); -void func_8010549C(GlobalContext* globalCtx, void* segmentAddress); -void func_8010565C(GlobalContext* globalCtx, u8 num, void* segmentAddress); -void func_80105818(GlobalContext* globalCtx, u32 uParm2, TransitionActorEntry* puParm3); -// void func_80105A40(void); -// void func_80105B34(void); -// void func_80105C40(void); +void func_8010549C(PlayState* play, void* segmentAddress); +void func_8010565C(PlayState* play, u8 num, void* segmentAddress); +void func_80105818(PlayState* play, u32 uParm2, TransitionActorEntry* puParm3); +void func_80105A40(void); +void func_80105B34(PlayState* play); +void func_80105C40(s16 arg0); // void func_80105FE0(void); // void func_80106408(void); // void func_80106450(void); // void func_801064CC(void); -// void func_80106530(void); +s32 func_80106530(PlayState* play); // void func_8010657C(void); -// void func_80106644(void); +void func_80106644(PlayState* play, s16 arg1, s16 arg2, s16 arg3); // void func_8010683C(void); // void func_801068B4(void); // void func_801068D8(void); @@ -1754,7 +1675,7 @@ void func_80105818(GlobalContext* globalCtx, u32 uParm2, TransitionActorEntry* p // void func_80108A64(void); // void func_80108AF8(void); // void func_801090B0(void); -// void func_80109124(void); +s32 func_80109124(s16 arg0); // void func_801091F0(void); // void func_80109428(void); // void func_801094A0(void); @@ -1796,21 +1717,21 @@ void func_80105818(GlobalContext* globalCtx, u32 uParm2, TransitionActorEntry* p // void func_80109E70(void); // void func_80109EF8(void); // void func_80109F78(void); -s32 func_8010A000(GlobalContext* globalCtx); -s32 func_8010A074(GlobalContext* globalCtx); -s32 func_8010A0A4(GlobalContext* globalCtx); -// void func_8010A0F0(void); -// void func_8010A164(void); -// void func_8010A194(void); -// void func_8010A208(void); -// void func_8010A238(void); -// void func_8010A2AC(void); -void func_8010A2DC(GlobalContext* globalCtx); -void func_8010A33C(GlobalContext* globalCtx, s16 param_2); -// void func_8010A410(void); -// void func_8010A430(void); -// void func_8010A54C(void); -// void func_8010A580(void); +s32 Map_GetDungeonOrBossAreaIndex(PlayState* play); +s32 Map_IsInDungeonOrBossArea(PlayState* play); +s32 func_8010A0A4(PlayState* play); +// void Map_GetDungeonAreaIndex(PlayState* play); +// void Map_IsInDungeonArea(PlayState* play); +// void Map_GetBossAreaIndex(PlayState* play); +// void Map_IsInBossArea(PlayState* play); +// void func_8010A238(PlayState* play); +// void func_8010A2AC(PlayState* play); +void Minimap_SavePlayerRoomInitInfo(PlayState* play); +void Map_InitRoomData(PlayState* play, s16 room); +// void Map_Destroy(void); +// void Map_Init(PlayState* play); +// void Minimap_Draw(PlayState* play); +// void Map_Update(PlayState* play); // void func_8010A760(void); // void func_8010A7CC(void); // void func_8010A814(void); @@ -1862,7 +1783,7 @@ void func_8010A33C(GlobalContext* globalCtx, s16 param_2); // void func_8010BEBC(void); // void func_8010BEF0(void); // void func_8010BF24(void); -s32 func_8010BF58(Actor* actor, GlobalContext* globalCtx, s32* param_3, UNK_PTR param_4, s32* param_5); +s32 func_8010BF58(Actor* actor, PlayState* play, s32* param_3, UNK_PTR param_4, s32* param_5); void Nmi_Init(void); void Nmi_SetPrenmiStart(void); // s32 Nmi_GetPrenmiHasStarted(void); @@ -1901,7 +1822,7 @@ void func_8010EA9C(s32 arg0, s32 arg1); // void func_8010EB50(void); // void func_8010EBA0(void); // void func_8010EC54(void); -void func_8010EE74(GlobalContext* globalCtx, s32 day); +void func_8010EE74(PlayState* play, s32 day); void Interface_ChangeAlpha(u16 param_1); // void func_8010EF9C(void); // void func_8010F0D4(void); @@ -1909,33 +1830,32 @@ void Interface_ChangeAlpha(u16 param_1); // void func_80110038(void); // void func_80111CB4(void); // void func_801129E4(void); -void func_80112AFC(GlobalContext* globalCtx); -void func_80112B40(GlobalContext* globalCtx, u8 arg1); -// void func_80112BE4(void); +void func_80112AFC(PlayState* play); +void Interface_LoadItemIconImpl(PlayState* play, u8 btn); +void Interface_LoadItemIcon(PlayState* play, u8 btn); // void func_80112C0C(void); -u32 Item_Give(GlobalContext* globalCtx, u8 param_2); -// void func_801143CC(void); -UNK_TYPE func_80114978(UNK_TYPE arg0); -void func_801149A0(s32 itemId, s16 slotId); -// void func_80114A9C(void); -// void func_80114B84(void); -// void func_80114CA0(void); -s32 Interface_HasEmptyBottle(void); -s32 Interface_HasItemInBottle(u8 itemId); -// void func_80114FD0(void); -// void func_80115130(void); -// void func_801152B8(void); +u8 Item_Give(PlayState* play, u8 item); +u8 Item_CheckObtainability(u8 item); +void Inventory_DeleteItem(s16 item, s16 slot); +void Inventory_UnequipItem(s16 item); +s32 Inventory_ReplaceItem(PlayState* play, u8 oldItem, u8 newItem); +void Inventory_UpdateDeitySwordEquip(PlayState* play) ; +s32 Inventory_HasEmptyBottle(void); +s32 Inventory_HasItemInBottle(u8 item); +void Inventory_UpdateBottleItem(PlayState* play, u8 item, u8 btn); +s32 Inventory_ConsumeFairy(PlayState* play); +void Inventory_UpdateItem(PlayState* play, s16 slot, s16 item); // void func_801153C8(void); // void func_80115428(void); -void func_8011552C(GlobalContext* globalCtx, s16 arg1); +void func_8011552C(PlayState* play, s16 arg1); // void func_801155B4(void); // void func_80115764(void); -void func_80115844(GlobalContext* globalCtx, s16 param_2); -s32 func_80115908(GlobalContext* globalCtx, u8 param_2); -void func_801159c0(s16 param_1); -void func_801159EC(s16 arg0); -void func_80115A14(s16 arg0, s16 arg1); -void Parameter_AddMagic(GlobalContext* globalCtx, s16 arg1); +void func_80115844(PlayState* play, s16 param_2); +s32 Health_ChangeBy(PlayState* play, s16 healthChange); +void Health_GiveHearts(s16 hearts); +void Rupees_ChangeBy(s16 rupeeChange); +void Inventory_ChangeAmmo(s16 item, s16 ammoChange); +void Parameter_AddMagic(PlayState* play, s16 arg1); void func_80115D5C(GameState* gamestate); // void func_80115DB4(void); // void func_80116088(void); @@ -1952,12 +1872,12 @@ void func_80115D5C(GameState* gamestate); // void func_80118BA4(void); // void func_80119030(void); // void func_80119610(void); -void func_8011B4E0(GlobalContext* globalCtx, s32 arg1); +void func_8011B4E0(PlayState* play, s32 arg1); // void func_8011B5C0(void); // void func_8011B9E0(void); // void func_8011BF70(void); // void func_8011C4C4(void); -void func_8011C808(GlobalContext* globalCtx); +void func_8011C808(PlayState* play); // void func_8011C898(void); // void func_8011CA64(void); // void func_8011E3B4(void); @@ -1968,112 +1888,90 @@ void func_8011C808(GlobalContext* globalCtx); // void func_80121064(void); // void func_801210E0(void); // void func_80121F94(void); -void func_80121FC4(GlobalContext* globalCtx); -Path* Path_GetByIndex(GlobalContext* globalCtx, s16 index, s16 max); +void func_80121FC4(PlayState* play); +Path* Path_GetByIndex(PlayState* play, s16 index, s16 max); f32 Path_OrientAndGetDistSq(Actor* actor, Path* path, s16 waypoint, s16* yaw); void Path_CopyLastPoint(Path* path, Vec3f* dest); + void FrameAdvance_Init(FrameAdvanceContext* frameAdvCtx); s32 FrameAdvance_Update(FrameAdvanceContext* frameAdvCtx, Input* input); -void func_801226E0(GlobalContext* globalCtx, s8 arg1); -void func_80122744(GlobalContext* globalCtx, UNK_PTR arg1, u32 arg2, Vec3s* arg3); -s32 func_80122760(GlobalContext* globalCtx, UNK_PTR arg1, f32 arg2); -void func_80122868(GlobalContext* globalCtx, Player* player); -void func_801229A0(GlobalContext* globalCtx, Player* player); -// void func_801229EC(void); -// void func_801229FC(void); -// void func_80122BA4(void); -// void func_80122C20(void); -// void func_80122D44(void); -// void func_80122ED8(void); -// void func_80122EEC(void); + +s32 func_801226E0(PlayState* play, s32 arg1); +s32 func_80122744(PlayState* play, struct_80122744_arg1* arg1, u32 arg2, Vec3s* arg3); +s32 func_80122760(PlayState* play, struct_80122744_arg1* arg1, f32 arg2); +void func_80122868(PlayState* play, Player* player); +void func_801229A0(PlayState* play, Player* player); +void func_801229EC(UNK_TYPE arg0, UNK_TYPE arg1); +void func_801229FC(Player* player); +void func_80122BA4(PlayState* play, struct_80122D44_arg1* arg1, s32 arg2, s32 alpha); +void func_80122C20(PlayState* play, struct_80122D44_arg1* arg1); +void func_80122D44(PlayState* play, struct_80122D44_arg1* arg1); +u8 Player_MaskIdToItemId(s32 maskIdMinusOne); +u8 Player_GetCurMaskItemId(PlayState* play); void func_80122F28(Player* player); -s32 func_80122F9C(GlobalContext* globalCtx); -s32 func_80122FCC(GlobalContext* globalCtx); -void func_8012300C(GlobalContext* globalCtx, s32 arg1); -void func_8012301C(s32 iParm1, GlobalContext* globalCtx); -void func_80123140(GlobalContext* globalCtx, Player* player); -u32 func_80123358(GlobalContext* globalCtx, Player* player); -s32 Player_InCsMode(GameState* gameState); -// void func_80123420(void); -// void func_80123434(void); -// void func_80123448(void); -// void func_801234B0(void); -// void func_801234D4(void); -s32 func_80123590(GlobalContext* globalCtx, Actor* actor); -// void func_8012364C(void); -s32 func_80123810(GlobalContext* globalCtx); -// void func_80123960(void); -// void func_801239AC(void); -void func_80123AA4(Player* player, s32 arg1); -// void func_80123BD4(void); -// void func_80123C58(void); -void Player_SetEquipmentData(GlobalContext* globalCtx, Player* this); -void func_80123D50(GlobalContext* globalCtx, Player* player, UNK_TYPE arg2, UNK_TYPE arg3); +s32 func_80122F9C(PlayState* play); +s32 func_80122FCC(PlayState* play); +void func_8012300C(PlayState* play, s32 arg1); +void func_8012301C(Player* player, PlayState* play); +void func_80123140(PlayState* play, Player* player); +s32 Player_InBlockingCsMode(PlayState* play, Player* player); +s32 Player_InCsMode(PlayState* play); +s32 func_80123420(Player* player); +s32 func_80123434(Player* player); +s32 func_80123448(PlayState* play); +s32 Player_IsGoronOrDeku(Player* player); +s32 func_801234D4(PlayState* play); +s32 func_80123590(PlayState* play, Actor* actor); +s32 func_8012364C(PlayState* play, Player* player, s32 arg2); +s32 func_80123810(PlayState* play); +s32 Player_ActionToModelGroup(Player* player, s32 actionParam); +void func_801239AC(Player* player); +void Player_SetModels(Player* player, s32 arg1); +void Player_SetModelGroup(Player* player, s32 modelGroup); +void func_80123C58(Player* player); +void Player_SetEquipmentData(PlayState* play, Player* this); +void func_80123D50(PlayState* play, Player* player, s32 itemId, s32 actionParam); void func_80123DA4(Player* player); -// void func_80123DC0(void); -void func_80123E90(GlobalContext* globalCtx, Actor* actor); -void func_80123F2C(GlobalContext* globalCtx, s32 arg1); -s32 func_80123F48(GlobalContext* globalCtx, Vec3f* arg1, f32 arg2, f32 arg3); -s32 func_80124020(void); -u8 Player_GetMask(GlobalContext* globalCtx); -void Player_RemoveMask(GlobalContext* globalCtx); -s32 func_8012405C(GlobalContext* globalCtx); -s32 func_80124088(GlobalContext* globalCtx); -s32 func_801240C8(Player* player); -// void func_801240DC(void); -// void func_80124110(void); -// void func_80124148(void); -// void func_80124168(void); -s32 func_80124190(Player* player); -// void func_801241B4(void); -// void func_801241E0(void); -// void func_8012420C(void); -// void func_8012422C(void); +void func_80123DC0(Player* player); +void func_80123E90(PlayState* play, Actor* actor); +s32 func_80123F2C(PlayState* play, s32 ammo); +s32 Player_IsBurningStickInRange(PlayState* play, Vec3f* pos, f32 xzRange, f32 yRange); +u8 Player_GetStrength(void); +u8 Player_GetMask(PlayState* play); +void Player_RemoveMask(PlayState* play); +s32 Player_HasMirrorShieldEquipped(PlayState* play); +s32 Player_IsHoldingMirrorShield(PlayState* play); +s32 Player_IsHoldingHookshot(Player* player); +s32 func_801240DC(Player* player); +s32 func_80124110(Player* player, s32 actionParam); +s32 func_80124148(Player* player); +s32 Player_ActionToMeleeWeapon(s32 actionParam); +s32 Player_GetMeleeWeaponHeld(Player* player); +s32 Player_IsHoldingTwoHandedWeapon(Player* player); +s32 Player_ActionToBottle(Player* player, s32 actionParam); +s32 Player_GetBottleHeld(Player* Player); +s32 Player_ActionToExplosive(Player* player, s32 actionParam); s32 Player_GetExplosiveHeld(Player* player); -// void func_80124278(void); +s32 func_80124278(Actor* actor, s32 arg1); s32 func_801242B4(Player* player); -// void func_801242DC(void); -// void func_80124420(void); -// void func_80124618(void); -// void func_801246F4(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE4 param_5, UNK_TYPE4 param_6, UNK_TYPE1 param_7, UNK_TYPE4 param_8, UNK_TYPE4 param_9, UNK_TYPE4 param_10, UNK_TYPE4 param_11); -// void func_80124870(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE4 param_5, UNK_TYPE4 param_6, UNK_TYPE4 param_7, UNK_TYPE4 param_8); -// void func_80124CC4(void); -// void func_80124F18(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE4 param_5); -// void func_80124FF0(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE4 param_5, UNK_TYPE4 param_6, UNK_TYPE4 param_7, UNK_TYPE4 param_8, UNK_TYPE4 param_9, UNK_TYPE2 param_10); -// void func_801251C4(void); -// void func_80125318(void); -// void func_80125340(void); -// void func_8012536C(void); -// void func_801253A4(void); -// void func_80125500(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE4 param_5); -// void func_80125580(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE4 param_5, UNK_TYPE4 param_6); -// void func_80125CE0(void); -// void func_80125D4C(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE4 param_5, UNK_TYPE4 param_6); -// void func_801262C8(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE4 param_5, UNK_TYPE4 param_6); -// void func_801263FC(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE4 param_5, UNK_TYPE4 param_6); -s32 func_80126440(GlobalContext* globalCtx, Collider* param_2, s32* param_3, Vec3f* param_4, Vec3f* param_5); -// void func_801265C8(void); -// void func_8012669C(void); -// void func_80126808(void); -void func_8012697C(GlobalContext* globalCtx, Player* player); -// void func_80126AB4(void); -// void func_80126B8C(void); -// void func_80126BD0(void); -// void func_801271B0(void); -// void func_80127438(void); -// void func_80127488(void); -// void func_8012754C(void); -// void func_80127594(void); -// void func_801278F8(void); -// void func_80127A60(void); -// void func_80127B64(void); -// void func_80127BE8(void); -// void func_80127DA4(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE4 param_5, UNK_TYPE4 param_6, UNK_TYPE4 param_7); -// void func_80128388(void); -// void func_801284A0(void); -// void func_80128640(void); -// void func_80128B74(void); -// void func_80128BD0(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE1 param_5, UNK_TYPE4 param_6); +s32 func_801242DC(PlayState* play); +void func_80124420(Player* player); +void func_80124618(struct_80124618 arg0[], f32 curFrame, Vec3f* arg2); +void func_801246F4(PlayState* play, void** skeleton, Vec3s* jointTable, s32 dListCount, s32 lod, s32 tunic, s32 boots, s32 face, OverrideLimbDrawFlex overrideLimbDraw, PostLimbDrawFlex postLimbDraw, Actor* actor); +void func_80125318(Vec3f* arg0, Vec3s* arg1); +void Player_DrawZoraShield(PlayState* play, Player* player); +void func_80125500(PlayState* play, Player* player, s32 limbIndex, Vec3f* pos, Vec3s* rot); +s32 func_80125D4C(PlayState* play, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, Actor* actor); +s32 func_801262C8(PlayState* play, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, Actor* actor); +s32 func_801263FC(PlayState* play, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, Actor* thisx); +s32 func_80126440(PlayState* play, ColliderQuad* collider, WeaponInfo* weaponInfo, Vec3f* arg3, Vec3f* arg4); +void Player_DrawGetItem(PlayState* play, Player* player); +void func_80126B8C(PlayState* play, Player* player); +s32 func_80127438(PlayState* play, Player* player, s32 maskId); +s32 func_80128640(PlayState* play, Player* player, Gfx* dlist); +void func_80128B74(PlayState* play, Player* player, s32 limbIndex); +void func_80128BD0(PlayState* play, s32 limbIndex, Gfx** dList1, Gfx** dList2, Vec3s* rot, Actor* actor); + void PreNMI_Stop(PreNMIContext* prenmiCtx); void PreNMI_Update(PreNMIContext* prenmiCtx); void PreNMI_Draw(PreNMIContext* prenmiCtx); @@ -2102,7 +2000,7 @@ void Quake_Init(void); s16 Quake_Add(Camera* camera, u32 callbackIdx); u32 Quake_RemoveFromIdx(s16 idx); s16 Quake_Calc(Camera* camera, QuakeCamCalc* camData); -void Distortion_Init(GlobalContext* globalCtx); +void Distortion_Init(PlayState* play); void Distortion_SetCountdown(s16 countdown); s16 Distortion_GetCountdown(void); s16 Distortion_GetType(void); @@ -2133,7 +2031,7 @@ void func_8012C1C0(GraphicsContext* gfxCtx); Gfx* func_8012C1EC(Gfx* gfx); void func_8012C214(GraphicsContext* gfxCtx); void func_8012C240(GraphicsContext* gfxCtx); -void func_8012C268(GlobalContext* globalCtx); +void func_8012C268(PlayState* play); void func_8012C28C(GraphicsContext* gfxCtx); Gfx* func_8012C2B4(Gfx* gfx); void func_8012C2DC(GraphicsContext* gfxCtx); @@ -2191,30 +2089,30 @@ Gfx* Gfx_PrimColor(GraphicsContext* gfxCtx, s32 lodfrac, s32 r, s32 g, s32 b, s3 void func_8012CF0C(GraphicsContext* gfxCtx, s32 clearFb, s32 clearZb, u8 r, u8 g, u8 b); void func_8012D374(GraphicsContext* gfxCtx, u8 r, u8 g, u8 b); void func_8012D40C(f32* param_1, f32* param_2, s16* param_3); -void Room_nop8012D510(GlobalContext* globalCtx, Room* room, UNK_PTR param_3, UNK_TYPE1 param_4); -void Room_DrawType3Mesh(GlobalContext* globalCtx, Room* room, u32 flags); -void Room_DrawType0Mesh(GlobalContext* globalCtx, Room* room, u32 flags); -void Room_DrawType2Mesh(GlobalContext* globalCtx, Room* room, u32 flags); -void func_8012DEE8(GlobalContext* globalCtx, Room* room, u32 flags); -u32 func_8012E254(s32 param_1, GlobalContext* globalCtx); -void func_8012E32C(GlobalContext* globalCtx, Room* room, u32 flags); -void Room_DrawType1Mesh(GlobalContext* globalCtx, Room* room, u32 flags); -void Room_Init(GlobalContext* globalCtx, RoomContext* roomCtx); -u32 Room_AllocateAndLoad(GlobalContext* globalCtx, RoomContext* roomCtx); -s32 Room_StartRoomTransition(GlobalContext* globalCtx, RoomContext* roomCtx, s32 index); -s32 Room_HandleLoadCallbacks(GlobalContext* globalCtx, RoomContext* roomCtx); -void Room_Draw(GlobalContext* globalCtx, Room* room, u32 flags); -void func_8012EBF8(GlobalContext* globalCtx, RoomContext* roomCtx); -s32 Inventory_GetBtnBItem(GlobalContext* globalCtx); +void Room_nop8012D510(PlayState* play, Room* room, UNK_PTR param_3, UNK_TYPE1 param_4); +void Room_DrawType3Mesh(PlayState* play, Room* room, u32 flags); +void Room_DrawType0Mesh(PlayState* play, Room* room, u32 flags); +void Room_DrawType2Mesh(PlayState* play, Room* room, u32 flags); +void func_8012DEE8(PlayState* play, Room* room, u32 flags); +u32 func_8012E254(s32 param_1, PlayState* play); +void func_8012E32C(PlayState* play, Room* room, u32 flags); +void Room_DrawType1Mesh(PlayState* play, Room* room, u32 flags); +void Room_Init(PlayState* play, RoomContext* roomCtx); +u32 Room_AllocateAndLoad(PlayState* play, RoomContext* roomCtx); +s32 Room_StartRoomTransition(PlayState* play, RoomContext* roomCtx, s32 index); +s32 Room_HandleLoadCallbacks(PlayState* play, RoomContext* roomCtx); +void Room_Draw(PlayState* play, Room* room, u32 flags); +void func_8012EBF8(PlayState* play, RoomContext* roomCtx); +s32 Inventory_GetBtnBItem(PlayState* play); void Inventory_ChangeEquipment(s16 value); -u8 Inventory_DeleteEquipment(GlobalContext* globalCtx, s16 equipment); +u8 Inventory_DeleteEquipment(PlayState* play, s16 equipment); void Inventory_ChangeUpgrade(s16 upgrade, u32 value); s32 Inventory_IsMapVisible(s16 sceneNum); void Inventory_SetMapVisibility(s16 tingleIndex); void Inventory_SaveDekuPlaygroundHighScore(s16 timerId); void Inventory_IncrementSkullTokenCount(s16 sceneIndex); s16 Inventory_GetSkullTokenCount(s16 sceneIndex); -void Inventory_SaveLotteryCodeGuess(GlobalContext* globalCtx); +void Inventory_SaveLotteryCodeGuess(PlayState* play); s32 Object_Spawn(ObjectContext* objectCtx, s16 id); void Object_InitBank(GameState* gameState, ObjectContext* objectCtx); void Object_UpdateBank(ObjectContext* objectCtx); @@ -2222,167 +2120,148 @@ s32 Object_GetIndex(ObjectContext* objectCtx, s16 id); s32 Object_IsLoaded(ObjectContext* objectCtx, s32 index); void Object_LoadAll(ObjectContext* objectCtx); void* func_8012F73C(ObjectContext* objectCtx, s32 iParm2, s16 id); -void Scene_HeaderCmdSpawnList(GlobalContext* globalCtx, SceneCmd* cmd); -void Scene_HeaderCmdActorList(GlobalContext* globalCtx, SceneCmd* cmd); -void Scene_HeaderCmdActorCutsceneCamList(GlobalContext* globalCtx, SceneCmd* cmd); -void Scene_HeaderCmdColHeader(GlobalContext* globalCtx, SceneCmd* cmd); -void Scene_HeaderCmdRoomList(GlobalContext* globalCtx, SceneCmd* cmd); -void Scene_HeaderCmdEntranceList(GlobalContext* globalCtx, SceneCmd* cmd); -void Scene_HeaderCmdSpecialFiles(GlobalContext* globalCtx, SceneCmd* cmd); -void Scene_HeaderCmdRoomBehavior(GlobalContext* globalCtx, SceneCmd* cmd); -void Scene_HeaderCmdMesh(GlobalContext* globalCtx, SceneCmd* cmd); -void Scene_HeaderCmdObjectList(GlobalContext* globalCtx, SceneCmd* cmd); -void Scene_HeaderCmdLightList(GlobalContext* globalCtx, SceneCmd* cmd); -void Scene_HeaderCmdPathList(GlobalContext* globalCtx, SceneCmd* cmd); -void Scene_HeaderCmdTransiActorList(GlobalContext* globalCtx, SceneCmd* cmd); +void Scene_HeaderCmdSpawnList(PlayState* play, SceneCmd* cmd); +void Scene_HeaderCmdActorList(PlayState* play, SceneCmd* cmd); +void Scene_HeaderCmdActorCutsceneCamList(PlayState* play, SceneCmd* cmd); +void Scene_HeaderCmdColHeader(PlayState* play, SceneCmd* cmd); +void Scene_HeaderCmdRoomList(PlayState* play, SceneCmd* cmd); +void Scene_HeaderCmdEntranceList(PlayState* play, SceneCmd* cmd); +void Scene_HeaderCmdSpecialFiles(PlayState* play, SceneCmd* cmd); +void Scene_HeaderCmdRoomBehavior(PlayState* play, SceneCmd* cmd); +void Scene_HeaderCmdMesh(PlayState* play, SceneCmd* cmd); +void Scene_HeaderCmdObjectList(PlayState* play, SceneCmd* cmd); +void Scene_HeaderCmdLightList(PlayState* play, SceneCmd* cmd); +void Scene_HeaderCmdPathList(PlayState* play, SceneCmd* cmd); +void Scene_HeaderCmdTransiActorList(PlayState* play, SceneCmd* cmd); void Door_InitContext(GameState* gameState, DoorContext* doorCtx); -void Scene_HeaderCmdEnvLightSettings(GlobalContext* globalCtx, SceneCmd* cmd); -s32 Scene_LoadAreaTextures(GlobalContext* globalCtx, s32 fileIndex); -void Scene_HeaderCmdSkyboxSettings(GlobalContext* globalCtx, SceneCmd* cmd); -void Scene_HeaderCmdSkyboxDisables(GlobalContext* globalCtx, SceneCmd* cmd); -void Scene_HeaderCmdTimeSettings(GlobalContext* globalCtx, SceneCmd* cmd); -void Scene_HeaderCmdWindSettings(GlobalContext* globalCtx, SceneCmd* cmd); -void Scene_HeaderCmdExitList(GlobalContext* globalCtx, SceneCmd* cmd); -void Scene_HeaderCmd09(GlobalContext* globalCtx, SceneCmd* cmd); -void Scene_HeaderCmdSoundSettings(GlobalContext* globalCtx, SceneCmd* cmd); -void Scene_HeaderCmdEchoSetting(GlobalContext* globalCtx, SceneCmd* cmd); -void Scene_HeaderCmdAltHeaderList(GlobalContext* globalCtx, SceneCmd* cmd); -void Scene_HeaderCmdCutsceneList(GlobalContext* globalCtx, SceneCmd* cmd); -void Scene_HeaderCmdActorCutsceneList(GlobalContext* globalCtx, SceneCmd* cmd); -void Scene_HeaderCmdMiniMap(GlobalContext* globalCtx, SceneCmd* cmd); -void Scene_HeaderCmd1D(GlobalContext* globalCtx, SceneCmd* cmd); -void Scene_HeaderCmdMiniMapCompassInfo(GlobalContext* globalCtx, SceneCmd* cmd); -void Scene_HeaderCmdSetAreaVisitedFlag(GlobalContext* globalCtx, SceneCmd* cmd); -void Scene_HeaderCmdAnimatedMaterials(GlobalContext* globalCtx, SceneCmd* cmd); -void Scene_SetExitFade(GlobalContext* globalCtx); -s32 Scene_ProcessHeader(GlobalContext* globalCtx, SceneCmd* header); -u16 Entrance_CreateIndex(s32 sceneIndex, s32 spawnIndex, s32 sceneSetup); -u16 Entrance_CreateIndexFromSpawn(s32 spawnIndex); -void Scene_ExecuteDrawConfig(GlobalContext* globalCtx); -void Scene_DrawConfigDefault(GlobalContext* globalCtx); -Gfx* AnimatedMat_TexScroll(GlobalContext* globalCtx, AnimatedMatTexScrollParams* params); -void AnimatedMat_DrawTexScroll(GlobalContext* globalCtx, s32 segment, void* params); -Gfx* AnimatedMat_TwoLayerTexScroll(GlobalContext* globalCtx, AnimatedMatTexScrollParams* params); -void AnimatedMat_DrawTwoTexScroll(GlobalContext* globalCtx, s32 segment, void* params); -void AnimatedMat_SetColor(GlobalContext* globalCtx, s32 segment, F3DPrimColor* primColor, F3DEnvColor* envColor); -void AnimatedMat_DrawColor(GlobalContext* globalCtx, s32 segment, void* params); +void Scene_HeaderCmdEnvLightSettings(PlayState* play, SceneCmd* cmd); +void Scene_LoadAreaTextures(PlayState* play, s32 fileIndex); +void Scene_HeaderCmdSkyboxSettings(PlayState* play, SceneCmd* cmd); +void Scene_HeaderCmdSkyboxDisables(PlayState* play, SceneCmd* cmd); +void Scene_HeaderCmdTimeSettings(PlayState* play, SceneCmd* cmd); +void Scene_HeaderCmdWindSettings(PlayState* play, SceneCmd* cmd); +void Scene_HeaderCmdExitList(PlayState* play, SceneCmd* cmd); +void Scene_HeaderCmd09(PlayState* play, SceneCmd* cmd); +void Scene_HeaderCmdSoundSettings(PlayState* play, SceneCmd* cmd); +void Scene_HeaderCmdEchoSetting(PlayState* play, SceneCmd* cmd); +void Scene_HeaderCmdAltHeaderList(PlayState* play, SceneCmd* cmd); +void Scene_HeaderCmdCutsceneList(PlayState* play, SceneCmd* cmd); +void Scene_HeaderCmdActorCutsceneList(PlayState* play, SceneCmd* cmd); +void Scene_HeaderCmdMiniMap(PlayState* play, SceneCmd* cmd); +void Scene_HeaderCmd1D(PlayState* play, SceneCmd* cmd); +void Scene_HeaderCmdMiniMapCompassInfo(PlayState* play, SceneCmd* cmd); +void Scene_HeaderCmdSetAreaVisitedFlag(PlayState* play, SceneCmd* cmd); +void Scene_HeaderCmdAnimatedMaterials(PlayState* play, SceneCmd* cmd); +void Scene_SetExitFade(PlayState* play); +s32 Scene_ProcessHeader(PlayState* play, SceneCmd* header); +u16 Entrance_Create(s32 scene, s32 spawn, s32 layer); +u16 Entrance_CreateFromSpawn(s32 spawn); +void Scene_ExecuteDrawConfig(PlayState* play); +void Scene_DrawConfigDefault(PlayState* play); +Gfx* AnimatedMat_TexScroll(PlayState* play, AnimatedMatTexScrollParams* params); +void AnimatedMat_DrawTexScroll(PlayState* play, s32 segment, void* params); +Gfx* AnimatedMat_TwoLayerTexScroll(PlayState* play, AnimatedMatTexScrollParams* params); +void AnimatedMat_DrawTwoTexScroll(PlayState* play, s32 segment, void* params); +void AnimatedMat_SetColor(PlayState* play, s32 segment, F3DPrimColor* primColor, F3DEnvColor* envColor); +void AnimatedMat_DrawColor(PlayState* play, s32 segment, void* params); s32 AnimatedMat_Lerp(s32 min, s32 max, f32 norm); -void AnimatedMat_DrawColorLerp(GlobalContext* globalCtx, s32 segment, void* params); +void AnimatedMat_DrawColorLerp(PlayState* play, s32 segment, void* params); f32 Scene_LagrangeInterp(s32 n, f32 x[], f32 fx[], f32 xp); u8 Scene_LagrangeInterpColor(s32 n, f32 x[], f32 fx[], f32 xp); -void AnimatedMat_DrawColorNonLinearInterp(GlobalContext* globalCtx, s32 segment, void* params); -void AnimatedMat_DrawTexCycle(GlobalContext* globalCtx, s32 segment, void* params); -void AnimatedMat_DrawMain(GlobalContext* globalCtx, AnimatedMaterial* matAnim, f32 alphaRatio, u32 step, u32 flags); -void AnimatedMat_Draw(GlobalContext* globalCtx, AnimatedMaterial* matAnim); -void AnimatedMat_DrawOpa(GlobalContext* globalCtx, AnimatedMaterial* matAnim); -void AnimatedMat_DrawXlu(GlobalContext* globalCtx, AnimatedMaterial* matAnim); -void AnimatedMat_DrawAlpha(GlobalContext* globalCtx, AnimatedMaterial* matAnim, f32 alphaRatio); -void AnimatedMat_DrawAlphaOpa(GlobalContext* globalCtx, AnimatedMaterial* matAnim, f32 alphaRatio); -void AnimatedMat_DrawAlphaXlu(GlobalContext* globalCtx, AnimatedMaterial* matAnim, f32 alphaRatio); -void AnimatedMat_DrawStep(GlobalContext* globalCtx, AnimatedMaterial* matAnim, u32 step); -void AnimatedMat_DrawStepOpa(GlobalContext* globalCtx, AnimatedMaterial* matAnim, u32 step); -void AnimatedMat_DrawStepXlu(GlobalContext* globalCtx, AnimatedMaterial* matAnim, u32 step); -void AnimatedMat_DrawAlphaStep(GlobalContext* globalCtx, AnimatedMaterial* matAnim, f32 alphaRatio, u32 step); -void AnimatedMat_DrawAlphaStepOpa(GlobalContext* globalCtx, AnimatedMaterial* matAnim, f32 alphaRatio, u32 step); -void AnimatedMat_DrawAlphaStepXlu(GlobalContext* globalCtx, AnimatedMaterial* matAnim, f32 alphaRatio, u32 step); -void Scene_DrawConfigMatAnim(GlobalContext* globalCtx); -void Scene_DrawConfig3(GlobalContext* globalCtx); -void Scene_DrawConfig4(GlobalContext* globalCtx); -void Scene_DrawConfigDoNothing(GlobalContext* globalCtx); -void Scene_SetRenderModeXlu(GlobalContext* globalCtx, s32 index, u32 flags); -void Scene_SetCullFlag(GlobalContext* globalCtx, s32 index, u32 flags); -void Scene_DrawConfig5(GlobalContext* globalCtx); -void Scene_DrawConfigMatAnimManualStep(GlobalContext* globalCtx); -void Scene_DrawConfigGreatBayTemple(GlobalContext* globalCtx); +void AnimatedMat_DrawColorNonLinearInterp(PlayState* play, s32 segment, void* params); +void AnimatedMat_DrawTexCycle(PlayState* play, s32 segment, void* params); +void AnimatedMat_DrawMain(PlayState* play, AnimatedMaterial* matAnim, f32 alphaRatio, u32 step, u32 flags); +void AnimatedMat_Draw(PlayState* play, AnimatedMaterial* matAnim); +void AnimatedMat_DrawOpa(PlayState* play, AnimatedMaterial* matAnim); +void AnimatedMat_DrawXlu(PlayState* play, AnimatedMaterial* matAnim); +void AnimatedMat_DrawAlpha(PlayState* play, AnimatedMaterial* matAnim, f32 alphaRatio); +void AnimatedMat_DrawAlphaOpa(PlayState* play, AnimatedMaterial* matAnim, f32 alphaRatio); +void AnimatedMat_DrawAlphaXlu(PlayState* play, AnimatedMaterial* matAnim, f32 alphaRatio); +void AnimatedMat_DrawStep(PlayState* play, AnimatedMaterial* matAnim, u32 step); +void AnimatedMat_DrawStepOpa(PlayState* play, AnimatedMaterial* matAnim, u32 step); +void AnimatedMat_DrawStepXlu(PlayState* play, AnimatedMaterial* matAnim, u32 step); +void AnimatedMat_DrawAlphaStep(PlayState* play, AnimatedMaterial* matAnim, f32 alphaRatio, u32 step); +void AnimatedMat_DrawAlphaStepOpa(PlayState* play, AnimatedMaterial* matAnim, f32 alphaRatio, u32 step); +void AnimatedMat_DrawAlphaStepXlu(PlayState* play, AnimatedMaterial* matAnim, f32 alphaRatio, u32 step); +void Scene_DrawConfigMatAnim(PlayState* play); +void Scene_DrawConfig3(PlayState* play); +void Scene_DrawConfig4(PlayState* play); +void Scene_DrawConfigDoNothing(PlayState* play); +void Scene_SetRenderModeXlu(PlayState* play, s32 index, u32 flags); +void Scene_SetCullFlag(PlayState* play, s32 index, u32 flags); +void Scene_DrawConfig5(PlayState* play); +void Scene_DrawConfigMatAnimManualStep(PlayState* play); +void Scene_DrawConfigGreatBayTemple(PlayState* play); EntranceTableEntry* Entrance_GetTableEntry(u16 entrance); -s32 Entrance_GetSceneNum(u16 entranceIndex); -s32 Entrance_GetSceneNumAbsolute(u16 entranceIndex); -s32 Entrance_GetSpawnNum(u16 entranceIndex); -s32 Entrance_GetTransitionFlags(u16 entranceIndex); -// void func_801323D0(void); -// void func_80132428(void); -// void func_80132494(void); -// void func_801326B8(void); -// void func_801328F0(void); -// void func_80132920(void); -// void func_80132938(void); -// void func_80132954(void); -// void func_8013296C(void); -// void func_80132A18(void); -// void func_80132A3C(void); -// void func_80132A80(void); -// void func_80132AD8(void); -// void func_80132B24(void); -// void func_80132B84(void); -// void func_80132D70(void); -// void func_80132E9C(void); -// void func_80132FDC(void); -// void func_80133000(void); -UNK_TYPE func_80133038(GlobalContext* globalCtx, UNK_TYPE* arg1, struct_80133038_arg2* arg2); -void SkelAnime_DrawLimbLod(GlobalContext* globalCtx, s32 limbIndex, void** skeleton, Vec3s* jointTable, OverrideLimbDrawOpa overrideLimbDraw, PostLimbDrawOpa postLimbDraw, Actor* actor, s32 lod); -void SkelAnime_DrawLod(GlobalContext* globalCtx, void** skeleton, Vec3s* jointTable, OverrideLimbDrawOpa overrideLimbDraw, PostLimbDrawOpa postLimbDraw, Actor* actor, s32 lod); -void SkelAnime_DrawFlexLimbLod(GlobalContext* globalCtx, s32 limbIndex, void** skeleton, Vec3s* jointTable, OverrideLimbDrawFlex overrideLimbDraw, PostLimbDrawFlex postLimbDraw, Actor* actor, s32 lod, Mtx** mtx); -void SkelAnime_DrawFlexLod(GlobalContext* globalCtx, void** skeleton, Vec3s* jointTable, s32 dListCount, OverrideLimbDrawFlex overrideLimbDraw, PostLimbDrawFlex postLimbDraw, Actor* actor, s32 lod); -void SkelAnime_DrawLimbOpa(GlobalContext* globalCtx, s32 limbIndex, void** skeleton, Vec3s* jointTable, OverrideLimbDrawOpa overrideLimbDraw, PostLimbDrawOpa postLimbDraw, Actor* actor); -void SkelAnime_DrawOpa(GlobalContext* globalCtx, void** skeleton, Vec3s* jointTable, OverrideLimbDrawOpa overrideLimbDraw, PostLimbDrawOpa postLimbDraw, Actor* actor); -void SkelAnime_DrawFlexLimbOpa(GlobalContext* globalCtx, s32 limbIndex, void** skeleton, Vec3s* jointTable, OverrideLimbDrawOpa overrideLimbDraw, PostLimbDrawOpa postLimbDraw, Actor* actor, Mtx** limbMatricies); -void SkelAnime_DrawFlexOpa(GlobalContext* globalCtx, void** skeleton, Vec3s* jointTable, s32 dListCount, OverrideLimbDrawOpa overrideLimbDraw, PostLimbDrawOpa postLimbDraw, Actor* actor); -void SkelAnime_DrawTransformFlexLimbOpa(GlobalContext* globalCtx, s32 limbIndex, void** skeleton, Vec3s* jointTable, OverrideLimbDrawOpa overrideLimbDraw, PostLimbDrawOpa postLimbDraw, TransformLimbDrawOpa transformLimbDraw, Actor* actor, Mtx** mtx); -void SkelAnime_DrawTransformFlexOpa(GlobalContext* globalCtx, void** skeleton, Vec3s* jointTable, s32 dListCount, OverrideLimbDrawOpa overrideLimbDraw, PostLimbDrawOpa postLimbDraw, TransformLimbDrawOpa transformLimbDraw, Actor* actor); +s32 Entrance_GetSceneNum(u16 entrance); +s32 Entrance_GetSceneNumAbsolute(u16 entrance); +s32 Entrance_GetSpawnNum(u16 entrance); +s32 Entrance_GetTransitionFlags(u16 entrance); +s32 Schedule_RunScript(PlayState* play, u8* script, ScheduleOutput* output); +void SkelAnime_DrawLimbLod(PlayState* play, s32 limbIndex, void** skeleton, Vec3s* jointTable, OverrideLimbDrawOpa overrideLimbDraw, PostLimbDrawOpa postLimbDraw, Actor* actor, s32 lod); +void SkelAnime_DrawLod(PlayState* play, void** skeleton, Vec3s* jointTable, OverrideLimbDrawOpa overrideLimbDraw, PostLimbDrawOpa postLimbDraw, Actor* actor, s32 lod); +void SkelAnime_DrawFlexLimbLod(PlayState* play, s32 limbIndex, void** skeleton, Vec3s* jointTable, OverrideLimbDrawFlex overrideLimbDraw, PostLimbDrawFlex postLimbDraw, Actor* actor, s32 lod, Mtx** mtx); +void SkelAnime_DrawFlexLod(PlayState* play, void** skeleton, Vec3s* jointTable, s32 dListCount, OverrideLimbDrawFlex overrideLimbDraw, PostLimbDrawFlex postLimbDraw, Actor* actor, s32 lod); +void SkelAnime_DrawLimbOpa(PlayState* play, s32 limbIndex, void** skeleton, Vec3s* jointTable, OverrideLimbDrawOpa overrideLimbDraw, PostLimbDrawOpa postLimbDraw, Actor* actor); +void SkelAnime_DrawOpa(PlayState* play, void** skeleton, Vec3s* jointTable, OverrideLimbDrawOpa overrideLimbDraw, PostLimbDrawOpa postLimbDraw, Actor* actor); +void SkelAnime_DrawFlexLimbOpa(PlayState* play, s32 limbIndex, void** skeleton, Vec3s* jointTable, OverrideLimbDrawOpa overrideLimbDraw, PostLimbDrawOpa postLimbDraw, Actor* actor, Mtx** limbMatricies); +void SkelAnime_DrawFlexOpa(PlayState* play, void** skeleton, Vec3s* jointTable, s32 dListCount, OverrideLimbDrawOpa overrideLimbDraw, PostLimbDrawOpa postLimbDraw, Actor* actor); +void SkelAnime_DrawTransformFlexLimbOpa(PlayState* play, s32 limbIndex, void** skeleton, Vec3s* jointTable, OverrideLimbDrawOpa overrideLimbDraw, PostLimbDrawOpa postLimbDraw, TransformLimbDrawOpa transformLimbDraw, Actor* actor, Mtx** mtx); +void SkelAnime_DrawTransformFlexOpa(PlayState* play, void** skeleton, Vec3s* jointTable, s32 dListCount, OverrideLimbDrawOpa overrideLimbDraw, PostLimbDrawOpa postLimbDraw, TransformLimbDrawOpa transformLimbDraw, Actor* actor); void SkelAnime_GetFrameData(AnimationHeader* animation, s32 currentFrame, s32 limbCount, Vec3s* dst); s16 Animation_GetLength(void* animation); s16 Animation_GetLastFrame(void* animation); -Gfx* SkelAnime_DrawLimb(GlobalContext* globalCtx, s32 limbIndex, void** skeleton, Vec3s* jointTable, OverrideLimbDraw overrideLimbDraw, PostLimbDraw postLimbDraw, Actor* actor, Gfx* gfx); -Gfx* SkelAnime_Draw(GlobalContext* globalCtx, void** skeleton, Vec3s* jointTable, OverrideLimbDraw overrideLimbDraw, PostLimbDraw postLimbDraw, Actor* actor, Gfx* gfx); -Gfx* SkelAnime_DrawFlexLimb(GlobalContext* globalCtx, s32 limbIndex, void** skeleton, Vec3s* jointTable, OverrideLimbDraw overrideLimbDraw, PostLimbDraw postLimbDraw, Actor* actor, Mtx** mtx, Gfx* gfx); -Gfx* SkelAnime_DrawFlex(GlobalContext* globalCtx, void** skeleton, Vec3s* jointTable, s32 dListCount, OverrideLimbDraw overrideLimbDraw, PostLimbDraw postLimbDraw, Actor* actor, Gfx* gfx); +Gfx* SkelAnime_DrawLimb(PlayState* play, s32 limbIndex, void** skeleton, Vec3s* jointTable, OverrideLimbDraw overrideLimbDraw, PostLimbDraw postLimbDraw, Actor* actor, Gfx* gfx); +Gfx* SkelAnime_Draw(PlayState* play, void** skeleton, Vec3s* jointTable, OverrideLimbDraw overrideLimbDraw, PostLimbDraw postLimbDraw, Actor* actor, Gfx* gfx); +Gfx* SkelAnime_DrawFlexLimb(PlayState* play, s32 limbIndex, void** skeleton, Vec3s* jointTable, OverrideLimbDraw overrideLimbDraw, PostLimbDraw postLimbDraw, Actor* actor, Mtx** mtx, Gfx* gfx); +Gfx* SkelAnime_DrawFlex(PlayState* play, void** skeleton, Vec3s* jointTable, s32 dListCount, OverrideLimbDraw overrideLimbDraw, PostLimbDraw postLimbDraw, Actor* actor, Gfx* gfx); s16 SkelAnime_GetFrameDataLegacy(LegacyAnimationHeader* animation, s32 frame, Vec3s* frameTable); s16 Animation_GetLimbCount2(LegacyAnimationHeader* animation); s16 Animation_GetLength2(LegacyAnimationHeader* animation); s16 Animation_GetLastFrame2(LegacyAnimationHeader* animation); -void SkelAnime_InterpFrameTable(s32 limbCount, Vec3s* dst, Vec3s* vec2, Vec3s* vec3, f32 unkf); +void SkelAnime_InterpFrameTable(s32 limbCount, Vec3s* dst, Vec3s* start, Vec3s* target, f32 weight); void AnimationContext_Reset(AnimationContext* animationCtx); -void AnimationContext_SetNextQueue(GlobalContext* globalCtx); -void AnimationContext_DisableQueue(GlobalContext* globalCtx); +void AnimationContext_SetNextQueue(PlayState* play); +void AnimationContext_DisableQueue(PlayState* play); AnimationEntry* AnimationContext_AddEntry(AnimationContext* animationCtx, AnimationType type); -void AnimationContext_SetLoadFrame(GlobalContext* globalCtx, LinkAnimationHeader* animation, s32 frame, s32 limbCount, Vec3s* frameTable); -void AnimationContext_SetCopyAll(GlobalContext* globalCtx, s32 vecCount, Vec3s* dst, Vec3s* src); -void AnimationContext_SetInterp(GlobalContext* globalCtx, s32 vecCount, Vec3s* base, Vec3s* mod, f32 weight); -void AnimationContext_SetCopyTrue(GlobalContext* globalCtx, s32 vecCount, Vec3s* dst, Vec3s* src, u8* index); -void AnimationContext_SetCopyFalse(GlobalContext* globalCtx, s32 vecCount, Vec3s* dst, Vec3s* src, u8* index); -void AnimationContext_SetMoveActor(GlobalContext* globalCtx, Actor* actor, SkelAnime* skelAnime, f32 arg3); -void AnimationContext_LoadFrame(GlobalContext* globalCtx, AnimationEntryData* data); -void AnimationContext_CopyAll(GlobalContext* globalCtx, AnimationEntryData* data); -void AnimationContext_Interp(GlobalContext* globalCtx, AnimationEntryData* data); -void AnimationContext_CopyTrue(GlobalContext* globalCtx, AnimationEntryData* data); -void AnimationContext_CopyFalse(GlobalContext* globalCtx, AnimationEntryData* data); -void AnimationContext_MoveActor(GlobalContext* globalCtx, AnimationEntryData* data); -void AnimationContext_Update(GlobalContext* globalCtx, AnimationContext* animationCtx); -void SkelAnime_InitLink(GlobalContext* globalCtx, SkelAnime* skelAnime, FlexSkeletonHeader* skeletonHeaderSeg, LinkAnimationHeader* animation, s32 flags, Vec3s* jointTable, Vec3s* morphTable, s32 limbBufCount); +void AnimationContext_SetLoadFrame(PlayState* play, LinkAnimationHeader* animation, s32 frame, s32 limbCount, Vec3s* frameTable); +void AnimationContext_SetCopyAll(PlayState* play, s32 vecCount, Vec3s* dst, Vec3s* src); +void AnimationContext_SetInterp(PlayState* play, s32 vecCount, Vec3s* base, Vec3s* mod, f32 weight); +void AnimationContext_SetCopyTrue(PlayState* play, s32 vecCount, Vec3s* dst, Vec3s* src, u8* index); +void AnimationContext_SetCopyFalse(PlayState* play, s32 vecCount, Vec3s* dst, Vec3s* src, u8* index); +void AnimationContext_SetMoveActor(PlayState* play, Actor* actor, SkelAnime* skelAnime, f32 arg3); +void AnimationContext_LoadFrame(PlayState* play, AnimationEntryData* data); +void AnimationContext_CopyAll(PlayState* play, AnimationEntryData* data); +void AnimationContext_Interp(PlayState* play, AnimationEntryData* data); +void AnimationContext_CopyTrue(PlayState* play, AnimationEntryData* data); +void AnimationContext_CopyFalse(PlayState* play, AnimationEntryData* data); +void AnimationContext_MoveActor(PlayState* play, AnimationEntryData* data); +void AnimationContext_Update(PlayState* play, AnimationContext* animationCtx); +void SkelAnime_InitLink(PlayState* play, SkelAnime* skelAnime, FlexSkeletonHeader* skeletonHeaderSeg, LinkAnimationHeader* animation, s32 flags, Vec3s* jointTable, Vec3s* morphTable, s32 limbBufCount); void LinkAnimation_SetUpdateFunction(SkelAnime* skelAnime); -s32 LinkAnimation_Update(GlobalContext* globalCtx, SkelAnime* skelAnime); -s32 LinkAnimation_Morph(GlobalContext* globalCtx, SkelAnime* skelAnime); -void LinkAnimation_AnimateFrame(GlobalContext* globalCtx, SkelAnime* skelAnime); -s32 LinkAnimation_Loop(GlobalContext* globalCtx, SkelAnime* skelAnime); -s32 LinkAnimation_Once(GlobalContext* globalCtx, SkelAnime* skelAnime); -void Animation_SetMorph(GlobalContext* globalCtx, SkelAnime* skelAnime, f32 morphFrames); -void LinkAnimation_Change(GlobalContext* globalCtx, SkelAnime* skelAnime, LinkAnimationHeader* animation, f32 playSpeed, f32 startFrame, f32 endFrame, u8 mode, f32 morphFrames); -void LinkAnimation_PlayOnce(GlobalContext* globalCtx, SkelAnime* skelAnime, LinkAnimationHeader* animation); -void LinkAnimation_PlayOnceSetSpeed(GlobalContext* globalCtx, SkelAnime* skelAnime, LinkAnimationHeader* animation, f32 playSpeed); -void LinkAnimation_PlayLoop(GlobalContext* globalCtx, SkelAnime* skelAnime, LinkAnimationHeader* animation); -void LinkAnimation_PlayLoopSetSpeed(GlobalContext* globalCtx, SkelAnime* skelAnime, LinkAnimationHeader* animation, f32 playSpeed); -void LinkAnimation_CopyJointToMorph(GlobalContext* globalCtx, SkelAnime* skelAnime); -void LinkAnimation_CopyMorphToJoint(GlobalContext* globalCtx, SkelAnime* skelAnime); -void LinkAnimation_LoadToMorph(GlobalContext* globalCtx, SkelAnime* skelAnime, LinkAnimationHeader* animation, f32 frame); -void LinkAnimation_LoadToJoint(GlobalContext* globalCtx, SkelAnime* skelAnime, LinkAnimationHeader* animation, f32 frame); -void LinkAnimation_InterpJointMorph(GlobalContext* globalCtx, SkelAnime* skelAnime, f32 frame); -void LinkAnimation_BlendToJoint(GlobalContext* globalCtx, SkelAnime* skelAnime, LinkAnimationHeader* animation1, f32 frame1, LinkAnimationHeader* animation2, f32 frame2, f32 blendWeight, Vec3s* blendTable); -void LinkAnimation_BlendToMorph(GlobalContext* globalCtx, SkelAnime* skelAnime, LinkAnimationHeader* animation1, f32 frame1, LinkAnimationHeader* animation2, f32 frame2, f32 blendWeight, Vec3s* blendTable); +s32 LinkAnimation_Update(PlayState* play, SkelAnime* skelAnime); +s32 LinkAnimation_Morph(PlayState* play, SkelAnime* skelAnime); +void LinkAnimation_AnimateFrame(PlayState* play, SkelAnime* skelAnime); +s32 LinkAnimation_Loop(PlayState* play, SkelAnime* skelAnime); +s32 LinkAnimation_Once(PlayState* play, SkelAnime* skelAnime); +void Animation_SetMorph(PlayState* play, SkelAnime* skelAnime, f32 morphFrames); +void LinkAnimation_Change(PlayState* play, SkelAnime* skelAnime, LinkAnimationHeader* animation, f32 playSpeed, f32 startFrame, f32 endFrame, u8 mode, f32 morphFrames); +void LinkAnimation_PlayOnce(PlayState* play, SkelAnime* skelAnime, LinkAnimationHeader* animation); +void LinkAnimation_PlayOnceSetSpeed(PlayState* play, SkelAnime* skelAnime, LinkAnimationHeader* animation, f32 playSpeed); +void LinkAnimation_PlayLoop(PlayState* play, SkelAnime* skelAnime, LinkAnimationHeader* animation); +void LinkAnimation_PlayLoopSetSpeed(PlayState* play, SkelAnime* skelAnime, LinkAnimationHeader* animation, f32 playSpeed); +void LinkAnimation_CopyJointToMorph(PlayState* play, SkelAnime* skelAnime); +void LinkAnimation_CopyMorphToJoint(PlayState* play, SkelAnime* skelAnime); +void LinkAnimation_LoadToMorph(PlayState* play, SkelAnime* skelAnime, LinkAnimationHeader* animation, f32 frame); +void LinkAnimation_LoadToJoint(PlayState* play, SkelAnime* skelAnime, LinkAnimationHeader* animation, f32 frame); +void LinkAnimation_InterpJointMorph(PlayState* play, SkelAnime* skelAnime, f32 frame); +void LinkAnimation_BlendToJoint(PlayState* play, SkelAnime* skelAnime, LinkAnimationHeader* animation1, f32 frame1, LinkAnimationHeader* animation2, f32 frame2, f32 blendWeight, Vec3s* blendTable); +void LinkAnimation_BlendToMorph(PlayState* play, SkelAnime* skelAnime, LinkAnimationHeader* animation1, f32 frame1, LinkAnimationHeader* animation2, f32 frame2, f32 blendWeight, Vec3s* blendTable); void LinkAnimation_EndLoop(SkelAnime* skelAnime); s32 Animation_OnFrameImpl(SkelAnime* skelAnime, f32 frame, f32 updateRate); s32 LinkAnimation_OnFrame(SkelAnime* skelAnime, f32 frame); -void SkelAnime_Init(GlobalContext* globalCtx, SkelAnime* skelAnime, SkeletonHeader* skeletonHeaderSeg, AnimationHeader* animation, Vec3s* jointTable, Vec3s* morphTable, s32 limbCount); -void SkelAnime_InitFlex(GlobalContext* globalCtx, SkelAnime* skelAnime, FlexSkeletonHeader* skeletonHeaderSeg, AnimationHeader* animation, Vec3s* jointTable, Vec3s* morphTable, s32 limbCount); +void SkelAnime_Init(PlayState* play, SkelAnime* skelAnime, SkeletonHeader* skeletonHeaderSeg, AnimationHeader* animation, Vec3s* jointTable, Vec3s* morphTable, s32 limbCount); +void SkelAnime_InitFlex(PlayState* play, SkelAnime* skelAnime, FlexSkeletonHeader* skeletonHeaderSeg, AnimationHeader* animation, Vec3s* jointTable, Vec3s* morphTable, s32 limbCount); void SkelAnime_InitSkin(GameState* gameState, SkelAnime* skelAnime, SkeletonHeader* skeletonHeaderSeg, AnimationHeader* animationSeg); void SkelAnime_SetUpdate(SkelAnime* skelAnime); s32 SkelAnime_Update(SkelAnime* skelAnime); @@ -2406,7 +2285,7 @@ void SkelAnime_CopyFrameTableTrue(SkelAnime* skelAnime, Vec3s* dst, Vec3s* src, void SkelAnime_CopyFrameTableFalse(SkelAnime* skelAnime, Vec3s* dst, Vec3s* src, u8* copyFlag); void SkelAnime_UpdateTranslation(SkelAnime* skelAnime, Vec3f* pos, s16 angle); s32 Animation_OnFrame(SkelAnime* skelAnime, f32 frame); -void SkelAnime_Free(SkelAnime* skelAnime, GlobalContext* globalCtx); +void SkelAnime_Free(SkelAnime* skelAnime, PlayState* play); void SkelAnime_CopyFrameTable(SkelAnime* skelAnime, Vec3s* dst, Vec3s* src); void SkinMatrix_Vec3fMtxFMultXYZW(MtxF* mf, Vec3f* src, Vec3f* xyzDest, f32* wDest); void SkinMatrix_Vec3fMtxFMultXYZ(MtxF* mf, Vec3f* src, Vec3f* dest); @@ -2433,76 +2312,6 @@ void SkinMatrix_SetYRotation(MtxF* mf, s16 a); void SkinMatrix_MulYRotation(MtxF* mf, s16 a); void SkinMatrix_SetZRotation(MtxF* mf, s16 a); -s32 func_8013A240(GlobalContext* globalCtx); -void func_8013A41C(s32 flag); -void func_8013A46C(s32 flag); -u32 func_8013A4C4(s32 flag); -s16 func_8013A504(s16 val); -s32 func_8013A530(GlobalContext* globalCtx, Actor* actor, s32 flag, Vec3f* pos, Vec3s* rot, f32 distanceMin, f32 distanceMax, s16 angleError); -struct EnDoor* SubS_FindDoor(GlobalContext* globalCtx, s32 switchFlag); -Gfx* SubS_DrawTransformFlexLimb(GlobalContext* globalCtx, s32 limbIndex, void** skeleton, Vec3s* jointTable, OverrideLimbDraw overrideLimbDraw, PostLimbDraw postLimbDraw, TransformLimbDraw transformLimbDraw, Actor* actor, Mtx** mtx, Gfx* gfx); -Gfx* SubS_DrawTransformFlex(GlobalContext* globalCtx, void** skeleton, Vec3s* jointTable, s32 dListCount, OverrideLimbDraw overrideLimbDraw, PostLimbDraw postLimbDraw, TransformLimbDraw transformLimbDraw, Actor* actor, Gfx* gfx); -s32 func_8013AD6C(GlobalContext* globalCtx); -s32 func_8013AD9C(s16 arg0, s16 arg1, Vec3f* arg2, Vec3s* arg3, s32 arg4, s32 arg5); -void SubS_UpdateFlags(u16* flags, u16 setBits, u16 unsetBits); -void func_8013AF00(f32* arg0, s32 arg1, s32 arg2); -s32 func_8013B010(f32* arg0, s32 arg1, s32 arg2, s32 arg3, s32 arg4, s32 arg5, f32* arg6); -void func_8013B0C8(s32 arg0, f32 arg1, s32 arg2, f32* arg3, f32* arg4); -void func_8013B350(Vec3f* arg0, f32* arg1, f32 arg2, s32 arg3, s32 arg4, Vec3s* arg5, f32* arg6); -s32 func_8013B6B0(Path* path, f32* arg1, s32* arg2, s32 arg3, s32 arg4, s32* arg5, f32* arg6, Vec3f* arg7, s32 arg8); -void func_8013B878(GlobalContext* globalCtx, Path* path, s32 arg2, Vec3f* arg3); -Path* SubS_GetAdditionalPath(GlobalContext* globalCtx, u8 pathIndex, s32 max); -Actor* SubS_FindNearestActor(Actor* actor, 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(GlobalContext* globalCtx, u8 pathIndex, u8 max, s32* startPointIndex); -s32 func_8013C068(Path* path, s32 arg1, Vec3f* arg2, f32 arg3, s32 arg4); -s32 func_8013C624(Actor* actor, Path* path, s32* arg2, f32* arg3, s32 arg4, s32 arg5); -s32 SubS_CopyPointFromPathCheckBounds(Path* path, s32 pointIndex, Vec3f* dst); -s32 func_8013C964(Actor* actor, GlobalContext* globalCtx, f32 arg2, f32 arg3, s32 arg4, s32 arg5); -void func_8013CC2C(s32 arg0, s32 arg1, u8* arg2, s32 arg3); -void func_8013CD64(Vec3f* arg0, Vec3f* arg1, u8* arg2, f32 arg3, u8 arg4, u8* arg5, s8* arg6); -void func_8013CF04(Actor* actor, GraphicsContext** gfxCtxPtr, u8* arg2); -s16 func_8013D0E0(s16* arg0, s16 arg1, s16 arg2, f32 arg3, f32 arg4, f32 arg5); -s32 func_8013D2E0(Vec3f* arg0, Vec3f* arg1, Vec3s* arg2, Vec3s* arg3, Vec3s* arg4, Vec3s* arg5, u16* arg6); -s32 SubS_AngleDiffLessEqual(s16 angleA, s16 threshold, s16 angleB); -Path* SubS_GetPathByIndex(GlobalContext* globalCtx, s16 pathIndex, s16 max); -s32 SubS_CopyPointFromPath(Path* path, s32 pointIndex, Vec3f* dst); -s16 SubS_GetDistSqAndOrientPoints(Vec3f* vecA, Vec3f* vecB, f32* distSq); -s32 SubS_MoveActorToPoint(Actor* actor, Vec3f* point, s16 rotStep); -s16 SubS_GetDistSqAndOrientPath(Path* path, s32 pointIdx, Vec3f* pos, f32* distSq); -s8 SubS_IsObjectLoaded(s8 index, GlobalContext* globalCtx); -s8 SubS_GetObjectIndex(s16 id, GlobalContext* globalCtx); -Actor* SubS_FindActor(GlobalContext* globalCtx, Actor* actorListStart, u8 actorCategory, s16 actorId); -s32 SubS_FillLimbRotTables(GlobalContext* globalCtx, s16* limbRotTableY, s16* limbRotTableZ, s32 numLimbs); -s32 SubS_IsFloorAbove(GlobalContext* globalCtx, Vec3f* pos, f32 distAbove); -s32 SubS_CopyPointFromPathList(Path* paths, s32 pathIndex, s32 pointIndex, Vec3f* dst); -u8 SubS_GetPathCount(Path* paths, s32 index); -void SubS_ActorPathing_Init(GlobalContext* globalCtx, Vec3f* worldPos, Actor* actor, ActorPathing* actorPath, Path* paths, s32 pathIndex, s32 begPointIndex, s32 endPointIndex, s32 curPointIndex, u8 flags); -s32 SubS_ActorPathing_Update(GlobalContext* globalCtx, ActorPathing* actorPath, ActorPathingComputeFunc computePointInfoFunc, ActorPathingUpdateFunc updateActorInfoFunc, ActorPathingUpdateFunc moveFunc, ActorPathingUpdateFunc setNextPointFunc); -void SubS_ActorPathing_ComputePointInfo(GlobalContext* globalCtx, ActorPathing* actorPath); -s32 SubS_ActorPathing_MoveWithGravity(GlobalContext* globalCtx, ActorPathing* actorPath); -s32 SubS_ActorPathing_MoveWithoutGravityReverse(GlobalContext* globalCtx, ActorPathing* actorPath); -s32 SubS_ActorPathing_SetNextPoint(GlobalContext* globalCtx, ActorPathing* actorPath); -void SubS_ChangeAnimationBySpeedInfo(SkelAnime* skelAnime, AnimationSpeedInfo* animations, s32 nextIndex, s32* curIndex); -s32 SubS_StartActorCutscene(Actor* actor, s16 nextCutscene, s16 curCutscene, s32 type); -s32 SubS_FillCutscenesList(Actor* actor, s16 cutscenes[], s16 numCutscenes); -void func_8013E4B0(Vec3f* arg0, Vec3f* arg1, Vec3s* arg2, Plane* plane); -s32 func_8013E5CC(Vec3f* arg0, Vec3s* arg1, Vec3f* arg2, Vec3f* arg3, Vec3f* arg4, Vec3f* arg5); -Actor* SubS_FindActorCustom(GlobalContext* globalCtx, Actor* actor, Actor* actorListStart, u8 actorCategory, s16 actorId, void* verifyData, VerifyActor verifyActor); -s32 func_8013E748(Actor* actor, GlobalContext* globalCtx, f32 arg2, f32 arg3, s32 arg4, Vec3s* arg5, func_8013E748_arg6 arg6); -s32 func_8013E7C0(GlobalContext* globalCtx, Actor* actor, Vec3s* arg2); -void func_8013E8F8(Actor* actor, GlobalContext* globalCtx, f32 arg2, f32 arg3, s32 arg4, s16 arg5, s16 arg6); -s32 func_8013E950(Vec3f* arg0, Vec3f* arg1, s16 arg2, Vec3f* arg3, Vec3f* arg4, s16* arg5, s16* arg6, s16* arg7, s16* arg8, u16 arg9, u16 arg10, u16 arg11, u16 arg12); -// void func_8013EC10(void); -void func_8013EC44(f32 a, u8 b, u8 c, u8 d); -void func_8013ECE0(f32 xyzDistToPlayerSq, u8 arg1, u8 arg2, u8 arg3); -void func_8013ED9C(void); -void func_8013EDD0(void); -u32 func_8013EE04(void); -void func_8013EE24(void); -// void func_8013EE38(void); -// void func_8013EE48(void); void View_ViewportToVp(Vp* dest, Viewport* src); void View_Init(View* view, GraphicsContext* gfxCtx); void View_SetViewOrientation(View* view, Vec3f* eye, Vec3f* at, Vec3f* up); @@ -2553,34 +2362,34 @@ void func_80140E80(void* param_1); // void func_8014151C(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE4 param_5, UNK_TYPE4 param_6); // void func_80141678(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE4 param_5); // void func_80141778(void); -void func_801418B0(void* arg0); -void func_80141900(void* arg0); -// void func_80141924(void); -// void func_80141C34(void); -void VisMono_Draw(void* arg0, Gfx** gfx, u32 arg2); -// void func_8014204C(void); +void VisMono_Init(VisMono* this); +void VisMono_Destroy(VisMono* this); +// void VisMono_DesaturateTLUT(u16* tlut); +// void VisMono_DesaturateDList(Gfx* gfx); +void VisMono_Draw(VisMono* this, Gfx** gfxp); +// void VisMono_DrawOld(VisMono* this); void func_801420C0(void* arg0); void func_801420F4(void* arg0); void func_80142100(void* arg0, Gfx** gfx, u32 arg2); s32 func_80142440(SkyboxContext* skyboxCtx, Vtx* vtx, s32 arg2, s32 arg3, s32 arg4, s32 arg5, s32 arg6, s32 arg7, s32 arg8); void func_80143148(SkyboxContext* skyboxCtx, s32 arg1); void func_801431E8(GameState* gameState, SkyboxContext* skyboxCtx, s16 skyType); -void func_80143324(GlobalContext* globalCtx, SkyboxContext* skyboxCtx, s16 skyType); -void func_801434E4(GameState* gameState, SkyboxContext* skyboxCtx, s16 skyType); +void func_80143324(PlayState* play, SkyboxContext* skyboxCtx, s16 skyType); +void func_801434E4(GameState* gameState, SkyboxContext* skyboxCtx, s16 skyType); Mtx* SkyboxDraw_UpdateMatrix(SkyboxContext* skyboxCtx, f32 x, f32 y, f32 z); void SkyboxDraw_SetColors(SkyboxContext* skyboxCtx, u8 primR, u8 primG, u8 primB, u8 envR, u8 envG, u8 envB); void SkyboxDraw_Draw(SkyboxContext* skyboxCtx, GraphicsContext* gfxCtx, s16 skyboxId, s16 blend, f32 x, f32 y, f32 z); void SkyboxDraw_Noop(SkyboxContext* skyboxCtx); // void func_80147520(void); -void func_80147564(GlobalContext* globalCtx); -s32 Message_ShouldAdvance(GlobalContext* globalCtx); -s32 Message_ShouldAdvanceSilent(GlobalContext* globalCtx); -void func_801477B4(GlobalContext* globalCtx); -void func_80147818(GlobalContext* globalCtx, UNK_PTR puParm2, UNK_TYPE4 uParm3, UNK_TYPE4 uParm4); -// void func_80147F18(GlobalContext* globalCtx, UNK_PTR puParm2, UNK_TYPE4 uParm3, UNK_TYPE4 uParm4); -// void func_80148558(GlobalContext* globalCtx, UNK_PTR puParm2, UNK_TYPE4 uParm3, UNK_TYPE4 uParm4); -void func_80148B98(GlobalContext* globalCtx, u8 bParm2); +void func_80147564(PlayState* play); +s32 Message_ShouldAdvance(PlayState* play); +s32 Message_ShouldAdvanceSilent(PlayState* play); +void func_801477B4(PlayState* play); +void func_80147818(PlayState* play, UNK_PTR puParm2, UNK_TYPE4 uParm3, UNK_TYPE4 uParm4); +// void func_80147F18(PlayState* play, UNK_PTR puParm2, UNK_TYPE4 uParm3, UNK_TYPE4 uParm4); +// void func_80148558(PlayState* play, UNK_PTR puParm2, UNK_TYPE4 uParm3, UNK_TYPE4 uParm4); +void func_80148B98(PlayState* play, u8 bParm2); // void func_80148CBC(void); // void func_80148D64(void); // void func_80149048(void); @@ -2588,29 +2397,29 @@ void func_80148B98(GlobalContext* globalCtx, u8 bParm2); // void func_80149454(void); // void func_801496C8(void); // void func_8014995C(void); -void func_80149C18(GlobalContext* globalCtx); +void func_80149C18(PlayState* play); // void Message_FindMessage(void); -void func_80149F74(GlobalContext* globalCtx, u32** ppuParm2); +void func_80149F74(PlayState* play, u32** ppuParm2); // void func_8014AAD0(void); -void func_8014ADBC(GlobalContext* globalCtx, UNK_PTR puParm2); +void func_8014ADBC(PlayState* play, UNK_PTR puParm2); // void func_8014C70C(void); -void Message_LoadChar(GlobalContext* globalCtx, u16 codePointIndex, s32* offset, f32* arg3, s16 arg4); +void Message_LoadChar(PlayState* play, u16 codePointIndex, s32* offset, f32* arg3, s16 arg4); // void func_8014CCB4(void); // void func_8014CDF0(void); // void func_8014CFDC(void); void func_8014D304(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE4 param_5); // void func_8014D62C(void); // void func_8014D7B4(void); -void func_80150A84(GlobalContext* globalCtx); -void func_80150D08(GlobalContext* globalCtx, u32 uParm2); +void func_80150A84(PlayState* play); +void func_80150D08(PlayState* play, u32 uParm2); // void func_801514B0(void); -void Message_StartTextbox(GlobalContext* globalCtx, u16 textId, Actor* Actor); -void func_80151938(GlobalContext* globalCtx, u16 textId); -void func_80151A68(GlobalContext* globalCtx, u16 textId); -void func_80151BB4(GlobalContext* globalCtx, u8 uParm2); +void Message_StartTextbox(PlayState* play, u16 textId, Actor* Actor); +void func_80151938(PlayState* play, u16 textId); +void func_80151A68(PlayState* play, u16 textId); +void func_80151BB4(PlayState* play, u8 uParm2); // void func_80151C9C(void); -void func_80151DA4(GlobalContext* globalCtx, u16 arg2); -void func_80152434(GlobalContext* globalCtx, u16 arg2); +void func_80151DA4(PlayState* play, u16 arg2); +void func_80152434(PlayState* play, u16 arg2); // void func_80152464(void); u8 Message_GetState(MessageContext* msgCtx); // void func_8015268C(void); @@ -2621,12 +2430,12 @@ u8 Message_GetState(MessageContext* msgCtx); // void func_80153750(void); // void func_80153E7C(void); // void func_80153EF0(void); -void func_801541D4(GlobalContext* globalCtx, Gfx** gfxp); +void func_801541D4(PlayState* play, Gfx** gfxp); // void func_80156758(void); -void func_8015680C(GlobalContext* globalCtx); -void func_801586A4(GlobalContext* globalCtx); -void Message_Init(GlobalContext* globalCtx); -void Message_FindMessageNES(GlobalContext* globalCtx, u16 textId); +void func_8015680C(PlayState* play); +void func_801586A4(PlayState* play); +void Message_Init(PlayState* play); +void Message_FindMessageNES(PlayState* play, u16 textId); // void Message_LoadCharNES(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE2 param_5); // void Message_LoadPluralRupeesNES(void); // void Message_LoadLocalizedRupeesNES(void); @@ -2634,11 +2443,11 @@ void Message_FindMessageNES(GlobalContext* globalCtx, u16 textId); // void Message_LoadTimeNES(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE4 param_5); // void Message_LoadAreaTextNES(void); // void func_80159438(void); -void func_8015966C(GlobalContext* globalCtx, UNK_PTR puParm2, UNK_TYPE arg3); +void func_8015966C(PlayState* play, UNK_PTR puParm2, UNK_TYPE arg3); // void func_8015A144(void); -void func_8015B198(GlobalContext* globalCtx); -void Message_FindCreditsMessage(GlobalContext *globalCtx, u16 textId); -void func_8015E7EC(GlobalContext* globalCtx, UNK_PTR puParm2); +void func_8015B198(PlayState* play); +void Message_FindCreditsMessage(PlayState* play, u16 textId); +void func_8015E7EC(PlayState* play, UNK_PTR puParm2); // void func_8015F8A8(UNK_TYPE4 ctxt); void ShrinkWindow_SetLetterboxTarget(s32 target); @@ -2677,14 +2486,14 @@ void func_80161C0C(void); void* KaleidoManager_FaultAddrConvFunc(void* address, void* param); void KaleidoManager_LoadOvl(KaleidoMgrOverlay* ovl); void KaleidoManager_ClearOvl(KaleidoMgrOverlay* ovl); -void KaleidoManager_Init(GlobalContext* globalCtx); +void KaleidoManager_Init(PlayState* play); void KaleidoManager_Destroy(); void* KaleidoManager_GetRamAddr(void* vram); void KaleidoScopeCall_LoadPlayer(void); -void KaleidoScopeCall_Init(GlobalContext* globalCtx); -void KaleidoScopeCall_Destroy(GlobalContext* globalCtx); -void KaleidoScopeCall_Update(GlobalContext* globalCtx); -void KaleidoScopeCall_Draw(GlobalContext* globalCtx); +void KaleidoScopeCall_Init(PlayState* play); +void KaleidoScopeCall_Destroy(PlayState* play); +void KaleidoScopeCall_Update(PlayState* play); +void KaleidoScopeCall_Draw(PlayState* play); // void func_80163C90(void); // void func_80163D80(void); // void func_80163DC0(void); @@ -2732,42 +2541,42 @@ void func_80165690(void); // void func_80165E7C(void); // void func_80165EC0(void); // void func_80166060(void); -Gfx* func_801660B8(GlobalContext* globalCtx, Gfx* gfx); -void Play_Fini(GameState* gameState); +Gfx* func_801660B8(PlayState* play, Gfx* gfx); +void Play_Destroy(GameState* thisx); // void func_801663C4(void); // void func_80166644(void); // void func_801668B4(void); -void func_80166968(GlobalContext* globalCtx, Camera* camera); -void func_80166B30(GlobalContext* globalCtx); -void func_80167814(GlobalContext* globalCtx); -void func_80167DE4(GlobalContext* globalCtx); +void func_80166968(PlayState* play, Camera* camera); +void func_80166B30(PlayState* play); +void Play_Update(PlayState* play); +void func_80167DE4(PlayState* play); // void func_80167F0C(void); -void Play_Draw(GlobalContext* globalCtx); -void func_80168DAC(GlobalContext* globalCtx); -void Play_Update(GlobalContext* globalCtx); -s32 Play_InCsMode(GlobalContext* globalCtx); -f32 func_80169100(GlobalContext* globalCtx, MtxF* mtx, CollisionPoly** arg2, s32* arg3, Vec3f* feetPosPtr); +void Play_Draw(PlayState* play); +void func_80168DAC(PlayState* play); +void Play_Main(PlayState* play); +s32 Play_InCsMode(PlayState* play); +f32 func_80169100(PlayState* play, MtxF* mtx, CollisionPoly** arg2, s32* arg3, Vec3f* feetPosPtr); // void func_801691F0(void); -void* Play_LoadScene(GlobalContext* globalCtx, RomFile* entry); -void func_8016927C(GlobalContext* globalCtx, s16 sParm2); -// void func_801692C4(GlobalContext* globalCtx, UNK_TYPE1 uParm2); -// void Play_SceneInit(GlobalContext* globalCtx, s32 sceneIndex, UNK_TYPE1 param_3); -UNK_RET func_80169474(GlobalContext* globalCtx, Vec3f* v1, Vec3f* v2); -s32 Play_CreateSubCamera(GlobalContext* globalCtx); -s32 Play_GetActiveCamId(GlobalContext* globalCtx); -void Play_CameraChangeStatus(GlobalContext* globalCtx, s16 camId, s16 status); -void Play_ClearCamera(GlobalContext* globalCtx, s16 camId); -Camera* Play_GetCamera(GlobalContext* globalCtx, s16 index); -s32 Play_CameraSetAtEye(GlobalContext* globalCtx, s16 camId, Vec3f* at, Vec3f* eye); -void Play_CameraSetAtEyeUp(GlobalContext* globalCtx, s16 camId, Vec3f* at, Vec3f* eye, Vec3f* up); -void Play_CameraSetFov(GlobalContext* globalCtx, s16 camId, f32 fov); -void Play_CameraSetRoll(GlobalContext* globalCtx, s16 camId, s16 roll); -void Play_CopyCamera(GlobalContext* globalCtx, s16 dstCamId, s16 srcCamId); -// void func_80169A50(void); -void Play_CameraChangeSetting(GlobalContext* globalCtx, s16 camId, s16 setting); -void func_80169AFC(GlobalContext* globalCtx, s16 camId, s16 arg2); -s16 Play_GetCsCamDataSetting(GlobalContext* globalCtx, s32 camId); -Vec3s* Play_GetCsCamDataVec3s(GlobalContext* globalCtx, s32 camId); +void* Play_LoadScene(PlayState* play, RomFile* entry); +void func_8016927C(PlayState* play, s16 sParm2); +// void func_801692C4(PlayState* play, UNK_TYPE1 uParm2); +// void Play_SceneInit(PlayState* play, s32 sceneIndex, UNK_TYPE1 param_3); +void Play_GetScreenPos(PlayState* play, Vec3f* worldPos, Vec3f* screenPos); +s16 Play_CreateSubCamera(PlayState* play); +s16 Play_GetActiveCamId(PlayState* play); +s32 Play_ChangeCameraStatus(PlayState* play, s16 camId, s16 status); +void Play_ClearCamera(PlayState* play, s16 camId); +Camera* Play_GetCamera(PlayState* play, s16 camId); +s32 Play_SetCameraAtEye(PlayState* play, s16 camId, Vec3f* at, Vec3f* eye); +s32 Play_SetCameraAtEyeUp(PlayState* play, s16 camId, Vec3f* at, Vec3f* eye, Vec3f* up); +s32 Play_SetCameraFov(PlayState* play, s16 camId, f32 fov); +s32 Play_SetCameraRoll(PlayState* play, s16 camId, s16 roll); +void Play_CopyCamera(PlayState* play, s16 dstCamId, s16 srcCamId); +s32 func_80169A50(PlayState* play, s16 camId, Player* player, s16 setting); +s32 Play_ChangeCameraSetting(PlayState* play, s16 camId, s16 setting); +void func_80169AFC(PlayState* play, s16 camId, s16 arg2); +u16 Play_GetActorCsCamSetting(PlayState* play, s32 csCamDataIndex); +Vec3s* Play_GetActorCsCamFuncData(PlayState* play, s32 csCamDataIndex); s16 Play_GetOriginalSceneNumber(s16 sceneNum); void Play_SaveCycleSceneFlags(GameState* gameState); void Play_SetRespawnData(GameState* gameState, s32 respawnNumber, u16 sceneSetup, s32 roomIndex, s32 playerParams, Vec3f* pos, s16 yaw); @@ -2778,8 +2587,8 @@ void func_80169FDC(GameState* gameState); s32 func_80169FFC(GameState* gameState); s32 FrameAdvance_IsEnabled(GameState* gameState); s32 func_8016A02C(GameState* gameState, Actor* actor, s16* yaw); -s32 Play_IsUnderwater(GlobalContext* globalCtx, Vec3f* pos); -s32 func_8016A168(void); +s32 Play_IsUnderwater(PlayState* play, Vec3f* pos); +s32 Play_IsDebugCamEnabled(void); void Play_AssignPlayerActorCsIdsFromScene(GameState* gameState, s32 cutscene); void func_8016A268(GameState* gameState, s16 arg1, u8 arg2, u8 arg3, u8 arg4, u8 arg5); void Play_Init(GameState* gameState); @@ -2793,7 +2602,7 @@ void Play_Init(GameState* gameState); // void func_8016EA90(void); // void func_8016F1A8(void); // void func_8016F4EC(void); -void func_8016F5A8(GlobalContext* globalCtx, s8* pcParm2, Input* iParm3); +void func_8016F5A8(PlayState* play, s8* pcParm2, Input* iParm3); // void func_8016FC78(void); // void func_8016FC98(void); void PreRender_SetValuesSave(PreRender* this, u32 width, u32 height, void* fbuf, void* zbuf, void* cvg); @@ -2852,7 +2661,7 @@ u32 THA_IsCrash(TwoHeadArena* tha); void THA_Init(TwoHeadArena* tha); void THA_Ct(TwoHeadArena* tha, void* ptr, size_t size); void THA_Dt(TwoHeadArena* tha); -void func_80172BC0(void); +void AudioMgr_StopAllSfxExceptSystem(void); void func_80172C30(AudioMgr* audioMgr); void AudioMgr_HandleRetrace(AudioMgr* audioMgr); void AudioMgr_HandlePRENMI(AudioMgr* audioMgr); @@ -2867,9 +2676,9 @@ void Game_UpdateFramerateVariables(s32 divisor); void Game_SetFramerateDivisor(GameState* gameState, s32 divisor); void GameState_SetFBFilter(Gfx** gfx, u32 arg1); void Game_Nop80173534(GameState* gameState); -void GameState_Draw(GameState* gameState, GraphicsContext* gCtxt); -void GameState_SetFrameBuffer(GraphicsContext* gCtxt); -void func_801736DC(GraphicsContext* gCtxt); +void GameState_Draw(GameState* gameState, GraphicsContext* gfxCtx); +void GameState_SetFrameBuffer(GraphicsContext* gfxCtx); +void func_801736DC(GraphicsContext* gfxCtx); void Game_UpdateInput(GameState* gameState); void Game_Update(GameState* gameState); void Game_IncrementFrameCount(GameState* gameState); @@ -2887,7 +2696,7 @@ void* GameAlloc_Malloc(GameAlloc* this, size_t size); void GameAlloc_Free(GameAlloc* this, void* data); void GameAlloc_Cleanup(GameAlloc* this); void GameAlloc_Init(GameAlloc* this); -void* Graph_FaultClient(void); +void Graph_FaultClient(void); void Graph_InitTHGA(TwoHeadGfxArena* arena, Gfx* buffer, s32 size); void Graph_SetNextGfxPool(GraphicsContext* gfxCtx); GameStateOverlay* Graph_GetNextGameState(GameState* gameState); @@ -2908,8 +2717,8 @@ ListAlloc* ListAlloc_Init(ListAlloc* this); void ListAlloc_FreeAll(ListAlloc* this); void Main(void* arg); u32 Padmgr_GetControllerBitmask(void); -// void func_80174F24(void); -// void func_80174F44(void); +void func_80174F24(void (*arg0)(void*), void* arg1); +void func_80174F44(void (*arg0)(void*), void* arg1); // void func_80174F7C(void); // void func_80174F9C(void); // OSMesgQueue* Padmgr_GetEventCallback(void); @@ -2920,10 +2729,10 @@ void Padmgr_SetEventCallback(OSMesg pvParm1); // void Padmgr_Unlock(void); // void func_801750FC(void); // void func_80175364(void); -// void func_80175434(void); -// void func_8017544C(void); -// void func_80175474(void); -// void func_801754C0(void); +void func_80175434(void); +void func_8017544C(s32 port, s32 rumbleOn); +void PadMgr_RumbleSet(u8 rumbleEnabled[MAXCONTROLLERS]); +s32 PadMgr_ControllerHasRumblePak(s32 port); void Padmgr_CalcStickEdges(Input* input); // void Padmgr_ParseState(void); // void func_801759BC(void); @@ -2966,7 +2775,7 @@ void SpeedMeter_DrawTimeEntries(void* displayList, GraphicsContext* gfxCtx); void SpeedMeter_DrawAllocEntries(void* displayList, GraphicsContext* gfxCtx, GameState* gameState); void func_801780F0(Mtx* param_1, f32 param_2, f32 param_3, f32 param_4, f32 param_5, f32 param_6, f32 param_7); // void func_801781EC(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE4 param_5); -// void func_8017842C(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE2 param_5, UNK_TYPE4 param_6, UNK_TYPE4 param_7, UNK_TYPE4 param_8, UNK_TYPE4 param_9, UNK_TYPE4 param_10, UNK_TYPE4 param_11); +void func_8017842C(MtxF* arg0, f32 arg1, f32 arg2, f32 arg3, s16 arg4, f32 arg5, f32 arg6, f32 arg7, f32 arg8, f32 arg9, f32 arg10); // void func_80178750(void); // void func_80178818(void); void func_80178978(void); @@ -3091,62 +2900,18 @@ s32 Math3D_XYInSphere(Sphere16* sphere, f32 x, f32 y); s32 Math3D_YZInSphere(Sphere16* sphere, f32 y, f32 z); // void func_8017FB1C(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE4 param_5, UNK_TYPE4 param_6, UNK_TYPE4 param_7, UNK_TYPE4 param_8, UNK_TYPE4 param_9, UNK_TYPE4 param_10, UNK_TYPE4 param_11); // void func_8017FD44(void); + u16 Math_GetAtan2Tbl(f32 opposite, f32 adjacent); s16 Math_Atan2S(f32 opposite, f32 adjacent); f32 Math_Atan2F(f32 opposite, f32 adjacent); s16 Math_FAtan2F(f32 adjacent, f32 opposite); f32 Math_Acot2F(f32 adjacent, f32 opposite); -void Matrix_StateAlloc(GameState* gameState); -void Matrix_StatePush(void); -void Matrix_StatePop(void); -void Matrix_CopyCurrentState(MtxF* matrix); -void Matrix_SetCurrentState(MtxF* matrix); -MtxF* Matrix_GetCurrentState(void); -void Matrix_InsertMatrix(MtxF* matrix, s32 appendToState); -void Matrix_InsertTranslation(f32 x, f32 y, f32 z, s32 appendToState); -void Matrix_Scale(f32 xScale, f32 yScale, f32 zScale, s32 appendToState); -void Matrix_InsertXRotation_s(s16 rotation, s32 appendToState); -void Matrix_InsertXRotation_f(f32 rotation, s32 appendToState); -void Matrix_RotateStateAroundXAxis(f32 rotation); -void Matrix_SetStateXRotation(f32 rotation); -void Matrix_RotateY(s16 rotation, s32 appendToState); -void Matrix_InsertYRotation_f(f32 rotation, s32 appendToState); -void Matrix_InsertZRotation_s(s16 rotation, s32 appendToState); -void Matrix_InsertZRotation_f(f32 rotation, s32 appendToState); -void Matrix_InsertRotation(s16 xRotation, s16 yRotation, s16 zRotation, s32 appendToState); -void Matrix_JointPosition(Vec3f* position, Vec3s* rotation); -void Matrix_RotateAndTranslateState(Vec3f* translation, Vec3s* rotation); -void Matrix_SetStateRotationAndTranslation(f32 x, f32 y, f32 z, Vec3s* rotation); -RSPMatrix* Matrix_ToRSPMatrix(MtxF* src, RSPMatrix* dst); -Mtx* Matrix_ToMtx(Mtx* dest); -RSPMatrix* Matrix_GetStateAsRSPMatrix(RSPMatrix* matrix); -Mtx* Matrix_NewMtx(GraphicsContext* gfxCtx); -RSPMatrix* Matrix_AppendStateToPolyOpaDisp(GraphicsContext* gfxCtx); -void Matrix_AppendToPolyOpaDisp(MtxF* mtx, GraphicsContext* gfxCtx); -void Matrix_MultiplyVector3fByState(Vec3f* src, Vec3f* dst); -void Matrix_GetStateTranslation(Vec3f* dst); -void Matrix_GetStateTranslationAndScaledX(f32 scale, Vec3f* dst); -void Matrix_GetStateTranslationAndScaledY(f32 scale, Vec3f* dst); -void Matrix_GetStateTranslationAndScaledZ(f32 scale, Vec3f* dst); -void Matrix_MultiplyVector3fXZByCurrentState(Vec3f* src, Vec3f* dst); -void Matrix_MtxFCopy(MtxF* dst, MtxF* src); -void Matrix_FromRSPMatrix(Mtx* src, MtxF* dst); -void Matrix_MultiplyVector3fByMatrix(Vec3f* src, Vec3f* dst, MtxF* matrix); -void Matrix_TransposeXYZ(MtxF* matrix); -void Matrix_NormalizeXYZ(MtxF* matrix); -void func_8018219C(MtxF* pfParm1, Vec3s* psParm2, s32 iParm3); -// void func_801822C4(void); -void Matrix_InsertRotationAroundUnitVector_f(f32 rotation, Vec3f* vector, s32 appendToState); -void Matrix_InsertRotationAroundUnitVector_s(s16 rotation, Vec3f* vector, s32 appendToState); u64* SysUcode_GetUCodeBoot(void); size_t SysUcode_GetUCodeBootSize(void); u64* SysUcode_GetUCode(void); u64* SysUcode_GetUCodeData(void); -// void func_80182CE0(void); -// void func_80183020(void); -// void func_80183058(void); void func_80183070(void); // void func_801830A0(void); // void func_801830C8(void); @@ -3156,7 +2921,7 @@ void func_80183070(void); // void func_801832B0(void); // void func_8018332C(void); // void func_8018340C(void); -void func_80183430(SkeletonInfo* skeletonInfo, void* arg1, void* arg2, Vec3s* arg3, s16* arg4, UnkKeyframeCallback* callbacks); +void func_80183430(SkeletonInfo* skeletonInfo, void* arg1, void* arg2, Vec3s* arg3, Vec3s* arg4, UnkKeyframeCallback* callbacks); void func_8018349C(UNK_PTR arg0); void func_801834A8(SkeletonInfo* skeletonInfo, void* arg1); // void func_80183510(void); @@ -3173,7 +2938,7 @@ void func_801835EC(UNK_PTR arg0, UNK_PTR arg1); // void func_80183B68(void); s32 func_80183DE0(SkeletonInfo* skeletonInfo); // void func_8018410C(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE4 param_5, UNK_TYPE4 param_6, UNK_TYPE4 param_7); -void func_8018450C(GlobalContext* globalCtx, SkeletonInfo* skeleton, Mtx* mtx, +void func_8018450C(PlayState* play, SkeletonInfo* skeleton, Mtx* mtx, OverrideKeyframeDrawScaled overrideKeyframeDraw, PostKeyframeDrawScaled postKeyframeDraw, Actor* actor); // void func_801845A4(void); @@ -3226,6 +2991,7 @@ void osFlashSectorEraseThrough(u32 pageNum); s32 osFlashWriteBuffer(OSIoMesg* mb, s32 priority, void* dramAddr, OSMesgQueue* mq); s32 osFlashWriteArray(u32 pageNum); s32 osFlashReadArray(OSIoMesg* mb, s32 priority, u32 pageNum, void* dramAddr, u32 pageCount, OSMesgQueue* mq); + // void func_801877D0(void); // void func_80187B64(void); // void func_80187BEC(void); @@ -3268,6 +3034,7 @@ s32 osFlashReadArray(OSIoMesg* mb, s32 priority, u32 pageNum, void* dramAddr, u3 // void func_8018A808(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE2 param_5, UNK_TYPE4 param_6); // void func_8018ACC4(void); // void func_8018AE34(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE4 param_5, UNK_TYPE4 param_6); + void AudioHeap_DiscardFont(s32 fontId); void* AudioHeap_WritebackDCache(void* addr, size_t size); void* AudioHeap_AllocAttemptExternal(AudioAllocPool* pool, size_t size); @@ -3287,6 +3054,7 @@ void* AudioHeap_AllocPermanent(s32 tableType, s32 id, size_t size); void* AudioHeap_AllocSampleCache(size_t size, s32 sampleBankId, void* sampleAddr, s8 medium, s32 cache); void AudioHeap_ApplySampleBankCache(s32 sampleBankId); void AudioHeap_SetReverbData(s32 reverbIndex, u32 dataType, s32 data, s32 flags); + void AudioLoad_DecreaseSampleDmaTtls(void); void* AudioLoad_DmaSampleData(uintptr_t devAddr, size_t size, s32 arg2, u8* dmaIndexRef, s32 medium); void AudioLoad_InitSampleDmaBuffers(s32 numNotes); @@ -3302,8 +3070,8 @@ void AudioLoad_AsyncLoadFont(s32 fontId, s32 arg1, s32 retData, OSMesgQueue* ret u8* AudioLoad_GetFontsForSequence(s32 seqId, u32* outNumFonts); void AudioLoad_DiscardSeqFonts(s32 seqId); void func_8018FA60(u32 tableType, u32 id, s32 arg2, s32 arg3); -s32 AudioLoad_SyncIniPlayer(s32 playerIdx, s32 seqId, s32 arg2); -s32 AudioLoad_SyncInitSetSeqqPlayerSkipTicks(s32 playerIdx, s32 seqId, s32 skipTicks); +s32 AudioLoad_SyncInitSeqPlayer(s32 playerIndex, s32 seqId, s32 arg2); +s32 AudioLoad_SyncInitSeqPlayerSkipTicks(s32 playerIndex, s32 seqId, s32 skipTicks); void AudioLoad_ProcessLoads(s32 resetStatus); void AudioLoad_SetDmaHandler(DmaHandler callback); void AudioLoad_Init(void* heap, u32 heapSize); @@ -3315,6 +3083,7 @@ void AudioLoad_LoadPermanentSamples(void); void AudioLoad_ScriptLoad(s32 tableType, s32 id, s8* isDone); void AudioLoad_ProcessScriptLoads(void); void AudioLoad_InitScriptLoads(void); + AudioTask* func_80192BE0(void); // void func_80192C00(void); // void func_8019319C(void); @@ -3323,10 +3092,10 @@ AudioTask* func_80192BE0(void); // void func_80193774(void); // void func_8019380C(void); // void func_80193858(void); -// void func_8019387C(void); -void Audio_QueueCmdS8(u32 opArgs, s8 data); +void AudioThread_QueueCmdS32(u32 opArgs, s32 data); +void AudioThread_QueueCmdS8(u32 opArgs, s8 data); // void func_801938D0(void); -// void func_80193900(void); +s32 AudioThread_ScheduleProcessCmds(void); // void func_80193990(void); // void func_801939A8(void); // void func_80193AEC(void); @@ -3348,13 +3117,14 @@ void Audio_QueueCmdS8(u32 opArgs, s8 data); // void func_80194528(void); // void func_80194548(void); // void func_80194568(void); -u32 Audio_NextRandom(void); -void Audio_InitMesgQueues(void); +u32 AudioThread_NextRandom(void); +void AudioThread_InitMesgQueues(void); + void Audio_InvalDCache(void* buf, size_t size); void Audio_WritebackDCache(void* buf, size_t size); -// void func_80194790(void); -// void func_80194840(void); -// void func_801948B0(void); + +s32 osAiSetNextBuffer(void* buf, u32 size); + void AudioPlayback_NoteDisable(Note* note); void AudioPlayback_ProcessNotes(void); SoundFontSound* AudioPlayback_InstrumentGetSound(Instrument* instrument, s32 semitone); @@ -3372,118 +3142,58 @@ void AudioPlayback_NotePoolFill(NotePool* pool, s32 count); void AudioPlayback_AudioListRemove(AudioListItem* item); Note* AudioPlayback_AllocNote(SequenceLayer* layer); void AudioPlayback_NoteInitAll(void); + void AudioEffects_SequencePlayerProcessSound(SequencePlayer* seqPlayer); void AudioEffects_NoteVibratoUpdate(Note* note); void AudioEffects_NoteVibratoInit(Note* note); void AudioEffects_NotePortamentoInit(Note* note); -void AudioEffects_AdsrInit(AdsrState* adsr, AdsrEnvelope* envelope, s16* volOut); +void AudioEffects_AdsrInit(AdsrState* adsr, EnvelopePoint* envelope, s16* volOut); f32 AudioEffects_AdsrUpdate(AdsrState* adsr); -// void func_801974D0(void); -// void func_80197538(void); -// void func_80197714(void); -// void func_80197880(void); -// void func_801979D8(void); -// void func_80197A54(void); + void AudioSeq_SequenceChannelDisable(SequenceChannel* channel); -// void func_80197B14(void); -// void func_80197C0C(void); -// void func_80197C8C(void); void AudioSeq_SequencePlayerDisableAsFinished(SequencePlayer* seqPlayer); void AudioSeq_SequencePlayerDisable(SequencePlayer* seqPlayer); void AudioSeq_AudioListPushBack(AudioListItem* list, AudioListItem* item); void* AudioSeq_AudioListPopBack(AudioListItem* list); -// void func_80197E88(void); -// void func_80197F28(void); -// void func_80197F3C(void); -// void func_80197F74(void); -// void func_80197FB4(void); -// void func_801980D0(void); -// void func_8019815C(void); -// void func_8019825C(void); -// void func_80198640(void); -// void func_80198CE0(void); -// void func_801990F4(void); -// void func_80199124(void); -// void func_80199198(void); -// void func_80199244(void); -void func_80199268(s32* param_1); -// void func_8019A0BC(void); -// void func_8019AA3C(void); -// void func_8019AAF0(void); +void AudioSeq_ProcessSequences(s32 arg0); +void AudioSeq_SkipForwardSequence(SequencePlayer* seqPlayer); void AudioSeq_ResetSequencePlayer(SequencePlayer* seqPlayer); -void AudioSeq_InitSequencePlayerChannels(s32 playerIdx); -// void func_8019ACEC(void); +void AudioSeq_InitSequencePlayerChannels(s32 playerIndex); void AudioSeq_InitSequencePlayers(void); + void func_8019AE40(s32 param_1, s32 param_2, u32 param_3, s32 param_4); void func_8019AEC0(UNK_PTR param_1, UNK_PTR param_2); -// void func_8019AF00(void); -// void func_8019AF58(void); -// void func_8019AFE8(void); -// void func_8019B02C(void); -// void AudioOcarina_MapSongFromNotesToButtons(void); -// void func_8019B144(void); -// void func_8019B378(void); -// void func_8019B38C(void); -// void func_8019B3D0(void); -// void func_8019B4B8(void); -void AudioOcarina_StartDefault(u32 arg0); -// void func_8019B568(void); -// void func_8019B5AC(void); -// void func_8019B5EC(void); -// void func_8019B618(void); -// void func_8019B654(void); -// void func_8019B6B4(void); -// void func_8019BC44(void); -// void func_8019BE98(void); -// void func_8019C1D0(void); -// void func_8019C268(void); -// void func_8019C2E4(void); -u32 AudioOcarina_SetInstrumentId(u8 arg0); -// void func_8019C398(void); -// void func_8019C5A0(void); -// void func_8019C8D8(void); -// void func_8019CD08(void); -// void func_8019CE34(void); -// void func_8019CE6C(void); -// void func_8019CEBC(void); -// void func_8019CF6C(void); -// void func_8019CF78(void); + +void AudioOcarina_SetSongStartingPos(void); +void AudioOcarina_StartAtSongStartingPos(u32 ocarinaFlags); +void AudioOcarina_StartForSongCheck(u32 ocarinaFlags, u8 ocarinaStaffPlayingPosStart); +void AudioOcarina_StartWithSongNoteLengths(u32 ocarinaFlags); +void AudioOcarina_StartDefault(u32 ocarinaFlags); +u8 func_8019B5AC(void); +void AudioOcarina_ResetAndReadInput(void); +void AudioOcarina_SetOcarinaDisableTimer(u8 resetUnused, u8 resetDelay); +u32 AudioOcarina_SetInstrument(u8 ocarinaInstrumentId); +void AudioOcarina_SetPlaybackSong(s8 songIndexPlusOne, u8 playbackState); +void AudioOcarina_SetRecordingState(u8 recordingState); +OcarinaStaff* AudioOcarina_GetRecordingStaff(void); +OcarinaStaff* AudioOcarina_GetPlayingStaff(void); OcarinaStaff* AudioOcarina_GetPlaybackStaff(void); -// void func_8019CFA8(void); -// void AudioOcarina_TerminaWallValidateNotes(void); void AudioOcarina_TerminaWallGenerateNotes(void); -// void AudioOcarina_MemoryGameSetNumNotes(void); -// void AudioOcarina_MemoryGameGenerateNotes(void); -// void func_8019D600(void); -void func_8019D758(void); -// void func_8019D864(void); -// void func_8019D8B4(void); -// void func_8019D8E4(void); -// void func_8019DF28(void); -// void func_8019DF64(void); +void AudioOcarina_PlayLongScarecrowAfterCredits(void); + void func_8019E014(void); // void func_8019E110(void); -// void func_8019E14C(void); -// void func_8019E324(void); -// void func_8019E4B0(void); -// void func_8019E634(void); -// void func_8019E864(void); -// void func_8019EA40(void); -// void func_8019EB2C(void); -// void func_8019F024(void); -// void func_8019F05C(void); +void AudioSfx_SetProperties(u8 bankId, u8 entryIndex, u8 channelIndex); void play_sound(u16 sfxId); void func_8019F128(u16 sfxId); void func_8019F170(Vec3f* pos, u16 sfxId); void Audio_PlaySfxAtPos(Vec3f* pos, u16 sfxId); void func_8019F208(void); // decide sfx void func_8019F230(void); // cancel sfx -// void func_8019F258(void); -// void func_8019F300(void); void func_8019F420(Vec3f* pos, u16 sfxId); void func_8019F4AC(Vec3f* pos, u16 sfxId); void func_8019F540(s8 arg0); -void func_8019F570(Vec3f* pos, s8 arg1); +void AudioSfx_LowerSfxSettingsReverb(Vec3f* pos, s8 isReverbLowered); // void func_8019F5AC(void); // void func_8019F638(void); // void func_8019F780(void); @@ -3515,9 +3225,9 @@ void func_801A0238(s32 arg0, s32 arg1); // void Audio_UpdateRiverSoundVolumes(void); // void func_801A0554(void); // void func_801A05F0(void); -void func_801A0654(Vec3f* arg0, u16 sfxId, s32 arg2); +void AudioSfx_SetChannelIO(Vec3f* pos, u16 sfxId, u8 ioData); void func_801A0810(Vec3f* arg0, u16 sfxId, u8 arg2); -// void func_801A0868(void); +void func_801A0868(Vec3f* pos, u16 sfxId, u8 val); // void func_801A09D4(void); // void Audio_SplitBgmChannels(void); // void func_801A0E44(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE4 param_5, UNK_TYPE4 param_6, UNK_TYPE4 param_7); @@ -3534,7 +3244,7 @@ void func_801A1DB8(Vec3f* vec, u8 seqId, f32 arg2); // void func_801A1E0C(void); void func_801A1F00(u8 arg0, u16 seqId); void func_801A1F88(void); -void func_801A1FB4(u8 playerIdx, Vec3f* pos, u16 seqId, f32 maxDist); +void func_801A1FB4(u8 playerIndex, Vec3f* pos, u16 seqId, f32 maxDist); // void func_801A2090(void); void func_801A246C(u8 param_1, u8 param_2); // void func_801A2544(void); @@ -3586,7 +3296,7 @@ void func_801A4058(UNK_TYPE arg0); // void func_801A42C8(void); // void func_801A4324(void); // void func_801A4348(void); -// void func_801A4380(void); +void Audio_SetSfxVolumeExceptSystemAndOcarinaBanks(u8 arg0); void func_801A4428(u8 reverbIndex); void Audio_PreNMI(void); // void func_801A44C4(void); @@ -3597,14 +3307,14 @@ void func_801A479C(Vec3f* arg0, u16 sfxId, s32 arg2); void func_801A47DC(u8 channelIndexRange, u8 port, u8 val); // void func_801A48E0(void); void func_801A4A28(u8 natureSeqId); -// void func_801A4B80(void); -void func_801A4C30(void); -// void func_801A4C54(void); +// void Audio_SetNatureAmbienceRandomBend(void); +void Audio_Init(void); void func_801A4D00(void); // void func_801A4D50(void); // void func_801A4DA4(void); // void func_801A4DF4(void); // void func_801A4E64(void); + // void func_801A4EB0(void); // void func_801A4EB8(void); // void func_801A4FD8(void); @@ -3623,36 +3333,31 @@ UNK_TYPE func_801A51F0(UNK_TYPE arg0); // void func_801A5808(void); // void func_801A5A10(void); // void func_801A5A1C(void); -void func_801A5BD0(s32 param_1); -// void func_801A5C28(void); -// void func_801A5C8C(void); -void Audio_PlaySfxGeneral(u16 sfxId, Vec3f* param_2, u8 param_3, f32* param_4, f32* param_5, s8* param_6); -// void func_801A5DDC(void); -// void func_801A5F7C(void); -// void func_801A6430(void); -// void func_801A65C8(void); -// void func_801A6D0C(void); -// void func_801A7084(void); -// void func_801A7168(void); -// void func_801A7284(void); -void Audio_StopSfxByPos(Vec3f* pos); -void func_801A7328(Vec3f* pos, u16 sfxId); -// void func_801A7484(void); -void func_801A75E8(u16 sfxId); -// void func_801A7720(void); -void func_801A7794(u32 param_1, u32 param_2, u32 param_3); -// void func_801A7828(void); -// void func_801A787C(void); -u8 Audio_IsSfxPlaying(u32 sfxId); -// void func_801A794C(void); -// void func_801A7B10(void); + +void AudioSfx_MuteBanks(u16 muteMask); +void AudioSfx_LowerBgmVolume(u8 channelIndex); +void AudioSfx_RestoreBgmVolume(u8 channelIndex); +void AudioSfx_PlaySfx(u16 sfxId, Vec3f* pos, u8 token, f32* freqScale, f32* volume, s8* reverbAdd); +void AudioSfx_ProcessRequest(void); +void AudioSfx_StopByBank(u8 bankId); +void AudioSfx_StopByPosAndBank(u8 bankId, Vec3f* pos); +void AudioSfx_StopByPos(Vec3f* pos); +void AudioSfx_StopByPosAndId(Vec3f* pos, u16 sfxId); +void AudioSfx_StopByTokenAndId(u8 token, u16 sfxId); +void AudioSfx_StopById(u32 sfxId); +void AudioSfx_ProcessRequests(void); +void AudioSfx_ProcessActiveSfx(void); +u8 AudioSfx_IsPlaying(u32 sfxId); +void AudioSfx_Reset(void); + +void Audio_StartSequence(u8 playerIndex, u8 seqId, u8 seqArgs, u16 fadeTimer); // void func_801A7D04(void); // void func_801A7D84(void); void Audio_QueueSeqCmd(u32 cmd); // void func_801A89D0(void); s32 func_801A8A50(s32 param1); // void func_801A8ABC(void); -void Audio_SetVolumeScale(u8 playerIdx, u8 scaleIdx, u8 targetVol, u8 volFadeTimer); +void Audio_SetVolumeScale(u8 playerIndex, u8 scaleIndex, u8 targetVol, u8 volFadeTimer); // void func_801A8D5C(void); // void func_801A8E90(void); // void func_801A9768(void); @@ -3660,9 +3365,9 @@ void Audio_SetVolumeScale(u8 playerIdx, u8 scaleIdx, u8 targetVol, u8 volFadeTim // void func_801A99B8(void); // void func_801A9A74(void); -void GameOver_Init(GlobalContext* globalCtx); -void GameOver_FadeLights(GlobalContext* globalCtx); -void GameOver_Update(GlobalContext* globalCtx); -void func_801AAAA0(GlobalContext* globalCtx); +void GameOver_Init(PlayState* play); +void GameOver_FadeLights(PlayState* play); +void GameOver_Update(PlayState* play); +void func_801AAAA0(PlayState* play); #endif diff --git a/include/gfxprint.h b/include/gfxprint.h new file mode 100644 index 000000000..e643b0504 --- /dev/null +++ b/include/gfxprint.h @@ -0,0 +1,49 @@ +#ifndef GFXPRINT_H +#define GFXPRINT_H + +#include "color.h" +#include "PR/gbi.h" +#include "PR/ultratypes.h" +#include "xstdio.h" + +#define GFXP_UNUSED "\x8E" +#define GFXP_UNUSED_CHAR 0x8E +#define GFXP_HIRAGANA "\x8D" +#define GFXP_HIRAGANA_CHAR 0x8D +#define GFXP_KATAKANA "\x8C" +#define GFXP_KATAKANA_CHAR 0x8C +#define GFXP_RAINBOW_ON "\x8B" +#define GFXP_RAINBOW_ON_CHAR 0x8B +#define GFXP_RAINBOW_OFF "\x8A" +#define GFXP_RAINBOW_OFF_CHAR 0x8A + +typedef struct GfxPrint { + /* 0x00 */ PrintCallback callback; + /* 0x04 */ Gfx* dList; + /* 0x08 */ u16 posX; + /* 0x0A */ u16 posY; + /* 0x0C */ u16 baseX; + /* 0x0E */ u8 baseY; + /* 0x0F */ u8 flags; + /* 0x10 */ Color_RGBA8_u32 color; + /* 0x14 */ UNK_TYPE1 unk_14[0x1C]; // unused +} GfxPrint; // size = 0x30 + +void GfxPrint_Setup(GfxPrint* printer); +void GfxPrint_SetColor(GfxPrint* printer, u32 r, u32 g, u32 b, u32 a); +void GfxPrint_SetPosPx(GfxPrint* printer, s32 x, s32 y); +void GfxPrint_SetPos(GfxPrint* printer, s32 x, s32 y); +void GfxPrint_SetBasePosPx(GfxPrint* printer, s32 x, s32 y); +void GfxPrint_PrintCharImpl(GfxPrint* printer, u8 c); +void GfxPrint_PrintChar(GfxPrint* printer, u8 c); +void GfxPrint_PrintStringWithSize(GfxPrint* printer, const void* buffer, size_t charSize, size_t charCount); +void GfxPrint_PrintString(GfxPrint* printer, const char* str); +void* GfxPrint_Callback(void* arg, const char* str, size_t size); +void GfxPrint_Init(GfxPrint* printer); +void GfxPrint_Destroy(GfxPrint* printer); +void GfxPrint_Open(GfxPrint* printer, Gfx* dList); +Gfx* GfxPrint_Close(GfxPrint* printer); +s32 GfxPrint_VPrintf(GfxPrint* printer, const char* fmt, va_list args); +s32 GfxPrint_Printf(GfxPrint* printer, const char* fmt, ...); + +#endif diff --git a/include/global.h b/include/global.h index 7c7971ee9..9fa3ef7bc 100644 --- a/include/global.h +++ b/include/global.h @@ -1,5 +1,5 @@ -#ifndef _GLOBAL_H_ -#define _GLOBAL_H_ +#ifndef GLOBAL_H +#define GLOBAL_H #include "z64.h" #include "regs.h" diff --git a/include/libc/math.h b/include/libc/math.h index c6756d959..1cdac0fb3 100644 --- a/include/libc/math.h +++ b/include/libc/math.h @@ -9,7 +9,6 @@ #define FLT_MAX 340282346638528859811704183484516925440.0f #define SHT_MAX 32767.0f #define SHT_MINV (1.0f / SHT_MAX) -#define DEGTORAD(x) ((x) * (M_PI / 180.0f)) typedef union { f64 d; diff --git a/include/libc/stdint.h b/include/libc/stdint.h index 1696615a7..20288d40d 100644 --- a/include/libc/stdint.h +++ b/include/libc/stdint.h @@ -11,19 +11,19 @@ typedef u32 uintptr_t; #define INT32_MIN (-0x80000000) #define INT64_MIN (-0x8000000000000000) -#define INT8_MAX 0x7f -#define INT16_MAX 0x7fff -#define INT32_MAX 0x7fffffff -#define INT64_MAX 0x7fffffffffffffff +#define INT8_MAX 0x7F +#define INT16_MAX 0x7FFF +#define INT32_MAX 0x7FFFFFFF +#define INT64_MAX 0x7FFFFFFFFFFFFFFF -#define UINT8_MAX 0xff -#define UINT16_MAX 0xffff -#define UINT32_MAX 0xffffffff -#define UINT64_MAX 0xffffffffffffffff +#define UINT8_MAX 0xFF +#define UINT16_MAX 0xFFFF +#define UINT32_MAX 0xFFFFFFFF +#define UINT64_MAX 0xFFFFFFFFFFFFFFFF #define INTPTR_MIN (-0x80000000) -#define INTPTR_MAX 0x7fffffff -#define UINTPTR_MAX 0xffffffff +#define INTPTR_MAX 0x7FFFFFFF +#define UINTPTR_MAX 0xFFFFFFFF #endif /* STDINT_H */ diff --git a/include/macros.h b/include/macros.h index 5e9c062c9..f713bf736 100644 --- a/include/macros.h +++ b/include/macros.h @@ -11,46 +11,30 @@ #define SCREEN_WIDTH_HIGH_RES 576 #define SCREEN_HEIGHT_HIGH_RES 454 +#define PROJECTED_TO_SCREEN_X(projectedPos, invW) ((projectedPos).x * (invW) * (SCREEN_WIDTH / 2) + (SCREEN_WIDTH / 2)) +#define PROJECTED_TO_SCREEN_Y(projectedPos, invW) ((projectedPos).y * (invW) * (-SCREEN_HEIGHT / 2) + (SCREEN_HEIGHT / 2)) + #define ARRAY_COUNT(arr) (s32)(sizeof(arr) / sizeof(arr[0])) #define ARRAY_COUNTU(arr) (u32)(sizeof(arr) / sizeof(arr[0])) // TODO: After uintptr_t cast change should have an AVOID_UB target that just toggles the KSEG0 bit in the address rather than add/sub 0x80000000 #define PHYSICAL_TO_VIRTUAL(addr) ((uintptr_t)(addr) + RDRAM_CACHED) -#define PHYSICAL_TO_VIRTUAL2(addr) ((uintptr_t)(addr) - RDRAM_CACHED) #define VIRTUAL_TO_PHYSICAL(addr) (uintptr_t)((u8*)(addr) - RDRAM_CACHED) #define SEGMENTED_TO_VIRTUAL(addr) (void*)(PHYSICAL_TO_VIRTUAL(gSegments[SEGMENT_NUMBER(addr)]) + SEGMENT_OFFSET(addr)) -#define GET_ACTIVE_CAM(globalCtx) ((globalCtx)->cameraPtrs[(globalCtx)->activeCamera]) -#define CAM_ID_MAIN 0 +#define GET_ACTIVE_CAM(play) ((play)->cameraPtrs[(play)->activeCamId]) #define SET_NEXT_GAMESTATE(curState, newInit, newStruct) \ (curState)->nextGameStateInit = (GameStateFunc)newInit; \ (curState)->nextGameStateSize = sizeof(newStruct) -#define SET_FULLSCREEN_VIEWPORT(view) \ - { \ - Viewport viewport; \ - viewport.bottomY = SCREEN_HEIGHT; \ - viewport.rightX = SCREEN_WIDTH; \ - viewport.topY = 0; \ - viewport.leftX = 0; \ - View_SetViewport(view, &viewport); \ - } \ - (void)0 +#define GET_PLAYER(play) ((Player*)(play)->actorCtx.actorLists[ACTORCAT_PLAYER].first) -#define GET_PLAYER(globalCtx) ((Player*)(globalCtx)->actorCtx.actorLists[ACTORCAT_PLAYER].first) - -#define GET_FIRST_ENEMY(globalCtx) ((Actor*)(globalCtx)->actorCtx.actorLists[ACTORCAT_ENEMY].first) - -// linkAge still exists in MM, but is always set to 0 (always adult) -// There are remnants of these macros from OOT, but they are essentially useless -#define LINK_IS_CHILD (gSaveContext.save.linkAge == 1) -#define LINK_IS_ADULT (gSaveContext.save.linkAge == 0) - -#define CURRENT_DAY (((void)0, gSaveContext.save.day) % 5) +#define GET_FIRST_ENEMY(play) ((Actor*)(play)->actorCtx.actorLists[ACTORCAT_ENEMY].first) #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))) @@ -58,62 +42,13 @@ #define TIME_TO_MINUTES_ALT_F(time) ((time) / (0x10000 / (24.0f * 60.0f))) #define CLOCK_TIME_ALT_F(hr, min) (((hr) * 60.0f + (min)) / (24.0f * 60.0f / 0x10000)) -#define SLOT(item) gItemSlots[item] -#define AMMO(item) gSaveContext.save.inventory.ammo[SLOT(item)] -#define INV_CONTENT(item) gSaveContext.save.inventory.items[SLOT(item)] -#define GET_INV_CONTENT(item) ((void)0, gSaveContext.save.inventory.items)[SLOT(item)] - -#define CUR_FORM ((gSaveContext.save.playerForm == PLAYER_FORM_HUMAN) ? 0 : gSaveContext.save.playerForm) - -#define GET_SAVE_EQUIPS_EQUIPMENT ((void)0, gSaveContext.save.equips.equipment) -#define GET_SAVE_INVENTORY_UPGRADES ((void)0, gSaveContext.save.inventory.upgrades) -#define GET_SAVE_INVENTORY_QUEST_ITEMS ((void)0, gSaveContext.save.inventory.questItems) - -#define GET_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) diff --git a/include/message_data_static.h b/include/message_data_static.h index f69e17232..d139c4621 100644 --- a/include/message_data_static.h +++ b/include/message_data_static.h @@ -3,7 +3,7 @@ #include "PR/ultratypes.h" -typedef struct MessageTableEntry{ +typedef struct MessageTableEntry { /* 0x0 */ u16 textId; /* 0x2 */ u8 typePos; /* 0x4 */ const char* segment; diff --git a/include/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 9942242a7..f8ce4ca86 100644 --- a/include/regs.h +++ b/include/regs.h @@ -74,10 +74,10 @@ #define R_MAGIC_BAR_X XREG(49) #define R_MAGIC_BAR_LARGE_Y XREG(50) #define R_MAGIC_FILL_X XREG(51) +#define R_MINIMAP_DISABLED XREG(95) #define R_B_LABEL_DD WREG(0) #define R_OW_MINIMAP_X WREG(29) #define R_OW_MINIMAP_Y WREG(30) -#define R_MINIMAP_TOGGLED WREG(31) #define R_B_LABEL_X(i) WREG(40 + i) #define R_B_LABEL_Y(i) WREG(43 + i) #define R_DGN_MINIMAP_X WREG(68) diff --git a/include/sfx.h b/include/sfx.h index 7430f8581..33c79abf4 100644 --- a/include/sfx.h +++ b/include/sfx.h @@ -1,6 +1,19 @@ #ifndef SFX_H #define SFX_H +/** + * With `SFX_FLAG` on, play the entire sfx audio clip. + * Requesting the sfx while playing will restart the sfx from the beginning. + * i.e. sfx only needs to be requested once. + * + * With `SFX_FLAG` off, play the sfx for only one frame. + * Requesting the sfx while playing will allow the sfx to continue to the next frame. + * i.e. sfx needs to be requested every frame. + * + * By default, `SFX_FLAG` is on. + * Use `- SFX_FLAG` to turn `SFX_FLAG` off. + */ +#define SFX_FLAG_MASK 0xC00 #define SFX_FLAG 0x800 // ------------ PLAYER ------------ @@ -469,28 +482,6 @@ #define NA_SE_PL_BOUND_METAL 0x9CD #define NA_SE_PL_WALK_WALL 0x9CE #define NA_SE_PL_WALK_WALL_DEKU 0x9CF -#define NA_SE_PL_WALK_WALL_ZORA 0x9D0 -#define NA_SE_PL_WALK_WALL_GORON 0x9D1 -#define NA_SE_PL_DEKU_IDOLING1 0x9D2 -#define NA_SE_PL_GOLON_IDOLING1 0x9D3 -#define NA_SE_PL_ZORA_IDOLING1 0x9D4 -#define NA_SE_PL_WALK_WALL2_METAL 0x9D5 -#define NA_SE_PL_WALK_WALL2_DEKU 0x9D6 -#define NA_SE_PL_WALK_WALL2_ZORA 0x9D7 -#define NA_SE_PL_WALK_WALL2_GORON 0x9D8 -#define NA_SE_PL_WALK_WEED 0x9D9 -#define NA_SE_PL_WALK_WOOD 0x9DA -#define NA_SE_PL_JUMP_WOOD 0x9DB -#define NA_SE_PL_LAND_WOOD 0x9DC -#define NA_SE_PL_GIANT_SWING 0x9DD -#define NA_SE_PL_GIANT_SWING2 0x9DE -#define NA_SE_PL_GIANT_SWING_FINISH 0x9DF -#define NA_SE_PL_GIANT_GUARD 0x9E0 -#define NA_SE_PL_GIANT_GUARD_OFF 0x9E1 -#define NA_SE_PL_GORON_GAKKI_START 0x9E2 -#define NA_SE_PL_KEIREI 0x9E3 -#define NA_SE_PL_GIANT_LINK_FOOT 0x9E4 -#define NA_SE_PL_DUMMY485 0x9E5 // ------------ ITEM ------------ @@ -605,6 +596,7 @@ #define NA_SE_IT_FISHING_WORM_BOUND 0x186C #define NA_SE_IT_DUMMY_109 0x186D #define NA_SE_IT_DUMMY_110 0x186E +#define NA_SE_IT_DUMMY_111 0x186F // ------------ ENVIRONMENT ------------ @@ -1072,72 +1064,6 @@ #define NA_SE_EV_DEMO_KID_SAGURU 0x29CD #define NA_SE_EV_WATER_WALL3 0x29CE #define NA_SE_EV_BOMBERS_TAORE 0x29CF -#define NA_SE_EV_RIVER_STREAM_TOWER 0x29D0 -#define NA_SE_EV_MONKEY_ROPE 0x29D1 -#define NA_SE_EV_MONKEY_FOOT_PAN 0x29D2 -#define NA_SE_EV_BODYFALL_SAND1 0x29D3 -#define NA_SE_EV_SCOOP_SAND1 0x29D4 -#define NA_SE_EV_CHICKEN_CRY_M_0600 0x29D5 -#define NA_SE_EV_WATER_WALL_BIG2 0x29D6 -#define NA_SE_EV_WATER_VOLTEX 0x29D7 -#define NA_SE_EV_WATER_WALL_IKANA 0x29D8 -#define NA_SE_EV_DOOR_OPEN_GATYA 0x29D9 -#define NA_SE_EV_CLAP_1SHOT 0x29DA -#define NA_SE_EV_TRR_APPEAR 0x29DB -#define NA_SE_EV_ICE_MELT_SHORT 0x29DC -#define NA_SE_EV_DEMO37_CLOTH1 0x29DD -#define NA_SE_EV_DEMO37_CLOTH2 0x29DE -#define NA_SE_EV_DEMO37_CLOTH3 0x29DF -#define NA_SE_EV_DEMO37_CLOTH4 0x29E0 -#define NA_SE_EV_WHITE_FAIRY_DASH_SHORT 0x29E1 -#define NA_SE_EV_WHITE_FAIRY_DASH_SHORT2 0x29E2 -#define NA_SE_EV_DEMO27_BODYFALL 0x29E3 -#define NA_SE_EV_DEMO30_LINK_RIDE 0x29E4 -#define NA_SE_EV_DEMO16_WHITEOUT 0x29E5 -#define NA_SE_EV_DEMO16_MIKAU_FADE 0x29E6 -#define NA_SE_EV_DEMO27_WHITEOUT 0x29E7 -#define NA_SE_SC_ZHOP_WAVE 0x29E8 -#define NA_SE_EV_DEMO02_ME1 0x29E9 -#define NA_SE_EV_DEMO02_WHOOSH 0x29EA -#define NA_SE_EV_DEMO02_ME2 0x29EB -#define NA_SE_EV_DEMO25_ME1 0x29EC -#define NA_SE_EV_DEMO25_HEAD_HIT 0x29ED -#define NA_SE_EV_TENTI_GYAKUTEN 0x29EE -#define NA_SE_EV_IKANA_JYOUKA 0x29EF -#define NA_SE_EV_IKANA_SHARP 0x29F0 -#define NA_SE_EV_IKANA_JYOUKA_FLASH 0x29F1 -#define NA_SE_EV_IKACASTLE_SLIDE1 0x29F2 -#define NA_SE_EV_OKUJYOU_WIND 0x29F3 -#define NA_SE_EV_CAM_WHOOSH 0x29F4 -#define NA_SE_EV_DESK_HIT 0x29F5 -#define NA_SE_EV_DEMO08_FIRE 0x29F6 -#define NA_SE_EV_DEMO08_ME1 0x29F7 -#define NA_SE_EV_OCARINA_FALL 0x29F8 -#define NA_SE_EV_LINK_WARP_LV 0x29F9 -#define NA_SE_EV_DEMO_ATATAME 0x29FA -#define NA_SE_EV_DEMO12_KIRAKIRA 0x29FB -#define NA_SE_EV_DEMO32_FIRE_SIPPAI 0x29FC -#define NA_SE_EV_KYOJIN_DOWN 0x29FD -#define NA_SE_EV_FACE_BREAKDOWN_OFF 0x29FE -#define NA_SE_EV_DEMO_MOON_IN 0x29FF -#define NA_SE_EV_1ST_MODORU_ME 0x2A00 -#define NA_SE_EV_WATER_WALL_BIG_SILENT2 0x2A01 -#define NA_SE_EV_MOONFALL_WIND1 0x2A02 -#define NA_SE_EV_MOONFALL_WIND2 0x2A03 -#define NA_SE_EV_MOONFALL_WIND3 0x2A04 -#define NA_SE_EV_MOONFALL_WIND4 0x2A05 -#define NA_SE_EV_TOKEITOU_EXPLO1 0x2A06 -#define NA_SE_EV_TOKEITOU_EXPLO2 0x2A07 -#define NA_SE_EV_MOONFALL_WIND5 0x2A08 -#define NA_SE_EV_MOONFALL_WIND6 0x2A09 -#define NA_SE_EV_MOONFALL_WIND7 0x2A0A -#define NA_SE_EV_GIANT_DOWN 0x2A0B -#define NA_SE_SC_DEMO_SPLASH1 0x2A0C -#define NA_SE_EV_TURI_SPLASH 0x2A0D -#define NA_SE_EV_DUMMY_525 0x2A0E -#define NA_SE_EV_WAVE_S_TURIBORI 0x2A0F -#define NA_SE_EN_LAST_DAMAGE_3DOFF 0x2A10 -#define NA_SE_EV_DUMMY_529 0x2A11 // ------------ ENEMY ------------ @@ -1877,41 +1803,6 @@ #define NA_SE_EN_KITA_SNORE 0x3ADD #define NA_SE_EN_IRONNACK_DASH 0x3ADE #define NA_SE_EN_TUBOOCK_FLY 0x3ADF -#define NA_SE_EN_MIMICK_BREATH 0x3AE0 -#define NA_SE_EN_FANTOM_DEAD 0x3AE1 -#define NA_SE_EN_KAICHO_PIYORI 0x3AE2 -#define NA_SE_EN_READED_WALK 0x3AE3 -#define NA_SE_EN_LEADED_WHITE 0x3AE4 -#define NA_SE_EN_MIBOSS_APPEAR_B_OLD 0x3AE5 -#define NA_SE_EN_MIBOSS_KICK_OLD 0x3AE6 -#define NA_SE_EN_MIBOSS_HEADDOWN_OLD 0x3AE7 -#define NA_SE_EN_MIBOSS_LEGDOWN_OLD 0x3AE8 -#define NA_SE_EN_MIBOSS_WEAKWAIT_OLD 0x3AE9 -#define NA_SE_EN_MIBOSS_THRUST1_OLD 0x3AEA -#define NA_SE_EN_MIBOSS_JUMP3_OLD 0x3AEB -#define NA_SE_EN_MIBOSS_SWORD_ROLL_OLD 0x3AEC -#define NA_SE_EN_MIBOSS_DANCE_THRUST_OLD 0x3AED -#define NA_SE_EN_MIBOSS_DANCE_FIRE_OLD 0x3AEE -#define NA_SE_EN_B_PAMET_ROCK 0x3AEF -#define NA_SE_EN_DUMMY753 0x3AF0 -#define NA_SE_EN_DUMMY_754 0x3AF1 -#define NA_SE_EN_FANTOM_FLOAT 0x3AF2 -#define NA_SE_EN_KONB_SUIKOMI 0x3AF3 -#define NA_SE_EN_KONB_LANDING_OLD 0x3AF4 -#define NA_SE_EN_KONB_SIBUKI_OLD 0x3AF5 -#define NA_SE_EN_KONB_PIYORI_OLD 0x3AF6 -#define NA_SE_EN_KOUME_UBAITORU 0x3AF7 -#define NA_SE_EN_STALKIDS_PSYCHO2 0x3AF8 -#define NA_SE_EN_RIZA_ATTACK3 0x3AF9 -#define NA_SE_EN_YASE_LAUGH_K_HOLD 0x3AFA -#define NA_SE_EN_WIZ_DEAD_NEW 0x3AFB -#define NA_SE_EN_HIPLOOP_BURN 0x3AFC -#define NA_SE_EN_EYEGOLE_HATAKI 0x3AFD -#define NA_SE_EN_DEKNUTS_DANCE_FADE 0x3AFE -#define NA_SE_EN_NUTS_FURUERU 0x3AFF -#define NA_SE_EN_PO_APPEAR_IDO 0x3B00 -#define NA_SE_EN_FOLLOWERS_TO_KABE 0x3B01 -#define NA_SE_EN_MUJURA_LAST_UP 0x3B02 // ------------ SYSTEM ------------ @@ -2011,31 +1902,6 @@ #define NA_SE_SY_TIME_CONTROL_SLOW 0x485D #define NA_SE_SY_TIME_CONTROL_NORMAL 0x485E #define NA_SE_SY_SECOM_WARNING 0x485F -#define NA_SE_SY_WIN_CHANGE 0x4860 -#define NA_SE_SY_TOUCH1 0x4861 -#define NA_SE_SY_MENU_CHAT_MOVE 0x4862 -#define NA_SE_SY_YUBI_MOVE 0x4863 -#define NA_SE_SY_CHAT_ALLERT_IN 0x4864 -#define NA_SE_SY_CHAT_ALLERT 0x4865 -#define NA_SE_SY_CHAT_ALLERT_OUT 0x4866 -#define NA_SE_SY_TOUCH2 0x4867 -#define NA_SE_SY_TOUCH2_OUT 0x4868 -#define NA_SE_SY_TOUCH3 0x4869 -#define NA_SE_SY_TOUCH4 0x486A -#define NA_SE_SY_YUBI_CURSOL_KEY 0x486B -#define NA_SE_SY_EVENT_INFO 0x486C -#define NA_SE_SY_CLEAR1 0x486D -#define NA_SE_SY_ALARM_MOVE 0x486E -#define NA_SE_SY_QUEST_NEW 0x486F -#define NA_SE_SY_EVENT_FAIL 0x4870 -#define NA_SE_SY_QUEST_CLEAR 0x4871 -#define NA_SE_SY_CHAT_ALARM_OFF 0x4872 -#define NA_SE_SY_CHAT_ALARM_INFO 0x4873 -#define NA_SE_SY_ICON_MOVE 0x4874 -#define NA_SE_SY_ICON_MOVE_SET 0x4875 -#define NA_SE_SY_DIAMOND_SWITCH 0x4876 -#define NA_SE_SY_PREDEMO_EVIL 0x4877 -#define NA_SE_SY_PREDEMO_OMEN 0x4878 // ------------ OCARINA ------------ @@ -2055,10 +1921,6 @@ #define NA_SE_OC_13 0x580D #define NA_SE_OC_14 0x580E #define NA_SE_OC_15 0x580F -#define NA_SE_OC_HINT_MOVIE 0x5810 -#define NA_SE_OC_HINT_MOVIE2_WHITE 0x5811 -#define NA_SE_OC_HINT_MOVIE_ZOOMIN 0x5812 -#define NA_SE_OC_HIBIKI_ISHI 0x5813 // ------------ VOICE ------------ @@ -2458,205 +2320,36 @@ #define NA_SE_VO_DEMO_388 0x6989 #define NA_SE_VO_DEMO_389 0x698A #define NA_SE_VO_DEMO_390 0x698B +#define NA_SE_VO_DEMO_391 0x698C +#define NA_SE_VO_DEMO_392 0x698D +#define NA_SE_VO_DEMO_393 0x698E +#define NA_SE_VO_DEMO_394 0x698F -// ------------ UNKNOWN ------------ +// ------------ Sfx Table ------------ +// TODO: Extract via table after 100% decompilation /* -#define NA_BGM_DEMO_SE_SEQ 0x7800 -#define NA_BGM_DEMO_SE_SEQ_1 0x7801 -#define NA_BGM_DEMO_SE_SEQ_2 0x7802 -#define NA_BGM_DEMO_SE_SEQ_3 0x7803 -#define NA_BGM_DEMO_SE_SEQ_4 0x7804 -#define NA_BGM_DEMO_SE_SEQ_5 0x7805 -#define NA_BGM_DEMO_SE_SEQ_6 0x7806 -#define NA_BGM_DEMO_SE_SEQ_7 0x7807 -#define NA_BGM_DEMO_SE_SEQ_8 0x7808 -#define NA_BGM_DEMO_SE_SEQ_9 0x7809 -#define NA_BGM_DEMO_SE_SEQ_A 0x780A -#define NA_BGM_DEMO_SE_SEQ_B 0x780B -#define NA_BGM_DEMO_SE_SEQ_C 0x780C -#define NA_BGM_DEMO_SE_SEQ_D 0x780D -#define NA_BGM_DEMO_SE_SEQ_E 0x780E -#define NA_BGM_DEMO_SE_SEQ_F 0x780F -#define NA_SE_EN_MIBOSS_FALL 0x7810 -#define NA_SE_EN_MIBOSS_DAMAGE 0x7811 -#define NA_SE_EN_MIBOSS_DASH 0x7812 -#define NA_SE_EN_MIBOSS_DEAD 0x7813 -#define NA_SE_EN_MIBOSS_GND1 0x7814 -#define NA_SE_EN_MIBOSS_GND2 0x7815 -#define NA_SE_EN_MIBOSS_UNARI 0x7816 -#define NA_SE_EN_MIBOSS_RHYTHM 0x7817 -#define NA_SE_EN_MIBOSS_SWORD 0x7818 -#define NA_SE_EN_MIBOSS_JUMP1_NOTUSE 0x7819 -#define NA_SE_EN_MIBOSS_JUMP2_NOTUSE 0x781A -#define NA_SE_EN_MIBOSS_VOICE1 0x781B -#define NA_SE_EN_MIBOSS_VOICE2 0x781C -#define NA_SE_EN_MIBOSS_VOICE3 0x781D -#define NA_SE_EN_MIBOSS_FAINT 0x781E -#define NA_SE_EN_MIBOSS_ROLLING 0x781F -#define NA_SE_EN_MIBOSS_FREEZE 0x7820 -#define NA_SE_EN_MIBOSS_APPEAR_B 0x7821 -#define NA_SE_EN_MIBOSS_KICK 0x7822 -#define NA_SE_EN_MIBOSS_HEADDOWN 0x7823 -#define NA_SE_EN_MIBOSS_LEGDOWN 0x7824 -#define NA_SE_EN_MIBOSS_WEAKWAIT 0x7825 -#define NA_SE_EN_MIBOSS_THRUST1 0x7826 -#define NA_SE_EN_MIBOSS_JUMP3 0x7827 -#define NA_SE_EN_MIBOSS_SWORD_ROLL 0x7828 -#define NA_SE_EN_MIBOSS_DANCE_THRUST 0x7829 -#define NA_SE_EN_MIBOSS_DANCE_FIRE 0x782A -#define NA_SE_EN_ICEB_FOOTSTEP 0x782B -#define NA_SE_EN_ICEB_CRY 0x782C -#define NA_SE_EN_ICEB_STEAM_LONG 0x782D -#define NA_SE_EN_ICEB_STEAMS_DEMO 0x782E -#define NA_SE_EN_ICEB_STEAM_DEMO_UP 0x782F -#define NA_SE_EN_ICEB_DEAD 0x7830 -#define NA_SE_EN_ICEB_DAMAGE 0x7831 -#define NA_SE_EN_ICEB_SLIDING 0x7832 -#define NA_SE_EN_ICEB_BACK_ATTACK2 0x7833 -#define NA_SE_EN_KONB_BITE 0x7834 -#define NA_SE_EN_KONB_BOUND 0x7835 -#define NA_SE_EN_KONB_BOUND2 0x7836 -#define NA_SE_EN_KONB_DAMAGE 0x7837 -#define NA_SE_EN_KONB_DEAD 0x7838 -#define NA_SE_EN_KONB_DEAD2 0x7839 -#define NA_SE_EN_KONB_DEAD_JUMP 0x783A -#define NA_SE_EN_KONB_DEAD_JUMP2 0x783B -#define NA_SE_EN_KONB_DEMO_MOVE 0x783C -#define NA_SE_EN_KONB_INIT 0x783D -#define NA_SE_EN_KONB_JUMP 0x783E -#define NA_SE_EN_KONB_JUMP_LEV 0x783F -#define NA_SE_EN_KONB_LANDING 0x7840 -#define NA_SE_EN_KONB_MINI_APPEAR_NOTUSE 0x7841 -#define NA_SE_EN_KONB_PIYORI 0x7842 -#define NA_SE_EN_KONB_PREATTACK 0x7843 -#define NA_SE_EN_KONB_SIBUKI 0x7844 -#define NA_SE_EN_KONB_SINK 0x7845 -#define NA_SE_EN_KONB_WAIT 0x7846 -#define NA_SE_EN_KONB_DODAI_FALL 0x7847 -#define NA_SE_EN_KONB_SUIKOMU 0x7848 -#define NA_SE_EN_KONB_TABERU 0x7849 -#define NA_SE_EN_KONB_TOBIDASU 0x784A -#define NA_SE_EN_KONB_TOSSIN1_KAMAE 0x784B -#define NA_SE_EN_KONB_TOSSIN1_DASH 0x784C -#define NA_SE_EN_KONB_TOSSIN1_TYAKUSUI 0x784D -#define NA_SE_EN_KONB_BOMB1_INSIDE 0x784E -#define NA_SE_EN_KONB_BOMB1_OUTSIDE 0x784F -#define NA_SE_EN_KONB_MEDAMA_APPEAR 0x7850 -#define NA_SE_EN_KONB_BOMB_CHAIN 0x7851 -#define NA_SE_EN_KONB_CHIAN_SLASH 0x7852 -#define NA_SE_EN_KONB_INFO_SAKEBI 0x7853 -#define NA_SE_EN_KONB_INFO_SAKEBI_LONG 0x7854 -#define NA_SE_EN_KONB_DODAI_ATTACK1 0x7855 -#define NA_SE_EN_KONB_DODAI_ATTACK2 0x7856 -#define NA_SE_EN_KONB_TAORE 0x7857 -#define NA_SE_EN_INBOSS_SAND 0x7858 -#define NA_SE_EN_INBOSS_ROAR 0x7859 -#define NA_SE_EN_INBOSS_DAMAGE 0x785A -#define NA_SE_EN_INBOSS_DEAD_PRE2 0x785B -#define NA_SE_EN_INBOSS_DEAD 0x785C -#define NA_SE_EN_INBOSS_DOWN_PRE 0x785D -#define NA_SE_EN_INBOSS_BRESS_PRE 0x785E -#define NA_SE_EN_INBOSS_SANRAN 0x785F -#define NA_SE_EN_INBOSS_CHIBI_WALK 0x7860 -#define NA_SE_EN_INBOSS_CHIBI_DAMAGE 0x7861 -#define NA_SE_EN_INBOSS_CHIBI_DEAD 0x7862 -#define NA_SE_EN_INBOSS_CHIBI_RUN 0x7863 -#define NA_SE_EN_INBOSS_JIMEN_MORI 0x7864 -#define NA_SE_EN_INBOSS_JIMEN_DERU 0x7865 -#define NA_SE_EN_INBOSS_UNDER_MOVE 0x7866 -#define NA_SE_EN_INBOSS_BREATH 0x7867 -#define NA_SE_EN_INBOSS_DAMAGE_MOVE 0x7868 -#define NA_SE_EN_INBOSS_MEDAMA_DERU 0x7869 -#define NA_SE_EN_INBOSS_FIREBALL_FLY 0x786A -#define NA_SE_EN_INBOSS_SANRAN_SHORT 0x786B -#define NA_SE_EN_INBOSS_DOWN 0x786C -#define NA_SE_EN_INBOSS_DEAD_RED 0x786D -#define NA_SE_EN_INBOSS_TAME 0x786E -#define NA_SE_EN_LAST1_ATTACK 0x786F -#define NA_SE_EN_LAST1_ATTACK_2ND 0x7870 -#define NA_SE_EN_LAST1_BEAM 0x7871 -#define NA_SE_EN_LAST1_BEAM2 0x7872 -#define NA_SE_EN_LAST1_BLOW 0x7873 -#define NA_SE_EN_LAST1_DAMAGE1 0x7874 -#define NA_SE_EN_LAST1_DAMAGE2 0x7875 -#define NA_SE_EN_LAST1_DEAD 0x7876 -#define NA_SE_EN_LAST1_DEMO_BREAK_NOUSE 0x7877 -#define NA_SE_EN_LAST1_DEMO_WALL_NOUSE 0x7878 -#define NA_SE_EN_LAST1_FALL 0x7879 -#define NA_SE_EN_LAST1_FLOAT 0x787A -#define NA_SE_EN_LAST1_GROW_HEAD_NOTUSE 0x787B -#define NA_SE_EN_LAST1_ROLLING 0x787C -#define NA_SE_EN_LAST1_TRANSFORM_NOTUSE 0x787D -#define NA_SE_EN_LAST2_BALLET 0x787E -#define NA_SE_EN_LAST2_BIRD 0x787F -#define NA_SE_EN_LAST2_BIRD2 0x7880 -#define NA_SE_EN_LAST2_DAMAGE 0x7881 -#define NA_SE_EN_LAST2_DAMAGE2 0x7882 -#define NA_SE_EN_LAST2_DEAD 0x7883 -#define NA_SE_EN_LAST2_FIRE 0x7884 -#define NA_SE_EN_LAST2_GROW_HEAD 0x7885 -#define NA_SE_EN_LAST2_VOICE_UAUOO2 0x7886 -#define NA_SE_EN_LAST2_GYM_B 0x7887 -#define NA_SE_EN_LAST2_HEARTBEAT 0x7888 -#define NA_SE_EN_LAST2_JUMP 0x7889 -#define NA_SE_EN_LAST2_VOICE_UAUOO1 0x788A -#define NA_SE_EN_LAST2_MOONWALK 0x788B -#define NA_SE_EN_LAST2_PUMP_UP 0x788C -#define NA_SE_EN_LAST2_SHOUT_NOTUSE 0x788D -#define NA_SE_EN_LAST2_VOICE_SURPRISED 0x788E -#define NA_SE_EN_LAST2_UAUOO 0x788F -#define NA_SE_EN_LAST2_WAIT 0x7890 -#define NA_SE_EN_LAST2_WALK 0x7891 -#define NA_SE_EN_LAST2_WALK2 0x7892 -#define NA_SE_EN_LAST3_COIL_ATTACK 0x7893 -#define NA_SE_EN_LAST3_VOICE_DAMAGE 0x7894 -#define NA_SE_EN_LAST3_VOICE_DAMAGE2 0x7895 -#define NA_SE_EN_LAST3_VOICE_DEAD 0x7896 -#define NA_SE_EN_LAST3_DEAD_DEAD1 0x7897 -#define NA_SE_EN_LAST3_DEAD_DEAD2 0x7898 -#define NA_SE_EN_LAST3_DEAD_FLOAT_NOTUSE 0x7899 -#define NA_SE_EN_LAST3_DEAD_LIGHTS 0x789A -#define NA_SE_EN_LAST3_DEAD_ROD_NOTUSE 0x789B -#define NA_SE_EN_LAST3_DEAD_WIND1 0x789C -#define NA_SE_EN_LAST3_DEAD_WIND2 0x789D -#define NA_SE_EN_LAST3_DEAD_WIND3 0x789E -#define NA_SE_EN_LAST3_GET_LINK 0x789F -#define NA_SE_EN_LAST3_VOICE_KICK 0x78A0 -#define NA_SE_EN_LAST3_KOMA 0x78A1 -#define NA_SE_EN_LAST3_ROD_DANCE 0x78A2 -#define NA_SE_EN_LAST3_ROD_MID 0x78A3 -#define NA_SE_EN_LAST3_ROD_FLOOR 0x78A4 -#define NA_SE_EN_LAST3_ROD_HOP 0x78A5 -#define NA_SE_EN_LAST3_ROD_HOP2 0x78A6 -#define NA_SE_EN_LAST3_ROD_WIND 0x78A7 -#define NA_SE_EN_LAST3_VOICE_KOMA 0x78A8 -#define NA_SE_EN_LAST3_VOICE_ROD 0x78A9 -#define NA_SE_EN_LAST3_VOICE_THROW 0x78AA -#define NA_SE_EN_LAST3_VOICE_LAUGH 0x78AB -#define NA_SE_EN_LAST1_SIZZLE 0x78AC -#define NA_SE_EN_LAST1_LAND2 0x78AD -#define NA_SE_EN_LAST3_WHIP1 0x78AE -#define NA_SE_EV_LAVA_HIT 0x78AF -#define NA_SE_EV_LAVA_WHOOSH 0x78B0 -#define Wind_seq1 0x78B1 -#define Bird_seqs 0x78B2 -#define Rain_seq0 0x78B3 -#define Thun_seq0 0x78B4 -#define NA_BGM_OCA_EPONA_SEQ 0x78B5 -#define NA_BGM_OCA_TIME_SEQ 0x78B6 -#define NA_BGM_OCA_STORM_SEQ 0x78B7 -#define NA_BGM_OCA_BIGWING_SEQ 0x78B8 -#define NA_BGM_OCA_TIME_SPEED_SEQ 0x78B9 -#define NA_BGM_OCA_TIME_JUMP_SEQ 0x78BA -#define NA_BGM_OCA_AWAKING_SEQ 0x78BB -#define NA_BGM_OCA_CURE_SEQ 0x78BC -#define NA_BGM_OCA_LULLABY_HALF_SEQ 0x78BD -#define NA_BGM_OCA_LULLABY_SEQ 0x78BE -#define NA_BGM_OCA_PLEDGE_SEQ 0x78BF -#define NA_BGM_OCA_TIDE_SEQ 0x78C0 -#define NA_BGM_OCA_SHELL_SEQ 0x78C1 -#define NA_BGM_GERO_SEQ 0x78C2 +#define DEFINE_SFX(enum, _1, _2, _3, _4, _5) enum, + +typedef enum { + NA_SE_PL_BASE = 0x7FF, + #include "tables/sfx/playerbank_table.h" + NA_SE_IT_BASE = 0x17FF, + #include "tables/sfx/itembank_table.h" + NA_SE_EV_BASE = 0x27FF, + #include "tables/sfx/environmentbank_table.h" + NA_SE_EN_BASE = 0x37FF, + #include "tables/sfx/enemybank_table.h" + NA_SE_SY_BASE = 0x47FF, + #include "tables/sfx/systembank_table.h" + NA_SE_OC_BASE = 0x57FF, + #include "tables/sfx/ocarinabank_table.h" + NA_SE_VO_BASE = 0x67FF, + #include "tables/sfx/voicebank_table.h" + NA_SE_MAX +} SfxId; + +#undef DEFINE_SFX */ #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/tables/sfx/enemybank_table.h b/include/tables/sfx/enemybank_table.h new file mode 100644 index 000000000..e969fef59 --- /dev/null +++ b/include/tables/sfx/enemybank_table.h @@ -0,0 +1,749 @@ +/** + * Sfx Enemy Bank + * + * DEFINE_SFX should be used for all sfx define in the enemy bank from sequence 0 + * - Argument 0: Enum value for this sfx + * - Argument 1: Importance for deciding which sfx to prioritize. Higher values have greater importance + * - Argument 2: Slows the decay of volume with distance (a 3-bit number ranging from 0-7) + * - Argument 3: Applies increasingly random offsets to frequency (a 2-bit number ranging from 0-3) + * - Argument 4: Various flags to add properties to the sfx + * - Argument 5: Various flags to add properties to the sfx + * + * WARNING: entries must align with the table defined for the enemy bank in sequence 0 + */ +/* 0x3800 */ DEFINE_SFX(NA_SE_EN_DODO_J_WALK, 0x18, 1, 0, 0, 0) +/* 0x3801 */ DEFINE_SFX(NA_SE_EN_DODO_J_CRY, 0x30, 1, 0, 0, 0) +/* 0x3802 */ DEFINE_SFX(NA_SE_EN_DODO_J_FIRE, 0x30, 1, 0, 0, 0) +/* 0x3803 */ DEFINE_SFX(NA_SE_EN_DODO_J_DAMAGE, 0x38, 1, 0, 0, 0) +/* 0x3804 */ DEFINE_SFX(NA_SE_EN_DODO_J_DEAD, 0x40, 1, 0, 0, 0) +/* 0x3805 */ DEFINE_SFX(NA_SE_EN_BAKUO_ROLL, 0x30, 3, 0, 0, 0) +/* 0x3806 */ DEFINE_SFX(NA_SE_EN_MIZUBABA2_VOICE, 0x36, 0, 0, 0, 0) +/* 0x3807 */ DEFINE_SFX(NA_SE_EN_MIZUBABA2_DAMAGE, 0x38, 0, 0, 0, 0) +/* 0x3808 */ DEFINE_SFX(NA_SE_EN_MIBOSS_FALL_OLD_OLD, 0x40, 3, 0, 0, 0) +/* 0x3809 */ DEFINE_SFX(NA_SE_EN_MIBOSS_DAMAGE_OLD, 0x58, 3, 0, 0, 0) +/* 0x380A */ DEFINE_SFX(NA_SE_EN_MIBOSS_DASH_OLD, 0x40, 3, 0, 0, 0) +/* 0x380B */ DEFINE_SFX(NA_SE_EN_MIBOSS_DEAD_OLD, 0x68, 3, 0, 0, SFX_FLAG_REVERB_NO_DIST) +/* 0x380C */ DEFINE_SFX(NA_SE_EN_MIBOSS_GND1_OLD, 0x40, 3, 0, 0, 0) +/* 0x380D */ DEFINE_SFX(NA_SE_EN_GOMA_DOWN, 0x30, 3, 0, 0, 0) +/* 0x380E */ DEFINE_SFX(NA_SE_EN_MIBOSS_GND2_OLD, 0x40, 3, 0, 0, 0) +/* 0x380F */ DEFINE_SFX(NA_SE_EN_MIBOSS_UNARI_OLD, 0x40, 3, 0, 0, 0) +/* 0x3810 */ DEFINE_SFX(NA_SE_EN_MIBOSS_RHYTHM_OLD, 0x54, 3, 0, 0, SFX_FLAG_LOWER_VOLUME_BGM) +/* 0x3811 */ DEFINE_SFX(NA_SE_EN_MIBOSS_SWORD_OLD, 0x54, 3, 0, 0, 0) +/* 0x3812 */ DEFINE_SFX(NA_SE_EN_ANSATSUSYA_ENTRY, 0x30, 3, 0, 0, 0) +/* 0x3813 */ DEFINE_SFX(NA_SE_EN_MIBOSS_JUMP1, 0x40, 3, 0, 0, 0) +/* 0x3814 */ DEFINE_SFX(NA_SE_EN_MIBOSS_JUMP2, 0x40, 3, 0, 0, 0) +/* 0x3815 */ DEFINE_SFX(NA_SE_EN_MIBOSS_VOICE1_OLD, 0x54, 3, 0, 0, 0) +/* 0x3816 */ DEFINE_SFX(NA_SE_EN_MIBOSS_VOICE2_OLD, 0x54, 3, 0, 0, 0) +/* 0x3817 */ DEFINE_SFX(NA_SE_EN_MIBOSS_VOICE3_OLD, 0x54, 3, 0, 0, 0) +/* 0x3818 */ DEFINE_SFX(NA_SE_EN_INBOSS_SAND_OLD, 0x30, 3, 0, 0, SFX_FLAG_VOLUME_NO_DIST) +/* 0x3819 */ DEFINE_SFX(NA_SE_EN_INBOSS_ROAR_OLD, 0x50, 3, 0, 0, 0) +/* 0x381A */ DEFINE_SFX(NA_SE_EN_INBOSS_DAMAGE_OLD, 0x58, 3, 0, 0, 0) +/* 0x381B */ DEFINE_SFX(NA_SE_EN_COMMON_WEAKENED, 0x38, 3, 0, 0, 0) +/* 0x381C */ DEFINE_SFX(NA_SE_EN_MIBOSS_FAINT_OLD, 0x50, 3, 0, 0, 0) +/* 0x381D */ DEFINE_SFX(NA_SE_EN_MIBOSS_ROLLING_OLD, 0x30, 3, 0, 0, 0) +/* 0x381E */ DEFINE_SFX(NA_SE_EN_MIZUBABA1_DAMAGE, 0x38, 0, 0, 0, 0) +/* 0x381F */ DEFINE_SFX(NA_SE_EN_MIZUBABA_DEAD, 0x48, 0, 0, 0, 0) +/* 0x3820 */ DEFINE_SFX(NA_SE_EN_DODO_M_CRY, 0x30, 0, 0, 0, 0) +/* 0x3821 */ DEFINE_SFX(NA_SE_EN_DODO_M_DEAD, 0x40, 1, 0, 0, 0) +/* 0x3822 */ DEFINE_SFX(NA_SE_EN_DODO_M_MOVE, 0x18, 0, 0, 0, 0) +/* 0x3823 */ DEFINE_SFX(NA_SE_EN_DODO_M_DOWN, 0x14, 0, 0, 0, 0) +/* 0x3824 */ DEFINE_SFX(NA_SE_EN_DODO_M_UP, 0x14, 0, 0, 0, 0) +/* 0x3825 */ DEFINE_SFX(NA_SE_EN_MIZUBABA_TRANSFORM, 0x30, 0, 0, 0, 0) +/* 0x3826 */ DEFINE_SFX(NA_SE_EN_DODO_M_EAT, 0x30, 0, 0, 0, 0) +/* 0x3827 */ DEFINE_SFX(NA_SE_EN_MIZUBABA2_WALK, 0x28, 0, 0, 0, SFX_PARAM_RAND_FREQ_LOWER) +/* 0x3828 */ DEFINE_SFX(NA_SE_EN_BOMCHU_WALK, 0x28, 0, 0, 0, 0) +/* 0x3829 */ DEFINE_SFX(NA_SE_EN_RIZA_CRY, 0x30, 2, 0, 0, 0) +/* 0x382A */ DEFINE_SFX(NA_SE_EN_RIZA_ATTACK, 0x32, 2, 0, 0, 0) +/* 0x382B */ DEFINE_SFX(NA_SE_EN_RIZA_DAMAGE, 0x38, 1, 0, 0, 0) +/* 0x382C */ DEFINE_SFX(NA_SE_EN_RIZA_WARAU, 0x20, 0, 0, 0, 0) +/* 0x382D */ DEFINE_SFX(NA_SE_EN_RIZA_DEAD, 0x40, 1, 0, 0, 0) +/* 0x382E */ DEFINE_SFX(NA_SE_EN_RIZA_WALK, 0x18, 0, 0, 0, 0) +/* 0x382F */ DEFINE_SFX(NA_SE_EN_RIZA_JUMP, 0x28, 0, 0, 0, 0) +/* 0x3830 */ DEFINE_SFX(NA_SE_EN_STALKID_WALK, 0x18, 0, 1, 0, 0) +/* 0x3831 */ DEFINE_SFX(NA_SE_EN_STALKID_ATTACK, 0x30, 0, 0, 0, 0) +/* 0x3832 */ DEFINE_SFX(NA_SE_EN_STALKID_DAMAGE, 0x38, 1, 0, 0, 0) +/* 0x3833 */ DEFINE_SFX(NA_SE_EN_STALKID_DEAD, 0x40, 1, 0, 0, 0) +/* 0x3834 */ DEFINE_SFX(NA_SE_EN_FLOORMASTER_SLIDING, 0x14, 0, 0, 0, 0) +/* 0x3835 */ DEFINE_SFX(NA_SE_EN_TEKU_WALK_WATER, 0x18, 0, 2, 0, 0) +/* 0x3836 */ DEFINE_SFX(NA_SE_EN_LIGHT_ARROW_HIT, 0x38, 2, 0, 0, 0) +/* 0x3837 */ DEFINE_SFX(NA_SE_EN_MIZUBABA2_ATTACK, 0x34, 0, 0, 0, 0) +/* 0x3838 */ DEFINE_SFX(NA_SE_EN_STAL_WARAU, 0x28, 1, 0, 0, 0) +/* 0x3839 */ DEFINE_SFX(NA_SE_EN_STAL_SAKEBI, 0x30, 0, 0, 0, 0) +/* 0x383A */ DEFINE_SFX(NA_SE_EN_STAL_DAMAGE, 0x38, 1, 0, 0, 0) +/* 0x383B */ DEFINE_SFX(NA_SE_EN_STAL_DEAD, 0x40, 1, 0, 0, 0) +/* 0x383C */ DEFINE_SFX(NA_SE_EN_WOLFOS_APPEAR, 0x30, 0, 0, 0, 0) +/* 0x383D */ DEFINE_SFX(NA_SE_EN_STAL_WALK, 0x18, 0, 0, 0, 0) +/* 0x383E */ DEFINE_SFX(NA_SE_EN_WOLFOS_CRY, 0x20, 0, 0, 0, 0) +/* 0x383F */ DEFINE_SFX(NA_SE_EN_WOLFOS_ATTACK, 0x30, 0, 0, 0, 0) +/* 0x3840 */ DEFINE_SFX(NA_SE_EN_FFLY_ATTACK, 0x32, 0, 0, 0, 0) +/* 0x3841 */ DEFINE_SFX(NA_SE_EN_FFLY_FLY, 0x20, 1, 0, 0, 0) +/* 0x3842 */ DEFINE_SFX(NA_SE_EN_FFLY_DEAD, 0x37, 1, 0, 0, 0) +/* 0x3843 */ DEFINE_SFX(NA_SE_EN_WOLFOS_DAMAGE, 0x38, 1, 0, 0, 0) +/* 0x3844 */ DEFINE_SFX(NA_SE_EN_AMOS_WALK, 0x30, 0, 0, 0, 0) +/* 0x3845 */ DEFINE_SFX(NA_SE_EN_AMOS_WAVE, 0x30, 0, 0, 0, 0) +/* 0x3846 */ DEFINE_SFX(NA_SE_EN_EYEGOLE_DEAD, 0x40, 2, 0, 0, 0) +/* 0x3847 */ DEFINE_SFX(NA_SE_EN_EYEGOLE_DAMAGE, 0x38, 2, 0, 0, 0) +/* 0x3848 */ DEFINE_SFX(NA_SE_EN_AMOS_VOICE, 0x20, 0, 0, 0, 0) +/* 0x3849 */ DEFINE_SFX(NA_SE_EN_KUSAMUSHI_VIBE, 0x18, 0, 0, 0, 0) +/* 0x384A */ DEFINE_SFX(NA_SE_EN_BEE_FLY, 0x40, 7, 0, 0, SFX_PARAM_RAND_FREQ_LOWER) +/* 0x384B */ DEFINE_SFX(NA_SE_EN_WOLFOS_DEAD, 0x40, 1, 0, 0, 0) +/* 0x384C */ DEFINE_SFX(NA_SE_EN_COMMON_E_BALL, 0x30, 3, 0, 0, 0) +/* 0x384D */ DEFINE_SFX(NA_SE_EN_COMMON_THUNDER_THR, 0x30, 3, 0, 0, 0) +/* 0x384E */ DEFINE_SFX(NA_SE_EN_COMMON_E_BALL_HIT, 0x30, 3, 0, 0, 0) +/* 0x384F */ DEFINE_SFX(NA_SE_EN_COMMON_ELEC_ARK, 0x30, 3, 0, 0, 0) +/* 0x3850 */ DEFINE_SFX(NA_SE_EN_SUISEN_EAT, 0x30, 0, 0, 0, 0) +/* 0x3851 */ DEFINE_SFX(NA_SE_EN_SUISEN_DEAD, 0x40, 0, 0, 0, 0) +/* 0x3852 */ DEFINE_SFX(NA_SE_EN_COMMON_E_BALL_THR, 0x30, 3, 0, 0, 0) +/* 0x3853 */ DEFINE_SFX(NA_SE_EN_UTSUBO_APPEAR, 0x30, 3, 0, 0, 0) +/* 0x3854 */ DEFINE_SFX(NA_SE_EN_BOMCHU_VOICE, 0x34, 0, 0, 0, 0) +/* 0x3855 */ DEFINE_SFX(NA_SE_EN_BOMCHU_AIM, 0x34, 0, 0, 0, 0) +/* 0x3856 */ DEFINE_SFX(NA_SE_EN_BOMCHU_RUN, 0x36, 0, 0, 0, 0) +/* 0x3857 */ DEFINE_SFX(NA_SE_EN_UTSUBO_BACK, 0x30, 3, 0, 0, 0) +/* 0x3858 */ DEFINE_SFX(NA_SE_EN_DODO_J_BREATH, 0x28, 0, 0, 0, 0) +/* 0x3859 */ DEFINE_SFX(NA_SE_EN_DODO_J_TAIL, 0x30, 0, 0, 0, 0) +/* 0x385A */ DEFINE_SFX(NA_SE_EN_WOLFOS_WALK, 0x18, 0, 0, 0, 0) +/* 0x385B */ DEFINE_SFX(NA_SE_EN_DODO_J_EAT, 0x30, 0, 0, 0, 0) +/* 0x385C */ DEFINE_SFX(NA_SE_EN_DEKU_MOUTH, 0x28, 0, 3, 0, 0) +/* 0x385D */ DEFINE_SFX(NA_SE_EN_DEKU_ATTACK, 0x30, 0, 1, 0, 0) +/* 0x385E */ DEFINE_SFX(NA_SE_EN_DEKU_DAMAGE, 0x38, 1, 1, 0, 0) +/* 0x385F */ DEFINE_SFX(NA_SE_EN_DEKU_DEAD, 0x40, 1, 1, 0, 0) +/* 0x3860 */ DEFINE_SFX(NA_SE_EN_MIZUBABA1_MOUTH, 0x30, 0, 0, 0, 0) +/* 0x3861 */ DEFINE_SFX(NA_SE_EN_MIZUBABA1_ATTACK, 0x36, 0, 0, 0, 0) +/* 0x3862 */ DEFINE_SFX(NA_SE_EN_DEKU_JR_DEAD, 0x40, 1, 0, 0, 0) +/* 0x3863 */ DEFINE_SFX(NA_SE_EN_DEKU_SCRAPE, 0x14, 0, 0, 0, 0) +/* 0x3864 */ DEFINE_SFX(NA_SE_EN_TAIL_FLY, 0x30, 0, 0, 0, 0) +/* 0x3865 */ DEFINE_SFX(NA_SE_EN_TAIL_CRY, 0x20, 0, 0, 0, 0) +/* 0x3866 */ DEFINE_SFX(NA_SE_EN_TAIL_DEAD, 0x40, 1, 0, 0, 0) +/* 0x3867 */ DEFINE_SFX(NA_SE_EN_GOLON_STAND_IMT, 0x30, 3, 0, 0, 0) +/* 0x3868 */ DEFINE_SFX(NA_SE_EN_STALTU_DOWN, 0x30, 4, 0, 0, 0) +/* 0x3869 */ DEFINE_SFX(NA_SE_EN_STALTU_UP, 0x30, 4, 0, 0, 0) +/* 0x386A */ DEFINE_SFX(NA_SE_EN_STALTU_LAUGH, 0x20, 4, 0, 0, 0) +/* 0x386B */ DEFINE_SFX(NA_SE_EN_STALTU_DAMAGE, 0x38, 4, 0, 0, 0) +/* 0x386C */ DEFINE_SFX(NA_SE_EN_TEKU_JUMP, 0x20, 3, 0, 0, 0) +/* 0x386D */ DEFINE_SFX(NA_SE_EN_TEKU_DAMAGE, 0x38, 1, 0, 0, 0) +/* 0x386E */ DEFINE_SFX(NA_SE_EN_TEKU_DEAD, 0x40, 1, 0, 0, 0) +/* 0x386F */ DEFINE_SFX(NA_SE_EN_TEKU_WALK, 0x14, 0, 0, 0, 0) +/* 0x3870 */ DEFINE_SFX(NA_SE_EN_PO_KANTERA, 0x30, 3, 0, 0, 0) +/* 0x3871 */ DEFINE_SFX(NA_SE_EN_PO_FLY, 0x20, 1, 0, 0, 0) +/* 0x3872 */ DEFINE_SFX(NA_SE_EN_PO_AWAY, 0x20, 1, 0, 0, 0) +/* 0x3873 */ DEFINE_SFX(NA_SE_EN_STALKIDS_APPEAR, 0x30, 2, 0, 0, 0) +/* 0x3874 */ DEFINE_SFX(NA_SE_EN_PO_DISAPPEAR, 0x35, 2, 0, 0, 0) +/* 0x3875 */ DEFINE_SFX(NA_SE_EN_PO_DAMAGE, 0x38, 2, 0, 0, 0) +/* 0x3876 */ DEFINE_SFX(NA_SE_EN_PO_DEAD, 0x48, 2, 0, 0, 0) +/* 0x3877 */ DEFINE_SFX(NA_SE_EN_WIZ_DISAPPEAR, 0x40, 2, 0, 0, 0) +/* 0x3878 */ DEFINE_SFX(NA_SE_EN_EXTINCT, 0x45, 1, 2, 0, 0) +/* 0x3879 */ DEFINE_SFX(NA_SE_EN_GOLON_LAND_BIG, 0x34, 0, 0, 0, 0) +/* 0x387A */ DEFINE_SFX(NA_SE_EN_GERUDOFT_DOWN, 0x40, 0, 0, 0, 0) +/* 0x387B */ DEFINE_SFX(NA_SE_EN_EYEGOLE_ATTACK, 0x20, 2, 0, 0, 0) +/* 0x387C */ DEFINE_SFX(NA_SE_EN_NUTS_UP, 0x28, 0, 0, 0, 0) +/* 0x387D */ DEFINE_SFX(NA_SE_EN_NUTS_DOWN, 0x28, 0, 0, 0, 0) +/* 0x387E */ DEFINE_SFX(NA_SE_EN_NUTS_THROW, 0x30, 0, 0, 0, 0) +/* 0x387F */ DEFINE_SFX(NA_SE_EN_NUTS_WALK, 0x20, 4, 2, 0, 0) +/* 0x3880 */ DEFINE_SFX(NA_SE_EN_NUTS_DAMAGE, 0x38, 1, 0, 0, 0) +/* 0x3881 */ DEFINE_SFX(NA_SE_EN_NUTS_DEAD, 0x40, 1, 0, 0, 0) +/* 0x3882 */ DEFINE_SFX(NA_SE_EN_NUT_FAINT, 0x20, 0, 0, 0, 0) +/* 0x3883 */ DEFINE_SFX(NA_SE_EN_PO_BIG_GET, 0x30, 3, 0, 0, 0) +/* 0x3884 */ DEFINE_SFX(NA_SE_EN_STALTU_ROLL, 0x30, 4, 0, 0, 0) +/* 0x3885 */ DEFINE_SFX(NA_SE_EN_STALTU_DEAD, 0x40, 4, 0, 0, 0) +/* 0x3886 */ DEFINE_SFX(NA_SE_EN_PO_SISTER_DEAD, 0x40, 3, 0, 0, 0) +/* 0x3887 */ DEFINE_SFX(NA_SE_EN_BARI_SPLIT, 0x40, 1, 0, 0, 0) +/* 0x3888 */ DEFINE_SFX(NA_SE_EN_LAST1_GROW_HEAD, 0x28, 1, 0, 0, 0) +/* 0x3889 */ DEFINE_SFX(NA_SE_EN_NUTS_VOICE, 0x30, 3, 0, 0, 0) +/* 0x388A */ DEFINE_SFX(NA_SE_EN_TEKU_LAND_WATER, 0x20, 0, 0, 0, 0) +/* 0x388B */ DEFINE_SFX(NA_SE_EN_LAST_DAMAGE, 0x38, 1, 0, 0, 0) +/* 0x388C */ DEFINE_SFX(NA_SE_EN_STALWALL_ROLL, 0x30, 4, 0, 0, 0) +/* 0x388D */ DEFINE_SFX(NA_SE_EN_STALWALL_DASH, 0x30, 0, 0, 0, 0) +/* 0x388E */ DEFINE_SFX(NA_SE_EN_TEKU_JUMP_WATER, 0x20, 0, 0, 0, 0) +/* 0x388F */ DEFINE_SFX(NA_SE_EN_TEKU_LAND_WATER2, 0x20, 0, 0, 0, 0) +/* 0x3890 */ DEFINE_SFX(NA_SE_EN_FALL_AIM, 0x38, 0, 0, 0, SFX_FLAG_VOLUME_NO_DIST) +/* 0x3891 */ DEFINE_SFX(NA_SE_EN_FALL_UP, 0x30, 3, 0, 0, 0) +/* 0x3892 */ DEFINE_SFX(NA_SE_EN_FALL_CATCH, 0x30, 0, 0, 0, SFX_FLAG_VOLUME_NO_DIST) +/* 0x3893 */ DEFINE_SFX(NA_SE_EN_FALL_LAND, 0x30, 0, 0, 0, 0) +/* 0x3894 */ DEFINE_SFX(NA_SE_EN_FALL_WALK, 0x14, 0, 0, 0, 0) +/* 0x3895 */ DEFINE_SFX(NA_SE_EN_FALL_DAMAGE, 0x38, 1, 0, 0, 0) +/* 0x3896 */ DEFINE_SFX(NA_SE_EN_DAIOCTA_REVERSE, 0x40, 1, 0, 0, 0) +/* 0x3897 */ DEFINE_SFX(NA_SE_EN_KAICHO_FLUTTER, 0x14, 0, 0, 0, 0) +/* 0x3898 */ DEFINE_SFX(NA_SE_EN_BIRI_FLY, 0x20, 0, 0, 0, 0) +/* 0x3899 */ DEFINE_SFX(NA_SE_EN_BIRI_JUMP, 0x20, 0, 0, 0, 0) +/* 0x389A */ DEFINE_SFX(NA_SE_EN_BIRI_SPARK, 0x30, 0, 0, 0, 0) +/* 0x389B */ DEFINE_SFX(NA_SE_EN_BIRI_DEAD, 0x40, 1, 0, 0, 0) +/* 0x389C */ DEFINE_SFX(NA_SE_EN_COMMON_WATER_DEEP, 0x30, 0, 2, 0, 0) +/* 0x389D */ DEFINE_SFX(NA_SE_EN_BARI_ROLL, 0x30, 0, 0, 0, 0) +/* 0x389E */ DEFINE_SFX(NA_SE_EN_COMMON_FREEZE, 0x37, 1, 0, 0, 0) +/* 0x389F */ DEFINE_SFX(NA_SE_EN_BARI_DEAD, 0x40, 1, 0, 0, 0) +/* 0x38A0 */ DEFINE_SFX(NA_SE_EN_BATTA_FLY, 0x28, 5, 0, 0, 0) +/* 0x38A1 */ DEFINE_SFX(NA_SE_EN_BATTA_ATTACK, 0x36, 5, 0, 0, 0) +/* 0x38A2 */ DEFINE_SFX(NA_SE_EN_BATTA_DAMAGE, 0x38, 5, 0, 0, 0) +/* 0x38A3 */ DEFINE_SFX(NA_SE_EN_BATTA_DEAD, 0x48, 5, 0, 0, 0) +/* 0x38A4 */ DEFINE_SFX(NA_SE_EN_WIZ_UNARI, 0x30, 3, 0, 0, 0) +/* 0x38A5 */ DEFINE_SFX(NA_SE_EN_WIZ_RUN, 0x28, 2, 0, 0, 0) +/* 0x38A6 */ DEFINE_SFX(NA_SE_EN_WIZ_VOICE, 0x30, 3, 0, 0, 0) +/* 0x38A7 */ DEFINE_SFX(NA_SE_EN_WIZ_LAUGH, 0x30, 3, 0, 0, 0) +/* 0x38A8 */ DEFINE_SFX(NA_SE_EN_WIZ_ATTACK, 0x34, 3, 0, 0, 0) +/* 0x38A9 */ DEFINE_SFX(NA_SE_EN_WIZ_DAMAGE, 0x38, 3, 0, 0, 0) +/* 0x38AA */ DEFINE_SFX(NA_SE_EN_WIZ_DEAD, 0x40, 3, 0, 0, 0) +/* 0x38AB */ DEFINE_SFX(NA_SE_EN_WIZ_EXP, 0x30, 3, 0, 0, 0) +/* 0x38AC */ DEFINE_SFX(NA_SE_EN_DAIOCTA_DEAD, 0x30, 0, 0, 0, SFX_FLAG_VOLUME_NO_DIST) +/* 0x38AD */ DEFINE_SFX(NA_SE_EN_DAIOCTA_DEAD2, 0x30, 3, 0, 0, 0) +/* 0x38AE */ DEFINE_SFX(NA_SE_EN_FANTOM_DAMAGE, 0x38, 3, 0, 0, 0) +/* 0x38AF */ DEFINE_SFX(NA_SE_EN_DAIOCTA_DAMAGE, 0x40, 3, 0, 0, 0) +/* 0x38B0 */ DEFINE_SFX(NA_SE_EN_WIZ_LAUGH2, 0x30, 3, 0, 0, 0) +/* 0x38B1 */ DEFINE_SFX(NA_SE_EN_GOLON_SIT_IMT, 0x30, 3, 0, 0, 0) +/* 0x38B2 */ DEFINE_SFX(NA_SE_EN_FANTOM_VOICE, 0x30, 3, 0, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x38B3 */ DEFINE_SFX(NA_SE_EN_KAICHO_DAMAGE, 0x38, 1, 0, 0, 0) +/* 0x38B4 */ DEFINE_SFX(NA_SE_EN_GOLON_COLD, 0x30, 3, 1, 0, 0) +/* 0x38B5 */ DEFINE_SFX(NA_SE_EN_GOLON_JUMP, 0x30, 3, 0, 0, 0) +/* 0x38B6 */ DEFINE_SFX(NA_SE_EN_KAICHO_CRY, 0x20, 0, 0, 0, 0) +/* 0x38B7 */ DEFINE_SFX(NA_SE_EN_KAICHO_ATTACK, 0x34, 0, 0, 0, 0) +/* 0x38B8 */ DEFINE_SFX(NA_SE_EN_GOLON_WALK, 0x18, 0, 2, 0, 0) +/* 0x38B9 */ DEFINE_SFX(NA_SE_EN_SLIME_JUMP, 0x30, 0, 0, 0, 0) +/* 0x38BA */ DEFINE_SFX(NA_SE_EN_SLIME_DAMAGE, 0x38, 0, 0, 0, 0) +/* 0x38BB */ DEFINE_SFX(NA_SE_EN_SLIME_BREAK, 0x30, 0, 0, 0, 0) +/* 0x38BC */ DEFINE_SFX(NA_SE_EN_KUROSUKE_MOVE, 0x14, 0, 0, 0, 0) +/* 0x38BD */ DEFINE_SFX(NA_SE_EN_KUROSUKE_ATTACK, 0x34, 0, 0, 0, 0) +/* 0x38BE */ DEFINE_SFX(NA_SE_EN_SLIME_DEAD, 0x40, 0, 0, 0, 0) +/* 0x38BF */ DEFINE_SFX(NA_SE_EN_SLIME_DEFENCE, 0x30, 3, 0, 0, 0) +/* 0x38C0 */ DEFINE_SFX(NA_SE_EN_OCTAROCK_ROCK, 0x20, 0, 0, 0, 0) +/* 0x38C1 */ DEFINE_SFX(NA_SE_EN_COMMON_WATER_SLW, 0x30, 0, 2, 0, 0) +/* 0x38C2 */ DEFINE_SFX(NA_SE_EN_OCTAROCK_JUMP, 0x30, 0, 0, 0, 0) +/* 0x38C3 */ DEFINE_SFX(NA_SE_EN_DAIOCTA_LAND, 0x30, 0, 0, 0, 0) +/* 0x38C4 */ DEFINE_SFX(NA_SE_EN_DAIOCTA_SINK, 0x28, 0, 0, 0, 0) +/* 0x38C5 */ DEFINE_SFX(NA_SE_EN_COMMON_WATER_MID, 0x30, 0, 2, 0, 0) +/* 0x38C6 */ DEFINE_SFX(NA_SE_EN_OCTAROCK_DEAD1, 0x40, 1, 0, 0, 0) +/* 0x38C7 */ DEFINE_SFX(NA_SE_EN_OCTAROCK_DEAD2, 0x40, 1, 0, 0, 0) +/* 0x38C8 */ DEFINE_SFX(NA_SE_EN_BUBLE_WING, 0x20, 0, 0, 0, 0) +/* 0x38C9 */ DEFINE_SFX(NA_SE_EN_BUBLE_MOUTH, 0x20, 0, 0, 0, 0) +/* 0x38CA */ DEFINE_SFX(NA_SE_EN_BUBLE_LAUGH, 0x14, 0, 0, 0, 0) +/* 0x38CB */ DEFINE_SFX(NA_SE_EN_BUBLE_BITE, 0x30, 0, 0, 0, 0) +/* 0x38CC */ DEFINE_SFX(NA_SE_EN_BUBLE_UP, 0x30, 0, 0, 0, 0) +/* 0x38CD */ DEFINE_SFX(NA_SE_EN_BUBLE_DOWN, 0x30, 0, 0, 0, 0) +/* 0x38CE */ DEFINE_SFX(NA_SE_EN_BUBLE_DEAD, 0x40, 1, 0, 0, 0) +/* 0x38CF */ DEFINE_SFX(NA_SE_EN_BUBLEFALL_FIRE, 0x30, 0, 0, 0, 0) +/* 0x38D0 */ DEFINE_SFX(NA_SE_EN_UTSUBO_DEAD, 0x30, 3, 0, 0, 0) +/* 0x38D1 */ DEFINE_SFX(NA_SE_EN_UTSUBO_DAMAGE, 0x38, 3, 0, 0, 0) +/* 0x38D2 */ DEFINE_SFX(NA_SE_EN_FROG_REAL, 0x40, 3, 0, 0, 0) +/* 0x38D3 */ DEFINE_SFX(NA_SE_EN_FROG_DAMAGE, 0x48, 3, 0, 0, 0) +/* 0x38D4 */ DEFINE_SFX(NA_SE_EN_B_SLIME_EAT, 0x30, 3, 0, 0, 0) +/* 0x38D5 */ DEFINE_SFX(NA_SE_EN_B_SLIME_LAUGH, 0x34, 3, 0, 0, 0) +/* 0x38D6 */ DEFINE_SFX(NA_SE_EN_FROG_DEAD, 0x48, 3, 0, 0, 0) +/* 0x38D7 */ DEFINE_SFX(NA_SE_EN_UTSUBO_BITE, 0x30, 3, 0, 0, 0) +/* 0x38D8 */ DEFINE_SFX(NA_SE_EN_B_SLIME_REVERSE, 0x34, 3, 0, 0, 0) +/* 0x38D9 */ DEFINE_SFX(NA_SE_EN_SLIME_JUMP1, 0x30, 3, 2, 0, SFX_PARAM_RAND_FREQ_LOWER) +/* 0x38DA */ DEFINE_SFX(NA_SE_EN_SLIME_JUMP2, 0x30, 3, 2, 0, SFX_PARAM_RAND_FREQ_LOWER) +/* 0x38DB */ DEFINE_SFX(NA_SE_EN_B_SLIME_BREAK, 0x40, 3, 0, 0, 0) +/* 0x38DC */ DEFINE_SFX(NA_SE_EN_BARI_DAMAGE, 0x38, 1, 0, 0, 0) +/* 0x38DD */ DEFINE_SFX(NA_SE_EN_HIPLOOP_LAND, 0x30, 1, 0, 0, 0) +/* 0x38DE */ DEFINE_SFX(NA_SE_EN_MOFER_CORE_MOVE_WT, 0x28, 3, 0, 0, 0) +/* 0x38DF */ DEFINE_SFX(NA_SE_EN_MOFER_CORE_SMJUMP, 0x28, 3, 0, 0, 0) +/* 0x38E0 */ DEFINE_SFX(NA_SE_EN_MONBLIN_GNDWAVE, 0x30, 3, 0, 0, 0) +/* 0x38E1 */ DEFINE_SFX(NA_SE_EN_MONBLIN_HAM_DOWN, 0x30, 3, 0, 0, 0) +/* 0x38E2 */ DEFINE_SFX(NA_SE_EN_MONBLIN_HAM_UP, 0x30, 3, 0, 0, SFX_FLAG_VOLUME_NO_DIST) +/* 0x38E3 */ DEFINE_SFX(NA_SE_EN_BUBLE_DAMAGE, 0x38, 1, 0, 0, 0) +/* 0x38E4 */ DEFINE_SFX(NA_SE_EN_REDEAD_CRY, 0x20, 0, 0, 0, 0) +/* 0x38E5 */ DEFINE_SFX(NA_SE_EN_REDEAD_AIM, 0x34, 0, 0, 0, 0) +/* 0x38E6 */ DEFINE_SFX(NA_SE_EN_REDEAD_DAMAGE, 0x38, 1, 0, 0, 0) +/* 0x38E7 */ DEFINE_SFX(NA_SE_EN_REDEAD_DEAD, 0x40, 1, 0, 0, 0) +/* 0x38E8 */ DEFINE_SFX(NA_SE_EN_REDEAD_ATTACK, 0x34, 0, 0, 0, SFX_FLAG_VOLUME_NO_DIST) +/* 0x38E9 */ DEFINE_SFX(NA_SE_EN_GOLON_KID_SOB, 0x20, 0, 0, 0, 0) +/* 0x38EA */ DEFINE_SFX(NA_SE_EN_GOLON_KID_CRY, 0x38, 2, 1, 0, 0) +/* 0x38EB */ DEFINE_SFX(NA_SE_EN_KAICHO_DEAD, 0x40, 1, 0, 0, 0) +/* 0x38EC */ DEFINE_SFX(NA_SE_EN_PO_LAUGH, 0x30, 3, 0, 0, 0) +/* 0x38ED */ DEFINE_SFX(NA_SE_EN_PO_CRY, 0x30, 2, 0, 0, 0) +/* 0x38EE */ DEFINE_SFX(NA_SE_EN_PO_ROLL, 0x30, 2, 0, 0, 0) +/* 0x38EF */ DEFINE_SFX(NA_SE_EN_PO_LAUGH2, 0x38, 3, 0, 0, 0) +/* 0x38F0 */ DEFINE_SFX(NA_SE_EN_GOLON_ROLLING, 0x30, 0, 0, 0, 0) +/* 0x38F1 */ DEFINE_SFX(NA_SE_EN_GOLON_READY, 0x30, 0, 0, 0, 0) +/* 0x38F2 */ DEFINE_SFX(NA_SE_EN_GOLON_DASH, 0x34, 0, 0, 0, 0) +/* 0x38F3 */ DEFINE_SFX(NA_SE_EN_PAMET_VOICE, 0x34, 3, 0, 0, 0) +/* 0x38F4 */ DEFINE_SFX(NA_SE_EN_PAMET_ROLL, 0x30, 3, 0, 0, 0) +/* 0x38F5 */ DEFINE_SFX(NA_SE_EN_PAMET_WALK, 0x24, 0, 1, 0, 0) +/* 0x38F6 */ DEFINE_SFX(NA_SE_EN_PAMET_ROAR, 0x30, 3, 0, 0, 0) +/* 0x38F7 */ DEFINE_SFX(NA_SE_EN_PAMET_WAKEUP, 0x28, 2, 2, 0, 0) +/* 0x38F8 */ DEFINE_SFX(NA_SE_EN_PAMET_REVERSE, 0x40, 3, 0, 0, 0) +/* 0x38F9 */ DEFINE_SFX(NA_SE_EN_PAMET_DAMAGE, 0x40, 3, 0, 0, 0) +/* 0x38FA */ DEFINE_SFX(NA_SE_EN_PAMET_DEAD, 0x30, 3, 0, 0, 0) +/* 0x38FB */ DEFINE_SFX(NA_SE_EN_BAKUO_VOICE, 0x34, 3, 0, 0, 0) +/* 0x38FC */ DEFINE_SFX(NA_SE_EN_GOLON_WAKE_UP, 0x20, 3, 2, 0, 0) +/* 0x38FD */ DEFINE_SFX(NA_SE_EN_GOLON_SIT_DOWN, 0x20, 0, 0, 0, 0) +/* 0x38FE */ DEFINE_SFX(NA_SE_EN_DAIGOLON_SLEEP3, 0x30, 3, 0, 0, 0) +/* 0x38FF */ DEFINE_SFX(NA_SE_EN_CHICKEN_FLUTTER, 0x20, 0, 2, 0, 0) +/* 0x3900 */ DEFINE_SFX(NA_SE_EN_KOUME_ILL, 0x30, 3, 2, 0, 0) +/* 0x3901 */ DEFINE_SFX(NA_SE_EN_KOUME_REGAIN, 0x18, 3, 2, 0, 0) +/* 0x3902 */ DEFINE_SFX(NA_SE_EN_KOUME_DRINK, 0x34, 3, 2, 0, 0) +/* 0x3903 */ DEFINE_SFX(NA_SE_EN_KOUME_LAUGH, 0x30, 3, 2, 0, 0) +/* 0x3904 */ DEFINE_SFX(NA_SE_EN_KOUME_FLY, 0x38, 3, 0, 0, 0) +/* 0x3905 */ DEFINE_SFX(NA_SE_EN_KOUME_AWAY, 0x18, 3, 0, 0, 0) +/* 0x3906 */ DEFINE_SFX(NA_SE_EN_KOUME_MAGIC, 0x30, 0, 0, 0, SFX_FLAG_VOLUME_NO_DIST) +/* 0x3907 */ DEFINE_SFX(NA_SE_EN_DAIGOLON_SLEEP2, 0x38, 3, 0, 0, 0) +/* 0x3908 */ DEFINE_SFX(NA_SE_EN_STALKIDS_JUMP, 0x30, 3, 0, 0, 0) +/* 0x3909 */ DEFINE_SFX(NA_SE_EN_STALKIDS_FADEOUT, 0x40, 3, 0, 0, 0) +/* 0x390A */ DEFINE_SFX(NA_SE_EN_STALKIDS_LAUGH, 0x40, 4, 0, 0, SFX_FLAG_VOLUME_NO_DIST) +/* 0x390B */ DEFINE_SFX(NA_SE_EN_STALKIDS_SHAKEHEAD, 0x38, 5, 0, 0, 0) +/* 0x390C */ DEFINE_SFX(NA_SE_EN_STALKIDS_ONGND, 0x30, 0, 0, 0, SFX_FLAG_VOLUME_NO_DIST) +/* 0x390D */ DEFINE_SFX(NA_SE_EN_STALKIDS_SURPRISED, 0x30, 3, 0, 0, 0) +/* 0x390E */ DEFINE_SFX(NA_SE_EN_STALKIDS_WALK, 0x30, 0, 2, 0, 0) +/* 0x390F */ DEFINE_SFX(NA_SE_EN_STALKIDS_REVERSE, 0x30, 5, 0, 0, 0) +/* 0x3910 */ DEFINE_SFX(NA_SE_EN_STALKIDS_FLOAT, 0x30, 3, 0, 0, 0) +/* 0x3911 */ DEFINE_SFX(NA_SE_EN_EYEGOLE_EYE, 0x30, 2, 2, 0, 0) +/* 0x3912 */ DEFINE_SFX(NA_SE_EN_STALKIDS_CAUGHT, 0x30, 3, 0, 0, 0) +/* 0x3913 */ DEFINE_SFX(NA_SE_EN_STALKIDS_MASK_ON, 0x30, 5, 0, 0, 0) +/* 0x3914 */ DEFINE_SFX(NA_SE_EN_TWINROBA_CUTBODY, 0x30, 3, 0, 0, 0) +/* 0x3915 */ DEFINE_SFX(NA_SE_EN_STALKIDS_MASK_OFF, 0x30, 4, 2, 0, 0) +/* 0x3916 */ DEFINE_SFX(NA_SE_EN_STALKIDS_RIDE, 0x38, 0, 2, 0, 0) +/* 0x3917 */ DEFINE_SFX(NA_SE_EN_DEKNUTS_DANCE, 0x38, 3, 2, 0, SFX_PARAM_RAND_FREQ_LOWER | SFX_FLAG_VOLUME_NO_DIST) +/* 0x3918 */ DEFINE_SFX(NA_SE_EN_DEKNUTS_DANCE1, 0x38, 3, 2, 0, SFX_PARAM_RAND_FREQ_LOWER | SFX_FLAG_VOLUME_NO_DIST) +/* 0x3919 */ DEFINE_SFX(NA_SE_EN_DEKNUTS_DANCE2, 0x38, 3, 2, 0, SFX_PARAM_RAND_FREQ_LOWER | SFX_FLAG_VOLUME_NO_DIST) +/* 0x391A */ DEFINE_SFX(NA_SE_EN_DEKNUTS_DANCE_BIG, 0x38, 3, 2, 0, SFX_PARAM_RAND_FREQ_LOWER | SFX_FLAG_VOLUME_NO_DIST) +/* 0x391B */ DEFINE_SFX(NA_SE_EN_EYEGOLE_BEAM, 0x40, 2, 2, 0, SFX_PARAM_RAND_FREQ_LOWER) +/* 0x391C */ DEFINE_SFX(NA_SE_EN_GOLON_EYE_BIG, 0x18, 3, 2, 0, 0) +/* 0x391D */ DEFINE_SFX(NA_SE_EN_GOLON_GOOD_BIG, 0x30, 3, 0, 0, 0) +/* 0x391E */ DEFINE_SFX(NA_SE_EN_STALKIDS_LAUGH_MID, 0x30, 3, 0, 0, 0) +/* 0x391F */ DEFINE_SFX(NA_SE_EN_STALKIDS_FLOAT_COPY, 0x20, 3, 0, 0, 0) +/* 0x3920 */ DEFINE_SFX(NA_SE_EN_STALKIDS_TURN, 0x24, 5, 0, 0, 0) +/* 0x3921 */ DEFINE_SFX(NA_SE_EN_STALKIDS_DAMAGE, 0x28, 3, 0, 0, 0) +/* 0x3922 */ DEFINE_SFX(NA_SE_EN_STALKIDS_SCREAM, 0x30, 3, 0, 0, 0) +/* 0x3923 */ DEFINE_SFX(NA_SE_EN_STALKIDS_OTEDAMA2, 0x30, 5, 0, 0, 0) +/* 0x3924 */ DEFINE_SFX(NA_SE_EN_STALKIDS_STRETCH, 0x30, 5, 0, 0, 0) +/* 0x3925 */ DEFINE_SFX(NA_SE_EN_STALKIDS_LAUGH_MD2, 0x30, 0, 0, 0, 0) +/* 0x3926 */ DEFINE_SFX(NA_SE_EN_OWL_FLUTTER, 0x30, 0, 0, 0, 0) +/* 0x3927 */ DEFINE_SFX(NA_SE_EN_VALVAISA_LAND, 0x30, 3, 0, 0, 0) +/* 0x3928 */ DEFINE_SFX(NA_SE_EN_IRONNACK_WALK, 0x18, 1, 0, 0, 0) +/* 0x3929 */ DEFINE_SFX(NA_SE_EN_IRONNACK_SWING_AXE, 0x34, 3, 0, 0, 0) +/* 0x392A */ DEFINE_SFX(NA_SE_EN_STALKIDS_OTEDAMA1, 0x30, 5, 0, 0, 0) +/* 0x392B */ DEFINE_SFX(NA_SE_EN_PAMET_CUTTER_ON, 0x34, 3, 0, 0, 0) +/* 0x392C */ DEFINE_SFX(NA_SE_EN_IRONNACK_ARMOR_OFF_DEMO, 0x34, 3, 0, 0, 0) +/* 0x392D */ DEFINE_SFX(NA_SE_EN_PAMET_CUTTER_OFF, 0x34, 3, 0, 0, 0) +/* 0x392E */ DEFINE_SFX(NA_SE_EN_B_SLIME_JUMP1, 0x30, 3, 0, 0, 0) +/* 0x392F */ DEFINE_SFX(NA_SE_EN_B_SLIME_JUMP2, 0x30, 3, 0, 0, 0) +/* 0x3930 */ DEFINE_SFX(NA_SE_EN_FLOORMASTER_ATTACK, 0x30, 1, 0, 0, 0) +/* 0x3931 */ DEFINE_SFX(NA_SE_EN_FLOORMASTER_SM_WALK, 0x14, 0, 0, 0, 0) +/* 0x3932 */ DEFINE_SFX(NA_SE_EN_FLOORMASTER_SM_DEAD, 0x40, 1, 0, 0, 0) +/* 0x3933 */ DEFINE_SFX(NA_SE_EN_FLOORMASTER_RESTORE, 0x30, 1, 0, 0, 0) +/* 0x3934 */ DEFINE_SFX(NA_SE_EN_FLOORMASTER_EXPAND, 0x30, 1, 0, 0, 0) +/* 0x3935 */ DEFINE_SFX(NA_SE_EN_KUSAMUSHI_HIDE, 0x20, 1, 0, 0, 0) +/* 0x3936 */ DEFINE_SFX(NA_SE_EN_FLOORMASTER_SM_STICK, 0x38, 3, 0, 0, 0) +/* 0x3937 */ DEFINE_SFX(NA_SE_EN_FLOORMASTER_SM_LAND, 0x30, 0, 0, 0, 0) +/* 0x3938 */ DEFINE_SFX(NA_SE_EN_B_SLIME_COMBINE, 0x40, 3, 0, 0, SFX_PARAM_RAND_FREQ_LOWER) +/* 0x3939 */ DEFINE_SFX(NA_SE_EN_B_SLIME_PUNCH_MOVE, 0x30, 3, 0, 0, SFX_PARAM_RAND_FREQ_LOWER) +/* 0x393A */ DEFINE_SFX(NA_SE_EN_IRONNACK_ARMOR_HIT, 0x38, 3, 0, 0, 0) +/* 0x393B */ DEFINE_SFX(NA_SE_EN_CUTBODY, 0x38, 3, 0, 0, 0) +/* 0x393C */ DEFINE_SFX(NA_SE_EN_LAST1_TRANSFORM, 0x40, 3, 0, 0, 0) +/* 0x393D */ DEFINE_SFX(NA_SE_EN_LAST1_DEMO_BREAK, 0x40, 3, 2, 0, 0) +/* 0x393E */ DEFINE_SFX(NA_SE_EN_LAST1_DEMO_WALL, 0x40, 3, 2, 0, 0) +/* 0x393F */ DEFINE_SFX(NA_SE_EN_B_PAMET_BREAK, 0x40, 3, 0, 0, 0) +/* 0x3940 */ DEFINE_SFX(NA_SE_EN_KONB_DEMO_MOVE_OLD, 0x21, 3, 0, 0, SFX_PARAM_RAND_FREQ_LOWER) +/* 0x3941 */ DEFINE_SFX(NA_SE_EN_KONB_JUMP_OLD, 0x54, 3, 0, 0, 0) +/* 0x3942 */ DEFINE_SFX(NA_SE_EN_KONB_SINK_OLD, 0x54, 3, 0, 0, 0) +/* 0x3943 */ DEFINE_SFX(NA_SE_EN_UTSUBO_EAT, 0x54, 3, 0, 0, 0) +/* 0x3944 */ DEFINE_SFX(NA_SE_EN_YMAJIN_HOLD_SNOW, 0x34, 2, 0, 0, 0) +/* 0x3945 */ DEFINE_SFX(NA_SE_EN_KONB_DAMAGE_OLD, 0x58, 3, 0, 0, 0) +/* 0x3946 */ DEFINE_SFX(NA_SE_EN_KONB_DEAD_OLD, 0x68, 3, 0, 0, 0) +/* 0x3947 */ DEFINE_SFX(NA_SE_EN_KONB_BOUND_OLD, 0x50, 3, 3, 0, SFX_PARAM_RAND_FREQ_LOWER) +/* 0x3948 */ DEFINE_SFX(NA_SE_EN_AWA_BOUND, 0x14, 0, 0, 0, 0) +/* 0x3949 */ DEFINE_SFX(NA_SE_EN_AWA_BREAK, 0x20, 1, 0, 0, 0) +/* 0x394A */ DEFINE_SFX(NA_SE_EN_ICEB_FOOTSTEP_OLD, 0x48, 0, 2, 0, SFX_PARAM_RAND_FREQ_LOWER) +/* 0x394B */ DEFINE_SFX(NA_SE_EN_COMMON_THUNDER, 0x30, 0, 2, 0, SFX_PARAM_RAND_FREQ_LOWER) +/* 0x394C */ DEFINE_SFX(NA_SE_EN_ICEB_CRY_OLD, 0x50, 1, 0, 0, 0) +/* 0x394D */ DEFINE_SFX(NA_SE_EN_ICEB_STEAM_LONG_OLD, 0x50, 1, 0, 0, 0) +/* 0x394E */ DEFINE_SFX(NA_SE_EN_ICEB_STEAMS_DEMO_OLD, 0x50, 0, 0, 0, 0) +/* 0x394F */ DEFINE_SFX(NA_SE_EN_ICEB_STEAM_DEMO_UP_OLD, 0x50, 0, 0, 0, 0) +/* 0x3950 */ DEFINE_SFX(NA_SE_EN_ICEB_DEAD_OLD, 0x68, 3, 0, 0, 0) +/* 0x3951 */ DEFINE_SFX(NA_SE_EN_ICEB_DAMAGE_OLD, 0x58, 3, 0, 0, 0) +/* 0x3952 */ DEFINE_SFX(NA_SE_EN_KONB_INIT_OLD, 0x90, 3, 0, 0, 0) +/* 0x3953 */ DEFINE_SFX(NA_SE_EN_KONB_DEAD2_OLD, 0x48, 3, 0, 0, 0) +/* 0x3954 */ DEFINE_SFX(NA_SE_EN_PIHAT_UP, 0x28, 2, 0, 0, 0) +/* 0x3955 */ DEFINE_SFX(NA_SE_EN_PIHAT_FLY, 0x30, 0, 0, 0, 0) +/* 0x3956 */ DEFINE_SFX(NA_SE_EN_PIHAT_DAMAGE, 0x38, 1, 0, 0, 0) +/* 0x3957 */ DEFINE_SFX(NA_SE_EN_PIHAT_LAND, 0x28, 2, 0, 0, 0) +/* 0x3958 */ DEFINE_SFX(NA_SE_EN_KONB_BOUND2_OLD, 0x50, 3, 0, 0, 0) +/* 0x3959 */ DEFINE_SFX(NA_SE_EN_KONB_DEAD_JUMP_OLD, 0x50, 3, 0, 0, 0) +/* 0x395A */ DEFINE_SFX(NA_SE_EN_KONB_DEAD_JUMP2_OLD, 0x50, 3, 0, 0, 0) +/* 0x395B */ DEFINE_SFX(NA_SE_EN_FROG_JUMP, 0x40, 3, 2, 0, SFX_PARAM_RAND_FREQ_LOWER) +/* 0x395C */ DEFINE_SFX(NA_SE_EN_FROG_GREET, 0x40, 3, 0, 0, 0) +/* 0x395D */ DEFINE_SFX(NA_SE_EN_FROG_HOLD_SLIME, 0x40, 3, 0, 0, 0) +/* 0x395E */ DEFINE_SFX(NA_SE_EN_FROG_THROW_SLIME, 0x40, 3, 0, 0, 0) +/* 0x395F */ DEFINE_SFX(NA_SE_EN_FROG_JUMP_MID, 0x40, 3, 0, 0, 0) +/* 0x3960 */ DEFINE_SFX(NA_SE_EN_KONB_BITE_OLD, 0x54, 3, 0, 0, 0) +/* 0x3961 */ DEFINE_SFX(NA_SE_EN_FROG_PUNCH1, 0x40, 3, 0, 0, 0) +/* 0x3962 */ DEFINE_SFX(NA_SE_EN_FROG_PUNCH2, 0x40, 3, 0, 0, 0) +/* 0x3963 */ DEFINE_SFX(NA_SE_EN_UTSUBO_APPEAR_TRG, 0x48, 3, 0, 0, 0) +/* 0x3964 */ DEFINE_SFX(NA_SE_EN_FROG_DOWN, 0x48, 3, 0, 0, 0) +/* 0x3965 */ DEFINE_SFX(NA_SE_EN_FROG_JUMP_ABOVE, 0x48, 3, 0, 0, 0) +/* 0x3966 */ DEFINE_SFX(NA_SE_EN_FROG_KICK, 0x40, 3, 0, 0, 0) +/* 0x3967 */ DEFINE_SFX(NA_SE_EN_YMAJIN_MINI_HOLD, 0x34, 2, 0, 0, 0) +/* 0x3968 */ DEFINE_SFX(NA_SE_EN_YMAJIN_MINI_THROW, 0x34, 2, 0, 0, SFX_FLAG_VOLUME_NO_DIST) +/* 0x3969 */ DEFINE_SFX(NA_SE_EN_YMAJIN_MOVE, 0x28, 2, 0, 0, 0) +/* 0x396A */ DEFINE_SFX(NA_SE_EN_YMAJIN_MINI_MOVE, 0x28, 2, 0, 0, 0) +/* 0x396B */ DEFINE_SFX(NA_SE_EN_YMAJIN_SURFACE, 0x30, 2, 0, 0, 0) +/* 0x396C */ DEFINE_SFX(NA_SE_EN_YMAJIN_HIDE, 0x30, 2, 0, 0, 0) +/* 0x396D */ DEFINE_SFX(NA_SE_EN_YMAJIN_SPLIT, 0x38, 2, 0, 0, 0) +/* 0x396E */ DEFINE_SFX(NA_SE_EN_YMAJIN_UNITE, 0x38, 2, 0, 0, 0) +/* 0x396F */ DEFINE_SFX(NA_SE_EN_YMAJIN_DEAD_BREAK, 0x48, 2, 0, 0, 0) +/* 0x3970 */ DEFINE_SFX(NA_SE_EN_BIMOS_ROLL_HEAD, 0x10, 0, 0, 0, 0) +/* 0x3971 */ DEFINE_SFX(NA_SE_EN_BIMOS_LAZER, 0x34, 0, 0, 0, 0) +/* 0x3972 */ DEFINE_SFX(NA_SE_EN_BIMOS_LAZER_GND, 0x18, 0, 0, 0, 0) +/* 0x3973 */ DEFINE_SFX(NA_SE_EN_BIMOS_AIM, 0x30, 0, 0, 0, 0) +/* 0x3974 */ DEFINE_SFX(NA_SE_EN_BUBLEWALK_WALK, 0x14, 0, 0, 0, 0) +/* 0x3975 */ DEFINE_SFX(NA_SE_EN_BUBLEWALK_AIM, 0x34, 0, 0, 0, 0) +/* 0x3976 */ DEFINE_SFX(NA_SE_EN_BUBLEWALK_REVERSE, 0x28, 1, 0, 0, 0) +/* 0x3977 */ DEFINE_SFX(NA_SE_EN_BUBLEWALK_DAMAGE, 0x38, 1, 0, 0, 0) +/* 0x3978 */ DEFINE_SFX(NA_SE_EN_BUBLEWALK_DEAD, 0x40, 1, 0, 0, 0) +/* 0x3979 */ DEFINE_SFX(NA_SE_EN_HIPLOOP_RUN, 0x30, 1, 0, 0, 0) +/* 0x397A */ DEFINE_SFX(NA_SE_EN_HIPLOOP_PAUSE, 0x38, 1, 0, 0, 0) +/* 0x397B */ DEFINE_SFX(NA_SE_EN_HIPLOOP_MASC_OFF, 0x36, 1, 0, 0, 0) +/* 0x397C */ DEFINE_SFX(NA_SE_EN_HIPLOOP_FOOT, 0x34, 1, 0, 0, 0) +/* 0x397D */ DEFINE_SFX(NA_SE_EN_HIPLOOP_DAMAGE, 0x38, 1, 0, 0, 0) +/* 0x397E */ DEFINE_SFX(NA_SE_EN_HIPLOOP_DEAD, 0x48, 1, 0, 0, 0) +/* 0x397F */ DEFINE_SFX(NA_SE_EN_HIPLOOP_FOOTSTEP, 0x30, 1, 0, 0, 0) +/* 0x3980 */ DEFINE_SFX(NA_SE_EN_DEKUHIME_WALK, 0x38, 3, 2, 0, 0) +/* 0x3981 */ DEFINE_SFX(NA_SE_EN_DEKUHIME_TURN, 0x30, 3, 0, 0, 0) +/* 0x3982 */ DEFINE_SFX(NA_SE_EN_DEKUHIME_GREET, 0x20, 0, 0, 0, SFX_FLAG_VOLUME_NO_DIST) +/* 0x3983 */ DEFINE_SFX(NA_SE_EN_DEKUHIME_GREET2, 0x30, 3, 0, 0, 0) +/* 0x3984 */ DEFINE_SFX(NA_SE_EN_PIHAT_SM_FLY, 0x30, 0, 0, 0, 0) +/* 0x3985 */ DEFINE_SFX(NA_SE_EN_PIHAT_SM_DEAD, 0x40, 1, 0, 0, 0) +/* 0x3986 */ DEFINE_SFX(NA_SE_EN_STALKID_APPEAR, 0x30, 0, 0, 0, 0) +/* 0x3987 */ DEFINE_SFX(NA_SE_EN_AKINDONUTS_HIDE, 0x20, 0, 0, 0, 0) +/* 0x3988 */ DEFINE_SFX(NA_SE_EN_RIVA_DAMAGE, 0x38, 1, 0, 0, 0) +/* 0x3989 */ DEFINE_SFX(NA_SE_EN_RIVA_DEAD, 0x40, 1, 0, 0, 0) +/* 0x398A */ DEFINE_SFX(NA_SE_EN_RIVA_MOVE, 0x30, 0, 0, 0, 0) +/* 0x398B */ DEFINE_SFX(NA_SE_EN_DEKUHIME_VOICE_SAD, 0x30, 0, 0, 0, SFX_FLAG_VOLUME_NO_DIST) +/* 0x398C */ DEFINE_SFX(NA_SE_EN_DEKUHIME_VOICE_JOY, 0x30, 3, 0, 0, 0) +/* 0x398D */ DEFINE_SFX(NA_SE_EN_NUTS_JUMP, 0x30, 2, 0, 0, 0) +/* 0x398E */ DEFINE_SFX(NA_SE_EN_NUTS_CLOTHES, 0x30, 3, 0, 0, 0) +/* 0x398F */ DEFINE_SFX(NA_SE_EN_SITSUJI_VOICE, 0x30, 3, 0, 0, 0) +/* 0x3990 */ DEFINE_SFX(NA_SE_EN_LIKE_WALK, 0x18, 0, 0, 0, 0) +/* 0x3991 */ DEFINE_SFX(NA_SE_EN_LIKE_UNARI, 0x28, 0, 0, 0, 0) +/* 0x3992 */ DEFINE_SFX(NA_SE_EN_SUISEN_DRINK, 0x34, 2, 0, 0, 0) +/* 0x3993 */ DEFINE_SFX(NA_SE_EN_EYEGOLE_DEMO_EYE, 0x34, 2, 0, 0, 0) +/* 0x3994 */ DEFINE_SFX(NA_SE_EN_SUISEN_THROW, 0x34, 0, 0, 0, 0) +/* 0x3995 */ DEFINE_SFX(NA_SE_EN_LIKE_DAMAGE, 0x38, 1, 0, 0, 0) +/* 0x3996 */ DEFINE_SFX(NA_SE_EN_LIKE_DEAD, 0x40, 1, 0, 0, 0) +/* 0x3997 */ DEFINE_SFX(NA_SE_EN_MGANON_SWORD, 0x30, 3, 0, 0, 0) +/* 0x3998 */ DEFINE_SFX(NA_SE_EN_PIRATE_ATTACK, 0x30, 2, 0, 0, 0) +/* 0x3999 */ DEFINE_SFX(NA_SE_EN_PIRATE_DAMAGE, 0x38, 0, 0, 0, 0) +/* 0x399A */ DEFINE_SFX(NA_SE_EN_PIRATE_DEAD, 0x48, 0, 0, 0, 0) +/* 0x399B */ DEFINE_SFX(NA_SE_EN_MB_MOTH_FLY, 0x28, 4, 0, 0, SFX_PARAM_RAND_FREQ_LOWER) +/* 0x399C */ DEFINE_SFX(NA_SE_EN_MB_MOTH_DEAD, 0x48, 4, 0, 0, 0) +/* 0x399D */ DEFINE_SFX(NA_SE_EN_MB_INSECT_WALK, 0x20, 4, 0, 0, 0) +/* 0x399E */ DEFINE_SFX(NA_SE_EN_B_PAMET_ROLL, 0x25, 3, 0, 0, 0) +/* 0x399F */ DEFINE_SFX(NA_SE_EN_FROG_VOICE1, 0x40, 2, 0, 0, 0) +/* 0x39A0 */ DEFINE_SFX(NA_SE_EN_GERUDOFT_WALK, 0x18, 0, 2, 0, 0) +/* 0x39A1 */ DEFINE_SFX(NA_SE_EN_FROG_VOICE2, 0x44, 3, 0, 0, 0) +/* 0x39A2 */ DEFINE_SFX(NA_SE_EN_B_PAMET_VOICE, 0x44, 0, 0, 0, 0) +/* 0x39A3 */ DEFINE_SFX(NA_SE_EN_B_PAMET_REVERSE, 0x18, 0, 0, 0, 0) +/* 0x39A4 */ DEFINE_SFX(NA_SE_EN_FREEZAD_BREATH, 0x30, 0, 0, 0, 0) +/* 0x39A5 */ DEFINE_SFX(NA_SE_EN_FREEZAD_DAMAGE, 0x38, 1, 0, 0, 0) +/* 0x39A6 */ DEFINE_SFX(NA_SE_EN_FREEZAD_DEAD, 0x40, 1, 0, 0, 0) +/* 0x39A7 */ DEFINE_SFX(NA_SE_EN_DEKUHIMA_VOICE_HURY, 0x18, 3, 0, 0, 0) +/* 0x39A8 */ DEFINE_SFX(NA_SE_EN_KINGNUTS_VOICE, 0x30, 3, 0, 0, 0) +/* 0x39A9 */ DEFINE_SFX(NA_SE_EN_FROG_RUNAWAY, 0x38, 3, 1, 0, 0) +/* 0x39AA */ DEFINE_SFX(NA_SE_EN_LAST3_DEAD_DEAD1_OLD, 0x30, 3, 0, 0, 0) +/* 0x39AB */ DEFINE_SFX(NA_SE_EN_LAST3_DEAD_DEAD2_OLD, 0x30, 3, 0, 0, 0) +/* 0x39AC */ DEFINE_SFX(NA_SE_EN_FROG_RUNAWAY2, 0x30, 3, 0, 0, 0) +/* 0x39AD */ DEFINE_SFX(NA_SE_EN_DAIGOLON_SLEEP1, 0x36, 3, 0, 0, 0) +/* 0x39AE */ DEFINE_SFX(NA_SE_EN_IRONNACK_HIT_GND, 0x34, 3, 0, 0, 0) +/* 0x39AF */ DEFINE_SFX(NA_SE_EN_LAST3_DEAD_WIND1_OLD, 0x34, 2, 2, 0, 0) +/* 0x39B0 */ DEFINE_SFX(NA_SE_EN_TWINROBA_LAUGH, 0x58, 3, 0, 0, 0) +/* 0x39B1 */ DEFINE_SFX(NA_SE_EN_TWINROBA_LAUGH2, 0x68, 3, 0, 0, 0) +/* 0x39B2 */ DEFINE_SFX(NA_SE_EN_IRONNACK_PULLOUT, 0x30, 3, 0, 0, 0) +/* 0x39B3 */ DEFINE_SFX(NA_SE_EN_TWINROBA_SHOOT_VOICE, 0x30, 3, 0, 0, 0) +/* 0x39B4 */ DEFINE_SFX(NA_SE_EN_LAST3_DEAD_WIND2_OLD, 0x34, 2, 0, 0, 0) +/* 0x39B5 */ DEFINE_SFX(NA_SE_EN_LAST3_DEAD_WIND3_OLD, 0x34, 3, 0, 0, 0) +/* 0x39B6 */ DEFINE_SFX(NA_SE_EN_LAST3_DEAD_LIGHTS_OLD, 0x40, 0, 0, 0, 0) +/* 0x39B7 */ DEFINE_SFX(NA_SE_EN_PIRATE_BREATH, 0x30, 3, 0, 0, 0) +/* 0x39B8 */ DEFINE_SFX(NA_SE_EN_LAST3_DEAD_ROD, 0x40, 0, 0, 0, SFX_FLAG_VOLUME_NO_DIST) +/* 0x39B9 */ DEFINE_SFX(NA_SE_EN_LAST2_SHOUT, 0x30, 0, 0, 0, SFX_FLAG_VOLUME_NO_DIST) +/* 0x39BA */ DEFINE_SFX(NA_SE_EN_LAST2_PUMP_UP_OLD, 0x30, 0, 3, 0, 0) +/* 0x39BB */ DEFINE_SFX(NA_SE_EN_LAST2_GROW_HEAD_OLD, 0x30, 0, 3, 0, 0) +/* 0x39BC */ DEFINE_SFX(NA_SE_EN_LAST2_HEARTBEAT_OLD, 0x40, 0, 0, 0, 0) +/* 0x39BD */ DEFINE_SFX(NA_SE_EN_ANSATSUSYA_MOVING, 0x30, 3, 0, 0, 0) +/* 0x39BE */ DEFINE_SFX(NA_SE_EN_ANSATSUSYA_DASH_2, 0x28, 3, 0, 0, 0) +/* 0x39BF */ DEFINE_SFX(NA_SE_EN_LAST3_DEAD_FLOAT, 0x40, 3, 0, 0, 0) +/* 0x39C0 */ DEFINE_SFX(NA_SE_EN_ANSATSUSYA_CRYING, 0x40, 3, 0, 0, 0) +/* 0x39C1 */ DEFINE_SFX(NA_SE_EN_ANSATSUSYA_SKIP, 0x30, 3, 0, 0, 0) +/* 0x39C2 */ DEFINE_SFX(NA_SE_EN_STALTURA_APPEAR, 0x30, 3, 0, 0, 0) +/* 0x39C3 */ DEFINE_SFX(NA_SE_EN_ANSATSUSYA_JUMP, 0x30, 3, 0, 0, 0) +/* 0x39C4 */ DEFINE_SFX(NA_SE_EN_ANSATSUSYA_FALL, 0x30, 3, 0, 0, 0) +/* 0x39C5 */ DEFINE_SFX(NA_SE_EN_ANSATSUSYA_DAMAGE, 0x38, 3, 0, 0, 0) +/* 0x39C6 */ DEFINE_SFX(NA_SE_EN_ANSATSUSYA_DEAD, 0x48, 3, 0, 0, 0) +/* 0x39C7 */ DEFINE_SFX(NA_SE_EN_ANSATSUSYA_SWORD, 0x20, 3, 0, 0, 0) +/* 0x39C8 */ DEFINE_SFX(NA_SE_EN_BAKUO_DEAD, 0x48, 3, 0, 0, 0) +/* 0x39C9 */ DEFINE_SFX(NA_SE_EN_BAKUO_APPEAR, 0x36, 3, 0, 0, 0) +/* 0x39CA */ DEFINE_SFX(NA_SE_EN_LAST3_ROD_WIND_OLD, 0x30, 3, 0, 0, 0) +/* 0x39CB */ DEFINE_SFX(NA_SE_EN_LAST3_ROD_FLOOR_OLD, 0x30, 3, 0, 0, 0) +/* 0x39CC */ DEFINE_SFX(NA_SE_EN_LAST3_ROD_DANCE_OLD, 0x38, 3, 0, 0, 0) +/* 0x39CD */ DEFINE_SFX(NA_SE_EN_LAST3_ROD_HOP_OLD, 0x38, 3, 0, 0, 0) +/* 0x39CE */ DEFINE_SFX(NA_SE_EN_LAST3_ROD_HOP2_OLD, 0x20, 3, 0, 0, 0) +/* 0x39CF */ DEFINE_SFX(NA_SE_EN_GANON_RESTORE, 0x30, 3, 0, 0, 0) +/* 0x39D0 */ DEFINE_SFX(NA_SE_EN_GOLON_CIRCLE, 0x44, 3, 0, 0, 0) +/* 0x39D1 */ DEFINE_SFX(NA_SE_EN_GOLON_CIRCLE_OFF, 0x30, 3, 2, 0, 0) +/* 0x39D2 */ DEFINE_SFX(NA_SE_EN_LAST1_BLOW_OLD, 0x30, 3, 0, 0, 0) +/* 0x39D3 */ DEFINE_SFX(NA_SE_EN_LAST1_BEAM_OLD, 0x30, 3, 0, 0, 0) +/* 0x39D4 */ DEFINE_SFX(NA_SE_EN_LAST1_ATTACK_OLD, 0x34, 3, 0, 0, 0) +/* 0x39D5 */ DEFINE_SFX(NA_SE_EN_LAST1_DAMAGE1_OLD, 0x30, 3, 0, 0, 0) +/* 0x39D6 */ DEFINE_SFX(NA_SE_EN_LAST1_DAMAGE2_OLD, 0x30, 3, 0, 0, 0) +/* 0x39D7 */ DEFINE_SFX(NA_SE_EN_LAST1_FALL_OLD, 0x20, 2, 0, 0, 0) +/* 0x39D8 */ DEFINE_SFX(NA_SE_EN_MGANON_STAND, 0x34, 3, 0, 0, 0) +/* 0x39D9 */ DEFINE_SFX(NA_SE_EN_LAST2_FIRE_OLD, 0x20, 3, 2, 0, 0) +/* 0x39DA */ DEFINE_SFX(NA_SE_EN_STALGOLD_ROLL, 0x30, 4, 0, 0, 0) +/* 0x39DB */ DEFINE_SFX(NA_SE_EN_LAST2_WALK_OLD, 0x30, 2, 1, 0, SFX_PARAM_RAND_FREQ_LOWER) +/* 0x39DC */ DEFINE_SFX(NA_SE_EN_LAST2_WAIT_OLD, 0x40, 2, 1, 0, SFX_PARAM_RAND_FREQ_LOWER) +/* 0x39DD */ DEFINE_SFX(NA_SE_EN_LAST2_JUMP_OLD, 0x40, 3, 2, 0, 0) +/* 0x39DE */ DEFINE_SFX(NA_SE_EN_LAST2_BIRD_OLD, 0x30, 2, 1, 0, SFX_PARAM_RAND_FREQ_LOWER) +/* 0x39DF */ DEFINE_SFX(NA_SE_EN_LAST2_BIRD2_OLD, 0x30, 2, 1, 0, SFX_PARAM_RAND_FREQ_LOWER) +/* 0x39E0 */ DEFINE_SFX(NA_SE_EN_STALTU_WAVE, 0x30, 0, 0, 0, 0) +/* 0x39E1 */ DEFINE_SFX(NA_SE_EN_STALTU_DOWN_SET, 0x30, 0, 0, 0, 0) +/* 0x39E2 */ DEFINE_SFX(NA_SE_EN_DEKU_WAKEUP, 0x30, 1, 0, 0, 0) +/* 0x39E3 */ DEFINE_SFX(NA_SE_EN_LAST2_WALK2_OLD, 0x32, 2, 2, 0, SFX_PARAM_RAND_FREQ_LOWER) +/* 0x39E4 */ DEFINE_SFX(NA_SE_EN_LAST1_FLOAT_OLD, 0x32, 3, 0, 0, 0) +/* 0x39E5 */ DEFINE_SFX(NA_SE_EN_LAST1_ATTACK_2ND_OLD, 0x54, 1, 0, 0, 0) +/* 0x39E6 */ DEFINE_SFX(NA_SE_EN_LAST1_ROLLING_OLD, 0x52, 0, 0, 0, 0) +/* 0x39E7 */ DEFINE_SFX(NA_SE_EN_LAST3_GET_LINK_OLD, 0x54, 3, 0, 0, 0) +/* 0x39E8 */ DEFINE_SFX(NA_SE_EN_PO_BIG_CRY, 0x30, 0, 0, 0, 0) +/* 0x39E9 */ DEFINE_SFX(NA_SE_EN_STALTURA_BOUND, 0x08, 1, 0, 0, 0) +/* 0x39EA */ DEFINE_SFX(NA_SE_EN_STALGOLD_UP_CRY, 0x30, 1, 0, 0, 0) +/* 0x39EB */ DEFINE_SFX(NA_SE_EN_GOLON_CRY, 0x30, 3, 0, 0, 0) +/* 0x39EC */ DEFINE_SFX(NA_SE_EN_LAST3_ROD_SOFT, 0x54, 3, 0, 0, 0) +/* 0x39ED */ DEFINE_SFX(NA_SE_EN_LAST3_ROD_MID_OLD, 0x54, 0, 0, 0, SFX_FLAG_VOLUME_NO_DIST) +/* 0x39EE */ DEFINE_SFX(NA_SE_EN_RIVA_BIG_APPEAR, 0x34, 3, 0, 0, 0) +/* 0x39EF */ DEFINE_SFX(NA_SE_EN_LAST3_ROD_HARD, 0x54, 0, 0, 0, SFX_FLAG_VOLUME_NO_DIST) +/* 0x39F0 */ DEFINE_SFX(NA_SE_EN_MUSI_WALK, 0x08, 0, 0, 0, 0) +/* 0x39F1 */ DEFINE_SFX(NA_SE_EN_LAST3_COIL_ATTACK_OLD, 0x54, 0, 0, 0, 0) +/* 0x39F2 */ DEFINE_SFX(NA_SE_EN_STALWALL_LAUGH, 0x34, 0, 0, 0, 0) +/* 0x39F3 */ DEFINE_SFX(NA_SE_EN_PIRANHA_EXIST, 0x15, 0, 0, 0, 0) +/* 0x39F4 */ DEFINE_SFX(NA_SE_EN_PIRANHA_ATTACK, 0x35, 0, 0, 0, 0) +/* 0x39F5 */ DEFINE_SFX(NA_SE_EN_PIRANHA_DEAD, 0x48, 0, 0, 0, 0) +/* 0x39F6 */ DEFINE_SFX(NA_SE_EN_KINGNUTS_DAMAGE, 0x38, 0, 0, 0, 0) +/* 0x39F7 */ DEFINE_SFX(NA_SE_EN_COMMON_DEADLIGHT, 0x30, 0, 0, 0, 0) +/* 0x39F8 */ DEFINE_SFX(NA_SE_EN_GOLONKID_WALK, 0x30, 2, 3, 0, 0) +/* 0x39F9 */ DEFINE_SFX(NA_SE_EN_YMAJIN_MINI_DAMAGE, 0x38, 2, 0, 0, 0) +/* 0x39FA */ DEFINE_SFX(NA_SE_EN_YMAJIN_DAMAGE, 0x38, 2, 0, 0, 0) +/* 0x39FB */ DEFINE_SFX(NA_SE_EN_KOTAKE_SURPRISED, 0x30, 0, 2, 0, 0) +/* 0x39FC */ DEFINE_SFX(NA_SE_EN_HANDW_GET, 0x30, 0, 0, 0, 0) +/* 0x39FD */ DEFINE_SFX(NA_SE_EN_HANDW_RELEASE, 0x30, 0, 0, 0, 0) +/* 0x39FE */ DEFINE_SFX(NA_SE_EN_SLIME_SURFACE, 0x30, 0, 0, 0, 0) +/* 0x39FF */ DEFINE_SFX(NA_SE_EN_KOTAKE_SLEEP, 0x30, 0, 0, 0, 0) +/* 0x3A00 */ DEFINE_SFX(NA_SE_EN_KOTAKE_SURPRISED2, 0x30, 0, 2, SFX_FLAG2_FORCE_RESET, 0) +/* 0x3A01 */ DEFINE_SFX(NA_SE_EN_NEMURI_SLEEP, 0x30, 6, 0, SFX_FLAG2_APPLY_LOWPASS_FILTER | SFX_FLAG2_SURROUND_NO_HIGHPASS_FILTER | SFX_FLAG2_UNUSED4 | SFX_FLAG2_UNUSED2, 0) +/* 0x3A02 */ DEFINE_SFX(NA_SE_EN_LAST1_DEAD_OLD, 0x30, 0, 0, 0, 0) +/* 0x3A03 */ DEFINE_SFX(NA_SE_EN_GOLON_SIRLOIN_ROLL, 0x30, 6, 0, 0, 0) +/* 0x3A04 */ DEFINE_SFX(NA_SE_EN_GOLON_VOICE_EATFULL, 0x30, 3, 2, 0, 0) +/* 0x3A05 */ DEFINE_SFX(NA_SE_EN_GOLON_SIRLOIN_EAT, 0x30, 0, 0, 0, 0) +/* 0x3A06 */ DEFINE_SFX(NA_SE_EN_EYEGOLE_WALK, 0x30, 2, 0, 0, 0) +/* 0x3A07 */ DEFINE_SFX(NA_SE_EN_EYEGOLE_STAND, 0x30, 2, 0, 0, 0) +/* 0x3A08 */ DEFINE_SFX(NA_SE_EN_EYEGOLE_SIT, 0x30, 2, 0, 0, 0) +/* 0x3A09 */ DEFINE_SFX(NA_SE_EN_INVADER_DEAD, 0x48, 2, 0, 0, 0) +/* 0x3A0A */ DEFINE_SFX(NA_SE_EN_FOLLOWERS_BEAM_PRE, 0x28, 1, 0, 0, 0) +/* 0x3A0B */ DEFINE_SFX(NA_SE_EN_FOLLOWERS_BEAM, 0x36, 0, 0, 0, 0) +/* 0x3A0C */ DEFINE_SFX(NA_SE_EN_FOLLOWERS_DAMAGE, 0x38, 0, 0, 0, 0) +/* 0x3A0D */ DEFINE_SFX(NA_SE_EN_FOLLOWERS_DEAD, 0x48, 0, 0, 0, 0) +/* 0x3A0E */ DEFINE_SFX(NA_SE_EN_INBOSS_DEAD_PRE2_OLD, 0x68, 3, 0, 0, 0) +/* 0x3A0F */ DEFINE_SFX(NA_SE_EN_IKURA_JUMP1, 0x30, 3, 0, 0, 0) +/* 0x3A10 */ DEFINE_SFX(NA_SE_EN_IKURA_JUMP2, 0x30, 3, 0, 0, 0) +/* 0x3A11 */ DEFINE_SFX(NA_SE_EN_IKURA_DAMAGE, 0x38, 3, 0, 0, 0) +/* 0x3A12 */ DEFINE_SFX(NA_SE_EN_IKURA_DEAD, 0x48, 3, 0, 0, 0) +/* 0x3A13 */ DEFINE_SFX(NA_SE_EN_ME_DAMAGE, 0x58, 3, 0, 0, 0) +/* 0x3A14 */ DEFINE_SFX(NA_SE_EN_ME_DEAD, 0x68, 3, 0, 0, 0) +/* 0x3A15 */ DEFINE_SFX(NA_SE_EN_ME_EXIST, 0x29, 3, 0, 0, 0) +/* 0x3A16 */ DEFINE_SFX(NA_SE_EN_ME_ATTACK, 0x54, 3, 0, 0, 0) +/* 0x3A17 */ DEFINE_SFX(NA_SE_EN_GOLONKID_SOB_TALK, 0x30, 0, 0, 0, 0) +/* 0x3A18 */ DEFINE_SFX(NA_SE_EN_GOLONKID_YAWN, 0x30, 0, 0, 0, 0) +/* 0x3A19 */ DEFINE_SFX(NA_SE_EN_GOLONKID_SNORE, 0x30, 0, 1, 0, 0) +/* 0x3A1A */ DEFINE_SFX(NA_SE_EN_GOLON_SNORE1, 0x30, 0, 1, 0, 0) +/* 0x3A1B */ DEFINE_SFX(NA_SE_EN_GOLON_SNORE2, 0x30, 0, 1, 0, 0) +/* 0x3A1C */ DEFINE_SFX(NA_SE_EN_BUBLEFALL_APPEAR, 0x30, 0, 0, 0, 0) +/* 0x3A1D */ DEFINE_SFX(NA_SE_EN_INBOSS_DEAD_OLD, 0x68, 3, 0, 0, 0) +/* 0x3A1E */ DEFINE_SFX(NA_SE_EN_LAST1_BEAM2_OLD, 0x30, 0, 0, 0, 0) +/* 0x3A1F */ DEFINE_SFX(NA_SE_EN_COMMON_EXTINCT_LEV, 0x45, 2, 0, 0, 0) +/* 0x3A20 */ DEFINE_SFX(NA_SE_EN_BOSU_HEAD_MID, 0x40, 3, 1, 0, SFX_PARAM_RAND_FREQ_LOWER) +/* 0x3A21 */ DEFINE_SFX(NA_SE_EN_BOSU_HEAD_SHORT, 0x40, 3, 1, 0, SFX_PARAM_RAND_FREQ_LOWER) +/* 0x3A22 */ DEFINE_SFX(NA_SE_EN_DEBU_HEAD_MID, 0x30, 3, 1, 0, SFX_PARAM_RAND_FREQ_LOWER) +/* 0x3A23 */ DEFINE_SFX(NA_SE_EN_DEBU_HEAD_SHORT, 0x30, 3, 1, 0, SFX_PARAM_RAND_FREQ_LOWER) +/* 0x3A24 */ DEFINE_SFX(NA_SE_EN_YASE_HEAD_MID, 0x30, 3, 1, 0, SFX_PARAM_RAND_FREQ_LOWER) +/* 0x3A25 */ DEFINE_SFX(NA_SE_EN_YASE_HEAD_SHORT, 0x30, 3, 1, 0, SFX_PARAM_RAND_FREQ_LOWER) +/* 0x3A26 */ DEFINE_SFX(NA_SE_EN_BOSU_WALK, 0x30, 3, 2, 0, SFX_PARAM_RAND_FREQ_LOWER) +/* 0x3A27 */ DEFINE_SFX(NA_SE_EN_DEBU_WALK, 0x30, 3, 2, 0, SFX_PARAM_RAND_FREQ_LOWER) +/* 0x3A28 */ DEFINE_SFX(NA_SE_EN_YASE_WALK, 0x30, 3, 2, 0, SFX_PARAM_RAND_FREQ_LOWER) +/* 0x3A29 */ DEFINE_SFX(NA_SE_EN_BOSU_SIT, 0x50, 3, 0, 0, 0) +/* 0x3A2A */ DEFINE_SFX(NA_SE_EN_BOSU_STAND, 0x30, 3, 0, 0, 0) +/* 0x3A2B */ DEFINE_SFX(NA_SE_EN_BOSU_HAND, 0x30, 3, 0, 0, 0) +/* 0x3A2C */ DEFINE_SFX(NA_SE_EN_LAST3_KOMA_OLD, 0x10, 0, 0, 0, 0) +/* 0x3A2D */ DEFINE_SFX(NA_SE_EN_KONB_PREATTACK_OLD, 0x54, 3, 0, 0, 0) +/* 0x3A2E */ DEFINE_SFX(NA_SE_EN_BOSU_SHOCK, 0x50, 3, 0, 0, 0) +/* 0x3A2F */ DEFINE_SFX(NA_SE_EN_BOSU_SHIT, 0x50, 3, 0, 0, 0) +/* 0x3A30 */ DEFINE_SFX(NA_SE_EN_BOSU_ATTACK, 0x54, 3, 1, 0, 0) +/* 0x3A31 */ DEFINE_SFX(NA_SE_EN_BOSU_CYNICAL, 0x50, 3, 1, 0, 0) +/* 0x3A32 */ DEFINE_SFX(NA_SE_EN_BOSU_LAUGH, 0x50, 3, 1, 0, 0) +/* 0x3A33 */ DEFINE_SFX(NA_SE_EN_BOSU_LAUGH_DEMO, 0x50, 3, 1, 0, 0) +/* 0x3A34 */ DEFINE_SFX(NA_SE_EN_DEBU_ATTACK, 0x36, 3, 1, 0, 0) +/* 0x3A35 */ DEFINE_SFX(NA_SE_EN_DEBU_LAUGH, 0x34, 3, 1, 0, 0) +/* 0x3A36 */ DEFINE_SFX(NA_SE_EN_DEBU_PAUSE, 0x34, 3, 2, 0, 0) +/* 0x3A37 */ DEFINE_SFX(NA_SE_EN_YASE_ATTACK, 0x36, 3, 1, 0, 0) +/* 0x3A38 */ DEFINE_SFX(NA_SE_EN_YASE_LAUGH, 0x35, 3, 1, 0, 0) +/* 0x3A39 */ DEFINE_SFX(NA_SE_EN_YASE_PAUSE, 0x34, 3, 2, 0, 0) +/* 0x3A3A */ DEFINE_SFX(NA_SE_EN_BOSU_DAMAGE, 0x58, 3, 1, 0, 0) +/* 0x3A3B */ DEFINE_SFX(NA_SE_EN_DEBU_DAMAGE, 0x68, 3, 1, 0, 0) +/* 0x3A3C */ DEFINE_SFX(NA_SE_EN_YASE_DAMAGE, 0x38, 3, 1, 0, 0) +/* 0x3A3D */ DEFINE_SFX(NA_SE_EN_BOSU_DEAD, 0x48, 3, 1, 0, 0) +/* 0x3A3E */ DEFINE_SFX(NA_SE_EN_DEBU_DEAD, 0x38, 3, 1, 0, 0) +/* 0x3A3F */ DEFINE_SFX(NA_SE_EN_YASE_DEAD, 0x48, 3, 1, 0, 0) +/* 0x3A40 */ DEFINE_SFX(NA_SE_EN_DEBU_PAUSE_K, 0x34, 3, 2, 0, 0) +/* 0x3A41 */ DEFINE_SFX(NA_SE_EN_DEBU_LAUGH_SHORT_K, 0x34, 3, 1, 0, SFX_PARAM_RAND_FREQ_LOWER) +/* 0x3A42 */ DEFINE_SFX(NA_SE_EN_DEBU_LAUGH_K, 0x34, 3, 1, 0, SFX_PARAM_RAND_FREQ_LOWER) +/* 0x3A43 */ DEFINE_SFX(NA_SE_EN_YASE_PAUSE_K, 0x34, 3, 2, 0, 0) +/* 0x3A44 */ DEFINE_SFX(NA_SE_EN_YASE_LAUGH_K, 0x34, 3, 1, 0, SFX_PARAM_RAND_FREQ_LOWER) +/* 0x3A45 */ DEFINE_SFX(NA_SE_EN_BOSU_LAUGH_DEMO_K, 0x50, 3, 1, 0, 0) +/* 0x3A46 */ DEFINE_SFX(NA_SE_EN_DEBU_LAUGH_SHORT, 0x34, 3, 1, 0, 0) +/* 0x3A47 */ DEFINE_SFX(NA_SE_EN_BOSU_LAUGH_K, 0x50, 3, 1, 0, 0) +/* 0x3A48 */ DEFINE_SFX(NA_SE_EN_DEBU_ATTACK_W, 0x36, 3, 1, 0, 0) +/* 0x3A49 */ DEFINE_SFX(NA_SE_EN_YASE_ATTACK_W, 0x36, 3, 1, 0, 0) +/* 0x3A4A */ DEFINE_SFX(NA_SE_EN_BOSU_ATTACK_W, 0x34, 3, 1, 0, 0) +/* 0x3A4B */ DEFINE_SFX(NA_SE_EN_STAL_FREEZE_LIGHTS, 0x37, 3, 0, 0, 0) +/* 0x3A4C */ DEFINE_SFX(NA_SE_EN_BOSU_ATTACK_K, 0x54, 3, 1, 0, 0) +/* 0x3A4D */ DEFINE_SFX(NA_SE_EN_BOSU_SWORD, 0x40, 3, 0, 0, 0) +/* 0x3A4E */ DEFINE_SFX(NA_SE_EN_KONB_JUMP_LEV_OLD, 0x40, 3, 0, 0, 0) +/* 0x3A4F */ DEFINE_SFX(NA_SE_EN_MIBOSS_FREEZE_OLD, 0x57, 3, 0, 0, 0) +/* 0x3A50 */ DEFINE_SFX(NA_SE_EN_YMAJIN_THROW, 0x34, 2, 0, 0, 0) +/* 0x3A51 */ DEFINE_SFX(NA_SE_EN_BOSU_HEAD_BITE, 0x40, 0, 0, 0, 0) +/* 0x3A52 */ DEFINE_SFX(NA_SE_EN_BOSU_HEAD_FLOAT, 0x32, 0, 0, 0, 0) +/* 0x3A53 */ DEFINE_SFX(NA_SE_EN_LAST3_VOICE_KICK_OLD, 0x50, 3, 2, 0, 0) +/* 0x3A54 */ DEFINE_SFX(NA_SE_EN_LAST3_VOICE_KOMA_OLD, 0x50, 3, 2, 0, 0) +/* 0x3A55 */ DEFINE_SFX(NA_SE_EN_LAST3_VOICE_ROD_OLD, 0x50, 3, 2, 0, 0) +/* 0x3A56 */ DEFINE_SFX(NA_SE_EN_LAST3_VOICE_THROW_OLD, 0x50, 3, 2, 0, 0) +/* 0x3A57 */ DEFINE_SFX(NA_SE_EN_LAST3_VOICE_LAUGH_OLD, 0x50, 3, 2, 0, 0) +/* 0x3A58 */ DEFINE_SFX(NA_SE_EN_LAST3_VOICE_DAMAGE_OLD, 0x58, 3, 2, 0, 0) +/* 0x3A59 */ DEFINE_SFX(NA_SE_EN_LAST3_VOICE_DAMAGE2_OLD, 0x58, 3, 2, 0, 0) +/* 0x3A5A */ DEFINE_SFX(NA_SE_EN_LAST3_VOICE_DEAD_OLD, 0x68, 3, 0, 0, 0) +/* 0x3A5B */ DEFINE_SFX(NA_SE_EN_BOSU_DEAD_VOICE, 0x68, 3, 0, 0, 0) +/* 0x3A5C */ DEFINE_SFX(NA_SE_EN_DEBU_DEAD_VOICE, 0x48, 3, 0, 0, 0) +/* 0x3A5D */ DEFINE_SFX(NA_SE_EN_YASE_DEAD_VOICE, 0x48, 3, 0, 0, 0) +/* 0x3A5E */ DEFINE_SFX(NA_SE_EN_LAST2_BALLET_OLD, 0x50, 3, 0, 0, 0) +/* 0x3A5F */ DEFINE_SFX(NA_SE_EN_LAST2_MOONWALK_OLD, 0x50, 3, 0, 0, 0) +/* 0x3A60 */ DEFINE_SFX(NA_SE_EN_SHARP_FLOAT, 0x28, 4, 0, 0, 0) +/* 0x3A61 */ DEFINE_SFX(NA_SE_EN_SHARP_REACTION, 0x34, 2, 0, 0, 0) +/* 0x3A62 */ DEFINE_SFX(NA_SE_EN_REDEAD_WEAKENED1, 0x30, 0, 2, 0, SFX_PARAM_RAND_FREQ_LOWER) +/* 0x3A63 */ DEFINE_SFX(NA_SE_EN_REDEAD_WEAKENED_L1, 0x30, 0, 2, 0, SFX_PARAM_RAND_FREQ_LOWER) +/* 0x3A64 */ DEFINE_SFX(NA_SE_EN_REDEAD_WEAKENED2, 0x30, 0, 2, 0, SFX_PARAM_RAND_FREQ_LOWER) +/* 0x3A65 */ DEFINE_SFX(NA_SE_EN_REDEAD_WEAKENED_L2, 0x30, 0, 2, 0, SFX_PARAM_RAND_FREQ_LOWER) +/* 0x3A66 */ DEFINE_SFX(NA_SE_EN_PIRATE_ONGND, 0x30, 1, 0, 0, 0) +/* 0x3A67 */ DEFINE_SFX(NA_SE_EN_FOLLOWERS_STAY, 0x30, 4, 2, 0, 0) +/* 0x3A68 */ DEFINE_SFX(NA_SE_EN_LAST2_VOICE_BALLET, 0x50, 3, 0, 0, 0) +/* 0x3A69 */ DEFINE_SFX(NA_SE_EN_LAST2_VOICE_UAUOO1_OLD, 0x50, 3, 0, 0, 0) +/* 0x3A6A */ DEFINE_SFX(NA_SE_EN_LAST2_VOICE_UAUOO2_OLD, 0x50, 3, 0, 0, 0) +/* 0x3A6B */ DEFINE_SFX(NA_SE_EN_LAST2_VOICE_SURPRISED_OLD, 0x50, 3, 0, 0, 0) +/* 0x3A6C */ DEFINE_SFX(NA_SE_EN_LAST2_DAMAGE_OLD, 0x58, 3, 0, 0, 0) +/* 0x3A6D */ DEFINE_SFX(NA_SE_EN_LAST2_DAMAGE2_OLD, 0x58, 3, 0, 0, 0) +/* 0x3A6E */ DEFINE_SFX(NA_SE_EN_LAST2_DEAD_OLD, 0x68, 3, 0, 0, 0) +/* 0x3A6F */ DEFINE_SFX(NA_SE_EN_LAST2_UAUOO_OLD, 0x50, 3, 0, 0, 0) +/* 0x3A70 */ DEFINE_SFX(NA_SE_EN_LAST2_GYM_B_OLD, 0x50, 3, 0, 0, 0) +/* 0x3A71 */ DEFINE_SFX(NA_SE_EN_PIRATE_COOL_LAUGH, 0x30, 1, 0, 0, 0) +/* 0x3A72 */ DEFINE_SFX(NA_SE_EN_PIRATE_CYNICAL, 0x30, 1, 0, 0, 0) +/* 0x3A73 */ DEFINE_SFX(NA_SE_EN_PIRATE_DAMM_BREATH, 0x30, 1, 0, 0, 0) +/* 0x3A74 */ DEFINE_SFX(NA_SE_EN_PIRATE_SHOUT, 0x30, 1, 0, 0, 0) +/* 0x3A75 */ DEFINE_SFX(NA_SE_EN_STAL01_LAUGH, 0x34, 0, 2, 0, 0) +/* 0x3A76 */ DEFINE_SFX(NA_SE_EN_STAL02_LAUGH_SHORT, 0x34, 0, 0, 0, 0) +/* 0x3A77 */ DEFINE_SFX(NA_SE_EN_STAL03_LAUGH_BIG, 0x34, 0, 0, 0, 0) +/* 0x3A78 */ DEFINE_SFX(NA_SE_EN_STAL04_ANGER, 0x34, 0, 0, 0, 0) +/* 0x3A79 */ DEFINE_SFX(NA_SE_EN_STAL05_CYNICAL, 0x34, 0, 0, 0, 0) +/* 0x3A7A */ DEFINE_SFX(NA_SE_EN_STAL06_SURPRISED, 0x34, 0, 0, 0, 0) +/* 0x3A7B */ DEFINE_SFX(NA_SE_EN_STAL07_ANTONISHED, 0x34, 0, 0, 0, 0) +/* 0x3A7C */ DEFINE_SFX(NA_SE_EN_STAL08_CRY_BIG, 0x34, 0, 0, 0, 0) +/* 0x3A7D */ DEFINE_SFX(NA_SE_EN_STAL09_SCREAM, 0x34, 0, 0, 0, 0) +/* 0x3A7E */ DEFINE_SFX(NA_SE_EN_STAL10_LAUGH_SHY, 0x34, 0, 0, 0, 0) +/* 0x3A7F */ DEFINE_SFX(NA_SE_EN_STAL11_LAUGH_SHY2, 0x54, 0, 0, 0, 0) +/* 0x3A80 */ DEFINE_SFX(NA_SE_EN_STAL12_LAUGH_KIDLY, 0x34, 0, 0, 0, 0) +/* 0x3A81 */ DEFINE_SFX(NA_SE_EN_STAL20_CALL_MOON, 0x34, 0, 0, 0, SFX_FLAG_VOLUME_NO_DIST) +/* 0x3A82 */ DEFINE_SFX(NA_SE_EN_STAL20_CALL_MOON2, 0x34, 0, 0, 0, SFX_FLAG_VOLUME_NO_DIST) +/* 0x3A83 */ DEFINE_SFX(NA_SE_EN_STAL21_PSYCHO_VOICE, 0x34, 0, 0, 0, 0) +/* 0x3A84 */ DEFINE_SFX(NA_SE_EN_STALKIDS_DOWN_K, 0x30, 5, 0, 0, 0) +/* 0x3A85 */ DEFINE_SFX(NA_SE_EN_AKINDO_FLY, 0x30, 1, 0, 0, 0) +/* 0x3A86 */ DEFINE_SFX(NA_SE_EN_NPC_APPEAR, 0x30, 0, 0, 0, 0) +/* 0x3A87 */ DEFINE_SFX(NA_SE_EN_NPC_FADEAWAY, 0x30, 0, 0, 0, 0) +/* 0x3A88 */ DEFINE_SFX(NA_SE_EN_DEBU_PAUSEx2, 0x34, 3, 2, 0, SFX_PARAM_RAND_FREQ_LOWER) +/* 0x3A89 */ DEFINE_SFX(NA_SE_EN_YASE_PAUSEx2, 0x34, 3, 2, 0, SFX_PARAM_RAND_FREQ_LOWER) +/* 0x3A8A */ DEFINE_SFX(NA_SE_EN_DEBU_HEAD_UP, 0x30, 3, 2, 0, SFX_PARAM_RAND_FREQ_LOWER) +/* 0x3A8B */ DEFINE_SFX(NA_SE_EN_YASE_HEAD_UP, 0x30, 3, 2, 0, SFX_PARAM_RAND_FREQ_LOWER) +/* 0x3A8C */ DEFINE_SFX(NA_SE_EN_STAL22_LAUGH_KID_L, 0x34, 0, 0, 0, 0) +/* 0x3A8D */ DEFINE_SFX(NA_SE_EN_EVIL_POWER, 0x30, 0, 0, 0, 0) +/* 0x3A8E */ DEFINE_SFX(NA_SE_NE_STAL23_COLD, 0x34, 3, 2, 0, SFX_FLAG_REVERB_NO_DIST) +/* 0x3A8F */ DEFINE_SFX(NA_SE_EN_STALKIDS_GASAGOSO, 0x30, 5, 0, 0, SFX_FLAG_REVERB_NO_DIST) +/* 0x3A90 */ DEFINE_SFX(NA_SE_EN_BOSU_TALK, 0x30, 0, 2, 0, SFX_PARAM_RAND_FREQ_LOWER) +/* 0x3A91 */ DEFINE_SFX(NA_SE_EN_FAMOS_REVERSE1, 0x34, 0, 0, 0, 0) +/* 0x3A92 */ DEFINE_SFX(NA_SE_EN_FAMOS_REVERSE2, 0x34, 0, 0, 0, 0) +/* 0x3A93 */ DEFINE_SFX(NA_SE_EN_FAMOS_FLOAT, 0x30, 6, 0, 0, 0) +/* 0x3A94 */ DEFINE_SFX(NA_SE_EN_FAMOS_FLOAT_REVERSE, 0x30, 6, 0, 0, 0) +/* 0x3A95 */ DEFINE_SFX(NA_SE_EN_KOTAKE_ROLL, 0x30, 5, 0, 0, 0) +/* 0x3A96 */ DEFINE_SFX(NA_SE_EN_KOTAKE_FLY, 0x30, 6, 0, 0, 0) +/* 0x3A97 */ DEFINE_SFX(NA_SE_EN_THIEFBIRD_VOICE, 0x34, 0, 0, 0, 0) +/* 0x3A98 */ DEFINE_SFX(NA_SE_EN_THIEFBIRD_DAMAGE, 0x38, 0, 0, 0, 0) +/* 0x3A99 */ DEFINE_SFX(NA_SE_EN_THIEFBIRD_DEAD, 0x48, 0, 0, 0, 0) +/* 0x3A9A */ DEFINE_SFX(NA_SE_EN_STALKIDS_BODY, 0x30, 0, 2, 0, 0) +/* 0x3A9B */ DEFINE_SFX(NA_SE_EN_STALKIDS_BODY_LEV, 0x30, 5, 2, 0, 0) +/* 0x3A9C */ DEFINE_SFX(NA_SE_EN_BOSU_STAND_RAPID, 0x30, 0, 0, 0, 0) +/* 0x3A9D */ DEFINE_SFX(NA_SE_EN_STAL24_SCREAM2, 0x30, 0, 0, 0, 0) +/* 0x3A9E */ DEFINE_SFX(NA_SE_EN_STALKIDS_EARTHQUAKE, 0x30, 0, 2, 0, 0) +/* 0x3A9F */ DEFINE_SFX(NA_SE_EN_MASK_FLOAT, 0x30, 0, 0, 0, 0) +/* 0x3AA0 */ DEFINE_SFX(NA_SE_EN_STALKIDS_PULLED, 0x30, 0, 0, 0, 0) +/* 0x3AA1 */ DEFINE_SFX(NA_SE_EN_KITA_SALUTE, 0x40, 2, 0, 0, 0) +/* 0x3AA2 */ DEFINE_SFX(NA_SE_EN_KTIA_WALK, 0x32, 0, 2, 0, 0) +/* 0x3AA3 */ DEFINE_SFX(NA_SE_EN_KTIA_PAUSE_K, 0x50, 2, 0, 0, 0) +/* 0x3AA4 */ DEFINE_SFX(NA_SE_EN_KITA_LAUGH_K, 0x50, 2, 0, 0, 0) +/* 0x3AA5 */ DEFINE_SFX(NA_SE_EN_KITA_DAMAGE, 0x58, 2, 0, 0, 0) +/* 0x3AA6 */ DEFINE_SFX(NA_SE_EN_KITA_DEAD, 0x68, 2, 0, 0, 0) +/* 0x3AA7 */ DEFINE_SFX(NA_SE_EN_STALBABY_LAUGH, 0x30, 0, 0, 0, 0) +/* 0x3AA8 */ DEFINE_SFX(NA_SE_EN_STALBABY_SURPRISED, 0x30, 0, 0, 0, 0) +/* 0x3AA9 */ DEFINE_SFX(NA_SE_EN_KITA_BREAK, 0x50, 2, 0, 0, 0) +/* 0x3AAA */ DEFINE_SFX(NA_SE_EN_KITA_ATTACK_W, 0x50, 2, 0, 0, 0) +/* 0x3AAB */ DEFINE_SFX(NA_SE_EN_KONB_WAIT_OLD, 0x30, 3, 0, 0, 0) +/* 0x3AAC */ DEFINE_SFX(NA_SE_EN_DEATH_SCYTHE, 0x54, 5, 0, 0, 0) +/* 0x3AAD */ DEFINE_SFX(NA_SE_EN_DEATH_ROLL, 0x28, 5, 0, 0, 0) +/* 0x3AAE */ DEFINE_SFX(NA_SE_EN_DEATH_SCYTHE_LEV, 0x78, 0, 0, 0, SFX_FLAG_VOLUME_NO_DIST) +/* 0x3AAF */ DEFINE_SFX(NA_SE_EN_DEATH_SCYTHE_ONGND, 0x78, 0, 0, 0, SFX_FLAG_VOLUME_NO_DIST) +/* 0x3AB0 */ DEFINE_SFX(NA_SE_EN_DEATH_VOICE, 0x50, 3, 0, 0, 0) +/* 0x3AB1 */ DEFINE_SFX(NA_SE_EN_DEATH_DAMAGE, 0x58, 3, 0, 0, 0) +/* 0x3AB2 */ DEFINE_SFX(NA_SE_EN_DEATH_DEAD, 0x68, 3, 0, 0, 0) +/* 0x3AB3 */ DEFINE_SFX(NA_SE_EN_DEATH_ATTACK, 0x54, 3, 0, 0, 0) +/* 0x3AB4 */ DEFINE_SFX(NA_SE_EN_DEATH_APPEAR, 0x40, 3, 0, 0, 0) +/* 0x3AB5 */ DEFINE_SFX(NA_SE_EN_DEATH_HEARTBREAK, 0x78, 3, 0, 0, 0) +/* 0x3AB6 */ DEFINE_SFX(NA_SE_EN_KONB_MINI_DEAD, 0x48, 0, 0, 0, 0) +/* 0x3AB7 */ DEFINE_SFX(NA_SE_EN_HALF_REDEAD_LOOP, 0x30, 3, 2, 0, 0) +/* 0x3AB8 */ DEFINE_SFX(NA_SE_EN_HALF_REDEAD_SURPRISE, 0x30, 3, 2, 0, 0) +/* 0x3AB9 */ DEFINE_SFX(NA_SE_EN_HALF_REDEAD_SCREAME, 0x30, 3, 2, 0, 0) +/* 0x3ABA */ DEFINE_SFX(NA_SE_EN_HALF_REDEAD_TRANS, 0x30, 3, 0, 0, 0) +/* 0x3ABB */ DEFINE_SFX(NA_SE_EN_GOLON_VOICE_GENERAL, 0x30, 0, 0, 0, 0) +/* 0x3ABC */ DEFINE_SFX(NA_SE_EN_IWAIGORON_EVERYBODY, 0x30, 0, 0, 0, 0) +/* 0x3ABD */ DEFINE_SFX(NA_SE_EN_IWAIGORON_SOLO, 0x30, 3, 3, 0, 0) +/* 0x3ABE */ DEFINE_SFX(NA_SE_EN_ROMANI_WALK, 0x30, 0, 2, 0, 0) +/* 0x3ABF */ DEFINE_SFX(NA_SE_EN_MOON_SCREAM1, 0x30, 0, 0, 0, SFX_FLAG_VOLUME_NO_DIST) +/* 0x3AC0 */ DEFINE_SFX(NA_SE_EN_MOON_SCREAM2, 0x30, 0, 0, 0, SFX_FLAG_VOLUME_NO_DIST) +/* 0x3AC1 */ DEFINE_SFX(NA_SE_EN_MOON_SCREAM3, 0x30, 0, 0, 0, SFX_FLAG_VOLUME_NO_DIST) +/* 0x3AC2 */ DEFINE_SFX(NA_SE_EN_MOON_SCREAM4, 0x30, 0, 0, 0, SFX_FLAG_VOLUME_NO_DIST) +/* 0x3AC3 */ DEFINE_SFX(NA_SE_EN_STALKIDS_HEADACHE, 0x30, 0, 0, 0, SFX_FLAG_VOLUME_NO_DIST) +/* 0x3AC4 */ DEFINE_SFX(NA_SE_EN_BIGNUTS_WALK, 0x30, 5, 1, 0, 0) +/* 0x3AC5 */ DEFINE_SFX(NA_SE_EN_KITA_PAUSE, 0x60, 2, 0, 0, 0) +/* 0x3AC6 */ DEFINE_SFX(NA_SE_EN_ANSATSUSYA_LAUGH, 0x70, 0, 0, 0, SFX_FLAG_VOLUME_NO_DIST) +/* 0x3AC7 */ DEFINE_SFX(NA_SE_EN__copy514, 0x30, 0, 2, 0, 0) +/* 0x3AC8 */ DEFINE_SFX(NA_SE_EN__copy515, 0x30, 0, 2, 0, 0) +/* 0x3AC9 */ DEFINE_SFX(NA_SE_EN__copy516, 0x30, 0, 2, 0, 0) +/* 0x3ACA */ DEFINE_SFX(NA_SE_EN__copy517, 0x30, 0, 2, 0, 0) +/* 0x3ACB */ DEFINE_SFX(NA_SE_EN__copy518, 0x30, 0, 2, 0, 0) +/* 0x3ACC */ DEFINE_SFX(NA_SE_EN__copy519, 0x30, 0, 2, 0, 0) +/* 0x3ACD */ DEFINE_SFX(NA_SE_EN_DALMANI_A, 0x30, 0, 2, 0, 0) +/* 0x3ACE */ DEFINE_SFX(NA_SE_EN_DALMANI_B, 0x30, 0, 2, 0, 0) +/* 0x3ACF */ DEFINE_SFX(NA_SE_EN_DALMANI_C, 0x30, 0, 2, 0, 0) +/* 0x3AD0 */ DEFINE_SFX(NA_SE_EN_DALMANI_D, 0x30, 0, 2, 0, 0) +/* 0x3AD1 */ DEFINE_SFX(NA_SE_EN__2d1, 0x30, 0, 0, 0, 0) +/* 0x3AD2 */ DEFINE_SFX(NA_SE_EN__2d2, 0x30, 0, 0, 0, 0) +/* 0x3AD3 */ DEFINE_SFX(NA_SE_EN_EVIL_POWER_PREDEMO, 0x30, 7, 0, 0, 0) +/* 0x3AD4 */ DEFINE_SFX(NA_SE_EN_KOUME_DAMAGE, 0x30, 4, 1, 0, 0) +/* 0x3AD5 */ DEFINE_SFX(NA_SE_EN_KOUME_DAMAGE2, 0x30, 4, 1, 0, 0) +/* 0x3AD6 */ DEFINE_SFX(NA_SE_EN_KONB_MINI_APPEAR, 0x30, 3, 2, 0, 0) +/* 0x3AD7 */ DEFINE_SFX(NA_SE_EN_IRONNACK_DAMAGE, 0x48, 3, 0, 0, 0) +/* 0x3AD8 */ DEFINE_SFX(NA_SE_EN_IRONNACK_DEAD, 0x58, 3, 0, 0, 0) +/* 0x3AD9 */ DEFINE_SFX(NA_SE_EN_ANSATSUSYA_ONGND, 0x30, 0, 0, 0, 0) +/* 0x3ADA */ DEFINE_SFX(NA_SE_EN_ANSATSUSYA_ROCK, 0x30, 3, 0, 0, 0) +/* 0x3ADB */ DEFINE_SFX(NA_SE_EN_REDEAD_REVERSE, 0x36, 0, 0, 0, 0) +/* 0x3ADC */ DEFINE_SFX(NA_SE_EN_STALKIDS_NOSE, 0x40, 2, 0, 0, 0) +/* 0x3ADD */ DEFINE_SFX(NA_SE_EN_KITA_SNORE, 0x30, 0, 0, 0, 0) +/* 0x3ADE */ DEFINE_SFX(NA_SE_EN_IRONNACK_DASH, 0x30, 0, 0, 0, 0) +/* 0x3ADF */ DEFINE_SFX(NA_SE_EN_TUBOOCK_FLY, 0x30, 0, 0, 0, 0) diff --git a/include/tables/sfx/environmentbank_table.h b/include/tables/sfx/environmentbank_table.h new file mode 100644 index 000000000..ab7945c34 --- /dev/null +++ b/include/tables/sfx/environmentbank_table.h @@ -0,0 +1,477 @@ +/** + * Sfx Environment Bank + * + * DEFINE_SFX should be used for all sfx define in the environment bank from sequence 0 + * - Argument 0: Enum value for this sfx + * - Argument 1: Importance for deciding which sfx to prioritize. Higher values have greater importance + * - Argument 2: Slows the decay of volume with distance (a 3-bit number ranging from 0-7) + * - Argument 3: Applies increasingly random offsets to frequency (a 2-bit number ranging from 0-3) + * - Argument 4: Various flags to add properties to the sfx + * - Argument 5: Various flags to add properties to the sfx + * + * WARNING: entries must align with the table defined for the environment bank in sequence 0 + */ +/* 0x2800 */ DEFINE_SFX(NA_SE_EV_DOOR_OPEN, 0x70, 0, 1, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX | SFX_FLAG_SURROUND_LOWPASS_FILTER) +/* 0x2801 */ DEFINE_SFX(NA_SE_EV_DOOR_CLOSE, 0x80, 0, 1, 0, 0) +/* 0x2802 */ DEFINE_SFX(NA_SE_EV_EXPLOSION, 0x30, 0, 0, 0, 0) +/* 0x2803 */ DEFINE_SFX(NA_SE_EV_HORSE_WALK, 0x60, 0, 1, 0, 0) +/* 0x2804 */ DEFINE_SFX(NA_SE_EV_HORSE_RUN, 0x60, 0, 1, 0, 0) +/* 0x2805 */ DEFINE_SFX(NA_SE_EV_HORSE_NEIGH, 0x70, 0, 1, 0, 0) +/* 0x2806 */ DEFINE_SFX(NA_SE_EV_RIVER_STREAM, 0x30, 0, 2, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x2807 */ DEFINE_SFX(NA_SE_EV_WATER_WALL_BIG, 0x70, 2, 0, 0, 0) +/* 0x2808 */ DEFINE_SFX(NA_SE_EV_OUT_OF_WATER, 0x30, 0, 1, 0, 0) +/* 0x2809 */ DEFINE_SFX(NA_SE_EV_DIVE_WATER, 0x30, 0, 1, 0, 0) +/* 0x280A */ DEFINE_SFX(NA_SE_EV_ROCK_SLIDE, 0x80, 2, 0, 0, 0) +/* 0x280B */ DEFINE_SFX(NA_SE_EV_MAGMA_LEVEL, 0xA0, 3, 0, 0, 0) +/* 0x280C */ DEFINE_SFX(NA_SE_EV_BRIDGE_OPEN, 0x30, 3, 0, 0, SFX_FLAG_8) +/* 0x280D */ DEFINE_SFX(NA_SE_EV_BRIDGE_CLOSE, 0x30, 3, 0, 0, 0) +/* 0x280E */ DEFINE_SFX(NA_SE_EV_BRIDGE_OPEN_STOP, 0x30, 3, 0, 0, 0) +/* 0x280F */ DEFINE_SFX(NA_SE_EV_BRIDGE_CLOSE_STOP, 0x30, 3, 0, 0, 0) +/* 0x2810 */ DEFINE_SFX(NA_SE_EV_WALL_BROKEN, 0x30, 2, 0, 0, 0) +/* 0x2811 */ DEFINE_SFX(NA_SE_EV_CHICKEN_CRY_N, 0x30, 0, 1, 0, 0) +/* 0x2812 */ DEFINE_SFX(NA_SE_EV_CHICKEN_CRY_A, 0x30, 0, 1, 0, 0) +/* 0x2813 */ DEFINE_SFX(NA_SE_EV_CHICKEN_CRY_M, 0x50, 0, 0, 0, 0) +/* 0x2814 */ DEFINE_SFX(NA_SE_EV_SLIDE_DOOR_OPEN, 0x60, 2, 0, 0, 0) +/* 0x2815 */ DEFINE_SFX(NA_SE_EV_FOOT_SWITCH, 0x30, 3, 0, 0, 0) +/* 0x2816 */ DEFINE_SFX(NA_SE_EV_HORSE_GROAN, 0x60, 0, 0, 0, 0) +/* 0x2817 */ DEFINE_SFX(NA_SE_EV_BOMB_DROP_WATER, 0x30, 2, 2, 0, 0) +/* 0x2818 */ DEFINE_SFX(NA_SE_EV_HORSE_JUMP, 0x30, 0, 0, 0, 0) +/* 0x2819 */ DEFINE_SFX(NA_SE_EV_HORSE_LAND, 0x40, 0, 0, 0, 0) +/* 0x281A */ DEFINE_SFX(NA_SE_EV_HORSE_SLIP, 0x68, 0, 0, 0, 0) +/* 0x281B */ DEFINE_SFX(NA_SE_EV_WHITE_FAIRY_DASH, 0x58, 0, 1, 0, 0) +/* 0x281C */ DEFINE_SFX(NA_SE_EV_SLIDE_DOOR_CLOSE, 0x60, 0, 0, 0, 0) +/* 0x281D */ DEFINE_SFX(NA_SE_EV_BIGWALL_BOUND, 0x70, 3, 0, 0, 0) +/* 0x281E */ DEFINE_SFX(NA_SE_EV_STONE_STATUE_OPEN, 0x30, 3, 1, 0, 0) +/* 0x281F */ DEFINE_SFX(NA_SE_EV_TBOX_UNLOCK, 0x30, 0, 0, 0, 0) +/* 0x2820 */ DEFINE_SFX(NA_SE_EV_TBOX_OPEN, 0x30, 0, 0, 0, 0) +/* 0x2821 */ DEFINE_SFX(NA_SE_SY_TIMER, 0xA0, 0, 0, 0, SFX_FLAG_VOLUME_NO_DIST | SFX_FLAG_LOWER_VOLUME_BGM) +/* 0x2822 */ DEFINE_SFX(NA_SE_EV_FLAME_IGNITION, 0x20, 2, 0, 0, 0) +/* 0x2823 */ DEFINE_SFX(NA_SE_EV_SPEAR_HIT, 0x30, 0, 0, 0, 0) +/* 0x2824 */ DEFINE_SFX(NA_SE_EV_ELEVATOR_MOVE, 0x30, 0, 0, 0, SFX_PARAM_RAND_FREQ_SCALE) +/* 0x2825 */ DEFINE_SFX(NA_SE_EV_WARP_HOLE, 0x30, 0, 0, 0, SFX_FLAG_FREQ_NO_DIST | SFX_PARAM_RAND_FREQ_SCALE) +/* 0x2826 */ DEFINE_SFX(NA_SE_EV_LINK_WARP, 0x30, 0, 0, 0, SFX_FLAG_FREQ_NO_DIST) +/* 0x2827 */ DEFINE_SFX(NA_SE_EV_PILLAR_SINK, 0x30, 2, 0, 0, 0) +/* 0x2828 */ DEFINE_SFX(NA_SE_EV_WATER_WALL, 0x30, 0, 0, 0, 0) +/* 0x2829 */ DEFINE_SFX(NA_SE_EV_RIVER_STREAM_S, 0x30, 0, 0, 0, 0) +/* 0x282A */ DEFINE_SFX(NA_SE_EV_RIVER_STREAM_F, 0x30, 0, 0, 0, 0) +/* 0x282B */ DEFINE_SFX(NA_SE_EV_KID_HORSE_LAND2, 0x60, 0, 0, 0, 0) +/* 0x282C */ DEFINE_SFX(NA_SE_EV_KID_HORSE_SANDDUST, 0x60, 0, 0, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x282D */ DEFINE_SFX(NA_SE_EV_DUMMY_45, 0x30, 0, 0, 0, 0) +/* 0x282E */ DEFINE_SFX(NA_SE_EV_LIGHTNING, 0x80, 0, 0, 0, 0) +/* 0x282F */ DEFINE_SFX(NA_SE_EV_BOMB_BOUND, 0x30, 0, 2, 0, 0) +/* 0x2830 */ DEFINE_SFX(NA_SE_EV_WATERDROP, 0x30, 0, 1, 0, 0) +/* 0x2831 */ DEFINE_SFX(NA_SE_EV_TORCH, 0x10, 0, 0, 0, 0) +/* 0x2832 */ DEFINE_SFX(NA_SE_EV_MAGMA_LEVEL_M, 0xA0, 3, 0, 0, 0) +/* 0x2833 */ DEFINE_SFX(NA_SE_EV_FIRE_PILLAR, 0x30, 0, 0, 0, SFX_FLAG_8) +/* 0x2834 */ DEFINE_SFX(NA_SE_EV_FIRE_PLATE, 0x30, 0, 0, 0, SFX_FLAG_PRIORITY_NO_DIST) +/* 0x2835 */ DEFINE_SFX(NA_SE_EV_BLOCK_BOUND, 0x30, 3, 0, 0, 0) +/* 0x2836 */ DEFINE_SFX(NA_SE_EV_METALDOOR_SLIDE, 0x60, 3, 0, SFX_FLAG2_UNUSED6, 0) +/* 0x2837 */ DEFINE_SFX(NA_SE_EV_METALDOOR_STOP, 0x30, 0, 0, 0, 0) +/* 0x2838 */ DEFINE_SFX(NA_SE_EV_BLOCK_SHAKE, 0x30, 0, 0, 0, 0) +/* 0x2839 */ DEFINE_SFX(NA_SE_EV_BOX_BREAK, 0x30, 2, 0, 0, 0) +/* 0x283A */ DEFINE_SFX(NA_SE_EV_HAMMER_SWITCH, 0x30, 0, 0, 0, 0) +/* 0x283B */ DEFINE_SFX(NA_SE_EV_MAGMA_LEVEL_L, 0xA0, 3, 0, 0, 0) +/* 0x283C */ DEFINE_SFX(NA_SE_EV_SPEAR_FENCE, 0x30, 0, 0, 0, 0) +/* 0x283D */ DEFINE_SFX(NA_SE_EV_WATERDROP_GRD, 0x30, 0, 0, 0, 0) +/* 0x283E */ DEFINE_SFX(NA_SE_EV_EXPLSION_LONG, 0x30, 3, 0, 0, 0) +/* 0x283F */ DEFINE_SFX(NA_SE_EV_WATER_WALL_BIG_SILENT, 0x70, 0, 0, 0, 0) +/* 0x2840 */ DEFINE_SFX(NA_SE_EV_DESERT_WARPHOLE, 0x60, 0, 0, 0, SFX_FLAG_FREQ_NO_DIST) +/* 0x2841 */ DEFINE_SFX(NA_SE_EV_FOUNTAIN, 0x30, 0, 0, 0, SFX_FLAG_FREQ_NO_DIST) +/* 0x2842 */ DEFINE_SFX(NA_SE_EV_KID_HORSE_WALK, 0x60, 0, 0, 0, 0) +/* 0x2843 */ DEFINE_SFX(NA_SE_EV_KID_HORSE_RUN, 0x60, 0, 0, 0, 0) +/* 0x2844 */ DEFINE_SFX(NA_SE_EV_KID_HORSE_NEIGH, 0x60, 0, 0, 0, 0) +/* 0x2845 */ DEFINE_SFX(NA_SE_EV_KID_HORSE_GROAN, 0x60, 0, 0, 0, 0) +/* 0x2846 */ DEFINE_SFX(NA_SE_EV_S_STONE_FLASH, 0x30, 3, 0, 0, SFX_FLAG_VOLUME_NO_DIST) +/* 0x2847 */ DEFINE_SFX(NA_SE_EV_LIGHT_GATHER, 0x30, 0, 0, 0, 0) +/* 0x2848 */ DEFINE_SFX(NA_SE_EV_TREE_CUT, 0x30, 0, 0, 0, 0) +/* 0x2849 */ DEFINE_SFX(NA_SE_EV_VOLCANO, 0x30, 0, 0, 0, SFX_FLAG_VOLUME_NO_DIST | SFX_FLAG_PRIORITY_NO_DIST) +/* 0x284A */ DEFINE_SFX(NA_SE_EV_POSTMAN_WALK, 0x30, 0, 1, 0, 0) +/* 0x284B */ DEFINE_SFX(NA_SE_EV_POSTMACHINE_HIT_OPEN, 0x60, 0, 0, 0, 0) +/* 0x284C */ DEFINE_SFX(NA_SE_EV_POSTMACHINE_OPEN, 0x60, 3, 0, 0, 0) +/* 0x284D */ DEFINE_SFX(NA_SE_EV_CHINETRAP_DOWN, 0x30, 0, 0, 0, 0) +/* 0x284E */ DEFINE_SFX(NA_SE_EV_PLANT_BROKEN, 0x58, 1, 0, 0, 0) +/* 0x284F */ DEFINE_SFX(NA_SE_EV_STONE_SWITCH_ON, 0x30, 0, 0, 0, 0) +/* 0x2850 */ DEFINE_SFX(NA_SE_EV_FLUTTER_FLAG, 0x30, 0, 0, 0, 0) +/* 0x2851 */ DEFINE_SFX(NA_SE_EV_TRAP_BOUND, 0x40, 0, 0, 0, 0) +/* 0x2852 */ DEFINE_SFX(NA_SE_EV_ROCK_BROKEN, 0x30, 3, 3, 0, 0) +/* 0x2853 */ DEFINE_SFX(NA_SE_EV_FANTOM_WARP_S2, 0x70, 2, 0, 0, 0) +/* 0x2854 */ DEFINE_SFX(NA_SE_EV_FANTOM_WARP_L2, 0x60, 2, 0, 0, 0) +/* 0x2855 */ DEFINE_SFX(NA_SE_EV_COFFIN_CAP_OPEN, 0x30, 0, 0, 0, 0) +/* 0x2856 */ DEFINE_SFX(NA_SE_EV_TRE_BOX_BOUND, 0x60, 1, 1, 0, 0) +/* 0x2857 */ DEFINE_SFX(NA_SE_EV_WIND_TRAP, 0x30, 2, 0, 0, 0) +/* 0x2858 */ DEFINE_SFX(NA_SE_EV_TRAP_OBJ_SLIDE, 0x30, 0, 0, 0, 0) +/* 0x2859 */ DEFINE_SFX(NA_SE_EV_METALDOOR_OPEN, 0x90, 3, 0, 0, 0) +/* 0x285A */ DEFINE_SFX(NA_SE_EV_METALDOOR_CLOSE, 0x90, 3, 0, 0, 0) +/* 0x285B */ DEFINE_SFX(NA_SE_EV_BURN_OUT, 0x30, 0, 0, 0, 0) +/* 0x285C */ DEFINE_SFX(NA_SE_EV_BLOCKSINK, 0x30, 2, 0, 0, 0) +/* 0x285D */ DEFINE_SFX(NA_SE_EV_CROWD, 0x30, 0, 0, 0, SFX_FLAG_VOLUME_NO_DIST | SFX_FLAG_REVERB_NO_DIST | SFX_PARAM_RAND_FREQ_SCALE) +/* 0x285E */ DEFINE_SFX(NA_SE_EV_WATER_LEVEL_DOWN, 0x30, 0, 0, 0, 0) +/* 0x285F */ DEFINE_SFX(NA_SE_EV_NAVY_VANISH, 0x30, 0, 0, 0, 0) +/* 0x2860 */ DEFINE_SFX(NA_SE_EV_STONE_SWITCH_OFF, 0x30, 3, 0, 0, 0) +/* 0x2861 */ DEFINE_SFX(NA_SE_EV_WEB_VIBRATION, 0x30, 0, 0, 0, 0) +/* 0x2862 */ DEFINE_SFX(NA_SE_EV_ICE_STAND_APPEAR, 0x30, 0, 0, 0, 0) +/* 0x2863 */ DEFINE_SFX(NA_SE_EV_ROLL_STAND, 0x30, 3, 0, 0, 0) +/* 0x2864 */ DEFINE_SFX(NA_SE_EV_SEESAW_WATER_BOUND, 0x30, 0, 1, 0, 0) +/* 0x2865 */ DEFINE_SFX(NA_SE_EV_SECOM_CONVEYOR, 0x30, 0, 0, 0, 0) +/* 0x2866 */ DEFINE_SFX(NA_SE_EV_WOODDOOR_OPEN, 0x30, 0, 0, 0, 0) +/* 0x2867 */ DEFINE_SFX(NA_SE_EV_METALGATE_OPEN, 0x30, 0, 0, 0, 0) +/* 0x2868 */ DEFINE_SFX(NA_SE_IT_SCOOP_UP_WATER, 0x30, 0, 0, 0, 0) +/* 0x2869 */ DEFINE_SFX(NA_SE_EV_FISH_LEAP, 0x30, 0, 0, 0, 0) +/* 0x286A */ DEFINE_SFX(NA_SE_EV_KAKASHI_SWING, 0x30, 0, 0, 0, 0) +/* 0x286B */ DEFINE_SFX(NA_SE_EV_KAKASHI_ROLL, 0x30, 0, 0, 0, 0) +/* 0x286C */ DEFINE_SFX(NA_SE_EV_BOTTLE_CAP_OPEN, 0x30, 3, 0, 0, 0) +/* 0x286D */ DEFINE_SFX(NA_SE_EV_G_STONE_CRUSH, 0x30, 3, 0, 0, SFX_PARAM_RAND_FREQ_SCALE) +/* 0x286E */ DEFINE_SFX(NA_SE_EV_KAKASH_LONGI_ROLL, 0x30, 0, 0, 0, 0) +/* 0x286F */ DEFINE_SFX(NA_SE_EV_SUN_MARK_FLASH, 0x30, 3, 0, 0, 0) +/* 0x2870 */ DEFINE_SFX(NA_SE_EV_FALL_DOWN_DIRT, 0x30, 0, 0, 0, 0) +/* 0x2871 */ DEFINE_SFX(NA_SE_EV_SEESAW_BOUND, 0x30, 0, 0, 0, 0) +/* 0x2872 */ DEFINE_SFX(NA_SE_EV_FAIRY_ATTACK, 0x30, 0, 2, 0, 0) +/* 0x2873 */ DEFINE_SFX(NA_SE_EV_WOOD_HIT, 0x30, 0, 0, 0, 0) +/* 0x2874 */ DEFINE_SFX(NA_SE_EV_SCOOPUP_WATER, 0x30, 0, 0, 0, 0) +/* 0x2875 */ DEFINE_SFX(NA_SE_EV_DROP_FALL, 0x30, 0, 0, 0, 0) +/* 0x2876 */ DEFINE_SFX(NA_SE_EV_WOOD_GEAR, 0x30, 2, 0, 0, 0) +/* 0x2877 */ DEFINE_SFX(NA_SE_EV_TREE_SWING, 0x60, 0, 0, 0, 0) +/* 0x2878 */ DEFINE_SFX(NA_SE_EV_AUTO_DOOR_CLOSE, 0x30, 0, 1, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX | SFX_FLAG_SURROUND_LOWPASS_FILTER) +/* 0x2879 */ DEFINE_SFX(NA_SE_EV_NAVY_FLY_REBIRTH, 0x30, 2, 0, 0, 0) +/* 0x287A */ DEFINE_SFX(NA_SE_EV_CHAINLIFT_STOP, 0x30, 2, 0, 0, 0) +/* 0x287B */ DEFINE_SFX(NA_SE_EV_TRE_BOX_APPEAR, 0x80, 2, 0, 0, 0) +/* 0x287C */ DEFINE_SFX(NA_SE_EV_CHAIN_KEY_UNLOCK, 0x40, 0, 0, 0, 0) +/* 0x287D */ DEFINE_SFX(NA_SE_EV_SPINE_TRAP_MOVE, 0x1C, 0, 0, 0, 0) +/* 0x287E */ DEFINE_SFX(NA_SE_EV_HEALING, 0x30, 0, 0, 0, 0) +/* 0x287F */ DEFINE_SFX(NA_SE_EV_GREAT_FAIRY_APPEAR, 0x30, 0, 0, 0, 0) +/* 0x2880 */ DEFINE_SFX(NA_SE_EV_GREAT_FAIRY_VANISH, 0x30, 0, 0, 0, 0) +/* 0x2881 */ DEFINE_SFX(NA_SE_EV_RED_EYE, 0x30, 0, 0, 0, 0) +/* 0x2882 */ DEFINE_SFX(NA_SE_EV_ROLL_STAND_2, 0x30, 0, 0, 0, 0) +/* 0x2883 */ DEFINE_SFX(NA_SE_EV_WALL_SLIDE, 0x30, 0, 0, 0, 0) +/* 0x2884 */ DEFINE_SFX(NA_SE_EV_TRE_BOX_FLASH, 0x30, 0, 0, 0, 0) +/* 0x2885 */ DEFINE_SFX(NA_SE_EV_WINDMILL_LEVEL, 0x60, 4, 0, 0, 0) +/* 0x2886 */ DEFINE_SFX(NA_SE_EV_GOTO_HEAVEN, 0x30, 0, 0, 0, SFX_PARAM_RAND_FREQ_SCALE) +/* 0x2887 */ DEFINE_SFX(NA_SE_EV_POT_BROKEN, 0x30, 0, 1, 0, 0) +/* 0x2888 */ DEFINE_SFX(NA_SE_PL_PUT_DOWN_POT, 0x30, 0, 0, 0, 0) +/* 0x2889 */ DEFINE_SFX(NA_SE_EV_DIVE_INTO_WATER, 0x60, 0, 0, 0, 0) +/* 0x288A */ DEFINE_SFX(NA_SE_EV_JUMP_OUT_WATER, 0x60, 0, 0, 0, 0) +/* 0x288B */ DEFINE_SFX(NA_SE_EV_ICE_PIECE, 0x30, 0, 0, 0, 0) +/* 0x288C */ DEFINE_SFX(NA_SE_EV_TRIFORCE, 0x30, 0, 0, 0, 0) +/* 0x288D */ DEFINE_SFX(NA_SE_EV_AURORA, 0x30, 0, 0, 0, 0) +/* 0x288E */ DEFINE_SFX(NA_SE_EV_CHIBI_FAIRY_SAVED, 0x60, 3, 0, 0, 0) +/* 0x288F */ DEFINE_SFX(NA_SE_EV_BUYOSTAND_RISING, 0x30, 3, 0, 0, 0) +/* 0x2890 */ DEFINE_SFX(NA_SE_EV_BUYOSTAND_FALL, 0x30, 3, 0, 0, 0) +/* 0x2891 */ DEFINE_SFX(NA_SE_EV_MILK_POT_BROKEN, 0x80, 0, 0, 0, 0) +/* 0x2892 */ DEFINE_SFX(NA_SE_EV_CHAIR_ROLL, 0x30, 0, 0, 0, SFX_FLAG_VOLUME_NO_DIST) +/* 0x2893 */ DEFINE_SFX(NA_SE_EV_STONEDOOR_STOP, 0x30, 3, 0, 0, 0) +/* 0x2894 */ DEFINE_SFX(NA_SE_EV_S_STONE_REVIVAL, 0x30, 0, 0, 0, 0) +/* 0x2895 */ DEFINE_SFX(NA_SE_EV_WATER_TANK, 0x30, 0, 0, 0, 0) +/* 0x2896 */ DEFINE_SFX(NA_SE_EV_HUMAN_BOUND, 0x30, 0, 2, 0, 0) +/* 0x2897 */ DEFINE_SFX(NA_SE_EV_TOILET_WATER, 0x30, 0, 0, 0, 0) +/* 0x2898 */ DEFINE_SFX(NA_SE_EV_EARTHQUAKE, 0x30, 0, 0, 0, 0) +/* 0x2899 */ DEFINE_SFX(NA_SE_EV_SWEEP, 0x30, 0, 0, 0, 0) +/* 0x289A */ DEFINE_SFX(NA_SE_EV_GOD_LIGHTBALL_2, 0x30, 0, 0, 0, 0) +/* 0x289B */ DEFINE_SFX(NA_SE_EV_RUN_AROUND, 0x30, 0, 0, 0, 0) +/* 0x289C */ DEFINE_SFX(NA_SE_EV_CONSENTRATION, 0x30, 0, 0, 0, SFX_PARAM_RAND_FREQ_SCALE) +/* 0x289D */ DEFINE_SFX(NA_SE_EV_TIMETRIP_LIGHT, 0x30, 0, 0, 0, SFX_PARAM_RAND_FREQ_SCALE) +/* 0x289E */ DEFINE_SFX(NA_SE_EV_DOOR_BELL, 0x30, 2, 0, 0, 0) +/* 0x289F */ DEFINE_SFX(NA_SE_EV_BOUND_ON_MAGMA, 0x30, 3, 0, 0, 0) +/* 0x28A0 */ DEFINE_SFX(NA_SE_EV_HONEYCOMB_FALL, 0x30, 0, 0, 0, 0) +/* 0x28A1 */ DEFINE_SFX(NA_SE_EV_JUMP_CONC, 0x30, 0, 0, 0, 0) +/* 0x28A2 */ DEFINE_SFX(NA_SE_EV_ICE_MELT, 0x30, 0, 0, 0, 0) +/* 0x28A3 */ DEFINE_SFX(NA_SE_EV_FIRE_PILLAR_S, 0x30, 0, 0, 0, 0) +/* 0x28A4 */ DEFINE_SFX(NA_SE_EV_BLOCK_RISING, 0x20, 3, 0, 0, 0) +/* 0x28A5 */ DEFINE_SFX(NA_SE_EV_CHINCLE_SPELL_EFFECT, 0x30, 0, 0, 0, 0) +/* 0x28A6 */ DEFINE_SFX(NA_SE_EV_LINK_WARP_IN, 0x30, 0, 0, 0, SFX_FLAG_FREQ_NO_DIST) +/* 0x28A7 */ DEFINE_SFX(NA_SE_EV_LINK_WARP_OUT, 0x30, 0, 0, 0, 0) +/* 0x28A8 */ DEFINE_SFX(NA_SE_EV_FIATY_HEAL, 0x30, 0, 0, 0, 0) +/* 0x28A9 */ DEFINE_SFX(NA_SE_EV_CHAIN_KEY_UNLOCK_B, 0x30, 0, 0, 0, 0) +/* 0x28AA */ DEFINE_SFX(NA_SE_EV_WOODBOX_BREAK, 0x70, 2, 0, 0, 0) +/* 0x28AB */ DEFINE_SFX(NA_SE_EV_PUT_DOWN_WOODBOX, 0x30, 0, 0, 0, 0) +/* 0x28AC */ DEFINE_SFX(NA_SE_EV_LAND_DIRT, 0x30, 0, 0, 0, 0) +/* 0x28AD */ DEFINE_SFX(NA_SE_EV_FLOOR_ROLLING, 0x30, 0, 0, 0, 0) +/* 0x28AE */ DEFINE_SFX(NA_SE_EV_DOG_CRY_EVENING, 0x50, 0, 0, 0, 0) +/* 0x28AF */ DEFINE_SFX(NA_SE_EV_JABJAB_HICCUP, 0x30, 0, 0, 0, 0) +/* 0x28B0 */ DEFINE_SFX(NA_SE_EV_STICK_SWING, 0x30, 0, 0, 0, 0) +/* 0x28B1 */ DEFINE_SFX(NA_SE_EV_FROG_JUMP, 0x30, 0, 0, 0, 0) +/* 0x28B2 */ DEFINE_SFX(NA_SE_EV_ICE_FREEZE, 0x30, 3, 0, 0, SFX_FLAG_VOLUME_NO_DIST) +/* 0x28B3 */ DEFINE_SFX(NA_SE_EV_BURNING, 0x20, 0, 0, 0, 0) +/* 0x28B4 */ DEFINE_SFX(NA_SE_EV_WOODPLATE_BOUND, 0x30, 0, 3, 0, 0) +/* 0x28B5 */ DEFINE_SFX(NA_SE_EV_MOON_CRY, 0x30, 0, 0, 0, SFX_FLAG_VOLUME_NO_DIST) +/* 0x28B6 */ DEFINE_SFX(NA_SE_EV_JABJAB_GROAN, 0x30, 0, 0, 0, 0) +/* 0x28B7 */ DEFINE_SFX(NA_SE_EV_WAVE_S, 0x30, 2, 0, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x28B8 */ DEFINE_SFX(NA_SE_EV_BIGBALL_ROLL, 0x30, 0, 0, 0, 0) +/* 0x28B9 */ DEFINE_SFX(NA_SE_EV_ELEVATOR_MOVE3, 0x30, 0, 0, 0, 0) +/* 0x28BA */ DEFINE_SFX(NA_SE_EV_DIAMOND_SWITCH, 0x30, 2, 0, 0, 0) +/* 0x28BB */ DEFINE_SFX(NA_SE_EV_FLAME_OF_FIRE, 0x30, 3, 0, 0, 0) +/* 0x28BC */ DEFINE_SFX(NA_SE_EV_FISH_GROW_UP, 0x30, 2, 0, 0, 0) +/* 0x28BD */ DEFINE_SFX(NA_SE_EV_FLYING_AIR, 0x30, 0, 0, 0, 0) +/* 0x28BE */ DEFINE_SFX(NA_SE_EV_PASS_AIR, 0x30, 0, 0, 0, 0) +/* 0x28BF */ DEFINE_SFX(NA_SE_EV_COME_UP_DEKU_JR, 0x30, 0, 0, 0, 0) +/* 0x28C0 */ DEFINE_SFX(NA_SE_EV_SAND_STORM, 0x30, 0, 0, 0, 0) +/* 0x28C1 */ DEFINE_SFX(NA_SE_EV_BOILED_WATER_S, 0x30, 6, 0, 0, 0) +/* 0x28C2 */ DEFINE_SFX(NA_SE_EV_GRAVE_EXPLOSION, 0xA0, 3, 0, 0, 0) +/* 0x28C3 */ DEFINE_SFX(NA_SE_EV_LURE_MOVE_W, 0x30, 0, 0, 0, 0) +/* 0x28C4 */ DEFINE_SFX(NA_SE_EV_POT_MOVE_START, 0x30, 0, 0, 0, 0) +/* 0x28C5 */ DEFINE_SFX(NA_SE_EV_DIVE_INTO_WATER_L, 0x30, 0, 0, 0, 0) +/* 0x28C6 */ DEFINE_SFX(NA_SE_EV_OUT_OF_WATER_L, 0x30, 0, 0, 0, 0) +/* 0x28C7 */ DEFINE_SFX(NA_SE_EV_BOILED_WATER_L, 0x30, 0, 0, 0, 0) +/* 0x28C8 */ DEFINE_SFX(NA_SE_EV_DIG_UP, 0x30, 0, 0, 0, 0) +/* 0x28C9 */ DEFINE_SFX(NA_SE_EV_WOOD_BOUND, 0x30, 0, 0, 0, 0) +/* 0x28CA */ DEFINE_SFX(NA_SE_EV_WATER_BUBBLE, 0x30, 0, 3, 0, 0) +/* 0x28CB */ DEFINE_SFX(NA_SE_EV_ICE_BROKEN, 0x30, 2, 0, 0, 0) +/* 0x28CC */ DEFINE_SFX(NA_SE_EV_FROG_GROW_UP, 0x30, 2, 0, 0, 0) +/* 0x28CD */ DEFINE_SFX(NA_SE_EV_WATER_CONVECTION, 0x30, 0, 0, 0, 0) +/* 0x28CE */ DEFINE_SFX(NA_SE_EV_GROUND_GATE_OPEN, 0x30, 3, 0, 0, 0) +/* 0x28CF */ DEFINE_SFX(NA_SE_EV_FACE_BREAKDOWN, 0x30, 3, 0, 0, 0) +/* 0x28D0 */ DEFINE_SFX(NA_SE_EV_TOILET_HAND_APPEAR, 0x30, 0, 0, 0, 0) +/* 0x28D1 */ DEFINE_SFX(NA_SE_EV_TOILET_HAND_VANISH, 0x30, 3, 2, 0, SFX_PARAM_RAND_FREQ_LOWER) +/* 0x28D2 */ DEFINE_SFX(NA_SE_EV_ROUND_TRAP_MOVE, 0x30, 0, 0, 0, 0) +/* 0x28D3 */ DEFINE_SFX(NA_SE_EV_HIT_SOUND, 0x30, 0, 0, 0, 0) +/* 0x28D4 */ DEFINE_SFX(NA_SE_EV_ICE_SWING, 0x30, 0, 0, 0, 0) +/* 0x28D5 */ DEFINE_SFX(NA_SE_EV_DOWN_TO_GROUND, 0x30, 0, 0, 0, 0) +/* 0x28D6 */ DEFINE_SFX(NA_SE_EV_BIG_TORTOISE_SWIM, 0x60, 3, 2, 0, 0) +/* 0x28D7 */ DEFINE_SFX(NA_SE_EV_TORTOISE_WAKE_UP, 0x80, 0, 0, 0, SFX_FLAG_VOLUME_NO_DIST) +/* 0x28D8 */ DEFINE_SFX(NA_SE_EV_SMALL_DOG_BARK, 0x50, 0, 0, 0, 0) +/* 0x28D9 */ DEFINE_SFX(NA_SE_EV_RUPY_FALL, 0x60, 0, 0, 0, 0) +/* 0x28DA */ DEFINE_SFX(NA_SE_EV_RAIN, 0x90, 0, 0, 0, 0) +/* 0x28DB */ DEFINE_SFX(NA_SE_EV_IRON_DOOR_OPEN, 0x30, 0, 0, 0, 0) +/* 0x28DC */ DEFINE_SFX(NA_SE_EV_IRON_DOOR_CLOSE, 0x30, 0, 0, 0, 0) +/* 0x28DD */ DEFINE_SFX(NA_SE_EV_WHIRLPOOL, 0x30, 0, 0, 0, 0) +/* 0x28DE */ DEFINE_SFX(NA_SE_EV_BIG_TORTOISE_ROLL, 0x60, 0, 0, 0, SFX_FLAG_VOLUME_NO_DIST) +/* 0x28DF */ DEFINE_SFX(NA_SE_EV_COW_CRY, 0x30, 0, 0, 0, 0) +/* 0x28E0 */ DEFINE_SFX(NA_SE_EV_METAL_BOX_BOUND, 0x30, 0, 0, 0, 0) +/* 0x28E1 */ DEFINE_SFX(NA_SE_EV_ELECTRIC_EXPLOSION, 0x30, 3, 0, 0, 0) +/* 0x28E2 */ DEFINE_SFX(NA_SE_EV_HEAVY_THROW, 0x30, 3, 0, 0, 0) +/* 0x28E3 */ DEFINE_SFX(NA_SE_EV_FROG_CRY_0, 0x30, 0, 0, 0, 0) +/* 0x28E4 */ DEFINE_SFX(NA_SE_EV_FROG_CRY_1, 0x30, 0, 0, 0, 0) +/* 0x28E5 */ DEFINE_SFX(NA_SE_EV_COW_CRY_LV, 0x30, 0, 0, 0, 0) +/* 0x28E6 */ DEFINE_SFX(NA_SE_EV_RONRON_DOOR_CLOSE, 0x30, 0, 0, 0, 0) +/* 0x28E7 */ DEFINE_SFX(NA_SE_EV_BUTTERFRY_TO_FAIRY, 0x30, 0, 0, 0, 0) +/* 0x28E8 */ DEFINE_SFX(NA_SE_EV_FIVE_COUNT_LUPY, 0xA0, 0, 0, 0, SFX_PARAM_RAND_FREQ_SCALE) +/* 0x28E9 */ DEFINE_SFX(NA_SE_EV_STONE_GROW_UP, 0x30, 0, 0, 0, 0) +/* 0x28EA */ DEFINE_SFX(NA_SE_EV_STONE_LAUNCH, 0x30, 0, 0, 0, 0) +/* 0x28EB */ DEFINE_SFX(NA_SE_EV_STONE_ROLLING, 0x30, 0, 0, 0, 0) +/* 0x28EC */ DEFINE_SFX(NA_SE_EV_TOGE_STICK_ROLLING, 0x30, 2, 0, 0, 0) +/* 0x28ED */ DEFINE_SFX(NA_SE_EV_TOWER_ENERGY, 0x30, 0, 0, 0, 0) +/* 0x28EE */ DEFINE_SFX(NA_SE_EV_MOON_LIGHT_PILLAR, 0x30, 3, 0, 0, 0) +/* 0x28EF */ DEFINE_SFX(NA_SE_EV_MONKEY_WALK, 0x20, 0, 0, 0, 0) +/* 0x28F0 */ DEFINE_SFX(NA_SE_EV_KNIGHT_WALK, 0x30, 0, 0, 0, 0) +/* 0x28F1 */ DEFINE_SFX(NA_SE_EV_PILLAR_MOVE_STOP, 0x30, 0, 1, 0, 0) +/* 0x28F2 */ DEFINE_SFX(NA_SE_EV_WAVE, 0x30, 2, 0, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x28F3 */ DEFINE_SFX(NA_SE_EV_BIGBELL, 0x30, 2, 0, 0, 0) +/* 0x28F4 */ DEFINE_SFX(NA_SE_EV_NUTS_BROKEN, 0x30, 0, 0, 0, 0) +/* 0x28F5 */ DEFINE_SFX(NA_SE_EV_SNOWBALL_BROKEN, 0x30, 2, 0, 0, 0) +/* 0x28F6 */ DEFINE_SFX(NA_SE_EV_SMALLBALL_ROLL, 0x30, 5, 0, 0, 0) +/* 0x28F7 */ DEFINE_SFX(NA_SE_EV_FLOWERPETAL_MOVE, 0x30, 0, 0, 0, 0) +/* 0x28F8 */ DEFINE_SFX(NA_SE_EV_FLOWERPETAL_STOP, 0x30, 0, 0, 0, 0) +/* 0x28F9 */ DEFINE_SFX(NA_SE_EV_FLOWER_ROLLING, 0x40, 0, 0, 0, 0) +/* 0x28FA */ DEFINE_SFX(NA_SE_EV_GLASSBROKEN_IMPACT, 0x30, 0, 0, 0, 0) +/* 0x28FB */ DEFINE_SFX(NA_SE_EV_GLASSBROKEN_BOUND, 0x30, 0, 0, 0, 0) +/* 0x28FC */ DEFINE_SFX(NA_SE_EV_BIGBALL_ROLL_SR, 0x30, 5, 0, 0, 0) +/* 0x28FD */ DEFINE_SFX(NA_SE_EV_SMALL_SNOWBALL_BROKEN, 0x30, 2, 3, 0, 0) +/* 0x28FE */ DEFINE_SFX(NA_SE_EV_STATUE_VANISH, 0x30, 0, 0, 0, 0) +/* 0x28FF */ DEFINE_SFX(NA_SE_EV_BIGBALL_BOUND, 0x30, 0, 0, 0, 0) +/* 0x2900 */ DEFINE_SFX(NA_SE_EV_MONKEY_VO_WALK, 0x30, 0, 2, 0, 0) +/* 0x2901 */ DEFINE_SFX(NA_SE_EV_MONKEY_VO_JOY, 0x30, 0, 2, 0, 0) +/* 0x2902 */ DEFINE_SFX(NA_SE_EV_WALK_WATER, 0x30, 0, 0, 0, 0) +/* 0x2903 */ DEFINE_SFX(NA_SE_EV_PLATE_LIFT_LEVEL, 0x30, 2, 0, 0, 0) +/* 0x2904 */ DEFINE_SFX(NA_SE_EV_BIGBALL_ROLL_2, 0x30, 0, 0, 0, 0) +/* 0x2905 */ DEFINE_SFX(NA_SE_EV_BIGBALL_ROLL_SR_2, 0x30, 0, 0, 0, 0) +/* 0x2906 */ DEFINE_SFX(NA_SE_EV_BIGBALL_ROLL_3, 0x30, 0, 0, 0, 0) +/* 0x2907 */ DEFINE_SFX(NA_SE_EV_BIGBALL_ROLL_SR_3, 0x30, 0, 0, 0, 0) +/* 0x2908 */ DEFINE_SFX(NA_SE_EV_BEAVER_SWIM_MOTOR, 0x68, 2, 0, 0, 0) +/* 0x2909 */ DEFINE_SFX(NA_SE_EV_BEAVER_SWIM_HAND, 0x30, 2, 0, 0, 0) +/* 0x290A */ DEFINE_SFX(NA_SE_EV_SMALL_DOG_CRY, 0x30, 0, 1, 0, SFX_PARAM_RAND_FREQ_LOWER) +/* 0x290B */ DEFINE_SFX(NA_SE_EV_SMALL_DOG_GROAN, 0x30, 0, 0, 0, 0) +/* 0x290C */ DEFINE_SFX(NA_SE_EV_SMALL_DOG_ATK_BARK, 0x30, 0, 0, 0, 0) +/* 0x290D */ DEFINE_SFX(NA_SE_EV_ICE_PILLAR_RISING, 0x30, 2, 0, 0, 0) +/* 0x290E */ DEFINE_SFX(NA_SE_EV_ICE_PILLAR_FALL, 0x30, 2, 0, 0, 0) +/* 0x290F */ DEFINE_SFX(NA_SE_EV_GORON_CHEER, 0x30, 3, 0, 0, 0) +/* 0x2910 */ DEFINE_SFX(NA_SE_EV_SMALL_DOG_ANG_BARK, 0x30, 0, 0, 0, 0) +/* 0x2911 */ DEFINE_SFX(NA_SE_EV_COMICAL_JUMP, 0x30, 0, 0, 0, 0) +/* 0x2912 */ DEFINE_SFX(NA_SE_EV_LIGHTNING_HARD, 0x30, 0, 0, 0, 0) +/* 0x2913 */ DEFINE_SFX(NA_SE_EV_SMALL_DOG_WHINE, 0x30, 0, 3, 0, 0) +/* 0x2914 */ DEFINE_SFX(NA_SE_EV_PANIC_IN_HOUSE, 0x80, 0, 0, 0, 0) +/* 0x2915 */ DEFINE_SFX(NA_SE_EV_CLOCK_TOWER_BELL, 0x30, 0, 0, 0, 0) +/* 0x2916 */ DEFINE_SFX(NA_SE_EV_CLOCK_TOWER_SECOND_HAND, 0x30, 2, 0, 0, 0) +/* 0x2917 */ DEFINE_SFX(NA_SE_EV_SIGNAL_BIGBELL, 0xA0, 3, 0, 0, SFX_FLAG_FREQ_NO_DIST | SFX_FLAG_VOLUME_NO_DIST) +/* 0x2918 */ DEFINE_SFX(NA_SE_EV_DUMMY_280, 0x30, 0, 0, 0, 0) +/* 0x2919 */ DEFINE_SFX(NA_SE_EV_BEAVER_VOICE_0, 0x30, 0, 0, 0, 0) +/* 0x291A */ DEFINE_SFX(NA_SE_EV_BEAVER_VOICE_1, 0x30, 0, 0, 0, 0) +/* 0x291B */ DEFINE_SFX(NA_SE_EV_WATERWHEEL_LEVEL, 0x30, 0, 2, 0, 0) +/* 0x291C */ DEFINE_SFX(NA_SE_EV_WOOD_GATE_OPEN_N, 0x30, 0, 0, 0, 0) +/* 0x291D */ DEFINE_SFX(NA_SE_EV_INVISIBLE_MONKEY, 0x30, 5, 2, 0, 0) +/* 0x291E */ DEFINE_SFX(NA_SE_EV_CRUISER, 0x30, 0, 1, 0, 0) +/* 0x291F */ DEFINE_SFX(NA_SE_EV_SECRET_CHEER, 0x30, 0, 0, 0, 0) +/* 0x2920 */ DEFINE_SFX(NA_SE_EV_BOTTLE_WATERING, 0x30, 0, 0, 0, 0) +/* 0x2921 */ DEFINE_SFX(NA_SE_EV_MONKEY_VO_SADNESS, 0x30, 0, 0, 0, 0) +/* 0x2922 */ DEFINE_SFX(NA_SE_EV_SNOWSTORM_HARD, 0x60, 0, 0, 0, SFX_FLAG_VOLUME_NO_DIST) +/* 0x2923 */ DEFINE_SFX(NA_SE_EV_UNSKILLFUL_OCARINA, 0x30, 0, 0, 0, 0) +/* 0x2924 */ DEFINE_SFX(NA_SE_EV_BLACK_FAIRY_DASH, 0x30, 0, 1, 0, 0) +/* 0x2925 */ DEFINE_SFX(NA_SE_EV_FAIRY_SURPRISE, 0x30, 0, 0, 0, 0) +/* 0x2926 */ DEFINE_SFX(NA_SE_EV_MONDO_SURPRISE, 0x30, 0, 0, 0, 0) +/* 0x2927 */ DEFINE_SFX(NA_SE_EV_SPOT_LIGHT_OPEN, 0x30, 0, 0, 0, SFX_FLAG_VOLUME_NO_DIST) +/* 0x2928 */ DEFINE_SFX(NA_SE_EV_HOUSE_BROKEN, 0x30, 2, 0, 0, 0) +/* 0x2929 */ DEFINE_SFX(NA_SE_EV_MOON_FALL, 0x30, 3, 0, 0, 0) +/* 0x292A */ DEFINE_SFX(NA_SE_EV_OCARINA_BOUND_0, 0x30, 0, 0, 0, 0) +/* 0x292B */ DEFINE_SFX(NA_SE_EV_OCARINA_BOUND_1, 0x30, 0, 1, 0, 0) +/* 0x292C */ DEFINE_SFX(NA_SE_EV_BOMBERS_WALK, 0x30, 0, 1, 0, 0) +/* 0x292D */ DEFINE_SFX(NA_SE_EV_BOMBERS_LAND, 0x30, 0, 2, 0, 0) +/* 0x292E */ DEFINE_SFX(NA_SE_EV_BOMBERS_SHOT_BREATH, 0x30, 0, 0, 0, 0) +/* 0x292F */ DEFINE_SFX(NA_SE_EV_BOMBERS_SHOT_EXPLOSUIN, 0x30, 0, 0, 0, 0) +/* 0x2930 */ DEFINE_SFX(NA_SE_EV_BOMBERS_JUMP, 0x30, 0, 0, 0, 0) +/* 0x2931 */ DEFINE_SFX(NA_SE_EV_SOLDIER_WALK, 0x30, 0, 3, 0, 0) +/* 0x2932 */ DEFINE_SFX(NA_SE_EV_ROCK_CUBE_RISING, 0x30, 0, 0, 0, 0) +/* 0x2933 */ DEFINE_SFX(NA_SE_EV_ROCK_CUBE_FALL, 0x30, 0, 0, 0, 0) +/* 0x2934 */ DEFINE_SFX(NA_SE_EV_BELL_SPIT, 0x30, 0, 0, 0, 0) +/* 0x2935 */ DEFINE_SFX(NA_SE_EV_BELL_SIGH, 0x30, 0, 0, 0, 0) +/* 0x2936 */ DEFINE_SFX(NA_SE_EV_BELL_BRAKE, 0x30, 0, 0, 0, 0) +/* 0x2937 */ DEFINE_SFX(NA_SE_EV_DOG_SWIM, 0x30, 0, 0, 0, 0) +/* 0x2938 */ DEFINE_SFX(NA_SE_EV_CHIBI_FAIRY_HEAL_ORG, 0x80, 0, 0, 0, 0) +/* 0x2939 */ DEFINE_SFX(NA_SE_EV_BOMBERS_CLIMB, 0x30, 0, 0, 0, 0) +/* 0x293A */ DEFINE_SFX(NA_SE_EV_WOODPLATE_BROKEN, 0x30, 3, 1, 0, 0) +/* 0x293B */ DEFINE_SFX(NA_SE_EV_WATER_LEVEL_DOWN_FIX, 0x30, 0, 0, 0, SFX_FLAG_VOLUME_NO_DIST) +/* 0x293C */ DEFINE_SFX(NA_SE_EV_HONEYCOMB_BROKEN, 0x30, 0, 0, 0, 0) +/* 0x293D */ DEFINE_SFX(NA_SE_EV_CLOCK_TOWER_UP, 0x30, 3, 0, 0, 0) +/* 0x293E */ DEFINE_SFX(NA_SE_EV_CLOCK_TOWER_STOP, 0x30, 3, 0, 0, 0) +/* 0x293F */ DEFINE_SFX(NA_SE_EV_CLOCK_TOWER_FALL, 0x30, 3, 0, 0, 0) +/* 0x2940 */ DEFINE_SFX(NA_SE_EV_CLOCK_TOWER_BOUND_0, 0x30, 3, 0, 0, 0) +/* 0x2941 */ DEFINE_SFX(NA_SE_EV_CLOCK_TOWER_BOUND_1, 0x30, 3, 0, 0, 0) +/* 0x2942 */ DEFINE_SFX(NA_SE_EV_CLOCK_TOWER_BOUND_2, 0x30, 3, 0, 0, 0) +/* 0x2943 */ DEFINE_SFX(NA_SE_EV_STONEDOOR_OPEN_S, 0x30, 0, 0, 0, 0) +/* 0x2944 */ DEFINE_SFX(NA_SE_EV_ICE_MELT_LEVEL, 0x30, 0, 0, 0, 0) +/* 0x2945 */ DEFINE_SFX(NA_SE_EV_CLOCK_TOWER_STAIR_MOVE, 0x30, 3, 0, 0, 0) +/* 0x2946 */ DEFINE_SFX(NA_SE_EV_DUMMY_326, 0xA0, 0, 0, 0, SFX_PARAM_RAND_FREQ_LOWER) +/* 0x2947 */ DEFINE_SFX(NA_SE_EV_OBJECT_STICK, 0x30, 3, 1, 0, 0) +/* 0x2948 */ DEFINE_SFX(NA_SE_EV_CHICK_TO_CHICKEN, 0x30, 0, 1, 0, 0) +/* 0x2949 */ DEFINE_SFX(NA_SE_EV_MUJURA_BALLOON_BROKEN, 0x60, 2, 0, 0, 0) +/* 0x294A */ DEFINE_SFX(NA_SE_EV_BALLOON_SWELL, 0x30, 0, 0, 0, 0) +/* 0x294B */ DEFINE_SFX(NA_SE_EV_SEAHORSE_OUT_BOTTLE, 0x30, 0, 0, 0, 0) +/* 0x294C */ DEFINE_SFX(NA_SE_EV_KYOJIN_VOICE_SUCCESS, 0x30, 0, 2, 0, SFX_FLAG_VOLUME_NO_DIST) +/* 0x294D */ DEFINE_SFX(NA_SE_EV_KYOJIN_VOICE_FAIL, 0x30, 0, 2, 0, SFX_FLAG_VOLUME_NO_DIST) +/* 0x294E */ DEFINE_SFX(NA_SE_EV_KYOJIN_WALK, 0x30, 0, 0, 0, SFX_FLAG_VOLUME_NO_DIST) +/* 0x294F */ DEFINE_SFX(NA_SE_EV_MOON_FALL_LAST, 0x30, 0, 0, 0, 0) +/* 0x2950 */ DEFINE_SFX(NA_SE_EV_EARTHQUAKE_LAST, 0x30, 0, 0, 0, SFX_FLAG_VOLUME_NO_DIST) +/* 0x2951 */ DEFINE_SFX(NA_SE_EV_SEAHORSE_SWIM, 0x30, 0, 0, 0, 0) +/* 0x2952 */ DEFINE_SFX(NA_SE_EV_OPEN_AMBRELLA, 0x30, 0, 0, 0, 0) +/* 0x2953 */ DEFINE_SFX(NA_SE_EV_BUTLER_FRY, 0x60, 0, 0, 0, 0) +/* 0x2954 */ DEFINE_SFX(NA_SE_EV_PIRATE_SHIP, 0x30, 2, 0, 0, 0) +/* 0x2955 */ DEFINE_SFX(NA_SE_EV_DRAIN, 0x30, 0, 0, 0, 0) +/* 0x2956 */ DEFINE_SFX(NA_SE_EV_DORA_L, 0x30, 2, 0, 0, 0) +/* 0x2957 */ DEFINE_SFX(NA_SE_EV_LOG_BOUND, 0x30, 0, 2, 0, 0) +/* 0x2958 */ DEFINE_SFX(NA_SE_EV_CART_WHEEL, 0x60, 2, 1, 0, 0) +/* 0x2959 */ DEFINE_SFX(NA_SE_EV_EARTHQUAKE_LAST2, 0x30, 0, 0, 0, SFX_FLAG_VOLUME_NO_DIST) +/* 0x295A */ DEFINE_SFX(NA_SE_EV_DORA_S, 0x30, 0, 0, 0, 0) +/* 0x295B */ DEFINE_SFX(NA_SE_EV_ROCK_FALL, 0x30, 0, 0, 0, 0) +/* 0x295C */ DEFINE_SFX(NA_SE_EV_FREEZE_S, 0x30, 0, 0, 0, 0) +/* 0x295D */ DEFINE_SFX(NA_SE_EV_WOOD_BOUND_S, 0x30, 0, 0, 0, 0) +/* 0x295E */ DEFINE_SFX(NA_SE_EV_CLOSE_AMBRELLA, 0x30, 0, 0, 0, 0) +/* 0x295F */ DEFINE_SFX(NA_SE_EV_OBJECT_SLIDE, 0x30, 0, 0, 0, 0) +/* 0x2960 */ DEFINE_SFX(NA_SE_EV_ROLL_AND_FALL, 0x30, 0, 0, 0, SFX_FLAG_VOLUME_NO_DIST) +/* 0x2961 */ DEFINE_SFX(NA_SE_EV_GORON_BOUND_0, 0x30, 0, 0, 0, SFX_FLAG_VOLUME_NO_DIST) +/* 0x2962 */ DEFINE_SFX(NA_SE_EV_GORON_BOUND_1, 0x30, 0, 0, 0, SFX_FLAG_VOLUME_NO_DIST) +/* 0x2963 */ DEFINE_SFX(NA_SE_EV_MONKEY_VO_DAMAGE, 0x30, 0, 0, 0, 0) +/* 0x2964 */ DEFINE_SFX(NA_SE_EV_FORT_RISING, 0x30, 0, 0, 0, SFX_FLAG_VOLUME_NO_DIST) +/* 0x2965 */ DEFINE_SFX(NA_SE_EV_MONKEY_VO_REWARD, 0x30, 0, 0, 0, 0) +/* 0x2966 */ DEFINE_SFX(NA_SE_EV_WATER_PURIFICATION, 0x30, 0, 0, 0, SFX_FLAG_VOLUME_NO_DIST) +/* 0x2967 */ DEFINE_SFX(NA_SE_EV_OWL_WARP_SWITCH_ON, 0x80, 0, 0, 0, 0) +/* 0x2968 */ DEFINE_SFX(NA_SE_EV_BIG_WATER_WHEEL_RR, 0x80, 3, 0, 0, 0) +/* 0x2969 */ DEFINE_SFX(NA_SE_EV_BIG_WATER_WHEEL_LR, 0x80, 3, 0, 0, 0) +/* 0x296A */ DEFINE_SFX(NA_SE_EV_SMALL_WATER_WHEEL, 0x30, 3, 0, 0, 0) +/* 0x296B */ DEFINE_SFX(NA_SE_EV_COCK_SWITCH_ROLL, 0x80, 2, 0, 0, 0) +/* 0x296C */ DEFINE_SFX(NA_SE_EV_COCK_SWITCH_STOP, 0x80, 2, 0, 0, 0) +/* 0x296D */ DEFINE_SFX(NA_SE_EV_PIPE_STREAM_START, 0x30, 0, 0, 0, 0) +/* 0x296E */ DEFINE_SFX(NA_SE_EV_WATER_PILLAR, 0x60, 0, 0, 0, 0) +/* 0x296F */ DEFINE_SFX(NA_SE_EV_SEESAW_INCLINE, 0x30, 0, 0, 0, 0) +/* 0x2970 */ DEFINE_SFX(NA_SE_EV_ZORA_WALK, 0x30, 2, 1, 0, 0) +/* 0x2971 */ DEFINE_SFX(NA_SE_EV_PIRATE_WALK, 0x30, 2, 1, 0, 0) +/* 0x2972 */ DEFINE_SFX(NA_SE_EV_PILLAR_UP_FAST, 0x30, 3, 1, 0, 0) +/* 0x2973 */ DEFINE_SFX(NA_SE_EV_DUMMY_WATER_WHEEL_RR, 0x60, 0, 0, SFX_FLAG2_APPLY_LOWPASS_FILTER, SFX_FLAG_VOLUME_NO_DIST) +/* 0x2974 */ DEFINE_SFX(NA_SE_EV_DUMMY_WATER_WHEEL_LR, 0x60, 0, 0, SFX_FLAG2_APPLY_LOWPASS_FILTER, SFX_FLAG_VOLUME_NO_DIST) +/* 0x2975 */ DEFINE_SFX(NA_SE_EV_MUJURA_FOLLOWERS_FLY, 0x30, 0, 0, 0, 0) +/* 0x2976 */ DEFINE_SFX(NA_SE_EV_MAKE_TURRET, 0x30, 0, 0, 0, 0) +/* 0x2977 */ DEFINE_SFX(NA_SE_EV_CHANDELIER_ROLL, 0x30, 3, 0, 0, 0) +/* 0x2978 */ DEFINE_SFX(NA_SE_EV_CHANDELIER_BROKEN, 0x30, 0, 0, 0, 0) +/* 0x2979 */ DEFINE_SFX(NA_SE_EV_SINK_WOOD_FLOOR, 0x30, 0, 0, 0, 0) +/* 0x297A */ DEFINE_SFX(NA_SE_EV_REBOUND_WOOD_FLOOR, 0x30, 0, 0, 0, 0) +/* 0x297B */ DEFINE_SFX(NA_SE_EV_UFO_APPEAR, 0x30, 3, 0, 0, 0) +/* 0x297C */ DEFINE_SFX(NA_SE_EV_UFO_DASH, 0x30, 0, 0, 0, SFX_FLAG_VOLUME_NO_DIST) +/* 0x297D */ DEFINE_SFX(NA_SE_EV_TORNADE, 0x80, 0, 0, 0, SFX_FLAG_VOLUME_NO_DIST) +/* 0x297E */ DEFINE_SFX(NA_SE_EV_MILK_POT_DAMAGE, 0x80, 3, 0, 0, 0) +/* 0x297F */ DEFINE_SFX(NA_SE_EV_DUMMY_383, 0x30, 0, 0, 0, 0) +/* 0x2980 */ DEFINE_SFX(NA_SE_EV_KYOJIN_SIGN, 0x30, 0, 0, 0, SFX_FLAG_VOLUME_NO_DIST) +/* 0x2981 */ DEFINE_SFX(NA_SE_EV_KYOJIN_GRATITUDE0, 0x30, 0, 0, 0, SFX_FLAG_VOLUME_NO_DIST) +/* 0x2982 */ DEFINE_SFX(NA_SE_EV_KYOJIN_GRATITUDE1, 0x30, 0, 0, 0, SFX_FLAG_VOLUME_NO_DIST) +/* 0x2983 */ DEFINE_SFX(NA_SE_EV_KYOJIN_GRATITUDE2, 0x30, 0, 0, 0, SFX_FLAG_VOLUME_NO_DIST) +/* 0x2984 */ DEFINE_SFX(NA_SE_EV_IKANA_DOOR_OPEN, 0x30, 0, 0, 0, 0) +/* 0x2985 */ DEFINE_SFX(NA_SE_EV_IKANA_DOOR_CLOSE, 0x30, 0, 0, 0, 0) +/* 0x2986 */ DEFINE_SFX(NA_SE_EV_MOONSTONE_FALL, 0x80, 3, 0, 0, 0) +/* 0x2987 */ DEFINE_SFX(NA_SE_EV_COMING_FIRE, 0x30, 0, 0, 0, SFX_FLAG_VOLUME_NO_DIST) +/* 0x2988 */ DEFINE_SFX(NA_SE_EV_FAIRY_GROUP_FRY, 0x30, 0, 0, 0, 0) +/* 0x2989 */ DEFINE_SFX(NA_SE_EV_FAIRY_GROUP_HEAL, 0x30, 0, 0, 0, 0) +/* 0x298A */ DEFINE_SFX(NA_SE_EV_WOOD_DOOR_OPEN_SPEEDY, 0x30, 0, 0, 0, 0) +/* 0x298B */ DEFINE_SFX(NA_SE_EV_PAMERA_WALK, 0x30, 0, 0, 0, 0) +/* 0x298C */ DEFINE_SFX(NA_SE_EV_G_STONE_CHANGE_COLOR, 0x30, 0, 0, 0, 0) +/* 0x298D */ DEFINE_SFX(NA_SE_EV_CURTAIN_DOWN, 0x30, 0, 0, 0, 0) +/* 0x298E */ DEFINE_SFX(NA_SE_EV_GORON_HAND_HIT, 0x30, 3, 0, 0, 0) +/* 0x298F */ DEFINE_SFX(NA_SE_EV_SMALL_WOODPLATE_BOUND_0, 0x30, 3, 1, 0, 0) +/* 0x2990 */ DEFINE_SFX(NA_SE_EV_GET_UP_ON_BED, 0x30, 3, 0, 0, 0) +/* 0x2991 */ DEFINE_SFX(NA_SE_EV_LIE_DOWN_ON_BED, 0x30, 3, 0, 0, 0) +/* 0x2992 */ DEFINE_SFX(NA_SE_EV_BANK_MAN_HAND_HIT, 0x30, 0, 0, 0, 0) +/* 0x2993 */ DEFINE_SFX(NA_SE_EV_HANKO, 0x30, 0, 0, 0, SFX_FLAG_VOLUME_NO_DIST) +/* 0x2994 */ DEFINE_SFX(NA_SE_EV_CHICK_SONG, 0x10, 7, 0, 0, 0) +/* 0x2995 */ DEFINE_SFX(NA_SE_EV_LAND_SAND, 0x30, 0, 0, 0, 0) +/* 0x2996 */ DEFINE_SFX(NA_SE_EV_JUMP_SAND, 0x30, 0, 0, 0, 0) +/* 0x2997 */ DEFINE_SFX(NA_SE_EV_SECRET_LADDER_APPEAR, 0x30, 0, 0, 0, 0) +/* 0x2998 */ DEFINE_SFX(NA_SE_EV_CLAPPING_2P, 0x30, 0, 0, 0, 0) +/* 0x2999 */ DEFINE_SFX(NA_SE_EV_DIVE_INTO_WEED, 0x30, 0, 0, 0, 0) +/* 0x299A */ DEFINE_SFX(NA_SE_EV_FAIRY_SHIVER, 0x30, 0, 0, 0, 0) +/* 0x299B */ DEFINE_SFX(NA_SE_EV_MASK_RISING, 0x30, 0, 0, 0, 0) +/* 0x299C */ DEFINE_SFX(NA_SE_EV_MOON_EYE_FLASH, 0x30, 0, 0, 0, SFX_FLAG_VOLUME_NO_DIST) +/* 0x299D */ DEFINE_SFX(NA_SE_EV_SLIP_MOON, 0x30, 0, 0, 0, SFX_FLAG_VOLUME_NO_DIST) +/* 0x299E */ DEFINE_SFX(NA_SE_EV_FALL_POWER, 0x30, 0, 0, 0, SFX_FLAG_VOLUME_NO_DIST) +/* 0x299F */ DEFINE_SFX(NA_SE_EV_BELL_DASH_NORMAL, 0x58, 0, 1, 0, SFX_FLAG_BLOCK_EQUAL_IMPORTANCE) +/* 0x29A0 */ DEFINE_SFX(NA_SE_EV_IKANA_BLOCK_MOVE_X, 0x60, 3, 0, 0, 0) +/* 0x29A1 */ DEFINE_SFX(NA_SE_EV_IKANA_BLOCK_MOVE_Z, 0x60, 3, 0, 0, 0) +/* 0x29A2 */ DEFINE_SFX(NA_SE_EV_IKANA_BLOCK_MOVE_Y, 0x60, 3, 0, 0, 0) +/* 0x29A3 */ DEFINE_SFX(NA_SE_EV_IKANA_BLOCK_STOP_C, 0x70, 3, 0, 0, 0) +/* 0x29A4 */ DEFINE_SFX(NA_SE_EV_IKANA_BLOCK_STOP_F, 0x70, 3, 0, 0, 0) +/* 0x29A5 */ DEFINE_SFX(NA_SE_EV_BELL_ANGER, 0x30, 0, 0, 0, 0) +/* 0x29A6 */ DEFINE_SFX(NA_SE_EV_IKANA_BLOCK_SWITCH, 0x70, 3, 0, 0, 0) +/* 0x29A7 */ DEFINE_SFX(NA_SE_EV_BAT_FLY, 0x30, 4, 0, 0, 0) +/* 0x29A8 */ DEFINE_SFX(NA_SE_EV_UFO_LIGHT_BEAM, 0x30, 3, 0, 0, 0) +/* 0x29A9 */ DEFINE_SFX(NA_SE_EV_DOOR_UNLOCK, 0x30, 0, 0, 0, 0) +/* 0x29AA */ DEFINE_SFX(NA_SE_EV_WOOD_WATER_WHEEL, 0x30, 0, 0, 0, 0) +/* 0x29AB */ DEFINE_SFX(NA_SE_EV_CONVEYOR_SHUTTER_OPEN, 0x60, 0, 0, 0, 0) +/* 0x29AC */ DEFINE_SFX(NA_SE_EV_CONVEYOR_SHUTTER_CLOSE, 0x60, 0, 0, 0, 0) +/* 0x29AD */ DEFINE_SFX(NA_SE_EV_ROOM_CARTAIN, 0x30, 0, 0, 0, 0) +/* 0x29AE */ DEFINE_SFX(NA_SE_EV_ZORA_KIDS_BORN, 0x30, 0, 0, SFX_FLAG2_APPLY_LOWPASS_FILTER, 0) +/* 0x29AF */ DEFINE_SFX(NA_SE_EV_ZORA_KIDS_SWIM_0, 0x30, 0, 1, SFX_FLAG2_APPLY_LOWPASS_FILTER, 0) +/* 0x29B0 */ DEFINE_SFX(NA_SE_EV_ZORA_KIDS_SWIM_1, 0x30, 0, 1, SFX_FLAG2_APPLY_LOWPASS_FILTER, 0) +/* 0x29B1 */ DEFINE_SFX(NA_SE_EV_MOON_EXPLOSION, 0x60, 0, 0, 0, SFX_FLAG_VOLUME_NO_DIST) +/* 0x29B2 */ DEFINE_SFX(NA_SE_EV_RAINBOW, 0x70, 0, 0, 0, SFX_FLAG_VOLUME_NO_DIST) +/* 0x29B3 */ DEFINE_SFX(NA_SE_EV_OMENYA_WALK, 0x30, 0, 2, 0, 0) +/* 0x29B4 */ DEFINE_SFX(NA_SE_EV_KYOJIN_GROAN, 0x30, 0, 0, 0, SFX_FLAG_VOLUME_NO_DIST) +/* 0x29B5 */ DEFINE_SFX(NA_SE_EV_UFO_FLY, 0x30, 3, 0, 0, 0) +/* 0x29B6 */ DEFINE_SFX(NA_SE_EV_GRASS_WALL_BROKEN, 0x30, 0, 0, 0, 0) +/* 0x29B7 */ DEFINE_SFX(NA_SE_EV_WARP_HOLE_ENERGY, 0x60, 3, 0, 0, 0) +/* 0x29B8 */ DEFINE_SFX(NA_SE_EV_BOSS_WARP_HOLE, 0x70, 0, 0, 0, 0) +/* 0x29B9 */ DEFINE_SFX(NA_SE_EV_FIREWORKS_LAUNCH, 0x30, 0, 0, 0, 0) +/* 0x29BA */ DEFINE_SFX(NA_SE_EV_IKANA_SOUL_LV, 0x30, 0, 0, 0, 0) +/* 0x29BB */ DEFINE_SFX(NA_SE_EV_IKANA_PURIFICATION, 0x30, 0, 0, 0, 0) +/* 0x29BC */ DEFINE_SFX(NA_SE_EV_ZORA_KIDS_SWIM_2, 0x30, 0, 0, 0, 0) +/* 0x29BD */ DEFINE_SFX(NA_SE_EV_DARUMA_VANISH, 0x30, 0, 0, 0, 0) +/* 0x29BE */ DEFINE_SFX(NA_SE_EV_IKANA_SOUL_TRANSFORM, 0x30, 0, 0, 0, 0) +/* 0x29BF */ DEFINE_SFX(NA_SE_EV_ROMANI_BOW_FLICK, 0x40, 0, 0, 0, 0) +/* 0x29C0 */ DEFINE_SFX(NA_SE_EV_WHITE_FAIRY_SHOT_DASH, 0x58, 0, 1, 0, 0) +/* 0x29C1 */ DEFINE_SFX(NA_SE_EV_BLACK_FAIRY_SHOT_DASH, 0x58, 0, 1, 0, 0) +/* 0x29C2 */ DEFINE_SFX(NA_SE_EV_SWORD_FORGE, 0x30, 0, 1, 0, 0) +/* 0x29C3 */ DEFINE_SFX(NA_SE_EV_STONEDOOR_CLOSE_S, 0x30, 1, 1, 0, 0) +/* 0x29C4 */ DEFINE_SFX(NA_SE_EV_BOTTLE_CAP_CLOSE, 0x30, 0, 0, 0, 0) +/* 0x29C5 */ DEFINE_SFX(NA_SE_EV_PAMET_ROCK_CRASH, 0x30, 0, 0, 0, 0) +/* 0x29C6 */ DEFINE_SFX(NA_SE_EV_GUILLOTINE_UP, 0x30, 0, 0, 0, 0) +/* 0x29C7 */ DEFINE_SFX(NA_SE_EV_ROCK_BROKEN2, 0x30, 0, 0, 0, 0) +/* 0x29C8 */ DEFINE_SFX(NA_SE_EV_OBJECT_STICK2, 0x30, 0, 0, 0, 0) +/* 0x29C9 */ DEFINE_SFX(NA_SE_EV_WOODBOX_BOUND2, 0x30, 0, 0, 0, 0) +/* 0x29CA */ DEFINE_SFX(NA_SE_EV_DEMO_KID_ATOZUSARI, 0x30, 0, 0, 0, 0) +/* 0x29CB */ DEFINE_SFX(NA_SE_EV_UNDER_WATER, 0x30, 0, 0, 0, 0) +/* 0x29CC */ DEFINE_SFX(NA_SE_EV_FREEZE2, 0x30, 0, 0, 0, 0) +/* 0x29CD */ DEFINE_SFX(NA_SE_EV_DEMO_KID_SAGURU, 0x30, 0, 0, 0, 0) +/* 0x29CE */ DEFINE_SFX(NA_SE_EV_WATER_WALL3, 0x30, 0, 0, 0, 0) +/* 0x29CF */ DEFINE_SFX(NA_SE_EV_BOMBERS_TAORE, 0x30, 0, 0, 0, 0) diff --git a/include/tables/sfx/itembank_table.h b/include/tables/sfx/itembank_table.h new file mode 100644 index 000000000..f8b25aaa0 --- /dev/null +++ b/include/tables/sfx/itembank_table.h @@ -0,0 +1,125 @@ +/** + * Sfx Item Bank + * + * DEFINE_SFX should be used for all sfx define in the item bank from sequence 0 + * - Argument 0: Enum value for this sfx + * - Argument 1: Importance for deciding which sfx to prioritize. Higher values have greater importance + * - Argument 2: Slows the decay of volume with distance (a 3-bit number ranging from 0-7) + * - Argument 3: Applies increasingly random offsets to frequency (a 2-bit number ranging from 0-3) + * - Argument 4: Various flags to add properties to the sfx + * - Argument 5: Various flags to add properties to the sfx + * + * WARNING: entries must align with the table defined for the item bank in sequence 0 + */ +/* 0x1800 */ DEFINE_SFX(NA_SE_IT_SWORD_IMPACT, 0x30, 0, 1, 0, SFX_FLAG_FREQ_NO_DIST) +/* 0x1801 */ DEFINE_SFX(NA_SE_IT_SWORD_SWING, 0x30, 0, 1, 0, 0) +/* 0x1802 */ DEFINE_SFX(NA_SE_IT_SWORD_PUTAWAY, 0x30, 0, 0, 0, 0) +/* 0x1803 */ DEFINE_SFX(NA_SE_IT_SWORD_PICKOUT, 0x30, 0, 0, 0, 0) +/* 0x1804 */ DEFINE_SFX(NA_SE_IT_ARROW_SHOT, 0x40, 0, 1, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x1805 */ DEFINE_SFX(NA_SE_IT_BOOMERANG_THROW, 0x30, 0, 1, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x1806 */ DEFINE_SFX(NA_SE_IT_SHIELD_BOUND, 0x60, 3, 2, 0, 0) +/* 0x1807 */ DEFINE_SFX(NA_SE_IT_BOW_DRAW, 0x30, 0, 1, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x1808 */ DEFINE_SFX(NA_SE_IT_SHIELD_REFLECT_SW, 0x80, 3, 1, 0, 0) +/* 0x1809 */ DEFINE_SFX(NA_SE_IT_ARROW_STICK_HRAD, 0x30, 0, 0, 0, 0) +/* 0x180A */ DEFINE_SFX(NA_SE_IT_HAMMER_HIT, 0x30, 0, 1, 0, 0) +/* 0x180B */ DEFINE_SFX(NA_SE_IT_HOOKSHOT_CHAIN, 0x38, 0, 0, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x180C */ DEFINE_SFX(NA_SE_IT_SHIELD_REFLECT_MG, 0x30, 1, 0, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x180D */ DEFINE_SFX(NA_SE_IT_BOMB_IGNIT, 0x50, 0, 0, 0, SFX_FLAG_8) +/* 0x180E */ DEFINE_SFX(NA_SE_IT_BOMB_EXPLOSION, 0x90, 2, 0, 0, 0) +/* 0x180F */ DEFINE_SFX(NA_SE_IT_BOMB_UNEXPLOSION, 0x50, 2, 0, 0, 0) +/* 0x1810 */ DEFINE_SFX(NA_SE_IT_BOOMERANG_FLY, 0x30, 0, 0, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x1811 */ DEFINE_SFX(NA_SE_IT_SWORD_STRIKE, 0x40, 2, 0, 0, 0) +/* 0x1812 */ DEFINE_SFX(NA_SE_IT_HAMMER_SWING, 0x30, 0, 1, 0, 0) +/* 0x1813 */ DEFINE_SFX(NA_SE_IT_HOOKSHOT_REFLECT, 0x30, 0, 0, 0, 0) +/* 0x1814 */ DEFINE_SFX(NA_SE_IT_HOOKSHOT_STICK_CRE, 0x30, 0, 0, 0, 0) +/* 0x1815 */ DEFINE_SFX(NA_SE_IT_ARROW_STICK_OBJ, 0x34, 0, 0, 0, 0) +/* 0x1816 */ DEFINE_SFX(NA_SE_IT_SWORD_SLASH, 0x30, 0, 0, 0, 0) +/* 0x1817 */ DEFINE_SFX(NA_SE_IT_SWORD_SLASH_HARD, 0x30, 0, 0, 0, 0) +/* 0x1818 */ DEFINE_SFX(NA_SE_IT_SWORD_SWING_HARD, 0x30, 0, 0, 0, 0) +/* 0x1819 */ DEFINE_SFX(NA_SE_IT_BOMB_BOUND, 0x30, 0, 0, 0, 0) +/* 0x181A */ DEFINE_SFX(NA_SE_IT_WALL_HIT_HARD, 0x60, 0, 0, 0, 0) +/* 0x181B */ DEFINE_SFX(NA_SE_IT_WALL_HIT_SOFT, 0x30, 0, 0, 0, 0) +/* 0x181C */ DEFINE_SFX(NA_SE_IT_STONE_HIT, 0x30, 0, 0, 0, 0) +/* 0x181D */ DEFINE_SFX(NA_SE_IT_WOODSTICK_BROKEN, 0x30, 0, 0, 0, 0) +/* 0x181E */ DEFINE_SFX(NA_SE_IT_LASH, 0x30, 0, 2, 0, 0) +/* 0x181F */ DEFINE_SFX(NA_SE_IT_SHIELD_SWING, 0x30, 0, 1, 0, 0) +/* 0x1820 */ DEFINE_SFX(NA_SE_IT_SLING_SHOT, 0x30, 0, 0, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x1821 */ DEFINE_SFX(NA_SE_IT_SLING_DRAW, 0x20, 0, 0, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x1822 */ DEFINE_SFX(NA_SE_IT_SWORD_CHARGE, 0x30, 0, 0, 0, 0) +/* 0x1823 */ DEFINE_SFX(NA_SE_IT_ROLLING_CUT, 0x30, 0, 0, 0, 0) +/* 0x1824 */ DEFINE_SFX(NA_SE_IT_SWORD_STRIKE_HARD, 0x30, 0, 0, 0, 0) +/* 0x1825 */ DEFINE_SFX(NA_SE_IT_SLING_REFLECT, 0x30, 0, 0, 0, 0) +/* 0x1826 */ DEFINE_SFX(NA_SE_IT_SHIELD_REMOVE, 0x30, 0, 0, 0, 0) +/* 0x1827 */ DEFINE_SFX(NA_SE_IT_HOOKSHOT_READY, 0x30, 0, 0, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x1828 */ DEFINE_SFX(NA_SE_IT_HOOKSHOT_RECEIVE, 0x30, 0, 0, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x1829 */ DEFINE_SFX(NA_SE_IT_HOOKSHOT_STICK_OBJ, 0x60, 3, 1, 0, 0) +/* 0x182A */ DEFINE_SFX(NA_SE_IT_SWORD_REFLECT_MG, 0x30, 1, 0, 0, 0) +/* 0x182B */ DEFINE_SFX(NA_SE_IT_DEKU, 0x30, 1, 0, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x182C */ DEFINE_SFX(NA_SE_IT_WALL_HIT_BUYO, 0x30, 0, 0, 0, 0) +/* 0x182D */ DEFINE_SFX(NA_SE_IT_SWORD_PUTAWAY_STN, 0x30, 0, 0, 0, 0) +/* 0x182E */ DEFINE_SFX(NA_SE_IT_ROLLING_CUT_LV1, 0xA0, 2, 0, 0, 0) +/* 0x182F */ DEFINE_SFX(NA_SE_IT_ROLLING_CUT_LV2, 0xA0, 2, 0, 0, 0) +/* 0x1830 */ DEFINE_SFX(NA_SE_IT_BOW_FLICK, 0x30, 0, 0, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x1831 */ DEFINE_SFX(NA_SE_IT_BOMBCHU_MOVE, 0x30, 0, 0, 0, SFX_FLAG_8) +/* 0x1832 */ DEFINE_SFX(NA_SE_IT_SHIELD_CHARGE_LV1, 0x60, 0, 0, 0, 0) +/* 0x1833 */ DEFINE_SFX(NA_SE_IT_SHIELD_CHARGE_LV2, 0x60, 0, 0, 0, 0) +/* 0x1834 */ DEFINE_SFX(NA_SE_IT_SHIELD_CHARGE_LV3, 0x60, 0, 0, 0, 0) +/* 0x1835 */ DEFINE_SFX(NA_SE_IT_SLING_FLICK, 0x30, 0, 0, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x1836 */ DEFINE_SFX(NA_SE_IT_SWORD_STICK_STN, 0x30, 0, 0, 0, 0) +/* 0x1837 */ DEFINE_SFX(NA_SE_IT_REFLECTION_WOOD, 0x60, 1, 2, 0, 0) +/* 0x1838 */ DEFINE_SFX(NA_SE_IT_SHIELD_REFLECT_MG2, 0x30, 0, 0, 0, 0) +/* 0x1839 */ DEFINE_SFX(NA_SE_IT_MAGIC_ARROW_SHOT, 0x30, 0, 0, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x183A */ DEFINE_SFX(NA_SE_IT_EXPLOSION_FRAME, 0x60, 3, 0, 0, SFX_FLAG_FREQ_NO_DIST) +/* 0x183B */ DEFINE_SFX(NA_SE_IT_EXPLOSION_ICE, 0x60, 3, 0, 0, SFX_FLAG_FREQ_NO_DIST) +/* 0x183C */ DEFINE_SFX(NA_SE_IT_EXPLOSION_LIGHT, 0x60, 3, 0, 0, SFX_FLAG_FREQ_NO_DIST) +/* 0x183D */ DEFINE_SFX(NA_SE_IT_FISHING_REEL_SLOW, 0x30, 0, 0, 0, SFX_PARAM_RAND_FREQ_LOWER) +/* 0x183E */ DEFINE_SFX(NA_SE_IT_FISHING_REEL_HIGH, 0x30, 0, 0, 0, SFX_PARAM_RAND_FREQ_LOWER) +/* 0x183F */ DEFINE_SFX(NA_SE_IT_PULL_FISHING_ROD, 0x30, 0, 1, 0, 0) +/* 0x1840 */ DEFINE_SFX(NA_SE_IT_DM_FLYING_GOD_PASS, 0x80, 3, 0, 0, 0) +/* 0x1841 */ DEFINE_SFX(NA_SE_IT_DM_FLYING_GOD_DASH, 0x80, 3, 0, 0, 0) +/* 0x1842 */ DEFINE_SFX(NA_SE_IT_DM_RING_EXPLOSION, 0x30, 3, 0, 0, 0) +/* 0x1843 */ DEFINE_SFX(NA_SE_IT_DM_RING_GATHER, 0x30, 0, 0, 0, 0) +/* 0x1844 */ DEFINE_SFX(NA_SE_IT_INGO_HORSE_NEIGH, 0x30, 0, 1, 0, 0) +/* 0x1845 */ DEFINE_SFX(NA_SE_IT_EARTHQUAKE, 0x30, 0, 0, 0, 0) +/* 0x1846 */ DEFINE_SFX(NA_SE_IT_ERUPTION_PILLAR, 0x30, 0, 0, 0, 0) +/* 0x1847 */ DEFINE_SFX(NA_SE_IT_KAKASHI_JUMP, 0x30, 0, 0, 0, 0) +/* 0x1848 */ DEFINE_SFX(NA_SE_IT_FLAME, 0x30, 0, 0, 0, 0) +/* 0x1849 */ DEFINE_SFX(NA_SE_IT_SHIELD_BEAM, 0x30, 0, 0, 0, 0) +/* 0x184A */ DEFINE_SFX(NA_SE_IT_FISHING_HIT, 0x30, 0, 0, 0, 0) +/* 0x184B */ DEFINE_SFX(NA_SE_IT_GOODS_APPEAR, 0x30, 0, 0, 0, 0) +/* 0x184C */ DEFINE_SFX(NA_SE_IT_MAJIN_SWORD_BROKEN, 0x80, 0, 0, 0, 0) +/* 0x184D */ DEFINE_SFX(NA_SE_IT_HAND_CLAP, 0x30, 0, 0, 0, 0) +/* 0x184E */ DEFINE_SFX(NA_SE_IT_MASTER_SWORD_SWING, 0x30, 0, 0, 0, 0) +/* 0x184F */ DEFINE_SFX(NA_SE_IT_GORON_BALLFANG, 0x30, 0, 0, 0, 0) +/* 0x1850 */ DEFINE_SFX(NA_SE_IT_DEKUNUTS_FLOWER_OPEN, 0x80, 0, 0, 0, 0) +/* 0x1851 */ DEFINE_SFX(NA_SE_IT_DEKUNUTS_FLOWER_ROLL, 0x80, 0, 0, 0, 0) +/* 0x1852 */ DEFINE_SFX(NA_SE_IT_DEKUNUTS_FLOWER_CLOSE, 0x30, 0, 0, 0, 0) +/* 0x1853 */ DEFINE_SFX(NA_SE_IT_DEKUNUTS_BUBLE_BROKEN, 0x30, 0, 0, 0, 0) +/* 0x1854 */ DEFINE_SFX(NA_SE_IT_DEKUNUTS_BUBLE_VANISH, 0x30, 0, 0, 0, 0) +/* 0x1855 */ DEFINE_SFX(NA_SE_IT_DEKUNUTS_DROP_BOMB, 0x30, 0, 0, 0, 0) +/* 0x1856 */ DEFINE_SFX(NA_SE_IT_SET_TRANSFORM_MASK, 0x30, 0, 0, 0, 0) +/* 0x1857 */ DEFINE_SFX(NA_SE_IT_GORON_PUNCH_SWING, 0x30, 0, 0, 0, 0) +/* 0x1858 */ DEFINE_SFX(NA_SE_IT_TRANSFORM_MASK_BROKEN, 0x30, 0, 0, 0, 0) +/* 0x1859 */ DEFINE_SFX(NA_SE_IT_ZORA_KICK_SWING, 0x40, 0, 0, 0, 0) +/* 0x185A */ DEFINE_SFX(NA_SE_IT_DEKUNUTS_BUBLE_SHOT_LEVEL, 0x30, 0, 0, 0, 0) +/* 0x185B */ DEFINE_SFX(NA_SE_IT_BIG_BOMB_IGNIT, 0x60, 0, 0, 0, SFX_FLAG_8) +/* 0x185C */ DEFINE_SFX(NA_SE_IT_BIG_BOMB_EXPLOSION, 0x70, 0, 0, 0, 0) +/* 0x185D */ DEFINE_SFX(NA_SE_IT_REFLECTION_SNOW, 0x60, 0, 0, 0, 0) +/* 0x185E */ DEFINE_SFX(NA_SE_IT_GORON_ROLLING_REFLECTION, 0x30, 3, 2, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x185F */ DEFINE_SFX(NA_SE_IT_MASK_BOUND_0, 0x30, 0, 1, 0, 0) +/* 0x1860 */ DEFINE_SFX(NA_SE_IT_MASK_BOUND_1, 0x30, 0, 1, 0, 0) +/* 0x1861 */ DEFINE_SFX(NA_SE_IT_MASK_BOUND_SAND, 0x30, 0, 0, 0, 0) +/* 0x1862 */ DEFINE_SFX(NA_SE_IT_REFLECTION_WATER, 0x30, 0, 0, 0, 0) +/* 0x1863 */ DEFINE_SFX(NA_SE_IT_KYOJIN_BEARING, 0x60, 0, 0, 0, SFX_FLAG_VOLUME_NO_DIST) +/* 0x1864 */ DEFINE_SFX(NA_SE_FISHING_REEL_SLOW2, 0x30, 0, 0, 0, 0) +/* 0x1865 */ DEFINE_SFX(NA_SE_IT_LURE_LAND1, 0x30, 0, 0, 0, 0) +/* 0x1866 */ DEFINE_SFX(NA_SE_IT_ROD_THROW, 0x30, 0, 0, 0, 0) +/* 0x1867 */ DEFINE_SFX(NA_SE_IT_REFLECT_BOSS, 0x30, 0, 0, 0, 0) +/* 0x1868 */ DEFINE_SFX(NA_SE_IT_SHIELD_SWING_ZORA, 0x30, 0, 0, 0, 0) +/* 0x1869 */ DEFINE_SFX(NA_SE_IT_SHIELD_REMOVE_ZORA, 0x30, 0, 0, 0, 0) +/* 0x186A */ DEFINE_SFX(NA_SE_IT_BOMB_EXPLOSION2, 0x30, 0, 0, 0, 0) +/* 0x186B */ DEFINE_SFX(NA_SE_IT_FISHING_REEL_REVERSE, 0x30, 0, 0, 0, 0) +/* 0x186C */ DEFINE_SFX(NA_SE_IT_FISHING_WORM_BOUND, 0x30, 0, 0, 0, 0) +/* 0x186D */ DEFINE_SFX(NA_SE_IT_DUMMY_109, 0x30, 0, 0, 0, 0) +/* 0x186E */ DEFINE_SFX(NA_SE_IT_DUMMY_110, 0x30, 0, 0, 0, 0) +/* 0x186F */ DEFINE_SFX(NA_SE_IT_DUMMY_111, 0x30, 0, 0, 0, 0) diff --git a/include/tables/sfx/ocarinabank_table.h b/include/tables/sfx/ocarinabank_table.h new file mode 100644 index 000000000..fa83394ab --- /dev/null +++ b/include/tables/sfx/ocarinabank_table.h @@ -0,0 +1,29 @@ +/** + * Sfx Ocarina Bank + * + * DEFINE_SFX should be used for all sfx define in the ocarina bank from sequence 0 + * - Argument 0: Enum value for this sfx + * - Argument 1: Importance for deciding which sfx to prioritize. Higher values have greater importance + * - Argument 2: Slows the decay of volume with distance (a 3-bit number ranging from 0-7) + * - Argument 3: Applies increasingly random offsets to frequency (a 2-bit number ranging from 0-3) + * - Argument 4: Various flags to add properties to the sfx + * - Argument 5: Various flags to add properties to the sfx + * + * WARNING: entries must align with the table defined for the ocarina bank in sequence 0 + */ +/* 0x5800 */ DEFINE_SFX(NA_SE_OC_OCARINA, 0x30, 0, 0, 0, 0) +/* 0x5801 */ DEFINE_SFX(NA_SE_OC_ABYSS, 0x30, 0, 0, 0, SFX_FLAG_BLOCK_EQUAL_IMPORTANCE) +/* 0x5802 */ DEFINE_SFX(NA_SE_OC_DOOR_OPEN, 0x30, 2, 1, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX | SFX_FLAG_SURROUND_LOWPASS_FILTER) +/* 0x5803 */ DEFINE_SFX(NA_SE_OC_SECRET_WARP_IN, 0x30, 0, 0, 0, 0) +/* 0x5804 */ DEFINE_SFX(NA_SE_OC_SECRET_WARP_OUT, 0x30, 0, 0, 0, 0) +/* 0x5805 */ DEFINE_SFX(NA_SE_OC_SECRET_HOLE_OUT, 0x30, 0, 0, 0, 0) +/* 0x5806 */ DEFINE_SFX(NA_SE_OC_REVENGE, 0x30, 0, 0, 0, 0) +/* 0x5807 */ DEFINE_SFX(NA_SE_OC_TUNAMI, 0x30, 0, 0, 0, 0) +/* 0x5808 */ DEFINE_SFX(NA_SE_OC_TELOP_IMPACT, 0x30, 0, 0, 0, 0) +/* 0x5809 */ DEFINE_SFX(NA_SE_OC_WOOD_GATE_OPEN, 0x30, 0, 0, 0, 0) +/* 0x580A */ DEFINE_SFX(NA_SE_OC_FIREWORKS, 0x30, 0, 0, 0, SFX_FLAG_VOLUME_NO_DIST) +/* 0x580B */ DEFINE_SFX(NA_SE_OC_WHITE_OUT_INTO_KYOJIN, 0x30, 0, 0, 0, SFX_FLAG_VOLUME_NO_DIST) +/* 0x580C */ DEFINE_SFX(NA_SE_OC_12, 0x30, 0, 0, 0, 0) +/* 0x580D */ DEFINE_SFX(NA_SE_OC_13, 0x30, 0, 0, 0, 0) +/* 0x580E */ DEFINE_SFX(NA_SE_OC_14, 0x30, 0, 0, 0, 0) +/* 0x580F */ DEFINE_SFX(NA_SE_OC_15, 0x30, 0, 0, 0, 0) diff --git a/include/tables/sfx/playerbank_table.h b/include/tables/sfx/playerbank_table.h new file mode 100644 index 000000000..bcec96a67 --- /dev/null +++ b/include/tables/sfx/playerbank_table.h @@ -0,0 +1,477 @@ +/** + * Sfx Player Bank + * + * DEFINE_SFX should be used for all sfx define in the player bank from sequence 0 + * - Argument 0: Enum value for this sfx + * - Argument 1: Importance for deciding which sfx to prioritize. Higher values have greater importance + * - Argument 2: Slows the decay of volume with distance (a 3-bit number ranging from 0-7) + * - Argument 3: Applies increasingly random offsets to frequency (a 2-bit number ranging from 0-3) + * - Argument 4: Various flags to add properties to the sfx + * - Argument 5: Various flags to add properties to the sfx + * + * WARNING: entries must align with the table defined for the player bank in sequence 0 + */ +/* 0x800 */ DEFINE_SFX(NA_SE_PL_WALK_GROUND, 0x20, 0, 2, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x801 */ DEFINE_SFX(NA_SE_PL_WALK_SAND, 0x20, 0, 2, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x802 */ DEFINE_SFX(NA_SE_PL_WALK_CONCRETE, 0x20, 0, 2, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x803 */ DEFINE_SFX(NA_SE_PL_WALK_DIRT, 0x20, 0, 2, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x804 */ DEFINE_SFX(NA_SE_PL_WALK_WATER0, 0x20, 0, 1, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x805 */ DEFINE_SFX(NA_SE_PL_WALK_WATER1, 0x20, 0, 1, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x806 */ DEFINE_SFX(NA_SE_PL_WALK_WATER2, 0x20, 0, 1, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x807 */ DEFINE_SFX(NA_SE_PL_WALK_MAGMA, 0x20, 0, 1, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x808 */ DEFINE_SFX(NA_SE_PL_WALK_GRASS, 0x20, 0, 2, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x809 */ DEFINE_SFX(NA_SE_PL_WALK_IRON, 0x20, 0, 1, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x80A */ DEFINE_SFX(NA_SE_PL_WALK_LADDER, 0x20, 0, 2, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x80B */ DEFINE_SFX(NA_SE_PL_WALK_GLASS, 0x20, 0, 0, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x80C */ DEFINE_SFX(NA_SE_PL_WALK_METAL1, 0x20, 0, 0, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x80D */ DEFINE_SFX(NA_CODE_DIRT_DEEP, 0x20, 0, 0, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x80E */ DEFINE_SFX(NA_SE_PL_WALK_SNOW, 0x20, 0, 0, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x80F */ DEFINE_SFX(NA_SE_PL_WALK_ICE, 0x20, 0, 0, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x810 */ DEFINE_SFX(NA_SE_PL_JUMP_GROUND, 0x30, 0, 0, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x811 */ DEFINE_SFX(NA_SE_PL_JUMP_SAND, 0x30, 0, 0, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x812 */ DEFINE_SFX(NA_SE_PL_JUMP_CONCRETE, 0x30, 0, 0, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x813 */ DEFINE_SFX(NA_SE_PL_JUMP_DIRT, 0x30, 0, 0, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x814 */ DEFINE_SFX(NA_SE_PL_JUMP_WATER0, 0x30, 0, 0, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x815 */ DEFINE_SFX(NA_SE_PL_JUMP_WATER1, 0x30, 0, 0, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x816 */ DEFINE_SFX(NA_SE_PL_JUMP_WATER2, 0x30, 0, 0, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x817 */ DEFINE_SFX(NA_SE_PL_JUMP_MAGMA, 0x30, 0, 0, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x818 */ DEFINE_SFX(NA_SE_PL_JUMP_GRASS, 0x30, 0, 0, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x819 */ DEFINE_SFX(NA_SE_PL_JUMP_IRON, 0x30, 0, 0, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x81A */ DEFINE_SFX(NA_SE_PL_JUMP_LADDER, 0x30, 0, 0, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x81B */ DEFINE_SFX(NA_SE_PL_JUMP_GLASS, 0x30, 0, 0, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x81C */ DEFINE_SFX(NA_SE_PL_DUMMY_28, 0x30, 0, 0, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x81D */ DEFINE_SFX(NA_SE_PL_JUMP_HEAVYBOOTS, 0x30, 0, 0, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x81E */ DEFINE_SFX(NA_SE_PL_JUMP_SNOW, 0x30, 0, 0, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x81F */ DEFINE_SFX(NA_SE_PL_JUMP_ICE, 0x30, 0, 0, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x820 */ DEFINE_SFX(NA_SE_PL_LAND_GROUND, 0x40, 0, 1, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x821 */ DEFINE_SFX(NA_SE_PL_LAND_SAND, 0x40, 0, 1, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x822 */ DEFINE_SFX(NA_SE_PL_LAND_CONCRETE, 0x40, 0, 1, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x823 */ DEFINE_SFX(NA_SE_PL_LAND_DIRT, 0x40, 0, 1, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x824 */ DEFINE_SFX(NA_SE_PL_LAND_WATER0, 0x40, 0, 1, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x825 */ DEFINE_SFX(NA_SE_PL_LAND_WATER1, 0x40, 0, 1, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x826 */ DEFINE_SFX(NA_SE_PL_LAND_WATER2, 0x40, 0, 1, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x827 */ DEFINE_SFX(NA_SE_PL_LAND_MAGMA, 0x40, 0, 1, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x828 */ DEFINE_SFX(NA_SE_PL_LAND_GRASS, 0x40, 0, 1, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x829 */ DEFINE_SFX(NA_SE_PL_LAND_IRON, 0x40, 0, 1, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x82A */ DEFINE_SFX(NA_SE_PL_LAND_LADDER, 0x40, 0, 1, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x82B */ DEFINE_SFX(NA_SE_PL_LAND_GLASS, 0x40, 0, 1, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x82C */ DEFINE_SFX(NA_SE_PL_DUMMY_44, 0x40, 0, 1, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x82D */ DEFINE_SFX(NA_SE_PL_LAND_HEAVYBOOTS, 0x40, 0, 1, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x82E */ DEFINE_SFX(NA_SE_PL_LAND_SNOW, 0x40, 0, 1, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x82F */ DEFINE_SFX(NA_SE_PL_LAND_ICE, 0x40, 0, 1, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x830 */ DEFINE_SFX(NA_SE_PL_SLIPDOWN, 0x30, 0, 2, 0, 0) +/* 0x831 */ DEFINE_SFX(NA_SE_PL_CLIMB_CLIFF, 0x30, 0, 0, 0, 0) +/* 0x832 */ DEFINE_SFX(NA_SE_PL_SIT_ON_HORSE, 0x30, 0, 0, 0, 0) +/* 0x833 */ DEFINE_SFX(NA_SE_PL_GET_OFF_HORSE, 0x30, 0, 0, 0, 0) +/* 0x834 */ DEFINE_SFX(NA_SE_PL_TAKE_OUT_SHIELD, 0x30, 0, 0, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x835 */ DEFINE_SFX(NA_SE_PL_CHANGE_ARMS, 0x30, 0, 0, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x836 */ DEFINE_SFX(NA_SE_PL_CATCH_BOOMERANG, 0x30, 0, 0, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x837 */ DEFINE_SFX(NA_SE_PL_DIVE_INTO_WATER, 0x30, 0, 1, 0, 0) +/* 0x838 */ DEFINE_SFX(NA_SE_PL_JUMP_OUT_WATER, 0x30, 0, 1, 0, 0) +/* 0x839 */ DEFINE_SFX(NA_SE_PL_SWIM, 0x30, 0, 2, 0, 0) +/* 0x83A */ DEFINE_SFX(NA_SE_PL_THROW, 0x30, 0, 0, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x83B */ DEFINE_SFX(NA_SE_PL_BODY_BOUND, 0x30, 0, 0, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x83C */ DEFINE_SFX(NA_SE_PL_ROLL, 0x40, 0, 0, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x83D */ DEFINE_SFX(NA_SE_PL_SKIP, 0x30, 0, 0, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x83E */ DEFINE_SFX(NA_SE_PL_BODY_HIT, 0x30, 2, 0, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x83F */ DEFINE_SFX(NA_SE_PL_DAMAGE, 0x30, 0, 0, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x840 */ DEFINE_SFX(NA_SE_PL_SLIP, 0x30, 0, 1, 0, 0) +/* 0x841 */ DEFINE_SFX(NA_SE_PL_SLIP_SAND, 0x30, 0, 1, 0, 0) +/* 0x842 */ DEFINE_SFX(NA_SE_PL_SLIP_CONCRETE, 0x30, 0, 1, 0, 0) +/* 0x843 */ DEFINE_SFX(NA_SE_PL_SLIP_DIRT, 0x30, 0, 1, 0, 0) +/* 0x844 */ DEFINE_SFX(NA_SE_PL_SLIP_WATER0, 0x30, 0, 1, 0, 0) +/* 0x845 */ DEFINE_SFX(NA_SE_PL_SLIP_WATER1, 0x30, 0, 1, 0, 0) +/* 0x846 */ DEFINE_SFX(NA_SE_PL_SLIP_WATER2, 0x30, 0, 1, 0, 0) +/* 0x847 */ DEFINE_SFX(NA_SE_PL_SLIP_MAGMA, 0x30, 0, 1, 0, 0) +/* 0x848 */ DEFINE_SFX(NA_SE_PL_SLIP_GRASS, 0x30, 0, 1, 0, 0) +/* 0x849 */ DEFINE_SFX(NA_SE_PL_SLIP_IRON, 0x30, 0, 1, 0, 0) +/* 0x84A */ DEFINE_SFX(NA_SE_PL_SLIP_LADDER, 0x30, 0, 1, 0, 0) +/* 0x84B */ DEFINE_SFX(NA_SE_PL_SLIP_GLASS, 0x30, 0, 1, 0, 0) +/* 0x84C */ DEFINE_SFX(NA_SE_PL_DUMMY76, 0x30, 0, 0, 0, 0) +/* 0x84D */ DEFINE_SFX(NA_SE_PL_SLIP_HEAVYBOOTS, 0x30, 0, 0, 0, 0) +/* 0x84E */ DEFINE_SFX(NA_SE_PL_SLIP_SNOW, 0x30, 0, 0, 0, 0) +/* 0x84F */ DEFINE_SFX(NA_SE_PL_SLIP_ICE, 0x30, 0, 0, 0, 0) +/* 0x850 */ DEFINE_SFX(NA_SE_PL_BOUND, 0x80, 0, 0, 0, 0) +/* 0x851 */ DEFINE_SFX(NA_SE_PL_BOUND_SAND, 0x80, 0, 0, 0, 0) +/* 0x852 */ DEFINE_SFX(NA_SE_PL_BOUND_CONCRETE, 0x80, 0, 0, 0, 0) +/* 0x853 */ DEFINE_SFX(NA_SE_PL_BOUND_DIRT, 0x80, 0, 0, 0, 0) +/* 0x854 */ DEFINE_SFX(NA_SE_PL_BOUND_WATER0, 0x80, 0, 0, 0, 0) +/* 0x855 */ DEFINE_SFX(NA_SE_PL_BOUND_WATER1, 0x80, 0, 0, 0, 0) +/* 0x856 */ DEFINE_SFX(NA_SE_PL_BOUND_WATER2, 0x80, 0, 0, 0, 0) +/* 0x857 */ DEFINE_SFX(NA_SE_PL_BOUND_MAGMA, 0x80, 0, 0, 0, 0) +/* 0x858 */ DEFINE_SFX(NA_SE_PL_BOUND_GRASS, 0x80, 0, 0, 0, 0) +/* 0x859 */ DEFINE_SFX(NA_SE_PL_BOUND_IRON, 0x80, 0, 0, 0, 0) +/* 0x85A */ DEFINE_SFX(NA_SE_PL_BOUND_LADDER, 0x80, 0, 0, 0, 0) +/* 0x85B */ DEFINE_SFX(NA_SE_PL_BOUND_WOOD, 0x80, 0, 0, 0, 0) +/* 0x85C */ DEFINE_SFX(NA_SE_PL_DUMMY_92, 0x80, 0, 0, 0, 0) +/* 0x85D */ DEFINE_SFX(NA_SE_PL_BOUND_HEAVYBOOTS, 0x80, 0, 0, 0, 0) +/* 0x85E */ DEFINE_SFX(NA_SE_PL_BOUND_SNOW, 0x80, 0, 0, 0, 0) +/* 0x85F */ DEFINE_SFX(NA_SE_PL_BOUND_ICE, 0x80, 0, 0, 0, 0) +/* 0x860 */ DEFINE_SFX(NA_SE_PL_BOW_DRAW, 0x30, 0, 1, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x861 */ DEFINE_SFX(NA_SE_PL_MEATL_BOOTS_JUMP, 0x30, 0, 0, 0, 0) +/* 0x862 */ DEFINE_SFX(NA_SE_PL_DUMMY_98, 0x30, 0, 0, 0, 0) +/* 0x863 */ DEFINE_SFX(NA_SE_PL_FACE_UP, 0x30, 0, 0, 0, 0) +/* 0x864 */ DEFINE_SFX(NA_SE_PL_DIVE_BUBBLE, 0x30, 0, 0, 0, 0) +/* 0x865 */ DEFINE_SFX(NA_SE_PL_MOVE_BUBBLE, 0x30, 0, 0, 0, 0) +/* 0x866 */ DEFINE_SFX(NA_SE_PL_METALEFFECT_KID, 0x30, 0, 0, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x867 */ DEFINE_SFX(NA_SE_PL_METALEFFECT_ADULT, 0x30, 0, 0, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x868 */ DEFINE_SFX(NA_SE_PL_SPARK, 0x30, 0, 0, 0, 0) +/* 0x869 */ DEFINE_SFX(NA_SE_PL_PULL_UP_PLANT, 0x30, 0, 0, 0, 0) +/* 0x86A */ DEFINE_SFX(NA_SE_PL_PULL_UP_ROCK, 0x30, 0, 0, 0, 0) +/* 0x86B */ DEFINE_SFX(NA_SE_PL_IN_BUBBLE, 0x30, 0, 0, 0, 0) +/* 0x86C */ DEFINE_SFX(NA_SE_PL_PULL_UP_BIGROCK, 0x30, 3, 0, 0, 0) +/* 0x86D */ DEFINE_SFX(NA_SE_PL_SWORD_CHARGE, 0x30, 0, 0, 0, 0) +/* 0x86E */ DEFINE_SFX(NA_SE_PL_FREEZE, 0x30, 0, 0, 0, 0) +/* 0x86F */ DEFINE_SFX(NA_SE_PL_PULL_UP_POT, 0x30, 0, 0, 0, 0) +/* 0x870 */ DEFINE_SFX(NA_SE_PL_KNOCK, 0x30, 0, 0, 0, 0) +/* 0x871 */ DEFINE_SFX(NA_SE_PL_CALM_HIT, 0x30, 0, 2, 0, 0) +/* 0x872 */ DEFINE_SFX(NA_SE_PL_CALM_PAT, 0x30, 0, 0, 0, 0) +/* 0x873 */ DEFINE_SFX(NA_SE_PL_SUBMERGE, 0x30, 0, 0, 0, 0) +/* 0x874 */ DEFINE_SFX(NA_SE_PL_FREEZE_S, 0x30, 3, 0, 0, 0) +/* 0x875 */ DEFINE_SFX(NA_SE_PL_ICE_BROKEN, 0x30, 1, 0, 0, 0) +/* 0x876 */ DEFINE_SFX(NA_SE_PL_SLIP_ICE_LELEL, 0x30, 0, 0, 0, 0) +/* 0x877 */ DEFINE_SFX(NA_SE_PL_PUT_OUT_ITEM, 0x30, 0, 0, 0, 0) +/* 0x878 */ DEFINE_SFX(NA_SE_PL_PULL_UP_WOODBOX, 0x30, 0, 0, 0, 0) +/* 0x879 */ DEFINE_SFX(NA_SE_PL_MAGIC_FIRE, 0x30, 0, 0, 0, 0) +/* 0x87A */ DEFINE_SFX(NA_SE_PL_MAGIC_WIND_NORMAL, 0x30, 0, 0, 0, 0) +/* 0x87B */ DEFINE_SFX(NA_SE_PL_MAGIC_WIND_WARP, 0x30, 0, 0, 0, SFX_FLAG_VOLUME_NO_DIST) +/* 0x87C */ DEFINE_SFX(NA_SE_PL_MAGIC_SOUL_NORMAL, 0x30, 0, 0, 0, SFX_PARAM_RAND_FREQ_SCALE | SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x87D */ DEFINE_SFX(NA_SE_PL_ARROW_CHARGE_FIRE, 0x30, 0, 0, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x87E */ DEFINE_SFX(NA_SE_PL_ARROW_CHARGE_ICE, 0x30, 0, 0, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x87F */ DEFINE_SFX(NA_SE_PL_ARROW_CHARGE_LIGHT, 0x30, 0, 0, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x880 */ DEFINE_SFX(NA_SE_DUMMY_128, 0x20, 0, 2, 0, 0) +/* 0x881 */ DEFINE_SFX(NA_SE_DUMMY_129, 0x20, 0, 2, 0, 0) +/* 0x882 */ DEFINE_SFX(NA_SE_DUMMY_130, 0x20, 0, 2, 0, 0) +/* 0x883 */ DEFINE_SFX(NA_SE_PL_PULL_UP_RUTO, 0x20, 0, 2, 0, 0) +/* 0x884 */ DEFINE_SFX(NA_SE_DUMMY_132, 0x20, 0, 1, 0, 0) +/* 0x885 */ DEFINE_SFX(NA_SE_DUMMY_133, 0x20, 0, 1, 0, 0) +/* 0x886 */ DEFINE_SFX(NA_SE_DUMMY_134, 0x20, 0, 1, 0, 0) +/* 0x887 */ DEFINE_SFX(NA_SE_DUMMY_135, 0x20, 0, 1, 0, 0) +/* 0x888 */ DEFINE_SFX(NA_SE_DUMMY_136, 0x20, 0, 2, 0, 0) +/* 0x889 */ DEFINE_SFX(NA_SE_DUMMY_137, 0x20, 0, 2, 0, 0) +/* 0x88A */ DEFINE_SFX(NA_SE_DUMMY_138, 0x20, 0, 2, 0, 0) +/* 0x88B */ DEFINE_SFX(NA_SE_DUMMY_139, 0x20, 0, 0, 0, 0) +/* 0x88C */ DEFINE_SFX(NA_SE_DUMMY_140, 0x20, 0, 0, 0, 0) +/* 0x88D */ DEFINE_SFX(NA_SE_DUMMY_141, 0x20, 0, 0, 0, 0) +/* 0x88E */ DEFINE_SFX(NA_SE_DUMMY_142, 0x20, 0, 0, 0, 0) +/* 0x88F */ DEFINE_SFX(NA_SE_DUMMY_143, 0x20, 0, 0, 0, 0) +/* 0x890 */ DEFINE_SFX(NA_SE_DUMMY_144, 0x30, 0, 0, 0, 0) +/* 0x891 */ DEFINE_SFX(NA_SE_DUMMY_145, 0x30, 0, 0, 0, 0) +/* 0x892 */ DEFINE_SFX(NA_SE_DUMMY_146, 0x30, 0, 0, 0, 0) +/* 0x893 */ DEFINE_SFX(NA_SE_DUMMY_147, 0x30, 0, 0, 0, 0) +/* 0x894 */ DEFINE_SFX(NA_SE_DUMMY_148, 0x30, 0, 0, 0, 0) +/* 0x895 */ DEFINE_SFX(NA_SE_DUMMY_149, 0x30, 0, 0, 0, 0) +/* 0x896 */ DEFINE_SFX(NA_SE_DUMMY_150, 0x30, 0, 0, 0, 0) +/* 0x897 */ DEFINE_SFX(NA_SE_DUMMY_151, 0x30, 0, 0, 0, 0) +/* 0x898 */ DEFINE_SFX(NA_SE_DUMMY_152, 0x30, 0, 0, 0, 0) +/* 0x899 */ DEFINE_SFX(NA_SE_DUMMY_153, 0x30, 0, 0, 0, 0) +/* 0x89A */ DEFINE_SFX(NA_SE_DUMMY_154, 0x30, 0, 0, 0, 0) +/* 0x89B */ DEFINE_SFX(NA_SE_DUMMY_155, 0x30, 0, 0, 0, 0) +/* 0x89C */ DEFINE_SFX(NA_SE_DUMMY_156, 0x30, 0, 0, 0, 0) +/* 0x89D */ DEFINE_SFX(NA_SE_DUMMY_157, 0x30, 0, 0, 0, 0) +/* 0x89E */ DEFINE_SFX(NA_SE_DUMMY_158, 0x30, 0, 0, 0, 0) +/* 0x89F */ DEFINE_SFX(NA_SE_DUMMY_159, 0x30, 0, 0, 0, 0) +/* 0x8A0 */ DEFINE_SFX(NA_SE_DUMMY_160, 0x40, 0, 0, 0, 0) +/* 0x8A1 */ DEFINE_SFX(NA_SE_DUMMY_161, 0x40, 0, 0, 0, 0) +/* 0x8A2 */ DEFINE_SFX(NA_SE_DUMMY_162, 0x40, 0, 0, 0, 0) +/* 0x8A3 */ DEFINE_SFX(NA_SE_DUMMY_163, 0x40, 0, 0, 0, 0) +/* 0x8A4 */ DEFINE_SFX(NA_SE_DUMMY_164, 0x40, 0, 0, 0, 0) +/* 0x8A5 */ DEFINE_SFX(NA_SE_DUMMY_165, 0x40, 0, 0, 0, 0) +/* 0x8A6 */ DEFINE_SFX(NA_SE_DUMMY_166, 0x40, 0, 0, 0, 0) +/* 0x8A7 */ DEFINE_SFX(NA_SE_DUMMY_167, 0x40, 0, 0, 0, 0) +/* 0x8A8 */ DEFINE_SFX(NA_SE_DUMMY_168, 0x40, 0, 0, 0, 0) +/* 0x8A9 */ DEFINE_SFX(NA_SE_DUMMY_169, 0x40, 0, 0, 0, 0) +/* 0x8AA */ DEFINE_SFX(NA_SE_DUMMY_170, 0x40, 0, 0, 0, 0) +/* 0x8AB */ DEFINE_SFX(NA_SE_DUMMY_171, 0x40, 0, 0, 0, 0) +/* 0x8AC */ DEFINE_SFX(NA_SE_DUMMY_172, 0x40, 0, 0, 0, 0) +/* 0x8AD */ DEFINE_SFX(NA_SE_DUMMY_173, 0x40, 0, 0, 0, 0) +/* 0x8AE */ DEFINE_SFX(NA_SE_DUMMY_174, 0x40, 0, 0, 0, 0) +/* 0x8AF */ DEFINE_SFX(NA_SE_DUMMY_175, 0x40, 0, 0, 0, 0) +/* 0x8B0 */ DEFINE_SFX(NA_SE_PL_CRAWL, 0x30, 0, 1, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x8B1 */ DEFINE_SFX(NA_SE_PL_CRAWL_SAND, 0x30, 0, 1, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x8B2 */ DEFINE_SFX(NA_SE_PL_CRAWL_CONCRETE, 0x30, 0, 1, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x8B3 */ DEFINE_SFX(NA_SE_PL_CRAWL_DIRT, 0x30, 0, 1, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x8B4 */ DEFINE_SFX(NA_SE_PL_CRAWL_WATER0, 0x30, 0, 1, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x8B5 */ DEFINE_SFX(NA_SE_DUMMY_181, 0x30, 0, 1, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x8B6 */ DEFINE_SFX(NA_SE_DUMMY_182, 0x30, 0, 1, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x8B7 */ DEFINE_SFX(NA_SE_DUMMY_183, 0x30, 0, 1, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x8B8 */ DEFINE_SFX(NA_SE_DUMMY_184, 0x30, 0, 1, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x8B9 */ DEFINE_SFX(NA_SE_DUMMY_185, 0x30, 0, 1, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x8BA */ DEFINE_SFX(NA_SE_DUMMY_186, 0x30, 0, 1, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x8BB */ DEFINE_SFX(NA_SE_PL_CRAWL_WOOD, 0x30, 0, 1, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x8BC */ DEFINE_SFX(NA_SE_DUMMY_188, 0x30, 0, 1, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x8BD */ DEFINE_SFX(NA_SE_DUMMY_189, 0x30, 0, 1, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x8BE */ DEFINE_SFX(NA_SE_DUMMY_190, 0x30, 0, 1, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x8BF */ DEFINE_SFX(NA_SE_PL_CRAWL_ICE, 0x30, 0, 1, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x8C0 */ DEFINE_SFX(NA_SE_PL_MAGIC_SOUL_FLASH, 0x30, 0, 0, 0, SFX_PARAM_RAND_FREQ_SCALE | SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x8C1 */ DEFINE_SFX(NA_SE_PL_ROLL_DUST, 0x30, 0, 2, 0, SFX_PARAM_RAND_FREQ_LOWER) +/* 0x8C2 */ DEFINE_SFX(NA_SE_DUMMY_194, 0x30, 0, 0, 0, 0) +/* 0x8C3 */ DEFINE_SFX(NA_SE_PL_MAGIC_SOUL_BALL, 0x30, 0, 0, 0, 0) +/* 0x8C4 */ DEFINE_SFX(NA_SE_PL_SPIRAL_HEAL_BEAM, 0x30, 0, 0, 0, 0) +/* 0x8C5 */ DEFINE_SFX(NA_SE_PL_BOUND_NOWEAPON, 0x30, 0, 0, 0, 0) +/* 0x8C6 */ DEFINE_SFX(NA_SE_PL_PLANT_GROW_UP, 0x30, 0, 0, 0, 0) +/* 0x8C7 */ DEFINE_SFX(NA_SE_PL_PLANT_TALLER, 0x30, 0, 0, 0, 0) +/* 0x8C8 */ DEFINE_SFX(NA_SE_PL_MAGIC_WIND_VANISH, 0x60, 2, 0, 0, 0) +/* 0x8C9 */ DEFINE_SFX(NA_SE_PL_HOBBERBOOTS_LV, 0x30, 0, 0, 0, 0) +/* 0x8CA */ DEFINE_SFX(NA_SE_PL_PLANT_MOVE, 0x30, 0, 0, 0, 0) +/* 0x8CB */ DEFINE_SFX(NA_SE_EV_WALL_MOVE_SP, 0x30, 0, 0, 0, SFX_PARAM_RAND_FREQ_SCALE) +/* 0x8CC */ DEFINE_SFX(NA_SE_PL_PLANT_GROW_BIG, 0x30, 0, 0, 0, 0) +/* 0x8CD */ DEFINE_SFX(NA_SE_PL_TELESCOPE_MOVEMENT, 0x30, 0, 0, 0, 0) +/* 0x8CE */ DEFINE_SFX(NA_SE_PL_GIANT_WALK, 0x30, 3, 0, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x8CF */ DEFINE_SFX(NA_SE_PL_CHIBI_FAIRY_HEAL, 0x30, 0, 0, 0, 0) +/* 0x8D0 */ DEFINE_SFX(NA_SE_PL_SLIP_LEVEL, 0x30, 0, 0, 0, 0) +/* 0x8D1 */ DEFINE_SFX(NA_SE_PL_SLIP_SAND_LEVEL, 0x30, 0, 0, 0, 0) +/* 0x8D2 */ DEFINE_SFX(NA_SE_PL_SLIP_CONCRETE_LEVEL, 0x30, 0, 0, 0, 0) +/* 0x8D3 */ DEFINE_SFX(NA_SE_PL_SLIP_DIRT_LEVEL, 0x30, 0, 0, 0, 0) +/* 0x8D4 */ DEFINE_SFX(NA_SE_PL_SLIP_WATER0_LEVEL, 0x30, 0, 0, 0, 0) +/* 0x8D5 */ DEFINE_SFX(NA_SE_PL_SLIP_WATER1_LEVEL, 0x30, 0, 0, 0, 0) +/* 0x8D6 */ DEFINE_SFX(NA_SE_PL_SLIP_WATER2_LEVEL, 0x30, 0, 0, 0, 0) +/* 0x8D7 */ DEFINE_SFX(NA_SE_PL_SLIP_MAGMA_LEVEL, 0x30, 0, 0, 0, 0) +/* 0x8D8 */ DEFINE_SFX(NA_SE_PL_SLIP_GRASS_LEVEL, 0x30, 0, 0, 0, 0) +/* 0x8D9 */ DEFINE_SFX(NA_SE_PL_SLIP_IRON_LEVEL, 0x30, 0, 0, 0, 0) +/* 0x8DA */ DEFINE_SFX(NA_SE_PL_SLIP_LADDER_LEVEL, 0x30, 0, 0, 0, 0) +/* 0x8DB */ DEFINE_SFX(NA_SE_PL_SLIP_GLASS_LEVEL, 0x30, 0, 0, 0, 0) +/* 0x8DC */ DEFINE_SFX(NA_SE_PL_DUMMY_220, 0x30, 0, 0, 0, 0) +/* 0x8DD */ DEFINE_SFX(NA_SE_PL_SLIP_HEAVYBOOTS_LEVEL, 0x30, 0, 0, 0, 0) +/* 0x8DE */ DEFINE_SFX(NA_SE_PL_DUMMY_222, 0x30, 0, 0, 0, 0) +/* 0x8DF */ DEFINE_SFX(NA_SE_PL_SLIP_ICE_LEVEL, 0x30, 0, 0, 0, 0) +/* 0x8E0 */ DEFINE_SFX(NA_SE_PL_DEKUNUTS_FIRE, 0x30, 0, 0, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x8E1 */ DEFINE_SFX(NA_SE_PL_GORON_BALLJUMP, 0x60, 0, 1, 0, 0) +/* 0x8E2 */ DEFINE_SFX(NA_SE_PL_DEKUNUTS_IN_GRD, 0x40, 0, 0, 0, 0) +/* 0x8E3 */ DEFINE_SFX(NA_SE_PL_DEKUNUTS_OUT_GRD, 0x30, 0, 0, 0, 0) +/* 0x8E4 */ DEFINE_SFX(NA_SE_PL_TRANSFORM, 0x30, 0, 0, 0, 0) +/* 0x8E5 */ DEFINE_SFX(NA_SE_PL_TRANSFORM_DEMO, 0x30, 0, 0, 0, 0) +/* 0x8E6 */ DEFINE_SFX(NA_SE_PL_GORON_TO_BALL, 0x30, 0, 0, 0, 0) +/* 0x8E7 */ DEFINE_SFX(NA_SE_PL_BALL_TO_GORON, 0x30, 0, 0, 0, 0) +/* 0x8E8 */ DEFINE_SFX(NA_SE_PL_GORON_PUNCH, 0x50, 3, 1, 0, 0) +/* 0x8E9 */ DEFINE_SFX(NA_SE_PL_SINK_ON_SAND, 0x30, 0, 0, 0, 0) +/* 0x8EA */ DEFINE_SFX(NA_SE_PL_SINK_ON_SNOW, 0x30, 0, 0, 0, 0) +/* 0x8EB */ DEFINE_SFX(NA_SE_PL_GORON_BALL_CHARGE, 0x30, 0, 0, 0, 0) +/* 0x8EC */ DEFINE_SFX(NA_SE_PL_ZORA_SWIM_DASH, 0x30, 0, 0, 0, 0) +/* 0x8ED */ DEFINE_SFX(NA_SE_PL_ZORA_SWIM_LV, 0x30, 0, 0, 0, 0) +/* 0x8EE */ DEFINE_SFX(NA_SE_PL_ZORA_SWIM_ROLL, 0x30, 0, 0, 0, 0) +/* 0x8EF */ DEFINE_SFX(NA_SE_PL_GORON_SQUAT, 0x30, 0, 0, 0, 0) +/* 0x8F0 */ DEFINE_SFX(NA_SE_PL_DUMMY_240, 0x20, 0, 2, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x8F1 */ DEFINE_SFX(NA_SE_PL_DUMMY_241, 0x20, 0, 2, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x8F2 */ DEFINE_SFX(NA_SE_PL_DUMMY_242, 0x20, 0, 2, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x8F3 */ DEFINE_SFX(NA_SE_PL_DUMMY_243, 0x20, 0, 2, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x8F4 */ DEFINE_SFX(NA_SE_PL_DUMMY_244, 0x20, 0, 1, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x8F5 */ DEFINE_SFX(NA_SE_PL_DUMMY_245, 0x20, 0, 1, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x8F6 */ DEFINE_SFX(NA_SE_PL_DUMMY_246, 0x20, 0, 1, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x8F7 */ DEFINE_SFX(NA_SE_PL_DUMMY_247, 0x20, 0, 1, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x8F8 */ DEFINE_SFX(NA_SE_PL_DUMMY_248, 0x20, 0, 2, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x8F9 */ DEFINE_SFX(NA_SE_PL_DUMMY_249, 0x20, 0, 1, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x8FA */ DEFINE_SFX(NA_SE_PL_DUMMY_250, 0x20, 0, 2, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x8FB */ DEFINE_SFX(NA_SE_PL_DUMMY_251, 0x20, 0, 0, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x8FC */ DEFINE_SFX(NA_SE_PL_DUMMY_252, 0x20, 0, 0, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x8FD */ DEFINE_SFX(NA_SE_PL_DUMMY_253, 0x20, 0, 0, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x8FE */ DEFINE_SFX(NA_SE_PL_DUMMY_254, 0x20, 0, 0, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x8FF */ DEFINE_SFX(NA_SE_PL_DUMMY_255, 0x20, 0, 0, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x900 */ DEFINE_SFX(NA_SE_PL_DUMMY_256, 0x30, 0, 0, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x901 */ DEFINE_SFX(NA_SE_PL_DUMMY_257, 0x30, 0, 0, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x902 */ DEFINE_SFX(NA_SE_PL_DUMMY_258, 0x30, 0, 0, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x903 */ DEFINE_SFX(NA_SE_PL_DUMMY_259, 0x30, 0, 0, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x904 */ DEFINE_SFX(NA_SE_PL_DUMMY_260, 0x30, 0, 0, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x905 */ DEFINE_SFX(NA_SE_PL_DUMMY_261, 0x30, 0, 0, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x906 */ DEFINE_SFX(NA_SE_PL_DUMMY_262, 0x30, 0, 0, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x907 */ DEFINE_SFX(NA_SE_PL_DUMMY_263, 0x30, 0, 0, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x908 */ DEFINE_SFX(NA_SE_PL_DUMMY_264, 0x30, 0, 0, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x909 */ DEFINE_SFX(NA_SE_PL_DUMMY_265, 0x30, 0, 0, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x90A */ DEFINE_SFX(NA_SE_PL_DUMMY_266, 0x30, 0, 0, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x90B */ DEFINE_SFX(NA_SE_PL_DUMMY_267, 0x30, 0, 0, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x90C */ DEFINE_SFX(NA_SE_PL_DUMMY_268, 0x30, 0, 0, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x90D */ DEFINE_SFX(NA_SE_PL_DUMMY_269, 0x30, 0, 0, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x90E */ DEFINE_SFX(NA_SE_PL_DUMMY_270, 0x30, 0, 0, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x90F */ DEFINE_SFX(NA_SE_PL_DUMMY_271, 0x30, 0, 0, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x910 */ DEFINE_SFX(NA_SE_PL_DUMMY_272, 0x40, 0, 1, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x911 */ DEFINE_SFX(NA_SE_PL_DUMMY_273, 0x40, 0, 1, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x912 */ DEFINE_SFX(NA_SE_PL_DUMMY_274, 0x40, 0, 1, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x913 */ DEFINE_SFX(NA_SE_PL_DUMMY_275, 0x40, 0, 1, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x914 */ DEFINE_SFX(NA_SE_PL_DUMMY_276, 0x40, 0, 1, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x915 */ DEFINE_SFX(NA_SE_PL_DUMMY_277, 0x40, 0, 1, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x916 */ DEFINE_SFX(NA_SE_PL_DUMMY_278, 0x40, 0, 1, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x917 */ DEFINE_SFX(NA_SE_PL_DUMMY_279, 0x40, 0, 1, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x918 */ DEFINE_SFX(NA_SE_PL_DUMMY_280, 0x40, 0, 1, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x919 */ DEFINE_SFX(NA_SE_PL_DUMMY_281, 0x40, 0, 1, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x91A */ DEFINE_SFX(NA_SE_PL_DUMMY_282, 0x40, 0, 1, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x91B */ DEFINE_SFX(NA_SE_PL_DUMMY_283, 0x40, 0, 1, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x91C */ DEFINE_SFX(NA_SE_PL_DUMMY_284, 0x40, 0, 1, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x91D */ DEFINE_SFX(NA_SE_PL_DUMMY_285, 0x40, 0, 1, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x91E */ DEFINE_SFX(NA_SE_PL_DUMMY_286, 0x40, 0, 1, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x91F */ DEFINE_SFX(NA_SE_PL_DUMMY_287, 0x40, 0, 1, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x920 */ DEFINE_SFX(NA_SE_PL_DUMMY_288, 0x20, 0, 2, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x921 */ DEFINE_SFX(NA_SE_PL_DUMMY_289, 0x20, 0, 2, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x922 */ DEFINE_SFX(NA_SE_PL_DUMMY_290, 0x20, 0, 2, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x923 */ DEFINE_SFX(NA_SE_PL_DUMMY_291, 0x20, 0, 2, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x924 */ DEFINE_SFX(NA_SE_PL_DUMMY_292, 0x20, 0, 1, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x925 */ DEFINE_SFX(NA_SE_PL_DUMMY_293, 0x20, 0, 1, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x926 */ DEFINE_SFX(NA_SE_PL_DUMMY_294, 0x20, 0, 1, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x927 */ DEFINE_SFX(NA_SE_PL_DUMMY_295, 0x20, 0, 1, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x928 */ DEFINE_SFX(NA_SE_PL_DUMMY_296, 0x20, 0, 2, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x929 */ DEFINE_SFX(NA_SE_PL_DUMMY_297, 0x20, 0, 1, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x92A */ DEFINE_SFX(NA_SE_PL_DUMMY_298, 0x20, 0, 2, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x92B */ DEFINE_SFX(NA_SE_PL_DUMMY_299, 0x20, 0, 0, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x92C */ DEFINE_SFX(NA_SE_PL_DUMMY_300, 0x20, 0, 0, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x92D */ DEFINE_SFX(NA_SE_PL_DUMMY_301, 0x20, 0, 0, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x92E */ DEFINE_SFX(NA_SE_PL_DUMMY_302, 0x20, 0, 0, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x92F */ DEFINE_SFX(NA_SE_PL_DUMMY_303, 0x20, 0, 0, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x930 */ DEFINE_SFX(NA_SE_PL_DUMMY_304, 0x30, 0, 0, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x931 */ DEFINE_SFX(NA_SE_PL_DUMMY_305, 0x30, 0, 0, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x932 */ DEFINE_SFX(NA_SE_PL_DUMMY_306, 0x30, 0, 0, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x933 */ DEFINE_SFX(NA_SE_PL_DUMMY_307, 0x30, 0, 0, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x934 */ DEFINE_SFX(NA_SE_PL_DUMMY_308, 0x30, 0, 0, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x935 */ DEFINE_SFX(NA_SE_PL_DUMMY_309, 0x30, 0, 0, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x936 */ DEFINE_SFX(NA_SE_PL_DUMMY_310, 0x30, 0, 0, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x937 */ DEFINE_SFX(NA_SE_PL_DUMMY_311, 0x30, 0, 0, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x938 */ DEFINE_SFX(NA_SE_PL_DUMMY_312, 0x30, 0, 0, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x939 */ DEFINE_SFX(NA_SE_PL_DUMMY_313, 0x30, 0, 0, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x93A */ DEFINE_SFX(NA_SE_PL_DUMMY_314, 0x30, 0, 0, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x93B */ DEFINE_SFX(NA_SE_PL_DUMMY_315, 0x30, 0, 0, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x93C */ DEFINE_SFX(NA_SE_PL_DUMMY_316, 0x30, 0, 0, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x93D */ DEFINE_SFX(NA_SE_PL_DUMMY_317, 0x30, 0, 0, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x93E */ DEFINE_SFX(NA_SE_PL_DUMMY_318, 0x30, 0, 0, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x93F */ DEFINE_SFX(NA_SE_PL_DUMMY_319, 0x30, 0, 0, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x940 */ DEFINE_SFX(NA_SE_PL_DUMMY_320, 0x40, 0, 1, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x941 */ DEFINE_SFX(NA_SE_PL_DUMMY_321, 0x40, 0, 1, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x942 */ DEFINE_SFX(NA_SE_PL_DUMMY_322, 0x40, 0, 1, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x943 */ DEFINE_SFX(NA_SE_PL_DUMMY_323, 0x40, 0, 1, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x944 */ DEFINE_SFX(NA_SE_PL_DUMMY_324, 0x40, 0, 1, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x945 */ DEFINE_SFX(NA_SE_PL_DUMMY_325, 0x40, 0, 1, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x946 */ DEFINE_SFX(NA_SE_PL_DUMMY_326, 0x40, 0, 1, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x947 */ DEFINE_SFX(NA_SE_PL_DUMMY_327, 0x40, 0, 1, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x948 */ DEFINE_SFX(NA_SE_PL_DUMMY_328, 0x40, 0, 1, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x949 */ DEFINE_SFX(NA_SE_PL_DUMMY_329, 0x40, 0, 1, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x94A */ DEFINE_SFX(NA_SE_PL_DUMMY_330, 0x40, 0, 1, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x94B */ DEFINE_SFX(NA_SE_PL_DUMMY_331, 0x40, 0, 1, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x94C */ DEFINE_SFX(NA_SE_PL_DUMMY_332, 0x40, 0, 1, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x94D */ DEFINE_SFX(NA_SE_PL_DUMMY_333, 0x40, 0, 1, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x94E */ DEFINE_SFX(NA_SE_PL_DUMMY_334, 0x40, 0, 1, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x94F */ DEFINE_SFX(NA_SE_PL_DUMMY_335, 0x40, 0, 1, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x950 */ DEFINE_SFX(NA_SE_PL_DUMMY_336, 0x20, 0, 2, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x951 */ DEFINE_SFX(NA_SE_PL_DUMMY_337, 0x20, 0, 2, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x952 */ DEFINE_SFX(NA_SE_PL_DUMMY_338, 0x20, 0, 2, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x953 */ DEFINE_SFX(NA_SE_PL_DUMMY_339, 0x20, 0, 2, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x954 */ DEFINE_SFX(NA_SE_PL_DUMMY_340, 0x20, 0, 1, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x955 */ DEFINE_SFX(NA_SE_PL_DUMMY_341, 0x20, 0, 1, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x956 */ DEFINE_SFX(NA_SE_PL_DUMMY_342, 0x20, 0, 1, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x957 */ DEFINE_SFX(NA_SE_PL_DUMMY_343, 0x20, 0, 1, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x958 */ DEFINE_SFX(NA_SE_PL_DUMMY_344, 0x20, 0, 2, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x959 */ DEFINE_SFX(NA_SE_PL_DUMMY_345, 0x20, 0, 1, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x95A */ DEFINE_SFX(NA_SE_PL_DUMMY_346, 0x20, 0, 2, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x95B */ DEFINE_SFX(NA_SE_PL_DUMMY_347, 0x20, 0, 0, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x95C */ DEFINE_SFX(NA_SE_PL_DUMMY_348, 0x20, 0, 0, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x95D */ DEFINE_SFX(NA_SE_PL_DUMMY_349, 0x20, 0, 0, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x95E */ DEFINE_SFX(NA_SE_PL_DUMMY_350, 0x20, 0, 0, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x95F */ DEFINE_SFX(NA_SE_PL_DUMMY_351, 0x20, 0, 0, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x960 */ DEFINE_SFX(NA_SE_EV_MARATHONMAN_RISE, 0x30, 0, 0, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x961 */ DEFINE_SFX(NA_SE_PL_DUMMY_353, 0x30, 0, 0, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x962 */ DEFINE_SFX(NA_SE_PL_DUMMY_354, 0x30, 0, 0, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x963 */ DEFINE_SFX(NA_SE_PL_DUMMY_355, 0x30, 0, 0, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x964 */ DEFINE_SFX(NA_SE_PL_DUMMY_356, 0x30, 0, 0, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x965 */ DEFINE_SFX(NA_SE_PL_DUMMY_357, 0x30, 0, 0, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x966 */ DEFINE_SFX(NA_SE_PL_DUMMY_358, 0x30, 0, 0, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x967 */ DEFINE_SFX(NA_SE_PL_DUMMY_359, 0x30, 0, 0, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x968 */ DEFINE_SFX(NA_SE_PL_DUMMY_360, 0x30, 0, 0, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x969 */ DEFINE_SFX(NA_SE_PL_DUMMY_361, 0x30, 0, 0, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x96A */ DEFINE_SFX(NA_SE_PL_DUMMY_362, 0x30, 0, 0, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x96B */ DEFINE_SFX(NA_SE_PL_DUMMY_363, 0x30, 0, 0, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x96C */ DEFINE_SFX(NA_SE_PL_DUMMY_364, 0x30, 0, 0, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x96D */ DEFINE_SFX(NA_SE_PL_DUMMY_365, 0x30, 0, 0, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x96E */ DEFINE_SFX(NA_SE_PL_DUMMY_366, 0x30, 0, 0, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x96F */ DEFINE_SFX(NA_SE_PL_DUMMY_367, 0x30, 0, 0, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x970 */ DEFINE_SFX(NA_SE_EV_MARATHONMAN_LAND, 0x40, 0, 1, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x971 */ DEFINE_SFX(NA_SE_PL_DUMMY_369, 0x40, 0, 1, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x972 */ DEFINE_SFX(NA_SE_PL_DUMMY_370, 0x40, 0, 1, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x973 */ DEFINE_SFX(NA_SE_PL_DUMMY_371, 0x40, 0, 1, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x974 */ DEFINE_SFX(NA_SE_PL_DUMMY_372, 0x40, 0, 1, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x975 */ DEFINE_SFX(NA_SE_PL_DUMMY_373, 0x40, 0, 1, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x976 */ DEFINE_SFX(NA_SE_PL_DUMMY_374, 0x40, 0, 1, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x977 */ DEFINE_SFX(NA_SE_PL_DUMMY_375, 0x40, 0, 1, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x978 */ DEFINE_SFX(NA_SE_PL_DUMMY_376, 0x40, 0, 1, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x979 */ DEFINE_SFX(NA_SE_PL_DUMMY_377, 0x40, 0, 1, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x97A */ DEFINE_SFX(NA_SE_PL_DUMMY378, 0x40, 0, 1, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x97B */ DEFINE_SFX(NA_SE_PL_DUMMY_379, 0x40, 0, 1, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x97C */ DEFINE_SFX(NA_SE_PL_DUMMY_380, 0x40, 0, 1, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x97D */ DEFINE_SFX(NA_SE_PL_DUMMY_381, 0x40, 0, 1, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x97E */ DEFINE_SFX(NA_SE_PL_DUMMY_382, 0x40, 0, 1, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x97F */ DEFINE_SFX(NA_SE_PL_DUMMY_383, 0x40, 0, 1, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x980 */ DEFINE_SFX(NA_SE_PL_GORON_CHG_ROLL, 0x30, 0, 0, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x981 */ DEFINE_SFX(NA_SE_PL_DUMMY_385, 0x30, 0, 0, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x982 */ DEFINE_SFX(NA_SE_PL_DUMMY_386, 0x30, 0, 0, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x983 */ DEFINE_SFX(NA_SE_PL_DUMMY_387, 0x30, 0, 0, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x984 */ DEFINE_SFX(NA_SE_PL_DUMMY_388, 0x30, 0, 0, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x985 */ DEFINE_SFX(NA_SE_PL_DUMMY_389, 0x30, 0, 0, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x986 */ DEFINE_SFX(NA_SE_PL_DUMMY_390, 0x30, 0, 0, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x987 */ DEFINE_SFX(NA_SE_PL_DUMMY_391, 0x30, 0, 0, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x988 */ DEFINE_SFX(NA_SE_PL_DUMMY_392, 0x30, 0, 0, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x989 */ DEFINE_SFX(NA_SE_PL_DUMMY_393, 0x30, 0, 0, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x98A */ DEFINE_SFX(NA_SE_PL_DUMMY_394, 0x30, 0, 0, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x98B */ DEFINE_SFX(NA_SE_PL_DUMMY_395, 0x30, 0, 0, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x98C */ DEFINE_SFX(NA_SE_PL_DUMMY_396, 0x30, 0, 0, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x98D */ DEFINE_SFX(NA_SE_PL_DUMMY_397, 0x30, 0, 0, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x98E */ DEFINE_SFX(NA_SE_PL_DUMMY_398, 0x30, 0, 0, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x98F */ DEFINE_SFX(NA_SE_PL_GORON_CHG_ROLL_ICE, 0x30, 0, 0, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x990 */ DEFINE_SFX(NA_SE_PL_GORON_ROLL, 0x30, 0, 0, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x991 */ DEFINE_SFX(NA_SE_PL_DUMMY_401, 0x30, 0, 0, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x992 */ DEFINE_SFX(NA_SE_PL_DUMMY_402, 0x50, 0, 0, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x993 */ DEFINE_SFX(NA_SE_PL_DUMMY_403, 0x50, 0, 0, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x994 */ DEFINE_SFX(NA_SE_PL_DUMMY_404, 0x30, 0, 0, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x995 */ DEFINE_SFX(NA_SE_PL_DUMMY_405, 0x30, 0, 0, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x996 */ DEFINE_SFX(NA_SE_PL_DUMMY_406, 0x30, 0, 0, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x997 */ DEFINE_SFX(NA_SE_PL_DUMMY_407, 0x30, 0, 0, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x998 */ DEFINE_SFX(NA_SE_PL_DUMMY_408, 0x30, 0, 0, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x999 */ DEFINE_SFX(NA_SE_PL_DUMMY_409, 0x30, 0, 0, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x99A */ DEFINE_SFX(NA_SE_PL_DUMMY_410, 0x30, 0, 0, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x99B */ DEFINE_SFX(NA_SE_PL_DUMMY_411, 0x30, 0, 0, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x99C */ DEFINE_SFX(NA_SE_PL_DUMMY_412, 0x30, 0, 0, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x99D */ DEFINE_SFX(NA_SE_PL_DUMMY_413, 0x30, 0, 0, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x99E */ DEFINE_SFX(NA_SE_PL_DUMMY_414, 0x30, 0, 0, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x99F */ DEFINE_SFX(NA_SE_PL_GORON_ROLL_ICE, 0x30, 0, 0, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x9A0 */ DEFINE_SFX(NA_SE_PL_DEKUNUTS_BUD, 0x30, 0, 0, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x9A1 */ DEFINE_SFX(NA_SE_PL_DEKUNUTS_BUBLE_BREATH, 0x30, 0, 0, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x9A2 */ DEFINE_SFX(NA_SE_PL_GORON_BALL_CHARGE_FAILED, 0x30, 0, 0, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x9A3 */ DEFINE_SFX(NA_SE_PL_GORON_BALL_CHARGE_DASH, 0x60, 0, 0, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x9A4 */ DEFINE_SFX(NA_SE_PL_FACE_CHANGE, 0x30, 0, 0, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x9A5 */ DEFINE_SFX(NA_SE_PL_FACE_UP_S, 0x30, 0, 0, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x9A6 */ DEFINE_SFX(NA_SE_PL_DEKUNUTS_STRUGGLE, 0x30, 0, 0, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x9A7 */ DEFINE_SFX(NA_SE_PL_WARP_PLATE, 0x30, 0, 0, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x9A8 */ DEFINE_SFX(NA_SE_PL_WARP_PLATE_OUT, 0x30, 0, 0, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x9A9 */ DEFINE_SFX(NA_SE_PL_DEKUNUTS_ATTACK, 0x30, 0, 0, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x9AA */ DEFINE_SFX(NA_SE_PL_TRANSFORM_VOICE, 0x30, 0, 0, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x9AB */ DEFINE_SFX(NA_SE_PL_FACE_RETURN, 0x30, 0, 0, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x9AC */ DEFINE_SFX(NA_SE_PL_DEKUNUTS_DROP_BOMB, 0x30, 0, 0, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x9AD */ DEFINE_SFX(NA_SE_PL_GORON_SLIP, 0x30, 0, 0, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x9AE */ DEFINE_SFX(NA_SE_PL_ROLL_SNOW_DUST, 0x30, 0, 2, 0, SFX_PARAM_RAND_FREQ_LOWER) +/* 0x9AF */ DEFINE_SFX(NA_SE_PL_ZORA_SPARK_BARRIER, 0x40, 3, 0, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x9B0 */ DEFINE_SFX(NA_SE_PL_DEKUNUTS_JUMP, 0x30, 0, 0, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x9B1 */ DEFINE_SFX(NA_SE_PL_DEKUNUTS_JUMP2, 0x30, 0, 0, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x9B2 */ DEFINE_SFX(NA_SE_PL_DEKUNUTS_JUMP3, 0x30, 0, 0, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x9B3 */ DEFINE_SFX(NA_SE_PL_DEKUNUTS_JUMP4, 0x30, 0, 0, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x9B4 */ DEFINE_SFX(NA_SE_PL_DEKUNUTS_JUMP5, 0x30, 0, 0, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x9B5 */ DEFINE_SFX(NA_SE_PL_DEKUNUTS_JUMP6, 0x30, 0, 0, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x9B6 */ DEFINE_SFX(NA_SE_PL_DEKUNUTS_JUMP7, 0x30, 0, 0, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x9B7 */ DEFINE_SFX(NA_SE_PL_DEKUNUTS_JUMP8, 0x30, 0, 0, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x9B8 */ DEFINE_SFX(NA_SE_PL_GORON_STOMACH_EXPLOSION, 0x30, 0, 0, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x9B9 */ DEFINE_SFX(NA_SE_PL_GORON_DRINK_BOMB, 0x30, 0, 0, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x9BA */ DEFINE_SFX(NA_SE_PL_GET_UP, 0x30, 0, 0, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x9BB */ DEFINE_SFX(NA_SE_PL_WARP_WING_OPEN, 0x30, 0, 0, 0, SFX_FLAG_VOLUME_NO_DIST | SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x9BC */ DEFINE_SFX(NA_SE_PL_WARP_WING_CLOSE, 0x30, 0, 0, 0, SFX_FLAG_VOLUME_NO_DIST | SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x9BD */ DEFINE_SFX(NA_SE_PL_WARP_WING_ROLL, 0x30, 0, 0, 0, SFX_FLAG_VOLUME_NO_DIST | SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x9BE */ DEFINE_SFX(NA_SE_PL_WARP_WING_VANISH, 0x30, 0, 0, 0, SFX_FLAG_VOLUME_NO_DIST | SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x9BF */ DEFINE_SFX(NA_SE_PL_DEKUNUTS_MISS_FIRE, 0x30, 0, 0, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x9C0 */ DEFINE_SFX(NA_SE_PL_FLYING_AIR, 0x30, 0, 0, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x9C1 */ DEFINE_SFX(NA_SE_PL_FIREWORKS, 0x30, 3, 1, 0, 0) +/* 0x9C2 */ DEFINE_SFX(NA_SE_PL_FIREWORKS_DUMMY, 0x30, 3, 1, 0, 0) +/* 0x9C3 */ DEFINE_SFX(NA_SE_PL_PULL_UP_SNOWBALL, 0x30, 0, 0, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x9C4 */ DEFINE_SFX(NA_SE_PL_WARP_WING_ROLL_2, 0x30, 0, 0, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x9C5 */ DEFINE_SFX(NA_SE_PL_TRANSFORM_GIANT, 0x30, 0, 0, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x9C6 */ DEFINE_SFX(NA_SE_PL_TRANSFORM_NORAML, 0x30, 0, 0, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x9C7 */ DEFINE_SFX(NA_SE_PL_LI_OKARINATORI, 0x30, 0, 0, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x9C8 */ DEFINE_SFX(NA_SE_PL_LI_FUTTOBI, 0x30, 0, 0, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x9C9 */ DEFINE_SFX(NA_SE_PL_LI_OP_OKIAGARI, 0x30, 0, 0, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x9CA */ DEFINE_SFX(NA_SE_PL_LI_OP_TATIAGARI, 0x30, 0, 0, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x9CB */ DEFINE_SFX(NA_SE_PL_JUMP_METAL, 0x30, 0, 0, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x9CC */ DEFINE_SFX(NA_SE_PL_LAND_METAL, 0x30, 0, 0, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x9CD */ DEFINE_SFX(NA_SE_PL_BOUND_METAL, 0x30, 0, 0, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x9CE */ DEFINE_SFX(NA_SE_PL_WALK_WALL, 0x30, 0, 0, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x9CF */ DEFINE_SFX(NA_SE_PL_WALK_WALL_DEKU, 0x30, 0, 0, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) diff --git a/include/tables/sfx/systembank_table.h b/include/tables/sfx/systembank_table.h new file mode 100644 index 000000000..9d27d5d49 --- /dev/null +++ b/include/tables/sfx/systembank_table.h @@ -0,0 +1,109 @@ +/** + * Sfx System Bank + * + * DEFINE_SFX should be used for all sfx define in the system bank from sequence 0 + * - Argument 0: Enum value for this sfx + * - Argument 1: Importance for deciding which sfx to prioritize. Higher values have greater importance + * - Argument 2: Slows the decay of volume with distance (a 3-bit number ranging from 0-7) + * - Argument 3: Applies increasingly random offsets to frequency (a 2-bit number ranging from 0-3) + * - Argument 4: Various flags to add properties to the sfx + * - Argument 5: Various flags to add properties to the sfx + * + * WARNING: entries must align with the table defined for the system bank in sequence 0 + */ +/* 0x4800 */ DEFINE_SFX(NA_SE_SY_WIN_OPEN, 0xC0, 0, 0, 0, 0) +/* 0x4801 */ DEFINE_SFX(NA_SE_SY_WIN_CLOSE, 0xC0, 0, 0, 0, 0) +/* 0x4802 */ DEFINE_SFX(NA_SE_SY_CORRECT_CHIME, 0xB0, 0, 0, 0, SFX_FLAG_BLOCK_EQUAL_IMPORTANCE) +/* 0x4803 */ DEFINE_SFX(NA_SE_SY_GET_RUPY, 0x30, 0, 0, 0, 0) +/* 0x4804 */ DEFINE_SFX(NA_SE_SY_MESSAGE_WOMAN, 0x30, 0, 0, 0, 0) +/* 0x4805 */ DEFINE_SFX(NA_SE_SY_MESSAGE_MAN, 0x30, 0, 0, 0, 0) +/* 0x4806 */ DEFINE_SFX(NA_SE_SY_ERROR, 0x50, 0, 0, 0, 0) +/* 0x4807 */ DEFINE_SFX(NA_SE_SY_TRE_BOX_APPEAR, 0x30, 0, 0, 0, SFX_FLAG_BLOCK_EQUAL_IMPORTANCE) +/* 0x4808 */ DEFINE_SFX(NA_SE_SY_DECIDE, 0x30, 0, 0, 0, 0) +/* 0x4809 */ DEFINE_SFX(NA_SE_SY_CURSOR, 0x30, 0, 0, 0, 0) +/* 0x480A */ DEFINE_SFX(NA_SE_SY_CANCEL, 0x30, 0, 0, 0, 0) +/* 0x480B */ DEFINE_SFX(NA_SE_SY_HP_RECOVER, 0x30, 0, 0, 0, 0) +/* 0x480C */ DEFINE_SFX(NA_SE_SY_ATTENTION_ON, 0x20, 0, 0, 0, 0) +/* 0x480D */ DEFINE_SFX(NA_SE_SY_DUMMY_13, 0x30, 0, 0, 0, 0) +/* 0x480E */ DEFINE_SFX(NA_SE_SY_DUMMY_14, 0x30, 0, 0, 0, 0) +/* 0x480F */ DEFINE_SFX(NA_SE_SY_LOCK_OFF, 0x30, 0, 0, 0, 0) +/* 0x4810 */ DEFINE_SFX(NA_SE_SY_LOCK_ON_HUMAN, 0x28, 0, 0, 0, 0) +/* 0x4811 */ DEFINE_SFX(NA_SE_SY_DUMMY_17, 0x30, 0, 0, 0, 0) +/* 0x4812 */ DEFINE_SFX(NA_SE_SY_DUMMY_18, 0x30, 0, 0, 0, 0) +/* 0x4813 */ DEFINE_SFX(NA_SE_SY_CAMERA_ZOOM_UP, 0x30, 0, 0, 0, 0) +/* 0x4814 */ DEFINE_SFX(NA_SE_SY_CAMERA_ZOOM_DOWN, 0x30, 0, 0, 0, 0) +/* 0x4815 */ DEFINE_SFX(NA_SE_SY_DUMMY_21, 0x30, 0, 0, 0, 0) +/* 0x4816 */ DEFINE_SFX(NA_SE_SY_DUMMY_22, 0x30, 0, 0, 0, 0) +/* 0x4817 */ DEFINE_SFX(NA_SE_SY_ATTENTION_ON_OLD, 0x30, 0, 0, 0, 0) +/* 0x4818 */ DEFINE_SFX(NA_SE_SY_MESSAGE_PASS, 0x18, 0, 0, 0, 0) +/* 0x4819 */ DEFINE_SFX(NA_SE_SY_WARNING_COUNT_N, 0x2C, 0, 0, 0, 0) +/* 0x481A */ DEFINE_SFX(NA_SE_SY_WARNING_COUNT_E, 0x2C, 0, 0, 0, 0) +/* 0x481B */ DEFINE_SFX(NA_SE_SY_HITPOINT_ALARM, 0x20, 0, 0, 0, 0) +/* 0x481C */ DEFINE_SFX(NA_SE_SY_DUMMY_28, 0x30, 0, 0, 0, 0) +/* 0x481D */ DEFINE_SFX(NA_SE_SY_DEMO_CUT, 0x30, 0, 0, 0, 0) +/* 0x481E */ DEFINE_SFX(NA_SE_SY_NAVY_CALL, 0x30, 0, 0, 0, 0) +/* 0x481F */ DEFINE_SFX(NA_SE_SY_GAUGE_UP, 0x30, 0, 0, 0, 0) +/* 0x4820 */ DEFINE_SFX(NA_SE_SY_DUMMY_32, 0x30, 0, 0, 0, 0) +/* 0x4821 */ DEFINE_SFX(NA_SE_SY_DUMMY_33, 0x30, 0, 0, 0, 0) +/* 0x4822 */ DEFINE_SFX(NA_SE_SY_DUMMY_34, 0x30, 0, 0, 0, 0) +/* 0x4823 */ DEFINE_SFX(NA_SE_SY_PIECE_OF_HEART, 0x30, 0, 0, 0, 0) +/* 0x4824 */ DEFINE_SFX(NA_SE_SY_GET_ITEM, 0x30, 0, 0, 0, 0) +/* 0x4825 */ DEFINE_SFX(NA_SE_SY_WIN_SCROLL_LEFT, 0x30, 0, 0, 0, 0) +/* 0x4826 */ DEFINE_SFX(NA_SE_SY_WIN_SCROLL_RIGHT, 0x30, 0, 0, 0, 0) +/* 0x4827 */ DEFINE_SFX(NA_SE_SY_OCARINA_ERROR, 0x20, 0, 0, 0, 0) +/* 0x4828 */ DEFINE_SFX(NA_SE_SY_CAMERA_ZOOM_UP_2, 0x30, 0, 0, 0, 0) +/* 0x4829 */ DEFINE_SFX(NA_SE_SY_CAMERA_ZOOM_DOWN_2, 0x30, 0, 0, 0, 0) +/* 0x482A */ DEFINE_SFX(NA_SE_SY_GLASSMODE_ON, 0x30, 0, 0, 0, 0) +/* 0x482B */ DEFINE_SFX(NA_SE_SY_GLASSMODE_OFF, 0x30, 0, 0, 0, 0) +/* 0x482C */ DEFINE_SFX(NA_SE_SY_FOUND, 0x60, 0, 0, 0, 0) +/* 0x482D */ DEFINE_SFX(NA_SE_SY_HIT_SOUND, 0x30, 0, 0, 0, 0) +/* 0x482E */ DEFINE_SFX(NA_SE_SY_MESSAGE_END, 0x30, 0, 0, 0, 0) +/* 0x482F */ DEFINE_SFX(NA_SE_SY_RUPY_COUNT, 0x30, 0, 0, 0, 0) +/* 0x4830 */ DEFINE_SFX(NA_SE_SY_LOCK_ON, 0x30, 0, 0, 0, 0) +/* 0x4831 */ DEFINE_SFX(NA_SE_SY_GET_BOXITEM, 0x30, 0, 0, 0, 0) +/* 0x4832 */ DEFINE_SFX(NA_SE_SY_WHITE_OUT_INTO_MOON, 0x30, 0, 0, 0, 0) +/* 0x4833 */ DEFINE_SFX(NA_SE_SY_WHITE_OUT_S, 0x30, 0, 0, 0, 0) +/* 0x4834 */ DEFINE_SFX(NA_SE_SY_WHITE_OUT_T, 0x30, 0, 0, 0, 0) +/* 0x4835 */ DEFINE_SFX(NA_SE_SY_START_SHOT, 0x30, 0, 0, 0, 0) +/* 0x4836 */ DEFINE_SFX(NA_SE_SY_METRONOME, 0x30, 0, 0, 0, 0) +/* 0x4837 */ DEFINE_SFX(NA_SE_SY_ATTENTION_URGENCY, 0x30, 0, 0, 0, 0) +/* 0x4838 */ DEFINE_SFX(NA_SE_SY_METRONOME_LV, 0x30, 0, 0, 0, 0) +/* 0x4839 */ DEFINE_SFX(NA_SE_SY_FSEL_CURSOR, 0x30, 0, 0, 0, 0) +/* 0x483A */ DEFINE_SFX(NA_SE_SY_FSEL_DECIDE_S, 0x30, 0, 0, 0, 0) +/* 0x483B */ DEFINE_SFX(NA_SE_SY_FSEL_DECIDE_L, 0x30, 0, 0, 0, 0) +/* 0x483C */ DEFINE_SFX(NA_SE_SY_FSEL_CLOSE, 0x30, 0, 0, 0, 0) +/* 0x483D */ DEFINE_SFX(NA_SE_SY_FSEL_ERROR, 0x30, 0, 0, 0, 0) +/* 0x483E */ DEFINE_SFX(NA_SE_SY_SET_FIRE_ARROW, 0x30, 0, 0, 0, 0) +/* 0x483F */ DEFINE_SFX(NA_SE_SY_SET_ICE_ARROW, 0x30, 0, 0, 0, 0) +/* 0x4840 */ DEFINE_SFX(NA_SE_SY_SET_LIGHT_ARROW, 0x30, 0, 0, 0, 0) +/* 0x4841 */ DEFINE_SFX(NA_SE_SY_SYNTH_MAGIC_ARROW, 0x30, 0, 0, 0, 0) +/* 0x4842 */ DEFINE_SFX(NA_SE_SY_METRONOME_2, 0x30, 0, 0, 0, 0) +/* 0x4843 */ DEFINE_SFX(NA_SE_SY_KINSTA_MARK_APPEAR, 0x30, 0, 0, 0, 0) +/* 0x4844 */ DEFINE_SFX(NA_SE_SY_FIVE_COUNT_LUPY, 0x30, 0, 0, 0, 0) +/* 0x4845 */ DEFINE_SFX(NA_SE_SY_CARROT_RECOVER, 0x30, 0, 0, 0, 0) +/* 0x4846 */ DEFINE_SFX(NA_SE_EV_FAIVE_LUPY_COUNT, 0x30, 0, 0, 0, 0) +/* 0x4847 */ DEFINE_SFX(NA_SE_SY_METRONOME_TEMPO, 0x30, 0, 0, 0, 0) +/* 0x4848 */ DEFINE_SFX(NA_SE_SY_COMICAL_SOUND0_0, 0x30, 0, 0, 0, 0) +/* 0x4849 */ DEFINE_SFX(NA_SE_SY_COMICAL_SOUND0_1, 0x30, 0, 0, 0, 0) +/* 0x484A */ DEFINE_SFX(NA_SE_SY_COMICAL_SOUND0_LAST, 0x30, 0, 0, 0, 0) +/* 0x484B */ DEFINE_SFX(NA_SE_SY_SOUT_DEMO, 0x30, 0, 0, 0, 0) +/* 0x484C */ DEFINE_SFX(NA_SE_SY_TIMESIGNAL_BELL, 0x30, 0, 0, 0, 0) +/* 0x484D */ DEFINE_SFX(NA_SE_SY_DEKUNUTS_JUMP_FAILED, 0x30, 0, 0, 0, 0) +/* 0x484E */ DEFINE_SFX(NA_SE_SY_ATTENTION_SOUND, 0x30, 0, 0, 0, 0) +/* 0x484F */ DEFINE_SFX(NA_SE_SY_TRANSFORM_MASK_FLASH, 0x30, 0, 0, 0, 0) +/* 0x4850 */ DEFINE_SFX(NA_SE_SY_CAMERA_SHUTTER, 0x30, 0, 0, 0, 0) +/* 0x4851 */ DEFINE_SFX(NA_SE_SY_STALKIDS_PSYCHO, 0x60, 0, 0, 0, 0) +/* 0x4852 */ DEFINE_SFX(NA_SE_SY_CHICK_JOIN_CHIME, 0x30, 0, 0, 0, 0) +/* 0x4853 */ DEFINE_SFX(NA_SE_SY_HIT_SOUND_L, 0x30, 0, 0, 0, 0) +/* 0x4854 */ DEFINE_SFX(NA_SE_SY_FAIRY_MASK_SUCCESS, 0x30, 0, 0, 0, SFX_FLAG_BLOCK_EQUAL_IMPORTANCE) +/* 0x4855 */ DEFINE_SFX(NA_SE_SY_SCHEDULE_WRITE, 0x60, 0, 0, 0, 0) +/* 0x4856 */ DEFINE_SFX(NA_SE_SY_STOPWATCH_TIMER_3, 0x30, 0, 0, 0, 0) +/* 0x4857 */ DEFINE_SFX(NA_SE_SY_STOPWATCH_TIMER_INF, 0x30, 0, 0, 0, 0) +/* 0x4858 */ DEFINE_SFX(NA_SE_SY_EARTHQUAKE_OUTDOOR, 0x30, 0, 0, 0, 0) +/* 0x4859 */ DEFINE_SFX(NA_SE_SY_SPIRAL_DASH, 0x30, 0, 0, 0, 0) +/* 0x485A */ DEFINE_SFX(NA_SE_SY_QUIZ_CORRECT, 0x30, 0, 0, 0, 0) +/* 0x485B */ DEFINE_SFX(NA_SE_SY_QUIZ_INCORRECT, 0x30, 0, 0, 0, 0) +/* 0x485C */ DEFINE_SFX(NA_SE_SY_DIZZY_EFFECT, 0x30, 0, 0, 0, 0) +/* 0x485D */ DEFINE_SFX(NA_SE_SY_TIME_CONTROL_SLOW, 0xA0, 0, 0, 0, SFX_FLAG_LOWER_VOLUME_BGM) +/* 0x485E */ DEFINE_SFX(NA_SE_SY_TIME_CONTROL_NORMAL, 0xA0, 0, 0, 0, SFX_FLAG_LOWER_VOLUME_BGM) +/* 0x485F */ DEFINE_SFX(NA_SE_SY_SECOM_WARNING, 0x30, 0, 0, 0, 0) diff --git a/include/tables/sfx/voicebank_table.h b/include/tables/sfx/voicebank_table.h new file mode 100644 index 000000000..d2ce5aae3 --- /dev/null +++ b/include/tables/sfx/voicebank_table.h @@ -0,0 +1,413 @@ +/** + * Sfx Voice Bank + * + * DEFINE_SFX should be used for all sfx define in the voice bank from sequence 0 + * - Argument 0: Enum value for this sfx + * - Argument 1: Importance for deciding which sfx to prioritize. Higher values have greater importance + * - Argument 2: Slows the decay of volume with distance (a 3-bit number ranging from 0-7) + * - Argument 3: Applies increasingly random offsets to frequency (a 2-bit number ranging from 0-3) + * - Argument 4: Various flags to add properties to the sfx + * - Argument 5: Various flags to add properties to the sfx + * + * WARNING: entries must align with the table defined for the voice bank in sequence 0 + */ +/* 0x6800 */ DEFINE_SFX(NA_SE_VO_LI_SWORD_N, 0x30, 2, 0, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x6801 */ DEFINE_SFX(NA_SE_VO_LI_SWORD_L, 0x30, 2, 0, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x6802 */ DEFINE_SFX(NA_SE_VO_LI_LASH, 0x30, 2, 0, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x6803 */ DEFINE_SFX(NA_SE_VO_LI_HANG, 0x20, 2, 0, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x6804 */ DEFINE_SFX(NA_SE_VO_LI_CLIMB_END, 0x30, 2, 0, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x6805 */ DEFINE_SFX(NA_SE_VO_LI_DAMAGE_S, 0x30, 2, 0, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x6806 */ DEFINE_SFX(NA_SE_VO_LI_FREEZE, 0x30, 2, 0, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x6807 */ DEFINE_SFX(NA_SE_VO_LI_FALL_S, 0x30, 2, 0, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x6808 */ DEFINE_SFX(NA_SE_VO_LI_FALL_L, 0x30, 2, 0, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x6809 */ DEFINE_SFX(NA_SE_VO_LI_BREATH_REST, 0x30, 2, 1, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x680A */ DEFINE_SFX(NA_SE_VO_LI_BREATH_DRINK, 0x30, 2, 1, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x680B */ DEFINE_SFX(NA_SE_VO_LI_DOWN, 0x30, 2, 0, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x680C */ DEFINE_SFX(NA_SE_VO_LI_TAKEN_AWAY, 0x30, 2, 0, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x680D */ DEFINE_SFX(NA_SE_VO_LI_HELD, 0x50, 2, 0, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x680E */ DEFINE_SFX(NA_SE_VO_LI_SNEEZE, 0x30, 2, 0, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x680F */ DEFINE_SFX(NA_SE_VO_LI_SWEAT, 0x30, 2, 0, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x6810 */ DEFINE_SFX(NA_SE_VO_LI_DRINK, 0x30, 2, 0, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x6811 */ DEFINE_SFX(NA_SE_VO_LI_RELAX, 0x30, 2, 0, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x6812 */ DEFINE_SFX(NA_SE_VO_LI_SWORD_PUTAWAY, 0x30, 2, 0, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x6813 */ DEFINE_SFX(NA_SE_VO_LI_GROAN, 0x30, 2, 0, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x6814 */ DEFINE_SFX(NA_SE_VO_LI_AUTO_JUMP, 0x30, 2, 0, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x6815 */ DEFINE_SFX(NA_SE_VO_LI_MAGIC_NALE, 0x30, 2, 0, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x6816 */ DEFINE_SFX(NA_SE_VO_LI_SURPRISE, 0x30, 2, 0, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x6817 */ DEFINE_SFX(NA_SE_VO_LI_MAGIC_FROL, 0x30, 2, 0, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x6818 */ DEFINE_SFX(NA_SE_VO_LI_PUSH, 0x30, 2, 2, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x6819 */ DEFINE_SFX(NA_SE_VO_LI_HOOKSHOT_HANG, 0x30, 2, 0, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x681A */ DEFINE_SFX(NA_SE_VO_LI_LAND_DAMAGE_S, 0x30, 2, 0, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x681B */ DEFINE_SFX(NA_SE_VO_LI_MAGIC_START, 0x30, 2, 0, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x681C */ DEFINE_SFX(NA_SE_VO_LI_MAGIC_ATTACK, 0x30, 2, 0, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x681D */ DEFINE_SFX(NA_SE_VO_BL_DOWN, 0x80, 2, 0, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x681E */ DEFINE_SFX(NA_SE_VO_LI_DEMO_DAMAGE, 0x30, 2, 0, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x681F */ DEFINE_SFX(NA_SE_VO_LI_SWORD_N_copy30, 0x30, 2, 0, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x6820 */ DEFINE_SFX(NA_SE_VO_DUMMY_32, 0x30, 2, 0, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x6821 */ DEFINE_SFX(NA_SE_VO_DUMMY_33, 0x30, 2, 0, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x6822 */ DEFINE_SFX(NA_SE_VO_DUMMY_34, 0x30, 2, 0, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x6823 */ DEFINE_SFX(NA_SE_VO_DUMMY_35, 0x20, 2, 0, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x6824 */ DEFINE_SFX(NA_SE_VO_DUMMY_36, 0x30, 2, 0, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x6825 */ DEFINE_SFX(NA_SE_VO_DUMMY_37, 0x30, 2, 0, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x6826 */ DEFINE_SFX(NA_SE_VO_DUMMY_38, 0x30, 2, 0, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x6827 */ DEFINE_SFX(NA_SE_VO_DUMMY_39, 0x30, 2, 0, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x6828 */ DEFINE_SFX(NA_SE_VO_NAVY_ENEMY, 0x30, 2, 0, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x6829 */ DEFINE_SFX(NA_SE_VO_NAVY_HELLO, 0x30, 2, 1, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x682A */ DEFINE_SFX(NA_SE_VO_NAVY_HEAR, 0x30, 2, 1, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x682B */ DEFINE_SFX(NA_SE_VO_DUMMY_43, 0x30, 2, 0, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x682C */ DEFINE_SFX(NA_SE_VO_DUMMY_44, 0x30, 2, 0, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x682D */ DEFINE_SFX(NA_SE_VO_DUMMY_45, 0x50, 2, 0, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x682E */ DEFINE_SFX(NA_SE_VO_DUMMY_46, 0x30, 2, 0, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x682F */ DEFINE_SFX(NA_SE_VO_DUMMY_47, 0x30, 2, 0, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x6830 */ DEFINE_SFX(NA_SE_VO_DUMMY_48, 0x30, 2, 0, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x6831 */ DEFINE_SFX(NA_SE_VO_DUMMY_49, 0x30, 2, 0, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x6832 */ DEFINE_SFX(NA_SE_VO_DUMMY_50, 0x30, 2, 0, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x6833 */ DEFINE_SFX(NA_SE_VO_DUMMY_51, 0x30, 2, 0, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x6834 */ DEFINE_SFX(NA_SE_VO_DUMMY_52, 0x30, 2, 0, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x6835 */ DEFINE_SFX(NA_SE_VO_DUMMY_53, 0x30, 2, 0, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x6836 */ DEFINE_SFX(NA_SE_VO_DUMMY_54, 0x30, 2, 0, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x6837 */ DEFINE_SFX(NA_SE_VO_DUMMY_55, 0x30, 2, 0, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x6838 */ DEFINE_SFX(NA_SE_VO_DUMMY_56, 0x30, 1, 2, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x6839 */ DEFINE_SFX(NA_SE_VO_DUMMY_57, 0x30, 2, 0, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x683A */ DEFINE_SFX(NA_SE_VO_DUMMY_58, 0x30, 2, 0, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x683B */ DEFINE_SFX(NA_SE_VO_DUMMY_59, 0x30, 2, 0, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x683C */ DEFINE_SFX(NA_SE_VO_DUMMY_60, 0x30, 2, 0, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x683D */ DEFINE_SFX(NA_SE_VO_DUMMY_61, 0x30, 2, 0, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x683E */ DEFINE_SFX(NA_SE_VO_DUMMY_62, 0x30, 2, 0, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x683F */ DEFINE_SFX(NA_SE_VO_DUMMY_63, 0x30, 2, 0, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x6840 */ DEFINE_SFX(NA_SE_VO_LK_WAKE_UP, 0x30, 2, 0, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x6841 */ DEFINE_SFX(NA_SE_VO_LK_CATCH_DEMO, 0x30, 2, 0, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x6842 */ DEFINE_SFX(NA_SE_VO_LK_DRAGGED_DAMAGE, 0x30, 0, 0, 0, 0) +/* 0x6843 */ DEFINE_SFX(NA_SE_VO_NAVY_CALL, 0x60, 0, 0, 0, SFX_FLAG_BLOCK_EQUAL_IMPORTANCE) +/* 0x6844 */ DEFINE_SFX(NA_SE_VO_NA_HELLO_3, 0x30, 0, 0, 0, 0) +/* 0x6845 */ DEFINE_SFX(NA_SE_VO_CHAT_MESSAGE_CALL, 0x30, 0, 0, 0, 0) +/* 0x6846 */ DEFINE_SFX(NA_SE_VO_BELL_MESSAGE, 0x30, 0, 0, 0, 0) +/* 0x6847 */ DEFINE_SFX(NA_SE_VO_MONDO_MESSAGE, 0x30, 0, 0, 0, 0) +/* 0x6848 */ DEFINE_SFX(NA_SE_VO_LK_USING_UP_ENERGY, 0x30, 0, 0, 0, 0) +/* 0x6849 */ DEFINE_SFX(NA_SE_VO_DUMMY_73, 0x30, 0, 0, 0, 0) +/* 0x684A */ DEFINE_SFX(NA_SE_VO_GO_SLEEP, 0x30, 0, 0, 0, 0) +/* 0x684B */ DEFINE_SFX(NA_SE_VO_NP_SLEEP_OUT, 0x30, 0, 0, 0, 0) +/* 0x684C */ DEFINE_SFX(NA_SE_VO_DUMMY_76, 0x30, 0, 0, 0, 0) +/* 0x684D */ DEFINE_SFX(NA_SE_VO_DUMMY_77, 0x30, 0, 0, 0, 0) +/* 0x684E */ DEFINE_SFX(NA_SE_VO_NP_DRINK, 0x30, 0, 0, 0, 0) +/* 0x684F */ DEFINE_SFX(NA_SE_VO_DUMMY_79, 0x30, 0, 0, 0, 0) +/* 0x6850 */ DEFINE_SFX(NA_SE_VO_NARRATION_0, 0x30, 0, 0, 0, 0) +/* 0x6851 */ DEFINE_SFX(NA_SE_VO_TA_SURPRISE, 0x30, 0, 0, 0, 0) +/* 0x6852 */ DEFINE_SFX(NA_SE_VO_TA_CRY_0, 0x30, 1, 1, 0, SFX_FLAG_FREQ_NO_DIST) +/* 0x6853 */ DEFINE_SFX(NA_SE_VO_TA_CRY_1, 0x30, 1, 1, 0, SFX_FLAG_FREQ_NO_DIST) +/* 0x6854 */ DEFINE_SFX(NA_SE_VO_IN_CRY_0, 0x30, 1, 1, 0, SFX_FLAG_FREQ_NO_DIST) +/* 0x6855 */ DEFINE_SFX(NA_SE_VO_IN_LOST, 0x30, 1, 1, 0, SFX_FLAG_FREQ_NO_DIST) +/* 0x6856 */ DEFINE_SFX(NA_SE_VO_IN_LASH_0, 0x30, 1, 1, 0, SFX_FLAG_FREQ_NO_DIST) +/* 0x6857 */ DEFINE_SFX(NA_SE_VO_IN_LASH_1, 0x30, 1, 1, 0, SFX_FLAG_FREQ_NO_DIST) +/* 0x6858 */ DEFINE_SFX(NA_SE_VO_FR_LAUGH_0, 0x30, 1, 1, 0, SFX_FLAG_FREQ_NO_DIST) +/* 0x6859 */ DEFINE_SFX(NA_SE_VO_FR_SMILE_0, 0x30, 1, 1, 0, SFX_FLAG_FREQ_NO_DIST) +/* 0x685A */ DEFINE_SFX(NA_SE_VO_NB_AGONY, 0x30, 1, 1, 0, SFX_FLAG_FREQ_NO_DIST) +/* 0x685B */ DEFINE_SFX(NA_SE_VO_NB_CRY_0, 0x30, 1, 1, 0, SFX_FLAG_FREQ_NO_DIST) +/* 0x685C */ DEFINE_SFX(NA_SE_VO_NB_NOTICE, 0x30, 1, 1, 0, SFX_FLAG_FREQ_NO_DIST) +/* 0x685D */ DEFINE_SFX(NA_SE_VO_NA_HELLO_0, 0x30, 0, 0, 0, SFX_FLAG_FREQ_NO_DIST) +/* 0x685E */ DEFINE_SFX(NA_SE_VO_NA_HELLO_1, 0x30, 0, 0, 0, SFX_FLAG_FREQ_NO_DIST) +/* 0x685F */ DEFINE_SFX(NA_SE_VO_NA_HELLO_2, 0x30, 0, 0, 0, SFX_FLAG_FREQ_NO_DIST) +/* 0x6860 */ DEFINE_SFX(NA_SE_VO_RT_CRASH, 0x30, 1, 1, 0, SFX_FLAG_FREQ_NO_DIST) +/* 0x6861 */ DEFINE_SFX(NA_SE_VO_RT_DISCOVER, 0x30, 1, 1, 0, SFX_FLAG_FREQ_NO_DIST) +/* 0x6862 */ DEFINE_SFX(NA_SE_VO_RT_FALL, 0x30, 1, 1, 0, SFX_FLAG_FREQ_NO_DIST) +/* 0x6863 */ DEFINE_SFX(NA_SE_VO_RT_LAUGH_0, 0x30, 1, 1, 0, SFX_FLAG_FREQ_NO_DIST) +/* 0x6864 */ DEFINE_SFX(NA_SE_VO_RT_LIFT, 0x30, 1, 1, 0, SFX_FLAG_FREQ_NO_DIST) +/* 0x6865 */ DEFINE_SFX(NA_SE_VO_RT_THROW, 0x30, 1, 1, 0, SFX_FLAG_FREQ_NO_DIST) +/* 0x6866 */ DEFINE_SFX(NA_SE_VO_RT_UNBALLANCE, 0x30, 1, 1, 0, SFX_FLAG_FREQ_NO_DIST) +/* 0x6867 */ DEFINE_SFX(NA_SE_VO_ST_DAMAGE, 0x30, 1, 1, 0, SFX_FLAG_FREQ_NO_DIST) +/* 0x6868 */ DEFINE_SFX(NA_SE_VO_ST_ATTACK, 0x30, 1, 1, 0, SFX_FLAG_FREQ_NO_DIST) +/* 0x6869 */ DEFINE_SFX(NA_SE_VO_Z0_HURRY, 0x30, 1, 1, 0, SFX_FLAG_FREQ_NO_DIST) +/* 0x686A */ DEFINE_SFX(NA_SE_VO_Z0_MEET, 0x30, 1, 1, 0, SFX_FLAG_FREQ_NO_DIST) +/* 0x686B */ DEFINE_SFX(NA_SE_VO_Z0_QUESTION, 0x30, 1, 1, 0, SFX_FLAG_FREQ_NO_DIST) +/* 0x686C */ DEFINE_SFX(NA_SE_VO_Z0_SIGH_0, 0x30, 1, 1, 0, SFX_FLAG_FREQ_NO_DIST) +/* 0x686D */ DEFINE_SFX(NA_SE_VO_Z0_SMILE_0, 0x30, 1, 1, 0, SFX_FLAG_FREQ_NO_DIST) +/* 0x686E */ DEFINE_SFX(NA_SE_VO_Z0_SURPRISE, 0x30, 1, 1, 0, SFX_FLAG_FREQ_NO_DIST) +/* 0x686F */ DEFINE_SFX(NA_SE_VO_Z0_THROW, 0x30, 1, 1, 0, SFX_FLAG_FREQ_NO_DIST) +/* 0x6870 */ DEFINE_SFX(NA_SE_VO_SK_CRY_0, 0x30, 1, 1, 0, SFX_FLAG_FREQ_NO_DIST) +/* 0x6871 */ DEFINE_SFX(NA_SE_VO_SK_CRY_1, 0x30, 1, 1, 0, SFX_FLAG_FREQ_NO_DIST) +/* 0x6872 */ DEFINE_SFX(NA_SE_VO_SK_CRASH, 0x30, 1, 1, 0, SFX_FLAG_FREQ_NO_DIST) +/* 0x6873 */ DEFINE_SFX(NA_SE_VO_NA_LISTEN, 0x30, 1, 1, 0, SFX_FLAG_FREQ_NO_DIST) +/* 0x6874 */ DEFINE_SFX(NA_SE_VO_SK_SHOUT, 0x30, 1, 0, 0, SFX_FLAG_FREQ_NO_DIST) +/* 0x6875 */ DEFINE_SFX(NA_SE_VO_Z1_CRY_0, 0x30, 3, 1, 0, SFX_FLAG_FREQ_NO_DIST) +/* 0x6876 */ DEFINE_SFX(NA_SE_VO_Z1_CRY_1, 0x30, 3, 1, 0, SFX_FLAG_FREQ_NO_DIST) +/* 0x6877 */ DEFINE_SFX(NA_SE_VO_Z1_OPENDOOR, 0x30, 3, 1, 0, SFX_FLAG_FREQ_NO_DIST) +/* 0x6878 */ DEFINE_SFX(NA_SE_VO_FR_SMILE_1, 0x30, 1, 1, 0, SFX_FLAG_FREQ_NO_DIST) +/* 0x6879 */ DEFINE_SFX(NA_SE_VO_FR_SMILE_2, 0x30, 1, 1, 0, SFX_FLAG_FREQ_NO_DIST) +/* 0x687A */ DEFINE_SFX(NA_SE_VO_KZ_MOVE, 0x30, 1, 1, 0, SFX_FLAG_FREQ_NO_DIST) +/* 0x687B */ DEFINE_SFX(NA_SE_VO_NB_LAUGH, 0x30, 1, 1, 0, SFX_FLAG_FREQ_NO_DIST) +/* 0x687C */ DEFINE_SFX(NA_SE_VO_IN_JOY0, 0x30, 1, 1, 0, SFX_FLAG_FREQ_NO_DIST) +/* 0x687D */ DEFINE_SFX(NA_SE_VO_IN_JOY1, 0x30, 1, 1, 0, SFX_FLAG_FREQ_NO_DIST) +/* 0x687E */ DEFINE_SFX(NA_SE_VO_IN_JOY2, 0x30, 1, 1, 0, SFX_FLAG_FREQ_NO_DIST) +/* 0x687F */ DEFINE_SFX(NA_SE_VO_DUMMY_127, 0x30, 1, 1, 0, SFX_FLAG_FREQ_NO_DIST) +/* 0x6880 */ DEFINE_SFX(NA_SE_VO_DUMMY_128, 0x30, 2, 0, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x6881 */ DEFINE_SFX(NA_SE_VO_DUMMY_129, 0x30, 2, 0, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x6882 */ DEFINE_SFX(NA_SE_VO_DUMMY_130, 0x30, 2, 0, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x6883 */ DEFINE_SFX(NA_SE_VO_DUMMY_131, 0x20, 2, 0, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x6884 */ DEFINE_SFX(NA_SE_VO_DUMMY_132, 0x30, 2, 0, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x6885 */ DEFINE_SFX(NA_SE_VO_DUMMY_133, 0x30, 2, 0, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x6886 */ DEFINE_SFX(NA_SE_VO_DUMMY_134, 0x30, 2, 0, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x6887 */ DEFINE_SFX(NA_SE_VO_DUMMY_135, 0x30, 2, 0, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x6888 */ DEFINE_SFX(NA_SE_VO_DUMMY_136, 0x30, 2, 0, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x6889 */ DEFINE_SFX(NA_SE_VO_DUMMY_137, 0x30, 2, 1, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x688A */ DEFINE_SFX(NA_SE_VO_DUMMY_138, 0x30, 2, 1, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x688B */ DEFINE_SFX(NA_SE_VO_DUMMY_139, 0x30, 2, 0, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x688C */ DEFINE_SFX(NA_SE_VO_DUMMY_140, 0x30, 2, 0, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x688D */ DEFINE_SFX(NA_SE_VO_DUMMY_141, 0x50, 2, 0, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x688E */ DEFINE_SFX(NA_SE_VO_DUMMY_142, 0x30, 2, 0, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x688F */ DEFINE_SFX(NA_SE_VO_DUMMY_143, 0x30, 2, 0, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x6890 */ DEFINE_SFX(NA_SE_VO_DUMMY_144, 0x30, 2, 0, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x6891 */ DEFINE_SFX(NA_SE_VO_DUMMY_145, 0x30, 2, 0, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x6892 */ DEFINE_SFX(NA_SE_VO_DUMMY_146, 0x30, 2, 0, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x6893 */ DEFINE_SFX(NA_SE_VO_DUMMY_147, 0x30, 2, 0, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x6894 */ DEFINE_SFX(NA_SE_VO_DUMMY_148, 0x30, 2, 0, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x6895 */ DEFINE_SFX(NA_SE_VO_DUMMY_149, 0x30, 2, 0, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x6896 */ DEFINE_SFX(NA_SE_VO_DUMMY_150, 0x30, 2, 0, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x6897 */ DEFINE_SFX(NA_SE_VO_DUMMY_151, 0x30, 2, 0, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x6898 */ DEFINE_SFX(NA_SE_VO_DUMMY_152, 0x30, 1, 2, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x6899 */ DEFINE_SFX(NA_SE_VO_DUMMY_153, 0x30, 2, 0, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x689A */ DEFINE_SFX(NA_SE_VO_DUMMY_154, 0x30, 2, 0, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x689B */ DEFINE_SFX(NA_SE_VO_DUMMY_155, 0x30, 2, 0, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x689C */ DEFINE_SFX(NA_SE_VO_DUMMY_156, 0x30, 2, 0, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x689D */ DEFINE_SFX(NA_SE_VO_DUMMY_157, 0x30, 2, 0, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x689E */ DEFINE_SFX(NA_SE_VO_DUMMY_158, 0x30, 2, 0, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x689F */ DEFINE_SFX(NA_SE_VO_DUMMY_159, 0x30, 2, 0, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x68A0 */ DEFINE_SFX(NA_SE_VO_DUMMY_160, 0x30, 2, 0, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x68A1 */ DEFINE_SFX(NA_SE_VO_DUMMY_161, 0x30, 2, 0, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x68A2 */ DEFINE_SFX(NA_SE_VO_DUMMY_162, 0x30, 2, 0, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x68A3 */ DEFINE_SFX(NA_SE_VO_DUMMY_163, 0x20, 2, 0, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x68A4 */ DEFINE_SFX(NA_SE_VO_DUMMY_164, 0x30, 2, 0, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x68A5 */ DEFINE_SFX(NA_SE_VO_DUMMY_165, 0x30, 2, 0, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x68A6 */ DEFINE_SFX(NA_SE_VO_DUMMY_166, 0x30, 2, 0, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x68A7 */ DEFINE_SFX(NA_SE_VO_DUMMY_167, 0x30, 2, 0, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x68A8 */ DEFINE_SFX(NA_SE_VO_DUMMY_168, 0x30, 2, 0, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x68A9 */ DEFINE_SFX(NA_SE_VO_DUMMY_169, 0x30, 2, 1, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x68AA */ DEFINE_SFX(NA_SE_VO_DUMMY_170, 0x30, 2, 1, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x68AB */ DEFINE_SFX(NA_SE_VO_DUMMY_171, 0x30, 2, 0, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x68AC */ DEFINE_SFX(NA_SE_VO_DUMMY_172, 0x30, 2, 0, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x68AD */ DEFINE_SFX(NA_SE_VO_DUMMY_173, 0x50, 2, 0, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x68AE */ DEFINE_SFX(NA_SE_VO_DUMMY_174, 0x30, 2, 0, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x68AF */ DEFINE_SFX(NA_SE_VO_DUMMY_175, 0x30, 2, 0, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x68B0 */ DEFINE_SFX(NA_SE_VO_DUMMY_176, 0x30, 2, 0, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x68B1 */ DEFINE_SFX(NA_SE_VO_DUMMY_177, 0x30, 2, 0, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x68B2 */ DEFINE_SFX(NA_SE_VO_DUMMY_178, 0x30, 2, 0, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x68B3 */ DEFINE_SFX(NA_SE_VO_DUMMY_179, 0x30, 2, 0, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x68B4 */ DEFINE_SFX(NA_SE_VO_DUMMY_180, 0x30, 2, 0, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x68B5 */ DEFINE_SFX(NA_SE_VO_DUMMY_181, 0x30, 2, 0, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x68B6 */ DEFINE_SFX(NA_SE_VO_DUMMY_182, 0x30, 2, 0, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x68B7 */ DEFINE_SFX(NA_SE_VO_DUMMY_183, 0x30, 2, 0, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x68B8 */ DEFINE_SFX(NA_SE_VO_DUMMY_184, 0x30, 2, 2, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x68B9 */ DEFINE_SFX(NA_SE_VO_DUMMY_185, 0x30, 2, 0, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x68BA */ DEFINE_SFX(NA_SE_VO_DUMMY_186, 0x30, 2, 0, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x68BB */ DEFINE_SFX(NA_SE_VO_DUMMY_187, 0x30, 2, 0, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x68BC */ DEFINE_SFX(NA_SE_VO_DUMMY_188, 0x30, 2, 0, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x68BD */ DEFINE_SFX(NA_SE_VO_DUMMY_189, 0x80, 2, 0, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x68BE */ DEFINE_SFX(NA_SE_VO_DUMMY_190, 0x30, 2, 0, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x68BF */ DEFINE_SFX(NA_SE_VO_DUMMY_191, 0x30, 2, 0, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x68C0 */ DEFINE_SFX(NA_SE_VO_DUMMY_192, 0x30, 2, 0, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x68C1 */ DEFINE_SFX(NA_SE_VO_DUMMY_193, 0x30, 2, 0, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x68C2 */ DEFINE_SFX(NA_SE_VO_DUMMY_194, 0x30, 2, 0, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x68C3 */ DEFINE_SFX(NA_SE_VO_DUMMY_195, 0x20, 2, 0, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x68C4 */ DEFINE_SFX(NA_SE_VO_DUMMY_196, 0x30, 2, 0, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x68C5 */ DEFINE_SFX(NA_SE_VO_DUMMY_197, 0x30, 2, 0, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x68C6 */ DEFINE_SFX(NA_SE_VO_DUMMY_198, 0x30, 2, 0, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x68C7 */ DEFINE_SFX(NA_SE_VO_DUMMY_199, 0x30, 2, 0, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x68C8 */ DEFINE_SFX(NA_SE_VO_DUMMY_200, 0x30, 2, 0, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x68C9 */ DEFINE_SFX(NA_SE_VO_DUMMY_201, 0x30, 2, 1, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x68CA */ DEFINE_SFX(NA_SE_VO_DUMMY_202, 0x30, 2, 1, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x68CB */ DEFINE_SFX(NA_SE_VO_DUMMY_203, 0x30, 2, 0, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x68CC */ DEFINE_SFX(NA_SE_VO_DUMMY_204, 0x30, 2, 0, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x68CD */ DEFINE_SFX(NA_SE_VO_DUMMY_205, 0x50, 2, 0, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x68CE */ DEFINE_SFX(NA_SE_VO_DUMMY_206, 0x30, 2, 0, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x68CF */ DEFINE_SFX(NA_SE_VO_DUMMY_207, 0x30, 2, 0, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x68D0 */ DEFINE_SFX(NA_SE_VO_DUMMY_208, 0x30, 2, 0, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x68D1 */ DEFINE_SFX(NA_SE_VO_DUMMY_209, 0x30, 2, 0, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x68D2 */ DEFINE_SFX(NA_SE_VO_DUMMY_210, 0x30, 2, 0, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x68D3 */ DEFINE_SFX(NA_SE_VO_DUMMY_211, 0x30, 2, 0, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x68D4 */ DEFINE_SFX(NA_SE_VO_DUMMY_212, 0x30, 2, 0, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x68D5 */ DEFINE_SFX(NA_SE_VO_DUMMY_213, 0x30, 2, 0, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x68D6 */ DEFINE_SFX(NA_SE_VO_DUMMY_214, 0x30, 2, 0, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x68D7 */ DEFINE_SFX(NA_SE_VO_DUMMY_215, 0x30, 2, 0, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x68D8 */ DEFINE_SFX(NA_SE_VO_DUMMY_216, 0x30, 2, 2, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x68D9 */ DEFINE_SFX(NA_SE_VO_DUMMY_217, 0x30, 2, 0, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x68DA */ DEFINE_SFX(NA_SE_VO_DUMMY_218, 0x30, 2, 0, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x68DB */ DEFINE_SFX(NA_SE_VO_DUMMY_219, 0x30, 2, 0, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x68DC */ DEFINE_SFX(NA_SE_VO_DUMMY_220, 0x30, 2, 0, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x68DD */ DEFINE_SFX(NA_SE_VO_DUMMY_221, 0x80, 2, 0, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x68DE */ DEFINE_SFX(NA_SE_VO_DUMMY_222, 0x30, 2, 0, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x68DF */ DEFINE_SFX(NA_SE_VO_DUMMY_223, 0x30, 2, 0, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x68E0 */ DEFINE_SFX(NA_SE_VO_LI_POO_WAIT, 0x30, 2, 1, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x68E1 */ DEFINE_SFX(NA_SE_VO_DUMMY_225, 0x30, 2, 1, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x68E2 */ DEFINE_SFX(NA_SE_VO_DUMMY_226, 0x30, 2, 1, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x68E3 */ DEFINE_SFX(NA_SE_VO_DUMMY_227, 0x20, 2, 1, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x68E4 */ DEFINE_SFX(NA_SE_VO_DUMMY_228, 0x30, 2, 1, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x68E5 */ DEFINE_SFX(NA_SE_VO_DUMMY_229, 0x30, 2, 1, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x68E6 */ DEFINE_SFX(NA_SE_VO_DUMMY_230, 0x30, 2, 1, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x68E7 */ DEFINE_SFX(NA_SE_VO_DUMMY_231, 0x30, 2, 1, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x68E8 */ DEFINE_SFX(NA_SE_VO_DUMMY_232, 0x30, 2, 1, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x68E9 */ DEFINE_SFX(NA_SE_VO_DUMMY_233, 0x30, 2, 1, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x68EA */ DEFINE_SFX(NA_SE_VO_DUMMY_234, 0x30, 2, 1, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x68EB */ DEFINE_SFX(NA_SE_VO_DUMMY_235, 0x30, 2, 1, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x68EC */ DEFINE_SFX(NA_SE_VO_DUMMY_236, 0x30, 2, 1, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x68ED */ DEFINE_SFX(NA_SE_VO_DUMMY_237, 0x50, 2, 1, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x68EE */ DEFINE_SFX(NA_SE_VO_DUMMY_238, 0x30, 2, 1, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x68EF */ DEFINE_SFX(NA_SE_VO_DUMMY_239, 0x30, 2, 1, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x68F0 */ DEFINE_SFX(NA_SE_VO_DUMMY_240, 0x30, 2, 1, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x68F1 */ DEFINE_SFX(NA_SE_VO_DUMMY_241, 0x30, 2, 1, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x68F2 */ DEFINE_SFX(NA_SE_VO_DUMMY_242, 0x30, 2, 1, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x68F3 */ DEFINE_SFX(NA_SE_VO_DUMMY_243, 0x30, 2, 1, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x68F4 */ DEFINE_SFX(NA_SE_VO_DUMMY_244, 0x30, 2, 1, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x68F5 */ DEFINE_SFX(NA_SE_VO_DUMMY_245, 0x30, 2, 1, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x68F6 */ DEFINE_SFX(NA_SE_VO_DUMMY_246, 0x30, 2, 1, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x68F7 */ DEFINE_SFX(NA_SE_VO_DUMMY_247, 0x30, 2, 1, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x68F8 */ DEFINE_SFX(NA_SE_VO_DUMMY_248, 0x30, 2, 2, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x68F9 */ DEFINE_SFX(NA_SE_VO_DUMMY_249, 0x30, 2, 1, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x68FA */ DEFINE_SFX(NA_SE_VO_DUMMY_250, 0x30, 2, 1, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x68FB */ DEFINE_SFX(NA_SE_VO_DUMMY_251, 0x30, 2, 1, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x68FC */ DEFINE_SFX(NA_SE_VO_DUMMY_252, 0x30, 2, 1, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x68FD */ DEFINE_SFX(NA_SE_VO_DUMMY_253, 0x80, 2, 1, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x68FE */ DEFINE_SFX(NA_SE_VO_DUMMY_254, 0x30, 2, 1, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x68FF */ DEFINE_SFX(NA_SE_VO_DUMMY_255, 0x30, 2, 1, SFX_FLAG2_APPLY_LOWPASS_FILTER, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x6900 */ DEFINE_SFX(NA_SE_VO_JMVO02, 0x30, 2, 0, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x6901 */ DEFINE_SFX(NA_SE_VO_JMVO04, 0x30, 2, 0, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x6902 */ DEFINE_SFX(NA_SE_VO_CDVO00, 0x30, 2, 0, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x6903 */ DEFINE_SFX(NA_SE_VO_CDVO01, 0x30, 2, 0, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x6904 */ DEFINE_SFX(NA_SE_VO_CDVO02, 0x30, 2, 0, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x6905 */ DEFINE_SFX(NA_SE_VO_CDVO03, 0x30, 2, 0, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x6906 */ DEFINE_SFX(NA_SE_VO_BBVO00, 0x30, 2, 0, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x6907 */ DEFINE_SFX(NA_SE_VO_BBVO01, 0x30, 2, 0, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x6908 */ DEFINE_SFX(NA_SE_VO_BBVO02, 0x30, 2, 0, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x6909 */ DEFINE_SFX(NA_SE_VO_BBVO03, 0x30, 2, 0, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x690A */ DEFINE_SFX(NA_SE_VO_BBVO04, 0x30, 2, 0, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x690B */ DEFINE_SFX(NA_SE_VO_BBVO05, 0x30, 2, 0, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x690C */ DEFINE_SFX(NA_SE_VO_OBVO01, 0x30, 2, 0, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x690D */ DEFINE_SFX(NA_SE_VO_ARVO00, 0x30, 2, 0, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x690E */ DEFINE_SFX(NA_SE_VO_ARVO01, 0x30, 2, 0, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x690F */ DEFINE_SFX(NA_SE_VO_MMVO00, 0x30, 2, 0, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x6910 */ DEFINE_SFX(NA_SE_VO_MMVO01, 0x30, 2, 0, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x6911 */ DEFINE_SFX(NA_SE_VO_MMVO02, 0x30, 2, 0, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x6912 */ DEFINE_SFX(NA_SE_VO_MMVO03, 0x30, 2, 0, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x6913 */ DEFINE_SFX(NA_SE_VO_MMVO04, 0x30, 2, 0, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x6914 */ DEFINE_SFX(NA_SE_VO_MMVO05, 0x30, 2, 0, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x6915 */ DEFINE_SFX(NA_SE_VO_ABVO00, 0x30, 2, 0, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x6916 */ DEFINE_SFX(NA_SE_VO_ABVO01, 0x30, 2, 0, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x6917 */ DEFINE_SFX(NA_SE_VO_NPVO00, 0x30, 2, 0, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x6918 */ DEFINE_SFX(NA_SE_VO_FPVO00, 0x30, 2, 0, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x6919 */ DEFINE_SFX(NA_SE_VO_FPVO01, 0x30, 2, 0, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x691A */ DEFINE_SFX(NA_SE_VO_FPVO02, 0x30, 2, 0, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x691B */ DEFINE_SFX(NA_SE_VO_FPVO03, 0x30, 2, 0, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x691C */ DEFINE_SFX(NA_SE_VO_ROVO01, 0x30, 2, 0, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x691D */ DEFINE_SFX(NA_SE_VO_ROVO02, 0x30, 2, 0, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x691E */ DEFINE_SFX(NA_SE_VO_RYVO01, 0x30, 2, 0, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x691F */ DEFINE_SFX(NA_SE_VO_RYVO02, 0x30, 2, 0, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x6920 */ DEFINE_SFX(NA_SE_VO_RYVO03, 0x30, 2, 0, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x6921 */ DEFINE_SFX(NA_SE_VO_RYVO04, 0x30, 2, 0, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x6922 */ DEFINE_SFX(NA_SE_VO_ANVO00, 0x30, 2, 0, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x6923 */ DEFINE_SFX(NA_SE_VO_ANVO01, 0x30, 2, 0, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x6924 */ DEFINE_SFX(NA_SE_VO_ANVO02, 0x30, 2, 0, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x6925 */ DEFINE_SFX(NA_SE_VO_ANVO03, 0x30, 2, 0, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x6926 */ DEFINE_SFX(NA_SE_VO_CRVO00, 0x30, 2, 0, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x6927 */ DEFINE_SFX(NA_SE_VO_CRVO01, 0x30, 2, 0, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x6928 */ DEFINE_SFX(NA_SE_VO_CRVO02, 0x30, 2, 0, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x6929 */ DEFINE_SFX(NA_SE_VO_CRVO03, 0x30, 2, 0, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x692A */ DEFINE_SFX(NA_SE_VO_HNVO00, 0x30, 2, 0, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x692B */ DEFINE_SFX(NA_SE_VO_HNVO01, 0x30, 2, 0, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x692C */ DEFINE_SFX(NA_SE_VO_HNVO02, 0x30, 2, 0, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x692D */ DEFINE_SFX(NA_SE_VO_RMVO00, 0x30, 2, 0, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x692E */ DEFINE_SFX(NA_SE_VO_RMVO01, 0x30, 2, 0, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x692F */ DEFINE_SFX(NA_SE_VO_RMVO02, 0x30, 2, 0, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x6930 */ DEFINE_SFX(NA_SE_VO_PMVO01, 0x30, 2, 0, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x6931 */ DEFINE_SFX(NA_SE_VO_PMVO02, 0x30, 2, 0, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x6932 */ DEFINE_SFX(NA_SE_VO_PMVO03, 0x30, 2, 0, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x6933 */ DEFINE_SFX(NA_SE_VO_DHVO00, 0x30, 2, 0, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x6934 */ DEFINE_SFX(NA_SE_VO_DHVO01, 0x30, 2, 0, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x6935 */ DEFINE_SFX(NA_SE_VO_DHVO02, 0x30, 2, 0, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x6936 */ DEFINE_SFX(NA_SE_VO_DHVO03, 0x30, 2, 0, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x6937 */ DEFINE_SFX(NA_SE_VO_DHVO04, 0x30, 2, 0, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x6938 */ DEFINE_SFX(NA_SE_VO_TFVO00, 0x30, 2, 0, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x6939 */ DEFINE_SFX(NA_SE_VO_ANVO04, 0x30, 2, 0, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x693A */ DEFINE_SFX(NA_SE_VO_ANVO05, 0x30, 2, 0, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x693B */ DEFINE_SFX(NA_SE_VO_PMVO00, 0x30, 2, 0, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x693C */ DEFINE_SFX(NA_SE_VO_CHVO03, 0x30, 2, 0, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x693D */ DEFINE_SFX(NA_SE_VO_CHVO04, 0x30, 2, 0, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x693E */ DEFINE_SFX(NA_SE_VO_CHVO05, 0x30, 2, 0, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x693F */ DEFINE_SFX(NA_SE_VO_CHVO06, 0x30, 2, 0, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x6940 */ DEFINE_SFX(NA_SE_VO_CHVO07, 0x30, 2, 0, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x6941 */ DEFINE_SFX(NA_SE_VO_CHVO08, 0x30, 2, 0, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x6942 */ DEFINE_SFX(NA_SE_VO_CHVO09, 0x30, 2, 0, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x6943 */ DEFINE_SFX(NA_SE_VO_DPVO00, 0x30, 2, 0, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x6944 */ DEFINE_SFX(NA_SE_VO_DPVO01, 0x30, 2, 0, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x6945 */ DEFINE_SFX(NA_SE_VO_DPVO02, 0x30, 2, 0, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x6946 */ DEFINE_SFX(NA_SE_VO_SKVO00, 0x30, 2, 0, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x6947 */ DEFINE_SFX(NA_SE_VO_SKVO01, 0x30, 2, 0, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x6948 */ DEFINE_SFX(NA_SE_VO_KHVO00, 0x30, 2, 0, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x6949 */ DEFINE_SFX(NA_SE_VO_KHVO01, 0x30, 2, 0, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x694A */ DEFINE_SFX(NA_SE_VO_KHVO02, 0x30, 2, 0, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x694B */ DEFINE_SFX(NA_SE_VO_SHVO00, 0x30, 2, 0, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x694C */ DEFINE_SFX(NA_SE_VO_SHVO01, 0x30, 2, 0, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x694D */ DEFINE_SFX(NA_SE_VO_KAVO02, 0x30, 2, 0, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x694E */ DEFINE_SFX(NA_SE_VO_KAVO03, 0x30, 2, 0, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x694F */ DEFINE_SFX(NA_SE_VO_MTVO00, 0x30, 2, 0, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x6950 */ DEFINE_SFX(NA_SE_VO_TTVO00, 0x30, 2, 0, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x6951 */ DEFINE_SFX(NA_SE_VO_ITVO00, 0x30, 2, 0, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x6952 */ DEFINE_SFX(NA_SE_VO_ITVO01, 0x30, 2, 0, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x6953 */ DEFINE_SFX(NA_SE_VO_ITVO02, 0x30, 2, 0, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x6954 */ DEFINE_SFX(NA_SE_VO_KMVO00, 0x30, 2, 0, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x6955 */ DEFINE_SFX(NA_SE_VO_KMVO01, 0x30, 2, 0, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x6956 */ DEFINE_SFX(NA_SE_VO_JOVO00, 0x30, 2, 0, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x6957 */ DEFINE_SFX(NA_SE_VO_JYVO00, 0x30, 2, 0, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x6958 */ DEFINE_SFX(NA_SE_VO_DTVO00, 0x30, 2, 0, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x6959 */ DEFINE_SFX(NA_SE_VO_GUVO00, 0x30, 2, 0, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x695A */ DEFINE_SFX(NA_SE_VO_KTVO00, 0x30, 2, 0, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x695B */ DEFINE_SFX(NA_SE_VO_KTVO01, 0x30, 2, 0, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x695C */ DEFINE_SFX(NA_SE_VO_KTVO03, 0x30, 2, 0, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x695D */ DEFINE_SFX(NA_SE_VO_ZBVO00, 0x30, 2, 0, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x695E */ DEFINE_SFX(NA_SE_VO_ZBVO01, 0x30, 2, 0, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x695F */ DEFINE_SFX(NA_SE_VO_DAVO01, 0x30, 2, 0, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x6960 */ DEFINE_SFX(NA_SE_VO_SHVO04, 0x30, 2, 0, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x6961 */ DEFINE_SFX(NA_SE_VO_GBVO02, 0x30, 2, 0, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x6962 */ DEFINE_SFX(NA_SE_VO_GBVO03, 0x30, 2, 0, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x6963 */ DEFINE_SFX(NA_SE_VO_PFVO00, 0x30, 2, 0, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x6964 */ DEFINE_SFX(NA_SE_VO_PFVO01, 0x30, 2, 0, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x6965 */ DEFINE_SFX(NA_SE_VO_GAVO00, 0x30, 2, 0, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x6966 */ DEFINE_SFX(NA_SE_VO_GAVO01, 0x30, 2, 0, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x6967 */ DEFINE_SFX(NA_SE_VO_DJVO00, 0x30, 2, 0, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x6968 */ DEFINE_SFX(NA_SE_VO_DJVO01, 0x30, 2, 0, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x6969 */ DEFINE_SFX(NA_SE_VO_MSVO00, 0x30, 2, 0, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x696A */ DEFINE_SFX(NA_SE_VO_MSVO01, 0x30, 2, 0, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x696B */ DEFINE_SFX(NA_SE_VO_JPVO00, 0x30, 2, 0, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x696C */ DEFINE_SFX(NA_SE_VO_HYVO00, 0x30, 2, 0, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x696D */ DEFINE_SFX(NA_SE_VO_HYVO01, 0x30, 2, 0, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x696E */ DEFINE_SFX(NA_SE_VO_BAVO00, 0x30, 2, 0, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x696F */ DEFINE_SFX(NA_SE_VO_POVO00, 0x30, 2, 0, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x6970 */ DEFINE_SFX(NA_SE_VO_DAVO00, 0x30, 2, 0, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x6971 */ DEFINE_SFX(NA_SE_VO_DAVO02, 0x30, 2, 0, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x6972 */ DEFINE_SFX(NA_SE_VO_MKVO00, 0x30, 2, 0, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x6973 */ DEFINE_SFX(NA_SE_VO_MKVO01, 0x30, 2, 0, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x6974 */ DEFINE_SFX(NA_SE_VO_MKVO02, 0x30, 2, 0, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x6975 */ DEFINE_SFX(NA_SE_VO_MKVO03, 0x30, 2, 0, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x6976 */ DEFINE_SFX(NA_SE_VO_MKVO04, 0x30, 2, 0, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x6977 */ DEFINE_SFX(NA_SE_VO_TIVO00, 0x30, 2, 0, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x6978 */ DEFINE_SFX(NA_SE_VO_TIVO01, 0x30, 2, 0, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x6979 */ DEFINE_SFX(NA_SE_VO_TIVO02, 0x30, 2, 0, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x697A */ DEFINE_SFX(NA_SE_VO_TIVO03, 0x30, 2, 0, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x697B */ DEFINE_SFX(NA_SE_VO_TIVO04, 0x30, 2, 0, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x697C */ DEFINE_SFX(NA_SE_VO_TIVO05, 0x30, 2, 0, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x697D */ DEFINE_SFX(NA_SE_VO_OMVO00, 0x30, 2, 0, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x697E */ DEFINE_SFX(NA_SE_VO_OMVO01, 0x30, 2, 0, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x697F */ DEFINE_SFX(NA_SE_VO_OMVO02, 0x30, 2, 0, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x6980 */ DEFINE_SFX(NA_SE_VO_OMVO03, 0x30, 2, 0, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x6981 */ DEFINE_SFX(NA_SE_VO_OMVO04, 0x30, 2, 0, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x6982 */ DEFINE_SFX(NA_SE_VO_OMVO05, 0x30, 2, 0, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x6983 */ DEFINE_SFX(NA_SE_VO_OMVO06, 0x30, 2, 0, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x6984 */ DEFINE_SFX(NA_SE_VO_DEMO_FALL2, 0x30, 2, 0, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x6985 */ DEFINE_SFX(NA_SE_VO_DEMO_384, 0x30, 2, 0, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x6986 */ DEFINE_SFX(NA_SE_VO_DEMO_385, 0x30, 2, 0, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x6987 */ DEFINE_SFX(NA_SE_VO_DEMO_386, 0x30, 2, 0, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x6988 */ DEFINE_SFX(NA_SE_VO_DEMO_387, 0x30, 2, 0, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x6989 */ DEFINE_SFX(NA_SE_VO_DEMO_388, 0x30, 2, 0, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x698A */ DEFINE_SFX(NA_SE_VO_DEMO_389, 0x30, 2, 0, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x698B */ DEFINE_SFX(NA_SE_VO_DEMO_390, 0x30, 2, 0, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x698C */ DEFINE_SFX(NA_SE_VO_DEMO_391, 0x30, 2, 0, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x698D */ DEFINE_SFX(NA_SE_VO_DEMO_392, 0x30, 2, 0, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x698E */ DEFINE_SFX(NA_SE_VO_DEMO_393, 0x30, 2, 0, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) +/* 0x698E */ DEFINE_SFX(NA_SE_VO_DEMO_394, 0x30, 2, 0, 0, SFX_FLAG_BEHIND_SCREEN_Z_INDEX) 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/gs2dex.h b/include/ultra64/gs2dex.h index 5c0bc7175..1e77f1cd3 100644 --- a/include/ultra64/gs2dex.h +++ b/include/ultra64/gs2dex.h @@ -20,7 +20,7 @@ extern "C" { * Background *---------------------------------------------------------------------------*/ #define G_BGLT_LOADBLOCK 0x0033 -#define G_BGLT_LOADTILE 0xfff4 +#define G_BGLT_LOADTILE 0xFFF4 #define G_BG_FLAG_FLIPS 0x01 #define G_BG_FLAG_FLIPT 0x10 @@ -155,7 +155,7 @@ typedef union { * Loading into TMEM *---------------------------------------------------------------------------*/ #define G_OBJLT_TXTRBLOCK 0x00001033 -#define G_OBJLT_TXTRTILE 0x00fc1034 +#define G_OBJLT_TXTRTILE 0x00FC1034 #define G_OBJLT_TLUT 0x00000030 #define GS_TB_TSIZE(pix,siz) (GS_PIX2TMEM((pix),(siz))-1) @@ -220,9 +220,9 @@ typedef struct { *===========================================================================*/ /* GBI Header */ #ifdef F3DEX_GBI_2 -#define G_OBJ_RECTANGLE_R 0xda -#define G_OBJ_MOVEMEM 0xdc -#define G_RDPHALF_0 0xe4 +#define G_OBJ_RECTANGLE_R 0xDA +#define G_OBJ_MOVEMEM 0xDC +#define G_RDPHALF_0 0xE4 #define G_OBJ_RECTANGLE 0x01 #define G_OBJ_SPRITE 0x02 #define G_SELECT_DL 0x04 @@ -231,22 +231,22 @@ typedef struct { #define G_OBJ_LDTX_RECT 0x07 #define G_OBJ_LDTX_RECT_R 0x08 #define G_BG_1CYC 0x09 -#define G_BG_COPY 0x0a -#define G_OBJ_RENDERMODE 0x0b +#define G_BG_COPY 0x0A +#define G_OBJ_RENDERMODE 0x0B #else #define G_BG_1CYC 0x01 #define G_BG_COPY 0x02 #define G_OBJ_RECTANGLE 0x03 #define G_OBJ_SPRITE 0x04 #define G_OBJ_MOVEMEM 0x05 -#define G_SELECT_DL 0xb0 -#define G_OBJ_RENDERMODE 0xb1 -#define G_OBJ_RECTANGLE_R 0xb2 -#define G_OBJ_LOADTXTR 0xc1 -#define G_OBJ_LDTX_SPRITE 0xc2 -#define G_OBJ_LDTX_RECT 0xc3 -#define G_OBJ_LDTX_RECT_R 0xc4 -#define G_RDPHALF_0 0xe4 +#define G_SELECT_DL 0xB0 +#define G_OBJ_RENDERMODE 0xB1 +#define G_OBJ_RECTANGLE_R 0xB2 +#define G_OBJ_LOADTXTR 0xC1 +#define G_OBJ_LDTX_SPRITE 0xC2 +#define G_OBJ_LDTX_RECT 0xC3 +#define G_OBJ_LDTX_RECT_R 0xC4 +#define G_RDPHALF_0 0xE4 #endif /*---------------------------------------------------------------------------* @@ -293,16 +293,16 @@ typedef struct { * Select Display List *---------------------------------------------------------------------------*/ #define gSPSelectDL(pkt, mptr, sid, flag, mask) \ -{ gDma1p((pkt), G_RDPHALF_0, (flag), (u32)(mptr) & 0xffff, (sid)); \ +{ gDma1p((pkt), G_RDPHALF_0, (flag), (u32)(mptr) & 0xFFFF, (sid)); \ gDma1p((pkt), G_SELECT_DL, (mask), (u32)(mptr) >> 16, G_DL_PUSH); } #define gsSPSelectDL(mptr, sid, flag, mask) \ -{ gsDma1p(G_RDPHALF_0, (flag), (u32)(mptr) & 0xffff, (sid)); \ +{ gsDma1p(G_RDPHALF_0, (flag), (u32)(mptr) & 0xFFFF, (sid)); \ gsDma1p(G_SELECT_DL, (mask), (u32)(mptr) >> 16, G_DL_PUSH); } #define gSPSelectBranchDL(pkt, mptr, sid, flag, mask) \ -{ gDma1p((pkt), G_RDPHALF_0, (flag), (u32)(mptr) & 0xffff, (sid)); \ +{ gDma1p((pkt), G_RDPHALF_0, (flag), (u32)(mptr) & 0xFFFF, (sid)); \ gDma1p((pkt), G_SELECT_DL, (mask), (u32)(mptr) >> 16, G_DL_NOPUSH); } #define gsSPSelectBranchDL(mptr, sid, flag, mask) \ -{ gsDma1p(G_RDPHALF_0, (flag), (u32)(mptr) & 0xffff, (sid)); \ +{ gsDma1p(G_RDPHALF_0, (flag), (u32)(mptr) & 0xFFFF, (sid)); \ gsDma1p(G_SELECT_DL, (mask), (u32)(mptr) >> 16, G_DL_NOPUSH); } /*---------------------------------------------------------------------------* 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/ultra64/vi.h b/include/ultra64/vi.h index ca9b8e45e..7737b58b4 100644 --- a/include/ultra64/vi.h +++ b/include/ultra64/vi.h @@ -63,7 +63,7 @@ typedef struct { /* 0x02 */ u16 retraceCount; /* 0x04 */ void* buffer; /* 0x08 */ OSViMode* modep; - /* 0x0c */ u32 features; + /* 0x0C */ u32 features; /* 0x10 */ OSMesgQueue* mq; /* 0x14 */ OSMesg* msg; /* 0x18 */ __OSViScale x; diff --git a/include/variables.h b/include/variables.h index 605b63939..e39b4adfb 100644 --- a/include/variables.h +++ b/include/variables.h @@ -35,13 +35,13 @@ 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_80097524; // extern u32 sRandInt; @@ -815,10 +815,10 @@ extern BgSpecialSceneMaxObjects sCustomDynapolyMem[]; // extern UNK_TYPE1 D_801B969C; // extern UNK_TYPE1 D_801B976C; // extern UNK_TYPE1 D_801B979C; -extern CameraStateParams cameraStates[91]; +// extern CameraStateParams cameraStates[91]; // extern UNK_TYPE1 D_801B9CE2; -extern UNK_PTR D_801B9CE4; -extern camera_update_func cameraUpdateFuncs[71]; +// extern UNK_PTR D_801B9CE4; +// extern camera_update_func cameraUpdateFuncs[71]; // extern UNK_TYPE2 D_801B9E04; // extern UNK_TYPE4 D_801B9E08; // extern UNK_TYPE4 D_801B9E0C; @@ -870,7 +870,6 @@ extern EffectShieldParticleInit shieldParticleInitWood; extern u8 D_801BB12C; -extern s801BB170 D_801BB170[118]; // extern UNK_TYPE1 D_801BC210; extern Gfx D_801BC240[9]; extern Gfx D_801BC288[3]; @@ -882,7 +881,7 @@ extern s16 actorCutsceneEnding; extern s16 actorCutsceneCurrentCamera; extern Actor* actorCutsceneCurrentCutsceneActor; // extern UNK_TYPE4 actorCutsceneStartMethod; -extern GlobalContext* actorCutscenesGlobalCtxt; +extern PlayState* actorCutscenesPlayState; extern s16 actorCutsceneReturnCamera; extern s16 D_801BD8C6; extern GameStateOverlay gGameStateOverlayTable[]; @@ -917,7 +916,7 @@ extern u8 kanfontOrdering[92]; // extern UNK_TYPE1 D_801BDBA0; // extern UNK_TYPE1 D_801BDBA4; // extern UNK_TYPE1 D_801BDBA8; -extern u8 D_801BDBB0; +extern u8 gWeatherMode; // extern UNK_TYPE1 D_801BDBB4; // extern UNK_TYPE1 D_801BDBB8; // extern UNK_TYPE1 D_801BDBBC; @@ -1160,31 +1159,18 @@ extern UNK_PTR D_801BF5C0; // extern UNK_TYPE1 D_801BFD8C; // extern UNK_TYPE1 D_801BFD94; // extern UNK_TYPE2 D_801BFD98; -// extern UNK_TYPE1 D_801BFD9E; + // extern UNK_TYPE1 D_801BFDD0; -// extern UNK_TYPE1 D_801BFDE8; // extern UNK_TYPE1 D_801BFE00; // extern UNK_TYPE1 D_801BFE14; // extern UNK_TYPE2 D_801BFF34; -// extern UNK_TYPE1 D_801BFF3C; // extern UNK_TYPE1 D_801BFF90; -// extern UNK_TYPE1 D_801BFF98; -// extern UNK_TYPE1 D_801BFFA0; -// extern UNK_TYPE1 D_801BFFB0; +extern u8 gPlayerModelTypes[][5]; // extern UNK_TYPE1 D_801BFFFC; -// extern UNK_TYPE1 D_801C0000; -// extern UNK_TYPE1 D_801C0001; -// extern UNK_TYPE1 D_801C0002; -// extern UNK_TYPE1 D_801C0008; -// extern UNK_TYPE1 D_801C0010; // extern UNK_TYPE1 D_801C0024; // extern UNK_TYPE1 D_801C0034; -// extern UNK_TYPE1 D_801C0040; // extern UNK_TYPE1 D_801C005C; -// extern UNK_TYPE1 D_801C0060; -// extern UNK_TYPE1 D_801C0070; // extern UNK_TYPE1 D_801C0084; -// extern UNK_TYPE1 D_801C00A0; // extern UNK_TYPE1 D_801C00AC; // extern UNK_TYPE1 D_801C00BC; // extern UNK_TYPE1 D_801C00D4; @@ -1204,7 +1190,6 @@ extern UNK_PTR D_801BF5C0; // extern UNK_TYPE1 D_801C02BC; // extern UNK_TYPE1 D_801C02D0; // extern UNK_TYPE1 D_801C02E4; -extern UNK_PTR D_801C02F8; // extern UNK_TYPE1 D_801C0340; // extern UNK_TYPE1 D_801C0368; // extern UNK_TYPE1 D_801C03A0; @@ -1222,8 +1207,6 @@ extern UNK_PTR D_801C02F8; // extern UNK_TYPE1 D_801C05C8; // extern UNK_TYPE1 D_801C05D8; // extern UNK_TYPE1 D_801C05F0; -// extern UNK_TYPE2 D_801C05F2; -// extern UNK_TYPE1 D_801C05FA; // extern UNK_TYPE1 D_801C0608; // extern UNK_TYPE1 D_801C0628; // extern UNK_TYPE1 D_801C0678; @@ -1247,14 +1230,12 @@ extern Gfx D_801C0850[]; extern UNK_PTR D_801C0870; // extern UNK_TYPE1 D_801C0890; // extern UNK_TYPE1 D_801C08A0; -// extern UNK_TYPE1 D_801C08A1; // extern UNK_TYPE1 D_801C08C0; // extern UNK_TYPE1 D_801C08FC; // extern UNK_TYPE1 D_801C0910; // extern UNK_TYPE1 D_801C0924; // extern UNK_TYPE1 D_801C0938; // extern UNK_TYPE1 D_801C094C; -// extern UNK_TYPE4 D_801C0954; // extern UNK_TYPE4 D_801C0958; extern UNK_PTR D_801C095C; // extern UNK_TYPE1 D_801C0964; @@ -1281,26 +1262,17 @@ extern UNK_PTR D_801C0B0C; // extern UNK_TYPE1 D_801C0B20; // extern UNK_TYPE1 D_801C0B90; // extern UNK_TYPE4 D_801C0BA8; -// extern UNK_TYPE4 D_801C0BAC; -// extern UNK_TYPE4 D_801C0BB0; // extern UNK_TYPE1 D_801C0BB4; -// extern UNK_TYPE4 D_801C0BB8; // extern UNK_TYPE1 D_801C0BC0; // extern UNK_TYPE1 D_801C0BD0; // extern UNK_TYPE4 D_801C0BE0; -// extern UNK_TYPE4 D_801C0BE4; -// extern UNK_TYPE4 D_801C0BE8; // extern UNK_TYPE4 D_801C0BEC; -// extern UNK_TYPE4 D_801C0BF0; -// extern UNK_TYPE4 D_801C0BF4; // extern UNK_TYPE1 D_801C0BF8; // extern UNK_TYPE1 D_801C0BFC; // extern UNK_TYPE1 D_801C0C00; // extern UNK_TYPE4 D_801C0C0C; // extern UNK_TYPE1 D_801C0C30; // extern UNK_TYPE1 D_801C0C54; -// extern UNK_TYPE1 D_801C0C78; -// extern UNK_TYPE1 D_801C0C94; // extern UNK_TYPE1 D_801C0CA8; // extern UNK_TYPE4 D_801C0CE8; // extern UNK_TYPE1 D_801C0D24; @@ -1323,6 +1295,7 @@ extern UNK_PTR D_801C0B0C; // extern UNK_TYPE1 D_801C0EA0; // extern UNK_TYPE1 D_801C0EAC; // extern UNK_TYPE1 D_801C0EB8; + extern Gfx sSetupDL[438]; extern Gfx sFillSetupDL[12]; extern Gfx gEmptyDL[1]; @@ -1343,18 +1316,12 @@ extern u8 gItemSlots[]; extern s16 gItemPrices[]; extern u16 gScenesPerRegion[11][27]; extern u32 D_801C2410[]; -extern s16 gLinkFormObjectIndexes[8]; -extern RomFile objectFileTable[643]; +extern s16 gPlayerFormObjectIndices[8]; +extern RomFile gObjectTable[643]; extern SceneTableEntry gSceneTable[]; extern UNK_PTR D_801C5C50; // extern UNK_TYPE1 D_801C5C9C; 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; @@ -1509,7 +1476,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; @@ -1580,24 +1547,18 @@ extern UNK_PTR D_801D1540; // extern f32 sFactorialTbl[13]; extern Vec3f gZeroVec3f; extern Vec3s gZeroVec3s; -extern Mtx gIdentityMtx; -extern MtxF gIdentityMtxF; -// extern UNK_TYPE1 D_801D1E70; + 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; -extern f32 gBendPitchOneOctaveFrequencies[256]; -// extern UNK_TYPE1 D_801D4FB4; -// extern UNK_TYPE4 gBendPitchTwoSemitonesFrequencies; -// extern UNK_TYPE4 D_801D53B4; -// extern UNK_TYPE1 gPitchFrequencies; -// extern UNK_TYPE1 gDefaultShortNoteVelocityTable; -// extern UNK_TYPE1 gDefaultShortNoteGateTimeTable; -// extern UNK_TYPE1 gDefaultEnvelope; +extern f32 gBendPitchOneOctaveFrequencies[]; +extern f32 gBendPitchTwoSemitonesFrequencies[]; +extern f32 gPitchFrequencies[]; +extern u8 gDefaultShortNoteVelocityTable[]; +extern u8 gDefaultShortNoteGateTimeTable[]; +extern EnvelopePoint gDefaultEnvelope[]; extern NoteSubEu gZeroNoteSub; extern NoteSubEu gDefaultNoteSub; extern u16 gHeadsetPanQuantization[]; @@ -1621,20 +1582,13 @@ extern s32 gAudioContextInitalized; // extern UNK_TYPE1 D_801D5FF8; // extern UNK_TYPE4 D_801D5FFC; extern UNK_PTR D_801D6000; -// extern UNK_TYPE1 D_801D6010; -// extern UNK_TYPE1 D_801D6014; -// extern UNK_TYPE1 D_801D6028; -// extern UNK_TYPE1 D_801D6098; -// extern UNK_TYPE1 D_801D6100; -extern UNK_PTR D_801D6188; -extern UNK_PTR D_801D618C; // extern UNK_TYPE4 D_801D6190; // extern UNK_TYPE4 D_801D6194; // extern UNK_TYPE1 D_801D6200; -// extern UNK_TYPE1 D_801D6600; -// extern UNK_TYPE1 D_801D6608; -// extern UNK_TYPE1 D_801D6610; -// extern UNK_TYPE1 D_801D662C; +extern u8 gIsLargeSfxBank[7]; +extern u8 D_801D6608[7]; +extern u8 gChannelsPerBank[4][7]; +extern u8 gUsedChannelsPerBank[4][7]; // extern UNK_TYPE1 D_801D6648; // extern UNK_TYPE1 D_801D664C; // extern UNK_TYPE1 D_801D6650; @@ -1688,8 +1642,8 @@ extern f32 gSfxVolume; // extern UNK_TYPE1 D_801D6FD8; // extern UNK_TYPE1 D_801D6FDC; // extern UNK_TYPE1 D_801D6FE0; -// extern UNK_TYPE1 D_801D6FE4; -// extern UNK_TYPE1 D_801D6FE8; +// extern UNK_TYPE1 sPlaybackStaffStopPos; +// extern UNK_TYPE1 sPlaybackStaffStartPos; // extern UNK_TYPE4 D_801D6FEC; // extern UNK_TYPE4 D_801D6FF0; // extern UNK_TYPE2 D_801D6FF4; @@ -1756,28 +1710,17 @@ extern UNK_PTR D_801D8B24; // extern UNK_TYPE1 D_801D8E48; // extern UNK_TYPE1 D_801D8E50; // extern UNK_TYPE1 D_801D8F70; -// extern SfxParams sEnemyBankParams[]; -// extern SfxParams sPlayerBankParams[]; -// extern SfxParams sItemBankParams[]; -// extern SfxParams sEnvBankParams[]; -// extern SfxParams sSystemBankParams[]; -// extern SfxParams sOcarinaBankParams[]; -// extern SfxParams sVoiceBankParams[]; extern SfxParams* gSfxParams[7]; -// extern UNK_TYPE1 D_801DB470; -// extern UNK_TYPE1 D_801DB474; -extern UNK_PTR D_801DB478[7]; -// extern UNK_TYPE1 D_801DB494; -// extern UNK_TYPE1 D_801DB49C; -// extern UNK_TYPE2 D_801DB4A0; -extern Vec3f D_801DB4A4; -extern f32 D_801DB4B0; -extern s8 D_801DB4B8; +extern SfxBankEntry* gSfxBanks[7]; +extern u8 gSfxChannelLayout; +extern Vec3f gSfxDefaultPos; +extern f32 gSfxDefaultFreqAndVolScale; +extern s8 gSfxDefaultReverb; // extern UNK_TYPE1 D_801DB4C0; // extern UNK_TYPE1 D_801DB4C4; // extern UNK_TYPE1 D_801DB4C8; // extern UNK_TYPE1 D_801DB4CC; -// extern UNK_TYPE1 D_801DB4D4; +extern u8 gAudioSpecId; // extern UNK_TYPE1 D_801DB4D8; // extern UNK_TYPE4 D_801DB4DC; // extern UNK_TYPE1 D_801DB4E0; @@ -3220,15 +3163,8 @@ extern s16 D_801F4E7A; // extern UNK_TYPE1 D_801F59E0; // extern UNK_TYPE1 D_801F59E4; // extern UNK_TYPE1 D_801F59E8; -// extern UNK_TYPE1 D_801F59EC; -// extern UNK_TYPE1 D_801F59F0; // extern UNK_TYPE1 D_801F59F4; // extern UNK_TYPE1 D_801F59F8; -// extern UNK_TYPE1 D_801F69D0; -// extern UNK_TYPE1 D_801F6A10; -// extern UNK_TYPE1 D_801F6AD4; -// extern UNK_TYPE1 D_801F6AD5; -// extern UNK_TYPE1 D_801F6ADA; // extern UNK_TYPE1 sSkyboxDrawMatrix; // extern UNK_TYPE1 D_801F6AF0; // extern UNK_TYPE1 D_801F6AF2; @@ -3251,8 +3187,8 @@ extern ShrinkWindowContext gShrinkWindowContext; extern ShrinkWindowContext* gShrinkWindowContextPtr; // extern UNK_TYPE4 D_801F6B50; // extern UNK_TYPE1 D_801F6B58; -extern void (*sKaleidoScopeUpdateFunc)(GlobalContext* globalCtx); -extern void (*sKaleidoScopeDrawFunc)(GlobalContext* globalCtx); +extern void (*sKaleidoScopeUpdateFunc)(PlayState* play); +extern void (*sKaleidoScopeDrawFunc)(PlayState* play); extern FaultAddrConvClient sKaleidoAreaFaultClient; // extern UNK_TYPE1 D_801F6C10; extern Input D_801F6C18; @@ -3518,21 +3454,21 @@ extern s32 D_801FD120; // extern UNK_TYPE1 D_801FD5E8; // extern UNK_TYPE1 D_801FD608; // extern UNK_TYPE1 D_801FD610; -// extern UNK_TYPE1 D_801FD710; -// extern UNK_TYPE1 D_801FD8C0; -// extern UNK_TYPE1 D_801FDB00; -// extern UNK_TYPE1 D_801FE100; -// extern UNK_TYPE1 D_801FE4C0; -// extern UNK_TYPE1 D_801FE640; -// extern UNK_TYPE1 D_801FE6D0; -extern SoundRequest D_801FE7C0[1]; -// extern UNK_TYPE1 D_801FFBC0; -// extern UNK_TYPE1 D_801FFBC8; -// extern UNK_TYPE1 D_801FFBD0; -// extern UNK_TYPE1 D_801FFBD8; -// extern UNK_TYPE1 D_801FFC80; -// extern UNK_TYPE1 D_801FFC84; -// extern UNK_TYPE1 D_801FFC90; +// extern UNK_TYPE1 sSfxPlayerBank; +// extern UNK_TYPE1 sSfxItemBank; +// extern UNK_TYPE1 sSfxEnvironmentBank; +// extern UNK_TYPE1 sSfxEnemyBank; +// extern UNK_TYPE1 sSfxSystemBank; +// extern UNK_TYPE1 sSfxOcarinaBank; +// extern UNK_TYPE1 sSfxVoiceBank; +// extern SfxRequest sSfxRequests[0x100]; +// extern UNK_TYPE1 sSfxBankListEnd; +// extern UNK_TYPE1 sSfxBankFreeListStart; +// extern UNK_TYPE1 sSfxBankUnused; +extern ActiveSfx gActiveSfx[7][3]; +// extern UNK_TYPE1 sCurSfxPlayerChannelIndex; +// extern UNK_TYPE1 gSfxBankMuted; +// extern UNK_TYPE1 sUnusedBankLerp; // extern UNK_TYPE1 D_801FFD00; // extern UNK_TYPE1 D_801FFD34; // extern UNK_TYPE1 D_801FFD40; @@ -3570,7 +3506,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 1ef496df3..ec51a3a8c 100644 --- a/include/z64.h +++ b/include/z64.h @@ -23,25 +23,33 @@ #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 "z64camera.h" #include "z64collision_check.h" +#include "z64curve.h" #include "z64cutscene.h" #include "z64dma.h" #include "z64effect.h" #include "z64item.h" #include "z64light.h" +#include "z64map.h" #include "z64math.h" +#include "z64message.h" #include "z64object.h" #include "z64ocarina.h" #include "z64player.h" #include "z64save.h" #include "z64scene.h" +#include "z64schedule.h" #include "z64skin.h" #include "z64subs.h" #include "z64transition.h" +#include "z64view.h" #include "regs.h" #define Z_THREAD_ID_IDLE 1 @@ -62,10 +70,13 @@ #define Z_PRIORITY_DMAMGR 17 #define Z_PRIORITY_IRQMGR 18 -#define EQUIP_SLOT_B 0 -#define EQUIP_SLOT_C_LEFT 1 -#define EQUIP_SLOT_C_DOWN 2 -#define EQUIP_SLOT_C_RIGHT 3 +typedef enum { + /* 0 */ EQUIP_SLOT_B, + /* 1 */ EQUIP_SLOT_C_LEFT, + /* 2 */ EQUIP_SLOT_C_DOWN, + /* 3 */ EQUIP_SLOT_C_RIGHT, + /* 4 */ EQUIP_SLOT_A +} EquipSlot; typedef struct { /* 0x0 */ s16 priority; // Lower means higher priority. -1 means it ignores priority @@ -87,17 +98,17 @@ typedef struct { } AnimatedMaterial; // size = 0x8 typedef struct { - /* 0x00 */ Vec3s pos; - /* 0x06 */ s16 unk_06; - /* 0x08 */ Gfx* opa; - /* 0x0C */ Gfx* xlu; -} PolygonDlist2; // size = 0x8 + /* 0x0 */ Vec3s pos; + /* 0x6 */ s16 unk_06; + /* 0x8 */ Gfx* opa; + /* 0xC */ Gfx* xlu; +} PolygonDlist2; // size = 0x10 typedef struct { - /* 0x00 */ u8 type; - /* 0x01 */ u8 num; // number of dlist entries - /* 0x04 */ void* start; - /* 0x08 */ void* end; + /* 0x0 */ u8 type; + /* 0x1 */ u8 num; // number of dlist entries + /* 0x4 */ void* start; + /* 0x8 */ void* end; } PolygonType2; // size = 0xC typedef struct { @@ -145,7 +156,7 @@ typedef struct { /* 0xA */ u8 colorsIndex; /* 0xB */ u8 flags; /* 0xC */ u8 lightParamsIndex; -} FireObjInitParams; // size = 0xD +} FireObjInitParams; // size = 0x10 typedef struct FireObjColors { /* 0x0 */ Color_RGBA8 primColor; @@ -159,25 +170,6 @@ typedef struct FireObjLightParams { /* 0x5 */ Color_RGB8 maxColorAdj; } FireObjLightParams; // size = 0x8 -#define FONT_CHAR_TEX_WIDTH 16 -#define FONT_CHAR_TEX_HEIGHT 16 -//! @TODO: Make this use `sizeof(AnyFontTextureSymbol)` -#define FONT_CHAR_TEX_SIZE ((16 * 16) / 2) // 16x16 I4 texture - -// Font textures are loaded into here -typedef struct { - /* 0x00000 */ u8 charBuf[2][FONT_CHAR_TEX_SIZE * 120]; - /* 0x07800 */ u8 iconBuf[FONT_CHAR_TEX_SIZE]; - /* 0x07880 */ u8 fontBuf[FONT_CHAR_TEX_SIZE * 320]; - /* 0x11880 */ union { - u8 schar[640]; - u16 wchar[640]; - } msgBuf; - /* 0x11D80 */ u8* messageStart; - /* 0x11D84 */ u8* messageEnd; - /* 0x11D88 */ u8 unk_11D88; // current Char Buffer ? -} Font; // size = 0x11D8C - // Game Info aka. Static Context // Data normally accessed through REG macros (see regs.h) typedef struct { @@ -191,17 +183,17 @@ typedef struct { } GameInfo; // size = 0x15D4 typedef struct { - /* 0x0000 */ u32 size; - /* 0x0004 */ void* bufp; - /* 0x0008 */ void* head; - /* 0x000C */ void* tail; + /* 0x0 */ u32 size; + /* 0x4 */ void* bufp; + /* 0x8 */ void* head; + /* 0xC */ void* tail; } TwoHeadArena; // size = 0x10 typedef struct { - /* 0x0000 */ u32 size; - /* 0x0004 */ Gfx* bufp; - /* 0x0008 */ Gfx* p; - /* 0x000C */ Gfx* d; + /* 0x0 */ u32 size; + /* 0x4 */ Gfx* bufp; + /* 0x8 */ Gfx* p; + /* 0xC */ Gfx* d; } TwoHeadGfxArena; // size = 0x10 typedef struct { @@ -287,15 +279,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; @@ -303,11 +286,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; @@ -315,13 +293,6 @@ typedef struct { /* 0x3 */ s8 pillarboxMagnitude; } ShrinkWindowContext; // size = 0x4 -typedef struct { - /* 0x0 */ s32 topY; - /* 0x4 */ s32 bottomY; - /* 0x8 */ s32 leftX; - /* 0xC */ s32 rightX; -} Viewport; // size = 0x10 - typedef void(*osCreateThread_func)(void*); typedef enum { @@ -382,13 +353,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; @@ -426,27 +390,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; @@ -455,34 +398,6 @@ typedef struct { /* 0x10 */ Vec3f projectedPos; } SoundSource; // size = 0x1C -typedef struct { - /* 0x000 */ u32 magic; - /* 0x004 */ GraphicsContext* gfxCtx; - /* 0x008 */ Viewport viewport; - /* 0x018 */ f32 fovy; - /* 0x01C */ f32 zNear; - /* 0x020 */ f32 zFar; - /* 0x024 */ f32 scale; - /* 0x028 */ Vec3f eye; - /* 0x034 */ Vec3f at; - /* 0x040 */ Vec3f up; - /* 0x04C */ UNK_TYPE1 pad4C[0x4]; - /* 0x050 */ Vp vp; - /* 0x060 */ Mtx projection; - /* 0x0A0 */ Mtx viewing; - /* 0x0E0 */ Mtx unkE0; - /* 0x120 */ Mtx* projectionPtr; - /* 0x124 */ Mtx* viewingPtr; - /* 0x128 */ Vec3f distortionDirRot; - /* 0x134 */ Vec3f distortionScale; - /* 0x140 */ f32 distortionSpeed; - /* 0x144 */ Vec3f curDistortionDirRot; - /* 0x150 */ Vec3f curDistortionScale; - /* 0x15C */ u16 normal; - /* 0x160 */ u32 flags; // bit 3: Render to an orthographic perspective - /* 0x164 */ UNK_TYPE4 unk164; -} View; // size = 0x168 - typedef void(*fault_update_input_func)(Input* input); typedef struct { @@ -509,7 +424,7 @@ typedef struct { /* 0x1D0 */ OSMesgQueue loadQueue; /* 0x1E8 */ OSMesg loadMsg; /* 0x1EC */ u16 state; - /* 0x1EE */ u16 debugState; + /* 0x1EE */ u16 debugEditor; /* 0x1F0 */ u8 unk_1F0; /* 0x1F4 */ Vec3f eye; /* 0x200 */ u16 unk_200; @@ -527,8 +442,8 @@ typedef struct { /* 0x226 */ s16 offsetY; /* 0x228 */ s32 unk_228; /* 0x22C */ s32 unk_22C; - /* 0x230 */ s32 unk_230; - /* 0x234 */ s32 unk_234; + /* 0x230 */ s32 stickRelX; + /* 0x234 */ s32 stickRelY; /* 0x238 */ s16 unk_238[5]; /* 0x242 */ s16 unk_242[5]; /* 0x24C */ s16 unk_24C[5]; @@ -536,7 +451,7 @@ typedef struct { /* 0x258 */ s16 unk_258; /* 0x25A */ s16 unk_25A; /* 0x25C */ u16 unk_25C; - /* 0x25E */ u16 unk_25E[5]; // ItemId + /* 0x25E */ u16 cursorItem[5]; /* 0x268 */ u16 unk_268[5]; /* 0x272 */ u16 equipTargetItem; /* 0x274 */ u16 equipTargetSlot; @@ -589,7 +504,7 @@ typedef struct { /* 0x214 */ u16 unk_214; /* 0x218 */ f32 unk_218; /* 0x21C */ s16 unk_21C; - /* 0x21E */ s16 unk_21E; + /* 0x21E */ s16 bButtonDoAction; /* 0x220 */ s16 unk_220; /* 0x222 */ s16 unk_222; /* 0x224 */ s16 unk_224; @@ -625,7 +540,7 @@ typedef struct { /* 0x274 */ s16 minimapAlpha; /* 0x276 */ s16 startAlpha; /* 0x278 */ s16 unk_278; - /* 0x27A */ s16 unk_27A; + /* 0x27A */ s16 dungeonOrBossAreaMapIndex; /* 0x27C */ s16 mapRoomNum; /* 0x27E */ u8 unk_27E; /* 0x27F */ u8 unk_27F; @@ -743,34 +658,34 @@ typedef struct { /* 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 typedef struct { - /* 0x00000 */ View view; - /* 0x00168 */ void* skyboxStaticSegment[4]; - /* 0x00178 */ void* skyboxPaletteStaticSegment; - /* 0x0017C */ Gfx* dListBuf; - /* 0x00180 */ Gfx* roomDL; - /* 0x00184 */ Vtx* roomVtx; - /* 0x00188 */ DmaRequest unk188; - /* 0x001A8 */ DmaRequest unk1A8; - /* 0x001C8 */ DmaRequest unk1C8; - /* 0x001E8 */ OSMesgQueue loadQueue; - /* 0x00200 */ OSMesg loadMsg; - /* 0x00204 */ s16 skyboxShouldDraw; - /* 0x00208 */ f32 rotX; - /* 0x0020C */ f32 rotY; - /* 0x00210 */ f32 rotZ; - /* 0x00214 */ Vec3f eye; - /* 0x00220 */ s16 angle; - /* 0x00222 */ u8 primR; - /* 0x00223 */ u8 primG; - /* 0x00224 */ u8 primB; - /* 0x00225 */ u8 envR; - /* 0x00226 */ u8 envG; - /* 0x00227 */ u8 envB; + /* 0x000 */ View view; + /* 0x168 */ void* skyboxStaticSegment[4]; + /* 0x178 */ void* skyboxPaletteStaticSegment; + /* 0x17C */ Gfx* dListBuf; + /* 0x180 */ Gfx* roomDL; + /* 0x184 */ Vtx* roomVtx; + /* 0x188 */ DmaRequest unk188; + /* 0x1A8 */ DmaRequest unk1A8; + /* 0x1C8 */ DmaRequest unk1C8; + /* 0x1E8 */ OSMesgQueue loadQueue; + /* 0x200 */ OSMesg loadMsg; + /* 0x204 */ s16 skyboxShouldDraw; + /* 0x208 */ f32 rotX; + /* 0x20C */ f32 rotY; + /* 0x210 */ f32 rotZ; + /* 0x214 */ Vec3f eye; + /* 0x220 */ s16 angle; + /* 0x222 */ u8 primR; + /* 0x223 */ u8 primG; + /* 0x224 */ u8 primB; + /* 0x225 */ u8 envR; + /* 0x226 */ u8 envG; + /* 0x227 */ u8 envB; } SkyboxContext; // size = 0x228 typedef enum { @@ -778,8 +693,8 @@ typedef enum { } SkyboxId; typedef struct ListAlloc { - /* 0x00 */ struct ListAlloc* prev; - /* 0x04 */ struct ListAlloc* next; + /* 0x0 */ struct ListAlloc* prev; + /* 0x4 */ struct ListAlloc* next; } ListAlloc; // size = 0x8 typedef struct { @@ -824,96 +739,63 @@ typedef struct { /* 0x24 */ u32 flags; } PreRenderParams; // size = 0x28 -typedef struct { - /* 0x00000 */ View view; - /* 0x00168 */ Font font; - /* 0x11EF4 */ char unk_11EF4[0x4]; - /* 0x11EF8 */ UNK_PTR unk11EF8; - /* 0x11EFC */ UNK_TYPE1 unk11EFC[0x8]; - /* 0x11F04 */ u16 currentTextId; - /* 0x11F06 */ UNK_TYPE1 pad11F06[0x4]; - /* 0x11F0A */ u8 unk11F0A; - /* 0x11F0B */ UNK_TYPE1 pad11F0B[0x5]; - /* 0x11F10 */ s32 unk11F10; - /* 0x11F14 */ UNK_TYPE1 pad11F14[0x6]; - /* 0x11F1A */ s16 unk11F1A[3]; - /* 0x11F20 */ UNK_TYPE1 pad11F20[0x2]; - /* 0x11F22 */ u8 msgMode; - /* 0x11F23 */ UNK_TYPE1 pad11F23; - /* 0x11F24 */ union { - u8 schar[206]; - u16 wchar[103]; - } decodedBuffer; - /* 0x11FF2 */ u16 unk11FF2; - /* 0x11FF4 */ s16 unk11FF4; - /* 0x11FF6 */ s16 unk11FF6; - /* 0x11FF8 */ UNK_TYPE1 unk11FF8[0x6]; - /* 0x11FFE */ s16 unk11FFE[0x3]; - /* 0x12004 */ s16 unk12004; - /* 0x12006 */ s16 unk12006; - /* 0x12008 */ u8 unk12008[0x16]; - /* 0x1201E */ s16 unk1201E; - /* 0x12020 */ u8 unk12020; - /* 0x12021 */ u8 choiceIndex; - /* 0x12022 */ u8 unk12022; - /* 0x12023 */ u8 unk12023; - /* 0x12024 */ s16 unk12024; - /* 0x12026 */ u16 unk12026; - /* 0x12028 */ u16 songPlayed; - /* 0x1202A */ u16 ocarinaMode; - /* 0x1202C */ u16 ocarinaAction; - /* 0x1202E */ u16 unk1202E; - /* 0x12030 */ s16 unk_12030; - /* 0x12032 */ UNK_TYPE1 unk_12032[0x2]; - /* 0x12034 */ UNK_TYPE1 pad12034[0x6]; - /* 0x1203A */ s16 unk1203A; - /* 0x1203C */ s16 unk1203C; - /* 0x1203E */ s16 pad1203E; - /* 0x12040 */ Actor* unkActor; - /* 0x12044 */ s16 unk12044; - /* 0x12046 */ s16 unk12046; - /* 0x12048 */ u8 unk12048; // EnKakasi - /* 0x12049 */ UNK_TYPE1 pad12049[0x1]; - /* 0x1204A */ s16 unk1204A[0x5]; - /* 0x12054 */ s16 unk12054[3]; // First, second and third digits in lottery code guess - /* 0x1205A */ UNK_TYPE1 pad1205A[0xE]; - /* 0x12068 */ s16 unk12068; - /* 0x1206A */ s16 unk1206A; - /* 0x1206C */ s32 unk1206C; - /* 0x12070 */ s32 unk12070; - /* 0x12074 */ UNK_TYPE1 pad12074[0x4]; - /* 0x12078 */ s32 bankRupeesSelected; - /* 0x1207C */ s32 bankRupees; - /* 0x12080 */ MessageTableEntry* messageEntryTable; - /* 0x12084 */ MessageTableEntry* messageEntryTableNes; - /* 0x12088 */ UNK_TYPE4 unk12088; - /* 0x1208C */ MessageTableEntry* messageTableStaff; - /* 0x12090 */ s16 unk12090; - /* 0x12092 */ s16 unk12092; - /* 0x12094 */ s8 unk12094; - /* 0x12095 */ UNK_TYPE1 unk12095[0x3]; - /* 0x12098 */ f32 unk12098; // Text_Scale? - /* 0x1209C */ s16 unk1209C; - /* 0x1209E */ UNK_TYPE1 unk1209E[0x2]; - /* 0x120A0 */ s32 unk120A0; - /* 0x120A4 */ UNK_TYPE1 unk120A4[0xC]; - /* 0x120B0 */ u8 unk120B0; - /* 0x120B1 */ u8 unk120B1; - /* 0x120B2 */ u8 unk120B2[0xC]; - /* 0x120BE */ s16 unk120BE; - /* 0x120C0 */ s16 unk120C0; - /* 0x120C2 */ s16 unk120C2; - /* 0x120C4 */ s32 unk120C4; - /* 0x120C8 */ s16 unk120C8; - /* 0x120CA */ s16 unk120CA; - /* 0x120CC */ s16 unk120CC; - /* 0x120CE */ s16 unk120CE; - /* 0x120D0 */ s16 unk120D0; - /* 0x120D2 */ s16 unk120D2; - /* 0x120D4 */ s16 unk120D4; - /* 0x120D6 */ s16 unk120D6; - /* 0x120D8 */ UNK_TYPE1 pad120D8[0x8]; -} MessageContext; // size = 0x120E0 +#define TRANS_TRIGGER_OFF 0 // transition is not active +#define TRANS_TRIGGER_START 20 // start transition (exiting an area) +#define TRANS_TRIGGER_END -20 // transition is ending (arriving in a new area) + +typedef enum { + /* 0 */ TRANS_MODE_OFF, + /* 1 */ TRANS_MODE_01, + /* 2 */ TRANS_MODE_02, + /* 3 */ TRANS_MODE_03, + /* 4 */ TRANS_MODE_04, + /* 5 */ TRANS_MODE_05, + /* 6 */ TRANS_MODE_06, + /* 7 */ TRANS_MODE_07, + /* 8 */ TRANS_MODE_08, + /* 9 */ TRANS_MODE_09, + /* 10 */ TRANS_MODE_10, + /* 11 */ TRANS_MODE_11, + /* 12 */ TRANS_MODE_12, + /* 13 */ TRANS_MODE_13, + /* 14 */ TRANS_MODE_14, + /* 15 */ TRANS_MODE_15, + /* 16 */ TRANS_MODE_16, + /* 17 */ TRANS_MODE_17 +} TransitionMode; + +typedef enum { + /* 0 */ TRANS_TYPE_00, + /* 1 */ TRANS_TYPE_01, + /* 2 */ TRANS_TYPE_02, + /* 3 */ TRANS_TYPE_03, + /* 4 */ TRANS_TYPE_04, + /* 5 */ TRANS_TYPE_05, + /* 6 */ TRANS_TYPE_06, + /* 7 */ TRANS_TYPE_07, + /* 8 */ TRANS_TYPE_08, + /* 9 */ TRANS_TYPE_09, + /* 10 */ TRANS_TYPE_10, + /* 11 */ TRANS_TYPE_11, + /* 12 */ TRANS_TYPE_12, + /* 13 */ TRANS_TYPE_13, + /* 14 */ TRANS_TYPE_14, + /* 15 */ TRANS_TYPE_15, + /* 16 */ TRANS_TYPE_16, + /* 17 */ TRANS_TYPE_17, + /* 18 */ TRANS_TYPE_18, + /* 19 */ TRANS_TYPE_19, + /* 20 */ TRANS_TYPE_20, + /* 21 */ TRANS_TYPE_21, + /* 64 */ TRANS_TYPE_64 = 64, + /* 70 */ TRANS_TYPE_70 = 70, + /* 72 */ TRANS_TYPE_72 = 72, + /* 73 */ TRANS_TYPE_73, + /* 80 */ TRANS_TYPE_80 = 80, + /* 86 */ TRANS_TYPE_86 = 86 +} TransitionType; + +#define TRANS_NEXT_TYPE_DEFAULT 0xFF typedef struct FaultAddrConvClient { /* 0x0 */ struct FaultAddrConvClient* next; @@ -1011,96 +893,15 @@ typedef struct { /* 0x10 */ OSTime resetTime; } PreNmiBuff; // size = 0x18 (actually osAppNmiBuffer is 0x40 bytes large but the rest is unused) -typedef struct GlobalContext GlobalContext; +typedef struct PlayState PlayState; -typedef s32 (*ColChkResetFunc)(GlobalContext*, Collider*); -typedef void (*ColChkBloodFunc)(GlobalContext*, Collider*, Vec3f*); -typedef void (*ColChkApplyFunc)(GlobalContext*, CollisionCheckContext*, Collider*); -typedef void (*ColChkVsFunc)(GlobalContext*, CollisionCheckContext*, Collider*, Collider*); -typedef s32 (*ColChkLineFunc)(GlobalContext*, CollisionCheckContext*, Collider*, Vec3f*, Vec3f*); +typedef s32 (*ColChkResetFunc)(PlayState*, Collider*); +typedef void (*ColChkBloodFunc)(PlayState*, Collider*, Vec3f*); +typedef void (*ColChkApplyFunc)(PlayState*, CollisionCheckContext*, Collider*); +typedef void (*ColChkVsFunc)(PlayState*, CollisionCheckContext*, Collider*, Collider*); +typedef s32 (*ColChkLineFunc)(PlayState*, CollisionCheckContext*, Collider*, Vec3f*, Vec3f*); -typedef void(*draw_func)(GlobalContext* globalCtx, s16 index); - -typedef void(*room_draw_func)(GlobalContext* globalCtx, Room* room, u32 flags); - -typedef struct { - /* 0x00 */ draw_func unk0; - /* 0x04 */ u32 unk4; - /* 0x08 */ u32 unk8; - /* 0x0C */ u32 unkC; - /* 0x10 */ u32 unk10; - /* 0x14 */ u32 unk14; - /* 0x18 */ u32 unk18; - /* 0x1C */ u32 unk1C; - /* 0x20 */ u32 unk20; -} s801BB170; // size = 0x24 - -typedef struct Camera { - /* 0x000 */ char paramData[0x50]; - /* 0x050 */ Vec3f at; - /* 0x05C */ Vec3f eye; - /* 0x068 */ Vec3f up; - /* 0x074 */ Vec3f eyeNext; - /* 0x080 */ Vec3f skyboxOffset; - /* 0x08C */ struct GlobalContext* globalCtx; - /* 0x090 */ struct Player* player; - /* 0x094 */ PosRot playerPosRot; - /* 0x0A8 */ struct Actor* target; - /* 0x0AC */ PosRot targetPosRot; - /* 0x0C0 */ f32 rUpdateRateInv; - /* 0x0C4 */ f32 pitchUpdateRateInv; - /* 0x0C8 */ f32 yawUpdateRateInv; - /* 0x0CC */ f32 yOffsetUpdateRate; - /* 0x0D0 */ f32 xzOffsetUpdateRate; - /* 0x0D4 */ f32 fovUpdateRate; - /* 0x0D8 */ f32 xzSpeed; - /* 0x0DC */ f32 dist; - /* 0x0E0 */ f32 speedRatio; - /* 0x0E4 */ Vec3f posOffset; - /* 0x0F0 */ Vec3f playerPosDelta; - /* 0x0FC */ f32 fov; - /* 0x100 */ f32 atLERPStepScale; - /* 0x104 */ f32 playerGroundY; - /* 0x108 */ Vec3f floorNorm; - /* 0x114 */ f32 waterYPos; - /* 0x118 */ s32 waterPrevCamIdx; - /* 0x11C */ s32 waterPrevCamSetting; - /* 0x120 */ s16 waterQuakeId; - /* 0x122 */ s16 unk122; - /* 0x124 */ void* data0; - /* 0x128 */ void* data1; - /* 0x12C */ s16 data2; - /* 0x12E */ s16 data3; - /* 0x130 */ s16 uid; - /* 0x132 */ UNK_TYPE1 pad132[2]; - /* 0x134 */ Vec3s inputDir; - /* 0x13A */ Vec3s camDir; - /* 0x140 */ s16 status; - /* 0x142 */ s16 setting; - /* 0x144 */ s16 mode; - /* 0x146 */ s16 bgCheckId; - /* 0x148 */ s16 camDataIdx; - /* 0x14A */ s16 flags1; - /* 0x14C */ s16 flags2; - /* 0x14E */ s16 childCamIdx; - /* 0x150 */ s16 unk150; - /* 0x152 */ s16 unk152; - /* 0x154 */ s16 prevSetting; - /* 0x156 */ s16 nextCamDataIdx; - /* 0x158 */ s16 nextBGCheckId; - /* 0x15A */ s16 roll; - /* 0x15C */ s16 paramFlags; - /* 0x15E */ s16 animState; - /* 0x160 */ s16 unk160; - /* 0x162 */ s16 timer; - /* 0x164 */ s16 camId; - /* 0x166 */ s16 prevCamDataIdx; - /* 0x168 */ s16 unk168; - /* 0x16A */ s16 unk16A; - /* 0x16C */ Vec3f meshActorPos; -} Camera; // size = 0x178 - -typedef s32(*camera_update_func)(Camera* camera); +typedef void(*room_draw_func)(PlayState* play, Room* room, u32 flags); typedef struct { /* 0x00 */ Vec3f atOffset; @@ -1147,7 +948,7 @@ typedef s16 (*QuakeCallbackFunc)(QuakeRequest*, ShakeInfo*); #define QUAKE_IS_SHAKE_PERPENDICULAR (1 << 9) typedef struct { - /* 0x0 */ GlobalContext* globalCtx; + /* 0x0 */ PlayState* play; /* 0x4 */ s32 type; // bitfield, highest set bit determines type /* 0x8 */ s16 countdown; /* 0xA */ s16 state; @@ -1202,7 +1003,7 @@ struct FireObjLight { /* 0x00 */ LightNode* light; /* 0x04 */ LightInfo lightInfo; /* 0x12 */ u8 lightParamsIndex; -}; // size = 0x13 +}; // size = 0x14 #define OS_SC_RETRACE_MSG 1 #define OS_SC_DONE_MSG 2 @@ -1223,7 +1024,7 @@ typedef struct { /* 0x12C */ UNK_TYPE1 pad_12C[0x4]; /* 0x130 */ OSThread thread; } AudioMgr; // size = 0x2E0 - + typedef struct { /* 0x00 */ MtxF displayMatrix; /* 0x40 */ Actor* actor; @@ -1261,22 +1062,21 @@ struct FireObj { }; // size = 0x8B typedef struct { - /* 0x00 */ u8 seqIndex; - /* 0x01 */ u8 nightSeqIndex; - /* 0x02 */ u8 unk_02; + /* 0x0 */ u8 seqIndex; + /* 0x1 */ u8 nightSeqIndex; + /* 0x2 */ u8 unk_02; } SoundContext; // size = 0x3 typedef struct { - /* 0x00 */ s32 enabled; - /* 0x04 */ s32 timer; + /* 0x0 */ s32 enabled; + /* 0x4 */ s32 timer; } FrameAdvanceContext; // size = 0x8 typedef enum { - /* 00 */ GAMEOVER_INACTIVE, - /* 01 */ GAMEOVER_DEATH_START, - /* 02 */ GAMEOVER_DEATH_WAIT_GROUND, // wait for player to fall and hit the ground - /* 03 */ GAMEOVER_DEATH_FADE_OUT, // wait before fading out - + /* 0 */ GAMEOVER_INACTIVE, + /* 1 */ GAMEOVER_DEATH_START, + /* 2 */ GAMEOVER_DEATH_WAIT_GROUND, // wait for player to fall and hit the ground + /* 3 */ GAMEOVER_DEATH_FADE_OUT, // wait before fading out /* 20 */ GAMEOVER_REVIVE_START = 20, /* 21 */ GAMEOVER_REVIVE_RUMBLE, /* 22 */ GAMEOVER_REVIVE_WAIT_GROUND, // wait for player to fall and hit the ground @@ -1285,10 +1085,10 @@ typedef enum { } GameOverState; typedef struct { - /* 0x00 */ u16 state; -} GameOverContext; // size = 0x02 + /* 0x0 */ u16 state; +} GameOverContext; // size = 0x2 -struct GlobalContext { +struct PlayState { /* 0x00000 */ GameState state; /* 0x000A4 */ s16 sceneNum; /* 0x000A6 */ u8 sceneConfig; @@ -1297,9 +1097,9 @@ struct GlobalContext { /* 0x000B4 */ char unk_B4[0x4]; /* 0x000B8 */ View view; /* 0x00220 */ Camera mainCamera; - /* 0x00398 */ Camera subCameras[3]; - /* 0x00800 */ Camera* cameraPtrs[4]; - /* 0x00810 */ s16 activeCamera; + /* 0x00398 */ Camera subCameras[NUM_CAMS - CAM_ID_SUB_FIRST]; + /* 0x00800 */ Camera* cameraPtrs[NUM_CAMS]; + /* 0x00810 */ s16 activeCamId; /* 0x00812 */ s16 nextCamera; /* 0x00814 */ SoundContext soundCtx; /* 0x00818 */ LightContext lightCtx; @@ -1320,19 +1120,19 @@ struct GlobalContext { /* 0x17D88 */ ObjectContext objectCtx; /* 0x186E0 */ RoomContext roomCtx; /* 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)(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); - /* 0x18780 */ void (*func_18780)(Player* player, struct GlobalContext* globalCtx); - /* 0x18784 */ s32 (*damagePlayer)(struct GlobalContext* globalCtx, s32 damage); - /* 0x18788 */ void (*talkWithPlayer)(struct GlobalContext* globalCtx, Actor* actor); - /* 0x1878C */ void (*unk_1878C)(struct GlobalContext* globalCtx); - /* 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); + /* 0x18768 */ void (*playerInit)(Player* player, struct PlayState* play, FlexSkeletonHeader* skelHeader); + /* 0x1876C */ void (*playerUpdate)(Player* player, struct PlayState* play, Input* input); + /* 0x18770 */ void (*unk_18770)(struct PlayState* play, Player* player); + /* 0x18774 */ s32 (*startPlayerFishing)(struct PlayState* play); + /* 0x18778 */ s32 (*grabPlayer)(struct PlayState* play, Player* player); + /* 0x1877C */ s32 (*startPlayerCutscene)(struct PlayState* play, Player* player, s32 mode); + /* 0x18780 */ void (*func_18780)(Player* player, struct PlayState* play); + /* 0x18784 */ s32 (*damagePlayer)(struct PlayState* play, s32 damage); + /* 0x18788 */ void (*talkWithPlayer)(struct PlayState* play, Actor* actor); + /* 0x1878C */ void (*unk_1878C)(struct PlayState* play); + /* 0x18790 */ void (*unk_18790)(struct PlayState* play, s16 arg1, Actor* actor); + /* 0x18794 */ s32 (*unk_18794)(struct PlayState* play, Player* player, s32 arg2, s32 arg3); + /* 0x18798 */ s32 (*setPlayerTalkAnim)(struct PlayState* play, void* talkAnim, s32 arg2); /* 0x1879C */ s16 playerActorCsIds[10]; /* 0x187B0 */ MtxF viewProjectionMtxF; /* 0x187F0 */ Vec3f unk_187F0; @@ -1346,7 +1146,7 @@ struct GlobalContext { /* 0x1884C */ RomFile* roomList; /* 0x18850 */ ActorEntry* linkActorEntry; /* 0x18854 */ ActorEntry* setupActorList; - /* 0x18858 */ CsCamData* csCamData; + /* 0x18858 */ ActorCsCamInfo* actorCsCamList; /* 0x1885C */ EntranceEntry* setupEntranceList; /* 0x18860 */ u16* setupExitList; /* 0x18864 */ Path* setupPathList; @@ -1354,20 +1154,20 @@ struct GlobalContext { /* 0x1886C */ AnimatedMaterial* sceneMaterialAnims; /* 0x18870 */ void* specialEffects; /* 0x18874 */ u8 skyboxId; - /* 0x18875 */ s8 sceneLoadFlag; // "fade_direction" + /* 0x18875 */ s8 transitionTrigger; // "fade_direction" /* 0x18876 */ s16 unk_18876; /* 0x18878 */ s16 bgCoverAlpha; - /* 0x1887A */ u16 nextEntranceIndex; - /* 0x1887C */ s8 unk_1887C; + /* 0x1887A */ u16 nextEntrance; + /* 0x1887C */ s8 unk_1887C; // shootingGalleryStatus? /* 0x1887D */ s8 unk_1887D; /* 0x1887E */ s8 unk_1887E; - /* 0x1887F */ u8 unk_1887F; // fadeTransition + /* 0x1887F */ u8 transitionType; // fadeTransition /* 0x18880 */ u8 unk_18880; /* 0x18884 */ CollisionCheckContext colChkCtx; /* 0x18B20 */ u16 envFlags[20]; /* 0x18B48 */ u8 curSpawn; /* 0x18B49 */ u8 unk_18B49; - /* 0x18B4A */ u8 unk_18B4A; + /* 0x18B4A */ u8 transitionMode; /* 0x18B4C */ PreRender pauseBgPreRender; /* 0x18B9C */ char unk_18B9C[0x2B8]; /* 0x18E54 */ SceneTableEntry* loadedScene; @@ -1398,44 +1198,28 @@ typedef struct { } struct_800BD888_arg1; // size = 0x28 typedef struct { - /* 0x0 */ u8 unk0; - /* 0x4 */ s32 unk4; - /* 0x8 */ s32 unk8; // game script pointer? -} struct_80133038_arg2; // size = 0xC - -typedef struct { - /* 0x00 */ u32 type; - /* 0x04 */ u32 setScissor; - /* 0x08 */ Color_RGBA8 color; - /* 0x0C */ Color_RGBA8 envColor; + /* 0x0 */ u32 type; + /* 0x4 */ u32 setScissor; + /* 0x8 */ Color_RGBA8 color; + /* 0xC */ Color_RGBA8 envColor; } struct_801F8010; // size = 0x10 typedef struct { - /* 0x00 */ u32 useRgba; - /* 0x04 */ u32 setScissor; - /* 0x08 */ Color_RGBA8 primColor; - /* 0x08 */ Color_RGBA8 envColor; + /* 0x0 */ u32 useRgba; + /* 0x4 */ u32 setScissor; + /* 0x8 */ Color_RGBA8 primColor; + /* 0xC */ Color_RGBA8 envColor; } struct_801F8020; // size = 0x10 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; @@ -1452,9 +1236,9 @@ typedef struct { } TargetRangeParams; // size = 0x8 typedef struct { - /* 0x00 */ u8* value; - /* 0x04 */ const char* name; -} FlagSetEntry; // size = 0x08 + /* 0x0 */ u8* value; + /* 0x4 */ const char* name; +} FlagSetEntry; // size = 0x8 // TODO: Dedicated Header? #define FRAM_BASE_ADDRESS 0x08000000 // FRAM Base Address in Cart Memory @@ -1467,21 +1251,21 @@ enum fram_command { Writes Contents in FLASHRAM_MODE_WRITE After execution, sets FRAM_MODE to FRAM_MODE_NOP */ FRAM_COMMAND_EXECUTE = 0xD2000000, - /* flashram->erase_offset = (command & 0xffff) * 128; */ + /* flashram->erase_offset = (command & 0xFFFF) * 128; */ FRAM_COMMAND_SET_ERASE_SECTOR_OFFSET = 0x4B000000, /* flashram->mode = FLASHRAM_MODE_ERASE; - flashram->status = 0x1111800800c20000LL; */ + flashram->status = 0x1111800800C20000LL; */ FRAM_COMMAND_SET_MODE_ERASE_AND_STATUS = 0x78000000, - /* flashram->erase_offset = (command & 0xffff) * 128; - flashram->status = 0x1111800400c20000LL; */ + /* flashram->erase_offset = (command & 0xFFFF) * 128; + flashram->status = 0x1111800400C20000LL; */ FRAM_COMMAND_SET_ERASE_SECTOR_OFFSET_AND_STATUS = 0xA5000000, /* flashram->mode = FLASHRAM_MODE_WRITE; */ FRAM_COMMAND_SET_MODE_WRITE = 0xB4000000, /* flashram->mode = FLASHRAM_MODE_STATUS; - flashram->status = 0x1111800100c20000LL; */ + flashram->status = 0x1111800100C20000LL; */ FRAM_COMMAND_SET_MODE_STATUS_AND_STATUS = 0xE1000000, /* flashram->mode = FLASHRAM_MODE_READ; - flashram->status = 0x11118004f0000000LL; */ + flashram->status = 0x11118004F0000000LL; */ FRAM_COMMAND_SET_MODE_READ_AND_STATUS = 0xF0000000, /* unk */ FRAM_COMMAND_UNK_ERASE_OPERATION = 0x3C000000 diff --git a/include/z64actor.h b/include/z64actor.h index ee73ae8af..175d9ef22 100644 --- a/include/z64actor.h +++ b/include/z64actor.h @@ -9,17 +9,18 @@ // This value is hardcoded to be the size of ovl_Arrow_Fire which currently is the biggest actor that uses the AM_FIELD. #define AM_FIELD_SIZE SEGMENT_SIZE(ovl_Arrow_Fire) + #define MASS_IMMOVABLE 0xFF // Cannot be pushed by OC collisions #define MASS_HEAVY 0xFE // Can only be pushed by OC collisions with IMMOVABLE and HEAVY objects. struct Actor; -struct GlobalContext; +struct PlayState; struct Lights; struct CollisionPoly; struct EnBox; -typedef void(*ActorFunc)(struct Actor* this, struct GlobalContext* globalCtx); +typedef void(*ActorFunc)(struct Actor* this, struct PlayState* play); typedef struct { /* 0x00 */ Vec3f pos; @@ -31,18 +32,18 @@ typedef struct { } DamageTable; // size = 0x20 typedef struct { - /* 0x00 */ u8 health; - /* 0x02 */ s16 cylRadius; - /* 0x04 */ s16 cylHeight; - /* 0x06 */ u8 mass; -} CollisionCheckInfoInit; + /* 0x0 */ u8 health; + /* 0x2 */ s16 cylRadius; + /* 0x4 */ s16 cylHeight; + /* 0x6 */ u8 mass; +} CollisionCheckInfoInit; // size = 0x8 typedef struct { - /* 0x00 */ u8 health; - /* 0x02 */ s16 cylRadius; - /* 0x04 */ s16 cylHeight; - /* 0x06 */ s16 cylYShift; - /* 0x08 */ u8 mass; + /* 0x0 */ u8 health; + /* 0x2 */ s16 cylRadius; + /* 0x4 */ s16 cylHeight; + /* 0x6 */ s16 cylYShift; + /* 0x8 */ u8 mass; } CollisionCheckInfoInit2; // size = 0xC typedef struct { @@ -80,6 +81,11 @@ typedef struct { /* 0x3A */ s16 unk3A; } ActorEnTest20C; // size = 0x3C +typedef struct { + /* 0x0 */ s16 unk_0; // frame? + /* 0x2 */ Vec3s unk_2; // pos? +} struct_80124618; // size = 0x8 + typedef struct { /* 0x00 */ s16 id; /* 0x02 */ u8 type; @@ -110,7 +116,7 @@ typedef struct { /* 0x1E */ s8 numLoaded; // original name: "clients" } ActorOverlay; // size = 0x20 -typedef void(*ActorShadowFunc)(struct Actor* actor, struct Lights* mapper, struct GlobalContext* globalCtx); +typedef void(*ActorShadowFunc)(struct Actor* actor, struct Lights* mapper, struct PlayState* play); typedef struct { /* 0x00 */ Vec3s rot; // Current actor shape rotation @@ -217,11 +223,12 @@ typedef struct { /* 0x15A */ s16 pad15A; } DynaPolyActor; // size = 0x15C + typedef enum { /* 0x00 */ ITEM00_RUPEE_GREEN, /* 0x01 */ ITEM00_RUPEE_BLUE, /* 0x02 */ ITEM00_RUPEE_RED, - /* 0x03 */ ITEM00_HEART, + /* 0x03 */ ITEM00_RECOVERY_HEART, /* 0x04 */ ITEM00_BOMBS_A, /* 0x05 */ ITEM00_ARROWS_10, /* 0x06 */ ITEM00_HEART_PIECE, @@ -254,13 +261,16 @@ typedef enum { struct EnItem00; -typedef void (*EnItem00ActionFunc)(struct EnItem00*, struct GlobalContext*); +typedef void (*EnItem00ActionFunc)(struct EnItem00*, struct PlayState*); + +#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; /* 0x148 */ s16 collectibleFlag; - /* 0x14A */ s16 unk14A; + /* 0x14A */ s16 getItemId; /* 0x14C */ s16 unk14C; /* 0x14E */ s16 unk14E; /* 0x150 */ s16 unk150; @@ -272,7 +282,7 @@ typedef struct EnItem00 { struct EnAObj; -typedef void (*EnAObjActionFunc)(struct EnAObj*, struct GlobalContext*); +typedef void (*EnAObjActionFunc)(struct EnAObj*, struct PlayState*); typedef struct EnAObj { /* 0x000 */ Actor actor; @@ -388,8 +398,8 @@ typedef struct ActorContext { } ActorContext; // size = 0x284 typedef enum { - /* 00 */ ACTOR_DRAW_DMGEFF_FIRE, - /* 01 */ ACTOR_DRAW_DMGEFF_BLUE_FIRE, + /* 0 */ ACTOR_DRAW_DMGEFF_FIRE, + /* 1 */ 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, @@ -1130,7 +1140,7 @@ typedef enum { #define ACTOR_FLAG_2000 (1 << 13) // #define ACTOR_FLAG_4000 (1 << 14) -// +//! Carried by arrow #define ACTOR_FLAG_8000 (1 << 15) // #define ACTOR_FLAG_10000 (1 << 16) diff --git a/include/z64animation.h b/include/z64animation.h index 974b8bea0..b697dbfdf 100644 --- a/include/z64animation.h +++ b/include/z64animation.h @@ -6,7 +6,7 @@ #include "z64dma.h" #include "z64math.h" -struct GlobalContext; +struct PlayState; struct Actor; struct SkelAnime; @@ -34,49 +34,49 @@ typedef enum { } AnimationTapers; typedef struct { - /* 0x00 */ Vec3s jointPos; // Root is position in model space, children are relative to parent - /* 0x06 */ u8 child; // The first child's index into the limb table. - /* 0x07 */ u8 sibling; // The parent limb's next limb index into the limb table. - /* 0x08 */ Gfx* dList; // Display lists for the limb. Index 0 is the normal display list, index 1 is the + /* 0x0 */ Vec3s jointPos; // Root is position in model space, children are relative to parent + /* 0x6 */ u8 child; // The first child's index into the limb table. + /* 0x7 */ u8 sibling; // The parent limb's next limb index into the limb table. + /* 0x8 */ Gfx* dList; // Display lists for the limb. Index 0 is the normal display list, index 1 is the // far model display list. } StandardLimb; // size = 0xC // Model has limbs with only rigid meshes typedef struct { - /* 0x00 */ Vec3s jointPos; // Root is position in model space, children are relative to parent - /* 0x06 */ u8 child; - /* 0x07 */ u8 sibling; - /* 0x08 */ Gfx* dLists[2]; // Near and far + /* 0x0 */ Vec3s jointPos; // Root is position in model space, children are relative to parent + /* 0x6 */ u8 child; + /* 0x7 */ u8 sibling; + /* 0x8 */ Gfx* dLists[2]; // Near and far } LodLimb; // size = 0x10 // Model has limbs with only rigid meshes typedef struct { - /* 0x00 */ void** segment; - /* 0x04 */ u8 limbCount; + /* 0x0 */ void** segment; + /* 0x4 */ u8 limbCount; } SkeletonHeader; // size = 0x8 // Model has limbs with flexible meshes typedef struct { - /* 0x00 */ SkeletonHeader sh; - /* 0x08 */ u8 dListCount; + /* 0x0 */ SkeletonHeader sh; + /* 0x8 */ u8 dListCount; } FlexSkeletonHeader; // size = 0xC // Index into the frame data table. typedef struct { - /* 0x00 */ u16 x; - /* 0x02 */ u16 y; - /* 0x04 */ u16 z; -} JointIndex; // size = 0x06 + /* 0x0 */ u16 x; + /* 0x2 */ u16 y; + /* 0x4 */ u16 z; +} JointIndex; // size = 0x6 typedef struct { - /* 0x00 */ s16 frameCount; -} AnimationHeaderCommon; + /* 0x0 */ s16 frameCount; +} AnimationHeaderCommon; // size = 0x2 typedef struct { - /* 0x000 */ AnimationHeaderCommon common; - /* 0x004 */ s16* frameData; // referenced as tbl - /* 0x008 */ JointIndex* jointIndices; // referenced as ref_tbl - /* 0x00C */ u16 staticIndexMax; + /* 0x0 */ AnimationHeaderCommon common; + /* 0x4 */ s16* frameData; // referenced as tbl + /* 0x8 */ JointIndex* jointIndices; // referenced as ref_tbl + /* 0xC */ u16 staticIndexMax; } AnimationHeader; // size = 0x10 typedef struct { @@ -89,10 +89,10 @@ typedef struct { } JointKey; // size = 0x12 typedef struct { - /* 0x00 */ s16 frameCount; - /* 0x02 */ s16 limbCount; - /* 0x04 */ s16* frameData; - /* 0x08 */ JointKey* jointKey; + /* 0x0 */ s16 frameCount; + /* 0x2 */ s16 limbCount; + /* 0x4 */ s16* frameData; + /* 0x8 */ JointKey* jointKey; } LegacyAnimationHeader; // size = 0xC typedef enum { @@ -105,46 +105,46 @@ typedef enum { } AnimationType; typedef struct { - /* 0x000 */ DmaRequest req; - /* 0x020 */ OSMesgQueue msgQueue; - /* 0x038 */ OSMesg msg; + /* 0x00 */ DmaRequest req; + /* 0x20 */ OSMesgQueue msgQueue; + /* 0x38 */ OSMesg msg; } AnimEntryLoadFrame; // size = 0x3C typedef struct { - /* 0x000 */ u8 queueFlag; - /* 0x001 */ u8 vecCount; - /* 0x004 */ Vec3s* dst; - /* 0x008 */ Vec3s* src; + /* 0x0 */ u8 queueFlag; + /* 0x1 */ u8 vecCount; + /* 0x4 */ Vec3s* dst; + /* 0x8 */ Vec3s* src; } AnimEntryCopyAll; // size = 0xC typedef struct { - /* 0x000 */ u8 queueFlag; - /* 0x001 */ u8 vecCount; - /* 0x004 */ Vec3s* base; - /* 0x008 */ Vec3s* mod; - /* 0x00C */ f32 weight; + /* 0x0 */ u8 queueFlag; + /* 0x1 */ u8 vecCount; + /* 0x4 */ Vec3s* base; + /* 0x8 */ Vec3s* mod; + /* 0xC */ f32 weight; } AnimEntryInterp; // size = 0x10 typedef struct { - /* 0x000 */ u8 queueFlag; - /* 0x001 */ u8 vecCount; - /* 0x004 */ Vec3s* dst; - /* 0x008 */ Vec3s* src; - /* 0x00C */ u8* copyFlag; + /* 0x0 */ u8 queueFlag; + /* 0x1 */ u8 vecCount; + /* 0x4 */ Vec3s* dst; + /* 0x8 */ Vec3s* src; + /* 0xC */ u8* copyFlag; } AnimEntryCopyTrue; // size = 0x10 typedef struct { - /* 0x000 */ u8 queueFlag; - /* 0x001 */ u8 vecCount; - /* 0x004 */ Vec3s* dst; - /* 0x008 */ Vec3s* src; - /* 0x00C */ u8* copyFlag; + /* 0x0 */ u8 queueFlag; + /* 0x1 */ u8 vecCount; + /* 0x4 */ Vec3s* dst; + /* 0x8 */ Vec3s* src; + /* 0xC */ u8* copyFlag; } AnimEntryCopyFalse; // size = 0x10 typedef struct { - /* 0x000 */ struct Actor* actor; - /* 0x004 */ struct SkelAnime* skelAnime; - /* 0x008 */ f32 unk08; + /* 0x0 */ struct Actor* actor; + /* 0x4 */ struct SkelAnime* skelAnime; + /* 0x8 */ f32 unk08; } AnimEntryMoveActor; // size = 0xC typedef union { @@ -157,8 +157,8 @@ typedef union { } AnimationEntryData; // size = 0x3C typedef struct { - /* 0x000 */ u8 type; - /* 0x004 */ AnimationEntryData data; + /* 0x00 */ u8 type; + /* 0x04 */ AnimationEntryData data; } AnimationEntry; // size = 0x40 typedef struct AnimationContext { @@ -167,8 +167,8 @@ typedef struct AnimationContext { } AnimationContext; // size = 0xC84 typedef struct { - /* 0x000 */ AnimationHeaderCommon common; - /* 0x004 */ u32 segment; + /* 0x0 */ AnimationHeaderCommon common; + /* 0x4 */ u32 segment; } LinkAnimationHeader; // size = 0x8 typedef struct SkelAnime { @@ -187,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 PlayState*, struct SkelAnime*); // Loop, Play once, and Morph + } update; /* 0x34 */ s8 initFlags; // Flags used when initializing Link's skeleton /* 0x35 */ u8 moveFlags; // Flags used for animations that move the actor in worldspace. /* 0x36 */ s16 prevRot; // Previous rotation in worldspace. @@ -195,82 +198,32 @@ typedef struct SkelAnime { /* 0x3E */ Vec3s baseTransl; // Base modelspace translation. } SkelAnime; // size = 0x44 -typedef s32 (*OverrideLimbDrawOpa)(struct GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, +typedef s32 (*OverrideLimbDrawOpa)(struct PlayState* play, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, struct Actor* thisx); -typedef void (*PostLimbDrawOpa)(struct GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, +typedef void (*PostLimbDrawOpa)(struct PlayState* play, s32 limbIndex, Gfx** dList, Vec3s* rot, struct Actor* thisx); -typedef s32 (*OverrideLimbDraw)(struct GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, +typedef s32 (*OverrideLimbDraw)(struct PlayState* play, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, struct Actor* thisx, Gfx** gfx); -typedef void (*PostLimbDraw)(struct GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, +typedef void (*PostLimbDraw)(struct PlayState* play, s32 limbIndex, Gfx** dList, Vec3s* rot, struct Actor* thisx, Gfx** gfx); -typedef s32 (*OverrideLimbDrawFlex)(struct GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, +typedef s32 (*OverrideLimbDrawFlex)(struct PlayState* play, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, struct Actor* thisx); -typedef void (*PostLimbDrawFlex)(struct GlobalContext* globalCtx, s32 limbIndex, Gfx** dList1, Gfx** dList2, Vec3s* rot, +typedef void (*PostLimbDrawFlex)(struct PlayState* play, s32 limbIndex, Gfx** dList1, Gfx** dList2, Vec3s* rot, struct Actor* thisx); -typedef void (*TransformLimbDrawOpa)(struct GlobalContext* globalCtx, s32 limbIndex, struct Actor* thisx); +typedef void (*TransformLimbDrawOpa)(struct PlayState* play, s32 limbIndex, struct Actor* thisx); -typedef void (*TransformLimbDraw)(struct GlobalContext* globalCtx, s32 limbIndex, struct Actor* thisx, Gfx** gfx); +typedef void (*TransformLimbDraw)(struct PlayState* play, s32 limbIndex, struct Actor* thisx, Gfx** gfx); -typedef void (*AnimationEntryCallback)(struct GlobalContext*, AnimationEntryData*); +typedef void (*AnimationEntryCallback)(struct PlayState*, 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 - -typedef struct { - /* 0x0000 */ u8* refIndex; - /* 0x0004 */ TransformData* transformData; - /* 0x0008 */ s16* copyValues; - /* 0x000C */ s16 unk0C; - /* 0x000E */ s16 unk10; -} TransformUpdateIndex; // 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); - typedef struct { /* 0x00 */ AnimationHeader* animation; /* 0x04 */ f32 playSpeed; @@ -281,40 +234,40 @@ typedef struct { } AnimationInfo; // size = 0x18 typedef struct { - /* 0x00 */ AnimationHeader* animation; - /* 0x04 */ f32 playSpeed; - /* 0x08 */ s16 startFrame; - /* 0x0A */ s16 frameCount; - /* 0x0C */ u8 mode; - /* 0x0E */ s16 morphFrames; + /* 0x0 */ AnimationHeader* animation; + /* 0x4 */ f32 playSpeed; + /* 0x8 */ s16 startFrame; + /* 0xA */ s16 frameCount; + /* 0xC */ u8 mode; + /* 0xE */ s16 morphFrames; } AnimationInfoS; // size = 0x10 typedef struct AnimationSpeedInfo { - /* 0x00 */ AnimationHeader* animation; - /* 0x04 */ f32 playSpeed; - /* 0x08 */ u8 mode; - /* 0x0C */ f32 morphFrames; + /* 0x0 */ AnimationHeader* animation; + /* 0x4 */ f32 playSpeed; + /* 0x8 */ u8 mode; + /* 0xC */ f32 morphFrames; } AnimationSpeedInfo; // size = 0x10 struct SkeletonInfo; -typedef s32 (*UnkKeyframeCallback)(struct GlobalContext* globalCtx, struct SkeletonInfo* skeletonInfo, s32* arg2, Gfx** dList, +typedef s32 (*UnkKeyframeCallback)(struct PlayState* play, 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; + /* 0x0 */ Gfx* dList; + /* 0x4 */ u8 unk_4; + /* 0x5 */ u8 flags; + /* 0x6 */ 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 + /* 0x0 */ Gfx* dList; + /* 0x4 */ u8 unk_4; + /* 0x5 */ u8 flags; + /* 0x6 */ u8 unk_6; // transform limb draw index } Struct_801BFA14_Arg1_Field4_2; // size = 0x8 typedef struct { @@ -326,18 +279,18 @@ typedef struct { }; /* 0x08 */ s16* unk_8; /* 0x0C */ s16* unk_C; - /* 0x0C */ char unk_10[0x2]; + /* 0x10 */ char unk_10[0x2]; /* 0x12 */ s16 unk_12; -} Struct_801BFA14_Arg1; +} Struct_801BFA14_Arg1; // size = 0x14 typedef struct { /* 0x00 */ u16* unk_0; /* 0x04 */ s16* unk_4; /* 0x08 */ s16* unk_8; /* 0x0C */ s16* unk_C; - /* 0x0C */ char unk_10[0x2]; + /* 0x10 */ char unk_10[0x2]; /* 0x12 */ s16 unk_12; -} SkeletonInfo_1C; +} SkeletonInfo_1C; // size = 0x14 typedef struct { /* 0x00 */ f32 unk_0; @@ -346,7 +299,7 @@ typedef struct { /* 0x0C */ f32 unk_C; /* 0x10 */ f32 unk_10; /* 0x14 */ s32 unk_14; -} FrameControl; +} FrameControl; // size = 0x18 // FlexKeyframeSkeleton ? typedef struct SkeletonInfo { @@ -357,12 +310,12 @@ typedef struct SkeletonInfo { /* 0x24 */ f32 unk_24; // duration? current time? /* 0x28 */ Vec3s* frameData; // array of 3 Vec3s /* 0x2C */ s16* unk_2C; -} SkeletonInfo; +} SkeletonInfo; // size = 0x30 -typedef s32 (*OverrideKeyframeDrawScaled)(struct GlobalContext* globalCtx, SkeletonInfo* skeletonInfo, s32 limbIndex, Gfx** dList, +typedef s32 (*OverrideKeyframeDrawScaled)(struct PlayState* play, 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, +typedef void (*PostKeyframeDrawScaled)(struct PlayState* play, 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 5dd78f73a..4095251ca 100644 --- a/include/z64audio.h +++ b/include/z64audio.h @@ -8,9 +8,16 @@ #define TATUMS_PER_BEAT 48 #define IS_SEQUENCE_CHANNEL_VALID(ptr) ((uintptr_t)(ptr) != (uintptr_t)&gAudioContext.sequenceChannelNone) +#define SEQ_NUM_CHANNELS 16 #define MAX_CHANNELS_PER_BANK 3 +#define MUTE_FLAGS_3 (1 << 3) // prevent further noteSubEus from playing +#define MUTE_FLAGS_4 (1 << 4) // stop something in seqLayer scripts +#define MUTE_FLAGS_SOFTEN (1 << 5) // lower volume, by default to half +#define MUTE_FLAGS_STOP_NOTES (1 << 6) // prevent further notes from playing +#define MUTE_FLAGS_STOP_SCRIPT (1 << 7) // stop processing sequence/channel scripts + #define AUDIO_LERPIMP(v0, v1, t) (v0 + ((v1 - v0) * t)) #define ADSR_DISABLE 0 @@ -21,19 +28,12 @@ #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 -} AudioSoundMode; + /* 0 */ SOUNDMODE_STEREO, + /* 1 */ SOUNDMODE_HEADSET, + /* 2 */ SOUNDMODE_SURROUND, + /* 3 */ SOUNDMODE_MONO, + /* 4 */ SOUNDMODE_SURROUND_EXTERNAL, +} SoundMode; typedef enum { /* 0 */ ADSR_STATE_DISABLED, @@ -86,12 +86,12 @@ typedef enum { } AudioCacheType; typedef enum { - /* 0 */ LOAD_STATUS_0, - /* 1 */ LOAD_STATUS_1, - /* 2 */ LOAD_STATUS_2, // Samples/Seqplayer - /* 3 */ LOAD_STATUS_3, // Sequences - /* 4 */ LOAD_STATUS_4, // SoundFonts - /* 5 */ LOAD_STATUS_5 // Permanent + /* 0 */ LOAD_STATUS_NOT_LOADED, + /* 1 */ LOAD_STATUS_IN_PROGRESS, + /* 2 */ LOAD_STATUS_COMPLETE, + /* 3 */ LOAD_STATUS_DISCARDABLE, + /* 4 */ LOAD_STATUS_MAYBE_DISCARDABLE, + /* 5 */ LOAD_STATUS_PERMANENT } AudioLoadStatus; typedef s32 (*DmaHandler)(OSPiHandle* handle, OSIoMesg* mb, s32 direction); @@ -139,7 +139,7 @@ typedef struct { typedef struct { /* 0x0 */ s16 delay; /* 0x2 */ s16 arg; -} AdsrEnvelope; // size = 0x4 +} EnvelopePoint; // size = 0x4 typedef struct { /* 0x00 */ u32 start; @@ -231,19 +231,19 @@ typedef struct { /* 0x00 */ u8 loaded; /* 0x01 */ u8 normalRangeLo; /* 0x02 */ u8 normalRangeHi; - /* 0x03 */ u8 releaseRate; - /* 0x04 */ AdsrEnvelope* envelope; + /* 0x03 */ u8 adsrDecayIndex; // index used to obtain adsr decay rate from adsrDecayTable + /* 0x04 */ EnvelopePoint* envelope; /* 0x08 */ SoundFontSound lowNotesSound; /* 0x10 */ SoundFontSound normalNotesSound; /* 0x18 */ SoundFontSound highNotesSound; } Instrument; // size = 0x20 typedef struct { - /* 0x00 */ u8 releaseRate; + /* 0x00 */ u8 adsrDecayIndex; // index used to obtain adsr decay rate from adsrDecayTable /* 0x01 */ u8 pan; /* 0x02 */ u8 loaded; /* 0x04 */ SoundFontSound sound; - /* 0x14 */ AdsrEnvelope* envelope; + /* 0x14 */ EnvelopePoint* envelope; } Drum; // size = 0x18 typedef struct { @@ -277,11 +277,11 @@ typedef struct { /* 0x000 */ u8 applyBend : 1; /* 0x001 */ u8 state; /* 0x002 */ u8 noteAllocPolicy; - /* 0x003 */ u8 muteBehavior; + /* 0x003 */ u8 muteFlags; /* 0x004 */ u8 seqId; /* 0x005 */ u8 defaultFont; /* 0x006 */ u8 unk_06[1]; - /* 0x007 */ s8 playerIdx; + /* 0x007 */ s8 playerIndex; /* 0x008 */ u16 tempo; // tatums per minute /* 0x00A */ u16 tempoAcc; /* 0x00C */ s16 unk_0C; @@ -289,7 +289,7 @@ typedef struct { /* 0x010 */ u16 delay; /* 0x012 */ u16 fadeTimer; /* 0x014 */ u16 fadeTimerUnkEu; - /* 0x016 */ u16 unk_16; // New to MM + /* 0x016 */ u16 unk_16; union { /* 0x018 */ u8* seqData; /* 0x018 */ u16* seqData16; @@ -313,9 +313,9 @@ typedef struct { } SequencePlayer; // size = 0x160 typedef struct { - /* 0x0 */ u8 releaseRate; + /* 0x0 */ u8 decayIndex; // index used to obtain adsr decay rate from adsrDecayTable /* 0x1 */ u8 sustain; - /* 0x4 */ AdsrEnvelope* envelope; + /* 0x4 */ EnvelopePoint* envelope; } AdsrSettings; // size = 0x8 typedef struct { @@ -337,7 +337,7 @@ typedef struct { /* 0x10 */ f32 current; /* 0x14 */ f32 target; /* 0x18 */ char unk_18[4]; - /* 0x1C */ AdsrEnvelope* envelope; + /* 0x1C */ EnvelopePoint* envelope; } AdsrState; // size = 0x20 typedef struct { @@ -356,7 +356,7 @@ typedef union { typedef struct { /* 0x00 */ u8 reverb; - /* 0x01 */ u8 unk_1; + /* 0x01 */ u8 gain; // Increases volume by a multiplicative scaling factor. Represented as a UQ4.4 number /* 0x02 */ u8 pan; /* 0x03 */ u8 unk_3; // Possibly part of stereo? /* 0x04 */ Stereo stereo; @@ -397,7 +397,7 @@ typedef struct SequenceChannel { /* 0x01 */ u8 asByte; } changes; /* 0x02 */ u8 noteAllocPolicy; - /* 0x03 */ u8 muteBehavior; + /* 0x03 */ u8 muteFlags; /* 0x04 */ u8 reverb; // or dry/wet mix /* 0x05 */ u8 notePriority; // 0-3 /* 0x06 */ u8 someOtherPriority; @@ -406,12 +406,12 @@ typedef struct SequenceChannel { /* 0x09 */ u8 bookOffset; /* 0x0A */ u8 newPan; /* 0x0B */ u8 panChannelWeight; // proportion of pan that comes from the channel (0..128) - /* 0x0C */ u8 unk_0C; + /* 0x0C */ u8 gain; // Increases volume by a multiplicative scaling factor. Represented as a UQ4.4 number /* 0x0D */ u8 velocityRandomVariance; /* 0x0E */ u8 gateTimeRandomVariance; /* 0x0F */ u8 unk_0F; - /* 0x10 */ u8 unk_10; // New to MM - /* 0x11 */ u8 unk_11; // New to MM + /* 0x10 */ u8 unk_10; + /* 0x11 */ u8 unk_11; /* 0x12 */ VibratoSubStruct vibrato; /* 0x20 */ u16 delay; /* 0x22 */ u16 unk_20; @@ -434,11 +434,11 @@ typedef struct SequenceChannel { /* 0x80 */ AdsrSettings adsr; /* 0x88 */ NotePool notePool; /* 0xC8 */ s8 soundScriptIO[8]; // bridge between sound script and audio lib, "io ports" - /* 0xD0 */ u8* unk_D0; // New to MM + /* 0xD0 */ u8* sfxState; // SfxChannelState /* 0xD4 */ s16* filter; /* 0xD8 */ Stereo stereo; - /* 0xDC */ s32 unk_DC; // New to MM - /* 0xE0 */ s32 unk_E0; // New to MM + /* 0xDC */ s32 unk_DC; + /* 0xE0 */ s32 unk_E0; } SequenceChannel; // size = 0xE4 // Might also be known as a Track, according to sm64 debug strings (?). @@ -531,7 +531,7 @@ typedef struct { /* 0x04 */ u8 reverbVol; /* 0x05 */ u8 numParts; /* 0x06 */ u16 samplePosFrac; - /* 0x08 */ u16 unk_08; // New to MM + /* 0x08 */ u16 unk_08; /* 0x0C */ s32 samplePosInt; /* 0x10 */ NoteSynthesisBuffers* synthesisBuffers; /* 0x14 */ s16 curVolLeft; @@ -596,7 +596,7 @@ typedef struct { /* 0x01 */ u8 hasTwoParts : 1; /* 0x01 */ u8 usesHeadsetPanEffects2 : 1; } bitField1; - /* 0x02 */ u8 unk_2; + /* 0x02 */ u8 gain; // Increases volume by a multiplicative scaling factor. Represented as a UQ4.4 number /* 0x03 */ u8 headsetPanRight; /* 0x04 */ u8 headsetPanLeft; /* 0x05 */ u8 reverbVol; @@ -611,8 +611,8 @@ typedef struct { /* 0x10 */ s16* samples; // used for synthetic waves } sound; /* 0x14 */ s16* filter; - /* 0x18 */ u8 unk_18; // New to MM - /* 0x19 */ u8 unk_19; // New to MM + /* 0x18 */ u8 unk_18; + /* 0x19 */ u8 unk_19; /* 0x1A */ UNK_TYPE1 pad_1A[0x6]; } NoteSubEu; // size = 0x20 @@ -965,7 +965,7 @@ typedef struct { /* 0x4448 */ volatile u8 resetStatus; /* 0x4449 */ u8 audioResetSpecIdToLoad; /* 0x444C */ s32 audioResetFadeOutFramesLeft; - /* 0x4450 */ f32* unk_3520; // fadeOutVelocities for ADSR + /* 0x4450 */ f32* adsrDecayTable; // A table on the audio heap that stores decay rates used for ADSR /* 0x4454 */ u8* audioHeap; /* 0x4458 */ size_t audioHeapSize; /* 0x445C */ Note* notes; @@ -994,7 +994,7 @@ typedef struct { typedef struct { /* 0x00 */ u8 reverbVol; - /* 0x01 */ u8 unk_1; + /* 0x01 */ u8 gain; // Increases volume by a multiplicative scaling factor. Represented as a UQ4.4 number /* 0x02 */ u8 pan; /* 0x03 */ u8 unk_3; /* 0x04 */ Stereo stereo; @@ -1050,7 +1050,7 @@ typedef struct { /* 0x218 */ u8 unk_4C; /* 0x219 */ u8 unk_4D; /* 0x21A */ u8 unk_4E; - /* 0x21B */ u8 unk_21B; // New to MM + /* 0x21B */ u8 unk_21B; } unk_D_8016E750; // size = 0x21C typedef struct { @@ -1073,51 +1073,47 @@ typedef enum { /* 1 */ SFX_STATE_QUEUED, /* 2 */ SFX_STATE_READY, /* 3 */ SFX_STATE_PLAYING_REFRESH, - /* 4 */ SFX_STATE_PLAYING_1, - /* 5 */ SFX_STATE_PLAYING_2 + /* 4 */ SFX_STATE_PLAYING, + /* 5 */ SFX_STATE_PLAYING_ONE_FRAME } SfxState; typedef struct { - /* 0x00 */ f32* posX; - /* 0x04 */ f32* posY; - /* 0x08 */ f32* posZ; - /* 0x0C */ f32* freqScale; - /* 0x10 */ f32* vol; - /* 0x14 */ s8* reverbAdd; - /* 0x18 */ f32 dist; - /* 0x1C */ u32 priority; // lower is more prioritized - /* 0x20 */ u16 sfxParams; - /* 0x22 */ u16 sfxId; - /* 0x25 */ u8 sfxFlags; - /* 0x24 */ u8 sfxImportance; - /* 0x26 */ u8 state; // uses SfxState enum - /* 0x27 */ u8 freshness; - /* 0x28 */ u8 prev; - /* 0x29 */ u8 next; - /* 0x2A */ u8 channelIdx; - /* 0x2B */ u8 unk_2F; - /* 0x2C */ u8 token; + /* 0x00 */ f32* posX; + /* 0x04 */ f32* posY; + /* 0x08 */ f32* posZ; + /* 0x0C */ f32* freqScale; + /* 0x10 */ f32* volume; + /* 0x14 */ s8* reverbAdd; + /* 0x18 */ f32 dist; + /* 0x1C */ u32 priority; // lower is more prioritized + /* 0x20 */ u16 sfxParams; + /* 0x22 */ u16 sfxId; + /* 0x25 */ u8 sfxFlags; + /* 0x24 */ u8 sfxImportance; + /* 0x26 */ u8 state; // uses SfxState enum + /* 0x27 */ u8 freshness; + /* 0x28 */ u8 prev; + /* 0x29 */ u8 next; + /* 0x2A */ u8 channelIndex; + /* 0x2B */ u8 randFreq; + /* 0x2C */ u8 token; } SfxBankEntry; // size = 0x30 /* - * SFX IDs + * SfxId: * - * index 0000000111111111 observed in audio code - * & 200 0000001000000000 single bit - * & 400 0000010000000000 single bit - * & 800 0000100000000000 single bit, what we currently call SFX_FLAG - * & 600 0000011000000000 2 bits - * & A00 0000101000000000 2 bits - * & C00 0000110000000000 2 bits, observed in audio code - * & E00 0000111000000000 all 3 bits - * bank 1111000000000000 observed in audio code + * & 03FF 0000000111111111 index + * & 0400 0000010000000000 unused flag + * & 0800 0000100000000000 SFX_FLAG + * & 0C00 0000110000000000 Flag Mask + * & F000 1111000000000000 observed in audio code */ #define SFX_BANK_SHIFT(sfxId) (((sfxId) >> 12) & 0xFF) #define SFX_BANK_MASK(sfxId) ((sfxId) & 0xF000) -#define SFX_INDEX(sfxId) ((sfxId) & 0x03FF) +#define SFX_INDEX(sfxId) ((sfxId) & 0x3FF) #define SFX_BANK(sfxId) SFX_BANK_SHIFT(SFX_BANK_MASK(sfxId)) typedef struct { @@ -1125,19 +1121,74 @@ typedef struct { /* 0x4 */ u8 entryIndex; } ActiveSfx; // size = 0x08 +// SfxParams bit-packing + +// Slows the decay of volume with distance (a 3-bit number ranging from 0-7) +#define SFX_PARAM_DIST_RANGE_SHIFT 0 +#define SFX_PARAM_DIST_RANGE_MASK_UPPER (4 << SFX_PARAM_DIST_RANGE_SHIFT) +#define SFX_PARAM_DIST_RANGE_MASK (7 << SFX_PARAM_DIST_RANGE_SHIFT) + +// Lower SEQ_PLAYER_BGM_MAIN and SEQ_PLAYER_BGM_SUB while the sfx is playing +#define SFX_FLAG_LOWER_VOLUME_BGM (1 << 3) + +// Sfx priority is not raised with distance (making it more likely to be ejected) +#define SFX_FLAG_PRIORITY_NO_DIST (1 << 4) + +// If a new sfx is requested at both the same position with the same importance, +// Block that new sfx from replacing the current sfx +// Note: Only 1 sfx can be played at a specific position at once +#define SFX_FLAG_BLOCK_EQUAL_IMPORTANCE (1 << 5) + +// Applies increasingly random offsets to frequency (a 2-bit number ranging from 0-3) +#define SFX_PARAM_RAND_FREQ_RAISE_SHIFT 6 +#define SFX_PARAM_RAND_FREQ_RAISE_MASK (3 << SFX_PARAM_RAND_FREQ_RAISE_SHIFT) + +// Sets a flag to ioPort 5 +#define SFX_FLAG_8 (1 << 8) + +// Use lowpass filter on surround sound +#define SFX_FLAG_SURROUND_LOWPASS_FILTER (1 << 9) + +// Unused remnant of OoT +#define SFX_FLAG_BEHIND_SCREEN_Z_INDEX_SHIFT 10 +#define SFX_FLAG_BEHIND_SCREEN_Z_INDEX (1 << SFX_FLAG_BEHIND_SCREEN_Z_INDEX_SHIFT) + +// Randomly scale base frequency each frame through mutiplicative offset +#define SFX_PARAM_RAND_FREQ_SCALE (1 << 11) + +// Sfx reverb is not raised with distance +#define SFX_FLAG_REVERB_NO_DIST (1 << 12) + +// Sfx volume is not lowered with distance +#define SFX_FLAG_VOLUME_NO_DIST (1 << 13) + +// SFX_FLAG_VIBRATO +// Randomly lower base frequency each frame through additive offset +#define SFX_PARAM_RAND_FREQ_LOWER (1 << 14) + +// Sfx frequency is not raised with distance +#define SFX_FLAG_FREQ_NO_DIST (1 << 15) + +// Force the sfx to reset from the beginning when requested again +#define SFX_FLAG2_FORCE_RESET (1 << 0) + +// Unused +#define SFX_FLAG2_UNUSED2 (1 << 2) +#define SFX_FLAG2_UNUSED4 (1 << 4) + +// Do not use highpass filter on surround sound +#define SFX_FLAG2_SURROUND_NO_HIGHPASS_FILTER (1 << 5) + +// Unused +#define SFX_FLAG2_UNUSED6 (1 << 6) + +// Apply a low-pass filter with a lowPassCutoff of 4 +#define SFX_FLAG2_APPLY_LOWPASS_FILTER (1 << 7) + typedef struct { /* 0x0 */ u8 importance; /* 0x1 */ u8 flags; /* 0x2 */ u16 params; } SfxParams; // size = 0x4 -typedef struct { - /* 0x00 */ u16 sfxId; - /* 0x02 */ u8 token; - /* 0x04 */ s8* reverbAdd; - /* 0x08 */ Vec3f* pos; - /* 0x0C */ f32* freqScale; - /* 0x10 */ f32* vol; -} SoundRequest; // size = 0x14 - #endif diff --git a/include/z64bgcheck.h b/include/z64bgcheck.h index 0a5afb3d9..b42938354 100644 --- a/include/z64bgcheck.h +++ b/include/z64bgcheck.h @@ -1,7 +1,7 @@ #ifndef Z64_BGCHECK_H #define Z64_BGCHECK_H -struct GlobalContext; +struct PlayState; struct Actor; struct DynaPolyActor; @@ -72,27 +72,38 @@ typedef struct { } ScaleRotPos; // size = 0x20 typedef struct CollisionPoly { - /* 0x00 */ u16 type; + /* 0x0 */ u16 type; union { - u16 vtxData[3]; + /* 0x2 */ u16 vtxData[3]; struct { - /* 0x02 */ u16 flags_vIA; // 0xE000 is poly exclusion flags (xpFlags), 0x1FFF is vtxId - /* 0x04 */ u16 flags_vIB; // 0xE000 is flags, 0x1FFF is vtxId + /* 0x2 */ u16 flags_vIA; // 0xE000 is poly exclusion flags (xpFlags), 0x1FFF is vtxId + /* 0x4 */ u16 flags_vIB; // 0xE000 is flags, 0x1FFF is vtxId // 0x2000 = poly IsConveyor surface - /* 0x06 */ u16 vIC; + /* 0x6 */ u16 vIC; }; }; - /* 0x08 */ Vec3s normal; // Unit normal vector + /* 0x8 */ Vec3s normal; // Unit normal vector // Value ranges from -0x7FFF to 0x7FFF, representing -1.0 to 1.0; 0x8000 is invalid - /* 0x0E */ s16 dist; // Plane distance from origin along the normal + /* 0xE */ s16 dist; // Plane distance from origin along the normal } CollisionPoly; // size = 0x10 typedef struct { - /* 0x0 */ u16 setting; - /* 0x2 */ s16 numData; - /* 0x4 */ Vec3s* data; -} CamData; // size = 0x8 (BgCamData) + /* 0x0 */ u16 setting; // camera setting described by CameraSettingType enum + /* 0x2 */ s16 count; // only used when `bgCamFuncData` is a list of points used for crawlspaces (unused oot legacy) + /* 0x4 */ Vec3s* bgCamFuncData; // s16 data grouped in threes (ex. Vec3s), is usually of type `BgCamFuncData` +} BgCamInfo; // size = 0x8 + +typedef BgCamInfo CamData; // TODO: ZAPD compatibility + +// The structure used for all instances of s16 data from `BgCamInfo`. +typedef struct { + /* 0x00 */ Vec3s pos; + /* 0x06 */ Vec3s rot; + /* 0x0C */ s16 fov; + /* 0x0E */ s16 unk_0E; + /* 0x10 */ s16 unk_10; +} BgCamFuncData; // size = 0x12 typedef struct { /* 0x0 */ Vec3s minPos; @@ -137,7 +148,7 @@ typedef struct { /* 0x14 */ u16 numPolygons; /* 0x18 */ CollisionPoly* polyList; /* 0x1C */ SurfaceType* surfaceTypeList; - /* 0x20 */ CamData* cameraDataList; + /* 0x20 */ CamData* bgCamList; /* 0x24 */ u16 numWaterBoxes; /* 0x28 */ WaterBox* waterBoxes; } CollisionHeader; // size = 0x2C @@ -147,9 +158,10 @@ typedef struct { /* 0x2 */ u16 next; // index of the next SSNode in the list, or SS_NULL if last element } SSNode; // size = 0x4 +// represents a linked list of type SSNode typedef struct { - u16 head; // index of the first SSNode in the list, or SS_NULL if the list is empty -} SSList; // represents a linked list of type SSNode + /* 0x0 */ u16 head; // index of the first SSNode in the list, or SS_NULL if the list is empty +} SSList; // size = 0x2 typedef struct { /* 0x0 */ u16 max; @@ -223,7 +235,7 @@ typedef struct { } CollisionContext; // size = 0x1470 typedef struct { - /* 0x00 */ struct GlobalContext* globalCtx; + /* 0x00 */ struct PlayState* play; /* 0x04 */ CollisionContext* colCtx; /* 0x08 */ u16 xpFlags; /* 0x0C */ CollisionPoly** resultPoly; @@ -302,8 +314,9 @@ typedef struct { } BgSpecialSceneMeshSubdivision; // size = 0xC typedef struct { - s16 sceneId; - Vec3s subdivAmount; - s32 nodeListMax; // if -1, dynamically compute max nodes -} BgCheckSceneSubdivisionEntry; + /* 0x0 */ s16 sceneId; + /* 0x2 */ Vec3s subdivAmount; + /* 0x8 */ s32 nodeListMax; // if -1, dynamically compute max nodes +} BgCheckSceneSubdivisionEntry; // size = 0xC + #endif diff --git a/include/z64camera.h b/include/z64camera.h new file mode 100644 index 000000000..e3b3a4483 --- /dev/null +++ b/include/z64camera.h @@ -0,0 +1,387 @@ +#ifndef Z64CAMERA_H +#define Z64CAMERA_H + +#include "ultra64.h" + +// these two angle conversion macros are slightly inaccurate +#define CAM_DEG_TO_BINANG(degrees) (s16)((degrees) * ((f32)0xFFFF / 360) + .5f) +#define CAM_BINANG_TO_DEG(binang) ((f32)(binang) * (360.0001525f / 0xFFFF)) + +#define NUM_CAMS 4 + +// Camera IDs are indices into `cameraPtrs` +#define CAM_ID_MAIN 0 // The index of the main camera +#define CAM_ID_SUB_FIRST 1 // The index sub cameras start at +#define CAM_ID_NONE -1 // Used to indicate no camera. Can be used to default to the active camera in some scenarios + +#define SUB_CAM_ID_DONE 0 // Used in some actors for variables holding sub camera IDs to indicate "subcam is finished" + +// Camera behaviorFlags. Flags specifically for settings, modes, and bgCam +// Used to store current state, only CAM_BEHAVIOR_SETTING_1 and CAM_BEHAVIOR_BG_2 are read from and used in logic +// Setting (0x1, 0x10) +#define CAM_BEHAVIOR_SETTING_USE_PRIORITY (1 << 0) // Use settings priority system +#define CAM_BEHAVIOR_SETTING_2 (1 << 4) +// Mode (0x2, 0x20) +#define CAM_BEHAVIOR_MODE_1 (1 << 1) +#define CAM_BEHAVIOR_MODE_2 (1 << 5) +// bgCam (0x4, 0x40) +#define CAM_BEHAVIOR_BGCAM_1 (1 << 2) +#define CAM_BEHAVIOR_BGCAM_2 (1 << 6) + +// Camera stateFlags. Variety of generic flags +#define CAM_STATE_0 (1 << 0) // Must be set for the camera from changing settings based on the bg surface +#define CAM_STATE_1 (1 << 1) +#define CAM_STATE_2 (1 << 2) +#define CAM_STATE_3 (1 << 3) +#define CAM_STATE_4 (1 << 4) +#define CAM_STATE_5 (1 << 5) +#define CAM_STATE_6 (1 << 6) +#define CAM_STATE_7 (1 << 7) +#define CAM_STATE_UNDERWATER (1 << 8) +#define CAM_STATE_9 (1 << 9) +#define CAM_STATE_10 (1 << 10) // Surpresses the camera from changing settings based on the bg surface +#define CAM_STATE_11 (1 << 11) +#define CAM_STATE_12 (1 << 12) +#define CAM_STATE_13 (1 << 13) +#define CAM_STATE_14 (1 << 14) +#define CAM_STATE_15 ((s16)(1 << 15)) + +// Camera viewFlags. Set params related to view +#define CAM_VIEW_AT (1 << 0) // camera->at +#define CAM_VIEW_EYE (1 << 1) // camera->eye and camera->eyeNext +#define CAM_VIEW_UP (1 << 2) // camera->up +#define CAM_VIEW_TARGET (1 << 3) // camera->target +#define CAM_VIEW_TARGET_POS (1 << 4) // camera->targetPosRot.pos +#define CAM_VIEW_FOV (1 << 5) // camera->fov +#define CAM_VIEW_ROLL (1 << 6) // camera->roll + +/** + * Camera Status type + * Determines how much the camera is updated each frame + * Higher values represents higher levels of activity + */ +// Camera is on +#define CAM_STATUS_CUT 0 // The camera is not updated at all +#define CAM_STATUS_WAIT 1 // There is minimally/partially updated, action function is not run +#define CAM_STATUS_UNK3 3 // The camera is mostly updated including running its action function, but data is not set to view +#define CAM_STATUS_ACTIVE 7 // The camera is fully updated, info is sent to view +// Camera is off +#define CAM_STATUS_INACTIVE 0x100 + +typedef enum { + /* 0x00 */ CAM_SET_NONE, + /* 0x01 */ CAM_SET_NORMAL0, // Generic camera 0, used in various places "NORMAL0" + /* 0x02 */ CAM_SET_NORMAL3, // Generic camera 3, used in various places "NORMAL3" + /* 0x03 */ CAM_SET_PIVOT_DIVING, // Player diving from the surface of the water to underwater not as zora "CIRCLE5" + /* 0x04 */ CAM_SET_HORSE, // Reiding a horse "HORSE0" + /* 0x05 */ CAM_SET_ZORA_DIVING, // Parallel's Pivot Diving, but as Zora. However, Zora does not dive like a human. So this setting appears to not be used "ZORA0" + /* 0x06 */ CAM_SET_PREREND_FIXED, // Unused remnant of OoT: camera is fixed in position and rotation "PREREND0" + /* 0x07 */ CAM_SET_PREREND_PIVOT, // Unused remnant of OoT: Camera is fixed in position with fixed pitch, but is free to rotate in the yaw direction 360 degrees "PREREND1" + /* 0x08 */ CAM_SET_DOORC, // Generic room door transitions, camera moves and follows player as the door is open and closed "DOORC" + /* 0x09 */ CAM_SET_DEMO0, // Unknown, possibly related to treasure chest game as goron? "DEMO0" + /* 0x0A */ CAM_SET_FREE0, // Free Camera, manual control is given, no auto-updating eye or at "FREE0" + /* 0x0B */ CAM_SET_BIRDS_EYE_VIEW_0, // Appears unused. Camera is a top-down view "FUKAN0" + /* 0x0C */ CAM_SET_NORMAL1, // Generic camera 1, used in various places "NORMAL1" + /* 0x0D */ CAM_SET_NANAME, // Unknown, slanted or tilted. Behaves identical to Normal0 except with added roll "NANAME" + /* 0x0E */ CAM_SET_CIRCLE0, // Used in Curiosity Shop, Pirates Fortress, Mayor's Residence "CIRCLE0" + /* 0x0F */ CAM_SET_FIXED0, // Used in Sakon's Hideout puzzle rooms, milk bar stage "FIXED0" + /* 0x10 */ CAM_SET_SPIRAL_DOOR, // Exiting a Spiral Staircase "SPIRAL" + /* 0x11 */ CAM_SET_DUNGEON0, // Generic dungeon camera 0, used in various places "DUNGEON0" + /* 0x12 */ CAM_SET_ITEM0, // Getting an item and holding it above Player's head (from small chest, freestanding, npc, ...) "ITEM0" + /* 0x13 */ CAM_SET_ITEM1, // Looking at player while playing the ocarina "ITEM1" + /* 0x14 */ CAM_SET_ITEM2, // Bottles: drinking, releasing fairy, dropping fish "ITEM2" + /* 0x15 */ CAM_SET_ITEM3, // Bottles: catching fish or bugs, showing an item "ITEM3" + /* 0x16 */ CAM_SET_NAVI, // Song of Soaring, variations of playing Song of Time "NAVI" + /* 0x17 */ CAM_SET_WARP_PAD_MOON, // Warp circles from Goron Trial on the moon "WARP0" + /* 0x18 */ CAM_SET_DEATH, // Player death animation when health goes to 0 "DEATH" + /* 0x19 */ CAM_SET_REBIRTH, // Unknown set with camDataId = -9 (it's not being revived by a fairy) "REBIRTH" + /* 0x1A */ CAM_SET_LONG_CHEST_OPENING, // Long cutscene when opening a big chest with a major item "TREASURE" + /* 0x1B */ CAM_SET_MASK_TRANSFORMATION, // Putting on a transformation mask "TRANSFORM" + /* 0x1C */ CAM_SET_ATTENTION, // Unknown, set with camDataId = -15 "ATTENTION" + /* 0x1D */ CAM_SET_WARP_PAD_ENTRANCE, // Warp pad from start of a dungeon to the boss-room "WARP1" + /* 0x1E */ CAM_SET_DUNGEON1, // Generic dungeon camera 1, used in various places "DUNGEON1" + /* 0x1F */ CAM_SET_FIXED1, // Fixes camera in place, used in various places eg. entering Stock Pot Inn, hiting a switch, giving witch a red potion, shop browsing "FIXED1" + /* 0x20 */ CAM_SET_FIXED2, // Used in Pinnacle Rock after defeating Sea Monsters, and by Tatl in Fortress "FIXED2" + /* 0x21 */ CAM_SET_MAZE, // Unused. Set to use Camera_Parallel2(), which is only Camera_Noop() "MAZE" + /* 0x22 */ CAM_SET_REMOTEBOMB, // Unused. Set to use Camera_Parallel2(), which is only Camera_Noop(). But also related to Play_ChangeCameraSetting? "REMOTEBOMB" + /* 0x23 */ CAM_SET_CIRCLE1, // Unknown "CIRCLE1" + /* 0x24 */ CAM_SET_CIRCLE2, // Looking at far-away NPCs eg. Garo in Road to Ikana, Hungry Goron, Tingle "CIRCLE2" + /* 0x25 */ CAM_SET_CIRCLE3, // Used in curiosity shop, goron racetrack, final room in Sakon's hideout, other places "CIRCLE3" + /* 0x26 */ CAM_SET_CIRCLE4, // Used during the races on the doggy racetrack "CIRCLE4" + /* 0x27 */ CAM_SET_FIXED3, // Used in Stock Pot Inn Toilet and Tatl cutscene after woodfall "FIXED3" + /* 0x28 */ CAM_SET_TOWER_ASCENT, // Various climbing structures (Snowhead climb to the temple entrance) "TOWER0" + /* 0x29 */ CAM_SET_PARALLEL0, // Unknown "PARALLEL0" + /* 0x2A */ CAM_SET_NORMALD, // Unknown, set with camDataId = -20 "NORMALD" + /* 0x2B */ CAM_SET_SUBJECTD, // Unknown, set with camDataId = -21 "SUBJECTD" + /* 0x2C */ CAM_SET_START0, // Entering a room, either Dawn of a New Day reload, or entering a door where the camera is fixed on the other end "START0" + /* 0x2D */ CAM_SET_START2, // Entering a scene, camera is put at a low angle eg. Grottos, Deku Palace, Stock Pot Inn "START2" + /* 0x2E */ CAM_SET_STOP0, // Called in z_play "STOP0" + /* 0x2F */ CAM_SET_BOAT_CRUISE, // Koume's boat cruise "JCRUISING" + /* 0x30 */ CAM_SET_VERTICAL_CLIMB, // Large vertical climbs, such as Mountain Village wall or Pirates Fortress ladder. "CLIMBMAZE" + /* 0x31 */ CAM_SET_SIDED, // Unknown, set with camDataId = -24 "SIDED" + /* 0x32 */ CAM_SET_DUNGEON2, // Generic dungeon camera 2, used in various places "DUNGEON2" + /* 0x33 */ CAM_SET_BOSS_ODOLWA, // Odolwa's Lair, also used in GBT entrance: "BOSS_SHIGE" + /* 0x34 */ CAM_SET_KEEPBACK, // Unknown. Possibly related to climbing something? "KEEPBACK" + /* 0x35 */ CAM_SET_CIRCLE6, // Used in select regions from Ikana "CIRCLE6" + /* 0x36 */ CAM_SET_CIRCLE7, // Unknown "CIRCLE7" + /* 0x37 */ CAM_SET_MINI_BOSS, // Used during the various minibosses of the "CHUBOSS" + /* 0x38 */ CAM_SET_RFIXED1, // Talking to Koume stuck on the floor in woods of mystery "RFIXED1" + /* 0x39 */ CAM_SET_TREASURE_CHEST_MINIGAME, // Treasure Chest Shop in East Clock Town, minigame location "TRESURE1" + /* 0x3A */ CAM_SET_HONEY_AND_DARLING_1, // Honey and Darling Minigames "BOMBBASKET" + /* 0x3B */ CAM_SET_CIRCLE8, // Used by Stone Tower moving platforms, Falling eggs in Marine Lab, Bugs into soilpatch cutscene "CIRCLE8" + /* 0x3C */ CAM_SET_BIRDS_EYE_VIEW_1, // Camera is a top-down view. Used in Fisherman's minigame and Deku Palace "FUKAN1" + /* 0x3D */ CAM_SET_DUNGEON3, // Generic dungeon camera 3, used in various places "DUNGEON3" + /* 0x3E */ CAM_SET_TELESCOPE, // Observatory telescope and Curiosity Shop Peep-Hole "TELESCOPE" + /* 0x3F */ CAM_SET_ROOM0, // Certain rooms eg. inside the clock tower "ROOM0" + /* 0x40 */ CAM_SET_RCIRC0, // Used by a few NPC cutscenes, focus close on the NPC "RCIRC0" + /* 0x41 */ CAM_SET_CIRCLE9, // Used by Sakon Hideout entrance and Deku Palace Maze "CIRCLE9" + /* 0x42 */ CAM_SET_ONTHEPOLE, // Somewhere in Snowhead Temple and Woodfall Temple "ONTHEPOLE" + /* 0x43 */ CAM_SET_INBUSH, // Various bush environments eg. grottos, Swamp Spider House, Termina Field grass bushes, Deku Palace near bean "INBUSH" + /* 0x44 */ CAM_SET_BOSS_MAJORA, // Majora's Lair: "BOSS_LAST" + /* 0x45 */ CAM_SET_BOSS_TWINMOLD, // Twinmold's Lair: "BOSS_INI" + /* 0x46 */ CAM_SET_BOSS_GOHT, // Goht's Lair: "BOSS_HAK" + /* 0x47 */ CAM_SET_BOSS_GYORG, // Gyorg's Lair: "BOSS_KON" + /* 0x48 */ CAM_SET_CONNECT0, // Smoothly and gradually return camera to Player after a cutscene "CONNECT0" + /* 0x49 */ CAM_SET_PINNACLE_ROCK, // Pinnacle Rock pit "MORAY" + /* 0x4A */ CAM_SET_NORMAL2, // Generic camera 2, used in various places "NORMAL2" + /* 0x4B */ CAM_SET_HONEY_AND_DARLING_2, // "BOMBBOWL" + /* 0x4C */ CAM_SET_CIRCLEA, // Unknown, Circle 10 "CIRCLEA" + /* 0x4D */ CAM_SET_WHIRLPOOL, // Great Bay Temple Central Room Whirlpool "WHIRLPOOL" + /* 0x4E */ CAM_SET_CUCCO_SHACK, // "KOKKOGAME" + /* 0x4F */ CAM_SET_GIANT, // Giants Mask in Twinmold's Lair "GIANT" + /* 0x50 */ CAM_SET_SCENE0, // Entering doors to a new scene "SCENE0" + /* 0x51 */ CAM_SET_ROOM1, // Certain rooms eg. some rooms in Stock Pot Inn "ROOM1" + /* 0x52 */ CAM_SET_WATER2, // Swimming as Zora in Great Bay Temple "WATER2" + /* 0x53 */ CAM_SET_WOODFALL_SWAMP, // Woodfall inside the swamp, but not on the platforms, "SOKONASI" + /* 0x54 */ CAM_SET_FORCEKEEP, // Unknown "FORCEKEEP" + /* 0x55 */ CAM_SET_PARALLEL1, // Unknown "PARALLEL1" + /* 0x56 */ CAM_SET_START1, // Used when entering the lens cave "START1" + /* 0x57 */ CAM_SET_ROOM2, // Certain rooms eg. Deku King's Chamber, Ocean Spider House "ROOM2" + /* 0x58 */ CAM_SET_NORMAL4, // Generic camera 4, used in Ikana Graveyard "NORMAL4" + /* 0x59 */ CAM_SET_ELEGY_SHELL, // cutscene after playing elegy of emptyness and spawning a shell "SHELL" + /* 0x5A */ CAM_SET_DUNGEON4, // Used in Pirates Fortress Interior, hidden room near hookshot "DUNGEON4" + /* 0x5B */ CAM_SET_MAX +} CameraSettingType; + +typedef enum { + /* 0x00 */ CAM_MODE_NORMAL, // "NORMAL" + /* 0x01 */ CAM_MODE_JUMP, // "JUMP" + /* 0x02 */ CAM_MODE_GORONDASH, // "GORONDASH" + /* 0x03 */ CAM_MODE_DEKUSHOOT, // "NUTSSHOT" + /* 0x04 */ CAM_MODE_BOWARROWZ, // "BOWARROWZ" + /* 0x05 */ CAM_MODE_DEKUFLY, // "NUTSFLY" + /* 0x06 */ CAM_MODE_FIRSTPERSON, // "SUBJECT" + /* 0x07 */ CAM_MODE_FOLLOWBOOMERANG, // "BOOKEEPON" + /* 0x08 */ CAM_MODE_ZORAFIN, // "ZORAFIN" + /* 0x09 */ CAM_MODE_FOLLOWTARGET, // "KEEPON" + /* 0x0A */ CAM_MODE_TARGET, // "PARALLEL" + /* 0x0B */ CAM_MODE_TALK, // "TALK" + /* 0x0C */ CAM_MODE_SLINGSHOT, // "PACHINCO" + /* 0x0D */ CAM_MODE_BOWARROW, // "BOWARROW" + /* 0x0E */ CAM_MODE_BATTLE, // "BATTLE" + /* 0x0F */ CAM_MODE_DEKUHIDE, // "NUTSHIDE" + /* 0x10 */ CAM_MODE_STILL, // "STILL" + /* 0x11 */ CAM_MODE_CHARGE, // "CHARGE" + /* 0x12 */ CAM_MODE_CLIMB, // "CLIMB" + /* 0x13 */ CAM_MODE_CLIMBZ, // "CLIMBZ" + /* 0x14 */ CAM_MODE_HOOKSHOT, // "FOOKSHOT" + /* 0x15 */ CAM_MODE_FREEFALL, // "FREEFALL" + /* 0x16 */ CAM_MODE_HANG, // "HANG" + /* 0x17 */ CAM_MODE_HANGZ, // "HANGZ + /* 0x18 */ CAM_MODE_PUSHPULL, // "PUSHPULL" + /* 0x19 */ CAM_MODE_DEKUFLYZ, // "CNUTSFLYZ" + /* 0x1A */ CAM_MODE_GORONJUMP, // "GORONJUMP" + /* 0x1B */ CAM_MODE_BOOMERANG, // "BOOMERANG" + /* 0x1C */ CAM_MODE_CHARGEZ, // "CHARGEZ" + /* 0x1D */ CAM_MODE_ZORAFINZ, // "ZORAFINZ" + /* 0x1E */ CAM_MODE_MAX +} CameraModeType; + +typedef enum { + /* 0x00 */ CAM_FUNC_NONE, + /* 0x01 */ CAM_FUNC_NORMAL0, + /* 0x02 */ CAM_FUNC_NORMAL1, + /* 0x03 */ CAM_FUNC_NORMAL2, + /* 0x04 */ CAM_FUNC_NORMAL3, + /* 0x05 */ CAM_FUNC_NORMAL4, + /* 0x06 */ CAM_FUNC_PARALLEL0, + /* 0x07 */ CAM_FUNC_PARALLEL1, + /* 0x08 */ CAM_FUNC_PARALLEL2, + /* 0x09 */ CAM_FUNC_PARALLEL3, + /* 0x0A */ CAM_FUNC_PARALLEL4, + /* 0x0B */ CAM_FUNC_KEEPON0, + /* 0x0C */ CAM_FUNC_KEEPON1, + /* 0x0D */ CAM_FUNC_KEEPON2, + /* 0x0E */ CAM_FUNC_KEEPON3, + /* 0x0F */ CAM_FUNC_KEEPON4, + /* 0x10 */ CAM_FUNC_SUBJECT0, + /* 0x11 */ CAM_FUNC_SUBJECT1, + /* 0x12 */ CAM_FUNC_SUBJECT2, + /* 0x13 */ CAM_FUNC_SUBJECT3, + /* 0x14 */ CAM_FUNC_SUBJECT4, + /* 0x15 */ CAM_FUNC_JUMP0, + /* 0x16 */ CAM_FUNC_JUMP1, + /* 0x17 */ CAM_FUNC_JUMP2, + /* 0x18 */ CAM_FUNC_JUMP3, + /* 0x19 */ CAM_FUNC_JUMP4, + /* 0x1A */ CAM_FUNC_BATTLE0, + /* 0x1B */ CAM_FUNC_BATTLE1, + /* 0x1C */ CAM_FUNC_BATTLE2, + /* 0x1D */ CAM_FUNC_BATTLE3, + /* 0x1E */ CAM_FUNC_BATTLE4, + /* 0x1F */ CAM_FUNC_FIXED0, + /* 0x20 */ CAM_FUNC_FIXED1, + /* 0x21 */ CAM_FUNC_FIXED2, + /* 0x22 */ CAM_FUNC_FIXED3, + /* 0x23 */ CAM_FUNC_FIXED4, + /* 0x24 */ CAM_FUNC_DATA0, + /* 0x25 */ CAM_FUNC_DATA1, + /* 0x26 */ CAM_FUNC_DATA2, + /* 0x27 */ CAM_FUNC_DATA3, + /* 0x28 */ CAM_FUNC_DATA4, + /* 0x29 */ CAM_FUNC_UNIQUE0, + /* 0x2A */ CAM_FUNC_UNIQUE1, + /* 0x2B */ CAM_FUNC_UNIQUE2, + /* 0x2C */ CAM_FUNC_UNIQUE3, + /* 0x2D */ CAM_FUNC_UNIQUE4, + /* 0x2E */ CAM_FUNC_UNIQUE5, + /* 0x2F */ CAM_FUNC_UNIQUE6, + /* 0x30 */ CAM_FUNC_UNIQUE7, + /* 0x31 */ CAM_FUNC_UNIQUE8, + /* 0x32 */ CAM_FUNC_UNIQUE9, + /* 0x33 */ CAM_FUNC_DEMO0, + /* 0x34 */ CAM_FUNC_DEMO1, + /* 0x35 */ CAM_FUNC_DEMO2, + /* 0x36 */ CAM_FUNC_DEMO3, + /* 0x37 */ CAM_FUNC_DEMO4, + /* 0x38 */ CAM_FUNC_DEMO5, + /* 0x39 */ CAM_FUNC_DEMO6, + /* 0x3A */ CAM_FUNC_DEMO7, + /* 0x3B */ CAM_FUNC_DEMO8, + /* 0x3C */ CAM_FUNC_DEMO9, + /* 0x3D */ CAM_FUNC_SPECIAL0, + /* 0x3E */ CAM_FUNC_SPECIAL1, + /* 0x3F */ CAM_FUNC_SPECIAL2, + /* 0x40 */ CAM_FUNC_SPECIAL3, + /* 0x41 */ CAM_FUNC_SPECIAL4, + /* 0x42 */ CAM_FUNC_SPECIAL5, + /* 0x43 */ CAM_FUNC_SPECIAL6, + /* 0x44 */ CAM_FUNC_SPECIAL7, + /* 0x45 */ CAM_FUNC_SPECIAL8, + /* 0x46 */ CAM_FUNC_SPECIAL9, + /* 0x47 */ CAM_FUNC_MAX +} CameraFuncType; + +typedef enum { + /* 0x00 */ CAM_DATA_00, + /* 0x01 */ CAM_DATA_01, + /* 0x02 */ CAM_DATA_02, + /* 0x03 */ CAM_DATA_03, + /* 0x04 */ CAM_DATA_04, + /* 0x05 */ CAM_DATA_05, + /* 0x06 */ CAM_DATA_06, + /* 0x07 */ CAM_DATA_07, + /* 0x08 */ CAM_DATA_08, + /* 0x09 */ CAM_DATA_09, + /* 0x0A */ CAM_DATA_10, + /* 0x0B */ CAM_DATA_11, + /* 0x0C */ CAM_DATA_12, + /* 0x0D */ CAM_DATA_13, + /* 0x0E */ CAM_DATA_14, + /* 0x0F */ CAM_DATA_15, + /* 0x10 */ CAM_DATA_16, + /* 0x11 */ CAM_DATA_17, + /* 0x12 */ CAM_DATA_18, + /* 0x13 */ CAM_DATA_19, + /* 0x14 */ CAM_DATA_20, + /* 0x15 */ CAM_DATA_21, +} CameraDataType; + +typedef struct { + /* 0x0 */ s16 val; + /* 0x2 */ s16 param; +} CameraModeValue; // size = 0x4 + +typedef struct { + /* 0x0 */ s16 funcId; + /* 0x2 */ s16 numValues; + /* 0x4 */ CameraModeValue* values; +} CameraMode; // size = 0x8 + +/** + * Flags: + * (flags & 0xF): Priority (lower value has higher priority) + * (flags & 0x40000000): Store previous setting and bgCamData, also ignores water checks + * (flags & 0x80000000): Set camera setting based on bg/scene data and reset action function state + */ +typedef struct { + /* 0x0 */ u32 validModes; + /* 0x4 */ u32 flags; + /* 0x8 */ CameraMode* cameraModes; +} CameraSetting; // size = 0xC + +typedef struct Camera { + /* 0x000 */ u8 paramData[0x50]; // function Data, acts like a heap that's reset every time a new action function is switched to + /* 0x050 */ Vec3f at; + /* 0x05C */ Vec3f eye; + /* 0x068 */ Vec3f up; + /* 0x074 */ Vec3f eyeNext; + /* 0x080 */ Vec3f quakeOffset; + /* 0x08C */ struct PlayState* play; + /* 0x090 */ Actor* focalActor; // the actor the camera is focused on. Most often Player, but can be any actor + /* 0x094 */ PosRot focalActorPosRot; + /* 0x0A8 */ Actor* target; // the actor that is being z-targeted + /* 0x0AC */ PosRot targetPosRot; + /* 0x0C0 */ f32 rUpdateRateInv; + /* 0x0C4 */ f32 pitchUpdateRateInv; + /* 0x0C8 */ f32 yawUpdateRateInv; + /* 0x0CC */ f32 yOffsetUpdateRate; + /* 0x0D0 */ f32 xzOffsetUpdateRate; + /* 0x0D4 */ f32 fovUpdateRate; + /* 0x0D8 */ f32 xzSpeed; + /* 0x0DC */ f32 dist; + /* 0x0E0 */ f32 speedRatio; + /* 0x0E4 */ Vec3f atActorOffset; + /* 0x0F0 */ Vec3f focalActorOffset; + /* 0x0FC */ f32 fov; + /* 0x100 */ f32 atLerpStepScale; + /* 0x104 */ f32 playerFloorHeight; + /* 0x108 */ Vec3f floorNorm; + /* 0x114 */ f32 waterYPos; + /* 0x118 */ s32 waterPrevBgCamDataId; + /* 0x11C */ s32 waterPrevCamSetting; + /* 0x120 */ s16 waterQuakeId; + /* 0x122 */ s16 unk122; + /* 0x124 */ void* data0; + /* 0x128 */ void* data1; + /* 0x12C */ s16 data2; + /* 0x12E */ s16 data3; + /* 0x130 */ s16 uid; + /* 0x132 */ UNK_TYPE1 unk_132[2]; + /* 0x134 */ Vec3s inputDir; + /* 0x13A */ Vec3s camDir; + /* 0x140 */ s16 status; + /* 0x142 */ s16 setting; + /* 0x144 */ s16 mode; + /* 0x146 */ s16 bgId; + /* 0x148 */ s16 bgCamDataId; + /* 0x14A */ s16 behaviorFlags; + /* 0x14C */ s16 stateFlags; + /* 0x14E */ s16 childCamId; + /* 0x150 */ s16 doorTimer1; // a door timer used when door cam is indexed from bgCamDataId + /* 0x152 */ s16 unk152; + /* 0x154 */ s16 prevSetting; + /* 0x156 */ s16 nextCamSceneDataId; + /* 0x158 */ s16 nextBgId; + /* 0x15A */ s16 roll; + /* 0x15C */ s16 viewFlags; + /* 0x15E */ s16 animState; // Determines the current state of the current camera behavior function + /* 0x160 */ s16 unk160; + /* 0x162 */ s16 doorTimer2; // a door timer used when door cam is indexed from bgCamDataId + /* 0x164 */ s16 camId; + /* 0x166 */ s16 prevBgCamDataId; + /* 0x168 */ s16 unk168; + /* 0x16C */ Vec3f meshActorPos; +} Camera; // size = 0x178 + +#endif diff --git a/include/z64collision_check.h b/include/z64collision_check.h index fbfcff7ae..434b74a3a 100644 --- a/include/z64collision_check.h +++ b/include/z64collision_check.h @@ -21,54 +21,54 @@ typedef struct { } Collider; // size = 0x18 typedef struct { - /* 0x00 */ u8 colType; // Determines hitmarks and sound effects during AC collisions. - /* 0x01 */ u8 atFlags; // Information flags for AT collisions. - /* 0x02 */ u8 acFlags; // Information flags for OC collisions. - /* 0x03 */ u8 ocFlags1; // Information flags for OC collisions. - /* 0x04 */ u8 ocFlags2; // Flags related to which colliders it can OC collide with. - /* 0x05 */ u8 shape; // JntSph, Cylinder, Tris, or Quad -} ColliderInit; // size = 0x06 + /* 0x0 */ u8 colType; // Determines hitmarks and sound effects during AC collisions. + /* 0x1 */ u8 atFlags; // Information flags for AT collisions. + /* 0x2 */ u8 acFlags; // Information flags for OC collisions. + /* 0x3 */ u8 ocFlags1; // Information flags for OC collisions. + /* 0x4 */ u8 ocFlags2; // Flags related to which colliders it can OC collide with. + /* 0x5 */ u8 shape; // JntSph, Cylinder, Tris, or Quad +} ColliderInit; // size = 0x6 typedef struct { - /* 0x00 */ u8 colType; // Determines hitmarks and sound effects during AC collisions. - /* 0x01 */ u8 atFlags; // Information flags for AT collisions. - /* 0x02 */ u8 acFlags; // Information flags for AC collisions. - /* 0x03 */ u8 ocFlags1; // Information flags for OC collisions. - /* 0x04 */ u8 shape; // JntSph, Cylinder, Tris, or Quad -} ColliderInitType1; // size = 0x05 + /* 0x0 */ u8 colType; // Determines hitmarks and sound effects during AC collisions. + /* 0x1 */ u8 atFlags; // Information flags for AT collisions. + /* 0x2 */ u8 acFlags; // Information flags for AC collisions. + /* 0x3 */ u8 ocFlags1; // Information flags for OC collisions. + /* 0x4 */ u8 shape; // JntSph, Cylinder, Tris, or Quad +} ColliderInitType1; // size = 0x5 typedef struct { - /* 0x00 */ struct Actor* actor; // Attached actor - /* 0x04 */ u8 atFlags; // Information flags for AT collisions. - /* 0x05 */ u8 acFlags; // Information flags for AC collisions. - /* 0x06 */ u8 ocFlags1; // Information flags for OC collisions. - /* 0x07 */ u8 shape; // JntSph, Cylinder, Tris, or Quad -} ColliderInitToActor; // size = 0x08 + /* 0x0 */ struct Actor* actor; // Attached actor + /* 0x4 */ u8 atFlags; // Information flags for AT collisions. + /* 0x5 */ u8 acFlags; // Information flags for AC collisions. + /* 0x6 */ u8 ocFlags1; // Information flags for OC collisions. + /* 0x7 */ u8 shape; // JntSph, Cylinder, Tris, or Quad +} ColliderInitToActor; // size = 0x8 typedef struct { - /* 0x00 */ u32 dmgFlags; // Toucher damage type flags. - /* 0x04 */ u8 effect; // Damage Effect (Knockback, Fire, etc.) - /* 0x05 */ u8 damage; // Damage or Stun Timer -} ColliderTouch; // size = 0x08 + /* 0x0 */ u32 dmgFlags; // Toucher damage type flags. + /* 0x4 */ u8 effect; // Damage Effect (Knockback, Fire, etc.) + /* 0x5 */ u8 damage; // Damage or Stun Timer +} ColliderTouch; // size = 0x8 typedef struct { - /* 0x00 */ u32 dmgFlags; // Toucher damage type flags. - /* 0x04 */ u8 effect; // Damage Effect (Knockback, Fire, etc.) - /* 0x05 */ u8 damage; // Damage or Stun Timer -} ColliderTouchInit; // size = 0x08 + /* 0x0 */ u32 dmgFlags; // Toucher damage type flags. + /* 0x4 */ u8 effect; // Damage Effect (Knockback, Fire, etc.) + /* 0x5 */ u8 damage; // Damage or Stun Timer +} ColliderTouchInit; // size = 0x8 typedef struct { - /* 0x00 */ u32 dmgFlags; // Bumper damage type flags. - /* 0x04 */ u8 effect; // Damage Effect (Knockback, Fire, etc.) - /* 0x05 */ u8 defense; // Damage Resistance - /* 0x06 */ Vec3s hitPos; // Point of contact -} ColliderBump; // size = 0x0C + /* 0x0 */ u32 dmgFlags; // Bumper damage type flags. + /* 0x4 */ u8 effect; // Damage Effect (Knockback, Fire, etc.) + /* 0x5 */ u8 defense; // Damage Resistance + /* 0x6 */ Vec3s hitPos; // Point of contact +} ColliderBump; // size = 0xC typedef struct { - /* 0x00 */ u32 dmgFlags; // Bumper exclusion mask - /* 0x04 */ u8 effect; // Damage Effect (Knockback, Fire, etc.) - /* 0x05 */ u8 defense; // Damage Resistance -} ColliderBumpInit; // size = 0x08 + /* 0x0 */ u32 dmgFlags; // Bumper exclusion mask + /* 0x4 */ u8 effect; // Damage Effect (Knockback, Fire, etc.) + /* 0x5 */ u8 defense; // Damage Resistance +} ColliderBumpInit; // size = 0x8 typedef struct ColliderInfo { /* 0x00 */ ColliderTouch toucher; // Damage properties when acting as an AT collider @@ -100,10 +100,10 @@ typedef struct { } ColliderJntSphElementDim; // size = 0x18 typedef struct { - /* 0x00 */ u8 limb; // attached limb - /* 0x02 */ Sphere16 modelSphere; // model space sphere - /* 0x0A */ s16 scale; // world space sphere = model * scale * 0.01 -} ColliderJntSphElementDimInit; // size = 0x0C + /* 0x0 */ u8 limb; // attached limb + /* 0x2 */ Sphere16 modelSphere; // model space sphere + /* 0xA */ s16 scale; // world space sphere = model * scale * 0.01 +} ColliderJntSphElementDimInit; // size = 0xC typedef struct { /* 0x00 */ ColliderInfo info; @@ -128,15 +128,15 @@ typedef struct { } ColliderJntSphInit; // size = 0x10 typedef struct { - /* 0x00 */ ColliderInitType1 base; - /* 0x08 */ s32 count; - /* 0x0C */ ColliderJntSphElementInit* elements; + /* 0x0 */ ColliderInitType1 base; + /* 0x8 */ s32 count; + /* 0xC */ ColliderJntSphElementInit* elements; } ColliderJntSphInitType1; // size = 0x10 typedef struct { - /* 0x00 */ ColliderInitToActor base; - /* 0x08 */ s32 count; - /* 0x0C */ ColliderJntSphElementInit* elements; + /* 0x0 */ ColliderInitToActor base; + /* 0x8 */ s32 count; + /* 0xC */ ColliderJntSphElementInit* elements; } ColliderJntSphInitToActor; // size = 0x10 typedef struct { @@ -190,9 +190,9 @@ typedef struct { } ColliderTrisInit; // size = 0x10 typedef struct { - /* 0x00 */ ColliderInitType1 base; - /* 0x08 */ s32 count; - /* 0x0C */ ColliderTrisElementInit* elements; + /* 0x0 */ ColliderInitType1 base; + /* 0x8 */ s32 count; + /* 0xC */ ColliderTrisElementInit* elements; } ColliderTrisInitType1; // size = 0x10 typedef struct { @@ -254,8 +254,8 @@ typedef struct { } CollisionCheckContext; // size = 0x29C typedef struct { - /* 0 */ u8 blood; - /* 1 */ u8 effect; + /* 0x0 */ u8 blood; + /* 0x1 */ u8 effect; } HitInfo; // size = 0x2 typedef enum { diff --git a/include/z64curve.h b/include/z64curve.h new file mode 100644 index 000000000..f4923e3bf --- /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 PlayState; + +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 PlayState* play, SkelCurve* skelCuve, s32 limbIndex, struct Actor* actor); +typedef void (*PostCurveLimbDraw)(struct PlayState* play, 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 PlayState* play, SkelCurve* skelCurve, CurveSkeletonHeader* skeletonHeaderSeg, CurveAnimationHeader* animation); +void SkelCurve_Destroy(struct PlayState* play, SkelCurve* skelCurve); +void SkelCurve_SetAnim(SkelCurve* skelCurve, CurveAnimationHeader* animation, f32 arg2, f32 endFrame, f32 curFrame, f32 playSpeed); +s32 SkelCurve_Update(struct PlayState* play, SkelCurve* skelCurve); +void SkelCurve_Draw(Actor* actor, struct PlayState* play, 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 84150a527..f4cc10802 100644 --- a/include/z64cutscene.h +++ b/include/z64cutscene.h @@ -5,11 +5,11 @@ #include "unk.h" typedef struct { - /* 0x00 */ s8 continueFlag; - /* 0x01 */ s8 cameraRoll; - /* 0x02 */ u16 nextPointFrame; - /* 0x04 */ f32 viewAngle; // in degrees - /* 0x08 */ Vec3s pos; + /* 0x0 */ s8 continueFlag; + /* 0x1 */ s8 cameraRoll; + /* 0x2 */ u16 nextPointFrame; + /* 0x4 */ f32 viewAngle; // in degrees + /* 0x8 */ Vec3s pos; } CutsceneCameraPoint; // size = 0x10 typedef struct { @@ -86,22 +86,22 @@ typedef struct { } 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 + /* -1 */ CS_TEXTBOX_TYPE_NONE = -1, + /* 0 */ CS_TEXTBOX_TYPE_DEFAULT, + /* 1 */ CS_TEXTBOX_TYPE_1, + /* 2 */ CS_TEXTBOX_TYPE_LEARN_SONG, + /* 3 */ CS_TEXTBOX_TYPE_3, + /* 4 */ CS_TEXTBOX_TYPE_BOSSES_REMAINS, + /* 5 */ CS_TEXTBOX_TYPE_ALL_NORMAL_MASKS } CutsceneTextboxType; typedef struct { /* 0x0 */ u16 type; /* 0x2 */ u16 startFrame; /* 0x4 */ u16 endFrame; - /* 0x6 */ u8 unk6; - /* 0x7 */ u8 unk7; - /* 0x8 */ u8 unk8; + /* 0x6 */ u8 intensity; + /* 0x7 */ u8 decayTimer; + /* 0x8 */ u8 decayStep; /* 0x9 */ UNK_TYPE1 pad9[0x3]; } CsCmdRumble; // size = 0xC @@ -145,13 +145,12 @@ typedef enum { /* 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, + /* 0x12D */ CS_CMD_STOPSEQ, + /* 0x12E */ CS_CMD_PLAYAMBIENCE, + /* 0x12F */ CS_CMD_FADEAMBIENCE, + /* 0x130 */ CS_CMD_130, /* 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 @@ -166,7 +165,7 @@ typedef union CutsceneData { typedef struct { /* 0x0 */ CutsceneData* segmentedData; - /* 0x4 */ s16 nextEntranceIndex; + /* 0x4 */ s16 nextEntrance; /* 0x6 */ u8 unk6; /* 0x7 */ u8 unk7; // a weekEventReg bitpack? } CutsceneEntry; // size = 0x8 @@ -178,7 +177,7 @@ typedef struct { /* 0x0C */ f32 unk_0C; /* 0x10 */ u16 frames; /* 0x12 */ u16 currentCsIndex; - /* 0x14 */ s32 csCamId; + /* 0x14 */ s32 subCamId; /* 0x18 */ u16 unk_18; /* 0x1A */ u8 unk_1A; /* 0x1B */ u8 unk_1B; diff --git a/include/z64cutscene_commands.h b/include/z64cutscene_commands.h index b487b49b1..1ab6533ac 100644 --- a/include/z64cutscene_commands.h +++ b/include/z64cutscene_commands.h @@ -548,8 +548,8 @@ * 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) } +#define CS_RUMBLE(base, startFrame, endFrame, intensity, decayTimer, decayStep) \ + { CMD_HH(base, startFrame) }, { CMD_HBB(endFrame, intensity, decayTimer) }, { CMD_BBBB(decayStep, 0, 0, 0) } /** diff --git a/include/z64dma.h b/include/z64dma.h index 570aa8432..3b17d04d0 100644 --- a/include/z64dma.h +++ b/include/z64dma.h @@ -15,10 +15,10 @@ typedef struct { } DmaRequest; // size = 0x20 typedef struct { - /* 0x00 */ u32 vromStart; - /* 0x04 */ u32 vromEnd; - /* 0x08 */ u32 romStart; - /* 0x0C */ u32 romEnd; + /* 0x0 */ u32 vromStart; + /* 0x4 */ u32 vromEnd; + /* 0x8 */ u32 romStart; + /* 0xC */ u32 romEnd; } DmaEntry; // size = 0x10 #endif diff --git a/include/z64effect.h b/include/z64effect.h index d9211ef5e..dde996eb7 100644 --- a/include/z64effect.h +++ b/include/z64effect.h @@ -8,7 +8,7 @@ #include "unk.h" struct GraphicsContext; -struct GlobalContext; +struct PlayState; #define SPARK_COUNT 3 #define BLURE_COUNT 25 @@ -19,9 +19,9 @@ struct GlobalContext; /* G Effect Regs */ -#define rgTexIdx regs[0] +#define rgTexIndex regs[0] #define rgScale regs[1] -#define rgTexIdxStep regs[2] +#define rgTexIndexStep regs[2] #define rgPrimColorR regs[3] #define rgPrimColorG regs[4] #define rgPrimColorB regs[5] @@ -30,13 +30,13 @@ struct GlobalContext; #define rgEnvColorG regs[8] #define rgEnvColorB regs[9] #define rgEnvColorA regs[10] -#define rgObjBankIdx regs[11] +#define rgObjBankIndex regs[11] typedef struct { - /* 0x00 */ u8 active; - /* 0x01 */ u8 unk1; - /* 0x02 */ u8 unk2; -} EffectStatus; // size = 0x03 + /* 0x0 */ u8 active; + /* 0x1 */ u8 unk1; + /* 0x2 */ u8 unk2; +} EffectStatus; // size = 0x3 typedef struct { /* 0x00 */ Vec3f velocity; @@ -199,7 +199,7 @@ typedef struct { } EffectTireMark; // size = 0x60C typedef struct { - /* 0x0000 */ struct GlobalContext* globalCtx; + /* 0x0000 */ struct PlayState* play; struct { EffectStatus status; EffectSpark effect; @@ -227,25 +227,25 @@ typedef struct { } EffectInfo; // size = 0x14 typedef enum { - /* 0x00 */ EFFECT_SPARK, - /* 0x01 */ EFFECT_BLURE1, - /* 0x02 */ EFFECT_BLURE2, - /* 0x03 */ EFFECT_SHIELD_PARTICLE, - /* 0x04 */ EFFECT_TIRE_MARK + /* 0 */ EFFECT_SPARK, + /* 1 */ EFFECT_BLURE1, + /* 2 */ EFFECT_BLURE2, + /* 3 */ EFFECT_SHIELD_PARTICLE, + /* 4 */ EFFECT_TIRE_MARK } EffectType; /* Effect Soft Sprites */ struct EffectSs; -typedef u32 (*EffectSsInitFunc)(struct GlobalContext* globalCtx, u32 index, struct EffectSs* effectSs, void* initParams); -typedef void(*EffectSsUpdateFunc)(struct GlobalContext* globalCtx, u32 index, struct EffectSs* particle); -typedef void(*EffectSsDrawFunc)(struct GlobalContext* globalCtx, u32 index, struct EffectSs* particle); +typedef u32 (*EffectSsInitFunc)(struct PlayState* play, u32 index, struct EffectSs* effectSs, void* initParams); +typedef void(*EffectSsUpdateFunc)(struct PlayState* play, u32 index, struct EffectSs* particle); +typedef void(*EffectSsDrawFunc)(struct PlayState* play, u32 index, struct EffectSs* particle); typedef struct { - /* 0x00 */ u32 type; - /* 0x04 */ EffectSsInitFunc init; -} EffectSsInit; // size = 0x08 + /* 0x0 */ u32 type; + /* 0x4 */ EffectSsInitFunc init; +} EffectSsInit; // size = 0x8 typedef struct { /* 0x00 */ u32 vromStart; @@ -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 a3c8a7c70..f68355858 100644 --- a/include/z64item.h +++ b/include/z64item.h @@ -7,19 +7,36 @@ // TODO fill out these enums typedef enum { - /* 0x0 */ EQUIP_SWORD, - /* 0x1 */ EQUIP_SHIELD + /* 0 */ EQUIP_TYPE_SWORD, + /* 1 */ EQUIP_TYPE_SHIELD, + /* 2 */ EQUIP_TYPE_MAX } EquipmentType; typedef enum { - /* 0x00 */ UPG_QUIVER, - /* 0x01 */ UPG_BOMB_BAG, - /* 0x02 */ UPG_STRENGTH, - /* 0x03 */ UPG_SCALE, - /* 0x04 */ UPG_WALLET, - /* 0x05 */ UPG_BULLET_BAG, - /* 0x06 */ UPG_STICKS, - /* 0x07 */ UPG_NUTS + /* 0 */ EQUIP_VALUE_SWORD_NONE, + /* 1 */ EQUIP_VALUE_SWORD_KOKIRI, + /* 2 */ EQUIP_VALUE_SWORD_RAZOR, + /* 3 */ EQUIP_VALUE_SWORD_GILDED, + /* 4 */ EQUIP_VALUE_SWORD_DIETY, + /* 5 */ EQUIP_VALUE_SWORD_MAX, +} EquipValueSword; + +typedef enum { + /* 0 */ EQUIP_VALUE_SHIELD_NONE, + /* 1 */ EQUIP_VALUE_SHIELD_HERO, + /* 2 */ EQUIP_VALUE_SHIELD_MIRROR, + /* 3 */ EQUIP_VALUE_SHIELD_MAX +} EquipValueShield; + +typedef enum { + /* 0 */ UPG_QUIVER, + /* 1 */ UPG_BOMB_BAG, + /* 2 */ UPG_STRENGTH, + /* 3 */ UPG_SCALE, + /* 4 */ UPG_WALLET, + /* 5 */ UPG_BULLET_BAG, + /* 6 */ UPG_STICKS, + /* 7 */ UPG_NUTS } UpgradeType; typedef enum { @@ -41,9 +58,11 @@ typedef enum { /* 0x0F */ QUEST_SONG_SOARING, /* 0x10 */ QUEST_SONG_STORMS, /* 0x11 */ QUEST_SONG_SUN, - /* 0x12 */ QUEST_BOMBERS_NOTEBOOK, + /* 0x12 */ QUEST_BOMBERS_NOTEBOOK, // Obtained Bombers Notebook + /* 0x13 */ QUEST_SKULL_TOKEN, /* 0x18 */ QUEST_SONG_LULLABY_INTRO = 0x18, - /* 0x19 */ QUEST_UNK_19 // Related to PictoBox + /* 0x19 */ QUEST_PICTOGRAPH, // A photo from the pictograph box is saved + /* 0x1C */ QUEST_HEART_PIECE_COUNT = 0x1C } QuestItem; typedef enum { @@ -135,7 +154,7 @@ typedef enum { /* 0x21 */ ITEM_ZORA_EGG, /* 0x22 */ ITEM_GOLD_DUST, /* 0x23 */ ITEM_MUSHROOM, - /* 0x24 */ ITEM_SEA_HORSE, + /* 0x24 */ ITEM_SEAHORSE, /* 0x25 */ ITEM_CHATEAU, /* 0x26 */ ITEM_HYLIAN_LOACH, /* 0x27 */ ITEM_OBABA_DRINK, @@ -147,7 +166,7 @@ typedef enum { /* 0x2D */ ITEM_ROOM_KEY, /* 0x2E */ ITEM_LETTER_MAMA, /* 0x2F */ ITEM_LETTER_TO_KAFEI, - /* 0x30 */ ITEM_PENDANT_MEMORIES, + /* 0x30 */ ITEM_PENDANT_OF_MEMORIES, /* 0x31 */ ITEM_TINGLE_MAP, /* 0x32 */ ITEM_MASK_DEKU, /* 0x33 */ ITEM_MASK_GORON, @@ -191,7 +210,7 @@ typedef enum { /* 0x59 */ ITEM_WALLET_DEFAULT, /* 0x5A */ ITEM_WALLET_ADULT, /* 0x5B */ ITEM_WALLET_GIANT, - /* 0x5C */ ITEM_FISHING_POLE, + /* 0x5C */ ITEM_FISHING_ROD, /* 0x5D */ ITEM_REMAINS_ODOLWA, /* 0x5E */ ITEM_REMAINS_GOHT, /* 0x5F */ ITEM_REMAINS_GYORG, @@ -228,7 +247,7 @@ typedef enum { /* 0x80 */ ITEM_INVALID_5, /* 0x81 */ ITEM_INVALID_6, /* 0x82 */ ITEM_INVALID_7, - /* 0x83 */ ITEM_HEART, + /* 0x83 */ ITEM_RECOVERY_HEART, /* 0x84 */ ITEM_RUPEE_GREEN, /* 0x85 */ ITEM_RUPEE_BLUE, /* 0x86 */ ITEM_RUPEE_10, @@ -260,11 +279,17 @@ typedef enum { /* 0xA0 */ ITEM_MILK, /* 0xA1 */ ITEM_GOLD_DUST_2, /* 0xA2 */ ITEM_HYLIAN_LOACH_2, - /* 0xA3 */ ITEM_SEA_HORSE_CAUGHT, - /* 0xFD */ ITEM_UNK_FD = 0xFD, + /* 0xA3 */ ITEM_SEAHORSE_CAUGHT, + /* 0xF0 */ ITEM_F0 = 0xF0, + /* 0xF1 */ ITEM_F1, + /* 0xF2 */ ITEM_F2, + /* 0xFD */ ITEM_FD = 0xFD, /* 0xFF */ ITEM_NONE = 0xFF } ItemID; +#define BOTTLE_FIRST 0 +#define BOTTLE_MAX 6 + typedef enum { /* 0x00 */ GI_NONE, /* 0x01 */ GI_RUPEE_GREEN, @@ -279,8 +304,15 @@ typedef enum { /* 0x0A */ GI_RECOVERY_HEART, /* 0x0C */ GI_HEART_PIECE = 0x0C, /* 0x0D */ GI_HEART_CONTAINER, - /* 0x16 */ GI_BOMBS_10 = 0x16, - /* 0x19 */ GI_STICKS_1 = 0x19, + /* 0x0E */ GI_MAGIC_SMALL, + /* 0x0F */ GI_MAGIC_LARGE, + /* 0x11 */ GI_STRAY_FAIRY = 0x11, + /* 0x14 */ GI_BOMBS_1 = 0x14, + /* 0x15 */ GI_BOMBS_5, + /* 0x16 */ GI_BOMBS_10, + /* 0x17 */ GI_BOMBS_20, + /* 0x18 */ GI_BOMBS_30, + /* 0x19 */ GI_STICKS_1, /* 0x1A */ GI_BOMBCHUS_10, /* 0x1B */ GI_BOMB_BAG_20, /* 0x1C */ GI_BOMB_BAG_30, @@ -292,28 +324,65 @@ typedef enum { /* 0x22 */ GI_QUIVER_30, /* 0x23 */ GI_QUIVER_40, /* 0x24 */ GI_QUIVER_50, - /* 0x28 */ GI_NUTS_1 = 0x28, - /* 0x2A */ GI_NUTS_10 = 0x2A, + /* 0x25 */ GI_ARROW_FIRE, + /* 0x26 */ GI_ARROW_ICE, + /* 0x27 */ GI_ARROW_LIGHT, + /* 0x28 */ GI_NUTS_1, + /* 0x29 */ GI_NUTS_5, + /* 0x2A */ GI_NUTS_10, + /* 0x2E */ GI_BOMBCHUS_20 = 0x2E, /* 0x32 */ GI_SHIELD_HERO = 0x32, /* 0x33 */ GI_SHIELD_MIRROR, - /* 0x35 */ GI_MAGIC_BEANS = 0x35, - /* 0x3C */ GI_KEY_SMALL = 0x3C, - /* 0x3E */ GI_MAP = 0x3E, + /* 0x34 */ GI_POWDER_KEG, + /* 0x35 */ GI_MAGIC_BEANS, + /* 0x36 */ GI_BOMBCHUS_1, + /* 0x37 */ GI_SWORD_KOKIRI, + /* 0x38 */ GI_SWORD_RAZOR, + /* 0x39 */ GI_SWORD_GILDED, + /* 0x3A */ GI_BOMBCHUS_5, + /* 0x3B */ GI_SWORD_GREAT_FAIRY, + /* 0x3C */ GI_KEY_SMALL, + /* 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, + /* 0x41 */ GI_HOOKSHOT = 0x41, + /* 0x42 */ GI_LENS, + /* 0x43 */ GI_PICTO_BOX, + /* 0x4C */ GI_OCARINA = 0x4C, + /* 0x50 */ GI_BOMBERS_NOTEBOOK = 0x50, + /* 0x52 */ GI_SKULL_TOKEN = 0x52, + /* 0x55 */ GI_REMAINS_ODOLWA = 0x55, + /* 0x56 */ GI_REMAINS_GOHT, + /* 0x57 */ GI_REMAINS_GYORG, + /* 0x58 */ GI_REMAINS_TWINMOLD, + /* 0x59 */ GI_POTION_RED_BOTTLE, // ITEM_LONGSHOT + /* 0x5A */ GI_BOTTLE, + /* 0x5B */ GI_POTION_RED, /* 0x5C */ GI_POTION_GREEN, /* 0x5D */ GI_POTION_BLUE, /* 0x5E */ GI_FAIRY, - /* 0x60 */ GI_MILK_BOTTLE = 0x60, + /* 0x5F */ GI_DEKU_PRINCESS, + /* 0x60 */ GI_MILK_BOTTLE, + /* 0x61 */ GI_MILK_HALF, + /* 0x62 */ GI_FISH, + /* 0x63 */ GI_BUG, + /* 0x64 */ GI_BLUE_FIRE, + /* 0x65 */ GI_POE, + /* 0x66 */ GI_BIG_POE, + /* 0x67 */ GI_SPRING_WATER, + /* 0x68 */ GI_HOT_SPRING_WATER, + /* 0x69 */ GI_ZORA_EGG, + /* 0x6A */ GI_GOLD_DUST, + /* 0x6B */ GI_MUSHROOM, + /* 0x6E */ GI_SEAHORSE = 0x6E, + /* 0x6F */ GI_CHATEAU_BOTTLE, + /* 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, @@ -326,77 +395,161 @@ 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, - /* 0x95 */ GI_95 = 0x95, + /* 0x8F */ GI_MASK_KAFEIS_MASK, + /* 0x91 */ GI_CHATEAU = 0x91, + /* 0x92 */ GI_MILK, + /* 0x93 */ GI_GOLD_DUST_2, + /* 0x94 */ GI_HYLIAN_LOACH, // Unused bottled eel + /* 0x95 */ GI_SEAHORSE_CAUGHT, /* 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, - /* 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, - /* 0xBA */ GI_MAX = 0xBA + /* 0x9B */ GI_SWORD_GREAT_FAIRY_STOLEN, + /* 0x9C */ GI_SWORD_KOKIRI_STOLEN, + /* 0x9D */ GI_SWORD_RAZOR_STOLEN, + /* 0x9E */ GI_SWORD_GILDED_STOLEN, + /* 0x9F */ GI_SHIELD_HERO_STOLEN, // Code that treats this as hero's shield is unused, implied as intended to be stolen + /* 0xA0 */ GI_ROOM_KEY, + /* 0xA1 */ GI_LETTER_TO_MAMA, + /* 0xA9 */ GI_BOTTLE_STOLEN = 0xA9, // buy back stolen bottle + /* 0xAA */ GI_LETTER_TO_KAFEI, + /* 0xAB */ GI_PENDANT_OF_MEMORIES, + /* 0xB4 */ GI_TINGLE_MAP_CLOCK_TOWN = 0xB4, + /* 0xB5 */ GI_TINGLE_MAP_WOODFALL, + /* 0xB6 */ GI_TINGLE_MAP_SNOWHEAD, + /* 0xB7 */ GI_TINGLE_MAP_ROMANI_RANCH, + /* 0xB8 */ GI_TINGLE_MAP_GREAT_BAY, + /* 0xB9 */ GI_TINGLE_MAP_STONE_TOWER, + /* 0xBA */ GI_MAX } 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, + /* 0x01 */ GID_KEY_SMALL, + /* 0x02 */ GID_MASK_KAMARO, + /* 0x03 */ GID_MASK_COUPLE, + /* 0x04 */ GID_04, + /* 0x05 */ GID_05, + /* 0x06 */ GID_06, + /* 0x07 */ GID_07, + /* 0x08 */ GID_RECOVERY_HEART, + /* 0x09 */ GID_KEY_BOSS, + /* 0x0A */ GID_COMPASS, + /* 0x0B */ GID_BOMBERS_NOTEBOOK, + /* 0x0C */ GID_MASK_STONE, + /* 0x0D */ GID_MASK_KAFEIS_MASK, + /* 0x0E */ GID_MASK_CIRCUS_LEADER, + /* 0x0F */ GID_MASK_BREMEN, + /* 0x10 */ GID_MASK_ALL_NIGHT, /* 0x11 */ GID_NUTS, - /* 0x17 */ GID_BOMB_BAG_20 = 0x17, + /* 0x12 */ GID_HEART_CONTAINER, + /* 0x13 */ GID_HEART_PIECE, + /* 0x14 */ GID_QUIVER_30, + /* 0x15 */ GID_QUIVER_40, + /* 0x16 */ GID_QUIVER_50, + /* 0x17 */ GID_BOMB_BAG_20, /* 0x18 */ GID_BOMB_BAG_30, /* 0x19 */ GID_BOMB_BAG_40, - /* 0x1A */ GID_STICK = 0x1A, + /* 0x1A */ GID_STICK, /* 0x1B */ GID_DUNGEON_MAP, - /* 0x1E */ GID_BOMB = 0x1E, - /* 0x23 */ GID_ARROWS_SMALL = 0x23, + /* 0x1C */ GID_MAGIC_SMALL, + /* 0x1D */ GID_MAGIC_LARGE, + /* 0x1E */ GID_BOMB, + /* 0x1F */ GID_STONE_OF_AGONY, + /* 0x20 */ GID_WALLET_ADULT, + /* 0x21 */ GID_WALLET_GIANT, + /* 0x22 */ GID_MASK_DON_GERO, + /* 0x23 */ GID_ARROWS_SMALL, /* 0x24 */ GID_ARROWS_MEDIUM, /* 0x25 */ GID_ARROWS_LARGE, /* 0x26 */ GID_BOMBCHU, /* 0x27 */ GID_SHIELD_HERO, - /* 0x30 */ GID_POTION_GREEN = 0x30, + /* 0x28 */ GID_HOOKSHOT, + /* 0x29 */ GID_29, + /* 0x2A */ GID_OCARINA, + /* 0x2B */ GID_MILK, + /* 0x2C */ GID_MASK_KEATON, + /* 0x2D */ GID_TINGLE_MAP, + /* 0x2E */ GID_BOW, + /* 0x2F */ GID_LENS, + /* 0x30 */ GID_POTION_GREEN, /* 0x31 */ GID_POTION_RED, /* 0x32 */ GID_POTION_BLUE, /* 0x33 */ GID_SHIELD_MIRROR, - /* 0x3A */ GID_3A = 0x3A, + /* 0x34 */ GID_MAGIC_BEANS, + /* 0x35 */ GID_FISH, + /* 0x36 */ GID_LETTER_MAMA, + /* 0x37 */ GID_37, + /* 0x38 */ GID_SWORD_BGS, + /* 0x39 */ GID_MASK_SUN, + /* 0x3A */ GID_MASK_BLAST, /* 0x3B */ GID_FAIRY, - /* 0x3E */ GID_3E = 0x3E, - /* 0x44 */ GID_44 = 0x44, - /* 0x45 */ GID_45, - /* 0x55 */ GID_SWORD_KOKIRI = 0x55, - /* 0x66 */ GID_SWORD_RAZOR = 0x66, + /* 0x3C */ GID_MASK_SCENTS, + /* 0x3D */ GID_MASK_CAPTAIN, + /* 0x3E */ GID_MASK_BUNNY, + /* 0x3F */ GID_MASK_TRUTH, + /* 0x40 */ GID_DEED_SWAMP, + /* 0x41 */ GID_DEED_MOUNTAIN, + /* 0x42 */ GID_RUPEE_HUGE, + /* 0x43 */ GID_DEED_OCEAN, + /* 0x44 */ GID_MASK_GORON, + /* 0x45 */ GID_MASK_ZORA, + /* 0x46 */ GID_46, + /* 0x47 */ GID_ARROW_FIRE, + /* 0x48 */ GID_ARROW_ICE, + /* 0x49 */ GID_ARROW_LIGHT, + /* 0x4A */ GID_SKULL_TOKEN, + /* 0x4B */ GID_BUG, + /* 0x4C */ GID_4C, + /* 0x4D */ GID_POE, + /* 0x4E */ GID_FAIRY_2, + /* 0x4F */ GID_RUPEE_GREEN, + /* 0x50 */ GID_RUPEE_BLUE, + /* 0x51 */ GID_RUPEE_RED, + /* 0x52 */ GID_BIG_POE, + /* 0x53 */ GID_RUPEE_PURPLE, + /* 0x54 */ GID_RUPEE_SILVER, + /* 0x55 */ GID_SWORD_KOKIRI, + /* 0x56 */ GID_SKULL_TOKEN_2, + /* 0x57 */ GID_57, + /* 0x58 */ GID_ZORA_EGG, + /* 0x59 */ GID_MOON_TEAR, + /* 0x5A */ GID_DEED_LAND, + /* 0x5B */ GID_MASK_DEKU, + /* 0x5C */ GID_REMAINS_ODOLWA, + /* 0x5D */ GID_POWDER_KEG, + /* 0x5E */ GID_GOLD_DUST, + /* 0x5F */ GID_SEAHORSE, + /* 0x60 */ GID_60, + /* 0x61 */ GID_HYLIAN_LOACH, + /* 0x62 */ GID_SEAHORSE_CAUGHT, + /* 0x63 */ GID_REMAINS_GOHT, + /* 0x64 */ GID_REMAINS_GYORG, + /* 0x65 */ GID_REMAINS_TWINMOLD, + /* 0x66 */ GID_SWORD_RAZOR, /* 0x67 */ GID_SWORD_GILDED, /* 0x68 */ GID_SWORD_GREAT_FAIRY, - /* 0x6A */ GID_6A = 0x6A, - /* 0x6B */ GID_6B, - /* 0x70 */ GID_70 = 0x70, - /* 0x71 */ GID_71 + /* 0x69 */ GID_MASK_GARO, + /* 0x6A */ GID_MASK_GREAT_FAIRY, + /* 0x6B */ GID_MASK_GIBDO, + /* 0x6C */ GID_ROOM_KEY, + /* 0x6D */ GID_LETTER_TO_KAFEI, + /* 0x6E */ GID_PENDANT_OF_MEMORIES, + /* 0x6F */ GID_MUSHROOM, + /* 0x70 */ GID_MASK_ROMANI, + /* 0x71 */ GID_MASK_POSTMAN, + /* 0x72 */ GID_MASK_GIANT, + /* 0x73 */ GID_CHATEAU, + /* 0x74 */ GID_PICTO_BOX, + /* 0x75 */ GID_MASK_FIERCE_DEITY, + /* 0x76 */ GID_MAX } 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 -} ExchangeItemID; - #endif diff --git a/include/z64light.h b/include/z64light.h index 0c90be713..df7c1b4fa 100644 --- a/include/z64light.h +++ b/include/z64light.h @@ -82,12 +82,12 @@ typedef struct LightContext { } LightContext; // size = 0x10 typedef enum LightType { - /* 0x00 */ LIGHT_POINT_NOGLOW, - /* 0x01 */ LIGHT_DIRECTIONAL, - /* 0x02 */ LIGHT_POINT_GLOW + /* 0 */ LIGHT_POINT_NOGLOW, + /* 1 */ LIGHT_DIRECTIONAL, + /* 2 */ LIGHT_POINT_GLOW } LightType; typedef void (*LightsBindFunc)(Lights* lights, LightParams* params, Vec3f* vec); -typedef void (*LightsPosBindFunc)(Lights* lights, LightParams* params, struct GlobalContext* globalCtx); +typedef void (*LightsPosBindFunc)(Lights* lights, LightParams* params, struct PlayState* play); #endif 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/z64map.h b/include/z64map.h new file mode 100644 index 000000000..195344114 --- /dev/null +++ b/include/z64map.h @@ -0,0 +1,6 @@ +#ifndef Z64MAP_H +#define Z64MAP_H + +#define FLOOR_INDEX_MAX 4 + +#endif diff --git a/include/z64math.h b/include/z64math.h index de0285e6c..16ab72e8a 100644 --- a/include/z64math.h +++ b/include/z64math.h @@ -1,54 +1,58 @@ -#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 + /* 0x0 */ s16 x; + /* 0x2 */ s16 z; +} Vec2s; // size = 0x4 typedef struct { - /* 0x00 */ f32 x; - /* 0x04 */ f32 z; -} Vec2f; // size = 0x08 + /* 0x0 */ f32 x; + /* 0x4 */ f32 z; +} Vec2f; // size = 0x8 typedef struct { - /* 0x00 */ f32 x; - /* 0x04 */ f32 y; - /* 0x08 */ f32 z; -} Vec3f; // size = 0x0C + /* 0x0 */ f32 x; + /* 0x4 */ f32 y; + /* 0x8 */ f32 z; +} Vec3f; // size = 0xC typedef struct { - /* 0x00 */ u16 x; - /* 0x02 */ u16 y; - /* 0x04 */ u16 z; -} Vec3us; // size = 0x06 + /* 0x0 */ u16 x; + /* 0x2 */ u16 y; + /* 0x4 */ u16 z; +} Vec3us; // size = 0x6 typedef struct { - /* 0x00 */ s16 x; - /* 0x02 */ s16 y; - /* 0x04 */ s16 z; -} Vec3s; // size = 0x06 + /* 0x0 */ s16 x; + /* 0x2 */ s16 y; + /* 0x4 */ s16 z; +} Vec3s; // size = 0x6 typedef struct { - /* 0x00 */ s32 x; - /* 0x04 */ s32 y; - /* 0x08 */ s32 z; -} Vec3i; // size = 0x0C + /* 0x0 */ s32 x; + /* 0x4 */ s32 y; + /* 0x8 */ s32 z; +} Vec3i; // size = 0xC typedef struct { - /* 0x00 */ Vec3s center; - /* 0x06 */ s16 radius; -} Sphere16; // size = 0x08 + /* 0x0 */ Vec3s center; + /* 0x6 */ s16 radius; +} Sphere16; // size = 0x8 typedef struct { - /* 0x00 */ Vec3f center; - /* 0x0C */ f32 radius; + /* 0x0 */ Vec3f center; + /* 0xC */ 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; @@ -60,11 +64,11 @@ typedef struct { } TriNorm; // size = 0x34 typedef struct { - /* 0x00 */ s16 radius; - /* 0x02 */ s16 height; - /* 0x04 */ s16 yShift; - /* 0x06 */ Vec3s pos; -} Cylinder16; // size = 0x0C + /* 0x0 */ s16 radius; + /* 0x2 */ s16 height; + /* 0x4 */ s16 yShift; + /* 0x6 */ Vec3s pos; +} Cylinder16; // size = 0xC typedef struct { /* 0x00 */ f32 radius; @@ -85,10 +89,10 @@ typedef struct { // Defines a point in the spherical coordinate system typedef struct { - /* 0x00 */ f32 r; // radius - /* 0x04 */ s16 pitch; // polar (zenith) angle - /* 0x06 */ s16 yaw; // azimuthal angle -} VecSph; // size = 0x08 + /* 0x0 */ f32 r; // radius + /* 0x4 */ s16 pitch; // polar (zenith) angle + /* 0x6 */ s16 yaw; // azimuthal angle +} VecSph; // size = 0x8 #define LERPIMP(v0, v1, t) ((v0) + (((v1) - (v0)) * (t))) #define F32_LERP(v0, v1, t) ((1.0f - (t)) * (f32)(v0) + (t) * (f32)(v1)) @@ -105,17 +109,17 @@ 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 RADF_TO_BINANG(radf) (s16)((radf) * (0x8000 / M_PI)) +#define RADF_TO_DEGF(radf) ((radf) * (180.0f / M_PI)) +#define DEGF_TO_RADF(degf) ((degf) * (M_PI / 180.0f)) +#define BINANG_TO_RAD(binang) (((f32)binang / 0x8000) * M_PI) + +// 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/z64message.h b/include/z64message.h new file mode 100644 index 000000000..590074339 --- /dev/null +++ b/include/z64message.h @@ -0,0 +1,179 @@ +#ifndef Z64MESSAGE_H +#define Z64MESSAGE_H + +#include "PR/ultratypes.h" +#include "z64view.h" +#include "unk.h" + +struct Actor; +struct MessageTableEntry; +struct OcarinaStaff; + +typedef enum TextState { + /* 0 */ TEXT_STATE_NONE, + /* 1 */ TEXT_STATE_1, + /* 2 */ TEXT_STATE_CLOSING, + /* 3 */ TEXT_STATE_3, + /* 4 */ TEXT_STATE_CHOICE, + /* 5 */ TEXT_STATE_5, + /* 6 */ TEXT_STATE_DONE, + /* 7 */ TEXT_STATE_7, + /* 8 */ TEXT_STATE_8, + /* 9 */ TEXT_STATE_9, + /* 10 */ TEXT_STATE_10, + /* 11 */ TEXT_STATE_11, + /* 12 */ TEXT_STATE_12, + /* 13 */ TEXT_STATE_13, + /* 14 */ TEXT_STATE_14, + /* 15 */ TEXT_STATE_15, + /* 16 */ TEXT_STATE_16, + /* 17 */ TEXT_STATE_17, + /* 18 */ TEXT_STATE_18 +} TextState; + + +#define FONT_CHAR_TEX_WIDTH 16 +#define FONT_CHAR_TEX_HEIGHT 16 +//! @TODO: Make this use `sizeof(AnyFontTextureSymbol)` +#define FONT_CHAR_TEX_SIZE ((16 * 16) / 2) // 16x16 I4 texture + +// TODO: should Font be in its own header or is it fine to have it here? +// Font textures are loaded into here +typedef struct { + /* 0x00000 */ union { + u8 charBuf[2][FONT_CHAR_TEX_SIZE * 120]; + u64 force_structure_alignment_charTex; + }; + /* 0x07800 */ union { + u8 iconBuf[FONT_CHAR_TEX_SIZE]; + u64 force_structure_alignment_icon; + }; + /* 0x07880 */ union { + u8 fontBuf[FONT_CHAR_TEX_SIZE * 320]; + u64 force_structure_alignment_font; + }; + /* 0x11880 */ union { + char schar[1280]; // msgBuf + u16 wchar[640]; // msgBufWide + u64 force_structure_alignment_msg; + } msgBuf; + /* 0x11D80 */ u8* messageStart; + /* 0x11D84 */ u8* messageEnd; + /* 0x11D88 */ u8 unk_11D88; // current Char Buffer ? +} Font; // size = 0x11D90 + +typedef struct MessageContext { + /* 0x00000 */ View view; + /* 0x00168 */ Font font; + /* 0x11EF8 */ UNK_PTR unk11EF8; + /* 0x11EFC */ UNK_TYPE1 unk11EFC[0x4]; + /* 0x11F00 */ struct OcarinaStaff* unk11F00; + /* 0x11F04 */ u16 currentTextId; + /* 0x11F06 */ UNK_TYPE1 unk11F06[0x2]; + /* 0x11F08 */ u16 unk11F08; + /* 0x11F0A */ u8 unk11F0A; + /* 0x11F0B */ s8 unk11F0B; + /* 0x11F0C */ s8 unk11F0C; + /* 0x11F0B */ UNK_TYPE1 unk11F0D[0x3]; + /* 0x11F10 */ s32 msgLength; + /* 0x11F14 */ u16 unk11F14; + /* 0x11F16 */ u16 unk11F16; + /* 0x11F18 */ s8 unk11F18; + /* 0x11F19 */ UNK_TYPE1 unk11F19[0x1]; + /* 0x11F1A */ s16 unk11F1A[3]; + /* 0x11F20 */ UNK_TYPE1 unk11F20[0x2]; + /* 0x11F22 */ u8 msgMode; // TODO: MessageMode enum + /* 0x11F23 */ UNK_TYPE1 unk11F23; + /* 0x11F24 */ union { + char schar[200]; + u16 wchar[100]; + } decodedBuffer; + /* 0x11FEC */ u16 msgBufPos; + /* 0x11FEE */ s16 unk11FEE; + /* 0x11FF0 */ s16 unk11FF0; + /* 0x11FF2 */ u16 unk11FF2; + /* 0x11FF4 */ s16 unk11FF4; + /* 0x11FF6 */ s16 unk11FF6; + /* 0x11FF8 */ s16 unk11FF8; + /* 0x11FFA */ s16 unk11FFA; + /* 0x11FFC */ s16 unk11FFC; + /* 0x11FFE */ s16 unk11FFE[0x3]; + /* 0x12004 */ s16 unk12004; + /* 0x12006 */ s16 unk12006; + /* 0x12008 */ s16 unk12008; + /* 0x1200A */ UNK_TYPE2 unk1200A; + /* 0x1200C */ s16 unk1200C; + /* 0x1200E */ s16 unk1200E; + /* 0x12010 */ s16 unk12010; + /* 0x12012 */ s16 unk12012; + /* 0x12014 */ s16 unk12014; + /* 0x12014 */ s16 unk12016; + /* 0x12018 */ s16 unk12018; // messageR + /* 0x1201A */ s16 unk1201A; // messageG + /* 0x1201C */ s16 unk1201C; // messageB + /* 0x1201E */ s16 unk1201E; // messageA + /* 0x12020 */ u8 unk12020; // probably textboxEndType + /* 0x12021 */ u8 choiceIndex; + /* 0x12022 */ u8 unk12022; + /* 0x12023 */ u8 stateTimer; + /* 0x12024 */ s16 unk12024; + /* 0x12026 */ u16 unk12026; + /* 0x12028 */ u16 songPlayed; + /* 0x1202A */ u16 ocarinaMode; + /* 0x1202C */ u16 ocarinaAction; + /* 0x1202E */ u16 lastPlayedSong; + /* 0x12030 */ s16 unk_12030; + /* 0x12032 */ UNK_TYPE1 unk_12032[0x2]; + /* 0x12034 */ s16 unk12034; + /* 0x12036 */ s16 unk12036; + /* 0x12038 */ s16 unk12038; + /* 0x1203A */ s16 unk1203A; + /* 0x1203C */ s16 unk1203C; + /* 0x1203E */ s16 unk1203E; + /* 0x12040 */ struct Actor* unkActor; + /* 0x12044 */ s16 unk12044; + /* 0x12046 */ s16 unk12046; + /* 0x12048 */ u8 unk12048; // EnKakasi + /* 0x12049 */ UNK_TYPE1 unk12049[0x1]; + /* 0x1204A */ s16 unk1204A[0x5]; + /* 0x12054 */ s16 unk12054[6]; // First, second and third digits in lottery code guess + /* 0x1205A */ UNK_TYPE1 unk12060[0x8]; + /* 0x12068 */ s16 unk12068; + /* 0x1206A */ s16 unk1206A; + /* 0x1206C */ s32 unk1206C; + /* 0x12070 */ s32 unk12070; + /* 0x12074 */ s32 unk12074; + /* 0x12078 */ s32 bankRupeesSelected; + /* 0x1207C */ s32 bankRupees; + /* 0x12080 */ struct MessageTableEntry* messageEntryTable; + /* 0x12084 */ struct MessageTableEntry* messageEntryTableNes; + /* 0x12088 */ UNK_TYPE4 unk12088; + /* 0x1208C */ struct MessageTableEntry* messageTableStaff; + /* 0x12090 */ s16 unk12090; + /* 0x12092 */ s16 unk12092; + /* 0x12094 */ s8 unk12094; + /* 0x12095 */ UNK_TYPE1 unk12095[0x3]; + /* 0x12098 */ f32 unk12098; // Text_Scale? + /* 0x1209C */ s16 unk1209C; + /* 0x1209E */ UNK_TYPE1 unk1209E[0x2]; + /* 0x120A0 */ s32 unk120A0; + /* 0x120A4 */ s16 unk120A4[6]; + /* 0x120B0 */ u8 unk120B0; + /* 0x120B1 */ u8 unk120B1; + /* 0x120B2 */ u8 unk120B2[0xC]; + /* 0x120BE */ s16 unk120BE; + /* 0x120C0 */ s16 unk120C0; + /* 0x120C2 */ s16 unk120C2; + /* 0x120C4 */ s32 unk120C4; + /* 0x120C8 */ s16 unk120C8; + /* 0x120CA */ s16 unk120CA; + /* 0x120CC */ s16 unk120CC; + /* 0x120CE */ s16 unk120CE; + /* 0x120D0 */ s16 unk120D0; + /* 0x120D2 */ s16 unk120D2; + /* 0x120D4 */ s16 unk120D4; + /* 0x120D6 */ s16 unk120D6; + /* 0x120D8 */ UNK_TYPE1 unk120D8[0x8]; +} MessageContext; // size = 0x120E0 + +#endif diff --git a/include/z64object.h b/include/z64object.h index 34035306b..3b221088a 100644 --- a/include/z64object.h +++ b/include/z64object.h @@ -207,7 +207,7 @@ typedef enum { /* 0x0C3 */ OBJECT_GI_SHIELD_3, /* 0x0C4 */ OBJECT_UNSET_C4, /* 0x0C5 */ OBJECT_UNSET_C5, - /* 0x0C6 */ OBJECT_GI_MAGIC_BEANS, + /* 0x0C6 */ OBJECT_GI_BEAN, /* 0x0C7 */ OBJECT_GI_FISH, /* 0x0C8 */ OBJECT_UNSET_C8, /* 0x0C9 */ OBJECT_UNSET_C9, diff --git a/include/z64ocarina.h b/include/z64ocarina.h index 56ab48312..597580388 100644 --- a/include/z64ocarina.h +++ b/include/z64ocarina.h @@ -26,10 +26,10 @@ typedef enum { /* 19 */ OCARINA_SONG_EVAN_PART1, /* 20 */ OCARINA_SONG_EVAN_PART2, /* 21 */ OCARINA_SONG_ZELDAS_LULLABY, - /* 22 */ OCARINA_SONG_SCARECROW, + /* 22 */ OCARINA_SONG_SCARECROW_SPAWN, /* 23 */ OCARINA_SONG_TERMINA_WALL, /* 24 */ OCARINA_SONG_MAX, - /* 24 */ OCARINA_SONG_SCARECROW_LONG = OCARINA_SONG_MAX + /* 24 */ OCARINA_SONG_SCARECROW_LONG = OCARINA_SONG_MAX // anything larger than 24 is considered the long scarecrow's song } OcarinaSongId; typedef enum { @@ -38,6 +38,7 @@ typedef enum { /* 2 */ OCARINA_BTN_C_RIGHT, /* 3 */ OCARINA_BTN_C_LEFT, /* 4 */ OCARINA_BTN_C_UP, + /* 5 */ OCARINA_BTN_C_RIGHT_OR_C_LEFT, /* -1 */ OCARINA_BTN_INVALID = 0xFF } OcarinaButtonIndex; @@ -92,15 +93,19 @@ typedef enum { } OcarinaRecordingState; /** - * BFlat4Flag Note: + * 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) + * that map to two semitones apart (OCARINA_PITCH_A4 and OCARINA_PITCH_B4) * 0x40 - BTN_Z is pressed to lower note by a semitone * 0x80 - BTN_R is pressed to raise note by a semitone */ +#define OCARINA_BUTTON_MASK_PITCH 0x3F +#define OCARINA_BUTTON_MASK_FLAG 0xC0 +#define OCARINA_BUTTON_FLAG_BFLAT_LOWER 0x40 +#define OCARINA_BUTTON_FLAG_BFLAT_RAISE 0x80 typedef struct { /* 0x0 */ u8 pitch; // number of semitones above middle C @@ -108,7 +113,7 @@ typedef struct { /* 0x4 */ u8 volume; /* 0x5 */ u8 vibrato; /* 0x6 */ s8 bend; // frequency multiplicative offset from the pitch defined by pitch - /* 0x7 */ u8 BFlat4Flag; // See note above + /* 0x7 */ u8 bFlat4Flag; // See note above } OcarinaNote; // size = 0x8 typedef struct { @@ -116,7 +121,7 @@ typedef struct { /* 0x1 */ u8 buttonIndex[8]; } OcarinaSongButtons; // size = 0x9 -typedef struct { +typedef struct OcarinaStaff { /* 0x0 */ u8 buttonIndex; /* 0x1 */ u8 state; // original name: "status" /* 0x2 */ u8 pos; // original name: "locate" diff --git a/include/z64player.h b/include/z64player.h index 4066e2baf..f49f30688 100644 --- a/include/z64player.h +++ b/include/z64player.h @@ -7,30 +7,38 @@ struct Player; typedef enum { - /* 0x00 */ PLAYER_SHIELD_NONE, - /* 0x01 */ PLAYER_SHIELD_HEROS_SHIELD, - /* 0x02 */ PLAYER_SHIELD_MIRROR_SHIELD, - /* 0x03 */ PLAYER_SHIELD_MAX + /* 0 */ PLAYER_SHIELD_NONE, + /* 1 */ PLAYER_SHIELD_HEROS_SHIELD, + /* 2 */ PLAYER_SHIELD_MIRROR_SHIELD, + /* 3 */ PLAYER_SHIELD_MAX } PlayerShield; typedef enum { - /* 0x00 */ PLAYER_BOOTS_FIERCE_DEITY, - /* 0x01 */ PLAYER_BOOTS_HYLIAN, - /* 0x02 */ PLAYER_BOOTS_GIANT, - /* 0x03 */ PLAYER_BOOTS_DEKU, - /* 0x04 */ PLAYER_BOOTS_ZORA_LAND, - /* 0x05 */ PLAYER_BOOTS_ZORA_UNDERWATER, - /* 0x06 */ PLAYER_BOOTS_GORON, - /* 0x07 */ PLAYER_BOOTS_MAX + /* 0 */ PLAYER_BOOTS_FIERCE_DEITY, + /* 1 */ PLAYER_BOOTS_HYLIAN, + /* 2 */ PLAYER_BOOTS_GIANT, + /* 3 */ PLAYER_BOOTS_DEKU, + /* 4 */ PLAYER_BOOTS_ZORA_LAND, + /* 5 */ PLAYER_BOOTS_ZORA_UNDERWATER, + /* 6 */ PLAYER_BOOTS_GORON, + /* 7 */ PLAYER_BOOTS_MAX } PlayerBoots; typedef enum { - /* 0x00 */ PLAYER_FORM_FIERCE_DEITY, - /* 0x01 */ PLAYER_FORM_GORON, - /* 0x02 */ PLAYER_FORM_ZORA, - /* 0x03 */ PLAYER_FORM_DEKU, - /* 0x04 */ PLAYER_FORM_HUMAN, - /* 0x05 */ PLAYER_FORM_MAX + /* 0 */ PLAYER_STRENGTH_DEKU, + /* 1 */ PLAYER_STRENGTH_HUMAN, + /* 2 */ PLAYER_STRENGTH_ZORA, + /* 3 */ PLAYER_STRENGTH_GORON, + /* 4 */ PLAYER_STRENGTH_MAX +} PlayerStrength; + +typedef enum { + /* 0 */ PLAYER_FORM_FIERCE_DEITY, + /* 1 */ PLAYER_FORM_GORON, + /* 2 */ PLAYER_FORM_ZORA, + /* 3 */ PLAYER_FORM_DEKU, + /* 4 */ PLAYER_FORM_HUMAN, + /* 5 */ PLAYER_FORM_MAX } PlayerTransformation; typedef enum { @@ -62,16 +70,17 @@ typedef enum { /* 0x19 */ PLAYER_MASK_MAX } PlayerMask; -typedef enum { +typedef enum PlayerActionParam { + /* -1 */ PLAYER_AP_MINUS1 = -1, /* 0x00 */ PLAYER_AP_NONE, - /* 0x01 */ PLAYER_AP_UNK_1, - /* 0x02 */ PLAYER_AP_UNK_2, + /* 0x01 */ PLAYER_AP_LAST_USED, + /* 0x02 */ PLAYER_AP_FISHING_ROD, /* 0x03 */ PLAYER_AP_SWORD_KOKIRI, /* 0x04 */ PLAYER_AP_SWORD_RAZOR, /* 0x05 */ PLAYER_AP_SWORD_GILDED, /* 0x06 */ PLAYER_AP_SWORD_GREAT_FAIRY, /* 0x07 */ PLAYER_AP_STICK, - /* 0x08 */ PLAYER_AP_UNK_8, + /* 0x08 */ PLAYER_AP_ZORA_FINS, /* 0x09 */ PLAYER_AP_BOW, /* 0x0A */ PLAYER_AP_BOW_FIRE, /* 0x0B */ PLAYER_AP_BOW_ICE, @@ -90,7 +99,7 @@ typedef enum { /* 0x19 */ PLAYER_AP_BOTTLE_ZORA_EGG, /* 0x1A */ PLAYER_AP_BOTTLE_DEKU_PRINCESS, /* 0x1B */ PLAYER_AP_BOTTLE_GOLD_DUST, - /* 0x1D */ PLAYER_AP_BOTTLE_SEA_HORSE = 0x1D, + /* 0x1D */ PLAYER_AP_BOTTLE_SEAHORSE = 0x1D, /* 0x1E */ PLAYER_AP_BOTTLE_MUSHROOM, /* 0x1F */ PLAYER_AP_BOTTLE_HYLIAN_LOACH, /* 0x20 */ PLAYER_AP_BOTTLE_BUG, @@ -112,7 +121,7 @@ typedef enum { /* 0x30 */ PLAYER_AP_DEED_MOUNTAIN, /* 0x31 */ PLAYER_AP_DEED_OCEAN, /* 0x33 */ PLAYER_AP_LETTER_MAMA = 0x33, - /* 0x36 */ PLAYER_AP_PENDANT_MEMORIES = 0x36, + /* 0x36 */ PLAYER_AP_PENDANT_OF_MEMORIES = 0x36, /* 0x3A */ PLAYER_AP_MASK_TRUTH = 0x3A, /* 0x3B */ PLAYER_AP_MASK_KAFEIS_MASK, /* 0x3C */ PLAYER_AP_MASK_ALL_NIGHT, @@ -141,6 +150,44 @@ typedef enum { /* 0xFD */ PLAYER_AP_MAX = 0xFD } PlayerActionParam; +typedef enum { + /* 0 */ PLAYER_MWA_FORWARD_SLASH_1H, // Vertical one-handed slash + /* 1 */ PLAYER_MWA_FORWARD_SLASH_2H, // Vertical two-handed slash + /* 2 */ PLAYER_MWA_FORWARD_COMBO_1H, // Third vertical one-handed slash + /* 3 */ PLAYER_MWA_FORWARD_COMBO_2H, // Third vertical two-handed slash + /* 4 */ PLAYER_MWA_RIGHT_SLASH_1H, // Horizontal one-handed slash + /* 5 */ PLAYER_MWA_RIGHT_SLASH_2H, // Horizontal two-handed slash + /* 6 */ PLAYER_MWA_RIGHT_COMBO_1H, // Third horizontal one-handed slash + /* 7 */ PLAYER_MWA_RIGHT_COMBO_2H, // Third horizontal two-handed slash + /* 8 */ PLAYER_MWA_LEFT_SLASH_1H, // Targeted one-handed rightwalk slash + /* 9 */ PLAYER_MWA_LEFT_SLASH_2H, // Targeted two-handed rightwalk slash + /* 10 */ PLAYER_MWA_LEFT_COMBO_1H, // Third targeted one-handed rightwalk slash + /* 11 */ PLAYER_MWA_LEFT_COMBO_2H, // Third targeted two-handed rightwalk slash + /* 12 */ PLAYER_MWA_STAB_1H, // Crouch stab/targeted one-handed stab + /* 13 */ PLAYER_MWA_STAB_2H, // Targeted two-handed stab + /* 14 */ PLAYER_MWA_STAB_COMBO_1H, // Third targeted one-handed stab + /* 15 */ PLAYER_MWA_STAB_COMBO_2H, // Third targeted two-handed stab + /* 16 */ PLAYER_MWA_FLIPSLASH_START, // unused + /* 17 */ PLAYER_MWA_JUMPSLASH_START, // Start of jumpslash + /* 18 */ PLAYER_MWA_ZORA_JUMPKICK_START, // Start of Zora jump attack + /* 19 */ PLAYER_MWA_FLIPSLASH_FINISH, // unused + /* 20 */ PLAYER_MWA_JUMPSLASH_FINISH, // End of jumpslash + /* 21 */ PLAYER_MWA_ZORA_JUMPKICK_FINISH, // End of Zora jump attack + /* 22 */ PLAYER_MWA_BACKSLASH_RIGHT, // unused + /* 23 */ PLAYER_MWA_BACKSLASH_LEFT, // unused + /* 24 */ PLAYER_MWA_GORON_PUNCH_LEFT, // Goron punch + /* 25 */ PLAYER_MWA_GORON_PUNCH_RIGHT, // Second Goron punch + /* 26 */ PLAYER_MWA_GORON_PUNCH_BUTT, // Goron butt punch + /* 27 */ PLAYER_MWA_ZORA_PUNCH_LEFT, // Zora punch + /* 28 */ PLAYER_MWA_ZORA_PUNCH_COMBO, // Second Zora punch + /* 29 */ PLAYER_MWA_ZORA_PUNCH_KICK, // Zora kick + /* 30 */ PLAYER_MWA_SPIN_ATTACK_1H, // Half-charged one-handed spin + /* 31 */ PLAYER_MWA_SPIN_ATTACK_2H, // Half-charged two-handed spin + /* 32 */ PLAYER_MWA_BIG_SPIN_1H, // Fully-charged one-handed spin + /* 33 */ PLAYER_MWA_BIG_SPIN_2H, // Fully-charged two-handed spin + /* 34 */ PLAYER_MWA_MAX +} PlayerMeleeWeaponAnimation; + typedef struct { /* 0x00 */ f32 unk_00; /* 0x04 */ f32 unk_04; @@ -178,7 +225,6 @@ typedef struct { /* 0xD4 */ LinkAnimationHeader* unk_D4[2]; } PlayerAgeProperties; // size = 0xDC - typedef struct { /* 0x00 */ s32 active; /* 0x04 */ Vec3f tip; @@ -186,7 +232,226 @@ typedef struct { } WeaponInfo; // size = 0x1C -typedef void (*PlayerFuncD58)(struct GlobalContext*, struct Player*); +typedef void (*PlayerFuncD58)(struct PlayState*, struct Player*); + +typedef struct { + /* 0x00 */ u8 unk_00; + /* 0x01 */ u8 alpha; + /* 0x02 */ char unk_02[2]; // probably alignment padding + /* 0x04 */ MtxF mf; +} struct_80122D44_arg1_unk_04; // size = 0x44 + +typedef struct { + /* 0x00 */ u8 unk_00; + /* 0x01 */ s8 unk_01; + /* 0x02 */ char unk_02[2]; // probably alignment padding + /* 0x04 */ struct_80122D44_arg1_unk_04 unk_04[4]; +} struct_80122D44_arg1; // size >= 0x114 + +typedef struct struct_80122744_arg1 { + /* 0x0 */ s8 unk_00; + /* 0x1 */ s8 unk_01; + /* 0x2 */ s8 unk_02; + /* 0x3 */ s8 unk_03; + /* 0x4 */ Vec3s* unk_04; +} struct_80122744_arg1; // size = 0x8 + +// +#define PLAYER_STATE1_1 (1 << 0) +// +#define PLAYER_STATE1_2 (1 << 1) +// +#define PLAYER_STATE1_4 (1 << 2) +// +#define PLAYER_STATE1_8 (1 << 3) +// +#define PLAYER_STATE1_10 (1 << 4) +// +#define PLAYER_STATE1_20 (1 << 5) +// +#define PLAYER_STATE1_40 (1 << 6) +// +#define PLAYER_STATE1_80 (1 << 7) +// +#define PLAYER_STATE1_100 (1 << 8) +// +#define PLAYER_STATE1_200 (1 << 9) +// +#define PLAYER_STATE1_400 (1 << 10) +// +#define PLAYER_STATE1_800 (1 << 11) +// +#define PLAYER_STATE1_1000 (1 << 12) +// +#define PLAYER_STATE1_2000 (1 << 13) +// +#define PLAYER_STATE1_4000 (1 << 14) +// +#define PLAYER_STATE1_8000 (1 << 15) +// +#define PLAYER_STATE1_10000 (1 << 16) +// +#define PLAYER_STATE1_20000 (1 << 17) +// +#define PLAYER_STATE1_40000 (1 << 18) +// +#define PLAYER_STATE1_80000 (1 << 19) +// +#define PLAYER_STATE1_100000 (1 << 20) +// +#define PLAYER_STATE1_200000 (1 << 21) +// +#define PLAYER_STATE1_400000 (1 << 22) +// +#define PLAYER_STATE1_800000 (1 << 23) +// +#define PLAYER_STATE1_1000000 (1 << 24) +// +#define PLAYER_STATE1_2000000 (1 << 25) +// +#define PLAYER_STATE1_4000000 (1 << 26) +// Swimming? +#define PLAYER_STATE1_8000000 (1 << 27) +// +#define PLAYER_STATE1_10000000 (1 << 28) +// +#define PLAYER_STATE1_20000000 (1 << 29) +// +#define PLAYER_STATE1_40000000 (1 << 30) +// +#define PLAYER_STATE1_80000000 (1 << 31) + + +// +#define PLAYER_STATE2_1 (1 << 0) +// +#define PLAYER_STATE2_2 (1 << 1) +// +#define PLAYER_STATE2_4 (1 << 2) +// +#define PLAYER_STATE2_8 (1 << 3) +// +#define PLAYER_STATE2_10 (1 << 4) +// +#define PLAYER_STATE2_20 (1 << 5) +// +#define PLAYER_STATE2_40 (1 << 6) +// +#define PLAYER_STATE2_80 (1 << 7) +// +#define PLAYER_STATE2_100 (1 << 8) +// +#define PLAYER_STATE2_200 (1 << 9) +// +#define PLAYER_STATE2_400 (1 << 10) +// +#define PLAYER_STATE2_800 (1 << 11) +// +#define PLAYER_STATE2_1000 (1 << 12) +// +#define PLAYER_STATE2_2000 (1 << 13) +// +#define PLAYER_STATE2_4000 (1 << 14) +// +#define PLAYER_STATE2_8000 (1 << 15) +// +#define PLAYER_STATE2_10000 (1 << 16) +// +#define PLAYER_STATE2_20000 (1 << 17) +// +#define PLAYER_STATE2_40000 (1 << 18) +// +#define PLAYER_STATE2_80000 (1 << 19) +// +#define PLAYER_STATE2_100000 (1 << 20) +// +#define PLAYER_STATE2_200000 (1 << 21) +// +#define PLAYER_STATE2_400000 (1 << 22) +// +#define PLAYER_STATE2_800000 (1 << 23) +// +#define PLAYER_STATE2_1000000 (1 << 24) +// +#define PLAYER_STATE2_2000000 (1 << 25) +// +#define PLAYER_STATE2_4000000 (1 << 26) +// +#define PLAYER_STATE2_8000000 (1 << 27) +// +#define PLAYER_STATE2_10000000 (1 << 28) +// +#define PLAYER_STATE2_20000000 (1 << 29) +// +#define PLAYER_STATE2_40000000 (1 << 30) +// +#define PLAYER_STATE2_80000000 (1 << 31) + + +// +#define PLAYER_STATE3_1 (1 << 0) +// +#define PLAYER_STATE3_2 (1 << 1) +// +#define PLAYER_STATE3_4 (1 << 2) +// +#define PLAYER_STATE3_8 (1 << 3) +// +#define PLAYER_STATE3_10 (1 << 4) +// +#define PLAYER_STATE3_20 (1 << 5) +// +#define PLAYER_STATE3_40 (1 << 6) +// +#define PLAYER_STATE3_80 (1 << 7) +// +#define PLAYER_STATE3_100 (1 << 8) +// +#define PLAYER_STATE3_200 (1 << 9) +// +#define PLAYER_STATE3_400 (1 << 10) +// +#define PLAYER_STATE3_800 (1 << 11) +// +#define PLAYER_STATE3_1000 (1 << 12) +// +#define PLAYER_STATE3_2000 (1 << 13) +// +#define PLAYER_STATE3_4000 (1 << 14) +// +#define PLAYER_STATE3_8000 (1 << 15) +// +#define PLAYER_STATE3_10000 (1 << 16) +// +#define PLAYER_STATE3_20000 (1 << 17) +// +#define PLAYER_STATE3_40000 (1 << 18) +// +#define PLAYER_STATE3_80000 (1 << 19) +// +#define PLAYER_STATE3_100000 (1 << 20) +// +#define PLAYER_STATE3_200000 (1 << 21) +// +#define PLAYER_STATE3_400000 (1 << 22) +// +#define PLAYER_STATE3_800000 (1 << 23) +// +#define PLAYER_STATE3_1000000 (1 << 24) +// +#define PLAYER_STATE3_2000000 (1 << 25) +// +#define PLAYER_STATE3_4000000 (1 << 26) +// +#define PLAYER_STATE3_8000000 (1 << 27) +// +#define PLAYER_STATE3_10000000 (1 << 28) +// breman mask march? +#define PLAYER_STATE3_20000000 (1 << 29) +// +#define PLAYER_STATE3_40000000 (1 << 30) +// +#define PLAYER_STATE3_80000000 (1 << 31) typedef struct Player { @@ -239,7 +504,7 @@ typedef struct Player { /* 0x1DC */ OSMesgQueue giObjectLoadQueue; /* 0x1F4 */ OSMesg giObjectLoadMsg; /* 0x1F8 */ void* giObjectSegment; - /* 0x1FC */ u8 maskObjectLoading; + /* 0x1FC */ u8 maskObjectLoadState; /* 0x1FD */ s8 maskId; /* 0x200 */ DmaRequest maskDmaRequest; /* 0x220 */ OSMesgQueue maskObjectLoadQueue; @@ -267,7 +532,7 @@ typedef struct Player { /* 0x38C */ s8 mountSide; /* 0x390 */ Actor* rideActor; /* 0x394 */ u8 csMode; - /* 0x395 */ u8 unk_395; + /* 0x395 */ u8 unk_395; // prevCsMode? /* 0x396 */ u8 unk_396; /* 0x397 */ u8 unk_397; /* 0x398 */ Actor* unk_398; @@ -283,15 +548,16 @@ typedef struct Player { /* 0x3CC */ s16 unk_3CC; /* 0x3CE */ s8 unk_3CE; /* 0x3CF */ u8 unk_3CF; - /* 0x3D0 */ char unk_3D0[0x148]; + /* 0x3D0 */ struct_80122D44_arg1 unk_3D0; + /* 0x404 */ UNK_TYPE1 unk_404[0x34]; /* 0x518 */ ColliderCylinder cylinder; - /* 0x564 */ ColliderQuad swordQuads[2]; + /* 0x564 */ ColliderQuad meleeWeaponQuads[2]; /* 0x664 */ ColliderQuad shieldQuad; /* 0x6E4 */ ColliderCylinder shieldCylinder; /* 0x730 */ Actor* unk_730; /* 0x734 */ char unk_734[4]; /* 0x738 */ s32 unk_738; - /* 0x73C */ s32 blureEffectIndex[3]; + /* 0x73C */ s32 meleeWeaponEffectIndex[3]; /* 0x748 */ char unk_748[0x320]; /* 0xA68 */ PlayerAgeProperties* ageProperties; // repurposed as "transformation properties"? /* 0xA6C */ u32 stateFlags1; @@ -329,8 +595,8 @@ typedef struct Player { /* 0xAD4 */ s16 currentYaw; /* 0xAD6 */ s16 targetYaw; /* 0xAD8 */ u16 unk_AD8; - /* 0xADA */ s8 swordAnimation; - /* 0xADB */ s8 swordState; + /* 0xADA */ s8 meleeWeaponAnimation; + /* 0xADB */ s8 meleeWeaponState; /* 0xADC */ s8 unk_ADC; /* 0xADD */ s8 unk_ADD; /* 0xADE */ u8 unk_ADE; @@ -390,7 +656,7 @@ typedef struct Player { /* 0xB92 */ s16 unk_B92; /* 0xB94 */ s16 unk_B94; /* 0xB96 */ s16 unk_B96; - /* 0xB98 */ WeaponInfo swordInfo[3]; + /* 0xB98 */ WeaponInfo meleeWeaponInfo[3]; /* 0xBEC */ Vec3f bodyPartsPos[18]; /* 0xCC4 */ MtxF mf_CC4; /* 0xD04 */ MtxF shieldMf; diff --git a/include/z64rumble.h b/include/z64rumble.h new file mode 100644 index 000000000..cb422d2de --- /dev/null +++ b/include/z64rumble.h @@ -0,0 +1,46 @@ +#ifndef Z64RUMBLE_H +#define Z64RUMBLE_H + +#include "PR/ultratypes.h" +#include "io/controller.h" + +typedef enum RumbleManagerState { + /* 0 */ RUMBLEMANAGER_STATE_WIPE, // Disables the request processing and wipes every request. It can be either set manually or automatically by the system as fail-safe in case the Rumble Pak has been vibrating for 2 minutes + /* 1 */ RUMBLEMANAGER_STATE_RUNNING, // Normal execution and updating + /* 2 */ RUMBLEMANAGER_STATE_INITIAL // Indicates initialization and cleanup must be done before processing the rumble requests. All the old requests on are wiped on this state. Then it proceeds to RUMBLEMANAGER_STATE_RUNNING +} RumbleManagerState; + +#define RUMBLE_REQUEST_BUFFER_SIZE 0x40 + +typedef struct RumbleManager { + /* 0x000 */ u8 rumbleEnabled[MAXCONTROLLERS]; + /* 0x004 */ u8 requestIntensities[RUMBLE_REQUEST_BUFFER_SIZE]; // seems to have two purposes: act as a priority value over the other rumble requests and to contribute to requestAccumulators on each tick + /* 0x044 */ u8 requestDecayTimers[RUMBLE_REQUEST_BUFFER_SIZE]; // amount of ticks this request will run before requestIntensities starts decreasing + /* 0x084 */ u8 requestDecaySteps[RUMBLE_REQUEST_BUFFER_SIZE]; // used to decrease requestIntensities by this amount each tick after requestDecayTimers runs out + /* 0x0C4 */ u8 requestAccumulators[RUMBLE_REQUEST_BUFFER_SIZE]; // the value contained here plus requestIntensities must meet a certain threshold to start rumbling this tick + /* 0x104 */ u8 state; + /* 0x105 */ u8 updateEnabled; // boolean value which controls if the Update function should be run. Unlike RUMBLEMANAGER_STATE_WIPE, disabling this does not wipe the state of the requests + /* 0x106 */ u16 rumblingDuration; // amount of "ticks" updates the Rumble Pak has been rumbling without pause. It is restarted after 5 ticks of not rumbling + /* 0x108 */ u16 downTime; // small counter/timer used to restart rumblingDuration + /* 0x10A */ u8 overrideIntensity; // "override" counterpart for requestIntensities + /* 0x10B */ u8 overrideDecayTimer; + /* 0x10C */ u8 overrideDecayStep; + /* 0x10D */ u8 overrideAccumulator; +} RumbleManager; // size = 0x10E + +extern RumbleManager gRumbleMgr; + +void Rumble_Override(f32 distSq, u8 sourceIntensity, u8 decayTimer, u8 decayStep); +void Rumble_Request(f32 distSq, u8 sourceIntensity, u8 decayTimer, u8 decayStep); +void Rumble_Init(void); +void Rumble_Destroy(void); +s32 Rumble_ControllerOneHasRumblePak(void); +void Rumble_StateReset(void); +void Rumble_StateWipeRequests(void); +void Rumble_SetUpdateEnabled(s32 updateEnabled); + +void RumbleManager_Update(RumbleManager* rumbleMgr); +void RumbleManager_Init(RumbleManager* rumbleMgr); +void RumbleManager_Destroy(RumbleManager* rumbleMgr); + +#endif diff --git a/include/z64save.h b/include/z64save.h index 2595b3c27..6b77e2968 100644 --- a/include/z64save.h +++ b/include/z64save.h @@ -6,15 +6,15 @@ #include "os.h" struct GameState; -struct GlobalContext; +struct PlayState; struct FileChooseContext; // TODO: properly name DOWN, RETURN and TOP typedef enum RespawnMode { - /* 0 */ RESTART_MODE_DOWN, // "RESTART_MODE_DOWN" - /* 1 */ RESTART_MODE_RETURN, // "RESTART_MODE_RETURN" - /* 2 */ RESTART_MODE_TOP, // "RESTART_MODE_TOP" - /* 3 */ RESPAWN_MODE_UNK_3, // Maybe related to grottos + /* 0 */ RESPAWN_MODE_DOWN, // "RESTART_MODE_DOWN" + /* 1 */ RESPAWN_MODE_RETURN, // "RESTART_MODE_RETURN" + /* 2 */ RESPAWN_MODE_TOP, // "RESTART_MODE_TOP" + /* 3 */ RESPAWN_MODE_UNK_3, // Related to grottos /* 4 */ RESPAWN_MODE_GORON, // "RESTART_MODE_GORON" /* 5 */ RESPAWN_MODE_ZORA, // "RESTART_MODE_ZORA" /* 6 */ RESPAWN_MODE_DEKU, // "RESTART_MODE_NUTS" @@ -49,22 +49,23 @@ typedef struct Inventory { /* 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" + /* 0x5A */ s8 dungeonKeys[9]; // "key_register" + /* 0x63 */ s8 defenseHearts; /* 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 HorseData { - /* 0x00 */ s16 scene; // "spot_no" - /* 0x02 */ Vec3s pos; // "horse_x", "horse_y" and "horse_z" - /* 0x08 */ s16 yaw; // "horse_a" -} HorseData; // size = 0x0A + /* 0x0 */ s16 scene; // "spot_no" + /* 0x2 */ Vec3s pos; // "horse_x", "horse_y" and "horse_z" + /* 0x8 */ s16 yaw; // "horse_a" +} HorseData; // size = 0xA typedef struct RespawnData { /* 0x00 */ Vec3f pos; /* 0x0C */ s16 yaw; /* 0x0E */ s16 playerParams; - /* 0x10 */ u16 entranceIndex; + /* 0x10 */ u16 entrance; /* 0x12 */ u8 roomIndex; /* 0x13 */ s8 data; /* 0x14 */ u32 tempSwitchFlags; @@ -78,8 +79,8 @@ typedef struct PermanentSceneFlags { /* 0x08 */ u32 switch1; /* 0x0C */ u32 clearedRoom; /* 0x10 */ u32 collectible; - /* 0x14 */ u32 unk_14; - /* 0x18 */ u32 unk_18; + /* 0x14 */ u32 unk_14; // varies based on scene. For dungeons, floors visited. + /* 0x18 */ u32 rooms; } PermanentSceneFlags; // size = 0x1C typedef struct CycleSceneFlags { @@ -91,36 +92,36 @@ typedef struct CycleSceneFlags { } CycleSceneFlags; // size = 0x14 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 + /* 0x0 */ u16 optionId; // "option_id" + /* 0x2 */ u8 language; // "j_n" + /* 0x3 */ s8 audioSetting; // "s_sound" + /* 0x4 */ u8 languageSetting; // "language" + /* 0x5 */ u8 zTargetSetting; // "z_attention", 0: Switch; 1: Hold +} SaveOptions; // size = 0x6 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" + /* 0x00 */ char newf[6]; // "newf" Will always be "ZELDA3 for a valid save + /* 0x06 */ u16 deaths; // "savect" + /* 0x08 */ char playerName[8]; // "player_name" + /* 0x10 */ s16 healthCapacity; // "max_life" + /* 0x12 */ s16 health; // "now_life" + /* 0x14 */ s8 magicLevel; // "magic_max" + /* 0x15 */ s8 magic; // "magic_now" + /* 0x16 */ s16 rupees; // "lupy_count" + /* 0x18 */ u16 swordHealth; // "long_sword_hp" + /* 0x1A */ u16 tatlTimer; // "navi_timer" + /* 0x1C */ u8 magicAcquired; // "magic_mode" + /* 0x1D */ u8 doubleMagic; // "magic_ability" + /* 0x1E */ u8 doubleDefense; // "life_ability" + /* 0x1F */ u8 unk_1F; // "ocarina_round" + /* 0x20 */ u8 unk_20; // "first_memory" + /* 0x22 */ u16 owlActivationFlags; // "memory_warp_point" + /* 0x24 */ u8 unk_24; // "last_warp_pt" + /* 0x26 */ s16 savedSceneNum; // "scene_data_ID" } SavePlayerData; // size = 0x28 typedef struct Save { - /* 0x0000 */ u32 entranceIndex; // "scene_no" + /* 0x0000 */ u32 entrance; // "scene_no" /* 0x0004 */ u8 equippedMask; // "player_mask" /* 0x0005 */ u8 isFirstCycle; // "opening_flag" /* 0x0006 */ u8 unk_06; @@ -129,9 +130,9 @@ typedef struct Save { /* 0x000C */ u16 time; // "zelda_time" /* 0x000E */ u16 owlSaveLocation; /* 0x0010 */ s32 isNight; // "asahiru_fg" - /* 0x0014 */ u32 daySpeed; // "change_zelda_time" + /* 0x0014 */ s32 daySpeed; // "change_zelda_time" /* 0x0018 */ s32 day; // "totalday" - /* 0x001C */ u32 daysElapsed; // "eventday" + /* 0x001C */ s32 daysElapsed; // "eventday" /* 0x0020 */ u8 playerForm; // "player_character" /* 0x0021 */ u8 snowheadCleared; // "spring_flag" /* 0x0022 */ u8 hasTatl; // "bell_flag" @@ -142,8 +143,8 @@ typedef struct Save { /* 0x00F8 */ PermanentSceneFlags permanentSceneFlags[120]; /* 0x0E18 */ u8 unk_E18[0x54]; /* 0x0E6C */ u32 dekuPlaygroundHighScores[3]; - /* 0x0E78 */ u32 pictoFlags0; - /* 0x0E7C */ u32 pictoFlags1; + /* 0x0E78 */ u32 pictoFlags0; // Flags set by `PictoActor`s if pictograph is valid + /* 0x0E7C */ u32 pictoFlags1; // Flags set by Snap_ValidatePictograph() to record errors; volatile since that function is run many times in succession /* 0x0E80 */ u32 unk_E80; /* 0x0E84 */ u32 unk_E84; /* 0x0E88 */ u32 unk_E88[7]; // Invadepoh flags @@ -160,13 +161,13 @@ typedef struct Save { /* 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 + /* 0x0EF4 */ u32 shootingGalleryHighScores; // High scores for both shooting galleries. Town uses lower 16 bits, Swamp uses higher 16 bits. /* 0x0EF8 */ u8 weekEventReg[100]; // "week_event_reg" /* 0x0F5C */ u32 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]; + /* 0x0F66 */ u8 scarecrowSpawnSong[128]; /* 0x0FE6 */ s8 bombersCaughtNum; // "aikotoba_index" /* 0x0FE7 */ s8 bombersCaughtOrder[5]; // "aikotoba_table" /* 0x0FEC */ s8 lotteryCodes[3][3]; // "numbers_table", Preset lottery codes @@ -240,16 +241,16 @@ typedef struct SaveContext { /* 0x3F3F */ u8 unk_3F3F; // "flash_flag" /* 0x3F40 */ SaveOptions options; /* 0x3F46 */ u16 unk_3F46; // "NottoriBgm" - /* 0x3F48 */ u8 unk_3F48; // "fade_go" + /* 0x3F48 */ u8 cutsceneTransitionControl; // "fade_go" /* 0x3F4A */ u16 nextCutsceneIndex; // "next_daytime" /* 0x3F4C */ u8 cutsceneTrigger; // "doukidemo" /* 0x3F4D */ u8 unk_3F4D; // "Kenjya_no" /* 0x3F4E */ u16 nextDayTime; // "next_zelda_time" - /* 0x3F50 */ u8 fadeDuration; // "fade_speed" - /* 0x3F51 */ u8 fadeSpeed; // "wipe_speed" transition related - /* 0x3F52 */ u16 environmentTime; // "kankyo_time" + /* 0x3F50 */ u8 transFadeDuration; // "fade_speed" + /* 0x3F51 */ u8 transWipeSpeed; // "wipe_speed" transition related + /* 0x3F52 */ u16 skyboxTime; // "kankyo_time" /* 0x3F54 */ u8 dogIsLost; // "dog_event_flag" - /* 0x3F55 */ u8 nextTransition; // "next_wipe" + /* 0x3F55 */ u8 nextTransitionType; // "next_wipe" /* 0x3F56 */ s16 worldMapArea; // "area_type" /* 0x3F58 */ s16 sunsSongState; // "sunmoon_flag" /* 0x3F5A */ s16 healthAccumulator; // "life_mode" @@ -257,7 +258,7 @@ typedef struct SaveContext { /* 0x3F60 */ u8 screenScaleFlag; // "framescale_flag" /* 0x3F64 */ f32 screenScale; // "framescale_scale" /* 0x3F68 */ CycleSceneFlags cycleSceneFlags[120]; // Scene flags that are temporarily stored over the duration of a single 3-day cycle - /* 0x48C8 */ u16 unk_48C8; // "scene_id_mix" + /* 0x48C8 */ u16 dungeonIndex; // "scene_id_mix" /* 0x48CA */ u8 maskMaskBit[27]; // "mask_mask_bit", masks given away on the Moon } SaveContext; // size = 0x48C8 @@ -273,9 +274,95 @@ typedef enum SunsSongState { /* 3 */ SUNSSONG_SPECIAL // time does not advance, but signals the song was played. used for freezing redeads } SunsSongState; +// linkAge still exists in MM, but is always set to 0 (always adult) +// There are remnants of these macros from OOT, but they are essentially useless +#define LINK_IS_CHILD (gSaveContext.save.linkAge == 1) +#define LINK_IS_ADULT (gSaveContext.save.linkAge == 0) + +#define CURRENT_DAY (((void)0, gSaveContext.save.day) % 5) + +#define SLOT(item) gItemSlots[item] +#define AMMO(item) gSaveContext.save.inventory.ammo[SLOT(item)] +#define INV_CONTENT(item) gSaveContext.save.inventory.items[SLOT(item)] +#define GET_INV_CONTENT(item) ((void)0, gSaveContext.save.inventory.items)[SLOT(item)] + +#define CUR_FORM ((gSaveContext.save.playerForm == PLAYER_FORM_HUMAN) ? 0 : gSaveContext.save.playerForm) + +#define GET_SAVE_EQUIPS_EQUIPMENT ((void)0, gSaveContext.save.equips.equipment) +#define GET_SAVE_INVENTORY_UPGRADES ((void)0, gSaveContext.save.inventory.upgrades) +#define GET_SAVE_INVENTORY_QUEST_ITEMS ((void)0, gSaveContext.save.inventory.questItems) + +#define GET_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 SET_QUEST_ITEM(item) (gSaveContext.save.inventory.questItems = (GET_SAVE_INVENTORY_QUEST_ITEMS | gBitFlags[item])) +#define REMOVE_QUEST_ITEM(item) (gSaveContext.save.inventory.questItems = (GET_SAVE_INVENTORY_QUEST_ITEMS & (-1 - gBitFlags[item]))) + +#define GET_QUEST_HEART_PIECE_COUNT ((GET_SAVE_INVENTORY_QUEST_ITEMS & 0xF0000000) >> QUEST_HEART_PIECE_COUNT) +#define EQ_MAX_QUEST_HEART_PIECE_COUNT ((GET_SAVE_INVENTORY_QUEST_ITEMS & 0xF0000000) == (4 << QUEST_HEART_PIECE_COUNT)) +#define LEQ_MAX_QUEST_HEART_PIECE_COUNT ((GET_SAVE_INVENTORY_QUEST_ITEMS & 0xF0000000) <= (4 << QUEST_HEART_PIECE_COUNT)) +#define INCREMENT_QUEST_HEART_PIECE_COUNT (gSaveContext.save.inventory.questItems += (1 << QUEST_HEART_PIECE_COUNT)) +#define DECREMENT_QUEST_HEART_PIECE_COUNT (gSaveContext.save.inventory.questItems -= (1 << QUEST_HEART_PIECE_COUNT)) +#define RESET_HEART_PIECE_COUNT (gSaveContext.save.inventory.questItems ^= (4 << QUEST_HEART_PIECE_COUNT)) + +#define CHECK_DUNGEON_ITEM(item, dungeonIndex) (gSaveContext.save.inventory.dungeonItems[(void)0, dungeonIndex] & gBitFlags[item]) +#define SET_DUNGEON_ITEM(item, dungeonIndex) (gSaveContext.save.inventory.dungeonItems[(void)0, dungeonIndex] |= (u8)gBitFlags[item]) +#define DUNGEON_KEY_COUNT(dungeonIndex) (gSaveContext.save.inventory.dungeonKeys[(void)0, dungeonIndex]) + +#define GET_CUR_FORM_BTN_ITEM(btn) ((u8)((btn) == EQUIP_SLOT_B ? BUTTON_ITEM_EQUIP(CUR_FORM, btn) : BUTTON_ITEM_EQUIP(0, btn))) +#define GET_CUR_FORM_BTN_SLOT(btn) ((u8)((btn) == EQUIP_SLOT_B ? C_SLOT_EQUIP(CUR_FORM, btn) : C_SLOT_EQUIP(0, btn))) + + +#define SET_CUR_FORM_BTN_ITEM(btn, item) \ + if ((btn) == EQUIP_SLOT_B) { \ + BUTTON_ITEM_EQUIP(CUR_FORM, (btn)) = (item); \ + } else { \ + BUTTON_ITEM_EQUIP(0, (btn)) = (item); \ + } \ + (void)0 + +#define SET_CUR_FORM_BTN_SLOT(btn, item) \ + if ((btn) == EQUIP_SLOT_B) { \ + C_SLOT_EQUIP(CUR_FORM, (btn)) = (item); \ + } else { \ + C_SLOT_EQUIP(0, (btn)) = (item); \ + } \ + (void)0 + +#define STOLEN_ITEM_NONE (0) + +#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 GET_TOWN_SHOOTING_GALLERY_HIGH_SCORE() ((s32)(gSaveContext.save.shootingGalleryHighScores & 0xFFFF)) +#define GET_SWAMP_SHOOTING_GALLERY_HIGH_SCORE() ((s32)((gSaveContext.save.shootingGalleryHighScores & 0xFFFF0000) >> 0x10)) +#define SET_TOWN_SHOOTING_GALLERY_HIGH_SCORE(score) (gSaveContext.save.shootingGalleryHighScores = (gSaveContext.save.shootingGalleryHighScores & 0xFFFF0000) | ((u16)(score))) +#define SET_SWAMP_SHOOTING_GALLERY_HIGH_SCORE(score) (gSaveContext.save.shootingGalleryHighScores = ((gSaveContext.save.shootingGalleryHighScores) & 0xFFFF) | ((u16)(score) << 0x10)) + +typedef enum { + /* 0 */ DUNGEON_INDEX_WOODFALL_TEMPLE, + /* 1 */ DUNGEON_INDEX_SNOWHEAD_TEMPLE, + /* 2 */ DUNGEON_INDEX_GREAT_BAY_TEMPLE, + /* 3 */ DUNGEON_INDEX_STONE_TOWER_TEMPLE, // Also applies to Inverted Stone Tower Temple +} DungeonIndex; + void Sram_ActivateOwl(u8 owlId); void Sram_ClearFlagsAtDawnOfTheFirstDay(void); -void Sram_SaveEndOfCycle(struct GlobalContext* globalCtx); +void Sram_SaveEndOfCycle(struct PlayState* play); void Sram_IncrementDay(void); u16 Sram_CalcChecksum(void* data, size_t count); void Sram_InitNewSave(void); @@ -290,8 +377,8 @@ 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 Sram_SaveSpecialEnterClockTown(struct PlayState* play); +void Sram_SaveSpecialNewDay(struct PlayState* play); void func_80147008(SramContext* sramCtx, u32 curPage, u32 numPages); void func_80147020(SramContext* sramCtx); void func_80147068(SramContext* sramCtx); @@ -300,7 +387,7 @@ void func_80147150(SramContext* sramCtx); void func_80147198(SramContext* sramCtx); extern s32 D_801C6798[]; -extern u8 D_801C67B0[24]; +extern u8 gAmmoItems[]; extern s32 D_801C67C8[]; extern s32 D_801C67E8[]; extern s32 D_801C67F0[]; diff --git a/include/z64scene.h b/include/z64scene.h index 5a1c39e16..6a0808b55 100644 --- a/include/z64scene.h +++ b/include/z64scene.h @@ -9,211 +9,210 @@ #define SPAWN_ROT_FLAGS(rotation, flags) (((rotation) << 7) | (flags)) typedef struct { - /* 0x00 */ uintptr_t vromStart; - /* 0x04 */ uintptr_t vromEnd; + /* 0x0 */ uintptr_t vromStart; + /* 0x4 */ uintptr_t vromEnd; } RomFile; // size = 0x8 typedef struct { - /* 0x00 */ u8 code; - /* 0x01 */ u8 data1; - /* 0x04 */ u32 data2; -} SCmdBase; + /* 0x0 */ u8 code; + /* 0x1 */ u8 data1; + /* 0x4 */ u32 data2; +} SCmdBase; // size = 0x8 typedef struct { - /* 0x00 */ u8 code; - /* 0x01 */ u8 data1; - /* 0x04 */ void* segment; -} SCmdSpawnList; + /* 0x0 */ u8 code; + /* 0x1 */ u8 data1; + /* 0x4 */ void* segment; +} SCmdSpawnList; // size = 0x8 typedef struct { - /* 0x00 */ u8 code; - /* 0x01 */ u8 num; - /* 0x04 */ void* segment; -} SCmdActorList; + /* 0x0 */ u8 code; + /* 0x1 */ u8 num; + /* 0x4 */ void* segment; +} SCmdActorList; // size = 0x8 typedef struct { - /* 0x00 */ u8 code; - /* 0x01 */ u8 data1; - /* 0x04 */ void* segment; -} SCmdCsCameraList; + /* 0x0 */ u8 code; + /* 0x1 */ u8 data1; + /* 0x4 */ void* segment; +} SCmdCsCameraList; // size = 0x8 typedef struct { - /* 0x00 */ u8 code; - /* 0x01 */ u8 data1; - /* 0x04 */ void* segment; -} SCmdColHeader; + /* 0x0 */ u8 code; + /* 0x1 */ u8 data1; + /* 0x4 */ void* segment; +} SCmdColHeader; // size = 0x8 typedef struct { - /* 0x00 */ u8 code; - /* 0x01 */ u8 num; - /* 0x04 */ void* segment; -} SCmdRoomList; + /* 0x0 */ u8 code; + /* 0x1 */ u8 num; + /* 0x4 */ void* segment; +} SCmdRoomList; // size = 0x8 typedef struct { - /* 0x00 */ u8 code; - /* 0x01 */ u8 data1; - /* 0x02 */ UNK_TYPE1 pad2[2]; - /* 0x04 */ s8 west; - /* 0x05 */ s8 vertical; - /* 0x06 */ s8 south; - /* 0x07 */ u8 clothIntensity; -} SCmdWindSettings; + /* 0x0 */ u8 code; + /* 0x1 */ u8 data1; + /* 0x2 */ UNK_TYPE1 pad2[2]; + /* 0x4 */ s8 west; + /* 0x5 */ s8 vertical; + /* 0x6 */ s8 south; + /* 0x7 */ u8 clothIntensity; +} SCmdWindSettings; // size = 0x8 typedef struct { - /* 0x00 */ u8 code; - /* 0x01 */ u8 data1; - /* 0x04 */ void* segment; -} SCmdEntranceList; + /* 0x0 */ u8 code; + /* 0x1 */ u8 data1; + /* 0x4 */ void* segment; +} SCmdEntranceList; // size = 0x8 typedef struct { - /* 0x00 */ u8 code; - /* 0x01 */ u8 cUpElfMsgNum; - /* 0x04 */ u32 subKeepIndex; -} SCmdSpecialFiles; + /* 0x0 */ u8 code; + /* 0x1 */ u8 cUpElfMsgNum; + /* 0x4 */ u32 subKeepIndex; +} SCmdSpecialFiles; // size = 0x8 typedef struct { - /* 0x00 */ u8 code; - /* 0x01 */ u8 gpFlag1; - /* 0x04 */ u32 gpFlag2; -} SCmdRoomBehavior; + /* 0x0 */ u8 code; + /* 0x1 */ u8 gpFlag1; + /* 0x4 */ u32 gpFlag2; +} SCmdRoomBehavior; // size = 0x8 typedef struct { - /* 0x00 */ u8 code; - /* 0x01 */ u8 data1; - /* 0x04 */ void* segment; -} SCmdMesh; + /* 0x0 */ u8 code; + /* 0x1 */ u8 data1; + /* 0x4 */ void* segment; +} SCmdMesh; // size = 0x8 typedef struct { - /* 0x00 */ u8 code; - /* 0x01 */ u8 num; - /* 0x04 */ void* segment; -} SCmdObjectList; + /* 0x0 */ u8 code; + /* 0x1 */ u8 num; + /* 0x4 */ void* segment; +} SCmdObjectList; // size = 0x8 typedef struct { - /* 0x00 */ u8 code; - /* 0x01 */ u8 num; - /* 0x04 */ void* segment; -} SCmdLightList; + /* 0x0 */ u8 code; + /* 0x1 */ u8 num; + /* 0x4 */ void* segment; +} SCmdLightList; // size = 0x8 typedef struct { - /* 0x00 */ u8 code; - /* 0x01 */ u8 data1; - /* 0x04 */ void* segment; -} SCmdPathList; + /* 0x0 */ u8 code; + /* 0x1 */ u8 data1; + /* 0x4 */ void* segment; +} SCmdPathList; // size = 0x8 typedef struct { - /* 0x00 */ u8 code; - /* 0x01 */ u8 num; - /* 0x04 */ void* segment; -} SCmdTransiActorList; + /* 0x0 */ u8 code; + /* 0x1 */ u8 num; + /* 0x4 */ void* segment; +} SCmdTransiActorList; // size = 0x8 typedef struct { - /* 0x00 */ u8 code; - /* 0x01 */ u8 num; - /* 0x04 */ void* segment; -} SCmdLightSettingList; -// Cloudmodding has this as Environment Settings + /* 0x0 */ u8 code; + /* 0x1 */ u8 num; + /* 0x4 */ void* segment; +} SCmdLightSettingList; // size = 0x8 typedef struct { - /* 0x00 */ u8 code; - /* 0x01 */ u8 data1; - /* 0x02 */ UNK_TYPE1 pad2[2]; - /* 0x04 */ u8 hour; - /* 0x05 */ u8 min; - /* 0x06 */ u8 unk6; -} SCmdTimeSettings; + /* 0x0 */ u8 code; + /* 0x1 */ u8 data1; + /* 0x2 */ UNK_TYPE1 pad2[2]; + /* 0x4 */ u8 hour; + /* 0x5 */ u8 min; + /* 0x6 */ u8 unk6; +} SCmdTimeSettings; // size = 0x7 typedef struct { - /* 0x00 */ u8 code; - /* 0x01 */ u8 data1; - /* 0x02 */ UNK_TYPE1 pad2[2]; - /* 0x04 */ u8 skyboxId; - /* 0x05 */ u8 unk5; - /* 0x06 */ u8 unk6; -} SCmdSkyboxSettings; + /* 0x0 */ u8 code; + /* 0x1 */ u8 data1; + /* 0x2 */ UNK_TYPE1 pad2[2]; + /* 0x4 */ u8 skyboxId; + /* 0x5 */ u8 unk5; + /* 0x6 */ u8 unk6; +} SCmdSkyboxSettings; // size = 0x7 typedef struct { - /* 0x00 */ u8 code; - /* 0x01 */ u8 data1; - /* 0x02 */ UNK_TYPE1 pad2[2]; - /* 0x04 */ u8 unk4; - /* 0x05 */ u8 unk5; -} SCmdSkyboxDisables; + /* 0x0 */ u8 code; + /* 0x1 */ u8 data1; + /* 0x2 */ UNK_TYPE1 pad2[2]; + /* 0x4 */ u8 unk4; + /* 0x5 */ u8 unk5; +} SCmdSkyboxDisables; // size = 0x6 typedef struct { - /* 0x00 */ u8 code; - /* 0x01 */ u8 data1; - /* 0x04 */ void* segment; -} SCmdExitList; + /* 0x0 */ u8 code; + /* 0x1 */ u8 data1; + /* 0x4 */ void* segment; +} SCmdExitList; // size = 0x8 typedef struct { - /* 0x00 */ u8 code; - /* 0x01 */ u8 data1; - /* 0x04 */ u32 data2; -} SCmdEndMarker; + /* 0x0 */ u8 code; + /* 0x1 */ u8 data1; + /* 0x4 */ u32 data2; +} SCmdEndMarker; // size = 0x8 typedef struct { - /* 0x00 */ u8 code; - /* 0x01 */ u8 bgmId; - /* 0x02 */ UNK_TYPE1 pad2[4]; - /* 0x06 */ u8 nighttimeSFX; - /* 0x07 */ u8 musicSeq; -} SCmdSoundSettings; + /* 0x0 */ u8 code; + /* 0x1 */ u8 bgmId; + /* 0x2 */ UNK_TYPE1 pad2[4]; + /* 0x6 */ u8 nighttimeSFX; + /* 0x7 */ u8 musicSeq; +} SCmdSoundSettings; // size = 0x8 typedef struct { - /* 0x00 */ u8 code; - /* 0x01 */ u8 data1; - /* 0x02 */ UNK_TYPE1 pad2[5]; - /* 0x07 */ u8 echo; -} SCmdEchoSettings; + /* 0x0 */ u8 code; + /* 0x1 */ u8 data1; + /* 0x2 */ UNK_TYPE1 pad2[5]; + /* 0x7 */ u8 echo; +} SCmdEchoSettings; // size = 0x8 typedef struct { - /* 0x00 */ u8 code; - /* 0x01 */ u8 data1; - /* 0x04 */ void* segment; -} SCmdCutsceneData; + /* 0x0 */ u8 code; + /* 0x1 */ u8 data1; + /* 0x4 */ void* segment; +} SCmdCutsceneData; // size = 0x8 typedef struct { - /* 0x00 */ u8 code; - /* 0x01 */ u8 cameraMovement; - /* 0x04 */ u32 area; -} SCmdMiscSettings; + /* 0x0 */ u8 code; + /* 0x1 */ u8 cameraMovement; + /* 0x4 */ u32 area; +} SCmdMiscSettings; // size = 0x8 typedef struct { - /* 0x00 */ u8 code; - /* 0x01 */ u8 data1; - /* 0x04 */ void* segment; -} SCmdAltHeaders; + /* 0x0 */ u8 code; + /* 0x1 */ u8 data1; + /* 0x4 */ void* segment; +} SCmdAltHeaders; // size = 0x8 typedef struct { - /* 0x00 */ u8 code; - /* 0x01 */ u8 data1; - /* 0x04 */ u32 data2; -} SCmdWorldMapVisited; + /* 0x0 */ u8 code; + /* 0x1 */ u8 data1; + /* 0x4 */ u32 data2; +} SCmdWorldMapVisited; // size = 0x8 typedef struct { - /* 0x00 */ u8 code; - /* 0x01 */ u8 data1; - /* 0x04 */ void* segment; -} SCmdTextureAnimations; + /* 0x0 */ u8 code; + /* 0x1 */ u8 data1; + /* 0x4 */ void* segment; +} SCmdTextureAnimations; // size = 0x8 typedef struct { - /* 0x00 */ u8 code; - /* 0x01 */ u8 num; - /* 0x04 */ void* segment; -} SCmdCutsceneActorList; + /* 0x0 */ u8 code; + /* 0x1 */ u8 num; + /* 0x4 */ void* segment; +} SCmdCutsceneActorList; // size = 0x8 typedef struct { - /* 0x00 */ u8 code; - /* 0x01 */ u8 data1; - /* 0x04 */ void* segment; -} SCmdMinimapSettings; + /* 0x0 */ u8 code; + /* 0x1 */ u8 data1; + /* 0x4 */ void* segment; +} SCmdMinimapSettings; // size = 0x8 typedef struct { - /* 0x00 */ u8 code; - /* 0x01 */ u8 num; - /* 0x04 */ void* segment; -} SCmdMinimapChests; + /* 0x0 */ u8 code; + /* 0x1 */ u8 num; + /* 0x4 */ void* segment; +} SCmdMinimapChests; // size = 0x8 typedef struct { /* 0x0 */ Gfx* opaqueDl; @@ -260,7 +259,7 @@ typedef union { typedef struct { /* 0x00 */ s8 num; /* 0x01 */ u8 unk1; - /* 0x02 */ u8 unk2; + /* 0x02 */ u8 unk2; // 3: Room is hot /* 0x03 */ u8 unk3; /* 0x04 */ s8 echo; /* 0x05 */ u8 unk5; @@ -292,17 +291,17 @@ typedef struct { struct { s8 room; // Room to switch to 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; - /* 0x0C */ s16 rotY; - /* 0x0E */ u16 params; + } /* 0x0 */ sides[2]; // 0 = front, 1 = back + /* 0x4 */ s16 id; + /* 0x6 */ Vec3s pos; + /* 0xC */ s16 rotY; + /* 0xE */ u16 params; } TransitionActorEntry; // size = 0x10 typedef struct { - /* 0x00 */ u8 numTransitionActors; - /* 0x04 */ TransitionActorEntry* transitionActorList; -} DoorContext; + /* 0x0 */ u8 numTransitionActors; + /* 0x4 */ TransitionActorEntry* transitionActorList; +} DoorContext; // size = 0x8 typedef struct { /* 0x0 */ s16 id; @@ -343,7 +342,7 @@ typedef struct { /* 0xA */ u8 unk_A; /* 0xB */ u8 drawConfig; /* 0xC */ u8 unk_C; -} SceneTableEntry; // size = 0x10; +} SceneTableEntry; // size = 0x10 typedef struct { /* 0x0 */ u8 r; @@ -377,7 +376,7 @@ typedef struct { typedef struct { /* 0x0 */ u16 keyFrameLength; - /* 0x4 */ void* textureList; + /* 0x4 */ TexturePtr* textureList; /* 0x8 */ u8* textureIndexList; } AnimatedMatTexCycleParams; // size = 0xC @@ -392,116 +391,118 @@ typedef struct { } ObjectContext; // size = 0x958 typedef struct { - u8 headerType; -} MeshHeaderBase; + /* 0x0 */ u8 headerType; +} MeshHeaderBase; // size = 0x1 typedef struct { - MeshHeaderBase base; - - u8 numEntries; - u32 dListStart; - u32 dListEnd; -} MeshHeader0; + /* 0x0 */ MeshHeaderBase base; + /* 0x1 */ u8 numEntries; + /* 0x4 */ u32 dListStart; + /* 0x8 */ u32 dListEnd; +} MeshHeader0; // size = 0xC typedef struct { - u32 opaqueDList; - u32 translucentDList; -} MeshEntry0; + /* 0x0 */ u32 opaqueDList; + /* 0x4 */ u32 translucentDList; +} MeshEntry0; // size = 0x8 typedef struct { - MeshHeaderBase base; - u8 format; - u32 entryRecord; -} MeshHeader1Base; + /* 0x0 */ MeshHeaderBase base; + /* 0x1 */ u8 format; + /* 0x4 */ u32 entryRecord; +} MeshHeader1Base; // size = 0x8 typedef struct { - MeshHeader1Base base; - u32 imagePtr; // 0x08 - u32 unknown; // 0x0C - u32 unknown2; // 0x10 - u16 bgWidth; // 0x14 - u16 bgHeight; // 0x16 - u8 imageFormat; // 0x18 - u8 imageSize; // 0x19 - u16 imagePal; // 0x1A - u16 imageFlip; // 0x1C -} MeshHeader1Single; + /* 0x00 */ MeshHeader1Base base; + /* 0x08 */ u32 imagePtr; + /* 0x0C */ u32 unknown; + /* 0x10 */ u32 unknown2; + /* 0x14 */ u16 bgWidth; + /* 0x16 */ u16 bgHeight; + /* 0x18 */ u8 imageFormat; + /* 0x19 */ u8 imageSize; + /* 0x1A */ u16 imagePal; + /* 0x1C */ u16 imageFlip; +} MeshHeader1Single; // size = 0x20 typedef struct { - MeshHeader1Base base; - u8 bgCnt; - u32 bgRecordPtr; -} MeshHeader1Multi; + /* 0x0 */ MeshHeader1Base base; + /* 0x8 */ u8 bgCnt; + /* 0xC */ u32 bgRecordPtr; +} MeshHeader1Multi; // size = 0x10 typedef struct { - u16 unknown; // 0x00 - s8 bgID; // 0x02 - u32 imagePtr; // 0x04 - u32 unknown2; // 0x08 - u32 unknown3; // 0x0C - u16 bgWidth; // 0x10 - u16 bgHeight; // 0x12 - u8 imageFmt; // 0x14 - u8 imageSize; // 0x15 - u16 imagePal; // 0x16 - u16 imageFlip; // 0x18 -} BackgroundRecord; + /* 0x00 */ u16 unknown; + /* 0x02 */ s8 bgID; + /* 0x04 */ u32 imagePtr; + /* 0x08 */ u32 unknown2; + /* 0x0C */ u32 unknown3; + /* 0x10 */ u16 bgWidth; + /* 0x12 */ u16 bgHeight; + /* 0x14 */ u8 imageFmt; + /* 0x15 */ u8 imageSize; + /* 0x16 */ u16 imagePal; + /* 0x18 */ u16 imageFlip; +} BackgroundRecord; // size = 0x1C typedef struct { - s16 playerXMax, playerZMax; - s16 playerXMin, playerZMin; - u32 opaqueDList; - u32 translucentDList; -} MeshEntry2; + /* 0x0 */ s16 playerXMax; + /* 0x2 */ s16 playerZMax; + /* 0x4 */ s16 playerXMin; + /* 0x6 */ s16 playerZMin; + /* 0x8 */ u32 opaqueDList; + /* 0xC */ u32 translucentDList; +} MeshEntry2; // size = 0x10 typedef struct { - MeshHeaderBase base; - u8 numEntries; - u32 dListStart; - u32 dListEnd; -} MeshHeader2; + /* 0x0 */ MeshHeaderBase base; + /* 0x1 */ u8 numEntries; + /* 0x4 */ u32 dListStart; + /* 0x8 */ u32 dListEnd; +} MeshHeader2; // size = 0xC typedef struct { - /* 0x00 */ u8 count; // number of points in the path - /* 0x01 */ u8 unk1; - /* 0x02 */ s16 unk2; - /* 0x04 */ Vec3s* points; // Segment Address to the array of points + /* 0x0 */ u8 count; // number of points in the path + /* 0x1 */ u8 unk1; + /* 0x2 */ s16 unk2; + /* 0x4 */ Vec3s* points; // Segment Address to the array of points } Path; // size = 0x8 typedef struct { - /* 0x00 */ UNK_TYPE2 unk0; - /* 0x02 */ UNK_TYPE2 unk2; - /* 0x04 */ UNK_TYPE2 unk4; - /* 0x06 */ UNK_TYPE2 unk6; - /* 0x08 */ UNK_TYPE2 unk8; + /* 0x0 */ UNK_TYPE2 unk0; + /* 0x2 */ UNK_TYPE2 unk2; + /* 0x4 */ UNK_TYPE2 unk4; + /* 0x6 */ UNK_TYPE2 unk6; + /* 0x8 */ UNK_TYPE2 unk8; } MinimapEntry; // size = 0xA typedef struct { - /* 0x00 */ MinimapEntry* entry; - /* 0x04 */ UNK_TYPE unk4; + /* 0x0 */ MinimapEntry* entry; + /* 0x4 */ UNK_TYPE unk4; } MinimapList; // size = 0x8 typedef struct { - /* 0x00 */ UNK_TYPE2 unk0; - /* 0x02 */ UNK_TYPE2 unk2; - /* 0x04 */ UNK_TYPE2 unk4; - /* 0x06 */ UNK_TYPE2 unk6; - /* 0x08 */ UNK_TYPE2 unk8; + /* 0x0 */ UNK_TYPE2 unk0; + /* 0x2 */ UNK_TYPE2 unk2; + /* 0x4 */ UNK_TYPE2 unk4; + /* 0x6 */ UNK_TYPE2 unk6; + /* 0x8 */ UNK_TYPE2 unk8; } MinimapChest; // size = 0xA +// TODO: consider merging with bgCamInfo? typedef struct { - /* 0x0 */ s16 setting; - /* 0x2 */ s16 numData; - /* 0x4 */ Vec3s* data; -} CsCamData; // size = 0x8 + /* 0x0 */ s16 setting; // camera setting described by CameraSettingType enum + /* 0x2 */ s16 count; + /* 0x4 */ Vec3s* actorCsCamFuncData; // s16 data grouped in threes +} ActorCsCamInfo; // size = 0x8 -typedef CsCamData CsCameraEntry; // TODO: Remove once ZAPD updates its structs +typedef ActorCsCamInfo CsCameraEntry; // TODO: Remove once ZAPD updates its structs typedef union { /* Command: N/A */ SCmdBase base; /* Command: 0x00 */ SCmdSpawnList spawnList; /* Command: 0x01 */ SCmdActorList actorList; - /* Command: 0x02 */ SCmdCsCameraList csCameraList; + /* Command: 0x02 */ SCmdCsCameraList actorCsCamList; /* Command: 0x03 */ SCmdColHeader colHeader; /* Command: 0x04 */ SCmdRoomList roomList; /* Command: 0x05 */ SCmdWindSettings windSettings; @@ -647,7 +648,128 @@ typedef enum { /* 0x6F */ SCENE_CLOCKTOWER, /* 0x70 */ SCENE_ALLEY, /* 0x71 */ SCENE_MAX -} SceneID; +} SceneId; + +typedef enum { + /* 0x00 */ ENTR_SCENE_MAYORS_RESIDENCE, + /* 0x01 */ ENTR_SCENE_MAJORAS_LAIR, + /* 0x02 */ ENTR_SCENE_MAGIC_HAGS_POTION_SHOP, + /* 0x03 */ ENTR_SCENE_RANCH_HOUSE, + /* 0x04 */ ENTR_SCENE_HONEY_AND_DARLINGS_SHOP, + /* 0x05 */ ENTR_SCENE_BENEATH_THE_GRAVERYARD, + /* 0x06 */ ENTR_SCENE_SOUTHERN_SWAMP_CLEARED, + /* 0x07 */ ENTR_SCENE_CURIOSITY_SHOP, + /* 0x08 */ ENTR_SCENE_UNSET_08, + /* 0x09 */ ENTR_SCENE_UNSET_09, + /* 0x0A */ ENTR_SCENE_GROTTOS, + /* 0x0B */ ENTR_SCENE_UNSET_0B, + /* 0x0C */ ENTR_SCENE_UNSET_0C, + /* 0x0D */ ENTR_SCENE_UNSET_0D, + /* 0x0E */ ENTR_SCENE_CUTSCENE, + /* 0x0F */ ENTR_SCENE_UNSET_0F, + /* 0x10 */ ENTR_SCENE_IKANA_CANYON, + /* 0x11 */ ENTR_SCENE_PIRATES_FORTRESS, + /* 0x12 */ ENTR_SCENE_MILK_BAR, + /* 0x13 */ ENTR_SCENE_STONE_TOWER_TEMPLE, + /* 0x14 */ ENTR_SCENE_TREASURE_CHEST_SHOP, + /* 0x15 */ ENTR_SCENE_STONE_TOWER_TEMPLE_INVERTED, + /* 0x16 */ ENTR_SCENE_CLOCK_TOWER_ROOFTOP, + /* 0x17 */ ENTR_SCENE_OPENING_DUNGEON, + /* 0x18 */ ENTR_SCENE_WOODFALL_TEMPLE, + /* 0x19 */ ENTR_SCENE_PATH_TO_MOUNTAIN_VILLAGE, + /* 0x1A */ ENTR_SCENE_IKANA_CASTLE, + /* 0x1B */ ENTR_SCENE_DEKU_SCRUB_PLAYGROUND, + /* 0x1C */ ENTR_SCENE_ODOLWAS_LAIR, + /* 0x1D */ ENTR_SCENE_TOWN_SHOOTING_GALLERY, + /* 0x1E */ ENTR_SCENE_SNOWHEAD_TEMPLE, + /* 0x1F */ ENTR_SCENE_MILK_ROAD, + /* 0x20 */ ENTR_SCENE_PIRATES_FORTRESS_INTERIOR, + /* 0x21 */ ENTR_SCENE_SWAMP_SHOOTING_GALLERY, + /* 0x22 */ ENTR_SCENE_PINNACLE_ROCK, + /* 0x23 */ ENTR_SCENE_FAIRY_FOUNTAIN, + /* 0x24 */ ENTR_SCENE_SWAMP_SPIDER_HOUSE, + /* 0x25 */ ENTR_SCENE_OCEANSIDE_SPIDER_HOUSE, + /* 0x26 */ ENTR_SCENE_ASTRAL_OBSERVATORY, + /* 0x27 */ ENTR_SCENE_MOON_DEKU_TRIAL, + /* 0x28 */ ENTR_SCENE_DEKU_PALACE, + /* 0x29 */ ENTR_SCENE_MOUNTAIN_SMITHY, + /* 0x2A */ ENTR_SCENE_TERMINA_FIELD, + /* 0x2B */ ENTR_SCENE_POST_OFFICE, + /* 0x2C */ ENTR_SCENE_MARINE_RESEARCH_LAB, + /* 0x2D */ ENTR_SCENE_DAMPES_HOUSE, + /* 0x2E */ ENTR_SCENE_UNSET_2E, + /* 0x2F */ ENTR_SCENE_GORON_SHRINE, + /* 0x30 */ ENTR_SCENE_ZORA_HALL, + /* 0x31 */ ENTR_SCENE_TRADING_POST, + /* 0x32 */ ENTR_SCENE_ROMANI_RANCH, + /* 0x33 */ ENTR_SCENE_TWINMOLDS_LAIR, + /* 0x34 */ ENTR_SCENE_GREAT_BAY_COAST, + /* 0x35 */ ENTR_SCENE_ZORA_CAPE, + /* 0x36 */ ENTR_SCENE_LOTTERY_SHOP, + /* 0x37 */ ENTR_SCENE_UNSET_37, + /* 0x38 */ ENTR_SCENE_PIRATES_FORTRESS_EXTERIOR, + /* 0x39 */ ENTR_SCENE_FISHERMANS_HUT, + /* 0x3A */ ENTR_SCENE_GORON_SHOP, + /* 0x3B */ ENTR_SCENE_DEKU_KINGS_CHAMBER, + /* 0x3C */ ENTR_SCENE_MOON_GORON_TRIAL, + /* 0x3D */ ENTR_SCENE_ROAD_TO_SOUTHERN_SWAMP, + /* 0x3E */ ENTR_SCENE_DOGGY_RACETRACK, + /* 0x3F */ ENTR_SCENE_CUCCO_SHACK, + /* 0x40 */ ENTR_SCENE_IKANA_GRAVEYARD, + /* 0x41 */ ENTR_SCENE_GOHTS_LAIR, + /* 0x42 */ ENTR_SCENE_SOUTHERN_SWAMP_POISONED, + /* 0x43 */ ENTR_SCENE_WOODFALL, + /* 0x44 */ ENTR_SCENE_MOON_ZORA_TRIAL, + /* 0x45 */ ENTR_SCENE_GORON_VILLAGE_SPRING, + /* 0x46 */ ENTR_SCENE_GREAT_BAY_TEMPLE, + /* 0x47 */ ENTR_SCENE_WATERFALL_RAPIDS, + /* 0x48 */ ENTR_SCENE_BENEATH_THE_WELL, + /* 0x49 */ ENTR_SCENE_ZORA_HALL_ROOMS, + /* 0x4A */ ENTR_SCENE_GORON_VILLAGE_WINTER, + /* 0x4B */ ENTR_SCENE_GORON_GRAVERYARD, + /* 0x4C */ ENTR_SCENE_SAKONS_HIDEOUT, + /* 0x4D */ ENTR_SCENE_MOUNTAIN_VILLAGE_WINTER, + /* 0x4E */ ENTR_SCENE_GHOST_HUT, + /* 0x4F */ ENTR_SCENE_DEKU_SHRINE, + /* 0x50 */ ENTR_SCENE_ROAD_TO_IKANA, + /* 0x51 */ ENTR_SCENE_SWORDMANS_SCHOOL, + /* 0x52 */ ENTR_SCENE_MUSIC_BOX_HOUSE, + /* 0x53 */ ENTR_SCENE_IGOS_DU_IKANAS_LAIR, + /* 0x54 */ ENTR_SCENE_TOURIST_INFORMATION, + /* 0x55 */ ENTR_SCENE_STONE_TOWER, + /* 0x56 */ ENTR_SCENE_STONE_TOWER_INVERTED, + /* 0x57 */ ENTR_SCENE_MOUNTAIN_VILLAGE_SPRING, + /* 0x58 */ ENTR_SCENE_PATH_TO_SNOWHEAD, + /* 0x59 */ ENTR_SCENE_SNOWHEAD, + /* 0x5A */ ENTR_SCENE_PATH_TO_GORON_VILLAGE_WINTER, + /* 0x5B */ ENTR_SCENE_PATH_TO_GORON_VILLAGE_SPRING, + /* 0x5C */ ENTR_SCENE_GYORGS_LAIR, + /* 0x5D */ ENTR_SCENE_SECRET_SHRINE, + /* 0x5E */ ENTR_SCENE_STOCK_POT_INN, + /* 0x5F */ ENTR_SCENE_GREAT_BAY_CUTSCENE, + /* 0x60 */ ENTR_SCENE_CLOCK_TOWER_INTERIOR, + /* 0x61 */ ENTR_SCENE_WOODS_OF_MYSTERY, + /* 0x62 */ ENTR_SCENE_LOST_WOODS, + /* 0x63 */ ENTR_SCENE_MOON_LINK_TRIAL, + /* 0x64 */ ENTR_SCENE_THE_MOON, + /* 0x65 */ ENTR_SCENE_BOMB_SHOP, + /* 0x66 */ ENTR_SCENE_GIANTS_CHAMBER, + /* 0x67 */ ENTR_SCENE_GORMAN_TRACK, + /* 0x68 */ ENTR_SCENE_GORON_RACETRACK, + /* 0x69 */ ENTR_SCENE_EAST_CLOCK_TOWN, + /* 0x6A */ ENTR_SCENE_WEST_CLOCK_TOWN, + /* 0x6B */ ENTR_SCENE_NORTH_CLOCK_TOWN, + /* 0x6C */ ENTR_SCENE_SOUTH_CLOCK_TOWN, + /* 0x6D */ ENTR_SCENE_LAUNDRY_POOL, + /* 0x6E */ ENTR_SCENE_MAX +} EntranceSceneId; + +/* +* 0xFE00: Index into sSceneEntranceTable (Scene) +* 0x01F0: Index into the scenes specific entrance table (Spawn) +* 0x000F: Index into the specific entrance table (Layer), stored seperately in sceneSetupIndex +*/ +#define ENTRANCE(scene, spawn) ((((ENTR_SCENE_##scene) & 0x7F) << 9) | (((spawn) & 0x1F) << 4)) // SceneTableEntry draw configs typedef enum { diff --git a/include/z64schedule.h b/include/z64schedule.h new file mode 100644 index 000000000..cff6224f4 --- /dev/null +++ b/include/z64schedule.h @@ -0,0 +1,256 @@ +#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 run, returning the result in a + * struct. The returned result can be a value or a encoded time value. + * + * The scripts contain 2 kinds of instructions: + * - Checks with branches (relative offsets, either 1-byte offsets (short, *_S), + * or 2-byte offsets (long, *_L)) + * - Returns + * + * Scripts are stored as u8[]. They are built using the macros are the bottom of + * this file. The scheduledis.py script can be used to convert any scripts in + * actor data into the macros. + */ + +/** + * Actors that use this system generally create 3 functions to interact with it. + * + * - FollowSchedule: The action function an actor sets to follow the schedule. + * - ProcessScheduleOutput: Holds the logic of processing the output received by running the schedule script, called by FollowSchedule + * - HandleSchedule: Holds the actual logic of how to actually follow the schedule based on the processed output, called by FollowSchedule + */ + +// Macro to convert the time format used in the save struct into the format used in Schedule +#define SCHEDULE_CONVERT_TIME(time) ((time) - 0x10000 / 360 * 90) +#define SCHEDULE_TIME_NOW SCHEDULE_CONVERT_TIME(gSaveContext.save.time) + +typedef enum { + /* 0x00 */ SCHEDULE_CMD_ID_CHECK_FLAG_S, // Checks if a weekEventReg flag is set and branches if so, short range branch + /* 0x01 */ SCHEDULE_CMD_ID_CHECK_FLAG_L, // Checks if a weekEventReg flag is set and branches if so, long range branch + /* 0x02 */ 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 + /* 0x03 */ 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 + /* 0x04 */ 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) + /* 0x05 */ SCHEDULE_CMD_ID_RET_NONE, // Ends script without returning anything + /* 0x06 */ SCHEDULE_CMD_ID_RET_EMPTY, // Ends script and indicates return without changing existing value + /* 0x07 */ SCHEDULE_CMD_ID_NOP, // No-Op + /* 0x08 */ SCHEDULE_CMD_ID_CHECK_MISC_S, // Special check based on items or masks and branches if check passes, short range branch + /* 0x09 */ SCHEDULE_CMD_ID_RET_VAL_S, // Ends script and returns byte value + /* 0x0A */ SCHEDULE_CMD_ID_CHECK_NOT_IN_SCENE_S, // Checks if the current scene is not SceneNum and branches if so, short range branch + /* 0x0B */ SCHEDULE_CMD_ID_CHECK_NOT_IN_SCENE_L, // Checks if the current scene is not SceneNum and branches if so, long range branch + /* 0x0C */ SCHEDULE_CMD_ID_CHECK_NOT_IN_DAY_S, // Checks if the current day is not Day and branches if so, short range branch + /* 0x0D */ SCHEDULE_CMD_ID_CHECK_NOT_IN_DAY_L, // Checks if the current day is not Day and branches if so, long range branch + /* 0x0E */ SCHEDULE_CMD_ID_RET_TIME, // Returns 2 time values + /* 0x0F */ SCHEDULE_CMD_ID_CHECK_BEFORE_TIME_S, // Branches if the current time is less than the command time, short range branch + /* 0x10 */ SCHEDULE_CMD_ID_CHECK_BEFORE_TIME_L, // Branches if the current time is less than the command time, long range branch + /* 0x11 */ SCHEDULE_CMD_ID_BRANCH_S, // Always branch, short range branch + /* 0x12 */ 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; +} ScheduleOutput; // 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 index adb2f9b0f..360e265e6 100644 --- a/include/z64skin.h +++ b/include/z64skin.h @@ -5,7 +5,7 @@ struct GraphicsContext; struct GameState; -struct GlobalContext; +struct PlayState; /** * Holds a compact version of a vertex used in the Skin system (doesn't has the x, y, z positions or the flag member) @@ -33,18 +33,18 @@ typedef struct { } 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; + /* 0x0 */ u16 vtxCount; // number of vertices in this modif entry + /* 0x2 */ u16 transformCount; + /* 0x4 */ u16 unk_04; // index of limbTransformations + /* 0x8 */ SkinVertex* skinVertices; + /* 0xC */ 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; + /* 0x0 */ u16 totalVtxCount; // total vertex count for all modif entries + /* 0x2 */ u16 limbModifCount; // count of limbModifCount + /* 0x4 */ SkinLimbModif* limbModifications; + /* 0x8 */ Gfx* dlist; } SkinAnimatedLimbData; // size = 0xC // ZAPD compatibility typedefs @@ -58,11 +58,11 @@ typedef SkinLimbModif Struct_800A598C; #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 + /* 0x0 */ Vec3s jointPos; // Root is position in model space, children are relative to parent + /* 0x6 */ u8 child; + /* 0x7 */ u8 sibling; + /* 0x8 */ s32 segmentType; // Type of data contained in segment + /* 0xC */ 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 { @@ -71,15 +71,15 @@ typedef struct { } 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; + /* 0x00 */ SkeletonHeader* skeletonHeader; + /* 0x04 */ MtxF mtx; + /* 0x44 */ s32 limbCount; + /* 0x48 */ SkinLimbVtx* vtxTable; // double buffered list of vertices for each limb + /* 0x4C */ SkelAnime skelAnime; } Skin; // size = 0x90 -typedef void (*SkinPostDraw)(struct Actor*, struct GlobalContext*, Skin*); -typedef s32 (*SkinOverrideLimbDraw)(struct Actor*, struct GlobalContext*, s32, Skin*); +typedef void (*SkinPostDraw)(struct Actor* thisx, struct PlayState* play, Skin* skin); +typedef s32 (*SkinOverrideLimbDraw)(struct Actor* thisx, struct PlayState* play, s32 limbIndex, Skin* skin); #define SKIN_DRAW_FLAG_CUSTOM_TRANSFORMS (1 << 0) #define SKIN_DRAW_FLAG_CUSTOM_MATRIX (1 << 1) @@ -89,10 +89,10 @@ void Skin_UpdateVertices(MtxF* mtx, SkinVertex* skinVertices, SkinLimbModif* mod 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 func_80138228(Actor* actor, struct PlayState* play, Skin* skin, SkinPostDraw postDraw, s32 setTranslation); +void func_80138258(Actor* actor, struct PlayState* play, Skin* skin, SkinPostDraw postDraw, SkinOverrideLimbDraw overrideLimbDraw, s32 setTranslation); +void func_8013828C(Actor* actor, struct PlayState* play, Skin* skin, SkinPostDraw postDraw, SkinOverrideLimbDraw overrideLimbDraw, s32 setTranslation, s32 arg6); +void func_801382C4(Actor* actor, struct PlayState* play, 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); diff --git a/include/z64snap.h b/include/z64snap.h new file mode 100644 index 000000000..fb3f86186 --- /dev/null +++ b/include/z64snap.h @@ -0,0 +1,52 @@ +#ifndef Z64_SNAP_H +#define Z64_SNAP_H + +#include "PR/ultratypes.h" +#include "z64actor.h" + +typedef s32 (*PictoValidationFunc)(struct PlayState*, Actor*); + +typedef struct { + /* 0x000 */ Actor actor; + /* 0x144 */ PictoValidationFunc validationFunc; +} PictoActor; + +// Picto box flags + +typedef enum { + // Used externally, set and read by actors + /* 0x00 */ PICTOGRAPH_0, + /* 0x01 */ PICTOGRAPH_IN_SWAMP, + /* 0x02 */ PICTOGRAPH_MONKEY, + /* 0x03 */ PICTOGRAPH_BIG_OCTO, + /* 0x04 */ PICTOGRAPH_LULU_HEAD, + /* 0x05 */ PICTOGRAPH_LULU_RIGHT_ARM, + /* 0x06 */ PICTOGRAPH_LULU_LEFT_ARM, // Need all three of these to qualify as a good picture + /* 0x07 */ PICTOGRAPH_SCARECROW, + /* 0x08 */ PICTOGRAPH_TINGLE, + /* 0x09 */ PICTOGRAPH_PIRATE_GOOD, + /* 0x0A */ PICTOGRAPH_DEKU_KING, + /* 0x0B */ PICTOGRAPH_PIRATE_TOO_FAR, // overlaps with PICTOGRAPH_PIRATE_GOOD, but that is checked first + + // Used internally, test for failures of position, angle etc. + /* 0x3B */ PICTOGRAPH_BEHIND_COLLISION = 0x3B, + /* 0x3C */ PICTOGRAPH_BEHIND_BG, + /* 0x3D */ PICTOGRAPH_NOT_IN_VIEW, + /* 0x3E */ PICTOGRAPH_BAD_ANGLE, + /* 0x3F */ PICTOGRAPH_BAD_DISTANCE +} PictographFlag; + +// The following macros are subject to renaming once the capture system is better understood +#define PICTO_RESOLUTION_HORIZONTAL 150 +#define PICTO_RESOLUTION_VERTICAL 105 +#define PICTO_CAPTURE_REGION_TOPLEFT_X ((SCREEN_WIDTH - PICTO_RESOLUTION_HORIZONTAL) / 2) +#define PICTO_CAPTURE_REGION_TOPLEFT_Y ((SCREEN_HEIGHT - PICTO_RESOLUTION_VERTICAL) / 2) + +s32 Snap_RecordPictographedActors(PlayState* play); +void Snap_SetFlag(s32 flag); +void Snap_UnsetFlag(s32 flag); +u32 Snap_CheckFlag(s32 flag); +s16 Snap_AbsS(s16 val); +s32 Snap_ValidatePictograph(PlayState* play, Actor* actor, s32 flag, Vec3f* pos, Vec3s* rot, f32 distanceMin, f32 distanceMax, s16 angleRange); + +#endif diff --git a/include/z64subs.h b/include/z64subs.h index ca69e72cb..9f0b5fea3 100644 --- a/include/z64subs.h +++ b/include/z64subs.h @@ -4,15 +4,40 @@ #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; -typedef s32 (*func_8013E748_arg6)(struct GlobalContext*, Actor*, void*); +//! @TODO: rename based on func_8013E748 and func_800B8500 +typedef s32 (*func_8013E748_VerifyFunc)(struct PlayState*, Actor*, void*); -typedef s32 (*VerifyActor)(struct GlobalContext*, Actor*, Actor*, void*); +typedef s32 (*VerifyActor)(struct PlayState*, 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) @@ -30,8 +55,8 @@ typedef s32 (*VerifyActor)(struct GlobalContext*, Actor*, Actor*, void*); (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 void (*ActorPathingComputeFunc)(struct PlayState*, struct ActorPathing*); +typedef s32 (*ActorPathingUpdateFunc)(struct PlayState*, struct ActorPathing*); typedef struct ActorPathing { /* 0x00 */ Path* setupPathList; @@ -57,4 +82,89 @@ typedef struct ActorPathing { /* 0x68 */ ActorPathingUpdateFunc setNextPointFunc; // Return true if should compute and update again } ActorPathing; // size = 0x6C +struct EnDoor* SubS_FindDoor(struct PlayState* play, s32 switchFlag); + +Gfx* SubS_DrawTransformFlexLimb(struct PlayState* play, s32 limbIndex, void** skeleton, Vec3s* jointTable, OverrideLimbDraw overrideLimbDraw, PostLimbDraw postLimbDraw, TransformLimbDraw transformLimbDraw, Actor* actor, Mtx** mtx, Gfx* gfx); +Gfx* SubS_DrawTransformFlex(struct PlayState* play, void** skeleton, Vec3s* jointTable, s32 dListCount, OverrideLimbDraw overrideLimbDraw, PostLimbDraw postLimbDraw, TransformLimbDraw transformLimbDraw, Actor* actor, Gfx* gfx); + +s32 SubS_InCsMode(struct PlayState* play); + +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 PlayState* play, Path* path, s32 waypoint, Vec3f* targetPos); + +Path* SubS_GetAdditionalPath(struct PlayState* play, u8 pathIndex, s32 max); + +Actor* SubS_FindNearestActor(Actor* actor, struct PlayState* play, u8 actorCategory, s16 actorId); + +s32 SubS_ChangeAnimationByInfoS(SkelAnime* skelAnime, AnimationInfoS* animationInfo, s32 animIndex); + +s32 SubS_HasReachedPoint(Actor* actor, Path* path, s32 pointIndex); + +Path* SubS_GetDayDependentPath(struct PlayState* play, 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 PlayState* play, 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* trackTarget, Vec3s* headRot, Vec3s* torsoRot, TrackOptionsSet* options); + +s32 SubS_AngleDiffLessEqual(s16 angleA, s16 threshold, s16 angleB); + +Path* SubS_GetPathByIndex(struct PlayState* play, 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 PlayState* play); +s8 SubS_GetObjectIndex(s16 id, struct PlayState* play); + +Actor* SubS_FindActor(struct PlayState* play, Actor* actorListStart, u8 actorCategory, s16 actorId); + +s32 SubS_FillLimbRotTables(struct PlayState* play, s16* limbRotTableY, s16* limbRotTableZ, s32 numLimbs); + +s32 SubS_IsFloorAbove(struct PlayState* play, 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 PlayState* play, Vec3f* worldPos, Actor* actor, ActorPathing* actorPath, Path* paths, s32 pathIndex, s32 begPointIndex, s32 endPointIndex, s32 curPointIndex, u8 flags); +s32 SubS_ActorPathing_Update(struct PlayState* play, ActorPathing* actorPath, ActorPathingComputeFunc computePointInfoFunc, ActorPathingUpdateFunc updateActorInfoFunc, ActorPathingUpdateFunc moveFunc, ActorPathingUpdateFunc setNextPointFunc); +void SubS_ActorPathing_ComputePointInfo(struct PlayState* play, ActorPathing* actorPath); +s32 SubS_ActorPathing_MoveWithGravity(struct PlayState* play, ActorPathing* actorPath); +s32 SubS_ActorPathing_MoveWithoutGravityReverse(struct PlayState* play, ActorPathing* actorPath); +s32 SubS_ActorPathing_SetNextPoint(struct PlayState* play, ActorPathing* actorPath); + +void SubS_ChangeAnimationBySpeedInfo(SkelAnime* skelAnime, AnimationSpeedInfo* animationInfo, s32 nextAnimIndex, s32* curAnimIndex); + +s32 SubS_StartActorCutscene(Actor* actor, s16 nextCutscene, s16 curCutscene, s32 type); +s32 SubS_FillCutscenesList(Actor* actor, s16 cutscenes[], s16 numCutscenes); + +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 PlayState* play, Actor* actor, Actor* actorListStart, u8 actorCategory, s16 actorId, void* verifyData, VerifyActor verifyActor); + +s32 func_8013E748(Actor* actor, struct PlayState* play, f32 xzRange, f32 yRange, s32 exchangeItemId, void* data, func_8013E748_VerifyFunc verifyFunc); +s32 SubS_ActorAndPlayerFaceEachOther(struct PlayState* play, Actor* actor, void* data); +s32 func_8013E8F8(Actor* actor, struct PlayState* play, 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/z64transition.h b/include/z64transition.h index 998dd9198..9630b4a3f 100644 --- a/include/z64transition.h +++ b/include/z64transition.h @@ -13,16 +13,16 @@ typedef struct { /* 0x18 */ void (*setColor)(void* transition, u32 color); /* 0x1C */ void (*setEnvColor)(void* transition, u32 color); /* 0x20 */ s32 (*isDone)(void* transition); -} TransitionInit; +} TransitionInit; // size = 0x24 typedef struct { - /* 0x000 */ char unk_0[0xC]; + /* 0x0 */ char unk_0[0xC]; } TransitionFade; // size = 0xC extern const TransitionInit TransitionFade_InitVars; typedef struct { - /* 0x000 */ char unk_0[0x20]; + /* 0x00 */ char unk_0[0x20]; } TransitionCircle; // size = 0x20 extern const TransitionInit TransitionCircle_InitVars; diff --git a/include/z64view.h b/include/z64view.h new file mode 100644 index 000000000..98ca1ab19 --- /dev/null +++ b/include/z64view.h @@ -0,0 +1,57 @@ +#ifndef Z64VIEW_H +#define Z64VIEW_H + +#include "PR/ultratypes.h" +#include "PR/gbi.h" +#include "z64math.h" +#include "unk.h" + +struct GraphicsContext; + +typedef struct Viewport { + /* 0x00 */ s32 topY; // uly (upper left y) + /* 0x04 */ s32 bottomY; // lry (lower right y) + /* 0x08 */ s32 leftX; // ulx (upper left x) + /* 0x0C */ s32 rightX; // lrx (lower right x) +} Viewport; // size = 0x10 + +typedef struct View { + /* 0x000 */ u32 magic; // string literal "VIEW" / 0x56494557 + /* 0x004 */ struct GraphicsContext* gfxCtx; + /* 0x008 */ Viewport viewport; + /* 0x018 */ f32 fovy; // vertical field of view in degrees + /* 0x01C */ f32 zNear; // distance to near clipping plane + /* 0x020 */ f32 zFar; // distance to far clipping plane + /* 0x024 */ f32 scale; // scale for matrix elements + /* 0x028 */ Vec3f eye; + /* 0x034 */ Vec3f at; + /* 0x040 */ Vec3f up; + /* 0x04C */ UNK_TYPE1 pad4C[0x4]; + /* 0x050 */ Vp vp; + /* 0x060 */ Mtx projection; + /* 0x0A0 */ Mtx viewing; + /* 0x0E0 */ Mtx unkE0; + /* 0x120 */ Mtx* projectionPtr; + /* 0x124 */ Mtx* viewingPtr; + /* 0x128 */ Vec3f distortionDirRot; + /* 0x134 */ Vec3f distortionScale; + /* 0x140 */ f32 distortionSpeed; + /* 0x144 */ Vec3f curDistortionDirRot; + /* 0x150 */ Vec3f curDistortionScale; + /* 0x15C */ u16 normal; // used to normalize the projection matrix + /* 0x160 */ u32 flags; // bit 3: Render to an orthographic perspective + /* 0x164 */ s32 unk164; +} View; // size = 0x168 + +#define SET_FULLSCREEN_VIEWPORT(view) \ + { \ + Viewport viewport; \ + viewport.bottomY = SCREEN_HEIGHT; \ + viewport.rightX = SCREEN_WIDTH; \ + viewport.topY = 0; \ + viewport.leftX = 0; \ + View_SetViewport(view, &viewport); \ + } \ + (void)0 + +#endif diff --git a/include/z_en_hy_code.h b/include/z_en_hy_code.h index 997a41233..d272522c9 100644 --- a/include/z_en_hy_code.h +++ b/include/z_en_hy_code.h @@ -10,36 +10,36 @@ struct EnHy; //! 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 + /* 0 */ ENHY_ANIM_AOB_0, + /* 1 */ ENHY_ANIM_BOJ_1, + /* 2 */ ENHY_ANIM_BOJ_2, + /* 3 */ ENHY_ANIM_BOJ_3, + /* 4 */ ENHY_ANIM_BOJ_4, + /* 5 */ ENHY_ANIM_BOJ_5, + /* 6 */ ENHY_ANIM_BBA_6, + /* 7 */ ENHY_ANIM_BJI_7, + /* 8 */ ENHY_ANIM_BJI_8, + /* 9 */ ENHY_ANIM_BJI_9, + /* 10 */ ENHY_ANIM_BOJ_10, + /* 11 */ ENHY_ANIM_OS_ANIME_11, + /* 12 */ ENHY_ANIM_BOJ_12, + /* 13 */ ENHY_ANIM_BOJ_13, + /* 14 */ ENHY_ANIM_BOJ_14, + /* 15 */ ENHY_ANIM_BOJ_15, + /* 16 */ ENHY_ANIM_BOJ_16, + /* 17 */ ENHY_ANIM_BOJ_17, + /* 18 */ ENHY_ANIM_BOJ_18, + /* 19 */ ENHY_ANIM_BOJ_19, + /* 20 */ ENHY_ANIM_BOJ_20, + /* 21 */ ENHY_ANIM_MAX } EnHyAnimation; -typedef void (*EnHyActionFunc)(struct EnHy*, GlobalContext*); +typedef void (*EnHyActionFunc)(struct EnHy*, PlayState*); typedef struct EnHy { /* 0x000 */ Actor actor; /* 0x144 */ EnHyActionFunc actionFunc; - /* 0x148 */ EnHyActionFunc tmpActionFunc; + /* 0x148 */ EnHyActionFunc prevActionFunc; /* 0x14C */ SkelAnime skelAnime; /* 0x190 */ s8 headObjIndex; // Limb 15 /* 0x191 */ s8 skelUpperObjIndex; // Limbs 8-14 @@ -57,12 +57,12 @@ typedef struct EnHy { /* 0x205 */ u8 isRightFootOnGround; /* 0x206 */ Vec3s jointTable[ENHY_LIMB_MAX]; /* 0x266 */ Vec3s morphTable[ENHY_LIMB_MAX]; - /* 0x2C6 */ Vec3s focusTarget; + /* 0x2C6 */ Vec3s trackTarget; /* 0x2CC */ Vec3s headRot; /* 0x2D2 */ Vec3s torsoRot; - /* 0x2D8 */ Vec3s tmpFocusTarget; - /* 0x2DE */ Vec3s tmpHeadRot; - /* 0x2E4 */ Vec3s tmpTorsoRot; + /* 0x2D8 */ Vec3s prevTrackTarget; + /* 0x2DE */ Vec3s prevHeadRot; + /* 0x2E4 */ Vec3s prevTorsoRot; /* 0x2EA */ s16 limbRotTableY[16]; /* 0x30A */ s16 limbRotTableZ[16]; /* 0x32C */ Vec3f bodyPartsPos[15]; @@ -72,23 +72,23 @@ typedef struct EnHy { } EnHy; // size = 0x3EC extern s8 gEnHyBodyParts[]; -extern s8 gEnHyBodyPartsIndex[]; -extern u8 gEnHyShadowSize[]; +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); +EnDoor* EnHy_FindNearestDoor(Actor* actor, PlayState* play); +void EnHy_ChangeObjectAndAnim(EnHy* enHy, PlayState* play, s16 animIndex); +s32 EnHy_UpdateSkelAnime(EnHy* enHy, PlayState* play); 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_Init(EnHy* enHy, PlayState* play, FlexSkeletonHeader* skeletonHeaderSeg, s16 animIndex); +void func_800F0BB4(EnHy* enHy, PlayState* play, EnDoor* door, s16 arg3, s16 arg4); +s32 func_800F0CE4(EnHy* enHy, PlayState* play, ActorFunc draw, s16 arg3, s16 arg4, f32 arg5); +s32 func_800F0DD4(EnHy* enHy, PlayState* play, s16 arg2, s16 arg3); +s32 EnHy_SetPointFowards(EnHy* enHy, PlayState* play, f32 gravity, s16 animIndex); +s32 EnHy_SetPointBackwards(EnHy* enHy, PlayState* play, 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); +void EnHy_UpdateCollider(EnHy* enHy, PlayState* play); +s32 EnHy_PlayWalkingSound(EnHy* enHy, PlayState* play, f32 distAboveThreshold); #endif // Z_EN_HY_CODE_H diff --git a/requirements.txt b/requirements.txt index d76027c1c..d410bc853 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,7 +1,12 @@ +# Setup libyaz0>=0.5 -pyelftools>=0.26 colorama>=0.4.3 -ansiwrap>=0.8.4 -attrs>=18.2.0 + +# disasm +rabbitizer>=1.0.0,<2.0.0 + +# diff watchdog>=0.10.2 -GitPython>=3.1.14 +argcomplete +python-Levenshtein +cxxfilt diff --git a/spec b/spec index 115bce29e..fe3d2f006 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" @@ -376,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,7 +461,6 @@ beginseg include "build/data/code/z_debug_mode.bss.o" include "build/src/code/z_demo.o" include "build/src/code/z_draw.o" - include "build/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" @@ -492,7 +492,6 @@ beginseg include "build/data/code/z_map_disp.bss.o" include "build/src/code/z_map_data.o" include "build/src/code/z_map_exp.o" - include "build/data/code/z_map_exp.data.o" include "build/src/code/z_msgevent.o" include "build/data/code/z_msgevent.data.o" include "build/src/code/z_nmi_buff.o" @@ -500,8 +499,6 @@ beginseg include "build/src/code/z_olib.o" pad_text include "build/src/code/z_parameter.o" - include "build/data/code/z_parameter.data.o" - include "build/data/code/z_parameter.bss.o" include "build/src/code/z_path.o" include "build/src/code/z_pause.o" include "build/src/code/z_player_lib.o" @@ -520,8 +517,7 @@ 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/src/code/z_skin_awb.o" @@ -529,8 +525,7 @@ beginseg include "build/src/code/z_snap.o" include "build/src/code/z_sub_s.o" include "build/data/code/code_801DE890.rodata.o" - include "build/src/code/code_8013EC10.o" - include "build/data/code/code_8013EC10.bss.o" + include "build/src/code/z_rumble.o" include "build/src/code/z_view.o" include "build/src/code/z_vimode.o" include "build/data/code/z_vimode.data.o" @@ -597,11 +592,9 @@ 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" + include "build/src/code/sys_rumble.o" + include "build/data/code/code_801D1E80.data.o" include "build/src/code/code_80183070.o" include "build/src/code/c_keyframe.o" include "build/src/code/sys_slowly.o" @@ -621,12 +614,10 @@ beginseg include "build/src/code/audio/code_80192BE0.o" include "build/data/code/code_80192BE0.data.o" include "build/src/code/audio/audio_dcache.o" - include "build/src/code/audio/code_80194790.o" - include "build/data/code/code_80194790.data.o" + include "build/src/code/audio/aisetnextbuf.o" include "build/src/code/audio/audio_playback.o" include "build/src/code/audio/audio_effects.o" include "build/src/code/audio/audio_seqplayer.o" - include "build/data/code/audio_seqplayer.data.o" include "build/data/code/audio_dramStack.data.o" include "build/asm/code/code_8019AE40.text.o" // handwritten pad_text @@ -640,15 +631,13 @@ beginseg pad_text include "build/src/code/audio/audio_sfx_params.o" include "build/src/code/audio/code_801A5BD0.o" - include "build/data/code/code_801A5BD0.data.o" - include "build/data/code/code_801A5BD0.bss.o" include "build/src/code/audio/code_801A7B10.o" include "build/data/code/code_801A7B10.data.o" include "build/data/code/code_801A7B10.bss.o" include "build/src/code/audio/audio_init_params.o" include "build/src/code/jpegutils.o" include "build/src/code/jpegdecoder.o" - include_readonly "build/src/code/z_game_over.o" + include_data_with_rodata "build/src/code/z_game_over.o" include "build/src/code/z_construct.o" include "build/data/code/audio_tables.rodata.o" include "build/data/code/aspMain.rodata.o" @@ -715,7 +704,6 @@ beginseg include "build/src/overlays/kaleido_scope/ovl_kaleido_scope/z_kaleido_map.o" include "build/src/overlays/kaleido_scope/ovl_kaleido_scope/z_kaleido_mask.o" include "build/src/overlays/kaleido_scope/ovl_kaleido_scope/z_kaleido_scope_NES.o" - include "build/data/ovl_kaleido_scope/ovl_kaleido_scope.data.o" include "build/data/ovl_kaleido_scope/ovl_kaleido_scope.bss.o" include "build/data/ovl_kaleido_scope/ovl_kaleido_scope.reloc.o" endseg @@ -747,8 +735,7 @@ beginseg name "ovl_En_Part" compress include "build/src/overlays/actors/ovl_En_Part/z_en_part.o" - include "build/data/ovl_En_Part/ovl_En_Part.data.o" - include "build/data/ovl_En_Part/ovl_En_Part.reloc.o" + include "build/src/overlays/actors/ovl_En_Part/ovl_En_Part_reloc.o" endseg beginseg @@ -769,8 +756,7 @@ 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 @@ -820,22 +806,14 @@ beginseg name "ovl_En_Horse" compress include "build/src/overlays/actors/ovl_En_Horse/z_en_horse.o" -#ifdef NON_MATCHING include "build/src/overlays/actors/ovl_En_Horse/ovl_En_Horse_reloc.o" -#else - include "build/data/ovl_En_Horse/ovl_En_Horse.reloc.o" -#endif endseg beginseg name "ovl_En_Arrow" compress include "build/src/overlays/actors/ovl_En_Arrow/z_en_arrow.o" -#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 @@ -884,8 +862,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 @@ -899,9 +876,7 @@ beginseg name "ovl_En_Viewer" compress include "build/src/overlays/actors/ovl_En_Viewer/z_en_viewer.o" - include "build/data/ovl_En_Viewer/ovl_En_Viewer.data.o" - include "build/data/ovl_En_Viewer/ovl_En_Viewer.bss.o" - include "build/data/ovl_En_Viewer/ovl_En_Viewer.reloc.o" + include "build/src/overlays/actors/ovl_En_Viewer/ovl_En_Viewer_reloc.o" endseg beginseg @@ -923,8 +898,7 @@ 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 @@ -973,8 +947,7 @@ 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 @@ -1025,11 +998,7 @@ 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 @@ -1057,8 +1026,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 @@ -1117,8 +1085,7 @@ 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 @@ -1146,8 +1113,7 @@ beginseg name "ovl_Bg_F40_Flift" compress include "build/src/overlays/actors/ovl_Bg_F40_Flift/z_bg_f40_flift.o" - include "build/data/ovl_Bg_F40_Flift/ovl_Bg_F40_Flift.data.o" - include "build/data/ovl_Bg_F40_Flift/ovl_Bg_F40_Flift.reloc.o" + include "build/src/overlays/actors/ovl_Bg_F40_Flift/ovl_Bg_F40_Flift_reloc.o" endseg beginseg @@ -1183,8 +1149,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 @@ -1206,8 +1171,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 @@ -1352,8 +1316,7 @@ beginseg name "ovl_Item_Etcetera" compress include "build/src/overlays/actors/ovl_Item_Etcetera/z_item_etcetera.o" - include "build/data/ovl_Item_Etcetera/ovl_Item_Etcetera.data.o" - include "build/data/ovl_Item_Etcetera/ovl_Item_Etcetera.reloc.o" + include "build/src/overlays/actors/ovl_Item_Etcetera/ovl_Item_Etcetera_reloc.o" endseg beginseg @@ -1388,16 +1351,14 @@ beginseg name "ovl_Obj_Tsubo" compress include "build/src/overlays/actors/ovl_Obj_Tsubo/z_obj_tsubo.o" - include "build/data/ovl_Obj_Tsubo/ovl_Obj_Tsubo.data.o" - include "build/data/ovl_Obj_Tsubo/ovl_Obj_Tsubo.reloc.o" + include "build/src/overlays/actors/ovl_Obj_Tsubo/ovl_Obj_Tsubo_reloc.o" endseg beginseg name "ovl_En_Ik" compress include "build/src/overlays/actors/ovl_En_Ik/z_en_ik.o" - include "build/data/ovl_En_Ik/ovl_En_Ik.data.o" - include "build/data/ovl_En_Ik/ovl_En_Ik.reloc.o" + include "build/src/overlays/actors/ovl_En_Ik/ovl_En_Ik_reloc.o" endseg beginseg @@ -1418,8 +1379,7 @@ beginseg name "ovl_Elf_Msg" compress include "build/src/overlays/actors/ovl_Elf_Msg/z_elf_msg.o" - include "build/data/ovl_Elf_Msg/ovl_Elf_Msg.data.o" - include "build/data/ovl_Elf_Msg/ovl_Elf_Msg.reloc.o" + include "build/src/overlays/actors/ovl_Elf_Msg/ovl_Elf_Msg_reloc.o" endseg beginseg @@ -1483,35 +1443,28 @@ beginseg name "ovl_Obj_Lift" compress include "build/src/overlays/actors/ovl_Obj_Lift/z_obj_lift.o" - include "build/data/ovl_Obj_Lift/ovl_Obj_Lift.data.o" - include "build/data/ovl_Obj_Lift/ovl_Obj_Lift.reloc.o" + include "build/src/overlays/actors/ovl_Obj_Lift/ovl_Obj_Lift_reloc.o" endseg beginseg name "ovl_Obj_Hsblock" compress include "build/src/overlays/actors/ovl_Obj_Hsblock/z_obj_hsblock.o" - include "build/data/ovl_Obj_Hsblock/ovl_Obj_Hsblock.data.o" - include "build/data/ovl_Obj_Hsblock/ovl_Obj_Hsblock.reloc.o" + include "build/src/overlays/actors/ovl_Obj_Hsblock/ovl_Obj_Hsblock_reloc.o" endseg beginseg name "ovl_En_Okarina_Tag" compress include "build/src/overlays/actors/ovl_En_Okarina_Tag/z_en_okarina_tag.o" - include "build/data/ovl_En_Okarina_Tag/ovl_En_Okarina_Tag.data.o" - include "build/data/ovl_En_Okarina_Tag/ovl_En_Okarina_Tag.reloc.o" + include "build/src/overlays/actors/ovl_En_Okarina_Tag/ovl_En_Okarina_Tag_reloc.o" endseg 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 @@ -1525,8 +1478,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 @@ -1540,16 +1492,14 @@ beginseg name "ovl_En_Ge1" compress include "build/src/overlays/actors/ovl_En_Ge1/z_en_ge1.o" - include "build/data/ovl_En_Ge1/ovl_En_Ge1.data.o" - include "build/data/ovl_En_Ge1/ovl_En_Ge1.reloc.o" + include "build/src/overlays/actors/ovl_En_Ge1/ovl_En_Ge1_reloc.o" endseg 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 @@ -1716,8 +1666,7 @@ beginseg name "ovl_Elf_Msg2" compress include "build/src/overlays/actors/ovl_Elf_Msg2/z_elf_msg2.o" - include "build/data/ovl_Elf_Msg2/ovl_Elf_Msg2.data.o" - include "build/data/ovl_Elf_Msg2/ovl_Elf_Msg2.reloc.o" + include "build/src/overlays/actors/ovl_Elf_Msg2/ovl_Elf_Msg2_reloc.o" endseg beginseg @@ -1762,8 +1711,7 @@ beginseg name "ovl_Shot_Sun" compress include "build/src/overlays/actors/ovl_Shot_Sun/z_shot_sun.o" - include "build/data/ovl_Shot_Sun/ovl_Shot_Sun.data.o" - include "build/data/ovl_Shot_Sun/ovl_Shot_Sun.reloc.o" + include "build/src/overlays/actors/ovl_Shot_Sun/ovl_Shot_Sun_reloc.o" endseg beginseg @@ -1801,8 +1749,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 @@ -1825,8 +1772,7 @@ beginseg name "ovl_Effect_Ss_G_Spk" compress include "build/src/overlays/effects/ovl_Effect_Ss_G_Spk/z_eff_ss_g_spk.o" - include "build/data/ovl_Effect_Ss_G_Spk/ovl_Effect_Ss_G_Spk.data.o" - include "build/data/ovl_Effect_Ss_G_Spk/ovl_Effect_Ss_G_Spk.reloc.o" + include "build/src/overlays/effects/ovl_Effect_Ss_G_Spk/ovl_Effect_Ss_G_Spk_reloc.o" endseg beginseg @@ -1848,32 +1794,28 @@ beginseg name "ovl_Effect_Ss_G_Ripple" compress include "build/src/overlays/effects/ovl_Effect_Ss_G_Ripple/z_eff_ss_g_ripple.o" - include "build/data/ovl_Effect_Ss_G_Ripple/ovl_Effect_Ss_G_Ripple.data.o" - include "build/data/ovl_Effect_Ss_G_Ripple/ovl_Effect_Ss_G_Ripple.reloc.o" + include "build/src/overlays/effects/ovl_Effect_Ss_G_Ripple/ovl_Effect_Ss_G_Ripple_reloc.o" endseg beginseg name "ovl_Effect_Ss_G_Splash" compress include "build/src/overlays/effects/ovl_Effect_Ss_G_Splash/z_eff_ss_g_splash.o" - include "build/data/ovl_Effect_Ss_G_Splash/ovl_Effect_Ss_G_Splash.data.o" - include "build/data/ovl_Effect_Ss_G_Splash/ovl_Effect_Ss_G_Splash.reloc.o" + include "build/src/overlays/effects/ovl_Effect_Ss_G_Splash/ovl_Effect_Ss_G_Splash_reloc.o" endseg beginseg name "ovl_Effect_Ss_G_Fire" compress include "build/src/overlays/effects/ovl_Effect_Ss_G_Fire/z_eff_ss_g_fire.o" - include "build/data/ovl_Effect_Ss_G_Fire/ovl_Effect_Ss_G_Fire.data.o" - include "build/data/ovl_Effect_Ss_G_Fire/ovl_Effect_Ss_G_Fire.reloc.o" + include "build/src/overlays/effects/ovl_Effect_Ss_G_Fire/ovl_Effect_Ss_G_Fire_reloc.o" endseg beginseg 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 @@ -1888,8 +1830,7 @@ beginseg name "ovl_Effect_Ss_Hahen" compress include "build/src/overlays/effects/ovl_Effect_Ss_Hahen/z_eff_ss_hahen.o" - include "build/data/ovl_Effect_Ss_Hahen/ovl_Effect_Ss_Hahen.data.o" - include "build/data/ovl_Effect_Ss_Hahen/ovl_Effect_Ss_Hahen.reloc.o" + include "build/src/overlays/effects/ovl_Effect_Ss_Hahen/ovl_Effect_Ss_Hahen_reloc.o" endseg beginseg @@ -1910,32 +1851,28 @@ 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 name "ovl_Effect_Ss_Hitmark" compress include "build/src/overlays/effects/ovl_Effect_Ss_Hitmark/z_eff_ss_hitmark.o" - include "build/data/ovl_Effect_Ss_Hitmark/ovl_Effect_Ss_Hitmark.data.o" - include "build/data/ovl_Effect_Ss_Hitmark/ovl_Effect_Ss_Hitmark.reloc.o" + include "build/src/overlays/effects/ovl_Effect_Ss_Hitmark/ovl_Effect_Ss_Hitmark_reloc.o" endseg beginseg name "ovl_Effect_Ss_Fhg_Flash" compress include "build/src/overlays/effects/ovl_Effect_Ss_Fhg_Flash/z_eff_ss_fhg_flash.o" - include "build/data/ovl_Effect_Ss_Fhg_Flash/ovl_Effect_Ss_Fhg_Flash.data.o" - include "build/data/ovl_Effect_Ss_Fhg_Flash/ovl_Effect_Ss_Fhg_Flash.reloc.o" + include "build/src/overlays/effects/ovl_Effect_Ss_Fhg_Flash/ovl_Effect_Ss_Fhg_Flash_reloc.o" endseg 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 @@ -1957,40 +1894,35 @@ 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 name "ovl_Effect_Ss_En_Ice" compress include "build/src/overlays/effects/ovl_Effect_Ss_En_Ice/z_eff_ss_en_ice.o" - include "build/data/ovl_Effect_Ss_En_Ice/ovl_Effect_Ss_En_Ice.data.o" - include "build/data/ovl_Effect_Ss_En_Ice/ovl_Effect_Ss_En_Ice.reloc.o" + include "build/src/overlays/effects/ovl_Effect_Ss_En_Ice/ovl_Effect_Ss_En_Ice_reloc.o" endseg beginseg name "ovl_Effect_Ss_Fire_Tail" compress include "build/src/overlays/effects/ovl_Effect_Ss_Fire_Tail/z_eff_ss_fire_tail.o" - include "build/data/ovl_Effect_Ss_Fire_Tail/ovl_Effect_Ss_Fire_Tail.data.o" - include "build/data/ovl_Effect_Ss_Fire_Tail/ovl_Effect_Ss_Fire_Tail.reloc.o" + include "build/src/overlays/effects/ovl_Effect_Ss_Fire_Tail/ovl_Effect_Ss_Fire_Tail_reloc.o" endseg beginseg name "ovl_Effect_Ss_En_Fire" compress include "build/src/overlays/effects/ovl_Effect_Ss_En_Fire/z_eff_ss_en_fire.o" - include "build/data/ovl_Effect_Ss_En_Fire/ovl_Effect_Ss_En_Fire.data.o" - include "build/data/ovl_Effect_Ss_En_Fire/ovl_Effect_Ss_En_Fire.reloc.o" + include "build/src/overlays/effects/ovl_Effect_Ss_En_Fire/ovl_Effect_Ss_En_Fire_reloc.o" endseg 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 @@ -2005,8 +1937,7 @@ beginseg name "ovl_Effect_Ss_Dead_Dd" compress include "build/src/overlays/effects/ovl_Effect_Ss_Dead_Dd/z_eff_ss_dead_dd.o" - include "build/data/ovl_Effect_Ss_Dead_Dd/ovl_Effect_Ss_Dead_Dd.data.o" - include "build/data/ovl_Effect_Ss_Dead_Dd/ovl_Effect_Ss_Dead_Dd.reloc.o" + include "build/src/overlays/effects/ovl_Effect_Ss_Dead_Dd/ovl_Effect_Ss_Dead_Dd_reloc.o" endseg beginseg @@ -2029,8 +1960,7 @@ beginseg name "ovl_Obj_Demo" compress include "build/src/overlays/actors/ovl_Obj_Demo/z_obj_demo.o" - include "build/data/ovl_Obj_Demo/ovl_Obj_Demo.data.o" - include "build/data/ovl_Obj_Demo/ovl_Obj_Demo.reloc.o" + include "build/src/overlays/actors/ovl_Obj_Demo/ovl_Obj_Demo_reloc.o" endseg beginseg @@ -2105,8 +2035,7 @@ beginseg name "ovl_Obj_Mure3" compress include "build/src/overlays/actors/ovl_Obj_Mure3/z_obj_mure3.o" - include "build/data/ovl_Obj_Mure3/ovl_Obj_Mure3.data.o" - include "build/data/ovl_Obj_Mure3/ovl_Obj_Mure3.reloc.o" + include "build/src/overlays/actors/ovl_Obj_Mure3/ovl_Obj_Mure3_reloc.o" endseg beginseg @@ -2180,16 +2109,14 @@ 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 name "ovl_Obj_Makekinsuta" compress include "build/src/overlays/actors/ovl_Obj_Makekinsuta/z_obj_makekinsuta.o" - include "build/data/ovl_Obj_Makekinsuta/ovl_Obj_Makekinsuta.data.o" - include "build/data/ovl_Obj_Makekinsuta/ovl_Obj_Makekinsuta.reloc.o" + include "build/src/overlays/actors/ovl_Obj_Makekinsuta/ovl_Obj_Makekinsuta_reloc.o" endseg beginseg @@ -2240,8 +2167,7 @@ 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 @@ -2292,8 +2218,7 @@ beginseg name "ovl_Bg_Fire_Wall" compress include "build/src/overlays/actors/ovl_Bg_Fire_Wall/z_bg_fire_wall.o" - include "build/data/ovl_Bg_Fire_Wall/ovl_Bg_Fire_Wall.data.o" - include "build/data/ovl_Bg_Fire_Wall/ovl_Bg_Fire_Wall.reloc.o" + include "build/src/overlays/actors/ovl_Bg_Fire_Wall/ovl_Bg_Fire_Wall_reloc.o" endseg beginseg @@ -2323,8 +2248,7 @@ beginseg name "ovl_Obj_Chikuwa" compress include "build/src/overlays/actors/ovl_Obj_Chikuwa/z_obj_chikuwa.o" - include "build/data/ovl_Obj_Chikuwa/ovl_Obj_Chikuwa.data.o" - include "build/data/ovl_Obj_Chikuwa/ovl_Obj_Chikuwa.reloc.o" + include "build/src/overlays/actors/ovl_Obj_Chikuwa/ovl_Obj_Chikuwa_reloc.o" endseg beginseg @@ -2439,11 +2363,7 @@ beginseg name "ovl_Bg_Spdweb" compress include "build/src/overlays/actors/ovl_Bg_Spdweb/z_bg_spdweb.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 @@ -2549,8 +2469,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 @@ -2585,11 +2504,7 @@ beginseg name "ovl_Obj_Spinyroll" compress include "build/src/overlays/actors/ovl_Obj_Spinyroll/z_obj_spinyroll.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 @@ -2632,8 +2547,7 @@ beginseg name "ovl_En_Bigpamet" compress include "build/src/overlays/actors/ovl_En_Bigpamet/z_en_bigpamet.o" - include "build/data/ovl_En_Bigpamet/ovl_En_Bigpamet.data.o" - include "build/data/ovl_En_Bigpamet/ovl_En_Bigpamet.reloc.o" + include "build/src/overlays/actors/ovl_En_Bigpamet/ovl_En_Bigpamet_reloc.o" endseg beginseg @@ -2654,8 +2568,7 @@ beginseg name "ovl_Elf_Msg3" compress include "build/src/overlays/actors/ovl_Elf_Msg3/z_elf_msg3.o" - include "build/data/ovl_Elf_Msg3/ovl_Elf_Msg3.data.o" - include "build/data/ovl_Elf_Msg3/ovl_Elf_Msg3.reloc.o" + include "build/src/overlays/actors/ovl_Elf_Msg3/ovl_Elf_Msg3_reloc.o" endseg beginseg @@ -2699,8 +2612,7 @@ beginseg name "ovl_Obj_Toudai" compress include "build/src/overlays/actors/ovl_Obj_Toudai/z_obj_toudai.o" - include "build/data/ovl_Obj_Toudai/ovl_Obj_Toudai.data.o" - include "build/data/ovl_Obj_Toudai/ovl_Obj_Toudai.reloc.o" + include "build/src/overlays/actors/ovl_Obj_Toudai/ovl_Obj_Toudai_reloc.o" endseg beginseg @@ -2728,16 +2640,14 @@ beginseg name "ovl_Obj_Shutter" compress include "build/src/overlays/actors/ovl_Obj_Shutter/z_obj_shutter.o" - include "build/data/ovl_Obj_Shutter/ovl_Obj_Shutter.data.o" - include "build/data/ovl_Obj_Shutter/ovl_Obj_Shutter.reloc.o" + include "build/src/overlays/actors/ovl_Obj_Shutter/ovl_Obj_Shutter_reloc.o" endseg beginseg 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 @@ -2774,11 +2684,7 @@ beginseg name "ovl_Obj_Vspinyroll" compress include "build/src/overlays/actors/ovl_Obj_Vspinyroll/z_obj_vspinyroll.o" -#ifdef NON_MATCHING include "build/src/overlays/actors/ovl_Obj_Vspinyroll/ovl_Obj_Vspinyroll_reloc.o" -#else - include "build/data/ovl_Obj_Vspinyroll/ovl_Obj_Vspinyroll.reloc.o" -#endif endseg beginseg @@ -2792,8 +2698,7 @@ beginseg name "ovl_En_Test2" compress include "build/src/overlays/actors/ovl_En_Test2/z_en_test2.o" - include "build/data/ovl_En_Test2/ovl_En_Test2.data.o" - include "build/data/ovl_En_Test2/ovl_En_Test2.reloc.o" + include "build/src/overlays/actors/ovl_En_Test2/ovl_En_Test2_reloc.o" endseg beginseg @@ -2816,17 +2721,14 @@ beginseg name "ovl_En_Bat" compress include "build/src/overlays/actors/ovl_En_Bat/z_en_bat.o" - include "build/data/ovl_En_Bat/ovl_En_Bat.data.o" - include "build/data/ovl_En_Bat/ovl_En_Bat.bss.o" - include "build/data/ovl_En_Bat/ovl_En_Bat.reloc.o" + include "build/src/overlays/actors/ovl_En_Bat/ovl_En_Bat_reloc.o" endseg beginseg name "ovl_En_Sekihi" compress include "build/src/overlays/actors/ovl_En_Sekihi/z_en_sekihi.o" - include "build/data/ovl_En_Sekihi/ovl_En_Sekihi.data.o" - include "build/data/ovl_En_Sekihi/ovl_En_Sekihi.reloc.o" + include "build/src/overlays/actors/ovl_En_Sekihi/ovl_En_Sekihi_reloc.o" endseg beginseg @@ -2841,8 +2743,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 @@ -2856,8 +2757,7 @@ beginseg name "ovl_Eff_Change" compress include "build/src/overlays/actors/ovl_Eff_Change/z_eff_change.o" - include "build/data/ovl_Eff_Change/ovl_Eff_Change.data.o" - include "build/data/ovl_Eff_Change/ovl_Eff_Change.reloc.o" + include "build/src/overlays/actors/ovl_Eff_Change/ovl_Eff_Change_reloc.o" endseg beginseg @@ -2885,16 +2785,14 @@ beginseg name "ovl_En_Mkk" compress include "build/src/overlays/actors/ovl_En_Mkk/z_en_mkk.o" - include "build/data/ovl_En_Mkk/ovl_En_Mkk.data.o" - include "build/data/ovl_En_Mkk/ovl_En_Mkk.reloc.o" + include "build/src/overlays/actors/ovl_En_Mkk/ovl_En_Mkk_reloc.o" endseg beginseg name "ovl_Demo_Getitem" compress include "build/src/overlays/actors/ovl_Demo_Getitem/z_demo_getitem.o" - include "build/data/ovl_Demo_Getitem/ovl_Demo_Getitem.data.o" - include "build/data/ovl_Demo_Getitem/ovl_Demo_Getitem.reloc.o" + include "build/src/overlays/actors/ovl_Demo_Getitem/ovl_Demo_Getitem_reloc.o" endseg beginseg @@ -2930,8 +2828,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 @@ -2952,8 +2849,7 @@ beginseg name "ovl_En_Rat" compress include "build/src/overlays/actors/ovl_En_Rat/z_en_rat.o" - include "build/data/ovl_En_Rat/ovl_En_Rat.data.o" - include "build/data/ovl_En_Rat/ovl_En_Rat.reloc.o" + include "build/src/overlays/actors/ovl_En_Rat/ovl_En_Rat_reloc.o" endseg beginseg @@ -2974,8 +2870,7 @@ beginseg name "ovl_Bg_Spout_Fire" compress include "build/src/overlays/actors/ovl_Bg_Spout_Fire/z_bg_spout_fire.o" - include "build/data/ovl_Bg_Spout_Fire/ovl_Bg_Spout_Fire.data.o" - include "build/data/ovl_Bg_Spout_Fire/ovl_Bg_Spout_Fire.reloc.o" + include "build/src/overlays/actors/ovl_Bg_Spout_Fire/ovl_Bg_Spout_Fire_reloc.o" endseg beginseg @@ -3011,11 +2906,7 @@ beginseg name "ovl_Obj_Driftice" compress include "build/src/overlays/actors/ovl_Obj_Driftice/z_obj_driftice.o" -#ifdef NON_MATCHING include "build/src/overlays/actors/ovl_Obj_Driftice/ovl_Obj_Driftice_reloc.o" -#else - include "build/data/ovl_Obj_Driftice/ovl_Obj_Driftice.reloc.o" -#endif endseg beginseg @@ -3050,9 +2941,7 @@ beginseg name "ovl_Bg_Crace_Movebg" compress include "build/src/overlays/actors/ovl_Bg_Crace_Movebg/z_bg_crace_movebg.o" - include "build/data/ovl_Bg_Crace_Movebg/ovl_Bg_Crace_Movebg.data.o" - include "build/data/ovl_Bg_Crace_Movebg/ovl_Bg_Crace_Movebg.bss.o" - include "build/data/ovl_Bg_Crace_Movebg/ovl_Bg_Crace_Movebg.reloc.o" + include "build/src/overlays/actors/ovl_Bg_Crace_Movebg/ovl_Bg_Crace_Movebg_reloc.o" endseg beginseg @@ -3114,8 +3003,7 @@ beginseg name "ovl_Obj_Purify" compress include "build/src/overlays/actors/ovl_Obj_Purify/z_obj_purify.o" - include "build/data/ovl_Obj_Purify/ovl_Obj_Purify.data.o" - include "build/data/ovl_Obj_Purify/ovl_Obj_Purify.reloc.o" + include "build/src/overlays/actors/ovl_Obj_Purify/ovl_Obj_Purify_reloc.o" endseg beginseg @@ -3178,8 +3066,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 @@ -3207,24 +3094,21 @@ beginseg name "ovl_Dm_Char02" compress include "build/src/overlays/actors/ovl_Dm_Char02/z_dm_char02.o" - include "build/data/ovl_Dm_Char02/ovl_Dm_Char02.data.o" - include "build/data/ovl_Dm_Char02/ovl_Dm_Char02.reloc.o" + include "build/src/overlays/actors/ovl_Dm_Char02/ovl_Dm_Char02_reloc.o" endseg beginseg name "ovl_Dm_Char03" compress include "build/src/overlays/actors/ovl_Dm_Char03/z_dm_char03.o" - include "build/data/ovl_Dm_Char03/ovl_Dm_Char03.data.o" - include "build/data/ovl_Dm_Char03/ovl_Dm_Char03.reloc.o" + include "build/src/overlays/actors/ovl_Dm_Char03/ovl_Dm_Char03_reloc.o" endseg beginseg name "ovl_Dm_Char04" compress include "build/src/overlays/actors/ovl_Dm_Char04/z_dm_char04.o" - include "build/data/ovl_Dm_Char04/ovl_Dm_Char04.data.o" - include "build/data/ovl_Dm_Char04/ovl_Dm_Char04.reloc.o" + include "build/src/overlays/actors/ovl_Dm_Char04/ovl_Dm_Char04_reloc.o" endseg beginseg @@ -3238,8 +3122,7 @@ beginseg name "ovl_Dm_Char06" compress include "build/src/overlays/actors/ovl_Dm_Char06/z_dm_char06.o" - include "build/data/ovl_Dm_Char06/ovl_Dm_Char06.data.o" - include "build/data/ovl_Dm_Char06/ovl_Dm_Char06.reloc.o" + include "build/src/overlays/actors/ovl_Dm_Char06/ovl_Dm_Char06_reloc.o" endseg beginseg @@ -3261,8 +3144,7 @@ beginseg name "ovl_Dm_Char09" compress include "build/src/overlays/actors/ovl_Dm_Char09/z_dm_char09.o" - include "build/data/ovl_Dm_Char09/ovl_Dm_Char09.data.o" - include "build/data/ovl_Dm_Char09/ovl_Dm_Char09.reloc.o" + include "build/src/overlays/actors/ovl_Dm_Char09/ovl_Dm_Char09_reloc.o" endseg beginseg @@ -3299,11 +3181,7 @@ beginseg name "ovl_Bg_Hakugin_Bombwall" compress include "build/src/overlays/actors/ovl_Bg_Hakugin_Bombwall/z_bg_hakugin_bombwall.o" -#ifdef NON_MATCHING include "build/src/overlays/actors/ovl_Bg_Hakugin_Bombwall/ovl_Bg_Hakugin_Bombwall_reloc.o" -#else - include "build/data/ovl_Bg_Hakugin_Bombwall/ovl_Bg_Hakugin_Bombwall.reloc.o" -#endif endseg beginseg @@ -3318,8 +3196,7 @@ beginseg name "ovl_Bg_Hakugin_Elvpole" compress include "build/src/overlays/actors/ovl_Bg_Hakugin_Elvpole/z_bg_hakugin_elvpole.o" - include "build/data/ovl_Bg_Hakugin_Elvpole/ovl_Bg_Hakugin_Elvpole.data.o" - include "build/data/ovl_Bg_Hakugin_Elvpole/ovl_Bg_Hakugin_Elvpole.reloc.o" + include "build/src/overlays/actors/ovl_Bg_Hakugin_Elvpole/ovl_Bg_Hakugin_Elvpole_reloc.o" endseg beginseg @@ -3364,9 +3241,7 @@ beginseg name "ovl_Bg_Icefloe" compress include "build/src/overlays/actors/ovl_Bg_Icefloe/z_bg_icefloe.o" - include "build/data/ovl_Bg_Icefloe/ovl_Bg_Icefloe.data.o" - include "build/data/ovl_Bg_Icefloe/ovl_Bg_Icefloe.bss.o" - include "build/data/ovl_Bg_Icefloe/ovl_Bg_Icefloe.reloc.o" + include "build/src/overlays/actors/ovl_Bg_Icefloe/ovl_Bg_Icefloe_reloc.o" endseg beginseg @@ -3413,40 +3288,35 @@ 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 name "ovl_Obj_Ocarinalift" compress include "build/src/overlays/actors/ovl_Obj_Ocarinalift/z_obj_ocarinalift.o" - include "build/data/ovl_Obj_Ocarinalift/ovl_Obj_Ocarinalift.data.o" - include "build/data/ovl_Obj_Ocarinalift/ovl_Obj_Ocarinalift.reloc.o" + include "build/src/overlays/actors/ovl_Obj_Ocarinalift/ovl_Obj_Ocarinalift_reloc.o" endseg beginseg 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 name "ovl_Bg_Open_Shutter" compress include "build/src/overlays/actors/ovl_Bg_Open_Shutter/z_bg_open_shutter.o" - include "build/data/ovl_Bg_Open_Shutter/ovl_Bg_Open_Shutter.data.o" - include "build/data/ovl_Bg_Open_Shutter/ovl_Bg_Open_Shutter.reloc.o" + include "build/src/overlays/actors/ovl_Bg_Open_Shutter/ovl_Bg_Open_Shutter_reloc.o" endseg beginseg 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 @@ -3546,8 +3416,7 @@ beginseg name "ovl_Bg_Fu_Mizu" compress include "build/src/overlays/actors/ovl_Bg_Fu_Mizu/z_bg_fu_mizu.o" - include "build/data/ovl_Bg_Fu_Mizu/ovl_Bg_Fu_Mizu.data.o" - include "build/data/ovl_Bg_Fu_Mizu/ovl_Bg_Fu_Mizu.reloc.o" + include "build/src/overlays/actors/ovl_Bg_Fu_Mizu/ovl_Bg_Fu_Mizu_reloc.o" endseg beginseg @@ -3591,8 +3460,7 @@ beginseg name "ovl_En_Ds2n" compress include "build/src/overlays/actors/ovl_En_Ds2n/z_en_ds2n.o" - include "build/data/ovl_En_Ds2n/ovl_En_Ds2n.data.o" - include "build/data/ovl_En_Ds2n/ovl_En_Ds2n.reloc.o" + include "build/src/overlays/actors/ovl_En_Ds2n/ovl_En_Ds2n_reloc.o" endseg beginseg @@ -3650,8 +3518,7 @@ beginseg name "ovl_Obj_Lupygamelift" compress include "build/src/overlays/actors/ovl_Obj_Lupygamelift/z_obj_lupygamelift.o" - include "build/data/ovl_Obj_Lupygamelift/ovl_Obj_Lupygamelift.data.o" - include "build/data/ovl_Obj_Lupygamelift/ovl_Obj_Lupygamelift.reloc.o" + include "build/src/overlays/actors/ovl_Obj_Lupygamelift/ovl_Obj_Lupygamelift_reloc.o" endseg beginseg @@ -3672,8 +3539,7 @@ beginseg name "ovl_Mir_Ray2" compress include "build/src/overlays/actors/ovl_Mir_Ray2/z_mir_ray2.o" - include "build/data/ovl_Mir_Ray2/ovl_Mir_Ray2.data.o" - include "build/data/ovl_Mir_Ray2/ovl_Mir_Ray2.reloc.o" + include "build/src/overlays/actors/ovl_Mir_Ray2/ovl_Mir_Ray2_reloc.o" endseg beginseg @@ -3688,8 +3554,7 @@ beginseg name "ovl_En_Gamelupy" compress include "build/src/overlays/actors/ovl_En_Gamelupy/z_en_gamelupy.o" - include "build/data/ovl_En_Gamelupy/ovl_En_Gamelupy.data.o" - include "build/data/ovl_En_Gamelupy/ovl_En_Gamelupy.reloc.o" + include "build/src/overlays/actors/ovl_En_Gamelupy/ovl_En_Gamelupy_reloc.o" endseg beginseg @@ -3726,16 +3591,14 @@ beginseg name "ovl_Elf_Msg4" compress include "build/src/overlays/actors/ovl_Elf_Msg4/z_elf_msg4.o" - include "build/data/ovl_Elf_Msg4/ovl_Elf_Msg4.data.o" - include "build/data/ovl_Elf_Msg4/ovl_Elf_Msg4.reloc.o" + include "build/src/overlays/actors/ovl_Elf_Msg4/ovl_Elf_Msg4_reloc.o" endseg beginseg name "ovl_Elf_Msg5" compress include "build/src/overlays/actors/ovl_Elf_Msg5/z_elf_msg5.o" - include "build/data/ovl_Elf_Msg5/ovl_Elf_Msg5.data.o" - include "build/data/ovl_Elf_Msg5/ovl_Elf_Msg5.reloc.o" + include "build/src/overlays/actors/ovl_Elf_Msg5/ovl_Elf_Msg5_reloc.o" endseg beginseg @@ -3785,8 +3648,7 @@ beginseg name "ovl_En_Onpuman" compress include "build/src/overlays/actors/ovl_En_Onpuman/z_en_onpuman.o" - include "build/data/ovl_En_Onpuman/ovl_En_Onpuman.data.o" - include "build/data/ovl_En_Onpuman/ovl_En_Onpuman.reloc.o" + include "build/src/overlays/actors/ovl_En_Onpuman/ovl_En_Onpuman_reloc.o" endseg beginseg @@ -3828,8 +3690,7 @@ 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 @@ -3850,8 +3711,7 @@ beginseg name "ovl_En_Pp" compress include "build/src/overlays/actors/ovl_En_Pp/z_en_pp.o" - include "build/data/ovl_En_Pp/ovl_En_Pp.data.o" - include "build/data/ovl_En_Pp/ovl_En_Pp.reloc.o" + include "build/src/overlays/actors/ovl_En_Pp/ovl_En_Pp_reloc.o" endseg beginseg @@ -3901,8 +3761,7 @@ beginseg name "ovl_Bg_Botihasira" compress include "build/src/overlays/actors/ovl_Bg_Botihasira/z_bg_botihasira.o" - include "build/data/ovl_Bg_Botihasira/ovl_Bg_Botihasira.data.o" - include "build/data/ovl_Bg_Botihasira/ovl_Bg_Botihasira.reloc.o" + include "build/src/overlays/actors/ovl_Bg_Botihasira/ovl_Bg_Botihasira_reloc.o" endseg beginseg @@ -3916,8 +3775,7 @@ beginseg name "ovl_En_Pst" compress include "build/src/overlays/actors/ovl_En_Pst/z_en_pst.o" - include "build/data/ovl_En_Pst/ovl_En_Pst.data.o" - include "build/data/ovl_En_Pst/ovl_En_Pst.reloc.o" + include "build/src/overlays/actors/ovl_En_Pst/ovl_En_Pst_reloc.o" endseg beginseg @@ -3931,11 +3789,7 @@ beginseg name "ovl_Obj_Spidertent" compress include "build/src/overlays/actors/ovl_Obj_Spidertent/z_obj_spidertent.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 @@ -4063,8 +3917,7 @@ 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 @@ -4103,8 +3956,7 @@ 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 @@ -4118,8 +3970,7 @@ beginseg name "ovl_Bg_Kin2_Bombwall" compress include "build/src/overlays/actors/ovl_Bg_Kin2_Bombwall/z_bg_kin2_bombwall.o" - include "build/data/ovl_Bg_Kin2_Bombwall/ovl_Bg_Kin2_Bombwall.data.o" - include "build/data/ovl_Bg_Kin2_Bombwall/ovl_Bg_Kin2_Bombwall.reloc.o" + include "build/src/overlays/actors/ovl_Bg_Kin2_Bombwall/ovl_Bg_Kin2_Bombwall_reloc.o" endseg beginseg @@ -4141,8 +3992,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 @@ -4170,8 +4020,7 @@ beginseg name "ovl_Obj_Um" compress include "build/src/overlays/actors/ovl_Obj_Um/z_obj_um.o" - include "build/data/ovl_Obj_Um/ovl_Obj_Um.data.o" - include "build/data/ovl_Obj_Um/ovl_Obj_Um.reloc.o" + include "build/src/overlays/actors/ovl_Obj_Um/ovl_Obj_Um_reloc.o" endseg beginseg @@ -4192,16 +4041,14 @@ 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 name "ovl_Bg_Ikana_Mirror" compress include "build/src/overlays/actors/ovl_Bg_Ikana_Mirror/z_bg_ikana_mirror.o" - include "build/data/ovl_Bg_Ikana_Mirror/ovl_Bg_Ikana_Mirror.data.o" - include "build/data/ovl_Bg_Ikana_Mirror/ovl_Bg_Ikana_Mirror.reloc.o" + include "build/src/overlays/actors/ovl_Bg_Ikana_Mirror/ovl_Bg_Ikana_Mirror_reloc.o" endseg beginseg @@ -4259,8 +4106,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 @@ -4289,8 +4135,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 @@ -4325,8 +4170,7 @@ beginseg name "ovl_Obj_Y2lift" compress include "build/src/overlays/actors/ovl_Obj_Y2lift/z_obj_y2lift.o" - include "build/data/ovl_Obj_Y2lift/ovl_Obj_Y2lift.data.o" - include "build/data/ovl_Obj_Y2lift/ovl_Obj_Y2lift.reloc.o" + include "build/src/overlays/actors/ovl_Obj_Y2lift/ovl_Obj_Y2lift_reloc.o" endseg beginseg @@ -4341,16 +4185,14 @@ 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 name "ovl_Obj_Taru" compress include "build/src/overlays/actors/ovl_Obj_Taru/z_obj_taru.o" - include "build/data/ovl_Obj_Taru/ovl_Obj_Taru.data.o" - include "build/data/ovl_Obj_Taru/ovl_Obj_Taru.reloc.o" + include "build/src/overlays/actors/ovl_Obj_Taru/ovl_Obj_Taru_reloc.o" endseg beginseg @@ -4396,9 +4238,7 @@ 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 @@ -4504,8 +4344,7 @@ beginseg name "ovl_En_S_Goro" compress include "build/src/overlays/actors/ovl_En_S_Goro/z_en_s_goro.o" - include "build/data/ovl_En_S_Goro/ovl_En_S_Goro.data.o" - include "build/data/ovl_En_S_Goro/ovl_En_S_Goro.reloc.o" + include "build/src/overlays/actors/ovl_En_S_Goro/ovl_En_S_Goro_reloc.o" endseg beginseg @@ -4587,26 +4426,21 @@ 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 name "ovl_Oceff_Wipe7" compress include "build/src/overlays/actors/ovl_Oceff_Wipe7/z_oceff_wipe7.o" - include "build/data/ovl_Oceff_Wipe7/ovl_Oceff_Wipe7.data.o" - include "build/data/ovl_Oceff_Wipe7/ovl_Oceff_Wipe7.bss.o" - include "build/data/ovl_Oceff_Wipe7/ovl_Oceff_Wipe7.reloc.o" + include "build/src/overlays/actors/ovl_Oceff_Wipe7/ovl_Oceff_Wipe7_reloc.o" endseg beginseg name "ovl_Eff_Kamejima_Wave" compress include "build/src/overlays/actors/ovl_Eff_Kamejima_Wave/z_eff_kamejima_wave.o" - include "build/data/ovl_Eff_Kamejima_Wave/ovl_Eff_Kamejima_Wave.data.o" - include "build/data/ovl_Eff_Kamejima_Wave/ovl_Eff_Kamejima_Wave.bss.o" - include "build/data/ovl_Eff_Kamejima_Wave/ovl_Eff_Kamejima_Wave.reloc.o" + include "build/src/overlays/actors/ovl_Eff_Kamejima_Wave/ovl_Eff_Kamejima_Wave_reloc.o" endseg beginseg @@ -4648,8 +4482,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 @@ -4670,8 +4507,11 @@ beginseg name "ovl_Bg_Haka_Bombwall" compress include "build/src/overlays/actors/ovl_Bg_Haka_Bombwall/z_bg_haka_bombwall.o" - include "build/data/ovl_Bg_Haka_Bombwall/ovl_Bg_Haka_Bombwall.data.o" - include "build/data/ovl_Bg_Haka_Bombwall/ovl_Bg_Haka_Bombwall.reloc.o" + #ifdef NON_MATCHING + include "build/src/overlays/actors/ovl_Bg_Haka_Bombwall/ovl_Bg_Haka_Bombwall_reloc.o" + #else + include "build/data/ovl_Bg_Haka_Bombwall/ovl_Bg_Haka_Bombwall.reloc.o" + #endif endseg beginseg @@ -4685,16 +4525,14 @@ 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 name "ovl_Bg_Iknv_Doukutu" compress include "build/src/overlays/actors/ovl_Bg_Iknv_Doukutu/z_bg_iknv_doukutu.o" - include "build/data/ovl_Bg_Iknv_Doukutu/ovl_Bg_Iknv_Doukutu.data.o" - include "build/data/ovl_Bg_Iknv_Doukutu/ovl_Bg_Iknv_Doukutu.reloc.o" + include "build/src/overlays/actors/ovl_Bg_Iknv_Doukutu/ovl_Bg_Iknv_Doukutu_reloc.o" endseg beginseg @@ -4857,17 +4695,14 @@ beginseg name "ovl_Eff_Lastday" compress include "build/src/overlays/actors/ovl_Eff_Lastday/z_eff_lastday.o" - include "build/data/ovl_Eff_Lastday/ovl_Eff_Lastday.data.o" - include "build/data/ovl_Eff_Lastday/ovl_Eff_Lastday.reloc.o" + include "build/src/overlays/actors/ovl_Eff_Lastday/ovl_Eff_Lastday_reloc.o" endseg beginseg 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 @@ -4896,11 +4731,7 @@ 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 @@ -4914,8 +4745,7 @@ beginseg name "ovl_En_Sth2" compress include "build/src/overlays/actors/ovl_En_Sth2/z_en_sth2.o" - include "build/data/ovl_En_Sth2/ovl_En_Sth2.data.o" - include "build/data/ovl_En_Sth2/ovl_En_Sth2.reloc.o" + include "build/src/overlays/actors/ovl_En_Sth2/ovl_En_Sth2_reloc.o" endseg beginseg @@ -4944,8 +4774,7 @@ beginseg name "ovl_En_Bjt" compress include "build/src/overlays/actors/ovl_En_Bjt/z_en_bjt.o" - include "build/data/ovl_En_Bjt/ovl_En_Bjt.data.o" - include "build/data/ovl_En_Bjt/ovl_En_Bjt.reloc.o" + include "build/src/overlays/actors/ovl_En_Bjt/ovl_En_Bjt_reloc.o" endseg beginseg @@ -5002,16 +4831,14 @@ 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 name "ovl_Eff_Zoraband" compress include "build/src/overlays/actors/ovl_Eff_Zoraband/z_eff_zoraband.o" - include "build/data/ovl_Eff_Zoraband/ovl_Eff_Zoraband.data.o" - include "build/data/ovl_Eff_Zoraband/ovl_Eff_Zoraband.reloc.o" + include "build/src/overlays/actors/ovl_Eff_Zoraband/ovl_Eff_Zoraband_reloc.o" endseg beginseg @@ -5062,8 +4889,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 @@ -5106,8 +4932,7 @@ beginseg name "ovl_Obj_Jgame_Light" compress include "build/src/overlays/actors/ovl_Obj_Jgame_Light/z_obj_jgame_light.o" - include "build/data/ovl_Obj_Jgame_Light/ovl_Obj_Jgame_Light.data.o" - include "build/data/ovl_Obj_Jgame_Light/ovl_Obj_Jgame_Light.reloc.o" + include "build/src/overlays/actors/ovl_Obj_Jgame_Light/ovl_Obj_Jgame_Light_reloc.o" endseg beginseg @@ -5143,8 +4968,7 @@ beginseg name "ovl_Bg_Last_Bwall" compress include "build/src/overlays/actors/ovl_Bg_Last_Bwall/z_bg_last_bwall.o" - include "build/data/ovl_Bg_Last_Bwall/ovl_Bg_Last_Bwall.data.o" - include "build/data/ovl_Bg_Last_Bwall/ovl_Bg_Last_Bwall.reloc.o" + include "build/src/overlays/actors/ovl_Bg_Last_Bwall/ovl_Bg_Last_Bwall_reloc.o" endseg beginseg @@ -5168,24 +4992,21 @@ beginseg name "ovl_Obj_Danpeilift" compress include "build/src/overlays/actors/ovl_Obj_Danpeilift/z_obj_danpeilift.o" - include "build/data/ovl_Obj_Danpeilift/ovl_Obj_Danpeilift.data.o" - include "build/data/ovl_Obj_Danpeilift/ovl_Obj_Danpeilift.reloc.o" + include "build/src/overlays/actors/ovl_Obj_Danpeilift/ovl_Obj_Danpeilift_reloc.o" endseg beginseg name "ovl_En_Fall2" compress include "build/src/overlays/actors/ovl_En_Fall2/z_en_fall2.o" - include "build/data/ovl_En_Fall2/ovl_En_Fall2.data.o" - include "build/data/ovl_En_Fall2/ovl_En_Fall2.reloc.o" + include "build/src/overlays/actors/ovl_En_Fall2/ovl_En_Fall2_reloc.o" endseg beginseg name "ovl_Dm_Al" compress include "build/src/overlays/actors/ovl_Dm_Al/z_dm_al.o" - include "build/data/ovl_Dm_Al/ovl_Dm_Al.data.o" - include "build/data/ovl_Dm_Al/ovl_Dm_Al.reloc.o" + include "build/src/overlays/actors/ovl_Dm_Al/ovl_Dm_Al_reloc.o" endseg beginseg @@ -5199,8 +5020,7 @@ beginseg name "ovl_Dm_Ah" compress include "build/src/overlays/actors/ovl_Dm_Ah/z_dm_ah.o" - include "build/data/ovl_Dm_Ah/ovl_Dm_Ah.data.o" - include "build/data/ovl_Dm_Ah/ovl_Dm_Ah.reloc.o" + include "build/src/overlays/actors/ovl_Dm_Ah/ovl_Dm_Ah_reloc.o" endseg beginseg @@ -5228,16 +5048,14 @@ 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 name "ovl_En_Paper" compress include "build/src/overlays/actors/ovl_En_Paper/z_en_paper.o" - include "build/data/ovl_En_Paper/ovl_En_Paper.data.o" - include "build/data/ovl_En_Paper/ovl_En_Paper.reloc.o" + include "build/src/overlays/actors/ovl_En_Paper/ovl_En_Paper_reloc.o" endseg beginseg @@ -5259,8 +5077,7 @@ beginseg name "ovl_En_Bh" compress include "build/src/overlays/actors/ovl_En_Bh/z_en_bh.o" - include "build/data/ovl_En_Bh/ovl_En_Bh.data.o" - include "build/data/ovl_En_Bh/ovl_En_Bh.reloc.o" + include "build/src/overlays/actors/ovl_En_Bh/ovl_En_Bh_reloc.o" endseg beginseg @@ -9159,7 +8976,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_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..b52675829 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_PASS, 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/fault.c b/src/boot_O2_g3/fault.c index 1f5503445..e648275b6 100644 --- a/src/boot_O2_g3/fault.c +++ b/src/boot_O2_g3/fault.c @@ -29,7 +29,7 @@ const char* sFpuExceptions[] = { }; void Fault_SleepImpl(u32 duration) { - u64 value = (duration * OS_CPU_COUNTER) / 1000ull; + u64 value = (duration * OS_CPU_COUNTER) / 1000ULL; Sleep_Cycles(value); } @@ -269,9 +269,9 @@ void Fault_DrawCornerRec(u16 color) { void Fault_PrintFReg(s32 idx, f32* value) { u32 raw = *(u32*)value; - s32 v0 = ((raw & 0x7f800000) >> 0x17) - 0x7f; + s32 v0 = ((raw & 0x7F800000) >> 0x17) - 0x7F; - if ((v0 >= -0x7e && v0 < 0x80) || raw == 0) { + if ((v0 >= -0x7E && v0 < 0x80) || raw == 0) { FaultDrawer_Printf("F%02d:%14.7e ", idx, *value); } else { FaultDrawer_Printf("F%02d: %08x(16) ", idx, raw); @@ -320,7 +320,7 @@ void osSyncPrintfFPCR(u32 value) { void Fault_PrintThreadContext(OSThread* t) { __OSThreadContext* ctx; - s32 causeStrIdx = (s32)((((u32)t->context.cause >> 2) & 0x1f) << 0x10) >> 0x10; + s32 causeStrIdx = (s32)((((u32)t->context.cause >> 2) & 0x1F) << 0x10) >> 0x10; if (causeStrIdx == 0x17) { causeStrIdx = 0x10; } @@ -383,11 +383,11 @@ void Fault_PrintThreadContext(OSThread* t) { void osSyncPrintfThreadContext(OSThread* t) { __OSThreadContext* ctx; - s32 causeStrIdx = (s32)((((u32)t->context.cause >> 2) & 0x1f) << 0x10) >> 0x10; + s32 causeStrIdx = (s32)((((u32)t->context.cause >> 2) & 0x1F) << 0x10) >> 0x10; if (causeStrIdx == 0x17) { causeStrIdx = 0x10; } - if (causeStrIdx == 0x1f) { + if (causeStrIdx == 0x1F) { causeStrIdx = 0x11; } @@ -416,29 +416,29 @@ void osSyncPrintfThreadContext(OSThread* t) { osSyncPrintfFReg(6, &ctx->fp6.f.f_even); osSyncPrintf("\n"); osSyncPrintfFReg(8, &ctx->fp8.f.f_even); - osSyncPrintfFReg(0xa, &ctx->fp10.f.f_even); + osSyncPrintfFReg(10, &ctx->fp10.f.f_even); osSyncPrintf("\n"); - osSyncPrintfFReg(0xc, &ctx->fp12.f.f_even); - osSyncPrintfFReg(0xe, &ctx->fp14.f.f_even); + osSyncPrintfFReg(12, &ctx->fp12.f.f_even); + osSyncPrintfFReg(14, &ctx->fp14.f.f_even); osSyncPrintf("\n"); - osSyncPrintfFReg(0x10, &ctx->fp16.f.f_even); - osSyncPrintfFReg(0x12, &ctx->fp18.f.f_even); + osSyncPrintfFReg(16, &ctx->fp16.f.f_even); + osSyncPrintfFReg(18, &ctx->fp18.f.f_even); osSyncPrintf("\n"); - osSyncPrintfFReg(0x14, &ctx->fp20.f.f_even); - osSyncPrintfFReg(0x16, &ctx->fp22.f.f_even); + osSyncPrintfFReg(20, &ctx->fp20.f.f_even); + osSyncPrintfFReg(22, &ctx->fp22.f.f_even); osSyncPrintf("\n"); - osSyncPrintfFReg(0x18, &ctx->fp24.f.f_even); - osSyncPrintfFReg(0x1a, &ctx->fp26.f.f_even); + osSyncPrintfFReg(24, &ctx->fp24.f.f_even); + osSyncPrintfFReg(26, &ctx->fp26.f.f_even); osSyncPrintf("\n"); - osSyncPrintfFReg(0x1c, &ctx->fp28.f.f_even); - osSyncPrintfFReg(0x1e, &ctx->fp30.f.f_even); + osSyncPrintfFReg(28, &ctx->fp28.f.f_even); + osSyncPrintfFReg(30, &ctx->fp30.f.f_even); osSyncPrintf("\n"); } OSThread* Fault_FindFaultedThread() { OSThread* iter = __osGetActiveQueue(); while (iter->priority != -1) { - if (iter->priority > 0 && iter->priority < 0x7f && (iter->flags & 3)) { + if (iter->priority > 0 && iter->priority < 0x7F && (iter->flags & 3)) { return iter; } iter = iter->tlnext; @@ -459,7 +459,7 @@ void Fault_Wait5Seconds(void) { void Fault_WaitForButtonCombo(void) { Input* input = &sFaultContext->padInput[0]; - FaultDrawer_SetForeColor(0xffff); + FaultDrawer_SetForeColor(0xFFFF); FaultDrawer_SetBackColor(1); do { do { @@ -480,8 +480,8 @@ void Fault_DrawMemDumpPage(const char* title, u32* addr, u32 param_3) { if (alignedAddr < (u32*)0x80000000) { alignedAddr = (u32*)0x80000000; } - if (alignedAddr > (u32*)0x807fff00) { - alignedAddr = (u32*)0x807fff00; + if (alignedAddr > (u32*)0x807FFF00) { + alignedAddr = (u32*)0x807FFF00; } alignedAddr = (u32*)((u32)alignedAddr & ~3); @@ -513,8 +513,8 @@ void Fault_DrawMemDump(u32 pc, u32 sp, u32 unk0, u32 unk1) { if (addr < 0x80000000) { addr = 0x80000000; } - if (addr > 0x807fff00) { - addr = 0x807fff00; + if (addr > 0x807FFF00) { + addr = 0x807FFF00; } addr &= ~0xF; @@ -696,14 +696,15 @@ void Fault_ResumeThread(OSThread* t) { t->context.cause = 0; t->context.fpcsr = 0; t->context.pc += 4; - *(u32*)t->context.pc = 0xd; + *(u32*)t->context.pc = 0x0000000D; // write in a break instruction osWritebackDCache((void*)t->context.pc, 4); osInvalICache((void*)t->context.pc, 4); osStartThread(t); } -void Fault_CommitFB() { +void Fault_CommitFB(void) { u16* fb; + osViSetYScale(1.0f); osViSetMode(&osViModeNtscLan1); osViSetSpecialFeatures(0x42); // gama_disable|dither_fliter_enable_aa_mode3_disable diff --git a/src/boot_O2_g3/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.c b/src/boot_O2_g3/idle.c index 942435fa7..da93f13fd 100644 --- a/src/boot_O2_g3/idle.c +++ b/src/boot_O2_g3/idle.c @@ -1,3 +1,4 @@ +#include "prevent_bss_reordering.h" #include "global.h" u8 D_80096B20 = 1; diff --git a/src/code/PreRender.c b/src/code/PreRender.c index 0afb1df68..46fd8ee6b 100644 --- a/src/code/PreRender.c +++ b/src/code/PreRender.c @@ -191,8 +191,6 @@ void func_80170774(PreRender* this, Gfx** gfxp) { func_8016FF70(this, gfxp, this->zbufSave, this->zbuf); } -#ifdef NON_MATCHING -// just regalloc void func_80170798(PreRender* this, Gfx** gfxp) { Gfx* gfx; s32 y; @@ -235,6 +233,10 @@ void func_80170798(PreRender* this, Gfx** gfxp) { gDPLoadMultiTile(gfx++, this->cvgSave, 0x0160, rtile, G_IM_FMT_I, G_IM_SIZ_8b, this->width, this->height, uls, ult, lrs, lrt, 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); + //! FAKE + if (1) {} + // The two if (1) {}'s above can be removed with do {} while(0) around macros + if (1) {} if (1) {} gSPTextureRectangle(gfx++, uls << 2, ult << 2, (lrs + 1) << 2, (lrt + 1) << 2, G_TX_RENDERTILE, uls << 5, ult << 5, 1 << 10, 1 << 10); @@ -247,9 +249,6 @@ void func_80170798(PreRender* this, Gfx** gfxp) { *gfxp = gfx; } } -#else -#pragma GLOBAL_ASM("asm/non_matchings/code/PreRender/func_80170798.s") -#endif void func_80170AE0(PreRender* this, Gfx** gfxp, s32 alpha) { func_8016FF90(this, gfxp, this->fbufSave, this->fbuf, 255, 255, 255, alpha); diff --git a/src/code/audio/aisetnextbuf.c b/src/code/audio/aisetnextbuf.c new file mode 100644 index 000000000..b82f28e6f --- /dev/null +++ b/src/code/audio/aisetnextbuf.c @@ -0,0 +1,107 @@ +#include "global.h" + +//! Note that this is not the same as the original libultra +//! osAiSetNextBuffer, see comments in the function + +s32 osAiSetNextBuffer(void* buf, u32 size) { + static u8 D_801D6010 = false; + u32 bufAdjusted = (u32)buf; + s32 status; + + if (D_801D6010) { + bufAdjusted = (u32)buf - 0x2000; + } + if ((((u32)buf + size) & 0x1FFF) == 0) { + D_801D6010 = true; + } else { + D_801D6010 = false; + } + + // Originally a call to __osAiDeviceBusy + status = HW_REG(AI_STATUS_REG, s32); + if (status & AI_STATUS_AI_FULL) { + return -1; + } + + // OS_K0_TO_PHYSICAL replaces osVirtualToPhysical, this replacement + // assumes that only KSEG0 addresses are given + HW_REG(AI_DRAM_ADDR_REG, u32) = OS_K0_TO_PHYSICAL(bufAdjusted); + HW_REG(AI_LEN_REG, u32) = size; + return 0; +} + +//! Note that the remaining data and functions are unused and not part of the +//! original libultra osAiSetNextBuffer + +s16 D_801D6014[] = { + 19720, 18360, 17680, 16320, 14960, 13600, 12240, 10880, 9520, 0, +}; +s8 D_801D6028[7][16] = { + { 0, 1, 2, 2, 1, 3, 4, 5, 6, 7, 8, 7, 6, 5, 4, 3 }, { 0, 1, 2, 3, 3, 2, 1, 4, 5, 6, 7, 8, 7, 6, 5, 4 }, + { 0, 1, 2, 3, 4, 4, 3, 2, 1, 5, 6, 7, 8, 7, 6, 5 }, { 0, 1, 2, 3, 4, 5, 5, 4, 3, 2, 1, 6, 7, 8, 7, 6 }, + { 0, 1, 2, 3, 4, 5, 6, 6, 5, 4, 3, 2, 1, 7, 8, 7 }, { 0, 1, 2, 3, 4, 5, 6, 7, 7, 6, 5, 4, 3, 2, 1, 8 }, + { 0, 1, 2, 3, 4, 5, 6, 7, 8, 7, 6, 5, 4, 3, 2, 1 }, +}; +s16 D_801D6098[7][17] = { + { 0, 268, 560, 834, 1126, 1418, 1692, 1966, 2240, 2514, 2718, 2922, 3196, 3470, 3744, 4018, 4292 }, + { 0, 268, 560, 834, 1108, 1382, 1674, 1966, 2240, 2514, 2788, 2992, 3196, 3470, 3744, 4018, 4292 }, + { 0, 268, 560, 834, 1108, 1382, 1656, 1930, 2222, 2514, 2788, 3062, 3266, 3470, 3744, 4018, 4292 }, + { 0, 268, 560, 834, 1108, 1382, 1656, 1930, 2204, 2478, 2770, 3062, 3336, 3540, 3744, 4018, 4292 }, + { 0, 268, 560, 834, 1108, 1382, 1656, 1930, 2222, 2514, 2752, 3026, 3318, 3610, 3814, 4018, 4292 }, + { 0, 268, 560, 834, 1108, 1382, 1656, 1930, 2134, 2408, 2682, 2956, 3230, 3504, 3796, 4088, 4292 }, + { 0, 268, 560, 834, 1108, 1382, 1656, 1930, 2134, 2338, 2612, 2886, 3163, 3434, 3708, 4000, 4292 }, +}; +s16* D_801D6188 = D_801D6098[0]; +s8* D_801D618C = D_801D6028[0]; + +// Unused +void func_80194804(s32 index) { + D_801D6188 = D_801D6098[index]; + D_801D618C = D_801D6028[index]; +} + +// Only used below +s16 func_80194840(s32 arg0) { + s32 i; + s32 j = 0; + + for (i = 1; i < 16; i++) { + if (arg0 < D_801D6188[i]) { + break; + } + j++; + } + + if (i == 16) { + return 0; + } else { + j = D_801D618C[j]; + return D_801D6014[j]; + } +} + +// Unused +s32 func_801948B0(s32* arg0, s32* arg1) { + s32 temp_v0; + s32 phi_s0 = *arg0; + s32 phi_s1 = *arg1; + + while (true) { + temp_v0 = func_80194840(phi_s0); + if (temp_v0 == 0) { + return -1; + } + + if (phi_s1 < temp_v0) { + break; + } + + phi_s1 -= temp_v0; + phi_s0++; + } + + *arg0 = phi_s0; + *arg1 = phi_s1; + + return 0; +} diff --git a/src/code/audio/audio_data.c b/src/code/audio/audio_data.c index c43018922..7238a4bfa 100644 --- a/src/code/audio/audio_data.c +++ b/src/code/audio/audio_data.c @@ -850,11 +850,11 @@ u8 gDefaultShortNoteGateTimeTable[] = { 229, 203, 177, 151, 139, 126, 113, 100, 87, 74, 61, 48, 36, 23, 10, 0, }; -AdsrEnvelope gDefaultEnvelope[] = { +EnvelopePoint gDefaultEnvelope[] = { { 1, 32000 }, { 1000, 32000 }, - { -1, 0 }, - { 0, 0 }, + { ADSR_HANG, 0 }, + { ADSR_DISABLE, 0 }, }; NoteSubEu gZeroNoteSub = { 0 }; diff --git a/src/code/audio/audio_effects.c b/src/code/audio/audio_effects.c index 2dcef2237..ab9228bbf 100644 --- a/src/code/audio/audio_effects.c +++ b/src/code/audio/audio_effects.c @@ -7,7 +7,7 @@ void AudioEffects_SequenceChannelProcessSound(SequenceChannel* channel, s32 reca if (channel->changes.s.volume || recalculateVolume) { channelVolume = channel->volume * channel->volumeScale * channel->seqPlayer->appliedFadeVolume; - if (channel->seqPlayer->muted && (channel->muteBehavior & 0x20)) { + if (channel->seqPlayer->muted && (channel->muteFlags & MUTE_FLAGS_SOFTEN)) { channelVolume = channel->seqPlayer->muteVolumeScale * channelVolume; } channel->appliedVolume = channelVolume * channelVolume; @@ -218,7 +218,7 @@ void AudioEffects_NotePortamentoInit(Note* note) { note->playbackState.portamento = note->playbackState.parentLayer->portamento; } -void AudioEffects_AdsrInit(AdsrState* adsr, AdsrEnvelope* envelope, s16* volOut) { +void AudioEffects_AdsrInit(AdsrState* adsr, EnvelopePoint* envelope, s16* volOut) { adsr->action.asByte = 0; adsr->delay = 0; adsr->envelope = envelope; diff --git a/src/code/audio/audio_heap.c b/src/code/audio/audio_heap.c index b06f6a577..7d3ea8ba6 100644 --- a/src/code/audio/audio_heap.c +++ b/src/code/audio/audio_heap.c @@ -21,45 +21,45 @@ f32 func_8018B0F0(f32 arg0) { void func_8018B10C(void) { s32 i; - gAudioContext.unk_3520[255] = func_8018B0F0(0.25f); - gAudioContext.unk_3520[254] = func_8018B0F0(0.33f); - gAudioContext.unk_3520[253] = func_8018B0F0(0.5f); - gAudioContext.unk_3520[252] = func_8018B0F0(0.66f); - gAudioContext.unk_3520[251] = func_8018B0F0(0.75f); + gAudioContext.adsrDecayTable[255] = func_8018B0F0(0.25f); + gAudioContext.adsrDecayTable[254] = func_8018B0F0(0.33f); + gAudioContext.adsrDecayTable[253] = func_8018B0F0(0.5f); + gAudioContext.adsrDecayTable[252] = func_8018B0F0(0.66f); + gAudioContext.adsrDecayTable[251] = func_8018B0F0(0.75f); for (i = 128; i < 251; i++) { - gAudioContext.unk_3520[i] = func_8018B0F0(251 - i); + gAudioContext.adsrDecayTable[i] = func_8018B0F0(251 - i); } for (i = 16; i < 128; i++) { - gAudioContext.unk_3520[i] = func_8018B0F0(4 * (143 - i)); + gAudioContext.adsrDecayTable[i] = func_8018B0F0(4 * (143 - i)); } for (i = 1; i < 16; i++) { - gAudioContext.unk_3520[i] = func_8018B0F0(60 * (23 - i)); + gAudioContext.adsrDecayTable[i] = func_8018B0F0(60 * (23 - i)); } - gAudioContext.unk_3520[0] = 0.0f; + gAudioContext.adsrDecayTable[0] = 0.0f; } void AudioHeap_ResetLoadStatus(void) { s32 i; for (i = 0; i < ARRAY_COUNT(gAudioContext.fontLoadStatus); i++) { - if (gAudioContext.fontLoadStatus[i] != LOAD_STATUS_5) { - gAudioContext.fontLoadStatus[i] = LOAD_STATUS_0; + if (gAudioContext.fontLoadStatus[i] != LOAD_STATUS_PERMANENT) { + gAudioContext.fontLoadStatus[i] = LOAD_STATUS_NOT_LOADED; } } for (i = 0; i < ARRAY_COUNT(gAudioContext.sampleFontLoadStatus); i++) { - if (gAudioContext.sampleFontLoadStatus[i] != LOAD_STATUS_5) { - gAudioContext.sampleFontLoadStatus[i] = LOAD_STATUS_0; + if (gAudioContext.sampleFontLoadStatus[i] != LOAD_STATUS_PERMANENT) { + gAudioContext.sampleFontLoadStatus[i] = LOAD_STATUS_NOT_LOADED; } } for (i = 0; i < ARRAY_COUNT(gAudioContext.seqLoadStatus); i++) { - if (gAudioContext.seqLoadStatus[i] != LOAD_STATUS_5) { - gAudioContext.seqLoadStatus[i] = LOAD_STATUS_0; + if (gAudioContext.seqLoadStatus[i] != LOAD_STATUS_PERMANENT) { + gAudioContext.seqLoadStatus[i] = LOAD_STATUS_NOT_LOADED; } } } @@ -302,7 +302,7 @@ void AudioHeap_PopCache(s32 tableType) { AudioHeap_DiscardFont(persistent->entries[persistent->numEntries - 1].id); } - loadStatus[persistent->entries[persistent->numEntries - 1].id] = LOAD_STATUS_0; + loadStatus[persistent->entries[persistent->numEntries - 1].id] = LOAD_STATUS_NOT_LOADED; persistent->numEntries--; } @@ -409,12 +409,12 @@ void* AudioHeap_AllocCached(s32 tableType, size_t size, s32 cache, s32 id) { } loadStatusEntry0 = - (temporaryCache->entries[0].id == -1) ? LOAD_STATUS_0 : loadStatus[temporaryCache->entries[0].id]; + (temporaryCache->entries[0].id == -1) ? LOAD_STATUS_NOT_LOADED : loadStatus[temporaryCache->entries[0].id]; loadStatusEntry1 = - (temporaryCache->entries[1].id == -1) ? LOAD_STATUS_0 : loadStatus[temporaryCache->entries[1].id]; + (temporaryCache->entries[1].id == -1) ? LOAD_STATUS_NOT_LOADED : loadStatus[temporaryCache->entries[1].id]; if (tableType == FONT_TABLE) { - if (loadStatusEntry0 == LOAD_STATUS_4) { + if (loadStatusEntry0 == LOAD_STATUS_MAYBE_DISCARDABLE) { for (i = 0; i < gAudioContext.numNotes; i++) { if ((gAudioContext.notes[i].playbackState.fontId == temporaryCache->entries[0].id) && gAudioContext.notes[i].noteSubEu.bitField0.enabled) { @@ -423,12 +423,12 @@ void* AudioHeap_AllocCached(s32 tableType, size_t size, s32 cache, s32 id) { } if (i == gAudioContext.numNotes) { - AudioLoad_SetFontLoadStatus(temporaryCache->entries[0].id, LOAD_STATUS_3); - loadStatusEntry0 = LOAD_STATUS_3; + AudioLoad_SetFontLoadStatus(temporaryCache->entries[0].id, LOAD_STATUS_DISCARDABLE); + loadStatusEntry0 = LOAD_STATUS_DISCARDABLE; } } - if (loadStatusEntry1 == LOAD_STATUS_4) { + if (loadStatusEntry1 == LOAD_STATUS_MAYBE_DISCARDABLE) { for (i = 0; i < gAudioContext.numNotes; i++) { if ((gAudioContext.notes[i].playbackState.fontId == temporaryCache->entries[1].id) && gAudioContext.notes[i].noteSubEu.bitField0.enabled) { @@ -437,26 +437,26 @@ void* AudioHeap_AllocCached(s32 tableType, size_t size, s32 cache, s32 id) { } if (i == gAudioContext.numNotes) { - AudioLoad_SetFontLoadStatus(temporaryCache->entries[1].id, LOAD_STATUS_3); - loadStatusEntry1 = LOAD_STATUS_3; + AudioLoad_SetFontLoadStatus(temporaryCache->entries[1].id, LOAD_STATUS_DISCARDABLE); + loadStatusEntry1 = LOAD_STATUS_DISCARDABLE; } } } - if (loadStatusEntry0 == LOAD_STATUS_0) { + if (loadStatusEntry0 == LOAD_STATUS_NOT_LOADED) { temporaryCache->nextSide = 0; - } else if (loadStatusEntry1 == LOAD_STATUS_0) { + } else if (loadStatusEntry1 == LOAD_STATUS_NOT_LOADED) { temporaryCache->nextSide = 1; - } else if ((loadStatusEntry0 == LOAD_STATUS_3) && (loadStatusEntry1 == LOAD_STATUS_3)) { + } else if ((loadStatusEntry0 == LOAD_STATUS_DISCARDABLE) && (loadStatusEntry1 == LOAD_STATUS_DISCARDABLE)) { // Use the opposite side from last time. - } else if (loadStatusEntry0 == LOAD_STATUS_3) { + } else if (loadStatusEntry0 == LOAD_STATUS_DISCARDABLE) { temporaryCache->nextSide = 0; - } else if (loadStatusEntry1 == LOAD_STATUS_3) { + } else if (loadStatusEntry1 == LOAD_STATUS_DISCARDABLE) { temporaryCache->nextSide = 1; } else { // Check if there is a side which isn't in active use, if so, evict that one. if (tableType == SEQUENCE_TABLE) { - if (loadStatusEntry0 == LOAD_STATUS_2) { + if (loadStatusEntry0 == LOAD_STATUS_COMPLETE) { for (i = 0; i < gAudioContext.audioBufferParameters.numSequencePlayers; i++) { if (gAudioContext.seqPlayers[i].enabled && gAudioContext.seqPlayers[i].seqId == temporaryCache->entries[0].id) { @@ -470,7 +470,7 @@ void* AudioHeap_AllocCached(s32 tableType, size_t size, s32 cache, s32 id) { } } - if (loadStatusEntry1 == LOAD_STATUS_2) { + if (loadStatusEntry1 == LOAD_STATUS_COMPLETE) { for (i = 0; i < gAudioContext.audioBufferParameters.numSequencePlayers; i++) { if (gAudioContext.seqPlayers[i].enabled && gAudioContext.seqPlayers[i].seqId == temporaryCache->entries[1].id) { @@ -484,7 +484,7 @@ void* AudioHeap_AllocCached(s32 tableType, size_t size, s32 cache, s32 id) { } } } else if (tableType == FONT_TABLE) { - if (loadStatusEntry0 == LOAD_STATUS_2) { + if (loadStatusEntry0 == LOAD_STATUS_COMPLETE) { for (i = 0; i < gAudioContext.numNotes; i++) { if ((gAudioContext.notes[i].playbackState.fontId == temporaryCache->entries[0].id) && gAudioContext.notes[i].noteSubEu.bitField0.enabled) { @@ -497,7 +497,7 @@ void* AudioHeap_AllocCached(s32 tableType, size_t size, s32 cache, s32 id) { } } - if (loadStatusEntry1 == LOAD_STATUS_2) { + if (loadStatusEntry1 == LOAD_STATUS_COMPLETE) { for (i = 0; i < gAudioContext.numNotes; i++) { if ((gAudioContext.notes[i].playbackState.fontId == temporaryCache->entries[1].id) && gAudioContext.notes[i].noteSubEu.bitField0.enabled) { @@ -514,15 +514,15 @@ void* AudioHeap_AllocCached(s32 tableType, size_t size, s32 cache, s32 id) { // No such luck. Evict the side that wasn't chosen last time, except // if it is being loaded into. if (temporaryCache->nextSide == 0) { - if (loadStatusEntry0 == LOAD_STATUS_1) { - if (loadStatusEntry1 == LOAD_STATUS_1) { + if (loadStatusEntry0 == LOAD_STATUS_IN_PROGRESS) { + if (loadStatusEntry1 == LOAD_STATUS_IN_PROGRESS) { goto fail; } temporaryCache->nextSide = 1; } } else { - if (loadStatusEntry1 == LOAD_STATUS_1) { - if (loadStatusEntry0 == LOAD_STATUS_1) { + if (loadStatusEntry1 == LOAD_STATUS_IN_PROGRESS) { + if (loadStatusEntry0 == LOAD_STATUS_IN_PROGRESS) { goto fail; } temporaryCache->nextSide = 0; @@ -544,7 +544,7 @@ void* AudioHeap_AllocCached(s32 tableType, size_t size, s32 cache, s32 id) { AudioHeap_DiscardSampleBank(temporaryCache->entries[side].id); } - loadStatus[temporaryCache->entries[side].id] = LOAD_STATUS_0; + loadStatus[temporaryCache->entries[side].id] = LOAD_STATUS_NOT_LOADED; if (tableType == FONT_TABLE) { AudioHeap_DiscardFont(temporaryCache->entries[side].id); @@ -564,7 +564,7 @@ void* AudioHeap_AllocCached(s32 tableType, size_t size, s32 cache, s32 id) { AudioHeap_DiscardSampleBank(temporaryCache->entries[1].id); } - loadStatus[temporaryCache->entries[1].id] = LOAD_STATUS_0; + loadStatus[temporaryCache->entries[1].id] = LOAD_STATUS_NOT_LOADED; switch (tableType) { case SEQUENCE_TABLE: @@ -594,7 +594,7 @@ void* AudioHeap_AllocCached(s32 tableType, size_t size, s32 cache, s32 id) { AudioHeap_DiscardSampleBank(temporaryCache->entries[0].id); } - loadStatus[temporaryCache->entries[0].id] = LOAD_STATUS_0; + loadStatus[temporaryCache->entries[0].id] = LOAD_STATUS_NOT_LOADED; switch (tableType) { case SEQUENCE_TABLE: @@ -1042,8 +1042,8 @@ void AudioHeap_Init(void) { AudioHeap_AllocDmaMemoryZeroed(&gAudioContext.miscPool, gAudioContext.maxAudioCmds * sizeof(u64)); } - // Initialize unk_3520 (fadeOutVelocities for ADSR) - gAudioContext.unk_3520 = AudioHeap_Alloc(&gAudioContext.miscPool, 0x100 * sizeof(f32)); + // Initialize adsrDecayTable (fadeOutVelocities for ADSR) + gAudioContext.adsrDecayTable = AudioHeap_Alloc(&gAudioContext.miscPool, 0x100 * sizeof(f32)); func_8018B10C(); // Initialize reverbs diff --git a/src/code/audio/audio_load.c b/src/code/audio/audio_load.c index b63f8192b..9ebdd1d85 100644 --- a/src/code/audio/audio_load.c +++ b/src/code/audio/audio_load.c @@ -29,7 +29,7 @@ typedef struct { } AudioRelocInfo; // size = 0x18 void AudioLoad_DiscardFont(s32 fontId); -s32 AudioLoad_SyncInitSeqPlayerInternal(s32 playerIdx, s32 seqId, s32 arg2); +s32 AudioLoad_SyncInitSeqPlayerInternal(s32 playerIndex, s32 seqId, s32 arg2); u8* AudioLoad_SyncLoadSeq(s32 seqId); u32 AudioLoad_TrySyncLoadSampleBank(u32 sampleBankId, u32* outMedium, s32 noLoad); SoundFontData* AudioLoad_SyncLoadFont(u32 fontId); @@ -277,7 +277,7 @@ void AudioLoad_InitSampleDmaBuffers(s32 numNotes) { } else { AudioHeap_WritebackDCache(dma->ramAddr, gAudioContext.sampleDmaBufSize); dma->size = gAudioContext.sampleDmaBufSize; - dma->devAddr = 0U; + dma->devAddr = 0; dma->sizeUnused = 0; dma->unused = 0; dma->ttl = 0; @@ -301,9 +301,9 @@ void AudioLoad_InitSampleDmaBuffers(s32 numNotes) { s32 AudioLoad_IsFontLoadComplete(s32 fontId) { if (fontId == 0xFF) { return true; - } else if (gAudioContext.fontLoadStatus[fontId] >= LOAD_STATUS_2) { + } else if (gAudioContext.fontLoadStatus[fontId] >= LOAD_STATUS_COMPLETE) { return true; - } else if (gAudioContext.fontLoadStatus[AudioLoad_GetRealTableIndex(FONT_TABLE, fontId)] >= LOAD_STATUS_2) { + } else if (gAudioContext.fontLoadStatus[AudioLoad_GetRealTableIndex(FONT_TABLE, fontId)] >= LOAD_STATUS_COMPLETE) { return true; } else { return false; @@ -313,9 +313,10 @@ s32 AudioLoad_IsFontLoadComplete(s32 fontId) { s32 AudioLoad_IsSeqLoadComplete(s32 seqId) { if (seqId == 0xFF) { return true; - } else if (gAudioContext.seqLoadStatus[seqId] >= LOAD_STATUS_2) { + } else if (gAudioContext.seqLoadStatus[seqId] >= LOAD_STATUS_COMPLETE) { return true; - } else if (gAudioContext.seqLoadStatus[AudioLoad_GetRealTableIndex(SEQUENCE_TABLE, seqId)] >= LOAD_STATUS_2) { + } else if (gAudioContext.seqLoadStatus[AudioLoad_GetRealTableIndex(SEQUENCE_TABLE, seqId)] >= + LOAD_STATUS_COMPLETE) { return true; } else { return false; @@ -325,10 +326,10 @@ s32 AudioLoad_IsSeqLoadComplete(s32 seqId) { s32 AudioLoad_IsSampleLoadComplete(s32 sampleBankId) { if (sampleBankId == 0xFF) { return true; - } else if (gAudioContext.sampleFontLoadStatus[sampleBankId] >= LOAD_STATUS_2) { + } else if (gAudioContext.sampleFontLoadStatus[sampleBankId] >= LOAD_STATUS_COMPLETE) { return true; } else if (gAudioContext.sampleFontLoadStatus[AudioLoad_GetRealTableIndex(SAMPLE_TABLE, sampleBankId)] >= - LOAD_STATUS_2) { + LOAD_STATUS_COMPLETE) { return true; } else { return false; @@ -336,32 +337,32 @@ s32 AudioLoad_IsSampleLoadComplete(s32 sampleBankId) { } void AudioLoad_SetFontLoadStatus(s32 fontId, s32 loadStatus) { - if ((fontId != 0xFF) && (gAudioContext.fontLoadStatus[fontId] != LOAD_STATUS_5)) { + if ((fontId != 0xFF) && (gAudioContext.fontLoadStatus[fontId] != LOAD_STATUS_PERMANENT)) { gAudioContext.fontLoadStatus[fontId] = loadStatus; } } void AudioLoad_SetSeqLoadStatus(s32 seqId, s32 loadStatus) { - if ((seqId != 0xFF) && (gAudioContext.seqLoadStatus[seqId] != LOAD_STATUS_5)) { + if ((seqId != 0xFF) && (gAudioContext.seqLoadStatus[seqId] != LOAD_STATUS_PERMANENT)) { gAudioContext.seqLoadStatus[seqId] = loadStatus; } } void AudioLoad_SetSampleFontLoadStatusAndApplyCaches(s32 sampleBankId, s32 loadStatus) { if (sampleBankId != 0xFF) { - if (gAudioContext.sampleFontLoadStatus[sampleBankId] != LOAD_STATUS_5) { + if (gAudioContext.sampleFontLoadStatus[sampleBankId] != LOAD_STATUS_PERMANENT) { gAudioContext.sampleFontLoadStatus[sampleBankId] = loadStatus; } - if ((gAudioContext.sampleFontLoadStatus[sampleBankId] == LOAD_STATUS_5) || - (gAudioContext.sampleFontLoadStatus[sampleBankId] == LOAD_STATUS_2)) { + if ((gAudioContext.sampleFontLoadStatus[sampleBankId] == LOAD_STATUS_PERMANENT) || + (gAudioContext.sampleFontLoadStatus[sampleBankId] == LOAD_STATUS_COMPLETE)) { AudioHeap_ApplySampleBankCache(sampleBankId); } } } void AudioLoad_SetSampleFontLoadStatus(s32 sampleBankId, s32 loadStatus) { - if ((sampleBankId != 0xFF) && (gAudioContext.sampleFontLoadStatus[sampleBankId] != LOAD_STATUS_5)) { + if ((sampleBankId != 0xFF) && (gAudioContext.sampleFontLoadStatus[sampleBankId] != LOAD_STATUS_PERMANENT)) { gAudioContext.sampleFontLoadStatus[sampleBankId] = loadStatus; } } @@ -459,6 +460,7 @@ s32 AudioLoad_SyncLoadInstrument(s32 fontId, s32 instId, s32 drumId) { 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); @@ -468,6 +470,7 @@ s32 AudioLoad_SyncLoadInstrument(s32 fontId, s32 instId, s32 drumId) { 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) { @@ -508,7 +511,7 @@ void AudioLoad_DiscardSeqFonts(s32 seqId) { fontId = AudioLoad_GetRealTableIndex(FONT_TABLE, gAudioContext.sequenceFontTable[index++]); if (AudioHeap_SearchPermanentCache(FONT_TABLE, fontId) == NULL) { AudioLoad_DiscardFont(fontId); - AudioLoad_SetFontLoadStatus(fontId, LOAD_STATUS_0); + AudioLoad_SetFontLoadStatus(fontId, LOAD_STATUS_NOT_LOADED); } } } @@ -551,31 +554,31 @@ void func_8018FA60(u32 tableType, u32 id, s32 type, s32 data) { } } -s32 AudioLoad_SyncInitSeqPlayer(s32 playerIdx, s32 seqId, s32 arg2) { +s32 AudioLoad_SyncInitSeqPlayer(s32 playerIndex, s32 seqId, s32 arg2) { if (gAudioContext.resetTimer != 0) { return 0; } - gAudioContext.seqPlayers[playerIdx].skipTicks = 0; - AudioLoad_SyncInitSeqPlayerInternal(playerIdx, seqId, arg2); + gAudioContext.seqPlayers[playerIndex].skipTicks = 0; + AudioLoad_SyncInitSeqPlayerInternal(playerIndex, seqId, arg2); // Intentionally missing return. Returning the result of the above function // call matches but is UB because it too is missing a return, and using the // result of a non-void function that has failed to return a value is UB. // The callers of this function do not use the return value, so it's fine. } -s32 AudioLoad_SyncInitSeqPlayerSkipTicks(s32 playerIdx, s32 seqId, s32 skipTicks) { +s32 AudioLoad_SyncInitSeqPlayerSkipTicks(s32 playerIndex, s32 seqId, s32 skipTicks) { if (gAudioContext.resetTimer != 0) { return 0; } - gAudioContext.seqPlayers[playerIdx].skipTicks = skipTicks; - AudioLoad_SyncInitSeqPlayerInternal(playerIdx, seqId, 0); + gAudioContext.seqPlayers[playerIndex].skipTicks = skipTicks; + AudioLoad_SyncInitSeqPlayerInternal(playerIndex, seqId, 0); // Missing return, see above. } -s32 AudioLoad_SyncInitSeqPlayerInternal(s32 playerIdx, s32 seqId, s32 arg2) { - SequencePlayer* seqPlayer = &gAudioContext.seqPlayers[playerIdx]; +s32 AudioLoad_SyncInitSeqPlayerInternal(s32 playerIndex, s32 seqId, s32 arg2) { + SequencePlayer* seqPlayer = &gAudioContext.seqPlayers[playerIndex]; u8* seqData; s32 index; s32 numFonts; @@ -618,7 +621,7 @@ s32 AudioLoad_SyncInitSeqPlayerInternal(s32 playerIdx, s32 seqId, s32 arg2) { seqPlayer->scriptState.depth = 0; seqPlayer->delay = 0; seqPlayer->finished = false; - seqPlayer->playerIdx = playerIdx; + seqPlayer->playerIndex = playerIndex; //! @bug missing return (but the return value is not used so it's not UB) } @@ -626,7 +629,7 @@ u8* AudioLoad_SyncLoadSeq(s32 seqId) { s32 pad; s32 didAllocate; - if (gAudioContext.seqLoadStatus[AudioLoad_GetRealTableIndex(SEQUENCE_TABLE, seqId)] == LOAD_STATUS_1) { + if (gAudioContext.seqLoadStatus[AudioLoad_GetRealTableIndex(SEQUENCE_TABLE, seqId)] == LOAD_STATUS_IN_PROGRESS) { return NULL; } @@ -647,8 +650,8 @@ u32 AudioLoad_TrySyncLoadSampleBank(u32 sampleBankId, u32* outMedium, s32 noLoad addr = AudioLoad_SearchCaches(SAMPLE_TABLE, realTableId); if (addr != NULL) { - if (gAudioContext.sampleFontLoadStatus[realTableId] != LOAD_STATUS_1) { - AudioLoad_SetSampleFontLoadStatus(realTableId, LOAD_STATUS_2); + if (gAudioContext.sampleFontLoadStatus[realTableId] != LOAD_STATUS_IN_PROGRESS) { + AudioLoad_SetSampleFontLoadStatus(realTableId, LOAD_STATUS_COMPLETE); } *outMedium = MEDIUM_RAM; @@ -680,7 +683,7 @@ SoundFontData* AudioLoad_SyncLoadFont(u32 fontId) { AudioRelocInfo relocInfo; s32 realFontId = AudioLoad_GetRealTableIndex(FONT_TABLE, fontId); - if (gAudioContext.fontLoadStatus[realFontId] == LOAD_STATUS_1) { + if (gAudioContext.fontLoadStatus[realFontId] == LOAD_STATUS_IN_PROGRESS) { return NULL; } @@ -728,7 +731,7 @@ void* AudioLoad_SyncLoad(s32 tableType, u32 id, s32* didAllocate) { ramAddr = AudioLoad_SearchCaches(tableType, realId); if (ramAddr != NULL) { *didAllocate = false; - loadStatus = LOAD_STATUS_2; + loadStatus = LOAD_STATUS_COMPLETE; } else { table = AudioLoad_GetLoadTable(tableType); size = table->entries[realId].size; @@ -791,7 +794,7 @@ void* AudioLoad_SyncLoad(s32 tableType, u32 id, s32* didAllocate) { AudioLoad_SyncDma(romAddr, ramAddr, size, medium); } - loadStatus = (cachePolicy == CACHE_LOAD_PERMANENT) ? LOAD_STATUS_5 : LOAD_STATUS_2; + loadStatus = (cachePolicy == CACHE_LOAD_PERMANENT) ? LOAD_STATUS_PERMANENT : LOAD_STATUS_COMPLETE; } switch (tableType) { @@ -1030,19 +1033,19 @@ void* AudioLoad_AsyncLoadInner(s32 tableType, s32 id, s32 nChunks, s32 retData, switch (tableType) { case SEQUENCE_TABLE: - if (gAudioContext.seqLoadStatus[realId] == LOAD_STATUS_1) { + if (gAudioContext.seqLoadStatus[realId] == LOAD_STATUS_IN_PROGRESS) { return NULL; } break; case FONT_TABLE: - if (gAudioContext.fontLoadStatus[realId] == LOAD_STATUS_1) { + if (gAudioContext.fontLoadStatus[realId] == LOAD_STATUS_IN_PROGRESS) { return NULL; } break; case SAMPLE_TABLE: - if (gAudioContext.sampleFontLoadStatus[realId] == LOAD_STATUS_1) { + if (gAudioContext.sampleFontLoadStatus[realId] == LOAD_STATUS_IN_PROGRESS) { return NULL; } break; @@ -1050,8 +1053,8 @@ void* AudioLoad_AsyncLoadInner(s32 tableType, s32 id, s32 nChunks, s32 retData, ramAddr = AudioLoad_SearchCaches(tableType, realId); if (ramAddr != NULL) { - loadStatus = LOAD_STATUS_2; - osSendMesg(retQueue, MK_ASYNC_MSG(retData, 0, 0, LOAD_STATUS_0), OS_MESG_NOBLOCK); + loadStatus = LOAD_STATUS_COMPLETE; + osSendMesg(retQueue, MK_ASYNC_MSG(retData, 0, 0, LOAD_STATUS_NOT_LOADED), OS_MESG_NOBLOCK); } else { table = AudioLoad_GetLoadTable(tableType); size = table->entries[realId].size; @@ -1059,7 +1062,7 @@ void* AudioLoad_AsyncLoadInner(s32 tableType, s32 id, s32 nChunks, s32 retData, medium = table->entries[id].medium; cachePolicy = table->entries[id].cachePolicy; romAddr = table->entries[realId].romAddr; - loadStatus = LOAD_STATUS_2; + loadStatus = LOAD_STATUS_COMPLETE; switch (cachePolicy) { case CACHE_LOAD_PERMANENT: @@ -1067,7 +1070,7 @@ void* AudioLoad_AsyncLoadInner(s32 tableType, s32 id, s32 nChunks, s32 retData, if (ramAddr == NULL) { return ramAddr; } - loadStatus = LOAD_STATUS_5; + loadStatus = LOAD_STATUS_PERMANENT; break; case CACHE_LOAD_PERSISTENT: @@ -1117,7 +1120,7 @@ void* AudioLoad_AsyncLoadInner(s32 tableType, s32 id, s32 nChunks, s32 retData, MK_ASYNC_MSG(retData, tableType, realId, loadStatus)); } - loadStatus = LOAD_STATUS_1; + loadStatus = LOAD_STATUS_IN_PROGRESS; } switch (tableType) { @@ -1205,7 +1208,7 @@ void AudioLoad_Init(void* heap, size_t heapSize) { gAudioContext.refreshRate = 60; } - Audio_InitMesgQueues(); + AudioThread_InitMesgQueues(); for (i = 0; i < ARRAY_COUNT(gAudioContext.aiBufLengths); i++) { gAudioContext.aiBufLengths[i] = 0xA0; @@ -1214,7 +1217,7 @@ void AudioLoad_Init(void* heap, size_t heapSize) { gAudioContext.totalTaskCount = 0; gAudioContext.rspTaskIndex = 0; gAudioContext.curAiBuffferIndex = 0; - gAudioContext.soundMode = AUDIO_MODE_STEREO; + gAudioContext.soundMode = SOUNDMODE_STEREO; gAudioContext.curTask = NULL; gAudioContext.rspTask[0].task.t.dataSize = 0; gAudioContext.rspTask[1].task.t.dataSize = 0; diff --git a/src/code/audio/audio_playback.c b/src/code/audio/audio_playback.c index 6ae5696f1..e7f5153ac 100644 --- a/src/code/audio/audio_playback.c +++ b/src/code/audio/audio_playback.c @@ -34,7 +34,7 @@ void AudioPlayback_InitNoteSub(Note* note, NoteSubEu* sub, NoteSubAttributes* at sub->bitField0.stereoStrongLeft = false; sub->bitField0.stereoHeadsetEffects = stereoData.stereoHeadsetEffects; sub->bitField0.usesHeadsetPanEffects = stereoData.usesHeadsetPanEffects; - if (stereoHeadsetEffects && gAudioContext.soundMode == AUDIO_MODE_HEADSET) { + if (stereoHeadsetEffects && gAudioContext.soundMode == SOUNDMODE_HEADSET) { smallPanIndex = pan >> 1; if (smallPanIndex > 0x3F) { smallPanIndex = 0x3F; @@ -46,7 +46,7 @@ void AudioPlayback_InitNoteSub(Note* note, NoteSubEu* sub, NoteSubAttributes* at volLeft = gHeadsetPanVolume[pan]; volRight = gHeadsetPanVolume[0x7F - pan]; - } else if (stereoHeadsetEffects && gAudioContext.soundMode == AUDIO_MODE_STEREO) { + } else if (stereoHeadsetEffects && gAudioContext.soundMode == SOUNDMODE_STEREO) { strongLeft = strongRight = false; sub->headsetPanRight = 0; sub->headsetPanLeft = 0; @@ -80,7 +80,7 @@ void AudioPlayback_InitNoteSub(Note* note, NoteSubEu* sub, NoteSubAttributes* at break; } - } else if (gAudioContext.soundMode == AUDIO_MODE_MONO) { + } else if (gAudioContext.soundMode == SOUNDMODE_MONO) { sub->bitField0.stereoHeadsetEffects = false; sub->bitField0.usesHeadsetPanEffects = false; volLeft = 0.707f; // approx 1/sqrt(2) @@ -98,7 +98,7 @@ void AudioPlayback_InitNoteSub(Note* note, NoteSubEu* sub, NoteSubAttributes* at sub->targetVolLeft = (s32)((vel * volLeft) * (0x1000 - 0.001f)); sub->targetVolRight = (s32)((vel * volRight) * (0x1000 - 0.001f)); - sub->unk_2 = attrs->unk_1; + sub->gain = attrs->gain; sub->filter = attrs->filter; sub->unk_07 = attrs->unk_14; sub->unk_0E = attrs->unk_16; @@ -125,7 +125,7 @@ void AudioPlayback_NoteSetResamplingRate(NoteSubEu* noteSubEu, f32 resamplingRat } void AudioPlayback_NoteInit(Note* note) { - if (note->playbackState.parentLayer->adsr.releaseRate == 0) { + if (note->playbackState.parentLayer->adsr.decayIndex == 0) { AudioEffects_AdsrInit(¬e->playbackState.adsr, note->playbackState.parentLayer->channel->adsr.envelope, ¬e->playbackState.adsrVolScaleUnused); } else { @@ -189,7 +189,7 @@ void AudioPlayback_ProcessNotes(void) { playbackState->unk_04 = 1; continue; } else if (playbackState->parentLayer->channel->seqPlayer->muted && - (playbackState->parentLayer->channel->muteBehavior & 0x40)) { + (playbackState->parentLayer->channel->muteFlags & MUTE_FLAGS_STOP_NOTES)) { // do nothing } else { goto out; @@ -257,7 +257,7 @@ void AudioPlayback_ProcessNotes(void) { subAttrs.pan = attrs->pan; subAttrs.reverbVol = attrs->reverb; subAttrs.stereo = attrs->stereo; - subAttrs.unk_1 = attrs->unk_1; + subAttrs.gain = attrs->gain; subAttrs.filter = attrs->filter; subAttrs.unk_14 = attrs->unk_4; subAttrs.unk_16 = attrs->unk_6; @@ -290,9 +290,9 @@ void AudioPlayback_ProcessNotes(void) { } if (layer->unk_0A.s.bit_9 == 1) { - subAttrs.unk_1 = channel->unk_0C; + subAttrs.gain = channel->gain; } else { - subAttrs.unk_1 = 0; + subAttrs.gain = 0; if (1) {} } @@ -301,7 +301,7 @@ void AudioPlayback_ProcessNotes(void) { subAttrs.unk_16 = channel->unk_20; bookOffset = channel->bookOffset & 0x7; - if (channel->seqPlayer->muted && (channel->muteBehavior & 8)) { + if (channel->seqPlayer->muted && (channel->muteFlags & MUTE_FLAGS_3)) { subAttrs.frequency = 0.0f; subAttrs.velocity = 0.0f; } @@ -506,9 +506,9 @@ void AudioPlayback_SeqLayerDecayRelease(SequenceLayer* layer, s32 target) { } if (layer->unk_0A.s.bit_9 == 1) { - attrs->unk_1 = chan->unk_0C; + attrs->gain = chan->gain; } else { - attrs->unk_1 = 0; + attrs->gain = 0; } attrs->filter = chan->filter; @@ -522,7 +522,7 @@ void AudioPlayback_SeqLayerDecayRelease(SequenceLayer* layer, s32 target) { attrs->unk_6 = chan->unk_20; attrs->unk_4 = chan->unk_0F; - if (chan->seqPlayer->muted && (chan->muteBehavior & 8)) { + if (chan->seqPlayer->muted && (chan->muteFlags & MUTE_FLAGS_3)) { note->noteSubEu.bitField0.finished = true; } @@ -546,10 +546,10 @@ void AudioPlayback_SeqLayerDecayRelease(SequenceLayer* layer, s32 target) { } else { note->playbackState.unk_04 = 1; note->playbackState.adsr.action.s.decay = true; - if (layer->adsr.releaseRate == 0) { - note->playbackState.adsr.fadeOutVel = gAudioContext.unk_3520[layer->channel->adsr.releaseRate]; + if (layer->adsr.decayIndex == 0) { + note->playbackState.adsr.fadeOutVel = gAudioContext.adsrDecayTable[layer->channel->adsr.decayIndex]; } else { - note->playbackState.adsr.fadeOutVel = gAudioContext.unk_3520[layer->adsr.releaseRate]; + note->playbackState.adsr.fadeOutVel = gAudioContext.adsrDecayTable[layer->adsr.decayIndex]; } note->playbackState.adsr.sustain = ((f32)(s32)(layer->channel->adsr.sustain) * note->playbackState.adsr.current) / 256.0f; diff --git a/src/code/audio/audio_seqplayer.c b/src/code/audio/audio_seqplayer.c index e57ad19b5..ebcc9a8d1 100644 --- a/src/code/audio/audio_seqplayer.c +++ b/src/code/audio/audio_seqplayer.c @@ -1,73 +1,2312 @@ +/** + * @file audio_seqplayer.c + * + * Manages audio sequence players, interprets and executes sequence instructions used to write .seq files + * + * Sequence Instructions: + * - A customized assembly language based on MIDI + * - All sequences are written using these instructions + * - There are 3 different sets of instructions + * 1) Sequence Instructions + * 2) Channel Instructions + * 3) Layer Instruction + * - All three sets share a common pool of control flow instructions (>= 0xF2). + * Otherwise, each set of instructions has its own command interpreter + */ #include "global.h" -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_seqplayer/func_801974D0.s") +#define PORTAMENTO_IS_SPECIAL(x) ((x).mode & 0x80) +#define PORTAMENTO_MODE(x) ((x).mode & ~0x80) -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_seqplayer/func_80197538.s") +#define PROCESS_SCRIPT_END -1 -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_seqplayer/func_80197714.s") +typedef enum { + /* 0 */ PORTAMENTO_MODE_OFF, + /* 1 */ PORTAMENTO_MODE_1, + /* 2 */ PORTAMENTO_MODE_2, + /* 3 */ PORTAMENTO_MODE_3, + /* 4 */ PORTAMENTO_MODE_4, + /* 5 */ PORTAMENTO_MODE_5 +} PortamentoMode; -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_seqplayer/func_80197880.s") +u8 AudioSeq_ScriptReadU8(SeqScriptState* state); +s16 AudioSeq_ScriptReadS16(SeqScriptState* state); +u16 AudioSeq_ScriptReadCompressedU16(SeqScriptState* state); +void AudioSeq_SeqLayerProcessScriptStep1(SequenceLayer* layer); +s32 AudioSeq_SeqLayerProcessScriptStep5(SequenceLayer* layer, s32 sameSound); +s32 AudioSeq_SeqLayerProcessScriptStep2(SequenceLayer* layer); +s32 AudioSeq_SeqLayerProcessScriptStep4(SequenceLayer* layer, s32 cmd); +s32 AudioSeq_SeqLayerProcessScriptStep3(SequenceLayer* layer, s32 cmd); +u8 AudioSeq_GetInstrument(SequenceChannel* channel, u8 instId, Instrument** instOut, AdsrSettings* adsr); -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_seqplayer/func_801979D8.s") +/** + * sSeqInstructionArgsTable is a table for each sequence instruction + * that contains both how many arguments an instruction takes, as well + * as the type of each argument + * + * sSeqInstructionArgsTable is bitpacked as follows: + * abcUUUnn + * + * n - number of arguments that the sequence instruction takes + * + * a - bitFlag for the type of arg0 if it exists + * b - bitFlag for the type of arg1 if it exists + * c - bitFlag for the type of arg2 if it exists + * + * bitFlag on - argument is s16 + * bitFlag off - argument is u8 + * + * U - Unused + */ -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_seqplayer/func_80197A54.s") +// CMD_ARGS_(NUMBER_OF_ARGS) +#define CMD_ARGS_0() 0 +#define CMD_ARGS_1(arg0Type) (((sizeof(arg0Type) - 1) << 7) | 1) +#define CMD_ARGS_2(arg0Type, arg1Type) (((sizeof(arg0Type) - 1) << 7) | ((sizeof(arg1Type) - 1) << 6) | 2) +#define CMD_ARGS_3(arg0Type, arg1Type, arg2Type) \ + (((sizeof(arg0Type) - 1) << 7) | ((sizeof(arg1Type) - 1) << 6) | ((sizeof(arg2Type) - 1) << 5) | 3) -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_seqplayer/AudioSeq_SequenceChannelDisable.s") +u8 sSeqInstructionArgsTable[] = { + CMD_ARGS_1(s16), // 0xA0 (channel:) + CMD_ARGS_0(), // 0xA1 (channel:) + CMD_ARGS_1(s16), // 0xA2 (channel:) + CMD_ARGS_0(), // 0xA3 (channel:) + CMD_ARGS_1(u8), // 0xA4 (channel:) + CMD_ARGS_0(), // 0xA5 (channel:) + CMD_ARGS_2(u8, s16), // 0xA6 (channel:) + CMD_ARGS_1(u8), // 0xA7 (channel:) + CMD_ARGS_2(s16, s16), // 0xA8 (channel: random range large) + CMD_ARGS_0(), // 0xA9 () + CMD_ARGS_0(), // 0xAA () + CMD_ARGS_0(), // 0xAB () + CMD_ARGS_0(), // 0xAC () + CMD_ARGS_0(), // 0xAD () + CMD_ARGS_0(), // 0xAE () + CMD_ARGS_0(), // 0xAF () + CMD_ARGS_1(s16), // 0xB0 (channel: set filter) + CMD_ARGS_0(), // 0xB1 (channel: clear filter) + CMD_ARGS_1(s16), // 0xB2 (channel: dynread sequence large) + CMD_ARGS_1(u8), // 0xB3 (channel: load filter) + CMD_ARGS_0(), // 0xB4 (channel: set dyntable large) + CMD_ARGS_0(), // 0xB5 (channel: read dyntable large) + CMD_ARGS_0(), // 0xB6 (channel: read dyntable) + CMD_ARGS_1(s16), // 0xB7 (channel: random large) + CMD_ARGS_1(u8), // 0xB8 (channel: random) + CMD_ARGS_1(u8), // 0xB9 (channel: set velocity random variance) + CMD_ARGS_1(u8), // 0xBA (channel: set gatetime random variance) + CMD_ARGS_2(u8, s16), // 0xBB (channel:) + CMD_ARGS_1(s16), // 0xBC (channel: add large) + CMD_ARGS_1(s16), // 0xBD (channel:) + CMD_ARGS_1(u8), // 0xBE (channel:) + CMD_ARGS_0(), // 0xBF () + CMD_ARGS_0(), // 0xC0 () + CMD_ARGS_1(u8), // 0xC1 (channel: set instrument) + CMD_ARGS_1(s16), // 0xC2 (channel: set dyntable) + CMD_ARGS_0(), // 0xC3 (channel: large notes off) + CMD_ARGS_0(), // 0xC4 (channel: large notes on) + CMD_ARGS_0(), // 0xC5 (channel: dyn set dyntable) + CMD_ARGS_1(u8), // 0xC6 (channel: set soundFont) + CMD_ARGS_2(u8, s16), // 0xC7 (channel: write into sequence script) + CMD_ARGS_1(u8), // 0xC8 (channel: subtract -> set value) + CMD_ARGS_1(u8), // 0xC9 (channel: `bit and` -> set value) + CMD_ARGS_1(u8), // 0xCA (channel: set mute behavior) + CMD_ARGS_1(s16), // 0xCB (channel: read sequence -> set value) + CMD_ARGS_1(u8), // 0xCC (channel: set value) + CMD_ARGS_1(u8), // 0xCD (channel: disable channel) + CMD_ARGS_1(s16), // 0xCE (channel:) + CMD_ARGS_1(s16), // 0xCF (channel: write large into sequence script) + CMD_ARGS_1(u8), // 0xD0 (channel: stereo headset effects) + CMD_ARGS_1(u8), // 0xD1 (channel: set note allocation policy) + CMD_ARGS_1(u8), // 0xD2 (channel: set sustain) + CMD_ARGS_1(u8), // 0xD3 (channel: large bend pitch) + CMD_ARGS_1(u8), // 0xD4 (channel: set reverb) + CMD_ARGS_1(u8), // 0xD5 () + CMD_ARGS_1(u8), // 0xD6 () + CMD_ARGS_1(u8), // 0xD7 (channel: set vibrato rate) + CMD_ARGS_1(u8), // 0xD8 (channel: set vibrato extent) + CMD_ARGS_1(u8), // 0xD9 (channel: set decay index) + CMD_ARGS_1(s16), // 0xDA (channel: set envelope) + CMD_ARGS_1(u8), // 0xDB (channel: transpose) + CMD_ARGS_1(u8), // 0xDC (channel: set pan mix) + CMD_ARGS_1(u8), // 0xDD (channel: set pan) + CMD_ARGS_1(s16), // 0xDE (channel: set freqscale) + CMD_ARGS_1(u8), // 0xDF (channel: set volume) + CMD_ARGS_1(u8), // 0xE0 (channel: set volume scale) + CMD_ARGS_3(u8, u8, u8), // 0xE1 (channel: set vibratorate linear) + CMD_ARGS_3(u8, u8, u8), // 0xE2 (channel: set vibrato extent linear) + CMD_ARGS_1(u8), // 0xE3 (channel: set vibrato delay) + CMD_ARGS_0(), // 0xE4 (channel: dyncall) + CMD_ARGS_1(u8), // 0xE5 (channel: set reverb index) + CMD_ARGS_1(u8), // 0xE6 (channel: set book offset) + CMD_ARGS_1(s16), // 0xE7 (channel:) + CMD_ARGS_3(u8, u8, u8), // 0xE8 (channel:) + CMD_ARGS_1(u8), // 0xE9 (channel: set note priority) + CMD_ARGS_0(), // 0xEA (channel: stop script) + CMD_ARGS_2(u8, u8), // 0xEB (channel: set soundFont and instrument) + CMD_ARGS_0(), // 0xEC (channel: reset vibrato) + CMD_ARGS_1(u8), // 0xED (channel: set hilo gain) + CMD_ARGS_1(u8), // 0xEE (channel: small bend pitch) + CMD_ARGS_2(s16, u8), // 0xEF () + CMD_ARGS_0(), // 0xF0 (channel: unreserve notes) + CMD_ARGS_1(u8), // 0xF1 (channel: reserve notes) + // Control flow instructions (>= 0xF2) can only have 0 or 1 args + CMD_ARGS_1(u8), // 0xF2 (branch relative if less than zero) + CMD_ARGS_1(u8), // 0xF3 (branch relative if equal to zero) + CMD_ARGS_1(u8), // 0xF4 (jump relative) + CMD_ARGS_1(s16), // 0xF5 (branch if greater than or equal to zero) + CMD_ARGS_0(), // 0xF6 (break) + CMD_ARGS_0(), // 0xF7 (loop end) + CMD_ARGS_1(u8), // 0xF8 (loop) + CMD_ARGS_1(s16), // 0xF9 (branch if less than zero) + CMD_ARGS_1(s16), // 0xFA (branch if equal to zero) + CMD_ARGS_1(s16), // 0xFB (jump) + CMD_ARGS_1(s16), // 0xFC (call and jump to a function) + CMD_ARGS_0(), // 0xFD (delay n frames) + CMD_ARGS_0(), // 0xFE (delay 1 frame) + CMD_ARGS_0(), // 0xFF (end script) +}; -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_seqplayer/func_80197B14.s") +/** + * Read and return the argument from the sequence script for a control flow instruction. + * Control flow instructions (>= 0xF2) can only have 0 or 1 args. + * + * @return the argument value for a control flow instruction, or 0 if there is no argument + */ +u16 AudioSeq_GetScriptControlFlowArgument(SeqScriptState* state, u8 cmd) { + u8 highBits = sSeqInstructionArgsTable[cmd - 0xA0]; + u8 lowBits = highBits & 3; + u16 cmdArg = 0; -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_seqplayer/func_80197C0C.s") + // only 1 argument + if (lowBits == 1) { + if (!(highBits & 0x80)) { + cmdArg = AudioSeq_ScriptReadU8(state); + } else { + cmdArg = AudioSeq_ScriptReadS16(state); + } + } -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_seqplayer/func_80197C8C.s") + return cmdArg; +} -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_seqplayer/AudioSeq_SequencePlayerDisableAsFinished.s") +/** + * Read and execute the control flow sequence instructions + * + * @return number of frames until next instruction. -1 signals termination + */ +s32 AudioSeq_HandleScriptFlowControl(SequencePlayer* seqPlayer, SeqScriptState* state, s32 cmd, s32 cmdArg) { + u32 depth; -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_seqplayer/AudioSeq_SequencePlayerDisable.s") + switch (cmd) { + case 0xFF: // end script + if (state->depth == 0) { + return PROCESS_SCRIPT_END; + } + state->pc = state->stack[--state->depth]; + break; -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_seqplayer/AudioSeq_AudioListPushBack.s") + case 0xFD: // delay n frames + return AudioSeq_ScriptReadCompressedU16(state); -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_seqplayer/AudioSeq_AudioListPopBack.s") + case 0xFE: // delay 1 frame + return 1; -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_seqplayer/func_80197E88.s") + case 0xFC: // call and jump to a function + state->stack[depth = state->depth++] = state->pc; + state->pc = seqPlayer->seqData + (u16)cmdArg; + break; -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_seqplayer/func_80197F28.s") + case 0xF8: // loop + state->remLoopIters[depth = state->depth] = cmdArg; + state->stack[state->depth++] = state->pc; + break; -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_seqplayer/func_80197F3C.s") + case 0xF7: // loop end + state->remLoopIters[state->depth - 1]--; + if (state->remLoopIters[state->depth - 1] != 0) { + state->pc = state->stack[state->depth - 1]; + } else { + state->depth--; + } + break; -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_seqplayer/func_80197F74.s") + case 0xF6: // break + state->depth--; + break; -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_seqplayer/func_80197FB4.s") + case 0xF5: // branch if greater than or equal to zero + case 0xF9: // branch if less than zero + case 0xFA: // branch if equal to zero + case 0xFB: // jump + if ((cmd == 0xFA) && (state->value != 0)) { + break; + } + if ((cmd == 0xF9) && (state->value >= 0)) { + break; + } + if ((cmd == 0xF5) && (state->value < 0)) { + break; + } + state->pc = seqPlayer->seqData + (u16)cmdArg; + break; -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_seqplayer/func_801980D0.s") + case 0xF2: // branch relative if less than zero + case 0xF3: // branch relative if equal to zero + case 0xF4: // jump relative + if ((cmd == 0xF3) && (state->value != 0)) { + break; + } + if ((cmd == 0xF2) && (state->value >= 0)) { + break; + } + state->pc += (s8)(cmdArg & 0xFF); + break; + } -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_seqplayer/func_8019815C.s") + return 0; +} -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_seqplayer/func_8019825C.s") +void AudioSeq_InitSequenceChannel(SequenceChannel* channel) { + s32 i; -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_seqplayer/func_80198640.s") + if (channel == &gAudioContext.sequenceChannelNone) { + return; + } -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_seqplayer/func_80198CE0.s") + channel->enabled = false; + channel->finished = false; + channel->stopScript = false; + channel->stopSomething2 = false; + channel->hasInstrument = false; + channel->stereoHeadsetEffects = false; + channel->transposition = 0; + channel->largeNotes = false; + channel->bookOffset = 0; + channel->stereo.asByte = 0; + channel->changes.asByte = 0xFF; + channel->scriptState.depth = 0; + channel->newPan = 0x40; + channel->panChannelWeight = 0x80; + channel->unk_10 = 0xFF; + channel->velocityRandomVariance = 0; + channel->gateTimeRandomVariance = 0; + channel->noteUnused = NULL; + channel->reverbIndex = 0; + channel->reverb = 0; + channel->gain = 0; + channel->notePriority = 3; + channel->someOtherPriority = 1; + channel->delay = 0; + channel->adsr.envelope = gDefaultEnvelope; + channel->adsr.decayIndex = 0xF0; + channel->adsr.sustain = 0; + channel->vibrato.vibratoRateTarget = 0x800; + channel->vibrato.vibratoRateStart = 0x800; + channel->vibrato.vibratoExtentTarget = 0; + channel->vibrato.vibratoExtentStart = 0; + channel->vibrato.vibratoRateChangeDelay = 0; + channel->vibrato.vibratoExtentChangeDelay = 0; + channel->vibrato.vibratoDelay = 0; + channel->filter = NULL; + channel->unk_20 = 0; + channel->unk_0F = 0; + channel->volume = 1.0f; + channel->volumeScale = 1.0f; + channel->freqScale = 1.0f; -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_seqplayer/func_801990F4.s") + for (i = 0; i < ARRAY_COUNT(channel->soundScriptIO); i++) { + channel->soundScriptIO[i] = -1; + } -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_seqplayer/func_80199124.s") + channel->unused = false; + AudioPlayback_InitNoteLists(&channel->notePool); + channel->unk_DC = 0; + channel->unk_E0 = 0; + channel->sfxState = NULL; +} -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_seqplayer/func_80199198.s") +s32 AudioSeq_SeqChannelSetLayer(SequenceChannel* channel, s32 layerIndex) { + SequenceLayer* layer; + s32 pad; -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_seqplayer/func_80199244.s") + if (channel->layers[layerIndex] == NULL) { + layer = AudioSeq_AudioListPopBack(&gAudioContext.layerFreeList); + channel->layers[layerIndex] = layer; + if (layer == NULL) { + channel->layers[layerIndex] = NULL; + return -1; + } + } else { + AudioPlayback_SeqLayerNoteDecay(channel->layers[layerIndex]); + } -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_seqplayer/func_80199268.s") + layer = channel->layers[layerIndex]; -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_seqplayer/func_8019A0BC.s") + layer->channel = channel; + layer->adsr = channel->adsr; + layer->adsr.decayIndex = 0; + layer->unk_09 = channel->reverb; + layer->enabled = true; + layer->finished = false; + layer->stopSomething = false; + layer->continuousNotes = false; + layer->bit3 = false; + layer->ignoreDrumPan = false; + layer->bit1 = false; + layer->notePropertiesNeedInit = false; + layer->gateTime = 0x80; + layer->unk_08 = 0x80; + layer->stereo.asByte = 0; + layer->portamento.mode = PORTAMENTO_MODE_OFF; + layer->scriptState.depth = 0; + layer->pan = 0x40; + layer->transposition = 0; + layer->delay = 0; + layer->gateDelay = 0; + layer->delay2 = 0; + layer->note = NULL; + layer->instrument = NULL; + layer->instOrWave = 0xFF; + layer->unk_0A.asByte = 0xFFFF; + layer->vibrato.vibratoRateTarget = 0x800; + layer->vibrato.vibratoRateStart = 0x800; + layer->vibrato.vibratoExtentTarget = 0; + layer->vibrato.vibratoExtentStart = 0; + layer->vibrato.vibratoRateChangeDelay = 0; + layer->vibrato.vibratoExtentChangeDelay = 0; + layer->vibrato.vibratoDelay = 0; + layer->freqScale = 1.0f; + layer->bend = 1.0f; + layer->velocitySquare2 = 0.0f; -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_seqplayer/func_8019AA3C.s") + return 0; +} -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_seqplayer/func_8019AAF0.s") +void AudioSeq_SeqLayerDisable(SequenceLayer* layer) { + if (layer != NULL) { + if ((layer->channel != &gAudioContext.sequenceChannelNone) && (layer->channel->seqPlayer->finished == true)) { + AudioPlayback_SeqLayerNoteRelease(layer); + } else { + AudioPlayback_SeqLayerNoteDecay(layer); + } + layer->enabled = false; + layer->finished = true; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_seqplayer/AudioSeq_ResetSequencePlayer.s") +void AudioSeq_SeqLayerFree(SequenceChannel* channel, s32 layerIndex) { + SequenceLayer* layer = channel->layers[layerIndex]; -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_seqplayer/AudioSeq_InitSequencePlayerChannels.s") + if (layer != NULL) { + AudioSeq_AudioListPushBack(&gAudioContext.layerFreeList, &layer->listItem); + AudioSeq_SeqLayerDisable(layer); + channel->layers[layerIndex] = NULL; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_seqplayer/func_8019ACEC.s") +void AudioSeq_SequenceChannelDisable(SequenceChannel* channel) { + s32 i; -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_seqplayer/AudioSeq_InitSequencePlayers.s") + channel->finished = true; + + for (i = 0; i < 4; i++) { + AudioSeq_SeqLayerFree(channel, i); + } + + AudioPlayback_NotePoolClear(&channel->notePool); + channel->enabled = false; +} + +void AudioSeq_SequencePlayerSetupChannels(SequencePlayer* seqPlayer, u16 channelBits) { + SequenceChannel* channel; + s32 i; + + for (i = 0; i < SEQ_NUM_CHANNELS; i++) { + if (channelBits & 1) { + channel = seqPlayer->channels[i]; + channel->fontId = seqPlayer->defaultFont; + channel->muteFlags = seqPlayer->muteFlags; + channel->noteAllocPolicy = seqPlayer->noteAllocPolicy; + } + channelBits = channelBits >> 1; + } +} + +void AudioSeq_SequencePlayerDisableChannels(SequencePlayer* seqPlayer, u16 channelBitsUnused) { + SequenceChannel* channel; + s32 i; + + for (i = 0; i < SEQ_NUM_CHANNELS; i++) { + channel = seqPlayer->channels[i]; + if (IS_SEQUENCE_CHANNEL_VALID(channel) == 1) { + AudioSeq_SequenceChannelDisable(channel); + } + } +} + +void AudioSeq_SequenceChannelEnable(SequencePlayer* seqPlayer, u8 channelIndex, void* script) { + SequenceChannel* channel = seqPlayer->channels[channelIndex]; + s32 i; + + channel->enabled = true; + channel->finished = false; + channel->scriptState.depth = 0; + channel->scriptState.pc = script; + channel->delay = 0; + + for (i = 0; i < ARRAY_COUNT(channel->layers); i++) { + if (channel->layers[i] != NULL) { + AudioSeq_SeqLayerFree(channel, i); + } + } +} + +void AudioSeq_SequencePlayerDisableAsFinished(SequencePlayer* seqPlayer) { + seqPlayer->finished = true; + AudioSeq_SequencePlayerDisable(seqPlayer); +} + +void AudioSeq_SequencePlayerDisable(SequencePlayer* seqPlayer) { + AudioSeq_SequencePlayerDisableChannels(seqPlayer, 0xFFFF); + AudioPlayback_NotePoolClear(&seqPlayer->notePool); + if (!seqPlayer->enabled) { + return; + } + + seqPlayer->enabled = false; + seqPlayer->finished = true; + + if (AudioLoad_IsSeqLoadComplete(seqPlayer->seqId)) { + AudioLoad_SetSeqLoadStatus(seqPlayer->seqId, LOAD_STATUS_DISCARDABLE); + } + + if (AudioLoad_IsFontLoadComplete(seqPlayer->defaultFont)) { + AudioLoad_SetFontLoadStatus(seqPlayer->defaultFont, LOAD_STATUS_MAYBE_DISCARDABLE); + } + + if (seqPlayer->defaultFont == gAudioContext.fontCache.temporary.entries[0].id) { + gAudioContext.fontCache.temporary.nextSide = 1; + } else if (seqPlayer->defaultFont == gAudioContext.fontCache.temporary.entries[1].id) { + gAudioContext.fontCache.temporary.nextSide = 0; + } +} + +void AudioSeq_AudioListPushBack(AudioListItem* list, AudioListItem* item) { + if (item->prev == NULL) { + list->prev->next = item; + item->prev = list->prev; + item->next = list; + list->prev = item; + list->u.count++; + item->pool = list->pool; + } +} + +void* AudioSeq_AudioListPopBack(AudioListItem* list) { + AudioListItem* item = list->prev; + + if (item == list) { + return NULL; + } + + item->prev->next = list; + list->prev = item->prev; + item->prev = NULL; + list->u.count--; + + return item->u.value; +} + +void AudioSeq_InitLayerFreelist(void) { + s32 i; + + gAudioContext.layerFreeList.prev = &gAudioContext.layerFreeList; + gAudioContext.layerFreeList.next = &gAudioContext.layerFreeList; + gAudioContext.layerFreeList.u.count = 0; + gAudioContext.layerFreeList.pool = NULL; + + for (i = 0; i < ARRAY_COUNT(gAudioContext.sequenceLayers); i++) { + gAudioContext.sequenceLayers[i].listItem.u.value = &gAudioContext.sequenceLayers[i]; + gAudioContext.sequenceLayers[i].listItem.prev = NULL; + AudioSeq_AudioListPushBack(&gAudioContext.layerFreeList, &gAudioContext.sequenceLayers[i].listItem); + } +} + +u8 AudioSeq_ScriptReadU8(SeqScriptState* state) { + return *(state->pc++); +} + +s16 AudioSeq_ScriptReadS16(SeqScriptState* state) { + s16 ret = *(state->pc++) << 8; + + ret = *(state->pc++) | ret; + return ret; +} + +u16 AudioSeq_ScriptReadCompressedU16(SeqScriptState* state) { + u16 ret = *(state->pc++); + + if (ret & 0x80) { + ret = (ret << 8) & 0x7F00; + ret = *(state->pc++) | ret; + } + return ret; +} + +void AudioSeq_SeqLayerProcessScript(SequenceLayer* layer) { + s32 cmd; + + if (!layer->enabled) { + return; + } + + if (layer->delay > 1) { + layer->delay--; + if (!layer->stopSomething && (layer->delay <= layer->gateDelay)) { + AudioPlayback_SeqLayerNoteDecay(layer); + layer->stopSomething = true; + } + return; + } + + AudioSeq_SeqLayerProcessScriptStep1(layer); + + do { + cmd = AudioSeq_SeqLayerProcessScriptStep2(layer); + if (cmd == PROCESS_SCRIPT_END) { + return; + } + + cmd = AudioSeq_SeqLayerProcessScriptStep3(layer, cmd); + + } while ((cmd == -1) && (layer->delay == 0)); + + if (cmd != PROCESS_SCRIPT_END) { + // returns `sameSound` instead of a command + cmd = AudioSeq_SeqLayerProcessScriptStep4(layer, cmd); + } + + if (cmd != PROCESS_SCRIPT_END) { + AudioSeq_SeqLayerProcessScriptStep5(layer, cmd); + } + + if (layer->stopSomething == true) { + if ((layer->note != NULL) || layer->continuousNotes) { + AudioPlayback_SeqLayerNoteDecay(layer); + } + } +} + +void AudioSeq_SeqLayerProcessScriptStep1(SequenceLayer* layer) { + if (!layer->continuousNotes) { + AudioPlayback_SeqLayerNoteDecay(layer); + } else if ((layer->note != NULL) && (layer->note->playbackState.wantedParentLayer == layer)) { + AudioPlayback_SeqLayerNoteDecay(layer); + } + + if ((PORTAMENTO_MODE(layer->portamento) == PORTAMENTO_MODE_1) || + (PORTAMENTO_MODE(layer->portamento) == PORTAMENTO_MODE_2)) { + layer->portamento.mode = PORTAMENTO_MODE_OFF; + } + layer->notePropertiesNeedInit = true; +} + +s32 AudioSeq_SeqLayerProcessScriptStep5(SequenceLayer* layer, s32 sameSound) { + Note* note; + + if ((layer->continuousNotes == true) && (layer->bit1 == true)) { + return 0; + } + + if ((layer->continuousNotes == true) && (layer->note != NULL) && layer->bit3 && (sameSound == true) && + (layer->note->playbackState.parentLayer == layer)) { + if (layer->sound == NULL) { + AudioPlayback_InitSyntheticWave(layer->note, layer); + } + } else { + if (!sameSound) { + AudioPlayback_SeqLayerNoteDecay(layer); + } + + layer->note = AudioPlayback_AllocNote(layer); + + if (layer->note != NULL) { + note = layer->note; + + if (note->playbackState.parentLayer == layer) { + AudioEffects_NoteVibratoInit(note); + } + } + } + + if ((layer->note != NULL) && (layer->note->playbackState.parentLayer == layer)) { + note = layer->note; + + AudioEffects_NotePortamentoInit(note); + } + + return 0; +} + +s32 AudioSeq_SeqLayerProcessScriptStep2(SequenceLayer* layer) { + SequenceChannel* channel = layer->channel; + SeqScriptState* state = &layer->scriptState; + SequencePlayer* seqPlayer = channel->seqPlayer; + u8 cmd; + u8 cmdArg8; + u16 cmdArg16; + u16 velocity; + + while (true) { + cmd = AudioSeq_ScriptReadU8(state); + + // Note Commands + // To be processed in AudioSeq_SeqLayerProcessScriptStep3 + if (cmd <= 0xC0) { + return cmd; + } + + // Control Flow Commands + if (cmd >= 0xF2) { + cmdArg16 = AudioSeq_GetScriptControlFlowArgument(state, cmd); + + if (AudioSeq_HandleScriptFlowControl(seqPlayer, state, cmd, cmdArg16) == 0) { + continue; + } + AudioSeq_SeqLayerDisable(layer); + return PROCESS_SCRIPT_END; + } + + switch (cmd) { + case 0xC1: // layer: set short note velocity + case 0xCA: // layer: set pan + cmdArg8 = *(state->pc++); + if (cmd == 0xC1) { + layer->velocitySquare = SQ(cmdArg8) / SQ(127.0f); + } else { + layer->pan = cmdArg8; + } + break; + + case 0xC9: // layer: set short note gatetime + case 0xC2: // layer: set transposition in semitones + cmdArg8 = *(state->pc++); + if (cmd == 0xC9) { + layer->gateTime = cmdArg8; + } else { + layer->transposition = cmdArg8; + } + break; + + case 0xC4: // layer: continuous notes on + case 0xC5: // layer: continuous notes off + if (cmd == 0xC4) { + layer->continuousNotes = true; + } else { + layer->continuousNotes = false; + } + layer->bit1 = false; + AudioPlayback_SeqLayerNoteDecay(layer); + break; + + case 0xC3: // layer: set short note default delay + cmdArg16 = AudioSeq_ScriptReadCompressedU16(state); + layer->shortNoteDefaultDelay = cmdArg16; + break; + + case 0xC6: // layer: set instrument + cmd = AudioSeq_ScriptReadU8(state); + if (cmd >= 0x7E) { + if (cmd == 0x7E) { + // Sfxs + layer->instOrWave = 1; + } else if (cmd == 0x7F) { + // Drums + layer->instOrWave = 0; + } else { + // Synthetic Wave + layer->instOrWave = cmd; + layer->instrument = NULL; + } + + if (cmd == 0xFF) { + layer->adsr.decayIndex = 0; + } + } else { + // Instrument + if ((layer->instOrWave = AudioSeq_GetInstrument(channel, cmd, &layer->instrument, &layer->adsr)) == + 0) { + layer->instOrWave = 0xFF; + } + } + break; + + case 0xC7: // layer: enable portamento + layer->portamento.mode = AudioSeq_ScriptReadU8(state); + + cmd = AudioSeq_ScriptReadU8(state); + cmd += channel->transposition; + cmd += layer->transposition; + cmd += seqPlayer->transposition; + + if (cmd >= 0x80) { + cmd = 0; + } + + layer->portamentoTargetNote = cmd; + + // If special, the next param is u8 instead of var + if (PORTAMENTO_IS_SPECIAL(layer->portamento)) { + layer->portamentoTime = *(state->pc++); + break; + } + + cmdArg16 = AudioSeq_ScriptReadCompressedU16(state); + layer->portamentoTime = cmdArg16; + break; + + case 0xC8: // layer: disable portamento + layer->portamento.mode = PORTAMENTO_MODE_OFF; + break; + + case 0xCB: // layer: set envelope and decay index + cmdArg16 = AudioSeq_ScriptReadS16(state); + layer->adsr.envelope = (EnvelopePoint*)(seqPlayer->seqData + cmdArg16); + // fallthrough + case 0xCF: // layer: set decay index + layer->adsr.decayIndex = AudioSeq_ScriptReadU8(state); + break; + + case 0xCC: // layer: ignore drum pan + layer->ignoreDrumPan = true; + break; + + case 0xCD: // layer: stereo effects + layer->stereo.asByte = AudioSeq_ScriptReadU8(state); + break; + + case 0xCE: // layer: bend pitch + cmdArg8 = AudioSeq_ScriptReadU8(state); + layer->bend = gBendPitchTwoSemitonesFrequencies[(u8)(cmdArg8 + 0x80)]; + break; + + case 0xF0: // layer: + cmdArg16 = AudioSeq_ScriptReadS16(state); + layer->unk_0A.asByte &= (cmdArg16 ^ 0xFFFF); + break; + + case 0xF1: // layer: + layer->unk_08 = AudioSeq_ScriptReadU8(state); + break; + + default: + switch (cmd & 0xF0) { + case 0xD0: // layer: set short note velocity from table + velocity = seqPlayer->shortNoteVelocityTable[cmd & 0xF]; + layer->velocitySquare = SQ(velocity) / SQ(127.0f); + break; + + case 0xE0: // layer: set short note gatetime from table + layer->gateTime = seqPlayer->shortNoteGateTimeTable[cmd & 0xF]; + break; + } + } + } +} + +s32 AudioSeq_SeqLayerProcessScriptStep4(SequenceLayer* layer, s32 cmd) { + s32 sameSound = true; + s32 instOrWave; + s32 speed; + f32 temp_f14; + f32 temp_f2; + Portamento* portamento; + f32 freqScale; + f32 freqScale2; + SoundFontSound* sound; + Instrument* instrument; + Drum* drum; + s32 pad; + SequenceChannel* channel; + SequencePlayer* seqPlayer; + u8 semitone = cmd; + u16 sfxId; + s32 semitone2; + s32 vel; + f32 time; + f32 tuning; + s32 speed2; + + instOrWave = layer->instOrWave; + channel = layer->channel; + seqPlayer = channel->seqPlayer; + + if (instOrWave == 0xFF) { + if (!channel->hasInstrument) { + return PROCESS_SCRIPT_END; + } + instOrWave = channel->instOrWave; + } + + switch (instOrWave) { + case 0: + // Drums + semitone += channel->transposition + layer->transposition; + layer->semitone = semitone; + + drum = AudioPlayback_GetDrum(channel->fontId, semitone); + if (drum == NULL) { + layer->stopSomething = true; + layer->delay2 = layer->delay; + return PROCESS_SCRIPT_END; + } + + sound = &drum->sound; + layer->adsr.envelope = drum->envelope; + layer->adsr.decayIndex = drum->adsrDecayIndex; + if (!layer->ignoreDrumPan) { + layer->pan = drum->pan; + } + + layer->sound = sound; + layer->freqScale = sound->tuning; + break; + + case 1: + // Sfxs + layer->semitone = semitone; + sfxId = (layer->transposition << 6) + semitone; + + sound = AudioPlayback_GetSfx(channel->fontId, sfxId); + if (sound == NULL) { + layer->stopSomething = true; + layer->delay2 = layer->delay + 1; + return PROCESS_SCRIPT_END; + } + + layer->sound = sound; + layer->freqScale = sound->tuning; + break; + + default: + semitone += seqPlayer->transposition + channel->transposition + layer->transposition; + semitone2 = semitone; + + layer->semitone = semitone; + if (semitone >= 0x80) { + layer->stopSomething = true; + return PROCESS_SCRIPT_END; + } + + if (layer->instOrWave == 0xFF) { + instrument = channel->instrument; + } else { + instrument = layer->instrument; + } + + if (layer->portamento.mode != PORTAMENTO_MODE_OFF) { + portamento = &layer->portamento; + vel = (semitone > layer->portamentoTargetNote) ? semitone : layer->portamentoTargetNote; + + if (instrument != NULL) { + sound = AudioPlayback_InstrumentGetSound(instrument, vel); + sameSound = (layer->sound == sound); + layer->sound = sound; + tuning = sound->tuning; + } else { + layer->sound = NULL; + tuning = 1.0f; + if (instOrWave >= 0xC0) { + layer->sound = &gAudioContext.synthesisReverbs[instOrWave - 0xC0].sound; + } + } + + temp_f2 = gPitchFrequencies[semitone2] * tuning; + temp_f14 = gPitchFrequencies[layer->portamentoTargetNote] * tuning; + + switch (PORTAMENTO_MODE(*portamento)) { + case PORTAMENTO_MODE_1: + case PORTAMENTO_MODE_3: + case PORTAMENTO_MODE_5: + freqScale2 = temp_f2; + freqScale = temp_f14; + break; + + case PORTAMENTO_MODE_2: + case PORTAMENTO_MODE_4: + freqScale = temp_f2; + freqScale2 = temp_f14; + break; + + default: + freqScale = temp_f2; + freqScale2 = temp_f2; + break; + } + + portamento->extent = (freqScale2 / freqScale) - 1.0f; + + if (PORTAMENTO_IS_SPECIAL(*portamento)) { + speed = seqPlayer->tempo * 0x8000 / gAudioContext.tempoInternalToExternal; + if (layer->delay != 0) { + speed = speed * 0x100 / (layer->delay * layer->portamentoTime); + } + } else { + speed = 0x20000 / (layer->portamentoTime * gAudioContext.audioBufferParameters.updatesPerFrame); + } + + if (speed >= 0x7FFF) { + speed = 0x7FFF; + } else if (speed < 1) { + speed = 1; + } + + portamento->speed = speed; + portamento->cur = 0; + layer->freqScale = freqScale; + if (PORTAMENTO_MODE(*portamento) == PORTAMENTO_MODE_5) { + layer->portamentoTargetNote = semitone; + } + break; + } + + if (instrument != NULL) { + sound = AudioPlayback_InstrumentGetSound(instrument, semitone); + sameSound = (sound == layer->sound); + layer->sound = sound; + layer->freqScale = gPitchFrequencies[semitone2] * sound->tuning; + } else { + layer->sound = NULL; + layer->freqScale = gPitchFrequencies[semitone2]; + if (instOrWave >= 0xC0) { + layer->sound = &gAudioContext.synthesisReverbs[instOrWave - 0xC0].sound; + } + } + break; + } + + layer->delay2 = layer->delay; + layer->freqScale *= layer->bend; + + if (layer->delay == 0) { + if (layer->sound != NULL) { + time = layer->sound->sample->loop->end; + } else { + time = 0.0f; + } + time *= seqPlayer->tempo; + time *= gAudioContext.unk_2870; + time /= layer->freqScale; + if (1) {} + if (time > 0x7FFE) { + time = 0x7FFE; + } + + layer->gateDelay = 0; + layer->delay = (u16)(s32)time + 1; + + if (layer->portamento.mode != PORTAMENTO_MODE_OFF) { + // (It's a bit unclear if 'portamento' has actually always been + // set when this is reached...) + if (PORTAMENTO_IS_SPECIAL(*portamento)) { + speed2 = seqPlayer->tempo * 0x8000 / gAudioContext.tempoInternalToExternal; + speed2 = speed2 * 0x100 / (layer->delay * layer->portamentoTime); + if (speed2 >= 0x7FFF) { + speed2 = 0x7FFF; + } else if (speed2 < 1) { + speed2 = 1; + } + portamento->speed = speed2; + } + } + } + return sameSound; +} + +s32 AudioSeq_SeqLayerProcessScriptStep3(SequenceLayer* layer, s32 cmd) { + SeqScriptState* state = &layer->scriptState; + u16 delay; + s32 velocity; + SequenceChannel* channel = layer->channel; + SequencePlayer* seqPlayer = channel->seqPlayer; + s32 intDelta; + f32 floatDelta; + + if (cmd == 0xC0) { // layer: delay + layer->delay = AudioSeq_ScriptReadCompressedU16(state); + layer->stopSomething = true; + layer->bit1 = false; + return PROCESS_SCRIPT_END; + } + + layer->stopSomething = false; + + if (channel->largeNotes == true) { + switch (cmd & 0xC0) { + case 0x00: // layer: large note 0 + delay = AudioSeq_ScriptReadCompressedU16(state); + velocity = *(state->pc++); + layer->gateTime = *(state->pc++); + layer->lastDelay = delay; + break; + + case 0x40: // layer: large note 1 + delay = AudioSeq_ScriptReadCompressedU16(state); + velocity = *(state->pc++); + layer->gateTime = 0; + layer->lastDelay = delay; + break; + + case 0x80: // layer: large note 2 + delay = layer->lastDelay; + velocity = *(state->pc++); + layer->gateTime = *(state->pc++); + break; + } + + if ((velocity > 0x7F) || (velocity < 0)) { + velocity = 0x7F; + } + layer->velocitySquare = SQ((f32)velocity) / SQ(127.0f); + cmd -= (cmd & 0xC0); + } else { + switch (cmd & 0xC0) { + case 0x00: // layer: small note 0 + delay = AudioSeq_ScriptReadCompressedU16(state); + layer->lastDelay = delay; + break; + + case 0x40: // layer: small note 1 + delay = layer->shortNoteDefaultDelay; + break; + + case 0x80: // layer: small note 2 + delay = layer->lastDelay; + break; + } + cmd -= (cmd & 0xC0); + } + + if (channel->velocityRandomVariance != 0) { + floatDelta = layer->velocitySquare * (gAudioContext.audioRandom % channel->velocityRandomVariance) / 100.0f; + if ((gAudioContext.audioRandom & 0x8000) != 0) { + floatDelta = -floatDelta; + } + + layer->velocitySquare2 = layer->velocitySquare + floatDelta; + + if (layer->velocitySquare2 < 0.0f) { + layer->velocitySquare2 = 0.0f; + } else if (layer->velocitySquare2 > 1.0f) { + layer->velocitySquare2 = 1.0f; + } + } else { + layer->velocitySquare2 = layer->velocitySquare; + } + + layer->delay = delay; + layer->gateDelay = (layer->gateTime * delay) >> 8; + + if (channel->gateTimeRandomVariance != 0) { + //! @bug should probably be gateTimeRandomVariance + intDelta = (layer->gateDelay * (gAudioContext.audioRandom % channel->velocityRandomVariance)) / 100; + if ((gAudioContext.audioRandom & 0x4000) != 0) { + intDelta = -intDelta; + } + + layer->gateDelay += intDelta; + if (layer->gateDelay < 0) { + layer->gateDelay = 0; + } else if (layer->gateDelay > layer->delay) { + layer->gateDelay = layer->delay; + } + } + + if ((seqPlayer->muted && (channel->muteFlags & (MUTE_FLAGS_STOP_NOTES | MUTE_FLAGS_4))) || + channel->stopSomething2) { + layer->stopSomething = true; + return PROCESS_SCRIPT_END; + } + + if (seqPlayer->skipTicks != 0) { + layer->stopSomething = true; + return PROCESS_SCRIPT_END; + } + + return cmd; +} + +void AudioSeq_SetChannelPriorities(SequenceChannel* channel, u8 priority) { + if ((priority & 0xF) != 0) { + channel->notePriority = priority & 0xF; + } + + priority = priority >> 4; + if (priority != 0) { + channel->someOtherPriority = priority; + } +} + +u8 AudioSeq_GetInstrument(SequenceChannel* channel, u8 instId, Instrument** instOut, AdsrSettings* adsr) { + Instrument* inst = AudioPlayback_GetInstrumentInner(channel->fontId, instId); + + if (inst == NULL) { + *instOut = NULL; + return 0; + } + + adsr->envelope = inst->envelope; + adsr->decayIndex = inst->adsrDecayIndex; + + *instOut = inst; + + // temporarily offset instrument id by 2 so that instId 0, 1 + // can be reserved by drums and sfxs respectively. + instId += 2; + + return instId; +} + +void AudioSeq_SetInstrument(SequenceChannel* channel, u8 instId) { + if (instId >= 0x80) { + // Synthetic Waves + channel->instOrWave = instId; + channel->instrument = NULL; + } else if (instId == 0x7F) { + // Drums + channel->instOrWave = 0; + channel->instrument = (Instrument*)1; // invalid pointer, never dereferenced + } else if (instId == 0x7E) { + // Sfxs + channel->instOrWave = 1; + channel->instrument = (Instrument*)2; // invalid pointer, never dereferenced + } else { + // Instruments + if ((channel->instOrWave = AudioSeq_GetInstrument(channel, instId, &channel->instrument, &channel->adsr)) == + 0) { + channel->hasInstrument = false; + return; + } + } + + channel->hasInstrument = true; +} + +void AudioSeq_SequenceChannelSetVolume(SequenceChannel* channel, u8 volume) { + channel->volume = (s32)volume / 127.0f; +} + +void AudioSeq_SequenceChannelProcessScript(SequenceChannel* channel) { + s32 i; + u8* data; + u32 rand; + SequencePlayer* seqPlayer; + + if (channel->stopScript) { + goto exit_loop; + } + + seqPlayer = channel->seqPlayer; + if (seqPlayer->muted && (channel->muteFlags & MUTE_FLAGS_STOP_SCRIPT)) { + return; + } + + if (channel->delay >= 2) { + channel->delay--; + goto exit_loop; + } + + while (true) { + SeqScriptState* scriptState = &channel->scriptState; + s32 param; + s16 temp1; + u16 cmdArgU16; + u32 cmdArgs[3]; + s8 cmdArgS8; + u8 cmd = AudioSeq_ScriptReadU8(scriptState); + u8 lowBits; + u8 highBits; + s32 delay; + s32 temp2; + u8 phi_v0_3; + u8 new_var; + u8 depth; + u8* seqData = seqPlayer->seqData; + u32 new_var2; + + // Commands 0xA0 - 0xFF + if (cmd >= 0xA0) { + highBits = sSeqInstructionArgsTable[cmd - 0xA0]; + lowBits = highBits & 3; + + // read in arguments for the instruction + for (i = 0; i < lowBits; i++, highBits <<= 1) { + if (!(highBits & 0x80)) { + cmdArgs[i] = AudioSeq_ScriptReadU8(scriptState); + } else { + cmdArgs[i] = AudioSeq_ScriptReadS16(scriptState); + } + } + + // Control Flow Commands + if (cmd >= 0xF2) { + delay = AudioSeq_HandleScriptFlowControl(seqPlayer, scriptState, cmd, cmdArgs[0]); + + if (delay != 0) { + if (delay == PROCESS_SCRIPT_END) { + AudioSeq_SequenceChannelDisable(channel); + } else { + channel->delay = delay; + } + break; + } + continue; + } + + switch (cmd) { + case 0xEA: // channel: stop script + channel->stopScript = true; + goto exit_loop; + + case 0xF1: // channel: reserve notes + AudioPlayback_NotePoolClear(&channel->notePool); + cmd = (u8)cmdArgs[0]; + AudioPlayback_NotePoolFill(&channel->notePool, cmd); + break; + + case 0xF0: // channel: unreserve notes + AudioPlayback_NotePoolClear(&channel->notePool); + break; + + case 0xC2: // channel: set dyntable + cmdArgU16 = (u16)cmdArgs[0]; + channel->dynTable = (void*)&seqPlayer->seqData[cmdArgU16]; + break; + + case 0xC5: // channel: dyn set dyntable + if (scriptState->value != -1) { + data = (*channel->dynTable)[scriptState->value]; + cmdArgU16 = (u16)((data[0] << 8) + data[1]); + scriptState->pc = (void*)&seqPlayer->seqData[cmdArgU16]; + } + break; + + case 0xEB: // channel: set soundFont and instrument + cmd = (u8)cmdArgs[0]; + + if (seqPlayer->defaultFont != 0xFF) { + cmdArgU16 = ((u16*)gAudioContext.sequenceFontTable)[seqPlayer->seqId]; + lowBits = gAudioContext.sequenceFontTable[cmdArgU16]; + cmd = gAudioContext.sequenceFontTable[cmdArgU16 + lowBits - cmd]; + } + + if (AudioHeap_SearchCaches(FONT_TABLE, CACHE_EITHER, cmd)) { + channel->fontId = cmd; + } + + cmdArgs[0] = cmdArgs[1]; + // fallthrough + case 0xC1: // channel: set instrument + cmd = (u8)cmdArgs[0]; + AudioSeq_SetInstrument(channel, cmd); + break; + + case 0xC3: // channel: large notes off + channel->largeNotes = false; + break; + + case 0xC4: // channel: large notes on + channel->largeNotes = true; + break; + + case 0xDF: // channel: set volume + cmd = (u8)cmdArgs[0]; + AudioSeq_SequenceChannelSetVolume(channel, cmd); + channel->changes.s.volume = true; + break; + + case 0xE0: // channel: set volume scale + cmd = (u8)cmdArgs[0]; + channel->volumeScale = (f32)(s32)cmd / 128.0f; + channel->changes.s.volume = true; + break; + + case 0xDE: // channel: set freqscale + cmdArgU16 = (u16)cmdArgs[0]; + channel->freqScale = (f32)(s32)cmdArgU16 / 0x8000; + channel->changes.s.freqScale = true; + break; + + case 0xD3: // channel: large bend pitch + cmd = (u8)cmdArgs[0]; + cmd += 0x80; + channel->freqScale = gBendPitchOneOctaveFrequencies[cmd]; + channel->changes.s.freqScale = true; + break; + + case 0xEE: // channel: small bend pitch + cmd = (u8)cmdArgs[0]; + cmd += 0x80; + channel->freqScale = gBendPitchTwoSemitonesFrequencies[cmd]; + channel->changes.s.freqScale = true; + break; + + case 0xDD: // channel: set pan + cmd = (u8)cmdArgs[0]; + channel->newPan = cmd; + channel->changes.s.pan = true; + break; + + case 0xDC: // channel: set pan mix + cmd = (u8)cmdArgs[0]; + channel->panChannelWeight = cmd; + channel->changes.s.pan = true; + break; + + case 0xDB: // channel: transpose + cmdArgS8 = (s8)cmdArgs[0]; + channel->transposition = cmdArgS8; + break; + + case 0xDA: // channel: set envelope + cmdArgU16 = (u16)cmdArgs[0]; + channel->adsr.envelope = (EnvelopePoint*)&seqPlayer->seqData[cmdArgU16]; + break; + + case 0xD9: // channel: set decay index + cmd = (u8)cmdArgs[0]; + channel->adsr.decayIndex = cmd; + break; + + case 0xD8: // channel: set vibrato extent + cmd = (u8)cmdArgs[0]; + channel->vibrato.vibratoExtentTarget = cmd * 8; + channel->vibrato.vibratoExtentStart = 0; + channel->vibrato.vibratoExtentChangeDelay = 0; + break; + + case 0xD7: // channel: set vibrato rate + cmd = (u8)cmdArgs[0]; + channel->vibrato.vibratoRateChangeDelay = 0; + channel->vibrato.vibratoRateTarget = cmd * 32; + channel->vibrato.vibratoRateStart = cmd * 32; + break; + + case 0xE2: // channel: set vibrato extent linear + cmd = (u8)cmdArgs[0]; + channel->vibrato.vibratoExtentStart = cmd * 8; + cmd = (u8)cmdArgs[1]; + channel->vibrato.vibratoExtentTarget = cmd * 8; + cmd = (u8)cmdArgs[2]; + channel->vibrato.vibratoExtentChangeDelay = cmd * 16; + break; + + case 0xE1: // channel: set vibratorate linear + cmd = (u8)cmdArgs[0]; + channel->vibrato.vibratoRateStart = cmd * 32; + cmd = (u8)cmdArgs[1]; + channel->vibrato.vibratoRateTarget = cmd * 32; + cmd = (u8)cmdArgs[2]; + channel->vibrato.vibratoRateChangeDelay = cmd * 16; + break; + + case 0xE3: // channel: set vibrato delay + cmd = (u8)cmdArgs[0]; + channel->vibrato.vibratoDelay = cmd * 16; + break; + + case 0xD4: // channel: set reverb + cmd = (u8)cmdArgs[0]; + channel->reverb = cmd; + break; + + case 0xC6: // channel: set soundFont + cmd = (u8)cmdArgs[0]; + + if (seqPlayer->defaultFont != 0xFF) { + cmdArgU16 = ((u16*)gAudioContext.sequenceFontTable)[seqPlayer->seqId]; + lowBits = gAudioContext.sequenceFontTable[cmdArgU16]; + cmd = gAudioContext.sequenceFontTable[cmdArgU16 + lowBits - cmd]; + } + + if (AudioHeap_SearchCaches(FONT_TABLE, CACHE_EITHER, cmd)) { + channel->fontId = cmd; + } + break; + + case 0xC7: // channel: write into sequence script + cmd = (u8)cmdArgs[0]; + cmdArgU16 = (u16)cmdArgs[1]; + seqData = &seqPlayer->seqData[cmdArgU16]; + seqData[0] = (u8)scriptState->value + cmd; + break; + + case 0xC8: // channel: subtract -> set value + case 0xCC: // channel: set value + case 0xC9: // channel: `bit and` -> set value + cmdArgS8 = (s8)cmdArgs[0]; + + if (cmd == 0xC8) { + scriptState->value -= cmdArgS8; + } else if (cmd == 0xCC) { + scriptState->value = cmdArgS8; + } else { + scriptState->value &= cmdArgS8; + } + break; + + case 0xCD: // channel: disable channel + cmd = (u8)cmdArgs[0]; + AudioSeq_SequenceChannelDisable(seqPlayer->channels[cmd]); + break; + + case 0xCA: // channel: set mute behavior + cmd = (u8)cmdArgs[0]; + channel->muteFlags = cmd; + channel->changes.s.volume = true; + break; + + case 0xCB: // channel: read sequence -> set value + cmdArgU16 = (u16)cmdArgs[0]; + scriptState->value = *(seqPlayer->seqData + (u32)(cmdArgU16 + scriptState->value)); + break; + + case 0xCE: // channel: + cmdArgU16 = (u16)cmdArgs[0]; + channel->unk_22 = cmdArgU16; + break; + + case 0xCF: // channel: write large into sequence script + cmdArgU16 = (u16)cmdArgs[0]; + seqData = &seqPlayer->seqData[cmdArgU16]; + seqData[0] = (channel->unk_22 >> 8) & 0xFF; + seqData[1] = channel->unk_22 & 0xFF; + break; + + case 0xD0: // channel: stereo headset effects + cmd = (u8)cmdArgs[0]; + if (cmd & 0x80) { + channel->stereoHeadsetEffects = true; + } else { + channel->stereoHeadsetEffects = false; + } + channel->stereo.asByte = cmd & 0x7F; + break; + + case 0xD1: // channel: set note allocation policy + cmd = (u8)cmdArgs[0]; + channel->noteAllocPolicy = cmd; + break; + + case 0xD2: // channel: set sustain + cmd = (u8)cmdArgs[0]; + channel->adsr.sustain = cmd; + break; + + case 0xE5: // channel: set reverb index + cmd = (u8)cmdArgs[0]; + channel->reverbIndex = cmd; + break; + + case 0xE4: // channel: dyncall + if (scriptState->value != -1) { + data = (*channel->dynTable)[scriptState->value]; + depth = scriptState->depth; + //! @bug: Missing a stack depth check here + scriptState->stack[depth] = scriptState->pc; + scriptState->depth++; + cmdArgU16 = (u16)((data[0] << 8) + data[1]); + scriptState->pc = seqPlayer->seqData + cmdArgU16; + } + break; + + case 0xE6: // channel: set book offset + cmd = (u8)cmdArgs[0]; + channel->bookOffset = cmd; + break; + + case 0xE7: // channel: + cmdArgU16 = (u16)cmdArgs[0]; + data = &seqPlayer->seqData[cmdArgU16]; + channel->muteFlags = data[0]; + data += 3; + channel->noteAllocPolicy = data[-2]; + AudioSeq_SetChannelPriorities(channel, data[-1]); + channel->transposition = (s8)data[0]; + data += 4; + channel->newPan = data[-3]; + channel->panChannelWeight = data[-2]; + channel->reverb = data[-1]; + channel->reverbIndex = data[0]; + //! @bug: Not marking reverb state as changed + channel->changes.s.pan = true; + break; + + case 0xE8: // channel: + channel->muteFlags = cmdArgs[0]; + channel->noteAllocPolicy = cmdArgs[1]; + cmd = (u8)cmdArgs[2]; + AudioSeq_SetChannelPriorities(channel, cmd); + channel->transposition = (s8)AudioSeq_ScriptReadU8(scriptState); + channel->newPan = AudioSeq_ScriptReadU8(scriptState); + channel->panChannelWeight = AudioSeq_ScriptReadU8(scriptState); + channel->reverb = AudioSeq_ScriptReadU8(scriptState); + channel->reverbIndex = AudioSeq_ScriptReadU8(scriptState); + //! @bug: Not marking reverb state as changed + channel->changes.s.pan = true; + break; + + case 0xEC: // channel: reset vibrato + channel->vibrato.vibratoExtentTarget = 0; + channel->vibrato.vibratoExtentStart = 0; + channel->vibrato.vibratoExtentChangeDelay = 0; + channel->vibrato.vibratoRateTarget = 0; + channel->vibrato.vibratoRateStart = 0; + channel->vibrato.vibratoRateChangeDelay = 0; + channel->filter = NULL; + channel->gain = 0; + channel->adsr.sustain = 0; + channel->velocityRandomVariance = 0; + channel->gateTimeRandomVariance = 0; + channel->unk_0F = 0; + channel->unk_20 = 0; + channel->bookOffset = 0; + channel->unk_DC = 0; + channel->unk_E0 = 0; + channel->freqScale = 1.0f; + break; + + case 0xE9: // channel: set note priority + AudioSeq_SetChannelPriorities(channel, (u8)cmdArgs[0]); + break; + + case 0xED: // channel: set hilo gain + cmd = (u8)cmdArgs[0]; + channel->gain = cmd; + break; + + case 0xB0: // channel: set filter + cmdArgU16 = (u16)cmdArgs[0]; + data = seqPlayer->seqData + cmdArgU16; + channel->filter = (s16*)data; + break; + + case 0xB1: // channel: clear filter + channel->filter = NULL; + break; + + case 0xB3: // channel: load filter + cmd = cmdArgs[0]; + + if (channel->filter != NULL) { + lowBits = (cmd >> 4) & 0xF; // LowPassCutoff + cmd &= 0xF; // HighPassCutoff + AudioHeap_LoadFilter(channel->filter, lowBits, cmd); + } + break; + + case 0xB2: // channel: dynread sequence large + cmdArgU16 = (u16)cmdArgs[0]; + channel->unk_22 = *(u16*)(seqPlayer->seqData + (u32)(cmdArgU16 + scriptState->value * 2)); + break; + + case 0xB4: // channel: set dyntable large + channel->dynTable = (void*)&seqPlayer->seqData[channel->unk_22]; + break; + + case 0xB5: // channel: read dyntable large + channel->unk_22 = ((u16*)(channel->dynTable))[scriptState->value]; + break; + + case 0xB6: // channel: read dyntable + scriptState->value = (*channel->dynTable)[0][scriptState->value]; + break; + + case 0xB7: // channel: random large + channel->unk_22 = (cmdArgs[0] == 0) ? (gAudioContext.audioRandom & 0xFFFF) + : (gAudioContext.audioRandom % cmdArgs[0]); + break; + + case 0xB8: // channel: random value + scriptState->value = (cmdArgs[0] == 0) ? (gAudioContext.audioRandom & 0xFFFF) + : (gAudioContext.audioRandom % cmdArgs[0]); + break; + + case 0xA8: // channel: random range large (only cmd that differs from OoT) + rand = AudioThread_NextRandom(); + channel->unk_22 = (cmdArgs[0] == 0) ? (rand & 0xFFFF) : (rand % cmdArgs[0]); + channel->unk_22 += cmdArgs[1]; + temp2 = (channel->unk_22 / 0x100) + 0x80; + param = channel->unk_22 % 0x100; + channel->unk_22 = (temp2 << 8) | param; + break; + + case 0xB9: // channel: set velocity random variance + channel->velocityRandomVariance = cmdArgs[0]; + break; + + case 0xBA: // channel: set gatetime random variance + channel->gateTimeRandomVariance = cmdArgs[0]; + break; + + case 0xBB: // channel: + channel->unk_0F = cmdArgs[0]; + channel->unk_20 = cmdArgs[1]; + break; + + case 0xBC: // channel: add large + channel->unk_22 += cmdArgs[0]; + break; + + case 0xBD: // channel: + channel->unk_DC = cmdArgs[0]; + break; + + case 0xBE: // channel: + if (cmdArgs[0] < 5) { + if (1) {} + if (gAudioContext.unk_29A8[cmdArgs[0]] != NULL) { + D_80208E6C = gAudioContext.unk_29A8[cmdArgs[0]]; + scriptState->value = D_80208E6C(scriptState->value, channel); + } + } + break; + + case 0xA0: // channel: + case 0xA1: // channel: + case 0xA2: // channel: + case 0xA3: // channel: + if ((cmd == 0xA0) || (cmd == 0xA2)) { + cmdArgU16 = (u16)cmdArgs[0]; + } else { + cmdArgU16 = channel->unk_22; + } + + if (channel->sfxState != NULL) { + if ((cmd == 0xA0) || (cmd == 0xA1)) { + scriptState->value = channel->sfxState[cmdArgU16]; + } else { + channel->sfxState[cmdArgU16] = scriptState->value; + } + } + break; + + case 0xA4: // channel: + channel->unk_10 = cmdArgs[0]; + break; + + case 0xA5: // channel: + scriptState->value += channel->unk_11; + break; + + case 0xA6: // channel: + cmd = (u8)cmdArgs[0]; + cmdArgU16 = (u16)cmdArgs[1]; + seqData = seqPlayer->seqData + (u32)(cmdArgU16 + channel->unk_11); + seqData[0] = (u8)scriptState->value + cmd; + break; + + case 0xA7: // channel: + new_var2 = (cmdArgs[0] & 0x80); + new_var = (scriptState->value & 0x80); + + if (!new_var2) { + phi_v0_3 = scriptState->value << (cmdArgs[0] & 0xF); + } else { + phi_v0_3 = scriptState->value >> (cmdArgs[0] & 0xF); + } + + if (cmdArgs[0] & 0x40) { + phi_v0_3 &= (u8)~0x80; + phi_v0_3 |= new_var; + } + + scriptState->value = phi_v0_3; + break; + } + continue; + } + + // Commands 0x70 - 0x9F + if (cmd >= 0x70) { + lowBits = cmd & 0x7; + + if (((cmd & 0xF8) != 0x70) && (lowBits >= 4)) { + lowBits = 0; + } + + switch (cmd & 0xF8) { + case 0x80: // channel: test layer is finished + if (channel->layers[lowBits] != NULL) { + scriptState->value = channel->layers[lowBits]->finished; + } else { + scriptState->value = -1; + } + break; + + case 0x88: // channel: set layer + cmdArgU16 = AudioSeq_ScriptReadS16(scriptState); + if (!AudioSeq_SeqChannelSetLayer(channel, lowBits)) { + channel->layers[lowBits]->scriptState.pc = &seqPlayer->seqData[cmdArgU16]; + } + break; + + case 0x90: // channel: free layer + AudioSeq_SeqLayerFree(channel, lowBits); + break; + + case 0x98: // channel: dynset layer + if ((scriptState->value != -1) && (AudioSeq_SeqChannelSetLayer(channel, lowBits) != -1)) { + data = (*channel->dynTable)[scriptState->value]; + cmdArgU16 = (data[0] << 8) + data[1]; + channel->layers[lowBits]->scriptState.pc = &seqPlayer->seqData[cmdArgU16]; + } + break; + + case 0x70: // channel: io write value + channel->soundScriptIO[lowBits] = scriptState->value; + break; + + case 0x78: // channel: set layer relative + temp1 = AudioSeq_ScriptReadS16(scriptState); + if (!AudioSeq_SeqChannelSetLayer(channel, lowBits)) { + channel->layers[lowBits]->scriptState.pc = &scriptState->pc[temp1]; + } + break; + } + continue; + } + + // Commands 0x00 - 0x6F + lowBits = cmd & 0xF; + + switch (cmd & 0xF0) { + case 0x00: // channel: delay short + channel->delay = lowBits; + if (lowBits == 0) { + break; + } + goto exit_loop; + + case 0x10: // channel: load sample + if (lowBits < 8) { + channel->soundScriptIO[lowBits] = -1; + if (AudioLoad_SlowLoadSample(channel->fontId, scriptState->value, + &channel->soundScriptIO[lowBits]) == -1) {} + } else { + lowBits -= 8; + channel->soundScriptIO[lowBits] = -1; + if (AudioLoad_SlowLoadSample(channel->fontId, channel->unk_22 + 0x100, + &channel->soundScriptIO[lowBits]) == -1) {} + } + break; + + case 0x60: // channel: io read value + scriptState->value = channel->soundScriptIO[lowBits]; + if (lowBits < 2) { + channel->soundScriptIO[lowBits] = -1; + } + break; + + case 0x50: // channel: io read value subtract + scriptState->value -= channel->soundScriptIO[lowBits]; + break; + + case 0x20: // channel: start channel + cmdArgU16 = AudioSeq_ScriptReadS16(scriptState); + AudioSeq_SequenceChannelEnable(seqPlayer, lowBits, &seqPlayer->seqData[cmdArgU16]); + break; + + case 0x30: // channel: io write value 2 + cmd = AudioSeq_ScriptReadU8(scriptState); + seqPlayer->channels[lowBits]->soundScriptIO[cmd] = scriptState->value; + break; + + case 0x40: // channel: io read value 2 + cmd = AudioSeq_ScriptReadU8(scriptState); + scriptState->value = seqPlayer->channels[lowBits]->soundScriptIO[cmd]; + break; + } + } +exit_loop: + + for (i = 0; i < ARRAY_COUNT(channel->layers); i++) { + if (channel->layers[i] != NULL) { + AudioSeq_SeqLayerProcessScript(channel->layers[i]); + } + } +} + +void AudioSeq_SequencePlayerProcessSequence(SequencePlayer* seqPlayer) { + u8 cmd; + u8 cmdLowBits; + SeqScriptState* seqScript = &seqPlayer->scriptState; + s16 tempS; + u16 temp; + s32 i; + s32 value; + u8* data1; + u8* data2; + u8* data3; + u8* data4; + s32 tempoChange; + s32 j; + SequenceChannel* channel; + u16* new_var; + s32 delay; + + if (!seqPlayer->enabled) { + return; + } + + if (!AudioLoad_IsSeqLoadComplete(seqPlayer->seqId) || !AudioLoad_IsFontLoadComplete(seqPlayer->defaultFont)) { + // These function calls serve no purpose + if (AudioLoad_IsSeqLoadComplete(seqPlayer->seqId)) {} + if (AudioLoad_IsSeqLoadComplete(seqPlayer->defaultFont)) {} + + AudioSeq_SequencePlayerDisable(seqPlayer); + return; + } + + AudioLoad_SetSeqLoadStatus(seqPlayer->seqId, LOAD_STATUS_COMPLETE); + AudioLoad_SetFontLoadStatus(seqPlayer->defaultFont, LOAD_STATUS_COMPLETE); + + if (seqPlayer->muted && (seqPlayer->muteFlags & MUTE_FLAGS_STOP_SCRIPT)) { + return; + } + + seqPlayer->scriptCounter++; + + tempoChange = seqPlayer->tempo + seqPlayer->unk_0C; + if (tempoChange > gAudioContext.tempoInternalToExternal) { + tempoChange = gAudioContext.tempoInternalToExternal; + } + + seqPlayer->tempoAcc += tempoChange; + + if (seqPlayer->tempoAcc < gAudioContext.tempoInternalToExternal) { + return; + } + + seqPlayer->tempoAcc -= (u16)gAudioContext.tempoInternalToExternal; + seqPlayer->unk_16++; + + if (seqPlayer->stopScript == true) { + return; + } + + if (seqPlayer->delay > 1) { + seqPlayer->delay--; + } else { + seqPlayer->recalculateVolume = true; + + while (true) { + cmd = AudioSeq_ScriptReadU8(seqScript); + + // 0xF2 and above are "flow control" commands, including termination. + if (cmd >= 0xF2) { + delay = AudioSeq_HandleScriptFlowControl( + seqPlayer, seqScript, cmd, AudioSeq_GetScriptControlFlowArgument(&seqPlayer->scriptState, cmd)); + + if (delay != 0) { + if (delay == -1) { + AudioSeq_SequencePlayerDisable(seqPlayer); + } else { + seqPlayer->delay = delay; + } + break; + } + continue; + } + + // Commands 0xC0 - 0xF1 + if (cmd >= 0xC0) { + switch (cmd) { + case 0xF1: // seqPlayer: reserve notes + AudioPlayback_NotePoolClear(&seqPlayer->notePool); + cmd = AudioSeq_ScriptReadU8(seqScript); + AudioPlayback_NotePoolFill(&seqPlayer->notePool, cmd); + break; + + case 0xF0: // seqPlayer: unreserve notes + AudioPlayback_NotePoolClear(&seqPlayer->notePool); + break; + + case 0xDF: // seqPlayer: transpose + seqPlayer->transposition = 0; + // fallthrough + case 0xDE: // seqPlayer: transpose relative + seqPlayer->transposition += (s8)AudioSeq_ScriptReadU8(seqScript); + break; + + case 0xDD: // seqPlayer: set tempo + seqPlayer->tempo = AudioSeq_ScriptReadU8(seqScript) * TATUMS_PER_BEAT; + if (seqPlayer->tempo > gAudioContext.tempoInternalToExternal) { + seqPlayer->tempo = gAudioContext.tempoInternalToExternal; + } + + if ((s16)seqPlayer->tempo <= 0) { + seqPlayer->tempo = 1; + } + break; + + case 0xDC: // seqPlayer: add tempo + seqPlayer->unk_0C = (s8)AudioSeq_ScriptReadU8(seqScript) * TATUMS_PER_BEAT; + break; + + case 0xDA: // seqPlayer: change volume + cmd = AudioSeq_ScriptReadU8(seqScript); + temp = AudioSeq_ScriptReadS16(seqScript); + switch (cmd) { + case 0: + case 1: + if (seqPlayer->state != 2) { + seqPlayer->fadeTimerUnkEu = temp; + seqPlayer->state = cmd; + } + break; + + case 2: + seqPlayer->fadeTimer = temp; + seqPlayer->state = cmd; + seqPlayer->fadeVelocity = (0.0f - seqPlayer->fadeVolume) / (s32)seqPlayer->fadeTimer; + break; + } + break; + + case 0xDB: // seqPlayer: set volume + value = AudioSeq_ScriptReadU8(seqScript); + switch (seqPlayer->state) { + case 1: + seqPlayer->state = 0; + seqPlayer->fadeVolume = 0.0f; + // fallthrough + case 0: + seqPlayer->fadeTimer = seqPlayer->fadeTimerUnkEu; + if (seqPlayer->fadeTimerUnkEu != 0) { + seqPlayer->fadeVelocity = + ((value / 127.0f) - seqPlayer->fadeVolume) / (s32)seqPlayer->fadeTimer; + } else { + seqPlayer->fadeVolume = value / 127.0f; + } + break; + + case 2: + break; + } + break; + + case 0xD9: // seqPlayer: set volume scale + seqPlayer->fadeVolumeScale = (s8)AudioSeq_ScriptReadU8(seqScript) / 127.0f; + break; + + case 0xD7: // seqPlayer: initialize channels + temp = AudioSeq_ScriptReadS16(seqScript); + AudioSeq_SequencePlayerSetupChannels(seqPlayer, temp); + break; + + case 0xD6: // seqPlayer: disable channels + AudioSeq_ScriptReadS16(seqScript); + break; + + case 0xD5: // seqPlayer: set mute scale + seqPlayer->muteVolumeScale = (s8)AudioSeq_ScriptReadU8(seqScript) / 127.0f; + break; + + case 0xD4: // seqPlayer: mute + seqPlayer->muted = true; + break; + + case 0xD3: // seqPlayer: set mute behavior + seqPlayer->muteFlags = AudioSeq_ScriptReadU8(seqScript); + break; + + case 0xD1: // seqPlayer: set short note gatetime table + case 0xD2: // seqPlayer: set short note velocity table + temp = AudioSeq_ScriptReadS16(seqScript); + data3 = &seqPlayer->seqData[temp]; + if (cmd == 0xD2) { + seqPlayer->shortNoteVelocityTable = data3; + } else { + seqPlayer->shortNoteGateTimeTable = data3; + } + break; + + case 0xD0: // seqPlayer: set note allocation policy + seqPlayer->noteAllocPolicy = AudioSeq_ScriptReadU8(seqScript); + break; + + case 0xCE: // seqPlayer: random value + cmd = AudioSeq_ScriptReadU8(seqScript); + if (cmd == 0) { + seqScript->value = (gAudioContext.audioRandom >> 2) & 0xFF; + } else { + seqScript->value = (gAudioContext.audioRandom >> 2) % cmd; + } + break; + + case 0xCD: // seqPlayer: dyncall + temp = AudioSeq_ScriptReadS16(seqScript); + if ((seqScript->value != -1) && (seqScript->depth != 3)) { + data1 = seqPlayer->seqData + (u32)(temp + (seqScript->value << 1)); + seqScript->stack[seqScript->depth] = seqScript->pc; + seqScript->depth++; + temp = (data1[0] << 8) + data1[1]; + seqScript->pc = &seqPlayer->seqData[temp]; + } + break; + + case 0xCC: // seqPlayer: set value + seqScript->value = AudioSeq_ScriptReadU8(seqScript); + break; + + case 0xC9: // seqPlayer: `bit and` -> set value + seqScript->value &= AudioSeq_ScriptReadU8(seqScript); + break; + + case 0xC8: // seqPlayer: subtract -> set value + seqScript->value -= AudioSeq_ScriptReadU8(seqScript); + break; + + case 0xC7: // seqPlayer: write into sequence script + cmd = AudioSeq_ScriptReadU8(seqScript); + temp = AudioSeq_ScriptReadS16(seqScript); + data2 = &seqPlayer->seqData[temp]; + *data2 = (u8)seqScript->value + cmd; + break; + + case 0xC2: // seqPlayer: + temp = AudioSeq_ScriptReadS16(seqScript); + if (seqScript->value != -1) { + data4 = seqPlayer->seqData + (u32)(temp + (seqScript->value << 1)); + + temp = (data4[0] << 8) + data4[1]; + seqScript->pc = &seqPlayer->seqData[temp]; + } + break; + + case 0xC6: // seqPlayer: stop script + seqPlayer->stopScript = true; + return; + + case 0xC5: // seqPlayer: + seqPlayer->unk_16 = AudioSeq_ScriptReadS16(seqScript); + break; + + case 0xEF: // seqPlayer: + AudioSeq_ScriptReadS16(seqScript); + AudioSeq_ScriptReadU8(seqScript); + break; + + case 0xC4: // seqPlayer: start sequence + cmd = AudioSeq_ScriptReadU8(seqScript); + if (cmd == 0xFF) { + cmd = seqPlayer->playerIndex; + if (seqPlayer->state == 2) { + break; + } + } + + cmdLowBits = AudioSeq_ScriptReadU8(seqScript); + AudioLoad_SyncInitSeqPlayer(cmd, cmdLowBits, 0); + if (cmd == (u8)seqPlayer->playerIndex) { + return; + } + break; + + case 0xC3: // seqPlayer: + temp = AudioSeq_ScriptReadS16(seqScript); + if (seqScript->value != -1) { + new_var = (u16*)(seqPlayer->seqData + (u32)(temp + seqScript->value * 2)); + temp = *new_var; + + for (i = 0; i < ARRAY_COUNT(seqPlayer->channels); i++) { + seqPlayer->channels[i]->stopSomething2 = temp & 1; + temp = temp >> 1; + } + } + break; + } + continue; + } + + // Commands 0x00 - 0xBF + cmdLowBits = cmd & 0x0F; + + switch (cmd & 0xF0) { + case 0x00: // seqPlayer: test channel disabled + seqScript->value = seqPlayer->channels[cmdLowBits]->enabled ^ 1; + break; + + case 0x50: // seqPlayer: io read value subtract + seqScript->value -= seqPlayer->soundScriptIO[cmdLowBits]; + break; + + case 0x70: // seqPlayer: io write value + seqPlayer->soundScriptIO[cmdLowBits] = seqScript->value; + break; + + case 0x80: // seqPlayer: io read value + seqScript->value = seqPlayer->soundScriptIO[cmdLowBits]; + if (cmdLowBits < 2) { + seqPlayer->soundScriptIO[cmdLowBits] = -1; + } + break; + + case 0x40: // seqPlayer: disable channel + AudioSeq_SequenceChannelDisable(seqPlayer->channels[cmdLowBits]); + break; + + case 0x90: // seqPlayer: start channel + temp = AudioSeq_ScriptReadS16(seqScript); + AudioSeq_SequenceChannelEnable(seqPlayer, cmdLowBits, (void*)&seqPlayer->seqData[temp]); + break; + + case 0xA0: // seqPlayer: start channel relative + tempS = AudioSeq_ScriptReadS16(seqScript); + AudioSeq_SequenceChannelEnable(seqPlayer, cmdLowBits, (void*)&seqScript->pc[tempS]); + break; + + case 0xB0: // seqPlayer: load sequence + cmd = AudioSeq_ScriptReadU8(seqScript); + temp = AudioSeq_ScriptReadS16(seqScript); + data2 = &seqPlayer->seqData[temp]; + AudioLoad_SlowLoadSeq(cmd, data2, &seqPlayer->soundScriptIO[cmdLowBits]); + break; + + case 0x60: // seqPlayer: async load + cmd = AudioSeq_ScriptReadU8(seqScript); + value = cmd; + temp = AudioSeq_ScriptReadU8(seqScript); + AudioLoad_ScriptLoad(value, temp, &seqPlayer->soundScriptIO[cmdLowBits]); + break; + } + } + } + + for (j = 0; j < SEQ_NUM_CHANNELS; j++) { + channel = seqPlayer->channels[j]; + if (channel->enabled) { + AudioSeq_SequenceChannelProcessScript(channel); + } + } +} + +void AudioSeq_ProcessSequences(s32 arg0) { + SequencePlayer* seqPlayer; + u32 i; + + gAudioContext.noteSubEuOffset = + (gAudioContext.audioBufferParameters.updatesPerFrame - arg0 - 1) * gAudioContext.numNotes; + + for (i = 0; i < (u32)gAudioContext.audioBufferParameters.numSequencePlayers; i++) { + seqPlayer = &gAudioContext.seqPlayers[i]; + if (seqPlayer->enabled == true) { + AudioSeq_SequencePlayerProcessSequence(seqPlayer); + AudioEffects_SequencePlayerProcessSound(seqPlayer); + } + } + + AudioPlayback_ProcessNotes(); +} + +void AudioSeq_SkipForwardSequence(SequencePlayer* seqPlayer) { + while (seqPlayer->skipTicks > 0) { + AudioSeq_SequencePlayerProcessSequence(seqPlayer); + AudioEffects_SequencePlayerProcessSound(seqPlayer); + seqPlayer->skipTicks--; + } +} + +void AudioSeq_ResetSequencePlayer(SequencePlayer* seqPlayer) { + s32 i; + + AudioSeq_SequencePlayerDisable(seqPlayer); + seqPlayer->stopScript = false; + seqPlayer->delay = 0; + seqPlayer->state = 1; + seqPlayer->fadeTimer = 0; + seqPlayer->fadeTimerUnkEu = 0; + seqPlayer->tempoAcc = 0; + seqPlayer->tempo = 120 * TATUMS_PER_BEAT; // 120 BPM + seqPlayer->unk_0C = 0; + seqPlayer->transposition = 0; + seqPlayer->noteAllocPolicy = 0; + seqPlayer->shortNoteVelocityTable = gDefaultShortNoteVelocityTable; + seqPlayer->shortNoteGateTimeTable = gDefaultShortNoteGateTimeTable; + seqPlayer->scriptCounter = 0; + seqPlayer->unk_16 = 0; + seqPlayer->fadeVolume = 1.0f; + seqPlayer->fadeVelocity = 0.0f; + seqPlayer->volume = 0.0f; + seqPlayer->muteVolumeScale = 0.5f; + + for (i = 0; i < SEQ_NUM_CHANNELS; i++) { + AudioSeq_InitSequenceChannel(seqPlayer->channels[i]); + } +} + +void AudioSeq_InitSequencePlayerChannels(s32 playerIndex) { + SequenceChannel* channel; + SequencePlayer* seqPlayer = &gAudioContext.seqPlayers[playerIndex]; + s32 i; + s32 j; + + for (i = 0; i < SEQ_NUM_CHANNELS; i++) { + seqPlayer->channels[i] = AudioHeap_AllocZeroed(&gAudioContext.miscPool, sizeof(SequenceChannel)); + if (seqPlayer->channels[i] == NULL) { + seqPlayer->channels[i] = &gAudioContext.sequenceChannelNone; + } else { + channel = seqPlayer->channels[i]; + channel->seqPlayer = seqPlayer; + channel->enabled = false; + channel->unk_11 = i; + for (j = 0; j < ARRAY_COUNT(channel->layers); j++) { + channel->layers[j] = NULL; + } + } + + AudioSeq_InitSequenceChannel(seqPlayer->channels[i]); + } +} + +void AudioSeq_InitSequencePlayer(SequencePlayer* seqPlayer) { + s32 i; + s32 j; + + for (i = 0; i < SEQ_NUM_CHANNELS; i++) { + seqPlayer->channels[i] = &gAudioContext.sequenceChannelNone; + } + + seqPlayer->enabled = false; + seqPlayer->muted = false; + seqPlayer->fontDmaInProgress = false; + seqPlayer->seqDmaInProgress = false; + seqPlayer->applyBend = false; + + for (j = 0; j < ARRAY_COUNT(seqPlayer->soundScriptIO); j++) { + seqPlayer->soundScriptIO[j] = -1; + } + + seqPlayer->muteFlags = MUTE_FLAGS_SOFTEN | MUTE_FLAGS_STOP_NOTES; + seqPlayer->fadeVolumeScale = 1.0f; + seqPlayer->bend = 1.0f; + + AudioPlayback_InitNoteLists(&seqPlayer->notePool); + AudioSeq_ResetSequencePlayer(seqPlayer); +} + +void AudioSeq_InitSequencePlayers(void) { + s32 i; + + AudioSeq_InitLayerFreelist(); + + for (i = 0; i < ARRAY_COUNT(gAudioContext.sequenceLayers); i++) { + gAudioContext.sequenceLayers[i].channel = NULL; + gAudioContext.sequenceLayers[i].enabled = false; + } + + for (i = 0; i < ARRAY_COUNT(gAudioContext.seqPlayers); i++) { + AudioSeq_InitSequencePlayer(&gAudioContext.seqPlayers[i]); + } +} diff --git a/src/code/audio/audio_sfx_params.c b/src/code/audio/audio_sfx_params.c index dd23da443..0066328b1 100644 --- a/src/code/audio/audio_sfx_params.c +++ b/src/code/audio/audio_sfx_params.c @@ -1,496 +1,40 @@ #include "global.h" -/** - * TODO: - * the number of #efined sfx's we have for each bank does not seem to line up with the - * number of SfxParam entries for each bank. So at some point either through hacking or - * decompilation/documentation of sequence 0, the sfxs should be verified, especially - * the ones that come at the end of the list (all the earlier sfxs in each bank seem fine). - * - * After that, defines should be paired with sfxparams to make it easier to look up - * specific sfxsparams for a a certain sfx i.e.: - * { 0x18, 0, 0x1 }, // NA_SE_EN_DODO_J_WALK - * { 0x30, 0, 0x1 }, // NA_SE_EN_DODO_J_CRY - * { 0x30, 0, 0x1 }, // NA_SE_EN_DODO_J_FIRE - */ +#define DEFINE_SFX(_0, importance, distParam, randParam, flags2, flags1) \ + { importance, flags2, \ + ((((distParam) << SFX_PARAM_DIST_RANGE_SHIFT) & SFX_PARAM_DIST_RANGE_MASK) | \ + (((randParam) << SFX_PARAM_RAND_FREQ_RAISE_SHIFT) & SFX_PARAM_RAND_FREQ_RAISE_MASK) | (flags1)) }, SfxParams sEnemyBankParams[] = { - { 0x18, 0, 0x1 }, { 0x30, 0, 0x1 }, { 0x30, 0, 0x1 }, { 0x38, 0, 0x1 }, { 0x40, 0, 0x1 }, - { 0x30, 0, 0x3 }, { 0x36, 0, 0 }, { 0x38, 0, 0 }, { 0x40, 0, 0x3 }, { 0x58, 0, 0x3 }, - { 0x40, 0, 0x3 }, { 0x68, 0, 0x1003 }, { 0x40, 0, 0x3 }, { 0x30, 0, 0x3 }, { 0x40, 0, 0x3 }, - { 0x40, 0, 0x3 }, { 0x54, 0, 0xB }, { 0x54, 0, 0x3 }, { 0x30, 0, 0x3 }, { 0x40, 0, 0x3 }, - { 0x40, 0, 0x3 }, { 0x54, 0, 0x3 }, { 0x54, 0, 0x3 }, { 0x54, 0, 0x3 }, { 0x30, 0, 0x2003 }, - { 0x50, 0, 0x3 }, { 0x58, 0, 0x3 }, { 0x38, 0, 0x3 }, { 0x50, 0, 0x3 }, { 0x30, 0, 0x3 }, - { 0x38, 0, 0 }, { 0x48, 0, 0 }, { 0x30, 0, 0 }, { 0x40, 0, 0x1 }, { 0x18, 0, 0 }, - { 0x14, 0, 0 }, { 0x14, 0, 0 }, { 0x30, 0, 0 }, { 0x30, 0, 0 }, { 0x28, 0, 0x4000 }, - { 0x28, 0, 0 }, { 0x30, 0, 0x2 }, { 0x32, 0, 0x2 }, { 0x38, 0, 0x1 }, { 0x20, 0, 0 }, - { 0x40, 0, 0x1 }, { 0x18, 0, 0 }, { 0x28, 0, 0 }, { 0x18, 0, 0x40 }, { 0x30, 0, 0 }, - { 0x38, 0, 0x1 }, { 0x40, 0, 0x1 }, { 0x14, 0, 0 }, { 0x18, 0, 0x80 }, { 0x38, 0, 0x2 }, - { 0x34, 0, 0 }, { 0x28, 0, 0x1 }, { 0x30, 0, 0 }, { 0x38, 0, 0x1 }, { 0x40, 0, 0x1 }, - { 0x30, 0, 0 }, { 0x18, 0, 0 }, { 0x20, 0, 0 }, { 0x30, 0, 0 }, { 0x32, 0, 0 }, - { 0x20, 0, 0x1 }, { 0x37, 0, 0x1 }, { 0x38, 0, 0x1 }, { 0x30, 0, 0 }, { 0x30, 0, 0 }, - { 0x40, 0, 0x2 }, { 0x38, 0, 0x2 }, { 0x20, 0, 0 }, { 0x18, 0, 0 }, { 0x40, 0, 0x4007 }, - { 0x40, 0, 0x1 }, { 0x30, 0, 0x3 }, { 0x30, 0, 0x3 }, { 0x30, 0, 0x3 }, { 0x30, 0, 0x3 }, - { 0x30, 0, 0 }, { 0x40, 0, 0 }, { 0x30, 0, 0x3 }, { 0x30, 0, 0x3 }, { 0x34, 0, 0 }, - { 0x34, 0, 0 }, { 0x36, 0, 0 }, { 0x30, 0, 0x3 }, { 0x28, 0, 0 }, { 0x30, 0, 0 }, - { 0x18, 0, 0 }, { 0x30, 0, 0 }, { 0x28, 0, 0xC0 }, { 0x30, 0, 0x40 }, { 0x38, 0, 0x41 }, - { 0x40, 0, 0x41 }, { 0x30, 0, 0 }, { 0x36, 0, 0 }, { 0x40, 0, 0x1 }, { 0x14, 0, 0 }, - { 0x30, 0, 0 }, { 0x20, 0, 0 }, { 0x40, 0, 0x1 }, { 0x30, 0, 0x3 }, { 0x30, 0, 0x4 }, - { 0x30, 0, 0x4 }, { 0x20, 0, 0x4 }, { 0x38, 0, 0x4 }, { 0x20, 0, 0x3 }, { 0x38, 0, 0x1 }, - { 0x40, 0, 0x1 }, { 0x14, 0, 0 }, { 0x30, 0, 0x3 }, { 0x20, 0, 0x1 }, { 0x20, 0, 0x1 }, - { 0x30, 0, 0x2 }, { 0x35, 0, 0x2 }, { 0x38, 0, 0x2 }, { 0x48, 0, 0x2 }, { 0x40, 0, 0x2 }, - { 0x45, 0, 0x81 }, { 0x34, 0, 0 }, { 0x40, 0, 0 }, { 0x20, 0, 0x2 }, { 0x28, 0, 0 }, - { 0x28, 0, 0 }, { 0x30, 0, 0 }, { 0x20, 0, 0x84 }, { 0x38, 0, 0x1 }, { 0x40, 0, 0x1 }, - { 0x20, 0, 0 }, { 0x30, 0, 0x3 }, { 0x30, 0, 0x4 }, { 0x40, 0, 0x4 }, { 0x40, 0, 0x3 }, - { 0x40, 0, 0x1 }, { 0x28, 0, 0x1 }, { 0x30, 0, 0x3 }, { 0x20, 0, 0 }, { 0x38, 0, 0x1 }, - { 0x30, 0, 0x4 }, { 0x30, 0, 0 }, { 0x20, 0, 0 }, { 0x20, 0, 0 }, { 0x38, 0, 0x2000 }, - { 0x30, 0, 0x3 }, { 0x30, 0, 0x2000 }, { 0x30, 0, 0 }, { 0x14, 0, 0 }, { 0x38, 0, 0x1 }, - { 0x40, 0, 0x1 }, { 0x14, 0, 0 }, { 0x20, 0, 0 }, { 0x20, 0, 0 }, { 0x30, 0, 0 }, - { 0x40, 0, 0x1 }, { 0x30, 0, 0x80 }, { 0x30, 0, 0 }, { 0x37, 0, 0x1 }, { 0x40, 0, 0x1 }, - { 0x28, 0, 0x5 }, { 0x36, 0, 0x5 }, { 0x38, 0, 0x5 }, { 0x48, 0, 0x5 }, { 0x30, 0, 0x3 }, - { 0x28, 0, 0x2 }, { 0x30, 0, 0x3 }, { 0x30, 0, 0x3 }, { 0x34, 0, 0x3 }, { 0x38, 0, 0x3 }, - { 0x40, 0, 0x3 }, { 0x30, 0, 0x3 }, { 0x30, 0, 0x2000 }, { 0x30, 0, 0x3 }, { 0x38, 0, 0x3 }, - { 0x40, 0, 0x3 }, { 0x30, 0, 0x3 }, { 0x30, 0, 0x3 }, { 0x30, 0, 0x403 }, { 0x38, 0, 0x1 }, - { 0x30, 0, 0x43 }, { 0x30, 0, 0x3 }, { 0x20, 0, 0 }, { 0x34, 0, 0 }, { 0x18, 0, 0x80 }, - { 0x30, 0, 0 }, { 0x38, 0, 0 }, { 0x30, 0, 0 }, { 0x14, 0, 0 }, { 0x34, 0, 0 }, - { 0x40, 0, 0 }, { 0x30, 0, 0x3 }, { 0x20, 0, 0 }, { 0x30, 0, 0x80 }, { 0x30, 0, 0 }, - { 0x30, 0, 0 }, { 0x28, 0, 0 }, { 0x30, 0, 0x80 }, { 0x40, 0, 0x1 }, { 0x40, 0, 0x1 }, - { 0x20, 0, 0 }, { 0x20, 0, 0 }, { 0x14, 0, 0 }, { 0x30, 0, 0 }, { 0x30, 0, 0 }, - { 0x30, 0, 0 }, { 0x40, 0, 0x1 }, { 0x30, 0, 0 }, { 0x30, 0, 0x3 }, { 0x38, 0, 0x3 }, - { 0x40, 0, 0x3 }, { 0x48, 0, 0x3 }, { 0x30, 0, 0x3 }, { 0x34, 0, 0x3 }, { 0x48, 0, 0x3 }, - { 0x30, 0, 0x3 }, { 0x34, 0, 0x3 }, { 0x30, 0, 0x4083 }, { 0x30, 0, 0x4083 }, { 0x40, 0, 0x3 }, - { 0x38, 0, 0x1 }, { 0x30, 0, 0x1 }, { 0x28, 0, 0x3 }, { 0x28, 0, 0x3 }, { 0x30, 0, 0x3 }, - { 0x30, 0, 0x3 }, { 0x30, 0, 0x2003 }, { 0x38, 0, 0x1 }, { 0x20, 0, 0 }, { 0x34, 0, 0 }, - { 0x38, 0, 0x1 }, { 0x40, 0, 0x1 }, { 0x34, 0, 0x2000 }, { 0x20, 0, 0 }, { 0x38, 0, 0x42 }, - { 0x40, 0, 0x1 }, { 0x30, 0, 0x3 }, { 0x30, 0, 0x2 }, { 0x30, 0, 0x2 }, { 0x38, 0, 0x3 }, - { 0x30, 0, 0 }, { 0x30, 0, 0 }, { 0x34, 0, 0 }, { 0x34, 0, 0x3 }, { 0x30, 0, 0x3 }, - { 0x24, 0, 0x40 }, { 0x30, 0, 0x3 }, { 0x28, 0, 0x82 }, { 0x40, 0, 0x3 }, { 0x40, 0, 0x3 }, - { 0x30, 0, 0x3 }, { 0x34, 0, 0x3 }, { 0x20, 0, 0x83 }, { 0x20, 0, 0 }, { 0x30, 0, 0x3 }, - { 0x20, 0, 0x80 }, { 0x30, 0, 0x83 }, { 0x18, 0, 0x83 }, { 0x34, 0, 0x83 }, { 0x30, 0, 0x83 }, - { 0x38, 0, 0x3 }, { 0x18, 0, 0x3 }, { 0x30, 0, 0x2000 }, { 0x38, 0, 0x3 }, { 0x30, 0, 0x3 }, - { 0x40, 0, 0x3 }, { 0x40, 0, 0x2004 }, { 0x38, 0, 0x5 }, { 0x30, 0, 0x2000 }, { 0x30, 0, 0x3 }, - { 0x30, 0, 0x80 }, { 0x30, 0, 0x5 }, { 0x30, 0, 0x3 }, { 0x30, 0, 0x82 }, { 0x30, 0, 0x3 }, - { 0x30, 0, 0x5 }, { 0x30, 0, 0x3 }, { 0x30, 0, 0x84 }, { 0x38, 0, 0x80 }, { 0x38, 0, 0x6083 }, - { 0x38, 0, 0x6083 }, { 0x38, 0, 0x6083 }, { 0x38, 0, 0x6083 }, { 0x40, 0, 0x4082 }, { 0x18, 0, 0x83 }, - { 0x30, 0, 0x3 }, { 0x30, 0, 0x3 }, { 0x20, 0, 0x3 }, { 0x24, 0, 0x5 }, { 0x28, 0, 0x3 }, - { 0x30, 0, 0x3 }, { 0x30, 0, 0x5 }, { 0x30, 0, 0x5 }, { 0x30, 0, 0 }, { 0x30, 0, 0 }, - { 0x30, 0, 0x3 }, { 0x18, 0, 0x1 }, { 0x34, 0, 0x3 }, { 0x30, 0, 0x5 }, { 0x34, 0, 0x3 }, - { 0x34, 0, 0x3 }, { 0x34, 0, 0x3 }, { 0x30, 0, 0x3 }, { 0x30, 0, 0x3 }, { 0x30, 0, 0x1 }, - { 0x14, 0, 0 }, { 0x40, 0, 0x1 }, { 0x30, 0, 0x1 }, { 0x30, 0, 0x1 }, { 0x20, 0, 0x1 }, - { 0x38, 0, 0x3 }, { 0x30, 0, 0 }, { 0x40, 0, 0x4003 }, { 0x30, 0, 0x4003 }, { 0x38, 0, 0x3 }, - { 0x38, 0, 0x3 }, { 0x40, 0, 0x3 }, { 0x40, 0, 0x83 }, { 0x40, 0, 0x83 }, { 0x40, 0, 0x3 }, - { 0x21, 0, 0x4003 }, { 0x54, 0, 0x3 }, { 0x54, 0, 0x3 }, { 0x54, 0, 0x3 }, { 0x34, 0, 0x2 }, - { 0x58, 0, 0x3 }, { 0x68, 0, 0x3 }, { 0x50, 0, 0x40C3 }, { 0x14, 0, 0 }, { 0x20, 0, 0x1 }, - { 0x48, 0, 0x4080 }, { 0x30, 0, 0x4080 }, { 0x50, 0, 0x1 }, { 0x50, 0, 0x1 }, { 0x50, 0, 0 }, - { 0x50, 0, 0 }, { 0x68, 0, 0x3 }, { 0x58, 0, 0x3 }, { 0x90, 0, 0x3 }, { 0x48, 0, 0x3 }, - { 0x28, 0, 0x2 }, { 0x30, 0, 0 }, { 0x38, 0, 0x1 }, { 0x28, 0, 0x2 }, { 0x50, 0, 0x3 }, - { 0x50, 0, 0x3 }, { 0x50, 0, 0x3 }, { 0x40, 0, 0x4083 }, { 0x40, 0, 0x3 }, { 0x40, 0, 0x3 }, - { 0x40, 0, 0x3 }, { 0x40, 0, 0x3 }, { 0x54, 0, 0x3 }, { 0x40, 0, 0x3 }, { 0x40, 0, 0x3 }, - { 0x48, 0, 0x3 }, { 0x48, 0, 0x3 }, { 0x48, 0, 0x3 }, { 0x40, 0, 0x3 }, { 0x34, 0, 0x2 }, - { 0x34, 0, 0x2002 }, { 0x28, 0, 0x2 }, { 0x28, 0, 0x2 }, { 0x30, 0, 0x2 }, { 0x30, 0, 0x2 }, - { 0x38, 0, 0x2 }, { 0x38, 0, 0x2 }, { 0x48, 0, 0x2 }, { 0x10, 0, 0 }, { 0x34, 0, 0 }, - { 0x18, 0, 0 }, { 0x30, 0, 0 }, { 0x14, 0, 0 }, { 0x34, 0, 0 }, { 0x28, 0, 0x1 }, - { 0x38, 0, 0x1 }, { 0x40, 0, 0x1 }, { 0x30, 0, 0x1 }, { 0x38, 0, 0x1 }, { 0x36, 0, 0x1 }, - { 0x34, 0, 0x1 }, { 0x38, 0, 0x1 }, { 0x48, 0, 0x1 }, { 0x30, 0, 0x1 }, { 0x38, 0, 0x83 }, - { 0x30, 0, 0x3 }, { 0x20, 0, 0x2000 }, { 0x30, 0, 0x3 }, { 0x30, 0, 0 }, { 0x40, 0, 0x1 }, - { 0x30, 0, 0 }, { 0x20, 0, 0 }, { 0x38, 0, 0x1 }, { 0x40, 0, 0x1 }, { 0x30, 0, 0 }, - { 0x30, 0, 0x2000 }, { 0x30, 0, 0x3 }, { 0x30, 0, 0x2 }, { 0x30, 0, 0x3 }, { 0x30, 0, 0x3 }, - { 0x18, 0, 0 }, { 0x28, 0, 0 }, { 0x34, 0, 0x2 }, { 0x34, 0, 0x2 }, { 0x34, 0, 0 }, - { 0x38, 0, 0x1 }, { 0x40, 0, 0x1 }, { 0x30, 0, 0x3 }, { 0x30, 0, 0x2 }, { 0x38, 0, 0 }, - { 0x48, 0, 0 }, { 0x28, 0, 0x4004 }, { 0x48, 0, 0x4 }, { 0x20, 0, 0x4 }, { 0x25, 0, 0x3 }, - { 0x40, 0, 0x2 }, { 0x18, 0, 0x80 }, { 0x44, 0, 0x3 }, { 0x44, 0, 0 }, { 0x18, 0, 0 }, - { 0x30, 0, 0 }, { 0x38, 0, 0x1 }, { 0x40, 0, 0x1 }, { 0x18, 0, 0x3 }, { 0x30, 0, 0x3 }, - { 0x38, 0, 0x43 }, { 0x30, 0, 0x3 }, { 0x30, 0, 0x3 }, { 0x30, 0, 0x3 }, { 0x36, 0, 0x3 }, - { 0x34, 0, 0x3 }, { 0x34, 0, 0x82 }, { 0x58, 0, 0x3 }, { 0x68, 0, 0x3 }, { 0x30, 0, 0x3 }, - { 0x30, 0, 0x3 }, { 0x34, 0, 0x2 }, { 0x34, 0, 0x3 }, { 0x40, 0, 0 }, { 0x30, 0, 0x3 }, - { 0x40, 0, 0x2000 }, { 0x30, 0, 0x2000 }, { 0x30, 0, 0xC0 }, { 0x30, 0, 0xC0 }, { 0x40, 0, 0 }, - { 0x30, 0, 0x3 }, { 0x28, 0, 0x3 }, { 0x40, 0, 0x3 }, { 0x40, 0, 0x3 }, { 0x30, 0, 0x3 }, - { 0x30, 0, 0x3 }, { 0x30, 0, 0x3 }, { 0x30, 0, 0x3 }, { 0x38, 0, 0x3 }, { 0x48, 0, 0x3 }, - { 0x20, 0, 0x3 }, { 0x48, 0, 0x3 }, { 0x36, 0, 0x3 }, { 0x30, 0, 0x3 }, { 0x30, 0, 0x3 }, - { 0x38, 0, 0x3 }, { 0x38, 0, 0x3 }, { 0x20, 0, 0x3 }, { 0x30, 0, 0x3 }, { 0x44, 0, 0x3 }, - { 0x30, 0, 0x83 }, { 0x30, 0, 0x3 }, { 0x30, 0, 0x3 }, { 0x34, 0, 0x3 }, { 0x30, 0, 0x3 }, - { 0x30, 0, 0x3 }, { 0x20, 0, 0x2 }, { 0x34, 0, 0x3 }, { 0x20, 0, 0x83 }, { 0x30, 0, 0x4 }, - { 0x30, 0, 0x4042 }, { 0x40, 0, 0x4042 }, { 0x40, 0, 0x83 }, { 0x30, 0, 0x4042 }, { 0x30, 0, 0x4042 }, - { 0x30, 0, 0 }, { 0x30, 0, 0 }, { 0x30, 0, 0x1 }, { 0x32, 0, 0x4082 }, { 0x32, 0, 0x3 }, - { 0x54, 0, 0x1 }, { 0x52, 0, 0 }, { 0x54, 0, 0x3 }, { 0x30, 0, 0 }, { 0x08, 0, 0x1 }, - { 0x30, 0, 0x1 }, { 0x30, 0, 0x3 }, { 0x54, 0, 0x3 }, { 0x54, 0, 0x2000 }, { 0x34, 0, 0x3 }, - { 0x54, 0, 0x2000 }, { 0x08, 0, 0 }, { 0x54, 0, 0 }, { 0x34, 0, 0 }, { 0x15, 0, 0 }, - { 0x35, 0, 0 }, { 0x48, 0, 0 }, { 0x38, 0, 0 }, { 0x30, 0, 0 }, { 0x30, 0, 0xC2 }, - { 0x38, 0, 0x2 }, { 0x38, 0, 0x2 }, { 0x30, 0, 0x80 }, { 0x30, 0, 0 }, { 0x30, 0, 0 }, - { 0x30, 0, 0 }, { 0x30, 0, 0 }, { 0x30, 0x1, 0x80 }, { 0x30, 0xB4, 0x6 }, { 0x30, 0, 0 }, - { 0x30, 0, 0x6 }, { 0x30, 0, 0x83 }, { 0x30, 0, 0 }, { 0x30, 0, 0x2 }, { 0x30, 0, 0x2 }, - { 0x30, 0, 0x2 }, { 0x48, 0, 0x2 }, { 0x28, 0, 0x1 }, { 0x36, 0, 0 }, { 0x38, 0, 0 }, - { 0x48, 0, 0 }, { 0x68, 0, 0x3 }, { 0x30, 0, 0x3 }, { 0x30, 0, 0x3 }, { 0x38, 0, 0x3 }, - { 0x48, 0, 0x3 }, { 0x58, 0, 0x3 }, { 0x68, 0, 0x3 }, { 0x29, 0, 0x3 }, { 0x54, 0, 0x3 }, - { 0x30, 0, 0 }, { 0x30, 0, 0 }, { 0x30, 0, 0x40 }, { 0x30, 0, 0x40 }, { 0x30, 0, 0x40 }, - { 0x30, 0, 0 }, { 0x68, 0, 0x3 }, { 0x30, 0, 0 }, { 0x45, 0, 0x2 }, { 0x40, 0, 0x4043 }, - { 0x40, 0, 0x4043 }, { 0x30, 0, 0x4043 }, { 0x30, 0, 0x4043 }, { 0x30, 0, 0x4043 }, { 0x30, 0, 0x4043 }, - { 0x30, 0, 0x4083 }, { 0x30, 0, 0x4083 }, { 0x30, 0, 0x4083 }, { 0x50, 0, 0x3 }, { 0x30, 0, 0x3 }, - { 0x30, 0, 0x3 }, { 0x10, 0, 0 }, { 0x54, 0, 0x3 }, { 0x50, 0, 0x3 }, { 0x50, 0, 0x3 }, - { 0x54, 0, 0x43 }, { 0x50, 0, 0x43 }, { 0x50, 0, 0x43 }, { 0x50, 0, 0x43 }, { 0x36, 0, 0x43 }, - { 0x34, 0, 0x43 }, { 0x34, 0, 0x83 }, { 0x36, 0, 0x43 }, { 0x35, 0, 0x43 }, { 0x34, 0, 0x83 }, - { 0x58, 0, 0x43 }, { 0x68, 0, 0x43 }, { 0x38, 0, 0x43 }, { 0x48, 0, 0x43 }, { 0x38, 0, 0x43 }, - { 0x48, 0, 0x43 }, { 0x34, 0, 0x83 }, { 0x34, 0, 0x4043 }, { 0x34, 0, 0x4043 }, { 0x34, 0, 0x83 }, - { 0x34, 0, 0x4043 }, { 0x50, 0, 0x43 }, { 0x34, 0, 0x43 }, { 0x50, 0, 0x43 }, { 0x36, 0, 0x43 }, - { 0x36, 0, 0x43 }, { 0x34, 0, 0x43 }, { 0x37, 0, 0x3 }, { 0x54, 0, 0x43 }, { 0x40, 0, 0x3 }, - { 0x40, 0, 0x3 }, { 0x57, 0, 0x3 }, { 0x34, 0, 0x2 }, { 0x40, 0, 0 }, { 0x32, 0, 0 }, - { 0x50, 0, 0x83 }, { 0x50, 0, 0x83 }, { 0x50, 0, 0x83 }, { 0x50, 0, 0x83 }, { 0x50, 0, 0x83 }, - { 0x58, 0, 0x83 }, { 0x58, 0, 0x83 }, { 0x68, 0, 0x3 }, { 0x68, 0, 0x3 }, { 0x48, 0, 0x3 }, - { 0x48, 0, 0x3 }, { 0x50, 0, 0x3 }, { 0x50, 0, 0x3 }, { 0x28, 0, 0x4 }, { 0x34, 0, 0x2 }, - { 0x30, 0, 0x4080 }, { 0x30, 0, 0x4080 }, { 0x30, 0, 0x4080 }, { 0x30, 0, 0x4080 }, { 0x30, 0, 0x1 }, - { 0x30, 0, 0x84 }, { 0x50, 0, 0x3 }, { 0x50, 0, 0x3 }, { 0x50, 0, 0x3 }, { 0x50, 0, 0x3 }, - { 0x58, 0, 0x3 }, { 0x58, 0, 0x3 }, { 0x68, 0, 0x3 }, { 0x50, 0, 0x3 }, { 0x50, 0, 0x3 }, - { 0x30, 0, 0x1 }, { 0x30, 0, 0x1 }, { 0x30, 0, 0x1 }, { 0x30, 0, 0x1 }, { 0x34, 0, 0x80 }, - { 0x34, 0, 0 }, { 0x34, 0, 0 }, { 0x34, 0, 0 }, { 0x34, 0, 0 }, { 0x34, 0, 0 }, - { 0x34, 0, 0 }, { 0x34, 0, 0 }, { 0x34, 0, 0 }, { 0x34, 0, 0 }, { 0x54, 0, 0 }, - { 0x34, 0, 0 }, { 0x34, 0, 0x2000 }, { 0x34, 0, 0x2000 }, { 0x34, 0, 0 }, { 0x30, 0, 0x5 }, - { 0x30, 0, 0x1 }, { 0x30, 0, 0 }, { 0x30, 0, 0 }, { 0x34, 0, 0x4083 }, { 0x34, 0, 0x4083 }, - { 0x30, 0, 0x4083 }, { 0x30, 0, 0x4083 }, { 0x34, 0, 0 }, { 0x30, 0, 0 }, { 0x34, 0, 0x1083 }, - { 0x30, 0, 0x1005 }, { 0x30, 0, 0x4080 }, { 0x34, 0, 0 }, { 0x34, 0, 0 }, { 0x30, 0, 0x6 }, - { 0x30, 0, 0x6 }, { 0x30, 0, 0x5 }, { 0x30, 0, 0x6 }, { 0x34, 0, 0 }, { 0x38, 0, 0 }, - { 0x48, 0, 0 }, { 0x30, 0, 0x80 }, { 0x30, 0, 0x85 }, { 0x30, 0, 0 }, { 0x30, 0, 0 }, - { 0x30, 0, 0x80 }, { 0x30, 0, 0 }, { 0x30, 0, 0 }, { 0x40, 0, 0x2 }, { 0x32, 0, 0x80 }, - { 0x50, 0, 0x2 }, { 0x50, 0, 0x2 }, { 0x58, 0, 0x2 }, { 0x68, 0, 0x2 }, { 0x30, 0, 0 }, - { 0x30, 0, 0 }, { 0x50, 0, 0x2 }, { 0x50, 0, 0x2 }, { 0x30, 0, 0x3 }, { 0x54, 0, 0x5 }, - { 0x28, 0, 0x5 }, { 0x78, 0, 0x2000 }, { 0x78, 0, 0x2000 }, { 0x50, 0, 0x3 }, { 0x58, 0, 0x3 }, - { 0x68, 0, 0x3 }, { 0x54, 0, 0x3 }, { 0x40, 0, 0x3 }, { 0x78, 0, 0x3 }, { 0x48, 0, 0 }, - { 0x30, 0, 0x83 }, { 0x30, 0, 0x83 }, { 0x30, 0, 0x83 }, { 0x30, 0, 0x3 }, { 0x30, 0, 0 }, - { 0x30, 0, 0 }, { 0x30, 0, 0xC3 }, { 0x30, 0, 0x80 }, { 0x30, 0, 0x2000 }, { 0x30, 0, 0x2000 }, - { 0x30, 0, 0x2000 }, { 0x30, 0, 0x2000 }, { 0x30, 0, 0x2000 }, { 0x30, 0, 0x45 }, { 0x60, 0, 0x2 }, - { 0x70, 0, 0x2000 }, { 0x30, 0, 0x80 }, { 0x30, 0, 0x80 }, { 0x30, 0, 0x80 }, { 0x30, 0, 0x80 }, - { 0x30, 0, 0x80 }, { 0x30, 0, 0x80 }, { 0x30, 0, 0x80 }, { 0x30, 0, 0x80 }, { 0x30, 0, 0x80 }, - { 0x30, 0, 0x80 }, { 0x30, 0, 0 }, { 0x30, 0, 0 }, { 0x30, 0, 0x7 }, { 0x30, 0, 0x44 }, - { 0x30, 0, 0x44 }, { 0x30, 0, 0x83 }, { 0x48, 0, 0x3 }, { 0x58, 0, 0x3 }, { 0x30, 0, 0 }, - { 0x30, 0, 0x3 }, { 0x36, 0, 0 }, { 0x40, 0, 0x2 }, { 0x30, 0, 0 }, { 0x30, 0, 0 }, - { 0x30, 0, 0 }, +#include "tables/sfx/enemybank_table.h" }; SfxParams sPlayerBankParams[] = { - { 0x20, 0, 0x480 }, { 0x20, 0, 0x480 }, { 0x20, 0, 0x480 }, { 0x20, 0, 0x480 }, { 0x20, 0, 0x440 }, - { 0x20, 0, 0x440 }, { 0x20, 0, 0x440 }, { 0x20, 0, 0x440 }, { 0x20, 0, 0x480 }, { 0x20, 0, 0x440 }, - { 0x20, 0, 0x480 }, { 0x20, 0, 0x400 }, { 0x20, 0, 0x400 }, { 0x20, 0, 0x400 }, { 0x20, 0, 0x400 }, - { 0x20, 0, 0x400 }, { 0x30, 0, 0x400 }, { 0x30, 0, 0x400 }, { 0x30, 0, 0x400 }, { 0x30, 0, 0x400 }, - { 0x30, 0, 0x400 }, { 0x30, 0, 0x400 }, { 0x30, 0, 0x400 }, { 0x30, 0, 0x400 }, { 0x30, 0, 0x400 }, - { 0x30, 0, 0x400 }, { 0x30, 0, 0x400 }, { 0x30, 0, 0x400 }, { 0x30, 0, 0x400 }, { 0x30, 0, 0x400 }, - { 0x30, 0, 0x400 }, { 0x30, 0, 0x400 }, { 0x40, 0, 0x440 }, { 0x40, 0, 0x440 }, { 0x40, 0, 0x440 }, - { 0x40, 0, 0x440 }, { 0x40, 0, 0x440 }, { 0x40, 0, 0x440 }, { 0x40, 0, 0x440 }, { 0x40, 0, 0x440 }, - { 0x40, 0, 0x440 }, { 0x40, 0, 0x440 }, { 0x40, 0, 0x440 }, { 0x40, 0, 0x440 }, { 0x40, 0, 0x440 }, - { 0x40, 0, 0x440 }, { 0x40, 0, 0x440 }, { 0x40, 0, 0x440 }, { 0x30, 0, 0x80 }, { 0x30, 0, 0 }, - { 0x30, 0, 0 }, { 0x30, 0, 0 }, { 0x30, 0, 0x400 }, { 0x30, 0, 0x400 }, { 0x30, 0, 0x400 }, - { 0x30, 0, 0x40 }, { 0x30, 0, 0x40 }, { 0x30, 0, 0x80 }, { 0x30, 0, 0x400 }, { 0x30, 0, 0x400 }, - { 0x40, 0, 0x400 }, { 0x30, 0, 0x400 }, { 0x30, 0, 0x402 }, { 0x30, 0, 0x400 }, { 0x30, 0, 0x40 }, - { 0x30, 0, 0x40 }, { 0x30, 0, 0x40 }, { 0x30, 0, 0x40 }, { 0x30, 0, 0x40 }, { 0x30, 0, 0x40 }, - { 0x30, 0, 0x40 }, { 0x30, 0, 0x40 }, { 0x30, 0, 0x40 }, { 0x30, 0, 0x40 }, { 0x30, 0, 0x40 }, - { 0x30, 0, 0x40 }, { 0x30, 0, 0 }, { 0x30, 0, 0 }, { 0x30, 0, 0 }, { 0x30, 0, 0 }, - { 0x80, 0, 0 }, { 0x80, 0, 0 }, { 0x80, 0, 0 }, { 0x80, 0, 0 }, { 0x80, 0, 0 }, - { 0x80, 0, 0 }, { 0x80, 0, 0 }, { 0x80, 0, 0 }, { 0x80, 0, 0 }, { 0x80, 0, 0 }, - { 0x80, 0, 0 }, { 0x80, 0, 0 }, { 0x80, 0, 0 }, { 0x80, 0, 0 }, { 0x80, 0, 0 }, - { 0x80, 0, 0 }, { 0x30, 0, 0x440 }, { 0x30, 0, 0 }, { 0x30, 0, 0 }, { 0x30, 0, 0 }, - { 0x30, 0, 0 }, { 0x30, 0, 0 }, { 0x30, 0, 0x400 }, { 0x30, 0, 0x400 }, { 0x30, 0, 0 }, - { 0x30, 0, 0 }, { 0x30, 0, 0 }, { 0x30, 0, 0 }, { 0x30, 0, 0x3 }, { 0x30, 0, 0 }, - { 0x30, 0, 0 }, { 0x30, 0, 0 }, { 0x30, 0, 0 }, { 0x30, 0, 0x80 }, { 0x30, 0, 0 }, - { 0x30, 0, 0 }, { 0x30, 0, 0x3 }, { 0x30, 0, 0x1 }, { 0x30, 0, 0 }, { 0x30, 0, 0 }, - { 0x30, 0, 0 }, { 0x30, 0, 0 }, { 0x30, 0, 0 }, { 0x30, 0, 0x2000 }, { 0x30, 0, 0xC00 }, - { 0x30, 0, 0x400 }, { 0x30, 0, 0x400 }, { 0x30, 0, 0x400 }, { 0x20, 0, 0x80 }, { 0x20, 0, 0x80 }, - { 0x20, 0, 0x80 }, { 0x20, 0, 0x80 }, { 0x20, 0, 0x40 }, { 0x20, 0, 0x40 }, { 0x20, 0, 0x40 }, - { 0x20, 0, 0x40 }, { 0x20, 0, 0x80 }, { 0x20, 0, 0x80 }, { 0x20, 0, 0x80 }, { 0x20, 0, 0 }, - { 0x20, 0, 0 }, { 0x20, 0, 0 }, { 0x20, 0, 0 }, { 0x20, 0, 0 }, { 0x30, 0, 0 }, - { 0x30, 0, 0 }, { 0x30, 0, 0 }, { 0x30, 0, 0 }, { 0x30, 0, 0 }, { 0x30, 0, 0 }, - { 0x30, 0, 0 }, { 0x30, 0, 0 }, { 0x30, 0, 0 }, { 0x30, 0, 0 }, { 0x30, 0, 0 }, - { 0x30, 0, 0 }, { 0x30, 0, 0 }, { 0x30, 0, 0 }, { 0x30, 0, 0 }, { 0x30, 0, 0 }, - { 0x40, 0, 0 }, { 0x40, 0, 0 }, { 0x40, 0, 0 }, { 0x40, 0, 0 }, { 0x40, 0, 0 }, - { 0x40, 0, 0 }, { 0x40, 0, 0 }, { 0x40, 0, 0 }, { 0x40, 0, 0 }, { 0x40, 0, 0 }, - { 0x40, 0, 0 }, { 0x40, 0, 0 }, { 0x40, 0, 0 }, { 0x40, 0, 0 }, { 0x40, 0, 0 }, - { 0x40, 0, 0 }, { 0x30, 0, 0x440 }, { 0x30, 0, 0x440 }, { 0x30, 0, 0x440 }, { 0x30, 0, 0x440 }, - { 0x30, 0, 0x440 }, { 0x30, 0, 0x440 }, { 0x30, 0, 0x440 }, { 0x30, 0, 0x440 }, { 0x30, 0, 0x440 }, - { 0x30, 0, 0x440 }, { 0x30, 0, 0x440 }, { 0x30, 0, 0x440 }, { 0x30, 0, 0x440 }, { 0x30, 0, 0x440 }, - { 0x30, 0, 0x440 }, { 0x30, 0, 0x440 }, { 0x30, 0, 0xC00 }, { 0x30, 0, 0x4080 }, { 0x30, 0, 0 }, - { 0x30, 0, 0 }, { 0x30, 0, 0 }, { 0x30, 0, 0 }, { 0x30, 0, 0 }, { 0x30, 0, 0 }, - { 0x60, 0, 0x2 }, { 0x30, 0, 0 }, { 0x30, 0, 0 }, { 0x30, 0, 0x800 }, { 0x30, 0, 0 }, - { 0x30, 0, 0 }, { 0x30, 0, 0x403 }, { 0x30, 0, 0 }, { 0x30, 0, 0 }, { 0x30, 0, 0 }, - { 0x30, 0, 0 }, { 0x30, 0, 0 }, { 0x30, 0, 0 }, { 0x30, 0, 0 }, { 0x30, 0, 0 }, - { 0x30, 0, 0 }, { 0x30, 0, 0 }, { 0x30, 0, 0 }, { 0x30, 0, 0 }, { 0x30, 0, 0 }, - { 0x30, 0, 0 }, { 0x30, 0, 0 }, { 0x30, 0, 0 }, { 0x30, 0, 0 }, { 0x30, 0, 0x400 }, - { 0x60, 0, 0x40 }, { 0x40, 0, 0 }, { 0x30, 0, 0 }, { 0x30, 0, 0 }, { 0x30, 0, 0 }, - { 0x30, 0, 0 }, { 0x30, 0, 0 }, { 0x50, 0, 0x43 }, { 0x30, 0, 0 }, { 0x30, 0, 0 }, - { 0x30, 0, 0 }, { 0x30, 0, 0 }, { 0x30, 0, 0 }, { 0x30, 0, 0 }, { 0x30, 0, 0 }, - { 0x20, 0, 0x480 }, { 0x20, 0, 0x480 }, { 0x20, 0, 0x480 }, { 0x20, 0, 0x480 }, { 0x20, 0, 0x440 }, - { 0x20, 0, 0x440 }, { 0x20, 0, 0x440 }, { 0x20, 0, 0x440 }, { 0x20, 0, 0x480 }, { 0x20, 0, 0x440 }, - { 0x20, 0, 0x480 }, { 0x20, 0, 0x400 }, { 0x20, 0, 0x400 }, { 0x20, 0, 0x400 }, { 0x20, 0, 0x400 }, - { 0x20, 0, 0x400 }, { 0x30, 0, 0x400 }, { 0x30, 0, 0x400 }, { 0x30, 0, 0x400 }, { 0x30, 0, 0x400 }, - { 0x30, 0, 0x400 }, { 0x30, 0, 0x400 }, { 0x30, 0, 0x400 }, { 0x30, 0, 0x400 }, { 0x30, 0, 0x400 }, - { 0x30, 0, 0x400 }, { 0x30, 0, 0x400 }, { 0x30, 0, 0x400 }, { 0x30, 0, 0x400 }, { 0x30, 0, 0x400 }, - { 0x30, 0, 0x400 }, { 0x30, 0, 0x400 }, { 0x40, 0, 0x440 }, { 0x40, 0, 0x440 }, { 0x40, 0, 0x440 }, - { 0x40, 0, 0x440 }, { 0x40, 0, 0x440 }, { 0x40, 0, 0x440 }, { 0x40, 0, 0x440 }, { 0x40, 0, 0x440 }, - { 0x40, 0, 0x440 }, { 0x40, 0, 0x440 }, { 0x40, 0, 0x440 }, { 0x40, 0, 0x440 }, { 0x40, 0, 0x440 }, - { 0x40, 0, 0x440 }, { 0x40, 0, 0x440 }, { 0x40, 0, 0x440 }, { 0x20, 0, 0x480 }, { 0x20, 0, 0x480 }, - { 0x20, 0, 0x480 }, { 0x20, 0, 0x480 }, { 0x20, 0, 0x440 }, { 0x20, 0, 0x440 }, { 0x20, 0, 0x440 }, - { 0x20, 0, 0x440 }, { 0x20, 0, 0x480 }, { 0x20, 0, 0x440 }, { 0x20, 0, 0x480 }, { 0x20, 0, 0x400 }, - { 0x20, 0, 0x400 }, { 0x20, 0, 0x400 }, { 0x20, 0, 0x400 }, { 0x20, 0, 0x400 }, { 0x30, 0, 0x400 }, - { 0x30, 0, 0x400 }, { 0x30, 0, 0x400 }, { 0x30, 0, 0x400 }, { 0x30, 0, 0x400 }, { 0x30, 0, 0x400 }, - { 0x30, 0, 0x400 }, { 0x30, 0, 0x400 }, { 0x30, 0, 0x400 }, { 0x30, 0, 0x400 }, { 0x30, 0, 0x400 }, - { 0x30, 0, 0x400 }, { 0x30, 0, 0x400 }, { 0x30, 0, 0x400 }, { 0x30, 0, 0x400 }, { 0x30, 0, 0x400 }, - { 0x40, 0, 0x440 }, { 0x40, 0, 0x440 }, { 0x40, 0, 0x440 }, { 0x40, 0, 0x440 }, { 0x40, 0, 0x440 }, - { 0x40, 0, 0x440 }, { 0x40, 0, 0x440 }, { 0x40, 0, 0x440 }, { 0x40, 0, 0x440 }, { 0x40, 0, 0x440 }, - { 0x40, 0, 0x440 }, { 0x40, 0, 0x440 }, { 0x40, 0, 0x440 }, { 0x40, 0, 0x440 }, { 0x40, 0, 0x440 }, - { 0x40, 0, 0x440 }, { 0x20, 0, 0x480 }, { 0x20, 0, 0x480 }, { 0x20, 0, 0x480 }, { 0x20, 0, 0x480 }, - { 0x20, 0, 0x440 }, { 0x20, 0, 0x440 }, { 0x20, 0, 0x440 }, { 0x20, 0, 0x440 }, { 0x20, 0, 0x480 }, - { 0x20, 0, 0x440 }, { 0x20, 0, 0x480 }, { 0x20, 0, 0x400 }, { 0x20, 0, 0x400 }, { 0x20, 0, 0x400 }, - { 0x20, 0, 0x400 }, { 0x20, 0, 0x400 }, { 0x30, 0, 0x400 }, { 0x30, 0, 0x400 }, { 0x30, 0, 0x400 }, - { 0x30, 0, 0x400 }, { 0x30, 0, 0x400 }, { 0x30, 0, 0x400 }, { 0x30, 0, 0x400 }, { 0x30, 0, 0x400 }, - { 0x30, 0, 0x400 }, { 0x30, 0, 0x400 }, { 0x30, 0, 0x400 }, { 0x30, 0, 0x400 }, { 0x30, 0, 0x400 }, - { 0x30, 0, 0x400 }, { 0x30, 0, 0x400 }, { 0x30, 0, 0x400 }, { 0x40, 0, 0x440 }, { 0x40, 0, 0x440 }, - { 0x40, 0, 0x440 }, { 0x40, 0, 0x440 }, { 0x40, 0, 0x440 }, { 0x40, 0, 0x440 }, { 0x40, 0, 0x440 }, - { 0x40, 0, 0x440 }, { 0x40, 0, 0x440 }, { 0x40, 0, 0x440 }, { 0x40, 0, 0x440 }, { 0x40, 0, 0x440 }, - { 0x40, 0, 0x440 }, { 0x40, 0, 0x440 }, { 0x40, 0, 0x440 }, { 0x40, 0, 0x440 }, { 0x30, 0, 0x400 }, - { 0x30, 0, 0x400 }, { 0x30, 0, 0x400 }, { 0x30, 0, 0x400 }, { 0x30, 0, 0x400 }, { 0x30, 0, 0x400 }, - { 0x30, 0, 0x400 }, { 0x30, 0, 0x400 }, { 0x30, 0, 0x400 }, { 0x30, 0, 0x400 }, { 0x30, 0, 0x400 }, - { 0x30, 0, 0x400 }, { 0x30, 0, 0x400 }, { 0x30, 0, 0x400 }, { 0x30, 0, 0x400 }, { 0x30, 0, 0x400 }, - { 0x30, 0, 0x400 }, { 0x30, 0, 0x400 }, { 0x50, 0, 0x400 }, { 0x50, 0, 0x400 }, { 0x30, 0, 0x400 }, - { 0x30, 0, 0x400 }, { 0x30, 0, 0x400 }, { 0x30, 0, 0x400 }, { 0x30, 0, 0x400 }, { 0x30, 0, 0x400 }, - { 0x30, 0, 0x400 }, { 0x30, 0, 0x400 }, { 0x30, 0, 0x400 }, { 0x30, 0, 0x400 }, { 0x30, 0, 0x400 }, - { 0x30, 0, 0x400 }, { 0x30, 0, 0x400 }, { 0x30, 0, 0x400 }, { 0x30, 0, 0x400 }, { 0x60, 0, 0x400 }, - { 0x30, 0, 0x400 }, { 0x30, 0, 0x400 }, { 0x30, 0, 0x400 }, { 0x30, 0, 0x400 }, { 0x30, 0, 0x400 }, - { 0x30, 0, 0x400 }, { 0x30, 0, 0x400 }, { 0x30, 0, 0x400 }, { 0x30, 0, 0x400 }, { 0x30, 0, 0x400 }, - { 0x30, 0, 0x4080 }, { 0x40, 0, 0x403 }, { 0x30, 0, 0x400 }, { 0x30, 0, 0x400 }, { 0x30, 0, 0x400 }, - { 0x30, 0, 0x400 }, { 0x30, 0, 0x400 }, { 0x30, 0, 0x400 }, { 0x30, 0, 0x400 }, { 0x30, 0, 0x400 }, - { 0x30, 0, 0x400 }, { 0x30, 0, 0x400 }, { 0x30, 0, 0x400 }, { 0x30, 0, 0x2400 }, { 0x30, 0, 0x2400 }, - { 0x30, 0, 0x2400 }, { 0x30, 0, 0x2400 }, { 0x30, 0, 0x400 }, { 0x30, 0, 0x400 }, { 0x30, 0, 0x43 }, - { 0x30, 0, 0x43 }, { 0x30, 0, 0x400 }, { 0x30, 0, 0x400 }, { 0x30, 0, 0x400 }, { 0x30, 0, 0x400 }, - { 0x30, 0, 0x400 }, { 0x30, 0, 0x400 }, { 0x30, 0, 0x400 }, { 0x30, 0, 0x400 }, { 0x30, 0, 0x400 }, - { 0x30, 0, 0x400 }, { 0x30, 0, 0x400 }, { 0x30, 0, 0x400 }, { 0x30, 0, 0x400 }, +#include "tables/sfx/playerbank_table.h" }; SfxParams sItemBankParams[] = { - { 0x30, 0, 0x8040 }, { 0x30, 0, 0x40 }, { 0x30, 0, 0 }, { 0x30, 0, 0 }, { 0x40, 0, 0x440 }, - { 0x30, 0, 0x440 }, { 0x60, 0, 0x83 }, { 0x30, 0, 0x440 }, { 0x80, 0, 0x43 }, { 0x30, 0, 0 }, - { 0x30, 0, 0x40 }, { 0x38, 0, 0x400 }, { 0x30, 0, 0x401 }, { 0x50, 0, 0x100 }, { 0x90, 0, 0x2 }, - { 0x50, 0, 0x2 }, { 0x30, 0, 0x400 }, { 0x40, 0, 0x2 }, { 0x30, 0, 0x40 }, { 0x30, 0, 0 }, - { 0x30, 0, 0 }, { 0x34, 0, 0 }, { 0x30, 0, 0 }, { 0x30, 0, 0 }, { 0x30, 0, 0 }, - { 0x30, 0, 0 }, { 0x60, 0, 0 }, { 0x30, 0, 0 }, { 0x30, 0, 0 }, { 0x30, 0, 0 }, - { 0x30, 0, 0x80 }, { 0x30, 0, 0x40 }, { 0x30, 0, 0x400 }, { 0x20, 0, 0x400 }, { 0x30, 0, 0 }, - { 0x30, 0, 0 }, { 0x30, 0, 0 }, { 0x30, 0, 0 }, { 0x30, 0, 0 }, { 0x30, 0, 0x400 }, - { 0x30, 0, 0x400 }, { 0x60, 0, 0x43 }, { 0x30, 0, 0x1 }, { 0x30, 0, 0x401 }, { 0x30, 0, 0 }, - { 0x30, 0, 0 }, { 0xA0, 0, 0x2 }, { 0xA0, 0, 0x2 }, { 0x30, 0, 0x400 }, { 0x30, 0, 0x100 }, - { 0x60, 0, 0 }, { 0x60, 0, 0 }, { 0x60, 0, 0 }, { 0x30, 0, 0x400 }, { 0x30, 0, 0 }, - { 0x60, 0, 0x81 }, { 0x30, 0, 0 }, { 0x30, 0, 0x400 }, { 0x60, 0, 0x8003 }, { 0x60, 0, 0x8003 }, - { 0x60, 0, 0x8003 }, { 0x30, 0, 0x4000 }, { 0x30, 0, 0x4000 }, { 0x30, 0, 0x40 }, { 0x80, 0, 0x3 }, - { 0x80, 0, 0x3 }, { 0x30, 0, 0x3 }, { 0x30, 0, 0 }, { 0x30, 0, 0x40 }, { 0x30, 0, 0 }, - { 0x30, 0, 0 }, { 0x30, 0, 0 }, { 0x30, 0, 0 }, { 0x30, 0, 0 }, { 0x30, 0, 0 }, - { 0x30, 0, 0 }, { 0x80, 0, 0 }, { 0x30, 0, 0 }, { 0x30, 0, 0 }, { 0x30, 0, 0 }, - { 0x80, 0, 0 }, { 0x80, 0, 0 }, { 0x30, 0, 0 }, { 0x30, 0, 0 }, { 0x30, 0, 0 }, - { 0x30, 0, 0 }, { 0x30, 0, 0 }, { 0x30, 0, 0 }, { 0x30, 0, 0 }, { 0x40, 0, 0 }, - { 0x30, 0, 0 }, { 0x60, 0, 0x100 }, { 0x70, 0, 0 }, { 0x60, 0, 0 }, { 0x30, 0, 0x483 }, - { 0x30, 0, 0x40 }, { 0x30, 0, 0x40 }, { 0x30, 0, 0 }, { 0x30, 0, 0 }, { 0x60, 0, 0x2000 }, - { 0x30, 0, 0 }, { 0x30, 0, 0 }, { 0x30, 0, 0 }, { 0x30, 0, 0 }, { 0x30, 0, 0 }, - { 0x30, 0, 0 }, { 0x30, 0, 0 }, { 0x30, 0, 0 }, { 0x30, 0, 0 }, { 0x30, 0, 0 }, - { 0x30, 0, 0 }, { 0x30, 0, 0 }, +#include "tables/sfx/itembank_table.h" }; SfxParams sEnvBankParams[] = { - { 0x70, 0, 0x640 }, { 0x80, 0, 0x40 }, { 0x30, 0, 0 }, { 0x60, 0, 0x40 }, { 0x60, 0, 0x40 }, - { 0x70, 0, 0x40 }, { 0x30, 0, 0x480 }, { 0x70, 0, 0x2 }, { 0x30, 0, 0x40 }, { 0x30, 0, 0x40 }, - { 0x80, 0, 0x2 }, { 0xA0, 0, 0x3 }, { 0x30, 0, 0x103 }, { 0x30, 0, 0x3 }, { 0x30, 0, 0x3 }, - { 0x30, 0, 0x3 }, { 0x30, 0, 0x2 }, { 0x30, 0, 0x40 }, { 0x30, 0, 0x40 }, { 0x50, 0, 0 }, - { 0x60, 0, 0x2 }, { 0x30, 0, 0x3 }, { 0x60, 0, 0 }, { 0x30, 0, 0x82 }, { 0x30, 0, 0 }, - { 0x40, 0, 0 }, { 0x68, 0, 0 }, { 0x58, 0, 0x40 }, { 0x60, 0, 0 }, { 0x70, 0, 0x3 }, - { 0x30, 0, 0x43 }, { 0x30, 0, 0 }, { 0x30, 0, 0 }, { 0xA0, 0, 0x2008 }, { 0x20, 0, 0x2 }, - { 0x30, 0, 0 }, { 0x30, 0, 0x800 }, { 0x30, 0, 0x8800 }, { 0x30, 0, 0x8000 }, { 0x30, 0, 0x2 }, - { 0x30, 0, 0 }, { 0x30, 0, 0 }, { 0x30, 0, 0 }, { 0x60, 0, 0 }, { 0x60, 0, 0x400 }, - { 0x30, 0, 0 }, { 0x80, 0, 0 }, { 0x30, 0, 0x80 }, { 0x30, 0, 0x40 }, { 0x10, 0, 0 }, - { 0xA0, 0, 0x3 }, { 0x30, 0, 0x100 }, { 0x30, 0, 0x10 }, { 0x30, 0, 0x3 }, { 0x60, 0x40, 0x3 }, - { 0x30, 0, 0 }, { 0x30, 0, 0 }, { 0x30, 0, 0x2 }, { 0x30, 0, 0 }, { 0xA0, 0, 0x3 }, - { 0x30, 0, 0 }, { 0x30, 0, 0 }, { 0x30, 0, 0x3 }, { 0x70, 0, 0 }, { 0x60, 0, 0x8000 }, - { 0x30, 0, 0x8000 }, { 0x60, 0, 0 }, { 0x60, 0, 0 }, { 0x60, 0, 0 }, { 0x60, 0, 0 }, - { 0x30, 0, 0x2003 }, { 0x30, 0, 0 }, { 0x30, 0, 0 }, { 0x30, 0, 0x2010 }, { 0x30, 0, 0x40 }, - { 0x60, 0, 0 }, { 0x60, 0, 0x3 }, { 0x30, 0, 0 }, { 0x58, 0, 0x1 }, { 0x30, 0, 0 }, - { 0x30, 0, 0 }, { 0x40, 0, 0 }, { 0x30, 0, 0xC3 }, { 0x70, 0, 0x2 }, { 0x60, 0, 0x2 }, - { 0x30, 0, 0 }, { 0x60, 0, 0x41 }, { 0x30, 0, 0x2 }, { 0x30, 0, 0 }, { 0x90, 0, 0x3 }, - { 0x90, 0, 0x3 }, { 0x30, 0, 0 }, { 0x30, 0, 0x2 }, { 0x30, 0, 0x3800 }, { 0x30, 0, 0 }, - { 0x30, 0, 0 }, { 0x30, 0, 0x3 }, { 0x30, 0, 0 }, { 0x30, 0, 0 }, { 0x30, 0, 0x3 }, - { 0x30, 0, 0x40 }, { 0x30, 0, 0 }, { 0x30, 0, 0 }, { 0x30, 0, 0 }, { 0x30, 0, 0 }, - { 0x30, 0, 0 }, { 0x30, 0, 0 }, { 0x30, 0, 0 }, { 0x30, 0, 0x3 }, { 0x30, 0, 0x803 }, - { 0x30, 0, 0 }, { 0x30, 0, 0x3 }, { 0x30, 0, 0 }, { 0x30, 0, 0 }, { 0x30, 0, 0x80 }, - { 0x30, 0, 0 }, { 0x30, 0, 0 }, { 0x30, 0, 0 }, { 0x30, 0, 0x2 }, { 0x60, 0, 0 }, - { 0x30, 0, 0x640 }, { 0x30, 0, 0x2 }, { 0x30, 0, 0x2 }, { 0x80, 0, 0x2 }, { 0x40, 0, 0 }, - { 0x1C, 0, 0 }, { 0x30, 0, 0 }, { 0x30, 0, 0 }, { 0x30, 0, 0 }, { 0x30, 0, 0 }, - { 0x30, 0, 0 }, { 0x30, 0, 0 }, { 0x30, 0, 0 }, { 0x60, 0, 0x4 }, { 0x30, 0, 0x800 }, - { 0x30, 0, 0x40 }, { 0x30, 0, 0 }, { 0x60, 0, 0 }, { 0x60, 0, 0 }, { 0x30, 0, 0 }, - { 0x30, 0, 0 }, { 0x30, 0, 0 }, { 0x60, 0, 0x3 }, { 0x30, 0, 0x3 }, { 0x30, 0, 0x3 }, - { 0x80, 0, 0 }, { 0x30, 0, 0x2000 }, { 0x30, 0, 0x3 }, { 0x30, 0, 0 }, { 0x30, 0, 0 }, - { 0x30, 0, 0x80 }, { 0x30, 0, 0 }, { 0x30, 0, 0 }, { 0x30, 0, 0 }, { 0x30, 0, 0 }, - { 0x30, 0, 0 }, { 0x30, 0, 0x800 }, { 0x30, 0, 0x800 }, { 0x30, 0, 0x2 }, { 0x30, 0, 0x3 }, - { 0x30, 0, 0 }, { 0x30, 0, 0 }, { 0x30, 0, 0 }, { 0x30, 0, 0 }, { 0x20, 0, 0x3 }, - { 0x30, 0, 0 }, { 0x30, 0, 0x8000 }, { 0x30, 0, 0 }, { 0x30, 0, 0 }, { 0x30, 0, 0 }, - { 0x70, 0, 0x2 }, { 0x30, 0, 0 }, { 0x30, 0, 0 }, { 0x30, 0, 0 }, { 0x50, 0, 0 }, - { 0x30, 0, 0 }, { 0x30, 0, 0 }, { 0x30, 0, 0 }, { 0x30, 0, 0x2003 }, { 0x20, 0, 0 }, - { 0x30, 0, 0xC0 }, { 0x30, 0, 0x2000 }, { 0x30, 0, 0 }, { 0x30, 0, 0x402 }, { 0x30, 0, 0 }, - { 0x30, 0, 0 }, { 0x30, 0, 0x2 }, { 0x30, 0, 0x3 }, { 0x30, 0, 0x2 }, { 0x30, 0, 0 }, - { 0x30, 0, 0 }, { 0x30, 0, 0 }, { 0x30, 0, 0 }, { 0x30, 0, 0x6 }, { 0xA0, 0, 0x3 }, - { 0x30, 0, 0 }, { 0x30, 0, 0 }, { 0x30, 0, 0 }, { 0x30, 0, 0 }, { 0x30, 0, 0 }, - { 0x30, 0, 0 }, { 0x30, 0, 0 }, { 0x30, 0, 0xC0 }, { 0x30, 0, 0x2 }, { 0x30, 0, 0x2 }, - { 0x30, 0, 0 }, { 0x30, 0, 0x3 }, { 0x30, 0, 0x3 }, { 0x30, 0, 0 }, { 0x30, 0, 0x4083 }, - { 0x30, 0, 0 }, { 0x30, 0, 0 }, { 0x30, 0, 0 }, { 0x30, 0, 0 }, { 0x60, 0, 0x83 }, - { 0x80, 0, 0x2000 }, { 0x50, 0, 0 }, { 0x60, 0, 0 }, { 0x90, 0, 0 }, { 0x30, 0, 0 }, - { 0x30, 0, 0 }, { 0x30, 0, 0 }, { 0x60, 0, 0x2000 }, { 0x30, 0, 0 }, { 0x30, 0, 0 }, - { 0x30, 0, 0x3 }, { 0x30, 0, 0x3 }, { 0x30, 0, 0 }, { 0x30, 0, 0 }, { 0x30, 0, 0 }, - { 0x30, 0, 0 }, { 0x30, 0, 0 }, { 0xA0, 0, 0x800 }, { 0x30, 0, 0 }, { 0x30, 0, 0 }, - { 0x30, 0, 0 }, { 0x30, 0, 0x2 }, { 0x30, 0, 0 }, { 0x30, 0, 0x3 }, { 0x20, 0, 0 }, - { 0x30, 0, 0 }, { 0x30, 0, 0x40 }, { 0x30, 0, 0x402 }, { 0x30, 0, 0x2 }, { 0x30, 0, 0 }, - { 0x30, 0, 0x2 }, { 0x30, 0, 0x5 }, { 0x30, 0, 0 }, { 0x30, 0, 0 }, { 0x40, 0, 0 }, - { 0x30, 0, 0 }, { 0x30, 0, 0 }, { 0x30, 0, 0x5 }, { 0x30, 0, 0xC2 }, { 0x30, 0, 0 }, - { 0x30, 0, 0 }, { 0x30, 0, 0x80 }, { 0x30, 0, 0x80 }, { 0x30, 0, 0 }, { 0x30, 0, 0x2 }, - { 0x30, 0, 0 }, { 0x30, 0, 0 }, { 0x30, 0, 0 }, { 0x30, 0, 0 }, { 0x68, 0, 0x2 }, - { 0x30, 0, 0x2 }, { 0x30, 0, 0x4040 }, { 0x30, 0, 0 }, { 0x30, 0, 0 }, { 0x30, 0, 0x2 }, - { 0x30, 0, 0x2 }, { 0x30, 0, 0x3 }, { 0x30, 0, 0 }, { 0x30, 0, 0 }, { 0x30, 0, 0 }, - { 0x30, 0, 0xC0 }, { 0x80, 0, 0 }, { 0x30, 0, 0 }, { 0x30, 0, 0x2 }, { 0xA0, 0, 0xA003 }, - { 0x30, 0, 0 }, { 0x30, 0, 0 }, { 0x30, 0, 0 }, { 0x30, 0, 0x80 }, { 0x30, 0, 0 }, - { 0x30, 0, 0x85 }, { 0x30, 0, 0x40 }, { 0x30, 0, 0 }, { 0x30, 0, 0 }, { 0x30, 0, 0 }, - { 0x60, 0, 0x2000 }, { 0x30, 0, 0 }, { 0x30, 0, 0x40 }, { 0x30, 0, 0 }, { 0x30, 0, 0 }, - { 0x30, 0, 0x2000 }, { 0x30, 0, 0x2 }, { 0x30, 0, 0x3 }, { 0x30, 0, 0 }, { 0x30, 0, 0x40 }, - { 0x30, 0, 0x40 }, { 0x30, 0, 0x80 }, { 0x30, 0, 0 }, { 0x30, 0, 0 }, { 0x30, 0, 0 }, - { 0x30, 0, 0xC0 }, { 0x30, 0, 0 }, { 0x30, 0, 0 }, { 0x30, 0, 0 }, { 0x30, 0, 0 }, - { 0x30, 0, 0 }, { 0x30, 0, 0 }, { 0x80, 0, 0 }, { 0x30, 0, 0 }, { 0x30, 0, 0x43 }, - { 0x30, 0, 0x2000 }, { 0x30, 0, 0 }, { 0x30, 0, 0x3 }, { 0x30, 0, 0x3 }, { 0x30, 0, 0x3 }, - { 0x30, 0, 0x3 }, { 0x30, 0, 0x3 }, { 0x30, 0, 0x3 }, { 0x30, 0, 0 }, { 0x30, 0, 0 }, - { 0x30, 0, 0x3 }, { 0xA0, 0, 0x4000 }, { 0x30, 0, 0x43 }, { 0x30, 0, 0x40 }, { 0x60, 0, 0x2 }, - { 0x30, 0, 0 }, { 0x30, 0, 0 }, { 0x30, 0, 0x2080 }, { 0x30, 0, 0x2080 }, { 0x30, 0, 0x2000 }, - { 0x30, 0, 0 }, { 0x30, 0, 0x2000 }, { 0x30, 0, 0 }, { 0x30, 0, 0 }, { 0x60, 0, 0 }, - { 0x30, 0, 0x2 }, { 0x30, 0, 0 }, { 0x30, 0, 0x2 }, { 0x30, 0, 0x80 }, { 0x60, 0, 0x42 }, - { 0x30, 0, 0x2000 }, { 0x30, 0, 0 }, { 0x30, 0, 0 }, { 0x30, 0, 0 }, { 0x30, 0, 0 }, - { 0x30, 0, 0 }, { 0x30, 0, 0 }, { 0x30, 0, 0x2000 }, { 0x30, 0, 0x2000 }, { 0x30, 0, 0x2000 }, - { 0x30, 0, 0 }, { 0x30, 0, 0x2000 }, { 0x30, 0, 0 }, { 0x30, 0, 0x2000 }, { 0x80, 0, 0 }, - { 0x80, 0, 0x3 }, { 0x80, 0, 0x3 }, { 0x30, 0, 0x3 }, { 0x80, 0, 0x2 }, { 0x80, 0, 0x2 }, - { 0x30, 0, 0 }, { 0x60, 0, 0 }, { 0x30, 0, 0 }, { 0x30, 0, 0x42 }, { 0x30, 0, 0x42 }, - { 0x30, 0, 0x43 }, { 0x60, 0x80, 0x2000 }, { 0x60, 0x80, 0x2000 }, { 0x30, 0, 0 }, { 0x30, 0, 0 }, - { 0x30, 0, 0x3 }, { 0x30, 0, 0 }, { 0x30, 0, 0 }, { 0x30, 0, 0 }, { 0x30, 0, 0x3 }, - { 0x30, 0, 0x2000 }, { 0x80, 0, 0x2000 }, { 0x80, 0, 0x3 }, { 0x30, 0, 0 }, { 0x30, 0, 0x2000 }, - { 0x30, 0, 0x2000 }, { 0x30, 0, 0x2000 }, { 0x30, 0, 0x2000 }, { 0x30, 0, 0 }, { 0x30, 0, 0 }, - { 0x80, 0, 0x3 }, { 0x30, 0, 0x2000 }, { 0x30, 0, 0 }, { 0x30, 0, 0 }, { 0x30, 0, 0 }, - { 0x30, 0, 0 }, { 0x30, 0, 0 }, { 0x30, 0, 0 }, { 0x30, 0, 0x3 }, { 0x30, 0, 0x43 }, - { 0x30, 0, 0x3 }, { 0x30, 0, 0x3 }, { 0x30, 0, 0 }, { 0x30, 0, 0x2000 }, { 0x10, 0, 0x7 }, - { 0x30, 0, 0 }, { 0x30, 0, 0 }, { 0x30, 0, 0 }, { 0x30, 0, 0 }, { 0x30, 0, 0 }, - { 0x30, 0, 0 }, { 0x30, 0, 0 }, { 0x30, 0, 0x2000 }, { 0x30, 0, 0x2000 }, { 0x30, 0, 0x2000 }, - { 0x58, 0, 0x60 }, { 0x60, 0, 0x3 }, { 0x60, 0, 0x3 }, { 0x60, 0, 0x3 }, { 0x70, 0, 0x3 }, - { 0x70, 0, 0x3 }, { 0x30, 0, 0 }, { 0x70, 0, 0x3 }, { 0x30, 0, 0x4 }, { 0x30, 0, 0x3 }, - { 0x30, 0, 0 }, { 0x30, 0, 0 }, { 0x60, 0, 0 }, { 0x60, 0, 0 }, { 0x30, 0, 0 }, - { 0x30, 0x80, 0 }, { 0x30, 0x80, 0x40 }, { 0x30, 0x80, 0x40 }, { 0x60, 0, 0x2000 }, { 0x70, 0, 0x2000 }, - { 0x30, 0, 0x80 }, { 0x30, 0, 0x2000 }, { 0x30, 0, 0x3 }, { 0x30, 0, 0 }, { 0x60, 0, 0x3 }, - { 0x70, 0, 0 }, { 0x30, 0, 0 }, { 0x30, 0, 0 }, { 0x30, 0, 0 }, { 0x30, 0, 0 }, - { 0x30, 0, 0 }, { 0x30, 0, 0 }, { 0x40, 0, 0 }, { 0x58, 0, 0x40 }, { 0x58, 0, 0x40 }, - { 0x30, 0, 0x40 }, { 0x30, 0, 0x41 }, { 0x30, 0, 0 }, { 0x30, 0, 0 }, { 0x30, 0, 0 }, - { 0x30, 0, 0 }, { 0x30, 0, 0 }, { 0x30, 0, 0 }, { 0x30, 0, 0 }, { 0x30, 0, 0 }, - { 0x30, 0, 0 }, { 0x30, 0, 0 }, { 0x30, 0, 0 }, { 0x30, 0, 0 }, +#include "tables/sfx/environmentbank_table.h" }; SfxParams sSystemBankParams[] = { - { 0xC0, 0, 0 }, { 0xC0, 0, 0 }, { 0xB0, 0, 0x20 }, { 0x30, 0, 0 }, { 0x30, 0, 0 }, { 0x30, 0, 0 }, - { 0x50, 0, 0 }, { 0x30, 0, 0x20 }, { 0x30, 0, 0 }, { 0x30, 0, 0 }, { 0x30, 0, 0 }, { 0x30, 0, 0 }, - { 0x20, 0, 0 }, { 0x30, 0, 0 }, { 0x30, 0, 0 }, { 0x30, 0, 0 }, { 0x28, 0, 0 }, { 0x30, 0, 0 }, - { 0x30, 0, 0 }, { 0x30, 0, 0 }, { 0x30, 0, 0 }, { 0x30, 0, 0 }, { 0x30, 0, 0 }, { 0x30, 0, 0 }, - { 0x18, 0, 0 }, { 0x2C, 0, 0 }, { 0x2C, 0, 0 }, { 0x20, 0, 0 }, { 0x30, 0, 0 }, { 0x30, 0, 0 }, - { 0x30, 0, 0 }, { 0x30, 0, 0 }, { 0x30, 0, 0 }, { 0x30, 0, 0 }, { 0x30, 0, 0 }, { 0x30, 0, 0 }, - { 0x30, 0, 0 }, { 0x30, 0, 0 }, { 0x30, 0, 0 }, { 0x20, 0, 0 }, { 0x30, 0, 0 }, { 0x30, 0, 0 }, - { 0x30, 0, 0 }, { 0x30, 0, 0 }, { 0x60, 0, 0 }, { 0x30, 0, 0 }, { 0x30, 0, 0 }, { 0x30, 0, 0 }, - { 0x30, 0, 0 }, { 0x30, 0, 0 }, { 0x30, 0, 0 }, { 0x30, 0, 0 }, { 0x30, 0, 0 }, { 0x30, 0, 0 }, - { 0x30, 0, 0 }, { 0x30, 0, 0 }, { 0x30, 0, 0 }, { 0x30, 0, 0 }, { 0x30, 0, 0 }, { 0x30, 0, 0 }, - { 0x30, 0, 0 }, { 0x30, 0, 0 }, { 0x30, 0, 0 }, { 0x30, 0, 0 }, { 0x30, 0, 0 }, { 0x30, 0, 0 }, - { 0x30, 0, 0 }, { 0x30, 0, 0 }, { 0x30, 0, 0 }, { 0x30, 0, 0 }, { 0x30, 0, 0 }, { 0x30, 0, 0 }, - { 0x30, 0, 0 }, { 0x30, 0, 0 }, { 0x30, 0, 0 }, { 0x30, 0, 0 }, { 0x30, 0, 0 }, { 0x30, 0, 0 }, - { 0x30, 0, 0 }, { 0x30, 0, 0 }, { 0x30, 0, 0 }, { 0x60, 0, 0 }, { 0x30, 0, 0 }, { 0x30, 0, 0 }, - { 0x30, 0, 0x20 }, { 0x60, 0, 0 }, { 0x30, 0, 0 }, { 0x30, 0, 0 }, { 0x30, 0, 0 }, { 0x30, 0, 0 }, - { 0x30, 0, 0 }, { 0x30, 0, 0 }, { 0x30, 0, 0 }, { 0xA0, 0, 0x8 }, { 0xA0, 0, 0x8 }, { 0x30, 0, 0 }, +#include "tables/sfx/systembank_table.h" }; SfxParams sOcarinaBankParams[] = { - { 0x30, 0, 0 }, { 0x30, 0, 0x20 }, { 0x30, 0, 0x642 }, { 0x30, 0, 0 }, { 0x30, 0, 0 }, { 0x30, 0, 0 }, - { 0x30, 0, 0 }, { 0x30, 0, 0 }, { 0x30, 0, 0 }, { 0x30, 0, 0 }, { 0x30, 0, 0x2000 }, { 0x30, 0, 0x2000 }, - { 0x30, 0, 0 }, { 0x30, 0, 0 }, { 0x30, 0, 0 }, { 0x30, 0, 0 }, +#include "tables/sfx/ocarinabank_table.h" }; SfxParams sVoiceBankParams[] = { - { 0x30, 0, 0x402 }, { 0x30, 0, 0x402 }, { 0x30, 0, 0x402 }, { 0x20, 0, 0x402 }, { 0x30, 0, 0x402 }, - { 0x30, 0, 0x402 }, { 0x30, 0, 0x402 }, { 0x30, 0, 0x402 }, { 0x30, 0, 0x402 }, { 0x30, 0, 0x442 }, - { 0x30, 0, 0x442 }, { 0x30, 0, 0x402 }, { 0x30, 0, 0x402 }, { 0x50, 0, 0x402 }, { 0x30, 0, 0x402 }, - { 0x30, 0, 0x402 }, { 0x30, 0, 0x402 }, { 0x30, 0, 0x402 }, { 0x30, 0, 0x402 }, { 0x30, 0, 0x402 }, - { 0x30, 0, 0x402 }, { 0x30, 0, 0x402 }, { 0x30, 0, 0x402 }, { 0x30, 0, 0x402 }, { 0x30, 0, 0x482 }, - { 0x30, 0, 0x402 }, { 0x30, 0, 0x402 }, { 0x30, 0, 0x402 }, { 0x30, 0, 0x402 }, { 0x80, 0, 0x402 }, - { 0x30, 0, 0x402 }, { 0x30, 0, 0x402 }, { 0x30, 0, 0x402 }, { 0x30, 0, 0x402 }, { 0x30, 0, 0x402 }, - { 0x20, 0, 0x402 }, { 0x30, 0, 0x402 }, { 0x30, 0, 0x402 }, { 0x30, 0, 0x402 }, { 0x30, 0, 0x402 }, - { 0x30, 0, 0x402 }, { 0x30, 0, 0x442 }, { 0x30, 0, 0x442 }, { 0x30, 0, 0x402 }, { 0x30, 0, 0x402 }, - { 0x50, 0, 0x402 }, { 0x30, 0, 0x402 }, { 0x30, 0, 0x402 }, { 0x30, 0, 0x402 }, { 0x30, 0, 0x402 }, - { 0x30, 0, 0x402 }, { 0x30, 0, 0x402 }, { 0x30, 0, 0x402 }, { 0x30, 0, 0x402 }, { 0x30, 0, 0x402 }, - { 0x30, 0, 0x402 }, { 0x30, 0, 0x481 }, { 0x30, 0, 0x402 }, { 0x30, 0, 0x402 }, { 0x30, 0, 0x402 }, - { 0x30, 0, 0x402 }, { 0x30, 0, 0x402 }, { 0x30, 0, 0x402 }, { 0x30, 0, 0x402 }, { 0x30, 0, 0x402 }, - { 0x30, 0, 0x402 }, { 0x30, 0, 0 }, { 0x60, 0, 0x20 }, { 0x30, 0, 0 }, { 0x30, 0, 0 }, - { 0x30, 0, 0 }, { 0x30, 0, 0 }, { 0x30, 0, 0 }, { 0x30, 0, 0 }, { 0x30, 0, 0 }, - { 0x30, 0, 0 }, { 0x30, 0, 0 }, { 0x30, 0, 0 }, { 0x30, 0, 0 }, { 0x30, 0, 0 }, - { 0x30, 0, 0 }, { 0x30, 0, 0 }, { 0x30, 0, 0x8041 }, { 0x30, 0, 0x8041 }, { 0x30, 0, 0x8041 }, - { 0x30, 0, 0x8041 }, { 0x30, 0, 0x8041 }, { 0x30, 0, 0x8041 }, { 0x30, 0, 0x8041 }, { 0x30, 0, 0x8041 }, - { 0x30, 0, 0x8041 }, { 0x30, 0, 0x8041 }, { 0x30, 0, 0x8041 }, { 0x30, 0, 0x8000 }, { 0x30, 0, 0x8000 }, - { 0x30, 0, 0x8000 }, { 0x30, 0, 0x8041 }, { 0x30, 0, 0x8041 }, { 0x30, 0, 0x8041 }, { 0x30, 0, 0x8041 }, - { 0x30, 0, 0x8041 }, { 0x30, 0, 0x8041 }, { 0x30, 0, 0x8041 }, { 0x30, 0, 0x8041 }, { 0x30, 0, 0x8041 }, - { 0x30, 0, 0x8041 }, { 0x30, 0, 0x8041 }, { 0x30, 0, 0x8041 }, { 0x30, 0, 0x8041 }, { 0x30, 0, 0x8041 }, - { 0x30, 0, 0x8041 }, { 0x30, 0, 0x8041 }, { 0x30, 0, 0x8041 }, { 0x30, 0, 0x8041 }, { 0x30, 0, 0x8041 }, - { 0x30, 0, 0x8041 }, { 0x30, 0, 0x8001 }, { 0x30, 0, 0x8043 }, { 0x30, 0, 0x8043 }, { 0x30, 0, 0x8043 }, - { 0x30, 0, 0x8041 }, { 0x30, 0, 0x8041 }, { 0x30, 0, 0x8041 }, { 0x30, 0, 0x8041 }, { 0x30, 0, 0x8041 }, - { 0x30, 0, 0x8041 }, { 0x30, 0, 0x8041 }, { 0x30, 0, 0x8041 }, { 0x30, 0, 0x402 }, { 0x30, 0, 0x402 }, - { 0x30, 0, 0x402 }, { 0x20, 0, 0x402 }, { 0x30, 0, 0x402 }, { 0x30, 0, 0x402 }, { 0x30, 0, 0x402 }, - { 0x30, 0, 0x402 }, { 0x30, 0, 0x402 }, { 0x30, 0, 0x442 }, { 0x30, 0, 0x442 }, { 0x30, 0, 0x402 }, - { 0x30, 0, 0x402 }, { 0x50, 0, 0x402 }, { 0x30, 0, 0x402 }, { 0x30, 0, 0x402 }, { 0x30, 0, 0x402 }, - { 0x30, 0, 0x402 }, { 0x30, 0, 0x402 }, { 0x30, 0, 0x402 }, { 0x30, 0, 0x402 }, { 0x30, 0, 0x402 }, - { 0x30, 0, 0x402 }, { 0x30, 0, 0x402 }, { 0x30, 0, 0x481 }, { 0x30, 0, 0x402 }, { 0x30, 0, 0x402 }, - { 0x30, 0, 0x402 }, { 0x30, 0, 0x402 }, { 0x30, 0, 0x402 }, { 0x30, 0, 0x402 }, { 0x30, 0, 0x402 }, - { 0x30, 0, 0x402 }, { 0x30, 0, 0x402 }, { 0x30, 0, 0x402 }, { 0x20, 0, 0x402 }, { 0x30, 0, 0x402 }, - { 0x30, 0, 0x402 }, { 0x30, 0, 0x402 }, { 0x30, 0, 0x402 }, { 0x30, 0, 0x402 }, { 0x30, 0, 0x442 }, - { 0x30, 0, 0x442 }, { 0x30, 0, 0x402 }, { 0x30, 0, 0x402 }, { 0x50, 0, 0x402 }, { 0x30, 0, 0x402 }, - { 0x30, 0, 0x402 }, { 0x30, 0, 0x402 }, { 0x30, 0, 0x402 }, { 0x30, 0, 0x402 }, { 0x30, 0, 0x402 }, - { 0x30, 0, 0x402 }, { 0x30, 0, 0x402 }, { 0x30, 0, 0x402 }, { 0x30, 0, 0x402 }, { 0x30, 0, 0x482 }, - { 0x30, 0, 0x402 }, { 0x30, 0, 0x402 }, { 0x30, 0, 0x402 }, { 0x30, 0, 0x402 }, { 0x80, 0, 0x402 }, - { 0x30, 0, 0x402 }, { 0x30, 0, 0x402 }, { 0x30, 0, 0x402 }, { 0x30, 0, 0x402 }, { 0x30, 0, 0x402 }, - { 0x20, 0, 0x402 }, { 0x30, 0, 0x402 }, { 0x30, 0, 0x402 }, { 0x30, 0, 0x402 }, { 0x30, 0, 0x402 }, - { 0x30, 0, 0x402 }, { 0x30, 0, 0x442 }, { 0x30, 0, 0x442 }, { 0x30, 0, 0x402 }, { 0x30, 0, 0x402 }, - { 0x50, 0, 0x402 }, { 0x30, 0, 0x402 }, { 0x30, 0, 0x402 }, { 0x30, 0, 0x402 }, { 0x30, 0, 0x402 }, - { 0x30, 0, 0x402 }, { 0x30, 0, 0x402 }, { 0x30, 0, 0x402 }, { 0x30, 0, 0x402 }, { 0x30, 0, 0x402 }, - { 0x30, 0, 0x402 }, { 0x30, 0, 0x482 }, { 0x30, 0, 0x402 }, { 0x30, 0, 0x402 }, { 0x30, 0, 0x402 }, - { 0x30, 0, 0x402 }, { 0x80, 0, 0x402 }, { 0x30, 0, 0x402 }, { 0x30, 0, 0x402 }, { 0x30, 0, 0x442 }, - { 0x30, 0, 0x442 }, { 0x30, 0, 0x442 }, { 0x20, 0, 0x442 }, { 0x30, 0, 0x442 }, { 0x30, 0, 0x442 }, - { 0x30, 0, 0x442 }, { 0x30, 0, 0x442 }, { 0x30, 0, 0x442 }, { 0x30, 0, 0x442 }, { 0x30, 0, 0x442 }, - { 0x30, 0, 0x442 }, { 0x30, 0, 0x442 }, { 0x50, 0, 0x442 }, { 0x30, 0, 0x442 }, { 0x30, 0, 0x442 }, - { 0x30, 0, 0x442 }, { 0x30, 0, 0x442 }, { 0x30, 0, 0x442 }, { 0x30, 0, 0x442 }, { 0x30, 0, 0x442 }, - { 0x30, 0, 0x442 }, { 0x30, 0, 0x442 }, { 0x30, 0, 0x442 }, { 0x30, 0, 0x482 }, { 0x30, 0, 0x442 }, - { 0x30, 0, 0x442 }, { 0x30, 0, 0x442 }, { 0x30, 0, 0x442 }, { 0x80, 0, 0x442 }, { 0x30, 0, 0x442 }, - { 0x30, 0x80, 0x442 }, { 0x30, 0, 0x402 }, { 0x30, 0, 0x402 }, { 0x30, 0, 0x402 }, { 0x30, 0, 0x402 }, - { 0x30, 0, 0x402 }, { 0x30, 0, 0x402 }, { 0x30, 0, 0x402 }, { 0x30, 0, 0x402 }, { 0x30, 0, 0x402 }, - { 0x30, 0, 0x402 }, { 0x30, 0, 0x402 }, { 0x30, 0, 0x402 }, { 0x30, 0, 0x402 }, { 0x30, 0, 0x402 }, - { 0x30, 0, 0x402 }, { 0x30, 0, 0x402 }, { 0x30, 0, 0x402 }, { 0x30, 0, 0x402 }, { 0x30, 0, 0x402 }, - { 0x30, 0, 0x402 }, { 0x30, 0, 0x402 }, { 0x30, 0, 0x402 }, { 0x30, 0, 0x402 }, { 0x30, 0, 0x402 }, - { 0x30, 0, 0x402 }, { 0x30, 0, 0x402 }, { 0x30, 0, 0x402 }, { 0x30, 0, 0x402 }, { 0x30, 0, 0x402 }, - { 0x30, 0, 0x402 }, { 0x30, 0, 0x402 }, { 0x30, 0, 0x402 }, { 0x30, 0, 0x402 }, { 0x30, 0, 0x402 }, - { 0x30, 0, 0x402 }, { 0x30, 0, 0x402 }, { 0x30, 0, 0x402 }, { 0x30, 0, 0x402 }, { 0x30, 0, 0x402 }, - { 0x30, 0, 0x402 }, { 0x30, 0, 0x402 }, { 0x30, 0, 0x402 }, { 0x30, 0, 0x402 }, { 0x30, 0, 0x402 }, - { 0x30, 0, 0x402 }, { 0x30, 0, 0x402 }, { 0x30, 0, 0x402 }, { 0x30, 0, 0x402 }, { 0x30, 0, 0x402 }, - { 0x30, 0, 0x402 }, { 0x30, 0, 0x402 }, { 0x30, 0, 0x402 }, { 0x30, 0, 0x402 }, { 0x30, 0, 0x402 }, - { 0x30, 0, 0x402 }, { 0x30, 0, 0x402 }, { 0x30, 0, 0x402 }, { 0x30, 0, 0x402 }, { 0x30, 0, 0x402 }, - { 0x30, 0, 0x402 }, { 0x30, 0, 0x402 }, { 0x30, 0, 0x402 }, { 0x30, 0, 0x402 }, { 0x30, 0, 0x402 }, - { 0x30, 0, 0x402 }, { 0x30, 0, 0x402 }, { 0x30, 0, 0x402 }, { 0x30, 0, 0x402 }, { 0x30, 0, 0x402 }, - { 0x30, 0, 0x402 }, { 0x30, 0, 0x402 }, { 0x30, 0, 0x402 }, { 0x30, 0, 0x402 }, { 0x30, 0, 0x402 }, - { 0x30, 0, 0x402 }, { 0x30, 0, 0x402 }, { 0x30, 0, 0x402 }, { 0x30, 0, 0x402 }, { 0x30, 0, 0x402 }, - { 0x30, 0, 0x402 }, { 0x30, 0, 0x402 }, { 0x30, 0, 0x402 }, { 0x30, 0, 0x402 }, { 0x30, 0, 0x402 }, - { 0x30, 0, 0x402 }, { 0x30, 0, 0x402 }, { 0x30, 0, 0x402 }, { 0x30, 0, 0x402 }, { 0x30, 0, 0x402 }, - { 0x30, 0, 0x402 }, { 0x30, 0, 0x402 }, { 0x30, 0, 0x402 }, { 0x30, 0, 0x402 }, { 0x30, 0, 0x402 }, - { 0x30, 0, 0x402 }, { 0x30, 0, 0x402 }, { 0x30, 0, 0x402 }, { 0x30, 0, 0x402 }, { 0x30, 0, 0x402 }, - { 0x30, 0, 0x402 }, { 0x30, 0, 0x402 }, { 0x30, 0, 0x402 }, { 0x30, 0, 0x402 }, { 0x30, 0, 0x402 }, - { 0x30, 0, 0x402 }, { 0x30, 0, 0x402 }, { 0x30, 0, 0x402 }, { 0x30, 0, 0x402 }, { 0x30, 0, 0x402 }, - { 0x30, 0, 0x402 }, { 0x30, 0, 0x402 }, { 0x30, 0, 0x402 }, { 0x30, 0, 0x402 }, { 0x30, 0, 0x402 }, - { 0x30, 0, 0x402 }, { 0x30, 0, 0x402 }, { 0x30, 0, 0x402 }, { 0x30, 0, 0x402 }, { 0x30, 0, 0x402 }, - { 0x30, 0, 0x402 }, { 0x30, 0, 0x402 }, { 0x30, 0, 0x402 }, { 0x30, 0, 0x402 }, { 0x30, 0, 0x402 }, - { 0x30, 0, 0x402 }, { 0x30, 0, 0x402 }, { 0x30, 0, 0x402 }, { 0x30, 0, 0x402 }, { 0x30, 0, 0x402 }, - { 0x30, 0, 0x402 }, { 0x30, 0, 0x402 }, { 0x30, 0, 0x402 }, { 0x30, 0, 0x402 }, { 0x30, 0, 0x402 }, - { 0x30, 0, 0x402 }, { 0x30, 0, 0x402 }, { 0x30, 0, 0x402 }, { 0x30, 0, 0x402 }, { 0x30, 0, 0x402 }, - { 0x30, 0, 0x402 }, { 0x30, 0, 0x402 }, { 0x30, 0, 0x402 }, { 0x30, 0, 0x402 }, { 0x30, 0, 0x402 }, +#include "tables/sfx/voicebank_table.h" }; +#undef DEFINE_SFX + SfxParams* gSfxParams[7] = { sPlayerBankParams, sItemBankParams, sEnvBankParams, sEnemyBankParams, sSystemBankParams, sOcarinaBankParams, sVoiceBankParams, diff --git a/src/code/audio/code_80192BE0.c b/src/code/audio/code_80192BE0.c index 20b4239da..e69f678ff 100644 --- a/src/code/audio/code_80192BE0.c +++ b/src/code/audio/code_80192BE0.c @@ -16,13 +16,13 @@ #pragma GLOBAL_ASM("asm/non_matchings/code/code_80192BE0/func_80193858.s") -#pragma GLOBAL_ASM("asm/non_matchings/code/code_80192BE0/func_8019387C.s") +#pragma GLOBAL_ASM("asm/non_matchings/code/code_80192BE0/AudioThread_QueueCmdS32.s") -#pragma GLOBAL_ASM("asm/non_matchings/code/code_80192BE0/Audio_QueueCmdS8.s") +#pragma GLOBAL_ASM("asm/non_matchings/code/code_80192BE0/AudioThread_QueueCmdS8.s") #pragma GLOBAL_ASM("asm/non_matchings/code/code_80192BE0/func_801938D0.s") -#pragma GLOBAL_ASM("asm/non_matchings/code/code_80192BE0/func_80193900.s") +#pragma GLOBAL_ASM("asm/non_matchings/code/code_80192BE0/AudioThread_ScheduleProcessCmds.s") #pragma GLOBAL_ASM("asm/non_matchings/code/code_80192BE0/func_80193990.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/Audio_NextRandom.s") +#pragma GLOBAL_ASM("asm/non_matchings/code/code_80192BE0/AudioThread_NextRandom.s") -#pragma GLOBAL_ASM("asm/non_matchings/code/code_80192BE0/Audio_InitMesgQueues.s") +#pragma GLOBAL_ASM("asm/non_matchings/code/code_80192BE0/AudioThread_InitMesgQueues.s") diff --git a/src/code/audio/code_80194790.c b/src/code/audio/code_80194790.c deleted file mode 100644 index 9ba2436de..000000000 --- a/src/code/audio/code_80194790.c +++ /dev/null @@ -1,9 +0,0 @@ -#include "global.h" - -#pragma GLOBAL_ASM("asm/non_matchings/code/code_80194790/func_80194790.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/code_80194790/func_80194804.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/code_80194790/func_80194840.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/code_80194790/func_801948B0.s") diff --git a/src/code/audio/code_8019AF00.c b/src/code/audio/code_8019AF00.c index 2e7cc91e1..b896facbc 100644 --- a/src/code/audio/code_8019AF00.c +++ b/src/code/audio/code_8019AF00.c @@ -18,15 +18,15 @@ typedef struct { } SfxSettings; // size = 0x9 typedef struct { - /* 0x0 */ f32 vol; + /* 0x0 */ f32 volume; /* 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 + /* 0xC */ u8 combFilterGain; + /* 0xD */ u8 zVolume; +} SfxChannelState; // size = 0xE typedef enum { /* 0x0 */ SFX_CHANNEL_PLAYER0, // SfxPlayerBank @@ -66,7 +66,7 @@ typedef struct { /* 0xC */ s32 remainingFrames; } FreqLerp; // size = 0x10 -s32 AudioOcarina_MemoryGameGenerateNotes(void); +s32 AudioOcarina_MemoryGameNextNote(void); s32 Audio_SetGanonsTowerBgmVolume(u8 targetVolume); void func_801A3238(s8 playerIndex, u16 seqId, u8 fadeTimer, s8 arg3, u8 arg4); @@ -91,7 +91,7 @@ f32* sSfxVolumeCur; f32 sSfxVolumeTarget; f32 sSfxVolumeRate; u16 sSceneSeqId1; -SfxPlayerState sSfxChannelState[16]; +SfxChannelState sSfxChannelState[16]; // Sequence bss u8 D_801FD3A8; @@ -131,18 +131,18 @@ u16 D_801FD438; OcarinaStaff sPlayingStaff; OcarinaStaff sPlaybackStaff; OcarinaStaff sRecordingStaff; -u32 sOcarinaUpdateTaskCurrent; +u32 sOcarinaUpdateTaskStart; OcarinaControlStick sOcarinaInputStickRel; u32 sOcarinaInputButtonCur; u32 sOcarinaInputButtonStart; u32 sOcarinaInputButtonPrev; -s32 sOcaInputBtnPress; -u8 sOcarinaResetDelay; -u8 sOcarinaResetUnused; +s32 sOcarinaInputButtonPress; +u8 sOcarinaDisableTimer; +u8 sOcarinaUnused; u8 sOcarinaHasStartedSong; u8 sFirstOcarinaSongIndex; u8 sLastOcarinaSongIndex; -u32 sOcarinaAvailSongs; +u32 sOcarinaAvailableSongFlags; u8 sOcarinaStaffPlayingPos; u16 sMusicStaffPos[OCARINA_SONG_MAX]; u16 sMusicStaffCurHeldLength[OCARINA_SONG_MAX]; @@ -150,11 +150,12 @@ 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; +OcarinaNote sScarecrowsLongSongSecondNote; u16 sCustomSequencePc; // Sfx Data -u8 D_801D6600[] = { +// If the Sfx Bank has more than 255 values (max value of u8) +u8 gIsLargeSfxBank[] = { true, false, true, true, false, false, true, }; u8 D_801D6608[] = { @@ -192,7 +193,7 @@ u8 sEnterGanonsTowerTimer = 0; u16 sSfxVolumeDuration = 0; // System Data -s8 sAudioFileSelectSetting = AUDIO_FS_STEREO; +s8 sSoundMode = SOUNDMODE_STEREO; s8 sAudioIsWindowOpen = false; s8 sAudioCutsceneFlag = false; s8 sSpecReverb = 0; @@ -987,35 +988,35 @@ NatureAmbienceDataIO sNatureAmbienceData[20] = { u8 sIsOcarinaInputEnabled = false; s8 sOcarinaInstrumentId = OCARINA_INSTRUMENT_OFF; u8 sCurOcarinaPitch = OCARINA_PITCH_NONE; -u8 sPrevOcarinaPitch = 0; -u8 sCurOcarinaButtonIndex = 0; -u8 sMusicStaffPrevPitch = 0; +u8 sPrevOcarinaPitch = OCARINA_PITCH_C4; +u8 sCurOcarinaButtonIndex = OCARINA_BTN_A; +u8 sMusicStaffPrevPitch = OCARINA_PITCH_C4; f32 sCurOcarinaBendFreq = 1.0f; -f32 sDefaultOcarinaVolume = 0.68503935f; +f32 sDefaultOcarinaVolume = 87.0f / 127.0f; s8 sCurOcarinaBendIndex = 0; -s8 sCurOcarinaVolume = 0x57; +s8 sCurOcarinaVolume = 87; s8 sCurOcarinaVibrato = 0; u8 sPlaybackState = 0; -u8 D_801D6FE4 = 0xFF; -u8 D_801D6FE8 = 0xFF; +u8 sPlaybackStaffStopPos = 0xFF; +u8 sPlaybackStaffStartPos = 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; +u32 sPrevOcarinaWithMusicStaffFlags = 0; // Stores sOcarinaFlags but never used +u8 sPlaybackPitch = OCARINA_PITCH_NONE; // Pitch + PitchFlags u8 sNotePlaybackVolume = 0; u8 sNotePlaybackVibrato = 0; s8 sNotePlaybackBend = 0; -f32 sNormalizedNotePlaybackTone = 1.0f; -f32 sNormalizedNotePlaybackVolume = 1.0f; +f32 sRelativeNotePlaybackBend = 1.0f; +f32 sRelativeNotePlaybackVolume = 1.0f; u32 sOcarinaPlaybackTaskStart = 0; u32 sOcarinaWallCounter = 0; -u8 sCurOcarinaSong[8] = { +u8 sCurOcarinaSongWithoutMusicStaff[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 sOcarinaWithoutMusicStaffPos = 0; u8 sOcarinaSongStartingPos = 0; u8 sButtonToPitchMap[5] = { @@ -1027,10 +1028,10 @@ u8 sButtonToPitchMap[5] = { }; u8 sOcarinaMemoryGameAppendPos = 0; -u8 sOcaMemoryGameEndPos = 0; -u8 sOcaMemoryGameNumNotes[] = { 5, 6, 8 }; +u8 sOcarinaMemoryGameEndPos = 0; +u8 sOcarinaMemoryGameNumNotes[] = { 5, 6, 8 }; OcarinaNote sOcarinaSongNotes[OCARINA_SONG_MAX][20] = { - // 0: Sonata of Awakening + // OCARINA_SONG_SONATA { { OCARINA_PITCH_D5, 19, 92, 0, 0, 0 }, { OCARINA_PITCH_B4, 19, 90, 0, 0, 0 }, @@ -1042,7 +1043,7 @@ OcarinaNote sOcarinaSongNotes[OCARINA_SONG_MAX][20] = { { OCARINA_PITCH_NONE, 0, 86, 0, 0, 0 }, }, - // 1: Goron Lullaby + // OCARINA_SONG_GORON_LULLABY { { OCARINA_PITCH_D4, 41, 80, 0, 0, 0 }, { OCARINA_PITCH_A4, 40, 72, 0, 0, 0 }, @@ -1056,7 +1057,7 @@ OcarinaNote sOcarinaSongNotes[OCARINA_SONG_MAX][20] = { { OCARINA_PITCH_NONE, 0, 66, 0, 0, 0 }, }, - // 2: New Wave Bossa Nova + // OCARINA_SONG_NEW_WAVE { { OCARINA_PITCH_B4, 64, 74, 0, 0, 0 }, { OCARINA_PITCH_D5, 13, 88, 0, 0, 0 }, @@ -1068,7 +1069,7 @@ OcarinaNote sOcarinaSongNotes[OCARINA_SONG_MAX][20] = { { OCARINA_PITCH_NONE, 0, 90, 0, 0, 0 }, }, - // 3: Elegy of Emptyness + // OCARINA_SONG_ELEGY { { OCARINA_PITCH_A4, 85, 93, 0, 0, 0 }, { OCARINA_PITCH_B4, 43, 91, 0, 0, 0 }, @@ -1080,7 +1081,7 @@ OcarinaNote sOcarinaSongNotes[OCARINA_SONG_MAX][20] = { { OCARINA_PITCH_NONE, 0, 94, 0, 0, 0 }, }, - // 4: Oath to Order + // OCARINA_SONG_OATH { { OCARINA_PITCH_A4, 97, 104, 0, 0, 0 }, { OCARINA_PITCH_F4, 48, 88, 0, 0, 0 }, @@ -1092,7 +1093,7 @@ OcarinaNote sOcarinaSongNotes[OCARINA_SONG_MAX][20] = { }, - // 5: Sarias Song + // OCARINA_SONG_SARIAS { { OCARINA_PITCH_F4, 17, 84, 0, 0, 0 }, { OCARINA_PITCH_A4, 17, 88, 0, 0, 0 }, @@ -1103,7 +1104,7 @@ OcarinaNote sOcarinaSongNotes[OCARINA_SONG_MAX][20] = { { OCARINA_PITCH_NONE, 0, 90, 0, 0, 0 }, }, - // 6: Song of Time + // OCARINA_SONG_TIME { { OCARINA_PITCH_A4, 32, 84, 0, 0, 0 }, { OCARINA_PITCH_D4, 65, 88, 0, 0, 0 }, @@ -1114,7 +1115,7 @@ OcarinaNote sOcarinaSongNotes[OCARINA_SONG_MAX][20] = { { OCARINA_PITCH_NONE, 0, 90, 0, 0, 0 }, }, - // 7: Song of Healing + // OCARINA_SONG_HEALING { { OCARINA_PITCH_B4, 32, 88, 0, 0, 0 }, { OCARINA_PITCH_A4, 33, 88, 0, 0, 0 }, @@ -1126,7 +1127,7 @@ OcarinaNote sOcarinaSongNotes[OCARINA_SONG_MAX][20] = { { OCARINA_PITCH_NONE, 0, 90, 0, 0, 0 }, }, - // 8: Eponas Song + // OCARINA_SONG_EPONAS { { OCARINA_PITCH_D5, 18, 84, 0, 0, 0 }, { OCARINA_PITCH_B4, 18, 88, 0, 0, 0 }, @@ -1137,7 +1138,7 @@ OcarinaNote sOcarinaSongNotes[OCARINA_SONG_MAX][20] = { { OCARINA_PITCH_NONE, 0, 90, 0, 0, 0 }, }, - // 9: Song of Soaring + // OCARINA_SONG_SOARING { { OCARINA_PITCH_F4, 18, 84, 0, 0, 0 }, { OCARINA_PITCH_B4, 18, 80, 0, 0, 0 }, @@ -1148,7 +1149,7 @@ OcarinaNote sOcarinaSongNotes[OCARINA_SONG_MAX][20] = { { OCARINA_PITCH_NONE, 0, 90, 0, 0, 0 }, }, - // 10: Song of Storms + // OCARINA_SONG_STORMS { { OCARINA_PITCH_D4, 11, 84, 0, 0, 0 }, { OCARINA_PITCH_F4, 11, 88, 0, 0, 0 }, @@ -1159,7 +1160,7 @@ OcarinaNote sOcarinaSongNotes[OCARINA_SONG_MAX][20] = { { OCARINA_PITCH_NONE, 0, 90, 0, 0, 0 }, }, - // 11: Suns Song + // OCARINA_SONG_SUNS { { OCARINA_PITCH_A4, 12, 84, 0, 0, 0 }, { OCARINA_PITCH_F4, 13, 88, 0, 0, 0 }, @@ -1171,7 +1172,7 @@ OcarinaNote sOcarinaSongNotes[OCARINA_SONG_MAX][20] = { { OCARINA_PITCH_NONE, 0, 90, 0, 0, 0 }, }, - // 12: Inverted Song of Time + // OCARINA_SONG_INVERTED_TIME { { OCARINA_PITCH_F4, 32, 84, 0, 0, 0 }, { OCARINA_PITCH_D4, 65, 88, 0, 0, 0 }, @@ -1182,7 +1183,7 @@ OcarinaNote sOcarinaSongNotes[OCARINA_SONG_MAX][20] = { { OCARINA_PITCH_NONE, 0, 90, 0, 0, 0 }, }, - // 13: Song of Double Time + // OCARINA_SONG_DOUBLE_TIME { { OCARINA_PITCH_A4, 29, 84, 0, 0, 0 }, { OCARINA_PITCH_NONE, 3, 84, 0, 0, 0 }, @@ -1198,7 +1199,7 @@ OcarinaNote sOcarinaSongNotes[OCARINA_SONG_MAX][20] = { { OCARINA_PITCH_NONE, 0, 0, 0, 0, 0 }, }, - // 14: Goron Lullaby Intro + // OCARINA_SONG_GORON_LULLABY_INTRO { { OCARINA_PITCH_D4, 32, 78, 0, 0, 0 }, { OCARINA_PITCH_A4, 33, 90, 0, 0, 0 }, @@ -1209,7 +1210,7 @@ OcarinaNote sOcarinaSongNotes[OCARINA_SONG_MAX][20] = { { OCARINA_PITCH_NONE, 0, 66, 0, 0, 0 }, }, - // 15: Milk Bar Jam "Ballad of the Wind Fish" Human + // OCARINA_SONG_WIND_FISH_HUMAN { { OCARINA_PITCH_D5, 89, 80, 0, 0, 0 }, { OCARINA_PITCH_A4, 41, 72, 0, 0, 0 }, @@ -1219,7 +1220,7 @@ OcarinaNote sOcarinaSongNotes[OCARINA_SONG_MAX][20] = { { OCARINA_PITCH_NONE, 0, 66, 0, 0, 0 }, }, - // 16: Milk Bar Jam "Ballad of the Wind Fish" Goron + // OCARINA_SONG_WIND_FISH_GORON { { OCARINA_PITCH_D4, 52, 80, 0, 0, 0 }, { OCARINA_PITCH_NONE, 3, 66, 0, 0, 0 }, @@ -1238,7 +1239,7 @@ OcarinaNote sOcarinaSongNotes[OCARINA_SONG_MAX][20] = { { OCARINA_PITCH_NONE, 0, 66, 0, 0, 0 }, }, - // 17: Milk Bar Jam "Ballad of the Wind Fish" Zora + // OCARINA_SONG_WIND_FISH_ZORA { { OCARINA_PITCH_D5, 11, 80, 0, 0, 0 }, { OCARINA_PITCH_A4, 11, 72, 0, 0, 0 }, @@ -1251,7 +1252,7 @@ OcarinaNote sOcarinaSongNotes[OCARINA_SONG_MAX][20] = { { OCARINA_PITCH_NONE, 0, 66, 0, 0, 0 }, }, - // 18: Milk Bar Jam "Ballad of the Wind Fish" Deku + // OCARINA_SONG_WIND_FISH_DEKU { { OCARINA_PITCH_A4, 54, 80, 0, 0, 0 }, { OCARINA_PITCH_D4, 77, 72, 0, 0, 0 }, @@ -1261,7 +1262,7 @@ OcarinaNote sOcarinaSongNotes[OCARINA_SONG_MAX][20] = { { OCARINA_PITCH_NONE, 0, 66, 0, 0, 0 }, }, - // 19: Evan HP (Zora Band Leader) Song Part 1 + // OCARINA_SONG_EVAN_PART1 { { OCARINA_PITCH_A4, 33, 100, 0, 0, 0 }, { OCARINA_PITCH_NONE, 3, 92, 0, 0, 0 }, @@ -1276,7 +1277,7 @@ OcarinaNote sOcarinaSongNotes[OCARINA_SONG_MAX][20] = { { OCARINA_PITCH_NONE, 0, 66, 0, 0, 0 }, }, - // 20: Evan HP (Zora Band Leader) Song Part 2 + // OCARINA_SONG_EVAN_PART2 { { OCARINA_PITCH_B4, 33, 107, 0, 0, 0 }, { OCARINA_PITCH_NONE, 3, 100, 0, 0, 0 }, @@ -1291,7 +1292,7 @@ OcarinaNote sOcarinaSongNotes[OCARINA_SONG_MAX][20] = { { OCARINA_PITCH_NONE, 0, 66, 0, 0, 0 }, }, - // 21: Zeldas Lullaby + // OCARINA_SONG_ZELDAS_LULLABY { { OCARINA_PITCH_B4, 51, 84, 0, 0, 0 }, { OCARINA_PITCH_D5, 25, 88, 0, 0, 0 }, @@ -1302,13 +1303,13 @@ OcarinaNote sOcarinaSongNotes[OCARINA_SONG_MAX][20] = { { OCARINA_PITCH_NONE, 0, 90, 0, 0, 0 }, }, - // 22: Scarecrow + // OCARINA_SONG_SCARECROW_SPAWN { { 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_SONG_TERMINA_WALL { { OCARINA_PITCH_D4, 3, 0, 0, 0, 0 }, { OCARINA_PITCH_NONE, 0, 255, 0, 0, 0 }, @@ -1434,7 +1435,7 @@ u8 sOoTOcarinaSongsNumNotes[] = { 6, // Suns Song }; -OcarinaNote* sPlaybackSong = sOcarinaSongNotes[OCARINA_SONG_SONATA]; +OcarinaNote* sPlaybackSong = sOcarinaSongNotes[0]; 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, @@ -1453,7 +1454,7 @@ u8 sPlayedOcarinaSongIndexPlusOne = 0; u8 sMusicStaffNumNotesPerTest = 0; u8 D_801D8530 = false; u32 D_801D8534 = 0; -u8 sIsOcarinaNoteChanged = false; +u8 sOcarinaDropInputTimer = 0; OcarinaNote sScarecrowsLongSongNotes[108] = { { OCARINA_PITCH_NONE, 0, 0, 0, 0, 0 }, @@ -1461,38 +1462,81 @@ OcarinaNote sScarecrowsLongSongNotes[108] = { }; OcarinaNote* gScarecrowLongSongPtr = sScarecrowsLongSongNotes; -u8* gScarecrowSpawnSongPtr = (u8*)&sOcarinaSongNotes[OCARINA_SONG_SCARECROW]; +u8* gScarecrowSpawnSongPtr = (u8*)&sOcarinaSongNotes[OCARINA_SONG_SCARECROW_SPAWN]; 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 + 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_OR_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 +// clang-format off 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, + /* 0 */ 0xFE, // delay1 + /* 1 */ 0xFE, // delay1 + /* 2 */ 0xD3, 0x20, // mutebhv 0x20 + /* 4 */ 0xD7, 0x00, 0x01, // initchan 0x0001 + /* 7 */ 0xCC, 0x00, // ldi 0 + /* 9 */ 0x70, // stio 0 + /* 10 */ 0x90, 0x00, 22, // ldchan 0, chan0 + /* 13 */ 0xDB, 100, // vol 100 + /* 15 */ 0xDD, 120, // tempo 120 + + // .sequence seq_loop + /* 17 */ 0xFE, // delay1 + /* 18 */ 0x00, // testchan 0 + /* 19 */ 0xF3, -4, // rbeqz seq_loop + /* 21 */ 0xFF, // end + + // .channel chan0 + /* 22 */ 0xC3, // short + /* 23 */ 0x88, 0x00, 41, // ldlayer 0, layer0 + /* 26 */ 0x89, 0x00, 43, // ldlayer 1, layer1 + /* 29 */ 0xDF, 127, // vol 127 + /* 31 */ 0xE9, 0x0F, // notepri 0x0F + /* 33 */ 0xDD, 55, // pan 55 + /* 35 */ 0xD4, 64, // reverb 64 + /* 37 */ 0xC1, 82, // instr 82 + + // .channel chan_loop + /* 39 */ 0xFE, // delay1 + /* 40 */ 0x80, // testlayer 0 + + // (no end or loop; channel script seems to run into the note layers?) + + // .layer layer0 + /* 41 */ 0xF3, -4, // rbeqz chan_loop + + // .layer layer1 + /* 43 */ 0xFF, // end + + // .layer layer2? + /* 44 */ 0xC2, -5, // transpose -5 + /* 46 */ 0xC0, 0, // ldelay 0 + /* 48 */ 0xC1, 87, // shortvel 87 + /* 50 */ 0xC9, 0, // shortgate 0 + /* 52 */ 0, // empty until the end }; +// clang-format on OcarinaSongButtons gOcarinaSongButtons[OCARINA_SONG_MAX] = { - // 0: Sonata of Awakening + // OCARINA_SONG_SONATA { 7, { @@ -1506,7 +1550,7 @@ OcarinaSongButtons gOcarinaSongButtons[OCARINA_SONG_MAX] = { }, }, - // 1: Goron Lullaby + // OCARINA_SONG_GORON_LULLABY { 8, { @@ -1521,7 +1565,7 @@ OcarinaSongButtons gOcarinaSongButtons[OCARINA_SONG_MAX] = { }, }, - // 2: New Wave Bossa Nova + // OCARINA_SONG_NEW_WAVE { 7, { @@ -1535,7 +1579,7 @@ OcarinaSongButtons gOcarinaSongButtons[OCARINA_SONG_MAX] = { }, }, - // 3: Elegy of Emptyness + // OCARINA_SONG_ELEGY { 7, { @@ -1549,7 +1593,7 @@ OcarinaSongButtons gOcarinaSongButtons[OCARINA_SONG_MAX] = { }, }, - // 4: Oath to Order + // OCARINA_SONG_OATH { 6, { @@ -1562,7 +1606,7 @@ OcarinaSongButtons gOcarinaSongButtons[OCARINA_SONG_MAX] = { }, }, - // 5; Sarias Song + // OCARINA_SONG_SARIAS { 6, { @@ -1575,7 +1619,7 @@ OcarinaSongButtons gOcarinaSongButtons[OCARINA_SONG_MAX] = { }, }, - // 6: Song of Time + // OCARINA_SONG_TIME { 6, { @@ -1588,7 +1632,7 @@ OcarinaSongButtons gOcarinaSongButtons[OCARINA_SONG_MAX] = { }, }, - // 7: Song of Healing + // OCARINA_SONG_HEALING { 6, { @@ -1601,7 +1645,7 @@ OcarinaSongButtons gOcarinaSongButtons[OCARINA_SONG_MAX] = { }, }, - // 8: Eponas Song + // OCARINA_SONG_EPONAS { 6, { @@ -1614,7 +1658,7 @@ OcarinaSongButtons gOcarinaSongButtons[OCARINA_SONG_MAX] = { }, }, - // 9: Song of Soaring + // OCARINA_SONG_SOARING { 6, { @@ -1627,7 +1671,7 @@ OcarinaSongButtons gOcarinaSongButtons[OCARINA_SONG_MAX] = { }, }, - // 10: Song of Storms + // OCARINA_SONG_STORMS { 6, { @@ -1640,7 +1684,7 @@ OcarinaSongButtons gOcarinaSongButtons[OCARINA_SONG_MAX] = { }, }, - // 11: Suns Song + // OCARINA_SONG_SUNS { 6, { @@ -1653,7 +1697,7 @@ OcarinaSongButtons gOcarinaSongButtons[OCARINA_SONG_MAX] = { }, }, - // 12: Inverted Song of Time + // OCARINA_SONG_INVERTED_TIME { 6, { @@ -1666,7 +1710,7 @@ OcarinaSongButtons gOcarinaSongButtons[OCARINA_SONG_MAX] = { }, }, - // 13; Song of Double Time + // OCARINA_SONG_DOUBLE_TIME { 6, { @@ -1679,7 +1723,7 @@ OcarinaSongButtons gOcarinaSongButtons[OCARINA_SONG_MAX] = { }, }, - // 14: Goron Lullaby Intro + // OCARINA_SONG_GORON_LULLABY_INTRO { 6, { @@ -1692,7 +1736,7 @@ OcarinaSongButtons gOcarinaSongButtons[OCARINA_SONG_MAX] = { }, }, - // 15: Milk Bar Jam "Ballad of the Wind Fish" Human + // OCARINA_SONG_WIND_FISH_HUMAN { 4, { @@ -1703,7 +1747,7 @@ OcarinaSongButtons gOcarinaSongButtons[OCARINA_SONG_MAX] = { }, }, - // 16: Milk Bar Jam "Ballad of the Wind Fish" Goron + // OCARINA_SONG_WIND_FISH_GORON { 8, { @@ -1718,7 +1762,7 @@ OcarinaSongButtons gOcarinaSongButtons[OCARINA_SONG_MAX] = { }, }, - // 17: Milk Bar Jam "Ballad of the Wind Fish" Zora + // OCARINA_SONG_WIND_FISH_ZORA { 8, { @@ -1733,7 +1777,7 @@ OcarinaSongButtons gOcarinaSongButtons[OCARINA_SONG_MAX] = { }, }, - // 18: Milk Bar Jam "Ballad of the Wind Fish" Deku + // OCARINA_SONG_WIND_FISH_DEKU { 5, { @@ -1745,7 +1789,7 @@ OcarinaSongButtons gOcarinaSongButtons[OCARINA_SONG_MAX] = { }, }, - // 19: Evan HP (Zora Band Leader) Song Part 1 + // OCARINA_SONG_EVAN_PART1 { 8, { @@ -1760,7 +1804,7 @@ OcarinaSongButtons gOcarinaSongButtons[OCARINA_SONG_MAX] = { }, }, - // 20: Evan HP (Zora Band Leader) Song Part 2 + // OCARINA_SONG_EVAN_PART2 { 8, { @@ -1775,7 +1819,7 @@ OcarinaSongButtons gOcarinaSongButtons[OCARINA_SONG_MAX] = { }, }, - // 21: Zeldas Lullaby + // OCARINA_SONG_ZELDAS_LULLABY { 6, { @@ -1788,7 +1832,7 @@ OcarinaSongButtons gOcarinaSongButtons[OCARINA_SONG_MAX] = { }, }, - // 22: Scarecrow + // OCARINA_SONG_SCARECROW_SPAWN { 8, { @@ -1803,7 +1847,7 @@ OcarinaSongButtons gOcarinaSongButtons[OCARINA_SONG_MAX] = { }, }, - // 23: Termina Field 2D Song Buttons Appearing on Wall (In OoT, this is Ocarina Memory Game) + // OCARINA_SONG_TERMINA_WALL { 8, { @@ -1819,26 +1863,6 @@ OcarinaSongButtons gOcarinaSongButtons[OCARINA_SONG_MAX] = { }, }; -// 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, @@ -1853,8 +1877,6 @@ const u16 gAudioEnvironmentalSfx[] = { 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 @@ -1878,65 +1900,9 @@ const u8 sIsOcarinaSongReserved[OCARINA_SONG_MAX] = { true, // OCARINA_SONG_EVAN_PART1 true, // OCARINA_SONG_EVAN_PART2 false, // OCARINA_SONG_ZELDAS_LULLABY - true, // OCARINA_SONG_SCARECROW + true, // OCARINA_SONG_SCARECROW_SPAWN false, // OCARINA_SONG_TERMINA_WALL }; -*/ - -#pragma GLOBAL_ASM("asm/non_matchings/code/code_8019AF00/func_8019AF00.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/code_8019AF00/func_8019AF58.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/code_8019AF00/func_8019AFE8.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/code_8019AF00/func_8019B02C.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") - -#pragma GLOBAL_ASM("asm/non_matchings/code/code_8019AF00/func_8019B378.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/code_8019AF00/func_8019B38C.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/code_8019AF00/func_8019B3D0.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/code_8019AF00/func_8019B4B8.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") - -#pragma GLOBAL_ASM("asm/non_matchings/code/code_8019AF00/func_8019B5AC.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/code_8019AF00/func_8019B5EC.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/code_8019AF00/func_8019B618.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/code_8019AF00/func_8019B654.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/code_8019AF00/func_8019B6B4.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/code_8019AF00/func_8019BC44.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/code_8019AF00/func_8019BE98.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/code_8019AF00/func_8019C1C0.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/code_8019AF00/func_8019C1D0.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/code_8019AF00/func_8019C268.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/code_8019AF00/func_8019C2E4.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") - -#pragma GLOBAL_ASM("asm/non_matchings/code/code_8019AF00/func_8019C5A0.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/code_8019AF00/func_8019C8D8.s") const char sAudioOcarinaUnusedText0[] = "key step is too long !!! %d:%d>%d\n"; const char sAudioOcarinaUnusedText1[] = "You played %d Melody !!! (last step:%d)\n"; @@ -1947,21 +1913,1113 @@ 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") +void AudioOcarina_ReadControllerInput(void) { + Input inputs[4]; + Input* input = &inputs[0]; + u32 ocarinaInputButtonPrev = sOcarinaInputButtonCur; -#pragma GLOBAL_ASM("asm/non_matchings/code/code_8019AF00/func_8019CE34.s") + Padmgr_GetInput2(inputs, 0); + sOcarinaInputButtonCur = input->cur.button; + sOcarinaInputButtonPrev = ocarinaInputButtonPrev; + sOcarinaInputStickRel.x = input->rel.stick_x; + sOcarinaInputStickRel.y = input->rel.stick_y; +} -#pragma GLOBAL_ASM("asm/non_matchings/code/code_8019AF00/func_8019CE6C.s") +/** + * Looks up the frequency to bend the pitch by. + * The pitch will bend up to a maximum of 2 semitones + * in each direction giving a total range of 4 semitones + */ +f32 AudioOcarina_BendPitchTwoSemitones(s8 bendIndex) { + s8 adjBendIndex; + f32 bendFreq; -#pragma GLOBAL_ASM("asm/non_matchings/code/code_8019AF00/func_8019CEBC.s") + if (bendIndex > 64) { + adjBendIndex = 127; + } else if (bendIndex < -64) { + adjBendIndex = -128; + } else if (bendIndex >= 0) { + adjBendIndex = (bendIndex * 127) / 64; + } else { + adjBendIndex = (bendIndex * 128) / 64; + } -#pragma GLOBAL_ASM("asm/non_matchings/code/code_8019AF00/func_8019CF6C.s") + /** + * index 128 is in the middle of the table and + * contains the value 1.0f i.e. no bend + * absolute indices above 128 will bend the pitch 2 semitones upwards + * absolute indices below 128 will bend the pitch 2 semitones downwards + */ + bendFreq = gBendPitchTwoSemitonesFrequencies[adjBendIndex + 128]; + return bendFreq; +} -#pragma GLOBAL_ASM("asm/non_matchings/code/code_8019AF00/func_8019CF78.s") +/** + * If an available song has been played, then return that song index + * If the ocarina is on, but no song has been played then return 0xFE + * If the ocarina is off, return 0xFF + */ +u8 AudioOcarina_GetPlayingState(void) { + u8 playedOcarinaSongIndex; -#pragma GLOBAL_ASM("asm/non_matchings/code/code_8019AF00/AudioOcarina_GetPlaybackStaff.s") + if (sPlayedOcarinaSongIndexPlusOne != 0) { + playedOcarinaSongIndex = sPlayedOcarinaSongIndexPlusOne - 1; + sPlayedOcarinaSongIndexPlusOne = 0; + } else if (sOcarinaFlags != 0) { + playedOcarinaSongIndex = 0xFE; + } else { + playedOcarinaSongIndex = 0xFF; + } -#pragma GLOBAL_ASM("asm/non_matchings/code/code_8019AF00/func_8019CFA8.s") + return playedOcarinaSongIndex; +} + +u8 AudioOcarina_MapPitchToButton(u8 pitchAndBFlatFlag) { + u8 buttonIndex = sPitchToButtonMap[pitchAndBFlatFlag & 0x3F]; + + /** + * Special case for bFlat4: + * CRIGHT and CLEFT are the only two pitches that are 2 semitones apart + * which are pitches A4 and B4 respectively + * bFlat4 is in the middle of those two and is the only pitch that can not + * be resolved between the two buttons without external information. + * That information is stored as flags in pitch with the mask: + * (pitchAndBFlatFlag & 0xC0) + */ + if (buttonIndex == OCARINA_BTN_C_RIGHT_OR_C_LEFT) { + if (pitchAndBFlatFlag & OCARINA_BUTTON_FLAG_BFLAT_RAISE) { + return OCARINA_BTN_C_RIGHT; + } + // OCARINA_BUTTON_FLAG_BFLAT_LOWER + return OCARINA_BTN_C_LEFT; + } + + return buttonIndex; +} + +void AudioOcarina_MapSongFromPitchToButton(u8 noteSongIndex, u8 buttonSongIndex, u8 numButtons) { + u8 buttonSongPos = 0; + u8 noteSongPos = 0; + u8 pitch; + + while ((buttonSongPos < numButtons) && (noteSongPos < 16)) { + pitch = sOcarinaSongNotes[noteSongIndex][noteSongPos++].pitch; + + if (pitch != OCARINA_PITCH_NONE) { + gOcarinaSongButtons[buttonSongIndex].buttonIndex[buttonSongPos++] = sPitchToButtonMap[pitch]; + } + } + + gOcarinaSongButtons[buttonSongIndex].numButtons = numButtons; +} + +/** + * Ocarina flags: + * bitmask 0x3FFF: + * - Ocarina song id + * bitmask 0xC000: + * - 0x0000: Limits the notes to 8 notes at a time. Not playing a correct song after 8 notes will cause an ocarina + * error + * - 0x4000: (Identical to 0xC000) + * - 0x8000: Limits the notes to 1 note at a time. A single incorrect note will cause an ocarina error + * - 0xC000: Free-play, no limitations to the number of notes to play + * bitmask 0x7FFF0000: + * - ocarina action (only used to make flags != 0) + * bitmask 0x80000000: + * - unused (only used to make flags != 0) + */ + +// The ocarina songs that can be performed at any time = 0x3FFF +#define OCARINA_SONGS_PLAYABLE_FLAGS \ + ((1 << OCARINA_SONG_SONATA) | (1 << OCARINA_SONG_GORON_LULLABY) | (1 << OCARINA_SONG_NEW_WAVE) | \ + (1 << OCARINA_SONG_ELEGY) | (1 << OCARINA_SONG_OATH) | (1 << OCARINA_SONG_SARIAS) | (1 << OCARINA_SONG_TIME) | \ + (1 << OCARINA_SONG_HEALING) | (1 << OCARINA_SONG_EPONAS) | (1 << OCARINA_SONG_SOARING) | \ + (1 << OCARINA_SONG_STORMS) | (1 << OCARINA_SONG_SUNS) | (1 << OCARINA_SONG_INVERTED_TIME) | \ + (1 << OCARINA_SONG_DOUBLE_TIME)) + +void AudioOcarina_Start(u32 ocarinaFlags) { + u8 songIndex; + + if ((sOcarinaSongNotes[OCARINA_SONG_SCARECROW_SPAWN][1].volume != 0xFF) && + ((ocarinaFlags & OCARINA_SONGS_PLAYABLE_FLAGS) == OCARINA_SONGS_PLAYABLE_FLAGS)) { + ocarinaFlags |= (1 << OCARINA_SONG_SCARECROW_SPAWN); + } + + if ((ocarinaFlags == (0xC0000000 | OCARINA_SONGS_PLAYABLE_FLAGS)) && + (sOcarinaSongNotes[OCARINA_SONG_SCARECROW_SPAWN][1].volume != 0xFF)) { + ocarinaFlags = (0xC0000000 | OCARINA_SONGS_PLAYABLE_FLAGS); + } + + if ((ocarinaFlags == OCARINA_SONGS_PLAYABLE_FLAGS) && + (sOcarinaSongNotes[OCARINA_SONG_SCARECROW_SPAWN][1].volume != 0xFF)) { + ocarinaFlags = OCARINA_SONGS_PLAYABLE_FLAGS; + } + + if (ocarinaFlags != 0xFFFF) { + sOcarinaFlags = 0x80000000 + ocarinaFlags; + sFirstOcarinaSongIndex = 0; + sLastOcarinaSongIndex = OCARINA_SONG_MAX; + sOcarinaAvailableSongFlags = ocarinaFlags & 0xFFFFFF; + sMusicStaffNumNotesPerTest = 8; // Ocarina Check + sOcarinaHasStartedSong = false; + sPlayedOcarinaSongIndexPlusOne = 0; + sOcarinaStaffPlayingPos = 0; + sPlayingStaff.state = AudioOcarina_GetPlayingState(); + sIsOcarinaInputEnabled = true; + sPrevOcarinaWithMusicStaffFlags = 0; + + // Reset music staff song check + for (songIndex = OCARINA_SONG_SONATA; songIndex <= OCARINA_SONG_EVAN_PART2; songIndex++) { + for (sMusicStaffPos[songIndex] = 0; + sOcarinaSongNotes[songIndex][sMusicStaffPos[songIndex]].pitch == OCARINA_PITCH_NONE;) { + sMusicStaffPos[songIndex]++; + } + + sMusicStaffCurHeldLength[songIndex] = 0; + sMusicStaffExpectedLength[songIndex] = 0; + sMusicStaffExpectedPitch[songIndex] = 0; + + if (D_801D8530) { + if ((1 << songIndex) & ocarinaFlags) { + D_801FD518[songIndex] = 0; + } else { + D_801FD518[songIndex] = 0xFF; + } + } + } + + if (ocarinaFlags & 0x80000000) { + sMusicStaffNumNotesPerTest = 0; // Ocarina Playback + } + + if (ocarinaFlags & 0x40000000) { + sOcarinaWithoutMusicStaffPos = 0; + } + + if (ocarinaFlags & 0xC0400000) { + AudioOcarina_MapSongFromPitchToButton(OCARINA_SONG_SCARECROW_SPAWN, OCARINA_SONG_SCARECROW_SPAWN, 8); + } + } else { + sOcarinaFlags = 0; + sIsOcarinaInputEnabled = false; + } +} + +#undef OCARINA_SONGS_PLAYABLE_FLAGS + +void AudioOcarina_SetSongStartingPos(void) { + sOcarinaSongStartingPos = sOcarinaWithoutMusicStaffPos; +} + +void AudioOcarina_StartAtSongStartingPos(u32 ocarinaFlags) { + D_801D8530 = false; + AudioOcarina_Start(ocarinaFlags); + if (sOcarinaSongStartingPos != 0) { + sOcarinaWithoutMusicStaffPos = sOcarinaSongStartingPos; + sOcarinaSongStartingPos = 0; + } +} + +void AudioOcarina_StartForSongCheck(u32 ocarinaFlags, u8 ocarinaStaffPlayingPosStart) { + u8 songIndex; + u8 j; + + AudioOcarina_Start(ocarinaFlags); + sMusicStaffNumNotesPerTest = 8; + sOcarinaStaffPlayingPos = ocarinaStaffPlayingPosStart; + + for (songIndex = 0; songIndex <= OCARINA_SONG_EVAN_PART2; songIndex++) { + for (j = 0; j < ocarinaStaffPlayingPosStart;) { + if (sOcarinaSongNotes[songIndex][sMusicStaffPos[songIndex]].pitch != OCARINA_PITCH_NONE) { + j++; + } + sMusicStaffPos[songIndex]++; + } + + if (sOcarinaSongNotes[songIndex][sMusicStaffPos[songIndex]].pitch == OCARINA_PITCH_NONE) { + sMusicStaffPos[songIndex]++; + } + } +} + +void AudioOcarina_StartWithSongNoteLengths(u32 ocarinaFlags) { + u8 songIndex; + + for (songIndex = 0; songIndex < OCARINA_SONG_MAX; songIndex++) { + if ((1 << songIndex) & ocarinaFlags) { + D_801FD530[songIndex] = 0; + } else { + D_801FD530[songIndex] = 0xFF; + } + } + + D_801D8530 = true; + D_801D8534 = ocarinaFlags; + AudioOcarina_Start(ocarinaFlags); +} + +void AudioOcarina_StartDefault(u32 ocarinaFlags) { + D_801D8530 = false; + AudioOcarina_Start(ocarinaFlags); +} + +u8 func_8019B568(void) { + u32 temp_v0 = D_801D8534; + u8 songIndex; + + for (songIndex = OCARINA_SONG_SONATA; !((temp_v0 >> songIndex) & 1) && (songIndex < OCARINA_SONG_MAX); + songIndex++) {} + + return songIndex; +} + +u8 func_8019B5AC(void) { + u8 songIndex = func_8019B568(); + + if (songIndex < OCARINA_SONG_MAX) { + return D_801FD518[songIndex]; + } + + return 0xFF; +} + +u8 func_8019B5EC(void) { + return D_801FD530[func_8019B568()]; +} + +void AudioOcarina_CheckIfStartedSong(void) { + if ((sCurOcarinaPitch != OCARINA_PITCH_NONE) && !sOcarinaHasStartedSong) { + sOcarinaHasStartedSong = true; + sMusicStaffPrevPitch = OCARINA_PITCH_NONE; + } +} + +void AudioOcarina_UpdateCurOcarinaSong(void) { + u8 i; + + if (sOcarinaWithoutMusicStaffPos == 8) { + for (i = 0; i < ARRAY_COUNT(sCurOcarinaSongWithoutMusicStaff) - 1; i++) { + sCurOcarinaSongWithoutMusicStaff[i] = sCurOcarinaSongWithoutMusicStaff[i + 1]; + } + } else { + sOcarinaWithoutMusicStaffPos++; + } +} + +/** + * Checks for ocarina songs from user input with a music staff prompt + * Type 1) Playback: tests note-by-note (ocarinaFlag & 0xC000 == 0x8000) eg: + * - learning a new song + * - playing the ocarina memory game + * Type 2) Check: tests in 8-note chunks (ocarinaFlag & 0xC000 == 0x0000) eg: + * - validating scarecrow spawn song as adult + * - ocarina prompt for zelda's lullaby, saria's song, Storms, Song of Time, etc... + */ +void AudioOcarina_CheckSongsWithMusicStaff(void) { + u32 curOcarinaSongFlag; + s32 pad; + u8 noNewValidInput = false; + s16 pad2; + s8 staffOcarinaPlayingPosOffset = 0; + u8 songIndex; + OcarinaNote* curNote; + OcarinaNote* nextNote; + + AudioOcarina_CheckIfStartedSong(); + + if (!sOcarinaHasStartedSong) { + return; + } + + if (ABS_ALT(sCurOcarinaBendIndex) > 20) { + sOcarinaFlags = 0; + for (songIndex = OCARINA_SONG_SONATA; songIndex < OCARINA_SONG_MAX; songIndex++) { + D_801FD518[songIndex] = 4; + } + sIsOcarinaInputEnabled = false; + return; + } + + if ((sPrevOcarinaPitch == sCurOcarinaPitch) || (sCurOcarinaPitch == OCARINA_PITCH_NONE)) { + noNewValidInput = true; + } else { + AudioOcarina_UpdateCurOcarinaSong(); + sCurOcarinaSongWithoutMusicStaff[sOcarinaWithoutMusicStaffPos - 1] = sCurOcarinaPitch; + } + + for (songIndex = sFirstOcarinaSongIndex; songIndex < sLastOcarinaSongIndex; songIndex++) { + curOcarinaSongFlag = 1 << songIndex; + + if (sOcarinaAvailableSongFlags & curOcarinaSongFlag) { + if (D_801D8530) { + sMusicStaffCurHeldLength[songIndex] += sOcarinaUpdateTaskStart - sOcarinaPlaybackTaskStart; + } else { + sMusicStaffCurHeldLength[songIndex] = sMusicStaffExpectedLength[songIndex] + 9; + } + + if (noNewValidInput) { + if ((sMusicStaffCurHeldLength[songIndex] > 8) && + (sMusicStaffPrevPitch != sMusicStaffExpectedPitch[songIndex])) { + sOcarinaAvailableSongFlags ^= curOcarinaSongFlag; + if (D_801D8530) { + D_801FD518[songIndex] = 1; + } + } + + if (D_801D8530 && ((sMusicStaffExpectedLength[songIndex] + 9) < sMusicStaffCurHeldLength[songIndex])) { + sOcarinaAvailableSongFlags ^= curOcarinaSongFlag; + D_801FD518[songIndex] = 3; + } else if ((sMusicStaffCurHeldLength[songIndex] >= (sMusicStaffExpectedLength[songIndex] - 9)) && + (sMusicStaffCurHeldLength[songIndex] >= sMusicStaffExpectedLength[songIndex]) && + (sOcarinaSongNotes[songIndex][sMusicStaffPos[songIndex]].length == 0) && + (sMusicStaffPrevPitch == sMusicStaffExpectedPitch[songIndex])) { + // This case is taken if the song is finished and successfully played + // (i.e. .length == 0 indicates that the song is at the end) + sPlayedOcarinaSongIndexPlusOne = songIndex + 1; + sIsOcarinaInputEnabled = false; + sOcarinaFlags = 0; + if (D_801D8530) { + D_801FD518[songIndex] = 5; + } + } + } else if (sMusicStaffCurHeldLength[songIndex] >= (sMusicStaffExpectedLength[songIndex] - 9)) { + // This else-if statement always holds true, taken if a new note is played + if (sMusicStaffPrevPitch != OCARINA_PITCH_NONE) { + // New note is played + if (sMusicStaffPrevPitch == sMusicStaffExpectedPitch[songIndex]) { + // Note is part of expected song + if (D_801D8530) { + D_801FD530[songIndex] += + ABS_ALT(sMusicStaffExpectedLength[songIndex] - sMusicStaffCurHeldLength[songIndex]); + } + sMusicStaffCurHeldLength[songIndex] = 0; + } else { + // Note is not part of expected song, so this song is no longer available as an option in this + // playback + sOcarinaAvailableSongFlags ^= curOcarinaSongFlag; + if (D_801D8530) { + D_801FD518[songIndex] = 1; + } + } + } + + curNote = &sOcarinaSongNotes[songIndex][sMusicStaffPos[songIndex]]; + nextNote = &sOcarinaSongNotes[songIndex][++sMusicStaffPos[songIndex]]; + sMusicStaffExpectedLength[songIndex] = curNote->length; + sMusicStaffExpectedPitch[songIndex] = curNote->pitch; + + while ((curNote->pitch == nextNote->pitch) || + ((nextNote->pitch == OCARINA_PITCH_NONE) && (nextNote->length != 0))) { + sMusicStaffExpectedLength[songIndex] += nextNote->length; + curNote = &sOcarinaSongNotes[songIndex][sMusicStaffPos[songIndex]]; + nextNote = &sOcarinaSongNotes[songIndex][sMusicStaffPos[songIndex] + 1]; + sMusicStaffPos[songIndex]++; + } + } else if (sMusicStaffCurHeldLength[songIndex] < 9) { + // case never taken + staffOcarinaPlayingPosOffset = -1; + sMusicStaffCurHeldLength[songIndex] = 0; + sMusicStaffPrevPitch = sCurOcarinaPitch; + } else { + // case never taken + if (sOcarinaSongNotes[songIndex][sMusicStaffPos[songIndex]].length == 0) { + D_801FD518[songIndex] = 1; + } else if (D_801D8530) { + D_801FD518[songIndex] = 2; + } + sOcarinaAvailableSongFlags ^= curOcarinaSongFlag; + } + } + + // if a note is played that doesn't match a song, the song bit in sAvailOcarinaSongFlags is turned off + // if there are no more songs remaining that it could be and the maximum position has been exceeded, then + if ((sOcarinaAvailableSongFlags == 0) && (sOcarinaStaffPlayingPos >= sMusicStaffNumNotesPerTest)) { + sIsOcarinaInputEnabled = false; + if (!D_801D8530) { + if ((sOcarinaFlags & 0x40000000) && (sCurOcarinaPitch == sOcarinaSongNotes[songIndex][0].pitch)) { + // case never taken, this function is not called if (sOcarinaFlags & 0x40000000) is set + sPrevOcarinaWithMusicStaffFlags = sOcarinaFlags; + } + } + sOcarinaFlags = 0; + return; + } + } + + if (!noNewValidInput) { + sMusicStaffPrevPitch = sCurOcarinaPitch; + sOcarinaStaffPlayingPos += staffOcarinaPlayingPosOffset + 1; + } +} + +/** + * Checks for ocarina songs from user input with no music staff prompt. + * Includes ocarina actions such as free play, no warp + */ +void AudioOcarina_CheckSongsWithoutMusicStaff(void) { + u32 pitch; + u8 ocarinaStaffPlayingPosStart; + u8 songIndex; + u8 j; + u8 k; + + if (CHECK_BTN_ANY(sOcarinaInputButtonCur, BTN_L) && + CHECK_BTN_ANY(sOcarinaInputButtonCur, BTN_A | BTN_CRIGHT | BTN_CLEFT | BTN_CDOWN | BTN_CUP)) { + AudioOcarina_StartDefault(sOcarinaFlags); + return; + } + + AudioOcarina_CheckIfStartedSong(); + + if (!sOcarinaHasStartedSong) { + return; + } + + ocarinaStaffPlayingPosStart = sOcarinaStaffPlayingPos; + if ((sPrevOcarinaPitch != sCurOcarinaPitch) && (sCurOcarinaPitch != OCARINA_PITCH_NONE)) { + sOcarinaStaffPlayingPos++; + if (sOcarinaStaffPlayingPos > ARRAY_COUNT(sCurOcarinaSongWithoutMusicStaff)) { + sOcarinaStaffPlayingPos = 1; + } + + AudioOcarina_UpdateCurOcarinaSong(); + + if ((ABS_ALT(sCurOcarinaBendIndex) > 20) && (ocarinaStaffPlayingPosStart != sOcarinaStaffPlayingPos)) { + sCurOcarinaSongWithoutMusicStaff[sOcarinaWithoutMusicStaffPos - 1] = OCARINA_PITCH_NONE; + } else { + sCurOcarinaSongWithoutMusicStaff[sOcarinaWithoutMusicStaffPos - 1] = sCurOcarinaPitch; + } + + // This nested for-loop tests to see if the notes from the ocarina are identical + // to any of the songIndex from sFirstOcarinaSongIndex to sLastOcarinaSongIndex + + // Loop through each of the songs + for (songIndex = sFirstOcarinaSongIndex; songIndex < sLastOcarinaSongIndex; songIndex++) { + // Checks to see if the song is available to be played + if ((u32)sOcarinaAvailableSongFlags & (1 << songIndex)) { + // Loops through all possible starting indices? + // Loops through the notes of the song? + for (j = 0, k = 0; j < gOcarinaSongButtons[songIndex].numButtons && k == 0 && + sOcarinaWithoutMusicStaffPos >= gOcarinaSongButtons[songIndex].numButtons;) { + + pitch = sCurOcarinaSongWithoutMusicStaff[(sOcarinaWithoutMusicStaffPos - + gOcarinaSongButtons[songIndex].numButtons) + + j]; + + if (pitch == sButtonToPitchMap[gOcarinaSongButtons[songIndex].buttonIndex[j]]) { + j++; + } else { + k++; + } + } + + // This conditional is true if songIndex = i is detected + if (j == gOcarinaSongButtons[songIndex].numButtons) { + sPlayedOcarinaSongIndexPlusOne = songIndex + 1; + sIsOcarinaInputEnabled = false; + sOcarinaFlags = 0; + } + } + } + } +} + +void AudioOcarina_PlayControllerInput(u8 isOcarinaSfxSuppressedWhenCancelled) { + u32 ocarinaBtnsHeld; + + // Prevents two different ocarina notes from being played on two consecutive frames + if ((sOcarinaFlags != 0) && (sOcarinaDropInputTimer != 0)) { + sOcarinaDropInputTimer--; + return; + } + + // Ensures the button pressed to start the ocarina does not also play an ocarina note + if ((sOcarinaInputButtonStart == 0) || + ((sOcarinaInputButtonStart & (BTN_A | BTN_CRIGHT | BTN_CLEFT | BTN_CDOWN | BTN_CUP)) != + (sOcarinaInputButtonCur & (BTN_A | BTN_CRIGHT | BTN_CLEFT | BTN_CDOWN | BTN_CUP)))) { + sOcarinaInputButtonStart = 0; + if (1) {} + sCurOcarinaPitch = OCARINA_PITCH_NONE; + sCurOcarinaButtonIndex = OCARINA_BTN_INVALID; + ocarinaBtnsHeld = (sOcarinaInputButtonCur & (BTN_A | BTN_CRIGHT | BTN_CLEFT | BTN_CDOWN | BTN_CUP)) & + (sOcarinaInputButtonPrev & (BTN_A | BTN_CRIGHT | BTN_CLEFT | BTN_CDOWN | BTN_CUP)); + + if (!(sOcarinaInputButtonPress & ocarinaBtnsHeld) && (sOcarinaInputButtonCur != 0)) { + sOcarinaInputButtonPress = sOcarinaInputButtonCur; + } else { + sOcarinaInputButtonPress &= ocarinaBtnsHeld; + } + + // Interprets and transforms controller input into ocarina buttons and notes + if (CHECK_BTN_ANY(sOcarinaInputButtonPress, BTN_A)) { + sCurOcarinaPitch = OCARINA_PITCH_D4; + sCurOcarinaButtonIndex = OCARINA_BTN_A; + + } else if (CHECK_BTN_ANY(sOcarinaInputButtonPress, BTN_CDOWN)) { + sCurOcarinaPitch = OCARINA_PITCH_F4; + sCurOcarinaButtonIndex = OCARINA_BTN_C_DOWN; + + } else if (CHECK_BTN_ANY(sOcarinaInputButtonPress, BTN_CRIGHT)) { + sCurOcarinaPitch = OCARINA_PITCH_A4; + sCurOcarinaButtonIndex = OCARINA_BTN_C_RIGHT; + + } else if (CHECK_BTN_ANY(sOcarinaInputButtonPress, BTN_CLEFT)) { + sCurOcarinaPitch = OCARINA_PITCH_B4; + sCurOcarinaButtonIndex = OCARINA_BTN_C_LEFT; + + } else if (CHECK_BTN_ANY(sOcarinaInputButtonPress, BTN_CUP)) { + sCurOcarinaPitch = OCARINA_PITCH_D5; + sCurOcarinaButtonIndex = OCARINA_BTN_C_UP; + } + + if (sOcarinaInputButtonCur) {} + + // Pressing the R Button will raise the pitch by 1 semitone + if ((sCurOcarinaPitch != OCARINA_PITCH_NONE) && CHECK_BTN_ANY(sOcarinaInputButtonCur, BTN_R) && + (sRecordingState != OCARINA_RECORD_SCARECROW_SPAWN)) { + sCurOcarinaButtonIndex += OCARINA_BUTTON_FLAG_BFLAT_RAISE; // Flag to resolve B Flat 4 + sCurOcarinaPitch++; // Raise the pitch by 1 semitone + } + + // Pressing the Z Button will lower the pitch by 1 semitone + if ((sCurOcarinaPitch != OCARINA_PITCH_NONE) && CHECK_BTN_ANY(sOcarinaInputButtonCur, BTN_Z) && + (sRecordingState != OCARINA_RECORD_SCARECROW_SPAWN)) { + sCurOcarinaButtonIndex += OCARINA_BUTTON_FLAG_BFLAT_LOWER; // Flag to resolve B Flat 4 + sCurOcarinaPitch--; // Lower the pitch by 1 semitone + } + + if (sRecordingState != OCARINA_RECORD_SCARECROW_SPAWN) { + // Bend the pitch of the note based on y control stick + sCurOcarinaBendIndex = sOcarinaInputStickRel.y; + sCurOcarinaBendFreq = AudioOcarina_BendPitchTwoSemitones(sCurOcarinaBendIndex); + + // Add vibrato of the ocarina note based on the x control stick + sCurOcarinaVibrato = ABS_ALT(sOcarinaInputStickRel.x) >> 2; + // Sets vibrato to io port 6 + AudioThread_QueueCmdS8(0x6 << 24 | SEQ_PLAYER_SFX << 16 | SFX_CHANNEL_OCARINA << 8 | 6, sCurOcarinaVibrato); + } else { + // no bending or vibrato for recording state OCARINA_RECORD_SCARECROW_SPAWN + sCurOcarinaBendIndex = 0; + sCurOcarinaVibrato = 0; + sCurOcarinaBendFreq = 1.0f; // No bend + } + + // Processes new and valid notes + if ((sCurOcarinaPitch != OCARINA_PITCH_NONE) && (sPrevOcarinaPitch != sCurOcarinaPitch)) { + // Sets ocarina instrument Id to io port 7, which is used + // as an index in seq 0 to get the true instrument Id + AudioThread_QueueCmdS8(0x6 << 24 | SEQ_PLAYER_SFX << 16 | SFX_CHANNEL_OCARINA << 8 | 7, + sOcarinaInstrumentId - 1); + // Sets pitch to io port 5 + AudioThread_QueueCmdS8(0x6 << 24 | SEQ_PLAYER_SFX << 16 | SFX_CHANNEL_OCARINA << 8 | 5, sCurOcarinaPitch); + AudioSfx_PlaySfx(NA_SE_OC_OCARINA, &gSfxDefaultPos, 4, &sCurOcarinaBendFreq, &sDefaultOcarinaVolume, + &gSfxDefaultReverb); + } else if ((sPrevOcarinaPitch != OCARINA_PITCH_NONE) && (sCurOcarinaPitch == OCARINA_PITCH_NONE) && + !isOcarinaSfxSuppressedWhenCancelled) { + // Stops ocarina sound when transitioning from playing to not playing a note + AudioSfx_StopById(NA_SE_OC_OCARINA); + } + } +} + +/** + * Directly enable the ocarina to receive input without + * properly resetting it based on an ocarina instrument id + * Unused. + */ +void AudioOcarina_EnableInput(u8 inputEnabled) { + sIsOcarinaInputEnabled = inputEnabled; +} + +/** + * Resets ocarina properties + */ +void AudioOcarina_ResetAndMute(void) { + sOcarinaInputButtonCur = 0; + sOcarinaInputButtonPrev = 0; + sOcarinaInputButtonPress = 0; + + sOcarinaInputButtonStart = 0xFFFF; + + AudioOcarina_PlayControllerInput(false); + AudioSfx_StopById(NA_SE_OC_OCARINA); + + if (gAudioSpecId != 12) { + AudioSfx_MuteBanks(0); + } + + sPlaybackState = 0; + sPlaybackStaffPos = 0; + sIsOcarinaInputEnabled = false; + + sOcarinaFlags = 0; + + // return to full volume for both bgm players after ocarina is finished + AudioSfx_RestoreBgmVolume(SFX_CHANNEL_OCARINA); + // return to full volume for all sfx channels except system & ocarina banks + Audio_SetSfxVolumeExceptSystemAndOcarinaBanks(0x7F); +} + +void AudioOcarina_ResetAndReadInput(void) { + sOcarinaInputButtonCur = 0; + sOcarinaInputButtonPrev = 0; + sOcarinaInputButtonPress = 0; + + sOcarinaInputButtonStart = 0xFFFF; + + AudioOcarina_PlayControllerInput(true); + + sPlaybackState = 0; + sPlaybackStaffPos = 0; + sIsOcarinaInputEnabled = false; + + sOcarinaFlags = 0; + + sOcarinaInputButtonCur = 0; + + AudioOcarina_ReadControllerInput(); + sOcarinaInputButtonStart = sOcarinaInputButtonCur; +} + +/** + * Set a timer that will disable the ocarina once the timer reaches 0 + */ +void AudioOcarina_SetOcarinaDisableTimer(u8 unused, u8 timer) { + sOcarinaDisableTimer = timer; + sOcarinaUnused = unused; +} + +u32 AudioOcarina_SetInstrument(u8 ocarinaInstrumentId) { + if ((sOcarinaInstrumentId != ocarinaInstrumentId) || (ocarinaInstrumentId == OCARINA_INSTRUMENT_DEFAULT)) { + Audio_QueueSeqCmd(0x80000000 | ((u32)(SEQ_PLAYER_SFX) << 24) | ((u32)(1) << 16) | + ((u32)(SFX_CHANNEL_OCARINA) << 8) | (u32)(ocarinaInstrumentId)); + sOcarinaInstrumentId = ocarinaInstrumentId; + + if (ocarinaInstrumentId == OCARINA_INSTRUMENT_OFF) { + AudioOcarina_ResetAndMute(); + } else { + sOcarinaInputButtonCur = 0; + AudioOcarina_ReadControllerInput(); + sOcarinaInputButtonStart = sOcarinaInputButtonCur; + // lowers volume of all sfx channels except system & ocarina banks + Audio_SetSfxVolumeExceptSystemAndOcarinaBanks(0x40); + // lowers volume of bgm players while playing ocarina + AudioSfx_LowerBgmVolume(SFX_CHANNEL_OCARINA); + } + } +} + +void AudioOcarina_SetPlaybackSong(s8 songIndexPlusOne, u8 playbackState) { + u8 i = 0; + + if (songIndexPlusOne == 0) { + sPlaybackState = 0; + AudioSfx_StopById(NA_SE_OC_OCARINA); + return; + } + + if (songIndexPlusOne < (OCARINA_SONG_MAX + 1)) { + sPlaybackSong = sOcarinaSongNotes[songIndexPlusOne - 1]; + } else { + sPlaybackSong = sScarecrowsLongSongNotes; + } + + sPlaybackNotePos = 0; + if (playbackState & 0x80) { + sPlaybackState = 1; + sPlaybackStaffStopPos = playbackState & 0xF; + sPlaybackStaffStartPos = 0xFF; + } else if (playbackState & 0x40) { + sPlaybackState = 1; + sPlaybackStaffStartPos = playbackState & 0xF; + sPlaybackStaffStopPos = 0xFF; + while (i < sPlaybackStaffStartPos) { + if (sOcarinaSongNotes[songIndexPlusOne - 1][sPlaybackNotePos].pitch != OCARINA_PITCH_NONE) { + i++; + } + sPlaybackNotePos++; + } + } else { + sPlaybackState = playbackState; + sPlaybackStaffStopPos = 0xFF; + sPlaybackStaffStartPos = 0xFF; + } + + sPlaybackNoteTimer = 0; + sPlaybackPitch = OCARINA_PITCH_NONE; + sPlaybackStaffPos = 0; + + if (sPlaybackStaffStartPos == 0xFF) { + while ((sPlaybackSong[sPlaybackNotePos].pitch == OCARINA_PITCH_NONE) && + (songIndexPlusOne > (OCARINA_SONG_EVAN_PART2 + 1))) { + sPlaybackNotePos++; + } + } +} + +/** + * Play a song with the ocarina to the user that is + * based on OcarinaNote data and not user input + */ +void AudioOcarina_PlaybackSong(void) { + s32 noteTimerStep; + s32 nextNoteTimerStep; + + if (sPlaybackState == 0) { + return; + } + + if (sPlaybackStaffPos == 0) { + noteTimerStep = 3; + } else { + noteTimerStep = sOcarinaUpdateTaskStart - sOcarinaPlaybackTaskStart; + } + + if (noteTimerStep < sPlaybackNoteTimer) { + sPlaybackNoteTimer -= noteTimerStep; + } else { + nextNoteTimerStep = noteTimerStep - sPlaybackNoteTimer; + sPlaybackNoteTimer = 0; + } + + if (sPlaybackNoteTimer == 0) { + + if (sPlaybackStaffPos == sPlaybackStaffStopPos) { + sPlaybackState = 0; + return; + } + + sPlaybackNoteTimer = sPlaybackSong[sPlaybackNotePos].length; + + if (sPlaybackNotePos == 1) { + sPlaybackNoteTimer++; + } + + if (sPlaybackNoteTimer == 0) { + sPlaybackState--; + if (sPlaybackState != 0) { + sPlaybackNotePos = 0; + sPlaybackStaffPos = 0; + sPlaybackPitch = OCARINA_PITCH_NONE; + } else { + AudioSfx_StopById(NA_SE_OC_OCARINA); + } + return; + } else { + sPlaybackNoteTimer -= nextNoteTimerStep; + } + + // Update volume + if (sNotePlaybackVolume != sPlaybackSong[sPlaybackNotePos].volume) { + sNotePlaybackVolume = sPlaybackSong[sPlaybackNotePos].volume; + sRelativeNotePlaybackVolume = sNotePlaybackVolume / 127.0f; + } + + // Update vibrato + sNotePlaybackVibrato = sPlaybackSong[sPlaybackNotePos].vibrato; + // Sets vibrato to io port 6 + AudioThread_QueueCmdS8(0x6 << 24 | SEQ_PLAYER_SFX << 16 | SFX_CHANNEL_OCARINA << 8 | 6, sNotePlaybackVibrato); + + // Update bend + if (sNotePlaybackBend != sPlaybackSong[sPlaybackNotePos].bend) { + sNotePlaybackBend = sPlaybackSong[sPlaybackNotePos].bend; + sRelativeNotePlaybackBend = AudioOcarina_BendPitchTwoSemitones(sNotePlaybackBend); + } + + // No changes in volume, vibrato, or bend between notes + if ((sPlaybackSong[sPlaybackNotePos].volume == sPlaybackSong[sPlaybackNotePos - 1].volume && + (sPlaybackSong[sPlaybackNotePos].vibrato == sPlaybackSong[sPlaybackNotePos - 1].vibrato) && + (sPlaybackSong[sPlaybackNotePos].bend == sPlaybackSong[sPlaybackNotePos - 1].bend))) { + sPlaybackPitch = 0xFE; + } + + if (sPlaybackPitch != sPlaybackSong[sPlaybackNotePos].pitch) { + u8 pitch = sPlaybackSong[sPlaybackNotePos].pitch; + + // As bFlat4 is exactly in the middle of notes B & A, a flag is + // added to the pitch to resolve which button to map Bflat4 to + if (pitch == OCARINA_PITCH_BFLAT4) { + sPlaybackPitch = pitch + sPlaybackSong[sPlaybackNotePos].bFlat4Flag; + } else { + sPlaybackPitch = pitch; + } + + if (sPlaybackPitch != OCARINA_PITCH_NONE) { + sPlaybackStaffPos++; + // Sets ocarina instrument Id to io port 7, which is used + // as an index in seq 0 to get the true instrument Id + AudioThread_QueueCmdS8(0x6 << 24 | SEQ_PLAYER_SFX << 16 | SFX_CHANNEL_OCARINA << 8 | 7, + sOcarinaInstrumentId - 1); + AudioThread_QueueCmdS8(0x6 << 24 | SEQ_PLAYER_SFX << 16 | SFX_CHANNEL_OCARINA << 8 | 5, + sPlaybackPitch & OCARINA_BUTTON_MASK_PITCH); + AudioSfx_PlaySfx(NA_SE_OC_OCARINA, &gSfxDefaultPos, 4, &sRelativeNotePlaybackBend, + &sRelativeNotePlaybackVolume, &gSfxDefaultReverb); + } else { + AudioSfx_StopById(NA_SE_OC_OCARINA); + } + } + sPlaybackNotePos++; + } +} + +void AudioOcarina_SetRecordingSong(u8 isRecordingComplete) { + u16 i; + u16 i2; + u16 pad; + u8 pitch; + OcarinaNote* note; + u8 j; + u8 k; + s32 t; + OcarinaNote* recordedSong; + + if (sRecordingState == OCARINA_RECORD_SCARECROW_LONG) { + recordedSong = gScarecrowLongSongPtr; + } else { + /** + * OCARINA_RECORD_SCARECROW_SPAWN + * + * The notes for scarecrows spawn song are first recorded into the ocarina termina + * wall address to act as a buffer. That way, if a new scarecrow spawn song is + * rejected, the previous scarecrow spawn song is not overwritten. If the scarecrow + * spawn song is accepted, then the notes are copied over to the scarecrow spawn + * song address + */ + recordedSong = sTerminaWallSongPtr; + } + + recordedSong[sRecordSongPos].pitch = sRecordOcarinaPitch; + recordedSong[sRecordSongPos].length = sOcarinaUpdateTaskStart - sOcarinaRecordTaskStart; + recordedSong[sRecordSongPos].volume = sRecordOcarinaVolume; + recordedSong[sRecordSongPos].vibrato = sRecordOcarinaVibrato; + recordedSong[sRecordSongPos].bend = sRecordOcarinaBendIndex; + recordedSong[sRecordSongPos].bFlat4Flag = sRecordOcarinaButtonIndex & OCARINA_BUTTON_MASK_FLAG; + + sRecordOcarinaPitch = sCurOcarinaPitch; + sRecordOcarinaVolume = sCurOcarinaVolume; + sRecordOcarinaVibrato = sCurOcarinaVibrato; + sRecordOcarinaBendIndex = sCurOcarinaBendIndex; + sRecordOcarinaButtonIndex = sCurOcarinaButtonIndex; + + sRecordSongPos++; + + if ((sRecordSongPos != (ARRAY_COUNT(sScarecrowsLongSongNotes) - 1)) && !isRecordingComplete) { + // Continue recording + return; + } + + // Recording is complete + + i = sRecordSongPos; + pitch = OCARINA_PITCH_NONE; + while (i != 0 && pitch == OCARINA_PITCH_NONE) { + i--; + pitch = recordedSong[i].pitch; + } + + if (sRecordSongPos != (i + 1)) { + sRecordSongPos = i + 2; + recordedSong[sRecordSongPos - 1].length = 0; + } + + recordedSong[sRecordSongPos].length = 0; + + if (sRecordingState == OCARINA_RECORD_SCARECROW_SPAWN) { + if (sOcarinaStaffPlayingPos >= 8) { + for (i = 0; i < sRecordSongPos; i++) { + recordedSong[i] = recordedSong[i + 1]; + } + + // Copies Notes from buffer into scarecrows spawn buttons to be tested for acceptance or rejection + AudioOcarina_MapSongFromPitchToButton(OCARINA_SONG_TERMINA_WALL, OCARINA_SONG_SCARECROW_SPAWN, 8); + + // Tests to see if the notes from the scarecrow song contain identical + // notes within its song to any of the reserved songIndex from 0 to 21 + + // Loop through each of the songs + for (i = 0; i < OCARINA_SONG_SCARECROW_SPAWN; i++) { + // Checks to see if the song is reserved + if (sIsOcarinaSongReserved[i]) { + // Loops through all possible starting indices + for (j = 0; (j < 9 - gOcarinaSongButtons[i].numButtons); j++) { + // Loops through the notes of the song + for (k = 0; (k < gOcarinaSongButtons[i].numButtons) && (k + j < 8) && + (gOcarinaSongButtons[i].buttonIndex[k] == + gOcarinaSongButtons[OCARINA_SONG_SCARECROW_SPAWN].buttonIndex[k + j]); + k++) { + ; + } + + // This conditional is true if the recorded song contains a reserved song + // recorded song is cancelled + if (k == gOcarinaSongButtons[i].numButtons) { + sRecordingState = OCARINA_RECORD_REJECTED; + sOcarinaSongNotes[OCARINA_SONG_SCARECROW_SPAWN][1].volume = 0xFF; + return; + } + } + } + } + + // Counts how many times a note is repeated + i = 1; + while (i < 8) { + if (gOcarinaSongButtons[OCARINA_SONG_SCARECROW_SPAWN].buttonIndex[0] != + gOcarinaSongButtons[OCARINA_SONG_SCARECROW_SPAWN].buttonIndex[i]) { + i = 9; // break + } else { + i++; + } + } + + // This condition is true if all 8 notes are the same pitch + if (i == 8) { + sRecordingState = OCARINA_RECORD_REJECTED; + sOcarinaSongNotes[OCARINA_SONG_SCARECROW_SPAWN][1].volume = 0xFF; + return; + } + + // The scarecrow spawn song is accepted and copied from the buffer to the scarecrow spawn notes + for (i = 0; i < sRecordSongPos; i++) { + sOcarinaSongNotes[OCARINA_SONG_SCARECROW_SPAWN][i] = sOcarinaSongNotes[OCARINA_SONG_TERMINA_WALL][i]; + } + + sIsOcarinaInputEnabled = false; + } else { + sOcarinaSongNotes[OCARINA_SONG_SCARECROW_SPAWN][1].volume = 0xFF; + } + } + + sRecordingState = OCARINA_RECORD_OFF; +} + +/** + * recordingState = OCARINA_RECORD_OFF, end + * recordingState = OCARINA_RECORD_SCARECROW_LONG, start long scarecrows song + * recordingState = OCARINA_RECORD_SCARECROW_SPAWN, start spawn scarecrows song + */ +void AudioOcarina_SetRecordingState(u8 recordingState) { + if ((u32)recordingState == sRecordingState) { + return; + } + + if (recordingState != OCARINA_RECORD_OFF) { + sOcarinaRecordTaskStart = sOcarinaUpdateTaskStart; + sRecordOcarinaPitch = OCARINA_PITCH_NONE; + sRecordOcarinaVolume = 0x57; + sRecordOcarinaVibrato = 0; + sRecordOcarinaBendIndex = 0; + sRecordOcarinaButtonIndex = 0; + sRecordSongPos = 0; + sIsOcarinaInputEnabled = true; + sOcarinaStaffPlayingPos = 0; + sScarecrowsLongSongSecondNote = sScarecrowsLongSongNotes[1]; + } else { + if (sRecordSongPos == 0) { + sScarecrowsLongSongNotes[1] = sScarecrowsLongSongSecondNote; + } else { + if (sRecordingState == OCARINA_RECORD_SCARECROW_SPAWN) { + sOcarinaStaffPlayingPos = 1; + } + + AudioOcarina_SetRecordingSong(true); + } + + sIsOcarinaInputEnabled = false; + sOcarinaStaffPlayingPos = 0; + } + + sRecordingState = recordingState; +} + +void AudioOcarina_UpdateRecordingStaff(void) { + sRecordingStaff.state = sRecordingState; + sRecordingStaff.pos = sOcarinaStaffPlayingPos; + if (sRecordingState == OCARINA_RECORD_REJECTED) { + sRecordingState = OCARINA_RECORD_OFF; + } +} + +void AudioOcarina_UpdatePlayingStaff(void) { + if (sCurOcarinaButtonIndex != OCARINA_BTN_INVALID) { + sPlayingStaff.buttonIndex = sCurOcarinaButtonIndex & OCARINA_BUTTON_MASK_PITCH; + } + sPlayingStaff.state = AudioOcarina_GetPlayingState(); + sPlayingStaff.pos = sOcarinaStaffPlayingPos; +} + +void AudioOcarina_UpdatePlaybackStaff(void) { + if ((sPlaybackPitch & OCARINA_BUTTON_MASK_PITCH) <= OCARINA_PITCH_EFLAT5) { + sPlaybackStaff.buttonIndex = AudioOcarina_MapPitchToButton(sPlaybackPitch); + } + + sPlaybackStaff.state = sPlaybackState; + + if (sPlaybackSong != sScarecrowsLongSongNotes) { + sPlaybackStaff.pos = sPlaybackStaffPos; + } else if (sPlaybackStaffPos == 0) { + sPlaybackStaff.pos = 0; + } else { + sPlaybackStaff.pos = ((sPlaybackStaffPos - 1) % 8) + 1; + } +} + +OcarinaStaff* AudioOcarina_GetRecordingStaff(void) { + return &sRecordingStaff; +} + +OcarinaStaff* AudioOcarina_GetPlayingStaff(void) { + if (sPlayingStaff.state < 0xFE) { + sOcarinaFlags = 0; + } + + return &sPlayingStaff; +} + +OcarinaStaff* AudioOcarina_GetPlaybackStaff(void) { + return &sPlaybackStaff; +} + +void AudioOcarina_RecordSong(void) { + s32 noteChanged; + + if ((sRecordingState != OCARINA_RECORD_OFF) && ((sOcarinaUpdateTaskStart - sOcarinaRecordTaskStart) >= 3)) { + noteChanged = false; + if (sRecordOcarinaPitch != sCurOcarinaPitch) { + if (sCurOcarinaPitch != OCARINA_PITCH_NONE) { + sRecordingStaff.buttonIndex = sCurOcarinaButtonIndex & OCARINA_BUTTON_MASK_PITCH; + sOcarinaStaffPlayingPos++; + } else if ((sRecordingState == OCARINA_RECORD_SCARECROW_SPAWN) && (sOcarinaStaffPlayingPos == 8)) { + AudioOcarina_SetRecordingSong(true); + return; + } + + if (sOcarinaStaffPlayingPos > 8) { + if (sRecordingState == OCARINA_RECORD_SCARECROW_SPAWN) { + // notes played are over 8 and in recording mode. + AudioOcarina_SetRecordingSong(true); + return; + } + sOcarinaStaffPlayingPos = 1; + } + noteChanged = true; + } else if (sRecordOcarinaVolume != sCurOcarinaVolume) { + noteChanged = true; + } else if (sRecordOcarinaVibrato != sCurOcarinaVibrato) { + if (sRecordingState != OCARINA_RECORD_SCARECROW_SPAWN) { + noteChanged = true; + } + } else if ((sRecordOcarinaBendIndex != sCurOcarinaBendIndex) && + (sRecordingState != OCARINA_RECORD_SCARECROW_SPAWN)) { + noteChanged = true; + } + + if (noteChanged) { + AudioOcarina_SetRecordingSong(false); + sOcarinaRecordTaskStart = sOcarinaUpdateTaskStart; + } + } +} /** * Tests to see if the notes from songIndex contain identical notes @@ -2007,7 +3065,7 @@ s32 AudioOcarina_TerminaWallValidateNotes(u8 songIndex, u8 maxSongIndex) { */ void AudioOcarina_TerminaWallGenerateNotes(void) { OcarinaNote* ocarinaNote; - u8 randButtonIndex; + u8 randomButtonIndex; u8 i; u8 j; @@ -2017,8 +3075,8 @@ void AudioOcarina_TerminaWallGenerateNotes(void) { j = 0; for (; i < 8; i++) { - randButtonIndex = Audio_NextRandom() % ARRAY_COUNT(sButtonToPitchMap); - sOcarinaSongNotes[OCARINA_SONG_TERMINA_WALL][j].pitch = sButtonToPitchMap[randButtonIndex]; + randomButtonIndex = AudioThread_NextRandom() % ARRAY_COUNT(sButtonToPitchMap); + sOcarinaSongNotes[OCARINA_SONG_TERMINA_WALL][j].pitch = sButtonToPitchMap[randomButtonIndex]; sOcarinaSongNotes[OCARINA_SONG_TERMINA_WALL][j].length = 19; sOcarinaSongNotes[OCARINA_SONG_TERMINA_WALL][j].volume = 80; sOcarinaSongNotes[OCARINA_SONG_TERMINA_WALL][j].vibrato = 0; @@ -2036,9 +3094,9 @@ void AudioOcarina_TerminaWallGenerateNotes(void) { 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); + AudioOcarina_MapSongFromPitchToButton(OCARINA_SONG_TERMINA_WALL, OCARINA_SONG_TERMINA_WALL, 8); } else { - j = Audio_NextRandom() % ARRAY_COUNT(sOoTOcarinaSongNotes); + j = AudioThread_NextRandom() % ARRAY_COUNT(sOoTOcarinaSongNotes); ocarinaNote = sOoTOcarinaSongNotes[j]; for (; ocarinaNote[i].length != 0; i++) { @@ -2047,8 +3105,8 @@ void AudioOcarina_TerminaWallGenerateNotes(void) { 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]); + AudioOcarina_MapSongFromPitchToButton(OCARINA_SONG_TERMINA_WALL, OCARINA_SONG_TERMINA_WALL, + sOoTOcarinaSongsNumNotes[j]); } } while (AudioOcarina_TerminaWallValidateNotes(OCARINA_SONG_TERMINA_WALL, OCARINA_SONG_TERMINA_WALL) != 0); } @@ -2056,7 +3114,7 @@ void AudioOcarina_TerminaWallGenerateNotes(void) { /** * Unused remnant of OoT */ -void AudioOcarina_MemoryGameSetNumNotes(u8 minigameRound) { +void AudioOcarina_MemoryGameInit(u8 minigameRound) { u8 i; if (minigameRound > 2) { @@ -2064,10 +3122,10 @@ void AudioOcarina_MemoryGameSetNumNotes(u8 minigameRound) { } sOcarinaMemoryGameAppendPos = 0; - sOcaMemoryGameEndPos = sOcaMemoryGameNumNotes[minigameRound]; + sOcarinaMemoryGameEndPos = sOcarinaMemoryGameNumNotes[minigameRound]; for (i = 0; i < 3; i++) { - AudioOcarina_MemoryGameGenerateNotes(); + AudioOcarina_MemoryGameNextNote(); } } @@ -2075,52 +3133,349 @@ void AudioOcarina_MemoryGameSetNumNotes(u8 minigameRound) { * 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; +#define OCARINA_SONG_MEMORY_GAME 14 +s32 AudioOcarina_MemoryGameNextNote(void) { + u32 randomButtonIndex; + u8 randomPitch; - if (sOcarinaMemoryGameAppendPos == sOcaMemoryGameEndPos) { + if (sOcarinaMemoryGameAppendPos == sOcarinaMemoryGameEndPos) { return true; } - randButtonIndex = Audio_NextRandom(); - randPitch = sButtonToPitchMap[randButtonIndex % ARRAY_COUNT(sButtonToPitchMap)]; + randomButtonIndex = AudioThread_NextRandom(); + randomPitch = sButtonToPitchMap[randomButtonIndex % ARRAY_COUNT(sButtonToPitchMap)]; - if (sOcarinaSongNotes[OCARINA_SONG_MEMORYGAME][sOcarinaMemoryGameAppendPos - 1].pitch == randPitch) { - randPitch = sButtonToPitchMap[(randButtonIndex + 1) % ARRAY_COUNT(sButtonToPitchMap)]; + if (sOcarinaSongNotes[OCARINA_SONG_MEMORY_GAME][sOcarinaMemoryGameAppendPos - 1].pitch == randomPitch) { + randomPitch = sButtonToPitchMap[(randomButtonIndex + 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; + sOcarinaSongNotes[OCARINA_SONG_MEMORY_GAME][sOcarinaMemoryGameAppendPos].pitch = randomPitch; + sOcarinaSongNotes[OCARINA_SONG_MEMORY_GAME][sOcarinaMemoryGameAppendPos].length = 45; + sOcarinaSongNotes[OCARINA_SONG_MEMORY_GAME][sOcarinaMemoryGameAppendPos].volume = 0x50; + sOcarinaSongNotes[OCARINA_SONG_MEMORY_GAME][sOcarinaMemoryGameAppendPos].vibrato = 0; + sOcarinaSongNotes[OCARINA_SONG_MEMORY_GAME][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; + sOcarinaSongNotes[OCARINA_SONG_MEMORY_GAME][sOcarinaMemoryGameAppendPos].pitch = OCARINA_PITCH_NONE; + sOcarinaSongNotes[OCARINA_SONG_MEMORY_GAME][sOcarinaMemoryGameAppendPos].length = 0; + sOcarinaSongNotes[OCARINA_SONG_MEMORY_GAME][sOcarinaMemoryGameAppendPos + 1].pitch = OCARINA_PITCH_NONE; + sOcarinaSongNotes[OCARINA_SONG_MEMORY_GAME][sOcarinaMemoryGameAppendPos + 1].length = 0; if (1) {} return false; } -#undef OCARINA_SONG_MEMORYGAME +#undef OCARINA_SONG_MEMORY_GAME -#pragma GLOBAL_ASM("asm/non_matchings/code/code_8019AF00/func_8019D600.s") +void AudioOcarina_Update(void) { + sOcarinaUpdateTaskStart = gAudioContext.totalTaskCount; + if (sOcarinaInstrumentId != OCARINA_INSTRUMENT_OFF) { + if (sIsOcarinaInputEnabled == true) { + AudioOcarina_ReadControllerInput(); + } -#pragma GLOBAL_ASM("asm/non_matchings/code/code_8019AF00/func_8019D758.s") + if ((sPlaybackState == 0) && (sIsOcarinaInputEnabled == true)) { + AudioOcarina_PlayControllerInput(false); + } -#pragma GLOBAL_ASM("asm/non_matchings/code/code_8019AF00/func_8019D864.s") + if (sOcarinaFlags != 0) { + if (sOcarinaFlags & 0x40000000) { + AudioOcarina_CheckSongsWithoutMusicStaff(); + } else { + AudioOcarina_CheckSongsWithMusicStaff(); + } + } -#pragma GLOBAL_ASM("asm/non_matchings/code/code_8019AF00/func_8019D8B4.s") + AudioOcarina_PlaybackSong(); + sOcarinaPlaybackTaskStart = sOcarinaUpdateTaskStart; -#pragma GLOBAL_ASM("asm/non_matchings/code/code_8019AF00/func_8019D8E4.s") + if (sPlaybackState == 0) { + AudioOcarina_RecordSong(); + } -#pragma GLOBAL_ASM("asm/non_matchings/code/code_8019AF00/func_8019DF28.s") + if ((sOcarinaFlags != 0) && (sPrevOcarinaPitch != sCurOcarinaPitch)) { + sOcarinaDropInputTimer = 1; // Drops ocarina input for 1 frame + } -#pragma GLOBAL_ASM("asm/non_matchings/code/code_8019AF00/func_8019DF64.s") + sPrevOcarinaPitch = sCurOcarinaPitch; + + if (sOcarinaDisableTimer != 0) { + sOcarinaDisableTimer--; + if (sOcarinaDisableTimer == 0) { + AudioOcarina_SetInstrument(OCARINA_INSTRUMENT_OFF); + } + } + } + + AudioOcarina_UpdatePlayingStaff(); + AudioOcarina_UpdatePlaybackStaff(); + AudioOcarina_UpdateRecordingStaff(); +} + +#define OCARINA_INSTRUMENT_OOT_MAX 7 + +void AudioOcarina_PlayLongScarecrowAfterCredits(void) { + static u8 sScarecrowAfterCreditsState = 0; + static u8 sScarecrowAfterCreditsIntrumentId = OCARINA_INSTRUMENT_DEFAULT; + static u16 sScarecrowAfterCreditsTimer = 1200; + + switch (sScarecrowAfterCreditsState) { + case 0: + if (sScarecrowAfterCreditsTimer-- == 0) { + // OoT originally had 7 Ocarina instruments + // MM has more so this does not go all the way to the max + if (sScarecrowAfterCreditsIntrumentId < OCARINA_INSTRUMENT_OOT_MAX) { + // set next ocarina instrument and restart + sScarecrowAfterCreditsState++; + } else { + // finished + sScarecrowAfterCreditsState = 3; + AudioOcarina_SetInstrument(OCARINA_INSTRUMENT_OFF); + } + sScarecrowAfterCreditsTimer = 1200; + } + break; + + case 1: + AudioSfx_MuteBanks(0); + AudioOcarina_SetInstrument(sScarecrowAfterCreditsIntrumentId); + AudioOcarina_SetPlaybackSong(OCARINA_SONG_SCARECROW_LONG + 1, 1); + sScarecrowAfterCreditsIntrumentId++; + sScarecrowAfterCreditsState++; + break; + + case 2: + if (AudioOcarina_GetPlaybackStaff()->state == 0) { + sScarecrowAfterCreditsState = 0; + } + break; + } +} + +u8 sRequestCustomSequence = false; + +void AudioOcarina_SetCustomSequence(void) { + // Never passes true as sRequestCustomSequence is never set true + if (sRequestCustomSequence && gAudioContext.seqPlayers[SEQ_PLAYER_FANFARE].enabled && + ((u8)gAudioContext.seqPlayers[SEQ_PLAYER_FANFARE].soundScriptIO[0] == 0xFF)) { + gAudioContext.seqPlayers[SEQ_PLAYER_FANFARE].seqData = sCustomSequenceScript; + sRequestCustomSequence = false; + } +} + +// Called by unused function +void AudioOcarina_PlayCustomSequence(void) { + sRequestCustomSequence = true; + Audio_QueueSeqCmd(0x00000000 | ((u32)(SEQ_PLAYER_FANFARE) << 24) | ((u32)(0) << 0x10) | + (u32)(NA_BGM_DUNGEON_APPEAR)); +} + +// Unused +// Regalloc Swap https://decomp.me/scratch/QEovr +#ifdef NON_MATCHING +s32 AudioOcarina_CreateCustomSequence(void) { + OcarinaNote* prevNote; + u16 i; + u16 phi_s4; + u16 temp_a0; // delay1 + u16 phi_a2; // delay2 + u8 absPitch; + s8 phi_a0; // adjBendIndex + s8 phi_s2; // prevBend + u8 phi_t1; // vibrato + u8 phi_t5; // isLegato + u16 temp_t4; // prevNoteLength + + phi_a2 = 0; + phi_t1 = 0; + phi_s2 = 0; + phi_t5 = 0; + phi_s4 = 0; + + sCustomSequencePc = 39; // .channel chan_loop + + prevNote = &sScarecrowsLongSongNotes[0]; + for (i = 1; ((prevNote->pitch == OCARINA_PITCH_NONE) && (prevNote->length != 0)); i++) { + prevNote = &sScarecrowsLongSongNotes[i]; + } + + for (; (prevNote->length != 0) && (sCustomSequencePc < 394); i++) { + + temp_a0 = ((prevNote->length * 48) / 30); + + if (phi_t1 != prevNote->vibrato) { + sCustomSequenceScript[sCustomSequencePc++] = 0xFD; // delay cmd + + if (phi_a2 >= 0x80) { + // Store as compressed u16 + sCustomSequenceScript[sCustomSequencePc++] = (((phi_a2 >> 8) & 0xFF) & 0x7F) + 0x80; // delay arg + sCustomSequenceScript[sCustomSequencePc++] = phi_a2 & 0xFF; // delay arg + } else { + // Store as u8 + sCustomSequenceScript[sCustomSequencePc++] = phi_a2; // delay arg + } + + sCustomSequenceScript[sCustomSequencePc++] = 0xD8; // vibdepth cmd + sCustomSequenceScript[sCustomSequencePc++] = prevNote->vibrato; // vibdepth arg + + phi_a2 = temp_a0; + phi_t1 = prevNote->vibrato; + } else { + phi_a2 += temp_a0; + } + + prevNote = &sScarecrowsLongSongNotes[i]; + } + + if (phi_a2 != 0) { + sCustomSequenceScript[sCustomSequencePc++] = 0xFD; // delay cmd + if (phi_a2 >= 0x80) { + // Store as compressed u16 + sCustomSequenceScript[sCustomSequencePc++] = (((phi_a2 >> 8) & 0xFF) & 0x7F) + 0x80; // delay arg + sCustomSequenceScript[sCustomSequencePc++] = phi_a2 & 0xFF; // delay arg + } else { + // Store as u8 + sCustomSequenceScript[sCustomSequencePc++] = phi_a2; // delay arg + } + } + + sCustomSequenceScript[sCustomSequencePc++] = 0xFF; // end cmd + + // ldlayer 0, layer0 + sCustomSequenceScript[24] = sCustomSequencePc >> 8; + sCustomSequenceScript[25] = sCustomSequencePc & 0xFF; + + // ldlayer 1, layer1 + sCustomSequenceScript[27] = (sCustomSequencePc + 4) >> 8; + sCustomSequenceScript[28] = (sCustomSequencePc + 4) & 0xFF; + + sCustomSequenceScript[sCustomSequencePc++] = 0xC2; // transpose cmd + sCustomSequenceScript[sCustomSequencePc++] = -5; // transpose arg + + sCustomSequenceScript[sCustomSequencePc++] = 0xC0; // ldelay cmd + sCustomSequenceScript[sCustomSequencePc++] = 8; // ldelay arg + + sCustomSequenceScript[sCustomSequencePc++] = 0xC1; // shortvel cmd + sCustomSequenceScript[sCustomSequencePc++] = 87; // shortvel arg + + sCustomSequenceScript[sCustomSequencePc++] = 0xC9; // shortgate cmd + sCustomSequenceScript[sCustomSequencePc++] = 0; // shortgate arg + + if (1) {} + if (1) {} // TODO: Needed? + + prevNote = &sScarecrowsLongSongNotes[0]; + + for (i = 1; ((prevNote->pitch == OCARINA_PITCH_NONE) && (prevNote->length != 0)); i++) { + prevNote = &sScarecrowsLongSongNotes[i]; + } + + for (; ((temp_t4 = prevNote->length) != 0) && (sCustomSequencePc < 394); i++) { + + if (prevNote->pitch == sScarecrowsLongSongNotes[i].pitch) { + if ((sScarecrowsLongSongNotes[i].length != 0) && (phi_t5 == 0)) { + sCustomSequenceScript[sCustomSequencePc++] = 0xC4; // legato cmd + phi_t5 = 1; + } + } else if ((phi_t5 == 1) && (sScarecrowsLongSongNotes[i].pitch != OCARINA_PITCH_NONE) && + (sScarecrowsLongSongNotes[i].pitch != OCARINA_PITCH_C4)) { + sCustomSequenceScript[sCustomSequencePc++] = 0xC5; // nolegato cmd + phi_t5 = 0; + } + + if (phi_s2 != prevNote->bend) { + sCustomSequenceScript[sCustomSequencePc++] = 0xCE; // bendfine cmd + + if (ABS_ALT(prevNote->bend) > 64) { + phi_a0 = 127; + } else if (prevNote->bend < 0) { + phi_a0 = -prevNote->bend; + } else { + phi_a0 = ((prevNote->bend * 127) / 64); + } + + if (prevNote->bend < 0) { + phi_a0 *= -1; + } + + sCustomSequenceScript[sCustomSequencePc++] = phi_a0; // bendfine arg + + phi_s2 = prevNote->bend; + } + + absPitch = prevNote->pitch + 39; // convert ocarina pitch to absolute pitch, + PITCH_C4 (Middle C) + if (prevNote->pitch != OCARINA_PITCH_NONE) { + sCustomSequenceScript[sCustomSequencePc++] = absPitch; // shortdvg cmd, shortdvg arg + } else { + sCustomSequenceScript[sCustomSequencePc++] = 0xC0; // ldelay cmd + } + + // delay/duration + temp_a0 = ((temp_t4 * 48) + phi_s4) / 30; + + if (temp_a0 < 0x80) { + // Store as u8 + sCustomSequenceScript[sCustomSequencePc++] = temp_a0; // shortdvg/ldelay arg + } else { + // Store as compressed u16 + sCustomSequenceScript[sCustomSequencePc++] = (((temp_a0 >> 8) & 0xFF) & 0x7F) + 0x80; // shortdvg/ldelay arg + sCustomSequenceScript[sCustomSequencePc++] = temp_a0 & 0xFF; // shortdvg/ldelay arg + } + + if (1) {} + + phi_s4 = ((temp_t4 * 48) + phi_s4) - (temp_a0 * 30); + + prevNote = &sScarecrowsLongSongNotes[i]; + } + + sCustomSequenceScript[sCustomSequencePc++] = 0xFF; // end cmd + + AudioOcarina_PlayCustomSequence(); + + if (i >= 394) { + return -1; + } + + return 0; +} +#else +#pragma GLOBAL_ASM("asm/non_matchings/code/code_8019AF00/AudioOcarina_CreateCustomSequence.s") +#endif + +void AudioOcarina_ResetInstrument(void) { + if (sOcarinaInstrumentId != OCARINA_INSTRUMENT_OFF) { + Audio_QueueSeqCmd(0x80000000 | ((u32)(SEQ_PLAYER_SFX) << 24) | ((u32)(1) << 16) | + ((u32)(SFX_CHANNEL_OCARINA) << 8) | (u32)(0)); + sOcarinaInstrumentId = OCARINA_INSTRUMENT_OFF; + AudioOcarina_ResetAndMute(); + } +} + +void AudioOcarina_ResetStaffs(void) { + u8 songIndex; + + sPlayingStaff.buttonIndex = OCARINA_BTN_INVALID; + sPlayingStaff.state = 0xFF; + sPlayingStaff.pos = 0; + + sPlaybackStaff.buttonIndex = OCARINA_BTN_INVALID; + sPlaybackStaff.state = 0; + sPlaybackStaff.pos = 0; + + sRecordingStaff.buttonIndex = OCARINA_BTN_INVALID; + sRecordingStaff.state = 0xFF; + sRecordingStaff.pos = 0; + + sOcarinaDisableTimer = 0; + sOcarinaDropInputTimer = 0; + + for (songIndex = OCARINA_SONG_SONATA; songIndex < OCARINA_SONG_MAX; songIndex++) { + D_801FD518[songIndex] = 0xFF; + D_801FD530[songIndex] = 0; + } + + D_801D8534 = 0; +} #pragma GLOBAL_ASM("asm/non_matchings/code/code_8019AF00/func_8019DFF8.s") @@ -2136,23 +3491,447 @@ s32 AudioOcarina_MemoryGameGenerateNotes(void) { #pragma GLOBAL_ASM("asm/non_matchings/code/code_8019AF00/func_8019E110.s") -#pragma GLOBAL_ASM("asm/non_matchings/code/code_8019AF00/func_8019E14C.s") +f32 AudioSfx_ComputeVolume(u8 bankId, u8 entryIndex) { + SfxBankEntry* bankEntry = &gSfxBanks[bankId][entryIndex]; + f32 minDist; + f32 phi_f14; + f32 baseDist; + f32 phi_f12; + f32 volume; // Also acts as intermediate volumeSquared + s32 pad[3]; -#pragma GLOBAL_ASM("asm/non_matchings/code/code_8019AF00/func_8019E324.s") + if (bankEntry->sfxParams & SFX_FLAG_VOLUME_NO_DIST) { + return 1.0f; + } -#pragma GLOBAL_ASM("asm/non_matchings/code/code_8019AF00/func_8019E4B0.s") + if (bankEntry->dist > 10000.0f) { + volume = 0.0f; + } else { + if (bankEntry->sfxParams & SFX_PARAM_DIST_RANGE_MASK_UPPER) { + phi_f12 = 0.35f; + phi_f14 = 0.65f; + } else { + phi_f12 = 0.81f; + phi_f14 = 0.19f; + } -#pragma GLOBAL_ASM("asm/non_matchings/code/code_8019AF00/func_8019E634.s") + switch (bankEntry->sfxParams & SFX_PARAM_DIST_RANGE_MASK) { + case 0: + baseDist = 500.0f; + break; -#pragma GLOBAL_ASM("asm/non_matchings/code/code_8019AF00/func_8019E864.s") + case 1: + baseDist = 666.6667f; + break; -#pragma GLOBAL_ASM("asm/non_matchings/code/code_8019AF00/func_8019EA40.s") + case 2: + baseDist = 952.381f; + break; -#pragma GLOBAL_ASM("asm/non_matchings/code/code_8019AF00/func_8019EB2C.s") + case 3: + baseDist = 3846.154f; + break; -#pragma GLOBAL_ASM("asm/non_matchings/code/code_8019AF00/func_8019F024.s") + case 4: + baseDist = 1000.0f; + break; -#pragma GLOBAL_ASM("asm/non_matchings/code/code_8019AF00/func_8019F05C.s") + case 5: + baseDist = 666.6667f; + break; + + case 6: + baseDist = 500.0f; + break; + + case 7: + baseDist = 400.0f; + break; + } + + minDist = baseDist / 5.0f; + + if (bankEntry->dist < minDist) { + volume = 1.0f; + } else if (bankEntry->dist < baseDist) { + volume = + ((((baseDist - minDist) - (bankEntry->dist - minDist)) / (baseDist - minDist)) * phi_f14) + phi_f12; + } else { + volume = (1.0f - ((bankEntry->dist - baseDist) / (10000.0f - baseDist))) * phi_f12; + } + + volume = SQ(volume); + } + + return volume; +} + +s8 AudioSfx_ComputeReverb(u8 bankId, u8 entryIndex, u8 channelIndex) { + s8 distAdd = 0; + s32 scriptAdd = 0; + SfxBankEntry* entry = &gSfxBanks[bankId][entryIndex]; + s32 reverb; + + if (!(entry->sfxParams & SFX_FLAG_REVERB_NO_DIST)) { + if (entry->dist < 2500.0f) { + distAdd = *entry->posZ > 0.0f ? (entry->dist / 2500.0f) * 70.0f : (entry->dist / 2500.0f) * 91.0f; + } else { + distAdd = 70; + } + } + + if (IS_SEQUENCE_CHANNEL_VALID(gAudioContext.seqPlayers[SEQ_PLAYER_SFX].channels[channelIndex])) { + scriptAdd = gAudioContext.seqPlayers[SEQ_PLAYER_SFX].channels[channelIndex]->soundScriptIO[1]; + if (gAudioContext.seqPlayers[SEQ_PLAYER_SFX].channels[channelIndex]->soundScriptIO[1] < 0) { + scriptAdd = 0; + } + } + + reverb = (*entry->reverbAdd & 0x7F) + distAdd; + + if (entry->state != SFX_STATE_READY) { + reverb += scriptAdd; + } + + if ((bankId != BANK_OCARINA) || (SFX_INDEX(entry->sfxId) >= 2)) { + reverb += sAudioEnvReverb + (sAudioCodeReverb & 0x3F) + sSpecReverb; + } + + if (reverb > 0x7F) { + reverb = 0x7F; + } + + return reverb; +} + +s8 AudioSfx_ComputePanSigned(f32 x, f32 z, u8 token) { + f32 absX = ABS_ALT(x); + f32 absZ = ABS_ALT(z); + f32 pan; + + if (absX > 8000.0f) { + absX = 8000.0f; + } + + if (absZ > 8000.0f) { + absZ = 8000.0f; + } + + if ((x == 0.0f) && (z == 0.0f)) { + pan = 0.5f; + } else if (absZ <= absX) { + pan = (16000.0f - absX) / (4.5f * (16000.0f - absZ)); + if (x >= 0.0f) { + pan = 1.0f - pan; + } + } else { + pan = (x / (3.6f * absZ)) + 0.5f; + } + + if ((absZ < 50.0f) && (absX < 50.0f)) { + pan = ((pan - 0.5f) * SQ(absX / 50.0f)) + 0.5f; + } + + return (pan * 127.0f) + 0.5f; +} + +f32 AudioSfx_ComputeFreqScale(u8 bankId, u8 entryIndex) { + s32 applyRandScaling = false; + SfxBankEntry* entry = &gSfxBanks[bankId][entryIndex]; + f32 dist; + f32 freq = 1.0f; + + if (entry->sfxParams & SFX_PARAM_RAND_FREQ_LOWER) { + freq = 1.0f - ((gAudioContext.audioRandom & 0xF) / 192.0f); + } + + switch (bankId) { + case BANK_VOICE: + if (((entry->sfxId & 0xFF) < 0x40) && (sAudioBaseFilter2 != 0)) { + applyRandScaling = true; + } else if (((entry->sfxId & 0xFF) >= 0x40) && (sAudioExtraFilter2 != 0)) { + applyRandScaling = true; + } + break; + + case BANK_PLAYER: + case BANK_ITEM: + if (sAudioBaseFilter2 != 0) { + applyRandScaling = true; + } + break; + + case BANK_ENV: + case BANK_ENEMY: + if (((*entry->reverbAdd & 0x80) != 0) | (sAudioExtraFilter2 != 0)) { + applyRandScaling = true; + } + break; + + case BANK_SYSTEM: + case BANK_OCARINA: + break; + + default: + break; + } + + if ((applyRandScaling == true) && !(entry->sfxParams & SFX_PARAM_RAND_FREQ_SCALE)) { + freq *= 1.0293 - ((gAudioContext.audioRandom & 0xF) / 144.0f); + } + + dist = entry->dist; + if (!(entry->sfxParams & SFX_FLAG_VOLUME_NO_DIST) && !(entry->sfxParams & SFX_FLAG_FREQ_NO_DIST)) { + if (dist >= 10000.0f) { + freq += 0.2f; + } else { + freq += (0.2f * (dist / 10000.0f)); + } + } + + if ((entry->sfxParams & SFX_PARAM_RAND_FREQ_RAISE_MASK) != (0 << SFX_PARAM_RAND_FREQ_RAISE_SHIFT)) { + freq += (entry->randFreq / 192.0f); + } + + return freq; +} + +u8 AudioSfx_ComputeSurroundSoundFilter(f32 behindScreenZ, SfxBankEntry* entry, s8 panSigned) { + u8 lowPassCutoff; + u8 highPassCutoff; + u16* sfxParams; + f32 distParam; + f32 dist; + + // Remnant of OoT + if (*entry->posZ < behindScreenZ) { + lowPassCutoff = 0; + } else { + lowPassCutoff = 0; + } + + sfxParams = &entry->sfxParams; + + if (*sfxParams & SFX_FLAG_SURROUND_LOWPASS_FILTER) { + lowPassCutoff = 0xF; + } + + switch ((*sfxParams & SFX_PARAM_DIST_RANGE_MASK)) { + case 0: + distParam = 15.0f; + break; + + case 1: + distParam = 12.0f; + break; + + case 2: + distParam = 9.0f; + break; + + case 3: + distParam = 6.0f; + break; + + case 4: + distParam = 18.0f; + break; + + case 5: + distParam = 21.0f; + break; + + case 6: + distParam = 24.0f; + break; + + case 7: + distParam = 27.0f; + break; + + default: + break; + } + + if (!(entry->sfxFlags & SFX_FLAG2_SURROUND_NO_HIGHPASS_FILTER)) { + if (entry->dist > 1923.077f) { + dist = 1923.077f; + } else { + dist = entry->dist; + } + + highPassCutoff = (distParam * dist) / (2 * 1923.077f); + } else { + highPassCutoff = 0; + } + + return (lowPassCutoff << 4) + highPassCutoff; +} + +s8 AudioSfx_ComputeCombFilter(f32 posY, u16 sfxParams) { + s8 combFilterGain; + + if (posY < 0.0f) { + if (posY < -625.0f) { + combFilterGain = -32; + } else { + combFilterGain = (s8)(((625.0f + posY) / 625.0f) * 31.0f) + 0xE0; + } + } else if (posY > 1250.0f) { + combFilterGain = 127; + } else { + combFilterGain = (posY / 1250.0f) * 126.0f; + } + + return combFilterGain | 1; +} + +void AudioSfx_SetProperties(u8 bankId, u8 entryIndex, u8 channelIndex) { + static s8 sZVolumes[] = { + 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 volume = 1.0f; + s8 volumeS8; + s8 reverb = 0; + f32 freqScale = 1.0f; + s8 panSigned = 0x40; + u8 pad; + u8 filter = 0; + s8 combFilterGain = 0; + s8 zVolume = -1; + f32 behindScreenZ; + u8 baseFilter = 0; + SfxBankEntry* entry = &gSfxBanks[bankId][entryIndex]; + s32 pad2; + + switch (bankId) { + case BANK_PLAYER: + case BANK_ITEM: + case BANK_ENV: + case BANK_ENEMY: + case BANK_VOICE: + if (sSoundMode == SOUNDMODE_SURROUND) { + combFilterGain = AudioSfx_ComputeCombFilter(*entry->posY, entry->sfxParams); + } + // fallthrough + case BANK_OCARINA: + entry->dist = sqrtf(entry->dist * 10.0f); + volume = AudioSfx_ComputeVolume(bankId, entryIndex) * *entry->volume; + reverb = AudioSfx_ComputeReverb(bankId, entryIndex, channelIndex); + panSigned = AudioSfx_ComputePanSigned(*entry->posX, *entry->posZ, entry->token); + freqScale = AudioSfx_ComputeFreqScale(bankId, entryIndex) * *entry->freqScale; + + if (sSoundMode == SOUNDMODE_SURROUND) { + if (*entry->posZ >= 0.0f) { + if (*entry->posZ < 200.0f) { + zVolume = 32.0f - ((*entry->posZ / 300.0f) * 32.0f); + } else { + zVolume = 0; + } + } else if (*entry->posZ < 0.0f) { + if (*entry->posZ > -300.0f) { + zVolume = 32.0f - ((*entry->posZ / 300.0f) * 95.0f); + } else { + zVolume = 127; + } + } + zVolume = sZVolumes[zVolume]; + } + + if (sAudioBaseFilter != 0) { + if ((bankId == BANK_PLAYER) || (bankId == BANK_ITEM) || + ((bankId == BANK_VOICE) && (((entry->sfxId & 0xFF) < 0x40) || ((entry->sfxId & 0xFF) >= 0x80)))) { + baseFilter = sAudioBaseFilter; + if (sAudioExtraFilter) { + reverb >>= 2; + } + } + } + + if (((*entry->reverbAdd & 0x80) | baseFilter | sAudioExtraFilter | + (entry->sfxFlags & SFX_FLAG2_APPLY_LOWPASS_FILTER)) != 0) { + filter = ((((*entry->reverbAdd & 0x80) >> 2) | baseFilter | sAudioExtraFilter | + ((entry->sfxFlags & SFX_FLAG2_APPLY_LOWPASS_FILTER) >> 2)) * + 2); + filter &= 0xFF; + } else if ((sSoundMode == SOUNDMODE_SURROUND) && !(entry->sfxParams & SFX_FLAG_VOLUME_NO_DIST)) { + filter = AudioSfx_ComputeSurroundSoundFilter(behindScreenZ, entry, panSigned); + } + break; + + case BANK_SYSTEM: + break; + } + + if (sSfxChannelState[channelIndex].volume != volume) { + volumeS8 = (u8)(volume * 127.0f); + sSfxChannelState[channelIndex].volume = volume; + } else { + volumeS8 = -1; + } + + //! FAKE: + if (1) {} + + // CHAN_UPD_SCRIPT_IO (slot 2, sets volume) + AudioThread_QueueCmdS8((0x6 << 24) | (SEQ_PLAYER_SFX << 16) | (channelIndex << 8) | 2, volumeS8); + + if (sSfxChannelState[channelIndex].reverb != reverb) { + sSfxChannelState[channelIndex].reverb = reverb; + } + if (sSfxChannelState[channelIndex].freqScale != freqScale) { + sSfxChannelState[channelIndex].freqScale = freqScale; + } + if (sSfxChannelState[channelIndex].stereoBits != 0) { + sSfxChannelState[channelIndex].stereoBits = 0; + } + if (sSfxChannelState[channelIndex].filter != filter) { + sSfxChannelState[channelIndex].filter = filter; + } + if (sSfxChannelState[channelIndex].combFilterGain != combFilterGain) { + sSfxChannelState[channelIndex].combFilterGain = combFilterGain; + } + if (sSfxChannelState[channelIndex].zVolume != zVolume) { + sSfxChannelState[channelIndex].zVolume = zVolume; + } + if (sSfxChannelState[channelIndex].panSigned != panSigned) { + sSfxChannelState[channelIndex].panSigned = panSigned; + } +} + +u32 AudioSfx_SetFreqAndStereoBits(u8 seqScriptValIn, SequenceChannel* channel) { + channel->stereo.asByte = sSfxChannelState[seqScriptValIn].stereoBits; + channel->freqScale = sSfxChannelState[seqScriptValIn].freqScale; + channel->changes.s.freqScale = true; + + return seqScriptValIn; +} + +void AudioSfx_ResetSfxChannelState(void) { + SfxChannelState* state; + u8 i; + + for (i = 0; i < ARRAY_COUNT(sSfxChannelState); i++) { + state = &sSfxChannelState[i]; + state->volume = 1.0f; + state->freqScale = 1.0f; + state->reverb = 0; + state->panSigned = 0x40; + state->stereoBits = 0; + state->filter = 0xFF; + state->combFilterGain = 0xFF; + state->zVolume = 0xFF; + } + + sSfxChannelState[SFX_CHANNEL_OCARINA].combFilterGain = 0; + sPrevSeqMode = SEQ_MODE_DEFAULT; + sAudioCodeReverb = 0; +} #pragma GLOBAL_ASM("asm/non_matchings/code/code_8019AF00/play_sound.s") @@ -2166,9 +3945,75 @@ s32 AudioOcarina_MemoryGameGenerateNotes(void) { #pragma GLOBAL_ASM("asm/non_matchings/code/code_8019AF00/func_8019F230.s") -#pragma GLOBAL_ASM("asm/non_matchings/code/code_8019AF00/func_8019F258.s") +SfxSettings* AudioSfx_AddSfxSetting(Vec3f* pos) { + SfxSettings* sfxSettings; + u8 i = 0; + u8 sfxSettingIndex = 0xFF; -#pragma GLOBAL_ASM("asm/non_matchings/code/code_8019AF00/func_8019F300.s") + for (; i < ARRAY_COUNT(sSfxSettings); i++) { + sfxSettings = &sSfxSettings[i]; + + if ((sfxSettings->pos == NULL) && (sfxSettingIndex == 0xFF)) { + sfxSettingIndex = i; + } + + if (sfxSettings->pos == pos) { + return sfxSettings; + } + } + + if (sfxSettingIndex != 0xFF) { + sSfxSettingsFlags |= 1 << sfxSettingIndex; + sfxSettings = &sSfxSettings[sfxSettingIndex]; + sfxSettings->pos = pos; + return sfxSettings; + } + + return NULL; +} + +void AudioSfx_ProcessSfxSettings(void) { + SfxBankEntry* entry; + u8 sfxSettingsFlags; + u8 sfxSettingIndex = 0; + u8 bankId; + u8 entryIndex; + s32 found; + + if (sSfxSettingsFlags != 0) { + sfxSettingsFlags = sSfxSettingsFlags; + + while (sfxSettingsFlags != 0) { + bankId = BANK_ENV; + if ((sfxSettingsFlags & (1 << sfxSettingIndex))) { + + found = false; + while ((bankId <= BANK_ENEMY) && !found) { + entryIndex = gSfxBanks[bankId]->next; + + while (entryIndex != 0xFF) { + entry = &gSfxBanks[bankId][entryIndex]; + entryIndex = 0xFF; + if (entry->posX == &sSfxSettings[sfxSettingIndex].pos->x) { + found = true; + } else { + entryIndex = entry->next; + } + } + bankId++; + } + + if (!found) { + sSfxSettingsFlags ^= (1 << sfxSettingIndex); + sSfxSettings[sfxSettingIndex].pos = NULL; + } + + sfxSettingsFlags ^= (1 << sfxSettingIndex); + } + sfxSettingIndex++; + } + } +} #pragma GLOBAL_ASM("asm/non_matchings/code/code_8019AF00/func_8019F420.s") @@ -2176,7 +4021,17 @@ s32 AudioOcarina_MemoryGameGenerateNotes(void) { #pragma GLOBAL_ASM("asm/non_matchings/code/code_8019AF00/func_8019F540.s") -#pragma GLOBAL_ASM("asm/non_matchings/code/code_8019AF00/func_8019F570.s") +void AudioSfx_LowerSfxSettingsReverb(Vec3f* pos, s8 isReverbLowered) { + SfxSettings* sfxSettings = AudioSfx_AddSfxSetting(pos); + + if (sfxSettings != NULL) { + if (isReverbLowered) { + sfxSettings->reverbAdd = -0x80; + } else { + sfxSettings->reverbAdd = 0; + } + } +} #pragma GLOBAL_ASM("asm/non_matchings/code/code_8019AF00/func_8019F5AC.s") @@ -2218,15 +4073,15 @@ s32 AudioOcarina_MemoryGameGenerateNotes(void) { * Used for EnRiverSound */ void Audio_PlaySfxForRiver(Vec3f* pos, f32 freqScale) { - if (!Audio_IsSfxPlaying(NA_SE_EV_RIVER_STREAM - SFX_FLAG)) { + if (!AudioSfx_IsPlaying(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); + AudioSfx_PlaySfx(NA_SE_EV_RIVER_STREAM - SFX_FLAG, pos, 4, &sRiverFreqScaleLerp.value, &gSfxDefaultFreqAndVolScale, + &gSfxDefaultReverb); } /** @@ -2234,15 +4089,15 @@ void Audio_PlaySfxForRiver(Vec3f* pos, f32 freqScale) { * Used for Zora's River Waterfall */ void Audio_PlaySfxForWaterfall(Vec3f* pos, f32 freqScale) { - if (!Audio_IsSfxPlaying(NA_SE_EV_WATER_WALL_BIG - SFX_FLAG)) { + if (!AudioSfx_IsPlaying(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); + AudioSfx_PlaySfx(NA_SE_EV_WATER_WALL_BIG - SFX_FLAG, pos, 4, &sWaterfallFreqScaleLerp.value, + &sWaterfallFreqScaleLerp.value, &gSfxDefaultReverb); } /** @@ -2259,6 +4114,9 @@ void Audio_StepFreqLerp(FreqLerp* lerp) { } } +f32 sBigBellsVolume[8] = { + 1.0f, 0.9f, 0.8f, 0.7f, 0.6f, 0.5f, 0.4f, 0.3f, +}; #pragma GLOBAL_ASM("asm/non_matchings/code/code_8019AF00/func_801A0124.s") #pragma GLOBAL_ASM("asm/non_matchings/code/code_8019AF00/func_801A0184.s") @@ -2285,7 +4143,7 @@ void Audio_SetGanonsTowerBgmVolumeLevel(u8 ganonsTowerLevel) { for (channelIndex = 0; channelIndex < 16; channelIndex++) { // CHAN_UPD_PAN_UNSIGNED - Audio_QueueCmdS8(((u8)(u32)channelIndex << 8) | 0x7000000, pan); + AudioThread_QueueCmdS8(((u8)(u32)channelIndex << 8) | 0x7000000, pan); } // Lowest room in Ganon's Tower (Entrance Room) @@ -2343,9 +4201,9 @@ s32 Audio_SetGanonsTowerBgmVolume(u8 targetVolume) { } // CHAN_UPD_REVERB - Audio_QueueCmdS8(_SHIFTL(5, 24, 8) | _SHIFTL(SEQ_PLAYER_BGM_MAIN, 16, 8) | - _SHIFTL(channelIndex, 8, 8), - (u8)reverb); + AudioThread_QueueCmdS8(_SHIFTL(5, 24, 8) | _SHIFTL(SEQ_PLAYER_BGM_MAIN, 16, 8) | + _SHIFTL(channelIndex, 8, 8), + (u8)reverb); } } } @@ -2401,7 +4259,29 @@ void Audio_UpdateRiverSoundVolumes(void) { #pragma GLOBAL_ASM("asm/non_matchings/code/code_8019AF00/func_801A05F0.s") -#pragma GLOBAL_ASM("asm/non_matchings/code/code_8019AF00/func_801A0654.s") +void AudioSfx_SetChannelIO(Vec3f* pos, u16 sfxId, u8 ioData) { + u8 channelIndex = 0; + u8 bankId = SFX_BANK_SHIFT(sfxId); + u8 entryIndex; + u8 i; + + for (i = 0; i < bankId; i++) { + channelIndex += gChannelsPerBank[gSfxChannelLayout][i]; + } + + for (i = 0; i < gChannelsPerBank[gSfxChannelLayout][bankId]; i++) { + entryIndex = gActiveSfx[bankId][i].entryIndex; + + if (entryIndex != 0xFF) { + if ((sfxId == gSfxBanks[bankId][entryIndex].sfxId) && (&pos->x == gSfxBanks[bankId][entryIndex].posX)) { + AudioThread_QueueCmdS8(_SHIFTL(6, 24, 8) | _SHIFTL(SEQ_PLAYER_SFX, 16, 8) | + _SHIFTL(channelIndex, 8, 8) | _SHIFTL(6, 0, 8), + ioData); + } + } + channelIndex++; + } +} #pragma GLOBAL_ASM("asm/non_matchings/code/code_8019AF00/func_801A0810.s") @@ -2447,7 +4327,7 @@ void func_801A09D4(Vec3f* pos, f32 xzDistToPlayer) { 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); + AudioThread_QueueCmdS8(0x03000000 | ((u8)((u32)channelIndex) << 8), pan); } } } @@ -2470,6 +4350,7 @@ void Audio_ClearSariaBgmAtPos(Vec3f* pos) { } } +u8 sBgmPlayers[2] = { SEQ_PLAYER_BGM_MAIN, SEQ_PLAYER_BGM_SUB }; void Audio_SplitBgmChannels(s8 volumeSplit); #pragma GLOBAL_ASM("asm/non_matchings/code/code_8019AF00/Audio_SplitBgmChannels.s") @@ -2664,7 +4545,7 @@ void Audio_ClearSariaBgm2(void) { #pragma GLOBAL_ASM("asm/non_matchings/code/code_8019AF00/func_801A4348.s") -#pragma GLOBAL_ASM("asm/non_matchings/code/code_8019AF00/func_801A4380.s") +#pragma GLOBAL_ASM("asm/non_matchings/code/code_8019AF00/Audio_SetSfxVolumeExceptSystemAndOcarinaBanks.s") #pragma GLOBAL_ASM("asm/non_matchings/code/code_8019AF00/func_801A4428.s") @@ -2676,6 +4557,7 @@ void Audio_ClearSariaBgm2(void) { #pragma GLOBAL_ASM("asm/non_matchings/code/code_8019AF00/func_801A46F8.s") +f32 sSfxOriginalPos[] = { 0.0f, 0.0f, 0.0f }; #pragma GLOBAL_ASM("asm/non_matchings/code/code_8019AF00/func_801A4748.s") #pragma GLOBAL_ASM("asm/non_matchings/code/code_8019AF00/func_801A479C.s") @@ -2686,11 +4568,27 @@ void Audio_ClearSariaBgm2(void) { #pragma GLOBAL_ASM("asm/non_matchings/code/code_8019AF00/func_801A4A28.s") -#pragma GLOBAL_ASM("asm/non_matchings/code/code_8019AF00/func_801A4B80.s") +u32 Audio_SetNatureAmbienceRandomBend(u8 seqScriptValIn, SequenceChannel* channel); +#pragma GLOBAL_ASM("asm/non_matchings/code/code_8019AF00/Audio_SetNatureAmbienceRandomBend.s") -#pragma GLOBAL_ASM("asm/non_matchings/code/code_8019AF00/func_801A4C30.s") +void Audio_Init(void) { + AudioLoad_Init(NULL, 0); +} -#pragma GLOBAL_ASM("asm/non_matchings/code/code_8019AF00/func_801A4C54.s") +void AudioSfx_Init(u16 fadeTimer) { + u8 channelIndex; + + AudioThread_ScheduleProcessCmds(); + Audio_StartSequence(SEQ_PLAYER_SFX, NA_BGM_GENERAL_SFX, 0x70, fadeTimer); + + for (channelIndex = 0; channelIndex < ARRAY_COUNT(sSfxChannelState); channelIndex++) { + AudioThread_QueueCmdS32(0x10 << 24 | SEQ_PLAYER_SFX << 16 | ((u8)(u32)channelIndex << 8), + &sSfxChannelState[channelIndex]); + } + + AudioThread_QueueCmdS32(0xE4000000, AudioSfx_SetFreqAndStereoBits); + AudioThread_QueueCmdS32(0xE4000001, Audio_SetNatureAmbienceRandomBend); +} #pragma GLOBAL_ASM("asm/non_matchings/code/code_8019AF00/func_801A4D00.s") diff --git a/src/code/audio/code_801A5BD0.c b/src/code/audio/code_801A5BD0.c index 8397fd52e..4cf1147bf 100644 --- a/src/code/audio/code_801A5BD0.c +++ b/src/code/audio/code_801A5BD0.c @@ -1,45 +1,951 @@ #include "global.h" -#pragma GLOBAL_ASM("asm/non_matchings/code/code_801A5BD0/func_801A5BD0.s") +typedef struct { + /* 0x00 */ u16 sfxId; + /* 0x02 */ u8 token; + /* 0x04 */ s8* reverbAdd; + /* 0x08 */ Vec3f* pos; + /* 0x0C */ f32* freqScale; + /* 0x10 */ f32* volume; +} SfxRequest; // size = 0x14 -#pragma GLOBAL_ASM("asm/non_matchings/code/code_801A5BD0/func_801A5C28.s") +typedef struct { + /* 0x0 */ f32 value; + /* 0x4 */ f32 target; + /* 0x8 */ f32 step; + /* 0xC */ u16 remainingFrames; +} SfxBankLerp; // size = 0x10 -#pragma GLOBAL_ASM("asm/non_matchings/code/code_801A5BD0/func_801A5C8C.s") +typedef enum { + /* 0 */ SFX_RM_REQ_BY_BANK, + /* 1 */ SFX_RM_REQ_BY_POS_AND_BANK, + /* 2 */ SFX_RM_REQ_BY_POS, + /* 3 */ SFX_RM_REQ_BY_POS_AND_ID, + /* 4 */ SFX_RM_REQ_BY_TOKEN_AND_ID, + /* 5 */ SFX_RM_REQ_BY_ID +} SfxRemoveRequest; -#pragma GLOBAL_ASM("asm/non_matchings/code/code_801A5BD0/Audio_PlaySfxGeneral.s") +SfxBankEntry sSfxPlayerBank[9]; +SfxBankEntry sSfxItemBank[12]; +SfxBankEntry sSfxEnvironmentBank[32]; +SfxBankEntry sSfxEnemyBank[20]; +SfxBankEntry sSfxSystemBank[8]; +SfxBankEntry sSfxOcarinaBank[3]; +SfxBankEntry sSfxVoiceBank[5]; +SfxRequest sSfxRequests[0x100]; +u8 sSfxBankListEnd[7]; +u8 sSfxBankFreeListStart[7]; +u8 sSfxBankUnused[7]; +ActiveSfx gActiveSfx[7][3]; +u8 sCurSfxPlayerChannelIndex; +u8 gSfxBankMuted[7]; +SfxBankLerp sSfxBankLerp[7]; -#pragma GLOBAL_ASM("asm/non_matchings/code/code_801A5BD0/func_801A5DDC.s") +// sSfxRequests ring buffer endpoints. read index <= write index, wrapping around mod 256. +u8 sSfxRequestWriteIndex = 0; +u8 sSfxRequestReadIndex = 0; -#pragma GLOBAL_ASM("asm/non_matchings/code/code_801A5BD0/func_801A5F7C.s") +/** + * Array of pointers to arrays of SfxBankEntry of sizes: 9, 12, 32, 20, 8, 3, 5 + * + * 0 : Player Bank size 9 + * 1 : Item Bank size 12 + * 2 : Environment Bank size 32 + * 3 : Enemy Bank size 20 + * 4 : System Bank size 8 + * 5 : Ocarina Bank size 3 + * 6 : Voice Bank size 5 + */ +SfxBankEntry* gSfxBanks[7] = { + sSfxPlayerBank, sSfxItemBank, sSfxEnvironmentBank, sSfxEnemyBank, sSfxSystemBank, sSfxOcarinaBank, sSfxVoiceBank, +}; -#pragma GLOBAL_ASM("asm/non_matchings/code/code_801A5BD0/func_801A6430.s") +u8 sSfxBankSizes[ARRAY_COUNT(gSfxBanks)] = { + ARRAY_COUNT(sSfxPlayerBank), ARRAY_COUNT(sSfxItemBank), ARRAY_COUNT(sSfxEnvironmentBank), + ARRAY_COUNT(sSfxEnemyBank), ARRAY_COUNT(sSfxSystemBank), ARRAY_COUNT(sSfxOcarinaBank), + ARRAY_COUNT(sSfxVoiceBank), +}; -#pragma GLOBAL_ASM("asm/non_matchings/code/code_801A5BD0/func_801A65C8.s") +u8 gSfxChannelLayout = 0; +u16 sSfxChannelLowVolumeFlag = 0; -#pragma GLOBAL_ASM("asm/non_matchings/code/code_801A5BD0/func_801A6D0C.s") +// The center of the screen in projected coordinates. +// Gives the impression that the sfx has no specific location +Vec3f gSfxDefaultPos = { 0.0f, 0.0f, 0.0f }; -#pragma GLOBAL_ASM("asm/non_matchings/code/code_801A5BD0/func_801A7084.s") +// Reused as either frequency or volume multiplicative scaling factor +// Does not alter or change frequency or volume +f32 gSfxDefaultFreqAndVolScale = 1.0f; +s32 D_801DB4B4 = 0; // unused -#pragma GLOBAL_ASM("asm/non_matchings/code/code_801A5BD0/func_801A7168.s") +// Adds no reverb to the existing reverb +s8 gSfxDefaultReverb = 0; -#pragma GLOBAL_ASM("asm/non_matchings/code/code_801A5BD0/func_801A7284.s") +void AudioSfx_MuteBanks(u16 muteMask) { + u8 bankId; -#pragma GLOBAL_ASM("asm/non_matchings/code/code_801A5BD0/Audio_StopSfxByPos.s") + for (bankId = 0; bankId < ARRAY_COUNT(gSfxBanks); bankId++) { + if (muteMask & 1) { + gSfxBankMuted[bankId] = true; + } else { + gSfxBankMuted[bankId] = false; + } + muteMask = muteMask >> 1; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/code/code_801A5BD0/func_801A7328.s") +/** + * Lowers volumes of both bgm players so that sfx can be more pronounced. + * Each sfx channel stores its own bit to lower the volume. + * Only a single channel needs to request this to lower the volume. + */ +void AudioSfx_LowerBgmVolume(u8 channelIndex) { + sSfxChannelLowVolumeFlag |= (1 << channelIndex); -#pragma GLOBAL_ASM("asm/non_matchings/code/code_801A5BD0/func_801A7484.s") + Audio_SetVolumeScale(SEQ_PLAYER_BGM_MAIN, 2, 0x40, 0xF); + Audio_SetVolumeScale(SEQ_PLAYER_BGM_SUB, 2, 0x40, 0xF); +} -#pragma GLOBAL_ASM("asm/non_matchings/code/code_801A5BD0/func_801A75E8.s") +/** + * Clears the flag for the specific channel to lower volume. + * If all flags are cleared, then both bgm players return to full volume + */ +void AudioSfx_RestoreBgmVolume(u8 channelIndex) { + sSfxChannelLowVolumeFlag &= ((1 << channelIndex) ^ 0xFFFF); -#pragma GLOBAL_ASM("asm/non_matchings/code/code_801A5BD0/func_801A7720.s") + if (sSfxChannelLowVolumeFlag == 0) { + Audio_SetVolumeScale(SEQ_PLAYER_BGM_MAIN, 2, 0x7F, 0xF); + Audio_SetVolumeScale(SEQ_PLAYER_BGM_SUB, 2, 0x7F, 0xF); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/code/code_801A5BD0/func_801A7794.s") +/** + * The main function to request a sfx. All sfx requests begin here. + */ +void AudioSfx_PlaySfx(u16 sfxId, Vec3f* pos, u8 token, f32* freqScale, f32* volume, s8* reverbAdd) { + u8 i; + SfxRequest* reqWrite; + SfxRequest* reqRead; -#pragma GLOBAL_ASM("asm/non_matchings/code/code_801A5BD0/func_801A7828.s") + if (!gSfxBankMuted[SFX_BANK_SHIFT(sfxId)]) { + reqWrite = &sSfxRequests[sSfxRequestWriteIndex]; -#pragma GLOBAL_ASM("asm/non_matchings/code/code_801A5BD0/func_801A787C.s") + for (i = sSfxRequestReadIndex; sSfxRequestWriteIndex != i; i++) { + reqRead = &sSfxRequests[i]; + if ((reqRead->pos == pos) && (reqRead->sfxId == sfxId)) { + return; + } + } -#pragma GLOBAL_ASM("asm/non_matchings/code/code_801A5BD0/Audio_IsSfxPlaying.s") + reqWrite->sfxId = sfxId; + reqWrite->pos = pos; + reqWrite->token = token; + reqWrite->freqScale = freqScale; + reqWrite->volume = volume; + reqWrite->reverbAdd = reverbAdd; + sSfxRequestWriteIndex++; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/code/code_801A5BD0/func_801A794C.s") +void AudioSfx_RemoveMatchingRequests(u8 aspect, SfxBankEntry* entry) { + SfxRequest* req; + s32 remove; + u8 i = sSfxRequestReadIndex; + + for (; i != sSfxRequestWriteIndex; i++) { + remove = false; + req = &sSfxRequests[i]; + + switch (aspect) { + case SFX_RM_REQ_BY_BANK: + if (SFX_BANK_MASK(req->sfxId) == SFX_BANK_MASK(entry->sfxId)) { + remove = true; + } + break; + + case SFX_RM_REQ_BY_POS_AND_BANK: + if ((SFX_BANK_MASK(req->sfxId) == SFX_BANK_MASK(entry->sfxId)) && (&req->pos->x == entry->posX)) { + remove = true; + } + break; + + case SFX_RM_REQ_BY_POS: + if (&req->pos->x == entry->posX) { + remove = true; + } + break; + + case SFX_RM_REQ_BY_POS_AND_ID: + if ((&req->pos->x == entry->posX) && (req->sfxId == entry->sfxId)) { + remove = true; + } + break; + + case SFX_RM_REQ_BY_TOKEN_AND_ID: + if ((req->token == entry->token) && (req->sfxId == entry->sfxId)) { + remove = true; + } + break; + + case SFX_RM_REQ_BY_ID: + if (req->sfxId == entry->sfxId) { + remove = true; + } + break; + + default: + break; + } + + if (remove) { + req->sfxId = 0; + } + } +} + +void AudioSfx_ProcessRequest(void) { + u16 sfxId; + u8 channelCount; + u8 index; + SfxRequest* req = &sSfxRequests[sSfxRequestReadIndex]; + SfxBankEntry* entry; + SfxParams* sfxParams; + s32 bankId; + u8 evictImportance; + u8 evictIndex = 0x80; + + if (req->sfxId == 0) { + return; + } + + bankId = SFX_BANK(req->sfxId); + channelCount = 0; + index = gSfxBanks[bankId][0].next; + + // Compare the sfx request to all sfx bank entries + while ((index != 0xFF) && (index != 0)) { + + // If an existing sfx from the same source exists in the bank, then we should either: + // renew if it is the same sfx, check if any sfx channels are available for that bank, + // interrupt that sfx and replace it with the new sfx request, or drop the new sfx request. + if (gSfxBanks[bankId][index].posX == &req->pos->x) { + + // If the new sfx has equal importance to the existing sfx, + // drop the request if the existing sfx has the "SFX_FLAG_BLOCK_EQUAL_IMPORTANCE" flag. + // Otherwise, keep processing the new sfx request + if ((gSfxParams[SFX_BANK_SHIFT(req->sfxId)][SFX_INDEX(req->sfxId)].params & + SFX_FLAG_BLOCK_EQUAL_IMPORTANCE) && + (gSfxParams[SFX_BANK_SHIFT(req->sfxId)][SFX_INDEX(req->sfxId)].importance == + gSfxBanks[bankId][index].sfxImportance)) { + // Drop the new request + return; + } + + if (gSfxBanks[bankId][index].sfxId == req->sfxId) { + // The new sfx is the same as the existing sfx + // Set channelCount to max value to reprocess the sfx + channelCount = gUsedChannelsPerBank[gSfxChannelLayout][bankId]; + } else { + // Determine which sfx to evict based on importance if there are no more channels available + if (channelCount == 0) { + // If this is the first sfx at the same source, than store the existing sfx info into evict temps + evictIndex = index; + sfxId = gSfxBanks[bankId][index].sfxId & 0xFFFF; + evictImportance = gSfxParams[SFX_BANK_SHIFT(sfxId)][SFX_INDEX(sfxId)].importance; + } else if (gSfxBanks[bankId][index].sfxImportance < evictImportance) { + // If a different existing sfx is at the same source, than update the evict temps if the next + // existing src has lower importance than the previous existing source + evictIndex = index; + sfxId = gSfxBanks[bankId][index].sfxId & 0xFFFF; + evictImportance = gSfxParams[SFX_BANK_SHIFT(sfxId)][SFX_INDEX(sfxId)].importance; + } + + channelCount++; + + // There are no channels available, evict the lowest importance + if (channelCount == gUsedChannelsPerBank[gSfxChannelLayout][bankId]) { + if (gSfxParams[SFX_BANK_SHIFT(req->sfxId)][SFX_INDEX(req->sfxId)].importance >= evictImportance) { + index = evictIndex; + } else { + index = 0; + } + } + } + + // Process this sfx by refreshing or replacing and existing sfx + if (channelCount == gUsedChannelsPerBank[gSfxChannelLayout][bankId]) { + sfxParams = &gSfxParams[SFX_BANK_SHIFT(req->sfxId)][SFX_INDEX(req->sfxId)]; + + // Interrupt existing sfx and play the new sfx instead. + if ((req->sfxId & SFX_FLAG_MASK) || (sfxParams->flags & SFX_FLAG2_FORCE_RESET) || + (index == evictIndex)) { + + // Restore bgm if the sfx about to be replaced has the right flag + if ((gSfxBanks[bankId][index].sfxParams & SFX_FLAG_LOWER_VOLUME_BGM) && + (gSfxBanks[bankId][index].state != SFX_STATE_QUEUED)) { + AudioSfx_RestoreBgmVolume(gSfxBanks[bankId][index].channelIndex); + } + + gSfxBanks[bankId][index].token = req->token; + gSfxBanks[bankId][index].sfxId = req->sfxId; + gSfxBanks[bankId][index].state = SFX_STATE_QUEUED; + gSfxBanks[bankId][index].freshness = 2; + gSfxBanks[bankId][index].freqScale = req->freqScale; + gSfxBanks[bankId][index].volume = req->volume; + gSfxBanks[bankId][index].reverbAdd = req->reverbAdd; + gSfxBanks[bankId][index].sfxParams = sfxParams->params; + gSfxBanks[bankId][index].sfxFlags = sfxParams->flags; + gSfxBanks[bankId][index].sfxImportance = sfxParams->importance; + } else if (gSfxBanks[bankId][index].state == SFX_STATE_PLAYING_ONE_FRAME) { + // The new sfx is "one-frame" and equals the existing sfx, + // continue playing the "one-frame" sfx by setting "SFX_STATE_PLAYING". + // This will avoid triggering deletion and get "SFX_STATE_REFRESH" + // The state will be set back to "SFX_STATE_PLAYING_ONE_FRAME" at the end of the cycle + gSfxBanks[bankId][index].state = SFX_STATE_PLAYING; + } + // Terminate loop, function is finished (nothing more is processed) + index = 0; + } + } + + if (index != 0) { + index = gSfxBanks[bankId][index].next; + } + } + + if ((gSfxBanks[bankId][sSfxBankFreeListStart[bankId]].next != 0xFF) && (index != 0)) { + // Allocate from free list + index = sSfxBankFreeListStart[bankId]; + + entry = &gSfxBanks[bankId][index]; + entry->posX = &req->pos->x; + entry->posY = &req->pos->y; + entry->posZ = &req->pos->z; + entry->token = req->token; + entry->freqScale = req->freqScale; + entry->volume = req->volume; + entry->reverbAdd = req->reverbAdd; + + sfxParams = &gSfxParams[SFX_BANK_SHIFT(req->sfxId)][SFX_INDEX(req->sfxId)]; + + entry->sfxParams = sfxParams->params; + entry->sfxFlags = sfxParams->flags; + entry->sfxImportance = sfxParams->importance; + entry->sfxId = req->sfxId; + entry->state = SFX_STATE_QUEUED; + entry->freshness = 2; + entry->prev = sSfxBankListEnd[bankId]; + + gSfxBanks[bankId][sSfxBankListEnd[bankId]].next = sSfxBankFreeListStart[bankId]; + sSfxBankListEnd[bankId] = sSfxBankFreeListStart[bankId]; + sSfxBankFreeListStart[bankId] = gSfxBanks[bankId][sSfxBankFreeListStart[bankId]].next; + gSfxBanks[bankId][sSfxBankFreeListStart[bankId]].prev = 0xFF; + + entry->next = 0xFF; + } +} + +void AudioSfx_RemoveBankEntry(u8 bankId, u8 entryIndex) { + SfxBankEntry* entry = &gSfxBanks[bankId][entryIndex]; + u8 i; + + if (entry->sfxParams & SFX_FLAG_LOWER_VOLUME_BGM) { + AudioSfx_RestoreBgmVolume(entry->channelIndex); + } + + if (entryIndex == sSfxBankListEnd[bankId]) { + sSfxBankListEnd[bankId] = entry->prev; + } else { + gSfxBanks[bankId][entry->next].prev = entry->prev; + } + + gSfxBanks[bankId][entry->prev].next = entry->next; + entry->next = sSfxBankFreeListStart[bankId]; + entry->prev = 0xFF; + gSfxBanks[bankId][sSfxBankFreeListStart[bankId]].prev = entryIndex; + sSfxBankFreeListStart[bankId] = entryIndex; + entry->state = SFX_STATE_EMPTY; + + for (i = 0; i < gChannelsPerBank[gSfxChannelLayout][bankId]; i++) { + if (gActiveSfx[bankId][i].entryIndex == entryIndex) { + gActiveSfx[bankId][i].entryIndex = 0xFF; + i = gChannelsPerBank[gSfxChannelLayout][bankId]; + } + } +} + +void AudioSfx_ChooseActiveSfx(u8 bankId) { + u8 numChosenSfx = 0; + u8 numChannels; + u8 entryIndex; + u8 i; + u8 j; + u8 k; + u8 sfxImportance; + u8 needNewSfx; + u8 chosenEntryIndex; + s32 pad; + SfxBankEntry* entry; + ActiveSfx chosenSfx[MAX_CHANNELS_PER_BANK]; + ActiveSfx* activeSfx; + f32 entryPosY; + f32 entryPosX; + + for (i = 0; i < MAX_CHANNELS_PER_BANK; i++) { + chosenSfx[i].priority = 0x7FFFFFFF; + chosenSfx[i].entryIndex = 0xFF; + } + + entryIndex = gSfxBanks[bankId][0].next; + k = 0; + + // Delete stale sfx and prioritize remaining sfx into the gActiveSfx arrays + while (entryIndex != 0xFF) { + + // Update the freshness for an "all-frame" sfx if it is still queued + if ((gSfxBanks[bankId][entryIndex].state == SFX_STATE_QUEUED) && + (gSfxBanks[bankId][entryIndex].sfxId & SFX_FLAG_MASK)) { + gSfxBanks[bankId][entryIndex].freshness--; + + // If a "one-frame" sfx is still in "SFX_STATE_PLAYING_ONE_FRAME", then remove the sfx + } else if (!(gSfxBanks[bankId][entryIndex].sfxId & SFX_FLAG_MASK) && + (gSfxBanks[bankId][entryIndex].state == SFX_STATE_PLAYING_ONE_FRAME)) { + // CHAN_UPD_SCRIPT_IO (ioPort 0, force stop sfx in seq 0) + AudioThread_QueueCmdS8( + (0x6 << 24) | (SEQ_PLAYER_SFX << 16) | (gSfxBanks[bankId][entryIndex].channelIndex << 8), 0); + AudioSfx_RemoveBankEntry(bankId, entryIndex); + } + + // If a "all-frame" sfx goes 2 frames in the "queued" state + // (because it is too low priority), then remove the sfx + if (gSfxBanks[bankId][entryIndex].freshness == 0) { + AudioSfx_RemoveBankEntry(bankId, entryIndex); + } else if (gSfxBanks[bankId][entryIndex].state != SFX_STATE_EMPTY) { + // process the entry + entry = &gSfxBanks[bankId][entryIndex]; + + // Recompute distSq each frame since the sound's position may have changed + // (later converted into dist) + if (&gSfxDefaultPos.x == entry[0].posX) { + entry->dist = 0.0f; + } else { + entryPosY = *entry->posY * 1; + entryPosX = *entry->posX * 0.5f; + entry->dist = (SQ(entryPosX) + SQ(entryPosY) + SQ(*entry->posZ)) / 10.0f; + } + + // Recompute priority, possibly based on sfx position relative to the camera. + // (Note that the priority is the opposite of importance; lower is more preserved) + sfxImportance = entry->sfxImportance; + + if (entry->sfxParams & SFX_FLAG_PRIORITY_NO_DIST) { + // Priority is independent of distance + entry->priority = SQ(0xFF - sfxImportance) * SQ(76); + } else { + // Priority value increases with distance (more likely to eject) + if (entry->dist > 0x7FFFFFD0) { + // max distance + entry->dist = 0x70000008; + } + + entry->priority = (u32)entry->dist + (SQ(0xFF - sfxImportance) * SQ(76)); + if (*entry->posZ < 0.0f) { + entry->priority += (s32)(-*entry->posZ * 6.0f); + } + } + + // Sfx is too far away, do not consider for chosen sfx + if (entry->dist > SQ(1e5f)) { + + // If too far away and also playing, stop playing + if (entry->state == SFX_STATE_PLAYING) { + // CHAN_UPD_SCRIPT_IO (ioPort 0, force stop sfx in seq 0) + AudioThread_QueueCmdS8((0x6 << 24) | (SEQ_PLAYER_SFX << 16) | (entry->channelIndex << 8), 0); + if (entry->sfxId & SFX_FLAG_MASK) { + AudioSfx_RemoveBankEntry(bankId, entryIndex); + entryIndex = k; + } + } + } else { + // Loop through all channels allocated to a specific bank + // Choose which sfx from gSfxBanks to play + // This includes all sfx requests and sfx already playing + // Sort all current sfx entries in gSfxBanks by priority + // This is where the "active" sfx are chosen + numChannels = gChannelsPerBank[gSfxChannelLayout][bankId]; + + for (i = 0; i < numChannels; i++) { + // Sort all sfx entries by priority + if (chosenSfx[i].priority >= entry->priority) { + // Update the number of sfx to attampt to play + if (numChosenSfx < gChannelsPerBank[gSfxChannelLayout][bankId]) { + numChosenSfx++; + } + + for (j = numChannels - 1; j > i; j--) { + chosenSfx[j].priority = chosenSfx[j - 1].priority; + chosenSfx[j].entryIndex = chosenSfx[j - 1].entryIndex; + } + + chosenSfx[i].priority = entry->priority; + chosenSfx[i].entryIndex = entryIndex; + i = numChannels; // make this the last pass through the loop, here equivalent to "break" + } + } + } + + k = entryIndex; + } + + entryIndex = gSfxBanks[bankId][k].next; + } + + // If a sfx is chosen, update its state + for (i = 0; i < numChosenSfx; i++) { + entry = &gSfxBanks[bankId][chosenSfx[i].entryIndex]; + + if (entry->state == SFX_STATE_QUEUED) { + // sfx is a new entry + entry->state = SFX_STATE_READY; + } else if (entry->state == SFX_STATE_PLAYING) { + // sfx is already playing + entry->state = SFX_STATE_PLAYING_REFRESH; + } + } + + // Apply the chosenSfx to the activeSfx in each channel + numChannels = gChannelsPerBank[gSfxChannelLayout][bankId]; + for (i = 0; i < numChannels; i++) { + needNewSfx = false; + activeSfx = &gActiveSfx[bankId][i]; + + // Check if a sfx is already in the channel + if (activeSfx->entryIndex == 0xFF) { + // No sfx playing in the channel + // Available for use + needNewSfx = true; + } else { + // The channel is already playing a sfx + // Get the entry of the sfx playing + entry = &gSfxBanks[bankId][activeSfx[0].entryIndex]; + + // Check the state of the sfx playing + if (entry->state == SFX_STATE_PLAYING) { + if (entry->sfxId & SFX_FLAG_MASK) { + // For "all-frames" sfx, remove the entry + AudioSfx_RemoveBankEntry(bankId, activeSfx->entryIndex); + } else { + // For "one-frame" sfx, reset the state to queued + entry->state = SFX_STATE_QUEUED; + entry->freshness = 0x80; + } + needNewSfx = true; + } else if (entry->state == SFX_STATE_EMPTY) { + // The sfx already in the channel is empty + // Can replace the sfx + activeSfx->entryIndex = 0xFF; + needNewSfx = true; + } else { + // Sfx is already playing as it should, nothing to do. + for (j = 0; j < numChannels; j++) { + if (activeSfx->entryIndex == chosenSfx[j].entryIndex) { + chosenSfx[j].entryIndex = 0xFF; + j = numChannels; + } + } + + numChosenSfx--; + } + } + + // enter the new sfx into the activeSfx + if (needNewSfx == true) { + for (j = 0; j < numChannels; j++) { + chosenEntryIndex = chosenSfx[j].entryIndex; + if ((chosenEntryIndex != 0xFF) && + (gSfxBanks[bankId][chosenEntryIndex].state != SFX_STATE_PLAYING_REFRESH)) { + for (k = 0; k < numChannels; k++) { + if (chosenEntryIndex == gActiveSfx[bankId][k].entryIndex) { + needNewSfx = false; + k = numChannels; // "break; i.e. force for-loop to end" + } + } + + if (needNewSfx == true) { + activeSfx->entryIndex = chosenEntryIndex; + chosenSfx[j].entryIndex = 0xFF; + j = numChannels + 1; + numChosenSfx--; + } + } + } + if (j == numChannels) { + // nothing found + activeSfx->entryIndex = 0xFF; + } + } + } +} + +void AudioSfx_PlayActiveSfx(u8 bankId) { + u8 entryIndex; + SequenceChannel* channel; + SfxBankEntry* entry; + u8 i; + u8 ioPort5Data; + + for (i = 0; i < gChannelsPerBank[gSfxChannelLayout][bankId]; i++) { + entryIndex = gActiveSfx[bankId][i].entryIndex; + // If entry is not empty + if (entryIndex != 0xFF) { + entry = &gSfxBanks[bankId][entryIndex]; + channel = gAudioContext.seqPlayers[SEQ_PLAYER_SFX].channels[sCurSfxPlayerChannelIndex]; + + if (entry->state == SFX_STATE_READY) { + // Initialize a sfx (new sfx request) + entry->channelIndex = sCurSfxPlayerChannelIndex; + if (entry->sfxParams & SFX_FLAG_LOWER_VOLUME_BGM) { + AudioSfx_LowerBgmVolume(sCurSfxPlayerChannelIndex); + } + + // Add noise that will offset the frequency of the sfx + if ((entry->sfxParams & SFX_PARAM_RAND_FREQ_RAISE_MASK) != (0 << SFX_PARAM_RAND_FREQ_RAISE_SHIFT)) { + switch (entry->sfxParams & SFX_PARAM_RAND_FREQ_RAISE_MASK) { + case (1 << SFX_PARAM_RAND_FREQ_RAISE_SHIFT): + entry->randFreq = AudioThread_NextRandom() & 0xF; + break; + + case (2 << SFX_PARAM_RAND_FREQ_RAISE_SHIFT): + entry->randFreq = AudioThread_NextRandom() & 0x1F; + break; + + case (3 << SFX_PARAM_RAND_FREQ_RAISE_SHIFT): + entry->randFreq = AudioThread_NextRandom() & 0x3F; + break; + + default: + entry->randFreq = 0; + break; + } + } + + // Calculate all the properties of sfx + AudioSfx_SetProperties(bankId, entryIndex, sCurSfxPlayerChannelIndex); + + // CHAN_UPD_SCRIPT_IO (ioPort 0, enable the sfx to play in seq 0) + AudioThread_QueueCmdS8((0x6 << 24) | (SEQ_PLAYER_SFX << 16) | ((sCurSfxPlayerChannelIndex & 0xFF) << 8), + 1); + + // CHAN_UPD_SCRIPT_IO (ioPort 4, write the lower bits sfx index to seq 0 so it can find the right code + // to execute) + AudioThread_QueueCmdS8((0x6 << 24) | (SEQ_PLAYER_SFX << 16) | + ((sCurSfxPlayerChannelIndex & 0xFF) << 8) | 4, + entry->sfxId & 0xFF); + + // If the sfx bank has more than 255 entries (greater than a u8 can store), + // then store the Id in upper and lower bits + if (gIsLargeSfxBank[bankId]) { + // Store upper bits + ioPort5Data = ((u8)((entry->sfxId & 0x300) >> 7) + (u8)((entry->sfxId & 0xFF) >> 7)); + } else { + ioPort5Data = 0; + } + + if ((entry->sfxParams & SFX_FLAG_8) && (entry->freshness == 0x80)) { + ioPort5Data += 0x80; + } + + if (D_801D6608[bankId]) { + // CHAN_UPD_SCRIPT_IO (ioPort 5, write the upper bits sfx index and a flag to seq 0, for banks with + // > 0xFF entries) + AudioThread_QueueCmdS8((0x6 << 24) | (SEQ_PLAYER_SFX << 16) | + ((sCurSfxPlayerChannelIndex & 0xFF) << 8) | 5, + ioPort5Data); + } + + // Update playing state + if (entry->sfxId & SFX_FLAG_MASK) { + // "all-frames" sfx + entry->state = SFX_STATE_PLAYING; + } else { + // "one-frame" sfx + entry->state = SFX_STATE_PLAYING_ONE_FRAME; + } + } else if ((u8)channel->soundScriptIO[1] == 0xFF) { + // Signal from seq 0 that the sfx is finished playing. Remove entry + AudioSfx_RemoveBankEntry(bankId, entryIndex); + } else if (entry->state == SFX_STATE_PLAYING_REFRESH) { + // Sfx is playing but a refresh is requested + AudioSfx_SetProperties(bankId, entryIndex, sCurSfxPlayerChannelIndex); + + // Update playing state + if (entry->sfxId & SFX_FLAG_MASK) { + // "all-frames" sfx + entry->state = SFX_STATE_PLAYING; + } else { + // "one-frame" sfx + entry->state = SFX_STATE_PLAYING_ONE_FRAME; + } + } + } + + sCurSfxPlayerChannelIndex++; + } +} + +void AudioSfx_StopByBank(u8 bankId) { + SfxBankEntry* entry; + s32 pad; + SfxBankEntry entryToRemove; + u8 entryIndex = gSfxBanks[bankId][0].next; + + while (entryIndex != 0xFF) { + entry = &gSfxBanks[bankId][entryIndex]; + if (entry->state >= SFX_STATE_PLAYING_REFRESH) { + AudioThread_QueueCmdS8((0x6 << 24) | (SEQ_PLAYER_SFX << 16) | ((entry->channelIndex & 0xFF) << 8), 0); + } + + if (entry->state != SFX_STATE_EMPTY) { + AudioSfx_RemoveBankEntry(bankId, entryIndex); + } + entryIndex = gSfxBanks[bankId][0].next; + } + + entryToRemove.sfxId = bankId << 12; + AudioSfx_RemoveMatchingRequests(SFX_RM_REQ_BY_BANK, &entryToRemove); +} + +void AudioSfx_StopByPosAndBankImpl(u8 bankId, Vec3f* pos) { + SfxBankEntry* entry; + u8 entryIndex = gSfxBanks[bankId][0].next; + u8 prevEntryIndex = 0; + + while (entryIndex != 0xFF) { + entry = &gSfxBanks[bankId][entryIndex]; + if (entry->posX == &pos->x) { + if (entry->state >= SFX_STATE_PLAYING_REFRESH) { + AudioThread_QueueCmdS8((0x6 << 24) | (SEQ_PLAYER_SFX << 16) | ((entry->channelIndex & 0xFF) << 8), 0); + } + + if (entry->state != SFX_STATE_EMPTY) { + AudioSfx_RemoveBankEntry(bankId, entryIndex); + } + } else { + prevEntryIndex = entryIndex; + } + + entryIndex = gSfxBanks[bankId][prevEntryIndex].next; + } +} + +void AudioSfx_StopByPosAndBank(u8 bankId, Vec3f* pos) { + SfxBankEntry entryToRemove; + + AudioSfx_StopByPosAndBankImpl(bankId, pos); + entryToRemove.sfxId = bankId << 12; + entryToRemove.posX = &pos->x; + AudioSfx_RemoveMatchingRequests(SFX_RM_REQ_BY_POS_AND_BANK, &entryToRemove); +} + +void AudioSfx_StopByPos(Vec3f* pos) { + u8 bankId; + SfxBankEntry entryToRemove; + + for (bankId = 0; bankId < ARRAY_COUNT(gSfxBanks); bankId++) { + AudioSfx_StopByPosAndBankImpl(bankId, pos); + } + + entryToRemove.posX = &pos->x; + AudioSfx_RemoveMatchingRequests(SFX_RM_REQ_BY_POS, &entryToRemove); +} + +void AudioSfx_StopByPosAndId(Vec3f* pos, u16 sfxId) { + SfxBankEntry* entry; + u8 entryIndex = gSfxBanks[SFX_BANK(sfxId)][0].next; + u8 prevEntryIndex = 0; + SfxBankEntry entryToRemove; + + while (entryIndex != 0xFF) { + entry = &gSfxBanks[SFX_BANK(sfxId)][entryIndex]; + if ((entry->posX == &pos->x) && (entry->sfxId == sfxId)) { + if (entry->state >= SFX_STATE_PLAYING_REFRESH) { + AudioThread_QueueCmdS8((0x6 << 24) | (SEQ_PLAYER_SFX << 16) | ((entry->channelIndex & 0xFF) << 8), 0); + } + + if (entry->state != SFX_STATE_EMPTY) { + AudioSfx_RemoveBankEntry(SFX_BANK(sfxId), entryIndex); + } + entryIndex = 0xFF; + } else { + prevEntryIndex = entryIndex; + } + + if (entryIndex != 0xFF) { + entryIndex = gSfxBanks[SFX_BANK(sfxId)][prevEntryIndex].next; + } + } + + entryToRemove.posX = &pos->x; + entryToRemove.sfxId = sfxId; + AudioSfx_RemoveMatchingRequests(SFX_RM_REQ_BY_POS_AND_ID, &entryToRemove); +} + +void AudioSfx_StopByTokenAndId(u8 token, u16 sfxId) { + SfxBankEntry* entry; + u8 entryIndex = gSfxBanks[SFX_BANK(sfxId)][0].next; + u8 prevEntryIndex = 0; + SfxBankEntry entryToRemove; + + while (entryIndex != 0xFF) { + entry = &gSfxBanks[SFX_BANK(sfxId)][entryIndex]; + if ((entry->token == token) && (entry->sfxId == sfxId)) { + if (entry->state >= SFX_STATE_PLAYING_REFRESH) { + AudioThread_QueueCmdS8((0x6 << 24) | (SEQ_PLAYER_SFX << 16) | ((entry->channelIndex & 0xFF) << 8), 0); + } + + if (entry->state != SFX_STATE_EMPTY) { + AudioSfx_RemoveBankEntry(SFX_BANK(sfxId), entryIndex); + } + } else { + prevEntryIndex = entryIndex; + } + + if (entryIndex != 0xFF) { + entryIndex = gSfxBanks[SFX_BANK(sfxId)][prevEntryIndex].next; + } + } + + entryToRemove.token = token; + entryToRemove.sfxId = sfxId; + AudioSfx_RemoveMatchingRequests(SFX_RM_REQ_BY_TOKEN_AND_ID, &entryToRemove); +} + +void AudioSfx_StopById(u32 sfxId) { + SfxBankEntry* entry; + u8 entryIndex = gSfxBanks[SFX_BANK(sfxId)][0].next; + u8 prevEntryIndex = 0; + SfxBankEntry entryToRemove; + + while (entryIndex != 0xFF) { + entry = &gSfxBanks[SFX_BANK(sfxId)][entryIndex]; + if (entry->sfxId == sfxId) { + if (entry->state >= SFX_STATE_PLAYING_REFRESH) { + AudioThread_QueueCmdS8((0x6 << 24) | (SEQ_PLAYER_SFX << 16) | ((entry->channelIndex & 0xFF) << 8), 0); + } + if (entry->state != SFX_STATE_EMPTY) { + AudioSfx_RemoveBankEntry(SFX_BANK(sfxId), entryIndex); + } + } else { + prevEntryIndex = entryIndex; + } + + entryIndex = gSfxBanks[SFX_BANK(sfxId)][prevEntryIndex].next; + } + + entryToRemove.sfxId = sfxId; + AudioSfx_RemoveMatchingRequests(SFX_RM_REQ_BY_ID, &entryToRemove); +} + +void AudioSfx_ProcessRequests(void) { + if (gAudioContext.seqPlayers[SEQ_PLAYER_SFX].enabled) { + while (sSfxRequestWriteIndex != sSfxRequestReadIndex) { + AudioSfx_ProcessRequest(); + sSfxRequestReadIndex++; + } + } +} + +/** + * Unused + */ +void AudioSfx_SetBankLerp(u8 bankId, u8 target, u16 delay) { + if (delay == 0) { + delay++; + } + + sSfxBankLerp[bankId].target = target / 127.0f; + sSfxBankLerp[bankId].remainingFrames = delay; + sSfxBankLerp[bankId].step = ((sSfxBankLerp[bankId].value - sSfxBankLerp[bankId].target) / delay); +} + +/** + * Unused + */ +void AudioSfx_StepBankLerp(u8 bankId) { + if (sSfxBankLerp[bankId].remainingFrames != 0) { + sSfxBankLerp[bankId].remainingFrames--; + + if (sSfxBankLerp[bankId].remainingFrames != 0) { + sSfxBankLerp[bankId].value -= sSfxBankLerp[bankId].step; + } else { + sSfxBankLerp[bankId].value = sSfxBankLerp[bankId].target; + } + } +} + +void AudioSfx_ProcessActiveSfx(void) { + u8 bankId; + + if (gAudioContext.seqPlayers[SEQ_PLAYER_SFX].enabled) { + sCurSfxPlayerChannelIndex = 0; + + for (bankId = 0; bankId < ARRAY_COUNT(gSfxBanks); bankId++) { + AudioSfx_ChooseActiveSfx(bankId); + AudioSfx_PlayActiveSfx(bankId); + AudioSfx_StepBankLerp(bankId); + } + } +} + +u8 AudioSfx_IsPlaying(u32 sfxId) { + SfxBankEntry* entry; + u8 entryIndex = gSfxBanks[SFX_BANK(sfxId)][0].next; + + while (entryIndex != 0xFF) { + entry = &gSfxBanks[SFX_BANK(sfxId)][entryIndex]; + if (entry->sfxId == sfxId) { + return true; + } + entryIndex = entry->next; + } + + return false; +} + +void AudioSfx_Reset(void) { + u8 bankId; + u8 i; + u8 entryIndex; + + sSfxRequestWriteIndex = 0; + sSfxRequestReadIndex = 0; + sSfxChannelLowVolumeFlag = 0; + + for (bankId = 0; bankId < ARRAY_COUNT(gSfxBanks); bankId++) { + sSfxBankListEnd[bankId] = 0; + sSfxBankFreeListStart[bankId] = 1; + sSfxBankUnused[bankId] = 0; + gSfxBankMuted[bankId] = false; + sSfxBankLerp[bankId].value = 1.0f; + sSfxBankLerp[bankId].remainingFrames = 0; + } + + for (bankId = 0; bankId < ARRAY_COUNT(gSfxBanks); bankId++) { + for (i = 0; i < MAX_CHANNELS_PER_BANK; i++) { + gActiveSfx[bankId][i].entryIndex = 0xFF; + } + } + + for (bankId = 0; bankId < ARRAY_COUNT(gSfxBanks); bankId++) { + gSfxBanks[bankId][0].prev = 0xFF; + gSfxBanks[bankId][0].next = 0xFF; + + for (i = 1; i < sSfxBankSizes[bankId] - 1; i++) { + gSfxBanks[bankId][i].prev = i - 1; + gSfxBanks[bankId][i].next = i + 1; + } + + gSfxBanks[bankId][i].prev = i - 1; + gSfxBanks[bankId][i].next = 0xFF; + } +} diff --git a/src/code/audio/code_801A7B10.c b/src/code/audio/code_801A7B10.c index 6d3faaeab..f2f37a013 100644 --- a/src/code/audio/code_801A7B10.c +++ b/src/code/audio/code_801A7B10.c @@ -1,6 +1,6 @@ #include "global.h" -#pragma GLOBAL_ASM("asm/non_matchings/code/code_801A7B10/func_801A7B10.s") +#pragma GLOBAL_ASM("asm/non_matchings/code/code_801A7B10/Audio_StartSequence.s") #pragma GLOBAL_ASM("asm/non_matchings/code/code_801A7B10/func_801A7D04.s") diff --git a/src/code/audioMgr.c b/src/code/audioMgr.c index ee6014137..ce21bda37 100644 --- a/src/code/audioMgr.c +++ b/src/code/audioMgr.c @@ -78,7 +78,7 @@ void AudioMgr_ThreadEntry(void* arg) { s16* msg = NULL; s32 exit; - func_801A4C30(); + Audio_Init(); AudioLoad_SetDmaHandler(DmaMgr_DmaHandler); func_801A4D00(); osSendMesg(&audioMgr->lockMsgQ, NULL, OS_MESG_BLOCK); diff --git a/src/code/code_800E8EA0.c b/src/code/code_800E8EA0.c index d95f53269..7485f2d3a 100644 --- a/src/code/code_800E8EA0.c +++ b/src/code/code_800E8EA0.c @@ -1,107 +1,147 @@ #include "global.h" -void func_800E8EA0(GlobalContext* globalCtx, Actor* actor, u16 textId) { - func_80151938(globalCtx, textId); +void Actor_ContinueText(PlayState* play, Actor* actor, u16 textId) { + func_80151938(play, 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) { - Player* player = GET_PLAYER(globalCtx); - s16 sVar3; - Vec3f local_14; +/** + * 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(PlayState* play, Actor* actor, Vec3s* headRot, Vec3s* torsoRot, f32 focusHeight) { + Player* player = GET_PLAYER(play); + 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 = ABS_ALT(BINANG_SUB(actor->yawTowardsPlayer, actor->shape.rot.y)); - if (sVar3 >= 0x4300) { - func_800E8F08(param_3, param_4); - return 0; + if (!((play->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 ((play->csCtx.state != 0) || gDbgCamEnabled) { + target = play->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) { - Player* player = GET_PLAYER(globalCtx); - s16 sVar3; - Vec3f local_14; +/** + * 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(PlayState* play, Actor* actor, Vec3s* headRot, Vec3s* torsoRot, Vec3f focusPos) { + Player* player = GET_PLAYER(play); + s16 yaw; + Vec3f target; - actor->focus.pos = param_5; + actor->focus.pos = focusPos; - if (((globalCtx->csCtx).state == 0) && (D_801D0D50 == 0)) { - sVar3 = ABS_ALT(BINANG_SUB(actor->yawTowardsPlayer, actor->shape.rot.y)); - if (sVar3 >= 0x4300) { - func_800E8F08(param_3, param_4); - return 0; + if (!((play->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 ((play->csCtx.state != 0) || gDbgCamEnabled) { + target = play->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 5dee17fb5..ee2070610 100644 --- a/src/code/code_8012EC80.c +++ b/src/code/code_8012EC80.c @@ -133,7 +133,7 @@ void* gItemIcons[] = { 0x08021000, // ITEM_ZORA_EGG 0x08022000, // ITEM_GOLD_DUST 0x08023000, // ITEM_MUSHROOM - 0x08024000, // ITEM_SEA_HORSE + 0x08024000, // ITEM_SEAHORSE 0x08025000, // ITEM_CHATEAU 0x08026000, // ITEM_HYLIAN_LOACH 0x08027000, // ITEM_OBABA_DRINK @@ -145,7 +145,7 @@ void* gItemIcons[] = { 0x0802D000, // ITEM_ROOM_KEY 0x0802E000, // ITEM_LETTER_MAMA 0x0802F000, // ITEM_LETTER_TO_KAFEI - 0x08030000, // ITEM_PENDANT_MEMORIES + 0x08030000, // ITEM_PENDANT_OF_MEMORIES 0x08031000, // ITEM_TINGLE_MAP 0x08032000, // ITEM_MASK_DEKU 0x08033000, // ITEM_MASK_GORON @@ -189,7 +189,7 @@ void* gItemIcons[] = { 0x08059000, // ITEM_WALLET_DEFAULT 0x0805A000, // ITEM_WALLET_ADULT 0x0805B000, // ITEM_WALLET_GIANT - 0x0805C000, // ITEM_FISHING_POLE + 0x0805C000, // ITEM_FISHING_ROD 0x0805D000, // ITEM_REMAINS_ODOLWA 0x0805E000, // ITEM_REMAINS_GOHT 0x0805F000, // ITEM_REMAINS_GYORG @@ -268,7 +268,7 @@ u8 gItemSlots[] = { SLOT_BOTTLE_1, // ITEM_ZORA_EGG SLOT_BOTTLE_1, // ITEM_GOLD_DUST SLOT_BOTTLE_1, // ITEM_MUSHROOM - SLOT_BOTTLE_1, // ITEM_SEA_HORSE + SLOT_BOTTLE_1, // ITEM_SEAHORSE SLOT_BOTTLE_1, // ITEM_CHATEAU SLOT_BOTTLE_1, // ITEM_HYLIAN_LOACH SLOT_BOTTLE_1, // ITEM_OBABA_DRINK @@ -280,7 +280,7 @@ u8 gItemSlots[] = { SLOT_TRADE_KEY_MAMA, // ITEM_ROOM_KEY SLOT_TRADE_KEY_MAMA, // ITEM_LETTER_MAMA SLOT_TRADE_COUPLE, // ITEM_LETTER_TO_KAFEI - SLOT_TRADE_COUPLE, // ITEM_PENDANT_MEMORIES + SLOT_TRADE_COUPLE, // ITEM_PENDANT_OF_MEMORIES SLOT_TRADE_COUPLE, // ITEM_TINGLE_MAP SLOT_MASK_DEKU, // ITEM_MASK_DEKU SLOT_MASK_GORON, // ITEM_MASK_GORON @@ -348,7 +348,7 @@ s16 gItemPrices[] = { 20, // ITEM_ZORA_EGG 200, // ITEM_GOLD_DUST 5, // ITEM_MUSHROOM - 0, // ITEM_SEA_HORSE + 0, // ITEM_SEAHORSE 200, // ITEM_CHATEAU 20, // ITEM_HYLIAN_LOACH 0, // ITEM_OBABA_DRINK @@ -360,7 +360,7 @@ s16 gItemPrices[] = { 0, // ITEM_ROOM_KEY 0, // ITEM_LETTER_MAMA 0, // ITEM_LETTER_KAFEI - 0, // ITEM_PENDANT_MEMORIES + 0, // ITEM_PENDANT_OF_MEMORIES 0, // ITEM_TINGLE_MAP }; @@ -474,15 +474,15 @@ u16 gScenesPerRegion[11][27] = { }, }; -s32 Inventory_GetBtnBItem(GlobalContext* globalCtx) { +s32 Inventory_GetBtnBItem(PlayState* play) { if (gSaveContext.buttonStatus[0] == BTN_DISABLED) { return ITEM_NONE; } else if (gSaveContext.unk_1015 == ITEM_NONE) { return ITEM_NONE; } else if (CUR_FORM_EQUIP(EQUIP_SLOT_B) == ITEM_NONE) { - if (globalCtx->interfaceCtx.unk_21C != 0) { - if (globalCtx->interfaceCtx.unk_21E != 0) { - return globalCtx->interfaceCtx.unk_21E; + if (play->interfaceCtx.unk_21C != 0) { + if (play->interfaceCtx.bButtonDoAction != 0) { + return play->interfaceCtx.bButtonDoAction; } } return ITEM_NONE; @@ -495,18 +495,18 @@ s32 Inventory_GetBtnBItem(GlobalContext* globalCtx) { * Only changes shield */ void Inventory_ChangeEquipment(s16 value) { - SET_EQUIP_VALUE(EQUIP_SHIELD, value); + SET_EQUIP_VALUE(EQUIP_TYPE_SHIELD, value); } /** * Only deletes shield, equipment argument unused and is a remnant of OoT */ -u8 Inventory_DeleteEquipment(GlobalContext* globalCtx, s16 equipment) { - Player* player = GET_PLAYER(globalCtx); +u8 Inventory_DeleteEquipment(PlayState* play, s16 equipment) { + Player* player = GET_PLAYER(play); - if (GET_CUR_EQUIP_VALUE(EQUIP_SHIELD) != 0) { - SET_EQUIP_VALUE(EQUIP_SHIELD, 0); - Player_SetEquipmentData(globalCtx, player); + if (GET_CUR_EQUIP_VALUE(EQUIP_TYPE_SHIELD) != EQUIP_VALUE_SHIELD_NONE) { + SET_EQUIP_VALUE(EQUIP_TYPE_SHIELD, EQUIP_VALUE_SHIELD_NONE); + Player_SetEquipmentData(play, player); return true; } @@ -719,12 +719,12 @@ s16 Inventory_GetSkullTokenCount(s16 sceneIndex) { } } -void Inventory_SaveLotteryCodeGuess(GlobalContext* globalCtx) { +void Inventory_SaveLotteryCodeGuess(PlayState* play) { u16 lotteryCodeGuess; - 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 + lotteryCodeGuess = ((play->msgCtx.unk12054[0] & 0xF) << 8); // First Digit + lotteryCodeGuess |= ((play->msgCtx.unk12054[1] & 0xF) << 4); // Second Digit + lotteryCodeGuess |= (play->msgCtx.unk12054[2] & 0xF); // Third Digit gSaveContext.save.lotteryCodeGuess = (gSaveContext.save.lotteryCodeGuess & 0xFFFF0000) | (lotteryCodeGuess & 0xFFFF); } 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/code_8013EC10.c b/src/code/code_8013EC10.c deleted file mode 100644 index b44ed73a8..000000000 --- a/src/code/code_8013EC10.c +++ /dev/null @@ -1,19 +0,0 @@ -#include "global.h" - -#pragma GLOBAL_ASM("asm/non_matchings/code/code_8013EC10/func_8013EC10.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/code_8013EC10/func_8013EC44.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/code_8013EC10/func_8013ECE0.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/code_8013EC10/func_8013ED9C.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/code_8013EC10/func_8013EDD0.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/code_8013EC10/func_8013EE04.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/code_8013EC10/func_8013EE24.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/code_8013EC10/func_8013EE38.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/code_8013EC10/func_8013EE48.s") diff --git a/src/code/code_80172BC0.c b/src/code/code_80172BC0.c index 93aee323f..94b55d4df 100644 --- a/src/code/code_80172BC0.c +++ b/src/code/code_80172BC0.c @@ -1,3 +1,15 @@ #include "global.h" -#pragma GLOBAL_ASM("asm/non_matchings/code/code_80172BC0/func_80172BC0.s") +const u8 sSfxBankIds[] = { + BANK_PLAYER, BANK_ITEM, BANK_ENV, BANK_ENEMY, BANK_SYSTEM, BANK_OCARINA, BANK_VOICE, +}; + +void AudioMgr_StopAllSfxExceptSystem(void) { + volatile const u8* bankIdPtr; + + for (bankIdPtr = sSfxBankIds; bankIdPtr < (sSfxBankIds + ARRAY_COUNT(sSfxBankIds)); bankIdPtr++) { + if (*bankIdPtr != BANK_SYSTEM) { + AudioSfx_StopByBank(*bankIdPtr); + } + } +} diff --git a/src/code/code_80182CE0.c b/src/code/code_80182CE0.c deleted file mode 100644 index 6ff8736e5..000000000 --- a/src/code/code_80182CE0.c +++ /dev/null @@ -1,7 +0,0 @@ -#include "global.h" - -#pragma GLOBAL_ASM("asm/non_matchings/code/code_80182CE0/func_80182CE0.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/code_80182CE0/func_80183020.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/code_80182CE0/func_80183058.s") diff --git a/src/code/flg_set.c b/src/code/flg_set.c index 53be7b68d..0bc978160 100644 --- a/src/code/flg_set.c +++ b/src/code/flg_set.c @@ -10,6 +10,7 @@ * Hold Start and press B: clear all weekEventReg and eventInf flags */ #include "global.h" +#include "overlays/kaleido_scope/ovl_kaleido_scope/z_kaleido_scope.h" static FlagSetEntry sFlagEntries[] = { { &gSaveContext.save.weekEventReg[0], "week_event_reg[0]" }, @@ -134,8 +135,8 @@ static u32 sCurrentBit = 0; static s32 sTimer = 0; void FlagSet_Update(GameState* gameState) { - GlobalContext* globalCtx = (GlobalContext*)gameState; - Input* input = CONTROLLER1(globalCtx); + PlayState* play = (PlayState*)gameState; + Input* input = CONTROLLER1(&play->state); /* Intra-byte navigation */ @@ -255,7 +256,7 @@ void FlagSet_Update(GameState* gameState) { // Pressing B will exit } else if (CHECK_BTN_ALL(input->press.button, BTN_B)) { - globalCtx->pauseCtx.debugState = 0; + play->pauseCtx.debugEditor = DEBUG_EDITOR_NONE; } } diff --git a/src/code/game.c b/src/code/game.c index 2713be299..84743b8c5 100644 --- a/src/code/game.c +++ b/src/code/game.c @@ -1,5 +1,6 @@ #include "global.h" #include "system_malloc.h" +#include "z64rumble.h" s32 gFramerateDivisor = 1; f32 gFramerateDivisorF = 1.0f; @@ -52,7 +53,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); } } } @@ -191,7 +192,7 @@ void GameState_Realloc(GameState* gameState, size_t size) { void GameState_Init(GameState* gameState, GameStateFunc init, GraphicsContext* gfxCtx) { gameState->gfxCtx = gfxCtx; - gameState->frames = 0U; + gameState->frames = 0; gameState->main = NULL; gameState->destroy = NULL; gameState->running = 1; @@ -200,7 +201,7 @@ void GameState_Init(GameState* gameState, GameStateFunc init, GraphicsContext* g gfxCtx->xScale = gViConfigXScale; gfxCtx->yScale = gViConfigYScale; gameState->nextGameStateInit = NULL; - gameState->nextGameStateSize = 0U; + gameState->nextGameStateSize = 0; { s32 requiredScopeTemp; @@ -213,17 +214,17 @@ 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(); + Rumble_Init(); osSendMesg(&gameState->gfxCtx->queue, NULL, OS_MESG_BLOCK); } } void GameState_Destroy(GameState* gameState) { - func_80172BC0(); + AudioMgr_StopAllSfxExceptSystem(); func_8019E014(); osRecvMesg(&gameState->gfxCtx->queue, NULL, OS_MESG_BLOCK); @@ -231,11 +232,11 @@ void GameState_Destroy(GameState* gameState) { gameState->destroy(gameState); } - func_8013EDD0(); + Rumble_Destroy(); 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..481aa1da0 100644 --- a/src/code/graph.c +++ b/src/code/graph.c @@ -13,7 +13,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); @@ -68,7 +68,7 @@ GameStateOverlay* Graph_GetNextGameState(GameState* gameState) { if (gameStateInit == (GameStateFunc)TitleSetup_Init) { return &gGameStateOverlayTable[0]; } - if (gameStateInit == (GameStateFunc)Select_Init) { + if (gameStateInit == (GameStateFunc)MapSelect_Init) { return &gGameStateOverlayTable[1]; } if (gameStateInit == (GameStateFunc)Title_Init) { diff --git a/src/code/padmgr.c b/src/code/padmgr.c index 0d539126a..077ef1b2b 100644 --- a/src/code/padmgr.c +++ b/src/code/padmgr.c @@ -31,9 +31,9 @@ #pragma GLOBAL_ASM("asm/non_matchings/code/padmgr/func_8017544C.s") -#pragma GLOBAL_ASM("asm/non_matchings/code/padmgr/func_80175474.s") +#pragma GLOBAL_ASM("asm/non_matchings/code/padmgr/PadMgr_RumbleSet.s") -#pragma GLOBAL_ASM("asm/non_matchings/code/padmgr/func_801754C0.s") +#pragma GLOBAL_ASM("asm/non_matchings/code/padmgr/PadMgr_ControllerHasRumblePak.s") #pragma GLOBAL_ASM("asm/non_matchings/code/padmgr/Padmgr_CalcStickEdges.s") diff --git a/src/code/sched.c b/src/code/sched.c index 927a48f66..5f9cdf236 100644 --- a/src/code/sched.c +++ b/src/code/sched.c @@ -1,3 +1,4 @@ +#include "prevent_bss_reordering.h" #include "global.h" #define RSP_DONE_MSG 667 diff --git a/src/code/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/sys_rumble.c b/src/code/sys_rumble.c new file mode 100644 index 000000000..4101758be --- /dev/null +++ b/src/code/sys_rumble.c @@ -0,0 +1,160 @@ +/* + * File: sys_rumble.c + * Description: Internal scheduler system for rumble requests + */ + +#include "global.h" +#include "z64rumble.h" + +// sRumbleWasEnabledOnLastTick/sWillDisableRumble? Probably name it after updateEnabled +u8 D_801D1E70 = true; + +void RumbleManager_Update(RumbleManager* rumbleMgr) { + s32 strongestIndex = -1; + s32 i; + s32 temp; + + // Turn rumbling off for all controllers + for (i = 0; i < ARRAY_COUNT(rumbleMgr->rumbleEnabled); i++) { + rumbleMgr->rumbleEnabled[i] = false; + } + + if (!rumbleMgr->updateEnabled) { + // Rumbling update is disabled + + if (D_801D1E70) { + for (i = 0; i < MAXCONTROLLERS; i++) { + func_8017544C(i, false); + } + } + + D_801D1E70 = rumbleMgr->updateEnabled; + func_80175434(); + + return; + } + + D_801D1E70 = rumbleMgr->updateEnabled; + + // Start up the manager by wiping old requests + if (rumbleMgr->state == RUMBLEMANAGER_STATE_INITIAL) { + for (i = 0; i < MAXCONTROLLERS; i++) { + func_8017544C(i, false); + } + + for (i = 0; i < RUMBLE_REQUEST_BUFFER_SIZE; i++) { + rumbleMgr->requestIntensities[i] = 0; + rumbleMgr->requestDecayTimers[i] = 0; + rumbleMgr->requestDecaySteps[i] = 0; + rumbleMgr->requestAccumulators[i] = 0; + } + + rumbleMgr->rumblingDuration = 0; + rumbleMgr->downTime = 0; + + rumbleMgr->overrideIntensity = 0; + rumbleMgr->overrideDecayTimer = 0; + rumbleMgr->overrideDecayStep = 0; + rumbleMgr->overrideAccumulator = 0; + + rumbleMgr->state = RUMBLEMANAGER_STATE_RUNNING; + + func_80175434(); + } + + if (rumbleMgr->state != RUMBLEMANAGER_STATE_WIPE) { + // Process arrays of rumble requests + for (i = 0; i < RUMBLE_REQUEST_BUFFER_SIZE; i++) { + if (rumbleMgr->requestIntensities[i] != 0) { // This entry has a non-empty rumble request + if (rumbleMgr->requestDecayTimers[i] > 0) { + rumbleMgr->requestDecayTimers[i]--; + } else { + temp = rumbleMgr->requestIntensities[i] - rumbleMgr->requestDecaySteps[i]; + if (temp > 0) { + rumbleMgr->requestIntensities[i] = temp; + } else { + rumbleMgr->requestIntensities[i] = 0; + } + } + + temp = rumbleMgr->requestAccumulators[i] + rumbleMgr->requestIntensities[i]; + rumbleMgr->requestAccumulators[i] = temp; // overflows + if (strongestIndex == -1) { + strongestIndex = i; + rumbleMgr->rumbleEnabled[0] = (temp >= 0x100); + } else if (rumbleMgr->requestIntensities[strongestIndex] < rumbleMgr->requestIntensities[i]) { + strongestIndex = i; + rumbleMgr->rumbleEnabled[0] = (temp >= 0x100); + } + } + } + + // Process Override request. Note it takes priority over the values set by the request arrays + if (rumbleMgr->overrideIntensity != 0) { + if (rumbleMgr->overrideDecayTimer > 0) { + rumbleMgr->overrideDecayTimer--; + } else { + temp = rumbleMgr->overrideIntensity - rumbleMgr->overrideDecayStep; + if (temp > 0) { + rumbleMgr->overrideIntensity = temp; + } else { + rumbleMgr->overrideIntensity = 0; + } + } + + temp = rumbleMgr->overrideAccumulator + rumbleMgr->overrideIntensity; + rumbleMgr->overrideAccumulator = temp; // overflows + rumbleMgr->rumbleEnabled[0] = (temp >= 0x100); + } + + if (rumbleMgr->overrideIntensity != 0) { + temp = rumbleMgr->overrideIntensity; + } else if (strongestIndex == -1) { + temp = 0; + } else { + temp = rumbleMgr->requestIntensities[strongestIndex]; + } + + // Keep track of how long this have been rumbling (almost) nonstop + if (temp == 0) { + rumbleMgr->downTime++; + if (rumbleMgr->downTime > 5) { + rumbleMgr->rumblingDuration = 0; + rumbleMgr->downTime = 5; + } + } else { + rumbleMgr->downTime = 0; + rumbleMgr->rumblingDuration++; + if (rumbleMgr->rumblingDuration > 2 * 60 * 60) { // 2 minutes + // Rumbling has lasted too long, clear system + rumbleMgr->state = RUMBLEMANAGER_STATE_WIPE; + } + } + } else { // RUMBLEMANAGER_STATE_WIPE + for (i = 0; i < RUMBLE_REQUEST_BUFFER_SIZE; i++) { + rumbleMgr->requestIntensities[i] = 0; + rumbleMgr->requestDecayTimers[i] = 0; + rumbleMgr->requestDecaySteps[i] = 0; + rumbleMgr->requestAccumulators[i] = 0; + } + + rumbleMgr->rumblingDuration = 0; + rumbleMgr->downTime = 0; + + rumbleMgr->overrideIntensity = 0; + rumbleMgr->overrideDecayTimer = 0; + rumbleMgr->overrideDecayStep = 0; + rumbleMgr->overrideAccumulator = 0; + + func_80175434(); + } +} + +void RumbleManager_Init(RumbleManager* rumbleMgr) { + bzero(rumbleMgr, sizeof(RumbleManager)); + rumbleMgr->state = RUMBLEMANAGER_STATE_INITIAL; + rumbleMgr->updateEnabled = true; +} + +void RumbleManager_Destroy(RumbleManager* rumbleMgr) { +} diff --git a/src/code/z_DLF.c b/src/code/z_DLF.c index 4c57aca01..020edcf27 100644 --- a/src/code/z_DLF.c +++ b/src/code/z_DLF.c @@ -1,6 +1,75 @@ #include "global.h" #include "system_malloc.h" +#include "z64load.h" -#pragma GLOBAL_ASM("asm/non_matchings/code/z_DLF/Overlay_LoadGameState.s") +void Overlay_LoadGameState(GameStateOverlay* overlayEntry) { + void* vramStart; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_DLF/Overlay_FreeGameState.s") + if (overlayEntry->loadedRamAddr != NULL) { + return; + } + vramStart = overlayEntry->vramStart; + if (vramStart == NULL) { + overlayEntry->unk_28 = 0; + return; + } + overlayEntry->loadedRamAddr = Load2_AllocateAndLoad(overlayEntry->vromStart, overlayEntry->vromEnd, + (uintptr_t)vramStart, (uintptr_t)overlayEntry->vramEnd); + if (overlayEntry->loadedRamAddr != NULL) { + + overlayEntry->unk_14 = (uintptr_t)( + (overlayEntry->unk_14 != NULL) + ? (void*)((uintptr_t)overlayEntry->unk_14 - (intptr_t)OVERLAY_RELOCATION_OFFSET(overlayEntry)) + : NULL); + overlayEntry->init = + (uintptr_t)((overlayEntry->init != NULL) + ? (void*)((uintptr_t)overlayEntry->init - (intptr_t)OVERLAY_RELOCATION_OFFSET(overlayEntry)) + : NULL); + overlayEntry->destroy = (uintptr_t)( + (overlayEntry->destroy != NULL) + ? (void*)((uintptr_t)overlayEntry->destroy - (intptr_t)OVERLAY_RELOCATION_OFFSET(overlayEntry)) + : NULL); + overlayEntry->unk_20 = (uintptr_t)( + (overlayEntry->unk_20 != NULL) + ? (void*)((uintptr_t)overlayEntry->unk_20 - (intptr_t)OVERLAY_RELOCATION_OFFSET(overlayEntry)) + : NULL); + overlayEntry->unk_24 = (uintptr_t)( + (overlayEntry->unk_24 != NULL) + ? (void*)((uintptr_t)overlayEntry->unk_24 - (intptr_t)OVERLAY_RELOCATION_OFFSET(overlayEntry)) + : NULL); + + overlayEntry->unk_28 = 0; + } +} + +void Overlay_FreeGameState(GameStateOverlay* overlayEntry) { + s32 var_v0; + + if (overlayEntry->loadedRamAddr != NULL) { + var_v0 = overlayEntry->unk_28 != 0 ? -1 : 0; + if (var_v0 == 0) { + overlayEntry->unk_14 = (uintptr_t)( + (overlayEntry->unk_14 != NULL) + ? (void*)((uintptr_t)overlayEntry->unk_14 + (intptr_t)OVERLAY_RELOCATION_OFFSET(overlayEntry)) + : NULL); + overlayEntry->init = (uintptr_t)( + (overlayEntry->init != NULL) + ? (void*)((uintptr_t)overlayEntry->init + (intptr_t)OVERLAY_RELOCATION_OFFSET(overlayEntry)) + : NULL); + overlayEntry->destroy = (uintptr_t)( + (overlayEntry->destroy != NULL) + ? (void*)((uintptr_t)overlayEntry->destroy + (intptr_t)OVERLAY_RELOCATION_OFFSET(overlayEntry)) + : NULL); + overlayEntry->unk_20 = (uintptr_t)( + (overlayEntry->unk_20 != NULL) + ? (void*)((uintptr_t)overlayEntry->unk_20 + (intptr_t)OVERLAY_RELOCATION_OFFSET(overlayEntry)) + : NULL); + overlayEntry->unk_24 = (uintptr_t)( + (overlayEntry->unk_24 != NULL) + ? (void*)((uintptr_t)overlayEntry->unk_24 + (intptr_t)OVERLAY_RELOCATION_OFFSET(overlayEntry)) + : NULL); + SystemArena_Free(overlayEntry->loadedRamAddr); + overlayEntry->loadedRamAddr = NULL; + } + } +} diff --git a/src/code/z_actor.c b/src/code/z_actor.c index 93eeeddc7..da2b70292 100644 --- a/src/code/z_actor.c +++ b/src/code/z_actor.c @@ -4,6 +4,8 @@ */ #include "global.h" +#include "z64load.h" +#include "z64rumble.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" @@ -29,13 +31,13 @@ extern Mtx D_801ED8E0; // 1 func extern Actor* D_801ED920; // 2 funcs. 1 out of z_actor // Internal forward declarations -void func_800BA8B8(GlobalContext* globalCtx, ActorContext* actorCtx); -Actor* Actor_SpawnEntry(ActorContext* actorCtx, ActorEntry* actorEntry, GlobalContext* globalCtx); -Actor* Actor_Delete(ActorContext* actorCtx, Actor* actor, GlobalContext* globalCtx); +void func_800BA8B8(PlayState* play, ActorContext* actorCtx); +Actor* Actor_SpawnEntry(ActorContext* actorCtx, ActorEntry* actorEntry, PlayState* play); +Actor* Actor_Delete(ActorContext* actorCtx, Actor* actor, PlayState* play); void func_800BB8EC(GameState* gameState, ActorContext* actorCtx, Actor** arg2, Actor** arg3, Player* player); -s32 func_800BA2FC(GlobalContext* globalCtx, Actor* actor, Vec3f* projectedPos, f32 projectedW); +s32 func_800BA2FC(PlayState* play, Actor* actor, Vec3f* projectedPos, f32 projectedW); void Actor_AddToCategory(ActorContext* actorCtx, Actor* actor, u8 actorCategory); -Actor* Actor_RemoveFromCategory(GlobalContext* globalCtx, ActorContext* actorCtx, Actor* actorToRemove); +Actor* Actor_RemoveFromCategory(PlayState* play, ActorContext* actorCtx, Actor* actorToRemove); void Actor_PrintLists(ActorContext* actorCtx) { ActorListEntry* actorList = &actorCtx->actorLists[0]; @@ -63,7 +65,7 @@ void ActorShape_Init(ActorShape* actorShape, f32 yOffset, ActorShadowFunc shadow actorShape->shadowAlpha = 255; } -void ActorShadow_Draw(Actor* actor, Lights* lights, GlobalContext* globalCtx, Gfx* dlist, Color_RGBA8* color) { +void ActorShadow_Draw(Actor* actor, Lights* lights, PlayState* play, Gfx* dlist, Color_RGBA8* color) { if (actor->floorPoly != NULL) { f32 dy = actor->world.pos.y - actor->floorHeight; @@ -71,7 +73,7 @@ void ActorShadow_Draw(Actor* actor, Lights* lights, GlobalContext* globalCtx, Gf f32 shadowScale; MtxF mtx; - OPEN_DISPS(globalCtx->state.gfxCtx); + OPEN_DISPS(play->state.gfxCtx); POLY_OPA_DISP = Gfx_CallSetupDL(POLY_OPA_DISP, 0x2C); @@ -92,57 +94,57 @@ 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; Matrix_Scale(actor->scale.x * shadowScale, 1.0f, actor->scale.z * shadowScale, MTXMODE_APPLY); - gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_MODELVIEW | G_MTX_LOAD); + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_MODELVIEW | G_MTX_LOAD); gSPDisplayList(POLY_OPA_DISP++, dlist); - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->state.gfxCtx); } } } -void ActorShadow_DrawCircle(Actor* actor, Lights* lights, GlobalContext* globalCtx) { +void ActorShadow_DrawCircle(Actor* actor, Lights* lights, PlayState* play) { if (actor->bgCheckFlags & 0x400) { - func_800B4AEC(globalCtx, actor, 50.0f); + func_800B4AEC(play, actor, 50.0f); } - ActorShadow_Draw(actor, lights, globalCtx, gCircleShadowDL, NULL); + ActorShadow_Draw(actor, lights, play, gCircleShadowDL, NULL); } -void ActorShadow_DrawSquare(Actor* actor, Lights* lights, GlobalContext* globalCtx) { +void ActorShadow_DrawSquare(Actor* actor, Lights* lights, PlayState* play) { if (actor->bgCheckFlags & 0x400) { - func_800B4AEC(globalCtx, actor, 50.0f); + func_800B4AEC(play, actor, 50.0f); } - ActorShadow_Draw(actor, lights, globalCtx, gSquareShadowDL, NULL); + ActorShadow_Draw(actor, lights, play, gSquareShadowDL, NULL); } -void ActorShadow_DrawWhiteCircle(Actor* actor, Lights* lights, GlobalContext* globalCtx) { +void ActorShadow_DrawWhiteCircle(Actor* actor, Lights* lights, PlayState* play) { static Color_RGBA8 color = { 255, 255, 255, 255 }; - ActorShadow_Draw(actor, lights, globalCtx, gCircleShadowDL, &color); + ActorShadow_Draw(actor, lights, play, gCircleShadowDL, &color); } -void ActorShadow_DrawHorse(Actor* actor, Lights* lights, GlobalContext* globalCtx) { - ActorShadow_Draw(actor, lights, globalCtx, gHorseShadowDL, NULL); +void ActorShadow_DrawHorse(Actor* actor, Lights* lights, PlayState* play) { + ActorShadow_Draw(actor, lights, play, gHorseShadowDL, NULL); } -void ActorShadow_DrawFoot(GlobalContext* globalCtx, Light* light, MtxF* arg2, s32 lightNum, f32 shadowAlpha, - f32 shadowScaleX, f32 shadowScaleZ) { +void ActorShadow_DrawFoot(PlayState* play, Light* light, MtxF* arg2, s32 lightNum, f32 shadowAlpha, f32 shadowScaleX, + f32 shadowScaleZ) { s32 pad; s16 sp58; f32 dir2; f32 dir0; - OPEN_DISPS(globalCtx->state.gfxCtx); + OPEN_DISPS(play->state.gfxCtx); gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, 0, 0, 0, (u8)(CLAMP_MAX(lightNum * 1.3e-05f, 1.0f) * shadowAlpha)); @@ -151,17 +153,17 @@ 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); + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_MODELVIEW | G_MTX_LOAD); gSPDisplayList(POLY_OPA_DISP++, gFootShadowDL); - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->state.gfxCtx); } -void ActorShadow_DrawFeet(Actor* actor, Lights* mapper, GlobalContext* globalCtx) { +void ActorShadow_DrawFeet(Actor* actor, Lights* mapper, PlayState* play) { f32 distToFloor = actor->world.pos.y - actor->floorHeight; if (distToFloor > 0.0f) { @@ -170,19 +172,19 @@ void ActorShadow_DrawFeet(Actor* actor, Lights* mapper, GlobalContext* globalCtx f32 alphaRatio; if ((actor->id == ACTOR_PLAYER) && (((Player*)actor)->stateFlags3 & 0x8000)) { - f32 tmpScaleZ = actor->scale.z; + f32 prevScaleZ = actor->scale.z; actor->scale.z += 0.03f * fabsf(Math_CosS(((Player*)actor)->unk_AAA)); actor->shape.shadowScale *= 0.2f; alphaRatio = distToFloor * 0.03f; actor->shape.shadowAlpha = actor->shape.shadowAlpha * CLAMP_MAX(alphaRatio, 1.0f); - ActorShadow_Draw(actor, mapper, globalCtx, gCircleShadowDL, NULL); - actor->scale.z = tmpScaleZ; + ActorShadow_Draw(actor, mapper, play, gCircleShadowDL, NULL); + actor->scale.z = prevScaleZ; } else { actor->shape.shadowScale *= 0.3f; alphaRatio = (distToFloor - 20.0f) * 0.02f; actor->shape.shadowAlpha = actor->shape.shadowAlpha * CLAMP_MAX(alphaRatio, 1.0f); - ActorShadow_DrawCircle(actor, mapper, globalCtx); + ActorShadow_DrawCircle(actor, mapper, play); } actor->shape.shadowScale = shadowScale; @@ -195,7 +197,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; @@ -213,7 +215,7 @@ void ActorShadow_DrawFeet(Actor* actor, Lights* mapper, GlobalContext* globalCtx feetPosPtr = actor->shape.feetPos; floorHeightPtr = floorHeight; - OPEN_DISPS(globalCtx->state.gfxCtx); + OPEN_DISPS(play->state.gfxCtx); POLY_OPA_DISP = Gfx_CallSetupDL(POLY_OPA_DISP, 0x2C); actor->shape.feetFloorFlags = 0; @@ -221,7 +223,7 @@ void ActorShadow_DrawFeet(Actor* actor, Lights* mapper, GlobalContext* globalCtx for (i = 0; i < ARRAY_COUNT(floorHeight); i++, spB8 >>= 1) { feetPosPtr->y += 50.0f; - *floorHeightPtr = func_80169100(globalCtx, &sp13C, &spF8, &bgId, feetPosPtr); + *floorHeightPtr = func_80169100(play, &sp13C, &spF8, &bgId, feetPosPtr); feetPosPtr->y -= 50.0f; distToFloor = feetPosPtr->y - *floorHeightPtr; @@ -232,15 +234,13 @@ void ActorShadow_DrawFeet(Actor* actor, Lights* mapper, GlobalContext* globalCtx actor->shape.feetFloorFlags |= spB8; if ((actor->depthInWater < 0.0f) && (bgId == 0x32) && ((actor->shape.unk_17 & spB8) != 0)) { - if (func_800C9C24(&globalCtx->colCtx, spF8, bgId, 1) != 0) { + if (func_800C9C24(&play->colCtx, spF8, bgId, 1) != 0) { SkinMatrix_MtxFCopy(&sp13C, &spFC); SkinMatrix_MulYRotation(&spFC, actor->shape.rot.y); - EffFootmark_Add(globalCtx, &spFC, actor, i, feetPosPtr, (actor->shape.shadowScale * 0.3f), + EffFootmark_Add(play, &spFC, actor, i, feetPosPtr, (actor->shape.shadowScale * 0.3f), IREG(88) + 80, IREG(89) + 60, IREG(90) + 40, 30000, 200, 60); } actor->shape.unk_17 &= ~spB8; - - if (!mapper->l.l) {} // POSSIBLE FAKE MATCH } } @@ -252,29 +252,32 @@ 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]); if (lightNum > 0) { lightNumMax += lightNum; - ActorShadow_DrawFoot(globalCtx, lightPtr, &sp13C, lightNum, shadowAlpha, shadowScaleX, + ActorShadow_DrawFoot(play, lightPtr, &sp13C, lightNum, shadowAlpha, shadowScaleX, 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])) - (lightNumMax * 8); if (lightNum > 0) { - ActorShadow_DrawFoot(globalCtx, lightPtr, &sp13C, lightNum, shadowAlpha, shadowScaleX, + ActorShadow_DrawFoot(play, lightPtr, &sp13C, lightNum, shadowAlpha, shadowScaleX, shadowScaleZ); } } + lightPtr++; } } feetPosPtr++; @@ -293,31 +296,31 @@ void ActorShadow_DrawFeet(Actor* actor, Lights* mapper, GlobalContext* globalCtx } } - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->state.gfxCtx); } } void Actor_SetFeetPos(Actor* actor, s32 limbIndex, s32 leftFootIndex, Vec3f* leftFootPos, s32 rightFootIndex, Vec3f* rightFootPos) { if (limbIndex == leftFootIndex) { - Matrix_MultiplyVector3fByState(leftFootPos, &actor->shape.feetPos[FOOT_LEFT]); + 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]); } } -void func_800B4AEC(GlobalContext* globalCtx, Actor* actor, f32 y) { +void func_800B4AEC(PlayState* play, Actor* actor, f32 y) { s32 floorBgId; f32 yPos = actor->world.pos.y; actor->world.pos.y += y; - actor->floorHeight = BgCheck_EntityRaycastFloor5_2(globalCtx, &globalCtx->colCtx, &actor->floorPoly, &floorBgId, - actor, &actor->world.pos); + actor->floorHeight = + BgCheck_EntityRaycastFloor5_2(play, &play->colCtx, &actor->floorPoly, &floorBgId, actor, &actor->world.pos); actor->floorBgId = floorBgId; actor->world.pos.y = yPos; } -void func_800B4B50(Actor* actor, Lights* mapper, GlobalContext* globalCtx) { +void func_800B4B50(Actor* actor, Lights* mapper, PlayState* play) { f32 spEC; f32 temp_f12; f32 shadowScaleZ; @@ -333,7 +336,7 @@ void func_800B4B50(Actor* actor, Lights* mapper, GlobalContext* globalCtx) { s32 lightNumMax; if (actor->bgCheckFlags & 0x400) { - func_800B4AEC(globalCtx, actor, 50.0f); + func_800B4AEC(play, actor, 50.0f); } if (actor->floorPoly != NULL) { @@ -347,13 +350,13 @@ void func_800B4B50(Actor* actor, Lights* mapper, GlobalContext* globalCtx) { actor->shape.shadowScale *= 0.3f; temp_f12 = (spEC - 20.0f) * 0.02f; actor->shape.shadowAlpha = CLAMP_MAX(temp_f12, 1.0f) * actor->shape.shadowAlpha; - ActorShadow_DrawCircle(actor, mapper, globalCtx); + ActorShadow_DrawCircle(actor, mapper, play); actor->shape.shadowScale = temp_f20; actor->shape.shadowAlpha = temp_v0; } else if (spEC >= -1.0f) { numLights = mapper->numLights - 2; - OPEN_DISPS(globalCtx->state.gfxCtx); + OPEN_DISPS(play->state.gfxCtx); POLY_OPA_DISP = Gfx_CallSetupDL(POLY_OPA_DISP, 0x2C); @@ -369,7 +372,7 @@ void func_800B4B50(Actor* actor, Lights* mapper, GlobalContext* globalCtx) { lightNum = (phi_s0->l.col[0] + phi_s0->l.col[1] + phi_s0->l.col[2]) * ABS_ALT(phi_s0->l.dir[1]); if (lightNum > 0) { lightNumMax += lightNum; - ActorShadow_DrawFoot(globalCtx, phi_s0, &sp94, lightNum, temp_f22, temp_f24, shadowScaleZ); + ActorShadow_DrawFoot(play, phi_s0, &sp94, lightNum, temp_f22, temp_f24, shadowScaleZ); } } } @@ -379,22 +382,18 @@ void func_800B4B50(Actor* actor, Lights* mapper, GlobalContext* globalCtx) { lightNum = ((phi_s0->l.col[0] + phi_s0->l.col[1] + phi_s0->l.col[2]) * ABS_ALT(phi_s0->l.dir[1])) - (8 * lightNumMax); if (lightNum > 0) { - ActorShadow_DrawFoot(globalCtx, phi_s0, &sp94, lightNum, temp_f22, temp_f24, shadowScaleZ); + ActorShadow_DrawFoot(play, phi_s0, &sp94, lightNum, temp_f22, temp_f24, shadowScaleZ); } } } - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->state.gfxCtx); } } } -void Actor_GetProjectedPos(GlobalContext* globalCtx, Vec3f* arg1, Vec3f* arg2, f32* arg3) { - SkinMatrix_Vec3fMtxFMultXYZW(&globalCtx->viewProjectionMtxF, arg1, arg2, arg3); - if (*arg3 < 1.0f) { - *arg3 = 1.0f; - } else { - *arg3 = 1.0f / *arg3; - } +void Actor_GetProjectedPos(PlayState* play, Vec3f* worldPos, Vec3f* projectedPos, f32* invW) { + SkinMatrix_Vec3fMtxFMultXYZW(&play->viewProjectionMtxF, worldPos, projectedPos, invW); + *invW = (*invW < 1.0f) ? 1.0f : (1.0f / *invW); } void Target_SetPos(TargetContext* targetCtx, s32 index, f32 x, f32 y, f32 z) { @@ -416,15 +415,15 @@ TatlColor sTatlColorList[] = { { { 0, 255, 0, 255 }, { 0, 255, 0, 0 } }, { { 0, 255, 0, 255 }, { 0, 255, 0, 0 } }, { { 0, 255, 0, 255 }, { 0, 255, 0, 0 } }, { { 255, 255, 0, 255 }, { 200, 155, 0, 0 } }, { { 0, 255, 0, 255 }, { 0, 255, 0, 0 } }, { { 0, 255, 0, 255 }, { 0, 255, 0, 0 } }, - { { 0, 255, 0, 255 }, { 0, 255, 0, 0 } } + { { 0, 255, 0, 255 }, { 0, 255, 0, 0 } }, }; -void func_800B4F78(TargetContext* targetCtx, s32 type, GlobalContext* globalCtx) { +void func_800B4F78(TargetContext* targetCtx, s32 type, PlayState* play) { TatlColor* tatlColorEntry; s32 i; TargetContextEntry* targetEntry; - Math_Vec3f_Copy(&targetCtx->targetCenterPos, &globalCtx->view.eye); + Math_Vec3f_Copy(&targetCtx->targetCenterPos, &play->view.eye); targetCtx->unk48 = 0x100; tatlColorEntry = &sTatlColorList[type]; targetCtx->unk44 = 500.0f; @@ -439,7 +438,7 @@ void func_800B4F78(TargetContext* targetCtx, s32 type, GlobalContext* globalCtx) } } -void Target_SetColors(TargetContext* targetCtx, Actor* actor, s32 type, GlobalContext* globalCtx) { +void Target_SetColors(TargetContext* targetCtx, Actor* actor, s32 type, PlayState* play) { targetCtx->unk0.x = actor->focus.pos.x; targetCtx->unk0.y = actor->focus.pos.y + (actor->targetArrowOffset * actor->scale.y); targetCtx->unk0.z = actor->focus.pos.z; @@ -454,7 +453,7 @@ void Target_SetColors(TargetContext* targetCtx, Actor* actor, s32 type, GlobalCo targetCtx->fairyOuter.a = sTatlColorList[type].outer.a; } -void Actor_TargetContextInit(TargetContext* targetCtx, Actor* actor, GlobalContext* globalCtx) { +void Actor_TargetContextInit(TargetContext* targetCtx, Actor* actor, PlayState* play) { targetCtx->bgmEnemy = NULL; targetCtx->unk8C = NULL; targetCtx->targetedActor = NULL; @@ -462,24 +461,24 @@ void Actor_TargetContextInit(TargetContext* targetCtx, Actor* actor, GlobalConte targetCtx->unk4B = 0; targetCtx->unk4C = 0; targetCtx->unk40 = 0.0f; - Target_SetColors(targetCtx, actor, actor->category, globalCtx); - func_800B4F78(targetCtx, actor->category, globalCtx); + Target_SetColors(targetCtx, actor, actor->category, play); + func_800B4F78(targetCtx, actor->category, play); } -void Actor_DrawZTarget(TargetContext* targetCtx, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); +void Actor_DrawZTarget(TargetContext* targetCtx, PlayState* play) { + Player* player = GET_PLAYER(play); if (!(player->stateFlags1 & 0x300006C2)) { Actor* actor = targetCtx->targetedActor; - OPEN_DISPS(globalCtx->state.gfxCtx); + OPEN_DISPS(play->state.gfxCtx); if (targetCtx->unk48 != 0) { TargetContextEntry* entry; s16 alpha = 255; f32 var1 = 1.0f; - Vec3f spBC; + Vec3f projectedPos; s32 spB8; - f32 spB4; + f32 invW; s32 spB0; s32 spAC; f32 var2; @@ -502,22 +501,22 @@ void Actor_DrawZTarget(TargetContext* targetCtx, GlobalContext* globalCtx) { alpha = targetCtx->unk48; } - Actor_GetProjectedPos(globalCtx, &targetCtx->targetCenterPos, &spBC, &spB4); + Actor_GetProjectedPos(play, &targetCtx->targetCenterPos, &projectedPos, &invW); - spBC.x = (160 * (spBC.x * spB4)) * var1; - spBC.x = CLAMP(spBC.x, -320.0f, 320.0f); + projectedPos.x = ((SCREEN_WIDTH / 2) * (projectedPos.x * invW)) * var1; + projectedPos.x = CLAMP(projectedPos.x, -SCREEN_WIDTH, SCREEN_WIDTH); - spBC.y = (120 * (spBC.y * spB4)) * var1; - spBC.y = CLAMP(spBC.y, -240.0f, 240.0f); + projectedPos.y = ((SCREEN_HEIGHT / 2) * (projectedPos.y * invW)) * var1; + projectedPos.y = CLAMP(projectedPos.y, -SCREEN_HEIGHT, SCREEN_HEIGHT); - spBC.z = spBC.z * var1; + projectedPos.z = projectedPos.z * var1; targetCtx->unk4C--; if (targetCtx->unk4C < 0) { targetCtx->unk4C = 2; } - Target_SetPos(targetCtx, targetCtx->unk4C, spBC.x, spBC.y, spBC.z); + Target_SetPos(targetCtx, targetCtx->unk4C, projectedPos.x, projectedPos.y, projectedPos.z); if ((!(player->stateFlags1 & 0x40)) || (actor != player->unk_730)) { OVERLAY_DISP = Gfx_CallSetupDL(OVERLAY_DISP, 0x39); @@ -532,22 +531,21 @@ 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); - gSPMatrix(OVERLAY_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), - G_MTX_MODELVIEW | G_MTX_LOAD); + Matrix_RotateZS(0x4000, MTXMODE_APPLY); + Matrix_Push(); + Matrix_Translate(entry->unkC, entry->unkC, 0.0f, MTXMODE_APPLY); + gSPMatrix(OVERLAY_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_MODELVIEW | G_MTX_LOAD); gSPDisplayList(OVERLAY_DISP++, gZTargetLockOnTriangleDL); - Matrix_StatePop(); + Matrix_Pop(); } } @@ -565,34 +563,34 @@ 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((play->gameplayFrames * 3000), MTXMODE_APPLY); Matrix_Scale((iREG(27) + 35) / 1000.0f, (iREG(28) + 60) / 1000.0f, (iREG(29) + 50) / 1000.0f, MTXMODE_APPLY); gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, color->inner.r, color->inner.g, color->inner.b, 255); - gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_MODELVIEW | G_MTX_LOAD); + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_MODELVIEW | G_MTX_LOAD); gSPDisplayList(POLY_XLU_DISP++, gZTargetArrowDL); } - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->state.gfxCtx); } } // OoT: func_8002C7BC void func_800B5814(TargetContext* targetCtx, Player* player, Actor* actor, GameState* gameState) { - GlobalContext* globalCtx = (GlobalContext*)gameState; + PlayState* play = (PlayState*)gameState; Actor* sp68 = NULL; s32 category; - Vec3f sp58; - f32 sp54; + Vec3f projectedPos; + f32 invW; if ((player->unk_730 != 0) && (player->unk_AE3[player->unk_ADE] == 2)) { targetCtx->unk_94 = NULL; } else { - func_800BB8EC(gameState, &globalCtx->actorCtx, &sp68, &D_801ED920, player); + func_800BB8EC(gameState, &play->actorCtx, &sp68, &D_801ED920, player); targetCtx->unk_94 = sp68; } @@ -635,12 +633,13 @@ void func_800B5814(TargetContext* targetCtx, Player* player, Actor* actor, GameS targetCtx->unk0.y += y * temp_f0; targetCtx->unk0.z += z * temp_f0; } else { - Target_SetColors(targetCtx, sp68, category, globalCtx); + Target_SetColors(targetCtx, sp68, category, play); } if (actor != NULL && targetCtx->unk4B == 0) { - Actor_GetProjectedPos(globalCtx, &actor->focus.pos, &sp58, &sp54); - if ((sp58.z <= 0.0f) || (fabsf(sp58.x * sp54) >= 1.0f) || (fabsf(sp58.y * sp54) >= 1.0f)) { + Actor_GetProjectedPos(play, &actor->focus.pos, &projectedPos, &invW); + if ((projectedPos.z <= 0.0f) || (fabsf(projectedPos.x * invW) >= 1.0f) || + (fabsf(projectedPos.y * invW) >= 1.0f)) { actor = NULL; } } @@ -649,7 +648,7 @@ void func_800B5814(TargetContext* targetCtx, Player* player, Actor* actor, GameS if (actor != targetCtx->targetedActor) { s32 sfxId; - func_800B4F78(targetCtx, actor->category, globalCtx); + func_800B4F78(targetCtx, actor->category, play); targetCtx->targetedActor = actor; @@ -691,9 +690,9 @@ void func_800B5814(TargetContext* targetCtx, Player* player, Actor* actor, GameS /** * Tests if current scene switch flag is set. */ -s32 Flags_GetSwitch(GlobalContext* globalCtx, s32 flag) { +s32 Flags_GetSwitch(PlayState* play, s32 flag) { if (flag >= 0 && flag < 0x80) { - return globalCtx->actorCtx.flags.switches[(flag & ~0x1F) >> 5] & (1 << (flag & 0x1F)); + return play->actorCtx.flags.switches[(flag & ~0x1F) >> 5] & (1 << (flag & 0x1F)); } return 0; } @@ -701,97 +700,97 @@ s32 Flags_GetSwitch(GlobalContext* globalCtx, s32 flag) { /** * Sets current scene switch flag. */ -void Flags_SetSwitch(GlobalContext* globalCtx, s32 flag) { +void Flags_SetSwitch(PlayState* play, s32 flag) { if (flag >= 0 && flag < 0x80) { - globalCtx->actorCtx.flags.switches[(flag & ~0x1F) >> 5] |= 1 << (flag & 0x1F); + play->actorCtx.flags.switches[(flag & ~0x1F) >> 5] |= 1 << (flag & 0x1F); } } /** * Unsets current scene switch flag. */ -void Flags_UnsetSwitch(GlobalContext* globalCtx, s32 flag) { +void Flags_UnsetSwitch(PlayState* play, s32 flag) { if (flag >= 0 && flag < 0x80) { - globalCtx->actorCtx.flags.switches[(flag & ~0x1F) >> 5] &= ~(1 << (flag & 0x1F)); + play->actorCtx.flags.switches[(flag & ~0x1F) >> 5] &= ~(1 << (flag & 0x1F)); } } /** * Tests if current scene chest flag is set. */ -s32 Flags_GetTreasure(GlobalContext* globalCtx, s32 flag) { - return globalCtx->actorCtx.flags.chest & (1 << flag); +s32 Flags_GetTreasure(PlayState* play, s32 flag) { + return play->actorCtx.flags.chest & (1 << flag); } /** * Sets current scene chest flag. */ -void Flags_SetTreasure(GlobalContext* globalCtx, s32 flag) { - globalCtx->actorCtx.flags.chest |= (1 << flag); +void Flags_SetTreasure(PlayState* play, s32 flag) { + play->actorCtx.flags.chest |= (1 << flag); } /** * Overrides the all the chest flags. */ -void Flags_SetAllTreasure(GlobalContext* globalCtx, s32 flag) { - globalCtx->actorCtx.flags.chest = flag; +void Flags_SetAllTreasure(PlayState* play, s32 flag) { + play->actorCtx.flags.chest = flag; } /** * Returns all the chest flags. */ -s32 Flags_GetAllTreasure(GlobalContext* globalCtx) { - return globalCtx->actorCtx.flags.chest; +s32 Flags_GetAllTreasure(PlayState* play) { + return play->actorCtx.flags.chest; } /** * Tests if current scene clear flag is set. */ -s32 Flags_GetClear(GlobalContext* globalCtx, s32 roomNumber) { - return globalCtx->actorCtx.flags.clearedRoom & (1 << roomNumber); +s32 Flags_GetClear(PlayState* play, s32 roomNumber) { + return play->actorCtx.flags.clearedRoom & (1 << roomNumber); } /** * Sets current scene clear flag. */ -void Flags_SetClear(GlobalContext* globalCtx, s32 roomNumber) { - globalCtx->actorCtx.flags.clearedRoom |= (1 << roomNumber); +void Flags_SetClear(PlayState* play, s32 roomNumber) { + play->actorCtx.flags.clearedRoom |= (1 << roomNumber); } /** * Unsets current scene clear flag. */ -void Flags_UnsetClear(GlobalContext* globalCtx, s32 roomNumber) { - globalCtx->actorCtx.flags.clearedRoom &= ~(1 << roomNumber); +void Flags_UnsetClear(PlayState* play, s32 roomNumber) { + play->actorCtx.flags.clearedRoom &= ~(1 << roomNumber); } /** * Tests if current scene temp clear flag is set. */ -s32 Flags_GetClearTemp(GlobalContext* globalCtx, s32 roomNumber) { - return globalCtx->actorCtx.flags.clearedRoomTemp & (1 << roomNumber); +s32 Flags_GetClearTemp(PlayState* play, s32 roomNumber) { + return play->actorCtx.flags.clearedRoomTemp & (1 << roomNumber); } /** * Sets current scene temp clear flag. */ -void Flags_SetClearTemp(GlobalContext* globalCtx, s32 roomNumber) { - globalCtx->actorCtx.flags.clearedRoomTemp |= (1 << roomNumber); +void Flags_SetClearTemp(PlayState* play, s32 roomNumber) { + play->actorCtx.flags.clearedRoomTemp |= (1 << roomNumber); } /** * Unsets current scene temp clear flag. */ -void Flags_UnsetClearTemp(GlobalContext* globalCtx, s32 roomNumber) { - globalCtx->actorCtx.flags.clearedRoomTemp &= ~(1 << roomNumber); +void Flags_UnsetClearTemp(PlayState* play, s32 roomNumber) { + play->actorCtx.flags.clearedRoomTemp &= ~(1 << roomNumber); } /** * Tests if current scene collectible flag is set. */ -s32 Flags_GetCollectible(GlobalContext* globalCtx, s32 flag) { +s32 Flags_GetCollectible(PlayState* play, s32 flag) { if (flag > 0 && flag < 0x80) { - return globalCtx->actorCtx.flags.collectible[(flag & ~0x1F) >> 5] & (1 << (flag & 0x1F)); + return play->actorCtx.flags.collectible[(flag & ~0x1F) >> 5] & (1 << (flag & 0x1F)); } return 0; } @@ -799,9 +798,9 @@ s32 Flags_GetCollectible(GlobalContext* globalCtx, s32 flag) { /** * Sets current scene collectible flag. */ -void Flags_SetCollectible(GlobalContext* globalCtx, s32 flag) { +void Flags_SetCollectible(PlayState* play, s32 flag) { if (flag > 0 && flag < 0x80) { - globalCtx->actorCtx.flags.collectible[(flag & ~0x1F) >> 5] |= 1 << (flag & 0x1F); + play->actorCtx.flags.collectible[(flag & ~0x1F) >> 5] |= 1 << (flag & 0x1F); } } @@ -896,8 +895,8 @@ void TitleCard_Draw(GameState* gameState, TitleCardContext* titleCtx) { /* End of TitleCard section */ // unused -s32 func_800B6434(GlobalContext* globalCtx, TitleCardContext* titleCtx) { - if ((globalCtx->actorCtx.titleCtxt.delayTimer != 0) || (globalCtx->actorCtx.titleCtxt.alpha != 0)) { +s32 func_800B6434(PlayState* play, TitleCardContext* titleCtx) { + if ((play->actorCtx.titleCtxt.delayTimer != 0) || (play->actorCtx.titleCtxt.alpha != 0)) { titleCtx->durationTimer = 0; titleCtx->delayTimer = 0; return false; @@ -905,57 +904,57 @@ s32 func_800B6434(GlobalContext* globalCtx, TitleCardContext* titleCtx) { return true; } -void func_800B6468(GlobalContext* globalCtx) { - globalCtx->actorCtx.unk1F5 = 0; +void func_800B6468(PlayState* play) { + play->actorCtx.unk1F5 = 0; } -void func_800B6474(GlobalContext* globalCtx) { - if (globalCtx->actorCtx.unk1F5 != 0) { - globalCtx->actorCtx.unk1F5--; +void func_800B6474(PlayState* play) { + if (play->actorCtx.unk1F5 != 0) { + play->actorCtx.unk1F5--; } } -s32 func_800B648C(GlobalContext* globalCtx, s32 arg1, s32 arg2, f32 arg3, Vec3f* arg4) { - if ((globalCtx->actorCtx.unk1F5 != 0) && (arg3 < globalCtx->actorCtx.unk1F8)) { +s32 func_800B648C(PlayState* play, s32 arg1, s32 arg2, f32 arg3, Vec3f* arg4) { + if ((play->actorCtx.unk1F5 != 0) && (arg3 < play->actorCtx.unk1F8)) { return false; } - globalCtx->actorCtx.unk1F4 = arg1; - globalCtx->actorCtx.unk1F5 = arg2; - globalCtx->actorCtx.unk1F8 = arg3; - Math_Vec3f_Copy(&globalCtx->actorCtx.unk1FC, arg4); + play->actorCtx.unk1F4 = arg1; + play->actorCtx.unk1F5 = arg2; + play->actorCtx.unk1F8 = arg3; + Math_Vec3f_Copy(&play->actorCtx.unk1FC, arg4); return true; } -f32 func_800B64FC(GlobalContext* globalCtx, f32 arg1, Vec3f* arg2, u32* arg3) { +f32 func_800B64FC(PlayState* play, f32 arg1, Vec3f* arg2, u32* arg3) { f32 temp_f8; - if ((globalCtx->actorCtx.unk1F5 == 0) || (arg1 == 0.0f)) { + if ((play->actorCtx.unk1F5 == 0) || (arg1 == 0.0f)) { return -1.0f; } - temp_f8 = Math_Vec3f_DistXYZ(&globalCtx->actorCtx.unk1FC, arg2) / arg1; - *arg3 = globalCtx->actorCtx.unk1F4; - return globalCtx->actorCtx.unk1F8 - temp_f8; + temp_f8 = Math_Vec3f_DistXYZ(&play->actorCtx.unk1FC, arg2) / arg1; + *arg3 = play->actorCtx.unk1F4; + return play->actorCtx.unk1F8 - temp_f8; } /** - * Initializes an element of the `globalCtx->actorCtx.unk_20C` array to the `arg2` pointer, or allocates one using the + * Initializes an element of the `play->actorCtx.unk_20C` array to the `arg2` pointer, or allocates one using the * `size` argument in case `arg2` is NULL. This element is associated to an `id` * * In success returns the allocated pointer if `arg2` was NULL or the `arg2` pointer otherwise - * In failure (There's no space left in `globalCtx->actorCtx.unk_20C` or an allocation error happened) returns NULL + * In failure (There's no space left in `play->actorCtx.unk_20C` or an allocation error happened) returns NULL * * Note there are no duplicated id checks. * * Used only by EnLiftNuts. */ -void* func_800B6584(GlobalContext* globalCtx, s16 id, void* arg2, size_t size) { - ActorContext_unk_20C* entry = globalCtx->actorCtx.unk_20C; +void* func_800B6584(PlayState* play, s16 id, void* arg2, size_t size) { + ActorContext_unk_20C* entry = play->actorCtx.unk_20C; s32 i; - for (i = 0; i < ARRAY_COUNT(globalCtx->actorCtx.unk_20C); i++) { + for (i = 0; i < ARRAY_COUNT(play->actorCtx.unk_20C); i++) { if (entry->id == 0) { if (arg2 == NULL) { arg2 = ZeldaArena_Malloc(size); @@ -977,18 +976,18 @@ void* func_800B6584(GlobalContext* globalCtx, s16 id, void* arg2, size_t size) { } /** - * Frees the first element of `globalCtx->actorCtx.unk_20C` with id `id`. + * Frees the first element of `play->actorCtx.unk_20C` with id `id`. * * If success, the free'd pointer is returned. * If failure, NULL is returned. * * Used only by EnLiftNuts. */ -void* func_800B6608(GlobalContext* globalCtx, s16 id) { - ActorContext_unk_20C* entry = globalCtx->actorCtx.unk_20C; +void* func_800B6608(PlayState* play, s16 id) { + ActorContext_unk_20C* entry = play->actorCtx.unk_20C; s32 i; - for (i = 0; i < ARRAY_COUNT(globalCtx->actorCtx.unk_20C); i++) { + for (i = 0; i < ARRAY_COUNT(play->actorCtx.unk_20C); i++) { if (id == entry->id) { entry->id = 0; if (entry->isDynamicallyInitialised) { @@ -1010,11 +1009,11 @@ void* func_800B6608(GlobalContext* globalCtx, s16 id) { * * Used only by EnLiftNuts. */ -void* func_800B6680(GlobalContext* globalCtx, s16 id) { - ActorContext_unk_20C* entry = globalCtx->actorCtx.unk_20C; +void* func_800B6680(PlayState* play, s16 id) { + ActorContext_unk_20C* entry = play->actorCtx.unk_20C; s32 i; - for (i = 0; i < ARRAY_COUNT(globalCtx->actorCtx.unk_20C); i++) { + for (i = 0; i < ARRAY_COUNT(play->actorCtx.unk_20C); i++) { if (id == entry->id) { return entry->ptr; } @@ -1059,11 +1058,11 @@ void Actor_SetScale(Actor* actor, f32 scale) { actor->scale.x = scale; } -void Actor_SetObjectDependency(GlobalContext* globalCtx, Actor* actor) { - gSegments[0x06] = PHYSICAL_TO_VIRTUAL(globalCtx->objectCtx.status[actor->objBankIndex].segment); +void Actor_SetObjectDependency(PlayState* play, Actor* actor) { + gSegments[0x06] = PHYSICAL_TO_VIRTUAL(play->objectCtx.status[actor->objBankIndex].segment); } -void Actor_Init(Actor* actor, GlobalContext* globalCtx) { +void Actor_Init(Actor* actor, PlayState* play) { Actor_SetWorldToHome(actor); Actor_SetShapeRotToWorld(actor); Actor_SetFocus(actor, 0.0f); @@ -1083,17 +1082,17 @@ void Actor_Init(Actor* actor, GlobalContext* globalCtx) { actor->floorBgId = BGCHECK_SCENE; ActorShape_Init(&actor->shape, 0.0f, NULL, 0.0f); - if (Object_IsLoaded(&globalCtx->objectCtx, actor->objBankIndex)) { - Actor_SetObjectDependency(globalCtx, actor); - actor->init(actor, globalCtx); + if (Object_IsLoaded(&play->objectCtx, actor->objBankIndex)) { + Actor_SetObjectDependency(play, actor); + actor->init(actor, play); actor->init = NULL; } } -void Actor_Destroy(Actor* actor, GlobalContext* globalCtx) { +void Actor_Destroy(Actor* actor, PlayState* play) { if (actor->init == NULL) { if (actor->destroy != NULL) { - actor->destroy(actor, globalCtx); + actor->destroy(actor, play); actor->destroy = NULL; } } @@ -1278,8 +1277,8 @@ 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 - Camera_GetInputDirYaw(GET_ACTIVE_CAM(globalCtx)); +void func_800B6F20(PlayState* play, Input* input, f32 magnitude, s16 baseYaw) { + s16 relativeYaw = baseYaw - Camera_GetInputDirYaw(GET_ACTIVE_CAM(play)); input->cur.stick_x = -Math_SinS(relativeYaw) * magnitude; input->rel.stick_x = input->cur.stick_x; @@ -1330,23 +1329,23 @@ s32 func_800B7128(Player* player) { return func_800B7118(player) && player->unk_ACC; } -s32 func_800B715C(GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); +s32 func_800B715C(PlayState* play) { + Player* player = GET_PLAYER(play); return player->stateFlags2 & 0x8; } -void Actor_SetCameraHorseSetting(GlobalContext* globalCtx, Player* player) { - if ((globalCtx->roomCtx.currRoom.unk3 != 4) && (player->actor.id == ACTOR_PLAYER)) { +void Actor_SetCameraHorseSetting(PlayState* play, Player* player) { + if ((play->roomCtx.currRoom.unk3 != 4) && (player->actor.id == ACTOR_PLAYER)) { EnHorse* rideActor = (EnHorse*)player->rideActor; if ((rideActor != NULL) && !(rideActor->unk_1EC & 0x10)) { - func_800DFAC8(Play_GetCamera(globalCtx, CAM_ID_MAIN), 4); + Camera_ChangeSetting(Play_GetCamera(play, CAM_ID_MAIN), CAM_SET_HORSE); } } } -void Actor_MountHorse(GlobalContext* globalCtx, Player* player, Actor* horse) { +void Actor_MountHorse(PlayState* play, Player* player, Actor* horse) { player->rideActor = horse; player->stateFlags1 |= 0x800000; horse->child = &player->actor; @@ -1360,8 +1359,8 @@ void func_800B722C(GameState* gameState, Player* player) { func_800F40A0(gameState, player); } -s32 func_800B724C(GlobalContext* globalCtx, Actor* actor, u8 csMode) { - Player* player = GET_PLAYER(globalCtx); +s32 func_800B724C(PlayState* play, Actor* actor, u8 csMode) { + Player* player = GET_PLAYER(play); if ((player->csMode == 5) || ((csMode == 6) && (player->csMode == 0))) { return false; @@ -1373,10 +1372,10 @@ s32 func_800B724C(GlobalContext* globalCtx, Actor* actor, u8 csMode) { return true; } -u32 func_800B7298(GlobalContext* globalCtx, Actor* actor, u8 csMode) { - Player* player = GET_PLAYER(globalCtx); +u32 func_800B7298(PlayState* play, Actor* actor, u8 csMode) { + Player* player = GET_PLAYER(play); - if (func_800B724C(globalCtx, actor, csMode)) { + if (func_800B724C(play, actor, csMode)) { player->unk_3BA = 1; return true; } @@ -1398,8 +1397,8 @@ void func_800B72F8(DynaPolyActor* dyna, f32 extraPushForce, s16 yRotation) { * Check if the player is facing the specified actor. * The maximum angle difference that qualifies as "facing" is specified by `maxAngleDiff`. */ -s32 Player_IsFacingActor(Actor* actor, s16 maxAngleDiff, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); +s32 Player_IsFacingActor(Actor* actor, s16 maxAngleDiff, PlayState* play) { + Player* player = GET_PLAYER(play); s16 yawDiff = BINANG_ADD(actor->yawTowardsPlayer, 0x8000) - player->actor.shape.rot.y; if (ABS_ALT(yawDiff) < maxAngleDiff) { @@ -1509,14 +1508,13 @@ s32 func_800B761C(Actor* actor, f32 arg1, s32 arg2) { return true; } -s32 func_800B7678(GlobalContext* globalCtx, Actor* actor, Vec3f* pos, s32 flags) { +s32 func_800B7678(PlayState* play, Actor* actor, Vec3f* pos, s32 flags) { f32 distToFloor; s32 bgId; pos->y += (flags & 0x800) ? 10.0f : 50.0f; - actor->floorHeight = - BgCheck_EntityRaycastFloor5_2(globalCtx, &globalCtx->colCtx, &actor->floorPoly, &bgId, actor, pos); + actor->floorHeight = BgCheck_EntityRaycastFloor5_2(play, &play->colCtx, &actor->floorPoly, &bgId, actor, pos); actor->bgCheckFlags &= ~(0x80 | 0x04 | 0x02); if (actor->floorHeight <= BGCHECK_Y_MIN) { return func_800B761C(actor, BGCHECK_Y_MIN, flags); @@ -1551,7 +1549,7 @@ s32 func_800B7678(GlobalContext* globalCtx, Actor* actor, Vec3f* pos, s32 flags) } actor->bgCheckFlags |= 1; - BgCheck2_AttachToMesh(&globalCtx->colCtx, actor, (s32)actor->floorBgId); + BgCheck2_AttachToMesh(&play->colCtx, actor, (s32)actor->floorBgId); } } else { return func_800B761C(actor, distToFloor, flags); @@ -1560,14 +1558,14 @@ s32 func_800B7678(GlobalContext* globalCtx, Actor* actor, Vec3f* pos, s32 flags) return true; } -void Actor_UpdateBgCheckInfo(GlobalContext* globalCtx, Actor* actor, f32 wallCheckHeight, f32 wallCheckRadius, +void Actor_UpdateBgCheckInfo(PlayState* play, Actor* actor, f32 wallCheckHeight, f32 wallCheckRadius, f32 ceilingCheckHeight, u32 flags) { f32 sp94 = actor->world.pos.y - actor->prevPos.y; s32 pad; Vec3f pos; if ((actor->floorBgId != BGCHECK_SCENE) && (actor->bgCheckFlags & 1)) { - BgCheck2_UpdateActorAttachedToMesh(&globalCtx->colCtx, actor->floorBgId, actor); + BgCheck2_UpdateActorAttachedToMesh(&play->colCtx, actor->floorBgId, actor); } if (flags & 1) { @@ -1575,10 +1573,10 @@ void Actor_UpdateBgCheckInfo(GlobalContext* globalCtx, Actor* actor, f32 wallChe actor->bgCheckFlags &= ~0x1000; if ((!(flags & 0x80) && - (BgCheck_EntitySphVsWall3(&globalCtx->colCtx, &pos, &actor->world.pos, &actor->prevPos, wallCheckRadius, + (BgCheck_EntitySphVsWall3(&play->colCtx, &pos, &actor->world.pos, &actor->prevPos, wallCheckRadius, &actor->wallPoly, &bgId, actor, wallCheckHeight))) || ((flags & 0x80) && - (BgCheck_EntitySphVsWall4(&globalCtx->colCtx, &pos, &actor->world.pos, &actor->prevPos, wallCheckRadius, + (BgCheck_EntitySphVsWall4(&play->colCtx, &pos, &actor->world.pos, &actor->prevPos, wallCheckRadius, &actor->wallPoly, &bgId, actor, wallCheckHeight)))) { CollisionPoly* sp7C = actor->wallPoly; @@ -1603,7 +1601,7 @@ void Actor_UpdateBgCheckInfo(GlobalContext* globalCtx, Actor* actor, f32 wallChe f32 y; pos.y = actor->prevPos.y + 4.0f; - if (BgCheck_EntityCheckCeiling(&globalCtx->colCtx, &y, &pos, (ceilingCheckHeight + sp94) - 4.0f, &D_801ED8B0, + if (BgCheck_EntityCheckCeiling(&play->colCtx, &y, &pos, (ceilingCheckHeight + sp94) - 4.0f, &D_801ED8B0, &D_801ED8B4, actor)) { actor->bgCheckFlags |= 0x10; actor->world.pos.y = (y + sp94) - 4.0f; @@ -1616,11 +1614,10 @@ void Actor_UpdateBgCheckInfo(GlobalContext* globalCtx, Actor* actor, f32 wallChe f32 y; pos.y = actor->prevPos.y; - func_800B7678(globalCtx, actor, &pos, flags); + func_800B7678(play, actor, &pos, flags); y = actor->world.pos.y; - if (WaterBox_GetSurface1(globalCtx, &globalCtx->colCtx, actor->world.pos.x, actor->world.pos.z, &y, - &waterbox)) { + if (WaterBox_GetSurface1(play, &play->colCtx, actor->world.pos.x, actor->world.pos.z, &y, &waterbox)) { actor->depthInWater = y - actor->world.pos.y; if (actor->depthInWater <= 0.0f) { actor->bgCheckFlags &= ~(0x40 | 0x20); @@ -1633,9 +1630,9 @@ void Actor_UpdateBgCheckInfo(GlobalContext* globalCtx, Actor* actor, f32 wallChe sp64.y = y; sp64.z = actor->world.pos.z; - EffectSsGRipple_Spawn(globalCtx, &sp64, 100, 500, 0); - EffectSsGRipple_Spawn(globalCtx, &sp64, 100, 500, 4); - EffectSsGRipple_Spawn(globalCtx, &sp64, 100, 500, 8); + EffectSsGRipple_Spawn(play, &sp64, 100, 500, 0); + EffectSsGRipple_Spawn(play, &sp64, 100, 500, 4); + EffectSsGRipple_Spawn(play, &sp64, 100, 500, 8); } } else { actor->bgCheckFlags &= ~0x40; @@ -1650,8 +1647,7 @@ void Actor_UpdateBgCheckInfo(GlobalContext* globalCtx, Actor* actor, f32 wallChe WaterBox* waterbox; f32 y = actor->world.pos.y; - if (WaterBox_GetSurface1(globalCtx, &globalCtx->colCtx, actor->world.pos.x, actor->world.pos.z, &y, - &waterbox)) { + if (WaterBox_GetSurface1(play, &play->colCtx, actor->world.pos.x, actor->world.pos.z, &y, &waterbox)) { actor->depthInWater = y - actor->world.pos.y; if (actor->depthInWater < 0.0f) { @@ -1665,9 +1661,9 @@ void Actor_UpdateBgCheckInfo(GlobalContext* globalCtx, Actor* actor, f32 wallChe sp50.y = y; sp50.z = actor->world.pos.z; - EffectSsGRipple_Spawn(globalCtx, &sp50, 100, 500, 0); - EffectSsGRipple_Spawn(globalCtx, &sp50, 100, 500, 4); - EffectSsGRipple_Spawn(globalCtx, &sp50, 100, 500, 8); + EffectSsGRipple_Spawn(play, &sp50, 100, 500, 0); + EffectSsGRipple_Spawn(play, &sp50, 100, 500, 4); + EffectSsGRipple_Spawn(play, &sp50, 100, 500, 8); } } else { actor->bgCheckFlags &= ~0x40; @@ -1719,41 +1715,41 @@ Hilite* Hilite_DrawXlu(Vec3f* object, Vec3f* eye, Vec3f* lightDir, GraphicsConte return hilite; } -void func_800B8050(Actor* actor, GlobalContext* globalCtx, s32 flag) { - Hilite* hilite = func_800BCBF4(&actor->world.pos, globalCtx); +void func_800B8050(Actor* actor, PlayState* play, s32 flag) { + Hilite* hilite = func_800BCBF4(&actor->world.pos, play); if (flag != 0) { Gfx* displayListHead; - Gfx* displayList = GRAPH_ALLOC(globalCtx->state.gfxCtx, 2 * sizeof(Gfx)); + Gfx* displayList = GRAPH_ALLOC(play->state.gfxCtx, 2 * sizeof(Gfx)); displayListHead = displayList; - OPEN_DISPS(globalCtx->state.gfxCtx); + OPEN_DISPS(play->state.gfxCtx); gDPSetHilite1Tile(displayListHead++, 1, hilite, 0x10, 0x10); gSPEndDisplayList(displayListHead); gSPSegment(POLY_OPA_DISP++, 0x07, displayList); - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->state.gfxCtx); } } -void func_800B8118(Actor* actor, GlobalContext* globalCtx, s32 flag) { - Hilite* hilite = func_800BCC68(&actor->world.pos, globalCtx); +void func_800B8118(Actor* actor, PlayState* play, s32 flag) { + Hilite* hilite = func_800BCC68(&actor->world.pos, play); if (flag != 0) { Gfx* displayListHead; - Gfx* displayList = GRAPH_ALLOC(globalCtx->state.gfxCtx, 2 * sizeof(Gfx)); + Gfx* displayList = GRAPH_ALLOC(play->state.gfxCtx, 2 * sizeof(Gfx)); displayListHead = displayList; - OPEN_DISPS(globalCtx->state.gfxCtx); + OPEN_DISPS(play->state.gfxCtx); gDPSetHilite1Tile(displayListHead++, 1, hilite, 0x10, 0x10); gSPEndDisplayList(displayListHead); gSPSegment(POLY_XLU_DISP++, 0x07, displayList); - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->state.gfxCtx); } } @@ -1854,11 +1850,10 @@ s32 Actor_ProcessTalkRequest(Actor* actor, GameState* gameState) { // Actor_PickUpExchange? Seems to be called with exchangeItemId -1 if the same actor used Actor_PickUp // This function is also used to toggle the "Speak" action on the A button -s32 func_800B8500(Actor* actor, GlobalContext* globalCtx, f32 xzRange, f32 yRange, s32 exchangeItemId) { - Player* player = GET_PLAYER(globalCtx); +s32 func_800B8500(Actor* actor, PlayState* play, f32 xzRange, f32 yRange, PlayerActionParam exchangeItemId) { + Player* player = GET_PLAYER(play); - if ((player->actor.flags & ACTOR_FLAG_100) || - ((exchangeItemId > EXCH_ITEM_NONE) && Player_InCsMode(&globalCtx->state)) || + if ((player->actor.flags & ACTOR_FLAG_100) || ((exchangeItemId > PLAYER_AP_NONE) && Player_InCsMode(play)) || (!actor->isTargeted && ((fabsf(actor->playerHeightRel) > fabsf(yRange)) || ((actor->xzDistToPlayer > player->targetActorDistance)) || (xzRange < actor->xzDistToPlayer)))) { @@ -1873,22 +1868,22 @@ s32 func_800B8500(Actor* actor, GlobalContext* globalCtx, f32 xzRange, f32 yRang return true; } -s32 func_800B85E0(Actor* actor, GlobalContext* globalCtx, f32 radius, s32 exchangeItemId) { - return func_800B8500(actor, globalCtx, radius, radius, exchangeItemId); +s32 func_800B85E0(Actor* actor, PlayState* play, f32 radius, PlayerActionParam exchangeItemId) { + return func_800B8500(actor, play, radius, radius, exchangeItemId); } -s32 func_800B8614(Actor* actor, GlobalContext* globalCtx, f32 radius) { - return func_800B85E0(actor, globalCtx, radius, EXCH_ITEM_NONE); +s32 func_800B8614(Actor* actor, PlayState* play, f32 radius) { + return func_800B85E0(actor, play, radius, PLAYER_AP_NONE); } -s32 func_800B863C(Actor* actor, GlobalContext* globalCtx) { +s32 func_800B863C(Actor* actor, PlayState* play) { f32 cylRadius = actor->colChkInfo.cylRadius + 50.0f; - return func_800B8614(actor, globalCtx, cylRadius); + return func_800B8614(actor, play, cylRadius); } -s32 Actor_TextboxIsClosing(Actor* actor, GlobalContext* globalCtx) { - if (Message_GetState(&globalCtx->msgCtx) == 2) { +s32 Actor_TextboxIsClosing(Actor* actor, PlayState* play) { + if (Message_GetState(&play->msgCtx) == TEXT_STATE_CLOSING) { actor->flags &= ~ACTOR_FLAG_100; return true; } @@ -1900,9 +1895,9 @@ s32 Actor_TextboxIsClosing(Actor* actor, GlobalContext* globalCtx) { * Changes the actor the Player is focussing on * Fails if Player is not already focussing on an actor or in a talking state */ -s32 Actor_ChangeFocus(Actor* actor1, GlobalContext* globalCtx, Actor* actor2) { +s32 Actor_ChangeFocus(Actor* actor1, PlayState* play, Actor* actor2) { Actor* targetActor; - Player* player = GET_PLAYER(globalCtx); + Player* player = GET_PLAYER(play); targetActor = player->targetActor; @@ -1915,8 +1910,8 @@ s32 Actor_ChangeFocus(Actor* actor1, GlobalContext* globalCtx, Actor* actor2) { return false; } -s32 Player_GetExchangeItemId(GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); +s32 Player_GetExchangeItemId(PlayState* play) { + Player* player = GET_PLAYER(play); return player->exchangeItemId; } @@ -1931,10 +1926,10 @@ s32 func_800B8718(Actor* actor, GameState* gameState) { } // Similar to func_800B8500 -s32 func_800B874C(Actor* actor, GlobalContext* globalCtx, f32 xzRange, f32 yRange) { - Player* player = GET_PLAYER(globalCtx); +s32 func_800B874C(Actor* actor, PlayState* play, f32 xzRange, f32 yRange) { + Player* player = GET_PLAYER(play); - if ((player->actor.flags & ACTOR_FLAG_20000000) || Player_InCsMode(&globalCtx->state) || + if ((player->actor.flags & ACTOR_FLAG_20000000) || Player_InCsMode(play) || (yRange < fabsf(actor->playerHeightRel)) || ((player->unk_A94 < actor->xzDistToPlayer)) || (xzRange < actor->xzDistToPlayer)) { return false; @@ -1945,44 +1940,46 @@ s32 func_800B874C(Actor* actor, GlobalContext* globalCtx, f32 xzRange, f32 yRang return true; } -s32 func_800B8804(Actor* actor, GlobalContext* globalCtx, f32 xzRange) { - return func_800B874C(actor, globalCtx, xzRange, 20.0f); +s32 func_800B8804(Actor* actor, PlayState* play, f32 xzRange) { + return func_800B874C(actor, play, xzRange, 20.0f); } -s32 func_800B882C(Actor* actor, GlobalContext* globalCtx) { +s32 func_800B882C(Actor* actor, PlayState* play) { f32 cylRadius = actor->colChkInfo.cylRadius + 50.0f; - return func_800B8804(actor, globalCtx, cylRadius); + return func_800B8804(actor, play, cylRadius); } -s32 func_800B886C(Actor* actor, GlobalContext* globalCtx) { - if (!(GET_PLAYER(globalCtx)->actor.flags & ACTOR_FLAG_20000000)) { +s32 func_800B886C(Actor* actor, PlayState* play) { + if (!(GET_PLAYER(play)->actor.flags & ACTOR_FLAG_20000000)) { return true; } return false; } -void Actor_GetScreenPos(GlobalContext* globalCtx, Actor* actor, s16* x, s16* y) { +void Actor_GetScreenPos(PlayState* play, Actor* actor, s16* x, s16* y) { Vec3f projectedPos; - f32 w; + f32 invW; - Actor_GetProjectedPos(globalCtx, &actor->focus.pos, &projectedPos, &w); - *x = (projectedPos.x * w * (SCREEN_WIDTH / 2)) + (SCREEN_WIDTH / 2); - *y = (projectedPos.y * w * -(SCREEN_HEIGHT / 2)) + (SCREEN_HEIGHT / 2); + Actor_GetProjectedPos(play, &actor->focus.pos, &projectedPos, &invW); + + *x = PROJECTED_TO_SCREEN_X(projectedPos, invW); + *y = PROJECTED_TO_SCREEN_Y(projectedPos, invW); } -s32 func_800B8934(GlobalContext* globalCtx, Actor* actor) { - Vec3f sp2C; - f32 sp28; +s32 Actor_OnScreen(PlayState* play, Actor* actor) { + Vec3f projectedPos; + f32 invW; s32 pad[2]; - Actor_GetProjectedPos(globalCtx, &actor->focus.pos, &sp2C, &sp28); + Actor_GetProjectedPos(play, &actor->focus.pos, &projectedPos, &invW); - return (sp2C.x * sp28 >= -1.0f) && (sp2C.x * sp28 <= 1.0f) && (sp2C.y * sp28 >= -1.0f) && (sp2C.y * sp28 <= 1.0f); + return (projectedPos.x * invW >= -1.0f) && (projectedPos.x * invW <= 1.0f) && (projectedPos.y * invW >= -1.0f) && + (projectedPos.y * invW <= 1.0f); } -s32 Actor_HasParent(Actor* actor, GlobalContext* globalCtx) { +s32 Actor_HasParent(Actor* actor, PlayState* play) { if (actor->parent != NULL) { return true; } else { @@ -1997,16 +1994,16 @@ s32 Actor_HasParent(Actor* actor, GlobalContext* globalCtx) { * GI_NONE is usually used as a special case to lift an actor * GI_MAX is usually used to catch an actor in a bottle */ -s32 Actor_PickUp(Actor* actor, GlobalContext* globalCtx, s32 getItemId, f32 xzRange, f32 yRange) { - Player* player = GET_PLAYER(globalCtx); +s32 Actor_PickUp(Actor* actor, PlayState* play, s32 getItemId, f32 xzRange, f32 yRange) { + Player* player = GET_PLAYER(play); 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 +2013,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->playerActorCsIds[1]); + ActorCutscene_SetIntentToPlay(play->playerActorCsIds[1]); } return true; @@ -2028,19 +2025,19 @@ s32 Actor_PickUp(Actor* actor, GlobalContext* globalCtx, s32 getItemId, f32 xzRa return false; } -s32 Actor_PickUpNearby(Actor* actor, GlobalContext* globalCtx, s32 getItemId) { - return Actor_PickUp(actor, globalCtx, getItemId, 50.0f, 10.0f); +s32 Actor_PickUpNearby(Actor* actor, PlayState* play, s32 getItemId) { + return Actor_PickUp(actor, play, getItemId, 50.0f, 10.0f); } -s32 Actor_LiftActor(Actor* actor, GlobalContext* globalCtx) { - return Actor_PickUpNearby(actor, globalCtx, GI_NONE); +s32 Actor_LiftActor(Actor* actor, PlayState* play) { + return Actor_PickUpNearby(actor, play, GI_NONE); } -s32 Actor_PickUpFar(Actor* actor, GlobalContext* globalCtx, s32 getItemId) { - return Actor_PickUp(actor, globalCtx, getItemId, 9999.9f, 9999.9f); +s32 Actor_PickUpFar(Actor* actor, PlayState* play, s32 getItemId) { + return Actor_PickUp(actor, play, getItemId, 9999.9f, 9999.9f); } -s32 Actor_HasNoParent(Actor* actor, GlobalContext* globalCtx) { +s32 Actor_HasNoParent(Actor* actor, PlayState* play) { if (actor->parent == NULL) { return true; } @@ -2048,7 +2045,7 @@ s32 Actor_HasNoParent(Actor* actor, GlobalContext* globalCtx) { return false; } -void func_800B8C20(Actor* actorA, Actor* actorB, GlobalContext* globalCtx) { +void func_800B8C20(Actor* actorA, Actor* actorB, PlayState* play) { Actor* parent = actorA->parent; if (parent->id == ACTOR_PLAYER) { @@ -2063,15 +2060,15 @@ void func_800B8C20(Actor* actorA, Actor* actorB, GlobalContext* globalCtx) { actorA->parent = NULL; } -void func_800B8C50(Actor* actor, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); +void func_800B8C50(Actor* actor, PlayState* play) { + Player* player = GET_PLAYER(play); if (actor->xyzDistToPlayerSq < player->unk_AA0) { player->unk_AA0 = actor->xyzDistToPlayerSq; } } -s32 Actor_HasRider(GlobalContext* globalCtx, Actor* horse) { +s32 Actor_HasRider(PlayState* play, Actor* horse) { if (horse->child != NULL) { return true; } @@ -2079,8 +2076,8 @@ s32 Actor_HasRider(GlobalContext* globalCtx, Actor* horse) { return false; } -s32 Actor_SetRideActor(GlobalContext* globalCtx, Actor* horse, s32 mountSide) { - Player* player = GET_PLAYER(globalCtx); +s32 Actor_SetRideActor(PlayState* play, Actor* horse, s32 mountSide) { + Player* player = GET_PLAYER(play); if (!(player->stateFlags1 & 0x003C7880)) { player->rideActor = horse; @@ -2092,7 +2089,7 @@ s32 Actor_SetRideActor(GlobalContext* globalCtx, Actor* horse, s32 mountSide) { return false; } -s32 Actor_HasNoRider(GlobalContext* globalCtx, Actor* horse) { +s32 Actor_HasNoRider(PlayState* play, Actor* horse) { if (horse->child == NULL) { return true; } @@ -2100,8 +2097,8 @@ s32 Actor_HasNoRider(GlobalContext* globalCtx, Actor* horse) { return false; } -void func_800B8D10(GlobalContext* globalCtx, Actor* actor, f32 arg2, s16 arg3, f32 arg4, u32 arg5, u32 arg6) { - Player* player = GET_PLAYER(globalCtx); +void func_800B8D10(PlayState* play, Actor* actor, f32 arg2, s16 arg3, f32 arg4, u32 arg5, u32 arg6) { + Player* player = GET_PLAYER(play); player->unk_B74 = arg6; player->unk_B75 = arg5; @@ -2110,27 +2107,28 @@ void func_800B8D10(GlobalContext* globalCtx, Actor* actor, f32 arg2, s16 arg3, f player->unk_B7C = arg4; } -void func_800B8D50(GlobalContext* globalCtx, Actor* actor, f32 arg2, s16 yaw, f32 arg4, u32 arg5) { - func_800B8D10(globalCtx, actor, arg2, yaw, arg4, 3, arg5); +void func_800B8D50(PlayState* play, Actor* actor, f32 arg2, s16 yaw, f32 arg4, u32 arg5) { + func_800B8D10(play, actor, arg2, yaw, arg4, 3, arg5); } -void func_800B8D98(GlobalContext* globalCtx, Actor* actor, f32 arg2, s16 arg3, f32 arg4) { - func_800B8D50(globalCtx, actor, arg2, arg3, arg4, 0); +void func_800B8D98(PlayState* play, Actor* actor, f32 arg2, s16 arg3, f32 arg4) { + func_800B8D50(play, actor, arg2, arg3, arg4, 0); } -void func_800B8DD4(GlobalContext* globalCtx, Actor* actor, f32 arg2, s16 arg3, f32 arg4, u32 arg5) { - func_800B8D10(globalCtx, actor, arg2, arg3, arg4, 2, arg5); +void func_800B8DD4(PlayState* play, Actor* actor, f32 arg2, s16 arg3, f32 arg4, u32 arg5) { + func_800B8D10(play, actor, arg2, arg3, arg4, 2, arg5); } -void func_800B8E1C(GlobalContext* globalCtx, Actor* actor, f32 arg2, s16 arg3, f32 arg4) { - func_800B8DD4(globalCtx, actor, arg2, arg3, arg4, 0); +void func_800B8E1C(PlayState* play, Actor* actor, f32 arg2, s16 arg3, f32 arg4) { + func_800B8DD4(play, actor, arg2, arg3, arg4, 0); } void func_800B8E58(Player* player, u16 sfxId) { if (player->currentMask == PLAYER_MASK_GIANT) { func_8019F170(&player->actor.projectedPos, sfxId); } else { - Audio_PlaySfxGeneral(sfxId, &player->actor.projectedPos, 4, &D_801DB4B0, &D_801DB4B0, &D_801DB4B8); + AudioSfx_PlaySfx(sfxId, &player->actor.projectedPos, 4, &gSfxDefaultFreqAndVolScale, + &gSfxDefaultFreqAndVolScale, &gSfxDefaultReverb); } } @@ -2141,7 +2139,7 @@ void Actor_PlaySfxAtPos(Actor* actor, u16 sfxId) { Audio_PlaySfxAtPos(&actor->projectedPos, sfxId); } -void func_800B8EF4(GlobalContext* globalCtx, Actor* actor) { +void func_800B8EF4(PlayState* play, Actor* actor) { u32 sfxId; if (actor->bgCheckFlags & 0x20) { @@ -2151,7 +2149,7 @@ void func_800B8EF4(GlobalContext* globalCtx, Actor* actor) { sfxId = NA_SE_PL_WALK_WATER1 - SFX_FLAG; } } else { - sfxId = SurfaceType_GetSfx(&globalCtx->colCtx, actor->floorPoly, actor->floorBgId); + sfxId = SurfaceType_GetSfx(&play->colCtx, actor->floorPoly, actor->floorBgId); } Audio_PlaySfxAtPos(&actor->projectedPos, NA_SE_EV_BOMB_BOUND); @@ -2206,18 +2204,18 @@ void func_800B9098(Actor* actor) { actor->audioFlags |= 0x40; } -s32 func_800B90AC(GlobalContext* globalCtx, Actor* actor, CollisionPoly* polygon, s32 index, s32 arg4) { - if (func_800C99D4(&globalCtx->colCtx, polygon, index) == 8) { +s32 func_800B90AC(PlayState* play, Actor* actor, CollisionPoly* polygon, s32 bgId, s32 arg4) { + if (func_800C99D4(&play->colCtx, polygon, bgId) == 8) { return true; } return false; } -void func_800B90F4(GlobalContext* globalCtx) { - if (globalCtx->actorCtx.unk3 != 0) { - globalCtx->actorCtx.unk3 = 0; - func_80115D5C(&globalCtx->state); +void func_800B90F4(PlayState* play) { + if (play->actorCtx.unk3 != 0) { + play->actorCtx.unk3 = 0; + func_80115D5C(&play->state); } } @@ -2231,18 +2229,18 @@ void func_800B9120(ActorContext* actorCtx) { actorCtx->unkC = 0x200 >> phi_v0; } -void Actor_InitContext(GlobalContext* globalCtx, ActorContext* actorCtx, ActorEntry* actorEntry) { +void Actor_InitContext(PlayState* play, ActorContext* actorCtx, ActorEntry* actorEntry) { ActorOverlay* overlayEntry; CycleSceneFlags* cycleFlags; s32 i; gSaveContext.save.weekEventReg[92] |= 0x80; - cycleFlags = &gSaveContext.cycleSceneFlags[Play_GetOriginalSceneNumber(globalCtx->sceneNum)]; + cycleFlags = &gSaveContext.cycleSceneFlags[Play_GetOriginalSceneNumber(play->sceneNum)]; bzero(actorCtx, sizeof(ActorContext)); ActorOverlayTable_Init(); - Matrix_MtxFCopy(&globalCtx->billboardMtxF, &gIdentityMtxF); - Matrix_MtxFCopy(&globalCtx->viewProjectionMtxF, &gIdentityMtxF); + Matrix_MtxFCopy(&play->billboardMtxF, &gIdentityMtxF); + Matrix_MtxFCopy(&play->viewProjectionMtxF, &gIdentityMtxF); overlayEntry = gActorOverlayTable; for (i = 0; i < ARRAY_COUNT(gActorOverlayTable); i++) { @@ -2254,42 +2252,42 @@ void Actor_InitContext(GlobalContext* globalCtx, ActorContext* actorCtx, ActorEn actorCtx->flags.chest = cycleFlags->chest; actorCtx->flags.switches[0] = cycleFlags->switch0; actorCtx->flags.switches[1] = cycleFlags->switch1; - if (globalCtx->sceneNum == SCENE_INISIE_R) { - cycleFlags = &gSaveContext.cycleSceneFlags[globalCtx->sceneNum]; + if (play->sceneNum == SCENE_INISIE_R) { + cycleFlags = &gSaveContext.cycleSceneFlags[play->sceneNum]; } actorCtx->flags.collectible[0] = cycleFlags->collectible; actorCtx->flags.clearedRoom = cycleFlags->clearedRoom; - TitleCard_ContextInit(&globalCtx->state, &actorCtx->titleCtxt); - func_800B6468(globalCtx); + TitleCard_ContextInit(&play->state, &actorCtx->titleCtxt); + func_800B6468(play); actorCtx->absoluteSpace = NULL; - Actor_SpawnEntry(actorCtx, actorEntry, globalCtx); - Actor_TargetContextInit(&actorCtx->targetContext, actorCtx->actorLists[ACTORCAT_PLAYER].first, globalCtx); + Actor_SpawnEntry(actorCtx, actorEntry, play); + Actor_TargetContextInit(&actorCtx->targetContext, actorCtx->actorLists[ACTORCAT_PLAYER].first, play); func_800B9120(actorCtx); Fault_AddClient(&sActorFaultClient, (void*)Actor_PrintLists, actorCtx, NULL); - func_800B722C(&globalCtx->state, (Player*)actorCtx->actorLists[ACTORCAT_PLAYER].first); + func_800B722C(&play->state, (Player*)actorCtx->actorLists[ACTORCAT_PLAYER].first); } /** * Spawns the actors in the current setup (of the current scene/setup/room triple) * Only spawns actors based on the time flags embedded in their rotation parameters */ -void Actor_SpawnSetupActors(GlobalContext* globalCtx, ActorContext* actorCtx) { - if (globalCtx->numSetupActors > 0) { - ActorEntry* actorEntry = globalCtx->setupActorList; +void Actor_SpawnSetupActors(PlayState* play, ActorContext* actorCtx) { + if (play->numSetupActors > 0) { + ActorEntry* actorEntry = play->setupActorList; s32 temp_fp = actorCtx->unkC; s32 temp_s1; s32 phi_v0; s32 i; func_800B9120(actorCtx); - func_800BA8B8(globalCtx, &globalCtx->actorCtx); + func_800BA8B8(play, &play->actorCtx); temp_s1 = (actorCtx->unkC * 2) & 0x2FF; - for (i = 0; i < globalCtx->numSetupActors; i++) { + for (i = 0; i < play->numSetupActors; i++) { phi_v0 = ((actorEntry->rot.x & 7) << 7) | (actorEntry->rot.z & 0x7F); if (phi_v0 == 0) { phi_v0 = 0x3FF; @@ -2297,18 +2295,18 @@ void Actor_SpawnSetupActors(GlobalContext* globalCtx, ActorContext* actorCtx) { if (!(phi_v0 & temp_fp) && (phi_v0 & actorCtx->unkC) && (!(gSaveContext.eventInf[1] & 0x80) || !(phi_v0 & temp_s1) || !(actorEntry->id & 0x800))) { - Actor_SpawnEntry(&globalCtx->actorCtx, actorEntry, globalCtx); + Actor_SpawnEntry(&play->actorCtx, actorEntry, play); } actorEntry++; } // Prevents re-spawning the setup actors - globalCtx->numSetupActors = -globalCtx->numSetupActors; + play->numSetupActors = -play->numSetupActors; } } typedef struct { - /* 0x00 */ GlobalContext* globalCtx; + /* 0x00 */ PlayState* play; /* 0x04 */ Actor* actor; /* 0x08 */ u32 unk_08; /* 0x0C */ u32 unkC; @@ -2319,7 +2317,7 @@ typedef struct { } UpdateActor_Params; // size = 0x1C Actor* Actor_UpdateActor(UpdateActor_Params* params) { - GlobalContext* globalCtx = params->globalCtx; + PlayState* play = params->play; Actor* actor = params->actor; Actor* nextActor; @@ -2331,21 +2329,21 @@ Actor* Actor_UpdateActor(UpdateActor_Params* params) { actor->audioFlags &= ~0x7F; if (actor->init != NULL) { - if (Object_IsLoaded(&globalCtx->objectCtx, actor->objBankIndex)) { - Actor_SetObjectDependency(globalCtx, actor); - actor->init(actor, globalCtx); + if (Object_IsLoaded(&play->objectCtx, actor->objBankIndex)) { + Actor_SetObjectDependency(play, actor); + actor->init(actor, play); actor->init = NULL; } nextActor = actor->next; } else if (actor->update == NULL) { if (!actor->isDrawn) { - nextActor = Actor_Delete(&globalCtx->actorCtx, actor, globalCtx); + nextActor = Actor_Delete(&play->actorCtx, actor, play); } else { - Actor_Destroy(actor, globalCtx); + Actor_Destroy(actor, play); nextActor = actor->next; } } else { - if (!Object_IsLoaded(&globalCtx->objectCtx, actor->objBankIndex)) { + if (!Object_IsLoaded(&play->objectCtx, actor->objBankIndex)) { Actor_MarkForDeath(actor); } else { s32 tmp = (params->unk_08 == 0); @@ -2377,14 +2375,14 @@ Actor* Actor_UpdateActor(UpdateActor_Params* params) { actor->targetPriority = 0; } - Actor_SetObjectDependency(globalCtx, actor); + Actor_SetObjectDependency(play, actor); if (actor->colorFilterTimer != 0) { actor->colorFilterTimer--; } - actor->update(actor, globalCtx); - BgCheck_ResetFlagsIfLoadedActor(globalCtx, &globalCtx->colCtx.dyna, actor); + actor->update(actor, play); + BgCheck_ResetFlagsIfLoadedActor(play, &play->colCtx.dyna, actor); } CollisionCheck_ResetDamage(&actor->colChkInfo); @@ -2400,10 +2398,10 @@ u32 D_801AED58[] = { 0x10000282, 0x00000002, 0x300002C2, 0x100006C2, 0x00000002, 0x100002C2, }; -void Actor_UpdateAll(GlobalContext* globalCtx, ActorContext* actorCtx) { +void Actor_UpdateAll(PlayState* play, ActorContext* actorCtx) { s32 i; Actor* actor; - Player* player = GET_PLAYER(globalCtx); + Player* player = GET_PLAYER(play); u32* tmp; s32 cat; Actor* next; @@ -2411,15 +2409,15 @@ void Actor_UpdateAll(GlobalContext* globalCtx, ActorContext* actorCtx) { UpdateActor_Params params; params.player = player; - params.globalCtx = globalCtx; + params.play = play; - if (globalCtx->unk_18844 != 0) { + if (play->unk_18844 != 0) { params.unk_18 = ACTOR_FLAG_200000; } else { params.unk_18 = ACTOR_FLAG_200000 | ACTOR_FLAG_40 | ACTOR_FLAG_10; } - Actor_SpawnSetupActors(globalCtx, actorCtx); + Actor_SpawnSetupActors(play, actorCtx); if (actorCtx->unk2 != 0) { actorCtx->unk2--; @@ -2448,7 +2446,7 @@ void Actor_UpdateAll(GlobalContext* globalCtx, ActorContext* actorCtx) { } if (i == ACTORCAT_BG) { - DynaPoly_Setup(globalCtx, &globalCtx->colCtx.dyna); + DynaPoly_Setup(play, &play->colCtx.dyna); } } @@ -2463,7 +2461,7 @@ void Actor_UpdateAll(GlobalContext* globalCtx, ActorContext* actorCtx) { next = actor->next; cat = actor->category; actor->category = i; - Actor_RemoveFromCategory(globalCtx, actorCtx, actor); + Actor_RemoveFromCategory(play, actorCtx, actor); Actor_AddToCategory(actorCtx, actor, cat); actor = next; } @@ -2487,44 +2485,43 @@ void Actor_UpdateAll(GlobalContext* globalCtx, ActorContext* actorCtx) { } if (!(player->stateFlags1 & 2)) { - func_800B5814(&actorCtx->targetContext, player, actor, &globalCtx->state); + func_800B5814(&actorCtx->targetContext, player, actor, &play->state); } - TitleCard_Update(&globalCtx->state, &actorCtx->titleCtxt); - func_800B6474(globalCtx); - DynaPoly_UpdateBgActorTransforms(globalCtx, &globalCtx->colCtx.dyna); + TitleCard_Update(&play->state, &actorCtx->titleCtxt); + func_800B6474(play); + DynaPoly_UpdateBgActorTransforms(play, &play->colCtx.dyna); } -void Actor_Draw(GlobalContext* globalCtx, Actor* actor) { +void Actor_Draw(PlayState* play, Actor* actor) { Lights* light; - OPEN_DISPS(globalCtx->state.gfxCtx); + OPEN_DISPS(play->state.gfxCtx); - light = LightContext_NewLights(&globalCtx->lightCtx, globalCtx->state.gfxCtx); - if ((actor->flags & ACTOR_FLAG_10000000) && (globalCtx->roomCtx.currRoom.enablePosLights || (MREG(93) != 0))) { + light = LightContext_NewLights(&play->lightCtx, play->state.gfxCtx); + if ((actor->flags & ACTOR_FLAG_10000000) && (play->roomCtx.currRoom.enablePosLights || (MREG(93) != 0))) { light->enablePosLights = true; } - Lights_BindAll(light, globalCtx->lightCtx.listHead, - (actor->flags & (ACTOR_FLAG_10000000 | ACTOR_FLAG_400000)) ? NULL : &actor->world.pos, globalCtx); - Lights_Draw(light, globalCtx->state.gfxCtx); + Lights_BindAll(light, play->lightCtx.listHead, + (actor->flags & (ACTOR_FLAG_10000000 | ACTOR_FLAG_400000)) ? NULL : &actor->world.pos, play); + Lights_Draw(light, play->state.gfxCtx); if (actor->flags & ACTOR_FLAG_1000) { - Matrix_SetStateRotationAndTranslation( - actor->world.pos.x + globalCtx->mainCamera.skyboxOffset.x, - actor->world.pos.y + ((actor->shape.yOffset * actor->scale.y) + globalCtx->mainCamera.skyboxOffset.y), - actor->world.pos.z + globalCtx->mainCamera.skyboxOffset.z, &actor->shape.rot); + Matrix_SetTranslateRotateYXZ(actor->world.pos.x + play->mainCamera.quakeOffset.x, + actor->world.pos.y + + ((actor->shape.yOffset * actor->scale.y) + play->mainCamera.quakeOffset.y), + actor->world.pos.z + play->mainCamera.quakeOffset.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); - Actor_SetObjectDependency(globalCtx, actor); + Actor_SetObjectDependency(play, actor); - gSPSegment(POLY_OPA_DISP++, 0x06, globalCtx->objectCtx.status[actor->objBankIndex].segment); - gSPSegment(POLY_XLU_DISP++, 0x06, globalCtx->objectCtx.status[actor->objBankIndex].segment); + gSPSegment(POLY_OPA_DISP++, 0x06, play->objectCtx.status[actor->objBankIndex].segment); + gSPSegment(POLY_XLU_DISP++, 0x06, play->objectCtx.status[actor->objBankIndex].segment); if (actor->colorFilterTimer != 0) { s32 temp_v0_2 = actor->colorFilterParams & 0xC000; @@ -2542,28 +2539,28 @@ void Actor_Draw(GlobalContext* globalCtx, Actor* actor) { } if (actor->colorFilterParams & 0x2000) { - func_800AE778(globalCtx, &actorDefaultHitColor, actor->colorFilterTimer, actor->colorFilterParams & 0xFF); + func_800AE778(play, &actorDefaultHitColor, actor->colorFilterTimer, actor->colorFilterParams & 0xFF); } else { - func_800AE434(globalCtx, &actorDefaultHitColor, actor->colorFilterTimer, actor->colorFilterParams & 0xFF); + func_800AE434(play, &actorDefaultHitColor, actor->colorFilterTimer, actor->colorFilterParams & 0xFF); } } - actor->draw(actor, globalCtx); + actor->draw(actor, play); if (actor->colorFilterTimer != 0) { if (actor->colorFilterParams & 0x2000) { - func_800AE8EC(globalCtx); + func_800AE8EC(play); } else { - func_800AE5A0(globalCtx); + func_800AE5A0(play); } } if (actor->shape.shadowDraw != NULL) { - actor->shape.shadowDraw(actor, light, globalCtx); + actor->shape.shadowDraw(actor, light, play); } actor->isDrawn = true; - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->state.gfxCtx); } void func_800B9D1C(Actor* actor) { @@ -2571,13 +2568,14 @@ void func_800B9D1C(Actor* actor) { if (sfxId != 0) { if (actor->audioFlags & 2) { - Audio_PlaySfxGeneral(sfxId, &actor->projectedPos, 4, &D_801DB4B0, &D_801DB4B0, &D_801DB4B8); + AudioSfx_PlaySfx(sfxId, &actor->projectedPos, 4, &gSfxDefaultFreqAndVolScale, &gSfxDefaultFreqAndVolScale, + &gSfxDefaultReverb); } else if (actor->audioFlags & 4) { play_sound(sfxId); } else if (actor->audioFlags & 8) { func_8019F128(sfxId); } else if (actor->audioFlags & 0x10) { - func_801A0810(&D_801DB4A4, NA_SE_SY_TIMER - SFX_FLAG, (sfxId - 1)); + func_801A0810(&gSfxDefaultPos, NA_SE_SY_TIMER - SFX_FLAG, (sfxId - 1)); } else if (actor->audioFlags & 1) { Audio_PlaySfxAtPos(&actor->projectedPos, sfxId); } @@ -2594,18 +2592,18 @@ void func_800B9D1C(Actor* actor) { } } -void Actor_DrawAllSetup(GlobalContext* globalCtx) { - globalCtx->actorCtx.undrawnActorCount = 0; - globalCtx->actorCtx.unkB = 0; +void Actor_DrawAllSetup(PlayState* play) { + play->actorCtx.undrawnActorCount = 0; + play->actorCtx.unkB = 0; } -s32 Actor_RecordUndrawnActor(GlobalContext* globalCtx, Actor* actor) { - if (globalCtx->actorCtx.undrawnActorCount >= 32) { +s32 Actor_RecordUndrawnActor(PlayState* play, Actor* actor) { + if (play->actorCtx.undrawnActorCount >= 32) { return false; } - globalCtx->actorCtx.undrawnActors[globalCtx->actorCtx.undrawnActorCount] = actor; - globalCtx->actorCtx.undrawnActorCount++; + play->actorCtx.undrawnActors[play->actorCtx.undrawnActorCount] = actor; + play->actorCtx.undrawnActorCount++; return true; } @@ -2615,7 +2613,7 @@ void func_800B9E84(Gfx** arg0, s32 arg1) { #ifdef NON_EQUIVALENT // Related to draw actors with lens -void func_800B9EF4(GlobalContext* globalCtx, s32 numActors, Actor** actors) { +void func_800B9EF4(PlayState* play, s32 numActors, Actor** actors) { s32 spB4; Gfx* spAC; void* spA8; // pad @@ -2633,18 +2631,18 @@ void func_800B9EF4(GlobalContext* globalCtx, s32 numActors, Actor** actors) { Gfx* phi_s1_2; // void* phi_s1_4; - OPEN_DISPS(globalCtx->state.gfxCtx); - // temp_s2 = globalCtx->state.gfxCtx; + OPEN_DISPS(play->state.gfxCtx); + // temp_s2 = play->state.gfxCtx; if (numActors > 0) { spAC = POLY_XLU_DISP; - // sp34 = globalCtx + 0x18000; - spA4 = globalCtx->unk_18E68; + // sp34 = play + 0x18000; + spA4 = play->unk_18E68; - PreRender_SetValues(&globalCtx->pauseBgPreRender, D_801FBBCC, D_801FBBCE, __gfxCtx->curFrameBuffer, + PreRender_SetValues(&play->pauseBgPreRender, D_801FBBCC, D_801FBBCE, __gfxCtx->curFrameBuffer, __gfxCtx->zbuffer); - func_80170200(&globalCtx->pauseBgPreRender, &spAC, __gfxCtx->zbuffer, (void*)spA4); + func_80170200(&play->pauseBgPreRender, &spAC, __gfxCtx->zbuffer, (void*)spA4); // spAC->words.w0 = 0xE7000000; // spAC->words.w1 = 0; @@ -2672,7 +2670,7 @@ void func_800B9EF4(GlobalContext* globalCtx, s32 numActors, Actor** actors) { gDPSetPrimColor(spAC++, 0, 0, 0, 0, 0, 255); // temp_s1_5 = spAC; - if (globalCtx->roomCtx.currRoom.unk5 == 0) { + if (play->roomCtx.currRoom.unk5 == 0) { // temp_s1_5->words.w0 = 0xFC61E6C3; // temp_s1_5->words.w1 = 0x11CF9FCF; // phi_s1 = temp_s1_5 + 8; @@ -2686,14 +2684,14 @@ void func_800B9EF4(GlobalContext* globalCtx, s32 numActors, Actor** actors) { } // spAC = phi_s1; - func_800B9E84(&spAC, globalCtx->actorCtx.unk4); - phi_s1_2 = func_801660B8(globalCtx, spAC); + func_800B9E84(&spAC, play->actorCtx.unk4); + phi_s1_2 = func_801660B8(play, spAC); for (spB4 = 0; spB4 < numActors; spB4++, actors++) { - Actor_Draw(globalCtx, *actors); + Actor_Draw(play, *actors); } - // temp_s0_2 = &globalCtx->pauseBgPreRender; + // temp_s0_2 = &play->pauseBgPreRender; // phi_s1_2->words.w0 = 0xE7000000; // phi_s1_2->words.w1 = 0; @@ -2722,7 +2720,7 @@ void func_800B9EF4(GlobalContext* globalCtx, s32 numActors, Actor** actors) { // temp_a0_2 = &spAC; // if (sp34->unk_6E5 == 0) { - if (globalCtx->roomCtx.currRoom.unk5 == 0) { + if (play->roomCtx.currRoom.unk5 == 0) { // temp_s1_10->unk_0 = 0xFC119623; // temp_s1_10->unk_4 = 0xFF2FFFFF; // phi_s1_4 = temp_s1_10 + 8; @@ -2740,14 +2738,13 @@ void func_800B9EF4(GlobalContext* globalCtx, s32 numActors, Actor** actors) { // phi_s1_4->unk_0 = (s32) (((sp34->unk_B4C - 1) & 0xFFF) | 0xFF100000); // temp_s1_11 = phi_s1_4 + 8; // phi_s1_4->unk_4 = spA4; - gDPSetColorImage(phi_s1_2++, G_IM_FMT_RGBA, G_IM_SIZ_16b, ((globalCtx->pauseBgPreRender.width - 1) & 0xFFF), - spA4); + gDPSetColorImage(phi_s1_2++, G_IM_FMT_RGBA, G_IM_SIZ_16b, ((play->pauseBgPreRender.width - 1) & 0xFFF), spA4); // temp_s1_11 = phi_s1_2; spAC = phi_s1_2; // spAC = temp_s1_11; - func_800B9E84(&spAC, (s32)globalCtx->actorCtx.unk4); + func_800B9E84(&spAC, (s32)play->actorCtx.unk4); // temp_s1_11->words.w0 = 0xE7000000; // temp_s1_11->words.w1 = 0; // temp_s1_12 = temp_s1_11 + 8; @@ -2761,13 +2758,13 @@ void func_800B9EF4(GlobalContext* globalCtx, s32 numActors, Actor** actors) { // temp_s1_14 = temp_s1_13 + 8; // temp_s1_13->words.w0 = ((sp34->unk_B4C - 1) & 0xFFF) | 0xFF100000; // temp_s1_13->words.w1 = sp34->unk_B5C; - gDPSetColorImage(spAC++, G_IM_FMT_RGBA, G_IM_SIZ_16b, ((globalCtx->pauseBgPreRender.width - 1) & 0xFFF), - globalCtx->pauseBgPreRender.fbuf); + gDPSetColorImage(spAC++, G_IM_FMT_RGBA, G_IM_SIZ_16b, ((play->pauseBgPreRender.width - 1) & 0xFFF), + play->pauseBgPreRender.fbuf); // temp_a1 = &spAC; // spAC = temp_s1_14; - // func_8016FDB8(&globalCtx->pauseBgPreRender, temp_a1, (void* ) spA4, spA8, 1U); - func_8016FDB8(&globalCtx->pauseBgPreRender, &spAC, (void*)spA4, __gfxCtx->zbuffer, 1U); + // func_8016FDB8(&play->pauseBgPreRender, temp_a1, (void* ) spA4, spA8, 1U); + func_8016FDB8(&play->pauseBgPreRender, &spAC, (void*)spA4, __gfxCtx->zbuffer, 1U); // // POLY_OPA_DISP = temp_s1_14; POLY_OPA_DISP = spAC; @@ -2799,22 +2796,22 @@ void func_800B9EF4(GlobalContext* globalCtx, s32 numActors, Actor** actors) { // spAC = temp_s1_18 + 8; gDPSetPrimColor(spAC++, 0, 0, 74, 0, 0, 74); - func_800B9E84(&spAC, (s32)globalCtx->actorCtx.unk4); + func_800B9E84(&spAC, (s32)play->actorCtx.unk4); OVERLAY_DISP = spAC; - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->state.gfxCtx); } #else -void func_800B9EF4(GlobalContext* globalCtx, s32 numActors, Actor** actors); +void func_800B9EF4(PlayState* play, s32 numActors, Actor** actors); #pragma GLOBAL_ASM("asm/non_matchings/code/z_actor/func_800B9EF4.s") #endif -s32 func_800BA2D8(GlobalContext* globalCtx, Actor* actor) { - return func_800BA2FC(globalCtx, actor, &actor->projectedPos, actor->projectedW); +s32 func_800BA2D8(PlayState* play, Actor* actor) { + return func_800BA2FC(play, actor, &actor->projectedPos, actor->projectedW); } -s32 func_800BA2FC(GlobalContext* globalCtx, Actor* actor, Vec3f* projectedPos, f32 projectedW) { +s32 func_800BA2FC(PlayState* play, Actor* actor, Vec3f* projectedPos, f32 projectedW) { if ((-actor->uncullZoneScale < projectedPos->z) && (projectedPos->z < (actor->uncullZoneForward + actor->uncullZoneScale))) { f32 phi_f12; @@ -2822,10 +2819,10 @@ s32 func_800BA2FC(GlobalContext* globalCtx, Actor* actor, Vec3f* projectedPos, f f32 phi_f14; f32 phi_f16; - if (globalCtx->view.fovy != 60.0f) { - phi_f12 = actor->uncullZoneScale * globalCtx->unk_187F0.x * 0.76980036f; // sqrt(16/27) + if (play->view.fovy != 60.0f) { + phi_f12 = actor->uncullZoneScale * play->unk_187F0.x * 0.76980036f; // sqrt(16/27) - phi_f14 = globalCtx->unk_187F0.y * 0.57735026f; // 1 / sqrt(3) + phi_f14 = play->unk_187F0.y * 0.57735026f; // 1 / sqrt(3) phi_f16 = actor->uncullZoneScale * phi_f14; phi_f14 *= actor->uncullZoneDownward; } else { @@ -2842,7 +2839,7 @@ s32 func_800BA2FC(GlobalContext* globalCtx, Actor* actor, Vec3f* projectedPos, f return false; } -void Actor_DrawAll(GlobalContext* globalCtx, ActorContext* actorCtx) { +void Actor_DrawAll(PlayState* play, ActorContext* actorCtx) { s32 pad[2]; Gfx* ref2; Gfx* tmp2; @@ -2853,15 +2850,15 @@ void Actor_DrawAll(GlobalContext* globalCtx, ActorContext* actorCtx) { s32 actorFlags; s32 i; - if (globalCtx->unk_18844 != 0) { + if (play->unk_18844 != 0) { actorFlags = ACTOR_FLAG_200000; } else { actorFlags = ACTOR_FLAG_200000 | ACTOR_FLAG_40 | ACTOR_FLAG_20; } - OPEN_DISPS(globalCtx->state.gfxCtx); + OPEN_DISPS(play->state.gfxCtx); - Actor_DrawAllSetup(globalCtx); + Actor_DrawAllSetup(play); sp58 = POLY_XLU_DISP; POLY_XLU_DISP = &sp58[1]; @@ -2870,14 +2867,14 @@ void Actor_DrawAll(GlobalContext* globalCtx, ActorContext* actorCtx) { actor = actorEntry->first; while (actor != NULL) { - SkinMatrix_Vec3fMtxFMultXYZW(&globalCtx->viewProjectionMtxF, &actor->world.pos, &actor->projectedPos, + SkinMatrix_Vec3fMtxFMultXYZW(&play->viewProjectionMtxF, &actor->world.pos, &actor->projectedPos, &actor->projectedW); if (actor->audioFlags & 0x7F) { func_800B9D1C(actor); } - if (func_800BA2D8(globalCtx, actor)) { + if (func_800BA2D8(play, actor)) { actor->flags |= ACTOR_FLAG_40; } else { actor->flags &= ~ACTOR_FLAG_40; @@ -2886,11 +2883,11 @@ void Actor_DrawAll(GlobalContext* globalCtx, ActorContext* actorCtx) { actor->isDrawn = false; if ((actor->init == NULL) && (actor->draw != NULL) && (actor->flags & actorFlags)) { if ((actor->flags & ACTOR_FLAG_80) && - ((globalCtx->roomCtx.currRoom.unk5 == 0) || (globalCtx->actorCtx.unk4 == 0x64) || - (actor->room != globalCtx->roomCtx.currRoom.num))) { - if (Actor_RecordUndrawnActor(globalCtx, actor)) {} + ((play->roomCtx.currRoom.unk5 == 0) || (play->actorCtx.unk4 == 0x64) || + (actor->room != play->roomCtx.currRoom.num))) { + if (Actor_RecordUndrawnActor(play, actor)) {} } else { - Actor_Draw(globalCtx, actor); + Actor_Draw(play, actor); } } @@ -2898,25 +2895,25 @@ void Actor_DrawAll(GlobalContext* globalCtx, ActorContext* actorCtx) { } } - Effect_DrawAll(globalCtx->state.gfxCtx); - EffectSS_DrawAllParticles(globalCtx); - EffFootmark_Draw(globalCtx); + Effect_DrawAll(play->state.gfxCtx); + EffectSS_DrawAllParticles(play); + EffFootmark_Draw(play); ref2 = POLY_XLU_DISP; gSPDisplayList(sp58, &ref2[1]); POLY_XLU_DISP = &ref2[1]; - if (globalCtx->actorCtx.unk3 != 0) { - Math_StepToC(&globalCtx->actorCtx.unk4, 100, 20); - if (GET_PLAYER(globalCtx)->stateFlags2 & 0x8000000) { - func_800B90F4(globalCtx); + if (play->actorCtx.unk3 != 0) { + Math_StepToC(&play->actorCtx.unk4, 100, 20); + if (GET_PLAYER(play)->stateFlags2 & 0x8000000) { + func_800B90F4(play); } } else { - Math_StepToC(&globalCtx->actorCtx.unk4, 0, 10); + Math_StepToC(&play->actorCtx.unk4, 0, 10); } - if (globalCtx->actorCtx.unk4 != 0) { - globalCtx->actorCtx.unkB = 1; - func_800B9EF4(globalCtx, globalCtx->actorCtx.undrawnActorCount, globalCtx->actorCtx.undrawnActors); + if (play->actorCtx.unk4 != 0) { + play->actorCtx.unkB = 1; + func_800B9EF4(play, play->actorCtx.undrawnActorCount, play->actorCtx.undrawnActors); } tmp2 = POLY_XLU_DISP; @@ -2924,19 +2921,19 @@ void Actor_DrawAll(GlobalContext* globalCtx, ActorContext* actorCtx) { gSPBranchList(ref2, &tmp2[1]); POLY_XLU_DISP = &tmp2[1]; - if (globalCtx->unk_18844 == 0) { - Lights_DrawGlow(globalCtx); + if (play->unk_18844 == 0) { + Lights_DrawGlow(play); } - TitleCard_Draw(&globalCtx->state, &actorCtx->titleCtxt); + TitleCard_Draw(&play->state, &actorCtx->titleCtxt); - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->state.gfxCtx); } /** * Kills every actor which its object is not loaded */ -void func_800BA6FC(GlobalContext* globalCtx, ActorContext* actorCtx) { +void func_800BA6FC(PlayState* play, ActorContext* actorCtx) { Actor* actor; s32 i; @@ -2944,7 +2941,7 @@ void func_800BA6FC(GlobalContext* globalCtx, ActorContext* actorCtx) { actor = actorCtx->actorLists[i].first; while (actor != NULL) { - if (!Object_IsLoaded(&globalCtx->objectCtx, actor->objBankIndex)) { + if (!Object_IsLoaded(&play->objectCtx, actor->objBankIndex)) { Actor_MarkForDeath(actor); } @@ -2956,7 +2953,7 @@ void func_800BA6FC(GlobalContext* globalCtx, ActorContext* actorCtx) { /** * Kill actors on room change and update flags accordingly */ -void func_800BA798(GlobalContext* globalCtx, ActorContext* actorCtx) { +void func_800BA798(PlayState* play, ActorContext* actorCtx) { Actor* actor; s32 i; @@ -2964,13 +2961,13 @@ void func_800BA798(GlobalContext* globalCtx, ActorContext* actorCtx) { actor = actorCtx->actorLists[i].first; while (actor != NULL) { - if ((actor->room >= 0) && (actor->room != globalCtx->roomCtx.currRoom.num) && - (actor->room != globalCtx->roomCtx.prevRoom.num)) { + if ((actor->room >= 0) && (actor->room != play->roomCtx.currRoom.num) && + (actor->room != play->roomCtx.prevRoom.num)) { if (!actor->isDrawn) { - actor = Actor_Delete(actorCtx, actor, globalCtx); + actor = Actor_Delete(actorCtx, actor, play); } else { Actor_MarkForDeath(actor); - Actor_Destroy(actor, globalCtx); + Actor_Destroy(actor, play); actor = actor->next; } } else { @@ -2979,14 +2976,14 @@ void func_800BA798(GlobalContext* globalCtx, ActorContext* actorCtx) { } } - CollisionCheck_ClearContext(globalCtx, &globalCtx->colChkCtx); + CollisionCheck_ClearContext(play, &play->colChkCtx); actorCtx->flags.clearedRoomTemp = 0; actorCtx->flags.switches[3] = 0; actorCtx->flags.collectible[3] = 0; - globalCtx->msgCtx.unk_12030 = 0; + play->msgCtx.unk_12030 = 0; } -void func_800BA8B8(GlobalContext* globalCtx, ActorContext* actorCtx) { +void func_800BA8B8(PlayState* play, ActorContext* actorCtx) { s32 i; for (i = 0; i < ARRAY_COUNT(actorCtx->actorLists); i++) { @@ -2994,12 +2991,12 @@ void func_800BA8B8(GlobalContext* globalCtx, ActorContext* actorCtx) { while (actor != NULL) { if (!(actor->unk20 & actorCtx->unkC)) { - func_80123590(globalCtx, actor); + func_80123590(play, actor); if (!actor->isDrawn) { - actor = Actor_Delete(actorCtx, actor, globalCtx); + actor = Actor_Delete(actorCtx, actor, play); } else { Actor_MarkForDeath(actor); - Actor_Destroy(actor, globalCtx); + Actor_Destroy(actor, play); actor = actor->next; } } else { @@ -3008,11 +3005,11 @@ void func_800BA8B8(GlobalContext* globalCtx, ActorContext* actorCtx) { } } - CollisionCheck_ClearContext(globalCtx, &globalCtx->colChkCtx); - globalCtx->msgCtx.unk_12030 = 0; + CollisionCheck_ClearContext(play, &play->colChkCtx); + play->msgCtx.unk_12030 = 0; } -void Actor_CleanupContext(ActorContext* actorCtx, GlobalContext* globalCtx) { +void Actor_CleanupContext(ActorContext* actorCtx, PlayState* play) { s32 i; Fault_RemoveClient(&sActorFaultClient); @@ -3022,14 +3019,14 @@ void Actor_CleanupContext(ActorContext* actorCtx, GlobalContext* globalCtx) { Actor* actor = actorCtx->actorLists[i].first; while (actor != NULL) { - Actor_Delete(actorCtx, actor, globalCtx); + Actor_Delete(actorCtx, actor, play); actor = actorCtx->actorLists[i].first; } } } while (actorCtx->actorLists[ACTORCAT_PLAYER].first != NULL) { - Actor_Delete(actorCtx, actorCtx->actorLists[ACTORCAT_PLAYER].first, globalCtx); + Actor_Delete(actorCtx, actorCtx->actorLists[ACTORCAT_PLAYER].first, play); } if (actorCtx->absoluteSpace != NULL) { @@ -3037,7 +3034,7 @@ void Actor_CleanupContext(ActorContext* actorCtx, GlobalContext* globalCtx) { actorCtx->absoluteSpace = NULL; } - Play_SaveCycleSceneFlags(&globalCtx->state); + Play_SaveCycleSceneFlags(&play->state); ActorOverlayTable_Cleanup(); } @@ -3074,7 +3071,7 @@ void Actor_AddToCategory(ActorContext* actorCtx, Actor* actor, u8 actorCategory) * Removes a given actor instance from its actor list. * Also sets the temp clear flag of the current room if the actor removed was the last enemy loaded. */ -Actor* Actor_RemoveFromCategory(GlobalContext* globalCtx, ActorContext* actorCtx, Actor* actorToRemove) { +Actor* Actor_RemoveFromCategory(PlayState* play, ActorContext* actorCtx, Actor* actorToRemove) { Actor* newHead; actorCtx->totalLoadedActors--; @@ -3095,9 +3092,9 @@ Actor* Actor_RemoveFromCategory(GlobalContext* globalCtx, ActorContext* actorCtx actorToRemove->next = NULL; actorToRemove->prev = NULL; - if ((actorToRemove->room == globalCtx->roomCtx.currRoom.num) && (actorToRemove->category == ACTORCAT_ENEMY) && + if ((actorToRemove->room == play->roomCtx.currRoom.num) && (actorToRemove->category == ACTORCAT_ENEMY) && (actorCtx->actorLists[ACTORCAT_ENEMY].length == 0)) { - Flags_SetClearTemp(globalCtx, globalCtx->roomCtx.currRoom.num); + Flags_SetClearTemp(play, play->roomCtx.currRoom.num); } return newHead; @@ -3120,10 +3117,10 @@ void Actor_FreeOverlay(ActorOverlay* entry) { } } -Actor* Actor_Spawn(ActorContext* actorCtx, GlobalContext* globalCtx, s16 actorId, f32 posX, f32 posY, f32 posZ, - s16 rotX, s16 rotY, s16 rotZ, s32 params) { - return Actor_SpawnAsChildAndCutscene(actorCtx, globalCtx, actorId, posX, posY, posZ, rotX, rotY, rotZ, params, -1, - 0x3FF, NULL); +Actor* Actor_Spawn(ActorContext* actorCtx, PlayState* play, s16 actorId, f32 posX, f32 posY, f32 posZ, s16 rotX, + s16 rotY, s16 rotZ, s32 params) { + return Actor_SpawnAsChildAndCutscene(actorCtx, play, actorId, posX, posY, posZ, rotX, rotY, rotZ, params, -1, 0x3FF, + NULL); } ActorInit* Actor_LoadOverlay(ActorContext* actorCtx, s16 index) { @@ -3157,17 +3154,17 @@ ActorInit* Actor_LoadOverlay(ActorContext* actorCtx, s16 index) { overlayEntry->numLoaded = 0; } - actorInit = - (uintptr_t)((overlayEntry->initInfo != NULL) - ? (void*)(-OVERLAY_RELOCATION_OFFSET(overlayEntry) + (uintptr_t)overlayEntry->initInfo) - : NULL); + actorInit = (uintptr_t)( + (overlayEntry->initInfo != NULL) + ? (void*)((uintptr_t)overlayEntry->initInfo - (intptr_t)OVERLAY_RELOCATION_OFFSET(overlayEntry)) + : NULL); } return actorInit; } -Actor* Actor_SpawnAsChildAndCutscene(ActorContext* actorCtx, GlobalContext* globalCtx, s16 index, f32 x, f32 y, f32 z, - s16 rotX, s16 rotY, s16 rotZ, s32 params, u32 cutscene, s32 arg11, Actor* parent) { +Actor* Actor_SpawnAsChildAndCutscene(ActorContext* actorCtx, PlayState* play, s16 index, f32 x, f32 y, f32 z, s16 rotX, + s16 rotY, s16 rotZ, s32 params, u32 cutscene, s32 arg11, Actor* parent) { s32 pad; Actor* actor; ActorInit* actorInit; @@ -3183,10 +3180,9 @@ Actor* Actor_SpawnAsChildAndCutscene(ActorContext* actorCtx, GlobalContext* glob return NULL; } - objBankIndex = Object_GetIndex(&globalCtx->objectCtx, actorInit->objectId); - if ((objBankIndex < 0) || - ((actorInit->type == ACTORCAT_ENEMY) && Flags_GetClear(globalCtx, globalCtx->roomCtx.currRoom.num) && - (actorInit->id != ACTOR_BOSS_05))) { + objBankIndex = Object_GetIndex(&play->objectCtx, actorInit->objectId); + if ((objBankIndex < 0) || ((actorInit->type == ACTORCAT_ENEMY) && + Flags_GetClear(play, play->roomCtx.currRoom.num) && (actorInit->id != ACTOR_BOSS_05))) { Actor_FreeOverlay(&gActorOverlayTable[index]); return NULL; } @@ -3224,7 +3220,7 @@ Actor* Actor_SpawnAsChildAndCutscene(ActorContext* actorCtx, GlobalContext* glob actor->parent = parent; parent->child = actor; } else { - actor->room = globalCtx->roomCtx.currRoom.num; + actor->room = play->roomCtx.currRoom.num; } actor->home.pos.x = x; @@ -3251,48 +3247,48 @@ Actor* Actor_SpawnAsChildAndCutscene(ActorContext* actorCtx, GlobalContext* glob { u32 sp20 = gSegments[6]; - Actor_Init(actor, globalCtx); + Actor_Init(actor, play); gSegments[6] = sp20; } return actor; } -Actor* Actor_SpawnAsChild(ActorContext* actorCtx, Actor* parent, GlobalContext* globalCtx, s16 actorId, f32 posX, - f32 posY, f32 posZ, s16 rotX, s16 rotY, s16 rotZ, s32 params) { - return Actor_SpawnAsChildAndCutscene(actorCtx, globalCtx, actorId, posX, posY, posZ, rotX, rotY, rotZ, params, -1, +Actor* Actor_SpawnAsChild(ActorContext* actorCtx, Actor* parent, PlayState* play, s16 actorId, f32 posX, f32 posY, + f32 posZ, s16 rotX, s16 rotY, s16 rotZ, s32 params) { + return Actor_SpawnAsChildAndCutscene(actorCtx, play, actorId, posX, posY, posZ, rotX, rotY, rotZ, params, -1, parent->unk20, parent); } -void Actor_SpawnTransitionActors(GlobalContext* globalCtx, ActorContext* actorCtx) { - TransitionActorEntry* transitionActorList = globalCtx->doorCtx.transitionActorList; +void Actor_SpawnTransitionActors(PlayState* play, ActorContext* actorCtx) { + TransitionActorEntry* transitionActorList = play->doorCtx.transitionActorList; s32 i; - s16 numTransitionActors = globalCtx->doorCtx.numTransitionActors; + s16 numTransitionActors = play->doorCtx.numTransitionActors; for (i = 0; i < numTransitionActors; transitionActorList++, i++) { if (transitionActorList->id >= 0) { if ((transitionActorList->sides[0].room >= 0 && - (globalCtx->roomCtx.currRoom.num == transitionActorList->sides[0].room || - globalCtx->roomCtx.prevRoom.num == transitionActorList->sides[0].room)) || + (play->roomCtx.currRoom.num == transitionActorList->sides[0].room || + play->roomCtx.prevRoom.num == transitionActorList->sides[0].room)) || (transitionActorList->sides[1].room >= 0 && - (globalCtx->roomCtx.currRoom.num == transitionActorList->sides[1].room || - globalCtx->roomCtx.prevRoom.num == transitionActorList->sides[1].room))) { + (play->roomCtx.currRoom.num == transitionActorList->sides[1].room || + play->roomCtx.prevRoom.num == transitionActorList->sides[1].room))) { s16 rotY = ((transitionActorList->rotY >> 7) & 0x1FF) * (0x10000 / 360.0f); - if (Actor_SpawnAsChildAndCutscene(actorCtx, globalCtx, transitionActorList->id & 0x1FFF, + if (Actor_SpawnAsChildAndCutscene(actorCtx, play, transitionActorList->id & 0x1FFF, transitionActorList->pos.x, transitionActorList->pos.y, transitionActorList->pos.z, 0, rotY, 0, (i << 0xA) + (transitionActorList->params & 0x3FF), transitionActorList->rotY & 0x7F, 0x3FF, 0) != NULL) { transitionActorList->id = -transitionActorList->id; } - numTransitionActors = globalCtx->doorCtx.numTransitionActors; + numTransitionActors = play->doorCtx.numTransitionActors; } } } } -Actor* Actor_SpawnEntry(ActorContext* actorCtx, ActorEntry* actorEntry, GlobalContext* globalCtx) { +Actor* Actor_SpawnEntry(ActorContext* actorCtx, ActorEntry* actorEntry, PlayState* play) { s16 rotX = (actorEntry->rot.x >> 7) & 0x1FF; s16 rotY = (actorEntry->rot.y >> 7) & 0x1FF; s16 rotZ = (actorEntry->rot.z >> 7) & 0x1FF; @@ -3315,21 +3311,21 @@ Actor* Actor_SpawnEntry(ActorContext* actorCtx, ActorEntry* actorEntry, GlobalCo rotZ -= 360; } - return Actor_SpawnAsChildAndCutscene(actorCtx, globalCtx, actorEntry->id & 0x1FFF, actorEntry->pos.x, - actorEntry->pos.y, actorEntry->pos.z, rotX, rotY, rotZ, - actorEntry->params & 0xFFFF, actorEntry->rot.y & 0x7F, + return Actor_SpawnAsChildAndCutscene(actorCtx, play, actorEntry->id & 0x1FFF, actorEntry->pos.x, actorEntry->pos.y, + actorEntry->pos.z, rotX, rotY, rotZ, actorEntry->params & 0xFFFF, + actorEntry->rot.y & 0x7F, ((actorEntry->rot.x & 7) << 7) | (actorEntry->rot.z & 0x7F), NULL); } -Actor* Actor_Delete(ActorContext* actorCtx, Actor* actor, GlobalContext* globalCtx) { +Actor* Actor_Delete(ActorContext* actorCtx, Actor* actor, PlayState* play) { s32 pad; - Player* player = GET_PLAYER(globalCtx); + Player* player = GET_PLAYER(play); Actor* newHead; ActorOverlay* overlayEntry = actor->overlayEntry; if ((player != NULL) && (actor == player->unk_730)) { func_80123DA4(player); - Camera_ChangeMode(Play_GetCamera(globalCtx, Play_GetActiveCamId(globalCtx)), 0); + Camera_ChangeMode(Play_GetCamera(play, Play_GetActiveCamId(play)), 0); } if (actor == actorCtx->targetContext.arrowPointedActor) { @@ -3344,10 +3340,10 @@ Actor* Actor_Delete(ActorContext* actorCtx, Actor* actor, GlobalContext* globalC actorCtx->targetContext.bgmEnemy = NULL; } - Audio_StopSfxByPos(&actor->projectedPos); - Actor_Destroy(actor, globalCtx); + AudioSfx_StopByPos(&actor->projectedPos); + Actor_Destroy(actor, play); - newHead = Actor_RemoveFromCategory(globalCtx, actorCtx, actor); + newHead = Actor_RemoveFromCategory(play, actorCtx, actor); ZeldaArena_Free(actor); if (overlayEntry->vramStart != NULL) { @@ -3358,17 +3354,17 @@ Actor* Actor_Delete(ActorContext* actorCtx, Actor* actor, GlobalContext* globalC return newHead; } -s32 func_800BB59C(GlobalContext* globalCtx, Actor* actor) { +s32 func_800BB59C(PlayState* play, Actor* actor) { s16 x; s16 y; - Actor_GetScreenPos(globalCtx, actor, &x, &y); + Actor_GetScreenPos(play, actor, &x, &y); return (x > -20) && (x < gScreenWidth + 20) && (y > -160) && (y < gScreenHeight + 160); } void func_800BB604(GameState* gameState, ActorContext* actorCtx, Player* player, s32 actorCategory) { - GlobalContext* globalCtx = (GlobalContext*)gameState; + PlayState* play = (PlayState*)gameState; f32 temp_f0_2; Actor* sp8C; Actor* actor; @@ -3403,11 +3399,10 @@ 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, true, true, true, true, - &sp7C)) || - (SurfaceType_IsIgnoredByProjectiles(&globalCtx->colCtx, sp80, sp7C)))) { + if (func_800BB59C(play, actor)) { + if (((!BgCheck_CameraLineTest1(&play->colCtx, &player->actor.focus.pos, &actor->focus.pos, + &sp70, &sp80, true, true, true, true, &sp7C)) || + (SurfaceType_IsIgnoredByProjectiles(&play->colCtx, sp80, sp7C)))) { if (actor->targetPriority != 0) { if ((phi_s2 != 0) && (actor->targetPriority < D_801ED8D4)) { D_801ED8BC = actor; @@ -3485,9 +3480,9 @@ void func_800BB8EC(GameState* gameState, ActorContext* actorCtx, Actor** arg2, A * Play the death sound effect and flash the screen white for 4 frames. * While the screen flashes, the game freezes. */ -void Enemy_StartFinishingBlow(GlobalContext* globalCtx, Actor* actor) { - globalCtx->actorCtx.freezeFlashTimer = 5; - SoundSource_PlaySfxAtFixedWorldPos(globalCtx, &actor->world.pos, 20, NA_SE_EN_LAST_DAMAGE); +void Enemy_StartFinishingBlow(PlayState* play, Actor* actor) { + play->actorCtx.freezeFlashTimer = 5; + SoundSource_PlaySfxAtFixedWorldPos(play, &actor->world.pos, 20, NA_SE_EN_LAST_DAMAGE); } // blinking routine @@ -3536,27 +3531,27 @@ s16 func_800BBC20(s16 arg0[2], s16 arg1, s16 arg2, s16 arg3) { return arg0[0]; } -void Actor_SpawnBodyParts(Actor* actor, GlobalContext* globalCtx, s32 arg2, Gfx** dList) { +void Actor_SpawnBodyParts(Actor* actor, PlayState* play, s32 arg2, Gfx** dList) { EnPart* part; Actor* spawnedPart; 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], + Actor_SpawnAsChild(&play->actorCtx, actor, play, ACTOR_EN_PART, currentMatrix->mf[3][0], currentMatrix->mf[3][1], currentMatrix->mf[3][2], 0, 0, actor->objBankIndex, arg2); if (spawnedPart != NULL) { part = (EnPart*)spawnedPart; - func_8018219C(currentMatrix, &part->actor.shape.rot, 0); - part->unk_150 = *dList; + Matrix_MtxFToYXZRot(currentMatrix, &part->actor.shape.rot, false); + part->dList = *dList; Math_Vec3f_Copy(&part->actor.scale, &actor->scale); } } } -void Actor_SpawnFloorDustRing(GlobalContext* globalCtx, Actor* actor, Vec3f* posXZ, f32 radius, s32 countMinusOne, +void Actor_SpawnFloorDustRing(PlayState* play, Actor* actor, Vec3f* posXZ, f32 radius, s32 countMinusOne, f32 randAccelWeight, s16 scale, s16 scaleStep, u8 useLighting) { Vec3f pos; Vec3f accel = { 0.0f, 0.3f, 0.0f }; @@ -3575,17 +3570,17 @@ void Actor_SpawnFloorDustRing(GlobalContext* globalCtx, Actor* actor, Vec3f* pos accel.z = (Rand_ZeroOne() - 0.5f) * randAccelWeight; if (scale == 0) { - func_800B10C0(globalCtx, &pos, &gZeroVec3f, &accel); + func_800B10C0(play, &pos, &gZeroVec3f, &accel); } else if (useLighting) { - func_800B1210(globalCtx, &pos, &gZeroVec3f, &accel, scale, scaleStep); + func_800B1210(play, &pos, &gZeroVec3f, &accel, scale, scaleStep); } else { - func_800B11A0(globalCtx, &pos, &gZeroVec3f, &accel, scale, scaleStep); + func_800B11A0(play, &pos, &gZeroVec3f, &accel, scale, scaleStep); } angle += (2.0f * 3.14f) / (countMinusOne + 1.0f); } } -void func_800BBFB0(GlobalContext* globalCtx, Vec3f* position, f32 arg2, s32 arg3, s16 arg4, s16 scaleStep, u8 arg6) { +void func_800BBFB0(PlayState* play, Vec3f* position, f32 arg2, s32 arg3, s16 arg4, s16 scaleStep, u8 arg6) { Vec3f pos; Vec3f accel = { 0.0f, 0.3f, 0.0f }; s32 i; @@ -3601,14 +3596,14 @@ void func_800BBFB0(GlobalContext* globalCtx, Vec3f* position, f32 arg2, s32 arg3 scale += arg4; if (arg6) { - func_800B1210(globalCtx, &pos, &gZeroVec3f, &accel, scale, scaleStep); + func_800B1210(play, &pos, &gZeroVec3f, &accel, scale, scaleStep); } else { - func_800B11A0(globalCtx, &pos, &gZeroVec3f, &accel, scale, scaleStep); + func_800B11A0(play, &pos, &gZeroVec3f, &accel, scale, scaleStep); } } } -void func_800BC154(GlobalContext* globalCtx, ActorContext* actorCtx, Actor* actor, u8 actorCategory) { +void func_800BC154(PlayState* play, ActorContext* actorCtx, Actor* actor, u8 actorCategory) { actorCtx->actorLists[actor->category].unk_08 = 1; actor->category = actorCategory; } @@ -3638,8 +3633,8 @@ s32 func_800BC1B4(Actor* actor, Actor* arg1, f32 arg2, f32 arg3) { return false; } -Actor* func_800BC270(GlobalContext* globalCtx, Actor* actor, f32 arg2, s32 arg3) { - Actor* itemAction = globalCtx->actorCtx.actorLists[ACTORCAT_ITEMACTION].first; +Actor* func_800BC270(PlayState* play, Actor* actor, f32 arg2, s32 arg3) { + Actor* itemAction = play->actorCtx.actorLists[ACTORCAT_ITEMACTION].first; while (itemAction != NULL) { if (((itemAction->id == ACTOR_ARMS_HOOK) && (arg3 & 0x80)) || @@ -3647,7 +3642,7 @@ Actor* func_800BC270(GlobalContext* globalCtx, Actor* actor, f32 arg2, s32 arg3) ((itemAction->id == ACTOR_EN_ARROW) && (func_800BC188(itemAction->params) & arg3))) { f32 speedXZ; - if ((itemAction->speedXZ <= 0.0f) && (GET_PLAYER(globalCtx)->unk_D57 != 0)) { + if ((itemAction->speedXZ <= 0.0f) && (GET_PLAYER(play)->unk_D57 != 0)) { if (itemAction->id == ACTOR_ARMS_HOOK) { speedXZ = 20.0f; } else if (itemAction->id == ACTOR_EN_BOOM) { @@ -3678,8 +3673,8 @@ Actor* func_800BC270(GlobalContext* globalCtx, Actor* actor, f32 arg2, s32 arg3) return itemAction; } -Actor* func_800BC444(GlobalContext* globalCtx, Actor* actor, f32 arg2) { - Actor* explosive = globalCtx->actorCtx.actorLists[ACTORCAT_EXPLOSIVES].first; +Actor* func_800BC444(PlayState* play, Actor* actor, f32 arg2) { + Actor* explosive = play->actorCtx.actorLists[ACTORCAT_EXPLOSIVES].first; while (explosive != NULL) { if (((explosive->id == ACTOR_EN_BOM) || (explosive->id == ACTOR_EN_BOM_CHU) || @@ -3700,7 +3695,7 @@ Actor* func_800BC444(GlobalContext* globalCtx, Actor* actor, f32 arg2) { * * Returns true if the actor will be standing on ground. */ -s16 Actor_TestFloorInDirection(Actor* actor, GlobalContext* globalCtx, f32 distance, s16 angle) { +s16 Actor_TestFloorInDirection(Actor* actor, PlayState* play, f32 distance, s16 angle) { s16 ret; u16 bgCheckFlags; f32 dx; @@ -3717,7 +3712,7 @@ s16 Actor_TestFloorInDirection(Actor* actor, GlobalContext* globalCtx, f32 dista actor->world.pos.x += dx; actor->world.pos.z += dz; - Actor_UpdateBgCheckInfo(globalCtx, actor, 0.0f, 0.0f, 0.0f, 4); + Actor_UpdateBgCheckInfo(play, actor, 0.0f, 0.0f, 0.0f, 4); Math_Vec3f_Copy(&actor->world.pos, &actorPos); ret = actor->bgCheckFlags & 1; @@ -3730,8 +3725,8 @@ s16 Actor_TestFloorInDirection(Actor* actor, GlobalContext* globalCtx, f32 dista /** * Returns true if the player is targeting the provided actor */ -s32 Actor_IsTargeted(GlobalContext* globalCtx, Actor* actor) { - Player* player = GET_PLAYER(globalCtx); +s32 Actor_IsTargeted(PlayState* play, Actor* actor) { + Player* player = GET_PLAYER(play); if ((player->stateFlags3 & 0x80000000) && actor->isTargeted) { return true; @@ -3743,8 +3738,8 @@ s32 Actor_IsTargeted(GlobalContext* globalCtx, Actor* actor) { /** * Returns true if the player is targeting an actor other than the provided actor */ -s32 Actor_OtherIsTargeted(GlobalContext* globalCtx, Actor* actor) { - Player* player = GET_PLAYER(globalCtx); +s32 Actor_OtherIsTargeted(PlayState* play, Actor* actor) { + Player* player = GET_PLAYER(play); if ((player->stateFlags3 & 0x80000000) && !actor->isTargeted) { return true; @@ -3753,13 +3748,13 @@ s32 Actor_OtherIsTargeted(GlobalContext* globalCtx, Actor* actor) { return false; } -void func_800BC620(Vec3f* arg0, Vec3f* arg1, u8 alpha, GlobalContext* globalCtx) { +void func_800BC620(Vec3f* arg0, Vec3f* arg1, u8 alpha, PlayState* play) { MtxF sp58; f32 sp54; Vec3f sp48; CollisionPoly* sp44; - OPEN_DISPS(globalCtx->state.gfxCtx); + OPEN_DISPS(play->state.gfxCtx); POLY_OPA_DISP = Gfx_CallSetupDL(POLY_OPA_DISP, 0x2C); gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, 0, 0, 0, alpha); @@ -3768,44 +3763,45 @@ void func_800BC620(Vec3f* arg0, Vec3f* arg1, u8 alpha, GlobalContext* globalCtx) sp48.y = arg0->y + 1.0f; sp48.z = arg0->z; - sp54 = BgCheck_EntityRaycastFloor2(globalCtx, &globalCtx->colCtx, &sp44, &sp48); + sp54 = BgCheck_EntityRaycastFloor2(play, &play->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); - gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_OPA_DISP++, gCircleShadowDL); - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->state.gfxCtx); } -void func_800BC770(GlobalContext* globalCtx, s16 y, s16 countdown) { - s16 idx = Quake_Add(&globalCtx->mainCamera, 3); +void func_800BC770(PlayState* play, s16 y, s16 countdown) { + s16 idx = Quake_Add(&play->mainCamera, 3); Quake_SetSpeed(idx, 20000); Quake_SetQuakeValues(idx, y, 0, 0, 0); Quake_SetCountdown(idx, countdown); } -void func_800BC7D8(GlobalContext* globalCtx, s16 y, s16 countdown, s16 speed) { - s16 idx = Quake_Add(&globalCtx->mainCamera, 3); +void func_800BC7D8(PlayState* play, s16 y, s16 countdown, s16 speed) { + s16 idx = Quake_Add(&play->mainCamera, 3); Quake_SetSpeed(idx, speed); Quake_SetQuakeValues(idx, y, 0, 0, 0); Quake_SetCountdown(idx, countdown); } -void func_800BC848(Actor* actor, GlobalContext* globalCtx, s16 y, s16 countdown) { +// Actor_RequestRumble? +void func_800BC848(Actor* actor, PlayState* play, s16 y, s16 countdown) { if (y >= 5) { - func_8013ECE0(actor->xyzDistToPlayerSq, 255, 20, 150); + Rumble_Request(actor->xyzDistToPlayerSq, 255, 20, 150); } else { - func_8013ECE0(actor->xyzDistToPlayerSq, 180, 20, 100); + Rumble_Request(actor->xyzDistToPlayerSq, 180, 20, 100); } - func_800BC770(globalCtx, y, countdown); + func_800BC770(play, y, countdown); } typedef struct { @@ -3828,7 +3824,7 @@ DoorLockInfo sDoorLocksInfo[DOORLOCK_MAX] = { * Draws chains and lock of a locked door, of the specified `type` (see `DoorLockType`). * `frame` can be 0 to 10, where 0 is "open" and 10 is "closed", the chains slide accordingly. */ -void Actor_DrawDoorLock(GlobalContext* globalCtx, s32 frame, s32 type) { +void Actor_DrawDoorLock(PlayState* play, s32 frame, s32 type) { s32 pad[2]; MtxF baseMtxF; s32 i; @@ -3838,23 +3834,23 @@ void Actor_DrawDoorLock(GlobalContext* globalCtx, s32 frame, s32 type) { f32 chainRotZ = entry->chainsRotZInit; f32 rotZStep; - OPEN_DISPS(globalCtx->state.gfxCtx); + OPEN_DISPS(play->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); } - gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_OPA_DISP++, entry->chainDL); if ((i % 2) != 0) { @@ -3866,17 +3862,17 @@ 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); + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_OPA_DISP++, entry->lockDL); - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->state.gfxCtx); } -void Actor_SpawnShieldParticlesMetal(GlobalContext* globalCtx, Vec3f* pos) { - CollisionCheck_SpawnShieldParticlesMetal(globalCtx, pos); +void Actor_SpawnShieldParticlesMetal(PlayState* play, Vec3f* pos) { + CollisionCheck_SpawnShieldParticlesMetal(play, pos); } void Actor_SetColorFilter(Actor* actor, u16 colorFlag, u16 colorIntensityMax, u16 xluFlag, u16 duration) { @@ -3888,24 +3884,24 @@ void Actor_SetColorFilter(Actor* actor, u16 colorFlag, u16 colorIntensityMax, u1 actor->colorFilterTimer = duration; } -Hilite* func_800BCBF4(Vec3f* arg0, GlobalContext* globalCtx) { +Hilite* func_800BCBF4(Vec3f* arg0, PlayState* play) { Vec3f lightDir; - lightDir.x = globalCtx->envCtx.dirLight1.params.dir.x; - lightDir.y = globalCtx->envCtx.dirLight1.params.dir.y; - lightDir.z = globalCtx->envCtx.dirLight1.params.dir.z; + lightDir.x = play->envCtx.dirLight1.params.dir.x; + lightDir.y = play->envCtx.dirLight1.params.dir.y; + lightDir.z = play->envCtx.dirLight1.params.dir.z; - return Hilite_DrawOpa(arg0, &globalCtx->view.eye, &lightDir, globalCtx->state.gfxCtx); + return Hilite_DrawOpa(arg0, &play->view.eye, &lightDir, play->state.gfxCtx); } -Hilite* func_800BCC68(Vec3f* arg0, GlobalContext* globalCtx) { +Hilite* func_800BCC68(Vec3f* arg0, PlayState* play) { Vec3f lightDir; - lightDir.x = globalCtx->envCtx.dirLight1.params.dir.x; - lightDir.y = globalCtx->envCtx.dirLight1.params.dir.y; - lightDir.z = globalCtx->envCtx.dirLight1.params.dir.z; + lightDir.x = play->envCtx.dirLight1.params.dir.x; + lightDir.y = play->envCtx.dirLight1.params.dir.y; + lightDir.z = play->envCtx.dirLight1.params.dir.z; - return Hilite_DrawXlu(arg0, &globalCtx->view.eye, &lightDir, globalCtx->state.gfxCtx); + return Hilite_DrawXlu(arg0, &play->view.eye, &lightDir, play->state.gfxCtx); } /** @@ -4054,20 +4050,20 @@ void Actor_GetClosestPosOnPath(Vec3s* points, s32 numPoints, Vec3f* srcPos, Vec3 } // unused -s32 func_800BD2B4(GlobalContext* globalCtx, Actor* actor, s16* arg2, f32 arg3, - u16 (*textIdCallback)(GlobalContext*, Actor*), s16 (*arg5)(GlobalContext*, Actor*)) { - if (Actor_ProcessTalkRequest(actor, &globalCtx->state)) { +s32 func_800BD2B4(PlayState* play, Actor* actor, s16* arg2, f32 arg3, u16 (*textIdCallback)(PlayState*, Actor*), + s16 (*arg5)(PlayState*, Actor*)) { + if (Actor_ProcessTalkRequest(actor, &play->state)) { *arg2 = true; return true; } else if (*arg2) { - *arg2 = arg5(globalCtx, actor); + *arg2 = arg5(play, actor); return false; - } else if (!func_800B8934(globalCtx, actor)) { + } else if (!Actor_OnScreen(play, actor)) { return false; - } else if (!func_800B8614(actor, globalCtx, arg3)) { + } else if (!func_800B8614(actor, play, arg3)) { return false; } else { - actor->textId = textIdCallback(globalCtx, actor); + actor->textId = textIdCallback(play, actor); return false; } } @@ -4249,39 +4245,39 @@ Gfx* func_800BD9A0(GraphicsContext* gfxCtx) { } // unused -void func_800BD9E0(GlobalContext* globalCtx, SkelAnime* skelAnime, OverrideLimbDraw overrideLimbDraw, - PostLimbDraw postLimbDraw, Actor* actor, s16 alpha) { - OPEN_DISPS(globalCtx->state.gfxCtx); - func_8012C28C(globalCtx->state.gfxCtx); +void func_800BD9E0(PlayState* play, SkelAnime* skelAnime, OverrideLimbDraw overrideLimbDraw, PostLimbDraw postLimbDraw, + Actor* actor, s16 alpha) { + OPEN_DISPS(play->state.gfxCtx); + func_8012C28C(play->state.gfxCtx); gDPSetEnvColor(POLY_OPA_DISP++, 0, 0, 0, alpha); gSPSegment(POLY_OPA_DISP++, 0x0C, gEmptyDL); - POLY_OPA_DISP = SkelAnime_DrawFlex(globalCtx, skelAnime->skeleton, skelAnime->jointTable, skelAnime->dListCount, + POLY_OPA_DISP = SkelAnime_DrawFlex(play, skelAnime->skeleton, skelAnime->jointTable, skelAnime->dListCount, overrideLimbDraw, postLimbDraw, actor, POLY_OPA_DISP); - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->state.gfxCtx); } -void func_800BDAA0(GlobalContext* globalCtx, SkelAnime* skelAnime, OverrideLimbDraw overrideLimbDraw, - PostLimbDraw postLimbDraw, Actor* actor, s16 alpha) { - OPEN_DISPS(globalCtx->state.gfxCtx); - func_8012C2DC(globalCtx->state.gfxCtx); +void func_800BDAA0(PlayState* play, SkelAnime* skelAnime, OverrideLimbDraw overrideLimbDraw, PostLimbDraw postLimbDraw, + Actor* actor, s16 alpha) { + OPEN_DISPS(play->state.gfxCtx); + func_8012C2DC(play->state.gfxCtx); gDPSetEnvColor(POLY_XLU_DISP++, 0, 0, 0, alpha); - gSPSegment(POLY_XLU_DISP++, 0x0C, func_800BD9A0(globalCtx->state.gfxCtx)); + gSPSegment(POLY_XLU_DISP++, 0x0C, func_800BD9A0(play->state.gfxCtx)); - POLY_XLU_DISP = SkelAnime_DrawFlex(globalCtx, skelAnime->skeleton, skelAnime->jointTable, skelAnime->dListCount, + POLY_XLU_DISP = SkelAnime_DrawFlex(play, skelAnime->skeleton, skelAnime->jointTable, skelAnime->dListCount, overrideLimbDraw, postLimbDraw, actor, POLY_XLU_DISP); - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->state.gfxCtx); } // Unused -s16 func_800BDB6C(Actor* actor, GlobalContext* globalCtx, s16 arg2, f32 arg3) { - Player* player = GET_PLAYER(globalCtx); +s16 func_800BDB6C(Actor* actor, PlayState* play, s16 arg2, f32 arg3) { + Player* player = GET_PLAYER(play); f32 phi_f2; - if ((globalCtx->csCtx.state != 0) || (D_801D0D50 != 0)) { - phi_f2 = Math_Vec3f_DistXYZ(&actor->world.pos, &globalCtx->view.eye) * 0.25f; + if ((play->csCtx.state != 0) || gDbgCamEnabled) { + phi_f2 = Math_Vec3f_DistXYZ(&actor->world.pos, &play->view.eye) * 0.25f; } else { phi_f2 = Math_Vec3f_DistXYZ(&actor->world.pos, &player->actor.world.pos); } @@ -4297,23 +4293,23 @@ s16 func_800BDB6C(Actor* actor, GlobalContext* globalCtx, s16 arg2, f32 arg3) { return arg2; } -void Actor_ChangeAnimationByInfo(SkelAnime* skelAnime, AnimationInfo* animation, s32 index) { +void Actor_ChangeAnimationByInfo(SkelAnime* skelAnime, AnimationInfo* animationInfo, s32 animIndex) { f32 frameCount; - animation += index; - if (animation->frameCount > 0.0f) { - frameCount = animation->frameCount; + animationInfo += animIndex; + if (animationInfo->frameCount > 0.0f) { + frameCount = animationInfo->frameCount; } else { - frameCount = Animation_GetLastFrame(&animation->animation->common); + frameCount = Animation_GetLastFrame(&animationInfo->animation->common); } - Animation_Change(skelAnime, animation->animation, animation->playSpeed, animation->startFrame, frameCount, - animation->mode, animation->morphFrames); + Animation_Change(skelAnime, animationInfo->animation, animationInfo->playSpeed, animationInfo->startFrame, + frameCount, animationInfo->mode, animationInfo->morphFrames); } // Unused -void func_800BDCF4(GlobalContext* globalCtx, s16* arg1, s16* arg2, s32 size) { - s32 frames = globalCtx->gameplayFrames; +void func_800BDCF4(PlayState* play, s16* arg1, s16* arg2, s32 size) { + s32 frames = play->gameplayFrames; s32 i; for (i = 0; i < size; i++) { @@ -4322,7 +4318,7 @@ void func_800BDCF4(GlobalContext* globalCtx, s16* arg1, s16* arg2, s32 size) { } } -void Actor_Noop(Actor* actor, GlobalContext* globalCtx) { +void Actor_Noop(Actor* actor, PlayState* play) { } #include "z_cheap_proc.c" @@ -4332,8 +4328,8 @@ void Actor_Noop(Actor* actor, GlobalContext* globalCtx) { * an actor if there is one. If the Id provided is -1, this will look for any actor of the * specified category rather than a specific Id. */ -Actor* Actor_FindNearby(GlobalContext* globalCtx, Actor* inActor, s16 actorId, u8 actorCategory, f32 distance) { - Actor* actor = globalCtx->actorCtx.actorLists[actorCategory].first; +Actor* Actor_FindNearby(PlayState* play, Actor* inActor, s16 actorId, u8 actorCategory, f32 distance) { + Actor* actor = play->actorCtx.actorLists[actorCategory].first; while (actor != NULL) { if (actor == inActor || ((actorId != -1) && (actorId != actor->id))) { @@ -4351,12 +4347,12 @@ Actor* Actor_FindNearby(GlobalContext* globalCtx, Actor* inActor, s16 actorId, u return NULL; } -s32 func_800BE184(GlobalContext* globalCtx, Actor* actor, f32 xzDist, s16 arg3, s16 arg4, s16 arg5) { - Player* player = GET_PLAYER(globalCtx); +s32 func_800BE184(PlayState* play, Actor* actor, f32 xzDist, s16 arg3, s16 arg4, s16 arg5) { + Player* player = GET_PLAYER(play); s16 phi_v0 = BINANG_SUB(BINANG_ROT180(actor->yawTowardsPlayer), player->actor.shape.rot.y); s16 temp_t0 = actor->yawTowardsPlayer - arg5; - if ((actor->xzDistToPlayer <= xzDist) && (player->swordState != 0)) { + if ((actor->xzDistToPlayer <= xzDist) && (player->meleeWeaponState != 0)) { if ((arg4 >= ABS_ALT(phi_v0)) && (arg3 >= ABS_ALT(temp_t0))) { return true; } @@ -4482,9 +4478,10 @@ 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; @@ -4500,7 +4497,7 @@ TexturePtr sElectricSparkTextures[] = { /** * Draw common damage effects applied to each limb provided in limbPos */ -void Actor_DrawDamageEffects(GlobalContext* globalCtx, Actor* actor, Vec3f limbPos[], s16 limbPosCount, f32 effectScale, +void Actor_DrawDamageEffects(PlayState* play, Actor* actor, Vec3f limbPos[], s16 limbPosCount, f32 effectScale, f32 frozenSteamScale, f32 effectAlpha, u8 type) { if (effectAlpha > 0.001f) { s32 twoTexScrollParam; @@ -4512,13 +4509,13 @@ void Actor_DrawDamageEffects(GlobalContext* globalCtx, Actor* actor, Vec3f limbP f32 electricSparksScale; f32 steamScale; Vec3f* limbPosStart = limbPos; - u32 gameplayFrames = globalCtx->gameplayFrames; + u32 gameplayFrames = play->gameplayFrames; f32 effectAlphaScaled; - currentMatrix = Matrix_GetCurrentState(); + currentMatrix = Matrix_GetCurrent(); // Apply sfx along with damage effect - if ((actor != NULL) && (effectAlpha > 0.05f) && (globalCtx->gameOverCtx.state == 0)) { + if ((actor != NULL) && (effectAlpha > 0.05f) && (play->gameOverCtx.state == GAMEOVER_INACTIVE)) { if (type == ACTOR_DRAW_DMGEFF_FIRE) { Actor_PlaySfxAtPos(actor, NA_SE_EV_BURN_OUT - SFX_FLAG); } else if (type == ACTOR_DRAW_DMGEFF_BLUE_FIRE) { @@ -4530,24 +4527,24 @@ void Actor_DrawDamageEffects(GlobalContext* globalCtx, Actor* actor, Vec3f limbP } } - OPEN_DISPS(globalCtx->state.gfxCtx); + OPEN_DISPS(play->state.gfxCtx); - func_8012C2DC(globalCtx->state.gfxCtx); + func_8012C2DC(play->state.gfxCtx); 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); + func_800BCC68(limbPos, play); // Setup to draw ice over frozen actor gSPSegment(POLY_XLU_DISP++, 0x08, - Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, 0, gameplayFrames & 0xFF, 32, 16, 1, 0, + Gfx_TwoTexScroll(play->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++, gEffIceFragment2MaterialDL); effectAlphaScaled = effectAlpha * 255.0f; @@ -4564,21 +4561,21 @@ void Actor_DrawDamageEffects(GlobalContext* globalCtx, Actor* actor, Vec3f limbP 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_Translate(limbPos->x, limbPos->y, limbPos->z, MTXMODE_NEW); Matrix_Scale(frozenScale, frozenScale, frozenScale, MTXMODE_APPLY); if (limbIndex & 1) { - Matrix_InsertYRotation_f(M_PI, MTXMODE_APPLY); + Matrix_RotateYF(M_PI, MTXMODE_APPLY); } if (limbIndex & 2) { - Matrix_InsertZRotation_f(M_PI, MTXMODE_APPLY); + Matrix_RotateZF(M_PI, MTXMODE_APPLY); } - gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - gSPDisplayList(POLY_XLU_DISP++, gFrozenIceVtxDL); + gSPDisplayList(POLY_XLU_DISP++, gEffIceFragment2ModelDL); } limbPos = limbPosStart; // reset limbPos @@ -4600,14 +4597,14 @@ void Actor_DrawDamageEffects(GlobalContext* globalCtx, Actor* actor, Vec3f limbP for (limbIndex = 0; limbIndex < limbPosCount; limbIndex++, limbPos++) { twoTexScrollParam = ((limbIndex * 3) + gameplayFrames); gSPSegment(POLY_XLU_DISP++, 0x08, - Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, twoTexScrollParam * 3, - twoTexScrollParam * -12, 32, 64, 1, 0, 0, 32, 32)); + Gfx_TwoTexScroll(play->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_Translate(limbPos->x, limbPos->y, limbPos->z, MTXMODE_NEW); + Matrix_ReplaceRotation(&play->billboardMtxF); Matrix_Scale(steamScale, steamScale, 1.0f, MTXMODE_APPLY); - gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_XLU_DISP++, gFrozenSteamVtxDL); @@ -4624,7 +4621,7 @@ void Actor_DrawDamageEffects(GlobalContext* globalCtx, Actor* actor, Vec3f limbP type = 255; } - Matrix_SetCurrentState(&globalCtx->billboardMtxF); + Matrix_Put(&play->billboardMtxF); Matrix_Scale((effectScale * 0.005f) * 1.35f, (effectScale * 0.005f), (effectScale * 0.005f) * 1.35f, MTXMODE_APPLY); @@ -4647,18 +4644,18 @@ void Actor_DrawDamageEffects(GlobalContext* globalCtx, Actor* actor, Vec3f limbP gDPSetPrimColor(POLY_XLU_DISP++, 0x80, 0x80, 255, 255, type, (u8)alpha); gSPSegment(POLY_XLU_DISP++, 0x08, - Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, 0, 0, 32, 64, 1, 0, + Gfx_TwoTexScroll(play->state.gfxCtx, 0, 0, 0, 32, 64, 1, 0, ((limbIndex * 10 + gameplayFrames) * -20) & 0x1FF, 32, 128)); - Matrix_InsertYRotation_f(M_PI, MTXMODE_APPLY); + 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), + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - gSPDisplayList(POLY_XLU_DISP++, gGameplayKeepDrawFlameDL); + gSPDisplayList(POLY_XLU_DISP++, gEffFire1DL); } break; @@ -4687,17 +4684,17 @@ void Actor_DrawDamageEffects(GlobalContext* globalCtx, Actor* actor, Vec3f limbP gDPSetEnvColor(POLY_XLU_DISP++, 255, 255, 100, 128); } - Matrix_SetCurrentState(&globalCtx->billboardMtxF); + Matrix_Put(&play->billboardMtxF); Matrix_Scale(lightOrbsScale, lightOrbsScale, 1.0f, MTXMODE_APPLY); // Apply and draw a light orb over each limb of frozen actor for (limbIndex = 0; limbIndex < limbPosCount; limbIndex++, limbPos++) { - Matrix_InsertZRotation_f(randPlusMinusPoint5Scaled(2 * M_PI), MTXMODE_APPLY); + 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), + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_XLU_DISP++, gLightOrbVtxDL); @@ -4716,7 +4713,7 @@ void Actor_DrawDamageEffects(GlobalContext* globalCtx, Actor* actor, Vec3f limbP } gSPSegment(POLY_XLU_DISP++, 0x08, - Lib_SegmentedToVirtual(sElectricSparkTextures[globalCtx->gameplayFrames % 4])); + Lib_SegmentedToVirtual(sElectricSparkTextures[play->gameplayFrames % 4])); gSPDisplayList(POLY_XLU_DISP++, gElectricSparkDL); @@ -4725,31 +4722,31 @@ void Actor_DrawDamageEffects(GlobalContext* globalCtx, Actor* actor, Vec3f limbP gDPSetEnvColor(POLY_XLU_DISP++, (u8)(sREG(20) + 255), (u8)(sREG(21) + 255), (u8)sREG(22), (u8)sREG(23)); - Matrix_SetCurrentState(&globalCtx->billboardMtxF); + Matrix_Put(&play->billboardMtxF); Matrix_Scale(electricSparksScale, electricSparksScale, electricSparksScale, MTXMODE_APPLY); // Every limb draws two electric sparks at random orientations for (limbIndex = 0; limbIndex < limbPosCount; limbIndex++, limbPos++) { // first electric spark - Matrix_RotateStateAroundXAxis(Rand_ZeroFloat(2 * M_PI)); - Matrix_InsertZRotation_f(Rand_ZeroFloat(2 * M_PI), MTXMODE_APPLY); + 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), + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_XLU_DISP++, gElectricSparkVtxDL); // second electric spark - Matrix_RotateStateAroundXAxis(Rand_ZeroFloat(2 * M_PI)); - Matrix_InsertZRotation_f(Rand_ZeroFloat(2 * M_PI), MTXMODE_APPLY); + 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), + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_XLU_DISP++, gElectricSparkVtxDL); @@ -4758,12 +4755,12 @@ void Actor_DrawDamageEffects(GlobalContext* globalCtx, Actor* actor, Vec3f limbP break; } - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->state.gfxCtx); } } -void Actor_SpawnIceEffects(GlobalContext* globalCtx, Actor* actor, Vec3f limbPos[], s32 limbPosCount, - s32 effectsPerLimb, f32 scale, f32 scaleRange) { +void Actor_SpawnIceEffects(PlayState* play, Actor* actor, Vec3f limbPos[], s32 limbPosCount, s32 effectsPerLimb, + f32 scale, f32 scaleRange) { static Color_RGBA8 primColor = { 170, 255, 255, 255 }; static Color_RGBA8 envColor = { 200, 200, 255, 255 }; static Vec3f accel = { 0.0f, -1.0f, 0.0f }; @@ -4774,13 +4771,13 @@ void Actor_SpawnIceEffects(GlobalContext* globalCtx, Actor* actor, Vec3f limbPos s16 yaw; s32 j; - SoundSource_PlaySfxAtFixedWorldPos(globalCtx, &actor->world.pos, 30, NA_SE_EV_ICE_BROKEN); + SoundSource_PlaySfxAtFixedWorldPos(play, &actor->world.pos, 30, NA_SE_EV_ICE_BROKEN); for (i = 0; i < limbPosCount; i++) { yaw = Actor_YawToPoint(actor, limbPos); for (j = 0; j < effectsPerLimb; j++) { - randomYaw = (Rand_Next() >> 0x13) + yaw; + randomYaw = ((s32)Rand_Next() >> 0x13) + yaw; velocity.z = Rand_ZeroFloat(5.0f); @@ -4788,7 +4785,7 @@ void Actor_SpawnIceEffects(GlobalContext* globalCtx, Actor* actor, Vec3f limbPos velocity.y = Rand_ZeroFloat(4.0f) + 8.0f; velocity.z *= Math_CosS(randomYaw); - EffectSsEnIce_Spawn(globalCtx, limbPos, Rand_ZeroFloat(scaleRange) + scale, &velocity, &accel, &primColor, + EffectSsEnIce_Spawn(play, limbPos, Rand_ZeroFloat(scaleRange) + scale, &velocity, &accel, &primColor, &envColor, 30); } diff --git a/src/code/z_bg_item.c b/src/code/z_bg_item.c index 74adbe695..79bdf2b82 100644 --- a/src/code/z_bg_item.c +++ b/src/code/z_bg_item.c @@ -15,11 +15,11 @@ void DynaPolyActor_Init(DynaPolyActor* dynaActor, s32 flags) { dynaActor->stateFlags = DYNAPOLY_STATE_NONE; } -void DynaPolyActor_LoadMesh(GlobalContext* globalCtx, DynaPolyActor* dynaActor, CollisionHeader* meshHeader) { +void DynaPolyActor_LoadMesh(PlayState* play, DynaPolyActor* dynaActor, CollisionHeader* meshHeader) { CollisionHeader* header = NULL; CollisionHeader_GetVirtual(meshHeader, &header); - dynaActor->bgId = DynaPoly_SetBgActor(globalCtx, &globalCtx->colCtx.dyna, &dynaActor->actor, header); + dynaActor->bgId = DynaPoly_SetBgActor(play, &play->colCtx.dyna, &dynaActor->actor, header); } void DynaPolyActor_ResetState(DynaPolyActor* dynaActor) { @@ -102,7 +102,7 @@ s32 DynaPolyActor_IsInHeavySwitchPressedState(DynaPolyActor* dynaActor) { } } -s32 DynaPolyActor_ValidateMove(GlobalContext* globalCtx, DynaPolyActor* dynaActor, s16 startRadius, s16 endRadius, +s32 DynaPolyActor_ValidateMove(PlayState* play, DynaPolyActor* dynaActor, s16 startRadius, s16 endRadius, s16 startHeight) { Vec3f startPos; Vec3f endPos; @@ -125,16 +125,16 @@ s32 DynaPolyActor_ValidateMove(GlobalContext* globalCtx, DynaPolyActor* dynaActo endPos.y = startPos.y; endPos.z = sign * adjustedEndRadius * cos + startPos.z; - if (BgCheck_EntityLineTest3(&globalCtx->colCtx, &startPos, &endPos, &intersectionPos, &poly, true, false, false, - true, &bgId, &dynaActor->actor, 0.0f)) { + if (BgCheck_EntityLineTest3(&play->colCtx, &startPos, &endPos, &intersectionPos, &poly, true, false, false, true, + &bgId, &dynaActor->actor, 0.0f)) { return false; } startPos.x = (dynaActor->actor.world.pos.x * 2.0f) - startPos.x; startPos.z = (dynaActor->actor.world.pos.z * 2.0f) - startPos.z; endPos.x = sign * adjustedEndRadius * sin + startPos.x; endPos.z = sign * adjustedEndRadius * cos + startPos.z; - if (BgCheck_EntityLineTest3(&globalCtx->colCtx, &startPos, &endPos, &intersectionPos, &poly, true, false, false, - true, &bgId, &dynaActor->actor, 0.0f)) { + if (BgCheck_EntityLineTest3(&play->colCtx, &startPos, &endPos, &intersectionPos, &poly, true, false, false, true, + &bgId, &dynaActor->actor, 0.0f)) { return false; } return true; diff --git a/src/code/z_bgcheck.c b/src/code/z_bgcheck.c index b2891de90..e73dd7f6e 100644 --- a/src/code/z_bgcheck.c +++ b/src/code/z_bgcheck.c @@ -1,6 +1,6 @@ -#include "prevent_bss_reordering.h" #include "global.h" #include "vt.h" +#include "overlays/kaleido_scope/ovl_kaleido_scope/z_kaleido_scope.h" #define DYNA_RAYCAST_FLOORS 1 #define DYNA_RAYCAST_WALLS 2 @@ -125,13 +125,13 @@ void DynaSSNodeList_SetSSListHead(DynaSSNodeList* list, SSList* ssList, s16* pol ssList->head = index; } -void DynaSSNodeList_Init(GlobalContext* globalCtx, DynaSSNodeList* list) { +void DynaSSNodeList_Init(PlayState* play, DynaSSNodeList* list) { list->tbl = NULL; list->count = 0; } -void DynaSSNodeList_Alloc(GlobalContext* globalCtx, DynaSSNodeList* list, u32 numNodes) { - list->tbl = (SSNode*)THA_AllocEndAlign(&globalCtx->state.heap, numNodes * sizeof(SSNode), -2); +void DynaSSNodeList_Alloc(PlayState* play, DynaSSNodeList* list, u32 numNodes) { + list->tbl = (SSNode*)THA_AllocEndAlign(&play->state.heap, numNodes * sizeof(SSNode), -2); list->maxNodes = numNodes; list->count = 0; } @@ -249,20 +249,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; } @@ -1192,7 +1192,7 @@ void BgCheck_GetSubdivisionMinBounds(CollisionContext* colCtx, Vec3f* pos, s32* /** * Get positive bias subdivision indices - * increments indicies if `pos` is within BGCHECK_SUBDIV_OVERLAP units of the postive subdivision boundary + * increments indices if `pos` is within BGCHECK_SUBDIV_OVERLAP units of the positive subdivision boundary * `sx`, `sy`, `sz` returns the subdivision x, y, z indices */ void BgCheck_GetSubdivisionMaxBounds(CollisionContext* colCtx, Vec3f* pos, s32* sx, s32* sy, s32* sz) { @@ -1377,7 +1377,7 @@ s32 BgCheck_PolyIntersectsSubdivision(Vec3f* min, Vec3f* max, CollisionPoly* pol * Initialize StaticLookup Table * returns size of table, in bytes */ -u32 BgCheck_InitStaticLookup(CollisionContext* colCtx, GlobalContext* globalCtx, StaticLookup* lookupTbl) { +u32 BgCheck_InitStaticLookup(CollisionContext* colCtx, PlayState* play, StaticLookup* lookupTbl) { Vec3s* vtxList; CollisionPoly* polyList; s32 polyMax; @@ -1461,11 +1461,11 @@ u32 BgCheck_InitStaticLookup(CollisionContext* colCtx, GlobalContext* globalCtx, /** * Returns whether the current scene should reserve less memory for it's collision lookup */ -s32 BgCheck_IsSmallMemScene(GlobalContext* globalCtx) { +s32 BgCheck_IsSmallMemScene(PlayState* play) { s16* i; for (i = sSmallMemScenes; i < sSmallMemScenes + ARRAY_COUNT(sSmallMemScenes); i++) { - if (globalCtx->sceneNum == *i) { + if (play->sceneNum == *i) { return true; } } @@ -1500,11 +1500,11 @@ void BgCheck_SetSubdivisionDimension(f32 min, s32 subdivAmount, f32* max, f32* s *max = *subdivLength * subdivAmount + min; } -s32 BgCheck_GetSpecialSceneMaxObjects(GlobalContext* globalCtx, s32* maxNodes, s32* maxPolygons, s32* maxVertices) { +s32 BgCheck_GetSpecialSceneMaxObjects(PlayState* play, s32* maxNodes, s32* maxPolygons, s32* maxVertices) { s32 i; for (i = 0; i < ARRAY_COUNT(sCustomDynapolyMem); i++) { - if (globalCtx->sceneNum == sCustomDynapolyMem[i].sceneId) { + if (play->sceneNum == sCustomDynapolyMem[i].sceneId) { *maxNodes = sCustomDynapolyMem[i].maxNodes; *maxPolygons = sCustomDynapolyMem[i].maxPolygons; *maxVertices = sCustomDynapolyMem[i].maxVertices; @@ -1517,7 +1517,7 @@ s32 BgCheck_GetSpecialSceneMaxObjects(GlobalContext* globalCtx, s32* maxNodes, s /** * Allocate CollisionContext */ -void BgCheck_Allocate(CollisionContext* colCtx, GlobalContext* globalCtx, CollisionHeader* colHeader) { +void BgCheck_Allocate(CollisionContext* colCtx, PlayState* play, CollisionHeader* colHeader) { u32 tblMax; u32 memSize; u32 lookupTblMemSize; @@ -1528,7 +1528,7 @@ void BgCheck_Allocate(CollisionContext* colCtx, GlobalContext* globalCtx, Collis colCtx->colHeader = colHeader; colCtx->flags = 0; - if (BgCheck_IsSmallMemScene(globalCtx)) { + if (BgCheck_IsSmallMemScene(play)) { colCtx->memSize = 0xF000; colCtx->dyna.polyNodesMax = 1000; colCtx->dyna.polyListMax = 512; @@ -1541,7 +1541,7 @@ void BgCheck_Allocate(CollisionContext* colCtx, GlobalContext* globalCtx, Collis s32 useCustomSubdivisions; s32 i; - if (BgCheck_TryGetCustomMemsize(globalCtx->sceneNum, &customMemSize)) { + if (BgCheck_TryGetCustomMemsize(play->sceneNum, &customMemSize)) { colCtx->memSize = customMemSize; } else { colCtx->memSize = 0x23000; @@ -1549,12 +1549,12 @@ void BgCheck_Allocate(CollisionContext* colCtx, GlobalContext* globalCtx, Collis colCtx->dyna.polyNodesMax = 1000; colCtx->dyna.polyListMax = 544; colCtx->dyna.vtxListMax = 512; - BgCheck_GetSpecialSceneMaxObjects(globalCtx, &colCtx->dyna.polyNodesMax, &colCtx->dyna.polyListMax, + BgCheck_GetSpecialSceneMaxObjects(play, &colCtx->dyna.polyNodesMax, &colCtx->dyna.polyListMax, &colCtx->dyna.vtxListMax); useCustomSubdivisions = false; for (i = 0; i < ARRAY_COUNT(sSceneSubdivisionList); i++) { - if (globalCtx->sceneNum == sSceneSubdivisionList[i].sceneId) { + if (play->sceneNum == sSceneSubdivisionList[i].sceneId) { colCtx->subdivAmount.x = sSceneSubdivisionList[i].subdivAmount.x; colCtx->subdivAmount.y = sSceneSubdivisionList[i].subdivAmount.y; colCtx->subdivAmount.z = sSceneSubdivisionList[i].subdivAmount.z; @@ -1569,7 +1569,7 @@ void BgCheck_Allocate(CollisionContext* colCtx, GlobalContext* globalCtx, Collis } } colCtx->lookupTbl = THA_AllocEndAlign( - &globalCtx->state.heap, + &play->state.heap, colCtx->subdivAmount.x * sizeof(StaticLookup) * colCtx->subdivAmount.y * colCtx->subdivAmount.z, ~1); if (colCtx->lookupTbl == NULL) { Fault_AddHungupAndCrash("../z_bgcheck.c", 3955); @@ -1602,12 +1602,12 @@ void BgCheck_Allocate(CollisionContext* colCtx, GlobalContext* globalCtx, Collis } SSNodeList_Init(&colCtx->polyNodes); - SSNodeList_Alloc(globalCtx, &colCtx->polyNodes, tblMax, colCtx->colHeader->numPolygons); + SSNodeList_Alloc(play, &colCtx->polyNodes, tblMax, colCtx->colHeader->numPolygons); - lookupTblMemSize = BgCheck_InitStaticLookup(colCtx, globalCtx, colCtx->lookupTbl); + lookupTblMemSize = BgCheck_InitStaticLookup(colCtx, play, colCtx->lookupTbl); - DynaPoly_Init(globalCtx, &colCtx->dyna); - DynaPoly_Alloc(globalCtx, &colCtx->dyna); + DynaPoly_Init(play, &colCtx->dyna); + DynaPoly_Alloc(play, &colCtx->dyna); } /** @@ -1662,7 +1662,7 @@ s32 BgCheck_PosInStaticBoundingBox(CollisionContext* colCtx, Vec3f* pos) { * returns the yIntersect of the nearest poly found directly below `pos`, or BGCHECK_Y_MIN if no floor detected * returns the poly found in `outPoly`, and the bgId of the entity in `outBgId` */ -f32 BgCheck_RaycastFloorImpl(GlobalContext* globalCtx, CollisionContext* colCtx, u16 xpFlags, CollisionPoly** outPoly, +f32 BgCheck_RaycastFloorImpl(PlayState* play, CollisionContext* colCtx, u16 xpFlags, CollisionPoly** outPoly, s32* outBgId, Vec3f* pos, Actor* actor, u32 arg7, f32 checkDist, s32 arg9) { f32 yIntersectDyna; f32 yIntersect; @@ -1694,7 +1694,7 @@ f32 BgCheck_RaycastFloorImpl(GlobalContext* globalCtx, CollisionContext* colCtx, checkPos.y -= colCtx->subdivLength.y; } if (!(arg9 & 1)) { - dynaRaycast.globalCtx = globalCtx; + dynaRaycast.play = play; dynaRaycast.colCtx = colCtx; dynaRaycast.xpFlags = xpFlags; dynaRaycast.resultPoly = outPoly; @@ -1742,22 +1742,20 @@ f32 BgCheck_EntityRaycastFloor1(CollisionContext* colCtx, CollisionPoly** outPol * Public raycast toward floor * returns yIntersect of the poly found, or BGCHECK_Y_MIN if no poly detected */ -f32 BgCheck_EntityRaycastFloor2(GlobalContext* globalCtx, CollisionContext* colCtx, CollisionPoly** outPoly, - Vec3f* pos) { +f32 BgCheck_EntityRaycastFloor2(PlayState* play, CollisionContext* colCtx, CollisionPoly** outPoly, Vec3f* pos) { s32 bgId; - return BgCheck_RaycastFloorImpl(globalCtx, colCtx, COLPOLY_IGNORE_ENTITY, outPoly, &bgId, pos, NULL, 0x1C, 1.0f, 0); + return BgCheck_RaycastFloorImpl(play, colCtx, COLPOLY_IGNORE_ENTITY, outPoly, &bgId, pos, NULL, 0x1C, 1.0f, 0); } /** * Public raycast toward floor * returns yIntersect of the poly found, or BGCHECK_Y_MIN if no poly detected */ -f32 BgCheck_EntityRaycastFloor2_1(GlobalContext* globalCtx, CollisionContext* colCtx, CollisionPoly** outPoly, - Vec3f* pos) { +f32 BgCheck_EntityRaycastFloor2_1(PlayState* play, CollisionContext* colCtx, CollisionPoly** outPoly, Vec3f* pos) { s32 bgId; - return BgCheck_RaycastFloorImpl(globalCtx, colCtx, COLPOLY_IGNORE_ENTITY, outPoly, &bgId, pos, NULL, 0x1C, 1.0f, 1); + return BgCheck_RaycastFloorImpl(play, colCtx, COLPOLY_IGNORE_ENTITY, outPoly, &bgId, pos, NULL, 0x1C, 1.0f, 1); } /** @@ -1781,18 +1779,18 @@ f32 BgCheck_EntityRaycastFloor5(CollisionContext* colCtx, CollisionPoly** outPol * Public raycast toward floor * returns yIntersect of the poly found, or BGCHECK_Y_MIN if no poly detected */ -f32 BgCheck_EntityRaycastFloor5_2(GlobalContext* globalCtx, CollisionContext* colCtx, CollisionPoly** outPoly, - s32* bgId, Actor* actor, Vec3f* pos) { - return BgCheck_RaycastFloorImpl(globalCtx, colCtx, COLPOLY_IGNORE_ENTITY, outPoly, bgId, pos, actor, 0x1C, 1.0f, 0); +f32 BgCheck_EntityRaycastFloor5_2(PlayState* play, CollisionContext* colCtx, CollisionPoly** outPoly, s32* bgId, + Actor* actor, Vec3f* pos) { + return BgCheck_RaycastFloorImpl(play, colCtx, COLPOLY_IGNORE_ENTITY, outPoly, bgId, pos, actor, 0x1C, 1.0f, 0); } /** * Public raycast toward floor * returns yIntersect of the poly found, or BGCHECK_Y_MIN if no poly detected */ -f32 BgCheck_EntityRaycastFloor5_3(GlobalContext* globalCtx, CollisionContext* colCtx, CollisionPoly** outPoly, - s32* bgId, Actor* actor, Vec3f* pos) { - return BgCheck_RaycastFloorImpl(globalCtx, colCtx, COLPOLY_IGNORE_ENTITY, outPoly, bgId, pos, actor, 0x3C, 1.0f, 0); +f32 BgCheck_EntityRaycastFloor5_3(PlayState* play, CollisionContext* colCtx, CollisionPoly** outPoly, s32* bgId, + Actor* actor, Vec3f* pos) { + return BgCheck_RaycastFloorImpl(play, colCtx, COLPOLY_IGNORE_ENTITY, outPoly, bgId, pos, actor, 0x3C, 1.0f, 0); } /** @@ -2454,11 +2452,11 @@ void SSNodeList_Init(SSNodeList* this) { * tblMax is the number of SSNode records to allocate * numPolys is the number of polygons defined within the CollisionHeader */ -void SSNodeList_Alloc(GlobalContext* globalCtx, SSNodeList* this, s32 tblMax, s32 numPolys) { +void SSNodeList_Alloc(PlayState* play, SSNodeList* this, s32 tblMax, s32 numPolys) { this->max = tblMax; this->count = 0; - this->tbl = THA_AllocEndAlign(&globalCtx->state.heap, tblMax * sizeof(SSNode), -2); - this->polyCheckTbl = THA_AllocEndAlign16(&globalCtx->state.heap, numPolys * sizeof(u8)); + this->tbl = THA_AllocEndAlign(&play->state.heap, tblMax * sizeof(SSNode), -2); + this->polyCheckTbl = THA_AllocEndAlign16(&play->state.heap, numPolys * sizeof(u8)); if (this->polyCheckTbl == NULL) { sprintf(D_801ED950, "this->polygon_check == NULL(game_alloc() MemoryAllocationError.)\n"); @@ -2555,7 +2553,7 @@ void DynaLookup_ResetWaterBoxStartIndex(u16* waterBoxStartIndex) { /** * Initialize BgActor */ -void BgActor_Init(GlobalContext* globalCtx, BgActor* bgActor) { +void BgActor_Init(PlayState* play, BgActor* bgActor) { bgActor->actor = NULL; bgActor->colHeader = NULL; ScaleRotPos_Init(&bgActor->prevTransform); @@ -2599,8 +2597,8 @@ void DynaPoly_NullPolyList(CollisionPoly** polyList) { /** * Allocate dyna.polyList */ -void DynaPoly_AllocPolyList(GlobalContext* globalCtx, CollisionPoly** polyList, s32 numPolys) { - *polyList = THA_AllocEndAlign(&globalCtx->state.heap, numPolys * sizeof(CollisionPoly), -2); +void DynaPoly_AllocPolyList(PlayState* play, CollisionPoly** polyList, s32 numPolys) { + *polyList = THA_AllocEndAlign(&play->state.heap, numPolys * sizeof(CollisionPoly), -2); } /** @@ -2613,8 +2611,8 @@ void DynaPoly_NullVtxList(Vec3s** vtxList) { /** * Allocate dyna.vtxList */ -void DynaPoly_AllocVtxList(GlobalContext* globalCtx, Vec3s** vtxList, s32 numVtx) { - *vtxList = THA_AllocEndAlign(&globalCtx->state.heap, numVtx * sizeof(Vec3s), -2); +void DynaPoly_AllocVtxList(PlayState* play, Vec3s** vtxList, s32 numVtx) { + *vtxList = THA_AllocEndAlign(&play->state.heap, numVtx * sizeof(Vec3s), -2); } /** @@ -2628,14 +2626,14 @@ void DynaPoly_InitWaterBoxList(DynaWaterBoxList* waterBoxList) { /** * Allocate dyna.waterBoxList */ -void DynaPoly_AllocWaterBoxList(GlobalContext* globalCtx, DynaWaterBoxList* waterBoxList, s32 numWaterBoxes) { - waterBoxList->boxes = THA_AllocEndAlign(&globalCtx->state.heap, numWaterBoxes * sizeof(WaterBox), -2); +void DynaPoly_AllocWaterBoxList(PlayState* play, DynaWaterBoxList* waterBoxList, s32 numWaterBoxes) { + waterBoxList->boxes = THA_AllocEndAlign(&play->state.heap, numWaterBoxes * sizeof(WaterBox), -2); } /** * Update BgActor's prevTransform */ -void DynaPoly_SetBgActorPrevTransform(GlobalContext* globalCtx, BgActor* bgActor) { +void DynaPoly_SetBgActorPrevTransform(PlayState* play, BgActor* bgActor) { bgActor->prevTransform = bgActor->curTransform; } @@ -2652,43 +2650,42 @@ s32 DynaPoly_IsBgIdBgActor(s32 bgId) { /** * Init DynaCollisionContext */ -void DynaPoly_Init(GlobalContext* globalCtx, DynaCollisionContext* dyna) { +void DynaPoly_Init(PlayState* play, DynaCollisionContext* dyna) { dyna->bitFlag = DYNAPOLY_INVALIDATE_LOOKUP; DynaPoly_NullPolyList(&dyna->polyList); DynaPoly_NullVtxList(&dyna->vtxList); DynaPoly_InitWaterBoxList(&dyna->waterBoxList); - DynaSSNodeList_Init(globalCtx, &dyna->polyNodes); + DynaSSNodeList_Init(play, &dyna->polyNodes); } /** * Set DynaCollisionContext */ -void DynaPoly_Alloc(GlobalContext* globalCtx, DynaCollisionContext* dyna) { +void DynaPoly_Alloc(PlayState* play, DynaCollisionContext* dyna) { s32 i; for (i = 0; i < BG_ACTOR_MAX; i++) { - BgActor_Init(globalCtx, &dyna->bgActors[i]); + BgActor_Init(play, &dyna->bgActors[i]); dyna->bgActorFlags[i] = 0; } DynaPoly_NullPolyList(&dyna->polyList); - DynaPoly_AllocPolyList(globalCtx, &dyna->polyList, dyna->polyListMax); + DynaPoly_AllocPolyList(play, &dyna->polyList, dyna->polyListMax); DynaPoly_NullVtxList(&dyna->vtxList); - DynaPoly_AllocVtxList(globalCtx, &dyna->vtxList, dyna->vtxListMax); + DynaPoly_AllocVtxList(play, &dyna->vtxList, dyna->vtxListMax); DynaPoly_InitWaterBoxList(&dyna->waterBoxList); - DynaPoly_AllocWaterBoxList(globalCtx, &dyna->waterBoxList, DYNA_WATERBOX_MAX); + DynaPoly_AllocWaterBoxList(play, &dyna->waterBoxList, DYNA_WATERBOX_MAX); - DynaSSNodeList_Init(globalCtx, &dyna->polyNodes); - DynaSSNodeList_Alloc(globalCtx, &dyna->polyNodes, dyna->polyNodesMax); + DynaSSNodeList_Init(play, &dyna->polyNodes); + DynaSSNodeList_Alloc(play, &dyna->polyNodes, dyna->polyNodesMax); } /** * Set BgActor * original name: DynaPolyInfo_setActor */ -s32 DynaPoly_SetBgActor(GlobalContext* globalCtx, DynaCollisionContext* dyna, Actor* actor, - CollisionHeader* colHeader) { +s32 DynaPoly_SetBgActor(PlayState* play, DynaCollisionContext* dyna, Actor* actor, CollisionHeader* colHeader) { s32 bgId; s32 foundSlot = false; @@ -2722,42 +2719,42 @@ DynaPolyActor* DynaPoly_GetActor(CollisionContext* colCtx, s32 bgId) { return (DynaPolyActor*)colCtx->dyna.bgActors[bgId].actor; } -void func_800C62BC(GlobalContext* globalCtx, DynaCollisionContext* dyna, s32 bgId) { +void func_800C62BC(PlayState* play, DynaCollisionContext* dyna, s32 bgId) { if (DynaPoly_IsBgIdBgActor(bgId)) { dyna->bgActorFlags[bgId] |= 4; dyna->bitFlag |= DYNAPOLY_INVALIDATE_LOOKUP; } } -void func_800C6314(GlobalContext* globalCtx, DynaCollisionContext* dyna, s32 bgId) { +void func_800C6314(PlayState* play, DynaCollisionContext* dyna, s32 bgId) { if (DynaPoly_IsBgIdBgActor(bgId)) { dyna->bgActorFlags[bgId] &= ~4; dyna->bitFlag |= DYNAPOLY_INVALIDATE_LOOKUP; } } -void func_800C636C(GlobalContext* globalCtx, DynaCollisionContext* dyna, s32 bgId) { +void func_800C636C(PlayState* play, DynaCollisionContext* dyna, s32 bgId) { if (DynaPoly_IsBgIdBgActor(bgId)) { dyna->bgActorFlags[bgId] |= 8; dyna->bitFlag |= DYNAPOLY_INVALIDATE_LOOKUP; } } -void func_800C63C4(GlobalContext* globalCtx, DynaCollisionContext* dyna, s32 bgId) { +void func_800C63C4(PlayState* play, DynaCollisionContext* dyna, s32 bgId) { if (DynaPoly_IsBgIdBgActor(bgId)) { dyna->bgActorFlags[bgId] &= ~8; dyna->bitFlag |= DYNAPOLY_INVALIDATE_LOOKUP; } } -void func_800C641C(GlobalContext* globalCtx, DynaCollisionContext* dyna, s32 bgId) { +void func_800C641C(PlayState* play, DynaCollisionContext* dyna, s32 bgId) { if (DynaPoly_IsBgIdBgActor(bgId)) { dyna->bgActorFlags[bgId] |= 0x20; dyna->bitFlag |= DYNAPOLY_INVALIDATE_LOOKUP; } } -void func_800C6474(GlobalContext* globalCtx, DynaCollisionContext* dyna, s32 bgId) { +void func_800C6474(PlayState* play, DynaCollisionContext* dyna, s32 bgId) { if (DynaPoly_IsBgIdBgActor(bgId)) { dyna->bgActorFlags[bgId] &= ~0x20; dyna->bitFlag |= DYNAPOLY_INVALIDATE_LOOKUP; @@ -2767,13 +2764,13 @@ void func_800C6474(GlobalContext* globalCtx, DynaCollisionContext* dyna, s32 bgI /** * original name: DynaPolyInfo_delReserve */ -void DynaPoly_DeleteBgActor(GlobalContext* globalCtx, DynaCollisionContext* dyna, s32 bgId) { +void DynaPoly_DeleteBgActor(PlayState* play, DynaCollisionContext* dyna, s32 bgId) { DynaPolyActor* actor; if (DynaPoly_IsBgIdBgActor(bgId) == false) { return; } - actor = DynaPoly_GetActor(&globalCtx->colCtx, bgId); + actor = DynaPoly_GetActor(&play->colCtx, bgId); if (actor != NULL) { actor->bgId = BGACTOR_NEG_ONE; @@ -2782,7 +2779,7 @@ void DynaPoly_DeleteBgActor(GlobalContext* globalCtx, DynaCollisionContext* dyna } } -void func_800C6554(GlobalContext* globalCtx, DynaCollisionContext* dyna) { +void func_800C6554(PlayState* play, DynaCollisionContext* dyna) { dyna->bitFlag |= DYNAPOLY_INVALIDATE_LOOKUP; } @@ -2840,8 +2837,8 @@ void BgCheck_CalcWaterboxDimensions(Vec3f* minPos, Vec3f* maxXPos, Vec3f* maxZPo /** * original name: DynaPolyInfo_expandSRT */ -void DynaPoly_ExpandSRT(GlobalContext* globalCtx, DynaCollisionContext* dyna, s32 bgId, s32* vtxStartIndex, - s32* polyStartIndex, s32* waterBoxStartIndex) { +void DynaPoly_ExpandSRT(PlayState* play, DynaCollisionContext* dyna, s32 bgId, s32* vtxStartIndex, s32* polyStartIndex, + s32* waterBoxStartIndex) { Actor* actor; s32 pad; s32 pad2; @@ -3065,13 +3062,13 @@ void DynaPoly_ExpandSRT(GlobalContext* globalCtx, DynaCollisionContext* dyna, s3 #pragma GLOBAL_ASM("asm/non_matchings/code/z_bgcheck/DynaPoly_ExpandSRT.s") #endif -void BgCheck_ResetFlagsIfLoadedActor(GlobalContext* globalCtx, DynaCollisionContext* dyna, Actor* actor) { +void BgCheck_ResetFlagsIfLoadedActor(PlayState* play, DynaCollisionContext* dyna, Actor* actor) { DynaPolyActor* dynaActor; s32 i; for (i = 0; i < BG_ACTOR_MAX; i++) { if ((dyna->bgActorFlags[i] & 1)) { - dynaActor = DynaPoly_GetActor(&globalCtx->colCtx, i); + dynaActor = DynaPoly_GetActor(&play->colCtx, i); if (dynaActor != NULL && &dynaActor->actor == actor) { DynaPolyActor_ResetState((DynaPolyActor*)actor); return; @@ -3083,7 +3080,7 @@ void BgCheck_ResetFlagsIfLoadedActor(GlobalContext* globalCtx, DynaCollisionCont /** * original name: DynaPolyInfo_setup */ -void DynaPoly_Setup(GlobalContext* globalCtx, DynaCollisionContext* dyna) { +void DynaPoly_Setup(PlayState* play, DynaCollisionContext* dyna) { DynaPolyActor* actor; s32 vtxStartIndex; s32 polyStartIndex; @@ -3100,19 +3097,19 @@ void DynaPoly_Setup(GlobalContext* globalCtx, DynaCollisionContext* dyna) { if (dyna->bgActorFlags[i] & 2) { // Initialize BgActor dyna->bgActorFlags[i] = 0; - BgActor_Init(globalCtx, &dyna->bgActors[i]); + BgActor_Init(play, &dyna->bgActors[i]); dyna->bitFlag |= DYNAPOLY_INVALIDATE_LOOKUP; } if (dyna->bgActors[i].actor != NULL && dyna->bgActors[i].actor->update == NULL) { // Delete BgActor - actor = DynaPoly_GetActor(&globalCtx->colCtx, i); + actor = DynaPoly_GetActor(&play->colCtx, i); if (actor == NULL) { return; } actor->bgId = BGACTOR_NEG_ONE; dyna->bgActorFlags[i] = 0; - BgActor_Init(globalCtx, &dyna->bgActors[i]); + BgActor_Init(play, &dyna->bgActors[i]); dyna->bitFlag |= DYNAPOLY_INVALIDATE_LOOKUP; } } @@ -3121,7 +3118,7 @@ void DynaPoly_Setup(GlobalContext* globalCtx, DynaCollisionContext* dyna) { waterBoxStartIndex = 0; for (i = 0; i < BG_ACTOR_MAX; i++) { if ((dyna->bgActorFlags[i] & 1) && !(dyna->bgActorFlags[i] & 2)) { - DynaPoly_ExpandSRT(globalCtx, dyna, i, &vtxStartIndex, &polyStartIndex, &waterBoxStartIndex); + DynaPoly_ExpandSRT(play, dyna, i, &vtxStartIndex, &polyStartIndex, &waterBoxStartIndex); } } dyna->bitFlag &= ~DYNAPOLY_INVALIDATE_LOOKUP; @@ -3151,12 +3148,12 @@ void func_800C756C(DynaCollisionContext* dyna, s32* numPolygons, s32* numVertice /** * Update all BgActor's previous ScaleRotPos */ -void DynaPoly_UpdateBgActorTransforms(GlobalContext* globalCtx, DynaCollisionContext* dyna) { +void DynaPoly_UpdateBgActorTransforms(PlayState* play, DynaCollisionContext* dyna) { s32 i; for (i = 0; i < BG_ACTOR_MAX; i++) { if (dyna->bgActorFlags[i] & 1) { - DynaPoly_SetBgActorPrevTransform(globalCtx, &dyna->bgActors[i]); + DynaPoly_SetBgActorPrevTransform(play, &dyna->bgActors[i]); } } } @@ -3296,10 +3293,10 @@ f32 BgCheck_RaycastFloorDyna(DynaRaycast* dynaRaycast) { } dynaActor = DynaPoly_GetActor(dynaRaycast->colCtx, *dynaRaycast->bgId); - if ((result != BGCHECK_Y_MIN) && (dynaActor != NULL) && (dynaRaycast->globalCtx != NULL)) { - pauseState = dynaRaycast->globalCtx->pauseCtx.state != 0; + if ((result != BGCHECK_Y_MIN) && (dynaActor != NULL) && (dynaRaycast->play != NULL)) { + pauseState = dynaRaycast->play->pauseCtx.state != 0; if (!pauseState) { - pauseState = dynaRaycast->globalCtx->pauseCtx.debugState != 0; + pauseState = dynaRaycast->play->pauseCtx.debugEditor != DEBUG_EDITOR_NONE; } if (!pauseState && (dynaRaycast->colCtx->dyna.bgActorFlags[*dynaRaycast->bgId] & 2)) { curTransform = &dynaRaycast->dyna->bgActors[*dynaRaycast->bgId].curTransform; @@ -3965,8 +3962,8 @@ void CollisionHeader_SegmentedToVirtual(CollisionHeader* colHeader) { if (colHeader->surfaceTypeList) { colHeader->surfaceTypeList = Lib_SegmentedToVirtual(colHeader->surfaceTypeList); } - if (colHeader->cameraDataList) { - colHeader->cameraDataList = Lib_SegmentedToVirtual(colHeader->cameraDataList); + if (colHeader->bgCamList) { + colHeader->bgCamList = Lib_SegmentedToVirtual(colHeader->bgCamList); } if (colHeader->waterBoxes) { colHeader->waterBoxes = Lib_SegmentedToVirtual(colHeader->waterBoxes); @@ -3984,7 +3981,7 @@ void CollisionHeader_GetVirtual(CollisionHeader* colHeader, CollisionHeader** de /** * SEGMENT_TO_VIRTUAL all active BgActor CollisionHeaders */ -void BgCheck_InitCollisionHeaders(CollisionContext* colCtx, GlobalContext* globalCtx) { +void BgCheck_InitCollisionHeaders(CollisionContext* colCtx, PlayState* play) { DynaCollisionContext* dyna = &colCtx->dyna; s32 i; u16 flag; @@ -3992,7 +3989,7 @@ void BgCheck_InitCollisionHeaders(CollisionContext* colCtx, GlobalContext* globa for (i = 0; i < BG_ACTOR_MAX; i++) { flag = dyna->bgActorFlags[i]; if ((flag & 1) && !(flag & 2)) { - Actor_SetObjectDependency(globalCtx, dyna->bgActors[i].actor); + Actor_SetObjectDependency(play, dyna->bgActors[i].actor); CollisionHeader_SegmentedToVirtual(dyna->bgActors[i].colHeader); } } @@ -4029,128 +4026,142 @@ u32 SurfaceType_GetData(CollisionContext* colCtx, CollisionPoly* poly, s32 bgId, } /** - * SurfaceType return CamData Index + * SurfaceType get index of bgCam */ -u32 SurfaceType_GetCamDataIndex(CollisionContext* colCtx, CollisionPoly* poly, s32 bgId) { +u32 SurfaceType_GetBgCamIndex(CollisionContext* colCtx, CollisionPoly* poly, s32 bgId) { return SurfaceType_GetData(colCtx, poly, bgId, 0) & 0xFF; } /** - * CamData return camera setting + * BgCam get setting of bgCam */ -u16 func_800C9728(CollisionContext* colCtx, u32 camId, s32 bgId) { - u16 result; +u16 BgCheck_GetBgCamSettingImpl(CollisionContext* colCtx, u32 bgCamIndex, s32 bgId) { + u16 camSetting; CollisionHeader* colHeader; - CamData* camData; + BgCamInfo* bgCamList; colHeader = BgCheck_GetCollisionHeader(colCtx, bgId); if (colHeader == NULL) { - return 0; + return CAM_SET_NONE; } - camData = colHeader->cameraDataList; - result = camData[camId].setting; - return result; + + bgCamList = colHeader->bgCamList; + camSetting = bgCamList[bgCamIndex].setting; + + return camSetting; } /** - * SurfaceType return camera setting + * BgCam Get the camera setting of bgCam */ -u16 SurfaceType_GetCameraSetting(CollisionContext* colCtx, CollisionPoly* poly, s32 bgId) { +u16 BgCheck_GetBgCamSetting(CollisionContext* colCtx, CollisionPoly* poly, s32 bgId) { CollisionHeader* colHeader = BgCheck_GetCollisionHeader(colCtx, bgId); - CamData* camData; + BgCamInfo* bgCamList; + SurfaceType* surfaceTypes; + + if (colHeader == NULL) { + return CAM_SET_NONE; + } + + bgCamList = colHeader->bgCamList; + if (bgCamList == NULL) { + return CAM_SET_NONE; + } + + surfaceTypes = colHeader->surfaceTypeList; + if (surfaceTypes == NULL) { + return CAM_SET_NONE; + } + + return BgCheck_GetBgCamSettingImpl(colCtx, SurfaceType_GetBgCamIndex(colCtx, poly, bgId), bgId); +} + +/** + * BgCam Get the total count of Vec3s data from bgCamFuncData + */ +u16 BgCheck_GetBgCamCountImpl(CollisionContext* colCtx, u32 bgCamIndex, s32 bgId) { + CollisionHeader* colHeader = BgCheck_GetCollisionHeader(colCtx, bgId); + BgCamInfo* bgCamList; + + if (colHeader == NULL) { + return 0; + } + + bgCamList = colHeader->bgCamList; + if (bgCamList == NULL) { + return 0; + } + + return bgCamList[bgCamIndex].count; +} + +/** + * BgCam Get the total count of Vec3s data from bgCamFuncData + */ +u16 BgCheck_GetBgCamCount(CollisionContext* colCtx, CollisionPoly* poly, s32 bgId) { + CollisionHeader* colHeader = BgCheck_GetCollisionHeader(colCtx, bgId); + BgCamInfo* bgCamList; SurfaceType* surfaceTypes; if (colHeader == NULL) { return 0; } - camData = colHeader->cameraDataList; - if (camData == NULL) { + + bgCamList = colHeader->bgCamList; + if (bgCamList == NULL) { return 0; } + surfaceTypes = colHeader->surfaceTypeList; if (surfaceTypes == NULL) { return 0; } - return func_800C9728(colCtx, SurfaceType_GetCamDataIndex(colCtx, poly, bgId), bgId); + + return BgCheck_GetBgCamCountImpl(colCtx, SurfaceType_GetBgCamIndex(colCtx, poly, bgId), bgId); } /** - * CamData get number of camera data blocks + * BgCam Get Vec3s data from bgCamFuncData */ -u16 func_800C97F8(CollisionContext* colCtx, u32 camId, s32 bgId) { +Vec3s* BgCheck_GetBgCamFuncDataImpl(CollisionContext* colCtx, s32 bgCamIndex, s32 bgId) { CollisionHeader* colHeader = BgCheck_GetCollisionHeader(colCtx, bgId); - CamData* camData; - - if (colHeader == NULL) { - return 0; - } - - camData = colHeader->cameraDataList; - if (camData == NULL) { - return 0; - } - return camData[camId].numData; -} - -/** - * SurfaceType get number of camera data blocks - */ -u16 func_800C9844(CollisionContext* colCtx, CollisionPoly* poly, s32 bgId) { - CollisionHeader* colHeader = BgCheck_GetCollisionHeader(colCtx, bgId); - CamData* camData; - SurfaceType* surfaceTypes; - - if (colHeader == NULL) { - return 0; - } - camData = colHeader->cameraDataList; - if (camData == NULL) { - return 0; - } - surfaceTypes = colHeader->surfaceTypeList; - if (surfaceTypes == NULL) { - return 0; - } - return func_800C97F8(colCtx, SurfaceType_GetCamDataIndex(colCtx, poly, bgId), bgId); -} - -/** - * CamData get data - */ -Vec3s* func_800C98CC(CollisionContext* colCtx, s32 camId, s32 bgId) { - CollisionHeader* colHeader = BgCheck_GetCollisionHeader(colCtx, bgId); - CamData* cameraDataList; + BgCamInfo* bgCamList; if (colHeader == NULL) { return NULL; } - cameraDataList = colHeader->cameraDataList; - if (cameraDataList == NULL) { + + bgCamList = colHeader->bgCamList; + if (bgCamList == NULL) { return NULL; } - return Lib_SegmentedToVirtual(cameraDataList[camId].data); + + return Lib_SegmentedToVirtual(bgCamList[bgCamIndex].bgCamFuncData); } /** - * SurfaceType Get data + * BgCam Get Vec3s data from bgCamFuncData */ -Vec3s* SurfaceType_GetCamPosData(CollisionContext* colCtx, CollisionPoly* poly, s32 bgId) { +Vec3s* BgCheck_GetBgCamFuncData(CollisionContext* colCtx, CollisionPoly* poly, s32 bgId) { CollisionHeader* colHeader = BgCheck_GetCollisionHeader(colCtx, bgId); - CamData* camData; + BgCamInfo* bgCamList; SurfaceType* surfaceTypes; if (colHeader == NULL) { return NULL; } - camData = colHeader->cameraDataList; - if (camData == NULL) { + + bgCamList = colHeader->bgCamList; + if (bgCamList == NULL) { return NULL; } + surfaceTypes = colHeader->surfaceTypeList; if (surfaceTypes == NULL) { return NULL; } - return func_800C98CC(colCtx, SurfaceType_GetCamDataIndex(colCtx, poly, bgId), bgId); + + return BgCheck_GetBgCamFuncDataImpl(colCtx, SurfaceType_GetBgCamIndex(colCtx, poly, bgId), bgId); } /** @@ -4209,9 +4220,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; } @@ -4382,7 +4390,7 @@ u32 SurfaceType_IsWallDamage(CollisionContext* colCtx, CollisionPoly* poly, s32 * 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 */ -s32 WaterBox_GetSurfaceImpl(GlobalContext* globalCtx, CollisionContext* colCtx, f32 x, f32 z, f32* ySurface, +s32 WaterBox_GetSurfaceImpl(PlayState* play, CollisionContext* colCtx, f32 x, f32 z, f32* ySurface, WaterBox** outWaterBox, s32* bgId) { CollisionHeader* colHeader; u32 room; @@ -4396,7 +4404,7 @@ s32 WaterBox_GetSurfaceImpl(GlobalContext* globalCtx, CollisionContext* colCtx, for (curWaterBox = colHeader->waterBoxes; curWaterBox < colHeader->waterBoxes + colHeader->numWaterBoxes; curWaterBox++) { room = 0x3F & (curWaterBox->properties >> 13); - if (room == (u32)globalCtx->roomCtx.currRoom.num || room == 0x3F) { + if (room == (u32)play->roomCtx.currRoom.num || room == 0x3F) { if (curWaterBox->properties & 0x80000) { continue; } @@ -4441,15 +4449,17 @@ s32 WaterBox_GetSurfaceImpl(GlobalContext* globalCtx, CollisionContext* colCtx, return false; } -s32 WaterBox_GetSurface1(GlobalContext* globalCtx, CollisionContext* colCtx, f32 x, f32 z, f32* ySurface, +// boolean +s32 WaterBox_GetSurface1(PlayState* play, CollisionContext* colCtx, f32 x, f32 z, f32* ySurface, WaterBox** outWaterBox) { - WaterBox_GetSurface1_2(globalCtx, colCtx, x, z, ySurface, outWaterBox); + return WaterBox_GetSurface1_2(play, colCtx, x, z, ySurface, outWaterBox); } -s32 WaterBox_GetSurface1_2(GlobalContext* globalCtx, CollisionContext* colCtx, f32 x, f32 z, f32* ySurface, +// boolean +s32 WaterBox_GetSurface1_2(PlayState* play, CollisionContext* colCtx, f32 x, f32 z, f32* ySurface, WaterBox** outWaterBox) { s32 bgId; - return WaterBox_GetSurfaceImpl(globalCtx, colCtx, x, z, ySurface, outWaterBox, &bgId); + return WaterBox_GetSurfaceImpl(play, colCtx, x, z, ySurface, outWaterBox, &bgId); } #ifdef NON_MATCHING @@ -4459,7 +4469,7 @@ s32 WaterBox_GetSurface1_2(GlobalContext* globalCtx, CollisionContext* colCtx, f * returns the index of the waterbox found, or -1 if no waterbox is found * `outWaterBox` returns the pointer to the waterbox found, or NULL if none is found */ -s32 WaterBox_GetSurface2(GlobalContext* globalCtx, CollisionContext* colCtx, Vec3f* pos, f32 surfaceCheckDist, +s32 WaterBox_GetSurface2(PlayState* play, CollisionContext* colCtx, Vec3f* pos, f32 surfaceCheckDist, WaterBox** outWaterBox, s32* bgId) { CollisionHeader* colHeader; s32 room; @@ -4479,7 +4489,7 @@ s32 WaterBox_GetSurface2(GlobalContext* globalCtx, CollisionContext* colCtx, Vec waterBox = &colHeader->waterBoxes[i]; room = WATERBOX_ROOM(waterBox->properties); - if (!(room == globalCtx->roomCtx.currRoom.num || room == 0x3F)) { + if (!(room == play->roomCtx.currRoom.num || room == 0x3F)) { continue; } if ((waterBox->properties & 0x80000)) { @@ -4545,41 +4555,46 @@ f32 func_800CA568(CollisionContext* colCtx, s32 waterBoxId, s32 bgId) { } /** - * WaterBox get CamData index + * WaterBox get BgCam index */ -u32 WaterBox_GetCamDataIndex(CollisionContext* colCtx, WaterBox* waterBox) { +u32 WaterBox_GetBgCamIndex(CollisionContext* colCtx, WaterBox* waterBox) { u32 prop = waterBox->properties >> 0; return prop & 0xFF; } /** - * WaterBox get CamData camera setting + * WaterBox get BgCam setting */ -u16 WaterBox_GetCameraSetting(CollisionContext* colCtx, WaterBox* waterBox, s32 bgId) { +u16 WaterBox_GetBgCamSetting(CollisionContext* colCtx, WaterBox* waterBox, s32 bgId) { s32 pad[2]; - u16 result = 0; + u16 camSetting = CAM_SET_NONE; CollisionHeader* colHeader; - CamData* camData; - s32 camId; + BgCamInfo* bgCamList; + s32 bgCamIndex; colHeader = BgCheck_GetCollisionHeader(colCtx, bgId); if (colHeader == NULL) { - return result; - } - camId = WaterBox_GetCamDataIndex(colCtx, waterBox); - camData = colHeader->cameraDataList; - - if (camData == NULL) { - return result; + return camSetting; } - result = camData[camId].setting; - return result; + bgCamIndex = WaterBox_GetBgCamIndex(colCtx, waterBox); + bgCamList = colHeader->bgCamList; + + if (bgCamList == NULL) { + return camSetting; + } + + camSetting = bgCamList[bgCamIndex].setting; + + return camSetting; } -void func_800CA6B8(CollisionContext* colCtx, WaterBox* waterBox) { - WaterBox_GetCameraSetting(colCtx, waterBox, BGCHECK_SCENE); +/** + * WaterBox get scene BgCam setting + */ +void WaterBox_GetSceneBgCamSetting(CollisionContext* colCtx, WaterBox* waterBox) { + WaterBox_GetBgCamSetting(colCtx, waterBox, BGCHECK_SCENE); } /** @@ -4598,8 +4613,8 @@ u32 WaterBox_GetLightSettingIndex(CollisionContext* colCtx, WaterBox* waterBox) * 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 */ -s32 func_800CA6F0(GlobalContext* globalCtx, CollisionContext* colCtx, f32 x, f32 z, f32* ySurface, - WaterBox** outWaterBox, s32* bgId) { +s32 func_800CA6F0(PlayState* play, CollisionContext* colCtx, f32 x, f32 z, f32* ySurface, WaterBox** outWaterBox, + s32* bgId) { CollisionHeader* colHeader; u32 room; WaterBox* curWaterBox; @@ -4616,7 +4631,7 @@ s32 func_800CA6F0(GlobalContext* globalCtx, CollisionContext* colCtx, f32 x, f32 for (curWaterBox = colHeader->waterBoxes; curWaterBox < colHeader->waterBoxes + colHeader->numWaterBoxes; curWaterBox++) { room = WATERBOX_ROOM(curWaterBox->properties); - if (room == (u32)globalCtx->roomCtx.currRoom.num || room == 0x3F) { + if (room == (u32)play->roomCtx.currRoom.num || room == 0x3F) { if ((curWaterBox->properties & 0x80000) != 0) { if (curWaterBox->minPos.x < x && x < curWaterBox->minPos.x + curWaterBox->xLength) { if (curWaterBox->minPos.z < z && z < curWaterBox->minPos.z + curWaterBox->zLength) { @@ -4658,11 +4673,10 @@ s32 func_800CA6F0(GlobalContext* globalCtx, CollisionContext* colCtx, f32 x, f32 #pragma GLOBAL_ASM("asm/non_matchings/code/z_bgcheck/func_800CA6F0.s") #endif -s32 func_800CA9D0(GlobalContext* globalCtx, CollisionContext* colCtx, f32 x, f32 z, f32* ySurface, - WaterBox** outWaterBox) { +s32 func_800CA9D0(PlayState* play, CollisionContext* colCtx, f32 x, f32 z, f32* ySurface, WaterBox** outWaterBox) { s32 bgId; - return func_800CA6F0(globalCtx, colCtx, x, z, ySurface, outWaterBox, &bgId); + return func_800CA6F0(play, colCtx, x, z, ySurface, outWaterBox, &bgId); } /** diff --git a/src/code/z_camera.c b/src/code/z_camera.c index d3f1f9203..027b78a4a 100644 --- a/src/code/z_camera.c +++ b/src/code/z_camera.c @@ -1,70 +1,439 @@ #include "global.h" -#pragma GLOBAL_ASM("asm/non_matchings/code/z_camera/Camera_fabsf.s") +/** + * Returns the absolute value for floats + */ +f32 Camera_fabsf(f32 f) { + return ABS(f); +} -#pragma GLOBAL_ASM("asm/non_matchings/code/z_camera/Camera_LengthVec3f.s") +/** + * Returns the magnitude for 3D float vectors + */ +f32 Camera_Vec3fMagnitude(Vec3f* vec) { + return sqrtf(SQ(vec->x) + SQ(vec->y) + SQ(vec->z)); +} -#pragma GLOBAL_ASM("asm/non_matchings/code/z_camera/func_800CB270.s") +/** + * Interpolates along the curve shown below + * returns value y ranging from 0.0f to 1.0f for -xMax <= x <= xMax + * returns 1.0f otherwise + * + * y = 1.0f ________ _________ + * __ __ + * _ _ + * y axis _ _ + * ___ ___ + * _____ + * y = 0.0f | | | + * -xMax 0 xMax + * + * x axis + */ +f32 Camera_QuadraticAttenuation(f32 xRange, f32 x) { + f32 y; + f32 absX; + f32 percent40 = 0.4f; + f32 percent60; + f32 xQuadratic; + f32 xMaxQuadratic; // Normalizing constant -#pragma GLOBAL_ASM("asm/non_matchings/code/z_camera/Camera_Lerpf.s") + absX = Camera_fabsf(x); -#pragma GLOBAL_ASM("asm/non_matchings/code/z_camera/Camera_Lerps.s") + if (absX > xRange) { + // fixed value outside xMax range + y = 1.0f; + } else { + // inside xMax range + percent60 = 1.0f - percent40; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_camera/func_800CB42C.s") + if (absX < (xRange * percent60)) { + // quadratic curve in the inner 60% of xMax range: +concavity (upward curve) + xQuadratic = SQ(x) * (1.0f - percent40); + xMaxQuadratic = SQ(xRange * percent60); -#pragma GLOBAL_ASM("asm/non_matchings/code/z_camera/Camera_LerpVec3f.s") + y = xQuadratic / xMaxQuadratic; + } else { + // quadratic curve in the outer 40% of xMax range: -concavity (flattening curve) + xQuadratic = SQ(xRange - absX) * percent40; + xMaxQuadratic = SQ(0.4f * xRange); -#pragma GLOBAL_ASM("asm/non_matchings/code/z_camera/func_800CB544.s") + y = 1.0f - (xQuadratic / xMaxQuadratic); + } + } + return y; +} -#pragma GLOBAL_ASM("asm/non_matchings/code/z_camera/func_800CB584.s") +/* + * Performs linear interpoloation between `cur` and `target`. If `cur` is within + * `minDiff` units, the result is rounded up to `target` + */ +f32 Camera_LerpCeilF(f32 target, f32 cur, f32 stepScale, f32 minDiff) { + f32 diff = target - cur; + f32 step = diff * stepScale; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_camera/func_800CB5DC.s") + return (Camera_fabsf(diff) >= minDiff) ? cur + step : target; +} -#pragma GLOBAL_ASM("asm/non_matchings/code/z_camera/func_800CB60C.s") +/* + * Performs linear interpoloation between `cur` and `target`. If `cur` is within + * `minDiff` units, the result is rounded up to `target` + */ +s16 Camera_LerpCeilS(s16 target, s16 cur, f32 stepScale, s16 minDiff) { + s16 diff = target - cur; + s16 step = diff * stepScale + 0.5f; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_camera/func_800CB674.s") + return (ABS(diff) >= minDiff) ? cur + step : target; +} -#pragma GLOBAL_ASM("asm/non_matchings/code/z_camera/func_800CB6C8.s") +/* + * Performs linear interpoloation between `cur` and `target`. If `cur` is within + * `minDiff` units, the result is rounded down to `cur` + */ +s16 Camera_LerpFloorS(s16 target, s16 cur, f32 stepScale, s16 minDiff) { + s16 diff = target - cur; + s16 step = diff * stepScale + 0.5f; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_camera/func_800CB700.s") + return (ABS(diff) >= minDiff) ? cur + step : cur; +} -#pragma GLOBAL_ASM("asm/non_matchings/code/z_camera/func_800CB780.s") +/* + * Performs linear interpoloation between `cur` and `target`. If `cur` is within + * `minDiff` units, the result is rounded up to `target`. Output is written to `cur` + */ +void Camera_LerpCeilVec3f(Vec3f* target, Vec3f* cur, f32 xzStepScale, f32 yStepScale, f32 minDiff) { + cur->x = Camera_LerpCeilF(target->x, cur->x, xzStepScale, minDiff); + cur->y = Camera_LerpCeilF(target->y, cur->y, yStepScale, minDiff); + cur->z = Camera_LerpCeilF(target->z, cur->z, xzStepScale, minDiff); +} -#pragma GLOBAL_ASM("asm/non_matchings/code/z_camera/func_800CB7CC.s") +void Camera_SetUpdateRatesFastPitch(Camera* camera) { + camera->yawUpdateRateInv = 100.0f; + camera->pitchUpdateRateInv = 16.0f; + camera->rUpdateRateInv = 20.0f; + camera->yOffsetUpdateRate = 0.05f; + camera->xzOffsetUpdateRate = 0.05f; + camera->fovUpdateRate = 0.05f; +} -#pragma GLOBAL_ASM("asm/non_matchings/code/z_camera/func_800CB7F8.s") +void Camera_SetUpdateRatesFastYaw(Camera* camera) { + camera->rUpdateRateInv = 50.0f; + camera->pitchUpdateRateInv = 100.0f; + camera->yawUpdateRateInv = 50.0f; + camera->yOffsetUpdateRate = 0.01f; + camera->xzOffsetUpdateRate = 0.1f; + camera->fovUpdateRate = 0.01f; + if (camera->speedRatio > 1.0f) { + camera->speedRatio = 1.0f; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/code/z_camera/func_800CB828.s") +void Camera_SetUpdateRatesSlow(Camera* camera) { + camera->rUpdateRateInv = 1800.0f; + camera->yawUpdateRateInv = 1800.0f; + camera->pitchUpdateRateInv = 1800.0f; + camera->yOffsetUpdateRate = 0.01; + camera->xzOffsetUpdateRate = 0.01; + camera->fovUpdateRate = 0.01; +} -#pragma GLOBAL_ASM("asm/non_matchings/code/z_camera/func_800CB854.s") +/** + * Converts a 3D s16 vector into a 3D f32 vector + */ +Vec3f* Camera_Vec3sToVec3f(Vec3f* dest, Vec3s* src) { + Vec3f copy; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_camera/func_800CB880.s") + copy.x = src->x; + copy.y = src->y; + copy.z = src->z; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_camera/func_800CB8C8.s") + *dest = copy; + return dest; +} -#pragma GLOBAL_ASM("asm/non_matchings/code/z_camera/func_800CB8F4.s") +/** + * Returns the difference between two angles and scales the difference up + */ +s16 Camera_AngleDiffAndScale(s16 angle1, s16 angle2, f32 scale) { + return BINANG_SUB(angle1, angle2) * scale; +} -#pragma GLOBAL_ASM("asm/non_matchings/code/z_camera/func_800CB924.s") +/** + * Calculates the current offset between the camera's at-coordinates and the centered actor's coordinates + */ +void Camera_UpdateAtActorOffset(Camera* camera, Vec3f* actorOffset) { + camera->atActorOffset.x = camera->at.x - actorOffset->x; + camera->atActorOffset.y = camera->at.y - actorOffset->y; + camera->atActorOffset.z = camera->at.z - actorOffset->z; +} -#pragma GLOBAL_ASM("asm/non_matchings/code/z_camera/func_800CB950.s") +f32 Camera_GetFocalActorHeight(Camera* camera) { + PosRot actorFocus; + Actor* focalActor = camera->focalActor; + f32 focalHeight; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_camera/func_800CBA08.s") + if (focalActor == &GET_PLAYER(camera->play)->actor) { + focalHeight = Player_GetHeight((Player*)focalActor); + } else { + Actor_GetFocus(&actorFocus, focalActor); + focalHeight = actorFocus.pos.y - camera->focalActorPosRot.pos.y; + if (focalHeight == 0.0f) { + focalHeight = 10.0f; + } + } + return focalHeight; +} -#pragma GLOBAL_ASM("asm/non_matchings/code/z_camera/func_800CBA34.s") +f32 Camera_GetRunSpeedLimit(Camera* camera) { + Actor* focalActor = camera->focalActor; + f32 runSpeedLimit; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_camera/func_800CBA7C.s") + if (focalActor == &GET_PLAYER(camera->play)->actor) { + runSpeedLimit = Player_GetRunSpeedLimit((Player*)focalActor); + } else { + runSpeedLimit = 10.0f; + } -#pragma GLOBAL_ASM("asm/non_matchings/code/z_camera/func_800CBAAC.s") + return runSpeedLimit; +} -#pragma GLOBAL_ASM("asm/non_matchings/code/z_camera/func_800CBAD4.s") +s32 func_800CB7CC(Camera* camera) { + Actor* focalActor = camera->focalActor; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_camera/func_800CBB58.s") + if (camera->focalActor == &GET_PLAYER(camera->play)->actor) { + return ((Player*)focalActor)->stateFlags3 & PLAYER_STATE3_10; + } else { + return 0; + } +} +s32 Camera_IsMountedOnHorse(Camera* camera) { + Actor* focalActor = camera->focalActor; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_camera/func_800CBB88.s") + if (camera->focalActor == &GET_PLAYER(camera->play)->actor) { + return ((Player*)focalActor)->stateFlags1 & PLAYER_STATE1_800000; + } else { + return 0; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/code/z_camera/func_800CBC00.s") +s32 Camera_IsDekuHovering(Camera* camera) { + Actor* focalActor = camera->focalActor; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_camera/func_800CBC30.s") + if (camera->focalActor == &GET_PLAYER(camera->play)->actor) { + return ((Player*)focalActor)->stateFlags3 & PLAYER_STATE3_2000; + } else { + return 0; + } +} + +/** + * When walking in a cutscene? Used during Postman's minigame. + */ +s32 func_800CB854(Camera* camera) { + Actor* focalActor = camera->focalActor; + + if (camera->focalActor == &GET_PLAYER(camera->play)->actor) { + return ((Player*)focalActor)->stateFlags1 & PLAYER_STATE1_20; + } else { + return 0; + } +} + +s32 Camera_IsSwimming(Camera* camera) { + Actor* focalActor = camera->focalActor; + + if (focalActor == &GET_PLAYER(camera->play)->actor) { + if (((Player*)focalActor)->stateFlags3 & PLAYER_STATE3_8000) { + // Swimming as Zora + return 999; + } else { + // Swimming as Human or Fierce Deity + return ((Player*)focalActor)->stateFlags1 & PLAYER_STATE1_8000000; + } + } else { + // Camera not focused on player + return 0; + } +} + +s32 Camera_IsDiving(Camera* camera) { + Actor* focalActor = camera->focalActor; + + if (camera->focalActor == &GET_PLAYER(camera->play)->actor) { + return ((Player*)focalActor)->stateFlags2 & PLAYER_STATE2_800; + } else { + return 0; + } +} + +s32 Camera_IsPlayerFormZora(Camera* camera) { + Actor* focalActor = camera->focalActor; + + if (camera->focalActor == &GET_PLAYER(camera->play)->actor) { + return ((Player*)focalActor)->transformation == PLAYER_FORM_ZORA; + } else { + return false; + } +} + +s32 func_800CB924(Camera* camera) { + Actor* focalActor = camera->focalActor; + + if (camera->focalActor == &GET_PLAYER(camera->play)->actor) { + return ((Player*)focalActor)->stateFlags3 & PLAYER_STATE3_1000; + } else { + return 0; + } +} + +s32 func_800CB950(Camera* camera) { + Player* player; + s32 phi_v0; + s32 ret; + f32 yDiff; + + if (camera->focalActor == &GET_PLAYER(camera->play)->actor) { + yDiff = Camera_fabsf(camera->focalActorPosRot.pos.y - camera->playerFloorHeight); + + phi_v0 = false; + if (yDiff < 11.0f) { + phi_v0 = true; + } + + ret = phi_v0; + + if (!ret) { + + ret = false; + + if (camera->focalActor->gravity > -0.1f) { + ret = true; + } + + player = (Player*)camera->focalActor; + if (!ret) { + // Using zora fins + ret = player->stateFlags1 & PLAYER_STATE1_200000; + ret = !!ret; + } + } + return ret; + } else { + return true; + } +} + +s32 Camera_IsClimbingLedge(Camera* camera) { + Actor* focalActor = camera->focalActor; + + if (focalActor == &GET_PLAYER(camera->play)->actor) { + return ((Player*)focalActor)->stateFlags1 & PLAYER_STATE1_4; + } else { + return 0; + } +} + +s32 Camera_IsChargingSwordOrDekuFlowerDive(Camera* camera) { + Actor* focalActor = camera->focalActor; + s32 ret; + + if (focalActor == &GET_PLAYER(camera->play)->actor) { + // Charging Sword + ret = !!(((Player*)focalActor)->stateFlags1 & PLAYER_STATE1_1000); + if (!ret) { + // Deku Flower Dive + ret = !!(((Player*)focalActor)->stateFlags3 & PLAYER_STATE3_100); + } + return ret; + } else { + return false; + } +} + +s32 func_800CBA7C(Camera* camera) { + Actor* focalActor = camera->focalActor; + + if (camera->focalActor == &GET_PLAYER(camera->play)->actor) { + return ((Player*)focalActor)->stateFlags2 & PLAYER_STATE2_800000; + } else { + return 0; + } +} + +s32 func_800CBAAC(Camera* camera) { + Actor* focalActor = camera->focalActor; + + if (camera->focalActor == &GET_PLAYER(camera->play)->actor) { + return ((Player*)focalActor)->meleeWeaponState; + } else { + return 0; + } +} + +s32 Camera_GetFocalActorPos(Vec3f* dst, Camera* camera) { + PosRot focalPosRot; + Actor* focalActor = camera->focalActor; + + if (camera->focalActor == &GET_PLAYER(camera->play)->actor) { + *dst = ((Player*)focalActor)->bodyPartsPos[0]; + return dst; + } else { + Actor_GetWorldPosShapeRot(&focalPosRot, camera->focalActor); + *dst = focalPosRot.pos; + return dst; + } +} + +s32 Camera_IsUnderwaterAsZora(Camera* camera) { + Actor* focalActor = camera->focalActor; + + if (camera->focalActor == &GET_PLAYER(camera->play)->actor) { + return ((Player*)focalActor)->currentBoots == PLAYER_BOOTS_ZORA_UNDERWATER; + } else { + return 0; + } +} + +/** + * Evaluate if player is in one of two sword animations + */ +s32 func_800CBB88(Camera* camera) { + Actor* focalActor = camera->focalActor; + + if (camera->focalActor == &GET_PLAYER(camera->play)->actor) { + if ((((Player*)focalActor)->meleeWeaponState != 0) && + (((Player*)focalActor)->meleeWeaponAnimation == PLAYER_MWA_GORON_PUNCH_BUTT)) { + return 3; + } + + if ((((Player*)focalActor)->stateFlags2 & PLAYER_STATE2_20000) || + ((((Player*)focalActor)->meleeWeaponState != 0) && + (((Player*)focalActor)->meleeWeaponAnimation == PLAYER_MWA_ZORA_PUNCH_KICK))) { + return 1; + } + } + + return 0; +} + +s32 Camera_IsUsingZoraFins(Camera* camera) { + Actor* focalActor = camera->focalActor; + + if (camera->focalActor == &GET_PLAYER(camera->play)->actor) { + return ((Player*)focalActor)->stateFlags1 & PLAYER_STATE1_200000; + } else { + return 0; + } +} + +s32 func_800CBC30(Camera* camera, f32 waterYMax, f32 waterYMin) { + if ((camera->playerFloorHeight != camera->waterYPos) && (camera->waterYPos < waterYMax) && + (camera->waterYPos > waterYMin)) { + return true; + } else { + return false; + } +} #pragma GLOBAL_ASM("asm/non_matchings/code/z_camera/func_800CBC84.s") @@ -84,13 +453,78 @@ #pragma GLOBAL_ASM("asm/non_matchings/code/z_camera/func_800CC5C8.s") -#pragma GLOBAL_ASM("asm/non_matchings/code/z_camera/func_800CC740.s") +#define CAM_DATA_IS_BG (1 << 12) // if not set, then cam data is for actor cutscenes -#pragma GLOBAL_ASM("asm/non_matchings/code/z_camera/func_800CC7A8.s") +/** + * Returns the CameraSettingType of the camera from either the bgCam or the actorCsCam at index `camDataId` + */ +s16 Camera_GetBgCamOrActorCsCamSetting(Camera* camera, u32 camDataId) { + if (camDataId & CAM_DATA_IS_BG) { + return BgCheck_GetBgCamSettingImpl(&camera->play->colCtx, camDataId & ~CAM_DATA_IS_BG, BGCHECK_SCENE); + } else { + return Play_GetActorCsCamSetting(camera->play, camDataId); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/code/z_camera/func_800CC804.s") +/** + * Returns either the bgCam data or the actorCsCam data at index `camDataId` + */ +Vec3s* Camera_GetBgCamOrActorCsCamFuncData(Camera* camera, u32 camDataId) { + if (camDataId & CAM_DATA_IS_BG) { + return BgCheck_GetBgCamFuncDataImpl(&camera->play->colCtx, camDataId & ~CAM_DATA_IS_BG, BGCHECK_SCENE); + } else { + return Play_GetActorCsCamFuncData(camera->play, camDataId); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/code/z_camera/func_800CC874.s") +/** + * Gets the bgCam index for the poly `poly`, returns -1 if + * there is no camera data for that poly. + */ +s32 Camera_GetBgCamIndex(Camera* camera, s32* bgId, CollisionPoly* poly) { + s32 bgCamIndex = SurfaceType_GetBgCamIndex(&camera->play->colCtx, poly, *bgId); + s32 ret; + + if (BgCheck_GetBgCamSettingImpl(&camera->play->colCtx, bgCamIndex, *bgId) == CAM_SET_NONE) { + ret = -1; + } else { + ret = bgCamIndex; + } + + return ret; +} + +/** + * Gets the Camera setting for the water box the player is in. + * Returns -1 if the player is not in a water box, or does not have a swimming state. + * Returns -2 if there is no bgCam index for the water box. + * Returns the camera setting otherwise. + */ +s32 Camera_GetWaterBoxBgCamSetting(Camera* camera, f32* waterY) { + PosRot playerPosShape; + WaterBox* waterBox; + s32 camSetting; + s32 bgId; + + Actor_GetWorldPosShapeRot(&playerPosShape, camera->focalActor); + *waterY = playerPosShape.pos.y; + + if (!WaterBox_GetSurfaceImpl(camera->play, &camera->play->colCtx, playerPosShape.pos.x, playerPosShape.pos.z, + waterY, &waterBox, &bgId)) { + // player's position is not in a waterbox + *waterY = playerPosShape.pos.y; + return -1; + } + + if (!Camera_IsSwimming(camera)) { + return -1; + } + + camSetting = WaterBox_GetBgCamSetting(&camera->play->colCtx, waterBox, bgId); + + // -2: no bgCam index + return (camSetting == CAM_SET_NONE) ? -2 : camSetting; +} #pragma GLOBAL_ASM("asm/non_matchings/code/z_camera/func_800CC938.s") @@ -292,9 +726,9 @@ #pragma GLOBAL_ASM("asm/non_matchings/code/z_camera/func_800DE0E0.s") -#pragma GLOBAL_ASM("asm/non_matchings/code/z_camera/func_800DE0EC.s") +#pragma GLOBAL_ASM("asm/non_matchings/code/z_camera/Camera_InitPlayerSettings.s") -#pragma GLOBAL_ASM("asm/non_matchings/code/z_camera/func_800DE308.s") +#pragma GLOBAL_ASM("asm/non_matchings/code/z_camera/Camera_ChangeStatus.s") #pragma GLOBAL_ASM("asm/non_matchings/code/z_camera/func_800DE324.s") @@ -318,7 +752,7 @@ #pragma GLOBAL_ASM("asm/non_matchings/code/z_camera/func_800DF8EC.s") -#pragma GLOBAL_ASM("asm/non_matchings/code/z_camera/func_800DFAC8.s") +#pragma GLOBAL_ASM("asm/non_matchings/code/z_camera/Camera_ChangeSetting.s") #pragma GLOBAL_ASM("asm/non_matchings/code/z_camera/Camera_ChangeDataIdx.s") @@ -328,15 +762,15 @@ #pragma GLOBAL_ASM("asm/non_matchings/code/z_camera/Camera_GetInputDirYaw.s") -#pragma GLOBAL_ASM("asm/non_matchings/code/z_camera/func_800DFC90.s") +#pragma GLOBAL_ASM("asm/non_matchings/code/z_camera/Camera_GetCamDir.s") #pragma GLOBAL_ASM("asm/non_matchings/code/z_camera/Camera_GetCamDirPitch.s") #pragma GLOBAL_ASM("asm/non_matchings/code/z_camera/Camera_GetCamDirYaw.s") -#pragma GLOBAL_ASM("asm/non_matchings/code/z_camera/func_800DFD04.s") +#pragma GLOBAL_ASM("asm/non_matchings/code/z_camera/Camera_AddQuake.s") -#pragma GLOBAL_ASM("asm/non_matchings/code/z_camera/func_800DFD78.s") +#pragma GLOBAL_ASM("asm/non_matchings/code/z_camera/Camera_SetViewParam.s") #pragma GLOBAL_ASM("asm/non_matchings/code/z_camera/func_800DFEF0.s") @@ -350,9 +784,9 @@ #pragma GLOBAL_ASM("asm/non_matchings/code/z_camera/Camera_ClearFlags.s") -#pragma GLOBAL_ASM("asm/non_matchings/code/z_camera/func_800DFFAC.s") +#pragma GLOBAL_ASM("asm/non_matchings/code/z_camera/Camera_ChangeDoorCam.s") -#pragma GLOBAL_ASM("asm/non_matchings/code/z_camera/func_800E007C.s") +#pragma GLOBAL_ASM("asm/non_matchings/code/z_camera/Camera_Copy.s") #pragma GLOBAL_ASM("asm/non_matchings/code/z_camera/func_800E01AC.s") diff --git a/src/code/z_cheap_proc.c b/src/code/z_cheap_proc.c index d0709fde9..2b4f67cae 100644 --- a/src/code/z_cheap_proc.c +++ b/src/code/z_cheap_proc.c @@ -3,37 +3,37 @@ /** * Draws a display list to the opaque display buffer */ -void Gfx_DrawDListOpa(GlobalContext* globalCtx, Gfx* dlist) { +void Gfx_DrawDListOpa(PlayState* play, Gfx* dlist) { Gfx* dl; - OPEN_DISPS(globalCtx->state.gfxCtx); + OPEN_DISPS(play->state.gfxCtx); dl = POLY_OPA_DISP; gSPDisplayList(&dl[0], &sSetupDL[6 * 0x19]); - gSPMatrix(&dl[1], Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPMatrix(&dl[1], Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(&dl[2], dlist); POLY_OPA_DISP = &dl[3]; - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->state.gfxCtx); } /** * Draws a display list to the translucent display buffer */ -void Gfx_DrawDListXlu(GlobalContext* globalCtx, Gfx* dlist) { +void Gfx_DrawDListXlu(PlayState* play, Gfx* dlist) { Gfx* dl; - OPEN_DISPS(globalCtx->state.gfxCtx); + OPEN_DISPS(play->state.gfxCtx); dl = POLY_XLU_DISP; gSPDisplayList(&dl[0], &sSetupDL[6 * 0x19]); - gSPMatrix(&dl[1], Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPMatrix(&dl[1], Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(&dl[2], dlist); POLY_XLU_DISP = &dl[3]; - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->state.gfxCtx); } diff --git a/src/code/z_collision_check.c b/src/code/z_collision_check.c index 4b7f48696..edaa159c6 100644 --- a/src/code/z_collision_check.c +++ b/src/code/z_collision_check.c @@ -1,4 +1,3 @@ -#include "prevent_bss_reordering.h" #include "global.h" Vec3f D_801EDE00; @@ -91,7 +90,7 @@ s32 CollisionCheck_GetToucherDamage(Collider* at, ColliderInfo* atInfo, Collider return atInfo->toucher.damage; } -s32 Collider_InitBase(GlobalContext* globalCtx, Collider* collider) { +s32 Collider_InitBase(PlayState* play, Collider* collider) { static Collider defaultCollider = { NULL, NULL, NULL, NULL, AT_NONE, AC_NONE, OC1_NONE, OC2_NONE, COLTYPE_HIT3, COLSHAPE_MAX, }; @@ -100,14 +99,14 @@ s32 Collider_InitBase(GlobalContext* globalCtx, Collider* collider) { return 1; } -s32 Collider_DestroyBase(GlobalContext* globalCtx, Collider* collider) { +s32 Collider_DestroyBase(PlayState* play, Collider* collider) { return 1; } /** * Uses default OC2_TYPE_1 and COLTYPE_HIT0 */ -s32 Collider_SetBaseToActor(GlobalContext* globalCtx, Collider* collider, ColliderInitToActor* src) { +s32 Collider_SetBaseToActor(PlayState* play, Collider* collider, ColliderInitToActor* src) { collider->actor = src->actor; collider->atFlags = src->atFlags; collider->acFlags = src->acFlags; @@ -120,7 +119,7 @@ s32 Collider_SetBaseToActor(GlobalContext* globalCtx, Collider* collider, Collid /** * Uses default OC2_TYPE_1 */ -s32 Collider_SetBaseType1(GlobalContext* globalCtx, Collider* collider, Actor* actor, ColliderInitType1* src) { +s32 Collider_SetBaseType1(PlayState* play, Collider* collider, Actor* actor, ColliderInitType1* src) { collider->actor = actor; collider->colType = src->colType; collider->atFlags = src->atFlags; @@ -131,7 +130,7 @@ s32 Collider_SetBaseType1(GlobalContext* globalCtx, Collider* collider, Actor* a return 1; } -s32 Collider_SetBase(GlobalContext* globalCtx, Collider* collider, Actor* actor, ColliderInit* src) { +s32 Collider_SetBase(PlayState* play, Collider* collider, Actor* actor, ColliderInit* src) { collider->actor = actor; collider->colType = src->colType; collider->atFlags = src->atFlags; @@ -142,62 +141,62 @@ s32 Collider_SetBase(GlobalContext* globalCtx, Collider* collider, Actor* actor, return 1; } -void Collider_ResetATBase(GlobalContext* globalCtx, Collider* collider) { +void Collider_ResetATBase(PlayState* play, Collider* collider) { collider->at = NULL; collider->atFlags &= ~(AT_HIT | AT_BOUNCED); } -void Collider_ResetACBase(GlobalContext* globalCtx, Collider* collider) { +void Collider_ResetACBase(PlayState* play, Collider* collider) { collider->ac = NULL; collider->acFlags &= ~(AC_HIT | AC_BOUNCED); } -void Collider_ResetOCBase(GlobalContext* globalCtx, Collider* collider) { +void Collider_ResetOCBase(PlayState* play, Collider* collider) { collider->oc = NULL; collider->ocFlags1 &= ~OC1_HIT; collider->ocFlags2 &= ~OC2_HIT_PLAYER; } -s32 Collider_InitTouch(GlobalContext* globalCtx, ColliderTouch* touch) { +s32 Collider_InitTouch(PlayState* play, ColliderTouch* touch) { static ColliderTouch defaultColliderTouch = { 0x00000000, 0, 0 }; *touch = defaultColliderTouch; return 1; } -s32 Collider_DestroyTouch(GlobalContext* globalCtx, ColliderTouch* touch) { +s32 Collider_DestroyTouch(PlayState* play, ColliderTouch* touch) { return 1; } -s32 Collider_SetTouch(GlobalContext* globalCtx, ColliderTouch* touch, ColliderTouchInit* src) { +s32 Collider_SetTouch(PlayState* play, ColliderTouch* touch, ColliderTouchInit* src) { touch->dmgFlags = src->dmgFlags; touch->effect = src->effect; touch->damage = src->damage; return 1; } -void Collider_ResetATInfoUnk(GlobalContext* globalCtx, ColliderInfo* info) { +void Collider_ResetATInfoUnk(PlayState* play, ColliderInfo* info) { } -s32 Collider_InitBump(GlobalContext* globalCtx, ColliderBump* bump) { +s32 Collider_InitBump(PlayState* play, ColliderBump* bump) { static ColliderBump defaultColliderBump = { 0xF7CFFFFF, 0, 0, { 0, 0, 0 } }; *bump = defaultColliderBump; return 1; } -s32 Collider_DestroyBump(GlobalContext* globalCtx, ColliderBump* bump) { +s32 Collider_DestroyBump(PlayState* play, ColliderBump* bump) { return 1; } -s32 Collider_SetBump(GlobalContext* globalCtx, ColliderBump* bump, ColliderBumpInit* src) { +s32 Collider_SetBump(PlayState* play, ColliderBump* bump, ColliderBumpInit* src) { bump->dmgFlags = src->dmgFlags; bump->effect = src->effect; bump->defense = src->defense; return 1; } -s32 Collider_InitInfo(GlobalContext* globalCtx, ColliderInfo* info) { +s32 Collider_InitInfo(PlayState* play, ColliderInfo* info) { static ColliderInfo defaultColliderInfo = { { 0, 0, 0 }, { 0xF7CFFFFF, 0, 0, { 0, 0, 0 } }, ELEMTYPE_UNK0, TOUCH_NONE, @@ -207,36 +206,36 @@ s32 Collider_InitInfo(GlobalContext* globalCtx, ColliderInfo* info) { }; *info = defaultColliderInfo; - Collider_InitTouch(globalCtx, &info->toucher); - Collider_InitBump(globalCtx, &info->bumper); + Collider_InitTouch(play, &info->toucher); + Collider_InitBump(play, &info->bumper); return 1; } -s32 Collider_DestroyInfo(GlobalContext* globalCtx, ColliderInfo* info) { - Collider_DestroyTouch(globalCtx, &info->toucher); - Collider_DestroyBump(globalCtx, &info->bumper); +s32 Collider_DestroyInfo(PlayState* play, ColliderInfo* info) { + Collider_DestroyTouch(play, &info->toucher); + Collider_DestroyBump(play, &info->bumper); return 1; } -s32 Collider_SetInfo(GlobalContext* globalCtx, ColliderInfo* info, ColliderInfoInit* src) { +s32 Collider_SetInfo(PlayState* play, ColliderInfo* info, ColliderInfoInit* src) { info->elemType = src->elemType; - Collider_SetTouch(globalCtx, &info->toucher, &src->toucher); - Collider_SetBump(globalCtx, &info->bumper, &src->bumper); + Collider_SetTouch(play, &info->toucher, &src->toucher); + Collider_SetBump(play, &info->bumper, &src->bumper); info->toucherFlags = src->toucherFlags; info->bumperFlags = src->bumperFlags; info->ocElemFlags = src->ocElemFlags; return 1; } -void Collider_ResetATInfo(GlobalContext* globalCtx, ColliderInfo* info) { +void Collider_ResetATInfo(PlayState* play, ColliderInfo* info) { info->atHit = NULL; info->atHitInfo = NULL; info->toucherFlags &= ~TOUCH_HIT; info->toucherFlags &= ~TOUCH_DREW_HITMARK; - Collider_ResetATInfoUnk(globalCtx, info); + Collider_ResetATInfoUnk(play, info); } -void Collider_ResetACInfo(GlobalContext* globalCtx, ColliderInfo* info) { +void Collider_ResetACInfo(PlayState* play, ColliderInfo* info) { info->bumper.hitPos.x = info->bumper.hitPos.y = info->bumper.hitPos.z = 0; info->bumperFlags &= ~BUMP_HIT; info->bumperFlags &= ~BUMP_DRAW_HITMARK; @@ -244,11 +243,11 @@ void Collider_ResetACInfo(GlobalContext* globalCtx, ColliderInfo* info) { info->acHitInfo = NULL; } -void Collider_ResetOCInfo(GlobalContext* globalCtx, ColliderInfo* info) { +void Collider_ResetOCInfo(PlayState* play, ColliderInfo* info) { info->ocElemFlags &= ~OCELEM_HIT; } -s32 Collider_InitJntSphElementDim(GlobalContext* globalCtx, ColliderJntSphElementDim* dim) { +s32 Collider_InitJntSphElementDim(PlayState* play, ColliderJntSphElementDim* dim) { static ColliderJntSphElementDim defaultColliderJntSphElementDim = { { { 0, 0, 0 }, 0 }, { { 0, 0, 0 }, 0 }, @@ -260,56 +259,55 @@ s32 Collider_InitJntSphElementDim(GlobalContext* globalCtx, ColliderJntSphElemen return 1; } -s32 Collider_DestroyJntSphElementDim(GlobalContext* globalCtx, ColliderJntSphElementDim* dim) { +s32 Collider_DestroyJntSphElementDim(PlayState* play, ColliderJntSphElementDim* dim) { return 1; } -s32 Collider_SetJntSphElementDim(GlobalContext* globalCtx, ColliderJntSphElementDim* dest, - ColliderJntSphElementDimInit* src) { +s32 Collider_SetJntSphElementDim(PlayState* play, ColliderJntSphElementDim* dest, ColliderJntSphElementDimInit* src) { dest->limb = src->limb; dest->modelSphere = src->modelSphere; dest->scale = src->scale * 0.01f; return 1; } -s32 Collider_InitJntSphElement(GlobalContext* globalCtx, ColliderJntSphElement* element) { - Collider_InitInfo(globalCtx, &element->info); - Collider_InitJntSphElementDim(globalCtx, &element->dim); +s32 Collider_InitJntSphElement(PlayState* play, ColliderJntSphElement* element) { + Collider_InitInfo(play, &element->info); + Collider_InitJntSphElementDim(play, &element->dim); return 1; } -s32 Collider_DestroyJntSphElement(GlobalContext* globalCtx, ColliderJntSphElement* element) { - Collider_DestroyInfo(globalCtx, &element->info); - Collider_DestroyJntSphElementDim(globalCtx, &element->dim); +s32 Collider_DestroyJntSphElement(PlayState* play, ColliderJntSphElement* element) { + Collider_DestroyInfo(play, &element->info); + Collider_DestroyJntSphElementDim(play, &element->dim); return 1; } -s32 Collider_SetJntSphElement(GlobalContext* globalCtx, ColliderJntSphElement* dest, ColliderJntSphElementInit* src) { - Collider_SetInfo(globalCtx, &dest->info, &src->info); - Collider_SetJntSphElementDim(globalCtx, &dest->dim, &src->dim); +s32 Collider_SetJntSphElement(PlayState* play, ColliderJntSphElement* dest, ColliderJntSphElementInit* src) { + Collider_SetInfo(play, &dest->info, &src->info); + Collider_SetJntSphElementDim(play, &dest->dim, &src->dim); return 1; } -s32 Collider_ResetJntSphElementAT(GlobalContext* globalCtx, ColliderJntSphElement* collider) { - Collider_ResetATInfo(globalCtx, &collider->info); +s32 Collider_ResetJntSphElementAT(PlayState* play, ColliderJntSphElement* collider) { + Collider_ResetATInfo(play, &collider->info); return 1; } -s32 Collider_ResetJntSphElementAC(GlobalContext* globalCtx, ColliderJntSphElement* collider) { - Collider_ResetACInfo(globalCtx, &collider->info); +s32 Collider_ResetJntSphElementAC(PlayState* play, ColliderJntSphElement* collider) { + Collider_ResetACInfo(play, &collider->info); return 1; } -s32 Collider_ResetJntSphElementOC(GlobalContext* globalCtx, ColliderJntSphElement* collider) { - Collider_ResetOCInfo(globalCtx, &collider->info); +s32 Collider_ResetJntSphElementOC(PlayState* play, ColliderJntSphElement* collider) { + Collider_ResetOCInfo(play, &collider->info); return 1; } /** * Initializes a ColliderJntSph to default values */ -s32 Collider_InitJntSph(GlobalContext* globalCtx, ColliderJntSph* collider) { - Collider_InitBase(globalCtx, &collider->base); +s32 Collider_InitJntSph(PlayState* play, ColliderJntSph* collider) { + Collider_InitBase(play, &collider->base); collider->count = 0; collider->elements = NULL; return 1; @@ -318,12 +316,12 @@ s32 Collider_InitJntSph(GlobalContext* globalCtx, ColliderJntSph* collider) { /** * Destroys a dynamically allocated ColliderJntSph */ -s32 Collider_FreeJntSph(GlobalContext* globalCtx, ColliderJntSph* collider) { +s32 Collider_FreeJntSph(PlayState* play, ColliderJntSph* collider) { ColliderJntSphElement* element; - Collider_DestroyBase(globalCtx, &collider->base); + Collider_DestroyBase(play, &collider->base); for (element = collider->elements; element < &collider->elements[collider->count]; element++) { - Collider_DestroyJntSphElement(globalCtx, element); + Collider_DestroyJntSphElement(play, element); } collider->count = 0; @@ -337,13 +335,13 @@ s32 Collider_FreeJntSph(GlobalContext* globalCtx, ColliderJntSph* collider) { /** * Destroys a preallocated ColliderJntSph */ -s32 Collider_DestroyJntSph(GlobalContext* globalCtx, ColliderJntSph* collider) { +s32 Collider_DestroyJntSph(PlayState* play, ColliderJntSph* collider) { ColliderJntSphElement* element; - Collider_DestroyBase(globalCtx, &collider->base); + Collider_DestroyBase(play, &collider->base); for (element = collider->elements; element < &collider->elements[collider->count]; element++) { - Collider_DestroyJntSphElement(globalCtx, element); + Collider_DestroyJntSphElement(play, element); } collider->count = 0; collider->elements = NULL; @@ -354,11 +352,11 @@ s32 Collider_DestroyJntSph(GlobalContext* globalCtx, ColliderJntSph* collider) { * Sets up the ColliderJntSph using the values in src, sets it to the actor specified in src, and dynamically allocates * the element array. Uses default OC2_TYPE_1 and COLTYPE_HIT0. */ -s32 Collider_SetJntSphToActor(GlobalContext* globalCtx, ColliderJntSph* collider, ColliderJntSphInitToActor* src) { +s32 Collider_SetJntSphToActor(PlayState* play, ColliderJntSph* collider, ColliderJntSphInitToActor* src) { ColliderJntSphElement* destElem; ColliderJntSphElementInit* srcElem; - Collider_SetBaseToActor(globalCtx, &collider->base, &src->base); + Collider_SetBaseToActor(play, &collider->base, &src->base); collider->count = src->count; collider->elements = ZeldaArena_Malloc(src->count * sizeof(ColliderJntSphElement)); @@ -369,8 +367,8 @@ s32 Collider_SetJntSphToActor(GlobalContext* globalCtx, ColliderJntSph* collider for (destElem = collider->elements, srcElem = src->elements; destElem < &collider->elements[collider->count]; destElem++, srcElem++) { - Collider_InitJntSphElement(globalCtx, destElem); - Collider_SetJntSphElement(globalCtx, destElem, srcElem); + Collider_InitJntSphElement(play, destElem); + Collider_SetJntSphElement(play, destElem, srcElem); } return 1; } @@ -379,12 +377,12 @@ s32 Collider_SetJntSphToActor(GlobalContext* globalCtx, ColliderJntSph* collider * Sets up the ColliderJntSph using the values in src and dynamically allocates the element array. Uses default * OC2_TYPE_1. */ -s32 Collider_SetJntSphAllocType1(GlobalContext* globalCtx, ColliderJntSph* sphereGroup, Actor* actor, +s32 Collider_SetJntSphAllocType1(PlayState* play, ColliderJntSph* sphereGroup, Actor* actor, ColliderJntSphInitType1* src) { ColliderJntSphElement* destElem; ColliderJntSphElementInit* srcElem; - Collider_SetBaseType1(globalCtx, &sphereGroup->base, actor, &src->base); + Collider_SetBaseType1(play, &sphereGroup->base, actor, &src->base); sphereGroup->count = src->count; sphereGroup->elements = ZeldaArena_Malloc(src->count * sizeof(ColliderJntSphElement)); @@ -395,8 +393,8 @@ s32 Collider_SetJntSphAllocType1(GlobalContext* globalCtx, ColliderJntSph* spher for (destElem = sphereGroup->elements, srcElem = src->elements; destElem < &sphereGroup->elements[sphereGroup->count]; destElem++, srcElem++) { - Collider_InitJntSphElement(globalCtx, destElem); - Collider_SetJntSphElement(globalCtx, destElem, srcElem); + Collider_InitJntSphElement(play, destElem); + Collider_SetJntSphElement(play, destElem, srcElem); } return 1; } @@ -404,19 +402,19 @@ s32 Collider_SetJntSphAllocType1(GlobalContext* globalCtx, ColliderJntSph* spher /** * Sets up the ColliderJntSph using the values in src, placing the element array in elements. */ -s32 Collider_SetJntSph(GlobalContext* globalCtx, ColliderJntSph* sphereGroup, Actor* actor, ColliderJntSphInit* src, +s32 Collider_SetJntSph(PlayState* play, ColliderJntSph* sphereGroup, Actor* actor, ColliderJntSphInit* src, ColliderJntSphElement* elements) { ColliderJntSphElement* destElem; ColliderJntSphElementInit* srcElem; - Collider_SetBase(globalCtx, &sphereGroup->base, actor, &src->base); + Collider_SetBase(play, &sphereGroup->base, actor, &src->base); sphereGroup->count = src->count; sphereGroup->elements = elements; for (destElem = sphereGroup->elements, srcElem = src->elements; destElem < &sphereGroup->elements[sphereGroup->count]; destElem++, srcElem++) { - Collider_InitJntSphElement(globalCtx, destElem); - Collider_SetJntSphElement(globalCtx, destElem, srcElem); + Collider_InitJntSphElement(play, destElem); + Collider_SetJntSphElement(play, destElem, srcElem); } return 1; @@ -425,24 +423,24 @@ s32 Collider_SetJntSph(GlobalContext* globalCtx, ColliderJntSph* sphereGroup, Ac /** * Fully initializes a ColliderJntSph using the values in `src`, placing the element array in elements. */ -s32 Collider_InitAndSetJntSph(GlobalContext* globalCtx, ColliderJntSph* sphereGroup, Actor* actor, - ColliderJntSphInit* src, ColliderJntSphElement* elements) { - Collider_InitJntSph(globalCtx, sphereGroup); - Collider_SetJntSph(globalCtx, sphereGroup, actor, src, elements); +s32 Collider_InitAndSetJntSph(PlayState* play, ColliderJntSph* sphereGroup, Actor* actor, ColliderJntSphInit* src, + ColliderJntSphElement* elements) { + Collider_InitJntSph(play, sphereGroup); + Collider_SetJntSph(play, sphereGroup, actor, src, elements); return 0; } /** * Resets the collider's AT collision flags. */ -s32 Collider_ResetJntSphAT(GlobalContext* globalCtx, Collider* collider) { +s32 Collider_ResetJntSphAT(PlayState* play, Collider* collider) { ColliderJntSphElement* element; ColliderJntSph* jntSph = (ColliderJntSph*)collider; - Collider_ResetATBase(globalCtx, &jntSph->base); + Collider_ResetATBase(play, &jntSph->base); for (element = jntSph->elements; element < &jntSph->elements[jntSph->count]; element++) { - Collider_ResetJntSphElementAT(globalCtx, element); + Collider_ResetJntSphElementAT(play, element); } return 1; } @@ -450,14 +448,14 @@ s32 Collider_ResetJntSphAT(GlobalContext* globalCtx, Collider* collider) { /** * Resets the collider's AC collision flags. */ -s32 Collider_ResetJntSphAC(GlobalContext* globalCtx, Collider* collider) { +s32 Collider_ResetJntSphAC(PlayState* play, Collider* collider) { ColliderJntSphElement* element; ColliderJntSph* jntSph = (ColliderJntSph*)collider; - Collider_ResetACBase(globalCtx, &jntSph->base); + Collider_ResetACBase(play, &jntSph->base); for (element = jntSph->elements; element < &jntSph->elements[jntSph->count]; element++) { - Collider_ResetJntSphElementAC(globalCtx, element); + Collider_ResetJntSphElementAC(play, element); } return 1; } @@ -465,30 +463,30 @@ s32 Collider_ResetJntSphAC(GlobalContext* globalCtx, Collider* collider) { /** * Resets the collider's OC collision flags. */ -s32 Collider_ResetJntSphOC(GlobalContext* globalCtx, Collider* collider) { +s32 Collider_ResetJntSphOC(PlayState* play, Collider* collider) { ColliderJntSphElement* element; ColliderJntSph* jntSph = (ColliderJntSph*)collider; - Collider_ResetOCBase(globalCtx, &jntSph->base); + Collider_ResetOCBase(play, &jntSph->base); for (element = jntSph->elements; element < &jntSph->elements[jntSph->count]; element++) { - Collider_ResetJntSphElementOC(globalCtx, element); + Collider_ResetJntSphElementOC(play, element); } return 1; } -s32 Collider_InitCylinderDim(GlobalContext* globalCtx, Cylinder16* dim) { +s32 Collider_InitCylinderDim(PlayState* play, Cylinder16* dim) { static Cylinder16 defaultColliderCylinderDim = { 0, 0, 0, { 0, 0, 0 } }; *dim = defaultColliderCylinderDim; return 1; } -s32 Collider_DestroyCylinderDim(GlobalContext* globalCtx, Cylinder16* dim) { +s32 Collider_DestroyCylinderDim(PlayState* play, Cylinder16* dim) { return 1; } -s32 Collider_SetCylinderDim(GlobalContext* globalCtx, Cylinder16* dim, Cylinder16* src) { +s32 Collider_SetCylinderDim(PlayState* play, Cylinder16* dim, Cylinder16* src) { *dim = *src; return 1; } @@ -496,20 +494,20 @@ s32 Collider_SetCylinderDim(GlobalContext* globalCtx, Cylinder16* dim, Cylinder1 /** * Initializes a ColliderCylinder to default values */ -s32 Collider_InitCylinder(GlobalContext* globalCtx, ColliderCylinder* collider) { - Collider_InitBase(globalCtx, &collider->base); - Collider_InitInfo(globalCtx, &collider->info); - Collider_InitCylinderDim(globalCtx, &collider->dim); +s32 Collider_InitCylinder(PlayState* play, ColliderCylinder* collider) { + Collider_InitBase(play, &collider->base); + Collider_InitInfo(play, &collider->info); + Collider_InitCylinderDim(play, &collider->dim); return 1; } /** * Destroys a ColliderCylinder */ -s32 Collider_DestroyCylinder(GlobalContext* globalCtx, ColliderCylinder* collider) { - Collider_DestroyBase(globalCtx, &collider->base); - Collider_DestroyInfo(globalCtx, &collider->info); - Collider_DestroyCylinderDim(globalCtx, &collider->dim); +s32 Collider_DestroyCylinder(PlayState* play, ColliderCylinder* collider) { + Collider_DestroyBase(play, &collider->base); + Collider_DestroyInfo(play, &collider->info); + Collider_DestroyCylinderDim(play, &collider->dim); return 1; } @@ -517,80 +515,77 @@ s32 Collider_DestroyCylinder(GlobalContext* globalCtx, ColliderCylinder* collide * Sets up the ColliderCylinder using the values in src and sets it to the actor specified in src. Uses default * OC2_TYPE_1 and COLTYPE_0. */ -s32 Collider_SetCylinderToActor(GlobalContext* globalCtx, ColliderCylinder* collider, - ColliderCylinderInitToActor* src) { - Collider_SetBaseToActor(globalCtx, &collider->base, &src->base); - Collider_SetInfo(globalCtx, &collider->info, &src->info); - Collider_SetCylinderDim(globalCtx, &collider->dim, &src->dim); +s32 Collider_SetCylinderToActor(PlayState* play, ColliderCylinder* collider, ColliderCylinderInitToActor* src) { + Collider_SetBaseToActor(play, &collider->base, &src->base); + Collider_SetInfo(play, &collider->info, &src->info); + Collider_SetCylinderDim(play, &collider->dim, &src->dim); return 1; } /** * Sets up the ColliderCylinder using the values in src. Uses default OC2_TYPE_1 */ -s32 Collider_SetCylinderType1(GlobalContext* globalCtx, ColliderCylinder* collider, Actor* actor, +s32 Collider_SetCylinderType1(PlayState* play, ColliderCylinder* collider, Actor* actor, ColliderCylinderInitType1* src) { - Collider_SetBaseType1(globalCtx, &collider->base, actor, &src->base); - Collider_SetInfo(globalCtx, &collider->info, &src->info); - Collider_SetCylinderDim(globalCtx, &collider->dim, &src->dim); + Collider_SetBaseType1(play, &collider->base, actor, &src->base); + Collider_SetInfo(play, &collider->info, &src->info); + Collider_SetCylinderDim(play, &collider->dim, &src->dim); return 1; } /** * Sets up the ColliderCylinder using the values in src. */ -s32 Collider_SetCylinder(GlobalContext* globalCtx, ColliderCylinder* collider, Actor* actor, - ColliderCylinderInit* src) { - Collider_SetBase(globalCtx, &collider->base, actor, &src->base); - Collider_SetInfo(globalCtx, &collider->info, &src->info); - Collider_SetCylinderDim(globalCtx, &collider->dim, &src->dim); +s32 Collider_SetCylinder(PlayState* play, ColliderCylinder* collider, Actor* actor, ColliderCylinderInit* src) { + Collider_SetBase(play, &collider->base, actor, &src->base); + Collider_SetInfo(play, &collider->info, &src->info); + Collider_SetCylinderDim(play, &collider->dim, &src->dim); return 1; } /** * Fully initializes a ColliderCylinder using the values in src. */ -s32 Collider_InitAndSetCylinder(GlobalContext* globalCtx, ColliderCylinder* collider, Actor* actor, - ColliderCylinderInit* src) { - Collider_InitCylinder(globalCtx, collider); - Collider_SetCylinder(globalCtx, collider, actor, src); +s32 Collider_InitAndSetCylinder(PlayState* play, ColliderCylinder* collider, Actor* actor, ColliderCylinderInit* src) { + Collider_InitCylinder(play, collider); + Collider_SetCylinder(play, collider, actor, src); return 1; } /** * Resets the collider's AT collision flags. */ -s32 Collider_ResetCylinderAT(GlobalContext* globalCtx, Collider* collider) { +s32 Collider_ResetCylinderAT(PlayState* play, Collider* collider) { ColliderCylinder* cylinder = (ColliderCylinder*)collider; - Collider_ResetATBase(globalCtx, &cylinder->base); - Collider_ResetATInfo(globalCtx, &cylinder->info); + Collider_ResetATBase(play, &cylinder->base); + Collider_ResetATInfo(play, &cylinder->info); return 1; } /** * Resets the collider's AC collision flags. */ -s32 Collider_ResetCylinderAC(GlobalContext* globalCtx, Collider* collider) { +s32 Collider_ResetCylinderAC(PlayState* play, Collider* collider) { ColliderCylinder* cylinder = (ColliderCylinder*)collider; - Collider_ResetACBase(globalCtx, &cylinder->base); - Collider_ResetACInfo(globalCtx, &cylinder->info); + Collider_ResetACBase(play, &cylinder->base); + Collider_ResetACInfo(play, &cylinder->info); return 1; } /** * Resets the collider's OC collision flags. */ -s32 Collider_ResetCylinderOC(GlobalContext* globalCtx, Collider* collider) { +s32 Collider_ResetCylinderOC(PlayState* play, Collider* collider) { ColliderCylinder* cylinder = (ColliderCylinder*)collider; - Collider_ResetOCBase(globalCtx, &cylinder->base); - Collider_ResetOCInfo(globalCtx, &cylinder->info); + Collider_ResetOCBase(play, &cylinder->base); + Collider_ResetOCInfo(play, &cylinder->info); return 1; } -s32 Collider_InitTrisElementDim(GlobalContext* globalCtx, TriNorm* dim) { +s32 Collider_InitTrisElementDim(PlayState* play, TriNorm* dim) { static TriNorm defaultColliderTrisElementDim = { { { 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 }, @@ -600,11 +595,11 @@ s32 Collider_InitTrisElementDim(GlobalContext* globalCtx, TriNorm* dim) { return 1; } -s32 Collider_DestroyTrisElementDim(GlobalContext* globalCtx, TriNorm* dim) { +s32 Collider_DestroyTrisElementDim(PlayState* play, TriNorm* dim) { return 1; } -s32 Collider_SetTrisElementDim(GlobalContext* globalCtx, TriNorm* dim, ColliderTrisElementDimInit* src) { +s32 Collider_SetTrisElementDim(PlayState* play, TriNorm* dim, ColliderTrisElementDimInit* src) { Vec3f* destVtx; Vec3f* srcVtx; f32 nx; @@ -625,44 +620,44 @@ s32 Collider_SetTrisElementDim(GlobalContext* globalCtx, TriNorm* dim, ColliderT return 1; } -s32 Collider_InitTrisElement(GlobalContext* globalCtx, ColliderTrisElement* element) { - Collider_InitInfo(globalCtx, &element->info); - Collider_InitTrisElementDim(globalCtx, &element->dim); +s32 Collider_InitTrisElement(PlayState* play, ColliderTrisElement* element) { + Collider_InitInfo(play, &element->info); + Collider_InitTrisElementDim(play, &element->dim); return 1; } -s32 Collider_DestroyTrisElement(GlobalContext* globalCtx, ColliderTrisElement* element) { - Collider_DestroyInfo(globalCtx, &element->info); - Collider_DestroyTrisElementDim(globalCtx, &element->dim); +s32 Collider_DestroyTrisElement(PlayState* play, ColliderTrisElement* element) { + Collider_DestroyInfo(play, &element->info); + Collider_DestroyTrisElementDim(play, &element->dim); return 1; } -s32 Collider_SetTrisElement(GlobalContext* globalCtx, ColliderTrisElement* element, ColliderTrisElementInit* src) { - Collider_SetInfo(globalCtx, &element->info, &src->info); - Collider_SetTrisElementDim(globalCtx, &element->dim, &src->dim); +s32 Collider_SetTrisElement(PlayState* play, ColliderTrisElement* element, ColliderTrisElementInit* src) { + Collider_SetInfo(play, &element->info, &src->info); + Collider_SetTrisElementDim(play, &element->dim, &src->dim); return 1; } -s32 Collider_ResetTrisElementAT(GlobalContext* globalCtx, ColliderTrisElement* element) { - Collider_ResetATInfo(globalCtx, &element->info); +s32 Collider_ResetTrisElementAT(PlayState* play, ColliderTrisElement* element) { + Collider_ResetATInfo(play, &element->info); return 1; } -s32 Collider_ResetTrisElementAC(GlobalContext* globalCtx, ColliderTrisElement* element) { - Collider_ResetACInfo(globalCtx, &element->info); +s32 Collider_ResetTrisElementAC(PlayState* play, ColliderTrisElement* element) { + Collider_ResetACInfo(play, &element->info); return 1; } -s32 Collider_ResetTrisElementOC(GlobalContext* globalCtx, ColliderTrisElement* element) { - Collider_ResetOCInfo(globalCtx, &element->info); +s32 Collider_ResetTrisElementOC(PlayState* play, ColliderTrisElement* element) { + Collider_ResetOCInfo(play, &element->info); return 1; } /** * Initializes a ColliderTris to default values */ -s32 Collider_InitTris(GlobalContext* globalCtx, ColliderTris* tris) { - Collider_InitBase(globalCtx, &tris->base); +s32 Collider_InitTris(PlayState* play, ColliderTris* tris) { + Collider_InitBase(play, &tris->base); tris->count = 0; tris->elements = NULL; return 1; @@ -671,13 +666,13 @@ s32 Collider_InitTris(GlobalContext* globalCtx, ColliderTris* tris) { /** * Destroys a dynamically allocated ColliderTris */ -s32 Collider_FreeTris(GlobalContext* globalCtx, ColliderTris* tris) { +s32 Collider_FreeTris(PlayState* play, ColliderTris* tris) { ColliderTrisElement* element; - Collider_DestroyBase(globalCtx, &tris->base); + Collider_DestroyBase(play, &tris->base); for (element = tris->elements; element < &tris->elements[tris->count]; element++) { - Collider_DestroyTrisElement(globalCtx, element); + Collider_DestroyTrisElement(play, element); } tris->count = 0; @@ -692,13 +687,13 @@ s32 Collider_FreeTris(GlobalContext* globalCtx, ColliderTris* tris) { /** * Destroys a preallocated ColliderTris */ -s32 Collider_DestroyTris(GlobalContext* globalCtx, ColliderTris* tris) { +s32 Collider_DestroyTris(PlayState* play, ColliderTris* tris) { ColliderTrisElement* element; - Collider_DestroyBase(globalCtx, &tris->base); + Collider_DestroyBase(play, &tris->base); for (element = tris->elements; element < &tris->elements[tris->count]; element++) { - Collider_DestroyTrisElement(globalCtx, element); + Collider_DestroyTrisElement(play, element); } tris->count = 0; tris->elements = NULL; @@ -709,11 +704,11 @@ s32 Collider_DestroyTris(GlobalContext* globalCtx, ColliderTris* tris) { * Sets up the ColliderTris using the values in src and dynamically allocates the element array. Uses default * OC2_TYPE_1. */ -s32 Collider_SetTrisAllocType1(GlobalContext* globalCtx, ColliderTris* tris, Actor* actor, ColliderTrisInitType1* src) { +s32 Collider_SetTrisAllocType1(PlayState* play, ColliderTris* tris, Actor* actor, ColliderTrisInitType1* src) { ColliderTrisElement* element; ColliderTrisElementInit* srcElem; - Collider_SetBaseType1(globalCtx, &tris->base, actor, &src->base); + Collider_SetBaseType1(play, &tris->base, actor, &src->base); tris->count = src->count; tris->elements = ZeldaArena_Malloc(tris->count * sizeof(ColliderTrisElement)); @@ -724,8 +719,8 @@ s32 Collider_SetTrisAllocType1(GlobalContext* globalCtx, ColliderTris* tris, Act for (element = tris->elements, srcElem = src->elements; element < &tris->elements[tris->count]; element++, srcElem++) { - Collider_InitTrisElement(globalCtx, element); - Collider_SetTrisElement(globalCtx, element, srcElem); + Collider_InitTrisElement(play, element); + Collider_SetTrisElement(play, element, srcElem); } return 1; @@ -734,19 +729,19 @@ s32 Collider_SetTrisAllocType1(GlobalContext* globalCtx, ColliderTris* tris, Act /** * Sets up the ColliderTris using the values in src, placing the element array in elements. */ -s32 Collider_SetTris(GlobalContext* globalCtx, ColliderTris* triGroup, Actor* actor, ColliderTrisInit* src, +s32 Collider_SetTris(PlayState* play, ColliderTris* triGroup, Actor* actor, ColliderTrisInit* src, ColliderTrisElement* tris) { ColliderTrisElement* element; ColliderTrisElementInit* srcElem; - Collider_SetBase(globalCtx, &triGroup->base, actor, &src->base); + Collider_SetBase(play, &triGroup->base, actor, &src->base); triGroup->count = src->count; triGroup->elements = tris; for (element = triGroup->elements, srcElem = src->elements; element < &triGroup->elements[triGroup->count]; element++, srcElem++) { - Collider_InitTrisElement(globalCtx, element); - Collider_SetTrisElement(globalCtx, element, srcElem); + Collider_InitTrisElement(play, element); + Collider_SetTrisElement(play, element, srcElem); } return 1; @@ -755,24 +750,24 @@ s32 Collider_SetTris(GlobalContext* globalCtx, ColliderTris* triGroup, Actor* ac /** * Fully initializes a ColliderTris using the values in src, placing the element array in elements. */ -s32 Collider_InitAndSetTris(GlobalContext* globalCtx, ColliderTris* tris, Actor* actor, ColliderTrisInit* src, +s32 Collider_InitAndSetTris(PlayState* play, ColliderTris* tris, Actor* actor, ColliderTrisInit* src, ColliderTrisElement* elements) { - Collider_InitTris(globalCtx, tris); - Collider_SetTris(globalCtx, tris, actor, src, elements); + Collider_InitTris(play, tris); + Collider_SetTris(play, tris, actor, src, elements); return 0; } /** * Resets the collider's AT collision flags. */ -s32 Collider_ResetTrisAT(GlobalContext* globalCtx, Collider* collider) { +s32 Collider_ResetTrisAT(PlayState* play, Collider* collider) { ColliderTrisElement* element; ColliderTris* tris = (ColliderTris*)collider; - Collider_ResetATBase(globalCtx, &tris->base); + Collider_ResetATBase(play, &tris->base); for (element = tris->elements; element < &tris->elements[tris->count]; element++) { - Collider_ResetTrisElementAT(globalCtx, element); + Collider_ResetTrisElementAT(play, element); } return 1; } @@ -780,14 +775,14 @@ s32 Collider_ResetTrisAT(GlobalContext* globalCtx, Collider* collider) { /** * Resets the collider's AC collision flags. */ -s32 Collider_ResetTrisAC(GlobalContext* globalCtx, Collider* collider) { +s32 Collider_ResetTrisAC(PlayState* play, Collider* collider) { ColliderTrisElement* element; ColliderTris* tris = (ColliderTris*)collider; - Collider_ResetACBase(globalCtx, &tris->base); + Collider_ResetACBase(play, &tris->base); for (element = tris->elements; element < &tris->elements[tris->count]; element++) { - Collider_ResetTrisElementAC(globalCtx, element); + Collider_ResetTrisElementAC(play, element); } return 1; } @@ -795,19 +790,19 @@ s32 Collider_ResetTrisAC(GlobalContext* globalCtx, Collider* collider) { /** * Resets the collider's OC collision flags. */ -s32 Collider_ResetTrisOC(GlobalContext* globalCtx, Collider* collider) { +s32 Collider_ResetTrisOC(PlayState* play, Collider* collider) { ColliderTrisElement* element; ColliderTris* tris = (ColliderTris*)collider; - Collider_ResetOCBase(globalCtx, &tris->base); + Collider_ResetOCBase(play, &tris->base); for (element = tris->elements; element < &tris->elements[tris->count]; element++) { - Collider_ResetTrisElementOC(globalCtx, element); + Collider_ResetTrisElementOC(play, element); } return 1; } -s32 Collider_InitQuadDim(GlobalContext* globalCtx, ColliderQuadDim* dim) { +s32 Collider_InitQuadDim(PlayState* play, ColliderQuadDim* dim) { static ColliderQuadDim defaultColliderQuadDim = { { { 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, 0, 0 }, @@ -819,11 +814,11 @@ s32 Collider_InitQuadDim(GlobalContext* globalCtx, ColliderQuadDim* dim) { return 1; } -s32 Collider_DestroyQuadDim(GlobalContext* globalCtx, ColliderQuadDim* dim) { +s32 Collider_DestroyQuadDim(PlayState* play, ColliderQuadDim* dim) { return 1; } -s32 Collider_ResetQuadACDist(GlobalContext* globalCtx, ColliderQuadDim* dim) { +s32 Collider_ResetQuadACDist(PlayState* play, ColliderQuadDim* dim) { dim->acDist = 1.0E38f; return 1; } @@ -837,7 +832,7 @@ void Collider_SetQuadMidpoints(ColliderQuadDim* dim) { dim->baMid.z = (dim->quad[1].z + dim->quad[0].z) * 0.5f; } -s32 Collider_SetQuadDim(GlobalContext* globalCtx, ColliderQuadDim* dim, ColliderQuadDimInit* init) { +s32 Collider_SetQuadDim(PlayState* play, ColliderQuadDim* dim, ColliderQuadDimInit* init) { dim->quad[0] = init->quad[0]; dim->quad[1] = init->quad[1]; dim->quad[2] = init->quad[2]; @@ -850,83 +845,83 @@ s32 Collider_SetQuadDim(GlobalContext* globalCtx, ColliderQuadDim* dim, Collider /** * Initializes a ColliderQuad to default values. */ -s32 Collider_InitQuad(GlobalContext* globalCtx, ColliderQuad* collider) { - Collider_InitBase(globalCtx, &collider->base); - Collider_InitInfo(globalCtx, &collider->info); - Collider_InitQuadDim(globalCtx, &collider->dim); +s32 Collider_InitQuad(PlayState* play, ColliderQuad* collider) { + Collider_InitBase(play, &collider->base); + Collider_InitInfo(play, &collider->info); + Collider_InitQuadDim(play, &collider->dim); return 1; } /** * Destroys a ColliderQuad. */ -s32 Collider_DestroyQuad(GlobalContext* globalCtx, ColliderQuad* collider) { - Collider_DestroyBase(globalCtx, &collider->base); - Collider_DestroyInfo(globalCtx, &collider->info); - Collider_DestroyQuadDim(globalCtx, &collider->dim); +s32 Collider_DestroyQuad(PlayState* play, ColliderQuad* collider) { + Collider_DestroyBase(play, &collider->base); + Collider_DestroyInfo(play, &collider->info); + Collider_DestroyQuadDim(play, &collider->dim); return 1; } /** * Sets up the ColliderQuad using the values in src. Uses the default OC2_TYPE_1 */ -s32 Collider_SetQuadType1(GlobalContext* globalCtx, ColliderQuad* collider, Actor* actor, ColliderQuadInitType1* src) { - Collider_SetBaseType1(globalCtx, &collider->base, actor, &src->base); - Collider_SetInfo(globalCtx, &collider->info, &src->info); - Collider_SetQuadDim(globalCtx, &collider->dim, &src->dim); +s32 Collider_SetQuadType1(PlayState* play, ColliderQuad* collider, Actor* actor, ColliderQuadInitType1* src) { + Collider_SetBaseType1(play, &collider->base, actor, &src->base); + Collider_SetInfo(play, &collider->info, &src->info); + Collider_SetQuadDim(play, &collider->dim, &src->dim); return 1; } /** * Sets up the ColliderQuad using the values in src. */ -s32 Collider_SetQuad(GlobalContext* globalCtx, ColliderQuad* collider, Actor* actor, ColliderQuadInit* src) { - Collider_SetBase(globalCtx, &collider->base, actor, &src->base); - Collider_SetInfo(globalCtx, &collider->info, &src->info); - Collider_SetQuadDim(globalCtx, &collider->dim, &src->dim); +s32 Collider_SetQuad(PlayState* play, ColliderQuad* collider, Actor* actor, ColliderQuadInit* src) { + Collider_SetBase(play, &collider->base, actor, &src->base); + Collider_SetInfo(play, &collider->info, &src->info); + Collider_SetQuadDim(play, &collider->dim, &src->dim); return 1; } /** * Fully initializes a ColliderQuad using the values in src. */ -s32 Collider_InitAndSetQuad(GlobalContext* globalCtx, ColliderQuad* collider, Actor* actor, ColliderQuadInit* src) { - Collider_InitQuad(globalCtx, collider); - Collider_SetQuad(globalCtx, collider, actor, src); +s32 Collider_InitAndSetQuad(PlayState* play, ColliderQuad* collider, Actor* actor, ColliderQuadInit* src) { + Collider_InitQuad(play, collider); + Collider_SetQuad(play, collider, actor, src); return 0; } /** * Resets the collider's AT collision flags. */ -s32 Collider_ResetQuadAT(GlobalContext* globalCtx, Collider* collider) { +s32 Collider_ResetQuadAT(PlayState* play, Collider* collider) { ColliderQuad* quad = (ColliderQuad*)collider; - Collider_ResetATBase(globalCtx, &quad->base); - Collider_ResetATInfo(globalCtx, &quad->info); - Collider_ResetQuadACDist(globalCtx, &quad->dim); + Collider_ResetATBase(play, &quad->base); + Collider_ResetATInfo(play, &quad->info); + Collider_ResetQuadACDist(play, &quad->dim); return 1; } /** * Resets the collider's AC collision flags. */ -s32 Collider_ResetQuadAC(GlobalContext* globalCtx, Collider* collider) { +s32 Collider_ResetQuadAC(PlayState* play, Collider* collider) { ColliderQuad* quad = (ColliderQuad*)collider; - Collider_ResetACBase(globalCtx, &quad->base); - Collider_ResetACInfo(globalCtx, &quad->info); + Collider_ResetACBase(play, &quad->base); + Collider_ResetACInfo(play, &quad->info); return 1; } /** * Resets the collider's OC collision flags. */ -s32 Collider_ResetQuadOC(GlobalContext* globalCtx, Collider* collider) { +s32 Collider_ResetQuadOC(PlayState* play, Collider* collider) { ColliderQuad* quad = (ColliderQuad*)collider; - Collider_ResetOCBase(globalCtx, &quad->base); - Collider_ResetOCInfo(globalCtx, &quad->info); + Collider_ResetOCBase(play, &quad->base); + Collider_ResetOCInfo(play, &quad->info); return 1; } @@ -934,7 +929,7 @@ s32 Collider_ResetQuadOC(GlobalContext* globalCtx, Collider* collider) { * For quad colliders with TOUCH_NEAREST, resets the previous AC collider it hit if the current element is closer, * otherwise returns false. Used on player AT colliders to prevent multiple collisions from registering. */ -s32 Collider_QuadSetNearestAC(GlobalContext* globalCtx, ColliderQuad* quad, Vec3f* hitPos) { +s32 Collider_QuadSetNearestAC(PlayState* play, ColliderQuad* quad, Vec3f* hitPos) { f32 acDist; Vec3f dcMid; @@ -948,10 +943,10 @@ s32 Collider_QuadSetNearestAC(GlobalContext* globalCtx, ColliderQuad* quad, Vec3 quad->dim.acDist = acDist; if (quad->info.atHit != NULL) { - Collider_ResetACBase(globalCtx, quad->info.atHit); + Collider_ResetACBase(play, quad->info.atHit); } if (quad->info.atHitInfo != NULL) { - Collider_ResetACInfo(globalCtx, quad->info.atHitInfo); + Collider_ResetACInfo(play, quad->info.atHitInfo); } return 1; } else { @@ -962,80 +957,79 @@ s32 Collider_QuadSetNearestAC(GlobalContext* globalCtx, ColliderQuad* quad, Vec3 /** * Initializes a ColliderSphere to default values. */ -s32 Collider_InitSphere(GlobalContext* globalCtx, ColliderSphere* collider) { - Collider_InitBase(globalCtx, &collider->base); - Collider_InitInfo(globalCtx, &collider->info); - Collider_InitJntSphElementDim(globalCtx, &collider->dim); +s32 Collider_InitSphere(PlayState* play, ColliderSphere* collider) { + Collider_InitBase(play, &collider->base); + Collider_InitInfo(play, &collider->info); + Collider_InitJntSphElementDim(play, &collider->dim); return 1; } /** * Destroys a ColliderSphere. */ -s32 Collider_DestroySphere(GlobalContext* globalCtx, ColliderSphere* collider) { - Collider_DestroyBase(globalCtx, &collider->base); - Collider_DestroyInfo(globalCtx, &collider->info); - Collider_DestroyJntSphElementDim(globalCtx, &collider->dim); +s32 Collider_DestroySphere(PlayState* play, ColliderSphere* collider) { + Collider_DestroyBase(play, &collider->base); + Collider_DestroyInfo(play, &collider->info); + Collider_DestroyJntSphElementDim(play, &collider->dim); return 1; } /** * Sets up the ColliderSphere using the values in src. */ -s32 Collider_SetSphere(GlobalContext* globalCtx, ColliderSphere* collider, Actor* actor, ColliderSphereInit* src) { - Collider_SetBase(globalCtx, &collider->base, actor, &src->base); - Collider_SetInfo(globalCtx, &collider->info, &src->info); - Collider_SetJntSphElementDim(globalCtx, &collider->dim, &src->dim); +s32 Collider_SetSphere(PlayState* play, ColliderSphere* collider, Actor* actor, ColliderSphereInit* src) { + Collider_SetBase(play, &collider->base, actor, &src->base); + Collider_SetInfo(play, &collider->info, &src->info); + Collider_SetJntSphElementDim(play, &collider->dim, &src->dim); return 1; } /** * Fully initializes a ColliderSphere using the values in src. */ -s32 Collider_InitAndSetSphere(GlobalContext* globalCtx, ColliderSphere* collider, Actor* actor, - ColliderSphereInit* src) { - Collider_InitSphere(globalCtx, collider); - Collider_SetSphere(globalCtx, collider, actor, src); +s32 Collider_InitAndSetSphere(PlayState* play, ColliderSphere* collider, Actor* actor, ColliderSphereInit* src) { + Collider_InitSphere(play, collider); + Collider_SetSphere(play, collider, actor, src); return 0; } /** * Resets the collider's AT collision flags. */ -s32 Collider_ResetSphereAT(GlobalContext* globalCtx, Collider* collider) { +s32 Collider_ResetSphereAT(PlayState* play, Collider* collider) { ColliderSphere* sphere = (ColliderSphere*)collider; - Collider_ResetATBase(globalCtx, &sphere->base); - Collider_ResetATInfo(globalCtx, &sphere->info); + Collider_ResetATBase(play, &sphere->base); + Collider_ResetATInfo(play, &sphere->info); return 1; } /** * Resets the collider's AC collision flags. */ -s32 Collider_ResetSphereAC(GlobalContext* globalCtx, Collider* collider) { +s32 Collider_ResetSphereAC(PlayState* play, Collider* collider) { ColliderSphere* sphere = (ColliderSphere*)collider; - Collider_ResetACBase(globalCtx, &sphere->base); - Collider_ResetACInfo(globalCtx, &sphere->info); + Collider_ResetACBase(play, &sphere->base); + Collider_ResetACInfo(play, &sphere->info); return 1; } /** * Resets the collider's OC collision flags. */ -s32 Collider_ResetSphereOC(GlobalContext* globalCtx, Collider* collider) { +s32 Collider_ResetSphereOC(PlayState* play, Collider* collider) { ColliderSphere* sphere = (ColliderSphere*)collider; - Collider_ResetOCBase(globalCtx, &sphere->base); - Collider_ResetOCInfo(globalCtx, &sphere->info); + Collider_ResetOCBase(play, &sphere->base); + Collider_ResetOCInfo(play, &sphere->info); return 1; } /** * Initializes an OcLine to default values */ -s32 Collider_InitLine(GlobalContext* globalCtx, OcLine* line) { +s32 Collider_InitLine(PlayState* play, OcLine* line) { static Vec3f defaultLinePoint = { 0.0f, 0.0f, 0.0f }; Math_Vec3f_Copy(&line->line.a, &defaultLinePoint); @@ -1046,14 +1040,14 @@ s32 Collider_InitLine(GlobalContext* globalCtx, OcLine* line) { /** * Destroys an OcLine */ -s32 Collider_DestroyLine(GlobalContext* globalCtx, OcLine* line) { +s32 Collider_DestroyLine(PlayState* play, OcLine* line) { return 1; } /** * Sets up an OcLine with endpoints a and b. */ -s32 Collider_SetLinePoints(GlobalContext* globalCtx, OcLine* line, Vec3f* a, Vec3f* b) { +s32 Collider_SetLinePoints(PlayState* play, OcLine* line, Vec3f* a, Vec3f* b) { Math_Vec3f_Copy(&line->line.a, a); Math_Vec3f_Copy(&line->line.b, b); return 1; @@ -1062,16 +1056,16 @@ s32 Collider_SetLinePoints(GlobalContext* globalCtx, OcLine* line, Vec3f* a, Vec /** * Sets up an OcLine using the values in src. */ -s32 Collider_SetLine(GlobalContext* globalCtx, OcLine* line, OcLine* src) { +s32 Collider_SetLine(PlayState* play, OcLine* line, OcLine* src) { line->ocFlags = src->ocFlags; - Collider_SetLinePoints(globalCtx, line, &src->line.a, &src->line.b); + Collider_SetLinePoints(play, line, &src->line.a, &src->line.b); return 1; } /** * Resets the OcLine's collision flags. */ -s32 Collider_ResetLineOC(GlobalContext* globalCtx, OcLine* line) { +s32 Collider_ResetLineOC(PlayState* play, OcLine* line) { line->ocFlags &= ~OCLINE_HIT; return 1; } @@ -1080,18 +1074,18 @@ s32 Collider_ResetLineOC(GlobalContext* globalCtx, OcLine* line) { * Initializes CollisionCheckContext. * Clears all collider arrays, disables SAC, and sets flags for drawing colliders. */ -void CollisionCheck_InitContext(GlobalContext* globalCtx, CollisionCheckContext* colCtxt) { +void CollisionCheck_InitContext(PlayState* play, CollisionCheckContext* colCtxt) { colCtxt->sacFlags = 0; - CollisionCheck_ClearContext(globalCtx, colCtxt); + CollisionCheck_ClearContext(play, colCtxt); } -void CollisionCheck_DestroyContext(GlobalContext* globalCtx, CollisionCheckContext* colCtxt) { +void CollisionCheck_DestroyContext(PlayState* play, CollisionCheckContext* colCtxt) { } /** * Clears all collider lists in CollisionCheckContext when not in SAC mode. */ -void CollisionCheck_ClearContext(GlobalContext* globalCtx, CollisionCheckContext* colCtxt) { +void CollisionCheck_ClearContext(PlayState* play, CollisionCheckContext* colCtxt) { Collider** col; OcLine** line; @@ -1124,14 +1118,14 @@ void CollisionCheck_ClearContext(GlobalContext* globalCtx, CollisionCheckContext /** * Enables SAC, an alternate collision check mode that allows direct management of collider lists. */ -void CollisionCheck_EnableSAC(GlobalContext* globalCtx, CollisionCheckContext* colCtxt) { +void CollisionCheck_EnableSAC(PlayState* play, CollisionCheckContext* colCtxt) { colCtxt->sacFlags |= SAC_ON; } /** * Disables SAC, an alternate collision check mode that allows direct management of collider lists. */ -void CollisionCheck_DisableSAC(GlobalContext* globalCtx, CollisionCheckContext* colCtxt) { +void CollisionCheck_DisableSAC(PlayState* play, CollisionCheckContext* colCtxt) { colCtxt->sacFlags &= ~SAC_ON; } @@ -1143,13 +1137,13 @@ ColChkResetFunc sATResetFuncs[] = { /** * Sets collider as an AT (attack) for the current frame, which will be checked against ACs (attack colliders) */ -s32 CollisionCheck_SetAT(GlobalContext* globalCtx, CollisionCheckContext* colCtxt, Collider* collider) { +s32 CollisionCheck_SetAT(PlayState* play, CollisionCheckContext* colCtxt, Collider* collider) { s32 index; - if (FrameAdvance_IsEnabled(&globalCtx->state)) { + if (FrameAdvance_IsEnabled(&play->state)) { return -1; } - sATResetFuncs[collider->shape](globalCtx, collider); + sATResetFuncs[collider->shape](play, collider); if (collider->actor != NULL && collider->actor->update == NULL) { return -1; @@ -1171,11 +1165,11 @@ s32 CollisionCheck_SetAT(GlobalContext* globalCtx, CollisionCheckContext* colCtx * If CollisionCheck_SAC is enabled, the collider will be inserted into the list at the specified index, otherwise it * will be inserted into the next slot. */ -s32 CollisionCheck_SetAT_SAC(GlobalContext* globalCtx, CollisionCheckContext* colCtxt, Collider* collider, s32 index) { - if (FrameAdvance_IsEnabled(&globalCtx->state)) { +s32 CollisionCheck_SetAT_SAC(PlayState* play, CollisionCheckContext* colCtxt, Collider* collider, s32 index) { + if (FrameAdvance_IsEnabled(&play->state)) { return -1; } - sATResetFuncs[collider->shape](globalCtx, collider); + sATResetFuncs[collider->shape](play, collider); if (collider->actor != NULL && collider->actor->update == NULL) { return -1; @@ -1203,13 +1197,13 @@ ColChkResetFunc sACResetFuncs[] = { /** * Sets collider as an AC (attack collider) for the current frame, allowing it to detect ATs (attacks) */ -s32 CollisionCheck_SetAC(GlobalContext* globalCtx, CollisionCheckContext* colCtxt, Collider* collider) { +s32 CollisionCheck_SetAC(PlayState* play, CollisionCheckContext* colCtxt, Collider* collider) { s32 index; - if (FrameAdvance_IsEnabled(&globalCtx->state)) { + if (FrameAdvance_IsEnabled(&play->state)) { return -1; } - sACResetFuncs[collider->shape](globalCtx, collider); + sACResetFuncs[collider->shape](play, collider); if (collider->actor != NULL && collider->actor->update == NULL) { return -1; @@ -1231,11 +1225,11 @@ s32 CollisionCheck_SetAC(GlobalContext* globalCtx, CollisionCheckContext* colCtx * If CollisionCheck_SAC is enabled, the collider will be inserted into the list at the specified index, otherwise it * will be inserted into the next slot */ -s32 CollisionCheck_SetAC_SAC(GlobalContext* globalCtx, CollisionCheckContext* colCtxt, Collider* collider, s32 index) { - if (FrameAdvance_IsEnabled(&globalCtx->state)) { +s32 CollisionCheck_SetAC_SAC(PlayState* play, CollisionCheckContext* colCtxt, Collider* collider, s32 index) { + if (FrameAdvance_IsEnabled(&play->state)) { return -1; } - sACResetFuncs[collider->shape](globalCtx, collider); + sACResetFuncs[collider->shape](play, collider); if (collider->actor != NULL && collider->actor->update == NULL) { return -1; @@ -1263,13 +1257,13 @@ ColChkResetFunc sOCResetFuncs[] = { /** * Sets collider as an OC (object collider) for the current frame, allowing it to detect other OCs. */ -s32 CollisionCheck_SetOC(GlobalContext* globalCtx, CollisionCheckContext* colCtxt, Collider* collider) { +s32 CollisionCheck_SetOC(PlayState* play, CollisionCheckContext* colCtxt, Collider* collider) { s32 index; - if (FrameAdvance_IsEnabled(&globalCtx->state)) { + if (FrameAdvance_IsEnabled(&play->state)) { return -1; } - sOCResetFuncs[collider->shape](globalCtx, collider); + sOCResetFuncs[collider->shape](play, collider); if (collider->actor != NULL && collider->actor->update == NULL) { return -1; @@ -1291,11 +1285,11 @@ s32 CollisionCheck_SetOC(GlobalContext* globalCtx, CollisionCheckContext* colCtx * If CollisionCheck_SAC is enabled, the collider will be inserted into the list at the specified index, otherwise it * will be inserted into the next slot. */ -s32 CollisionCheck_SetOC_SAC(GlobalContext* globalCtx, CollisionCheckContext* colCtxt, Collider* collider, s32 index) { - if (FrameAdvance_IsEnabled(&globalCtx->state)) { +s32 CollisionCheck_SetOC_SAC(PlayState* play, CollisionCheckContext* colCtxt, Collider* collider, s32 index) { + if (FrameAdvance_IsEnabled(&play->state)) { return -1; } - sOCResetFuncs[collider->shape](globalCtx, collider); + sOCResetFuncs[collider->shape](play, collider); if (collider->actor != NULL && collider->actor->update == NULL) { return -1; @@ -1321,14 +1315,14 @@ s32 CollisionCheck_SetOC_SAC(GlobalContext* globalCtx, CollisionCheckContext* co /** * Sets a line as an OC collider for this frame. */ -s32 CollisionCheck_SetOCLine(GlobalContext* globalCtx, CollisionCheckContext* colCtxt, OcLine* line) { +s32 CollisionCheck_SetOCLine(PlayState* play, CollisionCheckContext* colCtxt, OcLine* line) { s32 index; - if (FrameAdvance_IsEnabled(&globalCtx->state)) { + if (FrameAdvance_IsEnabled(&play->state)) { return -1; } - Collider_ResetLineOC(globalCtx, line); + Collider_ResetLineOC(play, line); if (colCtxt->colLineCount >= ARRAY_COUNT(colCtxt->colLine)) { return -1; @@ -1373,7 +1367,7 @@ s32 CollisionCheck_NoSharedFlags(ColliderInfo* toucher, ColliderInfo* bumper) { * Spawns no blood drops. * Used by collider types HIT1, HIT3, HIT5, METAL, NONE, WOOD, HARD, and TREE */ -void CollisionCheck_NoBlood(GlobalContext* globalCtx, Collider* collider, Vec3f* v) { +void CollisionCheck_NoBlood(PlayState* play, Collider* collider, Vec3f* v) { } /** @@ -1382,7 +1376,7 @@ void CollisionCheck_NoBlood(GlobalContext* globalCtx, Collider* collider, Vec3f* */ #ifdef NON_MATCHING // needs in-function static bss -void CollisionCheck_BlueBlood(GlobalContext* globalCtx, Collider* collider, Vec3f* v) { +void CollisionCheck_BlueBlood(PlayState* play, Collider* collider, Vec3f* v) { static EffectSparkInit D_801EEC00; s32 effectIndex; @@ -1428,7 +1422,7 @@ void CollisionCheck_BlueBlood(GlobalContext* globalCtx, Collider* collider, Vec3 D_801EEC00.speed = 8.0f; D_801EEC00.gravity = -1.0f; - Effect_Add(globalCtx, &effectIndex, EFFECT_SPARK, 0, 1, &D_801EEC00); + Effect_Add(play, &effectIndex, EFFECT_SPARK, 0, 1, &D_801EEC00); } #else #pragma GLOBAL_ASM("asm/non_matchings/code/z_collision_check/CollisionCheck_BlueBlood.s") @@ -1440,7 +1434,7 @@ void CollisionCheck_BlueBlood(GlobalContext* globalCtx, Collider* collider, Vec3 */ #ifdef NON_MATCHING // needs in-function static bss -void CollisionCheck_GreenBlood(GlobalContext* globalCtx, Collider* collider, Vec3f* v) { +void CollisionCheck_GreenBlood(PlayState* play, Collider* collider, Vec3f* v) { static EffectSparkInit D_801EF0C8; s32 effectIndex; @@ -1485,7 +1479,7 @@ void CollisionCheck_GreenBlood(GlobalContext* globalCtx, Collider* collider, Vec D_801EF0C8.duration = 16; D_801EF0C8.speed = 8.0f; D_801EF0C8.gravity = -1.0f; - Effect_Add(globalCtx, &effectIndex, EFFECT_SPARK, 0, 1, &D_801EF0C8); + Effect_Add(play, &effectIndex, EFFECT_SPARK, 0, 1, &D_801EF0C8); } #else #pragma GLOBAL_ASM("asm/non_matchings/code/z_collision_check/CollisionCheck_GreenBlood.s") @@ -1495,55 +1489,55 @@ void CollisionCheck_GreenBlood(GlobalContext* globalCtx, Collider* collider, Vec * Spawns a burst of water. * Used by collider type HIT4. */ -void CollisionCheck_WaterBurst(GlobalContext* globalCtx, Collider* collider, Vec3f* v) { - EffectSsSibuki_SpawnBurst(globalCtx, v); - CollisionCheck_SpawnWaterDroplets(globalCtx, v); +void CollisionCheck_WaterBurst(PlayState* play, Collider* collider, Vec3f* v) { + EffectSsSibuki_SpawnBurst(play, v); + CollisionCheck_SpawnWaterDroplets(play, v); } /** * Spawns red blood drops. * Used by collider type HIT7. */ -void CollisionCheck_RedBlood(GlobalContext* globalCtx, Collider* collider, Vec3f* v) { - CollisionCheck_SpawnRedBlood(globalCtx, v); +void CollisionCheck_RedBlood(PlayState* play, Collider* collider, Vec3f* v) { + CollisionCheck_SpawnRedBlood(play, v); } /** * Spawns red blood drops. */ -void CollisionCheck_RedBloodUnused(GlobalContext* globalCtx, Collider* collider, Vec3f* v) { - CollisionCheck_SpawnRedBlood(globalCtx, v); +void CollisionCheck_RedBloodUnused(PlayState* play, Collider* collider, Vec3f* v) { + CollisionCheck_SpawnRedBlood(play, v); } /** * Plays sound effects and displays hitmarks for solid-type AC colliders (METAL, WOOD, HARD, and TREE) */ -void CollisionCheck_HitSolid(GlobalContext* globalCtx, ColliderInfo* info, Collider* collider, Vec3f* hitPos) { +void CollisionCheck_HitSolid(PlayState* play, ColliderInfo* info, Collider* collider, Vec3f* hitPos) { s32 flags = info->toucherFlags & TOUCH_SFX_NONE; if (flags == TOUCH_SFX_NORMAL && collider->colType != COLTYPE_METAL) { - EffectSsHitMark_SpawnFixedScale(globalCtx, 0, hitPos); + EffectSsHitmark_SpawnFixedScale(play, 0, hitPos); if (collider->actor == NULL) { play_sound(NA_SE_IT_SHIELD_BOUND); } else { Audio_PlaySfxAtPos(&collider->actor->projectedPos, NA_SE_IT_SHIELD_BOUND); } } else if (flags == TOUCH_SFX_NORMAL) { - EffectSsHitMark_SpawnFixedScale(globalCtx, 3, hitPos); + EffectSsHitmark_SpawnFixedScale(play, 3, hitPos); if (collider->actor == NULL) { - CollisionCheck_SpawnShieldParticlesMetal(globalCtx, hitPos); + CollisionCheck_SpawnShieldParticlesMetal(play, hitPos); } else { - CollisionCheck_SpawnShieldParticlesMetalSound(globalCtx, hitPos, &collider->actor->projectedPos); + CollisionCheck_SpawnShieldParticlesMetalSound(play, hitPos, &collider->actor->projectedPos); } } else if (flags == TOUCH_SFX_HARD) { - EffectSsHitMark_SpawnFixedScale(globalCtx, 0, hitPos); + EffectSsHitmark_SpawnFixedScale(play, 0, hitPos); if (collider->actor == NULL) { play_sound(NA_SE_IT_SHIELD_BOUND); } else { Audio_PlaySfxAtPos(&collider->actor->projectedPos, NA_SE_IT_SHIELD_BOUND); } } else if (flags == TOUCH_SFX_WOOD) { - EffectSsHitMark_SpawnFixedScale(globalCtx, 1, hitPos); + EffectSsHitmark_SpawnFixedScale(play, 1, hitPos); if (collider->actor == NULL) { play_sound(NA_SE_IT_REFLECTION_WOOD); } else { @@ -1585,8 +1579,8 @@ HitInfo sHitInfo[] = { /** * Handles hitmarks, blood, and sound effects for each AC collision, determined by the AC collider's colType */ -void CollisionCheck_HitEffects(GlobalContext* globalCtx, Collider* at, ColliderInfo* atInfo, Collider* ac, - ColliderInfo* acInfo, Vec3f* hitPos) { +void CollisionCheck_HitEffects(PlayState* play, Collider* at, ColliderInfo* atInfo, Collider* ac, ColliderInfo* acInfo, + Vec3f* hitPos) { if (acInfo->bumperFlags & BUMP_NO_HITMARK) { return; } @@ -1596,26 +1590,26 @@ void CollisionCheck_HitEffects(GlobalContext* globalCtx, Collider* at, ColliderI } if (ac->actor != NULL) { - sBloodFuncs[sHitInfo[ac->colType].blood](globalCtx, ac, hitPos); + sBloodFuncs[sHitInfo[ac->colType].blood](play, ac, hitPos); } if (ac->actor != NULL) { if (sHitInfo[ac->colType].effect == HIT_SOLID) { - CollisionCheck_HitSolid(globalCtx, atInfo, ac, hitPos); + CollisionCheck_HitSolid(play, atInfo, ac, hitPos); } else if (sHitInfo[ac->colType].effect == HIT_WOOD) { if (at->actor == NULL) { - CollisionCheck_SpawnShieldParticles(globalCtx, hitPos); + CollisionCheck_SpawnShieldParticles(play, hitPos); play_sound(NA_SE_IT_REFLECTION_WOOD); } else { - CollisionCheck_SpawnShieldParticlesWood(globalCtx, hitPos, &at->actor->projectedPos); + CollisionCheck_SpawnShieldParticlesWood(play, hitPos, &at->actor->projectedPos); } } else if (sHitInfo[ac->colType].effect != HIT_NONE) { - EffectSsHitMark_SpawnFixedScale(globalCtx, sHitInfo[ac->colType].effect, hitPos); + EffectSsHitmark_SpawnFixedScale(play, sHitInfo[ac->colType].effect, hitPos); if (!(acInfo->bumperFlags & BUMP_NO_SWORD_SFX)) { CollisionCheck_SwordHitAudio(at, acInfo); } } } else { - EffectSsHitMark_SpawnFixedScale(globalCtx, 0, hitPos); + EffectSsHitmark_SpawnFixedScale(play, 0, hitPos); if (ac->actor == NULL) { play_sound(NA_SE_IT_SHIELD_BOUND); } else { @@ -1635,7 +1629,7 @@ void CollisionCheck_SetBounce(Collider* at, Collider* ac) { /** * Performs the AC collision between the AT element and AC element that collided. */ -s32 CollisionCheck_SetATvsAC(GlobalContext* globalCtx, Collider* at, ColliderInfo* atInfo, Vec3f* atPos, Collider* ac, +s32 CollisionCheck_SetATvsAC(PlayState* play, Collider* at, ColliderInfo* atInfo, Vec3f* atPos, Collider* ac, ColliderInfo* acInfo, Vec3f* acPos, Vec3f* hitPos) { f32 damage; u32 effect; @@ -1685,7 +1679,7 @@ s32 CollisionCheck_SetATvsAC(GlobalContext* globalCtx, Collider* at, ColliderInf ac->colType != COLTYPE_HARD) { acInfo->bumperFlags |= BUMP_DRAW_HITMARK; } else { - CollisionCheck_HitEffects(globalCtx, at, atInfo, ac, acInfo, hitPos); + CollisionCheck_HitEffects(play, at, atInfo, ac, acInfo, hitPos); atInfo->toucherFlags |= TOUCH_DREW_HITMARK; } return 1; @@ -1708,7 +1702,7 @@ void CollisionCheck_QuadAvgPoint(ColliderQuad* quad, Vec3f* avg) { /** * AC overlap check. Calculates the center of each collider element and the point of contact. */ -void CollisionCheck_AC_JntSphVsJntSph(GlobalContext* globalCtx, CollisionCheckContext* colCtxt, Collider* colAT, +void CollisionCheck_AC_JntSphVsJntSph(PlayState* play, CollisionCheckContext* colCtxt, Collider* colAT, Collider* colAC) { ColliderJntSph* at = (ColliderJntSph*)colAT; ColliderJntSphElement* atElem; @@ -1749,8 +1743,8 @@ void CollisionCheck_AC_JntSphVsJntSph(GlobalContext* globalCtx, CollisionCheckCo } else { Math_Vec3f_Copy(&hitPos, &atPos); } - CollisionCheck_SetATvsAC(globalCtx, &at->base, &atElem->info, &atPos, &ac->base, &acElem->info, - &acPos, &hitPos); + CollisionCheck_SetATvsAC(play, &at->base, &atElem->info, &atPos, &ac->base, &acElem->info, &acPos, + &hitPos); if (!(ac->base.ocFlags2 & OC2_FIRST_ONLY)) { return; @@ -1764,8 +1758,7 @@ void CollisionCheck_AC_JntSphVsJntSph(GlobalContext* globalCtx, CollisionCheckCo /** * AC overlap check. Calculates the center of each collider element and the point of contact. */ -void CollisionCheck_AC_JntSphVsCyl(GlobalContext* globalCtx, CollisionCheckContext* colCtxt, Collider* colAT, - Collider* colAC) { +void CollisionCheck_AC_JntSphVsCyl(PlayState* play, CollisionCheckContext* colCtxt, Collider* colAT, Collider* colAC) { ColliderJntSph* at = (ColliderJntSph*)colAT; ColliderJntSphElement* atElem; ColliderCylinder* ac = (ColliderCylinder*)colAC; @@ -1804,8 +1797,7 @@ void CollisionCheck_AC_JntSphVsCyl(GlobalContext* globalCtx, CollisionCheckConte } else { Math_Vec3f_Copy(&hitPos, &atPos); } - CollisionCheck_SetATvsAC(globalCtx, &at->base, &atElem->info, &atPos, &ac->base, &ac->info, &acPos, - &hitPos); + CollisionCheck_SetATvsAC(play, &at->base, &atElem->info, &atPos, &ac->base, &ac->info, &acPos, &hitPos); return; } } @@ -1815,8 +1807,7 @@ void CollisionCheck_AC_JntSphVsCyl(GlobalContext* globalCtx, CollisionCheckConte /** * AC overlap check. Calculates the center of each collider element and the point of contact. */ -void CollisionCheck_AC_JntSphVsTris(GlobalContext* globalCtx, CollisionCheckContext* colCtxt, Collider* colAT, - Collider* colAC) { +void CollisionCheck_AC_JntSphVsTris(PlayState* play, CollisionCheckContext* colCtxt, Collider* colAT, Collider* colAC) { ColliderJntSph* at = (ColliderJntSph*)colAT; ColliderJntSphElement* atElem; ColliderTris* ac = (ColliderTris*)colAC; @@ -1841,8 +1832,8 @@ void CollisionCheck_AC_JntSphVsTris(GlobalContext* globalCtx, CollisionCheckCont Math_Vec3s_ToVec3f(&atPos, &atElem->dim.worldSphere.center); CollisionCheck_TrisAvgPoint(acElem, &acPos); - CollisionCheck_SetATvsAC(globalCtx, &at->base, &atElem->info, &atPos, &ac->base, &acElem->info, - &acPos, &hitPos); + CollisionCheck_SetATvsAC(play, &at->base, &atElem->info, &atPos, &ac->base, &acElem->info, &acPos, + &hitPos); return; } } @@ -1853,8 +1844,7 @@ void CollisionCheck_AC_JntSphVsTris(GlobalContext* globalCtx, CollisionCheckCont /** * AC overlap check. Calculates the center of each collider element and the point of contact. */ -void CollisionCheck_AC_JntSphVsQuad(GlobalContext* globalCtx, CollisionCheckContext* colCtxt, Collider* colAT, - Collider* colAC) { +void CollisionCheck_AC_JntSphVsQuad(PlayState* play, CollisionCheckContext* colCtxt, Collider* colAT, Collider* colAC) { ColliderJntSph* at = (ColliderJntSph*)colAT; ColliderQuad* ac = (ColliderQuad*)colAC; Vec3f hitPos; @@ -1881,7 +1871,7 @@ void CollisionCheck_AC_JntSphVsQuad(GlobalContext* globalCtx, CollisionCheckCont Math_Vec3s_ToVec3f(&atPos, &sphElem->dim.worldSphere.center); CollisionCheck_QuadAvgPoint(ac, &acPos); - CollisionCheck_SetATvsAC(globalCtx, &at->base, &sphElem->info, &atPos, &ac->base, &ac->info, &acPos, + CollisionCheck_SetATvsAC(play, &at->base, &sphElem->info, &atPos, &ac->base, &ac->info, &acPos, &hitPos); return; } @@ -1892,7 +1882,7 @@ void CollisionCheck_AC_JntSphVsQuad(GlobalContext* globalCtx, CollisionCheckCont /** * AC overlap check. Calculates the center of each collider element and the point of contact. */ -void CollisionCheck_AC_JntSphVsSphere(GlobalContext* globalCtx, CollisionCheckContext* colCtxt, Collider* colAT, +void CollisionCheck_AC_JntSphVsSphere(PlayState* play, CollisionCheckContext* colCtxt, Collider* colAT, Collider* colAC) { ColliderJntSph* at = (ColliderJntSph*)colAT; ColliderSphere* ac = (ColliderSphere*)colAC; @@ -1928,7 +1918,7 @@ void CollisionCheck_AC_JntSphVsSphere(GlobalContext* globalCtx, CollisionCheckCo } else { Math_Vec3f_Copy(&hitPos, &atPos); } - CollisionCheck_SetATvsAC(globalCtx, &at->base, &sphElem->info, &atPos, &ac->base, &ac->info, &acPos, + CollisionCheck_SetATvsAC(play, &at->base, &sphElem->info, &atPos, &ac->base, &ac->info, &acPos, &hitPos); } } @@ -1938,8 +1928,7 @@ void CollisionCheck_AC_JntSphVsSphere(GlobalContext* globalCtx, CollisionCheckCo /** * AC overlap check. Calculates the center of each collider element and the point of contact. */ -void CollisionCheck_AC_CylVsJntSph(GlobalContext* globalCtx, CollisionCheckContext* colCtxt, Collider* colAT, - Collider* colAC) { +void CollisionCheck_AC_CylVsJntSph(PlayState* play, CollisionCheckContext* colCtxt, Collider* colAT, Collider* colAC) { ColliderCylinder* at = (ColliderCylinder*)colAT; ColliderJntSph* ac = (ColliderJntSph*)colAC; f32 overlapSize; @@ -1978,7 +1967,7 @@ void CollisionCheck_AC_CylVsJntSph(GlobalContext* globalCtx, CollisionCheckConte } else { Math_Vec3f_Copy(&hitPos, &atPos); } - CollisionCheck_SetATvsAC(globalCtx, &at->base, &at->info, &atPos, &ac->base, &sphElem->info, &acPos, + CollisionCheck_SetATvsAC(play, &at->base, &at->info, &atPos, &ac->base, &sphElem->info, &acPos, &hitPos); if (!(ac->base.ocFlags2 & OC2_FIRST_ONLY)) { break; @@ -1991,8 +1980,7 @@ void CollisionCheck_AC_CylVsJntSph(GlobalContext* globalCtx, CollisionCheckConte /** * AC overlap check. Calculates the center of each collider element and the point of contact. */ -void CollisionCheck_AC_CylVsCyl(GlobalContext* globalCtx, CollisionCheckContext* colCtxt, Collider* colAT, - Collider* colAC) { +void CollisionCheck_AC_CylVsCyl(PlayState* play, CollisionCheckContext* colCtxt, Collider* colAT, Collider* colAC) { ColliderCylinder* at = (ColliderCylinder*)colAT; ColliderCylinder* ac = (ColliderCylinder*)colAC; f32 overlapSize; @@ -2036,7 +2024,7 @@ void CollisionCheck_AC_CylVsCyl(GlobalContext* globalCtx, CollisionCheckContext* } else { Math_Vec3s_ToVec3f(&hitPos, &ac->dim.pos); } - CollisionCheck_SetATvsAC(globalCtx, &at->base, &at->info, &atPos, &ac->base, &ac->info, &acPos, &hitPos); + CollisionCheck_SetATvsAC(play, &at->base, &at->info, &atPos, &ac->base, &ac->info, &acPos, &hitPos); } } } @@ -2044,8 +2032,7 @@ void CollisionCheck_AC_CylVsCyl(GlobalContext* globalCtx, CollisionCheckContext* /** * AC overlap check. Calculates the center of each collider element and the point of contact. */ -void CollisionCheck_AC_CylVsTris(GlobalContext* globalCtx, CollisionCheckContext* colCtxt, Collider* colAT, - Collider* colAC) { +void CollisionCheck_AC_CylVsTris(PlayState* play, CollisionCheckContext* colCtxt, Collider* colAT, Collider* colAC) { ColliderCylinder* at = (ColliderCylinder*)colAT; ColliderTris* ac = (ColliderTris*)colAC; ColliderTrisElement* acElem; @@ -2070,8 +2057,7 @@ void CollisionCheck_AC_CylVsTris(GlobalContext* globalCtx, CollisionCheckContext Math_Vec3s_ToVec3f(&atPos, &at->dim.pos); CollisionCheck_TrisAvgPoint(acElem, &acPos); - CollisionCheck_SetATvsAC(globalCtx, &at->base, &at->info, &atPos, &ac->base, &acElem->info, &acPos, - &hitPos); + CollisionCheck_SetATvsAC(play, &at->base, &at->info, &atPos, &ac->base, &acElem->info, &acPos, &hitPos); return; } } @@ -2081,8 +2067,7 @@ void CollisionCheck_AC_CylVsTris(GlobalContext* globalCtx, CollisionCheckContext /** * AC overlap check. Calculates the center of each collider element and the point of contact. */ -void CollisionCheck_AC_CylVsQuad(GlobalContext* globalCtx, CollisionCheckContext* colCtxt, Collider* colAT, - Collider* colAC) { +void CollisionCheck_AC_CylVsQuad(PlayState* play, CollisionCheckContext* colCtxt, Collider* colAT, Collider* colAC) { ColliderCylinder* at = (ColliderCylinder*)colAT; ColliderQuad* ac = (ColliderQuad*)colAC; @@ -2105,16 +2090,14 @@ void CollisionCheck_AC_CylVsQuad(GlobalContext* globalCtx, CollisionCheckContext Math_Vec3s_ToVec3f(&atPos, &at->dim.pos); CollisionCheck_QuadAvgPoint(ac, &acPos); - CollisionCheck_SetATvsAC(globalCtx, &at->base, &at->info, &atPos, &ac->base, &ac->info, &acPos, - &D_801EDE00); + CollisionCheck_SetATvsAC(play, &at->base, &at->info, &atPos, &ac->base, &ac->info, &acPos, &D_801EDE00); } else if (Math3D_ColCylinderTri(&at->dim, &D_801EF638, &D_801EDE00) != 0) { Vec3f atPos; Vec3f acPos; Math_Vec3s_ToVec3f(&atPos, &at->dim.pos); CollisionCheck_QuadAvgPoint(ac, &acPos); - CollisionCheck_SetATvsAC(globalCtx, &at->base, &at->info, &atPos, &ac->base, &ac->info, &acPos, - &D_801EDE00); + CollisionCheck_SetATvsAC(play, &at->base, &at->info, &atPos, &ac->base, &ac->info, &acPos, &D_801EDE00); } } } @@ -2122,8 +2105,7 @@ void CollisionCheck_AC_CylVsQuad(GlobalContext* globalCtx, CollisionCheckContext /** * AC overlap check. Calculates the center of each collider element and the point of contact. */ -void CollisionCheck_AC_CylVsSphere(GlobalContext* globalCtx, CollisionCheckContext* colCtxt, Collider* colAT, - Collider* colAC) { +void CollisionCheck_AC_CylVsSphere(PlayState* play, CollisionCheckContext* colCtxt, Collider* colAT, Collider* colAC) { ColliderCylinder* at = (ColliderCylinder*)colAT; ColliderSphere* ac = (ColliderSphere*)colAC; f32 overlapSize; @@ -2161,7 +2143,7 @@ void CollisionCheck_AC_CylVsSphere(GlobalContext* globalCtx, CollisionCheckConte } else { Math_Vec3f_Copy(&hitPos, &atPos); } - CollisionCheck_SetATvsAC(globalCtx, &at->base, &at->info, &atPos, &ac->base, &ac->info, &acPos, &hitPos); + CollisionCheck_SetATvsAC(play, &at->base, &at->info, &atPos, &ac->base, &ac->info, &acPos, &hitPos); } } } @@ -2169,8 +2151,7 @@ void CollisionCheck_AC_CylVsSphere(GlobalContext* globalCtx, CollisionCheckConte /** * AC overlap check. Calculates the center of each collider element and the point of contact. */ -void CollisionCheck_AC_TrisVsJntSph(GlobalContext* globalCtx, CollisionCheckContext* colCtxt, Collider* colAT, - Collider* colAC) { +void CollisionCheck_AC_TrisVsJntSph(PlayState* play, CollisionCheckContext* colCtxt, Collider* colAT, Collider* colAC) { ColliderTris* at = (ColliderTris*)colAT; ColliderJntSphElement* acElem; ColliderJntSph* ac = (ColliderJntSph*)colAC; @@ -2195,8 +2176,8 @@ void CollisionCheck_AC_TrisVsJntSph(GlobalContext* globalCtx, CollisionCheckCont Math_Vec3s_ToVec3f(&acPos, &acElem->dim.worldSphere.center); CollisionCheck_TrisAvgPoint(atElem, &atPos); - CollisionCheck_SetATvsAC(globalCtx, &at->base, &atElem->info, &atPos, &ac->base, &acElem->info, - &acPos, &hitPos); + CollisionCheck_SetATvsAC(play, &at->base, &atElem->info, &atPos, &ac->base, &acElem->info, &acPos, + &hitPos); if (!(ac->base.ocFlags2 & OC2_FIRST_ONLY)) { return; @@ -2210,8 +2191,7 @@ void CollisionCheck_AC_TrisVsJntSph(GlobalContext* globalCtx, CollisionCheckCont /** * AC overlap check. Calculates the center of each collider element and the point of contact. */ -void CollisionCheck_AC_TrisVsCyl(GlobalContext* globalCtx, CollisionCheckContext* colCtxt, Collider* colAT, - Collider* colAC) { +void CollisionCheck_AC_TrisVsCyl(PlayState* play, CollisionCheckContext* colCtxt, Collider* colAT, Collider* colAC) { ColliderTris* at = (ColliderTris*)colAT; ColliderCylinder* ac = (ColliderCylinder*)colAC; ColliderTrisElement* atElem; @@ -2233,7 +2213,7 @@ void CollisionCheck_AC_TrisVsCyl(GlobalContext* globalCtx, CollisionCheckContext CollisionCheck_TrisAvgPoint(atElem, &atPos); Math_Vec3s_ToVec3f(&acPos, &ac->dim.pos); - CollisionCheck_SetATvsAC(globalCtx, &at->base, &atElem->info, &atPos, &ac->base, &ac->info, &acPos, + CollisionCheck_SetATvsAC(play, &at->base, &atElem->info, &atPos, &ac->base, &ac->info, &acPos, &D_801EDE10); return; } @@ -2244,8 +2224,7 @@ void CollisionCheck_AC_TrisVsCyl(GlobalContext* globalCtx, CollisionCheckContext /** * AC overlap check. Calculates the center of each collider element and the point of contact. */ -void CollisionCheck_AC_TrisVsTris(GlobalContext* globalCtx, CollisionCheckContext* colCtxt, Collider* colAT, - Collider* colAC) { +void CollisionCheck_AC_TrisVsTris(PlayState* play, CollisionCheckContext* colCtxt, Collider* colAT, Collider* colAC) { ColliderTris* at = (ColliderTris*)colAT; ColliderTrisElement* atElem; ColliderTris* ac = (ColliderTris*)colAC; @@ -2269,8 +2248,8 @@ void CollisionCheck_AC_TrisVsTris(GlobalContext* globalCtx, CollisionCheckContex CollisionCheck_TrisAvgPoint(atElem, &atPos); CollisionCheck_TrisAvgPoint(acElem, &acPos); - CollisionCheck_SetATvsAC(globalCtx, &at->base, &atElem->info, &atPos, &ac->base, &acElem->info, - &acPos, &D_801EDE20); + CollisionCheck_SetATvsAC(play, &at->base, &atElem->info, &atPos, &ac->base, &acElem->info, &acPos, + &D_801EDE20); return; } } @@ -2281,8 +2260,7 @@ void CollisionCheck_AC_TrisVsTris(GlobalContext* globalCtx, CollisionCheckContex /** * AC overlap check. Calculates the center of each collider element and the point of contact. */ -void CollisionCheck_AC_TrisVsQuad(GlobalContext* globalCtx, CollisionCheckContext* colCtxt, Collider* colAT, - Collider* colAC) { +void CollisionCheck_AC_TrisVsQuad(PlayState* play, CollisionCheckContext* colCtxt, Collider* colAT, Collider* colAC) { ColliderTris* at = (ColliderTris*)colAT; ColliderQuad* ac = (ColliderQuad*)colAC; ColliderTrisElement* atElem; @@ -2309,7 +2287,7 @@ void CollisionCheck_AC_TrisVsQuad(GlobalContext* globalCtx, CollisionCheckContex CollisionCheck_TrisAvgPoint(atElem, &atPos); CollisionCheck_QuadAvgPoint(ac, &acPos); - CollisionCheck_SetATvsAC(globalCtx, &at->base, &atElem->info, &atPos, &ac->base, &ac->info, &acPos, + CollisionCheck_SetATvsAC(play, &at->base, &atElem->info, &atPos, &ac->base, &ac->info, &acPos, &D_801EDE30); return; } @@ -2320,8 +2298,7 @@ void CollisionCheck_AC_TrisVsQuad(GlobalContext* globalCtx, CollisionCheckContex /** * AC overlap check. Calculates the center of each collider element and the point of contact. */ -void CollisionCheck_AC_TrisVsSphere(GlobalContext* globalCtx, CollisionCheckContext* colCtxt, Collider* colAT, - Collider* colAC) { +void CollisionCheck_AC_TrisVsSphere(PlayState* play, CollisionCheckContext* colCtxt, Collider* colAT, Collider* colAC) { ColliderTris* at = (ColliderTris*)colAT; ColliderTrisElement* atElem; ColliderSphere* ac = (ColliderSphere*)colAC; @@ -2344,8 +2321,7 @@ void CollisionCheck_AC_TrisVsSphere(GlobalContext* globalCtx, CollisionCheckCont Math_Vec3s_ToVec3f(&acPos, &ac->dim.worldSphere.center); CollisionCheck_TrisAvgPoint(atElem, &atPos); - CollisionCheck_SetATvsAC(globalCtx, &at->base, &atElem->info, &atPos, &ac->base, &ac->info, &acPos, - &hitPos); + CollisionCheck_SetATvsAC(play, &at->base, &atElem->info, &atPos, &ac->base, &ac->info, &acPos, &hitPos); } } } @@ -2354,8 +2330,7 @@ void CollisionCheck_AC_TrisVsSphere(GlobalContext* globalCtx, CollisionCheckCont /** * AC overlap check. Calculates the center of each collider element and the point of contact. */ -void CollisionCheck_AC_QuadVsJntSph(GlobalContext* globalCtx, CollisionCheckContext* colCtxt, Collider* colAT, - Collider* colAC) { +void CollisionCheck_AC_QuadVsJntSph(PlayState* play, CollisionCheckContext* colCtxt, Collider* colAT, Collider* colAC) { ColliderJntSphElement* acElem; Vec3f hitPos; ColliderQuad* at = (ColliderQuad*)colAT; @@ -2380,13 +2355,12 @@ void CollisionCheck_AC_QuadVsJntSph(GlobalContext* globalCtx, CollisionCheckCont Vec3f atPos; Vec3f acPos; - if (!Collider_QuadSetNearestAC(globalCtx, at, &hitPos)) { + if (!Collider_QuadSetNearestAC(play, at, &hitPos)) { continue; } Math_Vec3s_ToVec3f(&acPos, &acElem->dim.worldSphere.center); CollisionCheck_QuadAvgPoint(at, &atPos); - CollisionCheck_SetATvsAC(globalCtx, &at->base, &at->info, &atPos, &ac->base, &acElem->info, &acPos, - &hitPos); + CollisionCheck_SetATvsAC(play, &at->base, &at->info, &atPos, &ac->base, &acElem->info, &acPos, &hitPos); if (!(ac->base.ocFlags2 & OC2_FIRST_ONLY)) { break; @@ -2399,8 +2373,7 @@ void CollisionCheck_AC_QuadVsJntSph(GlobalContext* globalCtx, CollisionCheckCont /** * AC overlap check. Calculates the center of each collider element and the point of contact. */ -void CollisionCheck_AC_QuadVsCyl(GlobalContext* globalCtx, CollisionCheckContext* colCtxt, Collider* colAT, - Collider* colAC) { +void CollisionCheck_AC_QuadVsCyl(PlayState* play, CollisionCheckContext* colCtxt, Collider* colAT, Collider* colAC) { ColliderQuad* at = (ColliderQuad*)colAT; ColliderCylinder* ac = (ColliderCylinder*)colAC; @@ -2419,26 +2392,24 @@ void CollisionCheck_AC_QuadVsCyl(GlobalContext* globalCtx, CollisionCheckContext Math3D_TriSetCoords(&D_801EDF90, &at->dim.quad[2], &at->dim.quad[1], &at->dim.quad[0]); if (Math3D_ColCylinderTri(&ac->dim, &D_801EDF58, &D_801EDFE0) != 0) { - if (Collider_QuadSetNearestAC(globalCtx, at, &D_801EDFE0)) { + if (Collider_QuadSetNearestAC(play, at, &D_801EDFE0)) { Vec3f atPos; Vec3f acPos; CollisionCheck_QuadAvgPoint(at, &atPos); Math_Vec3s_ToVec3f(&acPos, &ac->dim.pos); - CollisionCheck_SetATvsAC(globalCtx, &at->base, &at->info, &atPos, &ac->base, &ac->info, &acPos, - &D_801EDFE0); + CollisionCheck_SetATvsAC(play, &at->base, &at->info, &atPos, &ac->base, &ac->info, &acPos, &D_801EDFE0); return; } } if (Math3D_ColCylinderTri(&ac->dim, &D_801EDF90, &D_801EDFE0) != 0) { - if (Collider_QuadSetNearestAC(globalCtx, at, &D_801EDFE0)) { + if (Collider_QuadSetNearestAC(play, at, &D_801EDFE0)) { Vec3f atPos; Vec3f acPos; CollisionCheck_QuadAvgPoint(at, &atPos); Math_Vec3s_ToVec3f(&acPos, &ac->dim.pos); - CollisionCheck_SetATvsAC(globalCtx, &at->base, &at->info, &atPos, &ac->base, &ac->info, &acPos, - &D_801EDFE0); + CollisionCheck_SetATvsAC(play, &at->base, &at->info, &atPos, &ac->base, &ac->info, &acPos, &D_801EDFE0); } } } @@ -2447,8 +2418,7 @@ void CollisionCheck_AC_QuadVsCyl(GlobalContext* globalCtx, CollisionCheckContext /** * AC overlap check. Calculates the center of each collider element and the point of contact. */ -void CollisionCheck_AC_QuadVsTris(GlobalContext* globalCtx, CollisionCheckContext* colCtxt, Collider* colAT, - Collider* colAC) { +void CollisionCheck_AC_QuadVsTris(PlayState* play, CollisionCheckContext* colCtxt, Collider* colAT, Collider* colAC) { ColliderQuad* at = (ColliderQuad*)colAT; ColliderTris* ac = (ColliderTris*)colAC; ColliderTrisElement* acElem; @@ -2471,13 +2441,13 @@ void CollisionCheck_AC_QuadVsTris(GlobalContext* globalCtx, CollisionCheckContex if ((Math3d_ColTriTri(&D_801EE000, &acElem->dim, &D_801EDFF0) != 0) || (Math3d_ColTriTri(&D_801EE038, &acElem->dim, &D_801EDFF0) != 0)) { - if (Collider_QuadSetNearestAC(globalCtx, at, &D_801EDFF0)) { + if (Collider_QuadSetNearestAC(play, at, &D_801EDFF0)) { Vec3f atPos; Vec3f acPos; CollisionCheck_TrisAvgPoint(acElem, &acPos); CollisionCheck_QuadAvgPoint(at, &atPos); - CollisionCheck_SetATvsAC(globalCtx, &at->base, &at->info, &atPos, &ac->base, &acElem->info, &acPos, + CollisionCheck_SetATvsAC(play, &at->base, &at->info, &atPos, &ac->base, &acElem->info, &acPos, &D_801EDFF0); return; } @@ -2489,8 +2459,7 @@ void CollisionCheck_AC_QuadVsTris(GlobalContext* globalCtx, CollisionCheckContex /** * AC overlap check. Calculates the center of each collider element and the point of contact. */ -void CollisionCheck_AC_QuadVsQuad(GlobalContext* globalCtx, CollisionCheckContext* colCtxt, Collider* colAT, - Collider* colAC) { +void CollisionCheck_AC_QuadVsQuad(PlayState* play, CollisionCheckContext* colCtxt, Collider* colAT, Collider* colAC) { ColliderQuad* at = (ColliderQuad*)colAT; ColliderQuad* ac = (ColliderQuad*)colAC; s32 i; @@ -2514,14 +2483,13 @@ void CollisionCheck_AC_QuadVsQuad(GlobalContext* globalCtx, CollisionCheckContex for (i = 0; i < 2; i++) { for (j = 0; j < 2; j++) { if (Math3d_ColTriTri(&D_801EE0E8[j], &D_801EE070[i], &D_801EE0D8) != 0 && - Collider_QuadSetNearestAC(globalCtx, at, &D_801EE0D8) != 0) { + Collider_QuadSetNearestAC(play, at, &D_801EE0D8) != 0) { Vec3f atPos; Vec3f acPos; CollisionCheck_QuadAvgPoint(at, &atPos); CollisionCheck_QuadAvgPoint(ac, &acPos); - CollisionCheck_SetATvsAC(globalCtx, &at->base, &at->info, &atPos, &ac->base, &ac->info, &acPos, - &D_801EE0D8); + CollisionCheck_SetATvsAC(play, &at->base, &at->info, &atPos, &ac->base, &ac->info, &acPos, &D_801EE0D8); return; } } @@ -2531,8 +2499,7 @@ void CollisionCheck_AC_QuadVsQuad(GlobalContext* globalCtx, CollisionCheckContex /** * AC overlap check. Calculates the center of each collider element and the point of contact. */ -void CollisionCheck_AC_QuadVsSphere(GlobalContext* globalCtx, CollisionCheckContext* colCtxt, Collider* colAT, - Collider* colAC) { +void CollisionCheck_AC_QuadVsSphere(PlayState* play, CollisionCheckContext* colCtxt, Collider* colAT, Collider* colAC) { ColliderQuad* at = (ColliderQuad*)colAT; Vec3f hitPos; ColliderSphere* ac = (ColliderSphere*)colAC; @@ -2549,13 +2516,13 @@ void CollisionCheck_AC_QuadVsSphere(GlobalContext* globalCtx, CollisionCheckCont if ((Math3D_ColSphereTri(&ac->dim.worldSphere, &D_801EE150, &hitPos) != 0) || (Math3D_ColSphereTri(&ac->dim.worldSphere, &D_801EE188, &hitPos) != 0)) { - if (Collider_QuadSetNearestAC(globalCtx, at, &hitPos)) { + if (Collider_QuadSetNearestAC(play, at, &hitPos)) { Vec3f atPos; Vec3f acPos; Math_Vec3s_ToVec3f(&acPos, &ac->dim.worldSphere.center); CollisionCheck_QuadAvgPoint(at, &atPos); - CollisionCheck_SetATvsAC(globalCtx, &at->base, &at->info, &atPos, &ac->base, &ac->info, &acPos, &hitPos); + CollisionCheck_SetATvsAC(play, &at->base, &at->info, &atPos, &ac->base, &ac->info, &acPos, &hitPos); } } } @@ -2563,7 +2530,7 @@ void CollisionCheck_AC_QuadVsSphere(GlobalContext* globalCtx, CollisionCheckCont /** * AC overlap check. Calculates the center of each collider element and the point of contact. */ -void CollisionCheck_AC_SphereVsJntSph(GlobalContext* globalCtx, CollisionCheckContext* colCtxt, Collider* colAT, +void CollisionCheck_AC_SphereVsJntSph(PlayState* play, CollisionCheckContext* colCtxt, Collider* colAT, Collider* colAC) { ColliderSphere* at = (ColliderSphere*)colAT; ColliderJntSph* ac = (ColliderJntSph*)colAC; @@ -2601,8 +2568,7 @@ void CollisionCheck_AC_SphereVsJntSph(GlobalContext* globalCtx, CollisionCheckCo } else { Math_Vec3f_Copy(&hitPos, &atPos); } - CollisionCheck_SetATvsAC(globalCtx, &at->base, &at->info, &atPos, &ac->base, &acElem->info, &acPos, - &hitPos); + CollisionCheck_SetATvsAC(play, &at->base, &at->info, &atPos, &ac->base, &acElem->info, &acPos, &hitPos); } } } @@ -2611,7 +2577,7 @@ void CollisionCheck_AC_SphereVsJntSph(GlobalContext* globalCtx, CollisionCheckCo /** * AC overlap check. Calculates the center of each collider element and the point of contact. */ -void CollisionCheck_AC_SphereVsCylinder(GlobalContext* globalCtx, CollisionCheckContext* colCtxt, Collider* colAT, +void CollisionCheck_AC_SphereVsCylinder(PlayState* play, CollisionCheckContext* colCtxt, Collider* colAT, Collider* colAC) { ColliderCylinder* ac = (ColliderCylinder*)colAC; ColliderSphere* at = (ColliderSphere*)colAT; @@ -2649,7 +2615,7 @@ void CollisionCheck_AC_SphereVsCylinder(GlobalContext* globalCtx, CollisionCheck } else { Math_Vec3f_Copy(&hitPos, &atPos); } - CollisionCheck_SetATvsAC(globalCtx, &at->base, &at->info, &atPos, &ac->base, &ac->info, &acPos, &hitPos); + CollisionCheck_SetATvsAC(play, &at->base, &at->info, &atPos, &ac->base, &ac->info, &acPos, &hitPos); } if (at) {} @@ -2658,8 +2624,7 @@ void CollisionCheck_AC_SphereVsCylinder(GlobalContext* globalCtx, CollisionCheck /** * AC overlap check. Calculates the center of each collider element and the point of contact. */ -void CollisionCheck_AC_SphereVsTris(GlobalContext* globalCtx, CollisionCheckContext* colCtxt, Collider* colAT, - Collider* colAC) { +void CollisionCheck_AC_SphereVsTris(PlayState* play, CollisionCheckContext* colCtxt, Collider* colAT, Collider* colAC) { ColliderSphere* at = (ColliderSphere*)colAT; ColliderTris* ac = (ColliderTris*)colAC; ColliderTrisElement* acElem; @@ -2682,8 +2647,7 @@ void CollisionCheck_AC_SphereVsTris(GlobalContext* globalCtx, CollisionCheckCont Math_Vec3s_ToVec3f(&atPos, &at->dim.worldSphere.center); CollisionCheck_TrisAvgPoint(acElem, &acPos); - CollisionCheck_SetATvsAC(globalCtx, &at->base, &at->info, &atPos, &ac->base, &acElem->info, &acPos, - &hitPos); + CollisionCheck_SetATvsAC(play, &at->base, &at->info, &atPos, &ac->base, &acElem->info, &acPos, &hitPos); return; } } @@ -2692,8 +2656,7 @@ void CollisionCheck_AC_SphereVsTris(GlobalContext* globalCtx, CollisionCheckCont /** * AC overlap check. Calculates the center of each collider element and the point of contact. */ -void CollisionCheck_AC_SphereVsQuad(GlobalContext* globalCtx, CollisionCheckContext* colCtxt, Collider* colAT, - Collider* colAC) { +void CollisionCheck_AC_SphereVsQuad(PlayState* play, CollisionCheckContext* colCtxt, Collider* colAT, Collider* colAC) { ColliderSphere* at = (ColliderSphere*)colAT; Vec3f hitPos; ColliderQuad* ac = (ColliderQuad*)colAC; @@ -2715,14 +2678,14 @@ void CollisionCheck_AC_SphereVsQuad(GlobalContext* globalCtx, CollisionCheckCont Math_Vec3s_ToVec3f(&atPos, &at->dim.worldSphere.center); CollisionCheck_QuadAvgPoint(ac, &acPos); - CollisionCheck_SetATvsAC(globalCtx, &at->base, &at->info, &atPos, &ac->base, &ac->info, &acPos, &hitPos); + CollisionCheck_SetATvsAC(play, &at->base, &at->info, &atPos, &ac->base, &ac->info, &acPos, &hitPos); } } /** * AC overlap check. Calculates the center of each collider element and the point of contact. */ -void CollisionCheck_AC_SphereVsSphere(GlobalContext* globalCtx, CollisionCheckContext* colCtxt, Collider* colAT, +void CollisionCheck_AC_SphereVsSphere(PlayState* play, CollisionCheckContext* colCtxt, Collider* colAT, Collider* colAC) { ColliderSphere* at = (ColliderSphere*)colAT; ColliderSphere* ac = (ColliderSphere*)colAC; @@ -2756,14 +2719,14 @@ void CollisionCheck_AC_SphereVsSphere(GlobalContext* globalCtx, CollisionCheckCo } else { Math_Vec3f_Copy(&hitPos, &atPos); } - CollisionCheck_SetATvsAC(globalCtx, &at->base, &at->info, &atPos, &ac->base, &ac->info, &acPos, &hitPos); + CollisionCheck_SetATvsAC(play, &at->base, &at->info, &atPos, &ac->base, &ac->info, &acPos, &hitPos); } } /** * Sets a ColliderJntSph's hit effects */ -void CollisionCheck_SetJntSphHitFX(GlobalContext* globalCtx, CollisionCheckContext* colCtxt, Collider* collider) { +void CollisionCheck_SetJntSphHitFX(PlayState* play, CollisionCheckContext* colCtxt, Collider* collider) { ColliderJntSph* jntSph = (ColliderJntSph*)collider; ColliderJntSphElement* element; @@ -2773,8 +2736,8 @@ void CollisionCheck_SetJntSphHitFX(GlobalContext* globalCtx, CollisionCheckConte Vec3f hitPos; Math_Vec3s_ToVec3f(&hitPos, &element->info.bumper.hitPos); - CollisionCheck_HitEffects(globalCtx, element->info.acHit, element->info.acHitInfo, &jntSph->base, - &element->info, &hitPos); + CollisionCheck_HitEffects(play, element->info.acHit, element->info.acHitInfo, &jntSph->base, &element->info, + &hitPos); element->info.acHitInfo->toucherFlags |= TOUCH_DREW_HITMARK; return; } @@ -2784,7 +2747,7 @@ void CollisionCheck_SetJntSphHitFX(GlobalContext* globalCtx, CollisionCheckConte /** * Sets a ColliderCylinder's hit effects */ -void CollisionCheck_SetCylHitFX(GlobalContext* globalCtx, CollisionCheckContext* colCtxt, Collider* collider) { +void CollisionCheck_SetCylHitFX(PlayState* play, CollisionCheckContext* colCtxt, Collider* collider) { ColliderCylinder* cylinder = (ColliderCylinder*)collider; if ((cylinder->info.bumperFlags & BUMP_DRAW_HITMARK) && cylinder->info.acHitInfo != NULL && @@ -2792,7 +2755,7 @@ void CollisionCheck_SetCylHitFX(GlobalContext* globalCtx, CollisionCheckContext* Vec3f hitPos; Math_Vec3s_ToVec3f(&hitPos, &cylinder->info.bumper.hitPos); - CollisionCheck_HitEffects(globalCtx, cylinder->info.acHit, cylinder->info.acHitInfo, &cylinder->base, + CollisionCheck_HitEffects(play, cylinder->info.acHit, cylinder->info.acHitInfo, &cylinder->base, &cylinder->info, &hitPos); cylinder->info.acHitInfo->toucherFlags |= TOUCH_DREW_HITMARK; } @@ -2801,7 +2764,7 @@ void CollisionCheck_SetCylHitFX(GlobalContext* globalCtx, CollisionCheckContext* /** * Sets a ColliderTris's hit effects */ -void CollisionCheck_SetTrisHitFX(GlobalContext* globalCtx, CollisionCheckContext* colCtxt, Collider* collider) { +void CollisionCheck_SetTrisHitFX(PlayState* play, CollisionCheckContext* colCtxt, Collider* collider) { ColliderTris* tris = (ColliderTris*)collider; ColliderTrisElement* element; @@ -2811,8 +2774,8 @@ void CollisionCheck_SetTrisHitFX(GlobalContext* globalCtx, CollisionCheckContext Vec3f hitPos; Math_Vec3s_ToVec3f(&hitPos, &element->info.bumper.hitPos); - CollisionCheck_HitEffects(globalCtx, element->info.acHit, element->info.acHitInfo, &tris->base, - &element->info, &hitPos); + CollisionCheck_HitEffects(play, element->info.acHit, element->info.acHitInfo, &tris->base, &element->info, + &hitPos); element->info.acHitInfo->toucherFlags |= TOUCH_DREW_HITMARK; return; } @@ -2822,7 +2785,7 @@ void CollisionCheck_SetTrisHitFX(GlobalContext* globalCtx, CollisionCheckContext /** * Sets a ColliderQuad's hit effects */ -void CollisionCheck_SetQuadHitFX(GlobalContext* globalCtx, CollisionCheckContext* colCtxt, Collider* collider) { +void CollisionCheck_SetQuadHitFX(PlayState* play, CollisionCheckContext* colCtxt, Collider* collider) { ColliderQuad* quad = (ColliderQuad*)collider; if ((quad->info.bumperFlags & BUMP_DRAW_HITMARK) && quad->info.acHitInfo != NULL && @@ -2830,7 +2793,7 @@ void CollisionCheck_SetQuadHitFX(GlobalContext* globalCtx, CollisionCheckContext Vec3f hitPos; Math_Vec3s_ToVec3f(&hitPos, &quad->info.bumper.hitPos); - CollisionCheck_HitEffects(globalCtx, quad->info.acHit, quad->info.acHitInfo, &quad->base, &quad->info, &hitPos); + CollisionCheck_HitEffects(play, quad->info.acHit, quad->info.acHitInfo, &quad->base, &quad->info, &hitPos); quad->info.acHitInfo->toucherFlags |= TOUCH_DREW_HITMARK; } } @@ -2838,7 +2801,7 @@ void CollisionCheck_SetQuadHitFX(GlobalContext* globalCtx, CollisionCheckContext /** * Sets a ColliderSphere's hit effects */ -void CollisionCheck_SetSphereHitFX(GlobalContext* globalCtx, CollisionCheckContext* colCtxt, Collider* collider) { +void CollisionCheck_SetSphereHitFX(PlayState* play, CollisionCheckContext* colCtxt, Collider* collider) { ColliderSphere* sphere = (ColliderSphere*)collider; if ((sphere->info.bumperFlags & BUMP_DRAW_HITMARK) && sphere->info.acHitInfo != NULL && @@ -2846,7 +2809,7 @@ void CollisionCheck_SetSphereHitFX(GlobalContext* globalCtx, CollisionCheckConte Vec3f hitPos; Math_Vec3s_ToVec3f(&hitPos, &sphere->info.bumper.hitPos); - CollisionCheck_HitEffects(globalCtx, sphere->info.acHit, sphere->info.acHitInfo, &sphere->base, &sphere->info, + CollisionCheck_HitEffects(play, sphere->info.acHit, sphere->info.acHitInfo, &sphere->base, &sphere->info, &hitPos); sphere->info.acHitInfo->toucherFlags |= TOUCH_DREW_HITMARK; } @@ -2860,7 +2823,7 @@ ColChkApplyFunc sColChkApplyFuncs[] = { /** * Handles hit effects for each AC collider that had an AC collision. Spawns hitmarks and plays sound effects. */ -void CollisionCheck_SetHitEffects(GlobalContext* globalCtx, CollisionCheckContext* colCtxt) { +void CollisionCheck_SetHitEffects(PlayState* play, CollisionCheckContext* colCtxt) { Collider** col; for (col = &colCtxt->colAC[0]; col < &colCtxt->colAC[colCtxt->colACCount]; col++) { @@ -2870,7 +2833,7 @@ void CollisionCheck_SetHitEffects(GlobalContext* globalCtx, CollisionCheckContex if (colAC->actor != NULL && colAC->actor->update == NULL) { continue; } - sColChkApplyFuncs[colAC->shape](globalCtx, colCtxt, colAC); + sColChkApplyFuncs[colAC->shape](play, colCtxt, colAC); } } } @@ -2891,7 +2854,7 @@ ColChkVsFunc sACVsFuncs[COLSHAPE_MAX][COLSHAPE_MAX] = { /** * Iterates through all AC colliders, performing AC collisions with the AT collider. */ -void CollisionCheck_AC(GlobalContext* globalCtx, CollisionCheckContext* colCtxt, Collider* colAT) { +void CollisionCheck_AC(PlayState* play, CollisionCheckContext* colCtxt, Collider* colAT) { Collider** col; for (col = &colCtxt->colAC[0]; col < &colCtxt->colAC[colCtxt->colACCount]; col++) { @@ -2905,7 +2868,7 @@ void CollisionCheck_AC(GlobalContext* globalCtx, CollisionCheckContext* colCtxt, if (!(colAT->atFlags & AT_SELF) && colAT->actor != NULL && colAC->actor == colAT->actor) { continue; } - sACVsFuncs[colAT->shape][colAC->shape](globalCtx, colCtxt, colAT, colAC); + sACVsFuncs[colAT->shape][colAC->shape](play, colCtxt, colAT, colAC); } } } @@ -2917,7 +2880,7 @@ void CollisionCheck_AC(GlobalContext* globalCtx, CollisionCheckContext* colCtxt, * successful collision. To collide, an AT collider must share a type (AC_TYPE_PLAYER, AC_TYPE_ENEMY, or AC_TYPE_OTHER) * with the AC collider and the toucher and bumper elements that overlapped must share a dmgFlag. */ -void CollisionCheck_AT(GlobalContext* globalCtx, CollisionCheckContext* colCtxt) { +void CollisionCheck_AT(PlayState* play, CollisionCheckContext* colCtxt) { Collider** col; if (colCtxt->colATCount == 0 || colCtxt->colACCount == 0) { @@ -2931,11 +2894,11 @@ void CollisionCheck_AT(GlobalContext* globalCtx, CollisionCheckContext* colCtxt) if (colAC->actor != NULL && colAC->actor->update == NULL) { continue; } - CollisionCheck_AC(globalCtx, colCtxt, colAC); + CollisionCheck_AC(play, colCtxt, colAC); } } - CollisionCheck_SetHitEffects(globalCtx, colCtxt); + CollisionCheck_SetHitEffects(play, colCtxt); } /** @@ -2956,8 +2919,8 @@ s32 CollisionCheck_GetMassType(u8 mass) { * Sets OC collision flags for OC collider overlaps. If both colliders are attached to actors and can push, * also performs an elastic collision where both colliders are moved apart in proportion to their masses. */ -void CollisionCheck_SetOCvsOC(GlobalContext* globalCtx, Collider* left, ColliderInfo* leftInfo, Vec3f* leftPos, - Collider* right, ColliderInfo* rightInfo, Vec3f* rightPos, f32 overlap) { +void CollisionCheck_SetOCvsOC(PlayState* play, Collider* left, ColliderInfo* leftInfo, Vec3f* leftPos, Collider* right, + ColliderInfo* rightInfo, Vec3f* rightPos, f32 overlap) { f32 pad; f32 leftDispRatio; f32 rightDispRatio; @@ -3054,8 +3017,7 @@ void CollisionCheck_SetOCvsOC(GlobalContext* globalCtx, Collider* left, Collider /** * OC overlap check for two JntSphs */ -void CollisionCheck_OC_JntSphVsJntSph(GlobalContext* globalCtx, CollisionCheckContext* colCtxt, Collider* l, - Collider* r) { +void CollisionCheck_OC_JntSphVsJntSph(PlayState* play, CollisionCheckContext* colCtxt, Collider* l, Collider* r) { ColliderJntSph* left = (ColliderJntSph*)l; ColliderJntSph* right = (ColliderJntSph*)r; ColliderJntSphElement* leftElem; @@ -3080,7 +3042,7 @@ void CollisionCheck_OC_JntSphVsJntSph(GlobalContext* globalCtx, CollisionCheckCo Math_Vec3s_ToVec3f(&leftPos, &leftElem->dim.worldSphere.center); Math_Vec3s_ToVec3f(&rightPos, &rightElem->dim.worldSphere.center); - CollisionCheck_SetOCvsOC(globalCtx, &left->base, &leftElem->info, &leftPos, &right->base, + CollisionCheck_SetOCvsOC(play, &left->base, &leftElem->info, &leftPos, &right->base, &rightElem->info, &rightPos, overlap); } } @@ -3091,7 +3053,7 @@ void CollisionCheck_OC_JntSphVsJntSph(GlobalContext* globalCtx, CollisionCheckCo /** * OC overlap check for a JntSph and Cylinder */ -void CollisionCheck_OC_JntSphVsCyl(GlobalContext* globalCtx, CollisionCheckContext* colCtxt, Collider* l, Collider* r) { +void CollisionCheck_OC_JntSphVsCyl(PlayState* play, CollisionCheckContext* colCtxt, Collider* l, Collider* r) { ColliderJntSph* left = (ColliderJntSph*)l; ColliderCylinder* right = (ColliderCylinder*)r; ColliderJntSphElement* leftElem; @@ -3110,7 +3072,7 @@ void CollisionCheck_OC_JntSphVsCyl(GlobalContext* globalCtx, CollisionCheckConte Math_Vec3s_ToVec3f(&leftPos, &leftElem->dim.worldSphere.center); Math_Vec3s_ToVec3f(&rightPos, &right->dim.pos); - CollisionCheck_SetOCvsOC(globalCtx, &left->base, &leftElem->info, &leftPos, &right->base, &right->info, + CollisionCheck_SetOCvsOC(play, &left->base, &leftElem->info, &leftPos, &right->base, &right->info, &rightPos, overlap); } } @@ -3120,8 +3082,7 @@ void CollisionCheck_OC_JntSphVsCyl(GlobalContext* globalCtx, CollisionCheckConte /** * OC overlap check for a JntSph and Sphere */ -void CollisionCheck_OC_JntSphVsSphere(GlobalContext* globalCtx, CollisionCheckContext* colCtxt, Collider* l, - Collider* r) { +void CollisionCheck_OC_JntSphVsSphere(PlayState* play, CollisionCheckContext* colCtxt, Collider* l, Collider* r) { ColliderJntSph* left = (ColliderJntSph*)l; ColliderSphere* right = (ColliderSphere*)r; ColliderJntSphElement* leftElem; @@ -3140,7 +3101,7 @@ void CollisionCheck_OC_JntSphVsSphere(GlobalContext* globalCtx, CollisionCheckCo Math_Vec3s_ToVec3f(&leftPos, &leftElem->dim.worldSphere.center); Math_Vec3s_ToVec3f(&rightPos, &right->dim.worldSphere.center); - CollisionCheck_SetOCvsOC(globalCtx, &left->base, &leftElem->info, &leftPos, &right->base, &right->info, + CollisionCheck_SetOCvsOC(play, &left->base, &leftElem->info, &leftPos, &right->base, &right->info, &rightPos, overlap); } } @@ -3150,14 +3111,14 @@ void CollisionCheck_OC_JntSphVsSphere(GlobalContext* globalCtx, CollisionCheckCo /** * OC overlap check for a Cylinder and JntSph */ -void CollisionCheck_OC_CylVsJntSph(GlobalContext* globalCtx, CollisionCheckContext* colCtxt, Collider* l, Collider* r) { - CollisionCheck_OC_JntSphVsCyl(globalCtx, colCtxt, r, l); +void CollisionCheck_OC_CylVsJntSph(PlayState* play, CollisionCheckContext* colCtxt, Collider* l, Collider* r) { + CollisionCheck_OC_JntSphVsCyl(play, colCtxt, r, l); } /** * OC overlap check for two Cylinders */ -void CollisionCheck_OC_CylVsCyl(GlobalContext* globalCtx, CollisionCheckContext* colCtxt, Collider* l, Collider* r) { +void CollisionCheck_OC_CylVsCyl(PlayState* play, CollisionCheckContext* colCtxt, Collider* l, Collider* r) { ColliderCylinder* left = (ColliderCylinder*)l; ColliderCylinder* right = (ColliderCylinder*)r; f32 overlap; @@ -3170,8 +3131,8 @@ void CollisionCheck_OC_CylVsCyl(GlobalContext* globalCtx, CollisionCheckContext* Math_Vec3s_ToVec3f(&leftPos, &left->dim.pos); Math_Vec3s_ToVec3f(&rightPos, &right->dim.pos); - CollisionCheck_SetOCvsOC(globalCtx, &left->base, &left->info, &leftPos, &right->base, &right->info, - &rightPos, overlap); + CollisionCheck_SetOCvsOC(play, &left->base, &left->info, &leftPos, &right->base, &right->info, &rightPos, + overlap); } } } @@ -3179,7 +3140,7 @@ void CollisionCheck_OC_CylVsCyl(GlobalContext* globalCtx, CollisionCheckContext* /** * OC overlap check for a Cylinder and Sphere */ -void CollisionCheck_OC_CylVsSphere(GlobalContext* globalCtx, CollisionCheckContext* colCtxt, Collider* l, Collider* r) { +void CollisionCheck_OC_CylVsSphere(PlayState* play, CollisionCheckContext* colCtxt, Collider* l, Collider* r) { ColliderCylinder* left = (ColliderCylinder*)l; ColliderSphere* right = (ColliderSphere*)r; f32 overlap; @@ -3192,8 +3153,8 @@ void CollisionCheck_OC_CylVsSphere(GlobalContext* globalCtx, CollisionCheckConte Math_Vec3s_ToVec3f(&leftPos, &left->dim.pos); Math_Vec3s_ToVec3f(&rightPos, &right->dim.worldSphere.center); - CollisionCheck_SetOCvsOC(globalCtx, &left->base, &left->info, &leftPos, &right->base, &right->info, - &rightPos, overlap); + CollisionCheck_SetOCvsOC(play, &left->base, &left->info, &leftPos, &right->base, &right->info, &rightPos, + overlap); } } } @@ -3201,23 +3162,21 @@ void CollisionCheck_OC_CylVsSphere(GlobalContext* globalCtx, CollisionCheckConte /** * OC overlap check for a Sphere and JntSph */ -void CollisionCheck_OC_SphereVsJntSph(GlobalContext* globalCtx, CollisionCheckContext* colCtxt, Collider* l, - Collider* r) { - CollisionCheck_OC_JntSphVsSphere(globalCtx, colCtxt, r, l); +void CollisionCheck_OC_SphereVsJntSph(PlayState* play, CollisionCheckContext* colCtxt, Collider* l, Collider* r) { + CollisionCheck_OC_JntSphVsSphere(play, colCtxt, r, l); } /** * OC overlap check for a Sphere and Cylinder */ -void CollisionCheck_OC_SphereVsCyl(GlobalContext* globalCtx, CollisionCheckContext* colCtxt, Collider* l, Collider* r) { - CollisionCheck_OC_CylVsSphere(globalCtx, colCtxt, r, l); +void CollisionCheck_OC_SphereVsCyl(PlayState* play, CollisionCheckContext* colCtxt, Collider* l, Collider* r) { + CollisionCheck_OC_CylVsSphere(play, colCtxt, r, l); } /** * OC overlap check for two Spheres */ -void CollisionCheck_OC_SphereVsSphere(GlobalContext* globalCtx, CollisionCheckContext* colCtxt, Collider* l, - Collider* r) { +void CollisionCheck_OC_SphereVsSphere(PlayState* play, CollisionCheckContext* colCtxt, Collider* l, Collider* r) { ColliderSphere* left = (ColliderSphere*)l; ColliderSphere* right = (ColliderSphere*)r; f32 overlap; @@ -3230,8 +3189,8 @@ void CollisionCheck_OC_SphereVsSphere(GlobalContext* globalCtx, CollisionCheckCo Math_Vec3s_ToVec3f(&leftPos, &left->dim.worldSphere.center); Math_Vec3s_ToVec3f(&rightPos, &right->dim.worldSphere.center); - CollisionCheck_SetOCvsOC(globalCtx, &left->base, &left->info, &leftPos, &right->base, &right->info, - &rightPos, overlap); + CollisionCheck_SetOCvsOC(play, &left->base, &left->info, &leftPos, &right->base, &right->info, &rightPos, + overlap); } } } @@ -3279,7 +3238,7 @@ ColChkVsFunc sOCVsFuncs[COLSHAPE_MAX][COLSHAPE_MAX] = { * colliders can collide, and each collider must have the OC flag corresponding to the other's OC type. Additionally, * OC2_UNK1 cannot collide with OC2_UNK2, nor can two colliders that share an actor. */ -void CollisionCheck_OC(GlobalContext* globalCtx, CollisionCheckContext* colCtxt) { +void CollisionCheck_OC(PlayState* play, CollisionCheckContext* colCtxt) { Collider** left; Collider** right; ColChkVsFunc vsFunc; @@ -3296,7 +3255,7 @@ void CollisionCheck_OC(GlobalContext* globalCtx, CollisionCheckContext* colCtxt) if (vsFunc == NULL) { continue; } - vsFunc(globalCtx, colCtxt, *left, *right); + vsFunc(play, colCtxt, *left, *right); } } } @@ -3366,7 +3325,7 @@ void CollisionCheck_SetInfoGetDamageTable(CollisionCheckInfo* info, s32 index, C /** * Apply AC damage effect */ -void CollisionCheck_ApplyDamage(GlobalContext* globalCtx, CollisionCheckContext* colCtxt, Collider* collider, +void CollisionCheck_ApplyDamage(PlayState* play, CollisionCheckContext* colCtxt, Collider* collider, ColliderInfo* info) { f32 damage; f32 finalDamage = 0.0f; @@ -3417,13 +3376,13 @@ void CollisionCheck_ApplyDamage(GlobalContext* globalCtx, CollisionCheckContext* /** * Apply ColliderJntSph AC damage effect */ -void CollisionCheck_ApplyDamageJntSph(GlobalContext* globalCtx, CollisionCheckContext* colCtxt, Collider* collider) { +void CollisionCheck_ApplyDamageJntSph(PlayState* play, CollisionCheckContext* colCtxt, Collider* collider) { ColliderJntSph* jntSph = (ColliderJntSph*)collider; s32 i; if (jntSph->count > 0 && jntSph->elements != NULL) { for (i = 0; i < jntSph->count; i++) { - CollisionCheck_ApplyDamage(globalCtx, colCtxt, &jntSph->base, &jntSph->elements[i].info); + CollisionCheck_ApplyDamage(play, colCtxt, &jntSph->base, &jntSph->elements[i].info); } } } @@ -3431,42 +3390,42 @@ void CollisionCheck_ApplyDamageJntSph(GlobalContext* globalCtx, CollisionCheckCo /** * Apply ColliderCylinder AC damage effect */ -void CollisionCheck_ApplyDamageCyl(GlobalContext* globalCtx, CollisionCheckContext* colCtxt, Collider* collider) { +void CollisionCheck_ApplyDamageCyl(PlayState* play, CollisionCheckContext* colCtxt, Collider* collider) { ColliderCylinder* cylinder = (ColliderCylinder*)collider; - CollisionCheck_ApplyDamage(globalCtx, colCtxt, &cylinder->base, &cylinder->info); + CollisionCheck_ApplyDamage(play, colCtxt, &cylinder->base, &cylinder->info); } /** * Apply ColliderTris AC damage effect */ -void CollisionCheck_ApplyDamageTris(GlobalContext* globalCtx, CollisionCheckContext* colCtxt, Collider* collider) { +void CollisionCheck_ApplyDamageTris(PlayState* play, CollisionCheckContext* colCtxt, Collider* collider) { ColliderTris* tris = (ColliderTris*)collider; s32 i; // unlike sphere groups above, tri groups are not guarded against // tris->elements being NULL for (i = 0; i < tris->count; i++) { - CollisionCheck_ApplyDamage(globalCtx, colCtxt, &tris->base, &tris->elements[i].info); + CollisionCheck_ApplyDamage(play, colCtxt, &tris->base, &tris->elements[i].info); } } /** * Apply ColliderQuad AC damage effect */ -void CollisionCheck_ApplyDamageQuad(GlobalContext* globalCtx, CollisionCheckContext* colCtxt, Collider* collider) { +void CollisionCheck_ApplyDamageQuad(PlayState* play, CollisionCheckContext* colCtxt, Collider* collider) { ColliderQuad* quad = (ColliderQuad*)collider; - CollisionCheck_ApplyDamage(globalCtx, colCtxt, &quad->base, &quad->info); + CollisionCheck_ApplyDamage(play, colCtxt, &quad->base, &quad->info); } /** * Apply ColliderSphere AC damage effect */ -void CollisionCheck_ApplyDamageSphere(GlobalContext* globalCtx, CollisionCheckContext* colCtxt, Collider* collider) { +void CollisionCheck_ApplyDamageSphere(PlayState* play, CollisionCheckContext* colCtxt, Collider* collider) { ColliderSphere* sphere = (ColliderSphere*)collider; - CollisionCheck_ApplyDamage(globalCtx, colCtxt, &sphere->base, &sphere->info); + CollisionCheck_ApplyDamage(play, colCtxt, &sphere->base, &sphere->info); } ColChkApplyFunc sApplyDamageFuncs[] = { @@ -3478,7 +3437,7 @@ ColChkApplyFunc sApplyDamageFuncs[] = { * For all AC colliders, sets any damage effects from collisions with AT colliders to their corresponding actor's * CollisionCheckInfo. */ -void CollisionCheck_Damage(GlobalContext* globalCtx, CollisionCheckContext* colCtxt) { +void CollisionCheck_Damage(PlayState* play, CollisionCheckContext* colCtxt) { s32 i; for (i = 0; i < colCtxt->colACCount; i++) { @@ -3490,15 +3449,15 @@ void CollisionCheck_Damage(GlobalContext* globalCtx, CollisionCheckContext* colC if (col->acFlags & AC_NO_DAMAGE) { continue; } - sApplyDamageFuncs[col->shape](globalCtx, colCtxt, col); + sApplyDamageFuncs[col->shape](play, colCtxt, col); } } /** * Checks if the line segment ab intersects any of the ColliderJntSph's elements */ -s32 CollisionCheck_LineOC_JntSph(GlobalContext* globalCtx, CollisionCheckContext* colChkCtx, Collider* collider, - Vec3f* a, Vec3f* b) { +s32 CollisionCheck_LineOC_JntSph(PlayState* play, CollisionCheckContext* colChkCtx, Collider* collider, Vec3f* a, + Vec3f* b) { ColliderJntSph* jntSph = (ColliderJntSph*)collider; s32 i; @@ -3521,7 +3480,7 @@ s32 CollisionCheck_LineOC_JntSph(GlobalContext* globalCtx, CollisionCheckContext /** * Checks if the line segment ab intersects the ColliderCylinder */ -s32 CollisionCheck_LineOC_Cyl(GlobalContext* globalCtx, CollisionCheckContext* colChkCtx, Collider* collider, Vec3f* a, +s32 CollisionCheck_LineOC_Cyl(PlayState* play, CollisionCheckContext* colChkCtx, Collider* collider, Vec3f* a, Vec3f* b) { ColliderCylinder* cylinder = (ColliderCylinder*)collider; @@ -3539,8 +3498,8 @@ s32 CollisionCheck_LineOC_Cyl(GlobalContext* globalCtx, CollisionCheckContext* c /** * Checks if the line segment ab intersects the ColliderSphere */ -s32 CollisionCheck_LineOC_Sphere(GlobalContext* globalCtx, CollisionCheckContext* colChkCtx, Collider* collider, - Vec3f* a, Vec3f* b) { +s32 CollisionCheck_LineOC_Sphere(PlayState* play, CollisionCheckContext* colChkCtx, Collider* collider, Vec3f* a, + Vec3f* b) { ColliderSphere* sphere = (ColliderSphere*)collider; if (!(sphere->info.ocElemFlags & OCELEM_ON)) { @@ -3564,8 +3523,8 @@ ColChkLineFunc sOCLineCheckFuncs[] = { * Checks if the line segment ab intersects any OC colliders, excluding those attached to actors * on the exclusion list. Returns true if there are any intersections and false otherwise. */ -s32 CollisionCheck_LineOC(GlobalContext* globalCtx, CollisionCheckContext* colChkCtx, Vec3f* a, Vec3f* b, - Actor** exclusions, s32 numExclusions) { +s32 CollisionCheck_LineOC(PlayState* play, CollisionCheckContext* colChkCtx, Vec3f* a, Vec3f* b, Actor** exclusions, + s32 numExclusions) { ColChkLineFunc lineCheck; Collider** col; s32 i; @@ -3593,7 +3552,7 @@ s32 CollisionCheck_LineOC(GlobalContext* globalCtx, CollisionCheckContext* colCh continue; } - result = lineCheck(globalCtx, colChkCtx, (*col), a, b); + result = lineCheck(play, colChkCtx, (*col), a, b); if (result) { break; } @@ -3605,17 +3564,17 @@ s32 CollisionCheck_LineOC(GlobalContext* globalCtx, CollisionCheckContext* colCh * Checks if the line segment ab intersects any OC colliders. Returns true if there are any intersections and false * otherwise. */ -s32 CollisionCheck_LineOCCheckAll(GlobalContext* globalCtx, CollisionCheckContext* colCtxt, Vec3f* a, Vec3f* b) { - return CollisionCheck_LineOC(globalCtx, colCtxt, a, b, NULL, 0); +s32 CollisionCheck_LineOCCheckAll(PlayState* play, CollisionCheckContext* colCtxt, Vec3f* a, Vec3f* b) { + return CollisionCheck_LineOC(play, colCtxt, a, b, NULL, 0); } /** * Checks if the line segment ab intersects any OC colliders, excluding those attached to actors on the exclusion list. * Returns true if there are any intersections and false otherwise. */ -s32 CollisionCheck_LineOCCheck(GlobalContext* globalCtx, CollisionCheckContext* colCtxt, Vec3f* a, Vec3f* b, - Actor** exclusions, s32 numExclusions) { - return CollisionCheck_LineOC(globalCtx, colCtxt, a, b, exclusions, numExclusions); +s32 CollisionCheck_LineOCCheck(PlayState* play, CollisionCheckContext* colCtxt, Vec3f* a, Vec3f* b, Actor** exclusions, + s32 numExclusions) { + return CollisionCheck_LineOC(play, colCtxt, a, b, exclusions, numExclusions); } /** @@ -3670,11 +3629,10 @@ void Collider_SetTrisVertices(ColliderTris* collider, s32 index, Vec3f* a, Vec3f /** * Sets the specified ColliderTrisElement's dim using the values in src */ -void Collider_SetTrisDim(GlobalContext* globalCtx, ColliderTris* collider, s32 index, - ColliderTrisElementDimInit* init) { +void Collider_SetTrisDim(PlayState* play, ColliderTris* collider, s32 index, ColliderTrisElementDimInit* init) { ColliderTrisElement* element = &collider->elements[index]; - Collider_SetTrisElementDim(globalCtx, &element->dim, init); + Collider_SetTrisElementDim(play, &element->dim, init); } /** @@ -3692,7 +3650,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; @@ -3734,7 +3692,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; @@ -3751,7 +3709,7 @@ void Collider_UpdateSphere(s32 limb, ColliderSphere* collider) { */ #ifdef NON_MATCHING // needs in-function static bss -void CollisionCheck_SpawnRedBlood(GlobalContext* globalCtx, Vec3f* v) { +void CollisionCheck_SpawnRedBlood(PlayState* play, Vec3f* v) { static EffectSparkInit D_801EE200; s32 effectIndex; @@ -3797,7 +3755,7 @@ void CollisionCheck_SpawnRedBlood(GlobalContext* globalCtx, Vec3f* v) { D_801EE200.speed = 8.0f; D_801EE200.gravity = -1.0f; - Effect_Add(globalCtx, &effectIndex, EFFECT_SPARK, 0, 1, &D_801EE200); + Effect_Add(play, &effectIndex, EFFECT_SPARK, 0, 1, &D_801EE200); } #else #pragma GLOBAL_ASM("asm/non_matchings/code/z_collision_check/CollisionCheck_SpawnRedBlood.s") @@ -3809,7 +3767,7 @@ void CollisionCheck_SpawnRedBlood(GlobalContext* globalCtx, Vec3f* v) { */ #ifdef NON_MATCHING // needs in-function static bss -void CollisionCheck_SpawnWaterDroplets(GlobalContext* globalCtx, Vec3f* v) { +void CollisionCheck_SpawnWaterDroplets(PlayState* play, Vec3f* v) { static EffectSparkInit D_801EE738; s32 effectIndex; @@ -3855,7 +3813,7 @@ void CollisionCheck_SpawnWaterDroplets(GlobalContext* globalCtx, Vec3f* v) { D_801EE738.speed = 8.0f; D_801EE738.gravity = -1.0f; - Effect_Add(globalCtx, &effectIndex, EFFECT_SPARK, 0, 1, &D_801EE738); + Effect_Add(play, &effectIndex, EFFECT_SPARK, 0, 1, &D_801EE738); } #else #pragma GLOBAL_ASM("asm/non_matchings/code/z_collision_check/CollisionCheck_SpawnWaterDroplets.s") @@ -3864,7 +3822,7 @@ void CollisionCheck_SpawnWaterDroplets(GlobalContext* globalCtx, Vec3f* v) { /** * Spawns streaks of light from hits against solid objects */ -void CollisionCheck_SpawnShieldParticles(GlobalContext* globalCtx, Vec3f* v) { +void CollisionCheck_SpawnShieldParticles(PlayState* play, Vec3f* v) { static EffectShieldParticleInit shieldParticleInitMetal = { 16, { 0, 0, 0 }, @@ -3890,36 +3848,36 @@ void CollisionCheck_SpawnShieldParticles(GlobalContext* globalCtx, Vec3f* v) { shieldParticleInitMetal.lightPoint.y = shieldParticleInitMetal.position.y; shieldParticleInitMetal.lightPoint.z = shieldParticleInitMetal.position.z; - Effect_Add(globalCtx, &effectIndex, EFFECT_SHIELD_PARTICLE, 0, 1, &shieldParticleInitMetal); + Effect_Add(play, &effectIndex, EFFECT_SHIELD_PARTICLE, 0, 1, &shieldParticleInitMetal); } /** * Spawns streaks of light and makes a metallic sound */ -void CollisionCheck_SpawnShieldParticlesMetal(GlobalContext* globalCtx, Vec3f* v) { - CollisionCheck_SpawnShieldParticles(globalCtx, v); +void CollisionCheck_SpawnShieldParticlesMetal(PlayState* play, Vec3f* v) { + CollisionCheck_SpawnShieldParticles(play, v); play_sound(NA_SE_IT_SHIELD_REFLECT_SW); } /** * Spawns streaks of light and makes a metallic sound at the specified position */ -void CollisionCheck_SpawnShieldParticlesMetalSound(GlobalContext* globalCtx, Vec3f* v, Vec3f* pos) { - CollisionCheck_SpawnShieldParticles(globalCtx, v); +void CollisionCheck_SpawnShieldParticlesMetalSound(PlayState* play, Vec3f* v, Vec3f* pos) { + CollisionCheck_SpawnShieldParticles(play, v); Audio_PlaySfxAtPos(pos, NA_SE_IT_SHIELD_REFLECT_SW); } /** * Spawns streaks of light and makes a metallic sound */ -void CollisionCheck_SpawnShieldParticlesMetal2(GlobalContext* globalCtx, Vec3f* v) { - CollisionCheck_SpawnShieldParticlesMetal(globalCtx, v); +void CollisionCheck_SpawnShieldParticlesMetal2(PlayState* play, Vec3f* v) { + CollisionCheck_SpawnShieldParticlesMetal(play, v); } /** * Spawns streaks of light and makes a wooden sound */ -void CollisionCheck_SpawnShieldParticlesWood(GlobalContext* globalCtx, Vec3f* v, Vec3f* pos) { +void CollisionCheck_SpawnShieldParticlesWood(PlayState* play, Vec3f* v, Vec3f* pos) { static EffectShieldParticleInit shieldParticleInitWood = { 16, { 0, 0, 0 }, @@ -3945,7 +3903,7 @@ void CollisionCheck_SpawnShieldParticlesWood(GlobalContext* globalCtx, Vec3f* v, shieldParticleInitWood.lightPoint.y = shieldParticleInitWood.position.y; shieldParticleInitWood.lightPoint.z = shieldParticleInitWood.position.z; - Effect_Add(globalCtx, &effectIndex, EFFECT_SHIELD_PARTICLE, 0, 1, &shieldParticleInitWood); + Effect_Add(play, &effectIndex, EFFECT_SHIELD_PARTICLE, 0, 1, &shieldParticleInitWood); Audio_PlaySfxAtPos(pos, NA_SE_IT_REFLECTION_WOOD); } diff --git a/src/code/z_common_data.c b/src/code/z_common_data.c index 3860cf153..955f54870 100644 --- a/src/code/z_common_data.c +++ b/src/code/z_common_data.c @@ -13,9 +13,9 @@ void SaveContext_Init(void) { gSaveContext.cutsceneTrigger = 0; gSaveContext.unk_3F4D = 0; gSaveContext.nextDayTime = 0xFFFF; - gSaveContext.environmentTime = 0; + gSaveContext.skyboxTime = 0; gSaveContext.dogIsLost = true; - gSaveContext.nextTransition = 0xFF; + gSaveContext.nextTransitionType = TRANS_NEXT_TYPE_DEFAULT; gSaveContext.unk_3F26 = 50; gSaveContext.options.language = 1; diff --git a/src/code/z_construct.c b/src/code/z_construct.c index a2e295da2..5e92d4958 100644 --- a/src/code/z_construct.c +++ b/src/code/z_construct.c @@ -1,4 +1,4 @@ #include "global.h" -void func_801AAAA0(GlobalContext* globalCtx) { +void func_801AAAA0(PlayState* play) { } diff --git a/src/code/z_debug_display.c b/src/code/z_debug_display.c index ab3478fa1..a8b851ed7 100644 --- a/src/code/z_debug_display.c +++ b/src/code/z_debug_display.c @@ -7,10 +7,10 @@ typedef struct { /* 0x04 */ void* drawArg; // segment address (display list or texture) passed to the draw funciton when called } DebugDispObjectInfo; // size = 0x8 -typedef void (*DebugDispObject_DrawFunc)(DebugDispObject*, void*, GlobalContext*); +typedef void (*DebugDispObject_DrawFunc)(DebugDispObject*, void*, PlayState*); -void DebugDisplay_DrawSpriteI8(DebugDispObject*, void*, GlobalContext*); -void DebugDisplay_DrawPolygon(DebugDispObject*, void*, GlobalContext*); +void DebugDisplay_DrawSpriteI8(DebugDispObject*, void*, PlayState*); +void DebugDisplay_DrawPolygon(DebugDispObject*, void*, PlayState*); DebugDispObject* DebugDisplay_Init(void) { sDebugObjectListHead = NULL; @@ -51,55 +51,55 @@ DebugDispObjectInfo sDebugObjectInfoTable[] = { { 1, &sDebugDisplay2DL }, }; -void DebugDisplay_DrawObjects(GlobalContext* globalCtx) { +void DebugDisplay_DrawObjects(PlayState* play) { DebugDispObject* dispObj = sDebugObjectListHead; DebugDispObjectInfo* objInfo; while (dispObj != NULL) { objInfo = &sDebugObjectInfoTable[dispObj->type]; - sDebugObjectDrawFuncTable[objInfo->drawType](dispObj, objInfo->drawArg, globalCtx); + sDebugObjectDrawFuncTable[objInfo->drawType](dispObj, objInfo->drawArg, play); dispObj = dispObj->next; } } -void DebugDisplay_DrawSpriteI8(DebugDispObject* dispObj, void* texture, GlobalContext* globalCtx) { - OPEN_DISPS(globalCtx->state.gfxCtx); +void DebugDisplay_DrawSpriteI8(DebugDispObject* dispObj, void* texture, PlayState* play) { + OPEN_DISPS(play->state.gfxCtx); - func_8012C6FC(globalCtx->state.gfxCtx); + func_8012C6FC(play->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(&play->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); - gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_XLU_DISP++, sDebugDisplaySpriteDL); - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->state.gfxCtx); } Lights1 sDebugDisplayLight1 = gdSPDefLights1(128, 128, 128, 255, 255, 255, 73, 73, 73); -void DebugDisplay_DrawPolygon(DebugDispObject* dispObj, void* arg1, GlobalContext* globalCtx) { - OPEN_DISPS(globalCtx->state.gfxCtx); +void DebugDisplay_DrawPolygon(DebugDispObject* dispObj, void* arg1, PlayState* play) { + OPEN_DISPS(play->state.gfxCtx); - func_8012C588(globalCtx->state.gfxCtx); + func_8012C588(play->state.gfxCtx); gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, dispObj->color.r, dispObj->color.g, dispObj->color.b, dispObj->color.a); 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); + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_XLU_DISP++, arg1); - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->state.gfxCtx); } s32 D_801BB068[] = { @@ -110,16 +110,16 @@ s32 D_801BB08C = 0; Gfx* func_800E99B0(GraphicsContext* gfxCtx, s32 arg1); -void func_800E992C(GlobalContext* globalCtx, s32 arg1) { +void func_800E992C(PlayState* play, s32 arg1) { s32 pad; - OPEN_DISPS(globalCtx->state.gfxCtx); + OPEN_DISPS(play->state.gfxCtx); - func_8012C560(globalCtx->state.gfxCtx); + func_8012C560(play->state.gfxCtx); gSPMatrix(POLY_XLU_DISP++, &gIdentityMtx, G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - gSPDisplayList(POLY_XLU_DISP++, func_800E99B0(globalCtx->state.gfxCtx, arg1)); + gSPDisplayList(POLY_XLU_DISP++, func_800E99B0(play->state.gfxCtx, arg1)); - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->state.gfxCtx); } #pragma GLOBAL_ASM("asm/non_matchings/code/z_debug_display/func_800E99B0.s") diff --git a/src/code/z_demo.c b/src/code/z_demo.c index 0af7dfb4d..8923669a7 100644 --- a/src/code/z_demo.c +++ b/src/code/z_demo.c @@ -1,14 +1,14 @@ -#include "prevent_bss_reordering.h" #include "global.h" +#include "z64rumble.h" #include "overlays/gamestates/ovl_daytelop/z_daytelop.h" -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); +void Cutscene_DoNothing(PlayState* play, CutsceneContext* csCtx); +void func_800EA258(PlayState* play, CutsceneContext* csCtx); +void func_800ED9C4(PlayState* play, CutsceneContext* csCtx); +void func_800EA2B8(PlayState* play, CutsceneContext* csCtx); +void func_800ED980(PlayState* play, CutsceneContext* csCtx); +void func_800EDA04(PlayState* play, CutsceneContext* csCtx); +void func_800EDA84(PlayState* play, CutsceneContext* csCtx); // Unused UNK_TYPE4 D_801BB120 = 0; @@ -28,14 +28,14 @@ UNK_TYPE D_801F4DDC; u8 D_801F4DE0; s16 D_801F4DE2; -void Cutscene_Init(GlobalContext* globalCtx, CutsceneContext* csCtx) { +void Cutscene_Init(PlayState* play, CutsceneContext* csCtx) { s32 i; csCtx->state = CS_STATE_0; csCtx->frames = 0; csCtx->unk_0C = 0.0f; - globalCtx->csCtx.sceneCsCount = 0; - globalCtx->csCtx.currentCsIndex = 0; + play->csCtx.sceneCsCount = 0; + play->csCtx.currentCsIndex = 0; for (i = 0; i < ARRAY_COUNT(D_801F4DC8); i++) { D_801F4DC8[i] = 0; @@ -46,18 +46,18 @@ void Cutscene_Init(GlobalContext* globalCtx, CutsceneContext* csCtx) { Audio_SetCutsceneFlag(false); } -void Cutscene_Start(GlobalContext* globalCtx, CutsceneContext* csCtx) { +void Cutscene_Start(PlayState* play, CutsceneContext* csCtx) { csCtx->state = CS_STATE_1; csCtx->playerAction = NULL; } -void Cutscene_End(GlobalContext* globalCtx, CutsceneContext* csCtx) { +void Cutscene_End(PlayState* play, CutsceneContext* csCtx) { if (csCtx->state != CS_STATE_4) { csCtx->state = CS_STATE_3; } } -typedef void (*CutsceneStateHandler)(GlobalContext* globalCtx, CutsceneContext* csCtx); +typedef void (*CutsceneStateHandler)(PlayState* play, CutsceneContext* csCtx); CutsceneStateHandler sCsStateHandlers1[] = { Cutscene_DoNothing, // CS_STATE_0 @@ -67,9 +67,9 @@ CutsceneStateHandler sCsStateHandlers1[] = { Cutscene_DoNothing, // CS_STATE_4 }; -void Cutscene_Update1(GlobalContext* globalCtx, CutsceneContext* csCtx) { +void Cutscene_Update1(PlayState* play, CutsceneContext* csCtx) { if (gSaveContext.save.cutscene < 0xFFF0) { - sCsStateHandlers1[csCtx->state](globalCtx, csCtx); + sCsStateHandlers1[csCtx->state](play, csCtx); } } @@ -81,8 +81,8 @@ CutsceneStateHandler sCsStateHandlers2[] = { func_800ED980, // CS_STATE_4 }; -void Cutscene_Update2(GlobalContext* globalCtx, CutsceneContext* csCtx) { - if ((gSaveContext.cutsceneTrigger != 0) && (globalCtx->sceneLoadFlag == 0x14)) { +void Cutscene_Update2(PlayState* play, CutsceneContext* csCtx) { + if ((gSaveContext.cutsceneTrigger != 0) && (play->transitionTrigger == TRANS_TRIGGER_START)) { gSaveContext.cutsceneTrigger = 0; } @@ -92,32 +92,32 @@ void Cutscene_Update2(GlobalContext* globalCtx, CutsceneContext* csCtx) { } if (gSaveContext.save.cutscene >= 0xFFF0) { - func_800EDA84(globalCtx, csCtx); - sCsStateHandlers2[csCtx->state](globalCtx, csCtx); + func_800EDA84(play, csCtx); + sCsStateHandlers2[csCtx->state](play, csCtx); } } -void Cutscene_DoNothing(GlobalContext* globalCtx, CutsceneContext* csCtx) { +void Cutscene_DoNothing(PlayState* play, CutsceneContext* csCtx) { } -s32 func_800EA220(GlobalContext* globalCtx, CutsceneContext* csCtx, f32 target) { +s32 func_800EA220(PlayState* play, CutsceneContext* csCtx, f32 target) { return Math_StepToF(&csCtx->unk_0C, target, 0.1f); } -void func_800EA258(GlobalContext* globalCtx, CutsceneContext* csCtx) { +void func_800EA258(PlayState* play, CutsceneContext* csCtx) { Interface_ChangeAlpha(1); ShrinkWindow_SetLetterboxTarget(32); - if (func_800EA220(globalCtx, csCtx, 1.0f)) { + if (func_800EA220(play, csCtx, 1.0f)) { Audio_SetCutsceneFlag(true); csCtx->state++; } } -void func_800EA2B8(GlobalContext* globalCtx, CutsceneContext* csCtx) { - func_800ED980(globalCtx, csCtx); +void func_800EA2B8(PlayState* play, CutsceneContext* csCtx) { + func_800ED980(play, csCtx); Interface_ChangeAlpha(1); ShrinkWindow_SetLetterboxTarget(32); - if (func_800EA220(globalCtx, csCtx, 1.0f)) { + if (func_800EA220(play, csCtx, 1.0f)) { Audio_SetCutsceneFlag(true); csCtx->state++; } @@ -126,14 +126,13 @@ void func_800EA2B8(GlobalContext* globalCtx, CutsceneContext* csCtx) { /* Start of command handling section */ // Command 0x96: Miscellaneous commands. -void Cutscene_Command_Misc(GlobalContext* globalCtx2, CutsceneContext* csCtx, CsCmdBase* cmd) { +void Cutscene_Command_Misc(PlayState* play2, CutsceneContext* csCtx, CsCmdBase* cmd) { static u16 D_801BB15C = 0xFFFF; - Player* player = GET_PLAYER(globalCtx2); - GlobalContext* globalCtx = globalCtx2; + Player* player = GET_PLAYER(play2); + PlayState* play = play2; u8 isStartFrame = false; f32 progress; SceneTableEntry* loadedScene; - u16 time; if ((csCtx->frames < cmd->startFrame) || ((csCtx->frames >= cmd->endFrame) && (cmd->endFrame != cmd->startFrame))) { return; @@ -148,33 +147,33 @@ void Cutscene_Command_Misc(GlobalContext* globalCtx2, CutsceneContext* csCtx, Cs switch (cmd->base) { case 0x1: if (isStartFrame) { - func_800FD78C(globalCtx); - globalCtx->envCtx.unk_F2[0] = 0x3C; + func_800FD78C(play); + play->envCtx.unk_F2[0] = 0x3C; } break; case 0x2: if (isStartFrame) { func_801A47DC(NATURE_CHANNEL_LIGHTNING, CHANNEL_IO_PORT_0, 0); - Environment_AddLightningBolts(globalCtx, 3); + Environment_AddLightningBolts(play, 3); D_801F4E68 = 1; } break; case 0x3: - if (globalCtx->envCtx.lightSettings.fogFar < 12800) { - globalCtx->envCtx.lightSettings.fogFar += 35; + if (play->envCtx.lightSettings.fogFar < 12800) { + play->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; + play->envCtx.unk_19 = 1; + play->envCtx.unk_17 = 1; + play->envCtx.unk_18 = 0; + play->envCtx.unk_1A = 0x3C; + play->envCtx.unk_21 = 1; + play->envCtx.unk_1F = 0; + play->envCtx.unk_20 = 1; + play->envCtx.unk_24 = 0x3C; + play->envCtx.unk_22 = play->envCtx.unk_24; } break; case 0x5: @@ -184,16 +183,16 @@ void Cutscene_Command_Misc(GlobalContext* globalCtx2, CutsceneContext* csCtx, Cs break; case 0x7: if (isStartFrame) { - loadedScene = globalCtx->loadedScene; + loadedScene = play->loadedScene; if (loadedScene->titleTextId != 0) { - func_80151A68(globalCtx, loadedScene->titleTextId); + func_80151A68(play, loadedScene->titleTextId); } } break; case 0x8: func_8019F128(NA_SE_EV_EARTHQUAKE_LAST - SFX_FLAG); if (isStartFrame) { - sCutsceneQuakeIndex = Quake_Add(GET_ACTIVE_CAM(globalCtx), 6); + sCutsceneQuakeIndex = Quake_Add(GET_ACTIVE_CAM(play), 6); Quake_SetSpeed(sCutsceneQuakeIndex, 22000); Quake_SetQuakeValues(sCutsceneQuakeIndex, 6, 4, 0, 0); Quake_SetCountdown(sCutsceneQuakeIndex, 800); @@ -217,32 +216,32 @@ void Cutscene_Command_Misc(GlobalContext* globalCtx2, CutsceneContext* csCtx, Cs D_801F6D30.a = 255 * progress; break; case 0xC: - globalCtx->roomCtx.currRoom.segment = NULL; + play->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; + if (play->state.frames & 8) { + if (play->envCtx.lightSettings.ambientColor[0] < 40) { + play->envCtx.lightSettings.ambientColor[0] += 2; + play->envCtx.lightSettings.diffuseColor1[1] -= 3; + play->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; + if (play->envCtx.lightSettings.ambientColor[0] > 2) { + play->envCtx.lightSettings.ambientColor[0] -= 2; + play->envCtx.lightSettings.diffuseColor1[1] += 3; + play->envCtx.lightSettings.diffuseColor1[2] += 3; } } break; case 0xE: - globalCtx->unk_18845 = 1; + play->unk_18845 = 1; break; case 0xF: - globalCtx->unk_18845 = 0; + play->unk_18845 = 0; break; case 0x10: if (isStartFrame) { - globalCtx->envCtx.sandstormState = 1; + play->envCtx.sandstormState = 1; } func_8019F128(NA_SE_EV_SAND_STORM - SFX_FLAG); break; @@ -251,23 +250,20 @@ void Cutscene_Command_Misc(GlobalContext* globalCtx2, CutsceneContext* csCtx, Cs break; case 0x12: if (!gSaveContext.save.isNight) { - time = gSaveContext.save.time; - gSaveContext.save.time = time - (u16)REG(15); + gSaveContext.save.time = ((void)0, gSaveContext.save.time) - (u16)REG(15); } else { - time = gSaveContext.save.time; - gSaveContext.save.time = time - (u16)(2 * REG(15)); + gSaveContext.save.time = ((void)0, gSaveContext.save.time) - (u16)(2 * REG(15)); } break; case 0x13: - // AudioOcarina_PlayLongScarecrowAfterCredits - func_8019D758(); + AudioOcarina_PlayLongScarecrowAfterCredits(); csCtx->frames = cmd->startFrame - 1; break; case 0x14: - EnvFlags_Set(globalCtx, 3); + EnvFlags_Set(play, 3); break; case 0x15: - EnvFlags_Set(globalCtx, 4); + EnvFlags_Set(play, 4); break; case 0x16: gSaveContext.save.playerForm = PLAYER_FORM_DEKU; @@ -286,7 +282,7 @@ void Cutscene_Command_Misc(GlobalContext* globalCtx2, CutsceneContext* csCtx, Cs case 0x1A: func_8019F128(NA_SE_EV_EARTHQUAKE_LAST2 - SFX_FLAG); if (isStartFrame) { - sCutsceneQuakeIndex = Quake_Add(GET_ACTIVE_CAM(globalCtx), 6); + sCutsceneQuakeIndex = Quake_Add(GET_ACTIVE_CAM(play), 6); Quake_SetSpeed(sCutsceneQuakeIndex, 30000); Quake_SetQuakeValues(sCutsceneQuakeIndex, 20, 10, 0, 0); Quake_SetCountdown(sCutsceneQuakeIndex, 800); @@ -294,15 +290,15 @@ void Cutscene_Command_Misc(GlobalContext* globalCtx2, CutsceneContext* csCtx, Cs break; case 0x1B: if (isStartFrame) { - globalCtx->nextEntranceIndex = 0x1C00; + play->nextEntrance = ENTRANCE(CUTSCENE, 0); gSaveContext.nextCutsceneIndex = 0xFFF8; - globalCtx->sceneLoadFlag = 0x14; - globalCtx->unk_1887F = 3; + play->transitionTrigger = TRANS_TRIGGER_START; + play->transitionType = TRANS_TYPE_03; } break; case 0x1C: if (isStartFrame) { - globalCtx->envCtx.unk_17 = 0xD; + play->envCtx.unk_17 = 0xD; } break; case 0x1D: @@ -316,12 +312,12 @@ void Cutscene_Command_Misc(GlobalContext* globalCtx2, CutsceneContext* csCtx, Cs break; case 0x21: if (isStartFrame) { - Sram_SaveSpecialEnterClockTown(globalCtx); + Sram_SaveSpecialEnterClockTown(play); } break; case 0x22: if (isStartFrame) { - func_80144A94(&globalCtx->sramCtx); + func_80144A94(&play->sramCtx); } break; case 0x23: @@ -329,17 +325,16 @@ void Cutscene_Command_Misc(GlobalContext* globalCtx2, CutsceneContext* csCtx, Cs D_801BB15C = csCtx->frames; if (REG(15) != 0) { - time = gSaveContext.save.time; - gSaveContext.save.time = (u16)REG(15) + time; - time = gSaveContext.save.time; - gSaveContext.save.time = (u16)gSaveContext.save.daySpeed + time; + 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); + sCutsceneQuakeIndex = Quake_Add(GET_ACTIVE_CAM(play), 6); Quake_SetSpeed(sCutsceneQuakeIndex, 22000); Quake_SetQuakeValues(sCutsceneQuakeIndex, 2, 1, 0, 0); Quake_SetCountdown(sCutsceneQuakeIndex, 800); @@ -352,12 +347,12 @@ void Cutscene_Command_Misc(GlobalContext* globalCtx2, CutsceneContext* csCtx, Cs gSaveContext.save.day = 9; { - GameState* gameState = &globalCtx->state; + GameState* gameState = &play->state; gameState->running = false; } - SET_NEXT_GAMESTATE(&globalCtx->state, Daytelop_Init, DaytelopContext); + SET_NEXT_GAMESTATE(&play->state, Daytelop_Init, DaytelopContext); - Sram_SaveSpecialNewDay(globalCtx); + Sram_SaveSpecialNewDay(play); break; case 0x27: @@ -371,33 +366,33 @@ void Cutscene_Command_Misc(GlobalContext* globalCtx2, CutsceneContext* csCtx, Cs } // Command 0x97: Set Environment Lighting -void Cutscene_Command_SetLighting(GlobalContext* globalCtx, CutsceneContext* csCtx, CsCmdEnvLighting* cmd) { +void Cutscene_Command_SetLighting(PlayState* play, CutsceneContext* csCtx, CsCmdEnvLighting* cmd) { if (csCtx->frames == cmd->startFrame) { if (cmd->setting != 0x20) { - globalCtx->envCtx.lightSettingOverride = cmd->setting - 1; - globalCtx->envCtx.lightBlend = 1.0f; + play->envCtx.lightSettingOverride = cmd->setting - 1; + play->envCtx.lightBlend = 1.0f; } else { - globalCtx->envCtx.lightSettingOverride = 0xFF; + play->envCtx.lightSettingOverride = 0xFF; } } } // Command 0x12C: Plays a sequence (Background music or Fanfare) -void Cutscene_Command_PlaySequence(GlobalContext* globalCtx, CutsceneContext* csCtx, CsCmdSequenceChange* cmd) { +void Cutscene_Command_PlaySequence(PlayState* play, 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) { +void Cutscene_Command_StopSequence(PlayState* play, 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) { +void Cutscene_Command_FadeSequence(PlayState* play, CutsceneContext* csCtx, CsCmdSequenceFade* cmd) { if ((csCtx->frames == cmd->startFrame) && (csCtx->frames < cmd->endFrame)) { u8 fadeTimer = cmd->endFrame - cmd->startFrame; @@ -410,16 +405,16 @@ void Cutscene_Command_FadeSequence(GlobalContext* globalCtx, CutsceneContext* cs } // Command 0x12E: Play Ambience sequence -void Cutscene_Command_PlayAmbienceSequence(GlobalContext* globalCtx, CutsceneContext* csCtx, CsCmdBase* cmd) { +void Cutscene_Command_PlayAmbienceSequence(PlayState* play, CutsceneContext* csCtx, CsCmdBase* cmd) { if (csCtx->frames == cmd->startFrame) { // Audio_PlayNatureAmbienceSequence // nightSeqIndex is natureAmbienceId - func_801A4A28(globalCtx->soundCtx.nightSeqIndex); + func_801A4A28(play->soundCtx.nightSeqIndex); } } // Command 0x130: -void func_800EAD48(GlobalContext* globalCtx, CutsceneContext* csCtx, CsCmdBase* cmd) { +void func_800EAD48(PlayState* play, CutsceneContext* csCtx, CsCmdBase* cmd) { if (csCtx->frames == cmd->startFrame) { // Audio_SetSfxReverbIndexExceptOcarinaBank func_801A4428(2); @@ -427,7 +422,7 @@ void func_800EAD48(GlobalContext* globalCtx, CutsceneContext* csCtx, CsCmdBase* } // Command 0x131: -void func_800EAD7C(GlobalContext* globalCtx, CutsceneContext* csCtx, CsCmdBase* cmd) { +void func_800EAD7C(PlayState* play, CutsceneContext* csCtx, CsCmdBase* cmd) { if (csCtx->frames == cmd->startFrame) { // Audio_SetSfxReverbIndexExceptOcarinaBank func_801A4428(1); @@ -437,7 +432,7 @@ void func_800EAD7C(GlobalContext* globalCtx, CutsceneContext* csCtx, CsCmdBase* #ifdef NON_MATCHING // needs in-function static bss // audio related -void func_800EADB0(GlobalContext* globalCtx, CutsceneContext* csCtx, CsCmdBase* cmd) { +void func_800EADB0(PlayState* play, CutsceneContext* csCtx, CsCmdBase* cmd) { static u16 seqId; u8 dayMinusOne; @@ -493,11 +488,12 @@ void func_800EADB0(GlobalContext* globalCtx, CutsceneContext* csCtx, CsCmdBase* } } #else +void func_800EADB0(PlayState* play, CutsceneContext* csCtx, CsCmdBase* cmd); #pragma GLOBAL_ASM("asm/non_matchings/code/z_demo/func_800EADB0.s") #endif // Command 0x12F: Fade Ambience sequence -void Cutscene_Command_FadeAmbienceSequence(GlobalContext* globalCtx, CutsceneContext* csCtx, CsCmdBase* cmd) { +void Cutscene_Command_FadeAmbienceSequence(PlayState* play, CutsceneContext* csCtx, CsCmdBase* cmd) { if (csCtx->frames == cmd->startFrame && csCtx->frames < cmd->endFrame) { u8 fadeTimer = cmd->endFrame - cmd->startFrame; @@ -506,18 +502,18 @@ void Cutscene_Command_FadeAmbienceSequence(GlobalContext* globalCtx, CutsceneCon } // Command 0x190: Rumble -void Cutscene_Command_Rumble(GlobalContext* globalCtx, CutsceneContext* csCtx, CsCmdRumble* cmd) { +void Cutscene_Command_Rumble(PlayState* play, CutsceneContext* csCtx, CsCmdRumble* cmd) { switch (cmd->type) { case 1: if (csCtx->frames == cmd->startFrame) { - func_8013ECE0(0.0f, cmd->unk6, cmd->unk7, cmd->unk8); + Rumble_Request(0.0f, cmd->intensity, cmd->decayTimer, cmd->decayStep); } break; case 2: if ((csCtx->frames >= cmd->startFrame) && (cmd->endFrame >= csCtx->frames)) { - if ((csCtx->frames == cmd->startFrame) || (globalCtx->state.frames % 64 == 0)) { - func_8013ECE0(0.0f, cmd->unk6, cmd->unk7, cmd->unk8); + if ((csCtx->frames == cmd->startFrame) || (play->state.frames % 64 == 0)) { + Rumble_Request(0.0f, cmd->intensity, cmd->decayTimer, cmd->decayStep); } } break; @@ -525,29 +521,29 @@ void Cutscene_Command_Rumble(GlobalContext* globalCtx, CutsceneContext* csCtx, C } // Command 0x9B: -void Cutscene_Command_FadeColorScreen(GlobalContext* globalCtx, CutsceneContext* csCtx, CsCmdFadeScreen* cmd) { +void Cutscene_Command_FadeColorScreen(PlayState* play, CutsceneContext* csCtx, CsCmdFadeScreen* cmd) { if ((csCtx->frames >= cmd->startFrame) && (cmd->endFrame >= csCtx->frames)) { f32 alpha; - globalCtx->envCtx.fillScreen = true; + play->envCtx.fillScreen = true; alpha = Environment_LerpWeight(cmd->endFrame, cmd->startFrame, csCtx->frames); 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; + play->envCtx.screenFillColor[0] = cmd->color.r; + play->envCtx.screenFillColor[1] = cmd->color.g; + play->envCtx.screenFillColor[2] = cmd->color.b; if (cmd->unk0 == 2) { - globalCtx->envCtx.screenFillColor[3] = (1.0f - alpha) * 255.0f; + play->envCtx.screenFillColor[3] = (1.0f - alpha) * 255.0f; } else { - globalCtx->envCtx.screenFillColor[3] = 255.0f * alpha; + play->envCtx.screenFillColor[3] = 255.0f * alpha; } } } } // Command 0x9D: Set Time of Day & Environment Time -void Cutscene_Command_SetTime(GlobalContext* globalCtx, CutsceneContext* csCtx, CsCmdDayTime* cmd) { +void Cutscene_Command_SetTime(PlayState* play, CutsceneContext* csCtx, CsCmdDayTime* cmd) { u16 nextTime; u16 hourAsMinutes; u16 minutes; @@ -558,15 +554,15 @@ void Cutscene_Command_SetTime(GlobalContext* globalCtx, CutsceneContext* csCtx, nextTime = hourAsMinutes + minutes; gSaveContext.save.time = nextTime; - gSaveContext.environmentTime = nextTime; + gSaveContext.skyboxTime = nextTime; } } -void Cutscene_TerminatorImpl(GlobalContext* globalCtx, CutsceneContext* csCtx, CsCmdBase* cmd) { +void Cutscene_TerminatorImpl(PlayState* play, CutsceneContext* csCtx, CsCmdBase* cmd) { csCtx->state = CS_STATE_4; func_80165690(); Audio_SetCutsceneFlag(false); - gSaveContext.unk_3F48 = 1; + gSaveContext.cutsceneTransitionControl = 1; if ((gSaveContext.gameMode != 0) && (csCtx->frames != cmd->startFrame)) { gSaveContext.unk_3F1E = 1; @@ -574,32 +570,32 @@ void Cutscene_TerminatorImpl(GlobalContext* globalCtx, CutsceneContext* csCtx, C gSaveContext.save.cutscene = 0; if (cmd->base == 1) { - globalCtx->nextEntranceIndex = globalCtx->csCtx.sceneCsList[globalCtx->csCtx.currentCsIndex].nextEntranceIndex; + play->nextEntrance = play->csCtx.sceneCsList[play->csCtx.currentCsIndex].nextEntrance; gSaveContext.nextCutsceneIndex = 0; - globalCtx->sceneLoadFlag = 0x14; + play->transitionTrigger = TRANS_TRIGGER_START; if (gSaveContext.gameMode != 1) { - Scene_SetExitFade(globalCtx); + Scene_SetExitFade(play); } else { D_801BB12C++; if (D_801BB12C >= 2) { D_801BB12C = 0; } - globalCtx->unk_1887F = 4; + play->transitionType = TRANS_TYPE_04; } - if ((globalCtx->nextEntranceIndex & 0xF) > 0) { - gSaveContext.nextCutsceneIndex = (globalCtx->nextEntranceIndex & 0xF) + 0xFFEF; + if ((play->nextEntrance & 0xF) > 0) { + gSaveContext.nextCutsceneIndex = (play->nextEntrance & 0xF) + 0xFFEF; } - globalCtx->nextEntranceIndex &= ~0xF; + play->nextEntrance &= ~0xF; } } // Command 0x15E -void Cutscene_Command_Terminator(GlobalContext* globalCtx, CutsceneContext* csCtx, CsCmdBase* cmd) { +void Cutscene_Command_Terminator(PlayState* play, CutsceneContext* csCtx, CsCmdBase* cmd) { if (cmd->base == 1) { if (csCtx->frames == cmd->startFrame) { - Cutscene_TerminatorImpl(globalCtx, csCtx, cmd); + Cutscene_TerminatorImpl(play, csCtx, cmd); } } else if (cmd->base == 2) { if (csCtx->frames == cmd->startFrame) { @@ -608,44 +604,44 @@ void Cutscene_Command_Terminator(GlobalContext* globalCtx, CutsceneContext* csCt switch (D_801F4DE2) { case 0x1F: if (gSaveContext.save.weekEventReg[20] & 2) { - globalCtx->nextEntranceIndex = 0x3010; - globalCtx->sceneLoadFlag = 0x14; - globalCtx->unk_1887F = 3; + play->nextEntrance = ENTRANCE(WOODFALL_TEMPLE, 1); + play->transitionTrigger = TRANS_TRIGGER_START; + play->transitionType = TRANS_TYPE_03; } else { - globalCtx->nextEntranceIndex = 0x8600; + play->nextEntrance = ENTRANCE(WOODFALL, 0); gSaveContext.nextCutsceneIndex = 0xFFF0; - globalCtx->sceneLoadFlag = 0x14; - globalCtx->unk_1887F = 3; + play->transitionTrigger = TRANS_TRIGGER_START; + play->transitionType = TRANS_TYPE_03; } break; case 0x44: if (gSaveContext.save.weekEventReg[33] & 0x80) { - globalCtx->nextEntranceIndex = 0xAE70; - globalCtx->sceneLoadFlag = 0x14; - globalCtx->unk_1887F = 3; + play->nextEntrance = ENTRANCE(MOUNTAIN_VILLAGE_SPRING, 7); + play->transitionTrigger = TRANS_TRIGGER_START; + play->transitionType = TRANS_TYPE_03; } else { - globalCtx->nextEntranceIndex = 0xAE00; + play->nextEntrance = ENTRANCE(MOUNTAIN_VILLAGE_SPRING, 0); gSaveContext.nextCutsceneIndex = 0xFFF0; - globalCtx->sceneLoadFlag = 0x14; - globalCtx->unk_1887F = 3; + play->transitionTrigger = TRANS_TRIGGER_START; + play->transitionType = TRANS_TYPE_03; } break; case 0x5F: gSaveContext.save.weekEventReg[55] |= 0x80; - globalCtx->nextEntranceIndex = 0x6A80; + play->nextEntrance = ENTRANCE(ZORA_CAPE, 8); gSaveContext.nextCutsceneIndex = 0xFFF0; - globalCtx->sceneLoadFlag = 0x14; - globalCtx->unk_1887F = 3; + play->transitionTrigger = TRANS_TRIGGER_START; + play->transitionType = TRANS_TYPE_03; break; case 0x36: gSaveContext.save.weekEventReg[52] |= 0x20; - globalCtx->nextEntranceIndex = 0x2000; + play->nextEntrance = ENTRANCE(IKANA_CANYON, 0); gSaveContext.nextCutsceneIndex = 0xFFF1; - globalCtx->sceneLoadFlag = 0x14; - globalCtx->unk_1887F = 3; + play->transitionTrigger = TRANS_TRIGGER_START; + play->transitionType = TRANS_TYPE_03; break; } } @@ -654,142 +650,123 @@ void Cutscene_Command_Terminator(GlobalContext* globalCtx, CutsceneContext* csCt // 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) { +void Cutscene_Command_ChooseCreditsScenes(PlayState* play, CutsceneContext* csCtx, CsCmdBase* cmd) { if ((csCtx->frames >= cmd->startFrame) && (func_801A3950(0, true) != 0xFF)) { switch (cmd->base) { case 1: - Cutscene_TerminatorImpl(globalCtx, csCtx, cmd); + Cutscene_TerminatorImpl(play, csCtx, cmd); break; case 2: if (INV_CONTENT(ITEM_MASK_KAMARO) == ITEM_MASK_KAMARO) { - // Milk bar - globalCtx->nextEntranceIndex = 0x2400; + play->nextEntrance = ENTRANCE(MILK_BAR, 0); gSaveContext.nextCutsceneIndex = 0xFFF0; } else { - // SPOT00 - globalCtx->nextEntranceIndex = 0x1C00; + play->nextEntrance = ENTRANCE(CUTSCENE, 0); gSaveContext.nextCutsceneIndex = 0xFFF9; } - globalCtx->sceneLoadFlag = 0x14; + play->transitionTrigger = TRANS_TRIGGER_START; break; case 3: if (INV_CONTENT(ITEM_MASK_GREAT_FAIRY) == ITEM_MASK_GREAT_FAIRY) { - // Fairy's fountain - globalCtx->nextEntranceIndex = 0x4600; + play->nextEntrance = ENTRANCE(FAIRY_FOUNTAIN, 0); gSaveContext.nextCutsceneIndex = 0xFFF0; } else { - // SPOT00 - globalCtx->nextEntranceIndex = 0x1C10; + play->nextEntrance = ENTRANCE(CUTSCENE, 1); gSaveContext.nextCutsceneIndex = 0xFFF9; } - globalCtx->sceneLoadFlag = 0x14; + play->transitionTrigger = TRANS_TRIGGER_START; break; case 4: if (INV_CONTENT(ITEM_MASK_ROMANI) == ITEM_MASK_ROMANI) { - // Romani ranch - globalCtx->nextEntranceIndex = 0x6400; + play->nextEntrance = ENTRANCE(ROMANI_RANCH, 0); gSaveContext.nextCutsceneIndex = 0xFFF1; } else { - // SPOT00 - globalCtx->nextEntranceIndex = 0x1C20; + play->nextEntrance = ENTRANCE(CUTSCENE, 2); gSaveContext.nextCutsceneIndex = 0xFFF9; } - globalCtx->sceneLoadFlag = 0x14; + play->transitionTrigger = TRANS_TRIGGER_START; break; case 5: if (INV_CONTENT(ITEM_MASK_BLAST) == ITEM_MASK_BLAST) { - // West clock town - globalCtx->nextEntranceIndex = 0xD400; + play->nextEntrance = ENTRANCE(WEST_CLOCK_TOWN, 0); gSaveContext.nextCutsceneIndex = 0xFFF0; } else { - // SPOT00 - globalCtx->nextEntranceIndex = 0x1C30; + play->nextEntrance = ENTRANCE(CUTSCENE, 3); gSaveContext.nextCutsceneIndex = 0xFFF9; } - globalCtx->sceneLoadFlag = 0x14; + play->transitionTrigger = TRANS_TRIGGER_START; break; case 6: if (INV_CONTENT(ITEM_MASK_CIRCUS_LEADER) == ITEM_MASK_CIRCUS_LEADER) { - // Milk bar - globalCtx->nextEntranceIndex = 0x2400; + play->nextEntrance = ENTRANCE(MILK_BAR, 0); gSaveContext.nextCutsceneIndex = 0xFFF1; } else { - // SPOT00 - globalCtx->nextEntranceIndex = 0x1C50; + play->nextEntrance = ENTRANCE(CUTSCENE, 5); gSaveContext.nextCutsceneIndex = 0xFFF9; } - globalCtx->sceneLoadFlag = 0x14; + play->transitionTrigger = TRANS_TRIGGER_START; break; case 7: if (INV_CONTENT(ITEM_MASK_BREMEN) == ITEM_MASK_BREMEN) { - // Milk bar - globalCtx->nextEntranceIndex = 0x2400; + play->nextEntrance = ENTRANCE(MILK_BAR, 0); gSaveContext.nextCutsceneIndex = 0xFFF3; } else { - // SPOT00 - globalCtx->nextEntranceIndex = 0x1C60; + play->nextEntrance = ENTRANCE(CUTSCENE, 6); gSaveContext.nextCutsceneIndex = 0xFFF9; } - globalCtx->sceneLoadFlag = 0x14; + play->transitionTrigger = TRANS_TRIGGER_START; break; case 8: - // Ikana canyon - globalCtx->nextEntranceIndex = 0x2000; + play->nextEntrance = ENTRANCE(IKANA_CANYON, 0); gSaveContext.nextCutsceneIndex = 0xFFF3; - globalCtx->sceneLoadFlag = 0x14; + play->transitionTrigger = TRANS_TRIGGER_START; break; case 9: if (INV_CONTENT(ITEM_MASK_COUPLE) == ITEM_MASK_COUPLE) { - // Termina field - globalCtx->nextEntranceIndex = 0x5400; + play->nextEntrance = ENTRANCE(TERMINA_FIELD, 0); gSaveContext.nextCutsceneIndex = 0xFFF8; } else { - // SPOT00 - globalCtx->nextEntranceIndex = 0x1C70; + play->nextEntrance = ENTRANCE(CUTSCENE, 7); gSaveContext.nextCutsceneIndex = 0xFFF9; } - globalCtx->sceneLoadFlag = 0x14; + play->transitionTrigger = TRANS_TRIGGER_START; break; case 10: if (INV_CONTENT(ITEM_MASK_BUNNY) == ITEM_MASK_BUNNY) { - // Cucco shack - globalCtx->nextEntranceIndex = 0x7E00; + play->nextEntrance = ENTRANCE(CUCCO_SHACK, 0); gSaveContext.nextCutsceneIndex = 0xFFF0; } else { - // SPOT00 - globalCtx->nextEntranceIndex = 0x1C40; + play->nextEntrance = ENTRANCE(CUTSCENE, 4); gSaveContext.nextCutsceneIndex = 0xFFF9; } - globalCtx->sceneLoadFlag = 0x14; + play->transitionTrigger = TRANS_TRIGGER_START; break; case 11: if (INV_CONTENT(ITEM_MASK_POSTMAN) == ITEM_MASK_POSTMAN) { - // Termina field - globalCtx->nextEntranceIndex = 0x5410; + play->nextEntrance = ENTRANCE(TERMINA_FIELD, 1); gSaveContext.nextCutsceneIndex = 0xFFF8; } else { - // SPOT00 - globalCtx->nextEntranceIndex = 0x1C80; + play->nextEntrance = ENTRANCE(CUTSCENE, 8); gSaveContext.nextCutsceneIndex = 0xFFF9; } - globalCtx->sceneLoadFlag = 0x14; + play->transitionTrigger = TRANS_TRIGGER_START; break; } } } // Command 0x99: Motion blur -void Cutscene_Command_MotionBlur(GlobalContext* globalCtx, CutsceneContext* csCtx, CsCmdBase* cmd) { +void Cutscene_Command_MotionBlur(PlayState* play, CutsceneContext* csCtx, CsCmdBase* cmd) { if ((csCtx->frames >= cmd->startFrame) && (cmd->endFrame >= csCtx->frames)) { if ((csCtx->frames == cmd->startFrame) && (cmd->base == 1)) { func_8016566C(180); @@ -808,8 +785,8 @@ void Cutscene_Command_MotionBlur(GlobalContext* globalCtx, CutsceneContext* csCt } // Command 0x9A: Gives Tatl to the player -void Cutscene_Command_GiveTatlToPlayer(GlobalContext* globalCtx, CutsceneContext* csCtx, CsCmdBase* cmd) { - Player* player = GET_PLAYER(globalCtx); +void Cutscene_Command_GiveTatlToPlayer(PlayState* play, CutsceneContext* csCtx, CsCmdBase* cmd) { + Player* player = GET_PLAYER(play); if (csCtx->frames == cmd->startFrame) { if (cmd->base == 1) { @@ -817,112 +794,112 @@ void Cutscene_Command_GiveTatlToPlayer(GlobalContext* globalCtx, CutsceneContext if (player->tatlActor != NULL) { return; } - player->tatlActor = Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_ELF, player->actor.world.pos.x, + player->tatlActor = Actor_Spawn(&play->actorCtx, play, 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) { +void Cutscene_Command_TransitionFX(PlayState* play, CutsceneContext* csCtx, CsCmdBase* cmd) { if ((csCtx->frames >= cmd->startFrame) && (cmd->endFrame >= csCtx->frames)) { f32 temp_f0; - globalCtx->envCtx.fillScreen = true; + play->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; + play->envCtx.screenFillColor[0] = 160; + play->envCtx.screenFillColor[1] = 160; + play->envCtx.screenFillColor[2] = 160; if (cmd->base == 1) { - globalCtx->envCtx.screenFillColor[3] = 255.0f * temp_f0; + play->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; + play->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; + play->envCtx.screenFillColor[0] = 0; + play->envCtx.screenFillColor[1] = 0; + play->envCtx.screenFillColor[2] = 255; if (cmd->base == 2) { - globalCtx->envCtx.screenFillColor[3] = 255.0f * temp_f0; + play->envCtx.screenFillColor[3] = 255.0f * temp_f0; } else { - globalCtx->envCtx.screenFillColor[3] = (1.0f - temp_f0) * 255.0f; + play->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; + play->envCtx.screenFillColor[0] = 255; + play->envCtx.screenFillColor[1] = 0; + play->envCtx.screenFillColor[2] = 0; if (cmd->base == 3) { - globalCtx->envCtx.screenFillColor[3] = (1.0f - temp_f0) * 255.0f; + play->envCtx.screenFillColor[3] = (1.0f - temp_f0) * 255.0f; } else { - globalCtx->envCtx.screenFillColor[3] = 255.0f * temp_f0; + play->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; + play->envCtx.screenFillColor[0] = 0; + play->envCtx.screenFillColor[1] = 255; + play->envCtx.screenFillColor[2] = 0; if (cmd->base == 4) { - globalCtx->envCtx.screenFillColor[3] = (1.0f - temp_f0) * 255.0f; + play->envCtx.screenFillColor[3] = (1.0f - temp_f0) * 255.0f; } else { - globalCtx->envCtx.screenFillColor[3] = 255.0f * temp_f0; + play->envCtx.screenFillColor[3] = 255.0f * temp_f0; } break; case 9: - gSaveContext.unk_3F48 = 1; + gSaveContext.cutsceneTransitionControl = 1; break; case 10: case 11: - globalCtx->envCtx.screenFillColor[0] = 0; - globalCtx->envCtx.screenFillColor[1] = 0; - globalCtx->envCtx.screenFillColor[2] = 0; + play->envCtx.screenFillColor[0] = 0; + play->envCtx.screenFillColor[1] = 0; + play->envCtx.screenFillColor[2] = 0; if (cmd->base == 10) { - globalCtx->envCtx.screenFillColor[3] = (1.0f - temp_f0) * 255.0f; + play->envCtx.screenFillColor[3] = (1.0f - temp_f0) * 255.0f; } else { - globalCtx->envCtx.screenFillColor[3] = 255.0f * temp_f0; + play->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; + play->envCtx.screenFillColor[0] = (160.0f * (1.0f - temp_f0)); + play->envCtx.screenFillColor[1] = play->envCtx.screenFillColor[0]; + play->envCtx.screenFillColor[2] = play->envCtx.screenFillColor[0]; + play->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; + play->envCtx.screenFillColor[0] = (160.0f * temp_f0); + play->envCtx.screenFillColor[1] = play->envCtx.screenFillColor[0]; + play->envCtx.screenFillColor[2] = play->envCtx.screenFillColor[0]; + play->envCtx.screenFillColor[3] = 255; break; } } } // Command 0x5A: Camera -s32 Cutscene_Command_Camera(GlobalContext* globalCtx, u8* cmd) { +s32 Cutscene_Command_Camera(PlayState* play, u8* cmd) { s32 sp1C = 0; bcopy(cmd, &sp1C, sizeof(s32)); cmd += sizeof(s32); - if (func_8016A168() == 0) { + if (!Play_IsDebugCamEnabled()) { func_80161998(cmd, &sCutsceneCameraInfo); } return sp1C + sizeof(s32); @@ -1000,9 +977,9 @@ s32 Cutscene_CountNormalMasks(void) { } // Command 0xA: Textbox -void Cutscene_Command_Textbox(GlobalContext* globalCtx, CutsceneContext* csCtx, CsCmdTextbox* cmd) { +void Cutscene_Command_Textbox(PlayState* play, CutsceneContext* csCtx, CsCmdTextbox* cmd) { static s32 D_801BB160 = CS_TEXTBOX_TYPE_DEFAULT; - u8 dialogState; + u8 talkState; s32 pad; u16 originalCsFrames; s32 pad2; @@ -1022,21 +999,21 @@ void Cutscene_Command_Textbox(GlobalContext* globalCtx, CutsceneContext* csCtx, 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); + Message_StartTextbox(play, cmd->textId1, NULL); } } else { - Message_StartTextbox(globalCtx, cmd->base, NULL); + Message_StartTextbox(play, 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); + Message_StartTextbox(play, cmd->textId1, NULL); } } else { - Message_StartTextbox(globalCtx, cmd->base, NULL); + Message_StartTextbox(play, cmd->base, NULL); } } else { - Message_StartTextbox(globalCtx, cmd->base, NULL); + Message_StartTextbox(play, cmd->base, NULL); } } else { goto else_label; @@ -1044,7 +1021,7 @@ void Cutscene_Command_Textbox(GlobalContext* globalCtx, CutsceneContext* csCtx, } else if (D_801BB128 != cmd->base) { D_801BB160 = CS_TEXTBOX_TYPE_LEARN_SONG; D_801BB128 = cmd->base; - func_80152434(globalCtx, cmd->base); + func_80152434(play, cmd->base); } else { else_label: if (csCtx->frames >= cmd->endFrame) { @@ -1052,17 +1029,18 @@ void Cutscene_Command_Textbox(GlobalContext* globalCtx, CutsceneContext* csCtx, // 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)) { + talkState = Message_GetState(&play->msgCtx); + if ((talkState != TEXT_STATE_CLOSING) && (talkState != TEXT_STATE_NONE) && (talkState != TEXT_STATE_7) && + (talkState != TEXT_STATE_8)) { csCtx->frames--; - if ((dialogState == 4) && Message_ShouldAdvance(globalCtx)) { - if (globalCtx->msgCtx.choiceIndex == 0) { + if ((talkState == TEXT_STATE_CHOICE) && Message_ShouldAdvance(play)) { + if (play->msgCtx.choiceIndex == 0) { if (cmd->base == 0x33BD) { func_8019F230(); } if (cmd->textId1 != 0xFFFF) { - func_80151938(globalCtx, cmd->textId1); + func_80151938(play, cmd->textId1); if (cmd->type == CS_TEXTBOX_TYPE_3) { D_801BB160 = CS_TEXTBOX_TYPE_3; if (cmd->textId2 != 0xFFFF) { @@ -1070,7 +1048,7 @@ void Cutscene_Command_Textbox(GlobalContext* globalCtx, CutsceneContext* csCtx, } } } else { - func_801477B4(globalCtx); + func_801477B4(play); csCtx->frames++; } } else { @@ -1079,7 +1057,7 @@ void Cutscene_Command_Textbox(GlobalContext* globalCtx, CutsceneContext* csCtx, } if (cmd->textId2 != 0xFFFF) { - func_80151938(globalCtx, cmd->textId2); + func_80151938(play, cmd->textId2); if (cmd->type == CS_TEXTBOX_TYPE_3) { D_801BB160 = CS_TEXTBOX_TYPE_3; if (cmd->textId1 != 0xFFFF) { @@ -1087,18 +1065,18 @@ void Cutscene_Command_Textbox(GlobalContext* globalCtx, CutsceneContext* csCtx, } } } else { - func_801477B4(globalCtx); + func_801477B4(play); csCtx->frames++; } } } - if (dialogState == 5 && Message_ShouldAdvance(globalCtx)) { - func_80152434(globalCtx, cmd->base); + if ((talkState == TEXT_STATE_5) && Message_ShouldAdvance(play)) { + func_80152434(play, cmd->base); } } - if ((dialogState == 2) && (D_801BB160 == CS_TEXTBOX_TYPE_3)) { + if ((talkState == TEXT_STATE_CLOSING) && (D_801BB160 == CS_TEXTBOX_TYPE_3)) { csCtx->frames--; D_801BB124++; } @@ -1134,8 +1112,6 @@ void func_800ECD7C(CutsceneContext* csCtx, u8** cutscenePtr, s16 index) { } } -#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). @@ -1162,16 +1138,15 @@ void func_800ECD7C(CutsceneContext* csCtx, u8** cutscenePtr, s16 index) { * * TODO: consider changing the type of `cutscenePtr` to `uintptr_t` when this function matches. */ -void Cutscene_ProcessCommands(GlobalContext* globalCtx, CutsceneContext* csCtx, u8* cutscenePtr) { +void Cutscene_ProcessCommands(PlayState* play, 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; + s32 totalEntries; + u32 cmdType; + s32 cmdEntries; + s32 pad2; + s32 cutsceneEndFrame; CsCmdBase* cmd; // Read the command list count and the ending frame for this cutscene @@ -1180,7 +1155,8 @@ void Cutscene_ProcessCommands(GlobalContext* globalCtx, CutsceneContext* csCtx, bcopy(cutscenePtr, &cutsceneEndFrame, sizeof(s32)); cutscenePtr += sizeof(s32); - if (((u16)cutsceneEndFrame < csCtx->frames) && (globalCtx->sceneLoadFlag != 0x14) && (csCtx->state != CS_STATE_4)) { + if (((u16)cutsceneEndFrame < csCtx->frames) && (play->transitionTrigger != TRANS_TRIGGER_START) && + (csCtx->state != CS_STATE_4)) { csCtx->state = CS_STATE_3; return; } @@ -1199,14 +1175,14 @@ void Cutscene_ProcessCommands(GlobalContext* globalCtx, CutsceneContext* csCtx, // 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); + for (j = 0; j < ARRAY_COUNT(D_801F4DC8); j = (s16)(j + 1)) { + if (D_801F4DC8[j] == (u16)cmdType) { + func_800ECD7C(csCtx, &cutscenePtr, j); cmdType = -2; break; - } else if (D_801F4DC8[phi_s0] == 0) { - D_801F4DC8[phi_s0] = cmdType; - func_800ECD7C(csCtx, &cutscenePtr, phi_s0); + } else if (D_801F4DC8[j] == 0) { + D_801F4DC8[j] = cmdType; + func_800ECD7C(csCtx, &cutscenePtr, j); cmdType = -2; break; } @@ -1218,7 +1194,7 @@ void Cutscene_ProcessCommands(GlobalContext* globalCtx, CutsceneContext* csCtx, bcopy(cutscenePtr, &cmdEntries, sizeof(s32)); cutscenePtr += sizeof(s32); for (j = 0; j < cmdEntries; j++) { - Cutscene_Command_Misc(globalCtx, csCtx, (CsCmdBase*)cutscenePtr); + Cutscene_Command_Misc(play, csCtx, (CsCmdBase*)cutscenePtr); cutscenePtr += sizeof(CsCmdBase); } break; @@ -1227,7 +1203,7 @@ void Cutscene_ProcessCommands(GlobalContext* globalCtx, CutsceneContext* csCtx, bcopy(cutscenePtr, &cmdEntries, sizeof(s32)); cutscenePtr += sizeof(s32); for (j = 0; j < cmdEntries; j++) { - Cutscene_Command_SetLighting(globalCtx, csCtx, (CsCmdEnvLighting*)cutscenePtr); + Cutscene_Command_SetLighting(play, csCtx, (CsCmdEnvLighting*)cutscenePtr); cutscenePtr += sizeof(CsCmdEnvLighting); } break; @@ -1236,7 +1212,7 @@ void Cutscene_ProcessCommands(GlobalContext* globalCtx, CutsceneContext* csCtx, bcopy(cutscenePtr, &cmdEntries, sizeof(s32)); cutscenePtr += sizeof(s32); for (j = 0; j < cmdEntries; j++) { - Cutscene_Command_PlaySequence(globalCtx, csCtx, (CsCmdSequenceChange*)cutscenePtr); + Cutscene_Command_PlaySequence(play, csCtx, (CsCmdSequenceChange*)cutscenePtr); cutscenePtr += sizeof(CsCmdSequenceChange); } break; @@ -1245,7 +1221,7 @@ void Cutscene_ProcessCommands(GlobalContext* globalCtx, CutsceneContext* csCtx, bcopy(cutscenePtr, &cmdEntries, sizeof(s32)); cutscenePtr += sizeof(s32); for (j = 0; j < cmdEntries; j++) { - Cutscene_Command_StopSequence(globalCtx, csCtx, (CsCmdSequenceChange*)cutscenePtr); + Cutscene_Command_StopSequence(play, csCtx, (CsCmdSequenceChange*)cutscenePtr); cutscenePtr += sizeof(CsCmdSequenceChange); } break; @@ -1254,7 +1230,7 @@ void Cutscene_ProcessCommands(GlobalContext* globalCtx, CutsceneContext* csCtx, bcopy(cutscenePtr, &cmdEntries, sizeof(s32)); cutscenePtr += sizeof(s32); for (j = 0; j < cmdEntries; j++) { - Cutscene_Command_FadeSequence(globalCtx, csCtx, (CsCmdSequenceFade*)cutscenePtr); + Cutscene_Command_FadeSequence(play, csCtx, (CsCmdSequenceFade*)cutscenePtr); cutscenePtr += sizeof(CsCmdSequenceFade); } break; @@ -1263,7 +1239,7 @@ void Cutscene_ProcessCommands(GlobalContext* globalCtx, CutsceneContext* csCtx, bcopy(cutscenePtr, &cmdEntries, sizeof(s32)); cutscenePtr += sizeof(s32); for (j = 0; j < cmdEntries; j++) { - Cutscene_Command_PlayAmbienceSequence(globalCtx, csCtx, (CsCmdBase*)cutscenePtr); + Cutscene_Command_PlayAmbienceSequence(play, csCtx, (CsCmdBase*)cutscenePtr); cutscenePtr += sizeof(CsCmdBase); } break; @@ -1272,7 +1248,7 @@ void Cutscene_ProcessCommands(GlobalContext* globalCtx, CutsceneContext* csCtx, bcopy(cutscenePtr, &cmdEntries, sizeof(s32)); cutscenePtr += sizeof(s32); for (j = 0; j < cmdEntries; j++) { - Cutscene_Command_FadeAmbienceSequence(globalCtx, csCtx, (CsCmdBase*)cutscenePtr); + Cutscene_Command_FadeAmbienceSequence(play, csCtx, (CsCmdBase*)cutscenePtr); cutscenePtr += sizeof(CsCmdBase); } break; @@ -1281,7 +1257,7 @@ void Cutscene_ProcessCommands(GlobalContext* globalCtx, CutsceneContext* csCtx, bcopy(cutscenePtr, &cmdEntries, sizeof(s32)); cutscenePtr += sizeof(s32); for (j = 0; j < cmdEntries; j++) { - func_800EAD48(globalCtx, csCtx, (CsCmdBase*)cutscenePtr); + func_800EAD48(play, csCtx, (CsCmdBase*)cutscenePtr); cutscenePtr += sizeof(CsCmdBase); } break; @@ -1290,7 +1266,7 @@ void Cutscene_ProcessCommands(GlobalContext* globalCtx, CutsceneContext* csCtx, bcopy(cutscenePtr, &cmdEntries, sizeof(s32)); cutscenePtr += sizeof(s32); for (j = 0; j < cmdEntries; j++) { - func_800EAD7C(globalCtx, csCtx, (CsCmdBase*)cutscenePtr); + func_800EAD7C(play, csCtx, (CsCmdBase*)cutscenePtr); cutscenePtr += sizeof(CsCmdBase); } break; @@ -1299,7 +1275,7 @@ void Cutscene_ProcessCommands(GlobalContext* globalCtx, CutsceneContext* csCtx, bcopy(cutscenePtr, &cmdEntries, sizeof(s32)); cutscenePtr += sizeof(s32); for (j = 0; j < cmdEntries; j++) { - func_800EADB0(globalCtx, csCtx, (CsCmdBase*)cutscenePtr); + func_800EADB0(play, csCtx, (CsCmdBase*)cutscenePtr); cutscenePtr += sizeof(CsCmdBase); } break; @@ -1308,7 +1284,7 @@ void Cutscene_ProcessCommands(GlobalContext* globalCtx, CutsceneContext* csCtx, bcopy(cutscenePtr, &cmdEntries, sizeof(s32)); cutscenePtr += sizeof(s32); for (j = 0; j < cmdEntries; j++) { - Cutscene_Command_Rumble(globalCtx, csCtx, (CsCmdRumble*)cutscenePtr); + Cutscene_Command_Rumble(play, csCtx, (CsCmdRumble*)cutscenePtr); cutscenePtr += sizeof(CsCmdRumble); } break; @@ -1317,7 +1293,7 @@ void Cutscene_ProcessCommands(GlobalContext* globalCtx, CutsceneContext* csCtx, bcopy(cutscenePtr, &cmdEntries, sizeof(s32)); cutscenePtr += sizeof(s32); for (j = 0; j < cmdEntries; j++) { - Cutscene_Command_FadeColorScreen(globalCtx, csCtx, (CsCmdFadeScreen*)cutscenePtr); + Cutscene_Command_FadeColorScreen(play, csCtx, (CsCmdFadeScreen*)cutscenePtr); cutscenePtr += sizeof(CsCmdFadeScreen); } break; @@ -1326,7 +1302,7 @@ void Cutscene_ProcessCommands(GlobalContext* globalCtx, CutsceneContext* csCtx, bcopy(cutscenePtr, &cmdEntries, sizeof(s32)); cutscenePtr += sizeof(s32); for (j = 0; j < cmdEntries; j++) { - Cutscene_Command_SetTime(globalCtx, csCtx, (CsCmdDayTime*)cutscenePtr); + Cutscene_Command_SetTime(play, csCtx, (CsCmdDayTime*)cutscenePtr); cutscenePtr += sizeof(CsCmdDayTime); } break; @@ -1336,22 +1312,22 @@ void Cutscene_ProcessCommands(GlobalContext* globalCtx, CutsceneContext* csCtx, 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; + if ((cmd->startFrame <= csCtx->frames) && (csCtx->frames < cmd->endFrame)) { + csCtx->playerAction = (CsCmdActorAction*)cmd; } cutscenePtr += sizeof(CsCmdActorAction); } break; case CS_CMD_CAMERA: - cutscenePtr = &cutscenePtr[Cutscene_Command_Camera(globalCtx, cutscenePtr)]; + cutscenePtr += Cutscene_Command_Camera(play, 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); + Cutscene_Command_Terminator(play, csCtx, (CsCmdBase*)cutscenePtr); cutscenePtr += sizeof(CsCmdBase); } break; @@ -1360,7 +1336,7 @@ void Cutscene_ProcessCommands(GlobalContext* globalCtx, CutsceneContext* csCtx, bcopy(cutscenePtr, &cmdEntries, sizeof(s32)); cutscenePtr += sizeof(s32); for (j = 0; j < cmdEntries; j++) { - Cutscene_Command_ChooseCreditsScenes(globalCtx, csCtx, (CsCmdBase*)cutscenePtr); + Cutscene_Command_ChooseCreditsScenes(play, csCtx, (CsCmdBase*)cutscenePtr); cutscenePtr += sizeof(CsCmdBase); } break; @@ -1371,7 +1347,7 @@ void Cutscene_ProcessCommands(GlobalContext* globalCtx, CutsceneContext* csCtx, for (j = 0; j < cmdEntries; j++) { cmd = (CsCmdBase*)cutscenePtr; if (cmd->base != 0xFFFF) { - Cutscene_Command_Textbox(globalCtx, csCtx, (CsCmdTextbox*)cutscenePtr); + Cutscene_Command_Textbox(play, csCtx, (CsCmdTextbox*)cmd); } cutscenePtr += sizeof(CsCmdTextbox); } @@ -1381,7 +1357,7 @@ void Cutscene_ProcessCommands(GlobalContext* globalCtx, CutsceneContext* csCtx, bcopy(cutscenePtr, &cmdEntries, sizeof(s32)); cutscenePtr += sizeof(s32); for (j = 0; j < cmdEntries; j++) { - Cutscene_Command_TransitionFX(globalCtx, csCtx, (CsCmdBase*)cutscenePtr); + Cutscene_Command_TransitionFX(play, csCtx, (CsCmdBase*)cutscenePtr); cutscenePtr += sizeof(CsCmdBase); } break; @@ -1390,7 +1366,7 @@ void Cutscene_ProcessCommands(GlobalContext* globalCtx, CutsceneContext* csCtx, bcopy(cutscenePtr, &cmdEntries, sizeof(s32)); cutscenePtr += sizeof(s32); for (j = 0; j < cmdEntries; j++) { - Cutscene_Command_MotionBlur(globalCtx, csCtx, (CsCmdBase*)cutscenePtr); + Cutscene_Command_MotionBlur(play, csCtx, (CsCmdBase*)cutscenePtr); cutscenePtr += sizeof(CsCmdBase); } break; @@ -1399,7 +1375,7 @@ void Cutscene_ProcessCommands(GlobalContext* globalCtx, CutsceneContext* csCtx, bcopy(cutscenePtr, &cmdEntries, sizeof(s32)); cutscenePtr += sizeof(s32); for (j = 0; j < cmdEntries; j++) { - Cutscene_Command_GiveTatlToPlayer(globalCtx, csCtx, (CsCmdBase*)cutscenePtr); + Cutscene_Command_GiveTatlToPlayer(play, csCtx, (CsCmdBase*)cutscenePtr); cutscenePtr += sizeof(CsCmdBase); } break; @@ -1417,29 +1393,26 @@ void Cutscene_ProcessCommands(GlobalContext* globalCtx, CutsceneContext* csCtx, } } } -#else -#pragma GLOBAL_ASM("asm/non_matchings/code/z_demo/Cutscene_ProcessCommands.s") -#endif /* End of command handling section */ -void func_800ED980(GlobalContext* globalCtx, CutsceneContext* csCtx) { +void func_800ED980(PlayState* play, CutsceneContext* csCtx) { if (gSaveContext.save.cutscene >= 0xFFF0) { csCtx->frames++; - Cutscene_ProcessCommands(globalCtx, csCtx, (u8*)globalCtx->csCtx.csData); + Cutscene_ProcessCommands(play, csCtx, (u8*)play->csCtx.csData); } } -void func_800ED9C4(GlobalContext* globalCtx, CutsceneContext* csCtx) { - if (func_800EA220(globalCtx, csCtx, 0.0f)) { +void func_800ED9C4(PlayState* play, CutsceneContext* csCtx) { + if (func_800EA220(play, csCtx, 0.0f)) { Audio_SetCutsceneFlag(false); csCtx->state = CS_STATE_0; } } // unused -void func_800EDA04(GlobalContext* globalCtx, CutsceneContext* csCtx) { - if (func_800EA220(globalCtx, csCtx, 0.0f)) { +void func_800EDA04(PlayState* play, CutsceneContext* csCtx) { + if (func_800EA220(play, csCtx, 0.0f)) { s16 i; csCtx->playerAction = NULL; @@ -1456,8 +1429,8 @@ void func_800EDA04(GlobalContext* globalCtx, CutsceneContext* csCtx) { } } -void func_800EDA84(GlobalContext* globalCtx, CutsceneContext* csCtx) { - if ((gSaveContext.cutsceneTrigger != 0) && (csCtx->state == CS_STATE_0) && !Player_InCsMode(&globalCtx->state)) { +void func_800EDA84(PlayState* play, CutsceneContext* csCtx) { + if ((gSaveContext.cutsceneTrigger != 0) && (csCtx->state == CS_STATE_0) && !Player_InCsMode(play)) { gSaveContext.save.cutscene = 0xFFFD; } @@ -1477,8 +1450,8 @@ void func_800EDA84(GlobalContext* globalCtx, CutsceneContext* csCtx) { Audio_SetCutsceneFlag(true); csCtx->frames = 0xFFFF; - csCtx->csCamId = ActorCutscene_GetCurrentCamera(0x7F); - func_8016119C(Play_GetCamera(globalCtx, csCtx->csCamId), &sCutsceneCameraInfo); + csCtx->subCamId = ActorCutscene_GetCurrentSubCamId(0x7F); + func_8016119C(Play_GetCamera(play, csCtx->subCamId), &sCutsceneCameraInfo); csCtx->unk_18 = 0xFFFF; if (gSaveContext.cutsceneTrigger == 0) { @@ -1488,18 +1461,16 @@ void func_800EDA84(GlobalContext* globalCtx, CutsceneContext* csCtx) { csCtx->state++; } - func_800ED980(globalCtx, csCtx); + func_800ED980(play, csCtx); } gSaveContext.cutsceneTrigger = 0; } } -#ifdef NON_MATCHING // HandleFlags? -// regalloc -void func_800EDBE0(GlobalContext* globalCtx) { - CutsceneEntry* temp_a3; +void func_800EDBE0(PlayState* play) { + s32 pad; s16 sp2A; SceneTableEntry* sp24; s32 temp_v0_3; @@ -1509,15 +1480,16 @@ void func_800EDBE0(GlobalContext* globalCtx) { 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) { + if ((play->csCtx.sceneCsList[temp_v0_3].unk7 != 0xFF) && (gSaveContext.respawnFlag == 0)) { + if (play->csCtx.sceneCsList[temp_v0_3].unk7 == 0xFE) { ActorCutscene_Start(sp2A, NULL); 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); + } else if (!(((void)0, + gSaveContext.save.weekEventReg[(play->csCtx.sceneCsList[temp_v0_3].unk7 / 8)]) & + (1 << (play->csCtx.sceneCsList[temp_v0_3].unk7 % 8)))) { + gSaveContext.save.weekEventReg[(play->csCtx.sceneCsList[temp_v0_3].unk7 / 8)] = + ((void)0, gSaveContext.save.weekEventReg[(play->csCtx.sceneCsList[temp_v0_3].unk7 / 8)]) | + (1 << (play->csCtx.sceneCsList[temp_v0_3].unk7 % 8)); ActorCutscene_Start(sp2A, NULL); gSaveContext.showTitleCard = false; } @@ -1529,31 +1501,29 @@ void func_800EDBE0(GlobalContext* globalCtx) { } if ((gSaveContext.respawnFlag == 0) || (gSaveContext.respawnFlag == -2)) { - sp24 = globalCtx->loadedScene; + sp24 = play->loadedScene; if ((sp24->titleTextId != 0) && gSaveContext.showTitleCard) { - if ((Entrance_GetTransitionFlags(gSaveContext.sceneSetupIndex + gSaveContext.save.entranceIndex) & + if ((Entrance_GetTransitionFlags(((void)0, gSaveContext.save.entrance) + + ((void)0, gSaveContext.sceneSetupIndex)) & 0x4000) != 0) { - func_80151A68(globalCtx, sp24->titleTextId); + func_80151A68(play, sp24->titleTextId); } } gSaveContext.showTitleCard = true; } } -#else -#pragma GLOBAL_ASM("asm/non_matchings/code/z_demo/func_800EDBE0.s") -#endif -void func_800EDDB0(GlobalContext* globalCtx) { +void func_800EDDB0(PlayState* play) { } void func_800EDDBC(UNK_TYPE arg0, UNK_TYPE arg1) { } -void Cutscene_LoadCutsceneData(GlobalContext* globalCtx, u8 csIndex) { +void Cutscene_LoadCutsceneData(PlayState* play, u8 csIndex) { if (dREG(95) == 0) { - globalCtx->csCtx.currentCsIndex = csIndex; - globalCtx->csCtx.csData = Lib_SegmentedToVirtual(globalCtx->csCtx.sceneCsList[csIndex].segmentedData); + play->csCtx.currentCsIndex = csIndex; + play->csCtx.csData = Lib_SegmentedToVirtual(play->csCtx.sceneCsList[csIndex].segmentedData); } gSaveContext.cutsceneTrigger = 1; @@ -1565,10 +1535,10 @@ void Cutscene_LoadCutsceneData(GlobalContext* globalCtx, u8 csIndex) { * Interpolates the actor's position based on the corresponding actor action's position * and the current cutscene frame */ -void Cutscene_ActorTranslate(Actor* actor, GlobalContext* globalCtx, s32 actorActionIndex) { +void Cutscene_ActorTranslate(Actor* actor, PlayState* play, s32 actorActionIndex) { Vec3f start; Vec3f end; - CsCmdActorAction* entry = globalCtx->csCtx.actorActions[actorActionIndex]; + CsCmdActorAction* entry = play->csCtx.actorActions[actorActionIndex]; f32 progress; start.x = entry->startPos.x; @@ -1578,7 +1548,7 @@ void Cutscene_ActorTranslate(Actor* actor, GlobalContext* globalCtx, s32 actorAc end.y = entry->endPos.y; end.z = entry->endPos.z; - progress = Environment_LerpWeight(entry->endFrame, entry->startFrame, globalCtx->csCtx.frames); + progress = Environment_LerpWeight(entry->endFrame, entry->startFrame, play->csCtx.frames); VEC3F_LERPIMPDST(&actor->world.pos, &start, &end, progress); } @@ -1587,10 +1557,10 @@ void Cutscene_ActorTranslate(Actor* actor, GlobalContext* globalCtx, s32 actorAc * 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); +void Cutscene_ActorTranslateAndYaw(Actor* actor, PlayState* play, s32 actorActionIndex) { + Cutscene_ActorTranslate(actor, play, actorActionIndex); - actor->world.rot.y = globalCtx->csCtx.actorActions[actorActionIndex]->urot.y; + actor->world.rot.y = play->csCtx.actorActions[actorActionIndex]->urot.y; actor->shape.rot.y = actor->world.rot.y; } @@ -1598,21 +1568,21 @@ void Cutscene_ActorTranslateAndYaw(Actor* actor, GlobalContext* globalCtx, s32 a * 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) { +void Cutscene_ActorTranslateAndYawSmooth(Actor* actor, PlayState* play, 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; + start.x = play->csCtx.actorActions[actorActionIndex]->startPos.x; + start.y = play->csCtx.actorActions[actorActionIndex]->startPos.y; + start.z = play->csCtx.actorActions[actorActionIndex]->startPos.z; + end.x = play->csCtx.actorActions[actorActionIndex]->endPos.x; + end.y = play->csCtx.actorActions[actorActionIndex]->endPos.y; + end.z = play->csCtx.actorActions[actorActionIndex]->endPos.z; - entry = globalCtx->csCtx.actorActions[actorActionIndex]; - progress = Environment_LerpWeight(entry->endFrame, entry->startFrame, globalCtx->csCtx.frames); + entry = play->csCtx.actorActions[actorActionIndex]; + progress = Environment_LerpWeight(entry->endFrame, entry->startFrame, play->csCtx.frames); VEC3F_LERPIMPDST(&actor->world.pos, &start, &end, progress); @@ -1624,19 +1594,19 @@ void Cutscene_ActorTranslateAndYawSmooth(Actor* actor, GlobalContext* globalCtx, * 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) { +void Cutscene_ActorTranslateXZAndYawSmooth(Actor* actor, PlayState* play, 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; + start.x = play->csCtx.actorActions[actorActionIndex]->startPos.x; + start.z = play->csCtx.actorActions[actorActionIndex]->startPos.z; + end.x = play->csCtx.actorActions[actorActionIndex]->endPos.x; + end.z = play->csCtx.actorActions[actorActionIndex]->endPos.z; - entry = globalCtx->csCtx.actorActions[actorActionIndex]; - progress = Environment_LerpWeight(entry->endFrame, entry->startFrame, globalCtx->csCtx.frames); + entry = play->csCtx.actorActions[actorActionIndex]; + progress = Environment_LerpWeight(entry->endFrame, entry->startFrame, play->csCtx.frames); actor->world.pos.x = start.x + (end.x - start.x) * progress; actor->world.pos.z = start.z + (end.z - start.z) * progress; @@ -1645,7 +1615,7 @@ void Cutscene_ActorTranslateXZAndYawSmooth(Actor* actor, GlobalContext* globalCt actor->shape.rot.y = actor->world.rot.y; } -s32 Cutscene_GetSceneSetupIndex(GlobalContext* globalCtx) { +s32 Cutscene_GetSceneSetupIndex(PlayState* play) { s32 sceneSetupIndex = 0; if (gSaveContext.sceneSetupIndex > 0) { @@ -1654,7 +1624,7 @@ s32 Cutscene_GetSceneSetupIndex(GlobalContext* globalCtx) { return sceneSetupIndex; } -s32 Cutscene_GetActorActionIndex(GlobalContext* globalCtx, u16 actorActionCmd) { +s32 Cutscene_GetActorActionIndex(PlayState* play, u16 actorActionCmd) { s32 i; s32 index = -1; @@ -1667,20 +1637,20 @@ s32 Cutscene_GetActorActionIndex(GlobalContext* globalCtx, u16 actorActionCmd) { return index; } -s32 Cutscene_CheckActorAction(GlobalContext* globalCtx, u16 actorActionCmd) { - if (globalCtx->csCtx.state != CS_STATE_0) { - s32 index = Cutscene_GetActorActionIndex(globalCtx, actorActionCmd); +s32 Cutscene_CheckActorAction(PlayState* play, u16 actorActionCmd) { + if (play->csCtx.state != CS_STATE_0) { + s32 index = Cutscene_GetActorActionIndex(play, actorActionCmd); if (index != -1) { - return globalCtx->csCtx.actorActions[index] != NULL; + return play->csCtx.actorActions[index] != NULL; } } return false; } -u8 Cutscene_IsPlaying(GlobalContext* globalCtx) { - return (gSaveContext.cutsceneTrigger != 0) || (globalCtx->csCtx.state != CS_STATE_0); +u8 Cutscene_IsPlaying(PlayState* play) { + return (gSaveContext.cutsceneTrigger != 0) || (play->csCtx.state != CS_STATE_0); } /* End of actor utilities section */ diff --git a/src/code/z_draw.c b/src/code/z_draw.c index b31f796b7..4167b4cea 100644 --- a/src/code/z_draw.c +++ b/src/code/z_draw.c @@ -1,49 +1,843 @@ +/** + * @file z_draw.c + * @brief Draw get-item models + */ #include "global.h" +#include "assets/objects/object_gi_arrow/object_gi_arrow.h" +#include "assets/objects/object_gi_arrowcase/object_gi_arrowcase.h" +#include "assets/objects/object_gi_bean/object_gi_bean.h" +#include "assets/objects/object_gi_bigbomb/object_gi_bigbomb.h" +#include "assets/objects/object_gi_bomb_1/object_gi_bomb_1.h" +#include "assets/objects/object_gi_bomb_2/object_gi_bomb_2.h" +#include "assets/objects/object_gi_bombpouch/object_gi_bombpouch.h" +#include "assets/objects/object_gi_bosskey/object_gi_bosskey.h" +#include "assets/objects/object_gi_bottle_04/object_gi_bottle_04.h" +#include "assets/objects/object_gi_bottle_15/object_gi_bottle_15.h" +#include "assets/objects/object_gi_bottle_16/object_gi_bottle_16.h" +#include "assets/objects/object_gi_bottle_21/object_gi_bottle_21.h" +#include "assets/objects/object_gi_bottle_22/object_gi_bottle_22.h" +#include "assets/objects/object_gi_bottle_red/object_gi_bottle_red.h" +#include "assets/objects/object_gi_bottle/object_gi_bottle.h" +#include "assets/objects/object_gi_bow/object_gi_bow.h" +#include "assets/objects/object_gi_camera/object_gi_camera.h" +#include "assets/objects/object_gi_compass/object_gi_compass.h" +#include "assets/objects/object_gi_fieldmap/object_gi_fieldmap.h" +#include "assets/objects/object_gi_fish/object_gi_fish.h" +#include "assets/objects/object_gi_ghost/object_gi_ghost.h" +#include "assets/objects/object_gi_glasses/object_gi_glasses.h" +#include "assets/objects/object_gi_gold_dust/object_gi_gold_dust.h" +#include "assets/objects/object_gi_golonmask/object_gi_golonmask.h" +#include "assets/objects/object_gi_heart/object_gi_heart.h" +#include "assets/objects/object_gi_hearts/object_gi_hearts.h" +#include "assets/objects/object_gi_hookshot/object_gi_hookshot.h" +#include "assets/objects/object_gi_insect/object_gi_insect.h" +#include "assets/objects/object_gi_key/object_gi_key.h" +#include "assets/objects/object_gi_ki_tan_mask/object_gi_ki_tan_mask.h" +#include "assets/objects/object_gi_liquid/object_gi_liquid.h" +#include "assets/objects/object_gi_loach/object_gi_loach.h" +#include "assets/objects/object_gi_longsword/object_gi_longsword.h" +#include "assets/objects/object_gi_m_arrow/object_gi_m_arrow.h" +#include "assets/objects/object_gi_magicmushroom/object_gi_magicmushroom.h" +#include "assets/objects/object_gi_magicpot/object_gi_magicpot.h" +#include "assets/objects/object_gi_map/object_gi_map.h" +#include "assets/objects/object_gi_mask03/object_gi_mask03.h" +#include "assets/objects/object_gi_mask05/object_gi_mask05.h" +#include "assets/objects/object_gi_mask06/object_gi_mask06.h" +#include "assets/objects/object_gi_mask09/object_gi_mask09.h" +#include "assets/objects/object_gi_mask10/object_gi_mask10.h" +#include "assets/objects/object_gi_mask11/object_gi_mask11.h" +#include "assets/objects/object_gi_mask12/object_gi_mask12.h" +#include "assets/objects/object_gi_mask13/object_gi_mask13.h" +#include "assets/objects/object_gi_mask14/object_gi_mask14.h" +#include "assets/objects/object_gi_mask15/object_gi_mask15.h" +#include "assets/objects/object_gi_mask16/object_gi_mask16.h" +#include "assets/objects/object_gi_mask17/object_gi_mask17.h" +#include "assets/objects/object_gi_mask18/object_gi_mask18.h" +#include "assets/objects/object_gi_mask20/object_gi_mask20.h" +#include "assets/objects/object_gi_mask21/object_gi_mask21.h" +#include "assets/objects/object_gi_mask22/object_gi_mask22.h" +#include "assets/objects/object_gi_mask23/object_gi_mask23.h" +#include "assets/objects/object_gi_melody/object_gi_melody.h" +#include "assets/objects/object_gi_milk/object_gi_milk.h" +#include "assets/objects/object_gi_mssa/object_gi_mssa.h" +#include "assets/objects/object_gi_nuts/object_gi_nuts.h" +#include "assets/objects/object_gi_nutsmask/object_gi_nutsmask.h" +#include "assets/objects/object_gi_ocarina/object_gi_ocarina.h" +#include "assets/objects/object_gi_purse/object_gi_purse.h" +#include "assets/objects/object_gi_rabit_mask/object_gi_rabit_mask.h" +#include "assets/objects/object_gi_reserve_b_00/object_gi_reserve_b_00.h" +#include "assets/objects/object_gi_reserve_b_01/object_gi_reserve_b_01.h" +#include "assets/objects/object_gi_reserve_c_00/object_gi_reserve_c_00.h" +#include "assets/objects/object_gi_reserve_c_01/object_gi_reserve_c_01.h" +#include "assets/objects/object_gi_reserve00/object_gi_reserve00.h" +#include "assets/objects/object_gi_reserve01/object_gi_reserve01.h" +#include "assets/objects/object_gi_rupy/object_gi_rupy.h" +#include "assets/objects/object_gi_schedule/object_gi_schedule.h" +#include "assets/objects/object_gi_seahorse/object_gi_seahorse.h" +#include "assets/objects/object_gi_shield_2/object_gi_shield_2.h" +#include "assets/objects/object_gi_shield_3/object_gi_shield_3.h" +#include "assets/objects/object_gi_soldout/object_gi_soldout.h" +#include "assets/objects/object_gi_soul/object_gi_soul.h" +#include "assets/objects/object_gi_stick/object_gi_stick.h" +#include "assets/objects/object_gi_stonemask/object_gi_stonemask.h" +#include "assets/objects/object_gi_sutaru/object_gi_sutaru.h" +#include "assets/objects/object_gi_sword_1/object_gi_sword_1.h" +#include "assets/objects/object_gi_sword_2/object_gi_sword_2.h" +#include "assets/objects/object_gi_sword_3/object_gi_sword_3.h" +#include "assets/objects/object_gi_sword_4/object_gi_sword_4.h" +#include "assets/objects/object_gi_truth_mask/object_gi_truth_mask.h" +#include "assets/objects/object_gi_zoramask/object_gi_zoramask.h" +#include "assets/objects/object_bsmask/object_bsmask.h" +#include "assets/objects/object_st/object_st.h" -#pragma GLOBAL_ASM("asm/non_matchings/code/z_draw/GetItem_Draw.s") +void GetItem_DrawBombchu(PlayState* play, s16 drawId); +void GetItem_DrawPoes(PlayState* play, s16 drawId); +void GetItem_DrawFairyBottle(PlayState* play, s16 drawId); +void GetItem_DrawSkullToken(PlayState* play, s16 drawId); +void GetItem_DrawCompass(PlayState* play, s16 drawId); +void GetItem_DrawPotion(PlayState* play, s16 drawId); +void GetItem_DrawGoronSword(PlayState* play, s16 drawId); +void GetItem_DrawDekuNuts(PlayState* play, s16 drawId); +void GetItem_DrawRecoveryHeart(PlayState* play, s16 drawId); +void GetItem_DrawFish(PlayState* play, s16 drawId); +void GetItem_DrawOpa0(PlayState* play, s16 drawId); +void GetItem_DrawOpa0Xlu1(PlayState* play, s16 drawId); +void GetItem_DrawOpa01(PlayState* play, s16 drawId); +void GetItem_DrawXlu01(PlayState* play, s16 drawId); +void GetItem_DrawSeahorse(PlayState* play, s16 drawId); +void GetItem_DrawFairyContainer(PlayState* play, s16 drawId); +void GetItem_DrawMoonsTear(PlayState* play, s16 drawId); +void GetItem_DrawMagicArrow(PlayState* play, s16 drawId); +void GetItem_DrawUpgrades(PlayState* play, s16 drawId); +void GetItem_DrawRupee(PlayState* play, s16 drawId); +void GetItem_DrawSmallRupee(PlayState* play, s16 drawId); +void GetItem_DrawWallet(PlayState* play, s16 drawId); +void GetItem_DrawRemains(PlayState* play, s16 drawId); -#pragma GLOBAL_ASM("asm/non_matchings/code/z_draw/func_800EE364.s") +typedef struct { + /* 0x00 */ void (*drawFunc)(PlayState*, s16); + /* 0x04 */ void* drawResources[8]; // Either display lists (Gfx*) or matrices (Mtx*) +} DrawItemTableEntry; // size = 0x24 -#pragma GLOBAL_ASM("asm/non_matchings/code/z_draw/func_800EE400.s") +static DrawItemTableEntry sDrawItemTable[] = { + // GID_BOTTLE, OBJECT_GI_BOTTLE + { GetItem_DrawOpa0Xlu1, { gGiEmptyBottleCorkDL, gGiEmptyBottleGlassDL } }, + // GID_KEY_SMALL, OBJECT_GI_KEY + { GetItem_DrawOpa0, { gGiSmallKeyDL } }, + // GID_MASK_KAMARO, OBJECT_GI_MASK17 + { GetItem_DrawOpa01, { gGiKamaroMaskDL, gGiKamaroMaskEmptyDL } }, + // GID_MASK_COUPLE, OBJECT_GI_MASK13 + { GetItem_DrawOpa0Xlu1, { gGiCouplesMaskFullDL, gGiCouplesMaskHalfDL } }, + // GID_04, OBJECT_GI_MELODY + { GetItem_DrawXlu01, { gGiSerenadeColorDL, gGiSongNoteDL } }, + // GID_05, OBJECT_GI_MELODY + { GetItem_DrawXlu01, { gGiRequiemColorDL, gGiSongNoteDL } }, + // GID_06, OBJECT_GI_MELODY + { GetItem_DrawXlu01, { gGiNocturneColorDL, gGiSongNoteDL } }, + // GID_07, OBJECT_GI_MELODY + { GetItem_DrawXlu01, { gGiPreludeColorDL, gGiSongNoteDL } }, + // GID_RECOVERY_HEART, OBJECT_GI_HEART + { GetItem_DrawRecoveryHeart, { gGiRecoveryHeartDL } }, + // GID_KEY_BOSS, OBJECT_GI_KEY_BOSS + { GetItem_DrawOpa0Xlu1, { gGiBossKeyDL, gGiBossKeyGemDL } }, + // GID_COMPASS, OBJECT_GI_COMPASS + { GetItem_DrawCompass, { gGiCompassDL, gGiCompassGlassDL } }, + // GID_BOMBERS_NOTEBOOK, OBJECT_GI_SCHEDULE + { GetItem_DrawOpa0Xlu1, { gGiBombersNotebookEmptyDL, gGiBombersNotebookDL } }, + // GID_MASK_STONE, OBJECT_GI_STONEMASK + { GetItem_DrawOpa0Xlu1, { gGiStoneMaskEmptyDL, gGiStoneMaskDL } }, + // GID_MASK_KAFEIS_MASK, OBJECT_GI_MASK05 + { GetItem_DrawOpa01, { gGiKafeiMaskDL, gGiKafeiMaskEmptyDL } }, + // GID_MASK_CIRCUS_LEADER, OBJECT_GI_MASK11 + { GetItem_DrawOpa0Xlu1, { gGiCircusLeaderMaskFaceDL, gGiCircusLeaderMaskEyebrowsDL } }, + // GID_MASK_BREMEN, OBJECT_GI_MASK20 + { GetItem_DrawOpa01, { gGiBremenMaskDL, gGiBremenMaskEmptyDL } }, + // GID_MASK_ALL_NIGHT, OBJECT_GI_MASK06 + { GetItem_DrawOpa0Xlu1, { gGiAllNightMaskEyesDL, gGiAllNightMaskFaceDL } }, + // GID_NUTS, OBJECT_GI_NUTS + { GetItem_DrawDekuNuts, { gGiNutDL } }, + // GID_HEART_CONTAINER, OBJECT_GI_HEARTS + { GetItem_DrawXlu01, { gGiHeartBorderDL, gGiHeartContainerDL } }, + // GID_HEART_PIECE, OBJECT_GI_HEARTS + { GetItem_DrawXlu01, { gGiHeartBorderDL, gGiHeartPieceDL } }, + // GID_QUIVER_30, OBJECT_GI_ARROWCASE + { GetItem_DrawUpgrades, { gGiQuiverInnerDL, gGiQuiver30InnerColorDL, gGiQuiver30OuterColorDL, gGiQuiverOuterDL } }, + // GID_QUIVER_40, OBJECT_GI_ARROWCASE + { GetItem_DrawUpgrades, { gGiQuiverInnerDL, gGiQuiver40InnerColorDL, gGiQuiver40OuterColorDL, gGiQuiverOuterDL } }, + // GID_QUIVER_50, OBJECT_GI_ARROWCASE + { GetItem_DrawUpgrades, { gGiQuiverInnerDL, gGiQuiver50InnerColorDL, gGiQuiver50OuterColorDL, gGiQuiverOuterDL } }, + // GID_BOMB_BAG_20, OBJECT_GI_BOMBPOUCH + { GetItem_DrawUpgrades, { gGiBombBagDL, gGiBombBag20BagColorDL, gGiBombBag20RingColorDL, gGiBombBagRingDL } }, + // GID_BOMB_BAG_30, OBJECT_GI_BOMBPOUCH + { GetItem_DrawUpgrades, { gGiBombBagDL, gGiBombBag30BagColorDL, gGiBombBag30RingColorDL, gGiBombBagRingDL } }, + // GID_BOMB_BAG_40, OBJECT_GI_BOMBPOUCH + { GetItem_DrawUpgrades, { gGiBombBagDL, gGiBombBag40BagColorDL, gGiBombBag40RingColorDL, gGiBombBagRingDL } }, + // GID_STICK, OBJECT_GI_STICK + { GetItem_DrawOpa0, { gGiStickDL } }, + // GID_DUNGEON_MAP, OBJECT_GI_MAP + { GetItem_DrawOpa0, { gGiDungeonMapDL } }, + // GID_MAGIC_SMALL, OBJECT_GI_MAGICPOT + { GetItem_DrawOpa0, { gGiMagicJarSmallDL } }, + // GID_MAGIC_LARGE, OBJECT_GI_MAGICPOT + { GetItem_DrawOpa0, { gGiMagicJarLargeDL } }, + // GID_BOMB, OBJECT_GI_BOMB_1 + { GetItem_DrawOpa0, { gGiBombDL } }, + // GID_STONE_OF_AGONY, OBJECT_GI_MAP + { GetItem_DrawOpa0, { gGiStoneOfAgonyDL } }, + // GID_WALLET_ADULT, OBJECT_GI_PURSE + { GetItem_DrawWallet, + { gGiWalletDL, gGiAdultWalletColorDL, gGiAdultWalletRupeeOuterColorDL, gGiWalletRupeeOuterDL, + gGiAdultWalletStringColorDL, gGiWalletStringDL, gGiAdultWalletRupeeInnerColorDL, gGiWalletRupeeInnerDL } }, + // GID_WALLET_GIANT, OBJECT_GI_PURSE + { GetItem_DrawWallet, + { gGiWalletDL, gGiGiantsWalletColorDL, gGiGiantsWalletRupeeOuterColorDL, gGiWalletRupeeOuterDL, + gGiGiantsWalletStringColorDL, gGiWalletStringDL, gGiGiantsWalletRupeeInnerColorDL, gGiWalletRupeeInnerDL } }, + // GID_MASK_DON_GERO, OBJECT_GI_MASK16 + { GetItem_DrawOpa0Xlu1, { gGiDonGeroMaskFaceDL, gGiDonGeroMaskBodyDL } }, + // GID_ARROWS_SMALL, OBJECT_GI_ARROW + { GetItem_DrawOpa0, { gGiArrowSmallDL } }, + // GID_ARROWS_MEDIUM, OBJECT_GI_ARROW + { GetItem_DrawOpa0, { gGiArrowMediumDL } }, + // GID_ARROWS_LARGE, OBJECT_GI_ARROW + { GetItem_DrawOpa0, { gGiArrowLargeDL } }, + // GID_BOMBCHU, OBJECT_GI_BOMB_2 + { GetItem_DrawBombchu, { gGiBombchuDL } }, + // GID_SHIELD_HERO, OBJECT_GI_SHIELD_2 + { GetItem_DrawOpa0Xlu1, { gGiHerosShieldEmblemDL, gGiHerosShieldDL } }, + // GID_HOOKSHOT, OBJECT_GI_HOOKSHOT + { GetItem_DrawOpa01, { gGiHookshotEmptyDL, gGiHookshotDL } }, + // GID_29, OBJECT_GI_HOOKSHOT + { GetItem_DrawOpa01, { gGiHookshotEmptyDL, gGiHookshotDL } }, + // GID_OCARINA, OBJECT_GI_OCARINA + { GetItem_DrawOpa0Xlu1, { gGiOcarinaOfTimeDL, gGiOcarinaOfTimeHolesDL } }, + // GID_MILK, OBJECT_GI_MILK + { GetItem_DrawOpa0Xlu1, { gGiMilkBottleContentsDL, gGiMilkBottleGlassDL } }, + // GID_MASK_KEATON, OBJECT_GI_KI_TAN_MASK + { GetItem_DrawOpa0Xlu1, { gGiKeatonMaskDL, gGiKeatonMaskEyesDL } }, + // GID_TINGLE_MAP, OBJECT_GI_FIELDMAP + { GetItem_DrawOpa01, { gGiTingleMapDL, gGiTingleMapEmptyDL } }, + // GID_BOW, OBJECT_GI_BOW + { GetItem_DrawOpa01, { gGiBowHandleDL, gGiBowStringDL } }, + // GID_LENS, OBJECT_GI_GLASSES + { GetItem_DrawOpa0Xlu1, { gGiLensDL, gGiLensGlassDL } }, + // GID_POTION_GREEN, OBJECT_GI_LIQUID + { GetItem_DrawPotion, + { gGiPotionContainerPotDL, gGiPotionContainerGreenPotColorDL, gGiPotionContainerGreenLiquidColorDL, + gGiPotionContainerLiquidDL, gGiPotionContainerGreenPatternColorDL, gGiPotionContainerPatternDL } }, + // GID_POTION_RED, OBJECT_GI_LIQUID + { GetItem_DrawPotion, + { gGiPotionContainerPotDL, gGiPotionContainerRedPotColorDL, gGiPotionContainerRedLiquidColorDL, + gGiPotionContainerLiquidDL, gGiPotionContainerRedPatternColorDL, gGiPotionContainerPatternDL } }, + // GID_POTION_BLUE, OBJECT_GI_LIQUID + { GetItem_DrawPotion, + { gGiPotionContainerPotDL, gGiPotionContainerBluePotColorDL, gGiPotionContainerBlueLiquidColorDL, + gGiPotionContainerLiquidDL, gGiPotionContainerBluePatternColorDL, gGiPotionContainerPatternDL } }, + // GID_SHIELD_MIRROR, OBJECT_GI_SHIELD_3 + { GetItem_DrawOpa0Xlu1, { gGiMirrorShieldEmptyDL, gGiMirrorShieldDL } }, + // GID_MAGIC_BEANS, OBJECT_GI_BEAN + { GetItem_DrawOpa0, { gGiBeanDL } }, + // GID_FISH, OBJECT_GI_FISH + { GetItem_DrawFish, { gGiFishContainerDL } }, + // GID_LETTER_MAMA, OBJECT_GI_RESERVE_B_01 + { GetItem_DrawOpa0Xlu1, { gGiLetterToMamaEnvelopeLetterDL, gGiLetterToMamaInscriptionsDL } }, + // GID_37 + { GetItem_DrawOpa0, { NULL } }, + // GID_SWORD_BGS, OBJECT_GI_LONGSWORD + { GetItem_DrawGoronSword, { gGiBiggoronSwordDL } }, + // GID_MASK_SUN, OBJECT_GI_MSSA + { GetItem_DrawOpa0Xlu1, { gGiSunMaskFaceDL, gGiSunMaskEyesSidePatternsDL } }, + // GID_MASK_BLAST, OBJECT_GI_MASK21 + { GetItem_DrawOpa0Xlu1, { gGiBlastMaskEmptyDL, gGiBlastMaskDL } }, + // GID_FAIRY, OBJECT_GI_BOTTLE_04 + { GetItem_DrawFairyContainer, + { gGiFairyBottleEmptyDL, gGiFairyBottleGlassCorkDL, gGiFairyBottleContentsDL, &gGiFairyBottleBillboardRotMtx } }, + // GID_MASK_SCENTS, OBJECT_GI_MASK22 + { GetItem_DrawOpa01, { gGiMaskOfScentsFaceDL, gGiMaskOfScentsTeethDL } }, + // GID_MASK_CAPTAIN, OBJECT_GI_MASK18 + { GetItem_DrawOpa01, { gGiCaptainsHatBodyDL, gGiCaptainsHatFaceDL } }, + // GID_MASK_BUNNY, OBJECT_GI_RABIT_MASK + { GetItem_DrawOpa0Xlu1, { gGiBunnyHoodDL, gGiBunnyHoodEyesDL } }, + // GID_MASK_TRUTH, OBJECT_GI_TRUTH_MASK + { GetItem_DrawOpa0Xlu1, { gGiMaskOfTruthDL, gGiMaskOfTruthAccentsDL } }, + // GID_DEED_SWAMP, OBJECT_GI_RESERVE01 + { GetItem_DrawOpa01, { gGiTitleDeedEmptyDL, gGiTitleDeedSwampColorDL } }, + // GID_DEED_MOUNTAIN, OBJECT_GI_RESERVE01 + { GetItem_DrawOpa01, { gGiTitleDeedEmptyDL, gGiTitleDeedMountainColorDL } }, + // GID_RUPEE_HUGE, OBJECT_GI_RUPY + { GetItem_DrawRupee, { gGiRupeeInnerDL, gGiGoldRupeeInnerColorDL, gGiRupeeOuterDL, gGiGoldRupeeOuterColorDL } }, + // GID_DEED_OCEAN, OBJECT_GI_RESERVE01 + { GetItem_DrawOpa01, { gGiTitleDeedEmptyDL, gGiTitleDeedOceanColorDL } }, + // GID_MASK_GORON, OBJECT_GI_GOLONMASK + { GetItem_DrawOpa0Xlu1, { gGiGoronMaskEmptyDL, gGiGoronMaskDL } }, + // GID_MASK_ZORA, OBJECT_GI_ZORAMASK + { GetItem_DrawOpa01, { gGiZoraMaskEmptyDL, gGiZoraMaskDL } }, + // GID_46 + { GetItem_DrawBombchu, { NULL } }, + // GID_ARROW_FIRE, OBJECT_GI_M_ARROW + { GetItem_DrawMagicArrow, { gGiMagicArrowAmmoDL, gGiMagicArrowFireColorDL, gGiMagicArrowGlowDL } }, + // GID_ARROW_ICE, OBJECT_GI_M_ARROW + { GetItem_DrawMagicArrow, { gGiMagicArrowAmmoDL, gGiMagicArrowIceColorDL, gGiMagicArrowGlowDL } }, + // GID_ARROW_LIGHT, OBJECT_GI_M_ARROW + { GetItem_DrawMagicArrow, { gGiMagicArrowAmmoDL, gGiMagicArrowLightColorDL, gGiMagicArrowGlowDL } }, + // GID_SKULL_TOKEN, OBJECT_GI_SUTARU + { GetItem_DrawSkullToken, { gGiSkulltulaTokenDL, gGiSkulltulaTokenFlameDL } }, + // GID_BUG, OBJECT_GI_INSECT + { GetItem_DrawOpa0Xlu1, { gGiBugContainerContentsDL, gGiBugContainerGlassDL } }, + // GID_4C + { GetItem_DrawOpa0Xlu1, { NULL } }, + // GID_POE, OBJECT_GI_GHOST + { GetItem_DrawPoes, + { gGiPoeContainerLidDL, gGiPoeContainerGlassDL, gGiPoeContainerContentsDL, gGiPoeContainerPoeColorDL } }, + // GID_FAIRY_2, OBJECT_GI_SOUL + { GetItem_DrawFairyBottle, { gGiFairyContainerBaseCapDL, gGiFairyContainerGlassDL, gGiFairyContainerContentsDL } }, + // GID_RUPEE_GREEN, OBJECT_GI_RUPY + { GetItem_DrawSmallRupee, + { gGiRupeeInnerDL, gGiGreenRupeeInnerColorDL, gGiRupeeOuterDL, gGiGreenRupeeOuterColorDL } }, + // GID_RUPEE_BLUE, OBJECT_GI_RUPY + { GetItem_DrawSmallRupee, + { gGiRupeeInnerDL, gGiBlueRupeeInnerColorDL, gGiRupeeOuterDL, gGiBlueRupeeOuterColorDL } }, + // GID_RUPEE_RED, OBJECT_GI_RUPY + { GetItem_DrawSmallRupee, { gGiRupeeInnerDL, gGiRedRupeeInnerColorDL, gGiRupeeOuterDL, gGiRedRupeeOuterColorDL } }, + // GID_BIG_POE, OBJECT_GI_GHOST + { GetItem_DrawPoes, + { gGiPoeContainerLidDL, gGiPoeContainerGlassDL, gGiPoeContainerContentsDL, gGiPoeContainerBigPoeColorDL } }, + // GID_RUPEE_PURPLE, OBJECT_GI_RUPY + { GetItem_DrawRupee, { gGiRupeeInnerDL, gGiPurpleRupeeInnerColorDL, gGiRupeeOuterDL, gGiPurpleRupeeOuterColorDL } }, + // GID_RUPEE_SILVER, OBJECT_GI_RUPY + { GetItem_DrawRupee, { gGiRupeeInnerDL, gGiSilverRupeeInnerColorDL, gGiRupeeOuterDL, gGiSilverRupeeOuterColorDL } }, + // GID_SWORD_KOKIRI, OBJECT_GI_SWORD_1 + { GetItem_DrawOpa01, { gGiKokiriSwordBladeHiltDL, gGiKokiriSwordGuardDL } }, + // GID_SKULL_TOKEN_2, OBJECT_ST + { GetItem_DrawSkullToken, { gSkulltulaTokenDL, gSkulltulaTokenFlameDL } }, + // GID_57, OBJECT_GI_BOTTLE_RED + { GetItem_DrawOpa0Xlu1, { gGiRedPotionBottleEmptyDL, gGiRedPotionBottleDL } }, + // GID_ZORA_EGG, OBJECT_GI_BOTTLE_15 + { GetItem_DrawOpa0Xlu1, { gGiZoraEggBottleContentsDL, gGiZoraEggBottleGlassAndCorkDL } }, + // GID_MOON_TEAR, OBJECT_GI_RESERVE00 + { GetItem_DrawMoonsTear, { gGiMoonsTearItemDL, gGiMoonsTearGlowDL } }, + // GID_DEED_LAND, OBJECT_GI_RESERVE01 + { GetItem_DrawOpa01, { gGiTitleDeedEmptyDL, gGiTitleDeedLandColorDL } }, + // GID_MASK_DEKU, OBJECT_GI_NUTSMASK + { GetItem_DrawOpa0Xlu1, { gGiDekuMaskEmptyDL, gGiDekuMaskDL } }, + // GID_REMAINS_ODOLWA, OBJECT_BSMASK + { GetItem_DrawRemains, { gRemainsOdolwaDL, gRemainsOdolwaDL } }, + // GID_POWDER_KEG, OBJECT_GI_BIGBOMB + { GetItem_DrawOpa0Xlu1, { gGiPowderKegBarrelDL, gGiPowderKegGoronSkullAndFuseDL } }, + // GID_GOLD_DUST, OBJECT_GI_GOLD_DUST + { GetItem_DrawOpa01, { gGiGoldDustPowderDL, gGiGoldDustPowderEmptyDL } }, + // GID_SEAHORSE, OBJECT_GI_BOTTLE_16 + { GetItem_DrawOpa0Xlu1, { gGiSeahorseBottleEmptyDL, gGiSeahorseBottleGlassAndCorkDL } }, + // GID_60, OBJECT_GI_BOTTLE_22 + { GetItem_DrawOpa0Xlu1, { gGiHylianLoachBottleContentsDL, gGiHylianLoachBottleGlassCorkWaterDL } }, + // GID_HYLIAN_LOACH, OBJECT_GI_LOACH + { GetItem_DrawOpa0Xlu1, { gGiHylianLoachEmptyDL, gGiHylianLoachDL } }, + // GID_SEAHORSE_CAUGHT, OBJECT_GI_SEAHORSE + { GetItem_DrawSeahorse, { gGiSeahorseEmptyDL, gGiSeahorseBodyDL, gGiSeahorseGlowDL, &gGiSeahorseBillboardRotMtx } }, + // GID_REMAINS_GOHT, OBJECT_BSMASK + { GetItem_DrawRemains, { gRemainsGohtDL, gRemainsGohtDL } }, + // GID_REMAINS_GYORG, OBJECT_BSMASK + { GetItem_DrawRemains, { gRemainsGyorgDL, gRemainsGyorgDL } }, + // GID_REMAINS_TWINMOLD, OBJECT_BSMASK + { GetItem_DrawRemains, { gRemainsTwinmoldDL, gRemainsTwinmoldDL } }, + // GID_SWORD_RAZOR, OBJECT_GI_SWORD_2 + { GetItem_DrawOpa01, { gGiRazorSwordDL, gGiRazorSwordEmptyDL } }, + // GID_SWORD_GILDED, OBJECT_GI_SWORD_3 + { GetItem_DrawOpa01, { gGiGildedSwordDL, gGiGildedSwordEmptyDL } }, + // GID_SWORD_GREAT_FAIRY, OBJECT_GI_SWORD_4 + { GetItem_DrawOpa0Xlu1, { gGiGreatFairySwordBladeDL, gGiGreatFairySwordHiltEmblemDL } }, + // GID_MASK_GARO, OBJECT_GI_MASK09 + { GetItem_DrawOpa0Xlu1, { gGiGarosMaskCloakDL, gGiGarosMaskFaceDL } }, + // GID_MASK_GREAT_FAIRY, OBJECT_GI_MASK14 + { GetItem_DrawOpa0Xlu1, { gGiGreatFairyMaskFaceDL, gGiGreatFairyMaskLeavesDL } }, + // GID_MASK_GIBDO, OBJECT_GI_MASK15 + { GetItem_DrawOpa0Xlu1, { gGiGibdoMaskEmptyDL, gGiGibdoMaskDL } }, + // GID_ROOM_KEY, OBJECT_GI_RESERVE_B_00 + { GetItem_DrawOpa0Xlu1, { gGiRoomKeyEmptyDL, gGiRoomKeyDL } }, + // GID_LETTER_TO_KAFEI, OBJECT_GI_RESERVE_C_00 + { GetItem_DrawOpa0Xlu1, { gGiLetterToKafeiEnvelopeLetterDL, gGiLetterToKafeiInscriptionsDL } }, + // GID_PENDANT_OF_MEMORIES, OBJECT_GI_RESERVE_C_01 + { GetItem_DrawOpa0Xlu1, { gGiPendantOfMemoriesEmptyDL, gGiPendantOfMemoriesDL } }, + // GID_MUSHROOM, OBJECT_GI_MAGICMUSHROOM + { GetItem_DrawOpa0Xlu1, { gGiMagicMushroomEmptyDL, gGiMagicMushroomDL } }, + // GID_MASK_ROMANI, OBJECT_GI_MASK10 + { GetItem_DrawOpa0Xlu1, { gGiRomaniMaskCapDL, gGiRomaniMaskNoseEyeDL } }, + // GID_MASK_POSTMAN, OBJECT_GI_MASK12 + { GetItem_DrawOpa0Xlu1, { gGiPostmanHatCapDL, gGiPostmanHatBunnyLogoDL } }, + // GID_MASK_GIANT, OBJECT_GI_MASK23 + { GetItem_DrawOpa01, { gGiGiantMaskEmptyDL, gGiGiantMaskDL } }, + // GID_CHATEAU, OBJECT_GI_BOTTLE_21 + { GetItem_DrawOpa0Xlu1, { gGiChateauRomaniBottleEmptyDL, gGiChateauRomaniBottleDL } }, + // GID_PICTO_BOX, OBJECT_GI_CAMERA + { GetItem_DrawOpa0Xlu1, { gGiPictoBoxFrameDL, gGiPictoBoxBodyAndLensDL } }, + // GID_MASK_FIERCE_DEITY, OBJECT_GI_MASK03 + { GetItem_DrawOpa01, { gGiFierceDeityMaskFaceDL, gGiFierceDeityMaskHairAndHatDL } }, +}; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_draw/func_800EE5FC.s") +/** + * Draw "Get Item" Model + * Calls the corresponding draw function for the given draw ID + */ +void GetItem_Draw(PlayState* play, s16 drawId) { + sDrawItemTable[drawId].drawFunc(play, drawId); +} -#pragma GLOBAL_ASM("asm/non_matchings/code/z_draw/func_800EE7D8.s") +void GetItem_DrawBombchu(PlayState* play, s16 drawId) { + s32 pad; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_draw/func_800EE940.s") + OPEN_DISPS(play->state.gfxCtx); -#pragma GLOBAL_ASM("asm/non_matchings/code/z_draw/func_800EEA48.s") + func_8012C214(play->state.gfxCtx); -#pragma GLOBAL_ASM("asm/non_matchings/code/z_draw/func_800EEC18.s") + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_OPA_DISP++, sDrawItemTable[drawId].drawResources[0]); -#pragma GLOBAL_ASM("asm/non_matchings/code/z_draw/func_800EED20.s") + CLOSE_DISPS(play->state.gfxCtx); +} -#pragma GLOBAL_ASM("asm/non_matchings/code/z_draw/func_800EEE34.s") +void GetItem_DrawPoes(PlayState* play, s16 drawId) { + s32 pad; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_draw/func_800EEF4C.s") + OPEN_DISPS(play->state.gfxCtx); -#pragma GLOBAL_ASM("asm/non_matchings/code/z_draw/func_800EF054.s") + func_8012C28C(play->state.gfxCtx); -#pragma GLOBAL_ASM("asm/non_matchings/code/z_draw/func_800EF0F0.s") + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_OPA_DISP++, sDrawItemTable[drawId].drawResources[0]); -#pragma GLOBAL_ASM("asm/non_matchings/code/z_draw/func_800EF1F4.s") + func_8012C2DC(play->state.gfxCtx); -#pragma GLOBAL_ASM("asm/non_matchings/code/z_draw/func_800EF2AC.s") + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_XLU_DISP++, sDrawItemTable[drawId].drawResources[1]); -#pragma GLOBAL_ASM("asm/non_matchings/code/z_draw/func_800EF364.s") + gSPSegment(POLY_XLU_DISP++, 0x08, + Gfx_TwoTexScroll(play->state.gfxCtx, G_TX_RENDERTILE, play->state.frames * 0, play->state.frames * 0, 16, + 32, 1, play->state.frames, -(play->state.frames * 6), 16, 32)); -#pragma GLOBAL_ASM("asm/non_matchings/code/z_draw/func_800EF4D4.s") + Matrix_Push(); + Matrix_ReplaceRotation(&play->billboardMtxF); -#pragma GLOBAL_ASM("asm/non_matchings/code/z_draw/func_800EF65C.s") + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_XLU_DISP++, sDrawItemTable[drawId].drawResources[3]); + gSPDisplayList(POLY_XLU_DISP++, sDrawItemTable[drawId].drawResources[2]); -#pragma GLOBAL_ASM("asm/non_matchings/code/z_draw/func_800EF780.s") + Matrix_Pop(); -#pragma GLOBAL_ASM("asm/non_matchings/code/z_draw/func_800EF89C.s") + CLOSE_DISPS(play->state.gfxCtx); +} -#pragma GLOBAL_ASM("asm/non_matchings/code/z_draw/func_800EF984.s") +void GetItem_DrawFairyBottle(PlayState* play, s16 drawId) { + s32 pad; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_draw/func_800EFAB8.s") + OPEN_DISPS(play->state.gfxCtx); -#pragma GLOBAL_ASM("asm/non_matchings/code/z_draw/func_800EFBFC.s") + func_8012C28C(play->state.gfxCtx); -#pragma GLOBAL_ASM("asm/non_matchings/code/z_draw/func_800EFD44.s") + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_OPA_DISP++, sDrawItemTable[drawId].drawResources[0]); + + func_8012C2DC(play->state.gfxCtx); + + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_XLU_DISP++, sDrawItemTable[drawId].drawResources[1]); + gSPSegment(POLY_XLU_DISP++, 0x08, + Gfx_TwoTexScroll(play->state.gfxCtx, G_TX_RENDERTILE, play->state.frames * 0, play->state.frames * 0, 32, + 32, 1, play->state.frames, -(play->state.frames * 6), 32, 32)); + + Matrix_Push(); + Matrix_ReplaceRotation(&play->billboardMtxF); + + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_XLU_DISP++, sDrawItemTable[drawId].drawResources[2]); + + Matrix_Pop(); + + CLOSE_DISPS(play->state.gfxCtx); +} + +void GetItem_DrawSkullToken(PlayState* play, s16 drawId) { + s32 pad; + + OPEN_DISPS(play->state.gfxCtx); + + func_8012C28C(play->state.gfxCtx); + + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_OPA_DISP++, sDrawItemTable[drawId].drawResources[0]); + + func_8012C2DC(play->state.gfxCtx); + + gSPSegment(POLY_XLU_DISP++, 0x08, + Gfx_TwoTexScroll(play->state.gfxCtx, G_TX_RENDERTILE, play->state.frames * 0, -(play->state.frames * 5), + 32, 32, 1, play->state.frames * 0, play->state.frames * 0, 32, 64)); + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_XLU_DISP++, sDrawItemTable[drawId].drawResources[1]); + + CLOSE_DISPS(play->state.gfxCtx); +} + +void GetItem_DrawCompass(PlayState* play, s16 drawId) { + s32 pad; + + OPEN_DISPS(play->state.gfxCtx); + + func_8012C28C(play->state.gfxCtx); + + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_OPA_DISP++, sDrawItemTable[drawId].drawResources[0]); + + POLY_XLU_DISP = Gfx_CallSetupDL(POLY_XLU_DISP, 5); + + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_XLU_DISP++, sDrawItemTable[drawId].drawResources[1]); + + CLOSE_DISPS(play->state.gfxCtx); +} + +void GetItem_DrawPotion(PlayState* play, s16 drawId) { + s32 pad; + + OPEN_DISPS(play->state.gfxCtx); + + func_8012C28C(play->state.gfxCtx); + + gSPSegment(POLY_OPA_DISP++, 0x08, + Gfx_TwoTexScroll(play->state.gfxCtx, G_TX_RENDERTILE, -play->state.frames, play->state.frames, 32, 32, 1, + -play->state.frames, play->state.frames, 32, 32)); + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_OPA_DISP++, sDrawItemTable[drawId].drawResources[1]); + gSPDisplayList(POLY_OPA_DISP++, sDrawItemTable[drawId].drawResources[0]); + gSPDisplayList(POLY_OPA_DISP++, sDrawItemTable[drawId].drawResources[2]); + gSPDisplayList(POLY_OPA_DISP++, sDrawItemTable[drawId].drawResources[3]); + + func_8012C2DC(play->state.gfxCtx); + + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_XLU_DISP++, sDrawItemTable[drawId].drawResources[4]); + gSPDisplayList(POLY_XLU_DISP++, sDrawItemTable[drawId].drawResources[5]); + + CLOSE_DISPS(play->state.gfxCtx); +} + +void GetItem_DrawGoronSword(PlayState* play, s16 drawId) { + s32 pad; + + OPEN_DISPS(play->state.gfxCtx); + + func_8012C28C(play->state.gfxCtx); + + gSPSegment(POLY_OPA_DISP++, 0x08, + Gfx_TwoTexScroll(play->state.gfxCtx, G_TX_RENDERTILE, play->state.frames * 1, play->state.frames * 0, 32, + 32, 1, play->state.frames * 0, play->state.frames * 0, 32, 32)); + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_OPA_DISP++, sDrawItemTable[drawId].drawResources[0]); + + CLOSE_DISPS(play->state.gfxCtx); +} + +void GetItem_DrawDekuNuts(PlayState* play, s16 drawId) { + s32 pad; + + OPEN_DISPS(play->state.gfxCtx); + + func_8012C28C(play->state.gfxCtx); + + gSPSegment(POLY_OPA_DISP++, 0x08, + Gfx_TwoTexScroll(play->state.gfxCtx, G_TX_RENDERTILE, play->state.frames * 6, play->state.frames * 6, 32, + 32, 1, play->state.frames * 6, play->state.frames * 6, 32, 32)); + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_OPA_DISP++, sDrawItemTable[drawId].drawResources[0]); + + CLOSE_DISPS(play->state.gfxCtx); +} + +void GetItem_DrawRecoveryHeart(PlayState* play, s16 drawId) { + s32 pad; + + OPEN_DISPS(play->state.gfxCtx); + + func_8012C2DC(play->state.gfxCtx); + + gSPSegment(POLY_XLU_DISP++, 0x08, + Gfx_TwoTexScroll(play->state.gfxCtx, G_TX_RENDERTILE, play->state.frames * 0, -(play->state.frames * 3), + 32, 32, 1, play->state.frames * 0, -(play->state.frames * 2), 32, 32)); + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_XLU_DISP++, sDrawItemTable[drawId].drawResources[0]); + + CLOSE_DISPS(play->state.gfxCtx); +} + +void GetItem_DrawFish(PlayState* play, s16 drawId) { + s32 pad; + + OPEN_DISPS(play->state.gfxCtx); + + func_8012C2DC(play->state.gfxCtx); + + gSPSegment(POLY_XLU_DISP++, 0x08, + Gfx_TwoTexScroll(play->state.gfxCtx, G_TX_RENDERTILE, play->state.frames * 0, play->state.frames * 1, 32, + 32, 1, play->state.frames * 0, play->state.frames * 1, 32, 32)); + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_XLU_DISP++, sDrawItemTable[drawId].drawResources[0]); + + CLOSE_DISPS(play->state.gfxCtx); +} + +/** + * Draw `drawResources[0]` as Opa + */ +void GetItem_DrawOpa0(PlayState* play, s16 drawId) { + s32 pad; + + OPEN_DISPS(play->state.gfxCtx); + + func_8012C28C(play->state.gfxCtx); + + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_OPA_DISP++, sDrawItemTable[drawId].drawResources[0]); + + CLOSE_DISPS(play->state.gfxCtx); +} + +/** + * Draw `drawResources[0]` as Opa and `drawResources[1]` as Xlu + */ +void GetItem_DrawOpa0Xlu1(PlayState* play, s16 drawId) { + s32 pad; + + OPEN_DISPS(play->state.gfxCtx); + + func_8012C28C(play->state.gfxCtx); + + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_OPA_DISP++, sDrawItemTable[drawId].drawResources[0]); + + func_8012C2DC(play->state.gfxCtx); + + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_XLU_DISP++, sDrawItemTable[drawId].drawResources[1]); + + CLOSE_DISPS(play->state.gfxCtx); +} + +/** + * Draw `drawResources[0]` and `drawResources[1]` as Opa + */ +void GetItem_DrawOpa01(PlayState* play, s16 drawId) { + s32 pad; + + OPEN_DISPS(play->state.gfxCtx); + + func_8012C28C(play->state.gfxCtx); + + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_OPA_DISP++, sDrawItemTable[drawId].drawResources[0]); + gSPDisplayList(POLY_OPA_DISP++, sDrawItemTable[drawId].drawResources[1]); + + CLOSE_DISPS(play->state.gfxCtx); +} + +/** + * Draw `drawResources[0]` and `drawResources[1]` as Xlu + */ +void GetItem_DrawXlu01(PlayState* play, s16 drawId) { + s32 pad; + + OPEN_DISPS(play->state.gfxCtx); + + func_8012C2DC(play->state.gfxCtx); + + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_XLU_DISP++, sDrawItemTable[drawId].drawResources[0]); + gSPDisplayList(POLY_XLU_DISP++, sDrawItemTable[drawId].drawResources[1]); + + CLOSE_DISPS(play->state.gfxCtx); +} + +void GetItem_DrawSeahorse(PlayState* play, s16 drawId) { + s32 pad; + MtxF mtx; + + OPEN_DISPS(play->state.gfxCtx); + + func_8012C28C(play->state.gfxCtx); + + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_OPA_DISP++, sDrawItemTable[drawId].drawResources[0]); + + func_8012C2DC(play->state.gfxCtx); + + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_XLU_DISP++, sDrawItemTable[drawId].drawResources[1]); + + Matrix_MtxToMtxF(Lib_SegmentedToVirtual(sDrawItemTable[drawId].drawResources[3]), &mtx); + Matrix_Mult(&mtx, MTXMODE_APPLY); + Matrix_ReplaceRotation(&play->billboardMtxF); + + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_XLU_DISP++, sDrawItemTable[drawId].drawResources[2]); + + CLOSE_DISPS(play->state.gfxCtx); +} + +void GetItem_DrawFairyContainer(PlayState* play, s16 drawId) { + s32 pad; + MtxF mtx; + + OPEN_DISPS(play->state.gfxCtx); + + func_8012C28C(play->state.gfxCtx); + func_8012C2DC(play->state.gfxCtx); + AnimatedMat_Draw(play, Lib_SegmentedToVirtual(gGiFairyBottleTexAnim)); + + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_OPA_DISP++, sDrawItemTable[drawId].drawResources[0]); + + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_XLU_DISP++, sDrawItemTable[drawId].drawResources[1]); + + Matrix_MtxToMtxF(Lib_SegmentedToVirtual(sDrawItemTable[drawId].drawResources[3]), &mtx); + Matrix_Mult(&mtx, MTXMODE_APPLY); + Matrix_ReplaceRotation(&play->billboardMtxF); + + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_XLU_DISP++, sDrawItemTable[drawId].drawResources[2]); + + CLOSE_DISPS(play->state.gfxCtx); +} + +void GetItem_DrawMoonsTear(PlayState* play, s16 drawId) { + s32 pad; + + OPEN_DISPS(play->state.gfxCtx); + + func_8012C28C(play->state.gfxCtx); + func_8012C2DC(play->state.gfxCtx); + AnimatedMat_Draw(play, Lib_SegmentedToVirtual(gGiMoonsTearTexAnim)); + + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_OPA_DISP++, sDrawItemTable[drawId].drawResources[0]); + + Matrix_ReplaceRotation(&play->billboardMtxF); + + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_XLU_DISP++, sDrawItemTable[drawId].drawResources[1]); + + CLOSE_DISPS(play->state.gfxCtx); +} + +void GetItem_DrawMagicArrow(PlayState* play, s16 drawId) { + s32 pad; + + OPEN_DISPS(play->state.gfxCtx); + + func_8012C28C(play->state.gfxCtx); + + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_OPA_DISP++, sDrawItemTable[drawId].drawResources[0]); + + func_8012C2DC(play->state.gfxCtx); + + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_XLU_DISP++, sDrawItemTable[drawId].drawResources[1]); + gSPDisplayList(POLY_XLU_DISP++, sDrawItemTable[drawId].drawResources[2]); + + CLOSE_DISPS(play->state.gfxCtx); +} + +void GetItem_DrawUpgrades(PlayState* play, s16 drawId) { + s32 pad; + + OPEN_DISPS(play->state.gfxCtx); + + func_8012C28C(play->state.gfxCtx); + + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_OPA_DISP++, sDrawItemTable[drawId].drawResources[1]); + gSPDisplayList(POLY_OPA_DISP++, sDrawItemTable[drawId].drawResources[0]); + gSPDisplayList(POLY_OPA_DISP++, sDrawItemTable[drawId].drawResources[2]); + gSPDisplayList(POLY_OPA_DISP++, sDrawItemTable[drawId].drawResources[3]); + + CLOSE_DISPS(play->state.gfxCtx); +} + +void GetItem_DrawRupee(PlayState* play, s16 drawId) { + s32 pad; + + OPEN_DISPS(play->state.gfxCtx); + + func_8012C28C(play->state.gfxCtx); + + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_OPA_DISP++, sDrawItemTable[drawId].drawResources[1]); + gSPDisplayList(POLY_OPA_DISP++, sDrawItemTable[drawId].drawResources[0]); + + func_8012C2DC(play->state.gfxCtx); + + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_XLU_DISP++, sDrawItemTable[drawId].drawResources[3]); + gSPDisplayList(POLY_XLU_DISP++, sDrawItemTable[drawId].drawResources[2]); + + CLOSE_DISPS(play->state.gfxCtx); +} + +void GetItem_DrawSmallRupee(PlayState* play, s16 drawId) { + s32 pad; + + OPEN_DISPS(play->state.gfxCtx); + + Matrix_Scale(0.7f, 0.7f, 0.7f, MTXMODE_APPLY); + func_8012C28C(play->state.gfxCtx); + + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_OPA_DISP++, sDrawItemTable[drawId].drawResources[1]); + gSPDisplayList(POLY_OPA_DISP++, sDrawItemTable[drawId].drawResources[0]); + + func_8012C2DC(play->state.gfxCtx); + + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_XLU_DISP++, sDrawItemTable[drawId].drawResources[3]); + gSPDisplayList(POLY_XLU_DISP++, sDrawItemTable[drawId].drawResources[2]); + + CLOSE_DISPS(play->state.gfxCtx); +} + +void GetItem_DrawWallet(PlayState* play, s16 drawId) { + s32 pad; + + OPEN_DISPS(play->state.gfxCtx); + + func_8012C28C(play->state.gfxCtx); + + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_OPA_DISP++, sDrawItemTable[drawId].drawResources[1]); + gSPDisplayList(POLY_OPA_DISP++, sDrawItemTable[drawId].drawResources[0]); + gSPDisplayList(POLY_OPA_DISP++, sDrawItemTable[drawId].drawResources[2]); + gSPDisplayList(POLY_OPA_DISP++, sDrawItemTable[drawId].drawResources[3]); + gSPDisplayList(POLY_OPA_DISP++, sDrawItemTable[drawId].drawResources[4]); + gSPDisplayList(POLY_OPA_DISP++, sDrawItemTable[drawId].drawResources[5]); + gSPDisplayList(POLY_OPA_DISP++, sDrawItemTable[drawId].drawResources[6]); + gSPDisplayList(POLY_OPA_DISP++, sDrawItemTable[drawId].drawResources[7]); + + CLOSE_DISPS(play->state.gfxCtx); +} + +void GetItem_DrawRemains(PlayState* play, s16 drawId) { + s32 pad; + s8 objectIndex; + + OPEN_DISPS(play->state.gfxCtx); + + objectIndex = Object_GetIndex(&play->objectCtx, OBJECT_BSMASK); + + gSPSegment(POLY_OPA_DISP++, 0x06, play->objectCtx.status[objectIndex].segment); + + func_8012C28C(play->state.gfxCtx); + Matrix_Scale(0.02f, 0.02f, 0.02f, MTXMODE_APPLY); + + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_OPA_DISP++, sDrawItemTable[drawId].drawResources[0]); + + POLY_OPA_DISP = func_801660B8(play, POLY_OPA_DISP); + + CLOSE_DISPS(play->state.gfxCtx); +} 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..1dc3d7237 100644 --- a/src/code/z_eff_footmark.c +++ b/src/code/z_eff_footmark.c @@ -1,10 +1,10 @@ #include "global.h" -void EffFootmark_Init(GlobalContext* globalCtx) { +void EffFootmark_Init(PlayState* play) { EffFootmark* footmark; s32 i; - for (footmark = globalCtx->footprintInfo, i = 0; i < 100; i++, footmark++) { + for (footmark = play->footprintInfo, i = 0; i < 100; i++, footmark++) { footmark->actor = NULL; footmark->location.x = 0; footmark->location.y = 0; @@ -16,15 +16,15 @@ void EffFootmark_Init(GlobalContext* globalCtx) { } } -void EffFootmark_Add(GlobalContext* globalCtx, MtxF* displayMatrix, Actor* actor, u8 id, Vec3f* location, u16 size, - u8 red, u8 green, u8 blue, u16 alpha, u16 alphaChange, u16 fadeoutDelay) { +void EffFootmark_Add(PlayState* play, MtxF* displayMatrix, Actor* actor, u8 id, Vec3f* location, u16 size, u8 red, + u8 green, u8 blue, u16 alpha, u16 alphaChange, u16 fadeoutDelay) { s32 i; EffFootmark* footmark; EffFootmark* destination = NULL; EffFootmark* oldest = NULL; s32 isNew = 1; - for (footmark = globalCtx->footprintInfo, i = 0; i < 100; i++, footmark++) { + for (footmark = play->footprintInfo, i = 0; i < 100; i++, footmark++) { if (((actor == footmark->actor) && (footmark->id == id)) && ((footmark->flags & 1) == 0)) { if (fabsf((footmark->location).x - location->x) <= 1) { if (fabsf((footmark->location).z - location->z) <= 1) { @@ -70,14 +70,14 @@ void EffFootmark_Add(GlobalContext* globalCtx, MtxF* displayMatrix, Actor* actor } } -void EffFootmark_Update(GlobalContext* globalCtx) { +void EffFootmark_Update(PlayState* play) { EffFootmark* footmark; s32 i; - for (footmark = globalCtx->footprintInfo, i = 0; i < 100; i++, footmark++) { + for (footmark = play->footprintInfo, i = 0; i < 100; i++, footmark++) { if (footmark->actor != NULL) { if ((footmark->flags & 1) == 1) { - if (footmark->age < 0xFFFFu) { // TODO replace with MAX_U16 or something + if ((u32)footmark->age < UINT16_MAX) { footmark->age++; } @@ -95,21 +95,21 @@ void EffFootmark_Update(GlobalContext* globalCtx) { } } -void EffFootmark_Draw(GlobalContext* globalCtx) { +void EffFootmark_Draw(PlayState* play) { EffFootmark* footmark; s32 i; - GraphicsContext* gfxCtx = globalCtx->state.gfxCtx; + GraphicsContext* gfxCtx = play->state.gfxCtx; - func_8012C448(globalCtx->state.gfxCtx); + func_8012C448(play->state.gfxCtx); gSPDisplayList(gfxCtx->polyXlu.p++, D_801BC240); - for (footmark = globalCtx->footprintInfo, i = 0; i < 100; i++, footmark++) { + for (footmark = play->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); + gSPMatrix(gfxCtx->polyXlu.p++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD); gDPSetPrimColor(gfxCtx->polyXlu.p++, 0, 0, footmark->red, footmark->green, footmark->blue, footmark->alpha >> 8); diff --git a/src/code/z_eff_shield_particle.c b/src/code/z_eff_shield_particle.c index e3a051fb4..90833947b 100644 --- a/src/code/z_eff_shield_particle.c +++ b/src/code/z_eff_shield_particle.c @@ -43,7 +43,7 @@ void EffectShieldParticle_Init(void* thisx, void* initParamsx) { this->lightInfo.type = LIGHT_POINT_NOGLOW; this->lightInfo.params.point = initParams->lightPoint; this->lightNode = - LightContext_InsertLight(Effect_GetGlobalCtx(), &Effect_GetGlobalCtx()->lightCtx, &this->lightInfo); + LightContext_InsertLight(Effect_GetPlayState(), &Effect_GetPlayState()->lightCtx, &this->lightInfo); } else { this->lightNode = NULL; } @@ -54,10 +54,10 @@ void EffectShieldParticle_Destroy(void* thisx) { EffectShieldParticle* this = (EffectShieldParticle*)thisx; if ((this != NULL) && (this->lightDecay == true)) { - if (this->lightNode == Effect_GetGlobalCtx()->lightCtx.listHead) { - Effect_GetGlobalCtx()->lightCtx.listHead = this->lightNode->next; + if (this->lightNode == Effect_GetPlayState()->lightCtx.listHead) { + Effect_GetPlayState()->lightCtx.listHead = this->lightNode->next; } - LightContext_RemoveLight(Effect_GetGlobalCtx(), &Effect_GetGlobalCtx()->lightCtx, this->lightNode); + LightContext_RemoveLight(Effect_GetPlayState(), &Effect_GetPlayState()->lightCtx, this->lightNode); } } diff --git a/src/code/z_eff_spark.c b/src/code/z_eff_spark.c index 697c55398..fd92516df 100644 --- a/src/code/z_eff_spark.c +++ b/src/code/z_eff_spark.c @@ -122,7 +122,7 @@ s32 EffectSpark_Update(void* thisx) { void EffectSpark_Draw(void* thisx, GraphicsContext* gfxCtx) { Vtx* vertices; EffectSpark* this = (EffectSpark*)thisx; - GlobalContext* globalCtx = Effect_GetGlobalCtx(); + PlayState* play = Effect_GetPlayState(); s32 i; s32 j; u8 sp1D3; @@ -199,7 +199,7 @@ void EffectSpark_Draw(void* thisx, GraphicsContext* gfxCtx) { SkinMatrix_SetTranslate(&spEC, elem->position.x, elem->position.y, elem->position.z); temp = ((Rand_ZeroOne() * 2.5f) + 1.5f) / 64.0f; SkinMatrix_SetScale(&spAC, temp, temp, 1.0f); - SkinMatrix_MtxFMtxFMult(&spEC, &globalCtx->billboardMtxF, &sp6C); + SkinMatrix_MtxFMtxFMult(&spEC, &play->billboardMtxF, &sp6C); SkinMatrix_MtxFMtxFMult(&sp6C, &spAC, &sp12C); vertices[j].v.ob[0] = -32; diff --git a/src/code/z_eff_ss_dead.c b/src/code/z_eff_ss_dead.c index bd93f5eed..b7c6af97e 100644 --- a/src/code/z_eff_ss_dead.c +++ b/src/code/z_eff_ss_dead.c @@ -1,11 +1,11 @@ #include "global.h" -void func_800AE2A0(GlobalContext* globalCtx, Color_RGBA8* color, s16 arg2, s16 arg3) { +void func_800AE2A0(PlayState* play, Color_RGBA8* color, s16 arg2, s16 arg3) { f32 cos; Gfx* displayListHead; f32 absCos; - OPEN_DISPS(globalCtx->state.gfxCtx); + OPEN_DISPS(play->state.gfxCtx); displayListHead = POLY_OPA_DISP; cos = Math_CosS((0x8000 / arg3) * arg2); @@ -23,14 +23,14 @@ void func_800AE2A0(GlobalContext* globalCtx, Color_RGBA8* color, s16 arg2, s16 a POLY_OPA_DISP = displayListHead; - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->state.gfxCtx); } -void func_800AE434(GlobalContext* globalCtx, Color_RGBA8* color, s16 arg2, s16 arg3) { +void func_800AE434(PlayState* play, Color_RGBA8* color, s16 arg2, s16 arg3) { Gfx* displayListHead; f32 cos; - OPEN_DISPS(globalCtx->state.gfxCtx); + OPEN_DISPS(play->state.gfxCtx); cos = Math_CosS((0x4000 / arg3) * arg2); displayListHead = POLY_OPA_DISP; @@ -41,26 +41,26 @@ void func_800AE434(GlobalContext* globalCtx, Color_RGBA8* color, s16 arg2, s16 a POLY_OPA_DISP = displayListHead; - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->state.gfxCtx); } -void func_800AE5A0(GlobalContext* globalCtx) { +void func_800AE5A0(PlayState* play) { s32 pad; - OPEN_DISPS(globalCtx->state.gfxCtx); + OPEN_DISPS(play->state.gfxCtx); gDPPipeSync(POLY_OPA_DISP++); - POLY_OPA_DISP = func_801660B8(globalCtx, POLY_OPA_DISP); + POLY_OPA_DISP = func_801660B8(play, POLY_OPA_DISP); - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->state.gfxCtx); } -void func_800AE5E4(GlobalContext* globalCtx, Color_RGBA8* color, s16 arg2, s16 arg3) { +void func_800AE5E4(PlayState* play, Color_RGBA8* color, s16 arg2, s16 arg3) { f32 cos; Gfx* displayListHead; f32 absCos; - OPEN_DISPS(globalCtx->state.gfxCtx); + OPEN_DISPS(play->state.gfxCtx); displayListHead = POLY_XLU_DISP; cos = Math_CosS((0x8000 / arg3) * arg2); @@ -78,14 +78,14 @@ void func_800AE5E4(GlobalContext* globalCtx, Color_RGBA8* color, s16 arg2, s16 a POLY_XLU_DISP = displayListHead; - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->state.gfxCtx); } -void func_800AE778(GlobalContext* globalCtx, Color_RGBA8* color, s16 arg2, s16 arg3) { +void func_800AE778(PlayState* play, Color_RGBA8* color, s16 arg2, s16 arg3) { f32 cos; Gfx* displayListHead; - OPEN_DISPS(globalCtx->state.gfxCtx); + OPEN_DISPS(play->state.gfxCtx); displayListHead = POLY_XLU_DISP; cos = Math_CosS((0x4000 / arg3) * arg2); @@ -96,16 +96,16 @@ void func_800AE778(GlobalContext* globalCtx, Color_RGBA8* color, s16 arg2, s16 a POLY_XLU_DISP = displayListHead; - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->state.gfxCtx); } -void func_800AE8EC(GlobalContext* globalCtx) { +void func_800AE8EC(PlayState* play) { s32 pad; - OPEN_DISPS(globalCtx->state.gfxCtx); + OPEN_DISPS(play->state.gfxCtx); gDPPipeSync(POLY_XLU_DISP++); - POLY_XLU_DISP = func_801660B8(globalCtx, POLY_XLU_DISP); + POLY_XLU_DISP = func_801660B8(play, POLY_XLU_DISP); - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->state.gfxCtx); } diff --git a/src/code/z_effect.c b/src/code/z_effect.c index 4c446b650..b4a76380e 100644 --- a/src/code/z_effect.c +++ b/src/code/z_effect.c @@ -40,8 +40,8 @@ EffectInfo sEffectInfoTable[] = { }, }; -GlobalContext* Effect_GetGlobalCtx(void) { - return sEffectContext.globalCtx; +PlayState* Effect_GetPlayState(void) { + return sEffectContext.play; } void* Effect_GetByIndex(s32 index) { @@ -93,7 +93,7 @@ void Effect_InitStatus(EffectStatus* status) { status->unk2 = 0; } -void Effect_Init(GlobalContext* globalCtx) { +void Effect_Init(PlayState* play) { s32 i; for (i = 0; i < SPARK_COUNT; i++) { @@ -113,10 +113,10 @@ void Effect_Init(GlobalContext* globalCtx) { Effect_InitStatus(&sEffectContext.tireMarks[i].status); } - sEffectContext.globalCtx = globalCtx; + sEffectContext.play = play; } -void Effect_Add(GlobalContext* globalCtx, s32* pIndex, s32 type, u8 arg3, u8 arg4, void* initParams) { +void Effect_Add(PlayState* play, s32* pIndex, s32 type, u8 arg3, u8 arg4, void* initParams) { u32 slotFound; s32 i; void* effect = NULL; @@ -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->state) != true) { + if (FrameAdvance_IsEnabled(&play->state) != true) { slotFound = false; switch (type) { case EFFECT_SPARK: @@ -217,14 +217,14 @@ void Effect_DrawAll(GraphicsContext* gfxCtx) { } } -void Effect_UpdateAll(GlobalContext* globalCtx) { +void Effect_UpdateAll(PlayState* play) { s32 i; for (i = 0; i < SPARK_COUNT; i++) { if (1) {} // necessary to match if (sEffectContext.sparks[i].status.active) { if (sEffectInfoTable[EFFECT_SPARK].update(&sEffectContext.sparks[i].effect) == 1) { - Effect_Destroy(globalCtx, i); + Effect_Destroy(play, i); } } } @@ -233,7 +233,7 @@ void Effect_UpdateAll(GlobalContext* globalCtx) { if (1) {} // necessary to match if (sEffectContext.blures[i].status.active) { if (sEffectInfoTable[EFFECT_BLURE1].update(&sEffectContext.blures[i].effect) == 1) { - Effect_Destroy(globalCtx, i + SPARK_COUNT); + Effect_Destroy(play, i + SPARK_COUNT); } } } @@ -242,7 +242,7 @@ void Effect_UpdateAll(GlobalContext* globalCtx) { if (1) {} // necessary to match if (sEffectContext.shieldParticles[i].status.active) { if (sEffectInfoTable[EFFECT_SHIELD_PARTICLE].update(&sEffectContext.shieldParticles[i].effect) == 1) { - Effect_Destroy(globalCtx, i + SPARK_COUNT + BLURE_COUNT); + Effect_Destroy(play, i + SPARK_COUNT + BLURE_COUNT); } } } @@ -251,13 +251,13 @@ void Effect_UpdateAll(GlobalContext* globalCtx) { if (1) {} // necessary to match if (sEffectContext.tireMarks[i].status.active) { if (sEffectInfoTable[EFFECT_TIRE_MARK].update(&sEffectContext.tireMarks[i].effect) == 1) { - Effect_Destroy(globalCtx, i + SPARK_COUNT + BLURE_COUNT + SHIELD_PARTICLE_COUNT); + Effect_Destroy(play, i + SPARK_COUNT + BLURE_COUNT + SHIELD_PARTICLE_COUNT); } } } } -void Effect_Destroy(GlobalContext* globalCtx, s32 index) { +void Effect_Destroy(PlayState* play, s32 index) { if (index == TOTAL_EFFECT_COUNT) { return; } @@ -290,7 +290,7 @@ void Effect_Destroy(GlobalContext* globalCtx, s32 index) { } } -void Effect_DestroyAll(GlobalContext* globalCtx) { +void Effect_DestroyAll(PlayState* play) { s32 i; for (i = 0; i < SPARK_COUNT; i++) { diff --git a/src/code/z_effect_soft_sprite.c b/src/code/z_effect_soft_sprite.c index fd1d0212c..ea8a546d6 100644 --- a/src/code/z_effect_soft_sprite.c +++ b/src/code/z_effect_soft_sprite.c @@ -1,13 +1,14 @@ #include "global.h" +#include "z64load.h" EffectSsInfo sEffectSsInfo = { NULL, 0, 0 }; -void EffectSS_Init(GlobalContext* globalCtx, s32 numEntries) { +void EffectSS_Init(PlayState* play, s32 numEntries) { u32 i; EffectSs* effectsSs; EffectSsOverlay* overlay; - sEffectSsInfo.data_table = (EffectSs*)THA_AllocEndAlign16(&globalCtx->state.heap, numEntries * sizeof(EffectSs)); + sEffectSsInfo.data_table = (EffectSs*)THA_AllocEndAlign16(&play->state.heap, numEntries * sizeof(EffectSs)); sEffectSsInfo.searchIndex = 0; sEffectSsInfo.size = numEntries; @@ -23,7 +24,7 @@ void EffectSS_Init(GlobalContext* globalCtx, s32 numEntries) { } } -void EffectSS_Clear(GlobalContext* globalCtx) { +void EffectSS_Clear(PlayState* play) { u32 i; EffectSs* effectsSs; EffectSsOverlay* overlay; @@ -58,11 +59,11 @@ EffectSs* EffectSS_GetTable() { void EffectSS_Delete(EffectSs* effectSs) { if (effectSs->flags & 2) { - Audio_StopSfxByPos(&effectSs->pos); + AudioSfx_StopByPos(&effectSs->pos); } if (effectSs->flags & 4) { - Audio_StopSfxByPos(&effectSs->vec); + AudioSfx_StopByPos(&effectSs->vec); } EffectSS_ResetEntry(effectSs); @@ -149,10 +150,10 @@ s32 EffectSS_FindFreeSpace(s32 priority, s32* tableEntry) { return false; } -void EffectSS_Copy(GlobalContext* globalCtx, EffectSs* effectsSs) { +void EffectSS_Copy(PlayState* play, EffectSs* effectsSs) { s32 index; - if (FrameAdvance_IsEnabled(&globalCtx->state) != true) { + if (FrameAdvance_IsEnabled(&play->state) != true) { if (EffectSS_FindFreeSpace(effectsSs->priority, &index) == 0) { sEffectSsInfo.searchIndex = index + 1; sEffectSsInfo.data_table[index] = *effectsSs; @@ -160,7 +161,7 @@ void EffectSS_Copy(GlobalContext* globalCtx, EffectSs* effectsSs) { } } -void EffectSs_Spawn(GlobalContext* globalCtx, s32 type, s32 priority, void* initData) { +void EffectSs_Spawn(PlayState* play, s32 type, s32 priority, void* initData) { s32 index; u32 overlaySize; EffectSsOverlay* entry = &gParticleOverlayTable[type]; @@ -187,8 +188,9 @@ void EffectSs_Spawn(GlobalContext* globalCtx, s32 type, s32 priority, void* init Load2_LoadOverlay(entry->vromStart, entry->vromEnd, entry->vramStart, entry->vramEnd, entry->loadedRamAddr); } - initInfo = (uintptr_t)( - (entry->initInfo != NULL) ? (void*)(-OVERLAY_RELOCATION_OFFSET(entry) + (uintptr_t)entry->initInfo) : NULL); + initInfo = (uintptr_t)((entry->initInfo != NULL) + ? (void*)((uintptr_t)entry->initInfo - (intptr_t)OVERLAY_RELOCATION_OFFSET(entry)) + : NULL); } if (initInfo->init != NULL) { @@ -198,13 +200,13 @@ void EffectSs_Spawn(GlobalContext* globalCtx, s32 type, s32 priority, void* init sEffectSsInfo.data_table[index].type = type; sEffectSsInfo.data_table[index].priority = priority; - if (initInfo->init(globalCtx, index, &sEffectSsInfo.data_table[index], initData) == 0) { + if (initInfo->init(play, index, &sEffectSsInfo.data_table[index], initData) == 0) { EffectSS_ResetEntry(&sEffectSsInfo.data_table[index]); } } } -void EffectSS_UpdateParticle(GlobalContext* globalCtx, s32 index) { +void EffectSS_UpdateParticle(PlayState* play, s32 index) { EffectSs* particle = &sEffectSsInfo.data_table[index]; if (particle->update != NULL) { @@ -216,11 +218,11 @@ void EffectSS_UpdateParticle(GlobalContext* globalCtx, s32 index) { particle->pos.y += particle->velocity.y; particle->pos.z += particle->velocity.z; - particle->update(globalCtx, index, particle); + particle->update(play, index, particle); } } -void EffectSS_UpdateAllParticles(GlobalContext* globalCtx) { +void EffectSS_UpdateAllParticles(PlayState* play) { s32 i; for (i = 0; i < sEffectSsInfo.size; i++) { @@ -233,25 +235,25 @@ void EffectSS_UpdateAllParticles(GlobalContext* globalCtx) { } if (sEffectSsInfo.data_table[i].life > -1) { - EffectSS_UpdateParticle(globalCtx, i); + EffectSS_UpdateParticle(play, i); } } } -void EffectSS_DrawParticle(GlobalContext* globalCtx, s32 index) { +void EffectSS_DrawParticle(PlayState* play, s32 index) { EffectSs* entry = &sEffectSsInfo.data_table[index]; if (entry->draw != NULL) { - entry->draw(globalCtx, index, entry); + entry->draw(play, index, entry); } } -void EffectSS_DrawAllParticles(GlobalContext* globalCtx) { - Lights* lights = LightContext_NewLights(&globalCtx->lightCtx, globalCtx->state.gfxCtx); +void EffectSS_DrawAllParticles(PlayState* play) { + Lights* lights = LightContext_NewLights(&play->lightCtx, play->state.gfxCtx); s32 i; - Lights_BindAll(lights, globalCtx->lightCtx.listHead, NULL, globalCtx); - Lights_Draw(lights, globalCtx->state.gfxCtx); + Lights_BindAll(lights, play->lightCtx.listHead, NULL, play); + Lights_Draw(lights, play->state.gfxCtx); for (i = 0; i < sEffectSsInfo.size; i++) { if (sEffectSsInfo.data_table[i].life > -1) { @@ -263,7 +265,7 @@ void EffectSS_DrawAllParticles(GlobalContext* globalCtx) { (sEffectSsInfo.data_table[i].pos.z < BGCHECK_Y_MIN)) { EffectSS_Delete(&sEffectSsInfo.data_table[i]); } else { - EffectSS_DrawParticle(globalCtx, i); + EffectSS_DrawParticle(play, 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..5258c2ecf 100644 --- a/src/code/z_effect_soft_sprite_old_init.c +++ b/src/code/z_effect_soft_sprite_old_init.c @@ -32,8 +32,8 @@ #include "overlays/effects/ovl_Effect_Ss_Stick/z_eff_ss_stick.h" #include "overlays/effects/ovl_Effect_Ss_Stone1/z_eff_ss_stone1.h" -void EffectSs_DrawGEffect(GlobalContext* globalCtx, EffectSs* this, void* texture) { - GraphicsContext* gfxCtx = globalCtx->state.gfxCtx; +void EffectSs_DrawGEffect(PlayState* play, EffectSs* this, TexturePtr texture) { + GraphicsContext* gfxCtx = play->state.gfxCtx; f32 scale; MtxF mfTrans; MtxF mfScale; @@ -41,14 +41,14 @@ void EffectSs_DrawGEffect(GlobalContext* globalCtx, EffectSs* this, void* textur MtxF mfTrans11DA0; s32 pad1; Mtx* mtx; - void* object = globalCtx->objectCtx.status[this->rgObjBankIdx].segment; + void* object = play->objectCtx.status[this->rgObjBankIndex].segment; OPEN_DISPS(gfxCtx); scale = this->rgScale * 0.0025f; SkinMatrix_SetTranslate(&mfTrans, this->pos.x, this->pos.y, this->pos.z); SkinMatrix_SetScale(&mfScale, scale, scale, scale); - SkinMatrix_MtxFMtxFMult(&mfTrans, &globalCtx->billboardMtxF, &mfTrans11DA0); + SkinMatrix_MtxFMtxFMult(&mfTrans, &play->billboardMtxF, &mfTrans11DA0); SkinMatrix_MtxFMtxFMult(&mfTrans11DA0, &mfScale, &mfResult); gSegments[0x06] = PHYSICAL_TO_VIRTUAL(object); gSPSegment(POLY_XLU_DISP++, 0x06, object); @@ -70,7 +70,7 @@ void EffectSs_DrawGEffect(GlobalContext* globalCtx, EffectSs* this, void* textur // EffectSsDust Spawn Functions -void EffectSsDust_Spawn(GlobalContext* globalCtx, u16 drawFlags, Vec3f* pos, Vec3f* velocity, Vec3f* accel, +void EffectSsDust_Spawn(PlayState* play, u16 drawFlags, Vec3f* pos, Vec3f* velocity, Vec3f* accel, Color_RGBA8* primColor, Color_RGBA8* envColor, s16 scale, s16 scaleStep, s16 life, u8 updateMode) { EffectSsDustInitParams initParams; @@ -86,80 +86,78 @@ void EffectSsDust_Spawn(GlobalContext* globalCtx, u16 drawFlags, Vec3f* pos, Vec initParams.life = life; initParams.updateMode = updateMode; - EffectSs_Spawn(globalCtx, EFFECT_SS_DUST, 128, &initParams); + EffectSs_Spawn(play, EFFECT_SS_DUST, 128, &initParams); } -void func_800B0DE0(GlobalContext* globalCtx, Vec3f* pos, Vec3f* velocity, Vec3f* accel, Color_RGBA8* primColor, +void func_800B0DE0(PlayState* play, Vec3f* pos, Vec3f* velocity, Vec3f* accel, Color_RGBA8* primColor, Color_RGBA8* envColor, s16 scale, s16 scaleStep) { - EffectSsDust_Spawn(globalCtx, 0, pos, velocity, accel, primColor, envColor, scale, scaleStep, 10, 0); + EffectSsDust_Spawn(play, 0, pos, velocity, accel, primColor, envColor, scale, scaleStep, 10, 0); } -void func_800B0E48(GlobalContext* globalCtx, Vec3f* pos, Vec3f* velocity, Vec3f* accel, Color_RGBA8* primColor, +void func_800B0E48(PlayState* play, Vec3f* pos, Vec3f* velocity, Vec3f* accel, Color_RGBA8* primColor, Color_RGBA8* envColor, s16 scale, s16 scaleStep) { - EffectSsDust_Spawn(globalCtx, 1, pos, velocity, accel, primColor, envColor, scale, scaleStep, 10, 0); + EffectSsDust_Spawn(play, 1, pos, velocity, accel, primColor, envColor, scale, scaleStep, 10, 0); } -void func_800B0EB0(GlobalContext* globalCtx, Vec3f* pos, Vec3f* velocity, Vec3f* accel, Color_RGBA8* primColor, +void func_800B0EB0(PlayState* play, Vec3f* pos, Vec3f* velocity, Vec3f* accel, Color_RGBA8* primColor, Color_RGBA8* envColor, s16 scale, s16 scaleStep, s16 life) { - EffectSsDust_Spawn(globalCtx, 0, pos, velocity, accel, primColor, envColor, scale, scaleStep, life, 0); + EffectSsDust_Spawn(play, 0, pos, velocity, accel, primColor, envColor, scale, scaleStep, life, 0); } -void func_800B0F18(GlobalContext* globalCtx, Vec3f* pos, Vec3f* velocity, Vec3f* accel, Color_RGBA8* primColor, +void func_800B0F18(PlayState* play, Vec3f* pos, Vec3f* velocity, Vec3f* accel, Color_RGBA8* primColor, Color_RGBA8* envColor, s16 scale, s16 scaleStep, s16 life) { - EffectSsDust_Spawn(globalCtx, 1, pos, velocity, accel, primColor, envColor, scale, scaleStep, life, 0); + EffectSsDust_Spawn(play, 1, pos, velocity, accel, primColor, envColor, scale, scaleStep, life, 0); } -void func_800B0F80(GlobalContext* globalCtx, Vec3f* pos, Vec3f* velocity, Vec3f* accel, Color_RGBA8* primColor, +void func_800B0F80(PlayState* play, Vec3f* pos, Vec3f* velocity, Vec3f* accel, Color_RGBA8* primColor, Color_RGBA8* envColor, s16 scale, s16 scaleStep, s16 life) { - EffectSsDust_Spawn(globalCtx, 2, pos, velocity, accel, primColor, envColor, scale, scaleStep, life, 0); + EffectSsDust_Spawn(play, 2, pos, velocity, accel, primColor, envColor, scale, scaleStep, life, 0); } -void func_800B0FE8(GlobalContext* globalCtx, Vec3f* pos, Vec3f* velocity, Vec3f* accel, Color_RGBA8* primColor, +void func_800B0FE8(PlayState* play, Vec3f* pos, Vec3f* velocity, Vec3f* accel, Color_RGBA8* primColor, Color_RGBA8* envColor, s16 scale, s16 scaleStep) { - EffectSsDust_Spawn(globalCtx, 0, pos, velocity, accel, primColor, envColor, scale, scaleStep, 10, 1); + EffectSsDust_Spawn(play, 0, pos, velocity, accel, primColor, envColor, scale, scaleStep, 10, 1); } -void func_800B1054(GlobalContext* globalCtx, Vec3f* pos, Vec3f* velocity, Vec3f* accel, Color_RGBA8* primColor, +void func_800B1054(PlayState* play, Vec3f* pos, Vec3f* velocity, Vec3f* accel, Color_RGBA8* primColor, Color_RGBA8* envColor, s16 scale, s16 scaleStep) { - EffectSsDust_Spawn(globalCtx, 1, pos, velocity, accel, primColor, envColor, scale, scaleStep, 10, 1); + EffectSsDust_Spawn(play, 1, pos, velocity, accel, primColor, envColor, scale, scaleStep, 10, 1); } static Color_RGBA8 sDustBrownPrim = { 170, 130, 90, 255 }; static Color_RGBA8 sDustBrownEnv = { 100, 60, 20, 255 }; -void func_800B10C0(GlobalContext* globalCtx, Vec3f* pos, Vec3f* velocity, Vec3f* accel) { - EffectSsDust_Spawn(globalCtx, 4, pos, velocity, accel, &sDustBrownPrim, &sDustBrownEnv, 100, 5, 10, 0); +void func_800B10C0(PlayState* play, Vec3f* pos, Vec3f* velocity, Vec3f* accel) { + EffectSsDust_Spawn(play, 4, pos, velocity, accel, &sDustBrownPrim, &sDustBrownEnv, 100, 5, 10, 0); } -void func_800B1130(GlobalContext* globalCtx, Vec3f* pos, Vec3f* velocity, Vec3f* accel) { - EffectSsDust_Spawn(globalCtx, 5, pos, velocity, accel, &sDustBrownPrim, &sDustBrownEnv, 100, 5, 10, 0); +void func_800B1130(PlayState* play, Vec3f* pos, Vec3f* velocity, Vec3f* accel) { + EffectSsDust_Spawn(play, 5, pos, velocity, accel, &sDustBrownPrim, &sDustBrownEnv, 100, 5, 10, 0); } -void func_800B11A0(GlobalContext* globalCtx, Vec3f* pos, Vec3f* velocity, Vec3f* accel, s16 scale, s16 scaleStep) { - EffectSsDust_Spawn(globalCtx, 4, pos, velocity, accel, &sDustBrownPrim, &sDustBrownEnv, scale, scaleStep, 10, 0); +void func_800B11A0(PlayState* play, Vec3f* pos, Vec3f* velocity, Vec3f* accel, s16 scale, s16 scaleStep) { + EffectSsDust_Spawn(play, 4, pos, velocity, accel, &sDustBrownPrim, &sDustBrownEnv, scale, scaleStep, 10, 0); } -void func_800B1210(GlobalContext* globalCtx, Vec3f* pos, Vec3f* velocity, Vec3f* accel, s16 scale, s16 scaleStep) { - EffectSsDust_Spawn(globalCtx, 5, pos, velocity, accel, &sDustBrownPrim, &sDustBrownEnv, scale, scaleStep, 10, 0); +void func_800B1210(PlayState* play, Vec3f* pos, Vec3f* velocity, Vec3f* accel, s16 scale, s16 scaleStep) { + EffectSsDust_Spawn(play, 5, pos, velocity, accel, &sDustBrownPrim, &sDustBrownEnv, scale, scaleStep, 10, 0); } -void func_800B1280(GlobalContext* globalCtx, Vec3f* pos, Vec3f* velocity, Vec3f* accel, s16 scale, s16 scaleStep, - s16 life) { - EffectSsDust_Spawn(globalCtx, 4, pos, velocity, accel, &sDustBrownPrim, &sDustBrownEnv, scale, scaleStep, life, 0); +void func_800B1280(PlayState* play, Vec3f* pos, Vec3f* velocity, Vec3f* accel, s16 scale, s16 scaleStep, s16 life) { + EffectSsDust_Spawn(play, 4, pos, velocity, accel, &sDustBrownPrim, &sDustBrownEnv, scale, scaleStep, life, 0); } -void func_800B12F0(GlobalContext* globalCtx, Vec3f* pos, Vec3f* velocity, Vec3f* accel, s16 scale, s16 scaleStep, - s16 life) { - EffectSsDust_Spawn(globalCtx, 5, pos, velocity, accel, &sDustBrownPrim, &sDustBrownEnv, scale, scaleStep, life, 0); +void func_800B12F0(PlayState* play, Vec3f* pos, Vec3f* velocity, Vec3f* accel, s16 scale, s16 scaleStep, s16 life) { + EffectSsDust_Spawn(play, 5, pos, velocity, accel, &sDustBrownPrim, &sDustBrownEnv, scale, scaleStep, life, 0); } -void func_800B1360(GlobalContext* globalCtx, Vec3f* pos, Vec3f* velocity, Vec3f* accel, Color_RGBA8* primColor, +void func_800B1360(PlayState* play, Vec3f* pos, Vec3f* velocity, Vec3f* accel, Color_RGBA8* primColor, Color_RGBA8* envColor) { - func_800B0DE0(globalCtx, pos, velocity, accel, primColor, envColor, 100, 5); + func_800B0DE0(play, pos, velocity, accel, primColor, envColor, 100, 5); } -void func_800B139C(GlobalContext* globalCtx, Vec3f* pos, Vec3f* velocity, Vec3f* accel, Color_RGBA8* primColor, +void func_800B139C(PlayState* play, Vec3f* pos, Vec3f* velocity, Vec3f* accel, Color_RGBA8* primColor, Color_RGBA8* envColor) { - func_800B0E48(globalCtx, pos, velocity, accel, primColor, envColor, 100, 5); + func_800B0E48(play, pos, velocity, accel, primColor, envColor, 100, 5); } void func_800B13D8(Vec3f* srcPos, f32 randScale, Vec3f* newPos, Vec3f* velocity, Vec3f* accel) { @@ -182,7 +180,7 @@ void func_800B13D8(Vec3f* srcPos, f32 randScale, Vec3f* newPos, Vec3f* velocity, accel->z = 0.0f; } -void func_800B14D4(GlobalContext* globalCtx, f32 randScale, Vec3f* srcPos) { +void func_800B14D4(PlayState* play, f32 randScale, Vec3f* srcPos) { s32 i; Vec3f pos; Vec3f velocity; @@ -190,11 +188,11 @@ void func_800B14D4(GlobalContext* globalCtx, f32 randScale, Vec3f* srcPos) { for (i = 0; i < 20; i++) { func_800B13D8(srcPos, randScale, &pos, &velocity, &accel); - func_800B1280(globalCtx, &pos, &velocity, &accel, 100, 30, 7); + func_800B1280(play, &pos, &velocity, &accel, 100, 30, 7); } } -void func_800B1598(GlobalContext* globalCtx, f32 randScale, Vec3f* srcPos) { +void func_800B1598(PlayState* play, f32 randScale, Vec3f* srcPos) { s32 i; Vec3f pos; Vec3f velocity; @@ -202,25 +200,25 @@ void func_800B1598(GlobalContext* globalCtx, f32 randScale, Vec3f* srcPos) { for (i = 0; i < 20; i++) { func_800B13D8(srcPos, randScale, &pos, &velocity, &accel); - func_800B12F0(globalCtx, &pos, &velocity, &accel, 100, 30, 7); + func_800B12F0(play, &pos, &velocity, &accel, 100, 30, 7); } } -void EffectSsKiraKira_SpawnSmallYellow(GlobalContext* globalCtx, Vec3f* pos, Vec3f* velocity, Vec3f* accel) { +void EffectSsKirakira_SpawnSmallYellow(PlayState* play, 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(play, pos, velocity, accel, &primColor, &envColor, 1000, 16); } -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); +void EffectSsKirakira_SpawnSmall(PlayState* play, Vec3f* pos, Vec3f* velocity, Vec3f* accel, Color_RGBA8* primColor, + Color_RGBA8* envColor) { + EffectSsKirakira_SpawnDispersed(play, pos, velocity, accel, primColor, envColor, 1000, 16); } -void EffectSsKiraKira_SpawnDispersed(GlobalContext* globalCtx, Vec3f* pos, Vec3f* velocity, Vec3f* accel, - Color_RGBA8* primColor, Color_RGBA8* envColor, s16 scale, s32 life) { - EffectSsKiraKiraInitParams initParams; +void EffectSsKirakira_SpawnDispersed(PlayState* play, Vec3f* pos, Vec3f* velocity, Vec3f* accel, Color_RGBA8* primColor, + Color_RGBA8* envColor, s16 scale, s32 life) { + EffectSsKirakiraInitParams initParams; Math_Vec3f_Copy(&initParams.pos, pos); Math_Vec3f_Copy(&initParams.velocity, velocity); @@ -236,12 +234,12 @@ void EffectSsKiraKira_SpawnDispersed(GlobalContext* globalCtx, Vec3f* pos, Vec3f initParams.envColor = *envColor; initParams.alphaStep = (-(255.0f / initParams.life)) + (-(255.0f / initParams.life)); - EffectSs_Spawn(globalCtx, EFFECT_SS_KIRAKIRA, 128, &initParams); + EffectSs_Spawn(play, EFFECT_SS_KIRAKIRA, 128, &initParams); } -void EffectSsKiraKira_SpawnFocused(GlobalContext* globalCtx, Vec3f* pos, Vec3f* velocity, Vec3f* accel, - Color_RGBA8* primColor, Color_RGBA8* envColor, s16 scale, s32 life) { - EffectSsKiraKiraInitParams initParams; +void EffectSsKirakira_SpawnFocused(PlayState* play, Vec3f* pos, Vec3f* velocity, Vec3f* accel, Color_RGBA8* primColor, + Color_RGBA8* envColor, s16 scale, s32 life) { + EffectSsKirakiraInitParams initParams; Math_Vec3f_Copy(&initParams.pos, pos); Math_Vec3f_Copy(&initParams.velocity, velocity); @@ -255,10 +253,10 @@ void EffectSsKiraKira_SpawnFocused(GlobalContext* globalCtx, Vec3f* pos, Vec3f* Color_RGBA8_Copy(&initParams.envColor, envColor); initParams.alphaStep = (-(255.0f / initParams.life)) + (-(255.0f / initParams.life)); - EffectSs_Spawn(globalCtx, EFFECT_SS_KIRAKIRA, 128, &initParams); + EffectSs_Spawn(play, EFFECT_SS_KIRAKIRA, 128, &initParams); } -void EffectSsBomb2_SpawnFade(GlobalContext* globalCtx, Vec3f* pos, Vec3f* velocity, Vec3f* accel) { +void EffectSsBomb2_SpawnFade(PlayState* play, Vec3f* pos, Vec3f* velocity, Vec3f* accel) { EffectSsBomb2InitParams initParams; Math_Vec3f_Copy(&initParams.pos, pos); @@ -268,11 +266,10 @@ void EffectSsBomb2_SpawnFade(GlobalContext* globalCtx, Vec3f* pos, Vec3f* veloci initParams.scaleStep = 0; initParams.drawMode = 0; - EffectSs_Spawn(globalCtx, EFFECT_SS_BOMB2, 10, &initParams); + EffectSs_Spawn(play, EFFECT_SS_BOMB2, 10, &initParams); } -void EffectSsBomb2_SpawnLayered(GlobalContext* globalCtx, Vec3f* pos, Vec3f* velocity, Vec3f* accel, s16 scale, - s16 scaleStep) { +void EffectSsBomb2_SpawnLayered(PlayState* play, Vec3f* pos, Vec3f* velocity, Vec3f* accel, s16 scale, s16 scaleStep) { EffectSsBomb2InitParams initParams; Math_Vec3f_Copy(&initParams.pos, pos); @@ -282,12 +279,12 @@ void EffectSsBomb2_SpawnLayered(GlobalContext* globalCtx, Vec3f* pos, Vec3f* vel initParams.scaleStep = scaleStep; initParams.drawMode = 1; - EffectSs_Spawn(globalCtx, EFFECT_SS_BOMB2, 10, &initParams); + EffectSs_Spawn(play, EFFECT_SS_BOMB2, 10, &initParams); } // EffectSsBlast Spawn Functions -void EffectSsBlast_Spawn(GlobalContext* globalCtx, Vec3f* pos, Vec3f* velocity, Vec3f* accel, Color_RGBA8* primColor, +void EffectSsBlast_Spawn(PlayState* play, Vec3f* pos, Vec3f* velocity, Vec3f* accel, Color_RGBA8* primColor, Color_RGBA8* envColor, s16 scale, s16 scaleStep, s16 sclaeStepDecay, s16 life) { EffectSsBlastInitParams initParams; @@ -301,32 +298,32 @@ void EffectSsBlast_Spawn(GlobalContext* globalCtx, Vec3f* pos, Vec3f* velocity, initParams.sclaeStepDecay = sclaeStepDecay; initParams.life = life; - EffectSs_Spawn(globalCtx, EFFECT_SS_BLAST, 128, &initParams); + EffectSs_Spawn(play, EFFECT_SS_BLAST, 128, &initParams); } -void EffectSsBlast_SpawnWhiteCustomScale(GlobalContext* globalCtx, Vec3f* pos, Vec3f* velocity, Vec3f* accel, s16 scale, +void EffectSsBlast_SpawnWhiteCustomScale(PlayState* play, Vec3f* pos, Vec3f* velocity, Vec3f* accel, s16 scale, s16 scaleStep, s16 life) { static Color_RGBA8 primColor = { 255, 255, 255, 255 }; static Color_RGBA8 envColor = { 200, 200, 200, 0 }; - EffectSsBlast_Spawn(globalCtx, pos, velocity, accel, &primColor, &envColor, scale, scaleStep, 35, life); + EffectSsBlast_Spawn(play, pos, velocity, accel, &primColor, &envColor, scale, scaleStep, 35, life); } -void EffectSsBlast_SpawnShockwave(GlobalContext* globalCtx, Vec3f* pos, Vec3f* velocity, Vec3f* accel, - Color_RGBA8* primColor, Color_RGBA8* envColor, s16 life) { - EffectSsBlast_Spawn(globalCtx, pos, velocity, accel, primColor, envColor, 100, 375, 35, life); +void EffectSsBlast_SpawnShockwave(PlayState* play, Vec3f* pos, Vec3f* velocity, Vec3f* accel, Color_RGBA8* primColor, + Color_RGBA8* envColor, s16 life) { + EffectSsBlast_Spawn(play, pos, velocity, accel, primColor, envColor, 100, 375, 35, life); } -void EffectSsBlast_SpawnWhiteShockwave(GlobalContext* globalCtx, Vec3f* pos, Vec3f* velocity, Vec3f* accel) { +void EffectSsBlast_SpawnWhiteShockwave(PlayState* play, Vec3f* pos, Vec3f* velocity, Vec3f* accel) { static Color_RGBA8 primColor = { 255, 255, 255, 255 }; static Color_RGBA8 envColor = { 200, 200, 200, 0 }; - EffectSsBlast_SpawnShockwave(globalCtx, pos, velocity, accel, &primColor, &envColor, 10); + EffectSsBlast_SpawnShockwave(play, pos, velocity, accel, &primColor, &envColor, 10); } // EffectSsGSpk Spawn Functions -void EffectSsGSpk_SpawnAccel(GlobalContext* globalCtx, Actor* actor, Vec3f* pos, Vec3f* velocity, Vec3f* accel, +void EffectSsGSpk_SpawnAccel(PlayState* play, Actor* actor, Vec3f* pos, Vec3f* velocity, Vec3f* accel, Color_RGBA8* primColor, Color_RGBA8* envColor, s16 scale, s16 scaleStep) { EffectSsGSpkInitParams initParams; @@ -338,13 +335,13 @@ void EffectSsGSpk_SpawnAccel(GlobalContext* globalCtx, Actor* actor, Vec3f* pos, initParams.actor = actor; initParams.scale = scale; initParams.scaleStep = scaleStep; - initParams.updateMode = 0; + initParams.updateMode = GSPK_UPDATEMODE_NORMAL; - EffectSs_Spawn(globalCtx, EFFECT_SS_G_SPK, 128, &initParams); + EffectSs_Spawn(play, EFFECT_SS_G_SPK, 128, &initParams); } // unused -void EffectSsGSpk_SpawnNoAccel(GlobalContext* globalCtx, Actor* actor, Vec3f* pos, Vec3f* velocity, Vec3f* accel, +void EffectSsGSpk_SpawnNoAccel(PlayState* play, Actor* actor, Vec3f* pos, Vec3f* velocity, Vec3f* accel, Color_RGBA8* primColor, Color_RGBA8* envColor, s16 scale, s16 scaleStep) { EffectSsGSpkInitParams initParams; @@ -356,21 +353,21 @@ void EffectSsGSpk_SpawnNoAccel(GlobalContext* globalCtx, Actor* actor, Vec3f* po initParams.actor = actor; initParams.scale = scale; initParams.scaleStep = scaleStep; - initParams.updateMode = 1; + initParams.updateMode = GSPK_UPDATEMODE_NO_ACCEL; - EffectSs_Spawn(globalCtx, EFFECT_SS_G_SPK, 128, &initParams); + EffectSs_Spawn(play, EFFECT_SS_G_SPK, 128, &initParams); } -void EffectSsGSpk_SpawnFuse(GlobalContext* globalCtx, Actor* actor, Vec3f* pos, Vec3f* velocity, Vec3f* accel) { +void EffectSsGSpk_SpawnFuse(PlayState* play, Actor* actor, Vec3f* pos, Vec3f* velocity, Vec3f* accel) { Color_RGBA8 primColor = { 255, 255, 150, 255 }; Color_RGBA8 envColor = { 255, 0, 0, 0 }; - EffectSsGSpk_SpawnSmall(globalCtx, actor, pos, velocity, accel, &primColor, &envColor); + EffectSsGSpk_SpawnSmall(play, actor, pos, velocity, accel, &primColor, &envColor); } // unused -void EffectSsGSpk_SpawnRandColor(GlobalContext* globalCtx, Actor* actor, Vec3f* pos, Vec3f* velocity, Vec3f* accel, - s16 scale, s16 scaleStep) { +void EffectSsGSpk_SpawnRandColor(PlayState* play, Actor* actor, Vec3f* pos, Vec3f* velocity, Vec3f* accel, s16 scale, + s16 scaleStep) { Color_RGBA8 primColor = { 255, 255, 150, 255 }; Color_RGBA8 envColor = { 255, 0, 0, 0 }; s32 randOffset = (Rand_ZeroOne() * 20.0f) - 10.0f; @@ -384,16 +381,16 @@ void EffectSsGSpk_SpawnRandColor(GlobalContext* globalCtx, Actor* actor, Vec3f* envColor.b += randOffset; envColor.a += randOffset; - EffectSsGSpk_SpawnAccel(globalCtx, actor, pos, velocity, accel, &primColor, &envColor, scale, scaleStep); + EffectSsGSpk_SpawnAccel(play, actor, pos, velocity, accel, &primColor, &envColor, scale, scaleStep); } -void EffectSsGSpk_SpawnSmall(GlobalContext* globalCtx, Actor* actor, Vec3f* pos, Vec3f* velocity, Vec3f* accel, +void EffectSsGSpk_SpawnSmall(PlayState* play, Actor* actor, Vec3f* pos, Vec3f* velocity, Vec3f* accel, Color_RGBA8* primColor, Color_RGBA8* envColor) { - EffectSsGSpk_SpawnAccel(globalCtx, actor, pos, velocity, accel, primColor, envColor, 100, 5); + EffectSsGSpk_SpawnAccel(play, actor, pos, velocity, accel, primColor, envColor, 100, 5); } // EffectSsDFire Spawn Functions -void EffectSsDFire_Spawn(GlobalContext* globalCtx, Vec3f* pos, Vec3f* velocity, Vec3f* accel, s16 scale, s16 scaleStep, +void EffectSsDFire_Spawn(PlayState* play, Vec3f* pos, Vec3f* velocity, Vec3f* accel, s16 scale, s16 scaleStep, s16 alpha, s16 fadeDelay, s16 arg8, s32 life) { EffectSsDFireInitParams initParams; @@ -407,12 +404,12 @@ void EffectSsDFire_Spawn(GlobalContext* globalCtx, Vec3f* pos, Vec3f* velocity, initParams.unk_2C = arg8; initParams.life = life; - EffectSs_Spawn(globalCtx, EFFECT_SS_D_FIRE, 128, &initParams); + EffectSs_Spawn(play, EFFECT_SS_D_FIRE, 128, &initParams); } // EffectSsBubble Spawn Functions -void EffectSsBubble_Spawn(GlobalContext* globalCtx, Vec3f* pos, f32 yPosOffset, f32 yPosRandScale, f32 xzPosRandScale, +void EffectSsBubble_Spawn(PlayState* play, Vec3f* pos, f32 yPosOffset, f32 yPosRandScale, f32 xzPosRandScale, f32 scale) { EffectSsBubbleInitParams initParams; @@ -422,12 +419,12 @@ void EffectSsBubble_Spawn(GlobalContext* globalCtx, Vec3f* pos, f32 yPosOffset, initParams.xzPosRandScale = xzPosRandScale; initParams.scale = scale; - EffectSs_Spawn(globalCtx, EFFECT_SS_BUBBLE, 128, &initParams); + EffectSs_Spawn(play, EFFECT_SS_BUBBLE, 128, &initParams); } // EffectSsGRipple Spawn Functions -void EffectSsGRipple_Spawn(GlobalContext* globalCtx, Vec3f* pos, s16 radius, s16 radiusMax, s16 life) { +void EffectSsGRipple_Spawn(PlayState* play, Vec3f* pos, s16 radius, s16 radiusMax, s16 life) { EffectSsGRippleInitParams initParams; Math_Vec3f_Copy(&initParams.pos, pos); @@ -435,13 +432,13 @@ void EffectSsGRipple_Spawn(GlobalContext* globalCtx, Vec3f* pos, s16 radius, s16 initParams.radiusMax = radiusMax; initParams.life = life; - EffectSs_Spawn(globalCtx, EFFECT_SS_G_RIPPLE, 128, &initParams); + EffectSs_Spawn(play, EFFECT_SS_G_RIPPLE, 128, &initParams); } // EffectSsGSplash Spawn Functions -void EffectSsGSplash_Spawn(GlobalContext* globalCtx, Vec3f* pos, Color_RGBA8* primColor, Color_RGBA8* envColor, - s16 type, s16 scale) { +void EffectSsGSplash_Spawn(PlayState* play, Vec3f* pos, Color_RGBA8* primColor, Color_RGBA8* envColor, s16 type, + s16 scale) { EffectSsGSplashInitParams initParams; Math_Vec3f_Copy(&initParams.pos, pos); @@ -456,23 +453,23 @@ void EffectSsGSplash_Spawn(GlobalContext* globalCtx, Vec3f* pos, Color_RGBA8* pr initParams.customColor = 0; } - EffectSs_Spawn(globalCtx, EFFECT_SS_G_SPLASH, 128, &initParams); + EffectSs_Spawn(play, EFFECT_SS_G_SPLASH, 128, &initParams); } // EffectSsGFire Spawn Functions -void EffectSsGFire_Spawn(GlobalContext* globalCtx, Vec3f* pos) { +void EffectSsGFire_Spawn(PlayState* play, Vec3f* pos) { EffectSsGFireInitParams initParams; Math_Vec3f_Copy(&initParams.pos, pos); - EffectSs_Spawn(globalCtx, EFFECT_SS_G_FIRE, 128, &initParams); + EffectSs_Spawn(play, EFFECT_SS_G_FIRE, 128, &initParams); } // EffectSsLightning Spawn Functions -void EffectSsLightning_Spawn(GlobalContext* globalCtx, Vec3f* pos, Color_RGBA8* primColor, Color_RGBA8* envColor, - s16 scale, s16 yaw, s16 life, s16 numBolts) { +void EffectSsLightning_Spawn(PlayState* play, Vec3f* pos, Color_RGBA8* primColor, Color_RGBA8* envColor, s16 scale, + s16 yaw, s16 life, s16 numBolts) { EffectSsLightningInitParams initParams; Math_Vec3f_Copy(&initParams.pos, pos); @@ -483,13 +480,13 @@ void EffectSsLightning_Spawn(GlobalContext* globalCtx, Vec3f* pos, Color_RGBA8* initParams.life = life; initParams.numBolts = numBolts; - EffectSs_Spawn(globalCtx, EFFECT_SS_LIGHTNING, 128, &initParams); + EffectSs_Spawn(play, EFFECT_SS_LIGHTNING, 128, &initParams); } // EffectSsDtBubble Spawn Functions -void EffectSsDtBubble_SpawnColorProfile(GlobalContext* globalCtx, Vec3f* pos, Vec3f* velocity, Vec3f* accel, s16 scale, - s16 life, s16 colorProfile, s16 randXZ) { +void EffectSsDtBubble_SpawnColorProfile(PlayState* play, Vec3f* pos, Vec3f* velocity, Vec3f* accel, s16 scale, s16 life, + s16 colorProfile, s16 randXZ) { EffectSsDtBubbleInitParams initParams; Math_Vec3f_Copy(&initParams.pos, pos); @@ -501,10 +498,10 @@ void EffectSsDtBubble_SpawnColorProfile(GlobalContext* globalCtx, Vec3f* pos, Ve initParams.life = life; initParams.randXZ = randXZ; - EffectSs_Spawn(globalCtx, EFFECT_SS_DT_BUBBLE, 128, &initParams); + EffectSs_Spawn(play, EFFECT_SS_DT_BUBBLE, 128, &initParams); } -void EffectSsDtBubble_SpawnCustomColor(GlobalContext* globalCtx, Vec3f* pos, Vec3f* velocity, Vec3f* accel, +void EffectSsDtBubble_SpawnCustomColor(PlayState* play, Vec3f* pos, Vec3f* velocity, Vec3f* accel, Color_RGBA8* primColor, Color_RGBA8* envColor, s16 scale, s16 life, s16 randXZ) { EffectSsDtBubbleInitParams initParams; @@ -518,7 +515,7 @@ void EffectSsDtBubble_SpawnCustomColor(GlobalContext* globalCtx, Vec3f* pos, Vec initParams.randXZ = randXZ; initParams.customColor = 1; - EffectSs_Spawn(globalCtx, EFFECT_SS_DT_BUBBLE, 128, &initParams); + EffectSs_Spawn(play, EFFECT_SS_DT_BUBBLE, 128, &initParams); } // EffectSsHahen Spawn Functions @@ -532,20 +529,20 @@ void EffectSsDtBubble_SpawnCustomColor(GlobalContext* globalCtx, Vec3f* pos, Vec * - due to how life is implemented it is capped at 200. Any value over 200 is accepted, but the fragment will * only live for 200 frames */ -void EffectSsHahen_Spawn(GlobalContext* globalCtx, Vec3f* pos, Vec3f* velocity, Vec3f* accel, s16 unused, s16 scale, - s16 objId, s16 life, Gfx* dList) { +void EffectSsHahen_Spawn(PlayState* play, Vec3f* pos, Vec3f* velocity, Vec3f* accel, s16 flags, s16 scale, s16 objId, + s16 life, Gfx* dList) { EffectSsHahenInitParams initParams; Math_Vec3f_Copy(&initParams.pos, pos); Math_Vec3f_Copy(&initParams.velocity, velocity); Math_Vec3f_Copy(&initParams.accel, accel); initParams.dList = dList; - initParams.unused = unused; + initParams.flags = flags; initParams.scale = scale; initParams.objId = objId; initParams.life = life; - EffectSs_Spawn(globalCtx, EFFECT_SS_HAHEN, 128, &initParams); + EffectSs_Spawn(play, EFFECT_SS_HAHEN, 128, &initParams); } /** @@ -557,8 +554,8 @@ void EffectSsHahen_Spawn(GlobalContext* globalCtx, Vec3f* pos, Vec3f* velocity, * - due to how life is implemented it is capped at 200. Any value over 200 is accepted, but the fragment will * only live for 200 frames */ -void EffectSsHahen_SpawnBurst(GlobalContext* globalCtx, Vec3f* pos, f32 burstScale, s16 unused, s16 scale, - s16 randScaleRange, s16 count, s16 objId, s16 life, Gfx* dList) { +void EffectSsHahen_SpawnBurst(PlayState* play, Vec3f* pos, f32 burstScale, s16 flags, s16 scale, s16 randScaleRange, + s16 count, s16 objId, s16 life, Gfx* dList) { s32 i; Vec3f velocity; Vec3f accel; @@ -571,15 +568,15 @@ void EffectSsHahen_SpawnBurst(GlobalContext* globalCtx, Vec3f* pos, f32 burstSca velocity.z = (Rand_ZeroOne() - 0.5f) * burstScale; velocity.y = ((Rand_ZeroOne() * 0.5f) + 0.5f) * burstScale; - EffectSsHahen_Spawn(globalCtx, pos, &velocity, &accel, unused, Rand_S16Offset(scale, randScaleRange), objId, - life, dList); + EffectSsHahen_Spawn(play, pos, &velocity, &accel, flags, Rand_S16Offset(scale, randScaleRange), objId, life, + dList); } } -void func_800B2364(GlobalContext* globalCtx, Vec3f* pos, Gfx* dList) { +void func_800B2364(PlayState* play, Vec3f* pos, Gfx* dList) { Vec3f accel = { 0.0f, -2.0f, 0.0f }; - EffectSsHahen_Spawn(globalCtx, pos, &gZeroVec3f, &accel, 1, 5, 1, 10, dList); + EffectSsHahen_Spawn(play, pos, &gZeroVec3f, &accel, HAHEN_SMALL, 5, GAMEPLAY_KEEP, 10, dList); } // EffectSsStick Spawn Functions @@ -588,19 +585,19 @@ void func_800B2364(GlobalContext* globalCtx, Vec3f* pos, Gfx* dList) { * As child, spawn a broken stick fragment * As adult, spawn a broken sword fragment */ -void EffectSsStick_Spawn(GlobalContext* globalCtx, Vec3f* pos, s16 yaw) { +void EffectSsStick_Spawn(PlayState* play, Vec3f* pos, s16 yaw) { EffectSsStickInitParams initParams; initParams.pos = *pos; initParams.yaw = yaw; - EffectSs_Spawn(globalCtx, EFFECT_SS_STICK, 128, &initParams); + EffectSs_Spawn(play, EFFECT_SS_STICK, 128, &initParams); } // EffectSsSibuki Spawn Functions -void EffectSsSibuki_Spawn(GlobalContext* globalCtx, Vec3f* pos, Vec3f* velocity, Vec3f* accel, s16 moveDelay, - s16 direction, s16 scale) { +void EffectSsSibuki_Spawn(PlayState* play, Vec3f* pos, Vec3f* velocity, Vec3f* accel, s16 moveDelay, s16 direction, + s16 scale) { EffectSsSibukiInitParams initParams; Math_Vec3f_Copy(&initParams.pos, pos); @@ -610,48 +607,48 @@ void EffectSsSibuki_Spawn(GlobalContext* globalCtx, Vec3f* pos, Vec3f* velocity, initParams.direction = direction; initParams.scale = scale; - EffectSs_Spawn(globalCtx, EFFECT_SS_SIBUKI, 128, &initParams); + EffectSs_Spawn(play, EFFECT_SS_SIBUKI, 128, &initParams); } -void EffectSsSibuki_SpawnBurst(GlobalContext* globalCtx, Vec3f* pos) { +void EffectSsSibuki_SpawnBurst(PlayState* play, Vec3f* pos) { s16 i; Vec3f zeroVec = { 0.0f, 0.0f, 0.0f }; s16 randDirection = Rand_ZeroOne() * 1.99f; for (i = 0; i < KREG(19) + 30; i++) { - EffectSsSibuki_Spawn(globalCtx, pos, &zeroVec, &zeroVec, i / (KREG(27) + 6), randDirection, KREG(18) + 40); + EffectSsSibuki_Spawn(play, pos, &zeroVec, &zeroVec, i / (KREG(27) + 6), randDirection, KREG(18) + 40); } } // EffectSsStone1 Spawn Functions -void EffectSsStone1_Spawn(GlobalContext* globalCtx, Vec3f* pos, s32 arg2) { +void EffectSsStone1_Spawn(PlayState* play, Vec3f* pos, s32 reg0) { EffectSsStone1InitParams initParams; initParams.pos = *pos; - initParams.unk_C = arg2; + initParams.reg0 = reg0; - EffectSs_Spawn(globalCtx, EFFECT_SS_STONE1, 128, &initParams); + EffectSs_Spawn(play, EFFECT_SS_STONE1, 128, &initParams); } -// EffectSsHitMark Spawn Functions +// EffectSsHitmark Spawn Functions -void EffectSsHitMark_Spawn(GlobalContext* globalCtx, s32 type, s16 scale, Vec3f* pos) { - EffectSsHitMarkInitParams initParams; +void EffectSsHitmark_Spawn(PlayState* play, s32 type, s16 scale, Vec3f* pos) { + EffectSsHitmarkInitParams initParams; initParams.type = type; initParams.scale = scale; Math_Vec3f_Copy(&initParams.pos, pos); - EffectSs_Spawn(globalCtx, EFFECT_SS_HITMARK, 128, &initParams); + EffectSs_Spawn(play, EFFECT_SS_HITMARK, 128, &initParams); } -void EffectSsHitMark_SpawnFixedScale(GlobalContext* globalCtx, s32 type, Vec3f* pos) { - EffectSsHitMark_Spawn(globalCtx, type, 300, pos); +void EffectSsHitmark_SpawnFixedScale(PlayState* play, s32 type, Vec3f* pos) { + EffectSsHitmark_Spawn(play, type, 300, pos); } -void EffectSsHitMark_SpawnCustomScale(GlobalContext* globalCtx, s32 type, s16 scale, Vec3f* pos) { - EffectSsHitMark_Spawn(globalCtx, type, scale, pos); +void EffectSsHitmark_SpawnCustomScale(PlayState* play, s32 type, s16 scale, Vec3f* pos) { + EffectSsHitmark_Spawn(play, type, scale, pos); } // EffectSsFhgFlash Spawn Functions @@ -662,23 +659,23 @@ void EffectSsHitMark_SpawnCustomScale(GlobalContext* globalCtx, s32 type, s16 sc * param determines where the ligntning should go * 0: dont attach to any actor. spawns at the position specified by pos * 1: spawn at one of Player's body parts, chosen at random - * 2: spawn at one of Phantom Ganon's body parts, chosen at random + * 2 - 6: spawn at one of Goht's body parts */ -void EffectSsFhgFlash_SpawnShock(GlobalContext* globalCtx, Actor* actor, Vec3f* pos, s16 scale, u8 param) { +void EffectSsFhgFlash_SpawnShock(PlayState* play, Actor* actor, Vec3f* pos, s16 scale, u8 params) { EffectSsFhgFlashInitParams initParams; initParams.actor = actor; Math_Vec3f_Copy(&initParams.pos, pos); initParams.scale = scale; - initParams.param = param; + initParams.params = params; initParams.type = FHGFLASH_SHOCK; - EffectSs_Spawn(globalCtx, EFFECT_SS_FHG_FLASH, 128, &initParams); + EffectSs_Spawn(play, EFFECT_SS_FHG_FLASH, 128, &initParams); } // EffectSsKFire Spawn Functions -void EffectSsKFire_Spawn(GlobalContext* globalCtx, Vec3f* pos, Vec3f* velocity, Vec3f* accel, s16 scaleMax, u8 type) { +void EffectSsKFire_Spawn(PlayState* play, Vec3f* pos, Vec3f* velocity, Vec3f* accel, s16 scaleMax, u8 type) { EffectSsKFireInitParams initParams; Math_Vec3f_Copy(&initParams.pos, pos); @@ -687,12 +684,12 @@ void EffectSsKFire_Spawn(GlobalContext* globalCtx, Vec3f* pos, Vec3f* velocity, initParams.scaleMax = scaleMax; initParams.type = type; - EffectSs_Spawn(globalCtx, EFFECT_SS_K_FIRE, 128, &initParams); + EffectSs_Spawn(play, EFFECT_SS_K_FIRE, 128, &initParams); } // EffectSsSolderSrchBall Spawn Functions -void EffectSsSolderSrchBall_Spawn(GlobalContext* globalCtx, Vec3f* pos, Vec3f* velocity, Vec3f* accel, s16 unused, +void EffectSsSolderSrchBall_Spawn(PlayState* play, Vec3f* pos, Vec3f* velocity, Vec3f* accel, s16 unused, s16* linkDetected, s16 drawFlag) { EffectSsSolderSrchBallInitParams initParams; @@ -703,14 +700,14 @@ void EffectSsSolderSrchBall_Spawn(GlobalContext* globalCtx, Vec3f* pos, Vec3f* v initParams.linkDetected = linkDetected; initParams.drawFlag = drawFlag; - EffectSs_Spawn(globalCtx, EFFECT_SS_SOLDER_SRCH_BALL, 128, &initParams); + EffectSs_Spawn(play, EFFECT_SS_SOLDER_SRCH_BALL, 128, &initParams); } // EffectSsKakera Spawn Functions -void EffectSsKakera_Spawn(GlobalContext* globalCtx, Vec3f* pos, Vec3f* velocity, Vec3f* arg3, s16 gravity, s16 arg5, - s16 arg6, s16 arg7, s16 arg8, s16 scale, s16 arg10, s16 arg11, s32 life, s16 colorIdx, - s16 objId, Gfx* dList) { +void EffectSsKakera_Spawn(PlayState* play, Vec3f* pos, Vec3f* velocity, Vec3f* arg3, s16 gravity, s16 arg5, s16 arg6, + s16 arg7, s16 arg8, s16 scale, s16 arg10, s16 arg11, s32 life, s16 colorIdx, s16 objId, + Gfx* dList) { EffectSsKakeraInitParams initParams; Math_Vec3f_Copy(&initParams.pos, pos); @@ -729,12 +726,12 @@ void EffectSsKakera_Spawn(GlobalContext* globalCtx, Vec3f* pos, Vec3f* velocity, initParams.objId = objId; initParams.dList = dList; - EffectSs_Spawn(globalCtx, EFFECT_SS_KAKERA, 101, &initParams); + EffectSs_Spawn(play, EFFECT_SS_KAKERA, 101, &initParams); } // EffectSsIcePiece Spawn Functions -void EffectSsIcePiece_Spawn(GlobalContext* globalCtx, Vec3f* pos, f32 scale, Vec3f* velocity, Vec3f* accel, s32 life) { +void EffectSsIcePiece_Spawn(PlayState* play, Vec3f* pos, f32 scale, Vec3f* velocity, Vec3f* accel, s32 life) { EffectSsIcePieceInitParams initParams; Math_Vec3f_Copy(&initParams.pos, pos); @@ -742,10 +739,10 @@ void EffectSsIcePiece_Spawn(GlobalContext* globalCtx, Vec3f* pos, f32 scale, Vec Math_Vec3f_Copy(&initParams.accel, accel); initParams.scale = scale; initParams.life = life; - EffectSs_Spawn(globalCtx, EFFECT_SS_ICE_PIECE, 128, &initParams); + EffectSs_Spawn(play, EFFECT_SS_ICE_PIECE, 128, &initParams); } -void EffectSsIcePiece_SpawnBurst(GlobalContext* globalCtx, Vec3f* refPos, f32 scale) { +void EffectSsIcePiece_SpawnBurst(PlayState* play, Vec3f* refPos, f32 scale) { static Vec3f accel = { 0.0f, 0.0f, 0.0f }; static Vec3f vecScales[] = { { 0.0f, 70.0f, 0.0f }, @@ -776,47 +773,47 @@ void EffectSsIcePiece_SpawnBurst(GlobalContext* globalCtx, Vec3f* refPos, f32 sc pos.y += vecScales[i].y; pos.z += vecScales[i].z; - EffectSsIcePiece_Spawn(globalCtx, &pos, (Rand_ZeroFloat(1.0f) + 0.5f) * ((scale * 1.3f) * 100.0f), &velocity, - &accel, 25); + EffectSsIcePiece_Spawn(play, &pos, (Rand_ZeroFloat(1.0f) + 0.5f) * ((scale * 1.3f) * 100.0f), &velocity, &accel, + 25); } } // EffectSsEnIce Spawn Functions -void EffectSsEnIce_SpawnFlyingVec3f(GlobalContext* globalCtx, Actor* actor, Vec3f* pos, Color_RGBA8* prim, - Color_RGBA8* env, f32 scale) { +void EffectSsEnIce_SpawnFlying(PlayState* play, Actor* actor, Vec3f* pos, Color_RGBA8* prim, Color_RGBA8* env, + f32 scale) { EffectSsEnIceInitParams initParams; initParams.actor = actor; Math_Vec3f_Copy(&initParams.pos, pos); Color_RGBA8_Copy(&initParams.primColor, prim); Color_RGBA8_Copy(&initParams.envColor, env); - initParams.type = 0; + initParams.type = ENICE_TYPE_FLYING; initParams.scale = scale; if (actor != NULL) { Actor_PlaySfxAtPos(actor, NA_SE_PL_FREEZE_S); } - EffectSs_Spawn(globalCtx, EFFECT_SS_EN_ICE, 80, &initParams); + EffectSs_Spawn(play, EFFECT_SS_EN_ICE, 80, &initParams); } -void func_800B2B44(GlobalContext* globalCtx, Actor* actor, Vec3f* pos, f32 scale) { +void func_800B2B44(PlayState* play, Actor* actor, Vec3f* pos, f32 scale) { static Color_RGBA8 primColor = { 150, 150, 150, 250 }; static Color_RGBA8 envColor = { 235, 245, 255, 255 }; - EffectSsEnIce_SpawnFlyingVec3f(globalCtx, actor, pos, &primColor, &envColor, scale); + EffectSsEnIce_SpawnFlying(play, actor, pos, &primColor, &envColor, scale); } -void func_800B2B7C(GlobalContext* globalCtx, Actor* actor, Vec3s* arg2, f32 scale) { +void func_800B2B7C(PlayState* play, Actor* actor, Vec3s* arg2, f32 scale) { Vec3f dest; Math_Vec3s_ToVec3f(&dest, arg2); - func_800B2B44(globalCtx, actor, &dest, scale); + func_800B2B44(play, actor, &dest, scale); } -void EffectSsEnIce_Spawn(GlobalContext* globalCtx, Vec3f* pos, f32 scale, Vec3f* velocity, Vec3f* accel, - Color_RGBA8* primColor, Color_RGBA8* envColor, s32 life) { +void EffectSsEnIce_Spawn(PlayState* play, Vec3f* pos, f32 scale, Vec3f* velocity, Vec3f* accel, Color_RGBA8* primColor, + Color_RGBA8* envColor, s32 life) { EffectSsEnIceInitParams initParams; Math_Vec3f_Copy(&initParams.pos, pos); @@ -826,14 +823,14 @@ void EffectSsEnIce_Spawn(GlobalContext* globalCtx, Vec3f* pos, f32 scale, Vec3f* Color_RGBA8_Copy(&initParams.envColor, envColor); initParams.scale = scale; initParams.life = life; - initParams.type = 1; + initParams.type = ENICE_TYPE_NORMAL; - EffectSs_Spawn(globalCtx, EFFECT_SS_EN_ICE, 128, &initParams); + EffectSs_Spawn(play, EFFECT_SS_EN_ICE, 128, &initParams); } // EffectSsFireTail Spawn Functions -void EffectSsFireTail_Spawn(GlobalContext* globalCtx, Actor* actor, Vec3f* pos, f32 scale, Vec3f* arg4, s16 arg5, +void EffectSsFireTail_Spawn(PlayState* play, Actor* actor, Vec3f* pos, f32 scale, Vec3f* arg4, s16 arg5, Color_RGBA8* primColor, Color_RGBA8* envColor, s16 type, s16 bodyPart, s32 life) { EffectSsFireTailInitParams initParams; @@ -848,10 +845,10 @@ void EffectSsFireTail_Spawn(GlobalContext* globalCtx, Actor* actor, Vec3f* pos, initParams.bodyPart = bodyPart; initParams.life = life; - EffectSs_Spawn(globalCtx, EFFECT_SS_FIRE_TAIL, 128, &initParams); + EffectSs_Spawn(play, EFFECT_SS_FIRE_TAIL, 128, &initParams); } -void EffectSsFireTail_SpawnFlame(GlobalContext* globalCtx, Actor* actor, Vec3f* pos, f32 arg3, s16 bodyPart, +void EffectSsFireTail_SpawnFlame(PlayState* play, Actor* actor, Vec3f* pos, f32 arg3, s16 bodyPart, f32 colorIntensity) { static Color_RGBA8 primColor = { 255, 255, 0, 255 }; static Color_RGBA8 envColor = { 255, 0, 0, 255 }; @@ -863,27 +860,26 @@ void EffectSsFireTail_SpawnFlame(GlobalContext* globalCtx, Actor* actor, Vec3f* envColor.b = 0; primColor.r = envColor.r = (s32)(255.0f * colorIntensity); - EffectSsFireTail_Spawn(globalCtx, actor, pos, arg3, &actor->velocity, 15, &primColor, &envColor, + EffectSsFireTail_Spawn(play, actor, pos, arg3, &actor->velocity, 15, &primColor, &envColor, (colorIntensity == 1.0f) ? 0 : 1, bodyPart, 1); } -void EffectSsFireTail_SpawnFlameOnPlayer(GlobalContext* globalCtx, f32 scale, s16 bodyPart, f32 colorIntensity) { - Player* player = GET_PLAYER(globalCtx); +void EffectSsFireTail_SpawnFlameOnPlayer(PlayState* play, f32 scale, s16 bodyPart, f32 colorIntensity) { + Player* player = GET_PLAYER(play); - EffectSsFireTail_SpawnFlame(globalCtx, &player->actor, &player->bodyPartsPos[bodyPart], scale, bodyPart, - colorIntensity); + EffectSsFireTail_SpawnFlame(play, &player->actor, &player->bodyPartsPos[bodyPart], scale, bodyPart, colorIntensity); } // EffectSsEnFire Spawn Functions -void EffectSsEnFire_SpawnVec3f(GlobalContext* globalCtx, Actor* actor, Vec3f* pos, s16 scale, s16 arg4, s16 flags, +void EffectSsEnFire_SpawnVec3f(PlayState* play, Actor* actor, Vec3f* pos, s16 scale, s16 params, s16 flags, s16 bodyPart) { EffectSsEnFireInitParams initParams; Math_Vec3f_Copy(&initParams.pos, pos); initParams.actor = actor; initParams.scale = scale; - initParams.unk_12 = arg4; + initParams.params = params; initParams.flags = flags; initParams.bodyPart = bodyPart; @@ -891,10 +887,10 @@ void EffectSsEnFire_SpawnVec3f(GlobalContext* globalCtx, Actor* actor, Vec3f* po Actor_PlaySfxAtPos(actor, NA_SE_EV_FLAME_IGNITION); } - EffectSs_Spawn(globalCtx, EFFECT_SS_EN_FIRE, 128, &initParams); + EffectSs_Spawn(play, EFFECT_SS_EN_FIRE, 128, &initParams); } -void EffectSsEnFire_SpawnVec3s(GlobalContext* globalCtx, Actor* actor, Vec3s* pos, s16 scale, s16 arg4, s16 flags, +void EffectSsEnFire_SpawnVec3s(PlayState* play, Actor* actor, Vec3s* pos, s16 scale, s16 params, s16 flags, s16 bodyPart) { EffectSsEnFireInitParams initParams; @@ -903,20 +899,20 @@ void EffectSsEnFire_SpawnVec3s(GlobalContext* globalCtx, Actor* actor, Vec3s* po initParams.pos.z = pos->z; initParams.actor = actor; initParams.scale = scale; - initParams.unk_12 = arg4; - initParams.flags = flags | 0x8000; + initParams.params = params; + initParams.flags = flags | ENFIRE_FLAGS_BODYPART_POS_VEC3S; initParams.bodyPart = bodyPart; if (actor != NULL) { Actor_PlaySfxAtPos(actor, NA_SE_EV_FLAME_IGNITION); } - EffectSs_Spawn(globalCtx, EFFECT_SS_EN_FIRE, 128, &initParams); + EffectSs_Spawn(play, EFFECT_SS_EN_FIRE, 128, &initParams); } // EffectSsExtra Spawn Functions -void EffectSsExtra_Spawn(GlobalContext* globalCtx, Vec3f* pos, Vec3f* velocity, Vec3f* accel, s16 scale, s16 scoreIdx) { +void EffectSsExtra_Spawn(PlayState* play, Vec3f* pos, Vec3f* velocity, Vec3f* accel, s16 scale, s16 scoreIdx) { EffectSsExtraInitParams initParams; Math_Vec3f_Copy(&initParams.pos, pos); @@ -925,12 +921,12 @@ void EffectSsExtra_Spawn(GlobalContext* globalCtx, Vec3f* pos, Vec3f* velocity, initParams.scale = scale; initParams.scoreIdx = scoreIdx; - EffectSs_Spawn(globalCtx, EFFECT_SS_EXTRA, 100, &initParams); + EffectSs_Spawn(play, EFFECT_SS_EXTRA, 100, &initParams); } // EffectSsDeadDb Spawn Functions -void EffectSsDeadDb_Spawn(GlobalContext* globalCtx, Vec3f* pos, Vec3f* velocity, Vec3f* accel, Color_RGBA8* prim, +void EffectSsDeadDb_Spawn(PlayState* play, Vec3f* pos, Vec3f* velocity, Vec3f* accel, Color_RGBA8* prim, Color_RGBA8* env, s16 scale, s16 scaleStep, s32 unk) { EffectSsDeadDbInitParams initParams; @@ -948,10 +944,10 @@ void EffectSsDeadDb_Spawn(GlobalContext* globalCtx, Vec3f* pos, Vec3f* velocity, initParams.envColor.b = env->b; initParams.unk_30 = unk; - EffectSs_Spawn(globalCtx, EFFECT_SS_DEAD_DB, 120, &initParams); + EffectSs_Spawn(play, EFFECT_SS_DEAD_DB, 120, &initParams); } -void func_800B3030(GlobalContext* globalCtx, Vec3f* pos, Vec3f* velocity, Vec3f* accel, s16 scale, s16 scaleStep, +void func_800B3030(PlayState* play, Vec3f* pos, Vec3f* velocity, Vec3f* accel, s16 scale, s16 scaleStep, s32 colorIndex) { static Color_RGBA8 primColor = { 255, 255, 255, 255 }; static Color_RGBA8 envColors[] = { @@ -961,12 +957,12 @@ void func_800B3030(GlobalContext* globalCtx, Vec3f* pos, Vec3f* velocity, Vec3f* { 150, 150, 150, 255 }, }; - EffectSsDeadDb_Spawn(globalCtx, pos, velocity, accel, &primColor, &envColors[colorIndex], scale, scaleStep, 9); + EffectSsDeadDb_Spawn(play, pos, velocity, accel, &primColor, &envColors[colorIndex], scale, scaleStep, 9); } // EffectSsDeadDd Spawn Functions -void EffectSsDeadDd_Spawn(GlobalContext* globalCtx, Vec3f* pos, Vec3f* velocity, Vec3f* accel, Color_RGBA8* prim, +void EffectSsDeadDd_Spawn(PlayState* play, Vec3f* pos, Vec3f* velocity, Vec3f* accel, Color_RGBA8* prim, Color_RGBA8* env, s16 scale, s16 scaleStep, s16 alphaStep, s32 life) { EffectSsDeadDdInitParams initParams; @@ -982,16 +978,16 @@ void EffectSsDeadDd_Spawn(GlobalContext* globalCtx, Vec3f* pos, Vec3f* velocity, initParams.envColor.r = env->r; initParams.envColor.g = env->g; initParams.envColor.b = env->b; - initParams.type = 0; + initParams.type = DEADDD_TYPE_0; initParams.alphaStep = alphaStep; initParams.life = life; - EffectSs_Spawn(globalCtx, EFFECT_SS_DEAD_DD, 120, &initParams); + EffectSs_Spawn(play, EFFECT_SS_DEAD_DD, 120, &initParams); } // EffectSsDeadDs Spawn Functions -void EffectSsDeadDs_Spawn(GlobalContext* globalCtx, Vec3f* pos, Vec3f* velocity, Vec3f* accel, s16 scale, s16 scaleStep, +void EffectSsDeadDs_Spawn(PlayState* play, Vec3f* pos, Vec3f* velocity, Vec3f* accel, s16 scale, s16 scaleStep, s16 alpha, s32 life) { EffectSsDeadDsInitParams initParams; @@ -1002,16 +998,16 @@ void EffectSsDeadDs_Spawn(GlobalContext* globalCtx, Vec3f* pos, Vec3f* velocity, initParams.scaleStep = scaleStep; initParams.alpha = alpha; initParams.life = life; - EffectSs_Spawn(globalCtx, EFFECT_SS_DEAD_DS, 100, &initParams); + EffectSs_Spawn(play, EFFECT_SS_DEAD_DS, 100, &initParams); } -void func_800B31BC(GlobalContext* globalCtx, Vec3f* pos, s16 scale, s16 scaleStep, s16 alpha, s32 life) { - EffectSsDeadDs_Spawn(globalCtx, pos, &gZeroVec3f, &gZeroVec3f, scale, scaleStep, alpha, life); +void func_800B31BC(PlayState* play, Vec3f* pos, s16 scale, s16 scaleStep, s16 alpha, s32 life) { + EffectSsDeadDs_Spawn(play, pos, &gZeroVec3f, &gZeroVec3f, scale, scaleStep, alpha, life); } // EffectSsIceSmoke Spawn Functions -void EffectSsIceSmoke_Spawn(GlobalContext* globalCtx, Vec3f* pos, Vec3f* velocity, Vec3f* accel, s16 scale) { +void EffectSsIceSmoke_Spawn(PlayState* play, Vec3f* pos, Vec3f* velocity, Vec3f* accel, s16 scale) { EffectSsIceSmokeInitParams initParams; Math_Vec3f_Copy(&initParams.pos, pos); @@ -1019,12 +1015,12 @@ void EffectSsIceSmoke_Spawn(GlobalContext* globalCtx, Vec3f* pos, Vec3f* velocit Math_Vec3f_Copy(&initParams.accel, accel); initParams.scale = scale; - EffectSs_Spawn(globalCtx, EFFECT_SS_ICE_SMOKE, 128, &initParams); + EffectSs_Spawn(play, EFFECT_SS_ICE_SMOKE, 128, &initParams); } // EffectSsIceBlock Spawn Functions -void EffectSsIceBlock_Spawn(GlobalContext* globalCtx, Vec3f* pos, Vec3f* velocity, Vec3f* accel, s16 scale) { +void EffectSsIceBlock_Spawn(PlayState* play, Vec3f* pos, Vec3f* velocity, Vec3f* accel, s16 scale) { EffectEnIceBlockInitParams initParams; Math_Vec3f_Copy(&initParams.pos, pos); @@ -1032,5 +1028,5 @@ void EffectSsIceBlock_Spawn(GlobalContext* globalCtx, Vec3f* pos, Vec3f* velocit Math_Vec3f_Copy(&initParams.accel, accel); initParams.scale = scale; - EffectSs_Spawn(globalCtx, EFFECT_EN_ICE_BLOCK, 128, &initParams); + EffectSs_Spawn(play, EFFECT_EN_ICE_BLOCK, 128, &initParams); } diff --git a/src/code/z_elf_message.c b/src/code/z_elf_message.c index cd2fa96b6..57e84e86b 100644 --- a/src/code/z_elf_message.c +++ b/src/code/z_elf_message.c @@ -1,6 +1,6 @@ #include "global.h" -u16 ElfMessage_GetFirstCycleHint(GlobalContext* globalCtx) { +u16 ElfMessage_GetFirstCycleHint(PlayState* play) { if (INV_CONTENT(ITEM_OCARINA) == ITEM_OCARINA) { return 0; } @@ -20,7 +20,7 @@ u16 ElfMessage_GetFirstCycleHint(GlobalContext* globalCtx) { if (gSaveContext.save.weekEventReg[9] & 1) { return 0x21E; } - if (globalCtx->sceneNum == SCENE_YOUSEI_IZUMI) { + if (play->sceneNum == SCENE_YOUSEI_IZUMI) { return 0; } return 0x21D; @@ -29,7 +29,7 @@ u16 ElfMessage_GetFirstCycleHint(GlobalContext* globalCtx) { return 0x21F; } if (INV_CONTENT(ITEM_DEED_LAND) == ITEM_DEED_LAND) { - if (globalCtx->sceneNum != SCENE_OKUJOU) { + if (play->sceneNum != SCENE_OKUJOU) { return 0x244; } return 0; diff --git a/src/code/z_en_a_keep.c b/src/code/z_en_a_keep.c index 1d083b2c7..267da4e40 100644 --- a/src/code/z_en_a_keep.c +++ b/src/code/z_en_a_keep.c @@ -2,56 +2,56 @@ #define THIS ((EnAObj*)thisx) -void EnAObj_Update1(EnAObj* this, GlobalContext* globalCtx); -void EnAObj_Update2(EnAObj* this, GlobalContext* globalCtx); +void EnAObj_Update1(EnAObj* this, PlayState* play); +void EnAObj_Update2(EnAObj* this, PlayState* play); -void EnAObj_Init(Actor* thisx, GlobalContext* globalCtx) { +void EnAObj_Init(Actor* thisx, PlayState* play) { EnAObj* this = THIS; this->actor.textId = ((this->actor.params >> 8) & 0xFF) | 0x300; this->actor.params = (this->actor.params & 0xFF) - 9; Actor_ProcessInitChain(&this->actor, &enAObjInitVar); ActorShape_Init(&this->actor.shape, 0, ActorShadow_DrawCircle, 12); - Collider_InitAndSetCylinder(globalCtx, &this->collision, &this->actor, &enAObjCylinderInit); + Collider_InitAndSetCylinder(play, &this->collision, &this->actor, &enAObjCylinderInit); Collider_UpdateCylinder(&this->actor, &this->collision); this->actor.colChkInfo.mass = MASS_IMMOVABLE; this->actionFunc = EnAObj_Update1; } -void EnAObj_Destroy(Actor* thisx, GlobalContext* globalCtx) { +void EnAObj_Destroy(Actor* thisx, PlayState* play) { EnAObj* this = THIS; - Collider_DestroyCylinder(globalCtx, &this->collision); + Collider_DestroyCylinder(play, &this->collision); } -void EnAObj_Update1(EnAObj* this, GlobalContext* globalCtx) { +void EnAObj_Update1(EnAObj* this, PlayState* play) { s32 yawDiff; - if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { + if (Actor_ProcessTalkRequest(&this->actor, &play->state)) { this->actionFunc = EnAObj_Update2; } else { yawDiff = ABS_ALT((s16)(this->actor.yawTowardsPlayer - this->actor.shape.rot.y)); if ((yawDiff < 0x2800) || ((this->actor.params == 1) && (yawDiff > 0x5800))) { - func_800B863C(&this->actor, globalCtx); + func_800B863C(&this->actor, play); } } } -void EnAObj_Update2(EnAObj* this, GlobalContext* globalCtx) { - if (Actor_TextboxIsClosing(&this->actor, globalCtx)) { +void EnAObj_Update2(EnAObj* this, PlayState* play) { + if (Actor_TextboxIsClosing(&this->actor, play)) { this->actionFunc = EnAObj_Update1; } } -void EnAObj_Update(Actor* thisx, GlobalContext* globalCtx) { +void EnAObj_Update(Actor* thisx, PlayState* play) { EnAObj* this = THIS; - this->actionFunc(this, globalCtx); + this->actionFunc(this, play); Actor_SetFocus(&this->actor, 45.0f); - CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collision.base); + CollisionCheck_SetOC(play, &play->colChkCtx, &this->collision.base); } -void EnAObj_Draw(Actor* thisx, GlobalContext* globalCtx) { - Gfx_DrawDListOpa(globalCtx, enAObjDisplayLists[thisx->params]); +void EnAObj_Draw(Actor* thisx, PlayState* play) { + Gfx_DrawDListOpa(play, enAObjDisplayLists[thisx->params]); } diff --git a/src/code/z_en_hy_code.c b/src/code/z_en_hy_code.c index 6b16cc91c..5e32e5c95 100644 --- a/src/code/z_en_hy_code.c +++ b/src/code/z_en_hy_code.c @@ -11,7 +11,7 @@ #include "objects/object_boj/object_boj.h" #include "objects/object_os_anime/object_os_anime.h" -static AnimationInfoS sAnimations[] = { +static AnimationInfoS sAnimationInfo[] = { { &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 }, @@ -37,28 +37,28 @@ static AnimationInfoS sAnimations[] = { s8 gEnHyBodyParts[] = { -1, 1, 12, 13, 14, 9, 10, 11, 0, 6, 7, 8, 3, 4, 5, 2 }; -s8 gEnHyBodyPartsIndex[] = { 0, 0, 0, 0, 3, 4, 0, 6, 7, 0, 9, 10, 0, 12, 13 }; +s8 gEnHyParentBodyParts[] = { 0, 0, 0, 0, 3, 4, 0, 6, 7, 0, 9, 10, 0, 12, 13 }; -u8 gEnHyShadowSize[] = { 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 >= ENHY_ANIMATION_AOB_0 && animIndex < ENHY_ANIMATION_MAX) { + if (animIndex >= ENHY_ANIM_AOB_0 && animIndex < ENHY_ANIM_MAX) { isChanged = true; - frameCount = sAnimations[animIndex].frameCount; + frameCount = sAnimationInfo[animIndex].frameCount; if (frameCount < 0) { - frameCount = Animation_GetLastFrame(&sAnimations[animIndex].animation->common); + frameCount = Animation_GetLastFrame(&sAnimationInfo[animIndex].animation->common); } - Animation_Change(skelAnime, sAnimations[animIndex].animation, sAnimations[animIndex].playSpeed, - sAnimations[animIndex].startFrame, frameCount, sAnimations[animIndex].mode, - sAnimations[animIndex].morphFrames); + Animation_Change(skelAnime, sAnimationInfo[animIndex].animation, sAnimationInfo[animIndex].playSpeed, + sAnimationInfo[animIndex].startFrame, frameCount, sAnimationInfo[animIndex].mode, + sAnimationInfo[animIndex].morphFrames); } return isChanged; } -EnDoor* EnHy_FindNearestDoor(Actor* actor, GlobalContext* globalCtx) { +EnDoor* EnHy_FindNearestDoor(Actor* actor, PlayState* play) { EnDoor* nearestDoor = NULL; Actor* doorIter = NULL; f32 dist; @@ -67,7 +67,7 @@ EnDoor* EnHy_FindNearestDoor(Actor* actor, GlobalContext* globalCtx) { f32 minDist = 0.0f; do { - doorIter = SubS_FindActor(globalCtx, doorIter, ACTORCAT_DOOR, ACTOR_EN_DOOR); + doorIter = SubS_FindActor(play, doorIter, ACTORCAT_DOOR, ACTOR_EN_DOOR); door = (EnDoor*)doorIter; dist = Actor_DistanceBetweenActors(actor, &door->dyna.actor); if (!isSetup || (dist < minDist)) { @@ -83,16 +83,16 @@ EnDoor* EnHy_FindNearestDoor(Actor* actor, GlobalContext* globalCtx) { return nearestDoor; } -void EnHy_ChangeObjectAndAnim(EnHy* enHy, GlobalContext* globalCtx, s16 animIndex) { - gSegments[6] = PHYSICAL_TO_VIRTUAL(globalCtx->objectCtx.status[enHy->animObjIndex].segment); +void EnHy_ChangeObjectAndAnim(EnHy* enHy, PlayState* play, s16 animIndex) { + gSegments[6] = PHYSICAL_TO_VIRTUAL(play->objectCtx.status[enHy->animObjIndex].segment); EnHy_ChangeAnim(&enHy->skelAnime, animIndex); } -s32 EnHy_UpdateSkelAnime(EnHy* enHy, GlobalContext* globalCtx) { +s32 EnHy_UpdateSkelAnime(EnHy* enHy, PlayState* play) { s32 isUpdated = false; if (enHy->actor.draw != NULL) { - gSegments[6] = PHYSICAL_TO_VIRTUAL(globalCtx->objectCtx.status[enHy->animObjIndex].segment); + gSegments[6] = PHYSICAL_TO_VIRTUAL(play->objectCtx.status[enHy->animObjIndex].segment); SkelAnime_Update(&enHy->skelAnime); isUpdated = true; } @@ -109,26 +109,26 @@ void EnHy_Blink(EnHy* enHy, s32 eyeTexMaxIndex) { } } -s32 EnHy_Init(EnHy* enHy, GlobalContext* globalCtx, FlexSkeletonHeader* skeletonHeaderSeg, s16 animIndex) { +s32 EnHy_Init(EnHy* enHy, PlayState* play, FlexSkeletonHeader* skeletonHeaderSeg, s16 animIndex) { s32 isInitialized = false; - 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)) { + if ((SubS_IsObjectLoaded(enHy->animObjIndex, play) == true) && + (SubS_IsObjectLoaded(enHy->headObjIndex, play) == true) && + (SubS_IsObjectLoaded(enHy->skelUpperObjIndex, play) == true) && + (SubS_IsObjectLoaded(enHy->skelLowerObjIndex, play) == 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, + gSegments[6] = PHYSICAL_TO_VIRTUAL(play->objectCtx.status[enHy->actor.objBankIndex].segment); + SkelAnime_InitFlex(play, &enHy->skelAnime, skeletonHeaderSeg, NULL, enHy->jointTable, enHy->morphTable, ENHY_LIMB_MAX); - EnHy_ChangeObjectAndAnim(enHy, globalCtx, animIndex); + EnHy_ChangeObjectAndAnim(enHy, play, animIndex); } return isInitialized; } -void func_800F0BB4(EnHy* enHy, GlobalContext* globalCtx, EnDoor* door, s16 arg3, s16 arg4) { +void func_800F0BB4(EnHy* enHy, PlayState* play, EnDoor* door, s16 arg3, s16 arg4) { s32 pad; s8 animIndex; Vec3f offset; @@ -137,26 +137,26 @@ void func_800F0BB4(EnHy* enHy, GlobalContext* globalCtx, EnDoor* door, s16 arg3, Actor_OffsetOfPointInActorCoords(&door->dyna.actor, &offset, &enHy->actor.world.pos); phi_f0 = (offset.z >= 0.0f) ? 1.0f : -1.0f; animIndex = ((s8)phi_f0 < 0) ? 0 : 2; - EnHy_ChangeObjectAndAnim(enHy, globalCtx, (animIndex == 0) ? arg3 : arg4); + EnHy_ChangeObjectAndAnim(enHy, play, (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); + AnimationContext_SetMoveActor(play, &enHy->actor, &enHy->skelAnime, 1.0f); door->unk_1A1 = 1; door->animIndex = animIndex; } -s32 func_800F0CE4(EnHy* enHy, GlobalContext* globalCtx, ActorFunc draw, s16 arg3, s16 arg4, f32 arg5) { +s32 func_800F0CE4(EnHy* enHy, PlayState* play, ActorFunc draw, s16 arg3, s16 arg4, f32 arg5) { s32 ret = false; s16 yaw; EnDoor* door; s32 pad; if (SubS_CopyPointFromPath(enHy->path, enHy->curPoint, &enHy->actor.world.pos)) { - door = EnHy_FindNearestDoor(&enHy->actor, globalCtx); + door = EnHy_FindNearestDoor(&enHy->actor, play); if (door != NULL) { ret = true; - func_800F0BB4(enHy, globalCtx, door, arg3, arg4); + func_800F0BB4(enHy, play, door, arg3, arg4); 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); @@ -168,17 +168,17 @@ s32 func_800F0CE4(EnHy* enHy, GlobalContext* globalCtx, ActorFunc draw, s16 arg3 return ret; } -s32 func_800F0DD4(EnHy* enHy, GlobalContext* globalCtx, s16 arg2, s16 arg3) { +s32 func_800F0DD4(EnHy* enHy, PlayState* play, s16 arg2, s16 arg3) { s32 ret = false; s32 pad; EnDoor* door; enHy->curPoint = 0; if (SubS_CopyPointFromPath(enHy->path, enHy->curPoint, &enHy->actor.world.pos)) { - door = EnHy_FindNearestDoor(&enHy->actor, globalCtx); + door = EnHy_FindNearestDoor(&enHy->actor, play); if (door != NULL) { ret = true; - func_800F0BB4(enHy, globalCtx, door, arg2, arg3); + func_800F0BB4(enHy, play, door, arg2, arg3); 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; @@ -188,16 +188,16 @@ s32 func_800F0DD4(EnHy* enHy, GlobalContext* globalCtx, s16 arg2, s16 arg3) { return ret; } -s32 EnHy_SetPointFowards(EnHy* enHy, GlobalContext* globalCtx, f32 gravity, s16 animIndex) { +s32 EnHy_SetPointFowards(EnHy* enHy, PlayState* play, f32 gravity, s16 animIndex) { enHy->actor.gravity = gravity; enHy->actor.flags |= ACTOR_FLAG_1; - EnHy_ChangeObjectAndAnim(enHy, globalCtx, animIndex); + EnHy_ChangeObjectAndAnim(enHy, play, animIndex); enHy->curPoint++; return false; } -s32 EnHy_SetPointBackwards(EnHy* enHy, GlobalContext* globalCtx, s16 animIndex) { - EnHy_ChangeObjectAndAnim(enHy, globalCtx, animIndex); +s32 EnHy_SetPointBackwards(EnHy* enHy, PlayState* play, s16 animIndex) { + EnHy_ChangeObjectAndAnim(enHy, play, animIndex); enHy->curPoint--; return false; } @@ -238,16 +238,16 @@ s32 EnHy_MoveBackwards(EnHy* enHy, f32 speedTarget) { return reachedEnd; } -void EnHy_UpdateCollider(EnHy* enHy, GlobalContext* globalCtx) { +void EnHy_UpdateCollider(EnHy* enHy, PlayState* play) { enHy->collider.dim.pos.x = enHy->actor.world.pos.x; enHy->collider.dim.pos.y = enHy->actor.world.pos.y; enHy->collider.dim.pos.z = enHy->actor.world.pos.z; - CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &enHy->collider.base); - CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &enHy->collider.base); + CollisionCheck_SetAC(play, &play->colChkCtx, &enHy->collider.base); + CollisionCheck_SetOC(play, &play->colChkCtx, &enHy->collider.base); } -s32 EnHy_PlayWalkingSound(EnHy* enHy, GlobalContext* globalCtx, f32 distAboveThreshold) { +s32 EnHy_PlayWalkingSound(EnHy* enHy, PlayState* play, f32 distAboveThreshold) { u8 wasLeftFootOnGround = enHy->isLeftFootOnGround; u8 wasRightFootOnGround = enHy->isRightFootOnGround; s32 waterSfxId; @@ -262,15 +262,15 @@ s32 EnHy_PlayWalkingSound(EnHy* enHy, GlobalContext* globalCtx, f32 distAboveThr } sfxId = waterSfxId + SFX_FLAG; } else { - sfxId = SurfaceType_GetSfx(&globalCtx->colCtx, enHy->actor.floorPoly, enHy->actor.floorBgId) + SFX_FLAG; + sfxId = SurfaceType_GetSfx(&play->colCtx, enHy->actor.floorPoly, enHy->actor.floorBgId) + SFX_FLAG; } - enHy->isLeftFootOnGround = isFootOnGround = SubS_IsFloorAbove(globalCtx, &enHy->leftFootPos, distAboveThreshold); + enHy->isLeftFootOnGround = isFootOnGround = SubS_IsFloorAbove(play, &enHy->leftFootPos, distAboveThreshold); if (enHy->isLeftFootOnGround && !wasLeftFootOnGround && isFootOnGround) { Actor_PlaySfxAtPos(&enHy->actor, sfxId); } - enHy->isRightFootOnGround = isFootOnGround = SubS_IsFloorAbove(globalCtx, &enHy->rightFootPos, distAboveThreshold); + enHy->isRightFootOnGround = isFootOnGround = SubS_IsFloorAbove(play, &enHy->rightFootPos, distAboveThreshold); if (enHy->isRightFootOnGround && !wasRightFootOnGround && isFootOnGround) { Actor_PlaySfxAtPos(&enHy->actor, sfxId); } diff --git a/src/code/z_en_item00.c b/src/code/z_en_item00.c index b8fa0f4f1..0637f6392 100644 --- a/src/code/z_en_item00.c +++ b/src/code/z_en_item00.c @@ -1,21 +1,22 @@ #include "global.h" #include "objects/gameplay_keep/gameplay_keep.h" #include "objects/object_gi_hearts/object_gi_hearts.h" +#include "overlays/actors/ovl_En_Elforg/z_en_elforg.h" #define FLAGS 0x00000000 #define THIS ((EnItem00*)thisx) -void EnItem00_Init(Actor* thisx, GlobalContext* globalCtx); -void EnItem00_Destroy(Actor* thisx, GlobalContext* globalCtx); -void EnItem00_Update(Actor* thisx, GlobalContext* globalCtx); -void EnItem00_Draw(Actor* thisx, GlobalContext* globalCtx); +void EnItem00_Init(Actor* thisx, PlayState* play); +void EnItem00_Destroy(Actor* thisx, PlayState* play); +void EnItem00_Update(Actor* thisx, PlayState* play); +void EnItem00_Draw(Actor* thisx, PlayState* play); -void EnItem00_WaitForHeartObject(EnItem00* this, GlobalContext* globalCtx); -void func_800A640C(EnItem00* this, GlobalContext* globalCtx); -void func_800A6650(EnItem00* this, GlobalContext* globalCtx); -void func_800A6780(EnItem00* this, GlobalContext* globalCtx); -void func_800A6A40(EnItem00* this, GlobalContext* globalCtx); +void EnItem00_WaitForHeartObject(EnItem00* this, PlayState* play); +void func_800A640C(EnItem00* this, PlayState* play); +void func_800A6650(EnItem00* this, PlayState* play); +void func_800A6780(EnItem00* this, PlayState* play); +void func_800A6A40(EnItem00* this, PlayState* play); const ActorInit En_Item00_InitVars = { ACTOR_EN_ITEM00, @@ -53,8 +54,8 @@ static InitChainEntry sInitChain[] = { ICHAIN_F32(targetArrowOffset, 2000, ICHAIN_STOP), }; -void EnItem00_SetObject(EnItem00* this, GlobalContext* globalCtx, f32* shadowOffset, f32* shadowScale) { - Actor_SetObjectDependency(globalCtx, &this->actor); +void EnItem00_SetObject(EnItem00* this, PlayState* play, f32* shadowOffset, f32* shadowScale) { + Actor_SetObjectDependency(play, &this->actor); Actor_SetScale(&this->actor, 0.5f); this->unk154 = 0.5f; *shadowOffset = 0.0f; @@ -62,34 +63,34 @@ void EnItem00_SetObject(EnItem00* this, GlobalContext* globalCtx, f32* shadowOff this->actor.world.rot.x = 0x4000; } -void EnItem00_Init(Actor* thisx, GlobalContext* globalCtx) { +void EnItem00_Init(Actor* thisx, PlayState* play) { EnItem00* this = THIS; s32 pad; 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 - if (Flags_GetCollectible(globalCtx, this->collectibleFlag)) { + if (Flags_GetCollectible(play, this->collectibleFlag)) { if (this->actor.params == ITEM00_HEART_PIECE) { sp30 = 0; this->collectibleFlag = 0; - this->actor.params = ITEM00_HEART; + this->actor.params = ITEM00_RECOVERY_HEART; } else { Actor_MarkForDeath(&this->actor); return; } } if (this->actor.params == ITEM00_3_HEARTS) { - this->actor.params = ITEM00_HEART; + this->actor.params = ITEM00_RECOVERY_HEART; } Actor_ProcessInitChain(&this->actor, sInitChain); - Collider_InitAndSetCylinder(globalCtx, &this->collider, &this->actor, &sCylinderInit); + Collider_InitAndSetCylinder(play, &this->collider, &this->actor, &sCylinderInit); this->unk150 = 1; @@ -117,7 +118,7 @@ void EnItem00_Init(Actor* thisx, GlobalContext* globalCtx) { sp30 = -1; } break; - case ITEM00_HEART: + case ITEM00_RECOVERY_HEART: this->actor.home.rot.z = randPlusMinusPoint5Scaled(65535.0f); shadowOffset = 430.0f; Actor_SetScale(&this->actor, 0.02f); @@ -164,16 +165,16 @@ void EnItem00_Init(Actor* thisx, GlobalContext* globalCtx) { this->unk154 = 0.01f; break; case ITEM00_SHIELD_HERO: - this->actor.objBankIndex = Object_GetIndex(&globalCtx->objectCtx, OBJECT_GI_SHIELD_2); - EnItem00_SetObject(this, globalCtx, &shadowOffset, &shadowScale); + this->actor.objBankIndex = Object_GetIndex(&play->objectCtx, OBJECT_GI_SHIELD_2); + EnItem00_SetObject(this, play, &shadowOffset, &shadowScale); break; case ITEM00_MAP: - this->actor.objBankIndex = Object_GetIndex(&globalCtx->objectCtx, OBJECT_GI_MAP); - EnItem00_SetObject(this, globalCtx, &shadowOffset, &shadowScale); + this->actor.objBankIndex = Object_GetIndex(&play->objectCtx, OBJECT_GI_MAP); + EnItem00_SetObject(this, play, &shadowOffset, &shadowScale); break; case ITEM00_COMPASS: - this->actor.objBankIndex = Object_GetIndex(&globalCtx->objectCtx, OBJECT_GI_COMPASS); - EnItem00_SetObject(this, globalCtx, &shadowOffset, &shadowScale); + this->actor.objBankIndex = Object_GetIndex(&play->objectCtx, OBJECT_GI_COMPASS); + EnItem00_SetObject(this, play, &shadowOffset, &shadowScale); break; default: break; @@ -183,7 +184,7 @@ void EnItem00_Init(Actor* thisx, GlobalContext* globalCtx) { ActorShape_Init(&this->actor.shape, shadowOffset, ActorShadow_DrawCircle, shadowScale); this->actor.shape.shadowAlpha = 180; this->actor.focus.pos = this->actor.world.pos; - this->unk14A = GI_NONE; + this->getItemId = GI_NONE; if (sp30 < 0) { this->actionFunc = EnItem00_WaitForHeartObject; @@ -205,51 +206,51 @@ void EnItem00_Init(Actor* thisx, GlobalContext* globalCtx) { switch (this->actor.params) { case ITEM00_RUPEE_GREEN: - Item_Give(globalCtx, ITEM_RUPEE_GREEN); + Item_Give(play, ITEM_RUPEE_GREEN); break; case ITEM00_RUPEE_BLUE: - Item_Give(globalCtx, ITEM_RUPEE_BLUE); + Item_Give(play, ITEM_RUPEE_BLUE); break; case ITEM00_RUPEE_RED: - Item_Give(globalCtx, ITEM_RUPEE_RED); + Item_Give(play, ITEM_RUPEE_RED); break; case ITEM00_RUPEE_PURPLE: - Item_Give(globalCtx, ITEM_RUPEE_PURPLE); + Item_Give(play, ITEM_RUPEE_PURPLE); break; case ITEM00_RUPEE_HUGE: - Item_Give(globalCtx, ITEM_RUPEE_HUGE); + Item_Give(play, ITEM_RUPEE_HUGE); break; - case ITEM00_HEART: - Item_Give(globalCtx, ITEM_HEART); + case ITEM00_RECOVERY_HEART: + Item_Give(play, ITEM_RECOVERY_HEART); break; case ITEM00_FLEXIBLE: case ITEM00_BIG_FAIRY: - func_80115908(globalCtx, 0x70); + Health_ChangeBy(play, 0x70); break; case ITEM00_BOMBS_A: case ITEM00_BOMBS_B: - Item_Give(globalCtx, ITEM_BOMBS_5); + Item_Give(play, ITEM_BOMBS_5); break; case ITEM00_ARROWS_10: - Item_Give(globalCtx, ITEM_ARROWS_10); + Item_Give(play, ITEM_ARROWS_10); break; case ITEM00_ARROWS_30: - Item_Give(globalCtx, ITEM_ARROWS_30); + Item_Give(play, ITEM_ARROWS_30); break; case ITEM00_ARROWS_40: - Item_Give(globalCtx, ITEM_ARROWS_40); + Item_Give(play, ITEM_ARROWS_40); break; case ITEM00_ARROWS_50: - Item_Give(globalCtx, ITEM_ARROWS_50); + Item_Give(play, ITEM_ARROWS_50); break; case ITEM00_MAGIC_LARGE: - Item_Give(globalCtx, ITEM_MAGIC_LARGE); + Item_Give(play, ITEM_MAGIC_LARGE); break; case ITEM00_MAGIC_SMALL: - Item_Give(globalCtx, ITEM_MAGIC_SMALL); + Item_Give(play, ITEM_MAGIC_SMALL); break; case ITEM00_SMALL_KEY: - Item_Give(globalCtx, ITEM_KEY_SMALL); + Item_Give(play, ITEM_KEY_SMALL); break; case ITEM00_NUTS_1: getItemId = GI_NUTS_1; @@ -261,32 +262,33 @@ void EnItem00_Init(Actor* thisx, GlobalContext* globalCtx) { break; } - if ((getItemId != GI_NONE) && (Actor_HasParent(&this->actor, globalCtx) == 0)) { - Actor_PickUp(&this->actor, globalCtx, getItemId, 50.0f, 20.0f); + if ((getItemId != GI_NONE) && (Actor_HasParent(&this->actor, play) == 0)) { + Actor_PickUp(&this->actor, play, getItemId, 50.0f, 20.0f); } this->actionFunc = func_800A6A40; - this->actionFunc(this, globalCtx); + this->actionFunc(this, play); } -void EnItem00_Destroy(Actor* thisx, GlobalContext* globalCtx) { +void EnItem00_Destroy(Actor* thisx, PlayState* play) { EnItem00* this = THIS; - Collider_DestroyCylinder(globalCtx, &this->collider); + Collider_DestroyCylinder(play, &this->collider); } -void EnItem00_WaitForHeartObject(EnItem00* this, GlobalContext* globalCtx) { +void EnItem00_WaitForHeartObject(EnItem00* this, PlayState* play) { s32 sp1C; - sp1C = Object_GetIndex(&globalCtx->objectCtx, OBJECT_GI_HEARTS); - if (Object_IsLoaded(&globalCtx->objectCtx, sp1C)) { + sp1C = Object_GetIndex(&play->objectCtx, OBJECT_GI_HEARTS); + if (Object_IsLoaded(&play->objectCtx, sp1C)) { this->actor.objBankIndex = sp1C; this->actionFunc = func_800A640C; } } -void func_800A640C(EnItem00* this, GlobalContext* globalCtx) { - if ((this->actor.params <= ITEM00_RUPEE_RED) || ((this->actor.params == ITEM00_HEART) && (this->unk152 < 0)) || +void func_800A640C(EnItem00* this, PlayState* play) { + if ((this->actor.params <= ITEM00_RUPEE_RED) || + ((this->actor.params == ITEM00_RECOVERY_HEART) && (this->unk152 < 0)) || (this->actor.params == ITEM00_HEART_PIECE) || (this->actor.params == ITEM00_HEART_CONTAINER)) { this->actor.shape.rot.y = this->actor.shape.rot.y + 960; } else if ((this->actor.params >= ITEM00_SHIELD_HERO) && (this->actor.params != ITEM00_NUTS_10) && @@ -335,18 +337,18 @@ static Color_RGBA8 D_801ADF14 = { 255, 255, 255, 0 }; static Vec3f D_801ADF18 = { 0.0f, 0.1f, 0.0f }; static Vec3f D_801ADF24 = { 0.0f, 0.01f, 0.0f }; -void func_800A6650(EnItem00* this, GlobalContext* globalCtx) { +void func_800A6650(EnItem00* this, PlayState* play) { u32 pad; Vec3f pos; if (this->actor.params <= ITEM00_RUPEE_RED) { this->actor.shape.rot.y = this->actor.shape.rot.y + 960; } - if ((globalCtx->gameplayFrames & 1) != 0) { + if ((play->gameplayFrames & 1) != 0) { 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(play, &pos, &D_801ADF18, &D_801ADF24, &D_801ADF10, &D_801ADF14); } if ((this->actor.bgCheckFlags & 3) != 0) { if (this->actor.velocity.y > -2.0f) { @@ -359,14 +361,14 @@ void func_800A6650(EnItem00* this, GlobalContext* globalCtx) { } } -void func_800A6780(EnItem00* this, GlobalContext* globalCtx) { +void func_800A6780(EnItem00* this, PlayState* play) { s32 pad; Vec3f pos; s32 var1; this->unk152++; - if (this->actor.params == ITEM00_HEART) { + if (this->actor.params == ITEM00_RECOVERY_HEART) { if (this->actor.velocity.y < 0.0f) { this->actor.speedXZ = 0.0f; this->actor.gravity = -0.4f; @@ -399,11 +401,11 @@ void func_800A6780(EnItem00* this, GlobalContext* globalCtx) { } } - if ((globalCtx->gameplayFrames & 1) == 0) { + if ((play->gameplayFrames & 1) == 0) { 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(play, &pos, &D_801ADF18, &D_801ADF24, &D_801ADF10, &D_801ADF14); } if (this->actor.bgCheckFlags & 0x0003) { @@ -413,15 +415,15 @@ void func_800A6780(EnItem00* this, GlobalContext* globalCtx) { } } -void func_800A6A40(EnItem00* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); +void func_800A6A40(EnItem00* this, PlayState* play) { + Player* player = GET_PLAYER(play); - if (this->unk14A != GI_NONE) { - if (Actor_HasParent(&this->actor, globalCtx) == 0) { - Actor_PickUp(&this->actor, globalCtx, this->unk14A, 50.0f, 80.0f); + if (this->getItemId != GI_NONE) { + if (Actor_HasParent(&this->actor, play) == 0) { + Actor_PickUp(&this->actor, play, this->getItemId, 50.0f, 80.0f); this->unk152++; } else { - this->unk14A = GI_NONE; + this->getItemId = GI_NONE; } } @@ -434,7 +436,7 @@ void func_800A6A40(EnItem00* this, GlobalContext* globalCtx) { if (this->actor.params <= ITEM00_RUPEE_RED) { this->actor.shape.rot.y = this->actor.shape.rot.y + 960; - } else if (this->actor.params == ITEM00_HEART) { + } else if (this->actor.params == ITEM00_RECOVERY_HEART) { this->actor.shape.rot.y = 0; } @@ -445,10 +447,10 @@ void func_800A6A40(EnItem00* this, GlobalContext* globalCtx) { } } -void EnItem00_Update(Actor* thisx, GlobalContext* globalCtx) { +void EnItem00_Update(Actor* thisx, PlayState* play) { EnItem00* this = THIS; s32 pad; - Player* player = GET_PLAYER(globalCtx); + Player* player = GET_PLAYER(play); s32 sp38 = player->stateFlags3 & 0x1000; s32 getItemId = GI_NONE; s32 params; @@ -461,7 +463,7 @@ void EnItem00_Update(Actor* thisx, GlobalContext* globalCtx) { this->unk14E = this->unk152; } - this->actionFunc(this, globalCtx); + this->actionFunc(this, play); Math_SmoothStepToF(&this->actor.scale.x, this->unk154, 0.1f, this->unk154 * 0.1f, 0.0f); this->actor.scale.z = this->actor.scale.x; @@ -469,7 +471,7 @@ void EnItem00_Update(Actor* thisx, GlobalContext* globalCtx) { if (this->actor.gravity != 0.0f) { Actor_MoveWithGravity(&this->actor); - Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 20.0f, 15.0f, 15.0f, 0x1D); + Actor_UpdateBgCheckInfo(play, &this->actor, 20.0f, 15.0f, 15.0f, 0x1D); if (this->actor.floorHeight <= BGCHECK_Y_MIN) { Actor_MarkForDeath(&this->actor); @@ -478,7 +480,7 @@ void EnItem00_Update(Actor* thisx, GlobalContext* globalCtx) { } Collider_UpdateCylinder(&this->actor, &this->collider); - CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + CollisionCheck_SetAC(play, &play->colChkCtx, &this->collider.base); params = this->actor.params; if ((params == ITEM00_SHIELD_HERO) || (params == ITEM00_MAP) || (params == ITEM00_COMPASS)) { @@ -493,35 +495,35 @@ void EnItem00_Update(Actor* thisx, GlobalContext* globalCtx) { (this->actor.playerHeightRel <= 100.0f)) && !((sp38 == 0) && (this->actor.xzDistToPlayer <= 30.0f) && (this->actor.playerHeightRel >= -50.0f) && (this->actor.playerHeightRel <= 50.0f))) { - if (!Actor_HasParent(&this->actor, globalCtx)) { + if (!Actor_HasParent(&this->actor, play)) { return; } } - if (globalCtx->gameOverCtx.state != 0) { + if (play->gameOverCtx.state != 0) { return; } switch (this->actor.params) { case ITEM00_RUPEE_GREEN: this->unk1A4 = 1; - Item_Give(globalCtx, ITEM_RUPEE_GREEN); + Item_Give(play, ITEM_RUPEE_GREEN); break; case ITEM00_RUPEE_BLUE: this->unk1A4 = 1; - Item_Give(globalCtx, ITEM_RUPEE_BLUE); + Item_Give(play, ITEM_RUPEE_BLUE); break; case ITEM00_RUPEE_RED: this->unk1A4 = 1; - Item_Give(globalCtx, ITEM_RUPEE_RED); + Item_Give(play, ITEM_RUPEE_RED); break; case ITEM00_RUPEE_PURPLE: this->unk1A4 = 1; - Item_Give(globalCtx, ITEM_RUPEE_PURPLE); + Item_Give(play, ITEM_RUPEE_PURPLE); break; case ITEM00_RUPEE_HUGE: this->unk1A4 = 1; - Item_Give(globalCtx, ITEM_RUPEE_HUGE); + Item_Give(play, ITEM_RUPEE_HUGE); break; case ITEM00_STICK: getItemId = GI_STICKS_1; @@ -532,28 +534,28 @@ void EnItem00_Update(Actor* thisx, GlobalContext* globalCtx) { case ITEM00_NUTS_10: getItemId = GI_NUTS_10; break; - case ITEM00_HEART: - Item_Give(globalCtx, ITEM_HEART); + case ITEM00_RECOVERY_HEART: + Item_Give(play, ITEM_RECOVERY_HEART); break; case ITEM00_FLEXIBLE: case ITEM00_BIG_FAIRY: - func_80115908(globalCtx, 0x70); + Health_ChangeBy(play, 0x70); break; case ITEM00_BOMBS_A: case ITEM00_BOMBS_B: - Item_Give(globalCtx, ITEM_BOMBS_5); + Item_Give(play, ITEM_BOMBS_5); break; case ITEM00_ARROWS_10: - Item_Give(globalCtx, ITEM_ARROWS_10); + Item_Give(play, ITEM_ARROWS_10); break; case ITEM00_ARROWS_30: - Item_Give(globalCtx, ITEM_ARROWS_30); + Item_Give(play, ITEM_ARROWS_30); break; case ITEM00_ARROWS_40: - Item_Give(globalCtx, ITEM_ARROWS_40); + Item_Give(play, ITEM_ARROWS_40); break; case ITEM00_ARROWS_50: - Item_Give(globalCtx, ITEM_ARROWS_50); + Item_Give(play, ITEM_ARROWS_50); break; case ITEM00_SMALL_KEY: getItemId = GI_KEY_SMALL; @@ -565,10 +567,10 @@ void EnItem00_Update(Actor* thisx, GlobalContext* globalCtx) { getItemId = GI_HEART_CONTAINER; break; case ITEM00_MAGIC_LARGE: - Item_Give(globalCtx, ITEM_MAGIC_LARGE); + Item_Give(play, ITEM_MAGIC_LARGE); break; case ITEM00_MAGIC_SMALL: - Item_Give(globalCtx, ITEM_MAGIC_SMALL); + Item_Give(play, ITEM_MAGIC_SMALL); break; case ITEM00_SHIELD_HERO: getItemId = GI_SHIELD_HERO; @@ -584,8 +586,8 @@ void EnItem00_Update(Actor* thisx, GlobalContext* globalCtx) { } if (getItemId != GI_NONE) { - if (!Actor_HasParent(&this->actor, globalCtx)) { - Actor_PickUp(&this->actor, globalCtx, getItemId, 50.0f, 20.0f); + if (!Actor_HasParent(&this->actor, play)) { + Actor_PickUp(&this->actor, play, getItemId, 50.0f, 20.0f); } } @@ -596,8 +598,8 @@ void EnItem00_Update(Actor* thisx, GlobalContext* globalCtx) { case ITEM00_SHIELD_HERO: case ITEM00_MAP: case ITEM00_COMPASS: - if (Actor_HasParent(&this->actor, globalCtx)) { - Flags_SetCollectible(globalCtx, this->collectibleFlag); + if (Actor_HasParent(&this->actor, play)) { + Flags_SetCollectible(play, this->collectibleFlag); Actor_MarkForDeath(&this->actor); } return; @@ -608,8 +610,8 @@ void EnItem00_Update(Actor* thisx, GlobalContext* globalCtx) { if ((this->actor.params <= ITEM00_RUPEE_RED) || (this->actor.params == ITEM00_RUPEE_HUGE)) { play_sound(NA_SE_SY_GET_RUPY); } else if (getItemId != GI_NONE) { - if (Actor_HasParent(&this->actor, globalCtx)) { - Flags_SetCollectible(globalCtx, this->collectibleFlag); + if (Actor_HasParent(&this->actor, play)) { + Flags_SetCollectible(play, this->collectibleFlag); Actor_MarkForDeath(&this->actor); } return; @@ -617,7 +619,7 @@ void EnItem00_Update(Actor* thisx, GlobalContext* globalCtx) { play_sound(NA_SE_SY_GET_ITEM); } - Flags_SetCollectible(globalCtx, this->collectibleFlag); + Flags_SetCollectible(play, this->collectibleFlag); this->unk152 = 15; this->unk14C = 35; @@ -628,16 +630,16 @@ void EnItem00_Update(Actor* thisx, GlobalContext* globalCtx) { Actor_SetScale(&this->actor, this->unk154); - this->unk14A = GI_NONE; + this->getItemId = GI_NONE; this->actionFunc = func_800A6A40; } -void EnItem00_DrawRupee(EnItem00* this, GlobalContext* globalCtx); -void EnItem00_DrawSprite(EnItem00* this, GlobalContext* globalCtx); -void EnItem00_DrawHeartContainer(EnItem00* this, GlobalContext* globalCtx); -void EnItem00_DrawHeartPiece(EnItem00* this, GlobalContext* globalCtx); +void EnItem00_DrawRupee(EnItem00* this, PlayState* play); +void EnItem00_DrawSprite(EnItem00* this, PlayState* play); +void EnItem00_DrawHeartContainer(EnItem00* this, PlayState* play); +void EnItem00_DrawHeartPiece(EnItem00* this, PlayState* play); -void EnItem00_Draw(Actor* thisx, GlobalContext* globalCtx) { +void EnItem00_Draw(Actor* thisx, PlayState* play) { s32 pad; EnItem00* this = THIS; @@ -648,26 +650,26 @@ void EnItem00_Draw(Actor* thisx, GlobalContext* globalCtx) { case ITEM00_RUPEE_RED: case ITEM00_RUPEE_HUGE: case ITEM00_RUPEE_PURPLE: - EnItem00_DrawRupee(this, globalCtx); + EnItem00_DrawRupee(this, play); break; case ITEM00_HEART_PIECE: - EnItem00_DrawHeartPiece(this, globalCtx); + EnItem00_DrawHeartPiece(this, play); break; case ITEM00_HEART_CONTAINER: - EnItem00_DrawHeartContainer(this, globalCtx); + EnItem00_DrawHeartContainer(this, play); break; - case ITEM00_HEART: + case ITEM00_RECOVERY_HEART: if (this->unk152 < 0) { if (this->unk152 == -1) { - s8 bankIndex = Object_GetIndex(&globalCtx->objectCtx, OBJECT_GI_HEART); - if (Object_IsLoaded(&globalCtx->objectCtx, bankIndex)) { + s8 bankIndex = Object_GetIndex(&play->objectCtx, OBJECT_GI_HEART); + if (Object_IsLoaded(&play->objectCtx, bankIndex)) { this->actor.objBankIndex = bankIndex; - Actor_SetObjectDependency(globalCtx, &this->actor); + Actor_SetObjectDependency(play, &this->actor); this->unk152 = -2; } } else { Matrix_Scale(16.0f, 16.0f, 16.0f, MTXMODE_APPLY); - GetItem_Draw(globalCtx, 8); + GetItem_Draw(play, GID_RECOVERY_HEART); } break; } @@ -684,16 +686,16 @@ void EnItem00_Draw(Actor* thisx, GlobalContext* globalCtx) { case ITEM00_SMALL_KEY: case ITEM00_NUTS_10: case ITEM00_BOMBS_0: - EnItem00_DrawSprite(this, globalCtx); + EnItem00_DrawSprite(this, play); break; case ITEM00_SHIELD_HERO: - GetItem_Draw(globalCtx, GID_SHIELD_HERO); + GetItem_Draw(play, GID_SHIELD_HERO); break; case ITEM00_MAP: - GetItem_Draw(globalCtx, GID_DUNGEON_MAP); + GetItem_Draw(play, GID_DUNGEON_MAP); break; case ITEM00_COMPASS: - GetItem_Draw(globalCtx, GID_COMPASS); + GetItem_Draw(play, GID_COMPASS); case ITEM00_MASK: case ITEM00_FLEXIBLE: case ITEM00_3_HEARTS: @@ -712,14 +714,14 @@ TexturePtr D_801ADF30[] = { gameplay_keep_Tex_062020 // Purple rupee }; -void EnItem00_DrawRupee(EnItem00* this, GlobalContext* globalCtx) { +void EnItem00_DrawRupee(EnItem00* this, PlayState* play) { s32 pad; s32 iconNb; - OPEN_DISPS(globalCtx->state.gfxCtx); + OPEN_DISPS(play->state.gfxCtx); - func_8012C28C(globalCtx->state.gfxCtx); - func_800B8050(&this->actor, globalCtx, 0); + func_8012C28C(play->state.gfxCtx); + func_800B8050(&this->actor, play, 0); if (this->actor.params <= ITEM00_RUPEE_RED) { iconNb = this->actor.params; @@ -727,13 +729,13 @@ void EnItem00_DrawRupee(EnItem00* this, GlobalContext* globalCtx) { iconNb = this->actor.params - 0x10; } - gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_MODELVIEW | G_MTX_LOAD); + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_MODELVIEW | G_MTX_LOAD); gSPSegment(POLY_OPA_DISP++, 0x08, Lib_SegmentedToVirtual(D_801ADF30[iconNb])); gSPDisplayList(POLY_OPA_DISP++, gameplay_keep_DL_0622C0); // TODO symbol - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->state.gfxCtx); } TexturePtr D_801ADF44[12] = { @@ -751,12 +753,12 @@ TexturePtr D_801ADF44[12] = { gameplay_keep_Tex_05F7C0 // Small Key }; -void EnItem00_DrawSprite(EnItem00* this, GlobalContext* globalCtx) { +void EnItem00_DrawSprite(EnItem00* this, PlayState* play) { s32 iconNb = this->actor.params - 3; - OPEN_DISPS(globalCtx->state.gfxCtx); + OPEN_DISPS(play->state.gfxCtx); - POLY_OPA_DISP = func_801660B8(globalCtx, POLY_OPA_DISP); + POLY_OPA_DISP = func_801660B8(play, POLY_OPA_DISP); if (this->actor.params == ITEM00_NUTS_10) { iconNb = 6; @@ -773,50 +775,48 @@ void EnItem00_DrawSprite(EnItem00* this, GlobalContext* globalCtx) { gSPSegment(POLY_OPA_DISP++, 0x08, Lib_SegmentedToVirtual(D_801ADF44[iconNb])); - gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_MODELVIEW | G_MTX_LOAD); + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_MODELVIEW | G_MTX_LOAD); gSPDisplayList(POLY_OPA_DISP++, gameplay_keep_DL_05F6F0); - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->state.gfxCtx); } -void EnItem00_DrawHeartContainer(EnItem00* actor, GlobalContext* globalCtx) { +void EnItem00_DrawHeartContainer(EnItem00* actor, PlayState* play) { s32 pad; s32 pad2; - if (Object_GetIndex(&globalCtx->objectCtx, OBJECT_GI_HEARTS) == actor->actor.objBankIndex) { - OPEN_DISPS(globalCtx->state.gfxCtx); + if (Object_GetIndex(&play->objectCtx, OBJECT_GI_HEARTS) == actor->actor.objBankIndex) { + OPEN_DISPS(play->state.gfxCtx); - func_8012C2DC(globalCtx->state.gfxCtx); + func_8012C2DC(play->state.gfxCtx); Matrix_Scale(20.0f, 20.0f, 20.0f, MTXMODE_APPLY); - gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_MODELVIEW | G_MTX_LOAD); + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_MODELVIEW | G_MTX_LOAD); - gSPDisplayList(POLY_XLU_DISP++, object_gi_hearts_DL_001290); - gSPDisplayList(POLY_XLU_DISP++, object_gi_hearts_DL_001470); + gSPDisplayList(POLY_XLU_DISP++, gGiHeartBorderDL); + gSPDisplayList(POLY_XLU_DISP++, gGiHeartContainerDL); - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->state.gfxCtx); } } -void EnItem00_DrawHeartPiece(EnItem00* this, GlobalContext* globalCtx) { +void EnItem00_DrawHeartPiece(EnItem00* this, PlayState* play) { s32 pad; - OPEN_DISPS(globalCtx->state.gfxCtx); + OPEN_DISPS(play->state.gfxCtx); - func_8012C2DC(globalCtx->state.gfxCtx); - func_800B8118(&this->actor, globalCtx, 0); + func_8012C2DC(play->state.gfxCtx); + func_800B8118(&this->actor, play, 0); - gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_MODELVIEW | G_MTX_LOAD); + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_MODELVIEW | G_MTX_LOAD); gSPDisplayList(POLY_XLU_DISP++, gameplay_keep_DL_05AAB0); - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->state.gfxCtx); } 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) || @@ -827,9 +827,8 @@ s16 func_800A7650(s16 dropId) { return ITEM00_NO_DROP; } - if (dropId == ITEM00_HEART) { - healthCapacity = gSaveContext.save.playerData.healthCapacity; - if (healthCapacity == gSaveContext.save.playerData.health) { + if (dropId == ITEM00_RECOVERY_HEART) { + if (((void)0, gSaveContext.save.playerData.healthCapacity) == ((void)0, gSaveContext.save.playerData.health)) { return ITEM00_RUPEE_GREEN; } } @@ -837,7 +836,7 @@ s16 func_800A7650(s16 dropId) { return dropId; } -Actor* Item_DropCollectible(GlobalContext* globalCtx, Vec3f* spawnPos, u32 params) { +Actor* Item_DropCollectible(PlayState* play, Vec3f* spawnPos, u32 params) { s32 pad; Actor* spawnedActor = NULL; s32 newParamFF; @@ -853,29 +852,29 @@ Actor* Item_DropCollectible(GlobalContext* globalCtx, Vec3f* spawnPos, u32 param if (paramFF == ITEM00_3_HEARTS) { for (i = 0; i < 3; i++) { - spawnedActor = Item_DropCollectible(globalCtx, spawnPos, param7F00 | ITEM00_HEART | param8000); + spawnedActor = Item_DropCollectible(play, spawnPos, param7F00 | ITEM00_RECOVERY_HEART | param8000); } } else if (paramFF == ITEM00_MUSHROOM_CLOUD) { param7F00 >>= 8; - if (!Flags_GetCollectible(globalCtx, param7F00)) { - Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_OBJ_KINOKO, spawnPos->x, spawnPos->y, spawnPos->z, 0, 0, - 0, param7F00); + if (!Flags_GetCollectible(play, param7F00)) { + Actor_Spawn(&play->actorCtx, play, ACTOR_OBJ_KINOKO, spawnPos->x, spawnPos->y, spawnPos->z, 0, 0, 0, + param7F00); } } else if (((paramFF == ITEM00_FLEXIBLE) || (newParamFF == ITEM00_BIG_FAIRY)) && (param10000 == 0)) { newParamFF = params & 0xFF; if (newParamFF == ITEM00_FLEXIBLE) { - spawnedActor = Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_ELF, spawnPos->x, spawnPos->y + 40.0f, + spawnedActor = Actor_Spawn(&play->actorCtx, play, ACTOR_EN_ELF, spawnPos->x, spawnPos->y + 40.0f, spawnPos->z, 0, 0, 0, ((((param7F00 >> 8) & 0x7F) << 9) & 0xFE00) | 0x102); - if (!Flags_GetCollectible(globalCtx, (param7F00 >> 8) & 0x7F)) { - SoundSource_PlaySfxAtFixedWorldPos(globalCtx, spawnPos, 40, NA_SE_EV_BUTTERFRY_TO_FAIRY); + if (!Flags_GetCollectible(play, (param7F00 >> 8) & 0x7F)) { + SoundSource_PlaySfxAtFixedWorldPos(play, spawnPos, 40, NA_SE_EV_BUTTERFRY_TO_FAIRY); } } else { spawnedActor = - Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_ELFORG, spawnPos->x, spawnPos->y + 40.0f, - spawnPos->z, 0, 0, 0, ((((param7F00 >> 8) & 0x7F) & 0x7F) << 9) | 7); + Actor_Spawn(&play->actorCtx, play, ACTOR_EN_ELFORG, spawnPos->x, spawnPos->y + 40.0f, spawnPos->z, 0, 0, + 0, STRAY_FAIRY_PARAMS(((param7F00 >> 8) & 0x7F), 0, STRAY_FAIRY_TYPE_COLLECTIBLE)); if (param20000 == 0) { - if (!Flags_GetCollectible(globalCtx, (param7F00 >> 8) & 0x7F)) { - SoundSource_PlaySfxAtFixedWorldPos(globalCtx, spawnPos, 40, NA_SE_EV_BUTTERFRY_TO_FAIRY); + if (!Flags_GetCollectible(play, (param7F00 >> 8) & 0x7F)) { + SoundSource_PlaySfxAtFixedWorldPos(play, spawnPos, 40, NA_SE_EV_BUTTERFRY_TO_FAIRY); } } } @@ -884,8 +883,8 @@ Actor* Item_DropCollectible(GlobalContext* globalCtx, Vec3f* spawnPos, u32 param params = func_800A7650(newParamFF); } if ((s32)params != ITEM00_NO_DROP) { - spawnedActor = Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_ITEM00, spawnPos->x, spawnPos->y, - spawnPos->z, 0, 0, 0, (s32)params | param8000 | param7F00); + spawnedActor = Actor_Spawn(&play->actorCtx, play, ACTOR_EN_ITEM00, spawnPos->x, spawnPos->y, spawnPos->z, 0, + 0, 0, (s32)params | param8000 | param7F00); if ((spawnedActor != NULL) && (param8000 == 0)) { if (param10000 == 0) { spawnedActor->velocity.y = 8.0f; @@ -910,7 +909,7 @@ Actor* Item_DropCollectible(GlobalContext* globalCtx, Vec3f* spawnPos, u32 param return spawnedActor; } -Actor* Item_DropCollectible2(GlobalContext* globalCtx, Vec3f* spawnPos, s32 params) { +Actor* Item_DropCollectible2(PlayState* play, Vec3f* spawnPos, s32 params) { Actor* spawnedActor = NULL; s32 pad; s32 param10000 = params & 0x10000; @@ -925,21 +924,21 @@ Actor* Item_DropCollectible2(GlobalContext* globalCtx, Vec3f* spawnPos, s32 para if ((((params & 0xFF) == ITEM00_FLEXIBLE) || ((params & 0xFF) == ITEM00_BIG_FAIRY)) && (param10000 == 0)) { if ((params & 0xFF) == ITEM00_FLEXIBLE) { - spawnedActor = Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_ELF, spawnPos->x, spawnPos->y + 40.0f, + spawnedActor = Actor_Spawn(&play->actorCtx, play, ACTOR_EN_ELF, spawnPos->x, spawnPos->y + 40.0f, spawnPos->z, 0, 0, 0, ((((param7F00 >> 8) & 0x7F) << 9) & 0xFE00) | 0x102); } else { spawnedActor = - Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_ELFORG, spawnPos->x, spawnPos->y + 40.0f, - spawnPos->z, 0, 0, 0, ((((param7F00 >> 8) & 0x7F) & 0x7F) << 9) | 7); + Actor_Spawn(&play->actorCtx, play, ACTOR_EN_ELFORG, spawnPos->x, spawnPos->y + 40.0f, spawnPos->z, 0, 0, + 0, STRAY_FAIRY_PARAMS(((param7F00 >> 8) & 0x7F), 0, STRAY_FAIRY_TYPE_COLLECTIBLE)); } - if (Flags_GetCollectible(globalCtx, (param7F00 >> 8) & 0x7F) == 0) { - SoundSource_PlaySfxAtFixedWorldPos(globalCtx, spawnPos, 40, NA_SE_EV_BUTTERFRY_TO_FAIRY); + if (Flags_GetCollectible(play, (param7F00 >> 8) & 0x7F) == 0) { + SoundSource_PlaySfxAtFixedWorldPos(play, spawnPos, 40, NA_SE_EV_BUTTERFRY_TO_FAIRY); } } else { params = func_800A7650(params & 0xFF); if (params != ITEM00_NO_DROP) { - spawnedActor = Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_ITEM00, spawnPos->x, spawnPos->y, - spawnPos->z, 0, 0, 0, (s32)params | param8000 | param7F00); + spawnedActor = Actor_Spawn(&play->actorCtx, play, ACTOR_EN_ITEM00, spawnPos->x, spawnPos->y, spawnPos->z, 0, + 0, 0, (s32)params | param8000 | param7F00); if (spawnedActor != NULL) { if (param8000 == 0) { spawnedActor->velocity.y = 0.0f; @@ -960,61 +959,61 @@ Actor* Item_DropCollectible2(GlobalContext* globalCtx, Vec3f* spawnPos, s32 para } u8 sDropTable[DROP_TABLE_SIZE * DROP_TABLE_NUMBER] = { - ITEM00_RUPEE_GREEN, ITEM00_RUPEE_GREEN, ITEM00_RUPEE_BLUE, ITEM00_NO_DROP, ITEM00_NO_DROP, - ITEM00_MASK, ITEM00_MASK, ITEM00_NO_DROP, ITEM00_NO_DROP, ITEM00_BOMBS_A, - ITEM00_MAGIC_SMALL, ITEM00_NO_DROP, ITEM00_NO_DROP, ITEM00_NO_DROP, ITEM00_HEART, - ITEM00_FLEXIBLE, ITEM00_RUPEE_GREEN, ITEM00_NO_DROP, ITEM00_NO_DROP, ITEM00_NO_DROP, - ITEM00_NO_DROP, ITEM00_MASK, ITEM00_MASK, ITEM00_NO_DROP, ITEM00_NO_DROP, - ITEM00_NO_DROP, ITEM00_MAGIC_SMALL, ITEM00_NO_DROP, ITEM00_HEART, ITEM00_HEART, - ITEM00_HEART, ITEM00_FLEXIBLE, ITEM00_RUPEE_GREEN, ITEM00_RUPEE_GREEN, ITEM00_NO_DROP, - ITEM00_NO_DROP, ITEM00_NO_DROP, ITEM00_MASK, ITEM00_MASK, ITEM00_NO_DROP, - ITEM00_NO_DROP, ITEM00_BOMBS_A, ITEM00_MAGIC_SMALL, ITEM00_MAGIC_LARGE, ITEM00_MAGIC_LARGE, - ITEM00_HEART, ITEM00_HEART, ITEM00_FLEXIBLE, ITEM00_RUPEE_GREEN, ITEM00_NO_DROP, - ITEM00_RUPEE_BLUE, ITEM00_RUPEE_RED, ITEM00_NO_DROP, ITEM00_MASK, ITEM00_MASK, - ITEM00_NO_DROP, ITEM00_NO_DROP, ITEM00_BOMBS_A, ITEM00_MAGIC_SMALL, ITEM00_NO_DROP, - ITEM00_NO_DROP, ITEM00_HEART, ITEM00_HEART, ITEM00_FLEXIBLE, ITEM00_MASK, - ITEM00_MASK, ITEM00_MASK, ITEM00_MASK, ITEM00_NO_DROP, ITEM00_NO_DROP, - ITEM00_NO_DROP, ITEM00_NO_DROP, ITEM00_NO_DROP, ITEM00_NO_DROP, ITEM00_NO_DROP, - ITEM00_NO_DROP, ITEM00_NO_DROP, ITEM00_NO_DROP, ITEM00_NO_DROP, ITEM00_NO_DROP, - ITEM00_NO_DROP, ITEM00_NO_DROP, ITEM00_NO_DROP, ITEM00_NO_DROP, ITEM00_NO_DROP, - ITEM00_NO_DROP, ITEM00_NO_DROP, ITEM00_NO_DROP, ITEM00_NO_DROP, ITEM00_NO_DROP, - ITEM00_NO_DROP, ITEM00_NO_DROP, ITEM00_NO_DROP, ITEM00_NO_DROP, ITEM00_NO_DROP, - ITEM00_NO_DROP, ITEM00_NO_DROP, ITEM00_NO_DROP, ITEM00_NO_DROP, ITEM00_NO_DROP, - ITEM00_HEART, ITEM00_HEART, ITEM00_HEART, ITEM00_HEART, ITEM00_HEART, - ITEM00_HEART, ITEM00_HEART, ITEM00_HEART, ITEM00_HEART, ITEM00_HEART, - ITEM00_HEART, ITEM00_FLEXIBLE, ITEM00_HEART, ITEM00_HEART, ITEM00_HEART, - ITEM00_HEART, ITEM00_HEART, ITEM00_HEART, ITEM00_HEART, ITEM00_HEART, - ITEM00_HEART, ITEM00_HEART, ITEM00_HEART, ITEM00_HEART, ITEM00_HEART, - ITEM00_HEART, ITEM00_HEART, ITEM00_HEART, ITEM00_RUPEE_GREEN, ITEM00_RUPEE_GREEN, - ITEM00_RUPEE_GREEN, ITEM00_RUPEE_BLUE, ITEM00_RUPEE_BLUE, ITEM00_NO_DROP, ITEM00_NO_DROP, - ITEM00_NO_DROP, ITEM00_NO_DROP, ITEM00_NO_DROP, ITEM00_NO_DROP, ITEM00_NO_DROP, - ITEM00_NO_DROP, ITEM00_NO_DROP, ITEM00_NO_DROP, ITEM00_NO_DROP, ITEM00_RUPEE_BLUE, - ITEM00_RUPEE_BLUE, ITEM00_RUPEE_BLUE, ITEM00_RUPEE_BLUE, ITEM00_RUPEE_BLUE, ITEM00_RUPEE_BLUE, - ITEM00_RUPEE_BLUE, ITEM00_RUPEE_BLUE, ITEM00_RUPEE_BLUE, ITEM00_RUPEE_RED, ITEM00_RUPEE_RED, - ITEM00_RUPEE_RED, ITEM00_RUPEE_RED, ITEM00_RUPEE_RED, ITEM00_RUPEE_RED, ITEM00_RUPEE_RED, - ITEM00_ARROWS_10, ITEM00_ARROWS_10, ITEM00_ARROWS_10, ITEM00_ARROWS_10, ITEM00_ARROWS_10, - ITEM00_ARROWS_10, ITEM00_ARROWS_10, ITEM00_ARROWS_10, ITEM00_ARROWS_10, ITEM00_ARROWS_10, - ITEM00_ARROWS_30, ITEM00_ARROWS_30, ITEM00_MAGIC_SMALL, ITEM00_MAGIC_SMALL, ITEM00_MAGIC_LARGE, - ITEM00_MAGIC_LARGE, ITEM00_NO_DROP, ITEM00_NO_DROP, ITEM00_NO_DROP, ITEM00_NO_DROP, - ITEM00_NO_DROP, ITEM00_NO_DROP, ITEM00_NO_DROP, ITEM00_BOMBS_A, ITEM00_BOMBS_A, - ITEM00_BOMBS_A, ITEM00_BOMBS_A, ITEM00_BOMBS_A, ITEM00_BOMBS_A, ITEM00_BOMBS_A, - ITEM00_BOMBS_A, ITEM00_BOMBS_A, ITEM00_NO_DROP, ITEM00_NO_DROP, ITEM00_NO_DROP, - ITEM00_NO_DROP, ITEM00_NO_DROP, ITEM00_NO_DROP, ITEM00_NO_DROP, ITEM00_NO_DROP, - ITEM00_MAGIC_SMALL, ITEM00_MAGIC_SMALL, ITEM00_MAGIC_SMALL, ITEM00_MAGIC_SMALL, ITEM00_MAGIC_SMALL, - ITEM00_MAGIC_SMALL, ITEM00_MAGIC_LARGE, ITEM00_MAGIC_LARGE, ITEM00_MAGIC_SMALL, ITEM00_MAGIC_SMALL, - ITEM00_MAGIC_SMALL, ITEM00_MAGIC_SMALL, ITEM00_MAGIC_SMALL, ITEM00_MAGIC_SMALL, ITEM00_MAGIC_SMALL, - ITEM00_MAGIC_SMALL, ITEM00_MAGIC_SMALL, ITEM00_MAGIC_SMALL, ITEM00_MAGIC_LARGE, ITEM00_MAGIC_LARGE, - ITEM00_MAGIC_LARGE, ITEM00_MAGIC_LARGE, ITEM00_MAGIC_LARGE, ITEM00_MAGIC_LARGE, ITEM00_NO_DROP, - ITEM00_NO_DROP, ITEM00_NO_DROP, ITEM00_NO_DROP, ITEM00_NUTS_1, ITEM00_NUTS_1, - ITEM00_NO_DROP, ITEM00_ARROWS_10, ITEM00_ARROWS_10, ITEM00_ARROWS_10, ITEM00_STICK, - ITEM00_STICK, ITEM00_NO_DROP, ITEM00_HEART, ITEM00_HEART, ITEM00_FLEXIBLE, - ITEM00_RUPEE_GREEN, ITEM00_RUPEE_BLUE, ITEM00_RUPEE_BLUE, ITEM00_RUPEE_RED, ITEM00_NO_DROP, - ITEM00_ARROWS_10, ITEM00_ARROWS_10, ITEM00_ARROWS_30, ITEM00_BOMBS_A, ITEM00_NO_DROP, - ITEM00_STICK, ITEM00_MAGIC_SMALL, ITEM00_MAGIC_LARGE, ITEM00_HEART, ITEM00_HEART, - ITEM00_FLEXIBLE, ITEM00_RUPEE_GREEN, ITEM00_HEART, ITEM00_HEART, ITEM00_MAGIC_SMALL, - ITEM00_MASK, ITEM00_NO_DROP, ITEM00_NO_DROP, ITEM00_NO_DROP, ITEM00_NO_DROP, - ITEM00_NO_DROP, ITEM00_NO_DROP, ITEM00_NO_DROP, ITEM00_NO_DROP, ITEM00_NO_DROP, - ITEM00_NO_DROP, ITEM00_NO_DROP, + ITEM00_RUPEE_GREEN, ITEM00_RUPEE_GREEN, ITEM00_RUPEE_BLUE, ITEM00_NO_DROP, ITEM00_NO_DROP, + ITEM00_MASK, ITEM00_MASK, ITEM00_NO_DROP, ITEM00_NO_DROP, ITEM00_BOMBS_A, + ITEM00_MAGIC_SMALL, ITEM00_NO_DROP, ITEM00_NO_DROP, ITEM00_NO_DROP, ITEM00_RECOVERY_HEART, + ITEM00_FLEXIBLE, ITEM00_RUPEE_GREEN, ITEM00_NO_DROP, ITEM00_NO_DROP, ITEM00_NO_DROP, + ITEM00_NO_DROP, ITEM00_MASK, ITEM00_MASK, ITEM00_NO_DROP, ITEM00_NO_DROP, + ITEM00_NO_DROP, ITEM00_MAGIC_SMALL, ITEM00_NO_DROP, ITEM00_RECOVERY_HEART, ITEM00_RECOVERY_HEART, + ITEM00_RECOVERY_HEART, ITEM00_FLEXIBLE, ITEM00_RUPEE_GREEN, ITEM00_RUPEE_GREEN, ITEM00_NO_DROP, + ITEM00_NO_DROP, ITEM00_NO_DROP, ITEM00_MASK, ITEM00_MASK, ITEM00_NO_DROP, + ITEM00_NO_DROP, ITEM00_BOMBS_A, ITEM00_MAGIC_SMALL, ITEM00_MAGIC_LARGE, ITEM00_MAGIC_LARGE, + ITEM00_RECOVERY_HEART, ITEM00_RECOVERY_HEART, ITEM00_FLEXIBLE, ITEM00_RUPEE_GREEN, ITEM00_NO_DROP, + ITEM00_RUPEE_BLUE, ITEM00_RUPEE_RED, ITEM00_NO_DROP, ITEM00_MASK, ITEM00_MASK, + ITEM00_NO_DROP, ITEM00_NO_DROP, ITEM00_BOMBS_A, ITEM00_MAGIC_SMALL, ITEM00_NO_DROP, + ITEM00_NO_DROP, ITEM00_RECOVERY_HEART, ITEM00_RECOVERY_HEART, ITEM00_FLEXIBLE, ITEM00_MASK, + ITEM00_MASK, ITEM00_MASK, ITEM00_MASK, ITEM00_NO_DROP, ITEM00_NO_DROP, + ITEM00_NO_DROP, ITEM00_NO_DROP, ITEM00_NO_DROP, ITEM00_NO_DROP, ITEM00_NO_DROP, + ITEM00_NO_DROP, ITEM00_NO_DROP, ITEM00_NO_DROP, ITEM00_NO_DROP, ITEM00_NO_DROP, + ITEM00_NO_DROP, ITEM00_NO_DROP, ITEM00_NO_DROP, ITEM00_NO_DROP, ITEM00_NO_DROP, + ITEM00_NO_DROP, ITEM00_NO_DROP, ITEM00_NO_DROP, ITEM00_NO_DROP, ITEM00_NO_DROP, + ITEM00_NO_DROP, ITEM00_NO_DROP, ITEM00_NO_DROP, ITEM00_NO_DROP, ITEM00_NO_DROP, + ITEM00_NO_DROP, ITEM00_NO_DROP, ITEM00_NO_DROP, ITEM00_NO_DROP, ITEM00_NO_DROP, + ITEM00_RECOVERY_HEART, ITEM00_RECOVERY_HEART, ITEM00_RECOVERY_HEART, ITEM00_RECOVERY_HEART, ITEM00_RECOVERY_HEART, + ITEM00_RECOVERY_HEART, ITEM00_RECOVERY_HEART, ITEM00_RECOVERY_HEART, ITEM00_RECOVERY_HEART, ITEM00_RECOVERY_HEART, + ITEM00_RECOVERY_HEART, ITEM00_FLEXIBLE, ITEM00_RECOVERY_HEART, ITEM00_RECOVERY_HEART, ITEM00_RECOVERY_HEART, + ITEM00_RECOVERY_HEART, ITEM00_RECOVERY_HEART, ITEM00_RECOVERY_HEART, ITEM00_RECOVERY_HEART, ITEM00_RECOVERY_HEART, + ITEM00_RECOVERY_HEART, ITEM00_RECOVERY_HEART, ITEM00_RECOVERY_HEART, ITEM00_RECOVERY_HEART, ITEM00_RECOVERY_HEART, + ITEM00_RECOVERY_HEART, ITEM00_RECOVERY_HEART, ITEM00_RECOVERY_HEART, ITEM00_RUPEE_GREEN, ITEM00_RUPEE_GREEN, + ITEM00_RUPEE_GREEN, ITEM00_RUPEE_BLUE, ITEM00_RUPEE_BLUE, ITEM00_NO_DROP, ITEM00_NO_DROP, + ITEM00_NO_DROP, ITEM00_NO_DROP, ITEM00_NO_DROP, ITEM00_NO_DROP, ITEM00_NO_DROP, + ITEM00_NO_DROP, ITEM00_NO_DROP, ITEM00_NO_DROP, ITEM00_NO_DROP, ITEM00_RUPEE_BLUE, + ITEM00_RUPEE_BLUE, ITEM00_RUPEE_BLUE, ITEM00_RUPEE_BLUE, ITEM00_RUPEE_BLUE, ITEM00_RUPEE_BLUE, + ITEM00_RUPEE_BLUE, ITEM00_RUPEE_BLUE, ITEM00_RUPEE_BLUE, ITEM00_RUPEE_RED, ITEM00_RUPEE_RED, + ITEM00_RUPEE_RED, ITEM00_RUPEE_RED, ITEM00_RUPEE_RED, ITEM00_RUPEE_RED, ITEM00_RUPEE_RED, + ITEM00_ARROWS_10, ITEM00_ARROWS_10, ITEM00_ARROWS_10, ITEM00_ARROWS_10, ITEM00_ARROWS_10, + ITEM00_ARROWS_10, ITEM00_ARROWS_10, ITEM00_ARROWS_10, ITEM00_ARROWS_10, ITEM00_ARROWS_10, + ITEM00_ARROWS_30, ITEM00_ARROWS_30, ITEM00_MAGIC_SMALL, ITEM00_MAGIC_SMALL, ITEM00_MAGIC_LARGE, + ITEM00_MAGIC_LARGE, ITEM00_NO_DROP, ITEM00_NO_DROP, ITEM00_NO_DROP, ITEM00_NO_DROP, + ITEM00_NO_DROP, ITEM00_NO_DROP, ITEM00_NO_DROP, ITEM00_BOMBS_A, ITEM00_BOMBS_A, + ITEM00_BOMBS_A, ITEM00_BOMBS_A, ITEM00_BOMBS_A, ITEM00_BOMBS_A, ITEM00_BOMBS_A, + ITEM00_BOMBS_A, ITEM00_BOMBS_A, ITEM00_NO_DROP, ITEM00_NO_DROP, ITEM00_NO_DROP, + ITEM00_NO_DROP, ITEM00_NO_DROP, ITEM00_NO_DROP, ITEM00_NO_DROP, ITEM00_NO_DROP, + ITEM00_MAGIC_SMALL, ITEM00_MAGIC_SMALL, ITEM00_MAGIC_SMALL, ITEM00_MAGIC_SMALL, ITEM00_MAGIC_SMALL, + ITEM00_MAGIC_SMALL, ITEM00_MAGIC_LARGE, ITEM00_MAGIC_LARGE, ITEM00_MAGIC_SMALL, ITEM00_MAGIC_SMALL, + ITEM00_MAGIC_SMALL, ITEM00_MAGIC_SMALL, ITEM00_MAGIC_SMALL, ITEM00_MAGIC_SMALL, ITEM00_MAGIC_SMALL, + ITEM00_MAGIC_SMALL, ITEM00_MAGIC_SMALL, ITEM00_MAGIC_SMALL, ITEM00_MAGIC_LARGE, ITEM00_MAGIC_LARGE, + ITEM00_MAGIC_LARGE, ITEM00_MAGIC_LARGE, ITEM00_MAGIC_LARGE, ITEM00_MAGIC_LARGE, ITEM00_NO_DROP, + ITEM00_NO_DROP, ITEM00_NO_DROP, ITEM00_NO_DROP, ITEM00_NUTS_1, ITEM00_NUTS_1, + ITEM00_NO_DROP, ITEM00_ARROWS_10, ITEM00_ARROWS_10, ITEM00_ARROWS_10, ITEM00_STICK, + ITEM00_STICK, ITEM00_NO_DROP, ITEM00_RECOVERY_HEART, ITEM00_RECOVERY_HEART, ITEM00_FLEXIBLE, + ITEM00_RUPEE_GREEN, ITEM00_RUPEE_BLUE, ITEM00_RUPEE_BLUE, ITEM00_RUPEE_RED, ITEM00_NO_DROP, + ITEM00_ARROWS_10, ITEM00_ARROWS_10, ITEM00_ARROWS_30, ITEM00_BOMBS_A, ITEM00_NO_DROP, + ITEM00_STICK, ITEM00_MAGIC_SMALL, ITEM00_MAGIC_LARGE, ITEM00_RECOVERY_HEART, ITEM00_RECOVERY_HEART, + ITEM00_FLEXIBLE, ITEM00_RUPEE_GREEN, ITEM00_RECOVERY_HEART, ITEM00_RECOVERY_HEART, ITEM00_MAGIC_SMALL, + ITEM00_MASK, ITEM00_NO_DROP, ITEM00_NO_DROP, ITEM00_NO_DROP, ITEM00_NO_DROP, + ITEM00_NO_DROP, ITEM00_NO_DROP, ITEM00_NO_DROP, ITEM00_NO_DROP, ITEM00_NO_DROP, + ITEM00_NO_DROP, ITEM00_NO_DROP, }; u8 sDropTableAmounts[DROP_TABLE_SIZE * DROP_TABLE_NUMBER] = { @@ -1035,7 +1034,7 @@ u8 sDropTableAmounts[DROP_TABLE_SIZE * DROP_TABLE_NUMBER] = { 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, }; -void Item_DropCollectibleRandom(GlobalContext* globalCtx, Actor* fromActor, Vec3f* spawnPos, s16 params) { +void Item_DropCollectibleRandom(PlayState* play, Actor* fromActor, Vec3f* spawnPos, s16 params) { EnItem00* spawnedActor; u8 dropId; s32 dropQuantity; @@ -1055,7 +1054,7 @@ void Item_DropCollectibleRandom(GlobalContext* globalCtx, Actor* fromActor, Vec3 dropId = ITEM00_ARROWS_10; break; case PLAYER_FORM_ZORA: - dropId = ITEM00_HEART; + dropId = ITEM00_RECOVERY_HEART; break; case PLAYER_FORM_GORON: dropId = ITEM00_MAGIC_SMALL; @@ -1076,7 +1075,7 @@ void Item_DropCollectibleRandom(GlobalContext* globalCtx, Actor* fromActor, Vec3 dropQuantity = 1; } else if (fromActor->dropFlag & 2) { params = 0x10; - dropId = ITEM00_HEART; + dropId = ITEM00_RECOVERY_HEART; dropQuantity = 1; } else if (fromActor->dropFlag & 0x20) { dropId = ITEM00_RUPEE_PURPLE; @@ -1087,19 +1086,19 @@ void Item_DropCollectibleRandom(GlobalContext* globalCtx, Actor* fromActor, Vec3 if (dropId == ITEM00_FLEXIBLE) { 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); + Actor_Spawn(&play->actorCtx, play, ACTOR_EN_ELF, spawnPos->x, spawnPos->y + 40.0f, spawnPos->z, 0, 0, 0, + 2); + SoundSource_PlaySfxAtFixedWorldPos(play, spawnPos, 40, NA_SE_EV_BUTTERFRY_TO_FAIRY); return; } if (gSaveContext.save.playerData.health <= 0x30) { params = 0x10; - dropId = ITEM00_HEART; + dropId = ITEM00_RECOVERY_HEART; dropQuantity = 3; } else if (gSaveContext.save.playerData.health <= 0x50) { params = 0x10; - dropId = ITEM00_HEART; + dropId = ITEM00_RECOVERY_HEART; dropQuantity = 1; } else if ((gSaveContext.save.playerData.magicLevel != 0) && (gSaveContext.save.playerData.magic == 0)) { params = 0xD0; @@ -1132,8 +1131,8 @@ void Item_DropCollectibleRandom(GlobalContext* globalCtx, Actor* fromActor, Vec3 if (param8000 == 0) { dropId = func_800A7650(dropId); if (dropId != (u8)ITEM00_NO_DROP) { - spawnedActor = (EnItem00*)Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_ITEM00, - spawnPos->x, spawnPos->y, spawnPos->z, 0, 0, 0, dropId); + spawnedActor = (EnItem00*)Actor_Spawn(&play->actorCtx, play, ACTOR_EN_ITEM00, spawnPos->x, + spawnPos->y, spawnPos->z, 0, 0, 0, dropId); if ((spawnedActor != 0) && (dropId != (u8)ITEM00_NO_DROP)) { spawnedActor->actor.velocity.y = 8.0f; spawnedActor->actor.speedXZ = 2.0f; @@ -1151,7 +1150,7 @@ void Item_DropCollectibleRandom(GlobalContext* globalCtx, Actor* fromActor, Vec3 } } } else { - Item_DropCollectible(globalCtx, spawnPos, params | 0x8000); + Item_DropCollectible(play, spawnPos, params | 0x8000); } dropQuantity--; @@ -1161,13 +1160,13 @@ void Item_DropCollectibleRandom(GlobalContext* globalCtx, Actor* fromActor, Vec3 } s32 D_801AE194[32] = { - ITEM00_NO_DROP, ITEM00_RUPEE_GREEN, ITEM00_RUPEE_BLUE, ITEM00_NO_DROP, ITEM00_RUPEE_RED, - ITEM00_RUPEE_PURPLE, ITEM00_NO_DROP, ITEM00_RUPEE_HUGE, ITEM00_COMPASS, ITEM00_MUSHROOM_CLOUD, - ITEM00_HEART, ITEM00_3_HEARTS, ITEM00_HEART_PIECE, ITEM00_HEART_CONTAINER, ITEM00_MAGIC_SMALL, - ITEM00_MAGIC_LARGE, ITEM00_FLEXIBLE, ITEM00_BIG_FAIRY, ITEM00_NO_DROP, ITEM00_NUTS_10, - ITEM00_NO_DROP, ITEM00_BOMBS_A, ITEM00_NO_DROP, ITEM00_NO_DROP, ITEM00_NO_DROP, - ITEM00_STICK, ITEM00_NO_DROP, ITEM00_NO_DROP, ITEM00_NO_DROP, ITEM00_NO_DROP, - ITEM00_ARROWS_10, ITEM00_ARROWS_30, + ITEM00_NO_DROP, ITEM00_RUPEE_GREEN, ITEM00_RUPEE_BLUE, ITEM00_NO_DROP, ITEM00_RUPEE_RED, + ITEM00_RUPEE_PURPLE, ITEM00_NO_DROP, ITEM00_RUPEE_HUGE, ITEM00_COMPASS, ITEM00_MUSHROOM_CLOUD, + ITEM00_RECOVERY_HEART, ITEM00_3_HEARTS, ITEM00_HEART_PIECE, ITEM00_HEART_CONTAINER, ITEM00_MAGIC_SMALL, + ITEM00_MAGIC_LARGE, ITEM00_FLEXIBLE, ITEM00_BIG_FAIRY, ITEM00_NO_DROP, ITEM00_NUTS_10, + ITEM00_NO_DROP, ITEM00_BOMBS_A, ITEM00_NO_DROP, ITEM00_NO_DROP, ITEM00_NO_DROP, + ITEM00_STICK, ITEM00_NO_DROP, ITEM00_NO_DROP, ITEM00_NO_DROP, ITEM00_NO_DROP, + ITEM00_ARROWS_10, ITEM00_ARROWS_30, }; s32 func_800A8150(s32 index) { @@ -1188,6 +1187,6 @@ s32 func_800A817C(s32 index) { return D_801AE214[index]; } -s32 func_800A81A4(GlobalContext* globalCtx, s32 a1, s32 a2) { - return (func_800A8150(a1) == ITEM00_BIG_FAIRY) && (!Flags_GetCollectible(globalCtx, a2)); +s32 Item_CanDropBigFairy(PlayState* play, s32 index, s32 collectibleFlag) { + return (func_800A8150(index) == ITEM00_BIG_FAIRY) && (!Flags_GetCollectible(play, collectibleFlag)); } diff --git a/src/code/z_env_flags.c b/src/code/z_env_flags.c index d76681512..06e216cd3 100644 --- a/src/code/z_env_flags.c +++ b/src/code/z_env_flags.c @@ -1,33 +1,33 @@ #include "global.h" -void EnvFlags_UnsetAll(GlobalContext* globalCtx) { +void EnvFlags_UnsetAll(PlayState* play) { u8 i; - for (i = 0; i < ARRAY_COUNT(globalCtx->envFlags); i++) { - globalCtx->envFlags[i] = 0; + for (i = 0; i < ARRAY_COUNT(play->envFlags); i++) { + play->envFlags[i] = 0; } } -void EnvFlags_Set(GlobalContext* globalCtx, s16 flag) { +void EnvFlags_Set(PlayState* play, s16 flag) { s16 index = flag / 16; s16 bit = flag % 16; s16 mask = 1 << bit; - globalCtx->envFlags[index] |= mask; + play->envFlags[index] |= mask; } -void EnvFlags_Unset(GlobalContext* globalCtx, s16 flag) { +void EnvFlags_Unset(PlayState* play, s16 flag) { s16 index = flag / 16; s16 bit = flag % 16; s16 mask = (1 << bit) ^ 0xFFFF; - globalCtx->envFlags[index] &= mask; + play->envFlags[index] &= mask; } -s32 EnvFlags_Get(GlobalContext* globalCtx, s16 flag) { +s32 EnvFlags_Get(PlayState* play, s16 flag) { s16 index = flag / 16; s16 bit = flag % 16; s16 mask = 1 << bit; - return globalCtx->envFlags[index] & mask; + return play->envFlags[index] & mask; } diff --git a/src/code/z_eventmgr.c b/src/code/z_eventmgr.c index 1c61431b9..7128368ac 100644 --- a/src/code/z_eventmgr.c +++ b/src/code/z_eventmgr.c @@ -42,7 +42,7 @@ #pragma GLOBAL_ASM("asm/non_matchings/code/z_eventmgr/func_800F2178.s") -#pragma GLOBAL_ASM("asm/non_matchings/code/z_eventmgr/ActorCutscene_GetCurrentCamera.s") +#pragma GLOBAL_ASM("asm/non_matchings/code/z_eventmgr/ActorCutscene_GetCurrentSubCamId.s") #pragma GLOBAL_ASM("asm/non_matchings/code/z_eventmgr/func_800F21CC.s") diff --git a/src/code/z_face_reaction.c b/src/code/z_face_reaction.c index d54561fdd..e6d985d65 100644 --- a/src/code/z_face_reaction.c +++ b/src/code/z_face_reaction.c @@ -178,9 +178,9 @@ static u16 sReactionTextIds[][PLAYER_MASK_GIANT - 1] = { }; // clang-format on -u16 Text_GetFaceReaction(GlobalContext* globalCtx, u32 reactionSet) { - if ((Player_GetMask(globalCtx) > PLAYER_MASK_NONE) && (Player_GetMask(globalCtx) < PLAYER_MASK_GIANT)) { - return sReactionTextIds[reactionSet][Player_GetMask(globalCtx) - 1]; +u16 Text_GetFaceReaction(PlayState* play, u32 reactionSet) { + if ((Player_GetMask(play) > PLAYER_MASK_NONE) && (Player_GetMask(play) < PLAYER_MASK_GIANT)) { + return sReactionTextIds[reactionSet][Player_GetMask(play) - 1]; } return 0; } 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 e22b5f351..669e01348 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(PlayState* play, SkelCurve* skelCurve, CurveSkeletonHeader* skeletonHeaderSeg, + CurveAnimationHeader* animation) { SkelCurveLimb** limbs; - SkelCurveLimbList* limbList = Lib_SegmentedToVirtual(limbListSeg); + CurveSkeletonHeader* skeletonHeader = Lib_SegmentedToVirtual(skeletonHeaderSeg); - skelCurve->limbCount = limbList->limbCount; - skelCurve->limbList = 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(PlayState* play, 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(PlayState* play, 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)play->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, - OverrideCurveLimbDraw overrideLimbDraw, PostCurveLimbDraw postLimbDraw, s32 lod, Actor* thisx) { - SkelCurveLimb* limb = Lib_SegmentedToVirtual(skelCurve->limbList[limbIndex]); +/** + * Recursively draws limbs with appropriate properties. + */ +void SkelCurve_DrawLimb(PlayState* play, s32 limbIndex, SkelCurve* skelCurve, OverrideCurveLimbDraw overrideLimbDraw, + PostCurveLimbDraw postLimbDraw, s32 lod, Actor* thisx) { + SkelCurveLimb* limb = Lib_SegmentedToVirtual(skelCurve->skeleton[limbIndex]); - OPEN_DISPS(globalCtx->state.gfxCtx); + OPEN_DISPS(play->state.gfxCtx); - Matrix_StatePush(); + Matrix_Push(); - if (overrideLimbDraw == NULL || - (overrideLimbDraw != NULL && overrideLimbDraw(globalCtx, skelCurve, limbIndex, thisx))) { + if ((overrideLimbDraw == NULL) || + ((overrideLimbDraw != NULL) && overrideLimbDraw(play, 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) { @@ -134,7 +191,7 @@ void SkelCurve_DrawLimb(GlobalContext* globalCtx, s32 limbIndex, SkelAnimeCurve* dList = limb->dList[0]; if (dList != NULL) { - gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_LOAD | G_MTX_NOPUSH | G_MTX_MODELVIEW); gSPDisplayList(POLY_OPA_DISP++, dList); } @@ -143,13 +200,13 @@ void SkelCurve_DrawLimb(GlobalContext* globalCtx, s32 limbIndex, SkelAnimeCurve* dList = limb->dList[0]; if (dList != NULL) { - gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_LOAD | G_MTX_NOPUSH | G_MTX_MODELVIEW); gSPDisplayList(POLY_OPA_DISP++, dList); } dList = limb->dList[1]; if (dList != NULL) { - gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_LOAD | G_MTX_NOPUSH | G_MTX_MODELVIEW); gSPDisplayList(POLY_XLU_DISP++, dList); } @@ -157,25 +214,25 @@ void SkelCurve_DrawLimb(GlobalContext* globalCtx, s32 limbIndex, SkelAnimeCurve* } if (postLimbDraw != NULL) { - postLimbDraw(globalCtx, skelCurve, limbIndex, thisx); + postLimbDraw(play, 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(play, 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(play, limb->sibling, skelCurve, overrideLimbDraw, postLimbDraw, lod, thisx); } - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->state.gfxCtx); } -void SkelCurve_Draw(Actor* actor, GlobalContext* globalCtx, SkelAnimeCurve* skelCurve, - OverrideCurveLimbDraw overrideLimbDraw, PostCurveLimbDraw postLimbDraw, s32 lod, Actor* thisx) { - if (skelCurve->transforms != NULL) { - SkelCurve_DrawLimb(globalCtx, 0, skelCurve, overrideLimbDraw, postLimbDraw, lod, thisx); +void SkelCurve_Draw(Actor* actor, PlayState* play, SkelCurve* skelCurve, OverrideCurveLimbDraw overrideLimbDraw, + PostCurveLimbDraw postLimbDraw, s32 lod, Actor* thisx) { + if (skelCurve->jointTable != NULL) { + SkelCurve_DrawLimb(play, 0, skelCurve, overrideLimbDraw, postLimbDraw, lod, thisx); } } diff --git a/src/code/z_fireobj.c b/src/code/z_fireobj.c index 379ebda1d..d0b88b3db 100644 --- a/src/code/z_fireobj.c +++ b/src/code/z_fireobj.c @@ -37,7 +37,7 @@ FireObjLightParams sFireObjLightParams[] = { { 200, { 128, 128, 0 }, { 127, 127, 0 } }, }; -void FireObj_InitWithParams(GlobalContext* globalCtx, FireObj* fire, FireObjInitParams* init) { +void FireObj_InitWithParams(PlayState* play, FireObj* fire, FireObjInitParams* init) { fire->size = init->size; fire->sizeInv = 1.0f / init->size; fire->dynamicSizeStep = init->dynamicSizeStep; @@ -92,8 +92,8 @@ void FireObj_StepSize(FireObj* fire) { fire->xScale = fire->dynamicSize * fire->size; } -void FireObj_UpdateStateTransitions(GlobalContext* globalCtx, FireObj* fire) { - Player* player = GET_PLAYER(globalCtx); +void FireObj_UpdateStateTransitions(PlayState* play, FireObj* fire) { + Player* player = GET_PLAYER(play); WaterBox* waterBox; f32 waterY; s32 sp40 = false; @@ -114,12 +114,12 @@ void FireObj_UpdateStateTransitions(GlobalContext* globalCtx, FireObj* fire) { FireObj_SetState(fire, fire->dynamicSizeStep, nextState); } if ((fire->flags & 1) && (fire->state != FIRE_STATE_3) && - WaterBox_GetSurface1_2(globalCtx, &globalCtx->colCtx, fire->position.x, fire->position.z, &waterY, &waterBox) && + WaterBox_GetSurface1_2(play, &play->colCtx, fire->position.x, fire->position.z, &waterY, &waterBox) && (waterY - fire->position.y > 6500.0f * fire->yScale)) { FireObj_SetState(fire, fire->dynamicSizeStep, FIRE_STATE_3); } if ((fire->flags & 2) && (player->itemActionParam == PLAYER_AP_STICK)) { - Math_Vec3f_Diff(&player->swordInfo[0].tip, &fire->position, &dist); + Math_Vec3f_Diff(&player->meleeWeaponInfo[0].tip, &fire->position, &dist); if (Math3D_LengthSquared(&dist) < 400.0f) { sp40 = true; } @@ -131,25 +131,24 @@ void FireObj_UpdateStateTransitions(GlobalContext* globalCtx, FireObj* fire) { } } else if (player->unk_B28 == 0) { player->unk_B28 = 0xD2; - SoundSource_PlaySfxAtFixedWorldPos(globalCtx, &fire->position, 20, NA_SE_EV_FLAME_IGNITION); + SoundSource_PlaySfxAtFixedWorldPos(play, &fire->position, 20, NA_SE_EV_FLAME_IGNITION); } else if (player->unk_B28 < 0xC8) { player->unk_B28 = 0xC8; } } } -void FireObj_Draw(GlobalContext* globalCtx, FireObj* fire) { +void FireObj_Draw(PlayState* play, FireObj* fire) { s32 pad; FireObjColors* fireColors = &sFireObjColors[fire->colorsIndex]; if (fire->state != FIRE_STATE_3) { Vec3s vec; - OPEN_DISPS(globalCtx->state.gfxCtx); - func_8012C2DC(globalCtx->state.gfxCtx); - gSPSegment( - POLY_XLU_DISP++, 0x08, - Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, 0, 0, 32, 64, 1, 0, (fire->unk26 * -20) & 511, 32, 128)); + OPEN_DISPS(play->state.gfxCtx); + func_8012C2DC(play->state.gfxCtx); + gSPSegment(POLY_XLU_DISP++, 0x08, + Gfx_TwoTexScroll(play->state.gfxCtx, 0, 0, 0, 32, 64, 1, 0, (fire->unk26 * -20) & 511, 32, 128)); gDPSetPrimColor(POLY_XLU_DISP++, 0, fireColors->lod, fireColors->primColor.r, fireColors->primColor.g, fireColors->primColor.b, fireColors->primColor.a); @@ -157,38 +156,39 @@ void FireObj_Draw(GlobalContext* globalCtx, FireObj* fire) { gDPSetEnvColor(POLY_XLU_DISP++, fireColors->envColor.r, fireColors->envColor.g, fireColors->envColor.b, 0); vec.x = 0; - vec.y = Camera_GetCamDirYaw(GET_ACTIVE_CAM(globalCtx)) + 0x8000; + vec.y = Camera_GetCamDirYaw(GET_ACTIVE_CAM(play)) + 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); - gSPDisplayList(POLY_XLU_DISP++, gGameplayKeepDrawFlameDL); - CLOSE_DISPS(globalCtx->state.gfxCtx); + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_XLU_DISP++, gEffFire1DL); + + CLOSE_DISPS(play->state.gfxCtx); } } -void FireObj_InitLight(GlobalContext* globalCtx, FireObjLight* light, u8* paramsIndex, Vec3f* pos) { +void FireObj_InitLight(PlayState* play, FireObjLight* light, u8* paramsIndex, Vec3f* pos) { FireObjLightParams* objectParams = &sFireObjLightParams[*paramsIndex]; 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->light = LightContext_InsertLight(play, &play->lightCtx, &light->lightInfo); light->lightParamsIndex = *paramsIndex; } -void FireObj_DestroyLight(GlobalContext* globalCtx, FireObjLight* light) { - LightContext_RemoveLight(globalCtx, &globalCtx->lightCtx, light->light); +void FireObj_DestroyLight(PlayState* play, FireObjLight* light) { + LightContext_RemoveLight(play, &play->lightCtx, light->light); } -void FireObj_UpdateLight(GlobalContext* globalCtx, FireObjLight* light, FireObj* fire) { +void FireObj_UpdateLight(PlayState* play, FireObjLight* light, FireObj* fire) { FireObjLightParams* lightParams = &sFireObjLightParams[light->lightParamsIndex]; s16 radius; if (fire->state == FIRE_STATE_3) { Lights_PointSetColorAndRadius(&light->lightInfo, 0, 0, 0, -1); } else { - radius = ((fire->yScale * 140.0f * fire->sizeInv) + 60.0f); + radius = (fire->yScale * 140.0f * fire->sizeInv) + 60.0f; Lights_PointGlowSetInfo(&light->lightInfo, fire->position.x, (fire->position.y + (fire->yScale * 6500.0f)), fire->position.z, @@ -198,33 +198,33 @@ void FireObj_UpdateLight(GlobalContext* globalCtx, FireObjLight* light, FireObj* } } -void FireObj_Init(GlobalContext* globalCtx, FireObj* fire, FireObjInitParams* init, Actor* actor) { +void FireObj_Init(PlayState* play, FireObj* fire, FireObjInitParams* init, Actor* actor) { FireObj* fire2 = fire; - FireObj_InitWithParams(globalCtx, fire, init); - Collider_InitCylinder(globalCtx, &fire->collision); - Collider_SetCylinder(globalCtx, &fire->collision, actor, &sFireObjCollisionInit); + FireObj_InitWithParams(play, fire, init); + Collider_InitCylinder(play, &fire->collision); + Collider_SetCylinder(play, &fire->collision, actor, &sFireObjCollisionInit); 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->lightParamsIndex, &fire->position); + FireObj_InitLight(play, &fire->light, &init->lightParamsIndex, &fire->position); } -void FireObj_Destroy(GlobalContext* globalCtx, FireObj* fire) { - Collider_DestroyCylinder(globalCtx, &fire->collision); - FireObj_DestroyLight(globalCtx, &fire->light); +void FireObj_Destroy(PlayState* play, FireObj* fire) { + Collider_DestroyCylinder(play, &fire->collision); + FireObj_DestroyLight(play, &fire->light); } void FireObj_SetState2(FireObj* fire, f32 dynamicSizeStep, u8 newState) { FireObj_SetState(fire, dynamicSizeStep, newState); } -void FireObj_Update(GlobalContext* globalCtx, FireObj* fire, Actor* actor) { +void FireObj_Update(PlayState* play, FireObj* fire, Actor* actor) { s32 pad; // Gamestate cast? EnArrow* arrow = (EnArrow*)fire->collision.base.ac; - FireObj_UpdateStateTransitions(globalCtx, fire); + FireObj_UpdateStateTransitions(play, fire); if (fire->state == FIRE_STATE_3) { if ((fire->collision.base.acFlags & AC_HIT) && (fire->collision.info.acHitInfo->toucher.dmgFlags & 0x800)) { FireObj_SetState(fire, fire->dynamicSizeStep, FIRE_STATE_0); @@ -237,6 +237,6 @@ void FireObj_Update(GlobalContext* globalCtx, FireObj* fire, Actor* actor) { fire->collision.dim.pos.x = fire->position.x; fire->collision.dim.pos.y = fire->position.y; fire->collision.dim.pos.z = fire->position.z; - CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &fire->collision.base); - FireObj_UpdateLight(globalCtx, &fire->light, fire); + CollisionCheck_SetAC(play, &play->colChkCtx, &fire->collision.base); + FireObj_UpdateLight(play, &fire->light, fire); } diff --git a/src/code/z_game_dlftbls.c b/src/code/z_game_dlftbls.c index 4e2590a6a..a79c732d8 100644 --- a/src/code/z_game_dlftbls.c +++ b/src/code/z_game_dlftbls.c @@ -15,9 +15,9 @@ GameStateOverlay gGameStateOverlayTable[] = { GAMESTATE_OVERLAY_INTERNAL(TitleSetup_Init, TitleSetup_Destroy, sizeof(GameState)), - GAMESTATE_OVERLAY(select, Select_Init, Select_Destroy, sizeof(SelectContext)), + GAMESTATE_OVERLAY(select, MapSelect_Init, MapSelect_Destroy, sizeof(MapSelectState)), GAMESTATE_OVERLAY(title, Title_Init, Title_Destroy, sizeof(TitleContext)), - GAMESTATE_OVERLAY_INTERNAL(Play_Init, Play_Fini, sizeof(GlobalContext)), + GAMESTATE_OVERLAY_INTERNAL(Play_Init, Play_Destroy, sizeof(PlayState)), GAMESTATE_OVERLAY(opening, Opening_Init, Opening_Destroy, sizeof(OpeningContext)), GAMESTATE_OVERLAY(file_choose, FileChoose_Init, FileChoose_Destroy, sizeof(FileChooseContext)), GAMESTATE_OVERLAY(daytelop, Daytelop_Init, Daytelop_Destroy, sizeof(DaytelopContext)), diff --git a/src/code/z_game_over.c b/src/code/z_game_over.c index 62d55bc00..dcbe71a1c 100644 --- a/src/code/z_game_over.c +++ b/src/code/z_game_over.c @@ -1,27 +1,28 @@ #include "global.h" +#include "z64rumble.h" -void GameOver_Init(GlobalContext* globalCtx) { - globalCtx->gameOverCtx.state = GAMEOVER_INACTIVE; +void GameOver_Init(PlayState* play) { + play->gameOverCtx.state = GAMEOVER_INACTIVE; } -void GameOver_FadeLights(GlobalContext* globalCtx) { - GameOverContext* gameOverCtx = &globalCtx->gameOverCtx; +void GameOver_FadeLights(PlayState* play) { + GameOverContext* gameOverCtx = &play->gameOverCtx; if ((gameOverCtx->state >= GAMEOVER_DEATH_WAIT_GROUND && gameOverCtx->state < GAMEOVER_REVIVE_START) || (gameOverCtx->state >= GAMEOVER_REVIVE_RUMBLE && gameOverCtx->state < GAMEOVER_REVIVE_FADE_OUT)) { - Kankyo_FadeInGameOverLights(globalCtx); + Kankyo_FadeInGameOverLights(play); } } static s16 sGameOverTimer = 0; -void GameOver_Update(GlobalContext* globalCtx) { - GameOverContext* gameOverCtx = &globalCtx->gameOverCtx; +void GameOver_Update(PlayState* play) { + GameOverContext* gameOverCtx = &play->gameOverCtx; s16 i; switch (gameOverCtx->state) { case GAMEOVER_DEATH_START: - func_801477B4(globalCtx); + func_801477B4(play); for (i = 0; i < ARRAY_COUNT(gSaveContext.unk_3DD0); i++) { gSaveContext.unk_3DD0[i] = 0; @@ -35,8 +36,8 @@ void GameOver_Update(GlobalContext* globalCtx) { CUR_FORM_EQUIP(EQUIP_SLOT_B) != ITEM_SWORD_GILDED && CUR_FORM_EQUIP(EQUIP_SLOT_B) != ITEM_SWORD_DEITY) { - if (gSaveContext.buttonStatus[0] != BTN_ENABLED) { - CUR_FORM_EQUIP(EQUIP_SLOT_B) = gSaveContext.buttonStatus[0]; + if (gSaveContext.buttonStatus[EQUIP_SLOT_B] != BTN_ENABLED) { + CUR_FORM_EQUIP(EQUIP_SLOT_B) = gSaveContext.buttonStatus[EQUIP_SLOT_B]; } else { CUR_FORM_EQUIP(EQUIP_SLOT_B) = ITEM_NONE; } @@ -51,46 +52,46 @@ void GameOver_Update(GlobalContext* globalCtx) { gSaveContext.eventInf[1] = 0; gSaveContext.eventInf[2] = 0; gSaveContext.eventInf[3] = 0; - gSaveContext.buttonStatus[0] = BTN_ENABLED; - gSaveContext.buttonStatus[1] = BTN_ENABLED; - gSaveContext.buttonStatus[2] = BTN_ENABLED; - gSaveContext.buttonStatus[3] = BTN_ENABLED; - gSaveContext.buttonStatus[4] = BTN_ENABLED; + gSaveContext.buttonStatus[EQUIP_SLOT_B] = BTN_ENABLED; + gSaveContext.buttonStatus[EQUIP_SLOT_C_LEFT] = BTN_ENABLED; + gSaveContext.buttonStatus[EQUIP_SLOT_C_DOWN] = BTN_ENABLED; + gSaveContext.buttonStatus[EQUIP_SLOT_C_RIGHT] = BTN_ENABLED; + gSaveContext.buttonStatus[EQUIP_SLOT_A] = BTN_ENABLED; gSaveContext.unk_3F1E = 0; gSaveContext.unk_3F20 = 0; gSaveContext.unk_3F22 = 0; gSaveContext.unk_3F24 = 0; - Kankyo_InitGameOverLights(globalCtx); + Kankyo_InitGameOverLights(play); sGameOverTimer = 20; - func_8013ECE0(0.0f, 126, 124, 63); + Rumble_Request(0.0f, 126, 124, 63); gameOverCtx->state = GAMEOVER_DEATH_WAIT_GROUND; break; case GAMEOVER_DEATH_FADE_OUT: if (func_801A8A50(1) != NA_BGM_GAME_OVER) { - func_80169F78(&globalCtx->state); + func_80169F78(&play->state); if (gSaveContext.respawnFlag != -7) { gSaveContext.respawnFlag = -6; } - gSaveContext.nextTransition = 2; - gSaveContext.save.playerData.health = 48; + gSaveContext.nextTransitionType = TRANS_TYPE_02; + gSaveContext.save.playerData.health = 0x30; gameOverCtx->state++; if (INV_CONTENT(ITEM_MASK_DEKU) == ITEM_MASK_DEKU) { gSaveContext.save.playerForm = PLAYER_FORM_HUMAN; gSaveContext.save.equippedMask = PLAYER_MASK_NONE; } - func_8013EE24(); + Rumble_StateReset(); } break; case GAMEOVER_REVIVE_START: gameOverCtx->state++; sGameOverTimer = 0; - Kankyo_InitGameOverLights(globalCtx); + Kankyo_InitGameOverLights(play); ShrinkWindow_SetLetterboxTarget(32); break; case GAMEOVER_REVIVE_RUMBLE: sGameOverTimer = 50; gameOverCtx->state++; - func_8013ECE0(0.0f, 126, 124, 63); + Rumble_Request(0.0f, 126, 124, 63); break; case GAMEOVER_REVIVE_WAIT_GROUND: sGameOverTimer--; @@ -107,7 +108,7 @@ void GameOver_Update(GlobalContext* globalCtx) { } break; case GAMEOVER_REVIVE_FADE_OUT: - Kankyo_FadeOutGameOverLights(globalCtx); + Kankyo_FadeOutGameOverLights(play); sGameOverTimer--; if (sGameOverTimer == 0) { gameOverCtx->state = GAMEOVER_INACTIVE; diff --git a/src/code/z_kaleido_manager.c b/src/code/z_kaleido_manager.c index 5e89f49e9..48e8e2ad6 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) \ { \ @@ -53,7 +54,7 @@ void KaleidoManager_ClearOvl(KaleidoMgrOverlay* ovl) { } } -void KaleidoManager_Init(GlobalContext* globalCtx) { +void KaleidoManager_Init(PlayState* play) { s32 largestSize = 0; s32 size; u32 i; @@ -65,7 +66,7 @@ void KaleidoManager_Init(GlobalContext* globalCtx) { } } - sKaleidoAreaPtr = THA_AllocEndAlign16(&globalCtx->state.heap, largestSize); + sKaleidoAreaPtr = THA_AllocEndAlign16(&play->state.heap, largestSize); gKaleidoMgrCurOvl = NULL; Fault_AddAddrConvClient(&sKaleidoAreaFaultClient, KaleidoManager_FaultAddrConvFunc, NULL); } diff --git a/src/code/z_kaleido_scope_call.c b/src/code/z_kaleido_scope_call.c index c3c616669..d7905e4dd 100644 --- a/src/code/z_kaleido_scope_call.c +++ b/src/code/z_kaleido_scope_call.c @@ -1,11 +1,12 @@ #include "prevent_bss_reordering.h" #include "global.h" +#include "overlays/kaleido_scope/ovl_kaleido_scope/z_kaleido_scope.h" -void (*sKaleidoScopeUpdateFunc)(GlobalContext* globalCtx); -void (*sKaleidoScopeDrawFunc)(GlobalContext* globalCtx); +void (*sKaleidoScopeUpdateFunc)(PlayState* play); +void (*sKaleidoScopeDrawFunc)(PlayState* play); -extern void KaleidoScope_Update(GlobalContext* globalCtx); -extern void KaleidoScope_Draw(GlobalContext* globalCtx); +extern void KaleidoScope_Update(PlayState* play); +extern void KaleidoScope_Draw(PlayState* play); void KaleidoScopeCall_LoadPlayer() { KaleidoMgrOverlay* playerActorOvl = &gKaleidoMgrOverlayTable[KALEIDO_OVL_PLAYER_ACTOR]; @@ -19,21 +20,21 @@ void KaleidoScopeCall_LoadPlayer() { } } -void KaleidoScopeCall_Init(GlobalContext* globalCtx) { +void KaleidoScopeCall_Init(PlayState* play) { sKaleidoScopeUpdateFunc = KaleidoManager_GetRamAddr(KaleidoScope_Update); sKaleidoScopeDrawFunc = KaleidoManager_GetRamAddr(KaleidoScope_Draw); - KaleidoSetup_Init(globalCtx); + KaleidoSetup_Init(play); } -void KaleidoScopeCall_Destroy(GlobalContext* globalCtx) { - KaleidoSetup_Destroy(globalCtx); +void KaleidoScopeCall_Destroy(PlayState* play) { + KaleidoSetup_Destroy(play); } -void KaleidoScopeCall_Update(GlobalContext* globalCtx) { - PauseContext* pauseCtx = &globalCtx->pauseCtx; +void KaleidoScopeCall_Update(PlayState* play) { + PauseContext* pauseCtx = &play->pauseCtx; KaleidoMgrOverlay* kaleidoScopeOvl = &gKaleidoMgrOverlayTable[KALEIDO_OVL_KALEIDO_SCOPE]; - if ((globalCtx->pauseCtx.state != 0) || (globalCtx->pauseCtx.debugState != 0)) { + if ((play->pauseCtx.state != 0) || (play->pauseCtx.debugEditor != DEBUG_EDITOR_NONE)) { if (pauseCtx->state == 1 || pauseCtx->state == 19) { if (ShrinkWindow_GetLetterboxMagnitude() == 0) { R_PAUSE_MENU_MODE = 1; @@ -60,9 +61,9 @@ void KaleidoScopeCall_Update(GlobalContext* globalCtx) { } if (gKaleidoMgrCurOvl == kaleidoScopeOvl) { - sKaleidoScopeUpdateFunc(globalCtx); + sKaleidoScopeUpdateFunc(play); - if ((globalCtx->pauseCtx.state == 0) && (globalCtx->pauseCtx.debugState == 0)) { + if ((play->pauseCtx.state == 0) && (play->pauseCtx.debugEditor == DEBUG_EDITOR_NONE)) { KaleidoManager_ClearOvl(kaleidoScopeOvl); KaleidoScopeCall_LoadPlayer(); } @@ -71,14 +72,14 @@ void KaleidoScopeCall_Update(GlobalContext* globalCtx) { } } -void KaleidoScopeCall_Draw(GlobalContext* globalCtx) { +void KaleidoScopeCall_Draw(PlayState* play) { KaleidoMgrOverlay* kaleidoScopeOvl = &gKaleidoMgrOverlayTable[KALEIDO_OVL_KALEIDO_SCOPE]; if (R_PAUSE_MENU_MODE == 3) { - if (((globalCtx->pauseCtx.state >= 4) && (globalCtx->pauseCtx.state <= 7)) || - ((globalCtx->pauseCtx.state >= 11) && (globalCtx->pauseCtx.state <= 26))) { + if (((play->pauseCtx.state >= 4) && (play->pauseCtx.state <= 7)) || + ((play->pauseCtx.state >= 11) && (play->pauseCtx.state <= 26))) { if (gKaleidoMgrCurOvl == kaleidoScopeOvl) { - sKaleidoScopeDrawFunc(globalCtx); + sKaleidoScopeDrawFunc(play); } } } diff --git a/src/code/z_kaleido_setup.c b/src/code/z_kaleido_setup.c index 5a234ea44..625adf20f 100644 --- a/src/code/z_kaleido_setup.c +++ b/src/code/z_kaleido_setup.c @@ -1,15 +1,16 @@ #include "global.h" -#include "overlays/gamestates/ovl_file_choose/z_file_choose.h" +#include "z64rumble.h" +#include "overlays/kaleido_scope/ovl_kaleido_scope/z_kaleido_scope.h" -s16 D_801BDB00[] = { PAUSE_1, PAUSE_2, PAUSE_3, PAUSE_0 }; +s16 D_801BDB00[] = { PAUSE_MAP, PAUSE_QUEST, PAUSE_MASK, PAUSE_ITEM }; f32 sKaleidoSetupEyeX[] = { -64.0f, 0.0f, 64.0f, 0.0f }; f32 sKaleidoSetupEyeZ[] = { 0.0f, -64.0f, 0.0f, 64.0f }; -void func_800F4A10(GlobalContext* globalCtx) { - PauseContext* pauseCtx = &globalCtx->pauseCtx; +void func_800F4A10(PlayState* play) { + PauseContext* pauseCtx = &play->pauseCtx; s16 i; - func_8013EE24(); + Rumble_StateReset(); pauseCtx->unk_206 = 0; pauseCtx->unk_200 = 1; @@ -59,35 +60,35 @@ void func_800F4A10(GlobalContext* globalCtx) { YREG(26) = -0x3840; } -void KaleidoSetup_Update(GlobalContext* globalCtx) { - Input* input = CONTROLLER1(globalCtx); - MessageContext* msgCtx = &globalCtx->msgCtx; - Player* player = GET_PLAYER(globalCtx); - PauseContext* pauseCtx = &globalCtx->pauseCtx; +void KaleidoSetup_Update(PlayState* play) { + Input* input = CONTROLLER1(&play->state); + MessageContext* msgCtx = &play->msgCtx; + Player* player = GET_PLAYER(play); + PauseContext* pauseCtx = &play->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 ((pauseCtx->state == 0) && (pauseCtx->debugEditor == DEBUG_EDITOR_NONE) && + (play->gameOverCtx.state == GAMEOVER_INACTIVE)) { + if ((play->transitionTrigger == TRANS_TRIGGER_OFF) && (play->transitionMode == TRANS_MODE_OFF)) { if ((gSaveContext.save.cutscene < 0xFFF0) && (gSaveContext.nextCutsceneIndex < 0xFFF0)) { - if (!Play_InCsMode(globalCtx) || ((msgCtx->msgMode != 0) && (msgCtx->currentTextId == 0xFF))) { - if ((globalCtx->unk_1887C < 2) && (gSaveContext.unk_3F28 != 8) && (gSaveContext.unk_3F28 != 9)) { + if (!Play_InCsMode(play) || ((msgCtx->msgMode != 0) && (msgCtx->currentTextId == 0xFF))) { + if ((play->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)) { + if (!(play->actorCtx.unk5 & 2) && !(play->actorCtx.unk5 & 4)) { + if ((play->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); + func_800F4A10(play); pauseCtx->mode = pauseCtx->pageIndex * 2 + 1; func_801A3A7C(1); } if (pauseCtx->state == 1) { - Game_SetFramerateDivisor(&globalCtx->state, 2); + Game_SetFramerateDivisor(&play->state, 2); if (ShrinkWindow_GetLetterboxTarget() != 0) { ShrinkWindow_SetLetterboxTarget(0); } @@ -102,13 +103,13 @@ void KaleidoSetup_Update(GlobalContext* globalCtx) { } } -void KaleidoSetup_Init(GlobalContext* globalCtx) { - PauseContext* pauseCtx = &globalCtx->pauseCtx; +void KaleidoSetup_Init(PlayState* play) { + PauseContext* pauseCtx = &play->pauseCtx; s32 pad[2]; bzero(pauseCtx, sizeof(PauseContext)); - pauseCtx->pageIndex = PAUSE_0; + pauseCtx->pageIndex = PAUSE_ITEM; pauseCtx->unk_21C = 160.0f; pauseCtx->unk_218 = 160.0f; @@ -119,18 +120,18 @@ void KaleidoSetup_Init(GlobalContext* globalCtx) { pauseCtx->unk_20C = 936.0f; pauseCtx->unk_220 = -314.0f; - pauseCtx->unk_238[PAUSE_1] = XREG(94) + 3; + pauseCtx->unk_238[PAUSE_MAP] = 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->cursorItem[PAUSE_ITEM] = 999; + pauseCtx->cursorItem[PAUSE_MAP] = XREG(94) + 3; + pauseCtx->cursorItem[PAUSE_QUEST] = 999; + pauseCtx->cursorItem[PAUSE_MASK] = 999; - pauseCtx->unk_268[PAUSE_0] = 0; - pauseCtx->unk_268[PAUSE_1] = XREG(94) + 3; + pauseCtx->unk_268[PAUSE_ITEM] = 0; + pauseCtx->unk_268[PAUSE_MAP] = XREG(94) + 3; pauseCtx->unk_284 = 2; pauseCtx->unk_2A0 = -1; @@ -138,8 +139,8 @@ void KaleidoSetup_Init(GlobalContext* globalCtx) { pauseCtx->unk_2BC = 40; pauseCtx->unk_29E = 100; - View_Init(&pauseCtx->view, globalCtx->state.gfxCtx); + View_Init(&pauseCtx->view, play->state.gfxCtx); } -void KaleidoSetup_Destroy(GlobalContext* globalCtx) { +void KaleidoSetup_Destroy(PlayState* play) { } diff --git a/src/code/z_kanfont.c b/src/code/z_kanfont.c index 2a4849ccb..68c0fdd01 100644 --- a/src/code/z_kanfont.c +++ b/src/code/z_kanfont.c @@ -1,11 +1,11 @@ #include "global.h" // stubbed in NTSC-U -void Font_LoadChar(GlobalContext* globalCtx, u16 codePointIndex, s32 offset) { +void Font_LoadChar(PlayState* play, u16 codePointIndex, s32 offset) { } -void Font_LoadCharNES(GlobalContext* globalCtx, u8 codePointIndex, s32 offset) { - MessageContext* msgCtx = &globalCtx->msgCtx; +void Font_LoadCharNES(PlayState* play, u8 codePointIndex, s32 offset) { + MessageContext* msgCtx = &play->msgCtx; Font* font = &msgCtx->font; DmaMgr_SendRequest0(&font->charBuf[font->unk_11D88][offset], diff --git a/src/code/z_lib.c b/src/code/z_lib.c index aaf4bc7d9..03e6c395c 100644 --- a/src/code/z_lib.c +++ b/src/code/z_lib.c @@ -651,15 +651,15 @@ void Lib_PlaySfxAtPos(Vec3f* pos, u16 sfxId) { Audio_PlaySfxAtPos(pos, sfxId); } -void Lib_Vec3f_TranslateAndRotateY(Vec3f* translation, s16 a, Vec3f* src, Vec3f* dst) { - f32 sp1C; - f32 f0; +void Lib_Vec3f_TranslateAndRotateY(Vec3f* translation, s16 rotAngle, Vec3f* src, Vec3f* dst) { + f32 cos; + f32 sin; - sp1C = Math_CosS(a); - f0 = Math_SinS(a); - dst->x = translation->x + (src->x * sp1C + src->z * f0); + cos = Math_CosS(rotAngle); + sin = Math_SinS(rotAngle); + dst->x = translation->x + (src->x * cos + src->z * sin); dst->y = translation->y + src->y; - dst->z = translation->z + (src->z * sp1C - src->x * f0); + dst->z = translation->z + (src->z * cos - src->x * sin); } void Lib_LerpRGB(Color_RGB8* a, Color_RGB8* b, f32 t, Color_RGB8* dst) { @@ -688,7 +688,7 @@ f32 Math_Vec3f_StepTo(Vec3f* start, Vec3f* target, f32 speed) { start->z = start->z + f2 * diff.z; } else { Math_Vec3f_Copy(start, target); - f0 = 0; + f0 = 0.0f; } return f0; diff --git a/src/code/z_lifemeter.c b/src/code/z_lifemeter.c index 73ba326b5..d2a3a254c 100644 --- a/src/code/z_lifemeter.c +++ b/src/code/z_lifemeter.c @@ -1,7 +1,7 @@ #include "prevent_bss_reordering.h" #include "global.h" +#include "overlays/kaleido_scope/ovl_kaleido_scope/z_kaleido_scope.h" #include "interface/parameter_static/parameter_static.h" -#include "prevent_bss_reordering.h" 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 } }; @@ -33,8 +33,8 @@ TexturePtr HeartDDTextures[] = { gDefenseHeartThreeQuarterTex, }; -void LifeMeter_Init(GlobalContext* globalCtx) { - InterfaceContext* interfaceCtx = &globalCtx->interfaceCtx; +void LifeMeter_Init(PlayState* play) { + InterfaceContext* interfaceCtx = &play->interfaceCtx; interfaceCtx->unkTimer = 320; @@ -71,8 +71,8 @@ void LifeMeter_Init(GlobalContext* globalCtx) { sHeartsDDEnv[0][2] = sHeartsDDEnv[1][2] = 0; } -void LifeMeter_UpdateColors(GlobalContext* globalCtx) { - InterfaceContext* interfaceCtx = &globalCtx->interfaceCtx; +void LifeMeter_UpdateColors(PlayState* play) { + InterfaceContext* interfaceCtx = &play->interfaceCtx; f32 factorBeating = interfaceCtx->lifeColorChange * 0.1f; f32 ddFactor; s32 type = 0; @@ -167,26 +167,26 @@ void LifeMeter_UpdateColors(GlobalContext* globalCtx) { sBeatingHeartsDDEnv[2] = (u8)(bFactor + 0) & 0xFF; } -s32 LifeMeter_SaveInterfaceHealth(GlobalContext* globalCtx) { - gSaveContext.save.playerData.health = globalCtx->interfaceCtx.health; +s32 LifeMeter_SaveInterfaceHealth(PlayState* play) { + gSaveContext.save.playerData.health = play->interfaceCtx.health; return 1; } -s32 LifeMeter_IncreaseInterfaceHealth(GlobalContext* globalCtx) { - InterfaceContext* interfaceCtx = &globalCtx->interfaceCtx; +s32 LifeMeter_IncreaseInterfaceHealth(PlayState* play) { + InterfaceContext* interfaceCtx = &play->interfaceCtx; interfaceCtx->unkTimer = 320; interfaceCtx->health += 0x10; - if (globalCtx->interfaceCtx.health >= gSaveContext.save.playerData.health) { - globalCtx->interfaceCtx.health = gSaveContext.save.playerData.health; + if (play->interfaceCtx.health >= gSaveContext.save.playerData.health) { + play->interfaceCtx.health = gSaveContext.save.playerData.health; return 1; } return 0; } -s32 LifeMeter_DecreaseInterfaceHealth(GlobalContext* globalCtx) { - InterfaceContext* interfaceCtx = &globalCtx->interfaceCtx; +s32 LifeMeter_DecreaseInterfaceHealth(PlayState* play) { + InterfaceContext* interfaceCtx = &play->interfaceCtx; if (interfaceCtx->unkTimer != 0) { interfaceCtx->unkTimer--; @@ -195,14 +195,14 @@ s32 LifeMeter_DecreaseInterfaceHealth(GlobalContext* globalCtx) { interfaceCtx->health -= 0x10; if (interfaceCtx->health <= 0) { interfaceCtx->health = 0; - globalCtx->damagePlayer(globalCtx, -(((void)0, gSaveContext.save.playerData.health) + 1)); + play->damagePlayer(play, -(((void)0, gSaveContext.save.playerData.health) + 1)); return 1; } } return 0; } -void LifeMeter_Draw(GlobalContext* globalCtx) { +void LifeMeter_Draw(PlayState* play) { s32 pad[5]; TexturePtr heartTex; s32 curColorSet; @@ -213,8 +213,8 @@ void LifeMeter_Draw(GlobalContext* globalCtx) { f32 posX; f32 halfTexSize; f32 temp_f4; - GraphicsContext* gfxCtx = globalCtx->state.gfxCtx; - InterfaceContext* interfaceCtx = &globalCtx->interfaceCtx; + GraphicsContext* gfxCtx = play->state.gfxCtx; + InterfaceContext* interfaceCtx = &play->interfaceCtx; Vtx* beatingHeartVtx = interfaceCtx->beatingHeartVtx; s32 fractionHeartCount = gSaveContext.save.playerData.health % 0x10; s16 healthCapacity = gSaveContext.save.playerData.healthCapacity / 0x10; @@ -223,7 +223,7 @@ void LifeMeter_Draw(GlobalContext* globalCtx) { f32 lifesize = interfaceCtx->lifeSizeChange * 0.1f; u32 curCombineModeSet = 0; TexturePtr temp = NULL; - s32 ddCount = gSaveContext.save.inventory.dungeonKeys[9] - 1; + s32 ddCount = gSaveContext.save.inventory.defenseHearts - 1; OPEN_DISPS(gfxCtx); @@ -391,16 +391,16 @@ void LifeMeter_Draw(GlobalContext* globalCtx) { CLOSE_DISPS(gfxCtx); } -void LifeMeter_UpdateSizeAndBeep(GlobalContext* globalCtx) { - InterfaceContext* interfaceCtx = &globalCtx->interfaceCtx; +void LifeMeter_UpdateSizeAndBeep(PlayState* play) { + InterfaceContext* interfaceCtx = &play->interfaceCtx; if (interfaceCtx->lifeSizeChangeDirection != 0) { interfaceCtx->lifeSizeChange--; if (interfaceCtx->lifeSizeChange <= 0) { interfaceCtx->lifeSizeChange = 0; interfaceCtx->lifeSizeChangeDirection = 0; - if (!Player_InCsMode(&globalCtx->state) && (globalCtx->pauseCtx.state == 0) && - (globalCtx->pauseCtx.debugState == 0) && LifeMeter_IsCritical() && !Play_InCsMode(globalCtx)) { + if (!Player_InCsMode(play) && (play->pauseCtx.state == 0) && + (play->pauseCtx.debugEditor == DEBUG_EDITOR_NONE) && LifeMeter_IsCritical() && !Play_InCsMode(play)) { play_sound(NA_SE_SY_HITPOINT_ALARM); } } @@ -416,16 +416,16 @@ void LifeMeter_UpdateSizeAndBeep(GlobalContext* globalCtx) { u32 LifeMeter_IsCritical(void) { s16 criticalThreshold; - if (gSaveContext.save.playerData.healthCapacity <= 80) { // healthCapacity <= 5 hearts? - criticalThreshold = 16; + if (gSaveContext.save.playerData.healthCapacity <= 0x50) { + criticalThreshold = 0x10; - } else if (gSaveContext.save.playerData.healthCapacity <= 160) { // healthCapacity <= 10 hearts? - criticalThreshold = 24; + } else if (gSaveContext.save.playerData.healthCapacity <= 0xA0) { + criticalThreshold = 0x18; - } else if (gSaveContext.save.playerData.healthCapacity <= 240) { // healthCapacity <= 15 hearts? - criticalThreshold = 32; + } else if (gSaveContext.save.playerData.healthCapacity <= 0xF0) { + criticalThreshold = 0x20; } else { - criticalThreshold = 44; + criticalThreshold = 0x2C; } if ((criticalThreshold >= gSaveContext.save.playerData.health) && (gSaveContext.save.playerData.health > 0)) { diff --git a/src/code/z_lights.c b/src/code/z_lights.c index 2b0db8ad4..e3e732eb3 100644 --- a/src/code/z_lights.c +++ b/src/code/z_lights.c @@ -124,7 +124,7 @@ void Lights_BindPointWithReference(Lights* lights, LightParams* params, Vec3f* p } } -void Lights_BindPoint(Lights* lights, LightParams* params, GlobalContext* globalCtx) { +void Lights_BindPoint(Lights* lights, LightParams* params, PlayState* play) { Light* light; f32 radiusF = params->point.radius; Vec3f posF; @@ -135,7 +135,7 @@ void Lights_BindPoint(Lights* lights, LightParams* params, GlobalContext* global posF.x = params->point.x; posF.y = params->point.y; posF.z = params->point.z; - SkinMatrix_Vec3fMtxFMultXYZ(&globalCtx->viewProjectionMtxF, &posF, &adjustedPos); + SkinMatrix_Vec3fMtxFMultXYZ(&play->viewProjectionMtxF, &posF, &adjustedPos); if ((adjustedPos.z > -radiusF) && (600 + radiusF > adjustedPos.z) && (400 > fabsf(adjustedPos.x) - radiusF) && (400 > fabsf(adjustedPos.y) - radiusF)) { light = Lights_FindSlot(lights); @@ -189,7 +189,7 @@ void Lights_BindDirectional(Lights* lights, LightParams* params, void* unused) { * Note: Lights in a given list can only be binded to however many free slots are * available in the Lights group. This is at most 7 slots for a new group, but could be less. */ -void Lights_BindAll(Lights* lights, LightNode* listHead, Vec3f* refPos, GlobalContext* globalCtx) { +void Lights_BindAll(Lights* lights, LightNode* listHead, Vec3f* refPos, PlayState* play) { static LightsPosBindFunc posBindFuncs[] = { Lights_BindPoint, (LightsPosBindFunc)Lights_BindDirectional, @@ -204,7 +204,7 @@ void Lights_BindAll(Lights* lights, LightNode* listHead, Vec3f* refPos, GlobalCo if (listHead != NULL) { if ((refPos == NULL) && (lights->enablePosLights == 1)) { do { - posBindFuncs[listHead->info->type](lights, &listHead->info->params, globalCtx); + posBindFuncs[listHead->info->type](lights, &listHead->info->params, play); listHead = listHead->next; } while (listHead != NULL); } else { @@ -216,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) { @@ -248,8 +248,8 @@ void Lights_FreeNode(LightNode* light) { } } -void LightContext_Init(GlobalContext* globalCtx, LightContext* lightCtx) { - LightContext_InitList(globalCtx, lightCtx); +void LightContext_Init(PlayState* play, LightContext* lightCtx) { + LightContext_InitList(play, lightCtx); LightContext_SetAmbientColor(lightCtx, 80, 80, 80); func_80102544(lightCtx, 0, 0, 0, 0x3E4, 0x3200); bzero(&sLightsBuffer, sizeof(LightsBuffer)); @@ -276,13 +276,13 @@ Lights* LightContext_NewLights(LightContext* lightCtx, GraphicsContext* gfxCtx) return Lights_New(gfxCtx, lightCtx->ambient.r, lightCtx->ambient.g, lightCtx->ambient.b); } -void LightContext_InitList(GlobalContext* globalCtx, LightContext* lightCtx) { +void LightContext_InitList(PlayState* play, LightContext* lightCtx) { lightCtx->listHead = NULL; } -void LightContext_DestroyList(GlobalContext* globalCtx, LightContext* lightCtx) { +void LightContext_DestroyList(PlayState* play, LightContext* lightCtx) { while (lightCtx->listHead != NULL) { - LightContext_RemoveLight(globalCtx, lightCtx, lightCtx->listHead); + LightContext_RemoveLight(play, lightCtx, lightCtx->listHead); lightCtx->listHead = lightCtx->listHead->next; } } @@ -293,7 +293,7 @@ void LightContext_DestroyList(GlobalContext* globalCtx, LightContext* lightCtx) * Note: Due to the limited number of slots in a Lights group, inserting too many lights in the * list may result in older entries not being bound to a Light when calling Lights_BindAll */ -LightNode* LightContext_InsertLight(GlobalContext* globalCtx, LightContext* lightCtx, LightInfo* info) { +LightNode* LightContext_InsertLight(PlayState* play, LightContext* lightCtx, LightInfo* info) { LightNode* light; light = Lights_FindBufSlot(); @@ -312,7 +312,7 @@ LightNode* LightContext_InsertLight(GlobalContext* globalCtx, LightContext* ligh return light; } -void LightContext_RemoveLight(GlobalContext* globalCtx, LightContext* lightCtx, LightNode* light) { +void LightContext_RemoveLight(PlayState* play, LightContext* lightCtx, LightNode* light) { if (light != NULL) { if (light->prev != NULL) { light->prev->next = light->next; @@ -372,29 +372,29 @@ Lights* Lights_New(GraphicsContext* gfxCtx, u8 ambientR, u8 ambientG, u8 ambient return lights; } -void Lights_GlowCheck(GlobalContext* globalCtx) { - LightNode* light = globalCtx->lightCtx.listHead; +void Lights_GlowCheck(PlayState* play) { + LightNode* light = play->lightCtx.listHead; while (light != NULL) { LightPoint* params = &light->info->params.point; if (light->info->type == LIGHT_POINT_GLOW) { - Vec3f pos; - Vec3f multDest; - f32 wDest; + Vec3f worldPos; + Vec3f projectedPos; + f32 invW; - pos.x = params->x; - pos.y = params->y; - pos.z = params->z; - Actor_GetProjectedPos(globalCtx, &pos, &multDest, &wDest); + worldPos.x = params->x; + worldPos.y = params->y; + worldPos.z = params->z; + Actor_GetProjectedPos(play, &worldPos, &projectedPos, &invW); params->drawGlow = 0; - if ((multDest.z > 1) && (fabsf(multDest.x * wDest) < 1) && (fabsf(multDest.y * wDest) < 1)) { - s32 wX = multDest.x * wDest * 160 + 160; - s32 wY = multDest.y * wDest * -120 + 120; - s32 wZ = (s32)((multDest.z * wDest) * 16352) + 16352; - s32 zBuf = func_80178A94(wX, wY); + if ((projectedPos.z > 1) && (fabsf(projectedPos.x * invW) < 1) && (fabsf(projectedPos.y * invW) < 1)) { + s32 screenPosX = PROJECTED_TO_SCREEN_X(projectedPos, invW); + s32 screenPosY = PROJECTED_TO_SCREEN_Y(projectedPos, invW); + s32 wZ = (s32)((projectedPos.z * invW) * 16352.0f) + 16352; + s32 zBuf = func_80178A94(screenPosX, screenPosY); if (wZ < zBuf) { params->drawGlow = 1; @@ -406,13 +406,13 @@ void Lights_GlowCheck(GlobalContext* globalCtx) { } } -void Lights_DrawGlow(GlobalContext* globalCtx) { +void Lights_DrawGlow(PlayState* play) { Gfx* dl; LightPoint* params; - LightNode* light = globalCtx->lightCtx.listHead; + LightNode* light = play->lightCtx.listHead; if (light != NULL) { - OPEN_DISPS(globalCtx->state.gfxCtx); + OPEN_DISPS(play->state.gfxCtx); dl = func_8012C7FC(POLY_XLU_DISP); @@ -431,11 +431,10 @@ void Lights_DrawGlow(GlobalContext* globalCtx) { 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), - G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPMatrix(dl++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(dl++, gameplay_keep_DL_029CF0); } @@ -446,6 +445,6 @@ void Lights_DrawGlow(GlobalContext* globalCtx) { POLY_XLU_DISP = dl; - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->state.gfxCtx); } } diff --git a/src/code/z_map_exp.c b/src/code/z_map_exp.c index 079117fd4..5135a3c41 100644 --- a/src/code/z_map_exp.c +++ b/src/code/z_map_exp.c @@ -1,31 +1,258 @@ #include "global.h" +#include "overlays/kaleido_scope/ovl_kaleido_scope/z_kaleido_scope.h" -#pragma GLOBAL_ASM("asm/non_matchings/code/z_map_exp/func_8010A000.s") +s16 sMinimapInitPosX = 0; +s16 sMinimapInitPosZ = 0; +s16 sMinimapInitDir = 0; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_map_exp/func_8010A074.s") +s32 sDungeonAndBossScenes[] = { + SCENE_MITURIN, SCENE_HAKUGIN, SCENE_SEA, SCENE_INISIE_N, SCENE_INISIE_R, + SCENE_MITURIN_BS, SCENE_HAKUGIN_BS, SCENE_SEA_BS, SCENE_INISIE_BS, +}; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_map_exp/func_8010A0A4.s") +/** + * If the current scene is a dungeon or boss scene, this function returns an index + * indicating which one it is. Otherwise, it returns -1. + */ +s32 Map_GetDungeonOrBossAreaIndex(PlayState* play) { + s32 i; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_map_exp/func_8010A0F0.s") + for (i = 0; i < ARRAY_COUNT(sDungeonAndBossScenes); i++) { + if (Play_GetOriginalSceneNumber(play->sceneNum) == sDungeonAndBossScenes[i]) { + return i; + } + } -#pragma GLOBAL_ASM("asm/non_matchings/code/z_map_exp/func_8010A164.s") + return -1; +} -#pragma GLOBAL_ASM("asm/non_matchings/code/z_map_exp/func_8010A194.s") +/** + * Returns true if the current scene is a dungeon or boss scene, false otherwise. + */ +s32 Map_IsInDungeonOrBossArea(PlayState* play) { + if (Map_GetDungeonOrBossAreaIndex(play) == -1) { + return false; + } -#pragma GLOBAL_ASM("asm/non_matchings/code/z_map_exp/func_8010A208.s") + return true; +} -#pragma GLOBAL_ASM("asm/non_matchings/code/z_map_exp/func_8010A238.s") +s32 func_8010A0A4(PlayState* play) { + if ((Map_GetDungeonOrBossAreaIndex(play) == -1) || !func_80102EF0(play)) { + return false; + } -#pragma GLOBAL_ASM("asm/non_matchings/code/z_map_exp/func_8010A2AC.s") + return true; +} -#pragma GLOBAL_ASM("asm/non_matchings/code/z_map_exp/func_8010A2DC.s") +s32 sDungeonScenes[] = { + SCENE_MITURIN, SCENE_HAKUGIN, SCENE_SEA, SCENE_INISIE_N, SCENE_INISIE_R, +}; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_map_exp/func_8010A33C.s") +/** + * If the current scene is a dungeon scene, this function returns an index + * indicating which one it is. Otherwise, it returns -1. + */ +s32 Map_GetDungeonAreaIndex(PlayState* play) { + s32 i; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_map_exp/func_8010A410.s") + for (i = 0; i < ARRAY_COUNT(sDungeonScenes); i++) { + if (Play_GetOriginalSceneNumber(play->sceneNum) == sDungeonScenes[i]) { + return i; + } + } -#pragma GLOBAL_ASM("asm/non_matchings/code/z_map_exp/func_8010A430.s") + return -1; +} -#pragma GLOBAL_ASM("asm/non_matchings/code/z_map_exp/func_8010A54C.s") +/** + * Returns true if the current scene is a dungeon scene, false otherwise. + */ +s32 Map_IsInDungeonArea(PlayState* play) { + if (Map_GetDungeonAreaIndex(play) == -1) { + return false; + } -#pragma GLOBAL_ASM("asm/non_matchings/code/z_map_exp/func_8010A580.s") + return true; +} + +s32 sBossScenes[] = { + SCENE_MITURIN_BS, // DUNGEON_INDEX_WOODFALL_TEMPLE + SCENE_HAKUGIN_BS, // DUNGEON_INDEX_SNOWHEAD_TEMPLE + SCENE_SEA_BS, // DUNGEON_INDEX_GREAT_BAY_TEMPLE + SCENE_INISIE_BS, // DUNGEON_INDEX_STONE_TOWER_TEMPLE +}; + +/** + * If the current scene is a boss scene, this function returns an index + * indicating which one it is. Otherwise, it returns -1. + */ +s32 Map_GetBossAreaIndex(PlayState* play) { + s32 i; + + for (i = 0; i < ARRAY_COUNT(sBossScenes); i++) { + if (Play_GetOriginalSceneNumber(play->sceneNum) == sBossScenes[i]) { + return i; + } + } + + return -1; +} + +/** + * Returns true if the current scene is a boss scene, false otherwise. + */ +s32 Map_IsInBossArea(PlayState* play) { + if (Map_GetBossAreaIndex(play) == -1) { + return false; + } + + return true; +} + +s32 D_801BF5A4[] = { + SCENE_22DEKUCITY, + SCENE_KOEPONARACE, + SCENE_F01, +}; + +s32 func_8010A238(PlayState* play) { + s32 i; + + for (i = 0; i < ARRAY_COUNT(D_801BF5A4); i++) { + if (Play_GetOriginalSceneNumber(play->sceneNum) == D_801BF5A4[i]) { + return i; + } + } + + return -1; +} + +s32 func_8010A2AC(PlayState* play) { + if (func_8010A238(play) == -1) { + return false; + } + + return true; +} + +/** + * When a room is loaded, this function is used to save the player's position and rotation + * so that the red arrow on the minimap can be drawn correctly. + */ +void Minimap_SavePlayerRoomInitInfo(PlayState* play) { + Player* player = GET_PLAYER(play); + + sMinimapInitPosX = player->actor.world.pos.x; + sMinimapInitPosZ = player->actor.world.pos.z; + sMinimapInitDir = (0x7FFF - player->actor.shape.rot.y) / 0x400; +} + +void Map_InitRoomData(PlayState* play, s16 room) { + s32 mapIndex = gSaveContext.mapIndex; + InterfaceContext* interfaceCtx = &play->interfaceCtx; + + func_80105C40(room); + + if (room >= 0) { + if (Map_IsInDungeonOrBossArea(play)) { + gSaveContext.save.permanentSceneFlags[Play_GetOriginalSceneNumber(play->sceneNum)].rooms |= gBitFlags[room]; + interfaceCtx->mapRoomNum = room; + interfaceCtx->dungeonOrBossAreaMapIndex = mapIndex; + } + } else { + interfaceCtx->mapRoomNum = 0; + } + + if (gSaveContext.sunsSongState != SUNSSONG_SPEED_TIME) { + gSaveContext.sunsSongState = SUNSSONG_INACTIVE; + } +} + +void Map_Destroy(void) { + func_80105A40(); +} + +void Map_Init(PlayState* play) { + InterfaceContext* interfaceCtx = &play->interfaceCtx; + s32 dungeonIndex; + + func_80105C40(play->roomCtx.currRoom.num); + interfaceCtx->unk_278 = -1; + interfaceCtx->dungeonOrBossAreaMapIndex = -1; + interfaceCtx->mapSegment = THA_AllocEndAlign16(&play->state.heap, 0x1000); + if (func_8010A2AC(play)) { + gSaveContext.mapIndex = func_8010A238(play); + return; + } + + if (Map_IsInDungeonOrBossArea(play)) { + dungeonIndex = Map_GetDungeonOrBossAreaIndex(play); + gSaveContext.mapIndex = dungeonIndex; + switch (play->sceneNum) { + case SCENE_MITURIN_BS: + dungeonIndex = DUNGEON_INDEX_WOODFALL_TEMPLE; + break; + + case SCENE_HAKUGIN_BS: + dungeonIndex = DUNGEON_INDEX_SNOWHEAD_TEMPLE; + break; + + case SCENE_SEA_BS: + dungeonIndex = DUNGEON_INDEX_GREAT_BAY_TEMPLE; + break; + + case SCENE_INISIE_BS: + dungeonIndex = DUNGEON_INDEX_STONE_TOWER_TEMPLE; + break; + } + + gSaveContext.dungeonIndex = dungeonIndex; + Map_InitRoomData(play, play->roomCtx.currRoom.num); + } +} + +void Minimap_Draw(PlayState* play) { + func_80106644(play, sMinimapInitPosX, sMinimapInitPosZ, sMinimapInitDir); +} + +s16 sLastRoomNum = 99; + +void Map_Update(PlayState* play) { + InterfaceContext* interfaceCtx = &play->interfaceCtx; + Player* player = GET_PLAYER(play); + Input* controller = CONTROLLER1(&play->state); + s32 pad1; + s16 floor; + s32 pad2; + + if ((play->pauseCtx.state < 4) && (CHECK_BTN_ALL(controller->press.button, BTN_L)) && (!Play_InCsMode(play)) && + (!func_80106530(play))) { + if (!R_MINIMAP_DISABLED) { + play_sound(NA_SE_SY_CAMERA_ZOOM_UP); + } else { + play_sound(NA_SE_SY_CAMERA_ZOOM_DOWN); + } + + R_MINIMAP_DISABLED ^= 1; + } + + func_80105B34(play); + + if ((play->pauseCtx.state == 0) && (play->pauseCtx.debugEditor == DEBUG_EDITOR_NONE)) { + if (Map_IsInDungeonArea(play)) { + floor = func_80109124(player->actor.world.pos.y); + if (floor != -1) { + gSaveContext.save.permanentSceneFlags[Play_GetOriginalSceneNumber(play->sceneNum)].unk_14 |= + gBitFlags[FLOOR_INDEX_MAX - floor]; + XREG(94) = FLOOR_INDEX_MAX - floor; + if (interfaceCtx->mapRoomNum != sLastRoomNum) { + sLastRoomNum = interfaceCtx->mapRoomNum; + } + } + } else if (Map_IsInBossArea(play)) { + func_80105294(); + XREG(94) = FLOOR_INDEX_MAX - func_80105318(); + } + } +} diff --git a/src/code/z_message.c b/src/code/z_message.c index f41c713f6..16e1203d7 100644 --- a/src/code/z_message.c +++ b/src/code/z_message.c @@ -1,5 +1,6 @@ #include "global.h" #include "message_data_static.h" +#include "overlays/kaleido_scope/ovl_kaleido_scope/z_kaleido_scope.h" #if 0 @@ -42,8 +43,8 @@ void func_80147520(void) { D_801CFCA4[7] = D_801CFCA4[8] = 0; } -void func_80147564(GlobalContext* globalCtx) { - MessageContext* msgCtx = &globalCtx->msgCtx; +void func_80147564(PlayState* play) { + MessageContext* msgCtx = &play->msgCtx; msgCtx->unk1204A[0] = 0xBD; msgCtx->unk1204A[1] = 0xB8; @@ -65,9 +66,9 @@ void func_80147564(GlobalContext* globalCtx) { D_801F6B20 = 0xA; } -s32 Message_ShouldAdvance(GlobalContext* globalCtx) { - MessageContext* msgCtx = &globalCtx->msgCtx; - Input* controller = CONTROLLER1(globalCtx); +s32 Message_ShouldAdvance(PlayState* play) { + MessageContext* msgCtx = &play->msgCtx; + Input* controller = CONTROLLER1(&play->state); if ((msgCtx->unk12020 == 0x10) || (msgCtx->unk12020 == 0x11)) { if (CHECK_BTN_ALL(controller->press.button, BTN_A)) { @@ -84,9 +85,9 @@ s32 Message_ShouldAdvance(GlobalContext* globalCtx) { } } -s32 Message_ShouldAdvanceSilent(GlobalContext* globalCtx) { - MessageContext* msgCtx = &globalCtx->msgCtx; - Input* controller = CONTROLLER1(globalCtx); +s32 Message_ShouldAdvanceSilent(PlayState* play) { + MessageContext* msgCtx = &play->msgCtx; + Input* controller = CONTROLLER1(&play->state); if (msgCtx->unk12020 == 0x10 || msgCtx->unk12020 == 0x11) { return CHECK_BTN_ALL(controller->press.button, BTN_A); @@ -96,11 +97,11 @@ s32 Message_ShouldAdvanceSilent(GlobalContext* globalCtx) { } } -void func_801477B4(GlobalContext* globalCtx) { - MessageContext* msgCtx = &globalCtx->msgCtx; +void func_801477B4(PlayState* play) { + MessageContext* msgCtx = &play->msgCtx; - if (globalCtx->msgCtx.unk11F10 != 0) { - msgCtx->unk12023 = 2; + if (play->msgCtx.msgLength != 0) { + msgCtx->stateTimer = 2; msgCtx->msgMode = 0x43; msgCtx->unk12020 = 0; play_sound(NA_SE_PL_WALK_GROUND - SFX_FLAG); @@ -114,10 +115,10 @@ void func_801477B4(GlobalContext* globalCtx) { #pragma GLOBAL_ASM("asm/non_matchings/code/z_message/func_80148558.s") #ifdef NON_MATCHING -void func_80148B98(GlobalContext* globalCtx, u8 arg1) { +void func_80148B98(PlayState* play, u8 arg1) { static s16 held = 0; - MessageContext* msgCtx = &globalCtx->msgCtx; - Input* curInput = CONTROLLER1(globalCtx); + MessageContext* msgCtx = &play->msgCtx; + Input* curInput = CONTROLLER1(&play->state); if ((curInput->rel.stick_y > 29) && held == 0) { held = 1; @@ -147,8 +148,8 @@ void func_80148B98(GlobalContext* globalCtx, u8 arg1) { #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; +void func_80148CBC(PlayState* play, UNK_PTR puParm2, u8 arg2) { + MessageContext* msgCtx = &play->msgCtx; msgCtx->unk11FF4 = 0x30; if (arg2 == 1) { @@ -156,7 +157,7 @@ void func_80148CBC(GlobalContext* globalCtx, UNK_PTR puParm2, u8 arg2) { } else { msgCtx->unk11FF6 = msgCtx->unk11FFE[msgCtx->choiceIndex]; } - func_80147818(globalCtx, puParm2, msgCtx->unk11FF4, msgCtx->unk11FF6); + func_80147818(play, puParm2, msgCtx->unk11FF4, msgCtx->unk11FF6); } #pragma GLOBAL_ASM("asm/non_matchings/code/z_message/func_80148D64.s") @@ -173,8 +174,8 @@ void func_80148CBC(GlobalContext* globalCtx, UNK_PTR puParm2, u8 arg2) { #pragma GLOBAL_ASM("asm/non_matchings/code/z_message/func_80149C18.s") -void Message_FindMessage(GlobalContext* globalCtx, u16 textId) { - MessageContext* msgCtx = &globalCtx->msgCtx; +void Message_FindMessage(PlayState* play, u16 textId) { + MessageContext* msgCtx = &play->msgCtx; Font* font = &msgCtx->font; MessageTableEntry* msgEntry = msgCtx->messageEntryTable; const char* segment = msgEntry->segment; @@ -209,12 +210,12 @@ void Message_FindMessage(GlobalContext* globalCtx, u16 textId) { #pragma GLOBAL_ASM("asm/non_matchings/code/z_message/func_8014C70C.s") -void Message_LoadChar(GlobalContext* globalCtx, u16 codePointIndex, s32* offset, f32* arg3, s16 decodedBufPos) { - MessageContext* msgCtx = &globalCtx->msgCtx; +void Message_LoadChar(PlayState* play, u16 codePointIndex, s32* offset, f32* arg3, s16 decodedBufPos) { + MessageContext* msgCtx = &play->msgCtx; s32 temp1 = *offset; f32 temp2 = *arg3; - Font_LoadChar(globalCtx, codePointIndex, temp1); + Font_LoadChar(play, codePointIndex, temp1); msgCtx->decodedBuffer.wchar[decodedBufPos] = codePointIndex; temp1 += FONT_CHAR_TEX_SIZE; temp2 += (16.0f * msgCtx->unk12098); @@ -223,21 +224,21 @@ void Message_LoadChar(GlobalContext* globalCtx, u16 codePointIndex, s32* offset, } // Message_LoadRupees JPN ? -void func_8014CCB4(GlobalContext* globalCtx, s16* decodedBufPos, s32* offset, f32* arg3) { - MessageContext* msgCtx = &globalCtx->msgCtx; +void func_8014CCB4(PlayState* play, s16* decodedBufPos, s32* offset, f32* arg3) { + MessageContext* msgCtx = &play->msgCtx; s16 t = *decodedBufPos; s32 k = *offset; f32 f = *arg3; - Font_LoadChar(globalCtx, 0x838B, k); // 0x838b = ル in JISX0213 + Font_LoadChar(play, 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 + Font_LoadChar(play, 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 + Font_LoadChar(play, 0x815C, k); // Ox815C = ― in JISX0213 k += FONT_CHAR_TEX_SIZE; msgCtx->decodedBuffer.wchar[t] = 0x815C; @@ -253,62 +254,39 @@ void func_8014CCB4(GlobalContext* globalCtx, s16* decodedBufPos, s32* offset, f3 #pragma GLOBAL_ASM("asm/non_matchings/code/z_message/func_8014D304.s") -#ifdef NON_EQUIVALENT -extern u16* D_801D0188; -extern s16* D_801D0250; +extern u16 D_801D0188[][9]; +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; +void func_8014D62C(PlayState* play, s32* arg1, f32* arg2, s16* arg3) { + MessageContext* msgCtx = &play->msgCtx; + PauseContext* pauseCtx = &play->pauseCtx; s16 temp_s6; - s32 temp_s2; - s32 temp_s2_2; - u16* temp_v0; + s16 temp_s1 = *arg3; + s32 temp_s2 = *arg1; + f32 sp3C = *arg2; 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)) { + if ((func_8010A0A4(play) != 0) || (play->sceneNum == 0x4F)) { phi_v0 = 0xA; } else { - phi_v0 = arg0->pauseCtx.unk_238[4]; + phi_v0 = pauseCtx->unk_238[PAUSE_WORLD_MAP]; } - 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); + + temp_s6 = D_801D0250[phi_v0]; + + for (phi_s0 = 0; phi_s0 < temp_s6; phi_s0++, temp_s1++, temp_s2 += 0x80) { + msgCtx->decodedBuffer.wchar[temp_s1] = D_801D0188[phi_v0][phi_s0]; + Font_LoadChar(play, D_801D0188[phi_v0][phi_s0], temp_s2); } - *arg3 = phi_s1_2 - 1; - *arg1 = phi_s2_2; - *arg2 = sp3C + ((f32)(temp_s6 - 1) * (16.0f * arg0->msgCtx.unk12098)); + + temp_s1--; + sp3C += (temp_s6 - 1) * (16.0f * msgCtx->unk12098); + + *arg3 = temp_s1; + *arg1 = temp_s2; + *arg2 = sp3C; } -#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") @@ -318,60 +296,60 @@ void func_8014D62C(GlobalContext* arg0, s32* arg1, f32* arg2, s16* arg3) { #pragma GLOBAL_ASM("asm/non_matchings/code/z_message/func_801514B0.s") -void Message_StartTextbox(GlobalContext* globalCtx, u16 textId, Actor* Actor) { - MessageContext* msgCtx = &globalCtx->msgCtx; +void Message_StartTextbox(PlayState* play, u16 textId, Actor* Actor) { + MessageContext* msgCtx = &play->msgCtx; msgCtx->ocarinaAction = 0xFFFF; - func_80150D08(globalCtx, textId); + func_80150D08(play, textId); msgCtx->unkActor = Actor; msgCtx->msgMode = 1; - msgCtx->unk12023 = 0; + msgCtx->stateTimer = 0; msgCtx->unk12024 = 0; - globalCtx->msgCtx.ocarinaMode = 0; + play->msgCtx.ocarinaMode = 0; } -void func_80151938(GlobalContext* globalCtx, u16 textId) { - MessageContext* msgCtx = &globalCtx->msgCtx; - InterfaceContext* interfaceCtx = &globalCtx->interfaceCtx; +void func_80151938(PlayState* play, u16 textId) { + MessageContext* msgCtx = &play->msgCtx; + InterfaceContext* interfaceCtx = &play->interfaceCtx; - msgCtx->unk11F10 = 0; - func_80150D08(globalCtx, textId); - func_80150A84(globalCtx); + msgCtx->msgLength = 0; + func_80150D08(play, textId); + func_80150A84(play); msgCtx->msgMode = 5; - msgCtx->unk12023 = 8; + msgCtx->stateTimer = 8; msgCtx->unk12024 = 0; if (interfaceCtx->unk_222 == 0) { if (textId != 0x1B93) { - func_8011552C(globalCtx, 0x10); + func_8011552C(play, 0x10); } else if (textId != 0xF8) { - func_8011552C(globalCtx, 6); + func_8011552C(play, 6); } } msgCtx->unk1203C = msgCtx->unk1203A; - if (globalCtx->pauseCtx.unk_1F0 != 0) { + if (play->pauseCtx.unk_1F0 != 0) { msgCtx->unk12004 = 0x22; msgCtx->unk12006 = 0x15E; - func_80149C18(globalCtx); - msgCtx->unk12023 = 1; + func_80149C18(play); + msgCtx->stateTimer = 1; } } -void func_80151A68(GlobalContext* globalCtx, u16 textId) { - MessageContext* msgCtx = &globalCtx->msgCtx; +void func_80151A68(PlayState* play, u16 textId) { + MessageContext* msgCtx = &play->msgCtx; - msgCtx->unk11F10 = 0; - func_80150D08(globalCtx, textId); - func_80150A84(globalCtx); - func_8015B198(globalCtx); + msgCtx->msgLength = 0; + func_80150D08(play, textId); + func_80150A84(play); + func_8015B198(play); msgCtx->msgMode = 0x45; msgCtx->unk12024 = 0; msgCtx->unk1203C = msgCtx->unk1203A = msgCtx->unk1201E = 0; - msgCtx->unk12023 = 0x1E; + msgCtx->stateTimer = 30; // Day/Dawn/Night.. Messages - if ((msgCtx->currentTextId >= 0x1BB2) && (msgCtx->currentTextId < 0x1BB7)) { + if ((msgCtx->currentTextId >= 0x1BB2) && (msgCtx->currentTextId <= 0x1BB6)) { XREG(74) = 0x6A; XREG(75) = 0; XREG(77) = 0x58; @@ -386,8 +364,8 @@ void func_80151A68(GlobalContext* globalCtx, u16 textId) { } } -void func_80151BB4(GlobalContext* globalCtx, u8 arg1) { - MessageContext* msgCtx = &globalCtx->msgCtx; +void func_80151BB4(PlayState* play, u8 arg1) { + MessageContext* msgCtx = &play->msgCtx; u8 temp = arg1; if (CHECK_QUEST_ITEM(QUEST_BOMBERS_NOTEBOOK)) { @@ -403,25 +381,25 @@ void func_80151BB4(GlobalContext* globalCtx, u8 arg1) { } } -u32 func_80151C9C(GlobalContext* globalCtx) { - MessageContext* msgCtx = &globalCtx->msgCtx; - u8 flag; +u32 func_80151C9C(PlayState* play) { + MessageContext* msgCtx = &play->msgCtx; while (true) { if (msgCtx->unk120B1 == 0) { - return 0; + return false; } msgCtx->unk120B1--; if ((gSaveContext.save.weekEventReg[D_801C6B28[msgCtx->unk120B2[msgCtx->unk120B1]] >> 8] & (u8)D_801C6B28[msgCtx->unk120B2[msgCtx->unk120B1]]) == 0) { - flag = gSaveContext.save.weekEventReg[D_801C6B28[msgCtx->unk120B2[msgCtx->unk120B1]] >> 8]; gSaveContext.save.weekEventReg[D_801C6B28[msgCtx->unk120B2[msgCtx->unk120B1]] >> 8] = - flag | (u8)D_801C6B28[msgCtx->unk120B2[msgCtx->unk120B1]]; + ((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]]); + func_80151938(play, D_801C6AB8[msgCtx->unk120B2[msgCtx->unk120B1]]); play_sound(NA_SE_SY_SCHEDULE_WRITE); - return 1; + return true; } } } @@ -429,17 +407,83 @@ u32 func_80151C9C(GlobalContext* globalCtx) { #pragma GLOBAL_ASM("asm/non_matchings/code/z_message/func_80151DA4.s") -void func_80152434(GlobalContext* globalCtx, u16 arg2) { - globalCtx->msgCtx.unk12046 = 0; - func_80151DA4(globalCtx, arg2); +void func_80152434(PlayState* play, u16 arg2) { + play->msgCtx.unk12046 = 0; + func_80151DA4(play, arg2); } -void func_80152464(GlobalContext* globalCtx, u16 arg1) { - globalCtx->msgCtx.unk12046 = 1; - func_80151DA4(globalCtx, arg1); +void func_80152464(PlayState* play, u16 arg1) { + play->msgCtx.unk12046 = 1; + func_80151DA4(play, arg1); } -#pragma GLOBAL_ASM("asm/non_matchings/code/z_message/Message_GetState.s") +/** + * @return u8 A value of the TextState enum representing the current state of the on-screen message + */ +u8 Message_GetState(MessageContext* msgCtx) { + if (msgCtx->msgLength == 0) { + return TEXT_STATE_NONE; + } + + if (msgCtx->msgMode == 0x42) { + if (msgCtx->unk11F14 != 0xFFFF) { + return TEXT_STATE_1; + } + + if ((msgCtx->unk12020 == 0x10) || (msgCtx->unk12020 == 0x11)) { + return TEXT_STATE_CHOICE; + } + if ((msgCtx->unk12020 == 0x40) || (msgCtx->unk12020 == 0x42) || (msgCtx->unk12020 == 0x30)) { + return TEXT_STATE_5; + } + if (msgCtx->unk12020 == 0x41) { + return TEXT_STATE_16; + } + if ((msgCtx->unk12020 >= 0x50) && (msgCtx->unk12020 < 0x58)) { + return TEXT_STATE_3; + } + if ((msgCtx->unk12020 == 0x60) || (msgCtx->unk12020 == 0x61)) { + return TEXT_STATE_14; + } + if (msgCtx->unk12020 == 0x62) { + return TEXT_STATE_15; + } + if (msgCtx->unk12020 == 0x63) { + return TEXT_STATE_17; + } + if (msgCtx->unk12020 == 0x12) { + return TEXT_STATE_18; + } + return TEXT_STATE_DONE; + } + + if (msgCtx->msgMode == 0x41) { + return TEXT_STATE_10; + } + if (msgCtx->msgMode == 0x1B) { + return TEXT_STATE_7; + } + if ((msgCtx->ocarinaMode == 3) || (msgCtx->msgMode == 0x37)) { + return TEXT_STATE_8; + } + if (msgCtx->msgMode == 0x20) { + return TEXT_STATE_9; + } + if ((msgCtx->msgMode == 0x21) || (msgCtx->msgMode == 0x3A)) { + return TEXT_STATE_11; + } + if (msgCtx->msgMode == 0x3D) { + return TEXT_STATE_12; + } + if (msgCtx->msgMode == 0x40) { + return TEXT_STATE_13; + } + if ((msgCtx->msgMode == 0x43) && (msgCtx->stateTimer == 1) && (msgCtx->unk120B1 == 0)) { + return TEXT_STATE_CLOSING; + } + + return TEXT_STATE_3; +} #pragma GLOBAL_ASM("asm/non_matchings/code/z_message/func_8015268C.s") @@ -451,21 +495,21 @@ void func_80152C64(View* view) { #pragma GLOBAL_ASM("asm/non_matchings/code/z_message/func_80152CAC.s") // Spawn song effect? -void func_80152EC0(GlobalContext* globalCtx) { - MessageContext* msgCtx = &globalCtx->msgCtx; - Player* player = GET_PLAYER(globalCtx); +void func_80152EC0(PlayState* play) { + MessageContext* msgCtx = &play->msgCtx; + Player* player = GET_PLAYER(play); 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, + Actor_Spawn(&play->actorCtx, play, 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); + Actor_Spawn(&play->actorCtx, play, ACTOR_OCEFF_WIPE4, player->actor.world.pos.x, player->actor.world.pos.y, + player->actor.world.pos.z, 0, 0, 0, 0); } } @@ -473,34 +517,34 @@ void func_80152EC0(GlobalContext* globalCtx) { #pragma GLOBAL_ASM("asm/non_matchings/code/z_message/func_80153750.s") -void func_80153E7C(GlobalContext* globalCtx, void* arg1) { - if ((gSaveContext.options.language == 0) && (globalCtx->msgCtx.unk12090 == 0)) { - func_8014ADBC(globalCtx, arg1); +void func_80153E7C(PlayState* play, void* arg1) { + if ((gSaveContext.options.language == 0) && (play->msgCtx.unk12090 == 0)) { + func_8014ADBC(play, arg1); return; } - if (globalCtx->msgCtx.unk12090 != 0) { - func_8015E7EC(globalCtx, arg1); + if (play->msgCtx.unk12090 != 0) { + func_8015E7EC(play, arg1); return; } - func_8015966C(globalCtx, arg1, 0); + func_8015966C(play, 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") -void func_80156758(GlobalContext* globalCtx) { +void func_80156758(PlayState* play) { Gfx* nextDisplayList; Gfx* polyOpa; - GraphicsContext* gfxCtx = globalCtx->state.gfxCtx; + GraphicsContext* gfxCtx = play->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); + if ((play->msgCtx.currentTextId != 0x5E6) || !Play_InCsMode(play)) { + func_801541D4(play, &nextDisplayList); } gSPEndDisplayList(nextDisplayList++); @@ -511,28 +555,28 @@ void func_80156758(GlobalContext* globalCtx) { #pragma GLOBAL_ASM("asm/non_matchings/code/z_message/func_8015680C.s") -void func_801586A4(GlobalContext* globalCtx) { - globalCtx->msgCtx.messageEntryTableNes = D_801C6B98; - globalCtx->msgCtx.messageTableStaff = D_801CFB08; +void func_801586A4(PlayState* play) { + play->msgCtx.messageEntryTableNes = D_801C6B98; + play->msgCtx.messageTableStaff = D_801CFB08; } -void Message_Init(GlobalContext* globalCtx) { +void Message_Init(PlayState* play) { Font* font; - MessageContext* messageCtx = &globalCtx->msgCtx; + MessageContext* messageCtx = &play->msgCtx; - func_801586A4(globalCtx); - globalCtx->msgCtx.ocarinaMode = 0; + func_801586A4(play); + play->msgCtx.ocarinaMode = 0; messageCtx->msgMode = 0; - messageCtx->unk11F10 = 0; + messageCtx->msgLength = 0; messageCtx->currentTextId = 0; messageCtx->unk12020 = 0; messageCtx->choiceIndex = 0; 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); + View_Init(&messageCtx->view, play->state.gfxCtx); + messageCtx->unk11EF8 = THA_AllocEndAlign16(&play->state.heap, 0x13C00); + font = &play->msgCtx.font; + Font_LoadOrderedFont(&play->msgCtx.font); font->unk_11D88 = 0; messageCtx->unk12090 = messageCtx->unk12092 = 0; messageCtx->unk12094 = 0; diff --git a/src/code/z_message_nes.c b/src/code/z_message_nes.c index 1de839d68..9231ca9b9 100644 --- a/src/code/z_message_nes.c +++ b/src/code/z_message_nes.c @@ -1,5 +1,6 @@ #include "global.h" #include "message_data_static.h" +#include "overlays/kaleido_scope/ovl_kaleido_scope/z_kaleido_scope.h" #if 0 @@ -42,8 +43,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; +void Message_FindMessageNES(PlayState* play, u16 textId) { + MessageContext* msgCtx = &play->msgCtx; Font* font = &msgCtx->font; MessageTableEntry* msgEntry = msgCtx->messageEntryTableNes; const char* segment = msgEntry->segment; @@ -70,12 +71,12 @@ void Message_FindMessageNES(GlobalContext* globalCtx, u16 textId) { font->messageEnd = nextSegment - foundSegment; } -void Message_LoadCharNES(GlobalContext* globalCtx, u8 codePointIndex, s32* offset, f32* arg3, s16 decodedBufPos) { - MessageContext* msgCtx = &globalCtx->msgCtx; +void Message_LoadCharNES(PlayState* play, u8 codePointIndex, s32* offset, f32* arg3, s16 decodedBufPos) { + MessageContext* msgCtx = &play->msgCtx; s32 temp1 = *offset; f32 temp2 = *arg3; - Font_LoadCharNES(globalCtx, codePointIndex, temp1); + Font_LoadCharNES(play, codePointIndex, temp1); msgCtx->decodedBuffer.schar[decodedBufPos] = codePointIndex; temp1 += FONT_CHAR_TEX_SIZE; temp2 += (16.0f * msgCtx->unk12098); @@ -83,35 +84,35 @@ void Message_LoadCharNES(GlobalContext* globalCtx, u8 codePointIndex, s32* offse *arg3 = temp2; } -void Message_LoadPluralRupeesNES(GlobalContext* globalCtx, s16* decodedBufPos, s32* offset, f32* arg3) { - MessageContext* msgCtx = &globalCtx->msgCtx; +void Message_LoadPluralRupeesNES(PlayState* play, s16* decodedBufPos, s32* offset, f32* arg3) { + MessageContext* msgCtx = &play->msgCtx; s16 p = *decodedBufPos; s32 o = *offset; f32 f = *arg3; msgCtx->decodedBuffer.schar[p] = 0x20; p++; - Font_LoadCharNES(globalCtx, 'R', o); + Font_LoadCharNES(play, 'R', o); o += FONT_CHAR_TEX_SIZE; msgCtx->decodedBuffer.schar[p] = 'R'; p++; - Font_LoadCharNES(globalCtx, 'u', o); + Font_LoadCharNES(play, 'u', o); o += FONT_CHAR_TEX_SIZE; msgCtx->decodedBuffer.schar[p] = 'u'; p++; - Font_LoadCharNES(globalCtx, 'p', o); + Font_LoadCharNES(play, 'p', o); o += FONT_CHAR_TEX_SIZE; msgCtx->decodedBuffer.schar[p] = 'p'; p++; - Font_LoadCharNES(globalCtx, 'e', o); + Font_LoadCharNES(play, 'e', o); o += FONT_CHAR_TEX_SIZE; msgCtx->decodedBuffer.schar[p] = 'e'; p++; - Font_LoadCharNES(globalCtx, 'e', o); + Font_LoadCharNES(play, 'e', o); o += FONT_CHAR_TEX_SIZE; msgCtx->decodedBuffer.schar[p] = 'e'; p++; - Font_LoadCharNES(globalCtx, 's', o); + Font_LoadCharNES(play, 's', o); o += FONT_CHAR_TEX_SIZE; msgCtx->decodedBuffer.schar[p] = 's'; @@ -121,8 +122,8 @@ void Message_LoadPluralRupeesNES(GlobalContext* globalCtx, s16* decodedBufPos, s *arg3 = f; } -void Message_LoadLocalizedRupeesNES(GlobalContext* globalCtx, s16* decodedBufPos, s32* offset, f32* arg3) { - MessageContext* msgCtx = &globalCtx->msgCtx; +void Message_LoadLocalizedRupeesNES(PlayState* play, s16* decodedBufPos, s32* offset, f32* arg3) { + MessageContext* msgCtx = &play->msgCtx; s16 p = *decodedBufPos; s32 o = *offset; f32 f = *arg3; @@ -132,7 +133,7 @@ void Message_LoadLocalizedRupeesNES(GlobalContext* globalCtx, s16* decodedBufPos p++; for (j = 0; j < D_801D0710[gSaveContext.options.language - 1]; j++) { - Font_LoadCharNES(globalCtx, D_801D06F0[gSaveContext.options.language - 1][j], o); + Font_LoadCharNES(play, 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++; @@ -145,37 +146,37 @@ void Message_LoadLocalizedRupeesNES(GlobalContext* globalCtx, s16* decodedBufPos *arg3 = f; } -void Message_LoadRupeesNES(GlobalContext* globalCtx, s16* decodedBufPos, s32* offset, f32* arg3, s16 singular) { - MessageContext* msgCtx = &globalCtx->msgCtx; +void Message_LoadRupeesNES(PlayState* play, s16* decodedBufPos, s32* offset, f32* arg3, s16 singular) { + MessageContext* msgCtx = &play->msgCtx; s16 p = *decodedBufPos; s32 o = *offset; f32 f = *arg3; msgCtx->decodedBuffer.schar[p] = ' '; p++; - Font_LoadCharNES(globalCtx, 'R', o); + Font_LoadCharNES(play, 'R', o); o += FONT_CHAR_TEX_SIZE; msgCtx->decodedBuffer.schar[p] = 'R'; p++; - Font_LoadCharNES(globalCtx, 'u', o); + Font_LoadCharNES(play, 'u', o); o += FONT_CHAR_TEX_SIZE; msgCtx->decodedBuffer.schar[p] = 'u'; p++; - Font_LoadCharNES(globalCtx, 'p', o); + Font_LoadCharNES(play, 'p', o); o += FONT_CHAR_TEX_SIZE; msgCtx->decodedBuffer.schar[p] = 'p'; p++; - Font_LoadCharNES(globalCtx, 'e', o); + Font_LoadCharNES(play, 'e', o); o += FONT_CHAR_TEX_SIZE; msgCtx->decodedBuffer.schar[p] = 'e'; p++; - Font_LoadCharNES(globalCtx, 'e', o); + Font_LoadCharNES(play, 'e', o); o += FONT_CHAR_TEX_SIZE; msgCtx->decodedBuffer.schar[p] = 'e'; if (singular != 1) { p++; - Font_LoadCharNES(globalCtx, 's', o); + Font_LoadCharNES(play, 's', o); o += FONT_CHAR_TEX_SIZE; msgCtx->decodedBuffer.schar[p] = 's'; f += 16.0f * msgCtx->unk12098 * 6.0f; @@ -188,46 +189,49 @@ void Message_LoadRupeesNES(GlobalContext* globalCtx, s16* decodedBufPos, s32* of *arg3 = f; } -void Message_LoadTimeNES(GlobalContext* globalCtx, u8 arg1, s32* offset, f32* arg3, s16* decodedBufPos) { - MessageContext* msgCtx = &globalCtx->msgCtx; +void Message_LoadTimeNES(PlayState* play, u8 arg1, s32* offset, f32* arg3, s16* decodedBufPos) { + MessageContext* msgCtx = &play->msgCtx; s16 p = *decodedBufPos; s32 o = *offset; f32 f = *arg3; - u32 dayTime; + u32 timeLeft; s16 digits[4]; - f32 timeInMinutes; - s32 day; + f32 timeLeftInMinutes; s16 i; if (arg1 == 0xCF) { - day = gSaveContext.save.day; - dayTime = 0x40000 - ((day % 5) << 16) - (u16)(-0x4000 + gSaveContext.save.time); + // 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 { - dayTime = 0x10000 - (u16)(-0x4000 + gSaveContext.save.time); + // 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)); } - timeInMinutes = TIME_TO_MINUTES_F(dayTime); + + timeLeftInMinutes = TIME_TO_MINUTES_F(timeLeft); digits[0] = 0; - digits[1] = (timeInMinutes / 60.0f); + digits[1] = (timeLeftInMinutes / 60.0f); while (digits[1] >= 10) { digits[0]++; digits[1] -= 10; } digits[2] = 0; - digits[3] = (s32)timeInMinutes % 60; + 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); + Font_LoadCharNES(play, digits[i] + '0', o); o += FONT_CHAR_TEX_SIZE; msgCtx->decodedBuffer.schar[p] = digits[i] + '0'; p++; if (i == 1) { - Font_LoadCharNES(globalCtx, ':', o); + Font_LoadCharNES(play, ':', o); o += FONT_CHAR_TEX_SIZE; msgCtx->decodedBuffer.schar[p] = ':'; p++; @@ -240,8 +244,8 @@ void Message_LoadTimeNES(GlobalContext* globalCtx, u8 arg1, s32* offset, f32* ar *arg3 = f; } -void Message_LoadAreaTextNES(GlobalContext* globalCtx, s32* offset, f32* arg2, s16* decodedBufPos) { - MessageContext* msgCtx = &globalCtx->msgCtx; +void Message_LoadAreaTextNES(PlayState* play, s32* offset, f32* arg2, s16* decodedBufPos) { + MessageContext* msgCtx = &play->msgCtx; s16 p = *decodedBufPos; s32 o = *offset; f32 f = *arg2; @@ -250,10 +254,10 @@ void Message_LoadAreaTextNES(GlobalContext* globalCtx, s32* offset, f32* arg2, s s16 currentArea; s16 stringLimit; - if ((func_8010A0A4(globalCtx) != 0) || (globalCtx->sceneNum == SCENE_SECOM)) { + if ((func_8010A0A4(play) != 0) || (play->sceneNum == SCENE_SECOM)) { currentArea = 10; } else { - currentArea = globalCtx->pauseCtx.unk_238[4]; + currentArea = play->pauseCtx.unk_238[PAUSE_WORLD_MAP]; } stringLimit = D_801D07C4[currentArea]; @@ -261,7 +265,7 @@ void Message_LoadAreaTextNES(GlobalContext* globalCtx, s32* offset, f32* arg2, s msgCtx->decodedBuffer.schar[p] = D_801D0714[currentArea][i]; currentChar = msgCtx->decodedBuffer.schar[p]; if (currentChar != ' ') { - Font_LoadCharNES(globalCtx, D_801D0714[currentArea][i], o); + Font_LoadCharNES(play, D_801D0714[currentArea][i], o); o += FONT_CHAR_TEX_SIZE; } currentChar = msgCtx->decodedBuffer.schar[p]; diff --git a/src/code/z_message_staff.c b/src/code/z_message_staff.c index 6620f88d5..ab30a3d9c 100644 --- a/src/code/z_message_staff.c +++ b/src/code/z_message_staff.c @@ -1,8 +1,8 @@ #include "global.h" #include "message_data_static.h" -void Message_FindCreditsMessage(GlobalContext* globalCtx, u16 textId) { - MessageContext* msgCtx = &globalCtx->msgCtx; +void Message_FindCreditsMessage(PlayState* play, u16 textId) { + MessageContext* msgCtx = &play->msgCtx; Font* font = &msgCtx->font; MessageTableEntry* msgEntry = msgCtx->messageTableStaff; const char* segment = msgEntry->segment; diff --git a/src/code/z_olib.c b/src/code/z_olib.c index 6f1cdbc55..2b6b8d139 100644 --- a/src/code/z_olib.c +++ b/src/code/z_olib.c @@ -123,14 +123,14 @@ VecSph* OLib_Vec3fToVecSph(VecSph* dest, Vec3f* vec) { if ((dist == 0.0f) && (vec->y == 0.0f)) { sph.pitch = 0; } else { - sph.pitch = DEGF_TO_BINANG(RADF_TO_DEGF(func_80086B30(dist, vec->y))); + sph.pitch = CAM_DEG_TO_BINANG(RADF_TO_DEGF(func_80086B30(dist, vec->y))); } sph.r = sqrtf(SQ(vec->y) + distSquared); if ((vec->x == 0.0f) && (vec->z == 0.0f)) { sph.yaw = 0; } else { - sph.yaw = DEGF_TO_BINANG(RADF_TO_DEGF(func_80086B30(vec->x, vec->z))); + sph.yaw = CAM_DEG_TO_BINANG(RADF_TO_DEGF(func_80086B30(vec->x, vec->z))); } *dest = sph; @@ -238,8 +238,8 @@ Vec3s* OLib_Vec3fDiffBinAng(Vec3s* dest, Vec3f* a, Vec3f* b) { OLib_Vec3fDiffRad(&anglesRad, a, b); - anglesBinAng.x = DEGF_TO_BINANG(RADF_TO_DEGF(anglesRad.x)); - anglesBinAng.y = DEGF_TO_BINANG(RADF_TO_DEGF(anglesRad.y)); + anglesBinAng.x = CAM_DEG_TO_BINANG(RADF_TO_DEGF(anglesRad.x)); + anglesBinAng.y = CAM_DEG_TO_BINANG(RADF_TO_DEGF(anglesRad.y)); anglesBinAng.z = 0.0f; *dest = anglesBinAng; diff --git a/src/code/z_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_parameter.c b/src/code/z_parameter.c index 44b1de152..b63af9038 100644 --- a/src/code/z_parameter.c +++ b/src/code/z_parameter.c @@ -1,4 +1,225 @@ #include "global.h" +#include "interface/parameter_static/parameter_static.h" +#include "interface/do_action_static/do_action_static.h" +#include "misc/story_static/story_static.h" +#include "overlays/kaleido_scope/ovl_kaleido_scope/z_kaleido_scope.h" + +typedef struct { + /* 0x00 */ u8 scene; + /* 0x01 */ u8 flags1; + /* 0x02 */ u8 flags2; + /* 0x03 */ u8 flags3; +} RestrictionFlags; + +Input D_801F5850[4]; + +RestrictionFlags sRestrictionFlags[] = { + { SCENE_20SICHITAI2, 0x00, 0x00, 0x00 }, + { SCENE_UNSET_1, 0x00, 0x00, 0x00 }, + { SCENE_UNSET_2, 0x00, 0x00, 0x00 }, + { SCENE_UNSET_3, 0x00, 0x00, 0x00 }, + { SCENE_UNSET_4, 0x00, 0x00, 0x00 }, + { SCENE_UNSET_5, 0x00, 0x00, 0x00 }, + { SCENE_UNSET_6, 0x00, 0x00, 0x00 }, + { SCENE_KAKUSIANA, 0x00, 0x00, 0x00 }, + { SCENE_SPOT00, 0x00, 0x00, 0x00 }, + { SCENE_UNSET_9, 0x00, 0x00, 0x00 }, + { SCENE_WITCH_SHOP, 0x10, 0x30, 0xC1 }, + { SCENE_LAST_BS, 0x00, 0x3F, 0x00 }, + { SCENE_HAKASHITA, 0x00, 0x00, 0x00 }, + { SCENE_AYASHIISHOP, 0x10, 0x30, 0xC1 }, + { SCENE_UNSET_E, 0x00, 0x00, 0x00 }, + { SCENE_UNSET_F, 0x00, 0x00, 0x00 }, + { SCENE_OMOYA, 0x00, 0x33, 0x00 }, + { SCENE_BOWLING, 0x10, 0x30, 0xC1 }, + { SCENE_SONCHONOIE, 0x10, 0x30, 0xC1 }, + { SCENE_IKANA, 0x00, 0x00, 0x00 }, + { SCENE_KAIZOKU, 0x00, 0x00, 0x00 }, + { SCENE_MILK_BAR, 0x10, 0x30, 0xC1 }, + { SCENE_INISIE_N, 0x00, 0x00, 0x00 }, + { SCENE_TAKARAYA, 0x10, 0x30, 0xC1 }, + { SCENE_INISIE_R, 0x00, 0x00, 0x00 }, + { SCENE_OKUJOU, 0x00, 0x3F, 0xF0 }, + { SCENE_OPENINGDAN, 0x00, 0x00, 0x00 }, + { SCENE_MITURIN, 0x00, 0x00, 0x00 }, + { SCENE_13HUBUKINOMITI, 0x00, 0x00, 0x00 }, + { SCENE_CASTLE, 0x00, 0x00, 0x00 }, + { SCENE_DEKUTES, 0x10, 0x30, 0x01 }, + { SCENE_MITURIN_BS, 0x00, 0x00, 0x00 }, + { SCENE_SYATEKI_MIZU, 0x10, 0x30, 0xC1 }, + { SCENE_HAKUGIN, 0x00, 0x00, 0x00 }, + { SCENE_ROMANYMAE, 0x00, 0x00, 0x00 }, + { SCENE_PIRATE, 0x00, 0x00, 0x00 }, + { SCENE_SYATEKI_MORI, 0x10, 0x30, 0xC1 }, + { SCENE_SINKAI, 0x00, 0x00, 0x00 }, + { SCENE_YOUSEI_IZUMI, 0x00, 0x00, 0x00 }, + { SCENE_KINSTA1, 0x00, 0x30, 0x00 }, + { SCENE_KINDAN2, 0x00, 0x30, 0x00 }, + { SCENE_TENMON_DAI, 0x00, 0x03, 0xC0 }, + { SCENE_LAST_DEKU, 0x00, 0x3F, 0x00 }, + { SCENE_22DEKUCITY, 0x00, 0x00, 0x00 }, + { SCENE_KAJIYA, 0x00, 0x30, 0xC0 }, + { SCENE_00KEIKOKU, 0x00, 0x00, 0x00 }, + { SCENE_POSTHOUSE, 0x00, 0x30, 0xC1 }, + { SCENE_LABO, 0x00, 0x30, 0xC1 }, + { SCENE_DANPEI2TEST, 0x00, 0x30, 0x00 }, + { SCENE_UNSET_31, 0x00, 0x00, 0x00 }, + { SCENE_16GORON_HOUSE, 0x00, 0x00, 0x00 }, + { SCENE_33ZORACITY, 0x00, 0x00, 0xC0 }, + { SCENE_8ITEMSHOP, 0x00, 0x30, 0xC1 }, + { SCENE_F01, 0x00, 0x00, 0x00 }, + { SCENE_INISIE_BS, 0x00, 0x00, 0x00 }, + { SCENE_30GYOSON, 0x00, 0x00, 0x00 }, + { SCENE_31MISAKI, 0x00, 0x00, 0x00 }, + { SCENE_TAKARAKUJI, 0x00, 0x30, 0xC1 }, + { SCENE_UNSET_3A, 0x00, 0x00, 0x00 }, + { SCENE_TORIDE, 0x00, 0x00, 0x00 }, + { SCENE_FISHERMAN, 0x00, 0x30, 0xC1 }, + { SCENE_GORONSHOP, 0x10, 0x30, 0xC1 }, + { SCENE_DEKU_KING, 0x00, 0x30, 0xC0 }, + { SCENE_LAST_GORON, 0x00, 0x3F, 0x00 }, + { SCENE_24KEMONOMITI, 0x00, 0x00, 0x00 }, + { SCENE_F01_B, 0x00, 0x30, 0x00 }, + { SCENE_F01C, 0x00, 0x30, 0x00 }, + { SCENE_BOTI, 0x00, 0x00, 0x00 }, + { SCENE_HAKUGIN_BS, 0x00, 0x00, 0x00 }, + { SCENE_20SICHITAI, 0x00, 0x00, 0x00 }, + { SCENE_21MITURINMAE, 0x00, 0x00, 0x00 }, + { SCENE_LAST_ZORA, 0x00, 0x3F, 0x00 }, + { SCENE_11GORONNOSATO2, 0x00, 0x00, 0x00 }, + { SCENE_SEA, 0x00, 0x00, 0x00 }, + { SCENE_35TAKI, 0x00, 0x00, 0x00 }, + { SCENE_REDEAD, 0x00, 0x00, 0x00 }, + { SCENE_BANDROOM, 0x00, 0x30, 0xC0 }, + { SCENE_11GORONNOSATO, 0x00, 0x00, 0x00 }, + { SCENE_GORON_HAKA, 0x00, 0x00, 0x00 }, + { SCENE_SECOM, 0x00, 0x3C, 0xC0 }, + { SCENE_10YUKIYAMANOMURA, 0x00, 0x00, 0x00 }, + { SCENE_TOUGITES, 0x00, 0x3F, 0xF0 }, + { SCENE_DANPEI, 0x00, 0x30, 0x00 }, + { SCENE_IKANAMAE, 0x00, 0x00, 0x00 }, + { SCENE_DOUJOU, 0x00, 0x30, 0xC1 }, + { SCENE_MUSICHOUSE, 0x00, 0x30, 0xC0 }, + { SCENE_IKNINSIDE, 0x00, 0x3F, 0xC0 }, + { SCENE_MAP_SHOP, 0x10, 0x30, 0xC1 }, + { SCENE_F40, 0x00, 0x00, 0x00 }, + { SCENE_F41, 0x00, 0x00, 0x00 }, + { SCENE_10YUKIYAMANOMURA2, 0x00, 0x00, 0x00 }, + { SCENE_14YUKIDAMANOMITI, 0x00, 0x00, 0x00 }, + { SCENE_12HAKUGINMAE, 0x00, 0x00, 0x00 }, + { SCENE_17SETUGEN, 0x00, 0x00, 0x00 }, + { SCENE_17SETUGEN2, 0x00, 0x00, 0x00 }, + { SCENE_SEA_BS, 0x00, 0x00, 0x00 }, + { SCENE_RANDOM, 0x00, 0x00, 0x00 }, + { SCENE_YADOYA, 0x10, 0x30, 0xC1 }, + { SCENE_KONPEKI_ENT, 0x00, 0x00, 0x00 }, + { SCENE_INSIDETOWER, 0x00, 0xFF, 0xC0 }, + { SCENE_26SARUNOMORI, 0x00, 0x30, 0x00 }, + { SCENE_LOST_WOODS, 0x00, 0x00, 0x00 }, + { SCENE_LAST_LINK, 0x00, 0x3F, 0x00 }, + { SCENE_SOUGEN, 0x00, 0x3F, 0x00 }, + { SCENE_BOMYA, 0x10, 0x30, 0xC1 }, + { SCENE_KYOJINNOMA, 0x00, 0x00, 0x00 }, + { SCENE_KOEPONARACE, 0x00, 0x30, 0x00 }, + { SCENE_GORONRACE, 0x00, 0x00, 0x00 }, + { SCENE_TOWN, 0x00, 0x00, 0x00 }, + { SCENE_ICHIBA, 0x00, 0x00, 0x00 }, + { SCENE_BACKTOWN, 0x00, 0x00, 0x00 }, + { SCENE_CLOCKTOWER, 0x00, 0x00, 0x00 }, + { SCENE_ALLEY, 0x00, 0x00, 0x00 }, +}; + +s16 D_801BF884 = 0; // pictoBox related +s16 D_801BF888 = false; // pictoBox related + +s16 sHBAScoreTier = 0; // Remnant of OoT, non-functional + +u16 sMinigameScoreDigits[] = { 0, 0, 0, 0 }; + +u16 sCUpInvisible = 0; +u16 sCUpTimer = 0; + +s16 sMagicBarOutlinePrimRed = 255; +s16 sMagicBarOutlinePrimGreen = 255; +s16 sMagicBarOutlinePrimBlue = 255; +s16 D_801BF8AC = 2; // sMagicBorderRatio +s16 D_801BF8B0 = 1; + +s16 sExtraItemBases[] = { + ITEM_STICK, // ITEM_STICKS_5 + ITEM_STICK, // ITEM_STICKS_10 + ITEM_NUT, // ITEM_NUTS_5 + ITEM_NUT, // ITEM_NUTS_10 + ITEM_BOMB, // ITEM_BOMBS_5 + ITEM_BOMB, // ITEM_BOMBS_10 + ITEM_BOMB, // ITEM_BOMBS_20 + ITEM_BOMB, // ITEM_BOMBS_30 + ITEM_BOW, // ITEM_ARROWS_10 + ITEM_BOW, // ITEM_ARROWS_30 + ITEM_BOW, // ITEM_ARROWS_40 + ITEM_BOMBCHU, // ITEM_ARROWS_50 !@bug this data is missing an ITEM_BOW, offsetting the rest by 1 + ITEM_BOMBCHU, // ITEM_BOMBCHUS_20 + ITEM_BOMBCHU, // ITEM_BOMBCHUS_10 + ITEM_BOMBCHU, // ITEM_BOMBCHUS_1 + ITEM_STICK, // ITEM_BOMBCHUS_5 + ITEM_STICK, // ITEM_STICK_UPGRADE_20 + ITEM_NUT, // ITEM_STICK_UPGRADE_30 + ITEM_NUT, // ITEM_NUT_UPGRADE_30 +}; + +s16 D_801BF8DC = 0; +s16 D_801BF8E0 = 0; +s16 D_801BF8E4 = 0; + +OSTime D_801BF8E8 = 0; +OSTime D_801BF8F0 = 0; +OSTime D_801BF8F8[] = { + 0, 0, 0, 0, 0, 0, 0, +}; +OSTime D_801BF930[] = { + 0, 0, 0, 0, 0, 0, 0, +}; + +u8 D_801BF968 = false; +u8 D_801BF96C = false; + +s16 D_801BF970 = 99; +s16 D_801BF974 = 0; +s16 D_801BF978 = 10; +s16 D_801BF97C = 255; +f32 D_801BF980 = 1.0f; +s32 D_801BF984 = 0; + +Gfx D_801BF988[] = { + gsDPPipeSync(), + gsSPClearGeometryMode(G_ZBUFFER | G_SHADE | G_CULL_BOTH | G_FOG | G_LIGHTING | G_TEXTURE_GEN | + G_TEXTURE_GEN_LINEAR | G_LOD | G_SHADING_SMOOTH), + gsDPSetOtherMode(G_AD_DISABLE | G_CD_MAGICSQ | G_CK_NONE | G_TC_FILT | G_TF_BILERP | G_TT_NONE | G_TL_TILE | + G_TD_CLAMP | G_TP_NONE | G_CYC_1CYCLE | G_PM_1PRIMITIVE, + G_AC_NONE | G_ZS_PIXEL | G_RM_CLD_SURF | G_RM_CLD_SURF2), + gsDPSetCombineMode(G_CC_PRIMITIVE, G_CC_PRIMITIVE), + gsSPEndDisplayList(), +}; + +s16 D_801BF9B0 = 0; +f32 D_801BF9B4[] = { 100.0f, 109.0f }; +s16 D_801BF9BC[] = { 0x226, 0x2A8, 0x2A8, 0x2A8 }; +s16 D_801BF9C4[] = { 0x9E, 0x9B }; +s16 D_801BF9C8[] = { 0x17, 0x16 }; +f32 D_801BF9CC[] = { -380.0f, -350.0f }; +s16 D_801BF9D4[] = { 0xA7, 0xE3 }; +s16 D_801BF9D8[] = { 0xF9, 0x10F }; +s16 D_801BF9DC[] = { 0x11, 0x12 }; +s16 D_801BF9E0[] = { 0x22, 0x12 }; +s16 D_801BF9E4[] = { 0x23F, 0x26C }; +s16 D_801BF9E8[] = { 0x26C, 0x26C }; + +s16 sFinalHoursClockDigitsRed = 0; +s16 sFinalHoursClockFrameEnvRed = 0; +s16 sFinalHoursClockFrameEnvGreen = 0; +s16 sFinalHoursClockFrameEnvBlue = 0; +s16 sFinalHoursClockColorTimer = 15; +s16 sFinalHoursClockColorTargetIndex = 0; #pragma GLOBAL_ASM("asm/non_matchings/code/z_parameter/func_8010CB80.s") @@ -18,8 +239,29 @@ #pragma GLOBAL_ASM("asm/non_matchings/code/z_parameter/func_8010DE38.s") +s16 D_801BFA04[] = { + -14, -14, -24, -8, -12, -12, -7, -8, -7, -8, -12, 0, +}; +s16 D_801BFA1C[] = { + 0x1C, 0x1C, 0x30, 0x10, 0x18, 0x18, 0x10, 0x10, 0x10, 0x10, 0x18, 0, +}; +s16 D_801BFA34[] = { + 14, 14, 8, 24, -82, -82, 58, 59, 58, 59, 32, 0, +}; +s16 D_801BFA4C[] = { + 0x1C, 0x1C, 0x10, 0x10, 0x18, 0x18, 0xB, 0xB, 0xB, 0xB, 0x20, 0, +}; +s16 D_801BFA64[] = { + -61, -45, 29, 104, -117, -42, 32, 55, +}; +s16 D_801BFA74[] = { + 1, -70, -99, -70, 71, 101, 72, 1, +}; + #pragma GLOBAL_ASM("asm/non_matchings/code/z_parameter/func_8010E028.s") +s32 D_801BFA84 = 0; + #pragma GLOBAL_ASM("asm/non_matchings/code/z_parameter/func_8010E968.s") #pragma GLOBAL_ASM("asm/non_matchings/code/z_parameter/func_8010E9F0.s") @@ -28,6 +270,7 @@ #pragma GLOBAL_ASM("asm/non_matchings/code/z_parameter/func_8010EB50.s") +void func_8010EBA0(s16 timer, s16 timerId); #pragma GLOBAL_ASM("asm/non_matchings/code/z_parameter/func_8010EBA0.s") #pragma GLOBAL_ASM("asm/non_matchings/code/z_parameter/func_8010EC54.s") @@ -52,38 +295,755 @@ #pragma GLOBAL_ASM("asm/non_matchings/code/z_parameter/func_80112AFC.s") -#pragma GLOBAL_ASM("asm/non_matchings/code/z_parameter/func_80112B40.s") +#pragma GLOBAL_ASM("asm/non_matchings/code/z_parameter/Interface_LoadItemIconImpl.s") -#pragma GLOBAL_ASM("asm/non_matchings/code/z_parameter/func_80112BE4.s") +#pragma GLOBAL_ASM("asm/non_matchings/code/z_parameter/Interface_LoadItemIcon.s") #pragma GLOBAL_ASM("asm/non_matchings/code/z_parameter/func_80112C0C.s") -#pragma GLOBAL_ASM("asm/non_matchings/code/z_parameter/Item_Give.s") +s16 sAmmoRefillCounts[] = { 5, 10, 20, 30 }; // Sticks, nuts, bombs +s16 sArrowRefillCounts[] = { 10, 30, 40, 50 }; +s16 sBombchuRefillCounts[] = { 20, 10, 1, 5 }; +s16 sRupeeRefillCounts[] = { 1, 5, 10, 20, 50, 100, 200 }; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_parameter/func_801143CC.s") +u8 Item_Give(PlayState* play, u8 item) { + Player* player = GET_PLAYER(play); + u8 i; + u8 temp; + u8 slot; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_parameter/func_80114978.s") + slot = SLOT(item); + if (item >= ITEM_STICKS_5) { + slot = SLOT(sExtraItemBases[item - ITEM_STICKS_5]); + } -#pragma GLOBAL_ASM("asm/non_matchings/code/z_parameter/func_801149A0.s") + if (item == ITEM_SKULL_TOKEN) { + SET_QUEST_ITEM(item - ITEM_SKULL_TOKEN + QUEST_SKULL_TOKEN); + Inventory_IncrementSkullTokenCount(play->sceneNum); + return ITEM_NONE; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_parameter/func_80114A9C.s") + } else if (item == ITEM_TINGLE_MAP) { + return ITEM_NONE; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_parameter/func_80114B84.s") + } else if (item == ITEM_BOMBERS_NOTEBOOK) { + SET_QUEST_ITEM(QUEST_BOMBERS_NOTEBOOK); + return ITEM_NONE; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_parameter/func_80114CA0.s") + } else if ((item == ITEM_HEART_PIECE_2) || (item == ITEM_HEART_PIECE)) { + INCREMENT_QUEST_HEART_PIECE_COUNT; + if (EQ_MAX_QUEST_HEART_PIECE_COUNT) { + RESET_HEART_PIECE_COUNT; + gSaveContext.save.playerData.healthCapacity += 0x10; + gSaveContext.save.playerData.health += 0x10; + } + return ITEM_NONE; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_parameter/Interface_HasEmptyBottle.s") + } else if (item == ITEM_HEART_CONTAINER) { + gSaveContext.save.playerData.healthCapacity += 0x10; + gSaveContext.save.playerData.health += 0x10; + return ITEM_NONE; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_parameter/Interface_HasItemInBottle.s") + } else if ((item >= ITEM_SONG_SONATA) && (item <= ITEM_SONG_LULLABY_INTRO)) { + SET_QUEST_ITEM(item - ITEM_SONG_SONATA + QUEST_SONG_SONATA); + return ITEM_NONE; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_parameter/func_80114FD0.s") + } else if ((item >= ITEM_SWORD_KOKIRI) && (item <= ITEM_SWORD_GILDED)) { + SET_EQUIP_VALUE(EQUIP_TYPE_SWORD, item - ITEM_SWORD_KOKIRI + EQUIP_VALUE_SWORD_KOKIRI); + BUTTON_ITEM_EQUIP(CUR_FORM, EQUIP_SLOT_B) = item; + Interface_LoadItemIconImpl(play, EQUIP_SLOT_B); + if (item == ITEM_SWORD_RAZOR) { + gSaveContext.save.playerData.swordHealth = 100; + } + return ITEM_NONE; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_parameter/func_80115130.s") + } else if ((item >= ITEM_SHIELD_HERO) && (item <= ITEM_SHIELD_MIRROR)) { + if (GET_CUR_EQUIP_VALUE(EQUIP_TYPE_SHIELD) != (u16)(item - ITEM_SHIELD_HERO + EQUIP_VALUE_SHIELD_HERO)) { + SET_EQUIP_VALUE(EQUIP_TYPE_SHIELD, item - ITEM_SHIELD_HERO + EQUIP_VALUE_SHIELD_HERO); + Player_SetEquipmentData(play, player); + return ITEM_NONE; + } + return item; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_parameter/func_801152B8.s") + } else if ((item == ITEM_KEY_BOSS) || (item == ITEM_COMPASS) || (item == ITEM_DUNGEON_MAP)) { + SET_DUNGEON_ITEM(item - ITEM_KEY_BOSS, gSaveContext.mapIndex); + return ITEM_NONE; + + } else if (item == ITEM_KEY_SMALL) { + if (DUNGEON_KEY_COUNT(gSaveContext.mapIndex) < 0) { + DUNGEON_KEY_COUNT(gSaveContext.mapIndex) = 1; + return ITEM_NONE; + } else { + DUNGEON_KEY_COUNT(gSaveContext.mapIndex)++; + return ITEM_NONE; + } + + } else if ((item == ITEM_QUIVER_30) || (item == ITEM_BOW)) { + if (CUR_UPG_VALUE(UPG_QUIVER) == 0) { + Inventory_ChangeUpgrade(UPG_QUIVER, 1); + INV_CONTENT(ITEM_BOW) = ITEM_BOW; + AMMO(ITEM_BOW) = CAPACITY(UPG_QUIVER, 1); + return ITEM_NONE; + } else { + AMMO(ITEM_BOW)++; + if (AMMO(ITEM_BOW) > (s8)CUR_CAPACITY(UPG_QUIVER)) { + AMMO(ITEM_BOW) = CUR_CAPACITY(UPG_QUIVER); + } + } + + } else if (item == ITEM_QUIVER_40) { + Inventory_ChangeUpgrade(UPG_QUIVER, 2); + INV_CONTENT(ITEM_BOW) = ITEM_BOW; + AMMO(ITEM_BOW) = CAPACITY(UPG_QUIVER, 2); + return ITEM_NONE; + + } else if (item == ITEM_QUIVER_50) { + Inventory_ChangeUpgrade(UPG_QUIVER, 3); + INV_CONTENT(ITEM_BOW) = ITEM_BOW; + AMMO(ITEM_BOW) = CAPACITY(UPG_QUIVER, 3); + return ITEM_NONE; + + } else if (item == ITEM_BOMB_BAG_20) { + if (CUR_UPG_VALUE(UPG_BOMB_BAG) == 0) { + Inventory_ChangeUpgrade(UPG_BOMB_BAG, 1); + INV_CONTENT(ITEM_BOMB) = ITEM_BOMB; + AMMO(ITEM_BOMB) = CAPACITY(UPG_BOMB_BAG, 1); + return ITEM_NONE; + + } else { + AMMO(ITEM_BOMB)++; + if (AMMO(ITEM_BOMB) > CUR_CAPACITY(UPG_BOMB_BAG)) { + AMMO(ITEM_BOMB) = CUR_CAPACITY(UPG_BOMB_BAG); + } + } + + } else if (item == ITEM_BOMB_BAG_30) { + Inventory_ChangeUpgrade(UPG_BOMB_BAG, 2); + INV_CONTENT(ITEM_BOMB) = ITEM_BOMB; + AMMO(ITEM_BOMB) = CAPACITY(UPG_BOMB_BAG, 2); + return ITEM_NONE; + + } else if (item == ITEM_BOMB_BAG_40) { + Inventory_ChangeUpgrade(UPG_BOMB_BAG, 3); + INV_CONTENT(ITEM_BOMB) = ITEM_BOMB; + AMMO(ITEM_BOMB) = CAPACITY(UPG_BOMB_BAG, 3); + return ITEM_NONE; + + } else if (item == ITEM_WALLET_ADULT) { + Inventory_ChangeUpgrade(UPG_WALLET, 1); + return ITEM_NONE; + + } else if (item == ITEM_WALLET_GIANT) { + Inventory_ChangeUpgrade(UPG_WALLET, 2); + return ITEM_NONE; + + } else if (item == ITEM_STICK_UPGRADE_20) { + if (INV_CONTENT(ITEM_STICK) != ITEM_STICK) { + INV_CONTENT(ITEM_STICK) = ITEM_STICK; + } + Inventory_ChangeUpgrade(UPG_STICKS, 2); + AMMO(ITEM_STICK) = CAPACITY(UPG_STICKS, 2); + return ITEM_NONE; + + } else if (item == ITEM_STICK_UPGRADE_30) { + if (INV_CONTENT(ITEM_STICK) != ITEM_STICK) { + INV_CONTENT(ITEM_STICK) = ITEM_STICK; + } + Inventory_ChangeUpgrade(UPG_STICKS, 3); + AMMO(ITEM_STICK) = CAPACITY(UPG_STICKS, 3); + return ITEM_NONE; + + } else if (item == ITEM_NUT_UPGRADE_30) { + if (INV_CONTENT(ITEM_NUT) != ITEM_NUT) { + INV_CONTENT(ITEM_NUT) = ITEM_NUT; + } + Inventory_ChangeUpgrade(UPG_NUTS, 2); + AMMO(ITEM_NUT) = CAPACITY(UPG_NUTS, 2); + return ITEM_NONE; + + } else if (item == ITEM_NUT_UPGRADE_40) { + if (INV_CONTENT(ITEM_NUT) != ITEM_NUT) { + INV_CONTENT(ITEM_NUT) = ITEM_NUT; + } + Inventory_ChangeUpgrade(UPG_NUTS, 3); + AMMO(ITEM_NUT) = CAPACITY(UPG_NUTS, 3); + return ITEM_NONE; + + } else if (item == ITEM_STICK) { + if (INV_CONTENT(ITEM_STICK) != ITEM_STICK) { + Inventory_ChangeUpgrade(UPG_STICKS, 1); + AMMO(ITEM_STICK) = 1; + } else { + AMMO(ITEM_STICK)++; + if (AMMO(ITEM_STICK) > CUR_CAPACITY(UPG_STICKS)) { + AMMO(ITEM_STICK) = CUR_CAPACITY(UPG_STICKS); + } + } + + } else if ((item == ITEM_STICKS_5) || (item == ITEM_STICKS_10)) { + if (INV_CONTENT(ITEM_STICK) != ITEM_STICK) { + Inventory_ChangeUpgrade(UPG_STICKS, 1); + AMMO(ITEM_STICK) = sAmmoRefillCounts[item - ITEM_STICKS_5]; + } else { + AMMO(ITEM_STICK) += sAmmoRefillCounts[item - ITEM_STICKS_5]; + if (AMMO(ITEM_STICK) > CUR_CAPACITY(UPG_STICKS)) { + AMMO(ITEM_STICK) = CUR_CAPACITY(UPG_STICKS); + } + } + + item = ITEM_STICK; + + } else if (item == ITEM_NUT) { + if (INV_CONTENT(ITEM_NUT) != ITEM_NUT) { + Inventory_ChangeUpgrade(UPG_NUTS, 1); + AMMO(ITEM_NUT) = 1; + } else { + AMMO(ITEM_NUT)++; + if (AMMO(ITEM_NUT) > CUR_CAPACITY(UPG_NUTS)) { + AMMO(ITEM_NUT) = CUR_CAPACITY(UPG_NUTS); + } + } + + } else if ((item == ITEM_NUTS_5) || (item == ITEM_NUTS_10)) { + if (INV_CONTENT(ITEM_NUT) != ITEM_NUT) { + Inventory_ChangeUpgrade(UPG_NUTS, 1); + AMMO(ITEM_NUT) += sAmmoRefillCounts[item - ITEM_NUTS_5]; + } else { + AMMO(ITEM_NUT) += sAmmoRefillCounts[item - ITEM_NUTS_5]; + if (AMMO(ITEM_NUT) > CUR_CAPACITY(UPG_NUTS)) { + AMMO(ITEM_NUT) = CUR_CAPACITY(UPG_NUTS); + } + } + item = ITEM_NUT; + + } else if (item == ITEM_POWDER_KEG) { + if (INV_CONTENT(ITEM_POWDER_KEG) != ITEM_POWDER_KEG) { + INV_CONTENT(ITEM_POWDER_KEG) = ITEM_POWDER_KEG; + } + + AMMO(ITEM_POWDER_KEG) = 1; + return ITEM_NONE; + + } else if (item == ITEM_BOMB) { + if ((AMMO(ITEM_BOMB) += 1) > CUR_CAPACITY(UPG_BOMB_BAG)) { + AMMO(ITEM_BOMB) = CUR_CAPACITY(UPG_BOMB_BAG); + } + return ITEM_NONE; + + } else if ((item >= ITEM_BOMBS_5) && (item <= ITEM_BOMBS_30)) { + if (gSaveContext.save.inventory.items[SLOT_BOMB] != ITEM_BOMB) { + INV_CONTENT(ITEM_BOMB) = ITEM_BOMB; + AMMO(ITEM_BOMB) += sAmmoRefillCounts[item - ITEM_BOMBS_5]; + return ITEM_NONE; + } + + if ((AMMO(ITEM_BOMB) += sAmmoRefillCounts[item - ITEM_BOMBS_5]) > CUR_CAPACITY(UPG_BOMB_BAG)) { + AMMO(ITEM_BOMB) = CUR_CAPACITY(UPG_BOMB_BAG); + } + return ITEM_NONE; + + } else if (item == ITEM_BOMBCHU) { + if (INV_CONTENT(ITEM_BOMBCHU) != ITEM_BOMBCHU) { + INV_CONTENT(ITEM_BOMBCHU) = ITEM_BOMBCHU; + AMMO(ITEM_BOMBCHU) = 10; + return ITEM_NONE; + } + if ((AMMO(ITEM_BOMBCHU) += 10) > CUR_CAPACITY(UPG_BOMB_BAG)) { + AMMO(ITEM_BOMBCHU) = CUR_CAPACITY(UPG_BOMB_BAG); + } + return ITEM_NONE; + + } else if ((item >= ITEM_BOMBCHUS_20) && (item <= ITEM_BOMBCHUS_5)) { + if (gSaveContext.save.inventory.items[SLOT_BOMBCHU] != ITEM_BOMBCHU) { + INV_CONTENT(ITEM_BOMBCHU) = ITEM_BOMBCHU; + AMMO(ITEM_BOMBCHU) += sBombchuRefillCounts[item - ITEM_BOMBCHUS_20]; + + if (AMMO(ITEM_BOMBCHU) > CUR_CAPACITY(UPG_BOMB_BAG)) { + AMMO(ITEM_BOMBCHU) = CUR_CAPACITY(UPG_BOMB_BAG); + } + return ITEM_NONE; + } + + if ((AMMO(ITEM_BOMBCHU) += sBombchuRefillCounts[item - ITEM_BOMBCHUS_20]) > CUR_CAPACITY(UPG_BOMB_BAG)) { + AMMO(ITEM_BOMBCHU) = CUR_CAPACITY(UPG_BOMB_BAG); + } + return ITEM_NONE; + + } else if ((item >= ITEM_ARROWS_10) && (item <= ITEM_ARROWS_50)) { + AMMO(ITEM_BOW) += sArrowRefillCounts[item - ITEM_ARROWS_10]; + + if ((AMMO(ITEM_BOW) >= CUR_CAPACITY(UPG_QUIVER)) || (AMMO(ITEM_BOW) < 0)) { + AMMO(ITEM_BOW) = CUR_CAPACITY(UPG_QUIVER); + } + return ITEM_BOW; + + } else if (item == ITEM_OCARINA) { + INV_CONTENT(ITEM_OCARINA) = ITEM_OCARINA; + return ITEM_NONE; + + } else if (item == ITEM_MAGIC_BEANS) { + if (INV_CONTENT(ITEM_MAGIC_BEANS) == ITEM_NONE) { + INV_CONTENT(item) = item; + AMMO(ITEM_MAGIC_BEANS) = 1; + } else if (AMMO(ITEM_MAGIC_BEANS) < 20) { + AMMO(ITEM_MAGIC_BEANS)++; + } else { + AMMO(ITEM_MAGIC_BEANS) = 20; + } + return ITEM_NONE; + + } else if ((item >= ITEM_REMAINS_ODOLWA) && (item <= ITEM_REMAINS_TWINMOLD)) { + SET_QUEST_ITEM(item - ITEM_REMAINS_ODOLWA + QUEST_REMAINS_ODOWLA); + return ITEM_NONE; + + } else if (item == ITEM_RECOVERY_HEART) { + Health_ChangeBy(play, 0x10); + return item; + + } else if (item == ITEM_MAGIC_SMALL) { + Parameter_AddMagic(play, 0x18); + if (!(gSaveContext.save.weekEventReg[12] & 0x80)) { + gSaveContext.save.weekEventReg[12] |= 0x80; + return ITEM_NONE; + } + return item; + + } else if (item == ITEM_MAGIC_LARGE) { + Parameter_AddMagic(play, 0x30); + if (!(gSaveContext.save.weekEventReg[12] & 0x80)) { + gSaveContext.save.weekEventReg[12] |= 0x80; + return ITEM_NONE; + } + return item; + + } else if ((item >= ITEM_RUPEE_GREEN) && (item <= ITEM_RUPEE_HUGE)) { + Rupees_ChangeBy(sRupeeRefillCounts[item - ITEM_RUPEE_GREEN]); + return ITEM_NONE; + + } else if (item == ITEM_LONGSHOT) { + slot = SLOT(item); + + for (i = BOTTLE_FIRST; i < BOTTLE_MAX; i++) { + if (gSaveContext.save.inventory.items[slot + i] == ITEM_NONE) { + gSaveContext.save.inventory.items[slot + i] = ITEM_POTION_RED; + return ITEM_NONE; + } + } + return item; + + } else if ((item == ITEM_MILK_BOTTLE) || (item == ITEM_POE) || (item == ITEM_GOLD_DUST) || (item == ITEM_CHATEAU) || + (item == ITEM_HYLIAN_LOACH)) { + slot = SLOT(item); + + for (i = BOTTLE_FIRST; i < BOTTLE_MAX; i++) { + if (gSaveContext.save.inventory.items[slot + i] == ITEM_NONE) { + gSaveContext.save.inventory.items[slot + i] = item; + return ITEM_NONE; + } + } + return item; + + } else if (item == ITEM_BOTTLE) { + slot = SLOT(item); + + for (i = BOTTLE_FIRST; i < BOTTLE_MAX; i++) { + if (gSaveContext.save.inventory.items[slot + i] == ITEM_NONE) { + gSaveContext.save.inventory.items[slot + i] = item; + return ITEM_NONE; + } + } + return item; + + } else if (((item >= ITEM_POTION_RED) && (item <= ITEM_OBABA_DRINK)) || (item == ITEM_CHATEAU_2) || + (item == ITEM_MILK) || (item == ITEM_GOLD_DUST_2) || (item == ITEM_HYLIAN_LOACH_2) || + (item == ITEM_SEAHORSE_CAUGHT)) { + slot = SLOT(item); + + if ((item != ITEM_MILK_BOTTLE) && (item != ITEM_MILK_HALF)) { + if (item == ITEM_CHATEAU_2) { + item = ITEM_CHATEAU; + + } else if (item == ITEM_MILK) { + item = ITEM_MILK_BOTTLE; + + } else if (item == ITEM_GOLD_DUST_2) { + item = ITEM_GOLD_DUST; + + } else if (item == ITEM_HYLIAN_LOACH_2) { + item = ITEM_HYLIAN_LOACH; + + } else if (item == ITEM_SEAHORSE_CAUGHT) { + item = ITEM_SEAHORSE; + } + slot = SLOT(item); + + for (i = BOTTLE_FIRST; i < BOTTLE_MAX; i++) { + if (gSaveContext.save.inventory.items[slot + i] == ITEM_BOTTLE) { + if (item == ITEM_HOT_SPRING_WATER) { + func_8010EBA0(60, i); + } + + if ((slot + i) == C_SLOT_EQUIP(0, EQUIP_SLOT_C_LEFT)) { + BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_C_LEFT) = item; + Interface_LoadItemIconImpl(play, EQUIP_SLOT_C_LEFT); + gSaveContext.buttonStatus[EQUIP_SLOT_C_LEFT] = BTN_ENABLED; + } else if ((slot + i) == C_SLOT_EQUIP(0, EQUIP_SLOT_C_DOWN)) { + BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_C_DOWN) = item; + Interface_LoadItemIconImpl(play, EQUIP_SLOT_C_DOWN); + gSaveContext.buttonStatus[EQUIP_SLOT_C_DOWN] = BTN_ENABLED; + } else if ((slot + i) == C_SLOT_EQUIP(0, EQUIP_SLOT_C_RIGHT)) { + BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_C_RIGHT) = item; + Interface_LoadItemIconImpl(play, EQUIP_SLOT_C_RIGHT); + gSaveContext.buttonStatus[EQUIP_SLOT_C_RIGHT] = BTN_ENABLED; + } + + gSaveContext.save.inventory.items[slot + i] = item; + return ITEM_NONE; + } + } + } else { + for (i = BOTTLE_FIRST; i < BOTTLE_MAX; i++) { + if (gSaveContext.save.inventory.items[slot + i] == ITEM_NONE) { + gSaveContext.save.inventory.items[slot + i] = item; + return ITEM_NONE; + } + } + } + + } else if ((item >= ITEM_MOON_TEAR) && (item <= ITEM_MASK_GIANT)) { + temp = INV_CONTENT(item); + INV_CONTENT(item) = item; + if ((item >= ITEM_MOON_TEAR) && (item <= ITEM_PENDANT_OF_MEMORIES) && (temp != ITEM_NONE)) { + for (i = EQUIP_SLOT_C_LEFT; i <= EQUIP_SLOT_C_RIGHT; i++) { + if (temp == GET_CUR_FORM_BTN_ITEM(i)) { + SET_CUR_FORM_BTN_ITEM(i, item); + Interface_LoadItemIconImpl(play, i); + return ITEM_NONE; + } + } + } + return ITEM_NONE; + } + + temp = gSaveContext.save.inventory.items[slot]; + INV_CONTENT(item) = item; + return temp; +} + +u8 Item_CheckObtainabilityImpl(u8 item) { + s16 i; + u8 slot; + u8 bottleSlot; + + slot = SLOT(item); + if (item >= ITEM_STICKS_5) { + slot = SLOT(sExtraItemBases[item - ITEM_STICKS_5]); + } + + if (item == ITEM_SKULL_TOKEN) { + return ITEM_NONE; + + } else if (item == ITEM_TINGLE_MAP) { + return ITEM_NONE; + + } else if (item == ITEM_BOMBERS_NOTEBOOK) { + return ITEM_NONE; + + } else if ((item >= ITEM_SWORD_KOKIRI) && (item <= ITEM_SWORD_GILDED)) { + return ITEM_NONE; + + } else if ((item >= ITEM_SHIELD_HERO) && (item <= ITEM_SHIELD_MIRROR)) { + return ITEM_NONE; + + } else if ((item == ITEM_KEY_BOSS) || (item == ITEM_COMPASS) || (item == ITEM_DUNGEON_MAP)) { + if (!CHECK_DUNGEON_ITEM(item - ITEM_KEY_BOSS, gSaveContext.mapIndex)) { + return ITEM_NONE; + } + return item; + + } else if (item == ITEM_KEY_SMALL) { + return ITEM_NONE; + + } else if ((item == ITEM_OCARINA) || (item == ITEM_BOMBCHU) || (item == ITEM_HOOKSHOT) || (item == ITEM_LENS) || + (item == ITEM_SWORD_GREAT_FAIRY) || (item == ITEM_PICTO_BOX)) { + if (INV_CONTENT(item) == ITEM_NONE) { + return ITEM_NONE; + } + return INV_CONTENT(item); + + } else if ((item >= ITEM_BOMBS_5) && (item == ITEM_BOMBS_30)) { + //! @bug: Should be a range check: (item <= ITEM_BOMBS_30) + if (CUR_UPG_VALUE(UPG_BOMB_BAG) == 0) { + return ITEM_NONE; + } + return 0; + + } else if ((item >= ITEM_BOMBCHUS_20) && (item <= ITEM_BOMBCHUS_5)) { + if (CUR_UPG_VALUE(UPG_BOMB_BAG) == 0) { + return ITEM_NONE; + } + return 0; + + } else if ((item == ITEM_QUIVER_30) || (item == ITEM_BOW)) { + if (CUR_UPG_VALUE(UPG_QUIVER) == 0) { + return ITEM_NONE; + } + return 0; + + } else if ((item == ITEM_QUIVER_40) || (item == ITEM_QUIVER_50)) { + return ITEM_NONE; + + } else if ((item == ITEM_BOMB_BAG_20) || (item == ITEM_BOMB)) { + if (CUR_UPG_VALUE(UPG_BOMB_BAG) == 0) { + return ITEM_NONE; + } + return 0; + + } else if ((item >= ITEM_STICK_UPGRADE_20) && (item <= ITEM_NUT_UPGRADE_40)) { + return ITEM_NONE; + + } else if ((item >= ITEM_BOMB_BAG_30) && (item <= ITEM_WALLET_GIANT)) { + return ITEM_NONE; + + } else if (item == ITEM_MAGIC_BEANS) { + return ITEM_NONE; + + } else if (item == ITEM_POWDER_KEG) { + return ITEM_NONE; + + } else if ((item == ITEM_HEART_PIECE_2) || (item == ITEM_HEART_PIECE)) { + return ITEM_NONE; + + } else if (item == ITEM_HEART_CONTAINER) { + return ITEM_NONE; + + } else if (item == ITEM_RECOVERY_HEART) { + return ITEM_RECOVERY_HEART; + + } else if ((item == ITEM_MAGIC_SMALL) || (item == ITEM_MAGIC_LARGE)) { + if (!(gSaveContext.save.weekEventReg[12] & 0x80)) { + return ITEM_NONE; + } + return item; + + } else if ((item >= ITEM_RUPEE_GREEN) && (item <= ITEM_RUPEE_HUGE)) { + return ITEM_NONE; + + } else if ((item >= ITEM_REMAINS_ODOLWA) && (item <= ITEM_REMAINS_TWINMOLD)) { + return ITEM_NONE; + + } else if (item == ITEM_LONGSHOT) { + return ITEM_NONE; + + } else if (item == ITEM_BOTTLE) { + return ITEM_NONE; + + } else if ((item == ITEM_MILK_BOTTLE) || (item == ITEM_POE) || (item == ITEM_GOLD_DUST) || (item == ITEM_CHATEAU) || + (item == ITEM_HYLIAN_LOACH)) { + return ITEM_NONE; + + } else if (((item >= ITEM_POTION_RED) && (item <= ITEM_OBABA_DRINK)) || (item == ITEM_CHATEAU_2) || + (item == ITEM_MILK) || (item == ITEM_GOLD_DUST_2) || (item == ITEM_HYLIAN_LOACH_2) || + (item == ITEM_SEAHORSE_CAUGHT)) { + bottleSlot = SLOT(item); + + if ((item != ITEM_MILK_BOTTLE) && (item != ITEM_MILK_HALF)) { + if (item == ITEM_CHATEAU_2) { + item = ITEM_CHATEAU; + + } else if (item == ITEM_MILK) { + item = ITEM_MILK_BOTTLE; + + } else if (item == ITEM_GOLD_DUST_2) { + item = ITEM_GOLD_DUST; + + } else if (item == ITEM_HYLIAN_LOACH_2) { + item = ITEM_HYLIAN_LOACH; + + } else if (item == ITEM_SEAHORSE_CAUGHT) { + item = ITEM_SEAHORSE; + } + bottleSlot = SLOT(item); + + for (i = BOTTLE_FIRST; i < BOTTLE_MAX; i++) { + if (gSaveContext.save.inventory.items[bottleSlot + i] == ITEM_BOTTLE) { + return ITEM_NONE; + } + } + } else { + for (i = BOTTLE_FIRST; i < BOTTLE_MAX; i++) { + if (gSaveContext.save.inventory.items[bottleSlot + i] == ITEM_NONE) { + return ITEM_NONE; + } + } + } + } else if ((item >= ITEM_MOON_TEAR) && (item <= ITEM_MASK_GIANT)) { + return ITEM_NONE; + } + + return gSaveContext.save.inventory.items[slot]; +} + +u8 Item_CheckObtainability(u8 item) { + return Item_CheckObtainabilityImpl(item); +} + +void Inventory_DeleteItem(s16 item, s16 slot) { + s16 btn; + + gSaveContext.save.inventory.items[slot] = ITEM_NONE; + + for (btn = EQUIP_SLOT_C_LEFT; btn <= EQUIP_SLOT_C_RIGHT; btn++) { + if (GET_CUR_FORM_BTN_ITEM(btn) == item) { + SET_CUR_FORM_BTN_ITEM(btn, ITEM_NONE); + SET_CUR_FORM_BTN_SLOT(btn, SLOT_NONE); + } + } +} + +void Inventory_UnequipItem(s16 item) { + s16 btn; + + for (btn = EQUIP_SLOT_C_LEFT; btn <= EQUIP_SLOT_C_RIGHT; btn++) { + if (GET_CUR_FORM_BTN_ITEM(btn) == item) { + SET_CUR_FORM_BTN_ITEM(btn, ITEM_NONE); + SET_CUR_FORM_BTN_SLOT(btn, SLOT_NONE); + } + } +} + +s32 Inventory_ReplaceItem(PlayState* play, u8 oldItem, u8 newItem) { + u8 i; + + for (i = 0; i < 24; i++) { + if (gSaveContext.save.inventory.items[i] == oldItem) { + gSaveContext.save.inventory.items[i] = newItem; + + for (i = EQUIP_SLOT_C_LEFT; i <= EQUIP_SLOT_C_RIGHT; i++) { + if (GET_CUR_FORM_BTN_ITEM(i) == oldItem) { + SET_CUR_FORM_BTN_ITEM(i, newItem); + Interface_LoadItemIconImpl(play, i); + break; + } + } + return true; + } + } + return false; +} + +void Inventory_UpdateDeitySwordEquip(PlayState* play) { + InterfaceContext* interfaceCtx = &play->interfaceCtx; + u8 btn; + + if (CUR_FORM == PLAYER_FORM_FIERCE_DEITY) { + interfaceCtx->unk_21C = 0; + interfaceCtx->bButtonDoAction = 0; + + // Is simply checking if (gSaveContext.save.playerForm == PLAYER_FORM_FIERCE_DEITY) + if ((((gSaveContext.save.playerForm > 0) && (gSaveContext.save.playerForm < 4)) + ? 1 + : gSaveContext.save.playerForm >> 1) == 0) { + BUTTON_ITEM_EQUIP(CUR_FORM, EQUIP_SLOT_B) = ITEM_SWORD_DEITY; + } else if (BUTTON_ITEM_EQUIP(CUR_FORM, EQUIP_SLOT_B) == ITEM_SWORD_DEITY) { + if (GET_CUR_EQUIP_VALUE(EQUIP_TYPE_SWORD) == EQUIP_VALUE_SWORD_NONE) { + BUTTON_ITEM_EQUIP(CUR_FORM, EQUIP_SLOT_B) = ITEM_NONE; + } else { + BUTTON_ITEM_EQUIP(CUR_FORM, EQUIP_SLOT_B) = + GET_CUR_EQUIP_VALUE(EQUIP_TYPE_SWORD) - EQUIP_VALUE_SWORD_KOKIRI + ITEM_SWORD_KOKIRI; + } + } + } + + for (btn = EQUIP_SLOT_B; btn <= EQUIP_SLOT_B; btn++) { + if ((GET_CUR_FORM_BTN_ITEM(btn) != ITEM_NONE) && (GET_CUR_FORM_BTN_ITEM(btn) != ITEM_FD)) { + Interface_LoadItemIconImpl(play, btn); + } + } +} + +s32 Inventory_HasEmptyBottle(void) { + s32 slot; + + for (slot = SLOT_BOTTLE_1; slot <= SLOT_BOTTLE_6; slot++) { + if (gSaveContext.save.inventory.items[slot] == ITEM_BOTTLE) { + return true; + } + } + return false; +} + +s32 Inventory_HasItemInBottle(u8 item) { + s32 slot; + + for (slot = SLOT_BOTTLE_1; slot <= SLOT_BOTTLE_6; slot++) { + if (gSaveContext.save.inventory.items[slot] == item) { + return true; + } + } + return false; +} + +void Inventory_UpdateBottleItem(PlayState* play, u8 item, u8 btn) { + gSaveContext.save.inventory.items[GET_CUR_FORM_BTN_SLOT(btn)] = item; + SET_CUR_FORM_BTN_ITEM(btn, item); + + Interface_LoadItemIconImpl(play, btn); + + play->pauseCtx.cursorItem[PAUSE_ITEM] = item; + gSaveContext.buttonStatus[btn] = BTN_ENABLED; + + if (item == ITEM_HOT_SPRING_WATER) { + func_8010EBA0(60, GET_CUR_FORM_BTN_SLOT(btn) - SLOT_BOTTLE_1); + } +} + +s32 Inventory_ConsumeFairy(PlayState* play) { + u8 bottleSlot = SLOT(ITEM_FAIRY); + u8 btn; + u8 i; + + for (i = BOTTLE_FIRST; i < BOTTLE_MAX; i++) { + if (gSaveContext.save.inventory.items[bottleSlot + i] == ITEM_FAIRY) { + for (btn = EQUIP_SLOT_C_LEFT; btn <= EQUIP_SLOT_C_RIGHT; btn++) { + if (GET_CUR_FORM_BTN_ITEM(btn) == ITEM_FAIRY) { + SET_CUR_FORM_BTN_ITEM(btn, ITEM_BOTTLE); + Interface_LoadItemIconImpl(play, btn); + bottleSlot = GET_CUR_FORM_BTN_SLOT(btn); + i = 0; + break; + } + } + gSaveContext.save.inventory.items[bottleSlot + i] = ITEM_BOTTLE; + return true; + } + } + + return false; +} + +/** + * Only used to equip Spring Water when Hot Spring Water timer runs out. + */ +void Inventory_UpdateItem(PlayState* play, s16 slot, s16 item) { + s16 btn; + + gSaveContext.save.inventory.items[slot] = item; + + for (btn = EQUIP_SLOT_C_LEFT; btn <= EQUIP_SLOT_C_RIGHT; btn++) { + if (GET_CUR_FORM_BTN_SLOT(btn) == slot) { + SET_CUR_FORM_BTN_ITEM(btn, item); + Interface_LoadItemIconImpl(play, btn); + } + } +} #pragma GLOBAL_ASM("asm/non_matchings/code/z_parameter/func_801153C8.s") +TexturePtr sDoActionTextures[] = { + gDoActionAttackENGTex, + gDoActionCheckENGTex, +}; + #pragma GLOBAL_ASM("asm/non_matchings/code/z_parameter/func_80115428.s") #pragma GLOBAL_ASM("asm/non_matchings/code/z_parameter/func_8011552C.s") @@ -94,13 +1054,96 @@ #pragma GLOBAL_ASM("asm/non_matchings/code/z_parameter/func_80115844.s") -#pragma GLOBAL_ASM("asm/non_matchings/code/z_parameter/func_80115908.s") +/** + * @return false if player is out of health + */ +s32 Health_ChangeBy(PlayState* play, s16 healthChange) { + if (healthChange > 0) { + play_sound(NA_SE_SY_HP_RECOVER); + } else if (gSaveContext.save.playerData.doubleDefense && (healthChange < 0)) { + healthChange >>= 1; + } -#pragma GLOBAL_ASM("asm/non_matchings/code/z_parameter/func_801159c0.s") + gSaveContext.save.playerData.health += healthChange; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_parameter/func_801159EC.s") + if (((void)0, gSaveContext.save.playerData.health) > ((void)0, gSaveContext.save.playerData.healthCapacity)) { + gSaveContext.save.playerData.health = gSaveContext.save.playerData.healthCapacity; + } -#pragma GLOBAL_ASM("asm/non_matchings/code/z_parameter/func_80115A14.s") + if (gSaveContext.save.playerData.health <= 0) { + gSaveContext.save.playerData.health = 0; + return false; + } else { + return true; + } +} + +void Health_GiveHearts(s16 hearts) { + gSaveContext.save.playerData.healthCapacity += hearts * 0x10; +} + +void Rupees_ChangeBy(s16 rupeeChange) { + gSaveContext.rupeeAccumulator += rupeeChange; +} + +void Inventory_ChangeAmmo(s16 item, s16 ammoChange) { + if (item == ITEM_STICK) { + AMMO(ITEM_STICK) += ammoChange; + + if (AMMO(ITEM_STICK) >= CUR_CAPACITY(UPG_STICKS)) { + AMMO(ITEM_STICK) = CUR_CAPACITY(UPG_STICKS); + } else if (AMMO(ITEM_STICK) < 0) { + AMMO(ITEM_STICK) = 0; + } + + } else if (item == ITEM_NUT) { + AMMO(ITEM_NUT) += ammoChange; + + if (AMMO(ITEM_NUT) >= CUR_CAPACITY(UPG_NUTS)) { + AMMO(ITEM_NUT) = CUR_CAPACITY(UPG_NUTS); + } else if (AMMO(ITEM_NUT) < 0) { + AMMO(ITEM_NUT) = 0; + } + + } else if (item == ITEM_BOMBCHU) { + AMMO(ITEM_BOMBCHU) += ammoChange; + + if (AMMO(ITEM_BOMBCHU) >= CUR_CAPACITY(UPG_BOMB_BAG)) { + AMMO(ITEM_BOMBCHU) = CUR_CAPACITY(UPG_BOMB_BAG); + } else if (AMMO(ITEM_BOMBCHU) < 0) { + AMMO(ITEM_BOMBCHU) = 0; + } + + } else if (item == ITEM_BOW) { + AMMO(ITEM_BOW) += ammoChange; + + if (AMMO(ITEM_BOW) >= CUR_CAPACITY(UPG_QUIVER)) { + AMMO(ITEM_BOW) = CUR_CAPACITY(UPG_QUIVER); + } else if (AMMO(ITEM_BOW) < 0) { + AMMO(ITEM_BOW) = 0; + } + + } else if (item == ITEM_BOMB) { + AMMO(ITEM_BOMB) += ammoChange; + + if (AMMO(ITEM_BOMB) >= CUR_CAPACITY(UPG_BOMB_BAG)) { + AMMO(ITEM_BOMB) = CUR_CAPACITY(UPG_BOMB_BAG); + } else if (AMMO(ITEM_BOMB) < 0) { + AMMO(ITEM_BOMB) = 0; + } + + } else if (item == ITEM_MAGIC_BEANS) { + AMMO(ITEM_MAGIC_BEANS) += ammoChange; + + } else if (item == ITEM_POWDER_KEG) { + AMMO(ITEM_POWDER_KEG) += ammoChange; + if (AMMO(ITEM_POWDER_KEG) >= 1) { + AMMO(ITEM_POWDER_KEG) = 1; + } else if (AMMO(ITEM_POWDER_KEG) < 0) { + AMMO(ITEM_POWDER_KEG) = 0; + } + } +} #pragma GLOBAL_ASM("asm/non_matchings/code/z_parameter/Parameter_AddMagic.s") @@ -110,6 +1153,13 @@ #pragma GLOBAL_ASM("asm/non_matchings/code/z_parameter/func_80116088.s") +s16 magicBorderColors[][3] = { + { 255, 255, 255 }, + { 150, 150, 150 }, +}; +s16 magicBorderIndices[] = { 0, 1, 1, 0 }; +s16 magicBorderColorTimerIndex[] = { 2, 1, 2, 1 }; + #pragma GLOBAL_ASM("asm/non_matchings/code/z_parameter/func_80116114.s") #pragma GLOBAL_ASM("asm/non_matchings/code/z_parameter/func_80116348.s") @@ -120,10 +1170,25 @@ #pragma GLOBAL_ASM("asm/non_matchings/code/z_parameter/func_801170B8.s") +TexturePtr cUpLabelTextures[] = { + gTatlCUpENGTex, gTatlCUpENGTex, gTatlCUpGERTex, gTatlCUpFRATex, gTatlCUpESPTex, +}; +s16 startButtonLeftPos[] = { + // Remnant of OoT + 130, 136, 136, 136, 136, +}; +s16 D_801BFAF4[] = { 0x1D, 0x1B }; +s16 D_801BFAF8[] = { 0x1B, 0x1B }; + #pragma GLOBAL_ASM("asm/non_matchings/code/z_parameter/func_80117100.s") +s16 D_801BFAFC[] = { 30, 24, 24, 24 }; + #pragma GLOBAL_ASM("asm/non_matchings/code/z_parameter/func_80117A20.s") +s16 D_801BFB04[] = { 0xA2, 0xE4, 0xFA, 0x110 }; +s16 D_801BFB0C[] = { 0x23, 0x23, 0x33, 0x23 }; + #pragma GLOBAL_ASM("asm/non_matchings/code/z_parameter/func_80117BD0.s") #pragma GLOBAL_ASM("asm/non_matchings/code/z_parameter/func_80118084.s") @@ -132,36 +1197,179 @@ #pragma GLOBAL_ASM("asm/non_matchings/code/z_parameter/func_80118BA4.s") +extern TexturePtr D_08095AC0; // gMagicArrowEquipEffectTex +s16 D_801BFB14[] = { 255, 100, 255, 0 }; // magicArrowEffectsR +s16 D_801BFB1C[] = { 0, 100, 255, 0 }; // magicArrowEffectsG +s16 D_801BFB24[] = { 0, 255, 100, 0 }; // magicArrowEffectsB + #pragma GLOBAL_ASM("asm/non_matchings/code/z_parameter/func_80119030.s") +s16 D_801BFB2C = 255; +s16 D_801BFB30 = 0; +s16 D_801BFB34 = 0; +u16 D_801BFB38[] = { + CLOCK_TIME(0, 0), CLOCK_TIME(1, 0), CLOCK_TIME(2, 0), CLOCK_TIME(3, 0), CLOCK_TIME(4, 0), + CLOCK_TIME(5, 0), CLOCK_TIME(6, 0), CLOCK_TIME(7, 0), CLOCK_TIME(8, 0), CLOCK_TIME(9, 0), + CLOCK_TIME(10, 0), CLOCK_TIME(11, 0), CLOCK_TIME(12, 0), CLOCK_TIME(13, 0), CLOCK_TIME(14, 0), + CLOCK_TIME(15, 0), CLOCK_TIME(16, 0), CLOCK_TIME(17, 0), CLOCK_TIME(18, 0), CLOCK_TIME(19, 0), + CLOCK_TIME(20, 0), CLOCK_TIME(21, 0), CLOCK_TIME(22, 0), CLOCK_TIME(23, 0), CLOCK_TIME(24, 0) - 1, +}; +TexturePtr D_801BFB6C[] = { + gThreeDayClockHour12Tex, gThreeDayClockHour1Tex, gThreeDayClockHour2Tex, gThreeDayClockHour3Tex, + gThreeDayClockHour4Tex, gThreeDayClockHour5Tex, gThreeDayClockHour6Tex, gThreeDayClockHour7Tex, + gThreeDayClockHour8Tex, gThreeDayClockHour9Tex, gThreeDayClockHour10Tex, gThreeDayClockHour11Tex, + gThreeDayClockHour12Tex, gThreeDayClockHour1Tex, gThreeDayClockHour2Tex, gThreeDayClockHour3Tex, + gThreeDayClockHour4Tex, gThreeDayClockHour5Tex, gThreeDayClockHour6Tex, gThreeDayClockHour7Tex, + gThreeDayClockHour8Tex, gThreeDayClockHour9Tex, gThreeDayClockHour10Tex, gThreeDayClockHour11Tex, +}; +s16 D_801BFBCC = 0; // color R +s16 D_801BFBD0 = 155; // color G +s16 D_801BFBD4 = 255; +s16 D_801BFBD8 = 0; +s16 D_801BFBDC = 0; +s16 D_801BFBE0 = 0; +s16 D_801BFBE4 = 0xF; +u32 D_801BFBE8 = 0; +s16 D_801BFBEC[] = { 100, 0 }; +s16 D_801BFBF0[] = { 205, 155 }; +s16 D_801BFBF4[] = { 255, 255 }; +s16 D_801BFBF8[] = { 30, 0 }; +s16 D_801BFBFC[] = { 30, 0 }; +s16 D_801BFC00[] = { 100, 0 }; +s16 D_801BFC04[] = { 255, 0 }; +s16 D_801BFC08[] = { 100, 0 }; +s16 D_801BFC0C[] = { 30, 0 }; +s16 D_801BFC10[] = { 100, 0 }; +TexturePtr D_801BFC14[] = { + gFinalHoursClockDigit0Tex, gFinalHoursClockDigit1Tex, gFinalHoursClockDigit2Tex, gFinalHoursClockDigit3Tex, + gFinalHoursClockDigit4Tex, gFinalHoursClockDigit5Tex, gFinalHoursClockDigit6Tex, gFinalHoursClockDigit7Tex, + gFinalHoursClockDigit8Tex, gFinalHoursClockDigit9Tex, gFinalHoursClockColonTex, +}; +s16 D_801BFC40[] = { + 127, 136, 144, 151, 160, 168, 175, 184, +}; + #pragma GLOBAL_ASM("asm/non_matchings/code/z_parameter/func_80119610.s") #pragma GLOBAL_ASM("asm/non_matchings/code/z_parameter/func_8011B4E0.s") +u16 D_801BFC50[] = { + 0xC000, 0xE000, 0x0000, 0x2000, 0xA000, 0x8000, 0x6000, 0x4000, +}; +s16 D_801BFC60[][3] = { + 255, 255, 255, 255, 165, 55, +}; + #pragma GLOBAL_ASM("asm/non_matchings/code/z_parameter/func_8011B5C0.s") +s16 D_801BFC6C[] = { + 78, 54, 29, 5, -18, -42, -67, -85, +}; +s16 D_801BFC7C[] = { + 180, 180, 180, 180, -180, -180, -180, -180, +}; +s16 D_801BFC8C[2][3] = { + { 255, 255, 255 }, + { 255, 165, 55 }, +}; + #pragma GLOBAL_ASM("asm/non_matchings/code/z_parameter/func_8011B9E0.s") +s16 D_801BFC98[] = { + 78, 54, 29, 5, -18, -42, -67, -85, +}; +u16 D_801BFCA8[] = { + 0xC000, 0xE000, 0x0000, 0x2000, 0xA000, 0x8000, 0x6000, 0x4000, +}; +s16 D_801BFCB8[2][3] = { + { 255, 255, 255 }, + { 255, 165, 55 }, +}; + #pragma GLOBAL_ASM("asm/non_matchings/code/z_parameter/func_8011BF70.s") +TexturePtr D_801BFCC4[] = { + gMinigameLetterPTex, gMinigameLetterETex, gMinigameLetterRTex, gMinigameLetterFTex, + gMinigameLetterETex, gMinigameLetterCTex, gMinigameLetterTTex, gMinigameExclamationTex, +}; + #pragma GLOBAL_ASM("asm/non_matchings/code/z_parameter/func_8011C4C4.s") #pragma GLOBAL_ASM("asm/non_matchings/code/z_parameter/func_8011C808.s") #pragma GLOBAL_ASM("asm/non_matchings/code/z_parameter/func_8011C898.s") +s16 D_801BFCE4 = 0; +s16 D_801BFCE8[] = { 0, 0, 0, 0, 0, 0, 0, 0 }; +s16 D_801BFCF8 = 99; +s16 D_801BFCFC[] = { + // timer digit width + 16, 25, 34, 42, 51, 60, 68, 77, +}; +s16 D_801BFD0C[] = { + // digit width + 9, 9, 8, 9, 9, 8, 9, 9, +}; + #pragma GLOBAL_ASM("asm/non_matchings/code/z_parameter/func_8011CA64.s") #pragma GLOBAL_ASM("asm/non_matchings/code/z_parameter/func_8011E3B4.s") #pragma GLOBAL_ASM("asm/non_matchings/code/z_parameter/func_8011E730.s") +// rupeeDigitsFirst +s16 D_801BFD1C[] = { 1, 0, 0, 0 }; +// rupeeDigitsCount +s16 D_801BFD24[] = { 2, 3, 3, 0 }; +// rupeeIconPrimColor +Color_RGB16 D_801BFD2C[] = { + { 200, 255, 100 }, + { 170, 170, 255 }, + { 255, 105, 105 }, +}; +// rupeeIconEnvColor +Color_RGB16 D_801BFD40[] = { + { 0, 80, 0 }, + { 10, 10, 80 }, + { 40, 10, 0 }, +}; +// minigameCountdownTexs +TexturePtr D_801BFD54[] = { + gMinigameCountdown3Tex, + gMinigameCountdown2Tex, + gMinigameCountdown1Tex, + gMinigameCountdownGoTex, +}; +// minigameCountdownTexHeights +s16 D_801BFD64[] = { 24, 24, 24, 40 }; +// minigameCountdownPrimColor +Color_RGB16 D_801BFD6C[] = { + { 100, 255, 100 }, + { 255, 255, 60 }, + { 255, 100, 0 }, + { 120, 170, 255 }, +}; +// grandma's story pictures +TexturePtr D_801BFD84[] = { + gStoryMaskFestivalTex, + gStoryGiantsLeavingTex, +}; +// grandma's story TLUT +TexturePtr D_801BFD8C[] = { + gStoryMaskFestivalTLUT, + gStoryGiantsLeavingTLUT, +}; + #pragma GLOBAL_ASM("asm/non_matchings/code/z_parameter/func_8011F0E0.s") #pragma GLOBAL_ASM("asm/non_matchings/code/z_parameter/func_80120F90.s") #pragma GLOBAL_ASM("asm/non_matchings/code/z_parameter/func_80121064.s") +u8 D_801BFD94 = 0; +s16 D_801BFD98 = 0; +s16 D_801BFD9C = 0; + #pragma GLOBAL_ASM("asm/non_matchings/code/z_parameter/func_801210E0.s") #pragma GLOBAL_ASM("asm/non_matchings/code/z_parameter/func_80121F94.s") diff --git a/src/code/z_path.c b/src/code/z_path.c index 0462a40cd..3c446d49a 100644 --- a/src/code/z_path.c +++ b/src/code/z_path.c @@ -1,10 +1,10 @@ #include "global.h" -Path* Path_GetByIndex(GlobalContext* globalCtx, s16 index, s16 max) { +Path* Path_GetByIndex(PlayState* play, s16 index, s16 max) { Path* path; if (index != max) { - path = &globalCtx->setupPathList[index]; + path = &play->setupPathList[index]; } else { path = NULL; } diff --git a/src/code/z_play.c b/src/code/z_play.c index aa360934e..c24a45b51 100644 --- a/src/code/z_play.c +++ b/src/code/z_play.c @@ -34,7 +34,7 @@ #pragma GLOBAL_ASM("asm/non_matchings/code/z_play/func_801660B8.s") -#pragma GLOBAL_ASM("asm/non_matchings/code/z_play/Play_Fini.s") +#pragma GLOBAL_ASM("asm/non_matchings/code/z_play/Play_Destroy.s") #pragma GLOBAL_ASM("asm/non_matchings/code/z_play/func_801663C4.s") @@ -46,7 +46,7 @@ #pragma GLOBAL_ASM("asm/non_matchings/code/z_play/func_80166B30.s") -#pragma GLOBAL_ASM("asm/non_matchings/code/z_play/func_80167814.s") +#pragma GLOBAL_ASM("asm/non_matchings/code/z_play/Play_Update.s") #pragma GLOBAL_ASM("asm/non_matchings/code/z_play/func_80167DE4.s") @@ -56,10 +56,10 @@ #pragma GLOBAL_ASM("asm/non_matchings/code/z_play/func_80168DAC.s") -#pragma GLOBAL_ASM("asm/non_matchings/code/z_play/Play_Update.s") +#pragma GLOBAL_ASM("asm/non_matchings/code/z_play/Play_Main.s") -s32 Play_InCsMode(GlobalContext* globalCtx) { - return (globalCtx->csCtx.state != 0) || Player_InCsMode(&globalCtx->state); +s32 Play_InCsMode(PlayState* this) { + return (this->csCtx.state != 0) || Player_InCsMode(this); } #pragma GLOBAL_ASM("asm/non_matchings/code/z_play/func_80169100.s") @@ -74,43 +74,229 @@ s32 Play_InCsMode(GlobalContext* globalCtx) { #pragma GLOBAL_ASM("asm/non_matchings/code/z_play/Play_SceneInit.s") -#pragma GLOBAL_ASM("asm/non_matchings/code/z_play/func_80169474.s") +void Play_GetScreenPos(PlayState* this, Vec3f* worldPos, Vec3f* screenPos) { + f32 invW; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_play/Play_CreateSubCamera.s") + // screenPos temporarily stores the projectedPos + Actor_GetProjectedPos(this, worldPos, screenPos, &invW); -#pragma GLOBAL_ASM("asm/non_matchings/code/z_play/Play_GetActiveCamId.s") + screenPos->x = (SCREEN_WIDTH / 2) + (screenPos->x * invW * (SCREEN_WIDTH / 2)); + screenPos->y = (SCREEN_HEIGHT / 2) - (screenPos->y * invW * (SCREEN_HEIGHT / 2)); +} -#pragma GLOBAL_ASM("asm/non_matchings/code/z_play/Play_CameraChangeStatus.s") +s16 Play_CreateSubCamera(PlayState* this) { + s16 subCamId; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_play/Play_ClearCamera.s") + for (subCamId = CAM_ID_SUB_FIRST; subCamId < NUM_CAMS; subCamId++) { + if (this->cameraPtrs[subCamId] == NULL) { + break; + } + } -#pragma GLOBAL_ASM("asm/non_matchings/code/z_play/Play_ClearAllSubCameras.s") + // if no subCameras available + if (subCamId == NUM_CAMS) { + return CAM_ID_NONE; + } -#pragma GLOBAL_ASM("asm/non_matchings/code/z_play/Play_GetCamera.s") + this->cameraPtrs[subCamId] = &this->subCameras[subCamId - CAM_ID_SUB_FIRST]; + Camera_Init(this->cameraPtrs[subCamId], &this->view, &this->colCtx, this); + this->cameraPtrs[subCamId]->camId = subCamId; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_play/Play_CameraSetAtEye.s") + return subCamId; +} -#pragma GLOBAL_ASM("asm/non_matchings/code/z_play/Play_CameraSetAtEyeUp.s") +s16 Play_GetActiveCamId(PlayState* this) { + return this->activeCamId; +} -#pragma GLOBAL_ASM("asm/non_matchings/code/z_play/Play_CameraSetFov.s") +s32 Play_ChangeCameraStatus(PlayState* this, s16 camId, s16 status) { + s16 camIdx = (camId == CAM_ID_NONE) ? this->activeCamId : camId; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_play/Play_CameraSetRoll.s") + if (status == CAM_STATUS_ACTIVE) { + this->activeCamId = camIdx; + } -#pragma GLOBAL_ASM("asm/non_matchings/code/z_play/Play_CopyCamera.s") + return Camera_ChangeStatus(this->cameraPtrs[camIdx], status); +} -#pragma GLOBAL_ASM("asm/non_matchings/code/z_play/func_80169A50.s") +void Play_ClearCamera(PlayState* this, s16 camId) { + s16 camIdx = (camId == CAM_ID_NONE) ? this->activeCamId : camId; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_play/Play_CameraChangeSetting.s") + if (this->cameraPtrs[camIdx] != NULL) { + Camera_ChangeStatus(this->cameraPtrs[camIdx], CAM_STATUS_INACTIVE); + this->cameraPtrs[camIdx] = NULL; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/code/z_play/func_80169AFC.s") +void Play_ClearAllSubCameras(PlayState* this) { + s16 subCamId; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_play/Play_CameraGetUID.s") + for (subCamId = CAM_ID_SUB_FIRST; subCamId < NUM_CAMS; subCamId++) { + if (this->cameraPtrs[subCamId] != NULL) { + Play_ClearCamera(this, subCamId); + } + } -#pragma GLOBAL_ASM("asm/non_matchings/code/z_play/func_80169BF8.s") + this->activeCamId = CAM_ID_MAIN; +} -#pragma GLOBAL_ASM("asm/non_matchings/code/z_play/Play_GetCsCamDataSetting.s") +Camera* Play_GetCamera(PlayState* this, s16 camId) { + s16 camIdx = (camId == CAM_ID_NONE) ? this->activeCamId : camId; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_play/Play_GetCsCamDataVec3s.s") + return this->cameraPtrs[camIdx]; +} + +/** + * @return bit-packed success if each of the params were applied + */ +s32 Play_SetCameraAtEye(PlayState* this, s16 camId, Vec3f* at, Vec3f* eye) { + s32 successfullySet = 0; + s16 camIdx = (camId == CAM_ID_NONE) ? this->activeCamId : camId; + Camera* camera = this->cameraPtrs[camIdx]; + + successfullySet |= Camera_SetViewParam(camera, CAM_VIEW_AT, at); + successfullySet <<= 1; + successfullySet |= Camera_SetViewParam(camera, CAM_VIEW_EYE, eye); + + camera->dist = Math3D_Distance(at, eye); + + if (camera->focalActor != NULL) { + camera->atActorOffset.x = at->x - camera->focalActor->world.pos.x; + camera->atActorOffset.y = at->y - camera->focalActor->world.pos.y; + camera->atActorOffset.z = at->z - camera->focalActor->world.pos.z; + } else { + camera->atActorOffset.x = camera->atActorOffset.y = camera->atActorOffset.z = 0.0f; + } + + camera->atLerpStepScale = 0.01f; + + return successfullySet; +} + +/** + * @return bit-packed success if each of the params were applied + */ +s32 Play_SetCameraAtEyeUp(PlayState* this, s16 camId, Vec3f* at, Vec3f* eye, Vec3f* up) { + s32 successfullySet = 0; + s16 camIdx = (camId == CAM_ID_NONE) ? this->activeCamId : camId; + Camera* camera = this->cameraPtrs[camIdx]; + + successfullySet |= Camera_SetViewParam(camera, CAM_VIEW_AT, at); + successfullySet <<= 1; + successfullySet |= Camera_SetViewParam(camera, CAM_VIEW_EYE, eye); + successfullySet <<= 1; + successfullySet |= Camera_SetViewParam(camera, CAM_VIEW_UP, up); + + camera->dist = Math3D_Distance(at, eye); + + if (camera->focalActor != NULL) { + camera->atActorOffset.x = at->x - camera->focalActor->world.pos.x; + camera->atActorOffset.y = at->y - camera->focalActor->world.pos.y; + camera->atActorOffset.z = at->z - camera->focalActor->world.pos.z; + } else { + camera->atActorOffset.x = camera->atActorOffset.y = camera->atActorOffset.z = 0.0f; + } + + camera->atLerpStepScale = 0.01f; + + return successfullySet; +} + +/** + * @return true if the fov was successfully set + */ +s32 Play_SetCameraFov(PlayState* this, s16 camId, f32 fov) { + s32 successfullySet = Camera_SetViewParam(this->cameraPtrs[camId], CAM_VIEW_FOV, &fov) & 1; + + if (1) {} + return successfullySet; +} + +s32 Play_SetCameraRoll(PlayState* this, s16 camId, s16 roll) { + s16 camIdx = (camId == CAM_ID_NONE) ? this->activeCamId : camId; + Camera* camera = this->cameraPtrs[camIdx]; + + camera->roll = roll; + + return 1; +} + +void Play_CopyCamera(PlayState* this, s16 destCamId, s16 srcCamId) { + s16 srcCamId2 = (srcCamId == CAM_ID_NONE) ? this->activeCamId : srcCamId; + s16 destCamId1 = (destCamId == CAM_ID_NONE) ? this->activeCamId : destCamId; + + Camera_Copy(this->cameraPtrs[destCamId1], this->cameraPtrs[srcCamId2]); +} + +// Same as Play_ChangeCameraSetting but also calls Camera_InitPlayerSettings +s32 func_80169A50(PlayState* this, s16 camId, Player* player, s16 setting) { + Camera* camera; + s16 camIdx = (camId == CAM_ID_NONE) ? this->activeCamId : camId; + + camera = this->cameraPtrs[camIdx]; + Camera_InitPlayerSettings(camera, player); + return Camera_ChangeSetting(camera, setting); +} + +s32 Play_ChangeCameraSetting(PlayState* this, s16 camId, s16 setting) { + return Camera_ChangeSetting(Play_GetCamera(this, camId), setting); +} + +// Related to bosses and fishing +void func_80169AFC(PlayState* this, s16 camId, s16 timer) { + s16 camIdx = (camId == CAM_ID_NONE) ? this->activeCamId : camId; + s16 i; + + Play_ClearCamera(this, camIdx); + + for (i = CAM_ID_SUB_FIRST; i < NUM_CAMS; i++) { + if (this->cameraPtrs[i] != NULL) { + Play_ClearCamera(this, i); + } + } + + if (timer <= 0) { + Play_ChangeCameraStatus(this, CAM_ID_MAIN, CAM_STATUS_ACTIVE); + this->cameraPtrs[CAM_ID_MAIN]->childCamId = this->cameraPtrs[CAM_ID_MAIN]->doorTimer2 = 0; + } +} + +s16 Play_GetCameraUID(PlayState* this, s16 camId) { + Camera* camera = this->cameraPtrs[camId]; + + if (camera != NULL) { + return camera->uid; + } else { + return -1; + } +} + +// Unused in both MM and OoT, purpose is very unclear +s16 func_80169BF8(PlayState* this, s16 camId, s16 uid) { + Camera* camera = this->cameraPtrs[camId]; + + if (camera != NULL) { + return 0; + } else if (camera->uid != uid) { + return 0; + } else if (camera->status != CAM_STATUS_ACTIVE) { + return 2; + } else { + return 1; + } +} + +u16 Play_GetActorCsCamSetting(PlayState* this, s32 csCamDataIndex) { + ActorCsCamInfo* actorCsCamList = &this->actorCsCamList[csCamDataIndex]; + + return actorCsCamList->setting; +} + +Vec3s* Play_GetActorCsCamFuncData(PlayState* this, s32 csCamDataIndex) { + ActorCsCamInfo* actorCsCamList = &this->actorCsCamList[csCamDataIndex]; + + return Lib_SegmentedToVirtual(actorCsCamList->actorCsCamFuncData); +} /** * Converts the number of a scene to its "original" equivalent, the default version of the area which the player first @@ -154,113 +340,113 @@ s16 Play_GetOriginalSceneNumber(s16 sceneNum) { * 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; +void Play_SaveCycleSceneFlags(GameState* thisx) { + PlayState* this = (PlayState*)thisx; CycleSceneFlags* cycleSceneFlags; - 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]; + cycleSceneFlags = &gSaveContext.cycleSceneFlags[Play_GetOriginalSceneNumber(this->sceneNum)]; + cycleSceneFlags->chest = this->actorCtx.flags.chest; + cycleSceneFlags->switch0 = this->actorCtx.flags.switches[0]; + cycleSceneFlags->switch1 = this->actorCtx.flags.switches[1]; - if (globalCtx->sceneNum == SCENE_INISIE_R) { // Inverted Stone Tower Temple - cycleSceneFlags = &gSaveContext.cycleSceneFlags[globalCtx->sceneNum]; + if (this->sceneNum == SCENE_INISIE_R) { // Inverted Stone Tower Temple + cycleSceneFlags = &gSaveContext.cycleSceneFlags[this->sceneNum]; } - cycleSceneFlags->collectible = globalCtx->actorCtx.flags.collectible[0]; - cycleSceneFlags->clearedRoom = globalCtx->actorCtx.flags.clearedRoom; + cycleSceneFlags->collectible = this->actorCtx.flags.collectible[0]; + cycleSceneFlags->clearedRoom = this->actorCtx.flags.clearedRoom; } -void Play_SetRespawnData(GameState* gameState, s32 respawnMode, u16 entranceIndex, s32 roomIndex, s32 playerParams, - Vec3f* pos, s16 yaw) { - GlobalContext* globalCtx = (GlobalContext*)gameState; +void Play_SetRespawnData(GameState* thisx, s32 respawnMode, u16 entrance, s32 roomIndex, s32 playerParams, Vec3f* pos, + s16 yaw) { + PlayState* this = (PlayState*)thisx; - gSaveContext.respawn[respawnMode].entranceIndex = Entrance_CreateIndex(entranceIndex >> 9, 0, entranceIndex & 0xF); + gSaveContext.respawn[respawnMode].entrance = Entrance_Create(entrance >> 9, 0, entrance & 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]; + gSaveContext.respawn[respawnMode].tempSwitchFlags = this->actorCtx.flags.switches[2]; + gSaveContext.respawn[respawnMode].unk_18 = this->actorCtx.flags.collectible[1]; + gSaveContext.respawn[respawnMode].tempCollectFlags = this->actorCtx.flags.collectible[2]; } -void Play_SetupRespawnPoint(GameState* gameState, s32 respawnMode, s32 playerParams) { - GlobalContext* globalCtx = (GlobalContext*)gameState; - Player* player = GET_PLAYER(globalCtx); +void Play_SetupRespawnPoint(GameState* thisx, s32 respawnMode, s32 playerParams) { + PlayState* this = (PlayState*)thisx; + Player* player = GET_PLAYER(this); - 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, + if (this->sceneNum != SCENE_KAKUSIANA) { // Grottos + Play_SetRespawnData(&this->state, respawnMode, (u16)((void)0, gSaveContext.save.entrance), + this->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; +void func_80169ECC(PlayState* this) { + if (this->sceneNum == SCENE_SECOM) { + this->nextEntrance = ENTRANCE(IKANA_CANYON, 6); 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; +void func_80169EFC(GameState* thisx) { + PlayState* this = (PlayState*)thisx; - 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.respawn[RESPAWN_MODE_DOWN].tempSwitchFlags = this->actorCtx.flags.switches[2]; + gSaveContext.respawn[RESPAWN_MODE_DOWN].unk_18 = this->actorCtx.flags.collectible[1]; + gSaveContext.respawn[RESPAWN_MODE_DOWN].tempCollectFlags = this->actorCtx.flags.collectible[2]; + this->nextEntrance = gSaveContext.respawn[RESPAWN_MODE_DOWN].entrance; gSaveContext.respawnFlag = 1; - func_80169ECC(globalCtx); - globalCtx->sceneLoadFlag = 0x14; - globalCtx->unk_1887F = 2; + func_80169ECC(this); + this->transitionTrigger = TRANS_TRIGGER_START; + this->transitionType = TRANS_TYPE_02; } // Gameplay_LoadToLastEntrance ? // Used by game_over and Test7 -void func_80169F78(GameState* gameState) { - GlobalContext* globalCtx = (GlobalContext*)gameState; +void func_80169F78(GameState* thisx) { + PlayState* this = (PlayState*)thisx; - globalCtx->nextEntranceIndex = gSaveContext.respawn[RESTART_MODE_TOP].entranceIndex; + this->nextEntrance = gSaveContext.respawn[RESPAWN_MODE_TOP].entrance; gSaveContext.respawnFlag = -1; - func_80169ECC(globalCtx); - globalCtx->sceneLoadFlag = 0x14; - globalCtx->unk_1887F = 2; + func_80169ECC(this); + this->transitionTrigger = TRANS_TRIGGER_START; + this->transitionType = TRANS_TYPE_02; } // Gameplay_TriggerRespawn ? // Used for void by Wallmaster, Deku Shrine doors. Also used by Player, Kaleido, DoorWarp1 -void func_80169FDC(GameState* gameState) { - func_80169F78(gameState); +void func_80169FDC(GameState* thisx) { + func_80169F78(thisx); } // Used by Kankyo to determine how to change the lighting, e.g. for game over. -s32 func_80169FFC(GameState* gameState) { - GlobalContext* globalCtx = (GlobalContext*)gameState; +s32 func_80169FFC(GameState* thisx) { + PlayState* this = (PlayState*)thisx; - return globalCtx->roomCtx.currRoom.mesh->type0.type != 1; + return this->roomCtx.currRoom.mesh->type0.type != 1; } -s32 FrameAdvance_IsEnabled(GameState* gameState) { - GlobalContext* globalCtx = (GlobalContext*)gameState; +s32 FrameAdvance_IsEnabled(GameState* thisx) { + PlayState* this = (PlayState*)thisx; - return globalCtx->frameAdvCtx.enabled != 0; + return this->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] thisx GameState, promoted to play 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; +s32 func_8016A02C(GameState* thisx, Actor* actor, s16* yaw) { + PlayState* this = (PlayState*)thisx; TransitionActorEntry* transitionActor; s8 frontRoom; @@ -268,7 +454,7 @@ s32 func_8016A02C(GameState* gameState, Actor* actor, s16* yaw) { return false; } - transitionActor = &globalCtx->doorCtx.transitionActorList[(u16)actor->params >> 10]; + transitionActor = &this->doorCtx.transitionActorList[(u16)actor->params >> 10]; frontRoom = transitionActor->sides[0].room; if (frontRoom == transitionActor->sides[1].room) { return false; @@ -287,11 +473,11 @@ s32 func_8016A02C(GameState* gameState, Actor* actor, s16* yaw) { /** * @brief Tests if \p pos is underwater. * - * @param[in] globalCtx GlobalContext + * @param[in] play PlayState * @param[in] pos position to test * @return true if inside a waterbox and not above a void. */ -s32 Play_IsUnderwater(GlobalContext* globalCtx, Vec3f* pos) { +s32 Play_IsUnderwater(PlayState* this, Vec3f* pos) { WaterBox* waterBox; CollisionPoly* poly; Vec3f waterSurfacePos; @@ -299,20 +485,18 @@ s32 Play_IsUnderwater(GlobalContext* globalCtx, Vec3f* pos) { waterSurfacePos = *pos; - if ((WaterBox_GetSurface1(globalCtx, &globalCtx->colCtx, waterSurfacePos.x, waterSurfacePos.z, &waterSurfacePos.y, + if ((WaterBox_GetSurface1(this, &this->colCtx, waterSurfacePos.x, waterSurfacePos.z, &waterSurfacePos.y, &waterBox) == true) && (pos->y < waterSurfacePos.y) && - (BgCheck_EntityRaycastFloor3(&globalCtx->colCtx, &poly, &bgId, &waterSurfacePos) != BGCHECK_Y_MIN)) { + (BgCheck_EntityRaycastFloor3(&this->colCtx, &poly, &bgId, &waterSurfacePos) != BGCHECK_Y_MIN)) { return true; } else { return false; } } -// z_demo and EnTest4 -// This data appears to be a boolean. It is only set by Play_Init. -s32 func_8016A168(void) { - return D_801D0D50; +s32 Play_IsDebugCamEnabled(void) { + return gDbgCamEnabled; } // A mapping from playerActorCsIds to sGlobalCamDataSettings indices. @@ -322,17 +506,17 @@ extern s16 D_801D0D64[]; // 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 + * this->playerActorCsIds. If a playerActorCsId is not present in the scene, then that particular id is set * to -1. Otherwise, if there is an ActorCutscene where csCamSceneDataId matches the appropriate element of D_801D0D64, * set the corresponding playerActorCsId (and possibly change its priority for the zeroth one) */ -void Play_AssignPlayerActorCsIdsFromScene(GameState* gameState, s32 startActorCsId) { - GlobalContext* globalCtx = (GlobalContext*)gameState; +void Play_AssignPlayerActorCsIdsFromScene(GameState* thisx, s32 startActorCsId) { + PlayState* this = (PlayState*)thisx; s32 i; - s16* curPlayerActorCsId = globalCtx->playerActorCsIds; + s16* curPlayerActorCsId = this->playerActorCsIds; s16* phi_s1 = D_801D0D64; - for (i = 0; i < ARRAY_COUNT(globalCtx->playerActorCsIds); i++, curPlayerActorCsId++, phi_s1++) { + for (i = 0; i < ARRAY_COUNT(this->playerActorCsIds); i++, curPlayerActorCsId++, phi_s1++) { ActorCutscene* actorCutscene; s32 curActorCsId; @@ -354,7 +538,7 @@ void Play_AssignPlayerActorCsIdsFromScene(GameState* gameState, s32 startActorCs } // 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) { +void func_8016A268(GameState* thisx, s16 arg1, u8 arg2, u8 arg3, u8 arg4, u8 arg5) { MREG(64) = arg1; MREG(65) = arg2; MREG(66) = arg3; diff --git a/src/code/z_player_call.c b/src/code/z_player_call.c index 7ed1ce5ce..8cd8207b7 100644 --- a/src/code/z_player_call.c +++ b/src/code/z_player_call.c @@ -9,10 +9,10 @@ ActorFunc sPlayerCallDestroyFunc; ActorFunc sPlayerCallUpdateFunc; ActorFunc sPlayerCallDrawFunc; -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); +void PlayerCall_Init(Actor* thisx, PlayState* play); +void PlayerCall_Destroy(Actor* thisx, PlayState* play); +void PlayerCall_Update(Actor* thisx, PlayState* play); +void PlayerCall_Draw(Actor* thisx, PlayState* play); const ActorInit Player_InitVars = { ACTOR_PLAYER, @@ -26,10 +26,10 @@ const ActorInit Player_InitVars = { (ActorFunc)PlayerCall_Draw, }; -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 Player_Init(Actor* thisx, PlayState* play); +void Player_Destroy(Actor* thisx, PlayState* play); +void Player_Update(Actor* thisx, PlayState* play); +void Player_Draw(Actor* thisx, PlayState* play); void PlayerCall_InitFuncPtrs(void) { sPlayerCallInitFunc = KaleidoManager_GetRamAddr(Player_Init); @@ -38,23 +38,23 @@ void PlayerCall_InitFuncPtrs(void) { sPlayerCallDrawFunc = KaleidoManager_GetRamAddr(Player_Draw); } -void PlayerCall_Init(Actor* thisx, GlobalContext* globalCtx) { +void PlayerCall_Init(Actor* thisx, PlayState* play) { KaleidoScopeCall_LoadPlayer(); PlayerCall_InitFuncPtrs(); - sPlayerCallInitFunc(thisx, globalCtx); + sPlayerCallInitFunc(thisx, play); } -void PlayerCall_Destroy(Actor* thisx, GlobalContext* globalCtx) { +void PlayerCall_Destroy(Actor* thisx, PlayState* play) { KaleidoScopeCall_LoadPlayer(); - sPlayerCallDestroyFunc(thisx, globalCtx); + sPlayerCallDestroyFunc(thisx, play); } -void PlayerCall_Update(Actor* thisx, GlobalContext* globalCtx) { +void PlayerCall_Update(Actor* thisx, PlayState* play) { KaleidoScopeCall_LoadPlayer(); - sPlayerCallUpdateFunc(thisx, globalCtx); + sPlayerCallUpdateFunc(thisx, play); } -void PlayerCall_Draw(Actor* thisx, GlobalContext* globalCtx) { +void PlayerCall_Draw(Actor* thisx, PlayState* play) { KaleidoScopeCall_LoadPlayer(); - sPlayerCallDrawFunc(thisx, globalCtx); + sPlayerCallDrawFunc(thisx, play); } diff --git a/src/code/z_player_lib.c b/src/code/z_player_lib.c index cb3d14e8b..1566077f1 100644 --- a/src/code/z_player_lib.c +++ b/src/code/z_player_lib.c @@ -1,130 +1,924 @@ #include "global.h" -#pragma GLOBAL_ASM("asm/non_matchings/code/z_player_lib/func_801226E0.s") +#include "objects/object_link_goron/object_link_goron.h" +#include "objects/object_link_zora/object_link_zora.h" -#pragma GLOBAL_ASM("asm/non_matchings/code/z_player_lib/func_80122744.s") +#include "objects/object_mask_meoto/object_mask_meoto.h" -#pragma GLOBAL_ASM("asm/non_matchings/code/z_player_lib/func_80122760.s") +void PlayerCall_Init(Actor* thisx, PlayState* play); +void PlayerCall_Destroy(Actor* thisx, PlayState* play); +void PlayerCall_Update(Actor* thisx, PlayState* play); +void PlayerCall_Draw(Actor* thisx, PlayState* play); -#pragma GLOBAL_ASM("asm/non_matchings/code/z_player_lib/func_80122868.s") +typedef struct { + /* 0x00 */ Vec3f unk_00; + /* 0x0C */ Vec3f unk_0C; + /* 0x18 */ s16 unk_18; + /* 0x1A */ s16 unk_1A; +} struct_801F58B0; // size = 0x1C -#pragma GLOBAL_ASM("asm/non_matchings/code/z_player_lib/func_801229A0.s") +extern struct_801F58B0 D_801F58B0[3][3]; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_player_lib/func_801229EC.s") +extern s32 D_801F59C8[2]; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_player_lib/func_801229FC.s") +extern s32 D_801F59E0; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_player_lib/func_80122BA4.s") +extern Vec3f D_801F59E8; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_player_lib/func_80122C20.s") +void func_80127B64(struct_801F58B0 arg0[], UNK_TYPE arg1, Vec3f* arg2); -#pragma GLOBAL_ASM("asm/non_matchings/code/z_player_lib/func_80122D44.s") +s32 func_801226E0(PlayState* play, s32 arg1) { + if (arg1 == 0) { + Play_SetupRespawnPoint(&play->state, RESPAWN_MODE_DOWN, 0xBFF); + if (play->sceneNum == SCENE_KAKUSIANA) { + return 1; + } + } -#pragma GLOBAL_ASM("asm/non_matchings/code/z_player_lib/func_80122ED8.s") + gSaveContext.respawn[RESPAWN_MODE_DOWN].data = 0; + return arg1; +} -#pragma GLOBAL_ASM("asm/non_matchings/code/z_player_lib/func_80122EEC.s") +s32 func_80122744(PlayState* play, struct_80122744_arg1* arg1, u32 arg2, Vec3s* arg3) { + arg1->unk_00 = arg2; + arg1->unk_01 = 0; + arg1->unk_04 = arg3; + return 1; +} -#pragma GLOBAL_ASM("asm/non_matchings/code/z_player_lib/func_80122F28.s") +s32 func_80122760(PlayState* play, struct_80122744_arg1* arg1, f32 arg2) { + if (arg1->unk_01 < arg1->unk_00) { + Player* player = GET_PLAYER(play); + Vec3f sp30; + s32 pad; + s16 yaw; + f32 distXZ; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_player_lib/func_80122F9C.s") + Math_Vec3s_ToVec3f(&sp30, &arg1->unk_04[arg1->unk_01]); + yaw = Math_Vec3f_Yaw(&player->actor.world.pos, &sp30); + func_800B6F20(play, &play->actorCtx.unk_26C, arg2, yaw); + play->actorCtx.unk268 = 1; + distXZ = Math_Vec3f_DistXZ(&player->actor.world.pos, &sp30); -#pragma GLOBAL_ASM("asm/non_matchings/code/z_player_lib/func_80122FCC.s") + if ((fabsf(player->actor.world.pos.y - sp30.y) < 50.0f) && (distXZ < arg2)) { + arg1->unk_01++; + } -#pragma GLOBAL_ASM("asm/non_matchings/code/z_player_lib/func_8012300C.s") + return false; + } -#pragma GLOBAL_ASM("asm/non_matchings/code/z_player_lib/func_8012301C.s") + return true; +} -#pragma GLOBAL_ASM("asm/non_matchings/code/z_player_lib/func_80123140.s") +void func_80122868(PlayState* play, Player* player) { + OPEN_DISPS(play->state.gfxCtx); -#pragma GLOBAL_ASM("asm/non_matchings/code/z_player_lib/func_80123358.s") + if (player->invincibilityTimer > 0) { + s32 phi_v0 = 50 - player->invincibilityTimer; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_player_lib/Player_InCsMode.s") + phi_v0 = CLAMP(phi_v0, 8, 40); -#pragma GLOBAL_ASM("asm/non_matchings/code/z_player_lib/func_80123420.s") + player->unk_B5F += phi_v0; + POLY_OPA_DISP = + Gfx_SetFog(POLY_OPA_DISP, 255, 0, 0, 0, 0, 4000 - (s32)(Math_CosS(player->unk_B5F << 8) * 2000.0f)); + } else if (gSaveContext.jinxTimer != 0) { + player->unk_B5F += 10; + POLY_OPA_DISP = + Gfx_SetFog(POLY_OPA_DISP, 0, 0, 255, 0, 0, 4000 - (s32)(Math_CosS(player->unk_B5F << 8) * 2000.0f)); + } -#pragma GLOBAL_ASM("asm/non_matchings/code/z_player_lib/func_80123434.s") + CLOSE_DISPS(play->state.gfxCtx); +} -#pragma GLOBAL_ASM("asm/non_matchings/code/z_player_lib/func_80123448.s") +void func_801229A0(PlayState* play, Player* player) { + OPEN_DISPS(play->state.gfxCtx); -#pragma GLOBAL_ASM("asm/non_matchings/code/z_player_lib/func_801234B0.s") + if ((gSaveContext.jinxTimer != 0) || (player->invincibilityTimer > 0)) { + POLY_OPA_DISP = func_801660B8(play, POLY_OPA_DISP); + } -#pragma GLOBAL_ASM("asm/non_matchings/code/z_player_lib/func_801234D4.s") + CLOSE_DISPS(play->state.gfxCtx); +} -#pragma GLOBAL_ASM("asm/non_matchings/code/z_player_lib/func_80123590.s") +void func_801229EC(UNK_TYPE arg0, UNK_TYPE arg1) { +} -#pragma GLOBAL_ASM("asm/non_matchings/code/z_player_lib/func_801235DC.s") +extern s16 sMaskObjectIds[PLAYER_MASK_MAX - 1]; +#if 0 +s16 sMaskObjectIds[PLAYER_MASK_MAX - 1] = { + OBJECT_MASK_TRUTH, OBJECT_MASK_KERFAY, OBJECT_MASK_YOFUKASI, OBJECT_MASK_RABIT, OBJECT_MASK_KI_TAN, + OBJECT_MASK_JSON, OBJECT_MASK_ROMERNY, OBJECT_MASK_ZACHO, OBJECT_MASK_POSTHAT, OBJECT_MASK_MEOTO, + OBJECT_MASK_BIGELF, OBJECT_MASK_GIBUDO, OBJECT_MASK_GERO, OBJECT_MASK_DANCER, OBJECT_MASK_SKJ, + OBJECT_MASK_STONE, OBJECT_MASK_BREE, OBJECT_MASK_BAKURETU, OBJECT_MASK_BU_SAN, OBJECT_MASK_KYOJIN, + OBJECT_MASK_BOY, OBJECT_MASK_GORON, OBJECT_MASK_ZORA, OBJECT_MASK_NUTS, +}; +#endif -#pragma GLOBAL_ASM("asm/non_matchings/code/z_player_lib/func_8012364C.s") +// Load mask object? +/** + * Notes: + * + * player->maskObjectLoadState seems to be able to take 3 possible values + * 0: The mask object is loaded. + * 1: The mask object must be changed (and the DMA request has not been sent yet) + * 2: Waiting for the DMA request to complete. + */ +void func_801229FC(Player* player) { + if (player->maskObjectLoadState == 1) { + s16 objectId = sMaskObjectIds[(u8)player->maskId - 1]; + + osCreateMesgQueue(&player->maskObjectLoadQueue, &player->maskObjectLoadMsg, 1); + DmaMgr_SendRequestImpl(&player->maskDmaRequest, player->maskObjectSegment, gObjectTable[objectId].vromStart, + gObjectTable[objectId].vromEnd - gObjectTable[objectId].vromStart, 0, + &player->maskObjectLoadQueue, NULL); + player->maskObjectLoadState++; + } else if (player->maskObjectLoadState == 2) { + if (osRecvMesg(&player->maskObjectLoadQueue, NULL, OS_MESG_NOBLOCK) == 0) { + player->maskObjectLoadState = 0; + + if (player->currentMask == PLAYER_MASK_GREAT_FAIRY) { + s32 i; + + for (i = 0; i < ARRAY_COUNT(D_801F58B0); i++) { + func_80127B64(D_801F58B0[i], ARRAY_COUNT(D_801F58B0[i]), &player->bodyPartsPos[7]); + } + } + } + } else if ((player->currentMask != PLAYER_MASK_NONE) && (player->currentMask != (u8)player->maskId)) { + player->maskObjectLoadState = 1; + player->maskId = player->currentMask; + } else if (player->currentMask == PLAYER_MASK_CIRCUS_LEADER) { + s32 i; + + for (i = 0; i < ARRAY_COUNT(D_801F59C8); i++) { + D_801F59C8[i] += Rand_S16Offset(4, 23) + (s32)(fabsf(player->linearVelocity) * 50.0f); + } + } +} + +void func_80122BA4(PlayState* play, struct_80122D44_arg1* arg1, s32 arg2, s32 alpha) { + if (arg2 == arg1->unk_00) { + s32 index; + + arg1->unk_01--; + if (arg1->unk_01 < 0) { + arg1->unk_01 = 3; + } + + index = arg1->unk_01; + arg1->unk_04[index].unk_00 = arg1->unk_00; + arg1->unk_04[index].alpha = alpha; + Matrix_Get(&arg1->unk_04[index].mf); + + arg1->unk_00 = 0; + } +} + +void func_80122C20(PlayState* play, struct_80122D44_arg1* arg1) { + struct_80122D44_arg1_unk_04* temp_v1 = &arg1->unk_04[0]; + s32 phi_a1; + s32 i; + + for (i = 0; i < ARRAY_COUNT(arg1->unk_04); i++, temp_v1++) { + // Can't be `temp_v1->alpha != 0` + if (temp_v1->alpha) { + phi_a1 = temp_v1->unk_00 == 3 ? (255 / 3) : (255 / 5); + if (phi_a1 >= temp_v1->alpha) { + temp_v1->alpha = 0; + } else { + temp_v1->alpha -= phi_a1; + } + } + } +} + +typedef struct { + /* 0x0 */ Color_RGB8 color; + /* 0x4 */ Gfx* dList; +} struct_801BFDD0; // size = 0x08 + +extern struct_801BFDD0 D_801BFDD0[]; +#if 0 +struct_801BFDD0 D_801BFDD0[] = { + { { 180, 200, 255 }, gLinkGoronCurledDL }, + { { 155, 0, 0 }, gLinkGoronRollingSpikesAndEffectDL }, + { { 255, 0, 0 }, gLinkGoronGoronPunchEffectDL }, +}; +#endif + +void func_80122D44(PlayState* play, struct_80122D44_arg1* arg1) { + struct_801BFDD0* temp_s3; + struct_80122D44_arg1_unk_04* phi_s2 = arg1->unk_04; + s32 phi_s6 = false; + s32 i; + + OPEN_DISPS(play->state.gfxCtx); + + for (i = 0; i != ARRAY_COUNT(arg1->unk_04); i++) { + if ((phi_s2->alpha != 0) && (phi_s2->alpha != 255)) { + temp_s3 = &D_801BFDD0[phi_s2->unk_00 - 1]; + Matrix_Put(&phi_s2->mf); + + gDPPipeSync(POLY_XLU_DISP++); + + if (!phi_s6 && phi_s2->unk_00 == 2) { + AnimatedMat_DrawXlu(play, Lib_SegmentedToVirtual(&object_link_goron_Matanimheader_013138)); + phi_s6 = true; + } + + Scene_SetRenderModeXlu(play, 1, 2); + gDPSetEnvColor(POLY_XLU_DISP++, temp_s3->color.r, temp_s3->color.g, temp_s3->color.b, phi_s2->alpha); + + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + + gSPDisplayList(POLY_XLU_DISP++, temp_s3->dList); + } + + phi_s2++; + } + + CLOSE_DISPS(play->state.gfxCtx); +} + +extern u8 sMaskItemIds[PLAYER_MASK_MAX - 1]; +#if 0 +u8 sMaskItemIds[PLAYER_MASK_MAX - 1] = { + ITEM_MASK_TRUTH, // PLAYER_MASK_TRUTH + ITEM_MASK_KAFEIS_MASK, // PLAYER_MASK_KAFEIS_MASK + ITEM_MASK_ALL_NIGHT, // PLAYER_MASK_ALL_NIGHT + ITEM_MASK_BUNNY, // PLAYER_MASK_BUNNY + ITEM_MASK_KEATON, // PLAYER_MASK_KEATON + ITEM_MASK_GARO, // PLAYER_MASK_GARO + ITEM_MASK_ROMANI, // PLAYER_MASK_ROMANI + ITEM_MASK_CIRCUS_LEADER, // PLAYER_MASK_CIRCUS_LEADER + ITEM_MASK_POSTMAN, // PLAYER_MASK_POSTMAN + ITEM_MASK_COUPLE, // PLAYER_MASK_COUPLE + ITEM_MASK_GREAT_FAIRY, // PLAYER_MASK_GREAT_FAIRY + ITEM_MASK_GIBDO, // PLAYER_MASK_GIBDO + ITEM_MASK_DON_GERO, // PLAYER_MASK_DON_GERO + ITEM_MASK_KAMARO, // PLAYER_MASK_KAMARO + ITEM_MASK_CAPTAIN, // PLAYER_MASK_CAPTAIN + ITEM_MASK_STONE, // PLAYER_MASK_STONE + ITEM_MASK_BREMEN, // PLAYER_MASK_BREMEN + ITEM_MASK_BLAST, // PLAYER_MASK_BLAST + ITEM_MASK_SCENTS, // PLAYER_MASK_SCENTS + ITEM_MASK_GIANT, // PLAYER_MASK_GIANT + ITEM_MASK_FIERCE_DEITY, // PLAYER_MASK_FIERCE_DEITY + ITEM_MASK_GORON, // PLAYER_MASK_GORON + ITEM_MASK_ZORA, // PLAYER_MASK_ZORA + ITEM_MASK_DEKU, // PLAYER_MASK_DEKU +}; +#endif + +u8 Player_MaskIdToItemId(s32 maskIdMinusOne) { + return sMaskItemIds[maskIdMinusOne]; +} + +u8 Player_GetCurMaskItemId(PlayState* play) { + Player* player = GET_PLAYER(play); + + if (player->currentMask != PLAYER_MASK_NONE) { + return Player_MaskIdToItemId(player->currentMask - 1); + } + + return ITEM_NONE; +} + +void func_80122F28(Player* player) { + if ((player->actor.category == ACTORCAT_PLAYER) && + (!(player->stateFlags1 & (PLAYER_STATE1_20000000 | PLAYER_STATE1_800000 | PLAYER_STATE1_200000 | + PLAYER_STATE1_800 | PLAYER_STATE1_400))) && + (!(player->stateFlags2 & PLAYER_STATE2_1))) { + if (player->doorType < 0) { + ActorCutscene_SetIntentToPlay(0x7C); + } else { + ActorCutscene_SetIntentToPlay(0x7D); + } + } +} + +s32 func_80122F9C(PlayState* play) { + Player* player = GET_PLAYER(play); + + return (player->stateFlags2 & PLAYER_STATE2_80000) && player->unk_AE7 == 2; +} + +s32 func_80122FCC(PlayState* play) { + Player* player = GET_PLAYER(play); + + return (player->stateFlags2 & PLAYER_STATE2_80000) && (player->unk_AE7 == 1 || player->unk_AE7 == 3); +} + +void func_8012300C(PlayState* play, s32 arg1) { + Player* player = GET_PLAYER(play); + + player->unk_B2B = arg1; +} + +void func_8012301C(Player* player, PlayState* play2) { + PlayState* play = play2; + s32 pad; + + player->unk_AE7++; + + if (player->unk_AE7 == 2) { + s16 objectId = gPlayerFormObjectIndices[((void)0, gSaveContext.save.playerForm)]; + + gActorOverlayTable[ACTOR_PLAYER].initInfo->objectId = objectId; + func_8012F73C(&play->objectCtx, player->actor.objBankIndex, objectId); + player->actor.objBankIndex = Object_GetIndex(&play->objectCtx, GAMEPLAY_KEEP); + } else if (player->unk_AE7 >= 3) { + s32 objBankIndex = Object_GetIndex(&play->objectCtx, gActorOverlayTable[ACTOR_PLAYER].initInfo->objectId); + + if (Object_IsLoaded(&play->objectCtx, objBankIndex)) { + player->actor.objBankIndex = objBankIndex; + player->actor.shape.rot.z = gSaveContext.save.playerForm + 1; + player->actor.init = PlayerCall_Init; + player->actor.update = PlayerCall_Update; + player->actor.draw = PlayerCall_Draw; + gSaveContext.save.equippedMask = PLAYER_MASK_NONE; + } + } +} + +extern s16 D_801BFE14[][18]; + +// OoT's Player_SetBootData +void func_80123140(PlayState* play, Player* player) { + s16* bootRegs; + s32 currentBoots; + f32 scale; + + if ((player->actor.id == ACTOR_PLAYER) && (player->transformation == PLAYER_FORM_FIERCE_DEITY)) { + REG(27) = 1200; + } else { + REG(27) = 2000; + } + + REG(48) = 370; + + currentBoots = player->currentBoots; + if (currentBoots >= PLAYER_BOOTS_ZORA_UNDERWATER) { + if (player->stateFlags1 & PLAYER_STATE1_8000000) { + currentBoots++; + } + if (player->transformation == PLAYER_FORM_GORON) { + REG(48) = 200; + } + } else if (currentBoots == PLAYER_BOOTS_GIANT) { + REG(48) = 170; + } + + bootRegs = D_801BFE14[currentBoots]; + REG(19) = bootRegs[0]; + REG(30) = bootRegs[1]; + REG(32) = bootRegs[2]; + REG(34) = bootRegs[3]; + REG(35) = bootRegs[4]; + REG(36) = bootRegs[5]; + REG(37) = bootRegs[6]; + REG(38) = bootRegs[7]; + REG(39) = bootRegs[8]; + REG(43) = bootRegs[9]; + R_RUN_SPEED_LIMIT = bootRegs[10]; + REG(68) = bootRegs[11]; + REG(69) = bootRegs[12]; + IREG(66) = bootRegs[13]; + IREG(67) = bootRegs[14]; + IREG(68) = bootRegs[15]; + IREG(69) = bootRegs[16]; + MREG(95) = bootRegs[17]; + + if (play->roomCtx.currRoom.unk3 == 2) { + R_RUN_SPEED_LIMIT = 500; + } + + if ((player->actor.id == ACTOR_PLAYER) && (player->transformation == PLAYER_FORM_FIERCE_DEITY)) { + scale = 0.015f; + } else { + scale = 0.01f; + } + + Actor_SetScale(&player->actor, scale); +} + +s32 Player_InBlockingCsMode(PlayState* play, Player* player) { + return (player->stateFlags1 & (PLAYER_STATE1_20000000 | PLAYER_STATE1_200 | PLAYER_STATE1_80)) || + (player->csMode != 0) || (play->transitionTrigger == TRANS_TRIGGER_START) || + (play->transitionMode != TRANS_MODE_OFF) || (player->stateFlags1 & PLAYER_STATE1_1) || + (player->stateFlags3 & PLAYER_STATE3_80) || (play->actorCtx.unk268 != 0); +} + +s32 Player_InCsMode(PlayState* play) { + Player* player = GET_PLAYER(play); + + return Player_InBlockingCsMode(play, player) || player->unk_AA5 == 5; +} + +s32 func_80123420(Player* player) { + return player->stateFlags3 & PLAYER_STATE3_80000000; +} + +s32 func_80123434(Player* player) { + return player->stateFlags1 & (PLAYER_STATE1_40000000 | PLAYER_STATE1_20000 | PLAYER_STATE1_10000); +} + +// Unused +s32 func_80123448(PlayState* play) { + Player* player = GET_PLAYER(play); + + return (player->stateFlags1 & PLAYER_STATE1_400000) && + (player->transformation != PLAYER_FORM_HUMAN || (!func_80123434(player) && player->unk_730 == NULL)); +} + +// TODO: Player_IsGoronOrDeku is a temporary name until we have more info on this function. +// Hypothesis: this function checks if the current form would crouch when he tries to use the shield +s32 Player_IsGoronOrDeku(Player* player) { + return player->transformation == PLAYER_FORM_GORON || player->transformation == PLAYER_FORM_DEKU; +} + +s32 func_801234D4(PlayState* play) { + Player* player = GET_PLAYER(play); + + return (player->stateFlags2 & PLAYER_STATE2_8) || player->actor.speedXZ != 0.0f || + ((player->transformation != PLAYER_FORM_ZORA) && (player->stateFlags1 & PLAYER_STATE1_8000000)) || + ((player->transformation == PLAYER_FORM_ZORA) && (player->stateFlags1 & PLAYER_STATE1_8000000) && + (!(player->actor.bgCheckFlags & 1) || (player->currentBoots < PLAYER_BOOTS_ZORA_UNDERWATER))); +} + +s32 func_80123590(PlayState* play, Actor* actor) { + Player* player = GET_PLAYER(play); + + if ((player->stateFlags1 & PLAYER_STATE1_800) && (player->heldActor == actor)) { + player->interactRangeActor = NULL; + player->heldActor = NULL; + player->actor.child = NULL; + player->stateFlags1 &= ~PLAYER_STATE1_800; + return true; + } + + return false; +} + +s32 func_801235DC(PlayState* play, f32 arg1, s16 arg2) { + Player* player = GET_PLAYER(play); + + if (player->stateFlags3 & PLAYER_STATE3_1000) { + player->unk_B08[0] = arg1; + player->unk_B08[1] += arg1 * 0.05f; + player->currentYaw = arg2; + player->actor.home.rot.y = arg2; + player->actor.shape.rot.y = arg2; + player->unk_B8C = 4; + player->invincibilityTimer = 20; + + return true; + } + + return false; +} + +s32 func_8012364C(PlayState* play, Player* player, s32 arg2) { + if (arg2 >= 4) { + return ITEM_NONE; + } + + if (arg2 == 0) { + s32 item = Inventory_GetBtnBItem(play); + + if (item >= ITEM_FD) { + return item; + } + + if ((player->currentMask == PLAYER_MASK_BLAST) && (play->interfaceCtx.bButtonDoAction == 0x18)) { + return ITEM_F0; + } + + if ((player->currentMask == PLAYER_MASK_BREMEN) && (play->interfaceCtx.bButtonDoAction == 0x1A)) { + return ITEM_F1; + } + + if ((player->currentMask == PLAYER_MASK_KAMARO) && (play->interfaceCtx.bButtonDoAction == 0x19)) { + return ITEM_F2; + } + + return item; + } + + if (arg2 == 1) { + return (gSaveContext.buttonStatus[1] != BTN_DISABLED) + ? gSaveContext.save.equips.buttonItems[0][EQUIP_SLOT_C_LEFT] + : (gSaveContext.unk_3F22 == 0x10) ? gSaveContext.save.equips.buttonItems[0][EQUIP_SLOT_C_LEFT] + : ITEM_NONE; + } + + if (arg2 == 2) { + return (gSaveContext.buttonStatus[2] != BTN_DISABLED) + ? gSaveContext.save.equips.buttonItems[0][EQUIP_SLOT_C_DOWN] + : (gSaveContext.unk_3F22 == 0x10) ? gSaveContext.save.equips.buttonItems[0][EQUIP_SLOT_C_DOWN] + : ITEM_NONE; + } + + return (gSaveContext.buttonStatus[3] != BTN_DISABLED) ? gSaveContext.save.equips.buttonItems[0][EQUIP_SLOT_C_RIGHT] + : (gSaveContext.unk_3F22 == 0x10) ? gSaveContext.save.equips.buttonItems[0][EQUIP_SLOT_C_RIGHT] + : ITEM_NONE; +} #pragma GLOBAL_ASM("asm/non_matchings/code/z_player_lib/func_80123810.s") -#pragma GLOBAL_ASM("asm/non_matchings/code/z_player_lib/func_80123960.s") +extern u8 sActionModelGroups[]; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_player_lib/func_801239AC.s") +s32 Player_ActionToModelGroup(Player* player, s32 actionParam) { + s32 modelGroup = sActionModelGroups[actionParam]; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_player_lib/func_80123AA4.s") + if ((modelGroup == 2) && Player_IsGoronOrDeku(player)) { + return 1; + } + return modelGroup; +} -#pragma GLOBAL_ASM("asm/non_matchings/code/z_player_lib/func_80123BD4.s") +extern u8 D_801BFF90[PLAYER_FORM_MAX]; +#if 0 +u8 D_801BFF90[PLAYER_FORM_MAX] = { + PLAYER_BOOTS_FIERCE_DEITY, // PLAYER_FORM_FIERCE_DEITY + PLAYER_BOOTS_GORON, // PLAYER_FORM_GORON + PLAYER_BOOTS_ZORA_LAND, // PLAYER_FORM_ZORA + PLAYER_BOOTS_DEKU, // PLAYER_FORM_DEKU + PLAYER_BOOTS_HYLIAN, // PLAYER_FORM_HUMAN +}; +#endif -#pragma GLOBAL_ASM("asm/non_matchings/code/z_player_lib/func_80123C58.s") +extern u8 sPlayerStrengths[PLAYER_FORM_MAX]; +#if 0 +u8 sPlayerStrengths[PLAYER_FORM_MAX] = { + PLAYER_STRENGTH_HUMAN, // PLAYER_FORM_FIERCE_DEITY + PLAYER_STRENGTH_GORON, // PLAYER_FORM_GORON + PLAYER_STRENGTH_ZORA, // PLAYER_FORM_ZORA + PLAYER_STRENGTH_DEKU, // PLAYER_FORM_DEKU + PLAYER_STRENGTH_HUMAN, // PLAYER_FORM_HUMAN +}; +#endif -#pragma GLOBAL_ASM("asm/non_matchings/code/z_player_lib/Player_SetEquipmentData.s") +typedef struct { + /* 0x00 */ u8 flag; + /* 0x02 */ u16 textId; +} TextTriggerEntry; // size = 0x04 -#pragma GLOBAL_ASM("asm/non_matchings/code/z_player_lib/func_80123D50.s") +extern TextTriggerEntry sEnvironmentTextTriggers[]; +// These textIds are OoT remnants. The corresponding text entries are not present in this game, and so these don't point +// to anything relevant. +#if 0 +TextTriggerEntry sEnvironmentTextTriggers[] = { + { 1, 0x26FC }, + { 2, 0x26FD }, + { 0, 0 }, + { 2, 0x26FD }, +}; +#endif -#pragma GLOBAL_ASM("asm/non_matchings/code/z_player_lib/func_80123DA4.s") +extern Gfx** sPlayerDListGroups[]; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_player_lib/func_80123DC0.s") +void func_801239AC(Player* player) { + if (player->stateFlags1 & PLAYER_STATE1_400000) { + if ((player->heldItemActionParam < 0) || (player->heldItemActionParam == player->itemActionParam)) { + if (!Player_IsHoldingTwoHandedWeapon(player)) { + if (!Player_IsGoronOrDeku(player)) { + D_801F59E0 = player->transformation * 2; + player->rightHandType = 8; + player->rightHandDLists = &sPlayerDListGroups[8][D_801F59E0]; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_player_lib/func_80123E90.s") + if (player->sheathType == 14) { + player->sheathType = 12; + } else if (player->sheathType == 15) { + player->sheathType = 13; + } -#pragma GLOBAL_ASM("asm/non_matchings/code/z_player_lib/func_80123F14.s") + player->sheathDLists = &sPlayerDListGroups[player->sheathType][D_801F59E0]; + player->modelAnimType = 2; + player->heldItemActionParam = -1; + } + } + } + } +} -#pragma GLOBAL_ASM("asm/non_matchings/code/z_player_lib/func_80123F2C.s") +void Player_SetModels(Player* player, s32 modelGroup) { + u8* playerModelTypes; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_player_lib/func_80123F48.s") + D_801F59E0 = player->transformation * 2; + player->leftHandType = gPlayerModelTypes[modelGroup][1]; + player->rightHandType = gPlayerModelTypes[modelGroup][2]; + player->sheathType = gPlayerModelTypes[modelGroup][3]; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_player_lib/func_80124020.s") + if (player->sheathType == 14) { + if (CUR_FORM_EQUIP(EQUIP_SLOT_B) == ITEM_NONE) { + player->sheathType = 15; + } + } -#pragma GLOBAL_ASM("asm/non_matchings/code/z_player_lib/Player_GetMask.s") + playerModelTypes = gPlayerModelTypes[modelGroup]; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_player_lib/Player_RemoveMask.s") + player->leftHandDLists = &sPlayerDListGroups[playerModelTypes[1]][D_801F59E0]; + player->rightHandDLists = &sPlayerDListGroups[playerModelTypes[2]][D_801F59E0]; + player->sheathDLists = &sPlayerDListGroups[playerModelTypes[3]][D_801F59E0]; + player->waistDLists = &sPlayerDListGroups[playerModelTypes[4]][D_801F59E0]; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_player_lib/func_8012405C.s") + func_801239AC(player); +} -#pragma GLOBAL_ASM("asm/non_matchings/code/z_player_lib/func_80124088.s") +void Player_SetModelGroup(Player* player, s32 modelGroup) { + player->modelGroup = modelGroup; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_player_lib/func_801240C8.s") + if (modelGroup == 1) { + player->modelAnimType = 0; + } else { + player->modelAnimType = gPlayerModelTypes[modelGroup][0]; + } -#pragma GLOBAL_ASM("asm/non_matchings/code/z_player_lib/func_801240DC.s") + if (player->modelAnimType < 3) { + if (((player->transformation != PLAYER_FORM_FIERCE_DEITY) && (player->transformation != PLAYER_FORM_HUMAN)) || + (player->currentShield == PLAYER_SHIELD_NONE)) { + player->modelAnimType = 0; + } + } -#pragma GLOBAL_ASM("asm/non_matchings/code/z_player_lib/func_80124110.s") + Player_SetModels(player, modelGroup); +} -#pragma GLOBAL_ASM("asm/non_matchings/code/z_player_lib/func_80124148.s") +void func_80123C58(Player* player) { + player->heldItemActionParam = player->itemActionParam; + Player_SetModelGroup(player, Player_ActionToModelGroup(player, player->itemActionParam)); + player->unk_AA5 = 0; +} -#pragma GLOBAL_ASM("asm/non_matchings/code/z_player_lib/func_80124168.s") +void Player_SetEquipmentData(PlayState* play, Player* player) { + if (player->csMode != 0x86) { + player->currentShield = GET_CUR_EQUIP_VALUE(EQUIP_TYPE_SHIELD); + if ((player->transformation != PLAYER_FORM_ZORA) || (((player->currentBoots != PLAYER_BOOTS_ZORA_LAND)) && + (player->currentBoots != PLAYER_BOOTS_ZORA_UNDERWATER))) { + player->currentBoots = D_801BFF90[player->transformation]; + } + Player_SetModelGroup(player, Player_ActionToModelGroup(player, player->itemActionParam)); + func_80123140(play, player); + if (player->unk_B62 != 0) { + player->unk_B62 = 1; + } + } +} -#pragma GLOBAL_ASM("asm/non_matchings/code/z_player_lib/func_80124190.s") +void func_80123D50(PlayState* play, Player* player, s32 itemId, s32 actionParam) { + Inventory_UpdateBottleItem(play, itemId, player->heldItemButton); -#pragma GLOBAL_ASM("asm/non_matchings/code/z_player_lib/func_801241B4.s") + if (itemId != ITEM_BOTTLE) { + player->heldItemId = itemId; + player->itemActionParam = actionParam; + } -#pragma GLOBAL_ASM("asm/non_matchings/code/z_player_lib/func_801241E0.s") + player->heldItemActionParam = actionParam; +} -#pragma GLOBAL_ASM("asm/non_matchings/code/z_player_lib/func_8012420C.s") +void func_80123DA4(Player* player) { + player->unk_730 = NULL; + player->stateFlags2 &= ~PLAYER_STATE2_2000; +} -#pragma GLOBAL_ASM("asm/non_matchings/code/z_player_lib/func_8012422C.s") +void func_80123DC0(Player* player) { + if ((player->actor.bgCheckFlags & 1) || + (player->stateFlags1 & (PLAYER_STATE1_8000000 | PLAYER_STATE1_800000 | PLAYER_STATE1_200000)) || + (!(player->stateFlags1 & (PLAYER_STATE1_80000 | PLAYER_STATE1_40000)) && + ((player->actor.world.pos.y - player->actor.floorHeight) < 100.0f))) { + player->stateFlags1 &= ~(PLAYER_STATE1_40000000 | PLAYER_STATE1_80000 | PLAYER_STATE1_40000 | + PLAYER_STATE1_20000 | PLAYER_STATE1_10000 | PLAYER_STATE1_8000); + } else if (!(player->stateFlags1 & (PLAYER_STATE1_200000 | PLAYER_STATE1_80000 | PLAYER_STATE1_40000))) { + player->stateFlags1 |= PLAYER_STATE1_80000; + } else if ((player->stateFlags1 & PLAYER_STATE1_40000) && (player->transformation == PLAYER_FORM_DEKU)) { + player->stateFlags1 &= + ~(PLAYER_STATE1_40000000 | PLAYER_STATE1_20000 | PLAYER_STATE1_10000 | PLAYER_STATE1_8000); + } -#pragma GLOBAL_ASM("asm/non_matchings/code/z_player_lib/Player_GetExplosiveHeld.s") + func_80123DA4(player); +} -#pragma GLOBAL_ASM("asm/non_matchings/code/z_player_lib/func_80124278.s") +void func_80123E90(PlayState* play, Actor* actor) { + Player* player = GET_PLAYER(play); -#pragma GLOBAL_ASM("asm/non_matchings/code/z_player_lib/func_801242B4.s") + func_80123DC0(player); + player->unk_730 = actor; + player->unk_A78 = actor; + player->stateFlags1 |= PLAYER_STATE1_10000; + Camera_SetViewParam(Play_GetCamera(play, CAM_ID_MAIN), CAM_VIEW_TARGET, actor); + Camera_ChangeMode(Play_GetCamera(play, CAM_ID_MAIN), CAM_MODE_FOLLOWTARGET); +} -#pragma GLOBAL_ASM("asm/non_matchings/code/z_player_lib/func_801242DC.s") +s32 func_80123F14(PlayState* play) { + Player* player = GET_PLAYER(play); + + return player->stateFlags1 & PLAYER_STATE1_800000; +} + +s32 func_80123F2C(PlayState* play, s32 ammo) { + play->unk_1887C = ammo + 1; + + return 1; +} + +s32 Player_IsBurningStickInRange(PlayState* play, Vec3f* pos, f32 xzRange, f32 yRange) { + Player* this = GET_PLAYER(play); + Vec3f diff; + s32 pad; + + if ((this->itemActionParam == PLAYER_AP_STICK) && (this->unk_B28 != 0)) { + Math_Vec3f_Diff(&this->meleeWeaponInfo[0].tip, pos, &diff); + return (SQXZ(diff) <= SQ(xzRange)) && (0.0f <= diff.y) && (diff.y <= yRange); + } + + return false; +} + +u8 Player_GetStrength(void) { + return sPlayerStrengths[(void)0, gSaveContext.save.playerForm]; +} + +u8 Player_GetMask(PlayState* play) { + Player* player = GET_PLAYER(play); + + return player->currentMask; +} + +// Unused +void Player_RemoveMask(PlayState* play) { + Player* player = GET_PLAYER(play); + + player->currentMask = PLAYER_MASK_NONE; +} + +s32 Player_HasMirrorShieldEquipped(PlayState* play) { + Player* player = GET_PLAYER(play); + + return (player->transformation == PLAYER_FORM_HUMAN) && (player->currentShield == PLAYER_SHIELD_MIRROR_SHIELD); +} + +s32 Player_IsHoldingMirrorShield(PlayState* play) { + Player* player = GET_PLAYER(play); + + return (player->transformation == PLAYER_FORM_HUMAN) && (player->rightHandType == 8) && + (player->currentShield == PLAYER_SHIELD_MIRROR_SHIELD); +} + +s32 Player_IsHoldingHookshot(Player* player) { + return player->itemActionParam == PLAYER_AP_HOOKSHOT; +} + +s32 func_801240DC(Player* player) { + return Player_IsHoldingHookshot(player) && (player->heldActor == NULL); +} + +s32 func_80124110(Player* player, s32 actionParam) { + s32 temp_v0 = actionParam - PLAYER_AP_FISHING_ROD; + + if (player->transformation != PLAYER_FORM_GORON) { + if (((actionParam - PLAYER_AP_FISHING_ROD) > (PLAYER_AP_FISHING_ROD - PLAYER_AP_FISHING_ROD)) && + ((actionParam - PLAYER_AP_FISHING_ROD) < (PLAYER_AP_SWORD_GREAT_FAIRY - PLAYER_AP_FISHING_ROD))) { + return temp_v0; + } + } + + return 0; +} + +s32 func_80124148(Player* player) { + return func_80124110(player, player->itemActionParam); +} + +s32 Player_ActionToMeleeWeapon(s32 actionParam) { + s32 weapon = actionParam - (PLAYER_AP_SWORD_KOKIRI - 1); + + if ((weapon > 0) && (weapon <= (PLAYER_AP_ZORA_FINS - (PLAYER_AP_SWORD_KOKIRI - 1)))) { + return weapon; + } + return 0; +} + +s32 Player_GetMeleeWeaponHeld(Player* player) { + return Player_ActionToMeleeWeapon(player->itemActionParam); +} + +s32 Player_IsHoldingTwoHandedWeapon(Player* player) { + // Relies on the actionParams for two-handed weapons being contiguous. + if ((player->itemActionParam >= PLAYER_AP_SWORD_GREAT_FAIRY) && (player->itemActionParam <= PLAYER_AP_STICK)) { + return true; + } + + return false; +} + +s32 Player_ActionToBottle(Player* player, s32 actionParam) { + s32 bottle = actionParam - PLAYER_AP_BOTTLE; + + // Relies on bottle-related action params to be contiguous + if ((bottle >= (PLAYER_AP_BOTTLE - PLAYER_AP_BOTTLE)) && (bottle <= (PLAYER_AP_BOTTLE_FAIRY - PLAYER_AP_BOTTLE))) { + return bottle; + } + + return -1; +} + +s32 Player_GetBottleHeld(Player* Player) { + return Player_ActionToBottle(Player, Player->itemActionParam); +} + +s32 Player_ActionToExplosive(Player* player, s32 actionParam) { + s32 explosive = actionParam - PLAYER_AP_BOMB; + + // Relies on explosive-related action params to be contiguous + if ((explosive >= (PLAYER_AP_BOMB - PLAYER_AP_BOMB)) && (explosive <= (PLAYER_AP_BOMBCHU - PLAYER_AP_BOMB))) { + return explosive; + } + + return -1; +} + +s32 Player_GetExplosiveHeld(Player* player) { + return Player_ActionToExplosive(player, player->itemActionParam); +} + +// Convert actionParam to sword +s32 func_80124278(Actor* actor, s32 actionParam) { + s32 sword = 0; + + //! FAKE: + if ((actionParam == PLAYER_AP_LAST_USED) || + ((sword = actionParam - PLAYER_AP_SWORD_KOKIRI, (sword >= PLAYER_AP_SWORD_KOKIRI - PLAYER_AP_SWORD_KOKIRI)) && + (sword <= PLAYER_AP_SWORD_GREAT_FAIRY - PLAYER_AP_SWORD_KOKIRI))) { + return sword; + } + + return -1; +} + +s32 func_801242B4(Player* player) { + return (player->stateFlags1 & PLAYER_STATE1_8000000) && player->currentBoots < PLAYER_BOOTS_ZORA_UNDERWATER; +} + +s32 func_801242DC(PlayState* play) { + Player* player = GET_PLAYER(play); + TextTriggerEntry* triggerEntry; + s32 envIndex; + + if (play->roomCtx.currRoom.unk2 == 3) { // Room is hot + envIndex = 0; + } else if ((player->transformation != PLAYER_FORM_ZORA) && (player->unk_AD8 > 80)) { + envIndex = 3; + } else if (player->stateFlags1 & PLAYER_STATE1_8000000) { + if ((player->transformation == PLAYER_FORM_ZORA) && (player->currentBoots >= PLAYER_BOOTS_ZORA_UNDERWATER) && + (player->actor.bgCheckFlags & 1)) { + envIndex = 1; + } else { + envIndex = 2; + } + } else { + return 0; + } + + // Trigger general textboxes under certain conditions, like "It's so hot in here!". Unused in MM + triggerEntry = &sEnvironmentTextTriggers[envIndex]; + if (!Player_InCsMode(play)) { + if ((triggerEntry->flag) && !(gSaveContext.textTriggerFlags & triggerEntry->flag) && (envIndex == 0)) { + Message_StartTextbox(play, triggerEntry->textId, NULL); + gSaveContext.textTriggerFlags |= triggerEntry->flag; + } + } + + return envIndex + 1; +} #pragma GLOBAL_ASM("asm/non_matchings/code/z_player_lib/func_80124420.s") -#pragma GLOBAL_ASM("asm/non_matchings/code/z_player_lib/func_80124618.s") +void func_80124618(struct_80124618 arg0[], f32 curFrame, Vec3f* arg2) { + s32 currentFrame = curFrame; + f32 temp_f0; + f32 temp_f14; + f32 progress; + s16 temp_v1; + + do { + temp_v1 = arg0[1].unk_0; + arg0++; + } while (temp_v1 < currentFrame); + + temp_f0 = arg0[-1].unk_0; + + progress = (curFrame - temp_f0) / (temp_v1 - temp_f0); + + temp_f14 = arg0[-1].unk_2.x; + arg2->x = LERPIMP(temp_f14, arg0->unk_2.x, progress) * 0.01f; + + temp_f14 = arg0[-1].unk_2.y; + arg2->y = LERPIMP(temp_f14, arg0->unk_2.y, progress) * 0.01f; + + temp_f14 = arg0[-1].unk_2.z; + arg2->z = LERPIMP(temp_f14, arg0->unk_2.z, progress) * 0.01f; +} #pragma GLOBAL_ASM("asm/non_matchings/code/z_player_lib/func_801246F4.s") @@ -132,22 +926,122 @@ #pragma GLOBAL_ASM("asm/non_matchings/code/z_player_lib/func_80124CC4.s") -#pragma GLOBAL_ASM("asm/non_matchings/code/z_player_lib/func_80124F18.s") +extern s32 D_801C0958; +#if 0 +s32 D_801C0958 = false; +#endif -#pragma GLOBAL_ASM("asm/non_matchings/code/z_player_lib/func_80124FF0.s") +void func_80124F18(s16* arg0, f32* arg1, s16 arg2, f32 arg3, f32 arg4) { + f32 phi_f12; + + if (*arg0 < arg2) { + *arg1 += arg3; + } else { + *arg1 -= arg3; + } + + *arg1 = CLAMP(*arg1, -arg4, arg4); + *arg0 += (s16)*arg1; + if (((arg2 - *arg0) * (s16)*arg1) < 0) { + *arg0 = arg2; + } +} + +void func_80124FF0(f32 arg0, s16 arg1, Vec3f* arg2, s16 arg3, Vec3f* arg4, Vec3f* arg5, s16* arg6, f32* arg7, f32 arg8, + s16 arg9, s16* arg10, f32* arg11, s32 arg12) { + Vec3f sp44; + f32 sp40; + s16 temp_v0; + s16 sp3C; + f32 temp_f14; + f32 sp34 = Math_CosS(arg1) * arg0; + f32 sp30 = Math_SinS(arg1) * -arg0; + + arg5->x = (Math_SinS(arg3) * sp30) + arg2->x; + arg5->y = arg2->y + sp34; + arg5->z = (Math_CosS(arg3) * sp30) + arg2->z; + + Math_Vec3f_Diff(arg5, arg4, &sp44); + sp40 = sqrtf(SQXZ(sp44)); + + sp3C = (sp40 <= 1.0f) ? arg3 : Math_FAtan2F(sp44.z, sp44.x); + sp40 = (Math_CosS(sp3C - arg3) * sp40) + arg8; + + if (ABS_ALT(BINANG_SUB(sp3C, arg3)) > 0x4000) { + sp3C = BINANG_ROT180(sp3C); + } + sp3C -= arg3; + + temp_v0 = Math_FAtan2F(sp44.y, sp40); + temp_v0 = CLAMP(temp_v0, (s16)-arg9, arg9); + //! FAKE: + if (sp3C) {} + + func_80124F18(arg6, arg7, temp_v0, 20.0f, 2000.0f); +} #pragma GLOBAL_ASM("asm/non_matchings/code/z_player_lib/func_801251C4.s") -#pragma GLOBAL_ASM("asm/non_matchings/code/z_player_lib/func_80125318.s") +void func_80125318(Vec3f* arg0, Vec3s* arg1) { + arg0->x = 0.0f; + arg0->y = 0.0f; + arg0->z = 0.0f; + arg1->x = 0; + arg1->y = 0; + arg1->z = 0; +} -#pragma GLOBAL_ASM("asm/non_matchings/code/z_player_lib/func_80125340.s") +void func_80125340(void) { + Matrix_Push(); + D_801C0958 = true; +} -#pragma GLOBAL_ASM("asm/non_matchings/code/z_player_lib/func_8012536C.s") +void func_8012536C(void) { + if (D_801C0958) { + Matrix_Pop(); + D_801C0958 = false; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/code/z_player_lib/func_801253A4.s") +void Player_DrawZoraShield(PlayState* play, Player* player) { + u8* phi_a0; + Vtx* vtx; + Gfx* dList; + f32 scale; + s32 i; + + scale = player->unk_B62 * (10.0f / 51.0f); + + OPEN_DISPS(play->state.gfxCtx); + + AnimatedMat_DrawXlu(play, Lib_SegmentedToVirtual(&object_link_zora_Matanimheader_012A80)); + Matrix_Scale(scale, scale, scale, MTXMODE_APPLY); + + // clang-format off + vtx = Lib_SegmentedToVirtual(&object_link_zora_Vtx_011210); phi_a0 = Lib_SegmentedToVirtual(&object_link_zora_U8_011710); + // clang-format on + + // ARRAY_COUNT(object_link_zora_Vtx_011210) + for (i = 0; i < 80; i++) { + // Editing the Vtxs in object itself + vtx->v.cn[3] = (*phi_a0 * player->unk_B62) >> 8; + vtx++; + phi_a0++; + } + + dList = POLY_XLU_DISP; + + gSPMatrix(&dList[0], Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(&dList[1], object_link_zora_DL_011760); + + POLY_XLU_DISP = &dList[2]; + + CLOSE_DISPS(play->state.gfxCtx); +} #pragma GLOBAL_ASM("asm/non_matchings/code/z_player_lib/func_80125500.s") +s32 func_80125580(PlayState* play, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, Actor* thisx); #pragma GLOBAL_ASM("asm/non_matchings/code/z_player_lib/func_80125580.s") #pragma GLOBAL_ASM("asm/non_matchings/code/z_player_lib/func_80125CE0.s") @@ -156,17 +1050,102 @@ #pragma GLOBAL_ASM("asm/non_matchings/code/z_player_lib/func_801262C8.s") -#pragma GLOBAL_ASM("asm/non_matchings/code/z_player_lib/func_801263FC.s") +// unused +s32 func_801263FC(PlayState* play, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, Actor* thisx) { + Player* player = (Player*)thisx; + + if (!func_80125580(play, limbIndex, dList, pos, rot, thisx)) { + *dList = NULL; + } + + return false; +} #pragma GLOBAL_ASM("asm/non_matchings/code/z_player_lib/func_80126440.s") -#pragma GLOBAL_ASM("asm/non_matchings/code/z_player_lib/func_801265C8.s") +extern u8 D_801C096C[PLAYER_SHIELD_MAX]; +#if 0 +u8 D_801C096C[PLAYER_SHIELD_MAX] = { + COLTYPE_METAL, + COLTYPE_METAL, + COLTYPE_METAL, +}; +#endif + +void func_801265C8(PlayState* play, Player* player, ColliderQuad* collider, Vec3f arg3[4]) { + if (player->stateFlags1 & PLAYER_STATE1_400000) { + Vec3f sp4C; + Vec3f sp40; + Vec3f sp34; + Vec3f sp28; + + player->shieldQuad.base.colType = D_801C096C[player->currentShield]; + Matrix_MultVec3f(&arg3[0], &sp28); + Matrix_MultVec3f(&arg3[1], &sp34); + Matrix_MultVec3f(&arg3[2], &sp40); + Matrix_MultVec3f(&arg3[3], &sp4C); + Collider_SetQuadVertices(collider, &sp28, &sp34, &sp40, &sp4C); + CollisionCheck_SetAC(play, &play->colChkCtx, &collider->base); + CollisionCheck_SetAT(play, &play->colChkCtx, &collider->base); + } +} #pragma GLOBAL_ASM("asm/non_matchings/code/z_player_lib/func_8012669C.s") -#pragma GLOBAL_ASM("asm/non_matchings/code/z_player_lib/func_80126808.s") +void Player_DrawGetItemImpl(PlayState* play, Player* player, Vec3f* refPos, s32 drawIdPlusOne) { + f32 sp34; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_player_lib/func_8012697C.s") + if (player->stateFlags3 & PLAYER_STATE3_4000000) { + sp34 = 6.0f; + } else { + sp34 = 14.0f; + } + + OPEN_DISPS(play->state.gfxCtx); + + gSegments[6] = PHYSICAL_TO_VIRTUAL(player->giObjectSegment); + + gSPSegment(POLY_OPA_DISP++, 0x06, player->giObjectSegment); + gSPSegment(POLY_XLU_DISP++, 0x06, player->giObjectSegment); + + Matrix_Translate((Math_SinS(player->actor.shape.rot.y) * 3.3f) + refPos->x, refPos->y + sp34, + (Math_CosS(player->actor.shape.rot.y) * 3.3f) + refPos->z, MTXMODE_NEW); + Matrix_RotateZYX(0, (play->gameplayFrames * 1000), 0, MTXMODE_APPLY); + Matrix_Scale(0.2f, 0.2f, 0.2f, MTXMODE_APPLY); + GetItem_Draw(play, drawIdPlusOne - 1); + + CLOSE_DISPS(play->state.gfxCtx); +} + +void Player_DrawGetItem(PlayState* play, Player* player) { + if (!player->giObjectLoading || (osRecvMesg(&player->giObjectLoadQueue, NULL, OS_MESG_NOBLOCK) == 0)) { + Vec3f refPos; + s32 drawIdPlusOne; + + player->giObjectLoading = false; + if ((player->actor.id == ACTOR_EN_TEST3) || + ((player->transformation == PLAYER_FORM_DEKU) && (player->stateFlags1 & PLAYER_STATE1_400))) { + refPos.x = player->actor.world.pos.x; + refPos.z = player->actor.world.pos.z; + if (player->actor.id == ACTOR_EN_TEST3) { + if (player->stateFlags1 & PLAYER_STATE1_400) { + refPos.y = player->actor.world.pos.y + 30.0f; + } else { + refPos.x = player->bodyPartsPos[0xC].x; + refPos.y = player->bodyPartsPos[0xC].y - 6.0f; + refPos.z = player->bodyPartsPos[0xC].z; + } + } else { + refPos.y = player->actor.world.pos.y + 28.0f; + } + } else { + Math_Vec3f_Copy(&refPos, &D_801F59E8); + } + + drawIdPlusOne = ABS_ALT(player->unk_B2A); + Player_DrawGetItemImpl(play, player, &refPos, drawIdPlusOne); + } +} #pragma GLOBAL_ASM("asm/non_matchings/code/z_player_lib/func_80126AB4.s") @@ -176,11 +1155,37 @@ #pragma GLOBAL_ASM("asm/non_matchings/code/z_player_lib/func_801271B0.s") -#pragma GLOBAL_ASM("asm/non_matchings/code/z_player_lib/func_80127438.s") +// Player_SetMaskSegment? +s32 func_80127438(PlayState* play, Player* player, s32 currentMask) { + if ((player->maskObjectLoadState == 0) && (currentMask == (u8)player->maskId)) { + OPEN_DISPS(play->state.gfxCtx); -#pragma GLOBAL_ASM("asm/non_matchings/code/z_player_lib/func_80127488.s") + gSPSegment(POLY_OPA_DISP++, 0x0A, player->maskObjectSegment); -#pragma GLOBAL_ASM("asm/non_matchings/code/z_player_lib/func_8012754C.s") + CLOSE_DISPS(play->state.gfxCtx); + + return true; + } + + return false; +} + +void func_80127488(PlayState* play, Player* player, u8 alpha) { + OPEN_DISPS(play->state.gfxCtx); + + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gDPSetEnvColor(POLY_XLU_DISP++, 255, 0, 0, alpha); + gSPDisplayList(POLY_XLU_DISP++, gLinkGoronGoronPunchEffectDL); + + func_80122BA4(play, &player->unk_3D0, 3, alpha); + + CLOSE_DISPS(play->state.gfxCtx); +} + +void Player_DrawCouplesMask(PlayState* play, Player* player) { + gSegments[0xA] = PHYSICAL_TO_VIRTUAL(player->maskObjectSegment); + AnimatedMat_DrawOpa(play, Lib_SegmentedToVirtual(&object_mask_meoto_Matanimheader_001CD8)); +} #pragma GLOBAL_ASM("asm/non_matchings/code/z_player_lib/func_80127594.s") diff --git a/src/code/z_quake.c b/src/code/z_quake.c index ee4fa3a6d..7caa0f426 100644 --- a/src/code/z_quake.c +++ b/src/code/z_quake.c @@ -303,7 +303,7 @@ s16 Quake_Calc(Camera* camera, QuakeCamCalc* camData) { s32 ret; u32 eq; Vec3f originVec; - GlobalContext* globalCtx = camera->globalCtx; + PlayState* play = camera->play; originVec.x = 0.0f; originVec.y = 0.0f; @@ -326,7 +326,7 @@ 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->camId] == NULL) { + if (play->cameraPtrs[req->camId] == NULL) { Quake_Remove(req); } else { eq = (camera->camId != req->camera->camId); @@ -382,9 +382,9 @@ s16 Quake_Calc(Camera* camera, QuakeCamCalc* camData) { return ret; } -void Distortion_Init(GlobalContext* globalCtx) { - sDistortionContext.globalCtx = globalCtx; - View_ClearDistortion(&globalCtx->view); +void Distortion_Init(PlayState* play) { + sDistortionContext.play = play; + View_ClearDistortion(&play->view); sDistortionContext.type = 0; sDistortionContext.countdown = 0; sDistortionContext.state = DISTORTION_INACTIVE; @@ -419,9 +419,9 @@ void Distortion_ClearType(s32 type) { * Checks that the bg surface is an underwater conveyor type and if so, returns the conveyor speed */ s32 Distortion_GetUnderwaterCurrentSpeed(Player* player) { - if (SurfaceType_GetConveyorType(&sDistortionContext.globalCtx->colCtx, player->actor.floorPoly, + if (SurfaceType_GetConveyorType(&sDistortionContext.play->colCtx, player->actor.floorPoly, player->actor.floorBgId) == CONVEYOR_WATER) { - return SurfaceType_GetConveyorSpeed(&sDistortionContext.globalCtx->colCtx, player->actor.floorPoly, + return SurfaceType_GetConveyorSpeed(&sDistortionContext.play->colCtx, player->actor.floorPoly, player->actor.floorBgId); } return 0; @@ -446,9 +446,9 @@ void Distortion_Update(void) { f32 zScale; f32 speed; Player* player; - GlobalContext* globalCtx = sDistortionContext.globalCtx; + PlayState* play = sDistortionContext.play; PosRot playerPosRot; - Camera* camera = GET_ACTIVE_CAM(globalCtx); + Camera* camera = GET_ACTIVE_CAM(play); f32 speedRatio = CLAMP_MAX(camera->speedRatio, 1.0f); if (sDistortionContext.type != 0) { @@ -636,9 +636,9 @@ void Distortion_Update(void) { screenPlanePhase = 0x156; sDistortionContext.countdown = 2; - player = GET_PLAYER(globalCtx); + player = GET_PLAYER(play); - if (&player->actor != NULL) { + if (player != NULL) { Actor_GetWorldPosShapeRot(&playerPosRot, &player->actor); } @@ -688,7 +688,7 @@ void Distortion_Update(void) { screenPlanePhase = 0x156; sDistortionContext.countdown = 2; - player = GET_PLAYER(globalCtx); + player = GET_PLAYER(play); depthPhaseStep = 359.2f; screenPlanePhaseStep = -18.5f; @@ -756,23 +756,23 @@ void Distortion_Update(void) { return; } - depthPhase += DEGF_TO_BINANG(depthPhaseStep); - screenPlanePhase += DEGF_TO_BINANG(screenPlanePhaseStep); + depthPhase += CAM_DEG_TO_BINANG(depthPhaseStep); + screenPlanePhase += CAM_DEG_TO_BINANG(screenPlanePhaseStep); - View_SetDistortionDirRot(&sDistortionContext.globalCtx->view, + View_SetDistortionDirRot(&sDistortionContext.play->view, Math_CosS(depthPhase) * (DEGF_TO_RADF(rotX) * xyScaleFactor), Math_SinS(depthPhase) * (DEGF_TO_RADF(rotY) * xyScaleFactor), Math_SinS(screenPlanePhase) * (DEGF_TO_RADF(rotZ) * zScaleFactor)); - View_SetDistortionScale(&sDistortionContext.globalCtx->view, + View_SetDistortionScale(&sDistortionContext.play->view, (Math_SinS(screenPlanePhase) * (xScale * xyScaleFactor)) + 1.0f, (Math_CosS(screenPlanePhase) * (yScale * xyScaleFactor)) + 1.0f, (Math_CosS(depthPhase) * (zScale * zScaleFactor)) + 1.0f); - View_SetDistortionSpeed(&sDistortionContext.globalCtx->view, speed * speedScaleFactor); + View_SetDistortionSpeed(&sDistortionContext.play->view, speed * speedScaleFactor); sDistortionContext.state = DISTORTION_ACTIVE; } else if (sDistortionContext.state != DISTORTION_INACTIVE) { - View_ClearDistortion(&globalCtx->view); + View_ClearDistortion(&play->view); sDistortionContext.state = DISTORTION_INACTIVE; sDistortionContext.countdown = 0; diff --git a/src/code/z_rcp.c b/src/code/z_rcp.c index f4ffd43c1..ace1cc4cd 100644 --- a/src/code/z_rcp.c +++ b/src/code/z_rcp.c @@ -896,8 +896,8 @@ void func_8012C240(GraphicsContext* gfxCtx) { gSPDisplayList(gfxCtx->polyXlu.p++, &sSetupDL[6 * 0x19]); } -void func_8012C268(GlobalContext* globalCtx) { - func_8012C28C(globalCtx->state.gfxCtx); +void func_8012C268(PlayState* play) { + func_8012C28C(play->state.gfxCtx); } void func_8012C28C(GraphicsContext* gfxCtx) { @@ -1239,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]); @@ -1267,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, &D_0F000000); + gDPSetColorImage(&masterGfx[6], G_IM_FMT_RGBA, G_IM_SIZ_16b, D_801FBBCC, D_0F000000); gSPEndDisplayList(&masterGfx[7]); } @@ -1275,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)); diff --git a/src/code/z_room.c b/src/code/z_room.c index 7579c6200..169d6d5b5 100644 --- a/src/code/z_room.c +++ b/src/code/z_room.c @@ -1,30 +1,30 @@ #include "global.h" -void Room_nop8012D510(GlobalContext* globalCtx, Room* room, UNK_PTR param_3, UNK_TYPE1 param_4) { +void Room_nop8012D510(PlayState* play, Room* room, UNK_PTR param_3, UNK_TYPE1 param_4) { } -void Room_DrawType3Mesh(GlobalContext* globalCtx, Room* room, u32 flags) { +void Room_DrawType3Mesh(PlayState* play, Room* room, u32 flags) { } -void Room_DrawType0Mesh(GlobalContext* globalCtx, Room* room, u32 flags) { +void Room_DrawType0Mesh(PlayState* play, Room* room, u32 flags) { RoomMeshType0* mesh; s32 i; RoomMeshType0Params* meshParams; GraphicsContext* gfxCtx; UNK_TYPE4 pad; - gfxCtx = globalCtx->state.gfxCtx; + gfxCtx = play->state.gfxCtx; if (flags & 1) { - func_800BCBF4(&D_801C1D10, globalCtx); + func_800BCBF4(&D_801C1D10, play); gSPSegment(gfxCtx->polyOpa.p++, 0x03, room->segment); - func_8012C268(globalCtx); + func_8012C268(play); gSPMatrix(gfxCtx->polyOpa.p++, &gIdentityMtx, G_MTX_MODELVIEW | G_MTX_LOAD); } if (flags & 2) { - func_800BCC68(&D_801C1D10, globalCtx); + func_800BCC68(&D_801C1D10, play); gSPSegment(gfxCtx->polyXlu.p++, 0x03, room->segment); - func_8012C2DC(globalCtx->state.gfxCtx); + func_8012C2DC(play->state.gfxCtx); gSPMatrix(gfxCtx->polyXlu.p++, &gIdentityMtx, G_MTX_MODELVIEW | G_MTX_LOAD); } @@ -51,18 +51,18 @@ void Room_DrawType0Mesh(GlobalContext* globalCtx, Room* room, u32 flags) { #pragma GLOBAL_ASM("asm/non_matchings/code/z_room/func_8012E32C.s") -void Room_DrawType1Mesh(GlobalContext* globalCtx, Room* room, u32 flags) { +void Room_DrawType1Mesh(PlayState* play, Room* room, u32 flags) { RoomMeshType1* mesh = &room->mesh->type1; if (mesh->format == 1) { - func_8012DEE8(globalCtx, room, flags); + func_8012DEE8(play, room, flags); } else if (mesh->format == 2) { - func_8012E32C(globalCtx, room, flags); + func_8012E32C(play, room, flags); } else { - __assert("../z_room.c", 0x3c5); + __assert("../z_room.c", 965); } } -void Room_Init(GlobalContext* globalCtx, RoomContext* roomCtx) { +void Room_Init(PlayState* play, RoomContext* roomCtx) { s32 i; roomCtx->currRoom.num = -1; roomCtx->currRoom.segment = NULL; @@ -75,7 +75,7 @@ void Room_Init(GlobalContext* globalCtx, RoomContext* roomCtx) { #pragma GLOBAL_ASM("asm/non_matchings/code/z_room/Room_AllocateAndLoad.s") -s32 Room_StartRoomTransition(GlobalContext* globalCtx, RoomContext* roomCtx, s32 index) { +s32 Room_StartRoomTransition(PlayState* play, RoomContext* roomCtx, s32 index) { if (roomCtx->unk31 == 0) { s32 size; @@ -84,14 +84,13 @@ s32 Room_StartRoomTransition(GlobalContext* globalCtx, RoomContext* roomCtx, s32 roomCtx->currRoom.segment = NULL; roomCtx->unk31 = 1; - size = globalCtx->roomList[index].vromEnd - globalCtx->roomList[index].vromStart; - roomCtx->activeRoomVram = - (void*)(((s32)roomCtx->roomMemPages[roomCtx->activeMemPage] - (size + 8) * roomCtx->activeMemPage + 8) & - 0xfffffff0); + size = play->roomList[index].vromEnd - play->roomList[index].vromStart; + roomCtx->activeRoomVram = (void*)(ALIGN16((u32)roomCtx->roomMemPages[roomCtx->activeMemPage] - + (size + 8) * roomCtx->activeMemPage - 7)); osCreateMesgQueue(&roomCtx->loadQueue, roomCtx->loadMsg, 1); - DmaMgr_SendRequestImpl(&roomCtx->dmaRequest, roomCtx->activeRoomVram, globalCtx->roomList[index].vromStart, - size, 0, &roomCtx->loadQueue, NULL); + DmaMgr_SendRequestImpl(&roomCtx->dmaRequest, roomCtx->activeRoomVram, play->roomList[index].vromStart, size, 0, + &roomCtx->loadQueue, NULL); roomCtx->activeMemPage ^= 1; return 1; @@ -100,7 +99,7 @@ s32 Room_StartRoomTransition(GlobalContext* globalCtx, RoomContext* roomCtx, s32 return 0; } -s32 Room_HandleLoadCallbacks(GlobalContext* globalCtx, RoomContext* roomCtx) { +s32 Room_HandleLoadCallbacks(PlayState* play, RoomContext* roomCtx) { if (roomCtx->unk31 == 1) { if (!osRecvMesg(&roomCtx->loadQueue, NULL, OS_MESG_NOBLOCK)) { roomCtx->unk31 = 0; @@ -108,18 +107,18 @@ s32 Room_HandleLoadCallbacks(GlobalContext* globalCtx, RoomContext* roomCtx) { // TODO: Segment number enum gSegments[0x03] = PHYSICAL_TO_VIRTUAL(roomCtx->activeRoomVram); - Scene_ProcessHeader(globalCtx, (SceneCmd*)roomCtx->currRoom.segment); - func_80123140(globalCtx, GET_PLAYER(globalCtx)); - Actor_SpawnTransitionActors(globalCtx, &globalCtx->actorCtx); + Scene_ProcessHeader(play, (SceneCmd*)roomCtx->currRoom.segment); + func_80123140(play, GET_PLAYER(play)); + Actor_SpawnTransitionActors(play, &play->actorCtx); - if (((globalCtx->sceneNum != SCENE_IKANA) || (roomCtx->currRoom.num != 1)) && - (globalCtx->sceneNum != SCENE_IKNINSIDE)) { - globalCtx->envCtx.lightSettingOverride = 0xff; - globalCtx->envCtx.unk_E0 = 0; + if (((play->sceneNum != SCENE_IKANA) || (roomCtx->currRoom.num != 1)) && + (play->sceneNum != SCENE_IKNINSIDE)) { + play->envCtx.lightSettingOverride = 0xFF; + play->envCtx.unk_E0 = 0; } func_800FEAB0(); - if (!func_800FE4B8(globalCtx)) { - func_800FD858(globalCtx); + if (!func_800FE4B8(play)) { + func_800FD858(play); } } else { return 0; @@ -129,23 +128,23 @@ s32 Room_HandleLoadCallbacks(GlobalContext* globalCtx, RoomContext* roomCtx) { return 1; } -void Room_Draw(GlobalContext* globalCtx, Room* room, u32 flags) { +void Room_Draw(PlayState* play, Room* room, u32 flags) { if (room->segment != NULL) { // TODO: Segment number enum gSegments[0x03] = PHYSICAL_TO_VIRTUAL(room->segment); - roomDrawFuncs[room->mesh->type0.type](globalCtx, room, flags); + roomDrawFuncs[room->mesh->type0.type](play, room, flags); } return; } -void func_8012EBF8(GlobalContext* globalCtx, RoomContext* roomCtx) { +void func_8012EBF8(PlayState* play, RoomContext* roomCtx) { roomCtx->prevRoom.num = -1; roomCtx->prevRoom.segment = NULL; - func_800BA798(globalCtx, &globalCtx->actorCtx); - Actor_SpawnTransitionActors(globalCtx, &globalCtx->actorCtx); - if (-1 < roomCtx->currRoom.num) { - func_8010A33C(globalCtx, roomCtx->currRoom.num); - func_8010A2DC(globalCtx); + func_800BA798(play, &play->actorCtx); + Actor_SpawnTransitionActors(play, &play->actorCtx); + if (roomCtx->currRoom.num > -1) { + Map_InitRoomData(play, roomCtx->currRoom.num); + Minimap_SavePlayerRoomInitInfo(play); } - func_801A3CD8(globalCtx->roomCtx.currRoom.echo); + func_801A3CD8(play->roomCtx.currRoom.echo); } diff --git a/src/code/z_rumble.c b/src/code/z_rumble.c new file mode 100644 index 000000000..ce5cc16b4 --- /dev/null +++ b/src/code/z_rumble.c @@ -0,0 +1,104 @@ +/* + * File: z_rumble.c + * Description: Rumble request system + * + * Provides a simple interface to allow scheduling up to RUMBLE_REQUEST_BUFFER_SIZE rumble requests to the RumblePak. + * There's an additional Override type of rumble request for requests which should take priorities over any other + * scheduled request. + */ + +#include "global.h" +#include "z64rumble.h" + +RumbleManager gRumbleMgr; + +void Rumble_Update(void* arg0) { + RumbleManager_Update(&gRumbleMgr); + PadMgr_RumbleSet(gRumbleMgr.rumbleEnabled); +} + +// Used by some bosses (and fishing) +void Rumble_Override(f32 distSq, u8 sourceIntensity, u8 decayTimer, u8 decayStep) { + s32 intensity; + s32 distance; + + if (SQ(1000.0f) < distSq) { + distance = 1000; + } else { + distance = sqrtf(distSq); + } + + if ((distance < 1000) && (sourceIntensity != 0) && (decayStep != 0)) { + intensity = sourceIntensity - (distance * 255) / 1000; + + if (intensity > 0) { + gRumbleMgr.overrideIntensity = intensity; + gRumbleMgr.overrideDecayTimer = decayTimer; + gRumbleMgr.overrideDecayStep = decayStep; + } + } +} + +void Rumble_Request(f32 distSq, u8 sourceIntensity, u8 decayTimer, u8 decayStep) { + s32 intensity; + s32 distance; + s32 i; + + if (SQ(1000.0f) < distSq) { + distance = 1000; + } else { + distance = sqrtf(distSq); + } + + if ((distance < 1000) && (sourceIntensity != 0) && (decayStep != 0)) { + intensity = sourceIntensity - (distance * 255) / 1000; + + for (i = 0; i < RUMBLE_REQUEST_BUFFER_SIZE; i++) { + if (gRumbleMgr.requestIntensities[i] == 0) { + if (intensity > 0) { + gRumbleMgr.requestIntensities[i] = intensity; + gRumbleMgr.requestDecayTimers[i] = decayTimer; + gRumbleMgr.requestDecaySteps[i] = decayStep; + } + break; + } + } + } +} + +void Rumble_Init(void) { + RumbleManager_Init(&gRumbleMgr); + func_80174F24(Rumble_Update, NULL); +} + +void Rumble_Destroy(void) { + func_80174F44(Rumble_Update, NULL); + RumbleManager_Destroy(&gRumbleMgr); +} + +s32 Rumble_ControllerOneHasRumblePak(void) { + return PadMgr_ControllerHasRumblePak(0); +} + +/** + * Wipes every old request for a fresh start, then proceeds to process them as normal + */ +void Rumble_StateReset(void) { + gRumbleMgr.state = RUMBLEMANAGER_STATE_INITIAL; +} + +/** + * Changes the state of the manager to WIPE + * + * In this state, every request is deleted + */ +void Rumble_StateWipeRequests(void) { + gRumbleMgr.state = RUMBLEMANAGER_STATE_WIPE; +} + +/** + * Request processing is paused if updateEnabled is set to false + */ +void Rumble_SetUpdateEnabled(s32 updateEnabled) { + gRumbleMgr.updateEnabled = !!updateEnabled; +} diff --git a/src/code/z_scene.c b/src/code/z_scene.c index 8a9bdd4e7..da05eac2b 100644 --- a/src/code/z_scene.c +++ b/src/code/z_scene.c @@ -4,12 +4,12 @@ s32 Object_Spawn(ObjectContext* objectCtx, s16 id) { size_t size; objectCtx->status[objectCtx->num].id = id; - size = objectFileTable[id].vromEnd - objectFileTable[id].vromStart; + size = gObjectTable[id].vromEnd - gObjectTable[id].vromStart; if (1) {} if (size != 0) { - DmaMgr_SendRequest0(objectCtx->status[objectCtx->num].segment, objectFileTable[id].vromStart, size); + DmaMgr_SendRequest0(objectCtx->status[objectCtx->num].segment, gObjectTable[id].vromStart, size); } if (objectCtx->num < OBJECT_EXCHANGE_BANK_MAX - 1) { @@ -23,17 +23,17 @@ s32 Object_Spawn(ObjectContext* objectCtx, s16 id) { } void Object_InitBank(GameState* gameState, ObjectContext* objectCtx) { - GlobalContext* globalCtx = (GlobalContext*)gameState; + PlayState* play = (PlayState*)gameState; s32 pad; u32 spaceSize; s32 i; - if (globalCtx->sceneNum == SCENE_CLOCKTOWER || globalCtx->sceneNum == SCENE_TOWN || - globalCtx->sceneNum == SCENE_BACKTOWN || globalCtx->sceneNum == SCENE_ICHIBA) { + if (play->sceneNum == SCENE_CLOCKTOWER || play->sceneNum == SCENE_TOWN || play->sceneNum == SCENE_BACKTOWN || + play->sceneNum == SCENE_ICHIBA) { spaceSize = OBJECT_SPACE_SIZE_CLOCK_TOWN; - } else if (globalCtx->sceneNum == SCENE_MILK_BAR) { + } else if (play->sceneNum == SCENE_MILK_BAR) { spaceSize = OBJECT_SPACE_SIZE_MILK_BAR; - } else if (globalCtx->sceneNum == SCENE_00KEIKOKU) { + } else if (play->sceneNum == SCENE_00KEIKOKU) { spaceSize = OBJECT_SPACE_SIZE_TERMINA_FIELD; } else { spaceSize = OBJECT_SPACE_SIZE_DEFAULT; @@ -66,7 +66,7 @@ void Object_UpdateBank(ObjectContext* objectCtx) { s32 id = -status->id; if (status->dmaReq.vromAddr == 0) { - objectFile = &objectFileTable[id]; + objectFile = &gObjectTable[id]; size = objectFile->vromEnd - objectFile->vromStart; if (size == 0) { @@ -112,13 +112,13 @@ void Object_LoadAll(ObjectContext* objectCtx) { for (i = 0; i < objectCtx->num; i++) { id = objectCtx->status[i].id; - vromSize = objectFileTable[id].vromEnd - objectFileTable[id].vromStart; + vromSize = gObjectTable[id].vromEnd - gObjectTable[id].vromStart; if (vromSize == 0) { continue; } - DmaMgr_SendRequest0(objectCtx->status[i].segment, objectFileTable[id].vromStart, vromSize); + DmaMgr_SendRequest0(objectCtx->status[i].segment, gObjectTable[id].vromStart, vromSize); } } @@ -130,7 +130,7 @@ void* func_8012F73C(ObjectContext* objectCtx, s32 iParm2, s16 id) { objectCtx->status[iParm2].id = -id; objectCtx->status[iParm2].dmaReq.vromAddr = 0; - fileTableEntry = &objectFileTable[id]; + fileTableEntry = &gObjectTable[id]; vromSize = fileTableEntry->vromEnd - fileTableEntry->vromStart; // TODO: UB to cast void to u32 @@ -141,48 +141,45 @@ 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; +void Scene_HeaderCmdSpawnList(PlayState* play, SceneCmd* cmd) { 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[RESTART_MODE_RETURN].playerParams == 0x0CFF)) { + play->linkActorEntry = + (ActorEntry*)Lib_SegmentedToVirtual(cmd->spawnList.segment) + play->setupEntranceList[play->curSpawn].spawn; + if ((play->linkActorEntry->params & 0x0F00) >> 8 == 0x0C || + (gSaveContext.respawnFlag == 0x02 && gSaveContext.respawn[RESPAWN_MODE_RETURN].playerParams == 0x0CFF)) { // Skull Kid Object - Object_Spawn(&globalCtx->objectCtx, OBJECT_STK); + Object_Spawn(&play->objectCtx, OBJECT_STK); return; } - loadedCount = Object_Spawn(&globalCtx->objectCtx, OBJECT_LINK_CHILD); - nextObject = globalCtx2->objectCtx.status[globalCtx2->objectCtx.num].segment; - globalCtx->objectCtx.num = loadedCount; - globalCtx->objectCtx.spawnedObjectCount = loadedCount; - playerForm = gSaveContext.save.playerForm; - playerObjectId = gLinkFormObjectIndexes[playerForm]; + loadedCount = Object_Spawn(&play->objectCtx, OBJECT_LINK_CHILD); + nextObject = play->objectCtx.status[play->objectCtx.num].segment; + play->objectCtx.num = loadedCount; + play->objectCtx.spawnedObjectCount = loadedCount; + playerObjectId = gPlayerFormObjectIndices[(void)0, gSaveContext.save.playerForm]; gActorOverlayTable[0].initInfo->objectId = playerObjectId; - Object_Spawn(&globalCtx->objectCtx, playerObjectId); + Object_Spawn(&play->objectCtx, playerObjectId); - globalCtx->objectCtx.status[globalCtx->objectCtx.num].segment = nextObject; + play->objectCtx.status[play->objectCtx.num].segment = nextObject; } // SceneTableEntry Header Command 0x01: Actor List -void Scene_HeaderCmdActorList(GlobalContext* globalCtx, SceneCmd* cmd) { - globalCtx->numSetupActors = cmd->actorList.num; - globalCtx->setupActorList = Lib_SegmentedToVirtual(cmd->actorList.segment); - globalCtx->actorCtx.unkC = 0; +void Scene_HeaderCmdActorList(PlayState* play, SceneCmd* cmd) { + play->numSetupActors = cmd->actorList.num; + play->setupActorList = Lib_SegmentedToVirtual(cmd->actorList.segment); + play->actorCtx.unkC = 0; } -// SceneTableEntry Header Command 0x02: List of cameras for actor cutscenes -void Scene_HeaderCmdActorCutsceneCamList(GlobalContext* globalCtx, SceneCmd* cmd) { - globalCtx->csCamData = Lib_SegmentedToVirtual(cmd->csCameraList.segment); +// SceneTableEntry Header Command 0x02: List of camera data for actor cutscenes +void Scene_HeaderCmdActorCutsceneCamList(PlayState* play, SceneCmd* cmd) { + play->actorCsCamList = Lib_SegmentedToVirtual(cmd->actorCsCamList.segment); } // SceneTableEntry Header Command 0x03: Collision Header -void Scene_HeaderCmdColHeader(GlobalContext* globalCtx, SceneCmd* cmd) { +void Scene_HeaderCmdColHeader(PlayState* play, SceneCmd* cmd) { CollisionHeader* colHeaderTemp; CollisionHeader* colHeader; @@ -195,63 +192,63 @@ void Scene_HeaderCmdColHeader(GlobalContext* globalCtx, SceneCmd* cmd) { colHeader->surfaceTypeList = Lib_SegmentedToVirtual(colHeader->surfaceTypeList); } - if (colHeader->cameraDataList != NULL) { - colHeader->cameraDataList = Lib_SegmentedToVirtual(colHeader->cameraDataList); + if (colHeader->bgCamList != NULL) { + colHeader->bgCamList = Lib_SegmentedToVirtual(colHeader->bgCamList); } if (colHeader->waterBoxes != NULL) { colHeader->waterBoxes = Lib_SegmentedToVirtual(colHeader->waterBoxes); } - BgCheck_Allocate(&globalCtx->colCtx, globalCtx, colHeader); + BgCheck_Allocate(&play->colCtx, play, colHeader); } // SceneTableEntry Header Command 0x04: Room List -void Scene_HeaderCmdRoomList(GlobalContext* globalCtx, SceneCmd* cmd) { - globalCtx->numRooms = cmd->roomList.num; - globalCtx->roomList = Lib_SegmentedToVirtual(cmd->roomList.segment); +void Scene_HeaderCmdRoomList(PlayState* play, SceneCmd* cmd) { + play->numRooms = cmd->roomList.num; + play->roomList = Lib_SegmentedToVirtual(cmd->roomList.segment); } // SceneTableEntry Header Command 0x06: Entrance List -void Scene_HeaderCmdEntranceList(GlobalContext* globalCtx, SceneCmd* cmd) { - globalCtx->setupEntranceList = Lib_SegmentedToVirtual(cmd->entranceList.segment); +void Scene_HeaderCmdEntranceList(PlayState* play, SceneCmd* cmd) { + play->setupEntranceList = Lib_SegmentedToVirtual(cmd->entranceList.segment); } // SceneTableEntry Header Command 0x07: Special Files -void Scene_HeaderCmdSpecialFiles(GlobalContext* globalCtx, SceneCmd* cmd) { +void Scene_HeaderCmdSpecialFiles(PlayState* play, SceneCmd* cmd) { static RomFile tatlMessageFiles[2] = { { SEGMENT_ROM_START(elf_message_field), SEGMENT_ROM_END(elf_message_field) }, { SEGMENT_ROM_START(elf_message_ydan), SEGMENT_ROM_END(elf_message_ydan) }, }; if (cmd->specialFiles.subKeepIndex != 0) { - globalCtx->objectCtx.subKeepIndex = Object_Spawn(&globalCtx->objectCtx, cmd->specialFiles.subKeepIndex); + play->objectCtx.subKeepIndex = Object_Spawn(&play->objectCtx, cmd->specialFiles.subKeepIndex); // TODO: Segment number enum? - gSegments[0x05] = PHYSICAL_TO_VIRTUAL(globalCtx->objectCtx.status[globalCtx->objectCtx.subKeepIndex].segment); + gSegments[0x05] = PHYSICAL_TO_VIRTUAL(play->objectCtx.status[play->objectCtx.subKeepIndex].segment); } if (cmd->specialFiles.cUpElfMsgNum != 0) { - globalCtx->unk_18868 = Play_LoadScene(globalCtx, &tatlMessageFiles[cmd->specialFiles.cUpElfMsgNum - 1]); + play->unk_18868 = Play_LoadScene(play, &tatlMessageFiles[cmd->specialFiles.cUpElfMsgNum - 1]); } } // SceneTableEntry Header Command 0x08: Room Behavior -void Scene_HeaderCmdRoomBehavior(GlobalContext* globalCtx, SceneCmd* cmd) { - globalCtx->roomCtx.currRoom.unk3 = cmd->roomBehavior.gpFlag1; - globalCtx->roomCtx.currRoom.unk2 = cmd->roomBehavior.gpFlag2 & 0xFF; - globalCtx->roomCtx.currRoom.unk5 = (cmd->roomBehavior.gpFlag2 >> 8) & 1; - globalCtx->msgCtx.unk12044 = (cmd->roomBehavior.gpFlag2 >> 0xa) & 1; - globalCtx->roomCtx.currRoom.enablePosLights = (cmd->roomBehavior.gpFlag2 >> 0xb) & 1; - globalCtx->envCtx.unk_E2 = (cmd->roomBehavior.gpFlag2 >> 0xc) & 1; +void Scene_HeaderCmdRoomBehavior(PlayState* play, SceneCmd* cmd) { + play->roomCtx.currRoom.unk3 = cmd->roomBehavior.gpFlag1; + play->roomCtx.currRoom.unk2 = cmd->roomBehavior.gpFlag2 & 0xFF; + play->roomCtx.currRoom.unk5 = (cmd->roomBehavior.gpFlag2 >> 8) & 1; + play->msgCtx.unk12044 = (cmd->roomBehavior.gpFlag2 >> 0xA) & 1; + play->roomCtx.currRoom.enablePosLights = (cmd->roomBehavior.gpFlag2 >> 0xB) & 1; + play->envCtx.unk_E2 = (cmd->roomBehavior.gpFlag2 >> 0xC) & 1; } // SceneTableEntry Header Command 0x0A: Mesh Header -void Scene_HeaderCmdMesh(GlobalContext* globalCtx, SceneCmd* cmd) { - globalCtx->roomCtx.currRoom.mesh = Lib_SegmentedToVirtual(cmd->mesh.segment); +void Scene_HeaderCmdMesh(PlayState* play, SceneCmd* cmd) { + play->roomCtx.currRoom.mesh = Lib_SegmentedToVirtual(cmd->mesh.segment); } // SceneTableEntry Header Command 0x0B: Object List -void Scene_HeaderCmdObjectList(GlobalContext* globalCtx, SceneCmd* cmd) { +void Scene_HeaderCmdObjectList(PlayState* play, SceneCmd* cmd) { s32 i; s32 j; s32 k; @@ -263,21 +260,21 @@ void Scene_HeaderCmdObjectList(GlobalContext* globalCtx, SceneCmd* cmd) { objectEntry = Lib_SegmentedToVirtual(cmd->objectList.segment); k = 0; - i = globalCtx->objectCtx.spawnedObjectCount; - status = &globalCtx->objectCtx.status[i]; - firstObject = globalCtx->objectCtx.status; + i = play->objectCtx.spawnedObjectCount; + status = &play->objectCtx.status[i]; + firstObject = play->objectCtx.status; - while (i < globalCtx->objectCtx.num) { + while (i < play->objectCtx.num) { if (status->id != *objectEntry) { - status2 = &globalCtx->objectCtx.status[i]; + status2 = &play->objectCtx.status[i]; - for (j = i; j < globalCtx->objectCtx.num; j++) { + for (j = i; j < play->objectCtx.num; j++) { status2->id = 0; status2++; } - globalCtx->objectCtx.num = i; - func_800BA6FC(globalCtx, &globalCtx->actorCtx); + play->objectCtx.num = i; + func_800BA6FC(play, &play->actorCtx); continue; } @@ -289,7 +286,7 @@ void Scene_HeaderCmdObjectList(GlobalContext* globalCtx, SceneCmd* cmd) { } while (k < cmd->objectList.num) { - nextPtr = func_8012F73C(&globalCtx->objectCtx, i, *objectEntry); + nextPtr = func_8012F73C(&play->objectCtx, i, *objectEntry); if (i < OBJECT_EXCHANGE_BANK_MAX - 1) { firstObject[i + 1].segment = nextPtr; @@ -300,30 +297,30 @@ void Scene_HeaderCmdObjectList(GlobalContext* globalCtx, SceneCmd* cmd) { objectEntry++; } - globalCtx->objectCtx.num = i; + play->objectCtx.num = i; } // SceneTableEntry Header Command 0x0C: Light List -void Scene_HeaderCmdLightList(GlobalContext* globalCtx, SceneCmd* cmd) { +void Scene_HeaderCmdLightList(PlayState* play, SceneCmd* cmd) { s32 i; LightInfo* lightInfo = Lib_SegmentedToVirtual(cmd->lightList.segment); for (i = 0; i < cmd->lightList.num; i++) { - LightContext_InsertLight(globalCtx, &globalCtx->lightCtx, lightInfo); + LightContext_InsertLight(play, &play->lightCtx, lightInfo); lightInfo++; } } // SceneTableEntry Header Command 0x0D: Path List -void Scene_HeaderCmdPathList(GlobalContext* globalCtx, SceneCmd* cmd) { - globalCtx->setupPathList = Lib_SegmentedToVirtual(cmd->pathList.segment); +void Scene_HeaderCmdPathList(PlayState* play, SceneCmd* cmd) { + play->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 = Lib_SegmentedToVirtual(cmd->transiActorList.segment); - func_80105818(globalCtx, globalCtx->doorCtx.numTransitionActors, globalCtx->doorCtx.transitionActorList); +void Scene_HeaderCmdTransiActorList(PlayState* play, SceneCmd* cmd) { + play->doorCtx.numTransitionActors = cmd->transiActorList.num; + play->doorCtx.transitionActorList = Lib_SegmentedToVirtual(cmd->transiActorList.segment); + func_80105818(play, play->doorCtx.numTransitionActors, play->doorCtx.transitionActorList); } // Init function for the transition system. @@ -332,16 +329,16 @@ 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 = Lib_SegmentedToVirtual(cmd->lightSettingList.segment); +void Scene_HeaderCmdEnvLightSettings(PlayState* play, SceneCmd* cmd) { + play->envCtx.numLightSettings = cmd->lightSettingList.num; + play->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(PlayState* play, s32 fileIndex) { static RomFile sceneTextureFiles[9] = { { 0, 0 }, // Default { SEGMENT_ROM_START(scene_texture_01), SEGMENT_ROM_END(scene_texture_01) }, @@ -357,100 +354,90 @@ s32 Scene_LoadAreaTextures(GlobalContext* globalCtx, s32 fileIndex) { size_t size = sceneTextureFiles[fileIndex].vromEnd - vromStart; if (size != 0) { - globalCtx->roomCtx.unk74 = THA_AllocEndAlign16(&globalCtx->state.heap, size); - return DmaMgr_SendRequest0(globalCtx->roomCtx.unk74, vromStart, size); + play->roomCtx.unk74 = THA_AllocEndAlign16(&play->state.heap, size); + DmaMgr_SendRequest0(play->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 -void Scene_HeaderCmdSkyboxSettings(GlobalContext* globalCtx, SceneCmd* cmd) { - globalCtx->skyboxId = cmd->skyboxSettings.skyboxId & 3; - globalCtx->envCtx.unk_17 = globalCtx->envCtx.unk_18 = cmd->skyboxSettings.unk5; - globalCtx->envCtx.unk_1E = cmd->skyboxSettings.unk6; - Scene_LoadAreaTextures(globalCtx, cmd->skyboxSettings.data1); +void Scene_HeaderCmdSkyboxSettings(PlayState* play, SceneCmd* cmd) { + play->skyboxId = cmd->skyboxSettings.skyboxId & 3; + play->envCtx.unk_17 = play->envCtx.unk_18 = cmd->skyboxSettings.unk5; + play->envCtx.unk_1E = cmd->skyboxSettings.unk6; + Scene_LoadAreaTextures(play, cmd->skyboxSettings.data1); } // SceneTableEntry Header Command 0x12: Skybox Disables -void Scene_HeaderCmdSkyboxDisables(GlobalContext* globalCtx, SceneCmd* cmd) { - globalCtx->envCtx.skyboxDisabled = cmd->skyboxDisables.unk4; - globalCtx->envCtx.sunMoonDisabled = cmd->skyboxDisables.unk5; +void Scene_HeaderCmdSkyboxDisables(PlayState* play, SceneCmd* cmd) { + play->envCtx.skyboxDisabled = cmd->skyboxDisables.unk4; + play->envCtx.sunMoonDisabled = cmd->skyboxDisables.unk5; } // SceneTableEntry Header Command 0x10: Time Settings -void Scene_HeaderCmdTimeSettings(GlobalContext* globalCtx, SceneCmd* cmd) { - u32 dayTime; - +void Scene_HeaderCmdTimeSettings(PlayState* play, SceneCmd* cmd) { if (cmd->timeSettings.hour != 0xFF && cmd->timeSettings.min != 0xFF) { - gSaveContext.environmentTime = gSaveContext.save.time = + gSaveContext.skyboxTime = gSaveContext.save.time = (u16)(((cmd->timeSettings.hour + (cmd->timeSettings.min / 60.0f)) * 60.0f) / 0.021972656f); } if (cmd->timeSettings.unk6 != 0xFF) { - globalCtx->envCtx.timeIncrement = cmd->timeSettings.unk6; + play->envCtx.timeIncrement = cmd->timeSettings.unk6; } else { - globalCtx->envCtx.timeIncrement = 0; + play->envCtx.timeIncrement = 0; } - if ((gSaveContext.save.inventory.items[SLOT_OCARINA] == ITEM_NONE) && (globalCtx->envCtx.timeIncrement != 0)) { - globalCtx->envCtx.timeIncrement = 5; + if ((gSaveContext.save.inventory.items[SLOT_OCARINA] == ITEM_NONE) && (play->envCtx.timeIncrement != 0)) { + play->envCtx.timeIncrement = 5; } if (gSaveContext.sunsSongState == SUNSSONG_INACTIVE) { - REG(15) = globalCtx->envCtx.timeIncrement; + REG(15) = play->envCtx.timeIncrement; } - dayTime = gSaveContext.save.time; - globalCtx->envCtx.unk_4 = -(Math_SinS(dayTime - 0x8000) * 120.0f) * 25.0f; - dayTime = gSaveContext.save.time; - globalCtx->envCtx.unk_8 = (Math_CosS(dayTime - 0x8000) * 120.0f) * 25.0f; - dayTime = gSaveContext.save.time; - globalCtx->envCtx.unk_C = (Math_CosS(dayTime - 0x8000) * 20.0f) * 25.0f; + play->envCtx.unk_4 = -(Math_SinS(((void)0, gSaveContext.save.time) - 0x8000) * 120.0f) * 25.0f; + play->envCtx.unk_8 = (Math_CosS(((void)0, gSaveContext.save.time) - 0x8000) * 120.0f) * 25.0f; + play->envCtx.unk_C = (Math_CosS(((void)0, gSaveContext.save.time) - 0x8000) * 20.0f) * 25.0f; - if (globalCtx->envCtx.timeIncrement == 0 && gSaveContext.save.cutscene < 0xFFF0) { - gSaveContext.environmentTime = gSaveContext.save.time; + if ((play->envCtx.timeIncrement == 0) && (gSaveContext.save.cutscene < 0xFFF0)) { + gSaveContext.skyboxTime = gSaveContext.save.time; - if (gSaveContext.environmentTime >= CLOCK_TIME(4, 0) && gSaveContext.environmentTime < CLOCK_TIME(6, 30)) { - gSaveContext.environmentTime = CLOCK_TIME(5, 0); - } else if (gSaveContext.environmentTime >= CLOCK_TIME(6, 30) && - gSaveContext.environmentTime < CLOCK_TIME(8, 0)) { - gSaveContext.environmentTime = CLOCK_TIME(8, 0); - } else if (gSaveContext.environmentTime >= CLOCK_TIME(16, 0) && - gSaveContext.environmentTime < CLOCK_TIME(17, 0)) { - gSaveContext.environmentTime = CLOCK_TIME(17, 0); - } else if (gSaveContext.environmentTime >= CLOCK_TIME(18, 0) && - gSaveContext.environmentTime < CLOCK_TIME(19, 0)) { - gSaveContext.environmentTime = CLOCK_TIME(19, 0); + if ((gSaveContext.skyboxTime >= CLOCK_TIME(4, 0)) && (gSaveContext.skyboxTime < CLOCK_TIME(6, 30))) { + gSaveContext.skyboxTime = CLOCK_TIME(5, 0); + } else if ((gSaveContext.skyboxTime >= CLOCK_TIME(6, 30)) && (gSaveContext.skyboxTime < CLOCK_TIME(8, 0))) { + gSaveContext.skyboxTime = CLOCK_TIME(8, 0); + } else if ((gSaveContext.skyboxTime >= CLOCK_TIME(16, 0)) && (gSaveContext.skyboxTime < CLOCK_TIME(17, 0))) { + gSaveContext.skyboxTime = CLOCK_TIME(17, 0); + } else if ((gSaveContext.skyboxTime >= CLOCK_TIME(18, 0)) && (gSaveContext.skyboxTime < CLOCK_TIME(19, 0))) { + gSaveContext.skyboxTime = CLOCK_TIME(19, 0); } } } // SceneTableEntry Header Command 0x05: Wind Settings -void Scene_HeaderCmdWindSettings(GlobalContext* globalCtx, SceneCmd* cmd) { +void Scene_HeaderCmdWindSettings(PlayState* play, SceneCmd* cmd) { s8 temp1 = cmd->windSettings.west; s8 temp2 = cmd->windSettings.vertical; s8 temp3 = cmd->windSettings.south; - globalCtx->envCtx.windDir.x = temp1; - globalCtx->envCtx.windDir.y = temp2; - globalCtx->envCtx.windDir.z = temp3; - globalCtx->envCtx.windSpeed = cmd->windSettings.clothIntensity; + play->envCtx.windDir.x = temp1; + play->envCtx.windDir.y = temp2; + play->envCtx.windDir.z = temp3; + play->envCtx.windSpeed = cmd->windSettings.clothIntensity; } // SceneTableEntry Header Command 0x13: Exit List -void Scene_HeaderCmdExitList(GlobalContext* globalCtx, SceneCmd* cmd) { - globalCtx->setupExitList = Lib_SegmentedToVirtual(cmd->exitList.segment); +void Scene_HeaderCmdExitList(PlayState* play, SceneCmd* cmd) { + play->setupExitList = Lib_SegmentedToVirtual(cmd->exitList.segment); } // SceneTableEntry Header Command 0x09: Undefined -void Scene_HeaderCmd09(GlobalContext* globalCtx, SceneCmd* cmd) { +void Scene_HeaderCmd09(PlayState* play, SceneCmd* cmd) { } // SceneTableEntry Header Command 0x15: Sound Settings= -void Scene_HeaderCmdSoundSettings(GlobalContext* globalCtx, SceneCmd* cmd) { - globalCtx->soundCtx.seqIndex = cmd->soundSettings.musicSeq; - globalCtx->soundCtx.nightSeqIndex = cmd->soundSettings.nighttimeSFX; +void Scene_HeaderCmdSoundSettings(PlayState* play, SceneCmd* cmd) { + play->soundCtx.seqIndex = cmd->soundSettings.musicSeq; + play->soundCtx.nightSeqIndex = cmd->soundSettings.nighttimeSFX; if (gSaveContext.seqIndex == (u8)NA_BGM_DISABLED || func_801A8A50(0) == NA_BGM_FINAL_HOURS) { audio_setBGM(cmd->soundSettings.bgmId); @@ -458,54 +445,54 @@ void Scene_HeaderCmdSoundSettings(GlobalContext* globalCtx, SceneCmd* cmd) { } // SceneTableEntry Header Command 0x16: Echo Setting -void Scene_HeaderCmdEchoSetting(GlobalContext* globalCtx, SceneCmd* cmd) { - globalCtx->roomCtx.currRoom.echo = cmd->echoSettings.echo; +void Scene_HeaderCmdEchoSetting(PlayState* play, SceneCmd* cmd) { + play->roomCtx.currRoom.echo = cmd->echoSettings.echo; } // SceneTableEntry Header Command 0x18: Alternate Header List= -void Scene_HeaderCmdAltHeaderList(GlobalContext* globalCtx, SceneCmd* cmd) { +void Scene_HeaderCmdAltHeaderList(PlayState* play, SceneCmd* cmd) { SceneCmd** altHeaderList; SceneCmd* altHeader; - if (gSaveContext.sceneSetupIndex) { + if (gSaveContext.sceneSetupIndex != 0) { altHeaderList = Lib_SegmentedToVirtual(cmd->altHeaders.segment); altHeader = altHeaderList[gSaveContext.sceneSetupIndex - 1]; if (altHeader != NULL) { - Scene_ProcessHeader(globalCtx, Lib_SegmentedToVirtual(altHeader)); + Scene_ProcessHeader(play, Lib_SegmentedToVirtual(altHeader)); (cmd + 1)->base.code = 0x14; } } } // SceneTableEntry Header Command 0x17: Cutscene List -void Scene_HeaderCmdCutsceneList(GlobalContext* globalCtx, SceneCmd* cmd) { - globalCtx->csCtx.sceneCsCount = cmd->base.data1; - globalCtx->csCtx.sceneCsList = Lib_SegmentedToVirtual(cmd->base.data2); +void Scene_HeaderCmdCutsceneList(PlayState* play, SceneCmd* cmd) { + play->csCtx.sceneCsCount = cmd->base.data1; + play->csCtx.sceneCsList = Lib_SegmentedToVirtual(cmd->base.data2); } // SceneTableEntry Header Command 0x1B: Actor Cutscene List -void Scene_HeaderCmdActorCutsceneList(GlobalContext* globalCtx, SceneCmd* cmd) { - ActorCutscene_Init(globalCtx, Lib_SegmentedToVirtual(cmd->cutsceneActorList.segment), cmd->cutsceneActorList.num); +void Scene_HeaderCmdActorCutsceneList(PlayState* play, SceneCmd* cmd) { + ActorCutscene_Init(play, Lib_SegmentedToVirtual(cmd->cutsceneActorList.segment), cmd->cutsceneActorList.num); } // SceneTableEntry Header Command 0x1C: Mini Maps -void Scene_HeaderCmdMiniMap(GlobalContext* globalCtx, SceneCmd* cmd) { - func_80104CF4(globalCtx); - func_8010549C(globalCtx, cmd->minimapSettings.segment); +void Scene_HeaderCmdMiniMap(PlayState* play, SceneCmd* cmd) { + func_80104CF4(play); + func_8010549C(play, cmd->minimapSettings.segment); } // SceneTableEntry Header Command 0x1D: Undefined -void Scene_HeaderCmd1D(GlobalContext* globalCtx, SceneCmd* cmd) { +void Scene_HeaderCmd1D(PlayState* play, SceneCmd* cmd) { } // SceneTableEntry Header Command 0x1E: Minimap Compass Icon Info -void Scene_HeaderCmdMiniMapCompassInfo(GlobalContext* globalCtx, SceneCmd* cmd) { - func_8010565C(globalCtx, cmd->minimapChests.num, cmd->minimapChests.segment); +void Scene_HeaderCmdMiniMapCompassInfo(PlayState* play, SceneCmd* cmd) { + func_8010565C(play, cmd->minimapChests.num, cmd->minimapChests.segment); } // SceneTableEntry Header Command 0x1A: Sets Area Visited Flag -void Scene_HeaderCmdSetAreaVisitedFlag(GlobalContext* globalCtx, SceneCmd* cmd) { +void Scene_HeaderCmdSetAreaVisitedFlag(PlayState* play, SceneCmd* cmd) { s16 j = 0; s16 i = 0; @@ -519,7 +506,7 @@ void Scene_HeaderCmdSetAreaVisitedFlag(GlobalContext* globalCtx, SceneCmd* cmd) } } - if (globalCtx->sceneNum == gScenesPerRegion[i][j]) { + if (play->sceneNum == gScenesPerRegion[i][j]) { break; } @@ -532,22 +519,22 @@ void Scene_HeaderCmdSetAreaVisitedFlag(GlobalContext* globalCtx, SceneCmd* cmd) } // SceneTableEntry Header Command 0x1A: Material Animations -void Scene_HeaderCmdAnimatedMaterials(GlobalContext* globalCtx, SceneCmd* cmd) { - globalCtx->sceneMaterialAnims = (AnimatedMaterial*)Lib_SegmentedToVirtual(cmd->textureAnimations.segment); +void Scene_HeaderCmdAnimatedMaterials(PlayState* play, SceneCmd* cmd) { + play->sceneMaterialAnims = (AnimatedMaterial*)Lib_SegmentedToVirtual(cmd->textureAnimations.segment); } /** * Sets the exit fade from the next entrance index. */ -void Scene_SetExitFade(GlobalContext* globalCtx) { - globalCtx->unk_1887F = Entrance_GetTransitionFlags(globalCtx->nextEntranceIndex) & 0x7F; +void Scene_SetExitFade(PlayState* play) { + play->transitionType = Entrance_GetTransitionFlags(play->nextEntrance) & 0x7F; } /** * Executes all of the commands in a scene or room header. */ -s32 Scene_ProcessHeader(GlobalContext* globalCtx, SceneCmd* header) { - static void (*sceneCmdHandlers[])(GlobalContext*, SceneCmd*) = { +s32 Scene_ProcessHeader(PlayState* play, SceneCmd* header) { + static void (*sceneCmdHandlers[])(PlayState*, SceneCmd*) = { Scene_HeaderCmdSpawnList, Scene_HeaderCmdActorList, Scene_HeaderCmdActorCutsceneCamList, @@ -590,7 +577,7 @@ s32 Scene_ProcessHeader(GlobalContext* globalCtx, SceneCmd* header) { } if (cmdId < SCENE_CMD_MAX) { - sceneCmdHandlers[cmdId](globalCtx, header); + sceneCmdHandlers[cmdId](play, header); } header++; @@ -600,15 +587,15 @@ s32 Scene_ProcessHeader(GlobalContext* globalCtx, SceneCmd* header) { } /** - * Creates an entrance index from the scene index, spawn index, and scene setup. + * Creates an entrance from the scene, spawn, and lyaer. */ -u16 Entrance_CreateIndex(s32 sceneIndex, s32 spawnIndex, s32 sceneSetup) { - return (((sceneIndex << 9) | (spawnIndex << 4)) | sceneSetup) & 0xFFFF; +u16 Entrance_Create(s32 scene, s32 spawn, s32 layer) { + return (scene << 9) | (spawn << 4) | layer; } /** - * Creates an entrance index from the current entrance index with the given spawn index. + * Creates an layer 0 entranace from the current entrance and the given spawn. */ -u16 Entrance_CreateIndexFromSpawn(s32 spawnIndex) { - return Entrance_CreateIndex(gSaveContext.save.entranceIndex >> 9, spawnIndex, 0); +u16 Entrance_CreateFromSpawn(s32 spawn) { + return Entrance_Create(gSaveContext.save.entrance >> 9, spawn, 0); } diff --git a/src/code/z_scene_proc.c b/src/code/z_scene_proc.c index f7f71a2dd..8ddde8a82 100644 --- a/src/code/z_scene_proc.c +++ b/src/code/z_scene_proc.c @@ -22,8 +22,8 @@ static Gfx sSceneDrawDefaultDL[] = { /** * Executes the current scene draw config handler. */ -void Scene_ExecuteDrawConfig(GlobalContext* globalCtx) { - static void (*sceneDrawConfigHandlers[])(GlobalContext*) = { +void Scene_ExecuteDrawConfig(PlayState* play) { + static void (*sceneDrawConfigHandlers[])(PlayState*) = { Scene_DrawConfigDefault, Scene_DrawConfigMatAnim, Scene_DrawConfigDoNothing, @@ -34,27 +34,27 @@ void Scene_ExecuteDrawConfig(GlobalContext* globalCtx) { Scene_DrawConfigMatAnimManualStep, }; - sceneDrawConfigHandlers[globalCtx->sceneConfig](globalCtx); + sceneDrawConfigHandlers[play->sceneConfig](play); } /** * SceneTableEntry Draw Config 0: * Default scene draw config function. This just executes `sSceneDrawDefaultDL`. */ -void Scene_DrawConfigDefault(GlobalContext* globalCtx) { - OPEN_DISPS(globalCtx->state.gfxCtx); +void Scene_DrawConfigDefault(PlayState* play) { + OPEN_DISPS(play->state.gfxCtx); gSPDisplayList(POLY_OPA_DISP++, sSceneDrawDefaultDL); gSPDisplayList(POLY_XLU_DISP++, sSceneDrawDefaultDL); - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->state.gfxCtx); } /** * Returns a pointer to a single layer texture scroll displaylist. */ -Gfx* AnimatedMat_TexScroll(GlobalContext* globalCtx, AnimatedMatTexScrollParams* params) { - return Gfx_TexScroll(globalCtx->state.gfxCtx, params->xStep * sMatAnimStep, -(params->yStep * sMatAnimStep), +Gfx* AnimatedMat_TexScroll(PlayState* play, AnimatedMatTexScrollParams* params) { + return Gfx_TexScroll(play->state.gfxCtx, params->xStep * sMatAnimStep, -(params->yStep * sMatAnimStep), params->width, params->height); } @@ -62,11 +62,11 @@ Gfx* AnimatedMat_TexScroll(GlobalContext* globalCtx, AnimatedMatTexScrollParams* * Animated Material Type 0: * Scrolls a single layer texture using the provided `AnimatedMatTexScrollParams`. */ -void AnimatedMat_DrawTexScroll(GlobalContext* globalCtx, s32 segment, void* params) { +void AnimatedMat_DrawTexScroll(PlayState* play, s32 segment, void* params) { AnimatedMatTexScrollParams* texScrollParams = (AnimatedMatTexScrollParams*)params; - Gfx* texScrollDList = AnimatedMat_TexScroll(globalCtx, texScrollParams); + Gfx* texScrollDList = AnimatedMat_TexScroll(play, texScrollParams); - OPEN_DISPS(globalCtx->state.gfxCtx); + OPEN_DISPS(play->state.gfxCtx); if (sMatAnimFlags & 1) { gSPSegment(POLY_OPA_DISP++, segment, texScrollDList); @@ -76,28 +76,27 @@ void AnimatedMat_DrawTexScroll(GlobalContext* globalCtx, s32 segment, void* para gSPSegment(POLY_XLU_DISP++, segment, texScrollDList); } - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->state.gfxCtx); } /** * Returns a pointer to a two layer texture scroll displaylist. */ -Gfx* AnimatedMat_TwoLayerTexScroll(GlobalContext* globalCtx, AnimatedMatTexScrollParams* params) { - return Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, params[0].xStep * sMatAnimStep, - -(params[0].yStep * sMatAnimStep), params[0].width, params[0].height, 1, - params[1].xStep * sMatAnimStep, -(params[1].yStep * sMatAnimStep), params[1].width, - params[1].height); +Gfx* AnimatedMat_TwoLayerTexScroll(PlayState* play, AnimatedMatTexScrollParams* params) { + return Gfx_TwoTexScroll(play->state.gfxCtx, 0, params[0].xStep * sMatAnimStep, -(params[0].yStep * sMatAnimStep), + params[0].width, params[0].height, 1, params[1].xStep * sMatAnimStep, + -(params[1].yStep * sMatAnimStep), params[1].width, params[1].height); } /** * Animated Material Type 1: * Scrolls a two layer texture using the provided `AnimatedMatTexScrollParams`. */ -void AnimatedMat_DrawTwoTexScroll(GlobalContext* globalCtx, s32 segment, void* params) { +void AnimatedMat_DrawTwoTexScroll(PlayState* play, s32 segment, void* params) { AnimatedMatTexScrollParams* texScrollParams = (AnimatedMatTexScrollParams*)params; - Gfx* texScrollDList = AnimatedMat_TwoLayerTexScroll(globalCtx, texScrollParams); + Gfx* texScrollDList = AnimatedMat_TwoLayerTexScroll(play, texScrollParams); - OPEN_DISPS(globalCtx->state.gfxCtx); + OPEN_DISPS(play->state.gfxCtx); if (sMatAnimFlags & 1) { gSPSegment(POLY_OPA_DISP++, segment, texScrollDList); @@ -107,16 +106,16 @@ void AnimatedMat_DrawTwoTexScroll(GlobalContext* globalCtx, s32 segment, void* p gSPSegment(POLY_XLU_DISP++, segment, texScrollDList); } - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->state.gfxCtx); } /** * 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 = GRAPH_ALLOC(globalCtx->state.gfxCtx, sizeof(Gfx) * 4); +void AnimatedMat_SetColor(PlayState* play, s32 segment, F3DPrimColor* primColorResult, F3DEnvColor* envColor) { + Gfx* colorDList = GRAPH_ALLOC(play->state.gfxCtx, sizeof(Gfx) * 4); - OPEN_DISPS(globalCtx->state.gfxCtx); + OPEN_DISPS(play->state.gfxCtx); // clang-format off if (sMatAnimFlags & 1) { gSPSegment(POLY_OPA_DISP++, segment, colorDList); } @@ -132,14 +131,14 @@ void AnimatedMat_SetColor(GlobalContext* globalCtx, s32 segment, F3DPrimColor* p gSPEndDisplayList(colorDList++); - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->state.gfxCtx); } /** * Animated Material Type 2: * Color key frame animation without linear interpolation. */ -void AnimatedMat_DrawColor(GlobalContext* globalCtx, s32 segment, void* params) { +void AnimatedMat_DrawColor(PlayState* play, s32 segment, void* params) { AnimatedMatColorParams* colorAnimParams = (AnimatedMatColorParams*)params; F3DPrimColor* primColor = Lib_SegmentedToVirtual(colorAnimParams->primColors); F3DEnvColor* envColor; @@ -150,7 +149,7 @@ void AnimatedMat_DrawColor(GlobalContext* globalCtx, s32 segment, void* params) ? (F3DEnvColor*)Lib_SegmentedToVirtual(colorAnimParams->envColors) + curFrame : NULL; - AnimatedMat_SetColor(globalCtx, segment, primColor, envColor); + AnimatedMat_SetColor(play, segment, primColor, envColor); } /** @@ -164,7 +163,7 @@ s32 AnimatedMat_Lerp(s32 min, s32 max, f32 norm) { * Animated Material Type 3: * Color key frame animation with linear interpolation. */ -void AnimatedMat_DrawColorLerp(GlobalContext* globalCtx, s32 segment, void* params) { +void AnimatedMat_DrawColorLerp(PlayState* play, s32 segment, void* params) { AnimatedMatColorParams* colorAnimParams = (AnimatedMatColorParams*)params; F3DPrimColor* primColorMax = Lib_SegmentedToVirtual(colorAnimParams->primColors); F3DEnvColor* envColorMax; @@ -216,7 +215,7 @@ void AnimatedMat_DrawColorLerp(GlobalContext* globalCtx, s32 segment, void* para envColorMax = NULL; } - AnimatedMat_SetColor(globalCtx, segment, &primColorResult, (envColorMax != NULL) ? &envColorResult : NULL); + AnimatedMat_SetColor(play, segment, &primColorResult, (envColorMax != NULL) ? &envColorResult : NULL); } /** @@ -234,7 +233,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); @@ -277,7 +276,7 @@ u8 Scene_LagrangeInterpColor(s32 n, f32 x[], f32 fx[], f32 xp) { * Animated Material Type 4: * Color key frame animation with non-linear interpolation. */ -void AnimatedMat_DrawColorNonLinearInterp(GlobalContext* globalCtx, s32 segment, void* params) { +void AnimatedMat_DrawColorNonLinearInterp(PlayState* play, s32 segment, void* params) { AnimatedMatColorParams* colorAnimParams = (AnimatedMatColorParams*)params; F3DPrimColor* primColorCur = Lib_SegmentedToVirtual(colorAnimParams->primColors); F3DEnvColor* envColorCur = Lib_SegmentedToVirtual(colorAnimParams->envColors); @@ -355,21 +354,21 @@ void AnimatedMat_DrawColorNonLinearInterp(GlobalContext* globalCtx, s32 segment, envColorCur = NULL; } - AnimatedMat_SetColor(globalCtx, segment, &primColorResult, (envColorCur != NULL) ? &envColorResult : NULL); + AnimatedMat_SetColor(play, segment, &primColorResult, (envColorCur != NULL) ? &envColorResult : NULL); } /** * Animated Material Type 5: * Cycles between a list of textures (imagine like a GIF) */ -void AnimatedMat_DrawTexCycle(GlobalContext* globalCtx, s32 segment, void* params) { +void AnimatedMat_DrawTexCycle(PlayState* play, s32 segment, void* params) { AnimatedMatTexCycleParams* texAnimParams = params; - void** texList = Lib_SegmentedToVirtual(texAnimParams->textureList); + TexturePtr* texList = Lib_SegmentedToVirtual(texAnimParams->textureList); u8* texId = Lib_SegmentedToVirtual(texAnimParams->textureIndexList); s32 curFrame = sMatAnimStep % texAnimParams->keyFrameLength; - void* tex = Lib_SegmentedToVirtual(texList[texId[curFrame]]); + TexturePtr tex = Lib_SegmentedToVirtual(texList[texId[curFrame]]); - OPEN_DISPS(globalCtx->state.gfxCtx); + OPEN_DISPS(play->state.gfxCtx); if (sMatAnimFlags & 1) { gSPSegment(POLY_OPA_DISP++, segment, tex); @@ -379,15 +378,15 @@ void AnimatedMat_DrawTexCycle(GlobalContext* globalCtx, s32 segment, void* param gSPSegment(POLY_XLU_DISP++, segment, tex); } - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->state.gfxCtx); } /** * This is the main function that handles the animated material system. * There are six different animated material types, which should be set in the provided `AnimatedMaterial`. */ -void AnimatedMat_DrawMain(GlobalContext* globalCtx, AnimatedMaterial* matAnim, f32 alphaRatio, u32 step, u32 flags) { - static void (*matAnimDrawHandlers[])(GlobalContext*, s32 segment, void* params) = { +void AnimatedMat_DrawMain(PlayState* play, AnimatedMaterial* matAnim, f32 alphaRatio, u32 step, u32 flags) { + static void (*matAnimDrawHandlers[])(PlayState*, s32 segment, void* params) = { AnimatedMat_DrawTexScroll, AnimatedMat_DrawTwoTexScroll, AnimatedMat_DrawColor, AnimatedMat_DrawColorLerp, AnimatedMat_DrawColorNonLinearInterp, AnimatedMat_DrawTexCycle, }; @@ -402,7 +401,7 @@ void AnimatedMat_DrawMain(GlobalContext* globalCtx, AnimatedMaterial* matAnim, f do { segment = matAnim->segment; segmentAbs = ((segment < 0) ? -segment : segment) + 7; - matAnimDrawHandlers[matAnim->type](globalCtx, segmentAbs, Lib_SegmentedToVirtual(matAnim->params)); + matAnimDrawHandlers[matAnim->type](play, segmentAbs, Lib_SegmentedToVirtual(matAnim->params)); matAnim++; } while (segment >= 0); } @@ -411,123 +410,123 @@ void AnimatedMat_DrawMain(GlobalContext* globalCtx, AnimatedMaterial* matAnim, f /** * Draws an animated material to both OPA and XLU buffers. */ -void AnimatedMat_Draw(GlobalContext* globalCtx, AnimatedMaterial* matAnim) { - AnimatedMat_DrawMain(globalCtx, matAnim, 1, globalCtx->gameplayFrames, 3); +void AnimatedMat_Draw(PlayState* play, AnimatedMaterial* matAnim) { + AnimatedMat_DrawMain(play, matAnim, 1, play->gameplayFrames, 3); } /** * Draws an animated material to only the OPA buffer. */ -void AnimatedMat_DrawOpa(GlobalContext* globalCtx, AnimatedMaterial* matAnim) { - AnimatedMat_DrawMain(globalCtx, matAnim, 1, globalCtx->gameplayFrames, 1); +void AnimatedMat_DrawOpa(PlayState* play, AnimatedMaterial* matAnim) { + AnimatedMat_DrawMain(play, matAnim, 1, play->gameplayFrames, 1); } /** * Draws an animated material to only the XLU buffer. */ -void AnimatedMat_DrawXlu(GlobalContext* globalCtx, AnimatedMaterial* matAnim) { - AnimatedMat_DrawMain(globalCtx, matAnim, 1, globalCtx->gameplayFrames, 2); +void AnimatedMat_DrawXlu(PlayState* play, AnimatedMaterial* matAnim) { + AnimatedMat_DrawMain(play, matAnim, 1, play->gameplayFrames, 2); } /** * Draws an animated material with an alpha ratio (0.0 - 1.0) both OPA and XLU buffers. */ -void AnimatedMat_DrawAlpha(GlobalContext* globalCtx, AnimatedMaterial* matAnim, f32 alphaRatio) { - AnimatedMat_DrawMain(globalCtx, matAnim, alphaRatio, globalCtx->gameplayFrames, 3); +void AnimatedMat_DrawAlpha(PlayState* play, AnimatedMaterial* matAnim, f32 alphaRatio) { + AnimatedMat_DrawMain(play, matAnim, alphaRatio, play->gameplayFrames, 3); } /** * Draws an animated material with an alpha ratio (0.0 - 1.0) to only the OPA buffer. */ -void AnimatedMat_DrawAlphaOpa(GlobalContext* globalCtx, AnimatedMaterial* matAnim, f32 alphaRatio) { - AnimatedMat_DrawMain(globalCtx, matAnim, alphaRatio, globalCtx->gameplayFrames, 1); +void AnimatedMat_DrawAlphaOpa(PlayState* play, AnimatedMaterial* matAnim, f32 alphaRatio) { + AnimatedMat_DrawMain(play, matAnim, alphaRatio, play->gameplayFrames, 1); } /** * Draws an animated material with an alpha ratio (0.0 - 1.0) to only the XLU buffer. */ -void AnimatedMat_DrawAlphaXlu(GlobalContext* globalCtx, AnimatedMaterial* matAnim, f32 alphaRatio) { - AnimatedMat_DrawMain(globalCtx, matAnim, alphaRatio, globalCtx->gameplayFrames, 2); +void AnimatedMat_DrawAlphaXlu(PlayState* play, AnimatedMaterial* matAnim, f32 alphaRatio) { + AnimatedMat_DrawMain(play, matAnim, alphaRatio, play->gameplayFrames, 2); } /** * Draws an animated material with a step to both the OPA and XLU buffers. */ -void AnimatedMat_DrawStep(GlobalContext* globalCtx, AnimatedMaterial* matAnim, u32 step) { - AnimatedMat_DrawMain(globalCtx, matAnim, 1, step, 3); +void AnimatedMat_DrawStep(PlayState* play, AnimatedMaterial* matAnim, u32 step) { + AnimatedMat_DrawMain(play, matAnim, 1, step, 3); } /** * Draws an animated material with a step to only the OPA buffer. */ -void AnimatedMat_DrawStepOpa(GlobalContext* globalCtx, AnimatedMaterial* textures, u32 step) { - AnimatedMat_DrawMain(globalCtx, textures, 1, step, 1); +void AnimatedMat_DrawStepOpa(PlayState* play, AnimatedMaterial* textures, u32 step) { + AnimatedMat_DrawMain(play, textures, 1, step, 1); } /** * Draws an animated material with a step to only the XLU buffer. */ -void AnimatedMat_DrawStepXlu(GlobalContext* globalCtx, AnimatedMaterial* matAnim, u32 step) { - AnimatedMat_DrawMain(globalCtx, matAnim, 1, step, 2); +void AnimatedMat_DrawStepXlu(PlayState* play, AnimatedMaterial* matAnim, u32 step) { + AnimatedMat_DrawMain(play, matAnim, 1, step, 2); } /** * Draws an animated material with an alpha ratio (0.0 - 1.0) and a step to both the OPA and XLU buffers. */ -void AnimatedMat_DrawAlphaStep(GlobalContext* globalCtx, AnimatedMaterial* matAnim, f32 alphaRatio, u32 step) { - AnimatedMat_DrawMain(globalCtx, matAnim, alphaRatio, step, 3); +void AnimatedMat_DrawAlphaStep(PlayState* play, AnimatedMaterial* matAnim, f32 alphaRatio, u32 step) { + AnimatedMat_DrawMain(play, matAnim, alphaRatio, step, 3); } /** * Draws an animated material with an alpha ratio (0.0 - 1.0) and a step to only the OPA buffer. */ -void AnimatedMat_DrawAlphaStepOpa(GlobalContext* globalCtx, AnimatedMaterial* matAnim, f32 alphaRatio, u32 step) { - AnimatedMat_DrawMain(globalCtx, matAnim, alphaRatio, step, 1); +void AnimatedMat_DrawAlphaStepOpa(PlayState* play, AnimatedMaterial* matAnim, f32 alphaRatio, u32 step) { + AnimatedMat_DrawMain(play, matAnim, alphaRatio, step, 1); } /** * Draws an animated material with an alpha ratio (0.0 - 1.0) and a step to only the XLU buffer. */ -void AnimatedMat_DrawAlphaStepXlu(GlobalContext* globalCtx, AnimatedMaterial* matAnim, f32 alphaRatio, u32 step) { - AnimatedMat_DrawMain(globalCtx, matAnim, alphaRatio, step, 2); +void AnimatedMat_DrawAlphaStepXlu(PlayState* play, AnimatedMaterial* matAnim, f32 alphaRatio, u32 step) { + AnimatedMat_DrawMain(play, matAnim, alphaRatio, step, 2); } /** * SceneTableEntry Draw Config 1: * Allows the usage of the animated material system in scenes. */ -void Scene_DrawConfigMatAnim(GlobalContext* globalCtx) { - AnimatedMat_Draw(globalCtx, globalCtx->sceneMaterialAnims); +void Scene_DrawConfigMatAnim(PlayState* play) { + AnimatedMat_Draw(play, play->sceneMaterialAnims); } /** * SceneTableEntry Draw Config 3: * This config is unused, although it is identical to the grotto scene config from Ocarina of Time. */ -void Scene_DrawConfig3(GlobalContext* globalCtx) { +void Scene_DrawConfig3(PlayState* play) { u32 frames; - OPEN_DISPS(globalCtx->state.gfxCtx); + OPEN_DISPS(play->state.gfxCtx); - frames = globalCtx->gameplayFrames; + frames = play->gameplayFrames; - gSPSegment(POLY_XLU_DISP++, 0x08, Gfx_TexScroll(globalCtx->state.gfxCtx, 0, (frames * 1) % 64, 256, 16)); + gSPSegment(POLY_XLU_DISP++, 0x08, Gfx_TexScroll(play->state.gfxCtx, 0, (frames * 1) % 64, 256, 16)); gSPSegment(POLY_XLU_DISP++, 0x09, - Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, 127 - (frames % 128), (frames * 1) % 128, 32, 32, 1, + Gfx_TwoTexScroll(play->state.gfxCtx, 0, 127 - (frames % 128), (frames * 1) % 128, 32, 32, 1, frames % 128, (frames * 1) % 128, 32, 32)); gSPSegment(POLY_OPA_DISP++, 0x0A, - Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, 0, 0, 32, 32, 1, 0, 127 - (frames * 1) % 128, 32, 32)); + Gfx_TwoTexScroll(play->state.gfxCtx, 0, 0, 0, 32, 32, 1, 0, 127 - (frames * 1) % 128, 32, 32)); - gSPSegment(POLY_OPA_DISP++, 0x0B, Gfx_TexScroll(globalCtx->state.gfxCtx, 0, (frames * 1) % 128, 32, 32)); + gSPSegment(POLY_OPA_DISP++, 0x0B, Gfx_TexScroll(play->state.gfxCtx, 0, (frames * 1) % 128, 32, 32)); - gSPSegment(POLY_XLU_DISP++, 0x0C, - Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, 0, (frames * 50) % 2048, 8, 512, 1, 0, (frames * 60) % 2048, - 8, 512)); + gSPSegment( + POLY_XLU_DISP++, 0x0C, + Gfx_TwoTexScroll(play->state.gfxCtx, 0, 0, (frames * 50) % 2048, 8, 512, 1, 0, (frames * 60) % 2048, 8, 512)); gSPSegment(POLY_OPA_DISP++, 0x0D, - Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, 0, 0, 32, 64, 1, 0, (frames * 1) % 128, 32, 32)); + Gfx_TwoTexScroll(play->state.gfxCtx, 0, 0, 0, 32, 64, 1, 0, (frames * 1) % 128, 32, 32)); gDPPipeSync(POLY_XLU_DISP++); gDPSetEnvColor(POLY_XLU_DISP++, 128, 128, 128, 128); @@ -535,7 +534,7 @@ void Scene_DrawConfig3(GlobalContext* globalCtx) { gDPPipeSync(POLY_OPA_DISP++); gDPSetEnvColor(POLY_OPA_DISP++, 128, 128, 128, 128); - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->state.gfxCtx); } /** @@ -543,16 +542,16 @@ void Scene_DrawConfig3(GlobalContext* globalCtx) { * This config is unused and just has a single TwoTexScroll intended for two 32x32 textures (likely two water textures). * It is identical to the Castle Courtyard and Sacred Forest Meadow scene config from Ocarina of Time. */ -void Scene_DrawConfig4(GlobalContext* globalCtx) { +void Scene_DrawConfig4(PlayState* play) { u32 frames; - OPEN_DISPS(globalCtx->state.gfxCtx); + OPEN_DISPS(play->state.gfxCtx); - frames = globalCtx->gameplayFrames; + frames = play->gameplayFrames; gSPSegment(POLY_XLU_DISP++, 0x08, - Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, 127 - frames % 128, (frames * 1) % 128, 32, 32, 1, - frames % 128, (frames * 1) % 128, 32, 32)); + Gfx_TwoTexScroll(play->state.gfxCtx, 0, 127 - frames % 128, (frames * 1) % 128, 32, 32, 1, frames % 128, + (frames * 1) % 128, 32, 32)); gDPPipeSync(POLY_OPA_DISP++); gDPSetEnvColor(POLY_OPA_DISP++, 128, 128, 128, 128); @@ -560,20 +559,20 @@ void Scene_DrawConfig4(GlobalContext* globalCtx) { gDPPipeSync(POLY_XLU_DISP++); gDPSetEnvColor(POLY_XLU_DISP++, 128, 128, 128, 128); - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->state.gfxCtx); } /** * SceneTableEntry Draw Config 2: * Has no effect, and is only used in SPOT00 (cutscene scene). */ -void Scene_DrawConfigDoNothing(GlobalContext* globalCtx) { +void Scene_DrawConfigDoNothing(PlayState* play) { } /** * Stores a displaylist in the provided segment ID that sets a render mode from the index provided. */ -void Scene_SetRenderModeXlu(GlobalContext* globalCtx, s32 index, u32 flags) { +void Scene_SetRenderModeXlu(PlayState* play, s32 index, u32 flags) { static Gfx renderModeSetNoneDL[] = { gsSPEndDisplayList(), // These instructions will never get executed @@ -612,7 +611,7 @@ void Scene_SetRenderModeXlu(GlobalContext* globalCtx, s32 index, u32 flags) { }; Gfx* dList = dLists[index]; - OPEN_DISPS(globalCtx->state.gfxCtx); + OPEN_DISPS(play->state.gfxCtx); if (flags & 1) { gSPSegment(POLY_OPA_DISP++, 0x0C, dList); @@ -622,14 +621,14 @@ void Scene_SetRenderModeXlu(GlobalContext* globalCtx, s32 index, u32 flags) { gSPSegment(POLY_XLU_DISP++, 0x0C, dList); } - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->state.gfxCtx); } /** * Although this function is unused, it will store a displaylist in the provided segment ID that sets the culling mode * from the index provided. */ -void Scene_SetCullFlag(GlobalContext* globalCtx, s32 index, u32 flags) { +void Scene_SetCullFlag(PlayState* play, s32 index, u32 flags) { static Gfx setBackCullDL[] = { gsSPSetGeometryMode(G_CULL_BACK), gsSPEndDisplayList(), @@ -644,7 +643,7 @@ void Scene_SetCullFlag(GlobalContext* globalCtx, s32 index, u32 flags) { }; Gfx* dList = dLists[index]; - OPEN_DISPS(globalCtx->state.gfxCtx); + OPEN_DISPS(play->state.gfxCtx); if (flags & 1) { gSPSegment(POLY_OPA_DISP++, 0x0C, dList); @@ -654,37 +653,37 @@ void Scene_SetCullFlag(GlobalContext* globalCtx, s32 index, u32 flags) { gSPSegment(POLY_XLU_DISP++, 0x0C, dList); } - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->state.gfxCtx); } /** * SceneTableEntry Draw Config 5: * This config is unused, and its purpose is unknown. */ -void Scene_DrawConfig5(GlobalContext* globalCtx) { +void Scene_DrawConfig5(PlayState* play) { u32 dListIndex; u32 alpha; - if (globalCtx->roomCtx.unk7A[0] != 0) { + if (play->roomCtx.unk7A[0] != 0) { dListIndex = 1; - alpha = globalCtx->roomCtx.unk7A[1]; + alpha = play->roomCtx.unk7A[1]; } else { dListIndex = 0; alpha = 255; } if (alpha == 0) { - globalCtx->roomCtx.unk78 = 0; + play->roomCtx.unk78 = 0; } else { - OPEN_DISPS(globalCtx->state.gfxCtx); + OPEN_DISPS(play->state.gfxCtx); - globalCtx->roomCtx.unk78 = 1; - AnimatedMat_Draw(globalCtx, globalCtx->sceneMaterialAnims); - Scene_SetRenderModeXlu(globalCtx, dListIndex, 3); + play->roomCtx.unk78 = 1; + AnimatedMat_Draw(play, play->sceneMaterialAnims); + Scene_SetRenderModeXlu(play, dListIndex, 3); gDPSetEnvColor(POLY_OPA_DISP++, 255, 255, 255, alpha); gDPSetEnvColor(POLY_XLU_DISP++, 255, 255, 255, alpha); - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->state.gfxCtx); } } @@ -693,8 +692,8 @@ void Scene_DrawConfig5(GlobalContext* globalCtx) { * This is a special draw config for Sakon's Hideout, as well as the Music Box House. Its step value is set manually * rather than always animating like `Scene_DrawConfigMatAnim`. */ -void Scene_DrawConfigMatAnimManualStep(GlobalContext* globalCtx) { - AnimatedMat_DrawStep(globalCtx, globalCtx->sceneMaterialAnims, globalCtx->roomCtx.unk7A[0]); +void Scene_DrawConfigMatAnimManualStep(PlayState* play) { + AnimatedMat_DrawStep(play, play->sceneMaterialAnims, play->roomCtx.unk7A[0]); } /** @@ -703,7 +702,7 @@ void Scene_DrawConfigMatAnimManualStep(GlobalContext* globalCtx) { * fraction to a certain value when certain flags are set, which are likely used for the pipes whenever they are * activated. */ -void Scene_DrawConfigGreatBayTemple(GlobalContext* globalCtx) { +void Scene_DrawConfigGreatBayTemple(PlayState* play) { static Gfx greatBayTempleColorSetDL[] = { gsDPSetPrimColor(0, 255, 255, 255, 255, 255), gsSPEndDisplayList(), @@ -713,18 +712,18 @@ void Scene_DrawConfigGreatBayTemple(GlobalContext* globalCtx) { Gfx* dListHead; Gfx* dList; - if (Flags_GetSwitch(globalCtx, 0x33) && Flags_GetSwitch(globalCtx, 0x34) && Flags_GetSwitch(globalCtx, 0x35) && - Flags_GetSwitch(globalCtx, 0x36)) { - BgCheck_SetContextFlags(&globalCtx->colCtx, BGCHECK_FLAG_REVERSE_CONVEYOR_FLOW); + if (Flags_GetSwitch(play, 0x33) && Flags_GetSwitch(play, 0x34) && Flags_GetSwitch(play, 0x35) && + Flags_GetSwitch(play, 0x36)) { + BgCheck_SetContextFlags(&play->colCtx, BGCHECK_FLAG_REVERSE_CONVEYOR_FLOW); } else { - BgCheck_UnsetContextFlags(&globalCtx->colCtx, BGCHECK_FLAG_REVERSE_CONVEYOR_FLOW); + BgCheck_UnsetContextFlags(&play->colCtx, BGCHECK_FLAG_REVERSE_CONVEYOR_FLOW); } - dList = GRAPH_ALLOC(globalCtx->state.gfxCtx, sizeof(Gfx) * 18); + dList = GRAPH_ALLOC(play->state.gfxCtx, sizeof(Gfx) * 18); - AnimatedMat_Draw(globalCtx, globalCtx->sceneMaterialAnims); + AnimatedMat_Draw(play, play->sceneMaterialAnims); - OPEN_DISPS(globalCtx->state.gfxCtx); + OPEN_DISPS(play->state.gfxCtx); for (dListHead = dList, i = 0; i < 9; i++, dListHead += 2) { lodFrac = 0; @@ -733,50 +732,48 @@ void Scene_DrawConfigGreatBayTemple(GlobalContext* globalCtx) { switch (i) { case 0: - if (Flags_GetSwitch(globalCtx, 0x33) && Flags_GetSwitch(globalCtx, 0x34) && - Flags_GetSwitch(globalCtx, 0x35) && Flags_GetSwitch(globalCtx, 0x36)) { + if (Flags_GetSwitch(play, 0x33) && Flags_GetSwitch(play, 0x34) && Flags_GetSwitch(play, 0x35) && + Flags_GetSwitch(play, 0x36)) { lodFrac = 255; } break; case 1: - if (Flags_GetSwitch(globalCtx, 0x37)) { + if (Flags_GetSwitch(play, 0x37)) { lodFrac = 68; } break; case 2: - if (Flags_GetSwitch(globalCtx, 0x37) && Flags_GetSwitch(globalCtx, 0x38)) { + if (Flags_GetSwitch(play, 0x37) && Flags_GetSwitch(play, 0x38)) { lodFrac = 68; } break; case 3: - if (Flags_GetSwitch(globalCtx, 0x37) && Flags_GetSwitch(globalCtx, 0x38) && - Flags_GetSwitch(globalCtx, 0x39)) { + if (Flags_GetSwitch(play, 0x37) && Flags_GetSwitch(play, 0x38) && Flags_GetSwitch(play, 0x39)) { lodFrac = 68; } break; case 4: - if (!(Flags_GetSwitch(globalCtx, 0x33))) { + if (!(Flags_GetSwitch(play, 0x33))) { lodFrac = 68; } break; case 5: - if (Flags_GetSwitch(globalCtx, 0x34)) { + if (Flags_GetSwitch(play, 0x34)) { lodFrac = 68; } break; case 6: - if (Flags_GetSwitch(globalCtx, 0x34) && Flags_GetSwitch(globalCtx, 0x35)) { + if (Flags_GetSwitch(play, 0x34) && Flags_GetSwitch(play, 0x35)) { lodFrac = 68; } break; case 7: - if (Flags_GetSwitch(globalCtx, 0x34) && Flags_GetSwitch(globalCtx, 0x35) && - Flags_GetSwitch(globalCtx, 0x36)) { + if (Flags_GetSwitch(play, 0x34) && Flags_GetSwitch(play, 0x35) && Flags_GetSwitch(play, 0x36)) { lodFrac = 68; } break; case 8: - if (Flags_GetSwitch(globalCtx, 0x3A)) { + if (Flags_GetSwitch(play, 0x3A)) { lodFrac = 68; } break; @@ -788,5 +785,5 @@ void Scene_DrawConfigGreatBayTemple(GlobalContext* globalCtx) { gSPSegment(POLY_OPA_DISP++, 0x06, dList); gSPSegment(POLY_XLU_DISP++, 0x06, dList); - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->state.gfxCtx); } diff --git a/src/code/z_scene_table.c b/src/code/z_scene_table.c index 8372c350a..108689978 100644 --- a/src/code/z_scene_table.c +++ b/src/code/z_scene_table.c @@ -7,119 +7,119 @@ { { 0, 0 }, 0, 0, 0, 0 } SceneTableEntry gSceneTable[] = { - SCENE_ENTRY(Z2_20SICHITAI2, 0x0116, SCENE_DRAW_CFG_MAT_ANIM), - SCENE_ENTRY_NONE(), - SCENE_ENTRY_NONE(), - SCENE_ENTRY_NONE(), - SCENE_ENTRY_NONE(), - SCENE_ENTRY_NONE(), - SCENE_ENTRY_NONE(), - SCENE_ENTRY(KAKUSIANA, 0x0000, SCENE_DRAW_CFG_MAT_ANIM), - SCENE_ENTRY(SPOT00, 0x0000, SCENE_DRAW_CFG_NOTHING), - SCENE_ENTRY_NONE(), - SCENE_ENTRY(Z2_WITCH_SHOP, 0x011A, SCENE_DRAW_CFG_MAT_ANIM), - SCENE_ENTRY(Z2_LAST_BS, 0x0000, SCENE_DRAW_CFG_MAT_ANIM), - SCENE_ENTRY(Z2_HAKASHITA, 0x0113, SCENE_DRAW_CFG_MAT_ANIM), - SCENE_ENTRY(Z2_AYASHIISHOP, 0x010E, SCENE_DRAW_CFG_MAT_ANIM), - SCENE_ENTRY_NONE(), - SCENE_ENTRY_NONE(), - SCENE_ENTRY(Z2_OMOYA, 0x0132, SCENE_DRAW_CFG_DEFAULT), - SCENE_ENTRY(Z2_BOWLING, 0x0108, SCENE_DRAW_CFG_MAT_ANIM), - SCENE_ENTRY(Z2_SONCHONOIE, 0x010B, SCENE_DRAW_CFG_DEFAULT), - SCENE_ENTRY(Z2_IKANA, 0x0141, SCENE_DRAW_CFG_MAT_ANIM), - SCENE_ENTRY(Z2_KAIZOKU, 0x0000, SCENE_DRAW_CFG_MAT_ANIM), - SCENE_ENTRY(Z2_MILK_BAR, 0x010C, SCENE_DRAW_CFG_MAT_ANIM), - SCENE_ENTRY(Z2_INISIE_N, 0x0144, SCENE_DRAW_CFG_MAT_ANIM), - SCENE_ENTRY(Z2_TAKARAYA, 0x0109, SCENE_DRAW_CFG_DEFAULT), - SCENE_ENTRY(Z2_INISIE_R, 0x0144, SCENE_DRAW_CFG_MAT_ANIM), - SCENE_ENTRY(Z2_OKUJOU, 0x0000, SCENE_DRAW_CFG_DEFAULT), - SCENE_ENTRY(Z2_OPENINGDAN, 0x0000, SCENE_DRAW_CFG_MAT_ANIM), - SCENE_ENTRY(Z2_MITURIN, 0x011F, SCENE_DRAW_CFG_MAT_ANIM), - SCENE_ENTRY(Z2_13HUBUKINOMITI, 0x0000, SCENE_DRAW_CFG_DEFAULT), - SCENE_ENTRY(Z2_CASTLE, 0x0142, SCENE_DRAW_CFG_MAT_ANIM), - SCENE_ENTRY(Z2_DEKUTES, 0x0000, SCENE_DRAW_CFG_MAT_ANIM), - SCENE_ENTRY(Z2_MITURIN_BS, 0x0000, SCENE_DRAW_CFG_DEFAULT), - SCENE_ENTRY(Z2_SYATEKI_MIZU, 0x0107, SCENE_DRAW_CFG_MAT_ANIM), - SCENE_ENTRY(Z2_HAKUGIN, 0x012B, SCENE_DRAW_CFG_MAT_ANIM), - SCENE_ENTRY(Z2_ROMANYMAE, 0x0149, SCENE_DRAW_CFG_DEFAULT), - SCENE_ENTRY(Z2_PIRATE, 0x0000, SCENE_DRAW_CFG_MAT_ANIM), - SCENE_ENTRY(Z2_SYATEKI_MORI, 0x011B, SCENE_DRAW_CFG_DEFAULT), - SCENE_ENTRY(Z2_SINKAI, 0x0135, SCENE_DRAW_CFG_MAT_ANIM), - SCENE_ENTRY(Z2_YOUSEI_IZUMI, 0x013E, SCENE_DRAW_CFG_MAT_ANIM), - SCENE_ENTRY(Z2_KINSTA1, 0x011E, SCENE_DRAW_CFG_MAT_ANIM), - SCENE_ENTRY(Z2_KINDAN2, 0x013F, SCENE_DRAW_CFG_MAT_ANIM), - SCENE_ENTRY(Z2_TENMON_DAI, 0x0114, SCENE_DRAW_CFG_MAT_ANIM), - SCENE_ENTRY(Z2_LAST_DEKU, 0x0000, SCENE_DRAW_CFG_DEFAULT), - SCENE_ENTRY(Z2_22DEKUCITY, 0x0118, SCENE_DRAW_CFG_MAT_ANIM), - SCENE_ENTRY(Z2_KAJIYA, 0x0127, SCENE_DRAW_CFG_MAT_ANIM), - SCENE_ENTRY(Z2_00KEIKOKU, 0x0100, SCENE_DRAW_CFG_MAT_ANIM), - SCENE_ENTRY(Z2_POSTHOUSE, 0x0111, SCENE_DRAW_CFG_DEFAULT), - SCENE_ENTRY(Z2_LABO, 0x013A, SCENE_DRAW_CFG_MAT_ANIM), - SCENE_ENTRY(Z2_DANPEI2TEST, 0x0113, SCENE_DRAW_CFG_MAT_ANIM), - SCENE_ENTRY_NONE(), - SCENE_ENTRY(Z2_16GORON_HOUSE, 0x0124, SCENE_DRAW_CFG_DEFAULT), - SCENE_ENTRY(Z2_33ZORACITY, 0x0136, SCENE_DRAW_CFG_MAT_ANIM), - SCENE_ENTRY(Z2_8ITEMSHOP, 0x010F, SCENE_DRAW_CFG_MAT_ANIM), - SCENE_ENTRY(Z2_F01, 0x012E, SCENE_DRAW_CFG_DEFAULT), - SCENE_ENTRY(Z2_INISIE_BS, 0x0000, SCENE_DRAW_CFG_MAT_ANIM), - SCENE_ENTRY(Z2_30GYOSON, 0x0134, SCENE_DRAW_CFG_MAT_ANIM), - SCENE_ENTRY(Z2_31MISAKI, 0x0134, SCENE_DRAW_CFG_MAT_ANIM), - SCENE_ENTRY(Z2_TAKARAKUJI, 0x0112, SCENE_DRAW_CFG_DEFAULT), - SCENE_ENTRY_NONE(), - SCENE_ENTRY(Z2_TORIDE, 0x0138, SCENE_DRAW_CFG_MAT_ANIM), - SCENE_ENTRY(Z2_FISHERMAN, 0x013B, SCENE_DRAW_CFG_MAT_ANIM), - SCENE_ENTRY(Z2_GORONSHOP, 0x0129, SCENE_DRAW_CFG_MAT_ANIM), - SCENE_ENTRY(Z2_DEKU_KING, 0x011C, SCENE_DRAW_CFG_MAT_ANIM), - SCENE_ENTRY(Z2_LAST_GORON, 0x0000, SCENE_DRAW_CFG_DEFAULT), - SCENE_ENTRY(Z2_24KEMONOMITI, 0x0000, SCENE_DRAW_CFG_MAT_ANIM), - SCENE_ENTRY(Z2_F01_B, 0x0130, SCENE_DRAW_CFG_DEFAULT), - SCENE_ENTRY(Z2_F01C, 0x012F, SCENE_DRAW_CFG_DEFAULT), - SCENE_ENTRY(Z2_BOTI, 0x0106, SCENE_DRAW_CFG_DEFAULT), - SCENE_ENTRY(Z2_HAKUGIN_BS, 0x0000, SCENE_DRAW_CFG_DEFAULT), - SCENE_ENTRY(Z2_20SICHITAI, 0x0116, SCENE_DRAW_CFG_MAT_ANIM), - SCENE_ENTRY(Z2_21MITURINMAE, 0x0117, SCENE_DRAW_CFG_MAT_ANIM), - SCENE_ENTRY(Z2_LAST_ZORA, 0x0000, SCENE_DRAW_CFG_MAT_ANIM), - SCENE_ENTRY(Z2_11GORONNOSATO2, 0x0123, SCENE_DRAW_CFG_MAT_ANIM), - SCENE_ENTRY(Z2_SEA, 0x013D, SCENE_DRAW_CFG_GREAT_BAY_TEMPLE), - SCENE_ENTRY(Z2_35TAKI, 0x0137, SCENE_DRAW_CFG_MAT_ANIM), - SCENE_ENTRY(Z2_REDEAD, 0x0145, SCENE_DRAW_CFG_MAT_ANIM), - SCENE_ENTRY(Z2_BANDROOM, 0x0000, SCENE_DRAW_CFG_MAT_ANIM), - SCENE_ENTRY(Z2_11GORONNOSATO, 0x0123, SCENE_DRAW_CFG_MAT_ANIM), - SCENE_ENTRY(Z2_GORON_HAKA, 0x012A, SCENE_DRAW_CFG_MAT_ANIM), - SCENE_ENTRY(Z2_SECOM, 0x0143, SCENE_DRAW_CFG_MAT_ANIM_MANUAL_STEP), - SCENE_ENTRY(Z2_10YUKIYAMANOMURA, 0x0122, SCENE_DRAW_CFG_MAT_ANIM), - SCENE_ENTRY(Z2_TOUGITES, 0x0146, SCENE_DRAW_CFG_DEFAULT), - SCENE_ENTRY(Z2_DANPEI, 0x0120, SCENE_DRAW_CFG_MAT_ANIM), - SCENE_ENTRY(Z2_IKANAMAE, 0x0000, SCENE_DRAW_CFG_DEFAULT), - SCENE_ENTRY(Z2_DOUJOU, 0x0110, SCENE_DRAW_CFG_DEFAULT), - SCENE_ENTRY(Z2_MUSICHOUSE, 0x0147, SCENE_DRAW_CFG_MAT_ANIM_MANUAL_STEP), - SCENE_ENTRY(Z2_IKNINSIDE, 0x0142, SCENE_DRAW_CFG_MAT_ANIM), - SCENE_ENTRY(Z2_MAP_SHOP, 0x0119, SCENE_DRAW_CFG_DEFAULT), - SCENE_ENTRY(Z2_F40, 0x0140, SCENE_DRAW_CFG_DEFAULT), - SCENE_ENTRY(Z2_F41, 0x0000, SCENE_DRAW_CFG_DEFAULT), - SCENE_ENTRY(Z2_10YUKIYAMANOMURA2, 0x0122, SCENE_DRAW_CFG_MAT_ANIM), - SCENE_ENTRY(Z2_14YUKIDAMANOMITI, 0x0000, SCENE_DRAW_CFG_DEFAULT), - SCENE_ENTRY(Z2_12HAKUGINMAE, 0x0125, SCENE_DRAW_CFG_MAT_ANIM), - SCENE_ENTRY(Z2_17SETUGEN, 0x0000, SCENE_DRAW_CFG_MAT_ANIM), - SCENE_ENTRY(Z2_17SETUGEN2, 0x0000, SCENE_DRAW_CFG_MAT_ANIM), - SCENE_ENTRY(Z2_SEA_BS, 0x0000, SCENE_DRAW_CFG_MAT_ANIM), - SCENE_ENTRY(Z2_RANDOM, 0x012C, SCENE_DRAW_CFG_MAT_ANIM), - SCENE_ENTRY(Z2_YADOYA, 0x010A, SCENE_DRAW_CFG_MAT_ANIM), - SCENE_ENTRY(Z2_KONPEKI_ENT, 0x0139, SCENE_DRAW_CFG_MAT_ANIM), - SCENE_ENTRY(Z2_INSIDETOWER, 0x0000, SCENE_DRAW_CFG_MAT_ANIM), - SCENE_ENTRY(Z2_26SARUNOMORI, 0x011D, SCENE_DRAW_CFG_MAT_ANIM), - SCENE_ENTRY(Z2_LOST_WOODS, 0x0000, SCENE_DRAW_CFG_MAT_ANIM), - SCENE_ENTRY(Z2_LAST_LINK, 0x0000, SCENE_DRAW_CFG_DEFAULT), - SCENE_ENTRY(Z2_SOUGEN, 0x0000, SCENE_DRAW_CFG_DEFAULT), - SCENE_ENTRY(Z2_BOMYA, 0x010D, SCENE_DRAW_CFG_DEFAULT), - SCENE_ENTRY(Z2_KYOJINNOMA, 0x0000, SCENE_DRAW_CFG_MAT_ANIM), - SCENE_ENTRY(Z2_KOEPONARACE, 0x0131, SCENE_DRAW_CFG_MAT_ANIM), - SCENE_ENTRY(Z2_GORONRACE, 0x0126, SCENE_DRAW_CFG_DEFAULT), - SCENE_ENTRY(Z2_TOWN, 0x0101, SCENE_DRAW_CFG_DEFAULT), - SCENE_ENTRY(Z2_ICHIBA, 0x0102, SCENE_DRAW_CFG_DEFAULT), - SCENE_ENTRY(Z2_BACKTOWN, 0x0103, SCENE_DRAW_CFG_DEFAULT), - SCENE_ENTRY(Z2_CLOCKTOWER, 0x0104, SCENE_DRAW_CFG_MAT_ANIM), - SCENE_ENTRY(Z2_ALLEY, 0x0105, SCENE_DRAW_CFG_MAT_ANIM), + /* 0x00 */ SCENE_ENTRY(Z2_20SICHITAI2, 0x0116, SCENE_DRAW_CFG_MAT_ANIM), + /* 0x01 */ SCENE_ENTRY_NONE(), + /* 0x02 */ SCENE_ENTRY_NONE(), + /* 0x03 */ SCENE_ENTRY_NONE(), + /* 0x04 */ SCENE_ENTRY_NONE(), + /* 0x05 */ SCENE_ENTRY_NONE(), + /* 0x06 */ SCENE_ENTRY_NONE(), + /* 0x07 */ SCENE_ENTRY(KAKUSIANA, 0x0000, SCENE_DRAW_CFG_MAT_ANIM), + /* 0x08 */ SCENE_ENTRY(SPOT00, 0x0000, SCENE_DRAW_CFG_NOTHING), + /* 0x09 */ SCENE_ENTRY_NONE(), + /* 0x0A */ SCENE_ENTRY(Z2_WITCH_SHOP, 0x011A, SCENE_DRAW_CFG_MAT_ANIM), + /* 0x0B */ SCENE_ENTRY(Z2_LAST_BS, 0x0000, SCENE_DRAW_CFG_MAT_ANIM), + /* 0x0C */ SCENE_ENTRY(Z2_HAKASHITA, 0x0113, SCENE_DRAW_CFG_MAT_ANIM), + /* 0x0D */ SCENE_ENTRY(Z2_AYASHIISHOP, 0x010E, SCENE_DRAW_CFG_MAT_ANIM), + /* 0x0E */ SCENE_ENTRY_NONE(), + /* 0x0F */ SCENE_ENTRY_NONE(), + /* 0x10 */ SCENE_ENTRY(Z2_OMOYA, 0x0132, SCENE_DRAW_CFG_DEFAULT), + /* 0x11 */ SCENE_ENTRY(Z2_BOWLING, 0x0108, SCENE_DRAW_CFG_MAT_ANIM), + /* 0x12 */ SCENE_ENTRY(Z2_SONCHONOIE, 0x010B, SCENE_DRAW_CFG_DEFAULT), + /* 0x13 */ SCENE_ENTRY(Z2_IKANA, 0x0141, SCENE_DRAW_CFG_MAT_ANIM), + /* 0x14 */ SCENE_ENTRY(Z2_KAIZOKU, 0x0000, SCENE_DRAW_CFG_MAT_ANIM), + /* 0x15 */ SCENE_ENTRY(Z2_MILK_BAR, 0x010C, SCENE_DRAW_CFG_MAT_ANIM), + /* 0x16 */ SCENE_ENTRY(Z2_INISIE_N, 0x0144, SCENE_DRAW_CFG_MAT_ANIM), + /* 0x17 */ SCENE_ENTRY(Z2_TAKARAYA, 0x0109, SCENE_DRAW_CFG_DEFAULT), + /* 0x18 */ SCENE_ENTRY(Z2_INISIE_R, 0x0144, SCENE_DRAW_CFG_MAT_ANIM), + /* 0x19 */ SCENE_ENTRY(Z2_OKUJOU, 0x0000, SCENE_DRAW_CFG_DEFAULT), + /* 0x1A */ SCENE_ENTRY(Z2_OPENINGDAN, 0x0000, SCENE_DRAW_CFG_MAT_ANIM), + /* 0x1B */ SCENE_ENTRY(Z2_MITURIN, 0x011F, SCENE_DRAW_CFG_MAT_ANIM), + /* 0x1C */ SCENE_ENTRY(Z2_13HUBUKINOMITI, 0x0000, SCENE_DRAW_CFG_DEFAULT), + /* 0x1D */ SCENE_ENTRY(Z2_CASTLE, 0x0142, SCENE_DRAW_CFG_MAT_ANIM), + /* 0x1E */ SCENE_ENTRY(Z2_DEKUTES, 0x0000, SCENE_DRAW_CFG_MAT_ANIM), + /* 0x1F */ SCENE_ENTRY(Z2_MITURIN_BS, 0x0000, SCENE_DRAW_CFG_DEFAULT), + /* 0x20 */ SCENE_ENTRY(Z2_SYATEKI_MIZU, 0x0107, SCENE_DRAW_CFG_MAT_ANIM), + /* 0x21 */ SCENE_ENTRY(Z2_HAKUGIN, 0x012B, SCENE_DRAW_CFG_MAT_ANIM), + /* 0x22 */ SCENE_ENTRY(Z2_ROMANYMAE, 0x0149, SCENE_DRAW_CFG_DEFAULT), + /* 0x23 */ SCENE_ENTRY(Z2_PIRATE, 0x0000, SCENE_DRAW_CFG_MAT_ANIM), + /* 0x24 */ SCENE_ENTRY(Z2_SYATEKI_MORI, 0x011B, SCENE_DRAW_CFG_DEFAULT), + /* 0x25 */ SCENE_ENTRY(Z2_SINKAI, 0x0135, SCENE_DRAW_CFG_MAT_ANIM), + /* 0x26 */ SCENE_ENTRY(Z2_YOUSEI_IZUMI, 0x013E, SCENE_DRAW_CFG_MAT_ANIM), + /* 0x27 */ SCENE_ENTRY(Z2_KINSTA1, 0x011E, SCENE_DRAW_CFG_MAT_ANIM), + /* 0x28 */ SCENE_ENTRY(Z2_KINDAN2, 0x013F, SCENE_DRAW_CFG_MAT_ANIM), + /* 0x29 */ SCENE_ENTRY(Z2_TENMON_DAI, 0x0114, SCENE_DRAW_CFG_MAT_ANIM), + /* 0x2A */ SCENE_ENTRY(Z2_LAST_DEKU, 0x0000, SCENE_DRAW_CFG_DEFAULT), + /* 0x2B */ SCENE_ENTRY(Z2_22DEKUCITY, 0x0118, SCENE_DRAW_CFG_MAT_ANIM), + /* 0x2C */ SCENE_ENTRY(Z2_KAJIYA, 0x0127, SCENE_DRAW_CFG_MAT_ANIM), + /* 0x2D */ SCENE_ENTRY(Z2_00KEIKOKU, 0x0100, SCENE_DRAW_CFG_MAT_ANIM), + /* 0x2E */ SCENE_ENTRY(Z2_POSTHOUSE, 0x0111, SCENE_DRAW_CFG_DEFAULT), + /* 0x2F */ SCENE_ENTRY(Z2_LABO, 0x013A, SCENE_DRAW_CFG_MAT_ANIM), + /* 0x30 */ SCENE_ENTRY(Z2_DANPEI2TEST, 0x0113, SCENE_DRAW_CFG_MAT_ANIM), + /* 0x31 */ SCENE_ENTRY_NONE(), + /* 0x32 */ SCENE_ENTRY(Z2_16GORON_HOUSE, 0x0124, SCENE_DRAW_CFG_DEFAULT), + /* 0x33 */ SCENE_ENTRY(Z2_33ZORACITY, 0x0136, SCENE_DRAW_CFG_MAT_ANIM), + /* 0x34 */ SCENE_ENTRY(Z2_8ITEMSHOP, 0x010F, SCENE_DRAW_CFG_MAT_ANIM), + /* 0x35 */ SCENE_ENTRY(Z2_F01, 0x012E, SCENE_DRAW_CFG_DEFAULT), + /* 0x36 */ SCENE_ENTRY(Z2_INISIE_BS, 0x0000, SCENE_DRAW_CFG_MAT_ANIM), + /* 0x37 */ SCENE_ENTRY(Z2_30GYOSON, 0x0134, SCENE_DRAW_CFG_MAT_ANIM), + /* 0x38 */ SCENE_ENTRY(Z2_31MISAKI, 0x0134, SCENE_DRAW_CFG_MAT_ANIM), + /* 0x39 */ SCENE_ENTRY(Z2_TAKARAKUJI, 0x0112, SCENE_DRAW_CFG_DEFAULT), + /* 0x3A */ SCENE_ENTRY_NONE(), + /* 0x3B */ SCENE_ENTRY(Z2_TORIDE, 0x0138, SCENE_DRAW_CFG_MAT_ANIM), + /* 0x3C */ SCENE_ENTRY(Z2_FISHERMAN, 0x013B, SCENE_DRAW_CFG_MAT_ANIM), + /* 0x3D */ SCENE_ENTRY(Z2_GORONSHOP, 0x0129, SCENE_DRAW_CFG_MAT_ANIM), + /* 0x3E */ SCENE_ENTRY(Z2_DEKU_KING, 0x011C, SCENE_DRAW_CFG_MAT_ANIM), + /* 0x3F */ SCENE_ENTRY(Z2_LAST_GORON, 0x0000, SCENE_DRAW_CFG_DEFAULT), + /* 0x40 */ SCENE_ENTRY(Z2_24KEMONOMITI, 0x0000, SCENE_DRAW_CFG_MAT_ANIM), + /* 0x41 */ SCENE_ENTRY(Z2_F01_B, 0x0130, SCENE_DRAW_CFG_DEFAULT), + /* 0x42 */ SCENE_ENTRY(Z2_F01C, 0x012F, SCENE_DRAW_CFG_DEFAULT), + /* 0x43 */ SCENE_ENTRY(Z2_BOTI, 0x0106, SCENE_DRAW_CFG_DEFAULT), + /* 0x44 */ SCENE_ENTRY(Z2_HAKUGIN_BS, 0x0000, SCENE_DRAW_CFG_DEFAULT), + /* 0x45 */ SCENE_ENTRY(Z2_20SICHITAI, 0x0116, SCENE_DRAW_CFG_MAT_ANIM), + /* 0x46 */ SCENE_ENTRY(Z2_21MITURINMAE, 0x0117, SCENE_DRAW_CFG_MAT_ANIM), + /* 0x47 */ SCENE_ENTRY(Z2_LAST_ZORA, 0x0000, SCENE_DRAW_CFG_MAT_ANIM), + /* 0x48 */ SCENE_ENTRY(Z2_11GORONNOSATO2, 0x0123, SCENE_DRAW_CFG_MAT_ANIM), + /* 0x49 */ SCENE_ENTRY(Z2_SEA, 0x013D, SCENE_DRAW_CFG_GREAT_BAY_TEMPLE), + /* 0x4A */ SCENE_ENTRY(Z2_35TAKI, 0x0137, SCENE_DRAW_CFG_MAT_ANIM), + /* 0x4B */ SCENE_ENTRY(Z2_REDEAD, 0x0145, SCENE_DRAW_CFG_MAT_ANIM), + /* 0x4C */ SCENE_ENTRY(Z2_BANDROOM, 0x0000, SCENE_DRAW_CFG_MAT_ANIM), + /* 0x4D */ SCENE_ENTRY(Z2_11GORONNOSATO, 0x0123, SCENE_DRAW_CFG_MAT_ANIM), + /* 0x4E */ SCENE_ENTRY(Z2_GORON_HAKA, 0x012A, SCENE_DRAW_CFG_MAT_ANIM), + /* 0x4F */ SCENE_ENTRY(Z2_SECOM, 0x0143, SCENE_DRAW_CFG_MAT_ANIM_MANUAL_STEP), + /* 0x50 */ SCENE_ENTRY(Z2_10YUKIYAMANOMURA, 0x0122, SCENE_DRAW_CFG_MAT_ANIM), + /* 0x51 */ SCENE_ENTRY(Z2_TOUGITES, 0x0146, SCENE_DRAW_CFG_DEFAULT), + /* 0x52 */ SCENE_ENTRY(Z2_DANPEI, 0x0120, SCENE_DRAW_CFG_MAT_ANIM), + /* 0x53 */ SCENE_ENTRY(Z2_IKANAMAE, 0x0000, SCENE_DRAW_CFG_DEFAULT), + /* 0x54 */ SCENE_ENTRY(Z2_DOUJOU, 0x0110, SCENE_DRAW_CFG_DEFAULT), + /* 0x55 */ SCENE_ENTRY(Z2_MUSICHOUSE, 0x0147, SCENE_DRAW_CFG_MAT_ANIM_MANUAL_STEP), + /* 0x56 */ SCENE_ENTRY(Z2_IKNINSIDE, 0x0142, SCENE_DRAW_CFG_MAT_ANIM), + /* 0x57 */ SCENE_ENTRY(Z2_MAP_SHOP, 0x0119, SCENE_DRAW_CFG_DEFAULT), + /* 0x58 */ SCENE_ENTRY(Z2_F40, 0x0140, SCENE_DRAW_CFG_DEFAULT), + /* 0x59 */ SCENE_ENTRY(Z2_F41, 0x0000, SCENE_DRAW_CFG_DEFAULT), + /* 0x5A */ SCENE_ENTRY(Z2_10YUKIYAMANOMURA2, 0x0122, SCENE_DRAW_CFG_MAT_ANIM), + /* 0x5B */ SCENE_ENTRY(Z2_14YUKIDAMANOMITI, 0x0000, SCENE_DRAW_CFG_DEFAULT), + /* 0x5C */ SCENE_ENTRY(Z2_12HAKUGINMAE, 0x0125, SCENE_DRAW_CFG_MAT_ANIM), + /* 0x5D */ SCENE_ENTRY(Z2_17SETUGEN, 0x0000, SCENE_DRAW_CFG_MAT_ANIM), + /* 0x5E */ SCENE_ENTRY(Z2_17SETUGEN2, 0x0000, SCENE_DRAW_CFG_MAT_ANIM), + /* 0x5F */ SCENE_ENTRY(Z2_SEA_BS, 0x0000, SCENE_DRAW_CFG_MAT_ANIM), + /* 0x60 */ SCENE_ENTRY(Z2_RANDOM, 0x012C, SCENE_DRAW_CFG_MAT_ANIM), + /* 0x61 */ SCENE_ENTRY(Z2_YADOYA, 0x010A, SCENE_DRAW_CFG_MAT_ANIM), + /* 0x62 */ SCENE_ENTRY(Z2_KONPEKI_ENT, 0x0139, SCENE_DRAW_CFG_MAT_ANIM), + /* 0x63 */ SCENE_ENTRY(Z2_INSIDETOWER, 0x0000, SCENE_DRAW_CFG_MAT_ANIM), + /* 0x64 */ SCENE_ENTRY(Z2_26SARUNOMORI, 0x011D, SCENE_DRAW_CFG_MAT_ANIM), + /* 0x65 */ SCENE_ENTRY(Z2_LOST_WOODS, 0x0000, SCENE_DRAW_CFG_MAT_ANIM), + /* 0x66 */ SCENE_ENTRY(Z2_LAST_LINK, 0x0000, SCENE_DRAW_CFG_DEFAULT), + /* 0x67 */ SCENE_ENTRY(Z2_SOUGEN, 0x0000, SCENE_DRAW_CFG_DEFAULT), + /* 0x68 */ SCENE_ENTRY(Z2_BOMYA, 0x010D, SCENE_DRAW_CFG_DEFAULT), + /* 0x69 */ SCENE_ENTRY(Z2_KYOJINNOMA, 0x0000, SCENE_DRAW_CFG_MAT_ANIM), + /* 0x6A */ SCENE_ENTRY(Z2_KOEPONARACE, 0x0131, SCENE_DRAW_CFG_MAT_ANIM), + /* 0x6B */ SCENE_ENTRY(Z2_GORONRACE, 0x0126, SCENE_DRAW_CFG_DEFAULT), + /* 0x6C */ SCENE_ENTRY(Z2_TOWN, 0x0101, SCENE_DRAW_CFG_DEFAULT), + /* 0x6D */ SCENE_ENTRY(Z2_ICHIBA, 0x0102, SCENE_DRAW_CFG_DEFAULT), + /* 0x6E */ SCENE_ENTRY(Z2_BACKTOWN, 0x0103, SCENE_DRAW_CFG_DEFAULT), + /* 0x6F */ SCENE_ENTRY(Z2_CLOCKTOWER, 0x0104, SCENE_DRAW_CFG_MAT_ANIM), + /* 0x70 */ SCENE_ENTRY(Z2_ALLEY, 0x0105, SCENE_DRAW_CFG_MAT_ANIM), }; static EntranceTableEntry sMayorsResidenceEntrance0[] = { @@ -486,22 +486,22 @@ static EntranceTableEntry* sTreasureChestShopEntranceTable[] = { sTreasureChestShopEntrance1, }; -static EntranceTableEntry sStoneTowerTempleReversedEntrance0[] = { +static EntranceTableEntry sStoneTowerTempleInvertedEntrance0[] = { { 0xE8, 0x00, 0xC102 }, }; -static EntranceTableEntry sStoneTowerTempleReversedEntrance1[] = { +static EntranceTableEntry sStoneTowerTempleInvertedEntrance1[] = { { 0xE8, 0x01, 0x8102 }, }; -static EntranceTableEntry sStoneTowerTempleReversedEntrance2[] = { +static EntranceTableEntry sStoneTowerTempleInvertedEntrance2[] = { { 0xE8, 0x02, 0x8102 }, }; -static EntranceTableEntry* sStoneTowerTempleReversedEntranceTable[] = { - sStoneTowerTempleReversedEntrance0, - sStoneTowerTempleReversedEntrance1, - sStoneTowerTempleReversedEntrance2, +static EntranceTableEntry* sStoneTowerTempleInvertedEntranceTable[] = { + sStoneTowerTempleInvertedEntrance0, + sStoneTowerTempleInvertedEntrance1, + sStoneTowerTempleInvertedEntrance2, }; static EntranceTableEntry sClockTowerRooftopEntrance0[] = { @@ -782,17 +782,17 @@ static EntranceTableEntry* sSwampShootingGalleryEntranceTable[] = { sSwampShootingGalleryEntrance0, }; -static EntranceTableEntry sPinaccleRockEntrance0[] = { +static EntranceTableEntry sPinnacleRockEntrance0[] = { { 0x25, 0x00, 0x4A14 }, }; -static EntranceTableEntry sPinaccleRockEntrance1[] = { +static EntranceTableEntry sPinnacleRockEntrance1[] = { { 0x25, 0x01, 0x0A14 }, }; -static EntranceTableEntry* sPinaccleRockEntranceTable[] = { - sPinaccleRockEntrance0, - sPinaccleRockEntrance1, +static EntranceTableEntry* sPinnacleRockEntranceTable[] = { + sPinnacleRockEntrance0, + sPinnacleRockEntrance1, }; static EntranceTableEntry sFairyFountainEntrance0[] = { @@ -2657,134 +2657,134 @@ static EntranceTableEntry* sCutsceneEntranceTable[] = { { 0, NULL, NULL } static SceneEntranceTableEntry sSceneEntranceTable[] = { - SCENE_ENTRANCE(sMayorsResidenceEntranceTable, "Z2_SONCHONOIE"), - SCENE_ENTRANCE(sMajorasLairEntranceTable, "Z2_LAST_BS"), - SCENE_ENTRANCE(sMagicHagsPotionShopEntranceTable, "Z2_WITCH_SHOP"), - SCENE_ENTRANCE(sRanchHouseEntranceTable, "Z2_OMOYA"), - SCENE_ENTRANCE(sHoneyAndDarlingsShopEntranceTable, "Z2_BOWLING"), - SCENE_ENTRANCE(sBeneathTheGraveryardEntranceTable, "Z2_HAKASHITA"), - SCENE_ENTRANCE(sSouthernSwampClearedEntranceTable, "Z2_20SICHITAI2"), - SCENE_ENTRANCE(sCuriosityShopEntranceTable, "Z2_AYASHIISHOP"), - SCENE_ENTRANCE_NONE(), - SCENE_ENTRANCE_NONE(), - SCENE_ENTRANCE(sGrottosEntranceTable, "KAKUSIANA"), - SCENE_ENTRANCE_NONE(), - SCENE_ENTRANCE_NONE(), - SCENE_ENTRANCE_NONE(), - SCENE_ENTRANCE(sCutsceneEntranceTable, "SPOT00"), - SCENE_ENTRANCE_NONE(), - SCENE_ENTRANCE(sIkanaCanyonEntranceTable, "Z2_IKANA"), - SCENE_ENTRANCE(sPiratesFortressEntranceTable, "Z2_KAIZOKU"), - SCENE_ENTRANCE(sMilkBarEntranceTable, "Z2_MILK_BAR"), - SCENE_ENTRANCE(sStoneTowerTempleEntranceTable, "Z2_INISIE_N"), - SCENE_ENTRANCE(sTreasureChestShopEntranceTable, "Z2_TAKARAYA"), - SCENE_ENTRANCE(sStoneTowerTempleReversedEntranceTable, "Z2_INISIE_R"), - SCENE_ENTRANCE(sClockTowerRooftopEntranceTable, "Z2_OKUJOU"), - SCENE_ENTRANCE(sOpeningDungeonEntranceTable, "Z2_OPENINGDAN"), - SCENE_ENTRANCE(sWoodfallTempleEntranceTable, "Z2_MITURIN"), - SCENE_ENTRANCE(sPathToMountainVillageEntranceTable, "Z2_13HUBUKINOMITI"), - SCENE_ENTRANCE(sIkanaCastleEntranceTable, "Z2_CASTLE"), - SCENE_ENTRANCE(sDekuScrubPlaygroundEntranceTable, "Z2_DEKUTES"), - SCENE_ENTRANCE(sOdolwasLairEntranceTable, "Z2_MITURIN_BS"), - SCENE_ENTRANCE(sTownShootingGalleryEntranceTable, "Z2_SYATEKI_MIZU"), - SCENE_ENTRANCE(sSnowheadTempleEntranceTable, "Z2_HAKUGIN"), - SCENE_ENTRANCE(sMilkRoadEntranceTable, "Z2_ROMANYMAE"), - SCENE_ENTRANCE(sPiratesFortressInteriorEntranceTable, "Z2_PIRATE"), - SCENE_ENTRANCE(sSwampShootingGalleryEntranceTable, "Z2_SYATEKI_MORI"), - SCENE_ENTRANCE(sPinaccleRockEntranceTable, "Z2_SINKAI"), - SCENE_ENTRANCE(sFairyFountainEntranceTable, "Z2_YOUSEI_IZUMI"), - SCENE_ENTRANCE(sSwampSpiderHouseEntranceTable, "Z2_KINSTA1"), - SCENE_ENTRANCE(sOceansideSpiderHouseEntranceTable, "Z2_KINDAN2"), - SCENE_ENTRANCE(sAstralObservatoryEntranceTable, "Z2_TENMON_DAI"), - SCENE_ENTRANCE(sMoonDekuTrialEntranceTable, "Z2_LAST_DEKU"), - SCENE_ENTRANCE(sDekuPalaceEntranceTable, "Z2_22DEKUCITY"), - SCENE_ENTRANCE(sMountainSmithyEntranceTable, "Z2_KAJIYA"), - SCENE_ENTRANCE(sTerminaFieldEntranceTable, "Z2_00KEIKOKU"), - SCENE_ENTRANCE(sPostOfficeEntranceTable, "Z2_POSTHOUSE"), - SCENE_ENTRANCE(sMarineResearchLabEntranceTable, "Z2_LABO"), - SCENE_ENTRANCE(sDampesHouseEntranceTable, "Z2_DANPEI2TEST"), - SCENE_ENTRANCE_NONE(), - SCENE_ENTRANCE(sGoronShrineEntranceTable, "Z2_16GORON_HOUSE"), - SCENE_ENTRANCE(sZoraHallEntranceTable, "Z2_33ZORACITY"), - SCENE_ENTRANCE(sTradingPostEntranceTable, "Z2_8ITEMSHOP"), - SCENE_ENTRANCE(sRomaniRanchEntranceTable, "Z2_F01"), - SCENE_ENTRANCE(sTwinmoldsLairEntranceTable, "Z2_INISIE_BS"), - SCENE_ENTRANCE(sGreatBayCoastEntranceTable, "Z2_30GYOSON"), - SCENE_ENTRANCE(sZoraCapeEntranceTable, "Z2_31MISAKI"), - SCENE_ENTRANCE(sLotteryShopEntranceTable, "Z2_TAKARAKUJI"), - SCENE_ENTRANCE_NONE(), - SCENE_ENTRANCE(sPiratesFortressExteriorEntranceTable, "Z2_TORIDE"), - SCENE_ENTRANCE(sFishermansHutEntranceTable, "Z2_FISHERMAN"), - SCENE_ENTRANCE(sGoronShopEntranceTable, "Z2_GORONSHOP"), - SCENE_ENTRANCE(sDekuKingsChamberEntranceTable, "Z2_DEKU_KING"), - SCENE_ENTRANCE(sMoonGoronTrialEntranceTable, "Z2_LAST_GORON"), - SCENE_ENTRANCE(sRoadToSouthernSwampEntranceTable, "Z2_24KEMONOMITI"), - SCENE_ENTRANCE(sDoggyRacetrackEntranceTable, "Z2_F01_B"), - SCENE_ENTRANCE(sCuccoShackEntranceTable, "Z2_F01C"), - SCENE_ENTRANCE(sIkanaGraveyardEntranceTable, "Z2_BOTI"), - SCENE_ENTRANCE(sGohtsLairEntranceTable, "Z2_HAKUGIN_BS"), - SCENE_ENTRANCE(sSouthernSwampPoisonedEntranceTable, "Z2_20SICHITAI"), - SCENE_ENTRANCE(sWoodfallEntranceTable, "Z2_21MITURINMAE"), - SCENE_ENTRANCE(sMoonZoraTrialEntranceTable, "Z2_LAST_ZORA"), - SCENE_ENTRANCE(sGoronVillageSpringEntranceTable, "Z2_11GORONNOSATO2"), - SCENE_ENTRANCE(sGreatBayTempleEntranceTable, "Z2_SEA"), - SCENE_ENTRANCE(sWaterfallRapidsEntranceTable, "Z2_35TAKI"), - SCENE_ENTRANCE(sBeneathTheWellEntranceTable, "Z2_REDEAD"), - SCENE_ENTRANCE(sZoraHallRoomsEntranceTable, "Z2_BANDROOM"), - SCENE_ENTRANCE(sGoronVillageWinterEntranceTable, "Z2_11GORONNOSATO"), - SCENE_ENTRANCE(sGoronGraveryardEntranceTable, "Z2_GORON_HAKA"), - SCENE_ENTRANCE(sSakonsHideoutEntranceTable, "Z2_SECOM"), - SCENE_ENTRANCE(sMountainVillageWinterEntranceTable, "Z2_10YUKIYAMANOMURA"), - SCENE_ENTRANCE(sGhostHutEntranceTable, "Z2_TOUGITES"), - SCENE_ENTRANCE(sDekuShrineEntranceTable, "Z2_DANPEI"), - SCENE_ENTRANCE(sRoadToIkanaEntranceTable, "Z2_IKANAMAE"), - SCENE_ENTRANCE(sSwordmansSchoolEntranceTable, "Z2_DOUJOU"), - SCENE_ENTRANCE(sMusicBoxHouseEntranceTable, "Z2_MUSICHOUSE"), - SCENE_ENTRANCE(sIgosDuIkanasLairEntranceTable, "Z2_IKNINSIDE"), - SCENE_ENTRANCE(sTouristInformationEntranceTable, "Z2_MAP_SHOP"), - SCENE_ENTRANCE(sStoneTowerEntranceTable, "Z2_F40"), - SCENE_ENTRANCE(sStoneTowerInvertedEntranceTable, "Z2_F41"), - SCENE_ENTRANCE(sMountainVillageSpringEntranceTable, "Z2_10YUKIYAMANOMURA2"), - SCENE_ENTRANCE(sPathToSnowheadEntranceTable, "Z2_14YUKIDAMANOMITI"), - SCENE_ENTRANCE(sSnowheadEntranceTable, "Z2_12HAKUGINMAE"), - SCENE_ENTRANCE(sPathToGoronVillageWinterEntranceTable, "Z2_17SETUGEN"), - SCENE_ENTRANCE(sPathToGoronVillageSpringEntranceTable, "Z2_17SETUGEN2"), - SCENE_ENTRANCE(sGyorgsLairEntranceTable, "Z2_SEA_BS"), - SCENE_ENTRANCE(sSecretShrineEntranceTable, "Z2_RANDOM"), - SCENE_ENTRANCE(sStockPotInnEntranceTable, "Z2_YADOYA"), - SCENE_ENTRANCE(sGreatBayCutsceneEntranceTable, "Z2_KONPEKI_ENT"), - SCENE_ENTRANCE(sClockTowerInteriorEntranceTable, "Z2_INSIDETOWER"), - SCENE_ENTRANCE(sWoodsOfMysteryEntranceTable, "Z2_26SARUNOMORI"), - SCENE_ENTRANCE(sLostWoodsEntranceTable, "Z2_LOST_WOODS"), - SCENE_ENTRANCE(sMoonLinkTrialEntranceTable, "Z2_LAST_LINK"), - SCENE_ENTRANCE(sTheMoonEntranceTable, "Z2_SOUGEN"), - SCENE_ENTRANCE(sBombShopEntranceTable, "Z2_BOMYA"), - SCENE_ENTRANCE(sGiantsChamberEntranceTable, "Z2_KYOJINNOMA"), - SCENE_ENTRANCE(sGormanTrackEntranceTable, "Z2_KOEPONARACE"), - SCENE_ENTRANCE(sGoronRacetrackEntranceTable, "Z2_GORONRACE"), - SCENE_ENTRANCE(sEastClockTownEntranceTable, "Z2_TOWN"), - SCENE_ENTRANCE(sWestClockTownEntranceTable, "Z2_ICHIBA"), - SCENE_ENTRANCE(sNorthClockTownEntranceTable, "Z2_BACKTOWN"), - SCENE_ENTRANCE(sSouthClockTownEntranceTable, "Z2_CLOCKTOWER"), - SCENE_ENTRANCE(sLaundryPoolEntranceTable, "Z2_ALLEY"), + /* 0x00 */ SCENE_ENTRANCE(sMayorsResidenceEntranceTable, "Z2_SONCHONOIE"), + /* 0x01 */ SCENE_ENTRANCE(sMajorasLairEntranceTable, "Z2_LAST_BS"), + /* 0x02 */ SCENE_ENTRANCE(sMagicHagsPotionShopEntranceTable, "Z2_WITCH_SHOP"), + /* 0x03 */ SCENE_ENTRANCE(sRanchHouseEntranceTable, "Z2_OMOYA"), + /* 0x04 */ SCENE_ENTRANCE(sHoneyAndDarlingsShopEntranceTable, "Z2_BOWLING"), + /* 0x05 */ SCENE_ENTRANCE(sBeneathTheGraveryardEntranceTable, "Z2_HAKASHITA"), + /* 0x06 */ SCENE_ENTRANCE(sSouthernSwampClearedEntranceTable, "Z2_20SICHITAI2"), + /* 0x07 */ SCENE_ENTRANCE(sCuriosityShopEntranceTable, "Z2_AYASHIISHOP"), + /* 0x08 */ SCENE_ENTRANCE_NONE(), + /* 0x09 */ SCENE_ENTRANCE_NONE(), + /* 0x0A */ SCENE_ENTRANCE(sGrottosEntranceTable, "KAKUSIANA"), + /* 0x0B */ SCENE_ENTRANCE_NONE(), + /* 0x0C */ SCENE_ENTRANCE_NONE(), + /* 0x0D */ SCENE_ENTRANCE_NONE(), + /* 0x0E */ SCENE_ENTRANCE(sCutsceneEntranceTable, "SPOT00"), + /* 0x0F */ SCENE_ENTRANCE_NONE(), + /* 0x10 */ SCENE_ENTRANCE(sIkanaCanyonEntranceTable, "Z2_IKANA"), + /* 0x11 */ SCENE_ENTRANCE(sPiratesFortressEntranceTable, "Z2_KAIZOKU"), + /* 0x12 */ SCENE_ENTRANCE(sMilkBarEntranceTable, "Z2_MILK_BAR"), + /* 0x13 */ SCENE_ENTRANCE(sStoneTowerTempleEntranceTable, "Z2_INISIE_N"), + /* 0x14 */ SCENE_ENTRANCE(sTreasureChestShopEntranceTable, "Z2_TAKARAYA"), + /* 0x15 */ SCENE_ENTRANCE(sStoneTowerTempleInvertedEntranceTable, "Z2_INISIE_R"), + /* 0x16 */ SCENE_ENTRANCE(sClockTowerRooftopEntranceTable, "Z2_OKUJOU"), + /* 0x17 */ SCENE_ENTRANCE(sOpeningDungeonEntranceTable, "Z2_OPENINGDAN"), + /* 0x18 */ SCENE_ENTRANCE(sWoodfallTempleEntranceTable, "Z2_MITURIN"), + /* 0x19 */ SCENE_ENTRANCE(sPathToMountainVillageEntranceTable, "Z2_13HUBUKINOMITI"), + /* 0x1A */ SCENE_ENTRANCE(sIkanaCastleEntranceTable, "Z2_CASTLE"), + /* 0x1B */ SCENE_ENTRANCE(sDekuScrubPlaygroundEntranceTable, "Z2_DEKUTES"), + /* 0x1C */ SCENE_ENTRANCE(sOdolwasLairEntranceTable, "Z2_MITURIN_BS"), + /* 0x1D */ SCENE_ENTRANCE(sTownShootingGalleryEntranceTable, "Z2_SYATEKI_MIZU"), + /* 0x1E */ SCENE_ENTRANCE(sSnowheadTempleEntranceTable, "Z2_HAKUGIN"), + /* 0x1F */ SCENE_ENTRANCE(sMilkRoadEntranceTable, "Z2_ROMANYMAE"), + /* 0x20 */ SCENE_ENTRANCE(sPiratesFortressInteriorEntranceTable, "Z2_PIRATE"), + /* 0x21 */ SCENE_ENTRANCE(sSwampShootingGalleryEntranceTable, "Z2_SYATEKI_MORI"), + /* 0x22 */ SCENE_ENTRANCE(sPinnacleRockEntranceTable, "Z2_SINKAI"), + /* 0x23 */ SCENE_ENTRANCE(sFairyFountainEntranceTable, "Z2_YOUSEI_IZUMI"), + /* 0x24 */ SCENE_ENTRANCE(sSwampSpiderHouseEntranceTable, "Z2_KINSTA1"), + /* 0x25 */ SCENE_ENTRANCE(sOceansideSpiderHouseEntranceTable, "Z2_KINDAN2"), + /* 0x26 */ SCENE_ENTRANCE(sAstralObservatoryEntranceTable, "Z2_TENMON_DAI"), + /* 0x27 */ SCENE_ENTRANCE(sMoonDekuTrialEntranceTable, "Z2_LAST_DEKU"), + /* 0x28 */ SCENE_ENTRANCE(sDekuPalaceEntranceTable, "Z2_22DEKUCITY"), + /* 0x29 */ SCENE_ENTRANCE(sMountainSmithyEntranceTable, "Z2_KAJIYA"), + /* 0x2A */ SCENE_ENTRANCE(sTerminaFieldEntranceTable, "Z2_00KEIKOKU"), + /* 0x2B */ SCENE_ENTRANCE(sPostOfficeEntranceTable, "Z2_POSTHOUSE"), + /* 0x2C */ SCENE_ENTRANCE(sMarineResearchLabEntranceTable, "Z2_LABO"), + /* 0x2D */ SCENE_ENTRANCE(sDampesHouseEntranceTable, "Z2_DANPEI2TEST"), + /* 0x2E */ SCENE_ENTRANCE_NONE(), + /* 0x2F */ SCENE_ENTRANCE(sGoronShrineEntranceTable, "Z2_16GORON_HOUSE"), + /* 0x30 */ SCENE_ENTRANCE(sZoraHallEntranceTable, "Z2_33ZORACITY"), + /* 0x31 */ SCENE_ENTRANCE(sTradingPostEntranceTable, "Z2_8ITEMSHOP"), + /* 0x32 */ SCENE_ENTRANCE(sRomaniRanchEntranceTable, "Z2_F01"), + /* 0x33 */ SCENE_ENTRANCE(sTwinmoldsLairEntranceTable, "Z2_INISIE_BS"), + /* 0x34 */ SCENE_ENTRANCE(sGreatBayCoastEntranceTable, "Z2_30GYOSON"), + /* 0x35 */ SCENE_ENTRANCE(sZoraCapeEntranceTable, "Z2_31MISAKI"), + /* 0x36 */ SCENE_ENTRANCE(sLotteryShopEntranceTable, "Z2_TAKARAKUJI"), + /* 0x37 */ SCENE_ENTRANCE_NONE(), + /* 0x38 */ SCENE_ENTRANCE(sPiratesFortressExteriorEntranceTable, "Z2_TORIDE"), + /* 0x39 */ SCENE_ENTRANCE(sFishermansHutEntranceTable, "Z2_FISHERMAN"), + /* 0x3A */ SCENE_ENTRANCE(sGoronShopEntranceTable, "Z2_GORONSHOP"), + /* 0x3B */ SCENE_ENTRANCE(sDekuKingsChamberEntranceTable, "Z2_DEKU_KING"), + /* 0x3C */ SCENE_ENTRANCE(sMoonGoronTrialEntranceTable, "Z2_LAST_GORON"), + /* 0x3D */ SCENE_ENTRANCE(sRoadToSouthernSwampEntranceTable, "Z2_24KEMONOMITI"), + /* 0x3E */ SCENE_ENTRANCE(sDoggyRacetrackEntranceTable, "Z2_F01_B"), + /* 0x3F */ SCENE_ENTRANCE(sCuccoShackEntranceTable, "Z2_F01C"), + /* 0x40 */ SCENE_ENTRANCE(sIkanaGraveyardEntranceTable, "Z2_BOTI"), + /* 0x41 */ SCENE_ENTRANCE(sGohtsLairEntranceTable, "Z2_HAKUGIN_BS"), + /* 0x42 */ SCENE_ENTRANCE(sSouthernSwampPoisonedEntranceTable, "Z2_20SICHITAI"), + /* 0x43 */ SCENE_ENTRANCE(sWoodfallEntranceTable, "Z2_21MITURINMAE"), + /* 0x44 */ SCENE_ENTRANCE(sMoonZoraTrialEntranceTable, "Z2_LAST_ZORA"), + /* 0x45 */ SCENE_ENTRANCE(sGoronVillageSpringEntranceTable, "Z2_11GORONNOSATO2"), + /* 0x46 */ SCENE_ENTRANCE(sGreatBayTempleEntranceTable, "Z2_SEA"), + /* 0x47 */ SCENE_ENTRANCE(sWaterfallRapidsEntranceTable, "Z2_35TAKI"), + /* 0x48 */ SCENE_ENTRANCE(sBeneathTheWellEntranceTable, "Z2_REDEAD"), + /* 0x49 */ SCENE_ENTRANCE(sZoraHallRoomsEntranceTable, "Z2_BANDROOM"), + /* 0x4A */ SCENE_ENTRANCE(sGoronVillageWinterEntranceTable, "Z2_11GORONNOSATO"), + /* 0x4B */ SCENE_ENTRANCE(sGoronGraveryardEntranceTable, "Z2_GORON_HAKA"), + /* 0x4C */ SCENE_ENTRANCE(sSakonsHideoutEntranceTable, "Z2_SECOM"), + /* 0x4D */ SCENE_ENTRANCE(sMountainVillageWinterEntranceTable, "Z2_10YUKIYAMANOMURA"), + /* 0x4E */ SCENE_ENTRANCE(sGhostHutEntranceTable, "Z2_TOUGITES"), + /* 0x4F */ SCENE_ENTRANCE(sDekuShrineEntranceTable, "Z2_DANPEI"), + /* 0x50 */ SCENE_ENTRANCE(sRoadToIkanaEntranceTable, "Z2_IKANAMAE"), + /* 0x51 */ SCENE_ENTRANCE(sSwordmansSchoolEntranceTable, "Z2_DOUJOU"), + /* 0x52 */ SCENE_ENTRANCE(sMusicBoxHouseEntranceTable, "Z2_MUSICHOUSE"), + /* 0x53 */ SCENE_ENTRANCE(sIgosDuIkanasLairEntranceTable, "Z2_IKNINSIDE"), + /* 0x54 */ SCENE_ENTRANCE(sTouristInformationEntranceTable, "Z2_MAP_SHOP"), + /* 0x55 */ SCENE_ENTRANCE(sStoneTowerEntranceTable, "Z2_F40"), + /* 0x56 */ SCENE_ENTRANCE(sStoneTowerInvertedEntranceTable, "Z2_F41"), + /* 0x57 */ SCENE_ENTRANCE(sMountainVillageSpringEntranceTable, "Z2_10YUKIYAMANOMURA2"), + /* 0x58 */ SCENE_ENTRANCE(sPathToSnowheadEntranceTable, "Z2_14YUKIDAMANOMITI"), + /* 0x59 */ SCENE_ENTRANCE(sSnowheadEntranceTable, "Z2_12HAKUGINMAE"), + /* 0x5A */ SCENE_ENTRANCE(sPathToGoronVillageWinterEntranceTable, "Z2_17SETUGEN"), + /* 0x5B */ SCENE_ENTRANCE(sPathToGoronVillageSpringEntranceTable, "Z2_17SETUGEN2"), + /* 0x5C */ SCENE_ENTRANCE(sGyorgsLairEntranceTable, "Z2_SEA_BS"), + /* 0x5D */ SCENE_ENTRANCE(sSecretShrineEntranceTable, "Z2_RANDOM"), + /* 0x5E */ SCENE_ENTRANCE(sStockPotInnEntranceTable, "Z2_YADOYA"), + /* 0x5F */ SCENE_ENTRANCE(sGreatBayCutsceneEntranceTable, "Z2_KONPEKI_ENT"), + /* 0x60 */ SCENE_ENTRANCE(sClockTowerInteriorEntranceTable, "Z2_INSIDETOWER"), + /* 0x61 */ SCENE_ENTRANCE(sWoodsOfMysteryEntranceTable, "Z2_26SARUNOMORI"), + /* 0x62 */ SCENE_ENTRANCE(sLostWoodsEntranceTable, "Z2_LOST_WOODS"), + /* 0x63 */ SCENE_ENTRANCE(sMoonLinkTrialEntranceTable, "Z2_LAST_LINK"), + /* 0x64 */ SCENE_ENTRANCE(sTheMoonEntranceTable, "Z2_SOUGEN"), + /* 0x65 */ SCENE_ENTRANCE(sBombShopEntranceTable, "Z2_BOMYA"), + /* 0x66 */ SCENE_ENTRANCE(sGiantsChamberEntranceTable, "Z2_KYOJINNOMA"), + /* 0x67 */ SCENE_ENTRANCE(sGormanTrackEntranceTable, "Z2_KOEPONARACE"), + /* 0x68 */ SCENE_ENTRANCE(sGoronRacetrackEntranceTable, "Z2_GORONRACE"), + /* 0x69 */ SCENE_ENTRANCE(sEastClockTownEntranceTable, "Z2_TOWN"), + /* 0x6A */ SCENE_ENTRANCE(sWestClockTownEntranceTable, "Z2_ICHIBA"), + /* 0x6B */ SCENE_ENTRANCE(sNorthClockTownEntranceTable, "Z2_BACKTOWN"), + /* 0x6C */ SCENE_ENTRANCE(sSouthClockTownEntranceTable, "Z2_CLOCKTOWER"), + /* 0x6D */ SCENE_ENTRANCE(sLaundryPoolEntranceTable, "Z2_ALLEY"), }; /** * Returns a pointer to an entrance table from a given entrance index. */ -EntranceTableEntry* Entrance_GetTableEntry(u16 entranceIndex) { - u32 entranceIndex2 = entranceIndex; - EntranceTableEntry** tableEntryP = sSceneEntranceTable[entranceIndex2 >> 9].table; - EntranceTableEntry* tableEntry = tableEntryP[(entranceIndex2 >> 4) & 0x1F]; +EntranceTableEntry* Entrance_GetTableEntry(u16 entrance) { + u32 entranceIndex = entrance; + EntranceTableEntry** tableEntryP = sSceneEntranceTable[entranceIndex >> 9].table; + EntranceTableEntry* tableEntry = tableEntryP[(entranceIndex >> 4) & 0x1F]; - return &tableEntry[entranceIndex2 & 0xF]; + return &tableEntry[entranceIndex & 0xF]; } /** * Returns the scene index from a given entrance index. */ -s32 Entrance_GetSceneNum(u16 entranceIndex) { - EntranceTableEntry* tableEntry = Entrance_GetTableEntry(entranceIndex); +s32 Entrance_GetSceneNum(u16 entrance) { + EntranceTableEntry* tableEntry = Entrance_GetTableEntry(entrance); return tableEntry->sceneNum; } @@ -2792,8 +2792,8 @@ s32 Entrance_GetSceneNum(u16 entranceIndex) { /** * Returns the absolute value scene index (since for some reason some of them are negative) from a given entrance index. */ -s32 Entrance_GetSceneNumAbsolute(u16 entranceIndex) { - EntranceTableEntry* tableEntry = Entrance_GetTableEntry(entranceIndex); +s32 Entrance_GetSceneNumAbsolute(u16 entrance) { + EntranceTableEntry* tableEntry = Entrance_GetTableEntry(entrance); return ABS_ALT(tableEntry->sceneNum); } @@ -2801,8 +2801,8 @@ s32 Entrance_GetSceneNumAbsolute(u16 entranceIndex) { /** * Returns the spawn index from a given entrance index. */ -s32 Entrance_GetSpawnNum(u16 entranceIndex) { - EntranceTableEntry* tableEntry = Entrance_GetTableEntry(entranceIndex); +s32 Entrance_GetSpawnNum(u16 entrance) { + EntranceTableEntry* tableEntry = Entrance_GetTableEntry(entrance); return tableEntry->spawnNum; } @@ -2810,8 +2810,8 @@ s32 Entrance_GetSpawnNum(u16 entranceIndex) { /** * Returns the transition effect flags from a given entrance index. */ -s32 Entrance_GetTransitionFlags(u16 entranceIndex) { - EntranceTableEntry* tableEntry = Entrance_GetTableEntry(entranceIndex); +s32 Entrance_GetTransitionFlags(u16 entrance) { + EntranceTableEntry* tableEntry = Entrance_GetTableEntry(entrance); return tableEntry->flags; } diff --git a/src/code/z_schedule.c b/src/code/z_schedule.c new file mode 100644 index 000000000..cfc6293ba --- /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(PlayState* play, u8** script, ScheduleOutput* output) { + 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(PlayState* play, u8** script, ScheduleOutput* output) { + 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(PlayState* play, u8** script, ScheduleOutput* output) { + 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(PlayState* play, u8** script, ScheduleOutput* output) { + 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(PlayState* play, u8** script, ScheduleOutput* output) { + ScheduleCmdReturnValueL* cmd = (ScheduleCmdReturnValueL*)*script; + + //! @bug result is a u8, value is truncated + output->result = (cmd->retH << 8) | cmd->retL; + output->hasResult = true; + + return true; +} + +s32 Schedule_ReturnNone(PlayState* play, u8** script, ScheduleOutput* output) { + output->hasResult = false; + + return true; +} + +s32 Schedule_ReturnEmpty(PlayState* play, u8** script, ScheduleOutput* output) { + output->hasResult = true; + + return true; +} + +s32 Schedule_Nop(PlayState* play, u8** script, ScheduleOutput* output) { + return false; +} + +s32 Schedule_CheckMiscS(PlayState* play, u8** script, ScheduleOutput* output) { + ScheduleCmdCheckMiscS* cmd = (ScheduleCmdCheckMiscS*)*script; + + if (((cmd->which == SCHEDULE_CHECK_MISC_ROOM_KEY) && (INV_CONTENT(ITEM_ROOM_KEY) == ITEM_ROOM_KEY)) || + ((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(play) == PLAYER_MASK_ROMANI))) { + *script += cmd->offset; + } + + return false; +} + +s32 Schedule_ReturnValueS(PlayState* play, u8** script, ScheduleOutput* output) { + ScheduleCmdReturnValueS* cmd = (ScheduleCmdReturnValueS*)*script; + + output->result = cmd->result; + output->hasResult = true; + + return true; +} + +s32 Schedule_CheckNotInSceneS(PlayState* play, u8** script, ScheduleOutput* output) { + ScheduleCmdCheckNotInSceneS* cmd = (ScheduleCmdCheckNotInSceneS*)*script; + s16 scene = (cmd->sceneH << 8) | cmd->sceneL; + + if (scene != play->sceneNum) { + *script += cmd->offset; + } + + return false; +} + +s32 Schedule_CheckNotInSceneL(PlayState* play, u8** script, ScheduleOutput* output) { + ScheduleCmdCheckNotInSceneL* cmd = (ScheduleCmdCheckNotInSceneL*)*script; + s16 scene = (cmd->sceneH << 8) | cmd->sceneL; + + if (scene != play->sceneNum) { + *script = *script + (s16)((cmd->offsetH << 8) | cmd->offsetL); + } + + return false; +} + +s32 Schedule_CheckNotInDayS(PlayState* play, u8** script, ScheduleOutput* output) { + 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(PlayState* play, u8** script, ScheduleOutput* output) { + 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(PlayState* play, u8** script, ScheduleOutput* output) { + 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--; + + output->result = cmd->result; + output->time0 = time0; + output->time1 = time1; + output->hasResult = true; + + return true; +} + +s32 Schedule_CheckBeforeTimeS(PlayState* play, u8** script, ScheduleOutput* output) { + 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(PlayState* play, u8** script, ScheduleOutput* output) { + 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(PlayState* play, u8** script, ScheduleOutput* output) { + ScheduleCmdBranchS* cmd = (ScheduleCmdBranchS*)*script; + + *script += cmd->offset; + return false; +} + +s32 Schedule_BranchL(PlayState* play, u8** script, ScheduleOutput* output) { + ScheduleCmdBranchL* cmd = (ScheduleCmdBranchL*)*script; + + *script += (s16)((cmd->offsetH << 8) | cmd->offsetL); + return false; +} + +static s32 (*sScheduleCmdFuncs[])(PlayState*, u8**, ScheduleOutput*) = { + Schedule_CheckFlagS, Schedule_CheckFlagL, Schedule_CheckTimeRangeS, Schedule_CheckTimeRangeL, + Schedule_ReturnValueL, Schedule_ReturnNone, Schedule_ReturnEmpty, Schedule_Nop, + Schedule_CheckMiscS, Schedule_ReturnValueS, Schedule_CheckNotInSceneS, Schedule_CheckNotInSceneL, + 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(PlayState* play, u8* script, ScheduleOutput* output) { + u8 size; + s32 stop; + + do { + size = sScheduleCmdSizes[*script]; + stop = (*sScheduleCmdFuncs[*script])(play, &script, output); + script += size; + } while (!stop); + + return output->hasResult; +} diff --git a/src/code/z_skelanime.c b/src/code/z_skelanime.c index 8ad36c891..8321a309e 100644 --- a/src/code/z_skelanime.c +++ b/src/code/z_skelanime.c @@ -2,14 +2,14 @@ #define ANIM_INTERP 1 -s32 LinkAnimation_Loop(GlobalContext* globalCtx, SkelAnime* skelAnime); -s32 LinkAnimation_Once(GlobalContext* globalCtx, SkelAnime* skelAnime); +s32 LinkAnimation_Loop(PlayState* play, SkelAnime* skelAnime); +s32 LinkAnimation_Once(PlayState* play, SkelAnime* skelAnime); s32 SkelAnime_LoopFull(SkelAnime* skelAnime); s32 SkelAnime_LoopPartial(SkelAnime* skelAnime); s32 SkelAnime_Once(SkelAnime* skelAnime); void Animation_PlayLoop(SkelAnime* skelAnime, AnimationHeader* animation); void SkelAnime_UpdateTranslation(SkelAnime* skelAnime, Vec3f* pos, s16 angle); -void LinkAnimation_Change(GlobalContext* globalCtx, SkelAnime* skelAnime, LinkAnimationHeader* animation, f32 playSpeed, +void LinkAnimation_Change(PlayState* play, SkelAnime* skelAnime, LinkAnimationHeader* animation, f32 playSpeed, f32 frame, f32 frameCount, u8 animationMode, f32 morphFrames); void SkelAnime_CopyFrameTable(SkelAnime* skelAnime, Vec3s* dst, Vec3s* src); @@ -24,16 +24,16 @@ s32 sDisableAnimQueueFlags; /* * Draws the limb at `limbIndex` with a level of detail display lists index by `dListIndex` */ -void SkelAnime_DrawLimbLod(GlobalContext* globalCtx, s32 limbIndex, void** skeleton, Vec3s* jointTable, +void SkelAnime_DrawLimbLod(PlayState* play, s32 limbIndex, void** skeleton, Vec3s* jointTable, OverrideLimbDrawOpa overrideLimbDraw, PostLimbDrawOpa postLimbDraw, Actor* actor, s32 lod) { LodLimb* limb; Gfx* dList; Vec3f pos; Vec3s rot; - OPEN_DISPS(globalCtx->state.gfxCtx); + OPEN_DISPS(play->state.gfxCtx); - Matrix_StatePush(); + Matrix_Push(); limb = Lib_SegmentedToVirtual(skeleton[limbIndex]); limbIndex++; rot = jointTable[limbIndex]; @@ -43,12 +43,12 @@ void SkelAnime_DrawLimbLod(GlobalContext* globalCtx, s32 limbIndex, void** skele pos.z = limb->jointPos.z; dList = limb->dLists[lod]; - if ((overrideLimbDraw == NULL) || (overrideLimbDraw(globalCtx, limbIndex, &dList, &pos, &rot, actor) == 0)) { - Matrix_JointPosition(&pos, &rot); + if ((overrideLimbDraw == NULL) || (overrideLimbDraw(play, limbIndex, &dList, &pos, &rot, actor) == 0)) { + Matrix_TranslateRotateZYX(&pos, &rot); if (dList != NULL) { Gfx* polyTemp = POLY_OPA_DISP; - gSPMatrix(&polyTemp[0], Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_LOAD); + gSPMatrix(&polyTemp[0], Matrix_NewMtx(play->state.gfxCtx), G_MTX_LOAD); gSPDisplayList(&polyTemp[1], dList); POLY_OPA_DISP = &polyTemp[2]; @@ -56,29 +56,28 @@ void SkelAnime_DrawLimbLod(GlobalContext* globalCtx, s32 limbIndex, void** skele } if (postLimbDraw != NULL) { - postLimbDraw(globalCtx, limbIndex, &dList, &rot, actor); + postLimbDraw(play, limbIndex, &dList, &rot, actor); } if (limb->child != LIMB_DONE) { - SkelAnime_DrawLimbLod(globalCtx, limb->child, skeleton, jointTable, overrideLimbDraw, postLimbDraw, actor, lod); + SkelAnime_DrawLimbLod(play, 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, - lod); + SkelAnime_DrawLimbLod(play, limb->sibling, skeleton, jointTable, overrideLimbDraw, postLimbDraw, actor, lod); } - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->state.gfxCtx); } /** * Draw all limbs of type `LodLimb` in a given skeleton * Near or far display list is specified via `lod` */ -void SkelAnime_DrawLod(GlobalContext* globalCtx, void** skeleton, Vec3s* jointTable, - OverrideLimbDrawOpa overrideLimbDraw, PostLimbDrawOpa postLimbDraw, Actor* actor, s32 lod) { +void SkelAnime_DrawLod(PlayState* play, void** skeleton, Vec3s* jointTable, OverrideLimbDrawOpa overrideLimbDraw, + PostLimbDrawOpa postLimbDraw, Actor* actor, s32 lod) { LodLimb* rootLimb; s32 pad; Gfx* dList; @@ -89,9 +88,9 @@ void SkelAnime_DrawLod(GlobalContext* globalCtx, void** skeleton, Vec3s* jointTa return; } - OPEN_DISPS(globalCtx->state.gfxCtx); + OPEN_DISPS(play->state.gfxCtx); - Matrix_StatePush(); + Matrix_Push(); rootLimb = Lib_SegmentedToVirtual(skeleton[0]); pos.x = jointTable[0].x; @@ -101,12 +100,12 @@ void SkelAnime_DrawLod(GlobalContext* globalCtx, void** skeleton, Vec3s* jointTa rot = jointTable[1]; dList = rootLimb->dLists[lod]; - if ((overrideLimbDraw == NULL) || !overrideLimbDraw(globalCtx, 1, &dList, &pos, &rot, actor)) { - Matrix_JointPosition(&pos, &rot); + if ((overrideLimbDraw == NULL) || !overrideLimbDraw(play, 1, &dList, &pos, &rot, actor)) { + Matrix_TranslateRotateZYX(&pos, &rot); if (dList != NULL) { Gfx* polyTemp = POLY_OPA_DISP; - gSPMatrix(&polyTemp[0], Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_LOAD); + gSPMatrix(&polyTemp[0], Matrix_NewMtx(play->state.gfxCtx), G_MTX_LOAD); gSPDisplayList(&polyTemp[1], dList); @@ -115,24 +114,23 @@ void SkelAnime_DrawLod(GlobalContext* globalCtx, void** skeleton, Vec3s* jointTa } if (postLimbDraw != NULL) { - postLimbDraw(globalCtx, 1, &dList, &rot, actor); + postLimbDraw(play, 1, &dList, &rot, actor); } if (rootLimb->child != LIMB_DONE) { - SkelAnime_DrawLimbLod(globalCtx, rootLimb->child, skeleton, jointTable, overrideLimbDraw, postLimbDraw, actor, - lod); + SkelAnime_DrawLimbLod(play, rootLimb->child, skeleton, jointTable, overrideLimbDraw, postLimbDraw, actor, lod); } - Matrix_StatePop(); + Matrix_Pop(); - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->state.gfxCtx); } /** * Draw a limb of type `LodLimb` contained within a flexible skeleton * Near or far display list is specified via `lod` */ -void SkelAnime_DrawFlexLimbLod(GlobalContext* globalCtx, s32 limbIndex, void** skeleton, Vec3s* jointTable, +void SkelAnime_DrawFlexLimbLod(PlayState* play, s32 limbIndex, void** skeleton, Vec3s* jointTable, OverrideLimbDrawFlex overrideLimbDraw, PostLimbDrawFlex postLimbDraw, Actor* actor, s32 lod, Mtx** mtx) { LodLimb* limb; @@ -141,9 +139,9 @@ void SkelAnime_DrawFlexLimbLod(GlobalContext* globalCtx, s32 limbIndex, void** s Vec3f pos; Vec3s rot; - OPEN_DISPS(globalCtx->state.gfxCtx); + OPEN_DISPS(play->state.gfxCtx); - Matrix_StatePush(); + Matrix_Push(); limb = Lib_SegmentedToVirtual(skeleton[limbIndex]); limbIndex++; @@ -156,8 +154,8 @@ 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); + if ((overrideLimbDraw == NULL) || !overrideLimbDraw(play, limbIndex, &newDList, &pos, &rot, actor)) { + Matrix_TranslateRotateZYX(&pos, &rot); if (newDList != NULL) { Matrix_ToMtx(*mtx); gSPMatrix(POLY_OPA_DISP++, *mtx, G_MTX_LOAD); @@ -170,22 +168,22 @@ void SkelAnime_DrawFlexLimbLod(GlobalContext* globalCtx, s32 limbIndex, void** s } if (postLimbDraw != NULL) { - postLimbDraw(globalCtx, limbIndex, &newDList, &limbDList, &rot, actor); + postLimbDraw(play, limbIndex, &newDList, &limbDList, &rot, actor); } if (limb->child != LIMB_DONE) { - SkelAnime_DrawFlexLimbLod(globalCtx, limb->child, skeleton, jointTable, overrideLimbDraw, postLimbDraw, actor, - lod, mtx); + SkelAnime_DrawFlexLimbLod(play, limb->child, skeleton, jointTable, overrideLimbDraw, postLimbDraw, actor, lod, + mtx); } - Matrix_StatePop(); + Matrix_Pop(); if (limb->sibling != LIMB_DONE) { - SkelAnime_DrawFlexLimbLod(globalCtx, limb->sibling, skeleton, jointTable, overrideLimbDraw, postLimbDraw, actor, - lod, mtx); + SkelAnime_DrawFlexLimbLod(play, limb->sibling, skeleton, jointTable, overrideLimbDraw, postLimbDraw, actor, lod, + mtx); } - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->state.gfxCtx); } /** @@ -193,7 +191,7 @@ void SkelAnime_DrawFlexLimbLod(GlobalContext* globalCtx, s32 limbIndex, void** s * Limbs in a flexible skeleton have meshes that can stretch to line up with other limbs. * An array of matrices is dynamically allocated so each limb can access any transform to ensure its meshes line up. */ -void SkelAnime_DrawFlexLod(GlobalContext* globalCtx, void** skeleton, Vec3s* jointTable, s32 dListCount, +void SkelAnime_DrawFlexLod(PlayState* play, void** skeleton, Vec3s* jointTable, s32 dListCount, OverrideLimbDrawFlex overrideLimbDraw, PostLimbDrawFlex postLimbDraw, Actor* actor, s32 lod) { LodLimb* rootLimb; @@ -202,16 +200,16 @@ void SkelAnime_DrawFlexLod(GlobalContext* globalCtx, void** skeleton, Vec3s* joi Gfx* limbDList; Vec3f pos; Vec3s rot; - Mtx* mtx = GRAPH_ALLOC(globalCtx->state.gfxCtx, ALIGN16(sizeof(Mtx) * dListCount)); + Mtx* mtx = GRAPH_ALLOC(play->state.gfxCtx, ALIGN16(sizeof(Mtx) * dListCount)); if (skeleton == NULL) { return; } - OPEN_DISPS(globalCtx->state.gfxCtx); + OPEN_DISPS(play->state.gfxCtx); gSPSegment(POLY_OPA_DISP++, 0x0D, mtx); - Matrix_StatePush(); + Matrix_Push(); rootLimb = Lib_SegmentedToVirtual(skeleton[0]); pos.x = jointTable[0].x; @@ -222,8 +220,8 @@ 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); + if ((overrideLimbDraw == NULL) || !overrideLimbDraw(play, 1, &newDList, &pos, &rot, actor)) { + Matrix_TranslateRotateZYX(&pos, &rot); if (newDList != NULL) { Gfx* polyTemp = POLY_OPA_DISP; @@ -238,32 +236,32 @@ void SkelAnime_DrawFlexLod(GlobalContext* globalCtx, void** skeleton, Vec3s* joi } if (postLimbDraw != NULL) { - postLimbDraw(globalCtx, 1, &newDList, &limbDList, &rot, actor); + postLimbDraw(play, 1, &newDList, &limbDList, &rot, actor); } if (rootLimb->child != LIMB_DONE) { - SkelAnime_DrawFlexLimbLod(globalCtx, rootLimb->child, skeleton, jointTable, overrideLimbDraw, postLimbDraw, - actor, lod, &mtx); + SkelAnime_DrawFlexLimbLod(play, rootLimb->child, skeleton, jointTable, overrideLimbDraw, postLimbDraw, actor, + lod, &mtx); } - Matrix_StatePop(); + Matrix_Pop(); - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->state.gfxCtx); } /* * Draws the limb of the Skeleton `skeleton` at `limbIndex` */ -void SkelAnime_DrawLimbOpa(GlobalContext* globalCtx, s32 limbIndex, void** skeleton, Vec3s* jointTable, +void SkelAnime_DrawLimbOpa(PlayState* play, s32 limbIndex, void** skeleton, Vec3s* jointTable, OverrideLimbDrawOpa overrideLimbDraw, PostLimbDrawOpa postLimbDraw, Actor* actor) { StandardLimb* limb; Gfx* dList; Vec3f pos; Vec3s rot; - OPEN_DISPS(globalCtx->state.gfxCtx); + OPEN_DISPS(play->state.gfxCtx); - Matrix_StatePush(); + Matrix_Push(); limb = Lib_SegmentedToVirtual(skeleton[limbIndex]); limbIndex++; @@ -273,39 +271,39 @@ void SkelAnime_DrawLimbOpa(GlobalContext* globalCtx, s32 limbIndex, void** skele pos.z = limb->jointPos.z; dList = limb->dList; - if ((overrideLimbDraw == NULL) || !overrideLimbDraw(globalCtx, limbIndex, &dList, &pos, &rot, actor)) { - Matrix_JointPosition(&pos, &rot); + if ((overrideLimbDraw == NULL) || !overrideLimbDraw(play, limbIndex, &dList, &pos, &rot, actor)) { + Matrix_TranslateRotateZYX(&pos, &rot); if (dList != NULL) { Gfx* polyTemp = POLY_OPA_DISP; - gSPMatrix(&polyTemp[0], Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_LOAD); + gSPMatrix(&polyTemp[0], Matrix_NewMtx(play->state.gfxCtx), G_MTX_LOAD); gSPDisplayList(&polyTemp[1], dList); POLY_OPA_DISP = &polyTemp[2]; } } if (postLimbDraw != NULL) { - postLimbDraw(globalCtx, limbIndex, &dList, &rot, actor); + postLimbDraw(play, limbIndex, &dList, &rot, actor); } if (limb->child != LIMB_DONE) { - SkelAnime_DrawLimbOpa(globalCtx, limb->child, skeleton, jointTable, overrideLimbDraw, postLimbDraw, actor); + SkelAnime_DrawLimbOpa(play, 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); + SkelAnime_DrawLimbOpa(play, limb->sibling, skeleton, jointTable, overrideLimbDraw, postLimbDraw, actor); } - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->state.gfxCtx); } /** * Draw all limbs of type `StandardLimb` in a given skeleton to the polyOpa buffer */ -void SkelAnime_DrawOpa(GlobalContext* globalCtx, void** skeleton, Vec3s* jointTable, - OverrideLimbDrawOpa overrideLimbDraw, PostLimbDrawOpa postLimbDraw, Actor* actor) { +void SkelAnime_DrawOpa(PlayState* play, void** skeleton, Vec3s* jointTable, OverrideLimbDrawOpa overrideLimbDraw, + PostLimbDrawOpa postLimbDraw, Actor* actor) { StandardLimb* rootLimb; s32 pad; Gfx* dList; @@ -316,9 +314,9 @@ void SkelAnime_DrawOpa(GlobalContext* globalCtx, void** skeleton, Vec3s* jointTa return; } - OPEN_DISPS(globalCtx->state.gfxCtx); + OPEN_DISPS(play->state.gfxCtx); - Matrix_StatePush(); + Matrix_Push(); rootLimb = Lib_SegmentedToVirtual(skeleton[0]); pos.x = jointTable[0].x; @@ -328,31 +326,31 @@ void SkelAnime_DrawOpa(GlobalContext* globalCtx, void** skeleton, Vec3s* jointTa rot = jointTable[1]; dList = rootLimb->dList; - if ((overrideLimbDraw == NULL) || !overrideLimbDraw(globalCtx, 1, &dList, &pos, &rot, actor)) { - Matrix_JointPosition(&pos, &rot); + if ((overrideLimbDraw == NULL) || !overrideLimbDraw(play, 1, &dList, &pos, &rot, actor)) { + Matrix_TranslateRotateZYX(&pos, &rot); if (dList != NULL) { Gfx* polyTemp = POLY_OPA_DISP; - gSPMatrix(&polyTemp[0], Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_LOAD); + gSPMatrix(&polyTemp[0], Matrix_NewMtx(play->state.gfxCtx), G_MTX_LOAD); gSPDisplayList(&polyTemp[1], dList); POLY_OPA_DISP = &polyTemp[2]; } } if (postLimbDraw != NULL) { - postLimbDraw(globalCtx, 1, &dList, &rot, actor); + postLimbDraw(play, 1, &dList, &rot, actor); } if (rootLimb->child != LIMB_DONE) { - SkelAnime_DrawLimbOpa(globalCtx, rootLimb->child, skeleton, jointTable, overrideLimbDraw, postLimbDraw, actor); + SkelAnime_DrawLimbOpa(play, rootLimb->child, skeleton, jointTable, overrideLimbDraw, postLimbDraw, actor); } - Matrix_StatePop(); + Matrix_Pop(); - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->state.gfxCtx); } -void SkelAnime_DrawFlexLimbOpa(GlobalContext* globalCtx, s32 limbIndex, void** skeleton, Vec3s* jointTable, +void SkelAnime_DrawFlexLimbOpa(PlayState* play, s32 limbIndex, void** skeleton, Vec3s* jointTable, OverrideLimbDrawOpa overrideLimbDraw, PostLimbDrawOpa postLimbDraw, Actor* actor, Mtx** limbMatricies) { StandardLimb* limb; @@ -361,9 +359,9 @@ void SkelAnime_DrawFlexLimbOpa(GlobalContext* globalCtx, s32 limbIndex, void** s Vec3f pos; Vec3s rot; - OPEN_DISPS(globalCtx->state.gfxCtx); + OPEN_DISPS(play->state.gfxCtx); - Matrix_StatePush(); + Matrix_Push(); limb = Lib_SegmentedToVirtual(skeleton[limbIndex]); limbIndex++; @@ -375,8 +373,8 @@ 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); + if ((overrideLimbDraw == NULL) || !overrideLimbDraw(play, limbIndex, &newDList, &pos, &rot, actor)) { + Matrix_TranslateRotateZYX(&pos, &rot); if (newDList != NULL) { Matrix_ToMtx(*limbMatricies); gSPMatrix(POLY_OPA_DISP++, *limbMatricies, G_MTX_LOAD); @@ -389,22 +387,22 @@ void SkelAnime_DrawFlexLimbOpa(GlobalContext* globalCtx, s32 limbIndex, void** s } if (postLimbDraw != NULL) { - postLimbDraw(globalCtx, limbIndex, &limbDList, &rot, actor); + postLimbDraw(play, limbIndex, &limbDList, &rot, actor); } if (limb->child != LIMB_DONE) { - SkelAnime_DrawFlexLimbOpa(globalCtx, limb->child, skeleton, jointTable, overrideLimbDraw, postLimbDraw, actor, + SkelAnime_DrawFlexLimbOpa(play, limb->child, skeleton, jointTable, overrideLimbDraw, postLimbDraw, actor, limbMatricies); } - Matrix_StatePop(); + Matrix_Pop(); if (limb->sibling != LIMB_DONE) { - SkelAnime_DrawFlexLimbOpa(globalCtx, limb->sibling, skeleton, jointTable, overrideLimbDraw, postLimbDraw, actor, + SkelAnime_DrawFlexLimbOpa(play, limb->sibling, skeleton, jointTable, overrideLimbDraw, postLimbDraw, actor, limbMatricies); } - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->state.gfxCtx); } /** @@ -412,7 +410,7 @@ void SkelAnime_DrawFlexLimbOpa(GlobalContext* globalCtx, s32 limbIndex, void** s * Limbs in a flexible skeleton have meshes that can stretch to line up with other limbs. * An array of matrices is dynamically allocated so each limb can access any transform to ensure its meshes line up. */ -void SkelAnime_DrawFlexOpa(GlobalContext* globalCtx, void** skeleton, Vec3s* jointTable, s32 dListCount, +void SkelAnime_DrawFlexOpa(PlayState* play, void** skeleton, Vec3s* jointTable, s32 dListCount, OverrideLimbDrawOpa overrideLimbDraw, PostLimbDrawOpa postLimbDraw, Actor* actor) { StandardLimb* rootLimb; s32 pad; @@ -420,17 +418,17 @@ void SkelAnime_DrawFlexOpa(GlobalContext* globalCtx, void** skeleton, Vec3s* joi Gfx* limbDList; Vec3f pos; Vec3s rot; - Mtx* mtx = GRAPH_ALLOC(globalCtx->state.gfxCtx, ALIGN16(sizeof(Mtx) * dListCount)); + Mtx* mtx = GRAPH_ALLOC(play->state.gfxCtx, ALIGN16(sizeof(Mtx) * dListCount)); if (skeleton == NULL) { return; } - OPEN_DISPS(globalCtx->state.gfxCtx); + OPEN_DISPS(play->state.gfxCtx); gSPSegment(POLY_OPA_DISP++, 0x0D, mtx); - Matrix_StatePush(); + Matrix_Push(); rootLimb = Lib_SegmentedToVirtual(skeleton[0]); @@ -441,8 +439,8 @@ 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); + if ((overrideLimbDraw == NULL) || !overrideLimbDraw(play, 1, &newDList, &pos, &rot, actor)) { + Matrix_TranslateRotateZYX(&pos, &rot); if (newDList != NULL) { Gfx* polyTemp = POLY_OPA_DISP; @@ -459,20 +457,20 @@ void SkelAnime_DrawFlexOpa(GlobalContext* globalCtx, void** skeleton, Vec3s* joi } if (postLimbDraw != NULL) { - postLimbDraw(globalCtx, 1, &limbDList, &rot, actor); + postLimbDraw(play, 1, &limbDList, &rot, actor); } if (rootLimb->child != LIMB_DONE) { - SkelAnime_DrawFlexLimbOpa(globalCtx, rootLimb->child, skeleton, jointTable, overrideLimbDraw, postLimbDraw, - actor, &mtx); + SkelAnime_DrawFlexLimbOpa(play, rootLimb->child, skeleton, jointTable, overrideLimbDraw, postLimbDraw, actor, + &mtx); } - Matrix_StatePop(); + Matrix_Pop(); - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->state.gfxCtx); } -void SkelAnime_DrawTransformFlexLimbOpa(GlobalContext* globalCtx, s32 limbIndex, void** skeleton, Vec3s* jointTable, +void SkelAnime_DrawTransformFlexLimbOpa(PlayState* play, s32 limbIndex, void** skeleton, Vec3s* jointTable, OverrideLimbDrawOpa overrideLimbDraw, PostLimbDrawOpa postLimbDraw, TransformLimbDrawOpa transformLimbDraw, Actor* actor, Mtx** mtx) { StandardLimb* limb; @@ -481,9 +479,9 @@ void SkelAnime_DrawTransformFlexLimbOpa(GlobalContext* globalCtx, s32 limbIndex, Vec3f pos; Vec3s rot; - OPEN_DISPS(globalCtx->state.gfxCtx); + OPEN_DISPS(play->state.gfxCtx); - Matrix_StatePush(); + Matrix_Push(); limb = Lib_SegmentedToVirtual(skeleton[limbIndex]); limbIndex++; @@ -495,11 +493,11 @@ 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(); + if ((overrideLimbDraw == NULL) || !overrideLimbDraw(play, limbIndex, &newDList, &pos, &rot, actor)) { + Matrix_TranslateRotateZYX(&pos, &rot); + Matrix_Push(); - transformLimbDraw(globalCtx, limbIndex, actor); + transformLimbDraw(play, limbIndex, actor); if (newDList != NULL) { Gfx* polyTemp = POLY_OPA_DISP; @@ -514,26 +512,26 @@ void SkelAnime_DrawTransformFlexLimbOpa(GlobalContext* globalCtx, s32 limbIndex, (*mtx)++; } } - Matrix_StatePop(); + Matrix_Pop(); } if (postLimbDraw != NULL) { - postLimbDraw(globalCtx, limbIndex, &limbDList, &rot, actor); + postLimbDraw(play, limbIndex, &limbDList, &rot, actor); } if (limb->child != LIMB_DONE) { - SkelAnime_DrawTransformFlexLimbOpa(globalCtx, limb->child, skeleton, jointTable, overrideLimbDraw, postLimbDraw, + SkelAnime_DrawTransformFlexLimbOpa(play, limb->child, skeleton, jointTable, overrideLimbDraw, postLimbDraw, transformLimbDraw, actor, mtx); } - Matrix_StatePop(); + Matrix_Pop(); if (limb->sibling != LIMB_DONE) { - SkelAnime_DrawTransformFlexLimbOpa(globalCtx, limb->sibling, skeleton, jointTable, overrideLimbDraw, - postLimbDraw, transformLimbDraw, actor, mtx); + SkelAnime_DrawTransformFlexLimbOpa(play, limb->sibling, skeleton, jointTable, overrideLimbDraw, postLimbDraw, + transformLimbDraw, actor, mtx); } - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->state.gfxCtx); } /** @@ -545,7 +543,7 @@ void SkelAnime_DrawTransformFlexLimbOpa(GlobalContext* globalCtx, s32 limbIndex, * coordinates. * Note that the `TransformLimbDraw` does not have a NULL check, so must be provided even if empty. */ -void SkelAnime_DrawTransformFlexOpa(GlobalContext* globalCtx, void** skeleton, Vec3s* jointTable, s32 dListCount, +void SkelAnime_DrawTransformFlexOpa(PlayState* play, void** skeleton, Vec3s* jointTable, s32 dListCount, OverrideLimbDrawOpa overrideLimbDraw, PostLimbDrawOpa postLimbDraw, TransformLimbDrawOpa transformLimbDraw, Actor* actor) { StandardLimb* rootLimb; @@ -560,13 +558,13 @@ void SkelAnime_DrawTransformFlexOpa(GlobalContext* globalCtx, void** skeleton, V return; } - OPEN_DISPS(globalCtx->state.gfxCtx); + OPEN_DISPS(play->state.gfxCtx); - mtx = GRAPH_ALLOC(globalCtx->state.gfxCtx, ALIGN16(sizeof(Mtx) * dListCount)); + mtx = GRAPH_ALLOC(play->state.gfxCtx, ALIGN16(sizeof(Mtx) * dListCount)); gSPSegment(POLY_OPA_DISP++, 0x0D, mtx); - Matrix_StatePush(); + Matrix_Push(); rootLimb = Lib_SegmentedToVirtual(skeleton[0]); @@ -577,11 +575,11 @@ 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(); + if ((overrideLimbDraw == NULL) || !overrideLimbDraw(play, 1, &newDList, &pos, &rot, actor)) { + Matrix_TranslateRotateZYX(&pos, &rot); + Matrix_Push(); - transformLimbDraw(globalCtx, 1, actor); + transformLimbDraw(play, 1, actor); if (newDList != NULL) { Gfx* polyTemp = POLY_OPA_DISP; @@ -595,21 +593,21 @@ void SkelAnime_DrawTransformFlexOpa(GlobalContext* globalCtx, void** skeleton, V Matrix_ToMtx(mtx++); } } - Matrix_StatePop(); + Matrix_Pop(); } if (postLimbDraw != NULL) { - postLimbDraw(globalCtx, 1, &limbDList, &rot, actor); + postLimbDraw(play, 1, &limbDList, &rot, actor); } if (rootLimb->child != LIMB_DONE) { - SkelAnime_DrawTransformFlexLimbOpa(globalCtx, rootLimb->child, skeleton, jointTable, overrideLimbDraw, - postLimbDraw, transformLimbDraw, actor, &mtx); + SkelAnime_DrawTransformFlexLimbOpa(play, rootLimb->child, skeleton, jointTable, overrideLimbDraw, postLimbDraw, + transformLimbDraw, actor, &mtx); } - Matrix_StatePop(); + Matrix_Pop(); - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->state.gfxCtx); } /** @@ -627,9 +625,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]; @@ -653,14 +649,14 @@ s16 Animation_GetLastFrame(void* animation) { * Draws the Skeleton `skeleton`'s limb at index `limbIndex`. Appends all generated graphics commands to * `gfx`. Returns a pointer to the next gfx to be appended to. */ -Gfx* SkelAnime_DrawLimb(GlobalContext* globalCtx, s32 limbIndex, void** skeleton, Vec3s* jointTable, +Gfx* SkelAnime_DrawLimb(PlayState* play, s32 limbIndex, void** skeleton, Vec3s* jointTable, OverrideLimbDraw overrideLimbDraw, PostLimbDraw postLimbDraw, Actor* actor, Gfx* gfx) { StandardLimb* limb; Gfx* dList; Vec3f pos; Vec3s rot; - Matrix_StatePush(); + Matrix_Push(); limb = Lib_SegmentedToVirtual(skeleton[limbIndex]); limbIndex++; @@ -672,29 +668,27 @@ 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); + if ((overrideLimbDraw == NULL) || !overrideLimbDraw(play, limbIndex, &dList, &pos, &rot, actor, &gfx)) { + Matrix_TranslateRotateZYX(&pos, &rot); if (dList != NULL) { - gSPMatrix(&gfx[0], Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_LOAD); + gSPMatrix(&gfx[0], Matrix_NewMtx(play->state.gfxCtx), G_MTX_LOAD); gSPDisplayList(&gfx[1], dList); gfx = &gfx[2]; } } if (postLimbDraw != NULL) { - postLimbDraw(globalCtx, limbIndex, &dList, &rot, actor, &gfx); + postLimbDraw(play, limbIndex, &dList, &rot, actor, &gfx); } if (limb->child != LIMB_DONE) { - gfx = SkelAnime_DrawLimb(globalCtx, limb->child, skeleton, jointTable, overrideLimbDraw, postLimbDraw, actor, - gfx); + gfx = SkelAnime_DrawLimb(play, limb->child, skeleton, jointTable, overrideLimbDraw, postLimbDraw, actor, gfx); } - Matrix_StatePop(); + Matrix_Pop(); if (limb->sibling != LIMB_DONE) { - gfx = SkelAnime_DrawLimb(globalCtx, limb->sibling, skeleton, jointTable, overrideLimbDraw, postLimbDraw, actor, - gfx); + gfx = SkelAnime_DrawLimb(play, limb->sibling, skeleton, jointTable, overrideLimbDraw, postLimbDraw, actor, gfx); } return gfx; @@ -704,7 +698,7 @@ Gfx* SkelAnime_DrawLimb(GlobalContext* globalCtx, s32 limbIndex, void** skeleton * Draws the Skeleton `skeleton` Appends all generated graphics to `gfx`, and returns a pointer to the * next gfx to be appended to. */ -Gfx* SkelAnime_Draw(GlobalContext* globalCtx, void** skeleton, Vec3s* jointTable, OverrideLimbDraw overrideLimbDraw, +Gfx* SkelAnime_Draw(PlayState* play, void** skeleton, Vec3s* jointTable, OverrideLimbDraw overrideLimbDraw, PostLimbDraw postLimbDraw, Actor* actor, Gfx* gfx) { StandardLimb* rootLimb; s32 pad; @@ -716,7 +710,7 @@ Gfx* SkelAnime_Draw(GlobalContext* globalCtx, void** skeleton, Vec3s* jointTable return NULL; } - Matrix_StatePush(); + Matrix_Push(); rootLimb = Lib_SegmentedToVirtual(skeleton[0]); @@ -728,25 +722,25 @@ 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); + if ((overrideLimbDraw == NULL) || !overrideLimbDraw(play, 1, &dList, &pos, &rot, actor, &gfx)) { + Matrix_TranslateRotateZYX(&pos, &rot); if (dList != NULL) { - gSPMatrix(&gfx[0], Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_LOAD); + gSPMatrix(&gfx[0], Matrix_NewMtx(play->state.gfxCtx), G_MTX_LOAD); gSPDisplayList(&gfx[1], dList); gfx = &gfx[2]; } } if (postLimbDraw != NULL) { - postLimbDraw(globalCtx, 1, &dList, &rot, actor, &gfx); + postLimbDraw(play, 1, &dList, &rot, actor, &gfx); } if (rootLimb->child != LIMB_DONE) { - gfx = SkelAnime_DrawLimb(globalCtx, rootLimb->child, skeleton, jointTable, overrideLimbDraw, postLimbDraw, - actor, gfx); + gfx = + SkelAnime_DrawLimb(play, rootLimb->child, skeleton, jointTable, overrideLimbDraw, postLimbDraw, actor, gfx); } - Matrix_StatePop(); + Matrix_Pop(); return gfx; } @@ -754,7 +748,7 @@ Gfx* SkelAnime_Draw(GlobalContext* globalCtx, void** skeleton, Vec3s* jointTable /** * Draw a limb of type `StandardLimb` contained within a flexible skeleton to the specified display buffer */ -Gfx* SkelAnime_DrawFlexLimb(GlobalContext* globalCtx, s32 limbIndex, void** skeleton, Vec3s* jointTable, +Gfx* SkelAnime_DrawFlexLimb(PlayState* play, s32 limbIndex, void** skeleton, Vec3s* jointTable, OverrideLimbDraw overrideLimbDraw, PostLimbDraw postLimbDraw, Actor* actor, Mtx** mtx, Gfx* gfx) { StandardLimb* limb; @@ -763,7 +757,7 @@ Gfx* SkelAnime_DrawFlexLimb(GlobalContext* globalCtx, s32 limbIndex, void** skel Vec3f pos; Vec3s rot; - Matrix_StatePush(); + Matrix_Push(); limb = Lib_SegmentedToVirtual(skeleton[limbIndex]); limbIndex++; @@ -775,8 +769,8 @@ 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); + if ((overrideLimbDraw == NULL) || !overrideLimbDraw(play, limbIndex, &newDList, &pos, &rot, actor, &gfx)) { + Matrix_TranslateRotateZYX(&pos, &rot); if (newDList != NULL) { gSPMatrix(&gfx[0], Matrix_ToMtx(*mtx), G_MTX_LOAD); gSPDisplayList(&gfx[1], newDList); @@ -791,19 +785,19 @@ Gfx* SkelAnime_DrawFlexLimb(GlobalContext* globalCtx, s32 limbIndex, void** skel } if (postLimbDraw != NULL) { - postLimbDraw(globalCtx, limbIndex, &limbDList, &rot, actor, &gfx); + postLimbDraw(play, limbIndex, &limbDList, &rot, actor, &gfx); } if (limb->child != LIMB_DONE) { - gfx = SkelAnime_DrawFlexLimb(globalCtx, limb->child, skeleton, jointTable, overrideLimbDraw, postLimbDraw, - actor, mtx, gfx); + gfx = SkelAnime_DrawFlexLimb(play, limb->child, skeleton, jointTable, overrideLimbDraw, postLimbDraw, actor, + mtx, gfx); } - Matrix_StatePop(); + Matrix_Pop(); if (limb->sibling != LIMB_DONE) { - gfx = SkelAnime_DrawFlexLimb(globalCtx, limb->sibling, skeleton, jointTable, overrideLimbDraw, postLimbDraw, - actor, mtx, gfx); + gfx = SkelAnime_DrawFlexLimb(play, limb->sibling, skeleton, jointTable, overrideLimbDraw, postLimbDraw, actor, + mtx, gfx); } return gfx; @@ -814,7 +808,7 @@ Gfx* SkelAnime_DrawFlexLimb(GlobalContext* globalCtx, s32 limbIndex, void** skel * Limbs in a flexible skeleton have meshes that can stretch to line up with other limbs. * An array of matrices is dynamically allocated so each limb can access any transform to ensure its meshes line up. */ -Gfx* SkelAnime_DrawFlex(GlobalContext* globalCtx, void** skeleton, Vec3s* jointTable, s32 dListCount, +Gfx* SkelAnime_DrawFlex(PlayState* play, void** skeleton, Vec3s* jointTable, s32 dListCount, OverrideLimbDraw overrideLimbDraw, PostLimbDraw postLimbDraw, Actor* actor, Gfx* gfx) { StandardLimb* rootLimb; s32 pad; @@ -828,11 +822,11 @@ Gfx* SkelAnime_DrawFlex(GlobalContext* globalCtx, void** skeleton, Vec3s* jointT return NULL; } - mtx = GRAPH_ALLOC(globalCtx->state.gfxCtx, ALIGN16(sizeof(Mtx) * dListCount)); + mtx = GRAPH_ALLOC(play->state.gfxCtx, ALIGN16(sizeof(Mtx) * dListCount)); gSPSegment(gfx++, 0x0D, mtx); - Matrix_StatePush(); + Matrix_Push(); rootLimb = Lib_SegmentedToVirtual(skeleton[0]); @@ -844,8 +838,8 @@ 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); + if ((overrideLimbDraw == NULL) || !overrideLimbDraw(play, 1, &newDList, &pos, &rot, actor, &gfx)) { + Matrix_TranslateRotateZYX(&pos, &rot); if (newDList != NULL) { gSPMatrix(&gfx[0], Matrix_ToMtx(mtx), G_MTX_LOAD); gSPDisplayList(&gfx[1], newDList); @@ -860,15 +854,15 @@ Gfx* SkelAnime_DrawFlex(GlobalContext* globalCtx, void** skeleton, Vec3s* jointT } if (postLimbDraw != NULL) { - postLimbDraw(globalCtx, 1, &limbDList, &rot, actor, &gfx); + postLimbDraw(play, 1, &limbDList, &rot, actor, &gfx); } if (rootLimb->child != LIMB_DONE) { - gfx = SkelAnime_DrawFlexLimb(globalCtx, rootLimb->child, skeleton, jointTable, overrideLimbDraw, postLimbDraw, - actor, &mtx, gfx); + gfx = SkelAnime_DrawFlexLimb(play, rootLimb->child, skeleton, jointTable, overrideLimbDraw, postLimbDraw, actor, + &mtx, gfx); } - Matrix_StatePop(); + Matrix_Pop(); return gfx; } @@ -930,30 +924,30 @@ s16 Animation_GetLastFrame2(LegacyAnimationHeader* animation) { } /** - * Linearly interpolates the start and tactoret frame tables with the given weight, putting the result in dst + * Linearly interpolates the start and target frame tables with the given weight, putting the result in dst */ -void SkelAnime_InterpFrameTable(s32 limbCount, Vec3s* dst, Vec3s* start, Vec3s* tactoret, f32 weight) { +void SkelAnime_InterpFrameTable(s32 limbCount, Vec3s* dst, Vec3s* start, Vec3s* target, f32 weight) { s32 i; s16 diff; s16 base; if (weight < 1.0f) { - for (i = 0; i < limbCount; i++, dst++, start++, tactoret++) { + for (i = 0; i < limbCount; i++, dst++, start++, target++) { base = start->x; - diff = tactoret->x - base; + diff = target->x - base; dst->x = (s16)(diff * weight) + base; base = start->y; - diff = tactoret->y - base; + diff = target->y - base; dst->y = (s16)(diff * weight) + base; base = start->z; - diff = tactoret->z - base; + diff = target->z - base; dst->z = (s16)(diff * weight) + base; } } else { - for (i = 0; i < limbCount; i++, dst++, tactoret++) { - dst->x = tactoret->x; - dst->y = tactoret->y; - dst->z = tactoret->z; + for (i = 0; i < limbCount; i++, dst++, target++) { + dst->x = target->x; + dst->y = target->y; + dst->z = target->z; } } } @@ -968,14 +962,14 @@ void AnimationContext_Reset(AnimationContext* animationCtx) { /** * Shifts the queue flag to the next queue */ -void AnimationContext_SetNextQueue(GlobalContext* globalCtx) { +void AnimationContext_SetNextQueue(PlayState* play) { sAnimQueueFlags <<= 1; } /** * Disables the current animation queue. Only load and move actor requests will be processed for that queue. */ -void AnimationContext_DisableQueue(GlobalContext* globalCtx) { +void AnimationContext_DisableQueue(PlayState* play) { sDisableAnimQueueFlags |= sAnimQueueFlags; } @@ -996,9 +990,9 @@ AnimationEntry* AnimationContext_AddEntry(AnimationContext* animationCtx, Animat /** * Requests loading frame data from the Link animation into frameTable */ -void AnimationContext_SetLoadFrame(GlobalContext* globalCtx, LinkAnimationHeader* animation, s32 frame, s32 limbCount, +void AnimationContext_SetLoadFrame(PlayState* play, LinkAnimationHeader* animation, s32 frame, s32 limbCount, Vec3s* frameTable) { - AnimationEntry* entry = AnimationContext_AddEntry(&globalCtx->animationCtx, ANIMATION_LINKANIMETION); + AnimationEntry* entry = AnimationContext_AddEntry(&play->animationCtx, ANIMATION_LINKANIMETION); if (entry != NULL) { LinkAnimationHeader* linkAnimHeader = Lib_SegmentedToVirtual(animation); @@ -1014,8 +1008,8 @@ void AnimationContext_SetLoadFrame(GlobalContext* globalCtx, LinkAnimationHeader /** * Requests copying all vectors from src frame table into dst frame table */ -void AnimationContext_SetCopyAll(GlobalContext* globalCtx, s32 vecCount, Vec3s* dst, Vec3s* src) { - AnimationEntry* entry = AnimationContext_AddEntry(&globalCtx->animationCtx, ANIMENTRY_COPYALL); +void AnimationContext_SetCopyAll(PlayState* play, s32 vecCount, Vec3s* dst, Vec3s* src) { + AnimationEntry* entry = AnimationContext_AddEntry(&play->animationCtx, ANIMENTRY_COPYALL); if (entry != NULL) { entry->data.copy.queueFlag = sAnimQueueFlags; @@ -1028,8 +1022,8 @@ void AnimationContext_SetCopyAll(GlobalContext* globalCtx, s32 vecCount, Vec3s* /** * Requests interpolating between base and mod frame tables with the given weight, placing the result in base */ -void AnimationContext_SetInterp(GlobalContext* globalCtx, s32 vecCount, Vec3s* base, Vec3s* mod, f32 weight) { - AnimationEntry* entry = AnimationContext_AddEntry(&globalCtx->animationCtx, ANIMENTRY_INTERP); +void AnimationContext_SetInterp(PlayState* play, s32 vecCount, Vec3s* base, Vec3s* mod, f32 weight) { + AnimationEntry* entry = AnimationContext_AddEntry(&play->animationCtx, ANIMENTRY_INTERP); if (entry != NULL) { entry->data.interp.queueFlag = sAnimQueueFlags; @@ -1043,8 +1037,8 @@ void AnimationContext_SetInterp(GlobalContext* globalCtx, s32 vecCount, Vec3s* b /** * Requests copying vectors from src frame table to dst frame table whose load flag is true */ -void AnimationContext_SetCopyTrue(GlobalContext* globalCtx, s32 vecCount, Vec3s* dst, Vec3s* src, u8* copyFlag) { - AnimationEntry* entry = AnimationContext_AddEntry(&globalCtx->animationCtx, ANIMENTRY_COPYTRUE); +void AnimationContext_SetCopyTrue(PlayState* play, s32 vecCount, Vec3s* dst, Vec3s* src, u8* copyFlag) { + AnimationEntry* entry = AnimationContext_AddEntry(&play->animationCtx, ANIMENTRY_COPYTRUE); if (entry != NULL) { entry->data.copy1.queueFlag = sAnimQueueFlags; @@ -1058,8 +1052,8 @@ void AnimationContext_SetCopyTrue(GlobalContext* globalCtx, s32 vecCount, Vec3s* /** * Requests copying vectors from src frame table to dst frame table whose load flag is false */ -void AnimationContext_SetCopyFalse(GlobalContext* globalCtx, s32 vecCount, Vec3s* dst, Vec3s* src, u8* copyFlag) { - AnimationEntry* entry = AnimationContext_AddEntry(&globalCtx->animationCtx, ANIMENTRY_COPYFALSE); +void AnimationContext_SetCopyFalse(PlayState* play, s32 vecCount, Vec3s* dst, Vec3s* src, u8* copyFlag) { + AnimationEntry* entry = AnimationContext_AddEntry(&play->animationCtx, ANIMENTRY_COPYFALSE); if (entry != NULL) { entry->data.copy0.queueFlag = sAnimQueueFlags; @@ -1073,8 +1067,8 @@ 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 arg3) { - AnimationEntry* entry = AnimationContext_AddEntry(&globalCtx->animationCtx, ANIMENTRY_MOVEACTOR); +void AnimationContext_SetMoveActor(PlayState* play, Actor* actor, SkelAnime* skelAnime, f32 arg3) { + AnimationEntry* entry = AnimationContext_AddEntry(&play->animationCtx, ANIMENTRY_MOVEACTOR); if (entry != NULL) { entry->data.move.actor = actor; @@ -1086,7 +1080,7 @@ void AnimationContext_SetMoveActor(GlobalContext* globalCtx, Actor* actor, SkelA /** * Receives the request for Link's animation frame data */ -void AnimationContext_LoadFrame(GlobalContext* globalCtx, AnimationEntryData* data) { +void AnimationContext_LoadFrame(PlayState* play, AnimationEntryData* data) { AnimEntryLoadFrame* entry = &data->load; osRecvMesg(&entry->msgQueue, NULL, OS_MESG_BLOCK); @@ -1095,7 +1089,7 @@ void AnimationContext_LoadFrame(GlobalContext* globalCtx, AnimationEntryData* da /** * If the entry's queue is enabled, copies all vectors from src frame table to dst frame table */ -void AnimationContext_CopyAll(GlobalContext* globalCtx, AnimationEntryData* data) { +void AnimationContext_CopyAll(PlayState* play, AnimationEntryData* data) { AnimEntryCopyAll* entry = &data->copy; if (!(entry->queueFlag & sDisableAnimQueueFlags)) { @@ -1112,7 +1106,7 @@ void AnimationContext_CopyAll(GlobalContext* globalCtx, AnimationEntryData* data /** * If the entry's queue is enabled, interpolates between the base and mod frame tables, placing the result in base */ -void AnimationContext_Interp(GlobalContext* globalCtx, AnimationEntryData* data) { +void AnimationContext_Interp(PlayState* play, AnimationEntryData* data) { AnimEntryInterp* entry = &data->interp; if (!(entry->queueFlag & sDisableAnimQueueFlags)) { @@ -1123,7 +1117,7 @@ void AnimationContext_Interp(GlobalContext* globalCtx, AnimationEntryData* data) /** * If the entry's queue is enabled, copies all vectors from src frame table to dst frame table whose copy flag is true */ -void AnimationContext_CopyTrue(GlobalContext* globalCtx, AnimationEntryData* data) { +void AnimationContext_CopyTrue(PlayState* play, AnimationEntryData* data) { AnimEntryCopyTrue* entry = &data->copy1; if (!(entry->queueFlag & sDisableAnimQueueFlags)) { @@ -1143,7 +1137,7 @@ void AnimationContext_CopyTrue(GlobalContext* globalCtx, AnimationEntryData* dat /** * If the entry's queue is enabled, copies all vectors from src frame table to dst frame table whose copy flag is false */ -void AnimationContext_CopyFalse(GlobalContext* globalCtx, AnimationEntryData* data) { +void AnimationContext_CopyFalse(PlayState* play, AnimationEntryData* data) { AnimEntryCopyFalse* entry = &data->copy0; if (!(entry->queueFlag & sDisableAnimQueueFlags)) { @@ -1163,7 +1157,7 @@ void AnimationContext_CopyFalse(GlobalContext* globalCtx, AnimationEntryData* da /** * Moves an actor according to the translation of its root limb */ -void AnimationContext_MoveActor(GlobalContext* globalCtx, AnimationEntryData* data) { +void AnimationContext_MoveActor(PlayState* play, AnimationEntryData* data) { AnimEntryMoveActor* entry = &data->move; Actor* actor = entry->actor; Vec3f diff; @@ -1177,11 +1171,11 @@ void AnimationContext_MoveActor(GlobalContext* globalCtx, AnimationEntryData* da /** * Performs all requests in the animation queue, then resets the queue flags. */ -void AnimationContext_Update(GlobalContext* globalCtx, AnimationContext* animationCtx) { +void AnimationContext_Update(PlayState* play, AnimationContext* animationCtx) { AnimationEntry* entry = animationCtx->entries; for (; animationCtx->animationCount != 0; entry++, animationCtx->animationCount--) { - sAnimationLoadDone[entry->type](globalCtx, &entry->data); + sAnimationLoadDone[entry->type](play, &entry->data); } sAnimQueueFlags = 1; @@ -1192,7 +1186,7 @@ void AnimationContext_Update(GlobalContext* globalCtx, AnimationContext* animati * Initializes a skeleton to be used with Link animations to a looping animation, dynamically allocating the frame * tables if not given. */ -void SkelAnime_InitLink(GlobalContext* globalCtx, SkelAnime* skelAnime, FlexSkeletonHeader* skeletonHeaderSeg, +void SkelAnime_InitLink(PlayState* play, SkelAnime* skelAnime, FlexSkeletonHeader* skeletonHeaderSeg, LinkAnimationHeader* animation, s32 flags, Vec3s* jointTable, Vec3s* morphTable, s32 limbBufCount) { FlexSkeletonHeader* skeletonHeader; @@ -1230,7 +1224,7 @@ void SkelAnime_InitLink(GlobalContext* globalCtx, SkelAnime* skelAnime, FlexSkel skelAnime->morphTable = (Vec3s*)ALIGN16((u32)morphTable); } - LinkAnimation_Change(globalCtx, skelAnime, animation, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, 0.0f); + LinkAnimation_Change(play, skelAnime, animation, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, 0.0f); } /** @@ -1238,9 +1232,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; } @@ -1249,24 +1243,24 @@ void LinkAnimation_SetUpdateFunction(SkelAnime* skelAnime) { * Advances the current Link animation and updates all frame tables. If the animation plays once, returns true when it * finishes. */ -s32 LinkAnimation_Update(GlobalContext* globalCtx, SkelAnime* skelAnime) { - return skelAnime->update(globalCtx, skelAnime); +s32 LinkAnimation_Update(PlayState* play, SkelAnime* skelAnime) { + return skelAnime->update.link(play, skelAnime); } /** * Requests an interpolation between the pose in jointTable to the one in morphTable, advancing the morph but not the * animation frame */ -s32 LinkAnimation_Morph(GlobalContext* globalCtx, SkelAnime* skelAnime) { +s32 LinkAnimation_Morph(PlayState* play, SkelAnime* skelAnime) { f32 prevMorphWeight = skelAnime->morphWeight; - f32 updateRate = (s32)globalCtx->state.framerateDivisor * 0.5f; + f32 updateRate = (s32)play->state.framerateDivisor * 0.5f; skelAnime->morphWeight -= skelAnime->morphRate * updateRate; if (skelAnime->morphWeight <= 0.0f) { LinkAnimation_SetUpdateFunction(skelAnime); } - AnimationContext_SetInterp(globalCtx, skelAnime->limbCount, skelAnime->jointTable, skelAnime->morphTable, + AnimationContext_SetInterp(play, skelAnime->limbCount, skelAnime->jointTable, skelAnime->morphTable, 1.0f - (skelAnime->morphWeight / prevMorphWeight)); return 0; } @@ -1275,16 +1269,16 @@ s32 LinkAnimation_Morph(GlobalContext* globalCtx, SkelAnime* skelAnime) { * Requests a load of the next frame of a Link animation, advances the morph, and requests an interpolation between * jointTable and morphTable */ -void LinkAnimation_AnimateFrame(GlobalContext* globalCtx, SkelAnime* skelAnime) { - AnimationContext_SetLoadFrame(globalCtx, skelAnime->animation, skelAnime->curFrame, skelAnime->limbCount, +void LinkAnimation_AnimateFrame(PlayState* play, SkelAnime* skelAnime) { + AnimationContext_SetLoadFrame(play, skelAnime->animation, skelAnime->curFrame, skelAnime->limbCount, skelAnime->jointTable); if (skelAnime->morphWeight != 0) { - f32 updateRate = (s32)globalCtx->state.framerateDivisor * 0.5f; + f32 updateRate = (s32)play->state.framerateDivisor * 0.5f; skelAnime->morphWeight -= skelAnime->morphRate * updateRate; if (skelAnime->morphWeight <= 0.0f) { skelAnime->morphWeight = 0.0f; } else { - AnimationContext_SetInterp(globalCtx, skelAnime->limbCount, skelAnime->jointTable, skelAnime->morphTable, + AnimationContext_SetInterp(play, skelAnime->limbCount, skelAnime->jointTable, skelAnime->morphTable, skelAnime->morphWeight); } } @@ -1293,8 +1287,8 @@ void LinkAnimation_AnimateFrame(GlobalContext* globalCtx, SkelAnime* skelAnime) /** * Advances a Link animation that loops over its full length */ -s32 LinkAnimation_Loop(GlobalContext* globalCtx, SkelAnime* skelAnime) { - f32 updateRate = (s32)globalCtx->state.framerateDivisor * 0.5f; +s32 LinkAnimation_Loop(PlayState* play, SkelAnime* skelAnime) { + f32 updateRate = (s32)play->state.framerateDivisor * 0.5f; skelAnime->curFrame += skelAnime->playSpeed * updateRate; if (skelAnime->curFrame < 0.0f) { @@ -1302,18 +1296,18 @@ s32 LinkAnimation_Loop(GlobalContext* globalCtx, SkelAnime* skelAnime) { } else if (skelAnime->animLength <= skelAnime->curFrame) { skelAnime->curFrame -= skelAnime->animLength; } - LinkAnimation_AnimateFrame(globalCtx, skelAnime); + LinkAnimation_AnimateFrame(play, skelAnime); return 0; } /** * Advances a Link animation that stops at endFrame and returns true when it is reached. */ -s32 LinkAnimation_Once(GlobalContext* globalCtx, SkelAnime* skelAnime) { - f32 updateRate = (s32)globalCtx->state.framerateDivisor * 0.5f; +s32 LinkAnimation_Once(PlayState* play, SkelAnime* skelAnime) { + f32 updateRate = (s32)play->state.framerateDivisor * 0.5f; if (skelAnime->curFrame == skelAnime->endFrame) { - LinkAnimation_AnimateFrame(globalCtx, skelAnime); + LinkAnimation_AnimateFrame(play, skelAnime); return 1; } @@ -1328,14 +1322,14 @@ s32 LinkAnimation_Once(GlobalContext* globalCtx, SkelAnime* skelAnime) { skelAnime->curFrame -= skelAnime->animLength; } } - LinkAnimation_AnimateFrame(globalCtx, skelAnime); + LinkAnimation_AnimateFrame(play, skelAnime); return 0; } /** * Sets a new morph and resets the morph weight for the current animation. */ -void Animation_SetMorph(GlobalContext* globalCtx, SkelAnime* skelAnime, f32 morphFrames) { +void Animation_SetMorph(PlayState* play, SkelAnime* skelAnime, f32 morphFrames) { skelAnime->morphWeight = 1.0f; skelAnime->morphRate = 1.0f / morphFrames; } @@ -1346,7 +1340,7 @@ void Animation_SetMorph(GlobalContext* globalCtx, SkelAnime* skelAnime, f32 morp * animation, then start the new animation. Negative morph frames start the new animation immediately, modified by the * pose immediately before the animation change. */ -void LinkAnimation_Change(GlobalContext* globalCtx, SkelAnime* skelAnime, LinkAnimationHeader* animation, f32 playSpeed, +void LinkAnimation_Change(PlayState* play, SkelAnime* skelAnime, LinkAnimationHeader* animation, f32 playSpeed, f32 startFrame, f32 endFrame, u8 mode, f32 morphFrames) { skelAnime->mode = mode; if ((morphFrames != 0.0f) && ((animation != skelAnime->animation) || (startFrame != skelAnime->curFrame))) { @@ -1355,16 +1349,15 @@ void LinkAnimation_Change(GlobalContext* globalCtx, SkelAnime* skelAnime, LinkAn SkelAnime_CopyFrameTable(skelAnime, skelAnime->morphTable, skelAnime->jointTable); morphFrames = -morphFrames; } else { - skelAnime->update = LinkAnimation_Morph; - AnimationContext_SetLoadFrame(globalCtx, animation, (s32)startFrame, skelAnime->limbCount, + skelAnime->update.link = LinkAnimation_Morph; + AnimationContext_SetLoadFrame(play, animation, (s32)startFrame, skelAnime->limbCount, skelAnime->morphTable); } skelAnime->morphWeight = 1.0f; skelAnime->morphRate = 1.0f / morphFrames; } else { LinkAnimation_SetUpdateFunction(skelAnime); - AnimationContext_SetLoadFrame(globalCtx, animation, (s32)startFrame, skelAnime->limbCount, - skelAnime->jointTable); + AnimationContext_SetLoadFrame(play, animation, (s32)startFrame, skelAnime->limbCount, skelAnime->jointTable); skelAnime->morphWeight = 0.0f; } @@ -1380,104 +1373,100 @@ void LinkAnimation_Change(GlobalContext* globalCtx, SkelAnime* skelAnime, LinkAn /** * Immediately changes to a Link animation that plays once at the default speed. */ -void LinkAnimation_PlayOnce(GlobalContext* globalCtx, SkelAnime* skelAnime, LinkAnimationHeader* animation) { - LinkAnimation_Change(globalCtx, skelAnime, animation, 1.0f, 0.0f, Animation_GetLastFrame(&animation->common), +void LinkAnimation_PlayOnce(PlayState* play, SkelAnime* skelAnime, LinkAnimationHeader* animation) { + LinkAnimation_Change(play, skelAnime, animation, 1.0f, 0.0f, Animation_GetLastFrame(&animation->common), ANIMMODE_ONCE, 0.0f); } /** * Immediately changes to a Link animation that plays once at the specified speed. */ -void LinkAnimation_PlayOnceSetSpeed(GlobalContext* globalCtx, SkelAnime* skelAnime, LinkAnimationHeader* animation, +void LinkAnimation_PlayOnceSetSpeed(PlayState* play, SkelAnime* skelAnime, LinkAnimationHeader* animation, f32 playSpeed) { - LinkAnimation_Change(globalCtx, skelAnime, animation, playSpeed, 0.0f, Animation_GetLastFrame(&animation->common), + LinkAnimation_Change(play, skelAnime, animation, playSpeed, 0.0f, Animation_GetLastFrame(&animation->common), ANIMMODE_ONCE, 0.0f); } /** * Immediately changes to a Link animation that loops at the default speed. */ -void LinkAnimation_PlayLoop(GlobalContext* globalCtx, SkelAnime* skelAnime, LinkAnimationHeader* animation) { - LinkAnimation_Change(globalCtx, skelAnime, animation, 1.0f, 0.0f, Animation_GetLastFrame(&animation->common), +void LinkAnimation_PlayLoop(PlayState* play, SkelAnime* skelAnime, LinkAnimationHeader* animation) { + LinkAnimation_Change(play, skelAnime, animation, 1.0f, 0.0f, Animation_GetLastFrame(&animation->common), ANIMMODE_LOOP, 0.0f); } /** * Immediately changes to a Link animation that loops at the specified speed. */ -void LinkAnimation_PlayLoopSetSpeed(GlobalContext* globalCtx, SkelAnime* skelAnime, LinkAnimationHeader* animation, +void LinkAnimation_PlayLoopSetSpeed(PlayState* play, SkelAnime* skelAnime, LinkAnimationHeader* animation, f32 playSpeed) { - LinkAnimation_Change(globalCtx, skelAnime, animation, playSpeed, 0.0f, Animation_GetLastFrame(&animation->common), + LinkAnimation_Change(play, skelAnime, animation, playSpeed, 0.0f, Animation_GetLastFrame(&animation->common), ANIMMODE_LOOP, 0.0f); } /** * Requests copying jointTable to morphTable */ -void LinkAnimation_CopyJointToMorph(GlobalContext* globalCtx, SkelAnime* skelAnime) { - AnimationContext_SetCopyAll(globalCtx, skelAnime->limbCount, skelAnime->morphTable, skelAnime->jointTable); +void LinkAnimation_CopyJointToMorph(PlayState* play, SkelAnime* skelAnime) { + AnimationContext_SetCopyAll(play, skelAnime->limbCount, skelAnime->morphTable, skelAnime->jointTable); } /** * Requests copying morphTable to jointTable */ -void LinkAnimation_CopyMorphToJoint(GlobalContext* globalCtx, SkelAnime* skelAnime) { - AnimationContext_SetCopyAll(globalCtx, skelAnime->limbCount, skelAnime->jointTable, skelAnime->morphTable); +void LinkAnimation_CopyMorphToJoint(PlayState* play, SkelAnime* skelAnime) { + AnimationContext_SetCopyAll(play, skelAnime->limbCount, skelAnime->jointTable, skelAnime->morphTable); } /** * Requests loading frame data from the Link animation into morphTable */ -void LinkAnimation_LoadToMorph(GlobalContext* globalCtx, SkelAnime* skelAnime, LinkAnimationHeader* animation, - f32 frame) { - AnimationContext_SetLoadFrame(globalCtx, animation, (s32)frame, skelAnime->limbCount, skelAnime->morphTable); +void LinkAnimation_LoadToMorph(PlayState* play, SkelAnime* skelAnime, LinkAnimationHeader* animation, f32 frame) { + AnimationContext_SetLoadFrame(play, animation, (s32)frame, skelAnime->limbCount, skelAnime->morphTable); } /** * Requests loading frame data from the Link animation into jointTable */ -void LinkAnimation_LoadToJoint(GlobalContext* globalCtx, SkelAnime* skelAnime, LinkAnimationHeader* animation, - f32 frame) { - AnimationContext_SetLoadFrame(globalCtx, animation, (s32)frame, skelAnime->limbCount, skelAnime->jointTable); +void LinkAnimation_LoadToJoint(PlayState* play, SkelAnime* skelAnime, LinkAnimationHeader* animation, f32 frame) { + AnimationContext_SetLoadFrame(play, animation, (s32)frame, skelAnime->limbCount, skelAnime->jointTable); } /** * Requests interpolating between jointTable and morphTable, placing the result in jointTable */ -void LinkAnimation_InterpJointMorph(GlobalContext* globalCtx, SkelAnime* skelAnime, f32 weight) { - AnimationContext_SetInterp(globalCtx, skelAnime->limbCount, skelAnime->jointTable, skelAnime->morphTable, weight); +void LinkAnimation_InterpJointMorph(PlayState* play, SkelAnime* skelAnime, f32 weight) { + AnimationContext_SetInterp(play, skelAnime->limbCount, skelAnime->jointTable, skelAnime->morphTable, weight); } /** * Requests loading frame data from the Link animations and blending them, placing the result in jointTable */ -void LinkAnimation_BlendToJoint(GlobalContext* globalCtx, SkelAnime* skelAnime, LinkAnimationHeader* animation1, - f32 frame1, LinkAnimationHeader* animation2, f32 frame2, f32 blendWeight, - Vec3s* blendTable) { +void LinkAnimation_BlendToJoint(PlayState* play, SkelAnime* skelAnime, LinkAnimationHeader* animation1, f32 frame1, + LinkAnimationHeader* animation2, f32 frame2, f32 blendWeight, Vec3s* blendTable) { Vec3s* alignedBlendTable; - AnimationContext_SetLoadFrame(globalCtx, animation1, (s32)frame1, skelAnime->limbCount, skelAnime->jointTable); + AnimationContext_SetLoadFrame(play, animation1, (s32)frame1, skelAnime->limbCount, skelAnime->jointTable); alignedBlendTable = (Vec3s*)ALIGN16((u32)blendTable); - AnimationContext_SetLoadFrame(globalCtx, animation2, (s32)frame2, skelAnime->limbCount, alignedBlendTable); - AnimationContext_SetInterp(globalCtx, skelAnime->limbCount, skelAnime->jointTable, alignedBlendTable, blendWeight); + AnimationContext_SetLoadFrame(play, animation2, (s32)frame2, skelAnime->limbCount, alignedBlendTable); + AnimationContext_SetInterp(play, skelAnime->limbCount, skelAnime->jointTable, alignedBlendTable, blendWeight); } /** * Requests loading frame data from the Link animations and blending them, placing the result in morphTable */ -void LinkAnimation_BlendToMorph(GlobalContext* globalCtx, SkelAnime* skelAnime, LinkAnimationHeader* animation1, - f32 frame1, LinkAnimationHeader* animation2, f32 frame2, f32 blendWeight, - Vec3s* blendTable) { +void LinkAnimation_BlendToMorph(PlayState* play, SkelAnime* skelAnime, LinkAnimationHeader* animation1, f32 frame1, + LinkAnimationHeader* animation2, f32 frame2, f32 blendWeight, Vec3s* blendTable) { Vec3s* alignedBlendTable; - AnimationContext_SetLoadFrame(globalCtx, animation1, (s32)frame1, skelAnime->limbCount, skelAnime->morphTable); + AnimationContext_SetLoadFrame(play, animation1, (s32)frame1, skelAnime->limbCount, skelAnime->morphTable); alignedBlendTable = (Vec3s*)ALIGN16((u32)blendTable); - AnimationContext_SetLoadFrame(globalCtx, animation2, (s32)frame2, skelAnime->limbCount, alignedBlendTable); - AnimationContext_SetInterp(globalCtx, skelAnime->limbCount, skelAnime->morphTable, alignedBlendTable, blendWeight); + AnimationContext_SetLoadFrame(play, animation2, (s32)frame2, skelAnime->limbCount, alignedBlendTable); + AnimationContext_SetInterp(play, skelAnime->limbCount, skelAnime->morphTable, alignedBlendTable, blendWeight); } /** @@ -1527,7 +1516,7 @@ s32 LinkAnimation_OnFrame(SkelAnime* skelAnime, f32 frame) { /** * Initializes a normal skeleton to a looping animation, dynamically allocating the frame tables if not provided. */ -void SkelAnime_Init(GlobalContext* globalCtx, SkelAnime* skelAnime, SkeletonHeader* skeletonHeaderSeg, +void SkelAnime_Init(PlayState* play, SkelAnime* skelAnime, SkeletonHeader* skeletonHeaderSeg, AnimationHeader* animation, Vec3s* jointTable, Vec3s* morphTable, s32 limbCount) { SkeletonHeader* skeletonHeader; @@ -1550,7 +1539,7 @@ void SkelAnime_Init(GlobalContext* globalCtx, SkelAnime* skelAnime, SkeletonHead /** * Initializes a flex skeleton to a looping animation, dynamically allocating the frame tables if not given. */ -void SkelAnime_InitFlex(GlobalContext* globalCtx, SkelAnime* skelAnime, FlexSkeletonHeader* skeletonHeaderSeg, +void SkelAnime_InitFlex(PlayState* play, SkelAnime* skelAnime, FlexSkeletonHeader* skeletonHeaderSeg, AnimationHeader* animation, Vec3s* jointTable, Vec3s* morphTable, s32 limbCount) { FlexSkeletonHeader* skeletonHeader; @@ -1599,11 +1588,11 @@ void SkelAnime_InitSkin(GameState* gameState, SkelAnime* skelAnime, SkeletonHead */ 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; } } @@ -1612,7 +1601,7 @@ void SkelAnime_SetUpdate(SkelAnime* skelAnime) { * finishes. */ s32 SkelAnime_Update(SkelAnime* skelAnime) { - return skelAnime->update(skelAnime); + return skelAnime->update.normal(skelAnime); } /** @@ -1774,10 +1763,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); } @@ -1965,7 +1954,7 @@ s32 Animation_OnFrame(SkelAnime* skelAnime, f32 frame) { /** * Frees the frame tables for a skelAnime with dynamically allocated tables. */ -void SkelAnime_Free(SkelAnime* skelAnime, GlobalContext* globalCtx) { +void SkelAnime_Free(SkelAnime* skelAnime, PlayState* play) { if (skelAnime->jointTable != NULL) { ZeldaArena_Free(skelAnime->jointTable); } diff --git a/src/code/z_skin.c b/src/code/z_skin.c index 808a00da0..0d3e0bf85 100644 --- a/src/code/z_skin.c +++ b/src/code/z_skin.c @@ -13,13 +13,13 @@ void Skin_UpdateVertices(MtxF* mtx, SkinVertex* skinVertices, SkinLimbModif* mod Vec3f normal; Vec3f sp44; - wTemp.x = mtx->wx; - wTemp.y = mtx->wy; - wTemp.z = mtx->wz; + wTemp.x = mtx->xw; + wTemp.y = mtx->yw; + wTemp.z = mtx->zw; - mtx->wx = 0.0f; - mtx->wy = 0.0f; - mtx->wz = 0.0f; + mtx->xw = 0.0f; + mtx->yw = 0.0f; + mtx->zw = 0.0f; for (vertexEntry = skinVertices; vertexEntry < &skinVertices[modifEntry->vtxCount]; vertexEntry++) { vtx = &vtxBuf[vertexEntry->index]; @@ -39,9 +39,9 @@ void Skin_UpdateVertices(MtxF* mtx, SkinVertex* skinVertices, SkinLimbModif* mod vtx->n.n[2] = normal.z; } - mtx->wx = wTemp.x; - mtx->wy = wTemp.y; - mtx->wz = wTemp.z; + mtx->xw = wTemp.x; + mtx->yw = wTemp.y; + mtx->zw = wTemp.z; } void Skin_ApplyLimbModifications(GraphicsContext* gfxCtx, Skin* skin, s32 limbIndex, s32 arg3) { @@ -182,11 +182,11 @@ void Skin_DrawLimb(GraphicsContext* gfxCtx, Skin* skin, s32 limbIndex, Gfx* dLis CLOSE_DISPS(gfxCtx); } -void Skin_DrawImpl(Actor* actor, GlobalContext* globalCtx, Skin* skin, SkinPostDraw postDraw, +void Skin_DrawImpl(Actor* actor, PlayState* play, Skin* skin, SkinPostDraw postDraw, SkinOverrideLimbDraw overrideLimbDraw, s32 setTranslation, s32 arg6, s32 drawFlags) { s32 i; SkinLimb** skeleton; - GraphicsContext* gfxCtx = globalCtx->state.gfxCtx; + GraphicsContext* gfxCtx = play->state.gfxCtx; OPEN_DISPS(gfxCtx); @@ -212,7 +212,7 @@ void Skin_DrawImpl(Actor* actor, GlobalContext* globalCtx, Skin* skin, SkinPostD s32 segmentType; if (overrideLimbDraw != NULL) { - shouldDraw = overrideLimbDraw(actor, globalCtx, i, skin); + shouldDraw = overrideLimbDraw(actor, play, i, skin); } segmentType = ((SkinLimb*)Lib_SegmentedToVirtual(skeleton[i]))->segmentType; @@ -225,7 +225,7 @@ void Skin_DrawImpl(Actor* actor, GlobalContext* globalCtx, Skin* skin, SkinPostD } if (postDraw != NULL) { - postDraw(actor, globalCtx, skin); + postDraw(actor, play, skin); } close_disps:; @@ -233,26 +233,26 @@ close_disps:; } // 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); +void func_80138228(Actor* actor, PlayState* play, Skin* skin, SkinPostDraw postDraw, s32 setTranslation) { + Skin_DrawImpl(actor, play, skin, postDraw, NULL, setTranslation, false, 0); } // allows specifying OverrideLimbDraw, postDraw and setTranslation -void func_80138258(Actor* actor, GlobalContext* globalCtx, Skin* skin, SkinPostDraw postDraw, +void func_80138258(Actor* actor, PlayState* play, Skin* skin, SkinPostDraw postDraw, SkinOverrideLimbDraw overrideLimbDraw, s32 setTranslation) { - Skin_DrawImpl(actor, globalCtx, skin, postDraw, overrideLimbDraw, setTranslation, false, 0); + Skin_DrawImpl(actor, play, skin, postDraw, overrideLimbDraw, setTranslation, false, 0); } // allows specifying OverrideLimbDraw, postDraw, setTranslation, and arg6 -void func_8013828C(Actor* actor, GlobalContext* globalCtx, Skin* skin, SkinPostDraw postDraw, +void func_8013828C(Actor* actor, PlayState* play, Skin* skin, SkinPostDraw postDraw, SkinOverrideLimbDraw overrideLimbDraw, s32 setTranslation, s32 arg6) { - Skin_DrawImpl(actor, globalCtx, skin, postDraw, overrideLimbDraw, setTranslation, arg6, 0); + Skin_DrawImpl(actor, play, skin, postDraw, overrideLimbDraw, setTranslation, arg6, 0); } // allows specifying all variables -void func_801382C4(Actor* actor, GlobalContext* globalCtx, Skin* skin, SkinPostDraw postDraw, +void func_801382C4(Actor* actor, PlayState* play, Skin* skin, SkinPostDraw postDraw, SkinOverrideLimbDraw overrideLimbDraw, s32 setTranslation, s32 arg6, s32 drawFlags) { - Skin_DrawImpl(actor, globalCtx, skin, postDraw, overrideLimbDraw, setTranslation, arg6, drawFlags); + Skin_DrawImpl(actor, play, skin, postDraw, overrideLimbDraw, setTranslation, arg6, drawFlags); } void Skin_GetLimbPos(Skin* skin, s32 limbIndex, Vec3f* offset, Vec3f* dst) { diff --git a/src/code/z_skin_awb.c b/src/code/z_skin_awb.c index d45b9bc25..edbcef05f 100644 --- a/src/code/z_skin_awb.c +++ b/src/code/z_skin_awb.c @@ -105,7 +105,7 @@ void Skin_Free(GameState* gameState, Skin* skin) { ZeldaArena_Free(skin->vtxTable); } - SkelAnime_Free(&skin->skelAnime, (GlobalContext*)gameState); + SkelAnime_Free(&skin->skelAnime, (PlayState*)gameState); } } 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 f85f33f0a..7a234ca22 100644 --- a/src/code/z_snap.c +++ b/src/code/z_snap.c @@ -1,80 +1,96 @@ #include "global.h" +#include "z64snap.h" +#include "overlays/actors/ovl_En_Kakasi/z_en_kakasi.h" -typedef struct { - Actor actor; - s32 (*pictoFunc)(GlobalContext* globalCtx, Actor* actor); -} PictoActor; +#define PICTO_SEEN_IN_SCENE 1 +#define PICTO_SEEN_ANYWHERE 2 -s32 func_8013A240(GlobalContext* globalCtx) { +/** + * Test every loaded actor to see if it is a pictographable `PictoActor`, and if so, run its `validationFunc` to set + * appropriate flags. + * + * @return s32 Number of pictograph actors validly captured. + */ +s32 Snap_RecordPictographedActors(PlayState* play) { PictoActor* pictoActor; Actor* actor; - s32 type = 0; + s32 category = 0; s32 seen; - s32 count = 0; + s32 validCount = 0; gSaveContext.save.pictoFlags0 = 0; gSaveContext.save.pictoFlags1 = 0; - if (globalCtx->sceneNum == SCENE_20SICHITAI) { - func_8013A41C(1); + if (play->sceneNum == SCENE_20SICHITAI) { + Snap_SetFlag(PICTOGRAPH_IN_SWAMP); } - for (; type < 12; type++) { - for (actor = globalCtx->actorCtx.actorLists[type].first; actor != NULL; actor = actor->next) { + for (; category < ACTORCAT_MAX; category++) { + for (actor = play->actorCtx.actorLists[category].first; actor != NULL; actor = actor->next) { seen = 0; - switch (globalCtx->sceneNum) { + // Actors which must be pictographed in a specific scene + switch (play->sceneNum) { case SCENE_20SICHITAI: if ((actor->id == ACTOR_EN_MNK) || (actor->id == ACTOR_EN_BIGOKUTA)) { - seen = 1; + seen = PICTO_SEEN_IN_SCENE; } break; + default: seen = 0; + break; } if (actor->id) { ; // Needed to match } + // Actors which may be pictographed anywhere switch (actor->id) { case ACTOR_EN_KAKASI: - if ((actor->params & 1) == 1) { - seen |= 2; + if (KAKASI_GET_ABOVE_GROUND(actor) == 1) { + seen |= PICTO_SEEN_ANYWHERE; break; //! @bug break is inside conditional, meaning it falls through if it is false } + // FALLTHROUGH case ACTOR_EN_ZOV: - seen |= 2; + seen |= PICTO_SEEN_ANYWHERE; break; + case ACTOR_EN_BAL: - seen |= 2; + seen |= PICTO_SEEN_ANYWHERE; break; + case ACTOR_EN_DNQ: - seen |= 2; + seen |= PICTO_SEEN_ANYWHERE; break; + case ACTOR_EN_GE1: case ACTOR_EN_GE3: case ACTOR_EN_KAIZOKU: case ACTOR_EN_GE2: - seen |= 2; + seen |= PICTO_SEEN_ANYWHERE; break; } - if (seen != 0) { + // If actor is recordable, run its validity function and record if valid + if (seen) { pictoActor = (PictoActor*)actor; - if (pictoActor->pictoFunc != NULL) { - if ((pictoActor->pictoFunc)(globalCtx, actor) == 0) { - count++; + if (pictoActor->validationFunc != NULL) { + if ((pictoActor->validationFunc)(play, actor) == 0) { + validCount++; } } } } } - return count; + return validCount; } -void func_8013A41C(s32 flag) { +// Only used in this file +void Snap_SetFlag(s32 flag) { if (flag < 0x20) { gSaveContext.save.pictoFlags0 |= (1 << flag); } else { @@ -83,7 +99,8 @@ void func_8013A41C(s32 flag) { } } -void func_8013A46C(s32 flag) { +// Unused +void Snap_UnsetFlag(s32 flag) { if (flag < 0x20) { gSaveContext.save.pictoFlags0 &= ~(1 << flag); } else { @@ -92,7 +109,7 @@ void func_8013A46C(s32 flag) { } } -u32 func_8013A4C4(s32 flag) { +u32 Snap_CheckFlag(s32 flag) { SaveContext* saveCtx = &gSaveContext; if (flag < 0x20) { @@ -103,58 +120,83 @@ u32 func_8013A4C4(s32 flag) { } } -s16 func_8013A504(s16 val) { - return (val >= 0) ? val : -val; +s16 Snap_AbsS(s16 val) { + return ABS(val); } -s32 func_8013A530(GlobalContext* globalCtx, Actor* actor, s32 flag, Vec3f* pos, Vec3s* rot, f32 distanceMin, - f32 distanceMax, s16 angleError) { - Vec3f screenSpace; +/** + * Test if a pictograph is a valid pictograph of an actor + * + * @param play + * @param actor Actor to test + * @param flag Flag to set if checks successful + * @param pos position of point to test (generally a particular point in the actor's model) + * @param rot rotation of point to test (for facing camera) + * @param distanceMin closest point may be + * @param distanceMax farthest away point may be + * @param angleRange Size of range that counts as facing the camera (-1 is used for any allowed) + * @return s32 0 on success, `or`ed combination of the validity flag indices if not + * + * @note It is generally not possible to recover the actual failure mode(s) from the return value: oring `ret` with the + * actual flag rather than its index would rectify this. + */ +s32 Snap_ValidatePictograph(PlayState* play, Actor* actor, s32 flag, Vec3f* pos, Vec3s* rot, f32 distanceMin, + f32 distanceMax, s16 angleRange) { + Vec3f projectedPos; s16 x; s16 y; f32 distance; CollisionPoly* poly; - Camera* camera = GET_ACTIVE_CAM(globalCtx); + Camera* camera = GET_ACTIVE_CAM(play); Actor* actors[2]; s32 ret = 0; s32 bgId; + // Check distance distance = OLib_Vec3fDist(pos, &camera->eye); if ((distance < distanceMin) || (distanceMax < distance)) { - func_8013A41C(0x3F); - ret = 0x3F; + Snap_SetFlag(PICTOGRAPH_BAD_DISTANCE); + ret = PICTOGRAPH_BAD_DISTANCE; } - 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; + // Check rot is facing camera? + x = Snap_AbsS(Camera_GetCamDirPitch(camera) + rot->x); + y = Snap_AbsS(Camera_GetCamDirYaw(camera) - BINANG_SUB(rot->y, 0x7FFF)); + if ((0 < angleRange) && ((angleRange < x) || (angleRange < y))) { + Snap_SetFlag(PICTOGRAPH_BAD_ANGLE); + ret |= PICTOGRAPH_BAD_ANGLE; } - 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) || (150 < x) || (y < 0) || (105 < y)) { - func_8013A41C(0x3D); - ret |= 0x3D; + // Check in capture region + Actor_GetProjectedPos(play, pos, &projectedPos, &distance); + // Convert to projected position to device coordinates, shift to be relative to the capture region's top-left corner + x = (s16)PROJECTED_TO_SCREEN_X(projectedPos, distance) - PICTO_CAPTURE_REGION_TOPLEFT_X; + y = (s16)PROJECTED_TO_SCREEN_Y(projectedPos, distance) - PICTO_CAPTURE_REGION_TOPLEFT_Y; + + // checks if the coordinates are within the capture region + if ((x < 0) || (x > PICTO_RESOLUTION_HORIZONTAL) || (y < 0) || (y > PICTO_RESOLUTION_VERTICAL)) { + Snap_SetFlag(PICTOGRAPH_NOT_IN_VIEW); + ret |= PICTOGRAPH_NOT_IN_VIEW; } - if (BgCheck_ProjectileLineTest(&globalCtx->colCtx, pos, &camera->eye, &screenSpace, &poly, true, true, true, true, + // Check not obscured by bg collision + if (BgCheck_ProjectileLineTest(&play->colCtx, pos, &camera->eye, &projectedPos, &poly, true, true, true, true, &bgId)) { - func_8013A41C(0x3C); - ret |= 0x3C; + Snap_SetFlag(PICTOGRAPH_BEHIND_BG); + ret |= PICTOGRAPH_BEHIND_BG; } + // Check not obscured by actor collision actors[0] = actor; - actors[1] = &GET_PLAYER(globalCtx)->actor; - if (CollisionCheck_LineOCCheck(globalCtx, &globalCtx->colChkCtx, pos, &camera->eye, actors, 2)) { - func_8013A41C(0x3B); - ret |= 0x3B; + actors[1] = &GET_PLAYER(play)->actor; + if (CollisionCheck_LineOCCheck(play, &play->colChkCtx, pos, &camera->eye, actors, 2)) { + Snap_SetFlag(PICTOGRAPH_BEHIND_COLLISION); + ret |= PICTOGRAPH_BEHIND_COLLISION; } + // If all of the above checks pass, set the flag if (ret == 0) { - func_8013A41C(flag); + Snap_SetFlag(flag); } return ret; diff --git a/src/code/z_sound_source.c b/src/code/z_sound_source.c index ba7036a4c..15ebd018a 100644 --- a/src/code/z_sound_source.c +++ b/src/code/z_sound_source.c @@ -1,24 +1,24 @@ #include "global.h" -void SoundSource_InitAll(GlobalContext* globalCtx) { - SoundSource* sources = &globalCtx->soundSources[0]; +void SoundSource_InitAll(PlayState* play) { + SoundSource* sources = &play->soundSources[0]; s32 i; // clang-format off - for (i = 0; i < ARRAY_COUNT(globalCtx->soundSources); i++) { sources[i].countdown = 0; } + for (i = 0; i < ARRAY_COUNT(play->soundSources); i++) { sources[i].countdown = 0; } // clang-format on } -void SoundSource_UpdateAll(GlobalContext* globalCtx) { - SoundSource* source = &globalCtx->soundSources[0]; +void SoundSource_UpdateAll(PlayState* play) { + SoundSource* source = &play->soundSources[0]; s32 i; - for (i = 0; i < ARRAY_COUNT(globalCtx->soundSources); i++) { + for (i = 0; i < ARRAY_COUNT(play->soundSources); i++) { if (source->countdown != 0) { if (DECR(source->countdown) == 0) { - Audio_StopSfxByPos(&source->projectedPos); + AudioSfx_StopByPos(&source->projectedPos); } else { - SkinMatrix_Vec3fMtxFMultXYZ(&globalCtx->viewProjectionMtxF, &source->worldPos, &source->projectedPos); + SkinMatrix_Vec3fMtxFMultXYZ(&play->viewProjectionMtxF, &source->worldPos, &source->projectedPos); if (source->playSfxEachFrame) { Audio_PlaySfxAtPos(&source->projectedPos, source->sfxId); } @@ -29,15 +29,15 @@ void SoundSource_UpdateAll(GlobalContext* globalCtx) { } } -void SoundSource_Add(GlobalContext* globalCtx, Vec3f* worldPos, u32 duration, u16 sfxId, u32 playSfxEachFrame) { +void SoundSource_Add(PlayState* play, Vec3f* worldPos, u32 duration, u16 sfxId, u32 playSfxEachFrame) { s32 countdown; SoundSource* source; s32 smallestCountdown = 0xFFFF; SoundSource* backupSource = NULL; s32 i; - source = &globalCtx->soundSources[0]; - for (i = 0; i < ARRAY_COUNT(globalCtx->soundSources); i++) { + source = &play->soundSources[0]; + for (i = 0; i < ARRAY_COUNT(play->soundSources); i++) { if (source->countdown == 0) { break; } @@ -52,9 +52,9 @@ void SoundSource_Add(GlobalContext* globalCtx, Vec3f* worldPos, u32 duration, u1 } // If no sound source is available, replace the sound source with the smallest remaining countdown - if (i >= ARRAY_COUNT(globalCtx->soundSources)) { + if (i >= ARRAY_COUNT(play->soundSources)) { source = backupSource; - Audio_StopSfxByPos(&source->projectedPos); + AudioSfx_StopByPos(&source->projectedPos); } source->worldPos = *worldPos; @@ -62,14 +62,14 @@ void SoundSource_Add(GlobalContext* globalCtx, Vec3f* worldPos, u32 duration, u1 source->playSfxEachFrame = playSfxEachFrame; source->sfxId = sfxId; - SkinMatrix_Vec3fMtxFMultXYZ(&globalCtx->viewProjectionMtxF, &source->worldPos, &source->projectedPos); + SkinMatrix_Vec3fMtxFMultXYZ(&play->viewProjectionMtxF, &source->worldPos, &source->projectedPos); Audio_PlaySfxAtPos(&source->projectedPos, sfxId); } -void SoundSource_PlaySfxAtFixedWorldPos(GlobalContext* globalCtx, Vec3f* worldPos, u32 duration, u16 sfxId) { - SoundSource_Add(globalCtx, worldPos, duration, sfxId, false); +void SoundSource_PlaySfxAtFixedWorldPos(PlayState* play, Vec3f* worldPos, u32 duration, u16 sfxId) { + SoundSource_Add(play, worldPos, duration, sfxId, false); } -void SoundSource_PlaySfxEachFrameAtFixedWorldPos(GlobalContext* globalCtx, Vec3f* worldPos, u32 duration, u16 sfxId) { - SoundSource_Add(globalCtx, worldPos, duration, sfxId, true); +void SoundSource_PlaySfxEachFrameAtFixedWorldPos(PlayState* play, Vec3f* worldPos, u32 duration, u16 sfxId) { + SoundSource_Add(play, worldPos, duration, sfxId, true); } diff --git a/src/code/z_sram_NES.c b/src/code/z_sram_NES.c index 52acc9379..5f92d13e5 100644 --- a/src/code/z_sram_NES.c +++ b/src/code/z_sram_NES.c @@ -148,10 +148,31 @@ s32 D_801C6798[] = { 0x00000020, 0x00001470, 0x000028C0, 0x00003D10, 0x00005160, 0x000065B0, }; -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, +u8 gAmmoItems[] = { + ITEM_NONE, // SLOT_OCARINA + ITEM_BOW, // SLOT_BOW + ITEM_NONE, // SLOT_ARROW_FIRE + ITEM_NONE, // SLOT_ARROW_ICE + ITEM_NONE, // SLOT_ARROW_LIGHT + ITEM_NONE, // SLOT_TRADE_DEED + ITEM_BOMB, // SLOT_BOMB + ITEM_BOMBCHU, // SLOT_BOMBCHU + ITEM_STICK, // SLOT_STICK + ITEM_NUT, // SLOT_NUT + ITEM_MAGIC_BEANS, // SLOT_MAGIC_BEANS + ITEM_NONE, // SLOT_TRADE_KEY_MAMA + ITEM_POWDER_KEG, // SLOT_POWDER_KEG + ITEM_PICTO_BOX, // SLOT_PICTO_BOX + ITEM_NONE, // SLOT_LENS + ITEM_NONE, // SLOT_HOOKSHOT + ITEM_NONE, // SLOT_SWORD_GREAT_FAIRY + ITEM_NONE, // SLOT_TRADE_COUPLE + ITEM_NONE, // SLOT_BOTTLE_1 + ITEM_NONE, // SLOT_BOTTLE_2 + ITEM_NONE, // SLOT_BOTTLE_3 + ITEM_NONE, // SLOT_BOTTLE_4 + ITEM_NONE, // SLOT_BOTTLE_5 + ITEM_NONE, // SLOT_BOTTLE_6 }; s32 D_801C67C8[] = { 0, 0x40, 0x80, 0xC0, 0x100, 0x180, 0x200, 0x280 }; @@ -199,8 +220,8 @@ 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; + SET_TOWN_SHOOTING_GALLERY_HIGH_SCORE(39); + SET_SWAMP_SHOOTING_GALLERY_HIGH_SCORE(10); gSaveContext.save.dekuPlaygroundHighScores[0] = 7500; // 75 seconds gSaveContext.save.dekuPlaygroundHighScores[1] = 7500; // 75 seconds @@ -226,12 +247,12 @@ void Sram_ClearFlagsAtDawnOfTheFirstDay(void) { /** * Used by Song of Time (when clicking "Yes") and (indirectly) by the "Dawn of the New Day" cutscene */ -void Sram_SaveEndOfCycle(GlobalContext* globalCtx) { +void Sram_SaveEndOfCycle(PlayState* play) { s16 sceneNum; s32 j; s32 i; - u8 temp; - u8 temp2; + u8 slot; + u8 item; gSaveContext.save.daySpeed = 0; gSaveContext.save.daysElapsed = 0; @@ -243,14 +264,14 @@ void Sram_SaveEndOfCycle(GlobalContext* globalCtx) { gSaveContext.save.playerData.deaths = 999; } - sceneNum = Play_GetOriginalSceneNumber(globalCtx->sceneNum); - Play_SaveCycleSceneFlags(&globalCtx->state); + sceneNum = Play_GetOriginalSceneNumber(play->sceneNum); + Play_SaveCycleSceneFlags(&play->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; + play->actorCtx.flags.chest &= D_801C5FC0[sceneNum][2]; + play->actorCtx.flags.switches[0] &= D_801C5FC0[sceneNum][0]; + play->actorCtx.flags.switches[1] &= D_801C5FC0[sceneNum][1]; + play->actorCtx.flags.collectible[0] &= D_801C5FC0[sceneNum][3]; + play->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]; @@ -260,7 +281,7 @@ void Sram_SaveEndOfCycle(GlobalContext* globalCtx) { ((void)0, gSaveContext.cycleSceneFlags[i].collectible) & D_801C5FC0[i][3]; gSaveContext.cycleSceneFlags[i].clearedRoom = 0; gSaveContext.save.permanentSceneFlags[i].unk_14 = 0; - gSaveContext.save.permanentSceneFlags[i].unk_18 = 0; + gSaveContext.save.permanentSceneFlags[i].rooms = 0; } for (; i < ARRAY_COUNT(gSaveContext.cycleSceneFlags); i++) { @@ -276,7 +297,7 @@ void Sram_SaveEndOfCycle(GlobalContext* globalCtx) { } if (gSaveContext.save.weekEventReg[84] & 0x20) { - func_801149A0(ITEM_MASK_FIERCE_DEITY, SLOT(ITEM_MASK_FIERCE_DEITY)); + Inventory_DeleteItem(ITEM_MASK_FIERCE_DEITY, SLOT(ITEM_MASK_FIERCE_DEITY)); } for (i = 0; i < ARRAY_COUNT(D_801C66D0); i++) { @@ -306,35 +327,35 @@ void Sram_SaveEndOfCycle(GlobalContext* globalCtx) { } if (INV_CONTENT(ITEM_BOMB) == ITEM_BOMB) { - temp2 = INV_CONTENT(ITEM_BOMB); - if (AMMO(temp2) != 0) { + item = INV_CONTENT(ITEM_BOMB); + if (AMMO(item) != 0) { gSaveContext.eventInf[7] |= 2; } } if (INV_CONTENT(ITEM_NUT) == ITEM_NUT) { - temp2 = INV_CONTENT(ITEM_NUT); - if (AMMO(temp2) != 0) { + item = INV_CONTENT(ITEM_NUT); + if (AMMO(item) != 0) { gSaveContext.eventInf[7] |= 4; } } if (INV_CONTENT(ITEM_STICK) == ITEM_STICK) { - temp2 = INV_CONTENT(ITEM_STICK); - if (AMMO(temp2) != 0) { + item = INV_CONTENT(ITEM_STICK); + if (AMMO(item) != 0) { gSaveContext.eventInf[7] |= 8; } } if (INV_CONTENT(ITEM_BOW) == ITEM_BOW) { - temp2 = INV_CONTENT(ITEM_BOW); - if (AMMO(temp2) != 0) { + item = INV_CONTENT(ITEM_BOW); + if (AMMO(item) != 0) { gSaveContext.eventInf[7] |= 0x10; } } - for (i = 0; i < ARRAY_COUNT(D_801C67B0); i++) { - if (D_801C67B0[i] != ITEM_NONE) { + for (i = 0; i < ARRAY_COUNT(gAmmoItems); i++) { + if (gAmmoItems[i] != ITEM_NONE) { if ((gSaveContext.save.inventory.items[i] != ITEM_NONE) && (i != SLOT_PICTO_BOX)) { - temp2 = gSaveContext.save.inventory.items[i]; - AMMO(temp2) = 0; + item = gSaveContext.save.inventory.items[i]; + AMMO(item) = 0; } } } @@ -343,10 +364,10 @@ void Sram_SaveEndOfCycle(GlobalContext* globalCtx) { // Check for all bottled items if (gSaveContext.save.inventory.items[i] >= ITEM_POTION_RED) { if (gSaveContext.save.inventory.items[i] <= ITEM_OBABA_DRINK) { - for (j = 1; j < 4; j++) { + for (j = EQUIP_SLOT_C_LEFT; j <= EQUIP_SLOT_C_RIGHT; j++) { if (GET_CUR_FORM_BTN_ITEM(j) == gSaveContext.save.inventory.items[i]) { SET_CUR_FORM_BTN_ITEM(j, ITEM_BOTTLE); - func_80112B40(globalCtx, j); + Interface_LoadItemIconImpl(play, j); } } gSaveContext.save.inventory.items[i] = ITEM_BOTTLE; @@ -354,26 +375,26 @@ void Sram_SaveEndOfCycle(GlobalContext* globalCtx) { } } - REMOVE_QUEST_ITEM(QUEST_UNK_19); + REMOVE_QUEST_ITEM(QUEST_PICTOGRAPH); if (gSaveContext.save.playerData.health < 0x30) { gSaveContext.save.playerData.health = 0x30; } - if (GET_CUR_EQUIP_VALUE(EQUIP_SWORD) < 3) { - SET_EQUIP_VALUE(EQUIP_SWORD, 1); + if (GET_CUR_EQUIP_VALUE(EQUIP_TYPE_SWORD) <= EQUIP_VALUE_SWORD_RAZOR) { + SET_EQUIP_VALUE(EQUIP_TYPE_SWORD, EQUIP_VALUE_SWORD_KOKIRI); if (CUR_FORM == 0) { if ((STOLEN_ITEM_1 >= ITEM_SWORD_GILDED) || (STOLEN_ITEM_2 >= ITEM_SWORD_GILDED)) { BUTTON_ITEM_EQUIP(CUR_FORM, EQUIP_SLOT_B) = ITEM_SWORD_GILDED; - SET_EQUIP_VALUE(EQUIP_SWORD, 3); + SET_EQUIP_VALUE(EQUIP_TYPE_SWORD, EQUIP_VALUE_SWORD_GILDED); } else { BUTTON_ITEM_EQUIP(CUR_FORM, EQUIP_SLOT_B) = ITEM_SWORD_KOKIRI; } } else { if ((STOLEN_ITEM_1 >= ITEM_SWORD_GILDED) || (STOLEN_ITEM_2 >= ITEM_SWORD_GILDED)) { BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_B) = ITEM_SWORD_GILDED; - SET_EQUIP_VALUE(EQUIP_SWORD, 3); + SET_EQUIP_VALUE(EQUIP_TYPE_SWORD, EQUIP_VALUE_SWORD_GILDED); } else { BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_B) = ITEM_SWORD_KOKIRI; } @@ -385,20 +406,20 @@ void Sram_SaveEndOfCycle(GlobalContext* globalCtx) { } if (STOLEN_ITEM_1 == ITEM_BOTTLE) { - temp = SLOT(ITEM_BOTTLE); - for (i = 0; i < 6; i++) { - if (gSaveContext.save.inventory.items[temp + i] == ITEM_NONE) { - gSaveContext.save.inventory.items[temp + i] = ITEM_BOTTLE; + slot = SLOT(ITEM_BOTTLE); + for (i = BOTTLE_FIRST; i < BOTTLE_MAX; i++) { + if (gSaveContext.save.inventory.items[slot + i] == ITEM_NONE) { + gSaveContext.save.inventory.items[slot + i] = ITEM_BOTTLE; break; } } } if (STOLEN_ITEM_2 == ITEM_BOTTLE) { - temp = SLOT(ITEM_BOTTLE); - for (i = 0; i < 6; i++) { - if (gSaveContext.save.inventory.items[temp + i] == ITEM_NONE) { - gSaveContext.save.inventory.items[temp + i] = ITEM_BOTTLE; + slot = SLOT(ITEM_BOTTLE); + for (i = BOTTLE_FIRST; i < BOTTLE_MAX; i++) { + if (gSaveContext.save.inventory.items[slot + i] == ITEM_NONE) { + gSaveContext.save.inventory.items[slot + i] = ITEM_BOTTLE; break; } } @@ -407,15 +428,14 @@ void Sram_SaveEndOfCycle(GlobalContext* globalCtx) { SET_STOLEN_ITEM_1(STOLEN_ITEM_NONE); SET_STOLEN_ITEM_2(STOLEN_ITEM_NONE); - // ?? - func_801149A0(ITEM_OCARINA_FAIRY, SLOT_TRADE_DEED); - func_801149A0(ITEM_SLINGSHOT, SLOT_TRADE_KEY_MAMA); - func_801149A0(ITEM_LONGSHOT, SLOT_TRADE_COUPLE); + Inventory_DeleteItem(ITEM_OCARINA_FAIRY, SLOT_TRADE_DEED); + Inventory_DeleteItem(ITEM_SLINGSHOT, SLOT_TRADE_KEY_MAMA); + Inventory_DeleteItem(ITEM_LONGSHOT, SLOT_TRADE_COUPLE); - for (j = 1; j < 4; j++) { - if (GET_CUR_FORM_BTN_ITEM(j) >= ITEM_MOON_TEAR && GET_CUR_FORM_BTN_ITEM(j) <= ITEM_PENDANT_MEMORIES) { + for (j = EQUIP_SLOT_C_LEFT; j <= EQUIP_SLOT_C_RIGHT; j++) { + if (GET_CUR_FORM_BTN_ITEM(j) >= ITEM_MOON_TEAR && GET_CUR_FORM_BTN_ITEM(j) <= ITEM_PENDANT_OF_MEMORIES) { SET_CUR_FORM_BTN_ITEM(j, ITEM_NONE); - func_80112B40(globalCtx, j); + Interface_LoadItemIconImpl(play, j); } } @@ -434,8 +454,8 @@ void Sram_SaveEndOfCycle(GlobalContext* globalCtx) { Sram_ClearHighscores(); for (i = 0; i < 8; i++) { - gSaveContext.save.inventory.dungeonItems[i] &= (u8)~1; - gSaveContext.save.inventory.dungeonKeys[i] = 0; + gSaveContext.save.inventory.dungeonItems[i] &= (u8)~1; // remove boss key + DUNGEON_KEY_COUNT(i) = 0; gSaveContext.save.inventory.strayFairies[i] = 0; } @@ -446,7 +466,7 @@ void Sram_SaveEndOfCycle(GlobalContext* globalCtx) { gSaveContext.jinxTimer = 0; gSaveContext.rupeeAccumulator = 0; - func_800F3B2C(globalCtx); + func_800F3B2C(play); } void Sram_IncrementDay(void) { @@ -481,7 +501,7 @@ u16 Sram_CalcChecksum(void* data, size_t count) { // Resets `Save` substruct void Sram_ResetSave(void) { - gSaveContext.save.entranceIndex = 0x1C00; + gSaveContext.save.entrance = ENTRANCE(CUTSCENE, 0); gSaveContext.save.equippedMask = 0; gSaveContext.save.isFirstCycle = false; gSaveContext.save.unk_06 = 0; @@ -596,7 +616,7 @@ ItemEquips sSaveDefaultItemEquips = { { ITEM_SWORD_KOKIRI, ITEM_NONE, ITEM_NONE, ITEM_NONE }, { ITEM_SWORD_KOKIRI, ITEM_NONE, ITEM_NONE, ITEM_NONE }, { ITEM_SWORD_KOKIRI, ITEM_NONE, ITEM_NONE, ITEM_NONE }, - { ITEM_UNK_FD, ITEM_NONE, ITEM_NONE, ITEM_NONE }, + { ITEM_FD, ITEM_NONE, ITEM_NONE, ITEM_NONE }, }, { { SLOT_OCARINA, SLOT_NONE, SLOT_NONE, SLOT_NONE }, @@ -625,7 +645,9 @@ Inventory sSaveDefaultInventory = { // dungeonItems { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, // dungeonKeys - { 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0 }, + { 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF }, + // defenceHearts + 0, // strayFairies { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, // dekuPlaygroundPlayerName @@ -769,7 +791,9 @@ Inventory sSaveDebugInventory = { // dungeonItems { 7, 7, 7, 7, 7, 7, 7, 7, 7, 7 }, // dungeonKeys - { 8, 8, 8, 8, 8, 8, 8, 8, 8, 0 }, + { 8, 8, 8, 8, 8, 8, 8, 8, 8 }, + // defenceHearts + 0, // strayFairies { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, // dekuPlaygroundPlayerName @@ -809,8 +833,8 @@ void Sram_InitDebugSave(void) { Lib_MemCpy(&gSaveContext.save.checksum, &sSaveDebugChecksum, sizeof(gSaveContext.save.checksum)); if (gSaveContext.save.playerForm != PLAYER_FORM_HUMAN) { - BUTTON_ITEM_EQUIP(0, 2) = D_801C6A48[((void)0, gSaveContext.save.playerForm & 0xFF)]; - C_SLOT_EQUIP(0, 2) = D_801C6A50[((void)0, gSaveContext.save.playerForm & 0xFF)]; + BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_C_DOWN) = D_801C6A48[((void)0, gSaveContext.save.playerForm)]; + C_SLOT_EQUIP(0, EQUIP_SLOT_C_DOWN) = D_801C6A50[((void)0, gSaveContext.save.playerForm)]; } gSaveContext.save.hasTatl = true; @@ -821,7 +845,7 @@ void Sram_InitDebugSave(void) { gSaveContext.save.horseData.pos.z = -1285; gSaveContext.save.horseData.yaw = -0x7554; - gSaveContext.save.entranceIndex = 0x1C00; + gSaveContext.save.entrance = ENTRANCE(CUTSCENE, 0); gSaveContext.save.isFirstCycle = true; // @@ -886,15 +910,19 @@ void func_80144A94(SramContext* sramCtx) { gSaveContext.jinxTimer = 0; } -u16 D_801C6A58[] = { 0x68B0, 0x6A60, 0xB230, 0x9A80, 0xD890, 0x3E40, 0x8640, 0x84A0, 0x2040, 0xAA30 }; +u16 D_801C6A58[] = { + ENTRANCE(GREAT_BAY_COAST, 11), ENTRANCE(ZORA_CAPE, 6), + ENTRANCE(SNOWHEAD, 3), ENTRANCE(MOUNTAIN_VILLAGE_WINTER, 8), + ENTRANCE(SOUTH_CLOCK_TOWN, 9), ENTRANCE(MILK_ROAD, 4), + ENTRANCE(WOODFALL, 4), ENTRANCE(SOUTHERN_SWAMP_POISONED, 10), + ENTRANCE(IKANA_CANYON, 4), ENTRANCE(STONE_TOWER, 3), +}; -#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 pad1; s32 fileNum; if (gSaveContext.unk_3F3F) { @@ -951,23 +979,24 @@ void Sram_OpenSave(FileChooseContext* fileChooseCtx, SramContext* sramCtx) { } if (gSaveContext.save.isFirstCycle) { - gSaveContext.save.entranceIndex = 0xD800; + gSaveContext.save.entrance = ENTRANCE(SOUTH_CLOCK_TOWN, 0); gSaveContext.save.day = 0; gSaveContext.save.time = 0x3FFF; } else { - gSaveContext.save.entranceIndex = 0x1C00; + gSaveContext.save.entrance = ENTRANCE(CUTSCENE, 0); 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)) { + gSaveContext.save.entrance = D_801C6A58[(void)0, gSaveContext.save.owlSaveLocation]; + if ((gSaveContext.save.entrance == ENTRANCE(SOUTHERN_SWAMP_POISONED, 10)) && + (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.entrance = ENTRANCE(SOUTHERN_SWAMP_CLEARED, 10); + } else if ((gSaveContext.save.entrance == ENTRANCE(MOUNTAIN_VILLAGE_WINTER, 8)) && (gSaveContext.save.weekEventReg[33] & 0x80)) { // Unconfirmed weekEventReg: "Mountain Village Unfrozen" - gSaveContext.save.entranceIndex = 0xAE80; + gSaveContext.save.entrance = ENTRANCE(MOUNTAIN_VILLAGE_SPRING, 8); } for (i = 0; i < ARRAY_COUNT(gSaveContext.cycleSceneFlags); i++) { @@ -979,19 +1008,16 @@ void Sram_OpenSave(FileChooseContext* fileChooseCtx, SramContext* sramCtx) { } if (gSaveContext.save.unk_F65) { - Lib_MemCpy(gScarecrowSpawnSongPtr, gSaveContext.save.scarecrowsSong, - sizeof(gSaveContext.save.scarecrowsSong)); + Lib_MemCpy(gScarecrowSpawnSongPtr, gSaveContext.save.scarecrowSpawnSong, + sizeof(gSaveContext.save.scarecrowSpawnSong)); - for (i = 0; i != ARRAY_COUNT(gSaveContext.save.scarecrowsSong); i++) {} + for (i = 0; i != ARRAY_COUNT(gSaveContext.save.scarecrowSpawnSong); 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) { @@ -1143,7 +1169,7 @@ void func_801457CC(FileChooseContext* fileChooseCtx2, SramContext* sramCtx) { 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_24454[sp76] = gSaveContext.save.inventory.defenseHearts; fileChooseCtx->unk_24444[sp76] = gSaveContext.save.inventory.questItems; fileChooseCtx->unk_24458[sp76] = gSaveContext.save.time; fileChooseCtx->unk_24460[sp76] = gSaveContext.save.day; @@ -1238,7 +1264,7 @@ void func_801457CC(FileChooseContext* fileChooseCtx2, SramContext* sramCtx) { 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_24454[sp76] = gSaveContext.save.inventory.defenseHearts; fileChooseCtx->unk_24444[sp76] = gSaveContext.save.inventory.questItems; fileChooseCtx->unk_24458[sp76] = gSaveContext.save.time; fileChooseCtx->unk_24460[sp76] = gSaveContext.save.day; @@ -1351,7 +1377,7 @@ void func_80146628(FileChooseContext* fileChooseCtx2, SramContext* sramCtx) { 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_24456[fileChooseCtx->fileNum] = gSaveContext.save.inventory.defenseHearts; 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; @@ -1394,7 +1420,7 @@ void func_80146628(FileChooseContext* fileChooseCtx2, SramContext* sramCtx) { 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_24454[fileChooseCtx->fileNum] = gSaveContext.save.inventory.defenseHearts; 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; @@ -1463,7 +1489,7 @@ void Sram_InitSave(FileChooseContext* fileChooseCtx2, SramContext* sramCtx) { 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_24454[fileChooseCtx->unk_24480] = gSaveContext.save.inventory.defenseHearts; 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; @@ -1495,7 +1521,7 @@ void func_80146DF8(SramContext* sramCtx) { } void Sram_InitSram(GameState* gameState, SramContext* sramCtx) { - if (&gSaveContext.save) {} + if (gSaveContext.save.entrance) {} // Required to match func_801A3D98(gSaveContext.options.audioSetting); } @@ -1519,9 +1545,9 @@ void func_80146EBC(SramContext* sramCtx, s32 curPage, s32 numPages) { /** * Saves the game on the very first time Player enters South Clock Town from the Clock Tower */ -void Sram_SaveSpecialEnterClockTown(GlobalContext* globalCtx) { +void Sram_SaveSpecialEnterClockTown(PlayState* play) { s32 pad[2]; - SramContext* sramCtx = &globalCtx->sramCtx; + SramContext* sramCtx = &play->sramCtx; gSaveContext.save.isFirstCycle = true; gSaveContext.save.isOwlSave = false; @@ -1532,7 +1558,7 @@ void Sram_SaveSpecialEnterClockTown(GlobalContext* globalCtx) { /** * Saves when beating the game, after showing the "Dawn of the New Day" message */ -void Sram_SaveSpecialNewDay(GlobalContext* globalCtx) { +void Sram_SaveSpecialNewDay(PlayState* play) { s32 cutscene = gSaveContext.save.cutscene; s32 day; u16 time = gSaveContext.save.time; @@ -1542,14 +1568,13 @@ void Sram_SaveSpecialNewDay(GlobalContext* globalCtx) { // Unconfirmed: "Obtained Fierce Deity Mask?" gSaveContext.save.weekEventReg[84] &= (u8)~0x20; - Sram_SaveEndOfCycle(globalCtx); - func_8014546C(&globalCtx->sramCtx); + Sram_SaveEndOfCycle(play); + func_8014546C(&play->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]); + func_80185F64(play->sramCtx.saveBuf, D_801C67C8[gSaveContext.fileNum * 2], D_801C67F0[gSaveContext.fileNum * 2]); } void func_80147008(SramContext* sramCtx, u32 curPage, u32 numPages) { diff --git a/src/code/z_sub_s.c b/src/code/z_sub_s.c index c36365d48..efc6774a7 100644 --- a/src/code/z_sub_s.c +++ b/src/code/z_sub_s.c @@ -10,19 +10,19 @@ s16 sPathDayFlags[] = { 0x40, 0x20, 0x10, 8, 4, 2, 1, 0 }; #include "code/sub_s/sub_s.c" -Vec3f D_801C5DB0 = { 1.0f, 1.0f, 1.0f }; +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 switchFlag. */ -EnDoor* SubS_FindDoor(GlobalContext* globalCtx, s32 switchFlag) { +EnDoor* SubS_FindDoor(PlayState* play, s32 switchFlag) { Actor* actor = NULL; EnDoor* door; while (true) { - actor = SubS_FindActor(globalCtx, actor, ACTORCAT_DOOR, ACTOR_EN_DOOR); + actor = SubS_FindActor(play, actor, ACTORCAT_DOOR, ACTOR_EN_DOOR); door = (EnDoor*)actor; if (actor == NULL) { @@ -44,7 +44,7 @@ EnDoor* SubS_FindDoor(GlobalContext* globalCtx, s32 switchFlag) { return door; } -Gfx* SubS_DrawTransformFlexLimb(GlobalContext* globalCtx, s32 limbIndex, void** skeleton, Vec3s* jointTable, +Gfx* SubS_DrawTransformFlexLimb(PlayState* play, s32 limbIndex, void** skeleton, Vec3s* jointTable, OverrideLimbDraw overrideLimbDraw, PostLimbDraw postLimbDraw, TransformLimbDraw transformLimbDraw, Actor* actor, Mtx** mtx, Gfx* gfx) { StandardLimb* limb; @@ -53,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]; @@ -62,11 +62,11 @@ Gfx* SubS_DrawTransformFlexLimb(GlobalContext* globalCtx, s32 limbIndex, void** pos.z = limb->jointPos.z; newDList = limbDList = limb->dList; - if ((overrideLimbDraw == NULL) || !overrideLimbDraw(globalCtx, limbIndex, &newDList, &pos, &rot, actor, &gfx)) { - Matrix_JointPosition(&pos, &rot); - Matrix_StatePush(); + if ((overrideLimbDraw == NULL) || !overrideLimbDraw(play, limbIndex, &newDList, &pos, &rot, actor, &gfx)) { + Matrix_TranslateRotateZYX(&pos, &rot); + Matrix_Push(); - transformLimbDraw(globalCtx, limbIndex, actor, &gfx); + transformLimbDraw(play, limbIndex, actor, &gfx); if (newDList != NULL) { Matrix_ToMtx(*mtx); @@ -77,18 +77,18 @@ 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); + postLimbDraw(play, limbIndex, &limbDList, &rot, actor, &gfx); } if (limb->child != LIMB_DONE) { - gfx = SubS_DrawTransformFlexLimb(globalCtx, limb->child, skeleton, jointTable, overrideLimbDraw, postLimbDraw, + gfx = SubS_DrawTransformFlexLimb(play, 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, + gfx = SubS_DrawTransformFlexLimb(play, limb->sibling, skeleton, jointTable, overrideLimbDraw, postLimbDraw, transformLimbDraw, actor, mtx, gfx); } return gfx; @@ -103,7 +103,7 @@ Gfx* SubS_DrawTransformFlexLimb(GlobalContext* globalCtx, s32 limbIndex, void** * coordinates. * Note that the `TransformLimbDraw` does not have a NULL check, so must be provided even if empty. */ -Gfx* SubS_DrawTransformFlex(GlobalContext* globalCtx, void** skeleton, Vec3s* jointTable, s32 dListCount, +Gfx* SubS_DrawTransformFlex(PlayState* play, void** skeleton, Vec3s* jointTable, s32 dListCount, OverrideLimbDraw overrideLimbDraw, PostLimbDraw postLimbDraw, TransformLimbDraw transformLimbDraw, Actor* actor, Gfx* gfx) { StandardLimb* rootLimb; @@ -112,14 +112,14 @@ Gfx* SubS_DrawTransformFlex(GlobalContext* globalCtx, void** skeleton, Vec3s* jo Gfx* limbDList; Vec3f pos; Vec3s rot; - Mtx* mtx = GRAPH_ALLOC(globalCtx->state.gfxCtx, ALIGN16(dListCount * sizeof(Mtx))); + Mtx* mtx = GRAPH_ALLOC(play->state.gfxCtx, ALIGN16(dListCount * sizeof(Mtx))); if (skeleton == NULL) { return NULL; } gSPSegment(gfx++, 0x0D, mtx); - Matrix_StatePush(); + Matrix_Push(); rootLimb = Lib_SegmentedToVirtual(skeleton[0]); pos.x = jointTable->x; pos.y = jointTable->y; @@ -128,11 +128,11 @@ Gfx* SubS_DrawTransformFlex(GlobalContext* globalCtx, void** skeleton, Vec3s* jo newDlist = rootLimb->dList; limbDList = rootLimb->dList; - if (overrideLimbDraw == NULL || !overrideLimbDraw(globalCtx, 1, &newDlist, &pos, &rot, actor, &gfx)) { - Matrix_JointPosition(&pos, &rot); - Matrix_StatePush(); + if (overrideLimbDraw == NULL || !overrideLimbDraw(play, 1, &newDlist, &pos, &rot, actor, &gfx)) { + Matrix_TranslateRotateZYX(&pos, &rot); + Matrix_Push(); - transformLimbDraw(globalCtx, 1, actor, &gfx); + transformLimbDraw(play, 1, actor, &gfx); if (newDlist != NULL) { Matrix_ToMtx(mtx); @@ -143,48 +143,350 @@ Gfx* SubS_DrawTransformFlex(GlobalContext* globalCtx, void** skeleton, Vec3s* jo Matrix_ToMtx(mtx); mtx++; } - Matrix_StatePop(); + Matrix_Pop(); } if (postLimbDraw != NULL) { - postLimbDraw(globalCtx, 1, &limbDList, &rot, actor, &gfx); + postLimbDraw(play, 1, &limbDList, &rot, actor, &gfx); } if (rootLimb->child != LIMB_DONE) { - gfx = SubS_DrawTransformFlexLimb(globalCtx, rootLimb->child, skeleton, jointTable, overrideLimbDraw, - postLimbDraw, transformLimbDraw, actor, &mtx, gfx); + gfx = SubS_DrawTransformFlexLimb(play, 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(PlayState* play) { + s32 inCsMode = false; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_sub_s/func_8013AD9C.s") + if (Play_InCsMode(play)) { + inCsMode = true; + } + + return inCsMode; +} + +/** + * 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; + + Matrix_MultVec3f(&zeroVec, &newPos); + Matrix_Get(&curState); + Matrix_MtxFToYXZRot(&curState, &newRot, MTXMODE_NEW); + *pos = newPos; + + if (!stepRot && !overrideRot) { + rot->x = newRot.x; + rot->y = newRot.y; + rot->z = newRot.z; + return true; + } + + if (overrideRot) { + newRot.z = newRotZ; + newRot.y = newRotY; + } + + 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; +} void SubS_UpdateFlags(u16* flags, u16 setBits, u16 unsetBits) { *flags = (*flags & ~unsetBits) | setBits; } -#pragma GLOBAL_ASM("asm/non_matchings/code/z_sub_s/func_8013AF00.s") +/** + * 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; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_sub_s/func_8013B010.s") + for (i = 0; i < numPoints; i++) { + if ((i >= order) && (i < (numPoints - order + 1))) { + val += 1.0f; + } + knots[i] = val; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/code/z_sub_s/func_8013B0C8.s") +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; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_sub_s/func_8013B350.s") +/** + * 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 -#pragma GLOBAL_ASM("asm/non_matchings/code/z_sub_s/func_8013B6B0.s") + *progress = 0.0f; + if ((waypointTime <= 0) || (elapsedTime < 0)) { + return SUBS_TIME_PATHING_PROGRESS_STATUS_ERROR; + } -#pragma GLOBAL_ASM("asm/non_matchings/code/z_sub_s/func_8013B878.s") + // 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++; + } + } -Path* SubS_GetAdditionalPath(GlobalContext* globalCtx, u8 pathIndex, s32 max) { + 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] play + * @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(PlayState* play, 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(&play->colCtx, &posA, &posB, &posResult, &outPoly, true, true, true, true, &bgId)) { + targetPos->y = posResult.y; + } +} + +Path* SubS_GetAdditionalPath(PlayState* play, u8 pathIndex, s32 limit) { Path* path; s32 i = 0; do { - path = &globalCtx->setupPathList[pathIndex]; - if (i >= max) { + path = &play->setupPathList[pathIndex]; + if (i >= limit) { break; } pathIndex = path->unk1; @@ -197,7 +499,7 @@ Path* SubS_GetAdditionalPath(GlobalContext* globalCtx, u8 pathIndex, s32 max) { /** * Finds the nearest actor instance of a specified Id and category to an actor. */ -Actor* SubS_FindNearestActor(Actor* actor, GlobalContext* globalCtx, u8 actorCategory, s16 actorId) { +Actor* SubS_FindNearestActor(Actor* actor, PlayState* play, u8 actorCategory, s16 actorId) { Actor* actorIter = NULL; Actor* actorTmp; f32 dist; @@ -206,7 +508,7 @@ Actor* SubS_FindNearestActor(Actor* actor, GlobalContext* globalCtx, u8 actorCat s32 isSetup = false; do { - actorIter = SubS_FindActor(globalCtx, actorIter, actorCategory, actorId); + actorIter = SubS_FindActor(play, actorIter, actorCategory, actorId); actorTmp = actorIter; if (actorTmp == NULL) { @@ -229,24 +531,24 @@ Actor* SubS_FindNearestActor(Actor* actor, GlobalContext* globalCtx, u8 actorCat return closestActor; } -s32 SubS_ChangeAnimationByInfoS(SkelAnime* skelAnime, AnimationInfoS* animations, s32 index) { +s32 SubS_ChangeAnimationByInfoS(SkelAnime* skelAnime, AnimationInfoS* animationInfo, s32 animIndex) { s32 endFrame; s32 startFrame; - animations += index; - endFrame = animations->frameCount; - if (animations->frameCount < 0) { - endFrame = Animation_GetLastFrame(&animations->animation->common); + animationInfo += animIndex; + endFrame = animationInfo->frameCount; + if (animationInfo->frameCount < 0) { + endFrame = Animation_GetLastFrame(&animationInfo->animation->common); } - startFrame = animations->startFrame; + startFrame = animationInfo->startFrame; if (startFrame >= endFrame || startFrame < 0) { return false; } - if (animations->playSpeed < 0.0f) { + if (animationInfo->playSpeed < 0.0f) { SWAP(s32, endFrame, startFrame); } - Animation_Change(skelAnime, animations->animation, animations->playSpeed, startFrame, endFrame, animations->mode, - animations->morphFrames); + Animation_Change(skelAnime, animationInfo->animation, animationInfo->playSpeed, startFrame, endFrame, + animationInfo->mode, animationInfo->morphFrames); return true; } @@ -283,7 +585,7 @@ s32 SubS_HasReachedPoint(Actor* actor, Path* path, s32 pointIndex) { return reached; } -Path* SubS_GetDayDependentPath(GlobalContext* globalCtx, u8 pathIndex, u8 max, s32* startPointIndex) { +Path* SubS_GetDayDependentPath(PlayState* play, u8 pathIndex, u8 max, s32* startPointIndex) { Path* path = NULL; s32 found = false; s32 time = (((s16)TIME_TO_MINUTES_F(gSaveContext.save.time) % 60) + @@ -296,7 +598,7 @@ Path* SubS_GetDayDependentPath(GlobalContext* globalCtx, u8 pathIndex, u8 max, s } while (pathIndex != 0xFF) { - path = &globalCtx->setupPathList[pathIndex]; + path = &play->setupPathList[pathIndex]; if (sPathDayFlags[day] & path->unk2) { found = true; break; @@ -314,9 +616,189 @@ Path* SubS_GetDayDependentPath(GlobalContext* globalCtx, u8 pathIndex, u8 max, s return path; } -#pragma GLOBAL_ASM("asm/non_matchings/code/z_sub_s/func_8013C068.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_8013C624.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]); + + return true; +} + +// 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; + + 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; +} s32 SubS_CopyPointFromPathCheckBounds(Path* path, s32 pointIndex, Vec3f* dst) { Vec3s* point; @@ -333,24 +815,291 @@ s32 SubS_CopyPointFromPathCheckBounds(Path* path, s32 pointIndex, Vec3f* dst) { return true; } -#pragma GLOBAL_ASM("asm/non_matchings/code/z_sub_s/func_8013C964.s") +//! TODO: Needs docs with func_800B8500 +s32 func_8013C964(Actor* actor, PlayState* play, f32 xzRange, f32 yRange, s32 itemId, s32 type) { + s32 ret = false; + s16 x; + s16 y; + f32 xzDistToPlayerTemp; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_sub_s/func_8013CC2C.s") + Actor_GetScreenPos(play, actor, &x, &y); -#pragma GLOBAL_ASM("asm/non_matchings/code/z_sub_s/func_8013CD64.s") + switch (type) { + case 1: + yRange = fabsf(actor->playerHeightRel) + 1.0f; + xzRange = actor->xzDistToPlayer + 1.0f; + ret = Actor_PickUp(actor, play, itemId, xzRange, yRange); + break; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_sub_s/func_8013CF04.s") + case 2: + if ((fabsf(actor->playerHeightRel) <= yRange) && (actor->xzDistToPlayer <= xzRange)) { + ret = func_800B8500(actor, play, xzRange, yRange, itemId); + } + break; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_sub_s/func_8013D0E0.s") + case 3: + //! @bug: Both x and y conditionals are always true, || should be an && + if (((x >= 0) || (x < SCREEN_WIDTH)) && ((y >= 0) || (y < SCREEN_HEIGHT))) { + ret = func_800B8500(actor, play, xzRange, yRange, itemId); + } + break; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_sub_s/func_8013D2E0.s") + case 4: + yRange = fabsf(actor->playerHeightRel) + 1.0f; + xzRange = actor->xzDistToPlayer + 1.0f; + xzDistToPlayerTemp = actor->xzDistToPlayer; + actor->xzDistToPlayer = 0.0f; + actor->flags |= ACTOR_FLAG_10000; + ret = func_800B8500(actor, play, xzRange, yRange, itemId); + actor->xzDistToPlayer = xzDistToPlayerTemp; + break; + + case 5: + //! @bug: Both x and y conditionals are always true, || should be an && + if (((x >= 0) || (x < SCREEN_WIDTH)) && ((y >= 0) || (y < SCREEN_HEIGHT)) && + (fabsf(actor->playerHeightRel) <= yRange) && (actor->xzDistToPlayer <= xzRange) && actor->isTargeted) { + actor->flags |= ACTOR_FLAG_10000; + ret = func_800B8500(actor, play, xzRange, yRange, itemId); + } + break; + + case 6: + //! @bug: Both x and y conditionals are always true, || should be an && + if (((x >= 0) || (x < SCREEN_WIDTH)) && ((y >= 0) || (y < SCREEN_HEIGHT)) && + (fabsf(actor->playerHeightRel) <= yRange) && (actor->xzDistToPlayer <= xzRange)) { + actor->flags |= ACTOR_FLAG_10000; + ret = func_800B8500(actor, play, xzRange, yRange, itemId); + } + break; + + default: + 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; +Path* SubS_GetPathByIndex(PlayState* play, s16 pathIndex, s16 max) { + return (pathIndex != max) ? &play->setupPathList[pathIndex] : NULL; } s32 SubS_CopyPointFromPath(Path* path, s32 pointIndex, Vec3f* dst) { @@ -412,22 +1161,22 @@ s16 SubS_GetDistSqAndOrientPath(Path* path, s32 pointIndex, Vec3f* pos, f32* dis return Math_Atan2S(diffX, diffZ); } -s8 SubS_IsObjectLoaded(s8 index, GlobalContext* globalCtx) { - return !Object_IsLoaded(&globalCtx->objectCtx, index) ? false : true; +s8 SubS_IsObjectLoaded(s8 index, PlayState* play) { + return !Object_IsLoaded(&play->objectCtx, index) ? false : true; } -s8 SubS_GetObjectIndex(s16 id, GlobalContext* globalCtx) { - return Object_GetIndex(&globalCtx->objectCtx, id); +s8 SubS_GetObjectIndex(s16 id, PlayState* play) { + return Object_GetIndex(&play->objectCtx, id); } /** * Finds the first actor instance of a specified Id and category. */ -Actor* SubS_FindActor(GlobalContext* globalCtx, Actor* actorListStart, u8 actorCategory, s16 actorId) { +Actor* SubS_FindActor(PlayState* play, Actor* actorListStart, u8 actorCategory, s16 actorId) { Actor* actor = actorListStart; if (actor == NULL) { - actor = globalCtx->actorCtx.actorLists[actorCategory].first; + actor = play->actorCtx.actorLists[actorCategory].first; } while (actor != NULL && actorId != actor->id) { @@ -437,9 +1186,9 @@ Actor* SubS_FindActor(GlobalContext* globalCtx, Actor* actorListStart, u8 actorC return actor; } -s32 SubS_FillLimbRotTables(GlobalContext* globalCtx, s16* limbRotTableY, s16* limbRotTableZ, s32 numLimbs) { +s32 SubS_FillLimbRotTables(PlayState* play, s16* limbRotTableY, s16* limbRotTableZ, s32 numLimbs) { s32 i; - u32 frames = globalCtx->gameplayFrames; + u32 frames = play->gameplayFrames; for (i = 0; i < numLimbs; i++) { limbRotTableY[i] = (i * 50 + 0x814) * frames; @@ -449,7 +1198,7 @@ s32 SubS_FillLimbRotTables(GlobalContext* globalCtx, s16* limbRotTableY, s16* li return true; } -s32 SubS_IsFloorAbove(GlobalContext* globalCtx, Vec3f* pos, f32 distAbove) { +s32 SubS_IsFloorAbove(PlayState* play, Vec3f* pos, f32 distAbove) { CollisionPoly* outPoly; Vec3f posA; Vec3f posB; @@ -458,8 +1207,7 @@ s32 SubS_IsFloorAbove(GlobalContext* globalCtx, Vec3f* pos, f32 distAbove) { posA = posB = *pos; posB.y += distAbove; - return BgCheck_EntityLineTest1(&globalCtx->colCtx, &posA, &posB, &posResult, &outPoly, false, true, false, true, - &bgId); + return BgCheck_EntityLineTest1(&play->colCtx, &posA, &posB, &posResult, &outPoly, false, true, false, true, &bgId); } s32 SubS_CopyPointFromPathList(Path* paths, s32 pathIndex, s32 pointIndex, Vec3f* dst) { @@ -473,18 +1221,17 @@ s32 SubS_CopyPointFromPathList(Path* paths, s32 pathIndex, s32 pointIndex, Vec3f return false; } -u8 SubS_GetPathCount(Path* paths, s32 index) { - Path* path = &paths[index]; +u8 SubS_GetPathCountFromPathList(Path* paths, s32 pathIndex) { + Path* path = &paths[pathIndex]; return path->count; } -void SubS_ActorPathing_Init(GlobalContext* globalCtx, Vec3f* worldPos, Actor* actor, ActorPathing* actorPath, - Path* paths, s32 pathIndex, s32 begPointIndex, s32 endPointIndex, s32 curPointIndex, - u8 flags) { +void SubS_ActorPathing_Init(PlayState* play, Vec3f* worldPos, Actor* actor, ActorPathing* actorPath, Path* paths, + s32 pathIndex, s32 begPointIndex, s32 endPointIndex, s32 curPointIndex, u8 flags) { Path* path; - actorPath->setupPathList = globalCtx->setupPathList; + actorPath->setupPathList = play->setupPathList; actorPath->pathIndex = pathIndex; path = &paths[pathIndex]; actorPath->points = Lib_SegmentedToVirtual(path->points); @@ -509,9 +1256,9 @@ void SubS_ActorPathing_Init(GlobalContext* globalCtx, Vec3f* worldPos, Actor* ac actorPath->prevFlags = flags; } -s32 SubS_ActorPathing_Update(GlobalContext* globalCtx, ActorPathing* actorPath, - ActorPathingComputeFunc computePointInfoFunc, ActorPathingUpdateFunc updateActorInfoFunc, - ActorPathingUpdateFunc moveFunc, ActorPathingUpdateFunc setNextPointFunc) { +s32 SubS_ActorPathing_Update(PlayState* play, ActorPathing* actorPath, ActorPathingComputeFunc computePointInfoFunc, + ActorPathingUpdateFunc updateActorInfoFunc, ActorPathingUpdateFunc moveFunc, + ActorPathingUpdateFunc setNextPointFunc) { s32 shouldSetNextPoint; s32 reupdate; @@ -531,24 +1278,24 @@ s32 SubS_ActorPathing_Update(GlobalContext* globalCtx, ActorPathing* actorPath, do { shouldSetNextPoint = false; if (actorPath->computePointInfoFunc != NULL) { - actorPath->computePointInfoFunc(globalCtx, actorPath); + actorPath->computePointInfoFunc(play, actorPath); } if (actorPath->updateActorInfoFunc != NULL) { - shouldSetNextPoint = actorPath->updateActorInfoFunc(globalCtx, actorPath); + shouldSetNextPoint = actorPath->updateActorInfoFunc(play, actorPath); } if (shouldSetNextPoint) { if (actorPath->setNextPointFunc != NULL) { - reupdate = actorPath->setNextPointFunc(globalCtx, actorPath); + reupdate = actorPath->setNextPointFunc(play, actorPath); } } else if (actorPath->moveFunc != NULL) { - reupdate = actorPath->moveFunc(globalCtx, actorPath); + reupdate = actorPath->moveFunc(play, actorPath); } } while (reupdate); actorPath->prevFlags = actorPath->flags; return false; } -void SubS_ActorPathing_ComputePointInfo(GlobalContext* globalCtx, ActorPathing* actorPath) { +void SubS_ActorPathing_ComputePointInfo(PlayState* play, ActorPathing* actorPath) { Vec3f diff; actorPath->curPoint.x = actorPath->points[actorPath->curPointIndex].x + actorPath->pointOffset.x; @@ -564,17 +1311,17 @@ void SubS_ActorPathing_ComputePointInfo(GlobalContext* globalCtx, ActorPathing* actorPath->rotToCurPoint.z = 0; } -s32 SubS_ActorPathing_MoveWithGravity(GlobalContext* globalCtx, ActorPathing* actorPath) { +s32 SubS_ActorPathing_MoveWithGravity(PlayState* play, ActorPathing* actorPath) { Actor_MoveWithGravity(actorPath->actor); return false; } -s32 SubS_ActorPathing_MoveWithoutGravityReverse(GlobalContext* globalCtx, ActorPathing* actorPath) { +s32 SubS_ActorPathing_MoveWithoutGravityReverse(PlayState* play, ActorPathing* actorPath) { Actor_MoveWithoutGravityReverse(actorPath->actor); return false; } -s32 SubS_ActorPathing_SetNextPoint(GlobalContext* globalCtx, ActorPathing* actorPath) { +s32 SubS_ActorPathing_SetNextPoint(PlayState* play, ActorPathing* actorPath) { s32 reupdate = true; Math_Vec3f_Copy(&actorPath->prevPoint, &actorPath->curPoint); @@ -610,21 +1357,21 @@ s32 SubS_ActorPathing_SetNextPoint(GlobalContext* globalCtx, ActorPathing* actor return reupdate; } -void SubS_ChangeAnimationBySpeedInfo(SkelAnime* skelAnime, AnimationSpeedInfo* animations, s32 nextIndex, - s32* curIndex) { - AnimationSpeedInfo* animation = &animations[nextIndex]; +void SubS_ChangeAnimationBySpeedInfo(SkelAnime* skelAnime, AnimationSpeedInfo* animationInfo, s32 nextAnimIndex, + s32* curAnimIndex) { + AnimationSpeedInfo* animation = &animationInfo[nextAnimIndex]; f32 startFrame = skelAnime->curFrame; f32 endFrame; f32 morphFrames; - if ((*curIndex < 0) || (nextIndex == *curIndex)) { + if ((*curAnimIndex < 0) || (nextAnimIndex == *curAnimIndex)) { morphFrames = 0.0f; - if (*curIndex < 0) { + if (*curAnimIndex < 0) { startFrame = 0.0f; } } else { morphFrames = animation->morphFrames; - if (nextIndex != *curIndex) { + if (nextAnimIndex != *curAnimIndex) { startFrame = 0.0f; } } @@ -636,7 +1383,7 @@ void SubS_ChangeAnimationBySpeedInfo(SkelAnime* skelAnime, AnimationSpeedInfo* a } Animation_Change(skelAnime, animation->animation, animation->playSpeed, startFrame, endFrame, animation->mode, morphFrames); - *curIndex = nextIndex; + *curAnimIndex = nextAnimIndex; } s32 SubS_StartActorCutscene(Actor* actor, s16 nextCutscene, s16 curCutscene, s32 type) { @@ -688,36 +1435,164 @@ s32 SubS_FillCutscenesList(Actor* actor, s16 cutscenes[], s16 numCutscenes) { return i; } -#pragma GLOBAL_ASM("asm/non_matchings/code/z_sub_s/func_8013E4B0.s") +/** + * 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; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_sub_s/func_8013E5CC.s") + 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. * The callback should return `true` when the actor is succesfully verified. */ -Actor* SubS_FindActorCustom(GlobalContext* globalCtx, Actor* actor, Actor* actorListStart, u8 actorCategory, - s16 actorId, void* verifyData, VerifyActor verifyActor) { +Actor* SubS_FindActorCustom(PlayState* play, Actor* actor, Actor* actorListStart, u8 actorCategory, s16 actorId, + void* verifyData, VerifyActor verifyActor) { Actor* actorIter = actorListStart; if (actorListStart == NULL) { - actorIter = globalCtx->actorCtx.actorLists[actorCategory].first; + actorIter = play->actorCtx.actorLists[actorCategory].first; } - while (actorIter != NULL && (actorId != actorIter->id || - (actorId == actorIter->id && - (verifyActor == NULL || - (verifyActor != NULL && !verifyActor(globalCtx, actor, actorIter, verifyData)))))) { + while (actorIter != NULL && + (actorId != actorIter->id || + (actorId == actorIter->id && + (verifyActor == NULL || (verifyActor != NULL && !verifyActor(play, actor, actorIter, verifyData)))))) { actorIter = actorIter->next; } 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, PlayState* play, 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(play, actor, data))) { + ret = func_800B8500(actor, play, xzRange, yRange, exchangeItemId); + } + return ret; +} -#pragma GLOBAL_ASM("asm/non_matchings/code/z_sub_s/func_8013E8F8.s") +s32 SubS_ActorAndPlayerFaceEachOther(PlayState* play, Actor* actor, void* data) { + Player* player = GET_PLAYER(play); + Vec3s* yawTols = (Vec3s*)data; + s16 playerYaw = ABS(BINANG_SUB(Actor_YawBetweenActors(&player->actor, actor), player->actor.shape.rot.y)); + s16 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, PlayState* play, f32 xzRange, f32 yRange, s32 exhangeItemId, s16 playerYawTol, + s16 actorYawTol) { + Vec3s yawTols; + + yawTols.x = playerYawTol; + yawTols.y = actorYawTol; + return func_8013E748(actor, play, 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.c b/src/code/z_vr_box.c index 29d1a1aca..7975b1c85 100644 --- a/src/code/z_vr_box.c +++ b/src/code/z_vr_box.c @@ -36,7 +36,7 @@ void func_80143148(SkyboxContext* skyboxCtx, s32 arg1) { } void func_801431E8(GameState* gameState, SkyboxContext* skyboxCtx, s16 skyType) { - GlobalContext* globalCtx = (GlobalContext*)gameState; + PlayState* play = (PlayState*)gameState; size_t size; void* offset; s32 pad; @@ -75,13 +75,13 @@ void func_801431E8(GameState* gameState, SkyboxContext* skyboxCtx, s16 skyType) skyboxCtx->envB = 40; // Inverted Stone Tower Temple and Inverted Stone Tower - if ((globalCtx->sceneNum == SCENE_F41) || (globalCtx->sceneNum == SCENE_INISIE_R)) { + if ((play->sceneNum == SCENE_F41) || (play->sceneNum == SCENE_INISIE_R)) { skyboxCtx->rotZ = 3.15000009537f; } } } -void func_80143324(GlobalContext* globalCtx, SkyboxContext* skyboxCtx, s16 skyType) { +void func_80143324(PlayState* play, SkyboxContext* skyboxCtx, s16 skyType) { size_t size; if (1) {} @@ -89,7 +89,7 @@ void func_80143324(GlobalContext* globalCtx, SkyboxContext* skyboxCtx, s16 skyTy if (skyType == 1) { osCreateMesgQueue(&skyboxCtx->loadQueue, &skyboxCtx->loadMsg, 1); - if (globalCtx->envCtx.unk_10 == 0) { + if (play->envCtx.unk_10 == 0) { // Send a DMA request for the clear sky texture size = SEGMENT_ROM_SIZE(d2_fine_static); @@ -106,7 +106,7 @@ void func_80143324(GlobalContext* globalCtx, SkyboxContext* skyboxCtx, s16 skyTy osRecvMesg(&skyboxCtx->loadQueue, NULL, OS_MESG_BLOCK); osCreateMesgQueue(&skyboxCtx->loadQueue, &skyboxCtx->loadMsg, 1); - if (globalCtx->envCtx.unk_11 == 0) { + if (play->envCtx.unk_11 == 0) { // Send a DMA request for the clear sky texture size = SEGMENT_ROM_SIZE(d2_fine_static); 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/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/lookathil.c b/src/libultra/gu/lookathil.c index 823ff0982..dcb05b3d9 100644 --- a/src/libultra/gu/lookathil.c +++ b/src/libultra/gu/lookathil.c @@ -1,6 +1,6 @@ #include "global.h" -#define FTOFRAC8(x) ((s32)MIN(((x) * (128.0f)), 127.0f) & 0xff) +#define FTOFRAC8(x) ((s32)MIN(((x) * (128.0f)), 127.0f) & 0xFF) void guLookAtHiliteF(f32 mf[4][4], LookAt* l, Hilite* h, f32 xEye, f32 yEye, f32 zEye, f32 xAt, f32 yAt, f32 zAt, f32 xUp, f32 yUp, f32 zUp, f32 xl1, f32 yl1, f32 zl1, /* light 1 direction */ 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..46dd605d4 100644 --- a/src/libultra/gu/rotate.c +++ b/src/libultra/gu/rotate.c @@ -1,7 +1,7 @@ #include "global.h" void guRotateF(float m[4][4], float a, float x, float y, float z) { - static float D_80097F90 = 0.017453292; // TODO this is PI / 180.0, we should define pi somewhere + static float D_80097F90 = M_PI / 180.0f; float sine; float cosine; float ab; @@ -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/libultra/io/contreaddata.c b/src/libultra/io/contreaddata.c index b54d894f3..163756e07 100644 --- a/src/libultra/io/contreaddata.c +++ b/src/libultra/io/contreaddata.c @@ -28,7 +28,7 @@ void osContGetReadData(OSContPad* data) { ptr = (u8*)__osContPifRam.ramarray; for (i = 0; i < __osMaxControllers; i++, ptr += sizeof(__OSContReadFormat), data++) { readformat = *(__OSContReadFormat*)ptr; - data->errno = (readformat.rxsize & 0xc0) >> 4; + data->errno = (readformat.rxsize & 0xC0) >> 4; if (data->errno == 0) { data->button = readformat.button; data->stick_x = readformat.stick_x; diff --git a/src/libultra/io/controller.c b/src/libultra/io/controller.c index bd8270993..245183280 100644 --- a/src/libultra/io/controller.c +++ b/src/libultra/io/controller.c @@ -58,7 +58,7 @@ void __osContGetInitData(u8* pattern, OSContStatus* data) { ptr = (u8*)__osContPifRam.ramarray; for (i = 0; i < __osMaxControllers; i++, ptr += sizeof(requestHeader), data++) { requestHeader = *(__OSContRequestHeader*)ptr; - data->errno = (requestHeader.rxsize & 0xc0) >> 4; + data->errno = (requestHeader.rxsize & 0xC0) >> 4; if (data->errno == 0) { data->type = requestHeader.typel << 8 | requestHeader.typeh; data->status = requestHeader.status; diff --git a/src/libultra/io/epirawdma.c b/src/libultra/io/epirawdma.c index cbe43ce82..fd7573151 100644 --- a/src/libultra/io/epirawdma.c +++ b/src/libultra/io/epirawdma.c @@ -53,7 +53,7 @@ s32 __osEPiRawStartDma(OSPiHandle* handle, s32 direction, u32 cartAddr, void* dr } HW_REG(PI_DRAM_ADDR_REG, void*) = (void*)osVirtualToPhysical(dramAddr); - HW_REG(PI_CART_ADDR_REG, void*) = (void*)((handle->baseAddress | cartAddr) & 0x1fffffff); + HW_REG(PI_CART_ADDR_REG, void*) = (void*)((handle->baseAddress | cartAddr) & 0x1FFFFFFF); switch (direction) { case OS_READ: diff --git a/src/libultra/io/visetxscale.c b/src/libultra/io/visetxscale.c index e6a9ec6bb..0e2cf762d 100644 --- a/src/libultra/io/visetxscale.c +++ b/src/libultra/io/visetxscale.c @@ -10,7 +10,7 @@ void osViSetXScale(f32 value) { __osViNext->state |= 0x2; - nomValue = __osViNext->modep->comRegs.xScale & 0xfff; + nomValue = __osViNext->modep->comRegs.xScale & 0xFFF; __osViNext->x.scale = (u32)(__osViNext->x.factor * nomValue) & 0xFFF; __osRestoreInt(saveMask); diff --git a/src/libultra/os/initialize.c b/src/libultra/os/initialize.c index 20564effb..9fbf5ff64 100644 --- a/src/libultra/os/initialize.c +++ b/src/libultra/os/initialize.c @@ -4,7 +4,7 @@ typedef struct { /* 0x0 */ u32 ins_00; // lui k0, 0x8000 - /* 0x4 */ u32 ins_04; // addiu k0, k0, 0x39e0 + /* 0x4 */ u32 ins_04; // addiu k0, k0, 0x39E0 /* 0x8 */ u32 ins_08; // jr k0 ; __osException /* 0xC */ u32 ins_0C; // nop } struct_exceptionPreamble; @@ -57,7 +57,7 @@ void osInitialize(void) { osUnmapTLBAll(); osMapTLBRdb(); - osClockRate = (u64)((osClockRate * 3ll) / 4ull); + osClockRate = (u64)((osClockRate * 3LL) / 4ULL); if (osResetType == COLD_RESET) { bzero(osAppNmiBuffer, 64); diff --git a/src/libultra/rmon/xldtob.c b/src/libultra/rmon/xldtob.c index 65ffc7a92..460d0951c 100644 --- a/src/libultra/rmon/xldtob.c +++ b/src/libultra/rmon/xldtob.c @@ -9,13 +9,13 @@ const f64 digs[] = { 10e0L, 10e1L, 10e3L, 10e7L, 10e15L, 10e31L, 10e63L, 10e127L /* float properties */ #define _D0 0 -#define _DBIAS 0x3ff +#define _DBIAS 0x3FF #define _DLONG 1 #define _DOFF 4 -#define _FBIAS 0x7e +#define _FBIAS 0x7E #define _FOFF 7 #define _FRND 1 -#define _LBIAS 0x3ffe +#define _LBIAS 0x3FFE #define _LOFF 15 /* integer properties */ #define _C2 1 @@ -26,7 +26,7 @@ const f64 digs[] = { 10e0L, 10e1L, 10e3L, 10e7L, 10e15L, 10e31L, 10e63L, 10e127L #define INF 1 #define FINITE -1 #define _DFRAC ((1 << _DOFF) - 1) -#define _DMASK (0x7fff & ~_DFRAC) +#define _DMASK (0x7FFF & ~_DFRAC) #define _DMAX ((1 << (15 - _DOFF)) - 1) #define _DNAN (0x8000 | _DMAX << _DOFF | 1 << (_DOFF - 1)) #define _DSIGN 0x8000 diff --git a/src/libultra/rmon/xprintf.c b/src/libultra/rmon/xprintf.c index 6c538a2a8..ddb83652d 100644 --- a/src/libultra/rmon/xprintf.c +++ b/src/libultra/rmon/xprintf.c @@ -51,8 +51,7 @@ int _Printf(PrintCallback pfn, void* arg, const char* fmt, va_list ap) { } fmt = ++s; x.flags = 0; - // TODO the cast isn't necessary because strchr should take it in as const, but it currently doesn't - for (; (t = strchr((char*)fchar, *s)) != NULL; s++) { + for (; (t = strchr(fchar, *s)) != NULL; s++) { x.flags |= fbit[t - fchar]; } if (*s == '*') { 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 009405238..5f32870a7 100644 --- a/src/overlays/actors/ovl_Arms_Hook/z_arms_hook.c +++ b/src/overlays/actors/ovl_Arms_Hook/z_arms_hook.c @@ -12,13 +12,13 @@ #define THIS ((ArmsHook*)thisx) -void ArmsHook_Init(Actor* thisx, GlobalContext* globalCtx); -void ArmsHook_Destroy(Actor* thisx, GlobalContext* globalCtx); -void ArmsHook_Update(Actor* thisx, GlobalContext* globalCtx); -void ArmsHook_Draw(Actor* thisx, GlobalContext* globalCtx); +void ArmsHook_Init(Actor* thisx, PlayState* play); +void ArmsHook_Destroy(Actor* thisx, PlayState* play); +void ArmsHook_Update(Actor* thisx, PlayState* play); +void ArmsHook_Draw(Actor* thisx, PlayState* play); -void ArmsHook_Wait(ArmsHook* this, GlobalContext* globalCtx); -void ArmsHook_Shoot(ArmsHook* this, GlobalContext* globalCtx); +void ArmsHook_Wait(ArmsHook* this, PlayState* play); +void ArmsHook_Shoot(ArmsHook* this, PlayState* play); const ActorInit Arms_Hook_InitVars = { ACTOR_ARMS_HOOK, @@ -56,29 +56,29 @@ void ArmsHook_SetupAction(ArmsHook* this, ArmsHookActionFunc actionFunc) { this->actionFunc = actionFunc; } -void ArmsHook_Init(Actor* thisx, GlobalContext* globalCtx) { +void ArmsHook_Init(Actor* thisx, PlayState* play) { ArmsHook* this = THIS; - Collider_InitQuad(globalCtx, &this->collider); - Collider_SetQuad(globalCtx, &this->collider, &this->actor, &D_808C1BC0); + Collider_InitQuad(play, &this->collider); + Collider_SetQuad(play, &this->collider, &this->actor, &D_808C1BC0); ArmsHook_SetupAction(this, ArmsHook_Wait); this->unk1E0 = this->actor.world.pos; } -void ArmsHook_Destroy(Actor* thisx, GlobalContext* globalCtx) { +void ArmsHook_Destroy(Actor* thisx, PlayState* play) { ArmsHook* this = THIS; if (this->grabbed != NULL) { this->grabbed->flags &= ~0x2000; } - Collider_DestroyQuad(globalCtx, &this->collider); + Collider_DestroyQuad(play, &this->collider); } -void ArmsHook_Wait(ArmsHook* this, GlobalContext* globalCtx) { +void ArmsHook_Wait(ArmsHook* this, PlayState* play) { if (this->actor.parent == NULL) { ArmsHook_SetupAction(this, ArmsHook_Shoot); Actor_SetSpeeds(&this->actor, 20.0f); - this->actor.parent = &GET_PLAYER(globalCtx)->actor; + this->actor.parent = &GET_PLAYER(play)->actor; this->timer = 26; } } @@ -107,7 +107,7 @@ void ArmsHook_DetachHookFromActor(ArmsHook* this) { s32 ArmsHook_CheckForCancel(ArmsHook* this) { Player* player = (Player*)this->actor.parent; - if (func_801240C8(player)) { + if (Player_IsHoldingHookshot(player)) { if ((player->heldItemActionParam != player->itemActionParam) || ((player->actor.flags & ACTOR_FLAG_100)) || ((player->stateFlags1 & 0x4000080))) { this->timer = 0; @@ -125,10 +125,10 @@ void ArmsHook_AttachHookToActor(ArmsHook* this, Actor* actor) { Math_Vec3f_Diff(&actor->world.pos, &this->actor.world.pos, &this->unk1FC); } -void ArmsHook_Shoot(ArmsHook* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); +void ArmsHook_Shoot(ArmsHook* this, PlayState* play) { + Player* player = GET_PLAYER(play); - if ((this->actor.parent == NULL) || (!func_801240C8(player))) { + if ((this->actor.parent == NULL) || (!Player_IsHoldingHookshot(player))) { ArmsHook_DetachHookFromActor(this); Actor_MarkForDeath(&this->actor); return; @@ -244,11 +244,11 @@ void ArmsHook_Shoot(ArmsHook* this, GlobalContext* globalCtx) { sp60.x = this->unk1EC.x - (this->unk1E0.x - this->unk1EC.x); sp60.y = this->unk1EC.y - (this->unk1E0.y - this->unk1EC.y); sp60.z = this->unk1EC.z - (this->unk1E0.z - this->unk1EC.z); - if (BgCheck_EntityLineTest1(&globalCtx->colCtx, &sp60, &this->unk1E0, &posResult, &poly, true, true, true, true, + if (BgCheck_EntityLineTest1(&play->colCtx, &sp60, &this->unk1E0, &posResult, &poly, true, true, true, true, &bgId) && - (func_800B90AC(globalCtx, &this->actor, poly, bgId, &posResult) == 0 || - BgCheck_ProjectileLineTest(&globalCtx->colCtx, &sp60, &this->unk1E0, &posResult, &poly, true, true, true, - true, &bgId))) { + (func_800B90AC(play, &this->actor, poly, bgId, &posResult) == 0 || + BgCheck_ProjectileLineTest(&play->colCtx, &sp60, &this->unk1E0, &posResult, &poly, true, true, true, true, + &bgId))) { f32 nx = COLPOLY_GET_NORMAL(poly->normal.x); f32 nz = COLPOLY_GET_NORMAL(poly->normal.z); @@ -256,22 +256,21 @@ void ArmsHook_Shoot(ArmsHook* this, GlobalContext* globalCtx) { this->actor.world.pos.x += 10.0f * nx; this->actor.world.pos.z += 10.0f * nz; this->timer = 1; - if (SurfaceType_IsHookshotSurface(&globalCtx->colCtx, poly, bgId)) { + if (SurfaceType_IsHookshotSurface(&play->colCtx, poly, bgId)) { { DynaPolyActor* dynaPolyActor; - if (bgId != BGCHECK_SCENE && - (dynaPolyActor = DynaPoly_GetActor(&globalCtx->colCtx, bgId)) != NULL) { + if (bgId != BGCHECK_SCENE && (dynaPolyActor = DynaPoly_GetActor(&play->colCtx, bgId)) != NULL) { ArmsHook_AttachHookToActor(this, &dynaPolyActor->actor); } } func_808C1154(this); Audio_PlaySfxAtPos(&this->actor.projectedPos, NA_SE_IT_HOOKSHOT_STICK_OBJ); } else { - CollisionCheck_SpawnShieldParticlesMetal(globalCtx, &this->actor.world.pos); + CollisionCheck_SpawnShieldParticlesMetal(play, &this->actor.world.pos); Audio_PlaySfxAtPos(&this->actor.projectedPos, NA_SE_IT_HOOKSHOT_REFLECT); } } else { - if (CHECK_BTN_ANY(CONTROLLER1(globalCtx)->press.button, + if (CHECK_BTN_ANY(CONTROLLER1(&play->state)->press.button, BTN_A | BTN_B | BTN_R | BTN_CUP | BTN_CLEFT | BTN_CRIGHT | BTN_CDOWN)) { s32 pad; this->timer = 1; @@ -280,10 +279,10 @@ void ArmsHook_Shoot(ArmsHook* this, GlobalContext* globalCtx) { } } -void ArmsHook_Update(Actor* thisx, GlobalContext* globalCtx) { +void ArmsHook_Update(Actor* thisx, PlayState* play) { ArmsHook* this = THIS; - this->actionFunc(this, globalCtx); + this->actionFunc(this, play); this->unk1EC = this->unk1E0; } @@ -294,10 +293,10 @@ static Vec3f D_808C1C34 = { 0.0f, -500.0f, -3000.0f }; static Vec3f D_808C1C40 = { 0.0f, 500.0f, 0.0f }; static Vec3f D_808C1C4C = { 0.0f, -500.0f, 0.0f }; -void ArmsHook_Draw(Actor* thisx, GlobalContext* globalCtx) { +void ArmsHook_Draw(Actor* thisx, PlayState* play) { ArmsHook* this = THIS; f32 f0; - Player* player = GET_PLAYER(globalCtx); + Player* player = GET_PLAYER(play); if (player->actor.draw != NULL && player->rightHandType == 0xB) { Vec3f sp68; @@ -306,37 +305,36 @@ void ArmsHook_Draw(Actor* thisx, GlobalContext* globalCtx) { f32 sp4C; f32 sp48; - OPEN_DISPS(globalCtx->state.gfxCtx); + OPEN_DISPS(play->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->unk_1C4.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_8012C28C(globalCtx->state.gfxCtx); - func_80122868(globalCtx, player); + func_80126440(play, &this->collider, &this->unk_1C4, &sp5C, &sp50); + func_8012C28C(play->state.gfxCtx); + func_80122868(play, player); - gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(play->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); + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_OPA_DISP++, gameplay_keep_DL_0008D0); - func_801229A0(globalCtx, player); + func_801229A0(play, player); - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->state.gfxCtx); } } 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..7afe3a2ce 100644 --- a/src/overlays/actors/ovl_Arms_Hook/z_arms_hook.h +++ b/src/overlays/actors/ovl_Arms_Hook/z_arms_hook.h @@ -5,18 +5,17 @@ struct ArmsHook; -typedef void (*ArmsHookActionFunc)(struct ArmsHook*, GlobalContext*); +typedef void (*ArmsHookActionFunc)(struct ArmsHook*, PlayState*); typedef struct ArmsHook { /* 0x000 */ Actor actor; /* 0x144 */ ColliderQuad collider; - /* 0x1C4 */ s32 unk1C4; - /* 0x1C8 */ char unk1C8[0x18]; + /* 0x1C4 */ WeaponInfo unk_1C4; /* 0x1E0 */ Vec3f unk1E0; /* 0x1EC */ Vec3f unk1EC; /* 0x1F8 */ Actor* grabbed; /* 0x1FC */ Vec3f unk1FC; - /* 0x208 */ char unk208[0x2]; + /* 0x208 */ UNK_TYPE1 unk208[0x2]; /* 0x20A */ s16 timer; /* 0x20C */ ArmsHookActionFunc actionFunc; } ArmsHook; // size = 0x210 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 0b9bedbb8..16e4832a8 100644 --- a/src/overlays/actors/ovl_Arrow_Fire/z_arrow_fire.c +++ b/src/overlays/actors/ovl_Arrow_Fire/z_arrow_fire.c @@ -11,13 +11,13 @@ #define THIS ((ArrowFire*)thisx) -void ArrowFire_Init(Actor* thisx, GlobalContext* globalCtx); -void ArrowFire_Destroy(Actor* thisx, GlobalContext* globalCtx); -void ArrowFire_Update(Actor* thisx, GlobalContext* globalCtx); -void ArrowFire_Draw(Actor* thisx, GlobalContext* globalCtx); +void ArrowFire_Init(Actor* thisx, PlayState* play); +void ArrowFire_Destroy(Actor* thisx, PlayState* play); +void ArrowFire_Update(Actor* thisx, PlayState* play); +void ArrowFire_Draw(Actor* thisx, PlayState* play); -void FireArrow_ChargeAndWait(ArrowFire* this, GlobalContext* globalCtx); -void FireArrow_Fly(ArrowFire* this, GlobalContext* globalCtx); +void FireArrow_ChargeAndWait(ArrowFire* this, PlayState* play); +void FireArrow_Fly(ArrowFire* this, PlayState* play); #include "overlays/ovl_Arrow_fire/ovl_Arrow_Fire.c" @@ -63,7 +63,7 @@ void ArrowFire_SetupAction(ArrowFire* this, ArrowFireActionFunc actionFunc) { this->actionFunc = actionFunc; } -void ArrowFire_Init(Actor* thisx, GlobalContext* globalCtx) { +void ArrowFire_Init(Actor* thisx, PlayState* play) { ArrowFire* this = THIS; Actor_ProcessInitChain(&this->actor, sInitChain); @@ -74,19 +74,19 @@ void ArrowFire_Init(Actor* thisx, GlobalContext* globalCtx) { 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); + Collider_InitAndSetQuad(play, &this->collider1, &this->actor, &sQuadInit); + Collider_InitAndSetQuad(play, &this->collider2, &this->actor, &sQuadInit); } -void ArrowFire_Destroy(Actor* thisx, GlobalContext* globalCtx) { +void ArrowFire_Destroy(Actor* thisx, PlayState* play) { ArrowFire* this = THIS; - func_80115D5C(&globalCtx->state); - Collider_DestroyQuad(globalCtx, &this->collider1); - Collider_DestroyQuad(globalCtx, &this->collider2); + func_80115D5C(&play->state); + Collider_DestroyQuad(play, &this->collider1); + Collider_DestroyQuad(play, &this->collider2); } -void FireArrow_ChargeAndWait(ArrowFire* this, GlobalContext* globalCtx) { +void FireArrow_ChargeAndWait(ArrowFire* this, PlayState* play) { EnArrow* arrow = (EnArrow*)this->actor.parent; if ((arrow == NULL) || (arrow->actor.update == NULL)) { @@ -115,7 +115,7 @@ void FireArrow_Lerp(Vec3f* firedPos, Vec3f* pos, f32 scale) { VEC3F_LERPIMPDST(firedPos, firedPos, pos, scale); } -void FireArrow_Hit(ArrowFire* this, GlobalContext* globalCtx) { +void FireArrow_Hit(ArrowFire* this, PlayState* play) { f32 offset; f32 scale; u16 timer; @@ -160,12 +160,12 @@ void FireArrow_Hit(ArrowFire* this, GlobalContext* globalCtx) { return; } if (this->timer >= 13) { - CollisionCheck_SetAT(globalCtx, &globalCtx->colChkCtx, &this->collider1.base); - CollisionCheck_SetAT(globalCtx, &globalCtx->colChkCtx, &this->collider2.base); + CollisionCheck_SetAT(play, &play->colChkCtx, &this->collider1.base); + CollisionCheck_SetAT(play, &play->colChkCtx, &this->collider2.base); } } -void FireArrow_Fly(ArrowFire* this, GlobalContext* globalCtx) { +void FireArrow_Fly(ArrowFire* this, PlayState* play) { EnArrow* arrow = (EnArrow*)this->actor.parent; s32 pad; s32 pad2; @@ -201,14 +201,14 @@ void FireArrow_Fly(ArrowFire* this, GlobalContext* globalCtx) { } } -void ArrowFire_Update(Actor* thisx, GlobalContext* globalCtx) { +void ArrowFire_Update(Actor* thisx, PlayState* play) { ArrowFire* this = (ArrowFire*)thisx; - if ((globalCtx->msgCtx.msgMode == 0xE) || (globalCtx->msgCtx.msgMode == 0x12)) { + if ((play->msgCtx.msgMode == 0xE) || (play->msgCtx.msgMode == 0x12)) { Actor_MarkForDeath(&this->actor); return; } - this->actionFunc(this, globalCtx); + this->actionFunc(this, play); } void FireArrow_SetQuadVerticies(ArrowFire* this) { @@ -225,22 +225,22 @@ void FireArrow_SetQuadVerticies(ArrowFire* this) { Vec3f sp2C; Vec3f sp20; - Matrix_MultiplyVector3fByState(&D_80922284, &sp44); - Matrix_MultiplyVector3fByState(&D_80922290, &sp38); - Matrix_MultiplyVector3fByState(&D_8092229C, &sp2C); - Matrix_MultiplyVector3fByState(&D_809222A8, &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_MultiplyVector3fByState(&D_809222B4, &sp44); - Matrix_MultiplyVector3fByState(&D_809222C0, &sp38); - Matrix_MultiplyVector3fByState(&D_809222CC, &sp2C); - Matrix_MultiplyVector3fByState(&D_809222D8, &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) { +void ArrowFire_Draw(Actor* thisx, PlayState* play) { EnArrow* arrow; ArrowFire* this = THIS; - u32 frames = globalCtx->state.frames; + u32 frames = play->state.frames; s32 pad; arrow = (EnArrow*)this->actor.parent; @@ -248,11 +248,11 @@ void ArrowFire_Draw(Actor* thisx, GlobalContext* globalCtx) { if ((arrow != NULL) && (arrow->actor.update != NULL) && (this->timer < 255)) { Actor* transform = (arrow->unk_261 & 2) ? &this->actor : &arrow->actor; - OPEN_DISPS(globalCtx->state.gfxCtx); - Matrix_InsertTranslation(transform->world.pos.x, transform->world.pos.y, transform->world.pos.z, MTXMODE_NEW); - Matrix_RotateY(transform->shape.rot.y, MTXMODE_APPLY); - Matrix_InsertXRotation_s(transform->shape.rot.x, MTXMODE_APPLY); - Matrix_InsertZRotation_s(transform->shape.rot.z, MTXMODE_APPLY); + OPEN_DISPS(play->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) { @@ -266,31 +266,30 @@ void ArrowFire_Draw(Actor* thisx, GlobalContext* globalCtx) { gSPDisplayList(POLY_XLU_DISP++, D_0E000000.fillRect); } - func_8012C2DC(globalCtx->state.gfxCtx); + func_8012C2DC(play->state.gfxCtx); gDPSetPrimColor(POLY_XLU_DISP++, 0x80, 0x80, 255, 200, 0, this->alpha); gDPSetEnvColor(POLY_XLU_DISP++, 255, 0, 0, 128); - Matrix_InsertRotation(0x4000, 0, 0, MTXMODE_APPLY); + 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 * 4.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); + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(play->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++, Gfx_TwoTexScroll(play->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); + CLOSE_DISPS(play->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 5f9617c65..ce43cc5ed 100644 --- a/src/overlays/actors/ovl_Arrow_Fire/z_arrow_fire.h +++ b/src/overlays/actors/ovl_Arrow_Fire/z_arrow_fire.h @@ -5,7 +5,7 @@ struct ArrowFire; -typedef void (*ArrowFireActionFunc)(struct ArrowFire*, GlobalContext*); +typedef void (*ArrowFireActionFunc)(struct ArrowFire*, PlayState*); typedef struct ArrowFire { /* 0x000 */ Actor actor; 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 8a402dfbe..7c4f1f969 100644 --- a/src/overlays/actors/ovl_Arrow_Ice/z_arrow_ice.c +++ b/src/overlays/actors/ovl_Arrow_Ice/z_arrow_ice.c @@ -11,13 +11,13 @@ #define THIS ((ArrowIce*)thisx) -void ArrowIce_Init(Actor* thisx, GlobalContext* globalCtx); -void ArrowIce_Destroy(Actor* thisx, GlobalContext* globalCtx); -void ArrowIce_Update(Actor* thisx, GlobalContext* globalCtx); -void ArrowIce_Draw(Actor* thisx, GlobalContext* globalCtx); +void ArrowIce_Init(Actor* thisx, PlayState* play); +void ArrowIce_Destroy(Actor* thisx, PlayState* play); +void ArrowIce_Update(Actor* thisx, PlayState* play); +void ArrowIce_Draw(Actor* thisx, PlayState* play); -void ArrowIce_Charge(ArrowIce* this, GlobalContext* globalCtx); -void ArrowIce_Fly(ArrowIce* this, GlobalContext* globalCtx); +void ArrowIce_Charge(ArrowIce* this, PlayState* play); +void ArrowIce_Fly(ArrowIce* this, PlayState* play); #include "overlays/ovl_Arrow_Ice/ovl_Arrow_Ice.c" @@ -43,7 +43,7 @@ void ArrowIce_SetupAction(ArrowIce* this, ArrowIceActionFunc actionFunc) { this->actionFunc = actionFunc; } -void ArrowIce_Init(Actor* thisx, GlobalContext* globalCtx) { +void ArrowIce_Init(Actor* thisx, PlayState* play) { ArrowIce* this = THIS; Actor_ProcessInitChain(&this->actor, sInitChain); @@ -56,12 +56,12 @@ void ArrowIce_Init(Actor* thisx, GlobalContext* globalCtx) { this->blueingEffectMagnitude = 0.0f; } -void ArrowIce_Destroy(Actor* thisx, GlobalContext* globalCtx) { - func_80115D5C(&globalCtx->state); +void ArrowIce_Destroy(Actor* thisx, PlayState* play) { + func_80115D5C(&play->state); (void)"消滅"; // Unreferenced in retail, means "Disappearance" } -void ArrowIce_Charge(ArrowIce* this, GlobalContext* globalCtx) { +void ArrowIce_Charge(ArrowIce* this, PlayState* play) { EnArrow* arrow = (EnArrow*)this->actor.parent; if ((arrow == NULL) || (arrow->actor.update == NULL)) { @@ -91,7 +91,7 @@ void ArrowIce_LerpFiredPosition(Vec3f* firedPos, Vec3f* icePos, f32 scale) { VEC3F_LERPIMPDST(firedPos, firedPos, icePos, scale); } -void ArrowIce_Hit(ArrowIce* this, GlobalContext* globalCtx) { +void ArrowIce_Hit(ArrowIce* this, PlayState* play) { f32 scale; u16 timer; @@ -140,7 +140,7 @@ void ArrowIce_Hit(ArrowIce* this, GlobalContext* globalCtx) { } } -void ArrowIce_Fly(ArrowIce* this, GlobalContext* globalCtx) { +void ArrowIce_Fly(ArrowIce* this, PlayState* play) { EnArrow* arrow = (EnArrow*)this->actor.parent; f32 distanceScaled; s32 pad; @@ -173,33 +173,33 @@ void ArrowIce_Fly(ArrowIce* this, GlobalContext* globalCtx) { } } -void ArrowIce_Update(Actor* thisx, GlobalContext* globalCtx) { +void ArrowIce_Update(Actor* thisx, PlayState* play) { ArrowIce* this = THIS; - if ((globalCtx->msgCtx.msgMode == 0xE) || (globalCtx->msgCtx.msgMode == 0x12)) { + if ((play->msgCtx.msgMode == 0xE) || (play->msgCtx.msgMode == 0x12)) { Actor_MarkForDeath(&this->actor); return; } else { - this->actionFunc(this, globalCtx); + this->actionFunc(this, play); } } -void ArrowIce_Draw(Actor* thisx, GlobalContext* globalCtx) { +void ArrowIce_Draw(Actor* thisx, PlayState* play) { s32 pad; ArrowIce* this = THIS; Actor* transform; - u32 stateFrames = globalCtx->state.frames; + u32 stateFrames = play->state.frames; EnArrow* arrow = (EnArrow*)this->actor.parent; if ((arrow != NULL) && (arrow->actor.update != NULL) && (this->timer < 255)) { transform = (arrow->unk_261 & 2) ? &this->actor : &arrow->actor; - OPEN_DISPS(globalCtx->state.gfxCtx); + OPEN_DISPS(play->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 @@ -214,24 +214,24 @@ void ArrowIce_Draw(Actor* thisx, GlobalContext* globalCtx) { } // Draw ice on the arrow - func_8012C2DC(globalCtx->state.gfxCtx); + func_8012C2DC(play->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); - gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + Matrix_Translate(0.0f, -700.0f, 0.0f, MTXMODE_APPLY); + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_XLU_DISP++, gIceArrowMaterialDL); gSPDisplayList(POLY_XLU_DISP++, - Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, 511 - (stateFrames * 5) % 512, 0, 128, 32, 1, + Gfx_TwoTexScroll(play->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++, gIceArrowModelDL); - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->state.gfxCtx); } } diff --git a/src/overlays/actors/ovl_Arrow_Ice/z_arrow_ice.h b/src/overlays/actors/ovl_Arrow_Ice/z_arrow_ice.h index a731d9d44..a90cfe0ae 100644 --- a/src/overlays/actors/ovl_Arrow_Ice/z_arrow_ice.h +++ b/src/overlays/actors/ovl_Arrow_Ice/z_arrow_ice.h @@ -5,17 +5,17 @@ struct ArrowIce; -typedef void (*ArrowIceActionFunc)(struct ArrowIce*, GlobalContext*); +typedef void (*ArrowIceActionFunc)(struct ArrowIce*, PlayState*); typedef struct ArrowIce { - /* 0x0000 */ Actor actor; - /* 0x0144 */ s16 radius; - /* 0x0146 */ u16 timer; - /* 0x0148 */ u8 alpha; - /* 0x014C */ Vec3f firedPos; - /* 0x0158 */ f32 height; - /* 0x015C */ f32 blueingEffectMagnitude; - /* 0x0160 */ ArrowIceActionFunc actionFunc; + /* 0x000 */ Actor actor; + /* 0x144 */ s16 radius; + /* 0x146 */ u16 timer; + /* 0x148 */ u8 alpha; + /* 0x14C */ Vec3f firedPos; + /* 0x158 */ f32 height; + /* 0x15C */ f32 blueingEffectMagnitude; + /* 0x160 */ ArrowIceActionFunc actionFunc; } ArrowIce; // size = 0x164 extern const ActorInit Arrow_Ice_InitVars; diff --git a/src/overlays/actors/ovl_Arrow_Light/z_arrow_light.c b/src/overlays/actors/ovl_Arrow_Light/z_arrow_light.c index ac8eb1ae9..1a7503e54 100644 --- a/src/overlays/actors/ovl_Arrow_Light/z_arrow_light.c +++ b/src/overlays/actors/ovl_Arrow_Light/z_arrow_light.c @@ -11,13 +11,13 @@ #define THIS ((ArrowLight*)thisx) -void ArrowLight_Init(Actor* thisx, GlobalContext* globalCtx); -void ArrowLight_Destroy(Actor* thisx, GlobalContext* globalCtx); -void ArrowLight_Update(Actor* thisx, GlobalContext* globalCtx); -void ArrowLight_Draw(Actor* thisx, GlobalContext* globalCtx); +void ArrowLight_Init(Actor* thisx, PlayState* play); +void ArrowLight_Destroy(Actor* thisx, PlayState* play); +void ArrowLight_Update(Actor* thisx, PlayState* play); +void ArrowLight_Draw(Actor* thisx, PlayState* play); -void ArrowLight_Charge(ArrowLight* this, GlobalContext* globalCtx); -void ArrowLight_Fly(ArrowLight* this, GlobalContext* globalCtx); +void ArrowLight_Charge(ArrowLight* this, PlayState* play); +void ArrowLight_Fly(ArrowLight* this, PlayState* play); #include "overlays/ovl_Arrow_Light/ovl_Arrow_Light.c" @@ -43,7 +43,7 @@ void ArrowLight_SetupAction(ArrowLight* this, ArrowLightActionFunc actionFunc) { this->actionFunc = actionFunc; } -void ArrowLight_Init(Actor* thisx, GlobalContext* globalCtx) { +void ArrowLight_Init(Actor* thisx, PlayState* play) { ArrowLight* this = (ArrowLight*)thisx; Actor_ProcessInitChain(&this->actor, sInitChain); this->radius = 0; @@ -55,12 +55,12 @@ void ArrowLight_Init(Actor* thisx, GlobalContext* globalCtx) { this->screenFillIntensity = 0.0f; } -void ArrowLight_Destroy(Actor* thisx, GlobalContext* globalCtx) { - func_80115D5C(&globalCtx->state); +void ArrowLight_Destroy(Actor* thisx, PlayState* play) { + func_80115D5C(&play->state); (void)"消滅"; // Unreferenced in retail, means "Disappearance" } -void ArrowLight_Charge(ArrowLight* this, GlobalContext* globalCtx) { +void ArrowLight_Charge(ArrowLight* this, PlayState* play) { EnArrow* arrow = (EnArrow*)this->actor.parent; if ((arrow == NULL) || (arrow->actor.update == NULL)) { @@ -88,7 +88,7 @@ void ArrowLight_Lerp(Vec3f* firedPos, Vec3f* pos, f32 scale) { VEC3F_LERPIMPDST(firedPos, firedPos, pos, scale); } -void ArrowLight_Hit(ArrowLight* this, GlobalContext* globalCtx) { +void ArrowLight_Hit(ArrowLight* this, PlayState* play) { f32 scale; u16 timer; @@ -134,7 +134,7 @@ void ArrowLight_Hit(ArrowLight* this, GlobalContext* globalCtx) { } } -void ArrowLight_Fly(ArrowLight* this, GlobalContext* globalCtx) { +void ArrowLight_Fly(ArrowLight* this, PlayState* play) { EnArrow* arrow = (EnArrow*)this->actor.parent; s32 pad[2]; @@ -169,31 +169,31 @@ void ArrowLight_Fly(ArrowLight* this, GlobalContext* globalCtx) { } } -void ArrowLight_Update(Actor* thisx, GlobalContext* globalCtx) { +void ArrowLight_Update(Actor* thisx, PlayState* play) { ArrowLight* this = THIS; - if ((globalCtx->msgCtx.msgMode == 0xE) || (globalCtx->msgCtx.msgMode == 0x12)) { + if ((play->msgCtx.msgMode == 0xE) || (play->msgCtx.msgMode == 0x12)) { Actor_MarkForDeath(&this->actor); return; } - this->actionFunc(this, globalCtx); + this->actionFunc(this, play); } -void ArrowLight_Draw(Actor* thisx, GlobalContext* globalCtx) { +void ArrowLight_Draw(Actor* thisx, PlayState* play) { s32 pad; ArrowLight* this = (ArrowLight*)thisx; - u32 frames = globalCtx->state.frames; + u32 frames = play->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); + OPEN_DISPS(play->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); if (this->screenFillIntensity > 0.0f) { POLY_XLU_DISP = func_8012BFC4(POLY_XLU_DISP); @@ -205,26 +205,26 @@ void ArrowLight_Draw(Actor* thisx, GlobalContext* globalCtx) { gSPDisplayList(POLY_XLU_DISP++, D_0E000000.fillRect); } - func_8012C2DC(globalCtx->state.gfxCtx); + func_8012C2DC(play->state.gfxCtx); gDPSetPrimColor(POLY_XLU_DISP++, 0x80, 0x80, 255, 255, 170, this->alpha); gDPSetEnvColor(POLY_XLU_DISP++, 255, 255, 0, 128); - Matrix_InsertRotation(0x4000, 0, 0, MTXMODE_APPLY); + 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 * 4.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); + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(play->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, + Gfx_TwoTexScroll(play->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); + CLOSE_DISPS(play->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 7b3f3088f..bf58b1e40 100644 --- a/src/overlays/actors/ovl_Arrow_Light/z_arrow_light.h +++ b/src/overlays/actors/ovl_Arrow_Light/z_arrow_light.h @@ -5,7 +5,7 @@ struct ArrowLight; -typedef void (*ArrowLightActionFunc)(struct ArrowLight*, GlobalContext*); +typedef void (*ArrowLightActionFunc)(struct ArrowLight*, PlayState*); typedef struct ArrowLight { /* 0x000 */ Actor actor; 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..ab7ac8a52 100644 --- a/src/overlays/actors/ovl_Bg_Astr_Bombwall/z_bg_astr_bombwall.c +++ b/src/overlays/actors/ovl_Bg_Astr_Bombwall/z_bg_astr_bombwall.c @@ -5,17 +5,24 @@ */ #include "z_bg_astr_bombwall.h" +#include "objects/object_astr_obj/object_astr_obj.h" #define FLAGS 0x00000000 #define THIS ((BgAstrBombwall*)thisx) -void BgAstrBombwall_Init(Actor* thisx, GlobalContext* globalCtx); -void BgAstrBombwall_Destroy(Actor* thisx, GlobalContext* globalCtx); -void BgAstrBombwall_Update(Actor* thisx, GlobalContext* globalCtx); -void BgAstrBombwall_Draw(Actor* thisx, GlobalContext* globalCtx); +void BgAstrBombwall_Init(Actor* thisx, PlayState* play); +void BgAstrBombwall_Destroy(Actor* thisx, PlayState* play); +void BgAstrBombwall_Update(Actor* thisx, PlayState* play); +void BgAstrBombwall_Draw(Actor* thisx, PlayState* play); + +void func_80C0A378(BgAstrBombwall* this); +void func_80C0A38C(BgAstrBombwall* this, PlayState* play); +void func_80C0A400(BgAstrBombwall* this, PlayState* play); +void func_80C0A418(BgAstrBombwall* this, PlayState* play); +void func_80C0A458(BgAstrBombwall* this, PlayState* play); +void func_80C0A4BC(BgAstrBombwall* this, PlayState* play); -#if 0 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, + }, + ARRAY_COUNT(sTrisElementsInit), + 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, PlayState* play) { + 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(play, &this->dyna, &object_astr_obj_Colheader_002498); + Collider_InitTris(play, &this->collider); + if (Flags_GetSwitch(play, BGASTRBOMBWALL_GET_SWITCHFLAG(thisx))) { + Actor_MarkForDeath(&this->dyna.actor); + return; + } + this->dyna.actor.flags |= ACTOR_FLAG_10000000; + if (!Collider_SetTris(play, &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, PlayState* play) { + BgAstrBombwall* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Astr_Bombwall/func_80C0A120.s") + DynaPoly_DeleteBgActor(play, &play->colCtx.dyna, this->dyna.bgId); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Astr_Bombwall/func_80C0A378.s") +void func_80C0A120(BgAstrBombwall* this, PlayState* play) { + 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(play, &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(play, &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, PlayState* play) { + if (this->collider.base.acFlags & AC_HIT) { + this->collider.base.acFlags &= ~AC_HIT; + Flags_SetSwitch(play, BGASTRBOMBWALL_GET_SWITCHFLAG(&this->dyna.actor)); + func_80C0A400(this, play); + } else { + CollisionCheck_SetAC(play, &play->colChkCtx, &this->collider.base); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Astr_Bombwall/func_80C0A4BC.s") +void func_80C0A400(BgAstrBombwall* this, PlayState* play) { + this->actionFunc = func_80C0A418; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Astr_Bombwall/BgAstrBombwall_Update.s") +void func_80C0A418(BgAstrBombwall* this, PlayState* play) { + if (SubS_StartActorCutscene(&this->dyna.actor, this->cutscenes[0], -1, SUBS_CUTSCENE_SET_UNK_LINK_FIELDS)) { + func_80C0A458(this, play); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Astr_Bombwall/BgAstrBombwall_Draw.s") +void func_80C0A458(BgAstrBombwall* this, PlayState* play) { + func_800C62BC(play, &play->colCtx.dyna, this->dyna.bgId); + this->dyna.actor.draw = NULL; + func_80C0A120(this, play); + Actor_PlaySfxAtPos(&this->dyna.actor, NA_SE_EV_WALL_BROKEN); + this->actionFunc = func_80C0A4BC; +} + +void func_80C0A4BC(BgAstrBombwall* this, PlayState* play) { +} + +void BgAstrBombwall_Update(Actor* thisx, PlayState* play) { + BgAstrBombwall* this = THIS; + + this->actionFunc(this, play); +} + +void BgAstrBombwall_Draw(Actor* thixs, PlayState* play) { + { + Gfx* opa; + + OPEN_DISPS(play->state.gfxCtx); + opa = POLY_OPA_DISP; + gSPDisplayList(&opa[0], &sSetupDL[25 * 6]); + gSPMatrix(&opa[1], Matrix_NewMtx(play->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(play->state.gfxCtx); + } + { + Gfx* xlu; + + OPEN_DISPS(play->state.gfxCtx); + xlu = POLY_XLU_DISP; + gSPDisplayList(&xlu[0], &sSetupDL[25 * 6]); + gSPMatrix(&xlu[1], Matrix_NewMtx(play->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(play->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..58b60b944 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; -typedef void (*BgAstrBombwallActionFunc)(struct BgAstrBombwall*, GlobalContext*); +#define BGASTRBOMBWALL_GET_SWITCHFLAG(thisx) ((thisx)->params & 0x7F) +typedef void (*BgAstrBombwallActionFunc)(struct BgAstrBombwall*, PlayState*); 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_Botihasira/z_bg_botihasira.c b/src/overlays/actors/ovl_Bg_Botihasira/z_bg_botihasira.c index 7ca6678ff..dfa31a6a0 100644 --- a/src/overlays/actors/ovl_Bg_Botihasira/z_bg_botihasira.c +++ b/src/overlays/actors/ovl_Bg_Botihasira/z_bg_botihasira.c @@ -5,17 +5,19 @@ */ #include "z_bg_botihasira.h" +#include "objects/object_botihasira/object_botihasira.h" #define FLAGS 0x00000000 #define THIS ((BgBotihasira*)thisx) -void BgBotihasira_Init(Actor* thisx, GlobalContext* globalCtx); -void BgBotihasira_Destroy(Actor* thisx, GlobalContext* globalCtx); -void BgBotihasira_Update(Actor* thisx, GlobalContext* globalCtx); -void BgBotihasira_Draw(Actor* thisx, GlobalContext* globalCtx); +void BgBotihasira_Init(Actor* thisx, PlayState* play); +void BgBotihasira_Destroy(Actor* thisx, PlayState* play); +void BgBotihasira_Update(Actor* thisx, PlayState* play2); +void BgBotihasira_Draw(Actor* thisx, PlayState* play); + +void BgBotihasira_DoNothing(BgBotihasira* this, PlayState* play); -#if 0 const ActorInit Bg_Botihasira_InitVars = { ACTOR_BG_BOTIHASIRA, ACTORCAT_ITEMACTION, @@ -28,26 +30,74 @@ const ActorInit Bg_Botihasira_InitVars = { (ActorFunc)BgBotihasira_Draw, }; -// static ColliderCylinderInit sCylinderInit = { -static ColliderCylinderInit D_80B282F0 = { - { COLTYPE_METAL, AT_NONE, AC_ON | AC_TYPE_PLAYER, OC1_ON | OC1_TYPE_ALL, OC2_TYPE_1, COLSHAPE_CYLINDER, }, - { ELEMTYPE_UNK2, { 0xF7CFFFFF, 0x00, 0x00 }, { 0xF7CFFFFF, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_ON, }, +static ColliderCylinderInit sCylinderInit = { + { + COLTYPE_METAL, + AT_NONE, + AC_ON | AC_TYPE_PLAYER, + OC1_ON | OC1_TYPE_ALL, + OC2_TYPE_1, + COLSHAPE_CYLINDER, + }, + { + ELEMTYPE_UNK2, + { 0xF7CFFFFF, 0x00, 0x00 }, + { 0xF7CFFFFF, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_ON, + }, { 27, 80, 0, { 0, 0, 0 } }, }; -#endif +void BgBotihasira_Init(Actor* thisx, PlayState* play) { + s32 pad; + BgBotihasira* this = THIS; + CollisionHeader* colHeader = NULL; -extern ColliderCylinderInit D_80B282F0; + if (this->dyna.actor.params == 0) { + DynaPolyActor_Init(&this->dyna, 0); + CollisionHeader_GetVirtual(&object_botihasira_Colheader_001BD8, &colHeader); + this->dyna.bgId = DynaPoly_SetBgActor(play, &play->colCtx.dyna, &this->dyna.actor, colHeader); + } else { + Collider_InitAndSetCylinder(play, &this->collider, &this->dyna.actor, &sCylinderInit); + } + this->actionFunc = BgBotihasira_DoNothing; + this->dyna.actor.scale.z = this->dyna.actor.scale.y = this->dyna.actor.scale.x = 0.1f; +} -extern UNK_TYPE D_06000638; -extern UNK_TYPE D_06001BD8; +void BgBotihasira_Destroy(Actor* thisx, PlayState* play) { + BgBotihasira* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Botihasira/BgBotihasira_Init.s") + if (this->dyna.actor.params == 0) { + DynaPoly_DeleteBgActor(play, &play->colCtx.dyna, this->dyna.bgId); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Botihasira/BgBotihasira_Destroy.s") +void BgBotihasira_DoNothing(BgBotihasira* this, PlayState* play) { +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Botihasira/func_80B2815C.s") +void BgBotihasira_Update(Actor* thisx, PlayState* play2) { + PlayState* play = play2; + BgBotihasira* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Botihasira/BgBotihasira_Update.s") + this->actionFunc(this, play); + if (this->dyna.actor.params != 0) { + this->dyna.actor.world.pos.x = this->dyna.actor.home.pos.x + (Math_SinS(this->dyna.actor.world.rot.y) * -27.0f); + this->dyna.actor.world.pos.z = this->dyna.actor.home.pos.z + (Math_CosS(this->dyna.actor.world.rot.y) * 7.0f); + Collider_UpdateCylinder(&this->dyna.actor, &this->collider); + CollisionCheck_SetAC(play, &play->colChkCtx, &this->collider.base); + CollisionCheck_SetOC(play, &play->colChkCtx, &this->collider.base); + Math_Vec3f_Copy(&this->dyna.actor.world.pos, &this->dyna.actor.home.pos); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Botihasira/BgBotihasira_Draw.s") +void BgBotihasira_Draw(Actor* thisx, PlayState* play) { + OPEN_DISPS(play->state.gfxCtx); + + func_8012C28C(play->state.gfxCtx); + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_OPA_DISP++, object_botihasira_DL_000638); + + CLOSE_DISPS(play->state.gfxCtx); +} diff --git a/src/overlays/actors/ovl_Bg_Botihasira/z_bg_botihasira.h b/src/overlays/actors/ovl_Bg_Botihasira/z_bg_botihasira.h index beed2391f..529b5a904 100644 --- a/src/overlays/actors/ovl_Bg_Botihasira/z_bg_botihasira.h +++ b/src/overlays/actors/ovl_Bg_Botihasira/z_bg_botihasira.h @@ -5,13 +5,12 @@ struct BgBotihasira; -typedef void (*BgBotihasiraActionFunc)(struct BgBotihasira*, GlobalContext*); +typedef void (*BgBotihasiraActionFunc)(struct BgBotihasira*, PlayState*); typedef struct BgBotihasira { - /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x18]; - /* 0x015C */ BgBotihasiraActionFunc actionFunc; - /* 0x0160 */ char unk_160[0x4C]; + /* 0x000 */ DynaPolyActor dyna; + /* 0x15C */ BgBotihasiraActionFunc actionFunc; + /* 0x160 */ ColliderCylinder collider; } BgBotihasira; // size = 0x1AC extern const ActorInit Bg_Botihasira_InitVars; diff --git a/src/overlays/actors/ovl_Bg_Breakwall/z_bg_breakwall.c b/src/overlays/actors/ovl_Bg_Breakwall/z_bg_breakwall.c index b2fe546cf..9a272e6aa 100644 --- a/src/overlays/actors/ovl_Bg_Breakwall/z_bg_breakwall.c +++ b/src/overlays/actors/ovl_Bg_Breakwall/z_bg_breakwall.c @@ -19,31 +19,31 @@ #define THIS ((BgBreakwall*)thisx) -void BgBreakwall_Init(Actor* thisx, GlobalContext* globalCtx); -void BgBreakwall_Update(Actor* thisx, GlobalContext* globalCtx); +void BgBreakwall_Init(Actor* thisx, PlayState* play); +void BgBreakwall_Update(Actor* thisx, PlayState* play); 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); +s32 func_808B736C(BgBreakwall* this, PlayState* play); +s32 func_808B7380(BgBreakwall* this, PlayState* play); +s32 func_808B73C4(BgBreakwall* this, PlayState* play); +s32 func_808B73FC(BgBreakwall* this, PlayState* play); +s32 func_808B7410(BgBreakwall* this, PlayState* play); +s32 func_808B7460(BgBreakwall* this, PlayState* play); +s32 func_808B74A8(BgBreakwall* this, PlayState* play); +s32 func_808B74D8(BgBreakwall* this, PlayState* play); +s32 func_808B751C(BgBreakwall* this, PlayState* play); +void func_808B76CC(BgBreakwall* this, PlayState* play); +void func_808B77D0(BgBreakwall* this, PlayState* play); +void func_808B77E0(BgBreakwall* this, PlayState* play); +void func_808B782C(BgBreakwall* this, PlayState* play); +void func_808B78A4(BgBreakwall* this, PlayState* play); +void func_808B78DC(BgBreakwall* this, PlayState* play); +void func_808B7914(BgBreakwall* this, PlayState* play); +void func_808B7A10(BgBreakwall* this, PlayState* play); +void func_808B7A90(Actor* thisx, PlayState* play); +void func_808B7B54(Actor* thisx, PlayState* play); +void func_808B7D34(Actor* thisx, PlayState* play); +void BgBreakwall_Draw(Actor* thisx, PlayState* play); const ActorInit Bg_Breakwall_InitVars = { ACTOR_BG_BREAKWALL, ACTORCAT_ITEMACTION, FLAGS, @@ -141,63 +141,63 @@ void BgBreakwall_SetupAction(BgBreakwall* this, BgBreakwallActionFunc actionFunc this->actionFunc = actionFunc; } -s32 func_808B736C(BgBreakwall* this, GlobalContext* globalCtx) { +s32 func_808B736C(BgBreakwall* this, PlayState* play) { return true; } -s32 func_808B7380(BgBreakwall* this, GlobalContext* globalCtx) { +s32 func_808B7380(BgBreakwall* this, PlayState* play) { if ((gSaveContext.save.day >= 2) && !(gSaveContext.save.weekEventReg[22] & 1)) { return false; } return true; } -s32 func_808B73C4(BgBreakwall* this, GlobalContext* globalCtx) { +s32 func_808B73C4(BgBreakwall* this, PlayState* play) { return (gSaveContext.save.weekEventReg[33] & 0x80) || (gSaveContext.save.weekEventReg[21] & 1); } -s32 func_808B73FC(BgBreakwall* this, GlobalContext* globalCtx) { +s32 func_808B73FC(BgBreakwall* this, PlayState* play) { return true; } -s32 func_808B7410(BgBreakwall* this, GlobalContext* globalCtx) { - if (Flags_GetSwitch(globalCtx, this->switchFlag)) { +s32 func_808B7410(BgBreakwall* this, PlayState* play) { + if (Flags_GetSwitch(play, this->switchFlag)) { this->dyna.actor.draw = NULL; } Actor_SetScale(&this->dyna.actor, 0.1f); return true; } -s32 func_808B7460(BgBreakwall* this, GlobalContext* globalCtx) { - if (!Flags_GetSwitch(globalCtx, this->switchFlag)) { +s32 func_808B7460(BgBreakwall* this, PlayState* play) { + if (!Flags_GetSwitch(play, this->switchFlag)) { this->dyna.actor.scale.x = 0.1f; } return true; } -s32 func_808B74A8(BgBreakwall* this, GlobalContext* globalCtx) { +s32 func_808B74A8(BgBreakwall* this, PlayState* play) { if (gSaveContext.save.weekEventReg[55] & 0x80) { return false; } return true; } -s32 func_808B74D8(BgBreakwall* this, GlobalContext* globalCtx) { +s32 func_808B74D8(BgBreakwall* this, PlayState* play) { if (!(gSaveContext.save.weekEventReg[9] & 0x80) || (gSaveContext.save.weekEventReg[23] & 0x20)) { return false; } return true; } -s32 func_808B751C(BgBreakwall* this, GlobalContext* globalCtx) { +s32 func_808B751C(BgBreakwall* this, PlayState* play) { Actor_SetScale(&this->dyna.actor, 0.1f); if ((BGBREAKWALL_SWITCHFLAG(&this->dyna.actor) != 0x7F) && - !Flags_GetSwitch(globalCtx, BGBREAKWALL_SWITCHFLAG(&this->dyna.actor))) { + !Flags_GetSwitch(play, BGBREAKWALL_SWITCHFLAG(&this->dyna.actor))) { return false; } - func_800FEA50(globalCtx); + func_800FEA50(play); if (gSaveContext.save.isNight) { this->unk_15E = 0; @@ -207,15 +207,15 @@ s32 func_808B751C(BgBreakwall* this, GlobalContext* globalCtx) { return true; } -void BgBreakwall_Init(Actor* thisx, GlobalContext* globalCtx) { +void BgBreakwall_Init(Actor* thisx, PlayState* play) { s32 pad; BgBreakwall* this = THIS; BgBreakwallStruct* sp24 = &D_808B8140[BGBREAKWALL_GET_F(&this->dyna.actor)]; Actor_ProcessInitChain(&this->dyna.actor, sInitChain); - this->unk_15C = Object_GetIndex(&globalCtx->objectCtx, sp24->unk_00); + this->unk_15C = Object_GetIndex(&play->objectCtx, sp24->unk_00); - if ((this->unk_15C < 0) || !sp24->unk_14(this, globalCtx)) { + if ((this->unk_15C < 0) || !sp24->unk_14(this, play)) { Actor_MarkForDeath(&this->dyna.actor); return; } @@ -224,17 +224,17 @@ void BgBreakwall_Init(Actor* thisx, GlobalContext* globalCtx) { this->switchFlag = BGBREAKWALL_SWITCHFLAG(&this->dyna.actor); } -void BgBreakwall_Destroy(Actor* thisx, GlobalContext* globalCtx) { +void BgBreakwall_Destroy(Actor* thisx, PlayState* play) { BgBreakwall* this = THIS; BgBreakwallStruct* temp_s1 = &D_808B8140[BGBREAKWALL_GET_F(&this->dyna.actor)]; if (temp_s1->unk_10 != NULL) { - DynaPoly_DeleteBgActor(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); + DynaPoly_DeleteBgActor(play, &play->colCtx.dyna, this->dyna.bgId); } } -void func_808B76CC(BgBreakwall* this, GlobalContext* globalCtx) { - if (Object_IsLoaded(&globalCtx->objectCtx, this->unk_15C)) { +void func_808B76CC(BgBreakwall* this, PlayState* play) { + if (Object_IsLoaded(&play->objectCtx, this->unk_15C)) { BgBreakwallStruct* temp_s1 = &D_808B8140[BGBREAKWALL_GET_F(&this->dyna.actor)]; this->dyna.actor.objBankIndex = this->unk_15C; @@ -246,7 +246,7 @@ void func_808B76CC(BgBreakwall* this, GlobalContext* globalCtx) { this->dyna.actor.flags &= ~ACTOR_FLAG_10; } - Actor_SetObjectDependency(globalCtx, &this->dyna.actor); + Actor_SetObjectDependency(play, &this->dyna.actor); if (temp_s1->unk_0C != NULL) { temp_s1->unk_0C = Lib_SegmentedToVirtual(temp_s1->unk_0C); @@ -254,7 +254,7 @@ void func_808B76CC(BgBreakwall* this, GlobalContext* globalCtx) { if (temp_s1->unk_10 != NULL) { DynaPolyActor_Init(&this->dyna, 0); - DynaPolyActor_LoadMesh(globalCtx, &this->dyna, temp_s1->unk_10); + DynaPolyActor_LoadMesh(play, &this->dyna, temp_s1->unk_10); } BgBreakwall_SetupAction(this, temp_s1->unk_18); @@ -262,21 +262,21 @@ void func_808B76CC(BgBreakwall* this, GlobalContext* globalCtx) { } } -void func_808B77D0(BgBreakwall* this, GlobalContext* globalCtx) { +void func_808B77D0(BgBreakwall* this, PlayState* play) { } -void func_808B77E0(BgBreakwall* this, GlobalContext* globalCtx) { - if (!Flags_GetSwitch(globalCtx, this->switchFlag)) { +void func_808B77E0(BgBreakwall* this, PlayState* play) { + if (!Flags_GetSwitch(play, this->switchFlag)) { this->dyna.actor.draw = BgBreakwall_Draw; } else { this->dyna.actor.draw = NULL; } } -void func_808B782C(BgBreakwall* this, GlobalContext* globalCtx) { +void func_808B782C(BgBreakwall* this, PlayState* play) { f32 phi_f0; - if (Flags_GetSwitch(globalCtx, this->switchFlag)) { + if (Flags_GetSwitch(play, this->switchFlag)) { phi_f0 = 1.0f; } else { phi_f0 = 0.1f; @@ -284,23 +284,23 @@ void func_808B782C(BgBreakwall* this, GlobalContext* globalCtx) { Math_SmoothStepToF(&this->dyna.actor.scale.x, phi_f0, 0.2f, 0.3f, 0.06f); } -void func_808B78A4(BgBreakwall* this, GlobalContext* globalCtx) { +void func_808B78A4(BgBreakwall* this, PlayState* play) { if (gSaveContext.save.weekEventReg[55] & 0x80) { Actor_MarkForDeath(&this->dyna.actor); } } -void func_808B78DC(BgBreakwall* this, GlobalContext* globalCtx) { +void func_808B78DC(BgBreakwall* this, PlayState* play) { 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) { +void func_808B7914(BgBreakwall* this, PlayState* play) { s32 pad; Vec3f sp30; Vec3f sp24; - if ((globalCtx->gameplayFrames % 8) == 0) { + if ((play->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); @@ -309,11 +309,11 @@ void func_808B7914(BgBreakwall* this, GlobalContext* globalCtx) { sp24.y = 0.5f; sp24.z = 0.0f; - EffectSsIceSmoke_Spawn(globalCtx, &sp30, &sp24, &gZeroVec3f, -200 - (s32)(Rand_ZeroOne() * 50.0f)); + EffectSsIceSmoke_Spawn(play, &sp30, &sp24, &gZeroVec3f, -200 - (s32)(Rand_ZeroOne() * 50.0f)); } } -void func_808B7A10(BgBreakwall* this, GlobalContext* globalCtx) { +void func_808B7A10(BgBreakwall* this, PlayState* play) { if (gSaveContext.save.isNight) { if (this->unk_15E < 245) { this->unk_15E += 10; @@ -327,17 +327,17 @@ void func_808B7A10(BgBreakwall* this, GlobalContext* globalCtx) { } } -void BgBreakwall_Update(Actor* thisx, GlobalContext* globalCtx) { +void BgBreakwall_Update(Actor* thisx, PlayState* play) { BgBreakwall* this = THIS; - this->actionFunc(this, globalCtx); + this->actionFunc(this, play); } -void func_808B7A90(Actor* thisx, GlobalContext* globalCtx) { +void func_808B7A90(Actor* thisx, PlayState* play) { Color_RGBA8 sp2C; Color_RGBA8 sp28; - OPEN_DISPS(globalCtx->state.gfxCtx); + OPEN_DISPS(play->state.gfxCtx); func_800FE7A8(D_808B82F0, &sp2C); func_800FE7A8(D_808B8300, &sp28); @@ -345,19 +345,19 @@ void func_808B7A90(Actor* thisx, GlobalContext* globalCtx) { 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); + CLOSE_DISPS(play->state.gfxCtx); } -void func_808B7B54(Actor* thisx, GlobalContext* globalCtx) { +void func_808B7B54(Actor* thisx, PlayState* play) { s32 pad; Color_RGBA8 sp50; Color_RGBA8 sp4C; - OPEN_DISPS(globalCtx->state.gfxCtx); + OPEN_DISPS(play->state.gfxCtx); - func_8012C2DC(globalCtx->state.gfxCtx); + func_8012C2DC(play->state.gfxCtx); - gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); func_800FE7A8(D_808B8310, &sp50); func_800FE7A8(D_808B8330, &sp4C); @@ -373,17 +373,17 @@ void func_808B7B54(Actor* thisx, GlobalContext* globalCtx) { gDPSetEnvColor(POLY_XLU_DISP++, sp4C.r, sp4C.g, sp4C.b, 255); gSPDisplayList(POLY_XLU_DISP++, object_kumo30_DL_000C98); - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->state.gfxCtx); } -void func_808B7D34(Actor* thisx, GlobalContext* globalCtx) { +void func_808B7D34(Actor* thisx, PlayState* play) { BgBreakwall* this = THIS; s32 sp48; s32 tempA; s32 tempB; s32 tempC; - OPEN_DISPS(globalCtx->state.gfxCtx); + OPEN_DISPS(play->state.gfxCtx); sp48 = 255 - this->unk_15E; @@ -391,50 +391,50 @@ void func_808B7D34(Actor* thisx, GlobalContext* globalCtx) { 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)); + gSPSegment(POLY_XLU_DISP++, 0x09, Gfx_PrimColor(play->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)); + gSPSegment(POLY_XLU_DISP++, 0x0A, Gfx_PrimColor(play->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)); + gSPSegment(POLY_XLU_DISP++, 0x0B, Gfx_PrimColor(play->state.gfxCtx, 255, 255, 255, tempA, tempB)); - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->state.gfxCtx); } -void BgBreakwall_Draw(Actor* thisx, GlobalContext* globalCtx) { +void BgBreakwall_Draw(Actor* thisx, PlayState* play) { s32 pad; BgBreakwall* this = THIS; BgBreakwallStruct* temp_s2 = &D_808B8140[BGBREAKWALL_GET_F(&this->dyna.actor)]; - OPEN_DISPS(globalCtx->state.gfxCtx); + OPEN_DISPS(play->state.gfxCtx); if (temp_s2->unk_0C != NULL) { - AnimatedMat_Draw(globalCtx, temp_s2->unk_0C); + AnimatedMat_Draw(play, temp_s2->unk_0C); } if (temp_s2->unk_1C != NULL) { - temp_s2->unk_1C(&this->dyna.actor, globalCtx); + temp_s2->unk_1C(&this->dyna.actor, play); } if (temp_s2->unk_04 != NULL) { - func_8012C28C(globalCtx->state.gfxCtx); + func_8012C28C(play->state.gfxCtx); - gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(play->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); + func_8012C2DC(play->state.gfxCtx); - gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_XLU_DISP++, temp_s2->unk_08); } - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->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 322929344..77c1b8808 100644 --- a/src/overlays/actors/ovl_Bg_Breakwall/z_bg_breakwall.h +++ b/src/overlays/actors/ovl_Bg_Breakwall/z_bg_breakwall.h @@ -5,9 +5,9 @@ struct BgBreakwall; -typedef void (*BgBreakwallActionFunc)(struct BgBreakwall*, GlobalContext*); -typedef s32 (*BgBreakwallUnkFunc)(struct BgBreakwall*, GlobalContext*); -typedef void (*BgBreakwallUnkFunc2)(struct BgBreakwall*, GlobalContext*); +typedef void (*BgBreakwallActionFunc)(struct BgBreakwall*, PlayState*); +typedef s32 (*BgBreakwallUnkFunc)(struct BgBreakwall*, PlayState*); +typedef void (*BgBreakwallUnkFunc2)(struct BgBreakwall*, PlayState*); #define BGBREAKWALL_GET_F(thisx) ((thisx)-> params & 0xF) #define BGBREAKWALL_SWITCHFLAG(thisx) (((thisx)-> params & 0xFE00) >> 9) @@ -19,11 +19,11 @@ enum { }; typedef struct BgBreakwall { - /* 0x0000 */ DynaPolyActor dyna; - /* 0x015C */ s8 unk_15C; - /* 0x015D */ u8 switchFlag; - /* 0x015E */ u8 unk_15E; - /* 0x0160 */ BgBreakwallActionFunc actionFunc; + /* 0x000 */ DynaPolyActor dyna; + /* 0x15C */ s8 unk_15C; + /* 0x15D */ u8 switchFlag; + /* 0x15E */ u8 unk_15E; + /* 0x160 */ BgBreakwallActionFunc actionFunc; } BgBreakwall; // size = 0x164 extern const ActorInit Bg_Breakwall_InitVars; diff --git a/src/overlays/actors/ovl_Bg_Crace_Movebg/z_bg_crace_movebg.c b/src/overlays/actors/ovl_Bg_Crace_Movebg/z_bg_crace_movebg.c index c5613248a..1a0cb5058 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 @@ -10,12 +10,28 @@ #define THIS ((BgCraceMovebg*)thisx) -void BgCraceMovebg_Init(Actor* thisx, GlobalContext* globalCtx); -void BgCraceMovebg_Destroy(Actor* thisx, GlobalContext* globalCtx); -void BgCraceMovebg_Update(Actor* thisx, GlobalContext* globalCtx); -void BgCraceMovebg_Draw(Actor* thisx, GlobalContext* globalCtx); +void BgCraceMovebg_Init(Actor* thisx, PlayState* play); +void BgCraceMovebg_Destroy(Actor* thisx, PlayState* play); +void BgCraceMovebg_Update(Actor* thisx, PlayState* play); +void BgCraceMovebg_Draw(Actor* thisx, PlayState* play); + +s32 func_80A7090C(PlayState* play); +void func_80A70970(BgCraceMovebg* this, PlayState* play); +void func_80A7099C(BgCraceMovebg* this, PlayState* play); +void func_80A709E4(BgCraceMovebg* this, PlayState* play); +void func_80A70A08(BgCraceMovebg* this, PlayState* play); +void func_80A70A84(BgCraceMovebg* this, PlayState* play); +void func_80A70A9C(BgCraceMovebg* this, PlayState* play); +void func_80A70C04(BgCraceMovebg* this, PlayState* play); +void func_80A70D74(BgCraceMovebg* this, PlayState* play); +void func_80A70DA8(BgCraceMovebg* this, PlayState* play); +void func_80A70E2C(BgCraceMovebg* this, PlayState* play); +void func_80A70E70(BgCraceMovebg* this, PlayState* play); +void func_80A70F14(BgCraceMovebg* this, PlayState* play); +void func_80A70F2C(BgCraceMovebg* this, PlayState* play); +void func_80A70FF4(BgCraceMovebg* this, PlayState* play); +void func_80A71040(BgCraceMovebg* this, PlayState* play); -#if 0 const ActorInit Bg_Crace_Movebg_InitVars = { ACTOR_BG_CRACE_MOVEBG, ACTORCAT_BG, @@ -28,47 +44,256 @@ const ActorInit Bg_Crace_Movebg_InitVars = { (ActorFunc)BgCraceMovebg_Draw, }; -#endif +static u8 D_80A710A0 = 0; +static u8 D_80A710A4 = 0; +static InitChainEntry sInitChain[] = { + ICHAIN_VEC3F_DIV1000(scale, 1000, ICHAIN_STOP), +}; +static Vec3f D_80A710AC[] = { 0.0f, 0.0f, 1.0f }; +u8 D_80A711B0[32]; -extern UNK_TYPE D_060003A0; -extern UNK_TYPE D_06000E00; +void BgCraceMovebg_Init(Actor* thisx, PlayState* play) { + BgCraceMovebg* this = THIS; + s32 i; + s32 j; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Crace_Movebg/BgCraceMovebg_Init.s") + Actor_ProcessInitChain(&this->dyna.actor, sInitChain); + if (D_80A710A0 == 0) { + for (i = 0; i < ARRAY_COUNT(D_80A711B0); i++) { + D_80A711B0[i] = 0; + } + D_80A710A0 = 1; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Crace_Movebg/func_80A7090C.s") + DynaPolyActor_Init(&this->dyna, 1); + DynaPolyActor_LoadMesh(play, &this->dyna, &object_crace_object_Colheader_000E00); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Crace_Movebg/func_80A70970.s") + this->unk184 = this->dyna.actor.world.rot.x; + this->unk16C = this->dyna.actor.world.rot.z; + this->dyna.actor.world.rot.x = 0; + this->dyna.actor.world.rot.z = 0; + this->dyna.actor.home.rot.x = 0; + this->dyna.actor.home.rot.z = 0; + this->dyna.actor.flags |= ACTOR_FLAG_10000000; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Crace_Movebg/func_80A7099C.s") + switch (BGCRACEMOVEBG_GET_F(&this->dyna.actor)) { + case 0: + case 2: + for (j = 0; j < D_80A710A4; j++) { + if (D_80A711B0[j] == this->unk184) { + this->unk170 |= 8; + Actor_MarkForDeath(&this->dyna.actor); + return; + } + } + if (D_80A710A4 < ARRAY_COUNT(D_80A711B0)) { + D_80A711B0[(s32)D_80A710A4++] = this->unk184; + } + this->dyna.actor.room = -1; + switch (func_80A7090C(play)) { + case 0: + func_80A70D74(this, play); + break; + case 1: + func_80A70D74(this, play); + break; + case 2: + Flags_UnsetSwitch(play, BGCRACEMOVEBG_GET_7F0(&this->dyna.actor) + 1); + func_80A70D74(this, play); + break; + } + break; + case 1: + func_80A70970(this, play); + break; + default: + Actor_MarkForDeath(&this->dyna.actor); + break; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Crace_Movebg/func_80A709E4.s") +s32 func_80A7090C(PlayState* play) { + s32 pad; + s32 returnVal = 0; + Actor* tempActor = SubS_FindActor(play, NULL, ACTORCAT_NPC, ACTOR_EN_DNO); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Crace_Movebg/func_80A70A08.s") + if (tempActor != NULL) { + if (Flags_GetSwitch(play, BGCRACEMOVEBG_GET_3F80(tempActor))) { + returnVal = 2; + } else { + returnVal = 1; + } + } + return returnVal; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Crace_Movebg/func_80A70A84.s") +void func_80A70970(BgCraceMovebg* this, PlayState* play) { + this->unk164 = 0.0f; + this->unk160 = 0.0f; + this->actionFunc = func_80A7099C; + this->dyna.actor.world.pos.y = this->dyna.actor.home.pos.y; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Crace_Movebg/func_80A70A9C.s") +void func_80A7099C(BgCraceMovebg* this, PlayState* play) { + if (Flags_GetSwitch(play, BGCRACEMOVEBG_GET_7F0(&this->dyna.actor))) { + func_80A709E4(this, play); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Crace_Movebg/BgCraceMovebg_Destroy.s") +void func_80A709E4(BgCraceMovebg* this, PlayState* play) { + this->actionFunc = func_80A70A08; + this->unk164 = 180.0f; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Crace_Movebg/BgCraceMovebg_Update.s") +void func_80A70A08(BgCraceMovebg* this, PlayState* play) { + func_800B9010(&this->dyna.actor, NA_SE_EV_STONEDOOR_OPEN_S - SFX_FLAG); + Math_SmoothStepToF(&this->unk160, this->unk164, 2.0f, this->unk16C, 0.01f); + this->dyna.actor.world.pos.y = this->dyna.actor.home.pos.y + this->unk160; + if (this->unk160 == this->unk164) { + func_80A70A84(this, play); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Crace_Movebg/func_80A70C04.s") +void func_80A70A84(BgCraceMovebg* this, PlayState* play) { + this->actionFunc = func_80A70A9C; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Crace_Movebg/func_80A70D74.s") +void func_80A70A9C(BgCraceMovebg* this, PlayState* play) { +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Crace_Movebg/func_80A70DA8.s") +void BgCraceMovebg_Destroy(Actor* thisx, PlayState* play) { + BgCraceMovebg* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Crace_Movebg/func_80A70E2C.s") + DynaPoly_DeleteBgActor(play, &play->colCtx.dyna, this->dyna.bgId); + if (!(this->unk170 & 0x8)) { + switch (BGCRACEMOVEBG_GET_F(&this->dyna.actor)) { + case 0: + case 2: + Flags_UnsetSwitch(play, BGCRACEMOVEBG_GET_7F0(thisx)); + Flags_UnsetSwitch(play, BGCRACEMOVEBG_GET_7F0(thisx) + 1); + break; + case 1: + Flags_UnsetSwitch(play, BGCRACEMOVEBG_GET_7F0(thisx)); + break; + } + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Crace_Movebg/func_80A70E70.s") +void BgCraceMovebg_Update(Actor* thisx, PlayState* play) { + BgCraceMovebg* this = THIS; + s32 pad; + Player* player = GET_PLAYER(play); + s16 tempRot; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Crace_Movebg/func_80A70F14.s") + switch (BGCRACEMOVEBG_GET_F(&this->dyna.actor)) { + case 0: + case 2: + tempRot = this->dyna.actor.yawTowardsPlayer - this->dyna.actor.home.rot.y; + if ((tempRot >= -0x4000) && (tempRot <= 0x4000)) { + this->dyna.actor.shape.rot.y = this->dyna.actor.home.rot.y; + } else { + this->dyna.actor.shape.rot.y = this->dyna.actor.home.rot.y + 0x8000; + } + default: + this->actionFunc(this, play); + Math_Vec3f_Copy(&this->unk188, &player->bodyPartsPos[0]); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Crace_Movebg/func_80A70F2C.s") +void func_80A70C04(BgCraceMovebg* this, PlayState* play) { + s32 pad; + Player* player = GET_PLAYER(play); + Vec3f intersect; + Vec3f diff; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Crace_Movebg/func_80A70FF4.s") + if ((BGCRACEMOVEBG_GET_F(&this->dyna.actor) != 2) && + SubS_LineSegVsPlane(&this->dyna.actor.home.pos, &this->dyna.actor.home.rot, D_80A710AC, &this->unk188, + &player->bodyPartsPos[0], &intersect)) { + Matrix_RotateYS(-this->dyna.actor.home.rot.y, MTXMODE_NEW); + Math_Vec3f_Diff(&player->bodyPartsPos[0], &this->dyna.actor.home.pos, &diff); + Matrix_MultVec3f(&diff, &this->unk178); + if (fabsf(this->unk178.x) < 100.0f && this->unk178.y >= -10.0f && this->unk178.y <= 180.0f) { + if (this->unk178.z < 0.0f) { + Flags_SetSwitch(play, BGCRACEMOVEBG_GET_7F0(&this->dyna.actor) + 1); + this->unk170 |= 2; + } else { + Flags_UnsetSwitch(play, BGCRACEMOVEBG_GET_7F0(&this->dyna.actor) + 1); + this->unk170 &= ~2; + } + } + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Crace_Movebg/func_80A71040.s") +void func_80A70D74(BgCraceMovebg* this, PlayState* play) { + this->unk164 = 180.0f; + this->unk160 = 180.0f; + this->actionFunc = func_80A70DA8; + this->dyna.actor.world.pos.y = this->dyna.actor.home.pos.y + 180.0f; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Crace_Movebg/BgCraceMovebg_Draw.s") +void func_80A70DA8(BgCraceMovebg* this, PlayState* play) { + this->dyna.actor.world.pos.y = this->dyna.actor.home.pos.y + this->unk160; + func_80A70C04(this, play); + if (this->unk170 & 1) { + func_80A70E2C(this, play); + } + if (Flags_GetSwitch(play, BGCRACEMOVEBG_GET_7F0(&this->dyna.actor))) { + func_80A70F14(this, play); + } +} + +void func_80A70E2C(BgCraceMovebg* this, PlayState* play) { + this->unk174 = BGCRACEMOVEBG_GET_F800(&this->dyna.actor) * 10; + this->unk164 = 180.0f; + this->unk160 = 180.0f; + this->actionFunc = func_80A70E70; +} + +void func_80A70E70(BgCraceMovebg* this, PlayState* play) { + if (this->unk174 > 0) { + this->unk174--; + } + this->dyna.actor.world.pos.y = this->dyna.actor.home.pos.y + this->unk160; + func_80A70C04(this, play); + if (this->unk174 <= 0) { + this->unk160 = 180.0f; + this->unk164 = 0.0f; + this->dyna.actor.world.pos.y = this->dyna.actor.home.pos.y + 180.0f; + Flags_SetSwitch(play, BGCRACEMOVEBG_GET_7F0(&this->dyna.actor)); + func_80A70F14(this, play); + } +} + +void func_80A70F14(BgCraceMovebg* this, PlayState* play) { + this->actionFunc = func_80A70F2C; +} + +void func_80A70F2C(BgCraceMovebg* this, PlayState* play) { + this->dyna.actor.world.pos.y = this->dyna.actor.home.pos.y + this->unk160; + func_80A70C04(this, play); + if (Math_StepToF(&this->unk160, 0.0f, 1.0f)) { + if (!(this->unk170 & 2) && !Flags_GetSwitch(play, BGCRACEMOVEBG_GET_7F0(&this->dyna.actor) + 1)) { + play->unk_18845 = 1; + func_80169FDC(&play->state); + play_sound(NA_SE_OC_ABYSS); + } + func_80A70FF4(this, play); + } else { + func_800B9010(&this->dyna.actor, NA_SE_EV_STONEDOOR_CLOSE_S - SFX_FLAG); + } +} + +void func_80A70FF4(BgCraceMovebg* this, PlayState* play) { + this->unk164 = 0.0f; + this->unk160 = 0.0f; + this->dyna.actor.world.pos.y = this->dyna.actor.home.pos.y; + Actor_PlaySfxAtPos(&this->dyna.actor, NA_SE_EV_STONEDOOR_STOP); + this->actionFunc = func_80A71040; +} + +void func_80A71040(BgCraceMovebg* this, PlayState* play) { +} + +void BgCraceMovebg_Draw(Actor* thisx, PlayState* play) { + Gfx_DrawDListOpa(play, object_crace_object_DL_0003A0); +} diff --git a/src/overlays/actors/ovl_Bg_Crace_Movebg/z_bg_crace_movebg.h b/src/overlays/actors/ovl_Bg_Crace_Movebg/z_bg_crace_movebg.h index 7208706d1..4faca7ba2 100644 --- a/src/overlays/actors/ovl_Bg_Crace_Movebg/z_bg_crace_movebg.h +++ b/src/overlays/actors/ovl_Bg_Crace_Movebg/z_bg_crace_movebg.h @@ -2,18 +2,29 @@ #define Z_BG_CRACE_MOVEBG_H #include "global.h" +#include "assets/objects/object_crace_object/object_crace_object.h" struct BgCraceMovebg; -typedef void (*BgCraceMovebgActionFunc)(struct BgCraceMovebg*, GlobalContext*); +typedef void (*BgCraceMovebgActionFunc)(struct BgCraceMovebg*, PlayState*); + +#define BGCRACEMOVEBG_GET_F(thisx) (((thisx)->params) & 0xF) +#define BGCRACEMOVEBG_GET_7F0(thisx) (((thisx)->params >> 4) & 0x7F) +#define BGCRACEMOVEBG_GET_3F80(thisx) (((thisx)->params >> 7) & 0x7F) +#define BGCRACEMOVEBG_GET_F800(thisx) (((thisx)->params >> 0xB) & 0x1F) typedef struct BgCraceMovebg { - /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x18]; - /* 0x015C */ BgCraceMovebgActionFunc actionFunc; - /* 0x0160 */ char unk_160[0x10]; - /* 0x0170 */ s32 unk_170; - /* 0x0174 */ char unk_174[0x20]; + /* 0x000 */ DynaPolyActor dyna; + /* 0x15C */ BgCraceMovebgActionFunc actionFunc; + /* 0x160 */ f32 unk160; + /* 0x164 */ f32 unk164; + /* 0x168 */ UNK_TYPE1 pad168[0x4]; + /* 0x16C */ f32 unk16C; + /* 0x170 */ s32 unk170; + /* 0x174 */ s32 unk174; + /* 0x178 */ Vec3f unk178; + /* 0x184 */ u8 unk184; + /* 0x188 */ Vec3f unk188; } BgCraceMovebg; // size = 0x194 extern const ActorInit Bg_Crace_Movebg_InitVars; diff --git a/src/overlays/actors/ovl_Bg_Ctower_Gear/z_bg_ctower_gear.c b/src/overlays/actors/ovl_Bg_Ctower_Gear/z_bg_ctower_gear.c index 09876c350..056af77bb 100644 --- a/src/overlays/actors/ovl_Bg_Ctower_Gear/z_bg_ctower_gear.c +++ b/src/overlays/actors/ovl_Bg_Ctower_Gear/z_bg_ctower_gear.c @@ -11,13 +11,13 @@ #define THIS ((BgCtowerGear*)thisx) -void BgCtowerGear_Init(Actor* thisx, GlobalContext* globalCtx); -void BgCtowerGear_Destroy(Actor* thisx, GlobalContext* globalCtx); -void BgCtowerGear_Update(Actor* thisx, GlobalContext* globalCtx); -void BgCtowerGear_Draw(Actor* thisx, GlobalContext* globalCtx); +void BgCtowerGear_Init(Actor* thisx, PlayState* play); +void BgCtowerGear_Destroy(Actor* thisx, PlayState* play); +void BgCtowerGear_Update(Actor* thisx, PlayState* play); +void BgCtowerGear_Draw(Actor* thisx, PlayState* play); -void BgCtowerGear_UpdateOrgan(Actor* thisx, GlobalContext* globalCtx); -void BgCtowerGear_DrawOrgan(Actor* thisx, GlobalContext* globalCtx); +void BgCtowerGear_UpdateOrgan(Actor* thisx, PlayState* play); +void BgCtowerGear_DrawOrgan(Actor* thisx, PlayState* play); const ActorInit Bg_Ctower_Gear_InitVars = { ACTOR_BG_CTOWER_GEAR, @@ -64,9 +64,9 @@ static InitChainEntry sInitChainOrgan[] = { static Gfx* sDLists[] = { gClockTowerCeilingCogDL, gClockTowerCenterCogDL, gClockTowerWaterWheelDL }; -void BgCtowerGear_Splash(BgCtowerGear* this, GlobalContext* globalCtx) { +void BgCtowerGear_Splash(BgCtowerGear* this, PlayState* play) { s32 i; - s32 flag40 = this->dyna.actor.flags & 0x40; + s32 flag40 = this->dyna.actor.flags & ACTOR_FLAG_40; Vec3f splashSpawnPos; Vec3f splashOffset; s32 pad; @@ -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(play, &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(play, &splashSpawnPos, NULL, NULL, 0, (Rand_Next() >> 25) + 280); } } } @@ -112,7 +112,7 @@ void BgCtowerGear_Splash(BgCtowerGear* this, GlobalContext* globalCtx) { } } -void BgCtowerGear_Init(Actor* thisx, GlobalContext* globalCtx) { +void BgCtowerGear_Init(Actor* thisx, PlayState* play) { BgCtowerGear* this = THIS; s32 type = BGCTOWERGEAR_GET_TYPE(&this->dyna.actor); @@ -128,24 +128,24 @@ void BgCtowerGear_Init(Actor* thisx, GlobalContext* globalCtx) { } if (type == BGCTOWERGEAR_WATER_WHEEL) { DynaPolyActor_Init(&this->dyna, 3); - DynaPolyActor_LoadMesh(globalCtx, &this->dyna, &gClockTowerWaterWheelCol); + DynaPolyActor_LoadMesh(play, &this->dyna, &gClockTowerWaterWheelCol); } else if (type == BGCTOWERGEAR_ORGAN) { DynaPolyActor_Init(&this->dyna, 0); - DynaPolyActor_LoadMesh(globalCtx, &this->dyna, &gClockTowerOrganCol); - func_800C62BC(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); + DynaPolyActor_LoadMesh(play, &this->dyna, &gClockTowerOrganCol); + func_800C62BC(play, &play->colCtx.dyna, this->dyna.bgId); } } -void BgCtowerGear_Destroy(Actor* thisx, GlobalContext* globalCtx) { +void BgCtowerGear_Destroy(Actor* thisx, PlayState* play) { BgCtowerGear* this = THIS; s32 type = BGCTOWERGEAR_GET_TYPE(&this->dyna.actor); if ((type == BGCTOWERGEAR_WATER_WHEEL) || (type == BGCTOWERGEAR_ORGAN)) { - DynaPoly_DeleteBgActor(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); + DynaPoly_DeleteBgActor(play, &play->colCtx.dyna, this->dyna.bgId); } } -void BgCtowerGear_Update(Actor* thisx, GlobalContext* globalCtx) { +void BgCtowerGear_Update(Actor* thisx, PlayState* play) { BgCtowerGear* this = THIS; s32 type = BGCTOWERGEAR_GET_TYPE(&this->dyna.actor); @@ -156,22 +156,22 @@ void BgCtowerGear_Update(Actor* thisx, GlobalContext* globalCtx) { func_800B9010(&this->dyna.actor, NA_SE_EV_WINDMILL_LEVEL - SFX_FLAG); } else if (type == BGCTOWERGEAR_WATER_WHEEL) { this->dyna.actor.shape.rot.z -= 0x1F4; - BgCtowerGear_Splash(this, globalCtx); + BgCtowerGear_Splash(this, play); } } -void BgCtowerGear_UpdateOrgan(Actor* thisx, GlobalContext* globalCtx) { +void BgCtowerGear_UpdateOrgan(Actor* thisx, PlayState* play) { BgCtowerGear* this = THIS; - if (Cutscene_CheckActorAction(globalCtx, 104)) { - switch (globalCtx->csCtx.actorActions[Cutscene_GetActorActionIndex(globalCtx, 104)]->action) { + if (Cutscene_CheckActorAction(play, 104)) { + switch (play->csCtx.actorActions[Cutscene_GetActorActionIndex(play, 104)]->action) { case 1: this->dyna.actor.draw = NULL; - func_800C62BC(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); + func_800C62BC(play, &play->colCtx.dyna, this->dyna.bgId); break; case 2: this->dyna.actor.draw = BgCtowerGear_DrawOrgan; - func_800C6314(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); + func_800C6314(play, &play->colCtx.dyna, this->dyna.bgId); break; case 3: Actor_MarkForDeath(&this->dyna.actor); @@ -180,17 +180,17 @@ void BgCtowerGear_UpdateOrgan(Actor* thisx, GlobalContext* globalCtx) { } } -void BgCtowerGear_Draw(Actor* thisx, GlobalContext* globalCtx) { - Gfx_DrawDListOpa(globalCtx, sDLists[BGCTOWERGEAR_GET_TYPE(thisx)]); +void BgCtowerGear_Draw(Actor* thisx, PlayState* play) { + Gfx_DrawDListOpa(play, sDLists[BGCTOWERGEAR_GET_TYPE(thisx)]); } -void BgCtowerGear_DrawOrgan(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); +void BgCtowerGear_DrawOrgan(Actor* thisx, PlayState* play) { + OPEN_DISPS(play->state.gfxCtx); + func_8012C28C(play->state.gfxCtx); + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_OPA_DISP++, gClockTowerOrganDL); - func_8012C2DC(globalCtx->state.gfxCtx); - gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + func_8012C2DC(play->state.gfxCtx); + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_XLU_DISP++, gClockTowerOrganPipesDL); - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->state.gfxCtx); } diff --git a/src/overlays/actors/ovl_Bg_Ctower_Gear/z_bg_ctower_gear.h b/src/overlays/actors/ovl_Bg_Ctower_Gear/z_bg_ctower_gear.h index 5da321679..952a13c4a 100644 --- a/src/overlays/actors/ovl_Bg_Ctower_Gear/z_bg_ctower_gear.h +++ b/src/overlays/actors/ovl_Bg_Ctower_Gear/z_bg_ctower_gear.h @@ -9,10 +9,10 @@ struct BgCtowerGear; #define BGCTOWERGEAR_GET_TYPE(thisx) ((thisx)->params & 3) typedef enum { - /* 0x00 */ BGCTOWERGEAR_CEILING_COG, - /* 0x01 */ BGCTOWERGEAR_CENTER_COG, - /* 0x02 */ BGCTOWERGEAR_WATER_WHEEL, - /* 0x03 */ BGCTOWERGEAR_ORGAN + /* 0x0 */ BGCTOWERGEAR_CEILING_COG, + /* 0x1 */ BGCTOWERGEAR_CENTER_COG, + /* 0x2 */ BGCTOWERGEAR_WATER_WHEEL, + /* 0x3 */ BGCTOWERGEAR_ORGAN } BgCtowerGearType; typedef struct BgCtowerGear { diff --git a/src/overlays/actors/ovl_Bg_Ctower_Rot/z_bg_ctower_rot.c b/src/overlays/actors/ovl_Bg_Ctower_Rot/z_bg_ctower_rot.c index 53ddd7b81..2ca48b346 100644 --- a/src/overlays/actors/ovl_Bg_Ctower_Rot/z_bg_ctower_rot.c +++ b/src/overlays/actors/ovl_Bg_Ctower_Rot/z_bg_ctower_rot.c @@ -11,15 +11,15 @@ #define THIS ((BgCtowerRot*)thisx) -void BgCtowerRot_Init(Actor* thisx, GlobalContext* globalCtx); -void BgCtowerRot_Destroy(Actor* thisx, GlobalContext* globalCtx); -void BgCtowerRot_Update(Actor* thisx, GlobalContext* globalCtx); -void BgCtowerRot_Draw(Actor* thisx, GlobalContext* globalCtx); +void BgCtowerRot_Init(Actor* thisx, PlayState* play); +void BgCtowerRot_Destroy(Actor* thisx, PlayState* play); +void BgCtowerRot_Update(Actor* thisx, PlayState* play); +void BgCtowerRot_Draw(Actor* thisx, PlayState* play); -void BgCtowerRot_CorridorRotate(BgCtowerRot* this, GlobalContext* globalCtx); -void BgCtowerRot_DoorDoNothing(BgCtowerRot* this, GlobalContext* globalCtx); -void BgCtowerRot_DoorIdle(BgCtowerRot* this, GlobalContext* globalCtx); -void BgCtowerRot_SetupDoorClose(BgCtowerRot* this, GlobalContext* globalCtx); +void BgCtowerRot_CorridorRotate(BgCtowerRot* this, PlayState* play); +void BgCtowerRot_DoorDoNothing(BgCtowerRot* this, PlayState* play); +void BgCtowerRot_DoorIdle(BgCtowerRot* this, PlayState* play); +void BgCtowerRot_SetupDoorClose(BgCtowerRot* this, PlayState* play); const ActorInit Bg_Ctower_Rot_InitVars = { ACTOR_BG_CTOWER_ROT, @@ -39,7 +39,7 @@ static InitChainEntry sInitChain[] = { static Gfx* sDLists[] = { gClockTowerCorridorDL, gClockTowerStoneDoorMainDL, gClockTowerStoneDoorDL }; -void BgCtowerRot_Init(Actor* thisx, GlobalContext* globalCtx) { +void BgCtowerRot_Init(Actor* thisx, PlayState* play) { s32 pad; BgCtowerRot* this = THIS; Player* player; @@ -48,17 +48,17 @@ void BgCtowerRot_Init(Actor* thisx, GlobalContext* globalCtx) { Actor_ProcessInitChain(&this->dyna.actor, sInitChain); DynaPolyActor_Init(&this->dyna, 1); if (this->dyna.actor.params == BGCTOWERROT_CORRIDOR) { - DynaPolyActor_LoadMesh(globalCtx, &this->dyna, &gClockTowerCorridorCol); + DynaPolyActor_LoadMesh(play, &this->dyna, &gClockTowerCorridorCol); this->actionFunc = BgCtowerRot_CorridorRotate; return; } - player = GET_PLAYER(globalCtx); + player = GET_PLAYER(play); if (this->dyna.actor.params == BGCTOWERROT_STONE_DOOR_MAIN) { - DynaPolyActor_LoadMesh(globalCtx, &this->dyna, &gClockTowerStoneDoorMainCol); + DynaPolyActor_LoadMesh(play, &this->dyna, &gClockTowerStoneDoorMainCol); this->dyna.actor.world.rot.y = this->dyna.actor.shape.rot.y + 0x4000; } else { - DynaPolyActor_LoadMesh(globalCtx, &this->dyna, &gClockTowerStoneDoorCol); + DynaPolyActor_LoadMesh(play, &this->dyna, &gClockTowerStoneDoorCol); this->dyna.actor.world.rot.y = this->dyna.actor.shape.rot.y - 0x4000; } Actor_OffsetOfPointInActorCoords(&this->dyna.actor, &offset, &player->actor.world.pos); @@ -72,36 +72,31 @@ void BgCtowerRot_Init(Actor* thisx, GlobalContext* globalCtx) { } } -void BgCtowerRot_Destroy(Actor* thisx, GlobalContext* globalCtx) { +void BgCtowerRot_Destroy(Actor* thisx, PlayState* play) { BgCtowerRot* this = THIS; - DynaPoly_DeleteBgActor(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); + DynaPoly_DeleteBgActor(play, &play->colCtx.dyna, this->dyna.bgId); } -void BgCtowerRot_CorridorRotate(BgCtowerRot* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); +void BgCtowerRot_CorridorRotate(BgCtowerRot* this, PlayState* play) { + Player* player = GET_PLAYER(play); 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[CAM_ID_MAIN], 17); + rotZ = CLAMP(1100.0f - offset.z, 0.0f, 1000.0f); + Camera_ChangeSetting(play->cameraPtrs[CAM_ID_MAIN], CAM_SET_DUNGEON0); this->dyna.actor.shape.rot.z = rotZ * 16.384f; - if (globalCtx->csCtx.frames == 132) { + + if (play->csCtx.frames == 132) { play_sound(NA_SE_SY_SPIRAL_DASH); } } -void BgCtowerRot_DoorDoNothing(BgCtowerRot* this, GlobalContext* globalCtx) { +void BgCtowerRot_DoorDoNothing(BgCtowerRot* this, PlayState* play) { } -void BgCtowerRot_DoorClose(BgCtowerRot* this, GlobalContext* globalCtx) { +void BgCtowerRot_DoorClose(BgCtowerRot* this, PlayState* play) { if (!Math_SmoothStepToF(&this->timer, 0.0f, 0.1f, 15.0f, 0.1f)) { if (this->dyna.actor.params == BGCTOWERROT_STONE_DOOR_MAIN) { Actor_PlaySfxAtPos(&this->dyna.actor, NA_SE_EV_STONEDOOR_STOP); @@ -117,8 +112,8 @@ void BgCtowerRot_DoorClose(BgCtowerRot* this, GlobalContext* globalCtx) { this->dyna.actor.home.pos.z + (Math_CosS(this->dyna.actor.world.rot.y) * this->timer); } -void BgCtowerRot_DoorIdle(BgCtowerRot* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); +void BgCtowerRot_DoorIdle(BgCtowerRot* this, PlayState* play) { + Player* player = GET_PLAYER(play); Vec3f offset; Actor_OffsetOfPointInActorCoords(&this->dyna.actor, &offset, &player->actor.world.pos); @@ -129,7 +124,7 @@ void BgCtowerRot_DoorIdle(BgCtowerRot* this, GlobalContext* globalCtx) { } } -void BgCtowerRot_SetupDoorClose(BgCtowerRot* this, GlobalContext* globalCtx) { +void BgCtowerRot_SetupDoorClose(BgCtowerRot* this, PlayState* play) { if (ActorCutscene_GetCanPlayNext(this->dyna.actor.cutscene)) { if (this->dyna.actor.params == BGCTOWERROT_STONE_DOOR_MAIN) { ActorCutscene_StartAndSetUnkLinkFields(this->dyna.actor.cutscene, &this->dyna.actor); @@ -140,17 +135,17 @@ void BgCtowerRot_SetupDoorClose(BgCtowerRot* this, GlobalContext* globalCtx) { } } -void BgCtowerRot_Update(Actor* thisx, GlobalContext* globalCtx) { +void BgCtowerRot_Update(Actor* thisx, PlayState* play) { BgCtowerRot* this = THIS; - this->actionFunc(this, globalCtx); + this->actionFunc(this, play); } -void BgCtowerRot_Draw(Actor* thisx, GlobalContext* globalCtx) { +void BgCtowerRot_Draw(Actor* thisx, PlayState* play) { BgCtowerRot* this = THIS; - Gfx_DrawDListOpa(globalCtx, sDLists[this->dyna.actor.params]); + Gfx_DrawDListOpa(play, sDLists[this->dyna.actor.params]); if (this->dyna.actor.params == BGCTOWERROT_CORRIDOR) { - Gfx_DrawDListXlu(globalCtx, gClockTowerCorridorFoliageDL); + Gfx_DrawDListXlu(play, gClockTowerCorridorFoliageDL); } } diff --git a/src/overlays/actors/ovl_Bg_Ctower_Rot/z_bg_ctower_rot.h b/src/overlays/actors/ovl_Bg_Ctower_Rot/z_bg_ctower_rot.h index b8b0dbfb0..e8b83fa22 100644 --- a/src/overlays/actors/ovl_Bg_Ctower_Rot/z_bg_ctower_rot.h +++ b/src/overlays/actors/ovl_Bg_Ctower_Rot/z_bg_ctower_rot.h @@ -5,7 +5,7 @@ struct BgCtowerRot; -typedef void (*BgCtowerRotActionFunc)(struct BgCtowerRot*, GlobalContext*); +typedef void (*BgCtowerRotActionFunc)(struct BgCtowerRot*, PlayState*); typedef enum { /* 0 */ BGCTOWERROT_CORRIDOR, 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 1aada9272..a998936ec 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 @@ -10,9 +10,9 @@ #define THIS ((BgDanpeiMovebg*)thisx) -void BgDanpeiMovebg_Init(Actor* thisx, GlobalContext* globalCtx); -void BgDanpeiMovebg_Destroy(Actor* thisx, GlobalContext* globalCtx); -void BgDanpeiMovebg_Update(Actor* thisx, GlobalContext* globalCtx); +void BgDanpeiMovebg_Init(Actor* thisx, PlayState* play); +void BgDanpeiMovebg_Destroy(Actor* thisx, PlayState* play); +void BgDanpeiMovebg_Update(Actor* thisx, PlayState* play); #if 0 const ActorInit Bg_Danpei_Movebg_InitVars = { diff --git a/src/overlays/actors/ovl_Bg_Danpei_Movebg/z_bg_danpei_movebg.h b/src/overlays/actors/ovl_Bg_Danpei_Movebg/z_bg_danpei_movebg.h index 28dafc099..1bdf17933 100644 --- a/src/overlays/actors/ovl_Bg_Danpei_Movebg/z_bg_danpei_movebg.h +++ b/src/overlays/actors/ovl_Bg_Danpei_Movebg/z_bg_danpei_movebg.h @@ -5,14 +5,14 @@ struct BgDanpeiMovebg; -typedef void (*BgDanpeiMovebgActionFunc)(struct BgDanpeiMovebg*, GlobalContext*); +typedef void (*BgDanpeiMovebgActionFunc)(struct BgDanpeiMovebg*, PlayState*); typedef struct BgDanpeiMovebg { - /* 0x0000 */ DynaPolyActor dyna; - /* 0x015C */ BgDanpeiMovebgActionFunc actionFunc; - /* 0x0160 */ char unk_160[0x6C]; - /* 0x01CC */ u16 unk_1CC; - /* 0x01CE */ char unk_1CE[0xA]; + /* 0x000 */ DynaPolyActor dyna; + /* 0x15C */ BgDanpeiMovebgActionFunc actionFunc; + /* 0x160 */ char unk_160[0x6C]; + /* 0x1CC */ u16 unk_1CC; + /* 0x1CE */ char unk_1CE[0xA]; } BgDanpeiMovebg; // size = 0x1D8 extern const ActorInit Bg_Danpei_Movebg_InitVars; diff --git a/src/overlays/actors/ovl_Bg_Dblue_Balance/z_bg_dblue_balance.c b/src/overlays/actors/ovl_Bg_Dblue_Balance/z_bg_dblue_balance.c index 07693307b..d849ab5ed 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 @@ -4,6 +4,7 @@ * Description: Great Bay Temple - See-Saw */ +#include "prevent_bss_reordering.h" #include "z_bg_dblue_balance.h" #include "objects/object_dblue_object/object_dblue_object.h" @@ -11,20 +12,20 @@ #define THIS ((BgDblueBalance*)thisx) -void BgDblueBalance_Init(Actor* thisx, GlobalContext* globalCtx); -void BgDblueBalance_Destroy(Actor* thisx, GlobalContext* globalCtx); -void BgDblueBalance_Update(Actor* thisx, GlobalContext* globalCtx); -void BgDblueBalance_Draw(Actor* thisx, GlobalContext* globalCtx); +void BgDblueBalance_Init(Actor* thisx, PlayState* play); +void BgDblueBalance_Destroy(Actor* thisx, PlayState* play); +void BgDblueBalance_Update(Actor* thisx, PlayState* play); +void BgDblueBalance_Draw(Actor* thisx, PlayState* play); void func_80B82DC4(BgDblueBalance* this); -void func_80B82DE0(BgDblueBalance* this, GlobalContext* globalCtx); -void func_80B8330C(Actor* thisx, GlobalContext* globalCtx); +void func_80B82DE0(BgDblueBalance* this, PlayState* play); +void func_80B8330C(Actor* thisx, PlayState* play); void func_80B83344(BgDblueBalance* this); -void func_80B8335C(BgDblueBalance* this, GlobalContext* globalCtx); +void func_80B8335C(BgDblueBalance* this, PlayState* play); 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); +void func_80B833C4(BgDblueBalance* this, PlayState* play); +void func_80B83518(Actor* thisx, PlayState* play); +void func_80B83758(Actor* thisx, PlayState* play); AnimatedMaterial* D_80B83C70; AnimatedMaterial* D_80B83C74; @@ -110,45 +111,45 @@ void func_80B823B0(BgDblueBalance* this) { s32 pad; Vec3f sp28; - Matrix_InsertTranslation(this->dyna.actor.world.pos.x, this->dyna.actor.world.pos.y, this->dyna.actor.world.pos.z, - MTXMODE_NEW); - Matrix_RotateY(this->dyna.actor.shape.rot.y, MTXMODE_APPLY); - Matrix_InsertZRotation_s(this->dyna.actor.shape.rot.z, MTXMODE_APPLY); + 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); sp28.x = -138.28f; sp28.y = 0.0f; sp28.z = 0.0f; if (this->unk_15C != NULL) { - Matrix_MultiplyVector3fByState(&sp28, &this->unk_15C->dyna.actor.world.pos); + Matrix_MultVec3f(&sp28, &this->unk_15C->dyna.actor.world.pos); } sp28.x = 138.28f; if (this->unk_160 != NULL) { - Matrix_MultiplyVector3fByState(&sp28, &this->unk_160->dyna.actor.world.pos); + Matrix_MultVec3f(&sp28, &this->unk_160->dyna.actor.world.pos); } } -s32 func_80B82454(BgDblueBalance* this, GlobalContext* globalCtx) { +s32 func_80B82454(BgDblueBalance* this, PlayState* play) { s32 pad; s32 sp58 = true; BgDblueBalance* balance; Vec3f sp48; Vec3f sp3C; - Matrix_InsertTranslation(this->dyna.actor.world.pos.x, this->dyna.actor.world.pos.y, this->dyna.actor.world.pos.z, - MTXMODE_NEW); - Matrix_RotateY(this->dyna.actor.shape.rot.y, MTXMODE_APPLY); - Matrix_InsertZRotation_s(this->dyna.actor.shape.rot.z, MTXMODE_APPLY); + 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); sp48.x = -138.28f; sp48.y = 0.0f; sp48.z = 0.0f; - Matrix_MultiplyVector3fByState(&sp48, &sp3C); + Matrix_MultVec3f(&sp48, &sp3C); - 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); + this->unk_15C = (BgDblueBalance*)Actor_Spawn(&play->actorCtx, play, 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 { @@ -157,10 +158,10 @@ s32 func_80B82454(BgDblueBalance* this, GlobalContext* globalCtx) { } sp48.x = 138.28f; - Matrix_MultiplyVector3fByState(&sp48, &sp3C); + Matrix_MultVec3f(&sp48, &sp3C); - 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); + this->unk_160 = (BgDblueBalance*)Actor_Spawn(&play->actorCtx, play, 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 { @@ -171,13 +172,13 @@ s32 func_80B82454(BgDblueBalance* this, GlobalContext* globalCtx) { return sp58; } -void func_80B8259C(BgDblueBalance* this, GlobalContext* globalCtx) { +void func_80B8259C(BgDblueBalance* this, PlayState* play) { s32 pad; WaterBox* sp30; f32 sp2C; - if (WaterBox_GetSurface1_2(globalCtx, &globalCtx->colCtx, this->dyna.actor.world.pos.x, - this->dyna.actor.world.pos.z, &sp2C, &sp30)) { + if (WaterBox_GetSurface1_2(play, &play->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)) { @@ -212,20 +213,20 @@ void func_80B8264C(BgDblueBalance* this) { } } - Matrix_InsertTranslation(this->dyna.actor.world.pos.x, this->dyna.actor.world.pos.y, this->dyna.actor.world.pos.z, - MTXMODE_NEW); - Matrix_RotateY(this->dyna.actor.shape.rot.y, MTXMODE_APPLY); + Matrix_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); 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; - Matrix_StatePush(); - Matrix_InsertXRotation_s(phi_s0->unk_0C, MTXMODE_NEW); - Matrix_InsertTranslation(-545.0f, 0.0f, 270.0f, MTXMODE_APPLY); - Matrix_GetStateTranslation(&sp78); - Matrix_StatePop(); - Matrix_MultiplyVector3fByState(&sp78, &phi_s0->unk_00); + 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); temp_f0 = (sp78.z - 135.0f); if (sp78.z > 135.0f) { @@ -246,8 +247,8 @@ void func_80B8264C(BgDblueBalance* this) { } } -void func_80B828E4(BgDblueBalance* this, GlobalContext* globalCtx) { - if (Flags_GetSwitch(globalCtx, BGDBLUEBALANCE_GET_7F(&this->dyna.actor)) && (this->unk_17D <= 0)) { +void func_80B828E4(BgDblueBalance* this, PlayState* play) { + if (Flags_GetSwitch(play, BGDBLUEBALANCE_GET_7F(&this->dyna.actor)) && (this->unk_17D <= 0)) { if (this->unk_183 >= 252) { this->unk_183 = 255; } else { @@ -260,7 +261,7 @@ void func_80B828E4(BgDblueBalance* this, GlobalContext* globalCtx) { } } -void func_80B8296C(GlobalContext* globalCtx, Vec3f* arg1, f32 arg2) { +void func_80B8296C(PlayState* play, Vec3f* arg1, f32 arg2) { s32 i; Vec3f sp60; f32 temp_f0; @@ -270,13 +271,13 @@ void func_80B8296C(GlobalContext* globalCtx, Vec3f* arg1, f32 arg2) { 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]); + EffectSsGRipple_Spawn(play, &sp60, 500, 2000, D_80B83A90[i]); } for (i = 0; i < ARRAY_COUNT(D_80B83A94); i++) { temp_f0 = Rand_ZeroOne(); temp_f20 = 1.0f - SQ(temp_f0); - if (Rand_Next() > 0) { + if ((s32)Rand_Next() > 0) { temp_f20 = -temp_f20; } @@ -285,12 +286,12 @@ void func_80B8296C(GlobalContext* globalCtx, Vec3f* arg1, f32 arg2) { temp_f0 = Rand_ZeroOne(); temp_f20 = 1.0f - SQ(temp_f0); - if (Rand_Next() > 0) { + 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]); + EffectSsGRipple_Spawn(play, &sp60, 400, 800, D_80B83A94[i]); } } @@ -301,12 +302,12 @@ s32 func_80B82B00(s16 arg0, s16 arg1, s16 arg2) { return (arg0 < arg2 || arg1 >= arg2); } -void BgDblueBalance_Init(Actor* thisx, GlobalContext* globalCtx) { +void BgDblueBalance_Init(Actor* thisx, PlayState* play) { 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)); + s32 sp24 = Flags_GetSwitch(play, BGDBLUEBALANCE_GET_7F(&this->dyna.actor)); Actor_ProcessInitChain(&this->dyna.actor, sInitChain); @@ -317,7 +318,7 @@ void BgDblueBalance_Init(Actor* thisx, GlobalContext* globalCtx) { this->dyna.actor.draw = D_80B83A20[sp2C].unk_18; DynaPolyActor_Init(&this->dyna, 1); - DynaPolyActor_LoadMesh(globalCtx, &this->dyna, D_80B83A20[sp2C].unk_04); + DynaPolyActor_LoadMesh(play, &this->dyna, D_80B83A20[sp2C].unk_04); if (sp2C == 3) { D_80B83C70 = Lib_SegmentedToVirtual(object_dblue_object_Matanimheader_00CE00); @@ -333,8 +334,8 @@ void BgDblueBalance_Init(Actor* thisx, GlobalContext* globalCtx) { this->dyna.actor.shape.rot.z = 0x1C72; this->unk_174 = 0x1C72; } - func_80B82454(this, globalCtx); - func_80B8259C(this, globalCtx); + func_80B82454(this, play); + func_80B8259C(this, play); func_80B82DC4(this); } else if (sp2C == 3) { this->unk_16C = sp24; @@ -348,12 +349,12 @@ void BgDblueBalance_Init(Actor* thisx, GlobalContext* globalCtx) { } } -void BgDblueBalance_Destroy(Actor* thisx, GlobalContext* globalCtx) { +void BgDblueBalance_Destroy(Actor* thisx, PlayState* play) { s32 pad; BgDblueBalance* this = THIS; s32 sp1C = BGDBLUEBALANCE_GET_300(&this->dyna.actor); - DynaPoly_DeleteBgActor(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); + DynaPoly_DeleteBgActor(play, &play->colCtx.dyna, this->dyna.bgId); if (sp1C == 0) { if (this->unk_15C != NULL) { @@ -378,7 +379,7 @@ void func_80B82DC4(BgDblueBalance* this) { this->actionFunc = func_80B82DE0; } -void func_80B82DE0(BgDblueBalance* this, GlobalContext* globalCtx) { +void func_80B82DE0(BgDblueBalance* this, PlayState* play) { s32 pad; f32 sp88 = Math_CosS(this->dyna.actor.shape.rot.z * 2.2499313f); Actor* actor = &this->dyna.actor; @@ -396,7 +397,7 @@ void func_80B82DE0(BgDblueBalance* this, GlobalContext* globalCtx) { BgDblueBalance* sp3C; Vec3f sp30; - if (Flags_GetSwitch(globalCtx, BGDBLUEBALANCE_GET_7F(&this->dyna.actor))) { + if (Flags_GetSwitch(play, BGDBLUEBALANCE_GET_7F(&this->dyna.actor))) { if (this->unk_17D > 0) { this->unk_17D--; } else { @@ -466,7 +467,7 @@ void func_80B82DE0(BgDblueBalance* this, GlobalContext* globalCtx) { 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); + AudioSfx_StopByPosAndId(&this->dyna.actor.projectedPos, NA_SE_EV_SEESAW_INCLINE - SFX_FLAG); } phi_f2 *= 0.0022222223f; @@ -486,16 +487,16 @@ void func_80B82DE0(BgDblueBalance* this, GlobalContext* globalCtx) { if (this->unk_182) { Actor_PlaySfxAtPos(&this->dyna.actor, NA_SE_EV_SEESAW_WATER_BOUND); sp5C = this->unk_15C; - Matrix_StatePush(); - Matrix_RotateY(BINANG_SUB(this->dyna.actor.shape.rot.y, 0x4000), MTXMODE_NEW); - Matrix_GetStateTranslationAndScaledZ(45.0f, &sp60); - Matrix_StatePop(); + 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); + func_80B8296C(play, &sp50, 70.0f); } else { Actor_PlaySfxAtPos(&this->dyna.actor, NA_SE_EV_SEESAW_BOUND); } @@ -511,16 +512,16 @@ void func_80B82DE0(BgDblueBalance* this, GlobalContext* globalCtx) { if (this->unk_182) { Actor_PlaySfxAtPos(&this->dyna.actor, NA_SE_EV_SEESAW_WATER_BOUND); sp3C = this->unk_160; - Matrix_StatePush(); - Matrix_RotateY(BINANG_ADD(this->dyna.actor.shape.rot.y, 0x4000), MTXMODE_NEW); - Matrix_GetStateTranslationAndScaledZ(30.0f, &sp40); - Matrix_StatePop(); + 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); + func_80B8296C(play, &sp30, 47.0f); } else { Actor_PlaySfxAtPos(&this->dyna.actor, NA_SE_EV_SEESAW_BOUND); } @@ -532,17 +533,17 @@ void func_80B82DE0(BgDblueBalance* this, GlobalContext* globalCtx) { func_80B823B0(this); } -void BgDblueBalance_Update(Actor* thisx, GlobalContext* globalCtx) { +void BgDblueBalance_Update(Actor* thisx, PlayState* play) { BgDblueBalance* this = THIS; this->unk_17A = this->unk_178; - this->actionFunc(this, globalCtx); + this->actionFunc(this, play); - func_80B828E4(this, globalCtx); + func_80B828E4(this, play); } -void func_80B8330C(Actor* thisx, GlobalContext* globalCtx) { +void func_80B8330C(Actor* thisx, PlayState* play) { BgDblueBalance* this = THIS; this->unk_180 = DynaPolyActor_IsInSwitchPressedState(&this->dyna); @@ -554,8 +555,8 @@ void func_80B83344(BgDblueBalance* this) { this->actionFunc = func_80B8335C; } -void func_80B8335C(BgDblueBalance* this, GlobalContext* globalCtx) { - if (!Flags_GetSwitch(globalCtx, BGDBLUEBALANCE_GET_7F(&this->dyna.actor))) { +void func_80B8335C(BgDblueBalance* this, PlayState* play) { + if (!Flags_GetSwitch(play, BGDBLUEBALANCE_GET_7F(&this->dyna.actor))) { this->unk_178 = -0x14; func_80B833A8(this); } @@ -567,7 +568,7 @@ void func_80B833A8(BgDblueBalance* this) { this->actionFunc = func_80B833C4; } -void func_80B833C4(BgDblueBalance* this, GlobalContext* globalCtx) { +void func_80B833C4(BgDblueBalance* this, PlayState* play) { s32 pad; s32 sp28 = false; s16 sp26; @@ -616,12 +617,12 @@ void func_80B833C4(BgDblueBalance* this, GlobalContext* globalCtx) { } } -void func_80B83518(Actor* thisx, GlobalContext* globalCtx) { +void func_80B83518(Actor* thisx, PlayState* play) { BgDblueBalance* this = THIS; - this->unk_170 = Flags_GetSwitch(globalCtx, BGDBLUEBALANCE_GET_7F(&this->dyna.actor)); + this->unk_170 = Flags_GetSwitch(play, BGDBLUEBALANCE_GET_7F(&this->dyna.actor)); - this->actionFunc(this, globalCtx); + this->actionFunc(this, play); if (this->unk_17F == 2) { this->unk_17E--; @@ -641,39 +642,39 @@ void func_80B83518(Actor* thisx, GlobalContext* globalCtx) { this->unk_16C = this->unk_170; } -void BgDblueBalance_Draw(Actor* thisx, GlobalContext* globalCtx) { +void BgDblueBalance_Draw(Actor* thisx, PlayState* play) { 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); + Gfx_DrawDListOpa(play, ptr2->unk_00); if (!(BGDBLUEBALANCE_GET_300(&this->dyna.actor)) && (this->unk_160 != NULL)) { - AnimatedMat_Draw(globalCtx, D_80B83C74); + AnimatedMat_Draw(play, D_80B83C74); sp38 = this->unk_160; - Matrix_SetStateRotationAndTranslation(sp38->dyna.actor.world.pos.x, sp38->dyna.actor.world.pos.y, - sp38->dyna.actor.world.pos.z, &sp38->dyna.actor.shape.rot); - Matrix_InsertTranslation(30.0f, 15.0f, 0.0f, MTXMODE_APPLY); + Matrix_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); + OPEN_DISPS(play->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); + gSPMatrix(gfx++, Matrix_NewMtx(play->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); + CLOSE_DISPS(play->state.gfxCtx); } } -void func_80B83758(Actor* thisx, GlobalContext* globalCtx) { +void func_80B83758(Actor* thisx, PlayState* play) { s32 pad; BgDblueBalance* this = THIS; f32 temp_f0; @@ -695,12 +696,12 @@ void func_80B83758(Actor* thisx, GlobalContext* globalCtx) { if (this->dyna.actor.flags & ACTOR_FLAG_40) { ptr2 = &D_80B83A20[BGDBLUEBALANCE_GET_300(&this->dyna.actor)]; - Gfx_DrawDListOpa(globalCtx, ptr2->unk_00); + Gfx_DrawDListOpa(play, ptr2->unk_00); if (this->unk_183 != 0) { - AnimatedMat_Draw(globalCtx, D_80B83C70); + AnimatedMat_Draw(play, D_80B83C70); - OPEN_DISPS(globalCtx->state.gfxCtx); + OPEN_DISPS(play->state.gfxCtx); gfx = POLY_XLU_DISP; @@ -708,22 +709,21 @@ void func_80B83758(Actor* thisx, GlobalContext* globalCtx) { for (i = 0, ptr = &this->unk_188[0]; i < ARRAY_COUNT(this->unk_188); i++, ptr++) { if (ptr->unk_0E != 0) { - Matrix_InsertTranslation(ptr->unk_00.x, ptr->unk_00.y, ptr->unk_00.z, MTXMODE_NEW); - Matrix_RotateY(this->dyna.actor.shape.rot.y, MTXMODE_APPLY); - Matrix_InsertXRotation_s(ptr->unk_0C, MTXMODE_APPLY); + Matrix_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); + gSPMatrix(gfx++, Matrix_NewMtx(play->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); + CLOSE_DISPS(play->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 16eed26e3..098f96770 100644 --- a/src/overlays/actors/ovl_Bg_Dblue_Balance/z_bg_dblue_balance.h +++ b/src/overlays/actors/ovl_Bg_Dblue_Balance/z_bg_dblue_balance.h @@ -5,7 +5,7 @@ struct BgDblueBalance; -typedef void (*BgDblueBalanceActionFunc)(struct BgDblueBalance*, GlobalContext*); +typedef void (*BgDblueBalanceActionFunc)(struct BgDblueBalance*, PlayState*); #define BGDBLUEBALANCE_GET_7F(thisx) ((thisx)->params & 0x7F) #define BGDBLUEBALANCE_GET_300(thisx) (((thisx)->params >> 8) & 3) @@ -18,30 +18,30 @@ typedef struct { } BgDblueBalanceStruct; // size = 0x14 typedef struct BgDblueBalance { - /* 0x0000 */ DynaPolyActor dyna; - /* 0x015C */ struct BgDblueBalance* unk_15C; - /* 0x0160 */ struct BgDblueBalance* unk_160; - /* 0x0164 */ struct BgDblueBalance* unk_164; - /* 0x0168 */ BgDblueBalanceActionFunc actionFunc; - /* 0x016C */ s32 unk_16C; - /* 0x0170 */ s32 unk_170; - /* 0x0174 */ s16 unk_174; - /* 0x0176 */ s16 unk_176; - /* 0x0178 */ s16 unk_178; - /* 0x017A */ s16 unk_17A; - /* 0x017C */ s8 unk_17C; - /* 0x017D */ s8 unk_17D; - /* 0x017E */ s8 unk_17E; - /* 0x017F */ s8 unk_17F; - /* 0x0180 */ s8 unk_180; - /* 0x0181 */ s8 unk_181; - /* 0x0182 */ s8 unk_182; - /* 0x0183 */ u8 unk_183; - /* 0x0184 */ s16 unk_184; - /* 0x0186 */ s8 unk_186; - /* 0x0187 */ s8 unk_187; - /* 0x0188 */ BgDblueBalanceStruct unk_188[8]; - /* 0x0228 */ f32 unk_228; + /* 0x000 */ DynaPolyActor dyna; + /* 0x15C */ struct BgDblueBalance* unk_15C; + /* 0x160 */ struct BgDblueBalance* unk_160; + /* 0x164 */ struct BgDblueBalance* unk_164; + /* 0x168 */ BgDblueBalanceActionFunc actionFunc; + /* 0x16C */ s32 unk_16C; + /* 0x170 */ s32 unk_170; + /* 0x174 */ s16 unk_174; + /* 0x176 */ s16 unk_176; + /* 0x178 */ s16 unk_178; + /* 0x17A */ s16 unk_17A; + /* 0x17C */ s8 unk_17C; + /* 0x17D */ s8 unk_17D; + /* 0x17E */ s8 unk_17E; + /* 0x17F */ s8 unk_17F; + /* 0x180 */ s8 unk_180; + /* 0x181 */ s8 unk_181; + /* 0x182 */ s8 unk_182; + /* 0x183 */ u8 unk_183; + /* 0x184 */ s16 unk_184; + /* 0x186 */ s8 unk_186; + /* 0x187 */ s8 unk_187; + /* 0x188 */ BgDblueBalanceStruct unk_188[8]; + /* 0x228 */ f32 unk_228; } BgDblueBalance; // size = 0x22C extern const ActorInit Bg_Dblue_Balance_InitVars; diff --git a/src/overlays/actors/ovl_Bg_Dblue_Elevator/z_bg_dblue_elevator.c b/src/overlays/actors/ovl_Bg_Dblue_Elevator/z_bg_dblue_elevator.c index af6ed5fa2..a945160f0 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 @@ -10,10 +10,10 @@ #define THIS ((BgDblueElevator*)thisx) -void BgDblueElevator_Init(Actor* thisx, GlobalContext* globalCtx); -void BgDblueElevator_Destroy(Actor* thisx, GlobalContext* globalCtx); -void BgDblueElevator_Update(Actor* thisx, GlobalContext* globalCtx); -void BgDblueElevator_Draw(Actor* thisx, GlobalContext* globalCtx); +void BgDblueElevator_Init(Actor* thisx, PlayState* play); +void BgDblueElevator_Destroy(Actor* thisx, PlayState* play); +void BgDblueElevator_Update(Actor* thisx, PlayState* play); +void BgDblueElevator_Draw(Actor* thisx, PlayState* play); #if 0 const ActorInit Bg_Dblue_Elevator_InitVars = { diff --git a/src/overlays/actors/ovl_Bg_Dblue_Elevator/z_bg_dblue_elevator.h b/src/overlays/actors/ovl_Bg_Dblue_Elevator/z_bg_dblue_elevator.h index 41015bdfb..db6cba5b4 100644 --- a/src/overlays/actors/ovl_Bg_Dblue_Elevator/z_bg_dblue_elevator.h +++ b/src/overlays/actors/ovl_Bg_Dblue_Elevator/z_bg_dblue_elevator.h @@ -5,13 +5,13 @@ struct BgDblueElevator; -typedef void (*BgDblueElevatorActionFunc)(struct BgDblueElevator*, GlobalContext*); +typedef void (*BgDblueElevatorActionFunc)(struct BgDblueElevator*, PlayState*); typedef struct BgDblueElevator { - /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x18]; - /* 0x015C */ BgDblueElevatorActionFunc actionFunc; - /* 0x0160 */ char unk_160[0x10]; + /* 0x000 */ Actor actor; + /* 0x144 */ char unk_144[0x18]; + /* 0x15C */ BgDblueElevatorActionFunc actionFunc; + /* 0x160 */ char unk_160[0x10]; } BgDblueElevator; // size = 0x170 extern const ActorInit Bg_Dblue_Elevator_InitVars; diff --git a/src/overlays/actors/ovl_Bg_Dblue_Movebg/z_bg_dblue_movebg.c b/src/overlays/actors/ovl_Bg_Dblue_Movebg/z_bg_dblue_movebg.c index 3a12f286d..c42d96c0f 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 @@ -4,6 +4,7 @@ * Description: Great Bay Temple - Waterwheels and push switches */ +#include "prevent_bss_reordering.h" #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" @@ -12,23 +13,23 @@ #define THIS ((BgDblueMovebg*)thisx) -void BgDblueMovebg_Init(Actor* thisx, GlobalContext* globalCtx); -void BgDblueMovebg_Destroy(Actor* thisx, GlobalContext* globalCtx); -void BgDblueMovebg_Update(Actor* thisx, GlobalContext* globalCtx); -void BgDblueMovebg_Draw(Actor* thisx, GlobalContext* globalCtx); +void BgDblueMovebg_Init(Actor* thisx, PlayState* play); +void BgDblueMovebg_Destroy(Actor* thisx, PlayState* play); +void BgDblueMovebg_Update(Actor* thisx, PlayState* play); +void BgDblueMovebg_Draw(Actor* thisx, PlayState* play); -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); +void func_80A2A1E0(BgDblueMovebg* this, PlayState* play); +void func_80A2A32C(BgDblueMovebg* this, PlayState* play); +void func_80A2A444(BgDblueMovebg* this, PlayState* play); +void func_80A2A670(BgDblueMovebg* this, PlayState* play); +void func_80A2A688(BgDblueMovebg* this, PlayState* play); +void func_80A2A714(BgDblueMovebg* this, PlayState* play); +void func_80A2A7F8(BgDblueMovebg* this, PlayState* play); +void func_80A2AAB8(BgDblueMovebg* this, PlayState* play); +void func_80A2AED0(BgDblueMovebg* this, PlayState* play); +void func_80A2B1A0(BgDblueMovebg* this, PlayState* play); +void func_80A2B274(Actor* thisx, PlayState* play); +void func_80A2B308(Actor* thisx, PlayState* play); BgDblueMovebg* D_80A2BBF0; @@ -107,7 +108,7 @@ static InitChainEntry sInitChain[] = { Vec3f D_80A2B988 = { 1785.0f, 0.0f, 220.0f }; -s32 func_80A29A80(GlobalContext* globalCtx, s32 arg1, s32 arg2) { +s32 func_80A29A80(PlayState* play, s32 arg1, s32 arg2) { s32 sp2C = 1; s32 val; s32 val2; @@ -118,11 +119,11 @@ s32 func_80A29A80(GlobalContext* globalCtx, s32 arg1, s32 arg2) { while (val--) { if ((1 << val) & val2) { - if (!Flags_GetSwitch(globalCtx, arg1 + val)) { + if (!Flags_GetSwitch(play, arg1 + val)) { sp2C = 0; break; } - } else if (Flags_GetSwitch(globalCtx, arg1 + val)) { + } else if (Flags_GetSwitch(play, arg1 + val)) { sp2C = 0; break; } @@ -131,20 +132,20 @@ s32 func_80A29A80(GlobalContext* globalCtx, s32 arg1, s32 arg2) { sp2C = 0; switch (arg2) { case 14: - if (!Flags_GetSwitch(globalCtx, arg1)) { + if (!Flags_GetSwitch(play, arg1)) { sp2C = 1; } - if (Flags_GetSwitch(globalCtx, arg1 + 1) && Flags_GetSwitch(globalCtx, arg1 + 2) && - Flags_GetSwitch(globalCtx, arg1 + 3)) { + if (Flags_GetSwitch(play, arg1 + 1) && Flags_GetSwitch(play, arg1 + 2) && + Flags_GetSwitch(play, arg1 + 3)) { sp2C += 2; } break; case 15: - if (!Flags_GetSwitch(globalCtx, arg1) || - (Flags_GetSwitch(globalCtx, arg1 + 1) && Flags_GetSwitch(globalCtx, arg1 + 2) && - Flags_GetSwitch(globalCtx, arg1 + 3))) { + if (!Flags_GetSwitch(play, arg1) || + (Flags_GetSwitch(play, arg1 + 1) && Flags_GetSwitch(play, arg1 + 2) && + Flags_GetSwitch(play, arg1 + 3))) { sp2C = 1; } break; @@ -153,7 +154,7 @@ s32 func_80A29A80(GlobalContext* globalCtx, s32 arg1, s32 arg2) { return sp2C; } -void BgDblueMovebg_Init(Actor* thisx, GlobalContext* globalCtx) { +void BgDblueMovebg_Init(Actor* thisx, PlayState* play) { s32 pad; BgDblueMovebg* this = THIS; s32 i; @@ -189,7 +190,7 @@ void BgDblueMovebg_Init(Actor* thisx, GlobalContext* globalCtx) { } if (D_80A2B90C[this->unk_160] != NULL) { - DynaPolyActor_LoadMesh(globalCtx, &this->dyna, D_80A2B90C[this->unk_160]); + DynaPolyActor_LoadMesh(play, &this->dyna, D_80A2B90C[this->unk_160]); } this->unk_164 = D_80A2B8AC[this->unk_160]; @@ -206,14 +207,14 @@ void BgDblueMovebg_Init(Actor* thisx, GlobalContext* globalCtx) { 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)) { + if (func_80A29A80(play, 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)) { + if (Flags_GetSwitch(play, this->unk_1C0)) { this->unk_18C = 0x384; } else { this->unk_18C = 0; @@ -223,7 +224,7 @@ void BgDblueMovebg_Init(Actor* thisx, GlobalContext* globalCtx) { break; case 6: - this->unk_178 = func_80A29A80(globalCtx, this->unk_1C0, this->unk_1BC); + this->unk_178 = func_80A29A80(play, this->unk_1C0, this->unk_1BC); this->unk_1CC = D_80A2B96C[this->unk_178]; this->unk_1CE = this->unk_1CC; this->actionFunc = func_80A2A1E0; @@ -236,7 +237,7 @@ void BgDblueMovebg_Init(Actor* thisx, GlobalContext* globalCtx) { 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)) { + if (Flags_GetSwitch(play, this->unk_1C0)) { Actor_MarkForDeath(&this->dyna.actor); break; } @@ -256,12 +257,12 @@ void BgDblueMovebg_Init(Actor* thisx, GlobalContext* globalCtx) { 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_178 = func_80A29A80(play, this->unk_1C0, this->unk_1BC); this->unk_1CC = D_80A2B96C[this->unk_178]; this->unk_1CE = this->unk_1CC; - Matrix_RotateY(this->dyna.actor.shape.rot.y, MTXMODE_NEW); - Matrix_GetStateTranslationAndScaledX(2240.0f, &this->unk_190); - Matrix_GetStateTranslationAndScaledX(-10.0f, &this->unk_19C); + 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; @@ -274,7 +275,7 @@ void BgDblueMovebg_Init(Actor* thisx, GlobalContext* globalCtx) { break; case 11: - this->unk_1CC = D_80A2B96C[func_80A29A80(globalCtx, this->unk_1C0, this->unk_1BC)]; + this->unk_1CC = D_80A2B96C[func_80A29A80(play, this->unk_1C0, this->unk_1BC)]; D_80A2BBF0 = this; this->dyna.actor.flags |= ACTOR_FLAG_20; this->dyna.actor.update = Actor_Noop; @@ -283,20 +284,20 @@ void BgDblueMovebg_Init(Actor* thisx, GlobalContext* globalCtx) { } } -void BgDblueMovebg_Destroy(Actor* thisx, GlobalContext* globalCtx) { +void BgDblueMovebg_Destroy(Actor* thisx, PlayState* play) { BgDblueMovebg* this = THIS; - DynaPoly_DeleteBgActor(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); + DynaPoly_DeleteBgActor(play, &play->colCtx.dyna, this->dyna.bgId); if ((this->unk_160 == 9) || (this->unk_160 == 8)) { - Audio_StopSfxByPos(&this->unk_1A8); + AudioSfx_StopByPos(&this->unk_1A8); } } -void func_80A2A128(BgDblueMovebg* this, GlobalContext* globalCtx) { +void func_80A2A128(BgDblueMovebg* this, PlayState* play) { Actor* phi_s0 = NULL; while (true) { - phi_s0 = SubS_FindActor(globalCtx, phi_s0, ACTORCAT_BG, ACTOR_OBJ_HUNSUI); + phi_s0 = SubS_FindActor(play, 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; @@ -312,8 +313,8 @@ void func_80A2A128(BgDblueMovebg* this, GlobalContext* globalCtx) { } } -void func_80A2A1E0(BgDblueMovebg* this, GlobalContext* globalCtx) { - s32 temp_v0 = func_80A29A80(globalCtx, this->unk_1C0, this->unk_1BC); +void func_80A2A1E0(BgDblueMovebg* this, PlayState* play) { + s32 temp_v0 = func_80A29A80(play, this->unk_1C0, this->unk_1BC); if (temp_v0 != this->unk_178) { switch (temp_v0) { @@ -339,16 +340,15 @@ void func_80A2A1E0(BgDblueMovebg* this, GlobalContext* globalCtx) { Math_StepToS(&this->unk_1CC, this->unk_1CE, 12); this->dyna.actor.shape.rot.y += this->unk_1CC; - if (globalCtx->roomCtx.currRoom.num == 0) { + if (play->roomCtx.currRoom.num == 0) { this->unk_164 = object_dblue_object_DL_004848; - } else if (globalCtx->roomCtx.currRoom.num == 8) { + } else if (play->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)) { + if (play->roomCtx.currRoom.num != this->unk_170) { + if (play->roomCtx.currRoom.num != this->unk_171) { + if ((play->roomCtx.prevRoom.num != this->unk_170) && (play->roomCtx.prevRoom.num != this->unk_171)) { D_80A2BBF4.unk_01 = 0; Actor_MarkForDeath(&this->dyna.actor); } @@ -356,8 +356,8 @@ void func_80A2A1E0(BgDblueMovebg* this, GlobalContext* globalCtx) { } } -void func_80A2A32C(BgDblueMovebg* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); +void func_80A2A32C(BgDblueMovebg* this, PlayState* play) { + Player* player = GET_PLAYER(play); s32 phi_v0; f32 phi_f0; s32 phi_v1; @@ -396,8 +396,8 @@ void func_80A2A32C(BgDblueMovebg* this, GlobalContext* globalCtx) { } } -void func_80A2A444(BgDblueMovebg* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); +void func_80A2A444(BgDblueMovebg* this, PlayState* play) { + Player* player = GET_PLAYER(play); s32 sp20; Player* temp_a3; s16 temp_v0; @@ -422,10 +422,10 @@ void func_80A2A444(BgDblueMovebg* this, GlobalContext* globalCtx) { if (sp20) { player->stateFlags2 &= ~0x10; this->dyna.pushForce = 0.0f; - Flags_SetSwitch(globalCtx, this->unk_1C0); + Flags_SetSwitch(play, this->unk_1C0); Actor_PlaySfxAtPos(&this->dyna.actor, NA_SE_EV_STONEDOOR_STOP); - if (func_80A29A80(globalCtx, this->unk_1C8, this->unk_1C4)) { + if (func_80A29A80(play, this->unk_1C8, this->unk_1C4)) { this->unk_172 |= 1; } else { this->unk_172 &= ~1; @@ -434,17 +434,17 @@ void func_80A2A444(BgDblueMovebg* this, GlobalContext* globalCtx) { if (!(this->unk_174 & 1) && (this->unk_172 & 1)) { func_801000CC(NA_SE_EV_PIPE_STREAM_START); } - func_80A2A670(this, globalCtx); + func_80A2A670(this, play); } else { func_800B9010(&this->dyna.actor, NA_SE_EV_COCK_SWITCH_ROLL - SFX_FLAG); } } -void func_80A2A670(BgDblueMovebg* this, GlobalContext* globalCtx) { +void func_80A2A670(BgDblueMovebg* this, PlayState* play) { this->actionFunc = func_80A2A688; } -void func_80A2A688(BgDblueMovebg* this, GlobalContext* globalCtx) { +void func_80A2A688(BgDblueMovebg* this, PlayState* play) { this->unk_180--; if (this->unk_180 <= 0) { ActorCutscene_Stop(this->unk_1B6[0]); @@ -456,8 +456,8 @@ void func_80A2A688(BgDblueMovebg* this, GlobalContext* globalCtx) { } } -void func_80A2A714(BgDblueMovebg* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); +void func_80A2A714(BgDblueMovebg* this, PlayState* play) { + Player* player = GET_PLAYER(play); s32 phi_v0; f32 phi_f0; @@ -484,8 +484,8 @@ void func_80A2A714(BgDblueMovebg* this, GlobalContext* globalCtx) { } } -void func_80A2A7F8(BgDblueMovebg* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); +void func_80A2A7F8(BgDblueMovebg* this, PlayState* play) { + Player* player = GET_PLAYER(play); s32 sp28; s16 sp26; s32 temp; @@ -511,9 +511,9 @@ void func_80A2A7F8(BgDblueMovebg* this, GlobalContext* globalCtx) { temp = (this->unk_18C + sp26 + 3600) % 3600; if ((temp == 900) || (temp == 2700)) { - Flags_SetSwitch(globalCtx, this->unk_1C0); + Flags_SetSwitch(play, this->unk_1C0); } else { - Flags_UnsetSwitch(globalCtx, this->unk_1C0); + Flags_UnsetSwitch(play, this->unk_1C0); } player->stateFlags1 |= 0x20; @@ -527,7 +527,7 @@ void func_80A2A7F8(BgDblueMovebg* this, GlobalContext* globalCtx) { Actor_PlaySfxAtPos(&this->dyna.actor, NA_SE_EV_STONEDOOR_STOP); - if (func_80A29A80(globalCtx, this->unk_1C8, this->unk_1C4)) { + if (func_80A29A80(play, this->unk_1C8, this->unk_1C4)) { this->unk_172 |= 1; } else { this->unk_172 &= ~1; @@ -545,8 +545,8 @@ void func_80A2A7F8(BgDblueMovebg* this, GlobalContext* globalCtx) { } } -void func_80A2AAB8(BgDblueMovebg* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); +void func_80A2AAB8(BgDblueMovebg* this, PlayState* play) { + Player* player = GET_PLAYER(play); s32 sp18; if (this->unk_180-- <= 0) { @@ -576,7 +576,7 @@ void func_80A2AAB8(BgDblueMovebg* this, GlobalContext* globalCtx) { } } -void func_80A2ABD0(BgDblueMovebg* this, GlobalContext* globalCtx) { +void func_80A2ABD0(BgDblueMovebg* this, PlayState* play) { Vec3f spAC; f32 temp_f0; f32 temp_f20; @@ -586,15 +586,15 @@ void func_80A2ABD0(BgDblueMovebg* this, GlobalContext* globalCtx) { for (i = 0; i < ARRAY_COUNT(this->unk_2F8); i++) { if (this->unk_2F8[i] == NULL) { - func_80A2A128(this, globalCtx); + func_80A2A128(this, play); continue; } for (j = 0; j < ARRAY_COUNT(this->unk_1D8[0]); j++) { - Matrix_RotateY(this->dyna.actor.shape.rot.y, MTXMODE_NEW); - Matrix_InsertXRotation_s(this->dyna.actor.shape.rot.x + (j * 0x2000), MTXMODE_APPLY); - Matrix_InsertZRotation_s(this->dyna.actor.shape.rot.z, MTXMODE_APPLY); - Matrix_MultiplyVector3fByState(&D_80A2B988, &spAC); + 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; @@ -624,14 +624,13 @@ void func_80A2ABD0(BgDblueMovebg* this, GlobalContext* globalCtx) { } } -void func_80A2AED0(BgDblueMovebg* this, GlobalContext* globalCtx) { +void func_80A2AED0(BgDblueMovebg* this, PlayState* play) { 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)) { + if (play->roomCtx.currRoom.num != this->unk_170) { + if (play->roomCtx.currRoom.num != this->unk_171) { + if ((play->roomCtx.prevRoom.num != this->unk_170) && (play->roomCtx.prevRoom.num != this->unk_171)) { D_80A2BBF4.unk_00 = 0; Actor_MarkForDeath(&this->dyna.actor); return; @@ -639,7 +638,7 @@ void func_80A2AED0(BgDblueMovebg* this, GlobalContext* globalCtx) { } } - temp_v0_3 = func_80A29A80(globalCtx, this->unk_1C0, this->unk_1BC); + temp_v0_3 = func_80A29A80(play, this->unk_1C0, this->unk_1BC); if (temp_v0_3 != this->unk_178) { switch (temp_v0_3) { case 1: @@ -670,17 +669,17 @@ void func_80A2AED0(BgDblueMovebg* this, GlobalContext* globalCtx) { this->dyna.actor.shape.rot.x += this->unk_1CC; if (this->unk_160 == 8) { - if (globalCtx->roomCtx.currRoom.num == 8) { - func_80A2ABD0(this, globalCtx); + if (play->roomCtx.currRoom.num == 8) { + func_80A2ABD0(this, play); this->unk_172 |= 0x20; } else { this->unk_172 &= ~0x20; } } - if (globalCtx->roomCtx.currRoom.num == 0) { + if (play->roomCtx.currRoom.num == 0) { this->unk_164 = object_dblue_object_DL_008778; - } else if (globalCtx->roomCtx.currRoom.num == 8) { + } else if (play->roomCtx.currRoom.num == 8) { this->unk_164 = object_dblue_object_DL_00A528; } @@ -688,25 +687,25 @@ void func_80A2AED0(BgDblueMovebg* this, GlobalContext* globalCtx) { Vec3f sp54; f32 sp50; - if (Math3D_PointDistToLine2D(globalCtx->view.eye.x, globalCtx->view.eye.z, this->unk_190.x, this->unk_190.z, + if (Math3D_PointDistToLine2D(play->view.eye.x, play->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)) { + if (Math_Vec3f_DistXYZ(&play->view.eye, &this->unk_190) <= + Math_Vec3f_DistXYZ(&play->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); + SkinMatrix_Vec3fMtxFMultXYZ(&play->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)) { +void func_80A2B1A0(BgDblueMovebg* this, PlayState* play) { + switch (func_80A29A80(play, this->unk_1C0, this->unk_1BC)) { case 1: this->dyna.actor.shape.rot.z = this->dyna.actor.home.rot.z; break; @@ -717,10 +716,10 @@ void func_80A2B1A0(BgDblueMovebg* this, GlobalContext* globalCtx) { } } -void BgDblueMovebg_Update(Actor* thisx, GlobalContext* globalCtx) { +void BgDblueMovebg_Update(Actor* thisx, PlayState* play) { BgDblueMovebg* this = THIS; - this->actionFunc(this, globalCtx); + this->actionFunc(this, play); if (this->unk_172 & 8) { if (SubS_StartActorCutscene(&this->dyna.actor, this->unk_1D2, -1, SUBS_CUTSCENE_SET_UNK_LINK_FIELDS)) { @@ -729,7 +728,7 @@ void BgDblueMovebg_Update(Actor* thisx, GlobalContext* globalCtx) { } } -void func_80A2B274(Actor* thisx, GlobalContext* globalCtx) { +void func_80A2B274(Actor* thisx, PlayState* play) { BgDblueMovebg* this = THIS; s16 temp_v1; @@ -738,7 +737,7 @@ void func_80A2B274(Actor* thisx, GlobalContext* globalCtx) { return; } - temp_v1 = D_80A2B96C[func_80A29A80(globalCtx, this->unk_1C0, this->unk_1BC)]; + temp_v1 = D_80A2B96C[func_80A29A80(play, 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); @@ -748,41 +747,41 @@ void func_80A2B274(Actor* thisx, GlobalContext* globalCtx) { } } -void func_80A2B308(Actor* thisx, GlobalContext* globalCtx) { +void func_80A2B308(Actor* thisx, PlayState* play) { s32 pad; BgDblueMovebg* this = THIS; - OPEN_DISPS(globalCtx->state.gfxCtx); + OPEN_DISPS(play->state.gfxCtx); - func_8012C28C(globalCtx->state.gfxCtx); + func_8012C28C(play->state.gfxCtx); - gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_OPA_DISP++, this->unk_164); - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->state.gfxCtx); } -void BgDblueMovebg_Draw(Actor* thisx, GlobalContext* globalCtx2) { - GlobalContext* globalCtx = globalCtx2; +void BgDblueMovebg_Draw(Actor* thisx, PlayState* play2) { + PlayState* play = play2; BgDblueMovebg* this = THIS; s32 i; s32 j; Gfx* gfx; Gfx* gfx2; - Matrix_StatePush(); + Matrix_Push(); - OPEN_DISPS(globalCtx->state.gfxCtx); + OPEN_DISPS(play->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)); + AnimatedMat_Draw(play, 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); + gSPMatrix(&gfx2[0], Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); if (this->unk_160 == 6) { gSPDisplayList(&gfx2[1], object_dblue_object_DL_0052B8); @@ -801,61 +800,59 @@ void BgDblueMovebg_Draw(Actor* thisx, GlobalContext* globalCtx2) { 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); + gSPMatrix(&gfx[0], Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(&gfx[1], this->unk_168); POLY_XLU_DISP = &gfx[2]; } } - Matrix_StatePop(); + Matrix_Pop(); - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->state.gfxCtx); if ((this->unk_160 == 8) && (this->unk_172 & 0x20)) { - AnimatedMat_Draw(globalCtx, Lib_SegmentedToVirtual(&object_dblue_object_Matanimheader_00CE00)); + AnimatedMat_Draw(play, Lib_SegmentedToVirtual(&object_dblue_object_Matanimheader_00CE00)); - OPEN_DISPS(globalCtx->state.gfxCtx); + OPEN_DISPS(play->state.gfxCtx); - Matrix_InsertTranslation(this->dyna.actor.world.pos.x, this->dyna.actor.world.pos.y, - this->dyna.actor.world.pos.z, MTXMODE_NEW); - Matrix_RotateY(this->dyna.actor.shape.rot.y, MTXMODE_APPLY); - Matrix_InsertXRotation_s(this->dyna.actor.shape.rot.x, MTXMODE_APPLY); - Matrix_InsertZRotation_s(this->dyna.actor.shape.rot.z, MTXMODE_APPLY); + 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)); + gSPSegment(gfx++, 0x09, + Gfx_TwoTexScroll(play->state.gfxCtx, 0, 0, + (s32)(((play->gameplayFrames % 128) * -9.0f) / this->unk_1F8[j][i]), + 0x20, 0x20, 1, 0, 0, 0x20, 0x20)); } - Matrix_StatePush(); - Matrix_InsertXRotation_s(i * 0x2000, MTXMODE_APPLY); - Matrix_InsertTranslation(1785.0f, 0.0f, 270.0f, MTXMODE_APPLY); + Matrix_Push(); + Matrix_RotateXS(i * 0x2000, MTXMODE_APPLY); + Matrix_Translate(1785.0f, 0.0f, 270.0f, MTXMODE_APPLY); if (j != 0) { - Matrix_InsertZRotation_s(-0x8000, MTXMODE_APPLY); + 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); + gSPMatrix(gfx++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gDPSetEnvColor(gfx++, 255, 255, 255, this->unk_1D8[j][i]); gSPDisplayList(gfx++, object_dblue_object_DL_00CD10); - Matrix_StatePop(); + Matrix_Pop(); } } } POLY_XLU_DISP = gfx; - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->state.gfxCtx); } if ((this->unk_160 == 9) || (this->unk_160 == 8)) { diff --git a/src/overlays/actors/ovl_Bg_Dblue_Movebg/z_bg_dblue_movebg.h b/src/overlays/actors/ovl_Bg_Dblue_Movebg/z_bg_dblue_movebg.h index b48776238..83fb1df62 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 @@ -5,7 +5,7 @@ struct BgDblueMovebg; -typedef void (*BgDblueMovebgActionFunc)(struct BgDblueMovebg*, GlobalContext*); +typedef void (*BgDblueMovebgActionFunc)(struct BgDblueMovebg*, PlayState*); #define BGDBLUEMOVEBG_GET_F(thisx) ((thisx)->params & 0xF) #define BGDBLUEMOVEBG_GET_FF0(thisx) (((thisx)->params >> 4) & 0xFF) 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 cd3b8a9d6..6f914a475 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 @@ -11,19 +11,19 @@ #define THIS ((BgDblueWaterfall*)thisx) -void BgDblueWaterfall_Init(Actor* thisx, GlobalContext* globalCtx); -void BgDblueWaterfall_Destroy(Actor* thisx, GlobalContext* globalCtx); -void BgDblueWaterfall_Update(Actor* thisx, GlobalContext* globalCtx); -void BgDblueWaterfall_Draw(Actor* thisx, GlobalContext* globalCtx); +void BgDblueWaterfall_Init(Actor* thisx, PlayState* play); +void BgDblueWaterfall_Destroy(Actor* thisx, PlayState* play); +void BgDblueWaterfall_Update(Actor* thisx, PlayState* play); +void BgDblueWaterfall_Draw(Actor* thisx, PlayState* play); -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); +void func_80B8484C(BgDblueWaterfall* this, PlayState* play); +void func_80B84928(BgDblueWaterfall* this, PlayState* play); +void func_80B84AD4(BgDblueWaterfall* this, PlayState* play); +void func_80B84AEC(BgDblueWaterfall* this, PlayState* play); +void func_80B84B9C(BgDblueWaterfall* this, PlayState* play); +void func_80B84BCC(BgDblueWaterfall* this, PlayState* play); +void func_80B84EF0(BgDblueWaterfall* this, PlayState* play); +void func_80B84F20(BgDblueWaterfall* this, PlayState* play); const ActorInit Bg_Dblue_Waterfall_InitVars = { ACTOR_BG_DBLUE_WATERFALL, @@ -76,11 +76,11 @@ s32 func_80B83C80(Vec3f* arg0, Vec3f* arg1) { return true; } -s32 func_80B83D04(BgDblueWaterfall* this, GlobalContext* globalCtx) { +s32 func_80B83D04(BgDblueWaterfall* this, PlayState* play) { s32 phi_v1; s32 sp18 = BGDBLUEWATERFALL_GET_100(&this->actor); - if (Flags_GetSwitch(globalCtx, BGDBLUEWATERFALL_GET_7F(&this->actor))) { + if (Flags_GetSwitch(play, BGDBLUEWATERFALL_GET_7F(&this->actor))) { phi_v1 = true; } else { phi_v1 = false; @@ -88,22 +88,22 @@ s32 func_80B83D04(BgDblueWaterfall* this, GlobalContext* globalCtx) { return phi_v1 ^ sp18; } -s32 func_80B83D58(Actor* thisx, GlobalContext* globalCtx) { +s32 func_80B83D58(Actor* thisx, PlayState* play) { BgDblueWaterfall* this = THIS; - if (Flags_GetSwitch(globalCtx, BGDBLUEWATERFALL_GET_7F(&this->actor))) { + if (Flags_GetSwitch(play, BGDBLUEWATERFALL_GET_7F(&this->actor))) { return false; } return true; } -void func_80B83D94(BgDblueWaterfall* this, GlobalContext* globalCtx) { +void func_80B83D94(BgDblueWaterfall* this, PlayState* play) { s32 pad; s32 sp20 = BGDBLUEWATERFALL_GET_7F(&this->actor); s32 sp1C = BGDBLUEWATERFALL_GET_100(&this->actor); s32 phi_v0; - if (Flags_GetSwitch(globalCtx, sp20)) { + if (Flags_GetSwitch(play, sp20)) { phi_v0 = true; } else { phi_v0 = false; @@ -111,20 +111,20 @@ void func_80B83D94(BgDblueWaterfall* this, GlobalContext* globalCtx) { if (phi_v0 != sp1C) { if (phi_v0) { - Flags_UnsetSwitch(globalCtx, sp20); + Flags_UnsetSwitch(play, sp20); } else { - Flags_SetSwitch(globalCtx, sp20); + Flags_SetSwitch(play, sp20); } } } -void func_80B83E1C(BgDblueWaterfall* this, GlobalContext* globalCtx) { +void func_80B83E1C(BgDblueWaterfall* this, PlayState* play) { s32 pad; s32 sp20 = BGDBLUEWATERFALL_GET_7F(&this->actor); s32 sp1C = BGDBLUEWATERFALL_GET_100(&this->actor); s32 phi_v0; - if (Flags_GetSwitch(globalCtx, sp20)) { + if (Flags_GetSwitch(play, sp20)) { phi_v0 = true; } else { phi_v0 = false; @@ -132,14 +132,14 @@ void func_80B83E1C(BgDblueWaterfall* this, GlobalContext* globalCtx) { if (phi_v0 == sp1C) { if (phi_v0) { - Flags_UnsetSwitch(globalCtx, sp20); + Flags_UnsetSwitch(play, sp20); } else { - Flags_SetSwitch(globalCtx, sp20); + Flags_SetSwitch(play, sp20); } } } -void func_80B83EA4(BgDblueWaterfall* this, GlobalContext* globalCtx) { +void func_80B83EA4(BgDblueWaterfall* this, PlayState* play) { s32 i; s32 temp_s1; Vec3f spD4; @@ -189,13 +189,13 @@ void func_80B83EA4(BgDblueWaterfall* this, GlobalContext* globalCtx) { 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); + EffectSsEnIce_Spawn(play, &spD4, (Rand_ZeroOne() * 0.3f) + 0.1f, &spC8, &spBC, &D_80B8539C, &D_80B853A0, + 30); } } } -void func_80B841A0(BgDblueWaterfall* this, GlobalContext* globalCtx) { +void func_80B841A0(BgDblueWaterfall* this, PlayState* play) { Vec3f sp94; s32 i; f32 temp_f0; @@ -220,15 +220,15 @@ void func_80B841A0(BgDblueWaterfall* this, GlobalContext* globalCtx) { 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); + EffectSsGSplash_Spawn(play, &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) { +void func_80B84348(BgDblueWaterfall* this, PlayState* play, 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; @@ -263,20 +263,19 @@ void func_80B84348(BgDblueWaterfall* this, GlobalContext* globalCtx, f32 arg2, f 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); + EffectSsIceSmoke_Spawn(play, &sp98, &sp8C, &sp80, (Rand_ZeroOne() * arg7) + arg6); } } -void func_80B84568(BgDblueWaterfall* this, GlobalContext* globalCtx) { +void func_80B84568(BgDblueWaterfall* this, PlayState* play) { s32 pad; CollisionPoly* sp40; WaterBox* sp3C; s32 sp38; - f32 sp34 = BgCheck_EntityRaycastFloor5(&globalCtx->colCtx, &sp40, &sp38, &this->actor, &this->actor.world.pos); + f32 sp34 = BgCheck_EntityRaycastFloor5(&play->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 (WaterBox_GetSurface1_2(play, &play->colCtx, this->actor.world.pos.x, this->actor.world.pos.z, &sp30, &sp3C)) { if (sp30 < sp34) { this->unk_198 = sp34; } else { @@ -287,15 +286,15 @@ void func_80B84568(BgDblueWaterfall* this, GlobalContext* globalCtx) { } } -void func_80B84610(BgDblueWaterfall* this, GlobalContext* globalCtx) { +void func_80B84610(BgDblueWaterfall* this, PlayState* play) { s32 pad[2]; Vec3f sp34; - Player* player = GET_PLAYER(globalCtx); + Player* player = GET_PLAYER(play); if (this->unk_1A7 <= 0) { this->unk_1A7 = 16; } else { - this->unk_1A7 -= (s8)((u32)Rand_Next() >> 0x1F); + this->unk_1A7 -= (s8)(Rand_Next() >> 0x1F); } if (this->unk_1A7 >= 6) { @@ -314,10 +313,10 @@ void func_80B84610(BgDblueWaterfall* this, GlobalContext* globalCtx) { } } - Matrix_StatePush(); - Matrix_RotateY(BINANG_ADD(this->actor.yawTowardsPlayer, 0x4000), MTXMODE_NEW); - Matrix_GetStateTranslationAndScaledZ(this->unk_1A8, &sp34); - Matrix_StatePop(); + 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; @@ -333,7 +332,7 @@ static InitChainEntry sInitChain[] = { ICHAIN_VEC3F_DIV1000(scale, 100, ICHAIN_STOP), }; -void BgDblueWaterfall_Init(Actor* thisx, GlobalContext* globalCtx) { +void BgDblueWaterfall_Init(Actor* thisx, PlayState* play) { s32 pad; BgDblueWaterfall* this = THIS; @@ -341,26 +340,26 @@ void BgDblueWaterfall_Init(Actor* thisx, GlobalContext* globalCtx) { this->actor.shape.rot.z = 0; this->actor.world.rot.z = 0; - Collider_InitCylinder(globalCtx, &this->collider); - Collider_SetCylinder(globalCtx, &this->collider, &this->actor, &sCylinderInit); + Collider_InitCylinder(play, &this->collider); + Collider_SetCylinder(play, &this->collider, &this->actor, &sCylinderInit); Collider_UpdateCylinder(&this->actor, &this->collider); this->unk_190 = Lib_SegmentedToVirtual(object_dblue_object_Matanimheader_00B448); Actor_SetFocus(&this->actor, -100.0f); - func_80B84568(this, globalCtx); - func_80B8484C(this, globalCtx); + func_80B84568(this, play); + func_80B8484C(this, play); } -void BgDblueWaterfall_Destroy(Actor* thisx, GlobalContext* globalCtx) { +void BgDblueWaterfall_Destroy(Actor* thisx, PlayState* play) { BgDblueWaterfall* this = THIS; - Collider_DestroyCylinder(globalCtx, &this->collider); + Collider_DestroyCylinder(play, &this->collider); } -void func_80B8484C(BgDblueWaterfall* this, GlobalContext* globalCtx) { +void func_80B8484C(BgDblueWaterfall* this, PlayState* play) { s32 pad; - s32 temp = func_80B83D04(this, globalCtx); + s32 temp = func_80B83D04(this, play); s32 sp1C = this->actor.home.rot.z * 10; if (temp) { @@ -381,7 +380,7 @@ void func_80B8484C(BgDblueWaterfall* this, GlobalContext* globalCtx) { this->actor.colChkInfo.mass = MASS_IMMOVABLE; } - if ((sp1C != 0) && !func_80B83D58(&this->actor, globalCtx)) { + if ((sp1C != 0) && !func_80B83D58(&this->actor, play)) { this->unk_19C = sp1C; } else { this->unk_19C = 0; @@ -391,9 +390,9 @@ void func_80B8484C(BgDblueWaterfall* this, GlobalContext* globalCtx) { this->actionFunc = func_80B84928; } -void func_80B84928(BgDblueWaterfall* this, GlobalContext* globalCtx) { +void func_80B84928(BgDblueWaterfall* this, PlayState* play) { s32 pad; - s32 sp30 = func_80B83D04(this, globalCtx); + s32 sp30 = func_80B83D04(this, play); s32 sp2C = (this->collider.base.acFlags & AC_HIT) != 0; s32 sp28 = false; @@ -402,18 +401,18 @@ void func_80B84928(BgDblueWaterfall* this, GlobalContext* globalCtx) { } if ((sp30 == 0) && (this->collider.base.ocFlags2 & OC2_HIT_PLAYER)) { - func_80B84610(this, globalCtx); + func_80B84610(this, play); } if (this->unk_19C > 0) { this->unk_19C--; if (this->unk_19C == 0) { if (sp30 != 0) { - func_80B83D94(this, globalCtx); - func_80B84EF0(this, globalCtx); + func_80B83D94(this, play); + func_80B84EF0(this, play); } else { - func_80B83E1C(this, globalCtx); - func_80B84B9C(this, globalCtx); + func_80B83E1C(this, play); + func_80B84B9C(this, play); } sp28 = true; } @@ -422,50 +421,50 @@ void func_80B84928(BgDblueWaterfall* this, GlobalContext* globalCtx) { if (!sp28) { if (sp2C) { if (sp30 != 0) { - func_80B83EA4(this, globalCtx); + func_80B83EA4(this, play); if (this->collider.info.acHitInfo->toucher.dmgFlags & 0x800) { this->unk_1A4 = this->actor.cutscene; - func_80B84AD4(this, globalCtx); + func_80B84AD4(this, play); } } else { - func_80B841A0(this, globalCtx); + func_80B841A0(this, play); if (this->collider.info.acHitInfo->toucher.dmgFlags & 0x1000) { this->unk_1A4 = ActorCutscene_GetAdditionalCutscene(this->actor.cutscene); - func_80B84AD4(this, globalCtx); + func_80B84AD4(this, play); } } } else { - CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); - CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + CollisionCheck_SetAC(play, &play->colChkCtx, &this->collider.base); + CollisionCheck_SetOC(play, &play->colChkCtx, &this->collider.base); } } } -void func_80B84AD4(BgDblueWaterfall* this, GlobalContext* globalCtx) { +void func_80B84AD4(BgDblueWaterfall* this, PlayState* play) { this->actionFunc = func_80B84AEC; } -void func_80B84AEC(BgDblueWaterfall* this, GlobalContext* globalCtx) { +void func_80B84AEC(BgDblueWaterfall* this, PlayState* play) { s32 pad; s32 sp20; if (ActorCutscene_GetCanPlayNext(this->unk_1A4)) { - sp20 = func_80B83D04(this, globalCtx); + sp20 = func_80B83D04(this, play); ActorCutscene_StartAndSetUnkLinkFields(this->unk_1A4, &this->actor); this->unk_1A3 = true; if (sp20) { - func_80B83D94(this, globalCtx); - func_80B84EF0(this, globalCtx); + func_80B83D94(this, play); + func_80B84EF0(this, play); } else { - func_80B83E1C(this, globalCtx); - func_80B84B9C(this, globalCtx); + func_80B83E1C(this, play); + func_80B84B9C(this, play); } } else { ActorCutscene_SetIntentToPlay(this->unk_1A4); } } -void func_80B84B9C(BgDblueWaterfall* this, GlobalContext* globalCtx) { +void func_80B84B9C(BgDblueWaterfall* this, PlayState* play) { this->unk_19C = 60; this->unk_19E = 255; this->unk_19F = 0; @@ -473,7 +472,7 @@ void func_80B84B9C(BgDblueWaterfall* this, GlobalContext* globalCtx) { this->actionFunc = func_80B84BCC; } -void func_80B84BCC(BgDblueWaterfall* this, GlobalContext* globalCtx) { +void func_80B84BCC(BgDblueWaterfall* this, PlayState* play) { s32 pad; this->unk_19C--; @@ -481,23 +480,23 @@ void func_80B84BCC(BgDblueWaterfall* this, GlobalContext* globalCtx) { s32 sp38 = this->unk_19C & 1; if (this->unk_19C > 56) { - func_80B84348(this, globalCtx, 0.0f, -5500.0f, 0.4f, -15.0f, 370.0f, 100.0f, 6); + func_80B84348(this, play, 0.0f, -5500.0f, 0.4f, -15.0f, 370.0f, 100.0f, 6); } 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, + func_80B84348(this, play, (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); } } if (this->unk_19C > 50) { - func_80B84348(this, globalCtx, 0.0f, -400.0f, 0.6f, -12.0f, 370.0f, 100.0f, 2); + func_80B84348(this, play, 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); + func_80B84348(this, play, 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); + func_80B84348(this, play, 0.0f, -400.0f, 1.8f, -12.0f, 370.0f, 100.0f, 2); } } @@ -536,11 +535,11 @@ void func_80B84BCC(BgDblueWaterfall* this, GlobalContext* globalCtx) { if (this->unk_1A3) { ActorCutscene_Stop(this->unk_1A4); } - func_80B8484C(this, globalCtx); + func_80B8484C(this, play); } } -void func_80B84EF0(BgDblueWaterfall* this, GlobalContext* globalCtx) { +void func_80B84EF0(BgDblueWaterfall* this, PlayState* play) { this->unk_19C = 60; this->unk_19E = 0; this->unk_19F = 255; @@ -548,12 +547,12 @@ void func_80B84EF0(BgDblueWaterfall* this, GlobalContext* globalCtx) { this->actionFunc = func_80B84F20; } -void func_80B84F20(BgDblueWaterfall* this, GlobalContext* globalCtx) { +void func_80B84F20(BgDblueWaterfall* this, PlayState* play) { 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); + func_80B84348(this, play, 100.0f, -100.0f, 4.0f, -6.0f, 370.0f, 100.0f, 0xC); } if (this->unk_19C < 50) { @@ -575,30 +574,30 @@ void func_80B84F20(BgDblueWaterfall* this, GlobalContext* globalCtx) { if (this->unk_1A3) { ActorCutscene_Stop(this->unk_1A4); } - func_80B8484C(this, globalCtx); + func_80B8484C(this, play); } } -void BgDblueWaterfall_Update(Actor* thisx, GlobalContext* globalCtx) { +void BgDblueWaterfall_Update(Actor* thisx, PlayState* play) { BgDblueWaterfall* this = THIS; - this->actionFunc(this, globalCtx); + this->actionFunc(this, play); } -void BgDblueWaterfall_Draw(Actor* thisx, GlobalContext* globalCtx) { +void BgDblueWaterfall_Draw(Actor* thisx, PlayState* play) { s32 pad; BgDblueWaterfall* this = THIS; - OPEN_DISPS(globalCtx->state.gfxCtx); + OPEN_DISPS(play->state.gfxCtx); - func_8012C2DC(globalCtx->state.gfxCtx); + func_8012C2DC(play->state.gfxCtx); - gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); if (this->unk_19E > 0) { s32 sp38 = this->unk_19E * 0.49803922f; - AnimatedMat_Draw(globalCtx, this->unk_190); + AnimatedMat_Draw(play, this->unk_190); gDPSetPrimColor(POLY_XLU_DISP++, 0, 0x8A, 255, 255, 255, sp38); gSPDisplayList(POLY_XLU_DISP++, object_dblue_object_DL_00B280); @@ -610,12 +609,11 @@ void BgDblueWaterfall_Draw(Actor* thisx, GlobalContext* globalCtx) { 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); + func_8012C28C(play->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); + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_OPA_DISP++, object_dblue_object_DL_003358); } @@ -628,5 +626,5 @@ void BgDblueWaterfall_Draw(Actor* thisx, GlobalContext* globalCtx) { gSPDisplayList(POLY_XLU_DISP++, object_dblue_object_DL_003770); } - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->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 0fa908629..c02b82619 100644 --- a/src/overlays/actors/ovl_Bg_Dblue_Waterfall/z_bg_dblue_waterfall.h +++ b/src/overlays/actors/ovl_Bg_Dblue_Waterfall/z_bg_dblue_waterfall.h @@ -5,27 +5,27 @@ struct BgDblueWaterfall; -typedef void (*BgDblueWaterfallActionFunc)(struct BgDblueWaterfall*, GlobalContext*); +typedef void (*BgDblueWaterfallActionFunc)(struct BgDblueWaterfall*, PlayState*); #define BGDBLUEWATERFALL_GET_7F(thisx) ((thisx)->params & 0x7F) #define BGDBLUEWATERFALL_GET_100(thisx) (((thisx)->params >> 8) & 1) typedef struct BgDblueWaterfall { - /* 0x0000 */ Actor actor; - /* 0x0144 */ ColliderCylinder collider; - /* 0x0190 */ AnimatedMaterial* unk_190; - /* 0x0194 */ BgDblueWaterfallActionFunc actionFunc; - /* 0x0198 */ f32 unk_198; - /* 0x019C */ s16 unk_19C; - /* 0x019E */ u8 unk_19E; - /* 0x019F */ u8 unk_19F; - /* 0x01A0 */ u8 unk_1A0; - /* 0x01A1 */ UNK_TYPE1 unk1A1[2]; - /* 0x01A3 */ s8 unk_1A3; - /* 0x01A4 */ s16 unk_1A4; - /* 0x01A6 */ UNK_TYPE1 unk1A6[1]; - /* 0x01A7 */ s8 unk_1A7; - /* 0x01A8 */ f32 unk_1A8; + /* 0x000 */ Actor actor; + /* 0x144 */ ColliderCylinder collider; + /* 0x190 */ AnimatedMaterial* unk_190; + /* 0x194 */ BgDblueWaterfallActionFunc actionFunc; + /* 0x198 */ f32 unk_198; + /* 0x19C */ s16 unk_19C; + /* 0x19E */ u8 unk_19E; + /* 0x19F */ u8 unk_19F; + /* 0x1A0 */ u8 unk_1A0; + /* 0x1A1 */ UNK_TYPE1 unk1A1[2]; + /* 0x1A3 */ s8 unk_1A3; + /* 0x1A4 */ s16 unk_1A4; + /* 0x1A6 */ UNK_TYPE1 unk1A6[1]; + /* 0x1A7 */ s8 unk_1A7; + /* 0x1A8 */ f32 unk_1A8; } BgDblueWaterfall; // size = 0x1AC extern const ActorInit Bg_Dblue_Waterfall_InitVars; diff --git a/src/overlays/actors/ovl_Bg_Dkjail_Ivy/z_bg_dkjail_ivy.c b/src/overlays/actors/ovl_Bg_Dkjail_Ivy/z_bg_dkjail_ivy.c index c5757ad0d..adeba93c8 100644 --- a/src/overlays/actors/ovl_Bg_Dkjail_Ivy/z_bg_dkjail_ivy.c +++ b/src/overlays/actors/ovl_Bg_Dkjail_Ivy/z_bg_dkjail_ivy.c @@ -10,10 +10,10 @@ #define THIS ((BgDkjailIvy*)thisx) -void BgDkjailIvy_Init(Actor* thisx, GlobalContext* globalCtx); -void BgDkjailIvy_Destroy(Actor* thisx, GlobalContext* globalCtx); -void BgDkjailIvy_Update(Actor* thisx, GlobalContext* globalCtx); -void BgDkjailIvy_Draw(Actor* thisx, GlobalContext* globalCtx); +void BgDkjailIvy_Init(Actor* thisx, PlayState* play); +void BgDkjailIvy_Destroy(Actor* thisx, PlayState* play); +void BgDkjailIvy_Update(Actor* thisx, PlayState* play); +void BgDkjailIvy_Draw(Actor* thisx, PlayState* play); #if 0 const ActorInit Bg_Dkjail_Ivy_InitVars = { diff --git a/src/overlays/actors/ovl_Bg_Dkjail_Ivy/z_bg_dkjail_ivy.h b/src/overlays/actors/ovl_Bg_Dkjail_Ivy/z_bg_dkjail_ivy.h index 0c4d95bb6..c4d824dc0 100644 --- a/src/overlays/actors/ovl_Bg_Dkjail_Ivy/z_bg_dkjail_ivy.h +++ b/src/overlays/actors/ovl_Bg_Dkjail_Ivy/z_bg_dkjail_ivy.h @@ -5,13 +5,13 @@ struct BgDkjailIvy; -typedef void (*BgDkjailIvyActionFunc)(struct BgDkjailIvy*, GlobalContext*); +typedef void (*BgDkjailIvyActionFunc)(struct BgDkjailIvy*, PlayState*); typedef struct BgDkjailIvy { - /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x64]; - /* 0x01A8 */ BgDkjailIvyActionFunc actionFunc; - /* 0x01AC */ char unk_1AC[0x4]; + /* 0x000 */ Actor actor; + /* 0x144 */ char unk_144[0x64]; + /* 0x1A8 */ BgDkjailIvyActionFunc actionFunc; + /* 0x1AC */ char unk_1AC[0x4]; } BgDkjailIvy; // size = 0x1B0 extern const ActorInit Bg_Dkjail_Ivy_InitVars; diff --git a/src/overlays/actors/ovl_Bg_Dy_Yoseizo/z_bg_dy_yoseizo.c b/src/overlays/actors/ovl_Bg_Dy_Yoseizo/z_bg_dy_yoseizo.c index 4e9bf5c63..b1bdc822c 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 @@ -10,20 +10,20 @@ #define THIS ((BgDyYoseizo*)thisx) -void BgDyYoseizo_Init(Actor* thisx, GlobalContext* globalCtx); -void BgDyYoseizo_Destroy(Actor* thisx, GlobalContext* globalCtx); -void BgDyYoseizo_Update(Actor* thisx, GlobalContext* globalCtx); +void BgDyYoseizo_Init(Actor* thisx, PlayState* play); +void BgDyYoseizo_Destroy(Actor* thisx, PlayState* play); +void BgDyYoseizo_Update(Actor* thisx, PlayState* play); -void func_80A0AE1C(BgDyYoseizo* this, GlobalContext* globalCtx); -void func_80A0B078(BgDyYoseizo* this, GlobalContext* globalCtx); -void func_80A0B184(BgDyYoseizo* this, GlobalContext* globalCtx); -void func_80A0B290(BgDyYoseizo* this, GlobalContext* globalCtx); -void func_80A0B35C(BgDyYoseizo* this, GlobalContext* globalCtx); -void func_80A0B500(BgDyYoseizo* this, GlobalContext* globalCtx); -void func_80A0B5F0(BgDyYoseizo* this, GlobalContext* globalCtx); -void func_80A0B75C(BgDyYoseizo* this, GlobalContext* globalCtx); -void func_80A0B8CC(BgDyYoseizo* this, GlobalContext* globalCtx); -void func_80A0BB08(BgDyYoseizo* this, GlobalContext* globalCtx); +void func_80A0AE1C(BgDyYoseizo* this, PlayState* play); +void func_80A0B078(BgDyYoseizo* this, PlayState* play); +void func_80A0B184(BgDyYoseizo* this, PlayState* play); +void func_80A0B290(BgDyYoseizo* this, PlayState* play); +void func_80A0B35C(BgDyYoseizo* this, PlayState* play); +void func_80A0B500(BgDyYoseizo* this, PlayState* play); +void func_80A0B5F0(BgDyYoseizo* this, PlayState* play); +void func_80A0B75C(BgDyYoseizo* this, PlayState* play); +void func_80A0B8CC(BgDyYoseizo* this, PlayState* play); +void func_80A0BB08(BgDyYoseizo* this, PlayState* play); #if 0 const ActorInit Bg_Dy_Yoseizo_InitVars = { diff --git a/src/overlays/actors/ovl_Bg_Dy_Yoseizo/z_bg_dy_yoseizo.h b/src/overlays/actors/ovl_Bg_Dy_Yoseizo/z_bg_dy_yoseizo.h index 4a0e14d2f..5d9d84749 100644 --- a/src/overlays/actors/ovl_Bg_Dy_Yoseizo/z_bg_dy_yoseizo.h +++ b/src/overlays/actors/ovl_Bg_Dy_Yoseizo/z_bg_dy_yoseizo.h @@ -5,7 +5,7 @@ struct BgDyYoseizo; -typedef void (*BgDyYoseizoActionFunc)(struct BgDyYoseizo*, GlobalContext*); +typedef void (*BgDyYoseizoActionFunc)(struct BgDyYoseizo*, PlayState*); typedef struct BgDyYoseizo { /* 0x0000 */ Actor actor; 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 1e8c369fb..4d2a8632e 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 @@ -11,20 +11,20 @@ #define THIS ((BgF40Block*)thisx) -void BgF40Block_Init(Actor* thisx, GlobalContext* globalCtx); -void BgF40Block_Destroy(Actor* thisx, GlobalContext* globalCtx); -void BgF40Block_Update(Actor* thisx, GlobalContext* globalCtx); -void BgF40Block_Draw(Actor* thisx, GlobalContext* globalCtx); +void BgF40Block_Init(Actor* thisx, PlayState* play); +void BgF40Block_Destroy(Actor* thisx, PlayState* play); +void BgF40Block_Update(Actor* thisx, PlayState* play); +void BgF40Block_Draw(Actor* thisx, PlayState* play); -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); +void func_80BC41AC(BgF40Block* this, PlayState* play); +void func_80BC4228(BgF40Block* this, PlayState* play); +void func_80BC4344(BgF40Block* this, PlayState* play); +void func_80BC4380(BgF40Block* this, PlayState* play); +void func_80BC43CC(BgF40Block* this, PlayState* play); +void func_80BC4448(BgF40Block* this, PlayState* play); +void func_80BC44F4(BgF40Block* this, PlayState* play); +void func_80BC4530(BgF40Block* this, PlayState* play); +void func_80BC457C(BgF40Block* this, PlayState* play); const ActorInit Bg_F40_Block_InitVars = { ACTOR_BG_F40_BLOCK, @@ -50,14 +50,14 @@ static InitChainEntry sInitChain[] = { ICHAIN_VEC3F_DIV1000(scale, 100, ICHAIN_STOP), }; -s32 func_80BC3980(BgF40Block* this, GlobalContext* globalCtx) { +s32 func_80BC3980(BgF40Block* this, PlayState* play) { Vec3s* points; this->unk_160 = 0; this->unk_164 = 0; if (BGF40BLOCK_GET_PATH(&this->dyna.actor) != 0x3F) { - this->path = &globalCtx->setupPathList[BGF40BLOCK_GET_PATH(&this->dyna.actor)]; + this->path = &play->setupPathList[BGF40BLOCK_GET_PATH(&this->dyna.actor)]; if (this->path != NULL) { points = Lib_SegmentedToVirtual(this->path->points); @@ -72,14 +72,14 @@ s32 func_80BC3980(BgF40Block* this, GlobalContext* globalCtx) { return false; } -s32 func_80BC3A2C(BgF40Block* this, GlobalContext* globalCtx) { +s32 func_80BC3A2C(BgF40Block* this, PlayState* play) { Vec3s* points; this->unk_160 = this->path->count - 1; this->unk_164 = this->path->count - 1; if (BGF40BLOCK_GET_PATH(&this->dyna.actor) != 0x3F) { - this->path = &globalCtx->setupPathList[BGF40BLOCK_GET_PATH(&this->dyna.actor)]; + this->path = &play->setupPathList[BGF40BLOCK_GET_PATH(&this->dyna.actor)]; if (this->path != NULL) { points = Lib_SegmentedToVirtual(this->path->points); points += this->unk_164; @@ -170,7 +170,7 @@ s32 func_80BC3CA4(BgF40Block* this) { return false; } -s32 func_80BC3D08(BgF40Block* this, GlobalContext* globalCtx, s32 arg2) { +s32 func_80BC3D08(BgF40Block* this, PlayState* play, s32 arg2) { CollisionPoly* sp54; Vec3f sp48; Vec3f sp3C; @@ -204,7 +204,7 @@ s32 func_80BC3D08(BgF40Block* this, GlobalContext* globalCtx, s32 arg2) { 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 (BgCheck_AnyLineTest1(&play->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; @@ -224,28 +224,28 @@ void func_80BC4038(BgF40Block* this) { this->unk_168 = 6; } -void BgF40Block_Init(Actor* thisx, GlobalContext* globalCtx) { +void BgF40Block_Init(Actor* thisx, PlayState* play) { BgF40Block* this = THIS; Actor_ProcessInitChain(&this->dyna.actor, sInitChain); DynaPolyActor_Init(&this->dyna, 1); - DynaPolyActor_LoadMesh(globalCtx, &this->dyna, &object_f40_obj_Colheader_004640); + DynaPolyActor_LoadMesh(play, &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)]; + this->path = &play->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))) { + if (Flags_GetSwitch(play, BGF40BLOCK_GET_SWITCHFLAG(&this->dyna.actor))) { this->actionFunc = func_80BC4530; this->dyna.actor.speedXZ = 40.0f; - func_80BC3A2C(this, globalCtx); + func_80BC3A2C(this, play); } else { this->actionFunc = func_80BC4380; this->dyna.actor.speedXZ = 20.0f; - func_80BC3980(this, globalCtx); + func_80BC3980(this, play); } } else { this->actionFunc = func_80BC457C; @@ -253,15 +253,15 @@ void BgF40Block_Init(Actor* thisx, GlobalContext* globalCtx) { this->unk_168 = 6; } -void BgF40Block_Destroy(Actor* thisx, GlobalContext* globalCtx) { +void BgF40Block_Destroy(Actor* thisx, PlayState* play) { BgF40Block* this = THIS; - DynaPoly_DeleteBgActor(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); + DynaPoly_DeleteBgActor(play, &play->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))) { +void func_80BC41AC(BgF40Block* this, PlayState* play) { + if (func_80BC3D08(this, play, 1)) { + if (!Flags_GetSwitch(play, BGF40BLOCK_GET_SWITCHFLAG(&this->dyna.actor))) { func_80BC4038(this); this->actionFunc = func_80BC44F4; } @@ -270,7 +270,7 @@ void func_80BC41AC(BgF40Block* this, GlobalContext* globalCtx) { } } -void func_80BC4228(BgF40Block* this, GlobalContext* globalCtx) { +void func_80BC4228(BgF40Block* this, PlayState* play) { if (func_80BC3B00(this)) { this->dyna.actor.speedXZ = 20.0f; if (this->unk_160 < (this->path->count - 1)) { @@ -282,7 +282,7 @@ void func_80BC4228(BgF40Block* this, GlobalContext* globalCtx) { } } - if (func_80BC3D08(this, globalCtx, 0)) { + if (func_80BC3D08(this, play, 0)) { ActorCutscene_Stop(this->dyna.actor.cutscene); this->actionFunc = func_80BC41AC; Actor_PlaySfxAtPos(&this->dyna.actor, NA_SE_EV_IKANA_BLOCK_STOP_F); @@ -307,21 +307,21 @@ void func_80BC4228(BgF40Block* this, GlobalContext* globalCtx) { } } -void func_80BC4344(BgF40Block* this, GlobalContext* globalCtx) { +void func_80BC4344(BgF40Block* this, PlayState* play) { 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))) { +void func_80BC4380(BgF40Block* this, PlayState* play) { + if (Flags_GetSwitch(play, 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))) { +void func_80BC43CC(BgF40Block* this, PlayState* play) { + if (func_80BC3D08(this, play, 1)) { + if (Flags_GetSwitch(play, BGF40BLOCK_GET_SWITCHFLAG(&this->dyna.actor))) { func_80BC4038(this); this->actionFunc = func_80BC4344; } @@ -330,7 +330,7 @@ void func_80BC43CC(BgF40Block* this, GlobalContext* globalCtx) { } } -void func_80BC4448(BgF40Block* this, GlobalContext* globalCtx) { +void func_80BC4448(BgF40Block* this, PlayState* play) { if (func_80BC3B00(this)) { this->dyna.actor.speedXZ = 40.0f; if (this->unk_160 > 0) { @@ -342,36 +342,36 @@ void func_80BC4448(BgF40Block* this, GlobalContext* globalCtx) { } } - if (func_80BC3D08(this, globalCtx, 0)) { + if (func_80BC3D08(this, play, 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) { +void func_80BC44F4(BgF40Block* this, PlayState* play) { 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))) { +void func_80BC4530(BgF40Block* this, PlayState* play) { + if (!Flags_GetSwitch(play, BGF40BLOCK_GET_SWITCHFLAG(&this->dyna.actor))) { this->actionFunc = func_80BC44F4; } } -void func_80BC457C(BgF40Block* this, GlobalContext* globalCtx) { +void func_80BC457C(BgF40Block* this, PlayState* play) { } -void BgF40Block_Update(Actor* thisx, GlobalContext* globalCtx) { +void BgF40Block_Update(Actor* thisx, PlayState* play) { BgF40Block* this = THIS; - this->actionFunc(this, globalCtx); + this->actionFunc(this, play); 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); +void BgF40Block_Draw(Actor* thisx, PlayState* play) { + Gfx_DrawDListOpa(play, 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 cf9dfb03b..df21bf933 100644 --- a/src/overlays/actors/ovl_Bg_F40_Block/z_bg_f40_block.h +++ b/src/overlays/actors/ovl_Bg_F40_Block/z_bg_f40_block.h @@ -5,18 +5,18 @@ struct BgF40Block; -typedef void (*BgF40BlockActionFunc)(struct BgF40Block*, GlobalContext*); +typedef void (*BgF40BlockActionFunc)(struct BgF40Block*, PlayState*); #define BGF40BLOCK_GET_PATH(thisx) (((thisx)->params & 0x1FC) >> 2) #define BGF40BLOCK_GET_SWITCHFLAG(thisx) (((thisx)->params & 0xFE00) >> 9) typedef struct BgF40Block { - /* 0x0000 */ DynaPolyActor dyna; - /* 0x015C */ Path* path; - /* 0x0160 */ s32 unk_160; - /* 0x0164 */ s32 unk_164; - /* 0x0168 */ s32 unk_168; - /* 0x016C */ BgF40BlockActionFunc actionFunc; + /* 0x000 */ DynaPolyActor dyna; + /* 0x15C */ Path* path; + /* 0x160 */ s32 unk_160; + /* 0x164 */ s32 unk_164; + /* 0x168 */ s32 unk_168; + /* 0x16C */ BgF40BlockActionFunc actionFunc; } BgF40Block; // size = 0x170 extern const ActorInit Bg_F40_Block_InitVars; diff --git a/src/overlays/actors/ovl_Bg_F40_Flift/z_bg_f40_flift.c b/src/overlays/actors/ovl_Bg_F40_Flift/z_bg_f40_flift.c index 7805a6e54..3974b2fc5 100644 --- a/src/overlays/actors/ovl_Bg_F40_Flift/z_bg_f40_flift.c +++ b/src/overlays/actors/ovl_Bg_F40_Flift/z_bg_f40_flift.c @@ -5,17 +5,20 @@ */ #include "z_bg_f40_flift.h" +#include "objects/object_f40_obj/object_f40_obj.h" #define FLAGS (ACTOR_FLAG_10) #define THIS ((BgF40Flift*)thisx) -void BgF40Flift_Init(Actor* thisx, GlobalContext* globalCtx); -void BgF40Flift_Destroy(Actor* thisx, GlobalContext* globalCtx); -void BgF40Flift_Update(Actor* thisx, GlobalContext* globalCtx); -void BgF40Flift_Draw(Actor* thisx, GlobalContext* globalCtx); +void BgF40Flift_Init(Actor* thisx, PlayState* play); +void BgF40Flift_Destroy(Actor* thisx, PlayState* play); +void BgF40Flift_Update(Actor* thisx, PlayState* play); +void BgF40Flift_Draw(Actor* thisx, PlayState* play); + +void func_808D75F0(BgF40Flift* this, PlayState* play); +void func_808D7714(BgF40Flift* this, PlayState* play); -#if 0 const ActorInit Bg_F40_Flift_InitVars = { ACTOR_BG_F40_FLIFT, ACTORCAT_BG, @@ -28,28 +31,65 @@ const ActorInit Bg_F40_Flift_InitVars = { (ActorFunc)BgF40Flift_Draw, }; -// static InitChainEntry sInitChain[] = { -static InitChainEntry D_808D7830[] = { +static InitChainEntry sInitChain[] = { ICHAIN_F32(uncullZoneScale, 400, ICHAIN_CONTINUE), ICHAIN_F32(uncullZoneForward, 5000, ICHAIN_CONTINUE), ICHAIN_VEC3F_DIV1000(scale, 100, ICHAIN_STOP), }; -#endif +void BgF40Flift_Init(Actor* thisx, PlayState* play) { + BgF40Flift* this = THIS; -extern InitChainEntry D_808D7830[]; + Actor_ProcessInitChain(&this->dyna.actor, sInitChain); + DynaPolyActor_Init(&this->dyna, 1); + DynaPolyActor_LoadMesh(play, &this->dyna, &object_f40_obj_Colheader_004240); + this->dyna.actor.params = 1; + this->actionFunc = func_808D75F0; +} -extern UNK_TYPE D_06004038; -extern UNK_TYPE D_06004240; +void BgF40Flift_Destroy(Actor* thisx, PlayState* play) { + BgF40Flift* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_F40_Flift/BgF40Flift_Init.s") + DynaPoly_DeleteBgActor(play, &play->colCtx.dyna, this->dyna.bgId); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_F40_Flift/BgF40Flift_Destroy.s") +void func_808D75F0(BgF40Flift* this, PlayState* play) { + if (((this->dyna.actor.params == 1) && (DynaPolyActor_IsInRidingMovingState(&this->dyna))) || + ((this->dyna.actor.params == -1) && (!DynaPolyActor_IsInRidingMovingState(&this->dyna)))) { + this->timer = 96; + this->actionFunc = func_808D7714; + } else { + if (this->timer == 0) { + this->timer = 48; + } + this->timer--; + if (this->dyna.actor.params == 1) { + this->dyna.actor.world.pos.y = (sin_rad(this->timer * (M_PI / 24.0f)) * 5.0f) + this->dyna.actor.home.pos.y; + } else { + this->dyna.actor.world.pos.y = + (sin_rad(this->timer * (M_PI / 24.0f)) * 5.0f) + (926.8f + this->dyna.actor.home.pos.y); + } + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_F40_Flift/func_808D75F0.s") +void func_808D7714(BgF40Flift* this, PlayState* play) { + if (this->timer != 0) { + this->timer--; + this->dyna.actor.world.pos.y = + (((cos_rad(this->timer * (M_PI / 96.0f)) * this->dyna.actor.params) + 1.0f) * 463.4f) + + this->dyna.actor.home.pos.y; + } else { + this->dyna.actor.params = -this->dyna.actor.params; + this->actionFunc = func_808D75F0; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_F40_Flift/func_808D7714.s") +void BgF40Flift_Update(Actor* thisx, PlayState* play) { + BgF40Flift* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_F40_Flift/BgF40Flift_Update.s") + this->actionFunc(this, play); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_F40_Flift/BgF40Flift_Draw.s") +void BgF40Flift_Draw(Actor* thisx, PlayState* play) { + Gfx_DrawDListOpa(play, object_f40_obj_DL_004038); +} diff --git a/src/overlays/actors/ovl_Bg_F40_Flift/z_bg_f40_flift.h b/src/overlays/actors/ovl_Bg_F40_Flift/z_bg_f40_flift.h index ca0a56d91..95b2e9073 100644 --- a/src/overlays/actors/ovl_Bg_F40_Flift/z_bg_f40_flift.h +++ b/src/overlays/actors/ovl_Bg_F40_Flift/z_bg_f40_flift.h @@ -5,13 +5,12 @@ struct BgF40Flift; -typedef void (*BgF40FliftActionFunc)(struct BgF40Flift*, GlobalContext*); +typedef void (*BgF40FliftActionFunc)(struct BgF40Flift*, PlayState*); typedef struct BgF40Flift { - /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x18]; - /* 0x015C */ BgF40FliftActionFunc actionFunc; - /* 0x0160 */ char unk_160[0x4]; + /* 0x000 */ DynaPolyActor dyna; + /* 0x15C */ BgF40FliftActionFunc actionFunc; + /* 0x160 */ s32 timer; } BgF40Flift; // size = 0x164 extern const ActorInit Bg_F40_Flift_InitVars; diff --git a/src/overlays/actors/ovl_Bg_F40_Switch/z_bg_f40_switch.c b/src/overlays/actors/ovl_Bg_F40_Switch/z_bg_f40_switch.c index 5278a4b73..7838dadb7 100644 --- a/src/overlays/actors/ovl_Bg_F40_Switch/z_bg_f40_switch.c +++ b/src/overlays/actors/ovl_Bg_F40_Switch/z_bg_f40_switch.c @@ -5,23 +5,24 @@ */ #include "z_bg_f40_switch.h" +#include "z64rumble.h" #include "objects/object_f40_switch/object_f40_switch.h" #define FLAGS (ACTOR_FLAG_10) #define THIS ((BgF40Switch*)thisx) -void BgF40Switch_Init(Actor* thisx, GlobalContext* globalCtx); -void BgF40Switch_Destroy(Actor* thisx, GlobalContext* globalCtx); -void BgF40Switch_Update(Actor* thisx, GlobalContext* globalCtx); -void BgF40Switch_Draw(Actor* thisx, GlobalContext* globalCtx); +void BgF40Switch_Init(Actor* thisx, PlayState* play); +void BgF40Switch_Destroy(Actor* thisx, PlayState* play); +void BgF40Switch_Update(Actor* thisx, PlayState* play); +void BgF40Switch_Draw(Actor* thisx, PlayState* play); -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); +void BgF40Switch_CheckAll(BgF40Switch* this, PlayState* play); +void BgF40Switch_Unpress(BgF40Switch* this, PlayState* play); +void BgF40Switch_IdlePressed(BgF40Switch* this, PlayState* play); +void BgF40Switch_Press(BgF40Switch* this, PlayState* play); +void BgF40Switch_WaitToPress(BgF40Switch* this, PlayState* play); +void BgF40Switch_IdleUnpressed(BgF40Switch* this, PlayState* play); const ActorInit Bg_F40_Switch_InitVars = { ACTOR_BG_F40_SWITCH, @@ -41,17 +42,17 @@ 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) { +void BgF40Switch_CheckAll(BgF40Switch* this, PlayState* play) { + if (play->gameplayFrames != sBgF40SwitchLastUpdateFrame) { u32 pressedSwitchFlags[4] = { 0 }; u32 pad; s32 switchFlag; s32 isPressed; Actor* actor; BgF40Switch* actorAsSwitch; - u32 inCsMode = Player_InCsMode(&globalCtx->state); + u32 inCsMode = Player_InCsMode(play); - for (actor = globalCtx->actorCtx.actorLists[ACTORCAT_SWITCH].first; actor != NULL; actor = actor->next) { + for (actor = play->actorCtx.actorLists[ACTORCAT_SWITCH].first; actor != NULL; actor = actor->next) { if (actor->id == ACTOR_BG_F40_SWITCH && actor->room == this->dyna.actor.room && actor->update != NULL) { actorAsSwitch = (BgF40Switch*)actor; actorAsSwitch->wasPressed = actorAsSwitch->isPressed; @@ -77,23 +78,23 @@ void BgF40Switch_CheckAll(BgF40Switch* this, GlobalContext* globalCtx) { if (switchFlag >= 0 && switchFlag < 0x80) { pressedSwitchFlags[(switchFlag & ~0x1F) >> 5] |= 1 << (switchFlag & 0x1F); if (!actorAsSwitch->wasPressed && actorAsSwitch->actionFunc == BgF40Switch_IdleUnpressed && - !Flags_GetSwitch(globalCtx, switchFlag)) { + !Flags_GetSwitch(play, switchFlag)) { actorAsSwitch->isInitiator = true; } } } } } - for (actor = globalCtx->actorCtx.actorLists[ACTORCAT_SWITCH].first; actor != NULL; actor = actor->next) { + for (actor = play->actorCtx.actorLists[ACTORCAT_SWITCH].first; actor != NULL; actor = actor->next) { if (actor->id == ACTOR_BG_F40_SWITCH && actor->room == this->dyna.actor.room && actor->update != 0) { switchFlag = BGF40SWITCH_GET_SWITCHFLAG(actor); - if (switchFlag >= 0 && switchFlag < 0x80 && Flags_GetSwitch(globalCtx, switchFlag) && + if (switchFlag >= 0 && switchFlag < 0x80 && Flags_GetSwitch(play, switchFlag) && !(pressedSwitchFlags[(switchFlag & ~0x1F) >> 5] & (1 << (switchFlag & 0x1F)))) { - Flags_UnsetSwitch(globalCtx, switchFlag); + Flags_UnsetSwitch(play, switchFlag); } } } - sBgF40SwitchLastUpdateFrame = globalCtx->gameplayFrames; + sBgF40SwitchLastUpdateFrame = play->gameplayFrames; } } @@ -104,7 +105,7 @@ static InitChainEntry sInitChain[] = { ICHAIN_VEC3F_DIV1000(scale, 123, ICHAIN_STOP), }; -void BgF40Switch_Init(Actor* thisx, GlobalContext* globalCtx) { +void BgF40Switch_Init(Actor* thisx, PlayState* play) { BgF40Switch* this = THIS; Actor_ProcessInitChain(&this->dyna.actor, sInitChain); @@ -112,20 +113,20 @@ void BgF40Switch_Init(Actor* thisx, GlobalContext* globalCtx) { 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); + DynaPolyActor_LoadMesh(play, &this->dyna, &object_f40_switch_Colheader_000118); if (!sBgF40SwitchGlobalsInitialized) { - sBgF40SwitchLastUpdateFrame = globalCtx->gameplayFrames; + sBgF40SwitchLastUpdateFrame = play->gameplayFrames; sBgF40SwitchGlobalsInitialized = true; } } -void BgF40Switch_Destroy(Actor* thisx, GlobalContext* globalCtx) { +void BgF40Switch_Destroy(Actor* thisx, PlayState* play) { BgF40Switch* this = THIS; - DynaPoly_DeleteBgActor(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); + DynaPoly_DeleteBgActor(play, &play->colCtx.dyna, this->dyna.bgId); } -void BgF40Switch_Unpress(BgF40Switch* this, GlobalContext* globalCtx) { +void BgF40Switch_Unpress(BgF40Switch* this, PlayState* play) { this->dyna.actor.scale.y += 0.0495f; if (this->dyna.actor.scale.y >= 0.165f) { Actor_PlaySfxAtPos(&this->dyna.actor, NA_SE_EV_IKANA_BLOCK_SWITCH); @@ -134,17 +135,17 @@ void BgF40Switch_Unpress(BgF40Switch* this, GlobalContext* globalCtx) { } } -void BgF40Switch_IdlePressed(BgF40Switch* this, GlobalContext* globalCtx) { +void BgF40Switch_IdlePressed(BgF40Switch* this, PlayState* play) { if (!this->isPressed) { this->actionFunc = BgF40Switch_Unpress; } } -void BgF40Switch_Press(BgF40Switch* this, GlobalContext* globalCtx) { +void BgF40Switch_Press(BgF40Switch* this, PlayState* play) { this->dyna.actor.scale.y -= 0.0495f; if (this->dyna.actor.scale.y <= 0.0165f) { Actor_PlaySfxAtPos(&this->dyna.actor, NA_SE_EV_IKANA_BLOCK_SWITCH); - func_8013ECE0(this->dyna.actor.xyzDistToPlayerSq, 120, 20, 10); + Rumble_Request(this->dyna.actor.xyzDistToPlayerSq, 120, 20, 10); if (this->isInitiator) { ActorCutscene_Stop(this->dyna.actor.cutscene); this->isInitiator = false; @@ -155,39 +156,39 @@ void BgF40Switch_Press(BgF40Switch* this, GlobalContext* globalCtx) { } } -void BgF40Switch_WaitToPress(BgF40Switch* this, GlobalContext* globalCtx) { +void BgF40Switch_WaitToPress(BgF40Switch* this, PlayState* play) { if (!this->isInitiator || this->dyna.actor.cutscene == -1) { this->actionFunc = BgF40Switch_Press; if (this->isInitiator) { - Flags_SetSwitch(globalCtx, BGF40SWITCH_GET_SWITCHFLAG(&this->dyna.actor)); + Flags_SetSwitch(play, BGF40SWITCH_GET_SWITCHFLAG(&this->dyna.actor)); } } else if (ActorCutscene_GetCanPlayNext(this->dyna.actor.cutscene)) { ActorCutscene_StartAndSetUnkLinkFields(this->dyna.actor.cutscene, &this->dyna.actor); this->actionFunc = BgF40Switch_Press; if (this->isInitiator) { - Flags_SetSwitch(globalCtx, BGF40SWITCH_GET_SWITCHFLAG(&this->dyna.actor)); + Flags_SetSwitch(play, BGF40SWITCH_GET_SWITCHFLAG(&this->dyna.actor)); } } else { ActorCutscene_SetIntentToPlay(this->dyna.actor.cutscene); } } -void BgF40Switch_IdleUnpressed(BgF40Switch* this, GlobalContext* globalCtx) { +void BgF40Switch_IdleUnpressed(BgF40Switch* this, PlayState* play) { if (this->isPressed) { this->actionFunc = BgF40Switch_WaitToPress; } } -void BgF40Switch_Update(Actor* thisx, GlobalContext* globalCtx) { +void BgF40Switch_Update(Actor* thisx, PlayState* play) { BgF40Switch* this = THIS; - BgF40Switch_CheckAll(this, globalCtx); - this->actionFunc(this, globalCtx); + BgF40Switch_CheckAll(this, play); + this->actionFunc(this, play); } -void BgF40Switch_Draw(Actor* thisx, GlobalContext* globalCtx) { +void BgF40Switch_Draw(Actor* thisx, PlayState* play) { BgF40Switch* this = THIS; - Gfx_DrawDListOpa(globalCtx, object_f40_switch_DL_000438); - Gfx_DrawDListOpa(globalCtx, object_f40_switch_DL_000390); + Gfx_DrawDListOpa(play, object_f40_switch_DL_000438); + Gfx_DrawDListOpa(play, 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 8d4e64603..b0fe89341 100644 --- a/src/overlays/actors/ovl_Bg_F40_Switch/z_bg_f40_switch.h +++ b/src/overlays/actors/ovl_Bg_F40_Switch/z_bg_f40_switch.h @@ -7,17 +7,17 @@ struct BgF40Switch; #define BGF40SWITCH_GET_SWITCHFLAG(thisx) (((thisx)->params & 0xFE00) >> 9) -typedef void (*BgF40SwitchActionFunc)(struct BgF40Switch*, GlobalContext*); +typedef void (*BgF40SwitchActionFunc)(struct BgF40Switch*, PlayState*); typedef struct BgF40Switch { - /* 0x0000 */ DynaPolyActor dyna; - /* 0x015C */ s16 switchReleaseDelay; // frames until a pressed switch becomes released if nothing is still pressing it - /* 0x015E */ s8 isPressed; // Logical state of the switch (pressed or unpressed). Animation state may lag behind this slightly. - /* 0x015F */ s8 wasPressed; // used as temporary during update function + /* 0x000 */ DynaPolyActor dyna; + /* 0x15C */ s16 switchReleaseDelay; // frames until a pressed switch becomes released if nothing is still pressing it + /* 0x15E */ s8 isPressed; // Logical state of the switch (pressed or unpressed). Animation state may lag behind this slightly. + /* 0x15F */ s8 wasPressed; // used as temporary during update function // true if this switch is the one that initiated a state change; false if this switch is changing as a result of another switch tied to the same flag. // this is a temporary flag related to something currently happening, not a permanent property of the switch. - /* 0x0160 */ s8 isInitiator; - /* 0x0164 */ BgF40SwitchActionFunc actionFunc; + /* 0x160 */ s8 isInitiator; + /* 0x164 */ BgF40SwitchActionFunc actionFunc; } BgF40Switch; // size = 0x168 extern const ActorInit Bg_F40_Switch_InitVars; diff --git a/src/overlays/actors/ovl_Bg_F40_Swlift/z_bg_f40_swlift.c b/src/overlays/actors/ovl_Bg_F40_Swlift/z_bg_f40_swlift.c index 9d84f191c..16b39cdd3 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 @@ -10,10 +10,10 @@ #define THIS ((BgF40Swlift*)thisx) -void BgF40Swlift_Init(Actor* thisx, GlobalContext* globalCtx); -void BgF40Swlift_Destroy(Actor* thisx, GlobalContext* globalCtx); -void BgF40Swlift_Update(Actor* thisx, GlobalContext* globalCtx); -void BgF40Swlift_Draw(Actor* thisx, GlobalContext* globalCtx); +void BgF40Swlift_Init(Actor* thisx, PlayState* play); +void BgF40Swlift_Destroy(Actor* thisx, PlayState* play); +void BgF40Swlift_Update(Actor* thisx, PlayState* play); +void BgF40Swlift_Draw(Actor* thisx, PlayState* play); #if 0 const ActorInit Bg_F40_Swlift_InitVars = { diff --git a/src/overlays/actors/ovl_Bg_Fire_Wall/z_bg_fire_wall.c b/src/overlays/actors/ovl_Bg_Fire_Wall/z_bg_fire_wall.c index 1f959e827..1ad295e68 100644 --- a/src/overlays/actors/ovl_Bg_Fire_Wall/z_bg_fire_wall.c +++ b/src/overlays/actors/ovl_Bg_Fire_Wall/z_bg_fire_wall.c @@ -5,21 +5,22 @@ */ #include "z_bg_fire_wall.h" +#include "objects/object_fwall/object_fwall.h" +#include "overlays/actors/ovl_En_Encount4/z_en_encount4.h" #define FLAGS 0x00000000 #define THIS ((BgFireWall*)thisx) -void BgFireWall_Init(Actor* thisx, GlobalContext* globalCtx); -void BgFireWall_Destroy(Actor* thisx, GlobalContext* globalCtx); -void BgFireWall_Update(Actor* thisx, GlobalContext* globalCtx); +void BgFireWall_Init(Actor* thisx, PlayState* play); +void BgFireWall_Destroy(Actor* thisx, PlayState* play); +void BgFireWall_Update(Actor* thisx, PlayState* play2); +void BgFireWall_Draw(Actor* thisx, PlayState* play); -void func_809AC638(BgFireWall* this, GlobalContext* globalCtx); -void func_809AC68C(BgFireWall* this, GlobalContext* globalCtx); -void func_809AC6C0(BgFireWall* this, GlobalContext* globalCtx); -void func_809AC970(BgFireWall* this, GlobalContext* globalCtx); +void func_809AC638(BgFireWall* this, PlayState* play); +void func_809AC68C(BgFireWall* this, PlayState* play); +void func_809AC6C0(BgFireWall* this, PlayState* play); -#if 0 const ActorInit Bg_Fire_Wall_InitVars = { ACTOR_BG_FIRE_WALL, ACTORCAT_BG, @@ -32,41 +33,184 @@ const ActorInit Bg_Fire_Wall_InitVars = { (ActorFunc)NULL, }; -// static ColliderCylinderInit sCylinderInit = { -static ColliderCylinderInit D_809ACC60 = { - { COLTYPE_NONE, AT_ON | AT_TYPE_ENEMY, AC_NONE, OC1_ON | OC1_TYPE_PLAYER, OC2_TYPE_2, COLSHAPE_CYLINDER, }, - { ELEMTYPE_UNK0, { 0x20000000, 0x01, 0x04 }, { 0xF7CFFFFF, 0x00, 0x00 }, TOUCH_ON | TOUCH_SFX_NONE, BUMP_NONE, OCELEM_ON, }, +static ColliderCylinderInit sCylinderInit = { + { + COLTYPE_NONE, + AT_ON | AT_TYPE_ENEMY, + AC_NONE, + OC1_ON | OC1_TYPE_PLAYER, + OC2_TYPE_2, + COLSHAPE_CYLINDER, + }, + { + ELEMTYPE_UNK0, + { 0x20000000, 0x01, 0x04 }, + { 0xF7CFFFFF, 0x00, 0x00 }, + TOUCH_ON | TOUCH_SFX_NONE, + BUMP_NONE, + OCELEM_ON, + }, { 34, 85, 0, { 0, 0, 0 } }, }; -// sColChkInfoInit -static CollisionCheckInfoInit D_809ACC8C = { 1, 80, 100, MASS_IMMOVABLE }; +static CollisionCheckInfoInit sColChkInfoInit = { 1, 80, 100, MASS_IMMOVABLE }; -#endif +static TexturePtr sFlameTextures[] = { + gFwallFireball0Tex, gFwallFireball1Tex, gFwallFireball2Tex, gFwallFireball3Tex, + gFwallFireball4Tex, gFwallFireball5Tex, gFwallFireball6Tex, gFwallFireball7Tex, +}; -extern ColliderCylinderInit D_809ACC60; -extern CollisionCheckInfoInit D_809ACC8C; +void BgFireWall_Init(Actor* thisx, PlayState* play) { + BgFireWall* this = THIS; -extern UNK_TYPE D_06000040; + this->unk_14C = this->actor.params; + this->actor.scale.y = 0.005f; + Collider_InitCylinder(play, &this->collider); + Collider_SetCylinder(play, &this->collider, &this->actor, &sCylinderInit); + CollisionCheck_SetInfo(&this->actor.colChkInfo, NULL, &sColChkInfoInit); + this->actor.scale.z = 0.12f; + this->actor.scale.x = 0.12f; + this->unk_15C = 0.09f; + this->unk_158 = 0.1f; + this->unk_160 = 300.0f; + this->texIndex = Rand_S16Offset(0, ARRAY_COUNT(sFlameTextures) - 1); + this->actor.flags |= ACTOR_FLAG_10; + this->collider.dim.pos.y = this->actor.world.pos.y; + this->actionFunc = func_809AC638; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Fire_Wall/BgFireWall_Init.s") +void BgFireWall_Destroy(Actor* thisx, PlayState* play) { + BgFireWall* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Fire_Wall/BgFireWall_Destroy.s") + Collider_DestroyCylinder(play, &this->collider); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Fire_Wall/func_809AC5C0.s") +s32 func_809AC5C0(BgFireWall* thisx, PlayState* play) { + BgFireWall* this = THIS; + Player* player = GET_PLAYER(play); + Vec3f sp1C; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Fire_Wall/func_809AC638.s") + Actor_OffsetOfPointInActorCoords(&this->actor, &sp1C, &player->actor.world.pos); + if ((fabsf(sp1C.x) < this->unk_160) && (fabsf(sp1C.z) < (this->unk_160 + 20.0f))) { + return true; + } + return false; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Fire_Wall/func_809AC68C.s") +void func_809AC638(BgFireWall* this, PlayState* play) { + if ((this->unk_14C != 0) || (func_809AC5C0(this, play))) { + this->actor.draw = BgFireWall_Draw; + this->timer = 5; + this->actionFunc = func_809AC68C; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Fire_Wall/func_809AC6C0.s") +void func_809AC68C(BgFireWall* this, PlayState* play) { + if (this->timer != 0) { + this->timer--; + } + if (this->timer == 0) { + this->actionFunc = func_809AC6C0; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Fire_Wall/func_809AC760.s") +void func_809AC6C0(BgFireWall* this, PlayState* play) { + if ((this->unk_14C != 0) || (func_809AC5C0(this, play))) { + this->unk_15C = 0.09f; + Math_StepToF(&this->actor.scale.y, this->unk_15C + this->unk_154, this->unk_158); + } else if (Math_StepToF(&this->actor.scale.y, 0.005f, this->unk_158)) { + this->actionFunc = func_809AC638; + } else { + this->timer = 0; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Fire_Wall/func_809AC7F8.s") +void func_809AC760(BgFireWall* this, PlayState* play) { + s16 phi_a3; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Fire_Wall/func_809AC970.s") + if (Actor_IsFacingPlayer(&this->actor, 0x4000)) { + phi_a3 = this->actor.shape.rot.y; + } else { + phi_a3 = (this->actor.shape.rot.y + 0x8000); + } + func_800B8D98(play, &this->actor, BREG(48) + 10.0f, phi_a3, BREG(49) + 5.0f); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Fire_Wall/BgFireWall_Update.s") +void func_809AC7F8(BgFireWall* this, PlayState* play) { + Player* player = GET_PLAYER(play); + Vec3f sp38; + f32 val = 25.0f; + f32 sin; + f32 cos; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Fire_Wall/func_809ACB28.s") + Actor_OffsetOfPointInActorCoords(&this->actor, &sp38, &player->actor.world.pos); + sp38.x = CLAMP(sp38.x, -80.0f, 80.0f); + + if (this->step == 0) { + if (sp38.z > 0.0f) { + sp38.z = -val; + this->step = -1.0f; + } else { + sp38.z = val; + this->step = 1.0f; + } + } else { + sp38.z = this->step * 25.0f; + } + + sin = Math_SinS(this->actor.shape.rot.y); + cos = Math_CosS(this->actor.shape.rot.y); + this->collider.dim.pos.x = this->actor.world.pos.x + (sp38.x * cos) + (sp38.z * sin); + this->collider.dim.pos.z = this->actor.world.pos.z - (sp38.x * sin) + (sp38.z * cos); +} + +void func_809AC970(BgFireWall* this, PlayState* play) { + if (Math_StepToF(&this->actor.scale.y, 0.005f, this->unk_158)) { + Actor_MarkForDeath(&this->actor); + } +} + +void BgFireWall_Update(Actor* thisx, PlayState* play2) { + PlayState* play = play2; + BgFireWall* this = THIS; + + this->actionFunc(this, play); + if ((this->unk_14C == 0) || ((this->unk_14C != 0) && (this->actor.xzDistToPlayer < 240.0f))) { + if (this->collider.base.atFlags & AT_HIT) { + this->collider.base.atFlags &= ~AT_HIT; + func_809AC760(this, play); + } + } + if (this->actionFunc == func_809AC6C0) { + func_800B9010(&this->actor, NA_SE_EV_FIRE_PLATE - SFX_FLAG); + if ((this->unk_14C == 0) || ((this->unk_14C != 0) && (this->actor.xzDistToPlayer < 240.0f))) { + func_809AC7F8(this, play); + CollisionCheck_SetAT(play, &play->colChkCtx, &this->collider.base); + CollisionCheck_SetOC(play, &play->colChkCtx, &this->collider.base); + } + } + this->texIndex = (this->texIndex + 1) % ARRAY_COUNT(sFlameTextures); + if (this->actionFunc != func_809AC970) { + if (this->actor.parent != NULL) { + EnEncount4* parent = (EnEncount4*)this->actor.parent; + if ((parent->actor.update != NULL) && (parent->unk_150 != 0)) { + this->actionFunc = func_809AC970; + } + } + } +} + +void BgFireWall_Draw(Actor* thisx, PlayState* play) { + BgFireWall* this = THIS; + + OPEN_DISPS(play->state.gfxCtx); + + POLY_XLU_DISP = Gfx_CallSetupDL(POLY_XLU_DISP, 20); + gSPSegment(POLY_XLU_DISP++, 0x08, Lib_SegmentedToVirtual(sFlameTextures[this->texIndex])); + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0x01, 255, 255, 0, 150); + gDPSetEnvColor(POLY_XLU_DISP++, 255, 0, 0, 255); + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_XLU_DISP++, object_fwall_DL_000040); + + CLOSE_DISPS(play->state.gfxCtx); +} diff --git a/src/overlays/actors/ovl_Bg_Fire_Wall/z_bg_fire_wall.h b/src/overlays/actors/ovl_Bg_Fire_Wall/z_bg_fire_wall.h index b4d176d9e..018e9f5f1 100644 --- a/src/overlays/actors/ovl_Bg_Fire_Wall/z_bg_fire_wall.h +++ b/src/overlays/actors/ovl_Bg_Fire_Wall/z_bg_fire_wall.h @@ -5,12 +5,20 @@ struct BgFireWall; -typedef void (*BgFireWallActionFunc)(struct BgFireWall*, GlobalContext*); +typedef void (*BgFireWallActionFunc)(struct BgFireWall*, PlayState*); typedef struct BgFireWall { - /* 0x0000 */ Actor actor; - /* 0x0144 */ BgFireWallActionFunc actionFunc; - /* 0x0148 */ char unk_148[0x68]; + /* 0x000 */ Actor actor; + /* 0x144 */ BgFireWallActionFunc actionFunc; + /* 0x148 */ s16 texIndex; + /* 0x14A */ s16 timer; + /* 0x14C */ s16 unk_14C; + /* 0x150 */ f32 step; + /* 0x154 */ f32 unk_154; + /* 0x158 */ f32 unk_158; + /* 0x15C */ f32 unk_15C; + /* 0x160 */ f32 unk_160; + /* 0x164 */ ColliderCylinder collider; } BgFireWall; // size = 0x1B0 extern const ActorInit Bg_Fire_Wall_InitVars; diff --git a/src/overlays/actors/ovl_Bg_Fu_Kaiten/z_bg_fu_kaiten.c b/src/overlays/actors/ovl_Bg_Fu_Kaiten/z_bg_fu_kaiten.c index 307d0fd0a..a98025524 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 @@ -11,10 +11,10 @@ #define THIS ((BgFuKaiten*)thisx) -void BgFuKaiten_Init(Actor* thisx, GlobalContext* globalCtx); -void BgFuKaiten_Destroy(Actor* thisx, GlobalContext* globalCtx); -void BgFuKaiten_Update(Actor* thisx, GlobalContext* globalCtx); -void BgFuKaiten_Draw(Actor* thisx, GlobalContext* globalCtx); +void BgFuKaiten_Init(Actor* thisx, PlayState* play); +void BgFuKaiten_Destroy(Actor* thisx, PlayState* play); +void BgFuKaiten_Update(Actor* thisx, PlayState* play); +void BgFuKaiten_Draw(Actor* thisx, PlayState* play); const ActorInit Bg_Fu_Kaiten_InitVars = { ACTOR_BG_FU_KAITEN, @@ -28,7 +28,7 @@ const ActorInit Bg_Fu_Kaiten_InitVars = { (ActorFunc)BgFuKaiten_Draw, }; -void BgFuKaiten_Init(Actor* thisx, GlobalContext* globalCtx) { +void BgFuKaiten_Init(Actor* thisx, PlayState* play) { s32 pad; BgFuKaiten* this = THIS; CollisionHeader* header = NULL; @@ -36,7 +36,7 @@ void BgFuKaiten_Init(Actor* thisx, GlobalContext* globalCtx) { Actor_SetScale(thisx, 1.0); DynaPolyActor_Init(&this->dyna, 3); CollisionHeader_GetVirtual(&object_fu_kaiten_Colheader_002D30, &header); - this->dyna.bgId = DynaPoly_SetBgActor(globalCtx, &globalCtx->colCtx.dyna, &this->dyna.actor, header); + this->dyna.bgId = DynaPoly_SetBgActor(play, &play->colCtx.dyna, &this->dyna.actor, header); this->bounceHeight = 0.0; this->rotationSpeed = 0; @@ -44,10 +44,10 @@ void BgFuKaiten_Init(Actor* thisx, GlobalContext* globalCtx) { this->bounce = 0; } -void BgFuKaiten_Destroy(Actor* thisx, GlobalContext* globalCtx) { +void BgFuKaiten_Destroy(Actor* thisx, PlayState* play) { BgFuKaiten* this = THIS; - DynaPoly_DeleteBgActor(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); + DynaPoly_DeleteBgActor(play, &play->colCtx.dyna, this->dyna.bgId); } void BgFuKaiten_UpdateRotation(BgFuKaiten* this) { @@ -67,19 +67,19 @@ void BgFuKaiten_UpdateHeight(BgFuKaiten* this) { this->dyna.actor.world.pos.y -= this->bounceHeight * Math_CosS(this->bounce); } -void BgFuKaiten_Update(Actor* thisx, GlobalContext* globalCtx) { +void BgFuKaiten_Update(Actor* thisx, PlayState* play) { BgFuKaiten* this = THIS; BgFuKaiten_UpdateRotation(this); BgFuKaiten_UpdateHeight(this); } -void BgFuKaiten_Draw(Actor* thisx, GlobalContext* globalCtx) { - OPEN_DISPS(globalCtx->state.gfxCtx); +void BgFuKaiten_Draw(Actor* thisx, PlayState* play) { + OPEN_DISPS(play->state.gfxCtx); - func_8012C28C(globalCtx->state.gfxCtx); + func_8012C28C(play->state.gfxCtx); - gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_OPA_DISP++, object_fu_kaiten_DL_0005D0); - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->state.gfxCtx); } 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 a8d54222d..c485927ce 100644 --- a/src/overlays/actors/ovl_Bg_Fu_Mizu/z_bg_fu_mizu.c +++ b/src/overlays/actors/ovl_Bg_Fu_Mizu/z_bg_fu_mizu.c @@ -5,17 +5,17 @@ */ #include "z_bg_fu_mizu.h" +#include "objects/object_fu_kaiten/object_fu_kaiten.h" #define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_20) #define THIS ((BgFuMizu*)thisx) -void BgFuMizu_Init(Actor* thisx, GlobalContext* globalCtx); -void BgFuMizu_Destroy(Actor* thisx, GlobalContext* globalCtx); -void BgFuMizu_Update(Actor* thisx, GlobalContext* globalCtx); -void BgFuMizu_Draw(Actor* thisx, GlobalContext* globalCtx); +void BgFuMizu_Init(Actor* thisx, PlayState* play); +void BgFuMizu_Destroy(Actor* thisx, PlayState* play); +void BgFuMizu_Update(Actor* thisx, PlayState* play); +void BgFuMizu_Draw(Actor* thisx, PlayState* play); -#if 0 const ActorInit Bg_Fu_Mizu_InitVars = { ACTOR_BG_FU_MIZU, ACTORCAT_BG, @@ -28,17 +28,68 @@ const ActorInit Bg_Fu_Mizu_InitVars = { (ActorFunc)BgFuMizu_Draw, }; -#endif +void BgFuMizu_Init(Actor* thisx, PlayState* play) { + BgFuMizu* this = THIS; + s32 pad; + CollisionHeader* colHeader = NULL; -extern UNK_TYPE D_060037D8; -extern UNK_TYPE D_060037F8; + Actor_SetScale(&this->dyna.actor, 1.0f); + DynaPolyActor_Init(&this->dyna, 1); + CollisionHeader_GetVirtual(&object_fu_kaiten_Colheader_0037F8, &colHeader); + this->dyna.bgId = DynaPoly_SetBgActor(play, &play->colCtx.dyna, &this->dyna.actor, colHeader); + this->unk_160 = 0; + this->dyna.actor.world.pos.y = -10.0f + this->dyna.actor.home.pos.y; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Fu_Mizu/BgFuMizu_Init.s") +void BgFuMizu_Destroy(Actor* thisx, PlayState* play) { + BgFuMizu* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Fu_Mizu/BgFuMizu_Destroy.s") + DynaPoly_DeleteBgActor(play, &play->colCtx.dyna, this->dyna.bgId); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Fu_Mizu/func_80ADABA4.s") +s32 func_80ADABA4(BgFuMizu* this, PlayState* play) { + Actor* actor = play->actorCtx.actorLists[ACTORCAT_BG].first; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Fu_Mizu/BgFuMizu_Update.s") + while (actor != NULL) { + if ((actor != NULL) && (actor->id == ACTOR_EN_FU_KAGO) && (actor->colChkInfo.health == 0)) { + return false; + } + actor = actor->next; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Fu_Mizu/BgFuMizu_Draw.s") + return true; +} + +void BgFuMizu_Update(Actor* thisx, PlayState* play) { + f32 heightTarget; + BgFuMizu* this = THIS; + + if (this->unk_160 == 0) { + if (func_80ADABA4(this, play)) { + heightTarget = -10.0f + this->dyna.actor.home.pos.y; + } else { + heightTarget = 10.0f + this->dyna.actor.home.pos.y; + } + } else { + heightTarget = 25.0f + this->dyna.actor.home.pos.y; + } + if (Math_SmoothStepToF(&this->dyna.actor.world.pos.y, heightTarget, 0.05f, 1.0f, 0.5f) > 1.0f) { + if (this->unk_160 == 1) { + func_800B9010(&this->dyna.actor, NA_SE_EV_WATER_LEVEL_DOWN_FIX - SFX_FLAG); + } else { + func_800B9010(&this->dyna.actor, NA_SE_EV_WATER_LEVEL_DOWN_FIX - SFX_FLAG); + } + } +} + +void BgFuMizu_Draw(Actor* thisx, PlayState* play) { + AnimatedMat_Draw(play, Lib_SegmentedToVirtual(object_fu_kaiten_Matanimheader_0037D8)); + + OPEN_DISPS(play->state.gfxCtx); + + func_8012C28C(play->state.gfxCtx); + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_XLU_DISP++, object_fu_kaiten_DL_002FC0); + + CLOSE_DISPS(play->state.gfxCtx); +} diff --git a/src/overlays/actors/ovl_Bg_Fu_Mizu/z_bg_fu_mizu.h b/src/overlays/actors/ovl_Bg_Fu_Mizu/z_bg_fu_mizu.h index ffb4cc8d8..89b1df323 100644 --- a/src/overlays/actors/ovl_Bg_Fu_Mizu/z_bg_fu_mizu.h +++ b/src/overlays/actors/ovl_Bg_Fu_Mizu/z_bg_fu_mizu.h @@ -6,8 +6,8 @@ struct BgFuMizu; typedef struct BgFuMizu { - /* 0x000 */ Actor actor; - /* 0x144 */ char unk_144[0x1C]; + /* 0x000 */ DynaPolyActor dyna; + /* 0x15C */ UNK_TYPE1 pad15C[0x4]; /* 0x160 */ s16 unk_160; } BgFuMizu; // size = 0x164 diff --git a/src/overlays/actors/ovl_Bg_Goron_Oyu/z_bg_goron_oyu.c b/src/overlays/actors/ovl_Bg_Goron_Oyu/z_bg_goron_oyu.c index d064a3cb4..fbae48df2 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 @@ -11,17 +11,17 @@ #define THIS ((BgGoronOyu*)thisx) -void BgGoronOyu_Init(Actor* thisx, GlobalContext* globalCtx); -void BgGoronOyu_Destroy(Actor* thisx, GlobalContext* globalCtx); -void BgGoronOyu_Update(Actor* thisx, GlobalContext* globalCtx); -void BgGoronOyu_Draw(Actor* thisx, GlobalContext* globalCtx); +void BgGoronOyu_Init(Actor* thisx, PlayState* play); +void BgGoronOyu_Destroy(Actor* thisx, PlayState* play); +void BgGoronOyu_Update(Actor* thisx, PlayState* play); +void BgGoronOyu_Draw(Actor* thisx, PlayState* play); -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 func_80B40160(BgGoronOyu* this, GlobalContext* globalCtx); +void func_80B40100(BgGoronOyu* this, PlayState* play); +void func_80B400C8(BgGoronOyu* this, PlayState* play); +void func_80B401F8(BgGoronOyu* this, PlayState* play); +void BgGoronOyu_UpdateWaterBoxInfo(BgGoronOyu* this, PlayState* play); +void BgGoronOyu_SpawnEffects(BgGoronOyu* this, PlayState* play); +void func_80B40160(BgGoronOyu* this, PlayState* play); const ActorInit Bg_Goron_Oyu_InitVars = { ACTOR_BG_GORON_OYU, @@ -47,12 +47,12 @@ void func_80B4009C(BgGoronOyu* this) { this->unk_164 = 20.0f; } -void func_80B400C8(BgGoronOyu* this, GlobalContext* globalCtx) { - BgGoronOyu_UpdateWaterBoxInfo(this, globalCtx); - func_80B401F8(this, globalCtx); +void func_80B400C8(BgGoronOyu* this, PlayState* play) { + BgGoronOyu_UpdateWaterBoxInfo(this, play); + func_80B401F8(this, play); } -void func_80B40100(BgGoronOyu* this, GlobalContext* globalCtx) { +void func_80B40100(BgGoronOyu* this, PlayState* play) { if (ActorCutscene_GetCanPlayNext(this->initialActorCutscene)) { ActorCutscene_StartAndSetUnkLinkFields(this->initialActorCutscene, &this->dyna.actor); this->actionFunc = func_80B40160; @@ -61,12 +61,12 @@ void func_80B40100(BgGoronOyu* this, GlobalContext* globalCtx) { } } -void func_80B40160(BgGoronOyu* this, GlobalContext* globalCtx) { +void func_80B40160(BgGoronOyu* this, PlayState* play) { static Vec3f D_80B40780 = { 0, 0, 0 }; Math_StepToF(&this->unk_164, 0.0f, 0.2f); this->dyna.actor.world.pos.y = this->dyna.actor.home.pos.y - this->unk_164; - BgGoronOyu_UpdateWaterBoxInfo(this, globalCtx); + BgGoronOyu_UpdateWaterBoxInfo(this, play); if (this->unk_164 <= 0.0f) { ActorCutscene_Stop(this->initialActorCutscene); @@ -77,45 +77,45 @@ void func_80B40160(BgGoronOyu* this, GlobalContext* globalCtx) { Audio_PlaySfxAtPos(&D_80B40780, NA_SE_EV_WATER_LEVEL_DOWN - SFX_FLAG); } -void func_80B401F8(BgGoronOyu* this, GlobalContext* globalCtx) { +void func_80B401F8(BgGoronOyu* this, PlayState* play) { Player* player; Vec3f dist; - if (Actor_HasParent(&this->dyna.actor, globalCtx)) { + if (Actor_HasParent(&this->dyna.actor, play)) { this->dyna.actor.parent = NULL; return; } - player = GET_PLAYER(globalCtx); + player = GET_PLAYER(play); Math_Vec3f_DistXYZAndStoreDiff(&this->waterBoxPos, &player->actor.world.pos, &dist); 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, GI_MAX, this->dyna.actor.xzDistToPlayer, + Actor_PickUp(&this->dyna.actor, play, GI_MAX, this->dyna.actor.xzDistToPlayer, fabsf(this->dyna.actor.playerHeightRel)); } } -void BgGoronOyu_UpdateWaterBoxInfo(BgGoronOyu* this, GlobalContext* globalCtx) { +void BgGoronOyu_UpdateWaterBoxInfo(BgGoronOyu* this, PlayState* play) { WaterBox* waterBox; f32 ySurface; - if (WaterBox_GetSurface1(globalCtx, &globalCtx->colCtx, this->dyna.actor.world.pos.x, this->dyna.actor.world.pos.z, - &ySurface, &waterBox)) { + if (WaterBox_GetSurface1(play, &play->colCtx, this->dyna.actor.world.pos.x, this->dyna.actor.world.pos.z, &ySurface, + &waterBox)) { Math_Vec3s_ToVec3f(&this->waterBoxPos, &waterBox->minPos); this->waterBoxXLength = waterBox->xLength; this->waterBoxZLength = waterBox->zLength; } } -void BgGoronOyu_SpawnParticles(BgGoronOyu* this, GlobalContext* globalCtx) { +void BgGoronOyu_SpawnEffects(BgGoronOyu* this, PlayState* play) { s16 scale; Vec3f pos1; Vec3f pos2; CollisionPoly* poly; s32 pad; - if ((globalCtx->state.frames % 4) == 0) { + if ((play->state.frames % 4) == 0) { Vec3f vel1; Vec3f vel2; @@ -127,9 +127,9 @@ void BgGoronOyu_SpawnParticles(BgGoronOyu* this, GlobalContext* globalCtx) { vel1.z = 0.0f; scale = -200 - (s32)(Rand_ZeroOne() * 50.0f); - if (BgCheck_EntityRaycastFloor2(globalCtx, &globalCtx->colCtx, &poly, &pos1) < this->waterBoxPos.y) { + if (BgCheck_EntityRaycastFloor2(play, &play->colCtx, &poly, &pos1) < this->waterBoxPos.y) { pos1.y = this->waterBoxPos.y + 10.0f; - EffectSsIceSmoke_Spawn(globalCtx, &pos1, &vel1, &gZeroVec3f, scale); + EffectSsIceSmoke_Spawn(play, &pos1, &vel1, &gZeroVec3f, scale); } pos2.x = (Rand_ZeroOne() * this->waterBoxXLength) + this->waterBoxPos.x; pos2.y = this->waterBoxPos.y + 100.0f; @@ -139,14 +139,14 @@ void BgGoronOyu_SpawnParticles(BgGoronOyu* this, GlobalContext* globalCtx) { vel2.z = 0.0f; scale = -200 - (s32)(Rand_ZeroOne() * 50.0f); - if (BgCheck_EntityRaycastFloor2(globalCtx, &globalCtx->colCtx, &poly, &pos2) < this->waterBoxPos.y) { + if (BgCheck_EntityRaycastFloor2(play, &play->colCtx, &poly, &pos2) < this->waterBoxPos.y) { pos2.y = this->waterBoxPos.y + 10.0f; - EffectSsIceSmoke_Spawn(globalCtx, &pos2, &vel2, &gZeroVec3f, scale); + EffectSsIceSmoke_Spawn(play, &pos2, &vel2, &gZeroVec3f, scale); } } } -void BgGoronOyu_Init(Actor* thisx, GlobalContext* globalCtx) { +void BgGoronOyu_Init(Actor* thisx, PlayState* play) { s32 pad; BgGoronOyu* this = THIS; CollisionHeader* colHeader = NULL; @@ -155,9 +155,9 @@ void BgGoronOyu_Init(Actor* thisx, GlobalContext* globalCtx) { DynaPolyActor_Init(&this->dyna, 1); CollisionHeader_GetVirtual(&object_oyu_Colheader_000988, &colHeader); - this->dyna.bgId = DynaPoly_SetBgActor(globalCtx, &globalCtx->colCtx.dyna, &this->dyna.actor, colHeader); + this->dyna.bgId = DynaPoly_SetBgActor(play, &play->colCtx.dyna, &this->dyna.actor, colHeader); - BgGoronOyu_UpdateWaterBoxInfo(this, globalCtx); + BgGoronOyu_UpdateWaterBoxInfo(this, play); if (thisx->params != 0) { thisx->world.pos.y = thisx->home.pos.y; @@ -168,25 +168,25 @@ void BgGoronOyu_Init(Actor* thisx, GlobalContext* globalCtx) { } } -void BgGoronOyu_Destroy(Actor* thisx, GlobalContext* globalCtx) { +void BgGoronOyu_Destroy(Actor* thisx, PlayState* play) { BgGoronOyu* this = THIS; - DynaPoly_DeleteBgActor(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); + DynaPoly_DeleteBgActor(play, &play->colCtx.dyna, this->dyna.bgId); } -void BgGoronOyu_Update(Actor* thisx, GlobalContext* globalCtx) { +void BgGoronOyu_Update(Actor* thisx, PlayState* play) { BgGoronOyu* this = THIS; - this->actionFunc(this, globalCtx); - BgGoronOyu_SpawnParticles(this, globalCtx); + this->actionFunc(this, play); + BgGoronOyu_SpawnEffects(this, play); } -void BgGoronOyu_Draw(Actor* thisx, GlobalContext* globalCtx) { - OPEN_DISPS(globalCtx->state.gfxCtx); - func_8012C2DC(globalCtx->state.gfxCtx); - AnimatedMat_Draw(globalCtx, Lib_SegmentedToVirtual(object_oyu_Matanimheader_000968)); - gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); +void BgGoronOyu_Draw(Actor* thisx, PlayState* play) { + OPEN_DISPS(play->state.gfxCtx); + func_8012C2DC(play->state.gfxCtx); + AnimatedMat_Draw(play, Lib_SegmentedToVirtual(object_oyu_Matanimheader_000968)); + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_XLU_DISP++, &object_oyu_DL_000158); gSPDisplayList(POLY_XLU_DISP++, &object_oyu_DL_000080); - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->state.gfxCtx); } diff --git a/src/overlays/actors/ovl_Bg_Goron_Oyu/z_bg_goron_oyu.h b/src/overlays/actors/ovl_Bg_Goron_Oyu/z_bg_goron_oyu.h index dba8bb044..d17ff87b3 100644 --- a/src/overlays/actors/ovl_Bg_Goron_Oyu/z_bg_goron_oyu.h +++ b/src/overlays/actors/ovl_Bg_Goron_Oyu/z_bg_goron_oyu.h @@ -5,7 +5,7 @@ struct BgGoronOyu; -typedef void (*BgGoronOyuActionFunc)(struct BgGoronOyu*, GlobalContext*); +typedef void (*BgGoronOyuActionFunc)(struct BgGoronOyu*, PlayState*); typedef struct BgGoronOyu { /* 0x000 */ DynaPolyActor dyna; diff --git a/src/overlays/actors/ovl_Bg_Haka_Bombwall/z_bg_haka_bombwall.c b/src/overlays/actors/ovl_Bg_Haka_Bombwall/z_bg_haka_bombwall.c index 3c535326e..f494131d9 100644 --- a/src/overlays/actors/ovl_Bg_Haka_Bombwall/z_bg_haka_bombwall.c +++ b/src/overlays/actors/ovl_Bg_Haka_Bombwall/z_bg_haka_bombwall.c @@ -5,17 +5,25 @@ */ #include "z_bg_haka_bombwall.h" +#include "objects/object_haka_obj/object_haka_obj.h" #define FLAGS 0x00000000 #define THIS ((BgHakaBombwall*)thisx) -void BgHakaBombwall_Init(Actor* thisx, GlobalContext* globalCtx); -void BgHakaBombwall_Destroy(Actor* thisx, GlobalContext* globalCtx); -void BgHakaBombwall_Update(Actor* thisx, GlobalContext* globalCtx); -void BgHakaBombwall_Draw(Actor* thisx, GlobalContext* globalCtx); +void BgHakaBombwall_Init(Actor* thisx, PlayState* play); +void BgHakaBombwall_Destroy(Actor* thisx, PlayState* play); +void BgHakaBombwall_Update(Actor* thisx, PlayState* play); +void BgHakaBombwall_Draw(Actor* thisx, PlayState* play); + +void func_80BD5E6C(BgHakaBombwall* this, PlayState* play); +void func_80BD6260(BgHakaBombwall* this); +void func_80BD6274(BgHakaBombwall* this, PlayState* play); +void BgHakaBombwall_SetupPlayCutscene(BgHakaBombwall* this); +void BgHakaBombwall_PlayCutscene(BgHakaBombwall* this, PlayState* play); +void BgHakaBombwall_SetupEndCutscene(BgHakaBombwall* this); +void BgHakaBombwall_EndCutscene(BgHakaBombwall* this, PlayState* play); -#if 0 const ActorInit Bg_Haka_Bombwall_InitVars = { ACTOR_BG_HAKA_BOMBWALL, ACTORCAT_BG, @@ -28,50 +36,191 @@ const ActorInit Bg_Haka_Bombwall_InitVars = { (ActorFunc)BgHakaBombwall_Draw, }; -// static ColliderCylinderInit sCylinderInit = { -static ColliderCylinderInit D_80BD64A0 = { - { COLTYPE_NONE, AT_NONE, AC_ON | AC_TYPE_PLAYER, OC1_NONE, OC2_NONE, COLSHAPE_CYLINDER, }, - { ELEMTYPE_UNK0, { 0x00000000, 0x00, 0x00 }, { 0x00000008, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_NONE, }, +static ColliderCylinderInit sCylinderInit = { + { + COLTYPE_NONE, + AT_NONE, + AC_ON | AC_TYPE_PLAYER, + OC1_NONE, + OC2_NONE, + COLSHAPE_CYLINDER, + }, + { + ELEMTYPE_UNK0, + { 0x00000000, 0x00, 0x00 }, + { 0x00000008, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_NONE, + }, { 80, 80, 0, { 0, 0, 0 } }, }; -// static InitChainEntry sInitChain[] = { -static InitChainEntry D_80BD64D4[] = { +static s16 D_80BD64CC[4] = { 24, 15, 10, 5 }; + +static InitChainEntry sInitChain[] = { ICHAIN_F32(uncullZoneForward, 4000, ICHAIN_CONTINUE), ICHAIN_F32(uncullZoneScale, 500, ICHAIN_CONTINUE), ICHAIN_F32(uncullZoneDownward, 500, ICHAIN_CONTINUE), ICHAIN_VEC3F_DIV1000(scale, 100, ICHAIN_STOP), }; +s32 func_80BD5E00(BgHakaBombwall* this) { + if (this->collider.base.acFlags & AC_HIT) { + if ((this->collider.base.ac != NULL) && + (Math3D_Vec3fDistSq(&this->dyna.actor.world.pos, &this->collider.base.ac->world.pos) < SQ(80.0f))) { + return true; + } + } + return false; +} + +#ifdef NON_MATCHING +void func_80BD5E6C(BgHakaBombwall* this, PlayState* play) { + s32 i; + Vec3f spE0; + Vec3f spD4; + Vec3f spC8; + Vec3f spBC; + f32 temp_fs0; + f32 phi_fs1; + s16 phi_s0; + s16 gravity; + s16 phi_t0; + + Matrix_Push(); + Matrix_RotateYS(this->dyna.actor.shape.rot.y, MTXMODE_NEW); + temp_fs0 = 0.0f; + phi_fs1 = 0.0f; + + for (i = 0; i < 30; i++) { + temp_fs0 += 60.0f + (Rand_ZeroOne() * 20.0f); + if (temp_fs0 > 75.0f) { + temp_fs0 -= 150.0f; + } + spC8.x = temp_fs0; + + phi_fs1 += 5; + spC8.y = phi_fs1; + + spC8.z = (Rand_ZeroOne() * 20.0f) - 10.0f; + + spBC.x = ((Rand_ZeroOne() - 0.5f) * 5.0f) + (temp_fs0 * (4.0f / 75.0f)); + spBC.y = (Rand_ZeroOne() * 7.0f) - 2.0f; + spBC.z = (Rand_ZeroOne() * 4.0f) - 2.0f; + + Matrix_MultVec3f(&spC8, &spE0); + Matrix_MultVec3f(&spBC, &spD4); + + spE0.x += this->dyna.actor.world.pos.x; + spE0.y += this->dyna.actor.world.pos.y; + spE0.z += this->dyna.actor.world.pos.z; + + if ((i & 3) == 0) { + phi_s0 = 32; + func_800BBFB0(play, &spE0, 60.0f, 2, 100, 120, 1); + } else { + phi_s0 = 64; + } + + if (i % 2 != 0) { + phi_s0 |= 1; + phi_t0 = 1; + } else { + phi_t0 = 0; + } + + if (D_80BD64CC[i & 3] >= 16) { + gravity = -550; + } else { + gravity = -450; + } + + EffectSsKakera_Spawn(play, &spE0, &spD4, &spE0, gravity, phi_s0, 30, 0, 0, D_80BD64CC[i & 3], phi_t0, 0, 50, -1, + OBJECT_IKANA_OBJ, object_haka_obj_DL_001680); + } + + Matrix_Pop(); +} +#else +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Haka_Bombwall/func_80BD5E6C.s") #endif -extern ColliderCylinderInit D_80BD64A0; -extern InitChainEntry D_80BD64D4[]; +void BgHakaBombwall_Init(Actor* thisx, PlayState* play) { + s32 pad; + BgHakaBombwall* this = THIS; -extern UNK_TYPE D_06000040; -extern UNK_TYPE D_06000148; -extern UNK_TYPE D_06001680; + Actor_ProcessInitChain(&this->dyna.actor, sInitChain); + DynaPolyActor_Init(&this->dyna, 0); + Collider_InitCylinder(play, &this->collider); + if (Flags_GetSwitch(play, BGHAKABOMBWALL_GET_7F(thisx))) { + Actor_MarkForDeath(&this->dyna.actor); + } else { + DynaPolyActor_LoadMesh(play, &this->dyna, &object_haka_obj_Colheader_000148); + Collider_SetCylinder(play, &this->collider, &this->dyna.actor, &sCylinderInit); + Collider_UpdateCylinder(&this->dyna.actor, &this->collider); + func_80BD6260(this); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Haka_Bombwall/func_80BD5E00.s") +void BgHakaBombwall_Destroy(Actor* thisx, PlayState* play) { + BgHakaBombwall* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Haka_Bombwall/func_80BD5E6C.s") + DynaPoly_DeleteBgActor(play, &play->colCtx.dyna, this->dyna.bgId); + Collider_DestroyCylinder(play, &this->collider); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Haka_Bombwall/BgHakaBombwall_Init.s") +void func_80BD6260(BgHakaBombwall* this) { + this->actionFunc = func_80BD6274; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Haka_Bombwall/BgHakaBombwall_Destroy.s") +void func_80BD6274(BgHakaBombwall* this, PlayState* play) { + if (func_80BD5E00(this)) { + BgHakaBombwall_SetupPlayCutscene(this); + } else { + CollisionCheck_SetAC(play, &play->colChkCtx, &this->collider.base); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Haka_Bombwall/func_80BD6260.s") +void BgHakaBombwall_SetupPlayCutscene(BgHakaBombwall* this) { + this->dyna.actor.flags |= ACTOR_FLAG_10; + ActorCutscene_SetIntentToPlay(this->dyna.actor.cutscene); + this->actionFunc = BgHakaBombwall_PlayCutscene; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Haka_Bombwall/func_80BD6274.s") +void BgHakaBombwall_PlayCutscene(BgHakaBombwall* this, PlayState* play) { + if (ActorCutscene_GetCanPlayNext(this->dyna.actor.cutscene)) { + ActorCutscene_StartAndSetUnkLinkFields(this->dyna.actor.cutscene, &this->dyna.actor); + func_80BD5E6C(this, play); + this->dyna.actor.draw = NULL; + Flags_SetSwitch(play, BGHAKABOMBWALL_GET_7F(&this->dyna.actor)); + SoundSource_PlaySfxAtFixedWorldPos(play, &this->dyna.actor.world.pos, 0x3C, NA_SE_EV_WALL_BROKEN); + func_800C62BC(play, &play->colCtx.dyna, this->dyna.bgId); + BgHakaBombwall_SetupEndCutscene(this); + } else { + ActorCutscene_SetIntentToPlay(this->dyna.actor.cutscene); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Haka_Bombwall/func_80BD62D0.s") +void BgHakaBombwall_SetupEndCutscene(BgHakaBombwall* this) { + this->csTimer = 30; + this->actionFunc = BgHakaBombwall_EndCutscene; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Haka_Bombwall/func_80BD6314.s") +void BgHakaBombwall_EndCutscene(BgHakaBombwall* this, PlayState* play) { + this->csTimer--; + if (this->csTimer <= 0) { + ActorCutscene_Stop(this->dyna.actor.cutscene); + Actor_MarkForDeath(&this->dyna.actor); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Haka_Bombwall/func_80BD63B4.s") +void BgHakaBombwall_Update(Actor* thisx, PlayState* play) { + BgHakaBombwall* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Haka_Bombwall/func_80BD63D0.s") + this->actionFunc(this, play); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Haka_Bombwall/BgHakaBombwall_Update.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Haka_Bombwall/BgHakaBombwall_Draw.s") +void BgHakaBombwall_Draw(Actor* thisx, PlayState* play) { + Gfx_DrawDListOpa(play, object_haka_obj_DL_000040); +} diff --git a/src/overlays/actors/ovl_Bg_Haka_Bombwall/z_bg_haka_bombwall.h b/src/overlays/actors/ovl_Bg_Haka_Bombwall/z_bg_haka_bombwall.h index 10ec6e057..6a37e3625 100644 --- a/src/overlays/actors/ovl_Bg_Haka_Bombwall/z_bg_haka_bombwall.h +++ b/src/overlays/actors/ovl_Bg_Haka_Bombwall/z_bg_haka_bombwall.h @@ -3,15 +3,17 @@ #include "global.h" +#define BGHAKABOMBWALL_GET_7F(thisx) ((thisx)->params & 0x7F) + struct BgHakaBombwall; -typedef void (*BgHakaBombwallActionFunc)(struct BgHakaBombwall*, GlobalContext*); +typedef void (*BgHakaBombwallActionFunc)(struct BgHakaBombwall*, PlayState*); typedef struct BgHakaBombwall { - /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x64]; - /* 0x01A8 */ BgHakaBombwallActionFunc actionFunc; - /* 0x01AC */ char unk_1AC[0x4]; + /* 0x000 */ DynaPolyActor dyna; + /* 0x15C */ ColliderCylinder collider; + /* 0x1A8 */ BgHakaBombwallActionFunc actionFunc; + /* 0x1AC */ s8 csTimer; } BgHakaBombwall; // size = 0x1B0 extern const ActorInit Bg_Haka_Bombwall_InitVars; diff --git a/src/overlays/actors/ovl_Bg_Haka_Curtain/z_bg_haka_curtain.c b/src/overlays/actors/ovl_Bg_Haka_Curtain/z_bg_haka_curtain.c index 576388d5c..cc90ccd94 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 @@ -11,19 +11,19 @@ #define THIS ((BgHakaCurtain*)thisx) -void BgHakaCurtain_Init(Actor* thisx, GlobalContext* globalCtx); -void BgHakaCurtain_Destroy(Actor* thisx, GlobalContext* globalCtx); -void BgHakaCurtain_Update(Actor* thisx, GlobalContext* globalCtx); -void BgHakaCurtain_Draw(Actor* thisx, GlobalContext* globalCtx); +void BgHakaCurtain_Init(Actor* thisx, PlayState* play); +void BgHakaCurtain_Destroy(Actor* thisx, PlayState* play); +void BgHakaCurtain_Update(Actor* thisx, PlayState* play); +void BgHakaCurtain_Draw(Actor* thisx, PlayState* play); void func_80B6DC98(BgHakaCurtain* this); -void func_80B6DCAC(BgHakaCurtain* this, GlobalContext* globalCtx); +void func_80B6DCAC(BgHakaCurtain* this, PlayState* play); void func_80B6DCEC(BgHakaCurtain* this); -void func_80B6DD00(BgHakaCurtain* this, GlobalContext* globalCtx); +void func_80B6DD00(BgHakaCurtain* this, PlayState* play); void func_80B6DD5C(BgHakaCurtain* this); -void func_80B6DD70(BgHakaCurtain* this, GlobalContext* globalCtx); -void func_80B6DD9C(BgHakaCurtain* this, GlobalContext* globalCtx); -void func_80B6DEA8(BgHakaCurtain* this, GlobalContext* globalCtx); +void func_80B6DD70(BgHakaCurtain* this, PlayState* play); +void func_80B6DD9C(BgHakaCurtain* this, PlayState* play); +void func_80B6DEA8(BgHakaCurtain* this, PlayState* play); void func_80B6DE80(BgHakaCurtain* this); const ActorInit Bg_Haka_Curtain_InitVars = { @@ -45,31 +45,31 @@ static InitChainEntry sInitChain[] = { ICHAIN_VEC3F_DIV1000(scale, 100, ICHAIN_STOP), }; -void BgHakaCurtain_Init(Actor* thisx, GlobalContext* globalCtx) { +void BgHakaCurtain_Init(Actor* thisx, PlayState* play) { BgHakaCurtain* this = THIS; Actor_ProcessInitChain(&this->dyna.actor, sInitChain); DynaPolyActor_Init(&this->dyna, 1); - DynaPolyActor_LoadMesh(globalCtx, &this->dyna, &object_haka_obj_Colheader_001588); - if (Flags_GetClear(globalCtx, this->dyna.actor.room)) { + DynaPolyActor_LoadMesh(play, &this->dyna, &object_haka_obj_Colheader_001588); + if (Flags_GetClear(play, this->dyna.actor.room)) { func_80B6DE80(this); return; } func_80B6DC98(this); } -void BgHakaCurtain_Destroy(Actor* thisx, GlobalContext* globalCtx) { +void BgHakaCurtain_Destroy(Actor* thisx, PlayState* play) { BgHakaCurtain* this = THIS; - DynaPoly_DeleteBgActor(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); + DynaPoly_DeleteBgActor(play, &play->colCtx.dyna, this->dyna.bgId); } void func_80B6DC98(BgHakaCurtain* this) { this->actionFunc = func_80B6DCAC; } -void func_80B6DCAC(BgHakaCurtain* this, GlobalContext* globalCtx) { - if (Flags_GetClear(globalCtx, this->dyna.actor.room)) { +void func_80B6DCAC(BgHakaCurtain* this, PlayState* play) { + if (Flags_GetClear(play, this->dyna.actor.room)) { func_80B6DCEC(this); } } @@ -78,7 +78,7 @@ void func_80B6DCEC(BgHakaCurtain* this) { this->actionFunc = func_80B6DD00; } -void func_80B6DD00(BgHakaCurtain* this, GlobalContext* globalCtx) { +void func_80B6DD00(BgHakaCurtain* this, PlayState* play) { if (ActorCutscene_GetCanPlayNext(this->dyna.actor.cutscene)) { ActorCutscene_StartAndSetUnkLinkFields(this->dyna.actor.cutscene, &this->dyna.actor); func_80B6DD5C(this); @@ -91,7 +91,7 @@ void func_80B6DD5C(BgHakaCurtain* this) { this->actionFunc = func_80B6DD70; } -void func_80B6DD70(BgHakaCurtain* this, GlobalContext* globalCtx) { +void func_80B6DD70(BgHakaCurtain* this, PlayState* play) { } void func_80B6DD80(BgHakaCurtain* this) { @@ -99,7 +99,7 @@ void func_80B6DD80(BgHakaCurtain* this) { this->dyna.actor.velocity.y = 0.0f; } -void func_80B6DD9C(BgHakaCurtain* this, GlobalContext* globalCtx) { +void func_80B6DD9C(BgHakaCurtain* this, PlayState* play) { if (this->dyna.actor.world.pos.y < this->dyna.actor.home.pos.y + 150.0f - 30.0f) { Math_StepToF(&this->dyna.actor.velocity.y, 1.6f, 0.12f); } else { @@ -118,22 +118,22 @@ void func_80B6DE80(BgHakaCurtain* this) { this->dyna.actor.world.pos.y = this->dyna.actor.home.pos.y + 150.0f; } -void func_80B6DEA8(BgHakaCurtain* this, GlobalContext* globalCtx) { +void func_80B6DEA8(BgHakaCurtain* this, PlayState* play) { } -void BgHakaCurtain_Update(Actor* thisx, GlobalContext* globalCtx) { +void BgHakaCurtain_Update(Actor* thisx, PlayState* play) { BgHakaCurtain* this = THIS; CsCmdActorAction* actorAction; - if (Cutscene_CheckActorAction(globalCtx, 469)) { - actorAction = globalCtx->csCtx.actorActions[Cutscene_GetActorActionIndex(globalCtx, 469)]; - if (actorAction->startFrame == globalCtx->csCtx.frames && actorAction->action == 2) { + if (Cutscene_CheckActorAction(play, 469)) { + actorAction = play->csCtx.actorActions[Cutscene_GetActorActionIndex(play, 469)]; + if (actorAction->startFrame == play->csCtx.frames && actorAction->action == 2) { func_80B6DD80(this); } } - this->actionFunc(this, globalCtx); + this->actionFunc(this, play); } -void BgHakaCurtain_Draw(Actor* thisx, GlobalContext* globalCtx) { - Gfx_DrawDListOpa(globalCtx, object_haka_obj_DL_001410); +void BgHakaCurtain_Draw(Actor* thisx, PlayState* play) { + Gfx_DrawDListOpa(play, object_haka_obj_DL_001410); } diff --git a/src/overlays/actors/ovl_Bg_Haka_Curtain/z_bg_haka_curtain.h b/src/overlays/actors/ovl_Bg_Haka_Curtain/z_bg_haka_curtain.h index f227e5c98..4b5e564b2 100644 --- a/src/overlays/actors/ovl_Bg_Haka_Curtain/z_bg_haka_curtain.h +++ b/src/overlays/actors/ovl_Bg_Haka_Curtain/z_bg_haka_curtain.h @@ -5,7 +5,7 @@ struct BgHakaCurtain; -typedef void (*BgHakaCurtainActionFunc)(struct BgHakaCurtain*, GlobalContext*); +typedef void (*BgHakaCurtainActionFunc)(struct BgHakaCurtain*, PlayState*); typedef struct BgHakaCurtain { /* 0x000 */ DynaPolyActor dyna; 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 7cb4aab5e..8d48168a6 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 @@ -11,17 +11,17 @@ #define THIS ((BgHakaTomb*)thisx) -void BgHakaTomb_Init(Actor* thisx, GlobalContext* globalCtx); -void BgHakaTomb_Destroy(Actor* thisx, GlobalContext* globalCtx); -void BgHakaTomb_Update(Actor* thisx, GlobalContext* globalCtx); -void BgHakaTomb_Draw(Actor* thisx, GlobalContext* globalCtx); +void BgHakaTomb_Init(Actor* thisx, PlayState* play); +void BgHakaTomb_Destroy(Actor* thisx, PlayState* play); +void BgHakaTomb_Update(Actor* thisx, PlayState* play); +void BgHakaTomb_Draw(Actor* thisx, PlayState* play); void func_80BD6624(BgHakaTomb* this); -void func_80BD66AC(BgHakaTomb* this, GlobalContext* globalCtx); +void func_80BD66AC(BgHakaTomb* this, PlayState* play); void func_80BD6754(BgHakaTomb* this); -void func_80BD6768(BgHakaTomb* this, GlobalContext* globalCtx); +void func_80BD6768(BgHakaTomb* this, PlayState* play); void BgHakaTomb_SetupDoNothing(BgHakaTomb* this); -void BgHakaTomb_DoNothing(BgHakaTomb* this, GlobalContext* globalCtx); +void BgHakaTomb_DoNothing(BgHakaTomb* this, PlayState* play); const ActorInit Bg_Haka_Tomb_InitVars = { ACTOR_BG_HAKA_TOMB, @@ -41,20 +41,20 @@ static InitChainEntry sInitChain[] = { static Vec3f D_80BD68A4 = { 30.0f, 90.0f, 0.0f }; -void BgHakaTomb_Init(Actor* thisx, GlobalContext* globalCtx) { +void BgHakaTomb_Init(Actor* thisx, PlayState* play) { BgHakaTomb* this = THIS; Actor_ProcessInitChain(&this->dyna.actor, sInitChain); DynaPolyActor_Init(&this->dyna, 1); - DynaPolyActor_LoadMesh(globalCtx, &this->dyna, &object_haka_obj_Colheader_000EE8); + DynaPolyActor_LoadMesh(play, &this->dyna, &object_haka_obj_Colheader_000EE8); SubS_FillCutscenesList(&this->dyna.actor, this->cutscenes, ARRAY_COUNT(this->cutscenes)); func_80BD6624(this); } -void BgHakaTomb_Destroy(Actor* thisx, GlobalContext* globalCtx) { +void BgHakaTomb_Destroy(Actor* thisx, PlayState* play) { BgHakaTomb* this = THIS; - DynaPoly_DeleteBgActor(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); + DynaPoly_DeleteBgActor(play, &play->colCtx.dyna, this->dyna.bgId); } void func_80BD6624(BgHakaTomb* this) { @@ -79,13 +79,13 @@ s32 func_80BD6638(s16* arg0, s16* arg1, s32 arg2) { return retVal; } -void func_80BD66AC(BgHakaTomb* this, GlobalContext* globalCtx) { +void func_80BD66AC(BgHakaTomb* this, PlayState* play) { s16 temp; - if (Flags_GetClear(globalCtx, this->dyna.actor.room)) { + if (Flags_GetClear(play, this->dyna.actor.room)) { this->dyna.actor.flags |= (ACTOR_FLAG_1 | ACTOR_FLAG_8); } - if (!func_80BD6638(&temp, this->cutscenes, 1) && (temp < 0) && Flags_GetClear(globalCtx, this->dyna.actor.room)) { + if (!func_80BD6638(&temp, this->cutscenes, 1) && (temp < 0) && Flags_GetClear(play, this->dyna.actor.room)) { this->dyna.actor.flags |= ACTOR_FLAG_1; if (this->dyna.actor.isTargeted) { func_80BD6754(this); @@ -99,7 +99,7 @@ void func_80BD6754(BgHakaTomb* this) { this->actionFunc = func_80BD6768; } -void func_80BD6768(BgHakaTomb* this, GlobalContext* globalCtx) { +void func_80BD6768(BgHakaTomb* this, PlayState* play) { if (SubS_StartActorCutscene(&this->dyna.actor, this->cutscenes[0], -1, SUBS_CUTSCENE_SET_UNK_LINK_FIELDS)) { BgHakaTomb_SetupDoNothing(this); } @@ -109,22 +109,22 @@ void BgHakaTomb_SetupDoNothing(BgHakaTomb* this) { this->actionFunc = BgHakaTomb_DoNothing; } -void BgHakaTomb_DoNothing(BgHakaTomb* this, GlobalContext* globalCtx) { +void BgHakaTomb_DoNothing(BgHakaTomb* this, PlayState* play) { } -void BgHakaTomb_Update(Actor* thisx, GlobalContext* globalCtx) { +void BgHakaTomb_Update(Actor* thisx, PlayState* play) { BgHakaTomb* this = THIS; s32 pad; 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); + this->actionFunc(this, play); + 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); } -void BgHakaTomb_Draw(Actor* thisx, GlobalContext* globalCtx) { - Gfx_DrawDListOpa(globalCtx, object_haka_obj_DL_0007B0); +void BgHakaTomb_Draw(Actor* thisx, PlayState* play) { + Gfx_DrawDListOpa(play, object_haka_obj_DL_0007B0); } diff --git a/src/overlays/actors/ovl_Bg_Haka_Tomb/z_bg_haka_tomb.h b/src/overlays/actors/ovl_Bg_Haka_Tomb/z_bg_haka_tomb.h index 51a024077..c1cefddc8 100644 --- a/src/overlays/actors/ovl_Bg_Haka_Tomb/z_bg_haka_tomb.h +++ b/src/overlays/actors/ovl_Bg_Haka_Tomb/z_bg_haka_tomb.h @@ -5,7 +5,7 @@ struct BgHakaTomb; -typedef void (*BgHakaTombActionFunc)(struct BgHakaTomb*, GlobalContext*); +typedef void (*BgHakaTombActionFunc)(struct BgHakaTomb*, PlayState*); typedef struct BgHakaTomb { /* 0x000 */ DynaPolyActor dyna; 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 1f0030d28..37a232bc5 100644 --- a/src/overlays/actors/ovl_Bg_Hakugin_Bombwall/z_bg_hakugin_bombwall.c +++ b/src/overlays/actors/ovl_Bg_Hakugin_Bombwall/z_bg_hakugin_bombwall.c @@ -11,20 +11,20 @@ #define THIS ((BgHakuginBombwall*)thisx) -void BgHakuginBombwall_Init(Actor* thisx, GlobalContext* globalCtx); -void BgHakuginBombwall_Destroy(Actor* thisx, GlobalContext* globalCtx); -void BgHakuginBombwall_Update(Actor* thisx, GlobalContext* globalCtx); -void BgHakuginBombwall_Draw(Actor* thisx, GlobalContext* globalCtx); +void BgHakuginBombwall_Init(Actor* thisx, PlayState* play); +void BgHakuginBombwall_Destroy(Actor* thisx, PlayState* play); +void BgHakuginBombwall_Update(Actor* thisx, PlayState* play); +void BgHakuginBombwall_Draw(Actor* thisx, PlayState* play); -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); +void func_80ABBFC0(BgHakuginBombwall* this, PlayState* play); +void func_80ABC2E0(BgHakuginBombwall* this, PlayState* play); +void func_80ABC58C(BgHakuginBombwall* this, PlayState* play); +void func_80ABC7FC(BgHakuginBombwall* this, PlayState* play); +s32 func_80ABCB5C(BgHakuginBombwall* this, PlayState* play); +s32 func_80ABCC00(BgHakuginBombwall* this, PlayState* play); +void func_80ABCCE4(BgHakuginBombwall* this, PlayState* play); +void func_80ABCD98(BgHakuginBombwall* this, PlayState* play); +void func_80ABCE60(BgHakuginBombwall* this, PlayState* play); const ActorInit Bg_Hakugin_Bombwall_InitVars = { ACTOR_BG_HAKUGIN_BOMBWALL, @@ -121,10 +121,8 @@ static InitChainEntry sInitChain[] = { ICHAIN_VEC3F_DIV1000(scale, 100, ICHAIN_STOP), }; -#ifdef NON_MATCHING -// Breaks relocs -void func_80ABBFC0(BgHakuginBombwall* this, GlobalContext* globalCtx) { - s32 temp; +void func_80ABBFC0(BgHakuginBombwall* this, PlayState* play) { + f32 temp; Vec3f spF0; Vec3f spE4; Vec3f spD8; @@ -135,21 +133,21 @@ void func_80ABBFC0(BgHakuginBombwall* this, GlobalContext* globalCtx) { s32 i; s32 j; - Matrix_RotateY(this->dyna.actor.shape.rot.y, MTXMODE_NEW); + Matrix_RotateYS(this->dyna.actor.shape.rot.y, MTXMODE_NEW); for (i = 0; i < 6; i++) { - temp = i + 1; + temp = (i + 1) * (80.0f / 3.0f); for (j = 0; j < ARRAY_COUNT(D_80ABD020); j++) { - spD8.x = D_80ABD020[j] + (s32)((u32)Rand_Next() >> 0x1C); - spD8.y = ((Rand_ZeroOne() - 0.5f) * 15.0f) + (temp * 26.666666f); + spD8.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; - spCC.x = ((Rand_ZeroOne() - 0.5f) * 7.0f) + (spD8.x * 0.07777778f); + 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; - Matrix_MultiplyVector3fByState(&spD8, &spF0); - Matrix_MultiplyVector3fByState(&spCC, &spE4); + Matrix_MultVec3f(&spD8, &spF0); + Matrix_MultVec3f(&spCC, &spE4); spF0.x += this->dyna.actor.world.pos.x; spF0.y += this->dyna.actor.world.pos.y; @@ -161,26 +159,22 @@ void func_80ABBFC0(BgHakuginBombwall* this, GlobalContext* globalCtx) { phi_s0 = 64; } - if (Rand_Next() > 0) { + if ((s32)Rand_Next() > 0) { phi_s0 |= 1; phi_s1 = 1; - func_800B0E48(globalCtx, &spF0, &gZeroVec3f, &D_80ABCFB4, &D_80ABCFAC, &D_80ABCFB0, - ((u32)Rand_Next() >> 0x1B) + 70, ((u32)Rand_Next() >> 0x1A) + 60); + func_800B0E48(play, &spF0, &gZeroVec3f, &D_80ABCFB4, &D_80ABCFAC, &D_80ABCFB0, + (Rand_Next() >> 0x1B) + 70, (Rand_Next() >> 0x1A) + 60); } else { phi_s1 = 0; } - EffectSsKakera_Spawn(globalCtx, &spF0, &spE4, &spF0, -550, phi_s0, 30, 0, 0, - (s32)(Rand_ZeroOne() * 22.0f) + 5, phi_s1, 0, 50, -1, OBJECT_HAKUGIN_OBJ, - object_hakugin_obj_DL_009830); + EffectSsKakera_Spawn(play, &spF0, &spE4, &spF0, -550, phi_s0, 30, 0, 0, (s32)(Rand_ZeroOne() * 22.0f) + 5, + phi_s1, 0, 50, -1, OBJECT_HAKUGIN_OBJ, object_hakugin_obj_DL_009830); } } } -#else -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Hakugin_Bombwall/func_80ABBFC0.s") -#endif -void func_80ABC2E0(BgHakuginBombwall* this, GlobalContext* globalCtx) { +void func_80ABC2E0(BgHakuginBombwall* this, PlayState* play) { s32 pad; s32 i; s16 phi_s2; @@ -224,17 +218,17 @@ void func_80ABC2E0(BgHakuginBombwall* this, GlobalContext* globalCtx) { phi_t0 = -400; } - EffectSsKakera_Spawn(globalCtx, &spC8, &spBC, &spC8, phi_t0, phi_v0, 30, 0, 0, temp_s1, phi_v1, 0, 50, -1, + EffectSsKakera_Spawn(play, &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, - ((u32)Rand_Next() >> 0x1B) + 60, ((u32)Rand_Next() >> 0x1A) + 50); + func_800B0E48(play, &spC8, &D_80ABD034, &D_80ABCFB4, &D_80ABCFAC, &D_80ABCFB0, (Rand_Next() >> 0x1B) + 60, + (Rand_Next() >> 0x1A) + 50); } } } -void func_80ABC58C(BgHakuginBombwall* this, GlobalContext* globalCtx) { +void func_80ABC58C(BgHakuginBombwall* this, PlayState* play) { s32 pad; Vec3f spD8; Vec3f spCC; @@ -250,7 +244,7 @@ void func_80ABC58C(BgHakuginBombwall* this, GlobalContext* globalCtx) { spA8.y = 0.0f; spB4.y = 0.3f; - Matrix_RotateY(this->dyna.actor.shape.rot.y, MTXMODE_NEW); + 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); @@ -266,20 +260,20 @@ void func_80ABC58C(BgHakuginBombwall* this, GlobalContext* globalCtx) { spB4.x = spA8.x * -0.09f; spB4.z = spA8.z * -0.09f; - Matrix_MultiplyVector3fByState(&sp9C, &spC0); - Matrix_MultiplyVector3fByState(&spA8, &spCC); - Matrix_MultiplyVector3fByState(&spB4, &spD8); + 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, ((u32)Rand_Next() >> 0x1A) + 60, - ((u32)Rand_Next() >> 0x1B) + 60); + func_800B0E48(play, &spC0, &spCC, &spD8, &D_80ABCFAC, &D_80ABCFB0, (Rand_Next() >> 0x1A) + 60, + (Rand_Next() >> 0x1B) + 60); } } -void func_80ABC7FC(BgHakuginBombwall* this, GlobalContext* globalCtx) { +void func_80ABC7FC(BgHakuginBombwall* this, PlayState* play) { s32 pad; Vec3f spB8; Vec3f spAC; @@ -308,28 +302,28 @@ void func_80ABC7FC(BgHakuginBombwall* this, GlobalContext* globalCtx) { spB8.x = spAC.x * -0.095f; spB8.z = spAC.z * -0.095f; - func_800B0E48(globalCtx, &spA0, &spAC, &spB8, &D_80ABCFAC, &D_80ABCFB0, ((u32)Rand_Next() >> 0x1A) + 60, - ((u32)Rand_Next() >> 0x1B) + 60); + func_800B0E48(play, &spA0, &spAC, &spB8, &D_80ABCFAC, &D_80ABCFB0, (Rand_Next() >> 0x1A) + 60, + (Rand_Next() >> 0x1B) + 60); } } -void BgHakuginBombwall_Init(Actor* thisx, GlobalContext* globalCtx) { +void BgHakuginBombwall_Init(Actor* thisx, PlayState* play) { 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); + Collider_InitCylinder(play, &this->collider); - if (Flags_GetSwitch(globalCtx, BGHAKUGIN_BOMBWALL_SWITCHFLAG(&this->dyna.actor))) { + if (Flags_GetSwitch(play, BGHAKUGIN_BOMBWALL_SWITCHFLAG(&this->dyna.actor))) { Actor_MarkForDeath(&this->dyna.actor); return; } - DynaPolyActor_LoadMesh(globalCtx, &this->dyna, ptr->unk_00); + DynaPolyActor_LoadMesh(play, &this->dyna, ptr->unk_00); - Collider_SetCylinder(globalCtx, &this->collider, &this->dyna.actor, &sCylinderInit); + Collider_SetCylinder(play, &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; @@ -341,22 +335,21 @@ void BgHakuginBombwall_Init(Actor* thisx, GlobalContext* globalCtx) { this->actionFunc = func_80ABCCE4; } -void BgHakuginBombwall_Destroy(Actor* thisx, GlobalContext* globalCtx) { +void BgHakuginBombwall_Destroy(Actor* thisx, PlayState* play) { BgHakuginBombwall* this = THIS; - DynaPoly_DeleteBgActor(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); - Collider_DestroyCylinder(globalCtx, &this->collider); + DynaPoly_DeleteBgActor(play, &play->colCtx.dyna, this->dyna.bgId); + Collider_DestroyCylinder(play, &this->collider); } -s32 func_80ABCB5C(Actor* thisx, GlobalContext* globalCtx) { - BgHakuginBombwall* this = THIS; - s32 pad; +s32 func_80ABCB5C(BgHakuginBombwall* this, PlayState* play) { + Actor* thisx = &this->dyna.actor; if (this->collider.base.acFlags & AC_HIT) { if (this->collider.base.ac != NULL) { - if (Math3D_Vec3fDistSq(&this->dyna.actor.world.pos, &this->collider.base.ac->world.pos) < - D_80ABCFC0[BGHAKUGIN_BOMBWALL_100(&this->dyna.actor)].unk_1C) { - SoundSource_PlaySfxAtFixedWorldPos(globalCtx, &this->dyna.actor.world.pos, 60, NA_SE_EV_WALL_BROKEN); + if (Math3D_Vec3fDistSq(&thisx->world.pos, &this->collider.base.ac->world.pos) < + D_80ABCFC0[BGHAKUGIN_BOMBWALL_100(thisx)].unk_1C) { + SoundSource_PlaySfxAtFixedWorldPos(play, &thisx->world.pos, 60, NA_SE_EV_WALL_BROKEN); return true; } } @@ -364,61 +357,58 @@ s32 func_80ABCB5C(Actor* thisx, GlobalContext* globalCtx) { return false; } -s32 func_80ABCC00(Actor* thisx, GlobalContext* globalCtx) { - BgHakuginBombwall* this = THIS; - s32 pad; - +s32 func_80ABCC00(BgHakuginBombwall* this, PlayState* play) { if (this->collider.base.acFlags & AC_HIT) { if (this->collider.info.acHitInfo->toucher.dmgFlags & 8) { if (this->collider.base.ac != NULL) { + s32 requiredScopeTemp; + if (Math3D_Vec3fDistSq(&this->dyna.actor.world.pos, &this->collider.base.ac->world.pos) < D_80ABCFC0[BGHAKUGIN_BOMBWALL_100(&this->dyna.actor)].unk_1C) { - SoundSource_PlaySfxAtFixedWorldPos(globalCtx, &this->dyna.actor.world.pos, 50, - NA_SE_EV_WALL_BROKEN); + SoundSource_PlaySfxAtFixedWorldPos(play, &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); + SoundSource_PlaySfxAtFixedWorldPos(play, &this->dyna.actor.world.pos, 50, NA_SE_EV_WALL_BROKEN); return true; } } return false; } -void func_80ABCCE4(BgHakuginBombwall* this, GlobalContext* globalCtx) { +void func_80ABCCE4(BgHakuginBombwall* this, PlayState* play) { BgHakuginBombwallStruct* ptr = &D_80ABCFC0[BGHAKUGIN_BOMBWALL_100(&this->dyna.actor)]; - if (ptr->unk_20(&this->dyna.actor, globalCtx)) { + if (ptr->unk_20(this, play)) { 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); + CollisionCheck_SetAC(play, &play->colChkCtx, &this->collider.base); } } -void func_80ABCD98(BgHakuginBombwall* this, GlobalContext* globalCtx) { +void func_80ABCD98(BgHakuginBombwall* this, PlayState* play) { 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); + ptr->unk_24(this, play); 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); + Flags_SetSwitch(play, BGHAKUGIN_BOMBWALL_SWITCHFLAG(&this->dyna.actor)); + func_800C62BC(play, &play->colCtx.dyna, this->dyna.bgId); this->actionFunc = func_80ABCE60; } else { ActorCutscene_SetIntentToPlay(this->dyna.actor.cutscene); } } -void func_80ABCE60(BgHakuginBombwall* this, GlobalContext* globalCtx) { +void func_80ABCE60(BgHakuginBombwall* this, PlayState* play) { BgHakuginBombwallStruct* ptr = &D_80ABCFC0[BGHAKUGIN_BOMBWALL_100(&this->dyna.actor)]; this->unk_1AC--; @@ -426,16 +416,16 @@ void func_80ABCE60(BgHakuginBombwall* this, GlobalContext* globalCtx) { ActorCutscene_Stop(this->dyna.actor.cutscene); Actor_MarkForDeath(&this->dyna.actor); } else if (this->unk_1AC == ptr->unk_2C) { - ptr->unk_28(this, globalCtx); + ptr->unk_28(this, play); } } -void BgHakuginBombwall_Update(Actor* thisx, GlobalContext* globalCtx) { +void BgHakuginBombwall_Update(Actor* thisx, PlayState* play) { BgHakuginBombwall* this = THIS; - this->actionFunc(this, globalCtx); + this->actionFunc(this, play); } -void BgHakuginBombwall_Draw(Actor* thisx, GlobalContext* globalCtx) { - Gfx_DrawDListOpa(globalCtx, D_80ABCFC0[BGHAKUGIN_BOMBWALL_100(thisx)].unk_04); +void BgHakuginBombwall_Draw(Actor* thisx, PlayState* play) { + Gfx_DrawDListOpa(play, 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 869741214..f849b356f 100644 --- a/src/overlays/actors/ovl_Bg_Hakugin_Bombwall/z_bg_hakugin_bombwall.h +++ b/src/overlays/actors/ovl_Bg_Hakugin_Bombwall/z_bg_hakugin_bombwall.h @@ -5,9 +5,9 @@ struct BgHakuginBombwall; -typedef void (*BgHakuginBombwallActionFunc)(struct BgHakuginBombwall*, GlobalContext*); -typedef s32 (*BgHakuginBombwallUnkFunc)(Actor*, GlobalContext*); -typedef void (*BgHakuginBombwallUnkFunc2)(struct BgHakuginBombwall*, GlobalContext*); +typedef void (*BgHakuginBombwallActionFunc)(struct BgHakuginBombwall*, PlayState*); +typedef s32 (*BgHakuginBombwallUnkFunc)(struct BgHakuginBombwall*, PlayState*); +typedef void (*BgHakuginBombwallUnkFunc2)(struct BgHakuginBombwall*, PlayState*); #define BGHAKUGIN_BOMBWALL_SWITCHFLAG(thisx) ((thisx)->params & 0x7F) #define BGHAKUGIN_BOMBWALL_100(thisx) (((thisx)->params >> 8) & 1) 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 b61f66bb6..8100c6205 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 @@ -5,19 +5,19 @@ */ #include "z_bg_hakugin_elvpole.h" +#include "objects/object_hakugin_obj/object_hakugin_obj.h" #define FLAGS (ACTOR_FLAG_10) #define THIS ((BgHakuginElvpole*)thisx) -void BgHakuginElvpole_Init(Actor* thisx, GlobalContext* globalCtx); -void BgHakuginElvpole_Destroy(Actor* thisx, GlobalContext* globalCtx); -void BgHakuginElvpole_Update(Actor* thisx, GlobalContext* globalCtx); -void BgHakuginElvpole_Draw(Actor* thisx, GlobalContext* globalCtx); +void BgHakuginElvpole_Init(Actor* thisx, PlayState* play); +void BgHakuginElvpole_Destroy(Actor* thisx, PlayState* play); +void BgHakuginElvpole_Update(Actor* thisx, PlayState* play); +void BgHakuginElvpole_Draw(Actor* thisx, PlayState* play); -void func_80ABD92C(BgHakuginElvpole* this, GlobalContext* globalCtx); +void func_80ABD92C(BgHakuginElvpole* this, PlayState* play); -#if 0 const ActorInit Bg_Hakugin_Elvpole_InitVars = { ACTOR_BG_HAKUGIN_ELVPOLE, ACTORCAT_BG, @@ -30,17 +30,104 @@ const ActorInit Bg_Hakugin_Elvpole_InitVars = { (ActorFunc)BgHakuginElvpole_Draw, }; -#endif +void BgHakuginElvpole_Init(Actor* thisx, PlayState* play) { + s32 pad; + CollisionHeader* colHeader = NULL; + BgHakuginElvpole* this = THIS; -extern UNK_TYPE D_0600ACB8; -extern UNK_TYPE D_0600BF40; + Actor_SetScale(&this->dyna.actor, 0.1f); + this->actionFunc = func_80ABD92C; + DynaPolyActor_Init(&this->dyna, 0); + CollisionHeader_GetVirtual(&object_hakugin_obj_Colheader_00BF40, &colHeader); + this->dyna.bgId = DynaPoly_SetBgActor(play, &play->colCtx.dyna, &this->dyna.actor, colHeader); + this->unk_15C = 0; + this->unk_160 = false; + if ((BGHAKUGINELVPOLE_GET_SWITCHFLAG(&this->dyna.actor) != 0x7F) && + Flags_GetSwitch(play, BGHAKUGINELVPOLE_GET_SWITCHFLAG(&this->dyna.actor))) { + this->unk_15E = 0x64; + } else { + this->unk_15E = -1; + this->dyna.actor.world.pos.y = this->dyna.actor.home.pos.y - 320.0f; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Hakugin_Elvpole/BgHakuginElvpole_Init.s") +void BgHakuginElvpole_Destroy(Actor* thisx, PlayState* play) { + BgHakuginElvpole* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Hakugin_Elvpole/BgHakuginElvpole_Destroy.s") + DynaPoly_DeleteBgActor(play, &play->colCtx.dyna, this->dyna.bgId); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Hakugin_Elvpole/func_80ABD92C.s") +void func_80ABD92C(BgHakuginElvpole* this, PlayState* play) { + s32 pad; + s32 sp28 = false; + f32 var_fv1; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Hakugin_Elvpole/BgHakuginElvpole_Update.s") + if (this->unk_15E > 0) { + if ((this->dyna.actor.world.pos.y - this->dyna.actor.home.pos.y) < -120.0f) { + this->dyna.actor.world.pos.y += 4.0f; + sp28 = true; + } else if (this->unk_15E > 0) { + if (this->unk_15E == 100) { + Actor_PlaySfxAtPos(&this->dyna.actor, NA_SE_EV_STONEDOOR_STOP); + } + this->dyna.actor.world.pos.y = this->dyna.actor.home.pos.y - 120.0f; + //! FAKE: + if (1) {} + this->unk_15E--; + } + } else if (this->unk_15E == 0) { + if ((this->dyna.actor.world.pos.y - this->dyna.actor.home.pos.y) > -320.0f) { + this->dyna.actor.world.pos.y -= 4.0f; + sp28 = true; + } else { + this->dyna.actor.world.pos.y = this->dyna.actor.home.pos.y - 320.0f; + Flags_UnsetSwitch(play, BGHAKUGINELVPOLE_GET_SWITCHFLAG(&this->dyna.actor)); + this->unk_15E = -1; + Actor_PlaySfxAtPos(&this->dyna.actor, NA_SE_EV_STONEDOOR_STOP); + } + } else if ((BGHAKUGINELVPOLE_GET_SWITCHFLAG(&this->dyna.actor) != 0x7F) && + Flags_GetSwitch(play, BGHAKUGINELVPOLE_GET_SWITCHFLAG(&this->dyna.actor))) { + this->unk_15E = 0x64; + this->unk_160 = true; + } + if (sp28 || (this->unk_15C & 7)) { + if (this->unk_15C & 1) { + var_fv1 = 1.0f; + } else { + var_fv1 = -1.0f; + } + this->unk_15C++; + this->dyna.actor.world.pos.x = (Math_SinS(this->unk_15C * 0x2000) * var_fv1) + this->dyna.actor.home.pos.x; + this->dyna.actor.world.pos.z = (Math_CosS(this->unk_15C * 0x2000) * var_fv1) + this->dyna.actor.home.pos.z; + func_800B9010(&this->dyna.actor, NA_SE_EV_PLATE_LIFT_LEVEL - SFX_FLAG); + } else { + this->unk_15C = 0; + } + if (this->unk_160) { + if (this->dyna.actor.cutscene == -1) { + this->unk_160 = false; + return; + } else if (ActorCutscene_GetCanPlayNext(this->dyna.actor.cutscene)) { + ActorCutscene_StartAndSetUnkLinkFields(this->dyna.actor.cutscene, &this->dyna.actor); + this->unk_160 = false; + return; + } + ActorCutscene_SetIntentToPlay(this->dyna.actor.cutscene); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Hakugin_Elvpole/BgHakuginElvpole_Draw.s") +void BgHakuginElvpole_Update(Actor* thisx, PlayState* play) { + BgHakuginElvpole* this = THIS; + + this->actionFunc(this, play); +} + +void BgHakuginElvpole_Draw(Actor* thisx, PlayState* play) { + OPEN_DISPS(play->state.gfxCtx); + + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + func_8012C28C(play->state.gfxCtx); + gSPDisplayList(POLY_OPA_DISP++, object_hakugin_obj_DL_00ACB8); + + CLOSE_DISPS(play->state.gfxCtx); +} diff --git a/src/overlays/actors/ovl_Bg_Hakugin_Elvpole/z_bg_hakugin_elvpole.h b/src/overlays/actors/ovl_Bg_Hakugin_Elvpole/z_bg_hakugin_elvpole.h index 1695faedc..b8316a4e6 100644 --- a/src/overlays/actors/ovl_Bg_Hakugin_Elvpole/z_bg_hakugin_elvpole.h +++ b/src/overlays/actors/ovl_Bg_Hakugin_Elvpole/z_bg_hakugin_elvpole.h @@ -5,12 +5,16 @@ struct BgHakuginElvpole; -typedef void (*BgHakuginElvpoleActionFunc)(struct BgHakuginElvpole*, GlobalContext*); +#define BGHAKUGINELVPOLE_GET_SWITCHFLAG(thisx) ((thisx)->params & 0x7F) + +typedef void (*BgHakuginElvpoleActionFunc)(struct BgHakuginElvpole*, PlayState*); typedef struct BgHakuginElvpole { - /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x20]; - /* 0x0164 */ BgHakuginElvpoleActionFunc actionFunc; + /* 0x000 */ DynaPolyActor dyna; + /* 0x15C */ s16 unk_15C; + /* 0x15E */ s16 unk_15E; + /* 0x160 */ u16 unk_160; + /* 0x164 */ BgHakuginElvpoleActionFunc actionFunc; } BgHakuginElvpole; // size = 0x168 extern const ActorInit Bg_Hakugin_Elvpole_InitVars; diff --git a/src/overlays/actors/ovl_Bg_Hakugin_Post/z_bg_hakugin_post.c b/src/overlays/actors/ovl_Bg_Hakugin_Post/z_bg_hakugin_post.c index 1ad88f3f8..0c273c739 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 @@ -6,34 +6,34 @@ #include "prevent_bss_reordering.h" #include "z_bg_hakugin_post.h" +#include "z64rumble.h" #include "objects/object_hakugin_obj/object_hakugin_obj.h" -#include "prevent_bss_reordering.h" #define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_20) #define THIS ((BgHakuginPost*)thisx) -void BgHakuginPost_Init(Actor* thisx, GlobalContext* globalCtx); -void BgHakuginPost_Destroy(Actor* thisx, GlobalContext* globalCtx); -void BgHakuginPost_Update(Actor* thisx, GlobalContext* globalCtx); +void BgHakuginPost_Init(Actor* thisx, PlayState* play); +void BgHakuginPost_Destroy(Actor* thisx, PlayState* play); +void BgHakuginPost_Update(Actor* thisx, PlayState* play); void func_80A9CA94(BgHakuginPost* this); -void func_80A9CAA8(BgHakuginPost* this, GlobalContext* globalCtx); +void func_80A9CAA8(BgHakuginPost* this, PlayState* play); void func_80A9CC84(BgHakuginPost* this); -void func_80A9CCA0(BgHakuginPost* this, GlobalContext* globalCtx); +void func_80A9CCA0(BgHakuginPost* this, PlayState* play); void func_80A9CD00(BgHakuginPost* this); -void func_80A9CD14(BgHakuginPost* this, GlobalContext* globalCtx); +void func_80A9CD14(BgHakuginPost* this, PlayState* play); void func_80A9CE00(BgHakuginPost* this); -void func_80A9CE1C(BgHakuginPost* this, GlobalContext* globalCtx); +void func_80A9CE1C(BgHakuginPost* this, PlayState* play); void func_80A9D0A0(BgHakuginPost* this); -void func_80A9D0B4(BgHakuginPost* this, GlobalContext* globalCtx); +void func_80A9D0B4(BgHakuginPost* this, PlayState* play); void func_80A9D1E0(BgHakuginPost* this, BgHakuginPostFunc unkFunc, f32 arg2, s16 arg3, s16 arg4); -void func_80A9D260(BgHakuginPost* this, GlobalContext* globalCtx); +void func_80A9D260(BgHakuginPost* this, PlayState* play); void func_80A9D2C4(BgHakuginPost* this, BgHakuginPostFunc unkFunc, f32 arg2, s16 arg3, s16 arg4); -void func_80A9D360(BgHakuginPost* this, GlobalContext* globalCtx); +void func_80A9D360(BgHakuginPost* this, PlayState* play); void func_80A9D3E4(BgHakuginPost* this); -void func_80A9D434(BgHakuginPost* this, GlobalContext* globalCtx); -void func_80A9D61C(Actor* thisx, GlobalContext* globalCtx); +void func_80A9D434(BgHakuginPost* this, PlayState* play); +void func_80A9D61C(Actor* thisx, PlayState* play); BgHakuginPostColliders D_80A9DDC0; BgHakuginPostUnkStruct D_80A9E028; @@ -96,7 +96,7 @@ void func_80A9ACF0(void) { bzero(&D_80A9DDC0, sizeof(BgHakuginPostColliders)); } -void func_80A9AD18(BgHakuginPost* this, GlobalContext* globalCtx, BgHakuginPostUnkStruct* unkStruct) { +void func_80A9AD18(BgHakuginPost* this, PlayState* play, BgHakuginPostUnkStruct* unkStruct) { s32 i; for (i = 0; i < unkStruct->count; i++) { @@ -105,8 +105,8 @@ void func_80A9AD18(BgHakuginPost* this, GlobalContext* globalCtx, BgHakuginPostU if ((unkStruct3->unk_04) && (D_80A9DDC0.count < 8)) { ColliderCylinder* collider = &D_80A9DDC0.colliders[D_80A9DDC0.count]; - Collider_InitCylinder(globalCtx, collider); - Collider_SetCylinder(globalCtx, collider, &this->dyna.actor, &sCylinderInit); + Collider_InitCylinder(play, collider); + Collider_SetCylinder(play, collider, &this->dyna.actor, &sCylinderInit); collider->dim.height = (s32)unkStruct3->unk_00 - 40; unkStruct->unk_0000[i].collider = collider; D_80A9DDC0.count++; @@ -114,14 +114,14 @@ void func_80A9AD18(BgHakuginPost* this, GlobalContext* globalCtx, BgHakuginPostU } } -void func_80A9AE3C(BgHakuginPost* this, GlobalContext* globalCtx) { +void func_80A9AE3C(BgHakuginPost* this, PlayState* play) { while (D_80A9DDC0.count != 0) { D_80A9DDC0.count--; - Collider_DestroyCylinder(globalCtx, &D_80A9DDC0.colliders[D_80A9DDC0.count]); + Collider_DestroyCylinder(play, &D_80A9DDC0.colliders[D_80A9DDC0.count]); } } -void func_80A9AEB8(BgHakuginPost* this, GlobalContext* globalCtx, BgHakuginPostUnkStruct* unkStruct) { +void func_80A9AEB8(BgHakuginPost* this, PlayState* play, BgHakuginPostUnkStruct* unkStruct) { s32 i; for (i = 0; i < unkStruct->count; i++) { @@ -131,12 +131,12 @@ void func_80A9AEB8(BgHakuginPost* this, GlobalContext* globalCtx, BgHakuginPostU collider->dim.pos.x = unkStruct->unk_0000[i].unk_14.x + this->dyna.actor.home.pos.x; collider->dim.pos.y = unkStruct->unk_0000[i].unk_14.y + this->unk_16C; collider->dim.pos.z = unkStruct->unk_0000[i].unk_14.z + this->dyna.actor.home.pos.z; - CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &collider->base); + CollisionCheck_SetAC(play, &play->colChkCtx, &collider->base); } } } -void func_80A9AFB4(BgHakuginPost* this, GlobalContext* globalCtx, BgHakuginPostUnkStruct* unkStruct) { +void func_80A9AFB4(BgHakuginPost* this, PlayState* play, BgHakuginPostUnkStruct* unkStruct) { s32 i; s32 j; @@ -156,7 +156,7 @@ void func_80A9AFB4(BgHakuginPost* this, GlobalContext* globalCtx, BgHakuginPostU Math_Vec3f_Copy(&unkStruct->unk_0000[i].unk_14, &this->dyna.actor.world.pos); unkStruct->unk_0000[i].unk_2E = BGHAKUGINPOST_GET_7F00(&this->dyna.actor); if (D_80A9D880[unkStruct->unk_0000[i].unk_00].unk_04) { - if (Flags_GetSwitch(globalCtx, unkStruct->unk_0000[i].unk_2E)) { + if (Flags_GetSwitch(play, unkStruct->unk_0000[i].unk_2E)) { unkStruct->unk_0000[i].unk_34 = 5; } else { unkStruct->unk_0000[i].unk_34 = 1; @@ -174,7 +174,7 @@ void func_80A9AFB4(BgHakuginPost* this, GlobalContext* globalCtx, BgHakuginPostU } } -void func_80A9B160(BgHakuginPostUnkStruct* unkStruct, GlobalContext* globalCtx) { +void func_80A9B160(BgHakuginPostUnkStruct* unkStruct, PlayState* play) { s32 i; for (i = 0; i < unkStruct->count; i++) { @@ -183,7 +183,7 @@ void func_80A9B160(BgHakuginPostUnkStruct* unkStruct, GlobalContext* globalCtx) unkStruct->unk_0000[i].unk_24 = 0.0f; unkStruct->unk_0000[i].unk_34 = 1; if (D_80A9D880[unkStruct->unk_0000[i].unk_00].unk_04 != 0) { - Flags_UnsetSwitch(globalCtx, unkStruct->unk_0000[i].unk_2E); + Flags_UnsetSwitch(play, unkStruct->unk_0000[i].unk_2E); } } } @@ -230,34 +230,34 @@ 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; matrix->mf[3][2] = arg0->z; } -void func_80A9B3BC(BgHakuginPost* this, GlobalContext* globalCtx) { +void func_80A9B3BC(BgHakuginPost* this, PlayState* play) { s32 pad; s32 sp28 = BGHAKUGINPOST_GET_7F00(&this->dyna.actor); s32 sp24 = BGHAKUGINPOST_GET_7F00(&this->dyna.actor) + 1; s32 sp20; s32 sp1C; - if (Flags_GetSwitch(globalCtx, sp28)) { + if (Flags_GetSwitch(play, sp28)) { sp20 = true; } else { sp20 = false; } - if (Flags_GetSwitch(globalCtx, sp24)) { + if (Flags_GetSwitch(play, sp24)) { sp1C = true; } else { sp1C = false; } if (!(sp20 | sp1C)) { - Flags_SetSwitch(globalCtx, sp28); + Flags_SetSwitch(play, sp28); this->unk_170 = true; } else { this->unk_170 = sp20; @@ -266,36 +266,36 @@ void func_80A9B3BC(BgHakuginPost* this, GlobalContext* globalCtx) { this->unk_174 = sp1C; } -void func_80A9B46C(BgHakuginPost* this, GlobalContext* globalCtx) { +void func_80A9B46C(BgHakuginPost* this, PlayState* play) { s32 pad; s32 sp30 = BGHAKUGINPOST_GET_7F00(&this->dyna.actor); s32 sp2C = BGHAKUGINPOST_GET_7F00(&this->dyna.actor) + 1; s32 sp28; s32 sp24; - if (Flags_GetSwitch(globalCtx, sp30)) { + if (Flags_GetSwitch(play, sp30)) { sp28 = true; } else { sp28 = false; } - if (Flags_GetSwitch(globalCtx, sp2C)) { + if (Flags_GetSwitch(play, sp2C)) { sp24 = true; } else { sp24 = false; } if (!this->unk_170 && (sp28 == 1)) { - Flags_UnsetSwitch(globalCtx, sp2C); + Flags_UnsetSwitch(play, sp2C); } else if (!this->unk_174 && (sp24 == 1)) { - Flags_UnsetSwitch(globalCtx, sp30); + Flags_UnsetSwitch(play, sp30); } this->unk_170 = sp28; this->unk_174 = sp24; } -void func_80A9B554(BgHakuginPost* this, GlobalContext* globalCtx, BgHakuginPostUnkStruct* unkStruct, +void func_80A9B554(BgHakuginPost* this, PlayState* play, BgHakuginPostUnkStruct* unkStruct, BgHakuginPostUnkStruct1* unkStruct1) { f32 spE4 = D_80A9D880[unkStruct1->unk_00].unk_00; s32 i; @@ -343,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; @@ -358,8 +358,8 @@ void func_80A9B554(BgHakuginPost* this, GlobalContext* globalCtx, BgHakuginPostU spA0.x = Math_SinS(val) * temp_f20 + spB8.x; spA0.y = (Rand_ZeroOne() * 1.2f - 0.1f) * spE4 + spB8.y; spA0.z = Math_CosS(val) * temp_f20 + spB8.z; - func_800B0E48(globalCtx, &spA0, &gZeroVec3f, &D_80A9D8EC, &D_80A9D8E4, &D_80A9D8E8, - (Rand_Next() >> 0x1A) + 0x82, (Rand_Next() >> 0x1A) + 0x6E); + func_800B0E48(play, &spA0, &gZeroVec3f, &D_80A9D8EC, &D_80A9D8E4, &D_80A9D8E8, + ((s32)Rand_Next() >> 0x1A) + 0x82, ((s32)Rand_Next() >> 0x1A) + 0x6E); } unkStruct1Temp = func_80A9B32C(unkStruct, unkStruct1); @@ -386,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; @@ -424,7 +424,7 @@ void func_80A9BC0C(BgHakuginPostUnkStruct* unkStruct) { } } -void func_80A9BD24(BgHakuginPost* this, GlobalContext* globalCtx, BgHakuginPostUnkStruct* unkStruct) { +void func_80A9BD24(BgHakuginPost* this, PlayState* play, BgHakuginPostUnkStruct* unkStruct) { s32 i; s32 j; @@ -490,7 +490,7 @@ void func_80A9BD24(BgHakuginPost* this, GlobalContext* globalCtx, BgHakuginPostU } } else if (unkStruct->unk_0000[i].unk_34 == 3) { if (Math3D_XZLengthSquared(unkStruct->unk_0000[i].unk_14.x, unkStruct->unk_0000[i].unk_14.z) > 278784.03f) { - func_80A9B554(this, globalCtx, unkStruct, &unkStruct->unk_0000[i]); + func_80A9B554(this, play, unkStruct, &unkStruct->unk_0000[i]); func_8019F128(NA_SE_EV_GLASSBROKEN_IMPACT); unkStruct->unk_0000[i].unk_34 = 4; unkStruct->unk_0000[i].unk_30 = 30; @@ -504,7 +504,7 @@ void func_80A9BD24(BgHakuginPost* this, GlobalContext* globalCtx, BgHakuginPostU } } -void func_80A9C058(BgHakuginPost* this, GlobalContext* globalCtx, BgHakuginPostUnkStruct* unkStruct) { +void func_80A9C058(BgHakuginPost* this, PlayState* play, BgHakuginPostUnkStruct* unkStruct) { s32 i; s32 pad; Vec3f sp44; @@ -519,8 +519,8 @@ void func_80A9C058(BgHakuginPost* this, GlobalContext* globalCtx, BgHakuginPostU sp44.x = this->dyna.actor.home.pos.x + unkStruct1->unk_14.x; sp44.y = this->unk_16C + unkStruct1->unk_14.y; sp44.z = this->dyna.actor.home.pos.z + unkStruct1->unk_14.z; - func_8013ECE0(Math3D_Vec3fDistSq(&sp44, &GET_PLAYER(globalCtx)->actor.world.pos), 255, 20, 150); - quake = Quake_Add(GET_ACTIVE_CAM(globalCtx), 3); + Rumble_Request(Math3D_Vec3fDistSq(&sp44, &GET_PLAYER(play)->actor.world.pos), 255, 20, 150); + quake = Quake_Add(GET_ACTIVE_CAM(play), 3); Quake_SetSpeed(quake, 20000); Quake_SetQuakeValues(quake, 7, 0, 0, 0); Quake_SetCountdown(quake, 12); @@ -534,22 +534,22 @@ void func_80A9C058(BgHakuginPost* this, GlobalContext* globalCtx, BgHakuginPostU } } -void func_80A9C18C(BgHakuginPost* this, GlobalContext* globalCtx) { +void func_80A9C18C(BgHakuginPost* this, PlayState* play) { s32 pad; - Player* player = GET_PLAYER(globalCtx); - Camera* activeCam = GET_ACTIVE_CAM(globalCtx); + Player* player = GET_PLAYER(play); + Camera* activeCam = GET_ACTIVE_CAM(play); s16 quake; - func_8013ECE0(Math3D_XZDistanceSquared(player->actor.world.pos.x, player->actor.world.pos.z, - this->dyna.actor.home.pos.x, this->dyna.actor.home.pos.z), - 255, 20, 150); + Rumble_Request(Math3D_XZDistanceSquared(player->actor.world.pos.x, player->actor.world.pos.z, + this->dyna.actor.home.pos.x, this->dyna.actor.home.pos.z), + 255, 20, 150); quake = Quake_Add(activeCam, 3); Quake_SetSpeed(quake, 17232); Quake_SetQuakeValues(quake, 6, 0, 0, 0); Quake_SetCountdown(quake, 20); } -void func_80A9C228(BgHakuginPost* this, GlobalContext* globalCtx, BgHakuginPostUnkStruct* unkStruct) { +void func_80A9C228(BgHakuginPost* this, PlayState* play, BgHakuginPostUnkStruct* unkStruct) { s32 val; BgHakuginPostUnkStruct1* spC8 = NULL; BgHakuginPostUnkStruct1* spC4; @@ -585,7 +585,7 @@ void func_80A9C228(BgHakuginPost* this, GlobalContext* globalCtx, BgHakuginPostU spA0.y = 0.2f; spA0.z = spAC.z * -0.08f; - func_800B0E48(globalCtx, &spB8, &spAC, &spA0, &D_80A9D8E4, &D_80A9D8E8, 0x50, + func_800B0E48(play, &spB8, &spAC, &spA0, &D_80A9D8E4, &D_80A9D8E8, 0x50, (s32)(Rand_ZeroOne() * 60.0f) + 110); } } @@ -610,14 +610,14 @@ void func_80A9C228(BgHakuginPost* this, GlobalContext* globalCtx, BgHakuginPostU spA0.y = 0.2f; spA0.z = spAC.z * -0.08f; - func_800B0E48(globalCtx, &spB8, &spAC, &spA0, &D_80A9D8E4, &D_80A9D8E8, 0xC8, + func_800B0E48(play, &spB8, &spAC, &spA0, &D_80A9D8E4, &D_80A9D8E8, 0xC8, (s32)(Rand_ZeroOne() * 70.0f) + 100); } } } } -void func_80A9C634(BgHakuginPost* this, GlobalContext* globalCtx) { +void func_80A9C634(BgHakuginPost* this, PlayState* play) { s32 i; Vec3f spB8; Vec3f spAC; @@ -645,12 +645,11 @@ void func_80A9C634(BgHakuginPost* this, GlobalContext* globalCtx) { spA0.x = spAC.x * -0.08f; spA0.y = 0.8f; spA0.z = spAC.z * -0.08f; - func_800B0DE0(globalCtx, &spB8, &spAC, &spA0, &D_80A9D8E4, &D_80A9D8E8, (s32)(Rand_ZeroOne() * 400.0f) + 2500, - -250); + func_800B0DE0(play, &spB8, &spAC, &spA0, &D_80A9D8E4, &D_80A9D8E8, (s32)(Rand_ZeroOne() * 400.0f) + 2500, -250); } } -void func_80A9C854(BgHakuginPost* this, GlobalContext* globalCtx) { +void func_80A9C854(BgHakuginPost* this, PlayState* play) { s32 pad; s32 sp38 = false; s32 pad2; @@ -659,13 +658,13 @@ void func_80A9C854(BgHakuginPost* this, GlobalContext* globalCtx) { s32 sp28; if (this->unk_174 != 0) { - if (Flags_GetSwitch(globalCtx, this->dyna.actor.home.rot.z & 0x7F)) { + if (Flags_GetSwitch(play, this->dyna.actor.home.rot.z & 0x7F)) { sp28 = true; for (i = 0; i < D_80A9E028.count; i++) { ColliderCylinder* collider = D_80A9E028.unk_0000[i].collider; - if ((collider != NULL) && Flags_GetSwitch(globalCtx, D_80A9E028.unk_0000[i].unk_2E)) { + if ((collider != NULL) && Flags_GetSwitch(play, D_80A9E028.unk_0000[i].unk_2E)) { sp28 = false; break; } @@ -678,13 +677,13 @@ void func_80A9C854(BgHakuginPost* this, GlobalContext* globalCtx) { } if (sp38) { - Flags_SetSwitch(globalCtx, this->dyna.actor.home.rot.x & 0x7F); + Flags_SetSwitch(play, this->dyna.actor.home.rot.x & 0x7F); } else { - Flags_UnsetSwitch(globalCtx, this->dyna.actor.home.rot.x & 0x7F); + Flags_UnsetSwitch(play, this->dyna.actor.home.rot.x & 0x7F); } } -void BgHakuginPost_Init(Actor* thisx, GlobalContext* globalCtx) { +void BgHakuginPost_Init(Actor* thisx, PlayState* play) { static s32 D_80A9D8FC = 1; BgHakuginPost* this = THIS; @@ -701,21 +700,21 @@ void BgHakuginPost_Init(Actor* thisx, GlobalContext* globalCtx) { this->dyna.actor.shape.rot.x = 0; this->dyna.actor.shape.rot.z = 0; DynaPolyActor_Init(&this->dyna, 1); - DynaPolyActor_LoadMesh(globalCtx, &this->dyna, &object_hakugin_obj_Colheader_00D3B0); - func_80A9B3BC(this, globalCtx); + DynaPolyActor_LoadMesh(play, &this->dyna, &object_hakugin_obj_Colheader_00D3B0); + func_80A9B3BC(this, play); func_80A9CA94(this); } else { - func_80A9AFB4(this, globalCtx, &D_80A9E028); + func_80A9AFB4(this, play, &D_80A9E028); Actor_MarkForDeath(&this->dyna.actor); } } -void BgHakuginPost_Destroy(Actor* thisx, GlobalContext* globalCtx) { +void BgHakuginPost_Destroy(Actor* thisx, PlayState* play) { BgHakuginPost* this = THIS; if (BGHAKUGINPOST_GET_7(&this->dyna.actor) == 7) { - DynaPoly_DeleteBgActor(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); - func_80A9AE3C(this, globalCtx); + DynaPoly_DeleteBgActor(play, &play->colCtx.dyna, this->dyna.bgId); + func_80A9AE3C(this, play); } } @@ -723,7 +722,7 @@ void func_80A9CA94(BgHakuginPost* this) { this->actionFunc = func_80A9CAA8; } -void func_80A9CAA8(BgHakuginPost* this, GlobalContext* globalCtx) { +void func_80A9CAA8(BgHakuginPost* this, PlayState* play) { s32 pad[2]; s32 i; @@ -763,7 +762,7 @@ void func_80A9CAA8(BgHakuginPost* this, GlobalContext* globalCtx) { } } - func_80A9AD18(this, globalCtx, &D_80A9E028); + func_80A9AD18(this, play, &D_80A9E028); this->dyna.actor.draw = func_80A9D61C; if (this->unk_170 != 0) { func_80A9CC84(this); @@ -777,7 +776,7 @@ void func_80A9CC84(BgHakuginPost* this) { this->unk_16C = this->unk_164; } -void func_80A9CCA0(BgHakuginPost* this, GlobalContext* globalCtx) { +void func_80A9CCA0(BgHakuginPost* this, PlayState* play) { if (this->unk_174 != 0) { func_80A9D1E0(this, func_80A9CD00, (this->unk_164 - this->dyna.actor.home.pos.y) + 100.0f, 60, this->dyna.actor.cutscene); @@ -788,14 +787,14 @@ void func_80A9CD00(BgHakuginPost* this) { this->actionFunc = func_80A9CD14; } -void func_80A9CD14(BgHakuginPost* this, GlobalContext* globalCtx) { +void func_80A9CD14(BgHakuginPost* this, PlayState* play) { f32 temp_f12 = Math_SinS((this->unk_16C - this->unk_164) * 0x8000 / (this->unk_168 - this->unk_164)) * 140.0f + 4.0f; temp_f12 = CLAMP_MAX(temp_f12, 40.0f); this->unk_16C += temp_f12; if (this->unk_168 <= this->unk_16C) { - func_80A9C18C(this, globalCtx); + func_80A9C18C(this, play); func_8019F128(NA_SE_EV_STONEDOOR_STOP); func_80A9CE00(this); } else { @@ -808,9 +807,9 @@ void func_80A9CE00(BgHakuginPost* this) { this->unk_16C = this->unk_168; } -void func_80A9CE1C(BgHakuginPost* this, GlobalContext* globalCtx) { +void func_80A9CE1C(BgHakuginPost* this, PlayState* play) { s32 pad; - Player* player = GET_PLAYER(globalCtx); + Player* player = GET_PLAYER(play); ColliderCylinder* collider; s32 yDiff; s32 i; @@ -838,7 +837,7 @@ void func_80A9CE1C(BgHakuginPost* this, GlobalContext* globalCtx) { D_80A9E028.unk_0000[i].unk_34 = 2; func_800B8E58(player, NA_SE_IT_HAMMER_HIT); func_8019F128(NA_SE_EV_SLIDE_DOOR_OPEN); - Flags_SetSwitch(globalCtx, D_80A9E028.unk_0000[i].unk_2E); + Flags_SetSwitch(play, D_80A9E028.unk_0000[i].unk_2E); this->unk_178 = 20; func_80A9D2C4(this, func_80A9CE00, D_80A9E028.unk_0000[i].unk_14.y + 50.0f, D_80A9E028.unk_0000[i].unk_2A, D_80A9E028.unk_0000[i].unk_2C); @@ -855,7 +854,7 @@ void func_80A9CE1C(BgHakuginPost* this, GlobalContext* globalCtx) { } if (this->unk_178 <= 0) { - func_80A9AEB8(this, globalCtx, &D_80A9E028); + func_80A9AEB8(this, play, &D_80A9E028); } } @@ -863,17 +862,17 @@ void func_80A9D0A0(BgHakuginPost* this) { this->actionFunc = func_80A9D0B4; } -void func_80A9D0B4(BgHakuginPost* this, GlobalContext* globalCtx) { +void func_80A9D0B4(BgHakuginPost* this, PlayState* play) { f32 sp24 = (this->unk_164 + this->unk_160) - func_80A9B2B8(&D_80A9E028); f32 temp_f14 = Math_SinS((this->unk_16C - sp24) * 0x8000 / (this->unk_168 - sp24)) * 140.0f + 4.0f; temp_f14 = CLAMP_MAX(temp_f14, 40.0f); this->unk_16C -= temp_f14; if (this->unk_16C <= sp24) { - func_80A9C634(this, globalCtx); - func_80A9B160(&D_80A9E028, globalCtx); + func_80A9C634(this, play); + func_80A9B160(&D_80A9E028, play); this->unk_16C = this->unk_164; - func_80A9C18C(this, globalCtx); + func_80A9C18C(this, play); func_8019F128(NA_SE_EV_STONEDOOR_STOP); func_80A9CC84(this); } else { @@ -894,7 +893,7 @@ void func_80A9D1E0(BgHakuginPost* this, BgHakuginPostFunc unkFunc, f32 arg2, s16 this->actionFunc = func_80A9D260; } -void func_80A9D260(BgHakuginPost* this, GlobalContext* globalCtx) { +void func_80A9D260(BgHakuginPost* this, PlayState* play) { if (ActorCutscene_GetCanPlayNext(this->unk_184)) { ActorCutscene_StartAndSetUnkLinkFields(this->unk_184, &this->dyna.actor); this->unkFunc(this); @@ -918,7 +917,7 @@ void func_80A9D2C4(BgHakuginPost* this, BgHakuginPostFunc unkFunc, f32 arg2, s16 this->actionFunc = func_80A9D360; } -void func_80A9D360(BgHakuginPost* this, GlobalContext* globalCtx) { +void func_80A9D360(BgHakuginPost* this, PlayState* play) { if (ActorCutscene_GetCanPlayNext(this->unk_184)) { ActorCutscene_StartAndSetUnkLinkFields(this->unk_184, &this->dyna.actor); if (this->unk_186 >= 0) { @@ -939,7 +938,7 @@ void func_80A9D3E4(BgHakuginPost* this) { this->actionFunc = func_80A9D434; } -void func_80A9D434(BgHakuginPost* this, GlobalContext* globalCtx) { +void func_80A9D434(BgHakuginPost* this, PlayState* play) { if (ActorCutscene_GetCanPlayNext(this->unk_186) != 0) { ActorCutscene_StartAndSetUnkLinkFields(this->unk_186, &this->dyna.actor); this->unkFunc(this); @@ -948,11 +947,11 @@ void func_80A9D434(BgHakuginPost* this, GlobalContext* globalCtx) { } } -void BgHakuginPost_Update(Actor* thisx, GlobalContext* globalCtx) { +void BgHakuginPost_Update(Actor* thisx, PlayState* play) { BgHakuginPost* this = THIS; f32 temp; - func_80A9B46C(this, globalCtx); + func_80A9B46C(this, play); if ((this->unk_180 >= 0) && ((this->actionFunc != func_80A9D260) || (this->actionFunc != func_80A9D360))) { this->unk_180--; if (this->unk_180 < 0) { @@ -976,10 +975,10 @@ void BgHakuginPost_Update(Actor* thisx, GlobalContext* globalCtx) { } func_80A9BC0C(&D_80A9E028); - this->actionFunc(this, globalCtx); - func_80A9BD24(this, globalCtx, &D_80A9E028); - func_80A9C058(this, globalCtx, &D_80A9E028); - func_80A9C228(this, globalCtx, &D_80A9E028); + this->actionFunc(this, play); + func_80A9BD24(this, play, &D_80A9E028); + func_80A9C058(this, play, &D_80A9E028); + func_80A9C228(this, play, &D_80A9E028); temp = func_80A9B2B8(&D_80A9E028); this->dyna.actor.scale.y = temp + this->unk_16C - this->dyna.actor.home.pos.y; this->dyna.actor.scale.y *= 0.0025f; @@ -987,10 +986,10 @@ void BgHakuginPost_Update(Actor* thisx, GlobalContext* globalCtx) { thisx->scale.y = 0.0001f; } - func_80A9C854(this, globalCtx); + func_80A9C854(this, play); } -void func_80A9D61C(Actor* thisx, GlobalContext* globalCtx) { +void func_80A9D61C(Actor* thisx, PlayState* play) { static Gfx* D_80A9D900[] = { object_hakugin_obj_DL_00C1A8, object_hakugin_obj_DL_00C568, NULL, NULL, object_hakugin_obj_DL_00CA38, object_hakugin_obj_DL_00CEC8, NULL, @@ -1007,11 +1006,11 @@ void func_80A9D61C(Actor* thisx, GlobalContext* globalCtx) { Vec3f sp68; s32 i; - OPEN_DISPS(globalCtx->state.gfxCtx); + OPEN_DISPS(play->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); + func_8012C28C(play->state.gfxCtx); + 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++) { @@ -1022,8 +1021,7 @@ void func_80A9D61C(Actor* thisx, GlobalContext* globalCtx) { sp68.z = unkStruct1->unk_14.z + this->dyna.actor.home.pos.z; func_80A9B384(&sp68); - gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), - G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_OPA_DISP++, D_80A9D900[unkStruct1->unk_00]); } } @@ -1032,16 +1030,16 @@ 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), + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_OPA_DISP++, D_80A9D91C[unkStruct2->unk_2D]); } } } - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->state.gfxCtx); } diff --git a/src/overlays/actors/ovl_Bg_Hakugin_Post/z_bg_hakugin_post.h b/src/overlays/actors/ovl_Bg_Hakugin_Post/z_bg_hakugin_post.h index 4a574bc24..8e702a006 100644 --- a/src/overlays/actors/ovl_Bg_Hakugin_Post/z_bg_hakugin_post.h +++ b/src/overlays/actors/ovl_Bg_Hakugin_Post/z_bg_hakugin_post.h @@ -5,7 +5,7 @@ struct BgHakuginPost; -typedef void (*BgHakuginPostActionFunc)(struct BgHakuginPost*, GlobalContext*); +typedef void (*BgHakuginPostActionFunc)(struct BgHakuginPost*, PlayState*); typedef void (*BgHakuginPostFunc)(struct BgHakuginPost*); #define BGHAKUGINPOST_GET_7(thisx) ((thisx)->params & 7) @@ -48,26 +48,26 @@ typedef struct { } BgHakuginPostUnkStruct; // size = 0x1928 typedef struct { - /* 0x0000 */ ColliderCylinder colliders[8]; - /* 0x0260 */ s32 count; + /* 0x000 */ ColliderCylinder colliders[8]; + /* 0x260 */ s32 count; } BgHakuginPostColliders; // size = 0x264 typedef struct BgHakuginPost { - /* 0x0000 */ DynaPolyActor dyna; - /* 0x015C */ BgHakuginPostActionFunc actionFunc; - /* 0x0160 */ f32 unk_160; - /* 0x0164 */ f32 unk_164; - /* 0x0168 */ f32 unk_168; - /* 0x016C */ f32 unk_16C; - /* 0x0170 */ s32 unk_170; - /* 0x0174 */ s32 unk_174; - /* 0x0178 */ s8 unk_178; - /* 0x0179 */ s8 unk_179; - /* 0x017C */ BgHakuginPostFunc unkFunc; - /* 0x0180 */ s16 unk_180; - /* 0x0182 */ s16 unk_182; - /* 0x0184 */ s16 unk_184; - /* 0x0186 */ s16 unk_186; + /* 0x000 */ DynaPolyActor dyna; + /* 0x15C */ BgHakuginPostActionFunc actionFunc; + /* 0x160 */ f32 unk_160; + /* 0x164 */ f32 unk_164; + /* 0x168 */ f32 unk_168; + /* 0x16C */ f32 unk_16C; + /* 0x170 */ s32 unk_170; + /* 0x174 */ s32 unk_174; + /* 0x178 */ s8 unk_178; + /* 0x179 */ s8 unk_179; + /* 0x17C */ BgHakuginPostFunc unkFunc; + /* 0x180 */ s16 unk_180; + /* 0x182 */ s16 unk_182; + /* 0x184 */ s16 unk_184; + /* 0x186 */ s16 unk_186; } BgHakuginPost; // size = 0x188 extern const ActorInit Bg_Hakugin_Post_InitVars; diff --git a/src/overlays/actors/ovl_Bg_Hakugin_Switch/z_bg_hakugin_switch.c b/src/overlays/actors/ovl_Bg_Hakugin_Switch/z_bg_hakugin_switch.c index f5e035be7..0498dc2ee 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,35 +5,36 @@ */ #include "z_bg_hakugin_switch.h" +#include "z64rumble.h" #include "objects/object_goronswitch/object_goronswitch.h" #define FLAGS (ACTOR_FLAG_10) #define THIS ((BgHakuginSwitch*)thisx) -void BgHakuginSwitch_Init(Actor* thisx, GlobalContext* globalCtx); -void BgHakuginSwitch_Destroy(Actor* thisx, GlobalContext* globalCtx); -void BgHakuginSwitch_Update(Actor* thisx, GlobalContext* globalCtx); -void BgHakuginSwitch_Draw(Actor* thisx, GlobalContext* globalCtx); +void BgHakuginSwitch_Init(Actor* thisx, PlayState* play); +void BgHakuginSwitch_Destroy(Actor* thisx, PlayState* play); +void BgHakuginSwitch_Update(Actor* thisx, PlayState* play); +void BgHakuginSwitch_Draw(Actor* thisx, PlayState* play); -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); +void func_80B15A68(BgHakuginSwitch* this, PlayState* play); +void func_80B15B1C(BgHakuginSwitch* this, PlayState* play); +void func_80B15B74(BgHakuginSwitch* this, PlayState* play); +void func_80B15E0C(BgHakuginSwitch* this, PlayState* play); +void func_80B15E78(BgHakuginSwitch* this, PlayState* play); +void func_80B15F3C(BgHakuginSwitch* this, PlayState* play); +void func_80B15F88(BgHakuginSwitch* this, PlayState* play); +void func_80B1606C(BgHakuginSwitch* this, PlayState* play); +void func_80B160DC(BgHakuginSwitch* this, PlayState* play); +void func_80B161A0(BgHakuginSwitch* this, PlayState* play); +void func_80B16244(BgHakuginSwitch* this, PlayState* play); +void func_80B162AC(BgHakuginSwitch* this, PlayState* play); +void func_80B163C4(BgHakuginSwitch* this, PlayState* play); +void func_80B16400(BgHakuginSwitch* this, PlayState* play); +void func_80B16494(BgHakuginSwitch* this, PlayState* play); +void func_80B16520(BgHakuginSwitch* this, PlayState* play); +void func_80B165A0(BgHakuginSwitch* this, PlayState* play); +void func_80B165E0(BgHakuginSwitch* this, PlayState* play); u32 D_80B16AF0; @@ -111,7 +112,7 @@ void func_80B157C4(BgHakuginSwitch* this, u16 arg1) { } } -void BgHakuginSwitch_Init(Actor* thisx, GlobalContext* globalCtx) { +void BgHakuginSwitch_Init(Actor* thisx, PlayState* play) { s32 pad; BgHakuginSwitch* this = THIS; s32 sp34 = BGHAKUGINSWITCH_GET_7(&this->dyna.actor); @@ -119,17 +120,17 @@ void BgHakuginSwitch_Init(Actor* thisx, GlobalContext* globalCtx) { s32 pad2; s32 sp28; - if (Flags_GetSwitch(globalCtx, BGHAKUGINSWITCH_GET_SWITCHFLAG(&this->dyna.actor))) { + if (Flags_GetSwitch(play, BGHAKUGINSWITCH_GET_SWITCHFLAG(&this->dyna.actor))) { sp30 = true; } else { sp30 = false; } DynaPolyActor_Init(&this->dyna, 1); - DynaPolyActor_LoadMesh(globalCtx, &this->dyna, &object_goronswitch_Colheader_0005C8); + DynaPolyActor_LoadMesh(play, &this->dyna, &object_goronswitch_Colheader_0005C8); - Collider_InitCylinder(globalCtx, &this->collider); - Collider_SetCylinder(globalCtx, &this->collider, &this->dyna.actor, &sCylinderInit); + Collider_InitCylinder(play, &this->collider); + Collider_SetCylinder(play, &this->collider, &this->dyna.actor, &sCylinderInit); this->unk_1B2 = 15; if (!BGHAKUGINSWITCH_GET_10(&this->dyna.actor)) { @@ -151,9 +152,9 @@ void BgHakuginSwitch_Init(Actor* thisx, GlobalContext* globalCtx) { } if (sp30) { - func_80B16494(this, globalCtx); + func_80B16494(this, play); } else { - func_80B16244(this, globalCtx); + func_80B16244(this, play); } } else { if (D_80B1688C[sp34].unk_14 & 4) { @@ -169,20 +170,20 @@ void BgHakuginSwitch_Init(Actor* thisx, GlobalContext* globalCtx) { this->unk_1BA = ActorCutscene_GetAdditionalCutscene(this->unk_1B8); if (sp30 == sp28) { - func_80B15F3C(this, globalCtx); + func_80B15F3C(this, play); } else { - func_80B15B1C(this, globalCtx); + func_80B15B1C(this, play); } } this->unk_1C8 = 1.0f / this->dyna.actor.scale.y; } -void BgHakuginSwitch_Destroy(Actor* thisx, GlobalContext* globalCtx) { +void BgHakuginSwitch_Destroy(Actor* thisx, PlayState* play) { BgHakuginSwitch* this = THIS; - DynaPoly_DeleteBgActor(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); - Collider_DestroyCylinder(globalCtx, &this->collider); + DynaPoly_DeleteBgActor(play, &play->colCtx.dyna, this->dyna.bgId); + Collider_DestroyCylinder(play, &this->collider); } void func_80B15A4C(BgHakuginSwitch* this, BgHakuginSwitchUnkFunc func, s32 arg2) { @@ -191,7 +192,7 @@ void func_80B15A4C(BgHakuginSwitch* this, BgHakuginSwitchUnkFunc func, s32 arg2) this->actionFunc = func_80B15A68; } -void func_80B15A68(BgHakuginSwitch* this, GlobalContext* globalCtx) { +void func_80B15A68(BgHakuginSwitch* this, PlayState* play) { s32 pad; BgHakuginSwitchStruct* s = &D_80B1688C[BGHAKUGINSWITCH_GET_7(&this->dyna.actor)]; s32 sp18 = !(s->unk_14 & 0x40); @@ -201,13 +202,13 @@ void func_80B15A68(BgHakuginSwitch* this, GlobalContext* globalCtx) { ActorCutscene_StartAndSetUnkLinkFields(this->unk_1BC, &this->dyna.actor); this->unk_1BF = 40; } - this->unk_1B4(this, globalCtx); + this->unk_1B4(this, play); } else if (sp18) { ActorCutscene_SetIntentToPlay(this->unk_1BC); } } -void func_80B15B1C(BgHakuginSwitch* this, GlobalContext* globalCtx) { +void func_80B15B1C(BgHakuginSwitch* this, PlayState* play) { BgHakuginSwitchStruct* s = &D_80B1688C[BGHAKUGINSWITCH_GET_7(&this->dyna.actor)]; this->dyna.actor.world.pos.y = s->unk_0 + this->dyna.actor.home.pos.y; @@ -216,7 +217,7 @@ void func_80B15B1C(BgHakuginSwitch* this, GlobalContext* globalCtx) { this->actionFunc = func_80B15B74; } -void func_80B15B74(BgHakuginSwitch* this, GlobalContext* globalCtx) { +void func_80B15B74(BgHakuginSwitch* this, PlayState* play) { s32 pad; BgHakuginSwitchStruct* sp38 = &D_80B1688C[BGHAKUGINSWITCH_GET_7(&this->dyna.actor)]; s32 sp34 = (this->collider.base.acFlags & AC_HIT) != 0; @@ -226,7 +227,7 @@ void func_80B15B74(BgHakuginSwitch* this, GlobalContext* globalCtx) { s32 sp24; s32 sp20; - if (Flags_GetSwitch(globalCtx, BGHAKUGINSWITCH_GET_SWITCHFLAG(&this->dyna.actor))) { + if (Flags_GetSwitch(play, BGHAKUGINSWITCH_GET_SWITCHFLAG(&this->dyna.actor))) { sp2C = 1; } else { sp2C = 0; @@ -262,7 +263,7 @@ void func_80B15B74(BgHakuginSwitch* this, GlobalContext* globalCtx) { if (sp2C == sp28) { if ((sp38->unk_14 & 0xFF) & 0x10) { - if (D_80B16AF0 < globalCtx->gameplayFrames) { + if (D_80B16AF0 < play->gameplayFrames) { sp24 = true; } } else { @@ -272,25 +273,25 @@ void func_80B15B74(BgHakuginSwitch* this, GlobalContext* globalCtx) { if (sp24) { if (sp20 == 1) { - Flags_SetSwitch(globalCtx, BGHAKUGINSWITCH_GET_SWITCHFLAG(&this->dyna.actor)); + Flags_SetSwitch(play, BGHAKUGINSWITCH_GET_SWITCHFLAG(&this->dyna.actor)); } else if (sp20 == 0) { - Flags_UnsetSwitch(globalCtx, BGHAKUGINSWITCH_GET_SWITCHFLAG(&this->dyna.actor)); + Flags_UnsetSwitch(play, BGHAKUGINSWITCH_GET_SWITCHFLAG(&this->dyna.actor)); } - D_80B16AF0 = globalCtx->gameplayFrames; + D_80B16AF0 = play->gameplayFrames; if (sp38->unk_14 & 0x10) { func_80B15A4C(this, func_80B15E0C, this->unk_1B8); } else { - func_80B15E0C(this, globalCtx); + func_80B15E0C(this, play); } } else if (!(sp38->unk_14 & 1)) { Collider_UpdateCylinder(&this->dyna.actor, &this->collider); - CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + CollisionCheck_SetAC(play, &play->colChkCtx, &this->collider.base); } } -void func_80B15E0C(BgHakuginSwitch* this, GlobalContext* globalCtx) { +void func_80B15E0C(BgHakuginSwitch* this, PlayState* play) { BgHakuginSwitchStruct* s = &D_80B1688C[BGHAKUGINSWITCH_GET_7(&this->dyna.actor)]; if ((s->unk_14 & 0x80)) { @@ -300,21 +301,21 @@ void func_80B15E0C(BgHakuginSwitch* this, GlobalContext* globalCtx) { this->actionFunc = func_80B15E78; } -void func_80B15E78(BgHakuginSwitch* this, GlobalContext* globalCtx) { +void func_80B15E78(BgHakuginSwitch* this, PlayState* play) { 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); + Rumble_Request(this->dyna.actor.xyzDistToPlayerSq, 120, 20, 10); } - func_80B15F3C(this, globalCtx); + func_80B15F3C(this, play); } else if (!(sp20->unk_14 & 0x80)) { func_80B157C4(this, NA_SE_EV_STONE_STATUE_OPEN - SFX_FLAG); } } -void func_80B15F3C(BgHakuginSwitch* this, GlobalContext* globalCtx) { +void func_80B15F3C(BgHakuginSwitch* this, PlayState* play) { 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; @@ -322,12 +323,12 @@ void func_80B15F3C(BgHakuginSwitch* this, GlobalContext* globalCtx) { this->actionFunc = func_80B15F88; } -void func_80B15F88(BgHakuginSwitch* this, GlobalContext* globalCtx) { +void func_80B15F88(BgHakuginSwitch* this, PlayState* play) { 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))) { + if (Flags_GetSwitch(play, BGHAKUGINSWITCH_GET_SWITCHFLAG(&this->dyna.actor))) { phi_a0 = true; } else { phi_a0 = false; @@ -341,16 +342,16 @@ void func_80B15F88(BgHakuginSwitch* this, GlobalContext* globalCtx) { if (phi_a0 != phi_v1) { if ((sp18->unk_14 & 0xFF) & 0x20) { - if (D_80B16AF0 < globalCtx->gameplayFrames) { + if (D_80B16AF0 < play->gameplayFrames) { func_80B15A4C(this, func_80B1606C, this->unk_1BA); } } else { - func_80B1606C(this, globalCtx); + func_80B1606C(this, play); } } } -void func_80B1606C(BgHakuginSwitch* this, GlobalContext* globalCtx) { +void func_80B1606C(BgHakuginSwitch* this, PlayState* play) { BgHakuginSwitchStruct* s = &D_80B1688C[BGHAKUGINSWITCH_GET_7(&this->dyna.actor)]; if (s->unk_14 & 0x80) { @@ -360,12 +361,12 @@ void func_80B1606C(BgHakuginSwitch* this, GlobalContext* globalCtx) { this->actionFunc = func_80B160DC; } -void func_80B160DC(BgHakuginSwitch* this, GlobalContext* globalCtx) { +void func_80B160DC(BgHakuginSwitch* this, PlayState* play) { 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); + func_80B15B1C(this, play); } else if (!(sp18->unk_14 & 0x80)) { func_80B157C4(this, NA_SE_EV_PILLAR_UP_FAST - SFX_FLAG); } @@ -378,32 +379,32 @@ void func_80B16180(BgHakuginSwitch* this, BgHakuginSwitchUnkFunc func, s32 arg2, this->actionFunc = func_80B161A0; } -void func_80B161A0(BgHakuginSwitch* this, GlobalContext* globalCtx) { +void func_80B161A0(BgHakuginSwitch* this, PlayState* play) { 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)); + Flags_SetSwitch(play, BGHAKUGINSWITCH_GET_SWITCHFLAG(&this->dyna.actor)); } else { - Flags_UnsetSwitch(globalCtx, BGHAKUGINSWITCH_GET_SWITCHFLAG(&this->dyna.actor)); + Flags_UnsetSwitch(play, BGHAKUGINSWITCH_GET_SWITCHFLAG(&this->dyna.actor)); } this->unk_1BF = 50; - this->unk_1B4(this, globalCtx); + this->unk_1B4(this, play); } else { ActorCutscene_SetIntentToPlay(this->unk_1BC); } } -void func_80B16244(BgHakuginSwitch* this, GlobalContext* globalCtx) { +void func_80B16244(BgHakuginSwitch* this, PlayState* play) { 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); + func_800BC154(play, &play->actorCtx, &this->dyna.actor, 0); } this->actionFunc = func_80B162AC; } -void func_80B162AC(BgHakuginSwitch* this, GlobalContext* globalCtx) { +void func_80B162AC(BgHakuginSwitch* this, PlayState* play) { s32 sp34 = (this->collider.base.acFlags & AC_HIT) != 0; s32 sp30 = BGHAKUGINSWITCH_GET_7(&this->dyna.actor); s32 pad; @@ -419,7 +420,7 @@ void func_80B162AC(BgHakuginSwitch* this, GlobalContext* globalCtx) { } if (sp30 == 1) { - if (Flags_GetSwitch(globalCtx, BGHAKUGINSWITCH_GET_SWITCHFLAG(&this->dyna.actor))) { + if (Flags_GetSwitch(play, BGHAKUGINSWITCH_GET_SWITCHFLAG(&this->dyna.actor))) { sp24 = true; } } @@ -428,63 +429,63 @@ void func_80B162AC(BgHakuginSwitch* this, GlobalContext* globalCtx) { if (sp28) { func_80B16180(this, func_80B163C4, 1, this->unk_1B8); } else { - func_80B163C4(this, globalCtx); + func_80B163C4(this, play); } } else { Collider_UpdateCylinder(&this->dyna.actor, &this->collider); - CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + CollisionCheck_SetAC(play, &play->colChkCtx, &this->collider.base); } } -void func_80B163C4(BgHakuginSwitch* this, GlobalContext* globalCtx) { +void func_80B163C4(BgHakuginSwitch* this, PlayState* play) { func_80B15790(this, NA_SE_EV_STONE_SWITCH_ON); this->unk_1C0 = 0; this->actionFunc = func_80B16400; } -void func_80B16400(BgHakuginSwitch* this, GlobalContext* globalCtx) { +void func_80B16400(BgHakuginSwitch* this, PlayState* play) { if (Math_StepToF(&this->dyna.actor.world.pos.y, (this->dyna.actor.home.pos.y + 2.0f) - (1800.0f * this->dyna.actor.scale.y), 10.0f)) { if (DynaPolyActor_IsInRidingMovingState(&this->dyna)) { - func_8013ECE0(this->dyna.actor.xyzDistToPlayerSq, 120, 20, 10); + Rumble_Request(this->dyna.actor.xyzDistToPlayerSq, 120, 20, 10); } - func_80B16494(this, globalCtx); + func_80B16494(this, play); } } -void func_80B16494(BgHakuginSwitch* this, GlobalContext* globalCtx) { +void func_80B16494(BgHakuginSwitch* this, PlayState* play) { 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); + func_800BC154(play, &play->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))) { +void func_80B16520(BgHakuginSwitch* this, PlayState* play) { + if (!Flags_GetSwitch(play, BGHAKUGINSWITCH_GET_SWITCHFLAG(&this->dyna.actor))) { if (BGHAKUGINSWITCH_GET_7(&this->dyna.actor) == BGHAKUGINSWITCH_GET_7_1) { func_80B16180(this, func_80B165A0, 0, this->unk_1BA); } else { - func_80B165A0(this, globalCtx); + func_80B165A0(this, play); } } } -void func_80B165A0(BgHakuginSwitch* this, GlobalContext* globalCtx) { +void func_80B165A0(BgHakuginSwitch* this, PlayState* play) { func_80B15790(this, NA_SE_EV_STONE_SWITCH_OFF); this->unk_1C0 = 1; this->actionFunc = func_80B165E0; } -void func_80B165E0(BgHakuginSwitch* this, GlobalContext* globalCtx) { +void func_80B165E0(BgHakuginSwitch* this, PlayState* play) { if (Math_StepToF(&this->dyna.actor.world.pos.y, this->dyna.actor.home.pos.y, 6.0f)) { - func_80B16244(this, globalCtx); + func_80B16244(this, play); } } -void BgHakuginSwitch_Update(Actor* thisx, GlobalContext* globalCtx) { +void BgHakuginSwitch_Update(Actor* thisx, PlayState* play) { s32 pad; BgHakuginSwitch* this = THIS; f32 sp24; @@ -502,7 +503,7 @@ void BgHakuginSwitch_Update(Actor* thisx, GlobalContext* globalCtx) { } } - this->actionFunc(this, globalCtx); + this->actionFunc(this, play); sp24 = this->dyna.actor.shape.yOffset * this->dyna.actor.scale.y; @@ -530,8 +531,8 @@ void BgHakuginSwitch_Update(Actor* thisx, GlobalContext* globalCtx) { } } -void BgHakuginSwitch_Draw(Actor* thisx, GlobalContext* globalCtx) { +void BgHakuginSwitch_Draw(Actor* thisx, PlayState* play) { BgHakuginSwitch* this = THIS; - Gfx_DrawDListOpa(globalCtx, this->unk_1A8); + Gfx_DrawDListOpa(play, 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 cc1363965..74757f836 100644 --- a/src/overlays/actors/ovl_Bg_Hakugin_Switch/z_bg_hakugin_switch.h +++ b/src/overlays/actors/ovl_Bg_Hakugin_Switch/z_bg_hakugin_switch.h @@ -5,8 +5,8 @@ struct BgHakuginSwitch; -typedef void (*BgHakuginSwitchActionFunc)(struct BgHakuginSwitch*, GlobalContext*); -typedef void (*BgHakuginSwitchUnkFunc)(struct BgHakuginSwitch*, GlobalContext*); +typedef void (*BgHakuginSwitchActionFunc)(struct BgHakuginSwitch*, PlayState*); +typedef void (*BgHakuginSwitchUnkFunc)(struct BgHakuginSwitch*, PlayState*); #define BGHAKUGINSWITCH_GET_7(thisx) ((thisx)->params & 7) #define BGHAKUGINSWITCH_GET_10(thisx) (((thisx)->params >> 4) & 1) @@ -15,21 +15,21 @@ typedef void (*BgHakuginSwitchUnkFunc)(struct BgHakuginSwitch*, GlobalContext*); #define BGHAKUGINSWITCH_GET_7_1 1 typedef struct BgHakuginSwitch { - /* 0x0000 */ DynaPolyActor dyna; - /* 0x015C */ ColliderCylinder collider; - /* 0x01A8 */ Gfx* unk_1A8; - /* 0x01AC */ BgHakuginSwitchActionFunc actionFunc; - /* 0x01B0 */ s16 unk_1B0; - /* 0x01B2 */ s8 unk_1B2; - /* 0x01B4 */ BgHakuginSwitchUnkFunc unk_1B4; - /* 0x01B8 */ s16 unk_1B8; - /* 0x01BA */ s16 unk_1BA; - /* 0x01BC */ s16 unk_1BC; - /* 0x01BE */ s8 unk_1BE; - /* 0x01BF */ s8 unk_1BF; - /* 0x01C0 */ s8 unk_1C0; - /* 0x01C4 */ f32 unk_1C4; - /* 0x01C8 */ f32 unk_1C8; + /* 0x000 */ DynaPolyActor dyna; + /* 0x15C */ ColliderCylinder collider; + /* 0x1A8 */ Gfx* unk_1A8; + /* 0x1AC */ BgHakuginSwitchActionFunc actionFunc; + /* 0x1B0 */ s16 unk_1B0; + /* 0x1B2 */ s8 unk_1B2; + /* 0x1B4 */ BgHakuginSwitchUnkFunc unk_1B4; + /* 0x1B8 */ s16 unk_1B8; + /* 0x1BA */ s16 unk_1BA; + /* 0x1BC */ s16 unk_1BC; + /* 0x1BE */ s8 unk_1BE; + /* 0x1BF */ s8 unk_1BF; + /* 0x1C0 */ s8 unk_1C0; + /* 0x1C4 */ f32 unk_1C4; + /* 0x1C8 */ f32 unk_1C8; } BgHakuginSwitch; // size = 0x1CC extern const ActorInit Bg_Hakugin_Switch_InitVars; diff --git a/src/overlays/actors/ovl_Bg_Icefloe/z_bg_icefloe.c b/src/overlays/actors/ovl_Bg_Icefloe/z_bg_icefloe.c index e3270fb6e..e64cbef70 100644 --- a/src/overlays/actors/ovl_Bg_Icefloe/z_bg_icefloe.c +++ b/src/overlays/actors/ovl_Bg_Icefloe/z_bg_icefloe.c @@ -5,17 +5,24 @@ */ #include "z_bg_icefloe.h" +#include "objects/object_icefloe/object_icefloe.h" #define FLAGS (ACTOR_FLAG_10) #define THIS ((BgIcefloe*)thisx) -void BgIcefloe_Init(Actor* thisx, GlobalContext* globalCtx); -void BgIcefloe_Destroy(Actor* thisx, GlobalContext* globalCtx); -void BgIcefloe_Update(Actor* thisx, GlobalContext* globalCtx); -void BgIcefloe_Draw(Actor* thisx, GlobalContext* globalCtx); +void BgIcefloe_Init(Actor* thisx, PlayState* play); +void BgIcefloe_Destroy(Actor* thisx, PlayState* play); +void BgIcefloe_Update(Actor* thisx, PlayState* play); +void BgIcefloe_Draw(Actor* thisx, PlayState* play); + +void func_80AC4A80(BgIcefloe* this, PlayState* play); +void BgIcefloe_Grow(BgIcefloe* this, PlayState* play); +void func_80AC4C18(BgIcefloe* this); +void func_80AC4D2C(BgIcefloe* this, PlayState* play); +void func_80AC4C34(BgIcefloe* this, PlayState* play); +void func_80AC4CF0(BgIcefloe* this); -#if 0 const ActorInit Bg_Icefloe_InitVars = { ACTOR_BG_ICEFLOE, ACTORCAT_BG, @@ -27,35 +34,144 @@ const ActorInit Bg_Icefloe_InitVars = { (ActorFunc)BgIcefloe_Update, (ActorFunc)BgIcefloe_Draw, }; +static BgIcefloe* sSpawnedInstances[] = { NULL, NULL, NULL }; -// static InitChainEntry sInitChain[] = { -static InitChainEntry D_80AC4F3C[] = { +static InitChainEntry sInitChain[] = { ICHAIN_VEC3F_DIV1000(scale, 0, ICHAIN_STOP), }; -#endif +static s32 numberSpawned; -extern InitChainEntry D_80AC4F3C[]; +void BgIcefloe_Init(Actor* thisx, PlayState* play) { + BgIcefloe* this = THIS; -extern UNK_TYPE D_060001E0; -extern UNK_TYPE D_06000C90; + Actor_ProcessInitChain(&this->dyna.actor, sInitChain); + DynaPolyActor_Init(&this->dyna, 0); + DynaPolyActor_LoadMesh(play, &this->dyna, &gIcefloePlatformCol); + if (numberSpawned >= ARRAY_COUNT(sSpawnedInstances)) { + s32 i; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Icefloe/BgIcefloe_Init.s") + if ((sSpawnedInstances[0] != NULL) && (sSpawnedInstances[0]->dyna.actor.update != NULL) && + (sSpawnedInstances[0]->actionFunc != func_80AC4D2C)) { + func_80AC4CF0(sSpawnedInstances[0]); + } + for (i = 0; i < ARRAY_COUNT(sSpawnedInstances) - 1; i++) { + sSpawnedInstances[i] = sSpawnedInstances[i + 1]; + } + sSpawnedInstances[ARRAY_COUNT(sSpawnedInstances) - 1] = this; + } else { + sSpawnedInstances[numberSpawned] = this; + } + numberSpawned++; + this->dyna.actor.world.pos.y = this->dyna.actor.home.pos.y + 10.0f; + func_80AC4A80(this, play); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Icefloe/BgIcefloe_Destroy.s") +void BgIcefloe_Destroy(Actor* thisx, PlayState* play) { + BgIcefloe* this = THIS; + s32 i; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Icefloe/func_80AC4A80.s") + DynaPoly_DeleteBgActor(play, &play->colCtx.dyna, this->dyna.bgId); + numberSpawned--; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Icefloe/func_80AC4AE8.s") + for (i = 0; i < 3; i++) { + if (sSpawnedInstances[i] == this) { + sSpawnedInstances[i] = NULL; + break; + } + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Icefloe/func_80AC4C18.s") +void func_80AC4A80(BgIcefloe* this, PlayState* play) { + this->timer = 20; + SkinMatrix_Vec3fMtxFMultXYZW(&play->viewProjectionMtxF, &this->dyna.actor.world.pos, &this->dyna.actor.projectedPos, + &this->dyna.actor.projectedW); + Actor_PlaySfxAtPos(&this->dyna.actor, NA_SE_EV_ICE_STAND_APPEAR); + this->actionFunc = BgIcefloe_Grow; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Icefloe/func_80AC4C34.s") +static Vec3f sIceBlockAccel = { 0.0f, -0.5f, 0.0f }; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Icefloe/func_80AC4CF0.s") +void BgIcefloe_Grow(BgIcefloe* this, PlayState* play) { + Vec3f velocity; + Vec3f position; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Icefloe/func_80AC4D2C.s") + velocity.x = randPlusMinusPoint5Scaled(6.0f); + velocity.z = randPlusMinusPoint5Scaled(6.0f); + velocity.y = Rand_ZeroFloat(4.0f) + 4.0f; + this->dyna.actor.scale.x += (0.65f * 0.01f); + this->dyna.actor.scale.z += (0.65f * 0.01f); + this->dyna.actor.scale.y += (0.65f * 0.01f); + position.x = this->dyna.actor.world.pos.x + (velocity.x * this->dyna.actor.scale.x * 75.0f); + position.z = this->dyna.actor.world.pos.z + (velocity.z * this->dyna.actor.scale.z * 75.0f); + position.y = this->dyna.actor.world.pos.y + (300.0f * this->dyna.actor.scale.y); + EffectSsIceBlock_Spawn(play, &position, &velocity, &sIceBlockAccel, Rand_S16Offset(10, 10)); + this->timer--; + if (this->timer == 0) { + func_80AC4C18(this); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Icefloe/BgIcefloe_Update.s") +void func_80AC4C18(BgIcefloe* this) { + this->timer = this->dyna.actor.params; + this->actionFunc = func_80AC4C34; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Icefloe/BgIcefloe_Draw.s") +void func_80AC4C34(BgIcefloe* this, PlayState* play) { + WaterBox* water; + + this->timer--; + if (this->timer == 0 || + !WaterBox_GetSurface1_2(play, &play->colCtx, this->dyna.actor.world.pos.x, this->dyna.actor.world.pos.z, + &this->dyna.actor.home.pos.y, &water)) { + func_80AC4CF0(this); + } else { + this->dyna.actor.world.pos.y = + (sin_rad(this->timer * (M_PI / 30.0f)) * 3.0f) + (this->dyna.actor.home.pos.y + 10.0f); + } +} + +void func_80AC4CF0(BgIcefloe* this) { + this->timer = 50; + Actor_PlaySfxAtPos(&this->dyna.actor, NA_SE_EV_ICE_MELT_LEVEL); + this->actionFunc = func_80AC4D2C; +} + +void func_80AC4D2C(BgIcefloe* this, PlayState* play) { + this->timer--; + if ((this->timer >= 38) && !(this->timer % 2)) { + Vec3f velocity; + Vec3f position; + + velocity.y = (this->timer - 38) * (1 / 12.0f); + velocity.x = randPlusMinusPoint5Scaled(1.5f) * velocity.y; + velocity.z = randPlusMinusPoint5Scaled(1.5f) * velocity.y; + velocity.y += 0.8f; + position.x = this->dyna.actor.world.pos.x + (2.0f * velocity.x); + position.z = this->dyna.actor.world.pos.z + (2.0f * velocity.z); + position.y = this->dyna.actor.world.pos.y + 3.0f; + EffectSsIceSmoke_Spawn(play, &position, &velocity, &gZeroVec3f, 200); + } + if (this->timer < 25) { + this->dyna.actor.scale.x -= 0.0052f; + this->dyna.actor.scale.z -= 0.0052f; + } + this->dyna.actor.scale.y -= 0.0026f; + if (this->dyna.actor.scale.y <= 0.0f) { + Actor_MarkForDeath(&this->dyna.actor); + } +} + +void BgIcefloe_Update(Actor* thisx, PlayState* play) { + BgIcefloe* this = THIS; + + if (!Play_InCsMode(play)) { + this->actionFunc(this, play); + } +} + +void BgIcefloe_Draw(Actor* thisx, PlayState* play) { + BgIcefloe* this = THIS; + + Gfx_DrawDListOpa(play, gIcefloeIcePlatformDL); +} diff --git a/src/overlays/actors/ovl_Bg_Icefloe/z_bg_icefloe.h b/src/overlays/actors/ovl_Bg_Icefloe/z_bg_icefloe.h index e35f93daf..91c007d26 100644 --- a/src/overlays/actors/ovl_Bg_Icefloe/z_bg_icefloe.h +++ b/src/overlays/actors/ovl_Bg_Icefloe/z_bg_icefloe.h @@ -5,13 +5,12 @@ struct BgIcefloe; -typedef void (*BgIcefloeActionFunc)(struct BgIcefloe*, GlobalContext*); +typedef void (*BgIcefloeActionFunc)(struct BgIcefloe*, PlayState*); typedef struct BgIcefloe { - /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x18]; - /* 0x015C */ BgIcefloeActionFunc actionFunc; - /* 0x0160 */ char unk_160[0x4]; + /* 0x000 */ DynaPolyActor dyna; + /* 0x15C */ BgIcefloeActionFunc actionFunc; + /* 0x160 */ s32 timer; } BgIcefloe; // size = 0x164 extern const ActorInit Bg_Icefloe_InitVars; diff --git a/src/overlays/actors/ovl_Bg_Icicle/z_bg_icicle.c b/src/overlays/actors/ovl_Bg_Icicle/z_bg_icicle.c index bf0851a5b..aec62ce15 100644 --- a/src/overlays/actors/ovl_Bg_Icicle/z_bg_icicle.c +++ b/src/overlays/actors/ovl_Bg_Icicle/z_bg_icicle.c @@ -11,16 +11,16 @@ #define THIS ((BgIcicle*)thisx) -void BgIcicle_Init(Actor* thisx, GlobalContext* globalCtx); -void BgIcicle_Destroy(Actor* thisx, GlobalContext* globalCtx); -void BgIcicle_Update(Actor* thisx, GlobalContext* globalCtx); -void BgIcicle_Draw(Actor* thisx, GlobalContext* globalCtx); +void BgIcicle_Init(Actor* thisx, PlayState* play); +void BgIcicle_Destroy(Actor* thisx, PlayState* play); +void BgIcicle_Update(Actor* thisx, PlayState* play); +void BgIcicle_Draw(Actor* thisx, PlayState* play); -void BgIcicle_DoNothing(BgIcicle* this, GlobalContext* globalCtx); -void BgIcicle_Wait(BgIcicle* this, GlobalContext* globalCtx); -void BgIcicle_Shiver(BgIcicle* this, GlobalContext* globalCtx); -void BgIcicle_Fall(BgIcicle* this, GlobalContext* globalCtx); -void BgIcicle_Regrow(BgIcicle* this, GlobalContext* globalCtx); +void BgIcicle_DoNothing(BgIcicle* this, PlayState* play); +void BgIcicle_Wait(BgIcicle* this, PlayState* play); +void BgIcicle_Shiver(BgIcicle* this, PlayState* play); +void BgIcicle_Fall(BgIcicle* this, PlayState* play); +void BgIcicle_Regrow(BgIcicle* this, PlayState* play); static ColliderCylinderInit sCylinderInit = { { @@ -61,7 +61,7 @@ static InitChainEntry sInitChain[] = { ICHAIN_VEC3F_DIV1000(scale, 100, ICHAIN_STOP), }; -void BgIcicle_Init(Actor* thisx, GlobalContext* globalCtx) { +void BgIcicle_Init(Actor* thisx, PlayState* play) { s32 pad; BgIcicle* this = THIS; s32 paramsHigh; @@ -69,9 +69,9 @@ void BgIcicle_Init(Actor* thisx, GlobalContext* globalCtx) { Actor_ProcessInitChain(thisx, sInitChain); DynaPolyActor_Init(&this->dyna, 0); - DynaPolyActor_LoadMesh(globalCtx, &this->dyna, &object_icicle_Colheader_000294); + DynaPolyActor_LoadMesh(play, &this->dyna, &object_icicle_Colheader_000294); - Collider_InitAndSetCylinder(globalCtx, &this->collider, thisx, &sCylinderInit); + Collider_InitAndSetCylinder(play, &this->collider, thisx, &sCylinderInit); Collider_UpdateCylinder(thisx, &this->collider); paramsHigh = (thisx->params >> 8) & 0xFF; @@ -89,14 +89,14 @@ void BgIcicle_Init(Actor* thisx, GlobalContext* globalCtx) { } } -void BgIcicle_Destroy(Actor* thisx, GlobalContext* globalCtx) { +void BgIcicle_Destroy(Actor* thisx, PlayState* play) { BgIcicle* this = THIS; - DynaPoly_DeleteBgActor(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); - Collider_DestroyCylinder(globalCtx, &this->collider); + DynaPoly_DeleteBgActor(play, &play->colCtx.dyna, this->dyna.bgId); + Collider_DestroyCylinder(play, &this->collider); } -void BgIcicle_Break(BgIcicle* this, GlobalContext* globalCtx, f32 arg2) { +void BgIcicle_Break(BgIcicle* this, PlayState* play, f32 arg2) { static Vec3f accel = { 0.0f, -1.0f, 0.0f }; static Color_RGBA8 primColor = { 170, 255, 255, 255 }; static Color_RGBA8 envColor = { 0, 50, 100, 255 }; @@ -105,7 +105,7 @@ void BgIcicle_Break(BgIcicle* this, GlobalContext* globalCtx, f32 arg2) { s32 j; s32 i; - SoundSource_PlaySfxAtFixedWorldPos(globalCtx, &this->dyna.actor.world.pos, 30, NA_SE_EV_ICE_BROKEN); + SoundSource_PlaySfxAtFixedWorldPos(play, &this->dyna.actor.world.pos, 30, NA_SE_EV_ICE_BROKEN); for (i = 0; i < 2; i++) { for (j = 0; j < 10; j++) { @@ -117,23 +117,23 @@ void BgIcicle_Break(BgIcicle* this, GlobalContext* globalCtx, f32 arg2) { velocity.z = randPlusMinusPoint5Scaled(7.0f); velocity.y = (Rand_ZeroOne() * 4.0f) + 8.0f; - EffectSsEnIce_Spawn(globalCtx, &pos, (Rand_ZeroOne() * 0.2f) + 0.1f, &velocity, &accel, &primColor, - &envColor, 30); + EffectSsEnIce_Spawn(play, &pos, (Rand_ZeroOne() * 0.2f) + 0.1f, &velocity, &accel, &primColor, &envColor, + 30); } } } -void BgIcicle_DoNothing(BgIcicle* this, GlobalContext* globalCtx) { +void BgIcicle_DoNothing(BgIcicle* this, PlayState* play) { } -void BgIcicle_Wait(BgIcicle* this, GlobalContext* globalCtx) { +void BgIcicle_Wait(BgIcicle* this, PlayState* play) { if (this->dyna.actor.xzDistToPlayer < 60.0f) { this->shiverTimer = 10; this->actionFunc = BgIcicle_Shiver; } } -void BgIcicle_Shiver(BgIcicle* this, GlobalContext* globalCtx) { +void BgIcicle_Shiver(BgIcicle* this, PlayState* play) { s32 randSign; f32 rand; @@ -149,8 +149,8 @@ void BgIcicle_Shiver(BgIcicle* this, GlobalContext* globalCtx) { this->dyna.actor.world.pos.x = this->dyna.actor.home.pos.x; this->dyna.actor.world.pos.z = this->dyna.actor.home.pos.z; - CollisionCheck_SetAT(globalCtx, &globalCtx->colChkCtx, &this->collider.base); - func_800C62BC(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); + CollisionCheck_SetAT(play, &play->colChkCtx, &this->collider.base); + func_800C62BC(play, &play->colCtx.dyna, this->dyna.bgId); this->actionFunc = BgIcicle_Fall; } else { rand = Rand_ZeroOne(); @@ -162,7 +162,7 @@ void BgIcicle_Shiver(BgIcicle* this, GlobalContext* globalCtx) { } } -void BgIcicle_Fall(BgIcicle* this, GlobalContext* globalCtx) { +void BgIcicle_Fall(BgIcicle* this, PlayState* play) { if ((this->collider.base.atFlags & AT_HIT) || (this->dyna.actor.bgCheckFlags & 1)) { this->collider.base.atFlags &= ~AT_HIT; this->dyna.actor.bgCheckFlags &= ~1; @@ -171,11 +171,11 @@ void BgIcicle_Fall(BgIcicle* this, GlobalContext* globalCtx) { this->dyna.actor.world.pos.y = this->dyna.actor.floorHeight; } - BgIcicle_Break(this, globalCtx, 40.0f); + BgIcicle_Break(this, play, 40.0f); if (this->dyna.actor.params == ICICLE_STALACTITE_REGROW) { this->dyna.actor.world.pos.y = this->dyna.actor.home.pos.y + 120.0f; - func_800C6314(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); + func_800C6314(play, &play->colCtx.dyna, this->dyna.bgId); this->actionFunc = BgIcicle_Regrow; } else { Actor_MarkForDeath(&this->dyna.actor); @@ -184,64 +184,64 @@ void BgIcicle_Fall(BgIcicle* this, GlobalContext* globalCtx) { } else { Actor_MoveWithGravity(&this->dyna.actor); this->dyna.actor.world.pos.y += 40.0f; - Actor_UpdateBgCheckInfo(globalCtx, &this->dyna.actor, 0.0f, 0.0f, 0.0f, 4); + Actor_UpdateBgCheckInfo(play, &this->dyna.actor, 0.0f, 0.0f, 0.0f, 4); this->dyna.actor.world.pos.y -= 40.0f; - CollisionCheck_SetAT(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + CollisionCheck_SetAT(play, &play->colChkCtx, &this->collider.base); } } -void BgIcicle_Regrow(BgIcicle* this, GlobalContext* globalCtx) { +void BgIcicle_Regrow(BgIcicle* this, PlayState* play) { if (Math_StepToF(&this->dyna.actor.world.pos.y, this->dyna.actor.home.pos.y, 1.0f)) { this->actionFunc = BgIcicle_Wait; this->dyna.actor.velocity.y = 0.0f; } } -void BgIcicle_UpdateAttacked(BgIcicle* this, GlobalContext* globalCtx) { +void BgIcicle_UpdateAttacked(BgIcicle* this, PlayState* play) { s32 dropItem00Id; if (this->collider.base.acFlags & AC_HIT) { this->collider.base.acFlags &= ~AC_HIT; if (this->dyna.actor.params == ICICLE_STALAGMITE_RANDOM_DROP) { - BgIcicle_Break(this, globalCtx, 50.0f); + BgIcicle_Break(this, play, 50.0f); if (this->unk_160 != 0xFF) { - Item_DropCollectibleRandom(globalCtx, NULL, &this->dyna.actor.world.pos, this->unk_160 << 4); + Item_DropCollectibleRandom(play, NULL, &this->dyna.actor.world.pos, this->unk_160 << 4); } } else if (this->dyna.actor.params == ICICLE_STALAGMITE_FIXED_DROP) { dropItem00Id = func_800A8150(this->unk_160); - BgIcicle_Break(this, globalCtx, 50.0f); - Item_DropCollectible(globalCtx, &this->dyna.actor.world.pos, (this->unk_161 << 8) | dropItem00Id); + BgIcicle_Break(this, play, 50.0f); + Item_DropCollectible(play, &this->dyna.actor.world.pos, (this->unk_161 << 8) | dropItem00Id); } else { if (this->dyna.actor.params == ICICLE_STALACTITE_REGROW) { - BgIcicle_Break(this, globalCtx, 40.0f); + BgIcicle_Break(this, play, 40.0f); this->dyna.actor.world.pos.y = this->dyna.actor.home.pos.y + 120.0f; - func_800C6314(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); + func_800C6314(play, &play->colCtx.dyna, this->dyna.bgId); this->actionFunc = BgIcicle_Regrow; return; } - BgIcicle_Break(this, globalCtx, 40.0f); + BgIcicle_Break(this, play, 40.0f); } Actor_MarkForDeath(&this->dyna.actor); } } -void BgIcicle_Update(Actor* thisx, GlobalContext* globalCtx) { +void BgIcicle_Update(Actor* thisx, PlayState* play) { s32 pad; BgIcicle* this = THIS; - BgIcicle_UpdateAttacked(this, globalCtx); - this->actionFunc(this, globalCtx); + BgIcicle_UpdateAttacked(this, play); + this->actionFunc(this, play); if (this->actionFunc != BgIcicle_Regrow) { Collider_UpdateCylinder(&this->dyna.actor, &this->collider); - CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + CollisionCheck_SetAC(play, &play->colChkCtx, &this->collider.base); } } -void BgIcicle_Draw(Actor* thisx, GlobalContext* globalCtx) { - Gfx_DrawDListOpa(globalCtx, object_icicle_DL_0000D0); +void BgIcicle_Draw(Actor* thisx, PlayState* play) { + Gfx_DrawDListOpa(play, object_icicle_DL_0000D0); } diff --git a/src/overlays/actors/ovl_Bg_Icicle/z_bg_icicle.h b/src/overlays/actors/ovl_Bg_Icicle/z_bg_icicle.h index 510332da0..20450f929 100644 --- a/src/overlays/actors/ovl_Bg_Icicle/z_bg_icicle.h +++ b/src/overlays/actors/ovl_Bg_Icicle/z_bg_icicle.h @@ -5,7 +5,7 @@ struct BgIcicle; -typedef void (*BgIcicleActionFunc)(struct BgIcicle*, GlobalContext*); +typedef void (*BgIcicleActionFunc)(struct BgIcicle*, PlayState*); typedef enum { /* 0 */ ICICLE_STALAGMITE_RANDOM_DROP, 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 9d2fd67d9..0a4c31d12 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,21 +5,26 @@ */ #include "z_bg_ikana_block.h" +#include "objects/gameplay_dangeon_keep/gameplay_dangeon_keep.h" #define FLAGS (ACTOR_FLAG_10) #define THIS ((BgIkanaBlock*)thisx) -void BgIkanaBlock_Init(Actor* thisx, GlobalContext* globalCtx); -void BgIkanaBlock_Destroy(Actor* thisx, GlobalContext* globalCtx); -void BgIkanaBlock_Update(Actor* thisx, GlobalContext* globalCtx); +void BgIkanaBlock_Init(Actor* thisx, PlayState* play); +void BgIkanaBlock_Destroy(Actor* thisx, PlayState* play); +void BgIkanaBlock_Update(Actor* thisx, PlayState* play); -void func_80B7F034(BgIkanaBlock* this, GlobalContext* globalCtx); -void func_80B7F0D0(BgIkanaBlock* this, GlobalContext* globalCtx); -void func_80B7F290(BgIkanaBlock* this, GlobalContext* globalCtx); -void func_80B7F398(BgIkanaBlock* this, GlobalContext* globalCtx); +void func_80B7F00C(BgIkanaBlock* this); +void func_80B7F034(BgIkanaBlock* this, PlayState* play); +void func_80B7F0A4(BgIkanaBlock* this); +void func_80B7F0D0(BgIkanaBlock* this, PlayState* play); +void func_80B7F1A8(BgIkanaBlock* this); +void func_80B7F290(BgIkanaBlock* this, PlayState* play); +void func_80B7F360(BgIkanaBlock* this); +void func_80B7F398(BgIkanaBlock* this, PlayState* play); +void func_80B7F564(Actor* thisx, PlayState* play); -#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, PlayState* play) { + return !(this->unk_17C & 8); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Ikana_Block/func_80B7EB94.s") +s32 func_80B7EB7C(BgIkanaBlock* this, PlayState* play) { + return this->unk_17B > 10; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Ikana_Block/func_80B7ECFC.s") +s32 func_80B7EB94(BgIkanaBlock* this, PlayState* play) { + 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(&play->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, PlayState* play) { + return func_80B7EB64(this, play) && func_80B7EB7C(this, play) && func_80B7EB94(this, play); +} -#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, PlayState* play) { + 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(play, &play->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, PlayState* play) { + if (func_80B7EDC4(this, play)) { + this->dyna.actor.world.pos.y = this->dyna.actor.floorHeight - this->unk_170; + return true; + } + return false; +} + +s32 func_80B7EEB4(BgIkanaBlock* this, PlayState* play) { + func_80B7EDC4(this, play); + + if (this->dyna.actor.floorHeight > (BGCHECK_Y_MIN + 1.0f)) { + if (DynaPoly_GetActor(&play->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, PlayState* play) { + BgIkanaBlock* this = THIS; + + Actor_ProcessInitChain(&this->dyna.actor, sInitChain); + DynaPolyActor_Init(&this->dyna, 1); + DynaPolyActor_LoadMesh(play, &this->dyna, &gameplay_dangeon_keep_Colheader_007498); + func_800C62BC(play, &play->colCtx.dyna, this->dyna.bgId); + this->unk_15C = Lib_SegmentedToVirtual(gameplay_dangeon_keep_Matanimheader_01B370); + this->unk_174 = this->dyna.actor.shape.rot; + func_80B7ED54(this); + func_80B7F00C(this); +} + +void BgIkanaBlock_Destroy(Actor* thisx, PlayState* play) { + BgIkanaBlock* this = THIS; + + DynaPoly_DeleteBgActor(play, &play->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, PlayState* play) { + if (this->unk_17D > 0) { + this->unk_17D--; + } + + if (func_80B7EEB4(this, play)) { + func_800C6314(play, &play->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, PlayState* play) { + s32 sp24 = 0; + s32 phi_v1; + + func_80B7EA60(this); + func_80B7EB30(this); + + if (this->unk_17C & 4) { + sp24 = 1; + } else if (func_80B7ECFC(this, play)) { + sp24 = 2; + } + + if ((sp24 != 2) && (this->unk_17A & (0x8 | 0x4 | 0x2 | 0x1))) { + Player* player = GET_PLAYER(play); + + 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, PlayState* play) { + 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(play); + + if (!func_80B7EB94(this, play)) { + Actor_PlaySfxAtPos(&this->dyna.actor, NA_SE_EV_BLOCK_BOUND); + } + + player->stateFlags2 &= ~0x10; + this->dyna.pushForce = 0.0f; + + if (func_80B7EDC4(this, play)) { + 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, PlayState* play) { + 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, play)) { + Actor_PlaySfxAtPos(&this->dyna.actor, NA_SE_EV_BLOCK_BOUND); + Actor_PlaySfxAtPos(&this->dyna.actor, + SurfaceType_GetSfx(&play->colCtx, this->dyna.actor.floorPoly, this->dyna.actor.floorBgId) + + SFX_FLAG); + func_80B7F0A4(this); + } +} + +void BgIkanaBlock_Update(Actor* thisx, PlayState* play) { + 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, play); + + 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, PlayState* play) { + s32 pad; + BgIkanaBlock* this = THIS; + + OPEN_DISPS(play->state.gfxCtx); + + func_8012C28C(play->state.gfxCtx); + AnimatedMat_DrawStep(play, this->unk_15C, 0); + + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(play->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(play->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 112e4ad00..5c5281911 100644 --- a/src/overlays/actors/ovl_Bg_Ikana_Block/z_bg_ikana_block.h +++ b/src/overlays/actors/ovl_Bg_Ikana_Block/z_bg_ikana_block.h @@ -5,18 +5,23 @@ struct BgIkanaBlock; -typedef void (*BgIkanaBlockActionFunc)(struct BgIkanaBlock*, GlobalContext*); +typedef void (*BgIkanaBlockActionFunc)(struct BgIkanaBlock*, PlayState*); typedef struct BgIkanaBlock { - /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x1C]; - /* 0x0160 */ BgIkanaBlockActionFunc actionFunc; - /* 0x0164 */ char unk_164[0xC]; - /* 0x0170 */ f32 unk_170; - /* 0x0174 */ char unk_174[0x8]; - /* 0x017C */ u8 unk_17C; - /* 0x017D */ char unk_17D[0x1]; - /* 0x017E */ u8 unk_17E; + /* 0x000 */ DynaPolyActor dyna; + /* 0x15C */ AnimatedMaterial* unk_15C; + /* 0x160 */ BgIkanaBlockActionFunc actionFunc; + /* 0x164 */ f32* unk_164; + /* 0x168 */ f32 unk_168; + /* 0x16C */ f32 unk_16C; + /* 0x170 */ f32 unk_170; + /* 0x174 */ Vec3s unk_174; + /* 0x17A */ u8 unk_17A; + /* 0x17B */ s8 unk_17B; + /* 0x17C */ u8 unk_17C; + /* 0x17D */ s8 unk_17D; + /* 0x17E */ s8 unk_17E; + /* 0x17F */ s8 unk_17F; } BgIkanaBlock; // size = 0x180 extern const ActorInit Bg_Ikana_Block_InitVars; diff --git a/src/overlays/actors/ovl_Bg_Ikana_Bombwall/z_bg_ikana_bombwall.c b/src/overlays/actors/ovl_Bg_Ikana_Bombwall/z_bg_ikana_bombwall.c index f183a7164..43627317e 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,17 +5,26 @@ */ #include "z_bg_ikana_bombwall.h" +#include "objects/object_ikana_obj/object_ikana_obj.h" #define FLAGS (ACTOR_FLAG_10000000) #define THIS ((BgIkanaBombwall*)thisx) -void BgIkanaBombwall_Init(Actor* thisx, GlobalContext* globalCtx); -void BgIkanaBombwall_Destroy(Actor* thisx, GlobalContext* globalCtx); -void BgIkanaBombwall_Update(Actor* thisx, GlobalContext* globalCtx); -void BgIkanaBombwall_Draw(Actor* thisx, GlobalContext* globalCtx); +void BgIkanaBombwall_Init(Actor* thisx, PlayState* play); +void BgIkanaBombwall_Destroy(Actor* thisx, PlayState* play); +void BgIkanaBombwall_Update(Actor* thisx, PlayState* play); +void BgIkanaBombwall_Draw(Actor* thisx, PlayState* play); + +void func_80BD4F18(BgIkanaBombwall* this); +void func_80BD4F2C(BgIkanaBombwall* this, PlayState* play); +void func_80BD4F88(BgIkanaBombwall* this); +void func_80BD4F9C(BgIkanaBombwall* this, PlayState* play); +void func_80BD4FF8(BgIkanaBombwall* this); +void func_80BD503C(BgIkanaBombwall* this, PlayState* play); +void func_80BD5118(BgIkanaBombwall* this); +void func_80BD5134(BgIkanaBombwall* this, PlayState* play); -#if 0 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, PlayState* play) { + 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(play, &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(play, &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, PlayState* play); +#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, PlayState* play) { + 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(play, &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(play, &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, PlayState* play) { + 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(play, &this->collider); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Ikana_Bombwall/func_80BD503C.s") + if (Flags_GetSwitch(play, 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(play, &this->dyna, sp28); + Collider_SetCylinder(play, &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, PlayState* play) { + BgIkanaBombwall* this = THIS; + + DynaPoly_DeleteBgActor(play, &play->colCtx.dyna, this->dyna.bgId); + Collider_DestroyCylinder(play, &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, PlayState* play) { + if (func_80BD4E44(this)) { + func_80BD4FF8(this); + } else { + CollisionCheck_SetAC(play, &play->colChkCtx, &this->collider.base); + } +} + +void func_80BD4F88(BgIkanaBombwall* this) { + this->actionFunc = func_80BD4F9C; +} + +void func_80BD4F9C(BgIkanaBombwall* this, PlayState* play) { + if (func_80BD4EAC(this)) { + func_80BD4FF8(this); + } else { + CollisionCheck_SetAC(play, &play->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, PlayState* play) { + 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, play); + } else { + func_80BD4A14(this, play); + } + this->dyna.actor.draw = NULL; + SoundSource_PlaySfxAtFixedWorldPos(play, &this->dyna.actor.world.pos, 60, NA_SE_EV_WALL_BROKEN); + Flags_SetSwitch(play, BGIKANABOMBWALL_GET_SWITCHFLAG(&this->dyna.actor)); + if (!BGIKANABOMBWALL_GET_100(&this->dyna.actor)) { + func_800C62BC(play, &play->colCtx.dyna, this->dyna.bgId); + } + 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, PlayState* play) { + 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, PlayState* play) { + BgIkanaBombwall* this = THIS; + + this->actionFunc(this, play); +} + +void BgIkanaBombwall_Draw(Actor* thisx, PlayState* play) { + Gfx_DrawDListOpa(play, 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..da11bcfea 100644 --- a/src/overlays/actors/ovl_Bg_Ikana_Bombwall/z_bg_ikana_bombwall.h +++ b/src/overlays/actors/ovl_Bg_Ikana_Bombwall/z_bg_ikana_bombwall.h @@ -5,13 +5,16 @@ struct BgIkanaBombwall; -typedef void (*BgIkanaBombwallActionFunc)(struct BgIkanaBombwall*, GlobalContext*); +typedef void (*BgIkanaBombwallActionFunc)(struct BgIkanaBombwall*, PlayState*); + +#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]; - /* 0x01A8 */ BgIkanaBombwallActionFunc actionFunc; - /* 0x01AC */ char unk_1AC[0x4]; + /* 0x000 */ DynaPolyActor dyna; + /* 0x15C */ ColliderCylinder collider; + /* 0x1A8 */ BgIkanaBombwallActionFunc actionFunc; + /* 0x1AC */ s8 unk_1AC; } BgIkanaBombwall; // size = 0x1B0 extern const ActorInit Bg_Ikana_Bombwall_InitVars; diff --git a/src/overlays/actors/ovl_Bg_Ikana_Dharma/z_bg_ikana_dharma.c b/src/overlays/actors/ovl_Bg_Ikana_Dharma/z_bg_ikana_dharma.c index 2fb508c79..e619aa7e0 100644 --- a/src/overlays/actors/ovl_Bg_Ikana_Dharma/z_bg_ikana_dharma.c +++ b/src/overlays/actors/ovl_Bg_Ikana_Dharma/z_bg_ikana_dharma.c @@ -5,17 +5,24 @@ */ #include "z_bg_ikana_dharma.h" +#include "assets/objects/object_ikana_obj/object_ikana_obj.h" #define FLAGS (ACTOR_FLAG_10) #define THIS ((BgIkanaDharma*)thisx) -void BgIkanaDharma_Init(Actor* thisx, GlobalContext* globalCtx); -void BgIkanaDharma_Destroy(Actor* thisx, GlobalContext* globalCtx); -void BgIkanaDharma_Update(Actor* thisx, GlobalContext* globalCtx); -void BgIkanaDharma_Draw(Actor* thisx, GlobalContext* globalCtx); +void BgIkanaDharma_Init(Actor* thisx, PlayState* play); +void BgIkanaDharma_Destroy(Actor* thisx, PlayState* play); +void BgIkanaDharma_Update(Actor* thisx, PlayState* play); +void BgIkanaDharma_Draw(Actor* thisx, PlayState* play); + +void BgIkanaDharma_SetupWaitForHit(BgIkanaDharma* this); +void BgIkanaDharma_WaitForHit(BgIkanaDharma* this, PlayState* play); +void BgIkanaDharma_SetupStartCutscene(BgIkanaDharma* this); +void BgIkanaDharma_StartCutscene(BgIkanaDharma* this, PlayState* play); +void BgIkanaDharma_SetupWaitForCutsceneToEnd(BgIkanaDharma* this); +void BgIkanaDharma_WaitForCutsceneToEnd(BgIkanaDharma* this, PlayState* play); -#if 0 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, PlayState* play) { + 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 = (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(play, &pos, &velocity, &accel); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Ikana_Dharma/BgIkanaDharma_Init.s") +void BgIkanaDharma_Init(Actor* thisx, PlayState* play2) { + PlayState* play = play2; + 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(play, &this->dyna, &gStoneTowerTemplePunchablePillarCol); + Collider_InitCylinder(play, &this->collider); + Collider_SetCylinder(play, &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(&play->actorCtx, play, ACTOR_BG_IKANA_DHARMA, this->dyna.actor.world.pos.x, + segmentY, this->dyna.actor.world.pos.z, this->dyna.actor.shape.rot.x, + this->dyna.actor.shape.rot.y, this->dyna.actor.shape.rot.z, + BGIKANADHARMA_PARAMS(0, true, 0), this->dyna.actor.cutscene, + this->dyna.actor.unk20, NULL); + } -#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, PlayState* play) { + BgIkanaDharma* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Ikana_Dharma/func_80BEC7EC.s") + DynaPoly_DeleteBgActor(play, &play->colCtx.dyna, this->dyna.bgId); + Collider_DestroyCylinder(play, &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, PlayState* play) { + s32 wasHit = (this->collider.base.acFlags & AC_HIT) != 0; + Player* player = GET_PLAYER(play); + 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(play, 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(play, &play->colChkCtx, &this->collider.base); + } + } +} + +void BgIkanaDharma_SetupStartCutscene(BgIkanaDharma* this) { + ActorCutscene_SetIntentToPlay(this->dyna.actor.cutscene); + this->actionFunc = BgIkanaDharma_StartCutscene; +} + +void BgIkanaDharma_StartCutscene(BgIkanaDharma* this, PlayState* play) { + if (ActorCutscene_GetCanPlayNext(this->dyna.actor.cutscene)) { + ActorCutscene_StartAndSetUnkLinkFields(this->dyna.actor.cutscene, &this->dyna.actor); + 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, PlayState* play) { + 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, play); + } +} + +void BgIkanaDharma_Update(Actor* thisx, PlayState* play) { + BgIkanaDharma* this = THIS; + + this->actionFunc(this, play); + if (this->actionFunc == BgIkanaDharma_WaitForHit) { + DynaPolyActor* actorBelow; + s32 pad[2]; + + func_800B4AEC(play, &this->dyna.actor, 30.0f); + actorBelow = DynaPoly_GetActor(&play->colCtx, this->dyna.actor.floorBgId); + if (actorBelow == NULL) { + Actor_MoveWithGravity(&this->dyna.actor); + Actor_UpdateBgCheckInfo(play, &this->dyna.actor, 0.0f, 0.0f, 0.0f, 4); + if (this->dyna.actor.bgCheckFlags & 2) { + s16 quake = Quake_Add(GET_ACTIVE_CAM(play), 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(play, &this->dyna.actor, 20.0f, wallCheckRadius, 0.0f, 5); + } + + Actor_SetFocus(&this->dyna.actor, 40.0f); +} + +void BgIkanaDharma_Draw(Actor* thisx, PlayState* play) { + BgIkanaDharma* this = THIS; + + Gfx_DrawDListOpa(play, 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..4642a4369 100644 --- a/src/overlays/actors/ovl_Bg_Ikana_Dharma/z_bg_ikana_dharma.h +++ b/src/overlays/actors/ovl_Bg_Ikana_Dharma/z_bg_ikana_dharma.h @@ -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 void (*BgIkanaDharmaActionFunc)(struct BgIkanaDharma*, PlayState*); typedef struct BgIkanaDharma { - /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x64]; - /* 0x01A8 */ BgIkanaDharmaActionFunc actionFunc; - /* 0x01AC */ char unk_1AC[0x4]; + /* 0x000 */ DynaPolyActor dyna; + /* 0x15C */ ColliderCylinder collider; + /* 0x1A8 */ BgIkanaDharmaActionFunc actionFunc; + /* 0x1AC */ s8 cutsceneFramesRemaining; } BgIkanaDharma; // size = 0x1B0 extern const ActorInit Bg_Ikana_Dharma_InitVars; diff --git a/src/overlays/actors/ovl_Bg_Ikana_Mirror/z_bg_ikana_mirror.c b/src/overlays/actors/ovl_Bg_Ikana_Mirror/z_bg_ikana_mirror.c index de45de35b..cfa67eb1d 100644 --- a/src/overlays/actors/ovl_Bg_Ikana_Mirror/z_bg_ikana_mirror.c +++ b/src/overlays/actors/ovl_Bg_Ikana_Mirror/z_bg_ikana_mirror.c @@ -2,20 +2,30 @@ * File: z_bg_ikana_mirror.c * Overlay: ovl_Bg_Ikana_Mirror * Description: Stone Tower Temple - Mirror + * + * This mirror absorbs light reflected by the mirror shield or by another mirror of the same kind for a + * maximum of 400 frames (20 seconds) to then release light for the same number of frames it was charged. This number + * of frames is stored in the actor struct's lightRayCharge field and is updated in the BgIkanaMirror_Wait and + * BgIkanaMirror_EmitLight functions both described below. */ #include "z_bg_ikana_mirror.h" +#include "objects/object_ikana_obj/object_ikana_obj.h" #define FLAGS (ACTOR_FLAG_10) #define THIS ((BgIkanaMirror*)thisx) -void BgIkanaMirror_Init(Actor* thisx, GlobalContext* globalCtx); -void BgIkanaMirror_Destroy(Actor* thisx, GlobalContext* globalCtx); -void BgIkanaMirror_Update(Actor* thisx, GlobalContext* globalCtx); -void BgIkanaMirror_Draw(Actor* thisx, GlobalContext* globalCtx); +void BgIkanaMirror_Init(Actor* thisx, PlayState* play); +void BgIkanaMirror_Destroy(Actor* thisx, PlayState* play); +void BgIkanaMirror_Update(Actor* thisx, PlayState* play); +void BgIkanaMirror_Draw(Actor* thisx, PlayState* play); + +void BgIkanaMirror_SetupWait(BgIkanaMirror* this); +void BgIkanaMirror_Wait(BgIkanaMirror* this, PlayState* play); +void BgIkanaMirror_SetupEmitLight(BgIkanaMirror* this); +void BgIkanaMirror_EmitLight(BgIkanaMirror* this, PlayState* play); -#if 0 const ActorInit Bg_Ikana_Mirror_InitVars = { ACTOR_BG_IKANA_MIRROR, ACTORCAT_PROP, @@ -28,99 +38,371 @@ const ActorInit Bg_Ikana_Mirror_InitVars = { (ActorFunc)BgIkanaMirror_Draw, }; -// static ColliderTrisElementInit sTrisElementsInit[9] = { -static ColliderTrisElementInit D_80B7FF50[9] = { +static ColliderTrisElementInit sMirrorColliderElementsInit[] = { { - { ELEMTYPE_UNK4, { 0x00000000, 0x00, 0x00 }, { 0x00200000, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_NONE, }, - { { { 0.0f, 21.600000381469727f, 13.699999809265137f }, { -25.299999237060547f, 6.0f, 8.399999618530273f }, { 25.299999237060547f, 6.0f, 8.399999618530273f } } }, + { + ELEMTYPE_UNK4, + { 0x00000000, 0x00, 0x00 }, + { 0x00200000, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_NONE, + }, + { { { 0.0f, 21.6f, 13.7f }, { -25.3f, 6.0f, 8.4f }, { 25.3f, 6.0f, 8.4f } } }, }, { - { ELEMTYPE_UNK4, { 0x00000000, 0x00, 0x00 }, { 0x00200000, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_NONE, }, - { { { 0.0f, 45.0f, 13.699999809265137f }, { -25.299999237060547f, 6.0f, 8.399999618530273f }, { 0.0f, 21.600000381469727f, 13.699999809265137f } } }, + { + ELEMTYPE_UNK4, + { 0x00000000, 0x00, 0x00 }, + { 0x00200000, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_NONE, + }, + { { { 0.0f, 45.0f, 13.7f }, { -25.3f, 6.0f, 8.4f }, { 0.0f, 21.6f, 13.7f } } }, }, { - { ELEMTYPE_UNK4, { 0x00000000, 0x00, 0x00 }, { 0x00200000, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_NONE, }, - { { { 0.0f, 45.0f, 13.699999809265137f }, { 0.0f, 21.600000381469727f, 13.699999809265137f }, { 25.299999237060547f, 6.0f, 8.399999618530273f } } }, + { + ELEMTYPE_UNK4, + { 0x00000000, 0x00, 0x00 }, + { 0x00200000, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_NONE, + }, + { { { 0.0f, 45.0f, 13.7f }, { 0.0f, 21.6f, 13.7f }, { 25.3f, 6.0f, 8.4f } } }, }, { - { ELEMTYPE_UNK4, { 0x00000000, 0x00, 0x00 }, { 0x00200000, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_NONE, }, - { { { 0.0f, 45.0f, 13.699999809265137f }, { -25.299999237060547f, 45.0f, 8.399999618530273f }, { -25.299999237060547f, 6.0f, 8.399999618530273f } } }, + { + ELEMTYPE_UNK4, + { 0x00000000, 0x00, 0x00 }, + { 0x00200000, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_NONE, + }, + { { { 0.0f, 45.0f, 13.7f }, { -25.3f, 45.0f, 8.4f }, { -25.3f, 6.0f, 8.4f } } }, }, { - { ELEMTYPE_UNK4, { 0x00000000, 0x00, 0x00 }, { 0x00200000, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_NONE, }, - { { { 0.0f, 45.0f, 13.699999809265137f }, { 25.299999237060547f, 6.0f, 8.399999618530273f }, { 25.299999237060547f, 45.0f, 8.399999618530273f } } }, + { + ELEMTYPE_UNK4, + { 0x00000000, 0x00, 0x00 }, + { 0x00200000, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_NONE, + }, + { { { 0.0f, 45.0f, 13.7f }, { 25.3f, 6.0f, 8.4f }, { 25.3f, 45.0f, 8.4f } } }, }, { - { ELEMTYPE_UNK4, { 0x00000000, 0x00, 0x00 }, { 0x00200000, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_NONE, }, - { { { 0.0f, 45.0f, 13.699999809265137f }, { -17.899999618530273f, 64.0999984741211f, 8.399999618530273f }, { -25.299999237060547f, 45.0f, 8.399999618530273f } } }, + { + ELEMTYPE_UNK4, + { 0x00000000, 0x00, 0x00 }, + { 0x00200000, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_NONE, + }, + { { { 0.0f, 45.0f, 13.7f }, { -17.9f, 64.1f, 8.4f }, { -25.3f, 45.0f, 8.4f } } }, }, { - { ELEMTYPE_UNK4, { 0x00000000, 0x00, 0x00 }, { 0x00200000, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_NONE, }, - { { { 0.0f, 45.0f, 13.699999809265137f }, { 25.299999237060547f, 45.0f, 8.399999618530273f }, { 17.899999618530273f, 64.0999984741211f, 8.399999618530273f } } }, + { + ELEMTYPE_UNK4, + { 0x00000000, 0x00, 0x00 }, + { 0x00200000, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_NONE, + }, + { { { 0.0f, 45.0f, 13.7f }, { 25.3f, 45.0f, 8.4f }, { 17.9f, 64.1f, 8.4f } } }, }, { - { ELEMTYPE_UNK4, { 0x00000000, 0x00, 0x00 }, { 0x00200000, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_NONE, }, - { { { 0.0f, 45.0f, 13.699999809265137f }, { 0.0f, 72.0f, 8.399999618530273f }, { -17.899999618530273f, 64.0999984741211f, 8.399999618530273f } } }, + { + ELEMTYPE_UNK4, + { 0x00000000, 0x00, 0x00 }, + { 0x00200000, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_NONE, + }, + { { { 0.0f, 45.0f, 13.7f }, { 0.0f, 72.0f, 8.4f }, { -17.9f, 64.1f, 8.4f } } }, }, { - { ELEMTYPE_UNK4, { 0x00000000, 0x00, 0x00 }, { 0x00200000, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_NONE, }, - { { { 0.0f, 45.0f, 13.699999809265137f }, { 17.899999618530273f, 64.0999984741211f, 8.399999618530273f }, { 0.0f, 72.0f, 8.399999618530273f } } }, + { + ELEMTYPE_UNK4, + { 0x00000000, 0x00, 0x00 }, + { 0x00200000, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_NONE, + }, + { { { 0.0f, 45.0f, 13.7f }, { 17.9f, 64.1f, 8.4f }, { 0.0f, 72.0f, 8.4f } } }, }, }; -// static ColliderTrisInit sTrisInit = { -static ColliderTrisInit D_80B8016C = { - { COLTYPE_NONE, AT_NONE, AC_ON | AC_TYPE_PLAYER | AC_TYPE_OTHER, OC1_NONE, OC2_NONE, COLSHAPE_TRIS, }, - 9, D_80B7FF50, // sTrisElementsInit, +static ColliderTrisInit sMirrorColliderInit = { + { + COLTYPE_NONE, + AT_NONE, + AC_ON | AC_TYPE_PLAYER | AC_TYPE_OTHER, + OC1_NONE, + OC2_NONE, + COLSHAPE_TRIS, + }, + ARRAY_COUNT(sMirrorColliderElementsInit), + sMirrorColliderElementsInit, }; -// static ColliderQuadInit sQuadInit = { -static ColliderQuadInit D_80B8017C = { - { COLTYPE_NONE, AT_ON | AT_TYPE_OTHER, AC_NONE, OC1_NONE, OC2_NONE, COLSHAPE_QUAD, }, - { ELEMTYPE_UNK0, { 0x00200000, 0x00, 0x00 }, { 0x00000000, 0x00, 0x00 }, TOUCH_ON | TOUCH_SFX_NONE, BUMP_NONE, OCELEM_NONE, }, - { { { 0.0f, 72.0f, 20.0f }, { 0.0f, 72.0f, 240.0f }, { 0.0f, 6.0f, 20.0f }, { 0.0f, 6.0f, 240.0f } } }, +static ColliderQuadInit sLightRaysCollidersInit[] = { + { + { + COLTYPE_NONE, + AT_ON | AT_TYPE_OTHER, + AC_NONE, + OC1_NONE, + OC2_NONE, + COLSHAPE_QUAD, + }, + { + ELEMTYPE_UNK0, + { 0x00200000, 0x00, 0x00 }, + { 0x00000000, 0x00, 0x00 }, + TOUCH_ON | TOUCH_SFX_NONE, + BUMP_NONE, + OCELEM_NONE, + }, + { { { 0.0f, 72.0f, 20.0f }, { 0.0f, 72.0f, 240.0f }, { 0.0f, 6.0f, 20.0f }, { 0.0f, 6.0f, 240.0f } } }, + }, + { + { + COLTYPE_NONE, + AT_ON | AT_TYPE_OTHER, + AC_NONE, + OC1_NONE, + OC2_NONE, + COLSHAPE_QUAD, + }, + { + ELEMTYPE_UNK0, + { 0x00200000, 0x00, 0x00 }, + { 0x00000000, 0x00, 0x00 }, + TOUCH_ON | TOUCH_SFX_NONE, + BUMP_NONE, + OCELEM_NONE, + }, + { { { 25.3f, 20.0f, 20.0f }, { 25.3f, 20.0f, 240.0f }, { -25.3f, 20.0f, 20.0f }, { -25.3f, 20.0f, 240.0f } } }, + } }; -// static ColliderQuadInit sQuadInit = { -static ColliderQuadInit D_80B801FC = { - { 0x41, AT_NONE | AT_TYPE_OTHER, AC_NONE, OC1_NONE, OC2_FIRST_ONLY | OC2_UNK1 | OC2_HIT_PLAYER, 0x70, }, - { 0xC1, { 0x41A00000, 0x41, 0xA0 }, { 0xC1CA6666, 0x41, 0xA0 }, TOUCH_ON | TOUCH_HIT | TOUCH_SFX_NORMAL | TOUCH_DREW_HITMARK, BUMP_NONE | BUMP_NO_DAMAGE | BUMP_NO_SWORD_SFX | BUMP_NO_HITMARK, OCELEM_NONE, }, - { { { -1.8339854079840734e-09f, -1.8626939990440405e-09f, -1.9208972190654094e-09f }, { 221185.5625f, 0.0f, 0.003921568859368563f }, { 0.0f, 0.0f, 0.0f }, { 2.8698592549372254e-42f, 1.0761972206014595e-42f, 2.2420775429197073e-44f } } }, -}; - -// static InitChainEntry sInitChain[] = { -static InitChainEntry D_80B8021C[] = { +static InitChainEntry sInitChain[] = { ICHAIN_F32(uncullZoneForward, 4000, ICHAIN_CONTINUE), ICHAIN_F32(uncullZoneScale, 220, ICHAIN_CONTINUE), ICHAIN_F32(uncullZoneDownward, 200, ICHAIN_CONTINUE), ICHAIN_VEC3F_DIV1000(scale, 100, ICHAIN_STOP), }; -#endif +void BgIkanaMirror_SetQuadVertices(BgIkanaMirror* this) { + ColliderQuadDimInit* dim; + ColliderQuad* lightRaysCollider; + Vec3f v0; + Vec3f v1; + Vec3f v2; + Vec3f v3; + s32 i; -extern ColliderTrisElementInit D_80B7FF50[9]; -extern ColliderTrisInit D_80B8016C; -extern ColliderQuadInit D_80B8017C; -extern ColliderQuadInit D_80B801FC; -extern InitChainEntry D_80B8021C[]; + Matrix_Push(); + Matrix_SetTranslateRotateYXZ(this->dyna.actor.world.pos.x, this->dyna.actor.world.pos.y, + this->dyna.actor.world.pos.z, &this->dyna.actor.shape.rot); + for (i = 0; i < ARRAY_COUNT(this->lightRaysColliders); i++) { + dim = &sLightRaysCollidersInit[i].dim; + Matrix_MultVec3f(&dim->quad[0], &v0); + Matrix_MultVec3f(&dim->quad[1], &v1); + Matrix_MultVec3f(&dim->quad[2], &v2); + Matrix_MultVec3f(&dim->quad[3], &v3); + lightRaysCollider = &this->lightRaysColliders[i]; + Collider_SetQuadVertices(lightRaysCollider, &v0, &v1, &v2, &v3); + } -extern UNK_TYPE D_06001E18; -extern UNK_TYPE D_06002358; + Matrix_Pop(); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Ikana_Mirror/func_80B7F730.s") +void BgIkanaMirror_Init(Actor* thisx, PlayState* play2) { + PlayState* play = play2; + BgIkanaMirror* this = THIS; + ColliderTrisElementInit* element; + Vec3f vertices[3]; + s32 i; + s32 j; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Ikana_Mirror/BgIkanaMirror_Init.s") + Actor_ProcessInitChain(&this->dyna.actor, sInitChain); + DynaPolyActor_Init(&this->dyna, 0); + DynaPolyActor_LoadMesh(play, &this->dyna, &gStoneTowerTempleMirrorCol); + Collider_InitTris(play, &this->mirrorCollider); + Collider_SetTris(play, &this->mirrorCollider, &this->dyna.actor, &sMirrorColliderInit, + this->mirrorColliderElements); + Matrix_SetTranslateRotateYXZ(this->dyna.actor.world.pos.x, this->dyna.actor.world.pos.y, + this->dyna.actor.world.pos.z, &this->dyna.actor.shape.rot); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Ikana_Mirror/BgIkanaMirror_Destroy.s") + for (i = 0; i < ARRAY_COUNT(sMirrorColliderElementsInit); i++) { + element = &sMirrorColliderInit.elements[i]; + for (j = 0; j < 3; j++) { + Matrix_MultVec3f(&element->dim.vtx[j], &vertices[j]); + } + Collider_SetTrisVertices(&this->mirrorCollider, i, &vertices[0], &vertices[1], &vertices[2]); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Ikana_Mirror/func_80B7FA84.s") + for (i = 0; i < ARRAY_COUNT(this->lightRaysColliders); i++) { + Collider_InitQuad(play, &this->lightRaysColliders[i]); + Collider_SetQuad(play, &this->lightRaysColliders[i], &this->dyna.actor, &sLightRaysCollidersInit[i]); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Ikana_Mirror/func_80B7FA9C.s") + BgIkanaMirror_SetQuadVertices(this); + this->lightAbsorptionTexScroll = Lib_SegmentedToVirtual(&gStoneTowerTempleMirrorLightAbsorptionTexAnim); + this->lightEmissionTexScroll = Lib_SegmentedToVirtual(&gStoneTowerTempleMirrorLightEmissionTexAnim); + BgIkanaMirror_SetupWait(this); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Ikana_Mirror/func_80B7FB84.s") +void BgIkanaMirror_Destroy(Actor* thisx, PlayState* play) { + BgIkanaMirror* this = THIS; + s32 i; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Ikana_Mirror/func_80B7FBA4.s") + DynaPoly_DeleteBgActor(play, &play->colCtx.dyna, this->dyna.bgId); + Collider_DestroyTris(play, &this->mirrorCollider); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Ikana_Mirror/BgIkanaMirror_Update.s") + for (i = 0; i < ARRAY_COUNT(this->lightRaysColliders); i++) { + Collider_DestroyQuad(play, &this->lightRaysColliders[i]); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Ikana_Mirror/BgIkanaMirror_Draw.s") +void BgIkanaMirror_SetupWait(BgIkanaMirror* this) { + this->isEmittingLight = 0; + this->actionFunc = BgIkanaMirror_Wait; +} + +/** + * Charges the mirror with light, increment the alpha value for the light absorption textures and decrement the alpha + * value for the light emission textures. + */ +void BgIkanaMirror_Wait(BgIkanaMirror* this, PlayState* play) { + s8 isEmittingLight; + s32 startEmittingLight = false; + + // The light emission texture gradually fades. + if (this->lightEmissionAlpha > 100) { + this->lightEmissionAlpha -= 100; + } else { + this->lightEmissionAlpha = 0; + } + + // This checks if light is touching the mirror. + if (this->mirrorCollider.base.acFlags & AC_HIT) { + this->mirrorCollider.base.acFlags &= ~AC_HIT; + this->isEmittingLight = 0; + + if (this->lightRayCharge < 400) { + this->lightRayCharge++; + } + + if (this->lightAbsorptionAlpha < 195) { + this->lightAbsorptionAlpha += 60; + } else { + this->lightAbsorptionAlpha = 255; + } + + } else { + isEmittingLight = this->isEmittingLight; + + if (isEmittingLight > 0) { + startEmittingLight = true; + } else if (this->lightRayCharge > 0) { + this->isEmittingLight = isEmittingLight + 1; + } + } + + if (startEmittingLight) { + BgIkanaMirror_SetupEmitLight(this); + } else { + CollisionCheck_SetAC(play, &play->colChkCtx, &this->mirrorCollider.base); + } +} + +void BgIkanaMirror_SetupEmitLight(BgIkanaMirror* this) { + this->dyna.actor.flags |= ACTOR_FLAG_20; + this->actionFunc = BgIkanaMirror_EmitLight; +} + +/** + * Depletes the mirror's light and release it, increase alpha value for the light + * emission textures and decrease the alpha value for the light absorption textures. + */ +void BgIkanaMirror_EmitLight(BgIkanaMirror* this, PlayState* play) { + s32 i; + + for (i = 0; i < ARRAY_COUNT(this->lightRaysColliders); i++) { + if (this->lightRaysColliders[i].base.atFlags & AT_HIT) { + this->lightRaysColliders[i].base.atFlags &= ~AT_HIT; + } + } + + if (this->lightEmissionAlpha < 155) { + this->lightEmissionAlpha += 100; + } else { + this->lightEmissionAlpha = 255; + } + + if (this->lightAbsorptionAlpha > 60) { + this->lightAbsorptionAlpha -= 60; + } else { + this->lightAbsorptionAlpha = 0; + } + + if (this->lightRayCharge > 0) { + this->lightRayCharge--; + + for (i = 0; i < ARRAY_COUNT(this->lightRaysColliders); i++) { + CollisionCheck_SetAT(play, &play->colChkCtx, &this->lightRaysColliders[i].base); + } + + } else { + this->dyna.actor.flags &= ~ACTOR_FLAG_20; + BgIkanaMirror_SetupWait(this); + } +} + +void BgIkanaMirror_Update(Actor* thisx, PlayState* play) { + BgIkanaMirror* this = THIS; + + this->actionFunc(this, play); +} + +void BgIkanaMirror_Draw(Actor* thisx, PlayState* play) { + s32 pad; + BgIkanaMirror* this = THIS; + + OPEN_DISPS(play->state.gfxCtx); + func_8012C28C(play->state.gfxCtx); + func_8012C2DC(play->state.gfxCtx); + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_OPA_DISP++, gStoneTowerTempleMirrorDL); + + if (this->lightAbsorptionAlpha > 0) { + AnimatedMat_Draw(play, this->lightAbsorptionTexScroll); + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0x80, 255, 255, 255, this->lightAbsorptionAlpha); + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_XLU_DISP++, gStoneTowerTempleMirrorLightAbsorptionDL); + } + + if (this->lightEmissionAlpha > 0) { + f32 alphaFraction = this->lightEmissionAlpha * (1.0f / 255.0f); + s32 primColorAlpha = (s32)(alphaFraction * 123.0f); + s32 envColorAlpha = (s32)(alphaFraction * 185.0f); + + AnimatedMat_Draw(play, this->lightEmissionTexScroll); + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0x80, 255, 255, 255, primColorAlpha); + gDPSetEnvColor(POLY_XLU_DISP++, 215, 215, 255, envColorAlpha); + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_XLU_DISP++, gStoneTowerTempleMirrorLightEmissionDL); + } + + CLOSE_DISPS(play->state.gfxCtx); +} diff --git a/src/overlays/actors/ovl_Bg_Ikana_Mirror/z_bg_ikana_mirror.h b/src/overlays/actors/ovl_Bg_Ikana_Mirror/z_bg_ikana_mirror.h index fc50c760d..5bd272480 100644 --- a/src/overlays/actors/ovl_Bg_Ikana_Mirror/z_bg_ikana_mirror.h +++ b/src/overlays/actors/ovl_Bg_Ikana_Mirror/z_bg_ikana_mirror.h @@ -5,15 +5,20 @@ struct BgIkanaMirror; -typedef void (*BgIkanaMirrorActionFunc)(struct BgIkanaMirror*, GlobalContext*); +typedef void (*BgIkanaMirrorActionFunc)(struct BgIkanaMirror*, PlayState*); typedef struct BgIkanaMirror { - /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x474]; - /* 0x05B8 */ BgIkanaMirrorActionFunc actionFunc; - /* 0x05BC */ char unk_5BC[0x10]; + /* 0x000 */ DynaPolyActor dyna; + /* 0x15C */ ColliderTris mirrorCollider; + /* 0x17C */ ColliderTrisElement mirrorColliderElements[9]; + /* 0x4B8 */ ColliderQuad lightRaysColliders[2]; + /* 0x5B8 */ BgIkanaMirrorActionFunc actionFunc; + /* 0x5BC */ AnimatedMaterial* lightAbsorptionTexScroll; + /* 0x5C0 */ AnimatedMaterial* lightEmissionTexScroll; + /* 0x5C4 */ s16 lightRayCharge; + /* 0x5C6 */ u8 lightAbsorptionAlpha; + /* 0x5C7 */ u8 lightEmissionAlpha; + /* 0x5C8 */ s8 isEmittingLight; } BgIkanaMirror; // size = 0x5CC -extern const ActorInit Bg_Ikana_Mirror_InitVars; - #endif // Z_BG_IKANA_MIRROR_H diff --git a/src/overlays/actors/ovl_Bg_Ikana_Ray/z_bg_ikana_ray.c b/src/overlays/actors/ovl_Bg_Ikana_Ray/z_bg_ikana_ray.c index d0ec42522..f4d964817 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 @@ -11,15 +11,15 @@ #define THIS ((BgIkanaRay*)thisx) -void BgIkanaRay_Init(Actor* thisx, GlobalContext* globalCtx); -void BgIkanaRay_Destroy(Actor* thisx, GlobalContext* globalCtx); -void BgIkanaRay_Update(Actor* thisx, GlobalContext* globalCtx); -void BgIkanaRay_Draw(Actor* thisx, GlobalContext* globalCtx); +void BgIkanaRay_Init(Actor* thisx, PlayState* play); +void BgIkanaRay_Destroy(Actor* thisx, PlayState* play); +void BgIkanaRay_Update(Actor* thisx, PlayState* play); +void BgIkanaRay_Draw(Actor* thisx, PlayState* play); void BgIkanaRay_SetDeactivated(BgIkanaRay* this); -void BgIkanaRay_UpdateCheckForActivation(BgIkanaRay* this, GlobalContext* globalCtx); +void BgIkanaRay_UpdateCheckForActivation(BgIkanaRay* this, PlayState* play); void BgIkanaRay_SetActivated(BgIkanaRay* this); -void BgIkanaRay_UpdateActivated(BgIkanaRay* this, GlobalContext* globalCtx); +void BgIkanaRay_UpdateActivated(BgIkanaRay* this, PlayState* play); const ActorInit Bg_Ikana_Ray_InitVars = { ACTOR_BG_IKANA_RAY, @@ -60,29 +60,29 @@ static InitChainEntry sInitChain[] = { ICHAIN_VEC3F_DIV1000(scale, 100, ICHAIN_STOP), }; -void BgIkanaRay_Init(Actor* thisx, GlobalContext* globalCtx) { +void BgIkanaRay_Init(Actor* thisx, PlayState* play) { BgIkanaRay* this = THIS; ColliderCylinder* collision = &this->collision; Actor_ProcessInitChain(&this->actor, sInitChain); - Collider_InitCylinder(globalCtx, collision); - Collider_SetCylinder(globalCtx, collision, &this->actor, &sCylinderInit); + Collider_InitCylinder(play, collision); + Collider_SetCylinder(play, collision, &this->actor, &sCylinderInit); Collider_UpdateCylinder(&this->actor, &this->collision); this->animatedTextures = Lib_SegmentedToVirtual(object_ikana_obj_Matanimheader_001228); - if (Flags_GetSwitch(globalCtx, BGIKANARAY_GET_SWITCH_FLAG(&this->actor))) { + if (Flags_GetSwitch(play, BGIKANARAY_GET_SWITCH_FLAG(&this->actor))) { BgIkanaRay_SetActivated(this); } else { BgIkanaRay_SetDeactivated(this); } } -void BgIkanaRay_Destroy(Actor* thisx, GlobalContext* globalCtx) { +void BgIkanaRay_Destroy(Actor* thisx, PlayState* play) { BgIkanaRay* this = THIS; ColliderCylinder* collision = &this->collision; - Collider_DestroyCylinder(globalCtx, collision); + Collider_DestroyCylinder(play, collision); } void BgIkanaRay_SetDeactivated(BgIkanaRay* this) { @@ -91,8 +91,8 @@ void BgIkanaRay_SetDeactivated(BgIkanaRay* this) { this->actionFunc = BgIkanaRay_UpdateCheckForActivation; } -void BgIkanaRay_UpdateCheckForActivation(BgIkanaRay* this, GlobalContext* globalCtx) { - if (Flags_GetSwitch(globalCtx, BGIKANARAY_GET_SWITCH_FLAG(&this->actor))) { +void BgIkanaRay_UpdateCheckForActivation(BgIkanaRay* this, PlayState* play) { + if (Flags_GetSwitch(play, BGIKANARAY_GET_SWITCH_FLAG(&this->actor))) { BgIkanaRay_SetActivated(this); } } @@ -103,19 +103,19 @@ void BgIkanaRay_SetActivated(BgIkanaRay* this) { this->actionFunc = BgIkanaRay_UpdateActivated; } -void BgIkanaRay_UpdateActivated(BgIkanaRay* this, GlobalContext* globalCtx) { - CollisionCheck_SetAT(globalCtx, &globalCtx->colChkCtx, &this->collision.base); +void BgIkanaRay_UpdateActivated(BgIkanaRay* this, PlayState* play) { + CollisionCheck_SetAT(play, &play->colChkCtx, &this->collision.base); } -void BgIkanaRay_Update(Actor* thisx, GlobalContext* globalCtx) { +void BgIkanaRay_Update(Actor* thisx, PlayState* play) { BgIkanaRay* this = THIS; - this->actionFunc(this, globalCtx); + this->actionFunc(this, play); } -void BgIkanaRay_Draw(Actor* thisx, GlobalContext* globalCtx) { +void BgIkanaRay_Draw(Actor* thisx, PlayState* play) { BgIkanaRay* this = THIS; - AnimatedMat_Draw(globalCtx, this->animatedTextures); - Gfx_DrawDListXlu(globalCtx, object_ikana_obj_DL_001100); + AnimatedMat_Draw(play, this->animatedTextures); + Gfx_DrawDListXlu(play, object_ikana_obj_DL_001100); } 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 7c8d8c369..9aa4f89d4 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,7 +5,7 @@ struct BgIkanaRay; -typedef void (*BgIkanaRayActionFunc)(struct BgIkanaRay*, GlobalContext*); +typedef void (*BgIkanaRayActionFunc)(struct BgIkanaRay*, PlayState*); #define BGIKANARAY_GET_SWITCH_FLAG(thisx) ((thisx)->params & 0x7F) 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 a3b234392..94eec2c1d 100644 --- a/src/overlays/actors/ovl_Bg_Ikana_Rotaryroom/z_bg_ikana_rotaryroom.c +++ b/src/overlays/actors/ovl_Bg_Ikana_Rotaryroom/z_bg_ikana_rotaryroom.c @@ -13,24 +13,24 @@ #define THIS ((BgIkanaRotaryroom*)thisx) -void BgIkanaRotaryroom_Init(Actor* thisx, GlobalContext* globalCtx); -void BgIkanaRotaryroom_Destroy(Actor* thisx, GlobalContext* globalCtx); -void BgIkanaRotaryroom_Update(Actor* thisx, GlobalContext* globalCtx); -void BgIkanaRotaryroom_Draw(Actor* thisx, GlobalContext* globalCtx); +void BgIkanaRotaryroom_Init(Actor* thisx, PlayState* play); +void BgIkanaRotaryroom_Destroy(Actor* thisx, PlayState* play); +void BgIkanaRotaryroom_Update(Actor* thisx, PlayState* play); +void BgIkanaRotaryroom_Draw(Actor* thisx, PlayState* play); -void func_80B814B8(BgIkanaRotaryroom* this, GlobalContext* globalCtx); +void func_80B814B8(BgIkanaRotaryroom* this, PlayState* play); void func_80B818B4(BgIkanaRotaryroom* this); -void func_80B818C8(Actor* thisx, GlobalContext* globalCtx); +void func_80B818C8(Actor* thisx, PlayState* play); void func_80B81978(BgIkanaRotaryroom* this); -void func_80B8198C(Actor* thisx, GlobalContext* globalCtx); +void func_80B8198C(Actor* thisx, PlayState* play); void func_80B819DC(BgIkanaRotaryroom* this); -void func_80B819F0(Actor* thisx, GlobalContext* globalCtx); +void func_80B819F0(Actor* thisx, PlayState* play); void func_80B81A64(BgIkanaRotaryroom* this); -void func_80B81A80(Actor* thisx, GlobalContext* globalCtx); +void func_80B81A80(Actor* thisx, PlayState* play); void func_80B81B84(BgIkanaRotaryroom* this); -void func_80B81BA0(Actor* thisx, GlobalContext* globalCtx); +void func_80B81BA0(Actor* thisx, PlayState* play); void func_80B81DAC(BgIkanaRotaryroom* this); -void func_80B81DC8(Actor* thisx, GlobalContext* globalCtx); +void func_80B81DC8(Actor* thisx, PlayState* play); const ActorInit Bg_Ikana_Rotaryroom_InitVars = { ACTOR_BG_IKANA_ROTARYROOM, @@ -78,7 +78,7 @@ static ColliderJntSphInit sJntSphInit1 = { OC2_NONE, COLSHAPE_JNTSPH, }, - 2, + ARRAY_COUNT(sJntSphElementsInit1), sJntSphElementsInit1, }; @@ -105,7 +105,7 @@ static ColliderJntSphInit sJntSphInit2 = { OC2_NONE, COLSHAPE_JNTSPH, }, - 1, + ARRAY_COUNT(sJntSphElementsInit2), sJntSphElementsInit2, }; @@ -140,8 +140,8 @@ CollisionHeader* D_80B82218[] = { &object_ikana_obj_Colheader_006368, &object_ik void func_80B802E0(BgIkanaRotaryroom* this) { 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); Matrix_Scale(this->dyna.actor.scale.x, this->dyna.actor.scale.y, this->dyna.actor.scale.z, MTXMODE_APPLY); Collider_UpdateSpheres(0, &this->collider); @@ -160,28 +160,28 @@ void func_80B80358(Vec3f* arg0) { arg0->z = (s32)arg0->z; } -void func_80B80440(BgIkanaRotaryroom* this, GlobalContext* globalCtx) { +void func_80B80440(BgIkanaRotaryroom* this, PlayState* play) { s32 pad; Vec3f sp50; - Matrix_StatePush(); - Matrix_SetStateRotationAndTranslation(this->dyna.actor.world.pos.x, this->dyna.actor.world.pos.y, - this->dyna.actor.world.pos.z, &this->dyna.actor.shape.rot); - if (Flags_GetSwitch(globalCtx, BGIKANAROTARYROOM_GET_7F00(&this->dyna.actor))) { - Matrix_InsertTranslation(D_80B82178.x, D_80B82178.y, D_80B82178.z, MTXMODE_APPLY); + 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(play, BGIKANAROTARYROOM_GET_7F00(&this->dyna.actor))) { + Matrix_Translate(D_80B82178.x, D_80B82178.y, D_80B82178.z, MTXMODE_APPLY); } else { - Matrix_InsertTranslation(D_80B8216C.x, D_80B8216C.y, D_80B8216C.z, MTXMODE_APPLY); + Matrix_Translate(D_80B8216C.x, D_80B8216C.y, D_80B8216C.z, MTXMODE_APPLY); } - Matrix_GetStateTranslation(&sp50); + 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, + &play->actorCtx, play, ACTOR_BG_IKANA_BLOCK, sp50.x, sp50.y, sp50.z, this->dyna.actor.shape.rot.x, this->dyna.actor.shape.rot.y, this->dyna.actor.shape.rot.z, -1, ActorCutscene_GetAdditionalCutscene(this->dyna.actor.cutscene), this->dyna.actor.unk20, NULL); - Matrix_StatePop(); + Matrix_Pop(); } -void func_80B80550(BgIkanaRotaryroom* this, GlobalContext* globalCtx) { +void func_80B80550(BgIkanaRotaryroom* this, PlayState* play) { s32 pad; s32 spC8 = BGIKANAROTARYROOM_GET_1(&this->dyna.actor); s32 spC4; @@ -193,19 +193,19 @@ void func_80B80550(BgIkanaRotaryroom* this, GlobalContext* globalCtx) { MtxF sp68; Vec3s sp60; - if (Flags_GetSwitch(globalCtx, BGIKANAROTARYROOM_GET_FE(&this->dyna.actor))) { + if (Flags_GetSwitch(play, BGIKANAROTARYROOM_GET_FE(&this->dyna.actor))) { spC4 = 1; } else { spC4 = 0; } - actor = globalCtx->actorCtx.actorLists[ACTORCAT_DOOR].first; - Matrix_StatePush(); + actor = play->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_SetStateRotationAndTranslation(this->dyna.actor.world.pos.x, this->dyna.actor.world.pos.y, - this->dyna.actor.world.pos.z, &sp60); + Matrix_SetTranslateRotateYXZ(this->dyna.actor.world.pos.x, this->dyna.actor.world.pos.y, + this->dyna.actor.world.pos.z, &sp60); while (actor != NULL) { if (actor->id == ACTOR_DOOR_SHUTTER) { @@ -215,27 +215,27 @@ void func_80B80550(BgIkanaRotaryroom* this, GlobalContext* globalCtx) { ptr = &D_80B82184[spC8][i]; if ((Math3D_Vec3fDistSq(&spB4, &D_80B82184[spC8][i].unk_04) < SQ(250.0f)) && - ((ptr->unk_00 ^ spC4) && (ptr->unk_01 == 0U))) { - Matrix_StatePush(); - Matrix_InsertTranslation(spB4.x, spB4.y, spB4.z, MTXMODE_APPLY); - Matrix_RotateY(actor->shape.rot.y - this->dyna.actor.home.rot.y, MTXMODE_APPLY); - Matrix_InsertXRotation_s(actor->shape.rot.x - this->dyna.actor.home.rot.x, MTXMODE_APPLY); - Matrix_InsertZRotation_s(actor->shape.rot.z - this->dyna.actor.home.rot.z, MTXMODE_APPLY); - Matrix_GetStateTranslation(&actor->world.pos); + ((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_CopyCurrentState(&sp68); - func_8018219C(&sp68, &actor->shape.rot, 0); - Matrix_StatePop(); + Matrix_Get(&sp68); + Matrix_MtxFToYXZRot(&sp68, &actor->shape.rot, false); + Matrix_Pop(); } } } actor = actor->next; } - Matrix_StatePop(); + Matrix_Pop(); } -BgIkanaRotaryroomStruct4* func_80B80778(BgIkanaRotaryroom* this, GlobalContext* globalCtx, Actor* arg2) { +BgIkanaRotaryroomStruct4* func_80B80778(BgIkanaRotaryroom* this, PlayState* play, Actor* arg2) { s32 i; Vec3f sp68; s32 pad[2]; @@ -246,69 +246,68 @@ BgIkanaRotaryroomStruct4* func_80B80778(BgIkanaRotaryroom* this, GlobalContext* if (1) {} if (arg2->id == ACTOR_DOOR_SHUTTER) { - Matrix_StatePush(); + Matrix_Push(); for (i = 0; i < ARRAY_COUNT(D_80B82184); i++) { ptr = &D_80B82184[temp_s3][i]; if ((ptr->unk_01 == 0) && - (Matrix_SetStateRotationAndTranslation(this->dyna.actor.world.pos.x, this->dyna.actor.world.pos.y, - this->dyna.actor.world.pos.z, &this->dyna.actor.shape.rot), - Matrix_MultiplyVector3fByState(&ptr->unk_04, &sp68), - (Math3D_Vec3fDistSq(&arg2->world.pos, &sp68) < SQ(250.0f)))) { + (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; } } - Matrix_StatePop(); + Matrix_Pop(); } return sp58; } -void func_80B80894(BgIkanaRotaryroom* this, GlobalContext* globalCtx) { +void func_80B80894(BgIkanaRotaryroom* this, PlayState* play) { s32 pad[7]; Actor* actor = this->unk_204.unk_00; s32 i; - Matrix_StatePush(); + Matrix_Push(); - Matrix_InsertZRotation_s(-this->dyna.actor.shape.rot.z, MTXMODE_NEW); - Matrix_InsertXRotation_s(-this->dyna.actor.shape.rot.x, MTXMODE_APPLY); - Matrix_RotateY(-this->dyna.actor.shape.rot.y, MTXMODE_APPLY); - Matrix_InsertTranslation(-this->dyna.actor.world.pos.x, -this->dyna.actor.world.pos.y, - -this->dyna.actor.world.pos.z, MTXMODE_APPLY); + 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); if (actor != NULL) { - Matrix_StatePush(); + Matrix_Push(); - Matrix_InsertTranslation(actor->world.pos.x, actor->world.pos.y, actor->world.pos.z, MTXMODE_APPLY); - Matrix_RotateY(actor->shape.rot.y, MTXMODE_APPLY); - Matrix_InsertXRotation_s(actor->shape.rot.x, MTXMODE_APPLY); - Matrix_InsertZRotation_s(actor->shape.rot.z, MTXMODE_APPLY); - Matrix_CopyCurrentState(&this->unk_204.unk_04); + 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); - Matrix_StatePop(); + Matrix_Pop(); } for (i = 0; i < ARRAY_COUNT(this->unk_248); i++) { this->unk_248[i].unk_00 = NULL; } - actor = globalCtx->actorCtx.actorLists[ACTORCAT_DOOR].first; + actor = play->actorCtx.actorLists[ACTORCAT_DOOR].first; i = 0; while (actor != NULL) { - if (func_80B80778(this, globalCtx, actor) && (i < 2)) { + if (func_80B80778(this, play, actor) && (i < 2)) { this->unk_248[i].unk_00 = actor; - Matrix_StatePush(); + Matrix_Push(); - Matrix_InsertTranslation(actor->world.pos.x, actor->world.pos.y, actor->world.pos.z, MTXMODE_APPLY); - Matrix_RotateY(actor->shape.rot.y, MTXMODE_APPLY); - Matrix_InsertXRotation_s(actor->shape.rot.x, MTXMODE_APPLY); - Matrix_InsertZRotation_s(actor->shape.rot.z, MTXMODE_APPLY); - Matrix_CopyCurrentState(&this->unk_248[i].unk_04); + 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); - Matrix_StatePop(); + Matrix_Pop(); i++; } actor = actor->next; @@ -318,21 +317,21 @@ void func_80B80894(BgIkanaRotaryroom* this, GlobalContext* globalCtx) { this->unk_2D0[i].unk_00 = NULL; } - actor = globalCtx->actorCtx.actorLists[ACTORCAT_ITEMACTION].first; + actor = play->actorCtx.actorLists[ACTORCAT_ITEMACTION].first; i = 0; while (actor != NULL) { if ((actor->id == ACTOR_EN_TORCH2) && (actor->update != NULL) && (i < ARRAY_COUNT(this->unk_2D0))) { this->unk_2D0[i].unk_00 = actor; - Matrix_StatePush(); + Matrix_Push(); - Matrix_InsertTranslation(actor->world.pos.x, actor->world.pos.y, actor->world.pos.z, MTXMODE_APPLY); - Matrix_RotateY(actor->shape.rot.y, MTXMODE_APPLY); - Matrix_InsertXRotation_s(actor->shape.rot.x, MTXMODE_APPLY); - Matrix_InsertZRotation_s(actor->shape.rot.z, MTXMODE_APPLY); - Matrix_CopyCurrentState(&this->unk_2D0[i].unk_04); + Matrix_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_StatePop(); + Matrix_Pop(); i++; } actor = actor->next; @@ -342,7 +341,7 @@ void func_80B80894(BgIkanaRotaryroom* this, GlobalContext* globalCtx) { this->unk_3E0[i].unk_00 = NULL; } - actor = globalCtx->actorCtx.actorLists[ACTORCAT_ENEMY].first; + actor = play->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))) { @@ -350,39 +349,39 @@ void func_80B80894(BgIkanaRotaryroom* this, GlobalContext* globalCtx) { this->unk_3E0[i].unk_44 = actor->shape.rot; this->unk_3E0[i].unk_4C = 0.0f; - Matrix_StatePush(); + Matrix_Push(); - Matrix_InsertTranslation(actor->world.pos.x, actor->world.pos.y, actor->world.pos.z, MTXMODE_APPLY); - Matrix_RotateY(actor->shape.rot.y, MTXMODE_APPLY); - Matrix_InsertXRotation_s(actor->shape.rot.x, MTXMODE_APPLY); - Matrix_InsertZRotation_s(actor->shape.rot.z, MTXMODE_APPLY); - Matrix_CopyCurrentState(&this->unk_3E0[i].unk_04); + Matrix_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_StatePop(); + Matrix_Pop(); i++; } actor = actor->next; } - actor = &GET_PLAYER(globalCtx)->actor; + actor = &GET_PLAYER(play)->actor; if (actor->update != NULL) { this->unk_520.unk_40 = actor->shape.rot; - Matrix_StatePush(); + Matrix_Push(); - Matrix_InsertTranslation(actor->world.pos.x, actor->world.pos.y, actor->world.pos.z, MTXMODE_APPLY); - Matrix_RotateY(actor->shape.rot.y, MTXMODE_APPLY); - Matrix_InsertXRotation_s(actor->shape.rot.x, MTXMODE_APPLY); - Matrix_InsertZRotation_s(actor->shape.rot.z, MTXMODE_APPLY); - Matrix_CopyCurrentState(&this->unk_520.unk_00); + Matrix_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_StatePop(); + Matrix_Pop(); } - Matrix_StatePop(); + Matrix_Pop(); } -void func_80B80C88(BgIkanaRotaryroom* this, GlobalContext* globalCtx) { +void func_80B80C88(BgIkanaRotaryroom* this, PlayState* play) { s32 pad[5]; BgIkanaBlock* ikanaBlock = (BgIkanaBlock*)this->unk_204.unk_00; Player* player; @@ -392,116 +391,117 @@ void func_80B80C88(BgIkanaRotaryroom* this, GlobalContext* globalCtx) { s32 i; MtxF sp3C; - Matrix_StatePush(); - Matrix_SetStateRotationAndTranslation(this->dyna.actor.world.pos.x, this->dyna.actor.world.pos.y, - this->dyna.actor.world.pos.z, &this->dyna.actor.shape.rot); + 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_StatePush(); + Matrix_Push(); - Matrix_InsertMatrix(&this->unk_204.unk_04, MTXMODE_APPLY); - Matrix_GetStateTranslation(&ikanaBlock->actor.world.pos); - func_80B80358(&ikanaBlock->actor.world.pos); - Matrix_CopyCurrentState(&sp3C); - func_8018219C(&sp3C, &ikanaBlock->actor.shape.rot, 0); + Matrix_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_StatePop(); + Matrix_Pop(); } for (i = 0; i < ARRAY_COUNT(this->unk_248); i++) { ptr = this->unk_248[i].unk_00; if (ptr != NULL) { - Matrix_StatePush(); + Matrix_Push(); - Matrix_InsertMatrix(&this->unk_248[i].unk_04, MTXMODE_APPLY); - Matrix_GetStateTranslation(&ptr->world.pos); + Matrix_Mult(&this->unk_248[i].unk_04, MTXMODE_APPLY); + Matrix_MultZero(&ptr->world.pos); func_80B80358(&ptr->world.pos); - Matrix_CopyCurrentState(&sp3C); - func_8018219C(&sp3C, &ptr->shape.rot, 0); + Matrix_Get(&sp3C); + Matrix_MtxFToYXZRot(&sp3C, &ptr->shape.rot, false); - Matrix_StatePop(); + Matrix_Pop(); } } for (i = 0; i < ARRAY_COUNT(this->unk_2D0); i++) { ptr2 = this->unk_2D0[i].unk_00; if (ptr2 != NULL) { - Matrix_StatePush(); + Matrix_Push(); - Matrix_InsertMatrix(&this->unk_2D0[i].unk_04, MTXMODE_APPLY); - Matrix_GetStateTranslation(&ptr2->world.pos); + Matrix_Mult(&this->unk_2D0[i].unk_04, MTXMODE_APPLY); + Matrix_MultZero(&ptr2->world.pos); func_80B80358(&ptr2->world.pos); - Matrix_CopyCurrentState(&sp3C); - func_8018219C(&sp3C, &ptr2->shape.rot, 0); + Matrix_Get(&sp3C); + Matrix_MtxFToYXZRot(&sp3C, &ptr2->shape.rot, false); - Matrix_StatePop(); + Matrix_Pop(); } } for (i = 0; i < ARRAY_COUNT(this->unk_3E0); i++) { ptr3 = this->unk_3E0[i].unk_00; if (ptr3 != NULL) { - Matrix_StatePush(); + Matrix_Push(); - Matrix_InsertMatrix(&this->unk_3E0[i].unk_04, MTXMODE_APPLY); - Matrix_GetStateTranslation(&ptr3->world.pos); + Matrix_Mult(&this->unk_3E0[i].unk_04, MTXMODE_APPLY); + Matrix_MultZero(&ptr3->world.pos); func_80B80358(&ptr3->world.pos); - Matrix_CopyCurrentState(&sp3C); - func_8018219C(&sp3C, &ptr3->shape.rot, 0); + Matrix_Get(&sp3C); + Matrix_MtxFToYXZRot(&sp3C, &ptr3->shape.rot, false); - Matrix_StatePop(); + Matrix_Pop(); } } - player = GET_PLAYER(globalCtx); + player = GET_PLAYER(play); if (player != NULL) { - Matrix_StatePush(); + Matrix_Push(); - Matrix_InsertMatrix(&this->unk_520.unk_00, MTXMODE_APPLY); - Matrix_GetStateTranslation(&player->actor.world.pos); + 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_CopyCurrentState(&sp3C); - func_8018219C(&sp3C, &player->actor.shape.rot, 0); + Matrix_Get(&sp3C); + Matrix_MtxFToYXZRot(&sp3C, &player->actor.shape.rot, false); - Matrix_StatePop(); + Matrix_Pop(); player->actor.freezeTimer = 2; } - Matrix_StatePop(); + Matrix_Pop(); } -s32 func_80B80F08(BgIkanaRotaryroom* this, GlobalContext* globalCtx) { +s32 func_80B80F08(BgIkanaRotaryroom* this, PlayState* play) { s32 pad; - BgIkanaBlock* sp40 = (BgIkanaBlock*)this->unk_204.unk_00; + BgIkanaBlock* ikanaBlock = (BgIkanaBlock*)this->unk_204.unk_00; Vec3f sp34; Vec3f sp28; s32 sp24 = false; - if (sp40 != NULL) { - Matrix_StatePush(); + if (ikanaBlock != NULL) { + Matrix_Push(); - Matrix_SetStateRotationAndTranslation(this->dyna.actor.world.pos.x, this->dyna.actor.world.pos.y, - this->dyna.actor.world.pos.z, &this->dyna.actor.shape.rot); - Matrix_InsertTranslation(D_80B82178.x, D_80B82178.y, D_80B82178.z, MTXMODE_APPLY); - Matrix_GetStateTranslation(&sp34); - Matrix_SetStateRotationAndTranslation(sp40->actor.world.pos.x, sp40->actor.world.pos.y + sp40->unk_170, - sp40->actor.world.pos.z, &sp40->actor.shape.rot); - Matrix_GetStateTranslation(&sp28); + Matrix_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_StatePop(); + Matrix_Pop(); if (Math3D_Vec3fDistSq(&sp34, &sp28) < 3.0f) { - if (!Flags_GetSwitch(globalCtx, BGIKANAROTARYROOM_GET_7F00(&this->dyna.actor))) { + if (!Flags_GetSwitch(play, BGIKANAROTARYROOM_GET_7F00(&this->dyna.actor))) { sp24 = true; } - Flags_SetSwitch(globalCtx, BGIKANAROTARYROOM_GET_7F00(&this->dyna.actor)); + Flags_SetSwitch(play, BGIKANAROTARYROOM_GET_7F00(&this->dyna.actor)); } } return sp24; } -void func_80B81010(BgIkanaRotaryroom* this, GlobalContext* globalCtx) { +void func_80B81010(BgIkanaRotaryroom* this, PlayState* play) { s32 pad; f32 temp_f0; s32 temp_s2; @@ -538,7 +538,7 @@ void func_80B81010(BgIkanaRotaryroom* this, GlobalContext* globalCtx) { sp84.y = ptr->prevPos.y + 50.0f; sp84.z = ptr->prevPos.z; - temp_f0 = BgCheck_EntityRaycastFloor5_2(globalCtx, &globalCtx->colCtx, &sp7C, &sp78, NULL, &sp84); + temp_f0 = BgCheck_EntityRaycastFloor5_2(play, &play->colCtx, &sp7C, &sp78, NULL, &sp84); if (ptr->world.pos.y <= temp_f0) { ptr->world.pos.y = temp_f0; } else { @@ -568,9 +568,9 @@ void func_80B81010(BgIkanaRotaryroom* this, GlobalContext* globalCtx) { } } -void func_80B81234(BgIkanaRotaryroom* this, GlobalContext* globalCtx) { +void func_80B81234(BgIkanaRotaryroom* this, PlayState* play) { s32 pad[2]; - Player* player = GET_PLAYER(globalCtx); + Player* player = GET_PLAYER(play); BgIkanaRotaryroomStruct3* ptr; s32 sp64; Vec3f sp58; @@ -603,16 +603,16 @@ void func_80B81234(BgIkanaRotaryroom* this, GlobalContext* globalCtx) { } ptr->unk_4C.y += ptr->unk_48; - Matrix_StatePush(); + Matrix_Push(); - Matrix_RotateY(player->actor.shape.rot.y, MTXMODE_NEW); - Matrix_InsertXRotation_s(player->actor.shape.rot.x, MTXMODE_APPLY); - Matrix_InsertZRotation_s(player->actor.shape.rot.z, MTXMODE_APPLY); - Matrix_GetStateTranslationAndScaledY(sp44, &sp4C); + Matrix_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_StatePop(); + Matrix_Pop(); - temp_f0 = BgCheck_EntityRaycastFloor5_2(globalCtx, &globalCtx->colCtx, &sp40, &sp3C, NULL, &sp58); + temp_f0 = BgCheck_EntityRaycastFloor5_2(play, &play->colCtx, &sp40, &sp3C, NULL, &sp58); if (ptr->unk_4C.y <= temp_f0) { ptr->unk_4C.y = temp_f0; } else { @@ -641,15 +641,15 @@ void func_80B81234(BgIkanaRotaryroom* this, GlobalContext* globalCtx) { } } -void func_80B814B8(BgIkanaRotaryroom* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); +void func_80B814B8(BgIkanaRotaryroom* this, PlayState* play) { + Player* player = GET_PLAYER(play); if (ActorCutscene_GetCurrentIndex() == this->dyna.actor.cutscene) { if (player->actor.bgCheckFlags & 0x100) { func_800B8E58(player, NA_SE_VO_LI_DAMAGE_S + player->ageProperties->unk_92); - func_80169EFC(&globalCtx->state); + func_80169EFC(&play->state); func_800B8E58(player, NA_SE_VO_LI_TAKEN_AWAY + player->ageProperties->unk_92); - globalCtx->unk_18845 = 1; + play->unk_18845 = 1; play_sound(NA_SE_OC_ABYSS); this->actionFunc = NULL; } @@ -658,31 +658,31 @@ void func_80B814B8(BgIkanaRotaryroom* this, GlobalContext* globalCtx) { } } -void func_80B81570(BgIkanaRotaryroom* this, GlobalContext* globalCtx) { +void func_80B81570(BgIkanaRotaryroom* this, PlayState* play) { s32 i; Vec3f sp70; Vec3f sp64; s32 pad; s32 pad2; - Matrix_StatePush(); - Matrix_RotateY(this->dyna.actor.shape.rot.y, MTXMODE_NEW); + 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_MultiplyVector3fByState(&sp64, &sp70); + 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); + Actor_Spawn(&play->actorCtx, play, ACTOR_EN_WATER_EFFECT, sp70.x, sp70.y, sp70.z, 0, 0, 0, 1); } - Matrix_StatePop(); + Matrix_Pop(); } s32 func_80B816A4(BgIkanaRotaryroom* this) { @@ -698,27 +698,27 @@ s32 func_80B816A4(BgIkanaRotaryroom* this) { return count; } -void BgIkanaRotaryroom_Init(Actor* thisx, GlobalContext* globalCtx) { +void BgIkanaRotaryroom_Init(Actor* thisx, PlayState* play) { 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))) { + if (Flags_GetSwitch(play, 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]); + DynaPolyActor_LoadMesh(play, &this->dyna, D_80B82218[sp34]); - Collider_InitJntSph(globalCtx, &this->collider); + Collider_InitJntSph(play, &this->collider); if (!sp34) { - Collider_SetJntSph(globalCtx, &this->collider, &this->dyna.actor, &sJntSphInit1, this->colliderElements); + Collider_SetJntSph(play, &this->collider, &this->dyna.actor, &sJntSphInit1, this->colliderElements); } else { - Collider_SetJntSph(globalCtx, &this->collider, &this->dyna.actor, &sJntSphInit2, this->colliderElements); + Collider_SetJntSph(play, &this->collider, &this->dyna.actor, &sJntSphInit2, this->colliderElements); } func_80B802E0(this); @@ -728,41 +728,41 @@ void BgIkanaRotaryroom_Init(Actor* thisx, GlobalContext* globalCtx) { } if (!sp34) { - func_80B80440(this, globalCtx); + func_80B80440(this, play); } else { - func_80B81570(this, globalCtx); + func_80B81570(this, play); } - func_80B80550(this, globalCtx); + func_80B80550(this, play); func_80B818B4(this); } -void BgIkanaRotaryroom_Destroy(Actor* thisx, GlobalContext* globalCtx) { +void BgIkanaRotaryroom_Destroy(Actor* thisx, PlayState* play) { BgIkanaRotaryroom* this = THIS; - DynaPoly_DeleteBgActor(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); - Collider_DestroyJntSph(globalCtx, &this->collider); + DynaPoly_DeleteBgActor(play, &play->colCtx.dyna, this->dyna.bgId); + Collider_DestroyJntSph(play, &this->collider); } void func_80B818B4(BgIkanaRotaryroom* this) { this->unk_200 = func_80B818C8; } -void func_80B818C8(Actor* thisx, GlobalContext* globalCtx) { +void func_80B818C8(Actor* thisx, PlayState* play) { 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); + if (Flags_GetSwitch(play, sp20)) { + Flags_UnsetSwitch(play, sp20); } else { - Flags_SetSwitch(globalCtx, sp20); + Flags_SetSwitch(play, sp20); } func_80B81978(this); } else { - CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + CollisionCheck_SetAC(play, &play->colChkCtx, &this->collider.base); } } @@ -770,7 +770,7 @@ void func_80B81978(BgIkanaRotaryroom* this) { this->unk_200 = func_80B8198C; } -void func_80B8198C(Actor* thisx, GlobalContext* globalCtx) { +void func_80B8198C(Actor* thisx, PlayState* play) { BgIkanaRotaryroom* this = THIS; if (this->unk_204.unk_00 == NULL) { @@ -785,13 +785,13 @@ void func_80B819DC(BgIkanaRotaryroom* this) { this->unk_200 = func_80B819F0; } -void func_80B819F0(Actor* thisx, GlobalContext* globalCtx) { +void func_80B819F0(Actor* thisx, PlayState* play) { BgIkanaRotaryroom* this = THIS; if (ActorCutscene_GetCanPlayNext(this->dyna.actor.cutscene)) { ActorCutscene_StartAndSetUnkLinkFields(this->dyna.actor.cutscene, &this->dyna.actor); if (this->dyna.actor.cutscene >= 0) { - func_800B7298(globalCtx, &this->dyna.actor, 7); + func_800B7298(play, &this->dyna.actor, 7); } func_80B81A64(this); } else { @@ -804,7 +804,7 @@ void func_80B81A64(BgIkanaRotaryroom* this) { this->unk_200 = func_80B81A80; } -void func_80B81A80(Actor* thisx, GlobalContext* globalCtx) { +void func_80B81A80(Actor* thisx, PlayState* play) { BgIkanaRotaryroom* this = THIS; s32 pad; s32 i; @@ -818,7 +818,7 @@ void func_80B81A80(Actor* thisx, GlobalContext* globalCtx) { if (1) {} if (1) {} if (1) {} - func_80B80894(this, globalCtx); + func_80B80894(this, play); for (i = 0; i < ARRAY_COUNT(this->unk_2D0); i++) { ptr = &this->unk_2D0[i]; @@ -829,7 +829,7 @@ void func_80B81A80(Actor* thisx, GlobalContext* globalCtx) { func_80B81B84(this); } else if (this->unk_584 == 15) { - s16 sp26 = Quake_Add(GET_ACTIVE_CAM(globalCtx), 3); + s16 sp26 = Quake_Add(GET_ACTIVE_CAM(play), 3); Quake_SetSpeed(sp26, 0x7B30); Quake_SetQuakeValues(sp26, 6, 0, 100, 0); @@ -842,7 +842,7 @@ void func_80B81B84(BgIkanaRotaryroom* this) { this->unk_200 = func_80B81BA0; } -void func_80B81BA0(Actor* thisx, GlobalContext* globalCtx) { +void func_80B81BA0(Actor* thisx, PlayState* play) { BgIkanaRotaryroom* this = THIS; s32 sp30 = 0; s32 i; @@ -856,14 +856,14 @@ void func_80B81BA0(Actor* thisx, GlobalContext* globalCtx) { thisx->shape.rot.x += 0x1F4; if (!(this->unk_584 & 7)) { - s16 quake = Quake_Add(GET_ACTIVE_CAM(globalCtx), 3); + s16 quake = Quake_Add(GET_ACTIVE_CAM(play), 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 (Flags_GetSwitch(play, BGIKANAROTARYROOM_GET_FE(&this->dyna.actor))) { if (this->dyna.actor.shape.rot.x < 0) { this->dyna.actor.shape.rot.x = -0x8000; sp30 = 1; @@ -873,10 +873,10 @@ void func_80B81BA0(Actor* thisx, GlobalContext* globalCtx) { sp30 = 1; } - func_80B80C88(this, globalCtx); + func_80B80C88(this, play); if (sp30 != 0) { - Player* player = GET_PLAYER(globalCtx); + Player* player = GET_PLAYER(play); BgIkanaRotaryroomStruct1* ptr; BgIkanaBlock* block = (BgIkanaBlock*)this->unk_204.unk_00; @@ -913,7 +913,7 @@ void func_80B81DAC(BgIkanaRotaryroom* this) { this->unk_200 = func_80B81DC8; } -void func_80B81DC8(Actor* thisx, GlobalContext* globalCtx) { +void func_80B81DC8(Actor* thisx, PlayState* play) { s32 pad; BgIkanaRotaryroom* this = THIS; @@ -926,7 +926,7 @@ void func_80B81DC8(Actor* thisx, GlobalContext* globalCtx) { ActorCutscene_Stop(this->dyna.actor.cutscene); func_80B818B4(this); } else if (this->unk_584 == 19) { - s16 quake = Quake_Add(GET_ACTIVE_CAM(globalCtx), 3); + s16 quake = Quake_Add(GET_ACTIVE_CAM(play), 3); Quake_SetSpeed(quake, 0x4E20); Quake_SetQuakeValues(quake, 5, 0, 40, 60); @@ -934,7 +934,7 @@ void func_80B81DC8(Actor* thisx, GlobalContext* globalCtx) { } } -void BgIkanaRotaryroom_Update(Actor* thisx, GlobalContext* globalCtx) { +void BgIkanaRotaryroom_Update(Actor* thisx, PlayState* play) { BgIkanaRotaryroom* this = THIS; BgIkanaRotaryroomStruct1* ptr; BgIkanaRotaryroomStruct1* ptr2; @@ -966,37 +966,37 @@ void BgIkanaRotaryroom_Update(Actor* thisx, GlobalContext* globalCtx) { } } - if (func_80B80F08(this, globalCtx)) { + if (func_80B80F08(this, play)) { if (this->unk_204.unk_00 != NULL) { ((BgIkanaBlock*)this->unk_204.unk_00)->unk_17E = 1; } } - this->unk_200(&this->dyna.actor, globalCtx); + this->unk_200(&this->dyna.actor, play); if (this->unk_578 != NULL) { - this->unk_578(this, globalCtx); + this->unk_578(this, play); } if (this->unk_57C != NULL) { - this->unk_57C(this, globalCtx); + this->unk_57C(this, play); } if (this->actionFunc != NULL) { - this->actionFunc(this, globalCtx); + this->actionFunc(this, play); } } -void BgIkanaRotaryroom_Draw(Actor* thisx, GlobalContext* globalCtx) { +void BgIkanaRotaryroom_Draw(Actor* thisx, PlayState* play) { 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); + Gfx_DrawDListOpa(play, object_ikana_obj_DL_0048A0); + Gfx_DrawDListXlu(play, 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); + AnimatedMat_Draw(play, this->unk_1FC); + Gfx_DrawDListOpa(play, object_ikana_obj_DL_007448); + Gfx_DrawDListXlu(play, 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 1e27fb485..89021fa54 100644 --- a/src/overlays/actors/ovl_Bg_Ikana_Rotaryroom/z_bg_ikana_rotaryroom.h +++ b/src/overlays/actors/ovl_Bg_Ikana_Rotaryroom/z_bg_ikana_rotaryroom.h @@ -5,9 +5,9 @@ struct BgIkanaRotaryroom; -typedef void (*BgIkanaRotaryroomActionFunc)(struct BgIkanaRotaryroom*, GlobalContext*); -typedef void (*BgIkanaRotaryroomUnkFunc)(Actor*, GlobalContext*); -typedef void (*BgIkanaRotaryroomUnkFunc2)(struct BgIkanaRotaryroom*, GlobalContext*); +typedef void (*BgIkanaRotaryroomActionFunc)(struct BgIkanaRotaryroom*, PlayState*); +typedef void (*BgIkanaRotaryroomUnkFunc)(Actor*, PlayState*); +typedef void (*BgIkanaRotaryroomUnkFunc2)(struct BgIkanaRotaryroom*, PlayState*); #define BGIKANAROTARYROOM_GET_1(thisx) ((thisx)->params & 1) #define BGIKANAROTARYROOM_GET_FE(thisx) (((thisx)->params >> 1) & 0x7F) @@ -33,20 +33,20 @@ typedef struct { } BgIkanaRotaryroomStruct3; // size = 0x58 typedef struct BgIkanaRotaryroom { - /* 0x0000 */ DynaPolyActor dyna; - /* 0x015C */ ColliderJntSph collider; - /* 0x017C */ ColliderJntSphElement colliderElements[2]; - /* 0x01FC */ AnimatedMaterial* unk_1FC; - /* 0x0200 */ BgIkanaRotaryroomUnkFunc unk_200; - /* 0x0204 */ BgIkanaRotaryroomStruct1 unk_204; - /* 0x0248 */ BgIkanaRotaryroomStruct1 unk_248[2]; - /* 0x02D0 */ BgIkanaRotaryroomStruct1 unk_2D0[4]; - /* 0x03E0 */ BgIkanaRotaryroomStruct2 unk_3E0[4]; - /* 0x0520 */ BgIkanaRotaryroomStruct3 unk_520; - /* 0x0578 */ BgIkanaRotaryroomUnkFunc2 unk_578; - /* 0x057C */ BgIkanaRotaryroomUnkFunc2 unk_57C; - /* 0x0580 */ BgIkanaRotaryroomActionFunc actionFunc; - /* 0x0584 */ s16 unk_584; + /* 0x000 */ DynaPolyActor dyna; + /* 0x15C */ ColliderJntSph collider; + /* 0x17C */ ColliderJntSphElement colliderElements[2]; + /* 0x1FC */ AnimatedMaterial* unk_1FC; + /* 0x200 */ BgIkanaRotaryroomUnkFunc unk_200; + /* 0x204 */ BgIkanaRotaryroomStruct1 unk_204; + /* 0x248 */ BgIkanaRotaryroomStruct1 unk_248[2]; + /* 0x2D0 */ BgIkanaRotaryroomStruct1 unk_2D0[4]; + /* 0x3E0 */ BgIkanaRotaryroomStruct2 unk_3E0[4]; + /* 0x520 */ BgIkanaRotaryroomStruct3 unk_520; + /* 0x578 */ BgIkanaRotaryroomUnkFunc2 unk_578; + /* 0x57C */ BgIkanaRotaryroomUnkFunc2 unk_57C; + /* 0x580 */ BgIkanaRotaryroomActionFunc actionFunc; + /* 0x584 */ s16 unk_584; } BgIkanaRotaryroom; // size = 0x588 extern const ActorInit Bg_Ikana_Rotaryroom_InitVars; diff --git a/src/overlays/actors/ovl_Bg_Ikana_Shutter/z_bg_ikana_shutter.c b/src/overlays/actors/ovl_Bg_Ikana_Shutter/z_bg_ikana_shutter.c index 16060bbd2..ec17965c6 100644 --- a/src/overlays/actors/ovl_Bg_Ikana_Shutter/z_bg_ikana_shutter.c +++ b/src/overlays/actors/ovl_Bg_Ikana_Shutter/z_bg_ikana_shutter.c @@ -11,29 +11,29 @@ #define THIS ((BgIkanaShutter*)thisx) -void BgIkanaShutter_Init(Actor* thisx, GlobalContext* globalCtx); -void BgIkanaShutter_Destroy(Actor* thisx, GlobalContext* globalCtx); -void BgIkanaShutter_Update(Actor* thisx, GlobalContext* globalCtx); -void BgIkanaShutter_Draw(Actor* thisx, GlobalContext* globalCtx); +void BgIkanaShutter_Init(Actor* thisx, PlayState* play); +void BgIkanaShutter_Destroy(Actor* thisx, PlayState* play); +void BgIkanaShutter_Update(Actor* thisx, PlayState* play); +void BgIkanaShutter_Draw(Actor* thisx, PlayState* play); void func_80BD5828(BgIkanaShutter* this); -void func_80BD5844(BgIkanaShutter* this, GlobalContext* globalCtx); +void func_80BD5844(BgIkanaShutter* this, PlayState* play); void func_80BD5878(BgIkanaShutter* this); -void func_80BD5894(BgIkanaShutter* this, GlobalContext* globalCtx); +void func_80BD5894(BgIkanaShutter* this, PlayState* play); void func_80BD58F0(BgIkanaShutter* this); -void func_80BD5910(BgIkanaShutter* this, GlobalContext* globalCtx); +void func_80BD5910(BgIkanaShutter* this, PlayState* play); void func_80BD599C(BgIkanaShutter* this); -void func_80BD59C4(BgIkanaShutter* this, GlobalContext* globalCtx); +void func_80BD59C4(BgIkanaShutter* this, PlayState* play); void func_80BD59F8(BgIkanaShutter* this); -void func_80BD5A18(BgIkanaShutter* this, GlobalContext* globalCtx); +void func_80BD5A18(BgIkanaShutter* this, PlayState* play); void func_80BD5AE8(BgIkanaShutter* this); -void func_80BD5B04(BgIkanaShutter* this, GlobalContext* globalCtx); +void func_80BD5B04(BgIkanaShutter* this, PlayState* play); void func_80BD5B44(BgIkanaShutter* this); -void func_80BD5B60(BgIkanaShutter* this, GlobalContext* globalCtx); +void func_80BD5B60(BgIkanaShutter* this, PlayState* play); void func_80BD5BC4(BgIkanaShutter* this); -void func_80BD5BD8(BgIkanaShutter* this, GlobalContext* globalCtx); +void func_80BD5BD8(BgIkanaShutter* this, PlayState* play); void BgIkanaShutter_SetupDoNothing(BgIkanaShutter* this); -void BgIkanaShutter_DoNothing(BgIkanaShutter* this, GlobalContext* globalCtx); +void BgIkanaShutter_DoNothing(BgIkanaShutter* this, PlayState* play); const ActorInit Bg_Ikana_Shutter_InitVars = { ACTOR_BG_IKANA_SHUTTER, @@ -54,38 +54,38 @@ static InitChainEntry sInitChain[] = { ICHAIN_VEC3F_DIV1000(scale, 100, ICHAIN_STOP), }; -s32 BgIkanaShutter_AllSwitchesPressed(BgIkanaShutter* this, GlobalContext* globalCtx) { - return Flags_GetSwitch(globalCtx, this->dyna.actor.params & 0x7F) && - Flags_GetSwitch(globalCtx, (this->dyna.actor.params & 0x7F) + 1) && - Flags_GetSwitch(globalCtx, (this->dyna.actor.params & 0x7F) + 2) && - Flags_GetSwitch(globalCtx, (this->dyna.actor.params & 0x7F) + 3); +s32 BgIkanaShutter_AllSwitchesPressed(BgIkanaShutter* this, PlayState* play) { + return Flags_GetSwitch(play, this->dyna.actor.params & 0x7F) && + Flags_GetSwitch(play, (this->dyna.actor.params & 0x7F) + 1) && + Flags_GetSwitch(play, (this->dyna.actor.params & 0x7F) + 2) && + Flags_GetSwitch(play, (this->dyna.actor.params & 0x7F) + 3); } -void BgIkanaShutter_Init(Actor* thisx, GlobalContext* globalCtx) { +void BgIkanaShutter_Init(Actor* thisx, PlayState* play) { BgIkanaShutter* this = THIS; Actor_ProcessInitChain(&this->dyna.actor, sInitChain); DynaPolyActor_Init(&this->dyna, 0); - DynaPolyActor_LoadMesh(globalCtx, &this->dyna, &object_ikana_obj_Colheader_000F28); + DynaPolyActor_LoadMesh(play, &this->dyna, &object_ikana_obj_Colheader_000F28); if (!((this->dyna.actor.params >> 8) & 1)) { - if (BgIkanaShutter_AllSwitchesPressed(this, globalCtx)) { + if (BgIkanaShutter_AllSwitchesPressed(this, play)) { func_80BD599C(this); return; } func_80BD5828(this); return; } - if (Flags_GetClear(globalCtx, this->dyna.actor.room)) { + if (Flags_GetClear(play, this->dyna.actor.room)) { BgIkanaShutter_SetupDoNothing(this); return; } func_80BD5AE8(this); } -void BgIkanaShutter_Destroy(Actor* thisx, GlobalContext* globalCtx) { +void BgIkanaShutter_Destroy(Actor* thisx, PlayState* play) { BgIkanaShutter* this = THIS; - DynaPoly_DeleteBgActor(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); + DynaPoly_DeleteBgActor(play, &play->colCtx.dyna, this->dyna.bgId); } void func_80BD5828(BgIkanaShutter* this) { @@ -93,8 +93,8 @@ void func_80BD5828(BgIkanaShutter* this) { this->dyna.actor.world.pos.y = this->dyna.actor.home.pos.y; } -void func_80BD5844(BgIkanaShutter* this, GlobalContext* globalCtx) { - if (BgIkanaShutter_AllSwitchesPressed(this, globalCtx)) { +void func_80BD5844(BgIkanaShutter* this, PlayState* play) { + if (BgIkanaShutter_AllSwitchesPressed(this, play)) { func_80BD5878(this); } } @@ -104,7 +104,7 @@ void func_80BD5878(BgIkanaShutter* this) { this->dyna.actor.world.pos.y = this->dyna.actor.home.pos.y; } -void func_80BD5894(BgIkanaShutter* this, GlobalContext* globalCtx) { +void func_80BD5894(BgIkanaShutter* this, PlayState* play) { if (ActorCutscene_GetCanPlayNext(this->dyna.actor.cutscene)) { ActorCutscene_StartAndSetUnkLinkFields(this->dyna.actor.cutscene, &this->dyna.actor); func_80BD58F0(this); @@ -118,7 +118,7 @@ void func_80BD58F0(BgIkanaShutter* this) { this->actionFunc = func_80BD5910; } -void func_80BD5910(BgIkanaShutter* this, GlobalContext* globalCtx) { +void func_80BD5910(BgIkanaShutter* this, PlayState* play) { Math_StepToF(&this->dyna.actor.velocity.y, 4.0f, 0.5f); if (Math_SmoothStepToF(&this->dyna.actor.world.pos.y, this->dyna.actor.home.pos.y + 220.0f, 0.5f, this->dyna.actor.velocity.y, 1.0f) < 0.5f) { @@ -131,8 +131,8 @@ void func_80BD599C(BgIkanaShutter* this) { this->dyna.actor.world.pos.y = this->dyna.actor.home.pos.y + 220.0f; } -void func_80BD59C4(BgIkanaShutter* this, GlobalContext* globalCtx) { - if (BgIkanaShutter_AllSwitchesPressed(this, globalCtx) == 0) { +void func_80BD59C4(BgIkanaShutter* this, PlayState* play) { + if (!BgIkanaShutter_AllSwitchesPressed(this, play)) { func_80BD59F8(this); } } @@ -142,7 +142,7 @@ void func_80BD59F8(BgIkanaShutter* this) { this->dyna.actor.velocity.y = -23.0f; } -void func_80BD5A18(BgIkanaShutter* this, GlobalContext* globalCtx) { +void func_80BD5A18(BgIkanaShutter* this, PlayState* play) { s32 pad[2]; s16 quake; @@ -150,7 +150,7 @@ void func_80BD5A18(BgIkanaShutter* this, GlobalContext* globalCtx) { this->dyna.actor.velocity.y *= 0.978f; this->dyna.actor.world.pos.y += this->dyna.actor.velocity.y; if (this->dyna.actor.world.pos.y <= this->dyna.actor.home.pos.y) { - quake = Quake_Add(GET_ACTIVE_CAM(globalCtx), 3); + quake = Quake_Add(GET_ACTIVE_CAM(play), 3); Quake_SetSpeed(quake, 0x5420); Quake_SetQuakeValues(quake, 4, 0, 0, 0); Quake_SetCountdown(quake, 12); @@ -163,8 +163,8 @@ void func_80BD5AE8(BgIkanaShutter* this) { this->dyna.actor.world.pos.y = this->dyna.actor.home.pos.y; } -void func_80BD5B04(BgIkanaShutter* this, GlobalContext* globalCtx) { - if (Flags_GetClearTemp(globalCtx, this->dyna.actor.room)) { +void func_80BD5B04(BgIkanaShutter* this, PlayState* play) { + if (Flags_GetClearTemp(play, this->dyna.actor.room)) { func_80BD5B44(this); } } @@ -174,10 +174,10 @@ void func_80BD5B44(BgIkanaShutter* this) { this->dyna.actor.world.pos.y = this->dyna.actor.home.pos.y; } -void func_80BD5B60(BgIkanaShutter* this, GlobalContext* globalCtx) { +void func_80BD5B60(BgIkanaShutter* this, PlayState* play) { if (ActorCutscene_GetCanPlayNext(this->dyna.actor.cutscene)) { ActorCutscene_StartAndSetUnkLinkFields(this->dyna.actor.cutscene, &this->dyna.actor); - Flags_SetClear(globalCtx, this->dyna.actor.room); + Flags_SetClear(play, this->dyna.actor.room); func_80BD5BC4(this); return; } @@ -188,7 +188,7 @@ void func_80BD5BC4(BgIkanaShutter* this) { this->actionFunc = func_80BD5BD8; } -void func_80BD5BD8(BgIkanaShutter* this, GlobalContext* globalCtx) { +void func_80BD5BD8(BgIkanaShutter* this, PlayState* play) { Math_StepToF(&this->dyna.actor.velocity.y, 4.0f, 0.5f); if (Math_SmoothStepToF(&this->dyna.actor.world.pos.y, this->dyna.actor.home.pos.y + -220.0f, 0.5f, this->dyna.actor.velocity.y, 1.0f) < 0.5f) { @@ -201,15 +201,15 @@ void BgIkanaShutter_SetupDoNothing(BgIkanaShutter* this) { this->dyna.actor.world.pos.y = this->dyna.actor.home.pos.y + -220.0f; } -void BgIkanaShutter_DoNothing(BgIkanaShutter* this, GlobalContext* globalCtx) { +void BgIkanaShutter_DoNothing(BgIkanaShutter* this, PlayState* play) { } -void BgIkanaShutter_Update(Actor* thisx, GlobalContext* globalCtx) { +void BgIkanaShutter_Update(Actor* thisx, PlayState* play) { BgIkanaShutter* this = THIS; - this->actionFunc(this, globalCtx); + this->actionFunc(this, play); } -void BgIkanaShutter_Draw(Actor* thisx, GlobalContext* globalCtx) { - Gfx_DrawDListOpa(globalCtx, object_ikana_obj_DL_000CE8); +void BgIkanaShutter_Draw(Actor* thisx, PlayState* play) { + Gfx_DrawDListOpa(play, object_ikana_obj_DL_000CE8); } diff --git a/src/overlays/actors/ovl_Bg_Ikana_Shutter/z_bg_ikana_shutter.h b/src/overlays/actors/ovl_Bg_Ikana_Shutter/z_bg_ikana_shutter.h index 37cadc342..1d39f3593 100644 --- a/src/overlays/actors/ovl_Bg_Ikana_Shutter/z_bg_ikana_shutter.h +++ b/src/overlays/actors/ovl_Bg_Ikana_Shutter/z_bg_ikana_shutter.h @@ -5,7 +5,7 @@ struct BgIkanaShutter; -typedef void (*BgIkanaShutterActionFunc)(struct BgIkanaShutter*, GlobalContext*); +typedef void (*BgIkanaShutterActionFunc)(struct BgIkanaShutter*, PlayState*); typedef struct BgIkanaShutter { /* 0x000 */ DynaPolyActor dyna; 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 7e05d6977..0bc385cb7 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 @@ -5,27 +5,28 @@ */ #include "z_bg_iknin_susceil.h" +#include "z64rumble.h" #include "objects/object_ikninside_obj/object_ikninside_obj.h" #define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_20) #define THIS ((BgIkninSusceil*)thisx) -void BgIkninSusceil_Init(Actor* thisx, GlobalContext* globalCtx); -void BgIkninSusceil_Destroy(Actor* thisx, GlobalContext* globalCtx); -void BgIkninSusceil_Update(Actor* thisx, GlobalContext* globalCtx); -void BgIkninSusceil_Draw(Actor* thisx, GlobalContext* globalCtx); +void BgIkninSusceil_Init(Actor* thisx, PlayState* play); +void BgIkninSusceil_Destroy(Actor* thisx, PlayState* play); +void BgIkninSusceil_Update(Actor* thisx, PlayState* play); +void BgIkninSusceil_Draw(Actor* thisx, PlayState* play); -void func_80C0AB44(BgIkninSusceil* this, GlobalContext* globalCtx); +void func_80C0AB44(BgIkninSusceil* this, PlayState* play); void func_80C0AB88(BgIkninSusceil* this); -void func_80C0ABA8(BgIkninSusceil* this, GlobalContext* globalCtx); +void func_80C0ABA8(BgIkninSusceil* this, PlayState* play); void func_80C0AC74(BgIkninSusceil* this); -void func_80C0AC90(BgIkninSusceil* this, GlobalContext* globalCtx); +void func_80C0AC90(BgIkninSusceil* this, PlayState* play); void func_80C0ACD4(BgIkninSusceil* this); -void func_80C0ACE8(BgIkninSusceil* this, GlobalContext* globalCtx); +void func_80C0ACE8(BgIkninSusceil* this, PlayState* play); void func_80C0AD44(BgIkninSusceil* this); -void func_80C0AD64(BgIkninSusceil* this, GlobalContext* globalCtx); -void func_80C0AE5C(BgIkninSusceil* this, GlobalContext* globalCtx); +void func_80C0AD64(BgIkninSusceil* this, PlayState* play); +void func_80C0AE5C(BgIkninSusceil* this, PlayState* play); const ActorInit Bg_Iknin_Susceil_InitVars = { ACTOR_BG_IKNIN_SUSCEIL, @@ -49,45 +50,45 @@ static InitChainEntry sInitChain[] = { ICHAIN_VEC3F_DIV1000(scale, 100, ICHAIN_STOP), }; -s32 func_80C0A740(BgIkninSusceil* this, GlobalContext* globalCtx) { +s32 func_80C0A740(BgIkninSusceil* this, PlayState* play) { s32 pad2[2]; Vec3f offset; - Player* player = GET_PLAYER(globalCtx); + Player* player = GET_PLAYER(play); Actor_OffsetOfPointInActorCoords(&this->dyna.actor, &offset, &player->actor.world.pos); 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) { - func_800C6314(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); +void func_80C0A804(BgIkninSusceil* this, PlayState* play) { + func_800C6314(play, &play->colCtx.dyna, this->dyna.bgId); } -void func_80C0A838(BgIkninSusceil* this, GlobalContext* globalCtx) { - func_800C62BC(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); +void func_80C0A838(BgIkninSusceil* this, PlayState* play) { + func_800C62BC(play, &play->colCtx.dyna, this->dyna.bgId); } -void func_80C0A86C(BgIkninSusceil* this, GlobalContext* globalCtx, s16 verticalMag, s16 countdown, s32 arg4) { +void func_80C0A86C(BgIkninSusceil* this, PlayState* play, s16 verticalMag, s16 countdown, s32 arg4) { s32 pad; - s16 quake = Quake_Add(GET_ACTIVE_CAM(globalCtx), 3); + s16 quake = Quake_Add(GET_ACTIVE_CAM(play), 3); Quake_SetSpeed(quake, 0x7B30); Quake_SetQuakeValues(quake, verticalMag, 0, 0, 0); Quake_SetCountdown(quake, countdown); if (arg4 == 1) { - func_8013ECE0(10000.0f, 255, 20, 150); + Rumble_Request(SQ(100.0f), 255, 20, 150); } else if (arg4 == 2) { - func_8013ECE0(10000.0f, 180, 20, 100); + Rumble_Request(SQ(100.0f), 180, 20, 100); } else if (arg4 == 3) { - func_8013ECE0(10000.0f, 120, 20, 10); + Rumble_Request(SQ(100.0f), 120, 20, 10); } } -s32 func_80C0A95C(BgIkninSusceil* this, GlobalContext* globalCtx) { +s32 func_80C0A95C(BgIkninSusceil* this, PlayState* play) { s32 phi_t0 = true; s32 i; f32 new_var; - Player* player = GET_PLAYER(globalCtx); + Player* player = GET_PLAYER(play); Vec3f offset; f32 temp1, temp2, temp3, temp4; @@ -108,20 +109,20 @@ s32 func_80C0A95C(BgIkninSusceil* this, GlobalContext* globalCtx) { return phi_t0; } -void BgIkninSusceil_Init(Actor* thisx, GlobalContext* globalCtx) { +void BgIkninSusceil_Init(Actor* thisx, PlayState* play) { BgIkninSusceil* this = THIS; Actor_ProcessInitChain(&this->dyna.actor, sInitChain); DynaPolyActor_Init(&this->dyna, 1); - DynaPolyActor_LoadMesh(globalCtx, &this->dyna, &object_ikninside_obj_Colheader_00CBAC); + DynaPolyActor_LoadMesh(play, &this->dyna, &object_ikninside_obj_Colheader_00CBAC); this->animatedTexture = Lib_SegmentedToVirtual(object_ikninside_obj_Matanimheader_00C670); func_80C0AC74(this); } -void BgIkninSusceil_Destroy(Actor* thisx, GlobalContext* globalCtx) { +void BgIkninSusceil_Destroy(Actor* thisx, PlayState* play) { BgIkninSusceil* this = THIS; - DynaPoly_DeleteBgActor(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); + DynaPoly_DeleteBgActor(play, &play->colCtx.dyna, this->dyna.bgId); } void func_80C0AB14(BgIkninSusceil* this) { @@ -130,13 +131,13 @@ void func_80C0AB14(BgIkninSusceil* this) { this->actionFunc = func_80C0AB44; } -void func_80C0AB44(BgIkninSusceil* this, GlobalContext* globalCtx) { +void func_80C0AB44(BgIkninSusceil* this, PlayState* play) { if (this->timer > 0) { this->timer -= 1; return; } - if (func_80C0A740(this, globalCtx)) { + if (func_80C0A740(this, play)) { func_80C0AB88(this); } } @@ -146,13 +147,13 @@ void func_80C0AB88(BgIkninSusceil* this) { this->dyna.actor.velocity.y = -10.0f; } -void func_80C0ABA8(BgIkninSusceil* this, GlobalContext* globalCtx) { +void func_80C0ABA8(BgIkninSusceil* this, PlayState* play) { this->dyna.actor.velocity.y += -0.7f; this->dyna.actor.velocity.y *= 0.93f; this->dyna.actor.world.pos.y += this->dyna.actor.velocity.y; if (this->dyna.actor.world.pos.y <= this->dyna.actor.home.pos.y) { - func_80C0A86C(this, globalCtx, 4, 14, 1); - Flags_UnsetSwitch(globalCtx, GET_SUSCEIL_SWITCHFLAG(this)); + func_80C0A86C(this, play, 4, 14, 1); + Flags_UnsetSwitch(play, SUSCEIL_GET_SWITCHFLAG(&this->dyna.actor)); Actor_PlaySfxAtPos(&this->dyna.actor, NA_SE_EV_BIGWALL_BOUND); func_80C0AC74(this); } else { @@ -165,8 +166,8 @@ void func_80C0AC74(BgIkninSusceil* this) { this->dyna.actor.world.pos.y = this->dyna.actor.home.pos.y; } -void func_80C0AC90(BgIkninSusceil* this, GlobalContext* globalCtx) { - if (Flags_GetSwitch(globalCtx, GET_SUSCEIL_SWITCHFLAG(this))) { +void func_80C0AC90(BgIkninSusceil* this, PlayState* play) { + if (Flags_GetSwitch(play, SUSCEIL_GET_SWITCHFLAG(&this->dyna.actor))) { func_80C0ACD4(this); } } @@ -175,7 +176,7 @@ void func_80C0ACD4(BgIkninSusceil* this) { this->actionFunc = func_80C0ACE8; } -void func_80C0ACE8(BgIkninSusceil* this, GlobalContext* globalCtx) { +void func_80C0ACE8(BgIkninSusceil* this, PlayState* play) { if (ActorCutscene_GetCanPlayNext(this->dyna.actor.cutscene)) { ActorCutscene_StartAndSetUnkLinkFields(this->dyna.actor.cutscene, &this->dyna.actor); func_80C0AD44(this); @@ -189,12 +190,12 @@ void func_80C0AD44(BgIkninSusceil* this) { this->dyna.actor.velocity.y = 5.0f; } -void func_80C0AD64(BgIkninSusceil* this, GlobalContext* globalCtx) { +void func_80C0AD64(BgIkninSusceil* this, PlayState* play) { this->dyna.actor.velocity.y += 0.46f; this->dyna.actor.velocity.y *= 0.98f; if (Math_SmoothStepToF(&this->dyna.actor.world.pos.y, this->dyna.actor.home.pos.y + 365.0f, 0.5f, this->dyna.actor.velocity.y, 1.0f) < 0.1f) { - func_80C0A86C(this, globalCtx, 1, 14, 3); + func_80C0A86C(this, play, 1, 14, 3); ActorCutscene_Stop(this->dyna.actor.cutscene); func_80C0AB14(this); } else { @@ -207,25 +208,25 @@ void func_80C0AE3C(BgIkninSusceil* this) { this->dyna.actor.velocity.y = 30.0f; } -void func_80C0AE5C(BgIkninSusceil* this, GlobalContext* globalCtx) { +void func_80C0AE5C(BgIkninSusceil* this, PlayState* play) { this->dyna.actor.velocity.y += -0.1f; this->dyna.actor.velocity.y *= 0.95f; this->dyna.actor.velocity.y = CLAMP_MIN(this->dyna.actor.velocity.y, 1.0f); this->dyna.actor.world.pos.y = this->dyna.actor.world.pos.y + this->dyna.actor.velocity.y; if ((this->dyna.actor.home.pos.y + 365.0f) < this->dyna.actor.world.pos.y) { - func_80C0A86C(this, globalCtx, 3, 14, 2); + func_80C0A86C(this, play, 3, 14, 2); func_80C0AB14(this); } } -void BgIkninSusceil_Update(Actor* thisx, GlobalContext* globalCtx) { +void BgIkninSusceil_Update(Actor* thisx, PlayState* play) { s32 pad; BgIkninSusceil* this = THIS; - Player* player = GET_PLAYER(globalCtx); + Player* player = GET_PLAYER(play); if ((this->unk168 == 0) && (this->unk166 > 0) && (player->stateFlags3 & 0x100) && (player->unk_B48 > 1000.0f)) { this->unk168 = 2; - if ((func_80C0A95C(this, globalCtx) != 0) && (this->actionFunc != func_80C0AE5C)) { + if ((func_80C0A95C(this, play) != 0) && (this->actionFunc != func_80C0AE5C)) { func_800B8E58(player, NA_SE_PL_BODY_HIT); func_80C0AE3C(this); } @@ -235,7 +236,7 @@ void BgIkninSusceil_Update(Actor* thisx, GlobalContext* globalCtx) { this->unk168--; } - this->actionFunc(this, globalCtx); + this->actionFunc(this, play); if ((this->dyna.actor.home.pos.y + 70.0f) < this->dyna.actor.world.pos.y) { this->unk166 = 0; @@ -247,15 +248,15 @@ void BgIkninSusceil_Update(Actor* thisx, GlobalContext* globalCtx) { } } if (this->unk166 > 0) { - func_80C0A838(this, globalCtx); + func_80C0A838(this, play); } else { - func_80C0A804(this, globalCtx); + func_80C0A804(this, play); } } -void BgIkninSusceil_Draw(Actor* thisx, GlobalContext* globalCtx) { +void BgIkninSusceil_Draw(Actor* thisx, PlayState* play) { BgIkninSusceil* this = THIS; - AnimatedMat_Draw(globalCtx, this->animatedTexture); - Gfx_DrawDListOpa(globalCtx, object_ikninside_obj_DL_00C308); + AnimatedMat_Draw(play, this->animatedTexture); + Gfx_DrawDListOpa(play, object_ikninside_obj_DL_00C308); } diff --git a/src/overlays/actors/ovl_Bg_Iknin_Susceil/z_bg_iknin_susceil.h b/src/overlays/actors/ovl_Bg_Iknin_Susceil/z_bg_iknin_susceil.h index 3692f4864..8fc32bd06 100644 --- a/src/overlays/actors/ovl_Bg_Iknin_Susceil/z_bg_iknin_susceil.h +++ b/src/overlays/actors/ovl_Bg_Iknin_Susceil/z_bg_iknin_susceil.h @@ -3,11 +3,11 @@ #include "global.h" -#define GET_SUSCEIL_SWITCHFLAG(this) (((this)->dyna.actor.params) & 0x7F) +#define SUSCEIL_GET_SWITCHFLAG(thisx) (((thisx)->params) & 0x7F) struct BgIkninSusceil; -typedef void (*BgIkninSusceilActionFunc)(struct BgIkninSusceil*, GlobalContext*); +typedef void (*BgIkninSusceilActionFunc)(struct BgIkninSusceil*, PlayState*); typedef struct BgIkninSusceil { /* 0x000 */ DynaPolyActor dyna; 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 a09bcba87..07de845c0 100644 --- a/src/overlays/actors/ovl_Bg_Ikninside/z_bg_ikninside.c +++ b/src/overlays/actors/ovl_Bg_Ikninside/z_bg_ikninside.c @@ -5,17 +5,19 @@ */ #include "z_bg_ikninside.h" +#include "objects/object_ikninside_obj/object_ikninside_obj.h" #define FLAGS (ACTOR_FLAG_10) #define THIS ((BgIkninside*)thisx) -void BgIkninside_Init(Actor* thisx, GlobalContext* globalCtx); -void BgIkninside_Destroy(Actor* thisx, GlobalContext* globalCtx); -void BgIkninside_Update(Actor* thisx, GlobalContext* globalCtx); -void BgIkninside_Draw(Actor* thisx, GlobalContext* globalCtx); +void BgIkninside_Init(Actor* thisx, PlayState* play); +void BgIkninside_Destroy(Actor* thisx, PlayState* play); +void BgIkninside_Update(Actor* thisx, PlayState* play); +void BgIkninside_Draw(Actor* thisx, PlayState* play); + +void func_80C072D0(BgIkninside* this, PlayState* play); -#if 0 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, PlayState* play) { + 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(play, &play->colCtx.dyna, &this->dyna.actor, colHeader); + Collider_InitAndSetCylinder(play, &this->collider, &this->dyna.actor, &sCylinderInit); + Collider_UpdateCylinder(&this->dyna.actor, &this->collider); + if (Flags_GetSwitch(play, DMIKNINSIDE_GET_SWITCH(thisx))) { + Actor_MarkForDeath(&this->dyna.actor); + } +} -extern UNK_TYPE D_0600CC78; -extern UNK_TYPE D_0600DE48; +void BgIkninside_Destroy(Actor* thisx, PlayState* play) { + BgIkninside* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Ikninside/BgIkninside_Init.s") + Collider_DestroyCylinder(play, &this->collider); + DynaPoly_DeleteBgActor(play, &play->colCtx.dyna, this->dyna.bgId); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Ikninside/BgIkninside_Destroy.s") +void func_80C07220(BgIkninside* this, PlayState* play) { +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Ikninside/func_80C07220.s") +void func_80C07230(BgIkninside* this, PlayState* play) { + 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, PlayState* play) { + 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 = 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(play, &pos, &velocity, &D_80C076D4, 0, 30, OBJECT_IKNINSIDE_OBJ, 25, + D_80C076A0[i & 1]); + } + Flags_SetSwitch(play, DMIKNINSIDE_GET_SWITCH(&this->dyna.actor)); + this->actionFunc = func_80C07230; + this->dyna.actor.draw = NULL; + func_800C62BC(play, &play->colCtx.dyna, this->dyna.bgId); + } 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(play, &play->colChkCtx, &this->collider.base); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Ikninside/BgIkninside_Draw.s") +void BgIkninside_Update(Actor* thisx, PlayState* play) { + BgIkninside* this = THIS; + + this->actionFunc(this, play); +} + +void BgIkninside_Draw(Actor* thisx, PlayState* play) { + OPEN_DISPS(play->state.gfxCtx); + + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + func_8012C28C(play->state.gfxCtx); + gSPDisplayList(POLY_OPA_DISP++, object_ikninside_obj_DL_00CC78); + + CLOSE_DISPS(play->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..84a66a88d 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; -typedef void (*BgIkninsideActionFunc)(struct BgIkninside*, GlobalContext*); +#define DMIKNINSIDE_GET_SWITCH(thisx) (((thisx)->params & 0xFE00) >> 9) + +typedef void (*BgIkninsideActionFunc)(struct BgIkninside*, PlayState*); 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 92a109925..06091b12b 100644 --- a/src/overlays/actors/ovl_Bg_Iknv_Doukutu/z_bg_iknv_doukutu.c +++ b/src/overlays/actors/ovl_Bg_Iknv_Doukutu/z_bg_iknv_doukutu.c @@ -5,24 +5,28 @@ */ #include "z_bg_iknv_doukutu.h" +#include "objects/object_iknv_obj/object_iknv_obj.h" #define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_20) #define THIS ((BgIknvDoukutu*)thisx) -void BgIknvDoukutu_Init(Actor* thisx, GlobalContext* globalCtx); -void BgIknvDoukutu_Destroy(Actor* thisx, GlobalContext* globalCtx); -void BgIknvDoukutu_Update(Actor* thisx, GlobalContext* globalCtx); -void BgIknvDoukutu_Draw(Actor* thisx, GlobalContext* globalCtx); +void BgIknvDoukutu_Init(Actor* thisx, PlayState* play); +void BgIknvDoukutu_Destroy(Actor* thisx, PlayState* play); +void BgIknvDoukutu_Update(Actor* thisx, PlayState* play); +void BgIknvDoukutu_Draw(Actor* thisx, PlayState* play); -void func_80BD716C(BgIknvDoukutu* this, GlobalContext* globalCtx); -void func_80BD71BC(BgIknvDoukutu* this, GlobalContext* globalCtx); -void func_80BD7250(BgIknvDoukutu* this, GlobalContext* globalCtx); -void func_80BD72BC(BgIknvDoukutu* this, GlobalContext* globalCtx); -void func_80BD7360(BgIknvDoukutu* this, GlobalContext* globalCtx); -void func_80BD73D0(BgIknvDoukutu* this, GlobalContext* globalCtx); +void func_80BD716C(BgIknvDoukutu* this, PlayState* play); +void func_80BD71BC(BgIknvDoukutu* this, PlayState* play); +void func_80BD7250(BgIknvDoukutu* this, PlayState* play); +void func_80BD72BC(BgIknvDoukutu* this, PlayState* play); +void func_80BD7360(BgIknvDoukutu* this, PlayState* play); +void func_80BD73D0(BgIknvDoukutu* this, PlayState* play); +void func_80BD7768(Actor* thisx, PlayState* play); +void func_80BD7820(Actor* thisx, PlayState* play); +void func_80BD78C4(Actor* thisx, PlayState* play); +void func_80BD7538(Actor* thisx, PlayState* play); -#if 0 const ActorInit Bg_Iknv_Doukutu_InitVars = { ACTOR_BG_IKNV_DOUKUTU, ACTORCAT_BG, @@ -35,38 +39,233 @@ const ActorInit Bg_Iknv_Doukutu_InitVars = { (ActorFunc)BgIknvDoukutu_Draw, }; -#endif +void BgIknvDoukutu_Init(Actor* thisx, PlayState* play) { + BgIknvDoukutu* this = THIS; + CollisionHeader* colHeader = NULL; + s32 pad; -extern UNK_TYPE D_0600F1C0; -extern UNK_TYPE D_06010D98; -extern UNK_TYPE D_060117A0; -extern UNK_TYPE D_06012728; -extern UNK_TYPE D_06012788; + Actor_SetScale(&this->dyna.actor, 0.1f); + this->actionFunc = func_80BD73D0; + this->unk_15C = 0; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Iknv_Doukutu/BgIknvDoukutu_Init.s") + switch (BGIKNVDOUKUTU_GET_F(&this->dyna.actor)) { + case BGIKNVDOUKUTU_F_0: + this->actionFunc = func_80BD71BC; + this->csAction = 0x204; + this->unk_160 = 1.0f; + if ((gSaveContext.save.weekEventReg[14] & 4) || (gSaveContext.save.weekEventReg[52] & 0x20)) { + this->dyna.actor.draw = func_80BD7768; + this->actionFunc = func_80BD73D0; + play->envCtx.lightSettingOverride = 25; + } else { + play->envCtx.lightSettingOverride = 24; + } + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Iknv_Doukutu/BgIknvDoukutu_Destroy.s") + case BGIKNVDOUKUTU_F_1: + Actor_SetScale(&this->dyna.actor, 1.0f); + this->dyna.actor.draw = func_80BD7820; + this->csAction = 0x204; + DynaPolyActor_Init(&this->dyna, 0); + CollisionHeader_GetVirtual(&object_iknv_obj_Colheader_012788, &colHeader); + this->dyna.bgId = DynaPoly_SetBgActor(play, &play->colCtx.dyna, &this->dyna.actor, colHeader); + if (!(gSaveContext.save.weekEventReg[14] & 4)) { + Actor_MarkForDeath(&this->dyna.actor); + } + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Iknv_Doukutu/func_80BD716C.s") + case BGIKNVDOUKUTU_F_2: + this->csAction = 0x204; + this->dyna.actor.draw = func_80BD78C4; + DynaPolyActor_Init(&this->dyna, 0); + CollisionHeader_GetVirtual(&object_iknv_obj_Colheader_0117C8, &colHeader); + this->dyna.bgId = DynaPoly_SetBgActor(play, &play->colCtx.dyna, &this->dyna.actor, colHeader); + if (gSaveContext.save.weekEventReg[14] & 4) { + this->unk_160 = 1.0f; + this->dyna.actor.world.pos.y += 68.0f; + } else { + this->actionFunc = func_80BD7360; + this->unk_160 = 0.0f; + } + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Iknv_Doukutu/func_80BD71BC.s") + default: + Actor_MarkForDeath(&this->dyna.actor); + break; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Iknv_Doukutu/func_80BD7250.s") +void BgIknvDoukutu_Destroy(Actor* thisx, PlayState* play) { + BgIknvDoukutu* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Iknv_Doukutu/func_80BD72BC.s") + if ((BGIKNVDOUKUTU_GET_F(&this->dyna.actor) == BGIKNVDOUKUTU_F_1) || + (BGIKNVDOUKUTU_GET_F(&this->dyna.actor) == BGIKNVDOUKUTU_F_2)) { + DynaPoly_DeleteBgActor(play, &play->colCtx.dyna, this->dyna.bgId); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Iknv_Doukutu/func_80BD7360.s") +void func_80BD716C(BgIknvDoukutu* this, PlayState* play) { + if (this->unk_160 >= 0.05f) { + this->unk_160 -= 0.05f; + } else { + this->actionFunc = func_80BD73D0; + this->dyna.actor.draw = func_80BD7768; + } + play->envCtx.lightSettingOverride = 25; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Iknv_Doukutu/func_80BD73D0.s") +void func_80BD71BC(BgIknvDoukutu* this, PlayState* play) { + play->envCtx.lightSettingOverride = 24; + if (Cutscene_CheckActorAction(play, this->csAction) && + (play->csCtx.actorActions[Cutscene_GetActorActionIndex(play, this->csAction)]->action == 2)) { + this->actionFunc = func_80BD716C; + this->dyna.actor.draw = func_80BD7538; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Iknv_Doukutu/BgIknvDoukutu_Update.s") +void func_80BD7250(BgIknvDoukutu* this, PlayState* play) { + f32 temp_fv0 = this->dyna.actor.home.pos.y + 68.0f; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Iknv_Doukutu/BgIknvDoukutu_Draw.s") + this->dyna.actor.world.pos.y += 1.7f; + if (temp_fv0 < this->dyna.actor.world.pos.y) { + this->dyna.actor.world.pos.y = temp_fv0; + this->actionFunc = func_80BD73D0; + } + func_8019F128(NA_SE_EV_WATER_LEVEL_DOWN - SFX_FLAG); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Iknv_Doukutu/func_80BD7538.s") +void func_80BD72BC(BgIknvDoukutu* this, PlayState* play) { + if (Cutscene_CheckActorAction(play, this->csAction) && + (play->csCtx.actorActions[Cutscene_GetActorActionIndex(play, this->csAction)]->action == 3)) { + this->actionFunc = func_80BD7250; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Iknv_Doukutu/func_80BD7768.s") + if (this->unk_160 < 0.95f) { + this->unk_160 += 0.05f; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Iknv_Doukutu/func_80BD7820.s") +void func_80BD7360(BgIknvDoukutu* this, PlayState* play) { + if (Cutscene_CheckActorAction(play, this->csAction) && + (play->csCtx.actorActions[Cutscene_GetActorActionIndex(play, this->csAction)]->action == 2)) { + this->actionFunc = func_80BD72BC; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Iknv_Doukutu/func_80BD78C4.s") +void func_80BD73D0(BgIknvDoukutu* this, PlayState* play) { +} + +void BgIknvDoukutu_Update(Actor* thisx, PlayState* play) { + BgIknvDoukutu* this = THIS; + + this->actionFunc(this, play); +} + +void BgIknvDoukutu_Draw(Actor* thisx, PlayState* play) { + BgIknvDoukutu* this = THIS; + + OPEN_DISPS(play->state.gfxCtx); + + AnimatedMat_Draw(play, Lib_SegmentedToVirtual(object_iknv_obj_Matanimheader_00F1C0)); + Scene_SetRenderModeXlu(play, 0, 1); + + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + + func_8012C28C(play->state.gfxCtx); + func_8012C2DC(play->state.gfxCtx); + + gDPSetEnvColor(POLY_OPA_DISP++, 0, 0, 0, 255); + gSPDisplayList(POLY_OPA_DISP++, object_iknv_obj_DL_00DDD8); + gDPSetEnvColor(POLY_XLU_DISP++, 215, 42, 55, 120); + gSPDisplayList(POLY_XLU_DISP++, object_iknv_obj_DL_00DB60); + + CLOSE_DISPS(play->state.gfxCtx); +} + +void func_80BD7538(Actor* thisx, PlayState* play) { + BgIknvDoukutu* this = THIS; + GraphicsContext* gfxCtx; + f32 sp54; + + func_80BD7768(&this->dyna.actor, play); + + gfxCtx = play->state.gfxCtx; + OPEN_DISPS(gfxCtx); + Vec3f sp40; + s16 sp3E = Math_Vec3f_Yaw(&GET_ACTIVE_CAM(play)->eye, &GET_ACTIVE_CAM(play)->at); + s16 sp3C = -Math_Vec3f_Pitch(&GET_ACTIVE_CAM(play)->eye, &GET_ACTIVE_CAM(play)->at); + + sp40.x = -100.0f * Math_SinS(sp3E) * Math_CosS(sp3C); + sp40.y = Math_SinS(sp3C) * -100.0f; + sp40.z = -100.0f * Math_CosS(sp3E) * Math_CosS(sp3C); + Matrix_Translate(sp40.x, sp40.y, sp40.z, MTXMODE_APPLY); + sp54 = this->unk_160; + AnimatedMat_Draw(play, Lib_SegmentedToVirtual(object_iknv_obj_Matanimheader_00F1C0)); + + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + + func_8012C304(POLY_XLU_DISP++); + Scene_SetRenderModeXlu(play, 1, 2); + func_8012C2DC(play->state.gfxCtx); + + gDPSetEnvColor(POLY_XLU_DISP++, 0, 0, 0, (s32)(255.0f * sp54)); + gSPDisplayList(POLY_XLU_DISP++, object_iknv_obj_DL_00DDD8); + gDPSetEnvColor(POLY_XLU_DISP++, 215, 42, 55, (s32)(120.0f * sp54)); + gSPDisplayList(POLY_XLU_DISP++, object_iknv_obj_DL_00DB60); + + CLOSE_DISPS(gfxCtx); +} + +void func_80BD7768(Actor* thisx, PlayState* play) { + BgIknvDoukutu* this = THIS; + + OPEN_DISPS(play->state.gfxCtx); + + Scene_SetRenderModeXlu(play, 0, 1); + + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + + func_8012C28C(play->state.gfxCtx); + + gDPSetEnvColor(POLY_OPA_DISP++, 0, 0, 0, 255); + gSPDisplayList(POLY_OPA_DISP++, object_iknv_obj_DL_010D98); + + CLOSE_DISPS(play->state.gfxCtx); +} + +void func_80BD7820(Actor* thisx, PlayState* play) { + BgIknvDoukutu* this = THIS; + + OPEN_DISPS(play->state.gfxCtx); + + AnimatedMat_Draw(play, Lib_SegmentedToVirtual(object_iknv_obj_Matanimheader_012728)); + + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + + func_8012C2DC(play->state.gfxCtx); + + gSPDisplayList(POLY_XLU_DISP++, object_iknv_obj_DL_012700); + + CLOSE_DISPS(play->state.gfxCtx); +} + +void func_80BD78C4(Actor* thisx, PlayState* play) { + BgIknvDoukutu* this = THIS; + f32 sp30 = this->unk_160; + s32 pad; + + OPEN_DISPS(play->state.gfxCtx); + + AnimatedMat_Draw(play, Lib_SegmentedToVirtual(object_iknv_obj_Matanimheader_0117A0)); + + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + + func_8012C2DC(play->state.gfxCtx); + + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0x80, 255, 255, 255, (s32)(140.0f * sp30)); + + gSPDisplayList(POLY_XLU_DISP++, object_iknv_obj_DL_0115E0); + + CLOSE_DISPS(play->state.gfxCtx); +} diff --git a/src/overlays/actors/ovl_Bg_Iknv_Doukutu/z_bg_iknv_doukutu.h b/src/overlays/actors/ovl_Bg_Iknv_Doukutu/z_bg_iknv_doukutu.h index 31c3c85f0..d9c4f78ad 100644 --- a/src/overlays/actors/ovl_Bg_Iknv_Doukutu/z_bg_iknv_doukutu.h +++ b/src/overlays/actors/ovl_Bg_Iknv_Doukutu/z_bg_iknv_doukutu.h @@ -5,13 +5,23 @@ struct BgIknvDoukutu; -typedef void (*BgIknvDoukutuActionFunc)(struct BgIknvDoukutu*, GlobalContext*); +typedef void (*BgIknvDoukutuActionFunc)(struct BgIknvDoukutu*, PlayState*); + +#define BGIKNVDOUKUTU_GET_F(thisx) ((thisx)->params & 0xF) + +enum { + BGIKNVDOUKUTU_F_0, + BGIKNVDOUKUTU_F_1, + BGIKNVDOUKUTU_F_2, +}; typedef struct BgIknvDoukutu { - /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x20]; - /* 0x0164 */ BgIknvDoukutuActionFunc actionFunc; -} BgIknvDoukutu; // size = 0x168 + /* 0x000 */ DynaPolyActor dyna; + /* 0x15C */ s16 unk_15C; // set and not used + /* 0x15E */ u16 csAction; + /* 0x160 */ f32 unk_160; + /* 0x164 */ BgIknvDoukutuActionFunc actionFunc; +} BgIknvDoukutu;// size = 0x168 extern const ActorInit Bg_Iknv_Doukutu_InitVars; diff --git a/src/overlays/actors/ovl_Bg_Iknv_Obj/z_bg_iknv_obj.c b/src/overlays/actors/ovl_Bg_Iknv_Obj/z_bg_iknv_obj.c index 023b4b706..81397039d 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 @@ -11,15 +11,15 @@ #define THIS ((BgIknvObj*)thisx) -void BgIknvObj_Init(Actor* thisx, GlobalContext* globalCtx); -void BgIknvObj_Destroy(Actor* thisx, GlobalContext* globalCtx); -void BgIknvObj_Update(Actor* thisx, GlobalContext* globalCtx); -void BgIknvObj_Draw(Actor* thisx, GlobalContext* globalCtx); +void BgIknvObj_Init(Actor* thisx, PlayState* play); +void BgIknvObj_Destroy(Actor* thisx, PlayState* play); +void BgIknvObj_Update(Actor* thisx, PlayState* play); +void BgIknvObj_Draw(Actor* thisx, PlayState* play); -void BgIknvObj_DoNothing(BgIknvObj* this, GlobalContext* globalCtx); -void BgIknvObj_UpdateWaterwheel(BgIknvObj* this, GlobalContext* globalCtx); -void BgIknvObj_UpdateRaisedDoor(BgIknvObj* this, GlobalContext* globalCtx); -void BgIknvObj_UpdateSakonDoor(BgIknvObj* this, GlobalContext* globalCtx); +void BgIknvObj_DoNothing(BgIknvObj* this, PlayState* play); +void BgIknvObj_UpdateWaterwheel(BgIknvObj* this, PlayState* play); +void BgIknvObj_UpdateRaisedDoor(BgIknvObj* this, PlayState* play); +void BgIknvObj_UpdateSakonDoor(BgIknvObj* this, PlayState* play); const ActorInit Bg_Iknv_Obj_InitVars = { ACTOR_BG_IKNV_OBJ, @@ -53,7 +53,7 @@ static ColliderCylinderInit sCylinderInit = { { 40, 40, 0, { 0, 0, 0 } }, }; -void BgIknvObj_Init(Actor* thisx, GlobalContext* globalCtx) { +void BgIknvObj_Init(Actor* thisx, PlayState* play) { s32 pad; BgIknvObj* this = THIS; CollisionHeader* colHeader = NULL; @@ -71,7 +71,7 @@ void BgIknvObj_Init(Actor* thisx, GlobalContext* globalCtx) { this->displayListPtr = object_iknv_obj_DL_011880; DynaPolyActor_Init(&this->dyna, 0); CollisionHeader_GetVirtual(&object_iknv_obj_Colheader_0119D4, &colHeader); - this->dyna.bgId = DynaPoly_SetBgActor(globalCtx, &globalCtx->colCtx.dyna, &this->dyna.actor, colHeader); + this->dyna.bgId = DynaPoly_SetBgActor(play, &play->colCtx.dyna, &this->dyna.actor, colHeader); this->actionFunc = BgIknvObj_UpdateRaisedDoor; this->dyna.actor.world.pos.y = this->dyna.actor.home.pos.y + 120.0f; break; @@ -80,8 +80,8 @@ void BgIknvObj_Init(Actor* thisx, GlobalContext* globalCtx) { this->actionFunc = BgIknvObj_UpdateSakonDoor; DynaPolyActor_Init(&this->dyna, 0); CollisionHeader_GetVirtual(&object_iknv_obj_Colheader_012CA4, &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.bgId = DynaPoly_SetBgActor(play, &play->colCtx.dyna, &this->dyna.actor, colHeader); + Collider_InitAndSetCylinder(play, &this->collider, &this->dyna.actor, &sCylinderInit); Collider_UpdateCylinder(&this->dyna.actor, &this->collider); this->dyna.actor.colChkInfo.mass = MASS_IMMOVABLE; gSaveContext.save.weekEventReg[51] &= (u8)~0x10; @@ -92,18 +92,18 @@ void BgIknvObj_Init(Actor* thisx, GlobalContext* globalCtx) { } } -void BgIknvObj_Destroy(Actor* thisx, GlobalContext* globalCtx) { +void BgIknvObj_Destroy(Actor* thisx, PlayState* play) { BgIknvObj* this = THIS; if (IKNV_OBJ_TYPE(this) != IKNV_OBJ_RAISED_DOOR) { if (IKNV_OBJ_TYPE(this) == IKNV_OBJ_SAKON_DOOR) { - Collider_DestroyCylinder(globalCtx, &this->collider); + Collider_DestroyCylinder(play, &this->collider); gSaveContext.save.weekEventReg[51] &= (u8)~0x10; } else { return; } } - DynaPoly_DeleteBgActor(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); + DynaPoly_DeleteBgActor(play, &play->colCtx.dyna, this->dyna.bgId); } s32 func_80BD7CEC(BgIknvObj* this) { @@ -124,26 +124,26 @@ s32 func_80BD7CEC(BgIknvObj* this) { return false; } -void BgIknvObj_UpdateWaterwheel(BgIknvObj* this, GlobalContext* globalCtx) { +void BgIknvObj_UpdateWaterwheel(BgIknvObj* this, PlayState* play) { 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.currentCsIndex == 4) && (globalCtx->csCtx.frames == 1495)) { + if ((play->csCtx.state != 0) && (gSaveContext.sceneSetupIndex == 1) && (play->csCtx.currentCsIndex == 4) && + (play->csCtx.frames == 1495)) { func_8019F128(NA_SE_EV_DOOR_UNLOCK); } } -s32 func_80BD7E0C(BgIknvObj* this, s16 targetRotation, GlobalContext* globalCtx) { +s32 func_80BD7E0C(BgIknvObj* this, s16 targetRotation, PlayState* play) { this->dyna.actor.shape.yOffset = 0.0f; - CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + CollisionCheck_SetOC(play, &play->colChkCtx, &this->collider.base); if (targetRotation != this->dyna.actor.shape.rot.y) { Math_SmoothStepToS(&this->dyna.actor.shape.rot.y, targetRotation, 2, 100, 100); this->dyna.actor.world.rot.y = this->dyna.actor.shape.rot.y; - if ((globalCtx->gameplayFrames % 2) != 0) { + if ((play->gameplayFrames % 2) != 0) { this->dyna.actor.shape.yOffset = 5.0f; } func_800B9010(&this->dyna.actor, NA_SE_EV_STONEDOOR_OPEN_S - SFX_FLAG); @@ -153,15 +153,15 @@ s32 func_80BD7E0C(BgIknvObj* this, s16 targetRotation, GlobalContext* globalCtx) return true; } -void func_80BD7ED8(BgIknvObj* this, GlobalContext* globalCtx) { - if (func_80BD7E0C(this, this->dyna.actor.home.rot.y, globalCtx)) { +void func_80BD7ED8(BgIknvObj* this, PlayState* play) { + if (func_80BD7E0C(this, this->dyna.actor.home.rot.y, play)) { this->actionFunc = BgIknvObj_UpdateSakonDoor; gSaveContext.save.weekEventReg[51] &= (u8)~0x10; } - CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + CollisionCheck_SetOC(play, &play->colChkCtx, &this->collider.base); } -void func_80BD7F4C(BgIknvObj* this, GlobalContext* globalCtx) { +void func_80BD7F4C(BgIknvObj* this, PlayState* play) { if (gSaveContext.save.time > CLOCK_TIME(19, 30)) { this->actionFunc = func_80BD7ED8; } @@ -169,50 +169,50 @@ void func_80BD7F4C(BgIknvObj* this, GlobalContext* globalCtx) { ActorCutscene_Stop(this->dyna.actor.cutscene); this->dyna.actor.home.rot.x = 0; } - CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + CollisionCheck_SetOC(play, &play->colChkCtx, &this->collider.base); } -void func_80BD7FDC(BgIknvObj* this, GlobalContext* globalCtx) { - if (func_80BD7E0C(this, this->dyna.actor.home.rot.y + 0x4000, globalCtx)) { +void func_80BD7FDC(BgIknvObj* this, PlayState* play) { + if (func_80BD7E0C(this, this->dyna.actor.home.rot.y + 0x4000, play)) { this->actionFunc = func_80BD7F4C; gSaveContext.save.weekEventReg[51] |= 0x10; this->dyna.actor.home.rot.x = 1; } } -void func_80BD8040(BgIknvObj* this, GlobalContext* globalCtx) { +void func_80BD8040(BgIknvObj* this, PlayState* play) { if (func_80BD7CEC(this)) { this->actionFunc = func_80BD7FDC; } - CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + CollisionCheck_SetOC(play, &play->colChkCtx, &this->collider.base); } -void BgIknvObj_UpdateSakonDoor(BgIknvObj* this, GlobalContext* globalCtx) { +void BgIknvObj_UpdateSakonDoor(BgIknvObj* this, PlayState* play) { if (gSaveContext.save.weekEventReg[58] & 0x80) { this->actionFunc = func_80BD8040; gSaveContext.save.weekEventReg[89] |= 0x80; } - CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + CollisionCheck_SetOC(play, &play->colChkCtx, &this->collider.base); } -void BgIknvObj_UpdateRaisedDoor(BgIknvObj* this, GlobalContext* globalCtx) { +void BgIknvObj_UpdateRaisedDoor(BgIknvObj* this, PlayState* play) { } -void BgIknvObj_DoNothing(BgIknvObj* this, GlobalContext* globalCtx) { +void BgIknvObj_DoNothing(BgIknvObj* this, PlayState* play) { } -void BgIknvObj_Update(Actor* thisx, GlobalContext* globalCtx) { +void BgIknvObj_Update(Actor* thisx, PlayState* play) { BgIknvObj* this = THIS; - this->actionFunc(this, globalCtx); + this->actionFunc(this, play); } -void BgIknvObj_Draw(Actor* thisx, GlobalContext* globalCtx) { +void BgIknvObj_Draw(Actor* thisx, PlayState* play) { BgIknvObj* this = THIS; - 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); + OPEN_DISPS(play->state.gfxCtx); + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + func_8012C28C(play->state.gfxCtx); gSPDisplayList(POLY_OPA_DISP++, this->displayListPtr); - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->state.gfxCtx); } diff --git a/src/overlays/actors/ovl_Bg_Iknv_Obj/z_bg_iknv_obj.h b/src/overlays/actors/ovl_Bg_Iknv_Obj/z_bg_iknv_obj.h index d583753c2..333b9d59e 100644 --- a/src/overlays/actors/ovl_Bg_Iknv_Obj/z_bg_iknv_obj.h +++ b/src/overlays/actors/ovl_Bg_Iknv_Obj/z_bg_iknv_obj.h @@ -5,7 +5,7 @@ struct BgIknvObj; -typedef void (*BgIknvObjActionFunc)(struct BgIknvObj*, GlobalContext*); +typedef void (*BgIknvObjActionFunc)(struct BgIknvObj*, PlayState*); #define IKNV_OBJ_TYPE(x) (x->dyna.actor.params & 0xF) 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 8c55cc2f3..7fb51ff8d 100644 --- a/src/overlays/actors/ovl_Bg_Ingate/z_bg_ingate.c +++ b/src/overlays/actors/ovl_Bg_Ingate/z_bg_ingate.c @@ -11,20 +11,20 @@ #define THIS ((BgIngate*)thisx) -void BgIngate_Init(Actor* thisx, GlobalContext* globalCtx); -void BgIngate_Destroy(Actor* thisx, GlobalContext* globalCtx); -void BgIngate_Update(Actor* thisx, GlobalContext* globalCtx); -void BgIngate_Draw(Actor* thisx, GlobalContext* globalCtx); +void BgIngate_Init(Actor* thisx, PlayState* play); +void BgIngate_Destroy(Actor* thisx, PlayState* play); +void BgIngate_Update(Actor* thisx, PlayState* play); +void BgIngate_Draw(Actor* thisx, PlayState* play); -Actor* BgIngate_FindActor(BgIngate* this, GlobalContext* globalCtx, u8 actorCat, s16 actorId); +Actor* BgIngate_FindActor(BgIngate* this, PlayState* play, 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); +void func_80953F8C(BgIngate* this, PlayState* play); +void func_80953F9C(BgIngate* this, PlayState* play); +void func_809541B8(BgIngate* this, PlayState* play); +void func_809542A0(BgIngate* this, PlayState* play); +void func_80954340(BgIngate* this, PlayState* play); +void func_809543D4(BgIngate* this, PlayState* play); const ActorInit Bg_Ingate_InitVars = { ACTOR_BG_INGATE, @@ -42,17 +42,17 @@ const ActorInit Bg_Ingate_InitVars = { * @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 play * @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* BgIngate_FindActor(BgIngate* this, PlayState* play, u8 actorCat, s16 actorId) { Actor* foundActor = NULL; Actor* tempActor; while (true) { - foundActor = SubS_FindActor(globalCtx, foundActor, actorCat, actorId); + foundActor = SubS_FindActor(play, foundActor, actorCat, actorId); if ((foundActor == NULL) || (((this != (BgIngate*)foundActor)) && (foundActor->update != NULL))) { break; @@ -73,45 +73,47 @@ void func_80953B40(BgIngate* this) { s32 temp; if (!(gSaveContext.eventInf[3] & 0x20)) { - this->unk180 = 0xFA0; - this->unk168 = 4; + this->timePathTotalTime = 4 * 1000; + this->timePathTimeSpeed = 4; } else { - this->unk180 = 0x7D0; - this->unk168 = 1; + this->timePathTotalTime = 1 * 2000; + this->timePathTimeSpeed = 1; } - temp = this->unk164->count - 2; - this->unk184 = this->unk180 / temp; - this->unk188 = 2; - this->unk18C = 0; + 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; } s32 func_80953BEC(BgIngate* this) { - f32 sp74[265]; + f32 knots[265]; Vec3f sp68; Vec3f sp5C; - Vec3f unkVec; + Vec3f timePathTargetPos; s16 yaw; - func_8013AF00(sp74, 3, this->unk164->count + 3); + SubS_TimePathing_FillKnots(knots, SUBS_TIME_PATHING_ORDER, this->timePath->count + SUBS_TIME_PATHING_ORDER); if (!(this->unk160 & 1)) { - unkVec = gZeroVec3f; - func_8013B6B0(this->unk164, &this->unk17C, &this->unk18C, this->unk184, this->unk180, &this->unk188, sp74, - &unkVec, this->unk168); + 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 { - unkVec = this->unk170; + timePathTargetPos = this->timePathTargetPos; } - this->dyna.actor.world.pos.x = unkVec.x; - this->dyna.actor.world.pos.z = unkVec.z; - this->unk170 = gZeroVec3f; - if (func_8013B6B0(this->unk164, &this->unk17C, &this->unk18C, this->unk184, this->unk180, &this->unk188, sp74, - &this->unk170, this->unk168) != 0) { + this->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->unk170; + sp5C = this->timePathTargetPos; yaw = Math_Vec3f_Yaw(&sp68, &sp5C); this->dyna.actor.world.rot.y = yaw; this->dyna.actor.shape.rot.y = yaw; @@ -120,34 +122,34 @@ s32 func_80953BEC(BgIngate* this) { return false; } -s32 func_80953DA8(BgIngate* this, GlobalContext* globalCtx) { - Camera* camera = Play_GetCamera(globalCtx, CAM_ID_MAIN); +s32 func_80953DA8(BgIngate* this, PlayState* play) { + Camera* mainCam = Play_GetCamera(play, CAM_ID_MAIN); if (gSaveContext.eventInf[3] & 0x20) { - func_800B7298(globalCtx, &this->dyna.actor, 7); + func_800B7298(play, &this->dyna.actor, 7); } else { gSaveContext.eventInf[4] |= 2; } - func_800DFAC8(camera, 47); - globalCtx->unk_1887C = 0x63; + Camera_ChangeSetting(mainCam, CAM_SET_BOAT_CRUISE); + play->unk_1887C = 0x63; return false; } -void func_80953E38(GlobalContext* globalCtx) { - func_800DFAC8(Play_GetCamera(globalCtx, CAM_ID_MAIN), 1); +void func_80953E38(PlayState* play) { + Camera_ChangeSetting(Play_GetCamera(play, CAM_ID_MAIN), CAM_SET_NORMAL0); if (!(gSaveContext.eventInf[3] & 0x20)) { gSaveContext.eventInf[4] &= (u8)~2; } - globalCtx->unk_1887C = -1; + play->unk_1887C = -1; } -void func_80953EA4(BgIngate* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); +void func_80953EA4(BgIngate* this, PlayState* play) { + Player* player = GET_PLAYER(play); - func_800B7298(globalCtx, &this->dyna.actor, 0x3A); + func_800B7298(play, &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; @@ -155,44 +157,44 @@ void func_80953EA4(BgIngate* this, GlobalContext* globalCtx) { this->actionFunc = func_80954340; } -void func_80953F14(BgIngate* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); +void func_80953F14(BgIngate* this, PlayState* play) { + Player* player = GET_PLAYER(play); player->actor.shape.rot.y = this->dyna.actor.shape.rot.y; player->actor.world.rot.y = player->actor.shape.rot.y; player->currentYaw = player->actor.shape.rot.y; player->actor.focus.rot.y = player->actor.shape.rot.y; this->unk160 |= 0x10; - func_80953DA8(this, globalCtx); - if (this->unk164 != NULL) { + func_80953DA8(this, play); + if (this->timePath != NULL) { func_80953B40(this); } this->unk16E = -1; this->actionFunc = func_80953F9C; } -void func_80953F8C(BgIngate* this, GlobalContext* globalCtx) { +void func_80953F8C(BgIngate* this, PlayState* play) { } -void func_80953F9C(BgIngate* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); - Camera* camera = Play_GetCamera(globalCtx, CAM_ID_MAIN); +void func_80953F9C(BgIngate* this, PlayState* play) { + Player* player = GET_PLAYER(play); + Camera* mainCam = Play_GetCamera(play, 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); + Message_StartTextbox(play, this->dyna.actor.textId, NULL); this->unk160 &= ~0x10; } if (this->unk160 & 2) { - if (this->unk164->unk1 != 0xFF) { - func_80953E38(globalCtx); - func_800B7298(globalCtx, &this->dyna.actor, 7); + if (this->timePath->unk1 != 0xFF) { + func_80953E38(play); + func_800B7298(play, &this->dyna.actor, 7); this->dyna.actor.textId = 0x9E4; - Message_StartTextbox(globalCtx, this->dyna.actor.textId, NULL); + Message_StartTextbox(play, this->dyna.actor.textId, NULL); this->unk16C += 1; gSaveContext.save.weekEventReg[90] |= 0x40; this->actionFunc = func_809543D4; @@ -205,34 +207,34 @@ void func_80953F9C(BgIngate* this, GlobalContext* globalCtx) { } this->actionFunc = func_809542A0; } - } else if ((ActorCutscene_GetCurrentIndex() == -1) && (this->unk164 != NULL)) { + } 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); + Camera_ChangeSetting(mainCam, CAM_SET_NORMAL0); player->stateFlags1 |= 0x20; - globalCtx->actorCtx.unk5 &= ~0x4; + play->actorCtx.unk5 &= ~0x4; } else { - func_800DFAC8(camera, 47); + Camera_ChangeSetting(mainCam, CAM_SET_BOAT_CRUISE); player->stateFlags1 &= ~0x20; } } this->unk16E = ActorCutscene_GetCurrentIndex(); } -void func_809541B8(BgIngate* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); +void func_809541B8(BgIngate* this, PlayState* play) { + Player* player = GET_PLAYER(play); if (this->unk160 & 0x4) { if ((player->transformation == PLAYER_FORM_HUMAN) && (player->actor.bgCheckFlags & 1) && (this->dyna.actor.xzDistToPlayer < 40.0f)) { if (this->dyna.actor.playerHeightRel > 15.0f) { - func_800B7298(globalCtx, &this->dyna.actor, 7); + func_800B7298(play, &this->dyna.actor, 7); this->dyna.actor.textId = 0x9E6; - Message_StartTextbox(globalCtx, this->dyna.actor.textId, NULL); + Message_StartTextbox(play, this->dyna.actor.textId, NULL); this->actionFunc = func_809543D4; } } @@ -241,94 +243,93 @@ void func_809541B8(BgIngate* this, GlobalContext* globalCtx) { } } -void func_809542A0(BgIngate* this, GlobalContext* globalCtx) { +void func_809542A0(BgIngate* this, PlayState* play) { if (gSaveContext.eventInf[5] & 1) { - globalCtx->nextEntranceIndex = 0xA820; + play->nextEntrance = ENTRANCE(TOURIST_INFORMATION, 2); gSaveContext.eventInf[5] &= (u8)~1; } else { - globalCtx->nextEntranceIndex = 0xA810; + play->nextEntrance = ENTRANCE(TOURIST_INFORMATION, 1); } gSaveContext.nextCutsceneIndex = 0; - globalCtx->sceneLoadFlag = 0x14; - globalCtx->unk_1887F = 3; - gSaveContext.nextTransition = 3; + play->transitionTrigger = TRANS_TRIGGER_START; + play->transitionType = TRANS_TYPE_03; + gSaveContext.nextTransitionType = TRANS_TYPE_03; this->actionFunc = func_80953F8C; gSaveContext.save.weekEventReg[90] &= (u8)~0x40; func_800FE498(); } -void func_80954340(BgIngate* this, GlobalContext* globalCtx) { +void func_80954340(BgIngate* this, PlayState* play) { if (!DECR(this->unk16A)) { - if (this->unk164 != NULL) { - func_800B7298(globalCtx, &this->dyna.actor, 6); - this->unk164 = &globalCtx->setupPathList[this->unk164->unk1]; - func_80953F14(this, globalCtx); + if (this->timePath != NULL) { + func_800B7298(play, &this->dyna.actor, 6); + this->timePath = &play->setupPathList[this->timePath->unk1]; + func_80953F14(this, play); func_800FE484(); } } } -void func_809543D4(BgIngate* this, GlobalContext* globalCtx) { - u8 talkState = Message_GetState(&globalCtx->msgCtx); +void func_809543D4(BgIngate* this, PlayState* play) { + u8 talkState = Message_GetState(&play->msgCtx); - if (((talkState == 4) || (talkState == 5)) && Message_ShouldAdvance(globalCtx)) { + if (((talkState == TEXT_STATE_CHOICE) || (talkState == TEXT_STATE_5)) && Message_ShouldAdvance(play)) { switch (this->dyna.actor.textId) { case 0x9E4: this->dyna.actor.textId = 0x9E5; - func_80151938(globalCtx, this->dyna.actor.textId); + func_80151938(play, this->dyna.actor.textId); break; case 0x9E5: - if (globalCtx->msgCtx.choiceIndex == 0) { - func_800B7298(globalCtx, &this->dyna.actor, 6); + if (play->msgCtx.choiceIndex == 0) { + func_800B7298(play, &this->dyna.actor, 6); this->unk160 &= ~0x4; this->actionFunc = func_809541B8; func_800FE498(); func_8019F208(); } else { - if (this->unk164 != NULL) { - this->unk164 = &globalCtx->setupPathList[this->unk164->unk1]; + if (this->timePath != NULL) { + this->timePath = &play->setupPathList[this->timePath->unk1]; } - func_80953F14(this, globalCtx); + func_80953F14(this, play); gSaveContext.save.weekEventReg[90] &= (u8)~0x40; func_8019F230(); } - func_801477B4(globalCtx); + func_801477B4(play); break; case 0x9E6: - if (globalCtx->msgCtx.choiceIndex == 0) { - func_80953EA4(this, globalCtx); + if (play->msgCtx.choiceIndex == 0) { + func_80953EA4(this, play); gSaveContext.save.weekEventReg[90] &= (u8)~0x40; func_8019F208(); } else { - this = this; - func_800B7298(globalCtx, &this->dyna.actor, 6); + func_800B7298(play, &this->dyna.actor, 6); this->unk160 &= ~0x4; this->actionFunc = func_809541B8; func_800FE498(); func_8019F230(); } - func_801477B4(globalCtx); + func_801477B4(play); break; } } } -void BgIngate_Init(Actor* thisx, GlobalContext* globalCtx2) { - GlobalContext* globalCtx = globalCtx2; +void BgIngate_Init(Actor* thisx, PlayState* play2) { + PlayState* play = play2; BgIngate* this = THIS; s32 phi_a2; Vec3s* sp38; Vec3f sp2C; Vec3f sp20; - if (BgIngate_FindActor(this, globalCtx, ACTORCAT_BG, ACTOR_BG_INGATE) == NULL) { + if (BgIngate_FindActor(this, play, ACTORCAT_BG, ACTOR_BG_INGATE) == NULL) { DynaPolyActor_Init(&this->dyna, 3); - DynaPolyActor_LoadMesh(globalCtx, &this->dyna, &gSichitaiBoatCol); + DynaPolyActor_LoadMesh(play, &this->dyna, &gSichitaiBoatCol); this->unk160 = 0; this->unk160 |= 0x8; this->unk160 |= 0x10; Actor_SetScale(&this->dyna.actor, 1.0f); - this->unk164 = SubS_GetAdditionalPath(globalCtx, BGINGATE_GET_FF(&this->dyna.actor), 0); + this->timePath = SubS_GetAdditionalPath(play, BGINGATE_GET_FF(&this->dyna.actor), 0); this->dyna.actor.room = -1; if (gSaveContext.save.weekEventReg[20] & 2) { gSaveContext.save.weekEventReg[90] &= (u8)~0x40; @@ -339,10 +340,10 @@ void BgIngate_Init(Actor* thisx, GlobalContext* globalCtx2) { this->actionFunc = func_809541B8; } else { phi_a2 = 0; - if (globalCtx->curSpawn == 6) { - func_80953F14(this, globalCtx); + if (play->curSpawn == 6) { + func_80953F14(this, play); if (gSaveContext.eventInf[3] & 0x20) { - func_80112AFC(globalCtx); + func_80112AFC(play); } else { gSaveContext.eventInf[4] |= 2; } @@ -350,9 +351,9 @@ void BgIngate_Init(Actor* thisx, GlobalContext* globalCtx2) { this->actionFunc = func_80953F8C; } } - this->unk164 = SubS_GetAdditionalPath(globalCtx, BGINGATE_GET_FF(&this->dyna.actor), phi_a2); - if (this->unk164 != NULL) { - sp38 = Lib_SegmentedToVirtual(this->unk164->points); + this->timePath = SubS_GetAdditionalPath(play, 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); @@ -361,32 +362,32 @@ void BgIngate_Init(Actor* thisx, GlobalContext* globalCtx2) { this->dyna.actor.world.pos.y = -15.0f; this->dyna.actor.world.pos.z = sp2C.z; } - this->unk164 = SubS_GetAdditionalPath(globalCtx, BGINGATE_GET_FF(&this->dyna.actor), 0); + this->timePath = SubS_GetAdditionalPath(play, BGINGATE_GET_FF(&this->dyna.actor), 0); } else { Actor_MarkForDeath(&this->dyna.actor); } } -void BgIngate_Destroy(Actor* thisx, GlobalContext* globalCtx) { +void BgIngate_Destroy(Actor* thisx, PlayState* play) { BgIngate* this = THIS; if (this->unk160 & 8) { - DynaPoly_DeleteBgActor(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); + DynaPoly_DeleteBgActor(play, &play->colCtx.dyna, this->dyna.bgId); } } -void BgIngate_Update(Actor* thisx, GlobalContext* globalCtx) { +void BgIngate_Update(Actor* thisx, PlayState* play) { BgIngate* this = THIS; - this->actionFunc(this, globalCtx); + this->actionFunc(this, play); } -void BgIngate_Draw(Actor* thisx, GlobalContext* globalCtx) { - OPEN_DISPS(globalCtx->state.gfxCtx); +void BgIngate_Draw(Actor* thisx, PlayState* play) { + OPEN_DISPS(play->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); + func_8012C28C(play->state.gfxCtx); + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_OPA_DISP++, gSichitaiBoat); - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->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 08d062e6c..b38ce2eeb 100644 --- a/src/overlays/actors/ovl_Bg_Ingate/z_bg_ingate.h +++ b/src/overlays/actors/ovl_Bg_Ingate/z_bg_ingate.h @@ -5,7 +5,7 @@ struct BgIngate; -typedef void (*BgIngateActionFunc)(struct BgIngate*, GlobalContext*); +typedef void (*BgIngateActionFunc)(struct BgIngate*, PlayState*); #define BGINGATE_GET_FF(thisx) ((thisx)->params & 0xFF) @@ -13,17 +13,17 @@ typedef struct BgIngate { /* 0x000 */ DynaPolyActor dyna; /* 0x15C */ BgIngateActionFunc actionFunc; /* 0x160 */ u16 unk160; - /* 0x164 */ Path* unk164; - /* 0x168 */ s16 unk168; + /* 0x164 */ Path* timePath; + /* 0x168 */ s16 timePathTimeSpeed; /* 0x16A */ s16 unk16A; /* 0x16C */ s16 unk16C; /* 0x16E */ s16 unk16E; - /* 0x170 */ Vec3f unk170; - /* 0x17C */ f32 unk17C; - /* 0x180 */ s32 unk180; - /* 0x184 */ s32 unk184; - /* 0x188 */ s32 unk188; - /* 0x18C */ s32 unk18C; + /* 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 9ae16fb1c..bd641bf4c 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 @@ -11,9 +11,9 @@ #define THIS ((BgInibsMovebg*)thisx) -void BgInibsMovebg_Init(Actor* thisx, GlobalContext* globalCtx); -void BgInibsMovebg_Destroy(Actor* thisx, GlobalContext* globalCtx); -void BgInibsMovebg_Draw(Actor* thisx, GlobalContext* globalCtx); +void BgInibsMovebg_Init(Actor* thisx, PlayState* play); +void BgInibsMovebg_Destroy(Actor* thisx, PlayState* play); +void BgInibsMovebg_Draw(Actor* thisx, PlayState* play); const ActorInit Bg_Inibs_Movebg_InitVars = { ACTOR_BG_INIBS_MOVEBG, @@ -35,7 +35,7 @@ static InitChainEntry sInitChain[] = { ICHAIN_VEC3F_DIV1000(scale, 1000, ICHAIN_STOP), }; -void BgInibsMovebg_Init(Actor* thisx, GlobalContext* globalCtx) { +void BgInibsMovebg_Init(Actor* thisx, PlayState* play) { BgInibsMovebg* this = THIS; Actor_ProcessInitChain(&this->dyna.actor, sInitChain); @@ -46,13 +46,13 @@ void BgInibsMovebg_Init(Actor* thisx, GlobalContext* globalCtx) { this->unk_164 = D_80B96570[BGINIBSMOVEBG_GET_F(thisx)]; } -void BgInibsMovebg_Destroy(Actor* thisx, GlobalContext* globalCtx) { +void BgInibsMovebg_Destroy(Actor* thisx, PlayState* play) { BgInibsMovebg* this = THIS; - DynaPoly_DeleteBgActor(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); + DynaPoly_DeleteBgActor(play, &play->colCtx.dyna, this->dyna.bgId); } -void BgInibsMovebg_Draw(Actor* thisx, GlobalContext* globalCtx) { +void BgInibsMovebg_Draw(Actor* thisx, PlayState* play) { BgInibsMovebg* this = THIS; AnimatedMaterial* animMat; @@ -61,16 +61,16 @@ void BgInibsMovebg_Draw(Actor* thisx, GlobalContext* globalCtx) { animMat = this->unk_164; if (animMat != NULL) { - AnimatedMat_Draw(globalCtx, Lib_SegmentedToVirtual(this->unk_164)); + AnimatedMat_Draw(play, Lib_SegmentedToVirtual(this->unk_164)); } dl1 = this->unk_15C; if (dl1 != NULL) { - Gfx_DrawDListOpa(globalCtx, this->unk_15C); + Gfx_DrawDListOpa(play, this->unk_15C); } dl2 = this->unk_160; if (dl2 != NULL) { - Gfx_DrawDListXlu(globalCtx, this->unk_160); + Gfx_DrawDListXlu(play, this->unk_160); } } 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..63ef9d369 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,17 +5,21 @@ */ #include "z_bg_keikoku_saku.h" +#include "objects/object_keikoku_obj/object_keikoku_obj.h" #define FLAGS 0x00000000 #define THIS ((BgKeikokuSaku*)thisx) -void BgKeikokuSaku_Init(Actor* thisx, GlobalContext* globalCtx); -void BgKeikokuSaku_Destroy(Actor* thisx, GlobalContext* globalCtx); -void BgKeikokuSaku_Update(Actor* thisx, GlobalContext* globalCtx); -void BgKeikokuSaku_Draw(Actor* thisx, GlobalContext* globalCtx); +void BgKeikokuSaku_Init(Actor* thisx, PlayState* play); +void BgKeikokuSaku_Destroy(Actor* thisx, PlayState* play); +void BgKeikokuSaku_Update(Actor* thisx, PlayState* play); +void BgKeikokuSaku_Draw(Actor* thisx, PlayState* play); + +void func_80A5389C(BgKeikokuSaku* this, PlayState* play); +void func_80A538E0(BgKeikokuSaku* this, PlayState* play); +void func_80A53994(BgKeikokuSaku* this, PlayState* play); -#if 0 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, PlayState* play) { + 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(play, &play->colCtx.dyna, &this->dyna.actor, colHeader); + this->switchFlag = BGKEIKOKUSAKU_GET_SWITCHFLAG(thisx); + if (Flags_GetSwitch(play, 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, PlayState* play) { + BgKeikokuSaku* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Keikoku_Saku/BgKeikokuSaku_Destroy.s") + DynaPoly_DeleteBgActor(play, &play->colCtx.dyna, this->dyna.bgId); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Keikoku_Saku/func_80A5389C.s") +void func_80A5389C(BgKeikokuSaku* this, PlayState* play) { + if (Flags_GetSwitch(play, 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, PlayState* play) { + 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, PlayState* play) { + 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, PlayState* play) { + 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, play); +} + +void BgKeikokuSaku_Draw(Actor* thisx, PlayState* play) { + OPEN_DISPS(play->state.gfxCtx); + + func_8012C2DC(play->state.gfxCtx); + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_XLU_DISP++, object_keikoku_obj_DL_001640); + + CLOSE_DISPS(play->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..c39994d77 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,16 +3,18 @@ #include "global.h" +#define BGKEIKOKUSAKU_GET_SWITCHFLAG(thisx) ((thisx)->params & 0x7F) + struct BgKeikokuSaku; -typedef void (*BgKeikokuSakuActionFunc)(struct BgKeikokuSaku*, GlobalContext*); +typedef void (*BgKeikokuSakuActionFunc)(struct BgKeikokuSaku*, PlayState*); 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; diff --git a/src/overlays/actors/ovl_Bg_Keikoku_Spr/z_bg_keikoku_spr.c b/src/overlays/actors/ovl_Bg_Keikoku_Spr/z_bg_keikoku_spr.c index 28cea492c..f54564e2d 100644 --- a/src/overlays/actors/ovl_Bg_Keikoku_Spr/z_bg_keikoku_spr.c +++ b/src/overlays/actors/ovl_Bg_Keikoku_Spr/z_bg_keikoku_spr.c @@ -11,10 +11,10 @@ #define THIS ((BgKeikokuSpr*)thisx) -void BgKeikokuSpr_Init(Actor* thisx, GlobalContext* globalCtx); -void BgKeikokuSpr_Destroy(Actor* thisx, GlobalContext* globalCtx); -void BgKeikokuSpr_Update(Actor* thisx, GlobalContext* globalCtx); -void BgKeikokuSpr_Draw(Actor* thisx, GlobalContext* globalCtx); +void BgKeikokuSpr_Init(Actor* thisx, PlayState* play); +void BgKeikokuSpr_Destroy(Actor* thisx, PlayState* play); +void BgKeikokuSpr_Update(Actor* thisx, PlayState* play); +void BgKeikokuSpr_Draw(Actor* thisx, PlayState* play); const ActorInit Bg_Keikoku_Spr_InitVars = { ACTOR_BG_KEIKOKU_SPR, @@ -35,28 +35,28 @@ static InitChainEntry sInitChain[] = { ICHAIN_VEC3F_DIV1000(scale, 20, ICHAIN_STOP), }; -void BgKeikokuSpr_Init(Actor* thisx, GlobalContext* globalCtx) { +void BgKeikokuSpr_Init(Actor* thisx, PlayState* play) { Actor_ProcessInitChain(thisx, sInitChain); } -void BgKeikokuSpr_Destroy(Actor* thisx, GlobalContext* globalCtx) { +void BgKeikokuSpr_Destroy(Actor* thisx, PlayState* play) { } -void BgKeikokuSpr_Update(Actor* thisx, GlobalContext* globalCtx) { +void BgKeikokuSpr_Update(Actor* thisx, PlayState* play) { } -void BgKeikokuSpr_Draw(Actor* thisx, GlobalContext* globalCtx) { +void BgKeikokuSpr_Draw(Actor* thisx, PlayState* play) { s32 pad; - OPEN_DISPS(globalCtx->state.gfxCtx); + OPEN_DISPS(play->state.gfxCtx); - AnimatedMat_Draw(globalCtx, Lib_SegmentedToVirtual(object_keikoku_obj_Matanimheader_0001F8)); - gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + AnimatedMat_Draw(play, Lib_SegmentedToVirtual(object_keikoku_obj_Matanimheader_0001F8)); + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_XLU_DISP++, object_keikoku_obj_DL_000100); - AnimatedMat_Draw(globalCtx, Lib_SegmentedToVirtual(object_keikoku_obj_Matanimheader_0003F8)); + AnimatedMat_Draw(play, Lib_SegmentedToVirtual(object_keikoku_obj_Matanimheader_0003F8)); gSPDisplayList(POLY_XLU_DISP++, object_keikoku_obj_DL_000300); - AnimatedMat_Draw(globalCtx, Lib_SegmentedToVirtual(object_keikoku_obj_Matanimheader_0005F8)); + AnimatedMat_Draw(play, Lib_SegmentedToVirtual(object_keikoku_obj_Matanimheader_0005F8)); gSPDisplayList(POLY_XLU_DISP++, object_keikoku_obj_DL_000500); - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->state.gfxCtx); } 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 5630bdd8f..86854cbe8 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 @@ -3,20 +3,26 @@ * Overlay: ovl_Bg_Kin2_Bombwall * Description: Ocean Spider House - Bombable Wall */ - #include "z_bg_kin2_bombwall.h" +#include "objects/object_kin2_obj/object_kin2_obj.h" #define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_10000000) #define THIS ((BgKin2Bombwall*)thisx) -void BgKin2Bombwall_Init(Actor* thisx, GlobalContext* globalCtx); -void BgKin2Bombwall_Destroy(Actor* thisx, GlobalContext* globalCtx); -void BgKin2Bombwall_Update(Actor* thisx, GlobalContext* globalCtx); -void BgKin2Bombwall_Draw(Actor* thisx, GlobalContext* globalCtx); +void BgKin2Bombwall_Init(Actor* thisx, PlayState* play); +void BgKin2Bombwall_Destroy(Actor* thisx, PlayState* play); +void BgKin2Bombwall_Update(Actor* thisx, PlayState* play); +void BgKin2Bombwall_Draw(Actor* thisx, PlayState* play); -#if 0 -const ActorInit Bg_Kin2_Bombwall_InitVars = { +void BgKin2Bombwall_SetupWait(BgKin2Bombwall* this); +void BgKin2Bombwall_Wait(BgKin2Bombwall* this, PlayState* play); +void BgKin2Bombwall_SetupPlayCutscene(BgKin2Bombwall* this); +void BgKin2Bombwall_PlayCutscene(BgKin2Bombwall* this, PlayState* play); +void BgKin2Bombwall_SetupEndCutscene(BgKin2Bombwall* this); +void BgKin2Bombwall_EndCutscene(BgKin2Bombwall* this, PlayState* play); + +ActorInit Bg_Kin2_Bombwall_InitVars = { ACTOR_BG_KIN2_BOMBWALL, ACTORCAT_BG, FLAGS, @@ -28,50 +34,190 @@ const ActorInit Bg_Kin2_Bombwall_InitVars = { (ActorFunc)BgKin2Bombwall_Draw, }; -// static ColliderCylinderInit sCylinderInit = { -static ColliderCylinderInit D_80B6E6F0 = { - { 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, + }, { 60, 60, 0, { 0, 0, 0 } }, }; -// static InitChainEntry sInitChain[] = { -static InitChainEntry D_80B6E748[] = { +s32 BgKin2Bombwall_IsHitFromNearby(BgKin2Bombwall* this, PlayState* play) { + Actor* bombwallCollider; + + if (this->collider.base.acFlags & AC_HIT) { + bombwallCollider = this->collider.base.ac; + // Distance check required to only react to sufficiently close explosions. + if ((bombwallCollider != NULL) && + (Math3D_Vec3fDistSq(&this->dyna.actor.world.pos, &bombwallCollider->world.pos) < 6400.0f)) { + return true; + } + } + return false; +} + +static Color_RGBA8 sPrimColor = { 210, 210, 210, 255 }; +static Color_RGBA8 sEnvColor = { 140, 140, 140, 255 }; +static Vec3f sDustAccel = { 0.0f, 0.33f, 0.0f }; +static s8 sRandomYOffsets[] = { -60, -34, -8, 18, 44 }; +static s16 sScales[] = { 25, 23, 21, 19, 17, 15, 13, 10 }; // Scales for random explosion debris. + +void BgKin2Bombwall_SpawnEffects(BgKin2Bombwall* this, PlayState* play) { + s32 i; + Vec3f pos; + Vec3f velocity; + Vec3f spD8; + Vec3f spCC; + s32 j; + s32 k; + f32 temp_a0; + s32 pad; + s16 phi_s0; + s16 phi_s1; + + Matrix_RotateYS(this->dyna.actor.shape.rot.y, 0); + + for (i = 0, k = 0; i < 6; i++) { + temp_a0 = (i + 1) * 15.f; + for (j = 0; j < ARRAY_COUNT(sRandomYOffsets); j++) { + k++; + k &= 7; + + spD8.x = sRandomYOffsets[j] + (s32)(Rand_Next() >> 0x1C); + spD8.y = ((Rand_ZeroOne() - 0.5f) * 15.0f) + temp_a0; + spD8.z = (Rand_ZeroOne() * 20.0f) - 10.0f; + + spCC.x = (2.0f * (Rand_ZeroOne() - 0.5f)) + (spD8.x * (6.0f / 325.0f)); + spCC.y = (Rand_ZeroOne() * 7.0f) + 4.0f; + spCC.z = spD8.z * 0.3f; + + Matrix_MultVec3f(&spD8, &pos); + Matrix_MultVec3f(&spCC, &velocity); + + pos.x += this->dyna.actor.world.pos.x; + pos.y += this->dyna.actor.world.pos.y; + pos.z += this->dyna.actor.world.pos.z; + + if (Rand_Next() % 4 == 0) { + phi_s0 = 0x20; + } else { + phi_s0 = 0x40; + } + + if (k < 2 || (s32)Rand_Next() > 0) { + phi_s0 |= 1; + phi_s1 = 1; + func_800B0E48(play, &pos, &gZeroVec3f, &sDustAccel, &sPrimColor, &sEnvColor, (Rand_Next() >> 0x1B) + 70, + (Rand_Next() >> 0x1A) + 60); // for dust spawn + } else { + phi_s1 = 0; + } + EffectSsKakera_Spawn(play, &pos, &velocity, &pos, -550, phi_s0, 30, 0, 0, sScales[k], phi_s1, 0, 50, -1, + OBJECT_KIN2_OBJ, gOceanSpiderHouseBombableWallDebrisDL); + } + } +} + +static InitChainEntry sInitChain[] = { ICHAIN_F32(uncullZoneForward, 4000, ICHAIN_CONTINUE), ICHAIN_F32(uncullZoneScale, 200, ICHAIN_CONTINUE), ICHAIN_F32(uncullZoneDownward, 300, ICHAIN_CONTINUE), ICHAIN_VEC3F_DIV1000(scale, 1000, ICHAIN_STOP), }; -#endif +void BgKin2Bombwall_Init(Actor* thisx, PlayState* play) { + BgKin2Bombwall* this = THIS; + ColliderCylinder* bombwallCollider; -extern ColliderCylinderInit D_80B6E6F0; -extern InitChainEntry D_80B6E748[]; + Actor_ProcessInitChain(&this->dyna.actor, sInitChain); + DynaPolyActor_Init(&this->dyna, 0); + bombwallCollider = &this->collider; + Collider_InitCylinder(play, bombwallCollider); + if (Flags_GetSwitch(play, BG_KIN2_BOMBWALL_SWITCH_FLAG(&this->dyna.actor))) { + Actor_MarkForDeath(&this->dyna.actor); + } else { + DynaPolyActor_LoadMesh(play, &this->dyna, &gOceanSpiderHouseBombableWallCol); + Collider_SetCylinder(play, bombwallCollider, &this->dyna.actor, &sCylinderInit); + Collider_UpdateCylinder(&this->dyna.actor, bombwallCollider); + Actor_SetFocus(&this->dyna.actor, 60.0f); + BgKin2Bombwall_SetupWait(this); + } +} -extern UNK_TYPE D_06000128; -extern UNK_TYPE D_06000360; -extern UNK_TYPE D_06000490; +void BgKin2Bombwall_Destroy(Actor* thisx, PlayState* play) { + BgKin2Bombwall* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Kin2_Bombwall/func_80B6E020.s") + DynaPoly_DeleteBgActor(play, &play->colCtx.dyna, this->dyna.bgId); + Collider_DestroyCylinder(play, &this->collider); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Kin2_Bombwall/func_80B6E090.s") +void BgKin2Bombwall_SetupWait(BgKin2Bombwall* this) { + this->actionFunc = BgKin2Bombwall_Wait; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Kin2_Bombwall/BgKin2Bombwall_Init.s") +void BgKin2Bombwall_Wait(BgKin2Bombwall* this, PlayState* play) { + if (BgKin2Bombwall_IsHitFromNearby(this, play)) { + this->collider.base.acFlags &= ~AC_HIT; + ActorCutscene_SetIntentToPlay(this->dyna.actor.cutscene); + BgKin2Bombwall_SetupPlayCutscene(this); + } else { + CollisionCheck_SetAC(play, &play->colChkCtx, &this->collider.base); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Kin2_Bombwall/BgKin2Bombwall_Destroy.s") +void BgKin2Bombwall_SetupPlayCutscene(BgKin2Bombwall* this) { + this->actionFunc = BgKin2Bombwall_PlayCutscene; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Kin2_Bombwall/func_80B6E4B8.s") +void BgKin2Bombwall_PlayCutscene(BgKin2Bombwall* this, PlayState* play) { + if (ActorCutscene_GetCanPlayNext(this->dyna.actor.cutscene)) { + ActorCutscene_StartAndSetUnkLinkFields(this->dyna.actor.cutscene, &this->dyna.actor); + Flags_SetSwitch(play, BG_KIN2_BOMBWALL_SWITCH_FLAG(&this->dyna.actor)); + SoundSource_PlaySfxAtFixedWorldPos(play, &this->dyna.actor.world.pos, 60, NA_SE_EV_WALL_BROKEN); + func_800C62BC(play, &play->colCtx.dyna, this->dyna.bgId); + this->dyna.actor.draw = NULL; + BgKin2Bombwall_SpawnEffects(this, play); + BgKin2Bombwall_SetupEndCutscene(this); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Kin2_Bombwall/func_80B6E4CC.s") + } else { + ActorCutscene_SetIntentToPlay(this->dyna.actor.cutscene); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Kin2_Bombwall/func_80B6E544.s") +void BgKin2Bombwall_SetupEndCutscene(BgKin2Bombwall* this) { + this->timer = 40; + this->actionFunc = BgKin2Bombwall_EndCutscene; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Kin2_Bombwall/func_80B6E558.s") +void BgKin2Bombwall_EndCutscene(BgKin2Bombwall* this, PlayState* play) { + this->timer--; + if (this->timer <= 0) { + ActorCutscene_Stop(this->dyna.actor.cutscene); + Actor_MarkForDeath(&this->dyna.actor); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Kin2_Bombwall/func_80B6E5F8.s") +void BgKin2Bombwall_Update(Actor* thisx, PlayState* play) { + BgKin2Bombwall* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Kin2_Bombwall/func_80B6E614.s") + this->actionFunc(this, play); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Kin2_Bombwall/BgKin2Bombwall_Update.s") +void BgKin2Bombwall_Draw(Actor* thisx, PlayState* play) { + BgKin2Bombwall* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Kin2_Bombwall/BgKin2Bombwall_Draw.s") + Gfx_DrawDListOpa(play, gOceanSpiderHouseBombableWallDL); + Gfx_DrawDListXlu(play, gOceanSpiderHouseBombableWallCrackDL); +} diff --git a/src/overlays/actors/ovl_Bg_Kin2_Bombwall/z_bg_kin2_bombwall.h b/src/overlays/actors/ovl_Bg_Kin2_Bombwall/z_bg_kin2_bombwall.h index 25ebd0362..17370427a 100644 --- a/src/overlays/actors/ovl_Bg_Kin2_Bombwall/z_bg_kin2_bombwall.h +++ b/src/overlays/actors/ovl_Bg_Kin2_Bombwall/z_bg_kin2_bombwall.h @@ -1,19 +1,19 @@ #ifndef Z_BG_KIN2_BOMBWALL_H #define Z_BG_KIN2_BOMBWALL_H +#define BG_KIN2_BOMBWALL_SWITCH_FLAG(thisx) ((thisx)->params & 0x7F) + #include "global.h" struct BgKin2Bombwall; -typedef void (*BgKin2BombwallActionFunc)(struct BgKin2Bombwall*, GlobalContext*); +typedef void (*BgKin2BombwallActionFunc)(struct BgKin2Bombwall*, PlayState*); typedef struct BgKin2Bombwall { - /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x64]; - /* 0x01A8 */ BgKin2BombwallActionFunc actionFunc; - /* 0x01AC */ char unk_1AC[0x4]; + /* 0x000 */ DynaPolyActor dyna; + /* 0x15C */ ColliderCylinder collider; + /* 0x1A8 */ BgKin2BombwallActionFunc actionFunc; + /* 0x1AC */ s8 timer; } BgKin2Bombwall; // size = 0x1B0 -extern const ActorInit Bg_Kin2_Bombwall_InitVars; - #endif // Z_BG_KIN2_BOMBWALL_H 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 6e27d1dc9..628ade7f1 100644 --- a/src/overlays/actors/ovl_Bg_Kin2_Fence/z_bg_kin2_fence.c +++ b/src/overlays/actors/ovl_Bg_Kin2_Fence/z_bg_kin2_fence.c @@ -11,21 +11,21 @@ #define THIS ((BgKin2Fence*)thisx) -void BgKin2Fence_Init(Actor* thisx, GlobalContext* globalCtx); -void BgKin2Fence_Destroy(Actor* thisx, GlobalContext* globalCtx); -void BgKin2Fence_Update(Actor* thisx, GlobalContext* globalCtx); -void BgKin2Fence_Draw(Actor* thisx, GlobalContext* globalCtx); +void BgKin2Fence_Init(Actor* thisx, PlayState* play); +void BgKin2Fence_Destroy(Actor* thisx, PlayState* play); +void BgKin2Fence_Update(Actor* thisx, PlayState* play); +void BgKin2Fence_Draw(Actor* thisx, PlayState* play); void BgKin2Fence_SetupHandleMaskCode(BgKin2Fence* this); -void BgKin2Fence_HandleMaskCode(BgKin2Fence* this, GlobalContext* globalCtx); +void BgKin2Fence_HandleMaskCode(BgKin2Fence* this, PlayState* play); void BgKin2Fence_SetupPlayOpenCutscene(BgKin2Fence* this); -void BgKin2Fence_PlayOpenCutscene(BgKin2Fence* this, GlobalContext* globalCtx); +void BgKin2Fence_PlayOpenCutscene(BgKin2Fence* this, PlayState* play); void BgKin2Fence_SetupWaitBeforeOpen(BgKin2Fence* this); -void BgKin2Fence_WaitBeforeOpen(BgKin2Fence* this, GlobalContext* globalCtx); +void BgKin2Fence_WaitBeforeOpen(BgKin2Fence* this, PlayState* play); void BgKin2Fence_SetupRaiseFence(BgKin2Fence* this); -void BgKin2Fence_RaiseFence(BgKin2Fence* this, GlobalContext* globalCtx); +void BgKin2Fence_RaiseFence(BgKin2Fence* this, PlayState* play); void BgKin2Fence_SetupDoNothing(BgKin2Fence* this); -void BgKin2Fence_DoNothing(BgKin2Fence* this, GlobalContext* globalCtx); +void BgKin2Fence_DoNothing(BgKin2Fence* this, PlayState* play); const ActorInit Bg_Kin2_Fence_InitVars = { ACTOR_BG_KIN2_FENCE, @@ -95,7 +95,7 @@ static ColliderJntSphInit sJntSphInit = { OC2_TYPE_2, COLSHAPE_JNTSPH, }, - 4, + ARRAY_COUNT(sJntSphElementsInit), sJntSphElementsInit, }; @@ -137,49 +137,49 @@ s32 BgKin2Fence_CheckHitMask(BgKin2Fence* this) { return -1; } -void BgKin2Fence_SpawnEyeSparkles(BgKin2Fence* this, GlobalContext* globalCtx, s32 mask) { +void BgKin2Fence_SpawnEyeSparkles(BgKin2Fence* this, PlayState* play, s32 mask) { s32 i; 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(play, &sp58, &gZeroVec3f, &gZeroVec3f, &primColor, &envColor, 6000, -10); } } -void BgKin2Fence_Init(Actor* thisx, GlobalContext* globalCtx) { +void BgKin2Fence_Init(Actor* thisx, PlayState* play) { BgKin2Fence* this = THIS; s32 i = 0; Actor_ProcessInitChain(&this->dyna.actor, sInitChain); DynaPolyActor_Init(&this->dyna, 0); - 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); + DynaPolyActor_LoadMesh(play, &this->dyna, &object_kin2_obj_Colheader_000908); + Collider_InitJntSph(play, &this->collider); + Collider_SetJntSph(play, &this->collider, &this->dyna.actor, &sJntSphInit, 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); 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++) { Collider_UpdateSpheres(i, &this->collider); } - if (Flags_GetSwitch(globalCtx, this->dyna.actor.params & 0x7F)) { + if (Flags_GetSwitch(play, this->dyna.actor.params & 0x7F)) { BgKin2Fence_SetupDoNothing(this); return; } BgKin2Fence_SetupHandleMaskCode(this); } -void BgKin2Fence_Destroy(Actor* thisx, GlobalContext* globalCtx) { +void BgKin2Fence_Destroy(Actor* thisx, PlayState* play) { BgKin2Fence* this = THIS; - DynaPoly_DeleteBgActor(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); - Collider_DestroyJntSph(globalCtx, &this->collider); + DynaPoly_DeleteBgActor(play, &play->colCtx.dyna, this->dyna.bgId); + Collider_DestroyJntSph(play, &this->collider); } void BgKin2Fence_SetupHandleMaskCode(BgKin2Fence* this) { @@ -187,7 +187,7 @@ void BgKin2Fence_SetupHandleMaskCode(BgKin2Fence* this) { this->actionFunc = BgKin2Fence_HandleMaskCode; } -void BgKin2Fence_HandleMaskCode(BgKin2Fence* this, GlobalContext* globalCtx) { +void BgKin2Fence_HandleMaskCode(BgKin2Fence* this, PlayState* play) { s32 hitMask; s32 nextMask; @@ -198,7 +198,7 @@ void BgKin2Fence_HandleMaskCode(BgKin2Fence* this, GlobalContext* globalCtx) { if (hitMask == nextMask) { play_sound(NA_SE_SY_TRE_BOX_APPEAR); this->masksHit += 1; - BgKin2Fence_SpawnEyeSparkles(this, globalCtx, nextMask); + BgKin2Fence_SpawnEyeSparkles(this, play, nextMask); } else { play_sound(NA_SE_SY_ERROR); this->masksHit = 0; @@ -215,7 +215,7 @@ void BgKin2Fence_HandleMaskCode(BgKin2Fence* this, GlobalContext* globalCtx) { this->cooldownTimer -= 1; return; } - CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + CollisionCheck_SetAC(play, &play->colChkCtx, &this->collider.base); } } @@ -223,10 +223,10 @@ void BgKin2Fence_SetupPlayOpenCutscene(BgKin2Fence* this) { this->actionFunc = BgKin2Fence_PlayOpenCutscene; } -void BgKin2Fence_PlayOpenCutscene(BgKin2Fence* this, GlobalContext* globalCtx) { +void BgKin2Fence_PlayOpenCutscene(BgKin2Fence* this, PlayState* play) { if (ActorCutscene_GetCanPlayNext(this->dyna.actor.cutscene)) { ActorCutscene_StartAndSetUnkLinkFields(this->dyna.actor.cutscene, &this->dyna.actor); - Flags_SetSwitch(globalCtx, this->dyna.actor.params & 0x7F); + Flags_SetSwitch(play, this->dyna.actor.params & 0x7F); BgKin2Fence_SetupWaitBeforeOpen(this); return; } @@ -238,7 +238,7 @@ void BgKin2Fence_SetupWaitBeforeOpen(BgKin2Fence* this) { this->actionFunc = BgKin2Fence_WaitBeforeOpen; } -void BgKin2Fence_WaitBeforeOpen(BgKin2Fence* this, GlobalContext* globalCtx) { +void BgKin2Fence_WaitBeforeOpen(BgKin2Fence* this, PlayState* play) { if (this->waitBeforeOpenTimer > 0) { this->waitBeforeOpenTimer -= 1; } else { @@ -250,7 +250,7 @@ void BgKin2Fence_SetupRaiseFence(BgKin2Fence* this) { this->actionFunc = BgKin2Fence_RaiseFence; } -void BgKin2Fence_RaiseFence(BgKin2Fence* this, GlobalContext* globalCtx) { +void BgKin2Fence_RaiseFence(BgKin2Fence* this, PlayState* play) { if (Math_StepToF(&this->dyna.actor.world.pos.y, this->dyna.actor.home.pos.y + 58.0f, 5.0f)) { BgKin2Fence_SetupDoNothing(this); } @@ -260,15 +260,15 @@ void BgKin2Fence_SetupDoNothing(BgKin2Fence* this) { this->dyna.actor.world.pos.y = this->dyna.actor.home.pos.y + 58.0f; } -void BgKin2Fence_DoNothing(BgKin2Fence* this, GlobalContext* globalCtx) { +void BgKin2Fence_DoNothing(BgKin2Fence* this, PlayState* play) { } -void BgKin2Fence_Update(Actor* thisx, GlobalContext* globalCtx) { +void BgKin2Fence_Update(Actor* thisx, PlayState* play) { BgKin2Fence* this = THIS; - this->actionFunc(this, globalCtx); + this->actionFunc(this, play); } -void BgKin2Fence_Draw(Actor* thisx, GlobalContext* globalCtx) { - Gfx_DrawDListOpa(globalCtx, object_kin2_obj_DL_000828); +void BgKin2Fence_Draw(Actor* thisx, PlayState* play) { + Gfx_DrawDListOpa(play, gOceanSpiderHouseFireplaceGrateDL); } diff --git a/src/overlays/actors/ovl_Bg_Kin2_Fence/z_bg_kin2_fence.h b/src/overlays/actors/ovl_Bg_Kin2_Fence/z_bg_kin2_fence.h index 1272c4b54..00d08b85f 100644 --- a/src/overlays/actors/ovl_Bg_Kin2_Fence/z_bg_kin2_fence.h +++ b/src/overlays/actors/ovl_Bg_Kin2_Fence/z_bg_kin2_fence.h @@ -5,7 +5,7 @@ struct BgKin2Fence; -typedef void (*BgKin2FenceActionFunc)(struct BgKin2Fence*, GlobalContext*); +typedef void (*BgKin2FenceActionFunc)(struct BgKin2Fence*, PlayState*); typedef struct BgKin2Fence { /* 0x000 */ DynaPolyActor dyna; diff --git a/src/overlays/actors/ovl_Bg_Kin2_Picture/z_bg_kin2_picture.c b/src/overlays/actors/ovl_Bg_Kin2_Picture/z_bg_kin2_picture.c index e9326d8cd..2f50ca820 100644 --- a/src/overlays/actors/ovl_Bg_Kin2_Picture/z_bg_kin2_picture.c +++ b/src/overlays/actors/ovl_Bg_Kin2_Picture/z_bg_kin2_picture.c @@ -10,16 +10,16 @@ #define THIS ((BgKin2Picture*)thisx) -void BgKin2Picture_Init(Actor* thisx, GlobalContext* globalCtx); -void BgKin2Picture_Destroy(Actor* thisx, GlobalContext* globalCtx); -void BgKin2Picture_Update(Actor* thisx, GlobalContext* globalCtx); -void BgKin2Picture_Draw(Actor* thisx, GlobalContext* globalCtx); +void BgKin2Picture_Init(Actor* thisx, PlayState* play); +void BgKin2Picture_Destroy(Actor* thisx, PlayState* play); +void BgKin2Picture_Update(Actor* thisx, PlayState* play); +void BgKin2Picture_Draw(Actor* thisx, PlayState* play); -void func_80B6F4D4(BgKin2Picture* this, GlobalContext* globalCtx); -void func_80B6F5B8(BgKin2Picture* this, GlobalContext* globalCtx); -void func_80B6F640(BgKin2Picture* this, GlobalContext* globalCtx); -void func_80B6F72C(BgKin2Picture* this, GlobalContext* globalCtx); -void func_80B6F90C(BgKin2Picture* this, GlobalContext* globalCtx); +void func_80B6F4D4(BgKin2Picture* this, PlayState* play); +void func_80B6F5B8(BgKin2Picture* this, PlayState* play); +void func_80B6F640(BgKin2Picture* this, PlayState* play); +void func_80B6F72C(BgKin2Picture* this, PlayState* play); +void func_80B6F90C(BgKin2Picture* this, PlayState* play); #if 0 const ActorInit Bg_Kin2_Picture_InitVars = { @@ -49,7 +49,7 @@ static ColliderTrisElementInit D_80B6F990[2] = { // static ColliderTrisInit sTrisInit = { static ColliderTrisInit D_80B6FA08 = { { COLTYPE_NONE, AT_NONE, AC_ON | AC_TYPE_PLAYER, OC1_NONE, OC2_NONE, COLSHAPE_TRIS, }, - 2, D_80B6F990, // sTrisElementsInit, + ARRAY_COUNT(sTrisElementsInit), D_80B6F990, // sTrisElementsInit, }; // static InitChainEntry sInitChain[] = { diff --git a/src/overlays/actors/ovl_Bg_Kin2_Picture/z_bg_kin2_picture.h b/src/overlays/actors/ovl_Bg_Kin2_Picture/z_bg_kin2_picture.h index eb5432f78..19651ef57 100644 --- a/src/overlays/actors/ovl_Bg_Kin2_Picture/z_bg_kin2_picture.h +++ b/src/overlays/actors/ovl_Bg_Kin2_Picture/z_bg_kin2_picture.h @@ -5,13 +5,13 @@ struct BgKin2Picture; -typedef void (*BgKin2PictureActionFunc)(struct BgKin2Picture*, GlobalContext*); +typedef void (*BgKin2PictureActionFunc)(struct BgKin2Picture*, PlayState*); typedef struct BgKin2Picture { - /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0xF0]; - /* 0x0234 */ BgKin2PictureActionFunc actionFunc; - /* 0x0238 */ char unk_238[0xC]; + /* 0x000 */ Actor actor; + /* 0x144 */ char unk_144[0xF0]; + /* 0x234 */ BgKin2PictureActionFunc actionFunc; + /* 0x238 */ char unk_238[0xC]; } BgKin2Picture; // size = 0x244 extern const ActorInit Bg_Kin2_Picture_InitVars; diff --git a/src/overlays/actors/ovl_Bg_Kin2_Shelf/z_bg_kin2_shelf.c b/src/overlays/actors/ovl_Bg_Kin2_Shelf/z_bg_kin2_shelf.c index cf09d0896..8080c4444 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,17 +5,24 @@ */ #include "z_bg_kin2_shelf.h" +#include "objects/object_kin2_obj/object_kin2_obj.h" #define FLAGS 0x00000000 #define THIS ((BgKin2Shelf*)thisx) -void BgKin2Shelf_Init(Actor* thisx, GlobalContext* globalCtx); -void BgKin2Shelf_Destroy(Actor* thisx, GlobalContext* globalCtx); -void BgKin2Shelf_Update(Actor* thisx, GlobalContext* globalCtx); -void BgKin2Shelf_Draw(Actor* thisx, GlobalContext* globalCtx); +void BgKin2Shelf_Init(Actor* thisx, PlayState* play); +void BgKin2Shelf_Destroy(Actor* thisx, PlayState* play); +void BgKin2Shelf_Update(Actor* thisx, PlayState* play); +void BgKin2Shelf_Draw(Actor* thisx, PlayState* play); + +void func_80B700A8(BgKin2Shelf* this); +void func_80B700C0(BgKin2Shelf* this, PlayState* play); +void func_80B70214(BgKin2Shelf* this); +void func_80B70230(BgKin2Shelf* this, PlayState* play); +void func_80B70498(BgKin2Shelf* this); +void func_80B704B4(BgKin2Shelf* this, PlayState* play); -#if 0 const ActorInit Bg_Kin2_Shelf_InitVars = { ACTOR_BG_KIN2_SHELF, ACTORCAT_BG, @@ -28,43 +35,344 @@ 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[] = { &gOceanSpiderHouseChestOfDrawersCol, &gOceanSpiderHouseBookshelfCol }; -extern InitChainEntry D_80B7077C[]; +Gfx* D_80B70788[] = { gOceanSpiderHouseChestOfDrawersDL, gOceanSpiderHouseBookshelfDL }; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Kin2_Shelf/func_80B6FB30.s") +s32 func_80B6FB30(BgKin2Shelf* this, PlayState* play) { + 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(&play->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, PlayState* play) { + 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(&play->colCtx, &sp78, &sp6C, &sp60, &sp50, true, false, false, true, &sp4C, + &this->dyna.actor, 0.0f); +} + +s32 func_80B6FE08(BgKin2Shelf* this, PlayState* play) { + if (this->unk_164 & (0x8 | 0x2)) { + return func_80B6FB30(this, play); + } + return func_80B6FCA4(this, play); +} + +s32 func_80B6FE48(BgKin2Shelf* this, PlayState* play) { + 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, PlayState* play) { + 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, PlayState* play) { + return (this->unk_165 > 8) && func_80B6FE48(this, play) && func_80B6FEBC(this, play) && !func_80B6FE08(this, play); +} + +void BgKin2Shelf_Init(Actor* thisx, PlayState* play) { + 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(play, &this->dyna, D_80B70780[sp24]); + func_80B700A8(this); +} + +void BgKin2Shelf_Destroy(Actor* thisx, PlayState* play) { + BgKin2Shelf* this = THIS; + + DynaPoly_DeleteBgActor(play, &play->colCtx.dyna, this->dyna.bgId); +} + +void func_80B700A8(BgKin2Shelf* this) { + this->unk_165 = 0; + this->actionFunc = func_80B700C0; +} + +void func_80B700C0(BgKin2Shelf* this, PlayState* play) { + 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, play)) { + if (this->unk_164 & (0x8 | 0x2)) { + func_80B70214(this); + } else { + func_80B70498(this); + } + } else { + Player* player = GET_PLAYER(play); + + 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, PlayState* play) { + 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(play); + + 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, PlayState* play) { + 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(play); + + 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, PlayState* play) { + BgKin2Shelf* this = THIS; + + this->actionFunc(this, play); +} + +void BgKin2Shelf_Draw(Actor* thisx, PlayState* play) { + Gfx_DrawDListOpa(play, 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..ce88b25e0 100644 --- a/src/overlays/actors/ovl_Bg_Kin2_Shelf/z_bg_kin2_shelf.h +++ b/src/overlays/actors/ovl_Bg_Kin2_Shelf/z_bg_kin2_shelf.h @@ -5,13 +5,18 @@ struct BgKin2Shelf; -typedef void (*BgKin2ShelfActionFunc)(struct BgKin2Shelf*, GlobalContext*); +typedef void (*BgKin2ShelfActionFunc)(struct BgKin2Shelf*, PlayState*); + +#define BGKIN2SHELF_GET_1(thisx) ((thisx)->params & 1) typedef struct BgKin2Shelf { - /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x18]; - /* 0x015C */ BgKin2ShelfActionFunc actionFunc; - /* 0x0160 */ char unk_160[0x8]; + /* 0x000 */ DynaPolyActor dyna; + /* 0x15C */ BgKin2ShelfActionFunc actionFunc; + /* 0x160 */ f32 unk_160; + /* 0x164 */ u8 unk_164; + /* 0x165 */ s8 unk_165; + /* 0x166 */ s8 unk_166; + /* 0x167 */ s8 unk_167; } BgKin2Shelf; // size = 0x168 extern const ActorInit Bg_Kin2_Shelf_InitVars; diff --git a/src/overlays/actors/ovl_Bg_Ladder/z_bg_ladder.c b/src/overlays/actors/ovl_Bg_Ladder/z_bg_ladder.c index de9b891ac..36226212e 100644 --- a/src/overlays/actors/ovl_Bg_Ladder/z_bg_ladder.c +++ b/src/overlays/actors/ovl_Bg_Ladder/z_bg_ladder.c @@ -11,14 +11,14 @@ #define THIS ((BgLadder*)thisx) -void BgLadder_Init(Actor* thisx, GlobalContext* globalCtx); -void BgLadder_Destroy(Actor* thisx, GlobalContext* globalCtx); -void BgLadder_Update(Actor* thisx, GlobalContext* globalCtx); -void BgLadder_Draw(Actor* thisx, GlobalContext* globalCtx); -void BgLadder_ActionWait(BgLadder* this, GlobalContext* globalCtx); -void BgLadder_ActionStartCutscene(BgLadder* this, GlobalContext* globalCtx); -void BgLadder_ActionFadeIn(BgLadder* this, GlobalContext* globalCtx); -void BgLadder_ActionIdle(BgLadder* this, GlobalContext* globalCtx); +void BgLadder_Init(Actor* thisx, PlayState* play); +void BgLadder_Destroy(Actor* thisx, PlayState* play); +void BgLadder_Update(Actor* thisx, PlayState* play); +void BgLadder_Draw(Actor* thisx, PlayState* play); +void BgLadder_Wait(BgLadder* this, PlayState* play); +void BgLadder_StartCutscene(BgLadder* this, PlayState* play); +void BgLadder_FadeIn(BgLadder* this, PlayState* play); +void BgLadder_DoNothing(BgLadder* this, PlayState* play); const ActorInit Bg_Ladder_InitVars = { ACTOR_BG_LADDER, @@ -43,110 +43,109 @@ static Gfx* sLadderDLists[] = { object_ladder_DL_000730, // 24 Rung }; -void BgLadder_Init(Actor* thisx, GlobalContext* globalCtx) { +void BgLadder_Init(Actor* thisx, PlayState* play) { BgLadder* this = THIS; BgLadderSize size; Actor_ProcessInitChain(&this->dyna.actor, sInitChain); - // Has to be `thisx` instead of `&this->actor` to match - this->switchFlag = GET_BGLADDER_SWITCHFLAG(thisx); - thisx->params = GET_BGLADDER_SIZE(thisx); + this->switchFlag = BGLADDER_GET_SWITCHFLAG(thisx); + thisx->params = BGLADDER_GET_SIZE(thisx); DynaPolyActor_Init(&this->dyna, 0); size = thisx->params; if (size == LADDER_SIZE_12RUNG) { - DynaPolyActor_LoadMesh(globalCtx, &this->dyna, &object_ladder_Colheader_0001D8); + DynaPolyActor_LoadMesh(play, &this->dyna, &object_ladder_Colheader_0001D8); } else if (size == LADDER_SIZE_16RUNG) { - DynaPolyActor_LoadMesh(globalCtx, &this->dyna, &object_ladder_Colheader_000408); + DynaPolyActor_LoadMesh(play, &this->dyna, &object_ladder_Colheader_000408); } else if (size == LADDER_SIZE_20RUNG) { - DynaPolyActor_LoadMesh(globalCtx, &this->dyna, &object_ladder_Colheader_000638); + DynaPolyActor_LoadMesh(play, &this->dyna, &object_ladder_Colheader_000638); } else if (size == LADDER_SIZE_24RUNG) { - DynaPolyActor_LoadMesh(globalCtx, &this->dyna, &object_ladder_Colheader_000868); + DynaPolyActor_LoadMesh(play, &this->dyna, &object_ladder_Colheader_000868); } else { Actor_MarkForDeath(&this->dyna.actor); return; } - if (Flags_GetSwitch(globalCtx, this->switchFlag)) { + if (Flags_GetSwitch(play, this->switchFlag)) { // If the flag is set, then the ladder draws immediately this->alpha = 255; this->dyna.actor.flags &= ~ACTOR_FLAG_10; // always update = off - this->action = BgLadder_ActionIdle; + this->action = BgLadder_DoNothing; } else { // Otherwise, the ladder doesn't draw; wait for the flag to be set this->alpha = 5; - func_800C62BC(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); + func_800C62BC(play, &play->colCtx.dyna, this->dyna.bgId); this->dyna.actor.draw = NULL; - this->action = BgLadder_ActionWait; + this->action = BgLadder_Wait; } } -void BgLadder_Destroy(Actor* thisx, GlobalContext* globalCtx) { +void BgLadder_Destroy(Actor* thisx, PlayState* play) { BgLadder* this = THIS; - DynaPoly_DeleteBgActor(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); + DynaPoly_DeleteBgActor(play, &play->colCtx.dyna, this->dyna.bgId); } -void BgLadder_ActionWait(BgLadder* this, GlobalContext* globalCtx) { +void BgLadder_Wait(BgLadder* this, PlayState* play) { // Wait for the flag to be set, then trigger the cutscene - if (Flags_GetSwitch(globalCtx, this->switchFlag)) { + if (Flags_GetSwitch(play, this->switchFlag)) { ActorCutscene_SetIntentToPlay(this->dyna.actor.cutscene); - this->action = BgLadder_ActionStartCutscene; + this->action = BgLadder_StartCutscene; } } -void BgLadder_ActionStartCutscene(BgLadder* this, GlobalContext* globalCtx) { +void BgLadder_StartCutscene(BgLadder* this, PlayState* play) { // Trigger the cutscene, then make the ladder fade in if (ActorCutscene_GetCanPlayNext(this->dyna.actor.cutscene)) { ActorCutscene_StartAndSetUnkLinkFields(this->dyna.actor.cutscene, &this->dyna.actor); this->dyna.actor.draw = BgLadder_Draw; Actor_PlaySfxAtPos(&this->dyna.actor, NA_SE_EV_SECRET_LADDER_APPEAR); - this->action = BgLadder_ActionFadeIn; + this->action = BgLadder_FadeIn; } else { ActorCutscene_SetIntentToPlay(this->dyna.actor.cutscene); } } -void BgLadder_ActionFadeIn(BgLadder* this, GlobalContext* globalCtx) { +void BgLadder_FadeIn(BgLadder* this, PlayState* play) { // Fade in the ladder, then stop the cutscene & go idle this->alpha += 5; if (this->alpha >= 255) { this->alpha = 255; ActorCutscene_Stop(this->dyna.actor.cutscene); - func_800C6314(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); + func_800C6314(play, &play->colCtx.dyna, this->dyna.bgId); this->dyna.actor.flags &= ~ACTOR_FLAG_10; // always update = off - this->action = BgLadder_ActionIdle; + this->action = BgLadder_DoNothing; } } -void BgLadder_ActionIdle(BgLadder* this, GlobalContext* globalCtx) { +void BgLadder_DoNothing(BgLadder* this, PlayState* play) { } -void BgLadder_Update(Actor* thisx, GlobalContext* globalCtx) { +void BgLadder_Update(Actor* thisx, PlayState* play) { BgLadder* this = THIS; - this->action(this, globalCtx); + this->action(this, play); } -void BgLadder_Draw(Actor* thisx, GlobalContext* globalCtx) { +void BgLadder_Draw(Actor* thisx, PlayState* play) { BgLadder* this = THIS; s32 pad; Gfx* gfx; - OPEN_DISPS(globalCtx->state.gfxCtx); + OPEN_DISPS(play->state.gfxCtx); if (this->alpha == 255) { - Scene_SetRenderModeXlu(globalCtx, 0, 0x01); + Scene_SetRenderModeXlu(play, 0, 0x01); gfx = POLY_OPA_DISP; } else { - Scene_SetRenderModeXlu(globalCtx, 1, 0x02); + Scene_SetRenderModeXlu(play, 1, 0x02); gfx = POLY_XLU_DISP; } gSPDisplayList(&gfx[0], &sSetupDL[6 * 0x19]); gDPSetEnvColor(&gfx[1], 255, 255, 255, this->alpha); - gSPMatrix(&gfx[2], Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_LOAD); + gSPMatrix(&gfx[2], Matrix_NewMtx(play->state.gfxCtx), G_MTX_LOAD); gSPDisplayList(&gfx[3], sLadderDLists[this->dyna.actor.params]); if (this->alpha == 255) { @@ -155,5 +154,5 @@ void BgLadder_Draw(Actor* thisx, GlobalContext* globalCtx) { POLY_XLU_DISP = gfx + 4; } - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->state.gfxCtx); } diff --git a/src/overlays/actors/ovl_Bg_Ladder/z_bg_ladder.h b/src/overlays/actors/ovl_Bg_Ladder/z_bg_ladder.h index fb4d8b4d2..c53a80352 100644 --- a/src/overlays/actors/ovl_Bg_Ladder/z_bg_ladder.h +++ b/src/overlays/actors/ovl_Bg_Ladder/z_bg_ladder.h @@ -3,12 +3,12 @@ #include "global.h" -#define GET_BGLADDER_SIZE(actor) ((actor)->params & 0xFF) -#define GET_BGLADDER_SWITCHFLAG(actor) (((actor)->params >> 8) & 0xFF) +#define BGLADDER_GET_SIZE(thisx) ((thisx)->params & 0xFF) +#define BGLADDER_GET_SWITCHFLAG(thisx) (((thisx)->params >> 8) & 0xFF) struct BgLadder; -typedef void (*BgLadderActionFn)(struct BgLadder*, GlobalContext*); +typedef void (*BgLadderActionFn)(struct BgLadder*, PlayState*); typedef struct BgLadder { /* 0x000 */ DynaPolyActor dyna; @@ -18,10 +18,10 @@ typedef struct BgLadder { } BgLadder; // size = 0x164 typedef enum { - LADDER_SIZE_12RUNG, - LADDER_SIZE_16RUNG, - LADDER_SIZE_20RUNG, - LADDER_SIZE_24RUNG, + /* 0 */ LADDER_SIZE_12RUNG, + /* 1 */ LADDER_SIZE_16RUNG, + /* 2 */ LADDER_SIZE_20RUNG, + /* 3 */ LADDER_SIZE_24RUNG, } BgLadderSize; extern const ActorInit Bg_Ladder_InitVars; diff --git a/src/overlays/actors/ovl_Bg_Last_Bwall/z_bg_last_bwall.c b/src/overlays/actors/ovl_Bg_Last_Bwall/z_bg_last_bwall.c index 0e3a88029..2b4c24381 100644 --- a/src/overlays/actors/ovl_Bg_Last_Bwall/z_bg_last_bwall.c +++ b/src/overlays/actors/ovl_Bg_Last_Bwall/z_bg_last_bwall.c @@ -10,12 +10,33 @@ #define THIS ((BgLastBwall*)thisx) -void BgLastBwall_Init(Actor* thisx, GlobalContext* globalCtx); -void BgLastBwall_Destroy(Actor* thisx, GlobalContext* globalCtx); -void BgLastBwall_Update(Actor* thisx, GlobalContext* globalCtx); -void BgLastBwall_Draw(Actor* thisx, GlobalContext* globalCtx); +typedef struct { + /* 0x0 */ Vec3s* posOffsets; + /* 0x4 */ s16* indices; + /* 0x8 */ s32 count; +} BgLastBwallInitColliderStruct; // size = 0xC + +typedef struct { + /* 0x0 */ Gfx* dList; + /* 0x4 */ void* pad4; + /* 0x8 */ CollisionHeader* colHeader; +} BgLastBwallModelInfo; // size = 0xC + +void BgLastBwall_Init(Actor* thisx, PlayState* play); +void BgLastBwall_Destroy(Actor* thisx, PlayState* play); +void BgLastBwall_Update(Actor* thisx, PlayState* play); +void BgLastBwall_Draw(Actor* thisx, PlayState* play); + +void BgLastBwall_InitCollider(ColliderTrisInit* init, Vec3f* pos, Vec3s* rot, ColliderTris* collider, + BgLastBwallInitColliderStruct* arg4); +void func_80C187E4(BgLastBwall* this); +void func_80C184EC(BgLastBwall* this, PlayState* play); +void func_80C187F8(BgLastBwall* this, PlayState* play); +void func_80C1886C(BgLastBwall* this, PlayState* play); +void func_80C18884(BgLastBwall* this, PlayState* play); +void func_80C188C4(BgLastBwall* this, PlayState* play); +void BgLastBwall_DoNothing(BgLastBwall* this, PlayState* play); -#if 0 const ActorInit Bg_Last_Bwall_InitVars = { ACTOR_BG_LAST_BWALL, ACTORCAT_BG, @@ -28,57 +49,217 @@ const ActorInit Bg_Last_Bwall_InitVars = { (ActorFunc)BgLastBwall_Draw, }; -// static ColliderTrisElementInit sTrisElementsInit[2] = { -static ColliderTrisElementInit D_80C189C0[2] = { +static ColliderTrisElementInit sTrisElementsInit[] = { { - { 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_80C18A38 = { - { COLTYPE_NONE, AT_NONE, AC_ON | AC_TYPE_PLAYER, OC1_NONE, OC2_NONE, COLSHAPE_TRIS, }, - 2, D_80C189C0, // sTrisElementsInit, +static ColliderTrisInit sTrisInit = { + { + COLTYPE_NONE, + AT_NONE, + AC_ON | AC_TYPE_PLAYER, + OC1_NONE, + OC2_NONE, + COLSHAPE_TRIS, + }, + ARRAY_COUNT(sTrisElementsInit), + sTrisElementsInit, }; -// static InitChainEntry sInitChain[] = { +static BgLastBwallModelInfo D_80C18A48[] = { + { object_last_obj_DL_0001A8, NULL, &object_last_obj_Colheader_000288 }, + { object_last_obj_DL_001318, NULL, &object_last_obj_Colheader_001450 }, +}; + +static Vec3s D_80C18A60[] = { + { 280, 280, -40 }, + { 280, 280, 120 }, + { 280, 400, 120 }, + { 280, 400, -40 }, +}; + +static s16 D_80C18A78[] = { 0, 1, 2, 0, 2, 3 }; + +static BgLastBwallInitColliderStruct D_80C18A84 = { D_80C18A60, D_80C18A78, 2 }; + +static Vec3s D_80C18A90[] = { + { -80, 400, -80 }, + { -80, 400, 80 }, + { 80, 400, 80 }, + { 80, 400, -80 }, +}; + +static s16 D_80C18AA8[] = { 0, 3, 2, 0, 2, 1 }; + +static BgLastBwallInitColliderStruct D_80C18AB4 = { D_80C18A90, D_80C18AA8, 2 }; + +static BgLastBwallInitColliderStruct* D_80C18AC0[] = { &D_80C18A84, &D_80C18AB4 }; + static InitChainEntry D_80C18AC8[] = { ICHAIN_VEC3F_DIV1000(scale, 100, ICHAIN_STOP), }; -#endif +void BgLastBwall_InitCollider(ColliderTrisInit* init, Vec3f* pos, Vec3s* rot, ColliderTris* collider, + BgLastBwallInitColliderStruct* arg4) { + s32 i; + s32 j; + Vec3f sp6C[3]; + Vec3f sp60; + Vec3f sp54; -extern ColliderTrisElementInit D_80C189C0[2]; -extern ColliderTrisInit D_80C18A38; -extern InitChainEntry D_80C18AC8[]; + Matrix_RotateYS(rot->y, MTXMODE_NEW); + Matrix_RotateXS(rot->x, MTXMODE_APPLY); + Matrix_RotateZS(rot->z, MTXMODE_APPLY); + for (i = 0; i < init->count; i++) { + for (j = 0; j < 3; j++) { + Math_Vec3s_ToVec3f(&sp60, &arg4->posOffsets[arg4->indices[j]]); + Matrix_MultVec3f(&sp60, &sp54); + Math_Vec3f_Sum(&sp54, pos, &sp6C[j]); + } -extern UNK_TYPE D_06000098; + arg4->indices += 3; + Collider_SetTrisVertices(collider, i, &sp6C[0], &sp6C[1], &sp6C[2]); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Last_Bwall/func_80C18240.s") +void BgLastBwall_Init(Actor* thisx, PlayState* play) { + s32 pad; + BgLastBwall* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Last_Bwall/BgLastBwall_Init.s") + Actor_ProcessInitChain(&this->dyna.actor, D_80C18AC8); + this->type = BGLASTBWALL_GET_TYPE(&this->dyna.actor); + DynaPolyActor_Init(&this->dyna, 1); + DynaPolyActor_LoadMesh(play, &this->dyna, D_80C18A48[this->type].colHeader); + Collider_InitTris(play, &this->colliderTris); + if (Flags_GetSwitch(play, BGLASTBWALL_GET_SWITCHFLAGS(&this->dyna.actor))) { + Actor_MarkForDeath(&this->dyna.actor); + } else if (!Collider_SetTris(play, &this->colliderTris, &this->dyna.actor, &sTrisInit, this->colliderTrisElement)) { + Actor_MarkForDeath(&this->dyna.actor); + } else { + BgLastBwall_InitCollider(&sTrisInit, &this->dyna.actor.world.pos, &this->dyna.actor.shape.rot, + &this->colliderTris, D_80C18AC0[this->type]); + SubS_FillCutscenesList(&this->dyna.actor, this->cutscenes, ARRAY_COUNT(this->cutscenes)); + func_80C187E4(this); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Last_Bwall/BgLastBwall_Destroy.s") +void BgLastBwall_Destroy(Actor* thisx, PlayState* play) { + BgLastBwall* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Last_Bwall/func_80C184EC.s") + DynaPoly_DeleteBgActor(play, &play->colCtx.dyna, this->dyna.bgId); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Last_Bwall/func_80C187E4.s") +void func_80C184EC(BgLastBwall* this, PlayState* play) { + f32 randVar; + Vec3f spD0; + Vec3f effectPosAndAccel; + s32 var_v0; + Vec3f effectVelocity; + s32 i; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Last_Bwall/func_80C187F8.s") + Matrix_RotateYS(this->dyna.actor.shape.rot.y, MTXMODE_NEW); + Matrix_RotateXS(this->dyna.actor.shape.rot.y, MTXMODE_APPLY); + Matrix_RotateZS(this->dyna.actor.shape.rot.y, MTXMODE_APPLY); + for (i = 0; i < 30; i++) { + switch (this->type) { + case BGLASTBWALL_TYPE_0: + spD0.x = 280.0f; + spD0.y = Rand_Centered() * 160.0f + 320.0f; + spD0.z = Rand_Centered() * 160.0f; + Matrix_MultVec3f(&spD0, &effectPosAndAccel); + Math_Vec3f_Sum(&this->dyna.actor.world.pos, &effectPosAndAccel, &effectPosAndAccel); + break; + case BGLASTBWALL_TYPE_1: + spD0.x = Rand_Centered() * 160.0f; + spD0.y = 400.0f; + spD0.z = Rand_Centered() * 160.0f; + Matrix_MultVec3f(&spD0, &effectPosAndAccel); + Math_Vec3f_Sum(&this->dyna.actor.world.pos, &effectPosAndAccel, &effectPosAndAccel); + break; + } + func_800BBFB0(play, &effectPosAndAccel, 50.0f, 2, Rand_ZeroOne() * 120.0f + 20.0f, + Rand_ZeroOne() * 240.0f + 20.0f, 0); + effectVelocity.x = Rand_ZeroOne() * 2.5f; + effectVelocity.y = Rand_ZeroOne() * 2.5f + 1.0f; + effectVelocity.z = Rand_ZeroOne() * 2.5f; + randVar = Rand_ZeroOne(); + if (randVar < 0.2f) { + var_v0 = 0x60; + } else if (randVar < 0.6f) { + var_v0 = 0x40; + } else { + var_v0 = 0x20; + } + EffectSsKakera_Spawn(play, &effectPosAndAccel, &effectVelocity, &effectPosAndAccel, -260, var_v0, 20, 0, 0, 10, + 0, 0, 50, -1, OBJECT_LAST_OBJ, object_last_obj_DL_000098); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Last_Bwall/func_80C1886C.s") +void func_80C187E4(BgLastBwall* this) { + this->actionFunc = func_80C187F8; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Last_Bwall/func_80C18884.s") +void func_80C187F8(BgLastBwall* this, PlayState* play) { + if (this->colliderTris.base.acFlags & 2) { + this->colliderTris.base.acFlags &= ~2; + Flags_SetSwitch(play, BGLASTBWALL_GET_SWITCHFLAGS(&this->dyna.actor)); + func_80C1886C(this, play); + } else { + CollisionCheck_SetAC(play, &play->colChkCtx, &this->colliderTris.base); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Last_Bwall/func_80C188C4.s") +void func_80C1886C(BgLastBwall* this, PlayState* play) { + this->actionFunc = func_80C18884; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Last_Bwall/func_80C18928.s") +void func_80C18884(BgLastBwall* this, PlayState* play) { + if (SubS_StartActorCutscene(&this->dyna.actor, this->cutscenes[0], -1, SUBS_CUTSCENE_SET_UNK_LINK_FIELDS)) { + func_80C188C4(this, play); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Last_Bwall/BgLastBwall_Update.s") +void func_80C188C4(BgLastBwall* this, PlayState* play) { + func_800C62BC(play, &play->colCtx.dyna, this->dyna.bgId); + this->dyna.actor.draw = NULL; + func_80C184EC(this, play); + Actor_PlaySfxAtPos(&this->dyna.actor, NA_SE_EV_WALL_BROKEN); + this->actionFunc = BgLastBwall_DoNothing; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Last_Bwall/BgLastBwall_Draw.s") +void BgLastBwall_DoNothing(BgLastBwall* this, PlayState* play) { +} + +void BgLastBwall_Update(Actor* thisx, PlayState* play) { + BgLastBwall* this = THIS; + + this->actionFunc(this, play); +} + +void BgLastBwall_Draw(Actor* thisx, PlayState* play2) { + PlayState* play = play2; + BgLastBwall* this = THIS; + + Gfx_DrawDListOpa(play, D_80C18A48[this->type].dList); +} diff --git a/src/overlays/actors/ovl_Bg_Last_Bwall/z_bg_last_bwall.h b/src/overlays/actors/ovl_Bg_Last_Bwall/z_bg_last_bwall.h index fe529b13d..d24b8ba42 100644 --- a/src/overlays/actors/ovl_Bg_Last_Bwall/z_bg_last_bwall.h +++ b/src/overlays/actors/ovl_Bg_Last_Bwall/z_bg_last_bwall.h @@ -2,16 +2,27 @@ #define Z_BG_LAST_BWALL_H #include "global.h" +#include "objects/object_last_obj/object_last_obj.h" struct BgLastBwall; -typedef void (*BgLastBwallActionFunc)(struct BgLastBwall*, GlobalContext*); +typedef void (*BgLastBwallActionFunc)(struct BgLastBwall*, PlayState*); + +#define BGLASTBWALL_GET_SWITCHFLAGS(thisx) ((thisx)->params & 0x7F) +#define BGLASTBWALL_GET_TYPE(thisx) (((thisx)->params >> 0xC) & 0xF) + +typedef enum { + BGLASTBWALL_TYPE_0 = 0, + BGLASTBWALL_TYPE_1 = 1, +} BgLastBwallType; typedef struct BgLastBwall { - /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x18]; - /* 0x015C */ BgLastBwallActionFunc actionFunc; - /* 0x0160 */ char unk_160[0xDC]; + /* 0x000 */ DynaPolyActor dyna; + /* 0x15C */ BgLastBwallActionFunc actionFunc; + /* 0x160 */ ColliderTris colliderTris; + /* 0x180 */ ColliderTrisElement colliderTrisElement[2]; + /* 0x238 */ u8 type; + /* 0x23A */ s16 cutscenes[1]; } BgLastBwall; // size = 0x23C extern const ActorInit Bg_Last_Bwall_InitVars; diff --git a/src/overlays/actors/ovl_Bg_Lbfshot/z_bg_lbfshot.c b/src/overlays/actors/ovl_Bg_Lbfshot/z_bg_lbfshot.c index b0ad9d32e..35d61af5e 100644 --- a/src/overlays/actors/ovl_Bg_Lbfshot/z_bg_lbfshot.c +++ b/src/overlays/actors/ovl_Bg_Lbfshot/z_bg_lbfshot.c @@ -11,9 +11,9 @@ #define THIS ((BgLbfshot*)thisx) -void BgLbfshot_Init(Actor* thisx, GlobalContext* globalCtx); -void BgLbfshot_Destroy(Actor* thisx, GlobalContext* globalCtx); -void BgLbfshot_Draw(Actor* thisx, GlobalContext* globalCtx); +void BgLbfshot_Init(Actor* thisx, PlayState* play); +void BgLbfshot_Destroy(Actor* thisx, PlayState* play); +void BgLbfshot_Draw(Actor* thisx, PlayState* play); const ActorInit Bg_Lbfshot_InitVars = { ACTOR_BG_LBFSHOT, @@ -31,19 +31,19 @@ static InitChainEntry sInitChain[] = { ICHAIN_VEC3F_DIV1000(scale, 100, ICHAIN_STOP), }; -void BgLbfshot_Init(Actor* thisx, GlobalContext* globalCtx) { +void BgLbfshot_Init(Actor* thisx, PlayState* play) { BgLbfshot* this = THIS; Actor_ProcessInitChain(&this->dyna.actor, sInitChain); this->dyna.actor.uncullZoneForward = 4000.0f; DynaPolyActor_Init(&this->dyna, 1); - DynaPolyActor_LoadMesh(globalCtx, &this->dyna, &object_lbfshot_Colheader_0014D8); + DynaPolyActor_LoadMesh(play, &this->dyna, &object_lbfshot_Colheader_0014D8); } -void BgLbfshot_Destroy(Actor* thisx, GlobalContext* globalCtx) { +void BgLbfshot_Destroy(Actor* thisx, PlayState* play) { BgLbfshot* this = THIS; - DynaPoly_DeleteBgActor(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); + DynaPoly_DeleteBgActor(play, &play->colCtx.dyna, this->dyna.bgId); } -void BgLbfshot_Draw(Actor* thisx, GlobalContext* globalCtx) { - Gfx_DrawDListOpa(globalCtx, object_lbfshot_DL_000228); +void BgLbfshot_Draw(Actor* thisx, PlayState* play) { + Gfx_DrawDListOpa(play, object_lbfshot_DL_000228); } 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 71f1d2b6a..6ac4ac866 100644 --- a/src/overlays/actors/ovl_Bg_Lotus/z_bg_lotus.c +++ b/src/overlays/actors/ovl_Bg_Lotus/z_bg_lotus.c @@ -11,14 +11,14 @@ #define THIS ((BgLotus*)thisx) -void BgLotus_Init(Actor* thisx, GlobalContext* globalCtx); -void BgLotus_Destroy(Actor* thisx, GlobalContext* globalCtx); -void BgLotus_Update(Actor* thisx, GlobalContext* globalCtx); -void BgLotus_Draw(Actor* thisx, GlobalContext* globalCtx); +void BgLotus_Init(Actor* thisx, PlayState* play); +void BgLotus_Destroy(Actor* thisx, PlayState* play); +void BgLotus_Update(Actor* thisx, PlayState* play); +void BgLotus_Draw(Actor* thisx, PlayState* play); -void BgLotus_Wait(BgLotus* this, GlobalContext* globalCtx); -void BgLotus_Sink(BgLotus* this, GlobalContext* globalCtx); -void BgLotus_WaitToAppear(BgLotus* this, GlobalContext* globalCtx); +void BgLotus_Wait(BgLotus* this, PlayState* play); +void BgLotus_Sink(BgLotus* this, PlayState* play); +void BgLotus_WaitToAppear(BgLotus* this, PlayState* play); const ActorInit Bg_Lotus_InitVars = { ACTOR_BG_LOTUS, @@ -36,25 +36,25 @@ static InitChainEntry sInitChain[] = { ICHAIN_VEC3F_DIV1000(scale, 100, ICHAIN_STOP), }; -void BgLotus_Init(Actor* thisx, GlobalContext* globalCtx) { +void BgLotus_Init(Actor* thisx, PlayState* play) { BgLotus* this = THIS; s32 pad; s32 bgId; Actor_ProcessInitChain(&this->dyna.actor, sInitChain); DynaPolyActor_Init(&this->dyna, 1); - DynaPolyActor_LoadMesh(globalCtx, &this->dyna, &object_lotus_Colheader_000A20); - this->dyna.actor.floorHeight = BgCheck_EntityRaycastFloor5(&globalCtx->colCtx, &thisx->floorPoly, &bgId, + DynaPolyActor_LoadMesh(play, &this->dyna, &object_lotus_Colheader_000A20); + this->dyna.actor.floorHeight = BgCheck_EntityRaycastFloor5(&play->colCtx, &thisx->floorPoly, &bgId, &this->dyna.actor, &this->dyna.actor.world.pos); this->timer2 = 96; - this->dyna.actor.world.rot.y = Rand_Next() >> 0x10; + this->dyna.actor.world.rot.y = (s32)Rand_Next() >> 0x10; this->actionFunc = BgLotus_Wait; } -void BgLotus_Destroy(Actor* thisx, GlobalContext* globalCtx) { +void BgLotus_Destroy(Actor* thisx, PlayState* play) { BgLotus* this = THIS; - DynaPoly_DeleteBgActor(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); + DynaPoly_DeleteBgActor(play, &play->colCtx.dyna, this->dyna.bgId); } void BgLotus_SetScaleXZ(BgLotus* this) { @@ -67,7 +67,7 @@ void BgLotus_SetScaleXZ(BgLotus* this) { } } -void BgLotus_Wait(BgLotus* this, GlobalContext* globalCtx) { +void BgLotus_Wait(BgLotus* this, PlayState* play) { f32 moveDist; // distance for the xz position of the lilypad to move this->timer2--; @@ -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); } } @@ -93,8 +93,8 @@ void BgLotus_Wait(BgLotus* this, GlobalContext* globalCtx) { if (DynaPolyActor_IsInRidingMovingState(&this->dyna)) { if (this->hasSpawnedRipples == 0) { - EffectSsGRipple_Spawn(globalCtx, &this->dyna.actor.world.pos, 1000, 1400, 0); - EffectSsGRipple_Spawn(globalCtx, &this->dyna.actor.world.pos, 1000, 1400, 8); + EffectSsGRipple_Spawn(play, &this->dyna.actor.world.pos, 1000, 1400, 0); + EffectSsGRipple_Spawn(play, &this->dyna.actor.world.pos, 1000, 1400, 8); this->timer = 40; } if (gSaveContext.save.playerForm != PLAYER_FORM_DEKU) { @@ -117,7 +117,7 @@ void BgLotus_Wait(BgLotus* this, GlobalContext* globalCtx) { BgLotus_SetScaleXZ(this); } -void BgLotus_Sink(BgLotus* this, GlobalContext* globalCtx) { +void BgLotus_Sink(BgLotus* this, PlayState* play) { if (this->height < this->dyna.actor.world.pos.y) { this->dyna.actor.world.pos.y = this->height; } @@ -136,7 +136,7 @@ void BgLotus_Sink(BgLotus* this, GlobalContext* globalCtx) { if (Math_StepToF(&this->dyna.actor.scale.x, 0, 0.0050000003539f)) { this->dyna.actor.draw = NULL; this->timer = 100; - func_800C62BC(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); + func_800C62BC(play, &play->colCtx.dyna, this->dyna.bgId); this->actionFunc = BgLotus_WaitToAppear; } @@ -144,12 +144,12 @@ void BgLotus_Sink(BgLotus* this, GlobalContext* globalCtx) { } } -void BgLotus_WaitToAppear(BgLotus* this, GlobalContext* globalCtx) { +void BgLotus_WaitToAppear(BgLotus* this, PlayState* play) { if (this->timer > 0) { this->timer--; } else if ((this->dyna.actor.xzDistToPlayer > 100.0f) && (this->dyna.actor.projectedPos.z < 0.0f)) { this->dyna.actor.draw = BgLotus_Draw; - func_800C6314(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); + func_800C6314(play, &play->colCtx.dyna, this->dyna.bgId); Actor_SetScale(&this->dyna.actor, 0.1f); this->dyna.actor.world.pos.y = CLAMP_MIN(this->height, this->dyna.actor.floorHeight); this->dyna.actor.flags &= ~ACTOR_FLAG_10; @@ -160,16 +160,16 @@ void BgLotus_WaitToAppear(BgLotus* this, GlobalContext* globalCtx) { } } -void BgLotus_Update(Actor* thisx, GlobalContext* globalCtx) { +void BgLotus_Update(Actor* thisx, PlayState* play) { BgLotus* this = THIS; s32 pad; WaterBox* waterBox; - WaterBox_GetSurface1_2(globalCtx, &globalCtx->colCtx, this->dyna.actor.world.pos.x, this->dyna.actor.world.pos.z, + WaterBox_GetSurface1_2(play, &play->colCtx, this->dyna.actor.world.pos.x, this->dyna.actor.world.pos.z, &this->height, &waterBox); - this->actionFunc(this, globalCtx); + this->actionFunc(this, play); } -void BgLotus_Draw(Actor* thisx, GlobalContext* globalCtx) { - Gfx_DrawDListOpa(globalCtx, object_lotus_DL_000040); +void BgLotus_Draw(Actor* thisx, PlayState* play) { + Gfx_DrawDListOpa(play, object_lotus_DL_000040); } diff --git a/src/overlays/actors/ovl_Bg_Lotus/z_bg_lotus.h b/src/overlays/actors/ovl_Bg_Lotus/z_bg_lotus.h index 505e6720c..a4d8f2ebb 100644 --- a/src/overlays/actors/ovl_Bg_Lotus/z_bg_lotus.h +++ b/src/overlays/actors/ovl_Bg_Lotus/z_bg_lotus.h @@ -5,7 +5,7 @@ struct BgLotus; -typedef void (*BgLotusActionFunc)(struct BgLotus*, GlobalContext*); +typedef void (*BgLotusActionFunc)(struct BgLotus*, PlayState*); typedef struct BgLotus { /* 0x000 */ DynaPolyActor dyna; 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 e25aeaf67..8ac6c61c3 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 @@ -11,8 +11,8 @@ #define THIS ((BgMarketStep*)thisx) -void BgMarketStep_Init(Actor* thisx, GlobalContext* globalCtx); -void BgMarketStep_Draw(Actor* thisx, GlobalContext* globalCtx); +void BgMarketStep_Init(Actor* thisx, PlayState* play); +void BgMarketStep_Draw(Actor* thisx, PlayState* play); const ActorInit Bg_Market_Step_InitVars = { ACTOR_BG_MARKET_STEP, ACTORCAT_BG, FLAGS, @@ -30,14 +30,14 @@ static InitChainEntry sInitChain[] = { Gfx* D_80AF0120[] = { object_market_obj_DL_01F050, object_market_obj_DL_018DA0 }; Gfx* D_80AF0128[] = { object_market_obj_DL_01EF10, object_market_obj_DL_018C60 }; -void BgMarketStep_Init(Actor* thisx, GlobalContext* globalCtx) { +void BgMarketStep_Init(Actor* thisx, PlayState* play) { BgMarketStep* this = THIS; Actor_ProcessInitChain(&this->actor, sInitChain); } -void BgMarketStep_Draw(Actor* thisx, GlobalContext* globalCtx) { +void BgMarketStep_Draw(Actor* thisx, PlayState* play) { s32 index = thisx->params & 1; - Gfx_DrawDListOpa(globalCtx, D_80AF0120[index]); - Gfx_DrawDListOpa(globalCtx, D_80AF0128[index]); + Gfx_DrawDListOpa(play, D_80AF0120[index]); + Gfx_DrawDListOpa(play, D_80AF0128[index]); } diff --git a/src/overlays/actors/ovl_Bg_Mbar_Chair/z_bg_mbar_chair.c b/src/overlays/actors/ovl_Bg_Mbar_Chair/z_bg_mbar_chair.c index e5e300757..f81e53611 100644 --- a/src/overlays/actors/ovl_Bg_Mbar_Chair/z_bg_mbar_chair.c +++ b/src/overlays/actors/ovl_Bg_Mbar_Chair/z_bg_mbar_chair.c @@ -11,10 +11,10 @@ #define THIS ((BgMbarChair*)thisx) -void BgMbarChair_Init(Actor* thisx, GlobalContext* globalCtx); -void BgMbarChair_Destroy(Actor* thisx, GlobalContext* globalCtx); -void BgMbarChair_Update(Actor* thisx, GlobalContext* globalCtx); -void BgMbarChair_Draw(Actor* thisx, GlobalContext* globalCtx); +void BgMbarChair_Init(Actor* thisx, PlayState* play); +void BgMbarChair_Destroy(Actor* thisx, PlayState* play); +void BgMbarChair_Update(Actor* thisx, PlayState* play); +void BgMbarChair_Draw(Actor* thisx, PlayState* play); const ActorInit Bg_Mbar_Chair_InitVars = { ACTOR_BG_MBAR_CHAIR, @@ -35,23 +35,23 @@ static InitChainEntry sInitChain[] = { ICHAIN_VEC3F_DIV1000(scale, 100, ICHAIN_STOP), }; -void BgMbarChair_Init(Actor* thisx, GlobalContext* globalCtx) { +void BgMbarChair_Init(Actor* thisx, PlayState* play) { BgMbarChair* this = THIS; Actor_ProcessInitChain(&this->dyna.actor, sInitChain); DynaPolyActor_Init(&this->dyna, 0); - DynaPolyActor_LoadMesh(globalCtx, &this->dyna, &object_mbar_obj_Colheader_0019B4); + DynaPolyActor_LoadMesh(play, &this->dyna, &object_mbar_obj_Colheader_0019B4); } -void BgMbarChair_Destroy(Actor* thisx, GlobalContext* globalCtx) { +void BgMbarChair_Destroy(Actor* thisx, PlayState* play) { BgMbarChair* this = THIS; - DynaPoly_DeleteBgActor(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); + DynaPoly_DeleteBgActor(play, &play->colCtx.dyna, this->dyna.bgId); } -void BgMbarChair_Update(Actor* thisx, GlobalContext* globalCtx) { +void BgMbarChair_Update(Actor* thisx, PlayState* play) { } -void BgMbarChair_Draw(Actor* thisx, GlobalContext* globalCtx) { - Gfx_DrawDListOpa(globalCtx, object_mbar_obj_DL_000288); +void BgMbarChair_Draw(Actor* thisx, PlayState* play) { + Gfx_DrawDListOpa(play, object_mbar_obj_DL_000288); } 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 186376d9b..4c0c109ea 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 @@ -12,23 +12,23 @@ #define THIS ((BgNumaHana*)thisx) -void BgNumaHana_Init(Actor* thisx, GlobalContext* globalCtx); -void BgNumaHana_Destroy(Actor* thisx, GlobalContext* globalCtx); -void BgNumaHana_Update(Actor* thisx, GlobalContext* globalCtx); -void BgNumaHana_Draw(Actor* thisx, GlobalContext* globalCtx); +void BgNumaHana_Init(Actor* thisx, PlayState* play); +void BgNumaHana_Destroy(Actor* thisx, PlayState* play); +void BgNumaHana_Update(Actor* thisx, PlayState* play); +void BgNumaHana_Draw(Actor* thisx, PlayState* play); void BgNumaHana_SetupDoNothing(BgNumaHana* this); -void BgNumaHana_DoNothing(BgNumaHana* this, GlobalContext* globalCtx); +void BgNumaHana_DoNothing(BgNumaHana* this, PlayState* play); void BgNumaHana_SetupClosedIdle(BgNumaHana* this); -void BgNumaHana_ClosedIdle(BgNumaHana* this, GlobalContext* globalCtx); +void BgNumaHana_ClosedIdle(BgNumaHana* this, PlayState* play); void BgNumaHana_SetupUnfoldInnerPetals(BgNumaHana* this); -void BgNumaHana_UnfoldInnerPetals(BgNumaHana* this, GlobalContext* globalCtx); +void BgNumaHana_UnfoldInnerPetals(BgNumaHana* this, PlayState* play); void BgNumaHana_SetupUnfoldOuterPetals(BgNumaHana* this); -void BgNumaHana_UnfoldOuterPetals(BgNumaHana* this, GlobalContext* globalCtx); +void BgNumaHana_UnfoldOuterPetals(BgNumaHana* this, PlayState* play); void BgNumaHana_SetupRaiseFlower(BgNumaHana* this); -void BgNumaHana_RaiseFlower(BgNumaHana* this, GlobalContext* globalCtx); +void BgNumaHana_RaiseFlower(BgNumaHana* this, PlayState* play); void BgNumaHana_SetupOpenedIdle(BgNumaHana* this); -void BgNumaHana_OpenedIdle(BgNumaHana* this, GlobalContext* globalCtx); +void BgNumaHana_OpenedIdle(BgNumaHana* this, PlayState* play); const ActorInit Bg_Numa_Hana_InitVars = { ACTOR_BG_NUMA_HANA, @@ -79,10 +79,10 @@ static InitChainEntry sInitChain[] = { * 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) { +s32 BgNumaHana_SpawnOpenFlowerCollisionChild(BgNumaHana* this, PlayState* play) { Actor* child; - child = Actor_SpawnAsChild(&globalCtx->actorCtx, &this->dyna.actor, globalCtx, ACTOR_BG_NUMA_HANA, + child = Actor_SpawnAsChild(&play->actorCtx, &this->dyna.actor, play, 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); @@ -136,7 +136,7 @@ void BgNumaHana_UpdateSettleRotation(s16* settleZRotation, s16* settleAngle, f32 *settleZRotation += (s16)(Math_SinS(*settleAngle) * *settleScale); } -void BgNumaHana_Init(Actor* thisx, GlobalContext* globalCtx) { +void BgNumaHana_Init(Actor* thisx, PlayState* play) { s32 pad; DynaPolyActor* child; s32 type; @@ -147,22 +147,22 @@ void BgNumaHana_Init(Actor* thisx, GlobalContext* globalCtx) { DynaPolyActor_Init(&this->dyna, 3); if (type == BG_NUMA_HANA_TYPE_OPEN_FLOWER_COLLISION) { - DynaPolyActor_LoadMesh(globalCtx, &this->dyna, &gWoodenFlowerOpenedFlowerCol); + DynaPolyActor_LoadMesh(play, &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); + DynaPolyActor_LoadMesh(play, &this->dyna, &gWoodenFlowerClosedFlowerCol); + FireObj_Init(play, &this->fire, &sFireObjInit, &this->dyna.actor); + Collider_InitCylinder(play, &this->torchCollider); + Collider_SetCylinder(play, &this->torchCollider, &this->dyna.actor, &sCylinderInit); this->dyna.actor.colChkInfo.mass = MASS_IMMOVABLE; - if (!BgNumaHana_SpawnOpenFlowerCollisionChild(this, globalCtx)) { + if (!BgNumaHana_SpawnOpenFlowerCollisionChild(this, play)) { Actor_MarkForDeath(&this->dyna.actor); return; } if (gSaveContext.save.weekEventReg[12] & 1) { - func_800C62BC(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); + func_800C62BC(play, &play->colCtx.dyna, this->dyna.bgId); this->petalZRotation = 0x2000; this->innerPetalZRotation = 0x2000; @@ -176,12 +176,12 @@ void BgNumaHana_Init(Actor* thisx, GlobalContext* globalCtx) { 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)); + Flags_SetSwitch(play, 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)); + func_800C62BC(play, &play->colCtx.dyna, child->bgId); + Flags_UnsetSwitch(play, BG_NUMA_HANA_SWITCH_FLAG(&this->dyna.actor)); BgNumaHana_SetupClosedIdle(this); } @@ -189,13 +189,13 @@ void BgNumaHana_Init(Actor* thisx, GlobalContext* globalCtx) { } } -void BgNumaHana_Destroy(Actor* thisx, GlobalContext* globalCtx) { +void BgNumaHana_Destroy(Actor* thisx, PlayState* play) { BgNumaHana* this = THIS; - DynaPoly_DeleteBgActor(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); + DynaPoly_DeleteBgActor(play, &play->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); + FireObj_Destroy(play, &this->fire); + Collider_DestroyCylinder(play, &this->torchCollider); } } @@ -203,7 +203,7 @@ void BgNumaHana_SetupDoNothing(BgNumaHana* this) { this->actionFunc = BgNumaHana_DoNothing; } -void BgNumaHana_DoNothing(BgNumaHana* this, GlobalContext* globalCtx) { +void BgNumaHana_DoNothing(BgNumaHana* this, PlayState* play) { } void BgNumaHana_SetupClosedIdle(BgNumaHana* this) { @@ -214,13 +214,13 @@ void BgNumaHana_SetupClosedIdle(BgNumaHana* this) { * 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) { +void BgNumaHana_ClosedIdle(BgNumaHana* this, PlayState* play) { if (this->fire.state != 3) { Actor_PlaySfxAtPos(&this->dyna.actor, NA_SE_EV_FLAME_IGNITION); if (ActorCutscene_GetCanPlayNext(this->dyna.actor.cutscene)) { ActorCutscene_StartAndSetUnkLinkFields(this->dyna.actor.cutscene, &this->dyna.actor); gSaveContext.save.weekEventReg[12] |= 1; - Flags_SetSwitch(globalCtx, BG_NUMA_HANA_SWITCH_FLAG(&this->dyna.actor)); + Flags_SetSwitch(play, BG_NUMA_HANA_SWITCH_FLAG(&this->dyna.actor)); BgNumaHana_SetupUnfoldInnerPetals(this); } else { ActorCutscene_SetIntentToPlay(this->dyna.actor.cutscene); @@ -237,7 +237,7 @@ void BgNumaHana_SetupUnfoldInnerPetals(BgNumaHana* this) { * 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) { +void BgNumaHana_UnfoldInnerPetals(BgNumaHana* this, PlayState* play) { Math_StepToS(&this->innerPetalZRotationalVelocity, 240, 14); if (Math_ScaledStepToS(&this->innerPetalZRotation, 0x2000, this->innerPetalZRotationalVelocity)) { if (this->transitionTimer >= 11) { @@ -269,7 +269,7 @@ void BgNumaHana_SetupUnfoldOuterPetals(BgNumaHana* this) { * 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) { +void BgNumaHana_UnfoldOuterPetals(BgNumaHana* this, PlayState* play) { Math_StepToS(&this->outerPetalZRotationalVelocity, 240, 14); if (Math_ScaledStepToS(&this->outerPetalZRotation, -0x4000, this->outerPetalZRotationalVelocity)) { if (this->transitionTimer >= 11) { @@ -299,7 +299,7 @@ void BgNumaHana_SetupRaiseFlower(BgNumaHana* this) { /** * This function slowly raises the flower to its final height and makes it start spinning. */ -void BgNumaHana_RaiseFlower(BgNumaHana* this, GlobalContext* globalCtx) { +void BgNumaHana_RaiseFlower(BgNumaHana* this, PlayState* play) { s32 pad; DynaPolyActor* child; @@ -314,8 +314,8 @@ void BgNumaHana_RaiseFlower(BgNumaHana* this, GlobalContext* globalCtx) { 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); + func_800C6314(play, &play->colCtx.dyna, child->bgId); + func_800C62BC(play, &play->colCtx.dyna, this->dyna.bgId); this->petalZRotation = 0x2000; this->innerPetalZRotation = 0x2000; @@ -342,14 +342,14 @@ void BgNumaHana_SetupOpenedIdle(BgNumaHana* this) { /** * Spins the "opened" flower around the y-axis. */ -void BgNumaHana_OpenedIdle(BgNumaHana* this, GlobalContext* globalCtx) { +void BgNumaHana_OpenedIdle(BgNumaHana* this, PlayState* play) { 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) { +void BgNumaHana_Update(Actor* thisx, PlayState* play) { s32 pad; BgNumaHana* this = THIS; s32 type = BG_NUMA_HANA_GET_TYPE(&this->dyna.actor); @@ -360,61 +360,61 @@ void BgNumaHana_Update(Actor* thisx, GlobalContext* globalCtx) { 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); + FireObj_Update(play, &this->fire, &this->dyna.actor); } - this->actionFunc(this, globalCtx); + this->actionFunc(this, play); 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); + CollisionCheck_SetOC(play, &play->colChkCtx, &this->torchCollider.base); + CollisionCheck_SetAC(play, &play->colChkCtx, &this->torchCollider.base); } } -void BgNumaHana_Draw(Actor* thisx, GlobalContext* globalCtx2) { - GlobalContext* globalCtx = globalCtx2; +void BgNumaHana_Draw(Actor* thisx, PlayState* play2) { + PlayState* play = play2; BgNumaHana* this = THIS; WoodenFlowerPetalPosRot* innerPetalPosRot; WoodenFlowerPetalPosRot* outerPetalPosRot; s32 objectIndex; s32 i; - OPEN_DISPS(globalCtx->state.gfxCtx); + OPEN_DISPS(play->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); + func_8012C28C(play->state.gfxCtx); + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_OPA_DISP++, gWoodenFlowerStalkDL); for (i = 0; i < ARRAY_COUNT(this->innerPetalPosRot); i++) { innerPetalPosRot = &this->innerPetalPosRot[i]; outerPetalPosRot = &this->outerPetalPosRot[i]; - Matrix_SetStateRotationAndTranslation(innerPetalPosRot->pos.x, innerPetalPosRot->pos.y, innerPetalPosRot->pos.z, - &innerPetalPosRot->rot); + Matrix_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); + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_OPA_DISP++, gWoodenFlowerInnerPetalDL); - Matrix_SetStateRotationAndTranslation(outerPetalPosRot->pos.x, outerPetalPosRot->pos.y, outerPetalPosRot->pos.z, - &outerPetalPosRot->rot); + Matrix_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); + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_OPA_DISP++, gWoodenFlowerOuterPetalDL); } - objectIndex = Object_GetIndex(&globalCtx->objectCtx, OBJECT_SYOKUDAI); - if ((objectIndex >= 0) && (Object_IsLoaded(&globalCtx->objectCtx, objectIndex))) { - Matrix_SetStateRotationAndTranslation(this->dyna.actor.world.pos.x, this->dyna.actor.world.pos.y - 64.5f, - this->dyna.actor.world.pos.z, &this->dyna.actor.shape.rot); + objectIndex = Object_GetIndex(&play->objectCtx, OBJECT_SYOKUDAI); + if ((objectIndex >= 0) && (Object_IsLoaded(&play->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); + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPSegment(POLY_OPA_DISP++, 0x06, play->objectCtx.status[objectIndex].segment); gSPDisplayList(POLY_OPA_DISP++, gObjectSyokudaiTypeNoSwitchDL); } - FireObj_Draw(globalCtx, &this->fire); + FireObj_Draw(play, &this->fire); - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->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 19d30a34f..e715b5c09 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 @@ -13,7 +13,7 @@ typedef enum { struct BgNumaHana; -typedef void (*BgNumaHanaActionFunc)(struct BgNumaHana*, GlobalContext*); +typedef void (*BgNumaHanaActionFunc)(struct BgNumaHana*, PlayState*); typedef struct { /* 0x00 */ Vec3f pos; 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 f1fa69810..b54e7a583 100644 --- a/src/overlays/actors/ovl_Bg_Open_Shutter/z_bg_open_shutter.c +++ b/src/overlays/actors/ovl_Bg_Open_Shutter/z_bg_open_shutter.c @@ -5,21 +5,27 @@ */ #include "z_bg_open_shutter.h" +#include "objects/object_open_obj/object_open_obj.h" +#include "z64rumble.h" #define FLAGS (ACTOR_FLAG_10) #define THIS ((BgOpenShutter*)thisx) -void BgOpenShutter_Init(Actor* thisx, GlobalContext* globalCtx); -void BgOpenShutter_Destroy(Actor* thisx, GlobalContext* globalCtx); -void BgOpenShutter_Update(Actor* thisx, GlobalContext* globalCtx); -void BgOpenShutter_Draw(Actor* thisx, GlobalContext* globalCtx); +void BgOpenShutter_Init(Actor* thisx, PlayState* play); +void BgOpenShutter_Destroy(Actor* thisx, PlayState* play); +void BgOpenShutter_Update(Actor* thisx, PlayState* play); +void BgOpenShutter_Draw(Actor* thisx, PlayState* play); -void func_80ACAD88(BgOpenShutter* this, GlobalContext* globalCtx); -void func_80ACAE5C(BgOpenShutter* this, GlobalContext* globalCtx); -void func_80ACAEF0(BgOpenShutter* this, GlobalContext* globalCtx); +void func_80ACAD88(BgOpenShutter* this, PlayState* play); +void func_80ACAE5C(BgOpenShutter* this, PlayState* play); +void func_80ACAEF0(BgOpenShutter* this, PlayState* play); + +typedef enum { + /* 0x1 */ BGOPENSHUTTER_DOOR_OPEN = 1, + /* 0x2 */ BGOPENSHUTTER_DOOR_CLOSED, +} BGOpenShutterDoorState; -#if 0 const ActorInit Bg_Open_Shutter_InitVars = { ACTOR_BG_OPEN_SHUTTER, ACTORCAT_DOOR, @@ -32,35 +38,151 @@ const ActorInit Bg_Open_Shutter_InitVars = { (ActorFunc)BgOpenShutter_Draw, }; -// static InitChainEntry sInitChain[] = { -static InitChainEntry D_80ACB140[] = { +static InitChainEntry sInitChain[] = { ICHAIN_F32(uncullZoneForward, 4000, ICHAIN_CONTINUE), ICHAIN_F32(uncullZoneScale, 350, ICHAIN_CONTINUE), ICHAIN_F32(uncullZoneDownward, 350, ICHAIN_CONTINUE), ICHAIN_VEC3F_DIV1000(scale, 100, ICHAIN_STOP), }; -#endif +f32 func_80ACAB10(PlayState* play, Actor* actor, f32 arg2, f32 arg3, f32 arg4) { + Player* player = GET_PLAYER(play); + Vec3f point; + Vec3f offset; -extern InitChainEntry D_80ACB140[]; + point.x = player->actor.world.pos.x; + point.y = player->actor.world.pos.y + arg2; + point.z = player->actor.world.pos.z; -extern UNK_TYPE D_060003E8; -extern UNK_TYPE D_06001640; + Actor_OffsetOfPointInActorCoords(actor, &offset, &point); + if ((arg3 < fabsf(offset.x)) || (arg4 < fabsf(offset.y))) { + return FLT_MAX; + } else { + return offset.z; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Open_Shutter/func_80ACAB10.s") +s8 func_80ACABA8(BgOpenShutter* this, PlayState* play) { + Player* player = GET_PLAYER(play); + f32 temp_fv0; + s16 temp_v0; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Open_Shutter/func_80ACABA8.s") + if (!Player_InCsMode(play) && (this->dyna.actor.xzDistToPlayer < 100.0f)) { + temp_fv0 = func_80ACAB10(play, &this->dyna.actor, 0.0f, 65.0f, 15.0f); + if (fabsf(temp_fv0) < 50.0f) { + temp_v0 = player->actor.shape.rot.y - this->dyna.actor.shape.rot.y; + if (temp_fv0 > 0.0f) { + temp_v0 = (0x8000 - temp_v0); + } + if (ABS_ALT(temp_v0) < 0x3000) { + if (temp_fv0 > 1.0f) { + return 1; + } + if (temp_fv0 < -1.0f) { + return -1; + } + } + } + } + return 0; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Open_Shutter/BgOpenShutter_Init.s") +void BgOpenShutter_Init(Actor* thisx, PlayState* play) { + BgOpenShutter* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Open_Shutter/BgOpenShutter_Destroy.s") + Actor_ProcessInitChain(&this->dyna.actor, sInitChain); + DynaPolyActor_Init(&this->dyna, 1); + DynaPolyActor_LoadMesh(play, &this->dyna, &object_open_obj_Colheader_001640); + this->actionFunc = func_80ACAD88; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Open_Shutter/func_80ACAD88.s") +void BgOpenShutter_Destroy(Actor* thisx, PlayState* play) { + BgOpenShutter* this = THIS; + s32 params = BGOPENSHUTTER_GET_A(thisx); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Open_Shutter/func_80ACAE5C.s") + play->doorCtx.transitionActorList[params].id = -play->doorCtx.transitionActorList[params].id; + DynaPoly_DeleteBgActor(play, &play->colCtx.dyna, this->dyna.bgId); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Open_Shutter/func_80ACAEF0.s") +void func_80ACAD88(BgOpenShutter* this, PlayState* play) { + s32 quake; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Open_Shutter/BgOpenShutter_Update.s") + if (this->unk_15C != 0) { + Player* player = GET_PLAYER(play); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Open_Shutter/BgOpenShutter_Draw.s") + Actor_PlaySfxAtPos(&this->dyna.actor, NA_SE_EV_SLIDE_DOOR_OPEN); + Camera_ChangeDoorCam(play->cameraPtrs[CAM_ID_MAIN], &this->dyna.actor, player->unk_3BA, 0.0f, 12, 15, 10); + this->unk_164 = 0; + this->actionFunc = func_80ACAE5C; + this->dyna.actor.velocity.y = 0.0f; + } else { + Player* player = GET_PLAYER(play); + + quake = func_80ACABA8(this, play); + if (quake > 0) { + player->doorType = 2; + player->doorDirection = quake; + player->doorActor = &this->dyna.actor; + func_80122F28(player); + } + } +} + +void func_80ACAE5C(BgOpenShutter* this, PlayState* play) { + Math_StepToF(&this->dyna.actor.velocity.y, 15.0f, 3.0f); + if (Math_StepToF(&this->dyna.actor.world.pos.y, this->dyna.actor.home.pos.y + 120.0f, + this->dyna.actor.velocity.y)) { + this->unk_164++; + } + if (this->unk_164 >= 10) { + Actor_PlaySfxAtPos(&this->dyna.actor, NA_SE_EV_SLIDE_DOOR_CLOSE); + this->actionFunc = func_80ACAEF0; + } +} + +void func_80ACAEF0(BgOpenShutter* this, PlayState* play) { + s32 pad; + s16 quake; + + Math_StepToF(&this->dyna.actor.velocity.y, 20.0f, 8.0f); + if (Math_StepToF(&this->dyna.actor.world.pos.y, this->dyna.actor.home.pos.y, this->dyna.actor.velocity.y)) { + this->dyna.actor.floorHeight = this->dyna.actor.home.pos.y; + Actor_SpawnFloorDustRing(play, &this->dyna.actor, &this->dyna.actor.world.pos, 60.0f, 10, 8.0f, 500, 10, true); + Actor_PlaySfxAtPos(&this->dyna.actor, NA_SE_EV_BIGWALL_BOUND); + quake = Quake_Add(Play_GetCamera(play, CAM_ID_MAIN), 3); + Quake_SetSpeed(quake, -0x7F18); + Quake_SetQuakeValues(quake, 2, 0, 0, 0); + Quake_SetCountdown(quake, 10); + Rumble_Request(this->dyna.actor.xyzDistToPlayerSq, 180, 20, 100); + this->unk_15C = 0; + this->actionFunc = func_80ACAD88; + } +} + +void BgOpenShutter_Update(Actor* thisx, PlayState* play2) { + BgOpenShutter* this = THIS; + PlayState* play = play2; + s32 index; + + if (Cutscene_CheckActorAction(play, 0x7C)) { + index = Cutscene_GetActorActionIndex(play, 0x7C); + if (play->csCtx.actorActions[index]->action == BGOPENSHUTTER_DOOR_OPEN) { + if (this->actionFunc == func_80ACAD88) { + Actor_PlaySfxAtPos(&this->dyna.actor, NA_SE_EV_SLIDE_DOOR_OPEN); + this->actionFunc = func_80ACAE5C; + this->dyna.actor.velocity.y = 0.0f; + } + this->unk_164 = 0; + } else if (play->csCtx.actorActions[index]->action == BGOPENSHUTTER_DOOR_CLOSED) { + if (this->actionFunc == func_80ACAE5C) { + Actor_PlaySfxAtPos(&this->dyna.actor, NA_SE_EV_SLIDE_DOOR_CLOSE); + this->actionFunc = func_80ACAEF0; + } + } + } + this->actionFunc(this, play); +} + +void BgOpenShutter_Draw(Actor* thisx, PlayState* play) { + Gfx_DrawDListOpa(play, object_open_obj_DL_0003E8); +} diff --git a/src/overlays/actors/ovl_Bg_Open_Shutter/z_bg_open_shutter.h b/src/overlays/actors/ovl_Bg_Open_Shutter/z_bg_open_shutter.h index 90c682e73..fdf2791e1 100644 --- a/src/overlays/actors/ovl_Bg_Open_Shutter/z_bg_open_shutter.h +++ b/src/overlays/actors/ovl_Bg_Open_Shutter/z_bg_open_shutter.h @@ -3,15 +3,17 @@ #include "global.h" +#define BGOPENSHUTTER_GET_A(thisx) ((u16)((thisx)->params) >> 0xA) + struct BgOpenShutter; -typedef void (*BgOpenShutterActionFunc)(struct BgOpenShutter*, GlobalContext*); +typedef void (*BgOpenShutterActionFunc)(struct BgOpenShutter*, PlayState*); typedef struct BgOpenShutter { - /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x1C]; - /* 0x0160 */ BgOpenShutterActionFunc actionFunc; - /* 0x0164 */ char unk_164[0x4]; + /* 0x000 */ DynaPolyActor dyna; + /* 0x15C */ s16 unk_15C; + /* 0x160 */ BgOpenShutterActionFunc actionFunc; + /* 0x164 */ s32 unk_164; } BgOpenShutter; // size = 0x168 extern const ActorInit Bg_Open_Shutter_InitVars; diff --git a/src/overlays/actors/ovl_Bg_Open_Spot/z_bg_open_spot.c b/src/overlays/actors/ovl_Bg_Open_Spot/z_bg_open_spot.c index b776253e6..0f800f97b 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 (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_Init(Actor* thisx, PlayState* play); +void BgOpenSpot_Destroy(Actor* thisx, PlayState* play); +void BgOpenSpot_Update(Actor* thisx, PlayState* play); +void BgOpenSpot_Draw(Actor* thisx, PlayState* play); -#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, PlayState* play) { + 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, PlayState* play) { +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Open_Spot/BgOpenSpot_Init.s") +void BgOpenSpot_Update(Actor* thisx, PlayState* play) { + BgOpenSpot* this = THIS; + u32 action; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Open_Spot/BgOpenSpot_Destroy.s") + if (Cutscene_CheckActorAction(play, 0x7D)) { + action = play->csCtx.actorActions[Cutscene_GetActorActionIndex(play, 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, PlayState* play) { + s32 pad; + BgOpenSpot* this = (BgOpenSpot*)thisx; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Open_Spot/func_80ACB2B0.s") + AnimatedMat_Draw(play, this->texScrolls); + OPEN_DISPS(play->state.gfxCtx); + + func_8012C2DC(play->state.gfxCtx); + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(play->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(play->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 e5af3fe1f..fb8f04d78 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,20 +1,29 @@ /* * File: z_bg_sinkai_kabe.c * Overlay: ovl_Bg_Sinkai_Kabe - * Description: Manages the Deep Pythons and Seahorse in Pinnacle Rock + * 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 (ACTOR_FLAG_10) #define THIS ((BgSinkaiKabe*)thisx) -void BgSinkaiKabe_Init(Actor* thisx, GlobalContext* globalCtx); -void BgSinkaiKabe_Destroy(Actor* thisx, GlobalContext* globalCtx); -void BgSinkaiKabe_Update(Actor* thisx, GlobalContext* globalCtx); +void BgSinkaiKabe_Init(Actor* thisx, PlayState* play); +void BgSinkaiKabe_Destroy(Actor* thisx, PlayState* play); +void BgSinkaiKabe_Update(Actor* thisx, PlayState* play); + +void BgSinkaiKabe_WaitForPlayer(BgSinkaiKabe* this, PlayState* play); -#if 0 const ActorInit Bg_Sinkai_Kabe_InitVars = { ACTOR_BG_SINKAI_KABE, ACTORCAT_ITEMACTION, @@ -27,14 +36,116 @@ const ActorInit Bg_Sinkai_Kabe_InitVars = { (ActorFunc)NULL, }; -#endif +static s32 sCurrentPythonIndex = 0; -extern UNK_TYPE D_06000048; +void BgSinkaiKabe_Init(Actor* thisx, PlayState* play) { + 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(play, &play->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(&play->actorCtx, &this->dyna.actor, play, 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(&play->actorCtx, play, ACTOR_EN_OT, pos.x, pos.y, pos.z, 0, + this->dyna.actor.shape.rot.y, 0, 0x4000, this->dyna.actor.cutscene, + this->dyna.actor.unk20, NULL); + } + + Actor_MarkForDeath(&this->dyna.actor); + } + + this->actionFunc = BgSinkaiKabe_WaitForPlayer; +} + +void BgSinkaiKabe_Destroy(Actor* thisx, PlayState* play) { + BgSinkaiKabe* this = THIS; + + DynaPoly_DeleteBgActor(play, &play->colCtx.dyna, this->dyna.bgId); +} + +/** + * Extends this actor's Deep Python if the player gets close enough. + */ +void BgSinkaiKabe_WaitForPlayer(BgSinkaiKabe* this, PlayState* play) { + 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(play); + + 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, PlayState* play) { + BgSinkaiKabe* this = THIS; + + this->actionFunc(this, play); +} 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..bc39da0ee 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 void (*BgSinkaiKabeActionFunc)(struct BgSinkaiKabe*, PlayState*); 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 d1847009c..296f56268 100644 --- a/src/overlays/actors/ovl_Bg_Spdweb/z_bg_spdweb.c +++ b/src/overlays/actors/ovl_Bg_Spdweb/z_bg_spdweb.c @@ -11,18 +11,18 @@ #define THIS ((BgSpdweb*)thisx) -void BgSpdweb_Init(Actor* thisx, GlobalContext* globalCtx); -void BgSpdweb_Destroy(Actor* thisx, GlobalContext* globalCtx); -void BgSpdweb_Update(Actor* thisx, GlobalContext* globalCtx); -void BgSpdweb_Draw(Actor* thisx, GlobalContext* globalCtx); +void BgSpdweb_Init(Actor* thisx, PlayState* play); +void BgSpdweb_Destroy(Actor* thisx, PlayState* play); +void BgSpdweb_Update(Actor* thisx, PlayState* play); +void BgSpdweb_Draw(Actor* thisx, PlayState* play); 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_809CE234(BgSpdweb* this, PlayState* play); +void func_809CE4C8(BgSpdweb* this, PlayState* play); +void func_809CE830(BgSpdweb* this, PlayState* play); +void func_809CEBC0(BgSpdweb* this, PlayState* play); void func_809CEE74(BgSpdweb* this); -void func_809CEEAC(BgSpdweb* this, GlobalContext* globalCtx); +void func_809CEEAC(BgSpdweb* this, PlayState* play); const ActorInit Bg_Spdweb_InitVars = { ACTOR_BG_SPDWEB, @@ -70,7 +70,7 @@ static ColliderTrisInit sTrisInit1 = { OC2_TYPE_2, COLSHAPE_TRIS, }, - 2, + ARRAY_COUNT(sTrisElementsInit1), sTrisElementsInit1, }; @@ -130,7 +130,7 @@ static ColliderTrisInit sTrisInit2 = { OC2_TYPE_2, COLSHAPE_TRIS, }, - 4, + ARRAY_COUNT(sTrisElementsInit2), sTrisElementsInit2, }; @@ -143,7 +143,7 @@ static InitChainEntry sInitChain[] = { ICHAIN_VEC3F_DIV1000(scale, 100, ICHAIN_STOP), }; -void BgSpdweb_Init(Actor* thisx, GlobalContext* globalCtx) { +void BgSpdweb_Init(Actor* thisx, PlayState* play) { BgSpdweb* this = THIS; Actor_ProcessInitChain(&this->dyna.actor, sInitChain); @@ -153,32 +153,32 @@ void BgSpdweb_Init(Actor* thisx, GlobalContext* globalCtx) { DynaPolyActor_Init(&this->dyna, 1); if (this->dyna.actor.params == BGSPDWEB_FF_0) { - Collider_InitAndSetTris(globalCtx, &this->collider, &this->dyna.actor, &sTrisInit1, this->colliderElements); + Collider_InitAndSetTris(play, &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; + DynaPolyActor_LoadMesh(play, &this->dyna, &object_spdweb_Colheader_002678); + this->unk_2F8 = play->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); + Collider_InitAndSetTris(play, &this->collider, &this->dyna.actor, &sTrisInit2, this->colliderElements); func_809CE068(this); - DynaPolyActor_LoadMesh(globalCtx, &this->dyna, &object_spdweb_Colheader_0011C0); + DynaPolyActor_LoadMesh(play, &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)) { + if (Flags_GetSwitch(play, this->switchFlag)) { Actor_MarkForDeath(&this->dyna.actor); } } -void BgSpdweb_Destroy(Actor* thisx, GlobalContext* globalCtx) { +void BgSpdweb_Destroy(Actor* thisx, PlayState* play) { BgSpdweb* this = THIS; - DynaPoly_DeleteBgActor(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); - Collider_DestroyTris(globalCtx, &this->collider); + DynaPoly_DeleteBgActor(play, &play->colCtx.dyna, this->dyna.bgId); + Collider_DestroyTris(play, &this->collider); } void func_809CE068(BgSpdweb* this) { @@ -186,12 +186,12 @@ void func_809CE068(BgSpdweb* this) { s32 i; s32 j; - Matrix_SetStateRotationAndTranslation(this->dyna.actor.world.pos.x, this->dyna.actor.world.pos.y, - this->dyna.actor.world.pos.z, &this->dyna.actor.shape.rot); + 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_MultiplyVector3fByState(this->collider.elements[i].dim.vtx + j, &sp64[j]); + Matrix_MultVec3f(this->collider.elements[i].dim.vtx + j, &sp64[j]); } Collider_SetTrisVertices(&this->collider, i, &sp64[0], &sp64[1], &sp64[2]); } @@ -203,9 +203,9 @@ void func_809CE15C(BgSpdweb* this) { (this->dyna.actor.home.pos.y - this->dyna.actor.world.pos.y) * 10.0f; } -void func_809CE1D0(BgSpdweb* this, GlobalContext* globalCtx) { +void func_809CE1D0(BgSpdweb* this, PlayState* play) { this->unk_162 = 30; - Flags_SetSwitch(globalCtx, this->switchFlag); + Flags_SetSwitch(play, this->switchFlag); if (this->dyna.actor.params == BGSPDWEB_FF_0) { this->actionFunc = func_809CE234; @@ -214,7 +214,7 @@ void func_809CE1D0(BgSpdweb* this, GlobalContext* globalCtx) { } } -void func_809CE234(BgSpdweb* this, GlobalContext* globalCtx) { +void func_809CE234(BgSpdweb* this, PlayState* play) { Vec3f spB4; Vec3f spA8; f32 temp_f20; @@ -258,17 +258,17 @@ void func_809CE234(BgSpdweb* this, GlobalContext* globalCtx) { 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); + EffectSsDeadDb_Spawn(play, &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); + SoundSource_PlaySfxAtFixedWorldPos(play, &this->dyna.actor.home.pos, 11, NA_SE_EN_EXTINCT); } } -void func_809CE4C8(BgSpdweb* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); +void func_809CE4C8(BgSpdweb* this, PlayState* play) { + Player* player = GET_PLAYER(play); Vec3f sp40; ColliderTrisElement* element; s16 sp3A; @@ -280,9 +280,9 @@ void func_809CE4C8(BgSpdweb* this, GlobalContext* globalCtx) { 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; + if (Player_IsBurningStickInRange(play, &sp40, 70.0f, 50.0f)) { + this->dyna.actor.home.pos.x = player->meleeWeaponInfo[0].tip.x; + this->dyna.actor.home.pos.z = player->meleeWeaponInfo[0].tip.z; func_809CEE74(this); return; } @@ -338,7 +338,7 @@ void func_809CE4C8(BgSpdweb* this, GlobalContext* globalCtx) { if (this->unk_164 > 3.0f) { Actor_PlaySfxAtPos(&this->dyna.actor, NA_SE_EV_WEB_VIBRATION); } else { - func_801A75E8(NA_SE_EV_WEB_VIBRATION); + AudioSfx_StopById(NA_SE_EV_WEB_VIBRATION); } } @@ -347,26 +347,23 @@ void func_809CE4C8(BgSpdweb* this, GlobalContext* globalCtx) { } func_809CE15C(this); - CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + CollisionCheck_SetAC(play, &play->colChkCtx, &this->collider.base); } -#ifdef NON_MATCHING -void func_809CE830(BgSpdweb* this, GlobalContext* globalCtx) { +void func_809CE830(BgSpdweb* this, PlayState* play) { 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; + s16 temp_s0; + f32 cosF2; + f32 sinF2; + f32 cosQ; + f32 sinQ; + f32 cosF1; + f32 sinF1; + f32 temp_f28; if (this->unk_162 != 0) { this->unk_162--; @@ -382,53 +379,46 @@ void func_809CE830(BgSpdweb* this, GlobalContext* globalCtx) { 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) {} + cosQ = Math_CosS(this->dyna.actor.shape.rot.x); + sinQ = Math_SinS(this->dyna.actor.shape.rot.x); + cosF1 = Math_CosS(this->dyna.actor.shape.rot.y); + sinF1 = Math_SinS(this->dyna.actor.shape.rot.y); - 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; + spC4.x = this->dyna.actor.world.pos.x + 90.0f * sinQ * sinF1; + spC4.y = this->dyna.actor.world.pos.y + 90.0f * cosQ; + spC4.z = this->dyna.actor.world.pos.z + 90.0f * sinQ * cosF1; 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); + sinF2 = Math_SinS(temp_s0); + cosF2 = 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))); + spD0.x = spC4.x + 90.0f * ((cosF1 * sinF2) + (sinQ * sinF1 * cosF2)); + spD0.y = spC4.y + 90.0f * cosQ * cosF2; + spD0.z = spC4.z + 90.0f * ((sinQ * cosF1 * cosF2) - (sinF1 * sinF2)); 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)); + sinF2 = Math_SinS(BINANG_ROT180(temp_s0)); + cosF2 = 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)); + spDC.x = 6.5f * temp_f28 * ((cosF1 * sinF2) + (sinQ * sinF1 * cosF2)); + spDC.y = 6.5f * temp_f28 * cosQ * cosF2; + spDC.z = 6.5f * temp_f28 * ((sinQ * cosF1 * cosF2) - (sinF1 * sinF2)); - EffectSsDeadDb_Spawn(globalCtx, &this->dyna.actor.home.pos, &spDC, &gZeroVec3f, &D_809CF208, &D_809CF20C, - 0x3C, 8, 0xE); + EffectSsDeadDb_Spawn(play, &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); + SoundSource_PlaySfxAtFixedWorldPos(play, &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 -void func_809CEBC0(BgSpdweb* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); +void func_809CEBC0(BgSpdweb* this, PlayState* play) { + Player* player = GET_PLAYER(play); f32 sp58; f32 temp_f10; f32 temp_f18; @@ -461,7 +451,7 @@ void func_809CEBC0(BgSpdweb* this, GlobalContext* globalCtx) { } func_809CEE74(this); } else if ((player->itemActionParam == 7) && (player->unk_B28 != 0)) { - Math_Vec3f_Diff(&player->swordInfo[0].tip, &this->dyna.actor.world.pos, &sp3C); + Math_Vec3f_Diff(&player->meleeWeaponInfo[0].tip, &this->dyna.actor.world.pos, &sp3C); sp38 = Math_SinS(-this->dyna.actor.shape.rot.x); sp34 = Math_CosS(-this->dyna.actor.shape.rot.x); sp30 = Math_SinS(-this->dyna.actor.shape.rot.y); @@ -472,12 +462,12 @@ void func_809CEBC0(BgSpdweb* this, GlobalContext* globalCtx) { temp_f10 = (sp3C.x * sp2C) + (sp3C.z * sp30); if ((fabsf(temp_f10) < 70.0f) && (fabsf(sp58) < 10.0f) && (temp_f18 < 160.0f) && (temp_f18 > 20.0f)) { - Math_Vec3f_Copy(&this->dyna.actor.home.pos, &player->swordInfo[0].tip); + Math_Vec3f_Copy(&this->dyna.actor.home.pos, &player->meleeWeaponInfo[0].tip); func_809CEE74(this); } } - CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + CollisionCheck_SetAC(play, &play->colChkCtx, &this->collider.base); } void func_809CEE74(BgSpdweb* this) { @@ -485,42 +475,42 @@ void func_809CEE74(BgSpdweb* this) { this->actionFunc = func_809CEEAC; } -void func_809CEEAC(BgSpdweb* this, GlobalContext* globalCtx) { +void func_809CEEAC(BgSpdweb* this, PlayState* play) { if (ActorCutscene_GetCanPlayNext(this->dyna.actor.cutscene)) { ActorCutscene_StartAndSetUnkLinkFields(this->dyna.actor.cutscene, &this->dyna.actor); - func_809CE1D0(this, globalCtx); + func_809CE1D0(this, play); } else { ActorCutscene_SetIntentToPlay(this->dyna.actor.cutscene); } } -void BgSpdweb_Update(Actor* thisx, GlobalContext* globalCtx) { +void BgSpdweb_Update(Actor* thisx, PlayState* play) { BgSpdweb* this = THIS; - this->actionFunc(this, globalCtx); + this->actionFunc(this, play); } -void BgSpdweb_Draw(Actor* thisx, GlobalContext* globalCtx) { +void BgSpdweb_Draw(Actor* thisx, PlayState* play) { Gfx* gfx; - OPEN_DISPS(globalCtx->state.gfxCtx); + OPEN_DISPS(play->state.gfxCtx); gfx = POLY_XLU_DISP; gSPDisplayList(&gfx[0], &sSetupDL[6 * 25]); if (thisx->params == BGSPDWEB_FF_1) { - gSPMatrix(&gfx[1], Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPMatrix(&gfx[1], Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(&gfx[2], object_spdweb_DL_000060); } else { - Matrix_InsertTranslation(0.0f, (thisx->home.pos.y - thisx->world.pos.y) * 10.0f, 0.0f, MTXMODE_APPLY); + Matrix_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); + gSPMatrix(&gfx[1], Matrix_NewMtx(play->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); + CLOSE_DISPS(play->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 9a71c278f..64a6fd34b 100644 --- a/src/overlays/actors/ovl_Bg_Spdweb/z_bg_spdweb.h +++ b/src/overlays/actors/ovl_Bg_Spdweb/z_bg_spdweb.h @@ -5,7 +5,7 @@ struct BgSpdweb; -typedef void (*BgSpdwebActionFunc)(struct BgSpdweb*, GlobalContext*); +typedef void (*BgSpdwebActionFunc)(struct BgSpdweb*, PlayState*); #define BGSPDWEB_GET_SWITCHFLAG(thisx) (((thisx)->params >> 8) & 0x7F) @@ -13,15 +13,15 @@ typedef void (*BgSpdwebActionFunc)(struct BgSpdweb*, GlobalContext*); #define BGSPDWEB_FF_1 1 typedef struct BgSpdweb { - /* 0x0000 */ DynaPolyActor dyna; - /* 0x015C */ BgSpdwebActionFunc actionFunc; - /* 0x0160 */ u8 switchFlag; - /* 0x0161 */ u8 unk_161; - /* 0x0162 */ s16 unk_162; - /* 0x0164 */ f32 unk_164; - /* 0x0168 */ ColliderTris collider; - /* 0x0188 */ ColliderTrisElement colliderElements[4]; - /* 0x02F8 */ Vec3s* unk_2F8; + /* 0x000 */ DynaPolyActor dyna; + /* 0x15C */ BgSpdwebActionFunc actionFunc; + /* 0x160 */ u8 switchFlag; + /* 0x161 */ u8 unk_161; + /* 0x162 */ s16 unk_162; + /* 0x164 */ f32 unk_164; + /* 0x168 */ ColliderTris collider; + /* 0x188 */ ColliderTrisElement colliderElements[4]; + /* 0x2F8 */ Vec3s* unk_2F8; } BgSpdweb; // size = 0x2FC extern const ActorInit Bg_Spdweb_InitVars; diff --git a/src/overlays/actors/ovl_Bg_Spout_Fire/z_bg_spout_fire.c b/src/overlays/actors/ovl_Bg_Spout_Fire/z_bg_spout_fire.c index 08a7087e3..055598c00 100644 --- a/src/overlays/actors/ovl_Bg_Spout_Fire/z_bg_spout_fire.c +++ b/src/overlays/actors/ovl_Bg_Spout_Fire/z_bg_spout_fire.c @@ -5,20 +5,23 @@ */ #include "z_bg_spout_fire.h" +#include "objects/object_fwall/object_fwall.h" #define FLAGS 0x00000000 #define THIS ((BgSpoutFire*)thisx) -void BgSpoutFire_Init(Actor* thisx, GlobalContext* globalCtx); -void BgSpoutFire_Destroy(Actor* thisx, GlobalContext* globalCtx); -void BgSpoutFire_Update(Actor* thisx, GlobalContext* globalCtx); +void BgSpoutFire_Init(Actor* thisx, PlayState* play); +void BgSpoutFire_Destroy(Actor* thisx, PlayState* play); +void BgSpoutFire_Update(Actor* thisx, PlayState* play); +void BgSpoutFire_Draw(Actor* thisx, PlayState* play); -void func_80A60C94(BgSpoutFire* this, GlobalContext* globalCtx); -void func_80A60CDC(BgSpoutFire* this, GlobalContext* globalCtx); -void func_80A60D10(BgSpoutFire* this, GlobalContext* globalCtx); +s32 func_80A60C24(BgSpoutFire* this, PlayState* play); +void func_80A60C94(BgSpoutFire* this, PlayState* play); +void func_80A60CDC(BgSpoutFire* this, PlayState* play); +void func_80A60D10(BgSpoutFire* this, PlayState* play); +void func_80A60E08(BgSpoutFire* this, PlayState* play); -#if 0 const ActorInit Bg_Spout_Fire_InitVars = { ACTOR_BG_SPOUT_FIRE, ACTORCAT_BG, @@ -31,39 +34,170 @@ const ActorInit Bg_Spout_Fire_InitVars = { (ActorFunc)NULL, }; -// static ColliderCylinderInit sCylinderInit = { -static ColliderCylinderInit D_80A61160 = { - { COLTYPE_NONE, AT_ON | AT_TYPE_ENEMY, AC_NONE, OC1_ON | OC1_TYPE_PLAYER, OC2_TYPE_2, COLSHAPE_CYLINDER, }, - { ELEMTYPE_UNK0, { 0x20000000, 0x01, 0x04 }, { 0xF7CFFFFF, 0x00, 0x00 }, TOUCH_ON | TOUCH_SFX_NONE, BUMP_NONE, OCELEM_ON, }, +static ColliderCylinderInit sCylinderInit = { + { + COLTYPE_NONE, + AT_ON | AT_TYPE_ENEMY, + AC_NONE, + OC1_ON | OC1_TYPE_PLAYER, + OC2_TYPE_2, + COLSHAPE_CYLINDER, + }, + { + ELEMTYPE_UNK0, + { 0x20000000, 0x01, 0x04 }, + { 0xF7CFFFFF, 0x00, 0x00 }, + TOUCH_ON | TOUCH_SFX_NONE, + BUMP_NONE, + OCELEM_ON, + }, { 30, 83, 0, { 0, 0, 0 } }, }; -// sColChkInfoInit -static CollisionCheckInfoInit D_80A6118C = { 1, 80, 100, MASS_IMMOVABLE }; +static CollisionCheckInfoInit sColChkInfoInit = { 1, 80, 100, MASS_IMMOVABLE }; -#endif +static TexturePtr sFlameTextures[] = { + gFwallFireball0Tex, gFwallFireball1Tex, gFwallFireball2Tex, gFwallFireball3Tex, + gFwallFireball4Tex, gFwallFireball5Tex, gFwallFireball6Tex, gFwallFireball7Tex, +}; -extern ColliderCylinderInit D_80A61160; -extern CollisionCheckInfoInit D_80A6118C; +static s32 sTexturesDesegmented = false; -extern UNK_TYPE D_06000040; +void BgSpoutFire_Init(Actor* thisx, PlayState* play) { + s32 i; + BgSpoutFire* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Spout_Fire/BgSpoutFire_Init.s") + this->actor.scale.z = 1350.0f * 0.0001f; + this->actor.scale.x = 1350.0f * 0.0001f; + this->actor.scale.y = 0.01f; + this->flameTexIndex = 0; + Collider_InitAndSetCylinder(play, &this->collider, &this->actor, &sCylinderInit); + this->collider.dim.pos.y = this->actor.world.pos.y; + CollisionCheck_SetInfo(&this->actor.colChkInfo, NULL, &sColChkInfoInit); + if (!sTexturesDesegmented) { + for (i = 0; i < ARRAY_COUNT(sFlameTextures); i++) { + sFlameTextures[i] = Lib_SegmentedToVirtual(sFlameTextures[i]); + } + sTexturesDesegmented = true; + } + this->actionFunc = func_80A60C94; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Spout_Fire/BgSpoutFire_Destroy.s") +void BgSpoutFire_Destroy(Actor* thisx, PlayState* play) { + BgSpoutFire* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Spout_Fire/func_80A60C24.s") + Collider_DestroyCylinder(play, &this->collider); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Spout_Fire/func_80A60C94.s") +s32 func_80A60C24(BgSpoutFire* this, PlayState* play) { + Player* player = GET_PLAYER(play); + Vec3f sp18; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Spout_Fire/func_80A60CDC.s") + Actor_OffsetOfPointInActorCoords(&this->actor, &sp18, &player->actor.world.pos); + if ((fabsf(sp18.x) < 100.0f) && (fabsf(sp18.z) < 120.0f)) { + return true; + } else { + return false; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Spout_Fire/func_80A60D10.s") +void func_80A60C94(BgSpoutFire* this, PlayState* play) { + if (func_80A60C24(this, play)) { + this->actor.draw = BgSpoutFire_Draw; + this->timer = 5; + this->actionFunc = func_80A60CDC; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Spout_Fire/func_80A60DA0.s") +void func_80A60CDC(BgSpoutFire* this, PlayState* play) { + if (this->timer != 0) { + this->timer--; + } + if (this->timer == 0) { + this->actionFunc = func_80A60D10; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Spout_Fire/func_80A60E08.s") +void func_80A60D10(BgSpoutFire* this, PlayState* play) { + if (func_80A60C24(this, play)) { + Math_StepToF(&this->actor.scale.y, 0.1f, 2.5f * 0.01f); + } else if (Math_StepToF(&this->actor.scale.y, 0.01f, 0.01f)) { + this->actor.draw = NULL; + this->actionFunc = func_80A60C94; + } else { + this->timer = 0; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Spout_Fire/BgSpoutFire_Update.s") +void func_80A60DA0(BgSpoutFire* this, PlayState* play) { + s16 phi_a3; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Spout_Fire/func_80A61040.s") + if (Actor_IsFacingPlayer(&this->actor, 0x4000)) { + phi_a3 = this->actor.shape.rot.y; + } else { + phi_a3 = (this->actor.shape.rot.y + 0x8000); + } + func_800B8D98(play, &this->actor, 5.0f, phi_a3, 1.0f); +} + +void func_80A60E08(BgSpoutFire* this, PlayState* play) { + Player* player = GET_PLAYER(play); + Vec3f sp30; + f32 cos; + f32 sin; + + Actor_OffsetOfPointInActorCoords(&this->actor, &sp30, &player->actor.world.pos); + sp30.x = CLAMP(sp30.x, -74.25f, 74.25f); + if (this->timer == 0) { + if (sp30.z > 0.0f) { + sp30.z = -25.0f; + this->timer = -1; + } else { + sp30.z = 25.0f; + this->timer = 1; + } + } else { + sp30.z = this->timer * 25.0f; + } + sin = Math_SinS(this->actor.shape.rot.y); + cos = Math_CosS(this->actor.shape.rot.y); + this->collider.dim.pos.x = this->actor.world.pos.x + (sp30.x * cos) + (sp30.z * sin); + this->collider.dim.pos.z = this->actor.world.pos.z - (sp30.x * sin) + (sp30.z * cos); +} + +void BgSpoutFire_Update(Actor* thisx, PlayState* play) { + s32 pad; + BgSpoutFire* this = THIS; + + this->flameTexIndex = (this->flameTexIndex + 1) % 8; + if ((this->collider.base.atFlags & AT_HIT)) { + this->collider.base.atFlags &= ~AT_HIT; + func_80A60DA0(this, play); + } + this->actionFunc(this, play); + if (this->actionFunc == func_80A60D10) { + func_80A60E08(this, play); + CollisionCheck_SetAT(play, &play->colChkCtx, &this->collider.base); + CollisionCheck_SetOC(play, &play->colChkCtx, &this->collider.base); + func_800B9010(&this->actor, NA_SE_EV_FIRE_PLATE - SFX_FLAG); + } +} + +void BgSpoutFire_Draw(Actor* thisx, PlayState* play) { + BgSpoutFire* this = THIS; + Gfx* gfx; + + OPEN_DISPS(play->state.gfxCtx); + + gfx = Gfx_CallSetupDL(POLY_XLU_DISP, 0x14); + POLY_XLU_DISP = gfx; + gSPSegment(&gfx[0], 0x08, sFlameTextures[this->flameTexIndex]); + gDPSetPrimColor(&gfx[1], 0, 1, 255, 255, 0, 150); + gDPSetEnvColor(&gfx[2], 255, 0, 0, 255); + Matrix_Translate(-55.0f, 0.0f, 0.0f, MTXMODE_APPLY); + gSPMatrix(&gfx[3], Matrix_NewMtx(play->state.gfxCtx), (G_MTX_NOPUSH | G_MTX_LOAD) | G_MTX_MODELVIEW); + gSPDisplayList(&gfx[4], object_fwall_DL_000040); + POLY_XLU_DISP = &gfx[5]; + + CLOSE_DISPS(play->state.gfxCtx); +} diff --git a/src/overlays/actors/ovl_Bg_Spout_Fire/z_bg_spout_fire.h b/src/overlays/actors/ovl_Bg_Spout_Fire/z_bg_spout_fire.h index 6fc19e4ca..808b72061 100644 --- a/src/overlays/actors/ovl_Bg_Spout_Fire/z_bg_spout_fire.h +++ b/src/overlays/actors/ovl_Bg_Spout_Fire/z_bg_spout_fire.h @@ -5,12 +5,14 @@ struct BgSpoutFire; -typedef void (*BgSpoutFireActionFunc)(struct BgSpoutFire*, GlobalContext*); +typedef void (*BgSpoutFireActionFunc)(struct BgSpoutFire*, PlayState*); typedef struct BgSpoutFire { - /* 0x0000 */ Actor actor; - /* 0x0144 */ BgSpoutFireActionFunc actionFunc; - /* 0x0148 */ char unk_148[0x50]; + /* 0x000 */ Actor actor; + /* 0x144 */ BgSpoutFireActionFunc actionFunc; + /* 0x148 */ s16 timer; + /* 0x14A */ s16 flameTexIndex; + /* 0x14C */ ColliderCylinder collider; } BgSpoutFire; // size = 0x198 extern const ActorInit Bg_Spout_Fire_InitVars; diff --git a/src/overlays/actors/ovl_Bg_Tobira01/z_bg_tobira01.c b/src/overlays/actors/ovl_Bg_Tobira01/z_bg_tobira01.c index f9b76fd00..55276b217 100644 --- a/src/overlays/actors/ovl_Bg_Tobira01/z_bg_tobira01.c +++ b/src/overlays/actors/ovl_Bg_Tobira01/z_bg_tobira01.c @@ -11,10 +11,10 @@ #define THIS ((BgTobira01*)thisx) -void BgTobira01_Init(Actor* thisx, GlobalContext* globalCtx); -void BgTobira01_Destroy(Actor* thisx, GlobalContext* globalCtx); -void BgTobira01_Update(Actor* thisx, GlobalContext* globalCtx); -void BgTobira01_Draw(Actor* thisx, GlobalContext* globalCtx); +void BgTobira01_Init(Actor* thisx, PlayState* play); +void BgTobira01_Destroy(Actor* thisx, PlayState* play); +void BgTobira01_Update(Actor* thisx, PlayState* play); +void BgTobira01_Draw(Actor* thisx, PlayState* play); const ActorInit Bg_Tobira01_InitVars = { ACTOR_BG_TOBIRA01, @@ -28,8 +28,8 @@ const ActorInit Bg_Tobira01_InitVars = { (ActorFunc)BgTobira01_Draw, }; -void BgTobira01_Open(BgTobira01* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); +void BgTobira01_Open(BgTobira01* this, PlayState* play) { + Player* player = GET_PLAYER(play); s16 cutsceneId = this->dyna.actor.cutscene; s16 prevTimer; @@ -43,10 +43,9 @@ void BgTobira01_Open(BgTobira01* this, GlobalContext* globalCtx) { } else { ActorCutscene_SetIntentToPlay(cutsceneId); } - } 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)) { + } else if (!(gSaveContext.save.weekEventReg[88] & 0x40) && (this->timer == 0) && (play->actorCtx.unk1F5 != 0) && + (play->actorCtx.unk1F4 == 0) && + (SurfaceType_GetSceneExitIndex(&play->colCtx, player->actor.floorPoly, player->actor.floorBgId) == 6)) { this->playCutscene = true; this->unk_16C = 0; // this variable is not used anywhere else } @@ -73,12 +72,12 @@ void BgTobira01_Open(BgTobira01* this, GlobalContext* globalCtx) { } } -void BgTobira01_Init(Actor* thisx, GlobalContext* globalCtx) { +void BgTobira01_Init(Actor* thisx, PlayState* play) { BgTobira01* this = THIS; s32 pad; DynaPolyActor_Init(&this->dyna, 1); - DynaPolyActor_LoadMesh(globalCtx, &this->dyna, &object_spot11_obj_Colheader_0011C0); + DynaPolyActor_LoadMesh(play, &this->dyna, &object_spot11_obj_Colheader_0011C0); gSaveContext.save.weekEventReg[88] &= (u8)~0x40; Actor_SetScale(&this->dyna.actor, 1.0f); this->timer2 = gSaveContext.save.isNight; @@ -86,26 +85,26 @@ void BgTobira01_Init(Actor* thisx, GlobalContext* globalCtx) { this->actionFunc = BgTobira01_Open; } -void BgTobira01_Destroy(Actor* thisx, GlobalContext* globalCtx) { +void BgTobira01_Destroy(Actor* thisx, PlayState* play) { BgTobira01* this = THIS; s32 pad; - DynaPoly_DeleteBgActor(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); + DynaPoly_DeleteBgActor(play, &play->colCtx.dyna, this->dyna.bgId); } -void BgTobira01_Update(Actor* thisx, GlobalContext* globalCtx) { +void BgTobira01_Update(Actor* thisx, PlayState* play) { BgTobira01* this = THIS; s32 pad; - this->actionFunc(this, globalCtx); + this->actionFunc(this, play); } -void BgTobira01_Draw(Actor* thisx, GlobalContext* globalCtx) { - OPEN_DISPS(globalCtx->state.gfxCtx); +void BgTobira01_Draw(Actor* thisx, PlayState* play) { + OPEN_DISPS(play->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); + func_8012C28C(play->state.gfxCtx); + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_OPA_DISP++, object_spot11_obj_DL_000088); - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->state.gfxCtx); } diff --git a/src/overlays/actors/ovl_Bg_Tobira01/z_bg_tobira01.h b/src/overlays/actors/ovl_Bg_Tobira01/z_bg_tobira01.h index eeed58695..559ea6351 100644 --- a/src/overlays/actors/ovl_Bg_Tobira01/z_bg_tobira01.h +++ b/src/overlays/actors/ovl_Bg_Tobira01/z_bg_tobira01.h @@ -5,7 +5,7 @@ struct BgTobira01; -typedef void (*BgTobira01ActionFunc)(struct BgTobira01*, struct GlobalContext*); +typedef void (*BgTobira01ActionFunc)(struct BgTobira01*, struct PlayState*); typedef struct BgTobira01 { /* 0x000 */ DynaPolyActor dyna; diff --git a/src/overlays/actors/ovl_Bg_Umajump/z_bg_umajump.c b/src/overlays/actors/ovl_Bg_Umajump/z_bg_umajump.c index 72aa44fb7..894ced552 100644 --- a/src/overlays/actors/ovl_Bg_Umajump/z_bg_umajump.c +++ b/src/overlays/actors/ovl_Bg_Umajump/z_bg_umajump.c @@ -10,9 +10,9 @@ #define THIS ((BgUmajump*)thisx) -void BgUmajump_Init(Actor* thisx, GlobalContext* globalCtx); -void BgUmajump_Destroy(Actor* thisx, GlobalContext* globalCtx); -void BgUmajump_Update(Actor* thisx, GlobalContext* globalCtx); +void BgUmajump_Init(Actor* thisx, PlayState* play); +void BgUmajump_Destroy(Actor* thisx, PlayState* play); +void BgUmajump_Update(Actor* thisx, PlayState* play); #if 0 const ActorInit Bg_Umajump_InitVars = { diff --git a/src/overlays/actors/ovl_Boss_01/z_boss_01.c b/src/overlays/actors/ovl_Boss_01/z_boss_01.c index 4a6ef6e66..11790f377 100644 --- a/src/overlays/actors/ovl_Boss_01/z_boss_01.c +++ b/src/overlays/actors/ovl_Boss_01/z_boss_01.c @@ -5,37 +5,38 @@ */ #include "z_boss_01.h" +#include "z64rumble.h" #define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_4 | ACTOR_FLAG_10 | ACTOR_FLAG_20) #define THIS ((Boss01*)thisx) -void Boss01_Init(Actor* thisx, GlobalContext* globalCtx); -void Boss01_Destroy(Actor* thisx, GlobalContext* globalCtx); -void Boss01_Update(Actor* thisx, GlobalContext* globalCtx); -void Boss01_Draw(Actor* thisx, GlobalContext* globalCtx); +void Boss01_Init(Actor* thisx, PlayState* play); +void Boss01_Destroy(Actor* thisx, PlayState* play); +void Boss01_Update(Actor* thisx, PlayState* play); +void Boss01_Draw(Actor* thisx, PlayState* play); -void func_809D12B4(Boss01* this, GlobalContext* globalCtx); -void func_809D1B2C(Boss01* this, GlobalContext* globalCtx); -void func_809D1E74(Boss01* this, GlobalContext* globalCtx); -void func_809D20D0(Boss01* this, GlobalContext* globalCtx); -void func_809D25E8(Boss01* this, GlobalContext* globalCtx); -void func_809D26B8(Boss01* this, GlobalContext* globalCtx); -void func_809D27D4(Boss01* this, GlobalContext* globalCtx); -void func_809D2AA0(Boss01* this, GlobalContext* globalCtx); -void func_809D2BCC(Boss01* this, GlobalContext* globalCtx); -void func_809D2CDC(Boss01* this, GlobalContext* globalCtx); -void func_809D2E4C(Boss01* this, GlobalContext* globalCtx); -void func_809D30D0(Boss01* this, GlobalContext* globalCtx); -void func_809D345C(Boss01* this, GlobalContext* globalCtx); -void func_809D3530(Boss01* this, GlobalContext* globalCtx); -void func_809D3ADC(Boss01* this, GlobalContext* globalCtx); -void func_809D3CD0(Boss01* this, GlobalContext* globalCtx); -void func_809D4464(Boss01* this, GlobalContext* globalCtx); -void func_809D6314(Boss01* this, GlobalContext* globalCtx); -void func_809D6488(Boss01* this, GlobalContext* globalCtx); -void func_809D6588(Boss01* this, GlobalContext* globalCtx); -void func_809D65E0(Boss01* this, GlobalContext* globalCtx); +void func_809D12B4(Boss01* this, PlayState* play); +void func_809D1B2C(Boss01* this, PlayState* play); +void func_809D1E74(Boss01* this, PlayState* play); +void func_809D20D0(Boss01* this, PlayState* play); +void func_809D25E8(Boss01* this, PlayState* play); +void func_809D26B8(Boss01* this, PlayState* play); +void func_809D27D4(Boss01* this, PlayState* play); +void func_809D2AA0(Boss01* this, PlayState* play); +void func_809D2BCC(Boss01* this, PlayState* play); +void func_809D2CDC(Boss01* this, PlayState* play); +void func_809D2E4C(Boss01* this, PlayState* play); +void func_809D30D0(Boss01* this, PlayState* play); +void func_809D345C(Boss01* this, PlayState* play); +void func_809D3530(Boss01* this, PlayState* play); +void func_809D3ADC(Boss01* this, PlayState* play); +void func_809D3CD0(Boss01* this, PlayState* play); +void func_809D4464(Boss01* this, PlayState* play); +void func_809D6314(Boss01* this, PlayState* play); +void func_809D6488(Boss01* this, PlayState* play); +void func_809D6588(Boss01* this, PlayState* play); +void func_809D65E0(Boss01* this, PlayState* play); #if 0 // static DamageTable sDamageTable = { @@ -129,7 +130,7 @@ static ColliderJntSphElementInit D_809D79D0[3] = { // static ColliderJntSphInit sJntSphInit = { static ColliderJntSphInit D_809D7A3C = { { COLTYPE_METAL, AT_ON | AT_TYPE_ENEMY, AC_ON | AC_HARD | AC_TYPE_PLAYER, OC1_ON | OC1_TYPE_PLAYER, OC2_TYPE_1, COLSHAPE_JNTSPH, }, - 3, D_809D79D0, // sJntSphElementsInit, + ARRAY_COUNT(sJntSphElementsInit), D_809D79D0, // sJntSphElementsInit, }; // static ColliderJntSphElementInit sJntSphElementsInit[1] = { @@ -143,7 +144,7 @@ static ColliderJntSphElementInit D_809D7A4C[1] = { // static ColliderJntSphInit sJntSphInit = { static ColliderJntSphInit D_809D7A70 = { { COLTYPE_METAL, AT_ON | AT_TYPE_ENEMY, AC_ON | AC_HARD | AC_TYPE_PLAYER, OC1_ON | OC1_TYPE_PLAYER, OC2_TYPE_1, COLSHAPE_JNTSPH, }, - 1, D_809D7A4C, // sJntSphElementsInit, + ARRAY_COUNT(sJntSphElementsInit), D_809D7A4C, // sJntSphElementsInit, }; // static ColliderJntSphElementInit sJntSphElementsInit[11] = { @@ -197,7 +198,7 @@ static ColliderJntSphElementInit D_809D7A80[11] = { // static ColliderJntSphInit sJntSphInit = { static ColliderJntSphInit D_809D7C0C = { { COLTYPE_HIT3, AT_ON | AT_TYPE_ENEMY, AC_ON | AC_TYPE_PLAYER, OC1_ON | OC1_TYPE_PLAYER, OC2_TYPE_1, COLSHAPE_JNTSPH, }, - 11, D_809D7A80, // sJntSphElementsInit, + ARRAY_COUNT(sJntSphElementsInit), D_809D7A80, // sJntSphElementsInit, }; // static ColliderJntSphElementInit sJntSphElementsInit[2] = { @@ -215,7 +216,7 @@ static ColliderJntSphElementInit D_809D7C1C[2] = { // static ColliderJntSphInit sJntSphInit = { static ColliderJntSphInit D_809D7C64 = { { COLTYPE_HIT3, AT_ON | AT_TYPE_ENEMY, AC_ON | AC_TYPE_PLAYER, OC1_ON | OC1_TYPE_PLAYER, OC2_TYPE_1, COLSHAPE_JNTSPH, }, - 2, D_809D7C1C, // sJntSphElementsInit, + ARRAY_COUNT(sJntSphElementsInit), D_809D7C1C, // sJntSphElementsInit, }; // static ColliderCylinderInit sCylinderInit = { diff --git a/src/overlays/actors/ovl_Boss_01/z_boss_01.h b/src/overlays/actors/ovl_Boss_01/z_boss_01.h index 2d2b0e59b..3d874a01f 100644 --- a/src/overlays/actors/ovl_Boss_01/z_boss_01.h +++ b/src/overlays/actors/ovl_Boss_01/z_boss_01.h @@ -5,13 +5,13 @@ struct Boss01; -typedef void (*Boss01ActionFunc)(struct Boss01*, GlobalContext*); +typedef void (*Boss01ActionFunc)(struct Boss01*, PlayState*); typedef struct Boss01 { - /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x320]; - /* 0x0464 */ Boss01ActionFunc actionFunc; - /* 0x0468 */ char unk_468[0x674]; + /* 0x000 */ Actor actor; + /* 0x144 */ char unk_144[0x320]; + /* 0x464 */ Boss01ActionFunc actionFunc; + /* 0x468 */ char unk_468[0x674]; } Boss01; // size = 0xADC extern const ActorInit Boss_01_InitVars; diff --git a/src/overlays/actors/ovl_Boss_02/z_boss_02.c b/src/overlays/actors/ovl_Boss_02/z_boss_02.c index 888a0587a..3ed675c5f 100644 --- a/src/overlays/actors/ovl_Boss_02/z_boss_02.c +++ b/src/overlays/actors/ovl_Boss_02/z_boss_02.c @@ -5,44 +5,43 @@ */ #include "z_boss_02.h" +#include "z64rumble.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 (ACTOR_FLAG_1 | ACTOR_FLAG_4 | ACTOR_FLAG_10 | ACTOR_FLAG_20) #define THIS ((Boss02*)thisx) -void Boss02_Init(Actor* thisx, GlobalContext* globalCtx); -void Boss02_Destroy(Actor* thisx, GlobalContext* globalCtx); -void Boss02_Update(Actor* thisx, GlobalContext* globalCtx); -void Boss02_Draw(Actor* thisx, GlobalContext* globalCtx); +void Boss02_Init(Actor* thisx, PlayState* play); +void Boss02_Destroy(Actor* thisx, PlayState* play); +void Boss02_Twinmold_Update(Actor* thisx, PlayState* play); +void Boss02_Twinmold_Draw(Actor* thisx, PlayState* play); -void func_809DAA74(Boss02* this, GlobalContext* globalCtx); -void func_809DAA98(Boss02* this, GlobalContext* globalCtx); -void func_809DAAA8(Boss02* this, GlobalContext* globalCtx); -void func_809DAB78(Boss02* this, GlobalContext* globalCtx); -void func_809DC218(Actor* thisx, GlobalContext* globalCtx); -void func_809DC78C(Actor* thisx, GlobalContext* globalCtx); -void func_809DD0A8(Actor* thisx, GlobalContext* globalCtx); -void func_809DD0CC(GlobalContext* globalCtx); -void func_809DD2F8(GlobalContext* globalCtx); -void func_809DD934(Boss02* this, GlobalContext* globalCtx); -void func_809DEAC4(Boss02* this, GlobalContext* globalCtx); +void func_809DAA74(Boss02* this, PlayState* play); +void func_809DAA98(Boss02* this, PlayState* play); +void func_809DAAA8(Boss02* this, PlayState* play); +void func_809DAB78(Boss02* this, PlayState* play); +void Boss02_Tail_Update(Actor* thisx, PlayState* play); +void Boss02_Static_Update(Actor* thisx, PlayState* play); +void Boss02_Static_Draw(Actor* thisx, PlayState* play); +void Boss02_UpdateEffects(PlayState* play); +void Boss02_DrawEffects(PlayState* play); +void func_809DD934(Boss02* this, PlayState* play); +void func_809DEAC4(Boss02* this, PlayState* play); -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 sIsInGiantMode; +Boss02* sRedTwinmold; +Boss02* sBlueTwinmold; +Boss02* sTwinmoldStatic; +u8 sMusicStartTimer; +DoorWarp1* sBlueWarp; +TwinmoldEffect sEffects[150]; -static DamageTable sDamageTable1 = { +static DamageTable sBlueTwinmoldDamageTable = { /* Deku Nut */ DMG_ENTRY(0, 0x0), /* Deku Stick */ DMG_ENTRY(1, 0xF), /* Horse trample */ DMG_ENTRY(0, 0x0), @@ -77,7 +76,7 @@ static DamageTable sDamageTable1 = { /* Powder Keg */ DMG_ENTRY(1, 0xF), }; -static DamageTable sDamageTable2 = { +static DamageTable sRedTwinmoldDamageTable = { /* Deku Nut */ DMG_ENTRY(0, 0x0), /* Deku Stick */ DMG_ENTRY(1, 0xF), /* Horse trample */ DMG_ENTRY(0, 0x0), @@ -120,21 +119,21 @@ const ActorInit Boss_02_InitVars = { sizeof(Boss02), (ActorFunc)Boss02_Init, (ActorFunc)Boss02_Destroy, - (ActorFunc)Boss02_Update, - (ActorFunc)Boss02_Draw, + (ActorFunc)Boss02_Twinmold_Update, + (ActorFunc)Boss02_Twinmold_Draw, }; -static f32 D_809DF5B0 = 1.0f; +f32 D_809DF5B0 = 1.0f; -static s16 D_809DF5B4[] = { +s16 D_809DF5B4[] = { 0, 195, 190, 185, 180, 175, 170, 165, 160, 155, 150, 145, 140, 135, 130, 125, 120, 115, 110, 105, 100, 95, 90, 0, }; -static s16 D_809DF5E4[] = { +s16 D_809DF5E4[] = { 0, 196, 192, 188, 184, 180, 176, 172, 168, 164, 160, 156, 152, 148, 144, 140, 136, 132, 128, 124, 120, 116, 112, }; -static ColliderJntSphElementInit sJntSphElementsInit1[22] = { +static ColliderJntSphElementInit sJntSphElementsInit1[] = { { { ELEMTYPE_UNK3, @@ -388,11 +387,11 @@ static ColliderJntSphInit sJntSphInit1 = { OC2_TYPE_1, COLSHAPE_JNTSPH, }, - 22, + ARRAY_COUNT(sJntSphElementsInit1), sJntSphElementsInit1, }; -static ColliderJntSphElementInit sJntSphElementsInit2[2] = { +static ColliderJntSphElementInit sJntSphElementsInit2[] = { { { ELEMTYPE_UNK3, @@ -426,7 +425,7 @@ static ColliderJntSphInit sJntSphInit2 = { OC2_TYPE_1, COLSHAPE_JNTSPH, }, - 2, + ARRAY_COUNT(sJntSphElementsInit2), sJntSphElementsInit2, }; @@ -450,19 +449,19 @@ static ColliderCylinderInit sCylinderInit = { { 150, 200, 0, { 0, 0, 0 } }, }; -static Vec3f D_809DF9C0[] = { +Vec3f D_809DF9C0[] = { { 0.0f, -200.0f, 1000.0f }, { 0.0f, 500.0f, 1000.0f }, { 0.0f, 1000.0f, 1000.0f }, { 1000.0f, 500.0f, 1000.0f }, { 1000.0f, 1000.0f, -1000.0f }, { -1000.0f, 500.0f, -1000.0f }, { -1000.0f, 500.0f, 1000.0f }, { -1000.0f, -1000.0f, -1000.0f }, { -1000.0f, -1000.0f, -1000.0f }, }; -static Vec3f D_809DFA2C[] = { +Vec3f D_809DFA2C[] = { { 0.0f, -200.0f, -800.0f }, { 0.0f, 800.0f, -800.0f }, { 800.0f, 300.0f, -800.0f }, { -800.0f, 800.0f, 0.0f }, { -800.0f, -1000.0f, 0.0f }, { -800.0f, -1000.0f, 0.0f }, { -800.0f, -1000.0f, 0.0f }, { -800.0f, -1000.0f, 0.0f }, { -800.0f, -1000.0f, 0.0f }, }; -void func_809DA1D0(GlobalContext* globalCtx, u8 arg1, u8 arg2, u8 arg3, u8 arg4) { +void func_809DA1D0(PlayState* play, u8 arg1, u8 arg2, u8 arg3, u8 arg4) { MREG(64) = 1; MREG(65) = arg1; MREG(66) = arg2; @@ -470,68 +469,68 @@ void func_809DA1D0(GlobalContext* globalCtx, u8 arg1, u8 arg2, u8 arg3, u8 arg4) MREG(68) = arg4; } -void func_809DA22C(GlobalContext* globalCtx, u8 arg1) { +void func_809DA22C(PlayState* play, u8 arg1) { MREG(68) = arg1; } -void func_809DA24C(GlobalContext* globalCtx) { +void func_809DA24C(PlayState* play) { MREG(64) = 0; } -void func_809DA264(Boss02Effects* effects, Vec3f* vec, f32 arg2) { +void Boss02_SpawnEffectSand(TwinmoldEffect* effects, Vec3f* pos, f32 scale) { s16 i; - for (i = 0; i < ARRAY_COUNT(D_809E0438); i++, effects++) { - if (effects->unk_24 == 0) { - effects->unk_24 = 1; - effects->unk_00 = *vec; - effects->unk_0C.x = randPlusMinusPoint5Scaled(30.0f); - effects->unk_0C.y = Rand_ZeroFloat(7.0f) + 7.0f; - effects->unk_0C.z = randPlusMinusPoint5Scaled(30.0f); - effects->unk_18.y = -0.3f; - effects->unk_34 = arg2; - effects->unk_2C = 255; - effects->unk_26 = 0; - effects->unk_38 = 2.0f * arg2; - effects->unk_18.x = effects->unk_18.z = 0.0f; + for (i = 0; i < ARRAY_COUNT(sEffects); i++, effects++) { + if (effects->type == TWINMOLD_EFFECT_NONE) { + effects->type = TWINMOLD_EFFECT_SAND; + effects->pos = *pos; + effects->velocity.x = randPlusMinusPoint5Scaled(30.0f); + effects->velocity.y = Rand_ZeroFloat(7.0f) + 7.0f; + effects->velocity.z = randPlusMinusPoint5Scaled(30.0f); + effects->accel.y = -0.3f; + effects->scale = scale; + effects->alpha = 255; + effects->timer = 0; + effects->targetScale = 2.0f * scale; + effects->accel.x = effects->accel.z = 0.0f; break; } } } -void func_809DA344(Boss02Effects* effects, Vec3f* vec) { +void Boss02_SpawnEffectFragment(TwinmoldEffect* effects, Vec3f* pos) { s16 i; - for (i = 0; i < ARRAY_COUNT(D_809E0438); i++, effects++) { - if (effects->unk_24 == 0) { - effects->unk_24 = 3; - effects->unk_00 = *vec; - effects->unk_26 = Rand_ZeroFloat(20.0f); - effects->unk_0C.x = randPlusMinusPoint5Scaled(50.0f); - effects->unk_0C.y = randPlusMinusPoint5Scaled(50.0f); - effects->unk_0C.z = randPlusMinusPoint5Scaled(50.0f); - effects->unk_18.z = 0.0f; - effects->unk_18.x = 0.0f; - effects->unk_18.y = -1.5f; - effects->unk_34 = Rand_ZeroFloat(0.04f) + 0.02f; - effects->unk_30 = Rand_ZeroFloat(32767.0f); - effects->unk_2E = Rand_ZeroFloat(32767.0f); + for (i = 0; i < ARRAY_COUNT(sEffects); i++, effects++) { + if (effects->type == TWINMOLD_EFFECT_NONE) { + effects->type = TWINMOLD_EFFECT_FRAGMENT; + effects->pos = *pos; + effects->timer = Rand_ZeroFloat(20.0f); + effects->velocity.x = randPlusMinusPoint5Scaled(50.0f); + effects->velocity.y = randPlusMinusPoint5Scaled(50.0f); + effects->velocity.z = randPlusMinusPoint5Scaled(50.0f); + effects->accel.z = 0.0f; + effects->accel.x = 0.0f; + effects->accel.y = -1.5f; + effects->scale = Rand_ZeroFloat(0.04f) + 0.02f; + effects->rotY = Rand_ZeroFloat(32767.0f); + effects->rotX = Rand_ZeroFloat(32767.0f); break; } } } -void func_809DA460(Boss02Effects* effects, Vec3f* vec) { +void Boss02_SpawnEffectFlash(TwinmoldEffect* effects, Vec3f* pos) { s16 i; - for (i = 0; i < ARRAY_COUNT(D_809E0438); i++, effects++) { - if ((effects->unk_24 == 0) || (effects->unk_24 == 3)) { - effects->unk_24 = 4; - effects->unk_00 = *vec; - Math_Vec3f_Copy(&effects->unk_0C, &gZeroVec3f); - Math_Vec3f_Copy(&effects->unk_18, &gZeroVec3f); - effects->unk_2C = 0xFF; - effects->unk_34 = 0.0f; + for (i = 0; i < ARRAY_COUNT(sEffects); i++, effects++) { + if ((effects->type == TWINMOLD_EFFECT_NONE) || (effects->type == TWINMOLD_EFFECT_FRAGMENT)) { + effects->type = TWINMOLD_EFFECT_FLASH; + effects->pos = *pos; + Math_Vec3f_Copy(&effects->velocity, &gZeroVec3f); + Math_Vec3f_Copy(&effects->accel, &gZeroVec3f); + effects->alpha = 255; + effects->scale = 0.0f; break; } } @@ -545,70 +544,70 @@ void func_809DA50C(s32 arg0, ColliderJntSph* collider, Vec3f* arg2) { collider->elements[arg0].dim.modelSphere.radius * collider->elements[arg0].dim.scale * D_809DF5B0; } -void Boss02_Init(Actor* thisx, GlobalContext* globalCtx) { +void Boss02_Init(Actor* thisx, PlayState* play) { Boss02* this = THIS; s32 i; s32 pad[2]; - 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); + if ((gSaveContext.save.weekEventReg[52] & 0x20) && (this->actor.params == TWINMOLD_RED)) { + sBlueWarp = (DoorWarp1*)Actor_SpawnAsChild(&play->actorCtx, &this->actor, play, ACTOR_DOOR_WARP1, 0.0f, 60.0f, + 0.0f, 0, 0, 0, 1); + Actor_Spawn(&play->actorCtx, play, ACTOR_ITEM_B_HEART, 0.0f, 30.0f, -150.0f, 0, 1, 0, 0); } this->actor.targetMode = 10; - this->unk_1D3C.z = this->unk_1D3C.x = 0.0f; - this->unk_1D3C.y = 1.0f; - if (this->actor.params == 200) { - D_809E042C = this; - globalCtx->specialEffects = (void*)D_809E0438; - this->actor.update = func_809DC78C; - this->actor.draw = func_809DD0A8; + this->subCamUp.z = this->subCamUp.x = 0.0f; + this->subCamUp.y = 1.0f; + if (this->actor.params == TWINMOLD_STATIC) { + sTwinmoldStatic = this; + play->specialEffects = (void*)sEffects; + this->actor.update = Boss02_Static_Update; + this->actor.draw = Boss02_Static_Draw; this->actor.flags &= ~ACTOR_FLAG_1; this->unk_1D70 = 0.00999999977648f; - if ((KREG(64) != 0) || (gSaveContext.eventInf[5] & 0x20) || (D_809E0434 != NULL)) { + if ((KREG(64) != 0) || (gSaveContext.eventInf[5] & 0x20) || (sBlueWarp != NULL)) { this->unk_1D20 = 0; - D_809E0430 = KREG(15) + 20; + sMusicStartTimer = KREG(15) + 20; } else { this->unk_1D20 = 1; } XREG(41) = KREG(14) + 20; this->unk_01AC = 1.0f; - Actor_SpawnAsChild(&globalCtx->actorCtx, &this->actor, globalCtx, ACTOR_EN_TANRON5, 0.0f, 1000.0f, 0.0f, 0, 0, - 0, 0); - } else if (this->actor.params == 100) { - this->actor.update = func_809DC218; + Actor_SpawnAsChild(&play->actorCtx, &this->actor, play, ACTOR_EN_TANRON5, 0.0f, 1000.0f, 0.0f, 0, 0, 0, 0); + } else if (this->actor.params == TWINMOLD_TAIL) { + this->actor.update = Boss02_Tail_Update; this->actor.draw = NULL; this->actor.hintId = 0x2E; } else { - if (this->actor.params != 35) { - this->actor.params = 0; - Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_BOSS_02, 0.0f, 0.0f, 0.0f, 0, 0, 0, 200); - D_809E0424 = this; - D_809E0428 = (Boss02*)Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_BOSS_02, this->actor.world.pos.x, - this->actor.world.pos.y, this->actor.world.pos.z, this->actor.world.rot.x, - this->actor.world.rot.y, this->actor.world.rot.z, 35); - D_809E0424->actor.colChkInfo.damageTable = &sDamageTable2; - D_809E0428->actor.colChkInfo.damageTable = &sDamageTable1; - D_809E0424->unk_1674 = D_809E0428; - D_809E0428->unk_1674 = D_809E0424; + if (this->actor.params != TWINMOLD_BLUE) { + this->actor.params = TWINMOLD_RED; + Actor_Spawn(&play->actorCtx, play, ACTOR_BOSS_02, 0.0f, 0.0f, 0.0f, 0, 0, 0, TWINMOLD_STATIC); + sRedTwinmold = this; + sBlueTwinmold = + (Boss02*)Actor_Spawn(&play->actorCtx, play, ACTOR_BOSS_02, this->actor.world.pos.x, + this->actor.world.pos.y, this->actor.world.pos.z, this->actor.world.rot.x, + this->actor.world.rot.y, this->actor.world.rot.z, TWINMOLD_BLUE); + sRedTwinmold->actor.colChkInfo.damageTable = &sRedTwinmoldDamageTable; + sBlueTwinmold->actor.colChkInfo.damageTable = &sBlueTwinmoldDamageTable; + sRedTwinmold->otherTwinmold = sBlueTwinmold; + sBlueTwinmold->otherTwinmold = sRedTwinmold; } this->actor.colChkInfo.mass = MASS_HEAVY; 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); - Collider_InitAndSetJntSph(globalCtx, &this->colliderSphere1, &this->actor, &sJntSphInit1, + SkelAnime_Init(play, &this->skelAnime, &gTwinmoldHeadSkel, &gTwinmoldHeadFlyAnim, this->jointTable, + this->morphTable, TWINMOLD_HEAD_LIMB_MAX); + Collider_InitAndSetJntSph(play, &this->colliderSphere1, &this->actor, &sJntSphInit1, this->colliderSphere1Elements); - Collider_InitAndSetJntSph(globalCtx, &this->colliderSphere2, &this->actor, &sJntSphInit2, + Collider_InitAndSetJntSph(play, &this->colliderSphere2, &this->actor, &sJntSphInit2, this->colliderSphere2Elements); - Collider_InitAndSetCylinder(globalCtx, &this->colliderCylinder, &this->actor, &sCylinderInit); + Collider_InitAndSetCylinder(play, &this->colliderCylinder, &this->actor, &sCylinderInit); - if (D_809E0434 != NULL) { - func_809DAA74(this, globalCtx); + if (sBlueWarp != NULL) { + func_809DAA74(this, play); } else { - func_809DAAA8(this, globalCtx); + func_809DAAA8(this, play); } for (i = 0; i < ARRAY_COUNT(this->unk_01BC); i++) { @@ -619,33 +618,33 @@ void Boss02_Init(Actor* thisx, GlobalContext* globalCtx) { this->unk_014C = Rand_ZeroFloat(1000.0f); this->unk_1678 = 22; - Actor_SpawnAsChild(&globalCtx->actorCtx, &this->actor, globalCtx, ACTOR_BOSS_02, 0.0f, 0.0f, 0.0f, 0, 0, 0, - 100); + Actor_SpawnAsChild(&play->actorCtx, &this->actor, play, ACTOR_BOSS_02, 0.0f, 0.0f, 0.0f, 0, 0, 0, + TWINMOLD_TAIL); } } -void Boss02_Destroy(Actor* thisx, GlobalContext* globalCtx) { +void Boss02_Destroy(Actor* thisx, PlayState* play) { } -void func_809DAA74(Boss02* this, GlobalContext* globalCtx) { +void func_809DAA74(Boss02* this, PlayState* play) { this->actionFunc = func_809DAA98; this->actor.world.pos.y = -3000.0f; } -void func_809DAA98(Boss02* this, GlobalContext* globalCtx) { +void func_809DAA98(Boss02* this, PlayState* play) { } -void func_809DAAA8(Boss02* this, GlobalContext* globalCtx) { +void func_809DAAA8(Boss02* this, PlayState* play) { this->actionFunc = func_809DAB78; - Animation_MorphToLoop(&this->skelAnime, &object_boss02_Anim_009C78, 0.0f); - if (D_809E042C->unk_1D20 != 0) { + Animation_MorphToLoop(&this->skelAnime, &gTwinmoldHeadFlyAnim, 0.0f); + if (sTwinmoldStatic->unk_1D20 != 0) { this->unk_0144 = 10; } else { this->unk_0144 = 100; this->unk_01A8 = 25.0f; - D_809E042C->unk_1D7E = 100; + sTwinmoldStatic->unk_1D7E = 100; this->actor.world.pos.x = 0.0f; - if (D_809E0424 == this) { + if (sRedTwinmold == this) { this->actor.world.pos.z = -1000.0f; } else { this->actor.world.pos.z = 1400.0f; @@ -654,10 +653,11 @@ void func_809DAAA8(Boss02* this, GlobalContext* globalCtx) { this->actor.world.pos.y = -500.0f; } -void func_809DAB78(Boss02* this, GlobalContext* globalCtx) { - static Color_RGBA8 D_809DFA98 = { 185, 140, 70, 255 }; +Color_RGBA8 D_809DFA98 = { 185, 140, 70, 255 }; + +void func_809DAB78(Boss02* this, PlayState* play) { s32 pad; - Player* player = GET_PLAYER(globalCtx); + Player* player = GET_PLAYER(play); CollisionPoly* spDC; Vec3f spD0; f32 spCC; @@ -668,7 +668,7 @@ void func_809DAB78(Boss02* this, GlobalContext* globalCtx) { f32 phi_f2; s16 temp_s0; s16 temp_s2; - Boss02* spB0 = this->unk_1674; + Boss02* otherTwinmold = this->otherTwinmold; Vec3f spA4; f32 spA0; f32 sp9C; @@ -695,7 +695,7 @@ void func_809DAB78(Boss02* this, GlobalContext* globalCtx) { this->unk_01A4 = Math_SinS(this->unk_0196) * this->unk_019C; this->actor.world.rot.x = this->actor.shape.rot.x + this->unk_01A4; - if (!(this->unk_014C & 0x1F) && (D_809E042C->unk_1D20 == 0)) { + if (!(this->unk_014C & 0x1F) && (sTwinmoldStatic->unk_1D20 == 0)) { this->unk_01A0 = Rand_ZeroFloat(0x1000) + 0x800; this->unk_019A = Rand_ZeroFloat(0x400) + 0x200; } @@ -718,13 +718,13 @@ void func_809DAB78(Boss02* this, GlobalContext* globalCtx) { Actor_UpdatePos(&this->actor); spD0 = this->actor.world.pos; - if (D_809E0422 != 0) { + if (sIsInGiantMode) { spD0.y = 5000.0f; } else { spD0.y = 2000.0f; } - temp_f0 = BgCheck_EntityRaycastFloor1(&globalCtx->colCtx, &spDC, &spD0); + temp_f0 = BgCheck_EntityRaycastFloor1(&play->colCtx, &spDC, &spD0); if (((this->unk_017C.y < temp_f0) && (temp_f0 <= this->unk_0188.y)) || ((temp_f0 < this->unk_017C.y) && (this->unk_0188.y <= temp_f0))) { this->unk_0170 = this->unk_017C; @@ -754,9 +754,9 @@ void func_809DAB78(Boss02* this, GlobalContext* globalCtx) { this->unk_0B1C[this->unk_014E].z = BINANG_TO_RAD(this->actor.world.rot.z); } - if ((this->unk_0144 < 10) && (spB0->unk_0144 >= 20)) { + if ((this->unk_0144 < 10) && (otherTwinmold->unk_0144 >= 20)) { this->unk_01B0.y = -1000.0f * D_809DF5B0; - if (D_809E0422 != 0) { + if (sIsInGiantMode) { this->unk_01B0.y += 3150.0f; } this->unk_0144 = 3; @@ -776,7 +776,7 @@ void func_809DAB78(Boss02* this, GlobalContext* globalCtx) { this->actor.world.pos.x = randPlusMinusPoint5Scaled(5000.0f * D_809DF5B0); this->actor.world.pos.z = randPlusMinusPoint5Scaled(5000.0f * D_809DF5B0); this->actor.world.pos.y = -500.0f * D_809DF5B0; - if (D_809E0422 != 0) { + if (sIsInGiantMode) { this->actor.world.pos.y += 3150.0f; } } @@ -809,7 +809,7 @@ void func_809DAB78(Boss02* this, GlobalContext* globalCtx) { this->unk_01B0.z = 500.0f; } this->unk_01B0.y = Rand_ZeroFloat(800.0f * D_809DF5B0) + (200.0f * D_809DF5B0); - if (D_809E0422 != 0) { + if (sIsInGiantMode) { this->unk_01B0.y += 3150.0f; } } @@ -826,7 +826,7 @@ void func_809DAB78(Boss02* this, GlobalContext* globalCtx) { if (sqrtf(SQ(spCC) + SQ(spC8) + SQ(spC4)) < (phi_f2 * D_809DF5B0)) { this->unk_0144 = 3; this->unk_01B0.y = -3000.0f * D_809DF5B0; - if (D_809E0422 != 0) { + if (sIsInGiantMode) { this->unk_01B0.y += 3150.0f; } this->unk_0146[0] = 150; @@ -848,7 +848,7 @@ void func_809DAB78(Boss02* this, GlobalContext* globalCtx) { this->unk_0144 = 3; this->unk_01B0.x = randPlusMinusPoint5Scaled(500.0f * D_809DF5B0) + this->actor.world.pos.x; this->unk_01B0.y = -3000.0f * D_809DF5B0; - if (D_809E0422 != 0) { + if (sIsInGiantMode) { this->unk_01B0.y += 3150.0f; } this->unk_01B0.z = randPlusMinusPoint5Scaled(500.0f * D_809DF5B0) + this->actor.world.pos.z; @@ -866,13 +866,13 @@ void func_809DAB78(Boss02* this, GlobalContext* globalCtx) { this->colliderCylinder.dim.height = 200.0f * D_809DF5B0; this->colliderCylinder.dim.yShift = 0; Collider_UpdateCylinder(&this->actor, &this->colliderCylinder); - CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->colliderCylinder.base); - CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->colliderCylinder.base); + CollisionCheck_SetOC(play, &play->colChkCtx, &this->colliderCylinder.base); + CollisionCheck_SetAC(play, &play->colChkCtx, &this->colliderCylinder.base); } return; case 11: - if (this == D_809E0424) { + if (this == sRedTwinmold) { this->unk_01B0.x = D_809DF9C0[this->unk_1D1A].x; this->unk_01B0.y = D_809DF9C0[this->unk_1D1A].y; this->unk_01B0.z = D_809DF9C0[this->unk_1D1A].z; @@ -896,7 +896,7 @@ void func_809DAB78(Boss02* this, GlobalContext* globalCtx) { if (this->unk_1D1A > 8) { this->unk_1D1A = 8; } - if (this == D_809E0424) { + if (this == sRedTwinmold) { this->unk_01B0.x = D_809DF9C0[this->unk_1D1A].x; this->unk_01B0.y = D_809DF9C0[this->unk_1D1A].y; this->unk_01B0.z = D_809DF9C0[this->unk_1D1A].z; @@ -912,12 +912,12 @@ 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); - if (D_809E0422 != 0) { + if (sIsInGiantMode) { this->unk_01B0.y += 3150.0f; } this->unk_01B0.z = player->actor.world.pos.z + spA4.z; @@ -935,8 +935,8 @@ void func_809DAB78(Boss02* this, GlobalContext* globalCtx) { this->unk_0144 = 21; this->unk_0146[0] = 20; this->unk_0152 = 0; - D_809E042C->unk_1D20 = 102; - D_809E042C->unk_1D5C = 0.0f; + sTwinmoldStatic->unk_1D20 = 102; + sTwinmoldStatic->subCamAtVel = 0.0f; play_sound(NA_SE_EN_INBOSS_DEAD_PRE2_OLD); } else if (!(this->unk_0146[1] & 0xF) && (Rand_ZeroOne() < 0.5f)) { Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_INBOSS_DAMAGE_OLD); @@ -950,10 +950,10 @@ void func_809DAB78(Boss02* this, GlobalContext* globalCtx) { this->unk_0146[0] = 3; for (i = 0; i < 35; i++) { - func_809DA344(globalCtx->specialEffects, &this->unk_147C[this->unk_1678]); + Boss02_SpawnEffectFragment(play->specialEffects, &this->unk_147C[this->unk_1678]); } - func_809DA460(globalCtx->specialEffects, &this->unk_147C[this->unk_1678]); + Boss02_SpawnEffectFlash(play->specialEffects, &this->unk_147C[this->unk_1678]); play_sound(NA_SE_EV_EXPLOSION); this->unk_1678--; @@ -976,7 +976,7 @@ void func_809DAB78(Boss02* this, GlobalContext* globalCtx) { this->actor.speedXZ = 15.0f * D_809DF5B0; } - if (spB0->unk_0144 >= 10) { + if (otherTwinmold->unk_0144 >= 10) { Audio_QueueSeqCmd(NA_BGM_CLEAR_BOSS | 0x8000); } @@ -992,7 +992,7 @@ void func_809DAB78(Boss02* this, GlobalContext* globalCtx) { this->unk_0B1C[i].y += this->unk_0164; Math_ApproachF(&this->unk_0B1C[i].x, -(M_PI / 2), 0.1f, 0.07f); Actor_MoveWithGravity(&this->actor); - Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 50.0f, 150.0f, 100.0f, 4); + Actor_UpdateBgCheckInfo(play, &this->actor, 50.0f, 150.0f, 100.0f, 4); if (this->actor.bgCheckFlags & 1) { this->unk_0144 = 23; @@ -1000,14 +1000,14 @@ void func_809DAB78(Boss02* this, GlobalContext* globalCtx) { this->unk_0170 = this->unk_017C; this->unk_016C = 30; this->unk_0170.y = this->actor.floorHeight; - D_809E042C->unk_1D20 = 103; - D_809E042C->unk_1D1C = 0; - D_809E042C->unk_0146[0] = 15; - D_809E042C->unk_0150 = 0; + sTwinmoldStatic->unk_1D20 = 103; + sTwinmoldStatic->unk_1D1C = 0; + sTwinmoldStatic->unk_0146[0] = 15; + sTwinmoldStatic->unk_0150 = 0; play_sound(NA_SE_EV_LIGHTNING); for (i = 0; i < 30; i++) { - func_809DA344(globalCtx->specialEffects, &this->unk_0170); + Boss02_SpawnEffectFragment(play->specialEffects, &this->unk_0170); } this->unk_0146[0] = 10; @@ -1023,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); + if (BgCheck_EntityRaycastFloor3(&play->colCtx, &sp8C, &sp88, &spD0) != BGCHECK_Y_MIN) { + spA0 = BgCheck_EntityRaycastFloor1(&play->colCtx, &sp8C, &spD0); + Matrix_MultVecZ(5.0f * D_809DF5B0, &sp70); sp70.y = 2.0f * D_809DF5B0; sp64.y = 0.3f * D_809DF5B0; sp64.z = 0.0f; @@ -1039,7 +1038,7 @@ void func_809DAB78(Boss02* this, GlobalContext* globalCtx) { sp7C.x = spD0.x; sp7C.y = spA0; sp7C.z = spD0.z; - func_800B0F18(globalCtx, &sp7C, &sp70, &sp64, &D_809DFA98, &D_809DFA98, + func_800B0F18(play, &sp7C, &sp70, &sp64, &D_809DFA98, &D_809DFA98, (Rand_ZeroFloat(500.0f) + 1200.0f) * D_809DF5B0, 20.0f * D_809DF5B0, Rand_ZeroFloat(5.0f) + 14.0f); } @@ -1051,17 +1050,17 @@ void func_809DAB78(Boss02* this, GlobalContext* globalCtx) { this->colliderCylinder.dim.height = 200.0f * D_809DF5B0; this->colliderCylinder.dim.yShift = 0; Collider_UpdateCylinder(&this->actor, &this->colliderCylinder); - CollisionCheck_SetAT(globalCtx, &globalCtx->colChkCtx, &this->colliderCylinder.base); + CollisionCheck_SetAT(play, &play->colChkCtx, &this->colliderCylinder.base); } -void func_809DBFB4(Boss02* this, GlobalContext* globalCtx) { - Boss02* temp_s6 = this->unk_1674; +void func_809DBFB4(Boss02* this, PlayState* play) { + Boss02* otherTwinmold = this->otherTwinmold; s32 temp; s32 i; u8 damage; if (this->unk_0154 == 0) { - if (D_809E0422 != 0) { + if (sIsInGiantMode) { temp = 0; } else { temp = 1; @@ -1081,7 +1080,7 @@ void func_809DBFB4(Boss02* this, GlobalContext* globalCtx) { this->unk_015C = 10; } - if (D_809E0422 != 0) { + if (sIsInGiantMode) { this->unk_0152 = 15; } else { this->unk_0152 = 12; @@ -1089,7 +1088,7 @@ void func_809DBFB4(Boss02* this, GlobalContext* globalCtx) { damage = this->actor.colChkInfo.damage; - if (temp_s6->unk_0144 < 20) { + if (otherTwinmold->unk_0144 < 20) { do { do { this->actor.colChkInfo.health -= damage; @@ -1099,21 +1098,21 @@ void func_809DBFB4(Boss02* this, GlobalContext* globalCtx) { if ((s8)this->actor.colChkInfo.health <= 0) { Actor_MarkForDeath(this->actor.child); this->actor.child = NULL; - Enemy_StartFinishingBlow(globalCtx, &this->actor); + Enemy_StartFinishingBlow(play, &this->actor); this->skelAnime.playSpeed = 2.0f; this->unk_0144 = 20; - if (temp_s6->unk_0144 >= 10) { + if (otherTwinmold->unk_0144 >= 10) { Audio_QueueSeqCmd(0x100100FF); } else { - temp_s6->unk_0195 = 1; + otherTwinmold->unk_0195 = 1; } this->unk_0146[1] = BREG(70) + 170; this->unk_0146[0] = 0; this->actor.shape.rot.x = 0x4000; - if (D_809E0422 == 0) { + if (!sIsInGiantMode) { if (this->actor.world.pos.y < -200.0f) { this->actor.world.pos.y = -200.0f; } @@ -1121,12 +1120,12 @@ void func_809DBFB4(Boss02* this, GlobalContext* globalCtx) { this->actor.world.pos.y = 3130.0f; } - D_809E042C->unk_1D20 = 100; + sTwinmoldStatic->unk_1D20 = 100; - if (this == D_809E0424) { - D_809E042C->unk_0194 = 0; + if (this == sRedTwinmold) { + sTwinmoldStatic->unk_0194 = 0; } else { - D_809E042C->unk_0194 = 1; + sTwinmoldStatic->unk_0194 = 1; } } } @@ -1135,24 +1134,23 @@ void func_809DBFB4(Boss02* this, GlobalContext* globalCtx) { } } -void func_809DC218(Actor* thisx, GlobalContext* globalCtx) { +void Boss02_Tail_Update(Actor* thisx, PlayState* play) { Boss02* this = THIS; s32 pad; - Vec3f sp24; - CollisionPoly* sp20; + Vec3f pos; + CollisionPoly* outPoly; this->unk_014C++; if ((this->unk_014C + this->actor.params) & 1) { - sp24 = this->actor.world.pos; + pos = this->actor.world.pos; this->actor.focus.pos = this->actor.world.pos; - if (D_809E0422 != 0) { - sp24.y = 5000.0f; + if (sIsInGiantMode) { + pos.y = 5000.0f; } else { - sp24.y = 2000.0f; + pos.y = 2000.0f; } - if ((this->actor.focus.pos.y < BgCheck_EntityRaycastFloor1(&globalCtx->colCtx, &sp20, &sp24)) || - (D_809E0422 != 0)) { + if ((this->actor.focus.pos.y < BgCheck_EntityRaycastFloor1(&play->colCtx, &outPoly, &pos)) || sIsInGiantMode) { this->actor.flags &= ~ACTOR_FLAG_1; } else { this->actor.flags |= ACTOR_FLAG_1; @@ -1160,19 +1158,19 @@ void func_809DC218(Actor* thisx, GlobalContext* globalCtx) { } } -void Boss02_Update(Actor* thisx, GlobalContext* globalCtx) { +void Boss02_Twinmold_Update(Actor* thisx, PlayState* play) { Vec3f sp3C; Boss02* this = THIS; s32 pad; s16 i; - if (D_809E0422 == 0) { + if (!sIsInGiantMode) { Actor_SetScale(&this->actor, 0.6f); } else { Actor_SetScale(&this->actor, 0.060000001f); } - if (D_809E042C->unk_1D18 == 0) { + if (sTwinmoldStatic->unk_1D18 == 0) { for (i = 0; i < ARRAY_COUNT(this->unk_0146); i++) { if (this->unk_0146[i] != 0) { this->unk_0146[i]--; @@ -1197,7 +1195,7 @@ void Boss02_Update(Actor* thisx, GlobalContext* globalCtx) { this->unk_014C++; - this->actionFunc(this, globalCtx); + this->actionFunc(this, play); if (this->unk_016C != 0) { if ((this->unk_016C == 60) && (this->unk_0144 < 20)) { @@ -1209,25 +1207,25 @@ void Boss02_Update(Actor* thisx, GlobalContext* globalCtx) { sp3C.x = randPlusMinusPoint5Scaled(100.0f * D_809DF5B0) + this->unk_0170.x; sp3C.y = randPlusMinusPoint5Scaled(50.0f * D_809DF5B0) + this->unk_0170.y; sp3C.z = randPlusMinusPoint5Scaled(100.0f * D_809DF5B0) + this->unk_0170.z; - func_809DA264(globalCtx->specialEffects, &sp3C, Rand_ZeroFloat(3.0f) + 6.0f); + Boss02_SpawnEffectSand(play->specialEffects, &sp3C, Rand_ZeroFloat(3.0f) + 6.0f); } if ((this->unk_014C % 2) == 0) { sp3C.x = randPlusMinusPoint5Scaled(100.0f * D_809DF5B0) + this->unk_0170.x; sp3C.y = randPlusMinusPoint5Scaled(50.0f * D_809DF5B0) + this->unk_0170.y; sp3C.z = randPlusMinusPoint5Scaled(100.0f * D_809DF5B0) + this->unk_0170.z; - func_809DA264(globalCtx->specialEffects, &sp3C, Rand_ZeroFloat(3.0f) + 6.0f); + Boss02_SpawnEffectSand(play->specialEffects, &sp3C, Rand_ZeroFloat(3.0f) + 6.0f); } } if ((this->unk_0144 < 20) && (this->unk_0144 != 10)) { - func_809DBFB4(this, globalCtx); - CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->colliderSphere1.base); - CollisionCheck_SetAT(globalCtx, &globalCtx->colChkCtx, &this->colliderSphere1.base); - CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->colliderSphere1.base); - CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->colliderSphere2.base); - CollisionCheck_SetAT(globalCtx, &globalCtx->colChkCtx, &this->colliderSphere2.base); - CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->colliderSphere2.base); + func_809DBFB4(this, play); + CollisionCheck_SetAC(play, &play->colChkCtx, &this->colliderSphere1.base); + CollisionCheck_SetAT(play, &play->colChkCtx, &this->colliderSphere1.base); + CollisionCheck_SetOC(play, &play->colChkCtx, &this->colliderSphere1.base); + CollisionCheck_SetAC(play, &play->colChkCtx, &this->colliderSphere2.base); + CollisionCheck_SetAT(play, &play->colChkCtx, &this->colliderSphere2.base); + CollisionCheck_SetOC(play, &play->colChkCtx, &this->colliderSphere2.base); } switch (this->unk_015C) { @@ -1278,27 +1276,27 @@ void Boss02_Update(Actor* thisx, GlobalContext* globalCtx) { } } -void func_809DC78C(Actor* thisx, GlobalContext* globalCtx) { +void Boss02_Static_Update(Actor* thisx, PlayState* play) { Boss02* this = THIS; this->unk_01AC = D_809DF5B0; - globalCtx->envCtx.sandstormState = 0xD; + play->envCtx.sandstormState = 0xD; - if (D_809E0434 != NULL) { + if (sBlueWarp != NULL) { this->unk_1D74 = KREG(23) + -15.0f; D_801F4E30 = 0; - globalCtx->envCtx.lightSettingOverride = 1; - globalCtx->skyboxId = 1; - } else if (D_809E0422 == 0) { + play->envCtx.lightSettingOverride = 1; + play->skyboxId = 1; + } else if (!sIsInGiantMode) { this->unk_1D74 = 0.0f; D_801F4E30 = this->unk_1D7C; - globalCtx->envCtx.lightSettingOverride = 0; - globalCtx->skyboxId = 2; + play->envCtx.lightSettingOverride = 0; + play->skyboxId = 2; } else { this->unk_1D74 = KREG(23) + -15.0f; D_801F4E30 = ((KREG(24) * 0.1f) + 1.0f) * this->unk_1D7C; - globalCtx->envCtx.lightSettingOverride = 1; - globalCtx->skyboxId = 1; + play->envCtx.lightSettingOverride = 1; + play->skyboxId = 1; } Math_ApproachS(&this->unk_1D7C, this->unk_1D7E, 1, 3); @@ -1307,31 +1305,33 @@ void func_809DC78C(Actor* thisx, GlobalContext* globalCtx) { this->unk_0146[0]--; } - if (D_809E0434 == NULL) { - if (D_809E0430 != 0) { - D_809E0430--; - if (D_809E0430 == 0) { + if (sBlueWarp == NULL) { + if (sMusicStartTimer != 0) { + sMusicStartTimer--; + if (sMusicStartTimer == 0) { Audio_QueueSeqCmd(NA_BGM_BOSS | 0x8000); } } } - func_809DD0CC(globalCtx); - func_809DEAC4(this, globalCtx); - func_809DD934(this, globalCtx); + Boss02_UpdateEffects(play); + func_809DEAC4(this, play); + func_809DD934(this, play); } -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, - }; - static Vec3f D_809DFAF4 = { -10000.0f, -100000.0f, -100000.0f }; - GlobalContext* globalCtx = globalCtx2; +Gfx* D_809DFA9C[] = { + gTwinmoldBodySegment1DL, gTwinmoldBodySegment2DL, gTwinmoldBodySegment3DL, gTwinmoldBodySegment4DL, + gTwinmoldBodySegment5DL, gTwinmoldBodySegment6DL, gTwinmoldBodySegment7DL, gTwinmoldBodySegment8DL, + gTwinmoldBodySegment9DL, gTwinmoldBodySegment10DL, gTwinmoldBodySegment11DL, gTwinmoldBodySegment12DL, + gTwinmoldBodySegment13DL, gTwinmoldBodySegment14DL, gTwinmoldBodySegment15DL, gTwinmoldBodySegment16DL, + gTwinmoldBodySegment17DL, gTwinmoldBodySegment18DL, gTwinmoldBodySegment19DL, gTwinmoldBodySegment20DL, + gTwinmoldBodySegment21DL, gTwinmoldBodyTailDL, +}; + +Vec3f D_809DFAF4 = { -10000.0f, -100000.0f, -100000.0f }; + +void Boss02_Twinmold_Draw(Actor* thisx, PlayState* play2) { + PlayState* play = play2; Boss02* this = THIS; s32 i; s32 idx; @@ -1346,21 +1346,21 @@ void Boss02_Draw(Actor* thisx, GlobalContext* globalCtx2) { f32 sp9C; f32 sp98; - mtxIter = mtx = GRAPH_ALLOC(globalCtx->state.gfxCtx, sizeof(Mtx) * 23); + mtxIter = mtx = GRAPH_ALLOC(play->state.gfxCtx, sizeof(Mtx) * 23); - OPEN_DISPS(globalCtx->state.gfxCtx); + OPEN_DISPS(play->state.gfxCtx); - func_8012C28C(globalCtx->state.gfxCtx); + func_8012C28C(play->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, mtx); - if (D_809E0422 == 0) { + if (!sIsInGiantMode) { sp98 = -500.0f; } else { sp98 = 3100.0f; @@ -1376,22 +1376,22 @@ 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)) { POLY_OPA_DISP = Gfx_SetFog(POLY_OPA_DISP, 255, 0, 0, 255, 0x384, 0x44B); } - SkelAnime_DrawOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, NULL, NULL, &this->actor); - POLY_OPA_DISP = func_801660B8(globalCtx, POLY_OPA_DISP); + SkelAnime_DrawOpa(play, this->skelAnime.skeleton, this->skelAnime.jointTable, NULL, NULL, &this->actor); + POLY_OPA_DISP = func_801660B8(play, POLY_OPA_DISP); spA4 = 0.0f; spA0 = 0.0f; @@ -1407,14 +1407,13 @@ 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_RotateYF(M_PI / 2, MTXMODE_APPLY); + Matrix_RotateXFApply(-(M_PI / 2)); Matrix_ToMtx(mtxIter); gSPMatrix(POLY_OPA_DISP++, mtxIter, G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); @@ -1427,7 +1426,7 @@ void Boss02_Draw(Actor* thisx, GlobalContext* globalCtx2) { if (sp98 < this->unk_01BC[phi_v0].y) { gSPDisplayList(POLY_OPA_DISP++, D_809DFA9C[i]); } - POLY_OPA_DISP = func_801660B8(globalCtx, POLY_OPA_DISP); + POLY_OPA_DISP = func_801660B8(play, POLY_OPA_DISP); } if (i == 21) { @@ -1436,26 +1435,26 @@ 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, &this->actor.child->world.pos); + Matrix_MultVecX(500.0f, &this->actor.child->world.pos); } func_809DA50C(1, &this->colliderSphere2, &this->unk_147C[i + 1]); - SkinMatrix_Vec3fMtxFMultXYZW(&globalCtx->viewProjectionMtxF, &this->unk_147C[i + 1], &this->unk_167C, + SkinMatrix_Vec3fMtxFMultXYZW(&play->viewProjectionMtxF, &this->unk_147C[i + 1], &this->unk_167C, &this->actor.projectedW); } else { func_809DA50C(i, &this->colliderSphere1, &this->unk_147C[i + 1]); } } - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->state.gfxCtx); - if (D_809E0422 == 0) { + if (!sIsInGiantMode) { func_809DA50C(0, &this->colliderSphere2, &D_809DFAF4); func_809DA50C(21, &this->colliderSphere1, &this->unk_147C[0]); } else { @@ -1464,165 +1463,163 @@ void Boss02_Draw(Actor* thisx, GlobalContext* globalCtx2) { } } -void func_809DD0A8(Actor* thisx, GlobalContext* globalCtx) { - func_809DD2F8(globalCtx); +void Boss02_Static_Draw(Actor* thisx, PlayState* play) { + Boss02_DrawEffects(play); } -void func_809DD0CC(GlobalContext* globalCtx) { - Boss02Effects* effect = (Boss02Effects*)globalCtx->specialEffects; - f32 phi_f22; +void Boss02_UpdateEffects(PlayState* play) { + TwinmoldEffect* effect = (TwinmoldEffect*)play->specialEffects; + f32 floorY; s16 i; - if (D_809E0422 == 0) { - phi_f22 = 0.0f; + if (!sIsInGiantMode) { + floorY = 0.0f; } else { - phi_f22 = 3150.0f; + floorY = 3150.0f; } - for (i = 0; i < ARRAY_COUNT(D_809E0438); i++, effect++) { - if (effect->unk_24) { - effect->unk_26++; - effect->unk_00.x += effect->unk_0C.x * D_809DF5B0; - effect->unk_00.y += effect->unk_0C.y * D_809DF5B0; - effect->unk_00.z += effect->unk_0C.z * D_809DF5B0; - effect->unk_0C.y += effect->unk_18.y; + for (i = 0; i < ARRAY_COUNT(sEffects); i++, effect++) { + if (effect->type) { + effect->timer++; + effect->pos.x += effect->velocity.x * D_809DF5B0; + effect->pos.y += effect->velocity.y * D_809DF5B0; + effect->pos.z += effect->velocity.z * D_809DF5B0; + effect->velocity.y += effect->accel.y; - if (effect->unk_24 < 3) { - Math_ApproachF(&effect->unk_34, effect->unk_38, 0.1f, 0.1f); - if (effect->unk_24 == 2) { - effect->unk_2C -= 18; + if (effect->type < TWINMOLD_EFFECT_FRAGMENT) { + Math_ApproachF(&effect->scale, effect->targetScale, 0.1f, 0.1f); + if (effect->type == TWINMOLD_EFFECT_BLACK_DUST) { + effect->alpha -= 18; } else { - effect->unk_2C -= 15; + effect->alpha -= 15; } - if (effect->unk_2C <= 0) { - effect->unk_24 = 0; + + if (effect->alpha <= 0) { + effect->type = TWINMOLD_EFFECT_NONE; } - } else if (effect->unk_24 == 3) { - effect->unk_2E += 0x1000; - effect->unk_30 += 0x1500; - if ((effect->unk_00.y < phi_f22) || (effect->unk_26 > 50)) { - effect->unk_24 = 0; + } else if (effect->type == TWINMOLD_EFFECT_FRAGMENT) { + effect->rotX += 0x1000; + effect->rotY += 0x1500; + if ((effect->pos.y < floorY) || (effect->timer > 50)) { + effect->type = TWINMOLD_EFFECT_NONE; } - } else if (effect->unk_24 == 4) { - Math_ApproachF(&effect->unk_34, 80.0f, 0.2f, 20.0f); - effect->unk_2C -= 15; - if (effect->unk_2C <= 0) { - effect->unk_24 = 0; + } else if (effect->type == TWINMOLD_EFFECT_FLASH) { + Math_ApproachF(&effect->scale, 80.0f, 0.2f, 20.0f); + effect->alpha -= 15; + if (effect->alpha <= 0) { + effect->type = TWINMOLD_EFFECT_NONE; } } } } } -void func_809DD2F8(GlobalContext* globalCtx) { +void Boss02_DrawEffects(PlayState* play) { u8 flag = false; - Boss02Effects* effect = (Boss02Effects*)globalCtx->specialEffects; + TwinmoldEffect* effect = (TwinmoldEffect*)play->specialEffects; s16 i; - u8 phi_a0; + u8 alpha; - OPEN_DISPS(globalCtx->state.gfxCtx); + OPEN_DISPS(play->state.gfxCtx); - func_8012C28C(globalCtx->state.gfxCtx); - func_8012C2DC(globalCtx->state.gfxCtx); + func_8012C28C(play->state.gfxCtx); + func_8012C2DC(play->state.gfxCtx); - for (i = 0; i < ARRAY_COUNT(D_809E0438); i++, effect++) { - if (effect->unk_24 == 1) { + for (i = 0; i < ARRAY_COUNT(sEffects); i++, effect++) { + if (effect->type == TWINMOLD_EFFECT_SAND) { if (!flag) { - gSPDisplayList(POLY_XLU_DISP++, object_boss02_DL_000230); + gSPDisplayList(POLY_XLU_DISP++, gTwinmoldDustMaterialDL); gDPSetEnvColor(POLY_XLU_DISP++, 185, 140, 70, 128); flag++; } - phi_a0 = effect->unk_2C; - if (effect->unk_2C > 255) { - phi_a0 = 255; + alpha = effect->alpha; + if (effect->alpha > 255) { + alpha = 255; } - gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 185, 140, 70, phi_a0); + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 185, 140, 70, alpha); gSPSegment(POLY_XLU_DISP++, 0x08, - Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, effect->unk_26 + (i * 3), - (effect->unk_26 + (i * 3)) * 5, 32, 64, 1, 0, 0, 32, 32)); + Gfx_TwoTexScroll(play->state.gfxCtx, 0, effect->timer + (i * 3), (effect->timer + (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_Scale(effect->unk_34 * D_809DF5B0, effect->unk_34 * D_809DF5B0, 1.0f, MTXMODE_APPLY); + Matrix_Translate(effect->pos.x, effect->pos.y, effect->pos.z, MTXMODE_NEW); + Matrix_ReplaceRotation(&play->billboardMtxF); + Matrix_Scale(effect->scale * D_809DF5B0, effect->scale * 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); + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_XLU_DISP++, gTwinmoldDustModelDL); } } - effect = (Boss02Effects*)globalCtx->specialEffects; - for (i = 0, flag = false; i < ARRAY_COUNT(D_809E0438); i++, effect++) { - if (effect->unk_24 == 3) { + effect = (TwinmoldEffect*)play->specialEffects; + for (i = 0, flag = false; i < ARRAY_COUNT(sEffects); i++, effect++) { + if (effect->type == TWINMOLD_EFFECT_FRAGMENT) { if (!flag) { gDPSetCombineLERP(POLY_OPA_DISP++, SHADE, 0, PRIMITIVE, 0, SHADE, 0, PRIMITIVE, 0, SHADE, 0, PRIMITIVE, 0, SHADE, 0, PRIMITIVE, 0); gDPSetPrimColor(POLY_OPA_DISP++, 0, 0x01, 100, 100, 120, 255); flag++; } - Matrix_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_Scale(effect->unk_34 * D_809DF5B0, effect->unk_34 * D_809DF5B0, effect->unk_34 * D_809DF5B0, + + Matrix_Translate(effect->pos.x, effect->pos.y, effect->pos.z, MTXMODE_NEW); + Matrix_RotateYS(effect->rotY, MTXMODE_APPLY); + Matrix_RotateXS(effect->rotX, MTXMODE_APPLY); + Matrix_Scale(effect->scale * D_809DF5B0, effect->scale * D_809DF5B0, effect->scale * D_809DF5B0, MTXMODE_APPLY); - gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), - G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - gSPDisplayList(POLY_OPA_DISP++, gameplay_keep_DL_01A620); + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_OPA_DISP++, gEffFragments1DL); } } - effect = (Boss02Effects*)globalCtx->specialEffects; - for (i = 0, flag = false; i < ARRAY_COUNT(D_809E0438); i++, effect++) { - if (effect->unk_24 == 4) { + effect = (TwinmoldEffect*)play->specialEffects; + for (i = 0, flag = false; i < ARRAY_COUNT(sEffects); i++, effect++) { + if (effect->type == TWINMOLD_EFFECT_FLASH) { if (!flag) { //! @bug - dev forgot to set flag to 1, should only apply to first entry? gSPDisplayList(POLY_XLU_DISP++, gLightOrb1DL); gDPSetEnvColor(POLY_XLU_DISP++, 255, 0, 0, 128); } - gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 255, 255, 200, (u8)effect->unk_2C); + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 255, 255, 200, (u8)effect->alpha); - Matrix_InsertTranslation(effect->unk_00.x, effect->unk_00.y, effect->unk_00.z, MTXMODE_NEW); - Matrix_NormalizeXYZ(&globalCtx->billboardMtxF); - Matrix_Scale(effect->unk_34 * D_809DF5B0, effect->unk_34 * D_809DF5B0, 1.0f, MTXMODE_APPLY); + Matrix_Translate(effect->pos.x, effect->pos.y, effect->pos.z, MTXMODE_NEW); + Matrix_ReplaceRotation(&play->billboardMtxF); + Matrix_Scale(effect->scale * D_809DF5B0, effect->scale * D_809DF5B0, 1.0f, MTXMODE_APPLY); - gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), - G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_XLU_DISP++, gLightOrbVtxDL); } } - effect = (Boss02Effects*)globalCtx->specialEffects; - for (i = 0, flag = false; i < ARRAY_COUNT(D_809E0438); i++, effect++) { - if (effect->unk_24 == 2) { + effect = (TwinmoldEffect*)play->specialEffects; + for (i = 0, flag = false; i < ARRAY_COUNT(sEffects); i++, effect++) { + if (effect->type == TWINMOLD_EFFECT_BLACK_DUST) { if (!flag) { - gSPDisplayList(POLY_XLU_DISP++, object_boss02_DL_000230); + gSPDisplayList(POLY_XLU_DISP++, gTwinmoldDustMaterialDL); gDPSetEnvColor(POLY_XLU_DISP++, 30, 30, 30, 128); flag++; } - gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 30, 30, 30, (u8)effect->unk_2C); + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 30, 30, 30, (u8)effect->alpha); gSPSegment(POLY_XLU_DISP++, 0x08, - Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, effect->unk_26 + (i * 3), - (effect->unk_26 + (i * 3)) * 5, 32, 64, 1, 0, 0, 32, 32)); + Gfx_TwoTexScroll(play->state.gfxCtx, 0, effect->timer + (i * 3), (effect->timer + (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_Scale(effect->unk_34 * D_809DF5B0, effect->unk_34 * D_809DF5B0, 1.0f, MTXMODE_APPLY); + Matrix_Translate(effect->pos.x, effect->pos.y, effect->pos.z, MTXMODE_NEW); + Matrix_ReplaceRotation(&play->billboardMtxF); + Matrix_Scale(effect->scale * D_809DF5B0, effect->scale * 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); + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_XLU_DISP++, gTwinmoldDustModelDL); } } - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->state.gfxCtx); } -void func_809DD934(Boss02* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); +void func_809DD934(Boss02* this, PlayState* play) { + Player* player = GET_PLAYER(play); s16 i; Actor* temp_a0_5; Vec3f sp58; @@ -1635,15 +1632,15 @@ void func_809DD934(Boss02* this, GlobalContext* globalCtx) { switch (this->unk_1D18) { case 0: if (player->stateFlags1 & 0x100) { - 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); + Cutscene_Start(play, &play->csCtx); + this->subCamId = Play_CreateSubCamera(play); + Play_ChangeCameraStatus(play, CAM_ID_MAIN, CAM_STATUS_WAIT); + Play_ChangeCameraStatus(play, this->subCamId, CAM_STATUS_ACTIVE); func_8016566C(150); this->unk_1D14 = 0; - this->unk_1D5C = 0.0f; + this->subCamAtVel = 0.0f; this->unk_1D58 = 0.0f; - if (D_809E0422 == 0) { + if (!sIsInGiantMode) { this->unk_1D18 = 1; this->unk_1D68 = 10.0f; this->unk_1D64 = 60.0f; @@ -1665,38 +1662,38 @@ void func_809DD934(Boss02* this, GlobalContext* globalCtx) { break; case 1: - if ((this->unk_1D14 < 80U) && (D_809E0420 != 0) && - CHECK_BTN_ANY(CONTROLLER1(globalCtx)->press.button, + if ((this->unk_1D14 < 80) && (D_809E0420 != 0) && + CHECK_BTN_ANY(CONTROLLER1(&play->state)->press.button, BTN_A | BTN_B | BTN_CUP | BTN_CDOWN | BTN_CLEFT | BTN_CRIGHT)) { this->unk_1D18++; this->unk_1D78 = 1; this->unk_1D14 = 0; } else { label1: - if (this->unk_1D14 >= 50U) { + if (this->unk_1D14 >= 50) { if (this->unk_1D14 == (u32)(BREG(43) + 60)) { play_sound(NA_SE_PL_TRANSFORM_GIANT); } - Math_ApproachF(&this->unk_1D64, 200.0f, 0.1f, this->unk_1D5C * 640.0f); - Math_ApproachF(&this->unk_1D6C, 273.0f, 0.1f, this->unk_1D5C * 150.0f); - Math_ApproachF(&this->unk_1D70, 0.1f, 0.2f, this->unk_1D5C * 0.1f); - Math_ApproachF(&this->unk_1D74, -100.0f, 1.0f, this->unk_1D5C * 100.0f); - Math_ApproachF(&this->unk_1D5C, 1.0f, 1.0f, 0.001f); + Math_ApproachF(&this->unk_1D64, 200.0f, 0.1f, this->subCamAtVel * 640.0f); + Math_ApproachF(&this->unk_1D6C, 273.0f, 0.1f, this->subCamAtVel * 150.0f); + Math_ApproachF(&this->unk_1D70, 0.1f, 0.2f, this->subCamAtVel * 0.1f); + Math_ApproachF(&this->unk_1D74, -100.0f, 1.0f, this->subCamAtVel * 100.0f); + Math_ApproachF(&this->subCamAtVel, 1.0f, 1.0f, 0.001f); } else { Math_ApproachF(&this->unk_1D64, 30.0f, 0.1f, 1.0f); } - if (this->unk_1D14 > 50U) { + if (this->unk_1D14 > 50) { Math_ApproachZeroF(&this->unk_1D58, 1.0f, 0.06f); } else { Math_ApproachF(&this->unk_1D58, 0.4f, 1.0f, 0.02f); } - if (this->unk_1D14 == 107U) { + if (this->unk_1D14 == 107) { this->unk_1D78 = 1; } - if (this->unk_1D14 < 121U) { + if (this->unk_1D14 < 121) { break; } @@ -1707,15 +1704,15 @@ void func_809DD934(Boss02* this, GlobalContext* globalCtx) { break; case 2: - if (this->unk_1D14 < 8U) { + if (this->unk_1D14 < 8) { break; } sp57 = 1; goto block_38; case 10: - if ((this->unk_1D14 < 30U) && (D_809E0421 != 0) && - CHECK_BTN_ANY(CONTROLLER1(globalCtx)->press.button, + if ((this->unk_1D14 < 30) && (D_809E0421 != 0) && + CHECK_BTN_ANY(CONTROLLER1(&play->state)->press.button, BTN_A | BTN_B | BTN_CUP | BTN_CDOWN | BTN_CLEFT | BTN_CRIGHT)) { this->unk_1D18++; this->unk_1D78 = 1; @@ -1724,38 +1721,38 @@ void func_809DD934(Boss02* this, GlobalContext* globalCtx) { } label2: - if (this->unk_1D14 != 0U) { + if (this->unk_1D14 != 0) { if (this->unk_1D14 == (u32)(BREG(44) + 10)) { play_sound(NA_SE_PL_TRANSFORM_NORAML); } - Math_ApproachF(&this->unk_1D64, 60.0f, 0.1f, this->unk_1D5C * 640.0f); - Math_ApproachF(&this->unk_1D6C, 23.0f, 0.1f, this->unk_1D5C * 150.0f); + Math_ApproachF(&this->unk_1D64, 60.0f, 0.1f, this->subCamAtVel * 640.0f); + Math_ApproachF(&this->unk_1D6C, 23.0f, 0.1f, this->subCamAtVel * 150.0f); Math_ApproachF(&this->unk_1D70, 0.01f, 0.1f, 0.003f); - Math_ApproachF(&this->unk_1D74, 0.0f, 1.0f, this->unk_1D5C * 100.0f); - Math_ApproachF(&this->unk_1D5C, 2.0f, 1.0f, 0.01f); + Math_ApproachF(&this->unk_1D74, 0.0f, 1.0f, this->subCamAtVel * 100.0f); + Math_ApproachF(&this->subCamAtVel, 2.0f, 1.0f, 0.01f); } - if (this->unk_1D14 == 42U) { + if (this->unk_1D14 == 42) { this->unk_1D78 = 1; } - if (this->unk_1D14 > 50U) { + if (this->unk_1D14 > 50) { D_809E0421 = 1; goto block_38; } break; case 11: - if (this->unk_1D14 < 8U) { + if (this->unk_1D14 < 8) { break; } block_38: case 20: this->unk_1D18 = 0; - func_80169AFC(globalCtx, this->unk_1D22, 0); - this->unk_1D22 = 0; - Cutscene_End(globalCtx, &globalCtx->csCtx); + func_80169AFC(play, this->subCamId, 0); + this->subCamId = SUB_CAM_ID_DONE; + Cutscene_End(play, &play->csCtx); this->actor.flags |= ACTOR_FLAG_1; player->stateFlags1 &= ~0x100; this->unk_1D70 = 0.01f; @@ -1769,22 +1766,22 @@ void func_809DD934(Boss02* this, GlobalContext* globalCtx) { Actor_SetScale(&player->actor, this->unk_1D70); } - globalCtx->envCtx.lightSettings.fogNear = this->unk_1D74; + play->envCtx.lightSettings.fogNear = this->unk_1D74; if (sp57) { - D_809E0422 = 1 - D_809E0422; - if (D_809E0422 == 0) { + sIsInGiantMode = 1 - sIsInGiantMode; + if (!sIsInGiantMode) { D_809DF5B0 = 1.0f; } else { D_809DF5B0 = 0.1f; } this->unk_01AC = D_809DF5B0; - if (D_809E0422 == 0) { - if (D_809E0434 != NULL) { - D_809E0434->unk_203 = 0; - D_809E0434->unk_204 = 1.0f; - D_809E0434->dyna.actor.world.pos.y = 60.0f; + if (!sIsInGiantMode) { + if (sBlueWarp != NULL) { + sBlueWarp->unk_203 = 0; + sBlueWarp->unk_204 = 1.0f; + sBlueWarp->dyna.actor.world.pos.y = 60.0f; } player->actor.world.pos.x *= 10.0f; @@ -1793,70 +1790,70 @@ void func_809DD934(Boss02* this, GlobalContext* globalCtx) { player->unk_B68 = player->actor.world.pos.y; player->actor.world.pos.z *= 10.0f; - if ((D_809E0434 != NULL) && ((SQ(player->actor.world.pos.z) + SQ(player->actor.world.pos.x)) < SQ(60.0f))) { + if ((sBlueWarp != NULL) && ((SQ(player->actor.world.pos.z) + SQ(player->actor.world.pos.x)) < SQ(60.0f))) { player->actor.world.pos.z = 60.0f; player->actor.world.pos.x = 60.0f; } - D_809E0424->actor.world.pos.x *= 10.0f; - D_809E0424->actor.world.pos.y -= 3150.0f; - D_809E0424->actor.world.pos.y *= 10.0f; - D_809E0424->actor.world.pos.z *= 10.0f; + sRedTwinmold->actor.world.pos.x *= 10.0f; + sRedTwinmold->actor.world.pos.y -= 3150.0f; + sRedTwinmold->actor.world.pos.y *= 10.0f; + sRedTwinmold->actor.world.pos.z *= 10.0f; - D_809E0424->unk_0170.x *= 10.0f; - D_809E0424->unk_0170.y -= 3150.0f; - D_809E0424->unk_0170.y *= 10.0f; - D_809E0424->unk_0170.z *= 10.0f; + sRedTwinmold->unk_0170.x *= 10.0f; + sRedTwinmold->unk_0170.y -= 3150.0f; + sRedTwinmold->unk_0170.y *= 10.0f; + sRedTwinmold->unk_0170.z *= 10.0f; for (i = 0; i < ARRAY_COUNT(this->unk_01BC); i++) { - D_809E0424->unk_01BC[i].x *= 10.0f; - D_809E0424->unk_01BC[i].y -= 3150.0f; - D_809E0424->unk_01BC[i].y *= 10.0f; - D_809E0424->unk_01BC[i].z *= 10.0f; + sRedTwinmold->unk_01BC[i].x *= 10.0f; + sRedTwinmold->unk_01BC[i].y -= 3150.0f; + sRedTwinmold->unk_01BC[i].y *= 10.0f; + sRedTwinmold->unk_01BC[i].z *= 10.0f; } - D_809E0424->unk_01B0.x *= 10.0f; - D_809E0424->unk_01B0.y -= 3150.0f; - D_809E0424->unk_01B0.y *= 10.0f; - D_809E0424->unk_01B0.z *= 10.0f; + sRedTwinmold->unk_01B0.x *= 10.0f; + sRedTwinmold->unk_01B0.y -= 3150.0f; + sRedTwinmold->unk_01B0.y *= 10.0f; + sRedTwinmold->unk_01B0.z *= 10.0f; - D_809E0424->unk_017C.y -= 3150.0f; - D_809E0424->unk_017C.y *= 10.0f; - D_809E0424->unk_0188.y -= 3150.0f; - D_809E0424->unk_0188.y *= 10.0f; + sRedTwinmold->unk_017C.y -= 3150.0f; + sRedTwinmold->unk_017C.y *= 10.0f; + sRedTwinmold->unk_0188.y -= 3150.0f; + sRedTwinmold->unk_0188.y *= 10.0f; - D_809E0428->actor.world.pos.x *= 10.0f; - D_809E0428->actor.world.pos.y -= 3150.0f; - D_809E0428->actor.world.pos.y *= 10.0f; - D_809E0428->actor.world.pos.z *= 10.0f; + sBlueTwinmold->actor.world.pos.x *= 10.0f; + sBlueTwinmold->actor.world.pos.y -= 3150.0f; + sBlueTwinmold->actor.world.pos.y *= 10.0f; + sBlueTwinmold->actor.world.pos.z *= 10.0f; - D_809E0428->unk_0170.x *= 10.0f; - D_809E0428->unk_0170.y -= 3150.0f; - D_809E0428->unk_0170.y *= 10.0f; - D_809E0428->unk_0170.z *= 10.0f; + sBlueTwinmold->unk_0170.x *= 10.0f; + sBlueTwinmold->unk_0170.y -= 3150.0f; + sBlueTwinmold->unk_0170.y *= 10.0f; + sBlueTwinmold->unk_0170.z *= 10.0f; for (i = 0; i < ARRAY_COUNT(this->unk_01BC); i++) { - D_809E0428->unk_01BC[i].x *= 10.0f; - D_809E0428->unk_01BC[i].y -= 3150.0f; - D_809E0428->unk_01BC[i].y *= 10.0f; - D_809E0428->unk_01BC[i].z *= 10.0f; + sBlueTwinmold->unk_01BC[i].x *= 10.0f; + sBlueTwinmold->unk_01BC[i].y -= 3150.0f; + sBlueTwinmold->unk_01BC[i].y *= 10.0f; + sBlueTwinmold->unk_01BC[i].z *= 10.0f; } - D_809E0428->unk_01B0.x *= 10.0f; - D_809E0428->unk_01B0.y -= 3150.0f; - D_809E0428->unk_01B0.y *= 10.0f; - D_809E0428->unk_01B0.z *= 10.0f; + sBlueTwinmold->unk_01B0.x *= 10.0f; + sBlueTwinmold->unk_01B0.y -= 3150.0f; + sBlueTwinmold->unk_01B0.y *= 10.0f; + sBlueTwinmold->unk_01B0.z *= 10.0f; - D_809E0428->unk_017C.y -= 3150.0f; - D_809E0428->unk_017C.y *= 10.0f; - D_809E0428->unk_0188.y -= 3150.0f; - D_809E0428->unk_0188.y *= 10.0f; + sBlueTwinmold->unk_017C.y -= 3150.0f; + sBlueTwinmold->unk_017C.y *= 10.0f; + sBlueTwinmold->unk_0188.y -= 3150.0f; + sBlueTwinmold->unk_0188.y *= 10.0f; } else { - if (D_809E0434 != 0) { - D_809E0434->unk_203 = 1; - D_809E0434->unk_204 = 0.1f; - D_809E0434->dyna.actor.world.pos.y = 3155.0f; + if (sBlueWarp != 0) { + sBlueWarp->unk_203 = 1; + sBlueWarp->unk_204 = 0.1f; + sBlueWarp->dyna.actor.world.pos.y = 3155.0f; } player->actor.world.pos.x *= 0.1f; @@ -1865,65 +1862,65 @@ void func_809DD934(Boss02* this, GlobalContext* globalCtx) { player->unk_B68 = player->actor.world.pos.y; player->actor.world.pos.z *= 0.1f; - D_809E0424->actor.world.pos.x *= 0.1f; - D_809E0424->actor.world.pos.y *= 0.1f; - D_809E0424->actor.world.pos.y += 3150.0f; - D_809E0424->actor.world.pos.z *= 0.1f; + sRedTwinmold->actor.world.pos.x *= 0.1f; + sRedTwinmold->actor.world.pos.y *= 0.1f; + sRedTwinmold->actor.world.pos.y += 3150.0f; + sRedTwinmold->actor.world.pos.z *= 0.1f; - D_809E0424->unk_0170.x *= 0.1f; - D_809E0424->unk_0170.y *= 0.1f; - D_809E0424->unk_0170.y += 3150.0f; - D_809E0424->unk_0170.z *= 0.1f; + sRedTwinmold->unk_0170.x *= 0.1f; + sRedTwinmold->unk_0170.y *= 0.1f; + sRedTwinmold->unk_0170.y += 3150.0f; + sRedTwinmold->unk_0170.z *= 0.1f; for (i = 0; i < ARRAY_COUNT(this->unk_01BC); i++) { - D_809E0424->unk_01BC[i].x *= 0.1f; - D_809E0424->unk_01BC[i].y *= 0.1f; - D_809E0424->unk_01BC[i].y += 3150.0f; - D_809E0424->unk_01BC[i].z *= 0.1f; + sRedTwinmold->unk_01BC[i].x *= 0.1f; + sRedTwinmold->unk_01BC[i].y *= 0.1f; + sRedTwinmold->unk_01BC[i].y += 3150.0f; + sRedTwinmold->unk_01BC[i].z *= 0.1f; } - D_809E0424->unk_01B0.x *= 0.1f; - D_809E0424->unk_01B0.y *= 0.1f; - D_809E0424->unk_01B0.y += 3150.0f; - D_809E0424->unk_01B0.z *= 0.1f; + sRedTwinmold->unk_01B0.x *= 0.1f; + sRedTwinmold->unk_01B0.y *= 0.1f; + sRedTwinmold->unk_01B0.y += 3150.0f; + sRedTwinmold->unk_01B0.z *= 0.1f; - D_809E0424->unk_017C.y *= 0.1f; - D_809E0424->unk_017C.y += 3150.0f; - D_809E0424->unk_0188.y *= 0.1f; - D_809E0424->unk_0188.y += 3150.0f; + sRedTwinmold->unk_017C.y *= 0.1f; + sRedTwinmold->unk_017C.y += 3150.0f; + sRedTwinmold->unk_0188.y *= 0.1f; + sRedTwinmold->unk_0188.y += 3150.0f; - D_809E0428->actor.world.pos.x *= 0.1f; - D_809E0428->actor.world.pos.y *= 0.1f; - D_809E0428->actor.world.pos.y += 3150.0f; - D_809E0428->actor.world.pos.z *= 0.1f; + sBlueTwinmold->actor.world.pos.x *= 0.1f; + sBlueTwinmold->actor.world.pos.y *= 0.1f; + sBlueTwinmold->actor.world.pos.y += 3150.0f; + sBlueTwinmold->actor.world.pos.z *= 0.1f; - D_809E0428->unk_0170.x *= 0.1f; - D_809E0428->unk_0170.y *= 0.1f; - D_809E0428->unk_0170.y += 3150.0f; - D_809E0428->unk_0170.z *= 0.1f; + sBlueTwinmold->unk_0170.x *= 0.1f; + sBlueTwinmold->unk_0170.y *= 0.1f; + sBlueTwinmold->unk_0170.y += 3150.0f; + sBlueTwinmold->unk_0170.z *= 0.1f; for (i = 0; i < ARRAY_COUNT(this->unk_01BC); i++) { - D_809E0428->unk_01BC[i].x *= 0.1f; - D_809E0428->unk_01BC[i].y *= 0.1f; - D_809E0428->unk_01BC[i].y += 3150.0f; - D_809E0428->unk_01BC[i].z *= 0.1f; + sBlueTwinmold->unk_01BC[i].x *= 0.1f; + sBlueTwinmold->unk_01BC[i].y *= 0.1f; + sBlueTwinmold->unk_01BC[i].y += 3150.0f; + sBlueTwinmold->unk_01BC[i].z *= 0.1f; } - D_809E0428->unk_01B0.x *= 0.1f; - D_809E0428->unk_01B0.y *= 0.1f; - D_809E0428->unk_01B0.y += 3150.0f; - D_809E0428->unk_01B0.z *= 0.1f; + sBlueTwinmold->unk_01B0.x *= 0.1f; + sBlueTwinmold->unk_01B0.y *= 0.1f; + sBlueTwinmold->unk_01B0.y += 3150.0f; + sBlueTwinmold->unk_01B0.z *= 0.1f; - D_809E0428->unk_017C.y *= 0.1f; - D_809E0428->unk_017C.y += 3150.0f; - D_809E0428->unk_0188.y *= 0.1f; - D_809E0428->unk_0188.y += 3150.0f; + sBlueTwinmold->unk_017C.y *= 0.1f; + sBlueTwinmold->unk_017C.y += 3150.0f; + sBlueTwinmold->unk_0188.y *= 0.1f; + sBlueTwinmold->unk_0188.y += 3150.0f; } player->actor.home.pos = player->actor.world.pos; player->actor.prevPos = player->actor.world.pos; - temp_a0_5 = globalCtx->actorCtx.actorLists[ACTORCAT_BG].first; + temp_a0_5 = play->actorCtx.actorLists[ACTORCAT_BG].first; while (temp_a0_5 != NULL) { if (temp_a0_5->id == ACTOR_BG_INIBS_MOVEBG) { Actor_MarkForDeath(temp_a0_5); @@ -1932,15 +1929,15 @@ void func_809DD934(Boss02* this, GlobalContext* globalCtx) { temp_a0_5 = temp_a0_5->next; } { - f32 tmp = D_809E0422 ? 3150.0f : 0.0f; + f32 tmp = sIsInGiantMode ? 3150.0f : 0.0f; - Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_BG_INIBS_MOVEBG, 0, tmp, 0, 0, 0, 0, D_809E0422); + Actor_Spawn(&play->actorCtx, play, ACTOR_BG_INIBS_MOVEBG, 0, tmp, 0, 0, 0, 0, sIsInGiantMode); } - temp_a0_5 = globalCtx->actorCtx.actorLists[ACTORCAT_BOSS].first; + temp_a0_5 = play->actorCtx.actorLists[ACTORCAT_BOSS].first; while (temp_a0_5 != NULL) { if ((temp_a0_5->id == ACTOR_EN_TANRON5) || (temp_a0_5->id == ACTOR_ITEM_B_HEART)) { - if (D_809E0422 == 0) { + if (!sIsInGiantMode) { temp_a0_5->world.pos.y -= 3150.0f; temp_a0_5->world.pos.y *= 10.0f; @@ -1988,7 +1985,7 @@ void func_809DD934(Boss02* this, GlobalContext* globalCtx) { case 1: this->unk_1D7A = 0; - func_809DA1D0(globalCtx, 255, 255, 255, 0); + func_809DA1D0(play, 255, 255, 255, 0); this->unk_1D78 = 2; play_sound(NA_SE_SY_TRANSFORM_MASK_FLASH); @@ -2001,7 +1998,7 @@ void func_809DD934(Boss02* this, GlobalContext* globalCtx) { if (phi_v1 > 255) { phi_v1 = 255; } - func_809DA22C(globalCtx, phi_v1); + func_809DA22C(play, phi_v1); break; case 3: @@ -2009,48 +2006,48 @@ void func_809DD934(Boss02* this, GlobalContext* globalCtx) { if (this->unk_1D7A <= 0) { this->unk_1D7A = 0; this->unk_1D78 = 0; - func_809DA24C(globalCtx); + func_809DA24C(play); } else { phi_v1 = this->unk_1D7A; if (phi_v1 > 255) { phi_v1 = 255; } - func_809DA22C(globalCtx, phi_v1); + func_809DA22C(play, phi_v1); } break; } - if ((this->unk_1D18 != 0) && (this->unk_1D22 != 0)) { - Matrix_RotateY(player->actor.shape.rot.y, MTXMODE_NEW); - Matrix_GetStateTranslationAndScaledZ(this->unk_1D64, &sp58); + if ((this->unk_1D18 != 0) && (this->subCamId != SUB_CAM_ID_DONE)) { + Matrix_RotateYS(player->actor.shape.rot.y, MTXMODE_NEW); + Matrix_MultVecZ(this->unk_1D64, &sp58); - this->unk_1D24.x = player->actor.world.pos.x + sp58.x; - this->unk_1D24.y = player->actor.world.pos.y + sp58.y + this->unk_1D68; - this->unk_1D24.z = player->actor.world.pos.z + sp58.z; + this->subCamEye.x = player->actor.world.pos.x + sp58.x; + this->subCamEye.y = player->actor.world.pos.y + sp58.y + this->unk_1D68; + this->subCamEye.z = player->actor.world.pos.z + sp58.z; - this->unk_1D30.x = player->actor.world.pos.x; - this->unk_1D30.y = player->actor.world.pos.y + this->unk_1D6C; - this->unk_1D30.z = player->actor.world.pos.z; + this->subCamAt.x = player->actor.world.pos.x; + this->subCamAt.y = player->actor.world.pos.y + this->unk_1D6C; + this->subCamAt.z = player->actor.world.pos.z; this->unk_1D54 = Math_SinS(this->unk_1D14 * 1512) * this->unk_1D58; - Matrix_InsertZRotation_f(this->unk_1D54, MTXMODE_APPLY); - Matrix_GetStateTranslationAndScaledY(1.0f, &this->unk_1D3C); - Play_CameraSetAtEyeUp(globalCtx, this->unk_1D22, &this->unk_1D30, &this->unk_1D24, &this->unk_1D3C); + Matrix_RotateZF(this->unk_1D54, MTXMODE_APPLY); + Matrix_MultVecY(1.0f, &this->subCamUp); + Play_SetCameraAtEyeUp(play, this->subCamId, &this->subCamAt, &this->subCamEye, &this->subCamUp); ShrinkWindow_SetLetterboxTarget(27); } } -void func_809DEAC4(Boss02* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); +void func_809DEAC4(Boss02* this, PlayState* play) { + Player* player = GET_PLAYER(play); Boss02* sp68; - Vec3f sp5C; + Vec3f subCamEye; f32 sp58 = 0.0f; this->unk_1D1C++; if (this->unk_0194 == 0) { - sp68 = D_809E0424; + sp68 = sRedTwinmold; } else { - sp68 = D_809E0428; + sp68 = sBlueTwinmold; } switch (this->unk_1D20) { @@ -2061,32 +2058,31 @@ void func_809DEAC4(Boss02* this, GlobalContext* globalCtx) { if ((gSaveContext.save.weekEventReg[52] & 0x20) || ((u32)(KREG(13) + 15) >= this->unk_1D1C)) { break; } - 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); + Cutscene_Start(play, &play->csCtx); + this->subCamId = Play_CreateSubCamera(play); + Play_ChangeCameraStatus(play, CAM_ID_MAIN, CAM_STATUS_WAIT); + Play_ChangeCameraStatus(play, this->subCamId, CAM_STATUS_ACTIVE); this->unk_1D20 = 2; this->unk_1D1C = 0; case 2: player->actor.shape.rot.y = -0x8000; player->actor.world.rot.y = player->actor.shape.rot.y; - this->unk_1D24.x = player->actor.world.pos.x - 20.0f; - this->unk_1D24.y = (Player_GetHeight(player) + player->actor.world.pos.y) - 29.0f; - this->unk_1D24.z = player->actor.world.pos.z - 50; + this->subCamEye.x = player->actor.world.pos.x - 20.0f; + this->subCamEye.y = (Player_GetHeight(player) + player->actor.world.pos.y) - 29.0f; + this->subCamEye.z = player->actor.world.pos.z - 50; - this->unk_1D30.x = player->actor.world.pos.x; - this->unk_1D30.y = (Player_GetHeight(player) + player->actor.world.pos.y) - 17.0f; - this->unk_1D30.z = player->actor.world.pos.z; + this->subCamAt.x = player->actor.world.pos.x; + this->subCamAt.y = (Player_GetHeight(player) + player->actor.world.pos.y) - 17.0f; + this->subCamAt.z = player->actor.world.pos.z; if (this->unk_1D1C >= 30) { if (this->unk_1D1C == 30) { - func_8013EC44(0.0f, 50, 200, 1); + Rumble_Override(0.0f, 50, 200, 1); } 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->subCamUp); func_8019F128(NA_SE_EV_EARTHQUAKE_LAST - SFX_FLAG); } @@ -2095,21 +2091,21 @@ void func_809DEAC4(Boss02* this, GlobalContext* globalCtx) { } if (this->unk_1D1C == 45) { - func_800B7298(globalCtx, &this->actor, 21); - D_809E0430 = KREG(91) + 43; + func_800B7298(play, &this->actor, 21); + sMusicStartTimer = KREG(91) + 43; } if (this->unk_1D1C == 85) { - D_809E0424->unk_0144 = 11; - D_809E0424->unk_014C = 0; + sRedTwinmold->unk_0144 = 11; + sRedTwinmold->unk_014C = 0; } if (this->unk_1D1C == 92) { - func_8013EC44(0.0f, 255, 30, 100); + Rumble_Override(0.0f, 255, 30, 100); } if (this->unk_1D1C == 100) { - func_800B7298(globalCtx, &this->actor, 0x73); + func_800B7298(play, &this->actor, 0x73); } if (this->unk_1D1C == 112) { @@ -2120,53 +2116,53 @@ void func_809DEAC4(Boss02* this, GlobalContext* globalCtx) { case 10: if (this->unk_1D1C < 310) { - this->unk_1D48 = sp68->actor.world.pos; - this->unk_1D24.x = (sp68->actor.world.pos.x * 50.0f) * 0.001f; - this->unk_1D24.y = (sp68->actor.world.pos.y * 50.0f) * 0.001f; - if (this->unk_1D24.y < 100.0f) { - this->unk_1D24.y = 100.0f; + this->subCamAtNext = sp68->actor.world.pos; + this->subCamEye.x = (sp68->actor.world.pos.x * 50.0f) * 0.001f; + this->subCamEye.y = (sp68->actor.world.pos.y * 50.0f) * 0.001f; + if (this->subCamEye.y < 100.0f) { + this->subCamEye.y = 100.0f; } - this->unk_1D24.z = (sp68->actor.world.pos.z * 100) * 0.001f; + this->subCamEye.z = (sp68->actor.world.pos.z * 100) * 0.001f; } - Math_ApproachF(&this->unk_1D30.x, this->unk_1D48.x, 0.1f, 3000.0f); - Math_ApproachF(&this->unk_1D30.y, this->unk_1D48.y, 0.1f, 3000.0f); - Math_ApproachF(&this->unk_1D30.z, this->unk_1D48.z, 0.1f, 3000.0f); + Math_ApproachF(&this->subCamAt.x, this->subCamAtNext.x, 0.1f, 3000.0f); + Math_ApproachF(&this->subCamAt.y, this->subCamAtNext.y, 0.1f, 3000.0f); + Math_ApproachF(&this->subCamAt.z, this->subCamAtNext.z, 0.1f, 3000.0f); if (this->unk_1D1C == 100) { - D_809E0428->unk_0144 = 11; - D_809E0428->unk_014C = 0; + sBlueTwinmold->unk_0144 = 11; + sBlueTwinmold->unk_014C = 0; this->unk_0194 = 1; } 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); + TitleCard_InitBossName(&play->state, &play->actorCtx.titleCtxt, + 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; - Cutscene_End(globalCtx, &globalCtx->csCtx); - func_800B7298(globalCtx, &this->actor, 6); + func_80169AFC(play, this->subCamId, 0); + this->subCamId = SUB_CAM_ID_DONE; + Cutscene_End(play, &play->csCtx); + func_800B7298(play, &this->actor, 6); this->actor.flags |= ACTOR_FLAG_1; this->unk_1D20 = 0; - D_809E0424->unk_0144 = D_809E0428->unk_0144 = 3; - D_809E0424->unk_0146[0] = D_809E0428->unk_0146[0] = 60; + sRedTwinmold->unk_0144 = sBlueTwinmold->unk_0144 = 3; + sRedTwinmold->unk_0146[0] = sBlueTwinmold->unk_0146[0] = 60; gSaveContext.eventInf[5] |= 0x20; } break; case 100: if (ActorCutscene_GetCurrentIndex() == -1) { - 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); + Cutscene_Start(play, &play->csCtx); + this->subCamId = Play_CreateSubCamera(play); + Play_ChangeCameraStatus(play, CAM_ID_MAIN, CAM_STATUS_WAIT); + Play_ChangeCameraStatus(play, this->subCamId, CAM_STATUS_ACTIVE); this->unk_1D20 = 101; this->unk_1D1C = 0; - this->unk_1D5C = 1.0f; - this->unk_1D30 = sp68->actor.world.pos; + this->subCamAtVel = 1.0f; + this->subCamAt = sp68->actor.world.pos; } else { break; } @@ -2175,30 +2171,30 @@ void func_809DEAC4(Boss02* this, GlobalContext* globalCtx) { case 102: case_10x: if ((this->unk_1D20 == 101) || (this->unk_1D20 == 103)) { - this->unk_1D48 = sp68->actor.world.pos; + this->subCamAtNext = sp68->actor.world.pos; } else { - this->unk_1D48 = sp68->unk_147C[sp68->unk_1678]; + this->subCamAtNext = sp68->unk_147C[sp68->unk_1678]; } - this->unk_1D24.x = player->actor.world.pos.x; - this->unk_1D24.y = player->actor.world.pos.y + 100.0f; - if (D_809E0422 == 0) { - if (this->unk_1D24.y < 100.0f) { - this->unk_1D24.y = 100.0f; + this->subCamEye.x = player->actor.world.pos.x; + this->subCamEye.y = player->actor.world.pos.y + 100.0f; + if (!sIsInGiantMode) { + if (this->subCamEye.y < 100.0f) { + this->subCamEye.y = 100.0f; } - } else if (this->unk_1D24.y < 3160.0f) { - this->unk_1D24.y = 3160.0f; + } else if (this->subCamEye.y < 3160.0f) { + this->subCamEye.y = 3160.0f; } - if (this->unk_1D48.y < (100.0f * D_809DF5B0)) { - this->unk_1D48.y = (100.0f * D_809DF5B0); + if (this->subCamAtNext.y < (100.0f * D_809DF5B0)) { + this->subCamAtNext.y = (100.0f * D_809DF5B0); } - this->unk_1D24.z = player->actor.world.pos.z; - Math_ApproachF(&this->unk_1D30.x, this->unk_1D48.x, 0.3f, this->unk_1D5C * 500.0f); - Math_ApproachF(&this->unk_1D30.y, this->unk_1D48.y, 0.3f, this->unk_1D5C * 500.0f); - Math_ApproachF(&this->unk_1D30.z, this->unk_1D48.z, 0.3f, this->unk_1D5C * 500.0f); - Math_ApproachF(&this->unk_1D5C, 1.0f, 1.0f, 0.02f); + this->subCamEye.z = player->actor.world.pos.z; + Math_ApproachF(&this->subCamAt.x, this->subCamAtNext.x, 0.3f, this->subCamAtVel * 500.0f); + Math_ApproachF(&this->subCamAt.y, this->subCamAtNext.y, 0.3f, this->subCamAtVel * 500.0f); + Math_ApproachF(&this->subCamAt.z, this->subCamAtNext.z, 0.3f, this->subCamAtVel * 500.0f); + Math_ApproachF(&this->subCamAtVel, 1.0f, 1.0f, 0.02f); break; case 103: @@ -2206,47 +2202,45 @@ void func_809DEAC4(Boss02* this, GlobalContext* globalCtx) { sp58 = Math_SinS(this->unk_0150); sp58 = (sp58 * this->unk_0146[0]) * 1.5f; if (this->unk_1D1C == 30) { - func_80169AFC(globalCtx, this->unk_1D22, 0); - this->unk_1D22 = 0; - Cutscene_End(globalCtx, &globalCtx->csCtx); - func_800B7298(globalCtx, &this->actor, 6); + func_80169AFC(play, this->subCamId, 0); + this->subCamId = SUB_CAM_ID_DONE; + Cutscene_End(play, &play->csCtx); + func_800B7298(play, &this->actor, 6); this->unk_1D20 = 0; this->actor.flags |= ACTOR_FLAG_1; sp68->unk_0144 = 10; - if ((D_809E0424->unk_0144 >= 10) && (D_809E0428->unk_0144 >= 10)) { + if ((sRedTwinmold->unk_0144 >= 10) && (sBlueTwinmold->unk_0144 >= 10)) { f32 phi_f0; this->unk_1D7E = 0; - if (D_809E0422 == 0) { - Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_ITEM_B_HEART, 0.0f, 30.0f, -150.0f, 0, 1, 0, - 0); + if (!sIsInGiantMode) { + Actor_Spawn(&play->actorCtx, play, ACTOR_ITEM_B_HEART, 0.0f, 30.0f, -150.0f, 0, 1, 0, 0); phi_f0 = 60.0f; } else { - Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_ITEM_B_HEART, 0.0f, 3153.0f, -15.0f, 0, 1, 0, - 35); + Actor_Spawn(&play->actorCtx, play, ACTOR_ITEM_B_HEART, 0.0f, 3153.0f, -15.0f, 0, 1, 0, 35); phi_f0 = 3155.0f; } - D_809E0434 = (DoorWarp1*)Actor_SpawnAsChild(&globalCtx->actorCtx, &this->actor, globalCtx, - ACTOR_DOOR_WARP1, 0.0f, phi_f0, 0.0f, 0, 0, 0, 1); + sBlueWarp = (DoorWarp1*)Actor_SpawnAsChild(&play->actorCtx, &this->actor, play, ACTOR_DOOR_WARP1, + 0.0f, phi_f0, 0.0f, 0, 0, 0, 1); - if (D_809E0422 == 0) { - D_809E0434->unk_203 = 0; - D_809E0434->unk_204 = 1.0f; + if (!sIsInGiantMode) { + sBlueWarp->unk_203 = 0; + sBlueWarp->unk_204 = 1.0f; } else { - D_809E0434->unk_203 = 1; - D_809E0434->unk_204 = 0.1f; + sBlueWarp->unk_203 = 1; + sBlueWarp->unk_204 = 0.1f; } } } goto case_10x; } - if ((this->unk_1D20 != 0) && (this->unk_1D22 != 0)) { - sp5C = this->unk_1D24; - sp5C.y += sp58 * D_809DF5B0; - Play_CameraSetAtEyeUp(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; + if ((this->unk_1D20 != 0) && (this->subCamId != SUB_CAM_ID_DONE)) { + subCamEye = this->subCamEye; + subCamEye.y += sp58 * D_809DF5B0; + Play_SetCameraAtEyeUp(play, this->subCamId, &this->subCamAt, &subCamEye, &this->subCamUp); + this->subCamUp.z = this->subCamUp.x = 0.0f; + this->subCamUp.y = 1.0f; ShrinkWindow_SetLetterboxTarget(27); } } diff --git a/src/overlays/actors/ovl_Boss_02/z_boss_02.h b/src/overlays/actors/ovl_Boss_02/z_boss_02.h index babf40b76..17028912b 100644 --- a/src/overlays/actors/ovl_Boss_02/z_boss_02.h +++ b/src/overlays/actors/ovl_Boss_02/z_boss_02.h @@ -2,24 +2,40 @@ #define Z_BOSS_02_H #include "global.h" +#include "objects/object_boss02/object_boss02.h" struct Boss02; -typedef void (*Boss02ActionFunc)(struct Boss02*, GlobalContext*); +typedef void (*Boss02ActionFunc)(struct Boss02*, PlayState*); typedef struct { - /* 0x00 */ Vec3f unk_00; - /* 0x0C */ Vec3f unk_0C; - /* 0x18 */ Vec3f unk_18; - /* 0x24 */ u8 unk_24; - /* 0x26 */ s16 unk_26; + /* 0x00 */ Vec3f pos; + /* 0x0C */ Vec3f velocity; + /* 0x18 */ Vec3f accel; + /* 0x24 */ u8 type; + /* 0x26 */ s16 timer; /* 0x28 */ UNK_TYPE1 unk_28[0x4]; - /* 0x2C */ s16 unk_2C; - /* 0x2E */ s16 unk_2E; - /* 0x30 */ s16 unk_30; - /* 0x34 */ f32 unk_34; - /* 0x38 */ f32 unk_38; -} Boss02Effects; // size = 0x3C + /* 0x2C */ s16 alpha; + /* 0x2E */ s16 rotX; + /* 0x30 */ s16 rotY; + /* 0x34 */ f32 scale; + /* 0x38 */ f32 targetScale; +} TwinmoldEffect; // size = 0x3C + +typedef enum { + /* 0 */ TWINMOLD_EFFECT_NONE, + /* 1 */ TWINMOLD_EFFECT_SAND, // The sand kicked up when Twinmold touches the ground + /* 2 */ TWINMOLD_EFFECT_BLACK_DUST, // Unused + /* 3 */ TWINMOLD_EFFECT_FRAGMENT, // The fragments that fly off when the parts of Twinmold explode + /* 4 */ TWINMOLD_EFFECT_FLASH, // The flashes of light that appear when the parts of Twinmold explode +} TwinmoldEffectType; + +typedef enum { + /* 0 */ TWINMOLD_RED, + /* 35 */ TWINMOLD_BLUE = 35, + /* 100 */ TWINMOLD_TAIL = 100, + /* 200 */ TWINMOLD_STATIC = 200, +} TwinmoldParams; typedef struct Boss02 { /* 0x0000 */ Actor actor; @@ -56,10 +72,10 @@ 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 + /* 0x1674 */ struct Boss02* otherTwinmold; // points to the other's instance /* 0x1678 */ s32 unk_1678; /* 0x167C */ Vec3f unk_167C; /* 0x1688 */ ColliderJntSph colliderSphere1; @@ -72,14 +88,14 @@ typedef struct Boss02 { /* 0x1D1A */ s16 unk_1D1A; /* 0x1D1C */ u32 unk_1D1C; /* 0x1D20 */ s16 unk_1D20; - /* 0x1D22 */ s16 unk_1D22; - /* 0x1D24 */ Vec3f unk_1D24; - /* 0x1D30 */ Vec3f unk_1D30; - /* 0x1D3C */ Vec3f unk_1D3C; - /* 0x1D48 */ Vec3f unk_1D48; + /* 0x1D22 */ s16 subCamId; + /* 0x1D24 */ Vec3f subCamEye; + /* 0x1D30 */ Vec3f subCamAt; + /* 0x1D3C */ Vec3f subCamUp; + /* 0x1D48 */ Vec3f subCamAtNext; /* 0x1D54 */ f32 unk_1D54; /* 0x1D58 */ f32 unk_1D58; - /* 0x1D5C */ f32 unk_1D5C; + /* 0x1D5C */ f32 subCamAtVel; /* 0x1D60 */ UNK_TYPE1 unk1D60[0x4]; /* 0x1D64 */ f32 unk_1D64; /* 0x1D68 */ f32 unk_1D68; diff --git a/src/overlays/actors/ovl_Boss_03/z_boss_03.c b/src/overlays/actors/ovl_Boss_03/z_boss_03.c index 31e8fb0ae..75378de78 100644 --- a/src/overlays/actors/ovl_Boss_03/z_boss_03.c +++ b/src/overlays/actors/ovl_Boss_03/z_boss_03.c @@ -77,37 +77,37 @@ #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); -void Boss03_Draw(Actor* thisx, GlobalContext* globalCtx); +void Boss03_Init(Actor* thisx, PlayState* play); +void Boss03_Destroy(Actor* thisx, PlayState* play); +void Boss03_Update(Actor* thisx, PlayState* play); +void Boss03_Draw(Actor* thisx, PlayState* play); -void func_809E344C(Boss03* this, GlobalContext* globalCtx); -void func_809E34B8(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 func_809E344C(Boss03* this, PlayState* play); +void func_809E34B8(Boss03* this, PlayState* play); +void Boss03_SetupChasePlayer(Boss03* this, PlayState* play); +void Boss03_ChasePlayer(Boss03* this, PlayState* play); +void Boss03_SetupCatchPlayer(Boss03* this, PlayState* play, u8 arg2); +void Boss03_CatchPlayer(Boss03* this, PlayState* play); +void Boss03_SetupChewPlayer(Boss03* this, PlayState* play); +void Boss03_ChewPlayer(Boss03* this, PlayState* play); +void Boss03_SetupPrepareCharge(Boss03* this, PlayState* play); +void Boss03_PrepareCharge(Boss03* this, PlayState* play); +void Boss03_SetupCharge(Boss03* this, PlayState* play); +void Boss03_Charge(Boss03* this, PlayState* play); +void Boss03_SetupJumpOverPlatform(Boss03* this, PlayState* play); +void Boss03_JumpOverPlatform(Boss03* this, PlayState* play); +void Boss03_SetupIntroCutscene(Boss03* this, PlayState* play); +void Boss03_IntroCutscene(Boss03* this, PlayState* play); +void Boss03_DeathCutscene(Boss03* this, PlayState* play); +void Boss03_SpawnSmallFishesCutscene(Boss03* this, PlayState* play); +void Boss03_Stunned(Boss03* this, PlayState* play); +void Boss03_Damaged(Boss03* this, PlayState* play); -void Boss03_UpdateEffects(GlobalContext* globalCtx); -void Boss03_DrawEffects(GlobalContext* globalCtx); +void Boss03_UpdateEffects(PlayState* play); +void Boss03_DrawEffects(PlayState* play); -void Boss03_SeaweedUpdate(Actor* thisx, GlobalContext* globalCtx); -void Boss03_SeaweedDraw(Actor* thisx, GlobalContext* globalCtx); +void Boss03_SeaweedUpdate(Actor* thisx, PlayState* play); +void Boss03_SeaweedDraw(Actor* thisx, PlayState* play); u8 D_809E9840; // Timer used to start playing the boss background music if the intro cutscene was skipped (because it was already @@ -130,9 +130,9 @@ void Boss03_PlayUnderwaterSfx(Vec3f* projectedPos, u16 sfxId) { /* Start of SpawnEffect section */ -void Boss03_SpawnEffectWetSpot(GlobalContext* globalCtx, Vec3f* pos) { +void Boss03_SpawnEffectWetSpot(PlayState* play, Vec3f* pos) { s16 i; - GyorgEffect* eff = globalCtx->specialEffects; + GyorgEffect* eff = play->specialEffects; for (i = 0; i < GYORG_EFFECT_COUNT; i++) { if ((eff->type == GYORG_EFFECT_NONE) || (eff->type == GYORG_EFFECT_BUBBLE)) { @@ -151,9 +151,9 @@ void Boss03_SpawnEffectWetSpot(GlobalContext* globalCtx, Vec3f* pos) { } } -void Boss03_SpawnEffectDroplet(GlobalContext* globalCtx, Vec3f* pos) { +void Boss03_SpawnEffectDroplet(PlayState* play, Vec3f* pos) { s16 i; - GyorgEffect* eff = globalCtx->specialEffects; + GyorgEffect* eff = play->specialEffects; for (i = 0; i < GYORG_EFFECT_COUNT; i++) { if ((eff->type == GYORG_EFFECT_NONE) || (eff->type == GYORG_EFFECT_BUBBLE)) { @@ -175,10 +175,10 @@ void Boss03_SpawnEffectDroplet(GlobalContext* globalCtx, Vec3f* pos) { } } -void Boss03_SpawnEffectSplash(GlobalContext* globalCtx, Vec3f* pos, Vec3f* velocity) { +void Boss03_SpawnEffectSplash(PlayState* play, Vec3f* pos, Vec3f* velocity) { Vec3f accel = { 0.0f, -1.0f, 0.0f }; f32 temp_f2; - GyorgEffect* eff = globalCtx->specialEffects; + GyorgEffect* eff = play->specialEffects; s16 i; for (i = 0; i < GYORG_EFFECT_COUNT; i++) { @@ -199,9 +199,9 @@ void Boss03_SpawnEffectSplash(GlobalContext* globalCtx, Vec3f* pos, Vec3f* veloc } } -void Boss03_SpawnEffectBubble(GlobalContext* globalCtx, Vec3f* pos) { +void Boss03_SpawnEffectBubble(PlayState* play, Vec3f* pos) { s16 i; - GyorgEffect* eff = globalCtx->specialEffects; + GyorgEffect* eff = play->specialEffects; for (i = 0; i < GYORG_EFFECT_COUNT; i++) { if (eff->type == GYORG_EFFECT_NONE) { @@ -263,8 +263,8 @@ f32 Boss03_RandZeroOne(void) { /* 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; +Actor* Boss03_FindActorDblueMovebg(PlayState* play) { + Actor* actor = play->actorCtx.actorLists[ACTORCAT_BG].first; while (actor != NULL) { if (actor->id == ACTOR_BG_DBLUE_MOVEBG) { @@ -421,7 +421,7 @@ Color_RGBA8 sGyorgDustEnvColor = { 40, 30, 30, 255 }; /** * Used when chasing Player and Gyorg is near the bottom */ -void Boss03_SpawnDust(Boss03* this, GlobalContext* globalCtx) { +void Boss03_SpawnDust(Boss03* this, PlayState* play) { if (this->insideJawPos.y < 80.0f) { u8 i; Vec3f pos; @@ -441,22 +441,22 @@ void Boss03_SpawnDust(Boss03* this, GlobalContext* globalCtx) { pos.z = randPlusMinusPoint5Scaled(150.0f) + this->insideJawPos.z; pos.x = randPlusMinusPoint5Scaled(150.0f) + this->insideJawPos.x; - func_800B0EB0(globalCtx, &pos, &velocity, &accel, &sGyorgDustPrimColor, &sGyorgDustEnvColor, + func_800B0EB0(play, &pos, &velocity, &accel, &sGyorgDustPrimColor, &sGyorgDustEnvColor, Rand_ZeroFloat(200.0f) + 400.0f, 10, Rand_ZeroFloat(10.0f) + 25.0f); } } } -void Boss03_Init(Actor* thisx, GlobalContext* globalCtx2) { +void Boss03_Init(Actor* thisx, PlayState* play2) { Boss03* this = THIS; s32 i; - GlobalContext* globalCtx = globalCtx2; + PlayState* play = play2; Vec3f sp70; 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_SpawnAsChild(&play->actorCtx, &this->actor, play, ACTOR_DOOR_WARP1, 0.0f, PLATFORM_HEIGHT, 200.0f, 0, 0, + 0, ENDOORWARP1_FF_1); + Actor_Spawn(&play->actorCtx, play, ACTOR_ITEM_B_HEART, 0.0f, PLATFORM_HEIGHT, 0.0f, 0, 0, 0, 0); Actor_MarkForDeath(&this->actor); return; } @@ -491,19 +491,19 @@ void Boss03_Init(Actor* thisx, GlobalContext* globalCtx2) { f32 rand; rand = Boss03_RandZeroOne(); - Matrix_InsertYRotation_f((rand * M_PI * 0.2f) + ((2.0f * M_PI / 5.0f) * i), MTXMODE_NEW); + Matrix_RotateYF((rand * M_PI * 0.2f) + ((2.0f * M_PI / 5.0f) * i), MTXMODE_NEW); rand = Boss03_RandZeroOne(); - Matrix_GetStateTranslationAndScaledZ((rand * 800.0f) + 400.0f, &sp70); + Matrix_MultVecZ((rand * 800.0f) + 400.0f, &sp70); rand = Boss03_RandZeroOne(); - Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_BOSS_03, sp70.x, sp70.y, sp70.z, 0, rand * 0x10000, 0, + Actor_Spawn(&play->actorCtx, play, ACTOR_BOSS_03, sp70.x, sp70.y, sp70.z, 0, rand * 0x10000, 0, GYORG_PARAM_SEAWEED); } sGyorgBossInstance = this; - globalCtx->specialEffects = sGyorgEffects; + play->specialEffects = sGyorgEffects; for (i = 0; i < ARRAY_COUNT(sGyorgEffects); i++) { sGyorgEffects[i].type = GYORG_EFFECT_NONE; @@ -513,12 +513,10 @@ void Boss03_Init(Actor* thisx, GlobalContext* globalCtx2) { this->actor.colChkInfo.mass = MASS_HEAVY; this->actor.colChkInfo.health = 10; - 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); + Collider_InitAndSetJntSph(play, &this->headCollider, &this->actor, &sHeadJntSphInit, this->headColliderElements); + Collider_InitAndSetJntSph(play, &this->bodyCollider, &this->actor, &sBodyJntSphInit, this->bodyColliderElements); + SkelAnime_InitFlex(play, &this->skelAnime, &gGyorgSkel, &gGyorgCrawlingAnim, this->jointTable, this->morphTable, + GYORG_LIMB_MAX); Actor_SetScale(&this->actor, 0.2f); // gSaveContext.eventInf[5] & 0x40: intro cutscene already watched @@ -527,7 +525,7 @@ void Boss03_Init(Actor* thisx, GlobalContext* globalCtx2) { D_809E9842 = false; Audio_QueueSeqCmd(NA_BGM_STOP | 0x10000); } else { - Boss03_SetupIntroCutscene(this, globalCtx); + Boss03_SetupIntroCutscene(this, play); D_809E9842 = true; } @@ -535,14 +533,14 @@ void Boss03_Init(Actor* thisx, GlobalContext* globalCtx2) { this->waterHeight = WATER_HEIGHT; } -void Boss03_Destroy(Actor* thisx, GlobalContext* globalCtx) { +void Boss03_Destroy(Actor* thisx, PlayState* play) { Boss03* this = THIS; } /* Start of ActionFuncs section */ -void func_809E344C(Boss03* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); +void func_809E344C(Boss03* this, PlayState* play) { + Player* player = GET_PLAYER(play); // Mid-air if (player->actor.world.pos.y < 540.0f) { @@ -556,14 +554,14 @@ void func_809E344C(Boss03* this, GlobalContext* globalCtx) { /** * Swims randomly until WORK_TIMER_UNK1_A runs out */ -void func_809E34B8(Boss03* this, GlobalContext* globalCtx) { +void func_809E34B8(Boss03* this, PlayState* play) { f32 xDiff; f32 yDiff; f32 zDiff; f32 bodyYRotTarget; s32 pad; s16 i; - Player* player = GET_PLAYER(globalCtx); + Player* player = GET_PLAYER(play); Boss03_PlayUnderwaterSfx(&this->actor.projectedPos, NA_SE_EN_KONB_WAIT_OLD - SFX_FLAG); @@ -574,8 +572,8 @@ void func_809E34B8(Boss03* this, GlobalContext* globalCtx) { SkelAnime_Update(&this->skelAnime); - Matrix_InsertTranslation(this->actor.world.pos.x, this->actor.world.pos.y, this->actor.world.pos.z, MTXMODE_NEW); - Matrix_RotateY(this->actor.world.rot.y, MTXMODE_APPLY); + 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; @@ -589,10 +587,10 @@ void func_809E34B8(Boss03* this, GlobalContext* globalCtx) { 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); + Math_ApproachF(&this->unk_260, sinf(this->skelAnime.curFrame * (M_PI / 5.0f)) * 10.0f * 0.01f, 0.5f, 1.0f); if ((this->workTimer[WORK_TIMER_UNK2_A] == 0) && (this->actor.bgCheckFlags & 8)) { - Matrix_GetStateTranslationAndScaledZ(-500.0f, &this->unk_268); + 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; @@ -626,18 +624,18 @@ void func_809E34B8(Boss03* this, GlobalContext* globalCtx) { 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); + Boss03_SetupPrepareCharge(this, play); } else if ((player->transformation != PLAYER_FORM_GORON) && (player->transformation != PLAYER_FORM_DEKU)) { if (KREG(70) == 0) { - Boss03_SetupChasePlayer(this, globalCtx); + Boss03_SetupChasePlayer(this, play); } else if (this->numSpawnedSmallFish <= 0) { - Boss03_SetupChasePlayer(this, globalCtx); + Boss03_SetupChasePlayer(this, play); } } } } -void Boss03_SetupChasePlayer(Boss03* this, GlobalContext* globalCtx) { +void Boss03_SetupChasePlayer(Boss03* this, PlayState* play) { this->actionFunc = Boss03_ChasePlayer; Animation_MorphToLoop(&this->skelAnime, &gGyorgFastSwimmingAnim, -10.0f); this->workTimer[WORK_TIMER_CURRENT_ACTION] = 100; @@ -650,8 +648,8 @@ void Boss03_SetupChasePlayer(Boss03* this, GlobalContext* globalCtx) { /** * 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); +void Boss03_ChasePlayer(Boss03* this, PlayState* play) { + Player* player = GET_PLAYER(play); f32 xDiff; f32 yDiff; f32 zDiff; @@ -677,7 +675,7 @@ void Boss03_ChasePlayer(Boss03* this, GlobalContext* globalCtx) { 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); + 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); @@ -693,7 +691,7 @@ void Boss03_ChasePlayer(Boss03* this, GlobalContext* globalCtx) { player->csMode = 0; } - func_809E344C(this, globalCtx); + func_809E344C(this, play); this->workTimer[WORK_TIMER_UNK1_A] = 100; } else { if ((this->waterHeight - 80.0f) < player->actor.world.pos.y) { @@ -706,10 +704,9 @@ void Boss03_ChasePlayer(Boss03* this, GlobalContext* globalCtx) { sp44 = 100.0f; } - Matrix_InsertTranslation(this->actor.world.pos.x, this->actor.world.pos.y, this->actor.world.pos.z, - MTXMODE_NEW); - Matrix_RotateY(this->actor.world.rot.y, MTXMODE_APPLY); - Matrix_GetStateTranslationAndScaledZ(sp44, &sp50); + 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; @@ -723,11 +720,11 @@ void Boss03_ChasePlayer(Boss03* this, GlobalContext* globalCtx) { // Near enough to Player? if (sqrtf(SQ(xDiff) + SQ(zDiff)) < phi_f2) { - Boss03_SetupCatchPlayer(this, globalCtx, sp43); + Boss03_SetupCatchPlayer(this, play, 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); + Actor_Spawn(&play->actorCtx, play, ACTOR_EN_WATER_EFFECT, player->actor.world.pos.x, this->waterHeight, + player->actor.world.pos.z, 0, 0, 0x78, ENWATEREFFECT_309); Boss03_PlayUnderwaterSfx(&this->actor.projectedPos, NA_SE_EN_KONB_SINK_OLD); } @@ -735,10 +732,10 @@ void Boss03_ChasePlayer(Boss03* this, GlobalContext* globalCtx) { } } - Boss03_SpawnDust(this, globalCtx); + Boss03_SpawnDust(this, play); } -void Boss03_SetupCatchPlayer(Boss03* this, GlobalContext* globalCtx, u8 arg2) { +void Boss03_SetupCatchPlayer(Boss03* this, PlayState* play, u8 arg2) { this->actionFunc = Boss03_CatchPlayer; Animation_MorphToLoop(&this->skelAnime, &gGyorgFastSwimmingAnim, -15.0f); this->workTimer[WORK_TIMER_CURRENT_ACTION] = 100; @@ -747,8 +744,8 @@ void Boss03_SetupCatchPlayer(Boss03* this, GlobalContext* globalCtx, u8 arg2) { this->unk_242 = arg2; } -void Boss03_CatchPlayer(Boss03* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); +void Boss03_CatchPlayer(Boss03* this, PlayState* play) { + Player* player = GET_PLAYER(play); f32 xDiff; f32 yDiff; f32 zDiff; @@ -774,7 +771,7 @@ void Boss03_CatchPlayer(Boss03* this, GlobalContext* globalCtx) { 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); + 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); @@ -790,7 +787,7 @@ void Boss03_CatchPlayer(Boss03* this, GlobalContext* globalCtx) { func_80165690(); } - func_809E344C(this, globalCtx); + func_809E344C(this, play); // WORK_TIMER_UNK1_A wasn't set } else { f32 phi_f0; @@ -808,11 +805,11 @@ void Boss03_CatchPlayer(Boss03* this, GlobalContext* globalCtx) { 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)) { + if ((&this->actor != player->actor.parent) && (play->grabPlayer(play, 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); + AudioSfx_PlaySfx(NA_SE_VO_LI_DAMAGE_S, &player->actor.projectedPos, 4, &gSfxDefaultFreqAndVolScale, + &gSfxDefaultFreqAndVolScale, &gSfxDefaultReverb); + Boss03_SetupChewPlayer(this, play); } } else { Math_ApproachS(&this->jawZRot, 0x3200, 2, 0xC00 * phi_f0); @@ -824,22 +821,22 @@ void Boss03_CatchPlayer(Boss03* this, GlobalContext* globalCtx) { Math_ApproachS(&player->actor.shape.rot.y, this->unk_2A2.y, 1, 0x400); } - Boss03_SpawnDust(this, globalCtx); + Boss03_SpawnDust(this, play); } -void Boss03_SetupChewPlayer(Boss03* this, GlobalContext* globalCtx) { +void Boss03_SetupChewPlayer(Boss03* this, PlayState* play) { s16 pitchAngle; Vec3f out; this->actionFunc = Boss03_ChewPlayer; pitchAngle = Math_FAtan2F(this->actor.world.pos.z, this->actor.world.pos.x); - Matrix_RotateY(pitchAngle, MTXMODE_NEW); + Matrix_RotateYS(pitchAngle, MTXMODE_NEW); out.x = 0.0f; out.y = 200.0f; out.z = 700.0f; - Matrix_MultiplyVector3fByState(&out, &this->unk_268); + Matrix_MultVec3f(&out, &this->unk_268); this->unk_276 = 0x800; this->unk_242 = 0; @@ -847,9 +844,9 @@ void Boss03_SetupChewPlayer(Boss03* this, GlobalContext* globalCtx) { this->skelAnime.playSpeed = 1.0f; } -void Boss03_ChewPlayer(Boss03* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); - Input* input = CONTROLLER1(globalCtx); +void Boss03_ChewPlayer(Boss03* this, PlayState* play) { + Player* player = GET_PLAYER(play); + Input* input = CONTROLLER1(&play->state); f32 jawZRotTarget; f32 xDiff; f32 yDiff; @@ -864,8 +861,8 @@ void Boss03_ChewPlayer(Boss03* this, GlobalContext* globalCtx) { SkelAnime_Update(&this->skelAnime); - Matrix_InsertTranslation(this->actor.world.pos.x, this->actor.world.pos.y, this->actor.world.pos.z, MTXMODE_NEW); - Matrix_RotateY(this->actor.world.rot.y, MTXMODE_APPLY); + 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; @@ -877,7 +874,7 @@ void Boss03_ChewPlayer(Boss03* this, GlobalContext* globalCtx) { -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); + 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: @@ -916,10 +913,10 @@ void Boss03_ChewPlayer(Boss03* this, GlobalContext* globalCtx) { player->actor.parent = NULL; player->csMode = 0; func_80165690(); - func_800B8D50(globalCtx, NULL, 10.0f, this->actor.shape.rot.y, 0.0f, 0x20); + func_800B8D50(play, NULL, 10.0f, this->actor.shape.rot.y, 0.0f, 0x20); } - func_809E344C(this, globalCtx); + func_809E344C(this, play); this->workTimer[WORK_TIMER_UNK1_A] = Rand_ZeroFloat(100.0f) + 200.0f; return; @@ -946,7 +943,7 @@ void Boss03_ChewPlayer(Boss03* this, GlobalContext* globalCtx) { } } -void Boss03_SetupPrepareCharge(Boss03* this, GlobalContext* globalCtx) { +void Boss03_SetupPrepareCharge(Boss03* this, PlayState* play) { this->actionFunc = Boss03_PrepareCharge; Animation_MorphToLoop(&this->skelAnime, &gGyorgBackingUpAnim, -15.0f); this->workTimer[WORK_TIMER_CURRENT_ACTION] = Rand_ZeroFloat(30.0f) + 80.0f; @@ -967,9 +964,9 @@ void Boss03_SetupPrepareCharge(Boss03* this, GlobalContext* globalCtx) { /** * Slowly turns back while looking at Player during WORK_TIMER_CURRENT_ACTION frames, then prepares to charge */ -void Boss03_PrepareCharge(Boss03* this, GlobalContext* globalCtx) { +void Boss03_PrepareCharge(Boss03* this, PlayState* play) { f32 posYTarget; - Player* player = GET_PLAYER(globalCtx); + Player* player = GET_PLAYER(play); if (this->workTimer[WORK_TIMER_UNK1_B] != 0) { Boss03_PlayUnderwaterSfx(&this->actor.projectedPos, NA_SE_EN_KONB_WAIT_OLD - SFX_FLAG); @@ -995,10 +992,10 @@ void Boss03_PrepareCharge(Boss03* this, GlobalContext* globalCtx) { // 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); + Boss03_SetupCharge(this, play); } } else if (player->actor.world.pos.y <= this->waterHeight) { - func_809E344C(this, globalCtx); + func_809E344C(this, play); this->workTimer[WORK_TIMER_UNK1_A] = 20; } @@ -1007,8 +1004,8 @@ void Boss03_PrepareCharge(Boss03* this, GlobalContext* globalCtx) { Actor_MoveWithoutGravityReverse(&this->actor); } -void Boss03_SetupCharge(Boss03* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); +void Boss03_SetupCharge(Boss03* this, PlayState* play) { + Player* player = GET_PLAYER(play); this->actionFunc = Boss03_Charge; Animation_MorphToLoop(&this->skelAnime, &gGyorgFastSwimmingAnim, -15.0f); @@ -1018,11 +1015,11 @@ void Boss03_SetupCharge(Boss03* this, GlobalContext* globalCtx) { /** * Charge against the platform, either by clashing against the platform or by preparing to jump over it */ -void Boss03_Charge(Boss03* this, GlobalContext* globalCtx) { +void Boss03_Charge(Boss03* this, PlayState* play) { f32 xDiff; f32 yDiff; f32 zDiff; - Player* player = GET_PLAYER(globalCtx); + Player* player = GET_PLAYER(play); s16 rotXTarget; this->skelAnime.playSpeed = 2.0f; @@ -1041,14 +1038,14 @@ void Boss03_Charge(Boss03* this, GlobalContext* globalCtx) { 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); + 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); + Boss03_SetupJumpOverPlatform(this, play); return; } } @@ -1056,23 +1053,23 @@ void Boss03_Charge(Boss03* this, GlobalContext* globalCtx) { // 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); + func_800BC848(&this->actor, play, 20, 15); + Actor_Spawn(&play->actorCtx, play, ACTOR_EN_WATER_EFFECT, 0.0f, this->waterHeight, 0.0f, 0, 0, 0x96, + ENWATEREFFECT_30C); // 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), + func_800B8D50(play, NULL, 7.0f, Math_FAtan2F(player->actor.world.pos.z, player->actor.world.pos.x), 7.0f, 0); } - func_809E344C(this, globalCtx); + func_809E344C(this, play); this->workTimer[WORK_TIMER_UNK1_A] = 50; } } } -void Boss03_SetupJumpOverPlatform(Boss03* this, GlobalContext* globalCtx) { +void Boss03_SetupJumpOverPlatform(Boss03* this, PlayState* play) { this->actionFunc = Boss03_JumpOverPlatform; this->actor.gravity = -2.0f; this->actor.velocity.y = 30.0f; @@ -1080,7 +1077,7 @@ void Boss03_SetupJumpOverPlatform(Boss03* this, GlobalContext* globalCtx) { Boss03_PlayUnderwaterSfx(&this->actor.projectedPos, NA_SE_EN_KONB_JUMP_OLD); } -void Boss03_JumpOverPlatform(Boss03* this, GlobalContext* globalCtx) { +void Boss03_JumpOverPlatform(Boss03* this, PlayState* play) { this->bubbleEffectSpawnCount = 0; Boss03_PlayUnderwaterSfx(&this->actor.projectedPos, NA_SE_EN_KONB_JUMP_LEV_OLD - SFX_FLAG); @@ -1096,7 +1093,7 @@ void Boss03_JumpOverPlatform(Boss03* this, GlobalContext* globalCtx) { 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); + func_809E344C(this, play); this->workTimer[WORK_TIMER_UNK1_A] = 50; } } else { @@ -1107,7 +1104,7 @@ void Boss03_JumpOverPlatform(Boss03* this, GlobalContext* globalCtx) { 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); + Boss03_SpawnEffectDroplet(play, &sp30); } } } @@ -1116,7 +1113,7 @@ void Boss03_JumpOverPlatform(Boss03* this, GlobalContext* globalCtx) { /* Start of Gyorg's Cutscenes section */ -void Boss03_SetupIntroCutscene(Boss03* this, GlobalContext* globalCtx) { +void Boss03_SetupIntroCutscene(Boss03* this, PlayState* play) { this->actionFunc = Boss03_IntroCutscene; Animation_MorphToLoop(&this->skelAnime, &gGyorgFastSwimmingAnim, -10.0f); this->skelAnime.playSpeed = 2.0f; @@ -1128,7 +1125,7 @@ Vec3f D_809E9104[] = { { 0.0f, 450.0f, 0.0f }, }; -void Boss03_IntroCutscene(Boss03* this, GlobalContext* globalCtx) { +void Boss03_IntroCutscene(Boss03* this, PlayState* play) { s16 i; Vec3f effectPos; f32 xDiff; @@ -1140,7 +1137,7 @@ void Boss03_IntroCutscene(Boss03* this, GlobalContext* globalCtx) { s16 pad2; s16 bubblesToSpawnNum = 0; f32 phi_f2; - Player* player = GET_PLAYER(globalCtx); + Player* player = GET_PLAYER(play); this->bubbleEffectSpawnCount = 0; this->csTimer++; @@ -1151,11 +1148,11 @@ void Boss03_IntroCutscene(Boss03* this, GlobalContext* globalCtx) { 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); + Cutscene_Start(play, &play->csCtx); + func_800B7298(play, &this->actor, 7); + this->subCamId = Play_CreateSubCamera(play); + Play_ChangeCameraStatus(play, CAM_ID_MAIN, CAM_STATUS_WAIT); + Play_ChangeCameraStatus(play, this->subCamId, CAM_STATUS_ACTIVE); this->actor.world.rot.y = -0x7B30; this->prevPlayerPos.y = 1850.0f; @@ -1168,34 +1165,34 @@ void Boss03_IntroCutscene(Boss03* this, GlobalContext* globalCtx) { player->actor.world.pos.y = 1850.0f; player->actor.world.rot.y = player->actor.shape.rot.y; - this->csCamAt.y = player->actor.world.pos.y + 30.0f; + this->subCamAt.y = player->actor.world.pos.y + 30.0f; this->csState = 1; this->csTimer = 0; this->actor.flags &= ~ACTOR_FLAG_1; this->unk_2D5 = true; - this->cameraFov = KREG(14) + 60.0f; + this->subCamFov = KREG(14) + 60.0f; case 1: player->actor.world.pos.z = 0.0f; player->actor.world.pos.x = 0.0f; player->actor.speedXZ = 0.0f; - this->csCamEye.x = 100.0f; - this->csCamEye.y = 540.0f; + this->subCamEye.x = 100.0f; + this->subCamEye.y = 540.0f; - this->csCamEye.z = player->actor.world.pos.z + 100.0f; - this->csCamAt.x = player->actor.world.pos.x; + this->subCamEye.z = player->actor.world.pos.z + 100.0f; + this->subCamAt.x = player->actor.world.pos.x; - Math_ApproachF(&this->csCamAt.y, player->actor.world.pos.y + 30.0f, 0.5f, 100.0f); - this->csCamAt.z = player->actor.world.pos.z; + Math_ApproachF(&this->subCamAt.y, player->actor.world.pos.y + 30.0f, 0.5f, 100.0f); + this->subCamAt.z = player->actor.world.pos.z; if (this->csTimer > 105) { this->csState = 2; this->csTimer = 0; this->unk_240 = 0; func_8016566C(0x96); - this->cameraFov = 80.0f; + this->subCamFov = 80.0f; case 2: Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_KONB_DEMO_MOVE_OLD - SFX_FLAG); @@ -1263,23 +1260,23 @@ void Boss03_IntroCutscene(Boss03* this, GlobalContext* globalCtx) { if (this->csTimer == 5) { // Rotates Player towards Gyorg - func_800B7298(globalCtx, &this->actor, 8); + func_800B7298(play, &this->actor, 8); } - this->csCamEye.x = player->actor.world.pos.x + 30.0f; - this->csCamEye.y = player->actor.world.pos.y + Player_GetHeight(player) - 4.0f + BREG(17); - this->csCamEye.z = player->actor.world.pos.z - 30.0f; + this->subCamEye.x = player->actor.world.pos.x + 30.0f; + this->subCamEye.y = player->actor.world.pos.y + Player_GetHeight(player) - 4.0f + BREG(17); + this->subCamEye.z = player->actor.world.pos.z - 30.0f; - this->csCamAt.x = player->actor.world.pos.x; - this->csCamAt.y = player->actor.world.pos.y + Player_GetHeight(player) - 18.0f + 6.0f + BREG(18); - this->csCamAt.z = player->actor.world.pos.z; + this->subCamAt.x = player->actor.world.pos.x; + this->subCamAt.y = player->actor.world.pos.y + Player_GetHeight(player) - 18.0f + 6.0f + BREG(18); + this->subCamAt.z = player->actor.world.pos.z; if (player->transformation == PLAYER_FORM_FIERCE_DEITY) { - this->csCamEye.y -= 60.0f; - this->csCamAt.y -= 35.0f; + this->subCamEye.y -= 60.0f; + this->subCamAt.y -= 35.0f; } - this->cameraFov = 60.0f; + this->subCamFov = 60.0f; if (this->csTimer == 16) { this->csState = 5; this->csTimer = 0; @@ -1296,13 +1293,13 @@ void Boss03_IntroCutscene(Boss03* this, GlobalContext* globalCtx) { player->actor.shape.rot.y = -0x1470; player->actor.world.rot.y = player->actor.shape.rot.y; - this->csCamEye.x = player->actor.world.pos.x + 30.0f - 90.0f + 300.0f; - this->csCamEye.y = player->actor.world.pos.y + 40.0f + 10.0f; - this->csCamEye.z = player->actor.world.pos.z - 30.0f + 160.0f + 300.0f; + this->subCamEye.x = player->actor.world.pos.x + 30.0f - 90.0f + 300.0f; + this->subCamEye.y = player->actor.world.pos.y + 40.0f + 10.0f; + this->subCamEye.z = player->actor.world.pos.z - 30.0f + 160.0f + 300.0f; - this->csCamAt.x = this->actor.world.pos.x; - this->csCamAt.y = this->actor.world.pos.y - 100.0f; - this->csCamAt.z = this->actor.world.pos.z; + this->subCamAt.x = this->actor.world.pos.x; + this->subCamAt.y = this->actor.world.pos.y - 100.0f; + this->subCamAt.z = this->actor.world.pos.z; if (this->csTimer == 10) { this->actor.velocity.y = 30.0f; @@ -1322,7 +1319,7 @@ void Boss03_IntroCutscene(Boss03* this, GlobalContext* globalCtx) { Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_KONB_JUMP_LEV_OLD - SFX_FLAG); if (this->csTimer == 30) { - TitleCard_InitBossName(&globalCtx->state, &globalCtx->actorCtx.titleCtxt, + TitleCard_InitBossName(&play->state, &play->actorCtx.titleCtxt, Lib_SegmentedToVirtual(gGyorgTitleCardTex), 160, 180, 128, 40); } @@ -1345,39 +1342,39 @@ void Boss03_IntroCutscene(Boss03* this, GlobalContext* globalCtx) { effectPos.y = this->actor.world.pos.y; effectPos.z = randPlusMinusPoint5Scaled(150.0f) + this->actor.world.pos.z; - Boss03_SpawnEffectDroplet(globalCtx, &effectPos); + Boss03_SpawnEffectDroplet(play, &effectPos); } - this->csCamTargetAt.x = this->actor.world.pos.x; - this->csCamTargetAt.y = this->actor.world.pos.y - 100.0f; - this->csCamTargetAt.z = this->actor.world.pos.z; + this->subCamAtNext.x = this->actor.world.pos.x; + this->subCamAtNext.y = this->actor.world.pos.y - 100.0f; + this->subCamAtNext.z = this->actor.world.pos.z; } } else { - Math_ApproachF(&this->csCamEye.x, player->actor.world.pos.x + 30.0f - 90.0f + 300.0f - 90.0f, 0.05f, + Math_ApproachF(&this->subCamEye.x, player->actor.world.pos.x + 30.0f - 90.0f + 300.0f - 90.0f, 0.05f, 3.0f); - Math_ApproachF(&this->csCamEye.y, player->actor.world.pos.y + 40.0f + 10.0f + 90.0f, 0.05f, 3.0f); - Math_ApproachF(&this->csCamEye.z, player->actor.world.pos.z - 30.0f + 160.0f + 300.0f - 90.0f, 0.05f, + Math_ApproachF(&this->subCamEye.y, player->actor.world.pos.y + 40.0f + 10.0f + 90.0f, 0.05f, 3.0f); + Math_ApproachF(&this->subCamEye.z, player->actor.world.pos.z - 30.0f + 160.0f + 300.0f - 90.0f, 0.05f, 3.0f); Math_ApproachF(&this->unk_568, 90.0f, 0.05f, 3.0f); } - Math_ApproachF(&this->csCamAt.x, this->csCamTargetAt.x, 0.5f, 100.0f); - Math_ApproachF(&this->csCamAt.y, this->csCamTargetAt.y + this->unk_568, 0.5f, 100.0f); - Math_ApproachF(&this->csCamAt.z, this->csCamTargetAt.z, 0.5f, 100.0f); + Math_ApproachF(&this->subCamAt.x, this->subCamAtNext.x, 0.5f, 100.0f); + Math_ApproachF(&this->subCamAt.y, this->subCamAtNext.y + this->unk_568, 0.5f, 100.0f); + Math_ApproachF(&this->subCamAt.z, this->subCamAtNext.z, 0.5f, 100.0f); if (this->csTimer == 145) { - Camera* camera = Play_GetCamera(globalCtx, CAM_ID_MAIN); + Camera* mainCam = Play_GetCamera(play, CAM_ID_MAIN); - camera->eye = this->csCamEye; - camera->eyeNext = this->csCamEye; - camera->at = this->csCamAt; + mainCam->eye = this->subCamEye; + mainCam->eyeNext = this->subCamEye; + mainCam->at = this->subCamAt; - func_80169AFC(globalCtx, this->csCamId, 0); - Cutscene_End(globalCtx, &globalCtx->csCtx); - func_800B7298(globalCtx, &this->actor, 6); - this->csCamId = 0; + func_80169AFC(play, this->subCamId, 0); + Cutscene_End(play, &play->csCtx); + func_800B7298(play, &this->actor, 6); + this->subCamId = SUB_CAM_ID_DONE; - func_809E344C(this, globalCtx); + func_809E344C(this, play); this->workTimer[WORK_TIMER_UNK1_A] = 50; gSaveContext.eventInf[5] |= 0x40; @@ -1394,31 +1391,30 @@ void Boss03_IntroCutscene(Boss03* this, GlobalContext* globalCtx) { phi_f2 = CLAMP_MAX(phi_f2, 0.12f); sp5C = Math_SinS(this->unk_240 * sp5A) * phi_f2; - Matrix_InsertTranslation(this->actor.world.pos.x, this->actor.world.pos.y, this->actor.world.pos.z, - MTXMODE_NEW); - Matrix_RotateY(this->actor.world.rot.y, MTXMODE_APPLY); - Matrix_InsertYRotation_f(sp5C, MTXMODE_APPLY); - Matrix_InsertXRotation_s(this->actor.world.rot.x, MTXMODE_APPLY); - Matrix_GetStateTranslationAndScaledZ(100.0f, &this->csCamAt); + 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->subCamAt); - this->csCamEye = this->actor.world.pos; + this->subCamEye = this->actor.world.pos; for (i = 0; i < bubblesToSpawnNum; i++) { - effectPos.x = randPlusMinusPoint5Scaled(100.0f) + this->csCamAt.x; - effectPos.y = (randPlusMinusPoint5Scaled(100.0f) + this->csCamAt.y) - 150.0f; - effectPos.z = randPlusMinusPoint5Scaled(100.0f) + this->csCamAt.z; + effectPos.x = randPlusMinusPoint5Scaled(100.0f) + this->subCamAt.x; + effectPos.y = (randPlusMinusPoint5Scaled(100.0f) + this->subCamAt.y) - 150.0f; + effectPos.z = randPlusMinusPoint5Scaled(100.0f) + this->subCamAt.z; - Boss03_SpawnEffectBubble(globalCtx, &effectPos); + Boss03_SpawnEffectBubble(play, &effectPos); } } - if (this->csCamId != 0) { - Play_CameraSetAtEye(globalCtx, this->csCamId, &this->csCamAt, &this->csCamEye); - Play_CameraSetFov(globalCtx, this->csCamId, this->cameraFov); + if (this->subCamId != SUB_CAM_ID_DONE) { + Play_SetCameraAtEye(play, this->subCamId, &this->subCamAt, &this->subCamEye); + Play_SetCameraFov(play, this->subCamId, this->subCamFov); } } -void Boss03_SetupDeathCutscene(Boss03* this, GlobalContext* globalCtx) { +void Boss03_SetupDeathCutscene(Boss03* this, PlayState* play) { this->actionFunc = Boss03_DeathCutscene; Animation_MorphToLoop(&this->skelAnime, &gGyorgFloppingAnim, -10.0f); this->floppingAnimLastFrame = Animation_GetLastFrame(&gGyorgFloppingAnim); @@ -1429,7 +1425,7 @@ void Boss03_SetupDeathCutscene(Boss03* this, GlobalContext* globalCtx) { this->actor.flags &= ~ACTOR_FLAG_1; } -void Boss03_DeathCutscene(Boss03* this, GlobalContext* globalCtx) { +void Boss03_DeathCutscene(Boss03* this, PlayState* play) { s16 i; Vec3f sp90; Vec3f sp84; @@ -1439,12 +1435,12 @@ void Boss03_DeathCutscene(Boss03* this, GlobalContext* globalCtx) { s32 pad; f32 pad2; f32 sp64; - Camera* camera = Play_GetCamera(globalCtx, CAM_ID_MAIN); + Camera* mainCam = Play_GetCamera(play, CAM_ID_MAIN); Player* player; f32 sp4C; aux2 = 0.0f; - player = GET_PLAYER(globalCtx); + player = GET_PLAYER(play); sp64 = this->actor.scale.x * 5.0f; this->csTimer++; @@ -1452,11 +1448,11 @@ void Boss03_DeathCutscene(Boss03* this, GlobalContext* globalCtx) { 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); + Cutscene_Start(play, &play->csCtx); + func_800B7298(play, &this->actor, 1); + this->subCamId = Play_CreateSubCamera(play); + Play_ChangeCameraStatus(play, CAM_ID_MAIN, CAM_STATUS_WAIT); + Play_ChangeCameraStatus(play, this->subCamId, CAM_STATUS_ACTIVE); this->unk_2BE = Math_FAtan2F(this->actor.world.pos.z, this->actor.world.pos.x); // Player is above water && Player is standing on ground @@ -1468,15 +1464,15 @@ void Boss03_DeathCutscene(Boss03* this, GlobalContext* globalCtx) { case 1: this->csTimer = 0; this->csState = 2; - this->csCamEye.x = camera->eye.x; - this->csCamEye.y = camera->eye.y; - this->csCamEye.z = camera->eye.z; - this->csCamAt.x = camera->at.x; - this->csCamAt.y = camera->at.y; - this->csCamAt.z = camera->at.z; + this->subCamEye.x = mainCam->eye.x; + this->subCamEye.y = mainCam->eye.y; + this->subCamEye.z = mainCam->eye.z; + this->subCamAt.x = mainCam->at.x; + this->subCamAt.y = mainCam->at.y; + this->subCamAt.z = mainCam->at.z; - aux = this->csCamEye.x - this->actor.world.pos.x; - this->unk_568 = Math_Acot2F(this->csCamEye.z - this->actor.world.pos.z, aux); + aux = this->subCamEye.x - this->actor.world.pos.x; + this->unk_568 = Math_Acot2F(this->subCamEye.z - this->actor.world.pos.z, aux); this->unk_570 = 0.0f; this->unk_56C = 0.0f; @@ -1486,26 +1482,26 @@ void Boss03_DeathCutscene(Boss03* this, GlobalContext* globalCtx) { sp90.y = (50.0f * sp64) + 150.0f; sp90.z = (400.0f * sp64) + 300.0f; - this->csCamTargetAt.x = this->actor.world.pos.x; - this->csCamTargetAt.y = this->actor.world.pos.y; - this->csCamTargetAt.z = this->actor.world.pos.z; + this->subCamAtNext.x = this->actor.world.pos.x; + this->subCamAtNext.y = this->actor.world.pos.y; + this->subCamAtNext.z = this->actor.world.pos.z; this->unk_568 += this->unk_56C; - Matrix_InsertYRotation_f(this->unk_568, MTXMODE_NEW); - Matrix_MultiplyVector3fByState(&sp90, &this->csCamTargetEye); + Matrix_RotateYF(this->unk_568, MTXMODE_NEW); + Matrix_MultVec3f(&sp90, &this->subCamEyeNext); - this->csCamTargetEye.x += this->actor.world.pos.x; - this->csCamTargetEye.y += this->waterHeight; - this->csCamTargetEye.z += this->actor.world.pos.z; + this->subCamEyeNext.x += this->actor.world.pos.x; + this->subCamEyeNext.y += this->waterHeight; + this->subCamEyeNext.z += this->actor.world.pos.z; sp4C = 40.0f + aux2; - Math_ApproachF(&this->csCamEye.x, this->csCamTargetEye.x, 0.1f, sp4C); - Math_ApproachF(&this->csCamEye.y, this->csCamTargetEye.y, 0.1f, sp4C); - Math_ApproachF(&this->csCamEye.z, this->csCamTargetEye.z, 0.1f, sp4C); + Math_ApproachF(&this->subCamEye.x, this->subCamEyeNext.x, 0.1f, sp4C); + Math_ApproachF(&this->subCamEye.y, this->subCamEyeNext.y, 0.1f, sp4C); + Math_ApproachF(&this->subCamEye.z, this->subCamEyeNext.z, 0.1f, sp4C); sp4C = 70.0f + aux2; - Math_ApproachF(&this->csCamAt.x, this->csCamTargetAt.x, 0.1f, sp4C); - Math_ApproachF(&this->csCamAt.y, this->csCamTargetAt.y, 0.1f, sp4C); - Math_ApproachF(&this->csCamAt.z, this->csCamTargetAt.z, 0.1f, sp4C); + Math_ApproachF(&this->subCamAt.x, this->subCamAtNext.x, 0.1f, sp4C); + Math_ApproachF(&this->subCamAt.y, this->subCamAtNext.y, 0.1f, sp4C); + Math_ApproachF(&this->subCamAt.z, this->subCamAtNext.z, 0.1f, sp4C); } break; } @@ -1517,8 +1513,8 @@ void Boss03_DeathCutscene(Boss03* this, GlobalContext* globalCtx) { Math_ApproachF(&this->actor.world.pos.y, Math_SinS(this->unk_240 * 0x1000) * 80.0f + this->waterHeight, 1.0f, 10.0f); this->actor.shape.rot.z += 0x100; - Matrix_RotateY(this->unk_2BE, MTXMODE_NEW); - Matrix_GetStateTranslationAndScaledZ(500.0f, &sp84); + 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); @@ -1531,8 +1527,8 @@ void Boss03_DeathCutscene(Boss03* this, GlobalContext* globalCtx) { 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); + Actor_Spawn(&play->actorCtx, play, ACTOR_EN_WATER_EFFECT, this->actor.world.pos.x, this->waterHeight, + this->actor.world.pos.z, 0, 0, 0x78, ENWATEREFFECT_309); if (this->actionFunc == Boss03_DeathCutscene) { if ((D_809E9840 % 2) != 0) { @@ -1607,33 +1603,33 @@ void Boss03_DeathCutscene(Boss03* this, GlobalContext* globalCtx) { 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); + Boss03_SpawnEffectDroplet(play, &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); + Actor_SpawnAsChild(&play->actorCtx, &this->actor, play, ACTOR_DOOR_WARP1, 0.0f, PLATFORM_HEIGHT, 200.0f, + 0, 0, 0, ENDOORWARP1_FF_1); + Actor_Spawn(&play->actorCtx, play, ACTOR_ITEM_B_HEART, 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); + AudioSfx_StopByPos(&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); + mainCam = Play_GetCamera(play, CAM_ID_MAIN); + mainCam->eye = this->subCamEye; + mainCam->eyeNext = this->subCamEye; + mainCam->at = this->subCamAt; + func_80169AFC(play, this->subCamId, 0); + this->subCamId = SUB_CAM_ID_DONE; + Cutscene_End(play, &play->csCtx); + func_800B7298(play, &this->actor, 6); this->csState = 3; func_80165690(); Boss03_PlayUnderwaterSfx(&this->actor.projectedPos, NA_SE_EN_KONB_INIT_OLD); @@ -1646,31 +1642,31 @@ void Boss03_DeathCutscene(Boss03* this, GlobalContext* globalCtx) { break; } - if (this->csCamId != 0) { - Play_CameraSetAtEye(globalCtx, this->csCamId, &this->csCamAt, &this->csCamEye); + if (this->subCamId != SUB_CAM_ID_DONE) { + Play_SetCameraAtEye(play, this->subCamId, &this->subCamAt, &this->subCamEye); } } -void Boss03_SetupSpawnSmallFishesCutscene(Boss03* this, GlobalContext* globalCtx) { +void Boss03_SetupSpawnSmallFishesCutscene(Boss03* this, PlayState* play) { 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); +void Boss03_SpawnSmallFishesCutscene(Boss03* this, PlayState* play) { + Player* player = GET_PLAYER(play); 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); + Cutscene_Start(play, &play->csCtx); + func_800B7298(play, &this->actor, 1); + this->subCamId = Play_CreateSubCamera(play); + Play_ChangeCameraStatus(play, CAM_ID_MAIN, CAM_STATUS_WAIT); + Play_ChangeCameraStatus(play, this->subCamId, CAM_STATUS_ACTIVE); this->csState = 1; this->unk_2BE = 0xBB8; @@ -1692,14 +1688,14 @@ void Boss03_SpawnSmallFishesCutscene(Boss03* this, GlobalContext* globalCtx) { player->actor.shape.rot.y = player->actor.world.rot.y = this->actor.world.rot.y + 0x8000; - Matrix_InsertTranslation(this->actor.world.pos.x, this->actor.world.pos.y, this->actor.world.pos.z, - MTXMODE_NEW); - Matrix_RotateY(this->actor.shape.rot.y + this->unk_2BE, MTXMODE_APPLY); - Matrix_GetStateTranslationAndScaledZ(340.0f, &this->csCamEye); + 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->subCamEye); - this->csCamAt.x = this->actor.world.pos.x; - this->csCamAt.y = this->actor.world.pos.y; - this->csCamAt.z = this->actor.world.pos.z; + this->subCamAt.x = this->actor.world.pos.x; + this->subCamAt.y = this->actor.world.pos.y; + this->subCamAt.z = this->actor.world.pos.z; Math_ApproachS(&this->unk_2BE, -4000, 10, 70); @@ -1707,7 +1703,7 @@ void Boss03_SpawnSmallFishesCutscene(Boss03* this, GlobalContext* globalCtx) { 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, + Actor_SpawnAsChild(&play->actorCtx, &this->actor, play, 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++; @@ -1719,27 +1715,26 @@ void Boss03_SpawnSmallFishesCutscene(Boss03* this, GlobalContext* globalCtx) { } if (this->csTimer >= 150) { - Camera* camera; + Camera* mainCam = Play_GetCamera(play, CAM_ID_MAIN); - camera = Play_GetCamera(globalCtx, CAM_ID_MAIN); - camera->eye = this->csCamEye; - camera->eyeNext = this->csCamEye; - camera->at = this->csCamAt; + mainCam->eye = this->subCamEye; + mainCam->eyeNext = this->subCamEye; + mainCam->at = this->subCamAt; - func_80169AFC(globalCtx, this->csCamId, 0); - this->csCamId = 0; - Cutscene_End(globalCtx, &globalCtx->csCtx); - func_800B7298(globalCtx, &this->actor, 6); + func_80169AFC(play, this->subCamId, 0); + this->subCamId = SUB_CAM_ID_DONE; + Cutscene_End(play, &play->csCtx); + func_800B7298(play, &this->actor, 6); - func_809E344C(this, globalCtx); + func_809E344C(this, play); this->workTimer[WORK_TIMER_UNK1_A] = 50; } } break; } - if (this->csCamId != 0) { - Play_CameraSetAtEye(globalCtx, this->csCamId, &this->csCamAt, &this->csCamEye); + if (this->subCamId != SUB_CAM_ID_DONE) { + Play_SetCameraAtEye(play, this->subCamId, &this->subCamAt, &this->subCamEye); } } @@ -1747,8 +1742,8 @@ void Boss03_SpawnSmallFishesCutscene(Boss03* this, GlobalContext* globalCtx) { /* Start of Gyorg's More actionFuncs and Update section */ -void Boss03_SetupStunned(Boss03* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); +void Boss03_SetupStunned(Boss03* this, PlayState* play) { + Player* player = GET_PLAYER(play); if (this->actionFunc != Boss03_Stunned) { Animation_MorphToLoop(&this->skelAnime, &gGyorgStunnedAnim, -15.0f); @@ -1766,7 +1761,7 @@ void Boss03_SetupStunned(Boss03* this, GlobalContext* globalCtx) { this->unk_240 = 0; } -void Boss03_Stunned(Boss03* this, GlobalContext* globalCtx) { +void Boss03_Stunned(Boss03* this, PlayState* play) { this->actor.hintId = 0x29; if (this->unk_240 >= 16) { @@ -1780,7 +1775,7 @@ void Boss03_Stunned(Boss03* this, GlobalContext* globalCtx) { Actor_MoveWithGravity(&this->actor); if (this->actor.bgCheckFlags & 2) { play_sound(NA_SE_IT_WALL_HIT_HARD); - func_800BC848(&this->actor, globalCtx, 10, 10); + func_800BC848(&this->actor, play, 10, 10); } } else { Math_ApproachS(&this->actor.shape.rot.z, -0x6000, 0xA, 0x900); @@ -1793,12 +1788,12 @@ void Boss03_Stunned(Boss03* this, GlobalContext* globalCtx) { } if (this->workTimer[WORK_TIMER_STUNNED] == 0) { - func_809E344C(this, globalCtx); + func_809E344C(this, play); // WORK_TIMER_UNK1_A wasn't set } } -void Boss03_SetupDamaged(Boss03* this, GlobalContext* globalCtx) { +void Boss03_SetupDamaged(Boss03* this, PlayState* play) { Animation_MorphToLoop(&this->skelAnime, &gGyorgFloppingAnim, -10.0f); this->actionFunc = Boss03_Damaged; this->workTimer[WORK_TIMER_CURRENT_ACTION] = 30; @@ -1807,7 +1802,7 @@ void Boss03_SetupDamaged(Boss03* this, GlobalContext* globalCtx) { /** * Invulnerability period by being damaged by Player */ -void Boss03_Damaged(Boss03* this, GlobalContext* globalCtx) { +void Boss03_Damaged(Boss03* this, PlayState* play) { this->unk_25C = 15; SkelAnime_Update(&this->skelAnime); @@ -1819,22 +1814,22 @@ void Boss03_Damaged(Boss03* this, GlobalContext* globalCtx) { if ((s8)this->actor.colChkInfo.health <= 5) { if (!this->hasSpwanedSmallFishes) { this->hasSpwanedSmallFishes++; - Boss03_SetupSpawnSmallFishesCutscene(this, globalCtx); + Boss03_SetupSpawnSmallFishesCutscene(this, play); return; } } - func_809E344C(this, globalCtx); + func_809E344C(this, play); this->workTimer[WORK_TIMER_UNK1_A] = 100; } } /* End of ActionFuncs section */ -void Boss03_UpdateCollision(Boss03* this, GlobalContext* globalCtx) { +void Boss03_UpdateCollision(Boss03* this, PlayState* play) { ColliderInfo* hitbox; u8 sp4B = true; - Player* player = GET_PLAYER(globalCtx); + Player* player = GET_PLAYER(play); s32 i; s32 phi_v1; u32 phi_v0; @@ -1887,10 +1882,10 @@ void Boss03_UpdateCollision(Boss03* this, GlobalContext* globalCtx) { 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); + Boss03_SetupDeathCutscene(this, play); + Enemy_StartFinishingBlow(play, &this->actor); } else { - Boss03_SetupDamaged(this, globalCtx); + Boss03_SetupDamaged(this, play); Boss03_PlayUnderwaterSfx(&this->actor.projectedPos, NA_SE_EN_KONB_DAMAGE_OLD); } return; @@ -1905,7 +1900,7 @@ void Boss03_UpdateCollision(Boss03* this, GlobalContext* globalCtx) { this->unk_25C = 15; if (this->actionFunc != stunnedActionFunc) { - Boss03_SetupStunned(this, globalCtx); + Boss03_SetupStunned(this, play); Boss03_PlayUnderwaterSfx(&this->actor.projectedPos, NA_SE_EN_KONB_DAMAGE_OLD); if (&this->actor == player->actor.parent) { @@ -1935,10 +1930,10 @@ void Boss03_UpdateCollision(Boss03* this, GlobalContext* globalCtx) { 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); + Enemy_StartFinishingBlow(play, &this->actor); + Boss03_SetupDeathCutscene(this, play); } else { - Boss03_SetupDamaged(this, globalCtx); + Boss03_SetupDamaged(this, play); Boss03_PlayUnderwaterSfx(&this->actor.projectedPos, NA_SE_EN_KONB_DAMAGE_OLD); } } @@ -1948,11 +1943,11 @@ void Boss03_UpdateCollision(Boss03* this, GlobalContext* globalCtx) { } } -void Boss03_Update(Actor* thisx, GlobalContext* globalCtx2) { - GlobalContext* globalCtx = globalCtx2; +void Boss03_Update(Actor* thisx, PlayState* play2) { + PlayState* play = play2; Boss03* this = THIS; Actor* dblueActor; - Player* player = GET_PLAYER(globalCtx); + Player* player = GET_PLAYER(play); s32 i; Vec3f wetSpotPos; Vec3f bubblePos; @@ -1994,13 +1989,13 @@ void Boss03_Update(Actor* thisx, GlobalContext* globalCtx2) { this->unk_25E--; } - this->actionFunc(this, globalCtx); + this->actionFunc(this, play); 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); + Actor_UpdateBgCheckInfo(play, &this->actor, 50.0f, 150.0f, 100.0f, 5); this->actor.world.pos.y += 100.0f; this->actor.prevPos.y += 100.0f; } @@ -2016,8 +2011,8 @@ void Boss03_Update(Actor* thisx, GlobalContext* globalCtx2) { 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); + Actor_Spawn(&play->actorCtx, play, ACTOR_EN_WATER_EFFECT, this->actor.world.pos.x, this->waterHeight, + this->actor.world.pos.z, 0, 0, 0x78, ENWATEREFFECT_309); this->unk_280 = 27; this->unk_284 = this->actor.world.pos.x; @@ -2033,29 +2028,29 @@ void Boss03_Update(Actor* thisx, GlobalContext* globalCtx2) { this->bodyCollider.base.colType = COLTYPE_METAL; } - Boss03_UpdateCollision(this, globalCtx); + Boss03_UpdateCollision(this, play); - CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->bodyCollider.base); + CollisionCheck_SetAC(play, &play->colChkCtx, &this->bodyCollider.base); if (player->transformation == PLAYER_FORM_HUMAN) { - CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->headCollider.base); + CollisionCheck_SetAC(play, &play->colChkCtx, &this->headCollider.base); } if (!this->unk_2BD) { if (player->transformation != PLAYER_FORM_HUMAN) { - CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->headCollider.base); + CollisionCheck_SetAC(play, &play->colChkCtx, &this->headCollider.base); } - CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->headCollider.base); - CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->bodyCollider.base); + CollisionCheck_SetOC(play, &play->colChkCtx, &this->headCollider.base); + CollisionCheck_SetOC(play, &play->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); + CollisionCheck_SetAT(play, &play->colChkCtx, &this->headCollider.base); + CollisionCheck_SetAT(play, &play->colChkCtx, &this->bodyCollider.base); } } - dblueActor = Boss03_FindActorDblueMovebg(globalCtx); + dblueActor = Boss03_FindActorDblueMovebg(play); if (dblueActor != NULL) { dblueActor->world.pos.y = this->waterHeight; } @@ -2065,8 +2060,8 @@ void Boss03_Update(Actor* thisx, GlobalContext* globalCtx2) { 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; + 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); @@ -2081,12 +2076,12 @@ void Boss03_Update(Actor* thisx, GlobalContext* globalCtx2) { bubblePos.y = randPlusMinusPoint5Scaled(100.0f) + this->actor.world.pos.y; bubblePos.z = randPlusMinusPoint5Scaled(100.0f) + this->actor.world.pos.z; - Boss03_SpawnEffectBubble(globalCtx, &bubblePos); + Boss03_SpawnEffectBubble(play, &bubblePos); } } this->bubbleEffectSpawnCount = 1; - Boss03_UpdateEffects(globalCtx); + Boss03_UpdateEffects(play); if (D_809E9841 != 0) { D_809E9841--; @@ -2112,7 +2107,7 @@ void Boss03_Update(Actor* thisx, GlobalContext* globalCtx2) { 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); + Boss03_SpawnEffectWetSpot(play, &wetSpotPos); } } @@ -2132,14 +2127,14 @@ void Boss03_Update(Actor* thisx, GlobalContext* globalCtx2) { yRot = 0.0f; for (j = 0, i = 0; i < 20; j++) { - Matrix_InsertYRotation_f(yRot, MTXMODE_NEW); - Matrix_GetStateTranslationAndScaledZ(Rand_ZeroFloat(60.000004f) + 312.0f, &dropletPos); + 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); + Boss03_SpawnEffectDroplet(play, &dropletPos); i++; } @@ -2155,21 +2150,20 @@ void Boss03_Update(Actor* thisx, GlobalContext* globalCtx2) { /* Start of Gyorg's Draw section */ -void Boss03_SetObject(GlobalContext* globalCtx, s16 objectId) { - s32 objectIndex = Object_GetIndex(&globalCtx->objectCtx, objectId); +void Boss03_SetObject(PlayState* play, s16 objectId) { + s32 objectIndex = Object_GetIndex(&play->objectCtx, objectId); - OPEN_DISPS(globalCtx->state.gfxCtx); + OPEN_DISPS(play->state.gfxCtx); - gSegments[6] = PHYSICAL_TO_VIRTUAL(globalCtx->objectCtx.status[objectIndex].segment); + gSegments[6] = PHYSICAL_TO_VIRTUAL(play->objectCtx.status[objectIndex].segment); - gSPSegment(POLY_OPA_DISP++, 0x06, globalCtx->objectCtx.status[objectIndex].segment); - gSPSegment(POLY_XLU_DISP++, 0x06, globalCtx->objectCtx.status[objectIndex].segment); + gSPSegment(POLY_OPA_DISP++, 0x06, play->objectCtx.status[objectIndex].segment); + gSPSegment(POLY_XLU_DISP++, 0x06, play->objectCtx.status[objectIndex].segment); - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->state.gfxCtx); } -s32 Boss03_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, - Actor* thisx) { +s32 Boss03_OverrideLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, Actor* thisx) { Boss03* this = THIS; if ((limbIndex == GYORG_LIMB_UPPER_TRUNK) || (limbIndex == GYORG_LIMB_LOWER_TRUNK) || @@ -2228,20 +2222,20 @@ Vec3f D_809E9154[] = { 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) { +void Boss03_PostLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx) { Boss03* this = THIS; s32 pad; s8 sphereElementIndex; Vec3f spherePos; - Player* player = GET_PLAYER(globalCtx); + Player* player = GET_PLAYER(play); if (limbIndex == GYORG_LIMB_HEAD) { - Matrix_MultiplyVector3fByState(&D_809E9148, &this->actor.focus.pos); + Matrix_MultVec3f(&D_809E9148, &this->actor.focus.pos); } sphereElementIndex = sGyorgSphElementIndices[limbIndex]; if (sphereElementIndex >= 0) { - Matrix_MultiplyVector3fByState(&D_809E9154[sphereElementIndex], &spherePos); + Matrix_MultVec3f(&D_809E9154[sphereElementIndex], &spherePos); if (sphereElementIndex < 2) { if ((this->actionFunc == Boss03_Stunned) && (this->waterHeight < player->actor.world.pos.y)) { @@ -2258,44 +2252,44 @@ void Boss03_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, V MtxF mf; D_809E91B4.x = this->unk_2C4 + 300.0f; - Matrix_MultiplyVector3fByState(&D_809E91B4, &this->insideJawPos); - Matrix_CopyCurrentState(&mf); - func_8018219C(&mf, &this->unk_2A2, 0); + Matrix_MultVec3f(&D_809E91B4, &this->insideJawPos); + Matrix_Get(&mf); + Matrix_MtxFToYXZRot(&mf, &this->unk_2A2, false); } } -void Boss03_Draw(Actor* thisx, GlobalContext* globalCtx) { +void Boss03_Draw(Actor* thisx, PlayState* play) { Boss03* this = THIS; - OPEN_DISPS(globalCtx->state.gfxCtx); + OPEN_DISPS(play->state.gfxCtx); - func_8012C28C(globalCtx->state.gfxCtx); + func_8012C28C(play->state.gfxCtx); if (!this->unk_2D5) { if ((this->unk_25E % 2) != 0) { POLY_OPA_DISP = Gfx_SetFog(POLY_OPA_DISP, 255, 0, 0, 255, 900, 1099); } - Matrix_InsertYRotation_f(this->unk_260, MTXMODE_APPLY); - Matrix_InsertTranslation(0.0f, -600.0f, 0.0f, MTXMODE_APPLY); - SkelAnime_DrawFlexOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, - this->skelAnime.dListCount, Boss03_OverrideLimbDraw, Boss03_PostLimbDraw, &this->actor); - POLY_OPA_DISP = func_801660B8(globalCtx, POLY_OPA_DISP); + Matrix_RotateYF(this->unk_260, MTXMODE_APPLY); + Matrix_Translate(0.0f, -600.0f, 0.0f, MTXMODE_APPLY); + SkelAnime_DrawFlexOpa(play, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, + Boss03_OverrideLimbDraw, Boss03_PostLimbDraw, &this->actor); + POLY_OPA_DISP = func_801660B8(play, POLY_OPA_DISP); } this->unk_2BC = 0; - Boss03_DrawEffects(globalCtx); + Boss03_DrawEffects(play); - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->state.gfxCtx); } /* End of Gyorg's Draw section */ /* Start of Effect Update/Draw section */ -void Boss03_UpdateEffects(GlobalContext* globalCtx) { - GyorgEffect* eff = globalCtx->specialEffects; +void Boss03_UpdateEffects(PlayState* play) { + GyorgEffect* eff = play->specialEffects; s16 i; Vec3f sp94; Vec3f velocity; @@ -2332,7 +2326,7 @@ void Boss03_UpdateEffects(GlobalContext* globalCtx) { if (eff->pos.y <= WATER_HEIGHT) { eff->type = GYORG_EFFECT_NONE; eff->pos.y = WATER_HEIGHT; - EffectSsGRipple_Spawn(globalCtx, &eff->pos, 0, 80, 0); + EffectSsGRipple_Spawn(play, &eff->pos, 0, 80, 0); } else if (eff->pos.y <= PLATFORM_HEIGHT) { s16 j; @@ -2346,12 +2340,12 @@ void Boss03_UpdateEffects(GlobalContext* globalCtx) { eff->alphaDelta = Rand_ZeroFloat(4.0f) + 5.0f; for (j = 0; j < 4; j++) { - Matrix_InsertYRotation_f((2.0f * (j * M_PI)) / 6.0f, 0); + 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_MultiplyVector3fByState(&sp94, &velocity); - Boss03_SpawnEffectSplash(globalCtx, &eff->pos, &velocity); + Matrix_MultVec3f(&sp94, &velocity); + Boss03_SpawnEffectSplash(play, &eff->pos, &velocity); } } } else if (eff->type == GYORG_EFFECT_SPLASH) { @@ -2390,17 +2384,17 @@ void Boss03_UpdateEffects(GlobalContext* globalCtx) { } } -void Boss03_DrawEffects(GlobalContext* globalCtx) { +void Boss03_DrawEffects(PlayState* play) { u8 flag = false; s16 i; - GraphicsContext* gfxCtx = globalCtx->state.gfxCtx; + GraphicsContext* gfxCtx = play->state.gfxCtx; s32 pad; - GyorgEffect* eff = globalCtx->specialEffects; + GyorgEffect* eff = play->specialEffects; GyorgEffect* effFirst = eff; OPEN_DISPS(gfxCtx); - func_8012C2DC(globalCtx->state.gfxCtx); + func_8012C2DC(play->state.gfxCtx); func_8012C28C(gfxCtx); for (i = 0; i < GYORG_EFFECT_COUNT; i++, eff++) { @@ -2413,19 +2407,18 @@ void Boss03_DrawEffects(GlobalContext* globalCtx) { flag = true; } - Matrix_InsertTranslation(eff->pos.x, eff->pos.y, eff->pos.z, MTXMODE_NEW); + 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_NormalizeXYZ(&globalCtx->billboardMtxF); + Matrix_ReplaceRotation(&play->billboardMtxF); - gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), - G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_OPA_DISP++, gGyorgBubbleModelDL); } } eff = effFirst; - Boss03_SetObject(globalCtx, OBJECT_WATER_EFFECT); + Boss03_SetObject(play, OBJECT_WATER_EFFECT); flag = false; @@ -2444,18 +2437,16 @@ void Boss03_DrawEffects(GlobalContext* globalCtx) { gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, (u8)eff->unk_40, (u8)((((void)0, eff->unk_40) + 55.0f)), 225, 150); - Matrix_InsertTranslation(eff->pos.x, eff->pos.y, eff->pos.z, MTXMODE_NEW); + Matrix_Translate(eff->pos.x, eff->pos.y, eff->pos.z, MTXMODE_NEW); if (eff->type == GYORG_EFFECT_DROPLET) { - Matrix_InsertYRotation_f(Camera_GetInputDirYaw(globalCtx->cameraPtrs[globalCtx->activeCamera]) * - (M_PI / 0x8000), - MTXMODE_APPLY); + Matrix_RotateYF(Camera_GetInputDirYaw(GET_ACTIVE_CAM(play)) * (M_PI / 0x8000), MTXMODE_APPLY); } else { // GYORG_EFFECT_SPLASH - Matrix_NormalizeXYZ(&globalCtx->billboardMtxF); + Matrix_ReplaceRotation(&play->billboardMtxF); } Matrix_Scale(eff->unk_34.x, eff->unk_34.y, 1.0f, MTXMODE_APPLY); - Matrix_InsertZRotation_f(eff->unk_34.z, 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); @@ -2481,17 +2472,17 @@ void Boss03_DrawEffects(GlobalContext* globalCtx) { gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, (s16)eff->unk_40, ((void)0, ((s16)eff->unk_40) + 55), 225, eff->alpha); - Matrix_InsertTranslation(eff->pos.x, eff->pos.y, eff->pos.z, MTXMODE_NEW); + Matrix_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_InsertYRotation_f(eff->unk_34.z, 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); + Boss03_SetObject(play, OBJECT_BOSS03); CLOSE_DISPS(gfxCtx); } @@ -2504,13 +2495,13 @@ void Boss03_DrawEffects(GlobalContext* globalCtx) { #define SEAWEED_FLAG_INTERACT_PLAYER 1 #define SEAWEED_FLAG_INTERACT_GYORG 2 -void Boss03_SeaweedUpdate(Actor* thisx, GlobalContext* globalCtx) { +void Boss03_SeaweedUpdate(Actor* thisx, PlayState* play) { Boss03* this = THIS; s16 i; s16 pad; s16 maxBendSpeed; u8 flag; - Player* player = GET_PLAYER(globalCtx); + Player* player = GET_PLAYER(play); f32 distanceBetweenSeaweedAndDisturbance; f32 disturbanceFactor; f32 xDiff; @@ -2598,42 +2589,42 @@ Gfx* sGyorgSeaweedDLs[] = { gGyorgSeaweedPiece3DL, gGyorgSeaweedPiece2DL, gGyorgSeaweedPiece1DL, }; -void Boss03_SeaweedDraw(Actor* thisx, GlobalContext* globalCtx) { +void Boss03_SeaweedDraw(Actor* thisx, PlayState* play) { 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); + Mtx* mtx = GRAPH_ALLOC(play->state.gfxCtx, sizeof(Mtx) * 10); - OPEN_DISPS(globalCtx->state.gfxCtx); + OPEN_DISPS(play->state.gfxCtx); - func_8012C28C(globalCtx->state.gfxCtx); + func_8012C28C(play->state.gfxCtx); gSPSegment(POLY_OPA_DISP++, 0x0D, mtx); - Matrix_InsertTranslation(this->actor.world.pos.x, this->actor.world.pos.y, this->actor.world.pos.z, MTXMODE_NEW); + Matrix_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_RotateY(this->actor.shape.rot.y, MTXMODE_APPLY); - Matrix_InsertZRotation_s(0x4000, MTXMODE_APPLY); + Matrix_RotateYS(this->actor.shape.rot.y, MTXMODE_APPLY); + Matrix_RotateZS(0x4000, MTXMODE_APPLY); // The indices looks a bit random... - Matrix_RotateY(this->jointTable[5].x * -5.0f * 0.1f, MTXMODE_APPLY); - Matrix_InsertXRotation_s(this->jointTable[3].y * -5.0f * 0.1f, MTXMODE_APPLY); - Matrix_InsertZRotation_s(this->jointTable[2].z * 6.0f * 0.1f, MTXMODE_APPLY); + 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_RotateY(this->jointTable[i].x + this->morphTable[i].x, MTXMODE_APPLY); - Matrix_InsertXRotation_s(this->jointTable[i].y + this->morphTable[i].y, MTXMODE_APPLY); - Matrix_InsertZRotation_s(this->jointTable[i].z + this->morphTable[i].z, MTXMODE_APPLY); + Matrix_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_GetStateTranslation(&this->seaweedSegmentPositions[i]); - Matrix_InsertTranslation(4000.0f, 0.0f, 0.0f, MTXMODE_APPLY); + Matrix_MultZero(&this->seaweedSegmentPositions[i]); + Matrix_Translate(4000.0f, 0.0f, 0.0f, MTXMODE_APPLY); } - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->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 f5af516c0..a00dbacff 100644 --- a/src/overlays/actors/ovl_Boss_03/z_boss_03.h +++ b/src/overlays/actors/ovl_Boss_03/z_boss_03.h @@ -6,7 +6,7 @@ struct Boss03; -typedef void (*Boss03ActionFunc)(struct Boss03*, GlobalContext*); +typedef void (*Boss03ActionFunc)(struct Boss03*, PlayState*); #define GYORG_WORK_TIMER_MAX 3 @@ -35,73 +35,73 @@ typedef enum { } GyorgEffectType; typedef struct Boss03 { - /* 0x0000 */ Actor actor; - /* 0x0144 */ UNK_TYPE1 unk_144[0x04]; - /* 0x0148 */ SkelAnime skelAnime; - /* 0x018C */ Vec3s jointTable[GYORG_LIMB_MAX]; - /* 0x01E6 */ Vec3s morphTable[GYORG_LIMB_MAX]; - /* 0x0240 */ s16 unk_240; // generic timer? used by Gyorg and seaweed - /* 0x0242 */ u8 unk_242; - /* 0x0243 */ UNK_TYPE1 unk_243[0x09]; - /* 0x024C */ s16 workTimer[GYORG_WORK_TIMER_MAX]; - /* 0x0252 */ s8 numSpawnedSmallFish; // number of Tanron3 fish that are currently alive, -1 indexed - /* 0x0253 */ u8 hasSpwanedSmallFishes; // Tanron - /* 0x0254 */ s16 bubbleEffectSpawnCount; // Amount of bubble effect which will be spawned by Update - /* 0x0258 */ f32 waterHeight; // always 430.0f - /* 0x025C */ s16 unk_25C; // Timer related to collision? - /* 0x025E */ s16 unk_25E; - /* 0x0260 */ f32 unk_260; // rotY - /* 0x0264 */ UNK_TYPE1 unk_264[0x04]; - /* 0x0268 */ Vec3f unk_268; // set to player.world.pos or random values - /* 0x0274 */ s16 unk_274; - /* 0x0276 */ s16 unk_276; - /* 0x0278 */ f32 unk_278; - /* 0x027C */ f32 unk_27C; - /* 0x0280 */ s16 unk_280; - /* 0x0284 */ f32 unk_284; // Maybe a Vec3f - /* 0x0288 */ f32 unk_288; // Set but not used - /* 0x028C */ f32 unk_28C; - /* 0x0290 */ u8 unk_290; - /* 0x0294 */ f32 unk_294; - /* 0x0298 */ f32 unk_298; - /* 0x029C */ s16 leftFinYRot; - /* 0x029E */ s16 rightFinYRot; - /* 0x02A0 */ s16 bodyYRot; - /* 0x02A2 */ Vec3s unk_2A2; - /* 0x02A8 */ s16 jawZRot; - /* 0x02AC */ Vec3f insideJawPos; // used to grab player - /* 0x02B8 */ f32 unk_2B8; - /* 0x02BC */ u8 unk_2BC; // set but not used - /* 0x02BD */ u8 unk_2BD; // playerUnderwater? - /* 0x02BE */ s16 unk_2BE; - /* 0x02C0 */ UNK_TYPE1 unk_2C0[0x04]; - /* 0x02C0 */ f32 unk_2C4; - /* 0x02C8 */ Vec3f prevPlayerPos; - /* 0x02D4 */ u8 wetSpotEffectSpawnCount; - /* 0x02D5 */ u8 unk_2D5; // flag - /* 0x02D6 */ s16 shapeRotTargetX; - /* 0x02D8 */ s16 shapeRotTargetY; - /* 0x02DA */ s16 shapeRotTargetZ; - /* 0x02DC */ Vec3f seaweedSegmentPositions[6]; - /* 0x0324 */ s16 unk_324; // timer? set by Tanron3 - /* 0x0328 */ Boss03ActionFunc actionFunc; - /* 0x032C */ ColliderJntSph headCollider; - /* 0x034C */ ColliderJntSphElement headColliderElements[2]; - /* 0x03CC */ ColliderJntSph bodyCollider; - /* 0x03EC */ ColliderJntSphElement bodyColliderElements[5]; - /* 0x052C */ f32 floppingAnimLastFrame; - /* 0x0530 */ u32 csTimer; - /* 0x0534 */ s16 csState; - /* 0x0536 */ s16 csCamId; - /* 0x0538 */ Vec3f csCamEye; - /* 0x0544 */ Vec3f csCamAt; - /* 0x0550 */ Vec3f csCamTargetEye; - /* 0x055C */ Vec3f csCamTargetAt; - /* 0x0568 */ f32 unk_568; - /* 0x056C */ f32 unk_56C; - /* 0x0570 */ f32 unk_570; // set but not used - /* 0x0574 */ UNK_TYPE1 unk_574[0x04]; - /* 0x0578 */ f32 cameraFov; + /* 0x000 */ Actor actor; + /* 0x144 */ UNK_TYPE1 unk_144[0x04]; + /* 0x148 */ SkelAnime skelAnime; + /* 0x18C */ Vec3s jointTable[GYORG_LIMB_MAX]; + /* 0x1E6 */ Vec3s morphTable[GYORG_LIMB_MAX]; + /* 0x240 */ s16 unk_240; // generic timer? used by Gyorg and seaweed + /* 0x242 */ u8 unk_242; + /* 0x243 */ UNK_TYPE1 unk_243[0x09]; + /* 0x24C */ s16 workTimer[GYORG_WORK_TIMER_MAX]; + /* 0x252 */ s8 numSpawnedSmallFish; // number of Tanron3 fish that are currently alive, -1 indexed + /* 0x253 */ u8 hasSpwanedSmallFishes; // Tanron + /* 0x254 */ s16 bubbleEffectSpawnCount; // Amount of bubble effect which will be spawned by Update + /* 0x258 */ f32 waterHeight; // always 430.0f + /* 0x25C */ s16 unk_25C; // Timer related to collision? + /* 0x25E */ s16 unk_25E; + /* 0x260 */ f32 unk_260; // rotY + /* 0x264 */ UNK_TYPE1 unk_264[0x04]; + /* 0x268 */ Vec3f unk_268; // set to player.world.pos or random values + /* 0x274 */ s16 unk_274; + /* 0x276 */ s16 unk_276; + /* 0x278 */ f32 unk_278; + /* 0x27C */ f32 unk_27C; + /* 0x280 */ s16 unk_280; + /* 0x284 */ f32 unk_284; // Maybe a Vec3f + /* 0x288 */ f32 unk_288; // Set but not used + /* 0x28C */ f32 unk_28C; + /* 0x290 */ u8 unk_290; + /* 0x294 */ f32 unk_294; + /* 0x298 */ f32 unk_298; + /* 0x29C */ s16 leftFinYRot; + /* 0x29E */ s16 rightFinYRot; + /* 0x2A0 */ s16 bodyYRot; + /* 0x2A2 */ Vec3s unk_2A2; + /* 0x2A8 */ s16 jawZRot; + /* 0x2AC */ Vec3f insideJawPos; // used to grab player + /* 0x2B8 */ f32 unk_2B8; + /* 0x2BC */ u8 unk_2BC; // set but not used + /* 0x2BD */ u8 unk_2BD; // playerUnderwater? + /* 0x2BE */ s16 unk_2BE; + /* 0x2C0 */ UNK_TYPE1 unk_2C0[0x04]; + /* 0x2C0 */ f32 unk_2C4; + /* 0x2C8 */ Vec3f prevPlayerPos; + /* 0x2D4 */ u8 wetSpotEffectSpawnCount; + /* 0x2D5 */ u8 unk_2D5; // flag + /* 0x2D6 */ s16 shapeRotTargetX; + /* 0x2D8 */ s16 shapeRotTargetY; + /* 0x2DA */ s16 shapeRotTargetZ; + /* 0x2DC */ Vec3f seaweedSegmentPositions[6]; + /* 0x324 */ s16 unk_324; // timer? set by Tanron3 + /* 0x328 */ Boss03ActionFunc actionFunc; + /* 0x32C */ ColliderJntSph headCollider; + /* 0x34C */ ColliderJntSphElement headColliderElements[2]; + /* 0x3CC */ ColliderJntSph bodyCollider; + /* 0x3EC */ ColliderJntSphElement bodyColliderElements[5]; + /* 0x52C */ f32 floppingAnimLastFrame; + /* 0x530 */ u32 csTimer; + /* 0x534 */ s16 csState; + /* 0x536 */ s16 subCamId; + /* 0x538 */ Vec3f subCamEye; + /* 0x544 */ Vec3f subCamAt; + /* 0x550 */ Vec3f subCamEyeNext; + /* 0x55C */ Vec3f subCamAtNext; + /* 0x568 */ f32 unk_568; + /* 0x56C */ f32 unk_56C; + /* 0x570 */ f32 unk_570; // set but not used + /* 0x574 */ UNK_TYPE1 unk_574[0x04]; + /* 0x578 */ f32 subCamFov; } Boss03; // size = 0x57C #define GYORG_PARAM_DEFAULT (0) diff --git a/src/overlays/actors/ovl_Boss_04/z_boss_04.c b/src/overlays/actors/ovl_Boss_04/z_boss_04.c index b74d9c66b..3524efa53 100644 --- a/src/overlays/actors/ovl_Boss_04/z_boss_04.c +++ b/src/overlays/actors/ovl_Boss_04/z_boss_04.c @@ -5,25 +5,24 @@ */ #include "z_boss_04.h" -#include "objects/object_boss04/object_boss04.h" #define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_4 | ACTOR_FLAG_10 | ACTOR_FLAG_20) #define THIS ((Boss04*)thisx) -void Boss04_Init(Actor* thisx, GlobalContext* globalCtx); -void Boss04_Destroy(Actor* thisx, GlobalContext* globalCtx); -void Boss04_Update(Actor* thisx, GlobalContext* globalCtx); -void Boss04_Draw(Actor* thisx, GlobalContext* globalCtx); +void Boss04_Init(Actor* thisx, PlayState* play); +void Boss04_Destroy(Actor* thisx, PlayState* play); +void Boss04_Update(Actor* thisx, PlayState* play); +void Boss04_Draw(Actor* thisx, PlayState* play); void func_809EC544(Boss04* this); -void func_809EC568(Boss04* this, GlobalContext* globalCtx); -void func_809ECD00(Boss04* this, GlobalContext* globalCtx); -void func_809ECD18(Boss04* this, GlobalContext* globalCtx); +void func_809EC568(Boss04* this, PlayState* play); +void func_809ECD00(Boss04* this, PlayState* play); +void func_809ECD18(Boss04* this, PlayState* play); void func_809ECEF4(Boss04* this); -void func_809ECF58(Boss04* this, GlobalContext* globalCtx); +void func_809ECF58(Boss04* this, PlayState* play); void func_809ED224(Boss04* this); -void func_809ED2A0(Boss04* this, GlobalContext* globalCtx); +void func_809ED2A0(Boss04* this, PlayState* play); static u8 D_809EE4D0; @@ -97,7 +96,7 @@ static ColliderJntSphInit sJntSphInit1 = { OC2_TYPE_1, COLSHAPE_JNTSPH, }, - 1, + ARRAY_COUNT(sJntSphElementsInit1), sJntSphElementsInit1, }; @@ -124,7 +123,7 @@ static ColliderJntSphInit sJntSphInit2 = { OC2_TYPE_1, COLSHAPE_JNTSPH, }, - 1, + ARRAY_COUNT(sJntSphElementsInit2), sJntSphElementsInit2, }; @@ -136,14 +135,14 @@ void func_809EC040(s32 index, ColliderJntSph* collider, Vec3f* arg2) { collider->elements[index].dim.modelSphere.radius * collider->elements[index].dim.scale; } -void Boss04_Init(Actor* thisx, GlobalContext* globalCtx2) { +void Boss04_Init(Actor* thisx, PlayState* play2) { static Vec3f D_809EE1F8[] = { { -1000.0f, 0.0f, 0.0f }, { 1000.0f, 0.0f, 0.0f }, { 0.0f, 0.0f, -1000.0f }, { 0.0f, 0.0f, 1000.0f }, }; - GlobalContext* globalCtx = globalCtx2; + PlayState* play = play2; Boss04* this = THIS; s32 i; CollisionPoly* spC0; @@ -156,7 +155,7 @@ void Boss04_Init(Actor* thisx, GlobalContext* globalCtx2) { s16 phi_s0_2; s32 pad; - if (Flags_GetClear(globalCtx, globalCtx->roomCtx.currRoom.num)) { + if (Flags_GetClear(play, play->roomCtx.currRoom.num)) { Actor_MarkForDeath(&this->actor); return; } @@ -170,16 +169,16 @@ void Boss04_Init(Actor* thisx, GlobalContext* globalCtx2) { this->unk_700 = 1.0f; this->unk_6FC = 1.0f; this->unk_6F8 = 1.0f; - Collider_InitAndSetJntSph(globalCtx, &this->collider1, &this->actor, &sJntSphInit1, this->collider1Elements); - Collider_InitAndSetJntSph(globalCtx, &this->collider2, &this->actor, &sJntSphInit2, this->collider2Elements); - SkelAnime_InitFlex(globalCtx, &this->skelAnime, &object_boss04_Skel_0045E8, &object_boss04_Anim_00004C, - this->jointTable, this->morphtable, 9); + Collider_InitAndSetJntSph(play, &this->collider1, &this->actor, &sJntSphInit1, this->collider1Elements); + Collider_InitAndSetJntSph(play, &this->collider2, &this->actor, &sJntSphInit2, this->collider2Elements); + SkelAnime_InitFlex(play, &this->skelAnime, &gWartSkel, &gWartIdleAnim, this->jointTable, this->morphtable, + WART_LIMB_MAX); spA8.y = this->actor.world.pos.y + 200.0f; for (i = 0; i < ARRAY_COUNT(D_809EE1F8); i++) { 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, true, false, false, + if (BgCheck_EntityLineTest1(&play->colCtx, &this->actor.world.pos, &spA8, &spB4, &spC0, true, false, false, true, &spA4)) { if (i == 0) { this->unk_6D8 = spB4.x; @@ -197,10 +196,10 @@ void Boss04_Init(Actor* thisx, GlobalContext* globalCtx2) { this->unk_6F0 = this->unk_6E0 + ((this->unk_6E4 - this->unk_6E0) * 0.5f); this->actor.world.pos.x = this->unk_6E8; this->actor.world.pos.z = this->unk_6F0; - Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 35.0f, 60.0f, 60.0f, 4); + Actor_UpdateBgCheckInfo(play, &this->actor, 35.0f, 60.0f, 60.0f, 4); if ((KREG(64) != 0) || (gSaveContext.eventInf[6] & 1)) { - func_809ECD00(this, globalCtx); + func_809ECD00(this, play); this->actor.world.pos.y = this->actor.floorHeight + 160.0f; phi_f24 = this->actor.floorHeight; D_809EE4D0 = KREG(41) + 50; @@ -214,19 +213,19 @@ 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); - 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); + Matrix_RotateYS(phi_s0_2, MTXMODE_NEW); + Matrix_MultVecZ(phi_f20, &sp90); + Actor_SpawnAsChild(&play->actorCtx, &this->actor, play, ACTOR_EN_TANRON2, this->unk_6E8 + sp90.x, phi_f24, + this->unk_6F0 + sp90.z, 0, 0, 0, i); phi_f20 += 2.5f; phi_s0_2 += 0x1300; } - Actor_SpawnAsChild(&globalCtx->actorCtx, &this->actor, globalCtx, ACTOR_EN_TANRON2, this->actor.world.pos.x, + Actor_SpawnAsChild(&play->actorCtx, &this->actor, play, ACTOR_EN_TANRON2, this->actor.world.pos.x, this->actor.world.pos.y, this->actor.world.pos.z, 0, 0, 0, 100); } -void Boss04_Destroy(Actor* thisx, GlobalContext* globalCtx) { +void Boss04_Destroy(Actor* thisx, PlayState* play) { } void func_809EC544(Boss04* this) { @@ -234,8 +233,8 @@ void func_809EC544(Boss04* this) { this->actor.flags &= ~ACTOR_FLAG_1; } -void func_809EC568(Boss04* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); +void func_809EC568(Boss04* this, PlayState* play) { + Player* player = GET_PLAYER(play); f32 x; f32 y; f32 z; @@ -245,7 +244,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,22 +258,22 @@ void func_809EC568(Boss04* this, GlobalContext* globalCtx) { this->unk_708 = 10; this->unk_704 = 0; - 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); + Cutscene_Start(play, &play->csCtx); + this->subCamId = Play_CreateSubCamera(play); + Play_ChangeCameraStatus(play, CAM_ID_MAIN, CAM_STATUS_WAIT); + Play_ChangeCameraStatus(play, this->subCamId, CAM_STATUS_ACTIVE); + func_800B7298(play, &this->actor, 7); player->actor.world.pos.x = this->unk_6E8; player->actor.world.pos.z = this->unk_6F0 + 410.0f; player->actor.shape.rot.y = 0x7FFF; player->actor.world.rot.y = player->actor.shape.rot.y; - Math_Vec3f_Copy(&this->unk_70C, &player->actor.world.pos); - this->unk_70C.y += 100.0f; - Math_Vec3f_Copy(&this->unk_718, &this->actor.world.pos); + Math_Vec3f_Copy(&this->subCamEye, &player->actor.world.pos); + this->subCamEye.y += 100.0f; + Math_Vec3f_Copy(&this->subCamAt, &this->actor.world.pos); func_8016566C(150); - this->unk_744 = 60.0f; + this->subCamFov = 60.0f; - boss = globalCtx->actorCtx.actorLists[ACTORCAT_BOSS].first; + boss = play->actorCtx.actorLists[ACTORCAT_BOSS].first; while (boss != NULL) { if (boss->id == ACTOR_EN_WATER_EFFECT) { Actor_MarkForDeath(boss); @@ -294,7 +293,7 @@ void func_809EC568(Boss04* this, GlobalContext* globalCtx) { } this->unk_2D0 = 10000.0f; this->unk_2C8 = 300; - Math_ApproachF(&this->unk_744, 20.0f, 0.3f, 11.0f); + Math_ApproachF(&this->subCamFov, 20.0f, 0.3f, 11.0f); if (this->unk_704 == 40) { this->unk_708 = 11; this->unk_704 = 0; @@ -313,41 +312,41 @@ void func_809EC568(Boss04* this, GlobalContext* globalCtx) { if (this->unk_704 == 45) { this->unk_708 = 1; this->unk_704 = 0; - func_800B7298(globalCtx, &this->actor, 0x15); + func_800B7298(play, &this->actor, 0x15); this->actor.gravity = 0.0f; break; } case 12: Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_ME_ATTACK - SFX_FLAG); - Math_ApproachF(&this->unk_718.x, this->actor.world.pos.x, 0.5f, 1000.0f); - Math_ApproachF(&this->unk_718.y, this->actor.world.pos.y, 0.5f, 1000.0f); - Math_ApproachF(&this->unk_718.z, this->actor.world.pos.z, 0.5f, 1000.0f); + Math_ApproachF(&this->subCamAt.x, this->actor.world.pos.x, 0.5f, 1000.0f); + Math_ApproachF(&this->subCamAt.y, this->actor.world.pos.y, 0.5f, 1000.0f); + Math_ApproachF(&this->subCamAt.z, this->actor.world.pos.z, 0.5f, 1000.0f); if (this->actor.bgCheckFlags & 2) { play_sound(NA_SE_IT_BIG_BOMB_EXPLOSION); this->unk_6F4 = 15; this->unk_708 = 13; this->unk_704 = 0; this->unk_2DA = 10; - Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_CLEAR_TAG, this->actor.world.pos.x, - this->actor.world.pos.y, this->actor.world.pos.z, 0, 0, 0, CLEAR_TAG_SPLASH); + Actor_Spawn(&play->actorCtx, play, ACTOR_EN_CLEAR_TAG, this->actor.world.pos.x, this->actor.world.pos.y, + this->actor.world.pos.z, 0, 0, 0, CLEAR_TAG_SPLASH); Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_KONB_JUMP_LEV_OLD - SFX_FLAG); - this->unk_748 = 20; + this->subCamAtOscillator = 20; } break; case 1: player->actor.shape.rot.y = 0x7FFF; player->actor.world.rot.y = player->actor.shape.rot.y; - Matrix_GetStateTranslationAndScaledZ(-100.0f, &this->unk_70C); + Matrix_MultVecZ(-100.0f, &this->subCamEye); - this->unk_70C.x += player->actor.world.pos.x; - this->unk_70C.y = Player_GetHeight(player) + player->actor.world.pos.y + 36.0f; - this->unk_70C.z += player->actor.world.pos.z; + this->subCamEye.x += player->actor.world.pos.x; + this->subCamEye.y = Player_GetHeight(player) + player->actor.world.pos.y + 36.0f; + this->subCamEye.z += player->actor.world.pos.z; - this->unk_718.x = player->actor.world.pos.x; - this->unk_718.y = (Player_GetHeight(player) + player->actor.world.pos.y) - 4.0f; - this->unk_718.z = player->actor.world.pos.z; + this->subCamAt.x = player->actor.world.pos.x; + this->subCamAt.y = (Player_GetHeight(player) + player->actor.world.pos.y) - 4.0f; + this->subCamAt.z = player->actor.world.pos.z; if (this->unk_704 >= 35) { this->unk_704 = 0; @@ -358,13 +357,13 @@ void func_809EC568(Boss04* this, GlobalContext* globalCtx) { case 2: case 3: - Matrix_GetStateTranslationAndScaledZ(500.0f, &this->unk_70C); - this->unk_70C.x += this->actor.world.pos.x; - this->unk_70C.y += this->actor.world.pos.y - 50.0f; - this->unk_70C.z += this->actor.world.pos.z; - this->unk_718.x = this->actor.world.pos.x; - this->unk_718.z = this->actor.world.pos.z; - this->unk_718.y = (this->actor.world.pos.y - 70.0f) + this->unk_728; + Matrix_MultVecZ(500.0f, &this->subCamEye); + this->subCamEye.x += this->actor.world.pos.x; + this->subCamEye.y += this->actor.world.pos.y - 50.0f; + this->subCamEye.z += this->actor.world.pos.z; + this->subCamAt.x = this->actor.world.pos.x; + this->subCamAt.z = this->actor.world.pos.z; + this->subCamAt.y = (this->actor.world.pos.y - 70.0f) + this->unk_728; Math_ApproachZeroF(&this->unk_728, 0.05f, this->unk_73C); Math_ApproachF(&this->unk_73C, 3.0f, 1.0f, 0.05f); if (this->unk_704 == 20) { @@ -380,35 +379,35 @@ void func_809EC568(Boss04* this, GlobalContext* globalCtx) { } if (this->unk_704 > 140) { - Camera* sp5C = Play_GetCamera(globalCtx, CAM_ID_MAIN); + Camera* mainCam = Play_GetCamera(play, CAM_ID_MAIN); this->unk_708 = 0; - func_809ECD00(this, globalCtx); - sp5C->eye = this->unk_70C; - sp5C->eyeNext = this->unk_70C; - sp5C->at = this->unk_718; - func_80169AFC(globalCtx, this->unk_70A, 0); - this->unk_70A = 0; - Cutscene_End(globalCtx, &globalCtx->csCtx); - func_800B7298(globalCtx, &this->actor, 6); + func_809ECD00(this, play); + mainCam->eye = this->subCamEye; + mainCam->eyeNext = this->subCamEye; + mainCam->at = this->subCamAt; + func_80169AFC(play, this->subCamId, 0); + this->subCamId = SUB_CAM_ID_DONE; + Cutscene_End(play, &play->csCtx); + func_800B7298(play, &this->actor, 6); func_80165690(); gSaveContext.eventInf[6] |= 1; } break; } - if (this->unk_70A != 0) { - Vec3f sp50; + if (this->subCamId != SUB_CAM_ID_DONE) { + Vec3f subCamAt; ShrinkWindow_SetLetterboxTarget(27); - if (this->unk_748 != 0) { - this->unk_748--; + if (this->subCamAtOscillator != 0) { + this->subCamAtOscillator--; } - Math_Vec3f_Copy(&sp50, &this->unk_718); - sp50.y += Math_SinS(this->unk_748 * 0x4000) * this->unk_748 * 1.5f; - Play_CameraSetAtEye(globalCtx, this->unk_70A, &sp50, &this->unk_70C); - Play_CameraSetFov(globalCtx, this->unk_70A, this->unk_744); - Math_ApproachF(&this->unk_744, 60.0f, 0.1f, 1.0f); + Math_Vec3f_Copy(&subCamAt, &this->subCamAt); + subCamAt.y += Math_SinS(this->subCamAtOscillator * 0x4000) * this->subCamAtOscillator * 1.5f; + Play_SetCameraAtEye(play, this->subCamId, &subCamAt, &this->subCamEye); + Play_SetCameraFov(play, this->subCamId, this->subCamFov); + Math_ApproachF(&this->subCamFov, 60.0f, 0.1f, 1.0f); } this->actor.shape.rot.y = this->actor.yawTowardsPlayer; x = player->actor.world.pos.x - this->actor.world.pos.x; @@ -417,12 +416,12 @@ void func_809EC568(Boss04* this, GlobalContext* globalCtx) { this->actor.shape.rot.x = Math_Atan2S(-y, sqrtf(SQ(x) + SQ(z))); } -void func_809ECD00(Boss04* this, GlobalContext* globalCtx) { +void func_809ECD00(Boss04* this, PlayState* play) { this->actionFunc = func_809ECD18; } -void func_809ECD18(Boss04* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); +void func_809ECD18(Boss04* this, PlayState* play) { + Player* player = GET_PLAYER(play); if (this->unk_1F4 >= 0x500) { this->unk_1F4 -= 0x300; @@ -464,7 +463,7 @@ void func_809ECEF4(Boss04* this) { this->actor.gravity = -3.0f; } -void func_809ECF58(Boss04* this, GlobalContext* globalCtx) { +void func_809ECF58(Boss04* this, PlayState* play) { Vec3f sp3C; if ((this->unk_1FE == 14) || ((this->actor.bgCheckFlags & 8) && (this->unk_1F8 == 0))) { @@ -481,12 +480,12 @@ void func_809ECF58(Boss04* this, GlobalContext* globalCtx) { if (this->actor.bgCheckFlags & 8) { play_sound(NA_SE_IT_BIG_BOMB_EXPLOSION); - func_800BC848(&this->actor, globalCtx, 15, 10); + func_800BC848(&this->actor, play, 15, 10); this->unk_6F4 = 15; sp3C.x = this->actor.focus.pos.x; sp3C.y = this->actor.focus.pos.y; sp3C.z = this->actor.focus.pos.z; - func_800BBFB0(globalCtx, &sp3C, 100.0f, 40, 500, 10, 0); + func_800BBFB0(play, &sp3C, 100.0f, 40, 500, 10, 0); } } @@ -500,7 +499,7 @@ void func_809ECF58(Boss04* this, GlobalContext* globalCtx) { sp3C.x = this->actor.world.pos.x; sp3C.y = this->actor.floorHeight + 2.0f; sp3C.z = this->actor.world.pos.z; - EffectSsGRipple_Spawn(globalCtx, &sp3C, 1400, 500, 0); + EffectSsGRipple_Spawn(play, &sp3C, 1400, 500, 0); Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_ME_ATTACK - SFX_FLAG); } } @@ -526,7 +525,7 @@ void func_809ED224(Boss04* this) { this->unk_1F6 = 10; } -void func_809ED2A0(Boss04* this, GlobalContext* globalCtx) { +void func_809ED2A0(Boss04* this, PlayState* play) { this->unk_2DA = 10; if (this->unk_1F8 >= 5) { @@ -549,9 +548,9 @@ void func_809ED2A0(Boss04* this, GlobalContext* globalCtx) { } if ((this->unk_1F8 == 2) || (this->unk_1F8 == 5)) { - Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_CLEAR_TAG, this->actor.world.pos.x, - this->actor.world.pos.y, this->actor.world.pos.z, 0, 0, 0, CLEAR_TAG_LARGE_EXPLOSION); - SoundSource_PlaySfxAtFixedWorldPos(globalCtx, &this->actor.world.pos, 40, NA_SE_IT_BIG_BOMB_EXPLOSION); + Actor_Spawn(&play->actorCtx, play, ACTOR_EN_CLEAR_TAG, this->actor.world.pos.x, this->actor.world.pos.y, + this->actor.world.pos.z, 0, 0, 0, CLEAR_TAG_LARGE_EXPLOSION); + SoundSource_PlaySfxAtFixedWorldPos(play, &this->actor.world.pos, 40, NA_SE_IT_BIG_BOMB_EXPLOSION); } if (this->unk_1FA == 3) { @@ -563,7 +562,7 @@ void func_809ED2A0(Boss04* this, GlobalContext* globalCtx) { } } -void func_809ED45C(Boss04* this, GlobalContext* globalCtx) { +void func_809ED45C(Boss04* this, PlayState* play) { ColliderJntSphElement* temp_v0; u8 damage; @@ -576,7 +575,7 @@ void func_809ED45C(Boss04* this, GlobalContext* globalCtx) { func_809ED224(this); this->unk_1FE = 100; this->unk_200 = 100; - Enemy_StartFinishingBlow(globalCtx, &this->actor); + Enemy_StartFinishingBlow(play, &this->actor); } else { this->unk_2DA = 15; this->unk_1FE = 15; @@ -591,86 +590,86 @@ 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) { - GlobalContext* globalCtx = globalCtx2; +void Boss04_Update(Actor* thisx, PlayState* play2) { + PlayState* play = play2; Boss04* this = THIS; s16 temp_v0_8; s32 pad; @@ -704,12 +703,12 @@ void Boss04_Update(Actor* thisx, GlobalContext* globalCtx2) { this->unk_6F4--; } - this->actionFunc(this, globalCtx); + this->actionFunc(this, play); Actor_MoveWithGravity(&this->actor); this->actor.world.pos.y -= 100.0f; this->actor.prevPos.y -= 100.0f; - Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 100.0f, 120.0f, 200.0f, 5); + Actor_UpdateBgCheckInfo(play, &this->actor, 100.0f, 120.0f, 200.0f, 5); this->actor.world.pos.y += 100.0f; this->actor.prevPos.y += 100.0f; } @@ -744,16 +743,16 @@ void Boss04_Update(Actor* thisx, GlobalContext* globalCtx2) { this->unk_6FC = (Math_CosS(this->unk_6F4 * 0x3000) * this->unk_6F4 * 0.02f) + 1.0f; this->unk_6F8 = this->unk_6FC; this->actor.shape.yOffset = (this->unk_6FC - 1.0f) * 1000.0f; - func_809ED45C(this, globalCtx); + func_809ED45C(this, play); if (this->unk_2CC > 3000.0f) { - CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->collider1.base); + CollisionCheck_SetAC(play, &play->colChkCtx, &this->collider1.base); this->actor.flags |= ACTOR_FLAG_1; } else { this->actor.flags &= ~ACTOR_FLAG_1; } - CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider2.base); - CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->collider2.base); - CollisionCheck_SetAT(globalCtx, &globalCtx->colChkCtx, &this->collider2.base); + CollisionCheck_SetOC(play, &play->colChkCtx, &this->collider2.base); + CollisionCheck_SetAC(play, &play->colChkCtx, &this->collider2.base); + CollisionCheck_SetAT(play, &play->colChkCtx, &this->collider2.base); func_809ED50C(this); } @@ -769,8 +768,7 @@ void Boss04_Update(Actor* thisx, GlobalContext* globalCtx2) { } } -s32 Boss04_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, - Actor* thisx) { +s32 Boss04_OverrideLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, Actor* thisx) { Boss04* this = THIS; if (limbIndex == KREG(32)) { @@ -782,11 +780,11 @@ s32 Boss04_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList rot->z += KREG(35) * 256; } - if ((limbIndex == 5) || (limbIndex == 7)) { + if ((limbIndex == WART_LIMB_TOP_EYELID_ROOT) || (limbIndex == WART_LIMB_BOTTOM_EYELID_ROOT)) { rot->y = (rot->y + (s16)this->unk_2CC) - 0x500; } - if (limbIndex == 4) { + if (limbIndex == WART_LIMB_EYE) { rot->y += this->unk_2D8; rot->z += this->unk_2D4; if (this->unk_2DA != 0) { @@ -798,53 +796,53 @@ s32 Boss04_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList return false; } -void Boss04_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx) { +void Boss04_PostLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx) { static Vec3f D_809EE228 = { 0.0f, -200.0f, 0.0f }; static Vec3f D_809EE234 = { 0.0f, 720.0f, 0.0f }; Boss04* this = THIS; Vec3f sp18; - if (limbIndex == 1) { - Matrix_GetStateTranslationAndScaledY(-500.0f, &this->actor.focus.pos); - Matrix_MultiplyVector3fByState(&D_809EE228, &sp18); + if (limbIndex == WART_LIMB_ROOT) { + 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); } } -void Boss04_Draw(Actor* thisx, GlobalContext* globalCtx) { +void Boss04_Draw(Actor* thisx, PlayState* play) { Boss04* this = THIS; - OPEN_DISPS(globalCtx->state.gfxCtx); + OPEN_DISPS(play->state.gfxCtx); - func_8012C28C(globalCtx->state.gfxCtx); + func_8012C28C(play->state.gfxCtx); if (this->unk_200 & 1) { POLY_OPA_DISP = Gfx_SetFog(POLY_OPA_DISP, 255, 0, 0, 255, 900, 1099); } - Matrix_InsertTranslation(0.0f, 0.0f, 800.0f, MTXMODE_APPLY); + Matrix_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, + SkelAnime_DrawFlexOpa(play, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, Boss04_OverrideLimbDraw, Boss04_PostLimbDraw, &this->actor); - POLY_OPA_DISP = func_801660B8(globalCtx, POLY_OPA_DISP); + POLY_OPA_DISP = func_801660B8(play, POLY_OPA_DISP); if (this->actionFunc != func_809EC568) { - func_8012C448(globalCtx->state.gfxCtx); + func_8012C448(play->state.gfxCtx); gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 0, 0, 0, 150); - gSPDisplayList(POLY_XLU_DISP++, object_boss04_DL_004510); + gSPDisplayList(POLY_XLU_DISP++, gWartShadowMaterialDL); - Matrix_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); - gSPDisplayList(POLY_XLU_DISP++, object_boss04_DL_004550); + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_XLU_DISP++, gWartShadowModelDL); } - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->state.gfxCtx); } diff --git a/src/overlays/actors/ovl_Boss_04/z_boss_04.h b/src/overlays/actors/ovl_Boss_04/z_boss_04.h index 267688ab0..c0944ce82 100644 --- a/src/overlays/actors/ovl_Boss_04/z_boss_04.h +++ b/src/overlays/actors/ovl_Boss_04/z_boss_04.h @@ -2,77 +2,78 @@ #define Z_BOSS_04_H #include "global.h" +#include "objects/object_boss04/object_boss04.h" struct Boss04; -typedef void (*Boss04ActionFunc)(struct Boss04*, GlobalContext*); +typedef void (*Boss04ActionFunc)(struct Boss04*, PlayState*); typedef struct Boss04 { - /* 0x0000 */ Actor actor; - /* 0x0144 */ SkelAnime skelAnime; - /* 0x0188 */ Vec3s jointTable[9]; - /* 0x01BE */ Vec3s morphtable[9]; - /* 0x01F4 */ s16 unk_1F4; - /* 0x01F6 */ u8 unk_1F6; - /* 0x01F7 */ u8 unk_1F7; - /* 0x01F8 */ s16 unk_1F8; - /* 0x01FA */ s16 unk_1FA; - /* 0x01FC */ UNK_TYPE1 unk_1FC[2]; - /* 0x01FE */ s16 unk_1FE; - /* 0x0200 */ s16 unk_200; - /* 0x0204 */ Boss04ActionFunc actionFunc; - /* 0x0208 */ ColliderJntSph collider1; - /* 0x0228 */ ColliderJntSphElement collider1Elements[1]; - /* 0x0268 */ ColliderJntSph collider2; - /* 0x0288 */ ColliderJntSphElement collider2Elements[1]; - /* 0x02C8 */ s16 unk_2C8; - /* 0x02CC */ f32 unk_2CC; - /* 0x02D0 */ f32 unk_2D0; - /* 0x02D4 */ s16 unk_2D4; - /* 0x02D6 */ s16 unk_2D6; - /* 0x02D8 */ s16 unk_2D8; - /* 0x02DA */ s16 unk_2DA; - /* 0x02DC */ s16 unk_2DC; - /* 0x02DE */ s16 unk_2DE; - /* 0x02E0 */ s16 unk_2E0; - /* 0x02E2 */ s16 unk_2E2; - /* 0x02E4 */ Vec3f unk_2E4[16]; - /* 0x02E4 */ Vec3f unk_3A4[15]; - /* 0x02E4 */ Vec3f unk_458[15]; - /* 0x02E4 */ Vec3f unk_50C[11]; - /* 0x02E4 */ Vec3f unk_590[11]; - /* 0x02E4 */ Vec3f unk_614[6]; - /* 0x02E4 */ Vec3f unk_65C[6]; - /* 0x02E4 */ Vec3f unk_6A4; - /* 0x02E4 */ Vec3f unk_6B0; - /* 0x06BC */ Vec3f unk_6BC; - /* 0x06C8 */ Vec3f unk_6C8; - /* 0x06D4 */ f32 unk_6D4; - /* 0x06D8 */ f32 unk_6D8; - /* 0x06DC */ f32 unk_6DC; - /* 0x06E0 */ f32 unk_6E0; - /* 0x06E4 */ f32 unk_6E4; - /* 0x06E8 */ f32 unk_6E8; - /* 0x06EC */ UNK_TYPE1 unk_6EC[4]; - /* 0x06F0 */ f32 unk_6F0; - /* 0x06F4 */ s16 unk_6F4; - /* 0x06F6 */ s16 unk_6F6; - /* 0x06F8 */ f32 unk_6F8; - /* 0x06FC */ f32 unk_6FC; - /* 0x0700 */ f32 unk_700; - /* 0x0704 */ u32 unk_704; - /* 0x0708 */ s16 unk_708; - /* 0x070A */ s16 unk_70A; - /* 0x070C */ Vec3f unk_70C; - /* 0x0718 */ Vec3f unk_718; - /* 0x0724 */ UNK_TYPE1 unk_724[4]; - /* 0x0728 */ f32 unk_728; - /* 0x072C */ UNK_TYPE1 unk_72C[0x10]; - /* 0x073C */ f32 unk_73C; - /* 0x0740 */ UNK_TYPE1 unk_740[4]; - /* 0x0744 */ f32 unk_744; - /* 0x0748 */ s16 unk_748; - /* 0x074A */ u8 unk_74A; + /* 0x000 */ Actor actor; + /* 0x144 */ SkelAnime skelAnime; + /* 0x188 */ Vec3s jointTable[WART_LIMB_MAX]; + /* 0x1BE */ Vec3s morphtable[WART_LIMB_MAX]; + /* 0x1F4 */ s16 unk_1F4; + /* 0x1F6 */ u8 unk_1F6; + /* 0x1F7 */ u8 unk_1F7; + /* 0x1F8 */ s16 unk_1F8; + /* 0x1FA */ s16 unk_1FA; + /* 0x1FC */ UNK_TYPE1 unk_1FC[2]; + /* 0x1FE */ s16 unk_1FE; + /* 0x200 */ s16 unk_200; + /* 0x204 */ Boss04ActionFunc actionFunc; + /* 0x208 */ ColliderJntSph collider1; + /* 0x228 */ ColliderJntSphElement collider1Elements[1]; + /* 0x268 */ ColliderJntSph collider2; + /* 0x288 */ ColliderJntSphElement collider2Elements[1]; + /* 0x2C8 */ s16 unk_2C8; + /* 0x2CC */ f32 unk_2CC; + /* 0x2D0 */ f32 unk_2D0; + /* 0x2D4 */ s16 unk_2D4; + /* 0x2D6 */ s16 unk_2D6; + /* 0x2D8 */ s16 unk_2D8; + /* 0x2DA */ s16 unk_2DA; + /* 0x2DC */ s16 unk_2DC; + /* 0x2DE */ s16 unk_2DE; + /* 0x2E0 */ s16 unk_2E0; + /* 0x2E2 */ s16 unk_2E2; + /* 0x2E4 */ Vec3f unk_2E4[16]; + /* 0x3A4 */ Vec3f unk_3A4[15]; + /* 0x458 */ Vec3f unk_458[15]; + /* 0x50C */ Vec3f unk_50C[11]; + /* 0x590 */ Vec3f unk_590[11]; + /* 0x614 */ Vec3f unk_614[6]; + /* 0x65C */ Vec3f unk_65C[6]; + /* 0x6A4 */ Vec3f unk_6A4; + /* 0x6B0 */ Vec3f unk_6B0; + /* 0x6BC */ Vec3f unk_6BC; + /* 0x6C8 */ Vec3f unk_6C8; + /* 0x6D4 */ f32 unk_6D4; + /* 0x6D8 */ f32 unk_6D8; + /* 0x6DC */ f32 unk_6DC; + /* 0x6E0 */ f32 unk_6E0; + /* 0x6E4 */ f32 unk_6E4; + /* 0x6E8 */ f32 unk_6E8; + /* 0x6EC */ UNK_TYPE1 unk_6EC[4]; + /* 0x6F0 */ f32 unk_6F0; + /* 0x6F4 */ s16 unk_6F4; + /* 0x6F6 */ s16 unk_6F6; + /* 0x6F8 */ f32 unk_6F8; + /* 0x6FC */ f32 unk_6FC; + /* 0x700 */ f32 unk_700; + /* 0x704 */ u32 unk_704; + /* 0x708 */ s16 unk_708; + /* 0x70A */ s16 subCamId; + /* 0x70C */ Vec3f subCamEye; + /* 0x718 */ Vec3f subCamAt; + /* 0x724 */ UNK_TYPE1 unk_724[4]; + /* 0x728 */ f32 unk_728; + /* 0x72C */ UNK_TYPE1 unk_72C[0x10]; + /* 0x73C */ f32 unk_73C; + /* 0x740 */ UNK_TYPE1 unk_740[4]; + /* 0x744 */ f32 subCamFov; + /* 0x748 */ s16 subCamAtOscillator; + /* 0x74A */ u8 unk_74A; } Boss04; // size = 0x74C extern const ActorInit Boss_04_InitVars; diff --git a/src/overlays/actors/ovl_Boss_05/z_boss_05.c b/src/overlays/actors/ovl_Boss_05/z_boss_05.c index a88ad8008..7b40069d7 100644 --- a/src/overlays/actors/ovl_Boss_05/z_boss_05.c +++ b/src/overlays/actors/ovl_Boss_05/z_boss_05.c @@ -10,23 +10,23 @@ #define THIS ((Boss05*)thisx) -void Boss05_Init(Actor* thisx, GlobalContext* globalCtx); -void Boss05_Destroy(Actor* thisx, GlobalContext* globalCtx); -void Boss05_Update(Actor* thisx, GlobalContext* globalCtx); -void Boss05_Draw(Actor* thisx, GlobalContext* globalCtx); +void Boss05_Init(Actor* thisx, PlayState* play); +void Boss05_Destroy(Actor* thisx, PlayState* play); +void Boss05_Update(Actor* thisx, PlayState* play); +void Boss05_Draw(Actor* thisx, PlayState* play); -void func_809EEDE8(Boss05* this, GlobalContext* globalCtx); -void func_809EF9BC(Boss05* this, GlobalContext* globalCtx); -void func_809EFAB4(Boss05* this, GlobalContext* globalCtx); -void func_809F010C(Boss05* this, GlobalContext* globalCtx); -void func_809F0244(Boss05* this, GlobalContext* globalCtx); -void func_809F0374(Boss05* this, GlobalContext* globalCtx); -void func_809F04C0(Boss05* this, GlobalContext* globalCtx); -void func_809F0590(Boss05* this, GlobalContext* globalCtx); -void func_809F06B8(Boss05* this, GlobalContext* globalCtx); -void func_809F0780(Boss05* this, GlobalContext* globalCtx); -void func_809F0ABC(Boss05* this, GlobalContext* globalCtx); -void func_809F0B0C(Boss05* this, GlobalContext* globalCtx); +void func_809EEDE8(Boss05* this, PlayState* play); +void func_809EF9BC(Boss05* this, PlayState* play); +void func_809EFAB4(Boss05* this, PlayState* play); +void func_809F010C(Boss05* this, PlayState* play); +void func_809F0244(Boss05* this, PlayState* play); +void func_809F0374(Boss05* this, PlayState* play); +void func_809F04C0(Boss05* this, PlayState* play); +void func_809F0590(Boss05* this, PlayState* play); +void func_809F06B8(Boss05* this, PlayState* play); +void func_809F0780(Boss05* this, PlayState* play); +void func_809F0ABC(Boss05* this, PlayState* play); +void func_809F0B0C(Boss05* this, PlayState* play); #if 0 // static ColliderJntSphElementInit sJntSphElementsInit[2] = { @@ -44,7 +44,7 @@ static ColliderJntSphElementInit D_809F1B2C[2] = { // static ColliderJntSphInit sJntSphInit = { static ColliderJntSphInit D_809F1B74 = { { COLTYPE_HIT3, AT_ON | AT_TYPE_ENEMY, AC_ON | AC_TYPE_PLAYER, OC1_ON | OC1_TYPE_PLAYER, OC2_TYPE_1, COLSHAPE_JNTSPH, }, - 2, D_809F1B2C, // sJntSphElementsInit, + ARRAY_COUNT(sJntSphElementsInit), D_809F1B2C, // sJntSphElementsInit, }; // static ColliderJntSphElementInit sJntSphElementsInit[1] = { @@ -58,7 +58,7 @@ static ColliderJntSphElementInit D_809F1B84[1] = { // static ColliderJntSphInit sJntSphInit = { static ColliderJntSphInit D_809F1BA8 = { { COLTYPE_HIT3, AT_ON | AT_TYPE_ENEMY, AC_ON | AC_TYPE_PLAYER, OC1_ON | OC1_TYPE_PLAYER, OC2_TYPE_1, COLSHAPE_JNTSPH, }, - 1, D_809F1B84, // sJntSphElementsInit, + ARRAY_COUNT(sJntSphElementsInit), D_809F1B84, // sJntSphElementsInit, }; // static ColliderJntSphElementInit sJntSphElementsInit[1] = { @@ -72,7 +72,7 @@ static ColliderJntSphElementInit D_809F1BB8[1] = { // static ColliderJntSphInit sJntSphInit = { static ColliderJntSphInit D_809F1BDC = { { COLTYPE_HIT3, AT_ON | AT_TYPE_ENEMY, AC_ON | AC_TYPE_PLAYER, OC1_ON | OC1_TYPE_PLAYER, OC2_TYPE_1, COLSHAPE_JNTSPH, }, - 1, D_809F1BB8, // sJntSphElementsInit, + ARRAY_COUNT(sJntSphElementsInit), D_809F1BB8, // sJntSphElementsInit, }; // static DamageTable sDamageTable = { diff --git a/src/overlays/actors/ovl_Boss_05/z_boss_05.h b/src/overlays/actors/ovl_Boss_05/z_boss_05.h index 85a2cdf9d..7a3f29507 100644 --- a/src/overlays/actors/ovl_Boss_05/z_boss_05.h +++ b/src/overlays/actors/ovl_Boss_05/z_boss_05.h @@ -5,13 +5,13 @@ struct Boss05; -typedef void (*Boss05ActionFunc)(struct Boss05*, GlobalContext*); +typedef void (*Boss05ActionFunc)(struct Boss05*, PlayState*); typedef struct Boss05 { - /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x2C]; - /* 0x0170 */ Boss05ActionFunc actionFunc; - /* 0x0174 */ char unk_174[0x394]; + /* 0x000 */ Actor actor; + /* 0x144 */ char unk_144[0x2C]; + /* 0x170 */ Boss05ActionFunc actionFunc; + /* 0x174 */ char unk_174[0x394]; } Boss05; // size = 0x508 extern const ActorInit Boss_05_InitVars; diff --git a/src/overlays/actors/ovl_Boss_06/z_boss_06.c b/src/overlays/actors/ovl_Boss_06/z_boss_06.c index 5a88f67c6..045a76995 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" @@ -13,19 +14,19 @@ #define THIS ((Boss06*)thisx) -void Boss06_Init(Actor* thisx, GlobalContext* globalCtx); -void Boss06_Destroy(Actor* thisx, GlobalContext* globalCtx); -void Boss06_Update(Actor* thisx, GlobalContext* globalCtx); -void Boss06_Draw(Actor* thisx, GlobalContext* globalCtx); +void Boss06_Init(Actor* thisx, PlayState* play); +void Boss06_Destroy(Actor* thisx, PlayState* play); +void Boss06_Update(Actor* thisx, PlayState* play); +void Boss06_Draw(Actor* thisx, PlayState* play); void func_809F24A8(Boss06* this); -void func_809F24C8(Boss06* this, GlobalContext* globalCtx); -void func_809F2B64(Boss06* this, GlobalContext* globalCtx); -void func_809F2C44(Boss06* this, GlobalContext* globalCtx); -void func_809F2E14(Boss06* this, GlobalContext* globalCtx); -void func_809F2E34(Boss06* this, GlobalContext* globalCtx); -void func_809F2ED0(Boss06* this, GlobalContext* globalCtx); -void func_809F2EE8(Boss06* this, GlobalContext* globalCtx); +void func_809F24C8(Boss06* this, PlayState* play); +void func_809F2B64(Boss06* this, PlayState* play); +void func_809F2C44(Boss06* this, PlayState* play); +void func_809F2E14(Boss06* this, PlayState* play); +void func_809F2E34(Boss06* this, PlayState* play); +void func_809F2ED0(Boss06* this, PlayState* play); +void func_809F2EE8(Boss06* this, PlayState* play); static Vec3f D_809F4370[128]; static EnKnight* D_809F4970; @@ -126,7 +127,7 @@ f32 func_809F2140(void) { return fabsf(temp_f2); } -void Boss06_Init(Actor* thisx, GlobalContext* globalCtx) { +void Boss06_Init(Actor* thisx, PlayState* play) { Boss06* this = THIS; u8* temp_v0; s32 i; @@ -143,7 +144,7 @@ void Boss06_Init(Actor* thisx, GlobalContext* globalCtx) { Actor_SetScale(&this->actor, 0.1f); Math_Vec3f_Copy(&this->actor.world.pos, &D_809F40EC[ENBOSS06_GET_PARAMS(&this->actor)]); this->actor.shape.rot.y = -0x8000; - Collider_InitAndSetCylinder(globalCtx, &this->collider, &this->actor, &sCylinderInit); + Collider_InitAndSetCylinder(play, &this->collider, &this->actor, &sCylinderInit); temp_v0 = SEGMENTED_TO_VIRTUAL(&object_knight_Tex_019490); for (i = 0; i < ARRAY_COUNT(this->unk_200); i++) { @@ -153,7 +154,7 @@ void Boss06_Init(Actor* thisx, GlobalContext* globalCtx) { this->actor.flags &= ~ACTOR_FLAG_1; } -void Boss06_Destroy(Actor* thisx, GlobalContext* globalCtx) { +void Boss06_Destroy(Actor* thisx, PlayState* play) { } void func_809F23CC(Boss06* this) { @@ -182,9 +183,9 @@ void func_809F24A8(Boss06* this) { #ifdef NON_MATCHING // Weird loading of 1 -void func_809F24C8(Boss06* this, GlobalContext* globalCtx) { +void func_809F24C8(Boss06* this, PlayState* play) { s16 sp4E = 0; - Player* player = GET_PLAYER(globalCtx); + Player* player = GET_PLAYER(play); Actor* temp_s0; Actor* temp_v0_2; Actor* child; @@ -197,18 +198,18 @@ void func_809F24C8(Boss06* this, GlobalContext* globalCtx) { break; } - Cutscene_Start(globalCtx, &globalCtx->csCtx); - func_800B7298(globalCtx, &this->actor, 7); - this->unk_A00 = Play_CreateSubCamera(globalCtx); - Play_CameraChangeStatus(globalCtx, CAM_ID_MAIN, 1); - Play_CameraChangeStatus(globalCtx, this->unk_A00, 7); + Cutscene_Start(play, &play->csCtx); + func_800B7298(play, &this->actor, 7); + this->subCamId = Play_CreateSubCamera(play); + Play_ChangeCameraStatus(play, CAM_ID_MAIN, CAM_STATUS_WAIT); + Play_ChangeCameraStatus(play, this->subCamId, CAM_STATUS_ACTIVE); D_809F4970->unk_151 = 1; this->unk_1C9 = 1; this->unk_1C8 = 1; this->unk_1E0 = 255.0f; this->unk_1DC = 0.0f; - temp_s0 = globalCtx->actorCtx.actorLists[ACTORCAT_ITEMACTION].first; + temp_s0 = play->actorCtx.actorLists[ACTORCAT_ITEMACTION].first; while (temp_s0 != NULL) { if (temp_s0->id == ACTOR_EN_ARROW) { Actor_MarkForDeath(temp_s0); @@ -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.fillScreen = 1; - globalCtx->envCtx.screenFillColor[2] = 0; - globalCtx->envCtx.screenFillColor[1] = 0; - globalCtx->envCtx.screenFillColor[0] = 0; - globalCtx->envCtx.screenFillColor[3] = this->unk_A2C; + play->envCtx.fillScreen = 1; + play->envCtx.screenFillColor[2] = 0; + play->envCtx.screenFillColor[1] = 0; + play->envCtx.screenFillColor[0] = 0; + play->envCtx.screenFillColor[3] = this->unk_A2C; Math_ApproachF(&this->unk_A2C, 75.0f, 1.0f, 3.0f); } @@ -232,37 +233,37 @@ void func_809F24C8(Boss06* this, GlobalContext* globalCtx) { } if (this->unk_1CA >= 60) { - globalCtx->envCtx.fillScreen = 0; + play->envCtx.fillScreen = 0; this->unk_1C8 = 0; this->unk_1DC = 0.0f; this->unk_1D8 = 0.0f; if (this->unk_1CA == 60) { D_809F4970->unk_154++; - func_800B7298(globalCtx, &this->actor, 0x84); + func_800B7298(play, &this->actor, 0x84); player->actor.shape.rot.y = 0; player->actor.world.rot.y = player->actor.shape.rot.y; } - this->unk_A04.x = player->actor.world.pos.x + 20.0f; - this->unk_A04.y = player->actor.world.pos.y + 20.0f; - this->unk_A04.z = player->actor.world.pos.z + 30.0f; + this->subCamEye.x = player->actor.world.pos.x + 20.0f; + this->subCamEye.y = player->actor.world.pos.y + 20.0f; + this->subCamEye.z = player->actor.world.pos.z + 30.0f; - this->unk_A10.x = player->actor.world.pos.x; - this->unk_A10.y = player->actor.world.pos.y + 26.0f; - this->unk_A10.z = player->actor.world.pos.z; + this->subCamAt.x = player->actor.world.pos.x; + this->subCamAt.y = player->actor.world.pos.y + 26.0f; + this->subCamAt.z = player->actor.world.pos.z; if (this->unk_1CA >= 75) { - temp_v0_2 = globalCtx->actorCtx.actorLists[ACTORCAT_BOSS].first; + temp_v0_2 = play->actorCtx.actorLists[ACTORCAT_BOSS].first; while (temp_v0_2 != NULL) { if ((temp_v0_2->id == ACTOR_EN_KNIGHT) && (&D_809F4970->actor == temp_v0_2) && (D_809F4970->unk_680 != 0)) { - this->unk_A04.x = 1307.0f; - this->unk_A04.y = 142.0f; - this->unk_A04.z = 2897.0f; + this->subCamEye.x = 1307.0f; + this->subCamEye.y = 142.0f; + this->subCamEye.z = 2897.0f; - this->unk_A10.x = 1376.0f; - this->unk_A10.y = 132.0f; - this->unk_A10.z = 2860.0f; + this->subCamAt.x = 1376.0f; + this->subCamAt.y = 132.0f; + this->subCamAt.z = 2860.0f; if (this->unk_1CA == 75) { D_809F4970->unk_148 = 1; @@ -286,30 +287,29 @@ void func_809F24C8(Boss06* this, GlobalContext* globalCtx) { this->unk_1E0 = 255.0f; this->unk_19C = 1.0f; - Actor_SpawnAsChild(&globalCtx->actorCtx, &this->actor, globalCtx, ACTOR_MIR_RAY2, - this->actor.world.pos.x, this->actor.world.pos.y - 200.0f, - this->actor.world.pos.z - 170.0f, 15, 0, 0, 1); + Actor_SpawnAsChild(&play->actorCtx, &this->actor, play, ACTOR_MIR_RAY2, this->actor.world.pos.x, + this->actor.world.pos.y - 200.0f, this->actor.world.pos.z - 170.0f, 15, 0, 0, 1); if (ENBOSS06_GET_PARAMS(&this->actor) == 0) { - this->unk_A04.x = this->actor.world.pos.x - 200.0f; + this->subCamEye.x = this->actor.world.pos.x - 200.0f; } else { - this->unk_A04.x = this->actor.world.pos.x + 200.0f; + this->subCamEye.x = this->actor.world.pos.x + 200.0f; } - this->unk_A04.y = (this->actor.world.pos.y - 200.0f) + 100.0f; - this->unk_A04.z = this->actor.world.pos.z - 200.0f; + this->subCamEye.y = (this->actor.world.pos.y - 200.0f) + 100.0f; + this->subCamEye.z = this->actor.world.pos.z - 200.0f; - this->unk_A10.x = this->actor.world.pos.x; - this->unk_A10.y = this->actor.world.pos.y + 80.0f; - this->unk_A10.z = this->actor.world.pos.z; + this->subCamAt.x = this->actor.world.pos.x; + this->subCamAt.y = this->actor.world.pos.y + 80.0f; + this->subCamAt.z = this->actor.world.pos.z; } } else { - this->unk_A10.z = this->actor.world.pos.z; - this->unk_A04.y = this->actor.world.pos.y + 60.0f; - this->unk_A04.x = this->actor.world.pos.x; + this->subCamEye.x = this->actor.world.pos.x; + this->subCamEye.y = this->actor.world.pos.y + 60.0f; + this->subCamEye.z = this->actor.world.pos.z - 210.0f; - this->unk_A04.z = this->actor.world.pos.z - 210.0f; - this->unk_A10.y = this->actor.world.pos.y + 80.0f; - this->unk_A10.x = this->actor.world.pos.x; + this->subCamAt.x = this->actor.world.pos.x; + this->subCamAt.y = this->actor.world.pos.y + 80.0f; + this->subCamAt.z = this->actor.world.pos.z; } break; @@ -317,37 +317,37 @@ void func_809F24C8(Boss06* this, GlobalContext* globalCtx) { child = this->actor.child; if (this->unk_1CA == 1) { - this->unk_A1C.x = fabsf(this->unk_A10.x - child->world.pos.x); - this->unk_A1C.y = fabsf(this->unk_A10.y - child->world.pos.y); - this->unk_A1C.z = fabsf(this->unk_A10.z - child->world.pos.z); + this->unk_A1C.x = fabsf(this->subCamAt.x - child->world.pos.x); + this->unk_A1C.y = fabsf(this->subCamAt.y - child->world.pos.y); + this->unk_A1C.z = fabsf(this->subCamAt.z - child->world.pos.z); } - Math_ApproachF(&this->unk_A10.x, child->world.pos.x, 0.15f, this->unk_A1C.x * this->unk_A28); - Math_ApproachF(&this->unk_A10.y, child->world.pos.y, 0.15f, this->unk_A1C.y * this->unk_A28); - Math_ApproachF(&this->unk_A10.z, child->world.pos.z, 0.15f, this->unk_A1C.z * this->unk_A28); + Math_ApproachF(&this->subCamAt.x, child->world.pos.x, 0.15f, this->unk_A1C.x * this->unk_A28); + Math_ApproachF(&this->subCamAt.y, child->world.pos.y, 0.15f, this->unk_A1C.y * this->unk_A28); + Math_ApproachF(&this->subCamAt.z, child->world.pos.z, 0.15f, this->unk_A1C.z * this->unk_A28); Math_ApproachF(&this->unk_A28, 1.0f, 1.0f, 0.001f); if (this->unk_1CA > 80) { - func_809F2ED0(this, globalCtx); - func_80169AFC(globalCtx, this->unk_A00, 0); - this->unk_A00 = 0; - Cutscene_End(globalCtx, &globalCtx->csCtx); - func_800B7298(globalCtx, &this->actor, 6); + func_809F2ED0(this, play); + func_80169AFC(play, this->subCamId, 0); + this->subCamId = SUB_CAM_ID_DONE; + Cutscene_End(play, &play->csCtx); + func_800B7298(play, &this->actor, 6); D_809F4970->unk_151 = 0; } break; } - if (this->unk_A00 != 0) { + if (this->subCamId != SUB_CAM_ID_DONE) { ShrinkWindow_SetLetterboxTarget(27); - Play_CameraSetAtEye(globalCtx, this->unk_A00, &this->unk_A10, &this->unk_A04); + Play_SetCameraAtEye(play, this->subCamId, &this->subCamAt, &this->subCamEye); } } #else #pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Boss_06/func_809F24C8.s") #endif -void func_809F2B64(Boss06* this, GlobalContext* globalCtx) { +void func_809F2B64(Boss06* this, PlayState* play) { this->actionFunc = func_809F2C44; this->unk_144 = 3; this->unk_1A8 = 110.0f; @@ -356,12 +356,12 @@ void func_809F2B64(Boss06* this, GlobalContext* globalCtx) { this->unk_1E4 = 30.0f; this->unk_1AC = 0.0f; this->unk_19C = 1.0f; - Actor_SpawnAsChild(&globalCtx->actorCtx, &this->actor, globalCtx, ACTOR_MIR_RAY2, this->actor.world.pos.x, + Actor_SpawnAsChild(&play->actorCtx, &this->actor, play, ACTOR_MIR_RAY2, this->actor.world.pos.x, this->actor.world.pos.y - 200.0f, this->actor.world.pos.z - 170.0f, 15, 0, 0, 1); D_809F4970->unk_154++; } -void func_809F2C44(Boss06* this, GlobalContext* globalCtx) { +void func_809F2C44(Boss06* this, PlayState* play) { if (D_809F4970->unk_153 != 0) { this->unk_A28 = 0.008f; Math_ApproachF(&this->unk_1E4, 0.0f, 0.2f, this->unk_A28 * 30.0f); @@ -383,34 +383,34 @@ void func_809F2C44(Boss06* this, GlobalContext* globalCtx) { if (D_809F4970->unk_153 == 2) { Actor_MarkForDeath(this->actor.child); this->actor.child = NULL; - func_809F2E14(this, globalCtx); + func_809F2E14(this, play); } } -void func_809F2E14(Boss06* this, GlobalContext* globalCtx) { +void func_809F2E14(Boss06* this, PlayState* play) { this->actionFunc = func_809F2E34; this->unk_144 = 1; } -void func_809F2E34(Boss06* this, GlobalContext* globalCtx) { +void func_809F2E34(Boss06* this, PlayState* play) { this->unk_1E0 = 200.0f; this->unk_1DC = 15.0f; func_809F23CC(this); Collider_UpdateCylinder(&this->actor, &this->collider); this->collider.dim.pos.z = (this->actor.world.pos.z - 50.0f) + 100.0f; - CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + CollisionCheck_SetAC(play, &play->colChkCtx, &this->collider.base); } -void func_809F2ED0(Boss06* this, GlobalContext* globalCtx) { +void func_809F2ED0(Boss06* this, PlayState* play) { this->actionFunc = func_809F2EE8; } -void func_809F2EE8(Boss06* this, GlobalContext* globalCtx) { +void func_809F2EE8(Boss06* this, PlayState* play) { this->unk_1E0 = 100.0f; this->unk_1DC = 13.0f; } -void Boss06_Update(Actor* thisx, GlobalContext* globalCtx) { +void Boss06_Update(Actor* thisx, PlayState* play) { Boss06* this = THIS; s32 i; Vec3f sp7C; @@ -418,7 +418,7 @@ void Boss06_Update(Actor* thisx, GlobalContext* globalCtx) { f32 phi_f26; f32 phi_f24; - this->actionFunc(this, globalCtx); + this->actionFunc(this, play); if (this->unk_146 != 0) { this->unk_146--; @@ -466,15 +466,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 +498,8 @@ void Boss06_Update(Actor* thisx, GlobalContext* globalCtx) { } } -void Boss06_Draw(Actor* thisx, GlobalContext* globalCtx2) { - GlobalContext* globalCtx = globalCtx2; +void Boss06_Draw(Actor* thisx, PlayState* play2) { + PlayState* play = play2; Boss06* this = THIS; s32 i; f32 spE0 = 0.0f; @@ -511,17 +510,17 @@ void Boss06_Draw(Actor* thisx, GlobalContext* globalCtx2) { u16 pad; u8 spD3; u8 spD2; - s32 maxColor = 255; // Possible FAKE MATCH + s32 maxColor = 255; //! FAKE: f32 sp68; - OPEN_DISPS(globalCtx->state.gfxCtx); + OPEN_DISPS(play->state.gfxCtx); - func_8012C2DC(globalCtx->state.gfxCtx); - func_8012C28C(globalCtx->state.gfxCtx); + func_8012C2DC(play->state.gfxCtx); + func_8012C28C(play->state.gfxCtx); temp_v0 = gSaveContext.save.time; if (temp_v0 > CLOCK_TIME(12, 0)) { - temp_v0 = 0xFFFF - temp_v0; + temp_v0 = (DAY_LENGTH - 1) - temp_v0; } sp68 = (f32)temp_v0 / 0x8000; spD3 = ((10.0f * sp68) + 105.0f) * this->unk_19C; @@ -571,13 +570,13 @@ void Boss06_Draw(Actor* thisx, GlobalContext* globalCtx2) { child->world.pos.z = (this->actor.world.pos.z - 170.0f) + (temp_f10 * 0.1f); } - 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); + AnimatedMat_Draw(play, Lib_SegmentedToVirtual(&object_knight_Matanimheader_019360)); + 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); + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); 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, 255, 255, maxColor, (u8)((100.0f * sp68) + 65.0f), spD2); @@ -589,18 +588,18 @@ void Boss06_Draw(Actor* thisx, GlobalContext* globalCtx2) { 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); + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(play->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); @@ -608,27 +607,27 @@ void Boss06_Draw(Actor* thisx, GlobalContext* globalCtx2) { 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)); + Gfx_TwoTexScroll(play->state.gfxCtx, 0, 0, 0, 0x20, 0x40, 1, 0, + ((play->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.02f / 10.0f, -this->unk_1D8, 1.0f, MTXMODE_APPLY); - gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - gSPDisplayList(POLY_XLU_DISP++, gGameplayKeepDrawFlameDL); + gSPDisplayList(POLY_XLU_DISP++, gEffFire1DL); - Matrix_StatePop(); + Matrix_Pop(); } } } else { @@ -639,20 +638,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++, 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(play->gameplayFrames * 64, MTXMODE_APPLY); - gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_XLU_DISP++, gLightOrbVtxDL); } - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->state.gfxCtx); } diff --git a/src/overlays/actors/ovl_Boss_06/z_boss_06.h b/src/overlays/actors/ovl_Boss_06/z_boss_06.h index d7e6875a2..39d2f900a 100644 --- a/src/overlays/actors/ovl_Boss_06/z_boss_06.h +++ b/src/overlays/actors/ovl_Boss_06/z_boss_06.h @@ -5,49 +5,49 @@ struct Boss06; -typedef void (*Boss06ActionFunc)(struct Boss06*, GlobalContext*); +typedef void (*Boss06ActionFunc)(struct Boss06*, PlayState*); #define ENBOSS06_GET_PARAMS(thisx) ((thisx)->params) typedef struct Boss06 { - /* 0x0000 */ Actor actor; - /* 0x0144 */ u8 unk_144; - /* 0x0146 */ s16 unk_146; - /* 0x0148 */ s16 unk_148; - /* 0x014C */ ColliderCylinder collider; - /* 0x0198 */ Boss06ActionFunc actionFunc; - /* 0x019C */ f32 unk_19C; - /* 0x01A0 */ f32 unk_1A0; - /* 0x01A4 */ f32 unk_1A4; - /* 0x01A8 */ f32 unk_1A8; - /* 0x01AC */ f32 unk_1AC; - /* 0x01B0 */ f32 unk_1B0; - /* 0x01B4 */ f32 unk_1B4; - /* 0x01B8 */ UNK_TYPE1 unk1B8[4]; - /* 0x01BC */ f32 unk_1BC; - /* 0x01C0 */ f32 unk_1C0; - /* 0x01C4 */ UNK_TYPE1 unk1C4[4]; - /* 0x01C8 */ u8 unk_1C8; - /* 0x01C9 */ u8 unk_1C9; - /* 0x01CA */ s16 unk_1CA; - /* 0x01CC */ f32 unk_1CC; - /* 0x01D0 */ f32 unk_1D0; - /* 0x01D4 */ f32 unk_1D4; - /* 0x01D8 */ f32 unk_1D8; - /* 0x01DC */ f32 unk_1DC; - /* 0x01E0 */ f32 unk_1E0; - /* 0x01E4 */ f32 unk_1E4; - /* 0x01E8 */ UNK_TYPE1 unk1E8[0x15]; - /* 0x01FD */ u8 unk_1FD; - /* 0x01FE */ u8 unk_1FE; - /* 0x01FF */ u8 unk_1FF; - /* 0x0200 */ u8 unk_200[0x800]; - /* 0x0A00 */ s16 unk_A00; - /* 0x0A04 */ Vec3f unk_A04; - /* 0x0A10 */ Vec3f unk_A10; - /* 0x0A1C */ Vec3f unk_A1C; - /* 0x0A28 */ f32 unk_A28; - /* 0x0A2C */ f32 unk_A2C; + /* 0x000 */ Actor actor; + /* 0x144 */ u8 unk_144; + /* 0x146 */ s16 unk_146; + /* 0x148 */ s16 unk_148; + /* 0x14C */ ColliderCylinder collider; + /* 0x198 */ Boss06ActionFunc actionFunc; + /* 0x19C */ f32 unk_19C; + /* 0x1A0 */ f32 unk_1A0; + /* 0x1A4 */ f32 unk_1A4; + /* 0x1A8 */ f32 unk_1A8; + /* 0x1AC */ f32 unk_1AC; + /* 0x1B0 */ f32 unk_1B0; + /* 0x1B4 */ f32 unk_1B4; + /* 0x1B8 */ UNK_TYPE1 unk1B8[4]; + /* 0x1BC */ f32 unk_1BC; + /* 0x1C0 */ f32 unk_1C0; + /* 0x1C4 */ UNK_TYPE1 unk1C4[4]; + /* 0x1C8 */ u8 unk_1C8; + /* 0x1C9 */ u8 unk_1C9; + /* 0x1CA */ s16 unk_1CA; + /* 0x1CC */ f32 unk_1CC; + /* 0x1D0 */ f32 unk_1D0; + /* 0x1D4 */ f32 unk_1D4; + /* 0x1D8 */ f32 unk_1D8; + /* 0x1DC */ f32 unk_1DC; + /* 0x1E0 */ f32 unk_1E0; + /* 0x1E4 */ f32 unk_1E4; + /* 0x1E8 */ UNK_TYPE1 unk1E8[0x15]; + /* 0x1FD */ u8 unk_1FD; + /* 0x1FE */ u8 unk_1FE; + /* 0x1FF */ u8 unk_1FF; + /* 0x200 */ u8 unk_200[0x800]; + /* 0xA00 */ s16 subCamId; + /* 0xA04 */ Vec3f subCamEye; + /* 0xA10 */ Vec3f subCamAt; + /* 0xA1C */ Vec3f unk_A1C; + /* 0xA28 */ f32 unk_A28; + /* 0xA2C */ f32 unk_A2C; } Boss06; // size = 0xA30 extern const ActorInit Boss_06_InitVars; diff --git a/src/overlays/actors/ovl_Boss_07/z_boss_07.c b/src/overlays/actors/ovl_Boss_07/z_boss_07.c index 9e8841034..9b988da18 100644 --- a/src/overlays/actors/ovl_Boss_07/z_boss_07.c +++ b/src/overlays/actors/ovl_Boss_07/z_boss_07.c @@ -10,47 +10,47 @@ #define THIS ((Boss07*)thisx) -void Boss07_Init(Actor* thisx, GlobalContext* globalCtx); -void Boss07_Destroy(Actor* thisx, GlobalContext* globalCtx); -void Boss07_Update(Actor* thisx, GlobalContext* globalCtx); -void Boss07_Draw(Actor* thisx, GlobalContext* globalCtx); +void Boss07_Init(Actor* thisx, PlayState* play); +void Boss07_Destroy(Actor* thisx, PlayState* play); +void Boss07_Update(Actor* thisx, PlayState* play); +void Boss07_Draw(Actor* thisx, PlayState* play); -void func_809F5E88(Boss07* this, GlobalContext* globalCtx); -void func_809F65F4(Boss07* this, GlobalContext* globalCtx); -void func_809F748C(Boss07* this, GlobalContext* globalCtx); -void func_809F76D0(Boss07* this, GlobalContext* globalCtx); -void func_809F77A8(Boss07* this, GlobalContext* globalCtx); -void func_809F7968(Boss07* this, GlobalContext* globalCtx); -void func_809F7BC4(Boss07* this, GlobalContext* globalCtx); -void func_809F805C(Boss07* this, GlobalContext* globalCtx); -void func_809F86B8(Boss07* this, GlobalContext* globalCtx); -void func_809F87C8(Boss07* this, GlobalContext* globalCtx); -void func_809F8908(Boss07* this, GlobalContext* globalCtx); -void func_809F8B1C(Boss07* this, GlobalContext* globalCtx); -void func_809F8D04(Boss07* this, GlobalContext* globalCtx); -void func_809F8EC8(Boss07* this, GlobalContext* globalCtx); -void func_809F91D4(Boss07* this, GlobalContext* globalCtx); -void func_809FCCCC(Boss07* this, GlobalContext* globalCtx); -void func_809FD710(Boss07* this, GlobalContext* globalCtx); -void func_809FD89C(Boss07* this, GlobalContext* globalCtx); -void func_809FDAB0(Boss07* this, GlobalContext* globalCtx); -void func_809FDF54(Boss07* this, GlobalContext* globalCtx); -void func_809FE0E4(Boss07* this, GlobalContext* globalCtx); -void func_809FE348(Boss07* this, GlobalContext* globalCtx); -void func_809FE524(Boss07* this, GlobalContext* globalCtx); -void func_809FE734(Boss07* this, GlobalContext* globalCtx); -void func_809FFA80(Boss07* this, GlobalContext* globalCtx); -void func_809FFEAC(Boss07* this, GlobalContext* globalCtx); -void func_80A00274(Boss07* this, GlobalContext* globalCtx); -void func_80A00554(Boss07* this, GlobalContext* globalCtx); -void func_80A00720(Boss07* this, GlobalContext* globalCtx); -void func_80A01750(Boss07* this, GlobalContext* globalCtx); -void func_80A0264C(Boss07* this, GlobalContext* globalCtx); -void func_80A04890(Boss07* this, GlobalContext* globalCtx); -void func_80A04E5C(Boss07* this, GlobalContext* globalCtx); -void func_80A05608(Boss07* this, GlobalContext* globalCtx); -void func_80A05B50(Boss07* this, GlobalContext* globalCtx); -void func_80A05DDC(Boss07* this, GlobalContext* globalCtx); +void func_809F5E88(Boss07* this, PlayState* play); +void func_809F65F4(Boss07* this, PlayState* play); +void func_809F748C(Boss07* this, PlayState* play); +void func_809F76D0(Boss07* this, PlayState* play); +void func_809F77A8(Boss07* this, PlayState* play); +void func_809F7968(Boss07* this, PlayState* play); +void func_809F7BC4(Boss07* this, PlayState* play); +void func_809F805C(Boss07* this, PlayState* play); +void func_809F86B8(Boss07* this, PlayState* play); +void func_809F87C8(Boss07* this, PlayState* play); +void func_809F8908(Boss07* this, PlayState* play); +void func_809F8B1C(Boss07* this, PlayState* play); +void func_809F8D04(Boss07* this, PlayState* play); +void func_809F8EC8(Boss07* this, PlayState* play); +void func_809F91D4(Boss07* this, PlayState* play); +void func_809FCCCC(Boss07* this, PlayState* play); +void func_809FD710(Boss07* this, PlayState* play); +void func_809FD89C(Boss07* this, PlayState* play); +void func_809FDAB0(Boss07* this, PlayState* play); +void func_809FDF54(Boss07* this, PlayState* play); +void func_809FE0E4(Boss07* this, PlayState* play); +void func_809FE348(Boss07* this, PlayState* play); +void func_809FE524(Boss07* this, PlayState* play); +void func_809FE734(Boss07* this, PlayState* play); +void func_809FFA80(Boss07* this, PlayState* play); +void func_809FFEAC(Boss07* this, PlayState* play); +void func_80A00274(Boss07* this, PlayState* play); +void func_80A00554(Boss07* this, PlayState* play); +void func_80A00720(Boss07* this, PlayState* play); +void func_80A01750(Boss07* this, PlayState* play); +void func_80A0264C(Boss07* this, PlayState* play); +void func_80A04890(Boss07* this, PlayState* play); +void func_80A04E5C(Boss07* this, PlayState* play); +void func_80A05608(Boss07* this, PlayState* play); +void func_80A05B50(Boss07* this, PlayState* play); +void func_80A05DDC(Boss07* this, PlayState* play); #if 0 // static DamageTable sDamageTable = { @@ -296,7 +296,7 @@ static ColliderJntSphElementInit D_80A07A40[11] = { // static ColliderJntSphInit sJntSphInit = { static ColliderJntSphInit D_80A07BCC = { { COLTYPE_HIT3, AT_ON | AT_TYPE_ENEMY, AC_ON | AC_TYPE_PLAYER, OC1_ON | OC1_TYPE_PLAYER, OC2_TYPE_1, COLSHAPE_JNTSPH, }, - 11, D_80A07A40, // sJntSphElementsInit, + ARRAY_COUNT(sJntSphElementsInit), D_80A07A40, // sJntSphElementsInit, }; // static ColliderCylinderInit sCylinderInit = { @@ -317,7 +317,7 @@ static ColliderJntSphElementInit D_80A07C08[1] = { // static ColliderJntSphInit sJntSphInit = { static ColliderJntSphInit D_80A07C2C = { { COLTYPE_HIT3, AT_ON | AT_TYPE_ENEMY, AC_ON | AC_TYPE_PLAYER, OC1_ON | OC1_TYPE_PLAYER, OC2_TYPE_1, COLSHAPE_JNTSPH, }, - 1, D_80A07C08, // sJntSphElementsInit, + ARRAY_COUNT(sJntSphElementsInit), D_80A07C08, // sJntSphElementsInit, }; // static ColliderQuadInit sQuadInit = { @@ -385,7 +385,7 @@ static ColliderJntSphElementInit D_80A07CDC[11] = { // static ColliderJntSphInit sJntSphInit = { static ColliderJntSphInit D_80A07E68 = { { COLTYPE_HIT3, AT_ON | AT_TYPE_ENEMY, AC_ON | AC_TYPE_PLAYER, OC1_ON | OC1_TYPE_PLAYER, OC2_TYPE_1, COLSHAPE_JNTSPH, }, - 11, D_80A07CDC, // sJntSphElementsInit, + ARRAY_COUNT(sJntSphElementsInit), D_80A07CDC, // sJntSphElementsInit, }; // static ColliderCylinderInit sCylinderInit = { diff --git a/src/overlays/actors/ovl_Boss_07/z_boss_07.h b/src/overlays/actors/ovl_Boss_07/z_boss_07.h index b8ace3f9c..f8a4d4d91 100644 --- a/src/overlays/actors/ovl_Boss_07/z_boss_07.h +++ b/src/overlays/actors/ovl_Boss_07/z_boss_07.h @@ -5,7 +5,7 @@ struct Boss07; -typedef void (*Boss07ActionFunc)(struct Boss07*, GlobalContext*); +typedef void (*Boss07ActionFunc)(struct Boss07*, PlayState*); typedef struct Boss07 { /* 0x0000 */ Actor actor; 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 d8ebaf7eb..75f530c48 100644 --- a/src/overlays/actors/ovl_Boss_Hakugin/z_boss_hakugin.c +++ b/src/overlays/actors/ovl_Boss_Hakugin/z_boss_hakugin.c @@ -5,31 +5,32 @@ */ #include "z_boss_hakugin.h" +#include "z64rumble.h" #define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_4 | ACTOR_FLAG_10 | ACTOR_FLAG_20) #define THIS ((BossHakugin*)thisx) -void BossHakugin_Init(Actor* thisx, GlobalContext* globalCtx); -void BossHakugin_Destroy(Actor* thisx, GlobalContext* globalCtx); -void BossHakugin_Update(Actor* thisx, GlobalContext* globalCtx); -void BossHakugin_Draw(Actor* thisx, GlobalContext* globalCtx); +void BossHakugin_Init(Actor* thisx, PlayState* play); +void BossHakugin_Destroy(Actor* thisx, PlayState* play); +void BossHakugin_Update(Actor* thisx, PlayState* play); +void BossHakugin_Draw(Actor* thisx, PlayState* play); -void func_80B08018(BossHakugin* this, GlobalContext* globalCtx); -void func_80B0813C(BossHakugin* this, GlobalContext* globalCtx); -void func_80B082AC(BossHakugin* this, GlobalContext* globalCtx); -void func_80B0863C(BossHakugin* this, GlobalContext* globalCtx); -void func_80B08960(BossHakugin* this, GlobalContext* globalCtx); -void func_80B08CB8(BossHakugin* this, GlobalContext* globalCtx); -void func_80B091D8(BossHakugin* this, GlobalContext* globalCtx); -void func_80B094E0(BossHakugin* this, GlobalContext* globalCtx); -void func_80B098BC(BossHakugin* this, GlobalContext* globalCtx); -void func_80B09C78(BossHakugin* this, GlobalContext* globalCtx); -void func_80B09E20(BossHakugin* this, GlobalContext* globalCtx); -void func_80B09EDC(BossHakugin* this, GlobalContext* globalCtx); -void func_80B0A2A4(BossHakugin* this, GlobalContext* globalCtx); -void func_80B0A638(BossHakugin* this, GlobalContext* globalCtx); -void func_80B0A8C4(BossHakugin* this, GlobalContext* globalCtx); +void func_80B08018(BossHakugin* this, PlayState* play); +void func_80B0813C(BossHakugin* this, PlayState* play); +void func_80B082AC(BossHakugin* this, PlayState* play); +void func_80B0863C(BossHakugin* this, PlayState* play); +void func_80B08960(BossHakugin* this, PlayState* play); +void func_80B08CB8(BossHakugin* this, PlayState* play); +void func_80B091D8(BossHakugin* this, PlayState* play); +void func_80B094E0(BossHakugin* this, PlayState* play); +void func_80B098BC(BossHakugin* this, PlayState* play); +void func_80B09C78(BossHakugin* this, PlayState* play); +void func_80B09E20(BossHakugin* this, PlayState* play); +void func_80B09EDC(BossHakugin* this, PlayState* play); +void func_80B0A2A4(BossHakugin* this, PlayState* play); +void func_80B0A638(BossHakugin* this, PlayState* play); +void func_80B0A8C4(BossHakugin* this, PlayState* play); #if 0 const ActorInit Boss_Hakugin_InitVars = { @@ -127,7 +128,7 @@ static ColliderJntSphElementInit D_80B0E700[19] = { // static ColliderJntSphInit sJntSphInit = { static ColliderJntSphInit D_80B0E9AC = { { COLTYPE_METAL, AT_ON | AT_TYPE_ENEMY, AC_ON | AC_HARD | AC_TYPE_PLAYER, OC1_ON | OC1_TYPE_ALL, OC2_TYPE_1, COLSHAPE_JNTSPH, }, - 19, D_80B0E700, // sJntSphElementsInit, + ARRAY_COUNT(sJntSphElementsInit), D_80B0E700, // sJntSphElementsInit, }; // static ColliderTrisElementInit sTrisElementsInit[1] = { @@ -141,7 +142,7 @@ static ColliderTrisElementInit D_80B0E9BC[1] = { // static ColliderTrisInit sTrisInit = { static ColliderTrisInit D_80B0E9F8 = { { COLTYPE_NONE, AT_ON | AT_TYPE_ENEMY, AC_NONE, OC1_NONE, OC2_TYPE_1, COLSHAPE_TRIS, }, - 1, D_80B0E9BC, // sTrisElementsInit, + ARRAY_COUNT(sTrisElementsInit), D_80B0E9BC, // sTrisElementsInit, }; // static ColliderSphereInit sSphereInit = { diff --git a/src/overlays/actors/ovl_Boss_Hakugin/z_boss_hakugin.h b/src/overlays/actors/ovl_Boss_Hakugin/z_boss_hakugin.h index 3b5882692..4b8227021 100644 --- a/src/overlays/actors/ovl_Boss_Hakugin/z_boss_hakugin.h +++ b/src/overlays/actors/ovl_Boss_Hakugin/z_boss_hakugin.h @@ -5,24 +5,35 @@ struct BossHakugin; -typedef void (*BossHakuginActionFunc)(struct BossHakugin*, GlobalContext*); +typedef void (*BossHakuginActionFunc)(struct BossHakugin*, PlayState*); -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 BossHakuginFhgFlashUnkStruct { + /* 0x00 */ Vec3f unk_00; + /* 0x0C */ char unk_0C[0x8]; +} BossHakuginFhgFlashUnkStruct; // size = 0x14 typedef struct BossHakugin { /* 0x0000 */ Actor actor; /* 0x0144 */ char unk_0144[0x44]; /* 0x0188 */ BossHakuginActionFunc actionFunc; - /* 0x018C */ char unk_018C[0x86C]; - /* 0x09F8 */ BossHakuginParticle unk_9F8[180]; - /* 0x2618 */ char unk_2618[0x11F8]; + /* 0x018C */ char unk_018C[0x5]; + /* 0x0191 */ u8 unk_191; + /* 0x018C */ char unk_0192[0x866]; + /* 0x09F8 */ BossHakuginEffect unk_9F8[BOSS_HAKUGIN_EFFECT_COUNT]; + /* 0x2618 */ char unk_2618[0x8E8]; + /* 0x2F00 */ BossHakuginFhgFlashUnkStruct unk_2F00[7][15]; + /* 0x3734 */ char unk_3734[0xDC]; } BossHakugin; // size = 0x3810 extern const ActorInit Boss_Hakugin_InitVars; 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 18be6991c..8b5deef59 100644 --- a/src/overlays/actors/ovl_Demo_Effect/z_demo_effect.c +++ b/src/overlays/actors/ovl_Demo_Effect/z_demo_effect.c @@ -5,21 +5,26 @@ */ #include "z_demo_effect.h" +#include "objects/gameplay_keep/gameplay_keep.h" +#include "objects/object_efc_tw/object_efc_tw.h" #define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_20) #define THIS ((DemoEffect*)thisx) -void DemoEffect_Init(Actor* thisx, GlobalContext* globalCtx); -void DemoEffect_Destroy(Actor* thisx, GlobalContext* globalCtx); -void DemoEffect_Update(Actor* thisx, GlobalContext* globalCtx); +void DemoEffect_Init(Actor* thisx, PlayState* play); +void DemoEffect_Destroy(Actor* thisx, PlayState* play); +void DemoEffect_Update(Actor* thisx, PlayState* play); -void func_808CD940(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_808CD940(DemoEffect* this, PlayState* play); +void func_808CD998(DemoEffect* this, PlayState* play); +void func_808CDBDC(DemoEffect* this, PlayState* play); +void func_808CDCEC(DemoEffect* this, PlayState* play); +void func_808CDD70(DemoEffect* this, PlayState* play); +void func_808CDDE0(DemoEffect* this, PlayState* play); +void func_808CDFF8(Actor* thisx, PlayState* play); +void func_808CE078(Actor* thisx, PlayState* play2); -#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, PlayState* play) { + 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(&play->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, PlayState* play) { + 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(play, &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, PlayState* play) { + if (Object_IsLoaded(&play->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, PlayState* play) { + s32 type = DEMO_EFFECT_GET_TYPE(&this->actor); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Demo_Effect/func_808CE078.s") + if (SkelCurve_Init(play, &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(play, &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, PlayState* play) { + 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, PlayState* play) { + func_800B8FE8(&this->actor, NA_SE_EV_TIMETRIP_LIGHT - SFX_FLAG); + + if (SkelCurve_Update(play, &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, PlayState* play) { + 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, PlayState* play) { + 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, PlayState* play) { + DemoEffect* this = THIS; + + this->actionFunc(this, play); +} + +s32 func_808CDE78(PlayState* play, SkelCurve* skelCurve, s32 limbIndex, Actor* thisx) { + s32 pad; + DemoEffect* this = THIS; + u32 frames = play->gameplayFrames; + + OPEN_DISPS(play->state.gfxCtx); + + func_8012C2DC(play->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(play->state.gfxCtx, 0, (frames * 6) % 1024, 255 - ((frames * 16) % 256), 0x100, 0x40, 1, + (frames * 4) % 512, 127 - ((frames * 12) % 128), 0x80, 0x20)); + + CLOSE_DISPS(play->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, PlayState* play) { + GraphicsContext* gfxCtx = play->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, play, &this->skelCurve, func_808CDE78, NULL, 1, &this->actor); + + CLOSE_DISPS(gfxCtx); +} + +void func_808CE078(Actor* thisx, PlayState* play2) { + PlayState* play = play2; + DemoEffect* this = THIS; + s16 zRot = (this->timer * 0x400) & 0xFFFF; + + OPEN_DISPS(play->state.gfxCtx); + + func_8012C2DC(play->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(&play->billboardMtxF, MTXMODE_APPLY); + Matrix_Push(); + Matrix_RotateZS(zRot, MTXMODE_APPLY); + + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_XLU_DISP++, gameplay_keep_DL_023288); + + Matrix_Pop(); + Matrix_RotateZS(-zRot, MTXMODE_APPLY); + + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_XLU_DISP++, gameplay_keep_DL_023288); + + CLOSE_DISPS(play->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..985e2c30c 100644 --- a/src/overlays/actors/ovl_Demo_Effect/z_demo_effect.h +++ b/src/overlays/actors/ovl_Demo_Effect/z_demo_effect.h @@ -2,15 +2,36 @@ #define Z_DEMO_EFFECT_H #include "global.h" +#include "z64curve.h" struct DemoEffect; -typedef void (*DemoEffectActionFunc)(struct DemoEffect*, GlobalContext*); +typedef void (*DemoEffectActionFunc)(struct DemoEffect*, PlayState*); + +#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]; - /* 0x0178 */ DemoEffectActionFunc actionFunc; + /* 0x000 */ Actor actor; + /* 0x144 */ SkelCurve skelCurve; + /* 0x164 */ u8 initObjectIndex; + /* 0x165 */ u8 primXluColor[3]; + /* 0x168 */ u8 envXluColor[3]; + /* 0x16C */ s16 timer; + /* 0x170 */ DemoEffectActionFunc initActionFunc; + /* 0x174 */ ActorFunc initDrawFunc; + /* 0x178 */ DemoEffectActionFunc actionFunc; } DemoEffect; // size = 0x17C extern const ActorInit Demo_Effect_InitVars; diff --git a/src/overlays/actors/ovl_Demo_Getitem/z_demo_getitem.c b/src/overlays/actors/ovl_Demo_Getitem/z_demo_getitem.c index 9e6661fd0..d39c8aa17 100644 --- a/src/overlays/actors/ovl_Demo_Getitem/z_demo_getitem.c +++ b/src/overlays/actors/ovl_Demo_Getitem/z_demo_getitem.c @@ -1,7 +1,7 @@ /* * File: z_demo_getitem.c * Overlay: ovl_Demo_Getitem - * Description: Cutscene object for Great Fairy's Mask and Great Fairy's Sword + * Description: Cutscene objectIndex for Great Fairy's Mask and Great Fairy's Sword */ #include "z_demo_getitem.h" @@ -10,11 +10,14 @@ #define THIS ((DemoGetitem*)thisx) -void DemoGetitem_Init(Actor* thisx, GlobalContext* globalCtx); -void DemoGetitem_Destroy(Actor* thisx, GlobalContext* globalCtx); -void DemoGetitem_Update(Actor* thisx, GlobalContext* globalCtx); +void DemoGetitem_Init(Actor* thisx, PlayState* play); +void DemoGetitem_Destroy(Actor* thisx, PlayState* play); +void DemoGetitem_Update(Actor* thisx, PlayState* play); + +void func_80A4FB10(DemoGetitem* this, PlayState* play); +void func_80A4FB68(DemoGetitem* this, PlayState* play2); +void DemoGetitem_Draw(Actor* thisx, PlayState* play); -#if 0 const ActorInit Demo_Getitem_InitVars = { ACTOR_DEMO_GETITEM, ACTORCAT_BG, @@ -27,16 +30,84 @@ const ActorInit Demo_Getitem_InitVars = { (ActorFunc)NULL, }; -#endif +static s16 sObjectBankIndices[] = { OBJECT_GI_MASK14, OBJECT_GI_SWORD_4 }; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Demo_Getitem/DemoGetitem_Init.s") +static s16 sGetItemDraws[] = { GID_MASK_GREAT_FAIRY, GID_SWORD_GREAT_FAIRY }; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Demo_Getitem/DemoGetitem_Destroy.s") +static u16 sCsActionIndices[] = { 0x6E, 0x236 }; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Demo_Getitem/func_80A4FB10.s") +void DemoGetitem_Init(Actor* thisx, PlayState* play) { + s32 pad; + s32 objectIndex; + s32 itemIndex; + DemoGetitem* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Demo_Getitem/func_80A4FB68.s") + itemIndex = 0; + if (DEMOGETITEM_GET_F(thisx) == 1) { + itemIndex = 1; + } + Actor_SetScale(&this->actor, 0.25f); + this->actionFunc = func_80A4FB10; + this->item = sGetItemDraws[itemIndex]; + this->csAction = sCsActionIndices[itemIndex]; + objectIndex = Object_GetIndex(&play->objectCtx, sObjectBankIndices[itemIndex]); + if (objectIndex < 0) { + Actor_MarkForDeath(&this->actor); + } else { + this->objectIndex = objectIndex; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Demo_Getitem/DemoGetitem_Update.s") +void DemoGetitem_Destroy(Actor* thisx, PlayState* play) { +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Demo_Getitem/func_80A4FCF0.s") +void func_80A4FB10(DemoGetitem* this, PlayState* play) { + if (Object_IsLoaded(&play->objectCtx, this->objectIndex)) { + this->actor.draw = NULL; + this->actor.objBankIndex = this->objectIndex; + this->actionFunc = func_80A4FB68; + } +} + +void func_80A4FB68(DemoGetitem* this, PlayState* play2) { + PlayState* play = play2; + u16 sp22 = (play->gameplayFrames * 1000) & 0xFFFF; + + if (Cutscene_CheckActorAction(play, this->csAction)) { + if (play->csCtx.actorActions[Cutscene_GetActorActionIndex(play, this->csAction)]->action != 4) { + this->actor.shape.yOffset = 0.0f; + } + switch (play->csCtx.actorActions[Cutscene_GetActorActionIndex(play, this->csAction)]->action) { + case 2: + this->actor.draw = DemoGetitem_Draw; + Cutscene_ActorTranslate(&this->actor, play, Cutscene_GetActorActionIndex(play, this->csAction)); + this->actor.shape.rot.y += 0x3E8; + return; + case 3: + Actor_MarkForDeath(&this->actor); + return; + case 4: + this->actor.draw = DemoGetitem_Draw; + Cutscene_ActorTranslateAndYaw(&this->actor, play, Cutscene_GetActorActionIndex(play, this->csAction)); + this->actor.shape.yOffset = Math_SinS(sp22) * 15.0f; + return; + } + this->actor.draw = NULL; + } else { + this->actor.draw = NULL; + } +} + +void DemoGetitem_Update(Actor* thisx, PlayState* play) { + DemoGetitem* this = THIS; + + this->actionFunc(this, play); +} + +void DemoGetitem_Draw(Actor* thisx, PlayState* play) { + DemoGetitem* this = THIS; + + func_800B8050(&this->actor, play, 0); + func_800B8118(&this->actor, play, 0); + GetItem_Draw(play, this->item); +} diff --git a/src/overlays/actors/ovl_Demo_Getitem/z_demo_getitem.h b/src/overlays/actors/ovl_Demo_Getitem/z_demo_getitem.h index 880f79fe2..acc2c0312 100644 --- a/src/overlays/actors/ovl_Demo_Getitem/z_demo_getitem.h +++ b/src/overlays/actors/ovl_Demo_Getitem/z_demo_getitem.h @@ -3,14 +3,18 @@ #include "global.h" +#define DEMOGETITEM_GET_F(thisx) ((thisx)->params & 0xF) + struct DemoGetitem; -typedef void (*DemoGetitemActionFunc)(struct DemoGetitem*, GlobalContext*); +typedef void (*DemoGetitemActionFunc)(struct DemoGetitem*, PlayState*); typedef struct DemoGetitem { - /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x8]; - /* 0x014C */ DemoGetitemActionFunc actionFunc; + /* 0x000 */ Actor actor; + /* 0x144 */ s16 item; + /* 0x146 */ u16 csAction; + /* 0x148 */ s8 objectIndex; + /* 0x14C */ DemoGetitemActionFunc actionFunc; } DemoGetitem; // size = 0x150 extern const ActorInit Demo_Getitem_InitVars; diff --git a/src/overlays/actors/ovl_Demo_Kankyo/z_demo_kankyo.c b/src/overlays/actors/ovl_Demo_Kankyo/z_demo_kankyo.c index b51fc64ec..64c42a1ce 100644 --- a/src/overlays/actors/ovl_Demo_Kankyo/z_demo_kankyo.c +++ b/src/overlays/actors/ovl_Demo_Kankyo/z_demo_kankyo.c @@ -1,7 +1,7 @@ /* * 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" @@ -12,12 +12,12 @@ #define THIS ((DemoKankyo*)thisx) -void DemoKankyo_Init(Actor* thisx, GlobalContext* globalCtx); -void DemoKankyo_Destroy(Actor* thisx, GlobalContext* globalCtx); -void DemoKankyo_Update(Actor* thisx, GlobalContext* globalCtx); -void DemoKankyo_Draw(Actor* thisx, GlobalContext* globalCtx); +void DemoKankyo_Init(Actor* thisx, PlayState* play); +void DemoKankyo_Destroy(Actor* thisx, PlayState* play); +void DemoKankyo_Update(Actor* thisx, PlayState* play); +void DemoKankyo_Draw(Actor* thisx, PlayState* play); -void DemoKakyo_MoonSparklesActionFunc(DemoKankyo* this, GlobalContext* globalCtx); +void DemoKakyo_MoonSparklesActionFunc(DemoKankyo* this, PlayState* play); static u8 sLostWoodsSparklesMutex = false; // make sure only one can exist at once static s16 sLostWoodsSkyFishParticleNum = 0; @@ -40,11 +40,11 @@ void DemoKankyo_SetupAction(DemoKankyo* this, DemoKankyoActionFunc actionFunc) { this->actionFunc = actionFunc; } -void DemoKakyo_LostWoodsSparkleActionFunc(DemoKankyo* this, GlobalContext* globalCtx) { +void DemoKakyo_LostWoodsSparkleActionFunc(DemoKankyo* this, PlayState* play) { 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; @@ -53,81 +53,81 @@ void DemoKakyo_LostWoodsSparkleActionFunc(DemoKankyo* this, GlobalContext* globa f32 posCenterY; f32 posCenterZ; Vec3f eyeToAt; - Player* player = GET_PLAYER(globalCtx); + Player* player = GET_PLAYER(play); - if (globalCtx->roomCtx.unk7A[1] != 0) { - if (globalCtx->envCtx.unk_F2[3] != 0) { - globalCtx->envCtx.unk_F2[3]--; + if (play->roomCtx.unk7A[1] != 0) { + if (play->envCtx.unk_F2[3] != 0) { + play->envCtx.unk_F2[3]--; } else { Actor_MarkForDeath(&this->actor); } - } else if (globalCtx->envCtx.unk_F2[3] < DEMOKANKYO_PARTICLE_COUNT) { - globalCtx->envCtx.unk_F2[3] += 16; + } else if (play->envCtx.unk_F2[3] < DEMOKANKYO_EFFECT_COUNT) { + play->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++) { + for (i = 0; i < play->envCtx.unk_F2[3]; i++) { repositionLimit = 130.0f; - eyeToAt.x = globalCtx->view.at.x - globalCtx->view.eye.x; - eyeToAt.y = globalCtx->view.at.y - globalCtx->view.eye.y; - eyeToAt.z = globalCtx->view.at.z - globalCtx->view.eye.z; + eyeToAt.x = play->view.at.x - play->view.eye.x; + eyeToAt.y = play->view.at.y - play->view.eye.y; + eyeToAt.z = play->view.at.z - play->view.eye.z; eyeToAtMag = sqrtf(SQXYZ(eyeToAt)); eyeToAtNormX = eyeToAt.x / eyeToAtMag; 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 = play->view.eye.x + (eyeToAtNormX * 80.0f); + this->effects[i].posBase.y = play->view.eye.y + (eyeToAtNormY * 80.0f); + this->effects[i].posBase.z = play->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++; - 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].alphaClock++; + posCenterX = play->view.eye.x + (eyeToAtNormX * 80.0f); + posCenterY = play->view.eye.y + (eyeToAtNormY * 80.0f); + posCenterZ = play->view.eye.z + (eyeToAtNormZ * 80.0f); + 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,157 +145,141 @@ 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; } } } -void DemoKakyo_GiantObjectCheck(DemoKankyo* this, GlobalContext* globalCtx) { - if (Object_IsLoaded(&globalCtx->objectCtx, this->objectId)) { +void DemoKakyo_GiantObjectCheck(DemoKankyo* this, PlayState* play) { + if (Object_IsLoaded(&play->objectCtx, this->objectId)) { this->isSafeToDrawGiants = true; this->actor.objBankIndex = this->objectId; DemoKankyo_SetupAction(this, DemoKakyo_MoonSparklesActionFunc); @@ -305,7 +289,7 @@ void DemoKakyo_GiantObjectCheck(DemoKankyo* this, GlobalContext* globalCtx) { /* * used by Moon AND giants types */ -void DemoKakyo_MoonSparklesActionFunc(DemoKankyo* this, GlobalContext* globalCtx) { +void DemoKakyo_MoonSparklesActionFunc(DemoKankyo* this, PlayState* play) { s32 i; Vec3f eyeToAt; f32 eyeToAtNormX; @@ -320,13 +304,13 @@ void DemoKakyo_MoonSparklesActionFunc(DemoKankyo* this, GlobalContext* globalCtx s32 pad1; Vec3f worldPos; - if (globalCtx->envCtx.unk_F2[3] < DEMOKANKYO_PARTICLE_COUNT) { - globalCtx->envCtx.unk_F2[3] += 16; + if (play->envCtx.unk_F2[3] < DEMOKANKYO_EFFECT_COUNT) { + play->envCtx.unk_F2[3] += 16; } - eyeToAt.x = globalCtx->view.at.x - globalCtx->view.eye.x; - eyeToAt.y = globalCtx->view.at.y - globalCtx->view.eye.y; - eyeToAt.z = globalCtx->view.at.z - globalCtx->view.eye.z; + eyeToAt.x = play->view.at.x - play->view.eye.x; + eyeToAt.y = play->view.at.y - play->view.eye.y; + eyeToAt.z = play->view.at.z - play->view.eye.z; eyeToAtMag = sqrtf(SQXYZ(eyeToAt)); eyeToAtNormX = eyeToAt.x / eyeToAtMag; eyeToAtNormY = eyeToAt.y / eyeToAtMag; @@ -334,122 +318,122 @@ 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) { + for (i = 0; i < play->envCtx.unk_F2[3]; i++) { + 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 = play->view.eye.x + (eyeToAtNormX * halfScreenHeight); + this->effects[i].posBase.y = play->view.eye.y + (eyeToAtNormY * halfScreenHeight); + this->effects[i].posBase.z = play->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 = - globalCtx->view.eye.y + (eyeToAtNormY * halfScreenHeight) + (SCREEN_HEIGHT / 3); + this->effects[i].posBase.y = + play->view.eye.y + (eyeToAtNormY * halfScreenHeight) + (SCREEN_HEIGHT / 3); } - newEye.x = globalCtx->view.eye.x + (eyeToAtNormX * halfScreenHeight); - newEye.y = globalCtx->view.eye.y + (eyeToAtNormY * halfScreenHeight); - newEye.z = globalCtx->view.eye.z + (eyeToAtNormZ * halfScreenHeight); + newEye.x = play->view.eye.x + (eyeToAtNormX * halfScreenHeight); + newEye.y = play->view.eye.y + (eyeToAtNormY * halfScreenHeight); + newEye.z = play->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 = Math_Vec3f_DistXZ(&worldPos, &play->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; } } } -void DemoKankyo_Init(Actor* thisx, GlobalContext* globalCtx) { +void DemoKankyo_Init(Actor* thisx, PlayState* play) { DemoKankyo* this = THIS; s32 pad; s32 i; @@ -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) {}; @@ -476,7 +460,7 @@ void DemoKankyo_Init(Actor* thisx, GlobalContext* globalCtx) { case DEMO_KANKYO_TYPE_GIANTS: this->isSafeToDrawGiants = false; - objId = Object_GetIndex(&globalCtx->objectCtx, sObjectBubbleIndex); + objId = Object_GetIndex(&play->objectCtx, sObjectBubbleIndex); DemoKankyo_SetupAction(this, DemoKakyo_GiantObjectCheck); break; @@ -497,20 +481,20 @@ void DemoKankyo_Init(Actor* thisx, GlobalContext* globalCtx) { } } -void DemoKankyo_Destroy(Actor* thisx, GlobalContext* globalCtx) { +void DemoKankyo_Destroy(Actor* thisx, PlayState* play) { DemoKankyo* this = THIS; Actor_MarkForDeath(&this->actor); } -void DemoKankyo_Update(Actor* thisx, GlobalContext* globalCtx) { +void DemoKankyo_Update(Actor* thisx, PlayState* play) { DemoKankyo* this = THIS; - this->actionFunc(this, globalCtx); + this->actionFunc(this, play); } -void DemoKakyo_DrawLostWoodsSparkle(Actor* thisx, GlobalContext* globalCtx2) { - GlobalContext* globalCtx = globalCtx2; +void DemoKakyo_DrawLostWoodsSparkle(Actor* thisx, PlayState* play2) { + PlayState* play = play2; DemoKankyo* this = THIS; s16 i; f32 scaleAlpha; @@ -518,90 +502,90 @@ void DemoKakyo_DrawLostWoodsSparkle(Actor* thisx, GlobalContext* globalCtx2) { Vec3f screenPos; // if not underwater - if (!(globalCtx->cameraPtrs[CAM_ID_MAIN]->flags2 & 0x100)) { - OPEN_DISPS(globalCtx->state.gfxCtx); + if (!(play->cameraPtrs[CAM_ID_MAIN]->stateFlags & CAM_STATE_UNDERWATER)) { + OPEN_DISPS(play->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); - 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; + for (i = 0; i < play->envCtx.unk_F2[3]; i++) { + 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 + Play_GetScreenPos(play, &worldPos, &screenPos); // 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; + if ((screenPos.x >= 0.0f) && (screenPos.x < SCREEN_WIDTH) && (screenPos.y >= 0.0f) && + (screenPos.y < SCREEN_HEIGHT)) { + 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(&play->billboardMtxF, MTXMODE_APPLY); + Matrix_RotateZF(DEGF_TO_RADF(play->state.frames * 20.0f), MTXMODE_APPLY); - gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_XLU_DISP++, gameplay_keep_DL_07AB58); } } - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->state.gfxCtx); } } // draw, giants and moon -void DemoKankyo_DrawMoonAndGiant(Actor* thisx, GlobalContext* globalCtx2) { - GlobalContext* globalCtx = globalCtx2; +void DemoKankyo_DrawMoonAndGiant(Actor* thisx, PlayState* play2) { + PlayState* play = play2; DemoKankyo* this = THIS; s16 i; f32 alphaScale; @@ -610,58 +594,58 @@ void DemoKankyo_DrawMoonAndGiant(Actor* thisx, GlobalContext* globalCtx2) { Vec3f worldPos; Vec3f screenPos; s32 pad; - GraphicsContext* gfxCtx = globalCtx->state.gfxCtx; + GraphicsContext* gfxCtx = play->state.gfxCtx; OPEN_DISPS(gfxCtx); 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; + for (i = 0; i < play->envCtx.unk_F2[3]; i++) { + 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 + Play_GetScreenPos(play, &worldPos, &screenPos); - // 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); - alphaScale = this->particles[i].alpha / 50.0f; + // checking if effect is on screen + if ((screenPos.x >= 0.0f) && (screenPos.x < SCREEN_WIDTH) && (screenPos.y >= 0.0f) && + (screenPos.y < SCREEN_HEIGHT)) { + 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); - alphaScale = Math_Vec3f_DistXYZ(&worldPos, &globalCtx->view.eye) / 300.0f; + Matrix_Scale(this->effects[i].scale * alphaScale, this->effects[i].scale * alphaScale, + this->effects[i].scale * alphaScale, MTXMODE_APPLY); + alphaScale = Math_Vec3f_DistXYZ(&worldPos, &play->view.eye) / 300.0f; 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++, &gLightOrb1DL); - Matrix_InsertMatrix(&globalCtx->billboardMtxF, MTXMODE_APPLY); + Matrix_Mult(&play->billboardMtxF, MTXMODE_APPLY); - Matrix_InsertZRotation_f(DEGF_TO_RADF(globalCtx->state.frames * 20.0f), MTXMODE_APPLY); + Matrix_RotateZF(DEGF_TO_RADF(play->state.frames * 20.0f), MTXMODE_APPLY); - gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); if (this->actor.params == DEMO_KANKYO_TYPE_GIANTS) { @@ -676,17 +660,17 @@ void DemoKankyo_DrawMoonAndGiant(Actor* thisx, GlobalContext* globalCtx2) { } } -void DemoKankyo_Draw(Actor* thisx, GlobalContext* globalCtx) { +void DemoKankyo_Draw(Actor* thisx, PlayState* play) { DemoKankyo* this = THIS; switch (this->actor.params) { case DEMO_KANKYO_TYPE_LOSTWOODS: - DemoKakyo_DrawLostWoodsSparkle(&this->actor, globalCtx); + DemoKakyo_DrawLostWoodsSparkle(&this->actor, play); break; case DEMO_KANKYO_TYPE_GIANTS: case DEMO_KANKYO_TYPE_MOON: - DemoKankyo_DrawMoonAndGiant(&this->actor, globalCtx); + DemoKankyo_DrawMoonAndGiant(&this->actor, play); break; } } 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..f6f05d0a6 100644 --- a/src/overlays/actors/ovl_Demo_Kankyo/z_demo_kankyo.h +++ b/src/overlays/actors/ovl_Demo_Kankyo/z_demo_kankyo.h @@ -5,31 +5,31 @@ struct DemoKankyo; -typedef void (*DemoKankyoActionFunc)(struct DemoKankyo*, GlobalContext*); +typedef void (*DemoKankyoActionFunc)(struct DemoKankyo*, PlayState*); typedef struct { - /* 0x000 */ u8 state; - /* 0x004 */ Vec3f posOffset; - /* 0x010 */ Vec3f posOffsetPrev; - /* 0x01C */ Vec3f posBase; - /* 0x028 */ Vec3f speedClock; // cycles in radians - /* 0x034 */ f32 speed; - /* 0x038 */ f32 speedTarget; - /* 0x03C */ u16 alphaClock; - /* 0x03E */ u16 LostWoodsSkyFishSpeedXZClock; - /* 0x040 */ u8 alpha; - /* 0x044 */ f32 scale; // size of the particle - /* 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 + /* 0x00 */ u8 state; + /* 0x04 */ Vec3f posOffset; + /* 0x10 */ Vec3f posOffsetPrev; + /* 0x1C */ Vec3f posBase; + /* 0x28 */ Vec3f speedClock; // cycles in radians + /* 0x34 */ f32 speed; + /* 0x38 */ f32 speedTarget; + /* 0x3C */ u16 alphaClock; + /* 0x3E */ u16 LostWoodsSkyFishSpeedXZClock; + /* 0x40 */ u8 alpha; + /* 0x44 */ f32 scale; // size of the effect + /* 0x48 */ u16 LostWoodsSkyFishSpeedXZ; // the x-z speed (angular velocity) the lost woods skyfish oscillates around player. pos or neg 200-400 + /* 0x4A */ u16 LostWoodsSkyFishPosOffsetMax; // The x-z range the lost woods skyfish oscillates around player. random value between 15-65 + /* 0x4C */ f32 LostWoodsSkyFishSpeedY; // the y speed (angular velocity) the lost woods skyfish oscillates around player. + /* 0x50 */ u16 pad50; // unused, always assigned to 0, nothing else in this actor uses it +} DemoKankyoEffect; // size = 0x54 -#define DEMOKANKYO_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 9ed7a0c27..c051ccf49 100644 --- a/src/overlays/actors/ovl_Demo_Moonend/z_demo_moonend.c +++ b/src/overlays/actors/ovl_Demo_Moonend/z_demo_moonend.c @@ -10,10 +10,10 @@ #define THIS ((DemoMoonend*)thisx) -void DemoMoonend_Init(Actor* thisx, GlobalContext* globalCtx); -void DemoMoonend_Destroy(Actor* thisx, GlobalContext* globalCtx); -void DemoMoonend_Update(Actor* thisx, GlobalContext* globalCtx); -void DemoMoonend_Draw(Actor* thisx, GlobalContext* globalCtx); +void DemoMoonend_Init(Actor* thisx, PlayState* play); +void DemoMoonend_Destroy(Actor* thisx, PlayState* play); +void DemoMoonend_Update(Actor* thisx, PlayState* play); +void DemoMoonend_Draw(Actor* thisx, PlayState* play); #if 0 const ActorInit Demo_Moonend_InitVars = { diff --git a/src/overlays/actors/ovl_Demo_Moonend/z_demo_moonend.h b/src/overlays/actors/ovl_Demo_Moonend/z_demo_moonend.h index 463e86743..212e93d84 100644 --- a/src/overlays/actors/ovl_Demo_Moonend/z_demo_moonend.h +++ b/src/overlays/actors/ovl_Demo_Moonend/z_demo_moonend.h @@ -5,12 +5,12 @@ struct DemoMoonend; -typedef void (*DemoMoonendActionFunc)(struct DemoMoonend*, GlobalContext*); +typedef void (*DemoMoonendActionFunc)(struct DemoMoonend*, PlayState*); typedef struct DemoMoonend { - /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x19C]; - /* 0x02E0 */ DemoMoonendActionFunc actionFunc; + /* 0x000 */ Actor actor; + /* 0x144 */ char unk_144[0x19C]; + /* 0x2E0 */ DemoMoonendActionFunc actionFunc; } DemoMoonend; // size = 0x2E4 extern const ActorInit Demo_Moonend_InitVars; diff --git a/src/overlays/actors/ovl_Demo_Shd/z_demo_shd.c b/src/overlays/actors/ovl_Demo_Shd/z_demo_shd.c index faedc1b74..0078f8959 100644 --- a/src/overlays/actors/ovl_Demo_Shd/z_demo_shd.c +++ b/src/overlays/actors/ovl_Demo_Shd/z_demo_shd.c @@ -10,10 +10,10 @@ #define THIS ((DemoShd*)thisx) -void DemoShd_Init(Actor* thisx, GlobalContext* globalCtx); -void DemoShd_Destroy(Actor* thisx, GlobalContext* globalCtx); -void DemoShd_Update(Actor* thisx, GlobalContext* globalCtx); -void DemoShd_Draw(Actor* thisx, GlobalContext* globalCtx); +void DemoShd_Init(Actor* thisx, PlayState* play); +void DemoShd_Destroy(Actor* thisx, PlayState* play); +void DemoShd_Update(Actor* thisx, PlayState* play); +void DemoShd_Draw(Actor* thisx, PlayState* play); const ActorInit Demo_Shd_InitVars = { ACTOR_DEMO_SHD, @@ -27,11 +27,11 @@ const ActorInit Demo_Shd_InitVars = { (ActorFunc)DemoShd_Draw, }; -void DemoShd_Init(Actor* thisx, GlobalContext* globalCtx) { +void DemoShd_Init(Actor* thisx, PlayState* play) { } -void DemoShd_Destroy(Actor* thisx, GlobalContext* globalCtx) { +void DemoShd_Destroy(Actor* thisx, PlayState* play) { } -void DemoShd_Update(Actor* thisx, GlobalContext* globalCtx) { +void DemoShd_Update(Actor* thisx, PlayState* play) { } -void DemoShd_Draw(Actor* thisx, GlobalContext* globalCtx) { +void DemoShd_Draw(Actor* thisx, PlayState* play) { } 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 aa25fddfd..b3a79895e 100644 --- a/src/overlays/actors/ovl_Demo_Syoten/z_demo_syoten.c +++ b/src/overlays/actors/ovl_Demo_Syoten/z_demo_syoten.c @@ -11,19 +11,19 @@ #define THIS ((DemoSyoten*)thisx) -void DemoSyoten_Init(Actor* thisx, GlobalContext* globalCtx); -void DemoSyoten_Destroy(Actor* thisx, GlobalContext* globalCtx); -void DemoSyoten_Update(Actor* thisx, GlobalContext* globalCtx); -void DemoSyoten_Draw(Actor* thisx, GlobalContext* globalCtx); +void DemoSyoten_Init(Actor* thisx, PlayState* play); +void DemoSyoten_Destroy(Actor* thisx, PlayState* play); +void DemoSyoten_Update(Actor* thisx, PlayState* play); +void DemoSyoten_Draw(Actor* thisx, PlayState* play); -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); +void func_80C16A64(DemoSyoten* this, PlayState* play); +void func_80C16A74(DemoSyoten* this, PlayState* play); +void func_80C16BD4(DemoSyoten* this, PlayState* play); +void func_80C16DD4(DemoSyoten* this, PlayState* play); +void func_80C16EAC(DemoSyoten* this, PlayState* play); +void func_80C17008(DemoSyoten* this, PlayState* play); +void func_80C173B4(Actor* thisx, PlayState* play); +void func_80C17690(Actor* thisx, PlayState* play); const ActorInit Demo_Syoten_InitVars = { ACTOR_DEMO_SYOTEN, @@ -57,7 +57,7 @@ Color_RGBA8 D_80C17834[] = { { 60, 50, 100, 255 }, }; -void DemoSyoten_Init(Actor* thisx, GlobalContext* globalCtx) { +void DemoSyoten_Init(Actor* thisx, PlayState* play) { s32 pad; DemoSyoten* this = THIS; @@ -74,13 +74,13 @@ void DemoSyoten_Init(Actor* thisx, GlobalContext* globalCtx) { 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); + this->unk_2A6, NULL); 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->actor.child = + Actor_SpawnAsChild(&play->actorCtx, &this->actor, play, ACTOR_EFF_DUST, this->actor.world.pos.x, + this->actor.world.pos.y, this->actor.world.pos.z, 0, this->actor.shape.rot.y, 0, 0); this->unk_3F0 = 0x215; Actor_SetScale(&this->actor, 0.05f); break; @@ -127,7 +127,7 @@ void DemoSyoten_Init(Actor* thisx, GlobalContext* globalCtx) { } } -void DemoSyoten_Destroy(Actor* thisx, GlobalContext* globalCtx) { +void DemoSyoten_Destroy(Actor* thisx, PlayState* play) { DemoSyoten* this = THIS; if (DEMOSYOTEN_GET_F(&this->actor) == DEMOSYOTEN_F_0) { @@ -135,14 +135,14 @@ void DemoSyoten_Destroy(Actor* thisx, GlobalContext* globalCtx) { } } -void func_80C16760(DemoSyoten* this, GlobalContext* globalCtx) { +void func_80C16760(DemoSyoten* this, PlayState* play) { s32 pad; Vec3s* points; Vec3f sp2C; this->unk_3EC = 0; if (DEMOSYOTEN_GET_7E00(&this->actor) != DEMOSYOTEN_7E00_3F) { - this->unk_3E8 = &globalCtx->setupPathList[DEMOSYOTEN_GET_7E00(&this->actor)]; + this->unk_3E8 = &play->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]); @@ -179,23 +179,23 @@ s32 func_80C16818(DemoSyoten* this) { return false; } -void func_80C168D0(DemoSyoten* this, GlobalContext* globalCtx) { +void func_80C168D0(DemoSyoten* this, PlayState* play) { s32 pad; Path* path = this->unk_3E8; Vec3s* points; - Vec3f sp30; - Vec3f sp24; - f32 sp20; + Vec3f worldPos; + Vec3f projectedPos; + f32 invW; 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); + Math_Vec3s_ToVec3f(&worldPos, points); + Actor_GetProjectedPos(play, &worldPos, &projectedPos, &invW); + Math_Vec3f_Copy(&worldPos, &this->actor.projectedPos); + worldPos.z = worldPos.y; + projectedPos.z = projectedPos.y; + this->actor.shape.rot.z = -Math_Vec3f_Yaw(&projectedPos, &worldPos); } } @@ -215,21 +215,21 @@ void func_80C16974(f32 arg0) { } } -void func_80C16A64(DemoSyoten* this, GlobalContext* globalCtx) { +void func_80C16A64(DemoSyoten* this, PlayState* play) { } -void func_80C16A74(DemoSyoten* this, GlobalContext* globalCtx) { +void func_80C16A74(DemoSyoten* this, PlayState* play) { u16 temp_a0; func_80183DE0(&this->unk_144); - if (Cutscene_CheckActorAction(globalCtx, this->unk_3F0)) { - if ((globalCtx->csCtx.frames >= 160) && (globalCtx->csCtx.frames < 322)) { + if (Cutscene_CheckActorAction(play, this->unk_3F0)) { + if ((play->csCtx.frames >= 160) && (play->csCtx.frames < 322)) { func_800B9010(&this->actor, NA_SE_EV_IKANA_SOUL_LV - SFX_FLAG); - } else if (globalCtx->csCtx.frames == 322) { + } else if (play->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; + temp_a0 = play->csCtx.actorActions[Cutscene_GetActorActionIndex(play, this->unk_3F0)]->action; if (this->unk_3F2 != temp_a0) { this->unk_3F2 = temp_a0; switch (temp_a0) { @@ -269,12 +269,12 @@ void func_80C16A74(DemoSyoten* this, GlobalContext* globalCtx) { } } -void func_80C16BD4(DemoSyoten* this, GlobalContext* globalCtx) { +void func_80C16BD4(DemoSyoten* this, PlayState* play) { 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 (Cutscene_CheckActorAction(play, this->unk_3F0)) { + temp_a0 = play->csCtx.actorActions[Cutscene_GetActorActionIndex(play, this->unk_3F0)]->action; if (this->unk_3F2 != temp_a0) { this->unk_3F2 = temp_a0; switch (temp_a0) { @@ -297,7 +297,7 @@ void func_80C16BD4(DemoSyoten* this, GlobalContext* globalCtx) { case 4: this->actor.draw = DemoSyoten_Draw; - func_80C16760(this, globalCtx); + func_80C16760(this, play); this->unk_3E4 |= 4; this->unk_3E4 &= ~1; break; @@ -314,13 +314,12 @@ void func_80C16BD4(DemoSyoten* this, GlobalContext* globalCtx) { case 4: this->actor.speedXZ = - globalCtx->csCtx.actorActions[Cutscene_GetActorActionIndex(globalCtx, this->unk_3F0)]->urot.z * - 0.005493164f; + play->csCtx.actorActions[Cutscene_GetActorActionIndex(play, 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); + func_80C168D0(this, play); } break; } @@ -329,12 +328,12 @@ void func_80C16BD4(DemoSyoten* this, GlobalContext* globalCtx) { } } -void func_80C16DD4(DemoSyoten* this, GlobalContext* globalCtx) { +void func_80C16DD4(DemoSyoten* this, PlayState* play) { 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 (Cutscene_CheckActorAction(play, this->unk_3F0)) { + temp_a0 = play->csCtx.actorActions[Cutscene_GetActorActionIndex(play, this->unk_3F0)]->action; if (this->unk_3F2 != temp_a0) { this->unk_3F2 = temp_a0; switch (temp_a0) { @@ -358,12 +357,12 @@ void func_80C16DD4(DemoSyoten* this, GlobalContext* globalCtx) { } } -void func_80C16EAC(DemoSyoten* this, GlobalContext* globalCtx) { +void func_80C16EAC(DemoSyoten* this, PlayState* play) { 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 (Cutscene_CheckActorAction(play, this->unk_3F0)) { + temp_a0 = play->csCtx.actorActions[Cutscene_GetActorActionIndex(play, this->unk_3F0)]->action; if (this->unk_3F2 != temp_a0) { this->unk_3F2 = temp_a0; switch (temp_a0) { @@ -401,11 +400,11 @@ void func_80C16EAC(DemoSyoten* this, GlobalContext* globalCtx) { func_80C16974(this->unk_3D8); } -void func_80C17008(DemoSyoten* this, GlobalContext* globalCtx) { +void func_80C17008(DemoSyoten* this, PlayState* play) { u16 temp_a0; - if (Cutscene_CheckActorAction(globalCtx, this->unk_3F0)) { - temp_a0 = globalCtx->csCtx.actorActions[Cutscene_GetActorActionIndex(globalCtx, this->unk_3F0)]->action; + if (Cutscene_CheckActorAction(play, this->unk_3F0)) { + temp_a0 = play->csCtx.actorActions[Cutscene_GetActorActionIndex(play, this->unk_3F0)]->action; if (this->unk_3F2 != temp_a0) { this->unk_3F2 = temp_a0; switch (temp_a0) { @@ -428,14 +427,14 @@ void func_80C17008(DemoSyoten* this, GlobalContext* globalCtx) { } } -void DemoSyoten_Update(Actor* thisx, GlobalContext* globalCtx) { +void DemoSyoten_Update(Actor* thisx, PlayState* play) { DemoSyoten* this = THIS; - this->actionFunc(this, globalCtx); + this->actionFunc(this, play); } -s32 func_80C170F8(GlobalContext* globalCtx, UNK_TYPE arg1, s32 arg2, UNK_TYPE arg3, UNK_TYPE arg4, Actor* thisx) { - GraphicsContext* gfxCtx = globalCtx->state.gfxCtx; +s32 func_80C170F8(PlayState* play, UNK_TYPE arg1, s32 arg2, UNK_TYPE arg3, UNK_TYPE arg4, Actor* thisx) { + GraphicsContext* gfxCtx = play->state.gfxCtx; DemoSyoten* this = THIS; OPEN_DISPS(gfxCtx); @@ -478,27 +477,27 @@ s32 func_80C170F8(GlobalContext* globalCtx, UNK_TYPE arg1, s32 arg2, UNK_TYPE ar return true; } -void func_80C173B4(Actor* thisx, GlobalContext* globalCtx) { +void func_80C173B4(Actor* thisx, PlayState* play) { s32 pad; DemoSyoten* this = THIS; Mtx* matrix; - AnimatedMat_DrawXlu(globalCtx, Lib_SegmentedToVirtual(&object_syoten_Matanimheader_001298)); + AnimatedMat_DrawXlu(play, Lib_SegmentedToVirtual(&object_syoten_Matanimheader_001298)); - matrix = GRAPH_ALLOC(globalCtx->state.gfxCtx, ALIGN16(sizeof(Mtx) * this->unk_144.unk_18->unk_1)); + matrix = GRAPH_ALLOC(play->state.gfxCtx, ALIGN16(sizeof(Mtx) * this->unk_144.unk_18->unk_1)); if (matrix != NULL) { - func_8012C2DC(globalCtx->state.gfxCtx); - Matrix_InsertMatrix(&globalCtx->billboardMtxF, MTXMODE_APPLY); - func_8018450C(globalCtx, &this->unk_144, matrix, (void*)func_80C170F8, 0, &this->actor); + func_8012C2DC(play->state.gfxCtx); + Matrix_Mult(&play->billboardMtxF, MTXMODE_APPLY); + func_8018450C(play, &this->unk_144, matrix, (void*)func_80C170F8, 0, &this->actor); } } -void func_80C17468(GlobalContext* globalCtx) { +void func_80C17468(PlayState* play) { Color_RGBA8 sp2C; Color_RGBA8 sp28; - OPEN_DISPS(globalCtx->state.gfxCtx); + OPEN_DISPS(play->state.gfxCtx); func_800FE7A8(D_80C17824, &sp2C); func_800FE7A8(D_80C17834, &sp28); @@ -506,70 +505,70 @@ void func_80C17468(GlobalContext* globalCtx) { 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); + CLOSE_DISPS(play->state.gfxCtx); } -void DemoSyoten_Draw(Actor* thisx, GlobalContext* globalCtx) { +void DemoSyoten_Draw(Actor* thisx, PlayState* play) { s32 pad; DemoSyoten* this = THIS; - OPEN_DISPS(globalCtx->state.gfxCtx); + OPEN_DISPS(play->state.gfxCtx); - func_8012C2DC(globalCtx->state.gfxCtx); + func_8012C2DC(play->state.gfxCtx); if (this->unk_3E4 & 4) { - Matrix_InsertZRotation_s(-this->actor.shape.rot.z, MTXMODE_APPLY); - Matrix_InsertMatrix(&globalCtx->billboardMtxF, MTXMODE_APPLY); - Matrix_InsertZRotation_s(this->actor.shape.rot.z, MTXMODE_APPLY); + Matrix_RotateZS(-this->actor.shape.rot.z, MTXMODE_APPLY); + Matrix_Mult(&play->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_InsertMatrix(&globalCtx->billboardMtxF, MTXMODE_APPLY); + Matrix_Mult(&play->billboardMtxF, MTXMODE_APPLY); } if (this->unk_3E4 & 8) { - func_80C17468(globalCtx); + func_80C17468(play); } if (this->unk_3E0 != NULL) { if (this->unk_3E4 & 2) { - AnimatedMat_DrawStepXlu(globalCtx, this->unk_3E0, this->unk_3E6); + AnimatedMat_DrawStepXlu(play, this->unk_3E0, this->unk_3E6); } else { - AnimatedMat_DrawXlu(globalCtx, this->unk_3E0); + AnimatedMat_DrawXlu(play, 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); + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_XLU_DISP++, this->unk_3DC); } - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->state.gfxCtx); } -void func_80C17690(Actor* thisx, GlobalContext* globalCtx) { +void func_80C17690(Actor* thisx, PlayState* play) { s32 pad; DemoSyoten* this = THIS; - OPEN_DISPS(globalCtx->state.gfxCtx); + OPEN_DISPS(play->state.gfxCtx); - func_8012C2DC(globalCtx->state.gfxCtx); - Matrix_RotateY(BINANG_ROT180(Camera_GetCamDirYaw(GET_ACTIVE_CAM(globalCtx))), MTXMODE_APPLY); + func_8012C2DC(play->state.gfxCtx); + Matrix_RotateYS(BINANG_ROT180(Camera_GetCamDirYaw(GET_ACTIVE_CAM(play))), MTXMODE_APPLY); if (this->unk_3E4 & 8) { - func_80C17468(globalCtx); + func_80C17468(play); } - gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - AnimatedMat_DrawStepXlu(globalCtx, this->unk_3E0, this->unk_3E6); + AnimatedMat_DrawStepXlu(play, this->unk_3E0, this->unk_3E6); gSPDisplayList(POLY_XLU_DISP++, object_syoten_DL_002880); - AnimatedMat_DrawStepXlu(globalCtx, this->unk_3E0, this->unk_3E6 + 5); + AnimatedMat_DrawStepXlu(play, this->unk_3E0, this->unk_3E6 + 5); gSPDisplayList(POLY_XLU_DISP++, object_syoten_DL_002A20); - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->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 204243f47..b0a00f2a6 100644 --- a/src/overlays/actors/ovl_Demo_Syoten/z_demo_syoten.h +++ b/src/overlays/actors/ovl_Demo_Syoten/z_demo_syoten.h @@ -5,7 +5,7 @@ struct DemoSyoten; -typedef void (*DemoSyotenActionFunc)(struct DemoSyoten*, GlobalContext*); +typedef void (*DemoSyotenActionFunc)(struct DemoSyoten*, PlayState*); #define DEMOSYOTEN_GET_F(thisx) ((thisx)->params & 0xF) #define DEMOSYOTEN_GET_7E00(thisx) (((thisx)->params & 0x7E00) >> 9) @@ -21,20 +21,20 @@ enum { }; typedef struct DemoSyoten { - /* 0x0000 */ Actor actor; - /* 0x0144 */ SkeletonInfo unk_144; - /* 0x0174 */ Vec3s unk_174[51]; - /* 0x02A6 */ s16 unk_2A6[153]; - /* 0x03D8 */ f32 unk_3D8; - /* 0x03DC */ Gfx* unk_3DC; - /* 0x03E0 */ AnimatedMaterial* unk_3E0; - /* 0x03E4 */ u16 unk_3E4; - /* 0x03E6 */ s16 unk_3E6; - /* 0x03E8 */ Path* unk_3E8; - /* 0x03EC */ s32 unk_3EC; - /* 0x03F0 */ u16 unk_3F0; - /* 0x03F2 */ u16 unk_3F2; - /* 0x03F4 */ DemoSyotenActionFunc actionFunc; + /* 0x000 */ Actor actor; + /* 0x144 */ SkeletonInfo unk_144; + /* 0x174 */ Vec3s unk_174[51]; + /* 0x2A6 */ Vec3s unk_2A6[51]; + /* 0x3D8 */ f32 unk_3D8; + /* 0x3DC */ Gfx* unk_3DC; + /* 0x3E0 */ AnimatedMaterial* unk_3E0; + /* 0x3E4 */ u16 unk_3E4; + /* 0x3E6 */ s16 unk_3E6; + /* 0x3E8 */ Path* unk_3E8; + /* 0x3EC */ s32 unk_3EC; + /* 0x3F0 */ u16 unk_3F0; + /* 0x3F2 */ u16 unk_3F2; + /* 0x3F4 */ DemoSyotenActionFunc actionFunc; } DemoSyoten; // size = 0x3F8 extern const ActorInit Demo_Syoten_InitVars; diff --git a/src/overlays/actors/ovl_Demo_Tre_Lgt/z_demo_tre_lgt.c b/src/overlays/actors/ovl_Demo_Tre_Lgt/z_demo_tre_lgt.c index 060a201d7..ca833fe0e 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,17 +5,36 @@ */ #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 (ACTOR_FLAG_10) #define THIS ((DemoTreLgt*)thisx) -void DemoTreLgt_Init(Actor* thisx, GlobalContext* globalCtx); -void DemoTreLgt_Destroy(Actor* thisx, GlobalContext* globalCtx); -void DemoTreLgt_Update(Actor* thisx, GlobalContext* globalCtx); -void DemoTreLgt_Draw(Actor* thisx, GlobalContext* globalCtx); +void DemoTreLgt_Init(Actor* thisx, PlayState* play); +void DemoTreLgt_Destroy(Actor* thisx, PlayState* play); +void DemoTreLgt_Update(Actor* thisx, PlayState* play); +void DemoTreLgt_Draw(Actor* thisx, PlayState* play); + +void DemoTreLgt_SetupWait(DemoTreLgt* this); + +void DemoTreLgt_Wait(DemoTreLgt* this, PlayState* play); +void DemoTreLgt_SetupAnimate(DemoTreLgt* this, PlayState* play, f32 frame); +void DemoTreLgt_Animate(DemoTreLgt* this, PlayState* play); + +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 }, +}; -#if 0 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, PlayState* play) { + DemoTreLgt* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Demo_Tre_Lgt/func_808E0EE8.s") + SkelCurve_Init(play, &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, PlayState* play) { + DemoTreLgt* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Demo_Tre_Lgt/func_808E0F4C.s") + SkelCurve_Destroy(play, &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, PlayState* play) { + 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, play, chest->skelAnime.curFrame); + } + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Demo_Tre_Lgt/DemoTreLgt_Draw.s") +void DemoTreLgt_SetupAnimate(DemoTreLgt* this, PlayState* play, 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(play, &this->skelCurve); +} + +void DemoTreLgt_Animate(DemoTreLgt* this, PlayState* play) { + 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(play, &this->skelCurve)) { + Actor_MarkForDeath(&this->actor); + } +} + +void DemoTreLgt_Update(Actor* thisx, PlayState* play) { + DemoTreLgt* this = THIS; + + sActionFuncs[this->action](this, play); +} + +s32 DemoTreLgt_OverrideLimbDraw(PlayState* play, SkelCurve* skelCuve, s32 limbIndex, Actor* thisx) { + s32 pad; + DemoTreLgt* this = THIS; + + OPEN_DISPS(play->state.gfxCtx); + + gSPSegment(POLY_XLU_DISP++, 0x08, + Gfx_TwoTexScroll(play->state.gfxCtx, 0, (play->state.frames * 2) % 256, 0, 64, 32, 1, + (play->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(play->state.gfxCtx); + + return true; +} + +void DemoTreLgt_Draw(Actor* thisx, PlayState* play) { + GraphicsContext* gfxCtx = play->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, play, &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..83a210b8c 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, PlayState* play); + 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 ede7baa1d..541a4d93d 100644 --- a/src/overlays/actors/ovl_Dm_Ah/z_dm_ah.c +++ b/src/overlays/actors/ovl_Dm_Ah/z_dm_ah.c @@ -10,15 +10,11 @@ #define THIS ((DmAh*)thisx) -void DmAh_Init(Actor* thisx, GlobalContext* globalCtx); -void DmAh_Destroy(Actor* thisx, GlobalContext* globalCtx); -void DmAh_Update(Actor* thisx, GlobalContext* globalCtx); -void DmAh_Draw(Actor* thisx, GlobalContext* globalCtx); +void DmAh_Init(Actor* thisx, PlayState* play); +void DmAh_Destroy(Actor* thisx, PlayState* play); +void DmAh_Update(Actor* thisx, PlayState* play); +void DmAh_Draw(Actor* thisx, PlayState* play); -void func_80C1D7FC(DmAh* this, GlobalContext* globalCtx); -void func_80C1D92C(DmAh* this, GlobalContext* globalCtx); - -#if 0 const ActorInit Dm_Ah_InitVars = { ACTOR_DM_AH, ACTORCAT_NPC, @@ -31,32 +27,232 @@ const ActorInit Dm_Ah_InitVars = { (ActorFunc)DmAh_Draw, }; -#endif +static AnimationInfoS sAnimations[] = { + { &object_ah_Anim_001860, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, + { &object_ah_Anim_000DDC, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, +}; -extern UNK_TYPE D_06009E70; +s32 func_80C1D410(DmAh* this, s32 animationIndex) { + s32 ret = false; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Ah/func_80C1D410.s") + if (animationIndex != this->animationIndex) { + this->animationIndex = animationIndex; + ret = SubS_ChangeAnimationByInfoS(&this->skelAnime, sAnimations, animationIndex); + } + return ret; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Ah/func_80C1D458.s") +void func_80C1D458(DmAh* this) { + if (DECR(this->unk_286) == 0) { + this->unk_284++; + if (this->unk_284 >= 4) { + this->unk_286 = Rand_S16Offset(30, 30); + this->unk_284 = 0; + } + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Ah/func_80C1D4D0.s") +s32 func_80C1D4D0(DmAh* this, s32 arg1) { + s32 pad; + Vec3f sp40; + Vec3f sp34; + s16 temp_v0; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Ah/func_80C1D6E0.s") + Math_Vec3f_Copy(&sp40, &this->unk_280->world.pos); + Math_Vec3f_Copy(&sp34, &this->actor.world.pos); + temp_v0 = Math_Vec3f_Yaw(&sp34, &sp40); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Ah/func_80C1D78C.s") + Math_ApproachS(&this->unk_28C, (temp_v0 - this->unk_290) - this->actor.shape.rot.y, 4, 0x2AA8); + this->unk_28C = CLAMP(this->unk_28C, -0x1FFE, 0x1FFE); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Ah/func_80C1D7FC.s") + Math_ApproachS(&this->unk_290, (temp_v0 - this->unk_28C) - this->actor.shape.rot.y, 4, 0x2AA8); + this->unk_290 = CLAMP(this->unk_290, -0x1C70, 0x1C70); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Ah/func_80C1D92C.s") + if (this->unk_280->id == ACTOR_PLAYER) { + sp40.y = ((Player*)this->unk_280)->bodyPartsPos[7].y + 3.0f; + } else { + Math_Vec3f_Copy(&sp40, &this->unk_280->focus.pos); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Ah/DmAh_Init.s") + Math_Vec3f_Copy(&sp34, &this->actor.focus.pos); + Math_ApproachS(&this->unk_28A, Math_Vec3f_Pitch(&sp34, &sp40) - this->unk_28E, 4, 0x2AA8); + this->unk_28A = CLAMP(this->unk_28A, -0x1C70, 0x1C70); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Ah/DmAh_Destroy.s") + Math_ApproachS(&this->unk_28E, Math_Vec3f_Pitch(&sp34, &sp40) - this->unk_28A, 4, 0x2AA8); + this->unk_28E = CLAMP(this->unk_28E, -0x1C70, 0x1C70); + return true; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Ah/DmAh_Update.s") +s32 func_80C1D6E0(DmAh* this, PlayState* play) { + if (this->unk_280 != NULL) { + func_80C1D4D0(this, play); + this->unk_27C &= ~1; + this->unk_27C |= 2; + } else if (this->unk_27C & 2) { + this->unk_27C &= ~2; + this->unk_28A = 0; + this->unk_28C = 0; + this->unk_28E = 0; + this->unk_290 = 0; + this->unk_288 = 20; + } else if (DECR(this->unk_288) == 0) { + this->unk_27C |= 1; + } + return true; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Ah/func_80C1DAD4.s") +Actor* func_80C1D78C(PlayState* play) { + Actor* tempActor; + Actor* foundActor = NULL; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Ah/func_80C1DB24.s") + while (true) { + foundActor = SubS_FindActor(play, foundActor, ACTORCAT_NPC, ACTOR_DM_AN); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Ah/DmAh_Draw.s") + if ((foundActor == NULL) || (foundActor->update != NULL)) { + break; + } + + tempActor = foundActor->next; + if (tempActor == NULL || false) { + foundActor = NULL; + break; + } + foundActor = tempActor; + } + return foundActor; +} + +void func_80C1D7FC(DmAh* this, PlayState* play) { + s32 D_80C1DE00[] = { 0, 0, 0, 0, 0 }; + u16 csAction; + s32 actionIndex; + + if (play->csCtx.state != 0) { + if (!this->unk_29C) { + this->action = 0xFF; + this->unk_29C = true; + this->animationIndex2 = this->animationIndex; + } + if (Cutscene_CheckActorAction(play, 0x232)) { + actionIndex = Cutscene_GetActorActionIndex(play, 0x232); + csAction = play->csCtx.actorActions[actionIndex]->action; + if (this->action != (u8)csAction) { + this->action = csAction; + func_80C1D410(this, D_80C1DE00[csAction]); + } + Cutscene_ActorTranslateAndYaw(&this->actor, play, actionIndex); + } + } else if (this->unk_29C) { + this->unk_29C = false; + func_80C1D410(this, this->animationIndex2); + } +} + +void func_80C1D92C(DmAh* this, PlayState* play) { +} + +void DmAh_Init(Actor* thisx, PlayState* play) { + DmAh* this = THIS; + + ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 20.0f); + SkelAnime_InitFlex(play, &this->skelAnime, &object_ah_Skel_009E70, NULL, this->morphTable, this->jointTable, + OBJECT_AH_LIMB_MAX); + this->animationIndex = -1; + func_80C1D410(this, 0); + this->actor.flags &= ~ACTOR_FLAG_1; + Actor_SetScale(&this->actor, 0.01f); + this->unk_27C |= 1; + if ((play->sceneNum == SCENE_YADOYA) && (play->curSpawn == 4)) { + this->unk_280 = func_80C1D78C(play); + func_80C1D410(this, 1); + this->actionFunc = func_80C1D92C; + } else { + this->actionFunc = func_80C1D7FC; + } +} + +void DmAh_Destroy(Actor* thisx, PlayState* play) { +} + +void DmAh_Update(Actor* thisx, PlayState* play) { + DmAh* this = THIS; + + this->actionFunc(this, play); + func_80C1D6E0(this, play); + SkelAnime_Update(&this->skelAnime); + func_80C1D458(this); + Actor_UpdateBgCheckInfo(play, &this->actor, 30.0f, 12.0f, 0.0f, 4); +} + +static Vec3f D_80C1DE14 = { 1000.0f, 0.0f, 0.0f }; + +void DmAh_PostLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx) { + if (limbIndex == OBJECT_AH_LIMB_07) { + Matrix_MultVec3f(&D_80C1DE14, &thisx->focus.pos); + Math_Vec3s_Copy(&thisx->focus.rot, &thisx->world.rot); + } +} + +void DmAh_TransformLimbDraw(PlayState* play, s32 limbIndex, Actor* thisx) { + DmAh* this = THIS; + s32 stepRot; + s32 overrideRot; + + if (!(this->unk_27C & 1)) { + if (this->unk_27C & 2) { + overrideRot = true; + } else { + overrideRot = false; + } + stepRot = true; + } else { + stepRot = false; + overrideRot = false; + } + + if (limbIndex == OBJECT_AH_LIMB_07) { + SubS_UpdateLimb(BINANG_ADD(this->unk_28A + this->unk_28E, 0x4000), + BINANG_ADD(this->unk_28C + this->unk_290 + 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(thisx->scale.x, thisx->scale.y, thisx->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_AH_LIMB_02) { + SubS_UpdateLimb(BINANG_ADD(this->unk_28E, 0x4000), BINANG_ADD(this->unk_290 + this->actor.shape.rot.y, 0x4000), + &this->unk_198, &this->unk_1AA, stepRot, overrideRot); + Matrix_Pop(); + Matrix_Translate(this->unk_198.x, this->unk_198.y, this->unk_198.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(); + } +} + +static TexturePtr D_80C1DE20[] = { object_ah_Tex_008D70, object_ah_Tex_009570 }; + +static TexturePtr D_80C1DE28[] = { + object_ah_Tex_006D70, object_ah_Tex_007570, object_ah_Tex_007D70, object_ah_Tex_007570, object_ah_Tex_008570, +}; + +void DmAh_Draw(Actor* thisx, PlayState* play) { + DmAh* this = THIS; + + OPEN_DISPS(play->state.gfxCtx); + + func_8012C28C(play->state.gfxCtx); + + gSPSegment(POLY_OPA_DISP++, 0x08, Lib_SegmentedToVirtual(D_80C1DE28[this->unk_284])); + gSPSegment(POLY_OPA_DISP++, 0x09, Lib_SegmentedToVirtual(D_80C1DE20[0])); + + SkelAnime_DrawTransformFlexOpa(play, this->skelAnime.skeleton, this->skelAnime.jointTable, + this->skelAnime.dListCount, NULL, DmAh_PostLimbDraw, DmAh_TransformLimbDraw, + &this->actor); + + CLOSE_DISPS(play->state.gfxCtx); +} diff --git a/src/overlays/actors/ovl_Dm_Ah/z_dm_ah.h b/src/overlays/actors/ovl_Dm_Ah/z_dm_ah.h index 20ca6c497..dc9a437ed 100644 --- a/src/overlays/actors/ovl_Dm_Ah/z_dm_ah.h +++ b/src/overlays/actors/ovl_Dm_Ah/z_dm_ah.h @@ -2,16 +2,35 @@ #define Z_DM_AH_H #include "global.h" +#include "objects/object_ah/object_ah.h" struct DmAh; -typedef void (*DmAhActionFunc)(struct DmAh*, GlobalContext*); +typedef void (*DmAhActionFunc)(struct DmAh*, PlayState*); typedef struct DmAh { - /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x44]; - /* 0x0188 */ DmAhActionFunc actionFunc; - /* 0x018C */ char unk_18C[0x114]; + /* 0x000 */ Actor actor; + /* 0x144 */ SkelAnime skelAnime; + /* 0x188 */ DmAhActionFunc actionFunc; + /* 0x18C */ Vec3f unk_18C; + /* 0x198 */ Vec3f unk_198; + /* 0x1A4 */ Vec3s unk_1A4; + /* 0x1AA */ Vec3s unk_1AA; + /* 0x1B0 */ Vec3s morphTable[OBJECT_AH_LIMB_MAX]; + /* 0x216 */ Vec3s jointTable[OBJECT_AH_LIMB_MAX]; + /* 0x27C */ u16 unk_27C; + /* 0x27E */ u8 action; + /* 0x280 */ Actor* unk_280; + /* 0x284 */ s16 unk_284; + /* 0x286 */ s16 unk_286; + /* 0x288 */ s16 unk_288; + /* 0x28A */ s16 unk_28A; + /* 0x28C */ s16 unk_28C; + /* 0x28E */ s16 unk_28E; + /* 0x290 */ s16 unk_290; + /* 0x294 */ s32 animationIndex; + /* 0x298 */ s32 animationIndex2; + /* 0x29C */ s32 unk_29C; } DmAh; // size = 0x2A0 extern const ActorInit Dm_Ah_InitVars; diff --git a/src/overlays/actors/ovl_Dm_Al/z_dm_al.c b/src/overlays/actors/ovl_Dm_Al/z_dm_al.c index d289b99ec..6c7a1be69 100644 --- a/src/overlays/actors/ovl_Dm_Al/z_dm_al.c +++ b/src/overlays/actors/ovl_Dm_Al/z_dm_al.c @@ -10,14 +10,11 @@ #define THIS ((DmAl*)thisx) -void DmAl_Init(Actor* thisx, GlobalContext* globalCtx); -void DmAl_Destroy(Actor* thisx, GlobalContext* globalCtx); -void DmAl_Update(Actor* thisx, GlobalContext* globalCtx); -void DmAl_Draw(Actor* thisx, GlobalContext* globalCtx); +void DmAl_Init(Actor* thisx, PlayState* play); +void DmAl_Destroy(Actor* thisx, PlayState* play); +void DmAl_Update(Actor* thisx, PlayState* play); +void DmAl_Draw(Actor* thisx, PlayState* play); -void func_80C1BDD8(DmAl* this, GlobalContext* globalCtx); - -#if 0 const ActorInit Dm_Al_InitVars = { ACTOR_EN_AL, ACTORCAT_NPC, @@ -30,24 +27,140 @@ const ActorInit Dm_Al_InitVars = { (ActorFunc)DmAl_Draw, }; -#endif +typedef enum { + /* 0 */ MADAME_AROMA_ANIM_0, + /* 1 */ MADAME_AROMA_ANIM_1 +} DmAlAnimation; -extern UNK_TYPE D_0600A0D8; +static AnimationInfoS sAnimationInfo[] = { + { &object_al_Anim_00DBE0, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, +}; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Al/func_80C1BD90.s") +s32 DmAl_ChangeAnim(DmAl* this, s32 animIndex) { + s32 didAnimationChange = false; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Al/func_80C1BDD8.s") + if (animIndex != this->animIndex) { + this->animIndex = animIndex; + didAnimationChange = SubS_ChangeAnimationByInfoS(&this->skelAnime, sAnimationInfo, animIndex); + } + return didAnimationChange; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Al/DmAl_Init.s") +void func_80C1BDD8(DmAl* this, PlayState* play) { + s32 D_80C1C280[] = { 0, 0, 0, 0, 0 }; + u16 csAction; + s32 actionIndex; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Al/DmAl_Destroy.s") + if (play->csCtx.state != 0) { + if (!this->unk_45C) { + this->action = 0xFF; + this->unk_45C = true; + this->animIndex2 = this->animIndex; + } + if (Cutscene_CheckActorAction(play, 0x232)) { + actionIndex = Cutscene_GetActorActionIndex(play, 0x232); + csAction = play->csCtx.actorActions[actionIndex]->action; + if (this->action != (u8)csAction) { + this->action = csAction; + DmAl_ChangeAnim(this, D_80C1C280[csAction]); + } + Cutscene_ActorTranslateAndYaw(&this->actor, play, actionIndex); + } + } else if (this->unk_45C) { + this->unk_45C = false; + DmAl_ChangeAnim(this, this->animIndex2); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Al/DmAl_Update.s") +void DmAl_Init(Actor* thisx, PlayState* play) { + DmAl* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Al/func_80C1C028.s") + ActorShape_Init(&this->actor.shape, 0.0f, NULL, 0.0f); + SkelAnime_InitFlex(play, &this->skelAnime, &gMadameAromaSkel, NULL, this->jointTable, this->morphTable, + MADAME_AROMA_LIMB_MAX); + this->animIndex = -1; + DmAl_ChangeAnim(this, MADAME_AROMA_ANIM_0); + this->actor.flags &= ~ACTOR_FLAG_1; + Actor_SetScale(&this->actor, 0.01f); + this->actionFunc = func_80C1BDD8; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Al/func_80C1C064.s") +void DmAl_Destroy(Actor* thisx, PlayState* play) { +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Al/func_80C1C11C.s") +void DmAl_Update(Actor* thisx, PlayState* play) { + DmAl* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Al/DmAl_Draw.s") + this->actionFunc(this, play); + SkelAnime_Update(&this->skelAnime); + Actor_UpdateBgCheckInfo(play, &this->actor, 30.0f, 12.0f, 0.0f, 4); +} + +s32 DmAl_OverrideLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3f* rot, Vec3s* pos, Actor* thisx) { + switch (limbIndex) { + case MADAME_AROMA_LIMB_SHAWL_MIDDLE: + case MADAME_AROMA_LIMB_SHAWL_UPPER: + case MADAME_AROMA_LIMB_SHAWL_LEFT_LOWER_MIDDLE: + case MADAME_AROMA_LIMB_SHAWL_LEFT_LOWER: + case MADAME_AROMA_LIMB_SHAWL_RIGHT_LOWER_MIDDLE: + case MADAME_AROMA_LIMB_SHAWL_RIGHT_LOWER: + *dList = NULL; + break; + } + return false; +} + +void DmAl_PostLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx) { + DmAl* this = THIS; + + switch (limbIndex) { + case MADAME_AROMA_LIMB_SHAWL_MIDDLE: + Matrix_Get(&this->shawlMatrices[0]); + break; + case MADAME_AROMA_LIMB_SHAWL_UPPER: + Matrix_Get(&this->shawlMatrices[1]); + break; + case MADAME_AROMA_LIMB_SHAWL_LEFT_LOWER_MIDDLE: + Matrix_Get(&this->shawlMatrices[2]); + break; + case MADAME_AROMA_LIMB_SHAWL_LEFT_LOWER: + Matrix_Get(&this->shawlMatrices[3]); + break; + case MADAME_AROMA_LIMB_SHAWL_RIGHT_LOWER_MIDDLE: + Matrix_Get(&this->shawlMatrices[4]); + break; + case MADAME_AROMA_LIMB_SHAWL_RIGHT_LOWER: + Matrix_Get(&this->shawlMatrices[5]); + break; + default: + break; + } +} + +void DmAl_TransformLimbDraw(PlayState* play, s32 limbIndex, Actor* thisx) { +} + +static Gfx* sDlists[] = { + gMadameAromaShawlMiddleDL, gMadameAromaShawlUpperDL, + gMadameAromaShawlLeftLowerMiddleDL, gMadameAromaShawlLeftLowerDL, + gMadameAromaShawlRightLowerMiddleDL, gMadameAromaShawlRightLowerDL, +}; + +void DmAl_Draw(Actor* thisx, PlayState* play) { + u32 i; + DmAl* this = THIS; + + OPEN_DISPS(play->state.gfxCtx); + + func_8012C28C(play->state.gfxCtx); + SkelAnime_DrawTransformFlexOpa(play, this->skelAnime.skeleton, this->skelAnime.jointTable, + this->skelAnime.dListCount, DmAl_OverrideLimbDraw, DmAl_PostLimbDraw, + DmAl_TransformLimbDraw, &this->actor); + for (i = 0; i < ARRAY_COUNT(this->shawlMatrices); i++) { + Matrix_Put(&this->shawlMatrices[i]); + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_OPA_DISP++, sDlists[i]); + } + + CLOSE_DISPS(play->state.gfxCtx); +} diff --git a/src/overlays/actors/ovl_Dm_Al/z_dm_al.h b/src/overlays/actors/ovl_Dm_Al/z_dm_al.h index df89f9150..8f89a4448 100644 --- a/src/overlays/actors/ovl_Dm_Al/z_dm_al.h +++ b/src/overlays/actors/ovl_Dm_Al/z_dm_al.h @@ -2,16 +2,23 @@ #define Z_DM_AL_H #include "global.h" +#include "objects/object_al/object_al.h" struct DmAl; -typedef void (*DmAlActionFunc)(struct DmAl*, GlobalContext*); +typedef void (*DmAlActionFunc)(struct DmAl*, PlayState*); typedef struct DmAl { - /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x44]; - /* 0x0188 */ DmAlActionFunc actionFunc; - /* 0x018C */ char unk_18C[0x2D4]; + /* 0x000 */ Actor actor; + /* 0x144 */ SkelAnime skelAnime; + /* 0x188 */ DmAlActionFunc actionFunc; + /* 0x18C */ MtxF shawlMatrices[6]; + /* 0x30C */ Vec3s jointTable[MADAME_AROMA_LIMB_MAX]; + /* 0x3AE */ Vec3s morphTable[MADAME_AROMA_LIMB_MAX]; + /* 0x450 */ u8 action; + /* 0x454 */ s32 animIndex; + /* 0x458 */ s32 animIndex2; + /* 0x45C */ s32 unk_45C; } DmAl; // size = 0x460 extern const ActorInit Dm_Al_InitVars; 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 2c23601f7..64b6a7a98 100644 --- a/src/overlays/actors/ovl_Dm_An/z_dm_an.c +++ b/src/overlays/actors/ovl_Dm_An/z_dm_an.c @@ -12,14 +12,14 @@ #define THIS ((DmAn*)thisx) -void DmAn_Init(Actor* thisx, GlobalContext* globalCtx); -void DmAn_Destroy(Actor* thisx, GlobalContext* globalCtx); -void DmAn_Update(Actor* thisx, GlobalContext* globalCtx); +void DmAn_Init(Actor* thisx, PlayState* play); +void DmAn_Destroy(Actor* thisx, PlayState* play); +void DmAn_Update(Actor* thisx, PlayState* play); -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); +void func_80C1C958(DmAn* this, PlayState* play); +void func_80C1CAB0(DmAn* this, PlayState* play); +void func_80C1CC80(DmAn* this, PlayState* play); +void func_80C1D0B0(Actor* this, PlayState* play); const ActorInit Dm_An_InitVars = { ACTOR_DM_AN, @@ -33,7 +33,7 @@ const ActorInit Dm_An_InitVars = { (ActorFunc)NULL, }; -static AnimationInfoS sAnimations[] = { +static AnimationInfoS sAnimationInfo[] = { { &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 }, @@ -50,7 +50,7 @@ static AnimationInfoS sAnimations[] = { { &object_an4_Anim_00506C, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, }; -s32 func_80C1C410(DmAn* this, GlobalContext* globalCtx) { +s32 func_80C1C410(DmAn* this, PlayState* play) { s8 objectIndex = this->actor.objBankIndex; s8 objectIndex2; s32 ret = false; @@ -62,14 +62,14 @@ s32 func_80C1C410(DmAn* this, GlobalContext* globalCtx) { } if (objectIndex2 >= 0) { - gSegments[6] = PHYSICAL_TO_VIRTUAL2(globalCtx->objectCtx.status[objectIndex2].segment); + gSegments[6] = VIRTUAL_TO_PHYSICAL(play->objectCtx.status[objectIndex2].segment); ret = SkelAnime_Update(&this->skelAnime); - gSegments[6] = PHYSICAL_TO_VIRTUAL2(globalCtx->objectCtx.status[objectIndex].segment); + gSegments[6] = VIRTUAL_TO_PHYSICAL(play->objectCtx.status[objectIndex].segment); } return ret; } -s32 func_80C1C4D8(DmAn* this, GlobalContext* globalCtx, s32 arg2) { +s32 func_80C1C4D8(DmAn* this, PlayState* play, s32 arg2) { s8 objectIndex = this->actor.objBankIndex; s8 objectIndex2; s32 ret = false; @@ -81,10 +81,10 @@ s32 func_80C1C4D8(DmAn* this, GlobalContext* globalCtx, s32 arg2) { } if ((objectIndex2 >= 0) && (arg2 != this->unk_2C8)) { - gSegments[6] = PHYSICAL_TO_VIRTUAL2(globalCtx->objectCtx.status[objectIndex2].segment); + gSegments[6] = VIRTUAL_TO_PHYSICAL(play->objectCtx.status[objectIndex2].segment); this->unk_2C8 = arg2; - ret = SubS_ChangeAnimationByInfoS(&this->skelAnime, sAnimations, arg2); - gSegments[6] = PHYSICAL_TO_VIRTUAL2(globalCtx->objectCtx.status[objectIndex].segment); + ret = SubS_ChangeAnimationByInfoS(&this->skelAnime, sAnimationInfo, arg2); + gSegments[6] = VIRTUAL_TO_PHYSICAL(play->objectCtx.status[objectIndex].segment); } return ret; } @@ -99,7 +99,7 @@ void func_80C1C5B4(DmAn* this) { } } -s32 func_80C1C62C(DmAn* this, GlobalContext* globalCtx) { +s32 func_80C1C62C(DmAn* this, PlayState* play) { s32 pad; Vec3f sp40; Vec3f sp34; @@ -130,9 +130,9 @@ s32 func_80C1C62C(DmAn* this, GlobalContext* globalCtx) { return true; } -s32 func_80C1C83C(DmAn* this, GlobalContext* globalCtx) { +s32 func_80C1C83C(DmAn* this, PlayState* play) { if (this->unk_2B4 != NULL) { - func_80C1C62C(this, globalCtx); + func_80C1C62C(this, play); this->unk_2AE &= ~1; this->unk_2AE |= 2; } else if (this->unk_2AE & 2) { @@ -148,12 +148,12 @@ s32 func_80C1C83C(DmAn* this, GlobalContext* globalCtx) { return true; } -Actor* func_80C1C8E8(GlobalContext* globalCtx) { +Actor* func_80C1C8E8(PlayState* play) { Actor* tempActor; Actor* foundActor = NULL; while (true) { - foundActor = SubS_FindActor(globalCtx, foundActor, ACTORCAT_NPC, ACTOR_DM_AH); + foundActor = SubS_FindActor(play, foundActor, ACTORCAT_NPC, ACTOR_DM_AH); if ((foundActor == NULL) || (foundActor->update != NULL)) { break; @@ -169,23 +169,23 @@ Actor* func_80C1C8E8(GlobalContext* globalCtx) { 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)) { +void func_80C1C958(DmAn* this, PlayState* play) { + if ((this->unk_2AC >= 0) && SubS_IsObjectLoaded(this->unk_2AC, play) && (this->unk_2AD >= 0) && + SubS_IsObjectLoaded(this->unk_2AD, play)) { 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); + SkelAnime_InitFlex(play, &this->skelAnime, &object_an1_Skel_012618, NULL, this->jointTable, this->morphTable, + OBJECT_AN1_LIMB_MAX); this->unk_2C8 = -1; - func_80C1C4D8(this, globalCtx, 0); + func_80C1C4D8(this, play, 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); + if ((play->sceneNum == SCENE_YADOYA) && (play->curSpawn == 4)) { + this->unk_2B4 = func_80C1C8E8(play); + func_80C1C4D8(this, play, 1); this->actionFunc = func_80C1CC80; } else { this->actionFunc = func_80C1CAB0; @@ -193,12 +193,12 @@ void func_80C1C958(DmAn* this, GlobalContext* globalCtx) { } } -void func_80C1CAB0(DmAn* this, GlobalContext* globalCtx) { +void func_80C1CAB0(DmAn* this, PlayState* play) { s32 sp28[] = { 0, 0, 12, 2, 4, 6, 8, 10, 11, 3 }; u16 action; s32 sp20; - if (globalCtx->csCtx.state != 0) { + if (play->csCtx.state != 0) { if (this->unk_2D0 == 0) { this->unk_2B0 = 255; this->unk_2D0 = 1; @@ -206,14 +206,14 @@ void func_80C1CAB0(DmAn* this, GlobalContext* globalCtx) { this->unk_2CC = this->unk_2C8; } - if (Cutscene_CheckActorAction(globalCtx, 0x22D)) { - sp20 = Cutscene_GetActorActionIndex(globalCtx, 0x22D); - action = globalCtx->csCtx.actorActions[sp20]->action; + if (Cutscene_CheckActorAction(play, 0x22D)) { + sp20 = Cutscene_GetActorActionIndex(play, 0x22D); + action = play->csCtx.actorActions[sp20]->action; if (this->unk_2B0 != (action & 0xFF)) { this->unk_2B0 = action; this->unk_2D4 = 1; - func_80C1C4D8(this, globalCtx, sp28[action]); + func_80C1C4D8(this, play, sp28[action]); } switch (this->unk_2B0) { @@ -225,144 +225,144 @@ void func_80C1CAB0(DmAn* this, GlobalContext* globalCtx) { 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); + func_80C1C4D8(this, play, this->unk_2C8 + 1); } } break; } - Cutscene_ActorTranslateAndYaw(&this->actor, globalCtx, sp20); + Cutscene_ActorTranslateAndYaw(&this->actor, play, sp20); } } else if (this->unk_2D0 != 0) { this->unk_2D0 = 0; this->unk_2D4 = 0; - func_80C1C4D8(this, globalCtx, this->unk_2CC); + func_80C1C4D8(this, play, this->unk_2CC); } } -void func_80C1CC80(DmAn* this, GlobalContext* globalCtx) { +void func_80C1CC80(DmAn* this, PlayState* play) { } -void DmAn_Init(Actor* thisx, GlobalContext* globalCtx) { +void DmAn_Init(Actor* thisx, PlayState* play) { DmAn* this = THIS; - this->unk_2AC = SubS_GetObjectIndex(OBJECT_AN4, globalCtx); - this->unk_2AD = SubS_GetObjectIndex(OBJECT_MSMO, globalCtx); + this->unk_2AC = SubS_GetObjectIndex(OBJECT_AN4, play); + this->unk_2AD = SubS_GetObjectIndex(OBJECT_MSMO, play); this->actionFunc = func_80C1C958; } -void DmAn_Destroy(Actor* thisx, GlobalContext* globalCtx) { +void DmAn_Destroy(Actor* thisx, PlayState* play) { } -void DmAn_Update(Actor* thisx, GlobalContext* globalCtx) { +void DmAn_Update(Actor* thisx, PlayState* play) { DmAn* this = THIS; - this->actionFunc(this, globalCtx); + this->actionFunc(this, play); - func_80C1C83C(this, globalCtx); + func_80C1C83C(this, play); if (this->actor.draw != NULL) { - func_80C1C410(this, globalCtx); + func_80C1C410(this, play); func_80C1C5B4(this); } - Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 30.0f, 12.0f, 0.0f, 4); + Actor_UpdateBgCheckInfo(play, &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) { +void func_80C1CD80(PlayState* play, 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); + OPEN_DISPS(play->state.gfxCtx); - Matrix_StatePush(); - Matrix_JointPosition(&D_80C1D2C8, &D_80C1D2D4); + 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); + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPSegment(POLY_OPA_DISP++, 0x06, play->objectCtx.status[sp2A].segment); gSPDisplayList(POLY_OPA_DISP++, gMoonMaskDL); - gSPSegment(POLY_OPA_DISP++, 0x06, globalCtx->objectCtx.status[sp2B].segment); + gSPSegment(POLY_OPA_DISP++, 0x06, play->objectCtx.status[sp2B].segment); - Matrix_StatePop(); + Matrix_Pop(); - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->state.gfxCtx); } if (limbIndex == OBJECT_AN1_LIMB_09) { - Matrix_MultiplyVector3fByState(&D_80C1D2DC, &this->actor.focus.pos); + 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) { +void func_80C1CEFC(PlayState* play, s32 limbIndex, Actor* thisx) { DmAn* this = THIS; - s16 phi_v1; - s16 phi_v0; + s16 stepRot; + s16 overrideRot; if (!(this->unk_2AE & 1)) { if (this->unk_2AE & 2) { - phi_v0 = 1; + overrideRot = true; } else { - phi_v0 = 0; + overrideRot = false; } - phi_v1 = 1; + stepRot = true; } else { - phi_v1 = 0; - phi_v0 = 0; + stepRot = false; + overrideRot = false; } if (limbIndex == OBJECT_AN1_LIMB_09) { - func_8013AD9C(this->unk_2BE + this->unk_2C2 + 0x4000, - this->unk_2C0 + this->unk_2C4 + this->actor.shape.rot.y + 0x4000, &this->unk_18C, &this->unk_1A4, - phi_v1, phi_v0); - Matrix_StatePop(); - Matrix_InsertTranslation(this->unk_18C.x, this->unk_18C.y, this->unk_18C.z, MTXMODE_NEW); + 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_RotateY(this->unk_1A4.y, MTXMODE_APPLY); - Matrix_InsertXRotation_s(this->unk_1A4.x, MTXMODE_APPLY); - Matrix_InsertZRotation_s(this->unk_1A4.z, MTXMODE_APPLY); - Matrix_StatePush(); + 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) { - func_8013AD9C(this->unk_2C2 + 0x4000, this->unk_2C4 + this->actor.shape.rot.y + 0x4000, &this->unk_194, - &this->unk_1AA, phi_v1, phi_v0); - Matrix_StatePop(); - Matrix_InsertTranslation(this->unk_194.x, this->unk_194.y, this->unk_194.z, MTXMODE_NEW); + 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_RotateY(this->unk_1AA.y, MTXMODE_APPLY); - Matrix_InsertXRotation_s(this->unk_1AA.x, MTXMODE_APPLY); - Matrix_InsertZRotation_s(this->unk_1AA.z, MTXMODE_APPLY); - Matrix_StatePush(); + 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, + 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, + 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) { +void func_80C1D0B0(Actor* thisx, PlayState* play) { DmAn* this = THIS; - OPEN_DISPS(globalCtx->state.gfxCtx); + OPEN_DISPS(play->state.gfxCtx); - func_8012C28C(globalCtx->state.gfxCtx); + func_8012C28C(play->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, + SkelAnime_DrawTransformFlexOpa(play, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, NULL, func_80C1CD80, func_80C1CEFC, &this->actor); - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->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 1b2b6f354..2282fee9c 100644 --- a/src/overlays/actors/ovl_Dm_An/z_dm_an.h +++ b/src/overlays/actors/ovl_Dm_An/z_dm_an.h @@ -6,34 +6,34 @@ struct DmAn; -typedef void (*DmAnActionFunc)(struct DmAn*, GlobalContext*); +typedef void (*DmAnActionFunc)(struct DmAn*, PlayState*); typedef struct DmAn { - /* 0x0000 */ Actor actor; - /* 0x0144 */ SkelAnime skelAnime; - /* 0x0188 */ DmAnActionFunc actionFunc; - /* 0x018C */ Vec3f unk_18C; - /* 0x018C */ Vec3f unk_194; - /* 0x01A4 */ Vec3s unk_1A4; - /* 0x01A4 */ Vec3s unk_1AA; - /* 0x01B0 */ Vec3s jointTable[OBJECT_AN1_LIMB_MAX]; - /* 0x022E */ Vec3s morphTable[OBJECT_AN1_LIMB_MAX]; - /* 0x02AC */ s8 unk_2AC; - /* 0x02AD */ s8 unk_2AD; - /* 0x02AE */ u16 unk_2AE; - /* 0x02B0 */ u8 unk_2B0; - /* 0x02B4 */ Actor* unk_2B4; - /* 0x02B8 */ s16 unk_2B8; - /* 0x02BA */ s16 unk_2BA; - /* 0x02BC */ s16 unk_2BC; - /* 0x02BE */ s16 unk_2BE; - /* 0x02C0 */ s16 unk_2C0; - /* 0x02C2 */ s16 unk_2C2; - /* 0x02C4 */ s16 unk_2C4; - /* 0x02C8 */ s32 unk_2C8; - /* 0x02CC */ s32 unk_2CC; - /* 0x02D0 */ s32 unk_2D0; - /* 0x02D4 */ s32 unk_2D4; + /* 0x000 */ Actor actor; + /* 0x144 */ SkelAnime skelAnime; + /* 0x188 */ DmAnActionFunc actionFunc; + /* 0x18C */ Vec3f unk_18C; + /* 0x18C */ Vec3f unk_194; + /* 0x1A4 */ Vec3s unk_1A4; + /* 0x1A4 */ Vec3s unk_1AA; + /* 0x1B0 */ Vec3s jointTable[OBJECT_AN1_LIMB_MAX]; + /* 0x22E */ Vec3s morphTable[OBJECT_AN1_LIMB_MAX]; + /* 0x2AC */ s8 unk_2AC; + /* 0x2AD */ s8 unk_2AD; + /* 0x2AE */ u16 unk_2AE; + /* 0x2B0 */ u8 unk_2B0; + /* 0x2B4 */ Actor* unk_2B4; + /* 0x2B8 */ s16 unk_2B8; + /* 0x2BA */ s16 unk_2BA; + /* 0x2BC */ s16 unk_2BC; + /* 0x2BE */ s16 unk_2BE; + /* 0x2C0 */ s16 unk_2C0; + /* 0x2C2 */ s16 unk_2C2; + /* 0x2C4 */ s16 unk_2C4; + /* 0x2C8 */ s32 unk_2C8; + /* 0x2CC */ s32 unk_2CC; + /* 0x2D0 */ s32 unk_2D0; + /* 0x2D4 */ s32 unk_2D4; } DmAn; // size = 0x2D8 extern const ActorInit Dm_An_InitVars; diff --git a/src/overlays/actors/ovl_Dm_Bal/z_dm_bal.c b/src/overlays/actors/ovl_Dm_Bal/z_dm_bal.c index aa4abb91d..04dd13ca4 100644 --- a/src/overlays/actors/ovl_Dm_Bal/z_dm_bal.c +++ b/src/overlays/actors/ovl_Dm_Bal/z_dm_bal.c @@ -10,14 +10,14 @@ #define THIS ((DmBal*)thisx) -void DmBal_Init(Actor* thisx, GlobalContext* globalCtx); -void DmBal_Destroy(Actor* thisx, GlobalContext* globalCtx); -void DmBal_Update(Actor* thisx, GlobalContext* globalCtx); -void DmBal_Draw(Actor* thisx, GlobalContext* globalCtx); +void DmBal_Init(Actor* thisx, PlayState* play); +void DmBal_Destroy(Actor* thisx, PlayState* play); +void DmBal_Update(Actor* thisx, PlayState* play); +void DmBal_Draw(Actor* thisx, PlayState* play); -void func_80C1EAD8(DmBal* this, GlobalContext* globalCtx); +void func_80C1EAC4(DmBal* this); +void func_80C1EAD8(DmBal* this, PlayState* play); -#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 sAnimationInfo[] = { + { &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, PlayState* play) { + 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(play, &this->skelAnime, &object_bal_Skel_00A6D0, &object_bal_Anim_0005FC, this->jointTable, + this->morphTable, OBJECT_BAL_LIMB_MAX); + Actor_UpdateBgCheckInfo(play, &this->actor, 0.0f, 0.0f, 0.0f, 4); + 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, PlayState* play) { +} -#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, PlayState* play) { +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Bal/func_80C1EAE8.s") +void func_80C1EAE8(DmBal* this, PlayState* play) { + static u16 D_80C1F2C0 = 0x63; + s32 actionIndex; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Bal/func_80C1EC60.s") + if (Cutscene_CheckActorAction(play, 0x238)) { + actionIndex = Cutscene_GetActorActionIndex(play, 0x238); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Bal/func_80C1ED0C.s") + if (D_80C1F2C0 != play->csCtx.actorActions[actionIndex]->action) { + D_80C1F2C0 = play->csCtx.actorActions[actionIndex]->action; + switch (play->csCtx.actorActions[actionIndex]->action) { + case 1: + this->unk_336 = 0; + this->eyeIndex = 0; + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, 0); + break; + case 2: + this->unk_336 = 1; + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, 12); + break; + case 3: + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, 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, play, 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, PlayState* play) { + 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, PlayState* play, Vec3f* arg2, Vec3f* arg3, f32 arg4) { + Actor* paper = Actor_Spawn(&play->actorCtx, play, 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, PlayState* play) { + 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, play, &sp3C, &sp30, -0.4f); + func_80C1ED64(this, play, &sp3C, &sp30, -0.5f); + } + this->actionFunc(this, play); + func_80C1EAE8(this, play); + func_80C1EC60(this, play); + func_80C1ED0C(this); + SkelAnime_Update(&this->skelAnime); +} + +s32 DmBal_OverrideLimbDraw(PlayState* play, 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(PlayState* play, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx) { +} + +TexturePtr sEyeTextures[] = { object_bal_Tex_006050, object_bal_Tex_0094D0 }; + +void DmBal_Draw(Actor* thisx, PlayState* play) { + DmBal* this = THIS; + + OPEN_DISPS(play->state.gfxCtx); + func_8012C28C(play->state.gfxCtx); + gSPSegment(POLY_OPA_DISP++, 0x08, SEGMENTED_TO_VIRTUAL(sEyeTextures[this->eyeIndex])); + SkelAnime_DrawFlexOpa(play, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, + DmBal_OverrideLimbDraw, DmBal_PostLimbDraw, &this->actor); + CLOSE_DISPS(play->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..bda05149f 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 void (*DmBalActionFunc)(struct DmBal*, PlayState*); 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 c72634216..177c5784d 100644 --- a/src/overlays/actors/ovl_Dm_Char00/z_dm_char00.c +++ b/src/overlays/actors/ovl_Dm_Char00/z_dm_char00.c @@ -12,13 +12,13 @@ #define THIS ((DmChar00*)thisx) -void DmChar00_Init(Actor* thisx, GlobalContext* globalCtx); -void DmChar00_Destroy(Actor* thisx, GlobalContext* globalCtx); -void DmChar00_Update(Actor* thisx, GlobalContext* globalCtx); -void DmChar00_Draw(Actor* thisx, GlobalContext* globalCtx); +void DmChar00_Init(Actor* thisx, PlayState* play); +void DmChar00_Destroy(Actor* thisx, PlayState* play); +void DmChar00_Update(Actor* thisx, PlayState* play); +void DmChar00_Draw(Actor* thisx, PlayState* play); -void func_80AA67F8(DmChar00* this, GlobalContext* globalCtx); -void func_80AA695C(DmChar00* this, GlobalContext* globalCtx); +void func_80AA67F8(DmChar00* this, PlayState* play); +void func_80AA695C(DmChar00* this, PlayState* play); const ActorInit Dm_Char00_InitVars = { ACTOR_DM_CHAR00, @@ -32,7 +32,7 @@ const ActorInit Dm_Char00_InitVars = { (ActorFunc)DmChar00_Draw, }; -static AnimationInfo sAnimations[] = { +static AnimationInfo sAnimationInfo[] = { { &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 }, @@ -120,13 +120,13 @@ static AnimationInfo sAnimations[] = { { &object_delf_Anim_000E44, 1.0f, 0.0f, -1.0f, 0, 0.0f }, }; -DmChar00Struct D_80AA77A8[] = { +Color_RGBAf 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 }, }; -DmChar00Struct D_80AA77D8[] = { +Color_RGBAf 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 }, @@ -148,9 +148,9 @@ void func_80AA5580(SkelAnime* skelAnime, AnimationInfo* animation, u16 idx) { animation->mode, animation->morphFrames); } -void func_80AA561C(DmChar00* this, GlobalContext* globalCtx) { +void func_80AA561C(DmChar00* this, PlayState* play) { if (DMCHAR00_GET(&this->actor) == DMCHAR00_0) { - switch (globalCtx->csCtx.frames + 20) { + switch (play->csCtx.frames + 20) { case 503: case 926: case 979: @@ -169,7 +169,7 @@ void func_80AA561C(DmChar00* this, GlobalContext* globalCtx) { break; } } else { - switch (globalCtx->csCtx.frames + 20) { + switch (play->csCtx.frames + 20) { case 503: case 926: case 979: @@ -187,15 +187,15 @@ void func_80AA561C(DmChar00* this, GlobalContext* globalCtx) { } } -void func_80AA5720(DmChar00* this, GlobalContext* globalCtx) { - if ((DMCHAR00_GET(&this->actor) == DMCHAR00_0) && (globalCtx->csCtx.frames == 505)) { +void func_80AA5720(DmChar00* this, PlayState* play) { + if ((DMCHAR00_GET(&this->actor) == DMCHAR00_0) && (play->csCtx.frames == 505)) { Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_SPOT_LIGHT_OPEN); } } -void func_80AA575C(DmChar00* this, GlobalContext* globalCtx) { +void func_80AA575C(DmChar00* this, PlayState* play) { if (DMCHAR00_GET(&this->actor) == DMCHAR00_0) { - switch (globalCtx->csCtx.frames) { + switch (play->csCtx.frames) { case 474: case 489: case 495: @@ -227,24 +227,24 @@ void func_80AA575C(DmChar00* this, GlobalContext* globalCtx) { Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_BELL_BRAKE); break; } - } else if (globalCtx->csCtx.frames == 660) { + } else if (play->csCtx.frames == 660) { Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_MONDO_SURPRISE); } } -void func_80AA5890(DmChar00* this, GlobalContext* globalCtx) { - if ((DMCHAR00_GET(&this->actor) == DMCHAR00_0) && (globalCtx->csCtx.frames == 20)) { +void func_80AA5890(DmChar00* this, PlayState* play) { + if ((DMCHAR00_GET(&this->actor) == DMCHAR00_0) && (play->csCtx.frames == 20)) { Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_WHITE_FAIRY_DASH); } } -void func_80AA58CC(DmChar00* this, GlobalContext* globalCtx) { +void func_80AA58CC(DmChar00* this, PlayState* play) { if (DMCHAR00_GET(&this->actor) == DMCHAR00_0) { - if (globalCtx->csCtx.frames == 568) { + if (play->csCtx.frames == 568) { Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_FAIRY_SURPRISE); } } else { - switch (globalCtx->csCtx.frames) { + switch (play->csCtx.frames) { case 375: case 479: Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_BLACK_FAIRY_DASH); @@ -257,16 +257,16 @@ void func_80AA58CC(DmChar00* this, GlobalContext* globalCtx) { } } -void func_80AA5950(DmChar00* this, GlobalContext* globalCtx) { +void func_80AA5950(DmChar00* this, PlayState* play) { } -void func_80AA5960(DmChar00* this, GlobalContext* globalCtx) { +void func_80AA5960(DmChar00* this, PlayState* play) { if (DMCHAR00_GET(&this->actor) == DMCHAR00_0) { - if (globalCtx->csCtx.frames == 280) { + if (play->csCtx.frames == 280) { Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_FAIRY_SURPRISE); } } else { - switch (globalCtx->csCtx.frames) { + switch (play->csCtx.frames) { case 87: case 190: Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_BLACK_FAIRY_DASH); @@ -279,9 +279,9 @@ void func_80AA5960(DmChar00* this, GlobalContext* globalCtx) { } } -void func_80AA59E4(DmChar00* this, GlobalContext* globalCtx) { +void func_80AA59E4(DmChar00* this, PlayState* play) { if (DMCHAR00_GET(&this->actor) == DMCHAR00_0) { - switch (globalCtx->csCtx.frames) { + switch (play->csCtx.frames) { case 125: Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_WHITE_FAIRY_DASH); break; @@ -291,14 +291,14 @@ void func_80AA59E4(DmChar00* this, GlobalContext* globalCtx) { Actor_PlaySfxAtPos(&this->actor, NA_SE_SY_WHITE_OUT_INTO_MOON); break; } - } else if (globalCtx->csCtx.frames == 125) { + } else if (play->csCtx.frames == 125) { Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_BLACK_FAIRY_DASH); } } -void func_80AA5A6C(DmChar00* this, GlobalContext* globalCtx) { +void func_80AA5A6C(DmChar00* this, PlayState* play) { if (DMCHAR00_GET(&this->actor) == DMCHAR00_0) { - switch (globalCtx->csCtx.frames) { + switch (play->csCtx.frames) { case 44: Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_WHITE_FAIRY_DASH); break; @@ -308,14 +308,14 @@ void func_80AA5A6C(DmChar00* this, GlobalContext* globalCtx) { Actor_PlaySfxAtPos(&this->actor, NA_SE_SY_WHITE_OUT_INTO_MOON); break; } - } else if (globalCtx->csCtx.frames == 44) { + } else if (play->csCtx.frames == 44) { Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_BLACK_FAIRY_DASH); } } -void func_80AA5AF4(DmChar00* this, GlobalContext* globalCtx) { +void func_80AA5AF4(DmChar00* this, PlayState* play) { if (DMCHAR00_GET(&this->actor) == DMCHAR00_0) { - switch (globalCtx->csCtx.frames) { + switch (play->csCtx.frames) { case 352: case 401: Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_WHITE_FAIRY_DASH); @@ -330,7 +330,7 @@ void func_80AA5AF4(DmChar00* this, GlobalContext* globalCtx) { break; } } else { - switch (globalCtx->csCtx.frames) { + switch (play->csCtx.frames) { case 362: case 401: Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_BLACK_FAIRY_DASH); @@ -341,15 +341,15 @@ void func_80AA5AF4(DmChar00* this, GlobalContext* globalCtx) { break; } - if ((globalCtx->csCtx.frames >= 500) && (globalCtx->csCtx.frames < 602)) { + if ((play->csCtx.frames >= 500) && (play->csCtx.frames < 602)) { Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_FAIRY_SHIVER - SFX_FLAG); } } } -void func_80AA5BF8(DmChar00* this, GlobalContext* globalCtx) { +void func_80AA5BF8(DmChar00* this, PlayState* play) { if (DMCHAR00_GET(&this->actor) == DMCHAR00_0) { - switch (globalCtx->csCtx.frames) { + switch (play->csCtx.frames) { case 762: Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_WHITE_FAIRY_SHOT_DASH); break; @@ -358,7 +358,7 @@ void func_80AA5BF8(DmChar00* this, GlobalContext* globalCtx) { break; } } else { - switch (globalCtx->csCtx.frames) { + switch (play->csCtx.frames) { case 762: Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_BLACK_FAIRY_SHOT_DASH); break; @@ -374,15 +374,15 @@ void func_80AA5BF8(DmChar00* this, GlobalContext* globalCtx) { } } -void func_80AA5CD4(DmChar00* this, GlobalContext* globalCtx) { - if ((DMCHAR00_GET(&this->actor) != DMCHAR00_0) && (globalCtx->csCtx.frames == 467)) { +void func_80AA5CD4(DmChar00* this, PlayState* play) { + if ((DMCHAR00_GET(&this->actor) != DMCHAR00_0) && (play->csCtx.frames == 467)) { Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_BLACK_FAIRY_DASH); } } -void func_80AA5D10(DmChar00* this, GlobalContext* globalCtx) { +void func_80AA5D10(DmChar00* this, PlayState* play) { if (DMCHAR00_GET(&this->actor) == DMCHAR00_0) { - switch (globalCtx->csCtx.frames) { + switch (play->csCtx.frames) { case 8: Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_FAIRY_SURPRISE); break; @@ -394,9 +394,9 @@ void func_80AA5D10(DmChar00* this, GlobalContext* globalCtx) { } } -void func_80AA5D6C(DmChar00* this, GlobalContext* globalCtx) { +void func_80AA5D6C(DmChar00* this, PlayState* play) { if (DMCHAR00_GET(&this->actor) == DMCHAR00_0) { - switch (globalCtx->csCtx.frames) { + switch (play->csCtx.frames) { case 2: case 166: Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_WHITE_FAIRY_DASH); @@ -409,9 +409,9 @@ void func_80AA5D6C(DmChar00* this, GlobalContext* globalCtx) { } } -void func_80AA5DC8(DmChar00* this, GlobalContext* globalCtx) { +void func_80AA5DC8(DmChar00* this, PlayState* play) { if (DMCHAR00_GET(&this->actor) == DMCHAR00_0) { - switch (globalCtx->csCtx.frames) { + switch (play->csCtx.frames) { case 233: case 415: case 593: @@ -425,9 +425,9 @@ void func_80AA5DC8(DmChar00* this, GlobalContext* globalCtx) { } } -void func_80AA5E2C(DmChar00* this, GlobalContext* globalCtx) { +void func_80AA5E2C(DmChar00* this, PlayState* play) { if (DMCHAR00_GET(&this->actor) == DMCHAR00_1) { - switch (globalCtx->csCtx.frames) { + switch (play->csCtx.frames) { case 32: Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_WHITE_FAIRY_DASH); break; @@ -447,87 +447,87 @@ void func_80AA5E2C(DmChar00* this, GlobalContext* globalCtx) { } } -void func_80AA5EBC(DmChar00* this, GlobalContext* globalCtx) { - if (globalCtx->csCtx.state != 0) { - switch (globalCtx->sceneNum) { +void func_80AA5EBC(DmChar00* this, PlayState* play) { + if (play->csCtx.state != 0) { + switch (play->sceneNum) { case SCENE_LOST_WOODS: if (gSaveContext.sceneSetupIndex == 1) { - func_80AA561C(this, globalCtx); + func_80AA561C(this, play); } 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); + if (play->csCtx.currentCsIndex == 0) { + func_80AA5720(this, play); + } else if (play->csCtx.currentCsIndex == 1) { + func_80AA575C(this, play); + } else if (play->csCtx.currentCsIndex == 2) { + func_80AA5890(this, play); } } 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); + if (play->csCtx.currentCsIndex == 0) { + func_80AA58CC(this, play); + } else if (play->csCtx.currentCsIndex == 1) { + func_80AA5950(this, play); + } else if (play->csCtx.currentCsIndex == 2) { + func_80AA5960(this, play); } } else if (gSaveContext.sceneSetupIndex == 2) { - if (globalCtx->csCtx.currentCsIndex == 0) { - func_80AA59E4(this, globalCtx); - } else if (globalCtx->csCtx.currentCsIndex == 1) { - func_80AA5A6C(this, globalCtx); + if (play->csCtx.currentCsIndex == 0) { + func_80AA59E4(this, play); + } else if (play->csCtx.currentCsIndex == 1) { + func_80AA5A6C(this, play); } } 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); + if (play->csCtx.currentCsIndex == 0) { + func_80AA5AF4(this, play); + } else if (play->csCtx.currentCsIndex == 2) { + func_80AA5E2C(this, play); } } else if (gSaveContext.sceneSetupIndex == 7) { - if (globalCtx->csCtx.currentCsIndex == 0) { - func_80AA5BF8(this, globalCtx); - } else if (globalCtx->csCtx.currentCsIndex == 1) { - func_80AA5CD4(this, globalCtx); + if (play->csCtx.currentCsIndex == 0) { + func_80AA5BF8(this, play); + } else if (play->csCtx.currentCsIndex == 1) { + func_80AA5CD4(this, play); } } break; case SCENE_MITURIN: - if ((gSaveContext.sceneSetupIndex == 0) && (globalCtx->csCtx.currentCsIndex == 1)) { - func_80AA5DC8(this, globalCtx); + if ((gSaveContext.sceneSetupIndex == 0) && (play->csCtx.currentCsIndex == 1)) { + func_80AA5DC8(this, play); } break; case SCENE_INSIDETOWER: - if ((gSaveContext.sceneSetupIndex == 0) && (globalCtx->csCtx.currentCsIndex == 0)) { - func_80AA5D10(this, globalCtx); + if ((gSaveContext.sceneSetupIndex == 0) && (play->csCtx.currentCsIndex == 0)) { + func_80AA5D10(this, play); } break; case SCENE_PIRATE: - if ((gSaveContext.sceneSetupIndex == 0) && (globalCtx->csCtx.currentCsIndex == 0)) { - func_80AA5D6C(this, globalCtx); + if ((gSaveContext.sceneSetupIndex == 0) && (play->csCtx.currentCsIndex == 0)) { + func_80AA5D6C(this, play); } break; } } } -void DmChar00_Init(Actor* thisx, GlobalContext* globalCtx) { +void DmChar00_Init(Actor* thisx, PlayState* play) { s32 pad; DmChar00* this = THIS; - if ((globalCtx->sceneNum == SCENE_LOST_WOODS) && !Cutscene_IsPlaying(globalCtx)) { + if ((play->sceneNum == SCENE_LOST_WOODS) && !Cutscene_IsPlaying(play)) { Actor_MarkForDeath(thisx); } @@ -539,30 +539,30 @@ void DmChar00_Init(Actor* thisx, GlobalContext* globalCtx) { 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); + SkelAnime_Init(play, &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); + func_80AA5580(&this->skelAnime, sAnimationInfo, 0); Actor_SetScale(thisx, 0.01f); this->actionFunc = func_80AA67F8; } -void DmChar00_Destroy(Actor* thisx, GlobalContext* globalCtx) { +void DmChar00_Destroy(Actor* thisx, PlayState* play) { } -void func_80AA62FC(DmChar00* this, GlobalContext* globalCtx) { +void func_80AA62FC(DmChar00* this, PlayState* play) { u16 sp26 = DMCHAR00_GET(&this->actor) + 113; s32 temp_v0; s32 pad; - if (Cutscene_CheckActorAction(globalCtx, sp26)) { - temp_v0 = Cutscene_GetActorActionIndex(globalCtx, sp26); + if (Cutscene_CheckActorAction(play, sp26)) { + temp_v0 = Cutscene_GetActorActionIndex(play, 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; + if (play->csCtx.frames == play->csCtx.actorActions[temp_v0]->startFrame) { + if (this->unk_260 != play->csCtx.actorActions[temp_v0]->action) { + this->unk_260 = play->csCtx.actorActions[temp_v0]->action; - switch (globalCtx->csCtx.actorActions[temp_v0]->action) { + switch (play->csCtx.actorActions[temp_v0]->action) { case 0x1: this->unk_261 = 0; break; @@ -783,10 +783,10 @@ void func_80AA62FC(DmChar00* this, GlobalContext* globalCtx) { this->unk_261 = 0; break; } - func_80AA5580(&this->skelAnime, &sAnimations[this->unk_261], 0); + func_80AA5580(&this->skelAnime, &sAnimationInfo[this->unk_261], 0); } } - Cutscene_ActorTranslateAndYaw(&this->actor, globalCtx, temp_v0); + Cutscene_ActorTranslateAndYaw(&this->actor, play, temp_v0); } else { this->unk_260 = 99; } @@ -796,7 +796,7 @@ void func_80AA62FC(DmChar00* this, GlobalContext* globalCtx) { case 0x4: case 0x5: this->unk_261 += 4; - func_80AA5580(&this->skelAnime, &sAnimations[this->unk_261], 0); + func_80AA5580(&this->skelAnime, &sAnimationInfo[this->unk_261], 0); this->skelAnime.curFrame = 37.0f; break; @@ -805,7 +805,7 @@ void func_80AA62FC(DmChar00* this, GlobalContext* globalCtx) { case 0x14: case 0x15: this->unk_261 += 2; - func_80AA5580(&this->skelAnime, &sAnimations[this->unk_261], 0); + func_80AA5580(&this->skelAnime, &sAnimationInfo[this->unk_261], 0); break; case 0xA: @@ -833,31 +833,30 @@ void func_80AA62FC(DmChar00* this, GlobalContext* globalCtx) { case 0x50: case 0x53: this->unk_261 += 1; - func_80AA5580(&this->skelAnime, &sAnimations[this->unk_261], 0); + func_80AA5580(&this->skelAnime, &sAnimationInfo[this->unk_261], 0); break; case 0x2D: this->unk_261 = 19; - func_80AA5580(&this->skelAnime, &sAnimations[this->unk_261], 0); + func_80AA5580(&this->skelAnime, &sAnimationInfo[this->unk_261], 0); break; case 0x46: case 0x4D: this->unk_261 = 0; - func_80AA5580(&this->skelAnime, &sAnimations[this->unk_261], 0); + func_80AA5580(&this->skelAnime, &sAnimationInfo[this->unk_261], 0); break; } } } -void func_80AA67F8(DmChar00* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); +void func_80AA67F8(DmChar00* this, PlayState* play) { + Player* player = GET_PLAYER(play); - if ((globalCtx->csCtx.state == 0) && (gSaveContext.sceneSetupIndex == 0) && - (globalCtx->csCtx.currentCsIndex == 1)) { + if ((play->csCtx.state == 0) && (gSaveContext.sceneSetupIndex == 0) && (play->csCtx.currentCsIndex == 1)) { if (this->unk_261 != 42) { this->unk_261 = 42; - func_80AA5580(&this->skelAnime, &sAnimations[this->unk_261], 0); + func_80AA5580(&this->skelAnime, &sAnimationInfo[this->unk_261], 0); } Math_SmoothStepToF(&this->actor.world.pos.x, 0.0f, 0.5f, 0.5f, 0.001f); @@ -866,14 +865,14 @@ void func_80AA67F8(DmChar00* this, GlobalContext* globalCtx) { if (player->actor.world.pos.z < -625.0f) { this->unk_261 = 43; - func_80AA5580(&this->skelAnime, &sAnimations[this->unk_261], 0); + func_80AA5580(&this->skelAnime, &sAnimationInfo[this->unk_261], 0); this->actionFunc = func_80AA695C; this->skelAnime.playSpeed = 1.5f; } } } -void func_80AA695C(DmChar00* this, GlobalContext* globalCtx) { +void func_80AA695C(DmChar00* this, PlayState* play) { 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); @@ -881,50 +880,49 @@ void func_80AA695C(DmChar00* this, GlobalContext* globalCtx) { } } -void DmChar00_Update(Actor* thisx, GlobalContext* globalCtx) { +void DmChar00_Update(Actor* thisx, PlayState* play) { DmChar00* this = THIS; SkelAnime_Update(&this->skelAnime); - this->actionFunc(this, globalCtx); + this->actionFunc(this, play); this->unk_262++; - func_80AA5EBC(this, globalCtx); - func_80AA62FC(this, globalCtx); + func_80AA5EBC(this, play); + func_80AA62FC(this, play); } -s32 DmChar00_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, - Actor* thisx, Gfx** gfx) { +s32 DmChar00_OverrideLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, Actor* thisx, + Gfx** gfx) { DmChar00* this = THIS; f32 sp28; Vec3f sp1C; if (limbIndex == 6) { - sp28 = ((Math_SinS(this->unk_262 * 0x1000) * 0.1f) + 1.0f) * 0.012f * (this->actor.scale.x * 124.99999f); - Matrix_MultiplyVector3fByState(&D_80AA7808, &sp1C); - Matrix_InsertTranslation(sp1C.x, sp1C.y, sp1C.z, MTXMODE_NEW); + sp28 = ((Math_SinS(this->unk_262 * 0x1000) * 0.1f) + 1.0f) * 0.012f * (this->actor.scale.x * (1.0f / 0.008f)); + Matrix_MultVec3f(&D_80AA7808, &sp1C); + Matrix_Translate(sp1C.x, sp1C.y, sp1C.z, MTXMODE_NEW); Matrix_Scale(sp28, sp28, sp28, MTXMODE_APPLY); } return false; } -void DmChar00_Draw(Actor* thisx, GlobalContext* globalCtx2) { - GlobalContext* globalCtx = globalCtx2; +void DmChar00_Draw(Actor* thisx, PlayState* play2) { + PlayState* play = play2; DmChar00* this = THIS; s32 phi_a0; s32 pad; - Gfx* gfx = GRAPH_ALLOC(globalCtx->state.gfxCtx, sizeof(Gfx) * 4); + Gfx* gfx = GRAPH_ALLOC(play->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))) { + if ((play->csCtx.state == 0) && ((play->sceneNum != SCENE_OPENINGDAN) || (gSaveContext.sceneSetupIndex != 0) || + (play->roomCtx.currRoom.num != 0) || (play->csCtx.currentCsIndex != 1) || + (DMCHAR00_GET(&this->actor) != DMCHAR00_0))) { return; } - OPEN_DISPS(globalCtx->state.gfxCtx); + OPEN_DISPS(play->state.gfxCtx); - func_8012C94C(globalCtx->state.gfxCtx); + func_8012C94C(play->state.gfxCtx); do { phi_a0 = (this->unk_262 * 50) & 511; @@ -936,17 +934,17 @@ void DmChar00_Draw(Actor* thisx, GlobalContext* globalCtx2) { 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)); + gDPSetPrimColor(gfx++, 0, 0x01, (u8)this->unk_240.r, (u8)this->unk_240.g, (u8)this->unk_240.b, + (u8)(this->unk_240.a * 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)); + gDPSetEnvColor(POLY_XLU_DISP++, (u8)(s8)this->unk_250.r, (u8)(s8)this->unk_250.g, (u8)(s8)this->unk_250.b, + (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, + POLY_XLU_DISP = SkelAnime_Draw(play, this->skelAnime.skeleton, this->skelAnime.jointTable, DmChar00_OverrideLimbDraw, NULL, &this->actor, POLY_XLU_DISP); - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->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 52adfe794..1df0df06d 100644 --- a/src/overlays/actors/ovl_Dm_Char00/z_dm_char00.h +++ b/src/overlays/actors/ovl_Dm_Char00/z_dm_char00.h @@ -5,7 +5,7 @@ struct DmChar00; -typedef void (*DmChar00ActionFunc)(struct DmChar00*, GlobalContext*); +typedef void (*DmChar00ActionFunc)(struct DmChar00*, PlayState*); #define DMCHAR00_GET(thisx) ((thisx)->params) #define DMCHAR00_GET_F800(thisx) ((thisx)->params << 0xB) @@ -13,26 +13,19 @@ typedef void (*DmChar00ActionFunc)(struct DmChar00*, GlobalContext*); #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 */ SkelAnime skelAnime; - /* 0x0188 */ Vec3s jointTable[7]; - /* 0x01B2 */ UNK_TYPE1 unk_1B2[0x30]; - /* 0x01E2 */ Vec3s morphTable[7]; - /* 0x020C */ UNK_TYPE1 unk_20C[0x30]; - /* 0x023C */ DmChar00ActionFunc actionFunc; - /* 0x0240 */ DmChar00Struct unk_240; - /* 0x0250 */ DmChar00Struct unk_250; - /* 0x0260 */ u8 unk_260; - /* 0x0261 */ u8 unk_261; - /* 0x0262 */ u16 unk_262; + /* 0x000 */ Actor actor; + /* 0x144 */ SkelAnime skelAnime; + /* 0x188 */ Vec3s jointTable[7]; + /* 0x1B2 */ UNK_TYPE1 unk_1B2[0x30]; + /* 0x1E2 */ Vec3s morphTable[7]; + /* 0x20C */ UNK_TYPE1 unk_20C[0x30]; + /* 0x23C */ DmChar00ActionFunc actionFunc; + /* 0x240 */ Color_RGBAf unk_240; + /* 0x250 */ Color_RGBAf unk_250; + /* 0x260 */ u8 unk_260; + /* 0x261 */ u8 unk_261; + /* 0x262 */ u16 unk_262; } DmChar00; // size = 0x264 extern const ActorInit Dm_Char00_InitVars; diff --git a/src/overlays/actors/ovl_Dm_Char01/z_dm_char01.c b/src/overlays/actors/ovl_Dm_Char01/z_dm_char01.c index b4537b1af..8c1aebc96 100644 --- a/src/overlays/actors/ovl_Dm_Char01/z_dm_char01.c +++ b/src/overlays/actors/ovl_Dm_Char01/z_dm_char01.c @@ -6,26 +6,27 @@ #include "z_dm_char01.h" #include "objects/object_mtoride/object_mtoride.h" +#include "overlays/actors/ovl_Obj_Etcetera/z_obj_etcetera.h" #define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_20 | ACTOR_FLAG_2000000) #define THIS ((DmChar01*)thisx) -void DmChar01_Init(Actor* thisx, GlobalContext* globalCtx); -void DmChar01_Destroy(Actor* thisx, GlobalContext* globalCtx); -void DmChar01_Update(Actor* thisx, GlobalContext* globalCtx); -void DmChar01_Draw(Actor* thisx, GlobalContext* globalCtx); +void DmChar01_Init(Actor* thisx, PlayState* play); +void DmChar01_Destroy(Actor* thisx, PlayState* play); +void DmChar01_Update(Actor* thisx, PlayState* play); +void DmChar01_Draw(Actor* thisx, PlayState* play); -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); +void func_80AA8698(DmChar01* this, PlayState* play); +void func_80AA884C(DmChar01* this, PlayState* play); +void func_80AA88A8(DmChar01* this, PlayState* play); +void func_80AA892C(DmChar01* this, PlayState* play); +void func_80AA8C28(DmChar01* this, PlayState* play); +void func_80AA8F1C(DmChar01* this, PlayState* play); +void func_80AA8F2C(DmChar01* this, PlayState* play); +void func_80AA9020(DmChar01* this, PlayState* play); +void func_80AA90AC(DmChar01* this, PlayState* play); +void func_80AA90F4(DmChar01* this, PlayState* play); s16 D_80AAAE20; s16 D_80AAAE22; @@ -52,7 +53,7 @@ static InitChainEntry sInitChain[] = { s16 D_80AAAAB4 = false; -void DmChar01_Init(Actor* thisx, GlobalContext* globalCtx) { +void DmChar01_Init(Actor* thisx, PlayState* play) { DmChar01* this = THIS; s32 i; @@ -73,8 +74,8 @@ void DmChar01_Init(Actor* thisx, GlobalContext* globalCtx) { } if (gSaveContext.sceneSetupIndex == 0) { - globalCtx->envCtx.unk_1F = 5; - globalCtx->envCtx.unk_20 = 5; + play->envCtx.unk_1F = 5; + play->envCtx.unk_20 = 5; } this->unk_348 = 255.0f; @@ -83,7 +84,7 @@ void DmChar01_Init(Actor* thisx, GlobalContext* globalCtx) { } DynaPolyActor_Init(&this->dyna, 0); - DynaPolyActor_LoadMesh(globalCtx, &this->dyna, &object_mtoride_Colheader_009E4C); + DynaPolyActor_LoadMesh(play, &this->dyna, &object_mtoride_Colheader_009E4C); this->unk_34D = true; if (gSaveContext.sceneSetupIndex == 1) { @@ -113,7 +114,7 @@ void DmChar01_Init(Actor* thisx, GlobalContext* globalCtx) { 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); + DynaPolyActor_LoadMesh(play, &this->dyna, &object_mtoride_Colheader_010C3C); this->unk_34D = true; this->unk_348 = 200.0f; this->actionFunc = func_80AA8F2C; @@ -127,9 +128,10 @@ void DmChar01_Init(Actor* thisx, GlobalContext* globalCtx) { return; } - Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_OBJ_ETCETERA, 5.0f, 202.0f, 294.0f, 0, 0, 0, 0x80); + Actor_Spawn(&play->actorCtx, play, ACTOR_OBJ_ETCETERA, 5.0f, 202.0f, 294.0f, 0, 0, 0, + DEKU_FLOWER_PARAMS(DEKU_FLOWER_TYPE_PINK_WITH_INITIAL_BOUNCE)); DynaPolyActor_Init(&this->dyna, 0); - DynaPolyActor_LoadMesh(globalCtx, &this->dyna, &object_mtoride_Colheader_00FE5C); + DynaPolyActor_LoadMesh(play, &this->dyna, &object_mtoride_Colheader_00FE5C); this->unk_34D = true; if (!(gSaveContext.save.weekEventReg[20] & 2)) { @@ -146,17 +148,17 @@ void DmChar01_Init(Actor* thisx, GlobalContext* globalCtx) { } } -void DmChar01_Destroy(Actor* thisx, GlobalContext* globalCtx) { +void DmChar01_Destroy(Actor* thisx, PlayState* play) { DmChar01* this = THIS; if (this->unk_34D) { - DynaPoly_DeleteBgActor(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); + DynaPoly_DeleteBgActor(play, &play->colCtx.dyna, this->dyna.bgId); } } -void func_80AA8698(DmChar01* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); - Player* player2 = GET_PLAYER(globalCtx); +void func_80AA8698(DmChar01* this, PlayState* play) { + Player* player = GET_PLAYER(play); + Player* player2 = GET_PLAYER(play); if (gSaveContext.save.weekEventReg[20] & 1) { return; @@ -173,8 +175,8 @@ void func_80AA8698(DmChar01* this, GlobalContext* globalCtx) { D_80AAAAB4 = false; } - if ((player->transformation == PLAYER_FORM_DEKU) && (globalCtx->msgCtx.ocarinaMode == 3) && - (globalCtx->msgCtx.unk1202E == 0)) { + if ((player->transformation == PLAYER_FORM_DEKU) && (play->msgCtx.ocarinaMode == 3) && + (play->msgCtx.lastPlayedSong == OCARINA_SONG_SONATA)) { 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)) { @@ -184,7 +186,7 @@ void func_80AA8698(DmChar01* this, GlobalContext* globalCtx) { } } -void func_80AA884C(DmChar01* this, GlobalContext* globalCtx) { +void func_80AA884C(DmChar01* this, PlayState* play) { s16 sp1E = this->dyna.actor.cutscene; if (ActorCutscene_GetCanPlayNext(sp1E)) { @@ -195,10 +197,9 @@ void func_80AA884C(DmChar01* this, GlobalContext* globalCtx) { } } -void func_80AA88A8(DmChar01* this, GlobalContext* globalCtx) { - if (Cutscene_CheckActorAction(globalCtx, 135)) { - if (globalCtx->csCtx.frames == - globalCtx->csCtx.actorActions[Cutscene_GetActorActionIndex(globalCtx, 135)]->startFrame) { +void func_80AA88A8(DmChar01* this, PlayState* play) { + if (Cutscene_CheckActorAction(play, 135)) { + if (play->csCtx.frames == play->csCtx.actorActions[Cutscene_GetActorActionIndex(play, 135)]->startFrame) { D_80AAAE24 = 1; Actor_PlaySfxAtPos(&this->dyna.actor, NA_SE_EV_FORT_RISING); } @@ -207,7 +208,7 @@ void func_80AA88A8(DmChar01* this, GlobalContext* globalCtx) { } } -void func_80AA892C(DmChar01* this, GlobalContext* globalCtx) { +void func_80AA892C(DmChar01* this, PlayState* play) { f32 temp_f18; s32 temp_v0_4; s32 i; @@ -268,7 +269,7 @@ void func_80AA892C(DmChar01* this, GlobalContext* globalCtx) { } } -void func_80AA8C28(DmChar01* this, GlobalContext* globalCtx) { +void func_80AA8C28(DmChar01* this, PlayState* play) { f32 temp_f18; s32 temp_v0_4; s32 i; @@ -320,72 +321,73 @@ void func_80AA8C28(DmChar01* this, GlobalContext* globalCtx) { } } -void func_80AA8F0C(DmChar01* this, GlobalContext* globalCtx) { +void func_80AA8F0C(DmChar01* this, PlayState* play) { } -void func_80AA8F1C(DmChar01* this, GlobalContext* globalCtx) { +void func_80AA8F1C(DmChar01* this, PlayState* play) { } -void func_80AA8F2C(DmChar01* this, GlobalContext* globalCtx) { +void func_80AA8F2C(DmChar01* this, PlayState* play) { 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); + Actor_Spawn(&play->actorCtx, play, ACTOR_OBJ_ETCETERA, 5.0f, 202.0f, 294.0f, 0, 0, 0, + DEKU_FLOWER_PARAMS(DEKU_FLOWER_TYPE_PINK_WITH_INITIAL_BOUNCE)); this->actionFunc = func_80AA90F4; } } - func_80AA8F0C(this, globalCtx); + func_80AA8F0C(this, play); } -void func_80AA9020(DmChar01* this, GlobalContext* globalCtx) { - if (Cutscene_CheckActorAction(globalCtx, 135)) { - CsCmdActorAction* temp_v1 = globalCtx->csCtx.actorActions[Cutscene_GetActorActionIndex(globalCtx, 135)]; +void func_80AA9020(DmChar01* this, PlayState* play) { + if (Cutscene_CheckActorAction(play, 135)) { + CsCmdActorAction* temp_v1 = play->csCtx.actorActions[Cutscene_GetActorActionIndex(play, 135)]; - if ((temp_v1->startFrame == globalCtx->csCtx.frames) && (temp_v1->action == 2)) { + if ((temp_v1->startFrame == play->csCtx.frames) && (temp_v1->action == 2)) { gSaveContext.save.weekEventReg[20] |= 2; this->actionFunc = func_80AA90AC; } } } -void func_80AA90AC(DmChar01* this, GlobalContext* globalCtx) { +void func_80AA90AC(DmChar01* this, PlayState* play) { Math_SmoothStepToF(&this->dyna.actor.world.pos.y, 0.0f, 0.05f, 2.0f, 0.001f); } -void func_80AA90F4(DmChar01* this, GlobalContext* globalCtx) { +void func_80AA90F4(DmChar01* this, PlayState* play) { Math_SmoothStepToF(&this->unk_348, 0.0f, 0.02f, 0.8f, 0.4f); } -void DmChar01_Update(Actor* thisx, GlobalContext* globalCtx2) { - GlobalContext* globalCtx = globalCtx2; +void DmChar01_Update(Actor* thisx, PlayState* play2) { + PlayState* play = play2; DmChar01* this = THIS; - this->actionFunc(this, globalCtx); + this->actionFunc(this, play); if (this->unk_34D) { if (DMCHAR01_GET(&this->dyna.actor) == DMCHAR01_0) { - Player* player = GET_PLAYER(globalCtx); + Player* player = GET_PLAYER(play); if (player->actor.world.pos.y > 5.0f) { - func_800C62BC(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); + func_800C62BC(play, &play->colCtx.dyna, this->dyna.bgId); } else { - func_800C6314(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); + func_800C6314(play, &play->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); + func_800C62BC(play, &play->colCtx.dyna, this->dyna.bgId); } else { - func_800C6314(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); + func_800C6314(play, &play->colCtx.dyna, this->dyna.bgId); } } } } -void DmChar01_Draw(Actor* thisx, GlobalContext* globalCtx) { +void DmChar01_Draw(Actor* thisx, PlayState* play) { static f32 D_80AAAAB8 = 0.0f; static f32 D_80AAAABC = 0.0f; static s16 D_80AAAAC0 = 0; @@ -402,52 +404,52 @@ void DmChar01_Draw(Actor* thisx, GlobalContext* globalCtx) { 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); + AnimatedMat_Draw(play, Lib_SegmentedToVirtual(&object_mtoride_Matanimheader_00AA50)); + Gfx_DrawDListOpa(play, object_mtoride_DL_00A8F8); break; case 1: if (gSaveContext.sceneSetupIndex == 1) { - AnimatedMat_Draw(globalCtx, Lib_SegmentedToVirtual(&object_mtoride_Matanimheader_0110B8)); - Gfx_DrawDListOpa(globalCtx, object_mtoride_DL_010FD8); - Gfx_DrawDListXlu(globalCtx, object_mtoride_DL_010EF0); - Matrix_InsertTranslation(0.0f, 10.0f, 0.0f, MTXMODE_APPLY); + AnimatedMat_Draw(play, Lib_SegmentedToVirtual(&object_mtoride_Matanimheader_0110B8)); + Gfx_DrawDListOpa(play, object_mtoride_DL_010FD8); + Gfx_DrawDListXlu(play, object_mtoride_DL_010EF0); + Matrix_Translate(0.0f, 10.0f, 0.0f, MTXMODE_APPLY); } - AnimatedMat_Draw(globalCtx, Lib_SegmentedToVirtual(&object_mtoride_Matanimheader_009D70)); + AnimatedMat_Draw(play, Lib_SegmentedToVirtual(&object_mtoride_Matanimheader_009D70)); - OPEN_DISPS(globalCtx->state.gfxCtx); + OPEN_DISPS(play->state.gfxCtx); if ((u8)this->unk_348 == 255) { - func_8012C28C(globalCtx->state.gfxCtx); + func_8012C28C(play->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), + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(play->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); + func_8012C2DC(play->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), + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_XLU_DISP++, object_mtoride_DL_009928); } - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->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); + AnimatedMat_Draw(play, Lib_SegmentedToVirtual(&object_mtoride_Matanimheader_0110B8)); + Gfx_DrawDListOpa(play, object_mtoride_DL_010FD8); + Gfx_DrawDListXlu(play, object_mtoride_DL_010EF0); break; } break; @@ -455,36 +457,36 @@ void DmChar01_Draw(Actor* thisx, GlobalContext* globalCtx) { 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); + AnimatedMat_Draw(play, Lib_SegmentedToVirtual(&object_mtoride_Matanimheader_00A5C0)); + Gfx_DrawDListOpa(play, object_mtoride_DL_00A398); break; case 1: - AnimatedMat_Draw(globalCtx, Lib_SegmentedToVirtual(&object_mtoride_Matanimheader_00B1A0)); - Gfx_DrawDListOpa(globalCtx, object_mtoride_DL_00AF98); + AnimatedMat_Draw(play, Lib_SegmentedToVirtual(&object_mtoride_Matanimheader_00B1A0)); + Gfx_DrawDListOpa(play, 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); + AnimatedMat_Draw(play, Lib_SegmentedToVirtual(&object_mtoride_Matanimheader_00FE90)); + Gfx_DrawDListOpa(play, object_mtoride_DL_00DF18); if ((this->unk_34C != 0) && ((u8)this->unk_348 != 0)) { - AnimatedMat_Draw(globalCtx, Lib_SegmentedToVirtual(&object_mtoride_Matanimheader_00F768)); + AnimatedMat_Draw(play, Lib_SegmentedToVirtual(&object_mtoride_Matanimheader_00F768)); - OPEN_DISPS(globalCtx->state.gfxCtx); + OPEN_DISPS(play->state.gfxCtx); - func_8012C2DC(globalCtx->state.gfxCtx); + func_8012C2DC(play->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), + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_XLU_DISP++, object_mtoride_DL_00F3C0); - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->state.gfxCtx); } if (D_80AAAE24 != 0) { @@ -517,29 +519,29 @@ void DmChar01_Draw(Actor* thisx, GlobalContext* globalCtx) { s16 temp; spBC = Rand_ZeroOne() * D_80AAAAC8; - if ((globalCtx->state.frames % 2) != 0) { + if ((play->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); + EffectSsGSplash_Spawn(play, &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); + EffectSsGSplash_Spawn(play, &sp44, NULL, NULL, 0, temp); } } } } - Gfx_DrawDListXlu(globalCtx, object_mtoride_DL_00DE50); + Gfx_DrawDListXlu(play, object_mtoride_DL_00DE50); break; case DMCHAR01_3: if (thisx->world.pos.y > -120.0f) { - Gfx_DrawDListOpa(globalCtx, object_mtoride_DL_00FAE8); + Gfx_DrawDListOpa(play, 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 b2c235f56..677a2b59b 100644 --- a/src/overlays/actors/ovl_Dm_Char01/z_dm_char01.h +++ b/src/overlays/actors/ovl_Dm_Char01/z_dm_char01.h @@ -5,7 +5,7 @@ struct DmChar01; -typedef void (*DmChar01ActionFunc)(struct DmChar01*, GlobalContext*); +typedef void (*DmChar01ActionFunc)(struct DmChar01*, PlayState*); #define DMCHAR01_GET(thisx) ((thisx)->params) @@ -17,15 +17,15 @@ enum { }; typedef struct DmChar01 { - /* 0x0000 */ DynaPolyActor dyna; - /* 0x015C */ UNK_TYPE1 unk15C[0x44]; - /* 0x01A0 */ DmChar01ActionFunc actionFunc; - /* 0x01A4 */ UNK_TYPE1 unk1A4[0x8]; - /* 0x01AC */ s16 unk_1AC[205]; - /* 0x0346 */ s16 unk_346; - /* 0x0348 */ f32 unk_348; - /* 0x034C */ u8 unk_34C; - /* 0x034D */ u8 unk_34D; + /* 0x000 */ DynaPolyActor dyna; + /* 0x15C */ UNK_TYPE1 unk15C[0x44]; + /* 0x1A0 */ DmChar01ActionFunc actionFunc; + /* 0x1A4 */ UNK_TYPE1 unk1A4[0x8]; + /* 0x1AC */ s16 unk_1AC[205]; + /* 0x346 */ s16 unk_346; + /* 0x348 */ f32 unk_348; + /* 0x34C */ u8 unk_34C; + /* 0x34D */ u8 unk_34D; } DmChar01; // size = 0x350 extern const ActorInit Dm_Char01_InitVars; diff --git a/src/overlays/actors/ovl_Dm_Char02/z_dm_char02.c b/src/overlays/actors/ovl_Dm_Char02/z_dm_char02.c index 72258b70b..5a6695816 100644 --- a/src/overlays/actors/ovl_Dm_Char02/z_dm_char02.c +++ b/src/overlays/actors/ovl_Dm_Char02/z_dm_char02.c @@ -1,23 +1,23 @@ /* * File: z_dm_char02.c * Overlay: ovl_Dm_Char02 - * Description: Ocarina of Time (dropped from Skull Kid's hand) + * Description: The Ocarina of Time that for the scenes on the Clock Tower's rooftop. */ #include "z_dm_char02.h" +#include "objects/object_stk2/object_stk2.h" #define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_20) #define THIS ((DmChar02*)thisx) -void DmChar02_Init(Actor* thisx, GlobalContext* globalCtx); -void DmChar02_Destroy(Actor* thisx, GlobalContext* globalCtx); -void DmChar02_Update(Actor* thisx, GlobalContext* globalCtx); -void DmChar02_Draw(Actor* thisx, GlobalContext* globalCtx); +void DmChar02_Init(Actor* thisx, PlayState* play); +void DmChar02_Destroy(Actor* thisx, PlayState* play); +void DmChar02_Update(Actor* thisx, PlayState* play); +void DmChar02_Draw(Actor* thisx, PlayState* play); -void func_80AAB04C(DmChar02* this, GlobalContext* globalCtx); +void DmChar02_PerformCutsceneActions(DmChar02* this, PlayState* play); -#if 0 const ActorInit Dm_Char02_InitVars = { ACTOR_DM_CHAR02, ACTORCAT_ITEMACTION, @@ -28,30 +28,166 @@ const ActorInit Dm_Char02_InitVars = { (ActorFunc)DmChar02_Destroy, (ActorFunc)DmChar02_Update, (ActorFunc)DmChar02_Draw, + }; -#endif +typedef enum { + /* 0 */ DMCHAR02_ANIM_HIT_GROUND, + /* 1 */ DMCHAR02_ANIM_TURN_AROUND, + /* 2 */ DMCHAR02_ANIM_JUGGLE, + /* 3 */ DMCHAR02_ANIM_FALL, +} DmChar02Animation; -extern UNK_TYPE D_0600AD68; +static AnimationInfo sAnimationInfo[] = { + { &gClockTowerOcarinaOfTimeHitGroundAnim, 1.0f, 0.0f, -1.0f, ANIMMODE_ONCE, 0.0f }, + { &gClockTowerOcarinaOfTimeTurnAroundAnim, 1.0f, 0.0f, -1.0f, ANIMMODE_ONCE, 0.0f }, + { &gClockTowerOcarinaOfTimeJuggleAnim, 1.0f, 0.0f, -1.0f, ANIMMODE_LOOP, 0.0f }, + { &gClockTowerOcarinaOfTimeFallAnim, 1.0f, 0.0f, -1.0f, ANIMMODE_ONCE, 0.0f }, +}; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Char02/func_80AAAE30.s") +void DmChar02_ChangeAnim(SkelAnime* skelAnime, AnimationInfo* animationInfo, u16 animIndex) { + f32 frameCount; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Char02/func_80AAAECC.s") + animationInfo += animIndex; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Char02/func_80AAAF2C.s") + if (animationInfo->frameCount < 0.0f) { + frameCount = Animation_GetLastFrame(animationInfo->animation); + } else { + frameCount = animationInfo->frameCount; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Char02/DmChar02_Init.s") + Animation_Change(skelAnime, animationInfo->animation, animationInfo->playSpeed, animationInfo->startFrame, + frameCount, animationInfo->mode, animationInfo->morphFrames); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Char02/DmChar02_Destroy.s") +void DmChar02_PlaySfxForDroppingOcarinaCutscene(DmChar02* this, PlayState* play) { + switch (play->csCtx.frames) { + case 95: + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_OCARINA_BOUND_0); + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Char02/func_80AAB04C.s") + case 101: + case 105: + case 112: + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_OCARINA_BOUND_1); + break; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Char02/DmChar02_Update.s") +void DmChar02_PlaySfxForCutscenes(DmChar02* this, PlayState* play) { + if ((play->csCtx.state != 0) && (play->sceneNum == SCENE_OKUJOU) && (play->csCtx.currentCsIndex == 1)) { + DmChar02_PlaySfxForDroppingOcarinaCutscene(this, play); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Char02/func_80AAB23C.s") +void DmChar02_Init(Actor* thisx, PlayState* play) { + DmChar02* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Char02/func_80AAB258.s") + if (gSaveContext.save.inventory.items[SLOT_OCARINA] == ITEM_NONE) { + this->animIndex = DMCHAR02_ANIM_HIT_GROUND; + this->actor.targetArrowOffset = 3000.0f; + ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 24.0f); + SkelAnime_InitFlex(play, &this->skelAnime, &gClockTowerOcarinaOfTimeSkel, NULL, NULL, NULL, 0); + DmChar02_ChangeAnim(&this->skelAnime, sAnimationInfo, 0); + Actor_SetScale(&this->actor, 0.01f); + this->actionFunc = DmChar02_PerformCutsceneActions; + } else { + Actor_MarkForDeath(&this->actor); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Char02/func_80AAB270.s") +void DmChar02_Destroy(Actor* thisx, PlayState* play) { +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Char02/DmChar02_Draw.s") +void DmChar02_PerformCutsceneActions(DmChar02* this, PlayState* play) { + u8 shouldChangeAnimation = true; + s32 actionIndex; + + if (Cutscene_CheckActorAction(play, 0x83)) { + actionIndex = Cutscene_GetActorActionIndex(play, 0x83); + if (play->csCtx.frames == play->csCtx.actorActions[actionIndex]->startFrame) { + switch (play->csCtx.actorActions[actionIndex]->action) { + default: + this->animIndex = DMCHAR02_ANIM_HIT_GROUND; + shouldChangeAnimation = false; + break; + + case 1: + this->animIndex = DMCHAR02_ANIM_HIT_GROUND; + break; + + case 2: + this->animIndex = DMCHAR02_ANIM_TURN_AROUND; + break; + + case 4: + this->animIndex = DMCHAR02_ANIM_FALL; + break; + } + + if (shouldChangeAnimation) { + DmChar02_ChangeAnim(&this->skelAnime, &sAnimationInfo[this->animIndex], 0); + } + } + + Cutscene_ActorTranslateAndYaw(&this->actor, play, actionIndex); + } + + if (Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) { + if (this->animIndex == DMCHAR02_ANIM_TURN_AROUND) { + this->animIndex++; + DmChar02_ChangeAnim(&this->skelAnime, &sAnimationInfo[this->animIndex], 0); + } + } +} + +void DmChar02_Update(Actor* thisx, PlayState* play) { + DmChar02* this = THIS; + + SkelAnime_Update(&this->skelAnime); + this->unk_2F0 = this->unk_2F0; + this->actionFunc(this, play); + if (!Actor_HasParent(&this->actor, play)) { + Actor_PickUp(&this->actor, play, GI_OCARINA, 30.0f, 80.0f); + } else { + gSaveContext.save.playerForm = PLAYER_FORM_HUMAN; + Actor_MarkForDeath(&this->actor); + } + + DmChar02_PlaySfxForCutscenes(this, play); +} + +s32 DmChar02_OverrideLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, Actor* thisx) { + return false; +} + +void DmChar02_PostLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx) { +} + +void DmChar02_TransformLimbDraw(PlayState* play, s32 limbIndex, Actor* thisx) { +} + +void DmChar02_Draw(Actor* thisx, PlayState* play) { + s32 pad[2]; + DmChar02* this = THIS; + s32 shouldDraw = false; + + if ((play->csCtx.state == 0) && (this->actor.world.pos.y < 100.0f)) { + shouldDraw = true; + } else if (Cutscene_CheckActorAction(play, 0x6B)) { + switch (play->csCtx.actorActions[Cutscene_GetActorActionIndex(play, 0x6B)]->action) { + case 0x17: + case 0x1C: + case 0x26: + shouldDraw = true; + break; + } + } + + if (shouldDraw) { + func_8012C28C(play->state.gfxCtx); + SkelAnime_DrawTransformFlexOpa(play, this->skelAnime.skeleton, this->skelAnime.jointTable, + this->skelAnime.dListCount, DmChar02_OverrideLimbDraw, DmChar02_PostLimbDraw, + DmChar02_TransformLimbDraw, &this->actor); + } +} diff --git a/src/overlays/actors/ovl_Dm_Char02/z_dm_char02.h b/src/overlays/actors/ovl_Dm_Char02/z_dm_char02.h index 987e353bc..697989496 100644 --- a/src/overlays/actors/ovl_Dm_Char02/z_dm_char02.h +++ b/src/overlays/actors/ovl_Dm_Char02/z_dm_char02.h @@ -5,13 +5,17 @@ struct DmChar02; -typedef void (*DmChar02ActionFunc)(struct DmChar02*, GlobalContext*); +typedef void (*DmChar02ActionFunc)(struct DmChar02*, PlayState*); typedef struct DmChar02 { - /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x14C]; - /* 0x0290 */ DmChar02ActionFunc actionFunc; - /* 0x0294 */ char unk_294[0x60]; + /* 0x000 */ Actor actor; + /* 0x144 */ SkelAnime skelAnime; + /* 0x188 */ UNK_TYPE1 pad_188[0x108]; + /* 0x290 */ DmChar02ActionFunc actionFunc; + /* 0x294 */ UNK_TYPE1 pad_294[0x4C]; + /* 0x2E0 */ s16 animIndex; + /* 0x2E2 */ UNK_TYPE1 pad_2E2[0xE]; + /* 0x2F0 */ u32 unk_2F0; } DmChar02; // size = 0x2F4 extern const ActorInit Dm_Char02_InitVars; diff --git a/src/overlays/actors/ovl_Dm_Char03/z_dm_char03.c b/src/overlays/actors/ovl_Dm_Char03/z_dm_char03.c index 1508f95a2..397fbfa3c 100644 --- a/src/overlays/actors/ovl_Dm_Char03/z_dm_char03.c +++ b/src/overlays/actors/ovl_Dm_Char03/z_dm_char03.c @@ -1,25 +1,25 @@ /* * File: z_dm_char03.c * Overlay: ovl_Dm_Char03 - * Description: + * Description: Deku Mask (cutscene) */ #include "z_dm_char03.h" +#include "objects/object_osn/object_osn.h" #define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_20) #define THIS ((DmChar03*)thisx) -void DmChar03_Init(Actor* thisx, GlobalContext* globalCtx); -void DmChar03_Destroy(Actor* thisx, GlobalContext* globalCtx); -void DmChar03_Update(Actor* thisx, GlobalContext* globalCtx); -void DmChar03_Draw(Actor* thisx, GlobalContext* globalCtx); +void DmChar03_Init(Actor* thisx, PlayState* play); +void DmChar03_Destroy(Actor* thisx, PlayState* play); +void DmChar03_Update(Actor* thisx, PlayState* play); +void DmChar03_Draw(Actor* thisx, PlayState* play); -void func_80AAB5F8(DmChar03* this, GlobalContext* globalCtx); -void func_80AAB644(DmChar03* this, GlobalContext* globalCtx); -void func_80AAB700(DmChar03* this, GlobalContext* globalCtx); +void func_80AAB644(DmChar03* this, PlayState* play); +void DmChar03_DoNothing(DmChar03* this, PlayState* play); +void func_80AABA84(PlayState* play, DmChar03* this); -#if 0 const ActorInit Dm_Char03_InitVars = { ACTOR_DM_CHAR03, ACTORCAT_ITEMACTION, @@ -32,34 +32,157 @@ const ActorInit Dm_Char03_InitVars = { (ActorFunc)DmChar03_Draw, }; -#endif +AnimationInfo sAnimationInfo[] = { { &object_osn_Anim_020530, 1.0f, 0.0f, -1.0f, ANIMMODE_ONCE, 0.0f } }; -extern UNK_TYPE D_06020550; +void DmChar03_ChangeAnim(SkelAnime* skelAnime, AnimationInfo* animationInfo, u16 animIndex) { + f32 frame; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Char03/func_80AAB4A0.s") + animationInfo += animIndex; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Char03/DmChar03_Init.s") + if (animationInfo->frameCount < 0.0f) { + frame = Animation_GetLastFrame(animationInfo->animation); + } else { + frame = animationInfo->frameCount; + } + Animation_Change(skelAnime, animationInfo->animation, animationInfo->playSpeed, animationInfo->startFrame, frame, + animationInfo->mode, animationInfo->morphFrames); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Char03/DmChar03_Destroy.s") +void DmChar03_Init(Actor* thisx, PlayState* play) { + DmChar03* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Char03/func_80AAB5F8.s") + this->animIndex = 0; + this->actor.targetArrowOffset = 3000.0f; + this->unk_18E = false; + ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 24.0f); + SkelAnime_InitFlex(play, &this->skelAnime, &gDekuMaskSkel, NULL, NULL, NULL, 0); + DmChar03_ChangeAnim(&this->skelAnime, sAnimationInfo, 0); + Actor_SetScale(&this->actor, 0.01f); + this->actionFunc = DmChar03_DoNothing; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Char03/func_80AAB644.s") +void DmChar03_Destroy(Actor* thisx, PlayState* play) { +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Char03/func_80AAB700.s") +void func_80AAB5F8(DmChar03* this, PlayState* play) { + s32 index = Object_GetIndex(&play->objectCtx, OBJECT_GI_NUTSMASK); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Char03/func_80AAB710.s") + if (index >= 0) { + this->objectIndex = index; + this->actionFunc = func_80AAB644; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Char03/func_80AAB838.s") +void func_80AAB644(DmChar03* this, PlayState* play) { + if (Cutscene_CheckActorAction(play, 0x88)) { + s32 index = Cutscene_GetActorActionIndex(play, 0x88); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Char03/DmChar03_Update.s") + if (play->csCtx.actorActions[index]->action == 4) { + this->unk_18E = true; + this->offset.x = play->csCtx.actorActions[index]->startPos.x; + this->offset.y = play->csCtx.actorActions[index]->startPos.y; + this->offset.z = play->csCtx.actorActions[index]->startPos.z; + } + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Char03/func_80AAB974.s") +void DmChar03_DoNothing(DmChar03* this, PlayState* play) { +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Char03/func_80AAB990.s") +void func_80AAB710(DmChar03* this, PlayState* play) { + u8 shouldChangeAnim = true; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Char03/func_80AAB9A8.s") + if (Cutscene_CheckActorAction(play, 0x88)) { + s32 index = Cutscene_GetActorActionIndex(play, 0x88); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Char03/DmChar03_Draw.s") + if (play->csCtx.frames == play->csCtx.actorActions[index]->startFrame) { + switch (play->csCtx.actorActions[index]->action) { + case 1: + shouldChangeAnim = false; + break; + case 2: + this->animIndex = 0; + break; + case 3: + this->unk_18E = false; + shouldChangeAnim = false; + Actor_MarkForDeath(&this->actor); + break; + case 4: + Item_Give(play, ITEM_MASK_DEKU); + shouldChangeAnim = false; + this->actionFunc = func_80AAB5F8; + break; + default: + shouldChangeAnim = false; + break; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Char03/func_80AABA84.s") + if (shouldChangeAnim) { + DmChar03_ChangeAnim(&this->skelAnime, &sAnimationInfo[this->animIndex], 0); + } + } + Cutscene_ActorTranslateAndYaw(&this->actor, play, index); + } +} + +void func_80AAB838(DmChar03* this, PlayState* play) { + if (Animation_OnFrame(&this->skelAnime, 5.0f)) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_IT_MASK_BOUND_0); + } else if ((Animation_OnFrame(&this->skelAnime, 10.0f)) || (Animation_OnFrame(&this->skelAnime, 18.0f)) || + (Animation_OnFrame(&this->skelAnime, 30.0f)) || (Animation_OnFrame(&this->skelAnime, 38.0f))) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_IT_MASK_BOUND_1); + } +} + +void DmChar03_Update(Actor* thisx, PlayState* play) { + DmChar03* this = THIS; + + if (Cutscene_CheckActorAction(play, 0x88) && + (play->csCtx.actorActions[Cutscene_GetActorActionIndex(play, 0x88)]->action == 2)) { + SkelAnime_Update(&this->skelAnime); + } + this->actionFunc(this, play); + func_80AAB710(this, play); + func_80AAB838(this, play); +} + +s32 DmChar03_OverrideLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, Actor* thisx) { + return false; +} + +void DmChar03_PostLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx) { +} + +void DmChar03_TransformLimbDraw(PlayState* play, s32 limbIndex, Actor* thisx) { +} + +void DmChar03_Draw(Actor* thisx, PlayState* play) { + DmChar03* this = THIS; + + if (!this->unk_18E) { + if ((Cutscene_CheckActorAction(play, 0x88)) && + (play->csCtx.actorActions[Cutscene_GetActorActionIndex(play, 0x88)]->action != 1)) { + func_8012C28C(play->state.gfxCtx); + SkelAnime_DrawTransformFlexOpa(play, this->skelAnime.skeleton, this->skelAnime.jointTable, + this->skelAnime.dListCount, DmChar03_OverrideLimbDraw, DmChar03_PostLimbDraw, + DmChar03_TransformLimbDraw, &this->actor); + } + } else { + func_80AABA84(play, this); + } +} + +void func_80AABA84(PlayState* play, DmChar03* this) { + s32 pad; + + if (this->actor.objBankIndex == this->objectIndex) { + Matrix_Translate(this->offset.x, this->offset.y, this->offset.z, MTXMODE_NEW); + Matrix_RotateZYX(0, (play->gameplayFrames * 0x3E8), 0, MTXMODE_APPLY); + Matrix_Scale(0.2f, 0.2f, 0.2f, MTXMODE_APPLY); + GetItem_Draw(play, GID_MASK_DEKU); + } + if (Object_IsLoaded(&play->objectCtx, this->objectIndex)) { + this->actor.objBankIndex = this->objectIndex; + } +} diff --git a/src/overlays/actors/ovl_Dm_Char03/z_dm_char03.h b/src/overlays/actors/ovl_Dm_Char03/z_dm_char03.h index 95d7ee3a5..f736220c8 100644 --- a/src/overlays/actors/ovl_Dm_Char03/z_dm_char03.h +++ b/src/overlays/actors/ovl_Dm_Char03/z_dm_char03.h @@ -5,13 +5,16 @@ struct DmChar03; -typedef void (*DmChar03ActionFunc)(struct DmChar03*, GlobalContext*); +typedef void (*DmChar03ActionFunc)(struct DmChar03*, PlayState*); typedef struct DmChar03 { - /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x44]; - /* 0x0188 */ DmChar03ActionFunc actionFunc; - /* 0x018C */ char unk_18C[0x10]; + /* 0x000 */ Actor actor; + /* 0x144 */ SkelAnime skelAnime; + /* 0x188 */ DmChar03ActionFunc actionFunc; + /* 0x18C */ s16 animIndex; + /* 0x18E */ u8 unk_18E; + /* 0x18F */ u8 objectIndex; + /* 0x190 */ Vec3f offset; } DmChar03; // size = 0x19C extern const ActorInit Dm_Char03_InitVars; diff --git a/src/overlays/actors/ovl_Dm_Char04/z_dm_char04.c b/src/overlays/actors/ovl_Dm_Char04/z_dm_char04.c index eff96b7e5..f7b4b47e8 100644 --- a/src/overlays/actors/ovl_Dm_Char04/z_dm_char04.c +++ b/src/overlays/actors/ovl_Dm_Char04/z_dm_char04.c @@ -5,17 +5,19 @@ */ #include "z_dm_char04.h" +#include "objects/gameplay_keep/gameplay_keep.h" #define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_20) #define THIS ((DmChar04*)thisx) -void DmChar04_Init(Actor* thisx, GlobalContext* globalCtx); -void DmChar04_Destroy(Actor* thisx, GlobalContext* globalCtx); -void DmChar04_Update(Actor* thisx, GlobalContext* globalCtx); -void DmChar04_Draw(Actor* thisx, GlobalContext* globalCtx); +void DmChar04_Init(Actor* thisx, PlayState* play); +void DmChar04_Destroy(Actor* thisx, PlayState* play); +void DmChar04_Update(Actor* thisx, PlayState* play); +void DmChar04_Draw(Actor* thisx, PlayState* play); + +void func_80AABE34(DmChar04* this, PlayState* play); -#if 0 const ActorInit Dm_Char04_InitVars = { ACTOR_DM_CHAR04, ACTORCAT_ITEMACTION, @@ -28,18 +30,127 @@ const ActorInit Dm_Char04_InitVars = { (ActorFunc)DmChar04_Draw, }; -#endif +void DmChar04_ChangeAnim(SkelAnime* skelAnime, AnimationInfo* animation, u16 animIndex) { + f32 endFrame; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Char04/func_80AABC40.s") + animation += animIndex; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Char04/DmChar04_Init.s") + if (animation->frameCount < 0.0f) { + endFrame = Animation_GetLastFrame(animation->animation); + } else { + endFrame = animation->frameCount; + } + Animation_Change(skelAnime, animation->animation, animation->playSpeed, animation->startFrame, endFrame, + animation->mode, animation->morphFrames); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Char04/DmChar04_Destroy.s") +static AnimationInfo sAnimationInfo[] = { + { &gameplay_keep_Anim_02B2E8, 1.0f, 0.0f, -1.0f, ANIMMODE_LOOP, 0.0f }, + { &gameplay_keep_Anim_029140, 1.0f, 0.0f, -1.0f, ANIMMODE_LOOP, 0.0f }, +}; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Char04/func_80AABE34.s") +Color_RGBAf sPrimColors[] = { + { 250.0f, 255.0f, 230.0f, 255.0f }, + { 10.0f, 10.0f, 40.0f, 255.0f }, + { 255.0f, 235.0f, 220.0f, 255.0f }, +}; +Color_RGBAf sEnvColors[] = { + { 220.0f, 160.0f, 80.0f, 255.0f }, + { 120.0f, 255.0f, 255.0f, 255.0f }, + { 255.0f, 235.0f, 220.0f, 255.0f }, +}; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Char04/DmChar04_Update.s") +void DmChar04_Init(Actor* thisx, PlayState* play) { + DmChar04* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Char04/func_80AABF74.s") + this->primColors = sPrimColors[this->actor.params]; + this->envColors = sEnvColors[this->actor.params]; + this->actor.targetArrowOffset = 3000.0f; + this->csAction = 0x63; + this->timer = this->actor.params << 0xB; + ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 24.0f); + SkelAnime_Init(play, &this->skelAnime, &gameplay_keep_Skel_02AF58.sh, &gameplay_keep_Anim_029140, this->jointTable, + this->morphTable, 7); + ActorShape_Init(&this->actor.shape, 0.0f, NULL, 15.0f); + DmChar04_ChangeAnim(&this->skelAnime, sAnimationInfo, 0); + Actor_SetScale(&this->actor, 0.01f); + this->actionFunc = func_80AABE34; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Char04/DmChar04_Draw.s") +void DmChar04_Destroy(Actor* thisx, PlayState* play) { +} + +void func_80AABE34(DmChar04* this, PlayState* play) { + u16 params = this->actor.params + 0x71; + + if (Cutscene_CheckActorAction(play, params)) { + s32 actionIndex = Cutscene_GetActorActionIndex(play, params); + + if (play->csCtx.frames == play->csCtx.actorActions[actionIndex]->startFrame) { + if (this->csAction != play->csCtx.actorActions[actionIndex]->action) { + this->csAction = play->csCtx.actorActions[actionIndex]->action; + if (play->csCtx.actorActions[actionIndex]->action == 1) { + this->animIndex = 0; + } else { + this->animIndex = 0; + } + DmChar04_ChangeAnim(&this->skelAnime, &sAnimationInfo[this->animIndex], 0); + } + } + Cutscene_ActorTranslateAndYaw(&this->actor, play, actionIndex); + } else { + this->csAction = 0x63; + } +} + +void DmChar04_Update(Actor* thisx, PlayState* play) { + DmChar04* this = THIS; + + SkelAnime_Update(&this->skelAnime); + this->actionFunc(this, play); + this->timer++; +} +static Vec3f D_80AAC4F0 = { 0.0f, 0.0f, 0.0f }; + +s32 DmChar04_OverrideLimbDraw(PlayState* play2, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, Actor* thisx, + Gfx** gfx) { + PlayState* play = play2; + f32 sp28; + Vec3f sp1C; + DmChar04* this = THIS; + + if (limbIndex == 6) { + sp28 = ((Math_SinS(this->timer << 0xC) * 0.1f) + 1.0f) * 0.012f * (this->actor.scale.x * (1.0f / 0.008f)); + Matrix_MultVec3f(&D_80AAC4F0, &sp1C); + Matrix_Translate(sp1C.x, sp1C.y, sp1C.z, MTXMODE_NEW); + Matrix_Scale(sp28, sp28, sp28, MTXMODE_APPLY); + } + return false; +} + +void DmChar04_Draw(Actor* thisx, PlayState* play) { + Gfx* gfx = GRAPH_ALLOC(play->state.gfxCtx, sizeof(Gfx) * 4); + s32 alpha; + s32 pad; + DmChar04* this = THIS; + + OPEN_DISPS(play->state.gfxCtx); + + func_8012C94C(play->state.gfxCtx); + alpha = (this->timer * 50) & 0x1FF; + if (alpha > 255) { + alpha = 511 - alpha; + } + gSPSegment(POLY_XLU_DISP++, 0x08, &gfx[0]); + gDPPipeSync(gfx++); + gDPSetPrimColor(gfx++, 0, 0x01, (u8)this->primColors.r, (u8)this->primColors.g, (u8)this->primColors.b, + (u8)(this->primColors.a * 1)); + gDPSetRenderMode(gfx++, G_RM_PASS, G_RM_ZB_CLD_SURF2); + gSPEndDisplayList(gfx); + gDPSetEnvColor(POLY_XLU_DISP++, (u8)(s8)this->envColors.r, (u8)(s8)this->envColors.g, (u8)(s8)this->envColors.b, + (u8)(s8)((f32)alpha * 1)); + gDPSetDither(POLY_XLU_DISP++, G_CD_BAYER); + POLY_XLU_DISP = SkelAnime_Draw(play, this->skelAnime.skeleton, this->skelAnime.jointTable, + DmChar04_OverrideLimbDraw, NULL, &this->actor, POLY_XLU_DISP); + CLOSE_DISPS(play->state.gfxCtx); +} diff --git a/src/overlays/actors/ovl_Dm_Char04/z_dm_char04.h b/src/overlays/actors/ovl_Dm_Char04/z_dm_char04.h index cb2fa75de..42c4a8501 100644 --- a/src/overlays/actors/ovl_Dm_Char04/z_dm_char04.h +++ b/src/overlays/actors/ovl_Dm_Char04/z_dm_char04.h @@ -5,13 +5,19 @@ struct DmChar04; -typedef void (*DmChar04ActionFunc)(struct DmChar04*, GlobalContext*); +typedef void (*DmChar04ActionFunc)(struct DmChar04*, PlayState*); typedef struct DmChar04 { /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0xF8]; + /* 0x144 */ SkelAnime skelAnime; + /* 0x188 */ Vec3s jointTable[15]; + /* 0x1E2 */ Vec3s morphTable[15]; /* 0x023C */ DmChar04ActionFunc actionFunc; - /* 0x0240 */ char unk_240[0x24]; + /* 0x240 */ Color_RGBAf primColors; + /* 0x250 */ Color_RGBAf envColors; + /* 0x260 */ u8 csAction; + /* 0x261 */ u8 animIndex; + /* 0x262 */ u16 timer; } DmChar04; // size = 0x264 extern const ActorInit Dm_Char04_InitVars; diff --git a/src/overlays/actors/ovl_Dm_Char05/z_dm_char05.c b/src/overlays/actors/ovl_Dm_Char05/z_dm_char05.c index 956f7317c..44e5732ad 100644 --- a/src/overlays/actors/ovl_Dm_Char05/z_dm_char05.c +++ b/src/overlays/actors/ovl_Dm_Char05/z_dm_char05.c @@ -11,29 +11,29 @@ #define THIS ((DmChar05*)thisx) -void DmChar05_Init(Actor* thisx, GlobalContext* globalCtx); -void DmChar05_Destroy(Actor* thisx, GlobalContext* globalCtx); -void DmChar05_Update(Actor* thisx, GlobalContext* globalCtx); -void DmChar05_Draw(Actor* thisx, GlobalContext* globalCtx); +void DmChar05_Init(Actor* thisx, PlayState* play); +void DmChar05_Destroy(Actor* thisx, PlayState* play); +void DmChar05_Update(Actor* thisx, PlayState* play); +void DmChar05_Draw(Actor* thisx, PlayState* play); -void func_80AAC990(DmChar05* this, GlobalContext* globalCtx); -void func_80AAC9DC(DmChar05* this, GlobalContext* globalCtx); -void func_80AACA98(DmChar05* this, GlobalContext* globalCtx); -void func_80AACAE4(DmChar05* this, GlobalContext* globalCtx); -void func_80AACBE4(DmChar05* this, GlobalContext* globalCtx); -void func_80AACC48(DmChar05* this, GlobalContext* globalCtx); -void func_80AACC6C(DmChar05* this, GlobalContext* globalCtx); -void func_80AACCD4(DmChar05* this, GlobalContext* globalCtx); -void func_80AACD0C(DmChar05* this, GlobalContext* globalCtx); -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); +void func_80AAC990(DmChar05* this, PlayState* play); +void func_80AAC9DC(DmChar05* this, PlayState* play); +void func_80AACA98(DmChar05* this, PlayState* play); +void func_80AACAE4(DmChar05* this, PlayState* play); +void func_80AACBE4(DmChar05* this, PlayState* play); +void func_80AACC48(DmChar05* this, PlayState* play); +void func_80AACC6C(DmChar05* this, PlayState* play); +void func_80AACCD4(DmChar05* this, PlayState* play); +void func_80AACD0C(DmChar05* this, PlayState* play); +void func_80AACD1C(DmChar05* this, PlayState* play); +void func_80AACD68(DmChar05* this, PlayState* play); +void func_80AACE10(DmChar05* this, PlayState* play); +void func_80AACE5C(DmChar05* this, PlayState* play); +void func_80AADD9C(PlayState* play, DmChar05* this); +void func_80AADE78(PlayState* play, DmChar05* this); +void func_80AADF54(PlayState* play, DmChar05* this); +void func_80AAE030(PlayState* play, DmChar05* this); +void func_80AAE114(PlayState* play, DmChar05* this); const ActorInit Dm_Char05_InitVars = { ACTOR_DM_CHAR05, @@ -47,7 +47,7 @@ const ActorInit Dm_Char05_InitVars = { (ActorFunc)DmChar05_Draw, }; -static AnimationInfo sAnimations[] = { +static AnimationInfo sAnimationInfo[] = { { &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 }, @@ -70,53 +70,53 @@ void func_80AAC5A0(SkelAnime* skelAnime, AnimationInfo* animation, u16 arg2) { animation->mode, animation->morphFrames); } -void func_80AAC63C(Actor* thisx, GlobalContext* globalCtx) { +void func_80AAC63C(Actor* thisx, PlayState* play) { DmChar05* this = THIS; ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 24.0f); - SkelAnime_Init(globalCtx, &this->skelAnime, &object_dmask_Skel_010B0, NULL, NULL, NULL, 0); + SkelAnime_Init(play, &this->skelAnime, &object_dmask_Skel_010B0, NULL, NULL, NULL, 0); if (DMCHAR05_GET(&this->actor) == DMCHAR05_0) { - func_80AAC5A0(&this->skelAnime, &sAnimations[0], 0); + func_80AAC5A0(&this->skelAnime, &sAnimationInfo[0], 0); } else { - func_80AAC5A0(&this->skelAnime, &sAnimations[1], 0); + func_80AAC5A0(&this->skelAnime, &sAnimationInfo[1], 0); } this->actionFunc = func_80AACC48; } -void func_80AAC6E4(Actor* thisx, GlobalContext* globalCtx) { +void func_80AAC6E4(Actor* thisx, PlayState* play) { DmChar05* this = THIS; 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); + SkelAnime_Init(play, &this->skelAnime, &object_dmask_Skel_042B0, NULL, NULL, NULL, 0); + func_80AAC5A0(&this->skelAnime, &sAnimationInfo[1], 0); this->actionFunc = func_80AACC48; } -void func_80AAC770(Actor* thisx, GlobalContext* globalCtx) { +void func_80AAC770(Actor* thisx, PlayState* play) { DmChar05* this = THIS; 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); + SkelAnime_InitFlex(play, &this->skelAnime, &object_dmask_Skel_001D0, NULL, NULL, NULL, 0); + func_80AAC5A0(&this->skelAnime, &sAnimationInfo[3], 0); this->actionFunc = func_80AACC48; } -void func_80AAC7FC(Actor* thisx, GlobalContext* globalCtx) { +void func_80AAC7FC(Actor* thisx, PlayState* play) { DmChar05* this = THIS; 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); + SkelAnime_Init(play, &this->skelAnime, &object_dmask_Skel_013D0, NULL, NULL, NULL, 0); + func_80AAC5A0(&this->skelAnime, &sAnimationInfo[4], 0); this->actionFunc = func_80AACC48; } -void func_80AAC888(Actor* thisx, GlobalContext* globalCtx) { +void func_80AAC888(Actor* thisx, PlayState* play) { DmChar05* this = THIS; this->actionFunc = func_80AACA98; } -void DmChar05_Init(Actor* thisx, GlobalContext* globalCtx) { +void DmChar05_Init(Actor* thisx, PlayState* play) { DmChar05* this = THIS; this->unk_18C = 0; @@ -131,23 +131,23 @@ void DmChar05_Init(Actor* thisx, GlobalContext* globalCtx) { switch (DMCHAR05_GET(&this->actor)) { case DMCHAR05_0: - func_80AAC63C(thisx, globalCtx); + func_80AAC63C(thisx, play); break; case DMCHAR05_1: - func_80AAC6E4(thisx, globalCtx); + func_80AAC6E4(thisx, play); break; case DMCHAR05_2: - func_80AAC770(thisx, globalCtx); + func_80AAC770(thisx, play); break; case DMCHAR05_3: - func_80AAC7FC(thisx, globalCtx); + func_80AAC7FC(thisx, play); break; case DMCHAR05_4: - func_80AAC888(thisx, globalCtx); + func_80AAC888(thisx, play); break; case DMCHAR05_5: @@ -164,11 +164,11 @@ void DmChar05_Init(Actor* thisx, GlobalContext* globalCtx) { Actor_SetScale(&this->actor, 0.01f); } -void DmChar05_Destroy(Actor* thisx, GlobalContext* globalCtx) { +void DmChar05_Destroy(Actor* thisx, PlayState* play) { } -void func_80AAC990(DmChar05* this, GlobalContext* globalCtx) { - s32 objectIdx = Object_GetIndex(&globalCtx->objectCtx, OBJECT_GI_GOLONMASK); +void func_80AAC990(DmChar05* this, PlayState* play) { + s32 objectIdx = Object_GetIndex(&play->objectCtx, OBJECT_GI_GOLONMASK); if (objectIdx >= 0) { this->unk_18F = objectIdx; @@ -176,21 +176,21 @@ void func_80AAC990(DmChar05* this, GlobalContext* globalCtx) { } } -void func_80AAC9DC(DmChar05* this, GlobalContext* globalCtx) { - if (Cutscene_CheckActorAction(globalCtx, 109) != 0) { - s32 actionIndex = Cutscene_GetActorActionIndex(globalCtx, 109); +void func_80AAC9DC(DmChar05* this, PlayState* play) { + if (Cutscene_CheckActorAction(play, 109) != 0) { + s32 actionIndex = Cutscene_GetActorActionIndex(play, 109); - if (globalCtx->csCtx.actorActions[actionIndex]->action == 4) { + if (play->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; + this->unk_190.x = play->csCtx.actorActions[actionIndex]->startPos.x; + this->unk_190.y = play->csCtx.actorActions[actionIndex]->startPos.y; + this->unk_190.z = play->csCtx.actorActions[actionIndex]->startPos.z; } } } -void func_80AACA98(DmChar05* this, GlobalContext* globalCtx) { - s32 objectIdx = Object_GetIndex(&globalCtx->objectCtx, OBJECT_GI_MASK13); +void func_80AACA98(DmChar05* this, PlayState* play) { + s32 objectIdx = Object_GetIndex(&play->objectCtx, OBJECT_GI_MASK13); if (objectIdx >= 0) { this->unk_18F = objectIdx; @@ -198,31 +198,31 @@ void func_80AACA98(DmChar05* this, GlobalContext* globalCtx) { } } -void func_80AACAE4(DmChar05* this, GlobalContext* globalCtx) { - if (Cutscene_CheckActorAction(globalCtx, 564)) { - s32 actionIndex = Cutscene_GetActorActionIndex(globalCtx, 564); +void func_80AACAE4(DmChar05* this, PlayState* play) { + if (Cutscene_CheckActorAction(play, 564)) { + s32 actionIndex = Cutscene_GetActorActionIndex(play, 564); - if (globalCtx->csCtx.actorActions[actionIndex]->action == 2) { - if (globalCtx->csCtx.frames == globalCtx->csCtx.actorActions[actionIndex]->startFrame) { - Item_Give(globalCtx, ITEM_MASK_COUPLE); + if (play->csCtx.actorActions[actionIndex]->action == 2) { + if (play->csCtx.frames == play->csCtx.actorActions[actionIndex]->startFrame) { + Item_Give(play, 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; + this->unk_190.x = play->csCtx.actorActions[actionIndex]->startPos.x; + this->unk_190.y = play->csCtx.actorActions[actionIndex]->startPos.y; + this->unk_190.z = play->csCtx.actorActions[actionIndex]->startPos.z; } else { this->unk_18E = 0; } } } -void func_80AACBE4(DmChar05* this, GlobalContext* globalCtx) { +void func_80AACBE4(DmChar05* this, PlayState* play) { 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]); + s32 objectIdx = Object_GetIndex(&play->objectCtx, D_80AAE2F0[params]); if (objectIdx >= 0) { this->unk_18F = objectIdx; @@ -230,13 +230,13 @@ void func_80AACBE4(DmChar05* this, GlobalContext* globalCtx) { } } -void func_80AACC48(DmChar05* this, GlobalContext* globalCtx) { +void func_80AACC48(DmChar05* this, PlayState* play) { if (this->unk_1B4 != 0) { this->actionFunc = func_80AACC6C; } } -void func_80AACC6C(DmChar05* this, GlobalContext* globalCtx) { +void func_80AACC6C(DmChar05* this, PlayState* play) { if (this->unk_19C < 247) { this->unk_19C += 8; } @@ -255,7 +255,7 @@ void func_80AACC6C(DmChar05* this, GlobalContext* globalCtx) { } } -void func_80AACCD4(DmChar05* this, GlobalContext* globalCtx) { +void func_80AACCD4(DmChar05* this, PlayState* play) { if (this->unk_1AC < 975) { this->unk_1AC += 25; } else { @@ -264,11 +264,11 @@ void func_80AACCD4(DmChar05* this, GlobalContext* globalCtx) { } } -void func_80AACD0C(DmChar05* this, GlobalContext* globalCtx) { +void func_80AACD0C(DmChar05* this, PlayState* play) { } -void func_80AACD1C(DmChar05* this, GlobalContext* globalCtx) { - s32 objectIdx = Object_GetIndex(&globalCtx->objectCtx, OBJECT_GI_ZORAMASK); +void func_80AACD1C(DmChar05* this, PlayState* play) { + s32 objectIdx = Object_GetIndex(&play->objectCtx, OBJECT_GI_ZORAMASK); if (objectIdx >= 0) { this->unk_18F = objectIdx; @@ -276,19 +276,19 @@ void func_80AACD1C(DmChar05* this, GlobalContext* globalCtx) { } } -void func_80AACD68(DmChar05* this, GlobalContext* globalCtx) { - if (Cutscene_CheckActorAction(globalCtx, 473)) { - s32 actionIndex = Cutscene_GetActorActionIndex(globalCtx, 473); +void func_80AACD68(DmChar05* this, PlayState* play) { + if (Cutscene_CheckActorAction(play, 473)) { + s32 actionIndex = Cutscene_GetActorActionIndex(play, 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; + this->unk_190.x = play->csCtx.actorActions[actionIndex]->startPos.x; + this->unk_190.y = play->csCtx.actorActions[actionIndex]->startPos.y; + this->unk_190.z = play->csCtx.actorActions[actionIndex]->startPos.z; } } -void func_80AACE10(DmChar05* this, GlobalContext* globalCtx) { - s32 objectIdx = Object_GetIndex(&globalCtx->objectCtx, OBJECT_GI_MASK15); +void func_80AACE10(DmChar05* this, PlayState* play) { + s32 objectIdx = Object_GetIndex(&play->objectCtx, OBJECT_GI_MASK15); if (objectIdx >= 0) { this->unk_18F = objectIdx; @@ -296,28 +296,28 @@ void func_80AACE10(DmChar05* this, GlobalContext* globalCtx) { } } -void func_80AACE5C(DmChar05* this, GlobalContext* globalCtx) { - if (Cutscene_CheckActorAction(globalCtx, 518)) { - s32 actionIndex = Cutscene_GetActorActionIndex(globalCtx, 518); +void func_80AACE5C(DmChar05* this, PlayState* play) { + if (Cutscene_CheckActorAction(play, 518)) { + s32 actionIndex = Cutscene_GetActorActionIndex(play, 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; + this->unk_190.x = play->csCtx.actorActions[actionIndex]->startPos.x; + this->unk_190.y = play->csCtx.actorActions[actionIndex]->startPos.y; + this->unk_190.z = play->csCtx.actorActions[actionIndex]->startPos.z; } } -void func_80AACF04(DmChar05* this, GlobalContext* globalCtx) { +void func_80AACF04(DmChar05* this, PlayState* play) { u8 sp2F = true; s32 actionIndex; switch (DMCHAR05_GET(&this->actor)) { case DMCHAR05_0: - if (Cutscene_CheckActorAction(globalCtx, 109)) { - actionIndex = Cutscene_GetActorActionIndex(globalCtx, 109); + if (Cutscene_CheckActorAction(play, 109)) { + actionIndex = Cutscene_GetActorActionIndex(play, 109); - if (globalCtx->csCtx.frames == globalCtx->csCtx.actorActions[actionIndex]->startFrame) { - switch (globalCtx->csCtx.actorActions[actionIndex]->action) { + if (play->csCtx.frames == play->csCtx.actorActions[actionIndex]->startFrame) { + switch (play->csCtx.actorActions[actionIndex]->action) { case 1: sp2F = false; break; @@ -331,7 +331,7 @@ void func_80AACF04(DmChar05* this, GlobalContext* globalCtx) { break; case 4: - Item_Give(globalCtx, ITEM_MASK_GORON); + Item_Give(play, ITEM_MASK_GORON); sp2F = false; this->actionFunc = func_80AAC990; break; @@ -347,20 +347,20 @@ void func_80AACF04(DmChar05* this, GlobalContext* globalCtx) { } if (sp2F) { - func_80AAC5A0(&this->skelAnime, &sAnimations[this->unk_18C], 0); + func_80AAC5A0(&this->skelAnime, &sAnimationInfo[this->unk_18C], 0); } } - Cutscene_ActorTranslateAndYaw(&this->actor, globalCtx, actionIndex); + Cutscene_ActorTranslateAndYaw(&this->actor, play, actionIndex); } break; case DMCHAR05_1: - if (Cutscene_CheckActorAction(globalCtx, 473)) { - actionIndex = Cutscene_GetActorActionIndex(globalCtx, 473); + if (Cutscene_CheckActorAction(play, 473)) { + actionIndex = Cutscene_GetActorActionIndex(play, 473); - if (globalCtx->csCtx.frames == globalCtx->csCtx.actorActions[actionIndex]->startFrame) { - switch (globalCtx->csCtx.actorActions[actionIndex]->action) { + if (play->csCtx.frames == play->csCtx.actorActions[actionIndex]->startFrame) { + switch (play->csCtx.actorActions[actionIndex]->action) { case 1: sp2F = false; break; @@ -375,7 +375,7 @@ void func_80AACF04(DmChar05* this, GlobalContext* globalCtx) { break; case 4: - Item_Give(globalCtx, ITEM_MASK_ZORA); + Item_Give(play, ITEM_MASK_ZORA); sp2F = false; this->actionFunc = func_80AACD1C; break; @@ -391,20 +391,20 @@ void func_80AACF04(DmChar05* this, GlobalContext* globalCtx) { } if (sp2F) { - func_80AAC5A0(&this->skelAnime, &sAnimations[this->unk_18C], 0); + func_80AAC5A0(&this->skelAnime, &sAnimationInfo[this->unk_18C], 0); } } - Cutscene_ActorTranslateAndYaw(&this->actor, globalCtx, actionIndex); + Cutscene_ActorTranslateAndYaw(&this->actor, play, actionIndex); } break; case DMCHAR05_2: - if (Cutscene_CheckActorAction(globalCtx, 518)) { - actionIndex = Cutscene_GetActorActionIndex(globalCtx, 518); + if (Cutscene_CheckActorAction(play, 518)) { + actionIndex = Cutscene_GetActorActionIndex(play, 518); - if (globalCtx->csCtx.frames == globalCtx->csCtx.actorActions[actionIndex]->startFrame) { - switch (globalCtx->csCtx.actorActions[actionIndex]->action) { + if (play->csCtx.frames == play->csCtx.actorActions[actionIndex]->startFrame) { + switch (play->csCtx.actorActions[actionIndex]->action) { case 1: sp2F = false; break; @@ -418,7 +418,7 @@ void func_80AACF04(DmChar05* this, GlobalContext* globalCtx) { break; case 4: - Item_Give(globalCtx, ITEM_MASK_GIBDO); + Item_Give(play, ITEM_MASK_GIBDO); sp2F = false; this->actionFunc = func_80AACE10; break; @@ -434,20 +434,20 @@ void func_80AACF04(DmChar05* this, GlobalContext* globalCtx) { } if (sp2F) { - func_80AAC5A0(&this->skelAnime, &sAnimations[this->unk_18C], 0); + func_80AAC5A0(&this->skelAnime, &sAnimationInfo[this->unk_18C], 0); } } - Cutscene_ActorTranslateAndYaw(&this->actor, globalCtx, actionIndex); + Cutscene_ActorTranslateAndYaw(&this->actor, play, actionIndex); } break; case DMCHAR05_3: - if (Cutscene_CheckActorAction(globalCtx, 559)) { - actionIndex = Cutscene_GetActorActionIndex(globalCtx, 559); + if (Cutscene_CheckActorAction(play, 559)) { + actionIndex = Cutscene_GetActorActionIndex(play, 559); - if (globalCtx->csCtx.frames == globalCtx->csCtx.actorActions[actionIndex]->startFrame) { - switch (globalCtx->csCtx.actorActions[actionIndex]->action) { + if (play->csCtx.frames == play->csCtx.actorActions[actionIndex]->startFrame) { + switch (play->csCtx.actorActions[actionIndex]->action) { default: sp2F = false; break; @@ -470,51 +470,51 @@ void func_80AACF04(DmChar05* this, GlobalContext* globalCtx) { } if (sp2F) { - func_80AAC5A0(&this->skelAnime, &sAnimations[this->unk_18C], 0); + func_80AAC5A0(&this->skelAnime, &sAnimationInfo[this->unk_18C], 0); } } - if (globalCtx->csCtx.actorActions[actionIndex]->action != 4) { - Cutscene_ActorTranslateAndYaw(&this->actor, globalCtx, actionIndex); + if (play->csCtx.actorActions[actionIndex]->action != 4) { + Cutscene_ActorTranslateAndYaw(&this->actor, play, actionIndex); } else { - Cutscene_ActorTranslate(&this->actor, globalCtx, actionIndex); + Cutscene_ActorTranslate(&this->actor, play, 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); + func_80AAC5A0(&this->skelAnime, &sAnimationInfo[this->unk_18C], 0); } } break; } } -void func_80AAD3F8(DmChar05* this, GlobalContext* globalCtx) { - if (globalCtx->csCtx.frames == 490) { +void func_80AAD3F8(DmChar05* this, PlayState* play) { + if (play->csCtx.frames == 490) { Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_EVIL_POWER); } - if (globalCtx->csCtx.frames > 550) { + if (play->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) { +void func_80AAD450(DmChar05* this, PlayState* play) { + if (play->csCtx.frames == 262) { Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_EVIL_POWER); } - if (globalCtx->csCtx.frames > 318) { + if (play->csCtx.frames > 318) { Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_MASK_FLOAT - SFX_FLAG); } } -void func_80AAD4A8(DmChar05* this, GlobalContext* globalCtx) { +void func_80AAD4A8(DmChar05* this, PlayState* play) { if (DMCHAR05_GET(&this->actor) == DMCHAR05_0) { - if (Cutscene_CheckActorAction(globalCtx, 109) && - (globalCtx->csCtx.actorActions[Cutscene_GetActorActionIndex(globalCtx, 109)]->action == 3)) { + if (Cutscene_CheckActorAction(play, 109) && + (play->csCtx.actorActions[Cutscene_GetActorActionIndex(play, 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)) { @@ -522,15 +522,15 @@ void func_80AAD4A8(DmChar05* this, GlobalContext* globalCtx) { } } } else if (DMCHAR05_GET(&this->actor) == DMCHAR05_1) { - if (Cutscene_CheckActorAction(globalCtx, 473)) { - if ((globalCtx->csCtx.actorActions[Cutscene_GetActorActionIndex(globalCtx, 473)]->action == 3) && + if (Cutscene_CheckActorAction(play, 473)) { + if ((play->csCtx.actorActions[Cutscene_GetActorActionIndex(play, 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 (Cutscene_CheckActorAction(play, 518) && + (play->csCtx.actorActions[Cutscene_GetActorActionIndex(play, 518)]->action == 2)) { if (Animation_OnFrame(&this->skelAnime, 7.0f)) { Actor_PlaySfxAtPos(&this->actor, NA_SE_IT_MASK_BOUND_0); } @@ -544,161 +544,160 @@ void func_80AAD4A8(DmChar05* this, GlobalContext* globalCtx) { } } } else if (DMCHAR05_GET(&this->actor) == DMCHAR05_3) { - if (globalCtx->sceneNum == SCENE_OKUJOU) { + if (play->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); + if (play->csCtx.currentCsIndex == 0) { + func_80AAD3F8(this, play); + } else if (play->csCtx.currentCsIndex == 1) { + func_80AAD450(this, play); } } - } else if (globalCtx->sceneNum == SCENE_SPOT00) { + } else if (play->sceneNum == SCENE_SPOT00) { if (gSaveContext.sceneSetupIndex == 9) { - if ((globalCtx->csCtx.currentCsIndex == 0) && (globalCtx->csCtx.frames == 255)) { + if ((play->csCtx.currentCsIndex == 0) && (play->csCtx.frames == 255)) { Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_EVIL_POWER); } - } else if ((gSaveContext.sceneSetupIndex == 0xB) && (globalCtx->csCtx.frames == 115)) { + } else if ((gSaveContext.sceneSetupIndex == 0xB) && (play->csCtx.frames == 115)) { Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_EVIL_POWER_PREDEMO); } } } } -void DmChar05_Update(Actor* thisx, GlobalContext* globalCtx) { +void DmChar05_Update(Actor* thisx, PlayState* play) { DmChar05* this = THIS; - func_80AACF04(this, globalCtx); - if (Cutscene_CheckActorAction(globalCtx, 109)) { - if (globalCtx->csCtx.actorActions[Cutscene_GetActorActionIndex(globalCtx, 109)]->action == 3) { + func_80AACF04(this, play); + if (Cutscene_CheckActorAction(play, 109)) { + if (play->csCtx.actorActions[Cutscene_GetActorActionIndex(play, 109)]->action == 3) { SkelAnime_Update(&this->skelAnime); } - } else if (Cutscene_CheckActorAction(globalCtx, 473)) { - if (globalCtx->csCtx.actorActions[Cutscene_GetActorActionIndex(globalCtx, 473)]->action == 3) { + } else if (Cutscene_CheckActorAction(play, 473)) { + if (play->csCtx.actorActions[Cutscene_GetActorActionIndex(play, 473)]->action == 3) { SkelAnime_Update(&this->skelAnime); } - } else if (Cutscene_CheckActorAction(globalCtx, 518)) { - if (globalCtx->csCtx.actorActions[Cutscene_GetActorActionIndex(globalCtx, 518)]->action == 2) { + } else if (Cutscene_CheckActorAction(play, 518)) { + if (play->csCtx.actorActions[Cutscene_GetActorActionIndex(play, 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)) { + } else if (Cutscene_CheckActorAction(play, 559)) { + if ((play->csCtx.actorActions[Cutscene_GetActorActionIndex(play, 559)]->action == 2) || + (play->csCtx.actorActions[Cutscene_GetActorActionIndex(play, 559)]->action == 3)) { SkelAnime_Update(&this->skelAnime); } - if (globalCtx->csCtx.actorActions[Cutscene_GetActorActionIndex(globalCtx, 559)]->action == 4) { + if (play->csCtx.actorActions[Cutscene_GetActorActionIndex(play, 559)]->action == 4) { this->actor.world.rot.y += 0x258; this->actor.shape.rot.y += 0x258; } } - this->actionFunc(this, globalCtx); - func_80AAD4A8(this, globalCtx); + this->actionFunc(this, play); + func_80AAD4A8(this, play); } -s32 DmChar05_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, - Actor* thisx) { +s32 DmChar05_OverrideLimbDraw(PlayState* play, 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 DmChar05_PostLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx) { } -void func_80AAD998(Actor* thisx, GlobalContext* globalCtx) { +void func_80AAD998(Actor* thisx, PlayState* play) { 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); + if (Cutscene_CheckActorAction(play, 109) && + (play->csCtx.actorActions[Cutscene_GetActorActionIndex(play, 109)]->action != 1)) { + OPEN_DISPS(play->state.gfxCtx); - func_8012C28C(globalCtx->state.gfxCtx); + func_8012C28C(play->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); + SkelAnime_DrawOpa(play, this->skelAnime.skeleton, this->skelAnime.jointTable, DmChar05_OverrideLimbDraw, + DmChar05_PostLimbDraw, &this->actor); - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->state.gfxCtx); } } else if (this->unk_18E == 1) { - func_80AADD9C(globalCtx, this); + func_80AADD9C(play, this); } } -void func_80AADA90(Actor* thisx, GlobalContext* globalCtx) { +void func_80AADA90(Actor* thisx, PlayState* play) { 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); + if (Cutscene_CheckActorAction(play, 473) && + (play->csCtx.actorActions[Cutscene_GetActorActionIndex(play, 473)]->action != 1)) { + func_8012C28C(play->state.gfxCtx); + SkelAnime_DrawOpa(play, this->skelAnime.skeleton, this->skelAnime.jointTable, DmChar05_OverrideLimbDraw, + DmChar05_PostLimbDraw, &this->actor); } } else if (this->unk_18E == 1) { - func_80AADE78(globalCtx, this); + func_80AADE78(play, this); } } -void func_80AADB4C(Actor* thisx, GlobalContext* globalCtx) { +void func_80AADB4C(Actor* thisx, PlayState* play) { 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, + if (Cutscene_CheckActorAction(play, 518) && + (play->csCtx.actorActions[Cutscene_GetActorActionIndex(play, 518)]->action != 1)) { + func_8012C28C(play->state.gfxCtx); + SkelAnime_DrawFlexOpa(play, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, NULL, NULL, &this->actor); } } else if (this->unk_18E == 1) { - func_80AADF54(globalCtx, this); + func_80AADF54(play, this); } } -void func_80AADC00(Actor* thisx, GlobalContext* globalCtx) { +void func_80AADC00(Actor* thisx, PlayState* play) { s32 pad; DmChar05* this = THIS; s32 actionIndex; - if (Cutscene_CheckActorAction(globalCtx, 559)) { - actionIndex = Cutscene_GetActorActionIndex(globalCtx, 559); + if (Cutscene_CheckActorAction(play, 559)) { + actionIndex = Cutscene_GetActorActionIndex(play, 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 ((play->csCtx.actorActions[actionIndex]->action != 1) && + (play->csCtx.actorActions[actionIndex]->action != 4)) { + func_8012C28C(play->state.gfxCtx); + SkelAnime_DrawOpa(play, this->skelAnime.skeleton, this->skelAnime.jointTable, DmChar05_OverrideLimbDraw, + DmChar05_PostLimbDraw, &this->actor); } - if (globalCtx->csCtx.actorActions[actionIndex]->action == 4) { - Matrix_InsertTranslation(-600.0f, 0.0f, 0.0f, MTXMODE_APPLY); - Gfx_DrawDListOpa(globalCtx, object_dmask_DL_001E70); + if (play->csCtx.actorActions[actionIndex]->action == 4) { + Matrix_Translate(-600.0f, 0.0f, 0.0f, MTXMODE_APPLY); + Gfx_DrawDListOpa(play, object_dmask_DL_001E70); } } } -void DmChar05_Draw(Actor* thisx, GlobalContext* globalCtx) { +void DmChar05_Draw(Actor* thisx, PlayState* play) { DmChar05* this = THIS; switch (DMCHAR05_GET(&this->actor)) { case DMCHAR05_0: - func_80AAD998(thisx, globalCtx); + func_80AAD998(thisx, play); break; case DMCHAR05_1: - func_80AADA90(thisx, globalCtx); + func_80AADA90(thisx, play); break; case DMCHAR05_2: - func_80AADB4C(thisx, globalCtx); + func_80AADB4C(thisx, play); break; case DMCHAR05_3: - func_80AADC00(thisx, globalCtx); + func_80AADC00(thisx, play); break; case DMCHAR05_4: - func_80AAE030(globalCtx, this); + func_80AAE030(play, this); break; case DMCHAR05_5: @@ -709,81 +708,81 @@ void DmChar05_Draw(Actor* thisx, GlobalContext* globalCtx) { case DMCHAR05_10: case DMCHAR05_11: case DMCHAR05_12: - func_80AAE114(globalCtx, this); + func_80AAE114(play, this); break; } } -void func_80AADD9C(GlobalContext* globalCtx, DmChar05* this) { +void func_80AADD9C(PlayState* play, DmChar05* this) { if (this->actor.objBankIndex == this->unk_18F) { - Matrix_InsertTranslation(this->unk_190.x, this->unk_190.y, this->unk_190.z, MTXMODE_NEW); - Matrix_InsertRotation(0, globalCtx->gameplayFrames * 1000, 0, MTXMODE_APPLY); + Matrix_Translate(this->unk_190.x, this->unk_190.y, this->unk_190.z, MTXMODE_NEW); + Matrix_RotateZYX(0, play->gameplayFrames * 1000, 0, MTXMODE_APPLY); Matrix_Scale(0.2f, 0.2f, 0.2f, MTXMODE_APPLY); - GetItem_Draw(globalCtx, GID_44); + GetItem_Draw(play, GID_MASK_GORON); } - if (Object_IsLoaded(&globalCtx->objectCtx, this->unk_18F)) { + if (Object_IsLoaded(&play->objectCtx, this->unk_18F)) { this->actor.objBankIndex = this->unk_18F; } } -void func_80AADE78(GlobalContext* globalCtx, DmChar05* this) { +void func_80AADE78(PlayState* play, DmChar05* this) { if (this->actor.objBankIndex == this->unk_18F) { - Matrix_InsertTranslation(this->unk_190.x, this->unk_190.y, this->unk_190.z, MTXMODE_NEW); - Matrix_InsertRotation(0, globalCtx->gameplayFrames * 1000, 0, MTXMODE_APPLY); + Matrix_Translate(this->unk_190.x, this->unk_190.y, this->unk_190.z, MTXMODE_NEW); + Matrix_RotateZYX(0, play->gameplayFrames * 1000, 0, MTXMODE_APPLY); Matrix_Scale(0.2f, 0.2f, 0.2f, MTXMODE_APPLY); - GetItem_Draw(globalCtx, GID_45); + GetItem_Draw(play, GID_MASK_ZORA); } - if (Object_IsLoaded(&globalCtx->objectCtx, this->unk_18F)) { + if (Object_IsLoaded(&play->objectCtx, this->unk_18F)) { this->actor.objBankIndex = this->unk_18F; } } -void func_80AADF54(GlobalContext* globalCtx, DmChar05* this) { +void func_80AADF54(PlayState* play, DmChar05* this) { if (this->actor.objBankIndex == this->unk_18F) { - Matrix_InsertTranslation(this->unk_190.x, this->unk_190.y, this->unk_190.z, MTXMODE_NEW); - Matrix_InsertRotation(0, globalCtx->gameplayFrames * 1000, 0, MTXMODE_APPLY); + Matrix_Translate(this->unk_190.x, this->unk_190.y, this->unk_190.z, MTXMODE_NEW); + Matrix_RotateZYX(0, play->gameplayFrames * 1000, 0, MTXMODE_APPLY); Matrix_Scale(0.2f, 0.2f, 0.2f, MTXMODE_APPLY); - GetItem_Draw(globalCtx, GID_6B); + GetItem_Draw(play, GID_MASK_GIBDO); } - if (Object_IsLoaded(&globalCtx->objectCtx, this->unk_18F)) { + if (Object_IsLoaded(&play->objectCtx, this->unk_18F)) { this->actor.objBankIndex = this->unk_18F; } } -void func_80AAE030(GlobalContext* globalCtx, DmChar05* this) { +void func_80AAE030(PlayState* play, DmChar05* this) { if (this->unk_18E != 0) { if (this->actor.objBankIndex == this->unk_18F) { - Matrix_InsertTranslation(this->unk_190.x, this->unk_190.y, this->unk_190.z, MTXMODE_NEW); - Matrix_InsertRotation(0, globalCtx->gameplayFrames * 1000, 0, MTXMODE_APPLY); + Matrix_Translate(this->unk_190.x, this->unk_190.y, this->unk_190.z, MTXMODE_NEW); + Matrix_RotateZYX(0, play->gameplayFrames * 1000, 0, MTXMODE_APPLY); Matrix_Scale(0.2f, 0.2f, 0.2f, MTXMODE_APPLY); - GetItem_Draw(globalCtx, GID_03); + GetItem_Draw(play, GID_MASK_COUPLE); } - if (Object_IsLoaded(&globalCtx->objectCtx, this->unk_18F)) { + if (Object_IsLoaded(&play->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, +void func_80AAE114(PlayState* play, DmChar05* this) { + s32 getItemDrawIndex; + s16 getItemDrawIds[] = { + GID_MASK_KAMARO, GID_MASK_GREAT_FAIRY, GID_MASK_ROMANI, GID_MASK_BLAST, + GID_MASK_CIRCUS_LEADER, GID_MASK_BREMEN, GID_MASK_BUNNY, GID_MASK_POSTMAN, }; - sp34 = DMCHAR05_GET(&this->actor) - DMCHAR05_5; + getItemDrawIndex = DMCHAR05_GET(&this->actor) - DMCHAR05_5; if (this->actor.objBankIndex == this->unk_18F) { - Matrix_InsertTranslation(this->actor.world.pos.x, this->actor.world.pos.y, this->actor.world.pos.z, - MTXMODE_NEW); - Matrix_InsertRotation(0, globalCtx->gameplayFrames * 1000, 0, MTXMODE_APPLY); + Matrix_Translate(this->actor.world.pos.x, this->actor.world.pos.y, this->actor.world.pos.z, MTXMODE_NEW); + Matrix_RotateZYX(0, play->gameplayFrames * 1000, 0, MTXMODE_APPLY); Matrix_Scale(0.2f, 0.2f, 0.2f, MTXMODE_APPLY); - GetItem_Draw(globalCtx, sp24[sp34]); + GetItem_Draw(play, getItemDrawIds[getItemDrawIndex]); } - if (Object_IsLoaded(&globalCtx->objectCtx, this->unk_18F)) { + if (Object_IsLoaded(&play->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 83bb67948..212cdb03e 100644 --- a/src/overlays/actors/ovl_Dm_Char05/z_dm_char05.h +++ b/src/overlays/actors/ovl_Dm_Char05/z_dm_char05.h @@ -5,7 +5,7 @@ struct DmChar05; -typedef void (*DmChar05ActionFunc)(struct DmChar05*, GlobalContext*); +typedef void (*DmChar05ActionFunc)(struct DmChar05*, PlayState*); #define DMCHAR05_GET(thisx) ((thisx)->params) @@ -26,20 +26,20 @@ enum { }; typedef struct DmChar05 { - /* 0x0000 */ Actor actor; - /* 0x0144 */ SkelAnime skelAnime; - /* 0x0188 */ DmChar05ActionFunc actionFunc; - /* 0x018C */ s16 unk_18C; - /* 0x018E */ u8 unk_18E; - /* 0x018F */ u8 unk_18F; - /* 0x0190 */ Vec3f unk_190; - /* 0x019C */ u32 unk_19C; - /* 0x01A0 */ u32 unk_1A0; - /* 0x01A4 */ u32 unk_1A4; - /* 0x01A8 */ s32 unk_1A8; - /* 0x01AC */ s32 unk_1AC; - /* 0x01B0 */ s32 unk_1B0; - /* 0x01B4 */ u8 unk_1B4; + /* 0x000 */ Actor actor; + /* 0x144 */ SkelAnime skelAnime; + /* 0x188 */ DmChar05ActionFunc actionFunc; + /* 0x18C */ s16 unk_18C; + /* 0x18E */ u8 unk_18E; + /* 0x18F */ u8 unk_18F; + /* 0x190 */ Vec3f unk_190; + /* 0x19C */ u32 unk_19C; + /* 0x1A0 */ u32 unk_1A0; + /* 0x1A4 */ u32 unk_1A4; + /* 0x1A8 */ s32 unk_1A8; + /* 0x1AC */ s32 unk_1AC; + /* 0x1B0 */ s32 unk_1B0; + /* 0x1B4 */ u8 unk_1B4; } DmChar05; // size = 0x1B8 extern const ActorInit Dm_Char05_InitVars; diff --git a/src/overlays/actors/ovl_Dm_Char06/z_dm_char06.c b/src/overlays/actors/ovl_Dm_Char06/z_dm_char06.c index e35328af0..a419ed5aa 100644 --- a/src/overlays/actors/ovl_Dm_Char06/z_dm_char06.c +++ b/src/overlays/actors/ovl_Dm_Char06/z_dm_char06.c @@ -10,16 +10,14 @@ #define THIS ((DmChar06*)thisx) -void DmChar06_Init(Actor* thisx, GlobalContext* globalCtx); -void DmChar06_Destroy(Actor* thisx, GlobalContext* globalCtx); -void DmChar06_Update(Actor* thisx, GlobalContext* globalCtx); -void DmChar06_Draw(Actor* thisx, GlobalContext* globalCtx); - -void func_80AAE6F0(DmChar06* this, GlobalContext* globalCtx); +void DmChar06_Init(Actor* thisx, PlayState* play); +void DmChar06_Destroy(Actor* thisx, PlayState* play); +void DmChar06_Update(Actor* thisx, PlayState* play); +void DmChar06_Draw(Actor* thisx, PlayState* play); void DmChar06_SetupAction(DmChar06* this, DmChar06ActionFunc actionFunc); +void func_80AAE6F0(DmChar06* this, PlayState* play); -#if 0 const ActorInit Dm_Char06_InitVars = { ACTOR_DM_CHAR06, ACTORCAT_ITEMACTION, @@ -32,18 +30,60 @@ const ActorInit Dm_Char06_InitVars = { (ActorFunc)DmChar06_Draw, }; -#endif +void DmChar06_SetupAction(DmChar06* this, DmChar06ActionFunc actionFunc) { + this->actionFunc = actionFunc; +} -extern UNK_TYPE D_06006868; +void DmChar06_Init(Actor* thisx, PlayState* play) { + DmChar06* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Char06/DmChar06_SetupAction.s") + gSaveContext.save.weekEventReg[33] |= 0x80; + Actor_SetScale(&this->actor, 1.0f); + this->alpha = 255; + DmChar06_SetupAction(this, func_80AAE6F0); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Char06/DmChar06_Init.s") +void DmChar06_Destroy(Actor* thisx, PlayState* play) { +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Char06/DmChar06_Destroy.s") +void func_80AAE6F0(DmChar06* this, PlayState* play) { + if (Cutscene_CheckActorAction(play, 0x1CF)) { + s32 actionIndex = Cutscene_GetActorActionIndex(play, 0x1CF); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Char06/func_80AAE6F0.s") + if ((play->csCtx.frames >= play->csCtx.actorActions[actionIndex]->startFrame) && + (play->csCtx.actorActions[actionIndex]->endFrame >= play->csCtx.frames)) { + if (play->csCtx.actorActions[actionIndex]->action == 1) { + this->alpha = 255; + } else if (play->csCtx.actorActions[actionIndex]->action == 2) { + f32 lerp = 1.0f - Environment_LerpWeight(play->csCtx.actorActions[actionIndex]->endFrame, + play->csCtx.actorActions[actionIndex]->startFrame, + play->csCtx.frames); + this->alpha = 255 * lerp; + } + } + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Char06/DmChar06_Update.s") +void DmChar06_Update(Actor* thisx, PlayState* play) { + DmChar06* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Char06/DmChar06_Draw.s") + this->actionFunc(this, play); +} + +void DmChar06_Draw(Actor* thisx, PlayState* play) { + s32 pad; + DmChar06* this = THIS; + + AnimatedMat_Draw(play, Lib_SegmentedToVirtual(object_yukiyama_Matanimheader_006868)); + + OPEN_DISPS(play->state.gfxCtx); + + func_8012C2DC(play->state.gfxCtx); + Scene_SetRenderModeXlu(play, 1, 2); + gDPPipeSync(POLY_XLU_DISP++); + gDPSetEnvColor(POLY_XLU_DISP++, 0, 0, 0, this->alpha); + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_XLU_DISP++, object_yukiyama_DL_0013A8); + + CLOSE_DISPS(play->state.gfxCtx); +} diff --git a/src/overlays/actors/ovl_Dm_Char06/z_dm_char06.h b/src/overlays/actors/ovl_Dm_Char06/z_dm_char06.h index a7e1e22ee..c6b83b4ff 100644 --- a/src/overlays/actors/ovl_Dm_Char06/z_dm_char06.h +++ b/src/overlays/actors/ovl_Dm_Char06/z_dm_char06.h @@ -2,16 +2,18 @@ #define Z_DM_CHAR06_H #include "global.h" +#include "assets/objects/object_yukiyama/object_yukiyama.h" struct DmChar06; -typedef void (*DmChar06ActionFunc)(struct DmChar06*, GlobalContext*); +typedef void (*DmChar06ActionFunc)(struct DmChar06*, PlayState*); typedef struct DmChar06 { - /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x14C]; - /* 0x0290 */ DmChar06ActionFunc actionFunc; - /* 0x0294 */ char unk_294[0x10]; + /* 0x000 */ Actor actor; + /* 0x144 */ UNK_TYPE1 pad144[0x14C]; + /* 0x290 */ DmChar06ActionFunc actionFunc; + /* 0x294 */ UNK_TYPE1 pad294[0xC]; + /* 0x2A0 */ u8 alpha; } DmChar06; // size = 0x2A4 extern const ActorInit Dm_Char06_InitVars; 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 d2aac5a7c..7058500a9 100644 --- a/src/overlays/actors/ovl_Dm_Char07/z_dm_char07.c +++ b/src/overlays/actors/ovl_Dm_Char07/z_dm_char07.c @@ -11,12 +11,12 @@ #define THIS ((DmChar07*)thisx) -void DmChar07_Init(Actor* thisx, GlobalContext* globalCtx); -void DmChar07_Destroy(Actor* thisx, GlobalContext* globalCtx); -void DmChar07_Update(Actor* thisx, GlobalContext* globalCtx); -void DmChar07_Draw(Actor* thisx, GlobalContext* globalCtx); +void DmChar07_Init(Actor* thisx, PlayState* play); +void DmChar07_Destroy(Actor* thisx, PlayState* play); +void DmChar07_Update(Actor* thisx, PlayState* play); +void DmChar07_Draw(Actor* thisx, PlayState* play); -void DmChar07_DoNothing(DmChar07* this, GlobalContext* globalCtx); +void DmChar07_DoNothing(DmChar07* this, PlayState* play); const ActorInit Dm_Char07_InitVars = { ACTOR_DM_CHAR07, @@ -34,7 +34,7 @@ void DmChar07_SetupAction(DmChar07* this, DmChar07ActionFunc actionFunc) { this->actionFunc = actionFunc; } -void DmChar07_Init(Actor* thisx, GlobalContext* globalCtx) { +void DmChar07_Init(Actor* thisx, PlayState* play) { DmChar07* this = THIS; this->isStage = 0; @@ -45,44 +45,44 @@ void DmChar07_Init(Actor* thisx, GlobalContext* globalCtx) { Actor_SetScale(&this->dyna.actor, 0.1f); this->isStage = 1; DynaPolyActor_Init(&this->dyna, 0); - DynaPolyActor_LoadMesh(globalCtx, &this->dyna, &object_milkbar_Colheader_006688); + DynaPolyActor_LoadMesh(play, &this->dyna, &object_milkbar_Colheader_006688); } else { Actor_SetScale(&this->dyna.actor, 1.0f); } DmChar07_SetupAction(this, DmChar07_DoNothing); } -void DmChar07_Destroy(Actor* thisx, GlobalContext* globalCtx) { +void DmChar07_Destroy(Actor* thisx, PlayState* play) { DmChar07* this = THIS; if (this->isStage) { - DynaPoly_DeleteBgActor(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); + DynaPoly_DeleteBgActor(play, &play->colCtx.dyna, this->dyna.bgId); } } -void DmChar07_DoNothing(DmChar07* this, GlobalContext* globalCtx) { +void DmChar07_DoNothing(DmChar07* this, PlayState* play) { } -void DmChar07_Update(Actor* thisx, GlobalContext* globalCtx) { +void DmChar07_Update(Actor* thisx, PlayState* play) { DmChar07* this = THIS; - this->actionFunc(this, globalCtx); + this->actionFunc(this, play); } -void DmChar07_Draw(Actor* thisx, GlobalContext* globalCtx) { +void DmChar07_Draw(Actor* thisx, PlayState* play) { DmChar07* this = THIS; s32 pad; - OPEN_DISPS(globalCtx->state.gfxCtx); + OPEN_DISPS(play->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); + func_8012C28C(play->state.gfxCtx); + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); switch (this->dyna.actor.params) { case DMCHAR07_STAGE: gSPDisplayList(POLY_OPA_DISP++, object_milkbar_DL_002CD0); break; case DMCHAR07_CREDITS_STAGE: - AnimatedMat_Draw(globalCtx, Lib_SegmentedToVirtual(object_milkbar_Matanimheader_0105F8)); + AnimatedMat_Draw(play, Lib_SegmentedToVirtual(object_milkbar_Matanimheader_0105F8)); gSPDisplayList(POLY_OPA_DISP++, object_milkbar_DL_007918); gSPDisplayList(POLY_OPA_DISP++, object_milkbar_DL_000240); gSPDisplayList(POLY_OPA_DISP++, object_milkbar_DL_000790); @@ -112,8 +112,8 @@ void DmChar07_Draw(Actor* thisx, GlobalContext* globalCtx) { break; } - func_8012C2DC(globalCtx->state.gfxCtx); - gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + func_8012C2DC(play->state.gfxCtx); + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); switch (this->dyna.actor.params) { case DMCHAR07_STAGE: gSPDisplayList(POLY_XLU_DISP++, object_milkbar_DL_002BA0); @@ -147,5 +147,5 @@ void DmChar07_Draw(Actor* thisx, GlobalContext* globalCtx) { break; } - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->state.gfxCtx); } diff --git a/src/overlays/actors/ovl_Dm_Char07/z_dm_char07.h b/src/overlays/actors/ovl_Dm_Char07/z_dm_char07.h index 2a151012b..8d3528347 100644 --- a/src/overlays/actors/ovl_Dm_Char07/z_dm_char07.h +++ b/src/overlays/actors/ovl_Dm_Char07/z_dm_char07.h @@ -5,16 +5,16 @@ struct DmChar07; -typedef void (*DmChar07ActionFunc)(struct DmChar07*, GlobalContext*); +typedef void (*DmChar07ActionFunc)(struct DmChar07*, PlayState*); #define DMCHAR07_GET_SPOTLIGHTFLAGS(thisx) (((thisx)->params >> 8) & 0x1F) #define DMCHAR07_GET_TYPE(thisx) ((thisx)->params & 0xFF) -#define DMCHAR07_STAGE_RIGHT_SPOTLIGHT 1 // Deku spotlight -#define DMCHAR07_UPSTAGE_RIGHT_SPOTLIGHT 2 // Goron spotlight -#define DMCHAR07_STAGE_CENTER_SPOTLIGHT 4 // Human spotlight -#define DMCHAR07_UPSTAGE_LEFT_SPOTLIGHT 8 // Zora spotlight -#define DMCHAR07_DOWNSTAGE_CENTER_SPOTLIGHT 16 +#define DMCHAR07_STAGE_RIGHT_SPOTLIGHT (1 << 0) // Deku spotlight +#define DMCHAR07_UPSTAGE_RIGHT_SPOTLIGHT (1 << 1) // Goron spotlight +#define DMCHAR07_STAGE_CENTER_SPOTLIGHT (1 << 2) // Human spotlight +#define DMCHAR07_UPSTAGE_LEFT_SPOTLIGHT (1 << 3) // Zora spotlight +#define DMCHAR07_DOWNSTAGE_CENTER_SPOTLIGHT (1 << 4) typedef enum { /* 0 */ DMCHAR07_STAGE, @@ -25,9 +25,9 @@ typedef enum { typedef struct DmChar07 { /* 0x000 */ DynaPolyActor dyna; - /* 0x15C */ char pad15C[0x14C]; + /* 0x15C */ UNK_TYPE1 pad15C[0x14C]; /* 0x2A8 */ DmChar07ActionFunc actionFunc; - /* 0x2AC */ char pad2AC[0xD]; + /* 0x2AC */ UNK_TYPE1 pad2AC[0xD]; /* 0x2B9 */ u8 spotlightFlags; /* 0x2BA */ u8 isStage; } DmChar07; // size = 0x2BC 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 f944c9c63..ed8625795 100644 --- a/src/overlays/actors/ovl_Dm_Char08/z_dm_char08.c +++ b/src/overlays/actors/ovl_Dm_Char08/z_dm_char08.c @@ -10,10 +10,10 @@ #define THIS ((DmChar08*)thisx) -void DmChar08_Init(Actor* thisx, GlobalContext* globalCtx); -void DmChar08_Destroy(Actor* thisx, GlobalContext* globalCtx); -void DmChar08_Update(Actor* thisx, GlobalContext* globalCtx); -void DmChar08_Draw(Actor* thisx, GlobalContext* globalCtx); +void DmChar08_Init(Actor* thisx, PlayState* play); +void DmChar08_Destroy(Actor* thisx, PlayState* play); +void DmChar08_Update(Actor* thisx, PlayState* play); +void DmChar08_Draw(Actor* thisx, PlayState* play); #if 0 const ActorInit Dm_Char08_InitVars = { diff --git a/src/overlays/actors/ovl_Dm_Char08/z_dm_char08.h b/src/overlays/actors/ovl_Dm_Char08/z_dm_char08.h index 6e31b5c34..1718a9fb0 100644 --- a/src/overlays/actors/ovl_Dm_Char08/z_dm_char08.h +++ b/src/overlays/actors/ovl_Dm_Char08/z_dm_char08.h @@ -5,13 +5,13 @@ struct DmChar08; -typedef void (*DmChar08ActionFunc)(struct DmChar08*, GlobalContext*); +typedef void (*DmChar08ActionFunc)(struct DmChar08*, PlayState*); typedef struct DmChar08 { - /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x5C]; - /* 0x01A0 */ DmChar08ActionFunc actionFunc; - /* 0x01A4 */ char unk_1A4[0x68]; + /* 0x000 */ Actor actor; + /* 0x144 */ char unk_144[0x5C]; + /* 0x1A0 */ DmChar08ActionFunc actionFunc; + /* 0x1A4 */ char unk_1A4[0x68]; } DmChar08; // size = 0x20C extern const ActorInit Dm_Char08_InitVars; diff --git a/src/overlays/actors/ovl_Dm_Char09/z_dm_char09.c b/src/overlays/actors/ovl_Dm_Char09/z_dm_char09.c index 7fb20d1a0..8f02a8bb4 100644 --- a/src/overlays/actors/ovl_Dm_Char09/z_dm_char09.c +++ b/src/overlays/actors/ovl_Dm_Char09/z_dm_char09.c @@ -10,16 +10,14 @@ #define THIS ((DmChar09*)thisx) -void DmChar09_Init(Actor* thisx, GlobalContext* globalCtx); -void DmChar09_Destroy(Actor* thisx, GlobalContext* globalCtx); -void DmChar09_Update(Actor* thisx, GlobalContext* globalCtx); -void DmChar09_Draw(Actor* thisx, GlobalContext* globalCtx); +void DmChar09_Init(Actor* thisx, PlayState* play); +void DmChar09_Destroy(Actor* thisx, PlayState* play); +void DmChar09_Update(Actor* thisx, PlayState* play); +void DmChar09_Draw(Actor* thisx, PlayState* play); -void func_80AB1FDC(DmChar09* this, GlobalContext* globalCtx); -void func_80AB2258(DmChar09* this, GlobalContext* globalCtx); -void func_80AB2268(DmChar09* this, GlobalContext* globalCtx); +void DmChar09_DoNothing(DmChar09* this, PlayState* play); +void func_80AB2268(DmChar09* this, PlayState* play); -#if 0 const ActorInit Dm_Char09_InitVars = { ACTOR_DM_CHAR09, ACTORCAT_ITEMACTION, @@ -32,28 +30,197 @@ const ActorInit Dm_Char09_InitVars = { (ActorFunc)DmChar09_Draw, }; -#endif +static AnimationInfo sAnimationInfo[] = { + { &object_bee_Anim_00005C, 1.0f, 0.0f, -1.0f, ANIMMODE_LOOP, 0.0f }, +}; -extern UNK_TYPE D_0600005C; +void DmChar09_ChangeAnim(SkelAnime* skelAnime, AnimationInfo* animationInfo, u16 animIndex) { + f32 frameCount; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Char09/func_80AB1E10.s") + animationInfo += animIndex; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Char09/DmChar09_Init.s") + if (animationInfo->frameCount < 0.0f) { + frameCount = Animation_GetLastFrame(animationInfo->animation); + } else { + frameCount = animationInfo->frameCount; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Char09/DmChar09_Destroy.s") + Animation_Change(skelAnime, animationInfo->animation, animationInfo->playSpeed, animationInfo->startFrame, + frameCount, animationInfo->mode, animationInfo->morphFrames); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Char09/func_80AB1FA0.s") +void DmChar09_Init(Actor* thisx, PlayState* play) { + DmChar09* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Char09/func_80AB1FDC.s") + ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 19.0f); + SkelAnime_Init(play, &this->skelAnime, &object_bee_Skel_001398, &object_bee_Anim_00005C, this->jointTable, + this->morphTable, OBJECT_BEE_LIMB_MAX); + DmChar09_ChangeAnim(&this->skelAnime, sAnimationInfo, 0); + Actor_SetScale(&this->actor, 0.01f); + this->unk_228 = Rand_ZeroOne() * 65535.0f; + this->unk_22A = Rand_ZeroOne() * 65535.0f; + this->actionFunc = DmChar09_DoNothing; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Char09/func_80AB2258.s") +void DmChar09_Destroy(Actor* thisx, PlayState* play) { +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Char09/func_80AB2268.s") +void func_80AB1FA0(DmChar09* this, s32 arg1) { + Math_Vec3s_ToVec3f(&this->actor.world.pos, &this->unk_224[arg1]); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Char09/func_80AB24BC.s") +void func_80AB1FDC(DmChar09* this, PlayState* play) { + Actor* thisx = &this->actor; + Vec3f sp58; + f32 sp54; + f32 phi_fa0; + f32 phi_fv0; + Vec3f sp40; + s32 phi_a1; + Vec3s* temp_v1; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Char09/DmChar09_Update.s") + Math_Vec3f_Copy(&sp40, &thisx->world.pos); + Math_Vec3s_ToVec3f(&sp58, this->unk_224 + this->unk_21C + this->unk_220); + Math_Vec3f_Diff(&sp58, &thisx->world.pos, &thisx->velocity); + sp54 = Math3D_Vec3fMagnitude(&thisx->velocity); + if ((sp54 < (this->speed * 8.0f)) && (this->speed > 2.0f)) { + phi_fv0 = ((this->speed - 2.0f) * 0.1f) + 2.0f; + phi_fa0 = this->speed * 0.03f; + } else { + phi_fv0 = this->speed; + phi_fa0 = this->speed * 0.16f; + } + Math_StepToF(&thisx->speedXZ, phi_fv0, phi_fa0); + if ((thisx->speedXZ + 0.05f) < sp54) { + Math_Vec3f_Scale(&thisx->velocity, thisx->speedXZ / sp54); + thisx->world.pos.x += thisx->velocity.x; + thisx->world.pos.y += thisx->velocity.y; + thisx->world.pos.z += thisx->velocity.z; + } else { + this->unk_21C += this->unk_220; + thisx->speedXZ *= 0.4f; + phi_a1 = true; + if (((this->unk_21C >= this->unk_218) && (this->unk_220 > 0)) || + ((this->unk_21C <= 0) && (this->unk_220 < 0))) { + temp_v1 = this->unk_224 + this->unk_218; + if (((this->unk_224->x == temp_v1->x) && (this->unk_224->y == temp_v1->y)) && + (this->unk_224->z == temp_v1->z)) { + this->unk_21C = 0; + this->unk_220 = 1; + } else { + phi_a1 = false; + this->actionFunc = func_80AB2268; + } + } + if (phi_a1) { + func_80AB1FA0(this, this->unk_21C); + } + } + Math_SmoothStepToS(&thisx->world.rot.y, Math_Vec3f_Yaw(&thisx->world.pos, &sp40) + 0x7FFF, 1, 0x7D0, 0); + thisx->shape.rot.y = thisx->world.rot.y; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Char09/func_80AB25D8.s") +void DmChar09_DoNothing(DmChar09* this, PlayState* play) { +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Char09/DmChar09_Draw.s") +void func_80AB2268(DmChar09* this, PlayState* play) { + Path* path; + s32 pad; + s32 i; + s32 actionIndex; + s32 max = 0; + s32 pathnum; + u8 temp = false; + + if (!DMCHAR09_GET_F(&this->actor)) { + if (play->csCtx.currentCsIndex == 1) { + temp = true; + } + } else if (play->csCtx.currentCsIndex == 0) { + temp = true; + } + + if (Cutscene_CheckActorAction(play, 0x1F7) && temp) { + actionIndex = Cutscene_GetActorActionIndex(play, 0x1F7); + if (this->unk_22F != play->csCtx.actorActions[actionIndex]->action) { + this->unk_22F = play->csCtx.actorActions[actionIndex]->action; + switch (play->csCtx.actorActions[actionIndex]->action) { + case 2: + max = 0; + break; + case 3: + max = 1; + break; + case 4: + max = 2; + break; + case 5: + max = 3; + break; + } + + if (play->csCtx.actorActions[actionIndex]->action >= 2) { + pathnum = DMCHAR09_GET_PATH(&this->actor); + path = &play->setupPathList[pathnum]; + + for (i = 0; i < max; i++) { + pathnum = path->unk1; + path = &play->setupPathList[pathnum]; + } + + this->unk_224 = Lib_SegmentedToVirtual(path->points); + this->unk_214 = path->count; + this->unk_21C = 0; + this->unk_218 = path->count - 1; + this->unk_220 = 1; + this->unk_22E = true; + + this->speed = (u16)play->csCtx.actorActions[actionIndex]->rot.z * 0.00390625f; + this->actionFunc = func_80AB1FDC; + } else { + this->unk_22E = false; + this->actionFunc = DmChar09_DoNothing; + } + } + } else { + this->unk_22F = 0x63; + } +} + +void func_80AB24BC(DmChar09* this, PlayState* play) { + this->unk_228 += 0xBB8; + this->unk_22A += 0x1388; + this->unk_204 = Math_SinS(this->unk_228) * 150.0f; + this->unk_208 = Math_SinS(this->unk_22A) * 150.0f; + this->unk_20C = Math_SinS(this->unk_228) * 150.0f; +} + +void DmChar09_Update(Actor* thisx, PlayState* play) { + DmChar09* this = THIS; + + SkelAnime_Update(&this->skelAnime); + this->actionFunc(this, play); + func_80AB2268(this, play); + func_80AB24BC(this, play); + if ((play->csCtx.state != 0) && this->unk_22E && DMCHAR09_GET_100(thisx)) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_POSTMAN_WALK + SFX_FLAG); + } +} + +s32 DmChar09_OverrideLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, Actor* thisx) { + DmChar09* this = THIS; + + Matrix_Translate(this->unk_204, this->unk_208, this->unk_20C, MTXMODE_APPLY); + return false; +} + +void DmChar09_Draw(Actor* thisx, PlayState* play) { + DmChar09* this = THIS; + + if ((play->csCtx.state != 0) && this->unk_22E) { + func_8012C28C(play->state.gfxCtx); + func_8012C2DC(play->state.gfxCtx); + SkelAnime_DrawOpa(play, this->skelAnime.skeleton, this->skelAnime.jointTable, DmChar09_OverrideLimbDraw, NULL, + &this->actor); + } +} diff --git a/src/overlays/actors/ovl_Dm_Char09/z_dm_char09.h b/src/overlays/actors/ovl_Dm_Char09/z_dm_char09.h index 280607ee2..ce01f164a 100644 --- a/src/overlays/actors/ovl_Dm_Char09/z_dm_char09.h +++ b/src/overlays/actors/ovl_Dm_Char09/z_dm_char09.h @@ -2,16 +2,36 @@ #define Z_DM_CHAR09_H #include "global.h" +#include "objects/object_bee/object_bee.h" + +#define DMCHAR09_GET_PATH(thisx) (((thisx)->params >> 4) & 0xF) +#define DMCHAR09_GET_100(thisx) ((thisx)->params & 0x100) +#define DMCHAR09_GET_F(thisx) ((thisx)->params & 0xF) struct DmChar09; -typedef void (*DmChar09ActionFunc)(struct DmChar09*, GlobalContext*); +typedef void (*DmChar09ActionFunc)(struct DmChar09*, PlayState*); typedef struct DmChar09 { - /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0xBC]; - /* 0x0200 */ DmChar09ActionFunc actionFunc; - /* 0x0204 */ char unk_204[0x2C]; + /* 0x000 */ Actor actor; + /* 0x144 */ SkelAnime skelAnime; + /* 0x188 */ Vec3s jointTable[OBJECT_BEE_LIMB_MAX]; + /* 0x1C4 */ Vec3s morphTable[OBJECT_BEE_LIMB_MAX]; + /* 0x200 */ DmChar09ActionFunc actionFunc; + /* 0x204 */ f32 unk_204; + /* 0x208 */ f32 unk_208; + /* 0x20C */ f32 unk_20C; + /* 0x210 */ f32 speed; + /* 0x214 */ s32 unk_214; + /* 0x218 */ s32 unk_218; + /* 0x21C */ s32 unk_21C; + /* 0x220 */ s32 unk_220; + /* 0x224 */ Vec3s* unk_224; + /* 0x228 */ s16 unk_228; + /* 0x22A */ s16 unk_22A; + /* 0x22C */ UNK_TYPE1 pad22C[2]; + /* 0x22E */ u8 unk_22E; + /* 0x22F */ u8 unk_22F; } DmChar09; // size = 0x230 extern const ActorInit Dm_Char09_InitVars; diff --git a/src/overlays/actors/ovl_Dm_Gm/z_dm_gm.c b/src/overlays/actors/ovl_Dm_Gm/z_dm_gm.c index 88a99ad53..2b9c62e19 100644 --- a/src/overlays/actors/ovl_Dm_Gm/z_dm_gm.c +++ b/src/overlays/actors/ovl_Dm_Gm/z_dm_gm.c @@ -12,14 +12,14 @@ #define THIS ((DmGm*)thisx) -void DmGm_Init(Actor* thisx, GlobalContext* globalCtx); -void DmGm_Destroy(Actor* thisx, GlobalContext* globalCtx); -void DmGm_Update(Actor* thisx, GlobalContext* globalCtx); +void DmGm_Init(Actor* thisx, PlayState* play); +void DmGm_Destroy(Actor* thisx, PlayState* play); +void DmGm_Update(Actor* thisx, PlayState* play); -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); +void func_80C248A8(DmGm* this, PlayState* play); +void func_80C24A00(DmGm* this, PlayState* play); +void func_80C24BD0(DmGm* this, PlayState* play); +void func_80C25000(Actor* thisx, PlayState* play); const ActorInit Dm_Gm_InitVars = { ACTOR_DM_GM, @@ -33,7 +33,7 @@ const ActorInit Dm_Gm_InitVars = { (ActorFunc)NULL, }; -static AnimationInfoS sAnimations[] = { +static AnimationInfoS sAnimationInfo[] = { { &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 }, @@ -50,7 +50,7 @@ static AnimationInfoS sAnimations[] = { { &object_an4_Anim_00506C, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, }; -s32 func_80C24360(DmGm* this, GlobalContext* globalCtx) { +s32 func_80C24360(DmGm* this, PlayState* play) { s8 objectIndex = this->actor.objBankIndex; s8 objectIndex2; s32 ret = false; @@ -62,14 +62,14 @@ s32 func_80C24360(DmGm* this, GlobalContext* globalCtx) { } if (objectIndex2 >= 0) { - gSegments[6] = PHYSICAL_TO_VIRTUAL2(globalCtx->objectCtx.status[objectIndex2].segment); + gSegments[6] = VIRTUAL_TO_PHYSICAL(play->objectCtx.status[objectIndex2].segment); ret = SkelAnime_Update(&this->skelAnime); - gSegments[6] = PHYSICAL_TO_VIRTUAL2(globalCtx->objectCtx.status[objectIndex].segment); + gSegments[6] = VIRTUAL_TO_PHYSICAL(play->objectCtx.status[objectIndex].segment); } return ret; } -s32 func_80C24428(DmGm* this, GlobalContext* globalCtx, s32 arg2) { +s32 func_80C24428(DmGm* this, PlayState* play, s32 arg2) { s8 objectIndex = this->actor.objBankIndex; s8 objectIndex2; s32 ret = false; @@ -81,10 +81,10 @@ s32 func_80C24428(DmGm* this, GlobalContext* globalCtx, s32 arg2) { } if ((objectIndex2 >= 0) && (arg2 != this->unk_2C8)) { - gSegments[6] = PHYSICAL_TO_VIRTUAL2(globalCtx->objectCtx.status[objectIndex2].segment); + gSegments[6] = VIRTUAL_TO_PHYSICAL(play->objectCtx.status[objectIndex2].segment); this->unk_2C8 = arg2; - ret = SubS_ChangeAnimationByInfoS(&this->skelAnime, sAnimations, arg2); - gSegments[6] = PHYSICAL_TO_VIRTUAL2(globalCtx->objectCtx.status[objectIndex].segment); + ret = SubS_ChangeAnimationByInfoS(&this->skelAnime, sAnimationInfo, arg2); + gSegments[6] = VIRTUAL_TO_PHYSICAL(play->objectCtx.status[objectIndex].segment); } return ret; } @@ -99,7 +99,7 @@ void func_80C24504(DmGm* this) { } } -s32 func_80C2457C(DmGm* this, GlobalContext* globalCtx) { +s32 func_80C2457C(DmGm* this, PlayState* play) { s32 pad; Vec3f sp40; Vec3f sp34; @@ -130,9 +130,9 @@ s32 func_80C2457C(DmGm* this, GlobalContext* globalCtx) { return true; } -s32 func_80C2478C(DmGm* this, GlobalContext* globalCtx) { +s32 func_80C2478C(DmGm* this, PlayState* play) { if (this->unk_2B4 != NULL) { - func_80C2457C(this, globalCtx); + func_80C2457C(this, play); this->unk_2AE &= ~1; this->unk_2AE |= 2; } else if (this->unk_2AE & 2) { @@ -148,12 +148,12 @@ s32 func_80C2478C(DmGm* this, GlobalContext* globalCtx) { return true; } -Actor* func_80C24838(GlobalContext* globalCtx) { +Actor* func_80C24838(PlayState* play) { Actor* tempActor; Actor* foundActor = NULL; while (true) { - foundActor = SubS_FindActor(globalCtx, foundActor, ACTORCAT_NPC, ACTOR_DM_AH); + foundActor = SubS_FindActor(play, foundActor, ACTORCAT_NPC, ACTOR_DM_AH); if ((foundActor == NULL) || (foundActor->update != NULL)) { break; @@ -169,23 +169,23 @@ Actor* func_80C24838(GlobalContext* globalCtx) { 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)) { +void func_80C248A8(DmGm* this, PlayState* play) { + if ((this->unk_2AC >= 0) && SubS_IsObjectLoaded(this->unk_2AC, play) && (this->unk_2AD >= 0) && + SubS_IsObjectLoaded(this->unk_2AD, play)) { 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); + SkelAnime_InitFlex(play, &this->skelAnime, &object_an1_Skel_012618, NULL, this->jointTable, this->morphTable, + OBJECT_AN1_LIMB_MAX); this->unk_2C8 = -1; - func_80C24428(this, globalCtx, 0); + func_80C24428(this, play, 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); + if ((play->sceneNum == SCENE_YADOYA) && (play->curSpawn == 4)) { + this->unk_2B4 = func_80C24838(play); + func_80C24428(this, play, 1); this->actionFunc = func_80C24BD0; } else { this->actionFunc = func_80C24A00; @@ -193,12 +193,12 @@ void func_80C248A8(DmGm* this, GlobalContext* globalCtx) { } } -void func_80C24A00(DmGm* this, GlobalContext* globalCtx) { +void func_80C24A00(DmGm* this, PlayState* play) { s32 sp28[] = { 0, 0, 12, 2, 4, 6, 8, 10, 11, 3 }; u16 action; s32 sp20; - if (globalCtx->csCtx.state != 0) { + if (play->csCtx.state != 0) { if (this->unk_2D0 == 0) { this->unk_2B0 = 255; this->unk_2D0 = 1; @@ -206,14 +206,14 @@ void func_80C24A00(DmGm* this, GlobalContext* globalCtx) { this->unk_2CC = this->unk_2C8; } - if (Cutscene_CheckActorAction(globalCtx, 0x22D)) { - sp20 = Cutscene_GetActorActionIndex(globalCtx, 0x22D); - action = globalCtx->csCtx.actorActions[sp20]->action; + if (Cutscene_CheckActorAction(play, 0x22D)) { + sp20 = Cutscene_GetActorActionIndex(play, 0x22D); + action = play->csCtx.actorActions[sp20]->action; if (this->unk_2B0 != (action & 0xFF)) { this->unk_2B0 = action; this->unk_2D4 = 1; - func_80C24428(this, globalCtx, sp28[action]); + func_80C24428(this, play, sp28[action]); } switch (this->unk_2B0) { @@ -225,118 +225,118 @@ void func_80C24A00(DmGm* this, GlobalContext* globalCtx) { 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); + func_80C24428(this, play, this->unk_2C8 + 1); } } break; } - Cutscene_ActorTranslateAndYaw(&this->actor, globalCtx, sp20); + Cutscene_ActorTranslateAndYaw(&this->actor, play, sp20); } } else if (this->unk_2D0 != 0) { this->unk_2D0 = 0; this->unk_2D4 = 0; - func_80C24428(this, globalCtx, this->unk_2CC); + func_80C24428(this, play, this->unk_2CC); } } -void func_80C24BD0(DmGm* this, GlobalContext* globalCtx) { +void func_80C24BD0(DmGm* this, PlayState* play) { } -void DmGm_Init(Actor* thisx, GlobalContext* globalCtx) { +void DmGm_Init(Actor* thisx, PlayState* play) { DmGm* this = THIS; - this->unk_2AC = SubS_GetObjectIndex(OBJECT_AN4, globalCtx); - this->unk_2AD = SubS_GetObjectIndex(OBJECT_MSMO, globalCtx); + this->unk_2AC = SubS_GetObjectIndex(OBJECT_AN4, play); + this->unk_2AD = SubS_GetObjectIndex(OBJECT_MSMO, play); this->actionFunc = func_80C248A8; } -void DmGm_Destroy(Actor* thisx, GlobalContext* globalCtx) { +void DmGm_Destroy(Actor* thisx, PlayState* play) { } -void DmGm_Update(Actor* thisx, GlobalContext* globalCtx) { +void DmGm_Update(Actor* thisx, PlayState* play) { DmGm* this = THIS; - this->actionFunc(this, globalCtx); + this->actionFunc(this, play); - func_80C2478C(this, globalCtx); + func_80C2478C(this, play); if (this->actor.draw != NULL) { - func_80C24360(this, globalCtx); + func_80C24360(this, play); func_80C24504(this); } - Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 30.0f, 12.0f, 0.0f, 4); + Actor_UpdateBgCheckInfo(play, &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) { +void DmGm_PostLimbDraw(PlayState* play, 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); + OPEN_DISPS(play->state.gfxCtx); - Matrix_StatePush(); - Matrix_JointPosition(&D_80C25218, &D_80C25224); + 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); + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPSegment(POLY_OPA_DISP++, 0x06, play->objectCtx.status[sp2A].segment); gSPDisplayList(POLY_OPA_DISP++, gMoonMaskDL); - gSPSegment(POLY_OPA_DISP++, 0x06, globalCtx->objectCtx.status[sp2B].segment); + gSPSegment(POLY_OPA_DISP++, 0x06, play->objectCtx.status[sp2B].segment); - Matrix_StatePop(); + Matrix_Pop(); - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->state.gfxCtx); } if (limbIndex == OBJECT_AN1_LIMB_09) { - Matrix_MultiplyVector3fByState(&D_80C2522C, &this->actor.focus.pos); + 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) { +void DmGm_TransformLimbDraw(PlayState* play, s32 limbIndex, Actor* thisx) { DmGm* this = THIS; - s16 phi_v1; - s16 phi_v0; + s16 stepRot; + s16 overrideRot; if (!(this->unk_2AE & 1)) { if (this->unk_2AE & 2) { - phi_v0 = 1; + overrideRot = true; } else { - phi_v0 = 0; + overrideRot = false; } - phi_v1 = 1; + stepRot = true; } else { - phi_v1 = 0; - phi_v0 = 0; + stepRot = false; + overrideRot = false; } if (limbIndex == OBJECT_AN1_LIMB_09) { - func_8013AD9C(this->unk_2BE + this->unk_2C2 + 0x4000, - this->unk_2C0 + this->unk_2C4 + this->actor.shape.rot.y + 0x4000, &this->unk_18C, &this->unk_1A4, - phi_v1, phi_v0); - Matrix_StatePop(); - Matrix_InsertTranslation(this->unk_18C.x, this->unk_18C.y, this->unk_18C.z, MTXMODE_NEW); + 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_RotateY(this->unk_1A4.y, MTXMODE_APPLY); - Matrix_InsertXRotation_s(this->unk_1A4.x, MTXMODE_APPLY); - Matrix_InsertZRotation_s(this->unk_1A4.z, MTXMODE_APPLY); - Matrix_StatePush(); + 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) { - func_8013AD9C(this->unk_2C2 + 0x4000, this->unk_2C4 + this->actor.shape.rot.y + 0x4000, &this->unk_194, - &this->unk_1AA, phi_v1, phi_v0); - Matrix_StatePop(); - Matrix_InsertTranslation(this->unk_194.x, this->unk_194.y, this->unk_194.z, MTXMODE_NEW); + 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_RotateY(this->unk_1AA.y, MTXMODE_APPLY); - Matrix_InsertXRotation_s(this->unk_1AA.x, MTXMODE_APPLY); - Matrix_InsertZRotation_s(this->unk_1AA.z, MTXMODE_APPLY); - Matrix_StatePush(); + 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(); } } @@ -351,19 +351,19 @@ TexturePtr D_80C25244[] = { object_an1_Tex_00FDA0, object_an1_Tex_00F9A0, object_an1_Tex_0103A0, }; -void func_80C25000(Actor* thisx, GlobalContext* globalCtx) { +void func_80C25000(Actor* thisx, PlayState* play) { DmGm* this = THIS; - OPEN_DISPS(globalCtx->state.gfxCtx); + OPEN_DISPS(play->state.gfxCtx); - func_8012C28C(globalCtx->state.gfxCtx); + func_8012C28C(play->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, + SkelAnime_DrawTransformFlexOpa(play, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, NULL, DmGm_PostLimbDraw, DmGm_TransformLimbDraw, &this->actor); - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->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 6f2307378..b7e45a3a1 100644 --- a/src/overlays/actors/ovl_Dm_Gm/z_dm_gm.h +++ b/src/overlays/actors/ovl_Dm_Gm/z_dm_gm.h @@ -6,34 +6,34 @@ struct DmGm; -typedef void (*DmGmActionFunc)(struct DmGm*, GlobalContext*); +typedef void (*DmGmActionFunc)(struct DmGm*, PlayState*); typedef struct DmGm { - /* 0x0000 */ Actor actor; - /* 0x0144 */ SkelAnime skelAnime; - /* 0x0188 */ DmGmActionFunc actionFunc; - /* 0x018C */ Vec3f unk_18C; - /* 0x018C */ Vec3f unk_194; - /* 0x01A4 */ Vec3s unk_1A4; - /* 0x01A4 */ Vec3s unk_1AA; - /* 0x01B0 */ Vec3s jointTable[OBJECT_AN1_LIMB_MAX]; - /* 0x022E */ Vec3s morphTable[OBJECT_AN1_LIMB_MAX]; - /* 0x02AC */ s8 unk_2AC; - /* 0x02AD */ s8 unk_2AD; - /* 0x02AE */ u16 unk_2AE; - /* 0x02B0 */ u8 unk_2B0; - /* 0x02B4 */ Actor* unk_2B4; - /* 0x02B8 */ s16 unk_2B8; - /* 0x02BA */ s16 unk_2BA; - /* 0x02BC */ s16 unk_2BC; - /* 0x02BE */ s16 unk_2BE; - /* 0x02C0 */ s16 unk_2C0; - /* 0x02C2 */ s16 unk_2C2; - /* 0x02C4 */ s16 unk_2C4; - /* 0x02C8 */ s32 unk_2C8; - /* 0x02CC */ s32 unk_2CC; - /* 0x02D0 */ s32 unk_2D0; - /* 0x02D4 */ s32 unk_2D4; + /* 0x000 */ Actor actor; + /* 0x144 */ SkelAnime skelAnime; + /* 0x188 */ DmGmActionFunc actionFunc; + /* 0x18C */ Vec3f unk_18C; + /* 0x18C */ Vec3f unk_194; + /* 0x1A4 */ Vec3s unk_1A4; + /* 0x1A4 */ Vec3s unk_1AA; + /* 0x1B0 */ Vec3s jointTable[OBJECT_AN1_LIMB_MAX]; + /* 0x22E */ Vec3s morphTable[OBJECT_AN1_LIMB_MAX]; + /* 0x2AC */ s8 unk_2AC; + /* 0x2AD */ s8 unk_2AD; + /* 0x2AE */ u16 unk_2AE; + /* 0x2B0 */ u8 unk_2B0; + /* 0x2B4 */ Actor* unk_2B4; + /* 0x2B8 */ s16 unk_2B8; + /* 0x2BA */ s16 unk_2BA; + /* 0x2BC */ s16 unk_2BC; + /* 0x2BE */ s16 unk_2BE; + /* 0x2C0 */ s16 unk_2C0; + /* 0x2C2 */ s16 unk_2C2; + /* 0x2C4 */ s16 unk_2C4; + /* 0x2C8 */ s32 unk_2C8; + /* 0x2CC */ s32 unk_2CC; + /* 0x2D0 */ s32 unk_2D0; + /* 0x2D4 */ s32 unk_2D4; } DmGm; // size = 0x2D8 extern const ActorInit Dm_Gm_InitVars; diff --git a/src/overlays/actors/ovl_Dm_Hina/z_dm_hina.c b/src/overlays/actors/ovl_Dm_Hina/z_dm_hina.c index a30e83620..07c2d2bdd 100644 --- a/src/overlays/actors/ovl_Dm_Hina/z_dm_hina.c +++ b/src/overlays/actors/ovl_Dm_Hina/z_dm_hina.c @@ -10,15 +10,15 @@ #define THIS ((DmHina*)thisx) -void DmHina_Init(Actor* thisx, GlobalContext* globalCtx); -void DmHina_Destroy(Actor* thisx, GlobalContext* globalCtx); -void DmHina_Update(Actor* thisx, GlobalContext* globalCtx); -void DmHina_Draw(Actor* thisx, GlobalContext* globalCtx); +void DmHina_Init(Actor* thisx, PlayState* play); +void DmHina_Destroy(Actor* thisx, PlayState* play); +void DmHina_Update(Actor* thisx, PlayState* play); +void DmHina_Draw(Actor* thisx, PlayState* play); -void func_80A1F470(DmHina* this, GlobalContext* globalCtx); -void func_80A1F56C(DmHina* this, GlobalContext* globalCtx); -void func_80A1F5AC(DmHina* this, GlobalContext* globalCtx); -void func_80A1F63C(DmHina* this, GlobalContext* globalCtx); +void func_80A1F470(DmHina* this, PlayState* play); +void func_80A1F56C(DmHina* this, PlayState* play); +void func_80A1F5AC(DmHina* this, PlayState* play); +void func_80A1F63C(DmHina* this, PlayState* play); #if 0 const ActorInit Dm_Hina_InitVars = { diff --git a/src/overlays/actors/ovl_Dm_Hina/z_dm_hina.h b/src/overlays/actors/ovl_Dm_Hina/z_dm_hina.h index 00385a1d1..02d12ee7d 100644 --- a/src/overlays/actors/ovl_Dm_Hina/z_dm_hina.h +++ b/src/overlays/actors/ovl_Dm_Hina/z_dm_hina.h @@ -5,15 +5,15 @@ struct DmHina; -typedef void (*DmHinaActionFunc)(struct DmHina*, GlobalContext*); +typedef void (*DmHinaActionFunc)(struct DmHina*, PlayState*); typedef struct DmHina { - /* 0x0000 */ Actor actor; - /* 0x0144 */ DmHinaActionFunc actionFunc; - /* 0x0148 */ char unk_148[0x10]; - /* 0x0158 */ f32 unk_158; - /* 0x015C */ f32 unk_15C; - /* 0x0160 */ char unk_160[0x24]; + /* 0x000 */ Actor actor; + /* 0x144 */ DmHinaActionFunc actionFunc; + /* 0x148 */ char unk_148[0x10]; + /* 0x158 */ f32 unk_158; + /* 0x15C */ f32 unk_15C; + /* 0x160 */ char unk_160[0x24]; } DmHina; // size = 0x184 extern const ActorInit Dm_Hina_InitVars; diff --git a/src/overlays/actors/ovl_Dm_Nb/z_dm_nb.c b/src/overlays/actors/ovl_Dm_Nb/z_dm_nb.c index 102ecd95e..3dcde3787 100644 --- a/src/overlays/actors/ovl_Dm_Nb/z_dm_nb.c +++ b/src/overlays/actors/ovl_Dm_Nb/z_dm_nb.c @@ -11,10 +11,10 @@ #define THIS ((DmNb*)thisx) -void DmNb_Init(Actor* thisx, GlobalContext* globalCtx); -void DmNb_Destroy(Actor* thisx, GlobalContext* globalCtx); -void DmNb_Update(Actor* thisx, GlobalContext* globalCtx); -void DmNb_Draw(Actor* thisx, GlobalContext* globalCtx); +void DmNb_Init(Actor* thisx, PlayState* play); +void DmNb_Destroy(Actor* thisx, PlayState* play); +void DmNb_Update(Actor* thisx, PlayState* play); +void DmNb_Draw(Actor* thisx, PlayState* play); const ActorInit Dm_Nb_InitVars = { ACTOR_DM_NB, @@ -28,37 +28,37 @@ const ActorInit Dm_Nb_InitVars = { (ActorFunc)DmNb_Draw, }; -static AnimationInfoS D_80C1E200[] = { { &object_nb_Anim_000990, 1.0f, 0, -1, ANIMMODE_LOOP, 0 } }; +static AnimationInfoS sAnimationInfo[] = { { &object_nb_Anim_000990, 1.0f, 0, -1, ANIMMODE_LOOP, 0 } }; s32 func_80C1DED0(DmNb* this, s32 arg1) { s32 ret = false; if (arg1 != this->unk1F0) { this->unk1F0 = arg1; - ret = SubS_ChangeAnimationByInfoS(&this->skelAnime, D_80C1E200, arg1); + ret = SubS_ChangeAnimationByInfoS(&this->skelAnime, sAnimationInfo, arg1); } return ret; } -void func_80C1DF18(DmNb* this, GlobalContext* globalCtx) { +void func_80C1DF18(DmNb* this, PlayState* play) { s32 sp2C[] = { 0, 0, 0, 0, 0 }; - u16 actionUnk0; - s32 actionIndex; + u16 csAction; + s32 csActionIndex; - if (globalCtx->csCtx.state != 0) { + if (play->csCtx.state != 0) { if (this->unk1F8 == 0) { this->unk1EC = 0xFF; this->unk1F8 = 1; this->unk1F4 = this->unk1F0; } - 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]); + if (Cutscene_CheckActorAction(play, 0x232)) { + csActionIndex = Cutscene_GetActorActionIndex(play, 0x232); + csAction = play->csCtx.actorActions[csActionIndex]->action; + if (this->unk1EC != (u8)csAction) { + this->unk1EC = csAction; + func_80C1DED0(this, sp2C[csAction]); } - Cutscene_ActorTranslateAndYaw(&this->actor, globalCtx, actionIndex); + Cutscene_ActorTranslateAndYaw(&this->actor, play, csActionIndex); } } else if (this->unk1F8 != 0) { this->unk1F8 = 0; @@ -66,12 +66,11 @@ void func_80C1DF18(DmNb* this, GlobalContext* globalCtx) { } } -void DmNb_Init(Actor* thisx, GlobalContext* globalCtx) { +void DmNb_Init(Actor* thisx, PlayState* play) { DmNb* this = THIS; ActorShape_Init(&this->actor.shape, 0.0f, NULL, 0.0f); - SkelAnime_InitFlex(globalCtx, &this->skelAnime, &object_nb_Skel_008C40, NULL, this->jointTable, this->morphTable, - 8); + SkelAnime_InitFlex(play, &this->skelAnime, &object_nb_Skel_008C40, NULL, this->jointTable, this->morphTable, 8); this->unk1F0 = -1; func_80C1DED0(this, 0); this->actor.flags &= ~ACTOR_FLAG_1; @@ -79,24 +78,24 @@ void DmNb_Init(Actor* thisx, GlobalContext* globalCtx) { this->actionFunc = func_80C1DF18; } -void DmNb_Destroy(Actor* thisx, GlobalContext* globalCtx) { +void DmNb_Destroy(Actor* thisx, PlayState* play) { } -void DmNb_Update(Actor* thisx, GlobalContext* globalCtx) { +void DmNb_Update(Actor* thisx, PlayState* play) { DmNb* this = THIS; - this->actionFunc(this, globalCtx); + this->actionFunc(this, play); SkelAnime_Update(&this->skelAnime); - Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 30.0f, 12.0f, 0.0f, 4); + Actor_UpdateBgCheckInfo(play, &this->actor, 30.0f, 12.0f, 0.0f, 4); } -void DmNb_TransformLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Actor* thisx) { +void DmNb_TransformLimbDraw(PlayState* play, s32 limbIndex, Actor* thisx) { } -void DmNb_Draw(Actor* thisx, GlobalContext* globalCtx) { +void DmNb_Draw(Actor* thisx, PlayState* play) { DmNb* this = THIS; - func_8012C5B0(globalCtx->state.gfxCtx); - SkelAnime_DrawTransformFlexOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, + func_8012C5B0(play->state.gfxCtx); + SkelAnime_DrawTransformFlexOpa(play, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, NULL, NULL, DmNb_TransformLimbDraw, &this->actor); } diff --git a/src/overlays/actors/ovl_Dm_Nb/z_dm_nb.h b/src/overlays/actors/ovl_Dm_Nb/z_dm_nb.h index a417ea070..eafc4ef99 100644 --- a/src/overlays/actors/ovl_Dm_Nb/z_dm_nb.h +++ b/src/overlays/actors/ovl_Dm_Nb/z_dm_nb.h @@ -5,7 +5,7 @@ struct DmNb; -typedef void (*DmNbActionFunc)(struct DmNb*, GlobalContext*); +typedef void (*DmNbActionFunc)(struct DmNb*, PlayState*); typedef struct DmNb { /* 0x000 */ Actor actor; 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 ef81bc467..4e3915af0 100644 --- a/src/overlays/actors/ovl_Dm_Opstage/z_dm_opstage.c +++ b/src/overlays/actors/ovl_Dm_Opstage/z_dm_opstage.c @@ -1,25 +1,23 @@ /* * File: z_dm_opstage.c * Overlay: ovl_Dm_Opstage - * Description: Lost Woods cutscene objects + * Description: Lost Woods Cutscene Trees and Floor */ #include "z_dm_opstage.h" +#include "objects/object_keikoku_demo/object_keikoku_demo.h" #define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_20) #define THIS ((DmOpstage*)thisx) -void DmOpstage_Init(Actor* thisx, GlobalContext* globalCtx); -void DmOpstage_Destroy(Actor* thisx, GlobalContext* globalCtx); -void DmOpstage_Update(Actor* thisx, GlobalContext* globalCtx); -void DmOpstage_Draw(Actor* thisx, GlobalContext* globalCtx); +void DmOpstage_Init(Actor* thisx, PlayState* play); +void DmOpstage_Destroy(Actor* thisx, PlayState* play); +void DmOpstage_Update(Actor* thisx, PlayState* play); +void DmOpstage_Draw(Actor* thisx, PlayState* play); -void func_80A9FA58(DmOpstage* this, GlobalContext* globalCtx); +void DmOpstage_FollowCutsceneScript(DmOpstage* this, PlayState* play); -void DmOpstage_SetupAction(DmOpstage* this, DmOpstageActionFunc actionFunc); - -#if 0 const ActorInit Dm_Opstage_InitVars = { ACTOR_DM_OPSTAGE, ACTORCAT_ITEMACTION, @@ -32,26 +30,109 @@ 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, PlayState* play) { + 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); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Opstage/DmOpstage_SetupAction.s") + if (DMOPSTAGE_GET_TYPE(&this->dyna.actor) == DMOPSTAGE_TYPE_GROUND) { + DynaPolyActor_Init(&this->dyna, 0); + DynaPolyActor_LoadMesh(play, &this->dyna, &gKeikokuDemoFloorColliderHeader); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Opstage/DmOpstage_Init.s") + if (DMOPSTAGE_GET_TYPE(&this->dyna.actor) > DMOPSTAGE_TYPE_GROUND) { + // trees move their world pos to map origin/center, then draw at their starting position + this->drawOffset.x = this->dyna.actor.world.pos.x; + this->drawOffset.y = this->dyna.actor.world.pos.y; + this->drawOffset.z = this->dyna.actor.world.pos.z; + this->dyna.actor.world.pos.x = 0.0f; + this->dyna.actor.world.pos.y = 0.0f; + this->dyna.actor.world.pos.z = 0.0f; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Opstage/DmOpstage_Destroy.s") +void DmOpstage_Destroy(Actor* thisx, PlayState* play) { + DmOpstage* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Opstage/func_80A9FA58.s") + if (DMOPSTAGE_GET_TYPE(&this->dyna.actor) == DMOPSTAGE_TYPE_GROUND) { + DynaPoly_DeleteBgActor(play, &play->colCtx.dyna, this->dyna.bgId); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Opstage/DmOpstage_Update.s") +void DmOpstage_FollowCutsceneScript(DmOpstage* this, PlayState* play) { + s32 actionIndex; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Opstage/DmOpstage_Draw.s") + if (DMOPSTAGE_GET_TYPE(&this->dyna.actor) == DMOPSTAGE_TYPE_GROUND) { + if (Cutscene_CheckActorAction(play, 0x73)) { + actionIndex = Cutscene_GetActorActionIndex(play, 0x73); + if (play->csCtx.actorActions[actionIndex]->action == 2) { + this->dyna.actor.scale.x = 0.075f; + this->dyna.actor.scale.z = 0.3f; + } else { + this->dyna.actor.scale.x = 0.1f; + this->dyna.actor.scale.z = 0.1f; + } + Cutscene_ActorTranslateAndYaw(&this->dyna.actor, play, actionIndex); + } + } else if (Cutscene_CheckActorAction(play, DMOPSTAGE_GET_ACTORACTION(&this->dyna.actor) + 0x74)) { + Cutscene_ActorTranslateAndYaw( + &this->dyna.actor, play, + Cutscene_GetActorActionIndex(play, DMOPSTAGE_GET_ACTORACTION(&this->dyna.actor) + 0x74)); + } +} + +void DmOpstage_Update(Actor* thisx, PlayState* play) { + DmOpstage* this = THIS; + + this->actionFunc(this, play); + if ((play->sceneNum == SCENE_SPOT00) && (gSaveContext.sceneSetupIndex == 0) && (play->csCtx.frames == 480)) { + // This actor is responsible for playing the fairy sound during the exposition in the intro, + // during the transition to Lost Woods, before Ocarina gets stolen. + func_8019F128(NA_SE_EV_NAVY_FLY_REBIRTH); + } +} + +void DmOpstage_Draw(Actor* thisx, PlayState* play) { + DmOpstage* this = THIS; + + if (DMOPSTAGE_GET_TYPE(&this->dyna.actor) > DMOPSTAGE_TYPE_GROUND) { + // Assumption: worldPos is being manipulated by cutscene + Matrix_Translate(this->dyna.actor.world.pos.x + this->drawOffset.x, + this->dyna.actor.world.pos.y + this->drawOffset.y, + this->dyna.actor.world.pos.z + this->drawOffset.z, MTXMODE_NEW); + Matrix_RotateYS(this->dyna.actor.world.rot.y, MTXMODE_APPLY); + Matrix_Scale(0.1f, 0.1f, 0.1f, MTXMODE_APPLY); + } + + switch (DMOPSTAGE_GET_TYPE(&this->dyna.actor)) { + case DMOPSTAGE_TYPE_GROUND: + Gfx_DrawDListOpa(play, gKeikokuDemoFloorDL); + Gfx_DrawDListXlu(play, gKeikokuDemoFloorEmptyDL); + break; + + case DMOPSTAGE_TYPE_ROOT_TREE: + Gfx_DrawDListOpa(play, gKeikokuDemoTallTreeWithRootBaseDL); + Gfx_DrawDListXlu(play, gKeikokuDemoTallTreeWithRootBaseEmptyDL); + break; + + case DMOPSTAGE_TYPE_CUT_TREE: + Gfx_DrawDListOpa(play, gKeikokuDemoTallTreeCutDL); + Gfx_DrawDListXlu(play, gKeikokuDemoTallTreeCutEmptyDL); + break; + + case DMOPSTAGE_TYPE_STRAIGHT_TREE: + Gfx_DrawDListOpa(play, gKeikokuDemoTallTreeStraightDL); + Gfx_DrawDListXlu(play, gKeikokuDemoTallTreeStraightEmptyDL); + break; + } +} diff --git a/src/overlays/actors/ovl_Dm_Opstage/z_dm_opstage.h b/src/overlays/actors/ovl_Dm_Opstage/z_dm_opstage.h index b0d0637e6..073efa1bf 100644 --- a/src/overlays/actors/ovl_Dm_Opstage/z_dm_opstage.h +++ b/src/overlays/actors/ovl_Dm_Opstage/z_dm_opstage.h @@ -3,15 +3,25 @@ #include "global.h" +#define DMOPSTAGE_GET_TYPE(thisx) ((thisx)->params & 0xFF) +#define DMOPSTAGE_GET_ACTORACTION(thisx) (((thisx)->params >> 8) & 0xFF) + struct DmOpstage; -typedef void (*DmOpstageActionFunc)(struct DmOpstage*, GlobalContext*); +typedef void (*DmOpstageActionFunc)(struct DmOpstage*, PlayState*); + +typedef enum { + /* 0 */ DMOPSTAGE_TYPE_GROUND, + /* 1 */ DMOPSTAGE_TYPE_ROOT_TREE, + /* 2 */ DMOPSTAGE_TYPE_CUT_TREE, + /* 3 */ DMOPSTAGE_TYPE_STRAIGHT_TREE, +} DmOpStageTypes; typedef struct DmOpstage { - /* 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 drawOffset; } DmOpstage; // size = 0x1B0 extern const ActorInit Dm_Opstage_InitVars; 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 bb8b735a4..afcd2b55d 100644 --- a/src/overlays/actors/ovl_Dm_Ravine/z_dm_ravine.c +++ b/src/overlays/actors/ovl_Dm_Ravine/z_dm_ravine.c @@ -10,11 +10,11 @@ #define THIS ((DmRavine*)thisx) -void DmRavine_Init(Actor* thisx, GlobalContext* globalCtx); -void DmRavine_Destroy(Actor* thisx, GlobalContext* globalCtx); -void DmRavine_DoNothing(DmRavine* this, GlobalContext* globalCtx); -void DmRavine_Update(Actor* thisx, GlobalContext* globalCtx); -void DmRavine_Draw(Actor* thisx, GlobalContext* globalCtx); +void DmRavine_Init(Actor* thisx, PlayState* play); +void DmRavine_Destroy(Actor* thisx, PlayState* play); +void DmRavine_DoNothing(DmRavine* this, PlayState* play); +void DmRavine_Update(Actor* thisx, PlayState* play); +void DmRavine_Draw(Actor* thisx, PlayState* play); const ActorInit Dm_Ravine_InitVars = { ACTOR_DM_RAVINE, @@ -28,29 +28,30 @@ const ActorInit Dm_Ravine_InitVars = { (ActorFunc)DmRavine_Draw, }; -void DmRavine_Init(Actor* thisx, GlobalContext* globalCtx) { +void DmRavine_Init(Actor* thisx, PlayState* play) { + s32 pad; DmRavine* this = THIS; - u8 flag = gSaveContext.save.weekEventReg[0]; - if (((flag & 0x10) | cREG(0)) != 0) { + + if (((((void)0, gSaveContext.save.weekEventReg[0]) & 0x10) | cREG(0)) != 0) { Actor_MarkForDeath(&this->actor); return; } this->isActive = false; - globalCtx->roomCtx.unk7A[0] = 1; - globalCtx->roomCtx.unk7A[1] = 0; + play->roomCtx.unk7A[0] = 1; + play->roomCtx.unk7A[1] = 0; this->state = 0; Actor_SetScale(&this->actor, 1.0f); this->actionFunc = DmRavine_DoNothing; } -void DmRavine_Destroy(Actor* thisx, GlobalContext* globalCtx) { +void DmRavine_Destroy(Actor* thisx, PlayState* play) { } -void DmRavine_DoNothing(DmRavine* this, GlobalContext* globalCtx) { +void DmRavine_DoNothing(DmRavine* this, PlayState* play) { } -void DmRavine_Update(Actor* thisx, GlobalContext* globalCtx) { +void DmRavine_Update(Actor* thisx, PlayState* play) { DmRavine* this = THIS; RoomContext* roomCtx; @@ -59,12 +60,12 @@ void DmRavine_Update(Actor* thisx, GlobalContext* globalCtx) { return; case DM_RAVINE_STATE_ACTIVE: this->isActive = true; - globalCtx->roomCtx.unk7A[1]++; - if (globalCtx->roomCtx.unk7A[1] > 254) { - globalCtx->roomCtx.unk7A[1] = 254; - if (globalCtx->csCtx.frames > 700) { - globalCtx->roomCtx.unk7A[1] = 255; - globalCtx->roomCtx.unk7A[0] = 0; + play->roomCtx.unk7A[1]++; + if (play->roomCtx.unk7A[1] > 254) { + play->roomCtx.unk7A[1] = 254; + if (play->csCtx.frames > 700) { + play->roomCtx.unk7A[1] = 255; + play->roomCtx.unk7A[0] = 0; this->state++; // -> DM_RAVINE_STATE_PENDING_DEATH } } @@ -75,5 +76,5 @@ void DmRavine_Update(Actor* thisx, GlobalContext* globalCtx) { } } -void DmRavine_Draw(Actor* thisx, GlobalContext* globalCtx) { +void DmRavine_Draw(Actor* thisx, PlayState* play) { } diff --git a/src/overlays/actors/ovl_Dm_Ravine/z_dm_ravine.h b/src/overlays/actors/ovl_Dm_Ravine/z_dm_ravine.h index 87e77f159..d634ec5e9 100644 --- a/src/overlays/actors/ovl_Dm_Ravine/z_dm_ravine.h +++ b/src/overlays/actors/ovl_Dm_Ravine/z_dm_ravine.h @@ -5,7 +5,7 @@ struct DmRavine; -typedef void (*DmRavineActionFunc)(struct DmRavine*, GlobalContext*); +typedef void (*DmRavineActionFunc)(struct DmRavine*, PlayState*); typedef enum { /* 0 */ DM_RAVINE_STATE_INITIALIZED, 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 4d5a20114..d9f775f6a 100644 --- a/src/overlays/actors/ovl_Dm_Sa/z_dm_sa.c +++ b/src/overlays/actors/ovl_Dm_Sa/z_dm_sa.c @@ -11,12 +11,12 @@ #define THIS ((DmSa*)thisx) -void DmSa_Init(Actor* thisx, GlobalContext* globalCtx); -void DmSa_Destroy(Actor* thisx, GlobalContext* globalCtx); -void DmSa_Update(Actor* thisx, GlobalContext* globalCtx); -void DmSa_Draw(Actor* thisx, GlobalContext* globalCtx); +void DmSa_Init(Actor* thisx, PlayState* play); +void DmSa_Destroy(Actor* thisx, PlayState* play); +void DmSa_Update(Actor* thisx, PlayState* play); +void DmSa_Draw(Actor* thisx, PlayState* play); -void DmSa_DoNothing(DmSa* this, GlobalContext* globalCtx); +void DmSa_DoNothing(DmSa* this, PlayState* play); const ActorInit Dm_Sa_InitVars = { ACTOR_DM_SA, @@ -30,7 +30,7 @@ const ActorInit Dm_Sa_InitVars = { (ActorFunc)DmSa_Draw, }; -static AnimationInfo D_80A2ED00[] = { { &object_stk_Anim_00CC94, 1.0f, 0, -1.0f, ANIMMODE_LOOP, 0 } }; +static AnimationInfo sAnimationInfo[] = { { &gSkullKidTPoseAnim, 1.0f, 0, -1.0f, ANIMMODE_LOOP, 0 } }; void func_80A2E960(SkelAnime* arg0, AnimationInfo* animations, u16 index) { f32 frameCount; @@ -45,41 +45,41 @@ void func_80A2E960(SkelAnime* arg0, AnimationInfo* animations, u16 index) { animations->mode, animations->morphFrames); } -void DmSa_Init(Actor* thisx, GlobalContext* globalCtx) { +void DmSa_Init(Actor* thisx, PlayState* play) { DmSa* this = THIS; this->unk2E0 = 0; 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); - func_80A2E960(&this->skelAnime, D_80A2ED00, 0); + SkelAnime_InitFlex(play, &this->skelAnime, &gSkullKidSkel, NULL, NULL, NULL, 0); + func_80A2E960(&this->skelAnime, sAnimationInfo, 0); Actor_SetScale(&this->actor, 0.01f); this->actionFunc = DmSa_DoNothing; } -void DmSa_Destroy(Actor* thisx, GlobalContext* globalCtx) { +void DmSa_Destroy(Actor* thisx, PlayState* play) { } -void DmSa_DoNothing(DmSa* this, GlobalContext* globalCtx) { +void DmSa_DoNothing(DmSa* this, PlayState* play) { } -void DmSa_Update(Actor* thisx, GlobalContext* globalCtx) { +void DmSa_Update(Actor* thisx, PlayState* play) { DmSa* this = THIS; SkelAnime_Update(&this->skelAnime); this->alpha += 0; - this->actionFunc(this, globalCtx); + this->actionFunc(this, play); } -s32 DmSa_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, Actor* thisx) { +s32 DmSa_OverrideLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, Actor* thisx) { return false; } -void DmSa_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx) { +void DmSa_PostLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx) { } -void DmSa_TransformLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Actor* thisx) { +void DmSa_TransformLimbDraw(PlayState* play, s32 limbIndex, Actor* thisx) { } Gfx* func_80A2EB58(GraphicsContext* gfxCtx, u32 alpha) { @@ -105,22 +105,22 @@ Gfx* func_80A2EBB0(GraphicsContext* gfxCtx, u32 alpha) { return dList; } -void DmSa_Draw(Actor* thisx, GlobalContext* globalCtx) { +void DmSa_Draw(Actor* thisx, PlayState* play) { DmSa* this = THIS; - OPEN_DISPS(globalCtx->state.gfxCtx); + OPEN_DISPS(play->state.gfxCtx); - func_8012C28C(globalCtx->state.gfxCtx); + func_8012C28C(play->state.gfxCtx); if (this->alpha < 0xFF) { - gSPSegment(POLY_OPA_DISP++, 0x0C, func_80A2EB58(globalCtx->state.gfxCtx, this->alpha)); + gSPSegment(POLY_OPA_DISP++, 0x0C, func_80A2EB58(play->state.gfxCtx, this->alpha)); } else { - gSPSegment(POLY_OPA_DISP++, 0x0C, func_80A2EBB0(globalCtx->state.gfxCtx, this->alpha)); + gSPSegment(POLY_OPA_DISP++, 0x0C, func_80A2EBB0(play->state.gfxCtx, this->alpha)); } - SkelAnime_DrawTransformFlexOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, + SkelAnime_DrawTransformFlexOpa(play, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, DmSa_OverrideLimbDraw, DmSa_PostLimbDraw, DmSa_TransformLimbDraw, &this->actor); - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->state.gfxCtx); } diff --git a/src/overlays/actors/ovl_Dm_Sa/z_dm_sa.h b/src/overlays/actors/ovl_Dm_Sa/z_dm_sa.h index e8b3f502f..d1d37128b 100644 --- a/src/overlays/actors/ovl_Dm_Sa/z_dm_sa.h +++ b/src/overlays/actors/ovl_Dm_Sa/z_dm_sa.h @@ -5,7 +5,7 @@ struct DmSa; -typedef void (*DmSaActionFunc)(struct DmSa*, GlobalContext*); +typedef void (*DmSaActionFunc)(struct DmSa*, PlayState*); typedef struct DmSa { /* 0x000 */ Actor actor; 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 6c9d11170..62c267322 100644 --- a/src/overlays/actors/ovl_Dm_Statue/z_dm_statue.c +++ b/src/overlays/actors/ovl_Dm_Statue/z_dm_statue.c @@ -11,10 +11,10 @@ #define THIS ((DmStatue*)thisx) -void DmStatue_Init(Actor* thisx, GlobalContext* globalCtx); -void DmStatue_Destroy(Actor* thisx, GlobalContext* globalCtx); -void DmStatue_Update(Actor* thisx, GlobalContext* globalCtx); -void DmStatue_Draw(Actor* thisx, GlobalContext* globalCtx); +void DmStatue_Init(Actor* thisx, PlayState* play); +void DmStatue_Destroy(Actor* thisx, PlayState* play); +void DmStatue_Update(Actor* thisx, PlayState* play); +void DmStatue_Draw(Actor* thisx, PlayState* play); const ActorInit Dm_Statue_InitVars = { ACTOR_DM_STATUE, @@ -28,19 +28,19 @@ const ActorInit Dm_Statue_InitVars = { (ActorFunc)DmStatue_Draw, }; -void DmStatue_Init(Actor* thisx, GlobalContext* globalCtx) { +void DmStatue_Init(Actor* thisx, PlayState* play) { DmStatue* this = THIS; Actor_SetScale(&this->actor, 10.0f); } -void DmStatue_Destroy(Actor* thisx, GlobalContext* globalCtx) { +void DmStatue_Destroy(Actor* thisx, PlayState* play) { } -void DmStatue_Update(Actor* thisx, GlobalContext* globalCtx) { +void DmStatue_Update(Actor* thisx, PlayState* play) { } -void DmStatue_Draw(Actor* thisx, GlobalContext* globalCtx) { - AnimatedMat_Draw(globalCtx, Lib_SegmentedToVirtual(object_smtower_Matanimheader_001788)); - Gfx_DrawDListXlu(globalCtx, object_smtower_DL_000520); +void DmStatue_Draw(Actor* thisx, PlayState* play) { + AnimatedMat_Draw(play, Lib_SegmentedToVirtual(object_smtower_Matanimheader_001788)); + Gfx_DrawDListXlu(play, object_smtower_DL_000520); } 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 08e515d26..1417d8094 100644 --- a/src/overlays/actors/ovl_Dm_Stk/z_dm_stk.c +++ b/src/overlays/actors/ovl_Dm_Stk/z_dm_stk.c @@ -1,11 +1,14 @@ /* * 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" @@ -13,25 +16,139 @@ #define THIS ((DmStk*)thisx) -void DmStk_Init(Actor* thisx, GlobalContext* globalCtx); -void DmStk_Destroy(Actor* thisx, GlobalContext* globalCtx); -void DmStk_Update(Actor* thisx, GlobalContext* globalCtx); -void DmStk_Draw(Actor* thisx, GlobalContext* globalCtx); +void DmStk_Init(Actor* thisx, PlayState* play); +void DmStk_Destroy(Actor* thisx, PlayState* play); +void DmStk_Update(Actor* thisx, PlayState* play); +void DmStk_Draw(Actor* thisx, PlayState* play); -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, PlayState* play); +void DmStk_DoNothing(DmStk* this, PlayState* play); +void DmStk_WaitForTelescope(DmStk* this, PlayState* play); +void DmStk_StartTelescopeCutscene(DmStk* this, PlayState* play); +void DmStk_ClockTower_StartIntroCutsceneVersion1(DmStk* this, PlayState* play); +void DmStk_ClockTower_WaitForIntroCutsceneVersion1ToEnd(DmStk* this, PlayState* play); +void DmStk_ClockTower_StartIntroCutsceneVersion2(DmStk* this, PlayState* play); +void DmStk_ClockTower_WaitForIntroCutsceneVersion2ToEnd(DmStk* this, PlayState* play); +void DmStk_ClockTower_StartDropOcarinaCutscene(DmStk* this, PlayState* play); +void DmStk_ClockTower_WaitForDropOcarinaCutsceneToEnd(DmStk* this, PlayState* play); +void DmStk_ClockTower_DeflectHit(DmStk* this, PlayState* play); +void DmStk_ClockTower_WaitForDeflectionToEnd(DmStk* this, PlayState* play); +void DmStk_ClockTower_IdleWithOcarina(DmStk* this, PlayState* play); +void DmStk_ClockTower_Idle(DmStk* this, PlayState* play); + +typedef enum { + /* 0 */ SK_ANIM_SHAKE_HEAD, + /* 1 */ SK_ANIM_WALK, + /* 2 */ SK_ANIM_LOOK_AROUND, // Not used in the final game + /* 3 */ SK_ANIM_IDLE, + /* 4 */ SK_ANIM_UNUSED_IDLE, // Unused duplicate of SK_ANIM_IDLE + /* 5 */ SK_ANIM_BENT_OVER_HEAD_TWITCH, + /* 6 */ SK_ANIM_GLITCHY_HORSE_RIDE_START, // Not used in the final game + /* 7 */ SK_ANIM_RECLINING_FLOAT, + /* 8 */ SK_ANIM_CURSE_START, + /* 9 */ SK_ANIM_CURSE_LOOP, + /* 10 */ SK_ANIM_LAUGH_START, + /* 11 */ SK_ANIM_LAUGH_LOOP, + /* 12 */ SK_ANIM_HIDE_OCARINA_START, + /* 13 */ SK_ANIM_HIDE_OCARINA_LOOP, + /* 14 */ SK_ANIM_PICK_UP_OCARINA_AND_START_PLAYING, + /* 15 */ SK_ANIM_PLAY_OCARINA_AND_LAUGH, + /* 16 */ SK_ANIM_PICK_UP_OCARINA, // Not used in the final game + /* 17 */ SK_ANIM_LOOK_AT_OCARINA, // Not used in the final game + /* 18 */ SK_ANIM_KICK_OVER_LINK, + /* 19 */ SK_ANIM_SEARCH_LINK, + /* 20 */ SK_ANIM_UNUSED_KICK_OVER_LINK, // Unused duplicate of SK_ANIM_KICK_OVER_LINK + /* 21 */ SK_ANIM_UNUSED_SEARCH_LINK, // Unused duplicate of SK_ANIM_SEARCH_LINK + /* 22 */ SK_ANIM_HORSE_RIDE_START, + /* 23 */ SK_ANIM_HORSE_RIDE_LOOP, + /* 24 */ SK_ANIM_RAISE_MASK_START, + /* 25 */ SK_ANIM_RAISE_MASK_LOOP, + /* 26 */ SK_ANIM_LOWER_MASK, + /* 27 */ SK_ANIM_JUMP_WHILE_HIDING_OCARINA, + /* 28 */ SK_ANIM_HORSE_RIDE_AND_ROTATE, // Used when Link gets thrown off his horse + /* 29 */ SK_ANIM_PLAY_OCARINA_WHILE_FLOATING, + /* 30 */ SK_ANIM_FLOATING_TURN_AROUND, + /* 31 */ SK_ANIM_OCARINA_JUGGLE, + /* 32 */ SK_ANIM_CALL_DOWN_MOON_START, + /* 33 */ SK_ANIM_CALL_DOWN_MOON_LOOP, + /* 34 */ SK_ANIM_SMACK_FAIRY_START, + /* 35 */ SK_ANIM_SMACK_FAIRY_LOOP, + /* 36 */ SK_ANIM_HIT_BY_BUBBLE, + /* 37 */ SK_ANIM_DROP_OCARINA, + /* 38 */ SK_ANIM_FLOATING_ARMS_CROSSED, + /* 39 */ SK_ANIM_DEFLECT_ATTACK, + /* 40 */ SK_ANIM_TELESCOPE_LOOK_UP_START, + /* 41 */ SK_ANIM_TELESCOPE_LOOK_UP_LOOP, + /* 42 */ SK_ANIM_SURPRISE_START, + /* 43 */ SK_ANIM_SURPRISE_LOOP, + /* 44 */ SK_ANIM_LOOK_AROUND_FOR_GIANTS_START, + /* 45 */ SK_ANIM_LOOK_AROUND_FOR_GIANTS_LOOP, + /* 46 */ SK_ANIM_HOLD_HEAD_AND_SHAKE_START, + /* 47 */ SK_ANIM_HOLD_HEAD_AND_SHAKE_LOOP, + /* 48 */ SK_ANIM_HOLD_HEAD_AND_SCREAM_START, + /* 49 */ SK_ANIM_HOLD_HEAD_AND_SCREAM_LOOP, + /* 50 */ SK_ANIM_HUDDLE_WITH_FAIRIES, + /* 51 */ SK_ANIM_SEARCH_MASK_SALESMAN, + /* 52 */ SK_ANIM_HOLD_UP_MASK_START, + /* 53 */ SK_ANIM_HOLD_UP_MASK_LOOP, + /* 54 */ SK_ANIM_SHIVER, + /* 55 */ SK_ANIM_DRAW, + /* 56 */ SK_ANIM_BENT_OVER_LOOK_UP, + /* 57 */ SK_ANIM_SPANK, + /* 58 */ SK_ANIM_HIP_SHAKE_AND_JUMP, + /* 59 */ SK_ANIM_PLAY_FLUTE, + /* 60 */ SK_ANIM_CARTWHEEL, + /* 61 */ SK_ANIM_LIE_FLAT, + /* 62 */ SK_ANIM_DANGLE_FROM_MASK_START, + /* 63 */ SK_ANIM_DANGLE_FROM_MASK_LOOP, + /* 64 */ SK_ANIM_DROPPED_FROM_MASK, + /* 65 */ SK_ANIM_LOOK_UP_AT_GIANTS, + /* 66 */ SK_ANIM_ASHAMED_START, + /* 67 */ SK_ANIM_ASHAMED_LOOP, + /* 68 */ SK_ANIM_LOOK_LEFT_START, + /* 69 */ SK_ANIM_LOOK_LEFT_LOOP, + /* 70 */ SK_ANIM_SNIFF, + /* 71 */ SK_ANIM_LAUGH_AFTER_SNIFF, +} SkullKidAnimation; + +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,111 +219,124 @@ static DamageTable sDamageTable = { /* Powder Keg */ DMG_ENTRY(1, 0xF), }; -static AnimationInfo sAnimations[] = { - { &object_stk_Anim_01C21C, 1.0f, 0.0f, -1.0f, ANIMMODE_LOOP, 0.0f }, - { &object_stk_Anim_01D3D0, 1.0f, 0.0f, -1.0f, ANIMMODE_LOOP, 0.0f }, - { &object_stk_Anim_001030, 1.0f, 0.0f, -1.0f, ANIMMODE_ONCE, 0.0f }, - { &object_stk_Anim_01D008, 1.0f, 0.0f, -1.0f, ANIMMODE_LOOP, 0.0f }, - { &object_stk_Anim_01D008, 1.0f, 0.0f, -1.0f, ANIMMODE_LOOP, 0.0f }, - { &object_stk_Anim_015C14, 1.0f, 0.0f, -1.0f, ANIMMODE_LOOP, 0.0f }, - { &object_stk2_Anim_0070DC, 1.0f, 0.0f, -1.0f, ANIMMODE_LOOP, 0.0f }, - { &object_stk2_Anim_00D830, 1.0f, 0.0f, -1.0f, ANIMMODE_LOOP, 0.0f }, - { &object_stk2_Anim_00055C, 1.0f, 0.0f, -1.0f, ANIMMODE_ONCE, 0.0f }, - { &object_stk2_Anim_00130C, 1.0f, 0.0f, -1.0f, ANIMMODE_LOOP, 0.0f }, - { &object_stk2_Anim_00C270, 1.0f, 0.0f, -1.0f, ANIMMODE_ONCE, 0.0f }, - { &object_stk2_Anim_00CBB8, 1.0f, 0.0f, -1.0f, ANIMMODE_LOOP, 0.0f }, - { &object_stk2_Anim_01AA80, 1.0f, 0.0f, -1.0f, ANIMMODE_ONCE, 0.0f }, - { &object_stk2_Anim_01D07C, 1.0f, 0.0f, -1.0f, ANIMMODE_LOOP, 0.0f }, - { &object_stk2_Anim_016910, 1.0f, 0.0f, -1.0f, ANIMMODE_ONCE, 0.0f }, - { &object_stk2_Anim_018ED0, 1.0f, 0.0f, -1.0f, ANIMMODE_LOOP, 0.0f }, - { &object_stk2_Anim_01DDE0, 1.0f, 0.0f, -1.0f, ANIMMODE_ONCE, 0.0f }, - { &object_stk2_Anim_01EF50, 1.0f, 0.0f, -1.0f, ANIMMODE_LOOP, 0.0f }, - { &object_stk2_Anim_02DC64, 1.0f, 0.0f, -1.0f, ANIMMODE_ONCE, 0.0f }, - { &object_stk2_Anim_02E9A0, 1.0f, 0.0f, -1.0f, ANIMMODE_LOOP, 0.0f }, - { &object_stk2_Anim_02DC64, 1.0f, 0.0f, -1.0f, ANIMMODE_ONCE, 0.0f }, - { &object_stk2_Anim_02E9A0, 1.0f, 0.0f, -1.0f, ANIMMODE_LOOP, 0.0f }, - { &object_stk2_Anim_0035C8, 1.0f, 0.0f, -1.0f, ANIMMODE_ONCE, 0.0f }, - { &object_stk2_Anim_0049C8, 1.0f, 0.0f, -1.0f, ANIMMODE_LOOP, 0.0f }, - { &object_stk2_Anim_0259F4, 1.0f, 0.0f, -1.0f, ANIMMODE_ONCE, 0.0f }, - { &object_stk2_Anim_0266C8, 1.0f, 0.0f, -1.0f, ANIMMODE_LOOP, 0.0f }, - { &object_stk2_Anim_026CF4, 1.0f, 0.0f, -1.0f, ANIMMODE_ONCE, 0.0f }, - { &object_stk2_Anim_01C114, 1.0f, 0.0f, -1.0f, ANIMMODE_ONCE, 0.0f }, - { &object_stk2_Anim_004580, 1.0f, 0.0f, -1.0f, ANIMMODE_ONCE, 0.0f }, - { &object_stk2_Anim_020CAC, 1.0f, 0.0f, -1.0f, ANIMMODE_LOOP, 0.0f }, - { &object_stk2_Anim_02200C, 1.0f, 0.0f, -1.0f, ANIMMODE_ONCE, 0.0f }, - { &object_stk2_Anim_02336C, 1.0f, 0.0f, -1.0f, ANIMMODE_LOOP, 0.0f }, - { &object_stk_Anim_002774, 1.0f, 0.0f, -1.0f, ANIMMODE_ONCE, 0.0f }, - { &object_stk_Anim_003068, 1.0f, 0.0f, -1.0f, ANIMMODE_LOOP, 0.0f }, - { &object_stk2_Anim_0101A4, 1.0f, 0.0f, -1.0f, ANIMMODE_ONCE, 0.0f }, - { &object_stk2_Anim_010B60, 1.0f, 0.0f, -1.0f, ANIMMODE_LOOP, 0.0f }, - { &object_stk2_Anim_02A2D8, 1.0f, 0.0f, -1.0f, ANIMMODE_ONCE, 0.0f }, - { &object_stk2_Anim_01F9E4, 1.0f, 0.0f, -1.0f, ANIMMODE_ONCE, 0.0f }, - { &object_stk2_Anim_029A04, 1.0f, 0.0f, -1.0f, ANIMMODE_LOOP, 0.0f }, - { &object_stk2_Anim_02AD54, 1.0f, 0.0f, -1.0f, ANIMMODE_ONCE, 0.0f }, - { &object_stk_Anim_00BB2C, 1.0f, 0.0f, -1.0f, ANIMMODE_ONCE, 0.0f }, - { &object_stk_Anim_00C964, 1.0f, 0.0f, -1.0f, ANIMMODE_LOOP, 0.0f }, - { &object_stk2_Anim_0110B4, 1.0f, 0.0f, -1.0f, ANIMMODE_ONCE, 0.0f }, - { &object_stk2_Anim_011FB0, 1.0f, 0.0f, -1.0f, ANIMMODE_LOOP, 0.0f }, - { &object_stk2_Anim_012A58, 1.0f, 0.0f, -1.0f, ANIMMODE_ONCE, 0.0f }, - { &object_stk2_Anim_0141E4, 1.0f, 0.0f, -1.0f, ANIMMODE_LOOP, 0.0f }, - { &object_stk2_Anim_00E6EC, 1.0f, 0.0f, -1.0f, ANIMMODE_ONCE, 0.0f }, - { &object_stk2_Anim_00EEC0, 1.0f, 0.0f, -1.0f, ANIMMODE_LOOP, 0.0f }, - { &object_stk2_Anim_027CF4, 1.0f, 0.0f, -1.0f, ANIMMODE_ONCE, 0.0f }, - { &object_stk2_Anim_028F28, 1.0f, 0.0f, -1.0f, ANIMMODE_LOOP, 0.0f }, - { &object_stk2_Anim_03323C, 1.0f, 0.0f, -1.0f, ANIMMODE_LOOP, 0.0f }, - { &object_stk2_Anim_031210, 1.0f, 0.0f, -1.0f, ANIMMODE_LOOP, 0.0f }, - { &object_stk2_Anim_0322FC, 1.0f, 0.0f, -1.0f, ANIMMODE_ONCE, 0.0f }, - { &object_stk2_Anim_032AE0, 1.0f, 0.0f, -1.0f, ANIMMODE_LOOP, 0.0f }, - { &object_stk2_Anim_03021C, 1.0f, 0.0f, -1.0f, ANIMMODE_LOOP, 0.0f }, - { &object_stk2_Anim_036964, 1.0f, 0.0f, -1.0f, ANIMMODE_ONCE, 0.0f }, - { &object_stk_Anim_016508, 1.0f, 0.0f, -1.0f, ANIMMODE_ONCE, 0.0f }, - { &object_stk_Anim_015028, 1.0f, 0.0f, -1.0f, ANIMMODE_LOOP, 0.0f }, - { &object_stk_Anim_014920, 1.0f, 0.0f, -1.0f, ANIMMODE_ONCE, 0.0f }, - { &object_stk2_Anim_02FA70, 1.0f, 0.0f, -1.0f, ANIMMODE_LOOP, 0.0f }, - { &object_stk2_Anim_037B94, 1.0f, 0.0f, -1.0f, ANIMMODE_ONCE, 0.0f }, - { &object_stk2_Anim_03967C, 1.0f, 0.0f, -1.0f, ANIMMODE_ONCE, 0.0f }, - { &object_stk2_Anim_03967C, 1.0f, 0.0f, -1.0f, ANIMMODE_ONCE, 0.0f }, - { &object_stk2_Anim_03A8F8, 1.0f, 0.0f, -1.0f, ANIMMODE_LOOP, 0.0f }, - { &object_stk2_Anim_034FD8, 1.0f, 0.0f, -1.0f, ANIMMODE_ONCE, 0.0f }, - { &object_stk3_Anim_005F44, 1.0f, 0.0f, -1.0f, ANIMMODE_LOOP, 0.0f }, - { &object_stk3_Anim_002CD8, 1.0f, 0.0f, -1.0f, ANIMMODE_ONCE, 0.0f }, - { &object_stk3_Anim_0039F0, 1.0f, 0.0f, -1.0f, ANIMMODE_LOOP, 0.0f }, - { &object_stk3_Anim_004554, 1.0f, 0.0f, -1.0f, ANIMMODE_ONCE, 0.0f }, - { &object_stk3_Anim_0051C0, 1.0f, 0.0f, -1.0f, ANIMMODE_LOOP, 0.0f }, - { &object_stk3_Anim_001374, 1.0f, 0.0f, -1.0f, ANIMMODE_ONCE, 0.0f }, - { &object_stk3_Anim_001EDC, 1.0f, 0.0f, -1.0f, ANIMMODE_LOOP, 0.0f }, +static AnimationInfo sAnimationInfo[] = { + { &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, PlayState* play) { + 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->animIndex >= SK_ANIM_SHAKE_HEAD) && (this->animIndex <= SK_ANIM_BENT_OVER_HEAD_TWITCH)) || + (this->animIndex == SK_ANIM_CALL_DOWN_MOON_START) || (this->animIndex == SK_ANIM_CALL_DOWN_MOON_LOOP) || + (this->animIndex == SK_ANIM_TELESCOPE_LOOK_UP_START) || (this->animIndex == SK_ANIM_TELESCOPE_LOOK_UP_LOOP)) { + objectIndex = this->objectStkObjectIndex; + } else if (this->animIndex >= SK_ANIM_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(play->objectCtx.status[objectIndex].segment); } } -void func_80A9FE3C(DmStk* this, GlobalContext* globalCtx, SkelAnime* skelAnime, AnimationInfo* animation, u16 index) { - func_80A9FDB0(this, globalCtx); +/** + * This function is always called with unusedExtraOffset = 0. + */ +void DmStk_ChangeAnim(DmStk* this, PlayState* play, SkelAnime* skelAnime, AnimationInfo* animationInfo, + u16 unusedExtraOffset) { + DmStk_LoadObjectForAnimation(this, play); - animation += index; + animationInfo += unusedExtraOffset; - Animation_Change(skelAnime, animation->animation, animation->playSpeed, animation->startFrame, - (animation->frameCount < 0.0f) ? Animation_GetLastFrame(&animation->animation->common) - : animation->frameCount, - animation->mode, animation->morphFrames); + Animation_Change(skelAnime, animationInfo->animation, animationInfo->playSpeed, animationInfo->startFrame, + (animationInfo->frameCount < 0.0f) ? Animation_GetLastFrame(animationInfo->animation) + : animationInfo->frameCount, + animationInfo->mode, animationInfo->morphFrames); } -void func_80A9FED8(DmStk* this, GlobalContext* globalCtx) { - switch (globalCtx->csCtx.frames + 20) { +/** + * 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, PlayState* play) { + switch (play->csCtx.frames + 20) { case 1195: Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_STALKIDS_APPEAR); break; @@ -291,14 +421,23 @@ void func_80A9FED8(DmStk* this, GlobalContext* globalCtx) { } } -void func_80AA00CC(DmStk* this, GlobalContext* globalCtx) { - if (globalCtx->csCtx.frames == 535) { +/** + * 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, PlayState* play) { + if (play->csCtx.frames == 535) { func_8019F128(NA_SE_EV_CLOCK_TOWER_BELL); } } -void func_80AA0100(DmStk* this, GlobalContext* globalCtx) { - switch (globalCtx->csCtx.frames) { +/** + * 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, PlayState* play) { + switch (play->csCtx.frames) { case 78: case 89: case 100: @@ -325,8 +464,12 @@ void func_80AA0100(DmStk* this, GlobalContext* globalCtx) { } } -void func_80AA0158(DmStk* this, GlobalContext* globalCtx) { - switch (globalCtx->csCtx.frames) { +/** + * Handles sound effects for the cutscene where Skull Kid steals Majora's Mask from + * the Happy Mask Salesman. + */ +void DmStk_PlaySfxForObtainingMajorasMaskCutscene(DmStk* this, PlayState* play) { + switch (play->csCtx.frames) { case 18: Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_STALKIDS_GASAGOSO); break; @@ -341,8 +484,13 @@ void func_80AA0158(DmStk* this, GlobalContext* globalCtx) { } } -void func_80AA01C0(DmStk* this, GlobalContext* globalCtx) { - switch (globalCtx->csCtx.frames) { +/** + * 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, PlayState* play) { + switch (play->csCtx.frames) { case 415: func_801A479C(&this->actor.projectedPos, NA_SE_EN_STALKIDS_FLOAT, 100); break; @@ -362,10 +510,15 @@ void func_80AA01C0(DmStk* this, GlobalContext* globalCtx) { } } -void func_80AA0264(DmStk* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(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, PlayState* play) { + Player* player = GET_PLAYER(play); - switch (globalCtx->csCtx.frames) { + switch (play->csCtx.frames) { case 10: func_801A479C(&this->actor.projectedPos, NA_SE_EN_STALKIDS_FLOAT, 50); break; @@ -375,7 +528,7 @@ void func_80AA0264(DmStk* this, GlobalContext* globalCtx) { break; case 365: - func_801A0654(&this->actor.projectedPos, NA_SE_EN_STALKIDS_FLOAT, 0); + AudioSfx_SetChannelIO(&this->actor.projectedPos, NA_SE_EN_STALKIDS_FLOAT, 0); break; case 650: @@ -405,15 +558,20 @@ void func_80AA0264(DmStk* this, GlobalContext* globalCtx) { if (player) {} - if ((globalCtx->csCtx.frames >= 263) && (globalCtx->csCtx.frames < 698)) { + if ((play->csCtx.frames >= 263) && (play->csCtx.frames < 698)) { Actor_PlaySfxAtPos(&player->actor, NA_SE_EN_STALKIDS_BODY_LEV - SFX_FLAG); } } -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, PlayState* play) { + static s32 sMoonCallTimer = 0; - switch (globalCtx->csCtx.frames) { + switch (play->csCtx.frames) { case 140: func_801A479C(&this->actor.projectedPos, NA_SE_EN_STALKIDS_FLOAT, 80); break; @@ -436,7 +594,7 @@ void func_80AA0420(DmStk* this, GlobalContext* globalCtx) { break; } - if ((this->unk_2E0 == 31) && (globalCtx->csCtx.frames < 700)) { + if ((this->animIndex == SK_ANIM_OCARINA_JUGGLE) && (play->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)) { @@ -444,35 +602,46 @@ void func_80AA0420(DmStk* this, GlobalContext* globalCtx) { } } - if (globalCtx->csCtx.frames >= 700) { - if (D_80AA3CB8 < 128) { - if ((D_80AA3CB8 & 0x1F) == 0) { + if (play->csCtx.frames >= 700) { + 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) { - if (globalCtx->csCtx.frames == 3) { +/** + * Handles sound effects for the cutscene where Skull Kid drops the Ocarina of Time. + */ +void DmStk_PlaySfxForDroppingOcarinaCutscene(DmStk* this, PlayState* play) { + if (play->csCtx.frames == 3) { Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_STAL06_SURPRISED); Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_STALKIDS_DOWN_K); } } -void func_80AA0634(DmStk* this, GlobalContext* globalCtx) { - if ((globalCtx->csCtx.frames >= 642) && (globalCtx->csCtx.frames < 845)) { +/** + * Handles sound effects for the cutscene where Skull Kid is shivering in the rain. + */ +void DmStk_PlaySfxForShiveringInRainCutscene(DmStk* this, PlayState* play) { + if ((play->csCtx.frames >= 642) && (play->csCtx.frames < 845)) { Actor_PlaySfxAtPos(&this->actor, NA_SE_NE_STAL23_COLD - SFX_FLAG); } } -void func_80AA066C(DmStk* this, GlobalContext* globalCtx) { - switch (globalCtx->csCtx.frames) { +/** + * Handles sound effects for the cutscene where Skull Kid is playing with Tatl and Tael + * in Termina Field. + */ +void DmStk_PlaySfxForPlayingWithFairiesCutscene(DmStk* this, PlayState* play) { + switch (play->csCtx.frames) { case 58: case 61: case 68: @@ -493,8 +662,13 @@ void func_80AA066C(DmStk* this, GlobalContext* globalCtx) { } } -void func_80AA071C(DmStk* this, GlobalContext* globalCtx) { - switch (globalCtx->csCtx.frames) { +/** + * 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, PlayState* play) { + switch (play->csCtx.frames) { case 5: func_801A4A28(12); break; @@ -505,10 +679,14 @@ void func_80AA071C(DmStk* this, GlobalContext* globalCtx) { } } -void func_80AA076C(DmStk* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(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, PlayState* play) { + Player* player = GET_PLAYER(play); - switch (globalCtx->csCtx.frames) { + switch (play->csCtx.frames) { case 5: func_801A4A28(12); break; @@ -550,11 +728,12 @@ void func_80AA076C(DmStk* this, GlobalContext* globalCtx) { break; case 2000: - func_801A5BD0(0x7F); + AudioSfx_MuteBanks((1 << BANK_PLAYER) | (1 << BANK_ITEM) | (1 << BANK_ENV) | (1 << BANK_ENEMY) | + (1 << BANK_SYSTEM) | (1 << BANK_OCARINA) | (1 << BANK_VOICE)); break; } - if (this->unk_2E0 == 0) { + if (this->animIndex == SK_ANIM_SHAKE_HEAD) { if (Animation_OnFrame(&this->skelAnime, 8.0f) || Animation_OnFrame(&this->skelAnime, 17.0f)) { Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_STALKIDS_MASK_OFF); } @@ -562,21 +741,26 @@ 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->animIndex == SK_ANIM_LAUGH_AFTER_SNIFF) { if (Animation_OnFrame(&this->skelAnime, 2.0f) || Animation_OnFrame(&this->skelAnime, 6.0f) || Animation_OnFrame(&this->skelAnime, 12.0f) || Animation_OnFrame(&this->skelAnime, 18.0f)) { Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_STALKIDS_MASK_OFF); } - } else if ((this->unk_2E0 == 70) && + } else if ((this->animIndex == SK_ANIM_SNIFF) && (Animation_OnFrame(&this->skelAnime, 16.0f) || Animation_OnFrame(&this->skelAnime, 23.0f))) { Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_STALKIDS_NOSE); } } -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, PlayState* play) { + static s32 sMoonCallTimer = 0; - switch (globalCtx->csCtx.frames) { + switch (play->csCtx.frames) { case 40: func_801A479C(&this->actor.projectedPos, NA_SE_EN_STALKIDS_FLOAT, 80); break; @@ -595,28 +779,33 @@ void func_80AA09DC(DmStk* this, GlobalContext* globalCtx) { break; } - if (globalCtx->csCtx.frames >= 408) { - if (D_80AA3CBC < 128) { - if ((D_80AA3CBC & 0x1F) == 0) { + if (play->csCtx.frames >= 408) { + 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, PlayState* play) { + 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) { + switch (play->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: @@ -636,11 +825,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: @@ -652,21 +841,21 @@ 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; } if (1) {} - if ((globalCtx->csCtx.frames >= 62) && (globalCtx->csCtx.frames < 273)) { - if ((Rand_ZeroOne() < 0.75f) && ((globalCtx->state.frames % 2) != 0)) { + if ((play->csCtx.frames >= 62) && (play->csCtx.frames < 273)) { + if ((Rand_ZeroOne() < 0.75f) && ((play->state.frames % 2) != 0)) { Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_STALKIDS_EARTHQUAKE); } } - if ((globalCtx->csCtx.frames >= 498) && (globalCtx->csCtx.frames < 577)) { - if ((globalCtx->state.frames % 4) == 0) { - if ((globalCtx->state.frames & 4) != 0) { + if ((play->csCtx.frames >= 498) && (play->csCtx.frames < 577)) { + if ((play->state.frames % 4) == 0) { + if ((play->state.frames & 4) != 0) { Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_STALKIDS_BODY_LEV); } else { Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_STALKIDS_MASK_OFF); @@ -674,13 +863,18 @@ void func_80AA0B08(DmStk* this, GlobalContext* globalCtx) { } } - if (globalCtx->csCtx.frames >= 290) { + if (play->csCtx.frames >= 290) { func_8019F128(NA_SE_EV_KYOJIN_VOICE_SUCCESS - SFX_FLAG); } } -void func_80AA0DA8(DmStk* this, GlobalContext* globalCtx) { - switch (globalCtx->csCtx.frames) { +/** + * 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, PlayState* play) { + switch (play->csCtx.frames) { case 551: Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_STALKIDS_PULLED); break; @@ -696,8 +890,13 @@ void func_80AA0DA8(DmStk* this, GlobalContext* globalCtx) { } } -void func_80AA0E1C(DmStk* this, GlobalContext* globalCtx) { - switch (globalCtx->csCtx.frames) { +/** + * 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, PlayState* play) { + switch (play->csCtx.frames) { case 311: Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_STALKIDS_PULLED); break; @@ -713,87 +912,90 @@ void func_80AA0E1C(DmStk* this, GlobalContext* globalCtx) { } } -void func_80AA0E90(DmStk* this, GlobalContext* globalCtx) { - if (globalCtx->csCtx.state != 0) { - switch (globalCtx->sceneNum) { +/** + * Handles sound effects for all cutscenes. + */ +void DmStk_PlaySfxForCutscenes(DmStk* this, PlayState* play) { + if (play->csCtx.state != 0) { + switch (play->sceneNum) { case SCENE_LOST_WOODS: if (gSaveContext.sceneSetupIndex == 1) { - func_80A9FED8(this, globalCtx); + DmStk_PlaySfxForIntroCutsceneFirstPart(this, play); } else if (gSaveContext.sceneSetupIndex == 0) { - func_80AA0100(this, globalCtx); - } else if ((gSaveContext.sceneSetupIndex == 2) && (globalCtx->csCtx.currentCsIndex == 0)) { - func_80AA0158(this, globalCtx); + DmStk_PlaySfxForIntroCutsceneSecondPart(this, play); + } else if ((gSaveContext.sceneSetupIndex == 2) && (play->csCtx.currentCsIndex == 0)) { + DmStk_PlaySfxForObtainingMajorasMaskCutscene(this, play); } break; case SCENE_CLOCKTOWER: if (gSaveContext.sceneSetupIndex == 1) { - func_80AA00CC(this, globalCtx); + DmStk_PlaySfxForTitleCutscene(this, play); } break; case SCENE_OPENINGDAN: if (gSaveContext.sceneSetupIndex == 0) { - if (globalCtx->csCtx.currentCsIndex == 0) { - func_80AA01C0(this, globalCtx); - } else if (globalCtx->csCtx.currentCsIndex == 1) { - func_80AA0264(this, globalCtx); + if (play->csCtx.currentCsIndex == 0) { + DmStk_PlaySfxForCurseCutsceneFirstPart(this, play); + } else if (play->csCtx.currentCsIndex == 1) { + DmStk_PlaySfxForCurseCutsceneSecondPart(this, play); } } break; case SCENE_OKUJOU: if (gSaveContext.sceneSetupIndex == 0) { - if (globalCtx->csCtx.currentCsIndex == 0) { - func_80AA0420(this, globalCtx); - } else if (globalCtx->csCtx.currentCsIndex == 1) { - func_80AA05F0(this, globalCtx); - } else if (globalCtx->csCtx.currentCsIndex == 2) { - func_80AA09DC(this, globalCtx); - } else if (globalCtx->csCtx.currentCsIndex == 3) { - func_80AA0B08(this, globalCtx); + if (play->csCtx.currentCsIndex == 0) { + DmStk_PlaySfxForClockTowerIntroCutsceneVersion1(this, play); + } else if (play->csCtx.currentCsIndex == 1) { + DmStk_PlaySfxForDroppingOcarinaCutscene(this, play); + } else if (play->csCtx.currentCsIndex == 2) { + DmStk_PlaySfxForClockTowerIntroCutsceneVersion2(this, play); + } else if (play->csCtx.currentCsIndex == 3) { + DmStk_PlaySfxForCutsceneAfterPlayingOathToOrder(this, play); } } else if (gSaveContext.sceneSetupIndex == 2) { - if (globalCtx->csCtx.currentCsIndex == 0) { - func_80AA0DA8(this, globalCtx); - } else if (globalCtx->csCtx.currentCsIndex == 1) { - func_80AA0E1C(this, globalCtx); + if (play->csCtx.currentCsIndex == 0) { + DmStk_PlaySfxForMoonWarpCutsceneVersion1(this, play); + } else if (play->csCtx.currentCsIndex == 1) { + DmStk_PlaySfxForMoonWarpCutsceneVersion2(this, play); } } break; case SCENE_00KEIKOKU: if (gSaveContext.sceneSetupIndex == 3) { - if (globalCtx->csCtx.currentCsIndex == 0) { - func_80AA0634(this, globalCtx); - } else if (globalCtx->csCtx.currentCsIndex == 2) { - func_80AA066C(this, globalCtx); + if (play->csCtx.currentCsIndex == 0) { + DmStk_PlaySfxForShiveringInRainCutscene(this, play); + } else if (play->csCtx.currentCsIndex == 2) { + DmStk_PlaySfxForPlayingWithFairiesCutscene(this, play); } } else if (gSaveContext.sceneSetupIndex == 7) { - if (globalCtx->csCtx.currentCsIndex == 0) { - func_80AA071C(this, globalCtx); - } else if (globalCtx->csCtx.currentCsIndex == 1) { - func_80AA076C(this, globalCtx); + if (play->csCtx.currentCsIndex == 0) { + DmStk_PlaySfxForEndingCutsceneFirstPart(this, play); + } else if (play->csCtx.currentCsIndex == 1) { + DmStk_PlaySfxForEndingCutsceneSecondPart(this, play); } } break; } } - if (this->unk_2E0 == 1) { + if (this->animIndex == SK_ANIM_WALK) { if (Animation_OnFrame(&this->skelAnime, 2.0f) || Animation_OnFrame(&this->skelAnime, 6.0f)) { Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_STALKIDS_WALK); } - } else if (this->unk_2E0 == 19) { + } else if (this->animIndex == SK_ANIM_SEARCH_LINK) { if (Animation_OnFrame(&this->skelAnime, 0.0f) || Animation_OnFrame(&this->skelAnime, 13.0f) || Animation_OnFrame(&this->skelAnime, 20.0f) || Animation_OnFrame(&this->skelAnime, 27.0f)) { Actor_PlaySfxAtPos(&this->actor, NA_SE_PL_CALM_HIT); } - } else if (this->unk_2E0 == 14) { + } else if (this->animIndex == SK_ANIM_PICK_UP_OCARINA_AND_START_PLAYING) { if (Animation_OnFrame(&this->skelAnime, 3.0f)) { Actor_PlaySfxAtPos(&this->actor, NA_SE_PL_PUT_OUT_ITEM); } - } else if (this->unk_2E0 == 15) { + } else if (this->animIndex == SK_ANIM_PLAY_OCARINA_AND_LAUGH) { if (Animation_OnFrame(&this->skelAnime, 14.0f)) { Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_UNSKILLFUL_OCARINA); } @@ -804,46 +1006,47 @@ void func_80AA0E90(DmStk* this, GlobalContext* globalCtx) { } } -void DmStk_Init(Actor* thisx, GlobalContext* globalCtx) { +void DmStk_Init(Actor* thisx, PlayState* play) { 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(&play->objectCtx, OBJECT_STK); + this->objectStk2ObjectIndex = Object_GetIndex(&play->objectCtx, OBJECT_STK2); + this->objectStk3ObjectIndex = Object_GetIndex(&play->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->animIndex = SK_ANIM_IDLE; + this->fogR = play->lightCtx.unk7; + this->fogG = play->lightCtx.unk8; + this->fogB = play->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; - } 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; + if ((play->sceneNum == SCENE_LOST_WOODS) && (gSaveContext.sceneSetupIndex == 1)) { + this->alpha = 0; + this->fogN = 0; + this->fogF = 1000; + this->fogScale = 1.0f; + this->actionFunc = DmStk_DoNothing; + } else if (play->sceneNum == SCENE_OKUJOU) { + this->alpha = 255; + this->fogN = 996; + this->fogF = 1000; + this->fogScale = 0.7f; + this->hasBeenHit = false; - Collider_InitCylinder(globalCtx, &this->collider); + Collider_InitCylinder(play, &this->collider); - if (gSaveContext.save.entranceIndex == 0x2C00) { + if (gSaveContext.save.entrance == ENTRANCE(CLOCK_TOWER_ROOFTOP, 0)) { 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; @@ -851,189 +1054,205 @@ void DmStk_Init(Actor* thisx, GlobalContext* globalCtx) { 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->animIndex = SK_ANIM_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->animIndex = SK_ANIM_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->animIndex = SK_ANIM_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); + Collider_SetCylinder(play, &this->collider, &this->actor, &sCylinderInit); CollisionCheck_SetInfo2(&this->actor.colChkInfo, &sDamageTable, &sColChkInfoInit); - } else if ((globalCtx->sceneNum == SCENE_00KEIKOKU) && (gSaveContext.sceneSetupIndex == 0)) { - if (!(globalCtx->actorCtx.unk5 & 2)) { + } else if ((play->sceneNum == SCENE_00KEIKOKU) && (gSaveContext.sceneSetupIndex == 0)) { + if (!(play->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->animIndex = SK_ANIM_BENT_OVER_HEAD_TWITCH; + this->actionFunc = DmStk_WaitForTelescope; } else { - if ((globalCtx->sceneNum == SCENE_LOST_WOODS) && !Cutscene_IsPlaying(globalCtx)) { + if ((play->sceneNum == SCENE_LOST_WOODS) && !Cutscene_IsPlaying(play)) { 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(play, &this->skelAnime, &gSkullKidSkel, NULL, NULL, NULL, 0); + DmStk_ChangeAnim(this, play, &this->skelAnime, &sAnimationInfo[this->animIndex], 0); } Actor_SetScale(&this->actor, 0.01f); - if ((globalCtx->sceneNum == SCENE_00KEIKOKU) && (gSaveContext.sceneSetupIndex == 3) && - (globalCtx->csCtx.currentCsIndex > 0)) { - globalCtx->envCtx.unk_17 = 15; - globalCtx->envCtx.unk_18 = 15; + if ((play->sceneNum == SCENE_00KEIKOKU) && (gSaveContext.sceneSetupIndex == 3) && + (play->csCtx.currentCsIndex > 0)) { + play->envCtx.unk_17 = 15; + play->envCtx.unk_18 = 15; } } -void DmStk_Destroy(Actor* thisx, GlobalContext* globalCtx) { +void DmStk_Destroy(Actor* thisx, PlayState* play) { } -void func_80AA16F4(DmStk* this, GlobalContext* globalCtx) { +void DmStk_ClockTower_DoNothing(DmStk* this, PlayState* play) { } -void func_80AA1704(DmStk* this, GlobalContext* globalCtx) { +void DmStk_DoNothing(DmStk* this, PlayState* play) { } -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, PlayState* play) { + Vec3f screenPos; if (!(gSaveContext.save.weekEventReg[74] & 0x20)) { - func_80169474(globalCtx, &this->actor.world.pos, &sp1C); - if (globalCtx->view.fovy < 25.0f) { - if ((sp1C.x >= 70.0f) && (sp1C.x < 250.0f) && (sp1C.y >= 30.0f) && (sp1C.y < 210.0f)) { + Play_GetScreenPos(play, &this->actor.world.pos, &screenPos); + if (play->view.fovy < 25.0f) { + if ((screenPos.x >= 70.0f) && (screenPos.x < (SCREEN_WIDTH - 70.0f)) && (screenPos.y >= 30.0f) && + (screenPos.y < (SCREEN_HEIGHT - 30.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, PlayState* play) { + s16 dayOneAndTwoCutscene = this->actor.cutscene; + s16 dayThreeCutscene = ActorCutscene_GetAdditionalCutscene(dayOneAndTwoCutscene); + s16 finalHoursCutscene = ActorCutscene_GetAdditionalCutscene(dayThreeCutscene); s16 cutscene; if (gSaveContext.save.day < 3) { - cutscene = sp1E; + cutscene = dayOneAndTwoCutscene; } else if ((gSaveContext.save.weekEventReg[8] & 0x40) || ((CURRENT_DAY == 3) && (gSaveContext.save.time < CLOCK_TIME(6, 0)))) { - cutscene = sp18; + 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, PlayState* play) { 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) { - 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; +void DmStk_ClockTower_WaitForIntroCutsceneVersion1ToEnd(DmStk* this, PlayState* play) { + if (play->csCtx.state == 0) { + this->animIndex = SK_ANIM_CALL_DOWN_MOON_LOOP; + this->handType = SK_HAND_TYPE_HOLDING_OCARINA; + DmStk_ChangeAnim(this, play, &this->skelAnime, &sAnimationInfo[this->animIndex], 0); + 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, PlayState* play) { + 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) { - if (globalCtx->csCtx.state == 0) { - this->unk_2E0 = 38; - func_80A9FE3C(this, globalCtx, &this->skelAnime, &sAnimations[this->unk_2E0], 0); - this->actionFunc = func_80AA27EC; +void DmStk_ClockTower_WaitForIntroCutsceneVersion2ToEnd(DmStk* this, PlayState* play) { + if (play->csCtx.state == 0) { + this->animIndex = SK_ANIM_FLOATING_ARMS_CROSSED; + DmStk_ChangeAnim(this, play, &this->skelAnime, &sAnimationInfo[this->animIndex], 0); + this->actionFunc = DmStk_ClockTower_Idle; } } -void func_80AA1A50(DmStk* this, GlobalContext* globalCtx) { - if (ActorCutscene_GetCanPlayNext(0xA)) { +void DmStk_ClockTower_StartDropOcarinaCutscene(DmStk* this, PlayState* play) { + 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) { - if ((globalCtx->csCtx.state != 0) && (globalCtx->csCtx.frames > 20)) { - this->actionFunc = func_80AA27EC; +void DmStk_ClockTower_WaitForDropOcarinaCutsceneToEnd(DmStk* this, PlayState* play) { + if ((play->csCtx.state != 0) && (play->csCtx.frames > 20)) { + this->actionFunc = DmStk_ClockTower_Idle; } } -void func_80AA1AF8(DmStk* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); +/** + * Makes Skull Kid bob up and down and face the player. + */ +void DmStk_ClockTower_AdjustHeightAndRotation(DmStk* this, PlayState* play) { + Player* player = GET_PLAYER(play); 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); @@ -1043,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) { - Player* player = GET_PLAYER(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, PlayState* play) { + Player* player = GET_PLAYER(play); - func_80AA1AF8(this, globalCtx); - this->unk_339++; - if (this->unk_339 >= 3) { - this->unk_339 = 0; + DmStk_ClockTower_AdjustHeightAndRotation(this, play); + this->deflectCount++; + if (this->deflectCount >= 3) { + this->deflectCount = 0; if (!(player->stateFlags2 & 0x8000000)) { - Message_StartTextbox(globalCtx, 0x2013, &this->actor); + // That won't do you any good + Message_StartTextbox(play, 0x2013, &this->actor); } } - this->unk_2E0 = 39; - func_80A9FE3C(this, globalCtx, &this->skelAnime, &sAnimations[this->unk_2E0], 0); + this->animIndex = SK_ANIM_DEFLECT_ATTACK; + DmStk_ChangeAnim(this, play, &this->skelAnime, &sAnimationInfo[this->animIndex], 0); Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_STALKIDS_DOWN_K); - 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, PlayState* play) { + DmStk_ClockTower_AdjustHeightAndRotation(this, play); 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->animIndex = SK_ANIM_FLOATING_ARMS_CROSSED; + DmStk_ChangeAnim(this, play, &this->skelAnime, &sAnimationInfo[this->animIndex], 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, PlayState* play) { s32 pad; - s32 temp_v0; + s32 actorActionIndex; - if (Cutscene_CheckActorAction(globalCtx, 107)) { - temp_v0 = Cutscene_GetActorActionIndex(globalCtx, 107); + if (Cutscene_CheckActorAction(play, 107)) { + actorActionIndex = Cutscene_GetActorActionIndex(play, 107); - if (globalCtx->csCtx.frames == globalCtx->csCtx.actorActions[temp_v0]->startFrame) { - if (this->unk_334 != globalCtx->csCtx.actorActions[temp_v0]->action) { - this->unk_334 = globalCtx->csCtx.actorActions[temp_v0]->action; - if (globalCtx->sceneNum == SCENE_CLOCKTOWER) { - this->unk_32D = 6; + if (play->csCtx.frames == play->csCtx.actorActions[actorActionIndex]->startFrame) { + if (this->csAction != play->csCtx.actorActions[actorActionIndex]->action) { + this->csAction = play->csCtx.actorActions[actorActionIndex]->action; + if (play->sceneNum == SCENE_CLOCKTOWER) { + this->handType = SK_HAND_TYPE_HOLDING_FLUTE; } else { - this->unk_32D = 9; + this->handType = SK_HAND_TYPE_DEFAULT; } - switch (globalCtx->csCtx.actorActions[temp_v0]->action) { + switch (play->csCtx.actorActions[actorActionIndex]->action) { case 0: case 1: - this->unk_2E0 = 3; + this->animIndex = SK_ANIM_IDLE; break; case 2: - this->unk_2E0 = 1; + this->animIndex = SK_ANIM_WALK; break; case 3: - this->unk_2E0 = 20; + this->animIndex = SK_ANIM_UNUSED_KICK_OVER_LINK; break; case 4: - this->unk_2E0 = 18; + this->animIndex = SK_ANIM_KICK_OVER_LINK; break; case 6: - this->unk_2E0 = 16; - this->unk_32D = 3; + this->animIndex = SK_ANIM_PICK_UP_OCARINA; + this->handType = SK_HAND_TYPE_HOLDING_OCARINA; break; case 7: - this->unk_2E0 = 14; - this->unk_32D = 3; + this->animIndex = SK_ANIM_PICK_UP_OCARINA_AND_START_PLAYING; + this->handType = SK_HAND_TYPE_HOLDING_OCARINA; break; case 8: - this->unk_2E0 = 0; + this->animIndex = SK_ANIM_SHAKE_HEAD; break; case 9: - this->unk_2E0 = 3; - this->unk_32E = 1; + this->animIndex = SK_ANIM_IDLE; + this->fadeInState = SK_FADE_IN_STATE_START; break; case 12: - this->unk_2E0 = 12; - this->unk_32D = 3; + this->animIndex = SK_ANIM_HIDE_OCARINA_START; + this->handType = SK_HAND_TYPE_HOLDING_OCARINA; break; case 13: - this->unk_2E0 = 27; - this->unk_32D = 3; + this->animIndex = SK_ANIM_JUMP_WHILE_HIDING_OCARINA; + this->handType = SK_HAND_TYPE_HOLDING_OCARINA; break; case 14: - this->unk_2E0 = 22; + this->animIndex = SK_ANIM_HORSE_RIDE_START; break; case 15: - this->unk_2E0 = 23; + this->animIndex = SK_ANIM_HORSE_RIDE_LOOP; break; case 16: - this->unk_2E0 = 28; + this->animIndex = SK_ANIM_HORSE_RIDE_AND_ROTATE; break; case 17: - this->unk_2E0 = 7; + this->animIndex = SK_ANIM_RECLINING_FLOAT; break; case 18: - this->unk_2E0 = 8; + this->animIndex = SK_ANIM_CURSE_START; break; case 19: - this->unk_2E0 = 10; + this->animIndex = SK_ANIM_LAUGH_START; break; case 20: - this->unk_2E0 = 24; + this->animIndex = SK_ANIM_RAISE_MASK_START; break; case 21: - this->unk_2E0 = 26; + this->animIndex = SK_ANIM_LOWER_MASK; break; case 22: - this->unk_2E0 = 29; + this->animIndex = SK_ANIM_PLAY_OCARINA_WHILE_FLOATING; if (gSaveContext.save.inventory.items[SLOT_OCARINA] == ITEM_NONE) { - this->unk_32D = 3; + this->handType = SK_HAND_TYPE_HOLDING_OCARINA; } break; case 23: - this->unk_2E0 = 30; - this->unk_32D = 4; + this->animIndex = SK_ANIM_FLOATING_TURN_AROUND; + this->handType = SK_HAND_TYPE_JUGGLING_OR_DROPPING_OCARINA; break; case 24: - this->unk_2E0 = 32; + this->animIndex = SK_ANIM_CALL_DOWN_MOON_START; if (gSaveContext.save.inventory.items[SLOT_OCARINA] == ITEM_NONE) { - this->unk_32D = 3; + this->handType = SK_HAND_TYPE_HOLDING_OCARINA; } break; @@ -1193,148 +1425,148 @@ void func_80AA1D1C(DmStk* this, GlobalContext* globalCtx) { break; case 26: - this->unk_2E0 = 34; + this->animIndex = SK_ANIM_SMACK_FAIRY_START; if (gSaveContext.save.inventory.items[SLOT_OCARINA] == ITEM_NONE) { - this->unk_32D = 3; + this->handType = SK_HAND_TYPE_HOLDING_OCARINA; } break; case 27: - this->unk_2E0 = 36; + this->animIndex = SK_ANIM_HIT_BY_BUBBLE; if (gSaveContext.save.inventory.items[SLOT_OCARINA] == ITEM_NONE) { - this->unk_32D = 3; + this->handType = SK_HAND_TYPE_HOLDING_OCARINA; } break; case 28: - this->unk_2E0 = 37; - this->unk_32D = 4; + this->animIndex = SK_ANIM_DROP_OCARINA; + this->handType = SK_HAND_TYPE_JUGGLING_OR_DROPPING_OCARINA; break; case 30: - this->unk_2E0 = 38; + this->animIndex = SK_ANIM_FLOATING_ARMS_CROSSED; break; case 31: - this->unk_2E0 = 39; + this->animIndex = SK_ANIM_DEFLECT_ATTACK; break; case 32: - this->unk_2E0 = 42; + this->animIndex = SK_ANIM_SURPRISE_START; break; case 33: - this->unk_2E0 = 44; + this->animIndex = SK_ANIM_LOOK_AROUND_FOR_GIANTS_START; break; case 34: - this->unk_2E0 = 46; + this->animIndex = SK_ANIM_HOLD_HEAD_AND_SHAKE_START; break; case 35: - this->unk_2E0 = 48; + this->animIndex = SK_ANIM_HOLD_HEAD_AND_SCREAM_START; break; case 36: - this->unk_2E0 = 50; + this->animIndex = SK_ANIM_HUDDLE_WITH_FAIRIES; break; case 37: - this->unk_2E0 = 51; + this->animIndex = SK_ANIM_SEARCH_MASK_SALESMAN; break; case 38: - this->unk_2E0 = 52; + this->animIndex = SK_ANIM_HOLD_UP_MASK_START; break; case 39: - this->unk_2E0 = 54; + this->animIndex = SK_ANIM_SHIVER; break; case 40: - this->unk_2E0 = 55; + this->animIndex = SK_ANIM_DRAW; break; case 41: - this->unk_2E0 = 40; + this->animIndex = SK_ANIM_TELESCOPE_LOOK_UP_START; break; case 42: - this->unk_2E0 = 5; + this->animIndex = SK_ANIM_BENT_OVER_HEAD_TWITCH; break; case 43: - this->unk_2E0 = 56; + this->animIndex = SK_ANIM_BENT_OVER_LOOK_UP; break; case 44: - this->unk_2E0 = 57; + this->animIndex = SK_ANIM_SPANK; break; case 45: - this->unk_2E0 = 58; - this->unk_32F = 1; + this->animIndex = SK_ANIM_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->animIndex = SK_ANIM_PLAY_FLUTE; break; case 47: - this->unk_2E0 = 60; + this->animIndex = SK_ANIM_CARTWHEEL; break; case 48: - this->unk_2E0 = 60; + this->animIndex = SK_ANIM_CARTWHEEL; break; case 49: - this->unk_2E0 = 65; + this->animIndex = SK_ANIM_LOOK_UP_AT_GIANTS; break; case 50: - this->unk_2E0 = 66; + this->animIndex = SK_ANIM_ASHAMED_START; break; case 51: - this->unk_2E0 = 68; + this->animIndex = SK_ANIM_LOOK_LEFT_START; break; case 52: - this->unk_2E0 = 70; + this->animIndex = SK_ANIM_SNIFF; break; case 53: - this->unk_2E0 = 60; + this->animIndex = SK_ANIM_CARTWHEEL; break; case 54: - this->unk_2E0 = 61; + this->animIndex = SK_ANIM_LIE_FLAT; break; case 55: - this->unk_2E0 = 62; + this->animIndex = SK_ANIM_DANGLE_FROM_MASK_START; break; case 56: - this->unk_2E0 = 64; + this->animIndex = SK_ANIM_DROPPED_FROM_MASK; break; case 57: - this->unk_2E0 = 65; + this->animIndex = SK_ANIM_LOOK_UP_AT_GIANTS; break; case 58: - this->unk_2E0 = 66; + this->animIndex = SK_ANIM_ASHAMED_START; break; case 59: - this->unk_2E0 = 68; + this->animIndex = SK_ANIM_LOOK_LEFT_START; break; case 60: - this->unk_2E0 = 70; + this->animIndex = SK_ANIM_SNIFF; break; case 5: @@ -1342,473 +1574,487 @@ void func_80AA1D1C(DmStk* this, GlobalContext* globalCtx) { break; default: - this->unk_2E0 = 0; + this->animIndex = SK_ANIM_SHAKE_HEAD; break; } - func_80A9FE3C(this, globalCtx, &this->skelAnime, &sAnimations[this->unk_2E0], 0); + DmStk_ChangeAnim(this, play, &this->skelAnime, &sAnimationInfo[this->animIndex], 0); } } - Cutscene_ActorTranslateAndYaw(&this->actor, globalCtx, temp_v0); + Cutscene_ActorTranslateAndYaw(&this->actor, play, 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 = play->lightCtx.unk7 * this->fogScale; + this->fogG = play->lightCtx.unk8 * this->fogScale; + this->fogB = play->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; + 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)) { + if (!(play->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->animIndex) { + case SK_ANIM_LOOK_AROUND: + case SK_ANIM_CURSE_START: + case SK_ANIM_LAUGH_START: + case SK_ANIM_HIDE_OCARINA_START: + case SK_ANIM_PICK_UP_OCARINA_AND_START_PLAYING: + case SK_ANIM_PICK_UP_OCARINA: + case SK_ANIM_KICK_OVER_LINK: + case SK_ANIM_UNUSED_KICK_OVER_LINK: + case SK_ANIM_HORSE_RIDE_START: + case SK_ANIM_RAISE_MASK_START: + case SK_ANIM_FLOATING_TURN_AROUND: + case SK_ANIM_CALL_DOWN_MOON_START: + case SK_ANIM_SMACK_FAIRY_START: + case SK_ANIM_TELESCOPE_LOOK_UP_START: + case SK_ANIM_SURPRISE_START: + case SK_ANIM_LOOK_AROUND_FOR_GIANTS_START: + case SK_ANIM_HOLD_HEAD_AND_SHAKE_START: + case SK_ANIM_HOLD_HEAD_AND_SCREAM_START: + case SK_ANIM_HOLD_UP_MASK_START: + case SK_ANIM_DANGLE_FROM_MASK_START: + case SK_ANIM_ASHAMED_START: + case SK_ANIM_LOOK_LEFT_START: + case SK_ANIM_SNIFF: + this->animIndex++; + DmStk_ChangeAnim(this, play, &this->skelAnime, &sAnimationInfo[this->animIndex], 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_ANIM_LOWER_MASK: + this->animIndex = SK_ANIM_IDLE; + this->maskType = SK_MASK_TYPE_NORMAL; + this->handType = SK_HAND_TYPE_DEFAULT; + DmStk_ChangeAnim(this, play, &this->skelAnime, &sAnimationInfo[this->animIndex], 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)) || - ((globalCtx->sceneNum == SCENE_00KEIKOKU) && (gSaveContext.sceneSetupIndex == 7))) { - this->unk_32C = 0; - if ((this->unk_2E0 == 52) || (this->unk_2E0 == 53)) { - this->unk_32D = 5; + if (((this->animIndex == SK_ANIM_RAISE_MASK_START) && (this->skelAnime.curFrame >= 16.0f)) || + (this->animIndex == SK_ANIM_RAISE_MASK_LOOP) || (this->animIndex == SK_ANIM_LOWER_MASK)) { + this->maskType = SK_MASK_TYPE_RAISED; + this->handType = SK_HAND_TYPE_HOLDING_MAJORAS_MASK; + } else if (((this->animIndex >= SK_ANIM_HUDDLE_WITH_FAIRIES) && (this->animIndex <= SK_ANIM_DRAW)) || + ((this->animIndex >= SK_ANIM_PLAY_FLUTE) && (this->animIndex <= SK_ANIM_CARTWHEEL)) || + ((play->sceneNum == SCENE_00KEIKOKU) && (gSaveContext.sceneSetupIndex == 7))) { + this->maskType = SK_MASK_TYPE_NO_MASK; + if ((this->animIndex == SK_ANIM_HOLD_UP_MASK_START) || (this->animIndex == SK_ANIM_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->animIndex == SK_ANIM_DROPPED_FROM_MASK) { + this->maskType = SK_MASK_TYPE_NO_MASK; } } -void func_80AA26CC(DmStk* this, GlobalContext* globalCtx) { +void DmStk_UpdateCollision(DmStk* this, PlayState* play) { s32 pad; Collider_UpdateCylinder(&this->actor, &this->collider); - CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); - CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + CollisionCheck_SetAC(play, &play->colChkCtx, &this->collider.base); + CollisionCheck_SetOC(play, &play->colChkCtx, &this->collider.base); } -void func_80AA2720(DmStk* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(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, PlayState* play) { + Player* player = GET_PLAYER(play); - if (globalCtx->csCtx.state == 0) { - func_80AA1AF8(this, globalCtx); + if (play->csCtx.state == 0) { + DmStk_ClockTower_AdjustHeightAndRotation(this, play); this->actor.flags |= ACTOR_FLAG_1; - this->unk_328++; - if (this->unk_328 > 800) { - this->unk_328 = 0; + this->tatlMessageTimer++; + if (this->tatlMessageTimer > 800) { + this->tatlMessageTimer = 0; if (!(player->stateFlags2 & 0x8000000)) { - Message_StartTextbox(globalCtx, 0x2014, &this->actor); + // Why are you just standing around? + Message_StartTextbox(play, 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) { - if (globalCtx->csCtx.state == 0) { - func_80AA1AF8(this, 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, PlayState* play) { + if (play->csCtx.state == 0) { + DmStk_ClockTower_AdjustHeightAndRotation(this, play); this->actor.flags |= ACTOR_FLAG_1; - if (this->unk_2E0 == 33) { + if (this->animIndex == SK_ANIM_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) { +void DmStk_Update(Actor* thisx, PlayState* play) { 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->animIndex == SK_ANIM_CALL_DOWN_MOON_LOOP) { Actor_SetFocus(&this->actor, 40.0f); } else { Actor_SetFocus(&this->actor, 6.0f); } - func_80A9FDB0(this, globalCtx); + DmStk_LoadObjectForAnimation(this, play); - if (this->unk_2E0 != 61) { + if (this->animIndex != SK_ANIM_LIE_FLAT) { SkelAnime_Update(&this->skelAnime); } - this->unk_2E4 = this->unk_2E4; + this->alpha = this->alpha; - this->actionFunc(this, globalCtx); + this->actionFunc(this, play); - if (globalCtx->sceneNum == SCENE_OKUJOU) { - func_80AA26CC(this, globalCtx); + if (play->sceneNum == SCENE_OKUJOU) { + DmStk_UpdateCollision(this, play); } - func_80AA1D1C(this, globalCtx); - func_80AA0E90(this, globalCtx); + DmStk_UpdateCutscenes(this, play); + DmStk_PlaySfxForCutscenes(this, play); - switch (this->unk_33A) { - case 1: - if (func_800B8718(&this->actor, &globalCtx->state)) { - this->unk_33A = 2; + // 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, &play->state)) { + this->dekuPipesCutsceneState = SK_DEKU_PIPES_CS_STATE_PLAYER_USED_OCARINA; } else { - func_800B874C(&this->actor, globalCtx, this->actor.xzDistToPlayer, - fabsf(this->actor.playerHeightRel)); + func_800B874C(&this->actor, play, 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: - if (globalCtx->csCtx.state == 0) { - this->unk_33A = 4; + case SK_DEKU_PIPES_CS_STATE_START: + if (play->csCtx.state == 0) { + this->dekuPipesCutsceneState = SK_DEKU_PIPES_CS_STATE_END; } break; } - 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)) { - time = gSaveContext.save.time; - gSaveContext.save.time = (u16)REG(15) + time; + // This code is responsible for making in-game time pass while using the telescope in the Astral Observatory. + // Skull Kid is always loaded in the scene, even if he isn't visible, hence why time always passes. + if ((play->actorCtx.unk5 & 2) && (play->msgCtx.msgMode != 0) && (play->msgCtx.currentTextId == 0x5E6) && + !FrameAdvance_IsEnabled(&play->state) && (play->transitionTrigger == TRANS_TRIGGER_OFF) && + (ActorCutscene_GetCurrentIndex() == -1) && (play->csCtx.state == 0)) { + gSaveContext.save.time = ((void)0, gSaveContext.save.time) + (u16)REG(15); if (REG(15) != 0) { - time = gSaveContext.save.time; - gSaveContext.save.time = (u16)gSaveContext.save.daySpeed + 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.currentCsIndex > 0)) { - globalCtx->envCtx.unk_17 = 15; - globalCtx->envCtx.unk_18 = 15; + if ((play->sceneNum == SCENE_00KEIKOKU) && (gSaveContext.sceneSetupIndex == 3) && + (play->csCtx.currentCsIndex > 0)) { + play->envCtx.unk_17 = 15; + play->envCtx.unk_18 = 15; } } -s32 DmStk_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, Actor* thisx) { +s32 DmStk_OverrideLimbDraw(PlayState* play, 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; } return false; } -void DmStk_PostLimbDraw2(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx, Gfx** gfx) { +void DmStk_PostLimbDraw2(PlayState* play, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx, Gfx** gfx) { s32 pad; 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); + OPEN_DISPS(play->state.gfxCtx); - gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(play->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->animIndex == SK_ANIM_LOOK_LEFT_LOOP) || (this->animIndex == SK_ANIM_LAUGH_LOOP) || + (this->animIndex == SK_ANIM_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: - 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; + case SK_MASK_TYPE_NORMAL: + if ((play->sceneNum == SCENE_LOST_WOODS) && (gSaveContext.sceneSetupIndex == 1) && + (play->csCtx.frames < 1400)) { + 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 = func_801660B8(globalCtx, POLY_OPA_DISP); + POLY_OPA_DISP = Gfx_SetFog(POLY_OPA_DISP, this->fogR, this->fogG, this->fogB, this->fogA, + this->fogN, this->fogF); + gSPDisplayList(POLY_OPA_DISP++, gSkullKidMajorasMask1DL); + POLY_OPA_DISP = func_801660B8(play, POLY_OPA_DISP); } 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 (Cutscene_CheckActorAction(globalCtx, 513) && - (globalCtx->csCtx.actorActions[Cutscene_GetActorActionIndex(globalCtx, 513)]->action == 2) && - (this->unk_337 >= 0)) { - Matrix_StatePush(); + if (Cutscene_CheckActorAction(play, 513) && + (play->csCtx.actorActions[Cutscene_GetActorActionIndex(play, 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(play->objectCtx.status[this->objectStk2ObjectIndex].segment); - gSPSegment(POLY_OPA_DISP++, 0x06, globalCtx->objectCtx.status[this->unk_337].segment); + gSPSegment(POLY_OPA_DISP++, 0x06, play->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(play, Lib_SegmentedToVirtual(gSkullKidMajorasMaskCurseOverlayTexAnim)); + Gfx_DrawDListOpa(play, gSkullKidMajorasMaskCurseOverlayDL); + gSegments[6] = PHYSICAL_TO_VIRTUAL(play->objectCtx.status[this->objectStkObjectIndex].segment); - gSPSegment(POLY_OPA_DISP++, 0x06, globalCtx->objectCtx.status[this->unk_336].segment); + gSPSegment(POLY_OPA_DISP++, 0x06, play->objectCtx.status[this->objectStkObjectIndex].segment); - Matrix_StatePop(); + Matrix_Pop(); } break; } - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->state.gfxCtx); - } else if (limbIndex == 15) { + } else if (limbIndex == SKULL_KID_LIMB_RIGHT_HAND) { - OPEN_DISPS(globalCtx->state.gfxCtx); + OPEN_DISPS(play->state.gfxCtx); - if (this->unk_32D != 5) { - gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), - G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + if (this->handType != SK_HAND_TYPE_HOLDING_MAJORAS_MASK_AND_FLUTE) { + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(play->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); + if ((play->sceneNum == SCENE_LOST_WOODS) && (gSaveContext.sceneSetupIndex == 1)) { + 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), + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(play->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); + CLOSE_DISPS(play->state.gfxCtx); - } else if (limbIndex == 12) { + } else if (limbIndex == SKULL_KID_LIMB_LEFT_HAND) { - OPEN_DISPS(globalCtx->state.gfxCtx); + OPEN_DISPS(play->state.gfxCtx); - gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(play->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: - if ((globalCtx->sceneNum != SCENE_LOST_WOODS) || (gSaveContext.sceneSetupIndex != 1)) { - gSPDisplayList(POLY_OPA_DISP++, object_stk_DL_00CAD0); + case SK_HAND_TYPE_HOLDING_OCARINA: + if ((play->sceneNum != SCENE_LOST_WOODS) || (gSaveContext.sceneSetupIndex != 1)) { + 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; } - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->state.gfxCtx); } } -void DmStk_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx) { +void DmStk_PostLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx) { DmStk* this = THIS; - DmStk_PostLimbDraw2(globalCtx, limbIndex, dList, rot, &this->actor, NULL); + DmStk_PostLimbDraw2(play, limbIndex, dList, rot, &this->actor, NULL); } -void DmStk_Draw(Actor* thisx, GlobalContext* globalCtx) { +void DmStk_Draw(Actor* thisx, PlayState* play) { 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(play, gSkullKidMajorasMask1DL); return; } - gSegments[6] = PHYSICAL_TO_VIRTUAL(globalCtx->objectCtx.status[this->unk_336].segment); + gSegments[6] = PHYSICAL_TO_VIRTUAL(play->objectCtx.status[this->objectStkObjectIndex].segment); - OPEN_DISPS(globalCtx->state.gfxCtx); + OPEN_DISPS(play->state.gfxCtx); - this->unk_2E4 = this->unk_2E4; - func_8012C28C(globalCtx->state.gfxCtx); + this->alpha = this->alpha; + func_8012C28C(play->state.gfxCtx); - if (this->unk_2E4 < 255) { - func_8012C2DC(globalCtx->state.gfxCtx); - Scene_SetRenderModeXlu(globalCtx, 1, 2); + if (this->alpha < 255) { + func_8012C2DC(play->state.gfxCtx); + Scene_SetRenderModeXlu(play, 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, + SkelAnime_DrawFlex(play, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, NULL, DmStk_PostLimbDraw2, &this->actor, POLY_XLU_DISP); } else { - Scene_SetRenderModeXlu(globalCtx, 0, 1); + Scene_SetRenderModeXlu(play, 0, 1); gDPPipeSync(POLY_OPA_DISP++); gDPSetEnvColor(POLY_OPA_DISP++, 255, 255, 255, 255); - SkelAnime_DrawFlexOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, + SkelAnime_DrawFlexOpa(play, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, DmStk_OverrideLimbDraw, DmStk_PostLimbDraw, &this->actor); } - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->state.gfxCtx); } } 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..ffea61265 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*); +typedef void (*DmStkActionFunc)(struct DmStk*, PlayState*); + +#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 animIndex; + /* 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 6290b41e0..b74c43940 100644 --- a/src/overlays/actors/ovl_Dm_Tag/z_dm_tag.c +++ b/src/overlays/actors/ovl_Dm_Tag/z_dm_tag.c @@ -10,13 +10,13 @@ #define THIS ((DmTag*)thisx) -void DmTag_Init(Actor* thisx, GlobalContext* globalCtx); -void DmTag_Destroy(Actor* thisx, GlobalContext* globalCtx); -void DmTag_Update(Actor* thisx, GlobalContext* globalCtx); +void DmTag_Init(Actor* thisx, PlayState* play); +void DmTag_Destroy(Actor* thisx, PlayState* play); +void DmTag_Update(Actor* thisx, PlayState* play); -void func_80C229AC(DmTag* this, GlobalContext* globalCtx); -void func_80C229EC(DmTag* this, GlobalContext* globalCtx); -void func_80C229FC(DmTag* this, GlobalContext* globalCtx); +void func_80C229AC(DmTag* this, PlayState* play); +void func_80C229EC(DmTag* this, PlayState* play); +void func_80C229FC(DmTag* this, PlayState* play); #if 0 const ActorInit Dm_Tag_InitVars = { diff --git a/src/overlays/actors/ovl_Dm_Tag/z_dm_tag.h b/src/overlays/actors/ovl_Dm_Tag/z_dm_tag.h index 2bb9e3a5c..fda9397c7 100644 --- a/src/overlays/actors/ovl_Dm_Tag/z_dm_tag.h +++ b/src/overlays/actors/ovl_Dm_Tag/z_dm_tag.h @@ -5,13 +5,13 @@ struct DmTag; -typedef void (*DmTagActionFunc)(struct DmTag*, GlobalContext*); +typedef void (*DmTagActionFunc)(struct DmTag*, PlayState*); typedef struct DmTag { - /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x44]; - /* 0x0188 */ DmTagActionFunc actionFunc; - /* 0x018C */ char unk_18C[0x20]; + /* 0x000 */ Actor actor; + /* 0x144 */ char unk_144[0x44]; + /* 0x188 */ DmTagActionFunc actionFunc; + /* 0x18C */ char unk_18C[0x20]; } DmTag; // size = 0x1AC extern const ActorInit Dm_Tag_InitVars; diff --git a/src/overlays/actors/ovl_Dm_Tsg/z_dm_tsg.c b/src/overlays/actors/ovl_Dm_Tsg/z_dm_tsg.c index 9ed86ba2c..ab0aca40e 100644 --- a/src/overlays/actors/ovl_Dm_Tsg/z_dm_tsg.c +++ b/src/overlays/actors/ovl_Dm_Tsg/z_dm_tsg.c @@ -10,10 +10,10 @@ #define THIS ((DmTsg*)thisx) -void DmTsg_Init(Actor* thisx, GlobalContext* globalCtx); -void DmTsg_Destroy(Actor* thisx, GlobalContext* globalCtx); -void DmTsg_Update(Actor* thisx, GlobalContext* globalCtx); -void DmTsg_Draw(Actor* thisx, GlobalContext* globalCtx); +void DmTsg_Init(Actor* thisx, PlayState* play); +void DmTsg_Destroy(Actor* thisx, PlayState* play); +void DmTsg_Update(Actor* thisx, PlayState* play); +void DmTsg_Draw(Actor* thisx, PlayState* play); #if 0 const ActorInit Dm_Tsg_InitVars = { 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 fc9d21b3d..47706cb9f 100644 --- a/src/overlays/actors/ovl_Dm_Zl/z_dm_zl.c +++ b/src/overlays/actors/ovl_Dm_Zl/z_dm_zl.c @@ -1,7 +1,7 @@ /* * 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" @@ -10,14 +10,13 @@ #define THIS ((DmZl*)thisx) -void DmZl_Init(Actor* thisx, GlobalContext* globalCtx); -void DmZl_Destroy(Actor* thisx, GlobalContext* globalCtx); -void DmZl_Update(Actor* thisx, GlobalContext* globalCtx); -void DmZl_Draw(Actor* thisx, GlobalContext* globalCtx); +void DmZl_Init(Actor* thisx, PlayState* play); +void DmZl_Destroy(Actor* thisx, PlayState* play); +void DmZl_Update(Actor* thisx, PlayState* play); +void DmZl_Draw(Actor* thisx, PlayState* play); -void func_80A382FC(DmZl* this, GlobalContext* globalCtx); +void DmZl_DoNothing(DmZl* this, PlayState* play); -#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 sAnimationInfo[] = { + { &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, +} DmZlAnimation; -#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 animationInfo[], u16 unusedExtraOffset) { + f32 endFrame; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Zl/DmZl_Update.s") + animationInfo += unusedExtraOffset; + endFrame = (animationInfo->frameCount < 0.0f) ? Animation_GetLastFrame(animationInfo->animation) + : animationInfo->frameCount; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Zl/func_80A3862C.s") + Animation_Change(skelAnime, animationInfo->animation, animationInfo->playSpeed, animationInfo->startFrame, endFrame, + animationInfo->mode, animationInfo->morphFrames); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Zl/func_80A38648.s") +void DmZl_Init(Actor* thisx, PlayState* play) { + s32 pad; + DmZl* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Zl/DmZl_Draw.s") + this->animIndex = 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(play, &this->skelAnime, &gZl4Skeleton, NULL, NULL, NULL, 0); + DmZl_ChangeAnimation(&this->skelAnime, &sAnimationInfo[this->animIndex], 0); + Actor_SetScale(&this->actor, 0.01f); + this->actionFunc = DmZl_DoNothing; +} + +void DmZl_Destroy(Actor* thisx, PlayState* play) { +} + +void DmZl_DoNothing(DmZl* this, PlayState* play) { +} + +void DmZl_UpdateCutscene(DmZl* this, PlayState* play) { + s32 actionIndex; + + if (Cutscene_CheckActorAction(play, 0x66)) { + actionIndex = Cutscene_GetActorActionIndex(play, 0x66); + if (play->csCtx.frames == play->csCtx.actorActions[actionIndex]->startFrame) { + s16 nextAnimIndex = ZELDA_ANIM_FACING_AWAY; + + switch (play->csCtx.actorActions[actionIndex]->action) { + default: + case 1: + break; + case 2: + nextAnimIndex = ZELDA_ANIM_TURNING_TOWARD_PLAYER; + break; + case 3: + nextAnimIndex = ZELDA_ANIM_GIVING_OCARINA_START; + break; + case 4: + nextAnimIndex = ZELDA_ANIM_PLAYING_OCARINA_START; + break; + } + + if (nextAnimIndex != this->animIndex) { + this->animIndex = nextAnimIndex; + DmZl_ChangeAnimation(&this->skelAnime, &sAnimationInfo[this->animIndex], 0); + } + } + + Cutscene_ActorTranslateAndYaw(&this->actor, play, actionIndex); + } + + if (Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) { + actionIndex = this->animIndex; + + 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->animIndex++; + DmZl_ChangeAnimation(&this->skelAnime, &sAnimationInfo[this->animIndex], 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->animIndex == ZELDA_ANIM_PLAYING_OCARINA) { + this->eyeTextureIndexLeft = this->eyeTextureIndexRight = ZELDA_EYE_CLOSED; + } +} + +void DmZl_Update(Actor* thisx, PlayState* play) { + DmZl* this = THIS; + + DmZl_UpdateFace(this); + SkelAnime_Update(&this->skelAnime); + DmZl_UpdateCutscene(this, play); + this->actionFunc(this, play); +} + +s32 DmZl_OverrideLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, Actor* thisx) { + return false; +} + +void DmZl_PostLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx) { + DmZl* this = THIS; + + if (limbIndex == ZL4_LIMB_RIGHT_HAND) { + if ((this->animIndex >= ZELDA_ANIM_GIVING_OCARINA_START) && (this->animIndex <= ZELDA_ANIM_PLAYING_OCARINA)) { + OPEN_DISPS(play->state.gfxCtx); + + gSPDisplayList(POLY_OPA_DISP++, gDmZl4OcarinaDL); + + CLOSE_DISPS(play->state.gfxCtx); + } + } +} + +void DmZl_Draw(Actor* thisx, PlayState* play) { + DmZl* this = THIS; + + OPEN_DISPS(play->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(play->state.gfxCtx); + SkelAnime_DrawFlexOpa(play, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, + DmZl_OverrideLimbDraw, DmZl_PostLimbDraw, &this->actor); + + CLOSE_DISPS(play->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..c267d9ae9 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 void (*DmZlActionFunc)(struct DmZl*, PlayState*); 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 animIndex; + /* 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 0d1daa6b5..173c3ea52 100644 --- a/src/overlays/actors/ovl_Door_Ana/z_door_ana.c +++ b/src/overlays/actors/ovl_Door_Ana/z_door_ana.c @@ -11,14 +11,14 @@ #define THIS ((DoorAna*)thisx) -void DoorAna_Init(Actor* thisx, GlobalContext* globalCtx); -void DoorAna_Destroy(Actor* thisx, GlobalContext* globalCtx); -void DoorAna_Update(Actor* thisx, GlobalContext* globalCtx); -void DoorAna_Draw(Actor* thisx, GlobalContext* globalCtx); +void DoorAna_Init(Actor* thisx, PlayState* play); +void DoorAna_Destroy(Actor* thisx, PlayState* play); +void DoorAna_Update(Actor* thisx, PlayState* play); +void DoorAna_Draw(Actor* thisx, PlayState* play); -void DoorAna_WaitClosed(DoorAna* this, GlobalContext* globalCtx); -void DoorAna_WaitOpen(DoorAna* this, GlobalContext* globalCtx); -void DoorAna_GrabLink(DoorAna* this, GlobalContext* globalCtx); +void DoorAna_WaitClosed(DoorAna* this, PlayState* play); +void DoorAna_WaitOpen(DoorAna* this, PlayState* play); +void DoorAna_GrabLink(DoorAna* this, PlayState* play); const ActorInit Door_Ana_InitVars = { ACTOR_DOOR_ANA, @@ -52,16 +52,17 @@ static ColliderCylinderInit sCylinderInit = { { 50, 10, 0, { 0, 0, 0 } }, }; -static u16 sEntranceIndexes[] = { - 0x1A00, 0x1400, 0x1410, 0x1420, 0x1430, 0x1440, 0x1450, 0x1460, - 0x1470, 0x1480, 0x1490, 0x14A0, 0x14B0, 0x14C0, 0x14D0, +static u16 sEntrances[] = { + ENTRANCE(UNSET_0D, 0), ENTRANCE(GROTTOS, 0), ENTRANCE(GROTTOS, 1), ENTRANCE(GROTTOS, 2), ENTRANCE(GROTTOS, 3), + ENTRANCE(GROTTOS, 4), ENTRANCE(GROTTOS, 5), ENTRANCE(GROTTOS, 6), ENTRANCE(GROTTOS, 7), ENTRANCE(GROTTOS, 8), + ENTRANCE(GROTTOS, 9), ENTRANCE(GROTTOS, 10), ENTRANCE(GROTTOS, 11), ENTRANCE(GROTTOS, 12), ENTRANCE(GROTTOS, 13), }; void DoorAna_SetupAction(DoorAna* this, DoorAnaActionFunc actionFunction) { this->actionFunc = actionFunction; } -void DoorAna_Init(Actor* thisx, GlobalContext* globalCtx) { +void DoorAna_Init(Actor* thisx, PlayState* play) { DoorAna* this = THIS; s32 grottoType = DOORANA_GET_TYPE(&this->actor); @@ -69,7 +70,7 @@ void DoorAna_Init(Actor* thisx, GlobalContext* globalCtx) { 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); + Collider_InitAndSetCylinder(play, &this->bombCollider, &this->actor, &sCylinderInit); } else { this->actor.flags |= ACTOR_FLAG_10; // always update } @@ -84,22 +85,22 @@ void DoorAna_Init(Actor* thisx, GlobalContext* globalCtx) { this->actor.targetMode = 0; } -void DoorAna_Destroy(Actor* thisx, GlobalContext* globalCtx) { +void DoorAna_Destroy(Actor* thisx, PlayState* play) { DoorAna* this = THIS; s32 grottoType = DOORANA_GET_TYPE(&this->actor); if (grottoType == DOORANA_TYPE_HIDDEN_BOMB) { - Collider_DestroyCylinder(globalCtx, &this->bombCollider); + Collider_DestroyCylinder(play, &this->bombCollider); } } -void DoorAna_WaitClosed(DoorAna* this, GlobalContext* globalCtx) { +void DoorAna_WaitClosed(DoorAna* this, PlayState* play) { s32 grottoIsOpen = false; u32 grottoType = DOORANA_GET_TYPE(&this->actor); 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)) { + if (this->actor.xyzDistToPlayerSq < SQ(200.0f) && EnvFlags_Get(play, 5)) { grottoIsOpen = true; this->actor.flags &= ~ACTOR_FLAG_10; // always update OFF } @@ -107,11 +108,11 @@ void DoorAna_WaitClosed(DoorAna* this, GlobalContext* globalCtx) { } else { if (this->bombCollider.base.acFlags & AC_HIT) { // bomb collision grottoIsOpen = true; - Collider_DestroyCylinder(globalCtx, &this->bombCollider); + Collider_DestroyCylinder(play, &this->bombCollider); } else { Collider_UpdateCylinder(&this->actor, &this->bombCollider); - CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->bombCollider.base); + CollisionCheck_SetAC(play, &play->colChkCtx, &this->bombCollider.base); } } @@ -121,25 +122,25 @@ void DoorAna_WaitClosed(DoorAna* this, GlobalContext* globalCtx) { play_sound(NA_SE_SY_CORRECT_CHIME); } - func_800B8C50(&this->actor, globalCtx); + func_800B8C50(&this->actor, play); } -void DoorAna_WaitOpen(DoorAna* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); +void DoorAna_WaitOpen(DoorAna* this, PlayState* play) { + Player* player = GET_PLAYER(play); s32 grottoType = DOORANA_GET_TYPE(&this->actor); 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 ((this->actor.targetMode != 0) && (play->transitionTrigger == TRANS_TRIGGER_OFF) && + (play->transitionMode == TRANS_MODE_OFF) && (player->stateFlags1 & 0x80000000) && (player->unk_AE7 == 0)) { if (grottoType == DOORANA_TYPE_VISIBLE_SCENE_EXIT) { s32 exitIndex = DOORANA_GET_EXIT_INDEX(&this->actor); - globalCtx->nextEntranceIndex = globalCtx->setupExitList[exitIndex]; + play->nextEntrance = play->setupExitList[exitIndex]; } else { s32 destinationIdx = DOORANA_GET_ENTRANCE(&this->actor); - Play_SetupRespawnPoint(&globalCtx->state, RESPAWN_MODE_UNK_3, 0x4FF); + Play_SetupRespawnPoint(&play->state, RESPAWN_MODE_UNK_3, 0x4FF); 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; @@ -151,12 +152,12 @@ void DoorAna_WaitOpen(DoorAna* this, GlobalContext* globalCtx) { destinationIdx = DOORANA_GET_EX_ENTRANCE(&this->actor); } - globalCtx->nextEntranceIndex = sEntranceIndexes[destinationIdx]; + play->nextEntrance = sEntrances[destinationIdx]; } DoorAna_SetupAction(this, DoorAna_GrabLink); - } else if (!Play_InCsMode(globalCtx) && !(player->stateFlags1 & 0x08800000) && + } else if (!Play_InCsMode(play) && !(player->stateFlags1 & 0x08800000) && (this->actor.xzDistToPlayer <= 20.0f) && (this->actor.playerHeightRel >= -50.0f) && (this->actor.playerHeightRel <= 15.0f)) { player->stateFlags1 |= 0x80000000; @@ -170,7 +171,7 @@ void DoorAna_WaitOpen(DoorAna* this, GlobalContext* globalCtx) { Actor_SetScale(&this->actor, this->actor.scale.x); } -void DoorAna_GrabLink(DoorAna* this, GlobalContext* globalCtx) { +void DoorAna_GrabLink(DoorAna* this, PlayState* play) { Player* player; s8 pad[2]; @@ -183,19 +184,19 @@ void DoorAna_GrabLink(DoorAna* this, GlobalContext* globalCtx) { } if (this->actor.playerHeightRel <= 0.0f && this->actor.xzDistToPlayer > 20.0f) { - player = GET_PLAYER(globalCtx); + player = GET_PLAYER(play); 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; } } -void DoorAna_Update(Actor* thisx, GlobalContext* globalCtx) { +void DoorAna_Update(Actor* thisx, PlayState* play) { DoorAna* this = THIS; - this->actionFunc(this, globalCtx); - this->actor.shape.rot.y = BINANG_ROT180(Camera_GetCamDirYaw(GET_ACTIVE_CAM(globalCtx))); + this->actionFunc(this, play); + this->actor.shape.rot.y = BINANG_ROT180(Camera_GetCamDirYaw(GET_ACTIVE_CAM(play))); } -void DoorAna_Draw(Actor* thisx, GlobalContext* globalCtx) { - Gfx_DrawDListXlu(globalCtx, gameplay_field_keep_DL_000C40); +void DoorAna_Draw(Actor* thisx, PlayState* play) { + Gfx_DrawDListXlu(play, gameplay_field_keep_DL_000C40); } 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 0cff726e9..980d0140f 100644 --- a/src/overlays/actors/ovl_Door_Ana/z_door_ana.h +++ b/src/overlays/actors/ovl_Door_Ana/z_door_ana.h @@ -5,7 +5,7 @@ struct DoorAna; -typedef void (*DoorAnaActionFunc)(struct DoorAna*, GlobalContext*); +typedef void (*DoorAnaActionFunc)(struct DoorAna*, PlayState*); typedef struct DoorAna { /* 0x000 */ Actor actor; diff --git a/src/overlays/actors/ovl_Door_Shutter/z_door_shutter.c b/src/overlays/actors/ovl_Door_Shutter/z_door_shutter.c index 01430acc3..0c99056b4 100644 --- a/src/overlays/actors/ovl_Door_Shutter/z_door_shutter.c +++ b/src/overlays/actors/ovl_Door_Shutter/z_door_shutter.c @@ -5,6 +5,7 @@ */ #include "z_door_shutter.h" +#include "z64rumble.h" #include "objects/gameplay_keep/gameplay_keep.h" #include "objects/object_bdoor/object_bdoor.h" #include "objects/object_numa_obj/object_numa_obj.h" @@ -22,21 +23,21 @@ #define THIS ((DoorShutter*)thisx) -void DoorShutter_Init(Actor* thisx, GlobalContext* globalCtx); -void DoorShutter_Destroy(Actor* thisx, GlobalContext* globalCtx); -void DoorShutter_Update(Actor* thisx, GlobalContext* globalCtx); +void DoorShutter_Init(Actor* thisx, PlayState* play); +void DoorShutter_Destroy(Actor* thisx, PlayState* play); +void DoorShutter_Update(Actor* thisx, PlayState* play); -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); +void DoorShutter_SetupType(DoorShutter* this, PlayState* play); +void func_808A0F88(DoorShutter* this, PlayState* play); +void func_808A1080(DoorShutter* this, PlayState* play); +void func_808A1090(DoorShutter* this, PlayState* play); +void func_808A1548(DoorShutter* this, PlayState* play); +void func_808A1618(DoorShutter* this, PlayState* play); +void func_808A1684(DoorShutter* this, PlayState* play); +void func_808A1784(DoorShutter* this, PlayState* play); +void func_808A1B48(DoorShutter* this, PlayState* play); +void func_808A1C50(DoorShutter* this, PlayState* play); +void DoorShutter_Draw(Actor* thisx, PlayState* play); const ActorInit Door_Shutter_InitVars = { ACTOR_DOOR_SHUTTER, @@ -137,8 +138,8 @@ void DoorShutter_SetupAction(DoorShutter* this, DoorShutterActionFunc actionFunc this->unk_167 = 0; } -s32 func_808A0900(DoorShutter* this, GlobalContext* globalCtx) { - TransitionActorEntry* transitionEntry = &globalCtx->doorCtx.transitionActorList[DOORSHUTTER_GET_FC00(&this->actor)]; +s32 func_808A0900(DoorShutter* this, PlayState* play) { + TransitionActorEntry* transitionEntry = &play->doorCtx.transitionActorList[DOORSHUTTER_GET_FC00(&this->actor)]; s8 frontRoom = transitionEntry->sides[0].room; if (frontRoom == transitionEntry->sides[1].room) { @@ -149,12 +150,12 @@ s32 func_808A0900(DoorShutter* this, GlobalContext* globalCtx) { return frontRoom == this->actor.room; } -s32 DoorShutter_SetupDoor(DoorShutter* this, GlobalContext* globalCtx) { +s32 DoorShutter_SetupDoor(DoorShutter* this, PlayState* play) { ShutterObjectInfo* sp24 = &D_808A2180[this->unk_163]; s32 doorType = this->doorType; if (doorType != 4) { - if (func_808A0900(this, globalCtx)) { + if (func_808A0900(this, play)) { if ((doorType == 7) || (doorType == 6)) { doorType = 1; } else if (doorType == 5) { @@ -172,13 +173,13 @@ s32 DoorShutter_SetupDoor(DoorShutter* this, GlobalContext* globalCtx) { } if (doorType == 1) { - if (!Flags_GetClear(globalCtx, this->actor.room)) { + if (!Flags_GetClear(play, 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))) { + if (!Flags_GetSwitch(play, DOORSHUTTER_GET_7F(&this->actor))) { DoorShutter_SetupAction(this, func_808A1548); this->unk_168 = 1.0f; return true; @@ -194,8 +195,8 @@ s32 DoorShutter_SetupDoor(DoorShutter* this, GlobalContext* globalCtx) { return false; } -void DoorShutter_Init(Actor* thisx, GlobalContext* globalCtx2) { - GlobalContext* globalCtx = globalCtx2; +void DoorShutter_Init(Actor* thisx, PlayState* play2) { + PlayState* play = play2; DoorShutter* this = THIS; s32 sp24; s32 i; @@ -209,7 +210,7 @@ void DoorShutter_Init(Actor* thisx, GlobalContext* globalCtx2) { ShutterSceneInfo* shutterSceneInfo = &D_808A2258[0]; for (i = 0; i < ARRAY_COUNT(D_808A2258) - 1; i++, shutterSceneInfo++) { - if (globalCtx->sceneNum == shutterSceneInfo->sceneNum) { + if (play->sceneNum == shutterSceneInfo->sceneNum) { break; } } @@ -222,8 +223,7 @@ void DoorShutter_Init(Actor* thisx, GlobalContext* globalCtx2) { BossDoorInfo* bossDoorInfo = &D_808A22A0[0]; for (i = 0; i < ARRAY_COUNT(D_808A22A0) - 1; i++, bossDoorInfo++) { - if ((globalCtx->sceneNum == bossDoorInfo->dungeonScene) || - (globalCtx->sceneNum == bossDoorInfo->bossScene)) { + if ((play->sceneNum == bossDoorInfo->dungeonScene) || (play->sceneNum == bossDoorInfo->bossScene)) { break; } } @@ -234,14 +234,14 @@ void DoorShutter_Init(Actor* thisx, GlobalContext* globalCtx2) { } // clang-format off - objId = Object_GetIndex(&globalCtx->objectCtx, D_808A2180[sp24].objectId); this->requiredObjBankIndex = objId; if (objId < 0) { Actor_MarkForDeath(&this->actor); return; } + objId = Object_GetIndex(&play->objectCtx, D_808A2180[sp24].objectId); this->requiredObjBankIndex = objId; if (objId < 0) { Actor_MarkForDeath(&this->actor); return; } // clang-format on DoorShutter_SetupAction(this, DoorShutter_SetupType); this->unk_163 = sp24; if ((this->doorType == 4) || (this->doorType == 5)) { - if (!Flags_GetSwitch(globalCtx, DOORSHUTTER_GET_7F(&this->actor))) { + if (!Flags_GetSwitch(play, DOORSHUTTER_GET_7F(&this->actor))) { this->unk_166 = 10; } } @@ -249,27 +249,27 @@ void DoorShutter_Init(Actor* thisx, GlobalContext* globalCtx2) { Actor_SetFocus(&this->actor, 60.0f); } -void DoorShutter_Destroy(Actor* thisx, GlobalContext* globalCtx) { +void DoorShutter_Destroy(Actor* thisx, PlayState* play) { DoorShutter* this = THIS; if (this->actor.room >= 0) { s32 transitionActorId = DOORSHUTTER_GET_FC00(&this->actor); - globalCtx->doorCtx.transitionActorList[transitionActorId].id = - -globalCtx->doorCtx.transitionActorList[transitionActorId].id; + play->doorCtx.transitionActorList[transitionActorId].id = + -play->doorCtx.transitionActorList[transitionActorId].id; } } -void DoorShutter_SetupType(DoorShutter* this, GlobalContext* globalCtx) { - if (Object_IsLoaded(&globalCtx->objectCtx, this->requiredObjBankIndex) && ((MREG(64) == 0) || (MREG(68) == 0))) { +void DoorShutter_SetupType(DoorShutter* this, PlayState* play) { + if (Object_IsLoaded(&play->objectCtx, this->requiredObjBankIndex) && ((MREG(64) == 0) || (MREG(68) == 0))) { this->actor.objBankIndex = this->requiredObjBankIndex; this->actor.draw = DoorShutter_Draw; - DoorShutter_SetupDoor(this, globalCtx); + DoorShutter_SetupDoor(this, play); } } -f32 func_808A0D90(GlobalContext* globalCtx, DoorShutter* this, f32 arg2, f32 arg3, f32 arg4) { - Player* player = GET_PLAYER(globalCtx); +f32 func_808A0D90(PlayState* play, DoorShutter* this, f32 arg2, f32 arg3, f32 arg4) { + Player* player = GET_PLAYER(play); Vec3f sp28; Vec3f sp1C; @@ -285,12 +285,12 @@ f32 func_808A0D90(GlobalContext* globalCtx, DoorShutter* this, f32 arg2, f32 arg return sp1C.z; } -s32 func_808A0E28(DoorShutter* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); +s32 func_808A0E28(DoorShutter* this, PlayState* play) { + Player* player = GET_PLAYER(play); - if (!Player_InCsMode(&globalCtx->state)) { + if (!Player_InCsMode(play)) { ShutterInfo* shutterInfo = &D_808A21B0[this->unk_164]; - f32 temp_f0 = func_808A0D90(globalCtx, this, 0.0f, shutterInfo->unk_0A, shutterInfo->unk_0B); + f32 temp_f0 = func_808A0D90(play, 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); @@ -307,8 +307,8 @@ s32 func_808A0E28(DoorShutter* this, GlobalContext* globalCtx) { return false; } -void func_808A0F88(DoorShutter* this, GlobalContext* globalCtx) { - if (Flags_GetClear(globalCtx, this->actor.room) || Flags_GetClearTemp(globalCtx, this->actor.room)) { +void func_808A0F88(DoorShutter* this, PlayState* play) { + if (Flags_GetClear(play, this->actor.room) || Flags_GetClearTemp(play, this->actor.room)) { this->unk_160 = this->actor.cutscene; if (this->doorType == 7) { if (this->unk_160 != -1) { @@ -318,14 +318,14 @@ void func_808A0F88(DoorShutter* this, GlobalContext* globalCtx) { if (ActorCutscene_GetCanPlayNext(this->unk_160)) { ActorCutscene_StartAndSetUnkLinkFields(this->unk_160, &this->actor); - Flags_SetClear(globalCtx, this->actor.room); + Flags_SetClear(play, 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); + } else if (func_808A0E28(this, play)) { + Player* player = GET_PLAYER(play); player->doorType = -1; player->doorActor = &this->actor; @@ -334,15 +334,15 @@ void func_808A0F88(DoorShutter* this, GlobalContext* globalCtx) { } } -void func_808A1080(DoorShutter* this, GlobalContext* globalCtx) { +void func_808A1080(DoorShutter* this, PlayState* play) { } -void func_808A1090(DoorShutter* this, GlobalContext* globalCtx) { +void func_808A1090(DoorShutter* this, PlayState* play) { 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)); + Flags_SetSwitch(play, DOORSHUTTER_GET_7F(&this->actor)); if (this->doorType != 5) { gSaveContext.save.inventory.dungeonKeys[gSaveContext.mapIndex]--; Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_CHAIN_KEY_UNLOCK); @@ -351,10 +351,10 @@ void func_808A1090(DoorShutter* this, GlobalContext* globalCtx) { } } } else { - s32 doorDirection = func_808A0E28(this, globalCtx); + s32 doorDirection = func_808A0E28(this, play); if (doorDirection != 0) { - Player* player = GET_PLAYER(globalCtx); + Player* player = GET_PLAYER(play); player->doorType = 2; player->doorDirection = doorDirection; @@ -390,13 +390,13 @@ void func_808A1090(DoorShutter* this, GlobalContext* globalCtx) { } } -void func_808A1288(DoorShutter* this, GlobalContext* globalCtx) { +void func_808A1288(DoorShutter* this, PlayState* play) { if (this->actor.category == ACTORCAT_DOOR) { - Player* player = GET_PLAYER(globalCtx); + Player* player = GET_PLAYER(play); s32 sp38 = this->unk_164; s32 sp34 = 0xF; - if (DoorShutter_SetupDoor(this, globalCtx)) { + if (DoorShutter_SetupDoor(this, play)) { sp34 = 0x20; } @@ -405,15 +405,15 @@ void func_808A1288(DoorShutter* this, GlobalContext* globalCtx) { 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); + Camera_ChangeDoorCam(play->cameraPtrs[CAM_ID_MAIN], &this->actor, player->unk_3BA, this->unk_168, 12, sp34, 10); } } -s32 func_808A1340(DoorShutter* this, GlobalContext* globalCtx) { +s32 func_808A1340(DoorShutter* this, PlayState* play) { Vec3f sp2C; if (this->actor.velocity.y == 0.0f) { - func_808A1288(this, globalCtx); + func_808A1288(this, play); if (this->unk_163 != 7) { Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_SLIDE_DOOR_OPEN); } @@ -443,7 +443,7 @@ s32 func_808A1340(DoorShutter* this, GlobalContext* globalCtx) { return false; } -s32 func_808A1478(DoorShutter* this, GlobalContext* globalCtx, f32 arg2) { +s32 func_808A1478(DoorShutter* this, PlayState* play, f32 arg2) { f32 temp = 1.0f - arg2; if (temp == this->unk_168) { @@ -454,7 +454,7 @@ s32 func_808A1478(DoorShutter* this, GlobalContext* globalCtx, f32 arg2) { } if ((this->unk_160 != -1) && (ActorCutscene_GetCurrentIndex() == this->unk_160)) { - func_800B724C(globalCtx, &this->actor, 1); + func_800B724C(play, &this->actor, 1); } } @@ -464,9 +464,9 @@ s32 func_808A1478(DoorShutter* this, GlobalContext* globalCtx, f32 arg2) { 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))) { +void func_808A1548(DoorShutter* this, PlayState* play) { + if (func_808A1478(this, play, 1.0f)) { + if (Flags_GetSwitch(play, DOORSHUTTER_GET_7F(&this->actor))) { this->unk_160 = this->actor.cutscene; if (ActorCutscene_GetCanPlayNext(this->unk_160)) { ActorCutscene_StartAndSetUnkLinkFields(this->unk_160, &this->actor); @@ -475,8 +475,8 @@ void func_808A1548(DoorShutter* this, GlobalContext* globalCtx) { } else { ActorCutscene_SetIntentToPlay(this->unk_160); } - } else if (func_808A0E28(this, globalCtx)) { - Player* player = GET_PLAYER(globalCtx); + } else if (func_808A0E28(this, play)) { + Player* player = GET_PLAYER(play); player->doorType = -1; player->doorActor = &this->actor; @@ -486,18 +486,18 @@ void func_808A1548(DoorShutter* this, GlobalContext* globalCtx) { } } -void func_808A1618(DoorShutter* this, GlobalContext* globalCtx) { - if ((this->unk_15C == 0) && !Flags_GetSwitch(globalCtx, DOORSHUTTER_GET_7F(&this->actor))) { +void func_808A1618(DoorShutter* this, PlayState* play) { + if ((this->unk_15C == 0) && !Flags_GetSwitch(play, DOORSHUTTER_GET_7F(&this->actor))) { DoorShutter_SetupAction(this, func_808A1548); } else { - func_808A1090(this, globalCtx); + func_808A1090(this, play); } } -void func_808A1684(DoorShutter* this, GlobalContext* globalCtx) { +void func_808A1684(DoorShutter* this, PlayState* play) { f32 phi_f0; - if ((DECR(this->unk_166) == 0) && (globalCtx->roomCtx.unk31 == 0) && func_808A1340(this, globalCtx)) { + if ((DECR(this->unk_166) == 0) && (play->roomCtx.unk31 == 0) && func_808A1340(this, play)) { if (this->doorType == 5) { phi_f0 = 20.0f; } else { @@ -508,7 +508,7 @@ void func_808A1684(DoorShutter* this, GlobalContext* globalCtx) { if (this->unk_163 == 7) { this->actor.velocity.y = 0.0f; } else { - if (DoorShutter_SetupDoor(this, globalCtx)) { + if (DoorShutter_SetupDoor(this, play)) { this->actor.velocity.y = 30.0f; } Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_SLIDE_DOOR_CLOSE); @@ -518,22 +518,22 @@ void func_808A1684(DoorShutter* this, GlobalContext* globalCtx) { } } -void func_808A1784(DoorShutter* this, GlobalContext* globalCtx) { +void func_808A1784(DoorShutter* this, PlayState* play) { if (this->unk_167 != 0) { if (func_800F22C4(this->unk_160, &this->actor)) { if (this->unk_167 < 0) { - if ((globalCtx->state.frames % 2) != 0) { + if ((play->state.frames % 2) != 0) { this->unk_167++; } } else { this->unk_167--; } } - } else if (func_808A1478(this, globalCtx, 0.0f)) { + } else if (func_808A1478(this, play, 0.0f)) { u8 doorType = this->doorType; if ((doorType != 0) && (doorType != 1) && - (((doorType != 7) && (doorType != 6)) || !func_808A0900(this, globalCtx))) { + (((doorType != 7) && (doorType != 6)) || !func_808A0900(this, play))) { DoorShutter_SetupAction(this, func_808A1618); } else { DoorShutter_SetupAction(this, func_808A1090); @@ -542,39 +542,36 @@ void func_808A1784(DoorShutter* this, GlobalContext* globalCtx) { } } -void func_808A1884(DoorShutter* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); +void func_808A1884(DoorShutter* this, PlayState* play) { + Player* player = GET_PLAYER(play); 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; + this->actor.room = + play->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; + Room temp = play->roomCtx.currRoom; - globalCtx->roomCtx.currRoom = globalCtx->roomCtx.prevRoom; - globalCtx->roomCtx.prevRoom = temp; - globalCtx->roomCtx.activeMemPage ^= 1; + play->roomCtx.currRoom = play->roomCtx.prevRoom; + play->roomCtx.prevRoom = temp; + play->roomCtx.activeMemPage ^= 1; } - func_8012EBF8(globalCtx, &globalCtx->roomCtx); + func_8012EBF8(play, &play->roomCtx); } this->unk_15C = 0; this->actor.velocity.y = 0.0f; - if (DoorShutter_SetupDoor(this, globalCtx) && !(player->stateFlags1 & 0x800)) { + if (DoorShutter_SetupDoor(this, play) && !(player->stateFlags1 & 0x800)) { DoorShutter_SetupAction(this, func_808A1C50); if (ActorCutscene_GetCurrentIndex() == 0x7D) { - s8 data = gSaveContext.respawn[RESTART_MODE_DOWN].data; - - func_801226E0(globalCtx, data); + func_801226E0(play, ((void)0, gSaveContext.respawn[RESPAWN_MODE_DOWN].data)); player->unk_A86 = -1; - func_800B7298(globalCtx, NULL, 0x73); + func_800B7298(play, NULL, 0x73); } } } @@ -602,39 +599,39 @@ s32 func_808A1A70(DoorShutter* this) { return false; } -void func_808A1B48(DoorShutter* this, GlobalContext* globalCtx) { +void func_808A1B48(DoorShutter* this, PlayState* play) { 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_SpawnFloorDustRing(play, &this->actor, &this->actor.world.pos, 45.0f, 10, 8.0f, 500, 10, 0); } Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_BIGWALL_BOUND); - quake = Quake_Add(Play_GetCamera(globalCtx, 0), 3); + quake = Quake_Add(Play_GetCamera(play, CAM_ID_MAIN), 3); Quake_SetSpeed(quake, -32536); Quake_SetQuakeValues(quake, 2, 0, 0, 0); Quake_SetCountdown(quake, 10); - func_8013ECE0(this->actor.xyzDistToPlayerSq, 180, 20, 100); - func_808A1884(this, globalCtx); + Rumble_Request(this->actor.xyzDistToPlayerSq, 180, 20, 100); + func_808A1884(this, play); } } -void func_808A1C50(DoorShutter* this, GlobalContext* globalCtx) { +void func_808A1C50(DoorShutter* this, PlayState* play) { if (this->unk_167++ > 30) { - if (GET_PLAYER(globalCtx)->csMode == 0x73) { - func_800B7298(globalCtx, NULL, 6); + if (GET_PLAYER(play)->csMode == 0x73) { + func_800B7298(play, NULL, 6); } - DoorShutter_SetupDoor(this, globalCtx); + DoorShutter_SetupDoor(this, play); } } -void DoorShutter_Update(Actor* thisx, GlobalContext* globalCtx) { +void DoorShutter_Update(Actor* thisx, PlayState* play) { DoorShutter* this = THIS; - Player* player = GET_PLAYER(globalCtx); + Player* player = GET_PLAYER(play); if (!(player->stateFlags1 & 0x100004C0) || (this->actionFunc == DoorShutter_SetupType)) { - this->actionFunc(this, globalCtx); + this->actionFunc(this, play); if (this->unk_163 == 7) { this->actor.home.rot.z = Math_Vec3f_DistXZ(&this->actor.home.pos, &this->actor.world.pos) * -100.0f; @@ -642,15 +639,15 @@ void DoorShutter_Update(Actor* thisx, GlobalContext* globalCtx) { } } -s32 func_808A1D68(DoorShutter* this, GlobalContext* globalCtx) { +s32 func_808A1D68(DoorShutter* this, PlayState* play) { s32 temp_a0; s32 temp_a1; - if (Player_InCsMode(&globalCtx->state)) { + if (Player_InCsMode(play)) { return true; } - temp_a0 = BINANG_SUB(Actor_YawToPoint(&this->actor, &globalCtx->view.eye), this->actor.shape.rot.y); + temp_a0 = BINANG_SUB(Actor_YawToPoint(&this->actor, &play->view.eye), this->actor.shape.rot.y); temp_a1 = BINANG_SUB(this->actor.yawTowardsPlayer, this->actor.shape.rot.y); temp_a0 = ABS_ALT(temp_a0); @@ -662,58 +659,57 @@ s32 func_808A1D68(DoorShutter* this, GlobalContext* globalCtx) { return true; } -void DoorShutter_Draw(Actor* thisx, GlobalContext* globalCtx) { +void DoorShutter_Draw(Actor* thisx, PlayState* play) { s32 pad; DoorShutter* this = THIS; ShutterInfo* sp44; - if (func_808A1D68(this, globalCtx)) { + if (func_808A1D68(this, play)) { sp44 = &D_808A21B0[this->unk_164]; - OPEN_DISPS(globalCtx->state.gfxCtx); + OPEN_DISPS(play->state.gfxCtx); - func_8012C28C(globalCtx->state.gfxCtx); + func_8012C28C(play->state.gfxCtx); if (this->unk_164 == 7) { - Matrix_InsertTranslation(0.0f, 64.96f, 0.0f, MTXMODE_APPLY); - Matrix_InsertZRotation_s(this->actor.home.rot.z, MTXMODE_APPLY); - Matrix_InsertTranslation(0.0f, -64.96f, 0.0f, MTXMODE_APPLY); + 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)]; + &play->doorCtx.transitionActorList[DOORSHUTTER_GET_FC00(&this->actor)]; - if ((globalCtx->roomCtx.prevRoom.num >= 0) || + if ((play->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); + s16 yaw = this->actor.shape.rot.y - Math_Vec3f_Yaw(&play->view.eye, &this->actor.world.pos); if (ABS_ALT(yaw) < 0x4000) { - Matrix_InsertYRotation_f(M_PI, MTXMODE_APPLY); + Matrix_RotateYF(M_PI, MTXMODE_APPLY); } } else if (this->actor.room == transitionEntry->sides[0].room) { - Matrix_InsertYRotation_f(M_PI, MTXMODE_APPLY); + 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); + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_OPA_DISP++, sp44->unk_00); if ((this->unk_168 != 0.0f) && (sp44->unk_04 != 0)) { - Matrix_InsertTranslation(0.0f, sp44->unk_08 * (1.0f - this->unk_168), sp44->translateZ, MTXMODE_APPLY); + 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); + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(play->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); + Actor_DrawDoorLock(play, this->unk_166, (this->doorType == 5) ? DOORLOCK_BOSS : DOORLOCK_NORMAL); } - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->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 0b796d442..e0d5653e2 100644 --- a/src/overlays/actors/ovl_Door_Shutter/z_door_shutter.h +++ b/src/overlays/actors/ovl_Door_Shutter/z_door_shutter.h @@ -5,12 +5,12 @@ struct DoorShutter; -typedef void (*DoorShutterActionFunc)(struct DoorShutter*, GlobalContext*); +typedef void (*DoorShutterActionFunc)(struct DoorShutter*, PlayState*); #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)) +#define DOORSHUTTER_GET_FC00(thisx) ((u16)(thisx)->params >> 0xA) typedef struct DoorShutter { /* 0x0000 */ Actor actor; 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 a2bc8a0be..f43f7c58c 100644 --- a/src/overlays/actors/ovl_Door_Spiral/z_door_spiral.c +++ b/src/overlays/actors/ovl_Door_Spiral/z_door_spiral.c @@ -16,10 +16,6 @@ #define THIS ((DoorSpiral*)thisx) -#define GET_ORIENTATION_PARAM(this) ((((Actor*)(this))->params >> 7) & 0x1) -#define GET_UNK145_PARAM(this) ((((Actor*)(this))->params >> 8) & 0x3) -#define GET_TRANSITION_ID_PARAM(this) ((u16)((Actor*)(this))->params >> 10) - typedef enum { /* 0 */ SPIRAL_OVERWORLD, // does not display anything as there is not a DL in GAMEPLAY_KEEP for it /* 1 */ SPIRAL_DUNGEON, @@ -62,14 +58,14 @@ typedef struct { /* 0x02 */ u8 objectType; } SpiralSceneInfo; -void DoorSpiral_Init(Actor* thisx, GlobalContext* globalCtx); -void DoorSpiral_Destroy(Actor* thisx, GlobalContext* globalCtx); -void DoorSpiral_Update(Actor* thisx, GlobalContext* globalCtx); -void DoorSpiral_Draw(Actor* thisx, GlobalContext* globalCtx); +void DoorSpiral_Init(Actor* thisx, PlayState* play); +void DoorSpiral_Destroy(Actor* thisx, PlayState* play); +void DoorSpiral_Update(Actor* thisx, PlayState* play); +void DoorSpiral_Draw(Actor* thisx, PlayState* play); -void DoorSpiral_WaitForObject(DoorSpiral* this, GlobalContext* globalCtx); -void DoorSpiral_Wait(DoorSpiral* this, GlobalContext* globalCtx); -void DoorSpiral_PlayerClimb(DoorSpiral* this, GlobalContext* globalCtx); +void DoorSpiral_WaitForObject(DoorSpiral* this, PlayState* play); +void DoorSpiral_Wait(DoorSpiral* this, PlayState* play); +void DoorSpiral_PlayerClimb(DoorSpiral* this, PlayState* play); const ActorInit Door_Spiral_InitVars = { ACTOR_DOOR_SPIRAL, @@ -114,13 +110,13 @@ void DoorSpiral_SetupAction(DoorSpiral* this, DoorSpiralActionFunc actionFunc) { /** * Sets this->spiralType, which is derived from `sSpiralObjectInfo`, and is used as an index to `sSpiralInfo`. */ -s32 DoorSpiral_SetSpiralType(DoorSpiral* this, GlobalContext* globalCtx) { +s32 DoorSpiral_SetSpiralType(DoorSpiral* this, PlayState* play) { SpiralObjectInfo* doorObjectInfo = &sSpiralObjectInfo[this->objectType]; this->spiralType = doorObjectInfo->spiralType; if ((this->spiralType == SPIRAL_DAMPES_HOUSE) || - ((this->spiralType == SPIRAL_WOODFALL_TEMPLE) && globalCtx->roomCtx.currRoom.enablePosLights)) { + ((this->spiralType == SPIRAL_WOODFALL_TEMPLE) && play->roomCtx.currRoom.enablePosLights)) { if (this->spiralType == SPIRAL_WOODFALL_TEMPLE) { this->spiralType = SPIRAL_WOODFALL_TEMPLE_ALT; } @@ -138,7 +134,7 @@ s32 DoorSpiral_SetSpiralType(DoorSpiral* this, GlobalContext* globalCtx) { * It first checks `sSpiralSceneInfo`, but if the current scene is not found it will fall back to the default spiral * (overworld or dungeon). */ -s32 DoorSpiral_GetObjectType(GlobalContext* globalCtx) { +s32 DoorSpiral_GetObjectType(PlayState* play) { // Defines which object type should be used for specific scenes static SpiralSceneInfo spiralSceneInfo[] = { { SCENE_MITURIN, SPIRAL_OBJECT_WOODFALL }, { SCENE_HAKUGIN, SPIRAL_OBJECT_SNOWHEAD }, @@ -151,7 +147,7 @@ s32 DoorSpiral_GetObjectType(GlobalContext* globalCtx) { s32 type; for (i = 0; i < ARRAY_COUNT(spiralSceneInfo); sceneInfo++, i++) { - if (globalCtx->sceneNum == sceneInfo->sceneNum) { + if (play->sceneNum == sceneInfo->sceneNum) { break; } } @@ -162,8 +158,8 @@ s32 DoorSpiral_GetObjectType(GlobalContext* globalCtx) { type = sceneInfo->objectType; } else { // Set the type based on if link is in a dungeon scene, or the overworld - type = (Object_GetIndex(&globalCtx->objectCtx, GAMEPLAY_DANGEON_KEEP) >= 0) ? SPIRAL_OBJECT_DUNGEON - : SPIRAL_OBJECT_OVERWORLD; + type = (Object_GetIndex(&play->objectCtx, GAMEPLAY_DANGEON_KEEP) >= 0) ? SPIRAL_OBJECT_DUNGEON + : SPIRAL_OBJECT_OVERWORLD; } return type; @@ -176,22 +172,22 @@ static InitChainEntry sInitChain[] = { ICHAIN_F32(uncullZoneDownward, 400, ICHAIN_STOP), }; -void DoorSpiral_Init(Actor* thisx, GlobalContext* globalCtx) { +void DoorSpiral_Init(Actor* thisx, PlayState* play) { DoorSpiral* this = THIS; s32 pad; - s32 transition = GET_TRANSITION_ID_PARAM(thisx); + s32 transition = DOORSPIRAL_GET_TRANSITION_ID(thisx); s8 objBankId; - if (this->actor.room != globalCtx->doorCtx.transitionActorList[transition].sides[0].room) { + if (this->actor.room != play->doorCtx.transitionActorList[transition].sides[0].room) { Actor_MarkForDeath(&this->actor); return; } Actor_ProcessInitChain(&this->actor, sInitChain); - this->unk145 = GET_UNK145_PARAM(thisx); // set but never used - this->orientation = GET_ORIENTATION_PARAM(thisx); - this->objectType = DoorSpiral_GetObjectType(globalCtx); - objBankId = Object_GetIndex(&globalCtx->objectCtx, sSpiralObjectInfo[this->objectType].objectBankId); + this->unk145 = DOORSPIRAL_GET_UNK145(thisx); // set but never used + this->orientation = DOORSPIRAL_GET_ORIENTATION(thisx); + this->objectType = DoorSpiral_GetObjectType(play); + objBankId = Object_GetIndex(&play->objectCtx, sSpiralObjectInfo[this->objectType].objectBankId); this->bankIndex = objBankId; if (objBankId < 0) { @@ -203,28 +199,27 @@ void DoorSpiral_Init(Actor* thisx, GlobalContext* globalCtx) { Actor_SetFocus(&this->actor, 60.0f); } -void DoorSpiral_Destroy(Actor* thisx, GlobalContext* globalCtx) { - s32 transition = GET_TRANSITION_ID_PARAM(thisx); +void DoorSpiral_Destroy(Actor* thisx, PlayState* play) { + s32 transition = DOORSPIRAL_GET_TRANSITION_ID(thisx); - globalCtx->doorCtx.transitionActorList[transition].id *= -1; + play->doorCtx.transitionActorList[transition].id *= -1; } /** * Waits for the required object to be loaded. */ -void DoorSpiral_WaitForObject(DoorSpiral* this, GlobalContext* globalCtx) { - if (Object_IsLoaded(&globalCtx->objectCtx, this->bankIndex)) { +void DoorSpiral_WaitForObject(DoorSpiral* this, PlayState* play) { + if (Object_IsLoaded(&play->objectCtx, this->bankIndex)) { this->actor.objBankIndex = this->bankIndex; - DoorSpiral_SetSpiralType(this, globalCtx); + DoorSpiral_SetSpiralType(this, play); } } /** * Finds the distance between the stairs and the player. */ -f32 DoorSpiral_GetDistFromPlayer(GlobalContext* globalCtx, DoorSpiral* this, f32 yOffset, f32 spiralWidth, - f32 spiralHeight) { - Player* player = GET_PLAYER(globalCtx); +f32 DoorSpiral_GetDistFromPlayer(PlayState* play, DoorSpiral* this, f32 yOffset, f32 spiralWidth, f32 spiralHeight) { + Player* player = GET_PLAYER(play); Vec3f target; Vec3f offset; @@ -244,13 +239,12 @@ f32 DoorSpiral_GetDistFromPlayer(GlobalContext* globalCtx, DoorSpiral* this, f32 /** * Checks if the player should climb the stairs. */ -s32 DoorSpiral_PlayerShouldClimb(DoorSpiral* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); +s32 DoorSpiral_PlayerShouldClimb(DoorSpiral* this, PlayState* play) { + Player* player = GET_PLAYER(play); - if (!Player_InCsMode(&globalCtx->state)) { + if (!Player_InCsMode(play)) { SpiralInfo* spiralInfo = &sSpiralInfo[this->spiralType]; - f32 dist = - DoorSpiral_GetDistFromPlayer(globalCtx, this, 0.0f, spiralInfo->spiralWidth, spiralInfo->spiralHeight); + f32 dist = DoorSpiral_GetDistFromPlayer(play, this, 0.0f, spiralInfo->spiralWidth, spiralInfo->spiralHeight); if (fabsf(dist) < 64.0f) { s16 angle = player->actor.shape.rot.y - this->actor.shape.rot.y; @@ -271,20 +265,20 @@ s32 DoorSpiral_PlayerShouldClimb(DoorSpiral* this, GlobalContext* globalCtx) { /** * Wait for the player to interact with the stairs. */ -void DoorSpiral_Wait(DoorSpiral* this, GlobalContext* globalCtx) { +void DoorSpiral_Wait(DoorSpiral* this, PlayState* play) { Player* player; s32 transition; if (this->shouldClimb) { DoorSpiral_SetupAction(this, DoorSpiral_PlayerClimb); - } else if (DoorSpiral_PlayerShouldClimb(this, globalCtx)) { - player = GET_PLAYER(globalCtx); + } else if (DoorSpiral_PlayerShouldClimb(this, play)) { + player = GET_PLAYER(play); player->doorType = 4; player->doorDirection = this->orientation; player->doorActor = &this->actor; - transition = GET_TRANSITION_ID_PARAM(this); - player->doorNext = ((u16)globalCtx->doorCtx.transitionActorList[transition].params) >> 10; + transition = DOORSPIRAL_GET_TRANSITION_ID(&this->actor); + player->doorNext = ((u16)play->doorCtx.transitionActorList[transition].params) >> 10; func_80122F28(player); } @@ -293,8 +287,8 @@ void DoorSpiral_Wait(DoorSpiral* this, GlobalContext* globalCtx) { /** * Player is climbing the stairs. */ -void DoorSpiral_PlayerClimb(DoorSpiral* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); +void DoorSpiral_PlayerClimb(DoorSpiral* this, PlayState* play) { + Player* player = GET_PLAYER(play); if (!(player->stateFlags1 & 0x20000000)) { DoorSpiral_SetupAction(this, DoorSpiral_WaitForObject); @@ -302,17 +296,17 @@ void DoorSpiral_PlayerClimb(DoorSpiral* this, GlobalContext* globalCtx) { } } -void DoorSpiral_Update(Actor* thisx, GlobalContext* globalCtx) { +void DoorSpiral_Update(Actor* thisx, PlayState* play) { DoorSpiral* this = THIS; s32 pad; - Player* player = GET_PLAYER(globalCtx); + Player* player = GET_PLAYER(play); if ((!(player->stateFlags1 & 0x100004C0)) || (this->actionFunc == DoorSpiral_WaitForObject)) { - this->actionFunc(this, globalCtx); + this->actionFunc(this, play); } } -void DoorSpiral_Draw(Actor* thisx, GlobalContext* globalCtx) { +void DoorSpiral_Draw(Actor* thisx, PlayState* play) { s32 pad; DoorSpiral* this = THIS; @@ -324,15 +318,14 @@ void DoorSpiral_Draw(Actor* thisx, GlobalContext* globalCtx) { dList = spiralInfo->spiralDL[this->orientation]; if (dList != NULL) { - OPEN_DISPS(globalCtx->state.gfxCtx); + OPEN_DISPS(play->state.gfxCtx); - func_8012C28C(globalCtx->state.gfxCtx); + func_8012C28C(play->state.gfxCtx); - gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), - G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_OPA_DISP++, spiralInfo->spiralDL[this->orientation]); - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->state.gfxCtx); } } } diff --git a/src/overlays/actors/ovl_Door_Spiral/z_door_spiral.h b/src/overlays/actors/ovl_Door_Spiral/z_door_spiral.h index cf191949a..f12b79d84 100644 --- a/src/overlays/actors/ovl_Door_Spiral/z_door_spiral.h +++ b/src/overlays/actors/ovl_Door_Spiral/z_door_spiral.h @@ -5,7 +5,11 @@ struct DoorSpiral; -typedef void (*DoorSpiralActionFunc)(struct DoorSpiral*, GlobalContext*); +#define DOORSPIRAL_GET_ORIENTATION(thisx) (((thisx)->params >> 7) & 0x1) +#define DOORSPIRAL_GET_UNK145(thisx) (((thisx)->params >> 8) & 0x3) +#define DOORSPIRAL_GET_TRANSITION_ID(thisx) ((u16)(thisx)->params >> 10) + +typedef void (*DoorSpiralActionFunc)(struct DoorSpiral*, PlayState*); typedef struct DoorSpiral { /* 0x000 */ Actor actor; 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 b2b05230f..9399bf5ca 100644 --- a/src/overlays/actors/ovl_Door_Warp1/z_door_warp1.c +++ b/src/overlays/actors/ovl_Door_Warp1/z_door_warp1.c @@ -11,40 +11,40 @@ #define THIS ((DoorWarp1*)thisx) -void DoorWarp1_Init(Actor* thisx, GlobalContext* globalCtx); -void DoorWarp1_Destroy(Actor* thisx, GlobalContext* globalCtx); -void DoorWarp1_Update(Actor* thisx, GlobalContext* globalCtx); -void DoorWarp1_Draw(Actor* thisx, GlobalContext* globalCtx); +void DoorWarp1_Init(Actor* thisx, PlayState* play); +void DoorWarp1_Destroy(Actor* thisx, PlayState* play); +void DoorWarp1_Update(Actor* thisx, PlayState* play); +void DoorWarp1_Draw(Actor* thisx, PlayState* play); void DoorWarp1_SetupAction(DoorWarp1* this, DoorWarp1ActionFunc actionFunc); -void func_808B8924(DoorWarp1* this, GlobalContext* globalCtx); -void func_808B8A7C(DoorWarp1* this, GlobalContext* globalCtx); -void func_808B8C48(DoorWarp1* this, GlobalContext* globalCtx); -void func_808B8E78(DoorWarp1* this, GlobalContext* globalCtx); -void func_808B9094(DoorWarp1* this, GlobalContext* globalCtx); -void func_808B90CC(DoorWarp1* this, GlobalContext* globalCtx); -void func_808B921C(DoorWarp1* this, GlobalContext* globalCtx); -void func_808B93A0(DoorWarp1* this, GlobalContext* globalCtx); -void func_808B94A4(DoorWarp1* this, GlobalContext* globalCtx); -void func_808B9524(DoorWarp1* this, GlobalContext* globalCtx); -void func_808B958C(DoorWarp1* this, GlobalContext* globalCtx); -void func_808B96A0(DoorWarp1* this, GlobalContext* globalCtx); -void func_808B96B0(DoorWarp1* this, GlobalContext* globalCtx); -void func_808B977C(DoorWarp1* this, GlobalContext* globalCtx); -void func_808B9840(DoorWarp1* this, GlobalContext* globalCtx); -void func_808B98A8(DoorWarp1* this, GlobalContext* globalCtx); -void func_808B9B30(DoorWarp1* this, GlobalContext* globalCtx); -void func_808B9BE8(DoorWarp1* this, GlobalContext* globalCtx); -void func_808B9CE8(DoorWarp1* this, GlobalContext* globalCtx); -void func_808B9E94(DoorWarp1* this, GlobalContext* globalCtx); -void func_808B9ED8(DoorWarp1* this, GlobalContext* globalCtx); -void func_808B9F10(DoorWarp1* this, GlobalContext* globalCtx); -void func_808B9FD0(DoorWarp1* this, GlobalContext* globalCtx); -void func_808BA10C(DoorWarp1* this, GlobalContext* globalCtx); -void func_808BA550(DoorWarp1* this, GlobalContext* globalCtx); -void func_808BAAF4(DoorWarp1* this, GlobalContext* globalCtx); -void func_808BABF4(DoorWarp1* this, GlobalContext* globalCtx); -void func_808BB8D4(DoorWarp1* this, GlobalContext* globalCtx, s32 arg2); +void func_808B8924(DoorWarp1* this, PlayState* play); +void func_808B8A7C(DoorWarp1* this, PlayState* play); +void func_808B8C48(DoorWarp1* this, PlayState* play); +void func_808B8E78(DoorWarp1* this, PlayState* play); +void func_808B9094(DoorWarp1* this, PlayState* play); +void func_808B90CC(DoorWarp1* this, PlayState* play); +void func_808B921C(DoorWarp1* this, PlayState* play); +void func_808B93A0(DoorWarp1* this, PlayState* play); +void func_808B94A4(DoorWarp1* this, PlayState* play); +void func_808B9524(DoorWarp1* this, PlayState* play); +void func_808B958C(DoorWarp1* this, PlayState* play); +void func_808B96A0(DoorWarp1* this, PlayState* play); +void func_808B96B0(DoorWarp1* this, PlayState* play); +void func_808B977C(DoorWarp1* this, PlayState* play); +void func_808B9840(DoorWarp1* this, PlayState* play); +void func_808B98A8(DoorWarp1* this, PlayState* play); +void func_808B9B30(DoorWarp1* this, PlayState* play); +void func_808B9BE8(DoorWarp1* this, PlayState* play); +void func_808B9CE8(DoorWarp1* this, PlayState* play); +void func_808B9E94(DoorWarp1* this, PlayState* play); +void func_808B9ED8(DoorWarp1* this, PlayState* play); +void func_808B9F10(DoorWarp1* this, PlayState* play); +void func_808B9FD0(DoorWarp1* this, PlayState* play); +void func_808BA10C(DoorWarp1* this, PlayState* play); +void func_808BA550(DoorWarp1* this, PlayState* play); +void func_808BAAF4(DoorWarp1* this, PlayState* play); +void func_808BABF4(DoorWarp1* this, PlayState* play); +void func_808BB8D4(DoorWarp1* this, PlayState* play, s32 arg2); static s16 D_808BC000; static f32 D_808BC004; @@ -72,34 +72,34 @@ void DoorWarp1_SetupAction(DoorWarp1* this, DoorWarp1ActionFunc actionFunc) { this->actionFunc = actionFunc; } -s32 func_808B849C(DoorWarp1* this, GlobalContext* globalCtx) { +s32 func_808B849C(DoorWarp1* this, PlayState* play) { s32 ret = 0; - if ((globalCtx->sceneNum == SCENE_MITURIN_BS) && !CHECK_QUEST_ITEM(QUEST_REMAINS_ODOWLA)) { + if ((play->sceneNum == SCENE_MITURIN_BS) && !CHECK_QUEST_ITEM(QUEST_REMAINS_ODOWLA)) { ret = 1; - } else if ((globalCtx->sceneNum == SCENE_HAKUGIN_BS) && !CHECK_QUEST_ITEM(QUEST_REMAINS_GOHT)) { + } else if ((play->sceneNum == SCENE_HAKUGIN_BS) && !CHECK_QUEST_ITEM(QUEST_REMAINS_GOHT)) { ret = 2; - } else if ((globalCtx->sceneNum == SCENE_SEA_BS) && !CHECK_QUEST_ITEM(QUEST_REMAINS_GYORG)) { + } else if ((play->sceneNum == SCENE_SEA_BS) && !CHECK_QUEST_ITEM(QUEST_REMAINS_GYORG)) { ret = 3; - } else if ((globalCtx->sceneNum == SCENE_INISIE_BS) && !CHECK_QUEST_ITEM(QUEST_REMAINS_TWINMOLD)) { + } else if ((play->sceneNum == SCENE_INISIE_BS) && !CHECK_QUEST_ITEM(QUEST_REMAINS_TWINMOLD)) { ret = 4; } return ret; } -void func_808B8568(DoorWarp1* this, GlobalContext* globalCtx) { +void func_808B8568(DoorWarp1* this, PlayState* play) { s32 pad[2]; Lights_PointNoGlowSetInfo(&this->unk_1E0, this->dyna.actor.world.pos.x, this->dyna.actor.world.pos.y, this->dyna.actor.world.pos.z, 0, 0, 0, 0); - this->unk_1DC = LightContext_InsertLight(globalCtx, &globalCtx->lightCtx, &this->unk_1E0); + this->unk_1DC = LightContext_InsertLight(play, &play->lightCtx, &this->unk_1E0); Lights_PointNoGlowSetInfo(&this->unk_1F4, this->dyna.actor.world.pos.x, this->dyna.actor.world.pos.y, this->dyna.actor.world.pos.z, 0, 0, 0, 0); - this->unk_1F0 = LightContext_InsertLight(globalCtx, &globalCtx->lightCtx, &this->unk_1F4); + this->unk_1F0 = LightContext_InsertLight(play, &play->lightCtx, &this->unk_1F4); } -s32 func_808B866C(DoorWarp1* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); +s32 func_808B866C(DoorWarp1* this, PlayState* play) { + Player* player = GET_PLAYER(play); s32 ret = false; if ((fabsf(this->dyna.actor.xzDistToPlayer) < 60.0f) && @@ -110,7 +110,7 @@ s32 func_808B866C(DoorWarp1* this, GlobalContext* globalCtx) { return ret; } -void DoorWarp1_Init(Actor* thisx, GlobalContext* globalCtx) { +void DoorWarp1_Init(Actor* thisx, PlayState* play) { DoorWarp1* this = THIS; this->unk_1CC = 0; @@ -133,17 +133,17 @@ void DoorWarp1_Init(Actor* thisx, GlobalContext* globalCtx) { case ENDOORWARP1_FF_3: case ENDOORWARP1_FF_4: case ENDOORWARP1_FF_5: - func_808B8568(this, globalCtx); + func_808B8568(this, play); break; } switch (DOORWARP1_GET_FF(&this->dyna.actor)) { case ENDOORWARP1_FF_0: - func_808B8924(this, globalCtx); + func_808B8924(this, play); break; case ENDOORWARP1_FF_1: - func_808B8A7C(this, globalCtx); + func_808B8A7C(this, play); break; case ENDOORWARP1_FF_2: @@ -152,43 +152,43 @@ void DoorWarp1_Init(Actor* thisx, GlobalContext* globalCtx) { case ENDOORWARP1_FF_5: this->unk_1D3 = 1; DynaPolyActor_Init(&this->dyna, 0); - DynaPolyActor_LoadMesh(globalCtx, &this->dyna, &object_warp1_Colheader_008BD4); - func_808B8C48(this, globalCtx); + DynaPolyActor_LoadMesh(play, &this->dyna, &object_warp1_Colheader_008BD4); + func_808B8C48(this, play); break; case ENDOORWARP1_FF_6: - func_808B8E78(this, globalCtx); + func_808B8E78(this, play); break; } - if ((globalCtx->sceneNum == SCENE_MITURIN_BS) || (globalCtx->sceneNum == SCENE_HAKUGIN_BS) || - (globalCtx->sceneNum == SCENE_INISIE_BS) || (globalCtx->sceneNum == SCENE_SEA_BS)) { + if ((play->sceneNum == SCENE_MITURIN_BS) || (play->sceneNum == SCENE_HAKUGIN_BS) || + (play->sceneNum == SCENE_INISIE_BS) || (play->sceneNum == SCENE_SEA_BS)) { func_800FE484(); - globalCtx->interfaceCtx.restrictions.unk_312 = 1; - globalCtx->interfaceCtx.restrictions.songOfSoaring = 1; + play->interfaceCtx.restrictions.unk_312 = 1; + play->interfaceCtx.restrictions.songOfSoaring = 1; } } -void DoorWarp1_Destroy(Actor* thisx, GlobalContext* globalCtx) { +void DoorWarp1_Destroy(Actor* thisx, PlayState* play) { s32 pad; DoorWarp1* this = THIS; s16 i; - LightContext_RemoveLight(globalCtx, &globalCtx->lightCtx, this->unk_1DC); - LightContext_RemoveLight(globalCtx, &globalCtx->lightCtx, this->unk_1F0); + LightContext_RemoveLight(play, &play->lightCtx, this->unk_1DC); + LightContext_RemoveLight(play, &play->lightCtx, this->unk_1F0); - 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]; + for (i = 0; i < ARRAY_COUNT(play->envCtx.lightSettings.diffuseColor1); i++) { + play->envCtx.lightSettings.diffuseColor1[i] = 0; + play->envCtx.lightSettings.fogColor[i] = play->envCtx.lightSettings.diffuseColor1[i]; + play->envCtx.lightSettings.ambientColor[i] = play->envCtx.lightSettings.diffuseColor1[i]; } if (this->unk_1D3 != 0) { - DynaPoly_DeleteBgActor(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); + DynaPoly_DeleteBgActor(play, &play->colCtx.dyna, this->dyna.bgId); } } -void func_808B8924(DoorWarp1* this, GlobalContext* globalCtx) { +void func_808B8924(DoorWarp1* this, PlayState* play) { this->unk_1C4 = 0; this->unk_1C6 = -140; this->unk_1C8 = -80; @@ -209,8 +209,8 @@ void func_808B8924(DoorWarp1* this, GlobalContext* globalCtx) { DoorWarp1_SetupAction(this, func_808B96B0); } -void func_808B8A7C(DoorWarp1* this, GlobalContext* globalCtx) { - SkelAnime_Init(globalCtx, &this->skelAnime, &object_warp1_Skel_002CA8, &object_warp1_Anim_001374, NULL, NULL, 0); +void func_808B8A7C(DoorWarp1* this, PlayState* play) { + SkelAnime_Init(play, &this->skelAnime, &object_warp1_Skel_002CA8, &object_warp1_Anim_001374, NULL, NULL, 0); Animation_ChangeImpl(&this->skelAnime, &object_warp1_Anim_001374, 1.0f, 1.0f, 1.0f, 2, 40.0f, 1); this->unk_1C4 = 0; this->unk_1C6 = -140; @@ -232,7 +232,7 @@ void func_808B8A7C(DoorWarp1* this, GlobalContext* globalCtx) { DoorWarp1_SetupAction(this, func_808B9B30); } -void func_808B8C48(DoorWarp1* this, GlobalContext* globalCtx) { +void func_808B8C48(DoorWarp1* this, PlayState* play) { this->dyna.actor.shape.yOffset = 0.0f; Actor_SetScale(&this->dyna.actor, 0.1f); Lights_PointNoGlowSetInfo(&this->unk_1E0, this->dyna.actor.world.pos.x, this->dyna.actor.world.pos.y, @@ -246,17 +246,17 @@ void func_808B8C48(DoorWarp1* this, GlobalContext* globalCtx) { s16 params = DOORWARP1_GET_FF00_2(&this->dyna.actor); params |= 6; - Actor_SpawnAsChild(&globalCtx->actorCtx, &this->dyna.actor, globalCtx, ACTOR_DOOR_WARP1, - this->dyna.actor.world.pos.x, this->dyna.actor.world.pos.y + 10.0f, - this->dyna.actor.world.pos.z, this->dyna.actor.world.rot.x, this->dyna.actor.world.rot.y, - this->dyna.actor.world.rot.z, params); + Actor_SpawnAsChild(&play->actorCtx, &this->dyna.actor, play, ACTOR_DOOR_WARP1, this->dyna.actor.world.pos.x, + this->dyna.actor.world.pos.y + 10.0f, this->dyna.actor.world.pos.z, + this->dyna.actor.world.rot.x, this->dyna.actor.world.rot.y, this->dyna.actor.world.rot.z, + params); DoorWarp1_SetupAction(this, func_808BAAF4); } else { DoorWarp1_SetupAction(this, func_808BABF4); } } -void func_808B8E78(DoorWarp1* this, GlobalContext* globalCtx) { +void func_808B8E78(DoorWarp1* this, PlayState* play) { Actor_SetScale(&this->dyna.actor, 0.1f); Lights_PointNoGlowSetInfo(&this->unk_1E0, this->dyna.actor.world.pos.x, this->dyna.actor.world.pos.y, this->dyna.actor.world.pos.z, 200, 255, 255, 0); @@ -268,7 +268,7 @@ void func_808B8E78(DoorWarp1* this, GlobalContext* globalCtx) { this->unk_1A8 = 0.0f; this->unk_1AC = 0.0f; this->unk_1A4 = 700.0f; - if (globalCtx->sceneNum == SCENE_INISIE_N) { + if (play->sceneNum == SCENE_INISIE_N) { DoorWarp1_SetupAction(this, func_808B96A0); } else if (gSaveContext.save.weekEventReg[86] & 0x80) { this->unk_1D4 = 0; @@ -278,16 +278,16 @@ void func_808B8E78(DoorWarp1* this, GlobalContext* globalCtx) { } } -s32 func_808B900C(DoorWarp1* this, GlobalContext* globalCtx) { +s32 func_808B900C(DoorWarp1* this, PlayState* play) { s32 index; u8 ret = false; - if (Cutscene_CheckActorAction(globalCtx, 569)) { - index = Cutscene_GetActorActionIndex(globalCtx, 569); + if (Cutscene_CheckActorAction(play, 569)) { + index = Cutscene_GetActorActionIndex(play, 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) { + if (this->unk_208 != play->csCtx.actorActions[index]->action) { + this->unk_208 = play->csCtx.actorActions[index]->action; + if (play->csCtx.actorActions[index]->action == 2) { ret = true; } } @@ -296,30 +296,30 @@ s32 func_808B900C(DoorWarp1* this, GlobalContext* globalCtx) { return ret; } -void func_808B9094(DoorWarp1* this, GlobalContext* globalCtx) { - if (func_808B900C(this, globalCtx)) { +void func_808B9094(DoorWarp1* this, PlayState* play) { + if (func_808B900C(this, play)) { DoorWarp1_SetupAction(this, func_808B90CC); } } -void func_808B90CC(DoorWarp1* this, GlobalContext* globalCtx) { +void func_808B90CC(DoorWarp1* this, PlayState* play) { s32 pad[2]; s16 sp2E = 0; f32 phi_f0 = 0.0f; - if (globalCtx->sceneNum == SCENE_MITURIN) { + if (play->sceneNum == SCENE_MITURIN) { sp2E = -10; phi_f0 = -5.0f; - } else if (globalCtx->sceneNum == SCENE_HAKUGIN) { + } else if (play->sceneNum == SCENE_HAKUGIN) { sp2E = -20; - } else if (globalCtx->sceneNum == SCENE_SEA) { + } else if (play->sceneNum == SCENE_SEA) { sp2E = -20; } Math_SmoothStepToF(&this->unk_1AC, 40.0f, 0.5f, 1.2f + phi_f0, 0.01f); Math_SmoothStepToF(&this->unk_1A4, 0.0f, 0.5f, 12.0f, 0.1f); if ((this->unk_1A4 < 460.0f) && (this->unk_1A4 > 100.0f)) { - func_808BB8D4(this, globalCtx, 6); + func_808BB8D4(this, play, 6); } if (this->unk_1A4 < 0.1f) { @@ -331,7 +331,7 @@ void func_808B90CC(DoorWarp1* this, GlobalContext* globalCtx) { Actor_PlaySfxAtPos(&this->dyna.actor, NA_SE_EV_WARP_HOLE_ENERGY - SFX_FLAG); } -void func_808B921C(DoorWarp1* this, GlobalContext* globalCtx) { +void func_808B921C(DoorWarp1* this, PlayState* play) { if (this->unk_1D0 != 0) { this->unk_1D0--; return; @@ -340,62 +340,62 @@ void func_808B921C(DoorWarp1* this, GlobalContext* globalCtx) { Math_SmoothStepToF(&this->unk_1A8, 1.0f, 0.2f, 0.05f, 0.01f); this->unk_203 = (u8)(this->unk_1A8 * 200.0f); if (this->unk_1A8 > 0.8f) { - func_808BB8D4(this, globalCtx, 1); + func_808BB8D4(this, play, 1); } - if (func_808B866C(this, globalCtx) && !Play_InCsMode(globalCtx)) { - func_800B7298(globalCtx, &this->dyna.actor, 7); - Message_StartTextbox(globalCtx, 0xF2, &this->dyna.actor); + if (func_808B866C(this, play) && !Play_InCsMode(play)) { + func_800B7298(play, &this->dyna.actor, 7); + Message_StartTextbox(play, 0xF2, &this->dyna.actor); DoorWarp1_SetupAction(this, func_808B93A0); } Actor_PlaySfxAtPos(&this->dyna.actor, NA_SE_EV_BOSS_WARP_HOLE - SFX_FLAG); } -void func_808B93A0(DoorWarp1* this, GlobalContext* globalCtx) { +void func_808B93A0(DoorWarp1* this, PlayState* play) { s32 pad; - Player* player = GET_PLAYER(globalCtx); + Player* player = GET_PLAYER(play); - if (Message_GetState(&globalCtx->msgCtx) == 4 && Message_ShouldAdvance(globalCtx)) { - func_801477B4(globalCtx); - if (globalCtx->msgCtx.choiceIndex == 0) { + if ((Message_GetState(&play->msgCtx) == TEXT_STATE_CHOICE) && Message_ShouldAdvance(play)) { + func_801477B4(play); + if (play->msgCtx.choiceIndex == 0) { func_8019F208(); - func_800B7298(globalCtx, &this->dyna.actor, 9); + func_800B7298(play, &this->dyna.actor, 9); player->unk_3A0.x = this->dyna.actor.world.pos.x; player->unk_3A0.z = this->dyna.actor.world.pos.z; this->unk_1CA = 1; DoorWarp1_SetupAction(this, func_808B9524); } else { func_8019F230(); - func_800B7298(globalCtx, &this->dyna.actor, 6); + func_800B7298(play, &this->dyna.actor, 6); DoorWarp1_SetupAction(this, func_808B94A4); } } - func_808BB8D4(this, globalCtx, 1); + func_808BB8D4(this, play, 1); Actor_PlaySfxAtPos(&this->dyna.actor, NA_SE_EV_BOSS_WARP_HOLE - SFX_FLAG); } -void func_808B94A4(DoorWarp1* this, GlobalContext* globalCtx) { - if (!func_808B866C(this, globalCtx) && (ActorCutscene_GetCurrentIndex() != globalCtx->playerActorCsIds[8])) { +void func_808B94A4(DoorWarp1* this, PlayState* play) { + if (!func_808B866C(this, play) && (ActorCutscene_GetCurrentIndex() != play->playerActorCsIds[8])) { DoorWarp1_SetupAction(this, func_808B921C); } - func_808BB8D4(this, globalCtx, 1); + func_808BB8D4(this, play, 1); Actor_PlaySfxAtPos(&this->dyna.actor, NA_SE_EV_BOSS_WARP_HOLE - SFX_FLAG); } -void func_808B9524(DoorWarp1* this, GlobalContext* globalCtx) { - if (!ActorCutscene_GetCanPlayNext(globalCtx->playerActorCsIds[9])) { - ActorCutscene_SetIntentToPlay(globalCtx->playerActorCsIds[9]); +void func_808B9524(DoorWarp1* this, PlayState* play) { + if (!ActorCutscene_GetCanPlayNext(play->playerActorCsIds[9])) { + ActorCutscene_SetIntentToPlay(play->playerActorCsIds[9]); } else { - ActorCutscene_Start(globalCtx->playerActorCsIds[9], NULL); + ActorCutscene_Start(play->playerActorCsIds[9], NULL); DoorWarp1_SetupAction(this, func_808B958C); } } -void func_808B958C(DoorWarp1* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); +void func_808B958C(DoorWarp1* this, PlayState* play) { + Player* player = GET_PLAYER(play); - func_808BB8D4(this, globalCtx, 1); + func_808BB8D4(this, play, 1); if (this->unk_1CA > 100) { if (player->actor.velocity.y < 10.0f) { @@ -409,19 +409,19 @@ void func_808B958C(DoorWarp1* this, GlobalContext* globalCtx) { this->unk_1D0++; if ((this->unk_1D0 > 120) && (gSaveContext.nextCutsceneIndex == 0xFFEF)) { - func_808BA10C(this, globalCtx); - globalCtx->unk_1887F = 3; - gSaveContext.nextTransition = 3; + func_808BA10C(this, play); + play->transitionType = TRANS_TYPE_03; + gSaveContext.nextTransitionType = TRANS_TYPE_03; } Math_SmoothStepToF(&this->unk_1A8, 6.0f, 0.2f, 0.02f, 0.01f); Actor_PlaySfxAtPos(&this->dyna.actor, NA_SE_EV_LINK_WARP - SFX_FLAG); } -void func_808B96A0(DoorWarp1* this, GlobalContext* globalCtx) { +void func_808B96A0(DoorWarp1* this, PlayState* play) { } -void func_808B96B0(DoorWarp1* this, GlobalContext* globalCtx) { +void func_808B96B0(DoorWarp1* this, PlayState* play) { Actor_PlaySfxAtPos(&this->dyna.actor, NA_SE_EV_WARP_HOLE - SFX_FLAG); Math_SmoothStepToF(&this->unk_1B0, 255.0f, 0.4f, 10.0f, 0.01f); Math_SmoothStepToF(&this->unk_1B4, 255.0f, 0.4f, 10.0f, 0.01f); @@ -441,13 +441,14 @@ void func_808B96B0(DoorWarp1* this, GlobalContext* globalCtx) { } } -void func_808B977C(DoorWarp1* this, GlobalContext* globalCtx) { +void func_808B977C(DoorWarp1* this, PlayState* play) { Actor_PlaySfxAtPos(&this->dyna.actor, NA_SE_EV_WARP_HOLE - SFX_FLAG); - if (func_808B866C(this, globalCtx) && !Play_InCsMode(globalCtx)) { - Player* player = GET_PLAYER(globalCtx); + if (func_808B866C(this, play) && !Play_InCsMode(play)) { + Player* player = GET_PLAYER(play); - Audio_PlaySfxGeneral(NA_SE_EV_LINK_WARP, &player->actor.projectedPos, 4, &D_801DB4B0, &D_801DB4B0, &D_801DB4B8); - func_800B7298(globalCtx, &this->dyna.actor, 9); + AudioSfx_PlaySfx(NA_SE_EV_LINK_WARP, &player->actor.projectedPos, 4, &gSfxDefaultFreqAndVolScale, + &gSfxDefaultFreqAndVolScale, &gSfxDefaultReverb); + func_800B7298(play, &this->dyna.actor, 9); player->unk_3A0.x = this->dyna.actor.world.pos.x; player->unk_3A0.z = this->dyna.actor.world.pos.z; this->unk_1CA = 1; @@ -455,17 +456,17 @@ void func_808B977C(DoorWarp1* this, GlobalContext* globalCtx) { } } -void func_808B9840(DoorWarp1* this, GlobalContext* globalCtx) { - if (!ActorCutscene_GetCanPlayNext(globalCtx->playerActorCsIds[9])) { - ActorCutscene_SetIntentToPlay(globalCtx->playerActorCsIds[9]); +void func_808B9840(DoorWarp1* this, PlayState* play) { + if (!ActorCutscene_GetCanPlayNext(play->playerActorCsIds[9])) { + ActorCutscene_SetIntentToPlay(play->playerActorCsIds[9]); } else { - ActorCutscene_Start(globalCtx->playerActorCsIds[9], NULL); + ActorCutscene_Start(play->playerActorCsIds[9], NULL); DoorWarp1_SetupAction(this, func_808B98A8); } } -void func_808B98A8(DoorWarp1* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); +void func_808B98A8(DoorWarp1* this, PlayState* play) { + Player* player = GET_PLAYER(play); if (this->unk_1CA > 100) { if (player->actor.velocity.y < 10.0f) { @@ -484,11 +485,11 @@ void func_808B98A8(DoorWarp1* this, GlobalContext* globalCtx) { if ((gSaveContext.nextCutsceneIndex == 0xFFEF) && (D_808BC000 < this->unk_1D0) && (gSaveContext.nextCutsceneIndex == 0xFFEF)) { if (DOORWARP1_GET_FF00_1(&this->dyna.actor) != 0xFF) { - globalCtx->nextEntranceIndex = globalCtx->setupExitList[DOORWARP1_GET_FF00_3(&this->dyna.actor)]; - Scene_SetExitFade(globalCtx); - globalCtx->sceneLoadFlag = 0x14; + play->nextEntrance = play->setupExitList[DOORWARP1_GET_FF00_3(&this->dyna.actor)]; + Scene_SetExitFade(play); + play->transitionTrigger = TRANS_TRIGGER_START; } else { - func_80169FDC(&globalCtx->state); + func_80169FDC(&play->state); } } } @@ -502,19 +503,18 @@ void func_808B98A8(DoorWarp1* this, GlobalContext* globalCtx) { Math_SmoothStepToF(&this->dyna.actor.shape.yOffset, 0.0f, 0.5f, 2.0f, 0.1f); } -void func_808B9B30(DoorWarp1* this, GlobalContext* globalCtx) { +void func_808B9B30(DoorWarp1* this, PlayState* play) { if (fabsf(this->dyna.actor.xzDistToPlayer) >= 60.0f) { - if (func_808B849C(this, globalCtx)) { - this->unk_1A0 = - (DmHina*)Actor_SpawnAsChild(&globalCtx->actorCtx, &this->dyna.actor, globalCtx, ACTOR_DM_HINA, - this->dyna.actor.world.pos.x, this->dyna.actor.world.pos.y, - this->dyna.actor.world.pos.z, 0, 0, 0, func_808B849C(this, globalCtx) - 1); + if (func_808B849C(this, play)) { + this->unk_1A0 = (DmHina*)Actor_SpawnAsChild( + &play->actorCtx, &this->dyna.actor, play, ACTOR_DM_HINA, this->dyna.actor.world.pos.x, + this->dyna.actor.world.pos.y, this->dyna.actor.world.pos.z, 0, 0, 0, func_808B849C(this, play) - 1); } DoorWarp1_SetupAction(this, func_808B9BE8); } } -void func_808B9BE8(DoorWarp1* this, GlobalContext* globalCtx) { +void func_808B9BE8(DoorWarp1* this, PlayState* play) { Actor_PlaySfxAtPos(&this->dyna.actor, NA_SE_EV_WARP_HOLE - SFX_FLAG); Math_SmoothStepToF(&this->unk_1B0, 255.0f, 0.2f, 2.0f, 0.1f); Math_SmoothStepToF(&this->unk_1B4, 255.0f, 0.2f, 2.0f, 0.1f); @@ -532,7 +532,7 @@ void func_808B9BE8(DoorWarp1* this, GlobalContext* globalCtx) { } this->dyna.actor.parent = NULL; - if (func_808B849C(this, globalCtx)) { + if (func_808B849C(this, play)) { this->unk_202 = 1; DoorWarp1_SetupAction(this, func_808B9CE8); } else { @@ -540,18 +540,18 @@ void func_808B9BE8(DoorWarp1* this, GlobalContext* globalCtx) { } } -void func_808B9CE8(DoorWarp1* this, GlobalContext* globalCtx) { +void func_808B9CE8(DoorWarp1* this, PlayState* play) { if (this->unk_203 != 0) { if (1) {} return; } - if (!Actor_HasParent(&this->dyna.actor, globalCtx)) { - Actor_PickUp(&this->dyna.actor, globalCtx, func_808B849C(this, globalCtx) + 84, 30.0f, 80.0f); + if (!Actor_HasParent(&this->dyna.actor, play)) { + Actor_PickUp(&this->dyna.actor, play, (GI_REMAINS_ODOLWA - 1) + func_808B849C(this, play), 30.0f, 80.0f); return; } - switch (globalCtx->sceneNum) { + switch (play->sceneNum) { case SCENE_MITURIN_BS: gSaveContext.save.unk_ECC[0] = (((void)0, gSaveContext.save.unk_ECC[0]) & 0xFFFFFF00) | (((u8)gSaveContext.save.unk_ECC[1]) & 0xFF); @@ -575,31 +575,31 @@ void func_808B9CE8(DoorWarp1* this, GlobalContext* globalCtx) { 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)); + Item_Give(play, func_808B849C(this, play) + (ITEM_REMAINS_ODOLWA - 1)); DoorWarp1_SetupAction(this, func_808B9E94); } -void func_808B9E94(DoorWarp1* this, GlobalContext* globalCtx) { - if (Message_GetState(&globalCtx->msgCtx) == 2) { +void func_808B9E94(DoorWarp1* this, PlayState* play) { + if (Message_GetState(&play->msgCtx) == TEXT_STATE_CLOSING) { this->unk_1CE = 110; DoorWarp1_SetupAction(this, func_808B9ED8); } } -void func_808B9ED8(DoorWarp1* this, GlobalContext* globalCtx) { +void func_808B9ED8(DoorWarp1* this, PlayState* play) { this->unk_1CE--; if (this->unk_1CE <= 0) { - func_808BA10C(this, globalCtx); + func_808BA10C(this, play); } } -void func_808B9F10(DoorWarp1* this, GlobalContext* globalCtx) { +void func_808B9F10(DoorWarp1* this, PlayState* play) { Actor_PlaySfxAtPos(&this->dyna.actor, NA_SE_EV_WARP_HOLE - SFX_FLAG); - if ((this->unk_203 == 0) && func_808B866C(this, globalCtx) && !Play_InCsMode(globalCtx) && (this->unk_203 == 0)) { - Player* player = GET_PLAYER(globalCtx); + if ((this->unk_203 == 0) && func_808B866C(this, play) && !Play_InCsMode(play) && (this->unk_203 == 0)) { + Player* player = GET_PLAYER(play); Interface_ChangeAlpha(1); - func_800B7298(globalCtx, &this->dyna.actor, 9); + func_800B7298(play, &this->dyna.actor, 9); player->unk_3A0.x = this->dyna.actor.world.pos.x; player->unk_3A0.z = this->dyna.actor.world.pos.z; this->unk_1CA = 20; @@ -607,20 +607,21 @@ void func_808B9F10(DoorWarp1* this, GlobalContext* globalCtx) { } } -void func_808B9FD0(DoorWarp1* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); - Player* player2 = GET_PLAYER(globalCtx); +void func_808B9FD0(DoorWarp1* this, PlayState* play) { + Player* player = GET_PLAYER(play); + Player* player2 = GET_PLAYER(play); if (this->unk_1CA != 0) { this->unk_1CA--; return; } - if (!ActorCutscene_GetCanPlayNext(globalCtx->playerActorCsIds[9])) { - ActorCutscene_SetIntentToPlay(globalCtx->playerActorCsIds[9]); + if (!ActorCutscene_GetCanPlayNext(play->playerActorCsIds[9])) { + ActorCutscene_SetIntentToPlay(play->playerActorCsIds[9]); } else { - ActorCutscene_Start(globalCtx->playerActorCsIds[9], NULL); - Audio_PlaySfxGeneral(NA_SE_EV_LINK_WARP, &player->actor.projectedPos, 4, &D_801DB4B0, &D_801DB4B0, &D_801DB4B8); + ActorCutscene_Start(play->playerActorCsIds[9], NULL); + AudioSfx_PlaySfx(NA_SE_EV_LINK_WARP, &player->actor.projectedPos, 4, &gSfxDefaultFreqAndVolScale, + &gSfxDefaultFreqAndVolScale, &gSfxDefaultReverb); Animation_ChangeImpl(&this->skelAnime, &object_warp1_Anim_001374, 1.0f, Animation_GetLastFrame(&object_warp1_Anim_001374.common), Animation_GetLastFrame(&object_warp1_Anim_001374.common), 2, 40.0f, 1); @@ -630,21 +631,21 @@ void func_808B9FD0(DoorWarp1* this, GlobalContext* globalCtx) { } } -void func_808BA10C(DoorWarp1* this, GlobalContext* globalCtx) { +void func_808BA10C(DoorWarp1* this, PlayState* play) { s32 phi_v0_2; u8 phi_a0; s32 phi_v0_3; - if ((globalCtx->sceneNum == SCENE_MITURIN_BS) || (globalCtx->sceneNum == SCENE_HAKUGIN_BS) || - (globalCtx->sceneNum == SCENE_INISIE_BS) || (globalCtx->sceneNum == SCENE_SEA_BS)) { - D_801F4DE2 = globalCtx->sceneNum; - if (globalCtx->sceneNum == SCENE_MITURIN_BS) { + if ((play->sceneNum == SCENE_MITURIN_BS) || (play->sceneNum == SCENE_HAKUGIN_BS) || + (play->sceneNum == SCENE_INISIE_BS) || (play->sceneNum == SCENE_SEA_BS)) { + D_801F4DE2 = play->sceneNum; + if (play->sceneNum == SCENE_MITURIN_BS) { phi_v0_2 = 0; - } else if (globalCtx->sceneNum == SCENE_HAKUGIN_BS) { + } else if (play->sceneNum == SCENE_HAKUGIN_BS) { phi_v0_2 = 1; - } else if (globalCtx->sceneNum == SCENE_INISIE_BS) { + } else if (play->sceneNum == SCENE_INISIE_BS) { phi_v0_2 = 2; - } else if (globalCtx->sceneNum == SCENE_SEA_BS) { + } else if (play->sceneNum == SCENE_SEA_BS) { phi_v0_2 = 3; } else { phi_v0_2 = 0; @@ -699,64 +700,64 @@ void func_808BA10C(DoorWarp1* this, GlobalContext* globalCtx) { break; } - globalCtx->nextEntranceIndex = 0xCC00; + play->nextEntrance = ENTRANCE(GIANTS_CHAMBER, 0); if (phi_v0_3 < 10) { gSaveContext.nextCutsceneIndex = phi_v0_3 + 0xFFF0; } - globalCtx->sceneLoadFlag = 0x14; - globalCtx->unk_1887F = 3; - gSaveContext.nextTransition = 3; + play->transitionTrigger = TRANS_TRIGGER_START; + play->transitionType = TRANS_TYPE_03; + gSaveContext.nextTransitionType = TRANS_TYPE_03; } else { switch (phi_v0_2) { case 0: if (gSaveContext.save.weekEventReg[20] & 2) { gSaveContext.save.weekEventReg[7] |= 0x80; - globalCtx->nextEntranceIndex = 0x3010; - globalCtx->sceneLoadFlag = 0x14; - globalCtx->unk_1887F = 3; - gSaveContext.nextTransition = 3; + play->nextEntrance = ENTRANCE(WOODFALL_TEMPLE, 1); + play->transitionTrigger = TRANS_TRIGGER_START; + play->transitionType = TRANS_TYPE_03; + gSaveContext.nextTransitionType = TRANS_TYPE_03; } else { - globalCtx->nextEntranceIndex = 0x8600; + play->nextEntrance = ENTRANCE(WOODFALL, 0); gSaveContext.nextCutsceneIndex = 0xFFF0; - globalCtx->sceneLoadFlag = 0x14; - globalCtx->unk_1887F = 3; - gSaveContext.nextTransition = 3; + play->transitionTrigger = TRANS_TRIGGER_START; + play->transitionType = TRANS_TYPE_03; + gSaveContext.nextTransitionType = TRANS_TYPE_03; } break; case 1: gSaveContext.save.weekEventReg[33] |= 0x80; - globalCtx->nextEntranceIndex = 0xAE70; - globalCtx->sceneLoadFlag = 0x14; - globalCtx->unk_1887F = 3; - gSaveContext.nextTransition = 3; + play->nextEntrance = ENTRANCE(MOUNTAIN_VILLAGE_SPRING, 7); + play->transitionTrigger = TRANS_TRIGGER_START; + play->transitionType = TRANS_TYPE_03; + gSaveContext.nextTransitionType = TRANS_TYPE_03; break; case 3: if (gSaveContext.save.weekEventReg[55] & 0x80) { - globalCtx->nextEntranceIndex = 0x6A90; + play->nextEntrance = ENTRANCE(ZORA_CAPE, 9); gSaveContext.nextCutsceneIndex = 0xFFF0; - globalCtx->sceneLoadFlag = 0x14; - globalCtx->unk_1887F = 3; - gSaveContext.nextTransition = 3; + play->transitionTrigger = TRANS_TRIGGER_START; + play->transitionType = TRANS_TYPE_03; + gSaveContext.nextTransitionType = TRANS_TYPE_03; } else { gSaveContext.save.weekEventReg[55] |= 0x80; - globalCtx->nextEntranceIndex = 0x6A80; + play->nextEntrance = ENTRANCE(ZORA_CAPE, 8); gSaveContext.nextCutsceneIndex = 0xFFF0; - globalCtx->sceneLoadFlag = 0x14; - globalCtx->unk_1887F = 3; - gSaveContext.nextTransition = 3; + play->transitionTrigger = TRANS_TRIGGER_START; + play->transitionType = TRANS_TYPE_03; + gSaveContext.nextTransitionType = TRANS_TYPE_03; } break; case 2: gSaveContext.save.weekEventReg[52] |= 0x20; - globalCtx->nextEntranceIndex = 0x20F0; + play->nextEntrance = ENTRANCE(IKANA_CANYON, 15); gSaveContext.nextCutsceneIndex = 0xFFF2; - globalCtx->sceneLoadFlag = 0x14; - globalCtx->unk_1887F = 3; - gSaveContext.nextTransition = 3; + play->transitionTrigger = TRANS_TRIGGER_START; + play->transitionType = TRANS_TYPE_03; + gSaveContext.nextTransitionType = TRANS_TYPE_03; break; } } @@ -764,17 +765,17 @@ void func_808BA10C(DoorWarp1* this, GlobalContext* globalCtx) { if (DOORWARP1_GET_FF(&this->dyna.actor) == ENDOORWARP1_FF_6) { gSaveContext.respawnFlag = ~1; } - globalCtx->nextEntranceIndex = globalCtx->setupExitList[DOORWARP1_GET_FF00_3(&this->dyna.actor)]; - Scene_SetExitFade(globalCtx); - globalCtx->sceneLoadFlag = 0x14; + play->nextEntrance = play->setupExitList[DOORWARP1_GET_FF00_3(&this->dyna.actor)]; + Scene_SetExitFade(play); + play->transitionTrigger = TRANS_TRIGGER_START; } else { - func_80169FDC(&globalCtx->state); + func_80169FDC(&play->state); } } -void func_808BA550(DoorWarp1* this, GlobalContext* globalCtx) { - Player* player2 = GET_PLAYER(globalCtx); - Player* player = GET_PLAYER(globalCtx); +void func_808BA550(DoorWarp1* this, PlayState* play) { + Player* player2 = GET_PLAYER(play); + Player* player = GET_PLAYER(play); s16 i; s32 temp_f16; f32 temp_f0; @@ -829,19 +830,19 @@ void func_808BA550(DoorWarp1* this, GlobalContext* globalCtx) { this->unk_1D0++; if ((D_808BC000 < this->unk_1D0) && (gSaveContext.nextCutsceneIndex == 0xFFEF)) { - func_808BA10C(this, globalCtx); + func_808BA10C(this, play); } if (this->unk_1D0 > 140) { - globalCtx->envCtx.fillScreen = 1; + play->envCtx.fillScreen = 1; temp_f0 = (this->unk_1D0 - 140) / 20.0f; if (temp_f0 > 1.0f) { temp_f0 = 1.0f; } - globalCtx->envCtx.screenFillColor[0] = 160; - globalCtx->envCtx.screenFillColor[1] = 160; - globalCtx->envCtx.screenFillColor[2] = 160; - globalCtx->envCtx.screenFillColor[3] = 255.0f * temp_f0; + play->envCtx.screenFillColor[0] = 160; + play->envCtx.screenFillColor[1] = 160; + play->envCtx.screenFillColor[2] = 160; + play->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, @@ -864,25 +865,25 @@ void func_808BA550(DoorWarp1* this, GlobalContext* globalCtx) { temp_f16 = -255.0f * temp_f0; for (i = 0; i < 3; i++) { - globalCtx->envCtx.lightSettings.diffuseColor1[i] = temp_f16; - globalCtx->envCtx.lightSettings.fogColor[i] = temp_f16; - globalCtx->envCtx.lightSettings.ambientColor[i] = temp_f16; + play->envCtx.lightSettings.diffuseColor1[i] = temp_f16; + play->envCtx.lightSettings.fogColor[i] = temp_f16; + play->envCtx.lightSettings.ambientColor[i] = temp_f16; } - globalCtx->envCtx.lightSettings.fogNear = -500.0f * temp_f0; - if (globalCtx->envCtx.lightSettings.fogNear < -300) { - globalCtx->roomCtx.currRoom.segment = NULL; + play->envCtx.lightSettings.fogNear = -500.0f * temp_f0; + if (play->envCtx.lightSettings.fogNear < -300) { + play->roomCtx.currRoom.segment = NULL; } } } -void func_808BAAF4(DoorWarp1* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); +void func_808BAAF4(DoorWarp1* this, PlayState* play) { + Player* player = GET_PLAYER(play); s16 cutscene; f32 phi_f2; phi_f2 = 200.0f; - if (globalCtx->sceneNum == SCENE_SEA) { + if (play->sceneNum == SCENE_SEA) { phi_f2 = 85.0f; } @@ -901,10 +902,10 @@ void func_808BAAF4(DoorWarp1* this, GlobalContext* globalCtx) { } } -void func_808BABF4(DoorWarp1* this, GlobalContext* globalCtx) { +void func_808BABF4(DoorWarp1* this, PlayState* play) { } -void DoorWarp1_Update(Actor* thisx, GlobalContext* globalCtx) { +void DoorWarp1_Update(Actor* thisx, PlayState* play) { DoorWarp1* this = THIS; if (this->unk_203 == 0) { @@ -917,35 +918,35 @@ void DoorWarp1_Update(Actor* thisx, GlobalContext* globalCtx) { this->unk_1A0->unk_15C = this->unk_204; } - this->actionFunc(this, globalCtx); + this->actionFunc(this, play); if (DOORWARP1_GET_FF(&this->dyna.actor) < ENDOORWARP1_FF_2) { Actor_SetScale(&this->dyna.actor, this->unk_1C4 / 100.0f); } } -void func_808BACCC(DoorWarp1* this, GlobalContext* globalCtx) { +void func_808BACCC(DoorWarp1* this, PlayState* play) { s32 pad; - OPEN_DISPS(globalCtx->state.gfxCtx); + OPEN_DISPS(play->state.gfxCtx); - func_8012C2DC(globalCtx->state.gfxCtx); + func_8012C2DC(play->state.gfxCtx); gDPSetPrimColor(POLY_XLU_DISP++, 0xFF, 0xFF, 200, 255, 255, (u8)this->unk_1B8); gDPSetEnvColor(POLY_XLU_DISP++, 0, 100, 255, (u8)this->unk_1B8); - POLY_XLU_DISP = SkelAnime_Draw(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, NULL, NULL, + POLY_XLU_DISP = SkelAnime_Draw(play, this->skelAnime.skeleton, this->skelAnime.jointTable, NULL, NULL, &this->dyna.actor, POLY_XLU_DISP); - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->state.gfxCtx); SkelAnime_Update(&this->skelAnime); } -void func_808BAE9C(DoorWarp1* this, GlobalContext* globalCtx) { +void func_808BAE9C(DoorWarp1* this, PlayState* play) { s32 pad; s32 pad2; - s32 sp94 = globalCtx->state.frames * 10; + s32 sp94 = play->state.frames * 10; f32 sp90; f32 sp8C; f32 phi_f12; @@ -963,37 +964,37 @@ void func_808BAE9C(DoorWarp1* this, GlobalContext* globalCtx) { sp8C = 1.0f - this->unk_1A8; } - OPEN_DISPS(globalCtx->state.gfxCtx); + OPEN_DISPS(play->state.gfxCtx); sp84 = 1.0f - ((2.0f - this->unk_1A4) / 1.7f); this->unk_1AC += sp84 * 15.0f; - func_8012C2DC(globalCtx->state.gfxCtx); + func_8012C2DC(play->state.gfxCtx); gDPSetPrimColor(POLY_XLU_DISP++, 0, 0x80, 255.0f * sp84, 255, 255, (u8)this->unk_1B4); gDPSetEnvColor(POLY_XLU_DISP++, 0, 255.0f * sp84, 255, 255); - Matrix_InsertTranslation(this->dyna.actor.world.pos.x, this->dyna.actor.world.pos.y + 1.0f, - this->dyna.actor.world.pos.z, MTXMODE_NEW); + 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; } Matrix_Scale(phi_f12, phi_f12, phi_f12, MTXMODE_APPLY); - gSPSegment(POLY_XLU_DISP++, 0x0A, Matrix_NewMtx(globalCtx->state.gfxCtx)); - Matrix_StatePush(); + gSPSegment(POLY_XLU_DISP++, 0x0A, Matrix_NewMtx(play->state.gfxCtx)); + Matrix_Push(); gSPSegment(POLY_XLU_DISP++, 0x08, - Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, sp94 & 0xFF, -((s16)(2.0f * this->unk_1AC) & 0x1FF), 0x100, + Gfx_TwoTexScroll(play->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)); + gSPSegment(POLY_XLU_DISP++, 0x09, Matrix_NewMtx(play->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); @@ -1001,29 +1002,27 @@ void func_808BAE9C(DoorWarp1* this, GlobalContext* globalCtx) { sp94 *= 2; gSPSegment(POLY_XLU_DISP++, 0x08, - Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, sp94 & 0xFF, -((s16)this->unk_1AC & 0x1FF), 0x100, - 0x100, 1, sp94 & 0xFF, -((s16)this->unk_1AC & 0x1FF), 0x100, 0x100)); + Gfx_TwoTexScroll(play->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); - gSPSegment(POLY_XLU_DISP++, 0x09, Matrix_NewMtx(globalCtx->state.gfxCtx)); + gSPSegment(POLY_XLU_DISP++, 0x09, Matrix_NewMtx(play->state.gfxCtx)); gSPDisplayList(POLY_XLU_DISP++, object_warp1_DL_0001A0); } - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->state.gfxCtx); } -void func_808BB4C4(DoorWarp1* this, GlobalContext* globalCtx) { - Gfx_DrawDListOpa(globalCtx, object_warp1_DL_0076C0); +void func_808BB4C4(DoorWarp1* this, PlayState* play) { + Gfx_DrawDListOpa(play, object_warp1_DL_0076C0); } -#ifdef NON_MATCHING -// GraphicsContext should be compiler-managed? -void func_808BB4F4(DoorWarp1* this, GlobalContext* globalCtx2) { - GlobalContext* globalCtx = globalCtx2; - GraphicsContext* gfxCtx; +void func_808BB4F4(DoorWarp1* this, PlayState* play2) { + PlayState* play = play2; + s32 pad; Color_RGB8 sp64[] = { { 50, 150, 0 }, { 100, 150, 200 }, @@ -1033,143 +1032,123 @@ 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); + AnimatedMat_Draw(play, Lib_SegmentedToVirtual(object_warp1_Matanimheader_0044D8)); + Gfx_DrawDListXlu(play, object_warp1_DL_003230); return; } - if (globalCtx->sceneNum != SCENE_MITURIN) { - if (globalCtx->sceneNum == SCENE_HAKUGIN) { + if (play->sceneNum != SCENE_MITURIN) { + if (play->sceneNum == SCENE_HAKUGIN) { sp60 = 1; - } else if (globalCtx->sceneNum == SCENE_SEA) { + } else if (play->sceneNum == SCENE_SEA) { sp60 = 2; - } else if (globalCtx->sceneNum == SCENE_INISIE_R) { + } else if (play->sceneNum == SCENE_INISIE_R) { sp60 = 3; } } - Matrix_InsertTranslation(this->dyna.actor.world.pos.x, this->dyna.actor.world.pos.y, this->dyna.actor.world.pos.z, - MTXMODE_NEW); - Matrix_RotateY(this->dyna.actor.world.rot.y, MTXMODE_APPLY); + Matrix_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)); + AnimatedMat_Draw(play, Lib_SegmentedToVirtual(object_warp1_Matanimheader_0057D8)); - OPEN_DISPS(globalCtx->state.gfxCtx); + OPEN_DISPS(play->state.gfxCtx); - func_8012C2DC(globalCtx->state.gfxCtx); + func_8012C2DC(play->state.gfxCtx); gDPSetEnvColor(POLY_XLU_DISP++, sp64[sp60].r, sp64[sp60].g, sp64[sp60].b, 255); gDPSetPrimColor(POLY_XLU_DISP++, 0, 0x80, 255, 255, 255, 255); - gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(play->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); + CLOSE_DISPS(play->state.gfxCtx); + + OPEN_DISPS(play->state.gfxCtx); + + AnimatedMat_Draw(play, 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); - CLOSE_DISPS(globalCtx->state.gfxCtx); - - OPEN_DISPS(gfxCtx); - - func_8012C2DC(globalCtx->state.gfxCtx); + func_8012C2DC(play->state.gfxCtx); gDPSetEnvColor(POLY_XLU_DISP++, sp64[sp60].r, sp64[sp60].g, sp64[sp60].b, 255); gDPSetPrimColor(POLY_XLU_DISP++, 0, 0x80, 255, 255, 255, this->unk_203); - gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_XLU_DISP++, object_warp1_DL_0058C8); - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->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) { +void DoorWarp1_Draw(Actor* thisx, PlayState* play) { DoorWarp1* this = THIS; switch (DOORWARP1_GET_FF(&this->dyna.actor)) { case ENDOORWARP1_FF_0: - func_808BAE9C(this, globalCtx); + func_808BAE9C(this, play); break; case ENDOORWARP1_FF_1: - func_808BACCC(this, globalCtx); - func_808BAE9C(this, globalCtx); + func_808BACCC(this, play); + func_808BAE9C(this, play); break; case ENDOORWARP1_FF_2: case ENDOORWARP1_FF_3: case ENDOORWARP1_FF_4: case ENDOORWARP1_FF_5: - func_808BB4C4(this, globalCtx); + func_808BB4C4(this, play); break; case ENDOORWARP1_FF_6: - func_808BB4F4(this, globalCtx); + func_808BB4F4(this, play); break; } } -#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; +void func_808BB8D4(DoorWarp1* this, PlayState* play, s32 arg2) { + 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(play, &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_Door_Warp1/z_door_warp1.h b/src/overlays/actors/ovl_Door_Warp1/z_door_warp1.h index ca177006b..c57f610a0 100644 --- a/src/overlays/actors/ovl_Door_Warp1/z_door_warp1.h +++ b/src/overlays/actors/ovl_Door_Warp1/z_door_warp1.h @@ -6,7 +6,7 @@ struct DoorWarp1; -typedef void (*DoorWarp1ActionFunc)(struct DoorWarp1*, GlobalContext*); +typedef void (*DoorWarp1ActionFunc)(struct DoorWarp1*, PlayState*); #define DOORWARP1_GET_FF(thisx) ((thisx)->params & 0xFF) #define DOORWARP1_GET_FF00_1(thisx) (((thisx)->params >> 8) & 0xFF) @@ -24,36 +24,36 @@ enum { }; typedef struct DoorWarp1 { - /* 0x0000 */ DynaPolyActor dyna; - /* 0x015C */ SkelAnime skelAnime; - /* 0x01A0 */ DmHina* unk_1A0; - /* 0x01A4 */ f32 unk_1A4; - /* 0x01A8 */ f32 unk_1A8; - /* 0x01AC */ f32 unk_1AC; - /* 0x01B0 */ f32 unk_1B0; - /* 0x01B4 */ f32 unk_1B4; - /* 0x01B8 */ f32 unk_1B8; - /* 0x01BC */ f32 unk_1BC; - /* 0x01C0 */ f32 unk_1C0; - /* 0x01C4 */ s16 unk_1C4; - /* 0x01C6 */ s16 unk_1C6; - /* 0x01C8 */ s16 unk_1C8; - /* 0x01CA */ s16 unk_1CA; - /* 0x01CC */ s16 unk_1CC; - /* 0x01CE */ s16 unk_1CE; - /* 0x01D0 */ u16 unk_1D0; - /* 0x01D2 */ s8 unk_1D2; - /* 0x01D3 */ u8 unk_1D3; - /* 0x01D4 */ u8 unk_1D4; - /* 0x01D8 */ DoorWarp1ActionFunc actionFunc; - /* 0x01DC */ LightNode* unk_1DC; - /* 0x01E0 */ LightInfo unk_1E0; - /* 0x01F0 */ LightNode* unk_1F0; - /* 0x01F4 */ LightInfo unk_1F4; - /* 0x0202 */ u8 unk_202; - /* 0x0203 */ u8 unk_203; - /* 0x0204 */ f32 unk_204; - /* 0x0208 */ u8 unk_208; + /* 0x000 */ DynaPolyActor dyna; + /* 0x15C */ SkelAnime skelAnime; + /* 0x1A0 */ DmHina* unk_1A0; + /* 0x1A4 */ f32 unk_1A4; + /* 0x1A8 */ f32 unk_1A8; + /* 0x1AC */ f32 unk_1AC; + /* 0x1B0 */ f32 unk_1B0; + /* 0x1B4 */ f32 unk_1B4; + /* 0x1B8 */ f32 unk_1B8; + /* 0x1BC */ f32 unk_1BC; + /* 0x1C0 */ f32 unk_1C0; + /* 0x1C4 */ s16 unk_1C4; + /* 0x1C6 */ s16 unk_1C6; + /* 0x1C8 */ s16 unk_1C8; + /* 0x1CA */ s16 unk_1CA; + /* 0x1CC */ s16 unk_1CC; + /* 0x1CE */ s16 unk_1CE; + /* 0x1D0 */ u16 unk_1D0; + /* 0x1D2 */ s8 unk_1D2; + /* 0x1D3 */ u8 unk_1D3; + /* 0x1D4 */ u8 unk_1D4; + /* 0x1D8 */ DoorWarp1ActionFunc actionFunc; + /* 0x1DC */ LightNode* unk_1DC; + /* 0x1E0 */ LightInfo unk_1E0; + /* 0x1F0 */ LightNode* unk_1F0; + /* 0x1F4 */ LightInfo unk_1F4; + /* 0x202 */ u8 unk_202; + /* 0x203 */ u8 unk_203; + /* 0x204 */ f32 unk_204; + /* 0x208 */ u8 unk_208; } DoorWarp1; // size = 0x20C extern const ActorInit Door_Warp1_InitVars; diff --git a/src/overlays/actors/ovl_Eff_Change/z_eff_change.c b/src/overlays/actors/ovl_Eff_Change/z_eff_change.c index d7bd601f0..0f5245617 100644 --- a/src/overlays/actors/ovl_Eff_Change/z_eff_change.c +++ b/src/overlays/actors/ovl_Eff_Change/z_eff_change.c @@ -10,11 +10,14 @@ #define THIS ((EffChange*)thisx) -void EffChange_Init(Actor* thisx, GlobalContext* globalCtx); -void EffChange_Destroy(Actor* thisx, GlobalContext* globalCtx); -void EffChange_Update(Actor* thisx, GlobalContext* globalCtx); +void EffChange_Init(Actor* thisx, PlayState* play); +void EffChange_Destroy(Actor* thisx, PlayState* play); +void EffChange_Update(Actor* thisx, PlayState* play); +void EffChange_Draw(Actor* thisx, PlayState* play); + +void EffChange_SetColors(EffChange* this, s32 arg1); +void func_80A4C5CC(EffChange* this, PlayState* play); -#if 0 const ActorInit Eff_Change_InitVars = { ACTOR_EFF_CHANGE, ACTORCAT_ITEMACTION, @@ -27,16 +30,118 @@ const ActorInit Eff_Change_InitVars = { (ActorFunc)NULL, }; -#endif +static u8 D_80A4C920[] = { + // prim r g b env r g b + 255, 255, 170, 0, 100, 0, // COLOR_0 + 255, 255, 170, 200, 0, 0, // COLOR_1 + 170, 255, 255, 0, 100, 255, // COLOR_2 + 255, 255, 170, 200, 150, 0, // COLOR_3 + 255, 255, 170, 0, 100, 0, // COLOR_4 + 255, 255, 170, 0, 100, 0, // COLOR_5 + 255, 255, 170, 0, 100, 0, // COLOR_6 + 255, 255, 170, 0, 100, 0 // COLOR_7 +}; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Eff_Change/EffChange_Init.s") +void EffChange_Init(Actor* thisx, PlayState* play) { + EffChange* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Eff_Change/EffChange_Destroy.s") + this->actionFunc = func_80A4C5CC; + this->actor.draw = EffChange_Draw; + EffChange_SetColors(this, EFFCHANGE_GET_COLORS(thisx)); + Actor_SetScale(&this->actor, 0.075f); + this->primColors[3] = 0; + func_80183430(&this->skeletonInfo, gameplay_keep_Blob_02900C, gameplay_keep_Blob_0281DC, this->jointTable, + this->morphTable, NULL); + func_801834A8(&this->skeletonInfo, gameplay_keep_Blob_0281DC); + this->step = 0; + this->actor.shape.rot.y = 0; + this->skeletonInfo.frameCtrl.unk_C = (2.0f / 3.0f); + ActorCutscene_SetIntentToPlay(0x7B); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Eff_Change/func_80A4C578.s") +void EffChange_Destroy(Actor* thisx, PlayState* play) { + EffChange* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Eff_Change/func_80A4C5CC.s") + func_8018349C(&this->skeletonInfo); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Eff_Change/EffChange_Update.s") +void EffChange_SetColors(EffChange* this, s32 arg1) { + arg1 *= 6; + this->primColors[0] = D_80A4C920[arg1]; + this->primColors[1] = D_80A4C920[arg1 + 1]; + this->primColors[2] = D_80A4C920[arg1 + 2]; + this->envColors[0] = D_80A4C920[arg1 + 3]; + this->envColors[1] = D_80A4C920[arg1 + 4]; + this->envColors[2] = D_80A4C920[arg1 + 5]; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Eff_Change/func_80A4C7B0.s") +void func_80A4C5CC(EffChange* this, PlayState* play) { + f32 phi_fv0; + + if (func_80183DE0(&this->skeletonInfo)) { + Actor_MarkForDeath(&this->actor); + ActorCutscene_Stop(0x7B); + func_800FD2B4(play, 0.0f, 850.0f, 0.2f, 0.0f); + } else { + this->step++; + if (this->skeletonInfo.frameCtrl.unk_10 < 20.0f) { + if ((this->primColors[3]) < 242) { + this->primColors[3] += 13; + } else { + this->primColors[3] = 255; + } + } else if (this->skeletonInfo.frameCtrl.unk_10 > 70.0f) { + if ((this->primColors[3]) >= 14) { + this->primColors[3] -= 13; + } else { + this->primColors[3] = 0; + } + } else { + this->primColors[3] = 255; + } + + phi_fv0 = this->primColors[3] * (1.0f / 255.0f); + if (phi_fv0 > 1.0f) { + phi_fv0 = 1.0f; + } else if (phi_fv0 < 0.0f) { + phi_fv0 = 0.0f; + } + func_800FD2B4(play, phi_fv0, 850.0f, 0.2f, 0.0f); + if (ActorCutscene_GetCurrentIndex() != 0x7B) { + if (ActorCutscene_GetCanPlayNext(0x7B)) { + ActorCutscene_Start(0x7B, &this->actor); + } else { + ActorCutscene_SetIntentToPlay(0x7B); + } + } + } +} + +void EffChange_Update(Actor* thisx, PlayState* play) { + EffChange* this = THIS; + + this->actionFunc(this, play); +} + +void EffChange_Draw(Actor* thisx, PlayState* play) { + s32 pad; + Mtx* mtx; + EffChange* this = THIS; + + AnimatedMat_DrawStepXlu(play, Lib_SegmentedToVirtual(&gameplay_keep_Matanimheader_028FEC), this->step); + mtx = GRAPH_ALLOC(play->state.gfxCtx, ALIGN16(this->skeletonInfo.unk_18->unk_1 * sizeof(Mtx))); + + if (mtx != NULL) { + func_8012C2DC(play->state.gfxCtx); + Matrix_RotateYS((Camera_GetCamDirYaw(GET_ACTIVE_CAM(play)) + 0x8000), MTXMODE_APPLY); + + OPEN_DISPS(play->state.gfxCtx); + + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0x80, this->primColors[0], this->primColors[1], this->primColors[2], + this->primColors[3]); + gDPSetEnvColor(POLY_XLU_DISP++, this->envColors[0], this->envColors[1], this->envColors[2], 255); + func_8018450C(play, &this->skeletonInfo, mtx, NULL, NULL, &this->actor); + + CLOSE_DISPS(play->state.gfxCtx); + } +} diff --git a/src/overlays/actors/ovl_Eff_Change/z_eff_change.h b/src/overlays/actors/ovl_Eff_Change/z_eff_change.h index 0c6c7a534..aed7e534a 100644 --- a/src/overlays/actors/ovl_Eff_Change/z_eff_change.h +++ b/src/overlays/actors/ovl_Eff_Change/z_eff_change.h @@ -2,15 +2,23 @@ #define Z_EFF_CHANGE_H #include "global.h" +#include "objects/gameplay_keep/gameplay_keep.h" + +#define EFFCHANGE_GET_COLORS(thisx) ((thisx)->params & 7) struct EffChange; -typedef void (*EffChangeActionFunc)(struct EffChange*, GlobalContext*); +typedef void (*EffChangeActionFunc)(struct EffChange*, PlayState*); typedef struct EffChange { - /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x84]; - /* 0x01C8 */ EffChangeActionFunc actionFunc; + /* 0x000 */ Actor actor; + /* 0x144 */ SkeletonInfo skeletonInfo; + /* 0x174 */ Vec3s jointTable[PINK_DEKU_FLOWER_LIMB_BACK_RIGHT_PETAL]; + /* 0x198 */ Vec3s morphTable[PINK_DEKU_FLOWER_LIMB_BACK_RIGHT_PETAL]; + /* 0x1BC */ s16 step; + /* 0x1BE */ u8 primColors[4]; + /* 0x1C2 */ u8 envColors[4]; + /* 0x1C8 */ EffChangeActionFunc actionFunc; } EffChange; // size = 0x1CC extern const ActorInit Eff_Change_InitVars; diff --git a/src/overlays/actors/ovl_Eff_Dust/z_eff_dust.c b/src/overlays/actors/ovl_Eff_Dust/z_eff_dust.c index e53635603..b2d896a14 100644 --- a/src/overlays/actors/ovl_Eff_Dust/z_eff_dust.c +++ b/src/overlays/actors/ovl_Eff_Dust/z_eff_dust.c @@ -12,17 +12,17 @@ #define THIS ((EffDust*)thisx) -void EffDust_Init(Actor* thisx, GlobalContext* globalCtx); -void EffDust_Destroy(Actor* thisx, GlobalContext* globalCtx); -void EffDust_Update(Actor* thisx, GlobalContext* globalCtx); -void EffDust_Draw(Actor* thisx, GlobalContext* globalCtx); +void EffDust_Init(Actor* thisx, PlayState* play); +void EffDust_Destroy(Actor* thisx, PlayState* play); +void EffDust_Update(Actor* thisx, PlayState* play); +void EffDust_Draw(Actor* thisx, PlayState* play); -void func_80918D64(EffDust* this, GlobalContext* globalCtx); -void func_80918FE4(EffDust* this, GlobalContext* globalCtx); -void func_80919230(EffDust* this, GlobalContext* globalCtx); +void func_80918D64(EffDust* this, PlayState* play); +void func_80918FE4(EffDust* this, PlayState* play); +void func_80919230(EffDust* this, PlayState* play); -void func_80919768(Actor* thisx, GlobalContext* globalCtx); -void func_809199FC(Actor* thisx, GlobalContext* globalCtx); +void func_80919768(Actor* thisx, PlayState* play); +void func_809199FC(Actor* thisx, PlayState* play); const ActorInit Eff_Dust_InitVars = { ACTOR_EFF_DUST, @@ -49,7 +49,7 @@ void func_80918B40(EffDust* this) { this->index = 0; } -void EffDust_Init(Actor* thisx, GlobalContext* globalCtx) { +void EffDust_Init(Actor* thisx, PlayState* play) { EffDust* this = THIS; u32 type = this->actor.params; @@ -100,10 +100,10 @@ void EffDust_Init(Actor* thisx, GlobalContext* globalCtx) { this->life = 10; } -void EffDust_Destroy(Actor* thisx, GlobalContext* globalCtx) { +void EffDust_Destroy(Actor* thisx, PlayState* play) { } -void func_80918D64(EffDust* this, GlobalContext* globalCtx) { +void func_80918D64(EffDust* this, PlayState* play) { s16 theta; s16 fi; s32 i; @@ -134,7 +134,7 @@ void func_80918D64(EffDust* this, GlobalContext* globalCtx) { } } -void func_80918FE4(EffDust* this, GlobalContext* globalCtx) { +void func_80918FE4(EffDust* this, PlayState* play) { s16 theta; s16 fi; f32* distanceTraveled = this->distanceTraveled; @@ -163,9 +163,9 @@ void func_80918FE4(EffDust* this, GlobalContext* globalCtx) { } } -void func_80919230(EffDust* this, GlobalContext* globalCtx) { +void func_80919230(EffDust* this, PlayState* play) { s16 theta; - Player* player = GET_PLAYER(globalCtx); + Player* player = GET_PLAYER(play); Actor* parent = this->actor.parent; f32* distanceTraveled = this->distanceTraveled; s32 i; @@ -243,20 +243,20 @@ void func_80919230(EffDust* this, GlobalContext* globalCtx) { } } -void EffDust_Update(Actor* thisx, GlobalContext* globalCtx) { +void EffDust_Update(Actor* thisx, PlayState* play) { EffDust* this = THIS; - this->actionFunc(this, globalCtx); + this->actionFunc(this, play); } Gfx D_80919DB0[] = { gsSPEndDisplayList(), }; -void func_80919768(Actor* thisx, GlobalContext* globalCtx2) { +void func_80919768(Actor* thisx, PlayState* play2) { EffDust* this = THIS; - GlobalContext* globalCtx = globalCtx2; - GraphicsContext* gfxCtx = globalCtx2->state.gfxCtx; + PlayState* play = play2; + GraphicsContext* gfxCtx = play2->state.gfxCtx; f32* distanceTraveled; Vec3f* initialPositions; s32 i; @@ -264,7 +264,7 @@ void func_80919768(Actor* thisx, GlobalContext* globalCtx2) { s16 sp92; Vec3f activeCamEye; - activeCamEye = GET_ACTIVE_CAM(globalCtx)->eye; + activeCamEye = GET_ACTIVE_CAM(play)->eye; sp92 = Math_Vec3f_Yaw(&activeCamEye, &thisx->world.pos); OPEN_DISPS(gfxCtx); @@ -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(&play->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); } @@ -307,15 +307,15 @@ void func_80919768(Actor* thisx, GlobalContext* globalCtx2) { CLOSE_DISPS(gfxCtx); } -void func_809199FC(Actor* thisx, GlobalContext* globalCtx2) { +void func_809199FC(Actor* thisx, PlayState* play2) { EffDust* this = THIS; - GlobalContext* globalCtx = globalCtx2; - GraphicsContext* gfxCtx = globalCtx2->state.gfxCtx; + PlayState* play = play2; + GraphicsContext* gfxCtx = play2->state.gfxCtx; f32* distanceTraveled; Vec3f* initialPositions; s32 i; f32 aux; - Player* player = GET_PLAYER(globalCtx); + Player* player = GET_PLAYER(play); OPEN_DISPS(gfxCtx); func_8012C28C(gfxCtx); @@ -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(&play->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); } @@ -363,8 +363,8 @@ void func_809199FC(Actor* thisx, GlobalContext* globalCtx2) { CLOSE_DISPS(gfxCtx); } -void EffDust_Draw(Actor* thisx, GlobalContext* globalCtx) { +void EffDust_Draw(Actor* thisx, PlayState* play) { EffDust* this = THIS; - this->drawFunc(thisx, globalCtx); + this->drawFunc(thisx, play); } diff --git a/src/overlays/actors/ovl_Eff_Dust/z_eff_dust.h b/src/overlays/actors/ovl_Eff_Dust/z_eff_dust.h index ec03b49d0..ec864ea4d 100644 --- a/src/overlays/actors/ovl_Eff_Dust/z_eff_dust.h +++ b/src/overlays/actors/ovl_Eff_Dust/z_eff_dust.h @@ -5,29 +5,29 @@ struct EffDust; -typedef void (*EffDustActionFunc)(struct EffDust*, GlobalContext*); +typedef void (*EffDustActionFunc)(struct EffDust*, PlayState*); typedef struct EffDust { - /* 0x0000 */ Actor actor; - /* 0x0144 */ f32 distanceTraveled[64]; // For each particle. Normalized. From 0.0f to 1.0f - /* 0x0244 */ Vec3f initialPositions[64]; // Array of position for each dust particle. - /* 0x0544 */ u8 index; - /* 0x0545 */ u8 life; // Only considered if actor.params is 2, 3 or 4. - /* 0x0548 */ f32 dx; // Normalized. 0.0f to 1.0f - /* 0x054C */ f32 dy; // Normalized. 0.0f to 1.0f - /* 0x0550 */ f32 dz; // Normalized. 0.0f to 1.0f - /* 0x0554 */ f32 scalingFactor; - /* 0x0558 */ EffDustActionFunc actionFunc; - /* 0x055C */ ActorFunc drawFunc; + /* 0x000 */ Actor actor; + /* 0x144 */ f32 distanceTraveled[64]; // For each particle. Normalized. From 0.0f to 1.0f + /* 0x244 */ Vec3f initialPositions[64]; // Array of position for each dust particle. + /* 0x544 */ u8 index; + /* 0x545 */ u8 life; // Only considered if actor.params is 2, 3 or 4. + /* 0x548 */ f32 dx; // Normalized. 0.0f to 1.0f + /* 0x54C */ f32 dy; // Normalized. 0.0f to 1.0f + /* 0x550 */ f32 dz; // Normalized. 0.0f to 1.0f + /* 0x554 */ f32 scalingFactor; + /* 0x558 */ EffDustActionFunc actionFunc; + /* 0x55C */ ActorFunc drawFunc; } EffDust; // size = 0x560 typedef enum { - /* 0x00 */ EFF_DUST_TYPE_0, - /* 0x01 */ EFF_DUST_TYPE_1, - /* 0x02 */ EFF_DUST_TYPE_2, - /* 0x03 */ EFF_DUST_TYPE_3, - /* 0x04 */ EFF_DUST_TYPE_4, - /* 0x05 */ EFF_DUST_TYPE_5 + /* 0x0 */ EFF_DUST_TYPE_0, + /* 0x1 */ EFF_DUST_TYPE_1, + /* 0x2 */ EFF_DUST_TYPE_2, + /* 0x3 */ EFF_DUST_TYPE_3, + /* 0x4 */ EFF_DUST_TYPE_4, + /* 0x5 */ EFF_DUST_TYPE_5 } EffDustType; extern const ActorInit Eff_Dust_InitVars; diff --git a/src/overlays/actors/ovl_Eff_Kamejima_Wave/z_eff_kamejima_wave.c b/src/overlays/actors/ovl_Eff_Kamejima_Wave/z_eff_kamejima_wave.c index 687ae1b96..83842569f 100644 --- a/src/overlays/actors/ovl_Eff_Kamejima_Wave/z_eff_kamejima_wave.c +++ b/src/overlays/actors/ovl_Eff_Kamejima_Wave/z_eff_kamejima_wave.c @@ -5,16 +5,23 @@ */ #include "z_eff_kamejima_wave.h" +#include "objects/object_kamejima/object_kamejima.h" #define FLAGS (ACTOR_FLAG_10) #define THIS ((EffKamejimaWave*)thisx) -void EffKamejimaWave_Init(Actor* thisx, GlobalContext* globalCtx); -void EffKamejimaWave_Destroy(Actor* thisx, GlobalContext* globalCtx); -void EffKamejimaWave_Update(Actor* thisx, GlobalContext* globalCtx); +void EffKamejimaWave_Init(Actor* thisx, PlayState* play); +void EffKamejimaWave_Destroy(Actor* thisx, PlayState* play); +void EffKamejimaWave_Update(Actor* thisx, PlayState* play); +void EffKamejimaWave_Draw(Actor* thisx, PlayState* play); + +void func_80BCEC6C(EffKamejimaWave* this, PlayState* play); +void func_80BCEDE0(EffKamejimaWave* this, PlayState* play); +void func_80BCEBC0(EffKamejimaWave* this, PlayState* play); +void func_80BCED34(EffKamejimaWave* this, PlayState* play); +void EffKamejimaWave_SetVtxAlpha(u8 alpha); -#if 0 const ActorInit Eff_Kamejima_Wave_InitVars = { ACTOR_EFF_KAMEJIMA_WAVE, ACTORCAT_ITEMACTION, @@ -27,26 +34,138 @@ const ActorInit Eff_Kamejima_Wave_InitVars = { (ActorFunc)NULL, }; -#endif +static Color_RGBA8 sPrimColors[] = { + { 255, 240, 255, 255 }, { 255, 255, 255, 255 }, { 255, 240, 230, 255 }, { 140, 170, 220, 255 } +}; +static Color_RGBA8 sEnvColors[] = { + { 130, 80, 90, 255 }, { 90, 120, 130, 255 }, { 130, 80, 70, 255 }, { 40, 60, 110, 255 } +}; -extern UNK_TYPE D_06000000; -extern UNK_TYPE D_06000140; -extern UNK_TYPE D_06001AF0; +s16 sVtxAlpha; +AnimatedMaterial* D_80BCF1C4; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Eff_Kamejima_Wave/EffKamejimaWave_Init.s") +void EffKamejimaWave_Init(Actor* thisx, PlayState* play) { + EffKamejimaWave* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Eff_Kamejima_Wave/EffKamejimaWave_Destroy.s") + Actor_SetScale(&this->actor, 0.2f); + this->actor.scale.y = 0.0f; + if (EFFKAMEJIMAWAVE_GET_F(thisx) == EFFKAMEJIMAWAVE_PARAMS_1) { + this->actionFunc = func_80BCEDE0; + sVtxAlpha = 255; + } else { + this->actionFunc = func_80BCEC6C; + sVtxAlpha = 255; + } + D_80BCF1C4 = Lib_SegmentedToVirtual(object_kamejima_Matanimheader_001AF0); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Eff_Kamejima_Wave/func_80BCEBC0.s") +void EffKamejimaWave_Destroy(Actor* thisx, PlayState* play) { +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Eff_Kamejima_Wave/func_80BCEC6C.s") +void func_80BCEBC0(EffKamejimaWave* this, PlayState* play) { + this->actor.scale.y += this->scaleOffset; + this->scaleOffset -= 0.003f; + this->actor.shape.rot.x += 0x64; + if (this->scaleOffset < 0.0f) { + this->actor.scale.x += 0.003f; + } + if (this->scaleOffset < -0.01f) { + this->scaleOffset = -0.01f; + } + if (this->actor.scale.y < 0.0f) { + this->actor.scale.y = 0.0f; + this->actor.scale.x = 0.2f; + this->actionFunc = func_80BCEC6C; + this->actor.draw = NULL; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Eff_Kamejima_Wave/func_80BCED34.s") +void func_80BCEC6C(EffKamejimaWave* this, PlayState* play) { + if (Cutscene_CheckActorAction(play, 0x1E0)) { + Cutscene_ActorTranslateAndYaw(&this->actor, play, Cutscene_GetActorActionIndex(play, 0x1E0)); + if (play->csCtx.actorActions[Cutscene_GetActorActionIndex(play, 0x1E0)]->action == 2) { + this->scaleOffset = 0.05f; + this->actionFunc = func_80BCEBC0; + this->actor.draw = EffKamejimaWave_Draw; + sVtxAlpha = 255; + this->actor.shape.rot.x = 0; + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_TORTOISE_WAKE_UP); + } + } else { + this->actor.draw = NULL; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Eff_Kamejima_Wave/func_80BCEDE0.s") +void func_80BCED34(EffKamejimaWave* this, PlayState* play) { + this->actor.scale.y += this->scaleOffset; + this->scaleOffset -= 0.002f; + this->actor.shape.rot.x += 0x8C; + if (this->scaleOffset < 0.0f) { + this->actor.scale.x += 0.002f; + } + if (this->scaleOffset < 0.0f) { + this->scaleOffset = 0; + } + if (sVtxAlpha >= 4) { + sVtxAlpha -= 4; + } else { + this->actor.scale.y = 0.0f; + this->actionFunc = func_80BCEDE0; + this->actor.draw = NULL; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Eff_Kamejima_Wave/EffKamejimaWave_Update.s") +void func_80BCEDE0(EffKamejimaWave* this, PlayState* play) { + if (Cutscene_CheckActorAction(play, 0x1F6)) { + Cutscene_ActorTranslateAndYaw(&this->actor, play, Cutscene_GetActorActionIndex(play, 0x1F6)); + if (play->csCtx.actorActions[Cutscene_GetActorActionIndex(play, 0x1F6)]->action == 2) { + this->scaleOffset = 0.03f; + this->actor.scale.x = 0.35f; + this->actionFunc = func_80BCED34; + this->actor.draw = EffKamejimaWave_Draw; + this->actor.shape.rot.x = 0; + } + } else { + this->actor.draw = NULL; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Eff_Kamejima_Wave/func_80BCEEBC.s") +void EffKamejimaWave_Update(Actor* thisx, PlayState* play) { + EffKamejimaWave* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Eff_Kamejima_Wave/func_80BCEF0C.s") + this->actionFunc(this, play); +} + +void EffKamejimaWave_SetVtxAlpha(u8 alpha) { + Vtx* vtx = Lib_SegmentedToVirtual(&object_kamejima_Vtx_000000); + + vtx[2].v.cn[3] = alpha; + vtx[6].v.cn[3] = alpha; + vtx[8].v.cn[3] = alpha; + vtx[9].v.cn[3] = alpha; + vtx[12].v.cn[3] = alpha; + vtx[16].v.cn[3] = alpha; + vtx[18].v.cn[3] = alpha; + vtx[19].v.cn[3] = alpha; +} + +void EffKamejimaWave_Draw(Actor* thisx, PlayState* play) { + Color_RGBA8 primColor; + Color_RGBA8 envColor; + + func_800FE7A8(sPrimColors, &primColor); + func_800FE7A8(sEnvColors, &envColor); + EffKamejimaWave_SetVtxAlpha(sVtxAlpha); + + OPEN_DISPS(play->state.gfxCtx); + + func_8012C2DC(play->state.gfxCtx); + Matrix_Scale(6.0f, 5.0f, 5.0f, MTXMODE_APPLY); + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + AnimatedMat_Draw(play, D_80BCF1C4); + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0x80, primColor.r, primColor.g, primColor.b, 255); + gDPSetEnvColor(POLY_XLU_DISP++, envColor.r, envColor.g, envColor.b, 255); + gSPDisplayList(POLY_XLU_DISP++, object_kamejima_DL_000140); + + CLOSE_DISPS(play->state.gfxCtx); +} diff --git a/src/overlays/actors/ovl_Eff_Kamejima_Wave/z_eff_kamejima_wave.h b/src/overlays/actors/ovl_Eff_Kamejima_Wave/z_eff_kamejima_wave.h index 2f20aed92..9b4713034 100644 --- a/src/overlays/actors/ovl_Eff_Kamejima_Wave/z_eff_kamejima_wave.h +++ b/src/overlays/actors/ovl_Eff_Kamejima_Wave/z_eff_kamejima_wave.h @@ -3,16 +3,24 @@ #include "global.h" +#define EFFKAMEJIMAWAVE_GET_F(thisx) ((thisx)->params & 0xF) + struct EffKamejimaWave; -typedef void (*EffKamejimaWaveActionFunc)(struct EffKamejimaWave*, GlobalContext*); +typedef void (*EffKamejimaWaveActionFunc)(struct EffKamejimaWave*, PlayState*); typedef struct EffKamejimaWave { - /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x8]; - /* 0x014C */ EffKamejimaWaveActionFunc actionFunc; + /* 0x000 */ Actor actor; + /* 0x144 */ f32 scaleOffset; + /* 0x148 */ UNK_TYPE1 pad148[4]; + /* 0x14C */ EffKamejimaWaveActionFunc actionFunc; } EffKamejimaWave; // size = 0x150 +typedef enum params { + /* 0x0 */ EFFKAMEJIMAWAVE_PARAMS_0, + /* 0x1 */ EFFKAMEJIMAWAVE_PARAMS_1 +} EffKamejimaWaveParams; + extern const ActorInit Eff_Kamejima_Wave_InitVars; #endif // Z_EFF_KAMEJIMA_WAVE_H diff --git a/src/overlays/actors/ovl_Eff_Lastday/z_eff_lastday.c b/src/overlays/actors/ovl_Eff_Lastday/z_eff_lastday.c index 3901c0179..773e881ed 100644 --- a/src/overlays/actors/ovl_Eff_Lastday/z_eff_lastday.c +++ b/src/overlays/actors/ovl_Eff_Lastday/z_eff_lastday.c @@ -5,22 +5,29 @@ */ #include "z_eff_lastday.h" +#include "objects/object_lastday/object_lastday.h" #define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_20) #define THIS ((EffLastday*)thisx) -void EffLastday_Init(Actor* thisx, GlobalContext* globalCtx); -void EffLastday_Destroy(Actor* thisx, GlobalContext* globalCtx); -void EffLastday_Update(Actor* thisx, GlobalContext* globalCtx); -void EffLastday_Draw(Actor* thisx, GlobalContext* globalCtx); +void EffLastday_Init(Actor* thisx, PlayState* play2); +void EffLastday_Destroy(Actor* thisx, PlayState* play); +void EffLastday_Update(Actor* thisx, PlayState* play); +void EffLastday_Draw(Actor* thisx, PlayState* play); -void func_80BEBD0C(EffLastday* this, GlobalContext* globalCtx); -void func_80BEBDF8(EffLastday* this, GlobalContext* globalCtx); -void func_80BEBEB8(EffLastday* this, GlobalContext* globalCtx); -void func_80BEBF78(EffLastday* this, GlobalContext* globalCtx); +void func_80BEBD0C(EffLastday* this, PlayState* play); +void func_80BEBDF8(EffLastday* this, PlayState* play); +void func_80BEBEB8(EffLastday* this, PlayState* play); +void func_80BEBF78(EffLastday* this, PlayState* play); + +typedef enum EffLastDayAction { + /* 0x0 */ EFFLASTDAY_ACTION_NONE, + /* 0x1 */ EFFLASTDAY_ACTION_1, + /* 0x2 */ EFFLASTDAY_ACTION_2, + /* 0x3 */ EFFLASTDAY_ACTION_3 +} EffLastDayAction; -#if 0 const ActorInit Eff_Lastday_InitVars = { ACTOR_EFF_LASTDAY, ACTORCAT_ITEMACTION, @@ -33,25 +40,216 @@ const ActorInit Eff_Lastday_InitVars = { (ActorFunc)EffLastday_Draw, }; -#endif +void EffLastday_Init(Actor* thisx, PlayState* play2) { + PlayState* play = play2; + EffLastday* this = THIS; -extern UNK_TYPE D_06000000; -extern UNK_TYPE D_06000510; + Actor_SetScale(&this->actor, 0.1f); + switch (EFFLASTDAY_GET_F(&this->actor)) { + case EFFLASTDAY_PARAMS_1: + this->dList = object_lastday_DL_000510; + this->matAnim = Lib_SegmentedToVirtual(object_lastday_Matanimheader_000608); + this->csActionCmd = 0x1FC; + this->actionFunc = func_80BEBDF8; + Actor_SetScale(&this->actor, 1.0f); + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Eff_Lastday/EffLastday_Init.s") + case EFFLASTDAY_PARAMS_2: + this->dList = object_lastday_DL_000210; + this->matAnim = Lib_SegmentedToVirtual(object_lastday_Matanimheader_000308); + this->csActionCmd = 0x1FD; + this->actionFunc = func_80BEBEB8; + Actor_SetScale(&this->actor, 0.5f); + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Eff_Lastday/EffLastday_Destroy.s") + case EFFLASTDAY_PARAMS_3: + this->dList = object_lastday_DL_000060; + this->matAnim = Lib_SegmentedToVirtual(object_lastday_Matanimheader_000148); + this->csActionCmd = 0x1FE; + this->actionFunc = func_80BEBF78; + Actor_SetScale(&this->actor, 0.2f); + this->actor.home.rot.z = 0; + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Eff_Lastday/func_80BEBD0C.s") + default: + this->dList = object_lastday_DL_000370; + this->matAnim = Lib_SegmentedToVirtual(object_lastday_Matanimheader_000448); + this->csActionCmd = 0x1FB; + this->actionFunc = func_80BEBD0C; + Actor_SetScale(&this->actor, 1.0f); + Actor_SpawnAsChild(&play->actorCtx, &this->actor, play, ACTOR_EFF_LASTDAY, this->actor.world.pos.x, + this->actor.world.pos.y, this->actor.world.pos.z, 0, this->actor.world.rot.y, 0, + EFFLASTDAY_PARAMS_1); + Actor_SpawnAsChild(&play->actorCtx, &this->actor, play, ACTOR_EFF_LASTDAY, this->actor.world.pos.x, + this->actor.world.pos.y, this->actor.world.pos.z, 0, this->actor.world.rot.y, 0, + EFFLASTDAY_PARAMS_2); + Actor_SpawnAsChild(&play->actorCtx, &this->actor, play, ACTOR_EFF_LASTDAY, this->actor.world.pos.x, + this->actor.world.pos.y, this->actor.world.pos.z, 0, this->actor.world.rot.y, 0, + EFFLASTDAY_PARAMS_3); + break; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Eff_Lastday/func_80BEBDF8.s") +void EffLastday_Destroy(Actor* thisx, PlayState* play) { +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Eff_Lastday/func_80BEBEB8.s") +void func_80BEBD0C(EffLastday* this, PlayState* play) { + u16 csAction; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Eff_Lastday/func_80BEBF78.s") + if ((Cutscene_CheckActorAction(play, this->csActionCmd))) { + Cutscene_ActorTranslateAndYaw(&this->actor, play, Cutscene_GetActorActionIndex(play, this->csActionCmd)); + csAction = play->csCtx.actorActions[Cutscene_GetActorActionIndex(play, this->csActionCmd)]->action; + switch (csAction) { + default: + this->actor.draw = NULL; + this->alpha = 0; + this->step = 0; + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Eff_Lastday/EffLastday_Update.s") + case EFFLASTDAY_ACTION_2: + this->actor.draw = NULL; + this->actor.draw = EffLastday_Draw; + if (this->alpha < 255) { + this->alpha += 10; + } + if (this->alpha > 255) { + this->alpha = 255; + } + this->step++; + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Eff_Lastday/func_80BEC0A4.s") + case EFFLASTDAY_ACTION_3: + this->actor.draw = EffLastday_Draw; + break; + } + } else { + this->actor.draw = NULL; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Eff_Lastday/EffLastday_Draw.s") +void func_80BEBDF8(EffLastday* this, PlayState* play) { + u16 csAction; + + if (Cutscene_CheckActorAction(play, this->csActionCmd)) { + Cutscene_ActorTranslateAndYaw(&this->actor, play, Cutscene_GetActorActionIndex(play, this->csActionCmd)); + csAction = play->csCtx.actorActions[Cutscene_GetActorActionIndex(play, this->csActionCmd)]->action; + switch (csAction) { + default: + this->actor.draw = NULL; + this->step = 0; + break; + + case EFFLASTDAY_ACTION_2: + this->actor.draw = EffLastday_Draw; + this->step++; + break; + + case EFFLASTDAY_ACTION_3: + this->actor.draw = EffLastday_Draw; + break; + } + } else { + this->actor.draw = NULL; + } +} + +void func_80BEBEB8(EffLastday* this, PlayState* play) { + u16 csAction; + + if (Cutscene_CheckActorAction(play, this->csActionCmd)) { + Cutscene_ActorTranslateAndYaw(&this->actor, play, Cutscene_GetActorActionIndex(play, this->csActionCmd)); + csAction = play->csCtx.actorActions[Cutscene_GetActorActionIndex(play, this->csActionCmd)]->action; + switch (csAction) { + default: + this->actor.draw = NULL; + this->step = 0; + break; + + case EFFLASTDAY_ACTION_2: + this->actor.draw = EffLastday_Draw; + this->step++; + break; + + case EFFLASTDAY_ACTION_3: + this->actor.draw = EffLastday_Draw; + break; + } + } else { + this->actor.draw = NULL; + } +} + +void func_80BEBF78(EffLastday* this, PlayState* play) { + u16 csAction; + + if (Cutscene_CheckActorAction(play, this->csActionCmd)) { + Cutscene_ActorTranslateAndYaw(&this->actor, play, Cutscene_GetActorActionIndex(play, this->csActionCmd)); + csAction = play->csCtx.actorActions[Cutscene_GetActorActionIndex(play, this->csActionCmd)]->action; + switch (csAction) { + default: + this->actor.draw = NULL; + this->alpha = 0; + this->step = 0; + break; + + case EFFLASTDAY_ACTION_2: + if (!this->actor.home.rot.z) { + this->actor.home.rot.z = true; + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_COMING_FIRE); + } + this->actor.draw = EffLastday_Draw; + if (this->alpha < 255) { + this->alpha += 5; + } + if (this->alpha > 255) { + this->alpha = 255; + } + this->step++; + break; + + case EFFLASTDAY_ACTION_3: + + this->actor.draw = EffLastday_Draw; + break; + } + } else { + this->actor.draw = NULL; + } +} + +void EffLastday_Update(Actor* thisx, PlayState* play) { + EffLastday* this = THIS; + + this->actionFunc(this, play); +} + +void EffLastday_SetVtxAlpha(s16 alpha) { + Vtx* vtx = Lib_SegmentedToVirtual(object_lastday_Vtx_000000); + + vtx[0].v.cn[3] = alpha; + vtx[3].v.cn[3] = alpha; + vtx[4].v.cn[3] = alpha; + vtx[5].v.cn[3] = alpha; +} + +void EffLastday_Draw(Actor* thisx, PlayState* play) { + EffLastday* this = THIS; + + OPEN_DISPS(play->state.gfxCtx); + + switch (EFFLASTDAY_GET_F(thisx)) { + case EFFLASTDAY_PARAMS_1: + case EFFLASTDAY_PARAMS_2: + break; + case EFFLASTDAY_PARAMS_3: + EffLastday_SetVtxAlpha(this->alpha); + break; + default: + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0x80, 255, 255, 170, this->alpha); + break; + } + AnimatedMat_DrawAlphaStep(play, this->matAnim, 1.0f, this->step); + Gfx_DrawDListXlu(play, this->dList); + + CLOSE_DISPS(play->state.gfxCtx); +} diff --git a/src/overlays/actors/ovl_Eff_Lastday/z_eff_lastday.h b/src/overlays/actors/ovl_Eff_Lastday/z_eff_lastday.h index 74ecf94fe..d1f81a184 100644 --- a/src/overlays/actors/ovl_Eff_Lastday/z_eff_lastday.h +++ b/src/overlays/actors/ovl_Eff_Lastday/z_eff_lastday.h @@ -3,16 +3,29 @@ #include "global.h" +#define EFFLASTDAY_GET_F(thisx) ((thisx)->params & 0xF) + struct EffLastday; -typedef void (*EffLastdayActionFunc)(struct EffLastday*, GlobalContext*); +typedef void (*EffLastdayActionFunc)(struct EffLastday*, PlayState*); typedef struct EffLastday { - /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x10]; - /* 0x0154 */ EffLastdayActionFunc actionFunc; + /* 0x000 */ Actor actor; + /* 0x144 */ Gfx* dList; + /* 0x148 */ AnimatedMaterial* matAnim; + /* 0x14C */ s16 step; + /* 0x14E */ s16 alpha; + /* 0x150 */ s16 csActionCmd; + /* 0x154 */ EffLastdayActionFunc actionFunc; } EffLastday; // size = 0x158 +typedef enum EffLastDayParams { + /* 0x0 */ EFFLASTDAY_PARAMS_0, + /* 0x1 */ EFFLASTDAY_PARAMS_1, + /* 0x2 */ EFFLASTDAY_PARAMS_2, + /* 0x3 */ EFFLASTDAY_PARAMS_3 +} EffLastDayParams; + extern const ActorInit Eff_Lastday_InitVars; #endif // Z_EFF_LASTDAY_H diff --git a/src/overlays/actors/ovl_Eff_Stk/z_eff_stk.c b/src/overlays/actors/ovl_Eff_Stk/z_eff_stk.c index b54bba577..778417139 100644 --- a/src/overlays/actors/ovl_Eff_Stk/z_eff_stk.c +++ b/src/overlays/actors/ovl_Eff_Stk/z_eff_stk.c @@ -10,10 +10,10 @@ #define THIS ((EffStk*)thisx) -void EffStk_Init(Actor* thisx, GlobalContext* globalCtx); -void EffStk_Destroy(Actor* thisx, GlobalContext* globalCtx); -void EffStk_Update(Actor* thisx, GlobalContext* globalCtx); -void EffStk_Draw(Actor* thisx, GlobalContext* globalCtx); +void EffStk_Init(Actor* thisx, PlayState* play); +void EffStk_Destroy(Actor* thisx, PlayState* play); +void EffStk_Update(Actor* thisx, PlayState* play); +void EffStk_Draw(Actor* thisx, PlayState* play); #if 0 const ActorInit Eff_Stk_InitVars = { diff --git a/src/overlays/actors/ovl_Eff_Stk/z_eff_stk.h b/src/overlays/actors/ovl_Eff_Stk/z_eff_stk.h index 518193375..9c8d5946e 100644 --- a/src/overlays/actors/ovl_Eff_Stk/z_eff_stk.h +++ b/src/overlays/actors/ovl_Eff_Stk/z_eff_stk.h @@ -5,12 +5,12 @@ struct EffStk; -typedef void (*EffStkActionFunc)(struct EffStk*, GlobalContext*); +typedef void (*EffStkActionFunc)(struct EffStk*, PlayState*); typedef struct EffStk { - /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x8]; - /* 0x014C */ EffStkActionFunc actionFunc; + /* 0x000 */ Actor actor; + /* 0x144 */ char unk_144[0x8]; + /* 0x14C */ EffStkActionFunc actionFunc; } EffStk; // size = 0x150 extern const ActorInit Eff_Stk_InitVars; diff --git a/src/overlays/actors/ovl_Eff_Zoraband/z_eff_zoraband.c b/src/overlays/actors/ovl_Eff_Zoraband/z_eff_zoraband.c index 8ed8c6db4..b566e5c62 100644 --- a/src/overlays/actors/ovl_Eff_Zoraband/z_eff_zoraband.c +++ b/src/overlays/actors/ovl_Eff_Zoraband/z_eff_zoraband.c @@ -5,19 +5,19 @@ */ #include "z_eff_zoraband.h" +#include "objects/object_zoraband/object_zoraband.h" #define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_20) #define THIS ((EffZoraband*)thisx) -void EffZoraband_Init(Actor* thisx, GlobalContext* globalCtx); -void EffZoraband_Destroy(Actor* thisx, GlobalContext* globalCtx); -void EffZoraband_Update(Actor* thisx, GlobalContext* globalCtx); -void EffZoraband_Draw(Actor* thisx, GlobalContext* globalCtx); +void EffZoraband_Init(Actor* thisx, PlayState* play); +void EffZoraband_Destroy(Actor* thisx, PlayState* play); +void EffZoraband_Update(Actor* thisx, PlayState* play); +void EffZoraband_Draw(Actor* thisx, PlayState* play2); -void func_80C07790(EffZoraband* this, GlobalContext* globalCtx); +void EffZoraband_MikauFadeOut(EffZoraband* this, PlayState* play); -#if 0 const ActorInit Eff_Zoraband_InitVars = { ACTOR_EFF_ZORABAND, ACTORCAT_ITEMACTION, @@ -30,16 +30,71 @@ const ActorInit Eff_Zoraband_InitVars = { (ActorFunc)EffZoraband_Draw, }; -#endif +void EffZoraband_Init(Actor* thisx, PlayState* play) { + EffZoraband* this = THIS; -extern UNK_TYPE D_06000F38; + Actor_SetScale(&this->actor, 1.0f); + this->actionFunc = EffZoraband_MikauFadeOut; + this->alpha = 0; + this->actor.shape.rot.z = 0; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Eff_Zoraband/EffZoraband_Init.s") +void EffZoraband_Destroy(Actor* thisx, PlayState* play) { +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Eff_Zoraband/EffZoraband_Destroy.s") +void EffZoraband_MikauFadeOut(EffZoraband* this, PlayState* play) { + if (Cutscene_CheckActorAction(play, 0x20F)) { + if ((EFFZORABAND_GET_F(&this->actor) + 2) == + play->csCtx.actorActions[Cutscene_GetActorActionIndex(play, 0x20F)]->action) { + this->stateFlags |= 2; + } + if (play->csCtx.actorActions[Cutscene_GetActorActionIndex(play, 0x20F)]->action == 7) { + this->actor.draw = NULL; + } else { + this->actor.draw = EffZoraband_Draw; + } + } + if ((this->actor.home.rot.z != 0) && (this->actor.draw != NULL)) { + func_800B9010(&this->actor, NA_SE_EV_UFO_LIGHT_BEAM - SFX_FLAG); + } + if (this->stateFlags & 2) { + if (this->alpha < 240) { + this->alpha += 25; + } else { + this->alpha = 255; + } + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Eff_Zoraband/func_80C07790.s") +void EffZoraband_Update(Actor* thisx, PlayState* play) { + EffZoraband* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Eff_Zoraband/EffZoraband_Update.s") + this->actionFunc(this, play); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Eff_Zoraband/EffZoraband_Draw.s") +void EffZoraband_Draw(Actor* thisx, PlayState* play2) { + PlayState* play = play2; + EffZoraband* this = THIS; + + if (this->alpha != 0) { + OPEN_DISPS(play->state.gfxCtx); + + func_8012C2DC(play->state.gfxCtx); + Matrix_RotateYS((Camera_GetCamDirYaw(GET_ACTIVE_CAM(play)) + 0x8000), MTXMODE_APPLY); + AnimatedMat_DrawXlu(play, Lib_SegmentedToVirtual(object_zoraband_Matanimheader_000F38)); + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + if (this->actor.home.rot.z != 0) { + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0x80, 255, 255, 100, this->alpha); + gDPSetEnvColor(POLY_XLU_DISP++, 255, 200, 0, 255); + } else { + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0x80, 0, 100, 255, this->alpha); + gDPSetEnvColor(POLY_XLU_DISP++, 0, 0, 100, 255); + } + gSPDisplayList(POLY_XLU_DISP++, object_zoraband_DL_000180); + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0xFF, 200, 255, 255, this->alpha); + gDPSetEnvColor(POLY_XLU_DISP++, 0, 100, 255, 255); + gSPDisplayList(POLY_XLU_DISP++, object_zoraband_DL_0002A8); + + CLOSE_DISPS(play->state.gfxCtx); + } +} diff --git a/src/overlays/actors/ovl_Eff_Zoraband/z_eff_zoraband.h b/src/overlays/actors/ovl_Eff_Zoraband/z_eff_zoraband.h index 6b1a5d666..2ecaf7187 100644 --- a/src/overlays/actors/ovl_Eff_Zoraband/z_eff_zoraband.h +++ b/src/overlays/actors/ovl_Eff_Zoraband/z_eff_zoraband.h @@ -3,14 +3,17 @@ #include "global.h" +#define EFFZORABAND_GET_F(thisx) ((thisx)->params & 0xF) + struct EffZoraband; -typedef void (*EffZorabandActionFunc)(struct EffZoraband*, GlobalContext*); +typedef void (*EffZorabandActionFunc)(struct EffZoraband*, PlayState*); typedef struct EffZoraband { - /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x4]; - /* 0x0148 */ EffZorabandActionFunc actionFunc; + /* 0x000 */ Actor actor; + /* 0x144 */ s16 alpha; + /* 0x146 */ u16 stateFlags; + /* 0x148 */ EffZorabandActionFunc actionFunc; } EffZoraband; // size = 0x14C extern const ActorInit Eff_Zoraband_InitVars; diff --git a/src/overlays/actors/ovl_Elf_Msg/z_elf_msg.c b/src/overlays/actors/ovl_Elf_Msg/z_elf_msg.c index 372a21d11..5d3905914 100644 --- a/src/overlays/actors/ovl_Elf_Msg/z_elf_msg.c +++ b/src/overlays/actors/ovl_Elf_Msg/z_elf_msg.c @@ -5,18 +5,19 @@ */ #include "z_elf_msg.h" +#include "overlays/actors/ovl_En_Elf/z_en_elf.h" #define FLAGS (ACTOR_FLAG_10) #define THIS ((ElfMsg*)thisx) -void ElfMsg_Init(Actor* thisx, GlobalContext* globalCtx); -void ElfMsg_Destroy(Actor* thisx, GlobalContext* globalCtx); -void ElfMsg_Update(Actor* thisx, GlobalContext* globalCtx); +void ElfMsg_Init(Actor* thisx, PlayState* play); +void ElfMsg_Destroy(Actor* thisx, PlayState* play); +void ElfMsg_Update(Actor* thisx, PlayState* play); void ElfMsg_SetupAction(ElfMsg* this, ElfMsgActionFunc actionFunc); +void func_8092E284(ElfMsg* this, PlayState* play); -#if 0 const ActorInit Elf_Msg_InitVars = { ACTOR_ELF_MSG, ACTORCAT_ITEMACTION, @@ -29,30 +30,119 @@ const ActorInit Elf_Msg_InitVars = { (ActorFunc)NULL, }; -// static InitChainEntry sInitChain[] = { -static InitChainEntry D_8092E470[] = { +static InitChainEntry sInitChain[] = { ICHAIN_VEC3F_DIV1000(scale, 1000, ICHAIN_CONTINUE), ICHAIN_F32(uncullZoneForward, 1000, ICHAIN_STOP), }; -#endif +void ElfMsg_SetupAction(ElfMsg* this, ElfMsgActionFunc actionFunc) { + this->actionFunc = actionFunc; +} -extern InitChainEntry D_8092E470[]; +s32 func_8092DF9C(ElfMsg* this, PlayState* play) { + if ((this->actor.home.rot.y > 0) && (this->actor.home.rot.y < 0x81) && + (Flags_GetSwitch(play, this->actor.home.rot.y - 1))) { + (void)"共倒れ"; // "Collapse together" + if (ELFMSG_GET_SWITCHFLAG(&this->actor) != 0x7F) { + Flags_SetSwitch(play, ELFMSG_GET_SWITCHFLAG(&this->actor)); + } + Actor_MarkForDeath(&this->actor); + return true; + } + if (this->actor.home.rot.y == 0x81) { + if (Flags_GetClear(play, this->actor.room)) { + if (ELFMSG_GET_SWITCHFLAG(&this->actor) != 0x7F) { + Flags_SetSwitch(play, ELFMSG_GET_SWITCHFLAG(&this->actor)); + } + Actor_MarkForDeath(&this->actor); + return true; + } + } + if (ELFMSG_GET_SWITCHFLAG(&this->actor) == 0x7F) { + return false; + } + if (Flags_GetSwitch(play, ELFMSG_GET_SWITCHFLAG(&this->actor))) { + (void)"共倒れ"; // "Collapse together" + Actor_MarkForDeath(&this->actor); + return true; + } + return false; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Elf_Msg/D_8092E480.s") +void ElfMsg_Init(Actor* thisx, PlayState* play) { + ElfMsg* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Elf_Msg/ElfMsg_SetupAction.s") + if (!func_8092DF9C(this, play)) { + Actor_ProcessInitChain(&this->actor, sInitChain); + if (ABS_ALT(this->actor.home.rot.x) == 0) { + this->actor.scale.x = this->actor.scale.z = 0.4f; + } else { + this->actor.scale.x = this->actor.scale.z = ABS_ALT(this->actor.home.rot.x) * 0.04f; + } + if (this->actor.home.rot.z == 0) { + this->actor.scale.y = 0.4f; + } else { + this->actor.scale.y = this->actor.home.rot.z * 0.04f; + } + ElfMsg_SetupAction(this, func_8092E284); + this->actor.shape.rot.x = this->actor.shape.rot.y = this->actor.shape.rot.z = 0; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Elf_Msg/func_8092DF9C.s") +void ElfMsg_Destroy(Actor* thisx, PlayState* play) { +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Elf_Msg/ElfMsg_Init.s") +s32 func_8092E1D0(ElfMsg* this) { + if (ELFMSG_GET_8000(&this->actor) != 0) { + return ELFMSG_GET_FF(&this->actor) + 0x200; + } else { + return -0x200 - ELFMSG_GET_FF(&this->actor); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Elf_Msg/ElfMsg_Destroy.s") +s32 func_8092E1FC(ElfMsg* this) { + return (this->actor.xzDistToPlayer < (100.0f * this->actor.scale.x)) && (this->actor.playerHeightRel >= 0.0f) && + (this->actor.playerHeightRel < (100.0f * this->actor.scale.y)); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Elf_Msg/func_8092E1D0.s") +void func_8092E284(ElfMsg* this, PlayState* play) { + Player* player = GET_PLAYER(play); + EnElf* tatl = (EnElf*)player->tatlActor; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Elf_Msg/func_8092E1FC.s") + if ((player->tatlActor != NULL) && ((func_8092E1FC(this)))) { + player->tatlTextId = func_8092E1D0(this); + ActorCutscene_SetIntentToPlay(0x7C); + tatl->elfMsg = &this->actor; + if (this->actor.cutscene == -1) { + this->actor.cutscene = 0x7C; + } + if ((player->tatlTextId < 0) && (this->actor.home.rot.x < 0)) { + if (ActorCutscene_GetCurrentIndex() == 0x7D) { + ActorCutscene_Stop(0x7D); + ActorCutscene_SetIntentToPlay(this->actor.cutscene); + } else if (ActorCutscene_GetCanPlayNext(this->actor.cutscene)) { + this->actor.home.rot.x = 0; + ActorCutscene_Start(this->actor.cutscene, &this->actor); + func_800E0348(play->cameraPtrs[CAM_ID_MAIN]); + } else { + ActorCutscene_SetIntentToPlay(this->actor.cutscene); + } + } + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Elf_Msg/func_8092E284.s") +void ElfMsg_Update(Actor* thisx, PlayState* play) { + ElfMsg* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Elf_Msg/ElfMsg_Update.s") + if (func_8092DF9C(this, play) == 0) { + if (Actor_ProcessTalkRequest(&this->actor, &play->state)) { + if (ELFMSG_GET_SWITCHFLAG(thisx) != 0x7F) { + Flags_SetSwitch(play, ELFMSG_GET_SWITCHFLAG(thisx)); + } + Actor_MarkForDeath(&this->actor); + } else if ((this->actor.home.rot.y >= 0) || (this->actor.home.rot.y < -0x80) || + (Flags_GetSwitch(play, -1 - this->actor.home.rot.y))) { + this->actionFunc(this, play); + } + } +} diff --git a/src/overlays/actors/ovl_Elf_Msg/z_elf_msg.h b/src/overlays/actors/ovl_Elf_Msg/z_elf_msg.h index 7d46680bd..f335f0158 100644 --- a/src/overlays/actors/ovl_Elf_Msg/z_elf_msg.h +++ b/src/overlays/actors/ovl_Elf_Msg/z_elf_msg.h @@ -3,13 +3,17 @@ #include "global.h" +#define ELFMSG_GET_FF(thisx) ((thisx)->params & 0xFF) +#define ELFMSG_GET_SWITCHFLAG(thisx) (((thisx)->params & 0x7F00) >> 8) +#define ELFMSG_GET_8000(thisx) ((thisx)->params & 0x8000) + struct ElfMsg; -typedef void (*ElfMsgActionFunc)(struct ElfMsg*, GlobalContext*); +typedef void (*ElfMsgActionFunc)(struct ElfMsg*, PlayState*); typedef struct ElfMsg { - /* 0x0000 */ Actor actor; - /* 0x0144 */ ElfMsgActionFunc actionFunc; + /* 0x000 */ Actor actor; + /* 0x144 */ ElfMsgActionFunc actionFunc; } ElfMsg; // size = 0x148 extern const ActorInit Elf_Msg_InitVars; diff --git a/src/overlays/actors/ovl_Elf_Msg2/z_elf_msg2.c b/src/overlays/actors/ovl_Elf_Msg2/z_elf_msg2.c index 5397ca5d6..6e78ef085 100644 --- a/src/overlays/actors/ovl_Elf_Msg2/z_elf_msg2.c +++ b/src/overlays/actors/ovl_Elf_Msg2/z_elf_msg2.c @@ -10,15 +10,14 @@ #define THIS ((ElfMsg2*)thisx) -void ElfMsg2_Init(Actor* thisx, GlobalContext* globalCtx); -void ElfMsg2_Destroy(Actor* thisx, GlobalContext* globalCtx); -void ElfMsg2_Update(Actor* thisx, GlobalContext* globalCtx); +void ElfMsg2_Init(Actor* thisx, PlayState* play); +void ElfMsg2_Destroy(Actor* thisx, PlayState* play); +void ElfMsg2_Update(Actor* thisx, PlayState* play); -void func_8096EFD0(ElfMsg2* this, GlobalContext* globalCtx); +s32 func_8096EE50(ElfMsg2* this); +void func_8096EF98(ElfMsg2* this, PlayState* play); +void func_8096EFD0(ElfMsg2* this, PlayState* play); -void ElfMsg2_SetupAction(ElfMsg2* this, ElfMsg2ActionFunc actionFunc); - -#if 0 const ActorInit Elf_Msg2_InitVars = { ACTOR_ELF_MSG2, ACTORCAT_BG, @@ -31,32 +30,120 @@ const ActorInit Elf_Msg2_InitVars = { (ActorFunc)NULL, }; -// static InitChainEntry sInitChain[] = { -static InitChainEntry D_8096F0B0[] = { +static InitChainEntry sInitChain[] = { ICHAIN_VEC3F_DIV1000(scale, 200, ICHAIN_CONTINUE), ICHAIN_F32(uncullZoneForward, 1000, ICHAIN_STOP), }; -#endif +void ElfMsg2_SetupAction(ElfMsg2* this, ElfMsg2ActionFunc actionFunc) { + this->actionFunc = actionFunc; +} -extern InitChainEntry D_8096F0B0[]; +s32 func_8096EC4C(ElfMsg2* this, PlayState* play) { + if ((this->actor.home.rot.y > 0) && (this->actor.home.rot.y < 0x81) && + (Flags_GetSwitch(play, this->actor.home.rot.y - 1))) { + (void)"共倒れ"; // "Collapse together" + if (ELFMSG2_GET_SWITCHFLAG(&this->actor) != 0x7F) { + Flags_SetSwitch(play, ELFMSG2_GET_SWITCHFLAG(&this->actor)); + } + Actor_MarkForDeath(&this->actor); + return true; + } + if (this->actor.home.rot.y == 129) { -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Elf_Msg2/D_8096F0C0.s") + if (Flags_GetClear(play, this->actor.room)) { + (void)"共倒れ2"; // "Collapse 2" + if (ELFMSG2_GET_SWITCHFLAG(&this->actor) != 0x7F) { + Flags_SetSwitch(play, ELFMSG2_GET_SWITCHFLAG(&this->actor)); + } + Actor_MarkForDeath(&this->actor); + return true; + } + } + if (ELFMSG2_GET_SWITCHFLAG(&this->actor) == 0x7F) { + return false; + } + if (Flags_GetSwitch(play, ELFMSG2_GET_SWITCHFLAG(&this->actor))) { + (void)"共倒れ"; // "Collapse together" + Actor_MarkForDeath(&this->actor); + return true; + } + return false; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Elf_Msg2/ElfMsg2_SetupAction.s") +void ElfMsg2_Init(Actor* thisx, PlayState* play) { + ElfMsg2* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Elf_Msg2/func_8096EC4C.s") + if (!func_8096EC4C(this, play)) { + if ((this->actor.home.rot.x > 0) && (this->actor.home.rot.x < 8)) { + this->actor.targetMode = this->actor.home.rot.x - 1; + } + Actor_ProcessInitChain(&this->actor, sInitChain); + if (this->actor.home.rot.y < 0) { + ElfMsg2_SetupAction(this, func_8096EFD0); + } else { + ElfMsg2_SetupAction(this, func_8096EF98); + this->actor.flags |= (ACTOR_FLAG_40000 | ACTOR_FLAG_1); + this->actor.textId = func_8096EE50(this); + } + this->actor.shape.rot.z = 0; + this->actor.shape.rot.x = this->actor.shape.rot.y = this->actor.shape.rot.z; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Elf_Msg2/ElfMsg2_Init.s") +void ElfMsg2_Destroy(Actor* thisx, PlayState* play) { +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Elf_Msg2/ElfMsg2_Destroy.s") +s32 func_8096EE50(ElfMsg2* this) { + return ELFMSG2_GET_FF(&this->actor) + 0x200; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Elf_Msg2/func_8096EE50.s") +void func_8096EE64(ElfMsg2* this, PlayState* play) { + if (Actor_TextboxIsClosing(&this->actor, play)) { + if (this->actor.cutscene != -1) { + if (ActorCutscene_GetCurrentIndex() == this->actor.cutscene) { + ActorCutscene_Stop(this->actor.cutscene); + } + } + if (this->actor.home.rot.z != 1) { + Actor_MarkForDeath(&this->actor); + if (ELFMSG2_GET_SWITCHFLAG(&this->actor) != 0x7F) { + Flags_SetSwitch(play, ELFMSG2_GET_SWITCHFLAG(&this->actor)); + } + } else { + ElfMsg2_SetupAction(this, func_8096EF98); + } + } else if ((this->actor.cutscene != -1) && (ActorCutscene_GetCurrentIndex() != this->actor.cutscene)) { + if (ActorCutscene_GetCurrentIndex() == 0x7C) { + ActorCutscene_Stop(0x7C); + ActorCutscene_SetIntentToPlay(this->actor.cutscene); + } else if (ActorCutscene_GetCanPlayNext(this->actor.cutscene)) { + ActorCutscene_Start(this->actor.cutscene, &this->actor); + } else { + ActorCutscene_SetIntentToPlay(this->actor.cutscene); + } + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Elf_Msg2/func_8096EE64.s") +void func_8096EF98(ElfMsg2* this, PlayState* play) { + if (Actor_ProcessTalkRequest(&this->actor, &play->state)) { + ElfMsg2_SetupAction(this, func_8096EE64); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Elf_Msg2/func_8096EF98.s") +void func_8096EFD0(ElfMsg2* this, PlayState* play) { + if ((this->actor.home.rot.y < 0) && (this->actor.home.rot.y >= -0x80) && + (Flags_GetSwitch(play, -this->actor.home.rot.y - 1))) { + ElfMsg2_SetupAction(this, func_8096EF98); + this->actor.flags |= (ACTOR_FLAG_40000 | ACTOR_FLAG_1); + this->actor.textId = func_8096EE50(this); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Elf_Msg2/func_8096EFD0.s") +void ElfMsg2_Update(Actor* thisx, PlayState* play) { + ElfMsg2* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Elf_Msg2/ElfMsg2_Update.s") + if (!func_8096EC4C(this, play)) { + this->actionFunc(this, play); + } +} diff --git a/src/overlays/actors/ovl_Elf_Msg2/z_elf_msg2.h b/src/overlays/actors/ovl_Elf_Msg2/z_elf_msg2.h index 9429df0b5..e8b48dfd7 100644 --- a/src/overlays/actors/ovl_Elf_Msg2/z_elf_msg2.h +++ b/src/overlays/actors/ovl_Elf_Msg2/z_elf_msg2.h @@ -3,13 +3,16 @@ #include "global.h" +#define ELFMSG2_GET_SWITCHFLAG(thisx) (((thisx)->params >> 8) & 0x7F) +#define ELFMSG2_GET_FF(thisx) ((thisx)->params & 0xFF) + struct ElfMsg2; -typedef void (*ElfMsg2ActionFunc)(struct ElfMsg2*, GlobalContext*); +typedef void (*ElfMsg2ActionFunc)(struct ElfMsg2*, PlayState*); typedef struct ElfMsg2 { - /* 0x0000 */ Actor actor; - /* 0x0144 */ ElfMsg2ActionFunc actionFunc; + /* 0x000 */ Actor actor; + /* 0x144 */ ElfMsg2ActionFunc actionFunc; } ElfMsg2; // size = 0x148 extern const ActorInit Elf_Msg2_InitVars; diff --git a/src/overlays/actors/ovl_Elf_Msg3/z_elf_msg3.c b/src/overlays/actors/ovl_Elf_Msg3/z_elf_msg3.c index dc0e5eb72..a62a22ad0 100644 --- a/src/overlays/actors/ovl_Elf_Msg3/z_elf_msg3.c +++ b/src/overlays/actors/ovl_Elf_Msg3/z_elf_msg3.c @@ -5,18 +5,18 @@ */ #include "z_elf_msg3.h" +#include "overlays/actors/ovl_En_Elf/z_en_elf.h" #define FLAGS (ACTOR_FLAG_10) #define THIS ((ElfMsg3*)thisx) -void ElfMsg3_Init(Actor* thisx, GlobalContext* globalCtx); -void ElfMsg3_Destroy(Actor* thisx, GlobalContext* globalCtx); -void ElfMsg3_Update(Actor* thisx, GlobalContext* globalCtx); +void ElfMsg3_Init(Actor* thisx, PlayState* play); +void ElfMsg3_Destroy(Actor* thisx, PlayState* play); +void ElfMsg3_Update(Actor* thisx, PlayState* play); -void ElfMsg3_SetupAction(ElfMsg3* this, ElfMsg3ActionFunc actionFunc); +void func_80A2CF7C(ElfMsg3* this, PlayState* play); -#if 0 const ActorInit Elf_Msg3_InitVars = { ACTOR_ELF_MSG3, ACTORCAT_ITEMACTION, @@ -29,28 +29,118 @@ const ActorInit Elf_Msg3_InitVars = { (ActorFunc)NULL, }; -// static InitChainEntry sInitChain[] = { -static InitChainEntry D_80A2D1E0[] = { +static InitChainEntry sInitChain[] = { ICHAIN_VEC3F_DIV1000(scale, 1000, ICHAIN_CONTINUE), ICHAIN_F32(uncullZoneForward, 1000, ICHAIN_STOP), }; -#endif +void ElfMsg3_SetupAction(ElfMsg3* this, ElfMsg3ActionFunc actionFunc) { + this->actionFunc = actionFunc; +} -extern InitChainEntry D_80A2D1E0[]; +s32 func_80A2CD1C(ElfMsg3* this, PlayState* play) { + if ((this->actor.home.rot.y > 0) && (this->actor.home.rot.y < 0x81) && + (Flags_GetSwitch(play, this->actor.home.rot.y - 1))) { + (void)"共倒れ"; // "Collapse together" + if (ELFMSG3_GET_SWITCH(&this->actor) != 0x7F) { + Flags_SetSwitch(play, ELFMSG3_GET_SWITCH(&this->actor)); + } + Actor_MarkForDeath(&this->actor); + return true; + } + if (this->actor.home.rot.y == 0x81) { + if (Flags_GetClear(play, this->actor.room)) { + if (ELFMSG3_GET_SWITCH(&this->actor) != 0x7F) { + Flags_SetSwitch(play, ELFMSG3_GET_SWITCH(&this->actor)); + } + Actor_MarkForDeath(&this->actor); + return true; + } + } + if (ELFMSG3_GET_SWITCH(&this->actor) == 0x7F) { + return false; + } + if (Flags_GetSwitch(play, ELFMSG3_GET_SWITCH(&this->actor))) { + (void)"共倒れ"; // "Collapse together" + Actor_MarkForDeath(&this->actor); + return true; + } + return false; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Elf_Msg3/D_80A2D1F0.s") +void ElfMsg3_Init(Actor* thisx, PlayState* play) { + ElfMsg3* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Elf_Msg3/ElfMsg3_SetupAction.s") + if (!func_80A2CD1C(this, play)) { + Actor_ProcessInitChain(&this->actor, sInitChain); + if (ABS_ALT(this->actor.home.rot.x) == 0) { + this->actor.scale.z = 0.4f; + this->actor.scale.x = 0.4f; + } else { + this->actor.scale.x = this->actor.scale.z = ABS_ALT(this->actor.home.rot.x) * 0.04f; + } + if (this->actor.home.rot.z == 0) { + this->actor.scale.y = 0.4f; + } else { + this->actor.scale.y = this->actor.home.rot.z * 0.04f; + } + ElfMsg3_SetupAction(this, func_80A2CF7C); + this->actor.shape.rot.x = this->actor.shape.rot.y = this->actor.shape.rot.z = 0; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Elf_Msg3/func_80A2CD1C.s") +void ElfMsg3_Destroy(Actor* thisx, PlayState* play) { +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Elf_Msg3/ElfMsg3_Init.s") +s32 func_80A2CF50(ElfMsg3* this) { + if (ELFMSG3_GET_8000(&this->actor) != 0) { + return ELFMSG3_GET_FF(&this->actor) + 0x200; + } else { + return -0x200 - ELFMSG3_GET_FF(&this->actor); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Elf_Msg3/ElfMsg3_Destroy.s") +void func_80A2CF7C(ElfMsg3* this, PlayState* play) { + Player* player = GET_PLAYER(play); + EnElf* tatl = (EnElf*)player->tatlActor; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Elf_Msg3/func_80A2CF50.s") + if (((((player->tatlActor != NULL) && + (fabsf(player->actor.world.pos.x - this->actor.world.pos.x) < (100.0f * this->actor.scale.x))) && + (this->actor.world.pos.y <= player->actor.world.pos.y)) && + ((player->actor.world.pos.y - this->actor.world.pos.y) < (100.0f * this->actor.scale.y))) && + (fabsf(player->actor.world.pos.z - this->actor.world.pos.z) < (100.0f * this->actor.scale.z))) { + player->tatlTextId = func_80A2CF50(this); + ActorCutscene_SetIntentToPlay(0x7C); + tatl->elfMsg = &this->actor; + if (this->actor.cutscene == -1) { + this->actor.cutscene = 0x7C; + } + if ((player->tatlTextId < 0) && (this->actor.home.rot.x < 0)) { + if (ActorCutscene_GetCurrentIndex() == 0x7D) { + ActorCutscene_Stop(0x7D); + ActorCutscene_SetIntentToPlay(this->actor.cutscene); + } else if (ActorCutscene_GetCanPlayNext(this->actor.cutscene)) { + ActorCutscene_Start(this->actor.cutscene, &this->actor); + func_800E0348(play->cameraPtrs[CAM_ID_MAIN]); + } else { + ActorCutscene_SetIntentToPlay(this->actor.cutscene); + } + } + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Elf_Msg3/func_80A2CF7C.s") +void ElfMsg3_Update(Actor* thisx, PlayState* play) { + ElfMsg3* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Elf_Msg3/ElfMsg3_Update.s") + if (!func_80A2CD1C(this, play)) { + if (Actor_ProcessTalkRequest(&this->actor, &play->state)) { + if (ELFMSG3_GET_SWITCH(thisx) != 0x7F) { + Flags_SetSwitch(play, ELFMSG3_GET_SWITCH(thisx)); + } + Actor_MarkForDeath(&this->actor); + } else if ((this->actor.home.rot.y >= 0) || (this->actor.home.rot.y < -0x80) || + (Flags_GetSwitch(play, -1 - this->actor.home.rot.y))) { + this->actionFunc(this, play); + } + } +} diff --git a/src/overlays/actors/ovl_Elf_Msg3/z_elf_msg3.h b/src/overlays/actors/ovl_Elf_Msg3/z_elf_msg3.h index 409847755..cb71166e8 100644 --- a/src/overlays/actors/ovl_Elf_Msg3/z_elf_msg3.h +++ b/src/overlays/actors/ovl_Elf_Msg3/z_elf_msg3.h @@ -3,13 +3,17 @@ #include "global.h" +#define ELFMSG3_GET_SWITCH(thisx) (((thisx)->params & 0x7F00) >> 8) +#define ELFMSG3_GET_FF(thisx) ((thisx)->params & 0xFF) +#define ELFMSG3_GET_8000(thisx) ((thisx)->params & 0x8000) + struct ElfMsg3; -typedef void (*ElfMsg3ActionFunc)(struct ElfMsg3*, GlobalContext*); +typedef void (*ElfMsg3ActionFunc)(struct ElfMsg3*, PlayState*); typedef struct ElfMsg3 { - /* 0x0000 */ Actor actor; - /* 0x0144 */ ElfMsg3ActionFunc actionFunc; + /* 0x000 */ Actor actor; + /* 0x144 */ ElfMsg3ActionFunc actionFunc; } ElfMsg3; // size = 0x148 extern const ActorInit Elf_Msg3_InitVars; diff --git a/src/overlays/actors/ovl_Elf_Msg4/z_elf_msg4.c b/src/overlays/actors/ovl_Elf_Msg4/z_elf_msg4.c index ca7981362..4c6f143ff 100644 --- a/src/overlays/actors/ovl_Elf_Msg4/z_elf_msg4.c +++ b/src/overlays/actors/ovl_Elf_Msg4/z_elf_msg4.c @@ -5,19 +5,23 @@ */ #include "z_elf_msg4.h" +#include "overlays/actors/ovl_En_Elf/z_en_elf.h" +#include "overlays/actors/ovl_Elf_Msg5/z_elf_msg5.h" #define FLAGS (ACTOR_FLAG_10) #define THIS ((ElfMsg4*)thisx) -void ElfMsg4_Init(Actor* thisx, GlobalContext* globalCtx); -void ElfMsg4_Destroy(Actor* thisx, GlobalContext* globalCtx); -void ElfMsg4_Update(Actor* thisx, GlobalContext* globalCtx); +void ElfMsg4_Init(Actor* thisx, PlayState* play); +void ElfMsg4_Destroy(Actor* thisx, PlayState* play); +void ElfMsg4_Update(Actor* thisx, PlayState* play); -void func_80AFD668(ElfMsg4* this, GlobalContext* globalCtx); -void func_80AFD770(ElfMsg4* this, GlobalContext* globalCtx); +void func_80AFD668(ElfMsg4* this, PlayState* play); +void func_80AFD770(ElfMsg4* this, PlayState* play); +s32 func_80AFD380(ElfMsg4* this, PlayState* play); +s32 ElfMsg4_GetTextId(ElfMsg4* this); +s32 func_80AFD5E0(ElfMsg4* this); -#if 0 const ActorInit Elf_Msg4_InitVars = { ACTOR_ELF_MSG4, ACTORCAT_ITEMACTION, @@ -30,30 +34,137 @@ const ActorInit Elf_Msg4_InitVars = { (ActorFunc)NULL, }; -// static InitChainEntry sInitChain[] = { -static InitChainEntry D_80AFD8F0[] = { +static InitChainEntry sInitChain[] = { ICHAIN_VEC3F_DIV1000(scale, 1000, ICHAIN_CONTINUE), ICHAIN_F32(uncullZoneForward, 1000, ICHAIN_STOP), }; -#endif +s32 func_80AFD380(ElfMsg4* this, PlayState* play) { + if ((this->actor.home.rot.y > 0) && (this->actor.home.rot.y < 0x81) && + (Flags_GetSwitch(play, this->actor.home.rot.y - 1))) { + (void)"共倒れ"; // "Collapse together" + if (ELFMSG4_GET_SWITCHFLAG(&this->actor) != 0x7F) { + Flags_SetSwitch(play, ELFMSG4_GET_SWITCHFLAG(&this->actor)); + } + Actor_MarkForDeath(&this->actor); + return true; + } + if (this->actor.home.rot.y == 0x81) { + if (Flags_GetClear(play, this->actor.room)) { + if (ELFMSG4_GET_SWITCHFLAG(&this->actor) != 0x7F) { + Flags_SetSwitch(play, ELFMSG4_GET_SWITCHFLAG(&this->actor)); + } + Actor_MarkForDeath(&this->actor); + return true; + } + } + if (ELFMSG4_GET_SWITCHFLAG(&this->actor) == 0x7F) { + return false; + } + if (Flags_GetSwitch(play, ELFMSG4_GET_SWITCHFLAG(&this->actor))) { + (void)"共倒れ"; // "Collapse together" + Actor_MarkForDeath(&this->actor); + return true; + } + return false; +} -extern InitChainEntry D_80AFD8F0[]; +void ElfMsg4_Init(Actor* thisx, PlayState* play) { + ElfMsg4* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Elf_Msg4/D_80AFD900.s") + if (!func_80AFD380(this, play)) { + Actor_ProcessInitChain(&this->actor, sInitChain); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Elf_Msg4/func_80AFD380.s") + if (ABS_ALT(this->actor.home.rot.x) == 0) { + this->actor.scale.z = 0.4f; + this->actor.scale.x = 0.4f; + } else { + this->actor.scale.x = this->actor.scale.z = ABS_ALT(this->actor.home.rot.x) * 0.04f; + } + if (this->actor.home.rot.z == 0) { + this->actor.scale.y = 0.4f; + } else { + this->actor.scale.y = this->actor.home.rot.z * 0.04f; + } + this->actor.shape.rot.z = 0; + this->actionFunc = func_80AFD770; + this->elfMsg5 = NULL; + this->actor.shape.rot.x = this->actor.shape.rot.y = this->actor.shape.rot.z; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Elf_Msg4/ElfMsg4_Init.s") +void ElfMsg4_Destroy(Actor* thisx, PlayState* play) { +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Elf_Msg4/ElfMsg4_Destroy.s") +s32 ElfMsg4_GetTextId(ElfMsg4* this) { + if (ELFMSG4_GET_8000(&this->actor) != 0) { + return ELFMSG4_GET_TEXT(&this->actor) + 0x200; + } else { + return -ELFMSG4_GET_TEXT(&this->actor) - 0x200; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Elf_Msg4/func_80AFD5B4.s") +s32 func_80AFD5E0(ElfMsg4* this) { + return (this->actor.xzDistToPlayer < (100.0f * this->actor.scale.x)) && (this->actor.playerHeightRel >= 0.0f) && + (this->actor.playerHeightRel < (100.0f * this->actor.scale.y)); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Elf_Msg4/func_80AFD5E0.s") +void func_80AFD668(ElfMsg4* this, PlayState* play) { + Player* player = GET_PLAYER(play); + EnElf* tatl = (EnElf*)player->tatlActor; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Elf_Msg4/func_80AFD668.s") + if ((player->tatlActor != NULL) && func_80AFD5E0(this)) { + player->tatlTextId = ElfMsg4_GetTextId(this); + ActorCutscene_SetIntentToPlay(0x7C); + tatl->elfMsg = this->elfMsg5; + if (this->actor.cutscene == -1) { + this->actor.cutscene = 0x7C; + } + if ((player->tatlTextId < 0) && (this->actor.home.rot.x < 0)) { + if (ActorCutscene_GetCurrentIndex() == 0x7D) { + ActorCutscene_Stop(0x7D); + ActorCutscene_SetIntentToPlay((s16)this->actor.cutscene); + } else if (ActorCutscene_GetCanPlayNext((s16)this->actor.cutscene)) { + ActorCutscene_Start(this->actor.cutscene, &this->actor); + func_800E0348(play->cameraPtrs[CAM_ID_MAIN]); + } else { + ActorCutscene_SetIntentToPlay((s16)this->actor.cutscene); + } + } + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Elf_Msg4/func_80AFD770.s") +void func_80AFD770(ElfMsg4* this, PlayState* play) { + Actor* bgActor = play->actorCtx.actorLists[ACTORCAT_BG].first; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Elf_Msg4/ElfMsg4_Update.s") + while (bgActor != NULL) { + if ((bgActor->id != ACTOR_ELF_MSG5) || (ELFMSG4_GET_TEXT(&this->actor) != ELFMSG5_GET_FF(bgActor)) || + (this->actor.cutscene != bgActor->cutscene)) { + bgActor = bgActor->next; + } else { + this->elfMsg5 = bgActor; + this->actionFunc = func_80AFD668; + bgActor = bgActor->next; + } + } +} + +void ElfMsg4_Update(Actor* thisx, PlayState* play) { + Actor* bgActor; + ElfMsg4* this = THIS; + + if (!func_80AFD380(this, play)) { + bgActor = this->elfMsg5; + if ((bgActor != NULL) && (bgActor->update == NULL)) { + Actor_MarkForDeath(&this->actor); + } else if ((bgActor != NULL) && (Actor_ProcessTalkRequest(bgActor, &play->state))) { + if (ELFMSG4_GET_SWITCHFLAG(thisx) != 0x7F) { + Flags_SetSwitch(play, ELFMSG4_GET_SWITCHFLAG(thisx)); + } + Actor_MarkForDeath(&this->actor); + } else if ((this->actor.home.rot.y >= 0) || (this->actor.home.rot.y < -0x80) || + (Flags_GetSwitch(play, -1 - this->actor.home.rot.y))) { + this->actionFunc(this, play); + } + } +} diff --git a/src/overlays/actors/ovl_Elf_Msg4/z_elf_msg4.h b/src/overlays/actors/ovl_Elf_Msg4/z_elf_msg4.h index ae1485708..f3d523ba4 100644 --- a/src/overlays/actors/ovl_Elf_Msg4/z_elf_msg4.h +++ b/src/overlays/actors/ovl_Elf_Msg4/z_elf_msg4.h @@ -3,14 +3,18 @@ #include "global.h" +#define ELFMSG4_GET_SWITCHFLAG(thisx) (((thisx)->params & 0x7F00) >> 8) +#define ELFMSG4_GET_8000(thisx) ((thisx)->params & 0x8000) +#define ELFMSG4_GET_TEXT(thisx) ((thisx)->params & 0xFF) + struct ElfMsg4; -typedef void (*ElfMsg4ActionFunc)(struct ElfMsg4*, GlobalContext*); +typedef void (*ElfMsg4ActionFunc)(struct ElfMsg4*, PlayState*); typedef struct ElfMsg4 { - /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x4]; - /* 0x0148 */ ElfMsg4ActionFunc actionFunc; + /* 0x000 */ Actor actor; + /* 0x144 */ Actor* elfMsg5; + /* 0x148 */ ElfMsg4ActionFunc actionFunc; } ElfMsg4; // size = 0x14C extern const ActorInit Elf_Msg4_InitVars; diff --git a/src/overlays/actors/ovl_Elf_Msg5/z_elf_msg5.c b/src/overlays/actors/ovl_Elf_Msg5/z_elf_msg5.c index aceb36807..bcc88ad5d 100644 --- a/src/overlays/actors/ovl_Elf_Msg5/z_elf_msg5.c +++ b/src/overlays/actors/ovl_Elf_Msg5/z_elf_msg5.c @@ -10,13 +10,13 @@ #define THIS ((ElfMsg5*)thisx) -void ElfMsg5_Init(Actor* thisx, GlobalContext* globalCtx); -void ElfMsg5_Destroy(Actor* thisx, GlobalContext* globalCtx); -void ElfMsg5_Update(Actor* thisx, GlobalContext* globalCtx); +void ElfMsg5_Init(Actor* thisx, PlayState* play); +void ElfMsg5_Destroy(Actor* thisx, PlayState* play); +void ElfMsg5_Update(Actor* thisx, PlayState* play); -void func_80AFDB38(ElfMsg5* this, GlobalContext* globalCtx); +void func_80AFDB38(ElfMsg5* this, PlayState* play); +s32 func_80AFD990(ElfMsg5* this, PlayState* play); -#if 0 const ActorInit Elf_Msg5_InitVars = { ACTOR_ELF_MSG5, ACTORCAT_BG, @@ -29,24 +29,65 @@ const ActorInit Elf_Msg5_InitVars = { (ActorFunc)NULL, }; -// static InitChainEntry sInitChain[] = { -static InitChainEntry D_80AFDBD0[] = { +static InitChainEntry sInitChainsInitChain[] = { ICHAIN_VEC3F_DIV1000(scale, 200, ICHAIN_CONTINUE), ICHAIN_F32(uncullZoneForward, 1000, ICHAIN_STOP), }; -#endif +s32 func_80AFD990(ElfMsg5* this, PlayState* play) { + if ((this->actor.home.rot.y > 0) && (this->actor.home.rot.y < 0x81) && + (Flags_GetSwitch(play, this->actor.home.rot.y - 1))) { + (void)"共倒れ"; // Collapse together + if (ELFMSG5_GET_SWITCHFLAG(&this->actor) != 0x7F) { + Flags_SetSwitch(play, ELFMSG5_GET_SWITCHFLAG(&this->actor)); + } + Actor_MarkForDeath(&this->actor); + return true; + } + if (this->actor.home.rot.y == 0x81) { + if (Flags_GetClear(play, this->actor.room)) { + (void)"共倒れ2"; // Collapse 2 + if (ELFMSG5_GET_SWITCHFLAG(&this->actor) != 0x7F) { + Flags_SetSwitch(play, ELFMSG5_GET_SWITCHFLAG(&this->actor)); + } + Actor_MarkForDeath(&this->actor); + return true; + } + } + if (ELFMSG5_GET_SWITCHFLAG(&this->actor) == 0x7F) { + return false; + } + if (Flags_GetSwitch(play, ELFMSG5_GET_SWITCHFLAG(&this->actor))) { + (void)"共倒れ"; // Collapse together + Actor_MarkForDeath(&this->actor); + return true; + } + return false; +} -extern InitChainEntry D_80AFDBD0[]; +void ElfMsg5_Init(Actor* thisx, PlayState* play) { + ElfMsg5* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Elf_Msg5/D_80AFDBE0.s") + if (!func_80AFD990(this, play)) { + Actor_ProcessInitChain(&this->actor, sInitChainsInitChain); + this->actor.shape.rot.z = 0; + this->actionFunc = func_80AFDB38; + this->actor.home.rot.x = -0x961; + this->actor.shape.rot.x = this->actor.shape.rot.y = this->actor.shape.rot.z; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Elf_Msg5/func_80AFD990.s") +void ElfMsg5_Destroy(Actor* thisx, PlayState* play) { +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Elf_Msg5/ElfMsg5_Init.s") +void func_80AFDB38(ElfMsg5* this, PlayState* play) { +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Elf_Msg5/ElfMsg5_Destroy.s") +void ElfMsg5_Update(Actor* thisx, PlayState* play) { + ElfMsg5* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Elf_Msg5/func_80AFDB38.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Elf_Msg5/ElfMsg5_Update.s") + if ((this->actor.home.rot.y >= 0) || (this->actor.home.rot.y < -0x80) || + (Flags_GetSwitch(play, -this->actor.home.rot.y - 1))) { + this->actionFunc(this, play); + } +} diff --git a/src/overlays/actors/ovl_Elf_Msg5/z_elf_msg5.h b/src/overlays/actors/ovl_Elf_Msg5/z_elf_msg5.h index f2cff67a7..af2589434 100644 --- a/src/overlays/actors/ovl_Elf_Msg5/z_elf_msg5.h +++ b/src/overlays/actors/ovl_Elf_Msg5/z_elf_msg5.h @@ -3,13 +3,16 @@ #include "global.h" +#define ELFMSG5_GET_SWITCHFLAG(thisx) (((thisx)->params >> 8) & 0x7F) +#define ELFMSG5_GET_FF(thisx) ((thisx)->params & 0xFF) + struct ElfMsg5; -typedef void (*ElfMsg5ActionFunc)(struct ElfMsg5*, GlobalContext*); +typedef void (*ElfMsg5ActionFunc)(struct ElfMsg5*, PlayState*); typedef struct ElfMsg5 { - /* 0x0000 */ Actor actor; - /* 0x0144 */ ElfMsg5ActionFunc actionFunc; + /* 0x000 */ Actor actor; + /* 0x144 */ ElfMsg5ActionFunc actionFunc; } ElfMsg5; // size = 0x148 extern const ActorInit Elf_Msg5_InitVars; diff --git a/src/overlays/actors/ovl_Elf_Msg6/z_elf_msg6.c b/src/overlays/actors/ovl_Elf_Msg6/z_elf_msg6.c index 68c22f2d1..e8c874df4 100644 --- a/src/overlays/actors/ovl_Elf_Msg6/z_elf_msg6.c +++ b/src/overlays/actors/ovl_Elf_Msg6/z_elf_msg6.c @@ -11,17 +11,17 @@ #define THIS ((ElfMsg6*)thisx) -void ElfMsg6_Init(Actor* thisx, GlobalContext* globalCtx); -void ElfMsg6_Destroy(Actor* thisx, GlobalContext* globalCtx); -void ElfMsg6_Update(Actor* thisx, GlobalContext* globalCtx); +void ElfMsg6_Init(Actor* thisx, PlayState* play); +void ElfMsg6_Destroy(Actor* thisx, PlayState* play); +void ElfMsg6_Update(Actor* thisx, PlayState* play); -void func_80BA1CF8(ElfMsg6* this, GlobalContext* globalCtx); -void func_80BA1E30(ElfMsg6* this, GlobalContext* globalCtx); -void func_80BA1F80(ElfMsg6* this, GlobalContext* globalCtx); -void func_80BA2038(ElfMsg6* this, GlobalContext* globalCtx); -void func_80BA2048(ElfMsg6* this, GlobalContext* globalCtx); -void func_80BA215C(ElfMsg6* this, GlobalContext* globalCtx); -void func_80BA21C4(ElfMsg6* this, GlobalContext* globalCtx); +void func_80BA1CF8(ElfMsg6* this, PlayState* play); +void func_80BA1E30(ElfMsg6* this, PlayState* play); +void func_80BA1F80(ElfMsg6* this, PlayState* play); +void func_80BA2038(ElfMsg6* this, PlayState* play); +void func_80BA2048(ElfMsg6* this, PlayState* play); +void func_80BA215C(ElfMsg6* this, PlayState* play); +void func_80BA21C4(ElfMsg6* this, PlayState* play); const ActorInit Elf_Msg6_InitVars = { ACTOR_ELF_MSG6, @@ -78,7 +78,7 @@ void func_80BA165C(void) { } } -s32 func_80BA16F4(ElfMsg6* this, GlobalContext* globalCtx) { +s32 func_80BA16F4(ElfMsg6* this, PlayState* play) { if (!(gSaveContext.save.weekEventReg[31] & 4) && (INV_CONTENT(ITEM_MASK_DEKU) == ITEM_MASK_DEKU)) { this->actor.textId = 0x216; return false; @@ -123,7 +123,7 @@ s32 func_80BA16F4(ElfMsg6* this, GlobalContext* globalCtx) { return true; } -void ElfMsg6_Init(Actor* thisx, GlobalContext* globalCtx) { +void ElfMsg6_Init(Actor* thisx, PlayState* play) { ElfMsg6* this = THIS; Actor_ProcessInitChain(&this->actor, sInitChain); @@ -146,7 +146,7 @@ void ElfMsg6_Init(Actor* thisx, GlobalContext* globalCtx) { switch (ELFMSG6_GET_F(&this->actor)) { case 0: this->actionFunc = func_80BA1E30; - if (func_80BA16F4(this, globalCtx)) { + if (func_80BA16F4(this, play)) { Actor_MarkForDeath(&this->actor); return; } @@ -155,7 +155,7 @@ void ElfMsg6_Init(Actor* thisx, GlobalContext* globalCtx) { case 1: this->actionFunc = func_80BA1F80; if ((this->actor.cutscene == -1) || ((ELFMSG6_SWITCHFLAG(&this->actor) != 0x7F) && - Flags_GetSwitch(globalCtx, ELFMSG6_SWITCHFLAG(&this->actor)))) { + Flags_GetSwitch(play, ELFMSG6_SWITCHFLAG(&this->actor)))) { Actor_MarkForDeath(&this->actor); return; } @@ -201,7 +201,7 @@ void ElfMsg6_Init(Actor* thisx, GlobalContext* globalCtx) { case 3: if (((ELFMSG6_SWITCHFLAG(&this->actor) != 0x7F) && - Flags_GetSwitch(globalCtx, ELFMSG6_SWITCHFLAG(&this->actor))) || + Flags_GetSwitch(play, 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); @@ -232,7 +232,7 @@ void ElfMsg6_Init(Actor* thisx, GlobalContext* globalCtx) { } } -void ElfMsg6_Destroy(Actor* thisx, GlobalContext* globalCtx) { +void ElfMsg6_Destroy(Actor* thisx, PlayState* play) { } s32 func_80BA1C00(ElfMsg6* this) { @@ -240,8 +240,8 @@ s32 func_80BA1C00(ElfMsg6* this) { ((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); +void func_80BA1C88(ElfMsg6* this, PlayState* play, s16 arg2) { + Player* player = GET_PLAYER(play); EnElf* sp20 = (EnElf*)player->tatlActor; if (player->tatlActor != NULL) { @@ -254,15 +254,15 @@ void func_80BA1C88(ElfMsg6* this, GlobalContext* globalCtx, s16 arg2) { } } -void func_80BA1CF8(ElfMsg6* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); +void func_80BA1CF8(ElfMsg6* this, PlayState* play) { + Player* player = GET_PLAYER(play); EnElf* sp20 = (EnElf*)player->tatlActor; if (player->tatlActor == NULL) { return; } - if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { + if (Actor_ProcessTalkRequest(&this->actor, &play->state)) { switch (this->actor.textId) { case 0x224: gSaveContext.save.weekEventReg[79] |= 0x10; @@ -288,15 +288,15 @@ void func_80BA1CF8(ElfMsg6* this, GlobalContext* globalCtx) { } } -void func_80BA1E30(ElfMsg6* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); +void func_80BA1E30(ElfMsg6* this, PlayState* play) { + Player* player = GET_PLAYER(play); EnElf* sp20 = (EnElf*)player->tatlActor; if (player->tatlActor == NULL) { return; } - if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { + if (Actor_ProcessTalkRequest(&this->actor, &play->state)) { switch (this->actor.textId) { case 0x216: gSaveContext.save.weekEventReg[31] |= 4; @@ -329,7 +329,7 @@ void func_80BA1E30(ElfMsg6* this, GlobalContext* globalCtx) { } } -void func_80BA1F80(ElfMsg6* this, GlobalContext* globalCtx) { +void func_80BA1F80(ElfMsg6* this, PlayState* play) { if (((ELFMSG6_GET_F0(&this->actor)) == 1) && (gSaveContext.save.weekEventReg[83] & 2)) { Actor_MarkForDeath(&this->actor); return; @@ -338,7 +338,7 @@ void func_80BA1F80(ElfMsg6* this, GlobalContext* globalCtx) { if (func_80BA1C00(this)) { if (ActorCutscene_GetCanPlayNext(this->actor.cutscene)) { ActorCutscene_StartAndSetUnkLinkFields(this->actor.cutscene, NULL); - Flags_SetSwitch(globalCtx, ELFMSG6_SWITCHFLAG(&this->actor)); + Flags_SetSwitch(play, ELFMSG6_SWITCHFLAG(&this->actor)); Actor_MarkForDeath(&this->actor); } else { ActorCutscene_SetIntentToPlay(this->actor.cutscene); @@ -346,22 +346,22 @@ void func_80BA1F80(ElfMsg6* this, GlobalContext* globalCtx) { } } -void func_80BA2038(ElfMsg6* this, GlobalContext* globalCtx) { +void func_80BA2038(ElfMsg6* this, PlayState* play) { } -void func_80BA2048(ElfMsg6* this, GlobalContext* globalCtx) { - if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { - EnElf* sp20 = (EnElf*)GET_PLAYER(globalCtx)->tatlActor; +void func_80BA2048(ElfMsg6* this, PlayState* play) { + if (Actor_ProcessTalkRequest(&this->actor, &play->state)) { + EnElf* sp20 = (EnElf*)GET_PLAYER(play)->tatlActor; sp20->unk_264 |= 0x20; if (ELFMSG6_SWITCHFLAG(&this->actor) != 0x7F) { - Flags_SetSwitch(globalCtx, ELFMSG6_SWITCHFLAG(&this->actor)); + Flags_SetSwitch(play, ELFMSG6_SWITCHFLAG(&this->actor)); } Actor_MarkForDeath(&this->actor); return; } - if (((ELFMSG6_SWITCHFLAG(&this->actor) != 0x7F) && Flags_GetSwitch(globalCtx, ELFMSG6_SWITCHFLAG(&this->actor))) || + if (((ELFMSG6_SWITCHFLAG(&this->actor) != 0x7F) && Flags_GetSwitch(play, 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); @@ -369,46 +369,46 @@ void func_80BA2048(ElfMsg6* this, GlobalContext* globalCtx) { } if (func_80BA1C00(this)) { - func_80BA1C88(this, globalCtx, 0x24D); + func_80BA1C88(this, play, 0x24D); } } -void func_80BA215C(ElfMsg6* this, GlobalContext* globalCtx) { - if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { +void func_80BA215C(ElfMsg6* this, PlayState* play) { + if (Actor_ProcessTalkRequest(&this->actor, &play->state)) { Actor_MarkForDeath(&this->actor); return; } if (func_80BA1C00(this)) { - func_80BA1C88(this, globalCtx, -this->actor.textId); + func_80BA1C88(this, play, -this->actor.textId); } } -void func_80BA21C4(ElfMsg6* this, GlobalContext* globalCtx) { - if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { - EnElf* sp20 = (EnElf*)GET_PLAYER(globalCtx)->tatlActor; +void func_80BA21C4(ElfMsg6* this, PlayState* play) { + if (Actor_ProcessTalkRequest(&this->actor, &play->state)) { + EnElf* sp20 = (EnElf*)GET_PLAYER(play)->tatlActor; sp20->unk_264 |= 0x20; if (ELFMSG6_SWITCHFLAG(&this->actor) != 0x7F) { - Flags_SetSwitch(globalCtx, ELFMSG6_SWITCHFLAG(&this->actor)); + Flags_SetSwitch(play, ELFMSG6_SWITCHFLAG(&this->actor)); } Actor_MarkForDeath(&this->actor); return; } - if (((ELFMSG6_SWITCHFLAG(&this->actor) != 0x7F) && Flags_GetSwitch(globalCtx, ELFMSG6_SWITCHFLAG(&this->actor))) || + if (((ELFMSG6_SWITCHFLAG(&this->actor) != 0x7F) && Flags_GetSwitch(play, 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); + func_80BA1C88(this, play, this->actor.textId); } } -void ElfMsg6_Update(Actor* thisx, GlobalContext* globalCtx) { +void ElfMsg6_Update(Actor* thisx, PlayState* play) { ElfMsg6* this = THIS; - this->actionFunc(this, globalCtx); + this->actionFunc(this, play); } 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 78f970de0..cd33b350b 100644 --- a/src/overlays/actors/ovl_Elf_Msg6/z_elf_msg6.h +++ b/src/overlays/actors/ovl_Elf_Msg6/z_elf_msg6.h @@ -5,15 +5,15 @@ struct ElfMsg6; -typedef void (*ElfMsg6ActionFunc)(struct ElfMsg6*, GlobalContext*); +typedef void (*ElfMsg6ActionFunc)(struct ElfMsg6*, PlayState*); #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; + /* 0x000 */ Actor actor; + /* 0x144 */ ElfMsg6ActionFunc actionFunc; } ElfMsg6; // size = 0x148 extern const ActorInit Elf_Msg6_InitVars; diff --git a/src/overlays/actors/ovl_En_Ah/z_en_ah.c b/src/overlays/actors/ovl_En_Ah/z_en_ah.c index be25dec24..7c0dfa71c 100644 --- a/src/overlays/actors/ovl_En_Ah/z_en_ah.c +++ b/src/overlays/actors/ovl_En_Ah/z_en_ah.c @@ -11,17 +11,32 @@ #define THIS ((EnAh*)thisx) -void EnAh_Init(Actor* thisx, GlobalContext* globalCtx); -void EnAh_Destroy(Actor* thisx, GlobalContext* globalCtx); -void EnAh_Update(Actor* thisx, GlobalContext* globalCtx); -void EnAh_Draw(Actor* thisx, GlobalContext* globalCtx); +void EnAh_Init(Actor* thisx, PlayState* play); +void EnAh_Destroy(Actor* thisx, PlayState* play); +void EnAh_Update(Actor* thisx, PlayState* play); +void EnAh_Draw(Actor* thisx, PlayState* play); -void func_80BD36B8(EnAh* this, GlobalContext* globalCtx); -void func_80BD3768(EnAh* this, GlobalContext* globalCtx); +void func_80BD36B8(EnAh* this, PlayState* play); +void func_80BD3768(EnAh* this, PlayState* play); -s32 D_80BD3DB0[] = { - 0x0A00611D, 0x0C000303, 0x0400010C, 0x00021102, 0x15001700, 0x08003220, 0x03040001, - 0x05040003, 0x050A0010, 0x120C0003, 0x0D021200, 0x06000105, 0x0E120006, 0x00020505, +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 }; @@ -66,7 +81,7 @@ static ColliderCylinderInit sCylinderInit = { static CollisionCheckInfoInit2 sColChkInfoInit = { 0, 0, 0, 0, MASS_IMMOVABLE }; -static AnimationInfoS sAnimations[] = { +static AnimationInfoS sAnimationInfo[] = { { &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 }, @@ -90,12 +105,12 @@ TexturePtr D_80BD3F14[] = { object_ah_Tex_006D70, object_ah_Tex_007570, object_ah_Tex_007D70, object_ah_Tex_007570, object_ah_Tex_008570, }; -s32 func_80BD2A30(EnAh* this, GlobalContext* globalCtx, u8 actorCat, s16 actorId) { +s32 func_80BD2A30(EnAh* this, PlayState* play, u8 actorCat, s16 actorId) { Actor* tempActor; Actor* foundActor = NULL; while (true) { - foundActor = SubS_FindActor(globalCtx, foundActor, actorCat, actorId); + foundActor = SubS_FindActor(play, foundActor, actorCat, actorId); if ((foundActor == NULL) || (((EnAh*)foundActor != this) && (foundActor->update != NULL))) { break; @@ -131,22 +146,22 @@ s32 func_80BD2B0C(EnAh* this, s32 arg1) { if (phi_v1) { this->unk_300 = arg1; - ret = SubS_ChangeAnimationByInfoS(&this->skelAnime, sAnimations, arg1); + ret = SubS_ChangeAnimationByInfoS(&this->skelAnime, sAnimationInfo, arg1); this->unk_2DC = this->skelAnime.playSpeed; } return ret; } -void func_80BD2BA4(EnAh* this, GlobalContext* globalCtx) { +void func_80BD2BA4(EnAh* this, PlayState* play) { Collider_UpdateCylinder(&this->actor, &this->collider); - CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + CollisionCheck_SetOC(play, &play->colChkCtx, &this->collider.base); } -s32 func_80BD2BE8(EnAh* this, GlobalContext* globalCtx) { +s32 func_80BD2BE8(EnAh* this, PlayState* play) { s32 ret = false; if (this->unk_2D8 & 7) { - if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { + if (Actor_ProcessTalkRequest(&this->actor, &play->state)) { SubS_UpdateFlags(&this->unk_2D8, 0, 7); ret = true; this->unk_2D8 |= 8; @@ -196,13 +211,13 @@ void func_80BD2C6C(EnAh* this) { } } -Actor* func_80BD2DA0(EnAh* this, GlobalContext* globalCtx) { +Actor* func_80BD2DA0(EnAh* this, PlayState* play) { Actor* actor; if (this->unk_1DC == 3) { actor = this->actor.child; } else { - actor = &GET_PLAYER(globalCtx)->actor; + actor = &GET_PLAYER(play)->actor; } return actor; } @@ -239,8 +254,8 @@ void func_80BD2DC8(EnAh* this) { this->unk_2F0 = CLAMP(this->unk_2F0, -0xE38, 0xE38); } -void func_80BD2FD0(EnAh* this, GlobalContext* globalCtx) { - this->unk_1E4 = func_80BD2DA0(this, globalCtx); +void func_80BD2FD0(EnAh* this, PlayState* play) { + this->unk_1E4 = func_80BD2DA0(this, play); if ((this->unk_2D8 & 8) && (this->unk_1E4 != NULL)) { if (DECR(this->unk_2F4) == 0) { @@ -265,7 +280,7 @@ void func_80BD2FD0(EnAh* this, GlobalContext* globalCtx) { } } -s32 func_80BD30C0(EnAh* this, GlobalContext* globalCtx) { +s32 func_80BD30C0(EnAh* this, PlayState* play) { switch (this->unk_1DC) { case 1: func_80BD2B0C(this, 0); @@ -278,7 +293,7 @@ s32 func_80BD30C0(EnAh* this, GlobalContext* globalCtx) { return false; } -void func_80BD3118(EnAh* this, GlobalContext* globalCtx) { +void func_80BD3118(EnAh* this, PlayState* play) { if (this->unk_2FE == 0) { func_80BD2B0C(this, 2); this->unk_2FE++; @@ -288,9 +303,9 @@ void func_80BD3118(EnAh* this, GlobalContext* globalCtx) { } } -s32 func_80BD3198(EnAh* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); - u16 temp = globalCtx->msgCtx.currentTextId; +s32 func_80BD3198(EnAh* this, PlayState* play) { + Player* player = GET_PLAYER(play); + u16 temp = play->msgCtx.currentTextId; if (player->stateFlags1 & 0x40) { if (this->unk_2DA != temp) { @@ -319,18 +334,18 @@ s32 func_80BD3198(EnAh* this, GlobalContext* globalCtx) { this->unk_2D8 &= ~0x100; this->unk_2F6 = 0; this->unk_2F8 = 4; - func_80BD30C0(this, globalCtx); + func_80BD30C0(this, play); } if (this->unk_18C != NULL) { - this->unk_18C(this, globalCtx); + this->unk_18C(this, play); } return false; } -s32* func_80BD3294(EnAh* this, GlobalContext* globalCtx) { - s32 mask = Player_GetMask(globalCtx); +s32* func_80BD3294(EnAh* this, PlayState* play) { + s32 mask = Player_GetMask(play); if (PLAYER_MASK_KAFEIS_MASK == mask) { return D_80BD3E08; @@ -349,10 +364,10 @@ s32* func_80BD3294(EnAh* this, GlobalContext* globalCtx) { return NULL; } -s32 func_80BD3320(EnAh* this, GlobalContext* globalCtx, u8 actorCat, s16 actorId) { +s32 func_80BD3320(EnAh* this, PlayState* play, u8 actorCat, s16 actorId) { s32 pad; s32 ret = false; - Actor* temp_v0 = func_80BD2A30(this, globalCtx, actorCat, actorId); + Actor* temp_v0 = func_80BD2A30(this, play, actorCat, actorId); if (temp_v0 != NULL) { this->actor.child = temp_v0; @@ -361,7 +376,7 @@ s32 func_80BD3320(EnAh* this, GlobalContext* globalCtx, u8 actorCat, s16 actorId return ret; } -s32 func_80BD3374(EnAh* this, GlobalContext* globalCtx, struct_80133038_arg2* arg2) { +s32 func_80BD3374(EnAh* this, PlayState* play, ScheduleOutput* scheduleOutput) { s32 pad; Math_Vec3f_Copy(&this->actor.world.pos, &D_80BD3EC4.pos); @@ -373,7 +388,7 @@ s32 func_80BD3374(EnAh* this, GlobalContext* globalCtx, struct_80133038_arg2* ar return true; } -s32 func_80BD33FC(EnAh* this, GlobalContext* globalCtx, struct_80133038_arg2* arg2) { +s32 func_80BD33FC(EnAh* this, PlayState* play, ScheduleOutput* scheduleOutput) { s32 pad; Math_Vec3f_Copy(&this->actor.world.pos, &D_80BD3ED8.pos); @@ -385,10 +400,10 @@ s32 func_80BD33FC(EnAh* this, GlobalContext* globalCtx, struct_80133038_arg2* ar return true; } -s32 func_80BD3484(EnAh* this, GlobalContext* globalCtx, struct_80133038_arg2* arg2) { +s32 func_80BD3484(EnAh* this, PlayState* play, ScheduleOutput* scheduleOutput) { s32 ret = false; - if (func_80BD3320(this, globalCtx, ACTORCAT_NPC, ACTOR_EN_AN)) { + if (func_80BD3320(this, play, 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); @@ -404,32 +419,32 @@ s32 func_80BD3484(EnAh* this, GlobalContext* globalCtx, struct_80133038_arg2* ar return ret; } -s32 func_80BD3548(EnAh* this, GlobalContext* globalCtx, struct_80133038_arg2* arg2) { +s32 func_80BD3548(EnAh* this, PlayState* play, ScheduleOutput* scheduleOutput) { s32 ret; this->unk_2D8 = 0; - switch (arg2->unk0) { + switch (scheduleOutput->result) { default: ret = false; break; case 1: - ret = func_80BD3374(this, globalCtx, arg2); + ret = func_80BD3374(this, play, scheduleOutput); break; case 2: - ret = func_80BD33FC(this, globalCtx, arg2); + ret = func_80BD33FC(this, play, scheduleOutput); break; case 3: - ret = func_80BD3484(this, globalCtx, arg2); + ret = func_80BD3484(this, play, scheduleOutput); break; } return ret; } -s32 func_80BD35BC(EnAh* this, GlobalContext* globalCtx) { +s32 func_80BD35BC(EnAh* this, PlayState* play) { s16 temp; s16 temp2; @@ -449,36 +464,35 @@ s32 func_80BD35BC(EnAh* this, GlobalContext* globalCtx) { } } -void func_80BD3658(EnAh* this, GlobalContext* globalCtx) { +void func_80BD3658(EnAh* this, PlayState* play) { if ((this->unk_1DC == 1) || (this->unk_1DC == 2) || (this->unk_1DC == 3)) { - func_80BD35BC(this, globalCtx); + func_80BD35BC(this, play); } Math_ApproachS(&this->actor.shape.rot.y, this->actor.world.rot.y, 3, 0x2AA8); } -void func_80BD36B8(EnAh* this, GlobalContext* globalCtx) { - s32 pad; - struct_80133038_arg2 sp18; +void func_80BD36B8(EnAh* this, PlayState* play) { + ScheduleOutput sp18; - if (!func_80133038(globalCtx, D_80BD3DB0, &sp18) || - ((this->unk_1DC != sp18.unk0) && !func_80BD3548(this, globalCtx, &sp18))) { + if (!Schedule_RunScript(play, D_80BD3DB0, &sp18) || + ((this->unk_1DC != sp18.result) && !func_80BD3548(this, play, &sp18))) { this->actor.shape.shadowDraw = NULL; this->actor.flags &= ~ACTOR_FLAG_1; - sp18.unk0 = 0; + sp18.result = 0; } else { this->actor.shape.shadowDraw = ActorShadow_DrawCircle; this->actor.flags |= ACTOR_FLAG_1; } - this->unk_1DC = sp18.unk0; - func_80BD3658(this, globalCtx); + this->unk_1DC = sp18.result; + func_80BD3658(this, play); } -void func_80BD3768(EnAh* this, GlobalContext* globalCtx) { +void func_80BD3768(EnAh* this, PlayState* play) { s32 pad; Vec3f sp40; Vec3f sp34; - if (func_8010BF58(&this->actor, globalCtx, func_80BD3294(this, globalCtx), NULL, &this->unk_1E0)) { + if (func_8010BF58(&this->actor, play, func_80BD3294(this, play), NULL, &this->unk_1E0)) { SubS_UpdateFlags(&this->unk_2D8, 3, 7); this->unk_2D8 &= ~8; this->unk_2D8 |= 0x80; @@ -494,20 +508,19 @@ void func_80BD3768(EnAh* this, GlobalContext* globalCtx) { } } -void EnAh_Init(Actor* thisx, GlobalContext* globalCtx) { +void EnAh_Init(Actor* thisx, PlayState* play) { EnAh* this = THIS; - if (func_80BD2A30(this, globalCtx, ACTORCAT_NPC, ACTOR_EN_AH)) { + if (func_80BD2A30(this, play, 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); + SkelAnime_InitFlex(play, &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); + Collider_InitAndSetCylinder(play, &this->collider, &this->actor, &sCylinderInit); CollisionCheck_SetInfo2(&this->actor.colChkInfo, DamageTable_Get(0x16), &sColChkInfoInit); this->actor.targetMode = 6; Actor_SetScale(&this->actor, 0.01f); @@ -515,105 +528,106 @@ void EnAh_Init(Actor* thisx, GlobalContext* globalCtx) { this->unk_2D8 = 0; this->actionFunc = func_80BD36B8; - this->actionFunc(this, globalCtx); + this->actionFunc(this, play); } -void EnAh_Destroy(Actor* thisx, GlobalContext* globalCtx) { +void EnAh_Destroy(Actor* thisx, PlayState* play) { EnAh* this = THIS; - Collider_DestroyCylinder(globalCtx, &this->collider); + Collider_DestroyCylinder(play, &this->collider); } -void EnAh_Update(Actor* thisx, GlobalContext* globalCtx) { +void EnAh_Update(Actor* thisx, PlayState* play) { EnAh* this = THIS; f32 radius; f32 height; - func_80BD2BE8(this, globalCtx); + func_80BD2BE8(this, play); - this->actionFunc(this, globalCtx); + this->actionFunc(this, play); if (this->unk_1DC != 0) { - func_80BD3198(this, globalCtx); + func_80BD3198(this, play); func_80BD2AE0(this); func_80BD2C6C(this); - func_80BD2FD0(this, globalCtx); + func_80BD2FD0(this, play); radius = this->collider.dim.radius + 60; height = this->collider.dim.height + 10; - func_8013C964(&this->actor, globalCtx, radius, height, 0, this->unk_2D8 & 7); + func_8013C964(&this->actor, play, radius, height, PLAYER_AP_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); + Actor_UpdateBgCheckInfo(play, &this->actor, 30.0f, 12.0f, 0.0f, 4); } - func_80BD2BA4(this, globalCtx); + func_80BD2BA4(this, play); } } -void func_80BD3AA8(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx) { +void EnAh_PostLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx) { EnAh* this = THIS; if (limbIndex == 7) { - Matrix_MultiplyVector3fByState(&D_80BD3F00, &this->actor.focus.pos); + Matrix_MultVec3f(&D_80BD3F00, &this->actor.focus.pos); Math_Vec3s_Copy(&this->actor.focus.rot, &this->actor.world.rot); } } -void func_80BD3AF8(GlobalContext* globalCtx, s32 limbIndex, Actor* thisx) { +void EnAh_TransformLimbDraw(PlayState* play, s32 limbIndex, Actor* thisx) { EnAh* this = THIS; - s32 phi_v1; - s32 phi_v0; + s32 stepRot; + s32 overrideRot; if (!(this->unk_2D8 & 0x80)) { if (this->unk_2D8 & 0x20) { - phi_v0 = 1; + overrideRot = true; } else { - phi_v0 = 0; + overrideRot = false; } - phi_v1 = 1; + stepRot = true; } else { - phi_v1 = 0; - phi_v0 = 0; + stepRot = false; + overrideRot = false; } if (limbIndex == 7) { - func_8013AD9C(BINANG_ADD(this->unk_2EC + this->unk_2F0, 0x4000), - BINANG_ADD(this->unk_2EE + this->unk_2F2 + this->actor.shape.rot.y, 0x4000), this->unk_1E8, - this->unk_200, phi_v1, phi_v0); - Matrix_StatePop(); - Matrix_InsertTranslation(this->unk_1E8[0].x, this->unk_1E8[0].y, this->unk_1E8[0].z, MTXMODE_NEW); + 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_RotateY(this->unk_200[0].y, MTXMODE_APPLY); - Matrix_InsertXRotation_s(this->unk_200[0].x, MTXMODE_APPLY); - Matrix_InsertZRotation_s(this->unk_200[0].z, MTXMODE_APPLY); - Matrix_StatePush(); + 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) { - func_8013AD9C(BINANG_ADD(this->unk_2F0, 0x4000), BINANG_ADD(this->unk_2F2 + this->actor.shape.rot.y, 0x4000), - &this->unk_1E8[1], &this->unk_200[1], phi_v1, phi_v0); - Matrix_StatePop(); - Matrix_InsertTranslation(this->unk_1E8[1].x, this->unk_1E8[1].y, this->unk_1E8[1].z, MTXMODE_NEW); + 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_RotateY(this->unk_200[1].y, MTXMODE_APPLY); - Matrix_InsertXRotation_s(this->unk_200[1].x, MTXMODE_APPLY); - Matrix_InsertZRotation_s(this->unk_200[1].z, MTXMODE_APPLY); - Matrix_StatePush(); + 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) { +void EnAh_Draw(Actor* thisx, PlayState* play) { EnAh* this = THIS; if (this->unk_1DC != 0) { - OPEN_DISPS(globalCtx->state.gfxCtx); + OPEN_DISPS(play->state.gfxCtx); - func_8012C28C(globalCtx->state.gfxCtx); + func_8012C28C(play->state.gfxCtx); gSPSegment(POLY_OPA_DISP++, 0x08, Lib_SegmentedToVirtual(D_80BD3F14[this->unk_2FA])); gSPSegment(POLY_OPA_DISP++, 0x09, Lib_SegmentedToVirtual(D_80BD3F0C[this->unk_2FC])); - SkelAnime_DrawTransformFlexOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, - this->skelAnime.dListCount, NULL, func_80BD3AA8, func_80BD3AF8, &this->actor); + SkelAnime_DrawTransformFlexOpa(play, this->skelAnime.skeleton, this->skelAnime.jointTable, + this->skelAnime.dListCount, NULL, EnAh_PostLimbDraw, EnAh_TransformLimbDraw, + &this->actor); - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->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 85263e04b..78872a270 100644 --- a/src/overlays/actors/ovl_En_Ah/z_en_ah.h +++ b/src/overlays/actors/ovl_En_Ah/z_en_ah.h @@ -5,37 +5,37 @@ struct EnAh; -typedef void (*EnAhActionFunc)(struct EnAh*, GlobalContext*); -typedef void (*EnAhUnkFunc)(struct EnAh*, GlobalContext*); +typedef void (*EnAhActionFunc)(struct EnAh*, PlayState*); +typedef void (*EnAhUnkFunc)(struct EnAh*, PlayState*); typedef struct EnAh { - /* 0x0000 */ Actor actor; - /* 0x0144 */ SkelAnime skelAnime; - /* 0x0188 */ EnAhActionFunc actionFunc; - /* 0x018C */ EnAhUnkFunc unk_18C; - /* 0x0190 */ ColliderCylinder collider; - /* 0x01DC */ u8 unk_1DC; - /* 0x01E0 */ s32 unk_1E0; - /* 0x01E4 */ Actor* unk_1E4; - /* 0x01E8 */ Vec3f unk_1E8[2]; - /* 0x0200 */ Vec3s unk_200[2]; - /* 0x020C */ Vec3s jointTable[17]; - /* 0x0272 */ Vec3s morphTable[17]; - /* 0x02D8 */ u16 unk_2D8; - /* 0x02DA */ u16 unk_2DA; - /* 0x02DC */ f32 unk_2DC; - /* 0x02E0 */ UNK_TYPE1 unk2E0[0xC]; - /* 0x02EC */ s16 unk_2EC; - /* 0x02EE */ s16 unk_2EE; - /* 0x02F0 */ s16 unk_2F0; - /* 0x02F2 */ s16 unk_2F2; - /* 0x02F4 */ s16 unk_2F4; - /* 0x02F6 */ s16 unk_2F6; - /* 0x02F8 */ s16 unk_2F8; - /* 0x02FA */ s16 unk_2FA; - /* 0x02FC */ s16 unk_2FC; - /* 0x02FE */ s16 unk_2FE; - /* 0x0300 */ s32 unk_300; + /* 0x000 */ Actor actor; + /* 0x144 */ SkelAnime skelAnime; + /* 0x188 */ EnAhActionFunc actionFunc; + /* 0x18C */ EnAhUnkFunc unk_18C; + /* 0x190 */ ColliderCylinder collider; + /* 0x1DC */ u8 unk_1DC; + /* 0x1E0 */ s32 unk_1E0; + /* 0x1E4 */ Actor* unk_1E4; + /* 0x1E8 */ Vec3f unk_1E8[2]; + /* 0x200 */ Vec3s unk_200[2]; + /* 0x20C */ Vec3s jointTable[17]; + /* 0x272 */ Vec3s morphTable[17]; + /* 0x2D8 */ u16 unk_2D8; + /* 0x2DA */ u16 unk_2DA; + /* 0x2DC */ f32 unk_2DC; + /* 0x2E0 */ UNK_TYPE1 unk2E0[0xC]; + /* 0x2EC */ s16 unk_2EC; + /* 0x2EE */ s16 unk_2EE; + /* 0x2F0 */ s16 unk_2F0; + /* 0x2F2 */ s16 unk_2F2; + /* 0x2F4 */ s16 unk_2F4; + /* 0x2F6 */ s16 unk_2F6; + /* 0x2F8 */ s16 unk_2F8; + /* 0x2FA */ s16 unk_2FA; + /* 0x2FC */ s16 unk_2FC; + /* 0x2FE */ s16 unk_2FE; + /* 0x300 */ s32 unk_300; } EnAh; // size = 0x304 extern const ActorInit En_Ah_InitVars; diff --git a/src/overlays/actors/ovl_En_Akindonuts/z_en_akindonuts.c b/src/overlays/actors/ovl_En_Akindonuts/z_en_akindonuts.c index 70e98fc15..4e7a51c97 100644 --- a/src/overlays/actors/ovl_En_Akindonuts/z_en_akindonuts.c +++ b/src/overlays/actors/ovl_En_Akindonuts/z_en_akindonuts.c @@ -11,25 +11,25 @@ #define THIS ((EnAkindonuts*)thisx) -void EnAkindonuts_Init(Actor* thisx, GlobalContext* globalCtx); -void EnAkindonuts_Destroy(Actor* thisx, GlobalContext* globalCtx); -void EnAkindonuts_Update(Actor* thisx, GlobalContext* globalCtx); -void EnAkindonuts_Draw(Actor* thisx, GlobalContext* globalCtx); +void EnAkindonuts_Init(Actor* thisx, PlayState* play); +void EnAkindonuts_Destroy(Actor* thisx, PlayState* play); +void EnAkindonuts_Update(Actor* thisx, PlayState* play); +void EnAkindonuts_Draw(Actor* thisx, PlayState* play); -void func_80BEEDC0(EnAkindonuts* this, GlobalContext* globalCtx); -void func_80BEEE10(EnAkindonuts* this, GlobalContext* globalCtx); -void func_80BEEFA8(EnAkindonuts* this, GlobalContext* globalCtx); -void func_80BEF18C(EnAkindonuts* this, GlobalContext* globalCtx); -void func_80BEF20C(EnAkindonuts* this, GlobalContext* globalCtx); -void func_80BEF360(EnAkindonuts* this, GlobalContext* globalCtx); -void func_80BEF450(EnAkindonuts* this, GlobalContext* globalCtx); -void func_80BEF4B8(EnAkindonuts* this, GlobalContext* globalCtx); -void func_80BEF518(EnAkindonuts* this, GlobalContext* globalCtx); -void func_80BEF770(EnAkindonuts* this, GlobalContext* globalCtx); -void func_80BEF83C(EnAkindonuts* this, GlobalContext* globalCtx); -void func_80BEF9F0(EnAkindonuts* this, GlobalContext* globalCtx); -void func_80BEFAF0(EnAkindonuts* this, GlobalContext* globalCtx); -void func_80BEFD74(EnAkindonuts* this, GlobalContext* globalCtx); +void func_80BEEDC0(EnAkindonuts* this, PlayState* play); +void func_80BEEE10(EnAkindonuts* this, PlayState* play); +void func_80BEEFA8(EnAkindonuts* this, PlayState* play); +void func_80BEF18C(EnAkindonuts* this, PlayState* play); +void func_80BEF20C(EnAkindonuts* this, PlayState* play); +void func_80BEF360(EnAkindonuts* this, PlayState* play); +void func_80BEF450(EnAkindonuts* this, PlayState* play); +void func_80BEF4B8(EnAkindonuts* this, PlayState* play); +void func_80BEF518(EnAkindonuts* this, PlayState* play); +void func_80BEF770(EnAkindonuts* this, PlayState* play); +void func_80BEF83C(EnAkindonuts* this, PlayState* play); +void func_80BEF9F0(EnAkindonuts* this, PlayState* play); +void func_80BEFAF0(EnAkindonuts* this, PlayState* play); +void func_80BEFD74(EnAkindonuts* this, PlayState* play); const ActorInit En_Akindonuts_InitVars = { ACTOR_EN_AKINDONUTS, @@ -62,7 +62,7 @@ static ColliderCylinderInitType1 sCylinderInit = { { 27, 32, 0, { 0, 0, 0 } }, }; -static AnimationInfoS sAnimations[] = { +static AnimationInfoS sAnimationInfo[] = { { &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 }, @@ -143,14 +143,14 @@ void func_80BECBE0(EnAkindonuts* this, s16 arg1) { Actor_UpdatePos(&this->actor); } -void func_80BECC7C(EnAkindonuts* this, GlobalContext* globalCtx) { +void func_80BECC7C(EnAkindonuts* this, PlayState* play) { if (this->unk_32C & 4) { Collider_UpdateCylinder(&this->actor, &this->collider); - CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + CollisionCheck_SetOC(play, &play->colChkCtx, &this->collider.base); } if (this->unk_32C & 2) { - Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 20.0f, 20.0f, 20.0f, 5); + Actor_UpdateBgCheckInfo(play, &this->actor, 20.0f, 20.0f, 20.0f, 5); } } @@ -221,40 +221,40 @@ s16 func_80BECF6C(Path* path) { s32 func_80BECFBC(EnAkindonuts* this) { switch (ENAKINDONUTS_GET_3(&this->actor)) { case 0: - return 0x98; + return GI_DEED_SWAMP; case 1: - return 0x99; + return GI_DEED_MOUNTAIN; case 2: - return 0x9A; + return GI_DEED_OCEAN; case 3: - func_801149A0(ITEM_DEED_OCEAN, SLOT(ITEM_DEED_OCEAN)); - return 0x7; + Inventory_DeleteItem(ITEM_DEED_OCEAN, SLOT(ITEM_DEED_OCEAN)); + return GI_RUPEE_HUGE; } - return 0; + return GI_NONE; } s32 func_80BED034(EnAkindonuts* this) { switch (ENAKINDONUTS_GET_3(&this->actor)) { case 0: - return 0x35; + return GI_MAGIC_BEANS; case 1: - return 0x1D; + return GI_BOMB_BAG_40; case 2: - return 0x5C; + return GI_POTION_GREEN; case 3: - return 0x5D; + return GI_POTION_BLUE; } - return 0; + return GI_NONE; } -void func_80BED090(GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); +void func_80BED090(PlayState* play) { + Player* player = GET_PLAYER(play); if (player->transformation == PLAYER_FORM_DEKU) { gSaveContext.save.weekEventReg[63] |= 8; @@ -271,8 +271,8 @@ void func_80BED090(GlobalContext* globalCtx) { } } -s32 func_80BED140(GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); +s32 func_80BED140(PlayState* play) { + Player* player = GET_PLAYER(play); if (player->transformation == PLAYER_FORM_DEKU) { if ((gSaveContext.save.weekEventReg[63] & 8) && !(gSaveContext.save.weekEventReg[63] & 0x10)) { @@ -296,7 +296,7 @@ s32 func_80BED140(GlobalContext* globalCtx) { } s32 func_80BED208(EnAkindonuts* this) { - if (INV_CONTENT(ITEM_MAGIC_BEANS) != 10U) { + if ((u32)INV_CONTENT(ITEM_MAGIC_BEANS) != ITEM_MAGIC_BEANS) { return 0; } @@ -332,7 +332,7 @@ s32 func_80BED27C(EnAkindonuts* this) { } s32 func_80BED2FC(EnAkindonuts* this) { - if (!Interface_HasEmptyBottle()) { + if (!Inventory_HasEmptyBottle()) { return 2; } @@ -346,7 +346,7 @@ s32 func_80BED2FC(EnAkindonuts* this) { } s32 func_80BED35C(EnAkindonuts* this) { - if (!Interface_HasEmptyBottle()) { + if (!Inventory_HasEmptyBottle()) { return 2; } @@ -359,8 +359,8 @@ s32 func_80BED35C(EnAkindonuts* this) { return 3; } -void func_80BED3BC(EnAkindonuts* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); +void func_80BED3BC(EnAkindonuts* this, PlayState* play) { + Player* player = GET_PLAYER(play); switch (this->unk_33C) { case 0: @@ -425,8 +425,8 @@ void func_80BED3BC(EnAkindonuts* this, GlobalContext* globalCtx) { func_8019F208(); this->unk_32C &= ~0x1; this->unk_32C |= 0x40; - globalCtx->msgCtx.msgMode = 0x43; - globalCtx->msgCtx.unk12023 = 4; + play->msgCtx.msgMode = 0x43; + play->msgCtx.stateTimer = 4; this->unk_33C = 0x15EF; this->actionFunc = func_80BEF360; return; @@ -445,7 +445,7 @@ void func_80BED3BC(EnAkindonuts* this, GlobalContext* globalCtx) { case 0x15E5: this->unk_33C = 0x15E6; - func_80BED090(globalCtx); + func_80BED090(play); gSaveContext.save.weekEventReg[61] |= 0x10; this->unk_32C |= 0x20; break; @@ -455,13 +455,13 @@ void func_80BED3BC(EnAkindonuts* this, GlobalContext* globalCtx) { break; } - Message_StartTextbox(globalCtx, this->unk_33C, &this->actor); + Message_StartTextbox(play, this->unk_33C, &this->actor); } -void func_80BED680(EnAkindonuts* this, GlobalContext* globalCtx) { +void func_80BED680(EnAkindonuts* this, PlayState* play) { switch (this->unk_33C) { case 0: - if (func_80BED140(globalCtx) && !(gSaveContext.save.weekEventReg[61] & 0x40)) { + if (func_80BED140(play) && !(gSaveContext.save.weekEventReg[61] & 0x40)) { gSaveContext.save.weekEventReg[61] |= 0x40; this->unk_33C = 0x15F0; break; @@ -508,8 +508,8 @@ void func_80BED680(EnAkindonuts* this, GlobalContext* globalCtx) { func_8019F208(); this->unk_32C |= 0x40; this->unk_32C &= ~0x1; - globalCtx->msgCtx.msgMode = 0x43; - globalCtx->msgCtx.unk12023 = 4; + play->msgCtx.msgMode = 0x43; + play->msgCtx.stateTimer = 4; this->unk_33C = 0x15EF; this->actionFunc = func_80BEF360; return; @@ -526,11 +526,11 @@ void func_80BED680(EnAkindonuts* this, GlobalContext* globalCtx) { break; } - Message_StartTextbox(globalCtx, this->unk_33C, &this->actor); + Message_StartTextbox(play, this->unk_33C, &this->actor); } -void func_80BED8A4(EnAkindonuts* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); +void func_80BED8A4(EnAkindonuts* this, PlayState* play) { + Player* player = GET_PLAYER(play); switch (this->unk_33C) { case 0: @@ -603,8 +603,8 @@ void func_80BED8A4(EnAkindonuts* this, GlobalContext* globalCtx) { func_8019F208(); this->unk_32C |= 0x40; this->unk_32C &= ~0x1; - globalCtx->msgCtx.msgMode = 0x43; - globalCtx->msgCtx.unk12023 = 4; + play->msgCtx.msgMode = 0x43; + play->msgCtx.stateTimer = 4; this->unk_33C = 0x15EF; this->actionFunc = func_80BEF360; return; @@ -632,11 +632,11 @@ void func_80BED8A4(EnAkindonuts* this, GlobalContext* globalCtx) { break; } - Message_StartTextbox(globalCtx, this->unk_33C, &this->actor); + Message_StartTextbox(play, this->unk_33C, &this->actor); } -void func_80BEDB88(EnAkindonuts* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); +void func_80BEDB88(EnAkindonuts* this, PlayState* play) { + Player* player = GET_PLAYER(play); switch (this->unk_33C) { case 0: @@ -686,8 +686,8 @@ void func_80BEDB88(EnAkindonuts* this, GlobalContext* globalCtx) { func_8019F208(); this->unk_32C |= 0x40; this->unk_32C &= ~0x1; - globalCtx->msgCtx.msgMode = 0x43; - globalCtx->msgCtx.unk12023 = 4; + play->msgCtx.msgMode = 0x43; + play->msgCtx.stateTimer = 4; this->unk_33C = 0x15EF; this->actionFunc = func_80BEF360; return; @@ -704,11 +704,11 @@ void func_80BEDB88(EnAkindonuts* this, GlobalContext* globalCtx) { break; } - Message_StartTextbox(globalCtx, this->unk_33C, &this->actor); + Message_StartTextbox(play, this->unk_33C, &this->actor); } -void func_80BEDDAC(EnAkindonuts* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); +void func_80BEDDAC(EnAkindonuts* this, PlayState* play) { + Player* player = GET_PLAYER(play); switch (this->unk_33C) { case 0: @@ -776,8 +776,8 @@ void func_80BEDDAC(EnAkindonuts* this, GlobalContext* globalCtx) { func_8019F208(); this->unk_32C |= 0x40; this->unk_32C &= ~0x1; - globalCtx->msgCtx.msgMode = 0x43; - globalCtx->msgCtx.unk12023 = 4; + play->msgCtx.msgMode = 0x43; + play->msgCtx.stateTimer = 4; this->unk_33C = 0x15EF; this->actionFunc = func_80BEF360; return; @@ -805,11 +805,11 @@ void func_80BEDDAC(EnAkindonuts* this, GlobalContext* globalCtx) { break; } - Message_StartTextbox(globalCtx, this->unk_33C, &this->actor); + Message_StartTextbox(play, this->unk_33C, &this->actor); } -void func_80BEE070(EnAkindonuts* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); +void func_80BEE070(EnAkindonuts* this, PlayState* play) { + Player* player = GET_PLAYER(play); switch (this->unk_33C) { case 0: @@ -854,8 +854,8 @@ void func_80BEE070(EnAkindonuts* this, GlobalContext* globalCtx) { func_8019F208(); this->unk_32C |= 0x40; this->unk_32C &= ~0x1; - globalCtx->msgCtx.msgMode = 0x43; - globalCtx->msgCtx.unk12023 = 4; + play->msgCtx.msgMode = 0x43; + play->msgCtx.stateTimer = 4; this->unk_33C = 0x161A; this->actionFunc = func_80BEF360; return; @@ -872,11 +872,11 @@ void func_80BEE070(EnAkindonuts* this, GlobalContext* globalCtx) { break; } - Message_StartTextbox(globalCtx, this->unk_33C, &this->actor); + Message_StartTextbox(play, this->unk_33C, &this->actor); } -void func_80BEE274(EnAkindonuts* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); +void func_80BEE274(EnAkindonuts* this, PlayState* play) { + Player* player = GET_PLAYER(play); switch (this->unk_33C) { case 0: @@ -937,8 +937,8 @@ void func_80BEE274(EnAkindonuts* this, GlobalContext* globalCtx) { func_8019F208(); this->unk_32C |= 0x40; this->unk_32C &= ~0x1; - globalCtx->msgCtx.msgMode = 0x43; - globalCtx->msgCtx.unk12023 = 4; + play->msgCtx.msgMode = 0x43; + play->msgCtx.stateTimer = 4; this->unk_33C = 0x1629; this->actionFunc = func_80BEF360; return; @@ -966,11 +966,11 @@ void func_80BEE274(EnAkindonuts* this, GlobalContext* globalCtx) { break; } - Message_StartTextbox(globalCtx, this->unk_33C, &this->actor); + Message_StartTextbox(play, this->unk_33C, &this->actor); } -void func_80BEE530(EnAkindonuts* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); +void func_80BEE530(EnAkindonuts* this, PlayState* play) { + Player* player = GET_PLAYER(play); switch (this->unk_33C) { case 0: @@ -1015,8 +1015,8 @@ void func_80BEE530(EnAkindonuts* this, GlobalContext* globalCtx) { func_8019F208(); this->unk_32C |= 0x40; this->unk_32C &= ~0x1; - globalCtx->msgCtx.msgMode = 0x43; - globalCtx->msgCtx.unk12023 = 4; + play->msgCtx.msgMode = 0x43; + play->msgCtx.stateTimer = 4; this->unk_33C = 0x15EF; this->actionFunc = func_80BEF360; return; @@ -1033,14 +1033,14 @@ void func_80BEE530(EnAkindonuts* this, GlobalContext* globalCtx) { break; } - Message_StartTextbox(globalCtx, this->unk_33C, &this->actor); + Message_StartTextbox(play, this->unk_33C, &this->actor); } -void func_80BEE73C(EnAkindonuts* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); +void func_80BEE73C(EnAkindonuts* this, PlayState* play) { + Player* player = GET_PLAYER(play); s32 pad; s32 params = ENAKINDONUTS_GET_3(&this->actor); - s32 itemActionParam = func_80123810(globalCtx); + s32 itemActionParam = func_80123810(play); if (itemActionParam > PLAYER_AP_NONE) { if (itemActionParam == PLAYER_AP_DEED_LAND) { @@ -1084,15 +1084,15 @@ void func_80BEE73C(EnAkindonuts* this, GlobalContext* globalCtx) { this->unk_33C = player->actor.textId; this->actionFunc = func_80BEF18C; } - func_801477B4(globalCtx); + func_801477B4(play); } else if (itemActionParam < PLAYER_AP_NONE) { this->unk_33C = D_80BF04AC[params]; - func_80151938(globalCtx, this->unk_33C); + func_80151938(play, this->unk_33C); this->actionFunc = func_80BEF18C; } } -void func_80BEE938(EnAkindonuts* this, GlobalContext* globalCtx) { +void func_80BEE938(EnAkindonuts* this, PlayState* play) { switch (ENAKINDONUTS_GET_3(&this->actor)) { case 0: if (gSaveContext.save.weekEventReg[61] & 0x10) { @@ -1152,9 +1152,9 @@ void func_80BEE938(EnAkindonuts* this, GlobalContext* globalCtx) { } } -void func_80BEEB20(EnAkindonuts* this, GlobalContext* globalCtx) { +void func_80BEEB20(EnAkindonuts* this, PlayState* play) { s16 sp26 = this->skelAnime.curFrame; - s16 sp24 = Animation_GetLastFrame(&sAnimations[this->unk_338].animation->common); + s16 sp24 = Animation_GetLastFrame(&sAnimationInfo[this->unk_338].animation->common); s16 phi_v0; Math_ApproachS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer, 2, 0xE38); @@ -1177,7 +1177,7 @@ void func_80BEEB20(EnAkindonuts* this, GlobalContext* globalCtx) { this->actionFunc = func_80BEEDC0; this->unk_338 = 3; this->collider.dim.height = 64; - SubS_ChangeAnimationByInfoS(&this->skelAnime, sAnimations, 3); + SubS_ChangeAnimationByInfoS(&this->skelAnime, sAnimationInfo, 3); return; } } @@ -1187,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); - SubS_ChangeAnimationByInfoS(&this->skelAnime, sAnimations, 17); + SubS_ChangeAnimationByInfoS(&this->skelAnime, sAnimationInfo, 17); } else if (this->unk_338 == 2) { this->unk_338 = 16; this->collider.dim.height = 32; Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_NUTS_UP); - SubS_ChangeAnimationByInfoS(&this->skelAnime, sAnimations, 16); + SubS_ChangeAnimationByInfoS(&this->skelAnime, sAnimationInfo, 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; - SubS_ChangeAnimationByInfoS(&this->skelAnime, sAnimations, 2); + SubS_ChangeAnimationByInfoS(&this->skelAnime, sAnimationInfo, 2); } } else if (this->unk_338 == 16) { phi_v0 = DECR(this->unk_33A); @@ -1207,158 +1207,158 @@ void func_80BEEB20(EnAkindonuts* this, GlobalContext* globalCtx) { this->unk_33A = Rand_S16Offset(40, 40); this->unk_338 = 18; this->collider.dim.height = 32; - SubS_ChangeAnimationByInfoS(&this->skelAnime, sAnimations, 18); + SubS_ChangeAnimationByInfoS(&this->skelAnime, sAnimationInfo, 18); } } } } -void func_80BEEDC0(EnAkindonuts* this, GlobalContext* globalCtx) { +void func_80BEEDC0(EnAkindonuts* this, PlayState* play) { if (this->skelAnime.curFrame == this->skelAnime.endFrame) { this->actionFunc = func_80BEEE10; - SubS_ChangeAnimationByInfoS(&this->skelAnime, sAnimations, 0); + SubS_ChangeAnimationByInfoS(&this->skelAnime, sAnimationInfo, 0); } } -void func_80BEEE10(EnAkindonuts* this, GlobalContext* globalCtx) { +void func_80BEEE10(EnAkindonuts* this, PlayState* play) { Math_SmoothStepToS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer, 3, 2000, 0); this->actor.world.rot.y = this->actor.shape.rot.y; - if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { - this->unk_2DC(this, globalCtx); + if (Actor_ProcessTalkRequest(&this->actor, &play->state)) { + this->unk_2DC(this, play); this->actionFunc = func_80BEEFA8; } else if (((this->actor.xzDistToPlayer < 100.0f) && (((this->actor.playerHeightRel < 50.0f) && (this->actor.playerHeightRel > -50.0f)) ? true : false)) || this->actor.isTargeted) { - func_800B8614(&this->actor, globalCtx, 100.0f); + func_800B8614(&this->actor, play, 100.0f); } else if (!(((this->actor.playerHeightRel < 50.0f) && (this->actor.playerHeightRel > -50.0f)) ? true : false) || !((this->actor.xzDistToPlayer < 200.0f) ? true : false)) { this->unk_338 = 4; - SubS_ChangeAnimationByInfoS(&this->skelAnime, sAnimations, 4); + SubS_ChangeAnimationByInfoS(&this->skelAnime, sAnimationInfo, 4); this->actionFunc = func_80BEEB20; } } -void func_80BEEFA8(EnAkindonuts* this, GlobalContext* globalCtx) { - u8 temp_v0 = Message_GetState(&globalCtx->msgCtx); +void func_80BEEFA8(EnAkindonuts* this, PlayState* play) { + u8 talkState = Message_GetState(&play->msgCtx); - if (temp_v0 == 5) { - if (Message_ShouldAdvance(globalCtx)) { + if (talkState == TEXT_STATE_5) { + if (Message_ShouldAdvance(play)) { if (this->unk_32C & 1) { this->unk_32C &= ~0x1; - globalCtx->msgCtx.msgMode = 0x43; - globalCtx->msgCtx.unk12023 = 4; + play->msgCtx.msgMode = 0x43; + play->msgCtx.stateTimer = 4; this->unk_33C = 0; this->actionFunc = func_80BEEE10; } else if (this->unk_32C & 0x20) { this->unk_32C &= ~0x20; this->actor.flags &= ~ACTOR_FLAG_1; this->unk_32C &= ~0x4; - globalCtx->msgCtx.msgMode = 0x43; - globalCtx->msgCtx.unk12023 = 4; + play->msgCtx.msgMode = 0x43; + play->msgCtx.stateTimer = 4; this->unk_338 = 8; this->unk_33C = 0; - SubS_ChangeAnimationByInfoS(&this->skelAnime, sAnimations, this->unk_338); + SubS_ChangeAnimationByInfoS(&this->skelAnime, sAnimationInfo, this->unk_338); this->actionFunc = func_80BEF518; } else { - this->unk_2DC(this, globalCtx); + this->unk_2DC(this, play); } } - } else if (temp_v0 == 4) { - if (Message_ShouldAdvance(globalCtx)) { - switch (globalCtx->msgCtx.choiceIndex) { + } else if (talkState == TEXT_STATE_CHOICE) { + if (Message_ShouldAdvance(play)) { + switch (play->msgCtx.choiceIndex) { case 0: this->unk_32C |= 0x8; - this->unk_2DC(this, globalCtx); + this->unk_2DC(this, play); break; case 1: func_8019F230(); this->unk_32C |= 0x10; - this->unk_2DC(this, globalCtx); + this->unk_2DC(this, play); break; } } - } else if (temp_v0 == 16) { - func_80BEE73C(this, globalCtx); + } else if (talkState == TEXT_STATE_16) { + func_80BEE73C(this, play); } } -void func_80BEF18C(EnAkindonuts* this, GlobalContext* globalCtx) { - if ((Message_GetState(&globalCtx->msgCtx) == 5) && Message_ShouldAdvance(globalCtx)) { - globalCtx->msgCtx.msgMode = 0x43; - globalCtx->msgCtx.unk12023 = 4; +void func_80BEF18C(EnAkindonuts* this, PlayState* play) { + if ((Message_GetState(&play->msgCtx) == TEXT_STATE_5) && Message_ShouldAdvance(play)) { + play->msgCtx.msgMode = 0x43; + play->msgCtx.stateTimer = 4; this->unk_33C = 0; this->actionFunc = func_80BEEE10; } } -void func_80BEF20C(EnAkindonuts* this, GlobalContext* globalCtx) { - u8 sp27 = Message_GetState(&globalCtx->msgCtx); +void func_80BEF20C(EnAkindonuts* this, PlayState* play) { + u8 talkState = Message_GetState(&play->msgCtx); s16 sp24 = this->skelAnime.curFrame; - s16 sp22 = Animation_GetLastFrame(&sAnimations[this->unk_338].animation->common); + s16 sp22 = Animation_GetLastFrame(&sAnimationInfo[this->unk_338].animation->common); if (this->unk_356 == 40) { this->unk_338 = 5; - SubS_ChangeAnimationByInfoS(&this->skelAnime, sAnimations, 5); + SubS_ChangeAnimationByInfoS(&this->skelAnime, sAnimationInfo, 5); } this->unk_356++; if ((sp24 == sp22) && (this->unk_338 == 5)) { this->unk_338 = 6; - SubS_ChangeAnimationByInfoS(&this->skelAnime, sAnimations, 6); + SubS_ChangeAnimationByInfoS(&this->skelAnime, sAnimationInfo, 6); } - if ((sp27 == 5) && Message_ShouldAdvance(globalCtx)) { + if ((talkState == TEXT_STATE_5) && Message_ShouldAdvance(play)) { if (this->unk_32C & 1) { this->unk_32C &= ~0x1; - globalCtx->msgCtx.msgMode = 0x43; - globalCtx->msgCtx.unk12023 = 4; + play->msgCtx.msgMode = 0x43; + play->msgCtx.stateTimer = 4; this->actionFunc = func_80BEF360; } else { - this->unk_2DC(this, globalCtx); + this->unk_2DC(this, play); } } } -void func_80BEF360(EnAkindonuts* this, GlobalContext* globalCtx) { +void func_80BEF360(EnAkindonuts* this, PlayState* play) { if (this->unk_32C & 0x40) { - if (Actor_HasParent(&this->actor, globalCtx)) { + if (Actor_HasParent(&this->actor, play)) { this->actor.parent = NULL; - func_801159EC(this->unk_364); + Rupees_ChangeBy(this->unk_364); this->unk_32C &= ~0x40; this->actionFunc = func_80BEF450; } else { - Actor_PickUp(&this->actor, globalCtx, func_80BED034(this), 300.0f, 300.0f); + Actor_PickUp(&this->actor, play, func_80BED034(this), 300.0f, 300.0f); } - } else if (Actor_HasParent(&this->actor, globalCtx)) { + } else if (Actor_HasParent(&this->actor, play)) { this->actor.parent = NULL; this->actionFunc = func_80BEF450; } else { - Actor_PickUp(&this->actor, globalCtx, func_80BECFBC(this), 300.0f, 300.0f); + Actor_PickUp(&this->actor, play, func_80BECFBC(this), 300.0f, 300.0f); } } -void func_80BEF450(EnAkindonuts* this, GlobalContext* globalCtx) { - if ((Message_GetState(&globalCtx->msgCtx) == 6) && Message_ShouldAdvance(globalCtx)) { - func_800B85E0(&this->actor, globalCtx, 400.0f, -1); +void func_80BEF450(EnAkindonuts* this, PlayState* play) { + if ((Message_GetState(&play->msgCtx) == TEXT_STATE_DONE) && Message_ShouldAdvance(play)) { + func_800B85E0(&this->actor, play, 400.0f, -1); this->actionFunc = func_80BEF4B8; } } -void func_80BEF4B8(EnAkindonuts* this, GlobalContext* globalCtx) { - if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { - this->unk_2DC(this, globalCtx); +void func_80BEF4B8(EnAkindonuts* this, PlayState* play) { + if (Actor_ProcessTalkRequest(&this->actor, &play->state)) { + this->unk_2DC(this, play); this->actionFunc = func_80BEEFA8; } else { - func_800B85E0(&this->actor, globalCtx, 400.0f, -1); + func_800B85E0(&this->actor, play, 400.0f, -1); } } -void func_80BEF518(EnAkindonuts* this, GlobalContext* globalCtx) { +void func_80BEF518(EnAkindonuts* this, PlayState* play) { s16 sp26 = this->skelAnime.curFrame; - s16 sp24 = Animation_GetLastFrame(&sAnimations[this->unk_338].animation->common); + s16 sp24 = Animation_GetLastFrame(&sAnimationInfo[this->unk_338].animation->common); switch (sp26) { case 10: @@ -1432,7 +1432,7 @@ void func_80BEF518(EnAkindonuts* this, GlobalContext* globalCtx) { if (sp26 == sp24) { this->unk_33E = 3; this->unk_338 = 19; - SubS_ChangeAnimationByInfoS(&this->skelAnime, sAnimations, this->unk_338); + SubS_ChangeAnimationByInfoS(&this->skelAnime, sAnimationInfo, this->unk_338); Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_NUTS_DOWN); this->unk_32C &= ~2; this->unk_32C |= 0x80; @@ -1441,7 +1441,7 @@ void func_80BEF518(EnAkindonuts* this, GlobalContext* globalCtx) { } } -void func_80BEF770(EnAkindonuts* this, GlobalContext* globalCtx) { +void func_80BEF770(EnAkindonuts* this, PlayState* play) { f32 sp24 = this->unk_358 - this->actor.world.pos.y; Vec3f sp18; @@ -1450,7 +1450,7 @@ void func_80BEF770(EnAkindonuts* this, GlobalContext* globalCtx) { sp18.x = this->actor.world.pos.x; sp18.y = this->unk_358; sp18.z = this->actor.world.pos.z; - func_800B14D4(globalCtx, 20.0f, &sp18); + func_800B14D4(play, 20.0f, &sp18); } if (sp24 > 5.0f) { @@ -1462,10 +1462,10 @@ void func_80BEF770(EnAkindonuts* this, GlobalContext* globalCtx) { } } -void func_80BEF83C(EnAkindonuts* this, GlobalContext* globalCtx) { +void func_80BEF83C(EnAkindonuts* this, PlayState* play) { Vec3f sp34; s16 sp32 = this->skelAnime.curFrame; - s16 sp30 = Animation_GetLastFrame(&sAnimations[this->unk_338].animation->common); + s16 sp30 = Animation_GetLastFrame(&sAnimationInfo[this->unk_338].animation->common); if (sp32 == sp30) { Math_SmoothStepToS(&this->unk_362, 0x1C71, 3, 0x100, 0); @@ -1479,25 +1479,25 @@ void func_80BEF83C(EnAkindonuts* this, GlobalContext* globalCtx) { if (DECR(this->unk_33A) == 0) { if (!(this->unk_35C & 3)) { sp34 = this->actor.world.pos; - func_800B14D4(globalCtx, 20.0f, &sp34); + func_800B14D4(play, 20.0f, &sp34); } this->actor.velocity.y = 5.0f; } else if (!(this->unk_35C & 3)) { sp34.x = this->actor.world.pos.x; sp34.y = this->unk_358; sp34.z = this->actor.world.pos.z; - func_800B14D4(globalCtx, 20.0f, &sp34); + func_800B14D4(play, 20.0f, &sp34); } if ((this->actor.home.pos.y + 22.5f) < this->actor.world.pos.y) { this->unk_34C = 0.3f; this->unk_338 = 9; - SubS_ChangeAnimationByInfoS(&this->skelAnime, sAnimations, this->unk_338); + SubS_ChangeAnimationByInfoS(&this->skelAnime, sAnimationInfo, this->unk_338); Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_AKINDONUTS_HIDE); this->actionFunc = func_80BEF9F0; } } -void func_80BEF9F0(EnAkindonuts* this, GlobalContext* globalCtx) { +void func_80BEF9F0(EnAkindonuts* this, PlayState* play) { this->unk_352 += this->unk_362; if (this->unk_34C >= 1.0f) { this->unk_34C = 1.0f; @@ -1510,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; - SubS_ChangeAnimationByInfoS(&this->skelAnime, sAnimations, this->unk_338); + SubS_ChangeAnimationByInfoS(&this->skelAnime, sAnimationInfo, this->unk_338); if (ENAKINDONUTS_GET_3(&this->actor) == ENAKINDONUTS_3_2) { this->unk_32C |= 0x2; } @@ -1519,7 +1519,7 @@ void func_80BEF9F0(EnAkindonuts* this, GlobalContext* globalCtx) { } } -void func_80BEFAF0(EnAkindonuts* this, GlobalContext* globalCtx) { +void func_80BEFAF0(EnAkindonuts* this, PlayState* play) { Vec3s sp38; f32 sp34; s16 sp32 = false; @@ -1585,19 +1585,19 @@ void func_80BEFAF0(EnAkindonuts* this, GlobalContext* globalCtx) { this->unk_356++; } -void func_80BEFD74(EnAkindonuts* this, GlobalContext* globalCtx) { +void func_80BEFD74(EnAkindonuts* this, PlayState* play) { Actor_MarkForDeath(&this->actor); } -void EnAkindonuts_Init(Actor* thisx, GlobalContext* globalCtx) { +void EnAkindonuts_Init(Actor* thisx, PlayState* play) { s32 pad; EnAkindonuts* this = THIS; Actor_ProcessInitChain(&this->actor, sInitChain); - SkelAnime_InitFlex(globalCtx, &this->skelAnime, &object_dnt_Skel_00AC70, &object_dnt_Anim_005488, this->jointTable, + SkelAnime_InitFlex(play, &this->skelAnime, &object_dnt_Skel_00AC70, &object_dnt_Anim_005488, this->jointTable, this->morphTable, 28); - Collider_InitCylinder(globalCtx, &this->collider); - Collider_SetCylinderType1(globalCtx, &this->collider, &this->actor, &sCylinderInit); + Collider_InitCylinder(play, &this->collider); + Collider_SetCylinderType1(play, &this->collider, &this->actor, &sCylinderInit); ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 35.0f); Actor_SetScale(&this->actor, 0.01f); @@ -1606,45 +1606,44 @@ void EnAkindonuts_Init(Actor* thisx, GlobalContext* globalCtx) { this->actor.gravity = -1.0f; if (!ENAKINDONUTS_GET_4(&this->actor)) { - this->path = SubS_GetPathByIndex(globalCtx, ENAKINDONUTS_GET_FC00(&this->actor), 0x3F); + this->path = SubS_GetPathByIndex(play, ENAKINDONUTS_GET_FC00(&this->actor), 0x3F); if (this->path == NULL) { Actor_MarkForDeath(&this->actor); return; } } - SubS_ChangeAnimationByInfoS(&this->skelAnime, sAnimations, 4); + SubS_ChangeAnimationByInfoS(&this->skelAnime, sAnimationInfo, 4); this->unk_32C |= 0x2; this->unk_32C |= 0x4; this->unk_338 = 4; this->cutscene = this->actor.cutscene; - func_80BEE938(this, globalCtx); + func_80BEE938(this, play); this->actionFunc = func_80BEEB20; } -void EnAkindonuts_Destroy(Actor* thisx, GlobalContext* globalCtx) { +void EnAkindonuts_Destroy(Actor* thisx, PlayState* play) { EnAkindonuts* this = THIS; - Collider_DestroyCylinder(globalCtx, &this->collider); + Collider_DestroyCylinder(play, &this->collider); } -void EnAkindonuts_Update(Actor* thisx, GlobalContext* globalCtx) { +void EnAkindonuts_Update(Actor* thisx, PlayState* play) { EnAkindonuts* this = THIS; Actor_SetFocus(&this->actor, 60.0f); SkelAnime_Update(&this->skelAnime); Actor_MoveWithGravity(&this->actor); - this->actionFunc(this, globalCtx); + this->actionFunc(this, play); if (this->unk_32C & 0x80) { func_800B9010(&this->actor, NA_SE_EN_AKINDO_FLY - SFX_FLAG); } - func_80BECC7C(this, globalCtx); + func_80BECC7C(this, play); } -s32 EnAkindonuts_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, - Actor* thisx) { +s32 EnAkindonuts_OverrideLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, Actor* thisx) { EnAkindonuts* this = THIS; if (((this->unk_338 == 4) && (this->unk_33E == 0)) || ((this->unk_338 == 8) && (this->unk_33E == 0)) || @@ -1684,10 +1683,10 @@ s32 EnAkindonuts_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** return false; } -void EnAkindonuts_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx) { +void EnAkindonuts_PostLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx) { } -void EnAkindonuts_TransformLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Actor* thisx) { +void EnAkindonuts_TransformLimbDraw(PlayState* play, s32 limbIndex, Actor* thisx) { EnAkindonuts* this = THIS; if (((this->unk_33E == 1) || (this->unk_33E == 2)) && ((limbIndex == 23) || (limbIndex == 24))) { @@ -1699,15 +1698,15 @@ 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); } } -void EnAkindonuts_Draw(Actor* thisx, GlobalContext* globalCtx) { +void EnAkindonuts_Draw(Actor* thisx, PlayState* play) { EnAkindonuts* this = THIS; - func_8012C28C(globalCtx->state.gfxCtx); - SkelAnime_DrawTransformFlexOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, + func_8012C28C(play->state.gfxCtx); + SkelAnime_DrawTransformFlexOpa(play, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, EnAkindonuts_OverrideLimbDraw, EnAkindonuts_PostLimbDraw, EnAkindonuts_TransformLimbDraw, &this->actor); } diff --git a/src/overlays/actors/ovl_En_Akindonuts/z_en_akindonuts.h b/src/overlays/actors/ovl_En_Akindonuts/z_en_akindonuts.h index e5d134f45..ec0446f95 100644 --- a/src/overlays/actors/ovl_En_Akindonuts/z_en_akindonuts.h +++ b/src/overlays/actors/ovl_En_Akindonuts/z_en_akindonuts.h @@ -5,8 +5,8 @@ struct EnAkindonuts; -typedef void (*EnAkindonutsActionFunc)(struct EnAkindonuts*, GlobalContext*); -typedef void (*EnAkindonutsUnkFunc)(struct EnAkindonuts*, GlobalContext*); +typedef void (*EnAkindonutsActionFunc)(struct EnAkindonuts*, PlayState*); +typedef void (*EnAkindonutsUnkFunc)(struct EnAkindonuts*, PlayState*); #define ENAKINDONUTS_GET_3(thisx) ((thisx)->params & 3) #define ENAKINDONUTS_GET_4(thisx) (((thisx)->params & 4) >> 2) @@ -18,36 +18,36 @@ enum { }; typedef struct EnAkindonuts { - /* 0x0000 */ Actor actor; - /* 0x0144 */ SkelAnime skelAnime; - /* 0x0188 */ Vec3s jointTable[28]; - /* 0x0230 */ Vec3s morphTable[28]; - /* 0x02D8 */ EnAkindonutsActionFunc actionFunc; - /* 0x02DC */ EnAkindonutsUnkFunc unk_2DC; - /* 0x02E0 */ ColliderCylinder collider; - /* 0x032C */ u16 unk_32C; - /* 0x0330 */ Path* path; - /* 0x0334 */ s32 unk_334; - /* 0x0338 */ s16 unk_338; - /* 0x033A */ s16 unk_33A; - /* 0x033C */ u16 unk_33C; - /* 0x033E */ s16 unk_33E; - /* 0x0340 */ f32 unk_340; - /* 0x0344 */ f32 unk_344; - /* 0x0348 */ f32 unk_348; - /* 0x034C */ f32 unk_34C; - /* 0x0350 */ s16 unk_350; - /* 0x0352 */ s16 unk_352; - /* 0x0354 */ UNK_TYPE1 unk354[0x2]; - /* 0x0356 */ s16 unk_356; - /* 0x0358 */ f32 unk_358; - /* 0x035C */ s16 unk_35C; - /* 0x035E */ s16 unk_35E; - /* 0x0360 */ s16 cutscene; - /* 0x0362 */ s16 unk_362; - /* 0x0364 */ s16 unk_364; - /* 0x0366 */ s8 unk_366; - /* 0x0368 */ s16 unk_368; + /* 0x000 */ Actor actor; + /* 0x144 */ SkelAnime skelAnime; + /* 0x188 */ Vec3s jointTable[28]; + /* 0x230 */ Vec3s morphTable[28]; + /* 0x2D8 */ EnAkindonutsActionFunc actionFunc; + /* 0x2DC */ EnAkindonutsUnkFunc unk_2DC; + /* 0x2E0 */ ColliderCylinder collider; + /* 0x32C */ u16 unk_32C; + /* 0x330 */ Path* path; + /* 0x334 */ s32 unk_334; + /* 0x338 */ s16 unk_338; + /* 0x33A */ s16 unk_33A; + /* 0x33C */ u16 unk_33C; + /* 0x33E */ s16 unk_33E; + /* 0x340 */ f32 unk_340; + /* 0x344 */ f32 unk_344; + /* 0x348 */ f32 unk_348; + /* 0x34C */ f32 unk_34C; + /* 0x350 */ s16 unk_350; + /* 0x352 */ s16 unk_352; + /* 0x354 */ UNK_TYPE1 unk354[0x2]; + /* 0x356 */ s16 unk_356; + /* 0x358 */ f32 unk_358; + /* 0x35C */ s16 unk_35C; + /* 0x35E */ s16 unk_35E; + /* 0x360 */ s16 cutscene; + /* 0x362 */ s16 unk_362; + /* 0x364 */ s16 unk_364; + /* 0x366 */ s8 unk_366; + /* 0x368 */ s16 unk_368; } EnAkindonuts; // size = 0x36C extern const ActorInit En_Akindonuts_InitVars; diff --git a/src/overlays/actors/ovl_En_Al/z_en_al.c b/src/overlays/actors/ovl_En_Al/z_en_al.c index e86f3971d..8792f8038 100644 --- a/src/overlays/actors/ovl_En_Al/z_en_al.c +++ b/src/overlays/actors/ovl_En_Al/z_en_al.c @@ -11,18 +11,30 @@ #define THIS ((EnAl*)thisx) -void EnAl_Init(Actor* thisx, GlobalContext* globalCtx); -void EnAl_Destroy(Actor* thisx, GlobalContext* globalCtx); -void EnAl_Update(Actor* thisx, GlobalContext* globalCtx); -void EnAl_Draw(Actor* thisx, GlobalContext* globalCtx); +void EnAl_Init(Actor* thisx, PlayState* play); +void EnAl_Destroy(Actor* thisx, PlayState* play); +void EnAl_Update(Actor* thisx, PlayState* play); +void EnAl_Draw(Actor* thisx, PlayState* play); -void func_80BDF5E8(EnAl* this, GlobalContext* globalCtx); -void func_80BDF6C4(EnAl* this, GlobalContext* globalCtx); +void func_80BDF5E8(EnAl* this, PlayState* play); +void func_80BDF6C4(EnAl* this, PlayState* play); -s32 D_80BDFC70[] = { - 0x0C00030D, 0x02120006, 0x0001050E, 0x12000600, 0x02020800, 0x0A002F02, 0x0A000A37, - 0x23020A37, 0x0B2D0D02, 0x0B2D1400, 0x01050E0B, 0x2D140001, 0x0C000206, 0x0E0A370B, - 0x2D010E0A, 0x370B2D03, 0x0E0A000A, 0x37010400, 0x01000000, +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[] = { @@ -107,7 +119,7 @@ static ColliderCylinderInit sCylinderInit = { static CollisionCheckInfoInit2 sColChkInfoInit = { 0, 0, 0, 0, MASS_IMMOVABLE }; -static AnimationInfoS sAnimations[] = { +static AnimationInfoS sAnimationInfo[] = { { &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 }, @@ -117,16 +129,17 @@ static AnimationInfoS sAnimations[] = { Vec3f D_80BE0070 = { 1000.0f, 0.0f, 0.0f }; Gfx* D_80BE007C[] = { - object_al_DL_006598, object_al_DL_005920, object_al_DL_005878, - object_al_DL_0057D0, object_al_DL_005728, object_al_DL_005680, + gMadameAromaShawlMiddleDL, gMadameAromaShawlUpperDL, + gMadameAromaShawlLeftLowerMiddleDL, gMadameAromaShawlLeftLowerDL, + gMadameAromaShawlRightLowerMiddleDL, gMadameAromaShawlRightLowerDL, }; -Actor* func_80BDE1A0(EnAl* this, GlobalContext* globalCtx, u8 arg0, s16 arg1) { +Actor* func_80BDE1A0(EnAl* this, PlayState* play, u8 arg0, s16 arg1) { Actor* foundActor = NULL; Actor* temp; while (true) { - foundActor = SubS_FindActor(globalCtx, foundActor, arg0, arg1); + foundActor = SubS_FindActor(play, foundActor, arg0, arg1); if (foundActor == NULL) { break; @@ -165,32 +178,32 @@ s32 func_80BDE27C(EnAl* this, s32 arg1) { if (phi_v1) { this->unk_4F8 = arg1; - ret = SubS_ChangeAnimationByInfoS(&this->skelAnime, sAnimations, arg1); + ret = SubS_ChangeAnimationByInfoS(&this->skelAnime, sAnimationInfo, arg1); this->unk_4C8 = this->skelAnime.playSpeed; } return ret; } -void func_80BDE318(EnAl* this, GlobalContext* globalCtx) { +void func_80BDE318(EnAl* this, PlayState* play) { s32 pad; f32 temp; 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); + CollisionCheck_SetOC(play, &play->colChkCtx, &this->unk_310.base); } -Actor* func_80BDE384(EnAl* this, GlobalContext* globalCtx) { +Actor* func_80BDE384(EnAl* this, PlayState* play) { Actor* actor; 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); + actor = func_80BDE1A0(this, play, ACTORCAT_NPC, ACTOR_EN_PM); } else { - actor = &GET_PLAYER(globalCtx)->actor; + actor = &GET_PLAYER(play)->actor; } break; @@ -199,7 +212,7 @@ Actor* func_80BDE384(EnAl* this, GlobalContext* globalCtx) { break; default: - actor = &GET_PLAYER(globalCtx)->actor; + actor = &GET_PLAYER(play)->actor; break; } @@ -302,7 +315,7 @@ s32 func_80BDE678(EnAl* this, s16* arg1, s16 arg2) { return ret; } -s32 func_80BDE7FC(EnAl* this, GlobalContext* globalCtx) { +s32 func_80BDE7FC(EnAl* this, PlayState* play) { s32 pad; s16 sp2A = func_80BDE484(this, 0); s32 pad2; @@ -319,8 +332,7 @@ s32 func_80BDE7FC(EnAl* this, GlobalContext* globalCtx) { 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); + Camera_SetTargetActor(Play_GetCamera(play, ActorCutscene_GetCurrentSubCamId(sp2A)), this->actor.child); } this->unk_4E6++; sp20 = true; @@ -330,7 +342,7 @@ s32 func_80BDE7FC(EnAl* this, GlobalContext* globalCtx) { case 3: case 5: case 7: - Camera_SetTargetActor(Play_GetCamera(globalCtx, ActorCutscene_GetCurrentCamera(sp2A)), &this->actor); + Camera_SetTargetActor(Play_GetCamera(play, ActorCutscene_GetCurrentSubCamId(sp2A)), &this->actor); this->unk_4E6++; sp20 = true; break; @@ -344,10 +356,10 @@ s32 func_80BDE7FC(EnAl* this, GlobalContext* globalCtx) { return sp20; } -s32 func_80BDE92C(EnAl* this, GlobalContext* globalCtx) { +s32 func_80BDE92C(EnAl* this, PlayState* play) { 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); + Actor* sp1C = func_80BDE1A0(this, play, ACTORCAT_NPC, ACTOR_EN_GM); + Actor* temp_v0 = func_80BDE1A0(this, play, ACTORCAT_NPC, ACTOR_EN_TOTO); if ((sp1C == NULL) || (sp1C->update == NULL) || (temp_v0 == NULL) || (temp_v0->update == NULL)) { this->unk_4E6++; @@ -391,7 +403,7 @@ s32 func_80BDE92C(EnAl* this, GlobalContext* globalCtx) { return true; } -s32 func_80BDEA14(EnAl* this, GlobalContext* globalCtx) { +s32 func_80BDEA14(EnAl* this, PlayState* play) { s32 pad; s32 sp18 = false; @@ -415,8 +427,8 @@ s32 func_80BDEA14(EnAl* this, GlobalContext* globalCtx) { return sp18; } -s32* func_80BDEABC(EnAl* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); +s32* func_80BDEABC(EnAl* this, PlayState* play) { + Player* player = GET_PLAYER(play); if (this->unk_35C == 3) { this->unk_4EC = func_80BDE92C; @@ -433,7 +445,7 @@ s32* func_80BDEABC(EnAl* this, GlobalContext* globalCtx) { return D_80BDFE8C; } - if (Player_GetMask(globalCtx) == PLAYER_MASK_KAFEIS_MASK) { + if (Player_GetMask(play) == PLAYER_MASK_KAFEIS_MASK) { return D_80BDFE7C; } return D_80BDFE84; @@ -445,7 +457,7 @@ s32* func_80BDEABC(EnAl* this, GlobalContext* globalCtx) { } this->unk_4EC = func_80BDEA14; - if (Player_GetMask(globalCtx) != PLAYER_MASK_KAFEIS_MASK) { + if (Player_GetMask(play) != PLAYER_MASK_KAFEIS_MASK) { return D_80BDFDE8; } @@ -461,11 +473,11 @@ s32* func_80BDEABC(EnAl* this, GlobalContext* globalCtx) { return NULL; } -s32 func_80BDEC2C(EnAl* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); +s32 func_80BDEC2C(EnAl* this, PlayState* play) { + Player* player = GET_PLAYER(play); s32 ret = false; - if ((this->unk_4C2 & 7) && Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { + if ((this->unk_4C2 & 7) && Actor_ProcessTalkRequest(&this->actor, &play->state)) { this->unk_4C2 &= ~0x1800; if (player->exchangeItemId == 0x33) { this->unk_4C2 |= 0x800; @@ -478,7 +490,7 @@ s32 func_80BDEC2C(EnAl* this, GlobalContext* globalCtx) { this->unk_4E6 = 0; this->unk_4EC = 0; this->actor.child = this->unk_368; - this->unk_360 = func_80BDEABC(this, globalCtx); + this->unk_360 = func_80BDEABC(this, play); this->unk_4C2 |= 0x20; this->actionFunc = func_80BDF6C4; ret = true; @@ -533,7 +545,7 @@ void func_80BDEE5C(EnAl* this) { } } -void func_80BDEF3C(EnAl* this, GlobalContext* globalCtx) { +void func_80BDEF3C(EnAl* this, PlayState* play) { if (this->unk_4E4 == 0) { func_80BDE27C(this, 7); this->unk_4C2 &= ~0x20; @@ -547,7 +559,7 @@ void func_80BDEF3C(EnAl* this, GlobalContext* globalCtx) { } } -void func_80BDEFE4(EnAl* this, GlobalContext* globalCtx) { +void func_80BDEFE4(EnAl* this, PlayState* play) { if (this->unk_4E4 == 0) { func_80BDE27C(this, 6); this->unk_4E4 += 1; @@ -557,11 +569,11 @@ void func_80BDEFE4(EnAl* this, GlobalContext* globalCtx) { } } -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); +s32 func_80BDF064(EnAl* this, PlayState* play) { + Player* player = GET_PLAYER(play); + u16 sp22 = play->msgCtx.currentTextId; + Actor* sp1C = func_80BDE1A0(this, play, 4, 0xA4); + Actor* temp_v0 = func_80BDE1A0(this, play, 4, 0x234); if (player->stateFlags1 & 0x40) { this->unk_4C2 |= 0x400; @@ -617,16 +629,16 @@ s32 func_80BDF064(EnAl* this, GlobalContext* globalCtx) { } if (this->unk_18C != NULL) { - this->unk_18C(this, globalCtx); + this->unk_18C(this, play); } return false; } -s32 func_80BDF244(EnAl* this, GlobalContext* globalCtx, struct_80133038_arg2* arg2) { +s32 func_80BDF244(EnAl* this, PlayState* play, ScheduleOutput* scheduleOutput) { 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); + Actor* sp20 = func_80BDE1A0(this, play, ACTORCAT_NPC, ACTOR_EN_GM); + Actor* temp_v0 = func_80BDE1A0(this, play, ACTORCAT_NPC, ACTOR_EN_TOTO); if ((sp20 != NULL) && (sp20->update != NULL) && (temp_v0 != NULL) && (temp_v0->update != NULL)) { func_80BDE27C(this, 0); @@ -638,16 +650,16 @@ s32 func_80BDF244(EnAl* this, GlobalContext* globalCtx, struct_80133038_arg2* ar return ret; } -s32 func_80BDF308(EnAl* this, GlobalContext* globalCtx, struct_80133038_arg2* arg2) { +s32 func_80BDF308(EnAl* this, PlayState* play, ScheduleOutput* scheduleOutput) { SubS_UpdateFlags(&this->unk_4C2, 3, 7); - switch (arg2->unk0) { + switch (scheduleOutput->result) { case 1: func_80BDE27C(this, 0); break; case 2: - this->unk_4F0 = 0; + this->unk_4F0 = PLAYER_AP_NONE; this->unk_4EA = 0; func_80BDE27C(this, 2); break; @@ -655,23 +667,23 @@ s32 func_80BDF308(EnAl* this, GlobalContext* globalCtx, struct_80133038_arg2* ar return true; } -s32 func_80BDF390(EnAl* this, GlobalContext* globalCtx, struct_80133038_arg2* arg2) { +s32 func_80BDF390(EnAl* this, PlayState* play, ScheduleOutput* scheduleOutput) { s32 ret; this->actor.flags |= ACTOR_FLAG_1; this->actor.targetMode = 0; - this->unk_4F0 = 0; + this->unk_4F0 = PLAYER_AP_NONE; this->unk_4C2 = 0; this->unk_4D4 = 40.0f; - switch (arg2->unk0) { + switch (scheduleOutput->result) { case 3: - ret = func_80BDF244(this, globalCtx, arg2); + ret = func_80BDF244(this, play, scheduleOutput); break; case 1: case 2: - ret = func_80BDF308(this, globalCtx, arg2); + ret = func_80BDF308(this, play, scheduleOutput); break; default: @@ -681,7 +693,7 @@ s32 func_80BDF390(EnAl* this, GlobalContext* globalCtx, struct_80133038_arg2* ar return ret; } -void func_80BDF414(EnAl* this, GlobalContext* globalCtx) { +void func_80BDF414(EnAl* this, PlayState* play) { s16 temp_v0; switch (this->unk_4EA) { @@ -715,45 +727,44 @@ void func_80BDF414(EnAl* this, GlobalContext* globalCtx) { } } -void func_80BDF568(EnAl* this, GlobalContext* globalCtx) { +void func_80BDF568(EnAl* this, PlayState* play) { } -void func_80BDF578(EnAl* this, GlobalContext* globalCtx) { +void func_80BDF578(EnAl* this, PlayState* play) { switch (this->unk_35C) { case 1: case 3: - func_80BDF568(this, globalCtx); + func_80BDF568(this, play); break; case 2: - func_80BDF414(this, globalCtx); + func_80BDF414(this, play); break; } Math_ApproachS(&this->actor.shape.rot.y, this->actor.world.rot.y, 3, 0x2AA8); } -void func_80BDF5E8(EnAl* this, GlobalContext* globalCtx) { - u32* unk14 = &gSaveContext.save.daySpeed; - struct_80133038_arg2 sp20; +void func_80BDF5E8(EnAl* this, PlayState* play) { + ScheduleOutput sp20; - this->unk_4E0 = REG(15) + *unk14; - if (!func_80133038(globalCtx, D_80BDFC70, &sp20) || - ((this->unk_35C != sp20.unk0) && !func_80BDF390(this, globalCtx, &sp20))) { + this->unk_4E0 = REG(15) + ((void)0, gSaveContext.save.daySpeed); + if (!Schedule_RunScript(play, D_80BDFC70, &sp20) || + ((this->unk_35C != sp20.result) && !func_80BDF390(this, play, &sp20))) { this->actor.shape.shadowDraw = NULL; this->actor.flags &= ~ACTOR_FLAG_1; - sp20.unk0 = 0; + sp20.result = 0; } else { this->actor.shape.shadowDraw = ActorShadow_DrawCircle; this->actor.flags |= ACTOR_FLAG_1; } - this->unk_35C = sp20.unk0; - this->unk_368 = func_80BDE384(this, globalCtx); - func_80BDF578(this, globalCtx); + this->unk_35C = sp20.result; + this->unk_368 = func_80BDE384(this, play); + func_80BDF578(this, play); } -void func_80BDF6C4(EnAl* this, GlobalContext* globalCtx) { - if (func_8010BF58(&this->actor, globalCtx, this->unk_360, this->unk_4EC, &this->unk_364)) { +void func_80BDF6C4(EnAl* this, PlayState* play) { + if (func_8010BF58(&this->actor, play, this->unk_360, this->unk_4EC, &this->unk_364)) { SubS_UpdateFlags(&this->unk_4C2, 3, 7); this->unk_4C2 &= ~0x20; this->unk_4C2 |= 0x200; @@ -766,149 +777,148 @@ void func_80BDF6C4(EnAl* this, GlobalContext* globalCtx) { } } -void EnAl_Init(Actor* thisx, GlobalContext* globalCtx) { +void EnAl_Init(Actor* thisx, PlayState* play) { 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); + SkelAnime_InitFlex(play, &this->skelAnime, &gMadameAromaSkel, NULL, this->jointTable, this->morphTable, + MADAME_AROMA_LIMB_MAX); this->unk_4F8 = -1; func_80BDE27C(this, 1); - Collider_InitAndSetCylinder(globalCtx, &this->unk_310, &this->actor, &sCylinderInit); + Collider_InitAndSetCylinder(play, &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); + this->actionFunc(this, play); } -void EnAl_Destroy(Actor* thisx, GlobalContext* globalCtx) { +void EnAl_Destroy(Actor* thisx, PlayState* play) { EnAl* this = THIS; - Collider_DestroyCylinder(globalCtx, &this->unk_310); + Collider_DestroyCylinder(play, &this->unk_310); } -void EnAl_Update(Actor* thisx, GlobalContext* globalCtx) { +void EnAl_Update(Actor* thisx, PlayState* play) { EnAl* this = THIS; - func_80BDEC2C(this, globalCtx); + func_80BDEC2C(this, play); - this->actionFunc(this, globalCtx); + this->actionFunc(this, play); - func_80BDF064(this, globalCtx); + func_80BDF064(this, play); 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); + func_8013C964(&this->actor, play, this->unk_4D4, 30.0f, this->unk_4F0, this->unk_4C2 & 7); + func_80BDE318(this, play); } } -s32 EnAl_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, Actor* thisx) { +s32 EnAl_OverrideLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, Actor* thisx) { switch (limbIndex) { - case 3: - case 11: - case 12: - case 13: - case 14: - case 15: + case MADAME_AROMA_LIMB_SHAWL_MIDDLE: + case MADAME_AROMA_LIMB_SHAWL_UPPER: + case MADAME_AROMA_LIMB_SHAWL_LEFT_LOWER_MIDDLE: + case MADAME_AROMA_LIMB_SHAWL_LEFT_LOWER: + case MADAME_AROMA_LIMB_SHAWL_RIGHT_LOWER_MIDDLE: + case MADAME_AROMA_LIMB_SHAWL_RIGHT_LOWER: *dList = NULL; break; - case 16: + case MADAME_AROMA_LIMB_HEAD: break; } return false; } -void EnAl_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx) { +void EnAl_PostLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx) { EnAl* this = THIS; switch (limbIndex) { - case 3: - Matrix_CopyCurrentState(&this->unk_190[0]); + case MADAME_AROMA_LIMB_SHAWL_MIDDLE: + Matrix_Get(&this->unk_190[0]); break; - case 11: - Matrix_CopyCurrentState(&this->unk_190[1]); + case MADAME_AROMA_LIMB_SHAWL_UPPER: + Matrix_Get(&this->unk_190[1]); break; - case 12: - Matrix_CopyCurrentState(&this->unk_190[2]); + case MADAME_AROMA_LIMB_SHAWL_LEFT_LOWER_MIDDLE: + Matrix_Get(&this->unk_190[2]); break; - case 13: - Matrix_CopyCurrentState(&this->unk_190[3]); + case MADAME_AROMA_LIMB_SHAWL_LEFT_LOWER: + Matrix_Get(&this->unk_190[3]); break; - case 14: - Matrix_CopyCurrentState(&this->unk_190[4]); + case MADAME_AROMA_LIMB_SHAWL_RIGHT_LOWER_MIDDLE: + Matrix_Get(&this->unk_190[4]); break; - case 15: - Matrix_CopyCurrentState(&this->unk_190[5]); + case MADAME_AROMA_LIMB_SHAWL_RIGHT_LOWER: + Matrix_Get(&this->unk_190[5]); break; - case 16: - Matrix_MultiplyVector3fByState(&D_80BE0070, &this->actor.focus.pos); + case MADAME_AROMA_LIMB_HEAD: + Matrix_MultVec3f(&D_80BE0070, &this->actor.focus.pos); Math_Vec3s_Copy(&this->actor.focus.rot, &this->actor.world.rot); break; } } -void EnAl_TransformLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Actor* thisx) { +void EnAl_TransformLimbDraw(PlayState* play, s32 limbIndex, Actor* thisx) { EnAl* this = THIS; - s32 phi_v0; - s32 phi_v1; + s32 stepRot; + s32 overrideRot; if (!(this->unk_4C2 & 0x200)) { if (this->unk_4C2 & 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 == 16) { - func_8013AD9C(this->unk_4DC + 0x4000, this->unk_4DE + this->actor.shape.rot.y + 0x4000, &this->unk_36C, - &this->unk_378, phi_v0, phi_v1); - Matrix_StatePop(); - Matrix_InsertTranslation(this->unk_36C.x, this->unk_36C.y, this->unk_36C.z, MTXMODE_NEW); + 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_RotateY(this->unk_378.y, MTXMODE_APPLY); - Matrix_InsertXRotation_s(this->unk_378.x, MTXMODE_APPLY); - Matrix_InsertZRotation_s(this->unk_378.z, MTXMODE_APPLY); - Matrix_StatePush(); + 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) { +void EnAl_Draw(Actor* thisx, PlayState* play) { EnAl* this = THIS; s32 i; if (this->unk_35C != 0) { - OPEN_DISPS(globalCtx->state.gfxCtx); + OPEN_DISPS(play->state.gfxCtx); - func_8012C28C(globalCtx->state.gfxCtx); - Matrix_InsertTranslation(0.0f, 0.0f, 850.0f, MTXMODE_APPLY); - SkelAnime_DrawTransformFlexOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, + func_8012C28C(play->state.gfxCtx); + Matrix_Translate(0.0f, 0.0f, 850.0f, MTXMODE_APPLY); + SkelAnime_DrawTransformFlexOpa(play, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, EnAl_OverrideLimbDraw, EnAl_PostLimbDraw, EnAl_TransformLimbDraw, &this->actor); for (i = 0; i < ARRAY_COUNT(this->unk_190); i++) { - Matrix_SetCurrentState(&this->unk_190[i]); + Matrix_Put(&this->unk_190[i]); - gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), - G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_OPA_DISP++, D_80BE007C[i]); } - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->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 9e5ee8872..4a92743df 100644 --- a/src/overlays/actors/ovl_En_Al/z_en_al.h +++ b/src/overlays/actors/ovl_En_Al/z_en_al.h @@ -5,44 +5,44 @@ struct EnAl; -typedef void (*EnAlActionFunc)(struct EnAl*, GlobalContext*); -typedef s32 (*EnAlUnkFunc)(struct EnAl*, GlobalContext*); -typedef void (*EnAlUnkFunc2)(struct EnAl*, GlobalContext*); +typedef void (*EnAlActionFunc)(struct EnAl*, PlayState*); +typedef s32 (*EnAlUnkFunc)(struct EnAl*, PlayState*); +typedef void (*EnAlUnkFunc2)(struct EnAl*, PlayState*); typedef struct EnAl { - /* 0x0000 */ Actor actor; - /* 0x0144 */ SkelAnime skelAnime; - /* 0x0188 */ EnAlActionFunc actionFunc; - /* 0x018C */ EnAlUnkFunc2 unk_18C; - /* 0x0190 */ MtxF unk_190[6]; - /* 0x0310 */ ColliderCylinder unk_310; - /* 0x035C */ u8 unk_35C; - /* 0x0360 */ s32* unk_360; - /* 0x0364 */ s32 unk_364; - /* 0x0368 */ Actor* unk_368; - /* 0x036C */ Vec3f unk_36C; - /* 0x0378 */ Vec3s unk_378; - /* 0x037E */ Vec3s jointTable[27]; - /* 0x0420 */ Vec3s morphTable[27]; - /* 0x04C2 */ u16 unk_4C2; - /* 0x04C4 */ u16 unk_4C4; - /* 0x04C8 */ f32 unk_4C8; - /* 0x04CC */ UNK_TYPE1 unk4CC[8]; - /* 0x04D4 */ f32 unk_4D4; - /* 0x04D8 */ UNK_TYPE1 unk4D8[4]; - /* 0x04DC */ s16 unk_4DC; - /* 0x04DE */ s16 unk_4DE; - /* 0x04E0 */ s16 unk_4E0; - /* 0x04E2 */ s16 unk_4E2; - /* 0x04E4 */ s16 unk_4E4; - /* 0x04E6 */ s16 unk_4E6; - /* 0x04E8 */ s16 unk_4E8; - /* 0x04EA */ s16 unk_4EA; - /* 0x04EC */ EnAlUnkFunc unk_4EC; - /* 0x04F0 */ s32 unk_4F0; - /* 0x04F4 */ s32 unk_4F4; - /* 0x04F8 */ s32 unk_4F8; - /* 0x04FC */ UNK_TYPE1 unk4FC[4]; + /* 0x000 */ Actor actor; + /* 0x144 */ SkelAnime skelAnime; + /* 0x188 */ EnAlActionFunc actionFunc; + /* 0x18C */ EnAlUnkFunc2 unk_18C; + /* 0x190 */ MtxF unk_190[6]; + /* 0x310 */ ColliderCylinder unk_310; + /* 0x35C */ u8 unk_35C; + /* 0x360 */ s32* unk_360; + /* 0x364 */ s32 unk_364; + /* 0x368 */ Actor* unk_368; + /* 0x36C */ Vec3f unk_36C; + /* 0x378 */ Vec3s unk_378; + /* 0x37E */ Vec3s jointTable[27]; + /* 0x420 */ Vec3s morphTable[27]; + /* 0x4C2 */ u16 unk_4C2; + /* 0x4C4 */ u16 unk_4C4; + /* 0x4C8 */ f32 unk_4C8; + /* 0x4CC */ UNK_TYPE1 unk4CC[8]; + /* 0x4D4 */ f32 unk_4D4; + /* 0x4D8 */ UNK_TYPE1 unk4D8[4]; + /* 0x4DC */ s16 unk_4DC; + /* 0x4DE */ s16 unk_4DE; + /* 0x4E0 */ s16 unk_4E0; + /* 0x4E2 */ s16 unk_4E2; + /* 0x4E4 */ s16 unk_4E4; + /* 0x4E6 */ s16 unk_4E6; + /* 0x4E8 */ s16 unk_4E8; + /* 0x4EA */ s16 unk_4EA; + /* 0x4EC */ EnAlUnkFunc unk_4EC; + /* 0x4F0 */ s32 unk_4F0; + /* 0x4F4 */ s32 unk_4F4; + /* 0x4F8 */ s32 unk_4F8; + /* 0x4FC */ UNK_TYPE1 unk4FC[4]; } EnAl; // size = 0x500 extern const ActorInit En_Al_InitVars; diff --git a/src/overlays/actors/ovl_En_Am/z_en_am.c b/src/overlays/actors/ovl_En_Am/z_en_am.c index c5b9381f6..5b1b488cb 100644 --- a/src/overlays/actors/ovl_En_Am/z_en_am.c +++ b/src/overlays/actors/ovl_En_Am/z_en_am.c @@ -12,30 +12,30 @@ #define THIS ((EnAm*)thisx) -void EnAm_Init(Actor* thisx, GlobalContext* globalCtx); -void EnAm_Destroy(Actor* thisx, GlobalContext* globalCtx); -void EnAm_Update(Actor* thisx, GlobalContext* globalCtx); -void EnAm_Draw(Actor* thisx, GlobalContext* globalCtx); +void EnAm_Init(Actor* thisx, PlayState* play); +void EnAm_Destroy(Actor* thisx, PlayState* play); +void EnAm_Update(Actor* thisx, PlayState* play); +void EnAm_Draw(Actor* thisx, PlayState* play); void func_808AFF9C(EnAm* this); -void EnAm_RemoveEnemyTexture(EnAm* this, GlobalContext* globalCtx); +void EnAm_RemoveEnemyTexture(EnAm* this, PlayState* play); void EnAm_WakeUp(EnAm* this); -void EnAm_ApplyEnemyTexture(EnAm* this, GlobalContext* globalCtx); +void EnAm_ApplyEnemyTexture(EnAm* this, PlayState* play); void func_808B0358(EnAm* this); -void func_808B03C0(EnAm* this, GlobalContext* globalCtx); +void func_808B03C0(EnAm* this, PlayState* play); void func_808B0460(EnAm* this); -void func_808B04A8(EnAm* this, GlobalContext* globalCtx); -void func_808B0508(EnAm* this, GlobalContext* globalCtx); +void func_808B04A8(EnAm* this, PlayState* play); +void func_808B0508(EnAm* this, PlayState* play); void func_808B057C(EnAm* this); -void func_808B05C8(EnAm* this, GlobalContext* globalCtx); +void func_808B05C8(EnAm* this, PlayState* play); 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_808B066C(EnAm* this, PlayState* play); +void EnAm_TakeDamage(EnAm* this, PlayState* play); +void func_808B07A8(EnAm* this, PlayState* play); 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); +void func_808B0894(EnAm* this, PlayState* play); +void func_808B0B4C(EnAm* this, PlayState* play); +void EnAm_PostLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* actor); const ActorInit En_Am_InitVars = { ACTOR_EN_AM, @@ -162,15 +162,15 @@ static Vec3f D_808B117C[] = { { 800.0f, -1000.0f, -1000.0f }, }; -void EnAm_Init(Actor* thisx, GlobalContext* globalCtx) { +void EnAm_Init(Actor* thisx, PlayState* play) { EnAm* this = THIS; 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, + SkelAnime_Init(play, &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); + Collider_InitAndSetCylinder(play, &this->enemyCollider, &this->actor, &sEnemyCylinderInit); + Collider_InitAndSetCylinder(play, &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); @@ -179,14 +179,14 @@ void EnAm_Init(Actor* thisx, GlobalContext* globalCtx) { func_808AFF9C(this); } -void EnAm_Destroy(Actor* thisx, GlobalContext* globalCtx) { +void EnAm_Destroy(Actor* thisx, PlayState* play) { EnAm* this = THIS; - Collider_DestroyCylinder(globalCtx, &this->enemyCollider); - Collider_DestroyCylinder(globalCtx, &this->interactCollider); + Collider_DestroyCylinder(play, &this->enemyCollider); + Collider_DestroyCylinder(play, &this->interactCollider); } -void EnAm_SpawnEffects(EnAm* this, GlobalContext* globalCtx) { +void EnAm_SpawnEffects(EnAm* this, PlayState* play) { s32 i; Vec3f effectPos; s32 pad; @@ -196,16 +196,16 @@ void EnAm_SpawnEffects(EnAm* this, GlobalContext* globalCtx) { 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); + EffectSsKirakira_SpawnSmall(play, &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); + Actor_SpawnFloorDustRing(play, &this->actor, &this->actor.world.pos, 4.0f, 3, 8.0f, 300, 15, 0); } void func_808AFF9C(EnAm* this) { f32 lastFrame = Animation_GetLastFrame(&gArmosPushedBackAnim); - Animation_Change(&this->skelAnime, &gArmosPushedBackAnim, 0.0f, lastFrame, lastFrame, 0, 0.0f); + Animation_Change(&this->skelAnime, &gArmosPushedBackAnim, 0.0f, lastFrame, lastFrame, ANIMMODE_LOOP, 0.0f); this->enemyCollider.info.bumper.dmgFlags = 0x80000088; this->interactCollider.info.bumper.dmgFlags = 0x77CFFF77; if (this->actor.colChkInfo.health != 0) { @@ -215,7 +215,7 @@ void func_808AFF9C(EnAm* this) { this->actionFunc = EnAm_RemoveEnemyTexture; } -void EnAm_RemoveEnemyTexture(EnAm* this, GlobalContext* globalCtx) { +void EnAm_RemoveEnemyTexture(EnAm* this, PlayState* play) { if (((this->enemyCollider.base.ocFlags1 & OC1_HIT) && (this->enemyCollider.base.ocFlags2 & OC2_HIT_PLAYER)) || (this->interactCollider.base.acFlags & AC_HIT)) { if (this->textureBlend == 0) { @@ -237,7 +237,7 @@ void EnAm_WakeUp(EnAm* this) { this->actionFunc = EnAm_ApplyEnemyTexture; } -void EnAm_ApplyEnemyTexture(EnAm* this, GlobalContext* globalCtx) { +void EnAm_ApplyEnemyTexture(EnAm* this, PlayState* play) { s32 tempTextureBlend; f32 cos; u8 pad; @@ -263,7 +263,7 @@ void EnAm_ApplyEnemyTexture(EnAm* this, GlobalContext* globalCtx) { } } -void func_808B0208(EnAm* this, GlobalContext* globalCtx) { +void func_808B0208(EnAm* this, PlayState* play) { // If the armos is against a wall, rotate and turn away from it if ((this->actor.speedXZ > 0.0f) && (this->actor.bgCheckFlags & 8)) { this->actor.world.rot.y = (this->actor.wallYaw * 2) - this->actor.world.rot.y; @@ -281,7 +281,7 @@ void func_808B0208(EnAm* this, GlobalContext* globalCtx) { Math_ScaledStepToS(&this->actor.world.rot.y, this->armosYaw, 0x1F40); this->actor.speedXZ = 0.0f; if (this->actor.bgCheckFlags & 2) { - EnAm_SpawnEffects(this, globalCtx); + EnAm_SpawnEffects(this, play); } } } @@ -299,9 +299,9 @@ void func_808B0358(EnAm* this) { this->actionFunc = func_808B03C0; } -void func_808B03C0(EnAm* this, GlobalContext* globalCtx) { +void func_808B03C0(EnAm* this, PlayState* play) { this->armosYaw = this->actor.yawTowardsPlayer; - func_808B0208(this, globalCtx); + func_808B0208(this, play); if (this->actor.bgCheckFlags & 2) { this->explodeTimer--; } @@ -319,8 +319,8 @@ void func_808B0460(EnAm* this) { this->actionFunc = func_808B04A8; } -void func_808B04A8(EnAm* this, GlobalContext* globalCtx) { - func_808B0208(this, globalCtx); +void func_808B04A8(EnAm* this, PlayState* play) { + func_808B0208(this, play); if (this->armosYaw == this->actor.world.rot.y) { func_808B057C(this); } @@ -332,8 +332,8 @@ void func_808B04E4(EnAm* this) { this->actionFunc = func_808B0508; } -void func_808B0508(EnAm* this, GlobalContext* globalCtx) { - func_808B0208(this, globalCtx); +void func_808B0508(EnAm* this, PlayState* play) { + func_808B0208(this, play); 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); @@ -350,9 +350,9 @@ void func_808B057C(EnAm* this) { this->actionFunc = func_808B05C8; } -void func_808B05C8(EnAm* this, GlobalContext* globalCtx) { +void func_808B05C8(EnAm* this, PlayState* play) { this->armosYaw = Actor_YawToPoint(&this->actor, &this->actor.home.pos); - func_808B0208(this, globalCtx); + func_808B0208(this, play); if (Actor_XZDistanceToPoint(&this->actor, &this->actor.home.pos) < 8.0f) { func_808B04E4(this); } @@ -365,12 +365,12 @@ void func_808B0640(EnAm* this) { this->actionFunc = func_808B066C; } -void func_808B066C(EnAm* this, GlobalContext* globalCtx) { +void func_808B066C(EnAm* this, PlayState* play) { if (this->explodeTimer != 0) { this->explodeTimer--; } else { this->armosYaw = this->actor.yawTowardsPlayer; - func_808B0208(this, globalCtx); + func_808B0208(this, play); if (this->armosYaw == this->actor.shape.rot.y) { Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_AMOS_VOICE); func_808B0358(this); @@ -378,9 +378,9 @@ void func_808B066C(EnAm* this, GlobalContext* globalCtx) { } } -void EnAm_TakeDamage(EnAm* this, GlobalContext* globalCtx) { +void EnAm_TakeDamage(EnAm* this, PlayState* play) { Animation_Change(&this->skelAnime, &gArmosTakeDamageAnim, 1.0f, 4.0f, - Animation_GetLastFrame(&gArmosTakeDamageAnim) - 6, 2, 0.0f); + Animation_GetLastFrame(&gArmosTakeDamageAnim) - 6, ANIMMODE_ONCE, 0.0f); func_800BE504(&this->actor, &this->enemyCollider); this->actor.speedXZ = 6.0f; Actor_SetColorFilter(&this->actor, 0x4000, 0xFF, 0, Animation_GetLastFrame(&gArmosTakeDamageAnim) - 10); @@ -390,7 +390,7 @@ void EnAm_TakeDamage(EnAm* this, GlobalContext* globalCtx) { this->actionFunc = func_808B07A8; } -void func_808B07A8(EnAm* this, GlobalContext* globalCtx) { +void func_808B07A8(EnAm* this, PlayState* play) { Math_StepToF(&this->actor.speedXZ, 0.0f, 0.5f); if (SkelAnime_Update(&this->skelAnime)) { if (this->actor.colChkInfo.health == 0) { @@ -412,29 +412,29 @@ void func_808B0820(EnAm* this) { this->actionFunc = func_808B0894; } -void func_808B0894(EnAm* this, GlobalContext* globalCtx) { +void func_808B0894(EnAm* this, PlayState* play) { s32 i; Vec3f dustPos; s32 pad; this->explodeTimer--; this->armosYaw = this->actor.yawTowardsPlayer; - func_808B0208(this, globalCtx); + func_808B0208(this, play); if (this->explodeTimer == 1) { - EnBom* bomb = (EnBom*)Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_BOM, this->actor.world.pos.x, + EnBom* bomb = (EnBom*)Actor_Spawn(&play->actorCtx, play, ACTOR_EN_BOM, this->actor.world.pos.x, this->actor.world.pos.y, this->actor.world.pos.z, 0, 0, 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); + Item_DropCollectibleRandom(play, &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); + func_800B0EB0(play, &dustPos, &gZeroVec3f, &gZeroVec3f, &D_808B1120, &D_808B1124, 200, 45, 12); } } else if (this->explodeTimer == 0) { Actor_MarkForDeath(&this->actor); @@ -448,26 +448,26 @@ void func_808B0894(EnAm* this, GlobalContext* globalCtx) { 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); +void func_808B0AD0(EnAm* this, PlayState* play) { + Animation_Change(&this->skelAnime, &gArmosPushedBackAnim, 1.0f, 0.0f, 8.0f, ANIMMODE_ONCE, 0.0f); this->actor.world.rot.y = this->actor.yawTowardsPlayer; this->actor.speedXZ = -6.0f; this->actionFunc = func_808B0B4C; } -void func_808B0B4C(EnAm* this, GlobalContext* globalCtx) { +void func_808B0B4C(EnAm* this, PlayState* play) { Math_StepToF(&this->actor.speedXZ, 0.0f, 0.5f); if (SkelAnime_Update(&this->skelAnime)) { func_808B0358(this); } } -s32 EnAm_UpdateDamage(EnAm* this, GlobalContext* globalCtx) { +s32 EnAm_UpdateDamage(EnAm* this, PlayState* play) { 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); + Enemy_StartFinishingBlow(play, &this->actor); } if (this->actor.colChkInfo.damageEffect == 0xD) { return true; @@ -479,54 +479,54 @@ s32 EnAm_UpdateDamage(EnAm* this, GlobalContext* globalCtx) { 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, + Actor_Spawn(&play->actorCtx, play, 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); + EnAm_TakeDamage(this, play); return true; } return false; } -void EnAm_Update(Actor* thisx, GlobalContext* globalCtx) { +void EnAm_Update(Actor* thisx, PlayState* play) { EnAm* this = THIS; s32 pad; - if (EnAm_UpdateDamage(this, globalCtx) == false) { + if (EnAm_UpdateDamage(this, play) == 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); + func_808B0AD0(this, play); } } } if (this->returnHomeTimer != 0) { this->returnHomeTimer--; } - this->actionFunc(this, globalCtx); + this->actionFunc(this, play); Actor_MoveWithGravity(&this->actor); - Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 30.0f, 30.0f, 100.0f, 0x1D); + Actor_UpdateBgCheckInfo(play, &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); + CollisionCheck_SetOC(play, &play->colChkCtx, &this->enemyCollider.base); if (this->enemyCollider.base.acFlags & AC_ON) { - CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->enemyCollider.base); + CollisionCheck_SetAC(play, &play->colChkCtx, &this->enemyCollider.base); } - CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->interactCollider.base); + CollisionCheck_SetAC(play, &play->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); + CollisionCheck_SetAT(play, &play->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) { +void EnAm_PostLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx) { s32 i; s32 phi_s3; Vec3f* phi_s1; @@ -551,22 +551,22 @@ void EnAm_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec phi_s3 = 0; } for (i = 0; i < phi_s3; i++, phi_s2++, phi_s1++) { - Matrix_MultiplyVector3fByState(phi_s1, phi_s2); + Matrix_MultVec3f(phi_s1, phi_s2); } } -void EnAm_Draw(Actor* thisx, GlobalContext* globalCtx) { +void EnAm_Draw(Actor* thisx, PlayState* play) { Gfx* gfx; EnAm* this = THIS; - OPEN_DISPS(globalCtx->state.gfxCtx); + OPEN_DISPS(play->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, + SkelAnime_DrawOpa(play, 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); + Actor_DrawDamageEffects(play, &this->actor, this->limbPos, ARRAY_COUNT(this->limbPos), this->drawDmgEffScale, 0.0f, + this->drawDmgEffAlpha, ACTOR_DRAW_DMGEFF_LIGHT_ORBS); + CLOSE_DISPS(play->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 2199a832f..79d3a81bd 100644 --- a/src/overlays/actors/ovl_En_Am/z_en_am.h +++ b/src/overlays/actors/ovl_En_Am/z_en_am.h @@ -6,25 +6,25 @@ struct EnAm; -typedef void (*EnAmActionFunc)(struct EnAm*, GlobalContext*); +typedef void (*EnAmActionFunc)(struct EnAm*, PlayState*); typedef struct EnAm { - /* 0x0000 */ Actor actor; - /* 0x0144 */ SkelAnime skelAnime; - /* 0x0188 */ Vec3s jointTable[OBJECT_AM_LIMB_MAX]; - /* 0x01DC */ Vec3s morphTable[OBJECT_AM_LIMB_MAX]; - /* 0x0230 */ EnAmActionFunc actionFunc; - /* 0x0234 */ u8 textureBlend; // 0 = statue textures; 255 = enemy textures - /* 0x0236 */ s16 explodeTimer; // timer counting down till armos explodes - /* 0x0238 */ s16 returnHomeTimer; // Timer that counts down till an armos will return to its spawn position - /* 0x023A */ s16 unkFlag; - /* 0x023C */ s16 armosYaw; // Yaw of Armos - /* 0x0240 */ f32 speed; // Hopping speed of Armos - /* 0x0244 */ f32 drawDmgEffAlpha; - /* 0x0248 */ f32 drawDmgEffScale; - /* 0x024C */ Vec3f limbPos[13]; - /* 0x02E8 */ ColliderCylinder enemyCollider; // Collider for when Armos is Hostile - /* 0x0334 */ ColliderCylinder interactCollider; // Collider for when an interactable Armos is docile + /* 0x000 */ Actor actor; + /* 0x144 */ SkelAnime skelAnime; + /* 0x188 */ Vec3s jointTable[OBJECT_AM_LIMB_MAX]; + /* 0x1DC */ Vec3s morphTable[OBJECT_AM_LIMB_MAX]; + /* 0x230 */ EnAmActionFunc actionFunc; + /* 0x234 */ u8 textureBlend; // 0 = statue textures; 255 = enemy textures + /* 0x236 */ s16 explodeTimer; // timer counting down till armos explodes + /* 0x238 */ s16 returnHomeTimer; // Timer that counts down till an armos will return to its spawn position + /* 0x23A */ s16 unkFlag; + /* 0x23C */ s16 armosYaw; // Yaw of Armos + /* 0x240 */ f32 speed; // Hopping speed of Armos + /* 0x244 */ f32 drawDmgEffAlpha; + /* 0x248 */ f32 drawDmgEffScale; + /* 0x24C */ Vec3f limbPos[13]; + /* 0x2E8 */ ColliderCylinder enemyCollider; // Collider for when Armos is Hostile + /* 0x334 */ ColliderCylinder interactCollider; // Collider for when an interactable Armos is docile } EnAm; // size = 0x380 extern const ActorInit En_Am_InitVars; diff --git a/src/overlays/actors/ovl_En_An/z_en_an.c b/src/overlays/actors/ovl_En_An/z_en_an.c index 9144d34fa..33638774e 100644 --- a/src/overlays/actors/ovl_En_An/z_en_an.c +++ b/src/overlays/actors/ovl_En_An/z_en_an.c @@ -10,13 +10,13 @@ #define THIS ((EnAn*)thisx) -void EnAn_Init(Actor* thisx, GlobalContext* globalCtx); -void EnAn_Destroy(Actor* thisx, GlobalContext* globalCtx); -void EnAn_Update(Actor* thisx, GlobalContext* globalCtx); +void EnAn_Init(Actor* thisx, PlayState* play); +void EnAn_Destroy(Actor* thisx, PlayState* play); +void EnAn_Update(Actor* thisx, PlayState* play); -void func_80B577F0(EnAn* this, GlobalContext* globalCtx); -void func_80B578F8(EnAn* this, GlobalContext* globalCtx); -void func_80B57A44(EnAn* this, GlobalContext* globalCtx); +void func_80B577F0(EnAn* this, PlayState* play); +void func_80B578F8(EnAn* this, PlayState* play); +void func_80B57A44(EnAn* this, PlayState* play); #if 0 const ActorInit En_An_InitVars = { diff --git a/src/overlays/actors/ovl_En_An/z_en_an.h b/src/overlays/actors/ovl_En_An/z_en_an.h index 67328bacd..c4d2dd5ae 100644 --- a/src/overlays/actors/ovl_En_An/z_en_an.h +++ b/src/overlays/actors/ovl_En_An/z_en_an.h @@ -5,13 +5,13 @@ struct EnAn; -typedef void (*EnAnActionFunc)(struct EnAn*, GlobalContext*); +typedef void (*EnAnActionFunc)(struct EnAn*, PlayState*); typedef struct EnAn { - /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x44]; - /* 0x0188 */ EnAnActionFunc actionFunc; - /* 0x018C */ char unk_18C[0x23C]; + /* 0x000 */ Actor actor; + /* 0x144 */ char unk_144[0x44]; + /* 0x188 */ EnAnActionFunc actionFunc; + /* 0x18C */ char unk_18C[0x23C]; } EnAn; // size = 0x3C8 extern const ActorInit En_An_InitVars; diff --git a/src/overlays/actors/ovl_En_And/z_en_and.c b/src/overlays/actors/ovl_En_And/z_en_and.c index 437bd1750..04c461908 100644 --- a/src/overlays/actors/ovl_En_And/z_en_and.c +++ b/src/overlays/actors/ovl_En_And/z_en_and.c @@ -10,12 +10,12 @@ #define THIS ((EnAnd*)thisx) -void EnAnd_Init(Actor* thisx, GlobalContext* globalCtx); -void EnAnd_Destroy(Actor* thisx, GlobalContext* globalCtx); -void EnAnd_Update(Actor* thisx, GlobalContext* globalCtx); -void EnAnd_Draw(Actor* thisx, GlobalContext* globalCtx); +void EnAnd_Init(Actor* thisx, PlayState* play); +void EnAnd_Destroy(Actor* thisx, PlayState* play); +void EnAnd_Update(Actor* thisx, PlayState* play); +void EnAnd_Draw(Actor* thisx, PlayState* play); -void func_80C18C50(EnAnd* this, GlobalContext* globalCtx); +void func_80C18C50(EnAnd* this, PlayState* play); #if 0 const ActorInit En_And_InitVars = { diff --git a/src/overlays/actors/ovl_En_And/z_en_and.h b/src/overlays/actors/ovl_En_And/z_en_and.h index 6cb598223..0ebd1a743 100644 --- a/src/overlays/actors/ovl_En_And/z_en_and.h +++ b/src/overlays/actors/ovl_En_And/z_en_and.h @@ -5,13 +5,13 @@ struct EnAnd; -typedef void (*EnAndActionFunc)(struct EnAnd*, GlobalContext*); +typedef void (*EnAndActionFunc)(struct EnAnd*, PlayState*); typedef struct EnAnd { - /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x44]; - /* 0x0188 */ EnAndActionFunc actionFunc; - /* 0x018C */ char unk_18C[0x188]; + /* 0x000 */ Actor actor; + /* 0x144 */ char unk_144[0x44]; + /* 0x188 */ EnAndActionFunc actionFunc; + /* 0x18C */ char unk_18C[0x188]; } EnAnd; // size = 0x314 extern const ActorInit En_And_InitVars; diff --git a/src/overlays/actors/ovl_En_Ani/z_en_ani.c b/src/overlays/actors/ovl_En_Ani/z_en_ani.c index 43e9de4f0..88ddcd0f8 100644 --- a/src/overlays/actors/ovl_En_Ani/z_en_ani.c +++ b/src/overlays/actors/ovl_En_Ani/z_en_ani.c @@ -19,25 +19,25 @@ #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); +void EnAni_Init(Actor* thisx, PlayState* play); +void EnAni_Destroy(Actor* thisx, PlayState* play); +void EnAni_Update(Actor* thisx, PlayState* play); +void EnAni_Draw(Actor* thisx, PlayState* play); 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_SetText(EnAni* this, PlayState* play, 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); +void EnAni_HangInTree(EnAni* this, PlayState* play); +void EnAni_LoseBalance(EnAni* this, PlayState* play); +void EnAni_FallToGround(EnAni* this, PlayState* play); +void EnAni_LandOnFoot(EnAni* this, PlayState* play); +void EnAni_FallOverInPain(EnAni* this, PlayState* play); +void EnAni_IdleInPain(EnAni* this, PlayState* play); +void EnAni_Talk(EnAni* this, PlayState* play); +void EnAni_IdleStanding(EnAni* this, PlayState* play); const ActorInit En_Ani_InitVars = { ACTOR_EN_ANI, @@ -110,17 +110,17 @@ void EnAni_WaitForEyeOpen(EnAni* this) { } } -void EnAni_Init(Actor* thisx, GlobalContext* globalCtx) { +void EnAni_Init(Actor* thisx, PlayState* play) { s32 pad; EnAni* this = THIS; 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, + SkelAnime_InitFlex(play, &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_InitAndSetCylinder(play, &this->collider1, &this->actor, &sCylinderInit); + Collider_InitAndSetCylinder(play, &this->collider2, &this->actor, &sCylinderInit); Collider_UpdateCylinder(&this->actor, &this->collider2); this->actor.colChkInfo.mass = MASS_IMMOVABLE; this->stateFlags = ANI_STATE_STANDING; @@ -128,7 +128,7 @@ void EnAni_Init(Actor* thisx, GlobalContext* globalCtx) { this->treeReachTimer = 0; this->blinkFunc = EnAni_DefaultBlink; - if (GET_ANI_TYPE(thisx) == ANI_TYPE_TREE_HANGING) { + if (ANI_GET_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; @@ -151,46 +151,46 @@ void EnAni_Init(Actor* thisx, GlobalContext* globalCtx) { } } -void EnAni_Destroy(Actor* thisx, GlobalContext* globalCtx) { +void EnAni_Destroy(Actor* thisx, PlayState* play) { EnAni* this = THIS; - Collider_DestroyCylinder(globalCtx, &this->collider1); - Collider_DestroyCylinder(globalCtx, &this->collider2); + Collider_DestroyCylinder(play, &this->collider1); + Collider_DestroyCylinder(play, &this->collider2); } -void EnAni_SetText(EnAni* this, GlobalContext* globalCtx, u16 textId) { +void EnAni_SetText(EnAni* this, PlayState* play, u16 textId) { s16 diffAngle = this->actor.yawTowardsPlayer - this->actor.shape.rot.y; 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); + func_800B8614(&this->actor, play, 120.0f); } } } -void EnAni_IdleStanding(EnAni* this, GlobalContext* globalCtx) { +void EnAni_IdleStanding(EnAni* this, PlayState* play) { SkelAnime_Update(&this->skelAnime); } -void EnAni_Talk(EnAni* this, GlobalContext* globalCtx) { +void EnAni_Talk(EnAni* this, PlayState* play) { SkelAnime_Update(&this->skelAnime); - if (Message_GetState(&globalCtx->msgCtx) == 2 && globalCtx->msgCtx.currentTextId == 0x6DE) { + if ((Message_GetState(&play->msgCtx) == TEXT_STATE_CLOSING) && play->msgCtx.currentTextId == 0x6DE) { this->actionFunc = EnAni_IdleInPain; } } -void EnAni_IdleInPain(EnAni* this, GlobalContext* globalCtx) { +void EnAni_IdleInPain(EnAni* this, PlayState* play) { SkelAnime_Update(&this->skelAnime); - if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { + if (Actor_ProcessTalkRequest(&this->actor, &play->state)) { this->actionFunc = EnAni_Talk; } else { // telling you not to take his rupees you knocked from the tree - EnAni_SetText(this, globalCtx, 0x6DE); + EnAni_SetText(this, play, 0x6DE); } } -void EnAni_FallOverInPain(EnAni* this, GlobalContext* globalCtx) { +void EnAni_FallOverInPain(EnAni* this, PlayState* play) { if (SkelAnime_Update(&this->skelAnime)) { this->blinkFunc = EnAni_WaitForEyeOpen; this->actionFunc = EnAni_IdleInPain; @@ -199,7 +199,7 @@ void EnAni_FallOverInPain(EnAni* this, GlobalContext* globalCtx) { } } -void EnAni_LandOnFoot(EnAni* this, GlobalContext* globalCtx) { +void EnAni_LandOnFoot(EnAni* this, PlayState* play) { if (SkelAnime_Update(&this->skelAnime)) { this->actionFunc = EnAni_FallOverInPain; Animation_Change(&this->skelAnime, &gAniFallOverHoldingFootAnim, 1.0f, 0.0f, @@ -207,7 +207,7 @@ void EnAni_LandOnFoot(EnAni* this, GlobalContext* globalCtx) { } } -void EnAni_FallToGround(EnAni* this, GlobalContext* globalCtx) { +void EnAni_FallToGround(EnAni* this, PlayState* play) { s32 pad; s16 quakeValue; @@ -219,7 +219,7 @@ void EnAni_FallToGround(EnAni* this, GlobalContext* globalCtx) { // 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); + quakeValue = Quake_Add(play->cameraPtrs[CAM_ID_MAIN], 3); Quake_SetSpeed(quakeValue, 0x6978); Quake_SetQuakeValues(quakeValue, 7, 0, 0, 0); Quake_SetCountdown(quakeValue, 0x14); @@ -230,7 +230,7 @@ void EnAni_FallToGround(EnAni* this, GlobalContext* globalCtx) { this->actor.world.rot.y = this->actor.shape.rot.y; } -void EnAni_LoseBalance(EnAni* this, GlobalContext* globalCtx) { +void EnAni_LoseBalance(EnAni* this, PlayState* play) { s32 pad; if (SkelAnime_Update(&this->skelAnime)) { @@ -245,7 +245,7 @@ void EnAni_LoseBalance(EnAni* this, GlobalContext* globalCtx) { } } -void EnAni_HangInTree(EnAni* this, GlobalContext* globalCtx) { +void EnAni_HangInTree(EnAni* this, PlayState* play) { if (SkelAnime_Update(&this->skelAnime)) { if (this->treeReachTimer > 0) { this->treeReachTimer--; @@ -271,15 +271,15 @@ void EnAni_HangInTree(EnAni* this, GlobalContext* globalCtx) { } } -void EnAni_Update(Actor* thisx, GlobalContext* globalCtx) { +void EnAni_Update(Actor* thisx, PlayState* play) { 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); + CollisionCheck_SetOC(play, &play->colChkCtx, &this->collider1.base); if (!(this->stateFlags & ANI_STATE_UNK)) { - CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider2.base); + CollisionCheck_SetOC(play, &play->colChkCtx, &this->collider2.base); } this->actor.velocity.y += this->actor.gravity; @@ -289,10 +289,10 @@ void EnAni_Update(Actor* thisx, GlobalContext* globalCtx) { } Actor_UpdatePos(&this->actor); - Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 0.0f, 0.0f, 0.0f, 4); - this->actionFunc(this, globalCtx); + Actor_UpdateBgCheckInfo(play, &this->actor, 0.0f, 0.0f, 0.0f, 4); + this->actionFunc(this, play); if (this->actor.xzDistToPlayer < 100.0f && !(this->stateFlags & ANI_STATE_CLIMBING)) { - func_800E9250(globalCtx, &this->actor, &this->headRot, &this->chestRot, this->actor.focus.pos); + Actor_TrackPlayer(play, &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); @@ -308,7 +308,7 @@ void EnAni_Update(Actor* thisx, GlobalContext* globalCtx) { } 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)), + Camera_SetToTrackActor(Play_GetCamera(play, ActorCutscene_GetCurrentSubCamId(this->actor.cutscene)), &this->actor); } else { ActorCutscene_SetIntentToPlay(this->actor.cutscene); @@ -316,7 +316,7 @@ void EnAni_Update(Actor* thisx, GlobalContext* globalCtx) { } } -s32 EnAni_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, Actor* thisx) { +s32 EnAni_OverrideLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, Actor* thisx) { EnAni* this = THIS; if (limbIndex == ANI_LIMB_HEAD) { @@ -327,28 +327,28 @@ s32 EnAni_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, return false; } -void EnAni_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx) { +void EnAni_PostLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx) { static Vec3f D_809686A4 = { 800.0f, 500.0f, 0.0f }; if (limbIndex == ANI_LIMB_HEAD) { - Matrix_MultiplyVector3fByState(&D_809686A4, &thisx->focus.pos); + Matrix_MultVec3f(&D_809686A4, &thisx->focus.pos); } } -void EnAni_Draw(Actor* thisx, GlobalContext* globalCtx) { +void EnAni_Draw(Actor* thisx, PlayState* play) { static TexturePtr sEyeTextures[] = { gAniOpenEyeTex, gAniClosingEyeTex, gAniClosedEyeTex }; s32 pad; EnAni* this = THIS; - OPEN_DISPS(globalCtx->state.gfxCtx); + OPEN_DISPS(play->state.gfxCtx); - Matrix_InsertTranslation(0.0f, 0.0f, -1000.0f, MTXMODE_APPLY); - func_8012C5B0(globalCtx->state.gfxCtx); + Matrix_Translate(0.0f, 0.0f, -1000.0f, MTXMODE_APPLY); + func_8012C5B0(play->state.gfxCtx); gSPSegment(POLY_OPA_DISP++, 0x08, Lib_SegmentedToVirtual(sEyeTextures[this->eyeState])); - SkelAnime_DrawFlexOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, + SkelAnime_DrawFlexOpa(play, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, EnAni_OverrideLimbDraw, EnAni_PostLimbDraw, &this->actor); - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->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 21dced2c1..fcced964b 100644 --- a/src/overlays/actors/ovl_En_Ani/z_en_ani.h +++ b/src/overlays/actors/ovl_En_Ani/z_en_ani.h @@ -6,7 +6,7 @@ struct EnAni; -typedef void (*EnAniActionFunc)(struct EnAni*, GlobalContext*); +typedef void (*EnAniActionFunc)(struct EnAni*, PlayState*); typedef void (*EnAniBlinkFunc)(struct EnAni*); @@ -33,6 +33,6 @@ enum EnAniType { /* 1 */ ANI_TYPE_TREE_HANGING = 1, }; -#define GET_ANI_TYPE(thisx) (thisx->params & 0xFF) +#define ANI_GET_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 0705d7f06..33f8225d3 100644 --- a/src/overlays/actors/ovl_En_Aob_01/z_en_aob_01.c +++ b/src/overlays/actors/ovl_En_Aob_01/z_en_aob_01.c @@ -12,25 +12,25 @@ #define THIS ((EnAob01*)thisx) -void EnAob01_Init(Actor* thisx, GlobalContext* globalCtx); -void EnAob01_Destroy(Actor* thisx, GlobalContext* globalCtx); -void EnAob01_Update(Actor* thisx, GlobalContext* globalCtx); -void EnAob01_Draw(Actor* thisx, GlobalContext* globalCtx); +void EnAob01_Init(Actor* thisx, PlayState* play); +void EnAob01_Destroy(Actor* thisx, PlayState* play); +void EnAob01_Update(Actor* thisx, PlayState* play); +void EnAob01_Draw(Actor* thisx, PlayState* play); -void func_809C1C9C(EnAob01* this, GlobalContext* globalCtx); -void func_809C1D64(EnAob01* this, GlobalContext* globalCtx); -void func_809C2060(EnAob01* this, GlobalContext* globalCtx); -void func_809C21E0(EnAob01* this, GlobalContext* globalCtx); -void func_809C26E4(EnAob01* this, GlobalContext* globalCtx); -void func_809C2730(EnAob01* this, GlobalContext* globalCtx); -void func_809C2788(EnAob01* this, GlobalContext* globalCtx); -void func_809C2824(EnAob01* this, GlobalContext* globalCtx); -void func_809C28B8(EnAob01* this, GlobalContext* globalCtx); -void func_809C2A64(EnAob01* this, GlobalContext* globalCtx); -void func_809C2BE4(EnAob01* this, GlobalContext* globalCtx); -void func_809C2C9C(EnAob01* this, GlobalContext* globalCtx); -void func_809C2D0C(EnAob01* this, GlobalContext* globalCtx); -s32 func_809C2EC4(EnAob01* this, GlobalContext* globalCtx); +void func_809C1C9C(EnAob01* this, PlayState* play); +void func_809C1D64(EnAob01* this, PlayState* play); +void func_809C2060(EnAob01* this, PlayState* play); +void func_809C21E0(EnAob01* this, PlayState* play); +void func_809C26E4(EnAob01* this, PlayState* play); +void func_809C2730(EnAob01* this, PlayState* play); +void func_809C2788(EnAob01* this, PlayState* play); +void func_809C2824(EnAob01* this, PlayState* play); +void func_809C28B8(EnAob01* this, PlayState* play); +void func_809C2A64(EnAob01* this, PlayState* play); +void func_809C2BE4(EnAob01* this, PlayState* play); +void func_809C2C9C(EnAob01* this, PlayState* play); +void func_809C2D0C(EnAob01* this, PlayState* play); +s32 func_809C2EC4(EnAob01* this, PlayState* play); const ActorInit En_Aob_01_InitVars = { ACTOR_EN_AOB_01, @@ -44,7 +44,7 @@ const ActorInit En_Aob_01_InitVars = { (ActorFunc)EnAob01_Draw, }; -static AnimationInfo D_809C3790[6] = { +static AnimationInfo sAnimationInfo[] = { { &gMamamuYanIdleAnim, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, 0.0f }, { &gMamamuYanLaughStartAnim, 1.0f, 0.0f, 0.0f, ANIMMODE_ONCE, 0.0f }, { &gMamamuYanLaughLoopAnim, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, 0.0f }, @@ -100,59 +100,56 @@ void func_809C10B0(EnAob01* this, s32 arg1) { } void func_809C1124(void) { - u16 time = gSaveContext.save.time; - - gSaveContext.save.time = (u16)REG(15) + time; - time = gSaveContext.save.time; - gSaveContext.save.time = (u16)gSaveContext.save.daySpeed + 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) { +void func_809C1158(EnAob01* this, PlayState* play) { s32 temp_s0 = ENAOB01_GET_7E00_2(&this->actor); s16 i = 0; if (temp_s0 != 0x3F) { do { - this->unk_1D8[i] = SubS_GetPathByIndex(globalCtx, temp_s0, 0x3F); + this->unk_1D8[i] = SubS_GetPathByIndex(play, temp_s0, 0x3F); temp_s0 = this->unk_1D8[i]->unk1; i++; } while (temp_s0 != 0xFF); } } -void func_809C11EC(EnAob01* this, GlobalContext* globalCtx) { - s32 unk; +void func_809C11EC(EnAob01* this, PlayState* play) { + s32 enDgParams; s16 i; - func_809C1158(this, globalCtx); + func_809C1158(this, play); for (i = 0; i < ARRAY_COUNT(D_809C384C); i++) { - unk = (this->unk_1D8[D_809C384C[i].unk_06]->unk1 << 0xA) | (i << 5); + enDgParams = ENDG_PARAMS(this->unk_1D8[D_809C384C[i].unk_06]->unk1, i); this->unk_3F8[i] = Actor_SpawnAsChildAndCutscene( - &globalCtx->actorCtx, globalCtx, ACTOR_EN_DG, D_809C384C[i].unk_00.x, D_809C384C[i].unk_00.y, - D_809C384C[i].unk_00.z, 0, D_809C384C[i].unk_04 * 182.04445f, 0, unk, 0xFFFF, this->actor.unk20, NULL); + &play->actorCtx, play, ACTOR_EN_DG, D_809C384C[i].unk_00.x, D_809C384C[i].unk_00.y, D_809C384C[i].unk_00.z, + 0, D_809C384C[i].unk_04 * 182.04445f, 0, enDgParams, 0xFFFF, this->actor.unk20, NULL); } } -void func_809C1304(EnAob01* this, GlobalContext* globalCtx) { +void func_809C1304(EnAob01* this, PlayState* play) { s16 i; for (i = 0; i < ARRAY_COUNT(this->unk_3F8); i++) { this->unk_3F8[i] = Actor_SpawnAsChildAndCutscene( - &globalCtx->actorCtx, globalCtx, ACTOR_EN_RACEDOG, (i * 15.0f) + -3897.0f, 130.0f, 1290.0f - (i * 10.0f), 0, - 0x1555, 0, (i << 5) | ENAOB01_GET_7E00_1(&this->actor), 0xFFFF, this->actor.unk20, NULL); + &play->actorCtx, play, ACTOR_EN_RACEDOG, (i * 15.0f) + -3897.0f, 130.0f, 1290.0f - (i * 10.0f), 0, 0x1555, + 0, (i << 5) | ENAOB01_GET_7E00_1(&this->actor), 0xFFFF, this->actor.unk20, NULL); } } s32 func_809C1424(EnAob01* this) { s16 curFrame = this->skelAnime.curFrame; - s16 lastFrame = Animation_GetLastFrame(D_809C3790[this->unk_43C].animation); + s16 lastFrame = Animation_GetLastFrame(sAnimationInfo[this->unk_43C].animation); if (this->unk_43C == 1) { if (curFrame == lastFrame) { this->unk_43C = 2; - Actor_ChangeAnimationByInfo(&this->skelAnime, D_809C3790, 2); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, 2); return true; } } else if (this->unk_43C == 2) { @@ -163,18 +160,18 @@ s32 func_809C1424(EnAob01* this) { s32 func_809C14D0(EnAob01* this) { s16 curFrame = this->skelAnime.curFrame; - s16 lastFrame = Animation_GetLastFrame(D_809C3790[this->unk_43C].animation); + s16 lastFrame = Animation_GetLastFrame(sAnimationInfo[this->unk_43C].animation); if ((this->unk_43C == 0) || (this->unk_43C == 5)) { if (curFrame == lastFrame) { this->unk_43C = 3; - Actor_ChangeAnimationByInfo(&this->skelAnime, D_809C3790, 3); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, 3); return true; } } else if (this->unk_43C == 3) { if (curFrame == lastFrame) { this->unk_43C = 4; - Actor_ChangeAnimationByInfo(&this->skelAnime, D_809C3790, 4); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, 4); return true; } } else if (this->unk_43C == 4) { @@ -185,12 +182,12 @@ s32 func_809C14D0(EnAob01* this) { s32 func_809C15BC(EnAob01* this) { s16 curFrame = this->skelAnime.curFrame; - s16 lastFrame = Animation_GetLastFrame(D_809C3790[this->unk_43C].animation); + s16 lastFrame = Animation_GetLastFrame(sAnimationInfo[this->unk_43C].animation); if ((this->unk_43C != 0) && (this->unk_43C != 5)) { if (curFrame == lastFrame) { this->unk_43C = 5; - Actor_ChangeAnimationByInfo(&this->skelAnime, D_809C3790, 5); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, 5); return true; } } else { @@ -200,16 +197,16 @@ s32 func_809C15BC(EnAob01* this) { return false; } -void func_809C165C(EnAob01* this, GlobalContext* globalCtx) { +void func_809C165C(EnAob01* this, PlayState* play) { this->collider.dim.pos.x = this->actor.world.pos.x; this->collider.dim.pos.y = this->actor.world.pos.y; this->collider.dim.pos.z = this->actor.world.pos.z; - CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); - CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + CollisionCheck_SetAC(play, &play->colChkCtx, &this->collider.base); + CollisionCheck_SetOC(play, &play->colChkCtx, &this->collider.base); } -void func_809C16DC(EnAob01* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); +void func_809C16DC(EnAob01* this, PlayState* play) { + Player* player = GET_PLAYER(play); switch (this->unk_210) { case 0: @@ -332,7 +329,7 @@ void func_809C16DC(EnAob01* this, GlobalContext* globalCtx) { this->unk_2D2 |= 0x40; this->unk_2D2 |= 0x10; this->unk_43C = 1; - Actor_ChangeAnimationByInfo(&this->skelAnime, D_809C3790, 1); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, 1); break; case 0x3525: @@ -347,7 +344,7 @@ void func_809C16DC(EnAob01* this, GlobalContext* globalCtx) { this->unk_2D2 |= 0x40; this->unk_2D2 |= 0x10; this->unk_43C = 1; - Actor_ChangeAnimationByInfo(&this->skelAnime, D_809C3790, 1); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, 1); break; } @@ -362,7 +359,7 @@ void func_809C16DC(EnAob01* this, GlobalContext* globalCtx) { this->unk_2D2 |= 4; this->unk_2D2 |= 0x10; this->unk_43C = 1; - Actor_ChangeAnimationByInfo(&this->skelAnime, D_809C3790, 1); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, 1); break; case 0x3527: @@ -374,7 +371,7 @@ void func_809C16DC(EnAob01* this, GlobalContext* globalCtx) { this->unk_210 = 0x3536; this->unk_2D2 |= 0x40; this->unk_43C = 1; - Actor_ChangeAnimationByInfo(&this->skelAnime, D_809C3790, 1); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, 1); break; } @@ -382,22 +379,22 @@ void func_809C16DC(EnAob01* this, GlobalContext* globalCtx) { this->unk_210 = 0x3537; this->unk_2D2 |= 0x40; this->unk_43C = 1; - Actor_ChangeAnimationByInfo(&this->skelAnime, D_809C3790, 1); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, 1); break; } gSaveContext.unk_3F5C = this->unk_434; - globalCtx->msgCtx.bankRupees = this->unk_434; + play->msgCtx.bankRupees = this->unk_434; this->unk_210 = 0x3529; break; case 0x3529: if (this->unk_2D2 & 2) { this->unk_2D2 &= ~2; - func_801159EC(-this->unk_434); - func_800B7298(globalCtx, NULL, 7); - globalCtx->msgCtx.msgMode = 0x43; - globalCtx->msgCtx.unk12023 = 4; + Rupees_ChangeBy(-this->unk_434); + func_800B7298(play, NULL, 7); + play->msgCtx.msgMode = 0x43; + play->msgCtx.stateTimer = 4; this->actionFunc = func_809C1C9C; return; } @@ -410,41 +407,41 @@ void func_809C16DC(EnAob01* this, GlobalContext* globalCtx) { break; } - Message_StartTextbox(globalCtx, this->unk_210, &this->actor); + Message_StartTextbox(play, this->unk_210, &this->actor); } -void func_809C1C9C(EnAob01* this, GlobalContext* globalCtx) { +void func_809C1C9C(EnAob01* this, PlayState* play) { if (gSaveContext.rupeeAccumulator == 0) { gSaveContext.save.weekEventReg[63] |= 1; gSaveContext.save.weekEventReg[63] &= (u8)~2; this->unk_2D2 |= 0x20; func_800FD750(0x40); - globalCtx->nextEntranceIndex = 0x7C10; - globalCtx->unk_1887F = 0x40; - gSaveContext.nextTransition = 0x40; + play->nextEntrance = ENTRANCE(DOGGY_RACETRACK, 1); + play->transitionType = TRANS_TYPE_64; + gSaveContext.nextTransitionType = TRANS_TYPE_64; gSaveContext.eventInf[0] = (gSaveContext.eventInf[0] & (u8)~7) | 2; gSaveContext.eventInf[0] = (gSaveContext.eventInf[0] & 7) | (this->unk_432 * 8); - globalCtx->sceneLoadFlag = 0x14; + play->transitionTrigger = TRANS_TRIGGER_START; } } -void func_809C1D64(EnAob01* this, GlobalContext* globalCtx) { - u8 temp_v0 = Message_GetState(&globalCtx->msgCtx); +void func_809C1D64(EnAob01* this, PlayState* play) { + u8 talkState = Message_GetState(&play->msgCtx); - if (temp_v0 == 4) { - if (Message_ShouldAdvance(globalCtx)) { - switch (globalCtx->msgCtx.choiceIndex) { + if (talkState == TEXT_STATE_CHOICE) { + if (Message_ShouldAdvance(play)) { + switch (play->msgCtx.choiceIndex) { case 0: if (gSaveContext.save.playerData.rupees < 10) { play_sound(NA_SE_SY_ERROR); this->unk_210 = 0x3524; - Message_StartTextbox(globalCtx, this->unk_210, &this->actor); + Message_StartTextbox(play, this->unk_210, &this->actor); } else { func_8019F208(); this->unk_2D2 |= 4; this->unk_2D2 |= 0x10; this->unk_210 = 0x3522; - Message_StartTextbox(globalCtx, this->unk_210, &this->actor); + Message_StartTextbox(play, this->unk_210, &this->actor); this->actionFunc = func_809C21E0; } break; @@ -452,78 +449,83 @@ void func_809C1D64(EnAob01* this, GlobalContext* globalCtx) { case 1: func_8019F230(); this->unk_210 = 0x3535; - Message_StartTextbox(globalCtx, this->unk_210, &this->actor); + Message_StartTextbox(play, this->unk_210, &this->actor); break; } } - } else if ((temp_v0 == 5) && Message_ShouldAdvance(globalCtx)) { - globalCtx->msgCtx.msgMode = 0x43; - globalCtx->msgCtx.unk12023 = 4; + } else if ((talkState == TEXT_STATE_5) && Message_ShouldAdvance(play)) { + play->msgCtx.msgMode = 0x43; + play->msgCtx.stateTimer = 4; this->unk_210 = 0; this->actionFunc = func_809C2060; } } -void func_809C1EC8(EnAob01* this, GlobalContext* globalCtx) { - static u16 D_809C392C[] = { 4000, 4, 1, 3, 6000, 4, 1, 6, 4000, 4, 1, 3, 6000, 4, 1, 6 }; - Player* player = GET_PLAYER(globalCtx); - Vec3f sp30; +void func_809C1EC8(EnAob01* this, PlayState* play) { + static TrackOptionsSet sTrackOptions = { + { 0xFA0, 4, 1, 3 }, + { 0x1770, 4, 1, 6 }, + { 0xFA0, 4, 1, 3 }, + { 0x1770, 4, 1, 6 }, + }; + Player* player = GET_PLAYER(play); + Vec3f point; SkelAnime_Update(&this->skelAnime); if (SubS_AngleDiffLessEqual(this->actor.shape.rot.y, 0x36B0, this->actor.yawTowardsPlayer)) { - sp30.x = player->actor.world.pos.x; - sp30.y = player->bodyPartsPos[7].y + 3.0f; - sp30.z = player->actor.world.pos.z; - func_8013D2E0(&sp30, &this->actor.focus.pos, &this->actor.shape.rot, &this->unk_2D4, &this->unk_2DA, - &this->unk_2E0, D_809C392C); + 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); - SubS_FillLimbRotTables(globalCtx, this->unk_2F8, this->unk_318, ARRAY_COUNT(this->unk_2F8)); - func_809C165C(this, globalCtx); + SubS_FillLimbRotTables(play, this->unk_2F8, this->unk_318, ARRAY_COUNT(this->unk_2F8)); + func_809C165C(this, play); if (player->stateFlags1 & 0x20) { func_809C1124(); } } -void func_809C2060(EnAob01* this, GlobalContext* globalCtx) { +void func_809C2060(EnAob01* this, PlayState* play) { if (func_809C15BC(this)) { - if (func_809C2EC4(this, globalCtx) && !(this->unk_2D2 & 0x100)) { + if (func_809C2EC4(this, play) && !(this->unk_2D2 & 0x100)) { if (this->collider.base.ocFlags2 & OC2_HIT_PLAYER) { this->actor.flags |= ACTOR_FLAG_10000; - func_800B8614(&this->actor, globalCtx, 100.0f); + func_800B8614(&this->actor, play, 100.0f); this->unk_2D2 |= 8; this->actionFunc = func_809C21E0; } - } else if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state) && (this->unk_2D2 & 0x100)) { + } else if (Actor_ProcessTalkRequest(&this->actor, &play->state) && (this->unk_2D2 & 0x100)) { this->unk_2D2 &= ~0x100; - this->unk_2E6 = this->unk_2D4; - this->unk_2EC = this->unk_2DA; - this->unk_2F2 = this->unk_2E0; - func_809C16DC(this, globalCtx); + this->unk_2E6 = this->trackTarget; + this->unk_2EC = this->headRot; + this->unk_2F2 = this->torsoRot; + func_809C16DC(this, play); this->actionFunc = func_809C21E0; } else { this->unk_2D2 &= ~0x100; if ((this->actor.xzDistToPlayer < 100.0f) && !(this->collider.base.ocFlags2 & OC2_HIT_PLAYER)) { this->unk_2D2 |= 0x100; - func_800B8614(&this->actor, globalCtx, 100.0f); + func_800B8614(&this->actor, play, 100.0f); } } } } -void func_809C21E0(EnAob01* this, GlobalContext* globalCtx) { - u8 sp2F = Message_GetState(&globalCtx->msgCtx); +void func_809C21E0(EnAob01* this, PlayState* play) { + u8 talkState = Message_GetState(&play->msgCtx); Math_SmoothStepToS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer, 4, 4000, 1); - if ((this->unk_2D2 & 8) && !func_809C2EC4(this, globalCtx)) { + if ((this->unk_2D2 & 8) && !func_809C2EC4(this, play)) { if ((this->unk_210 != 0) && (this->unk_210 != 0x3535) && (this->unk_210 != 0x3524) && (this->unk_210 != 0x3548) && (this->unk_210 != 0x3549) && (this->unk_210 != 0x354A)) { this->unk_210 = 0x3523; @@ -544,61 +546,61 @@ void func_809C21E0(EnAob01* this, GlobalContext* globalCtx) { } if (this->unk_2D2 & 8) { - if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { + if (Actor_ProcessTalkRequest(&this->actor, &play->state)) { this->actor.flags &= ~ACTOR_FLAG_10000; - func_80123E90(globalCtx, &this->actor); + func_80123E90(play, &this->actor); if (this->unk_2D2 & 4) { - func_809C16DC(this, globalCtx); + func_809C16DC(this, play); this->unk_2D2 &= ~4; } else { this->unk_2D2 |= 0x10; this->unk_2D2 |= 0x40; this->unk_43C = 1; - Actor_ChangeAnimationByInfo(&this->skelAnime, D_809C3790, 1); - Message_StartTextbox(globalCtx, 0x354B, &this->actor); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, 1); + Message_StartTextbox(play, 0x354B, &this->actor); } this->unk_2D2 &= ~8; } - } else if (sp2F == 4) { - if (Message_ShouldAdvance(globalCtx)) { + } else if (talkState == TEXT_STATE_CHOICE) { + if (Message_ShouldAdvance(play)) { this->unk_2D2 &= ~0x40; - switch (globalCtx->msgCtx.choiceIndex) { + switch (play->msgCtx.choiceIndex) { case 0: func_8019F208(); this->unk_2D2 |= 2; - func_809C16DC(this, globalCtx); + func_809C16DC(this, play); break; case 1: func_8019F230(); - func_809C16DC(this, globalCtx); + func_809C16DC(this, play); break; } } - } else if (sp2F == 5) { - if (Message_ShouldAdvance(globalCtx)) { + } else if (talkState == TEXT_STATE_5) { + if (Message_ShouldAdvance(play)) { this->unk_2D2 &= ~0x40; if (this->unk_2D2 & 0x10) { this->unk_2D2 &= ~0x10; - globalCtx->msgCtx.msgMode = 0x43; - globalCtx->msgCtx.unk12023 = 4; + play->msgCtx.msgMode = 0x43; + play->msgCtx.stateTimer = 4; this->actionFunc = func_809C2060; } else { - func_809C16DC(this, globalCtx); + func_809C16DC(this, play); } } - } else if ((sp2F == 14) && Message_ShouldAdvance(globalCtx)) { + } else if ((talkState == TEXT_STATE_14) && Message_ShouldAdvance(play)) { this->unk_2D2 &= ~0x40; - this->unk_434 = globalCtx->msgCtx.bankRupeesSelected; - func_809C16DC(this, globalCtx); + this->unk_434 = play->msgCtx.bankRupeesSelected; + func_809C16DC(this, play); } } -s32 func_809C2504(EnAob01* this, GlobalContext* globalCtx) { - Actor* npc = globalCtx->actorCtx.actorLists[ACTORCAT_NPC].first; +s32 func_809C2504(EnAob01* this, PlayState* play) { + Actor* npc = play->actorCtx.actorLists[ACTORCAT_NPC].first; while (npc != NULL) { - if ((npc->id == ACTOR_EN_RACEDOG) && (func_800F2178(this->unk_430) == ((EnRacedog*)npc)->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); @@ -610,11 +612,11 @@ s32 func_809C2504(EnAob01* this, GlobalContext* globalCtx) { return false; } -s32 func_809C2594(EnAob01* this, GlobalContext* globalCtx) { - Actor* npc = globalCtx->actorCtx.actorLists[ACTORCAT_NPC].first; +s32 func_809C2594(EnAob01* this, PlayState* play) { + Actor* npc = play->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; } @@ -624,12 +626,12 @@ s32 func_809C2594(EnAob01* this, GlobalContext* globalCtx) { return false; } -s32 func_809C25E4(EnAob01* this, GlobalContext* globalCtx) { - Actor* npc = globalCtx->actorCtx.actorLists[ACTORCAT_NPC].first; +s32 func_809C25E4(EnAob01* this, PlayState* play) { + Actor* npc = play->actorCtx.actorLists[ACTORCAT_NPC].first; 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; @@ -653,34 +655,33 @@ s32 func_809C2680(EnAob01* this) { return false; } -void func_809C26E4(EnAob01* this, GlobalContext* globalCtx) { +void func_809C26E4(EnAob01* this, PlayState* play) { ActorCutscene_Stop(this->unk_430); this->unk_430 = ActorCutscene_GetAdditionalCutscene(this->unk_430); this->actionFunc = func_809C2824; } -void func_809C2730(EnAob01* this, GlobalContext* globalCtx) { - if (func_809C2504(this, globalCtx) || func_809C2680(this)) { +void func_809C2730(EnAob01* this, PlayState* play) { + if (func_809C2504(this, play) || func_809C2680(this)) { ActorCutscene_SetIntentToPlay(this->unk_430); this->actionFunc = func_809C2824; } } -void func_809C2788(EnAob01* this, GlobalContext* globalCtx) { +void func_809C2788(EnAob01* this, PlayState* play) { this->unk_2D2 |= 0x20; - if (func_809C25E4(this, globalCtx)) { - globalCtx = globalCtx; + if (func_809C25E4(this, play)) { if (func_801A8A50(0) != 0x41) { - globalCtx->nextEntranceIndex = 0x7C10; + play->nextEntrance = ENTRANCE(DOGGY_RACETRACK, 1); gSaveContext.eventInf[0] = (gSaveContext.eventInf[0] & (u8)~7) | 3; - globalCtx->unk_1887F = 0x40; - gSaveContext.nextTransition = 3; - globalCtx->sceneLoadFlag = 0x14; + play->transitionType = TRANS_TYPE_64; + gSaveContext.nextTransitionType = TRANS_TYPE_03; + play->transitionTrigger = TRANS_TRIGGER_START; } } } -void func_809C2824(EnAob01* this, GlobalContext* globalCtx) { +void func_809C2824(EnAob01* this, PlayState* play) { if (ActorCutscene_GetCanPlayNext(this->unk_430)) { ActorCutscene_Start(this->unk_430, this->unk_3F4); switch (func_800F2178(this->unk_430)) { @@ -700,64 +701,64 @@ void func_809C2824(EnAob01* this, GlobalContext* globalCtx) { } } -void func_809C28B8(EnAob01* this, GlobalContext* globalCtx) { - if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { +void func_809C28B8(EnAob01* this, PlayState* play) { + if (Actor_ProcessTalkRequest(&this->actor, &play->state)) { this->actor.flags &= ~ACTOR_FLAG_10000; - func_80123E90(globalCtx, &this->actor); + func_80123E90(play, &this->actor); this->unk_434 = gSaveContext.unk_3F5C; switch ((gSaveContext.eventInf[0] & 0xF8) >> 3) { case 1: this->unk_210 = 0x352A; this->unk_2D2 |= 0x80; this->unk_434 *= 3; - func_801159EC(this->unk_434); - globalCtx->msgCtx.bankRupees = this->unk_434; + Rupees_ChangeBy(this->unk_434); + play->msgCtx.bankRupees = this->unk_434; break; case 2: this->unk_210 = 0x352B; this->unk_2D2 |= 0x80; this->unk_434 *= 2; - func_801159EC(this->unk_434); - globalCtx->msgCtx.bankRupees = this->unk_434; + Rupees_ChangeBy(this->unk_434); + play->msgCtx.bankRupees = this->unk_434; break; case 3: case 4: case 5: this->unk_210 = 0x352C; - func_801159EC(this->unk_434); + Rupees_ChangeBy(this->unk_434); break; default: this->unk_210 = 0x352D; this->unk_2D2 |= 0x40; this->unk_43C = 1; - Actor_ChangeAnimationByInfo(&this->skelAnime, D_809C3790, 1); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, 1); break; } - Message_StartTextbox(globalCtx, this->unk_210, &this->actor); + Message_StartTextbox(play, this->unk_210, &this->actor); this->actionFunc = func_809C2D0C; } else if (this->actor.xzDistToPlayer < 100.0f) { - func_800B8614(&this->actor, globalCtx, 100.0f); + func_800B8614(&this->actor, play, 100.0f); } } -void func_809C2A64(EnAob01* this, GlobalContext* globalCtx) { - u8 sp2F = Message_GetState(&globalCtx->msgCtx); +void func_809C2A64(EnAob01* this, PlayState* play) { + u8 talkState = Message_GetState(&play->msgCtx); if (func_809C15BC(this)) { - if ((sp2F == 5) && Message_ShouldAdvance(globalCtx)) { + if ((talkState == TEXT_STATE_5) && Message_ShouldAdvance(play)) { this->unk_434 = 0; - globalCtx->msgCtx.msgMode = 0x43; - globalCtx->msgCtx.unk12023 = 4; + play->msgCtx.msgMode = 0x43; + play->msgCtx.stateTimer = 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; + if (Actor_HasParent(&this->actor, play)) { + 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.save.weekEventReg[8] & 0x20) { @@ -767,17 +768,17 @@ void func_809C2A64(EnAob01* this, GlobalContext* globalCtx) { this->actionFunc = func_809C2BE4; } } else if (gSaveContext.save.weekEventReg[8] & 0x20) { - Actor_PickUp(&this->actor, globalCtx, GI_RUPEE_RED, 300.0f, 300.0f); + Actor_PickUp(&this->actor, play, GI_RUPEE_RED, 300.0f, 300.0f); } else { - Actor_PickUp(&this->actor, globalCtx, GI_HEART_PIECE, 300.0f, 300.0f); + Actor_PickUp(&this->actor, play, GI_HEART_PIECE, 300.0f, 300.0f); } } } -void func_809C2BE4(EnAob01* this, GlobalContext* globalCtx) { - u8 temp_v0 = Message_GetState(&globalCtx->msgCtx); +void func_809C2BE4(EnAob01* this, PlayState* play) { + u8 talkState = Message_GetState(&play->msgCtx); - if (((temp_v0 == 5) || (temp_v0 == 6)) && Message_ShouldAdvance(globalCtx)) { + if (((talkState == TEXT_STATE_5) || (talkState == TEXT_STATE_DONE)) && Message_ShouldAdvance(play)) { if (gSaveContext.save.weekEventReg[63] & 2) { gSaveContext.save.weekEventReg[63] &= (u8)~2; } @@ -787,24 +788,24 @@ void func_809C2BE4(EnAob01* this, GlobalContext* globalCtx) { } this->unk_210 = 0; - func_800B85E0(&this->actor, globalCtx, 400.0f, -1); + func_800B85E0(&this->actor, play, 400.0f, -1); gSaveContext.eventInf[0] &= (u8)~7; this->actionFunc = func_809C2C9C; } } -void func_809C2C9C(EnAob01* this, GlobalContext* globalCtx) { - if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { +void func_809C2C9C(EnAob01* this, PlayState* play) { + if (Actor_ProcessTalkRequest(&this->actor, &play->state)) { this->unk_210 = 0x354C; - func_80151938(globalCtx, this->unk_210); + func_80151938(play, this->unk_210); this->actionFunc = func_809C1D64; } else { - func_800B85E0(&this->actor, globalCtx, 400.0f, -1); + func_800B85E0(&this->actor, play, 400.0f, -1); } } -void func_809C2D0C(EnAob01* this, GlobalContext* globalCtx) { - u8 sp2F = Message_GetState(&globalCtx->msgCtx); +void func_809C2D0C(EnAob01* this, PlayState* play) { + u8 talkState = Message_GetState(&play->msgCtx); Math_SmoothStepToS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer, 4, 4000, 1); @@ -818,17 +819,17 @@ void func_809C2D0C(EnAob01* this, GlobalContext* globalCtx) { } } - if ((sp2F == 5) && Message_ShouldAdvance(globalCtx)) { + if ((talkState == TEXT_STATE_5) && Message_ShouldAdvance(play)) { this->unk_2D2 &= ~0x40; this->unk_2D2 &= ~0x80; if (this->unk_434 >= 150) { this->unk_210 = 0x352E; - Message_StartTextbox(globalCtx, this->unk_210, &this->actor); + Message_StartTextbox(play, 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; @@ -841,24 +842,24 @@ void func_809C2D0C(EnAob01* this, GlobalContext* globalCtx) { } this->unk_210 = 0x354C; - Message_StartTextbox(globalCtx, this->unk_210, &this->actor); + Message_StartTextbox(play, this->unk_210, &this->actor); this->actionFunc = func_809C1D64; gSaveContext.eventInf[0] &= (u8)~7; } } } -s32 func_809C2EC4(EnAob01* this, GlobalContext* globalCtx) { - Actor* dog = globalCtx->actorCtx.actorLists[ACTORCAT_ENEMY].first; +s32 func_809C2EC4(EnAob01* this, PlayState* play) { + Actor* dog = play->actorCtx.actorLists[ACTORCAT_ENEMY].first; while (dog != NULL) { if (dog->id == ACTOR_EN_DG) { - this->unk_432 = ((EnDg*)dog)->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; } } @@ -868,8 +869,8 @@ s32 func_809C2EC4(EnAob01* this, GlobalContext* globalCtx) { return false; } -void func_809C2F34(EnAob01* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); +void func_809C2F34(EnAob01* this, PlayState* play) { + Player* player = GET_PLAYER(play); player->actor.world.pos.x = -4134.0f; player->actor.world.pos.z = 1464.0f; @@ -883,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]; @@ -893,11 +894,11 @@ 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++) { @@ -907,54 +908,54 @@ void func_809C2FA0(void) { 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.save.weekEventReg[42 + idx2]; - gSaveContext.save.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; } } } -void EnAob01_Init(Actor* thisx, GlobalContext* globalCtx) { +void EnAob01_Init(Actor* thisx, PlayState* play) { s32 pad; EnAob01* this = THIS; ActorShape_Init(&this->actor.shape, 0.0f, NULL, 0.0f); - SkelAnime_InitFlex(globalCtx, &this->skelAnime, &gMamamuYanSkel, NULL, this->jointTable, this->morphTable, + SkelAnime_InitFlex(play, &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); + Collider_InitCylinder(play, &this->collider); + Collider_SetCylinder(play, &this->collider, &this->actor, &sCylinderInit); this->unk_43C = 0; - Actor_ChangeAnimationByInfo(&this->skelAnime, D_809C3790, 0); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, 0); Actor_SetScale(&this->actor, 0.01f); switch (gSaveContext.eventInf[0] & 7) { case 0: func_809C2FA0(); - func_809C11EC(this, globalCtx); + func_809C11EC(this, play); this->actor.flags |= ACTOR_FLAG_1; this->actionFunc = func_809C2060; break; case 2: this->unk_440 = 500; - func_809C1304(this, globalCtx); + func_809C1304(this, play); this->actor.draw = NULL; this->unk_430 = this->actor.cutscene; - func_809C2594(this, globalCtx); + func_809C2594(this, play); ActorCutscene_SetIntentToPlay(this->unk_430); this->actor.flags &= ~ACTOR_FLAG_1; - func_809C2F34(this, globalCtx); + func_809C2F34(this, play); this->actionFunc = func_809C2824; break; case 3: func_809C2FA0(); - func_809C11EC(this, globalCtx); + func_809C11EC(this, play); this->actor.flags |= ACTOR_FLAG_1; this->actor.flags |= ACTOR_FLAG_10000; this->actionFunc = func_809C28B8; @@ -962,24 +963,23 @@ void EnAob01_Init(Actor* thisx, GlobalContext* globalCtx) { } } -void EnAob01_Destroy(Actor* thisx, GlobalContext* globalCtx) { +void EnAob01_Destroy(Actor* thisx, PlayState* play) { EnAob01* this = THIS; if (!(this->unk_2D2 & 0x20)) { gSaveContext.save.weekEventReg[63] &= (u8)~1; } - Collider_DestroyCylinder(globalCtx, &this->collider); + Collider_DestroyCylinder(play, &this->collider); } -void EnAob01_Update(Actor* thisx, GlobalContext* globalCtx) { +void EnAob01_Update(Actor* thisx, PlayState* play) { EnAob01* this = THIS; - this->actionFunc(this, globalCtx); - func_809C1EC8(this, globalCtx); + this->actionFunc(this, play); + func_809C1EC8(this, play); } -s32 EnAob01_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, - Actor* thisx) { +s32 EnAob01_OverrideLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, Actor* thisx) { EnAob01* this = THIS; TexturePtr eyeTextures[] = { gMamamuYanEyeOpenTex, @@ -988,25 +988,25 @@ s32 EnAob01_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dLis }; if (limbIndex == MAMAMU_YAN_LIMB_HEAD) { - OPEN_DISPS(globalCtx->state.gfxCtx); + OPEN_DISPS(play->state.gfxCtx); *dList = gMamamuYanHeadDL; gSPSegment(POLY_OPA_DISP++, 0x0A, Lib_SegmentedToVirtual(eyeTextures[this->eyeIndex])); - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->state.gfxCtx); } if (limbIndex == MAMAMU_YAN_LIMB_HEAD) { - Matrix_InsertTranslation(1500.0f, 0.0f, 0.0f, MTXMODE_APPLY); - Matrix_InsertXRotation_s(this->unk_2DA.y, MTXMODE_APPLY); - Matrix_InsertZRotation_s(this->unk_2DA.x * -1, MTXMODE_APPLY); - Matrix_InsertTranslation(-1500.0f, 0.0f, 0.0f, MTXMODE_APPLY); + 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 == MAMAMU_YAN_LIMB_TORSO) { - Matrix_InsertXRotation_s(this->unk_2E0.y * -1, MTXMODE_APPLY); - Matrix_InsertZRotation_s(this->unk_2E0.x * -1, MTXMODE_APPLY); + Matrix_RotateXS(this->torsoRot.y * -1, MTXMODE_APPLY); + Matrix_RotateZS(this->torsoRot.x * -1, MTXMODE_APPLY); } if ((limbIndex == MAMAMU_YAN_LIMB_TORSO) || (limbIndex == MAMAMU_YAN_LIMB_LEFT_UPPER_ARM) || @@ -1017,44 +1017,44 @@ s32 EnAob01_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dLis return false; } -void EnAob01_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx) { +void EnAob01_PostLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx) { static Vec3f D_809C3968 = { 0.0f, 0.0f, 0.0f }; EnAob01* this = THIS; if (limbIndex == MAMAMU_YAN_LIMB_HEAD) { - Matrix_MultiplyVector3fByState(&D_809C3968, &this->actor.focus.pos); + Matrix_MultVec3f(&D_809C3968, &this->actor.focus.pos); } } -void EnAob01_TransformLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Actor* thisx) { +void EnAob01_TransformLimbDraw(PlayState* play, s32 limbIndex, Actor* thisx) { } -void EnAob01_Draw(Actor* thisx, GlobalContext* globalCtx) { +void EnAob01_Draw(Actor* thisx, PlayState* play) { s32 pad; EnAob01* this = THIS; Vec3f sp5C; Vec3f sp50; - OPEN_DISPS(globalCtx->state.gfxCtx); + OPEN_DISPS(play->state.gfxCtx); - func_8012C28C(globalCtx->state.gfxCtx); + func_8012C28C(play->state.gfxCtx); - gSPSegment(POLY_OPA_DISP++, 0x08, Gfx_EnvColor(globalCtx->state.gfxCtx, 50, 80, 0, 0)); - gSPSegment(POLY_OPA_DISP++, 0x09, Gfx_EnvColor(globalCtx->state.gfxCtx, 50, 80, 0, 0)); + gSPSegment(POLY_OPA_DISP++, 0x08, Gfx_EnvColor(play->state.gfxCtx, 50, 80, 0, 0)); + gSPSegment(POLY_OPA_DISP++, 0x09, Gfx_EnvColor(play->state.gfxCtx, 50, 80, 0, 0)); gDPPipeSync(POLY_OPA_DISP++); - SkelAnime_DrawTransformFlexOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, + SkelAnime_DrawTransformFlexOpa(play, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, EnAob01_OverrideLimbDraw, EnAob01_PostLimbDraw, EnAob01_TransformLimbDraw, &this->actor); if (this->actor.draw != NULL) { - func_8012C2DC(globalCtx->state.gfxCtx); + func_8012C2DC(play->state.gfxCtx); sp5C = this->actor.world.pos; sp50.x = 0.5f; sp50.y = 0.5f; sp50.z = 0.5f; - func_800BC620(&sp5C, &sp50, 0xFF, globalCtx); + func_800BC620(&sp5C, &sp50, 0xFF, play); } - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->state.gfxCtx); } diff --git a/src/overlays/actors/ovl_En_Aob_01/z_en_aob_01.h b/src/overlays/actors/ovl_En_Aob_01/z_en_aob_01.h index 69e15f658..7414f1890 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 @@ -6,7 +6,7 @@ struct EnAob01; -typedef void (*EnAob01ActionFunc)(struct EnAob01*, GlobalContext*); +typedef void (*EnAob01ActionFunc)(struct EnAob01*, PlayState*); #define ENAOB01_GET_7E00_1(thisx) ((thisx)->params & 0x7E00) #define ENAOB01_GET_7E00_2(thisx) (((thisx)->params & 0x7E00) >> 9) @@ -21,9 +21,9 @@ typedef struct EnAob01 { /* 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; 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 d3286f545..46d42a817 100644 --- a/src/overlays/actors/ovl_En_Arrow/z_en_arrow.c +++ b/src/overlays/actors/ovl_En_Arrow/z_en_arrow.c @@ -12,15 +12,15 @@ #define THIS ((EnArrow*)thisx) -void EnArrow_Init(Actor* thisx, GlobalContext* globalCtx); -void EnArrow_Destroy(Actor* thisx, GlobalContext* globalCtx); -void EnArrow_Update(Actor* thisx, GlobalContext* globalCtx); -void EnArrow_Draw(Actor* thisx, GlobalContext* globalCtx); +void EnArrow_Init(Actor* thisx, PlayState* play); +void EnArrow_Destroy(Actor* thisx, PlayState* play); +void EnArrow_Update(Actor* thisx, PlayState* play); +void EnArrow_Draw(Actor* thisx, PlayState* play); -void func_8088A594(EnArrow* this, GlobalContext* globalCtx); -void func_8088ACE0(EnArrow* this, GlobalContext* globalCtx); -void func_8088B630(EnArrow* this, GlobalContext* globalCtx); -void func_8088B6B0(EnArrow* this, GlobalContext* globalCtx); +void func_8088A594(EnArrow* this, PlayState* play); +void func_8088ACE0(EnArrow* this, PlayState* play); +void func_8088B630(EnArrow* this, PlayState* play); +void func_8088B6B0(EnArrow* this, PlayState* play); const ActorInit En_Arrow_InitVars = { ACTOR_EN_ARROW, @@ -58,7 +58,7 @@ static InitChainEntry sInitChain[] = { ICHAIN_F32(terminalVelocity, -150, ICHAIN_STOP), }; -void EnArrow_Init(Actor* thisx, GlobalContext* globalCtx) { +void EnArrow_Init(Actor* thisx, PlayState* play) { 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 }, @@ -84,7 +84,7 @@ void EnArrow_Init(Actor* thisx, GlobalContext* globalCtx) { } if (this->actor.params < ENARROW_6) { - SkelAnime_Init(globalCtx, &this->arrow.skelAnime, &gameplay_keep_Skel_014560, &gameplay_keep_Anim_0128BC, + SkelAnime_Init(play, &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) { @@ -92,18 +92,18 @@ void EnArrow_Init(Actor* thisx, GlobalContext* globalCtx) { } else { D_8088C234.elemDuration = 16; } - Effect_Add(globalCtx, &this->unk_240, EFFECT_BLURE2, 0, 0, &D_8088C234); + Effect_Add(play, &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); + Effect_Add(play, &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); + Effect_Add(play, &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); + Effect_Add(play, &this->unk_240, EFFECT_BLURE2, 0, 0, &D_8088C2A0); } } - Collider_InitQuad(globalCtx, &this->collider); - Collider_SetQuad(globalCtx, &this->collider, &this->actor, &sQuadInit); + Collider_InitQuad(play, &this->collider); + Collider_SetQuad(play, &this->collider, &this->actor, &sQuadInit); if (this->actor.params < ENARROW_6) { this->collider.info.toucherFlags &= ~(TOUCH_SFX_WOOD | TOUCH_SFX_HARD); @@ -125,21 +125,21 @@ void EnArrow_Init(Actor* thisx, GlobalContext* globalCtx) { this->actionFunc = func_8088A594; } -void EnArrow_Destroy(Actor* thisx, GlobalContext* globalCtx) { +void EnArrow_Destroy(Actor* thisx, PlayState* play) { EnArrow* this = THIS; if (this->actor.params < ENARROW_6) { - Effect_Destroy(globalCtx, this->unk_240); + Effect_Destroy(play, this->unk_240); } - Collider_DestroyQuad(globalCtx, &this->collider); + Collider_DestroyQuad(play, &this->collider); if ((this->unk_264 != NULL) && (this->unk_264->update != NULL)) { - this->unk_264->flags &= ~0x8000; + this->unk_264->flags &= ~ACTOR_FLAG_8000; } if ((this->actor.params >= ENARROW_3) && (this->actor.params < ENARROW_6) && (this->actor.child == NULL)) { - func_80115D5C(&globalCtx->state); + func_80115D5C(&play->state); } } @@ -149,8 +149,8 @@ void func_8088A514(EnArrow* this) { Actor_SetSpeeds(&this->actor, CLAMP(temp_f0, 1.0f, 80.0f)); } -void func_8088A594(EnArrow* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); +void func_8088A594(EnArrow* this, PlayState* play) { + Player* player = GET_PLAYER(play); if (this->actor.parent != NULL) { if (this->actor.params == ENARROW_7) { @@ -162,13 +162,13 @@ void func_8088A594(EnArrow* this, GlobalContext* globalCtx) { this->bubble.unk_148++; if (this->bubble.unk_148 > 20) { this->actionFunc = func_8088ACE0; - func_80115D5C(&globalCtx->state); + func_80115D5C(&play->state); } } } else { if ((this->actor.params != ENARROW_8) && (player->unk_D57 == 0)) { if (this->actor.params == ENARROW_7) { - func_80115D5C(&globalCtx->state); + func_80115D5C(&play->state); } Actor_MarkForDeath(&this->actor); return; @@ -202,7 +202,7 @@ void func_8088A594(EnArrow* this, GlobalContext* globalCtx) { this->bubble.unk_144 = CLAMP_MIN(this->bubble.unk_144, 3.5f); func_8088A514(this); this->unk_260 = 99; - func_80115D5C(&globalCtx->state); + func_80115D5C(&play->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); @@ -221,7 +221,7 @@ void func_8088A594(EnArrow* this, GlobalContext* globalCtx) { } } -void func_8088A7D8(GlobalContext* globalCtx, EnArrow* this) { +void func_8088A7D8(PlayState* play, EnArrow* this) { this->actionFunc = func_8088B6B0; Animation_PlayOnce(&this->arrow.skelAnime, &gameplay_keep_Anim_012860); this->actor.world.rot.y += (s32)(0x6000 * (Rand_ZeroOne() - 0.5f)) + 0x8000; @@ -231,7 +231,7 @@ void func_8088A7D8(GlobalContext* globalCtx, EnArrow* this) { this->unk_263 = 1; } -void func_8088A894(EnArrow* this, GlobalContext* globalCtx) { +void func_8088A894(EnArrow* this, PlayState* play) { CollisionPoly* sp74; Vec3f sp68; Vec3f sp5C; @@ -256,8 +256,8 @@ void func_8088A894(EnArrow* this, GlobalContext* globalCtx) { 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)) { + if (BgCheck_EntityLineTest1(&play->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; @@ -266,14 +266,13 @@ void func_8088A894(EnArrow* this, GlobalContext* globalCtx) { } } -void func_8088AA98(EnArrow* this, GlobalContext* globalCtx) { +void func_8088AA98(EnArrow* this, PlayState* play) { 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) && + if (WaterBox_GetSurface1(play, &play->colCtx, this->actor.world.pos.x, this->actor.world.pos.z, &sp50, &sp54) && (this->actor.world.pos.y < sp50) && !(this->actor.bgCheckFlags & 0x20)) { this->actor.bgCheckFlags |= 0x20; @@ -287,18 +286,18 @@ void func_8088AA98(EnArrow* this, GlobalContext* globalCtx) { 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); + EffectSsGSplash_Spawn(play, &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); + EffectSsGRipple_Spawn(play, &sp44, 100, 500, 0); + EffectSsGRipple_Spawn(play, &sp44, 100, 500, 4); + EffectSsGRipple_Spawn(play, &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_Spawn(&play->actorCtx, play, ACTOR_BG_ICEFLOE, sp44.x, sp44.y, sp44.z, 0, 0, 0, 300); Actor_MarkForDeath(&this->actor); return; } @@ -311,15 +310,12 @@ void func_8088AA98(EnArrow* this, GlobalContext* globalCtx) { return; } - func_80115D5C(&globalCtx->state); + func_80115D5C(&play->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) { +void func_8088ACE0(EnArrow* this, PlayState* play) { CollisionPoly* spAC; s32 spA8; Vec3f sp9C; @@ -330,8 +326,6 @@ void func_8088ACE0(EnArrow* this, GlobalContext* globalCtx) { f32 sp78; f32 sp74; f32 temp_f12_2; - Vec3f sp60; - Vec3f sp54; s32 sp50; if ((DECR(this->unk_260) == 0) || @@ -350,17 +344,17 @@ void func_8088ACE0(EnArrow* this, GlobalContext* globalCtx) { } if ((this->unk_262 != 0) || phi_a2) { - EffectSsStone1_Spawn(globalCtx, &this->actor.world.pos, 0); + EffectSsStone1_Spawn(play, &this->actor.world.pos, 0); } - SoundSource_PlaySfxAtFixedWorldPos(globalCtx, &this->actor.world.pos, 20, NA_SE_IT_DEKUNUTS_BUBLE_VANISH); + SoundSource_PlaySfxAtFixedWorldPos(play, &this->actor.world.pos, 20, NA_SE_IT_DEKUNUTS_BUBLE_VANISH); if ((this->unk_262 != 0) && (this->actor.wallBgId == BG_ACTOR_MAX)) { - Math_Vec3f_Copy(&sp84.unk_00, &this->actor.world.pos); - sp84.unk_0C = this->actor.wallPoly; - sp84.unk_10 = this->bubble.unk_144; - EffectSs_Spawn(globalCtx, EFFECT_SS_SBN, 128, &sp84.unk_00); + Math_Vec3f_Copy(&sp84.pos, &this->actor.world.pos); + sp84.colPoly = this->actor.wallPoly; + sp84.scale = this->bubble.unk_144; + EffectSs_Spawn(play, EFFECT_SS_SBN, 128, &sp84); } } Actor_MarkForDeath(&this->actor); @@ -380,24 +374,24 @@ void func_8088ACE0(EnArrow* this, GlobalContext* globalCtx) { 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); + Actor_Spawn(&play->actorCtx, play, ACTOR_EN_M_FIRE1, this->actor.world.pos.x, this->actor.world.pos.y, + this->actor.world.pos.z, 0, 0, 0, this->actor.speedXZ == 0.0f); 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); + EffectSsStone1_Spawn(play, &this->actor.world.pos, 0); + SoundSource_PlaySfxAtFixedWorldPos(play, &this->actor.world.pos, 20, sp82); Actor_MarkForDeath(&this->actor); } else { - EffectSsHitMark_SpawnCustomScale(globalCtx, 0, 150, &this->actor.world.pos); + EffectSsHitmark_SpawnCustomScale(play, 0, 150, &this->actor.world.pos); if (sp50 && (this->collider.info.atHitInfo->elemType != ELEMTYPE_UNK4)) { sp7C = this->collider.base.at; if ((sp7C->update != NULL) && !(this->collider.base.atFlags & AT_BOUNCED) && (sp7C->flags & 0x4000)) { this->unk_264 = sp7C; - func_8088A894(this, globalCtx); + func_8088A894(this, play); Math_Vec3f_Diff(&sp7C->world.pos, &this->actor.world.pos, &this->unk_268); sp7C->flags |= 0x8000; this->collider.base.atFlags &= ~AT_HIT; @@ -407,7 +401,7 @@ void func_8088ACE0(EnArrow* this, GlobalContext* globalCtx) { this->unk_261 |= 1; this->unk_261 |= 2; Math_Vec3f_Copy(&this->actor.world.pos, &this->actor.prevPos); - func_8088A7D8(globalCtx, this); + func_8088A7D8(play, this); Actor_PlaySfxAtPos(&this->actor, NA_SE_IT_HOOKSHOT_STICK_CRE); } } else if (this->unk_262 != 0) { @@ -426,7 +420,7 @@ void func_8088ACE0(EnArrow* this, GlobalContext* globalCtx) { } } } else { - func_8088AA98(this, globalCtx); + func_8088AA98(this, play); if (this->actor.params == ENARROW_7) { if (this->bubble.unk_149 == 0) { sp78 = sqrtf(SQ(this->actor.speedXZ) + SQ(this->actor.velocity.y)); @@ -471,10 +465,9 @@ void func_8088ACE0(EnArrow* this, GlobalContext* globalCtx) { 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); + if ((this->unk_262 = BgCheck_ProjectileLineTest(&play->colCtx, &this->actor.prevPos, &this->actor.world.pos, + &sp9C, &this->actor.wallPoly, true, true, true, true, &spA8))) { + func_800B90AC(play, &this->actor, this->actor.wallPoly, spA8, &sp9C); Math_Vec3f_Copy(&this->actor.world.pos, &sp9C); this->actor.wallBgId = spA8; } @@ -486,26 +479,26 @@ void func_8088ACE0(EnArrow* this, GlobalContext* globalCtx) { if (this->unk_264 != NULL) { if (this->unk_264->update != NULL) { - s32 pad; + Vec3f sp60; + Vec3f sp54; 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)) { + if (BgCheck_EntityLineTest1(&play->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->flags &= ~ACTOR_FLAG_8000; this->unk_264 = NULL; } else { Math_Vec3f_Sum(&this->actor.world.pos, &this->unk_268, &this->unk_264->world.pos); } if ((this->unk_262 != 0) && (this->unk_264 != NULL)) { - this->unk_264->flags &= ~0x8000; + this->unk_264->flags &= ~ACTOR_FLAG_8000; this->unk_264 = NULL; } } else { @@ -513,15 +506,12 @@ void func_8088ACE0(EnArrow* this, GlobalContext* globalCtx) { } } } -#else -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Arrow/func_8088ACE0.s") -#endif -void func_8088B630(EnArrow* this, GlobalContext* globalCtx) { +void func_8088B630(EnArrow* this, PlayState* play) { SkelAnime_Update(&this->arrow.skelAnime); if (this->actor.wallBgId != BG_ACTOR_MAX) { - BgCheck2_UpdateActorAttachedToMesh(&globalCtx->colCtx, this->actor.wallBgId, &this->actor); + BgCheck2_UpdateActorAttachedToMesh(&play->colCtx, this->actor.wallBgId, &this->actor); } if (DECR(this->unk_260) == 0) { @@ -529,40 +519,40 @@ void func_8088B630(EnArrow* this, GlobalContext* globalCtx) { } } -void func_8088B6B0(EnArrow* this, GlobalContext* globalCtx) { +void func_8088B6B0(EnArrow* this, PlayState* play) { SkelAnime_Update(&this->arrow.skelAnime); Actor_MoveWithGravity(&this->actor); - func_8088AA98(this, globalCtx); + func_8088AA98(this, play); if (DECR(this->unk_260) == 0) { Actor_MarkForDeath(&this->actor); } } -void EnArrow_Update(Actor* thisx, GlobalContext* globalCtx) { +void EnArrow_Update(Actor* thisx, PlayState* play) { 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); + Player* player = GET_PLAYER(play); 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); + !Player_InBlockingCsMode(play, player)) { + this->actionFunc(this, play); } if ((this->actor.params >= ENARROW_3) && (this->actor.params < ENARROW_6)) { s16 sp44[] = { ACTOR_ARROW_FIRE, ACTOR_ARROW_ICE, ACTOR_ARROW_LIGHT }; if (this->actor.child == NULL) { - Actor_SpawnAsChild(&globalCtx->actorCtx, &this->actor, globalCtx, sp44[this->actor.params - ENARROW_3], + Actor_SpawnAsChild(&play->actorCtx, &this->actor, play, 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); + func_800B0EB0(play, &this->unk_234, &D_8088C2CC, &D_8088C2D8, &D_8088C2E4, &D_8088C2E8, 100, 0, 8); } Math_Vec3f_Copy(&this->actor.home.pos, &this->actor.prevPos); } @@ -573,27 +563,28 @@ typedef struct { /* 0x48 */ Vec3f unk_48; } EnArrowUnkStruct; // size = 0x54 -void func_8088B88C(GlobalContext* globalCtx, EnArrow* this, EnArrowUnkStruct* arg2) { +void func_8088B88C(PlayState* play, EnArrow* this, EnArrowUnkStruct* arg2) { Vec3f* sp4C; Vec3f sp40; Vec3f sp34; s32 sp30; - Matrix_MultiplyVector3fByState(&arg2->unk_48, &this->unk_234); + Matrix_MultVec3f(&arg2->unk_48, &this->unk_234); if (func_8088ACE0 == this->actionFunc) { - if (this->unk_244 == 0) { + if (!this->unk_244.active) { sp4C = arg2->unk_00; } else { - sp4C = arg2->unk_18[globalCtx->gameplayFrames % 2]; + sp4C = arg2->unk_18[play->gameplayFrames % 2]; } - Matrix_MultiplyVector3fByState(&sp4C[0], &sp40); - Matrix_MultiplyVector3fByState(&sp4C[1], &sp34); + 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.base, &this->unk_244, &sp40, &sp34); - } else if (sp30 && (sp40.x == this->unk_248) && (sp40.y == this->unk_24C) && (sp40.z == this->unk_250) && - (sp34.x == this->unk_254) && (sp34.y == this->unk_258) && (sp34.z == this->unk_25C)) { + if (this->unk_264 == NULL) { + sp30 &= func_80126440(play, &this->collider, &this->unk_244, &sp40, &sp34); + } else if (sp30 && (sp40.x == this->unk_244.tip.x) && (sp40.y == this->unk_244.tip.y) && + (sp40.z == this->unk_244.tip.z) && (sp34.x == this->unk_244.base.x) && + (sp34.y == this->unk_244.base.y) && (sp34.z == this->unk_244.base.z)) { sp30 = false; } if (sp30) { @@ -603,7 +594,7 @@ void func_8088B88C(GlobalContext* globalCtx, EnArrow* this, EnArrowUnkStruct* ar } } -void EnArrow_Draw(Actor* thisx, GlobalContext* globalCtx) { +void EnArrow_Draw(Actor* thisx, PlayState* play) { static EnArrowUnkStruct D_8088C2EC[] = { { { @@ -644,20 +635,20 @@ void EnArrow_Draw(Actor* thisx, GlobalContext* globalCtx) { s32 phi_v0; if (this->actor.params < ENARROW_6) { - func_8012C28C(globalCtx->state.gfxCtx); - SkelAnime_DrawLod(globalCtx, this->arrow.skelAnime.skeleton, this->arrow.skelAnime.jointTable, NULL, NULL, + func_8012C28C(play->state.gfxCtx); + SkelAnime_DrawLod(play, 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); + OPEN_DISPS(play->state.gfxCtx); if (this->bubble.unk_149 >= 0) { - func_8088B88C(globalCtx, this, &D_8088C2EC[1]); + func_8088B88C(play, this, &D_8088C2EC[1]); } else { - Collider_ResetQuadAT(globalCtx, &this->collider.base); + Collider_ResetQuadAT(play, &this->collider.base); } sp9C *= 0.002f; @@ -665,10 +656,10 @@ void EnArrow_Draw(Actor* thisx, GlobalContext* globalCtx) { Matrix_Scale(this->bubble.unk_144 * sp9C, this->bubble.unk_144 * sp9C, this->bubble.unk_144 * spA0, MTXMODE_APPLY); - Matrix_InsertTranslation(0.0f, 0.0f, 460.0f, MTXMODE_APPLY); + Matrix_Translate(0.0f, 0.0f, 460.0f, MTXMODE_APPLY); if (this->actor.speedXZ == 0.0f) { - func_800B8118(&this->actor, globalCtx, MTXMODE_NEW); + func_800B8118(&this->actor, play, 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); @@ -676,34 +667,32 @@ void EnArrow_Draw(Actor* thisx, GlobalContext* globalCtx) { COMBINED, 0, ENVIRONMENT, 0, COMBINED, 0, ENVIRONMENT, 0); gDPSetEnvColor(POLY_XLU_DISP++, 230, 225, 150, spA4); - Matrix_NormalizeXYZ(&gIdentityMtxF); + 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++, Matrix_NewMtx(play->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); + func_800B8050(&this->actor, play, 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); + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_OPA_DISP++, gameplay_keep_DL_06FAE0); } - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->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); + OPEN_DISPS(play->state.gfxCtx); - func_8012C240(globalCtx->state.gfxCtx); + func_8012C240(play->state.gfxCtx); gSPClearGeometryMode(POLY_XLU_DISP++, G_FOG | G_LIGHTING); @@ -717,35 +706,35 @@ void EnArrow_Draw(Actor* thisx, GlobalContext* globalCtx) { sp5C = 150.0f; } - Matrix_StatePush(); - Matrix_InsertMatrix(&globalCtx->billboardMtxF, MTXMODE_APPLY); + Matrix_Push(); + Matrix_Mult(&play->billboardMtxF, MTXMODE_APPLY); if (this->actor.speedXZ == 0.0f) { phi_v0 = 0; } else { - phi_v0 = (globalCtx->gameplayFrames % 256) * 4000; + phi_v0 = (play->gameplayFrames % 256) * 4000; } - Matrix_InsertZRotation_s(phi_v0, MTXMODE_APPLY); + 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++, gameplay_keep_DL_054A90); + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_XLU_DISP++, gEffSparklesDL); - Matrix_StatePop(); - Matrix_RotateY(this->actor.world.rot.y, MTXMODE_APPLY); + Matrix_Pop(); + Matrix_RotateYS(this->actor.world.rot.y, MTXMODE_APPLY); - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->state.gfxCtx); } else if (this->actor.velocity.y != 0.0f) { - OPEN_DISPS(globalCtx->state.gfxCtx); + OPEN_DISPS(play->state.gfxCtx); - func_8012C28C(globalCtx->state.gfxCtx); - Matrix_InsertMatrix(&globalCtx->billboardMtxF, MTXMODE_APPLY); + func_8012C28C(play->state.gfxCtx); + Matrix_Mult(&play->billboardMtxF, MTXMODE_APPLY); - gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_OPA_DISP++, gameplay_keep_DL_058BA0); - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->state.gfxCtx); } - func_8088B88C(globalCtx, this, &D_8088C2EC[0]); + func_8088B88C(play, 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 f318cf152..fadf7fbf2 100644 --- a/src/overlays/actors/ovl_En_Arrow/z_en_arrow.h +++ b/src/overlays/actors/ovl_En_Arrow/z_en_arrow.h @@ -5,7 +5,7 @@ struct EnArrow; -typedef void (*EnArrowActionFunc)(struct EnArrow*, GlobalContext*); +typedef void (*EnArrowActionFunc)(struct EnArrow*, PlayState*); enum { /* -8 */ ENARROW_MINUS8 = -8, @@ -43,13 +43,7 @@ typedef struct EnArrow { /* 0x228 */ Vec3f unk_228; /* 0x234 */ Vec3f unk_234; /* 0x240 */ s32 unk_240; - /* 0x244 */ s32 unk_244; - /* 0x248 */ f32 unk_248; - /* 0x24C */ f32 unk_24C; - /* 0x250 */ f32 unk_250; - /* 0x254 */ f32 unk_254; - /* 0x258 */ f32 unk_258; - /* 0x25C */ f32 unk_25C; + /* 0x244 */ WeaponInfo unk_244; /* 0x260 */ u8 unk_260; // timer in OoT /* 0x261 */ u8 unk_261; // hitFlags in OoT /* 0x262 */ u8 unk_262; 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 b100f692f..72ca1ba8e 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,7 +1,7 @@ /* * File: z_en_attack_niw.c * Overlay: ovl_En_Attack_Niw - * Description: Attacking cucco + * Description: Attacking Cucco */ #include "z_en_attack_niw.h" @@ -11,14 +11,14 @@ #define THIS ((EnAttackNiw*)thisx) -void EnAttackNiw_Init(Actor* thisx, GlobalContext* globalCtx); -void EnAttackNiw_Destroy(Actor* thisx, GlobalContext* globalCtx); -void EnAttackNiw_Update(Actor* thisx, GlobalContext* globalCtx); -void EnAttackNiw_Draw(Actor* thisx, GlobalContext* globalCtx); +void EnAttackNiw_Init(Actor* thisx, PlayState* play); +void EnAttackNiw_Destroy(Actor* thisx, PlayState* play); +void EnAttackNiw_Update(Actor* thisx, PlayState* play); +void EnAttackNiw_Draw(Actor* thisx, PlayState* play); -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, PlayState* play); +void EnAttackNiw_AimAtPlayer(EnAttackNiw* this, PlayState* play); +void EnAttackNiw_FlyAway(EnAttackNiw* this, PlayState* play); const ActorInit En_Attack_Niw_InitVars = { ACTOR_EN_ATTACK_NIW, @@ -38,415 +38,413 @@ static InitChainEntry sInitChain[] = { ICHAIN_F32(targetArrowOffset, 0, ICHAIN_STOP), }; -void EnAttackNiw_Init(Actor* thisx, GlobalContext* globalCtx) { +void EnAttackNiw_Init(Actor* thisx, PlayState* play) { EnAttackNiw* this = THIS; Actor_ProcessInitChain(&this->actor, sInitChain); ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 25.0f); - SkelAnime_InitFlex(globalCtx, &this->skelAnime, &object_niw_Skel_002530, &object_niw_Anim_0000E8, this->jointTable, - this->morphTable, OBJECT_NIW_LIMB_MAX); + SkelAnime_InitFlex(play, &this->skelAnime, &gNiwSkeleton, &gNiwIdleAnim, this->jointTable, this->morphTable, + NIW_LIMB_MAX); + // probably copy pasted from EnNiw, which has this same code, but AttackNiw has no params if (this->actor.params < 0) { - this->actor.params = 0; + this->actor.params = ATTACK_NIW_REGULAR; } Actor_SetScale(&this->actor, 0.01f); this->actor.gravity = 0.0f; - this->unk_290.x = randPlusMinusPoint5Scaled(100.0f); - this->unk_290.y = randPlusMinusPoint5Scaled(10.0f); - this->unk_290.z = randPlusMinusPoint5Scaled(100.0f); + this->randomTargetCenterOffset.x = randPlusMinusPoint5Scaled(100.0f); + this->randomTargetCenterOffset.y = randPlusMinusPoint5Scaled(10.0f); + this->randomTargetCenterOffset.z = randPlusMinusPoint5Scaled(100.0f); Actor_SetScale(&this->actor, 0.01f); - this->actor.flags &= ~ACTOR_FLAG_1; + 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 = func_80958634; + this->actionFunc = EnAttackNiw_EnterViewFromOffscreen; } -void EnAttackNiw_Destroy(Actor* thisx, GlobalContext* globalCtx) { +void EnAttackNiw_Destroy(Actor* thisx, PlayState* play) { EnAttackNiw* this = THIS; EnNiw* parent = (EnNiw*)this->actor.parent; - if ((thisx->parent != NULL) && (thisx->parent->update != NULL)) { - if (parent->unk290 > 0) { - parent->unk290--; + if (this->actor.parent != NULL && this->actor.parent->update != NULL) { + if (parent->attackNiwCount > 0) { + parent->attackNiwCount--; } } } -void func_80958228(EnAttackNiw* this, GlobalContext* globalCtx, s16 arg2) { - if (this->unk_24C == 0) { - if (arg2 == 0) { - this->unk_25C = 0.0f; +/** + * 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, PlayState* play, s16 animationState) { + if (this->unkTimer24C == 0) { + if (animationState == 0) { + this->targetBodyRotY = 0.0f; } else { - this->unk_25C = -10000.0f; + this->targetBodyRotY = -10000.0f; } - this->unk_286++; - this->unk_24C = 3; - if ((this->unk_286 % 2) == 0) { - this->unk_25C = 0.0f; - if (arg2 == 0) { - this->unk_24C = Rand_ZeroFloat(30.0f); + + this->clearRotYToggleTimer++; + this->unkTimer24C = 3; + if ((this->clearRotYToggleTimer % 2) == 0) { + this->targetBodyRotY = 0.0f; + if (animationState == 0) { + this->unkTimer24C = Rand_ZeroFloat(30.0f); } } } - if (this->unk_250 == 0) { - this->unk_28A++; - this->unk_28A &= 1; + if (this->unkTimer250 == 0) { + this->unkToggle28A++; + this->unkToggle28A &= 1; - switch (arg2) { - case 0: - this->unk_264 = 0.0f; - this->unk_260 = 0.0f; + switch (animationState) { // only case 2 and 5 are ever called in AttackNiw + case NIW_ANIM_STILL: + this->targetLeftWingRotZ = 0.0f; + this->targetRightWingRotZ = 0.0f; break; - case 1: - this->unk_250 = 3; - this->unk_264 = 7000.0f; - this->unk_260 = 7000.0f; - if (this->unk_28A == 0) { - this->unk_264 = 0.0f; - this->unk_260 = 0.0f; + case NIW_ANIM_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 2: - this->unk_250 = 2; - this->unk_264 = -10000.0f; - this->unk_260 = -10000.0f; - this->unk_278 = 25000.0f; - this->unk_270 = 25000.0f; - this->unk_27C = 6000.0f; - this->unk_274 = 6000.0f; - if (this->unk_28A == 0) { - this->unk_270 = 8000.0f; - this->unk_278 = 8000.0f; + case NIW_ANIM_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 3: - this->unk_250 = 2; - this->unk_270 = 10000.0f; - this->unk_278 = 10000.0f; - if (this->unk_28A == 0) { - this->unk_270 = 3000.0f; - this->unk_278 = 3000.0f; + case NIW_ANIM_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 4: - this->unk_24E = 5; - this->unk_24C = this->unk_24E; + case NIW_ANIM_FREEZE: + this->unusedTimer24E = 5; + this->unkTimer24C = this->unusedTimer24E; break; - case 5: - this->unk_250 = 5; - this->unk_270 = 14000.0f; - this->unk_278 = 14000.0f; - if (this->unk_28A == 0) { - this->unk_270 = 10000.0f; - this->unk_278 = 10000.0f; + case NIW_ANIM_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->unk_280 != this->unk_2B8) { - Math_ApproachF(&this->unk_2B8, this->unk_280, 0.5f, 4000.0f); + if (this->targetHeadRotZ != this->headRotZ) { + Math_ApproachF(&this->headRotZ, this->targetHeadRotZ, 0.5f, 4000.0f); } - if (this->unk_25C != this->unk_2B4) { - Math_ApproachF(&this->unk_2B4, this->unk_25C, 0.5f, 4000.0f); + if (this->targetBodyRotY != this->upperBodyRotY) { + Math_ApproachF(&this->upperBodyRotY, this->targetBodyRotY, 0.5f, 4000.0f); } - if (this->unk_264 != this->unk_29C) { - Math_ApproachF(&this->unk_29C, this->unk_264, 0.8f, 7000.0f); + if (this->targetLeftWingRotZ != this->leftWingRotZ) { + Math_ApproachF(&this->leftWingRotZ, this->targetLeftWingRotZ, 0.8f, 7000.0f); } - if (this->unk_278 != this->unk_2A0) { - Math_ApproachF(&this->unk_2A0, this->unk_278, 0.8f, 7000.0f); + if (this->targetLeftWingRotY != this->leftWingRotY) { + Math_ApproachF(&this->leftWingRotY, this->targetLeftWingRotY, 0.8f, 7000.0f); } - if (this->unk_27C != this->unk_2A4) { - Math_ApproachF(&this->unk_2A4, this->unk_27C, 0.8f, 7000.0f); + if (this->targetLeftWingRotX != this->leftWingRotX) { + Math_ApproachF(&this->leftWingRotX, this->targetLeftWingRotX, 0.8f, 7000.0f); } - if (this->unk_260 != this->unk_2A8) { - Math_ApproachF(&this->unk_2A8, this->unk_260, 0.8f, 7000.0f); + if (this->targetRightWingRotZ != this->rightWingRotZ) { + Math_ApproachF(&this->rightWingRotZ, this->targetRightWingRotZ, 0.8f, 7000.0f); } - if (this->unk_270 != this->unk_2AC) { - Math_ApproachF(&this->unk_2AC, this->unk_270, 0.8f, 7000.0f); + if (this->targetRightWingRotY != this->rightWingRotY) { + Math_ApproachF(&this->rightWingRotY, this->targetRightWingRotY, 0.8f, 7000.0f); } - if (this->unk_274 != this->unk_2B0) { - Math_ApproachF(&this->unk_2B0, this->unk_274, 0.8f, 7000.0f); + if (this->targetRightWingRotX != this->rightWingRotX) { + Math_ApproachF(&this->rightWingRotX, this->targetRightWingRotX, 0.8f, 7000.0f); } } -s32 func_809585B0(EnAttackNiw* this, GlobalContext* globalCtx) { - s16 sp1E; - s16 sp1C; +s32 EnAttackNiw_IsOnScreen(EnAttackNiw* this, PlayState* play) { + s16 posX; + s16 posY; - Actor_SetFocus(&this->actor, this->unk_2DC); - Actor_GetScreenPos(globalCtx, &this->actor, &sp1E, &sp1C); + Actor_SetFocus(&this->actor, this->targetHeight); + Actor_GetScreenPos(play, &this->actor, &posX, &posY); - if ((this->actor.projectedPos.z < -20.0f) || (sp1E < 0) || (sp1E > SCREEN_WIDTH) || (sp1C < 0) || - (sp1C > SCREEN_HEIGHT)) { + if ((this->actor.projectedPos.z < -20.0f) || (posX < 0) || (posX > SCREEN_WIDTH) || (posY < 0) || + (posY > SCREEN_HEIGHT)) { return false; } return true; } -void func_80958634(EnAttackNiw* this, GlobalContext* globalCtx) { - s16 sp4E; - s16 sp4C; - Vec3f temp; - Vec3f sp34; +void EnAttackNiw_EnterViewFromOffscreen(EnAttackNiw* this, PlayState* play) { + s16 posX; + s16 posY; + Vec3f viewOffset; + Vec3f flightTarget; s32 pad; this->actor.speedXZ = 10.0f; - temp.x = (this->unk_290.x + globalCtx->view.at.x) - globalCtx->view.eye.x; - temp.y = (this->unk_290.y + globalCtx->view.at.y) - globalCtx->view.eye.y; - temp.z = (this->unk_290.z + globalCtx->view.at.z) - globalCtx->view.eye.z; + // 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 + play->view.at.x - play->view.eye.x; + viewOffset.y = this->randomTargetCenterOffset.y + play->view.at.y - play->view.eye.y; + viewOffset.z = this->randomTargetCenterOffset.z + play->view.at.z - play->view.eye.z; - sp34.x = globalCtx->view.at.x + temp.x; - sp34.y = globalCtx->view.at.y + temp.y; - sp34.z = globalCtx->view.at.z + temp.z; + // this is the 3D spot in space where the cucco is trying to fly into (until it lands or gets close) + flightTarget.x = play->view.at.x + viewOffset.x; + flightTarget.y = play->view.at.y + viewOffset.y; + flightTarget.z = play->view.at.z + viewOffset.z; - this->unk_2CC = Math_Vec3f_Yaw(&this->actor.world.pos, &sp34); - this->unk_2C8 = Math_Vec3f_Pitch(&this->actor.world.pos, &sp34) * -1.0f; + 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->unk_2CC, 5, this->unk_2D4, 0); - Math_SmoothStepToS(&this->actor.world.rot.x, this->unk_2C8, 5, this->unk_2D4, 0); - Math_ApproachF(&this->unk_2D4, 5000.0f, 1.0f, 100.0f); + 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->unk_2DC); - Actor_GetScreenPos(globalCtx, &this->actor, &sp4E, &sp4C); + Actor_SetFocus(&this->actor, this->targetHeight); + Actor_GetScreenPos(play, &this->actor, &posX, &posY); - if (this->actor.bgCheckFlags & 8) { - this->unk_2CC = this->actor.yawTowardsPlayer; - this->unk_2C8 = this->actor.world.rot.x - 3000.0f; - this->unk_252 = 0; - this->unk_254 = 100; - this->unk_2D4 = 0.0f; - this->unk_27C = 0.0f; - this->unk_274 = 0.0f; - this->unk_250 = this->unk_252; - this->unk_24E = this->unk_252; - this->unk_24C = this->unk_252; + 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->unk_280 = 0.0f; - this->actionFunc = func_80958974; - this->unk_2D8 = 5.0f; - } else if (((this->actor.projectedPos.z > 0.0f) && (fabsf(sp34.x - this->actor.world.pos.x) < 50.0f) && - (fabsf(sp34.y - this->actor.world.pos.y) < 50.0f) && - (fabsf(sp34.z - this->actor.world.pos.z) < 50.0f)) || - (this->actor.bgCheckFlags & 1)) { - this->unk_252 = 0; - this->unk_250 = this->unk_252; - this->unk_24E = this->unk_252; - this->unk_24C = this->unk_252; - this->unk_2D4 = 0.0f; - this->unk_274 = 0.0f; - this->unk_27C = 0.0f; - this->unk_2CC = this->actor.yawTowardsPlayer; - this->unk_2C8 = this->actor.world.rot.x - 2000.0f; - this->actor.gravity = -0.2f; - this->unk_280 = 0.0f; - this->actionFunc = func_80958974; - this->unk_2D8 = 5.0f; - } else { - this->unk_24C = 10; - this->unk_25C = -10000.0f; - this->unk_280 = -3000.0f; - func_80958228(this, globalCtx, 2); + 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, play, NIW_ANIM_PECKING_AND_WAVING); } } -void func_80958974(EnAttackNiw* this, GlobalContext* globalCtx) { - if (!func_809585B0(this, globalCtx)) { +void EnAttackNiw_AimAtPlayer(EnAttackNiw* this, PlayState* play) { + if (!EnAttackNiw_IsOnScreen(this, play)) { Actor_MarkForDeath(&this->actor); return; } - if (this->actor.bgCheckFlags & 1) { - if (this->unk_252 == 0) { - this->unk_252 = 3; + 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) { - this->unk_2CC = this->actor.yawTowardsPlayer; - this->unk_25A = 50; - this->unk_254 = 100; - this->unk_270 = 14000.0f; - this->unk_278 = 14000.0f; - this->unk_274 = 0.0f; - this->unk_27C = 0.0f; - this->unk_260 = 0.0f; - this->unk_264 = 0.0f; - this->unk_2C8 = 0.0f; + 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->unk_254 == 50) { - this->unk_2CC = randPlusMinusPoint5Scaled(200.0f) + this->actor.yawTowardsPlayer; + if (this->randomAngleChangeTimer == 50) { + this->targetRotY = randPlusMinusPoint5Scaled(200.0f) + this->actor.yawTowardsPlayer; } - Math_SmoothStepToS(&this->actor.world.rot.y, this->unk_2CC, 2, this->unk_2D4, 0); - Math_SmoothStepToS(&this->actor.world.rot.x, this->unk_2C8, 2, this->unk_2D4, 0); - Math_ApproachF(&this->unk_2D4, 10000.0f, 1.0f, 1000.0f); - Math_ApproachF(&this->actor.speedXZ, this->unk_2D8, 0.9f, 1.0f); + 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->unk_25A == 0) && - ((this->actor.bgCheckFlags & 8) || (this->unk_254 == 0))) { - this->unk_2D8 = 0.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->unk_2D4 = 0.0f; - this->unk_2C8 = this->actor.world.rot.x - 5000.0f; - this->actionFunc = func_80958BE4; - } else if (this->actor.bgCheckFlags & 1) { - func_80958228(this, globalCtx, 5); + 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, play, NIW_ANIM_PECKING_SLOW_FORFLAPPING); + } else { - func_80958228(this, globalCtx, 2); + EnAttackNiw_AnimateWingHead(this, play, NIW_ANIM_PECKING_AND_WAVING); } } -void func_80958BE4(EnAttackNiw* this, GlobalContext* globalCtx) { - if (!func_809585B0(this, globalCtx)) { +void EnAttackNiw_FlyAway(EnAttackNiw* this, PlayState* play) { + if (!EnAttackNiw_IsOnScreen(this, play)) { Actor_MarkForDeath(&this->actor); return; } - Math_SmoothStepToS(&this->actor.world.rot.x, this->unk_2C8, 5, this->unk_2D4, 0); - Math_ApproachF(&this->unk_2D4, 5000.0f, 1.0f, 100.0f); + Math_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); - func_80958228(this, globalCtx, 2); + EnAttackNiw_AnimateWingHead(this, play, NIW_ANIM_PECKING_AND_WAVING); } -void EnAttackNiw_Update(Actor* thisx, GlobalContext* globalCtx) { +void EnAttackNiw_Update(Actor* thisx, PlayState* play) { EnAttackNiw* this = THIS; s32 pad; EnNiw* parent; - Player* player = GET_PLAYER(globalCtx); + Player* player = GET_PLAYER(play); s32 pad2; - Vec3f sp30; + Vec3f splashPos; - this->unk_284++; + this->unusedCounter284++; - if (this->unk_24C != 0) { - this->unk_24C--; - } - - if (this->unk_250 != 0) { - this->unk_250--; - } - - if (this->unk_252 != 0) { - this->unk_252--; - } - - if (this->unk_256 != 0) { - this->unk_256--; - } - - if (this->unk_258 != 0) { - this->unk_258--; - } - - if (this->unk_254 != 0) { - this->unk_254--; - } - - if (this->unk_25A != 0) { - this->unk_25A--; - } + 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); + this->actionFunc(this, play); - Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 20.0f, 20.0f, 60.0f, 0x1D); + Actor_UpdateBgCheckInfo(play, &this->actor, 20.0f, 20.0f, 60.0f, 0x1D); - if (this->actionFunc == func_80958634) { + if (this->actionFunc == EnAttackNiw_EnterViewFromOffscreen) { Actor_MoveWithoutGravity(&this->actor); } else { Actor_MoveWithGravity(&this->actor); } - if (this->actor.floorHeight <= -32000.0f) { + if (this->actor.floorHeight <= BGCHECK_Y_MIN) { // under the world Actor_MarkForDeath(&this->actor); - } else if ((this->actor.bgCheckFlags & 0x20) && (this->actionFunc != func_80958BE4)) { - Math_Vec3f_Copy(&sp30, &this->actor.world.pos); - sp30.y += this->actor.depthInWater; - EffectSsGSplash_Spawn(globalCtx, &sp30, NULL, NULL, 0, 400); - this->unk_2D4 = 0.0f; + } 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(play, &splashPos, NULL, NULL, 0, 400); + this->rotStep = 0.0f; this->actor.gravity = 0.0f; - this->unk_2D8 = 0.0f; - this->unk_2C8 = this->actor.world.rot.x - 5000.0f; - this->actionFunc = func_80958BE4; + this->targetXZSpeed = 0.0f; + this->targetRotX = this->actor.world.rot.x - 5000.0f; + this->actionFunc = EnAttackNiw_FlyAway; + } else { - f32 temp = 20.0f; + f32 viewOffset = 20.0f; label: - if (this->actor.xyzDistToPlayerSq < SQ(temp)) { + if (this->actor.xyzDistToPlayerSq < SQ(viewOffset)) { parent = (EnNiw*)this->actor.parent; if ((this->actor.parent->update != NULL) && (this->actor.parent != NULL) && (parent != NULL) && - (parent->unusedTimer25E == 0) && (player->invincibilityTimer == 0)) { - func_800B8D50(globalCtx, &this->actor, 2.0f, this->actor.world.rot.y, 0.0f, 0x10); - parent->unusedTimer25E = 70; + (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(play, &this->actor, 2.0f, this->actor.world.rot.y, 0.0f, 0x10); + parent->unkAttackNiwTimer = 70; } } - if (this->unk_256 == 0) { - this->unk_256 = 30; + if (this->crySfxTimer == 0) { + this->crySfxTimer = 30; Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_CHICKEN_CRY_A); } - if (this->unk_258 == 0) { - this->unk_258 = 7; + 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) { +s32 EnAttackNiw_OverrideLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, Actor* thisx) { EnAttackNiw* this = THIS; - if (limbIndex == OBJECT_NIW_LIMB_0D) { - rot->y += (s16)this->unk_2B4; + if (limbIndex == NIW_LIMB_UPPER_BODY) { + rot->y += (s16)this->upperBodyRotY; } - if (limbIndex == OBJECT_NIW_LIMB_0F) { - rot->z += (s16)this->unk_2B8; + if (limbIndex == NIW_LIMB_HEAD) { + rot->z += (s16)this->headRotZ; } - if (limbIndex == OBJECT_NIW_LIMB_0B) { - rot->x += (s16)this->unk_2B0; - rot->y += (s16)this->unk_2AC; - rot->z += (s16)this->unk_2A8; + if (limbIndex == NIW_LIMB_RIGHT_WING_ROOT) { + rot->x += (s16)this->rightWingRotX; + rot->y += (s16)this->rightWingRotY; + rot->z += (s16)this->rightWingRotZ; } - if (limbIndex == OBJECT_NIW_LIMB_07) { - rot->x += (s16)this->unk_2A4; - rot->y += (s16)this->unk_2A0; - rot->z += (s16)this->unk_29C; + 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) { +void EnAttackNiw_Draw(Actor* thisx, PlayState* play) { EnAttackNiw* this = THIS; - func_8012C28C(globalCtx->state.gfxCtx); - SkelAnime_DrawFlexOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, + func_8012C28C(play->state.gfxCtx); + SkelAnime_DrawFlexOpa(play, 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 4d3243ef5..a1e29d627 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 @@ -6,54 +6,57 @@ struct EnAttackNiw; -typedef void (*EnAttackNiwActionFunc)(struct EnAttackNiw*, GlobalContext*); +typedef void (*EnAttackNiwActionFunc)(struct EnAttackNiw*, PlayState*); typedef struct EnAttackNiw { /* 0x000 */ Actor actor; /* 0x144 */ SkelAnime skelAnime; - /* 0x188 */ Vec3s jointTable[OBJECT_NIW_LIMB_MAX]; - /* 0x1E8 */ Vec3s morphTable[OBJECT_NIW_LIMB_MAX]; + /* 0x188 */ Vec3s jointTable[NIW_LIMB_MAX]; + /* 0x1E8 */ Vec3s morphTable[NIW_LIMB_MAX]; /* 0x248 */ EnAttackNiwActionFunc actionFunc; - /* 0x24C */ s16 unk_24C; - /* 0x24E */ s16 unk_24E; - /* 0x250 */ s16 unk_250; - /* 0x252 */ s16 unk_252; - /* 0x254 */ s16 unk_254; - /* 0x256 */ s16 unk_256; - /* 0x258 */ s16 unk_258; - /* 0x25A */ s16 unk_25A; - /* 0x25C */ f32 unk_25C; - /* 0x260 */ f32 unk_260; - /* 0x264 */ f32 unk_264; - /* 0x268 */ UNK_TYPE1 unk268[8]; - /* 0x270 */ f32 unk_270; - /* 0x274 */ f32 unk_274; - /* 0x278 */ f32 unk_278; - /* 0x27C */ f32 unk_27C; - /* 0x280 */ f32 unk_280; - /* 0x284 */ s16 unk_284; - /* 0x286 */ s16 unk_286; - /* 0x288 */ UNK_TYPE1 unk288[2]; - /* 0x28A */ s16 unk_28A; - /* 0x28C */ UNK_TYPE1 unk28C[4]; - /* 0x290 */ Vec3f unk_290; - /* 0x29C */ f32 unk_29C; - /* 0x2A0 */ f32 unk_2A0; - /* 0x2A4 */ f32 unk_2A4; - /* 0x2A8 */ f32 unk_2A8; - /* 0x2AC */ f32 unk_2AC; - /* 0x2B0 */ f32 unk_2B0; - /* 0x2B4 */ f32 unk_2B4; - /* 0x2B8 */ f32 unk_2B8; - /* 0x2BC */ UNK_TYPE1 unk2BC[0xC]; - /* 0x2C8 */ f32 unk_2C8; - /* 0x2CC */ f32 unk_2CC; - /* 0x2D0 */ UNK_TYPE1 unk2D0[4]; - /* 0x2D4 */ f32 unk_2D4; - /* 0x2D8 */ f32 unk_2D8; - /* 0x2DC */ f32 unk_2DC; + /* 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 f815991c1..c025a6f77 100644 --- a/src/overlays/actors/ovl_En_Az/z_en_az.c +++ b/src/overlays/actors/ovl_En_Az/z_en_az.c @@ -10,21 +10,21 @@ #define THIS ((EnAz*)thisx) -void EnAz_Init(Actor* thisx, GlobalContext* globalCtx); -void EnAz_Destroy(Actor* thisx, GlobalContext* globalCtx); -void EnAz_Update(Actor* thisx, GlobalContext* globalCtx); -void EnAz_Draw(Actor* thisx, GlobalContext* globalCtx); +void EnAz_Init(Actor* thisx, PlayState* play); +void EnAz_Destroy(Actor* thisx, PlayState* play); +void EnAz_Update(Actor* thisx, PlayState* play); +void EnAz_Draw(Actor* thisx, PlayState* play); -void func_80A95CEC(EnAz* this, GlobalContext* globalCtx); -void func_80A95E88(EnAz* this, GlobalContext* globalCtx); -void func_80A95FE8(EnAz* this, GlobalContext* globalCtx); -void func_80A979F4(EnAz* this, GlobalContext* globalCtx); -void func_80A97A40(EnAz* this, GlobalContext* globalCtx); -void func_80A97AB4(EnAz* this, GlobalContext* globalCtx); -void func_80A97C24(EnAz* this, GlobalContext* globalCtx); -void func_80A97C4C(EnAz* this, GlobalContext* globalCtx); -void func_80A97E48(EnAz* this, GlobalContext* globalCtx); -void func_80A97F9C(EnAz* this, GlobalContext* globalCtx); +void func_80A95CEC(EnAz* this, PlayState* play); +void func_80A95E88(EnAz* this, PlayState* play); +void func_80A95FE8(EnAz* this, PlayState* play); +void func_80A979F4(EnAz* this, PlayState* play); +void func_80A97A40(EnAz* this, PlayState* play); +void func_80A97AB4(EnAz* this, PlayState* play); +void func_80A97C24(EnAz* this, PlayState* play); +void func_80A97C4C(EnAz* this, PlayState* play); +void func_80A97E48(EnAz* this, PlayState* play); +void func_80A97F9C(EnAz* this, PlayState* play); #if 0 const ActorInit En_Az_InitVars = { diff --git a/src/overlays/actors/ovl_En_Az/z_en_az.h b/src/overlays/actors/ovl_En_Az/z_en_az.h index 89d7c1a09..5c302c6f3 100644 --- a/src/overlays/actors/ovl_En_Az/z_en_az.h +++ b/src/overlays/actors/ovl_En_Az/z_en_az.h @@ -5,12 +5,12 @@ struct EnAz; -typedef void (*EnAzActionFunc)(struct EnAz*, GlobalContext*); +typedef void (*EnAzActionFunc)(struct EnAz*, PlayState*); typedef struct EnAz { - /* 0x0000 */ Actor actor; - /* 0x0144 */ EnAzActionFunc actionFunc; - /* 0x0148 */ char unk_148[0x290]; + /* 0x000 */ Actor actor; + /* 0x144 */ EnAzActionFunc actionFunc; + /* 0x148 */ char unk_148[0x290]; } EnAz; // size = 0x3D8 extern const ActorInit En_Az_InitVars; diff --git a/src/overlays/actors/ovl_En_Baba/z_en_baba.c b/src/overlays/actors/ovl_En_Baba/z_en_baba.c index ff2d7c48e..4d783942d 100644 --- a/src/overlays/actors/ovl_En_Baba/z_en_baba.c +++ b/src/overlays/actors/ovl_En_Baba/z_en_baba.c @@ -5,29 +5,50 @@ */ #include "z_en_baba.h" -#include "overlays/actors/ovl_En_Ossan/z_en_ossan.h" -#include "objects/object_bba/object_bba.h" #define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_8 | ACTOR_FLAG_10) #define THIS ((EnBaba*)thisx) -void EnBaba_Init(Actor* thisx, GlobalContext* globalCtx); -void EnBaba_Destroy(Actor* thisx, GlobalContext* globalCtx); -void EnBaba_Update(Actor* thisx, GlobalContext* globalCtx); -void EnBaba_Draw(Actor* thisx, GlobalContext* globalCtx); +#define BOMB_SHOP_LADY_STATE_END_CONVERSATION (1 << 0) +#define BOMB_SHOP_LADY_STATE_VISIBLE (1 << 1) +#define BOMB_SHOP_LADY_STATE_KNOCKED_OVER (1 << 2) // Don't track player +#define BOMB_SHOP_LADY_STATE_AUTOTALK (1 << 3) +#define BOMB_SHOP_LADY_STATE_GIVE_BLAST_MASK (1 << 5) +#define BOMB_SHOP_LADY_STATE_GAVE_BLAST_MASK (1 << 6) +#define BOMB_SHOP_LADY_STATE_DRAW_SHADOW (1 << 7) -void func_80BA9480(EnBaba* this, GlobalContext* globalCtx); -void func_80BA9758(EnBaba* this, GlobalContext* globalCtx); -void func_80BA9848(EnBaba* this, GlobalContext* globalCtx); -void func_80BA98EC(EnBaba* this, GlobalContext* globalCtx); -void func_80BA9AB8(EnBaba* this, GlobalContext* globalCtx); -void func_80BA9B24(EnBaba* this, GlobalContext* globalCtx); -void func_80BA9B80(EnBaba* this, GlobalContext* globalCtx); -void func_80BA9CD4(EnBaba* this, GlobalContext* globalCtx); -void func_80BA9E00(EnBaba* this, GlobalContext* globalCtx); -void func_80BA9E10(EnBaba* this, GlobalContext* globalCtx); -void func_80BA9E48(EnBaba* this, GlobalContext* globalCtx); +void EnBaba_Init(Actor* thisx, PlayState* play); +void EnBaba_Destroy(Actor* thisx, PlayState* play); +void EnBaba_Update(Actor* thisx, PlayState* play); +void EnBaba_Draw(Actor* thisx, PlayState* play); + +void EnBaba_FinishInit(EnBaba* this, PlayState* play); +void EnBaba_Idle(EnBaba* this, PlayState* play); +void EnBaba_FollowSchedule_Talk(EnBaba* this, PlayState* play); +void EnBaba_Talk(EnBaba* this, PlayState* play); +void EnBaba_GiveBlastMask(EnBaba* this, PlayState* play); +void EnBaba_GaveBlastMask(EnBaba* this, PlayState* play); +void EnBaba_FollowSchedule(EnBaba* this, PlayState* play); +void EnBaba_KnockedOver(EnBaba* this, PlayState* play); +void EnBaba_DoNothing(EnBaba* this, PlayState* play); +void EnBaba_Walk(EnBaba* this, PlayState* play); +void EnBaba_FaceForward(EnBaba* this, PlayState* play); + +typedef enum { + /* 0 */ BOMB_SHOP_LADY_ANIM_IDLE_HOLDING_BAG, + /* 1 */ BOMB_SHOP_LADY_ANIM_IDLE, + /* 2 */ BOMB_SHOP_LADY_ANIM_WALKING_HOLDING_BAG, + /* 3 */ BOMB_SHOP_LADY_ANIM_KNOCKED_OVER, + /* 4 */ BOMB_SHOP_LADY_ANIM_LYING_DOWN, + /* 5 */ BOMB_SHOP_LADY_ANIM_SWAY +} BombShopLadyAnimation; + +typedef enum { + /* 0 */ BOMB_SHOP_LADY_SCH_NONE, + /* 1 */ BOMB_SHOP_LADY_SCH_KNOCKED_OVER, + /* 2 */ BOMB_SHOP_LADY_SCH_FOLLOW_TIME_PATH +} BombShopLadyScheduleResult; const ActorInit En_Baba_InitVars = { ACTOR_EN_BABA, @@ -41,13 +62,13 @@ const ActorInit En_Baba_InitVars = { (ActorFunc)EnBaba_Draw, }; -static AnimationInfo sAnimations[] = { +static AnimationInfo sAnimationInfo[] = { { &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 }, + { &gBbaSwayAnim, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, 0.0f }, }; static ColliderCylinderInit sCylinderInit = { @@ -107,661 +128,711 @@ static DamageTable sDamageTable = { /* Powder Keg */ DMG_ENTRY(1, 0x0), }; -s32 D_80BAA488[] = { - 0x0C000119, 0x0A006E14, 0x02000000, 0x1E080F00, 0x1E030400, 0x01050E00, 0x00001E02, 0x05050000, +static u8 sSchedule[] = { + /* 0x00 */ SCHEDULE_CMD_CHECK_NOT_IN_DAY_S(1, 0x1D - 0x04), + /* 0x04 */ SCHEDULE_CMD_CHECK_NOT_IN_SCENE_S(SCENE_BACKTOWN, 0x1C - 0x08), + /* 0x08 */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(0, 0, 0, 30, 0x16 - 0x0E), + /* 0x0E */ SCHEDULE_CMD_CHECK_BEFORE_TIME_S(0, 30, 0x15 - 0x12), + /* 0x12 */ SCHEDULE_CMD_RET_VAL_L(BOMB_SHOP_LADY_SCH_KNOCKED_OVER), + /* 0x15 */ SCHEDULE_CMD_RET_NONE(), + /* 0x16 */ SCHEDULE_CMD_RET_TIME(0, 0, 0, 30, BOMB_SHOP_LADY_SCH_FOLLOW_TIME_PATH), + /* 0x1C */ SCHEDULE_CMD_RET_NONE(), + /* 0x1D */ SCHEDULE_CMD_RET_NONE(), }; -s32 D_80BAA4A8[] = { -1, -1, 0 }; +static s32 sSearchTimePathLimit[] = { -1, -1, 0 }; -u16 D_80BAA4B4[] = { 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_80BA8820(EnBaba* this, GlobalContext* globalCtx) { - this->unk_144 = (EnOssan*)SubS_FindActor(globalCtx, &this->unk_144->actor, ACTORCAT_NPC, ACTOR_EN_OSSAN); +s32 EnBaba_FindBombShopkeeper(EnBaba* this, PlayState* play) { + //! The bomb shopkeeper is an EnSob1, but initalizes itself with id `ACTOR_EN_OSSAN` + //! Note if there are other `EnOssan` actors, it may find that instance instead + //! in which case `EnSob1` struct acceses would be incorrect + this->bombShopkeeper = (EnSob1*)SubS_FindActor(play, &this->bombShopkeeper->actor, ACTORCAT_NPC, ACTOR_EN_OSSAN); - if (this->unk_144 != NULL) { + if (this->bombShopkeeper != NULL) { return true; } return false; } -void func_80BA886C(EnBaba* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); +void EnBaba_HandleConversation(EnBaba* this, PlayState* play) { + Player* player = GET_PLAYER(play); - switch (this->unk_1E0) { + switch (this->textId) { case 0: - if (this->unk_40A & 8) { + if (this->stateFlags & BOMB_SHOP_LADY_STATE_AUTOTALK) { if (gSaveContext.save.weekEventReg[33] & 8) { - this->unk_1E0 = 0x2A34; + // Thanks. Can stock Bomb Bags tomorrow + this->textId = 0x2A34; break; } if (gSaveContext.save.weekEventReg[79] & 0x40) { - this->unk_40A |= 1; - this->unk_1E0 = 0x2A33; + this->stateFlags |= BOMB_SHOP_LADY_STATE_END_CONVERSATION; + // Oh my, learned my lesson. Can't stock Bomb Bags tomorrow + this->textId = 0x2A33; break; } - this->unk_40A |= 1; - this->unk_1E0 = 0x2A32; + this->stateFlags |= BOMB_SHOP_LADY_STATE_END_CONVERSATION; + // Can't stock Bomb Bags tomorrow + this->textId = 0x2A32; break; } else if (player->transformation == PLAYER_FORM_DEKU) { if (!(gSaveContext.save.weekEventReg[79] & 0x20)) { gSaveContext.save.weekEventReg[79] |= 0x20; - this->unk_40A |= 1; - this->unk_1E0 = 0x2A37; + this->stateFlags |= BOMB_SHOP_LADY_STATE_END_CONVERSATION; + // Small customer, use bombs as adult + this->textId = 0x2A37; break; } else { - this->unk_40A |= 1; - this->unk_1E0 = 0x2A38; + this->stateFlags |= BOMB_SHOP_LADY_STATE_END_CONVERSATION; + // use bombs as adult + this->textId = 0x2A38; } break; } else if (!(gSaveContext.save.weekEventReg[33] & 8)) { if (!(gSaveContext.save.weekEventReg[73] & 1)) { - this->unk_1E0 = 0x660; + // Thought could sell Big Bomb Bags + this->textId = 0x660; break; } - this->unk_1E0 = 0x662; + // Can't judge people + this->textId = 0x662; break; } else { if (!(gSaveContext.save.weekEventReg[73] & 2)) { - this->unk_1E0 = 0x65A; + // Someone helped me out + this->textId = 0x65A; break; } - this->unk_1E0 = 0x65E; + // Buy Big Bomb Bag + this->textId = 0x65E; break; } break; case 0x660: - Actor_ChangeFocus(&this->actor, globalCtx, &this->unk_144->actor); - this->unk_1E0 = 0x661; + Actor_ChangeFocus(&this->actor, play, &this->bombShopkeeper->actor); + // Don't go by yourself + this->textId = 0x661; break; case 0x661: - Actor_ChangeFocus(&this->unk_144->actor, globalCtx, &this->actor); - this->unk_1E0 = 0x662; + Actor_ChangeFocus(&this->bombShopkeeper->actor, play, &this->actor); + // Can't judge people + this->textId = 0x662; break; case 0x662: - Actor_ChangeFocus(&this->actor, globalCtx, &this->unk_144->actor); - this->unk_1E0 = 0x663; + Actor_ChangeFocus(&this->actor, play, &this->bombShopkeeper->actor); + // I'll go next time + this->textId = 0x663; gSaveContext.save.weekEventReg[73] |= 1; - this->unk_40A |= 1; + this->stateFlags |= BOMB_SHOP_LADY_STATE_END_CONVERSATION; break; case 0x65A: - Actor_ChangeFocus(&this->actor, globalCtx, &this->unk_144->actor); - this->unk_1E0 = 0x65B; + Actor_ChangeFocus(&this->actor, play, &this->bombShopkeeper->actor); + // Don't pick up Bomb bags at night + this->textId = 0x65B; break; case 0x65B: - Actor_ChangeFocus(&this->unk_144->actor, globalCtx, &this->actor); - this->unk_1E0 = 0x65C; + Actor_ChangeFocus(&this->bombShopkeeper->actor, play, &this->actor); + // Lifelong dream to sell Big Bomb Bags + this->textId = 0x65C; break; case 0x65C: - Actor_ChangeFocus(&this->actor, globalCtx, &this->unk_144->actor); - this->unk_1E0 = 0x65D; + Actor_ChangeFocus(&this->actor, play, &this->bombShopkeeper->actor); + // I worry about you + this->textId = 0x65D; gSaveContext.save.weekEventReg[73] |= 2; - this->unk_40A |= 1; + this->stateFlags |= BOMB_SHOP_LADY_STATE_END_CONVERSATION; break; case 0x65E: - Actor_ChangeFocus(&this->actor, globalCtx, &this->unk_144->actor); - this->unk_1E0 = 0x65F; - this->unk_40A |= 1; + Actor_ChangeFocus(&this->actor, play, &this->bombShopkeeper->actor); + // I worry about you + this->textId = 0x65F; + this->stateFlags |= BOMB_SHOP_LADY_STATE_END_CONVERSATION; break; case 0x2A34: if (INV_CONTENT(ITEM_MASK_BLAST) == ITEM_MASK_BLAST) { - this->unk_40A |= 1; - this->unk_1E0 = 0x2A36; + this->stateFlags |= BOMB_SHOP_LADY_STATE_END_CONVERSATION; + // Thank you + this->textId = 0x2A36; break; } - this->unk_40A |= 0x20; - this->unk_1E0 = 0x2A35; + this->stateFlags |= BOMB_SHOP_LADY_STATE_GIVE_BLAST_MASK; + // It's a dangerous mask + this->textId = 0x2A35; break; case 0x2A35: - this->unk_40A |= 1; - this->unk_1E0 = 0x2A36; + this->stateFlags |= BOMB_SHOP_LADY_STATE_END_CONVERSATION; + // Thank you + this->textId = 0x2A36; break; case 0x2A30: case 0x2A31: - this->unk_40A |= 1; + this->stateFlags |= BOMB_SHOP_LADY_STATE_END_CONVERSATION; break; } - Message_StartTextbox(globalCtx, this->unk_1E0, &this->actor); - if (this->unk_40A & 1) { - if (this->unk_40A & 0x40) { - this->unk_40A &= ~0x40; - func_80151BB4(globalCtx, 0x33); + Message_StartTextbox(play, this->textId, &this->actor); + if (this->stateFlags & BOMB_SHOP_LADY_STATE_END_CONVERSATION) { + if (this->stateFlags & BOMB_SHOP_LADY_STATE_GAVE_BLAST_MASK) { + this->stateFlags &= ~BOMB_SHOP_LADY_STATE_GAVE_BLAST_MASK; + func_80151BB4(play, 0x33); } - func_80151BB4(globalCtx, 4); + func_80151BB4(play, 4); } } -void func_80BA8C4C(GlobalContext* globalCtx, u16 nextEntrance) { - globalCtx->nextEntranceIndex = nextEntrance; - globalCtx->unk_1887F = 0x40; - gSaveContext.nextTransition = 0x40; - globalCtx->sceneLoadFlag = 0x14; +void EnBaba_TriggerTransition(PlayState* play, u16 nextEntrance) { + play->nextEntrance = nextEntrance; + play->transitionType = TRANS_TYPE_64; + gSaveContext.nextTransitionType = TRANS_TYPE_64; + play->transitionTrigger = TRANS_TRIGGER_START; } -void func_80BA8C90(EnBaba* this, GlobalContext* globalCtx) { +void EnBaba_UpdateCollider(EnBaba* this, PlayState* play) { this->collider.dim.pos.x = this->actor.world.pos.x + 5.0f; this->collider.dim.pos.y = this->actor.world.pos.y; this->collider.dim.pos.z = this->actor.world.pos.z + 22.0f; - CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); - CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + CollisionCheck_SetAC(play, &play->colChkCtx, &this->collider.base); + CollisionCheck_SetOC(play, &play->colChkCtx, &this->collider.base); } -s32 func_80BA8D2C(EnBaba* this, f32 arg1) { - s16 sp3E; - s32 ret = false; - Vec3f sp2C; +s32 EnBaba_MoveForward(EnBaba* this, f32 speedTarget) { + s16 rotStep; + s32 reachedEnd = false; + Vec3f point; - Math_SmoothStepToF(&this->actor.speedXZ, arg1, 0.4f, 1000.0f, 0.0f); - sp3E = this->actor.speedXZ * 400.0f; - if (SubS_CopyPointFromPath(this->path, this->unk_1E8, &sp2C) && SubS_MoveActorToPoint(&this->actor, &sp2C, sp3E)) { - this->unk_1E8++; - if (this->unk_1E8 >= this->path->count) { - ret = true; + Math_SmoothStepToF(&this->actor.speedXZ, speedTarget, 0.4f, 1000.0f, 0.0f); + rotStep = this->actor.speedXZ * 400.0f; + if (SubS_CopyPointFromPath(this->path, this->waypoint, &point) && + SubS_MoveActorToPoint(&this->actor, &point, rotStep)) { + this->waypoint++; + if (this->waypoint >= this->path->count) { + reachedEnd = true; } } - return ret; + return reachedEnd; } -void func_80BA8DF4(EnBaba* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); - Vec3f sp30; +void EnBaba_UpdateModel(EnBaba* this, PlayState* play) { + Player* player = GET_PLAYER(play); + Vec3f point; SkelAnime_Update(&this->skelAnime); if (SubS_AngleDiffLessEqual(this->actor.shape.rot.y, 0x36B0, this->actor.yawTowardsPlayer) && - !(this->unk_40A & 4)) { - sp30.x = player->actor.world.pos.x; - sp30.y = player->bodyPartsPos[7].y + 3.0f; - sp30.z = player->actor.world.pos.z; + !(this->stateFlags & BOMB_SHOP_LADY_STATE_KNOCKED_OVER)) { + point.x = player->actor.world.pos.x; + point.y = player->bodyPartsPos[7].y + 3.0f; + point.z = player->actor.world.pos.z; - func_8013D2E0(&sp30, &this->actor.focus.pos, &this->actor.shape.rot, &this->unk_2DE, &this->unk_2E4, - &this->unk_2EA, D_80BAA4B4); + SubS_TrackPoint(&point, &this->actor.focus.pos, &this->actor.shape.rot, &this->trackTarget, &this->headRot, + &this->torsoRot, &sTrackOptions); } else { - Math_SmoothStepToS(&this->unk_2DE.x, 0, 4, 1000, 1); - Math_SmoothStepToS(&this->unk_2DE.y, 0, 4, 1000, 1); - Math_SmoothStepToS(&this->unk_2E4.x, 0, 4, 1000, 1); - Math_SmoothStepToS(&this->unk_2E4.y, 0, 4, 1000, 1); - Math_SmoothStepToS(&this->unk_2EA.x, 0, 4, 1000, 1); - Math_SmoothStepToS(&this->unk_2EA.y, 0, 4, 1000, 1); + 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); } - SubS_FillLimbRotTables(globalCtx, this->unk_302, this->unk_326, ARRAY_COUNT(this->unk_302)); + SubS_FillLimbRotTables(play, this->limbRotTableY, this->limbRotTableZ, ARRAY_COUNT(this->limbRotTableY)); - if (this->unk_40A & 2) { - func_80BA8C90(this, globalCtx); + if (this->stateFlags & BOMB_SHOP_LADY_STATE_VISIBLE) { + EnBaba_UpdateCollider(this, play); } } -s32 func_80BA8F88(EnBaba* this, GlobalContext* globalCtx, struct_80133038_arg2* arg2) { - u16 sp26 = (u16)(gSaveContext.save.time - 0x3FFC); - u16 temp; - u8 sp23 = ENBABA_GET_3F00(&this->actor); +s32 EnBaba_InitTimePath(EnBaba* this, PlayState* play, ScheduleOutput* scheduleOutput) { + u16 now = SCHEDULE_TIME_NOW; + u16 startTime; + u8 pathIndex = BOMB_SHOP_LADY_GET_PATH_INDEX(&this->actor); + u16 numWaypoints; - if (D_80BAA4A8[arg2->unk0] >= 0) { - this->unk_410 = SubS_GetAdditionalPath(globalCtx, sp23, D_80BAA4A8[arg2->unk0]); + if (sSearchTimePathLimit[scheduleOutput->result] >= 0) { + this->timePath = SubS_GetAdditionalPath(play, pathIndex, sSearchTimePathLimit[scheduleOutput->result]); } - if (this->unk_410 == NULL) { + if (this->timePath == NULL) { return false; } - if ((this->unk_434 != 0) && (this->unk_436 >= 0)) { - temp = sp26; + if ((this->scheduleResult != BOMB_SHOP_LADY_SCH_NONE) && (this->timePathTimeSpeed >= 0)) { + startTime = now; } else { - temp = arg2->unk4; + startTime = scheduleOutput->time0; } - if (arg2->unk8 < temp) { - this->unk_424 = (temp - arg2->unk8) + 0xFFFF; + if (scheduleOutput->time1 < startTime) { + this->timePathTotalTime = (startTime - scheduleOutput->time1) + (DAY_LENGTH - 1); } else { - this->unk_424 = arg2->unk8 - temp; + this->timePathTotalTime = scheduleOutput->time1 - startTime; } - this->unk_430 = sp26 - temp; - temp = this->unk_410->count - 2; - this->unk_428 = this->unk_424 / temp; - this->unk_438 = 0; - this->unk_42C = (this->unk_430 / this->unk_428) + 2; - this->unk_43C = 0; + this->timePathElapsedTime = now - startTime; + + numWaypoints = startTime = this->timePath->count - (SUBS_TIME_PATHING_ORDER - 1); + this->timePathWaypointTime = this->timePathTotalTime / numWaypoints; + + this->timePathIsSetup = false; + this->timePathWaypoint = (this->timePathElapsedTime / this->timePathWaypointTime) + (SUBS_TIME_PATHING_ORDER - 1); + this->timePathHasReachedEnd = false; + return true; } -s32 func_80BA9110(EnBaba* this, GlobalContext* globalCtx, struct_80133038_arg2* arg2) { - s32 ret; +s32 EnBaba_ProcessScheduleOutput(EnBaba* this, PlayState* play, ScheduleOutput* scheduleOutput) { + s32 success; - switch (arg2->unk0) { + switch (scheduleOutput->result) { default: - ret = false; + success = false; break; - case 2: - ret = func_80BA8F88(this, globalCtx, arg2); + case BOMB_SHOP_LADY_SCH_FOLLOW_TIME_PATH: + success = EnBaba_InitTimePath(this, play, scheduleOutput); break; - case 1: - ret = true; + case BOMB_SHOP_LADY_SCH_KNOCKED_OVER: + success = true; break; } - return ret; + return success; } -s32 func_80BA9160(EnBaba* this, GlobalContext* globalCtx) { - f32 sp7C[265]; - Vec3f sp70; - Vec3f sp64; - Vec3f sp58; - s32 sp54 = 0; - s32 sp50 = 0; +s32 EnBaba_FollowTimePath(EnBaba* this, PlayState* play) { + f32 weightArray[265]; + Vec3f worldPos; + Vec3f timePathPointNew; // used to compute yaw after update + Vec3f timePathPoint; // used in setup and to store a backup before update + s32 prevTimePathElapsedTime = 0; + s32 prevTimePathWaypoint = 0; s32 pad; - func_8013AF00(sp7C, 3, this->unk_410->count + 3); + SubS_TimePathing_FillKnots(weightArray, SUBS_TIME_PATHING_ORDER, this->timePath->count + SUBS_TIME_PATHING_ORDER); - if (this->unk_438 == 0) { - sp58 = gZeroVec3f; + if (!this->timePathIsSetup) { + timePathPoint = gZeroVec3f; - func_8013B6B0(this->unk_410, &this->unk_420, &this->unk_430, this->unk_428, this->unk_424, &this->unk_42C, sp7C, - &sp58, this->unk_436); - func_8013B878(globalCtx, this->unk_410, this->unk_42C, &sp58); - this->actor.world.pos.y = sp58.y; - this->unk_438 = 1; + SubS_TimePathing_Update(this->timePath, &this->timePathProgress, &this->timePathElapsedTime, + this->timePathWaypointTime, this->timePathTotalTime, &this->timePathWaypoint, + weightArray, &timePathPoint, this->timePathTimeSpeed); + SubS_TimePathing_ComputeInitialY(play, this->timePath, this->timePathWaypoint, &timePathPoint); + this->actor.world.pos.y = timePathPoint.y; + this->timePathIsSetup = true; } else { - sp58 = this->unk_414; + timePathPoint = this->timePathPoint; } - this->actor.world.pos.x = sp58.x; - this->actor.world.pos.z = sp58.z; + this->actor.world.pos.x = timePathPoint.x; + this->actor.world.pos.z = timePathPoint.z; - if (func_8013AD6C(globalCtx)) { - sp54 = this->unk_430; - sp50 = this->unk_42C; - sp58 = this->actor.world.pos; + if (SubS_InCsMode(play)) { + prevTimePathElapsedTime = this->timePathElapsedTime; + prevTimePathWaypoint = this->timePathWaypoint; + timePathPoint = this->actor.world.pos; } - this->unk_414 = gZeroVec3f; + this->timePathPoint = gZeroVec3f; - if (func_8013B6B0(this->unk_410, &this->unk_420, &this->unk_430, this->unk_428, this->unk_424, &this->unk_42C, sp7C, - &this->unk_414, this->unk_436)) { - this->unk_43C = 1; + if (SubS_TimePathing_Update(this->timePath, &this->timePathProgress, &this->timePathElapsedTime, + this->timePathWaypointTime, this->timePathTotalTime, &this->timePathWaypoint, + weightArray, &this->timePathPoint, this->timePathTimeSpeed)) { + this->timePathHasReachedEnd = true; } else { - sp70 = this->actor.world.pos; - sp64 = this->unk_414; - this->actor.world.rot.y = Math_Vec3f_Yaw(&sp70, &sp64); + worldPos = this->actor.world.pos; + timePathPointNew = this->timePathPoint; + this->actor.world.rot.y = Math_Vec3f_Yaw(&worldPos, &timePathPointNew); } - if (func_8013AD6C(globalCtx)) { - this->unk_430 = sp54; - this->unk_42C = sp50; - this->unk_414 = sp58; + if (SubS_InCsMode(play)) { + this->timePathElapsedTime = prevTimePathElapsedTime; + this->timePathWaypoint = prevTimePathWaypoint; + this->timePathPoint = timePathPoint; } return false; } -void func_80BA93AC(EnBaba* this, GlobalContext* globalCtx) { - if (this->unk_434 != 1) { - if (this->unk_434 == 2) { +void EnBaba_HandleSchedule(EnBaba* this, PlayState* play) { + switch (this->scheduleResult) { + case BOMB_SHOP_LADY_SCH_FOLLOW_TIME_PATH: gSaveContext.save.weekEventReg[58] |= 0x40; - this->unk_40A |= 2; - func_80BA9160(this, 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; + this->stateFlags |= BOMB_SHOP_LADY_STATE_VISIBLE; + EnBaba_FollowTimePath(this, play); + break; + + case BOMB_SHOP_LADY_SCH_KNOCKED_OVER: + this->animIndex = BOMB_SHOP_LADY_ANIM_KNOCKED_OVER; + // Ouch + this->textId = 0x2A30; + this->actor.speedXZ = 0.0f; + Enemy_StartFinishingBlow(play, &this->actor); + this->stateFlags |= BOMB_SHOP_LADY_STATE_KNOCKED_OVER; + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, this->animIndex); + this->actionFunc = EnBaba_KnockedOver; + break; } Math_ApproachS(&this->actor.shape.rot.y, this->actor.world.rot.y, 4, 0x1554); } -void func_80BA9480(EnBaba* this, GlobalContext* globalCtx) { - SkelAnime_InitFlex(globalCtx, &this->skelAnime, &gBbaSkel, &gBbaWalkingHoldingBagAnim, this->jointTable, - this->morphTable, 0x12); +void EnBaba_FinishInit(EnBaba* this, PlayState* play) { + SkelAnime_InitFlex(play, &this->skelAnime, &gBbaSkel, &gBbaWalkingHoldingBagAnim, this->jointTable, + this->morphTable, BBA_LIMB_MAX); this->actor.draw = EnBaba_Draw; - this->unk_40A |= 0x80; + this->stateFlags |= BOMB_SHOP_LADY_STATE_DRAW_SHADOW; this->actor.flags |= ACTOR_FLAG_1; - if (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 (play->sceneNum == SCENE_BOMYA) { + this->stateFlags |= BOMB_SHOP_LADY_STATE_VISIBLE; + this->animIndex = BOMB_SHOP_LADY_ANIM_IDLE; + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, this->animIndex); + this->actionFunc = EnBaba_Idle; + } else if (play->sceneNum == SCENE_BACKTOWN) { + if ((BOMB_SHOP_LADY_GET_TYPE(&this->actor) == BOMB_SHOP_LADY_TYPE_FOLLOW_SCHEDULE) && + (gSaveContext.save.entrance != ENTRANCE(NORTH_CLOCK_TOWN, 7)) && + (BOMB_SHOP_LADY_GET_PATH_INDEX(&this->actor) != 0x3F)) { if ((gSaveContext.save.weekEventReg[58] & 0x40) || - (!(gSaveContext.save.time < CLOCK_TIME(0, 20)) && (gSaveContext.save.time < CLOCK_TIME(6, 0)))) { + (gSaveContext.save.time >= CLOCK_TIME(0, 20) && (gSaveContext.save.time < CLOCK_TIME(6, 0)))) { Actor_MarkForDeath(&this->actor); return; } - this->unk_404 = 50; - this->unk_40C = 2; - Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 2); - this->actionFunc = func_80BA9B80; - } else if ((ENBABA_GET_C000(&this->actor) == ENBABA_C000_1) && (gSaveContext.save.entranceIndex == 0xD670)) { + this->sakonDeadTimer = 50; + this->animIndex = BOMB_SHOP_LADY_ANIM_WALKING_HOLDING_BAG; + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, this->animIndex); + this->actionFunc = EnBaba_FollowSchedule; + } else if ((BOMB_SHOP_LADY_GET_TYPE(&this->actor) == BOMB_SHOP_LADY_TYPE_IDLE) && + (gSaveContext.save.entrance == ENTRANCE(NORTH_CLOCK_TOWN, 7))) { if (gSaveContext.save.weekEventReg[81] & 2) { Actor_MarkForDeath(&this->actor); return; } - this->unk_40A |= 2; + this->stateFlags |= BOMB_SHOP_LADY_STATE_VISIBLE; if (gSaveContext.save.weekEventReg[33] & 8) { - this->unk_40C = 0; + this->animIndex = BOMB_SHOP_LADY_ANIM_IDLE_HOLDING_BAG; } else { - this->unk_40C = 1; + this->animIndex = BOMB_SHOP_LADY_ANIM_IDLE; } - Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, this->unk_40C); - this->unk_40A |= 8; - this->actionFunc = func_80BA9758; + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, this->animIndex); + this->stateFlags |= BOMB_SHOP_LADY_STATE_AUTOTALK; + this->actionFunc = EnBaba_Idle; } else { Actor_MarkForDeath(&this->actor); return; } } else { - this->unk_40A |= 2; - if (ENBABA_GET_C000(&this->actor) == ENBABA_C000_2) { + this->stateFlags |= BOMB_SHOP_LADY_STATE_VISIBLE; + if (BOMB_SHOP_LADY_GET_TYPE(&this->actor) == BOMB_SHOP_LADY_TYPE_SWAY) { this->actor.flags &= ~ACTOR_FLAG_1; - this->unk_40C = 5; - Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 5); - this->actionFunc = func_80BA9E00; - } else if ((ENBABA_GET_3F00(&this->actor)) != ENBABA_3F00_3F) { - this->unk_40C = 2; - Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 2); - this->actionFunc = func_80BA9E10; + this->animIndex = BOMB_SHOP_LADY_ANIM_SWAY; + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, this->animIndex); + this->actionFunc = EnBaba_DoNothing; + } else if (BOMB_SHOP_LADY_GET_PATH_INDEX(&this->actor) != 0x3F) { + this->animIndex = BOMB_SHOP_LADY_ANIM_WALKING_HOLDING_BAG; + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, this->animIndex); + this->actionFunc = EnBaba_Walk; } else { - this->unk_40C = 0; - Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 0); - this->actionFunc = func_80BA9E48; + this->animIndex = BOMB_SHOP_LADY_ANIM_IDLE_HOLDING_BAG; + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, this->animIndex); + this->actionFunc = EnBaba_FaceForward; } } } -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) { +void EnBaba_Idle(EnBaba* this, PlayState* play) { + if ((this->stateFlags & BOMB_SHOP_LADY_STATE_AUTOTALK) || (this->bombShopkeeper != NULL) || + EnBaba_FindBombShopkeeper(this, play)) { + if (Actor_ProcessTalkRequest(&this->actor, &play->state)) { + EnBaba_HandleConversation(this, play); + if (this->stateFlags & BOMB_SHOP_LADY_STATE_AUTOTALK) { this->actor.flags &= ~ACTOR_FLAG_10000; } - this->actionFunc = func_80BA98EC; + this->actionFunc = EnBaba_Talk; } else if (this->actor.xzDistToPlayer < 100.0f) { - if (this->unk_40A & 8) { + if (this->stateFlags & BOMB_SHOP_LADY_STATE_AUTOTALK) { this->actor.flags |= ACTOR_FLAG_10000; } - func_800B8614(&this->actor, globalCtx, 100.0f); + func_800B8614(&this->actor, play, 100.0f); } } } -void func_80BA9848(EnBaba* this, GlobalContext* globalCtx) { - u8 temp_v0 = Message_GetState(&globalCtx->msgCtx); +void EnBaba_FollowSchedule_Talk(EnBaba* this, PlayState* play) { + u8 talkState = Message_GetState(&play->msgCtx); - if (((temp_v0 == 5) || (temp_v0 == 6)) && Message_ShouldAdvance(globalCtx)) { - globalCtx->msgCtx.msgMode = 0x43; - globalCtx->msgCtx.unk12023 = 4; - this->actionFunc = func_80BA9B80; + if (((talkState == TEXT_STATE_5) || (talkState == TEXT_STATE_DONE)) && Message_ShouldAdvance(play)) { + play->msgCtx.msgMode = 0x43; + play->msgCtx.stateTimer = 4; + this->actionFunc = EnBaba_FollowSchedule; } Math_SmoothStepToS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer, 5, 0x1000, 0x100); } -void func_80BA98EC(EnBaba* this, GlobalContext* globalCtx) { - u8 temp_v0 = Message_GetState(&globalCtx->msgCtx); +void EnBaba_Talk(EnBaba* this, PlayState* play) { + u8 talkState = Message_GetState(&play->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 (talkState == TEXT_STATE_5) { + if (Message_ShouldAdvance(play)) { + if (this->stateFlags & BOMB_SHOP_LADY_STATE_END_CONVERSATION) { + this->stateFlags &= ~BOMB_SHOP_LADY_STATE_END_CONVERSATION; + play->msgCtx.msgMode = 0x43; + play->msgCtx.stateTimer = 4; + if (this->stateFlags & BOMB_SHOP_LADY_STATE_AUTOTALK) { if (CHECK_QUEST_ITEM(QUEST_BOMBERS_NOTEBOOK)) { - if (globalCtx->msgCtx.unk120B1 == 0) { + if (play->msgCtx.unk120B1 == 0) { gSaveContext.save.weekEventReg[81] |= 2; - func_80BA8C4C(globalCtx, 0xD670); + EnBaba_TriggerTransition(play, ENTRANCE(NORTH_CLOCK_TOWN, 7)); return; } } else { gSaveContext.save.weekEventReg[81] |= 2; - func_80BA8C4C(globalCtx, 0xD670); + EnBaba_TriggerTransition(play, ENTRANCE(NORTH_CLOCK_TOWN, 7)); } } else { - this->unk_1E0 = 0; - this->actionFunc = func_80BA9758; + this->textId = 0; + this->actionFunc = EnBaba_Idle; } - } else if (this->unk_40A & 0x20) { - this->unk_40A &= ~0x20; - globalCtx->msgCtx.msgMode = 0x43; - globalCtx->msgCtx.unk12023 = 4; - this->actionFunc = func_80BA9AB8; + } else if (this->stateFlags & BOMB_SHOP_LADY_STATE_GIVE_BLAST_MASK) { + this->stateFlags &= ~BOMB_SHOP_LADY_STATE_GIVE_BLAST_MASK; + play->msgCtx.msgMode = 0x43; + play->msgCtx.stateTimer = 4; + this->actionFunc = EnBaba_GiveBlastMask; } else { - func_80BA886C(this, globalCtx); + EnBaba_HandleConversation(this, play); } } - } else if (temp_v0 == 6) { - if (Message_ShouldAdvance(globalCtx) && (globalCtx->msgCtx.unk120B1 == 0)) { + } else if (talkState == TEXT_STATE_DONE) { + if (Message_ShouldAdvance(play) && (play->msgCtx.unk120B1 == 0)) { gSaveContext.save.weekEventReg[81] |= 2; - func_80BA8C4C(globalCtx, 0xD670); + EnBaba_TriggerTransition(play, ENTRANCE(NORTH_CLOCK_TOWN, 7)); } } } -void func_80BA9AB8(EnBaba* this, GlobalContext* globalCtx) { - if (Actor_HasParent(&this->actor, globalCtx)) { +void EnBaba_GiveBlastMask(EnBaba* this, PlayState* play) { + if (Actor_HasParent(&this->actor, play)) { this->actor.parent = NULL; - this->unk_40A |= 0x40; - this->actionFunc = func_80BA9B24; + this->stateFlags |= BOMB_SHOP_LADY_STATE_GAVE_BLAST_MASK; + this->actionFunc = EnBaba_GaveBlastMask; } else { - Actor_PickUp(&this->actor, globalCtx, GI_MASK_BLAST, 300.0f, 300.0f); + Actor_PickUp(&this->actor, play, 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; +void EnBaba_GaveBlastMask(EnBaba* this, PlayState* play) { + if (Actor_ProcessTalkRequest(&this->actor, &play->state)) { + EnBaba_HandleConversation(this, play); + this->actionFunc = EnBaba_Talk; } else { - func_800B85E0(&this->actor, globalCtx, 400.0f, -1); + func_800B85E0(&this->actor, play, 400.0f, PLAYER_AP_MINUS1); } } -void func_80BA9B80(EnBaba* this, GlobalContext* globalCtx) { - u32* unk14 = &gSaveContext.save.daySpeed; - struct_80133038_arg2 sp20; +void EnBaba_FollowSchedule(EnBaba* this, PlayState* play) { + ScheduleOutput scheduleOutput; - this->unk_436 = REG(15) + *unk14; + this->timePathTimeSpeed = REG(15) + ((void)0, gSaveContext.save.daySpeed); - if (!func_80133038(globalCtx, D_80BAA488, &sp20) || - ((this->unk_434 != sp20.unk0) && !func_80BA9110(this, globalCtx, &sp20))) { - this->unk_40A &= ~0x80; + if (!Schedule_RunScript(play, sSchedule, &scheduleOutput) || + ((this->scheduleResult != scheduleOutput.result) && + !EnBaba_ProcessScheduleOutput(this, play, &scheduleOutput))) { + this->stateFlags &= ~BOMB_SHOP_LADY_STATE_DRAW_SHADOW; this->actor.flags &= ~ACTOR_FLAG_1; - sp20.unk0 = false; + scheduleOutput.result = BOMB_SHOP_LADY_SCH_NONE; } else { - this->unk_40A |= 0x80; + this->stateFlags |= BOMB_SHOP_LADY_STATE_DRAW_SHADOW; this->actor.flags |= ACTOR_FLAG_1; } - this->unk_434 = sp20.unk0; + this->scheduleResult = scheduleOutput.result; - func_80BA93AC(this, globalCtx); + EnBaba_HandleSchedule(this, play); - 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; + if (this->stateFlags & BOMB_SHOP_LADY_STATE_VISIBLE) { + if (Actor_ProcessTalkRequest(&this->actor, &play->state)) { + Message_StartTextbox(play, 0x2A39, &this->actor); // "I'm sorry" + this->actionFunc = EnBaba_FollowSchedule_Talk; } else if ((this->actor.xzDistToPlayer < 100.0f) || this->actor.isTargeted) { - func_800B863C(&this->actor, globalCtx); + func_800B863C(&this->actor, play); } } 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); +void EnBaba_KnockedOver(EnBaba* this, PlayState* play) { + s16 curFrame = this->skelAnime.curFrame; + s16 endFrame = Animation_GetLastFrame(sAnimationInfo[this->animIndex].animation); this->collider.dim.height = 37; this->collider.dim.radius = 23; - if (this->unk_40C == 3) { + if (this->animIndex == BOMB_SHOP_LADY_ANIM_KNOCKED_OVER) { if (Animation_OnFrame(&this->skelAnime, 0.0f)) { Actor_PlaySfxAtPos(&this->actor, NA_SE_VO_BBVO00); } - if (sp2E == sp2C) { - this->unk_40C = 4; - Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 4); + if (curFrame == endFrame) { + this->animIndex = BOMB_SHOP_LADY_ANIM_LYING_DOWN; + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, this->animIndex); } } else { - if ((gSaveContext.save.weekEventReg[79] & 0x40) && (DECR(this->unk_404) == 0)) { + if ((gSaveContext.save.weekEventReg[79] & 0x40) && (DECR(this->sakonDeadTimer) == 0)) { Audio_QueueSeqCmd(0x101400FF); - func_80BA8C4C(globalCtx, 0xD670); + EnBaba_TriggerTransition(play, ENTRANCE(NORTH_CLOCK_TOWN, 7)); } else { Actor_MoveWithGravity(&this->actor); } } } -void func_80BA9E00(EnBaba* this, GlobalContext* globalCtx) { +void EnBaba_DoNothing(EnBaba* this, PlayState* play) { } -void func_80BA9E10(EnBaba* this, GlobalContext* globalCtx) { - if (func_80BA8D2C(this, 1.0f)) { - this->unk_1E8 = 0; +void EnBaba_Walk(EnBaba* this, PlayState* play) { + if (EnBaba_MoveForward(this, 1.0f)) { + this->waypoint = 0; } } -void func_80BA9E48(EnBaba* this, GlobalContext* globalCtx) { +void EnBaba_FaceForward(EnBaba* this, PlayState* play) { this->actor.shape.rot = this->actor.world.rot; } -void EnBaba_Init(Actor* thisx, GlobalContext* globalCtx) { +void EnBaba_Init(Actor* thisx, PlayState* play) { s32 pad; EnBaba* this = THIS; - Collider_InitCylinder(globalCtx, &this->collider); - Collider_SetCylinder(globalCtx, &this->collider, &this->actor, &sCylinderInit); + Collider_InitCylinder(play, &this->collider); + Collider_SetCylinder(play, &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); + this->path = SubS_GetPathByIndex(play, BOMB_SHOP_LADY_GET_PATH_INDEX(&this->actor), 0x3F); Actor_SetScale(&this->actor, 0.01f); this->actor.targetMode = 0; this->actor.gravity = -4.0f; - this->actionFunc = func_80BA9480; + this->actionFunc = EnBaba_FinishInit; } -void EnBaba_Destroy(Actor* thisx, GlobalContext* globalCtx) { +void EnBaba_Destroy(Actor* thisx, PlayState* play) { EnBaba* this = THIS; - Collider_DestroyCylinder(globalCtx, &this->collider); + Collider_DestroyCylinder(play, &this->collider); } -void EnBaba_Update(Actor* thisx, GlobalContext* globalCtx) { +void EnBaba_Update(Actor* thisx, PlayState* play) { EnBaba* this = THIS; - this->actionFunc(this, globalCtx); + this->actionFunc(this, play); - Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 0.0f, 0.0f, 0.0f, 4); - func_80BA8DF4(this, globalCtx); + Actor_UpdateBgCheckInfo(play, &this->actor, 0.0f, 0.0f, 0.0f, 4); + EnBaba_UpdateModel(this, play); } -s32 EnBaba_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, - Actor* thisx) { +s32 EnBaba_OverrideLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, Actor* thisx) { EnBaba* this = THIS; - if (limbIndex == 6) { - Matrix_InsertTranslation(1500.0f, 0.0f, 0.0f, MTXMODE_APPLY); - Matrix_InsertXRotation_s(this->unk_2E4.y, MTXMODE_APPLY); - Matrix_InsertZRotation_s(-this->unk_2E4.x, MTXMODE_APPLY); - Matrix_InsertTranslation(-1500.0f, 0.0f, 0.0f, MTXMODE_APPLY); + if (limbIndex == BBA_LIMB_NECK) { + Matrix_Translate(1500.0f, 0.0f, 0.0f, MTXMODE_APPLY); + Matrix_RotateXS(this->headRot.y, MTXMODE_APPLY); + Matrix_RotateZS(-this->headRot.x, MTXMODE_APPLY); + Matrix_Translate(-1500.0f, 0.0f, 0.0f, MTXMODE_APPLY); } - if (limbIndex == 5) { - Matrix_InsertXRotation_s(-this->unk_2EA.y, MTXMODE_APPLY); - Matrix_InsertZRotation_s(-this->unk_2EA.x, MTXMODE_APPLY); + if (limbIndex == BBA_LIMB_UPPER_ROOT) { + Matrix_RotateXS(-this->torsoRot.y, MTXMODE_APPLY); + Matrix_RotateZS(-this->torsoRot.x, MTXMODE_APPLY); } - if ((limbIndex == 6) && (this->unk_1E2 != 0) && ((globalCtx->state.frames % 2) == 0)) { - Matrix_InsertTranslation(40.0f, 0.0f, 0.0f, MTXMODE_APPLY); + if ((limbIndex == BBA_LIMB_NECK) && (this->inMsgState3 != 0) && ((play->state.frames % 2) == 0)) { + Matrix_Translate(40.0f, 0.0f, 0.0f, MTXMODE_APPLY); } - if ((limbIndex == 5) || (limbIndex == 10) || (limbIndex == 14)) { - rot->y += (s16)(Math_SinS(this->unk_302[limbIndex]) * 200.0f); - rot->z += (s16)(Math_CosS(this->unk_326[limbIndex]) * 200.0f); + if ((limbIndex == BBA_LIMB_UPPER_ROOT) || (limbIndex == BBA_LIMB_LEFT_UPPER_ARM) || + (limbIndex == BBA_LIMB_RIGHT_UPPER_ARM)) { + rot->y += (s16)(Math_SinS(this->limbRotTableY[limbIndex]) * 200.0f); + rot->z += (s16)(Math_CosS(this->limbRotTableZ[limbIndex]) * 200.0f); } - if (((this->unk_40C == 1) || (this->unk_40C == 3) || (this->unk_40C == 4) || - (ENBABA_GET_C000(&this->actor) == ENBABA_C000_2)) && - (limbIndex == 8)) { + if (((this->animIndex == BOMB_SHOP_LADY_ANIM_IDLE) || (this->animIndex == BOMB_SHOP_LADY_ANIM_KNOCKED_OVER) || + (this->animIndex == BOMB_SHOP_LADY_ANIM_LYING_DOWN) || + (BOMB_SHOP_LADY_GET_TYPE(&this->actor) == BOMB_SHOP_LADY_TYPE_SWAY)) && + (limbIndex == BBA_LIMB_BAG)) { *dList = NULL; } - return 0; + return false; } -void EnBaba_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx) { +void EnBaba_PostLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx) { EnBaba* this = THIS; Vec3f sp18 = { 0.0f, 0.0f, 0.0f }; - if (limbIndex == 7) { + if (limbIndex == BBA_LIMB_HEAD) { this->actor.focus.pos.x = this->actor.world.pos.x; this->actor.focus.pos.y = this->actor.world.pos.y; this->actor.focus.pos.z = this->actor.world.pos.z; - Matrix_MultiplyVector3fByState(&sp18, &this->actor.focus.pos); + Matrix_MultVec3f(&sp18, &this->actor.focus.pos); } } -void EnBaba_TransformLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Actor* thisx) { +void EnBaba_TransformLimbDraw(PlayState* play, s32 limbIndex, Actor* thisx) { } -void EnBaba_Draw(Actor* thisx, GlobalContext* globalCtx) { +void EnBaba_Draw(Actor* thisx, PlayState* play) { s32 pad; EnBaba* this = THIS; - Vec3f sp4C; - Vec3f sp40; + Vec3f pos; + Vec3f scale; - if (this->unk_40A & 2) { - OPEN_DISPS(globalCtx->state.gfxCtx); + if (this->stateFlags & BOMB_SHOP_LADY_STATE_VISIBLE) { + OPEN_DISPS(play->state.gfxCtx); - func_8012C5B0(globalCtx->state.gfxCtx); + func_8012C5B0(play->state.gfxCtx); gSPSegment(POLY_OPA_DISP++, 0x08, Lib_SegmentedToVirtual(gBbaEyeTex)); - SkelAnime_DrawTransformFlexOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, + SkelAnime_DrawTransformFlexOpa(play, 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; + if (this->stateFlags & BOMB_SHOP_LADY_STATE_DRAW_SHADOW) { + if ((this->animIndex == BOMB_SHOP_LADY_ANIM_KNOCKED_OVER) || + (this->animIndex == BOMB_SHOP_LADY_ANIM_LYING_DOWN)) { + func_8012C2DC(play->state.gfxCtx); + pos.x = this->actor.world.pos.x + 20.0f; + pos.y = this->actor.world.pos.y; + pos.z = this->actor.world.pos.z + 20.0f; } else { - sp4C = this->actor.world.pos; + pos = this->actor.world.pos; } - sp40.x = sp40.y = sp40.z = 0.3f; - func_800BC620(&sp4C, &sp40, 255, globalCtx); + scale.x = scale.y = scale.z = 0.3f; + func_800BC620(&pos, &scale, 255, play); } - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->state.gfxCtx); } } diff --git a/src/overlays/actors/ovl_En_Baba/z_en_baba.h b/src/overlays/actors/ovl_En_Baba/z_en_baba.h index d26e68625..2335dcb70 100644 --- a/src/overlays/actors/ovl_En_Baba/z_en_baba.h +++ b/src/overlays/actors/ovl_En_Baba/z_en_baba.h @@ -2,58 +2,60 @@ #define Z_EN_BABA_H #include "global.h" +#include "overlays/actors/ovl_En_Sob1/z_en_sob1.h" +#include "objects/object_bba/object_bba.h" struct EnBaba; -typedef void (*EnBabaActionFunc)(struct EnBaba*, GlobalContext*); +typedef void (*EnBabaActionFunc)(struct EnBaba*, PlayState*); -#define ENBABA_GET_3F00(thisx) (((thisx)->params & 0x3F00) >> 8) -#define ENBABA_GET_C000(thisx) (((thisx)->params & 0xC000) >> 0xE) +#define BOMB_SHOP_LADY_GET_PATH_INDEX(thisx) (((thisx)->params & 0x3F00) >> 8) +#define BOMB_SHOP_LADY_GET_TYPE(thisx) (((thisx)->params & 0xC000) >> 0xE) -#define ENBABA_3F00_3F 0x3F - -enum { - /* 0 */ ENBABA_C000_0, - /* 1 */ ENBABA_C000_1, - /* 2 */ ENBABA_C000_2, -}; +// Types BOMB_SHOP_LADY_TYPE_FOLLOW_SCHEDULE and BOMB_SHOP_LADY_TYPE_IDLE can only be used in SCENE_BACKTOWN +// Type BOMB_SHOP_LADY_TYPE_SWAY can be used anywhere except SCENE_BACKTOWN and SCENE_BOMYA +typedef enum { + /* 0 */ BOMB_SHOP_LADY_TYPE_FOLLOW_SCHEDULE, + /* 1 */ BOMB_SHOP_LADY_TYPE_IDLE, + /* 2 */ BOMB_SHOP_LADY_TYPE_SWAY +} BombShopLadyType; typedef struct EnBaba { - /* 0x0000 */ Actor actor; - /* 0x0144 */ struct EnOssan* unk_144; - /* 0x0148 */ EnBabaActionFunc actionFunc; - /* 0x014C */ UNK_TYPE1 unk14C[4]; - /* 0x0150 */ SkelAnime skelAnime; - /* 0x0194 */ ColliderCylinder collider; - /* 0x01E0 */ u16 unk_1E0; - /* 0x01E2 */ u8 unk_1E2; - /* 0x01E4 */ Path* path; - /* 0x01E8 */ s16 unk_1E8; - /* 0x01EA */ UNK_TYPE1 unk1EA[0x1C]; - /* 0x0206 */ Vec3s jointTable[18]; - /* 0x0272 */ Vec3s morphTable[18]; - /* 0x02DE */ Vec3s unk_2DE; - /* 0x02E4 */ Vec3s unk_2E4; - /* 0x02EA */ Vec3s unk_2EA; - /* 0x02F0 */ UNK_TYPE1 unk2F0[0x12]; - /* 0x0302 */ s16 unk_302[18]; - /* 0x0326 */ s16 unk_326[18]; - /* 0x034A */ UNK_TYPE1 unk34A[0xBA]; - /* 0x0404 */ s16 unk_404; - /* 0x0406 */ UNK_TYPE1 unk406[4]; - /* 0x040A */ u16 unk_40A; - /* 0x040C */ s32 unk_40C; - /* 0x0410 */ Path* unk_410; - /* 0x0414 */ Vec3f unk_414; - /* 0x0420 */ f32 unk_420; - /* 0x0424 */ s32 unk_424; - /* 0x0428 */ s32 unk_428; - /* 0x042C */ s32 unk_42C; - /* 0x0430 */ s32 unk_430; - /* 0x0434 */ u8 unk_434; - /* 0x0436 */ s16 unk_436; - /* 0x0438 */ s32 unk_438; - /* 0x043C */ s32 unk_43C; + /* 0x000 */ Actor actor; + /* 0x144 */ EnSob1* bombShopkeeper; + /* 0x148 */ EnBabaActionFunc actionFunc; + /* 0x14C */ UNK_TYPE1 unk14C[4]; + /* 0x150 */ SkelAnime skelAnime; + /* 0x194 */ ColliderCylinder collider; + /* 0x1E0 */ u16 textId; + /* 0x1E2 */ u8 inMsgState3; + /* 0x1E4 */ Path* path; + /* 0x1E8 */ s16 waypoint; + /* 0x1EA */ UNK_TYPE1 unk1EA[0x1C]; + /* 0x206 */ Vec3s jointTable[BBA_LIMB_MAX]; + /* 0x272 */ Vec3s morphTable[BBA_LIMB_MAX]; + /* 0x2DE */ Vec3s trackTarget; + /* 0x2E4 */ Vec3s headRot; + /* 0x2EA */ Vec3s torsoRot; + /* 0x2F0 */ UNK_TYPE1 unk2F0[0x12]; + /* 0x302 */ s16 limbRotTableY[18]; + /* 0x326 */ s16 limbRotTableZ[18]; + /* 0x34A */ UNK_TYPE1 unk34A[0xBA]; + /* 0x404 */ s16 sakonDeadTimer; + /* 0x406 */ UNK_TYPE1 unk406[4]; + /* 0x40A */ u16 stateFlags; + /* 0x40C */ s32 animIndex; + /* 0x410 */ Path* timePath; + /* 0x414 */ Vec3f timePathPoint; + /* 0x420 */ f32 timePathProgress; + /* 0x424 */ s32 timePathTotalTime; + /* 0x428 */ s32 timePathWaypointTime; + /* 0x42C */ s32 timePathWaypoint; + /* 0x430 */ s32 timePathElapsedTime; + /* 0x434 */ u8 scheduleResult; + /* 0x436 */ s16 timePathTimeSpeed; + /* 0x438 */ s32 timePathIsSetup; + /* 0x43C */ s32 timePathHasReachedEnd; } EnBaba; // size = 0x440 extern const ActorInit En_Baba_InitVars; diff --git a/src/overlays/actors/ovl_En_Baguo/z_en_baguo.c b/src/overlays/actors/ovl_En_Baguo/z_en_baguo.c index 8e70d5d6b..a0954943b 100644 --- a/src/overlays/actors/ovl_En_Baguo/z_en_baguo.c +++ b/src/overlays/actors/ovl_En_Baguo/z_en_baguo.c @@ -11,21 +11,20 @@ #define THIS ((EnBaguo*)thisx) -void EnBaguo_Init(Actor* thisx, GlobalContext* globalCtx); -void EnBaguo_Destroy(Actor* thisx, GlobalContext* globalCtx); -void EnBaguo_Update(Actor* thisx, GlobalContext* globalCtx); +void EnBaguo_Init(Actor* thisx, PlayState* play); +void EnBaguo_Destroy(Actor* thisx, PlayState* play); +void EnBaguo_Update(Actor* thisx, PlayState* play); -void EnBaguo_UndergroundIdle(EnBaguo* this, GlobalContext* globalCtx); -void EnBaguo_EmergeFromUnderground(EnBaguo* this, GlobalContext* globalCtx); -void EnBaguo_Idle(EnBaguo* this, GlobalContext* globalCtx); -void EnBaguo_Roll(EnBaguo* this, GlobalContext* globalCtx); +void EnBaguo_UndergroundIdle(EnBaguo* this, PlayState* play); +void EnBaguo_EmergeFromUnderground(EnBaguo* this, PlayState* play); +void EnBaguo_Idle(EnBaguo* this, PlayState* play); +void EnBaguo_Roll(EnBaguo* this, PlayState* play); 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_RetreatUnderground(EnBaguo* this, PlayState* play); +void EnBaguo_DrawBody(Actor* thisx, PlayState* play); +void EnBaguo_InitializeEffect(EnBaguo* this, Vec3f* pos, Vec3f* velocity, Vec3f* accel, f32 scale, s16 timer); +void EnBaguo_UpdateEffects(EnBaguo* this, PlayState* play); +void EnBaguo_DrawEffects(EnBaguo* this, PlayState* play); typedef enum { /* 0x0 */ NEJIRON_ACTION_INACTIVE, // The Nejiron is either underground or emerging from underground @@ -77,7 +76,7 @@ static ColliderJntSphInit sJntSphInit = { OC2_TYPE_1, COLSHAPE_JNTSPH, }, - 1, + ARRAY_COUNT(sJntSphElementsInit), sJntSphElementsInit, }; @@ -122,12 +121,11 @@ static DamageTable sDamageTable = { /* Powder Keg */ DMG_ENTRY(1, NEJIRON_DMGEFF_KILL), }; -void EnBaguo_Init(Actor* thisx, GlobalContext* globalCtx) { +void EnBaguo_Init(Actor* thisx, PlayState* play) { EnBaguo* this = THIS; ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 0.0f); - SkelAnime_Init(globalCtx, &this->skelAnime, &gNejironSkel, NULL, this->jointTable, this->morphTable, - NEJIRON_LIMB_MAX); + SkelAnime_Init(play, &this->skelAnime, &gNejironSkel, NULL, this->jointTable, this->morphTable, NEJIRON_LIMB_MAX); this->actor.hintId = 0xB; this->maxDistanceFromHome = 240.0f; this->maxDistanceFromHome += this->actor.world.rot.z * 40.0f; @@ -136,7 +134,7 @@ void EnBaguo_Init(Actor* thisx, GlobalContext* globalCtx) { this->actor.colChkInfo.mass = MASS_IMMOVABLE; this->actor.targetMode = 2; - Collider_InitAndSetJntSph(globalCtx, &this->collider, &this->actor, &sJntSphInit, this->colliderElements); + Collider_InitAndSetJntSph(play, &this->collider, &this->actor, &sJntSphInit, this->colliderElements); this->collider.elements[0].dim.modelSphere.radius = 30; this->collider.elements[0].dim.scale = 1.0f; this->collider.elements[0].dim.modelSphere.center.x = 80; @@ -152,15 +150,15 @@ void EnBaguo_Init(Actor* thisx, GlobalContext* globalCtx) { this->actionFunc = EnBaguo_UndergroundIdle; } -void EnBaguo_Destroy(Actor* thisx, GlobalContext* globalCtx) { +void EnBaguo_Destroy(Actor* thisx, PlayState* play) { EnBaguo* this = THIS; - Collider_DestroyJntSph(globalCtx, &this->collider); + Collider_DestroyJntSph(play, &this->collider); } -void EnBaguo_UndergroundIdle(EnBaguo* this, GlobalContext* globalCtx) { +void EnBaguo_UndergroundIdle(EnBaguo* this, PlayState* play) { this->action = NEJIRON_ACTION_INACTIVE; - if (this->actor.xzDistToPlayer < 200.0f && Player_GetMask(globalCtx) != PLAYER_MASK_STONE) { + if (this->actor.xzDistToPlayer < 200.0f && Player_GetMask(play) != PLAYER_MASK_STONE) { this->actor.draw = EnBaguo_DrawBody; Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_BAKUO_APPEAR); this->actor.world.rot.z = 0; @@ -172,12 +170,12 @@ void EnBaguo_UndergroundIdle(EnBaguo* this, GlobalContext* globalCtx) { this->actor.shape.rot.y = this->actor.world.rot.y; } -void EnBaguo_EmergeFromUnderground(EnBaguo* this, GlobalContext* globalCtx) { +void EnBaguo_EmergeFromUnderground(EnBaguo* this, PlayState* play) { this->actor.world.rot.y += 0x1518; this->actor.shape.rot.y = this->actor.world.rot.y; - if ((globalCtx->gameplayFrames % 8) == 0) { - Actor_SpawnFloorDustRing(globalCtx, &this->actor, &this->actor.world.pos, this->actor.shape.shadowScale - 20.0f, - 10, 8.0f, 500, 10, 1); + if ((play->gameplayFrames % 8) == 0) { + Actor_SpawnFloorDustRing(play, &this->actor, &this->actor.world.pos, this->actor.shape.shadowScale - 20.0f, 10, + 8.0f, 500, 10, 1); } Math_ApproachF(&this->actor.shape.shadowScale, 50.0f, 0.3f, 5.0f); Math_ApproachF(&this->actor.shape.yOffset, 2700.0f, 100.0f, 500.0f); @@ -189,7 +187,7 @@ void EnBaguo_EmergeFromUnderground(EnBaguo* this, GlobalContext* globalCtx) { } } -void EnBaguo_Idle(EnBaguo* this, GlobalContext* globalCtx) { +void EnBaguo_Idle(EnBaguo* this, PlayState* play) { s16 absoluteYaw; s16 yaw; @@ -204,8 +202,8 @@ void EnBaguo_Idle(EnBaguo* this, GlobalContext* globalCtx) { if ((this->timer & 8) != 0) { if (fabsf(this->actor.world.rot.y - this->actor.yawTowardsPlayer) > 200.0f) { Math_SmoothStepToS(&this->actor.world.rot.y, this->actor.yawTowardsPlayer, 30, 300, 1000); - if ((globalCtx->gameplayFrames % 8) == 0) { - Actor_SpawnFloorDustRing(globalCtx, &this->actor, &this->actor.world.pos, + if ((play->gameplayFrames % 8) == 0) { + Actor_SpawnFloorDustRing(play, &this->actor, &this->actor.world.pos, this->actor.shape.shadowScale - 20.0f, 10, 8.0f, 500, 10, 1); Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_BAKUO_VOICE); } @@ -235,12 +233,12 @@ void EnBaguo_Idle(EnBaguo* this, GlobalContext* globalCtx) { } } -void EnBaguo_Roll(EnBaguo* this, GlobalContext* globalCtx) { +void EnBaguo_Roll(EnBaguo* this, PlayState* play) { f32 xDistanceFromHome = this->actor.home.pos.x - this->actor.world.pos.x; f32 zDistanceFromHome = this->actor.home.pos.z - this->actor.world.pos.z; if ((sqrtf(SQ(xDistanceFromHome) + SQ(zDistanceFromHome)) > this->maxDistanceFromHome) || - (Player_GetMask(globalCtx) == PLAYER_MASK_STONE)) { + (Player_GetMask(play) == PLAYER_MASK_STONE)) { EnBaguo_SetupRetreatUnderground(this); } else if (this->timer == 0) { this->timer = 100; @@ -277,12 +275,12 @@ void EnBaguo_SetupRetreatUnderground(EnBaguo* this) { this->actor.speedXZ = 0.0f; } -void EnBaguo_RetreatUnderground(EnBaguo* this, GlobalContext* globalCtx) { +void EnBaguo_RetreatUnderground(EnBaguo* this, PlayState* play) { this->actor.world.rot.y -= 0x1518; this->actor.shape.rot.y = this->actor.world.rot.y; - if ((globalCtx->gameplayFrames % 8) == 0) { - Actor_SpawnFloorDustRing(globalCtx, &this->actor, &this->actor.world.pos, this->actor.shape.shadowScale - 20.0f, - 10, 8.0f, 500, 10, 1); + if ((play->gameplayFrames % 8) == 0) { + Actor_SpawnFloorDustRing(play, &this->actor, &this->actor.world.pos, this->actor.shape.shadowScale - 20.0f, 10, + 8.0f, 500, 10, 1); } Math_ApproachF(&this->actor.shape.yOffset, -3000.0f, 100.0f, 500.0f); @@ -299,19 +297,19 @@ void EnBaguo_RetreatUnderground(EnBaguo* this, GlobalContext* globalCtx) { } } -void EnBaguo_PostDetonation(EnBaguo* this, GlobalContext* globalCtx) { +void EnBaguo_PostDetonation(EnBaguo* this, PlayState* play) { if (this->timer == 0) { Actor_MarkForDeath(&this->actor); } if (this->timer >= 26) { - CollisionCheck_SetAT(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + CollisionCheck_SetAT(play, &play->colChkCtx, &this->collider.base); } } -void EnBaguo_CheckForDetonation(EnBaguo* this, GlobalContext* globalCtx) { +void EnBaguo_CheckForDetonation(EnBaguo* this, PlayState* play) { 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,19 +333,19 @@ 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, - this->actor.world.pos.y, this->actor.world.pos.z, 0, 0, 0, CLEAR_TAG_POP); + Actor_Spawn(&play->actorCtx, play, ACTOR_EN_CLEAR_TAG, this->actor.world.pos.x, this->actor.world.pos.y, + this->actor.world.pos.z, 0, 0, 0, CLEAR_TAG_POP); Actor_PlaySfxAtPos(&this->actor, NA_SE_IT_BOMB_EXPLOSION); Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_BAKUO_DEAD); @@ -357,26 +355,26 @@ void EnBaguo_CheckForDetonation(EnBaguo* this, GlobalContext* globalCtx) { Actor_SetScale(&this->actor, 0.0f); this->collider.elements->dim.scale = 3.0f; this->collider.elements->info.toucher.damage = 8; - Item_DropCollectibleRandom(globalCtx, NULL, &this->actor.world.pos, 0xB0); + Item_DropCollectibleRandom(play, NULL, &this->actor.world.pos, 0xB0); this->actionFunc = EnBaguo_PostDetonation; } } } } -void EnBaguo_Update(Actor* thisx, GlobalContext* globalCtx) { +void EnBaguo_Update(Actor* thisx, PlayState* play) { EnBaguo* this = THIS; Actor_SetFocus(&this->actor, 30.0f); - EnBaguo_UpdateParticles(this, globalCtx); - EnBaguo_CheckForDetonation(this, globalCtx); - this->actionFunc(this, globalCtx); + EnBaguo_UpdateEffects(this, play); + EnBaguo_CheckForDetonation(this, play); + this->actionFunc(this, play); DECR(this->blinkTimer); DECR(this->timer); if (this->action != NEJIRON_ACTION_EXPLODING && this->action != NEJIRON_ACTION_INACTIVE) { - CollisionCheck_SetAT(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + CollisionCheck_SetAT(play, &play->colChkCtx, &this->collider.base); } if (this->action != NEJIRON_ACTION_EXPLODING) { @@ -392,32 +390,32 @@ void EnBaguo_Update(Actor* thisx, GlobalContext* globalCtx) { } Actor_MoveWithGravity(&this->actor); - Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 20.0f, 20.0f, 60.0f, 0x1D); + Actor_UpdateBgCheckInfo(play, &this->actor, 20.0f, 20.0f, 60.0f, 0x1D); if (this->action != NEJIRON_ACTION_INACTIVE) { - CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + CollisionCheck_SetAC(play, &play->colChkCtx, &this->collider.base); } if (this->action != NEJIRON_ACTION_EXPLODING) { - CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + CollisionCheck_SetOC(play, &play->colChkCtx, &this->collider.base); } } } -void EnBaguo_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx) { +void EnBaguo_PostLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx) { EnBaguo* this = THIS; Collider_UpdateSpheres(limbIndex, &this->collider); } -void EnBaguo_DrawBody(Actor* thisx, GlobalContext* globalCtx) { +void EnBaguo_DrawBody(Actor* thisx, PlayState* play) { static TexturePtr sEyeTextures[] = { &gNejironEyeOpenTex, &gNejironEyeHalfTex, &gNejironEyeClosedTex }; EnBaguo* this = THIS; Gfx* gfx; s32 eyeIndex; void* virtualAddress; - OPEN_DISPS(globalCtx->state.gfxCtx); + OPEN_DISPS(play->state.gfxCtx); - func_8012C28C(globalCtx->state.gfxCtx); + func_8012C28C(play->state.gfxCtx); gfx = POLY_OPA_DISP; @@ -427,82 +425,81 @@ void EnBaguo_DrawBody(Actor* thisx, GlobalContext* globalCtx) { POLY_OPA_DISP = &gfx[1]; - SkelAnime_DrawOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, NULL, EnBaguo_PostLimbDraw, + SkelAnime_DrawOpa(play, this->skelAnime.skeleton, this->skelAnime.jointTable, NULL, EnBaguo_PostLimbDraw, &this->actor); - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->state.gfxCtx); - EnBaguo_DrawRockParticles(this, globalCtx); + EnBaguo_DrawEffects(this, play); } -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, PlayState* play) { 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, PlayState* play) { s16 i; - NejironParticle* particle = this->particles; - GraphicsContext* gfxCtx = globalCtx->state.gfxCtx; + NejironEffect* effect = this->effects; + GraphicsContext* gfxCtx = play->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); + func_8012C28C(play->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_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..6c98eeaeb 100644 --- a/src/overlays/actors/ovl_En_Baguo/z_en_baguo.h +++ b/src/overlays/actors/ovl_En_Baguo/z_en_baguo.h @@ -6,21 +6,23 @@ struct EnBaguo; -typedef void (*EnBaguoActionFunc)(struct EnBaguo*, GlobalContext*); +typedef void (*EnBaguoActionFunc)(struct EnBaguo*, PlayState*); /** * 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 193c899c9..3555f0998 100644 --- a/src/overlays/actors/ovl_En_Baisen/z_en_baisen.c +++ b/src/overlays/actors/ovl_En_Baisen/z_en_baisen.c @@ -11,17 +11,17 @@ #define THIS ((EnBaisen*)thisx) -void EnBaisen_Init(Actor* thisx, GlobalContext* globalCtx); -void EnBaisen_Destroy(Actor* thisx, GlobalContext* globalCtx); -void EnBaisen_Update(Actor* thisx, GlobalContext* globalCtx); -void EnBaisen_Draw(Actor* thisx, GlobalContext* globalCtx); +void EnBaisen_Init(Actor* thisx, PlayState* play); +void EnBaisen_Destroy(Actor* thisx, PlayState* play); +void EnBaisen_Update(Actor* thisx, PlayState* play); +void EnBaisen_Draw(Actor* thisx, PlayState* play); -void func_80BE87B0(EnBaisen* this, GlobalContext* globalCtx); +void func_80BE87B0(EnBaisen* this, PlayState* play); void func_80BE87FC(EnBaisen* this); -void func_80BE887C(EnBaisen* this, GlobalContext* globalCtx); -void func_80BE895C(EnBaisen* this, GlobalContext* globalCtx); -void func_80BE8AAC(EnBaisen* this, GlobalContext* globalCtx); -void func_80BE89D8(EnBaisen* this, GlobalContext* globalCtx); +void func_80BE887C(EnBaisen* this, PlayState* play); +void func_80BE895C(EnBaisen* this, PlayState* play); +void func_80BE8AAC(EnBaisen* this, PlayState* play); +void func_80BE89D8(EnBaisen* this, PlayState* play); const ActorInit En_Baisen_InitVars = { ACTOR_EN_BAISEN, @@ -57,15 +57,15 @@ static ColliderCylinderInit sCylinderInit = { 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 AnimationHeader* sAnimations[] = { &object_bai_Anim_0011C0, &object_bai_Anim_0008B4, &object_bai_Anim_008198 }; -static u8 animModes[] = { ANIMMODE_LOOP, ANIMMODE_LOOP }; +static u8 sAnimationModes[] = { ANIMMODE_LOOP, ANIMMODE_LOOP }; -void EnBaisen_Init(Actor* thisx, GlobalContext* globalCtx) { +void EnBaisen_Init(Actor* thisx, PlayState* play) { EnBaisen* this = THIS; ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 25.0f); - SkelAnime_InitFlex(globalCtx, &this->skelAnime, &object_bai_Skel_007908, &object_bai_Anim_0011C0, this->jointTable, + SkelAnime_InitFlex(play, &this->skelAnime, &object_bai_Skel_007908, &object_bai_Anim_0011C0, this->jointTable, this->morphTable, 20); this->actor.colChkInfo.mass = MASS_IMMOVABLE; this->paramCopy = this->actor.params; @@ -86,7 +86,7 @@ void EnBaisen_Init(Actor* thisx, GlobalContext* globalCtx) { } this->actor.targetMode = 6; this->actor.gravity = -3.0f; - Collider_InitAndSetCylinder(globalCtx, &this->collider, &this->actor, &sCylinderInit); + Collider_InitAndSetCylinder(play, &this->collider, &this->actor, &sCylinderInit); if (this->paramCopy == 0) { this->actionFunc = func_80BE87B0; } else { @@ -94,17 +94,17 @@ void EnBaisen_Init(Actor* thisx, GlobalContext* globalCtx) { } } -void EnBaisen_Destroy(Actor* thisx, GlobalContext* globalCtx) { +void EnBaisen_Destroy(Actor* thisx, PlayState* play) { EnBaisen* this = THIS; - Collider_DestroyCylinder(globalCtx, &this->collider); + Collider_DestroyCylinder(play, &this->collider); } -void EnBaisen_ChangeAnimation(EnBaisen* this, s32 animIndex) { +void EnBaisen_ChangeAnim(EnBaisen* this, s32 animIndex) { this->animIndex = animIndex; - this->frameCount = Animation_GetLastFrame(D_80BE8E4C[animIndex]); - Animation_Change(&this->skelAnime, D_80BE8E4C[this->animIndex], 1.0f, 0.0f, this->frameCount, - animModes[this->animIndex], -10.0f); + this->frameCount = Animation_GetLastFrame(sAnimations[animIndex]); + Animation_Change(&this->skelAnime, sAnimations[this->animIndex], 1.0f, 0.0f, this->frameCount, + sAnimationModes[this->animIndex], -10.0f); } void func_80BE871C(EnBaisen* this) { @@ -122,8 +122,8 @@ void func_80BE871C(EnBaisen* this) { } } -void func_80BE87B0(EnBaisen* this, GlobalContext* globalCtx) { - Actor* actorIterator = globalCtx->actorCtx.actorLists[ACTORCAT_NPC].first; +void func_80BE87B0(EnBaisen* this, PlayState* play) { + Actor* actorIterator = play->actorCtx.actorLists[ACTORCAT_NPC].first; while (actorIterator != NULL) { if (actorIterator->id == ACTOR_EN_HEISHI) { @@ -138,10 +138,10 @@ void func_80BE87B0(EnBaisen* this, GlobalContext* globalCtx) { void func_80BE87FC(EnBaisen* this) { if (this->paramCopy == 0) { this->textIdIndex = 2; - EnBaisen_ChangeAnimation(this, 2); + EnBaisen_ChangeAnim(this, 2); this->unk29E = this->actor.world.rot.y; } else { - EnBaisen_ChangeAnimation(this, 0); + EnBaisen_ChangeAnim(this, 0); } this->actor.textId = sTextIds[this->textIdIndex]; @@ -149,33 +149,33 @@ void func_80BE87FC(EnBaisen* this) { this->actionFunc = func_80BE887C; } -void func_80BE887C(EnBaisen* this, GlobalContext* globalCtx) { - if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { - func_80BE895C(this, globalCtx); +void func_80BE887C(EnBaisen* this, PlayState* play) { + if (Actor_ProcessTalkRequest(&this->actor, &play->state)) { + func_80BE895C(this, play); } else { if (this->paramCopy != 0) { this->textIdIndex = 0; if (gSaveContext.save.weekEventReg[60] & 8) { this->textIdIndex = 1; } - if (Player_GetMask(globalCtx) == PLAYER_MASK_COUPLE) { + if (Player_GetMask(play) == PLAYER_MASK_COUPLE) { this->textIdIndex = 6; } if (this->unk2AC == 1) { - func_80BE895C(this, globalCtx); + func_80BE895C(this, play); return; } } this->actor.textId = sTextIds[this->textIdIndex]; - func_800B8614(&this->actor, globalCtx, 70.0f); + func_800B8614(&this->actor, play, 70.0f); } } -void func_80BE895C(EnBaisen* this, GlobalContext* globalCtx) { +void func_80BE895C(EnBaisen* this, PlayState* play) { if (this->unk2A4 != NULL) { this->unk290 = true; this->unk2AC = 1; - Actor_ChangeFocus(this->unk2A4, globalCtx, this->unk2A4); + Actor_ChangeFocus(this->unk2A4, play, this->unk2A4); } this->unk29C = 1; if (this->paramCopy == 0) { @@ -186,20 +186,20 @@ void func_80BE895C(EnBaisen* this, GlobalContext* globalCtx) { } } -void func_80BE89D8(EnBaisen* this, GlobalContext* globalCtx) { +void func_80BE89D8(EnBaisen* this, PlayState* play) { if (&this->actor == this->unk2A4) { this->unk29E = this->actor.world.rot.y; if (this->animIndex == 0) { - EnBaisen_ChangeAnimation(this, 1); + EnBaisen_ChangeAnim(this, 1); } } else { this->unk29E = Math_Vec3f_Yaw(&this->actor.world.pos, &this->unk2A4->world.pos); if (this->animIndex != 0) { - EnBaisen_ChangeAnimation(this, 0); + EnBaisen_ChangeAnim(this, 0); } } - if ((globalCtx->msgCtx.currentTextId == 0x2AC6) || (globalCtx->msgCtx.currentTextId == 0x2AC7) || - (globalCtx->msgCtx.currentTextId == 0x2AC8)) { + if ((play->msgCtx.currentTextId == 0x2AC6) || (play->msgCtx.currentTextId == 0x2AC7) || + (play->msgCtx.currentTextId == 0x2AC8)) { this->skelAnime.playSpeed = 0.0f; this->unk29E = this->actor.yawTowardsPlayer; } @@ -208,38 +208,38 @@ void func_80BE89D8(EnBaisen* this, GlobalContext* globalCtx) { } } -void func_80BE8AAC(EnBaisen* this, GlobalContext* globalCtx) { +void func_80BE8AAC(EnBaisen* this, PlayState* play) { if ((this->textIdIndex % 2) != 0) { this->unk29E = this->actor.world.rot.y; if (this->animIndex == 0) { - EnBaisen_ChangeAnimation(this, 1); + EnBaisen_ChangeAnim(this, 1); } } else { if (this->unk2A4 != NULL) { this->unk29E = Math_Vec3f_Yaw(&this->actor.world.pos, &this->unk2A4->world.pos); } if (this->animIndex != 0) { - EnBaisen_ChangeAnimation(this, 0); + EnBaisen_ChangeAnim(this, 0); } } - if ((Message_GetState(&globalCtx->msgCtx) == 5) && Message_ShouldAdvance(globalCtx)) { - func_801477B4(globalCtx); + if ((Message_GetState(&play->msgCtx) == TEXT_STATE_5) && Message_ShouldAdvance(play)) { + func_801477B4(play); this->textIdIndex++; if (this->textIdIndex < 6) { - func_80151938(globalCtx, sTextIds[this->textIdIndex]); + func_80151938(play, sTextIds[this->textIdIndex]); if ((this->textIdIndex % 2) == 0) { this->unk2A4 = this->heishiPointer; } else { this->unk2A4 = &this->actor; } - Actor_ChangeFocus(this->unk2A4, globalCtx, this->unk2A4); + Actor_ChangeFocus(this->unk2A4, play, this->unk2A4); } else { func_80BE87FC(this); } } } -void EnBaisen_Update(Actor* thisx, GlobalContext* globalCtx) { +void EnBaisen_Update(Actor* thisx, PlayState* play) { s32 pad; EnBaisen* this = THIS; @@ -252,9 +252,9 @@ void EnBaisen_Update(Actor* thisx, GlobalContext* globalCtx) { Actor_MarkForDeath(&this->actor); return; } - this->actionFunc(this, globalCtx); + this->actionFunc(this, play); Actor_MoveWithGravity(&this->actor); - Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 20.0f, 20.0f, 50.0f, 0x1D); + Actor_UpdateBgCheckInfo(play, &this->actor, 20.0f, 20.0f, 50.0f, 0x1D); Actor_SetScale(&this->actor, 0.01f); if (this->unk290) { func_80BE871C(this); @@ -263,11 +263,10 @@ void EnBaisen_Update(Actor* thisx, GlobalContext* globalCtx) { Math_SmoothStepToS(&this->headRotX, this->headRotXTarget, 1, 0xBB8, 0); Math_SmoothStepToS(&this->headRotY, this->headRotYTarget, 1, 0x3E8, 0); Collider_UpdateCylinder(&this->actor, &this->collider); - CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + CollisionCheck_SetOC(play, &play->colChkCtx, &this->collider.base); } -s32 EnBaisen_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, - Actor* thisx) { +s32 EnBaisen_OverrideLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, Actor* thisx) { EnBaisen* this = THIS; if (limbIndex == 9) { @@ -279,10 +278,10 @@ s32 EnBaisen_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dLi return false; } -void EnBaisen_Draw(Actor* thisx, GlobalContext* globalCtx) { +void EnBaisen_Draw(Actor* thisx, PlayState* play) { EnBaisen* this = THIS; - func_8012C28C(globalCtx->state.gfxCtx); - SkelAnime_DrawFlexOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, + func_8012C28C(play->state.gfxCtx); + SkelAnime_DrawFlexOpa(play, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, EnBaisen_OverrideLimbDraw, NULL, &this->actor); } diff --git a/src/overlays/actors/ovl_En_Baisen/z_en_baisen.h b/src/overlays/actors/ovl_En_Baisen/z_en_baisen.h index f903ec15d..3fb45f70a 100644 --- a/src/overlays/actors/ovl_En_Baisen/z_en_baisen.h +++ b/src/overlays/actors/ovl_En_Baisen/z_en_baisen.h @@ -5,7 +5,7 @@ struct EnBaisen; -typedef void (*EnBaisenActionFunc)(struct EnBaisen*, GlobalContext*); +typedef void (*EnBaisenActionFunc)(struct EnBaisen*, PlayState*); typedef struct EnBaisen { /* 0x000 */ Actor actor; 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 2f57c2804..dec839006 100644 --- a/src/overlays/actors/ovl_En_Bal/z_en_bal.c +++ b/src/overlays/actors/ovl_En_Bal/z_en_bal.c @@ -10,10 +10,10 @@ #define THIS ((EnBal*)thisx) -void EnBal_Init(Actor* thisx, GlobalContext* globalCtx); -void EnBal_Destroy(Actor* thisx, GlobalContext* globalCtx); -void EnBal_Update(Actor* thisx, GlobalContext* globalCtx); -void EnBal_Draw(Actor* thisx, GlobalContext* globalCtx); +void EnBal_Init(Actor* thisx, PlayState* play); +void EnBal_Destroy(Actor* thisx, PlayState* play); +void EnBal_Update(Actor* thisx, PlayState* play); +void EnBal_Draw(Actor* thisx, PlayState* play); #if 0 const ActorInit En_Bal_InitVars = { @@ -78,7 +78,7 @@ static ColliderJntSphElementInit D_80A63D0C[1] = { // static ColliderJntSphInit sJntSphInit = { static ColliderJntSphInit D_80A63D30 = { { COLTYPE_NONE, AT_ON | AT_TYPE_ENEMY, AC_ON | AC_TYPE_PLAYER, OC1_ON | OC1_TYPE_ALL, OC2_TYPE_1, COLSHAPE_JNTSPH, }, - 1, D_80A63D0C, // sJntSphElementsInit, + ARRAY_COUNT(sJntSphElementsInit), D_80A63D0C, // sJntSphElementsInit, }; #endif @@ -100,7 +100,7 @@ extern UNK_TYPE D_0600D530; #pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bal/func_80A61A44.s") -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bal/func_80A61A6C.s") +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bal/EnBal_ValidatePictograph.s") #pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bal/func_80A61ADC.s") diff --git a/src/overlays/actors/ovl_En_Bal/z_en_bal.h b/src/overlays/actors/ovl_En_Bal/z_en_bal.h index ecd4309a0..7f64293db 100644 --- a/src/overlays/actors/ovl_En_Bal/z_en_bal.h +++ b/src/overlays/actors/ovl_En_Bal/z_en_bal.h @@ -2,16 +2,17 @@ #define Z_EN_BAL_H #include "global.h" +#include "z64snap.h" struct EnBal; -typedef void (*EnBalActionFunc)(struct EnBal*, GlobalContext*); +typedef void (*EnBalActionFunc)(struct EnBal*, PlayState*); typedef struct EnBal { - /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x48]; - /* 0x018C */ EnBalActionFunc actionFunc; - /* 0x0190 */ char unk_190[0x224]; + /* 0x000 */ PictoActor picto; + /* 0x148 */ char unk_148[0x44]; + /* 0x18C */ EnBalActionFunc actionFunc; + /* 0x190 */ char unk_190[0x224]; } EnBal; // size = 0x3B4 extern const ActorInit En_Bal_InitVars; diff --git a/src/overlays/actors/ovl_En_Bat/z_en_bat.c b/src/overlays/actors/ovl_En_Bat/z_en_bat.c index ab76d88c8..e81608721 100644 --- a/src/overlays/actors/ovl_En_Bat/z_en_bat.c +++ b/src/overlays/actors/ovl_En_Bat/z_en_bat.c @@ -5,22 +5,29 @@ */ #include "z_en_bat.h" +#include "objects/object_bat/object_bat.h" #define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_4 | ACTOR_FLAG_1000 | ACTOR_FLAG_4000) #define THIS ((EnBat*)thisx) -void EnBat_Init(Actor* thisx, GlobalContext* globalCtx); -void EnBat_Destroy(Actor* thisx, GlobalContext* globalCtx); -void EnBat_Update(Actor* thisx, GlobalContext* globalCtx); -void EnBat_Draw(Actor* thisx, GlobalContext* globalCtx); +#define BAD_BAT_FLAP_FRAME 5 -void func_80A438D4(EnBat* this, GlobalContext* globalCtx); -void func_80A4392C(EnBat* this, GlobalContext* globalCtx); -void func_80A43CE8(EnBat* this, GlobalContext* globalCtx); -void func_80A44114(EnBat* this, GlobalContext* globalCtx); +void EnBat_Init(Actor* thisx, PlayState* play); +void EnBat_Destroy(Actor* thisx, PlayState* play); +void EnBat_Update(Actor* thisx, PlayState* play); +void EnBat_Draw(Actor* thisx, PlayState* play); + +s32 EnBat_IsGraveyardOnSecondDay(PlayState* play); +void EnBat_SetupPerch(EnBat* this); +void EnBat_Perch(EnBat* this, PlayState* play); +void EnBat_SetupFlyIdle(EnBat* this); +void EnBat_FlyIdle(EnBat* this, PlayState* play); +void EnBat_SetupDiveAttack(EnBat* this); +void EnBat_DiveAttack(EnBat* this, PlayState* play); +void EnBat_Die(EnBat* this, PlayState* play); +void EnBat_Stunned(EnBat* this, PlayState* play); -#if 0 const ActorInit En_Bat_InitVars = { ACTOR_EN_BAT, ACTORCAT_ENEMY, @@ -33,99 +40,522 @@ const ActorInit En_Bat_InitVars = { (ActorFunc)EnBat_Draw, }; -// static ColliderSphereInit sSphereInit = { -static ColliderSphereInit D_80A44A00 = { - { COLTYPE_HIT3, AT_NONE | AT_TYPE_ENEMY, AC_ON | AC_TYPE_PLAYER, OC1_ON | OC1_TYPE_ALL, OC2_TYPE_1, COLSHAPE_SPHERE, }, - { ELEMTYPE_UNK0, { 0xF7CFFFFF, 0x00, 0x04 }, { 0xF7CFFFFF, 0x00, 0x00 }, TOUCH_ON | TOUCH_SFX_HARD, BUMP_ON, OCELEM_ON, }, +static ColliderSphereInit sSphereInit = { + { + COLTYPE_HIT3, + AT_NONE | AT_TYPE_ENEMY, + AC_ON | AC_TYPE_PLAYER, + OC1_ON | OC1_TYPE_ALL, + OC2_TYPE_1, + COLSHAPE_SPHERE, + }, + { + ELEMTYPE_UNK0, + { 0xF7CFFFFF, 0x00, 0x04 }, + { 0xF7CFFFFF, 0x00, 0x00 }, + TOUCH_ON | TOUCH_SFX_HARD, + BUMP_ON, + OCELEM_ON, + }, { 1, { { 0, 0, 0 }, 15 }, 100 }, }; -// static DamageTable sDamageTable = { -static DamageTable D_80A44A2C = { - /* Deku Nut */ DMG_ENTRY(0, 0x1), - /* Deku Stick */ DMG_ENTRY(1, 0x0), - /* Horse trample */ DMG_ENTRY(1, 0x0), - /* Explosives */ DMG_ENTRY(1, 0x0), - /* Zora boomerang */ DMG_ENTRY(1, 0x0), - /* Normal arrow */ DMG_ENTRY(1, 0x0), - /* UNK_DMG_0x06 */ DMG_ENTRY(0, 0x0), - /* Hookshot */ DMG_ENTRY(1, 0x0), - /* Goron punch */ DMG_ENTRY(1, 0x0), - /* Sword */ DMG_ENTRY(1, 0x0), - /* Goron pound */ DMG_ENTRY(1, 0x0), - /* Fire arrow */ DMG_ENTRY(2, 0x2), - /* Ice arrow */ DMG_ENTRY(2, 0x3), - /* Light arrow */ DMG_ENTRY(2, 0x4), - /* Goron spikes */ DMG_ENTRY(1, 0x0), - /* Deku spin */ DMG_ENTRY(1, 0x0), - /* Deku bubble */ DMG_ENTRY(1, 0x0), - /* Deku launch */ DMG_ENTRY(2, 0x0), - /* UNK_DMG_0x12 */ DMG_ENTRY(0, 0x1), - /* Zora barrier */ DMG_ENTRY(0, 0x5), - /* Normal shield */ DMG_ENTRY(0, 0x0), - /* Light ray */ DMG_ENTRY(0, 0x0), - /* Thrown object */ DMG_ENTRY(1, 0x0), - /* Zora punch */ DMG_ENTRY(1, 0x0), - /* Spin attack */ DMG_ENTRY(1, 0x0), - /* Sword beam */ DMG_ENTRY(0, 0x0), - /* Normal Roll */ DMG_ENTRY(0, 0x0), - /* UNK_DMG_0x1B */ DMG_ENTRY(0, 0x0), - /* UNK_DMG_0x1C */ DMG_ENTRY(0, 0x0), - /* Unblockable */ DMG_ENTRY(0, 0x0), - /* UNK_DMG_0x1E */ DMG_ENTRY(0, 0x0), - /* Powder Keg */ DMG_ENTRY(1, 0x0), +typedef enum { + /* 0 */ BAD_BAT_DMGEFF_NONE, + /* 1 */ BAD_BAT_DMGEFF_STUN, + /* 2 */ BAD_BAT_DMGEFF_FIRE, + /* 3 */ BAD_BAT_DMGEFF_ICE, + /* 4 */ BAD_BAT_DMGEFF_LIGHT, + /* 5 */ BAD_BAT_DMGEFF_ELECTRIC +} BatDamageEffect; + +static DamageTable sDamageTable = { + /* Deku Nut */ DMG_ENTRY(0, BAD_BAT_DMGEFF_STUN), + /* Deku Stick */ DMG_ENTRY(1, BAD_BAT_DMGEFF_NONE), + /* Horse trample */ DMG_ENTRY(1, BAD_BAT_DMGEFF_NONE), + /* Explosives */ DMG_ENTRY(1, BAD_BAT_DMGEFF_NONE), + /* Zora boomerang */ DMG_ENTRY(1, BAD_BAT_DMGEFF_NONE), + /* Normal arrow */ DMG_ENTRY(1, BAD_BAT_DMGEFF_NONE), + /* UNK_DMG_0x06 */ DMG_ENTRY(0, BAD_BAT_DMGEFF_NONE), + /* Hookshot */ DMG_ENTRY(1, BAD_BAT_DMGEFF_NONE), + /* Goron punch */ DMG_ENTRY(1, BAD_BAT_DMGEFF_NONE), + /* Sword */ DMG_ENTRY(1, BAD_BAT_DMGEFF_NONE), + /* Goron pound */ DMG_ENTRY(1, BAD_BAT_DMGEFF_NONE), + /* Fire arrow */ DMG_ENTRY(2, BAD_BAT_DMGEFF_FIRE), + /* Ice arrow */ DMG_ENTRY(2, BAD_BAT_DMGEFF_ICE), + /* Light arrow */ DMG_ENTRY(2, BAD_BAT_DMGEFF_LIGHT), + /* Goron spikes */ DMG_ENTRY(1, BAD_BAT_DMGEFF_NONE), + /* Deku spin */ DMG_ENTRY(1, BAD_BAT_DMGEFF_NONE), + /* Deku bubble */ DMG_ENTRY(1, BAD_BAT_DMGEFF_NONE), + /* Deku launch */ DMG_ENTRY(2, BAD_BAT_DMGEFF_NONE), + /* UNK_DMG_0x12 */ DMG_ENTRY(0, BAD_BAT_DMGEFF_STUN), + /* Zora barrier */ DMG_ENTRY(0, BAD_BAT_DMGEFF_ELECTRIC), + /* Normal shield */ DMG_ENTRY(0, BAD_BAT_DMGEFF_NONE), + /* Light ray */ DMG_ENTRY(0, BAD_BAT_DMGEFF_NONE), + /* Thrown object */ DMG_ENTRY(1, BAD_BAT_DMGEFF_NONE), + /* Zora punch */ DMG_ENTRY(1, BAD_BAT_DMGEFF_NONE), + /* Spin attack */ DMG_ENTRY(1, BAD_BAT_DMGEFF_NONE), + /* Sword beam */ DMG_ENTRY(0, BAD_BAT_DMGEFF_NONE), + /* Normal Roll */ DMG_ENTRY(0, BAD_BAT_DMGEFF_NONE), + /* UNK_DMG_0x1B */ DMG_ENTRY(0, BAD_BAT_DMGEFF_NONE), + /* UNK_DMG_0x1C */ DMG_ENTRY(0, BAD_BAT_DMGEFF_NONE), + /* Unblockable */ DMG_ENTRY(0, BAD_BAT_DMGEFF_NONE), + /* UNK_DMG_0x1E */ DMG_ENTRY(0, BAD_BAT_DMGEFF_NONE), + /* Powder Keg */ DMG_ENTRY(1, BAD_BAT_DMGEFF_NONE), }; -// sColChkInfoInit -static CollisionCheckInfoInit D_80A44A4C = { 1, 15, 30, 10 }; +static CollisionCheckInfoInit sColChkInfoInit = { 1, 15, 30, 10 }; -// static InitChainEntry sInitChain[] = { -static InitChainEntry D_80A44A54[] = { +static InitChainEntry sInitChain[] = { ICHAIN_S8(hintId, 96, ICHAIN_CONTINUE), ICHAIN_F32(uncullZoneForward, 3000, ICHAIN_CONTINUE), ICHAIN_F32_DIV1000(gravity, -500, ICHAIN_CONTINUE), ICHAIN_F32(targetArrowOffset, 2000, ICHAIN_STOP), }; -#endif +static Gfx* sWingsDLs[] = { + gBadBatWingsFrame0DL, gBadBatWingsFrame1DL, gBadBatWingsFrame2DL, gBadBatWingsFrame3DL, gBadBatWingsFrame4DL, + gBadBatWingsFrame5DL, gBadBatWingsFrame6DL, gBadBatWingsFrame7DL, gBadBatWingsFrame8DL, +}; -extern ColliderSphereInit D_80A44A00; -extern DamageTable D_80A44A2C; -extern CollisionCheckInfoInit D_80A44A4C; -extern InitChainEntry D_80A44A54[]; +#define BAD_BAT_MAX_NUMBER_ATTACKING 3 -extern UNK_TYPE D_060000A0; +s32 sNumberAttacking; //!< Limit number attacking player to at most `BAD_BAT_MAX_NUMBER_ATTACKING` +s32 sAlreadySpawned; //!< used for those spawned with room -1 in Graveyard to avoid respawn on room change -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bat/EnBat_Init.s") +void EnBat_Init(Actor* thisx, PlayState* play) { + EnBat* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bat/EnBat_Destroy.s") + Actor_ProcessInitChain(thisx, sInitChain); + Collider_InitAndSetSphere(play, &this->collider, thisx, &sSphereInit); + this->collider.dim.worldSphere.radius = sSphereInit.dim.modelSphere.radius; + CollisionCheck_SetInfo(&thisx->colChkInfo, &sDamageTable, &sColChkInfoInit); + ActorShape_Init(&thisx->shape, 2000.0f, ActorShadow_DrawCircle, 25.0f); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bat/func_80A437CC.s") + this->animationFrame = Rand_ZeroOne() * 9.0f; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bat/func_80A43810.s") + this->paramFlags = BAD_BAT_GET_PARAMFLAGS(thisx); + this->switchFlag = BAD_BAT_GET_SWITCHFLAG(thisx); + thisx->params = BAD_BAT_GET_TYPE(thisx); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bat/func_80A43870.s") + thisx->depthInWater = BGCHECK_Y_MIN; + Actor_SetFocus(thisx, 20.0f); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bat/func_80A438D4.s") + if (sAlreadySpawned) { + Actor_MarkForDeath(thisx); + } else if (EnBat_IsGraveyardOnSecondDay(play)) { + if (Flags_GetSwitch(play, this->switchFlag)) { + Actor_MarkForDeath(thisx); + } else { + this->actor.room = -1; + } + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bat/func_80A438F8.s") + if (this->paramFlags & BAD_BAT_PARAMFLAG_PERCH) { + thisx->params = 0; + EnBat_SetupPerch(this); + } else { + if (thisx->params == 0x1F) { + thisx->params = 0; + } + EnBat_SetupFlyIdle(this); + while (BAD_BAT_GET_NUMBER_TO_SPAWN(thisx) > 1) { + Actor_SpawnAsChildAndCutscene( + &play->actorCtx, play, ACTOR_EN_BAT, thisx->world.pos.x + randPlusMinusPoint5Scaled(200.0f), + thisx->world.pos.y + randPlusMinusPoint5Scaled(100.0f), + thisx->world.pos.z + randPlusMinusPoint5Scaled(200.0f), randPlusMinusPoint5Scaled(0x2000), + 0xFFFF * Rand_ZeroOne(), 0, BAD_BAT_PARAMS(this->switchFlag, this->paramFlags, 0), -1, thisx->unk20, + NULL); + BAD_BAT_GET_NUMBER_TO_SPAWN(thisx)--; + } + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bat/func_80A4392C.s") +void EnBat_Destroy(Actor* thisx, PlayState* play) { + EnBat* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bat/func_80A43CA0.s") + Collider_DestroySphere(play, &this->collider); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bat/func_80A43CE8.s") +s32 EnBat_IsGraveyardOnSecondDay(PlayState* play) { + if ((CURRENT_DAY == 2) && (play->sceneNum == SCENE_BOTI)) { + return true; + } else { + return false; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bat/func_80A43F60.s") +void EnBat_StepAnimation(EnBat* this, s32 frameStep) { + s32 prevFrame = this->animationFrame; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bat/func_80A44114.s") + this->animationFrame += frameStep; + if (this->animationFrame >= ARRAY_COUNT(sWingsDLs)) { + this->animationFrame -= ARRAY_COUNT(sWingsDLs); + } + if ((prevFrame < BAD_BAT_FLAP_FRAME) && (this->animationFrame >= BAD_BAT_FLAP_FRAME)) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_FFLY_FLY); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bat/func_80A44294.s") +void EnBat_SetupPerch(EnBat* this) { + this->collider.base.acFlags |= AC_ON; + this->collider.base.atFlags |= AT_ON; + this->collider.dim.worldSphere.center.x = this->actor.focus.pos.x; + this->collider.dim.worldSphere.center.y = this->actor.focus.pos.y; + this->collider.dim.worldSphere.center.z = this->actor.focus.pos.z; + this->actor.speedXZ = 0.0f; + this->actionFunc = EnBat_Perch; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bat/func_80A4431C.s") +void EnBat_Perch(EnBat* this, PlayState* play) { + EnBat_StepAnimation(this, 1); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bat/func_80A443D8.s") +void EnBat_SetupFlyIdle(EnBat* this) { + this->timer = 100; + this->collider.base.acFlags |= AC_ON; + this->actor.speedXZ = 3.5f; + this->actionFunc = EnBat_FlyIdle; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bat/EnBat_Update.s") +void EnBat_FlyIdle(EnBat* this, PlayState* play) { + s32 finishedRotStep; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bat/EnBat_Draw.s") + EnBat_StepAnimation(this, 1); + + finishedRotStep = Math_ScaledStepToS(&this->actor.shape.rot.y, this->yawTarget, 0x300); + + if (this->actor.bgCheckFlags & 8) { + this->actor.bgCheckFlags &= ~8; + this->yawTarget = this->actor.wallYaw; + } else if (Math3D_XZDistanceSquared(this->actor.world.pos.x, this->actor.world.pos.z, this->actor.home.pos.x, + this->actor.home.pos.z) > SQ(300.0f)) { + this->yawTarget = Actor_YawToPoint(&this->actor, &this->actor.home.pos); + } else if (finishedRotStep && (Rand_ZeroOne() < 0.015f)) { + this->yawTarget = + this->actor.shape.rot.y + (((s32)(0x1000 * Rand_ZeroOne()) + 0x1000) * ((Rand_ZeroOne() < 0.5f) ? -1 : 1)); + } + + finishedRotStep = Math_ScaledStepToS(&this->actor.shape.rot.x, this->pitchTarget, 0x100); + + if ((this->actor.bgCheckFlags & 1) || (this->actor.depthInWater > -40.0f)) { + this->pitchTarget = -0x1000; + } else if (this->actor.world.pos.y < (this->actor.home.pos.y - 100.0f)) { + this->pitchTarget = -((s32)(0x800 * Rand_ZeroOne()) + 0x800); + } else if ((this->actor.home.pos.y + 100.0f) < this->actor.world.pos.y) { + this->pitchTarget = (s32)(0x800 * Rand_ZeroOne()) + 0x800; + } else if ((finishedRotStep) && (Rand_ZeroOne() < 0.015f)) { + this->pitchTarget += (s16)(((s32)(0x400 * Rand_ZeroOne()) + 0x400) * ((Rand_ZeroOne() < 0.5f) ? -1 : 1)); + this->pitchTarget = CLAMP(this->pitchTarget, -0x1000, 0x1000); + } + + if (this->timer != 0) { + this->timer--; + } + if ((this->actor.xzDistToPlayer < 300.0f) && (this->timer == 0) && (Player_GetMask(play) != PLAYER_MASK_STONE) && + (sNumberAttacking < BAD_BAT_MAX_NUMBER_ATTACKING) && + (!(this->paramFlags & BAD_BAT_PARAMFLAG_CHECK_HEIGHTREL) || (fabsf(this->actor.playerHeightRel) < 150.0f))) { + EnBat_SetupDiveAttack(this); + } +} + +void EnBat_SetupDiveAttack(EnBat* this) { + this->collider.base.atFlags |= AT_ON; + this->timer = 300; + this->actor.speedXZ = 4.0f; + sNumberAttacking++; + this->actionFunc = EnBat_DiveAttack; +} + +void EnBat_DiveAttack(EnBat* this, PlayState* play) { + Player* player = GET_PLAYER(play); + s32 isFacingPlayer; + Vec3f preyPos; + + EnBat_StepAnimation(this, 2); + isFacingPlayer = Actor_IsFacingPlayer(&this->actor, 0x2800); + + if (isFacingPlayer) { + s16 pitchTarget; + + preyPos.x = player->actor.world.pos.x; + preyPos.y = player->actor.world.pos.y + 20.0f; + preyPos.z = player->actor.world.pos.z; + + pitchTarget = Actor_PitchToPoint(&this->actor, &preyPos); + pitchTarget = CLAMP(pitchTarget, -0x3000, 0x3000); + Math_SmoothStepToS(&this->actor.shape.rot.x, pitchTarget, 2, 0x400, 0x40); + } else { + Math_SmoothStepToS(&this->actor.shape.rot.x, -0x800, 2, 0x100, 0x10); + } + if (isFacingPlayer || (this->actor.xzDistToPlayer > 80.0f)) { + Math_SmoothStepToS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer, 4, 0xC00, 0xC0); + } + + this->timer--; + + if ((this->timer == 0) || (this->collider.base.atFlags & AT_HIT) || (Player_GetMask(play) == PLAYER_MASK_STONE) || + (this->actor.bgCheckFlags & 1) || (player->stateFlags1 & PLAYER_STATE1_800000) || + (this->actor.depthInWater > -40.0f)) { + if (this->collider.base.atFlags & AT_HIT) { + this->collider.base.atFlags &= ~AT_HIT; + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_FFLY_ATTACK); + } + this->collider.base.atFlags &= ~AT_ON; + sNumberAttacking--; + EnBat_SetupFlyIdle(this); + } else if ((this->actor.bgCheckFlags & 8) && + (ABS_ALT(BINANG_SUB(this->actor.wallYaw, this->actor.yawTowardsPlayer)) > 0x6800)) { + sNumberAttacking--; + this->collider.base.atFlags &= ~AT_ON; + this->actor.bgCheckFlags &= ~8; + this->yawTarget = this->actor.wallYaw; + EnBat_SetupFlyIdle(this); + } +} + +void EnBat_SetupDie(EnBat* this, PlayState* play) { + this->actor.flags &= ~ACTOR_FLAG_1; + Enemy_StartFinishingBlow(play, &this->actor); + this->actor.speedXZ *= Math_CosS(this->actor.world.rot.x); + this->actor.bgCheckFlags &= ~1; + this->actor.velocity.y = 0.0f; + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_FFLY_DEAD); + + if (this->actor.colChkInfo.damageEffect == BAD_BAT_DMGEFF_ICE) { + this->drawDmgEffType = ACTOR_DRAW_DMGEFF_FROZEN_NO_SFX; + this->drawDmgEffAlpha = 1.0f; + this->drawDmgEffFrozenSteamScale = 60.0f * (0.45f / 40.0f); + this->drawDmgEffScale = 0.45f; + } else if (this->actor.colChkInfo.damageEffect == BAD_BAT_DMGEFF_LIGHT) { + this->drawDmgEffType = ACTOR_DRAW_DMGEFF_LIGHT_ORBS; + this->drawDmgEffAlpha = 4.0f; + this->drawDmgEffScale = 0.45f; + Actor_Spawn(&play->actorCtx, play, ACTOR_EN_CLEAR_TAG, this->collider.info.bumper.hitPos.x, + this->collider.info.bumper.hitPos.y, this->collider.info.bumper.hitPos.z, 0, 0, 0, + CLEAR_TAG_SMALL_LIGHT_RAYS); + } else if (this->actor.colChkInfo.damageEffect == BAD_BAT_DMGEFF_FIRE) { + this->drawDmgEffType = ACTOR_DRAW_DMGEFF_FIRE; + this->drawDmgEffAlpha = 4.0f; + this->drawDmgEffScale = 0.45f; + } + + Actor_SetColorFilter(&this->actor, 0x4000, 255, 0, 40); + + if (this->actor.flags & ACTOR_FLAG_8000) { + this->actor.speedXZ = 0.0f; + } + + this->collider.base.acFlags &= ~AC_ON; + this->actor.flags |= ACTOR_FLAG_10; + this->actionFunc = EnBat_Die; +} + +void EnBat_Die(EnBat* this, PlayState* play) { + Math_StepToF(&this->actor.speedXZ, 0.0f, 0.5f); + this->actor.colorFilterTimer = 40; + + if (!(this->actor.flags & ACTOR_FLAG_8000)) { // Carried by arrow + if (this->drawDmgEffType != ACTOR_DRAW_DMGEFF_FROZEN_NO_SFX) { + Math_ScaledStepToS(&this->actor.shape.rot.x, 0x4000, 0x200); + this->actor.shape.rot.z += 0x1780; + } + + if ((this->actor.bgCheckFlags & 1) || (this->actor.floorHeight == BGCHECK_Y_MIN)) { + if (this->drawDmgEffType == ACTOR_DRAW_DMGEFF_FROZEN_NO_SFX) { + Actor_SpawnIceEffects(play, &this->actor, this->bodyPartPoss, ARRAY_COUNT(this->bodyPartPoss), 2, 0.2f, + 0.2f); + } + + func_800B3030(play, &this->actor.world.pos, &gZeroVec3f, &gZeroVec3f, 100, 0, 0); + SoundSource_PlaySfxAtFixedWorldPos(play, &this->actor.world.pos, 11, NA_SE_EN_EXTINCT); + Actor_MarkForDeath(&this->actor); + + if (this->actor.room == -1) { + Actor* enemy = NULL; + + // Search for other EnBats. If find none, set switch flag. + do { + enemy = SubS_FindActor(play, enemy, ACTORCAT_ENEMY, ACTOR_EN_BAT); + if (enemy != NULL) { + if (enemy != &this->actor) { + break; + } + enemy = enemy->next; + } + } while (enemy != NULL); + + if (enemy == NULL) { + Flags_SetSwitch(play, this->switchFlag); + } + } + } + } +} + +void EnBat_SetupStunned(EnBat* this) { + if (this->actionFunc != EnBat_Stunned) { + this->actor.shape.yOffset = 700.0f; + this->actor.velocity.y = 0.0f; + this->actor.speedXZ = 0.0f; + this->actor.world.pos.y += 13.0f; + } + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_COMMON_FREEZE); + Actor_SetColorFilter(&this->actor, 0, 255, 0, this->timer); + this->actionFunc = EnBat_Stunned; +} + +void EnBat_Stunned(EnBat* this, PlayState* play) { + Math_ScaledStepToS(&this->actor.shape.rot.x, 0, 0x100); + if ((this->actor.bgCheckFlags & 1) || (this->actor.floorHeight == BGCHECK_Y_MIN)) { + if (this->timer != 0) { + this->timer--; + } + if (this->timer == 0) { + EnBat_SetupFlyIdle(this); + } + } else { + this->actor.colorFilterTimer = 40; + if (this->drawDmgEffAlpha > 0.0f) { + this->drawDmgEffAlpha = 2.0f; + } + } +} + +void EnBat_UpdateDamage(EnBat* this, PlayState* play) { + if (this->collider.base.acFlags & AC_HIT) { + this->collider.base.acFlags &= ~AC_HIT; + + Actor_SetDropFlag(&this->actor, &this->collider.info); + this->collider.base.atFlags &= ~AT_ON; + + if (this->actionFunc == EnBat_DiveAttack) { + sNumberAttacking--; + } + + if (this->actor.colChkInfo.damageEffect == BAD_BAT_DMGEFF_ELECTRIC) { + this->timer = 40; + this->drawDmgEffType = ACTOR_DRAW_DMGEFF_ELECTRIC_SPARKS_LARGE; + this->drawDmgEffAlpha = 2.0f; + this->drawDmgEffScale = 0.45f; + EnBat_SetupStunned(this); + } else if (this->actor.colChkInfo.damageEffect == BAD_BAT_DMGEFF_STUN) { + this->timer = 40; + EnBat_SetupStunned(this); + } else { + Actor_ApplyDamage(&this->actor); + EnBat_SetupDie(this, play); + } + } +} + +void EnBat_Update(Actor* thisx, PlayState* play) { + s32 pad; + EnBat* this = THIS; + + if (this->actor.room == -1) { + sAlreadySpawned = true; + } + + EnBat_UpdateDamage(this, play); + this->actionFunc(this, play); + + if (this->actionFunc != EnBat_Stunned) { + Math_StepToF(&this->actor.shape.yOffset, 2000.0f, 200.0f); + } + + if (this->actionFunc != EnBat_Perch) { + Vec3f prevPos; + + this->actor.world.rot.y = this->actor.shape.rot.y; + this->actor.world.rot.x = -this->actor.shape.rot.x; + Math_Vec3f_Copy(&prevPos, &this->actor.prevPos); + + if ((this->actor.colChkInfo.health != 0) && (this->actionFunc != EnBat_Stunned)) { + Actor_MoveWithoutGravity(&this->actor); + } else { + Actor_MoveWithGravity(&this->actor); + } + + if (this->actionFunc == EnBat_DiveAttack) { + Actor_UpdateBgCheckInfo(play, &this->actor, 12.0f, 15.0f, 50.0f, 5); + } else if ((this->actionFunc != EnBat_FlyIdle) || + ((this->actor.xzDistToPlayer < 400.0f) && (this->actor.projectedPos.z > 0.0f))) { + if (this->paramFlags & BAD_BAT_PARAMFLAG_0) { + Actor_UpdateBgCheckInfo(play, &this->actor, 12.0f, 15.0f, 50.0f, 5); + } else { + Actor_UpdateBgCheckInfo(play, &this->actor, 12.0f, 15.0f, 50.0f, 4); + } + } else { + Math_Vec3f_Copy(&this->actor.prevPos, &prevPos); + } + + Actor_SetFocus(&this->actor, this->actor.shape.yOffset * 0.01f); + this->collider.dim.worldSphere.center.x = this->actor.focus.pos.x; + this->collider.dim.worldSphere.center.y = this->actor.focus.pos.y; + this->collider.dim.worldSphere.center.z = this->actor.focus.pos.z; + } + + if (this->collider.base.atFlags & AT_ON) { + CollisionCheck_SetAT(play, &play->colChkCtx, &this->collider.base); + } + if (this->actionFunc == EnBat_DiveAttack) { + CollisionCheck_SetOC(play, &play->colChkCtx, &this->collider.base); + } + if (this->collider.base.acFlags & AC_ON) { + CollisionCheck_SetAC(play, &play->colChkCtx, &this->collider.base); + } + + if (this->drawDmgEffAlpha > 0.0f) { + if (this->drawDmgEffType != ACTOR_DRAW_DMGEFF_FROZEN_NO_SFX) { + Math_StepToF(&this->drawDmgEffAlpha, 0.0f, 0.05f); + this->drawDmgEffScale = (this->drawDmgEffAlpha + 1.0f) * 0.225f; + this->drawDmgEffScale = CLAMP_MAX(this->drawDmgEffScale, 0.45f); + } else if (!Math_StepToF(&this->drawDmgEffFrozenSteamScale, 0.45f, 0.45f / 40.0f)) { + func_800B9010(&this->actor, NA_SE_EV_ICE_FREEZE - SFX_FLAG); + } + } +} + +void EnBat_Draw(Actor* thisx, PlayState* play) { + EnBat* this = THIS; + Gfx* gfx; + + // Draw body and wings + if (this->actor.projectedPos.z > 0.0f) { + OPEN_DISPS(play->state.gfxCtx); + + gfx = POLY_OPA_DISP; + + gSPDisplayList(&gfx[0], &sSetupDL[6 * 25]); + gSPMatrix(&gfx[1], Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(&gfx[2], gBadBatSetupDL); + gSPDisplayList(&gfx[3], gBadBatBodyDL); + gSPDisplayList(&gfx[4], sWingsDLs[this->animationFrame]); + + POLY_OPA_DISP = &gfx[5]; + + CLOSE_DISPS(play->state.gfxCtx); + } + + // Draw damage effects + if (this->drawDmgEffAlpha > 0.0f) { + s16 rollAngle; + + if (this->animationFrame < BAD_BAT_FLAP_FRAME - 1) { + rollAngle = this->animationFrame * (15 * (0x10000 / 360)); + } else { + rollAngle = (this->animationFrame >= BAD_BAT_FLAP_FRAME) + ? (this->animationFrame * (15 * (0x10000 / 360))) - (120 * (0x10000 / 360)) + : 0; + } + Matrix_MultZero(&this->bodyPartPoss[0]); + Matrix_RotateZS(rollAngle, MTXMODE_APPLY); + Matrix_MultVecX(1700.0f, &this->bodyPartPoss[1]); + Matrix_RotateZS(-2 * rollAngle, MTXMODE_APPLY); + Matrix_MultVecX(-1700.0f, &this->bodyPartPoss[2]); + Actor_DrawDamageEffects(play, &this->actor, this->bodyPartPoss, ARRAY_COUNT(this->bodyPartPoss), + this->drawDmgEffScale, this->drawDmgEffFrozenSteamScale, this->drawDmgEffAlpha, + this->drawDmgEffType); + } +} diff --git a/src/overlays/actors/ovl_En_Bat/z_en_bat.h b/src/overlays/actors/ovl_En_Bat/z_en_bat.h index 2ccaaa892..4f4ada810 100644 --- a/src/overlays/actors/ovl_En_Bat/z_en_bat.h +++ b/src/overlays/actors/ovl_En_Bat/z_en_bat.h @@ -3,14 +3,41 @@ #include "global.h" +#define BAD_BAT_GET_TYPE(thisx) (((thisx)->params >> 0) & 0x1F) +#define BAD_BAT_GET_PARAMFLAGS(thisx) (((thisx)->params >> 5) & 7) +#define BAD_BAT_GET_SWITCHFLAG(thisx) (((thisx)->params >> 8) & 0xFF) +#define BAD_BAT_PARAMS(switchFlag, paramflags, type) ((type) | ((paramflags) << 5) | ((switchFlag) << 8)) + +//! PARAMFLAGS +//! Affects which flags are used in Actor_UpdateBgCheckInfo in certain circumstances +#define BAD_BAT_PARAMFLAG_0 (1 << 0) +//! Whether to apply a height range check to attack +#define BAD_BAT_PARAMFLAG_CHECK_HEIGHTREL (1 << 1) +//! Spawn as perching instead of flying +#define BAD_BAT_PARAMFLAG_PERCH (1 << 2) + +#define BAD_BAT_GET_NUMBER_TO_SPAWN(thisx) ((thisx)->params) +#define BAD_BAT_SPAWN_COUNT(n) (n) + struct EnBat; -typedef void (*EnBatActionFunc)(struct EnBat*, GlobalContext*); +typedef void (*EnBatActionFunc)(struct EnBat*, PlayState*); typedef struct EnBat { - /* 0x0000 */ Actor actor; - /* 0x0144 */ EnBatActionFunc actionFunc; - /* 0x0148 */ char unk_148[0x94]; + /* 0x000 */ Actor actor; + /* 0x144 */ EnBatActionFunc actionFunc; + /* 0x148 */ u8 drawDmgEffType; + /* 0x149 */ u8 paramFlags; + /* 0x14A */ s16 switchFlag; + /* 0x14C */ s16 timer; + /* 0x14E */ s16 pitchTarget; + /* 0x150 */ s16 yawTarget; + /* 0x152 */ s16 animationFrame; //!< Manual animation using displaylists + /* 0x154 */ f32 drawDmgEffScale; + /* 0x158 */ f32 drawDmgEffFrozenSteamScale; + /* 0x15C */ f32 drawDmgEffAlpha; + /* 0x160 */ Vec3f bodyPartPoss[3]; + /* 0x184 */ ColliderSphere collider; } EnBat; // size = 0x1DC extern const ActorInit En_Bat_InitVars; diff --git a/src/overlays/actors/ovl_En_Bb/z_en_bb.c b/src/overlays/actors/ovl_En_Bb/z_en_bb.c index 82b3ab923..488ed0482 100644 --- a/src/overlays/actors/ovl_En_Bb/z_en_bb.c +++ b/src/overlays/actors/ovl_En_Bb/z_en_bb.c @@ -11,23 +11,23 @@ #define THIS ((EnBb*)thisx) -void EnBb_Init(Actor* thisx, GlobalContext* globalCtx); -void EnBb_Destroy(Actor* thisx, GlobalContext* globalCtx); -void EnBb_Update(Actor* thisx, GlobalContext* globalCtx); -void EnBb_Draw(Actor* thisx, GlobalContext* globalCtx); +void EnBb_Init(Actor* thisx, PlayState* play); +void EnBb_Destroy(Actor* thisx, PlayState* play); +void EnBb_Update(Actor* thisx, PlayState* play); +void EnBb_Draw(Actor* thisx, PlayState* play); void EnBb_SetupFlyIdle(EnBb* this); -void EnBb_FlyIdle(EnBb* this, GlobalContext* globalCtx); +void EnBb_FlyIdle(EnBb* this, PlayState* play); 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_Attack(EnBb* this, PlayState* play); +void EnBb_Down(EnBb* this, PlayState* play); +void EnBb_Dead(EnBb* this, PlayState* play); +void EnBb_Damage(EnBb* this, PlayState* play); +void EnBb_Frozen(EnBb* this, PlayState* play); void EnBb_SetupWaitForRevive(EnBb* this); -void EnBb_WaitForRevive(EnBb* this, GlobalContext* globalCtx); +void EnBb_WaitForRevive(EnBb* this, PlayState* play); void EnBb_SetupRevive(EnBb* this); -void EnBb_Revive(EnBb* this, GlobalContext* globalCtx); +void EnBb_Revive(EnBb* this, PlayState* play); typedef enum { /* -1 */ BB_BODY_PART_DRAW_STATUS_BROKEN = -1, @@ -134,13 +134,13 @@ static s8 sLimbIndexToBodyPartsIndex[] = { */ static Vec3f sDuplicateCraniumBodyPartOffset = { 1000.0f, -700.0f, 0.0f }; -void EnBb_Init(Actor* thisx, GlobalContext* globalCtx) { +void EnBb_Init(Actor* thisx, PlayState* play) { EnBb* this = THIS; Actor_ProcessInitChain(&this->actor, sInitChain); - SkelAnime_Init(globalCtx, &this->skelAnime, &gBubbleSkel, &gBubbleFlyingAnim, this->jointTable, this->morphTable, + SkelAnime_Init(play, &this->skelAnime, &gBubbleSkel, &gBubbleFlyingAnim, this->jointTable, this->morphTable, BUBBLE_LIMB_MAX); - Collider_InitAndSetSphere(globalCtx, &this->collider, &this->actor, &sSphereInit); + Collider_InitAndSetSphere(play, &this->collider, &this->actor, &sSphereInit); ActorShape_Init(&this->actor.shape, 1500.0f, ActorShadow_DrawCircle, 35.0f); CollisionCheck_SetInfo(&this->actor.colChkInfo, &sDamageTable, &sColChkInfoInit); @@ -157,10 +157,10 @@ void EnBb_Init(Actor* thisx, GlobalContext* globalCtx) { EnBb_SetupFlyIdle(this); } -void EnBb_Destroy(Actor* thisx, GlobalContext* globalCtx) { +void EnBb_Destroy(Actor* thisx, PlayState* play) { EnBb* this = THIS; - Collider_DestroySphere(globalCtx, &this->collider); + Collider_DestroySphere(play, &this->collider); } /** @@ -192,12 +192,11 @@ void EnBb_Freeze(EnBb* this) { Actor_SetColorFilter(&this->actor, 0x4000, 255, 0, 80); } -void EnBb_Thaw(EnBb* this, GlobalContext* globalCtx) { +void EnBb_Thaw(EnBb* this, PlayState* play) { 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); + Actor_SpawnIceEffects(play, &this->actor, this->bodyPartsPos, ARRAY_COUNT(this->bodyPartsPos), 2, 0.2f, 0.15f); this->actor.flags |= ACTOR_FLAG_200; } } @@ -241,7 +240,7 @@ void EnBb_SetupFlyIdle(EnBb* this) { if ((this->actor.xzDistToPlayer < (this->attackRange + 120.0f)) || (Actor_XZDistanceToPoint(&this->actor, &this->actor.home.pos) < 300.0f)) { - this->targetYRotation += (s16)(Rand_Next() >> 0x11); + this->targetYRotation += (s16)((s32)Rand_Next() >> 0x11); } this->collider.base.atFlags |= AT_ON; @@ -252,7 +251,7 @@ void EnBb_SetupFlyIdle(EnBb* this) { /** * Makes the Bubble fly in circles around its home. */ -void EnBb_FlyIdle(EnBb* this, GlobalContext* globalCtx) { +void EnBb_FlyIdle(EnBb* this, PlayState* play) { EnBb_UpdateStateForFlying(this); if (Animation_OnFrame(&this->skelAnime, 5.0f)) { @@ -265,7 +264,7 @@ void EnBb_FlyIdle(EnBb* this, GlobalContext* globalCtx) { this->timer--; if ((this->attackWaitTimer == 0) && (this->actor.xzDistToPlayer < this->attackRange) && - (Player_GetMask(globalCtx) != PLAYER_MASK_STONE)) { + (Player_GetMask(play) != PLAYER_MASK_STONE)) { EnBb_SetupAttack(this); } else if (this->timer == 0) { EnBb_SetupFlyIdle(this); @@ -284,7 +283,7 @@ void EnBb_SetupAttack(EnBb* this) { /** * Makes the Bubble actively move towards the player. */ -void EnBb_Attack(EnBb* this, GlobalContext* globalCtx) { +void EnBb_Attack(EnBb* this, PlayState* play) { this->targetYRotation = this->actor.yawTowardsPlayer; EnBb_UpdateStateForFlying(this); @@ -299,7 +298,7 @@ void EnBb_Attack(EnBb* this, GlobalContext* globalCtx) { this->timer--; if (((this->attackRange + 120.0f) < this->actor.xzDistToPlayer) || (this->timer == 0) || - (Player_GetMask(globalCtx) == PLAYER_MASK_STONE) || + (Player_GetMask(play) == PLAYER_MASK_STONE) || (Actor_XZDistanceToPoint(&this->actor, &this->actor.home.pos) > 400.0f)) { EnBb_SetupFlyIdle(this); } @@ -322,7 +321,7 @@ void EnBb_SetupDown(EnBb* this) { /** * Makes the Bubble hop along the ground. */ -void EnBb_Down(EnBb* this, GlobalContext* globalCtx) { +void EnBb_Down(EnBb* this, PlayState* play) { SkelAnime_Update(&this->skelAnime); EnBb_CheckForWall(this); @@ -341,7 +340,7 @@ void EnBb_Down(EnBb* this, GlobalContext* globalCtx) { } this->actor.bgCheckFlags &= ~1; - Actor_SpawnFloorDustRing(globalCtx, &this->actor, &this->actor.world.pos, 7.0f, 2, 2.0f, 0, 0, 0); + Actor_SpawnFloorDustRing(play, &this->actor, &this->actor.world.pos, 7.0f, 2, 2.0f, 0, 0, 0); Math_ScaledStepToS(&this->actor.shape.rot.y, BINANG_ADD(this->actor.yawTowardsPlayer, 0x8000), 0xBB8); } @@ -355,7 +354,7 @@ void EnBb_Down(EnBb* this, GlobalContext* globalCtx) { } } -void EnBb_SetupDead(EnBb* this, GlobalContext* globalCtx) { +void EnBb_SetupDead(EnBb* this, PlayState* play) { Vec3f* bodyPartVelocity; Vec3f posDiff; f32 magnitude; @@ -365,8 +364,8 @@ void EnBb_SetupDead(EnBb* this, GlobalContext* globalCtx) { 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); + SoundSource_PlaySfxAtFixedWorldPos(play, &this->actor.world.pos, 40, NA_SE_EN_BUBLE_DEAD); + Item_DropCollectibleRandom(play, &this->actor, &this->actor.world.pos, 0x70); this->actor.velocity.y = 0.0f; this->actor.speedXZ = 0.0f; this->bodyPartDrawStatus = BB_BODY_PART_DRAW_STATUS_DEAD; @@ -390,7 +389,7 @@ void EnBb_SetupDead(EnBb* this, GlobalContext* globalCtx) { this->actionFunc = EnBb_Dead; } -void EnBb_Dead(EnBb* this, GlobalContext* globalCtx) { +void EnBb_Dead(EnBb* this, PlayState* play) { s32 i; this->timer--; @@ -398,8 +397,8 @@ void EnBb_Dead(EnBb* this, GlobalContext* globalCtx) { 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); + func_800B3030(play, &this->bodyPartsPos[i], &gZeroVec3f, &gZeroVec3f, 40, 7, 2); + SoundSource_PlaySfxAtFixedWorldPos(play, &this->bodyPartsPos[i], 11, NA_SE_EN_EXTINCT); } EnBb_SetupWaitForRevive(this); @@ -435,7 +434,7 @@ void EnBb_SetupDamage(EnBb* this) { this->actionFunc = EnBb_Damage; } -void EnBb_Damage(EnBb* this, GlobalContext* globalCtx) { +void EnBb_Damage(EnBb* this, PlayState* play) { Math_SmoothStepToF(&this->actor.speedXZ, 0.0f, 1.0f, 0.5f, 0.0f); if ((this->actor.bgCheckFlags & 1) && (this->actor.speedXZ < 0.1f)) { EnBb_SetupDown(this); @@ -452,13 +451,13 @@ void EnBb_SetupFrozen(EnBb* this) { this->actionFunc = EnBb_Frozen; } -void EnBb_Frozen(EnBb* this, GlobalContext* globalCtx) { +void EnBb_Frozen(EnBb* this, PlayState* play) { DECR(this->timer); if (this->timer == 0) { - EnBb_Thaw(this, globalCtx); + EnBb_Thaw(this, play); if (this->actor.colChkInfo.health == 0) { - EnBb_SetupDead(this, globalCtx); + EnBb_SetupDead(this, play); } else { EnBb_SetupDown(this); } @@ -479,7 +478,7 @@ void EnBb_SetupWaitForRevive(EnBb* this) { this->actionFunc = EnBb_WaitForRevive; } -void EnBb_WaitForRevive(EnBb* this, GlobalContext* globalCtx) { +void EnBb_WaitForRevive(EnBb* this, PlayState* play) { this->timer--; if (this->timer == 0) { EnBb_SetupRevive(this); @@ -498,7 +497,7 @@ void EnBb_SetupRevive(EnBb* this) { this->actionFunc = EnBb_Revive; } -void EnBb_Revive(EnBb* this, GlobalContext* globalCtx) { +void EnBb_Revive(EnBb* this, PlayState* play) { SkelAnime_Update(&this->skelAnime); this->actor.shape.rot.y += 0x1F00; @@ -515,20 +514,20 @@ void EnBb_Revive(EnBb* this, GlobalContext* globalCtx) { this->actor.scale.y = ((0.01f - this->actor.scale.x) * 0.5f) + 0.01f; } -void EnBb_UpdateDamage(EnBb* this, GlobalContext* globalCtx) { +void EnBb_UpdateDamage(EnBb* this, PlayState* play) { 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))) { + !(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); + EnBb_Thaw(this, play); if (Actor_ApplyDamage(&this->actor) == 0) { - Enemy_StartFinishingBlow(globalCtx, &this->actor); + Enemy_StartFinishingBlow(play, &this->actor); } if (this->actor.colChkInfo.damageEffect == EN_BB_DMGEFF_ICE_ARROW) { @@ -540,7 +539,7 @@ void EnBb_UpdateDamage(EnBb* this, GlobalContext* globalCtx) { EnBb_SetupFrozen(this); } else if (this->actor.colChkInfo.health == 0) { - EnBb_SetupDead(this, globalCtx); + EnBb_SetupDead(this, play); } else { EnBb_SetupDamage(this); } @@ -549,7 +548,7 @@ void EnBb_UpdateDamage(EnBb* this, GlobalContext* globalCtx) { 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, + Actor_Spawn(&play->actorCtx, play, ACTOR_EN_CLEAR_TAG, this->collider.info.bumper.hitPos.x, this->collider.info.bumper.hitPos.y, this->collider.info.bumper.hitPos.z, 0, 0, 0, CLEAR_TAG_SMALL_LIGHT_RAYS); } @@ -579,14 +578,14 @@ void EnBb_UpdateDamage(EnBb* this, GlobalContext* globalCtx) { } } -void EnBb_Update(Actor* thisx, GlobalContext* globalCtx) { +void EnBb_Update(Actor* thisx, PlayState* play) { EnBb* this = THIS; - EnBb_UpdateDamage(this, globalCtx); - this->actionFunc(this, globalCtx); + EnBb_UpdateDamage(this, play); + this->actionFunc(this, play); 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); + Actor_UpdateBgCheckInfo(play, &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; @@ -598,15 +597,15 @@ void EnBb_Update(Actor* thisx, GlobalContext* globalCtx) { if (this->collider.base.atFlags & AT_ON) { this->actor.flags |= ACTOR_FLAG_1000000; - CollisionCheck_SetAT(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + CollisionCheck_SetAT(play, &play->colChkCtx, &this->collider.base); } if (this->collider.base.acFlags & AC_ON) { - CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + CollisionCheck_SetAC(play, &play->colChkCtx, &this->collider.base); } if (this->collider.base.ocFlags1 & OC1_ON) { - CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + CollisionCheck_SetOC(play, &play->colChkCtx, &this->collider.base); } if (this->drawDmgEffAlpha > 0.0f) { @@ -621,7 +620,7 @@ void EnBb_Update(Actor* thisx, GlobalContext* globalCtx) { } } -s32 EnBb_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, Actor* thisx) { +s32 EnBb_OverrideLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, Actor* thisx) { EnBb* this = THIS; if (this->bodyPartDrawStatus == BB_BODY_PART_DRAW_STATUS_BROKEN) { @@ -632,7 +631,7 @@ s32 EnBb_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, return false; } -void EnBb_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx) { +void EnBb_PostLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx) { s32 pad; EnBb* this = THIS; MtxF* currentMatrixState; @@ -640,17 +639,17 @@ void EnBb_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec if (this->bodyPartDrawStatus == BB_BODY_PART_DRAW_STATUS_ALIVE) { if (sLimbIndexToBodyPartsIndex[limbIndex] != -1) { if (sLimbIndexToBodyPartsIndex[limbIndex] == 0) { - Matrix_GetStateTranslationAndScaledX(1000.0f, &this->bodyPartsPos[0]); + Matrix_MultVecX(1000.0f, &this->bodyPartsPos[0]); } else if (sLimbIndexToBodyPartsIndex[limbIndex] == 3) { - Matrix_GetStateTranslationAndScaledX(-1000.0f, &this->bodyPartsPos[3]); - Matrix_MultiplyVector3fByState(&sDuplicateCraniumBodyPartOffset, &this->bodyPartsPos[4]); + Matrix_MultVecX(-1000.0f, &this->bodyPartsPos[3]); + Matrix_MultVec3f(&sDuplicateCraniumBodyPartOffset, &this->bodyPartsPos[4]); } else { - Matrix_GetStateTranslation(&this->bodyPartsPos[sLimbIndexToBodyPartsIndex[limbIndex]]); + Matrix_MultZero(&this->bodyPartsPos[sLimbIndexToBodyPartsIndex[limbIndex]]); } } } else if (this->bodyPartDrawStatus > BB_BODY_PART_DRAW_STATUS_ALIVE) { if (sLimbIndexToBodyPartsIndex[limbIndex] != -1) { - Matrix_GetStateTranslation(&this->bodyPartsPos[sLimbIndexToBodyPartsIndex[limbIndex]]); + Matrix_MultZero(&this->bodyPartsPos[sLimbIndexToBodyPartsIndex[limbIndex]]); } if (limbIndex == BUBBLE_LIMB_CRANIUM) { @@ -658,56 +657,54 @@ void EnBb_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec } } else { if (sLimbIndexToBodyPartsIndex[limbIndex] != -1) { - OPEN_DISPS(globalCtx->state.gfxCtx); + OPEN_DISPS(play->state.gfxCtx); - currentMatrixState = Matrix_GetCurrentState(); + 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_InsertZRotation_s(thisx->world.rot.z, MTXMODE_APPLY); - gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), - G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + Matrix_RotateZS(thisx->world.rot.z, MTXMODE_APPLY); + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_OPA_DISP++, this->limbDList); - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->state.gfxCtx); } } } -void EnBb_Draw(Actor* thisx, GlobalContext* globalCtx) { +void EnBb_Draw(Actor* thisx, PlayState* play) { s32 pad; EnBb* this = THIS; MtxF* currentMatrixState; Gfx* gfx; - OPEN_DISPS(globalCtx->state.gfxCtx); + OPEN_DISPS(play->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, + SkelAnime_DrawOpa(play, this->skelAnime.skeleton, this->skelAnime.jointTable, EnBb_OverrideLimbDraw, EnBb_PostLimbDraw, &this->actor); if (this->flameScaleX > 0.0f) { - currentMatrixState = Matrix_GetCurrentState(); - func_8012C2DC(globalCtx->state.gfxCtx); - Matrix_RotateY( - ((Camera_GetCamDirYaw(globalCtx->cameraPtrs[globalCtx->activeCamera]) - this->actor.shape.rot.y) + 0x8000), - MTXMODE_APPLY); + currentMatrixState = Matrix_GetCurrent(); + func_8012C2DC(play->state.gfxCtx); + Matrix_RotateYS(((Camera_GetCamDirYaw(GET_ACTIVE_CAM(play)) - this->actor.shape.rot.y) + 0x8000), + MTXMODE_APPLY); Matrix_Scale(this->flameScaleX, this->flameScaleY, 1.0f, MTXMODE_APPLY); gDPSetPrimColor(POLY_XLU_DISP++, 0x80, 0x80, 255, 255, 255, 255); gDPSetEnvColor(POLY_XLU_DISP++, 0, 0, 255, 0); - gSPSegment(POLY_XLU_DISP++, 0x08, - Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, 0, 0, 32, 64, 1, 0, - (globalCtx->gameplayFrames * -20) & 0x1FF, 32, 128)); + gSPSegment( + POLY_XLU_DISP++, 0x08, + Gfx_TwoTexScroll(play->state.gfxCtx, 0, 0, 0, 32, 64, 1, 0, (play->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); + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_XLU_DISP++, gEffFire1DL); } - Actor_DrawDamageEffects(globalCtx, &this->actor, this->bodyPartsPos, ARRAY_COUNT(this->bodyPartsPos), + Actor_DrawDamageEffects(play, &this->actor, this->bodyPartsPos, ARRAY_COUNT(this->bodyPartsPos), this->drawDmgEffScale, this->drawDmgEffFrozenSteamScale, this->drawDmgEffAlpha, this->drawDmgEffType); - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->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 7d5da25b3..e6171065a 100644 --- a/src/overlays/actors/ovl_En_Bb/z_en_bb.h +++ b/src/overlays/actors/ovl_En_Bb/z_en_bb.h @@ -8,7 +8,7 @@ struct EnBb; -typedef void (*EnBbActionFunc)(struct EnBb*, GlobalContext*); +typedef void (*EnBbActionFunc)(struct EnBb*, PlayState*); typedef struct EnBb { /* 0x000 */ Actor actor; 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 e502b6637..d141c6514 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 @@ -19,14 +19,14 @@ #define THIS ((EnBba01*)thisx) -void EnBba01_Init(Actor* thisx, GlobalContext* globalCtx); -void EnBba01_Destroy(Actor* thisx, GlobalContext* globalCtx); -void EnBba01_Update(Actor* thisx, GlobalContext* globalCtx); -void EnBba01_Draw(Actor* thisx, GlobalContext* globalCtx); +void EnBba01_Init(Actor* thisx, PlayState* play); +void EnBba01_Destroy(Actor* thisx, PlayState* play); +void EnBba01_Update(Actor* thisx, PlayState* play); +void EnBba01_Draw(Actor* thisx, PlayState* play); -void EnBba01_Walk(EnHy* this, GlobalContext* globalCtx); -void EnBba01_FaceFoward(EnHy* this, GlobalContext* globalCtx); -void EnBba01_Talk(EnHy* this, GlobalContext* globalCtx); +void EnBba01_Walk(EnHy* this, PlayState* play); +void EnBba01_FaceFoward(EnHy* this, PlayState* play); +void EnBba01_Talk(EnHy* this, PlayState* play); const ActorInit En_Bba_01_InitVars = { ACTOR_EN_BBA_01, @@ -97,67 +97,72 @@ static DamageTable sDamageTable = { /* Powder Keg */ DMG_ENTRY(0, 0), }; -u16 D_809CCCD8[] = { 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 }, +}; -void EnBba01_UpdateModel(EnBba01* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); - Vec3f focus; +void EnBba01_UpdateModel(EnBba01* this, PlayState* play) { + Player* player = GET_PLAYER(play); + Vec3f point; - EnHy_UpdateSkelAnime(&this->enHy, globalCtx); + EnHy_UpdateSkelAnime(&this->enHy, play); if (SubS_AngleDiffLessEqual(this->enHy.actor.shape.rot.y, 0x36B0, this->enHy.actor.yawTowardsPlayer)) { - focus.x = player->actor.world.pos.x; - focus.y = player->bodyPartsPos[7].y + 3.0f; - focus.z = player->actor.world.pos.z; - func_8013D2E0(&focus, &this->enHy.actor.focus.pos, &this->enHy.actor.shape.rot, &this->enHy.focusTarget, - &this->enHy.headRot, &this->enHy.torsoRot, D_809CCCD8); + 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.focusTarget.x, 0, 4, 0x3E8, 1); - Math_SmoothStepToS(&this->enHy.focusTarget.y, 0, 4, 0x3E8, 1); + 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, + SubS_FillLimbRotTables(play, this->enHy.limbRotTableY, this->enHy.limbRotTableZ, ARRAY_COUNT(this->enHy.limbRotTableY)); - EnHy_UpdateCollider(&this->enHy, globalCtx); + EnHy_UpdateCollider(&this->enHy, play); } -s32 EnBba01_TestIsTalking(EnBba01* this, GlobalContext* globalCtx) { +s32 EnBba01_TestIsTalking(EnBba01* this, PlayState* play) { s32 isTalking = false; - if (Actor_ProcessTalkRequest(&this->enHy.actor, &globalCtx->state)) { + if (Actor_ProcessTalkRequest(&this->enHy.actor, &play->state)) { isTalking = true; this->enHy.textId = 0x10B9; // Invalid textId, produces empty textbox - this->enHy.tmpFocusTarget = this->enHy.focusTarget; - this->enHy.tmpHeadRot = this->enHy.headRot; - this->enHy.tmpTorsoRot = this->enHy.torsoRot; - this->enHy.tmpActionFunc = this->enHy.actionFunc; + this->enHy.prevTrackTarget = this->enHy.trackTarget; + this->enHy.prevHeadRot = this->enHy.headRot; + this->enHy.prevTorsoRot = this->enHy.torsoRot; + this->enHy.prevActionFunc = this->enHy.actionFunc; this->enHy.actionFunc = EnBba01_Talk; } return isTalking; } -s32 func_809CC270(EnBba01* this, GlobalContext* globalCtx) { +s32 func_809CC270(EnBba01* this, PlayState* play) { s16 x; s16 y; - Actor_GetScreenPos(globalCtx, &this->enHy.actor, &x, &y); + Actor_GetScreenPos(play, &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); + func_800B85E0(&this->enHy.actor, play, 30.0f, PLAYER_AP_MAGIC_BEANS); } return true; } -void EnBba01_FinishInit(EnHy* this, GlobalContext* globalCtx) { +void EnBba01_FinishInit(EnHy* this, PlayState* play) { //! @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)) { + if (EnHy_Init(this, play, &gBbaSkel, ENHY_ANIM_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) { + if (ENBBA01_GET_PATH(&this->actor) == 0x3F) { this->actionFunc = EnBba01_FaceFoward; } else { this->actionFunc = EnBba01_Walk; @@ -165,116 +170,116 @@ void EnBba01_FinishInit(EnHy* this, GlobalContext* globalCtx) { } } -void EnBba01_Walk(EnHy* this, GlobalContext* globalCtx) { +void EnBba01_Walk(EnHy* this, PlayState* play) { if (EnHy_MoveForwards(this, 1.0f)) { this->curPoint = 0; } } -void EnBba01_FaceFoward(EnHy* this, GlobalContext* globalCtx) { +void EnBba01_FaceFoward(EnHy* this, PlayState* play) { this->actor.shape.rot = this->actor.world.rot; } -void EnBba01_Talk(EnHy* this, GlobalContext* globalCtx) { +void EnBba01_Talk(EnHy* this, PlayState* play) { s16 yaw; u8 talkState; Math_SmoothStepToS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer, 4, 0xFA0, 1); - talkState = Message_GetState(&globalCtx->msgCtx); - this->inMsgState3 = (talkState == 3) ? true : false; + + talkState = Message_GetState(&play->msgCtx); + this->inMsgState3 = (talkState == TEXT_STATE_3) ? true : false; switch (talkState) { - case 0: + case TEXT_STATE_NONE: yaw = ABS_ALT(this->actor.shape.rot.y - this->actor.yawTowardsPlayer); if (yaw < 0x64) { - Message_StartTextbox(globalCtx, this->textId, NULL); + Message_StartTextbox(play, this->textId, NULL); } break; - case 2: + + case TEXT_STATE_CLOSING: this->actor.textId = 0; - this->focusTarget = this->tmpFocusTarget; - this->headRot = this->tmpHeadRot; - this->torsoRot = this->tmpTorsoRot; + this->trackTarget = this->prevTrackTarget; + this->headRot = this->prevHeadRot; + this->torsoRot = this->prevTorsoRot; this->actor.shape.rot.y = this->actor.world.rot.y; - this->actionFunc = this->tmpActionFunc; - this->tmpActionFunc = NULL; + this->actionFunc = this->prevActionFunc; + this->prevActionFunc = NULL; break; } } -void EnBba01_Init(Actor* thisx, GlobalContext* globalCtx) { +void EnBba01_Init(Actor* thisx, PlayState* play) { s32 pad; EnBba01* this = THIS; - 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); + this->enHy.animObjIndex = SubS_GetObjectIndex(OBJECT_BBA, play); + this->enHy.headObjIndex = SubS_GetObjectIndex(OBJECT_BBA, play); + this->enHy.skelUpperObjIndex = SubS_GetObjectIndex(OBJECT_BBA, play); + this->enHy.skelLowerObjIndex = SubS_GetObjectIndex(OBJECT_BBA, play); 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); + Collider_InitCylinder(play, &this->enHy.collider); + Collider_SetCylinder(play, &this->enHy.collider, &this->enHy.actor, &sCylinderInit); CollisionCheck_SetInfo2(&this->enHy.actor.colChkInfo, &sDamageTable, &sColChkInfoInit); this->enHy.actor.flags &= ~ACTOR_FLAG_1; - this->enHy.path = SubS_GetPathByIndex(globalCtx, ENBBA01_GET_PATH(&this->enHy.actor), ENBBA01_NO_PATH); + this->enHy.path = SubS_GetPathByIndex(play, ENBBA01_GET_PATH(&this->enHy.actor), 0x3F); this->enHy.waitingOnInit = true; Actor_SetScale(&this->enHy.actor, 0.01f); this->enHy.actionFunc = EnBba01_FinishInit; } -void EnBba01_Destroy(Actor* thisx, GlobalContext* globalCtx) { +void EnBba01_Destroy(Actor* thisx, PlayState* play) { EnBba01* this = THIS; - Collider_DestroyCylinder(globalCtx, &this->enHy.collider); + Collider_DestroyCylinder(play, &this->enHy.collider); } -void EnBba01_Update(Actor* thisx, GlobalContext* globalCtx) { +void EnBba01_Update(Actor* thisx, PlayState* play) { 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); + EnBba01_TestIsTalking(this, play); + this->enHy.actionFunc(&this->enHy, play); + Actor_UpdateBgCheckInfo(play, &this->enHy.actor, 0.0f, 0.0f, 0.0f, 4); + EnBba01_UpdateModel(this, play); + func_809CC270(this, play); } -s32 EnBba01_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, - Actor* thisx) { +s32 EnBba01_OverrideLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, Actor* thisx) { EnBba01* this = THIS; s8 bodyPart; Vec3f zeroVec = { 0.0f, 0.0f, 0.0f }; bodyPart = gEnHyBodyParts[limbIndex]; if (bodyPart >= 0) { - Matrix_MultiplyVector3fByState(&zeroVec, &this->enHy.bodyPartsPos[bodyPart]); + 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); + OPEN_DISPS(play->state.gfxCtx); + gSPSegment(POLY_OPA_DISP++, 0x06, play->objectCtx.status[this->enHy.headObjIndex].segment); + gSegments[6] = PHYSICAL_TO_VIRTUAL(play->objectCtx.status[this->enHy.headObjIndex].segment); + gSegments[6] = PHYSICAL_TO_VIRTUAL(play->objectCtx.status[this->enHy.skelLowerObjIndex].segment); + CLOSE_DISPS(play->state.gfxCtx); } if (limbIndex == BBA_LIMB_RIGHT_LOWER_ARM_ROOT) { - Matrix_InsertTranslation(1500.0f, 0.0f, 0.0f, MTXMODE_APPLY); - Matrix_InsertXRotation_s(this->enHy.headRot.y, MTXMODE_APPLY); - Matrix_InsertZRotation_s(-this->enHy.headRot.x, MTXMODE_APPLY); - Matrix_InsertTranslation(-1500.0f, 0.0f, 0.0f, MTXMODE_APPLY); + 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_InsertXRotation_s(-this->enHy.torsoRot.y, MTXMODE_APPLY); - Matrix_InsertZRotation_s(-this->enHy.torsoRot.x, MTXMODE_APPLY); + 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_InsertTranslation(40.0f, 0.0f, 0.0f, MTXMODE_APPLY); + if ((limbIndex == BBA_LIMB_RIGHT_LOWER_ARM_ROOT) && this->enHy.inMsgState3 && ((play->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)) { @@ -285,51 +290,51 @@ s32 EnBba01_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dLis return false; } -void EnBba01_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx) { +void EnBba01_PostLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx) { EnBba01* this = THIS; - GraphicsContext* gfxCtx = globalCtx->state.gfxCtx; + GraphicsContext* gfxCtx = play->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); + OPEN_DISPS(play->state.gfxCtx); + gSPSegment(POLY_OPA_DISP++, 0x06, play->objectCtx.status[this->enHy.skelUpperObjIndex].segment); + gSegments[0x06] = PHYSICAL_TO_VIRTUAL(play->objectCtx.status[this->enHy.skelUpperObjIndex].segment); + CLOSE_DISPS(play->state.gfxCtx); } if (limbIndex == BBA_LIMB_RIGHT_LOWER_ARM_ROOT) { - Matrix_MultiplyVector3fByState(&zeroVec, &this->enHy.actor.focus.pos); + Matrix_MultVec3f(&zeroVec, &this->enHy.actor.focus.pos); } } -void EnBba01_TransformLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Actor* thisx) { +void EnBba01_TransformLimbDraw(PlayState* play, s32 limbIndex, Actor* thisx) { } -void EnBba01_Draw(Actor* thisx, GlobalContext* globalCtx) { +void EnBba01_Draw(Actor* thisx, PlayState* play) { EnBba01* this = THIS; s32 i; - u8* shadowTex = GRAPH_ALLOC(globalCtx->state.gfxCtx, sizeof(u8[64][64])); + u8* shadowTex = GRAPH_ALLOC(play->state.gfxCtx, SUBS_SHADOW_TEX_SIZE); u8* shadowTexIter; - OPEN_DISPS(globalCtx->state.gfxCtx); + OPEN_DISPS(play->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)); + func_8012C28C(play->state.gfxCtx); + gSPSegment(POLY_OPA_DISP++, 0x08, Gfx_EnvColor(play->state.gfxCtx, 255, 255, 255, 0)); + gSPSegment(POLY_OPA_DISP++, 0x09, Gfx_EnvColor(play->state.gfxCtx, 55, 55, 255, 0)); gDPPipeSync(POLY_OPA_DISP++); - SkelAnime_DrawTransformFlexOpa(globalCtx, this->enHy.skelAnime.skeleton, this->enHy.skelAnime.jointTable, + SkelAnime_DrawTransformFlexOpa(play, this->enHy.skelAnime.skeleton, this->enHy.skelAnime.jointTable, this->enHy.skelAnime.dListCount, EnBba01_OverrideLimbDraw, EnBba01_PostLimbDraw, EnBba01_TransformLimbDraw, &this->enHy.actor); - Matrix_InsertXRotation_s(0, MTXMODE_NEW); + Matrix_RotateXS(0, MTXMODE_NEW); - for (i = 0, shadowTexIter = shadowTex; i < (s32)sizeof(u8[64][64]); i++) { + for (i = 0, shadowTexIter = shadowTex; i < SUBS_SHADOW_TEX_SIZE; i++) { *shadowTexIter++ = 0; } for (i = 0; i < 5; i++) { - func_8013CD64(this->enHy.bodyPartsPos, &this->enHy.actor.world.pos, shadowTex, i / 5.0f, - ARRAY_COUNT(this->enHy.bodyPartsPos), gEnHyShadowSize, gEnHyBodyPartsIndex); + SubS_GenShadowTex(this->enHy.bodyPartsPos, &this->enHy.actor.world.pos, shadowTex, i / 5.0f, + ARRAY_COUNT(this->enHy.bodyPartsPos), gEnHyShadowSizes, gEnHyParentBodyParts); } - func_8013CF04(&this->enHy.actor, &globalCtx->state.gfxCtx, shadowTex); + SubS_DrawShadowTex(&this->enHy.actor, &play->state, shadowTex); - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->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 b670dea01..c9030f112 100644 --- a/src/overlays/actors/ovl_En_Bba_01/z_en_bba_01.h +++ b/src/overlays/actors/ovl_En_Bba_01/z_en_bba_01.h @@ -5,10 +5,9 @@ struct EnBba01; -typedef void (*EnBba01ActionFunc)(struct EnBba01*, GlobalContext*); +typedef void (*EnBba01ActionFunc)(struct EnBba01*, PlayState*); #define ENBBA01_GET_PATH(thisx) (((thisx)->params & 0x7E00) >> 9) -#define ENBBA01_NO_PATH 0x3F typedef struct EnBba01 { /* 0x000 */ EnHy enHy; diff --git a/src/overlays/actors/ovl_En_Bbfall/z_en_bbfall.c b/src/overlays/actors/ovl_En_Bbfall/z_en_bbfall.c index 8af8e650a..2193203fe 100644 --- a/src/overlays/actors/ovl_En_Bbfall/z_en_bbfall.c +++ b/src/overlays/actors/ovl_En_Bbfall/z_en_bbfall.c @@ -5,26 +5,36 @@ */ #include "z_en_bbfall.h" +#include "objects/gameplay_keep/gameplay_keep.h" #define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_4 | ACTOR_FLAG_10 | ACTOR_FLAG_200) #define THIS ((EnBbfall*)thisx) -void EnBbfall_Init(Actor* thisx, GlobalContext* globalCtx); -void EnBbfall_Destroy(Actor* thisx, GlobalContext* globalCtx); -void EnBbfall_Update(Actor* thisx, GlobalContext* globalCtx); -void EnBbfall_Draw(Actor* thisx, GlobalContext* globalCtx); +void EnBbfall_Init(Actor* thisx, PlayState* play); +void EnBbfall_Destroy(Actor* thisx, PlayState* play); +void EnBbfall_Update(Actor* thisx, PlayState* play); +void EnBbfall_Draw(Actor* thisx, PlayState* play); -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, PlayState* play); +void EnBbfall_SetupEmerge(EnBbfall* this); +void EnBbfall_Emerge(EnBbfall* this, PlayState* play); +void EnBbfall_SetupFly(EnBbfall* this); +void EnBbfall_Fly(EnBbfall* this, PlayState* play); +void EnBbfall_SetupSinkIntoLava(EnBbfall* this); +void EnBbfall_SinkIntoLava(EnBbfall* this, PlayState* play); +void EnBbfall_Down(EnBbfall* this, PlayState* play); +void EnBbfall_Dead(EnBbfall* this, PlayState* play); +void EnBbfall_Damage(EnBbfall* this, PlayState* play); +void EnBbfall_Frozen(EnBbfall* this, PlayState* play); + +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,714 @@ 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, PlayState* play) { + 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(play, &this->skelAnime, &gBubbleSkel, &gBubbleFlyingAnim, this->jointTable, this->morphTable, + BUBBLE_LIMB_MAX); + CollisionCheck_SetInfo(&this->actor.colChkInfo, &sDamageTable, &sColChkInfoInit); + Collider_InitAndSetJntSph(play, &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, PlayState* play) { + EnBbfall* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bbfall/func_808BF344.s") + Collider_DestroyJntSph(play, &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, PlayState* play) { + if (this->drawDmgEffType == ACTOR_DRAW_DMGEFF_FROZEN_NO_SFX) { + this->drawDmgEffType = ACTOR_DRAW_DMGEFF_FIRE; + this->drawDmgEffAlpha = 0.0f; + Actor_SpawnIceEffects(play, &this->actor, this->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, PlayState* play) { + if (!SurfaceType_IsWallDamage(&play->colCtx, this->actor.floorPoly, this->actor.floorBgId)) { + u32 floorType = func_800C99D4(&play->colCtx, this->actor.floorPoly, this->actor.floorBgId); -#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, PlayState* play) { + if (this->timer != 0) { + this->timer--; + } else if ((Player_GetMask(play) != 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, PlayState* play) { + 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, PlayState* play) { + 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, play)) { + 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, PlayState* play) { + 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, PlayState* play) { + SkelAnime_Update(&this->skelAnime); + EnBbfall_CheckForWall(this); + + if (this->actor.bgCheckFlags & 1) { + if (EnBbfall_IsTouchingLava(this, play)) { + 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(play, &this->actor, &this->actor.world.pos, 7.0f, 2, 2.0f, 0, 0, 0); + Math_ScaledStepToS(&this->actor.shape.rot.y, BINANG_ADD(this->actor.yawTowardsPlayer, 0x8000), 0xBB8); + } + + this->actor.world.rot.y = this->actor.shape.rot.y; + if (Animation_OnFrame(&this->skelAnime, 5.0f)) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_BUBLE_WING); + } + + if (this->timer > 0) { + this->timer--; + } +} + +void EnBbfall_SetupDead(EnBbfall* this, PlayState* play) { + 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(play, &this->actor.world.pos, 40, NA_SE_EN_BUBLE_DEAD); + Item_DropCollectibleRandom(play, &this->actor, &this->actor.world.pos, 0x70); + this->actor.velocity.y = 0.0f; + this->actor.speedXZ = 0.0f; + this->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, PlayState* play) { + 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(play, &this->bodyPartsPos[i], &gZeroVec3f, &gZeroVec3f, 40, 7, 2); + SoundSource_PlaySfxAtFixedWorldPos(play, &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, PlayState* play) { + Math_SmoothStepToF(&this->actor.speedXZ, 0.0f, 1.0f, 0.5f, 0.0f); + if ((this->actor.bgCheckFlags & 1) && (this->actor.speedXZ < 0.1f)) { + if (EnBbfall_IsTouchingLava(this, play)) { + 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, PlayState* play) { + DECR(this->timer); + + if (this->timer == 0) { + EnBbfall_Thaw(this, play); + if (this->actor.colChkInfo.health == 0) { + EnBbfall_SetupDead(this, play); + } else { + EnBbfall_SetupDown(this); + } + } +} + +void EnBbfall_UpdateDamage(EnBbfall* this, PlayState* play) { + 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, play); + + if (Actor_ApplyDamage(&this->actor) == 0) { + Enemy_StartFinishingBlow(play, &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, play); + } 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(&play->actorCtx, play, 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, PlayState* play) { + EnBbfall* this = THIS; + Sphere16* sphere; + Vec3f diff; + s32 i; + f32 scale; + s32 pad[2]; + + EnBbfall_UpdateDamage(this, play); + this->actionFunc(this, play); + if (this->actionFunc != EnBbfall_Dead) { + Actor_MoveWithGravity(&this->actor); + if (this->isBgCheckCollisionEnabled) { + Actor_UpdateBgCheckInfo(play, &this->actor, 30.0f, 25.0f, 20.0f, 7); + } + + 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(play, &play->colChkCtx, &this->collider.base); + } + + if (this->collider.base.acFlags & AC_ON) { + CollisionCheck_SetAC(play, &play->colChkCtx, &this->collider.base); + } + + if (this->collider.base.ocFlags1 & OC1_ON) { + CollisionCheck_SetOC(play, &play->colChkCtx, &this->collider.base); + } + + if (this->drawDmgEffAlpha > 0.0f) { + if (this->drawDmgEffType != ACTOR_DRAW_DMGEFF_FROZEN_NO_SFX) { + Math_StepToF(&this->drawDmgEffAlpha, 0.0f, 0.05f); + this->drawDmgEffScale = (this->drawDmgEffAlpha + 1.0f) * 0.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(PlayState* play, 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(PlayState* play, 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(play->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(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_OPA_DISP++, this->limbDList); + + CLOSE_DISPS(play->state.gfxCtx); + } + } +} + +void EnBbfall_Draw(Actor* thisx, PlayState* play2) { + PlayState* play = play2; + EnBbfall* this = THIS; + MtxF* currentMatrixState; + Gfx* gfx; + s32 opacity; + Vec3f* pos; + s32 i; + + OPEN_DISPS(play->state.gfxCtx); + + gfx = POLY_OPA_DISP; + gSPDisplayList(&gfx[0], &sSetupDL[6 * 25]); + POLY_OPA_DISP = &gfx[1]; + SkelAnime_DrawOpa(play, this->skelAnime.skeleton, this->skelAnime.jointTable, EnBbfall_OverrideLimbDraw, + EnBbfall_PostLimbDraw, &this->actor); + + if (this->flameOpacity > 0) { + func_8012C2DC(play->state.gfxCtx); + Matrix_RotateYS(((Camera_GetCamDirYaw(GET_ACTIVE_CAM(play)) - this->actor.shape.rot.y) + 0x8000), + MTXMODE_APPLY); + Matrix_Scale(this->flameScaleX, this->flameScaleY, 1.0f, MTXMODE_APPLY); + gDPSetEnvColor(POLY_XLU_DISP++, 255, 0, 0, 0); + currentMatrixState = Matrix_GetCurrent(); + + opacity = this->flameOpacity; + pos = &this->flamePos[0]; + + for (i = 0; i < ARRAY_COUNT(this->flamePos); i++, pos++) { + gSPSegment(POLY_XLU_DISP++, 0x08, + Gfx_TwoTexScroll(play->state.gfxCtx, 0, 0, 0, 32, 64, 1, 0, + ((play->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(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_XLU_DISP++, gEffFire1DL); + + opacity -= 35; + if (opacity < 0) { + break; + } + + Matrix_Scale(0.87f, 0.87f, 1.0f, MTXMODE_APPLY); + } + } + + Actor_DrawDamageEffects(play, &this->actor, this->bodyPartsPos, ARRAY_COUNT(this->bodyPartsPos), + this->drawDmgEffScale, this->drawDmgEffFrozenSteamScale, this->drawDmgEffAlpha, + this->drawDmgEffType); + + CLOSE_DISPS(play->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..e835015e1 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 void (*EnBbfallActionFunc)(struct EnBbfall*, PlayState*); 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 ecb64cb91..f53b58bf6 100644 --- a/src/overlays/actors/ovl_En_Bee/z_en_bee.c +++ b/src/overlays/actors/ovl_En_Bee/z_en_bee.c @@ -10,13 +10,13 @@ #define THIS ((EnBee*)thisx) -void EnBee_Init(Actor* thisx, GlobalContext* globalCtx); -void EnBee_Destroy(Actor* thisx, GlobalContext* globalCtx); -void EnBee_Update(Actor* thisx, GlobalContext* globalCtx); -void EnBee_Draw(Actor* thisx, GlobalContext* globalCtx); +void EnBee_Init(Actor* thisx, PlayState* play); +void EnBee_Destroy(Actor* thisx, PlayState* play); +void EnBee_Update(Actor* thisx, PlayState* play); +void EnBee_Draw(Actor* thisx, PlayState* play); -void func_80B5A9E8(EnBee* this, GlobalContext* globalCtx); -void func_80B5AC3C(EnBee* this, GlobalContext* globalCtx); +void func_80B5A9E8(EnBee* this, PlayState* play); +void func_80B5AC3C(EnBee* this, PlayState* play); #if 0 const ActorInit En_Bee_InitVars = { diff --git a/src/overlays/actors/ovl_En_Bee/z_en_bee.h b/src/overlays/actors/ovl_En_Bee/z_en_bee.h index 8a5be7de3..1676a5507 100644 --- a/src/overlays/actors/ovl_En_Bee/z_en_bee.h +++ b/src/overlays/actors/ovl_En_Bee/z_en_bee.h @@ -5,13 +5,13 @@ struct EnBee; -typedef void (*EnBeeActionFunc)(struct EnBee*, GlobalContext*); +typedef void (*EnBeeActionFunc)(struct EnBee*, PlayState*); typedef struct EnBee { - /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0xBC]; - /* 0x0200 */ EnBeeActionFunc actionFunc; - /* 0x0204 */ char unk_204[0x84]; + /* 0x000 */ Actor actor; + /* 0x144 */ char unk_144[0xBC]; + /* 0x200 */ EnBeeActionFunc actionFunc; + /* 0x204 */ char unk_204[0x84]; } EnBee; // size = 0x288 extern const ActorInit En_Bee_InitVars; diff --git a/src/overlays/actors/ovl_En_Bh/z_en_bh.c b/src/overlays/actors/ovl_En_Bh/z_en_bh.c index ff6cb047d..b18bedfc9 100644 --- a/src/overlays/actors/ovl_En_Bh/z_en_bh.c +++ b/src/overlays/actors/ovl_En_Bh/z_en_bh.c @@ -10,12 +10,13 @@ #define THIS ((EnBh*)thisx) -void EnBh_Init(Actor* thisx, GlobalContext* globalCtx); -void EnBh_Destroy(Actor* thisx, GlobalContext* globalCtx); -void EnBh_Update(Actor* thisx, GlobalContext* globalCtx); -void EnBh_Draw(Actor* thisx, GlobalContext* globalCtx); +void EnBh_Init(Actor* thisx, PlayState* play); +void EnBh_Destroy(Actor* thisx, PlayState* play); +void EnBh_Update(Actor* thisx, PlayState* play); +void EnBh_Draw(Actor* thisx, PlayState* play); + +void func_80C22DEC(EnBh* this, PlayState* play); -#if 0 const ActorInit En_Bh_InitVars = { ACTOR_EN_BH, ACTORCAT_ITEMACTION, @@ -28,16 +29,93 @@ const ActorInit En_Bh_InitVars = { (ActorFunc)EnBh_Draw, }; -#endif +void EnBh_Init(Actor* thisx, PlayState* play) { + EnBh* this = THIS; -extern UNK_TYPE D_06000074; + this->actor.flags &= ~ACTOR_FLAG_1; + Actor_SetScale(&this->actor, 0.01f); + SkelAnime_InitFlex(play, &this->skelanime, &gBhSkel, &gBhFlyingAnim, this->jointTable, this->morphTable, + OBJECT_BH_LIMB_MAX); + Animation_PlayLoop(&this->skelanime, &gBhFlyingAnim); + this->actionFunc = func_80C22DEC; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bh/EnBh_Init.s") +void EnBh_Destroy(Actor* thisx, PlayState* play) { +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bh/EnBh_Destroy.s") +void func_80C22DEC(EnBh* this, PlayState* play) { + f32 xDiff; + f32 yDiff; + f32 zDiff; + f32 xzDist; + s16 xRot; + s16 yRot; + s16 zRot; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bh/func_80C22DEC.s") + this->actor.speedXZ = 3.0f; + xDiff = this->pos.x - this->actor.world.pos.x; + yDiff = this->pos.y - this->actor.world.pos.y; + zDiff = this->pos.z - this->actor.world.pos.z; + xzDist = sqrtf(SQ(xDiff) + SQ(zDiff)); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bh/EnBh_Update.s") + if ((this->timer2 == 0) || (xzDist < 100.0f)) { + this->pos.x = randPlusMinusPoint5Scaled(300.0f) + this->actor.home.pos.x; + this->pos.y = randPlusMinusPoint5Scaled(100.0f) + this->actor.home.pos.y; + this->pos.z = randPlusMinusPoint5Scaled(300.0f) + this->actor.home.pos.z; + this->timer2 = Rand_ZeroFloat(50.0f) + 30.0f; + this->step = 0; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bh/EnBh_Draw.s") + yRot = Math_Atan2S(xDiff, zDiff); + xRot = Math_Atan2S(yDiff, xzDist); + zRot = Math_SmoothStepToS(&this->actor.world.rot.y, yRot, 0xA, this->step, 0); + + if (zRot > 0x1000) { + zRot = 0x1000; + } else if (zRot < -0x1000) { + zRot = -0x1000; + } + + Math_ApproachS(&this->actor.world.rot.x, xRot, 0xA, this->step); + Math_ApproachS(&this->actor.world.rot.z, -zRot, 0xA, this->step); + Math_ApproachS(&this->step, 0x200, 1, 0x10); + + if ((s32)this->skelanime.playSpeed == 0) { + if (this->timer == 0) { + this->skelanime.playSpeed = 1.0f; + this->timer = Rand_ZeroFloat(70.0f) + 50.0f; + } else if (((this->timer & 7) == 7) && (Rand_ZeroOne() < 0.5f)) { + this->unk1E4 = randPlusMinusPoint5Scaled(3000.0f); + } + } else { + SkelAnime_Update(&this->skelanime); + if ((this->timer == 0) && (Animation_OnFrame(&this->skelanime, 6.0f))) { + this->skelanime.playSpeed = 0.0f; + this->timer = Rand_ZeroFloat(50.0f) + 50.0f; + } + } + + this->actor.shape.rot.x = -this->actor.world.rot.x; + this->actor.shape.rot.y = this->actor.world.rot.y; + this->actor.shape.rot.z = this->actor.world.rot.z; + Math_ApproachS(&this->unk1E2, this->unk1E4, 3, 0x3E8); +} + +void EnBh_Update(Actor* thisx, PlayState* play) { + EnBh* this = THIS; + + Actor_MoveWithoutGravity(&this->actor); + DECR(this->timer2); + DECR(this->timer); + this->actionFunc(this, play); + Math_Vec3f_Copy(&this->actor.focus.pos, &this->actor.world.pos); +} + +void EnBh_Draw(Actor* thisx, PlayState* play) { + EnBh* this = THIS; + + func_8012C28C(play->state.gfxCtx); + Matrix_RotateZS(this->unk1E2, MTXMODE_APPLY); + SkelAnime_DrawFlexOpa(play, this->skelanime.skeleton, this->skelanime.jointTable, this->skelanime.dListCount, NULL, + NULL, &this->actor); +} diff --git a/src/overlays/actors/ovl_En_Bh/z_en_bh.h b/src/overlays/actors/ovl_En_Bh/z_en_bh.h index 54723bfa7..b5e8a7c0c 100644 --- a/src/overlays/actors/ovl_En_Bh/z_en_bh.h +++ b/src/overlays/actors/ovl_En_Bh/z_en_bh.h @@ -2,15 +2,24 @@ #define Z_EN_BH_H #include "global.h" +#include "objects/object_bh/object_bh.h" struct EnBh; -typedef void (*EnBhActionFunc)(struct EnBh*, GlobalContext*); +typedef void (*EnBhActionFunc)(struct EnBh*, PlayState*); typedef struct EnBh { - /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0xA4]; - /* 0x01E8 */ EnBhActionFunc actionFunc; + /* 0x000 */ Actor actor; + /* 0x144 */ SkelAnime skelanime; + /* 0x188 */ Vec3s jointTable[OBJECT_BH_LIMB_MAX]; + /* 0x1AC */ Vec3s morphTable[OBJECT_BH_LIMB_MAX]; + /* 0x1D0 */ Vec3f pos; + /* 0x1DC */ s16 timer; + /* 0x1DE */ s16 timer2; + /* 0x1E0 */ s16 step; + /* 0x1E2 */ s16 unk1E2; + /* 0x1E4 */ s16 unk1E4; + /* 0x1E8 */ EnBhActionFunc actionFunc; } EnBh; // size = 0x1EC extern const ActorInit En_Bh_InitVars; diff --git a/src/overlays/actors/ovl_En_Bigokuta/z_en_bigokuta.c b/src/overlays/actors/ovl_En_Bigokuta/z_en_bigokuta.c index 8431d6706..bb3f28bee 100644 --- a/src/overlays/actors/ovl_En_Bigokuta/z_en_bigokuta.c +++ b/src/overlays/actors/ovl_En_Bigokuta/z_en_bigokuta.c @@ -5,31 +5,30 @@ */ #include "z_en_bigokuta.h" -#include "assets/objects/object_bigokuta/object_bigokuta.h" #define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_4) #define THIS ((EnBigokuta*)thisx) -void EnBigokuta_Init(Actor* thisx, GlobalContext* globalCtx); -void EnBigokuta_Destroy(Actor* thisx, GlobalContext* globalCtx); -void EnBigokuta_Update(Actor* thisx, GlobalContext* globalCtx); -void EnBigokuta_Draw(Actor* thisx, GlobalContext* globalCtx); +void EnBigokuta_Init(Actor* thisx, PlayState* play); +void EnBigokuta_Destroy(Actor* thisx, PlayState* play); +void EnBigokuta_Update(Actor* thisx, PlayState* play); +void EnBigokuta_Draw(Actor* thisx, PlayState* play); -void func_80AC2B4C(GlobalContext* globalCtx, EnBigokuta* this); +s32 EnBigokuta_ValidatePictograph(PlayState* play, Actor* thisx); void EnBigokuta_SetupIdle(EnBigokuta* this); -void EnBigokuta_Idle(EnBigokuta* this, GlobalContext* globalCtx); -void EnBigokuta_SetupRise(EnBigokuta* this, GlobalContext* globalCtx); -void EnBigokuta_RiseOutOfWater(EnBigokuta* this, GlobalContext* globalCtx); +void EnBigokuta_Idle(EnBigokuta* this, PlayState* play); +void EnBigokuta_SetupRise(EnBigokuta* this, PlayState* play); +void EnBigokuta_RiseOutOfWater(EnBigokuta* this, PlayState* play); void EnBigokuta_SetupIdleAboveWater(EnBigokuta* this); -void EnBigokuta_IdleAboveWater(EnBigokuta* this, GlobalContext* globalCtx); -void EnBigokuta_SetupSuckInPlayer(EnBigokuta* this, GlobalContext* globalCtx); -void EnBigokuta_SuckInPlayer(EnBigokuta* this, GlobalContext* globalCtx); +void EnBigokuta_IdleAboveWater(EnBigokuta* this, PlayState* play); +void EnBigokuta_SetupSuckInPlayer(EnBigokuta* this, PlayState* play); +void EnBigokuta_SuckInPlayer(EnBigokuta* this, PlayState* play); void EnBigokuta_SetupHoldPlayer(EnBigokuta* this); -void EnBigokuta_HoldPlayer(EnBigokuta* this, GlobalContext* globalCtx); -void EnBigokuta_PlayDeathCutscene(EnBigokuta* this, GlobalContext* globalCtx); +void EnBigokuta_HoldPlayer(EnBigokuta* this, PlayState* play); +void EnBigokuta_PlayDeathCutscene(EnBigokuta* this, PlayState* play); void EnBigokuta_SetupDeathEffects(EnBigokuta* this); -void EnBigokuta_PlayDeathEffects(EnBigokuta* this, GlobalContext* globalCtx); +void EnBigokuta_PlayDeathEffects(EnBigokuta* this, PlayState* play); const ActorInit En_Bigokuta_InitVars = { ACTOR_EN_BIGOKUTA, @@ -93,155 +92,157 @@ static InitChainEntry sInitChain[] = { ICHAIN_VEC3F_DIV1000(scale, 33, ICHAIN_STOP), }; -void EnBigokuta_Init(Actor* thisx, GlobalContext* globalCtx) { +void EnBigokuta_Init(Actor* thisx, PlayState* play) { EnBigokuta* this = THIS; - Actor_ProcessInitChain(&this->actor, sInitChain); - SkelAnime_InitFlex(globalCtx, &this->skelAnime, &gBigOctoSkel, &gBigOctoIdleAnim, this->jointTable, - this->morphTable, BIGOKUTA_LIMB_MAX); + Actor_ProcessInitChain(&this->picto.actor, sInitChain); + SkelAnime_InitFlex(play, &this->skelAnime, &gBigOctoSkel, &gBigOctoIdleAnim, this->jointTable, this->morphTable, + BIGOKUTA_LIMB_MAX); - Collider_InitAndSetCylinder(globalCtx, &this->shellCollider, &this->actor, &sShellCylinderInit); - Collider_InitAndSetCylinder(globalCtx, &this->bodyCollider, &this->actor, &sBodyCylinderInit); - CollisionCheck_SetInfo(&this->actor.colChkInfo, NULL, &sColChkInfoInit); - this->cutscene = ActorCutscene_GetAdditionalCutscene(this->actor.cutscene); + Collider_InitAndSetCylinder(play, &this->shellCollider, &this->picto.actor, &sShellCylinderInit); + Collider_InitAndSetCylinder(play, &this->bodyCollider, &this->picto.actor, &sBodyCylinderInit); + CollisionCheck_SetInfo(&this->picto.actor.colChkInfo, NULL, &sColChkInfoInit); + this->cutscene = ActorCutscene_GetAdditionalCutscene(this->picto.actor.cutscene); if (gSaveContext.save.weekEventReg[20] & 2 || - ((this->actor.params != 0xFF) && Flags_GetSwitch(globalCtx, this->actor.params))) { - Actor_MarkForDeath(&this->actor); + ((this->picto.actor.params != 0xFF) && Flags_GetSwitch(play, this->picto.actor.params))) { + Actor_MarkForDeath(&this->picto.actor); } else { - this->actor.world.pos.y -= 99.0f; + this->picto.actor.world.pos.y -= 99.0f; EnBigokuta_SetupIdle(this); } - this->camAt.x = (Math_SinS(this->actor.home.rot.y) * 66.0f) + this->actor.world.pos.x; - this->camAt.y = (this->actor.home.pos.y - 49.5f) + 42.899998f; - this->camAt.z = (Math_CosS(this->actor.home.rot.y) * 66.0f) + this->actor.world.pos.z; + this->subCamAt.x = (Math_SinS(this->picto.actor.home.rot.y) * 66.0f) + this->picto.actor.world.pos.x; + this->subCamAt.y = (this->picto.actor.home.pos.y - 49.5f) + 42.899998f; + this->subCamAt.z = (Math_CosS(this->picto.actor.home.rot.y) * 66.0f) + this->picto.actor.world.pos.z; - this->unkFunc = func_80AC2B4C; // set but never called + this->picto.validationFunc = EnBigokuta_ValidatePictograph; } -void EnBigokuta_Destroy(Actor* thisx, GlobalContext* globalCtx) { +void EnBigokuta_Destroy(Actor* thisx, PlayState* play) { EnBigokuta* this = THIS; - Collider_DestroyCylinder(globalCtx, &this->shellCollider); - Collider_DestroyCylinder(globalCtx, &this->bodyCollider); + Collider_DestroyCylinder(play, &this->shellCollider); + Collider_DestroyCylinder(play, &this->bodyCollider); } -void EnBigokuta_SetupCutsceneCamera(EnBigokuta* this, GlobalContext* globalCtx, Vec3f* at, Vec3f* eye) { +void EnBigokuta_SetupCutsceneCamera(EnBigokuta* this, PlayState* play, Vec3f* subCamAt, Vec3f* subCamEye) { s16 angle; - ActorCutscene_Start(this->actor.cutscene, &this->actor); - this->camId = ActorCutscene_GetCurrentCamera(this->actor.cutscene); - Play_CameraSetAtEye(globalCtx, this->camId, at, eye); + ActorCutscene_Start(this->picto.actor.cutscene, &this->picto.actor); + this->subCamId = ActorCutscene_GetCurrentSubCamId(this->picto.actor.cutscene); + Play_SetCameraAtEye(play, this->subCamId, subCamAt, subCamEye); - angle = BINANG_SUB(Actor_YawToPoint(&this->actor, eye), this->actor.home.rot.y); + angle = BINANG_SUB(Actor_YawToPoint(&this->picto.actor, subCamEye), this->picto.actor.home.rot.y); if (angle > 0) { - angle = BINANG_ADD(this->actor.home.rot.y, 0x1800); + angle = BINANG_ADD(this->picto.actor.home.rot.y, 0x1800); } else { - angle = BINANG_SUB(this->actor.home.rot.y, 0x1800); + angle = BINANG_SUB(this->picto.actor.home.rot.y, 0x1800); } - this->camEye.x = (Math_SinS(angle) * 250.0f) + this->camAt.x; - this->camEye.y = this->camAt.y + 100.0f; - this->camEye.z = (Math_CosS(angle) * 250.0f) + this->camAt.z; + this->subCamEye.x = (Math_SinS(angle) * 250.0f) + this->subCamAt.x; + this->subCamEye.y = this->subCamAt.y + 100.0f; + this->subCamEye.z = (Math_CosS(angle) * 250.0f) + this->subCamAt.z; } -void EnBigokuta_MoveCamera(EnBigokuta* this, GlobalContext* globalCtx) { - Camera* camera = Play_GetCamera(globalCtx, this->camId); +void EnBigokuta_MoveCamera(EnBigokuta* this, PlayState* play) { + Camera* subCam = Play_GetCamera(play, this->subCamId); - Math_Vec3f_StepTo(&camera->eye, &this->camEye, 20.0f); - Math_Vec3f_StepTo(&camera->at, &this->camAt, 20.0f); - Play_CameraSetAtEye(globalCtx, this->camId, &camera->at, &camera->eye); + Math_Vec3f_StepTo(&subCam->eye, &this->subCamEye, 20.0f); + Math_Vec3f_StepTo(&subCam->at, &this->subCamAt, 20.0f); + Play_SetCameraAtEye(play, this->subCamId, &subCam->at, &subCam->eye); } -void EnBigokuta_ResetCamera(EnBigokuta* this, GlobalContext* globalCtx) { - Camera* camera; +void EnBigokuta_ResetCamera(EnBigokuta* this, PlayState* play) { + Camera* subCam; - if (this->camId != 0) { - camera = Play_GetCamera(globalCtx, this->camId); - Play_CameraSetAtEye(globalCtx, 0, &camera->at, &camera->eye); - this->camId = 0; - ActorCutscene_Stop(this->actor.cutscene); + if (this->subCamId != SUB_CAM_ID_DONE) { + subCam = Play_GetCamera(play, this->subCamId); + Play_SetCameraAtEye(play, CAM_ID_MAIN, &subCam->at, &subCam->eye); + this->subCamId = SUB_CAM_ID_DONE; + ActorCutscene_Stop(this->picto.actor.cutscene); } } -void EnBigokuta_ShootPlayer(EnBigokuta* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); +void EnBigokuta_ShootPlayer(EnBigokuta* this, PlayState* play) { + Player* player = GET_PLAYER(play); - if (&this->actor == player->actor.parent) { + if (&this->picto.actor == player->actor.parent) { player->actor.parent = NULL; player->unk_AE8 = 100; player->actor.velocity.y = 0.0f; - player->actor.world.pos.x += 20.0f * Math_SinS(this->actor.home.rot.y); - player->actor.world.pos.z += 20.0f * Math_CosS(this->actor.home.rot.y); - func_800B8D50(globalCtx, &this->actor, 10.0f, this->actor.home.rot.y, 10.0f, 4); + player->actor.world.pos.x += 20.0f * Math_SinS(this->picto.actor.home.rot.y); + player->actor.world.pos.z += 20.0f * Math_CosS(this->picto.actor.home.rot.y); + func_800B8D50(play, &this->picto.actor, 10.0f, this->picto.actor.home.rot.y, 10.0f, 4); } - EnBigokuta_ResetCamera(this, globalCtx); + EnBigokuta_ResetCamera(this, play); } -void func_80AC2B4C(GlobalContext* globalCtx, EnBigokuta* this) { - func_8013A530(globalCtx, &this->actor, 3, &this->actor.focus.pos, &this->actor.shape.rot, 280.0f, 1800.0f, -1); +s32 EnBigokuta_ValidatePictograph(PlayState* play, Actor* thisx) { + return Snap_ValidatePictograph(play, thisx, PICTOGRAPH_BIG_OCTO, &thisx->focus.pos, &thisx->shape.rot, 280.0f, + 1800.0f, -1); } -s32 EnBigokuta_IsInWater(EnBigokuta* this, GlobalContext* globalCtx) { +s32 EnBigokuta_IsInWater(EnBigokuta* this, PlayState* play) { WaterBox* box; s32 bgId; - this->actor.floorHeight = BgCheck_EntityRaycastFloor5(&globalCtx->colCtx, &this->actor.floorPoly, &bgId, - &this->actor, &this->actor.world.pos); - if (!WaterBox_GetSurface1_2(globalCtx, &globalCtx->colCtx, this->actor.world.pos.x, this->actor.world.pos.z, - &this->actor.home.pos.y, &box) || - (this->actor.home.pos.y <= this->actor.floorHeight)) { + this->picto.actor.floorHeight = BgCheck_EntityRaycastFloor5(&play->colCtx, &this->picto.actor.floorPoly, &bgId, + &this->picto.actor, &this->picto.actor.world.pos); + if (!WaterBox_GetSurface1_2(play, &play->colCtx, this->picto.actor.world.pos.x, this->picto.actor.world.pos.z, + &this->picto.actor.home.pos.y, &box) || + (this->picto.actor.home.pos.y <= this->picto.actor.floorHeight)) { return false; } else { return true; } } -void EnBigokuta_SpawnRipple(EnBigokuta* this, GlobalContext* globalCtx) { +void EnBigokuta_SpawnRipple(EnBigokuta* this, PlayState* play) { Vec3f ripplePos; - ripplePos.x = this->actor.world.pos.x; - ripplePos.y = this->actor.home.pos.y; - ripplePos.z = this->actor.world.pos.z; - EffectSsGRipple_Spawn(globalCtx, &ripplePos, 1000, 1400, 0); + ripplePos.x = this->picto.actor.world.pos.x; + ripplePos.y = this->picto.actor.home.pos.y; + ripplePos.z = this->picto.actor.world.pos.z; + EffectSsGRipple_Spawn(play, &ripplePos, 1000, 1400, 0); } void EnBigokuta_SetupIdle(EnBigokuta* this) { - Animation_Change(&this->skelAnime, &gBigOctoIdleAnim, 0.5f, 0.0f, 0.0f, 1, -3.0f); + Animation_Change(&this->skelAnime, &gBigOctoIdleAnim, 0.5f, 0.0f, 0.0f, ANIMMODE_LOOP_INTERP, -3.0f); this->actionFunc = EnBigokuta_Idle; } -void EnBigokuta_Idle(EnBigokuta* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); +void EnBigokuta_Idle(EnBigokuta* this, PlayState* play) { + Player* player = GET_PLAYER(play); SkelAnime_Update(&this->skelAnime); - Math_StepToF(&this->actor.world.pos.y, this->actor.home.pos.y - 99.0f, 2.5f); - Math_ApproachS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer, 5, 0x1000); - if ((this->actor.xzDistToPlayer < 300.0f) && ((player->actor.world.pos.y - this->actor.home.pos.y) < 100.0f)) { - EnBigokuta_SetupRise(this, globalCtx); + Math_StepToF(&this->picto.actor.world.pos.y, this->picto.actor.home.pos.y - 99.0f, 2.5f); + Math_ApproachS(&this->picto.actor.shape.rot.y, this->picto.actor.yawTowardsPlayer, 5, 0x1000); + if ((this->picto.actor.xzDistToPlayer < 300.0f) && + ((player->actor.world.pos.y - this->picto.actor.home.pos.y) < 100.0f)) { + EnBigokuta_SetupRise(this, play); } } -void EnBigokuta_SetupRise(EnBigokuta* this, GlobalContext* globalCtx) { +void EnBigokuta_SetupRise(EnBigokuta* this, PlayState* play) { Vec3f splashPos; s32 i; s16 angle = 0; Animation_PlayOnce(&this->skelAnime, &gBigOctoRiseOutOfWaterAnim); - splashPos.y = this->actor.home.pos.y; + splashPos.y = this->picto.actor.home.pos.y; for (i = 0; i < 8; i++) { - splashPos.x = Math_SinS(angle) * 70.0f + this->actor.world.pos.x; - splashPos.z = Math_CosS(angle) * 70.0f + this->actor.world.pos.z; - EffectSsGSplash_Spawn(globalCtx, &splashPos, NULL, NULL, 0, Rand_S16Offset(1000, 200)); + splashPos.x = Math_SinS(angle) * 70.0f + this->picto.actor.world.pos.x; + splashPos.z = Math_CosS(angle) * 70.0f + this->picto.actor.world.pos.z; + EffectSsGSplash_Spawn(play, &splashPos, NULL, NULL, 0, Rand_S16Offset(1000, 200)); angle = BINANG_ADD(angle, 0x2000); } - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_DAIOCTA_LAND); + Actor_PlaySfxAtPos(&this->picto.actor, NA_SE_EN_DAIOCTA_LAND); this->actionFunc = EnBigokuta_RiseOutOfWater; } -void EnBigokuta_RiseOutOfWater(EnBigokuta* this, GlobalContext* globalCtx) { - Math_StepToF(&this->actor.world.pos.y, this->actor.home.pos.y - 16.5f, 15.0f); +void EnBigokuta_RiseOutOfWater(EnBigokuta* this, PlayState* play) { + Math_StepToF(&this->picto.actor.world.pos.y, this->picto.actor.home.pos.y - 16.5f, 15.0f); if (SkelAnime_Update(&this->skelAnime)) { EnBigokuta_SetupIdleAboveWater(this); } @@ -252,58 +253,58 @@ void EnBigokuta_SetupIdleAboveWater(EnBigokuta* this) { this->actionFunc = EnBigokuta_IdleAboveWater; } -void EnBigokuta_IdleAboveWater(EnBigokuta* this, GlobalContext* globalCtx) { +void EnBigokuta_IdleAboveWater(EnBigokuta* this, PlayState* play) { SkelAnime_Update(&this->skelAnime); - Math_StepToF(&this->actor.world.pos.y, this->actor.home.pos.y - 16.5f, 2.5f); - Math_ApproachS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer, 5, 0x1000); + Math_StepToF(&this->picto.actor.world.pos.y, this->picto.actor.home.pos.y - 16.5f, 2.5f); + Math_ApproachS(&this->picto.actor.shape.rot.y, this->picto.actor.yawTowardsPlayer, 5, 0x1000); - if ((this->actor.xzDistToPlayer > 400.0f) || (this->actor.playerHeightRel > 200.0f)) { - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_DAIOCTA_SINK); + if ((this->picto.actor.xzDistToPlayer > 400.0f) || (this->picto.actor.playerHeightRel > 200.0f)) { + Actor_PlaySfxAtPos(&this->picto.actor, NA_SE_EN_DAIOCTA_SINK); EnBigokuta_SetupIdle(this); - } else if ((this->actor.xzDistToPlayer < 200.0f) && globalCtx->grabPlayer(globalCtx, GET_PLAYER(globalCtx))) { - EnBigokuta_SetupSuckInPlayer(this, globalCtx); + } else if ((this->picto.actor.xzDistToPlayer < 200.0f) && play->grabPlayer(play, GET_PLAYER(play))) { + EnBigokuta_SetupSuckInPlayer(this, play); } } -void EnBigokuta_UpdateOrSetupCam(EnBigokuta* this, GlobalContext* globalCtx) { - if (this->actor.cutscene != -1) { - if (this->camId != 0) { - EnBigokuta_MoveCamera(this, globalCtx); - } else if (ActorCutscene_GetCanPlayNext(this->actor.cutscene)) { - Camera* camera = Play_GetCamera(globalCtx, 0); +void EnBigokuta_UpdateOrSetupCam(EnBigokuta* this, PlayState* play) { + if (this->picto.actor.cutscene != -1) { + if (this->subCamId != SUB_CAM_ID_DONE) { + EnBigokuta_MoveCamera(this, play); + } else if (ActorCutscene_GetCanPlayNext(this->picto.actor.cutscene)) { + Camera* mainCam = Play_GetCamera(play, CAM_ID_MAIN); - EnBigokuta_SetupCutsceneCamera(this, globalCtx, &camera->at, &camera->eye); + EnBigokuta_SetupCutsceneCamera(this, play, &mainCam->at, &mainCam->eye); } else { - ActorCutscene_SetIntentToPlay(this->actor.cutscene); + ActorCutscene_SetIntentToPlay(this->picto.actor.cutscene); } } } -void EnBigokuta_SetupSuckInPlayer(EnBigokuta* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); +void EnBigokuta_SetupSuckInPlayer(EnBigokuta* this, PlayState* play) { + Player* player = GET_PLAYER(play); - player->actor.parent = &this->actor; - this->actor.shape.rot.y = this->actor.yawTowardsPlayer; + player->actor.parent = &this->picto.actor; + this->picto.actor.shape.rot.y = this->picto.actor.yawTowardsPlayer; Math_Vec3f_Copy(&this->playerPos, &player->actor.world.pos); this->timer = 0; - Animation_Change(&this->skelAnime, &gBigOctoIdleAnim, 1.0f, 12.0f, 12.0f, 2, -3.0f); - ActorCutscene_SetIntentToPlay(this->actor.cutscene); + Animation_Change(&this->skelAnime, &gBigOctoIdleAnim, 1.0f, 12.0f, 12.0f, ANIMMODE_ONCE, -3.0f); + ActorCutscene_SetIntentToPlay(this->picto.actor.cutscene); - this->playerHoldPos.x = (Math_SinS(this->actor.shape.rot.y) * 66.0f) + this->actor.world.pos.x; - this->playerHoldPos.y = (this->actor.home.pos.y - 49.5f) + 42.899998f; - this->playerHoldPos.z = (Math_CosS(this->actor.shape.rot.y) * 66.0f) + this->actor.world.pos.z; + this->playerHoldPos.x = (Math_SinS(this->picto.actor.shape.rot.y) * 66.0f) + this->picto.actor.world.pos.x; + this->playerHoldPos.y = (this->picto.actor.home.pos.y - 49.5f) + 42.899998f; + this->playerHoldPos.z = (Math_CosS(this->picto.actor.shape.rot.y) * 66.0f) + this->picto.actor.world.pos.z; - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_SLIME_DEAD); + Actor_PlaySfxAtPos(&this->picto.actor, NA_SE_EN_SLIME_DEAD); this->actionFunc = EnBigokuta_SuckInPlayer; } -void EnBigokuta_SuckInPlayer(EnBigokuta* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); +void EnBigokuta_SuckInPlayer(EnBigokuta* this, PlayState* play) { + Player* player = GET_PLAYER(play); - EnBigokuta_UpdateOrSetupCam(this, globalCtx); + EnBigokuta_UpdateOrSetupCam(this, play); SkelAnime_Update(&this->skelAnime); - Math_StepToF(&this->actor.world.pos.y, this->actor.home.pos.y - 49.5f, 10.0f); + Math_StepToF(&this->picto.actor.world.pos.y, this->picto.actor.home.pos.y - 49.5f, 10.0f); if (this->timer < 9) { this->timer++; @@ -312,19 +313,19 @@ void EnBigokuta_SuckInPlayer(EnBigokuta* this, GlobalContext* globalCtx) { player->unk_AE8 = 0; Math_Vec3f_Copy(&player->actor.world.pos, &this->playerPos); if (Math_Vec3f_StepTo(&player->actor.world.pos, &this->playerHoldPos, sqrtf(this->timer) * 5.0f) < 0.1f) { - s16 rotY = this->actor.shape.rot.y; + s16 rotY = this->picto.actor.shape.rot.y; - if (Math_ScaledStepToS(&this->actor.shape.rot.y, this->actor.home.rot.y, 0x800)) { + if (Math_ScaledStepToS(&this->picto.actor.shape.rot.y, this->picto.actor.home.rot.y, 0x800)) { EnBigokuta_SetupHoldPlayer(this); } - this->playerHoldPos.x = (Math_SinS(this->actor.shape.rot.y) * 66.0f) + this->actor.world.pos.x; - this->playerHoldPos.y = (this->actor.home.pos.y - 49.5f) + 42.899998f; - this->playerHoldPos.z = (Math_CosS(this->actor.shape.rot.y) * 66.0f) + this->actor.world.pos.z; + this->playerHoldPos.x = (Math_SinS(this->picto.actor.shape.rot.y) * 66.0f) + this->picto.actor.world.pos.x; + this->playerHoldPos.y = (this->picto.actor.home.pos.y - 49.5f) + 42.899998f; + this->playerHoldPos.z = (Math_CosS(this->picto.actor.shape.rot.y) * 66.0f) + this->picto.actor.world.pos.z; Math_Vec3f_Copy(&player->actor.world.pos, &this->playerHoldPos); Math_Vec3f_Copy(&this->playerPos, &player->actor.world.pos); - player->actor.shape.rot.y += BINANG_SUB(this->actor.shape.rot.y, rotY); + player->actor.shape.rot.y += BINANG_SUB(this->picto.actor.shape.rot.y, rotY); } else { Math_Vec3f_Copy(&this->playerPos, &player->actor.world.pos); player->actor.velocity.y = 0.0f; @@ -336,17 +337,17 @@ void EnBigokuta_SetupHoldPlayer(EnBigokuta* this) { this->actionFunc = EnBigokuta_HoldPlayer; } -void EnBigokuta_HoldPlayer(EnBigokuta* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); +void EnBigokuta_HoldPlayer(EnBigokuta* this, PlayState* play) { + Player* player = GET_PLAYER(play); this->timer--; if (this->timer >= 0) { - EnBigokuta_UpdateOrSetupCam(this, globalCtx); + EnBigokuta_UpdateOrSetupCam(this, play); Math_Vec3f_Copy(&player->actor.world.pos, &this->playerHoldPos); if (this->timer == 0) { - EnBigokuta_ShootPlayer(this, globalCtx); - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_DAIOCTA_REVERSE); + EnBigokuta_ShootPlayer(this, play); + Actor_PlaySfxAtPos(&this->picto.actor, NA_SE_EN_DAIOCTA_REVERSE); } } else if (this->timer == -24) { EnBigokuta_SetupIdleAboveWater(this); @@ -360,26 +361,26 @@ void EnBigokuta_SetupDeathCutscene(EnBigokuta* this) { this->actionFunc = EnBigokuta_PlayDeathCutscene; } -void EnBigokuta_PlayDeathCutscene(EnBigokuta* this, GlobalContext* globalCtx) { +void EnBigokuta_PlayDeathCutscene(EnBigokuta* this, PlayState* play) { Player* player; - this->actor.colorFilterTimer = Animation_GetLastFrame(&gBigOctoDeathAnim); + this->picto.actor.colorFilterTimer = Animation_GetLastFrame(&gBigOctoDeathAnim); if (this->timer != 0) { this->timer--; if (this->timer == 0) { 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); + Actor_SpawnIceEffects(play, &this->picto.actor, this->limbPos, ARRAY_COUNT(this->limbPos), 2, 0.5f, 0.35f); EnBigokuta_SetupDeathEffects(this); } } else if (ActorCutscene_GetCanPlayNext(this->cutscene)) { - ActorCutscene_Start(this->cutscene, &this->actor); + ActorCutscene_Start(this->cutscene, &this->picto.actor); if (!(gSaveContext.eventInf[4] & 2) && !(gSaveContext.eventInf[3] & 0x20)) { - func_800B724C(globalCtx, &this->actor, 7); + func_800B724C(play, &this->picto.actor, 7); } else { - player = GET_PLAYER(globalCtx); + player = GET_PLAYER(play); player->stateFlags1 |= 0x20; } @@ -395,20 +396,20 @@ void EnBigokuta_PlayDeathCutscene(EnBigokuta* this, GlobalContext* globalCtx) { void EnBigokuta_SetupDeathEffects(EnBigokuta* this) { Animation_MorphToPlayOnce(&this->skelAnime, &gBigOctoDeathAnim, -5.0f); - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_DAIOCTA_DEAD2); - this->actor.flags &= ~1; + Actor_PlaySfxAtPos(&this->picto.actor, NA_SE_EN_DAIOCTA_DEAD2); + this->picto.actor.flags &= ~1; this->timer = 10; this->actionFunc = EnBigokuta_PlayDeathEffects; } -void EnBigokuta_PlayDeathEffects(EnBigokuta* this, GlobalContext* globalCtx) { +void EnBigokuta_PlayDeathEffects(EnBigokuta* this, PlayState* play) { static Vec3f D_80AC45A4 = { 0.0f, -0.5f, 0.0f }; static Color_RGBA8 D_80AC45B0 = { 255, 255, 255, 255 }; static Color_RGBA8 D_80AC45B4 = { 100, 255, 255, 255 }; static Color_RGBA8 D_80AC45B8 = { 150, 150, 150, 0 }; if (SkelAnime_Update(&this->skelAnime)) { - this->actor.world.pos.y -= 0.2f; + this->picto.actor.world.pos.y -= 0.2f; if (this->timer > 0) { this->timer--; @@ -416,76 +417,77 @@ void EnBigokuta_PlayDeathEffects(EnBigokuta* this, GlobalContext* globalCtx) { if (this->timer == 6) { Vec3f dustPos; - dustPos.x = this->actor.world.pos.x; - dustPos.y = this->actor.world.pos.y + 150.0f; - dustPos.z = this->actor.world.pos.z; + dustPos.x = this->picto.actor.world.pos.x; + dustPos.y = this->picto.actor.world.pos.y + 150.0f; + dustPos.z = this->picto.actor.world.pos.z; - func_800B0DE0(globalCtx, &dustPos, &gZeroVec3f, &gZeroVec3f, &D_80AC45B0, &D_80AC45B4, 1200, 20); - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_OCTAROCK_DEAD2); + func_800B0DE0(play, &dustPos, &gZeroVec3f, &gZeroVec3f, &D_80AC45B0, &D_80AC45B4, 1200, 20); + Actor_PlaySfxAtPos(&this->picto.actor, NA_SE_EN_OCTAROCK_DEAD2); } } else { - this->actor.world.pos.y -= 0.2f; + this->picto.actor.world.pos.y -= 0.2f; - if (Math_StepToF(&this->actor.scale.y, 0.001f, 0.001f)) { + if (Math_StepToF(&this->picto.actor.scale.y, 0.001f, 0.001f)) { s32 i; Vec3f bubbleVel; Vec3f bubblePos; - SoundSource_PlaySfxAtFixedWorldPos(globalCtx, &this->actor.world.pos, 50, NA_SE_EN_COMMON_WATER_MID); - bubblePos.y = this->actor.world.pos.y; + SoundSource_PlaySfxAtFixedWorldPos(play, &this->picto.actor.world.pos, 50, NA_SE_EN_COMMON_WATER_MID); + bubblePos.y = this->picto.actor.world.pos.y; for (i = 0; i < 20; i++) { bubbleVel.x = randPlusMinusPoint5Scaled(10.0f); bubbleVel.y = Rand_ZeroFloat(5.5f) + 5.5f; bubbleVel.z = randPlusMinusPoint5Scaled(10.0f); - bubblePos.x = this->actor.world.pos.x + (2.0f * bubbleVel.x); - bubblePos.z = this->actor.world.pos.z + (2.0f * bubbleVel.z); + bubblePos.x = this->picto.actor.world.pos.x + (2.0f * bubbleVel.x); + bubblePos.z = this->picto.actor.world.pos.z + (2.0f * bubbleVel.z); - EffectSsDtBubble_SpawnCustomColor(globalCtx, &bubblePos, &bubbleVel, &D_80AC45A4, &D_80AC45B0, + EffectSsDtBubble_SpawnCustomColor(play, &bubblePos, &bubbleVel, &D_80AC45A4, &D_80AC45B0, &D_80AC45B8, Rand_S16Offset(150, 50), 25, 0); } - if (this->actor.params != 0xFF) { - Flags_SetSwitch(globalCtx, this->actor.params); + if (this->picto.actor.params != 0xFF) { + Flags_SetSwitch(play, this->picto.actor.params); } ActorCutscene_Stop(this->cutscene); - Actor_MarkForDeath(&this->actor); + Actor_MarkForDeath(&this->picto.actor); if (!(gSaveContext.eventInf[4] & 2) && !(gSaveContext.eventInf[3] & 0x20)) { - func_800B724C(globalCtx, &this->actor, 6); + func_800B724C(play, &this->picto.actor, 6); } else { - Player* player = GET_PLAYER(globalCtx); + Player* player = GET_PLAYER(play); player->stateFlags1 &= ~0x20; } } if (this->drawDmgEffAlpha > 0.0f) { - this->drawDmgEffAlpha = this->actor.scale.y * 30.30303f; + this->drawDmgEffAlpha = this->picto.actor.scale.y * 30.30303f; } } } else { - Math_StepToF(&this->actor.world.pos.y, this->actor.home.pos.y - 16.5f, 15.0f); + Math_StepToF(&this->picto.actor.world.pos.y, this->picto.actor.home.pos.y - 16.5f, 15.0f); } } -s32 EnBigokuta_IsNearSwampBoat(EnBigokuta* this, GlobalContext* globalCtx) { - this->actor.child = SubS_FindActor(globalCtx, NULL, ACTORCAT_BG, ACTOR_BG_INGATE); +s32 EnBigokuta_IsNearSwampBoat(EnBigokuta* this, PlayState* play) { + this->picto.actor.child = SubS_FindActor(play, NULL, ACTORCAT_BG, ACTOR_BG_INGATE); - if ((this->actor.child != NULL) && (Actor_XZDistanceBetweenActors(&this->actor, this->actor.child) < 250.0f)) { + if ((this->picto.actor.child != NULL) && + (Actor_XZDistanceBetweenActors(&this->picto.actor, this->picto.actor.child) < 250.0f)) { return true; } else { return false; } } -void EnBigokuta_CheckOneHitKill(EnBigokuta* this, GlobalContext* globalCtx) { +void EnBigokuta_CheckOneHitKill(EnBigokuta* this, PlayState* play) { if ((this->bodyCollider.base.acFlags & AC_ON) && ((this->bodyCollider.base.acFlags & AC_HIT) || - ((globalCtx->sceneNum == SCENE_20SICHITAI || globalCtx->sceneNum == SCENE_20SICHITAI2) && - EnBigokuta_IsNearSwampBoat(this, globalCtx)))) { - Enemy_StartFinishingBlow(globalCtx, &this->actor); + ((play->sceneNum == SCENE_20SICHITAI || play->sceneNum == SCENE_20SICHITAI2) && + EnBigokuta_IsNearSwampBoat(this, play)))) { + Enemy_StartFinishingBlow(play, &this->picto.actor); if (this->bodyCollider.base.acFlags & AC_HIT) { if (this->bodyCollider.info.acHitInfo->toucher.dmgFlags & 0x1000) { // Ice Arrow @@ -497,48 +499,50 @@ void EnBigokuta_CheckOneHitKill(EnBigokuta* this, GlobalContext* globalCtx) { 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); + Actor_Spawn(&play->actorCtx, play, 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); } } this->bodyCollider.base.acFlags &= ~AC_HIT; - Actor_SetColorFilter(&this->actor, 0x4000, 255, 0, Animation_GetLastFrame(&gBigOctoDeathAnim)); - EnBigokuta_ShootPlayer(this, globalCtx); + Actor_SetColorFilter(&this->picto.actor, 0x4000, 255, 0, Animation_GetLastFrame(&gBigOctoDeathAnim)); + EnBigokuta_ShootPlayer(this, play); EnBigokuta_SetupDeathCutscene(this); } } -void EnBigokuta_Update(Actor* thisx, GlobalContext* globalCtx) { +void EnBigokuta_Update(Actor* thisx, PlayState* play) { s32 pad; EnBigokuta* this = THIS; - if (!EnBigokuta_IsInWater(this, globalCtx)) { - Actor_MarkForDeath(&this->actor); + if (!EnBigokuta_IsInWater(this, play)) { + Actor_MarkForDeath(&this->picto.actor); return; } - if (globalCtx->gameplayFrames % 7 == 0) { - EnBigokuta_SpawnRipple(this, globalCtx); + if (play->gameplayFrames % 7 == 0) { + EnBigokuta_SpawnRipple(this, play); } - EnBigokuta_CheckOneHitKill(this, globalCtx); - this->actionFunc(this, globalCtx); + EnBigokuta_CheckOneHitKill(this, play); + this->actionFunc(this, play); if ((this->bodyCollider.base.acFlags & AC_ON)) { - this->shellCollider.dim.pos.x = Math_SinS(this->actor.shape.rot.y) * -20.0f + this->actor.world.pos.x; - this->shellCollider.dim.pos.y = this->actor.world.pos.y; - this->shellCollider.dim.pos.z = Math_CosS(this->actor.shape.rot.y) * -20.0f + this->actor.world.pos.z; + this->shellCollider.dim.pos.x = + Math_SinS(this->picto.actor.shape.rot.y) * -20.0f + this->picto.actor.world.pos.x; + this->shellCollider.dim.pos.y = this->picto.actor.world.pos.y; + this->shellCollider.dim.pos.z = + Math_CosS(this->picto.actor.shape.rot.y) * -20.0f + this->picto.actor.world.pos.z; this->bodyCollider.dim.pos.x = this->shellCollider.dim.pos.x; this->bodyCollider.dim.pos.y = this->shellCollider.dim.pos.y; this->bodyCollider.dim.pos.z = this->shellCollider.dim.pos.z; - CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->bodyCollider.base); - CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->shellCollider.base); - CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->shellCollider.base); - Actor_SetFocus(&this->actor, 82.5f); + CollisionCheck_SetAC(play, &play->colChkCtx, &this->bodyCollider.base); + CollisionCheck_SetAC(play, &play->colChkCtx, &this->shellCollider.base); + CollisionCheck_SetOC(play, &play->colChkCtx, &this->shellCollider.base); + Actor_SetFocus(&this->picto.actor, 82.5f); } if (this->drawDmgEffAlpha > 0.0f) { @@ -547,13 +551,13 @@ void EnBigokuta_Update(Actor* thisx, GlobalContext* globalCtx) { 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); + func_800B9010(&this->picto.actor, NA_SE_EV_ICE_FREEZE - SFX_FLAG); } } } -s32 EnBigokuta_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, - Actor* thisx, Gfx** gfx) { +s32 EnBigokuta_OverrideLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, Actor* thisx, + Gfx** gfx) { if (limbIndex == BIGOKUTA_LIMB_HEAD) { EnBigokuta* this = THIS; s32 envColor; @@ -584,7 +588,7 @@ s32 EnBigokuta_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** d } rot->x -= rotX; } - } else if (limbIndex == BIGOKUTA_LIMB_SNOUT_CENTER) { + } else if (limbIndex == BIGOKUTA_LIMB_CENTER_SNOUT) { EnBigokuta* this = THIS; if (this->actionFunc == EnBigokuta_PlayDeathEffects) { @@ -621,8 +625,7 @@ s32 EnBigokuta_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** d return false; } -void EnBigokuta_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx, - Gfx** gfx) { +void EnBigokuta_PostLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx, Gfx** gfx) { static s8 D_80AC45BC[] = { -1, -1, -1, 0, -1, 1, -1, 2, -1, 3, 8, 4, -1, 5, -1, -1, -1, -1, 6, 7, }; @@ -636,43 +639,43 @@ 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]); } } } } -void EnBigokuta_Draw(Actor* thisx, GlobalContext* globalCtx) { +void EnBigokuta_Draw(Actor* thisx, PlayState* play) { s32 pad; EnBigokuta* this = THIS; Gfx* gfx; - OPEN_DISPS(globalCtx->state.gfxCtx); + OPEN_DISPS(play->state.gfxCtx); if ((this->actionFunc != EnBigokuta_PlayDeathEffects) || (this->timer != 0)) { - Scene_SetRenderModeXlu(globalCtx, 0, 1); + Scene_SetRenderModeXlu(play, 0, 1); gfx = POLY_OPA_DISP; gSPDisplayList(&gfx[0], &sSetupDL[6 * 25]); gDPSetEnvColor(&gfx[1], 255, 255, 255, 255); - POLY_OPA_DISP = SkelAnime_DrawFlex(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, - this->skelAnime.dListCount, EnBigokuta_OverrideLimbDraw, - EnBigokuta_PostLimbDraw, &this->actor, &gfx[2]); + POLY_OPA_DISP = + SkelAnime_DrawFlex(play, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, + EnBigokuta_OverrideLimbDraw, EnBigokuta_PostLimbDraw, &this->picto.actor, &gfx[2]); } else { - Scene_SetRenderModeXlu(globalCtx, 1, 2); + Scene_SetRenderModeXlu(play, 1, 2); gfx = POLY_XLU_DISP; gSPDisplayList(&gfx[0], &sSetupDL[6 * 25]); - gDPSetEnvColor(&gfx[1], 0, 0, 0, (this->actor.scale.y * 7727.273f)); + gDPSetEnvColor(&gfx[1], 0, 0, 0, (this->picto.actor.scale.y * 7727.273f)); POLY_XLU_DISP = - SkelAnime_DrawFlex(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, - this->skelAnime.dListCount, NULL, EnBigokuta_PostLimbDraw, &this->actor, &gfx[2]); + SkelAnime_DrawFlex(play, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, + NULL, EnBigokuta_PostLimbDraw, &this->picto.actor, &gfx[2]); } - Actor_DrawDamageEffects(globalCtx, &this->actor, this->limbPos, ARRAY_COUNT(this->limbPos), this->drawDmgEffScale, + Actor_DrawDamageEffects(play, &this->picto.actor, this->limbPos, ARRAY_COUNT(this->limbPos), this->drawDmgEffScale, this->drawDmgEffFrozenSteamScale, this->drawDmgEffAlpha, this->drawDmgEffType); - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->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 0f07c4d7f..fdb9d561d 100644 --- a/src/overlays/actors/ovl_En_Bigokuta/z_en_bigokuta.h +++ b/src/overlays/actors/ovl_En_Bigokuta/z_en_bigokuta.h @@ -2,57 +2,33 @@ #define Z_EN_BIGOKUTA_H #include "global.h" +#include "z64snap.h" +#include "assets/objects/object_bigokuta/object_bigokuta.h" struct EnBigokuta; -typedef void (*EnBigokutaActionFunc)(struct EnBigokuta*, GlobalContext*); -typedef void (*EnBigokutaUnkFunc)(GlobalContext*, struct EnBigokuta*); - -typedef enum { - /* 00 */ BIGOKUTA_LIMB_NONE, - /* 01 */ BIGOKUTA_LIMB_BODY, - /* 02 */ BIGOKUTA_LIMB_ARM_BASE_RIGHT_FRONT, - /* 03 */ BIGOKUTA_LIMB_ARM_END_RIGHT_FRONT, - /* 04 */ BIGOKUTA_LIMB_ARM_BASE_LEFT_FRONT, - /* 05 */ BIGOKUTA_LIMB_ARM_END_LEFT_FRONT, - /* 06 */ BIGOKUTA_LIMB_ARM_BASE_RIGHT_BACK, - /* 07 */ BIGOKUTA_LIMB_ARM_END_RIGHT_BACK, - /* 08 */ BIGOKUTA_LIMB_ARM_BASE_LEFT_BACK, - /* 09 */ BIGOKUTA_LIMB_ARM_END_LEFT_BACK, - /* 10 */ BIGOKUTA_LIMB_HEAD, - /* 11 */ BIGOKUTA_LIMB_TENTACLE_BASE_LEFT, - /* 12 */ BIGOKUTA_LIMB_TENTACLE_TIP_LEFT, - /* 13 */ BIGOKUTA_LIMB_TENTACLE_BASE_RIGHT, - /* 14 */ BIGOKUTA_LIMB_TENTACLE_TIP_RIGHT, - /* 15 */ BIGOKUTA_LIMB_WEAK_POINT_LEFT, - /* 16 */ BIGOKUTA_LIMB_WEAK_POINT_RIGHT, - /* 17 */ BIGOKUTA_LIMB_SNOUT_CENTER, - /* 18 */ BIGOKUTA_LIMB_SNOUT_RIGHT, - /* 19 */ BIGOKUTA_LIMB_SNOUT_LEFT, - /* 20 */ BIGOKUTA_LIMB_MAX -} ObjectBigokutaLimbs; +typedef void (*EnBigokutaActionFunc)(struct EnBigokuta*, PlayState*); typedef struct EnBigokuta { - /* 0x0000 */ Actor actor; - /* 0x0144 */ EnBigokutaUnkFunc unkFunc; // possibly something to do with photographing - /* 0x0148 */ SkelAnime skelAnime; - /* 0x018C */ EnBigokutaActionFunc actionFunc; - /* 0x0190 */ u8 drawDmgEffType; - /* 0x0192 */ s16 timer; - /* 0x0194 */ s16 camId; - /* 0x0196 */ s16 cutscene; - /* 0x0198 */ Vec3s jointTable[BIGOKUTA_LIMB_MAX]; - /* 0x0210 */ Vec3s morphTable[BIGOKUTA_LIMB_MAX]; - /* 0x0288 */ f32 drawDmgEffAlpha; - /* 0x028C */ f32 drawDmgEffScale; - /* 0x0290 */ f32 drawDmgEffFrozenSteamScale; // only affects DRAWEFFECT_ICE - /* 0x0294 */ Vec3f playerPos; - /* 0x02A0 */ Vec3f playerHoldPos; - /* 0x02AC */ Vec3f camAt; - /* 0x02B8 */ Vec3f camEye; - /* 0x02C4 */ Vec3f limbPos[13]; - /* 0x0360 */ ColliderCylinder shellCollider; - /* 0x03AC */ ColliderCylinder bodyCollider; + /* 0x000 */ PictoActor picto; + /* 0x148 */ SkelAnime skelAnime; + /* 0x18C */ EnBigokutaActionFunc actionFunc; + /* 0x190 */ u8 drawDmgEffType; + /* 0x192 */ s16 timer; + /* 0x194 */ s16 subCamId; + /* 0x196 */ s16 cutscene; + /* 0x198 */ Vec3s jointTable[BIGOKUTA_LIMB_MAX]; + /* 0x210 */ Vec3s morphTable[BIGOKUTA_LIMB_MAX]; + /* 0x288 */ f32 drawDmgEffAlpha; + /* 0x28C */ f32 drawDmgEffScale; + /* 0x290 */ f32 drawDmgEffFrozenSteamScale; // only affects DRAWEFFECT_ICE + /* 0x294 */ Vec3f playerPos; + /* 0x2A0 */ Vec3f playerHoldPos; + /* 0x2AC */ Vec3f subCamAt; + /* 0x2B8 */ Vec3f subCamEye; + /* 0x2C4 */ Vec3f limbPos[13]; + /* 0x360 */ ColliderCylinder shellCollider; + /* 0x3AC */ ColliderCylinder bodyCollider; } EnBigokuta; // size = 0x3F8 extern const ActorInit En_Bigokuta_InitVars; diff --git a/src/overlays/actors/ovl_En_Bigpamet/z_en_bigpamet.c b/src/overlays/actors/ovl_En_Bigpamet/z_en_bigpamet.c index 2fbd60927..d24b2df49 100644 --- a/src/overlays/actors/ovl_En_Bigpamet/z_en_bigpamet.c +++ b/src/overlays/actors/ovl_En_Bigpamet/z_en_bigpamet.c @@ -5,32 +5,46 @@ */ #include "z_en_bigpamet.h" +#include "z64rumble.h" +#include "overlays/actors/ovl_En_Pametfrog/z_en_pametfrog.h" +#include "objects/gameplay_keep/gameplay_keep.h" #define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_4 | ACTOR_FLAG_10 | ACTOR_FLAG_20 | ACTOR_FLAG_400) #define THIS ((EnBigpamet*)thisx) -void EnBigpamet_Init(Actor* thisx, GlobalContext* globalCtx); -void EnBigpamet_Destroy(Actor* thisx, GlobalContext* globalCtx); -void EnBigpamet_Update(Actor* thisx, GlobalContext* globalCtx); -void EnBigpamet_Draw(Actor* thisx, GlobalContext* globalCtx); +void EnBigpamet_Init(Actor* thisx, PlayState* play); +void EnBigpamet_Destroy(Actor* thisx, PlayState* play); +void EnBigpamet_Update(Actor* thisx, PlayState* play); +void EnBigpamet_Draw(Actor* thisx, PlayState* play); -void func_80A281DC(EnBigpamet* this, GlobalContext* globalCtx); -void func_80A282C8(EnBigpamet* this, GlobalContext* globalCtx); -void func_80A283A0(EnBigpamet* this, GlobalContext* globalCtx); -void func_80A2844C(EnBigpamet* this, GlobalContext* globalCtx); -void func_80A2855C(EnBigpamet* this, GlobalContext* globalCtx); -void func_80A2866C(EnBigpamet* this, GlobalContext* globalCtx); -void func_80A28708(EnBigpamet* this, GlobalContext* globalCtx); -void func_80A287E8(EnBigpamet* this, GlobalContext* globalCtx); -void func_80A289C8(EnBigpamet* this, GlobalContext* globalCtx); -void func_80A28A98(EnBigpamet* this, GlobalContext* globalCtx); -void func_80A28D0C(EnBigpamet* this, GlobalContext* globalCtx); -void func_80A28DC0(EnBigpamet* this, GlobalContext* globalCtx); -void func_80A28E98(EnBigpamet* this, GlobalContext* globalCtx); -void func_80A28EE8(EnBigpamet* this, GlobalContext* globalCtx); +void func_80A281DC(EnBigpamet* this, PlayState* play); +void func_80A282C8(EnBigpamet* this, PlayState* play); +void func_80A283A0(EnBigpamet* this, PlayState* play); +void func_80A2844C(EnBigpamet* this, PlayState* play); +void func_80A2855C(EnBigpamet* this, PlayState* play); +void func_80A2866C(EnBigpamet* this, PlayState* play); +void func_80A28708(EnBigpamet* this, PlayState* play); +void func_80A287E8(EnBigpamet* this, PlayState* play); +void func_80A289C8(EnBigpamet* this, PlayState* play); +void func_80A28A98(EnBigpamet* this, PlayState* play); +void func_80A28D0C(EnBigpamet* this, PlayState* play); +void func_80A28DC0(EnBigpamet* this, PlayState* play); +void func_80A28E98(EnBigpamet* this, PlayState* play); +void func_80A28EE8(EnBigpamet* this, PlayState* play); +void func_80A281B4(EnBigpamet* this); +void func_80A28274(EnBigpamet* this); +void func_80A28378(EnBigpamet* this); +void func_80A28E40(EnBigpamet* this); +void func_80A28618(EnBigpamet* this); +void func_80A2966C(Actor* thisx, PlayState* play); +void func_80A286C0(EnBigpamet* this); +void func_80A28760(EnBigpamet* this); +void func_80A28970(EnBigpamet* this); +void func_80A28A28(EnBigpamet* this); +void func_80A28D80(EnBigpamet* this); +void func_80A28ED4(EnBigpamet* this); -#if 0 const ActorInit En_Bigpamet_InitVars = { ACTOR_EN_BIGPAMET, ACTORCAT_BOSS, @@ -43,18 +57,29 @@ const ActorInit En_Bigpamet_InitVars = { (ActorFunc)EnBigpamet_Draw, }; -// static ColliderCylinderInit sCylinderInit = { -static ColliderCylinderInit D_80A29700 = { - { COLTYPE_HARD, AT_NONE | AT_TYPE_ENEMY, AC_ON | AC_HARD | AC_TYPE_PLAYER, OC1_ON | OC1_TYPE_ALL, OC2_TYPE_1, COLSHAPE_CYLINDER, }, - { ELEMTYPE_UNK0, { 0xF7CFFFFF, 0x04, 0x04 }, { 0xF7CF7FFF, 0x00, 0x00 }, TOUCH_ON | TOUCH_SFX_NORMAL, BUMP_ON | BUMP_HOOKABLE, OCELEM_ON, }, +static ColliderCylinderInit sCylinderInit = { + { + COLTYPE_HARD, + AT_NONE | AT_TYPE_ENEMY, + AC_ON | AC_HARD | AC_TYPE_PLAYER, + OC1_ON | OC1_TYPE_ALL, + OC2_TYPE_1, + COLSHAPE_CYLINDER, + }, + { + ELEMTYPE_UNK0, + { 0xF7CFFFFF, 0x04, 0x04 }, + { 0xF7CF7FFF, 0x00, 0x00 }, + TOUCH_ON | TOUCH_SFX_NORMAL, + BUMP_ON | BUMP_HOOKABLE, + OCELEM_ON, + }, { 53, 50, 0, { 0, 0, 0 } }, }; -// sColChkInfoInit -static CollisionCheckInfoInit D_80A2972C = { 1, 53, 60, 250 }; +static CollisionCheckInfoInit sColChkInfoInit = { 1, 53, 60, 250 }; -// static DamageTable sDamageTable = { -static DamageTable D_80A29734 = { +static DamageTable sDamageTable = { /* Deku Nut */ DMG_ENTRY(1, 0x0), /* Deku Stick */ DMG_ENTRY(1, 0x0), /* Horse trample */ DMG_ENTRY(0, 0x0), @@ -89,121 +114,760 @@ static DamageTable D_80A29734 = { /* Powder Keg */ DMG_ENTRY(1, 0xF), }; -// static InitChainEntry sInitChain[] = { -static InitChainEntry D_80A29764[] = { - ICHAIN_S8(hintId, 1, ICHAIN_CONTINUE), - ICHAIN_VEC3F_DIV1000(scale, 15, ICHAIN_CONTINUE), - ICHAIN_F32(gravity, -2, ICHAIN_CONTINUE), - ICHAIN_F32(targetArrowOffset, 4333, ICHAIN_CONTINUE), +TexturePtr D_80A29754[] = { + object_tl_Tex_0055A0, + object_tl_Tex_0057A0, + object_tl_Tex_0059A0, + object_tl_Tex_0057A0, +}; + +static InitChainEntry sInitChain[] = { + ICHAIN_S8(hintId, 1, ICHAIN_CONTINUE), ICHAIN_VEC3F_DIV1000(scale, 15, ICHAIN_CONTINUE), + ICHAIN_F32(gravity, -2, ICHAIN_CONTINUE), ICHAIN_F32(targetArrowOffset, 4333, ICHAIN_CONTINUE), ICHAIN_U8(targetMode, 5, ICHAIN_STOP), }; -#endif +s32 D_80A29778 = 0; +Vec3f D_80A2977C = { 0.0f, 1.0f, 0.0f }; +Color_RGBA8 D_80A29788 = { 250, 250, 250, 255 }; +Color_RGBA8 D_80A2978C = { 180, 180, 180, 255 }; -extern ColliderCylinderInit D_80A29700; -extern CollisionCheckInfoInit D_80A2972C; -extern DamageTable D_80A29734; -extern InitChainEntry D_80A29764[]; +void EnBigpamet_Init(Actor* thisx, PlayState* play) { + EnBigpamet* this = THIS; + s32 i; -extern UNK_TYPE D_06000440; -extern UNK_TYPE D_06000AF4; -extern UNK_TYPE D_06001C68; -extern UNK_TYPE D_060031DC; -extern UNK_TYPE D_06004210; -extern UNK_TYPE D_0600823C; + Actor_ProcessInitChain(&this->actor, sInitChain); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bigpamet/EnBigpamet_Init.s") + SkelAnime_InitFlex(play, &this->skelAnime2, &object_tl_Skel_007C70, &object_tl_Anim_004210, this->jointTable2, + this->morphTable2, OBJECT_TL_2_LIMB_MAX); + SkelAnime_InitFlex(play, &this->skelAnime1, &object_tl_Skel_001A50, &object_tl_Anim_000B30, this->jointTable1, + this->morphTable1, OBJECT_TL_1_LIMB_MAX); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bigpamet/EnBigpamet_Destroy.s") + ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 55.0f); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bigpamet/func_80A2768C.s") + Collider_InitAndSetCylinder(play, &this->collider, &this->actor, &sCylinderInit); + CollisionCheck_SetInfo(&this->actor.colChkInfo, &sDamageTable, &sColChkInfoInit); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bigpamet/func_80A276F4.s") + if (!D_80A29778) { + for (i = 0; i < ARRAY_COUNT(D_80A29754); i++) { + D_80A29754[i] = Lib_SegmentedToVirtual(D_80A29754[i]); + } + D_80A29778 = true; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bigpamet/func_80A2778C.s") + this->actor.params = ENBIGPAMET_1; + func_80A281B4(this); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bigpamet/func_80A27970.s") +void EnBigpamet_Destroy(Actor* thisx, PlayState* play) { + EnBigpamet* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bigpamet/func_80A27B58.s") + Collider_DestroyCylinder(play, &this->collider); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bigpamet/func_80A27DD8.s") +void func_80A2768C(EnBigpamet* this) { + if (this->unk_29C != 0) { + this->unk_29C++; + if (this->unk_29C == 4) { + this->unk_29C = 0; + } + } else if (Rand_ZeroOne() < 0.05f) { + this->unk_29C = 1; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bigpamet/func_80A27FE8.s") +void func_80A276F4(EnBigpamet* this) { + if (this->actor.parent->params == GEKKO_ON_SNAPPER) { + this->actor.parent->shape.rot.y = this->actor.shape.rot.y; + this->actor.parent->shape.rot.z = this->actor.shape.rot.z; + Matrix_SetTranslateRotateYXZ(this->actor.world.pos.x, this->unk_2AC, this->actor.world.pos.z, + &this->actor.shape.rot); + Matrix_MultVecY(46.0f, &this->actor.parent->world.pos); + } else if (this->actor.parent->params == GEKKO_REAR_ON_SNAPPER) { + this->actor.parent->world.pos.x = this->actor.world.pos.x; + this->actor.parent->world.pos.z = this->actor.world.pos.z; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bigpamet/func_80A2811C.s") +void func_80A2778C(EnBigpamet* this) { + f32 temp_fs1; + s16 temp_s1; + s16 temp_s2; + s32 i; + EnBigpametStruct* ptr; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bigpamet/func_80A281B4.s") + this->unk_2A2 = 40; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bigpamet/func_80A281DC.s") + for (ptr = &this->unk_2FC[0], i = 0; i < ARRAY_COUNT(this->unk_2FC); i++, ptr++) { + temp_s2 = (s32)Rand_Next() >> 0x10; + temp_s1 = Rand_S16Offset(0x1800, 0x2800); + temp_fs1 = Rand_ZeroFloat(5.0f) + 7.0f; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bigpamet/func_80A28274.s") + ptr->unk_0C.x = (temp_fs1 * Math_CosS(temp_s1)) * Math_SinS(temp_s2); + ptr->unk_0C.y = (temp_fs1 * Math_SinS(temp_s1)) + 3.0f; + ptr->unk_0C.z = (temp_fs1 * Math_CosS(temp_s1)) * Math_CosS(temp_s2); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bigpamet/func_80A282C8.s") + ptr->unk_18.x = (s32)Rand_Next() >> 0x10; + ptr->unk_18.y = (s32)Rand_Next() >> 0x10; + ptr->unk_18.z = (s32)Rand_Next() >> 0x10; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bigpamet/func_80A28378.s") + ptr->unk_00.x = (Math_SinS(temp_s2) * 40.0f) + this->actor.world.pos.x; + ptr->unk_00.y = this->actor.floorHeight; + ptr->unk_00.z = (Math_CosS(temp_s2) * 40.0f) + this->actor.world.pos.z; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bigpamet/func_80A283A0.s") + ptr->unk_20 = Rand_ZeroFloat(0.0025000002f) + 0.002f; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bigpamet/func_80A283F0.s") + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_B_PAMET_BREAK); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bigpamet/func_80A2844C.s") +void func_80A27970(EnBigpamet* this, PlayState* play2) { + Vec3f sp9C; + f32 temp_fs1 = this->actor.depthInWater + this->actor.world.pos.y; + s32 sp94; + s32 i; + s16 temp_s0; + f32 temp_fs0; + CollisionPoly* sp84; + PlayState* play = play2; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bigpamet/func_80A284E4.s") + for (i = 0; i < 2; i++) { + temp_fs0 = Rand_ZeroFloat(30.0f) + 30.0f; + temp_s0 = Rand_Next() >> 0x10; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bigpamet/func_80A2855C.s") + sp9C.x = (Math_SinS(temp_s0) * temp_fs0) + this->actor.world.pos.x; + sp9C.y = Rand_ZeroFloat(10.0f) + this->actor.floorHeight + 8.0f; + sp9C.z = (Math_CosS(temp_s0) * temp_fs0) + this->actor.world.pos.z; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bigpamet/func_80A28618.s") + if (BgCheck_EntityRaycastFloor5_2(play, &play->colCtx, &sp84, &sp94, &this->actor, &sp9C) < temp_fs1) { + sp9C.y = temp_fs1; + EffectSsGSplash_Spawn(play, &sp9C, NULL, NULL, 0, Rand_S16Offset(1000, 200)); + } else { + func_800B12F0(play, &sp9C, &D_80A2977C, &gZeroVec3f, Rand_S16Offset(950, 100), Rand_S16Offset(10, 10), 20); + } + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bigpamet/func_80A2866C.s") +void func_80A27B58(EnBigpamet* this) { + EnBigpametStruct* ptr; + s32 i; + Vec3f sp64; + f32 temp_fs0; + s16 temp_s2; + f32 temp_fs2; + s16 temp_s1; + f32 temp_fs3; + s16 var_s1; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bigpamet/func_80A286C0.s") + sp64.x = (Math_SinS(this->actor.wallYaw + 0x8000) * 50.0f) + this->actor.world.pos.x; + sp64.y = this->actor.world.pos.y; + sp64.z = (Math_CosS(this->actor.wallYaw + 0x8000) * 50.0f) + this->actor.world.pos.z; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bigpamet/func_80A28708.s") + this->unk_2A2 = 40; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bigpamet/func_80A28760.s") + for (ptr = &this->unk_2FC[0], i = 0; i < ARRAY_COUNT(this->unk_2FC); i++, ptr++) { + temp_s1 = (s32)randPlusMinusPoint5Scaled(20480.0f) + this->actor.wallYaw; + temp_s2 = Rand_S16Offset(0x1000, 0x3000); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bigpamet/func_80A287E8.s") + temp_fs2 = Math_SinS(temp_s2); + temp_fs3 = Math_CosS(temp_s2); + temp_fs0 = Rand_ZeroFloat(5.0f) + 7.0f; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bigpamet/func_80A28970.s") + ptr->unk_0C.x = Math_SinS(temp_s1) * (temp_fs0 * temp_fs3); + ptr->unk_0C.y = (temp_fs0 * temp_fs2) + 3.0f; + ptr->unk_0C.z = Math_CosS(temp_s1) * (temp_fs0 * temp_fs3); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bigpamet/func_80A289C8.s") + ptr->unk_18.x = (s32)Rand_Next() >> 0x10; + ptr->unk_18.y = (s32)Rand_Next() >> 0x10; + ptr->unk_18.z = (s32)Rand_Next() >> 0x10; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bigpamet/func_80A28A28.s") + if ((s16)(temp_s1 - this->actor.wallYaw) > 0) { + var_s1 = this->actor.wallYaw + 0x4000; + } else { + var_s1 = this->actor.wallYaw - 0x4000; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bigpamet/func_80A28A98.s") + ptr->unk_00.x = (Math_SinS(var_s1) * (60.0f * temp_fs3)) + sp64.x; + ptr->unk_00.y = (60.0f * temp_fs2) + sp64.y; + ptr->unk_00.z = (Math_CosS(var_s1) * (60.0f * temp_fs3)) + sp64.z; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bigpamet/func_80A28B98.s") + ptr->unk_20 = Rand_ZeroFloat(0.0025000002f) + 0.002f; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bigpamet/func_80A28D0C.s") + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_B_PAMET_BREAK); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bigpamet/func_80A28D80.s") +void func_80A27DD8(EnBigpamet* this, PlayState* play) { + s32 i; + Vec3f pos; + Vec3f sp8C; + f32 temp_fs0; + f32 temp_fs4; + f32 temp_fs5; + s16 temp_s0; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bigpamet/func_80A28DC0.s") + temp_fs4 = Math_SinS(this->actor.wallYaw + 0x4000); + temp_fs5 = Math_CosS(this->actor.wallYaw + 0x4000); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bigpamet/func_80A28E40.s") + sp8C.x = Math_SinS(this->actor.wallYaw + 0x8000) * 50.0f + this->actor.world.pos.x; + sp8C.y = this->actor.world.pos.y; + sp8C.z = (Math_CosS(this->actor.wallYaw + 0x8000) * 50.0f) + this->actor.world.pos.z; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bigpamet/func_80A28E98.s") + sp8C.x += (this->actor.world.pos.x - sp8C.x) * 0.3f; + sp8C.z += (this->actor.world.pos.z - sp8C.z) * 0.3f; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bigpamet/func_80A28ED4.s") + for (i = 0; i < 4; i++) { + temp_fs0 = Rand_ZeroFloat(60.0f) + 50.0f; + temp_s0 = Rand_Next() >> 0x11; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bigpamet/func_80A28EE8.s") + pos.x = (Math_CosS(temp_s0) * temp_fs0 * temp_fs4) + sp8C.x; + pos.y = (Math_SinS(temp_s0) * temp_fs0) + sp8C.y; + pos.z = (Math_CosS(temp_s0) * temp_fs0 * temp_fs5) + sp8C.z; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bigpamet/func_80A29028.s") + func_800B12F0(play, &pos, &gZeroVec3f, &gZeroVec3f, Rand_S16Offset(950, 100), Rand_S16Offset(20, 10), 20); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bigpamet/func_80A29094.s") +void func_80A27FE8(EnBigpamet* this, PlayState* play) { + Vec3f pos; + s16 sp32; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bigpamet/EnBigpamet_Update.s") + if (this->actor.depthInWater > 0.0f) { + pos.x = this->actor.world.pos.x; + pos.z = this->actor.world.pos.z; + pos.y = this->actor.world.pos.y + this->actor.depthInWater; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bigpamet/func_80A292A8.s") + EffectSsGRipple_Spawn(play, &pos, 500, 900, 0); + pos.y += 8.0f; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bigpamet/func_80A293E4.s") + if (this->actionFunc != func_80A28D0C) { + sp32 = (s32)randPlusMinusPoint5Scaled(0x8000) + this->actor.world.rot.y; + pos.x -= 55.0f * Math_SinS(sp32); + pos.z -= 55.0f * Math_CosS(sp32); + } + EffectSsGSplash_Spawn(play, &pos, NULL, NULL, 0, Rand_S16Offset(1400, 200)); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bigpamet/func_80A29494.s") +void func_80A2811C(EnBigpamet* this, PlayState* play) { + Vec3f pos; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bigpamet/EnBigpamet_Draw.s") + if ((this->actor.depthInWater > 0.0f) && ((play->gameplayFrames % 14) == 0)) { + pos.x = this->actor.world.pos.x; + pos.y = this->actor.world.pos.y + this->actor.depthInWater; + pos.z = this->actor.world.pos.z; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bigpamet/func_80A29580.s") + EffectSsGRipple_Spawn(play, &pos, 500, 900, 0); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bigpamet/func_80A29628.s") +void func_80A281B4(EnBigpamet* this) { + this->actor.draw = NULL; + this->actor.flags &= ~ACTOR_FLAG_1; + this->actionFunc = func_80A281DC; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bigpamet/func_80A2966C.s") +void func_80A281DC(EnBigpamet* this, PlayState* play) { + WaterBox* sp2C; + f32 sp28; + + if (this->actor.parent->params == GEKKO_GET_SNAPPER) { + if (WaterBox_GetSurface1(play, &play->colCtx, this->actor.world.pos.x, this->actor.world.pos.z, &sp28, &sp2C)) { + this->actor.depthInWater = sp28 - this->actor.world.pos.y; + } else { + this->actor.depthInWater = this->actor.world.pos.y; + } + + func_80A2778C(this); + func_80A27970(this, play); + func_80A28274(this); + } +} + +void func_80A28274(EnBigpamet* this) { + Animation_PlayLoop(&this->skelAnime2, &object_tl_Anim_004210); + this->actor.draw = EnBigpamet_Draw; + this->unk_29E = 20; + this->actionFunc = func_80A282C8; +} + +void func_80A282C8(EnBigpamet* this, PlayState* play) { + if (Math_SmoothStepToF(&this->actor.world.pos.y, this->actor.floorHeight, 0.7f, 30.0f, 10.0f) < 1.0f) { + this->unk_29E--; + if (this->unk_29E >= 16) { + func_80A27970(this, play); + } + if (this->unk_29E == 0) { + func_80A28378(this); + } + } else { + func_80A27970(this, play); + } +} + +void func_80A28378(EnBigpamet* this) { + this->actor.parent->params = GEKKO_INIT_SNAPPER; + this->actor.speedXZ = 0.0f; + this->actionFunc = func_80A283A0; +} + +void func_80A283A0(EnBigpamet* this, PlayState* play) { + SkelAnime_Update(&this->skelAnime2); + if (this->actor.parent->params == GEKKO_ON_SNAPPER) { + func_80A28E40(this); + } +} + +void func_80A283F0(EnBigpamet* this) { + Animation_PlayLoop(&this->skelAnime2, &object_tl_Anim_00823C); + this->actor.speedXZ = 1.0f; + this->actor.world.rot.y = this->actor.shape.rot.y; + this->actor.params = ENBIGPAMET_1; + this->actionFunc = func_80A2844C; +} + +void func_80A2844C(EnBigpamet* this, PlayState* play) { + SkelAnime_Update(&this->skelAnime2); + + if (this->actor.parent->params == GEKKO_RETURN_TO_SNAPPER) { + Math_ScaledStepToS(&this->actor.shape.rot.y, Actor_YawBetweenActors(&this->actor, this->actor.parent), 0x400); + this->actor.world.rot.y = this->actor.shape.rot.y; + } else if (this->actor.parent->params == GEKKO_JUMP_ON_SNAPPER) { + this->actor.speedXZ = 0.0f; + } else if (this->actor.parent->params == GEKKO_ON_SNAPPER) { + func_80A28E40(this); + } +} + +void func_80A284E4(EnBigpamet* this) { + Animation_MorphToPlayOnce(&this->skelAnime2, &object_tl_Anim_001C68, -3.0f); + this->unk_29E = 0; + this->unk_2A8 = 1.0f; + this->unk_2A4 = 1.0f; + this->actor.speedXZ = 0.0f; + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_B_PAMET_VOICE); + Actor_PlaySfxAtPos(this->actor.parent, NA_SE_EN_FROG_VOICE1); + this->actionFunc = func_80A2855C; +} + +void func_80A2855C(EnBigpamet* this, PlayState* play) { + if (SkelAnime_Update(&this->skelAnime2)) { + func_80A28618(this); + } else if (this->skelAnime2.curFrame > 2.0f) { + this->unk_2A8 = 1.5f - ((this->skelAnime2.curFrame - 2.0f) * 0.23333333f); + this->unk_2A4 = 1.5f - ((this->skelAnime2.curFrame - 2.0f) * 0.083333336f); + } else { + f32 curFrame = this->skelAnime2.curFrame; + + this->unk_2A4 = this->unk_2A8 = (0.25f * curFrame) + 1.0f; + } +} + +void func_80A28618(EnBigpamet* this) { + this->actor.draw = func_80A2966C; + this->unk_2A8 = 0.5f; + this->actor.speedXZ = 0.0f; + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_PAMET_CUTTER_ON); + this->actionFunc = func_80A2866C; +} + +void func_80A2866C(EnBigpamet* this, PlayState* play) { + this->unk_2A8 += 0.2f; + if (this->unk_2A8 > 1.1f) { + func_80A286C0(this); + } +} + +void func_80A286C0(EnBigpamet* this) { + this->collider.info.bumper.dmgFlags = 0xF7CF7FFF; + this->collider.base.atFlags |= AT_ON; + this->actor.shape.rot.z = 0x680; + this->unk_29E = 15; + this->unk_2A8 = 1.0f; + this->actionFunc = func_80A28708; +} + +void func_80A28708(EnBigpamet* this, PlayState* play) { + this->unk_29E--; + this->actor.shape.rot.y += 0x3B00; + func_800B9010(&this->actor, NA_SE_EN_B_PAMET_ROLL - SFX_FLAG); + if (this->unk_29E == 0) { + func_80A28760(this); + } +} + +void func_80A28760(EnBigpamet* this) { + this->actor.speedXZ = 15.0f; + if (this->actor.bgCheckFlags & 8) { + s16 temp_v1 = this->actor.yawTowardsPlayer - this->actor.wallYaw; + + this->actor.bgCheckFlags &= ~8; + + if (temp_v1 > 0x3C00) { + this->actor.world.rot.y = this->actor.wallYaw + 0x3C00; + } else if (temp_v1 < -0x3C00) { + this->actor.world.rot.y = this->actor.wallYaw - 0x3C00; + } else { + this->actor.world.rot.y = this->actor.yawTowardsPlayer; + } + } else { + this->actor.world.rot.y = this->actor.yawTowardsPlayer; + } + this->unk_29E = 0; + this->actionFunc = func_80A287E8; +} + +void func_80A287E8(EnBigpamet* this, PlayState* play) { + s16 quake; + + this->actor.shape.rot.y += 0x3B00; + func_800B9010(&this->actor, NA_SE_EN_B_PAMET_ROLL - SFX_FLAG); + this->unk_29E++; + this->unk_29E = CLAMP_MAX(this->unk_29E, 20); + if (this->collider.base.atFlags & AT_HIT) { + this->collider.base.atFlags &= ~AT_HIT; + if ((s16)(this->actor.yawTowardsPlayer - this->actor.world.rot.y) > 0) { + this->actor.world.rot.y = this->actor.world.rot.y - 0x300; + } else { + this->actor.world.rot.y = this->actor.world.rot.y + 0x300; + } + } + + if (play->gameplayFrames & 1) { + func_80A27FE8(this, play); + } + + if (this->actor.bgCheckFlags & 8) { + quake = Quake_Add(GET_ACTIVE_CAM(play), 3); + this->actor.velocity.y = this->unk_29E * 0.375f; + Quake_SetSpeed(quake, 0x4E20); + Quake_SetQuakeValues(quake, 15, 0, 0, 0); + Quake_SetCountdown(quake, 10); + Rumble_Request(this->actor.xyzDistToPlayerSq, 180, 20, 100); + func_80A27B58(this); + func_80A27DD8(this, play); + func_80A28970(this); + } +} + +void func_80A28970(EnBigpamet* this) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_PAMET_CUTTER_OFF); + this->actor.shape.rot.z = 0; + this->collider.base.atFlags &= ~AT_ON; + this->collider.info.bumper.dmgFlags = 0xF7CFFFFF; + this->actor.speedXZ = 0.0f; + this->actionFunc = func_80A289C8; +} + +void func_80A289C8(EnBigpamet* this, PlayState* play) { + this->unk_2A8 -= 0.1f; + if (this->unk_2A8 < 0.5f) { + func_80A28A28(this); + } + func_80A27DD8(this, play); +} + +void func_80A28A28(EnBigpamet* this) { + this->actor.draw = EnBigpamet_Draw; + Animation_MorphToPlayOnce(&this->skelAnime2, &object_tl_Anim_0031DC, -3.0f); + this->unk_2A8 = 0.1f; + this->unk_2A4 = 1.0f; + this->actor.world.rot.y = this->actor.shape.rot.y; + this->actionFunc = func_80A28A98; +} + +void func_80A28A98(EnBigpamet* this, PlayState* play) { + f32 curFrame; + + Math_ScaledStepToS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer, 0x600); + + if (SkelAnime_Update(&this->skelAnime2)) { + if ((this->actor.parent->params == GEKKO_RETURN_TO_SNAPPER) || + (this->actor.parent->params == GEKKO_JUMP_ON_SNAPPER)) { + func_80A283F0(this); + } else { + func_80A284E4(this); + } + } else { + curFrame = this->skelAnime2.curFrame; + + if (curFrame > 7.0f) { + this->unk_2A8 = 1.5f - ((curFrame - 7.0f) * (1.0f / 6.0f)); + this->unk_2A4 = 1.5f - ((curFrame - 7.0f) * (1.0f / 6.0f)); + } else { + this->unk_2A8 = (0.2f * curFrame) + 0.1f; + this->unk_2A4 = ((1.0f / 14.0f) * curFrame) + 1.0f; + } + } +} + +void func_80A28B98(EnBigpamet* this, PlayState* play) { + Actor* collectible; + + Animation_PlayLoop(&this->skelAnime2, &object_tl_Anim_000AF4); + + this->collider.base.atFlags &= ~AT_ON; + this->collider.info.bumper.dmgFlags = 0xF7CFFFFF; + this->collider.base.atFlags &= ~(AT_HIT | AT_BOUNCED); + this->collider.base.acFlags &= ~AC_ON; + + this->actor.velocity.y = 22.0f; + this->actor.speedXZ = 5.0f; + + if ((this->actor.draw == func_80A2966C) && (this->actionFunc != func_80A28DC0)) { + this->actor.draw = EnBigpamet_Draw; + } else if (this->collider.base.ac != NULL) { + this->actor.world.rot.y = BINANG_ROT180(Actor_YawBetweenActors(&this->actor, this->collider.base.ac)); + } + + this->actor.shape.rot.y = this->actor.world.rot.y; + this->actor.bgCheckFlags &= ~1; + this->actor.flags &= ~ACTOR_FLAG_1; + this->actor.params = ENBIGPAMET_0; + + if ((this->actor.parent->params == GEKKO_ON_SNAPPER) || (this->actor.parent->params == GEKKO_REAR_ON_SNAPPER) || + (this->actor.parent->params == GEKKO_JUMP_ON_SNAPPER)) { + this->actor.parent->params = GEKKO_CUTSCENE; + } + + collectible = Item_DropCollectible(play, &this->actor.world.pos, ITEM00_ARROWS_10); + if (collectible != NULL) { + collectible->velocity.y = 15.0f; + collectible->world.rot.y = Actor_YawToPoint(&this->actor, &this->actor.home.pos); + } + + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_B_PAMET_REVERSE); + this->actionFunc = func_80A28D0C; +} + +void func_80A28D0C(EnBigpamet* this, PlayState* play) { + SkelAnime_Update(&this->skelAnime2); + if (this->actor.bgCheckFlags & 1) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_HIPLOOP_LAND); + func_80A27FE8(this, play); + func_80A28D80(this); + } + this->actor.shape.rot.x += 0x800; + this->actor.shape.rot.z += 0x1000; +} + +void func_80A28D80(EnBigpamet* this) { + this->actor.draw = func_80A2966C; + this->actor.speedXZ = 0.0f; + this->actor.shape.rot.x = 0; + this->actor.shape.rot.z = 0; + this->unk_2A8 = 0.0f; + this->collider.base.acFlags |= AC_ON; + this->actionFunc = func_80A28DC0; +} + +void func_80A28DC0(EnBigpamet* this, PlayState* play) { + this->actor.shape.rot.x = (s32)Rand_Next() >> 0x16; + this->actor.shape.rot.z = (s32)Rand_Next() >> 0x16; + if ((this->actor.parent->params == GEKKO_RETURN_TO_SNAPPER) || + (this->actor.parent->params == GEKKO_JUMP_ON_SNAPPER)) { + func_80A28A28(this); + } else if (this->actor.parent->params == GEKKO_DEFEAT) { + func_80A28ED4(this); + } +} + +void func_80A28E40(EnBigpamet* this) { + Animation_MorphToPlayOnce(&this->skelAnime2, &object_tl_Anim_000440, -2.0f); + this->actor.flags |= ACTOR_FLAG_1; + this->actor.speedXZ = 0.0f; + this->actionFunc = func_80A28E98; +} + +void func_80A28E98(EnBigpamet* this, PlayState* play) { + if (SkelAnime_Update(&this->skelAnime2)) { + func_80A284E4(this); + } +} + +void func_80A28ED4(EnBigpamet* this) { + this->actionFunc = func_80A28EE8; +} + +void func_80A28EE8(EnBigpamet* this, PlayState* play) { + Vec3f pos; + s16 sp3A; + + this->actor.shape.rot.x = (s32)Rand_Next() >> 0x16; + this->actor.shape.rot.z = (s32)Rand_Next() >> 0x16; + + if (Math_StepToF(&this->actor.scale.x, 0.0f, 0.00075f)) { + sp3A = BINANG_ROT180(Camera_GetCamDirYaw(GET_ACTIVE_CAM(play))); + + pos.x = (Math_SinS(sp3A) * 20.0f) + this->actor.world.pos.x; + pos.y = this->actor.world.pos.y + 25.0f; + pos.z = (Math_CosS(sp3A) * 20.0f) + this->actor.world.pos.z; + + func_800B0DE0(play, &pos, &gZeroVec3f, &gZeroVec3f, &D_80A29788, &D_80A2978C, 800, 50); + SoundSource_PlaySfxAtFixedWorldPos(play, &this->actor.world.pos, 50, NA_SE_EN_NPC_FADEAWAY); + Actor_MarkForDeath(&this->actor); + } + + this->actor.scale.y = this->actor.scale.x; + this->actor.scale.z = this->actor.scale.x; +} + +void func_80A29028(EnBigpamet* this, PlayState* play) { + if (this->collider.base.acFlags & AC_HIT) { + this->collider.base.acFlags &= ~AC_HIT; + if ((this->actor.colChkInfo.damageEffect == 0xF) && (this->actor.parent->params != GEKKO_JUMP_ON_SNAPPER) && + (this->actionFunc != func_80A28E98)) { + func_80A28B98(this, play); + } + } +} + +void func_80A29094(EnBigpamet* this) { + EnBigpametStruct* ptr = &this->unk_2FC[0]; + s32 i; + + for (i = 0; i < ARRAY_COUNT(this->unk_2FC); i++, ptr++) { + ptr->unk_0C.y -= 1.0f; + + Math_Vec3f_Sum(&ptr->unk_00, &ptr->unk_0C, &ptr->unk_00); + + ptr->unk_18.x += (s16)((Rand_Next() >> 0x17) + 0x700); + ptr->unk_18.y += (s16)((Rand_Next() >> 0x17) + 0x900); + ptr->unk_18.z += (s16)((Rand_Next() >> 0x17) + 0xB00); + } +} + +void EnBigpamet_Update(Actor* thisx, PlayState* play) { + s32 pad; + EnBigpamet* this = THIS; + + func_80A2768C(this); + func_80A29028(this, play); + + this->actionFunc(this, play); + + if (this->unk_2A2 > 0) { + this->unk_2A2--; + func_80A29094(this); + } + + if ((this->actionFunc != func_80A281DC) && (this->actionFunc != func_80A282C8)) { + Actor_MoveWithGravity(&this->actor); + Actor_UpdateBgCheckInfo(play, &this->actor, 40.0f, 50.0f, 60.0f, 0x1F); + func_80A276F4(this); + Actor_SetFocus(&this->actor, 25.0f); + + Collider_UpdateCylinder(&this->actor, &this->collider); + + if (this->collider.base.atFlags & AT_ON) { + CollisionCheck_SetAT(play, &play->colChkCtx, &this->collider.base); + } + + if (this->collider.base.acFlags & AC_ON) { + CollisionCheck_SetAC(play, &play->colChkCtx, &this->collider.base); + } + + CollisionCheck_SetOC(play, &play->colChkCtx, &this->collider.base); + + if (this->actionFunc != func_80A287E8) { + func_80A2811C(this, play); + } + } +} + +void func_80A292A8(EnBigpamet* this, PlayState* play) { + s32 i; + EnBigpametStruct* ptr; + + if (this->unk_2A2 > 0) { + OPEN_DISPS(play->state.gfxCtx); + + func_8012C28C(play->state.gfxCtx); + + gDPSetPrimColor(POLY_OPA_DISP++, 0, 0x80, 255, 255, 255, 255); + gDPSetEnvColor(POLY_OPA_DISP++, 255, 255, 255, 255); + + for (ptr = &this->unk_2FC[0], i = 0; i < ARRAY_COUNT(this->unk_2FC); i++, ptr++) { + Matrix_SetTranslateRotateYXZ(ptr->unk_00.x, ptr->unk_00.y, ptr->unk_00.z, &ptr->unk_18); + Matrix_Scale(ptr->unk_20, ptr->unk_20, ptr->unk_20, MTXMODE_APPLY); + + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_OPA_DISP++, gameplay_keep_DL_06AB30); + } + + CLOSE_DISPS(play->state.gfxCtx); + } +} + +s32 EnBigpamet_OverrideLimbDraw2(PlayState* play, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, Actor* thisx) { + EnBigpamet* this = THIS; + + if ((this->actionFunc == func_80A2855C) || (this->actionFunc == func_80A28A98)) { + if (limbIndex == OBJECT_TL_2_LIMB_02) { + Matrix_Scale(this->unk_2A4, this->unk_2A8, this->unk_2A4, MTXMODE_APPLY); + } else if ((limbIndex == OBJECT_TL_2_LIMB_0B) || (limbIndex == OBJECT_TL_2_LIMB_09) || + (limbIndex == OBJECT_TL_2_LIMB_07) || (limbIndex == OBJECT_TL_2_LIMB_05)) { + Matrix_Scale(this->unk_2A4, this->unk_2A8, this->unk_2A8, MTXMODE_APPLY); + } + } + return false; +} + +void EnBigpamet_PostLimbDraw2(PlayState* play, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx) { + EnBigpamet* this = THIS; + + if (limbIndex == OBJECT_TL_2_LIMB_01) { + this->unk_2AC = Matrix_GetCurrent()->yw; + } +} + +void EnBigpamet_Draw(Actor* thisx, PlayState* play) { + EnBigpamet* this = THIS; + + OPEN_DISPS(play->state.gfxCtx); + + func_8012C28C(play->state.gfxCtx); + + gSPSegment(POLY_OPA_DISP++, 0x08, D_80A29754[this->unk_29C]); + + SkelAnime_DrawFlexOpa(play, this->skelAnime2.skeleton, this->skelAnime2.jointTable, this->skelAnime2.dListCount, + EnBigpamet_OverrideLimbDraw2, EnBigpamet_PostLimbDraw2, &this->actor); + func_80A292A8(this, play); + + CLOSE_DISPS(play->state.gfxCtx); +} + +s32 EnBigpamet_OverrideLimbDraw1(PlayState* play, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, Actor* thisx) { + EnBigpamet* this = THIS; + + if (limbIndex == OBJECT_TL_1_LIMB_01) { + if (this->actionFunc == func_80A28D0C) { + pos->y -= 2500.0f; + } else { + pos->y -= 700.0f; + } + } + + if ((this->unk_2A8 != 1.0f) && (limbIndex == OBJECT_TL_1_LIMB_03)) { + Matrix_Scale(1.0f, this->unk_2A8, this->unk_2A8, MTXMODE_APPLY); + } + + return false; +} + +void EnBigpamet_PostLimbDraw1(PlayState* play, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx) { + EnBigpamet* this = THIS; + + if (limbIndex == OBJECT_TL_1_LIMB_01) { + this->unk_2AC = Matrix_GetCurrent()->yw; + } +} + +void func_80A2966C(Actor* thisx, PlayState* play) { + EnBigpamet* this = THIS; + + func_8012C28C(play->state.gfxCtx); + SkelAnime_DrawFlexOpa(play, this->skelAnime1.skeleton, this->skelAnime1.jointTable, this->skelAnime1.dListCount, + EnBigpamet_OverrideLimbDraw1, EnBigpamet_PostLimbDraw1, &this->actor); + func_80A292A8(this, play); +} diff --git a/src/overlays/actors/ovl_En_Bigpamet/z_en_bigpamet.h b/src/overlays/actors/ovl_En_Bigpamet/z_en_bigpamet.h index a37d331db..07d3265c0 100644 --- a/src/overlays/actors/ovl_En_Bigpamet/z_en_bigpamet.h +++ b/src/overlays/actors/ovl_En_Bigpamet/z_en_bigpamet.h @@ -2,18 +2,42 @@ #define Z_EN_BIGPAMET_H #include "global.h" +#include "objects/object_tl/object_tl.h" struct EnBigpamet; -typedef void (*EnBigpametActionFunc)(struct EnBigpamet*, GlobalContext*); +typedef void (*EnBigpametActionFunc)(struct EnBigpamet*, PlayState*); + +enum { + /* 0 */ ENBIGPAMET_0, + /* 1 */ ENBIGPAMET_1, +}; + +typedef struct { + /* 0x00 */ Vec3f unk_00; + /* 0x0C */ Vec3f unk_0C; + /* 0x18 */ Vec3s unk_18; + /* 0x20 */ f32 unk_20; +} EnBigpametStruct; // size = 0x24 typedef struct EnBigpamet { - /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x154]; - /* 0x0298 */ EnBigpametActionFunc actionFunc; - /* 0x029C */ char unk_29C[0x10]; - /* 0x02AC */ f32 unk_2AC; - /* 0x02B0 */ char unk_2B0[0x31C]; + /* 0x000 */ Actor actor; + /* 0x144 */ SkelAnime skelAnime2; + /* 0x188 */ Vec3s jointTable2[OBJECT_TL_2_LIMB_MAX]; + /* 0x1D6 */ Vec3s morphTable2[OBJECT_TL_2_LIMB_MAX]; + /* 0x224 */ SkelAnime skelAnime1; + /* 0x268 */ Vec3s jointTable1[OBJECT_TL_1_LIMB_MAX]; + /* 0x280 */ Vec3s morphTable1[OBJECT_TL_1_LIMB_MAX]; + /* 0x298 */ EnBigpametActionFunc actionFunc; + /* 0x29C */ u8 unk_29C; + /* 0x29E */ s16 unk_29E; + /* 0x2A0 */ UNK_TYPE1 pad2A0[2]; + /* 0x2A2 */ s16 unk_2A2; + /* 0x2A4 */ f32 unk_2A4; + /* 0x2A8 */ f32 unk_2A8; + /* 0x2AC */ f32 unk_2AC; + /* 0x2B0 */ ColliderCylinder collider; + /* 0x2FC */ EnBigpametStruct unk_2FC[20]; } EnBigpamet; // size = 0x5CC extern const ActorInit En_Bigpamet_InitVars; diff --git a/src/overlays/actors/ovl_En_Bigpo/z_en_bigpo.c b/src/overlays/actors/ovl_En_Bigpo/z_en_bigpo.c index 38ab1c5d2..8121db9e2 100644 --- a/src/overlays/actors/ovl_En_Bigpo/z_en_bigpo.c +++ b/src/overlays/actors/ovl_En_Bigpo/z_en_bigpo.c @@ -12,10 +12,10 @@ #define THIS ((EnBigpo*)thisx) -void EnBigpo_Init(Actor* thisx, GlobalContext* globalCtx); -void EnBigpo_Destroy(Actor* thisx, GlobalContext* globalCtx); -void EnBigpo_Update(Actor* thisx, GlobalContext* globalCtx); -void EnBigpo_UpdateFire(Actor* thisx, GlobalContext* globalCtx); +void EnBigpo_Init(Actor* thisx, PlayState* play); +void EnBigpo_Destroy(Actor* thisx, PlayState* play); +void EnBigpo_Update(Actor* thisx, PlayState* play); +void EnBigpo_UpdateFire(Actor* thisx, PlayState* play); void EnBigpo_InitWellBigpo(EnBigpo* this); void EnBigpo_HitStun(EnBigpo* this); @@ -25,62 +25,62 @@ void EnBigpo_InitHiddenFire(EnBigpo* this); void EnBigpo_SetupFireRevealed(EnBigpo* this); void EnBigpo_SetupSpawnCutscene(EnBigpo* this); -void EnBigpo_SpawnCutsceneStage1(EnBigpo* this, GlobalContext* globalCtx); -void EnBigpo_SpawnCutsceneStage2(EnBigpo* this, GlobalContext* globalCtx); +void EnBigpo_SpawnCutsceneStage1(EnBigpo* this, PlayState* play); +void EnBigpo_SpawnCutsceneStage2(EnBigpo* this, PlayState* play); void EnBigpo_SpawnCutsceneStage3(EnBigpo* this); -void EnBigpo_SpawnCutsceneStage4(EnBigpo* this, GlobalContext* globalCtx); +void EnBigpo_SpawnCutsceneStage4(EnBigpo* this, PlayState* play); void EnBigpo_SpawnCutsceneStage5(EnBigpo* this); -void EnBigpo_SpawnCutsceneStage6(EnBigpo* this, GlobalContext* globalCtx); +void EnBigpo_SpawnCutsceneStage6(EnBigpo* this, PlayState* play); void EnBigpo_SpawnCutsceneStage7(EnBigpo* this); -void EnBigpo_SpawnCutsceneStage8(EnBigpo* this, GlobalContext* globalCtx); +void EnBigpo_SpawnCutsceneStage8(EnBigpo* this, PlayState* play); -s32 EnBigpo_ApplyDamage(EnBigpo* this, GlobalContext* globalCtx); -void EnBigpo_LowerCutsceneSubCamera(EnBigpo* this, GlobalContext* globalCtx); -void EnBigpo_WellWaitForProximity(EnBigpo* this, GlobalContext* globalCtx); -void EnBigpo_WaitCutsceneQueue(EnBigpo* this, GlobalContext* globalCtx); +s32 EnBigpo_ApplyDamage(EnBigpo* this, PlayState* play); +void EnBigpo_LowerCutsceneSubCamera(EnBigpo* this, PlayState* play); +void EnBigpo_WellWaitForProximity(EnBigpo* this, PlayState* play); +void EnBigpo_WaitCutsceneQueue(EnBigpo* this, PlayState* play); void EnBigpo_SetupWarpOut(EnBigpo* this); -void EnBigpo_WarpingOut(EnBigpo* this, GlobalContext* globalCtx); -void EnBigpo_SetupWarpIn(EnBigpo* this, GlobalContext* globalCtx); -void EnBigpo_WarpingIn(EnBigpo* this, GlobalContext* globalCtx); +void EnBigpo_WarpingOut(EnBigpo* this, PlayState* play); +void EnBigpo_SetupWarpIn(EnBigpo* this, PlayState* play); +void EnBigpo_WarpingIn(EnBigpo* this, PlayState* play); void EnBigpo_SetupIdleFlying(EnBigpo* this); -void EnBigpo_IdleFlying(EnBigpo* this, GlobalContext* globalCtx); +void EnBigpo_IdleFlying(EnBigpo* this, PlayState* play); void EnBigpo_SetupSpinUp(EnBigpo* this); -void EnBigpo_SpinningUp(EnBigpo* this, GlobalContext* globalCtx); +void EnBigpo_SpinningUp(EnBigpo* this, PlayState* play); void EnBigpo_SetupSpinAttack(EnBigpo* this); -void EnBigpo_SpinAttack(EnBigpo* this, GlobalContext* globalCtx); +void EnBigpo_SpinAttack(EnBigpo* this, PlayState* play); void EnBigpo_SetupSpinDown(EnBigpo* this); -void EnBigpo_SpinningDown(EnBigpo* this, GlobalContext* globalCtx); -void EnBigpo_CheckHealth(EnBigpo* this, GlobalContext* globalCtx); +void EnBigpo_SpinningDown(EnBigpo* this, PlayState* play); +void EnBigpo_CheckHealth(EnBigpo* this, PlayState* play); void EnBigpo_SetupDeath(EnBigpo* this); -void EnBigpo_BurnAwayDeath(EnBigpo* this, GlobalContext* globalCtx); -void EnBigpo_SetupLanternDrop(EnBigpo* this, GlobalContext* globalCtx); -void EnBigpo_LanternFalling(EnBigpo* this, GlobalContext* globalCtx); +void EnBigpo_BurnAwayDeath(EnBigpo* this, PlayState* play); +void EnBigpo_SetupLanternDrop(EnBigpo* this, PlayState* play); +void EnBigpo_LanternFalling(EnBigpo* this, PlayState* play); void EnBigpo_SpawnScoopSoul(EnBigpo* this); -void EnBigpo_ScoopSoulAppearing(EnBigpo* this, GlobalContext* globalCtx); +void EnBigpo_ScoopSoulAppearing(EnBigpo* this, PlayState* play); void EnBigpo_SetupScoopSoulIdle(EnBigpo* this); -void EnBigpo_ScoopSoulIdle(EnBigpo* this, GlobalContext* globalCtx); +void EnBigpo_ScoopSoulIdle(EnBigpo* this, PlayState* play); void EnBigpo_SetupScoopSoulLeaving(EnBigpo* this); -void EnBigpo_ScoopSoulFadingAway(EnBigpo* this, GlobalContext* globalCtx); -void EnBigpo_Die(EnBigpo* this, GlobalContext* globalCtx); -void EnBigpo_SelectRandomFireLocations(EnBigpo* this, GlobalContext* globalCtx); -void EnBigpo_FireCounting(EnBigpo* this, GlobalContext* globalCtx); -void EnBigpo_SetupFlameCirclePositions(EnBigpo* this, GlobalContext* globalCtx); +void EnBigpo_ScoopSoulFadingAway(EnBigpo* this, PlayState* play); +void EnBigpo_Die(EnBigpo* this, PlayState* play); +void EnBigpo_SelectRandomFireLocations(EnBigpo* this, PlayState* play); +void EnBigpo_FireCounting(EnBigpo* this, PlayState* play); +void EnBigpo_SetupFlameCirclePositions(EnBigpo* this, PlayState* play); void EnBigpo_SetupFlameCircleCutscene(EnBigpo* this); -void EnBigpo_FlameCircleCutscene(EnBigpo* this, GlobalContext* globalCtx); +void EnBigpo_FlameCircleCutscene(EnBigpo* this, PlayState* play); void EnBigpo_UpdateColor(EnBigpo* this); void EnBigpo_FlickerLanternLight(EnBigpo* this); void EnBigpo_SetupRevealedFireIdle(EnBigpo* this); -void EnBigpo_RevealedFireIdle(EnBigpo* this, GlobalContext* globalCtx); -void EnBigpo_DoNothing(EnBigpo* this, GlobalContext* globalCtx); -void EnBigpo_WaitingForDampe(EnBigpo* this, GlobalContext* globalCtx); -void EnBigpo_RevealedFireGrowing(EnBigpo* this, GlobalContext* globalCtx); +void EnBigpo_RevealedFireIdle(EnBigpo* this, PlayState* play); +void EnBigpo_DoNothing(EnBigpo* this, PlayState* play); +void EnBigpo_WaitingForDampe(EnBigpo* this, PlayState* play); +void EnBigpo_RevealedFireGrowing(EnBigpo* this, PlayState* play); // draw funcs -void EnBigpo_DrawMainBigpo(Actor* thisx, GlobalContext* globalCtx); -void EnBigpo_DrawScoopSoul(Actor* thisx, GlobalContext* globalCtx); -void EnBigpo_DrawLantern(Actor* thisx, GlobalContext* globalCtx); -void EnBigpo_DrawCircleFlames(Actor* thisx, GlobalContext* globalCtx); -void EnBigpo_RevealedFire(Actor* thisx, GlobalContext* globalCtx); +void EnBigpo_DrawMainBigpo(Actor* thisx, PlayState* play); +void EnBigpo_DrawScoopSoul(Actor* thisx, PlayState* play); +void EnBigpo_DrawLantern(Actor* thisx, PlayState* play); +void EnBigpo_DrawCircleFlames(Actor* thisx, PlayState* play); +void EnBigpo_RevealedFire(Actor* thisx, PlayState* play); extern const ActorInit En_Bigpo_InitVars; @@ -173,19 +173,18 @@ static Vec3f D_80B65084[] = { { -1000.0f, 1500.0f, 2000.0f }, }; -void EnBigpo_Init(Actor* thisx, GlobalContext* globalCtx2) { - GlobalContext* globalCtx = globalCtx2; +void EnBigpo_Init(Actor* thisx, PlayState* play2) { + PlayState* play = play2; EnBigpo* this = THIS; EnBigpoFireEffect* firesPtr; s32 i; Actor_ProcessInitChain(&this->actor, sInitChain); - // thisx req to match - this->switchFlags = GET_BIGPO_SWITCHFLAGS(thisx); + this->switchFlags = BIGPO_GET_SWITCHFLAGS(thisx); thisx->params &= 0xFF; if (thisx->params == ENBIGPO_POSSIBLEFIRE) { - if (Flags_GetSwitch(globalCtx, this->switchFlags)) { + if (Flags_GetSwitch(play, this->switchFlags)) { Actor_MarkForDeath(&this->actor); } else { thisx->update = Actor_Noop; @@ -194,14 +193,14 @@ void EnBigpo_Init(Actor* thisx, GlobalContext* globalCtx2) { return; } - SkelAnime_Init(globalCtx, &this->skelAnime, &gBigpoSkeleton, &gBigpoFloatAnim, this->jointTable, this->morphTable, + SkelAnime_Init(play, &this->skelAnime, &gBigpoSkeleton, &gBigpoFloatAnim, this->jointTable, this->morphTable, ENBIGPO_LIMBCOUNT); - Collider_InitAndSetCylinder(globalCtx, &this->collider, &this->actor, &sCylinderInit); + Collider_InitAndSetCylinder(play, &this->collider, &this->actor, &sCylinderInit); CollisionCheck_SetInfo(&thisx->colChkInfo, &sDamageTable, &sColChkInfoInit); for (i = 0; i < ARRAY_COUNT(this->fires); i++) { firesPtr = &this->fires[i]; - firesPtr->light = LightContext_InsertLight(globalCtx, &globalCtx->lightCtx, &firesPtr->info); + firesPtr->light = LightContext_InsertLight(play, &play->lightCtx, &firesPtr->info); Lights_PointNoGlowSetInfo(&firesPtr->info, thisx->home.pos.x, thisx->home.pos.y, thisx->home.pos.z, 255, 255, 255, 0); @@ -215,7 +214,7 @@ void EnBigpo_Init(Actor* thisx, GlobalContext* globalCtx2) { this->mainColor.b = 210; this->mainColor.a = 0; // fully invisible - if ((this->switchFlags != 0xFF) && (Flags_GetSwitch(globalCtx, this->switchFlags))) { + if ((this->switchFlags != 0xFF) && (Flags_GetSwitch(play, this->switchFlags))) { Actor_MarkForDeath(&this->actor); } @@ -228,8 +227,8 @@ void EnBigpo_Init(Actor* thisx, GlobalContext* globalCtx2) { } } -void EnBigpo_Destroy(Actor* thisx, GlobalContext* globalCtx2) { - GlobalContext* globalCtx = globalCtx2; +void EnBigpo_Destroy(Actor* thisx, PlayState* play2) { + PlayState* play = play2; EnBigpo* this = THIS; s32 fireCount; @@ -238,9 +237,9 @@ void EnBigpo_Destroy(Actor* thisx, GlobalContext* globalCtx2) { // if NOT a fire type, *ENBIGPO_REGULAR and ENBIGPO_SUMMONED (combat types only) if (1) {} for (fireCount = 0; fireCount < ARRAY_COUNT(this->fires); fireCount++) { - LightContext_RemoveLight(globalCtx, &globalCtx->lightCtx, this->fires[fireCount].light); + LightContext_RemoveLight(play, &play->lightCtx, this->fires[fireCount].light); } - Collider_DestroyCylinder(globalCtx, &this->collider); + Collider_DestroyCylinder(play, &this->collider); } } @@ -268,17 +267,17 @@ void EnBigpo_UpdateSpin(EnBigpo* this) { /* * Lowers the position/eye of the camera during the Big Poe spawn cutscene */ -void EnBigpo_LowerCutsceneSubCamera(EnBigpo* this, GlobalContext* globalContext) { +void EnBigpo_LowerCutsceneSubCamera(EnBigpo* this, PlayState* play) { Camera* subCam; - if (this->cutsceneSubCamId != CAM_ID_MAIN) { - subCam = Play_GetCamera(globalContext, this->cutsceneSubCamId); + if (this->subCamId != SUB_CAM_ID_DONE) { + subCam = Play_GetCamera(play, this->subCamId); subCam->eye.y -= this->actor.velocity.y; if (this->actor.velocity.y > 0.0f) { subCam->eye.x -= 1.5f * Math_SinS(this->actor.yawTowardsPlayer); subCam->eye.z -= 1.5f * Math_CosS(this->actor.yawTowardsPlayer); } - Play_CameraSetAtEye(globalContext, this->cutsceneSubCamId, &this->actor.focus.pos, &subCam->eye); + Play_SetCameraAtEye(play, this->subCamId, &this->actor.focus.pos, &subCam->eye); } } @@ -288,7 +287,7 @@ void EnBigpo_InitWellBigpo(EnBigpo* this) { this->fireRadius = 200.0f; } -void EnBigpo_WellWaitForProximity(EnBigpo* this, GlobalContext* globalCtx) { +void EnBigpo_WellWaitForProximity(EnBigpo* this, PlayState* play) { if (this->actor.xzDistToPlayer < 200.0f) { EnBigpo_SetupSpawnCutscene(this); } @@ -299,15 +298,15 @@ void EnBigpo_SetupSpawnCutscene(EnBigpo* this) { this->actionFunc = EnBigpo_WaitCutsceneQueue; } -void EnBigpo_WaitCutsceneQueue(EnBigpo* this, GlobalContext* globalCtx) { +void EnBigpo_WaitCutsceneQueue(EnBigpo* this, PlayState* play) { if (ActorCutscene_GetCanPlayNext(this->actor.cutscene)) { ActorCutscene_Start(this->actor.cutscene, &this->actor); - func_800B724C(globalCtx, &this->actor, 7); - this->cutsceneSubCamId = ActorCutscene_GetCurrentCamera(this->actor.cutscene); + func_800B724C(play, &this->actor, 7); + this->subCamId = ActorCutscene_GetCurrentSubCamId(this->actor.cutscene); if (this->actor.params == ENBIGPO_REGULAR) { // and SUMMONED, got switched earlier - EnBigpo_SpawnCutsceneStage1(this, globalCtx); + EnBigpo_SpawnCutsceneStage1(this, play); } else { // ENBIGPO_REVEALEDFIRE - EnBigpo_SetupFlameCirclePositions(this, globalCtx); + EnBigpo_SetupFlameCirclePositions(this, play); } } else { ActorCutscene_SetIntentToPlay(this->actor.cutscene); @@ -317,7 +316,7 @@ void EnBigpo_WaitCutsceneQueue(EnBigpo* this, GlobalContext* globalCtx) { /* * stage 1: fires are set to draw, size set to tiny, camera pointed */ -void EnBigpo_SpawnCutsceneStage1(EnBigpo* this, GlobalContext* globalCtx) { +void EnBigpo_SpawnCutsceneStage1(EnBigpo* this, PlayState* play) { s32 i; this->actor.draw = EnBigpo_DrawCircleFlames; @@ -332,13 +331,13 @@ void EnBigpo_SpawnCutsceneStage1(EnBigpo* this, GlobalContext* globalCtx) { this->actor.scale.y = 0.015f; this->actor.scale.z = 0.0f; - if (this->cutsceneSubCamId != CAM_ID_MAIN) { + if (this->subCamId != SUB_CAM_ID_DONE) { Vec3f subCamEye; subCamEye.x = ((this->actor.world.pos.x - this->fires[0].pos.x) * 1.8f) + this->actor.world.pos.x; subCamEye.y = this->actor.world.pos.y + 150.0f; subCamEye.z = ((this->actor.world.pos.z - this->fires[0].pos.z) * 1.8f) + this->actor.world.pos.z; - Play_CameraSetAtEye(globalCtx, this->cutsceneSubCamId, &this->actor.focus.pos, &subCamEye); + Play_SetCameraAtEye(play, this->subCamId, &this->actor.focus.pos, &subCamEye); } this->actionFunc = EnBigpo_SpawnCutsceneStage2; } @@ -346,7 +345,7 @@ void EnBigpo_SpawnCutsceneStage1(EnBigpo* this, GlobalContext* globalCtx) { /* * stage 2: fires are growing to full size */ -void EnBigpo_SpawnCutsceneStage2(EnBigpo* this, GlobalContext* globalCtx) { +void EnBigpo_SpawnCutsceneStage2(EnBigpo* this, PlayState* play) { if (Math_StepToF(&this->actor.scale.x, 0.01f, 0.001f)) { EnBigpo_SpawnCutsceneStage3(this); } @@ -367,7 +366,7 @@ void EnBigpo_SpawnCutsceneStage3(EnBigpo* this) { /* * stage 4: fires are circling inward toward each other */ -void EnBigpo_SpawnCutsceneStage4(EnBigpo* this, GlobalContext* globalCtx) { +void EnBigpo_SpawnCutsceneStage4(EnBigpo* this, PlayState* play) { s32 i; if (Math_StepToF(&this->fireRadius, 30.0f, 5.0f)) { @@ -383,7 +382,7 @@ void EnBigpo_SpawnCutsceneStage4(EnBigpo* this, GlobalContext* globalCtx) { } this->actor.world.pos.y += this->actor.velocity.y; - EnBigpo_LowerCutsceneSubCamera(this, globalCtx); + EnBigpo_LowerCutsceneSubCamera(this, play); if (this->actor.velocity.y >= 4.0f) { EnBigpo_SpawnCutsceneStage5(this); } @@ -405,7 +404,7 @@ void EnBigpo_SpawnCutsceneStage5(EnBigpo* this) { * stage 6: big poe becoming more visible in the flames * and flames dissapearing */ -void EnBigpo_SpawnCutsceneStage6(EnBigpo* this, GlobalContext* globalCtx) { +void EnBigpo_SpawnCutsceneStage6(EnBigpo* this, PlayState* play) { s32 i; s32 alphaPlus; // color alpha + 10 @@ -426,7 +425,7 @@ void EnBigpo_SpawnCutsceneStage6(EnBigpo* this, GlobalContext* globalCtx) { this->fires[i].pos.y += this->actor.velocity.y; } - EnBigpo_LowerCutsceneSubCamera(this, globalCtx); + EnBigpo_LowerCutsceneSubCamera(this, play); if (alphaPlus >= 255) { this->mainColor.a = 255; // fully visible EnBigpo_SpawnCutsceneStage7(this); @@ -452,18 +451,18 @@ void EnBigpo_SpawnCutsceneStage7(EnBigpo* this) { * also sets the main camera to align with the subCamera * and switches back from the subCamera back to the main camera */ -void EnBigpo_SpawnCutsceneStage8(EnBigpo* this, GlobalContext* globalCtx) { +void EnBigpo_SpawnCutsceneStage8(EnBigpo* this, PlayState* play) { Actor* dampe; Camera* subCam; SkelAnime_Update(&this->skelAnime); this->idleTimer--; if (this->idleTimer == 0) { - subCam = Play_GetCamera(globalCtx, this->cutsceneSubCamId); - Play_CameraSetAtEye(globalCtx, CAM_ID_MAIN, &subCam->at, &subCam->eye); - this->cutsceneSubCamId = CAM_ID_MAIN; + subCam = Play_GetCamera(play, this->subCamId); + Play_SetCameraAtEye(play, CAM_ID_MAIN, &subCam->at, &subCam->eye); + this->subCamId = SUB_CAM_ID_DONE; if (this->actor.params == ENBIGPO_SUMMONED) { - dampe = SubS_FindActor(globalCtx, NULL, ACTORCAT_NPC, ACTOR_EN_TK); + dampe = SubS_FindActor(play, NULL, ACTORCAT_NPC, ACTOR_EN_TK); if (dampe != NULL) { // if dampe exists, switch to viewing his running away cutscene dampe->params = this->actor.cutscene; @@ -473,7 +472,7 @@ void EnBigpo_SpawnCutsceneStage8(EnBigpo* this, GlobalContext* globalCtx) { } else { // ENBIGPO_REGULAR ActorCutscene_Stop(this->actor.cutscene); } - func_800B724C(globalCtx, &this->actor, 6); + func_800B724C(play, &this->actor, 6); EnBigpo_SetupIdleFlying(this); // setup idle flying } } @@ -489,7 +488,7 @@ void EnBigpo_SetupWarpOut(EnBigpo* this) { this->actionFunc = EnBigpo_WarpingOut; } -void EnBigpo_WarpingOut(EnBigpo* this, GlobalContext* globalCtx) { +void EnBigpo_WarpingOut(EnBigpo* this, PlayState* play) { DECR(this->idleTimer); this->actor.shape.rot.y += this->rotVelocity; if (this->idleTimer < 16) { @@ -498,14 +497,14 @@ void EnBigpo_WarpingOut(EnBigpo* this, GlobalContext* globalCtx) { this->mainColor.a = this->idleTimer * (255.0f / 32.0f); if (this->idleTimer == 0) { this->mainColor.a = 0; // fully invisible - EnBigpo_SetupWarpIn(this, globalCtx); + EnBigpo_SetupWarpIn(this, play); } } -void EnBigpo_SetupWarpIn(EnBigpo* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); +void EnBigpo_SetupWarpIn(EnBigpo* this, PlayState* play) { + Player* player = GET_PLAYER(play); 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); @@ -515,7 +514,7 @@ void EnBigpo_SetupWarpIn(EnBigpo* this, GlobalContext* globalCtx) { this->actionFunc = EnBigpo_WarpingIn; } -void EnBigpo_WarpingIn(EnBigpo* this, GlobalContext* globalCtx) { +void EnBigpo_WarpingIn(EnBigpo* this, PlayState* play) { this->idleTimer++; this->actor.shape.rot.y -= this->rotVelocity; if (this->idleTimer >= 16) { @@ -548,8 +547,8 @@ void EnBigpo_SetupIdleFlying(EnBigpo* this) { this->actionFunc = EnBigpo_IdleFlying; } -void EnBigpo_IdleFlying(EnBigpo* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); +void EnBigpo_IdleFlying(EnBigpo* this, PlayState* play) { + Player* player = GET_PLAYER(play); SkelAnime_Update(&this->skelAnime); DECR(this->idleTimer); @@ -565,7 +564,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; @@ -585,7 +584,7 @@ void EnBigpo_SetupSpinUp(EnBigpo* this) { this->actor.speedXZ = 0.0f; } -void EnBigpo_SpinningUp(EnBigpo* this, GlobalContext* globalCtx) { +void EnBigpo_SpinningUp(EnBigpo* this, PlayState* play) { SkelAnime_Update(&this->skelAnime); this->rotVelocity += 0x200; EnBigpo_UpdateSpin(this); @@ -600,8 +599,8 @@ void EnBigpo_SetupSpinAttack(EnBigpo* this) { this->actionFunc = EnBigpo_SpinAttack; } -void EnBigpo_SpinAttack(EnBigpo* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); +void EnBigpo_SpinAttack(EnBigpo* this, PlayState* play) { + Player* player = GET_PLAYER(play); s16 yawDiff; SkelAnime_Update(&this->skelAnime); @@ -625,8 +624,8 @@ void EnBigpo_SetupSpinDown(EnBigpo* this) { this->actionFunc = EnBigpo_SpinningDown; } -void EnBigpo_SpinningDown(EnBigpo* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); +void EnBigpo_SpinningDown(EnBigpo* this, PlayState* play) { + Player* player = GET_PLAYER(play); SkelAnime_Update(&this->skelAnime); Math_SmoothStepToF(&this->actor.world.pos.y, player->actor.world.pos.y + 100.0f, 0.3f, 5.0f, 1.0f); @@ -657,7 +656,7 @@ void EnBigpo_HitStun(EnBigpo* this) { /* * check if just damaged or dead */ -void EnBigpo_CheckHealth(EnBigpo* this, GlobalContext* globalCtx) { +void EnBigpo_CheckHealth(EnBigpo* this, PlayState* play) { Math_StepToF(&this->actor.speedXZ, 0.0f, 0.5f); if (SkelAnime_Update(&this->skelAnime)) { if (this->actor.colChkInfo.health == 0) { @@ -680,7 +679,7 @@ void EnBigpo_SetupDeath(EnBigpo* this) { /* * from [red damaged poe] to [burning up poe] to [shinking into the lantern] */ -void EnBigpo_BurnAwayDeath(EnBigpo* this, GlobalContext* globalCtx) { +void EnBigpo_BurnAwayDeath(EnBigpo* this, PlayState* play) { Vec3f tempVec; f32 unkTemp2; // dont really know what these unktemps are doing s16 camYaw; @@ -689,7 +688,7 @@ void EnBigpo_BurnAwayDeath(EnBigpo* this, GlobalContext* globalCtx) { this->idleTimer++; if (this->idleTimer < 8) { - camYaw = Camera_GetCamDirYaw(GET_ACTIVE_CAM(globalCtx)) + 0x4800; + camYaw = Camera_GetCamDirYaw(GET_ACTIVE_CAM(play)) + 0x4800; if (this->idleTimer < 5) { unkTemp = (this->idleTimer << 0xC) - 0x4000; // 1.4.0...1 is NOT 1.4, the rodata demands it @@ -706,16 +705,16 @@ void EnBigpo_BurnAwayDeath(EnBigpo* this, GlobalContext* globalCtx) { // not sure what we're turning this into, but its based on the timer modifiedTimer = ((f32)((this->idleTimer * 10) + 80) * 1.4000001f); - func_800B3030(globalCtx, &tempVec, &D_80B6506C, &gZeroVec3f, modifiedTimer, 0, 2); + func_800B3030(play, &tempVec, &D_80B6506C, &gZeroVec3f, modifiedTimer, 0, 2); tempVec.x = (2.0f * this->actor.world.pos.x) - tempVec.x; tempVec.z = (2.0f * this->actor.world.pos.z) - tempVec.z; - func_800B3030(globalCtx, &tempVec, &D_80B6506C, &gZeroVec3f, modifiedTimer, 0, 2); + func_800B3030(play, &tempVec, &D_80B6506C, &gZeroVec3f, modifiedTimer, 0, 2); tempVec.x = this->actor.world.pos.x; tempVec.z = this->actor.world.pos.z; - func_800B3030(globalCtx, &tempVec, &D_80B6506C, &gZeroVec3f, modifiedTimer, 0, 2); + func_800B3030(play, &tempVec, &D_80B6506C, &gZeroVec3f, modifiedTimer, 0, 2); } else if (this->idleTimer >= 28) { - EnBigpo_SetupLanternDrop(this, globalCtx); + EnBigpo_SetupLanternDrop(this, play); } else if (this->idleTimer >= 19) { this->actor.scale.x = ((28 - this->idleTimer) * 0.014f) * 0.1f; @@ -731,12 +730,12 @@ void EnBigpo_BurnAwayDeath(EnBigpo* this, GlobalContext* globalCtx) { } } -void EnBigpo_SetupLanternDrop(EnBigpo* this, GlobalContext* globalCtx) { +void EnBigpo_SetupLanternDrop(EnBigpo* this, PlayState* play) { 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; @@ -744,19 +743,19 @@ void EnBigpo_SetupLanternDrop(EnBigpo* this, GlobalContext* globalCtx) { this->actor.shape.rot.x = -0x8000; this->actor.velocity.y = 0.0f; this->actor.world.pos.y -= 15.0f; - func_800BC154(globalCtx, &globalCtx->actorCtx, &this->actor, ACTORCAT_MISC); + func_800BC154(play, &play->actorCtx, &this->actor, ACTORCAT_MISC); this->actor.flags &= ~(ACTOR_FLAG_1 | ACTOR_FLAG_4); // targetable OFF, enemy music OFF this->actor.bgCheckFlags &= ~0x400; this->actionFunc = EnBigpo_LanternFalling; } -void EnBigpo_LanternFalling(EnBigpo* this, GlobalContext* globalCtx) { +void EnBigpo_LanternFalling(EnBigpo* this, PlayState* play) { if (this->actor.bgCheckFlags & 1 || this->actor.floorHeight == BGCHECK_Y_MIN) { if (this->switchFlags != 0xFF) { - Flags_SetSwitch(globalCtx, this->switchFlags); + Flags_SetSwitch(play, this->switchFlags); } - EffectSsHahen_SpawnBurst(globalCtx, &this->actor.world.pos, 6.0f, 0, 1, 1, 15, OBJECT_BIGPO, 10, + EffectSsHahen_SpawnBurst(play, &this->actor.world.pos, 6.0f, 0, 1, 1, 15, OBJECT_BIGPO, 10, gBigpoDrawLanternFallingDL); EnBigpo_SpawnScoopSoul(this); } @@ -775,7 +774,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); @@ -802,7 +800,7 @@ void EnBigpo_SpawnScoopSoul(EnBigpo* this) { this->actionFunc = EnBigpo_ScoopSoulAppearing; } -void EnBigpo_ScoopSoulAppearing(EnBigpo* this, GlobalContext* globalCtx) { +void EnBigpo_ScoopSoulAppearing(EnBigpo* this, PlayState* play) { this->savedHeight += 2.0f; EnBigpo_AdjustPoAlpha(this, 20); // increase visibility if (this->mainColor.a == 255) { // fully visible @@ -818,16 +816,16 @@ void EnBigpo_SetupScoopSoulIdle(EnBigpo* this) { this->actionFunc = EnBigpo_ScoopSoulIdle; } -void EnBigpo_ScoopSoulIdle(EnBigpo* this, GlobalContext* globalCtx) { +void EnBigpo_ScoopSoulIdle(EnBigpo* this, PlayState* play) { DECR(this->idleTimer); - if (Actor_HasParent(&this->actor, globalCtx)) { + if (Actor_HasParent(&this->actor, play)) { Actor_MarkForDeath(&this->actor); } else if (this->idleTimer == 0) { // took too long, soul is leaving Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_PO_LAUGH); EnBigpo_SetupScoopSoulLeaving(this); } else { - Actor_PickUp(&this->actor, globalCtx, GI_MAX, 35.0f, 60.0f); + Actor_PickUp(&this->actor, play, GI_MAX, 35.0f, 60.0f); this->actor.world.pos.y = (sin_rad(this->idleTimer * (M_PI / 20)) * 5.0f) + this->savedHeight; } } @@ -837,7 +835,7 @@ void EnBigpo_SetupScoopSoulLeaving(EnBigpo* this) { this->actionFunc = EnBigpo_ScoopSoulFadingAway; } -void EnBigpo_ScoopSoulFadingAway(EnBigpo* this, GlobalContext* globalCtx) { +void EnBigpo_ScoopSoulFadingAway(EnBigpo* this, PlayState* play) { EnBigpo_AdjustPoAlpha(this, -13); if (this->mainColor.a == 0) { // fully invisible Actor_MarkForDeath(&this->actor); @@ -852,7 +850,7 @@ void EnBigpo_InitDampeMainPo(EnBigpo* this) { /* * dampe fires are in 3/N random locations, here we pick them randomly */ -void EnBigpo_SelectRandomFireLocations(EnBigpo* this, GlobalContext* globalCtx) { +void EnBigpo_SelectRandomFireLocations(EnBigpo* this, PlayState* play) { Actor* enemyPtr; EnBigpo* randomFirePo; s32 fireIndex; @@ -860,7 +858,7 @@ void EnBigpo_SelectRandomFireLocations(EnBigpo* this, GlobalContext* globalCtx) s32 fireCount = 0; // count the number of possible fires we can find (4 in vanilla) - for (enemyPtr = GET_FIRST_ENEMY(globalCtx); enemyPtr != NULL; enemyPtr = enemyPtr->next) { + for (enemyPtr = GET_FIRST_ENEMY(play); enemyPtr != NULL; enemyPtr = enemyPtr->next) { if (enemyPtr->id == ACTOR_EN_BIGPO && enemyPtr->params == ENBIGPO_POSSIBLEFIRE) { fireCount++; } @@ -870,7 +868,7 @@ void EnBigpo_SelectRandomFireLocations(EnBigpo* this, GlobalContext* globalCtx) if (fireCount < ARRAY_COUNT(this->fires)) { this->actor.draw = EnBigpo_DrawMainBigpo; Actor_SetScale(&this->actor, 0.014f); - EnBigpo_SetupWarpIn(this, globalCtx); + EnBigpo_SetupWarpIn(this, play); Math_Vec3f_Copy(&this->actor.world.pos, &this->actor.home.pos); this->actor.world.pos.y += 100.0f; return; @@ -878,7 +876,7 @@ void EnBigpo_SelectRandomFireLocations(EnBigpo* this, GlobalContext* globalCtx) // for available possiblefires, pick three to be random fires for (fireIndex = 0; fireIndex < ARRAY_COUNT(this->fires); fireIndex++, fireCount--) { - enemyPtr = GET_FIRST_ENEMY(globalCtx); + enemyPtr = GET_FIRST_ENEMY(play); randomIndex = ((s32)Rand_ZeroFloat(fireCount)) % fireCount; while (enemyPtr != NULL) { @@ -889,7 +887,7 @@ void EnBigpo_SelectRandomFireLocations(EnBigpo* this, GlobalContext* globalCtx) Math_Vec3f_Copy(&this->fires[fireIndex].pos, &randomFirePo->actor.world.pos); randomFirePo->actor.parent = (Actor*)this; randomFirePo->actor.update = EnBigpo_UpdateFire; - func_800BC154(globalCtx, &globalCtx->actorCtx, &randomFirePo->actor, ACTORCAT_PROP); + func_800BC154(play, &play->actorCtx, &randomFirePo->actor, ACTORCAT_PROP); randomFirePo->unk20C = fireIndex; randomFirePo->actor.flags &= ~ACTOR_FLAG_1; // targetable OFF // make invisible by size: 0 @@ -911,7 +909,7 @@ void EnBigpo_SelectRandomFireLocations(EnBigpo* this, GlobalContext* globalCtx) } // remove unused fires - for (enemyPtr = GET_FIRST_ENEMY(globalCtx); enemyPtr != NULL; enemyPtr = enemyPtr->next) { + for (enemyPtr = GET_FIRST_ENEMY(play); enemyPtr != NULL; enemyPtr = enemyPtr->next) { if (enemyPtr->id == ACTOR_EN_BIGPO && enemyPtr->params == ENBIGPO_POSSIBLEFIRE) { randomFirePo = (EnBigpo*)enemyPtr; randomFirePo->actionFunc = EnBigpo_Die; @@ -930,7 +928,7 @@ void EnBigpo_ChangeToFireCounting(EnBigpo* this) { * count fires already found by Dampe, * once enough: spawn big poe for fight */ -void EnBigpo_FireCounting(EnBigpo* this, GlobalContext* globalCtx) { +void EnBigpo_FireCounting(EnBigpo* this, PlayState* play) { EnBigpo* firePo; s32 activatedFireCount = 0; @@ -945,7 +943,7 @@ void EnBigpo_FireCounting(EnBigpo* this, GlobalContext* globalCtx) { } } -void EnBigpo_SetupFlameCirclePositions(EnBigpo* this, GlobalContext* globalCtx) { +void EnBigpo_SetupFlameCirclePositions(EnBigpo* this, PlayState* play) { EnBigpo* firePo; Vec3f subCamEye; @@ -954,18 +952,17 @@ void EnBigpo_SetupFlameCirclePositions(EnBigpo* this, GlobalContext* globalCtx) EnBigpo_SetupFlameCircleCutscene(firePo); } - // Setup sub camera - if (this->cutsceneSubCamId != CAM_ID_MAIN) { + if (this->subCamId != SUB_CAM_ID_DONE) { subCamEye.x = (Math_SinS(this->actor.yawTowardsPlayer) * 360.0f) + this->actor.world.pos.x; subCamEye.y = this->actor.world.pos.y + 150.0f; subCamEye.z = (Math_CosS(this->actor.yawTowardsPlayer) * 360.0f) + this->actor.world.pos.z; - Play_CameraSetAtEye(globalCtx, this->cutsceneSubCamId, &this->actor.focus.pos, &subCamEye); + Play_SetCameraAtEye(play, this->subCamId, &this->actor.focus.pos, &subCamEye); } this->actionFunc = EnBigpo_DoNothing; } -void EnBigpo_DoNothing(EnBigpo* this, GlobalContext* globalCtx) { +void EnBigpo_DoNothing(EnBigpo* this, PlayState* play) { } void EnBigpo_InitHiddenFire(EnBigpo* this) { @@ -977,13 +974,13 @@ void EnBigpo_InitHiddenFire(EnBigpo* this) { * idle until dampe finds this file by * changing this file params from ENBIGPO_POSSIBLEFIRE into ENBIGPO_REVEALEDFIRE */ -void EnBigpo_WaitingForDampe(EnBigpo* this, GlobalContext* globalCtx) { +void EnBigpo_WaitingForDampe(EnBigpo* this, PlayState* play) { if (this->actor.params == ENBIGPO_REVEALEDFIRE) { EnBigpo_SetupFireRevealed(this); } } -void EnBigpo_Die(EnBigpo* this, GlobalContext* globalCtx) { +void EnBigpo_Die(EnBigpo* this, PlayState* play) { Actor_MarkForDeath(&this->actor); } @@ -993,7 +990,7 @@ void EnBigpo_SetupFireRevealed(EnBigpo* this) { this->actionFunc = EnBigpo_RevealedFireGrowing; } -void EnBigpo_RevealedFireGrowing(EnBigpo* this, GlobalContext* globalCtx) { +void EnBigpo_RevealedFireGrowing(EnBigpo* this, PlayState* play) { if (Math_StepToF(&this->actor.scale.x, 0.01f, 0.0005f)) { this->idleTimer--; if (this->idleTimer == 0) { @@ -1009,7 +1006,7 @@ void EnBigpo_SetupRevealedFireIdle(EnBigpo* this) { this->actionFunc = EnBigpo_RevealedFireIdle; } -void EnBigpo_RevealedFireIdle(EnBigpo* this, GlobalContext* globalCtx) { +void EnBigpo_RevealedFireIdle(EnBigpo* this, PlayState* play) { if (this->idleTimer > 0) { if (this->idleTimer == 0) { //! @bug: unreachable code @@ -1039,14 +1036,14 @@ void EnBigpo_SetupFlameCircleCutscene(EnBigpo* this) { /* * every frame, swirl the flames toward big poe as summoned */ -void EnBigpo_FlameCircleCutscene(EnBigpo* this, GlobalContext* globalCtx) { +void EnBigpo_FlameCircleCutscene(EnBigpo* this, PlayState* play) { Vec3f posDiff; f32 magnitude; this->idleTimer--; if (this->idleTimer == 0) { EnBigpo* parentPoh = (EnBigpo*)this->actor.parent; - Flags_SetSwitch(globalCtx, this->switchFlags); + Flags_SetSwitch(play, this->switchFlags); Math_Vec3f_Copy(&parentPoh->fires[this->unk20C].pos, &this->actor.world.pos); Actor_MarkForDeath(&this->actor); if (this->unk20C == 0) { @@ -1114,7 +1111,7 @@ void EnBigpo_FlickerLanternLight(EnBigpo* this) { this->lanternColor.a = ((s32)(rand * 30.0f)) + 220; } -s32 EnBigpo_ApplyDamage(EnBigpo* this, GlobalContext* globalCtx) { +s32 EnBigpo_ApplyDamage(EnBigpo* this, PlayState* play) { if ((this->collider.base.acFlags & AC_HIT) && !(this->collider.base.acFlags & AC_HARD)) { this->collider.base.acFlags &= ~AC_HIT; @@ -1125,7 +1122,7 @@ s32 EnBigpo_ApplyDamage(EnBigpo* this, GlobalContext* globalCtx) { if (Actor_ApplyDamage(&this->actor) == 0) { this->actor.flags &= ~ACTOR_FLAG_1; // targetable OFF Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_PO_DEAD); - Enemy_StartFinishingBlow(globalCtx, &this->actor); + Enemy_StartFinishingBlow(play, &this->actor); if (this->actor.params == ENBIGPO_SUMMONED) { // dampe type func_801A2ED8(); } @@ -1137,7 +1134,7 @@ s32 EnBigpo_ApplyDamage(EnBigpo* this, GlobalContext* globalCtx) { if (this->actor.colChkInfo.damageEffect == 4) { this->drawDmgEffAlpha = 4.0f; this->drawDmgEffScale = 1.0f; - Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_CLEAR_TAG, this->collider.info.bumper.hitPos.x, + Actor_Spawn(&play->actorCtx, play, ACTOR_EN_CLEAR_TAG, this->collider.info.bumper.hitPos.x, this->collider.info.bumper.hitPos.y, this->collider.info.bumper.hitPos.z, 0, 0, 0, CLEAR_TAG_LARGE_LIGHT_RAYS); } @@ -1147,7 +1144,7 @@ s32 EnBigpo_ApplyDamage(EnBigpo* this, GlobalContext* globalCtx) { return false; } -void EnBigpo_Update(Actor* thisx, GlobalContext* globalCtx) { +void EnBigpo_Update(Actor* thisx, PlayState* play) { EnBigpo* this = THIS; s32 pad; ColliderCylinder* thisCollider; @@ -1157,7 +1154,7 @@ void EnBigpo_Update(Actor* thisx, GlobalContext* globalCtx) { this->savedHeight = this->actor.world.pos.y; } - if (EnBigpo_ApplyDamage(this, globalCtx) == 0) { + if (EnBigpo_ApplyDamage(this, play) == 0) { if ((this->actor.isTargeted) && (this->actionFunc != EnBigpo_WarpingOut) && !(this->collider.base.acFlags & AC_HARD) && (this->actor.category == ACTORCAT_ENEMY)) { this->unk20C++; @@ -1170,12 +1167,12 @@ void EnBigpo_Update(Actor* thisx, GlobalContext* globalCtx) { } } - this->actionFunc(this, globalCtx); + this->actionFunc(this, play); if ((this->actionFunc != EnBigpo_SpawnCutsceneStage6) && (this->actionFunc != EnBigpo_SpawnCutsceneStage4)) { Actor_MoveWithGravity(&this->actor); } if (this->actionFunc == EnBigpo_LanternFalling) { - Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 0.0f, 27.0f, 60.0f, 4); + Actor_UpdateBgCheckInfo(play, &this->actor, 0.0f, 27.0f, 60.0f, 4); } if (this->actor.draw == EnBigpo_DrawScoopSoul) { @@ -1191,13 +1188,13 @@ void EnBigpo_Update(Actor* thisx, GlobalContext* globalCtx) { thisCollider = &this->collider; Collider_UpdateCylinder(&this->actor, thisCollider); if (this->collider.base.ocFlags1 & OC1_ON) { - CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &thisCollider->base); + CollisionCheck_SetOC(play, &play->colChkCtx, &thisCollider->base); } if (this->collider.base.atFlags & AT_ON) { - CollisionCheck_SetAT(globalCtx, &globalCtx->colChkCtx, &thisCollider->base); + CollisionCheck_SetAT(play, &play->colChkCtx, &thisCollider->base); } if (this->collider.base.acFlags & AC_ON) { - CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &thisCollider->base); + CollisionCheck_SetAC(play, &play->colChkCtx, &thisCollider->base); } if (this->drawDmgEffAlpha > 0.0f) { @@ -1215,14 +1212,14 @@ void EnBigpo_Update(Actor* thisx, GlobalContext* globalCtx) { /* * alt update func: the revealed fires under dampe's house */ -void EnBigpo_UpdateFire(Actor* thisx, GlobalContext* globalCtx) { +void EnBigpo_UpdateFire(Actor* thisx, PlayState* play) { EnBigpo* this = THIS; - this->actor.shape.rot.y = BINANG_ROT180(Camera_GetCamDirYaw(GET_ACTIVE_CAM(globalCtx))); - this->actionFunc(this, globalCtx); + this->actor.shape.rot.y = BINANG_ROT180(Camera_GetCamDirYaw(GET_ACTIVE_CAM(play))); + this->actionFunc(this, play); } -s32 EnBigpo_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, Actor* thisx, +s32 EnBigpo_OverrideLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, Actor* thisx, Gfx** gfx) { EnBigpo* this = THIS; // not fully invisible @@ -1233,7 +1230,7 @@ s32 EnBigpo_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dLis return false; } -void EnBigpo_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx, Gfx** gfx) { +void EnBigpo_PostLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx, Gfx** gfx) { EnBigpo* this = THIS; s8 limbByte; Vec3f* v1ptr; // todo: figure out better names @@ -1241,53 +1238,53 @@ void EnBigpo_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f unusedVec; s32 i; - OPEN_DISPS(globalCtx->state.gfxCtx); + OPEN_DISPS(play->state.gfxCtx); if ((this->actionFunc == EnBigpo_BurnAwayDeath) && (this->idleTimer >= 2) && (limbIndex == 8)) { - gSPMatrix((*gfx)++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPMatrix((*gfx)++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList((*gfx)++, &gBigpoDrawCrispyBodyDL); } 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]); + Matrix_MultZero(&this->limbPos[limbByte]); } else if (limbByte == 3) { - Matrix_GetStateTranslationAndScaledX(3000.0f, &this->limbPos[limbByte]); + Matrix_MultVecX(3000.0f, &this->limbPos[limbByte]); } else if (limbByte == 4) { - Matrix_GetStateTranslationAndScaledY(-2000.0f, &this->limbPos[limbByte]); + Matrix_MultVecY(-2000.0f, &this->limbPos[limbByte]); } else { v2ptr = &this->limbPos[limbByte + 1]; v1ptr = D_80B65084; - Matrix_GetStateTranslationAndScaledX(-4000.0f, &this->limbPos[limbByte]); + Matrix_MultVecX(-4000.0f, &this->limbPos[limbByte]); for (i = limbByte + 1; i < ARRAY_COUNT(this->limbPos); i++) { - Matrix_MultiplyVector3fByState(v1ptr, v2ptr); + Matrix_MultVec3f(v1ptr, v2ptr); v2ptr++; v1ptr++; } } } - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->state.gfxCtx); } -void EnBigpo_DrawMainBigpo(Actor* thisx, GlobalContext* globalCtx) { +void EnBigpo_DrawMainBigpo(Actor* thisx, PlayState* play) { EnBigpo* this = THIS; Gfx* dispHead; - OPEN_DISPS(globalCtx->state.gfxCtx); + OPEN_DISPS(play->state.gfxCtx); if ((this->mainColor.a == 255) || (this->mainColor.a == 0)) { // fully visible OR fully transparent @@ -1295,9 +1292,9 @@ void EnBigpo_DrawMainBigpo(Actor* thisx, GlobalContext* globalCtx) { gSPDisplayList(dispHead, &sSetupDL[6 * 0x19]); gSPSegment(&dispHead[1], 0x0C, &D_801AEFA0); // empty display list for no transparency gSPSegment(&dispHead[2], 0x08, - Gfx_EnvColor(globalCtx->state.gfxCtx, this->mainColor.r, this->mainColor.g, this->mainColor.b, + Gfx_EnvColor(play->state.gfxCtx, this->mainColor.r, this->mainColor.g, this->mainColor.b, this->mainColor.a)); - POLY_OPA_DISP = SkelAnime_Draw(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, + POLY_OPA_DISP = SkelAnime_Draw(play, this->skelAnime.skeleton, this->skelAnime.jointTable, EnBigpo_OverrideLimbDraw, EnBigpo_PostLimbDraw, &this->actor, &dispHead[3]); } else { @@ -1305,37 +1302,37 @@ void EnBigpo_DrawMainBigpo(Actor* thisx, GlobalContext* globalCtx) { gSPDisplayList(dispHead, &sSetupDL[6 * 0x19]); gSPSegment(&dispHead[1], 0x0C, &D_801AEF88); // transparency display list gSPSegment(&dispHead[2], 0x08, - Gfx_EnvColor(globalCtx->state.gfxCtx, this->mainColor.r, this->mainColor.g, this->mainColor.b, + Gfx_EnvColor(play->state.gfxCtx, this->mainColor.r, this->mainColor.g, this->mainColor.b, this->mainColor.a)); - POLY_XLU_DISP = SkelAnime_Draw(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, + POLY_XLU_DISP = SkelAnime_Draw(play, this->skelAnime.skeleton, this->skelAnime.jointTable, EnBigpo_OverrideLimbDraw, EnBigpo_PostLimbDraw, &this->actor, &dispHead[3]); } // 71.428566f might be 500/7 context unknown - Actor_DrawDamageEffects(globalCtx, &this->actor, this->limbPos, ARRAY_COUNT(this->limbPos), + Actor_DrawDamageEffects(play, &this->actor, this->limbPos, ARRAY_COUNT(this->limbPos), this->actor.scale.x * 71.428566f * this->drawDmgEffScale, 0.0f, this->drawDmgEffAlpha, ACTOR_DRAW_DMGEFF_LIGHT_ORBS); - Matrix_SetCurrentState(&this->drawMtxF); - EnBigpo_DrawLantern(&this->actor, globalCtx); + Matrix_Put(&this->drawMtxF); + EnBigpo_DrawLantern(&this->actor, play); if (this->actionFunc == EnBigpo_SpawnCutsceneStage6) { - EnBigpo_DrawCircleFlames(&this->actor, globalCtx); + EnBigpo_DrawCircleFlames(&this->actor, play); } - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->state.gfxCtx); } -void EnBigpo_DrawScoopSoul(Actor* thisx, GlobalContext* globalCtx) { +void EnBigpo_DrawScoopSoul(Actor* thisx, PlayState* play) { EnBigpo* this = THIS; s32 pad; - OPEN_DISPS(globalCtx->state.gfxCtx); + OPEN_DISPS(play->state.gfxCtx); - func_8012C2DC(globalCtx->state.gfxCtx); + func_8012C2DC(play->state.gfxCtx); gSPSegment(POLY_XLU_DISP++, 0x08, - Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, 0, 0, 0x20, 0x40, 1, 0, - (globalCtx->gameplayFrames * -15) % 512, 0x20, 0x80)); + Gfx_TwoTexScroll(play->state.gfxCtx, 0, 0, 0, 0x20, 0x40, 1, 0, (play->gameplayFrames * -15) % 512, 0x20, + 0x80)); gDPSetPrimColor(POLY_XLU_DISP++, 0x80, 0x80, 255, 255, 170, this->mainColor.a); @@ -1345,23 +1342,23 @@ 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(Camera_GetCamDirYaw(GET_ACTIVE_CAM(globalCtx))), MTXMODE_APPLY); + Matrix_RotateYS(BINANG_ROT180(Camera_GetCamDirYaw(GET_ACTIVE_CAM(play))), MTXMODE_APPLY); - gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_XLU_DISP++, &gBigpoDrawSoulDL); - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->state.gfxCtx); } -void EnBigpo_DrawLantern(Actor* thisx, GlobalContext* globalCtx) { +void EnBigpo_DrawLantern(Actor* thisx, PlayState* play) { EnBigpo* this = THIS; f32 magnitude; f32 magnitude2; Gfx* dispHead; Vec3f vec1; Vec3f vec2; - Camera* cam = GET_ACTIVE_CAM(globalCtx); + Camera* cam = GET_ACTIVE_CAM(play); if (cam != NULL) { Math_Vec3f_Diff(&cam->eye, &cam->at, &vec1); @@ -1372,28 +1369,28 @@ void EnBigpo_DrawLantern(Actor* thisx, GlobalContext* globalCtx) { Math_Vec3f_Copy(&vec1, &gZeroVec3f); } - OPEN_DISPS(globalCtx->state.gfxCtx); + OPEN_DISPS(play->state.gfxCtx); // fully visible OR fully transparent if ((this->mainColor.a == 255) || (this->mainColor.a == 0)) { - Scene_SetRenderModeXlu(globalCtx, 0, 1); + Scene_SetRenderModeXlu(play, 0, 1); dispHead = POLY_OPA_DISP; } else { - Scene_SetRenderModeXlu(globalCtx, 1, 2); + Scene_SetRenderModeXlu(play, 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)); + gSPSegment(&dispHead[1], 0x0A, Gfx_EnvColor(play->state.gfxCtx, 160, 0, 255, this->mainColor.a)); - Matrix_GetStateTranslationAndScaledY(1400.0f, &vec2); + 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); + gSPMatrix(&dispHead[3], Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(&dispHead[4], &gBigpoDrawLanternMainDL); @@ -1406,21 +1403,21 @@ void EnBigpo_DrawLantern(Actor* thisx, GlobalContext* globalCtx) { POLY_XLU_DISP = &dispHead[6]; } - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->state.gfxCtx); } -void EnBigpo_DrawCircleFlames(Actor* thisx, GlobalContext* globalCtx) { +void EnBigpo_DrawCircleFlames(Actor* thisx, PlayState* play) { EnBigpo* this = THIS; s32 pad[3]; s16 fireRadius; MtxF* mtfxPtr; s32 i; - mtfxPtr = Matrix_GetCurrentState(); - OPEN_DISPS(globalCtx->state.gfxCtx); + mtfxPtr = Matrix_GetCurrent(); + OPEN_DISPS(play->state.gfxCtx); - func_8012C2DC(globalCtx->state.gfxCtx); - Matrix_RotateY(BINANG_ROT180(Camera_GetCamDirYaw(GET_ACTIVE_CAM(globalCtx))), MTXMODE_NEW); + func_8012C2DC(play->state.gfxCtx); + Matrix_RotateYS(BINANG_ROT180(Camera_GetCamDirYaw(GET_ACTIVE_CAM(play))), MTXMODE_NEW); if (this->actionFunc == EnBigpo_SpawnCutsceneStage6) { Matrix_Scale(0.01f, 0.01f, 0.01f, MTXMODE_APPLY); fireRadius = 500; @@ -1429,8 +1426,8 @@ void EnBigpo_DrawCircleFlames(Actor* thisx, GlobalContext* globalCtx) { fireRadius = (s16)(thisx->scale.x * 500.0f * 100.0f); } gSPSegment(POLY_XLU_DISP++, 0x08, - Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, 0, 0, 0x20, 0x40, 1, 0, - (globalCtx->gameplayFrames * -20) % 512, 0x20, 0x80)); + Gfx_TwoTexScroll(play->state.gfxCtx, 0, 0, 0, 0x20, 0x40, 1, 0, (play->gameplayFrames * -20) % 512, 0x20, + 0x80)); gDPSetPrimColor(POLY_XLU_DISP++, 0x80, 0x80, 170, 255, 255, 255 - this->mainColor.a); gDPSetEnvColor(POLY_XLU_DISP++, 0, 0, 255, 255); @@ -1440,30 +1437,30 @@ void EnBigpo_DrawCircleFlames(Actor* thisx, GlobalContext* globalCtx) { 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); + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - gSPDisplayList(POLY_XLU_DISP++, &gGameplayKeepDrawFlameDL); + gSPDisplayList(POLY_XLU_DISP++, gEffFire1DL); } - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->state.gfxCtx); } -void EnBigpo_RevealedFire(Actor* thisx, GlobalContext* globalCtx) { +void EnBigpo_RevealedFire(Actor* thisx, PlayState* play) { EnBigpo* this = THIS; EnBigpo* parent = (EnBigpo*)thisx->parent; s32 pad; - OPEN_DISPS(globalCtx->state.gfxCtx); + OPEN_DISPS(play->state.gfxCtx); - func_8012C2DC(globalCtx->state.gfxCtx); + func_8012C2DC(play->state.gfxCtx); gSPSegment(POLY_XLU_DISP++, 0x08, - Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, 0, 0, 0x20, 0x40, 1, 0, - (globalCtx->gameplayFrames * -20) % 512, 0x20, 0x80)); + Gfx_TwoTexScroll(play->state.gfxCtx, 0, 0, 0, 0x20, 0x40, 1, 0, (play->gameplayFrames * -20) % 512, 0x20, + 0x80)); gDPSetPrimColor(POLY_XLU_DISP++, 0x80, 0x80, 170, 255, 255, 255); gDPSetEnvColor(POLY_XLU_DISP++, 0, 0, 255, 255); @@ -1471,9 +1468,9 @@ void EnBigpo_RevealedFire(Actor* thisx, GlobalContext* globalCtx) { Lights_PointNoGlowSetInfo(&parent->fires[this->unk20C].info, thisx->world.pos.x, thisx->world.pos.y, thisx->world.pos.z, 170, 255, 255, (s32)(thisx->scale.x * 500.0f * 100.0f)); - gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - gSPDisplayList(POLY_XLU_DISP++, &gGameplayKeepDrawFlameDL); + gSPDisplayList(POLY_XLU_DISP++, gEffFire1DL); - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->state.gfxCtx); } 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 c5d0bbe4c..9117bd97c 100644 --- a/src/overlays/actors/ovl_En_Bigpo/z_en_bigpo.h +++ b/src/overlays/actors/ovl_En_Bigpo/z_en_bigpo.h @@ -5,7 +5,7 @@ struct EnBigpo; -typedef void (*EnBigPoActionFunc)(struct EnBigpo*, GlobalContext*); +typedef void (*EnBigPoActionFunc)(struct EnBigpo*, PlayState*); typedef struct EnBigpoFireEffect { /* 0x00 */ Vec3f pos; @@ -35,7 +35,7 @@ typedef struct EnBigpo { /* 0x208 */ s16 unk208; // facing rotY? /* 0x20A */ s16 rotVelocity; /* 0x20C */ s16 unk20C; // is this counting the number of frames the player is ztargeting them? - /* 0x20E */ s16 cutsceneSubCamId; + /* 0x20E */ s16 subCamId; /* 0x210 */ s16 switchFlags; /* 0x212 */ s16 hoverHeightCycleTimer; // sin wave up and down bobbing /* 0x214 */ f32 fireRadius; // distance from center during conjunction cutscene @@ -64,6 +64,6 @@ enum EnBigpoType { /* 5 */ ENBIGPO_UNK5, }; -#define GET_BIGPO_SWITCHFLAGS(thisx) ((u8)(thisx->params >> 0x8)) +#define BIGPO_GET_SWITCHFLAGS(thisx) (u8)((thisx)->params >> 0x8) #endif // Z_EN_BIGPO_H 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 5428e701a..12076537e 100644 --- a/src/overlays/actors/ovl_En_Bigslime/z_en_bigslime.c +++ b/src/overlays/actors/ovl_En_Bigslime/z_en_bigslime.c @@ -5,6 +5,7 @@ */ #include "z_en_bigslime.h" +#include "z64rumble.h" #include "overlays/effects/ovl_Effect_Ss_Hahen/z_eff_ss_hahen.h" #include "objects/object_bigslime/object_bigslime.h" #include "objects/gameplay_keep/gameplay_keep.h" @@ -13,69 +14,69 @@ #define THIS ((EnBigslime*)thisx) -void EnBigslime_Init(Actor* thisx, GlobalContext* globalCtx); -void EnBigslime_Destroy(Actor* thisx, GlobalContext* globalCtx); -void EnBigslime_UpdateGekko(Actor* thisx, GlobalContext* globalCtx); -void EnBigslime_DrawGekko(Actor* thisx, GlobalContext* globalCtx); +void EnBigslime_Init(Actor* thisx, PlayState* play); +void EnBigslime_Destroy(Actor* thisx, PlayState* play); +void EnBigslime_UpdateGekko(Actor* thisx, PlayState* play); +void EnBigslime_DrawGekko(Actor* thisx, PlayState* play); -void EnBigslime_EndCutscene(EnBigslime* this, GlobalContext* globalCtx); -void EnBigslime_CutsceneStartBattle(EnBigslime* this, GlobalContext* globalCtx); +void EnBigslime_EndCutscene(EnBigslime* this, PlayState* play); +void EnBigslime_CutsceneStartBattle(EnBigslime* this, PlayState* play); void EnBigslime_SetupCutsceneNoticePlayer(EnBigslime* this); -void EnBigslime_CutsceneNoticePlayer(EnBigslime* this, GlobalContext* globalCtx); -void EnBigslime_SetupCallMinislime(EnBigslime* this, GlobalContext* globalCtx); -void EnBigslime_CallMinislime(EnBigslime* this, GlobalContext* globalCtx); -void EnBigslime_MoveOnCeiling(EnBigslime* this, GlobalContext* globalCtx); +void EnBigslime_CutsceneNoticePlayer(EnBigslime* this, PlayState* play); +void EnBigslime_SetupCallMinislime(EnBigslime* this, PlayState* play); +void EnBigslime_CallMinislime(EnBigslime* this, PlayState* play); +void EnBigslime_MoveOnCeiling(EnBigslime* this, PlayState* play); void EnBigslime_SetupDrop(EnBigslime* this); -void EnBigslime_Drop(EnBigslime* this, GlobalContext* globalCtx); +void EnBigslime_Drop(EnBigslime* this, PlayState* play); void EnBigslime_SetTargetVtxToWideCone(EnBigslime* this); -void EnBigslime_SquishFlat(EnBigslime* this, GlobalContext* globalCtx); +void EnBigslime_SquishFlat(EnBigslime* this, PlayState* play); void EnBigslime_SetupSquishFlat(EnBigslime* this); void EnBigslime_SetTargetVtxToThinCone(EnBigslime* this); void EnBigslime_SetTargetVtxToInverseCone(EnBigslime* this); void EnBigslime_SetTargetVtxToStaticVtx(EnBigslime* this); void EnBigslime_SetupRise(EnBigslime* this); -void EnBigslime_Rise(EnBigslime* this, GlobalContext* globalCtx); -void EnBigslime_CutsceneGrabPlayer(EnBigslime* this, GlobalContext* globalCtx); +void EnBigslime_Rise(EnBigslime* this, PlayState* play); +void EnBigslime_CutsceneGrabPlayer(EnBigslime* this, PlayState* play); void EnBigslime_SetupAttackPlayerInBigslime(EnBigslime* this); -void EnBigslime_AttackPlayerInBigslime(EnBigslime* this, GlobalContext* globalCtx); +void EnBigslime_AttackPlayerInBigslime(EnBigslime* this, PlayState* play); void EnBigslime_SetupWindupThrowPlayer(EnBigslime* this); -void EnBigslime_WindupThrowPlayer(EnBigslime* this, GlobalContext* globalCtx); -void EnBigslime_SetupSetDynamicVtxThrowPlayer(EnBigslime* this, GlobalContext* globalCtx); -void EnBigslime_SetDynamicVtxThrowPlayer(EnBigslime* this, GlobalContext* globalCtx); +void EnBigslime_WindupThrowPlayer(EnBigslime* this, PlayState* play); +void EnBigslime_SetupSetDynamicVtxThrowPlayer(EnBigslime* this, PlayState* play); +void EnBigslime_SetDynamicVtxThrowPlayer(EnBigslime* this, PlayState* play); void EnBigslime_SetupFrozenGround(EnBigslime* this); -void EnBigslime_FrozenGround(EnBigslime* this, GlobalContext* globalCtx); -void EnBigslime_Freeze(EnBigslime* this, GlobalContext* globalCtx); -void EnBigslime_Melt(EnBigslime* this, GlobalContext* globalCtx); +void EnBigslime_FrozenGround(EnBigslime* this, PlayState* play); +void EnBigslime_Freeze(EnBigslime* this, PlayState* play); +void EnBigslime_Melt(EnBigslime* this, PlayState* play); void EnBigslime_SetupFrozenFall(EnBigslime* this); -void EnBigslime_FrozenFall(EnBigslime* this, GlobalContext* globalCtx); +void EnBigslime_FrozenFall(EnBigslime* this, PlayState* play); void EnBigslime_SetupJumpGekko(EnBigslime* this); -void EnBigslime_JumpGekko(EnBigslime* this, GlobalContext* globalCtx); +void EnBigslime_JumpGekko(EnBigslime* this, PlayState* play); void EnBigslime_SetupIdleLookAround(EnBigslime* this); -void EnBigslime_IdleLookAround(EnBigslime* this, GlobalContext* globalCtx); +void EnBigslime_IdleLookAround(EnBigslime* this, PlayState* play); void EnBigslime_SetupIdleNoticePlayer(EnBigslime* this); -void EnBigslime_IdleNoticePlayer(EnBigslime* this, GlobalContext* globalCtx); +void EnBigslime_IdleNoticePlayer(EnBigslime* this, PlayState* play); void EnBigslime_SetupThrowMinislime(EnBigslime* this); -void EnBigslime_DamageGekko(EnBigslime* this, GlobalContext* globalCtx); -void EnBigslime_StunGekko(EnBigslime* this, GlobalContext* globalCtx); -void EnBigslime_CutsceneFormBigslime(EnBigslime* this, GlobalContext* globalCtx); +void EnBigslime_DamageGekko(EnBigslime* this, PlayState* play); +void EnBigslime_StunGekko(EnBigslime* this, PlayState* play); +void EnBigslime_CutsceneFormBigslime(EnBigslime* this, PlayState* play); void EnBigslime_SetupFormBigslime(EnBigslime* this); -void EnBigslime_FormBigslime(EnBigslime* this, GlobalContext* globalCtx); -void EnBigslime_CutsceneDefeat(EnBigslime* this, GlobalContext* globalCtx); -void EnBigslime_SetupGekkoDespawn(EnBigslime* this, GlobalContext* globalCtx); -void EnBigslime_GekkoDespawn(EnBigslime* this, GlobalContext* globalCtx); -void EnBigslime_SetupFrogSpawn(EnBigslime* this, GlobalContext* globalCtx); -void EnBigslime_FrogSpawn(EnBigslime* this, GlobalContext* globalCtx); +void EnBigslime_FormBigslime(EnBigslime* this, PlayState* play); +void EnBigslime_CutsceneDefeat(EnBigslime* this, PlayState* play); +void EnBigslime_SetupGekkoDespawn(EnBigslime* this, PlayState* play); +void EnBigslime_GekkoDespawn(EnBigslime* this, PlayState* play); +void EnBigslime_SetupFrogSpawn(EnBigslime* this, PlayState* play); +void EnBigslime_FrogSpawn(EnBigslime* this, PlayState* play); void EnBigslime_SetupDespawn(EnBigslime* this); -void EnBigslime_Despawn(EnBigslime* this, GlobalContext* globalCtx); +void EnBigslime_Despawn(EnBigslime* this, PlayState* play); void EnBigslime_SetupInitEntrance(EnBigslime* this); -void EnBigslime_InitEntrance(EnBigslime* this, GlobalContext* globalCtx); -void EnBigslime_ThrowMinislime(EnBigslime* this, GlobalContext* globalCtx); +void EnBigslime_InitEntrance(EnBigslime* this, PlayState* play); +void EnBigslime_ThrowMinislime(EnBigslime* this, PlayState* play); void EnBigslime_SetupCutscene(EnBigslime* this); -void EnBigslime_PlayCutscene(EnBigslime* this, GlobalContext* globalCtx); -void EnBigslime_AddIceShardEffect(EnBigslime* this, GlobalContext* globalCtx); -void EnBigslime_UpdateBigslime(Actor* thisx, GlobalContext* globalCtx); -void EnBigslime_DrawBigslime(Actor* thisx, GlobalContext* globalCtx); -void EnBigslime_DrawShatteringEffects(EnBigslime* this, GlobalContext* globalCtx); +void EnBigslime_PlayCutscene(EnBigslime* this, PlayState* play); +void EnBigslime_AddIceShardEffect(EnBigslime* this, PlayState* play); +void EnBigslime_UpdateBigslime(Actor* thisx, PlayState* play); +void EnBigslime_DrawBigslime(Actor* thisx, PlayState* play); +void EnBigslime_DrawShatteringEffects(EnBigslime* this, PlayState* play); /* * Bigslime Spherical Vtx Data: @@ -152,7 +153,7 @@ static Vtx sBigslimeTargetVtx[BIGSLIME_NUM_VTX] = { * Purpose: indices to calculate/update normal vector for lighting calculations * "EnBigslimeTri" struct based on "Tri" struct from gbi.h, but without the flag */ -static EnBigslimeTri sEnbigslimeTri[BIGSLIME_NUM_FACES] = { +static EnBigslimeTri sBigslimeTri[BIGSLIME_NUM_FACES] = { { 0, 2, 1 }, { 1, 7, 6 }, { 1, 2, 7 }, { 2, 8, 7 }, { 6, 17, 16 }, { 6, 7, 17 }, { 8, 19, 18 }, { 7, 8, 18 }, { 7, 18, 17 }, { 9, 21, 20 }, { 0, 3, 2 }, { 2, 9, 8 }, { 2, 3, 9 }, { 3, 10, 9 }, { 8, 20, 19 }, { 8, 9, 20 }, { 10, 22, 21 }, { 9, 10, 21 }, @@ -308,7 +309,7 @@ static InitChainEntry sInitChain[] = { ICHAIN_U8(targetMode, 5, ICHAIN_STOP), }; -void EnBigslime_Init(Actor* thisx, GlobalContext* globalCtx2) { +void EnBigslime_Init(Actor* thisx, PlayState* play2) { // gSaveContext.save.weekEventReg[KEY] = VALUE // KEY | VALUE static s32 isFrogReturnedFlags[] = { @@ -317,34 +318,33 @@ void EnBigslime_Init(Actor* thisx, GlobalContext* globalCtx2) { (33 << 8) | 0x01, // Southern Swamp Frog Returned (33 << 8) | 0x02, // Laundry Pool Frog Returned }; - GlobalContext* globalCtx = globalCtx2; + PlayState* play = play2; EnBigslime* this = THIS; s32 i; Actor_ProcessInitChain(&this->actor, sInitChain); CollisionCheck_SetInfo(&this->actor.colChkInfo, &sDamageTable, &sColChkInfoInit); - SkelAnime_InitFlex(globalCtx, &this->skelAnime, &gGekkoSkel, &gGekkoLookAroundAnim, this->jointTable, - this->morphTable, GEKKO_LIMB_MAX); + SkelAnime_InitFlex(play, &this->skelAnime, &gGekkoSkel, &gGekkoLookAroundAnim, this->jointTable, this->morphTable, + GEKKO_LIMB_MAX); for (i = 0; i < BIGSLIME_NUM_RING_FACES; i++) { - Collider_InitAndSetCylinder(globalCtx, &this->bigslimeCollider[i], &this->actor, &sCylinderInit); + Collider_InitAndSetCylinder(play, &this->bigslimeCollider[i], &this->actor, &sCylinderInit); } this->bigslimeCollider[0].base.atFlags &= ~AT_ON; - Collider_InitAndSetCylinder(globalCtx, &this->gekkoCollider, &this->actor, &sCylinderInit); + Collider_InitAndSetCylinder(play, &this->gekkoCollider, &this->actor, &sCylinderInit); this->gekkoCollider.base.colType = COLTYPE_HIT6; this->gekkoCollider.info.elemType = ELEMTYPE_UNK1; this->gekkoCollider.base.atFlags &= ~AT_ON; this->gekkoCollider.base.ocFlags1 &= ~OC1_NO_PUSH; this->actor.params = CLAMP(this->actor.params, 1, 4); - if (Flags_GetClear(globalCtx, globalCtx->roomCtx.currRoom.num)) { + if (Flags_GetClear(play, play->roomCtx.currRoom.num)) { Actor_MarkForDeath(&this->actor); 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->actor.params); + Actor_Spawn(&play->actorCtx, play, ACTOR_EN_MINIFROG, this->actor.world.pos.x, this->actor.world.pos.y, + this->actor.world.pos.z, 0, this->actor.shape.rot.y, 0, this->actor.params); } } else { this->cutscene = this->actor.cutscene; @@ -355,7 +355,7 @@ void EnBigslime_Init(Actor* thisx, GlobalContext* globalCtx2) { this->actor.home.pos.y = GBT_ROOM_5_MAX_Y - 75.0f; this->actor.home.pos.z = GBT_ROOM_5_CENTER_Z; for (i = 0; i < MINISLIME_NUM_SPAWN; i++) { - this->minislime[i] = (EnMinislime*)Actor_SpawnAsChild(&globalCtx->actorCtx, &this->actor, globalCtx, + this->minislime[i] = (EnMinislime*)Actor_SpawnAsChild(&play->actorCtx, &this->actor, play, ACTOR_EN_MINISLIME, 0.0f, 0.0f, 0.0f, 0, 0, 0, i); if (this->minislime[i] == NULL) { for (i = i - 1; i >= 0; i--) { @@ -380,16 +380,16 @@ void EnBigslime_Init(Actor* thisx, GlobalContext* globalCtx2) { } } -void EnBigslime_Destroy(Actor* thisx, GlobalContext* globalCtx) { +void EnBigslime_Destroy(Actor* thisx, PlayState* play) { EnBigslime* this = THIS; s32 i; for (i = 0; i < BIGSLIME_NUM_RING_FACES; i++) { - Collider_DestroyCylinder(globalCtx, &this->bigslimeCollider[i]); + Collider_DestroyCylinder(play, &this->bigslimeCollider[i]); } - Collider_DestroyCylinder(globalCtx, &this->gekkoCollider); - Audio_StopSfxByPos(&this->gekkoProjectedPos); + Collider_DestroyCylinder(play, &this->gekkoCollider); + AudioSfx_StopByPos(&this->gekkoProjectedPos); } void EnBigslime_DynamicVtxCopyState(EnBigslime* this) { @@ -436,13 +436,13 @@ void EnBigslime_UpdateSurfaceNorm(EnBigslime* this) { } for (i = 0; i < BIGSLIME_NUM_FACES; i++) { - dynamicVtx0 = &sBigslimeDynamicVtx[this->dynamicVtxState][sEnbigslimeTri[i].v[0]]; - dynamicVtx12 = &sBigslimeDynamicVtx[this->dynamicVtxState][sEnbigslimeTri[i].v[1]]; + dynamicVtx0 = &sBigslimeDynamicVtx[this->dynamicVtxState][sBigslimeTri[i].v[0]]; + dynamicVtx12 = &sBigslimeDynamicVtx[this->dynamicVtxState][sBigslimeTri[i].v[1]]; vecTriEdge1.x = dynamicVtx12->n.ob[0] - dynamicVtx0->n.ob[0]; vecTriEdge1.y = dynamicVtx12->n.ob[1] - dynamicVtx0->n.ob[1]; vecTriEdge1.z = dynamicVtx12->n.ob[2] - dynamicVtx0->n.ob[2]; - dynamicVtx12 = &sBigslimeDynamicVtx[this->dynamicVtxState][sEnbigslimeTri[i].v[2]]; + dynamicVtx12 = &sBigslimeDynamicVtx[this->dynamicVtxState][sBigslimeTri[i].v[2]]; vecTriEdge2.x = dynamicVtx12->n.ob[0] - dynamicVtx0->n.ob[0]; vecTriEdge2.y = dynamicVtx12->n.ob[1] - dynamicVtx0->n.ob[1]; vecTriEdge2.z = dynamicVtx12->n.ob[2] - dynamicVtx0->n.ob[2]; @@ -450,9 +450,9 @@ void EnBigslime_UpdateSurfaceNorm(EnBigslime* this) { Math3D_CrossProduct(&vecTriEdge1, &vecTriEdge2, &vecTriNorm); EnBigslime_Vec3fNormalize(&vecTriNorm); - Math_Vec3f_Sum(&vtxNorm[sEnbigslimeTri[i].v[0]], &vecTriNorm, &vtxNorm[sEnbigslimeTri[i].v[0]]); - Math_Vec3f_Sum(&vtxNorm[sEnbigslimeTri[i].v[1]], &vecTriNorm, &vtxNorm[sEnbigslimeTri[i].v[1]]); - Math_Vec3f_Sum(&vtxNorm[sEnbigslimeTri[i].v[2]], &vecTriNorm, &vtxNorm[sEnbigslimeTri[i].v[2]]); + Math_Vec3f_Sum(&vtxNorm[sBigslimeTri[i].v[0]], &vecTriNorm, &vtxNorm[sBigslimeTri[i].v[0]]); + Math_Vec3f_Sum(&vtxNorm[sBigslimeTri[i].v[1]], &vecTriNorm, &vtxNorm[sBigslimeTri[i].v[1]]); + Math_Vec3f_Sum(&vtxNorm[sBigslimeTri[i].v[2]], &vecTriNorm, &vtxNorm[sBigslimeTri[i].v[2]]); } for (i = 0; i < BIGSLIME_NUM_VTX; i++) { @@ -583,7 +583,7 @@ void EnBigslime_CheckRoomBoundaries(EnBigslime* this, Vec3f* vtxMax, Vec3f* vtxM } } -void EnBigslime_UpdateBigslimeCollider(EnBigslime* this, GlobalContext* globalCtx) { +void EnBigslime_UpdateBigslimeCollider(EnBigslime* this, PlayState* play) { Vtx* dynamicVtx; f32 xzDist; s16 vtxRingMaxY[BIGSLIME_NUM_RING_VTX]; @@ -629,18 +629,18 @@ void EnBigslime_UpdateBigslimeCollider(EnBigslime* this, GlobalContext* globalCt if (this->bigslimeCollider[0].base.atFlags & AT_ON) { for (i = 0; i < BIGSLIME_NUM_RING_FACES; i++) { - CollisionCheck_SetAT(globalCtx, &globalCtx->colChkCtx, &this->bigslimeCollider[i].base); + CollisionCheck_SetAT(play, &play->colChkCtx, &this->bigslimeCollider[i].base); } } if (this->bigslimeCollider[0].base.acFlags & AC_ON) { for (i = 0; i < BIGSLIME_NUM_RING_FACES; i++) { - CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->bigslimeCollider[i].base); + CollisionCheck_SetAC(play, &play->colChkCtx, &this->bigslimeCollider[i].base); } } for (i = 0; i < BIGSLIME_NUM_RING_FACES; i++) { - CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->bigslimeCollider[i].base); + CollisionCheck_SetOC(play, &play->colChkCtx, &this->bigslimeCollider[i].base); } } @@ -724,13 +724,13 @@ void EnBigslime_SetMinislimeBreakLocation(EnBigslime* this) { } } -void EnBigslime_SetPlayerParams(EnBigslime* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); +void EnBigslime_SetPlayerParams(EnBigslime* this, PlayState* play) { + Player* player = GET_PLAYER(play); if (player->stateFlags2 & 0x80) { player->actor.parent = NULL; player->unk_AE8 = 100; - func_800B8D98(globalCtx, &this->actor, 10.0f, this->actor.world.rot.y, 10.0f); + func_800B8D98(play, &this->actor, 10.0f, this->actor.world.rot.y, 10.0f); } } @@ -741,14 +741,14 @@ void EnBigslime_EndThrowMinislime(EnBigslime* this) { } } -void EnBigslime_BreakIntoMinislime(EnBigslime* this, GlobalContext* globalCtx) { +void EnBigslime_BreakIntoMinislime(EnBigslime* this, PlayState* play) { s32 i; - s16 quake = Quake_Add(GET_ACTIVE_CAM(globalCtx), 3); + s16 quake = Quake_Add(GET_ACTIVE_CAM(play), 3); Quake_SetSpeed(quake, 20000); Quake_SetQuakeValues(quake, 15, 0, 0, 0); Quake_SetCountdown(quake, 15); - func_8013ECE0(this->actor.xyzDistToPlayerSq, 180, 20, 100); + Rumble_Request(this->actor.xyzDistToPlayerSq, 180, 20, 100); this->bigslimeCollider[0].base.atFlags &= ~AT_ON; this->gekkoCollider.base.acFlags &= ~(AC_ON | AC_HIT); @@ -760,8 +760,8 @@ void EnBigslime_BreakIntoMinislime(EnBigslime* this, GlobalContext* globalCtx) { this->actor.update = EnBigslime_UpdateGekko; this->actor.draw = EnBigslime_DrawGekko; this->actor.gravity = -2.0f; - EnBigslime_SetPlayerParams(this, globalCtx); - EnBigslime_EndCutscene(this, globalCtx); + EnBigslime_SetPlayerParams(this, play); + EnBigslime_EndCutscene(this, play); this->actor.colChkInfo.mass = 50; this->actor.flags &= ~(ACTOR_FLAG_1 | ACTOR_FLAG_400); this->actor.flags |= ACTOR_FLAG_200; @@ -770,7 +770,7 @@ void EnBigslime_BreakIntoMinislime(EnBigslime* this, GlobalContext* globalCtx) { this->gekkoRot.y = 0; this->actor.bgCheckFlags &= ~1; this->formBigslimeTimer = 2; - EnBigslime_AddIceShardEffect(this, globalCtx); + EnBigslime_AddIceShardEffect(this, play); Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_B_SLIME_BREAK); EnBigslime_SetupJumpGekko(this); } @@ -779,8 +779,8 @@ void EnBigslime_BreakIntoMinislime(EnBigslime* this, GlobalContext* globalCtx) { * Smoothly moves the camera to a side view and keeps it there * as bigslime grabs player and the Gekko melee-attacks player */ -void EnBigslime_UpdateCameraGrabPlayer(EnBigslime* this, GlobalContext* globalCtx) { - Camera* subCam = Play_GetCamera(globalCtx, this->subCamId); +void EnBigslime_UpdateCameraGrabPlayer(EnBigslime* this, PlayState* play) { + Camera* subCam = Play_GetCamera(play, this->subCamId); Vec3f subCamEye; Vec3f subCamAt; @@ -795,7 +795,7 @@ void EnBigslime_UpdateCameraGrabPlayer(EnBigslime* this, GlobalContext* globalCt Math_StepToF(&subCamAt.y, GBT_ROOM_5_MIN_Y + 87.5f, 10.0f); Math_StepToF(&subCamAt.z, this->actor.world.pos.z, 10.0f); - Play_CameraSetAtEye(globalCtx, this->subCamId, &subCamAt, &subCamEye); + Play_SetCameraAtEye(play, this->subCamId, &subCamAt, &subCamEye); } /** @@ -803,14 +803,14 @@ void EnBigslime_UpdateCameraGrabPlayer(EnBigslime* this, GlobalContext* globalCt * This gives the camera a "jerk" feeling * Used everytime player is hit inside of bigslime while being grabbed */ -void EnBigslime_JerkCameraPlayerHit(EnBigslime* this, GlobalContext* globalCtx) { - Camera* subCam = Play_GetCamera(globalCtx, this->subCamId); +void EnBigslime_JerkCameraPlayerHit(EnBigslime* this, PlayState* play) { + Camera* subCam = Play_GetCamera(play, this->subCamId); Vec3f subCamEye; Math_Vec3f_Diff(&subCam->eye, &subCam->at, &subCamEye); Math_Vec3f_Scale(&subCamEye, 0.9f); Math_Vec3f_Sum(&subCamEye, &subCam->at, &subCamEye); - Play_CameraSetAtEye(globalCtx, this->subCamId, &subCam->at, &subCamEye); + Play_SetCameraAtEye(play, this->subCamId, &subCam->at, &subCamEye); } /** @@ -818,8 +818,8 @@ void EnBigslime_JerkCameraPlayerHit(EnBigslime* this, GlobalContext* globalCtx) * and the battle starts. Positions the camera slightly offset from player, * then zooms into the Gekko until the Gekko calls the minislimes down from the ceiling */ -void EnBigslime_UpdateCameraIntroCs(EnBigslime* this, GlobalContext* globalCtx, s32 noticeTimer) { - Camera* subCam = Play_GetCamera(globalCtx, this->subCamId); +void EnBigslime_UpdateCameraIntroCs(EnBigslime* this, PlayState* play, s32 noticeTimer) { + Camera* subCam = Play_GetCamera(play, this->subCamId); Vec3f subCamEye; f32 zoom = (noticeTimer * 19.0f) + 67.0f; s16 yawOffset = this->actor.yawTowardsPlayer + (noticeTimer * 0x31); @@ -828,28 +828,27 @@ void EnBigslime_UpdateCameraIntroCs(EnBigslime* this, GlobalContext* globalCtx, subCamEye.z = Math_CosS(yawOffset) * zoom + subCam->at.z; subCamEye.y = subCam->at.y + -4.0f + (noticeTimer * 2.0f); - Play_CameraSetAtEye(globalCtx, this->subCamId, &subCam->at, &subCamEye); + Play_SetCameraAtEye(play, this->subCamId, &subCam->at, &subCamEye); } /** * Takes the camera and makes the focus point (at) point at bigslime, who is on the * center of the roof. This is used when the minislimes merges into bigslime. */ -void EnBigslime_UpdateCameraFormingBigslime(EnBigslime* this, GlobalContext* globalCtx) { - Play_CameraSetAtEye(globalCtx, this->subCamId, &this->actor.focus.pos, - &Play_GetCamera(globalCtx, this->subCamId)->eye); +void EnBigslime_UpdateCameraFormingBigslime(EnBigslime* this, PlayState* play) { + Play_SetCameraAtEye(play, this->subCamId, &this->actor.focus.pos, &Play_GetCamera(play, this->subCamId)->eye); } -void EnBigslime_EndCutscene(EnBigslime* this, GlobalContext* globalCtx) { +void EnBigslime_EndCutscene(EnBigslime* this, PlayState* play) { Camera* subCam; - 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; + if (this->subCamId != SUB_CAM_ID_DONE) { + subCam = Play_GetCamera(play, this->subCamId); + Play_SetCameraAtEye(play, CAM_ID_MAIN, &subCam->at, &subCam->eye); + this->subCamId = SUB_CAM_ID_DONE; ActorCutscene_Stop(this->cutscene); this->cutscene = ActorCutscene_GetAdditionalCutscene(this->actor.cutscene); - func_800B724C(globalCtx, &this->actor, 6); + func_800B724C(play, &this->actor, 6); } } @@ -862,8 +861,8 @@ 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.lightSettingOverride = 3; +void EnBigslime_InitShockwave(EnBigslime* this, PlayState* play) { + play->envCtx.lightSettingOverride = 3; Math_Vec3f_Copy(&this->frozenPos, &this->actor.world.pos); this->frozenPos.y = GBT_ROOM_5_MIN_Y; this->shockwaveAlpha = 235; @@ -916,42 +915,42 @@ void EnBigslime_GekkoFreeze(EnBigslime* this) { this->actor.flags &= ~ACTOR_FLAG_200; } -void EnBigslime_GekkoThaw(EnBigslime* this, GlobalContext* globalCtx) { +void EnBigslime_GekkoThaw(EnBigslime* this, PlayState* play) { 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->gekkoDrawDmgEffAlpha = 0.0f; - Actor_SpawnIceEffects(globalCtx, &this->actor, this->limbPos, ARRAY_COUNT(this->limbPos), 2, 0.3f, 0.2f); + Actor_SpawnIceEffects(play, &this->actor, this->limbPos, ARRAY_COUNT(this->limbPos), 2, 0.3f, 0.2f); this->actor.flags |= ACTOR_FLAG_200; } } -void EnBigslime_SetupCutsceneStartBattle(EnBigslime* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); - Camera* subCam = Play_GetCamera(globalCtx, this->subCamId); +void EnBigslime_SetupCutsceneStartBattle(EnBigslime* this, PlayState* play) { + Player* player = GET_PLAYER(play); + Camera* subCam = Play_GetCamera(play, this->subCamId); - globalCtx->envCtx.lightSettingOverride = 4; + play->envCtx.lightSettingOverride = 4; Animation_PlayLoop(&this->skelAnime, &gGekkoLookAroundAnim); this->bigslimeCollider[0].base.atFlags &= ~AT_ON; this->bigslimeCollider[0].base.acFlags &= ~AC_ON; Math_Vec3f_Copy(&subCam->at, &this->actor.focus.pos); - func_800B7298(globalCtx, &this->actor, 4); + func_800B7298(play, &this->actor, 4); player->actor.shape.rot.y = this->actor.yawTowardsPlayer + 0x8000; player->actor.world.pos.x = Math_SinS(this->actor.yawTowardsPlayer) * 347.0f + this->actor.world.pos.x; player->actor.world.pos.z = Math_CosS(this->actor.yawTowardsPlayer) * 347.0f + this->actor.world.pos.z; - EnBigslime_UpdateCameraIntroCs(this, globalCtx, 25); + EnBigslime_UpdateCameraIntroCs(this, play, 25); this->gekkoRot.y = this->actor.yawTowardsPlayer + 0x8000; this->isInitJump = false; this->actionFunc = EnBigslime_CutsceneStartBattle; } -void EnBigslime_CutsceneStartBattle(EnBigslime* this, GlobalContext* globalCtx) { +void EnBigslime_CutsceneStartBattle(EnBigslime* this, PlayState* play) { if (this->isAnimUpdate) { EnBigslime_SetupCutsceneNoticePlayer(this); } else if (!this->isInitJump && Math_ScaledStepToS(&this->gekkoRot.y, this->actor.yawTowardsPlayer, 0x200)) { @@ -967,30 +966,30 @@ void EnBigslime_SetupCutsceneNoticePlayer(EnBigslime* this) { this->actionFunc = EnBigslime_CutsceneNoticePlayer; } -void EnBigslime_CutsceneNoticePlayer(EnBigslime* this, GlobalContext* globalCtx) { +void EnBigslime_CutsceneNoticePlayer(EnBigslime* this, PlayState* play) { if (this->noticeTimer != 0) { this->noticeTimer--; } - EnBigslime_UpdateCameraIntroCs(this, globalCtx, this->noticeTimer); + EnBigslime_UpdateCameraIntroCs(this, play, this->noticeTimer); if (Animation_OnFrame(&this->skelAnime, 0.0f) || Animation_OnFrame(&this->skelAnime, 4.0f)) { EnBigslime_GekkoSfxOutsideBigslime(this, NA_SE_EV_WALK_WATER); } if (this->noticeTimer == 0) { - EnBigslime_SetupCallMinislime(this, globalCtx); + EnBigslime_SetupCallMinislime(this, play); } } -void EnBigslime_SetupCallMinislime(EnBigslime* this, GlobalContext* globalCtx) { +void EnBigslime_SetupCallMinislime(EnBigslime* this, PlayState* play) { Animation_MorphToPlayOnce(&this->skelAnime, &gGekkoCallAnim, 5.0f); EnBigslime_GekkoSfxOutsideBigslime(this, NA_SE_EN_FROG_GREET); this->callTimer = 0; - func_800B7298(globalCtx, &this->actor, 7); + func_800B7298(play, &this->actor, 7); this->actionFunc = EnBigslime_CallMinislime; } -void EnBigslime_CallMinislime(EnBigslime* this, GlobalContext* globalCtx) { +void EnBigslime_CallMinislime(EnBigslime* this, PlayState* play) { if (this->callTimer > 0) { this->callTimer--; if (Animation_OnFrame(&this->skelAnime, 0.0f) || Animation_OnFrame(&this->skelAnime, 4.0f)) { @@ -998,19 +997,19 @@ void EnBigslime_CallMinislime(EnBigslime* this, GlobalContext* globalCtx) { } if (this->callTimer == 0) { - EnBigslime_EndCutscene(this, globalCtx); + EnBigslime_EndCutscene(this, play); this->formBigslimeTimer = 2; this->actor.flags |= ACTOR_FLAG_1; EnBigslime_SetupIdleNoticePlayer(this); } } else if (this->isAnimUpdate) { Animation_PlayLoop(&this->skelAnime, &gGekkoNervousIdleAnim); - EnBigslime_UpdateCameraIntroCs(this, globalCtx, 25); + EnBigslime_UpdateCameraIntroCs(this, play, 25); func_801A2E54(0x38); EnBigslime_InitFallMinislime(this); - globalCtx->envCtx.lightSettingOverride = 0xFF; + play->envCtx.lightSettingOverride = 0xFF; this->callTimer = 35; - func_800B7298(globalCtx, &this->actor, 4); + func_800B7298(play, &this->actor, 4); } } @@ -1019,7 +1018,7 @@ void EnBigslime_SetupMoveOnCeiling(EnBigslime* this) { this->actor.gravity = 0.0f; this->actor.velocity.y = 20.0f; - if (this->subCamId != CAM_ID_MAIN) { + if (this->subCamId != SUB_CAM_ID_DONE) { this->actor.speedXZ = 0.0f; this->ceilingMoveTimer = 20; } else { @@ -1034,7 +1033,7 @@ void EnBigslime_SetupMoveOnCeiling(EnBigslime* this) { this->actionFunc = EnBigslime_MoveOnCeiling; } -void EnBigslime_MoveOnCeiling(EnBigslime* this, GlobalContext* globalCtx) { +void EnBigslime_MoveOnCeiling(EnBigslime* this, PlayState* play) { s16 pitch; // polar (zenith) angle Math_ScaledStepToS(&this->gekkoRot.x, 0, 0x400); @@ -1043,9 +1042,9 @@ void EnBigslime_MoveOnCeiling(EnBigslime* this, GlobalContext* globalCtx) { EnBigslime_Scale(this, pitch, 0.04f, 0.04f); EnBigslime_UpdateWavySurface(this); - if (this->subCamId != CAM_ID_MAIN) { + if (this->subCamId != SUB_CAM_ID_DONE) { if (this->ceilingMoveTimer == 0) { - EnBigslime_EndCutscene(this, globalCtx); + EnBigslime_EndCutscene(this, play); this->ceilingMoveTimer = 320; } } else if ((this->actor.xzDistToPlayer < 250.0f) || (this->ceilingMoveTimer == 0)) { @@ -1064,7 +1063,7 @@ void EnBigslime_SetupDrop(EnBigslime* this) { this->actionFunc = EnBigslime_Drop; } -void EnBigslime_Drop(EnBigslime* this, GlobalContext* globalCtx) { +void EnBigslime_Drop(EnBigslime* this, PlayState* play) { Vtx* staticVtx; Vtx* dynamicVtx; s32 i; @@ -1232,7 +1231,7 @@ void EnBigslime_SetupSquishFlat(EnBigslime* this) { * - The vtx shape of Fused Jelly starts from a wide cone shape * - The squishing occurs throught the large changes in &this->actor.scale */ -void EnBigslime_SquishFlat(EnBigslime* this, GlobalContext* globalCtx) { +void EnBigslime_SquishFlat(EnBigslime* this, PlayState* play) { Player* player; Vtx* dynamicVtx; Vtx* targetVtx; @@ -1262,8 +1261,8 @@ void EnBigslime_SquishFlat(EnBigslime* this, GlobalContext* globalCtx) { } if (i != BIGSLIME_NUM_RING_FACES) { - player = GET_PLAYER(globalCtx); - if (globalCtx->grabPlayer(globalCtx, player)) { + player = GET_PLAYER(play); + if (play->grabPlayer(play, player)) { player->actor.parent = &this->actor; EnBigslime_SetupCutscene(this); return; @@ -1431,7 +1430,7 @@ void EnBigslime_SetupRise(EnBigslime* this) { * - When riseCounter == 2 to 9, Fused Jelly is returning to its default spherical shape * - When riseCounter == 10, Fused Jelly starts moving on the ceiling */ -void EnBigslime_Rise(EnBigslime* this, GlobalContext* globalCtx) { +void EnBigslime_Rise(EnBigslime* this, PlayState* play) { Vtx* dynamicVtx; Vtx* targetVtx; s32 i; @@ -1492,16 +1491,16 @@ void EnBigslime_Rise(EnBigslime* this, GlobalContext* globalCtx) { Math_SmoothStepToS(&this->actor.world.rot.y, this->actor.yawTowardsPlayer, 10, 0x800, 0x80); } -void EnBigslime_SetupCutsceneGrabPlayer(EnBigslime* this, GlobalContext* globalCtx) { - Camera* mainCam = Play_GetCamera(globalCtx, CAM_ID_MAIN); +void EnBigslime_SetupCutsceneGrabPlayer(EnBigslime* this, PlayState* play) { + Camera* mainCam = Play_GetCamera(play, CAM_ID_MAIN); s16 yaw; - Play_CameraSetAtEye(globalCtx, this->subCamId, &mainCam->at, &mainCam->eye); + Play_SetCameraAtEye(play, this->subCamId, &mainCam->at, &mainCam->eye); this->grabPlayerTimer = 15; this->wavySurfaceTimer = 0; this->bigslimeCollider[0].base.atFlags &= ~AT_ON; this->actor.world.rot.y = Actor_YawToPoint(&this->actor, &this->actor.home.pos); - yaw = Camera_GetCamDirYaw(GET_ACTIVE_CAM(globalCtx)) - this->actor.world.rot.y; + yaw = Camera_GetCamDirYaw(GET_ACTIVE_CAM(play)) - this->actor.world.rot.y; if (yaw > 0x4000) { this->subCamYawGrabPlayer = -0x2000; @@ -1519,8 +1518,8 @@ void EnBigslime_SetupCutsceneGrabPlayer(EnBigslime* this, GlobalContext* globalC this->actionFunc = EnBigslime_CutsceneGrabPlayer; } -void EnBigslime_CutsceneGrabPlayer(EnBigslime* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); +void EnBigslime_CutsceneGrabPlayer(EnBigslime* this, PlayState* play) { + Player* player = GET_PLAYER(play); f32 invgrabPlayerTimer; f32 magPosXZOffset; Vtx* dynamicVtx; @@ -1529,7 +1528,7 @@ void EnBigslime_CutsceneGrabPlayer(EnBigslime* this, GlobalContext* globalCtx) { player->unk_AE8 = 0; Math_ScaledStepToS(&this->gekkoRot.x, 0, 0x400); - EnBigslime_UpdateCameraGrabPlayer(this, globalCtx); + EnBigslime_UpdateCameraGrabPlayer(this, play); if (this->grabPlayerTimer > 0) { invgrabPlayerTimer = 1.0f / this->grabPlayerTimer; @@ -1572,13 +1571,13 @@ void EnBigslime_SetupAttackPlayerInBigslime(EnBigslime* this) { this->actionFunc = EnBigslime_AttackPlayerInBigslime; } -void EnBigslime_AttackPlayerInBigslime(EnBigslime* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); +void EnBigslime_AttackPlayerInBigslime(EnBigslime* this, PlayState* play) { + Player* player = GET_PLAYER(play); s16 pitch = this->scaleFactor * 0x3333; // polar (zenith) angle player->unk_AE8 = 0; Math_ScaledStepToS(&this->gekkoRot.x, 0, 0x400); - EnBigslime_UpdateCameraGrabPlayer(this, globalCtx); + EnBigslime_UpdateCameraGrabPlayer(this, play); EnBigslime_UpdateWavySurface(this); if (this->scaleFactor != 0) { @@ -1595,7 +1594,7 @@ void EnBigslime_AttackPlayerInBigslime(EnBigslime* this, GlobalContext* globalCt this->scaleFactor = 10; player->actor.world.pos.x += 20.0f * Math_SinS(this->gekkoRot.y); player->actor.world.pos.z += 20.0f * Math_CosS(this->gekkoRot.y); - EnBigslime_JerkCameraPlayerHit(this, globalCtx); + EnBigslime_JerkCameraPlayerHit(this, play); if (this->skelAnime.animation == &gGekkoKickAnim) { EnBigslime_GekkoSfxInsideBigslime(this, NA_SE_EN_FROG_KICK); } else { @@ -1623,7 +1622,7 @@ void EnBigslime_AttackPlayerInBigslime(EnBigslime* this, GlobalContext* globalCt return; } - globalCtx->damagePlayer(globalCtx, -4); + play->damagePlayer(play, -4); func_800B8E58(player, player->ageProperties->unk_92 + NA_SE_VO_LI_DAMAGE_S); this->gekkoRot.y += (s16)(Rand_S16Offset(0x4000, 0x4000) * (Rand_ZeroOne() < 0.5f ? -1 : 1)); this->gekkoPosOffset.x = Math_SinS(this->gekkoRot.y) * -50.0f; @@ -1679,8 +1678,8 @@ void EnBigslime_SetupWindupThrowPlayer(EnBigslime* this) { this->actionFunc = EnBigslime_WindupThrowPlayer; } -void EnBigslime_WindupThrowPlayer(EnBigslime* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); +void EnBigslime_WindupThrowPlayer(EnBigslime* this, PlayState* play) { + Player* player = GET_PLAYER(play); f32 scale; f32 invWindupPunchTimer; Vtx* dynamicVtx; @@ -1689,7 +1688,7 @@ void EnBigslime_WindupThrowPlayer(EnBigslime* this, GlobalContext* globalCtx) { s32 j; this->windupPunchTimer--; - EnBigslime_UpdateCameraGrabPlayer(this, globalCtx); + EnBigslime_UpdateCameraGrabPlayer(this, play); if (this->windupPunchTimer > 0) { invWindupPunchTimer = 1.0f / this->windupPunchTimer; scale = cos_rad(this->windupPunchTimer * (M_PI / 27)) + 1.0f; @@ -1713,8 +1712,8 @@ void EnBigslime_WindupThrowPlayer(EnBigslime* this, GlobalContext* globalCtx) { } player->actor.velocity.y = 0.0f; - func_800B8D50(globalCtx, &this->actor, 10.0f, this->actor.world.rot.y, 10.0f, 4); - EnBigslime_SetupSetDynamicVtxThrowPlayer(this, globalCtx); + func_800B8D50(play, &this->actor, 10.0f, this->actor.world.rot.y, 10.0f, 4); + EnBigslime_SetupSetDynamicVtxThrowPlayer(this, play); } player->actor.world.pos.x = @@ -1765,18 +1764,18 @@ void EnBigslime_WindupThrowPlayer(EnBigslime* this, GlobalContext* globalCtx) { } } -void EnBigslime_SetupSetDynamicVtxThrowPlayer(EnBigslime* this, GlobalContext* globalCtx) { +void EnBigslime_SetupSetDynamicVtxThrowPlayer(EnBigslime* this, PlayState* play) { this->grabPlayerTimer = 10; EnBigslime_SetTargetVtxToWideCone(this); EnBigslime_CheckVtxWallBoundaries(this); - EnBigslime_EndCutscene(this, globalCtx); + EnBigslime_EndCutscene(this, play); this->actionFunc = EnBigslime_SetDynamicVtxThrowPlayer; } /** * Restores bigslime to wide cone after player is thrown */ -void EnBigslime_SetDynamicVtxThrowPlayer(EnBigslime* this, GlobalContext* globalCtx) { +void EnBigslime_SetDynamicVtxThrowPlayer(EnBigslime* this, PlayState* play) { f32 invThrowPlayerTimer; Vtx* targetVtx; Vtx* dynamicVtx; @@ -1861,7 +1860,7 @@ void EnBigslime_SetupFreeze(EnBigslime* this) { /** * Propogates the frozen effect from the seed at the bottom out through all vertices */ -void EnBigslime_Freeze(EnBigslime* this, GlobalContext* globalCtx) { +void EnBigslime_Freeze(EnBigslime* this, PlayState* play) { f32 randFloat; Vtx* targetVtx; Vtx* dynamicVtx; @@ -1900,10 +1899,10 @@ void EnBigslime_Freeze(EnBigslime* this, GlobalContext* globalCtx) { func_800B9010(&this->actor, NA_SE_EV_ICE_FREEZE - SFX_FLAG); if (this->actor.bgCheckFlags & 2) { if (this->freezeTimer == 0) { - EnBigslime_BreakIntoMinislime(this, globalCtx); + EnBigslime_BreakIntoMinislime(this, play); } else { this->bigslimeCollider[0].base.acFlags |= AC_ON; - EnBigslime_AddIceShardEffect(this, globalCtx); + EnBigslime_AddIceShardEffect(this, play); EnBigslime_SetupSquishFlat(this); } } else if (this->freezeTimer == 0) { @@ -1921,14 +1920,14 @@ void EnBigslime_SetupFrozenGround(EnBigslime* this) { this->actionFunc = EnBigslime_FrozenGround; } -void EnBigslime_FrozenGround(EnBigslime* this, GlobalContext* globalCtx) { +void EnBigslime_FrozenGround(EnBigslime* this, PlayState* play) { f32 invFreezerTimer; s32 randSign; f32 randFloat; this->freezeTimer--; if (this->freezeTimer == 0) { - EnBigslime_AddIceShardEffect(this, globalCtx); + EnBigslime_AddIceShardEffect(this, play); EnBigslime_SetTargetVtxFromPreFrozen(this); } else if (this->freezeTimer == 40) { Math_Vec3f_Copy(&this->frozenPos, &this->actor.world.pos); @@ -1963,7 +1962,7 @@ void EnBigslime_SetupMelt(EnBigslime* this) { this->actionFunc = EnBigslime_Melt; } -void EnBigslime_Melt(EnBigslime* this, GlobalContext* globalCtx) { +void EnBigslime_Melt(EnBigslime* this, PlayState* play) { static Vec3f iceSmokeVelocity = { 0.0f, 2.0f, 0.0f }; Vec3f iceSmokePos; Vtx* targetVtx; @@ -1977,7 +1976,7 @@ void EnBigslime_Melt(EnBigslime* this, GlobalContext* globalCtx) { iceSmokePos.x = (dynamicVtx->n.ob[0] * this->actor.scale.x) + this->actor.world.pos.x; iceSmokePos.y = (dynamicVtx->n.ob[1] * this->actor.scale.y) + this->actor.world.pos.y; iceSmokePos.z = (dynamicVtx->n.ob[2] * this->actor.scale.z) + this->actor.world.pos.z; - EffectSsIceSmoke_Spawn(globalCtx, &iceSmokePos, &iceSmokeVelocity, &gZeroVec3f, 600); + EffectSsIceSmoke_Spawn(play, &iceSmokePos, &iceSmokeVelocity, &gZeroVec3f, 600); } func_800B9010(&this->actor, NA_SE_EV_ICE_MELT_LEVEL - SFX_FLAG); @@ -1988,7 +1987,7 @@ void EnBigslime_Melt(EnBigslime* this, GlobalContext* globalCtx) { if (this->meltCounter == 100) { EnBigslime_SetTargetVtxFromPreFrozen(this); } else if (this->meltCounter == 50) { - globalCtx->envCtx.lightSettingOverride = 0xFF; + play->envCtx.lightSettingOverride = 0xFF; } } @@ -2006,7 +2005,7 @@ void EnBigslime_SetupFrozenFall(EnBigslime* this) { this->actionFunc = EnBigslime_FrozenFall; } -void EnBigslime_FrozenFall(EnBigslime* this, GlobalContext* globalCtx) { +void EnBigslime_FrozenFall(EnBigslime* this, PlayState* play) { s32 i; for (i = 0; i < BIGSLIME_NUM_RING_FACES; i++) { @@ -2016,11 +2015,11 @@ void EnBigslime_FrozenFall(EnBigslime* this, GlobalContext* globalCtx) { } if (i != BIGSLIME_NUM_RING_FACES) { - func_800B8D50(globalCtx, &this->actor, 7.0f, this->actor.yawTowardsPlayer, 5.0f, 0x10); + func_800B8D50(play, &this->actor, 7.0f, this->actor.yawTowardsPlayer, 5.0f, 0x10); } if (this->actor.bgCheckFlags & 1) { - EnBigslime_BreakIntoMinislime(this, globalCtx); + EnBigslime_BreakIntoMinislime(this, play); } } @@ -2033,7 +2032,7 @@ void EnBigslime_SetupJumpGekko(EnBigslime* this) { this->actionFunc = EnBigslime_JumpGekko; } -void EnBigslime_JumpGekko(EnBigslime* this, GlobalContext* globalCtx) { +void EnBigslime_JumpGekko(EnBigslime* this, PlayState* play) { s16 yaw; s16 yawDiff; @@ -2089,14 +2088,14 @@ 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; } -void EnBigslime_IdleLookAround(EnBigslime* this, GlobalContext* globalCtx) { +void EnBigslime_IdleLookAround(EnBigslime* this, PlayState* play) { s16 yawDiff; this->idleTimer--; @@ -2111,9 +2110,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; } } @@ -2130,7 +2129,7 @@ void EnBigslime_SetupIdleNoticePlayer(EnBigslime* this) { this->actionFunc = EnBigslime_IdleNoticePlayer; } -void EnBigslime_IdleNoticePlayer(EnBigslime* this, GlobalContext* globalCtx) { +void EnBigslime_IdleNoticePlayer(EnBigslime* this, PlayState* play) { s16* yaw = &this->gekkoRot.y; if (this->skelAnime.curFrame > 10.0f) { @@ -2148,7 +2147,7 @@ void EnBigslime_SetupThrowMinislime(EnBigslime* this) { this->actionFunc = EnBigslime_ThrowMinislime; } -void EnBigslime_ThrowMinislime(EnBigslime* this, GlobalContext* globalCtx) { +void EnBigslime_ThrowMinislime(EnBigslime* this, PlayState* play) { s16 jumpTimerStored; Math_ScaledStepToS(&this->gekkoRot.y, this->actor.yawTowardsPlayer, 0x300); @@ -2186,7 +2185,7 @@ void EnBigslime_SetupDamageGekko(EnBigslime* this, s32 isNotFrozen) { /** * Spins Gekko around as it takes damage */ -void EnBigslime_DamageGekko(EnBigslime* this, GlobalContext* globalCtx) { +void EnBigslime_DamageGekko(EnBigslime* this, PlayState* play) { s32 damageSpinTimer; this->damageSpinTimer--; @@ -2208,11 +2207,11 @@ void EnBigslime_SetupStunGekko(EnBigslime* this) { this->actor.speedXZ = 0.0f; } -void EnBigslime_StunGekko(EnBigslime* this, GlobalContext* globalCtx) { +void EnBigslime_StunGekko(EnBigslime* this, PlayState* play) { this->stunTimer--; if (this->stunTimer == 0) { if (this->gekkoDrawDmgEffType == ACTOR_DRAW_DMGEFF_FROZEN_NO_SFX) { - EnBigslime_GekkoThaw(this, globalCtx); + EnBigslime_GekkoThaw(this, play); EnBigslime_SetupDamageGekko(this, false); } else { this->gekkoCollider.base.acFlags &= ~AC_ON; @@ -2230,8 +2229,8 @@ void EnBigslime_SetupCutsceneFormBigslime(EnBigslime* this) { this->actor.speedXZ = 0.0f; } -void EnBigslime_CutsceneFormBigslime(EnBigslime* this, GlobalContext* globalCtx) { - EnBigslime_UpdateCameraFormingBigslime(this, globalCtx); +void EnBigslime_CutsceneFormBigslime(EnBigslime* this, PlayState* play) { + EnBigslime_UpdateCameraFormingBigslime(this, play); Math_ScaledStepToS(&this->gekkoRot.y, this->actor.world.rot.y, 0x800); if (Animation_OnFrame(&this->skelAnime, 18.0f)) { EnBigslime_SetupFormBigslime(this); @@ -2267,13 +2266,13 @@ void EnBigslime_SetupFormBigslime(EnBigslime* this) { this->actionFunc = EnBigslime_FormBigslime; } -void EnBigslime_FormBigslime(EnBigslime* this, GlobalContext* globalCtx) { +void EnBigslime_FormBigslime(EnBigslime* this, PlayState* play) { f32 xzScale; f32 yScaleFactor; s32 i; EnBigslime_UpdateWavySurface(this); - EnBigslime_UpdateCameraFormingBigslime(this, globalCtx); + EnBigslime_UpdateCameraFormingBigslime(this, play); if (this->formBigslimeCutsceneTimer < 0) { Math_ScaledStepToS(&this->gekkoRot.x, 0, 0x400); } else if (this->actor.world.pos.y > (GBT_ROOM_5_MAX_Y - 100.0f)) { @@ -2314,14 +2313,14 @@ void EnBigslime_FormBigslime(EnBigslime* this, GlobalContext* globalCtx) { } } -void EnBigslime_SetupCutsceneDefeat(EnBigslime* this, GlobalContext* globalCtx) { +void EnBigslime_SetupCutsceneDefeat(EnBigslime* this, PlayState* play) { Vec3f subCamEye; Vec3f subCamAt; s32 i; s16 yawOffset; Animation_Change(&this->skelAnime, &gGekkoDamagedAnim, 0.5f, 0.0f, - Animation_GetLastFrame(&gGekkoDamagedAnim.common), 3, 0.0f); + Animation_GetLastFrame(&gGekkoDamagedAnim.common), ANIMMODE_ONCE_INTERP, 0.0f); this->gekkoCollider.base.acFlags &= ~AC_ON; this->defeatTimer = 60; this->actor.speedXZ = 10.0f; @@ -2344,18 +2343,18 @@ void EnBigslime_SetupCutsceneDefeat(EnBigslime* this, GlobalContext* globalCtx) subCamEye.x = (Math_SinS(yawOffset) * 250.0f) + subCamAt.x; subCamEye.y = subCamAt.y + 60.0f; subCamEye.z = (Math_CosS(yawOffset) * 250.0f) + subCamAt.z; - Play_CameraSetAtEye(globalCtx, this->subCamId, &subCamAt, &subCamEye); + Play_SetCameraAtEye(play, this->subCamId, &subCamAt, &subCamEye); for (i = 0; i < MINISLIME_NUM_SPAWN; i++) { this->minislime[i]->actor.params = MINISLIME_DEFEAT_IDLE; } this->actor.flags &= ~ACTOR_FLAG_1; - EnBigslime_GekkoThaw(this, globalCtx); + EnBigslime_GekkoThaw(this, play); this->actionFunc = EnBigslime_CutsceneDefeat; } -void EnBigslime_CutsceneDefeat(EnBigslime* this, GlobalContext* globalCtx) { +void EnBigslime_CutsceneDefeat(EnBigslime* this, PlayState* play) { s32 defeatTimer; Camera* subCam; Vec3f subCamAt; @@ -2364,19 +2363,19 @@ void EnBigslime_CutsceneDefeat(EnBigslime* this, GlobalContext* globalCtx) { defeatTimer = CLAMP_MAX(this->defeatTimer, 10); this->gekkoRot.y += 0x300 * defeatTimer; if (Math_StepToF(&this->actor.speedXZ, 0.0f, 0.5f)) { - EnBigslime_SetupGekkoDespawn(this, globalCtx); + EnBigslime_SetupGekkoDespawn(this, play); } else { // Continue for the camera to follow Gekko as it spins in defeat - subCam = Play_GetCamera(globalCtx, this->subCamId); + subCam = Play_GetCamera(play, this->subCamId); subCamAt.x = this->actor.world.pos.x; subCamAt.y = this->actor.world.pos.y + 40.0f; subCamAt.z = this->actor.world.pos.z; - Play_CameraSetAtEye(globalCtx, this->subCamId, &subCamAt, &subCam->eye); + Play_SetCameraAtEye(play, this->subCamId, &subCamAt, &subCam->eye); } } -void EnBigslime_SetupGekkoDespawn(EnBigslime* this, GlobalContext* globalCtx) { - Camera* subCam = Play_GetCamera(globalCtx, this->subCamId); +void EnBigslime_SetupGekkoDespawn(EnBigslime* this, PlayState* play) { + Camera* subCam = Play_GetCamera(play, this->subCamId); f32 magnitude; f32 invMagnitude; @@ -2396,7 +2395,7 @@ void EnBigslime_SetupGekkoDespawn(EnBigslime* this, GlobalContext* globalCtx) { this->actionFunc = EnBigslime_GekkoDespawn; } -void EnBigslime_GekkoDespawn(EnBigslime* this, GlobalContext* globalCtx) { +void EnBigslime_GekkoDespawn(EnBigslime* this, PlayState* play) { Vec3f subCamEye; Vec3f subCamAt; Camera* subCam; @@ -2404,32 +2403,32 @@ void EnBigslime_GekkoDespawn(EnBigslime* this, GlobalContext* globalCtx) { this->despawnTimer--; this->gekkoScale = this->despawnTimer * 0.00035000002f; if (this->despawnTimer == 0) { - EnBigslime_SetupFrogSpawn(this, globalCtx); + EnBigslime_SetupFrogSpawn(this, play); } else { - subCam = Play_GetCamera(globalCtx, this->subCamId); + subCam = Play_GetCamera(play, this->subCamId); Math_Vec3f_Copy(&subCamAt, &subCam->at); Math_Vec3f_Diff(&subCam->eye, &this->subCamDistToFrog, &subCamEye); subCamEye.y -= 1.8f; subCamAt.y -= 1.7f; - Play_CameraSetAtEye(globalCtx, this->subCamId, &subCamAt, &subCamEye); + Play_SetCameraAtEye(play, this->subCamId, &subCamAt, &subCamEye); } } -void EnBigslime_SetupFrogSpawn(EnBigslime* this, GlobalContext* globalCtx) { +void EnBigslime_SetupFrogSpawn(EnBigslime* this, PlayState* play) { static Color_RGBA8 dustPrimColor = { 250, 250, 250, 255 }; static Color_RGBA8 dustEnvColor = { 180, 180, 180, 255 }; static Vec3f hahenAccel = { 0.0f, -0.5f, 0.0f }; - Camera* subCam = Play_GetCamera(globalCtx, this->subCamId); + Camera* subCam = Play_GetCamera(play, this->subCamId); Vec3f* worldPos; Vec3f dustPos; Vec3f hahenVel; - s16 yaw = Camera_GetCamDirYaw(GET_ACTIVE_CAM(globalCtx)); + s16 yaw = Camera_GetCamDirYaw(GET_ACTIVE_CAM(play)); s16 yawReverse = yaw + 0x8000; s32 i; this->gekkoCollider.base.ocFlags1 &= ~OC1_ON; - Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_MINIFROG, this->actor.world.pos.x, this->actor.world.pos.y, + Actor_Spawn(&play->actorCtx, play, ACTOR_EN_MINIFROG, this->actor.world.pos.x, this->actor.world.pos.y, this->actor.world.pos.z, 0, yawReverse, 0, this->actor.params); dustPos.x = (Math_SinS(yawReverse) * 20.0f) + this->actor.world.pos.x; @@ -2437,17 +2436,17 @@ void EnBigslime_SetupFrogSpawn(EnBigslime* this, GlobalContext* globalCtx) { worldPos = &this->actor.world.pos; dustPos.z = (Math_CosS(yawReverse) * 20.0f) + this->actor.world.pos.z; - SoundSource_PlaySfxAtFixedWorldPos(globalCtx, worldPos, 40, NA_SE_EN_NPC_APPEAR); + SoundSource_PlaySfxAtFixedWorldPos(play, worldPos, 40, NA_SE_EN_NPC_APPEAR); // dust cloud where the red frog appears - func_800B0DE0(globalCtx, &dustPos, &gZeroVec3f, &gZeroVec3f, &dustPrimColor, &dustEnvColor, 500, 50); + func_800B0DE0(play, &dustPos, &gZeroVec3f, &gZeroVec3f, &dustPrimColor, &dustEnvColor, 500, 50); for (i = 0; i < 25; i++) { hahenVel.x = randPlusMinusPoint5Scaled(5.0f); hahenVel.y = Rand_ZeroFloat(3.0f) + 4.0f; hahenVel.z = randPlusMinusPoint5Scaled(5.0f); - EffectSsHahen_Spawn(globalCtx, worldPos, &hahenVel, &hahenAccel, 0, Rand_S16Offset(12, 3), HAHEN_OBJECT_DEFAULT, - 10, 0); + EffectSsHahen_Spawn(play, worldPos, &hahenVel, &hahenAccel, 0, Rand_S16Offset(12, 3), HAHEN_OBJECT_DEFAULT, 10, + 0); } this->spawnFrogTimer = 40; @@ -2455,8 +2454,8 @@ void EnBigslime_SetupFrogSpawn(EnBigslime* this, GlobalContext* globalCtx) { this->actionFunc = EnBigslime_FrogSpawn; } -void EnBigslime_FrogSpawn(EnBigslime* this, GlobalContext* globalCtx) { - Camera* subCam = Play_GetCamera(globalCtx, this->subCamId); +void EnBigslime_FrogSpawn(EnBigslime* this, PlayState* play) { + Camera* subCam = Play_GetCamera(play, this->subCamId); Vec3f subCamEye; f32 subCamZoom; @@ -2467,10 +2466,10 @@ void EnBigslime_FrogSpawn(EnBigslime* this, GlobalContext* globalCtx) { subCamEye.x = subCam->at.x + (this->subCamDistToFrog.x * subCamZoom); subCamEye.z = subCam->at.z + (this->subCamDistToFrog.z * subCamZoom); subCamEye.y = subCam->at.y + (this->subCamDistToFrog.y * subCamZoom); - Play_CameraSetAtEye(globalCtx, this->subCamId, &subCam->at, &subCamEye); + Play_SetCameraAtEye(play, this->subCamId, &subCam->at, &subCamEye); if (this->spawnFrogTimer == 0) { - EnBigslime_EndCutscene(this, globalCtx); + EnBigslime_EndCutscene(this, play); EnBigslime_SetupDespawn(this); } } @@ -2487,7 +2486,7 @@ void EnBigslime_SetupDespawn(EnBigslime* this) { this->actionFunc = EnBigslime_Despawn; } -void EnBigslime_Despawn(EnBigslime* this, GlobalContext* globalCtx) { +void EnBigslime_Despawn(EnBigslime* this, PlayState* play) { s32 i; s32 counter = 0; @@ -2498,7 +2497,7 @@ void EnBigslime_Despawn(EnBigslime* this, GlobalContext* globalCtx) { } if (!this->isDespawned) { - Flags_SetClearTemp(globalCtx, globalCtx->roomCtx.currRoom.num); + Flags_SetClearTemp(play, play->roomCtx.currRoom.num); this->isDespawned = true; } @@ -2515,8 +2514,8 @@ void EnBigslime_SetupInitEntrance(EnBigslime* this) { this->actionFunc = EnBigslime_InitEntrance; } -void EnBigslime_InitEntrance(EnBigslime* this, GlobalContext* globalCtx) { - if (globalCtx->roomCtx.prevRoom.num == -1) { +void EnBigslime_InitEntrance(EnBigslime* this, PlayState* play) { + if (play->roomCtx.prevRoom.num == -1) { EnBigslime_SetupCutscene(this); } } @@ -2536,34 +2535,34 @@ void EnBigslime_SetupCutscene(EnBigslime* this) { this->actor.speedXZ = 0.0f; } -void EnBigslime_PlayCutscene(EnBigslime* this, GlobalContext* globalCtx) { +void EnBigslime_PlayCutscene(EnBigslime* this, PlayState* play) { if (ActorCutscene_GetCurrentIndex() == 0x7D) { ActorCutscene_Stop(0x7D); ActorCutscene_SetIntentToPlay(this->cutscene); } else if (ActorCutscene_GetCanPlayNext(this->cutscene)) { ActorCutscene_Start(this->cutscene, &this->actor); if (this->actionFuncStored != EnBigslime_SquishFlat) { - func_800B724C(globalCtx, &this->actor, 7); + func_800B724C(play, &this->actor, 7); } - this->subCamId = ActorCutscene_GetCurrentCamera(this->cutscene); + this->subCamId = ActorCutscene_GetCurrentSubCamId(this->cutscene); if (this->actor.colChkInfo.health == 0) { - EnBigslime_SetupCutsceneDefeat(this, globalCtx); + EnBigslime_SetupCutsceneDefeat(this, play); } else if ((this->actionFuncStored == EnBigslime_DamageGekko) || (this->actionFuncStored == EnBigslime_JumpGekko) || (this->actionFuncStored == EnBigslime_StunGekko)) { EnBigslime_SetupCutsceneFormBigslime(this); } else if (this->actionFuncStored == EnBigslime_SquishFlat) { - EnBigslime_SetupCutsceneGrabPlayer(this, globalCtx); + EnBigslime_SetupCutsceneGrabPlayer(this, play); } else { - EnBigslime_SetupCutsceneStartBattle(this, globalCtx); + EnBigslime_SetupCutsceneStartBattle(this, play); } } else { ActorCutscene_SetIntentToPlay(this->cutscene); } } -void EnBigslime_ApplyDamageEffectBigslime(EnBigslime* this, GlobalContext* globalCtx) { +void EnBigslime_ApplyDamageEffectBigslime(EnBigslime* this, PlayState* play) { s32 i; for (i = 0; i < BIGSLIME_NUM_RING_FACES; i++) { @@ -2571,10 +2570,10 @@ void EnBigslime_ApplyDamageEffectBigslime(EnBigslime* this, GlobalContext* globa this->bigslimeCollider[i].base.acFlags &= ~AC_HIT; if (this->actionFunc == EnBigslime_FrozenGround) { if (this->actor.colChkInfo.damageEffect == BIGSLIME_DMGEFF_BREAK_ICE) { - EnBigslime_BreakIntoMinislime(this, globalCtx); + EnBigslime_BreakIntoMinislime(this, play); break; } else if (this->actor.colChkInfo.damageEffect == BIGSLIME_DMGEFF_FIRE) { - EnBigslime_SetPlayerParams(this, globalCtx); + EnBigslime_SetPlayerParams(this, play); EnBigslime_SetupMelt(this); break; } @@ -2582,11 +2581,11 @@ void EnBigslime_ApplyDamageEffectBigslime(EnBigslime* this, GlobalContext* globa if (this->actor.colChkInfo.damageEffect == BIGSLIME_DMGEFF_ICE) { EnMinislime* minislime; - globalCtx->envCtx.lightSettingOverride = 2; - EnBigslime_SetPlayerParams(this, globalCtx); + play->envCtx.lightSettingOverride = 2; + EnBigslime_SetPlayerParams(this, play); this->rotation = 0; EnBigslime_SetupFreeze(this); - minislime = (EnMinislime*)SubS_FindActor(globalCtx, NULL, ACTORCAT_ITEMACTION, ACTOR_ARROW_ICE); + minislime = (EnMinislime*)SubS_FindActor(play, NULL, ACTORCAT_ITEMACTION, ACTOR_ARROW_ICE); if (minislime != NULL) { minislime->shakeRefPos.z = -100.0f; } @@ -2597,9 +2596,9 @@ void EnBigslime_ApplyDamageEffectBigslime(EnBigslime* this, GlobalContext* globa f32 randFloat = Rand_ZeroOne(); if (randFloat < 0.15f) { - Item_DropCollectible(globalCtx, &this->actor.world.pos, ITEM00_ARROWS_10); + Item_DropCollectible(play, &this->actor.world.pos, ITEM00_ARROWS_10); } else if (randFloat < 0.3f) { - Item_DropCollectible(globalCtx, &this->actor.world.pos, ITEM00_MAGIC_SMALL); + Item_DropCollectible(play, &this->actor.world.pos, ITEM00_MAGIC_SMALL); } this->itemDropTimer = 40; } @@ -2612,7 +2611,7 @@ void EnBigslime_ApplyDamageEffectBigslime(EnBigslime* this, GlobalContext* globa } } -void EnBigslime_ApplyDamageEffectGekko(EnBigslime* this, GlobalContext* globalCtx) { +void EnBigslime_ApplyDamageEffectGekko(EnBigslime* this, PlayState* play) { if (this->gekkoCollider.base.acFlags & AC_HIT) { this->gekkoCollider.base.acFlags &= ~AC_HIT; if ((this->gekkoDrawDmgEffType != ACTOR_DRAW_DMGEFF_FROZEN_NO_SFX) || @@ -2622,9 +2621,9 @@ void EnBigslime_ApplyDamageEffectGekko(EnBigslime* this, GlobalContext* globalCt if (Actor_ApplyDamage(&this->actor) == 0) { func_800BE504(&this->actor, &this->gekkoCollider); func_801A2ED8(); - Enemy_StartFinishingBlow(globalCtx, &this->actor); + Enemy_StartFinishingBlow(play, &this->actor); this->gekkoCollider.base.acFlags &= ~AC_ON; - EnBigslime_GekkoThaw(this, globalCtx); + EnBigslime_GekkoThaw(this, play); if ((this->actor.colChkInfo.damageEffect == BIGSLIME_DMGEFF_FIRE) || (this->actor.colChkInfo.damageEffect == BIGSLIME_DMGEFF_LIGHT)) { this->gekkoDrawDmgEffAlpha = 4.0f; @@ -2633,7 +2632,7 @@ void EnBigslime_ApplyDamageEffectGekko(EnBigslime* this, GlobalContext* globalCt this->gekkoDrawDmgEffType = ACTOR_DRAW_DMGEFF_FIRE; } else { this->gekkoDrawDmgEffType = ACTOR_DRAW_DMGEFF_LIGHT_ORBS; - Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_CLEAR_TAG, + Actor_Spawn(&play->actorCtx, play, ACTOR_EN_CLEAR_TAG, this->gekkoCollider.info.bumper.hitPos.x, this->gekkoCollider.info.bumper.hitPos.y, this->gekkoCollider.info.bumper.hitPos.z, 0, 0, 0, CLEAR_TAG_LARGE_LIGHT_RAYS); @@ -2659,7 +2658,7 @@ void EnBigslime_ApplyDamageEffectGekko(EnBigslime* this, GlobalContext* globalCt func_800BE504(&this->actor, &this->gekkoCollider); EnBigslime_SetupStunGekko(this); } else { - EnBigslime_GekkoThaw(this, globalCtx); + EnBigslime_GekkoThaw(this, play); if ((this->actor.colChkInfo.damageEffect == BIGSLIME_DMGEFF_FIRE) || (this->actor.colChkInfo.damageEffect == BIGSLIME_DMGEFF_LIGHT)) { this->gekkoDrawDmgEffAlpha = 3.0f; @@ -2668,7 +2667,7 @@ void EnBigslime_ApplyDamageEffectGekko(EnBigslime* this, GlobalContext* globalCt this->gekkoDrawDmgEffType = ACTOR_DRAW_DMGEFF_FIRE; } else { this->gekkoDrawDmgEffType = ACTOR_DRAW_DMGEFF_LIGHT_ORBS; - Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_CLEAR_TAG, + Actor_Spawn(&play->actorCtx, play, ACTOR_EN_CLEAR_TAG, this->gekkoCollider.info.bumper.hitPos.x, this->gekkoCollider.info.bumper.hitPos.y, this->gekkoCollider.info.bumper.hitPos.z, 0, 0, 0, CLEAR_TAG_LARGE_LIGHT_RAYS); @@ -2684,7 +2683,7 @@ void EnBigslime_ApplyDamageEffectGekko(EnBigslime* this, GlobalContext* globalCt /** * Adds ice shard effects and calls EnBigslime_InitShockwave */ -void EnBigslime_AddIceShardEffect(EnBigslime* this, GlobalContext* globalCtx) { +void EnBigslime_AddIceShardEffect(EnBigslime* this, PlayState* play) { Vtx* targetVtx = &sBigslimeTargetVtx[0]; EnBigslimeIceShardEffect* iceShardEffect; s32 i; @@ -2700,10 +2699,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,15 +2714,15 @@ 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); } } Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_ICE_BROKEN); - EnBigslime_InitShockwave(this, globalCtx); + EnBigslime_InitShockwave(this, play); } /** @@ -2736,15 +2735,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); } } @@ -2767,14 +2766,14 @@ void EnBigslime_UpdateEffects(EnBigslime* this) { } } -void EnBigslime_UpdateBigslime(Actor* thisx, GlobalContext* globalCtx) { +void EnBigslime_UpdateBigslime(Actor* thisx, PlayState* play) { EnBigslime* this = THIS; s32 i; Vec3f vtxMax; Vec3f vtxMin; - if (globalCtx->envCtx.lightSettingOverride == 3) { - globalCtx->envCtx.lightSettingOverride = 0xFF; + if (play->envCtx.lightSettingOverride == 3) { + play->envCtx.lightSettingOverride = 0xFF; } func_8019F540(1); @@ -2782,14 +2781,14 @@ void EnBigslime_UpdateBigslime(Actor* thisx, GlobalContext* globalCtx) { EnBigslime_DynamicVtxCopyState(this); this->isAnimUpdate = SkelAnime_Update(&this->skelAnime); if (this->actionFunc != EnBigslime_PlayCutscene) { - EnBigslime_ApplyDamageEffectBigslime(this, globalCtx); + EnBigslime_ApplyDamageEffectBigslime(this, play); } else { for (i = 0; i < BIGSLIME_NUM_RING_FACES; i++) { this->bigslimeCollider[i].base.acFlags &= ~AC_HIT; } } - this->actionFunc(this, globalCtx); + this->actionFunc(this, play); if (this->actionFunc != EnBigslime_FormBigslime) { Actor_MoveWithGravity(&this->actor); @@ -2802,7 +2801,7 @@ void EnBigslime_UpdateBigslime(Actor* thisx, GlobalContext* globalCtx) { EnBigslime_UpdateScale(this, &vtxMax, &vtxMin); EnBigslime_CheckRoomBoundaries(this, &vtxMax, &vtxMin); EnBigslime_UpdateSurfaceNorm(this); - EnBigslime_UpdateBigslimeCollider(this, globalCtx); + EnBigslime_UpdateBigslimeCollider(this, play); } EnBigslime_UpdateEffects(this); @@ -2812,40 +2811,40 @@ void EnBigslime_UpdateBigslime(Actor* thisx, GlobalContext* globalCtx) { } } -void EnBigslime_UpdateGekko(Actor* thisx, GlobalContext* globalCtx) { +void EnBigslime_UpdateGekko(Actor* thisx, PlayState* play) { static s32 isGekkoOnGround = false; EnBigslime* this = THIS; Player* player; s32 pad; - if (globalCtx->envCtx.lightSettingOverride == 3) { - globalCtx->envCtx.lightSettingOverride = 0xFF; + if (play->envCtx.lightSettingOverride == 3) { + play->envCtx.lightSettingOverride = 0xFF; } func_8019F540(0); this->isAnimUpdate = SkelAnime_Update(&this->skelAnime); if (this->actionFunc != EnBigslime_PlayCutscene) { - EnBigslime_ApplyDamageEffectGekko(this, globalCtx); + EnBigslime_ApplyDamageEffectGekko(this, play); } else { this->gekkoCollider.base.acFlags &= ~AC_HIT; } - this->actionFunc(this, globalCtx); + this->actionFunc(this, play); if (this->actionFunc != EnBigslime_FormBigslime) { Actor_MoveWithGravity(&this->actor); } else { Actor_MoveWithoutGravity(&this->actor); } - Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 20.0f, 40.0f, 80.0f, 0x1F); + Actor_UpdateBgCheckInfo(play, &this->actor, 20.0f, 40.0f, 80.0f, 0x1F); this->gekkoCollider.dim.pos.x = (s16)this->actor.world.pos.x; this->gekkoCollider.dim.pos.z = (s16)this->actor.world.pos.z; if (this->gekkoCollider.base.acFlags & AC_ON) { - CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->gekkoCollider.base); + CollisionCheck_SetAC(play, &play->colChkCtx, &this->gekkoCollider.base); } if ((this->actor.update == EnBigslime_UpdateGekko) && (this->gekkoCollider.base.ocFlags1 & OC1_ON)) { - CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->gekkoCollider.base); + CollisionCheck_SetOC(play, &play->colChkCtx, &this->gekkoCollider.base); } EnBigslime_UpdateEffects(this); @@ -2854,12 +2853,12 @@ void EnBigslime_UpdateGekko(Actor* thisx, GlobalContext* globalCtx) { (this->gekkoCollider.dim.pos.y < (s16)(3.0f + GBT_ROOM_5_MIN_Y))) { Vec3f vtxNorm; - if (((globalCtx->gameplayFrames % 4) == 0) || !isGekkoOnGround) { - player = GET_PLAYER(globalCtx); + if (((play->gameplayFrames % 4) == 0) || !isGekkoOnGround) { + player = GET_PLAYER(play); vtxNorm.x = this->actor.world.pos.x; vtxNorm.z = this->actor.world.pos.z; vtxNorm.y = player->actor.world.pos.y + player->actor.depthInWater; - EffectSsGRipple_Spawn(globalCtx, &vtxNorm, 150, 550, 0); + EffectSsGRipple_Spawn(play, &vtxNorm, 150, 550, 0); isGekkoOnGround = true; } } else { @@ -2870,46 +2869,46 @@ void EnBigslime_UpdateGekko(Actor* thisx, GlobalContext* globalCtx) { /** * Related to transforming and drawing shadows */ -void EnBigslime_SetSysMatrix(Vec3f* pos, GlobalContext* globalCtx, Gfx* shadowDList, f32 scaleX, f32 scalez, f32 scaleY, +void EnBigslime_SetSysMatrix(Vec3f* pos, PlayState* play, 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); + OPEN_DISPS(play->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)); - gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, 0, 0, 0, (u8)(alpha * zx)); + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_OPA_DISP++, shadowDList); - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->state.gfxCtx); } -void EnBigslime_DrawMinislime(EnBigslime* this, GlobalContext* globalCtx2) { +void EnBigslime_DrawMinislime(EnBigslime* this, PlayState* play2) { EnMinislime* minislime; - GlobalContext* globalCtx = globalCtx2; + PlayState* play = play2; s32 pad; s32 currIndex; s32 i; @@ -2932,39 +2931,38 @@ void EnBigslime_DrawMinislime(EnBigslime* this, GlobalContext* globalCtx2) { } } - OPEN_DISPS(globalCtx->state.gfxCtx); + OPEN_DISPS(play->state.gfxCtx); for (i = 0; i < MINISLIME_NUM_SPAWN; i++) { minislime = this->minislime[indices[i]]; - lights = LightContext_NewLights(&globalCtx->lightCtx, globalCtx->state.gfxCtx); - Lights_BindAll(lights, globalCtx->lightCtx.listHead, &minislime->actor.world.pos, globalCtx); - Lights_Draw(lights, globalCtx->state.gfxCtx); - func_8012C2DC(globalCtx->state.gfxCtx); - func_800B8118(&minislime->actor, globalCtx, 0); - Matrix_SetStateRotationAndTranslation(minislime->actor.world.pos.x, minislime->actor.world.pos.y, - minislime->actor.world.pos.z, &minislime->actor.shape.rot); + lights = LightContext_NewLights(&play->lightCtx, play->state.gfxCtx); + Lights_BindAll(lights, play->lightCtx.listHead, &minislime->actor.world.pos, play); + Lights_Draw(lights, play->state.gfxCtx); + func_8012C2DC(play->state.gfxCtx); + func_800B8118(&minislime->actor, play, 0); + 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); + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(play->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, MTXMODE_APPLY); + 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); + AnimatedMat_Draw(play, this->minislimeFrozenTexAnim); gDPSetPrimColor(POLY_XLU_DISP++, 0, 0x80, 255, 255, 255, minislime->frozenAlpha); - gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), - G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_XLU_DISP++, &gMinislimeFrozenDL); } - EnBigslime_SetSysMatrix(&minislime->actor.world.pos, globalCtx, gBigslimeShadowDL, + EnBigslime_SetSysMatrix(&minislime->actor.world.pos, play, gBigslimeShadowDL, (minislime->actor.scale.x * 0.4f) * 0.1f, (minislime->actor.scale.z * 0.4f) * 0.1f, minislime->actor.scale.y * 400.0f, minislime->actor.shape.rot.y, minislime->actor.shape.shadowAlpha * (175.0f / 255.0f)); } - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->state.gfxCtx); } -void EnBigslime_DrawBigslime(Actor* thisx, GlobalContext* globalCtx) { +void EnBigslime_DrawBigslime(Actor* thisx, PlayState* play) { // 28 equidistance-spaced vtx Points (uniformally over the sphere) static EnBigslimeBubbles bubblesInfo[] = { { 0, 0.3f }, { 6, 0.1f }, { 12, 0.45f }, { 18, 0.5f }, { 24, 0.6f }, { 30, 0.2f }, { 36, 0.4f }, @@ -2978,20 +2976,20 @@ void EnBigslime_DrawBigslime(Actor* thisx, GlobalContext* globalCtx) { MtxF* billboardMtxF; s32 i; - func_8012C2DC(globalCtx->state.gfxCtx); - func_800B8118(&this->actor, globalCtx, 0); - OPEN_DISPS(globalCtx->state.gfxCtx); + func_8012C2DC(play->state.gfxCtx); + func_800B8118(&this->actor, play, 0); + OPEN_DISPS(play->state.gfxCtx); // Draw Bigslime gSPSegment(POLY_XLU_DISP++, 0x09, sBigslimeDynamicVtx[this->dynamicVtxState]); - gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_XLU_DISP++, &gBigslimeNormalDL); gSPDisplayList(POLY_XLU_DISP++, &gBigslimeVtxDL); // Draw frozen Bigslime if ((this->actionFunc == EnBigslime_Freeze) || (this->actionFunc == EnBigslime_FrozenGround) || (this->actionFunc == EnBigslime_FrozenFall) || (this->actionFunc == EnBigslime_Melt)) { - AnimatedMat_Draw(globalCtx, this->bigslimeFrozenTexAnim); + AnimatedMat_Draw(play, this->bigslimeFrozenTexAnim); gSPSegment(POLY_XLU_DISP++, 0x09, sBigslimeTargetVtx); gSPDisplayList(POLY_XLU_DISP++, &gBigslimeFrozenVtxDL); gSPDisplayList(POLY_XLU_DISP++, &gBigslimeVtxDL); @@ -2999,32 +2997,31 @@ void EnBigslime_DrawBigslime(Actor* thisx, GlobalContext* globalCtx) { // Draw bubbles inside Bigslime if (this->actor.scale.x > 0.0f) { - Matrix_SetCurrentState(&globalCtx->billboardMtxF); + Matrix_Put(&play->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); + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_XLU_DISP++, &gBigslimeBubbleDL); } } - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->state.gfxCtx); - EnBigslime_SetSysMatrix(&this->actor.world.pos, globalCtx, gBigslimeShadowDL, this->vtxScaleX, this->vtxScaleZ, + EnBigslime_SetSysMatrix(&this->actor.world.pos, play, gBigslimeShadowDL, this->vtxScaleX, this->vtxScaleZ, this->actor.scale.y * BIGSLIME_RADIUS_F, this->rotation, 175.0f); - EnBigslime_DrawGekko(&this->actor, globalCtx); + EnBigslime_DrawGekko(&this->actor, play); } -void EnBigslime_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx) { +void EnBigslime_PostLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx) { /* value -1: Limb Not used * value 0: GEKKO_LIMB_WAIST * value 1: GEKKO_LIMB_L_SHIN @@ -3048,110 +3045,108 @@ 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); + if (limbIndex == GEKKO_LIMB_RIGHT_ANKLE) { + Matrix_MultVec3f(&rightFootOffsetRef, &rightFootOffset); this->gekkoCollider.dim.pos.y = rightFootOffset.y; } } -void EnBigslime_DrawGekko(Actor* thisx, GlobalContext* globalCtx) { +void EnBigslime_DrawGekko(Actor* thisx, PlayState* play) { static Color_RGBA8 gekkoDamageColor = { 255, 0, 0, 0 }; static Color_RGBA8 gekkoStunColor = { 0, 0, 255, 0 }; Vec3f gekkoPos; EnBigslime* this = THIS; s32 pad; - func_8012C28C(globalCtx->state.gfxCtx); + func_8012C28C(play->state.gfxCtx); if (this->actionFunc == EnBigslime_DamageGekko) { - func_800AE434(globalCtx, &gekkoDamageColor, this->damageSpinTimer, 20); + func_800AE434(play, &gekkoDamageColor, this->damageSpinTimer, 20); } else if ((this->actionFunc == EnBigslime_CutsceneDefeat) || (this->actionFunc == EnBigslime_GekkoDespawn)) { - func_800AE434(globalCtx, &gekkoDamageColor, 20, 20); + func_800AE434(play, &gekkoDamageColor, 20, 20); } else if (this->actionFunc == EnBigslime_StunGekko) { if (this->gekkoDrawDmgEffType == ACTOR_DRAW_DMGEFF_FROZEN_NO_SFX) { - func_800AE434(globalCtx, &gekkoDamageColor, this->stunTimer, 80); + func_800AE434(play, &gekkoDamageColor, this->stunTimer, 80); } else if (this->gekkoDrawDmgEffType == ACTOR_DRAW_DMGEFF_ELECTRIC_SPARKS_SMALL) { - func_800AE434(globalCtx, &gekkoStunColor, this->stunTimer, 40); + func_800AE434(play, &gekkoStunColor, this->stunTimer, 40); } else { - func_800AE434(globalCtx, &gekkoStunColor, this->stunTimer, 40); + func_800AE434(play, &gekkoStunColor, this->stunTimer, 40); } } - OPEN_DISPS(globalCtx->state.gfxCtx); + OPEN_DISPS(play->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); - SkelAnime_DrawFlexOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, - NULL, EnBigslime_PostLimbDraw, &this->actor); + SkinMatrix_Vec3fMtxFMultXYZ(&play->viewProjectionMtxF, &gekkoPos, &this->gekkoProjectedPos); + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + SkelAnime_DrawFlexOpa(play, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, NULL, + EnBigslime_PostLimbDraw, &this->actor); - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->state.gfxCtx); if ((this->actionFunc == EnBigslime_DamageGekko) || (this->actionFunc == EnBigslime_CutsceneDefeat) || (this->actionFunc == EnBigslime_GekkoDespawn) || (this->actionFunc == EnBigslime_StunGekko)) { - func_800AE5A0(globalCtx); + func_800AE5A0(play); } - EnBigslime_SetSysMatrix(&gekkoPos, globalCtx, gCircleShadowDL, this->gekkoScale * (550.0f / 7.0f), + EnBigslime_SetSysMatrix(&gekkoPos, play, gCircleShadowDL, this->gekkoScale * (550.0f / 7.0f), this->gekkoScale * (550.0f / 7.0f), 0.0f, 0, 255.0f); if (this->minislimeState != MINISLIME_INACTIVE_STATE) { - EnBigslime_DrawMinislime(this, globalCtx); + EnBigslime_DrawMinislime(this, play); } - EnBigslime_DrawShatteringEffects(this, globalCtx); + EnBigslime_DrawShatteringEffects(this, play); - Actor_DrawDamageEffects(globalCtx, &this->actor, this->limbPos, ARRAY_COUNT(this->limbPos), + Actor_DrawDamageEffects(play, &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) { +void EnBigslime_DrawShatteringEffects(EnBigslime* this, PlayState* play) { EnBigslimeIceShardEffect* iceShardEffect; s32 i; - OPEN_DISPS(globalCtx->state.gfxCtx); + OPEN_DISPS(play->state.gfxCtx); - func_8012C2DC(globalCtx->state.gfxCtx); + func_8012C2DC(play->state.gfxCtx); // Draw Shockwave if (this->shockwaveAlpha > 0) { gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 195, 225, 235, this->shockwaveAlpha); gSPSegment(POLY_XLU_DISP++, 0x0D, - Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, globalCtx->gameplayFrames % 128, - (u8)(globalCtx->gameplayFrames * 8), 32, 64, 1, - (-globalCtx->gameplayFrames * 2) % 64, 0, 16, 16)); - Matrix_InsertTranslation(this->frozenPos.x, this->frozenPos.y, this->frozenPos.z, MTXMODE_NEW); + Gfx_TwoTexScroll(play->state.gfxCtx, 0, play->gameplayFrames % 128, (u8)(play->gameplayFrames * 8), + 32, 64, 1, (-play->gameplayFrames * 2) % 64, 0, 16, 16)); + 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); + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_XLU_DISP++, &gBigslimeShockwaveDL); } // Draw Ice Shards - AnimatedMat_Draw(globalCtx, this->iceShardTexAnim); + AnimatedMat_Draw(play, this->iceShardTexAnim); gSPDisplayList(POLY_XLU_DISP++, &gBigslimeIceShardDL); for (i = 0; i < BIGSLIME_NUM_ICE_SHARD; i++) { iceShardEffect = &this->iceShardEffect[i]; - if (iceShardEffect->isActive > false) { - Matrix_SetStateRotationAndTranslation(iceShardEffect->pos.x, iceShardEffect->pos.y, iceShardEffect->pos.z, - &iceShardEffect->rotation); + 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); + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_XLU_DISP++, &gBigslimeIceShardVtxDL); } } - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->state.gfxCtx); } diff --git a/src/overlays/actors/ovl_En_Bigslime/z_en_bigslime.h b/src/overlays/actors/ovl_En_Bigslime/z_en_bigslime.h index f59a934bc..c66dd7850 100644 --- a/src/overlays/actors/ovl_En_Bigslime/z_en_bigslime.h +++ b/src/overlays/actors/ovl_En_Bigslime/z_en_bigslime.h @@ -7,7 +7,7 @@ struct EnBigslime; -typedef void (*EnBigslimeActionFunc)(struct EnBigslime*, GlobalContext*); +typedef void (*EnBigslimeActionFunc)(struct EnBigslime*, PlayState*); #define BIGSLIME_NUM_VTX 162 // Number of vertices #define BIGSLIME_NUM_FACES 320 // Number of triangles @@ -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 @@ -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 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 818515446..e49b743b8 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 @@ -5,31 +5,29 @@ */ #include "z_en_bji_01.h" -#include "objects/object_bji/object_bji.h" #define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_8 | ACTOR_FLAG_10) #define THIS ((EnBji01*)thisx) -void EnBji01_Init(Actor* thisx, GlobalContext* globalCtx); -void EnBji01_Destroy(Actor* thisx, GlobalContext* globalCtx); -void EnBji01_Update(Actor* thisx, GlobalContext* globalCtx); -void EnBji01_Draw(Actor* thisx, GlobalContext* globalCtx); +void EnBji01_Init(Actor* thisx, PlayState* play); +void EnBji01_Destroy(Actor* thisx, PlayState* play); +void EnBji01_Update(Actor* thisx, PlayState* play); +void EnBji01_Draw(Actor* thisx, PlayState* play); -void func_809CCE98(EnBji01* this, GlobalContext* globalCtx); -void func_809CCEE8(EnBji01* this, GlobalContext* globalCtx); -void func_809CD028(EnBji01* this, GlobalContext* globalCtx); -void EnBji01_DialogueHandler(EnBji01* this, GlobalContext* globalCtx); -void func_809CCDE0(EnBji01* this, GlobalContext* globalCtx); -void func_809CD634(EnBji01* this, GlobalContext* globalCtx); -void EnBji01_DoNothing(EnBji01* this, GlobalContext* globalCtx); -void func_809CD6C0(EnBji01* this, GlobalContext* globalCtx); -void func_809CD70C(EnBji01* this, GlobalContext* globalCtx); -void func_809CD77C(EnBji01* this, GlobalContext* globalCtx); +void func_809CCE98(EnBji01* this, PlayState* play); +void func_809CCEE8(EnBji01* this, PlayState* play); +void func_809CD028(EnBji01* this, PlayState* play); +void EnBji01_DialogueHandler(EnBji01* this, PlayState* play); +void func_809CCDE0(EnBji01* this, PlayState* play); +void func_809CD634(EnBji01* this, PlayState* play); +void EnBji01_DoNothing(EnBji01* this, PlayState* play); +void func_809CD6C0(EnBji01* this, PlayState* play); +void func_809CD70C(EnBji01* this, PlayState* play); +void func_809CD77C(EnBji01* this, PlayState* play); -s32 EnBji01_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, - Actor* thisx); -void EnBji01_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx); +s32 EnBji01_OverrideLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, Actor* thisx); +void EnBji01_PostLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx); const ActorInit En_Bji_01_InitVars = { ACTOR_EN_BJI_01, @@ -64,64 +62,63 @@ static ColliderCylinderInit sCylinderInit = { }; /* Animations struct */ -static AnimationSpeedInfo D_809CDC7C[] = { +static AnimationSpeedInfo sAnimationInfo[] = { { &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; +void func_809CCDE0(EnBji01* this, PlayState* play) { + Player* player = GET_PLAYER(play); + 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) { - SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, D_809CDC7C, 0, &this->animationIndex); +void func_809CCE98(EnBji01* this, PlayState* play) { + SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimationInfo, 0, &this->animIndex); this->actor.textId = 0; this->actionFunc = func_809CCEE8; } -void func_809CCEE8(EnBji01* this, GlobalContext* globalCtx) { +void func_809CCEE8(EnBji01* this, PlayState* play) { Math_ScaledStepToS(&this->actor.shape.rot.y, this->actor.home.rot.y, 0x444); - if (this->actor.params == ENBJI01_PARAMS_DEFAULT) { + if (this->actor.params == SHIKASHI_TYPE_DEFAULT) { if ((this->actor.xzDistToPlayer <= 60.0f) && (this->actor.playerHeightRel <= 10.0f)) { this->actor.flags |= ACTOR_FLAG_10000; } else { this->actor.flags &= ~ACTOR_FLAG_10000; } } - if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { - globalCtx->msgCtx.msgMode = 0; - globalCtx->msgCtx.unk11F10 = 0; - func_809CD028(this, globalCtx); + if (Actor_ProcessTalkRequest(&this->actor, &play->state)) { + play->msgCtx.msgMode = 0; + play->msgCtx.msgLength = 0; + func_809CD028(this, play); } else { if (this->moonsTear != NULL) { if (this->moonsTear->actor.colChkInfo.health == 1) { - func_809CD6C0(this, globalCtx); + func_809CD6C0(this, play); return; } } else { - this->moonsTear = (ObjMoonStone*)SubS_FindActor(globalCtx, NULL, ACTORCAT_PROP, ACTOR_OBJ_MOON_STONE); + this->moonsTear = (ObjMoonStone*)SubS_FindActor(play, NULL, ACTORCAT_PROP, ACTOR_OBJ_MOON_STONE); } - func_800B8500(&this->actor, globalCtx, 60.0f, 10.0f, EXCH_ITEM_NONE); + func_800B8500(&this->actor, play, 60.0f, 10.0f, PLAYER_AP_NONE); } } -void func_809CD028(EnBji01* this, GlobalContext* globalCtx) { - s32 tempDay; - f32 tempTimeBeforeMoonCrash; +void func_809CD028(EnBji01* this, PlayState* play) { + f32 timeBeforeMoonCrash; switch (this->actor.params) { - case ENBJI01_PARAMS_DEFAULT: - case ENBJI01_PARAMS_FINISHED_CONVERSATION: + case SHIKASHI_TYPE_DEFAULT: + case SHIKASHI_TYPE_FINISHED_CONVERSATION: switch (gSaveContext.save.playerForm) { case PLAYER_FORM_DEKU: if (gSaveContext.save.weekEventReg[17] & 0x10) { @@ -136,7 +133,7 @@ void func_809CD028(EnBji01* this, GlobalContext* globalCtx) { } break; case PLAYER_FORM_HUMAN: - if (Player_GetMask(globalCtx) == PLAYER_MASK_KAFEIS_MASK) { + if (Player_GetMask(play) == PLAYER_MASK_KAFEIS_MASK) { this->textId = 0x236A; } else if (gSaveContext.save.weekEventReg[74] & 0x10) { this->textId = 0x5F6; @@ -156,7 +153,7 @@ void func_809CD028(EnBji01* this, GlobalContext* globalCtx) { break; } break; - case ENBJI01_PARAMS_LOOKED_THROUGH_TELESCOPE: + case SHIKASHI_TYPE_LOOKED_THROUGH_TELESCOPE: switch (gSaveContext.save.playerForm) { case PLAYER_FORM_DEKU: if (gSaveContext.save.weekEventReg[74] & 0x80) { @@ -164,8 +161,8 @@ void func_809CD028(EnBji01* this, GlobalContext* globalCtx) { } else { this->textId = 0x5F1; } - func_800B8500(&this->actor, globalCtx, this->actor.xzDistToPlayer, this->actor.playerHeightRel, - EXCH_ITEM_NONE); + func_800B8500(&this->actor, play, this->actor.xzDistToPlayer, this->actor.playerHeightRel, + PLAYER_AP_NONE); break; case PLAYER_FORM_HUMAN: this->textId = 0x5F7; @@ -180,10 +177,11 @@ void func_809CD028(EnBji01* this, GlobalContext* globalCtx) { this->textId = 0x5EA; break; case 3: - tempDay = gSaveContext.save.day; - tempTimeBeforeMoonCrash = - ((-(tempDay % 5 << 0x10) - ((u16)(gSaveContext.save.time - 0x4000))) + 0x40000); - if (tempTimeBeforeMoonCrash < CLOCK_TIME_F(1, 0)) { /* 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,63 +191,63 @@ void func_809CD028(EnBji01* this, GlobalContext* globalCtx) { } break; } - SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, D_809CDC7C, 2, &this->animationIndex); + SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimationInfo, 2, &this->animIndex); this->actionFunc = EnBji01_DialogueHandler; } -void EnBji01_DialogueHandler(EnBji01* this, GlobalContext* globalCtx) { - switch (Message_GetState(&globalCtx->msgCtx)) { - case 0: +void EnBji01_DialogueHandler(EnBji01* this, PlayState* play) { + switch (Message_GetState(&play->msgCtx)) { + case TEXT_STATE_NONE: Math_ScaledStepToS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer, 0x444); - func_809CCDE0(this, globalCtx); + func_809CCDE0(this, play); if (this->actor.shape.rot.y == this->actor.yawTowardsPlayer) { - Message_StartTextbox(globalCtx, this->textId, &this->actor); + Message_StartTextbox(play, this->textId, &this->actor); } break; - case 4: - if (Message_ShouldAdvance(globalCtx) != 0) { + case TEXT_STATE_CHOICE: + if (Message_ShouldAdvance(play)) { this->actor.flags &= ~ACTOR_FLAG_10000; - this->actor.params = ENBJI01_PARAMS_FINISHED_CONVERSATION; - switch (globalCtx->msgCtx.choiceIndex) { + this->actor.params = SHIKASHI_TYPE_FINISHED_CONVERSATION; + switch (play->msgCtx.choiceIndex) { case 0: func_8019F208(); - func_801477B4(globalCtx); - func_809CD634(this, globalCtx); + func_801477B4(play); + func_809CD634(this, play); break; case 1: func_8019F230(); switch (gSaveContext.save.playerForm) { case PLAYER_FORM_DEKU: - func_80151938(globalCtx, 0x5F0); + func_80151938(play, 0x5F0); break; case PLAYER_FORM_HUMAN: - func_80151938(globalCtx, 0x5F8); + func_80151938(play, 0x5F8); break; case PLAYER_FORM_GORON: case PLAYER_FORM_ZORA: - func_80151938(globalCtx, 0x5E1); + func_80151938(play, 0x5E1); break; } break; } } break; - case 5: - if (Message_ShouldAdvance(globalCtx) != 0) { + case TEXT_STATE_5: + if (Message_ShouldAdvance(play)) { this->actor.flags &= ~ACTOR_FLAG_10000; - switch (globalCtx->msgCtx.currentTextId) { + switch (play->msgCtx.currentTextId) { case 0x5DE: - SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, D_809CDC7C, 3, &this->animationIndex); - func_80151938(globalCtx, 0x5DF); + SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimationInfo, 3, &this->animIndex); + func_80151938(play, 0x5DF); break; case 0x5E4: - func_80151938(globalCtx, 0x5E7); + func_80151938(play, 0x5E7); break; case 0x5E5: - func_80151938(globalCtx, 0x5E0); + func_80151938(play, 0x5E0); break; case 0x5E7: - func_80151938(globalCtx, 0x5E5); + func_80151938(play, 0x5E5); break; case 0x5DC: case 0x5DD: @@ -259,11 +257,11 @@ void EnBji01_DialogueHandler(EnBji01* this, GlobalContext* globalCtx) { case 0x5EE: case 0x5F2: case 0x5F5: - func_80151938(globalCtx, globalCtx->msgCtx.currentTextId + 1); + func_80151938(play, play->msgCtx.currentTextId + 1); break; case 0x5F0: case 0x5F6: - func_80151938(globalCtx, 0x5EF); + func_80151938(play, 0x5EF); break; case 0x5E1: case 0x5E8: @@ -275,87 +273,88 @@ void EnBji01_DialogueHandler(EnBji01* this, GlobalContext* globalCtx) { case 0x5F4: case 0x5F7: case 0x5F8: - func_801477B4(globalCtx); + func_801477B4(play); this->actor.flags &= ~ACTOR_FLAG_10000; - this->actor.params = ENBJI01_PARAMS_FINISHED_CONVERSATION; - func_809CCE98(this, globalCtx); + this->actor.params = SHIKASHI_TYPE_FINISHED_CONVERSATION; + func_809CCE98(this, play); break; } } break; - case 6: - this->actor.params = ENBJI01_PARAMS_FINISHED_CONVERSATION; + case TEXT_STATE_DONE: + this->actor.params = SHIKASHI_TYPE_FINISHED_CONVERSATION; this->actor.flags &= ~ACTOR_FLAG_10000; - func_809CCE98(this, globalCtx); + func_809CCE98(this, play); break; } - if ((this->animationIndex == 3) && (this->skelAnime.curFrame == this->skelAnime.endFrame)) { - SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, D_809CDC7C, 2, &this->animationIndex); + if ((this->animIndex == 3) && (this->skelAnime.curFrame == this->skelAnime.endFrame)) { + SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimationInfo, 2, &this->animIndex); } } -void func_809CD634(EnBji01* this, GlobalContext* globalCtx) { - func_801A5BD0(0x6F); +void func_809CD634(EnBji01* this, PlayState* play) { + AudioSfx_MuteBanks((1 << BANK_PLAYER) | (1 << BANK_ITEM) | (1 << BANK_ENV) | (1 << BANK_ENEMY) | + (1 << BANK_OCARINA) | (1 << BANK_VOICE)); Audio_QueueSeqCmd(0xE0000101); - globalCtx->nextEntranceIndex = 0x54A0; /* Termina Field from telescope */ - gSaveContext.respawn[RESTART_MODE_DOWN].entranceIndex = globalCtx->nextEntranceIndex; - func_80169EFC(&globalCtx->state); /* Load new entrance? */ + play->nextEntrance = ENTRANCE(TERMINA_FIELD, 10); /* Telescope entrance */ + gSaveContext.respawn[RESPAWN_MODE_DOWN].entrance = play->nextEntrance; + func_80169EFC(&play->state); /* Load new entrance? */ gSaveContext.respawnFlag = -2; this->actionFunc = EnBji01_DoNothing; } -void EnBji01_DoNothing(EnBji01* this, GlobalContext* globalCtx) { +void EnBji01_DoNothing(EnBji01* this, PlayState* play) { } -void func_809CD6C0(EnBji01* this, GlobalContext* globalCtx) { - SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, D_809CDC7C, 2, &this->animationIndex); +void func_809CD6C0(EnBji01* this, PlayState* play) { + SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimationInfo, 2, &this->animIndex); this->actionFunc = func_809CD70C; } -void func_809CD70C(EnBji01* this, GlobalContext* globalCtx) { +void func_809CD70C(EnBji01* this, PlayState* play) { Math_ScaledStepToS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer, 0x444); - func_809CCDE0(this, globalCtx); + func_809CCDE0(this, play); if (this->actor.shape.rot.y == this->actor.yawTowardsPlayer) { - Actor_ChangeFocus(&this->moonsTear->actor, globalCtx, &this->actor); /* Z-Target the Moon's Tear? */ + Actor_ChangeFocus(&this->moonsTear->actor, play, &this->actor); /* Z-Target the Moon's Tear? */ this->actionFunc = func_809CD77C; } } -void func_809CD77C(EnBji01* this, GlobalContext* globalCtx) { +void func_809CD77C(EnBji01* this, PlayState* play) { if (this->moonsTear->actor.colChkInfo.health == 0) { - func_809CCE98(this, globalCtx); + func_809CCE98(this, play); } } -void EnBji01_Init(Actor* thisx, GlobalContext* globalCtx) { +void EnBji01_Init(Actor* thisx, PlayState* play) { EnBji01* this = THIS; ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 30.0f); - SkelAnime_InitFlex(globalCtx, &this->skelAnime, &object_bji_Skel_00578C, &object_bji_Anim_000FDC, this->jointTable, - this->morphTable, BJI_LIMB_MAX); - Collider_InitAndSetCylinder(globalCtx, &this->collider, &this->actor, &sCylinderInit); + SkelAnime_InitFlex(play, &this->skelAnime, &gShikashiSkel, &object_bji_Anim_000FDC, this->jointTable, + this->morphTable, SHIKASHI_LIMB_MAX); + Collider_InitAndSetCylinder(play, &this->collider, &this->actor, &sCylinderInit); this->actor.colChkInfo.mass = MASS_IMMOVABLE; this->actor.targetMode = 0; this->actor.child = NULL; - this->animationIndex = -1; + this->animIndex = -1; Actor_SetScale(&this->actor, 0.01f); SubS_FillCutscenesList(&this->actor, this->cutscenes, ARRAY_COUNT(this->cutscenes)); - this->moonsTear = (ObjMoonStone*)SubS_FindActor(globalCtx, NULL, ACTORCAT_PROP, ACTOR_OBJ_MOON_STONE); + this->moonsTear = (ObjMoonStone*)SubS_FindActor(play, NULL, ACTORCAT_PROP, ACTOR_OBJ_MOON_STONE); - 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); + switch (gSaveContext.save.entrance) { + case ENTRANCE(ASTRAL_OBSERVATORY, 0): /* ECT entrance*/ + case ENTRANCE(ASTRAL_OBSERVATORY, 1): /* TF door entrance */ + this->actor.params = SHIKASHI_TYPE_DEFAULT; + func_809CCE98(this, play); break; - case 0x4C20: /* Observatory from Termina Field telescope */ + case ENTRANCE(ASTRAL_OBSERVATORY, 2): /* Telescope entrance */ this->actor.flags |= ACTOR_FLAG_10000; - func_801A5BD0(0); + AudioSfx_MuteBanks(0); Audio_QueueSeqCmd(0xE0000100); - this->actor.params = ENBJI01_PARAMS_LOOKED_THROUGH_TELESCOPE; - func_809CCE98(this, globalCtx); + this->actor.params = SHIKASHI_TYPE_LOOKED_THROUGH_TELESCOPE; + func_809CCE98(this, play); break; default: Actor_MarkForDeath(&this->actor); @@ -363,19 +362,19 @@ void EnBji01_Init(Actor* thisx, GlobalContext* globalCtx) { } } -void EnBji01_Destroy(Actor* thisx, GlobalContext* globalCtx) { +void EnBji01_Destroy(Actor* thisx, PlayState* play) { EnBji01* this = THIS; - Collider_DestroyCylinder(globalCtx, &this->collider); + Collider_DestroyCylinder(play, &this->collider); } -void EnBji01_Update(Actor* thisx, GlobalContext* globalCtx) { +void EnBji01_Update(Actor* thisx, PlayState* play) { static s16 sBlinkSequence[] = { 0, 1, 2, 1, 0, 0 }; EnBji01* this = THIS; s32 pad; - this->actionFunc(this, globalCtx); - Actor_UpdateBgCheckInfo(globalCtx, (Actor*)this, 0.0f, 0.0f, 0.0f, 4U); + this->actionFunc(this, play); + Actor_UpdateBgCheckInfo(play, &this->actor, 0.0f, 0.0f, 0.0f, 4); SkelAnime_Update(&this->skelAnime); if (this->blinkTimer-- <= 0) { @@ -389,57 +388,56 @@ void EnBji01_Update(Actor* thisx, GlobalContext* globalCtx) { Actor_SetFocus(&this->actor, 40.0f); Collider_UpdateCylinder(&this->actor, &this->collider); - CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + CollisionCheck_SetOC(play, &play->colChkCtx, &this->collider.base); } -s32 EnBji01_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, - Actor* thisx) { +s32 EnBji01_OverrideLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, Actor* thisx) { EnBji01* this = THIS; - if ((limbIndex == BJI_LIMB_NONE) && ((globalCtx->gameplayFrames % 2) != 0)) { + if ((limbIndex == SHIKASHI_LIMB_NONE) && ((play->gameplayFrames % 2) != 0)) { *dList = NULL; } - if (limbIndex == BJI_LIMB_NONE) { + if (limbIndex == SHIKASHI_LIMB_NONE) { rot->x = rot->x; rot->y = rot->y; rot->z = rot->z; } switch (limbIndex) { - case BJI_LIMB_TORSO: - rot->x += this->torsoXRotAdj; - rot->z += this->torsoZRotAdj; + case SHIKASHI_LIMB_TORSO: + rot->x += this->torsoXRotStep; + rot->z += this->torsoZRotStep; break; - case BJI_LIMB_HEAD: - rot->x += this->headXRotAdj; - rot->z += this->headZRotAdj; + case SHIKASHI_LIMB_HEAD: + rot->x += this->headXRotStep; + rot->z += this->headZRotStep; break; } return false; } -void EnBji01_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx) { +void EnBji01_PostLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx) { static Vec3f D_809CDCC8 = { 1088.0f, 1200.0f, 0.0f }; EnBji01* this = THIS; Vec3f sp20; s32 temp_f4 = 0; - if (limbIndex == BJI_LIMB_HEAD) { + if (limbIndex == SHIKASHI_LIMB_HEAD) { Math_Vec3f_Copy(&sp20, &D_809CDCC8); 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); } } -void EnBji01_Draw(Actor* thisx, GlobalContext* globalCtx) { +void EnBji01_Draw(Actor* thisx, PlayState* play) { static TexturePtr sEyeTextures[] = { object_bji_Tex_0049F0, object_bji_Tex_004E70, object_bji_Tex_005270 }; EnBji01* this = THIS; - OPEN_DISPS(globalCtx->state.gfxCtx); - func_8012C28C(globalCtx->state.gfxCtx); + OPEN_DISPS(play->state.gfxCtx); + func_8012C28C(play->state.gfxCtx); gSPSegment(POLY_OPA_DISP++, 0x08, Lib_SegmentedToVirtual(sEyeTextures[this->eyeTexIndex])); - SkelAnime_DrawFlexOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, + SkelAnime_DrawFlexOpa(play, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, EnBji01_OverrideLimbDraw, EnBji01_PostLimbDraw, &this->actor); - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->state.gfxCtx); } 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..8ab601e1b 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 @@ -3,52 +3,33 @@ #include "global.h" #include "overlays/actors/ovl_Obj_Moon_Stone/z_obj_moon_stone.h" +#include "objects/object_bji/object_bji.h" struct EnBji01; -typedef void (*EnBji01ActionFunc)(struct EnBji01*, GlobalContext*); +typedef void (*EnBji01ActionFunc)(struct EnBji01*, PlayState*); typedef enum { - /* 00 */ BJI_LIMB_NONE, - /* 01 */ BJI_LIMB_ROOT, - /* 02 */ BJI_LIMB_THIGH_LEFT, - /* 03 */ BJI_LIMB_LEG_LEFT, - /* 04 */ BJI_LIMB_FOOT_LEFT, - /* 05 */ BJI_LIMB_THIGH_RIGHT, - /* 06 */ BJI_LIMB_LEG_RIGHT, - /* 07 */ BJI_LIMB_FOOT_RIGHT, - /* 08 */ BJI_LIMB_TORSO, - /* 09 */ BJI_LIMB_ARM_LEFT, - /* 10 */ BJI_LIMB_FOREARM_LEFT, - /* 11 */ BJI_LIMB_HAND_LEFT, - /* 12 */ BJI_LIMB_ARM_RIGHT, - /* 13 */ BJI_LIMB_FOREARM_RIGHT, - /* 14 */ BJI_LIMB_HAND_RIGHT, - /* 15 */ BJI_LIMB_HEAD, - /* 16 */ BJI_LIMB_MAX -} ObjectBjiLimbs; - -typedef enum { - /* 00 */ ENBJI01_PARAMS_DEFAULT, - /* 01 */ ENBJI01_PARAMS_FINISHED_CONVERSATION, - /* 03 */ ENBJI01_PARAMS_LOOKED_THROUGH_TELESCOPE = 3 -} EnBji01Params; + /* 0 */ SHIKASHI_TYPE_DEFAULT, + /* 1 */ SHIKASHI_TYPE_FINISHED_CONVERSATION, + /* 3 */ SHIKASHI_TYPE_LOOKED_THROUGH_TELESCOPE = 3 +} ShikashiType; typedef struct EnBji01 { /* 0x000 */ Actor actor; /* 0x144 */ EnBji01ActionFunc actionFunc; /* 0x148 */ SkelAnime skelAnime; /* 0x18C */ ColliderCylinder collider; - /* 0x1D8 */ Vec3s jointTable[BJI_LIMB_MAX]; - /* 0x238 */ Vec3s morphTable[BJI_LIMB_MAX]; - /* 0x298 */ s32 animationIndex; + /* 0x1D8 */ Vec3s jointTable[SHIKASHI_LIMB_MAX]; + /* 0x238 */ Vec3s morphTable[SHIKASHI_LIMB_MAX]; + /* 0x298 */ s32 animIndex; /* 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 dedb09d4c..788759e3c 100644 --- a/src/overlays/actors/ovl_En_Bjt/z_en_bjt.c +++ b/src/overlays/actors/ovl_En_Bjt/z_en_bjt.c @@ -10,15 +10,42 @@ #define THIS ((EnBjt*)thisx) -void EnBjt_Init(Actor* thisx, GlobalContext* globalCtx); -void EnBjt_Destroy(Actor* thisx, GlobalContext* globalCtx); -void EnBjt_Update(Actor* thisx, GlobalContext* globalCtx); -void EnBjt_Draw(Actor* thisx, GlobalContext* globalCtx); +void EnBjt_Init(Actor* thisx, PlayState* play); +void EnBjt_Destroy(Actor* thisx, PlayState* play); +void EnBjt_Update(Actor* thisx, PlayState* play); +void EnBjt_Draw(Actor* thisx, PlayState* play); -void func_80BFDA48(EnBjt* this, GlobalContext* globalCtx); -void func_80BFDAE8(EnBjt* this, GlobalContext* globalCtx); +void EnBjt_Talk(EnBjt* this, PlayState* play); +void EnBjt_FollowSchedule(EnBjt* this, PlayState* play); + +#define TOILET_HAND_STATE_TALKING (1 << 3) // Actually talking to Player +#define TOILET_HAND_STATE_TEXTBOX (1 << 4) // Whenever a textbox is on screen +#define TOILET_HAND_STATE_APPEARING (1 << 7) // Appearing +#define TOILET_HAND_STATE_VANISHING (1 << 8) // Vanishing +#define TOILET_HAND_STATE_VISIBLE (1 << 9) // Out + +typedef enum { + /* 0 */ TOILET_HAND_SCH_NONE, + /* 1 */ TOILET_HAND_SCH_AVAILABLE +} ToiletHandScheduleResult; + +static u8 sScheduleScript[] = { + /* 0x00 */ SCHEDULE_CMD_CHECK_NOT_IN_SCENE_S(SCENE_YADOYA, 0x11 - 0x04), + /* 0x04 */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(0, 0, 6, 0, 0x0B - 0x0A), + /* 0x0A */ SCHEDULE_CMD_RET_NONE(), + /* 0x0B */ SCHEDULE_CMD_RET_TIME(0, 0, 6, 0, TOILET_HAND_SCH_AVAILABLE), + /* 0x11 */ SCHEDULE_CMD_RET_NONE(), +}; + +static u8 sMsgEventScript[] = { + 0x0E, 0x29, 0x48, 0x0C, 0x0E, 0x00, 0xFF, 0x2B, 0x00, 0x00, 0x00, 0x52, 0x00, 0x5F, 0x2C, 0x29, 0x4A, 0x0C, 0x2F, + 0x00, 0x00, 0x0C, 0x15, 0x09, 0x00, 0x00, 0x0E, 0x29, 0x4B, 0x0C, 0x15, 0x09, 0x00, 0x00, 0x0E, 0x29, 0x4C, 0x0C, + 0x12, 0x00, 0x49, 0x08, 0x00, 0x1D, 0x09, 0x00, 0x00, 0x06, 0x00, 0x0C, 0x00, 0x00, 0x13, 0x00, 0x0C, 0x2F, 0x00, + 0x00, 0x2E, 0x2D, 0x00, 0x28, 0x2D, 0x00, 0x0D, 0x0C, 0x11, 0x49, 0x08, 0x11, 0x5A, 0x80, 0x10, 0x09, 0x00, 0x00, + 0x06, 0x00, 0x02, 0x00, 0x00, 0x13, 0x00, 0x02, 0x2F, 0x00, 0x00, 0x2E, 0x2D, 0x00, 0x0D, 0x0C, 0x11, 0x5A, 0x80, + 0x10, 0x2C, 0x29, 0x49, 0x0C, 0x2F, 0x00, 0x00, 0x0C, 0x2D, 0x00, 0x0D, 0x12, 0x10, 0x2D, 0x00, 0x0D, 0x12, 0x10, +}; -#if 0 const ActorInit En_Bjt_InitVars = { ACTOR_EN_BJT, ACTORCAT_NPC, @@ -31,49 +58,406 @@ const ActorInit En_Bjt_InitVars = { (ActorFunc)EnBjt_Draw, }; -// static ColliderCylinderInit sCylinderInit = { -static ColliderCylinderInit D_80BFDF48 = { - { COLTYPE_HIT1, AT_NONE, AC_NONE, OC1_ON | OC1_TYPE_ALL, OC2_TYPE_1, COLSHAPE_CYLINDER, }, - { ELEMTYPE_UNK1, { 0x00000000, 0x00, 0x00 }, { 0x00000000, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_NONE, OCELEM_ON, }, +static ColliderCylinderInit sCylinderInit = { + { + COLTYPE_HIT1, + AT_NONE, + AC_NONE, + OC1_ON | OC1_TYPE_ALL, + OC2_TYPE_1, + COLSHAPE_CYLINDER, + }, + { + ELEMTYPE_UNK1, + { 0x00000000, 0x00, 0x00 }, + { 0x00000000, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_NONE, + OCELEM_ON, + }, { 10, 68, 0, { 0, 0, 0 } }, }; -// sColChkInfoInit -static CollisionCheckInfoInit2 D_80BFDF74 = { 0, 0, 0, 0, MASS_IMMOVABLE }; +static CollisionCheckInfoInit2 sColChkInfoInit = { 0, 0, 0, 0, MASS_IMMOVABLE }; -#endif +typedef enum { + /* -1 */ TOILET_HAND_ANIM_NONE = -1, + /* 0 */ TOILET_HAND_ANIM_WAITING, + /* 1 */ TOILET_HAND_ANIM_WAITING_MORPH, // Same as TOILET_HAND_ANIM_WAITING, but with morph frames + /* 2 */ TOILET_HAND_ANIM_WAGGING_FINGER, // Wrong + /* 3 */ TOILET_HAND_ANIM_THUMBS_UP, // Right + /* 4 */ TOILET_HAND_ANIM_OPEN_HAND, + /* 5 */ TOILET_HAND_ANIM_FIST // i.e. holding the reward +} ToiletHandAnimation; -extern ColliderCylinderInit D_80BFDF48; -extern CollisionCheckInfoInit2 D_80BFDF74; +static AnimationInfoS sAnimationInfo[] = { + /* 0 */ { &gToiletHandWaitingAnim, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, + /* 1 */ { &gToiletHandWaitingAnim, 1.0f, 0, -1, ANIMMODE_LOOP, -4 }, + /* 2 */ { &gToiletHandWaggingFingerAnim, 1.0f, 0, -1, ANIMMODE_LOOP, -4 }, + /* 3 */ { &gToiletHandThumbsUpAnim, 1.0f, 0, -1, ANIMMODE_LOOP, -4 }, + /* 4 */ { &gToiletHandOpenHandAnim, 1.0f, 0, -1, ANIMMODE_LOOP, -4 }, + /* 5 */ { &gToiletHandFistAnim, 1.0f, 0, -1, ANIMMODE_LOOP, -4 }, +}; -extern UNK_TYPE D_06002390; +void EnBjt_UpdateSkelAnime(EnBjt* this) { + this->skelAnime.playSpeed = this->animPlaySpeed; + SkelAnime_Update(&this->skelAnime); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bjt/func_80BFD2E0.s") +s32 EnBjt_ChangeAnim(EnBjt* this, s32 animIndex) { + s32 changeAnim = false; + s32 changed = false; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bjt/func_80BFD30C.s") + if ((animIndex == TOILET_HAND_ANIM_WAITING) || (animIndex == TOILET_HAND_ANIM_WAITING_MORPH)) { + if (!((this->animIndex == TOILET_HAND_ANIM_WAITING) || (this->animIndex == TOILET_HAND_ANIM_WAITING_MORPH))) { + changeAnim = true; + } + } else if (this->animIndex != animIndex) { + changeAnim = true; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bjt/func_80BFD3A4.s") + if (changeAnim) { + this->animIndex = animIndex; + changed = SubS_ChangeAnimationByInfoS(&this->skelAnime, sAnimationInfo, animIndex); + this->animPlaySpeed = this->skelAnime.playSpeed; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bjt/func_80BFD434.s") + return changed; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bjt/func_80BFD4FC.s") +void EnBjt_UpdateCollision(EnBjt* this, PlayState* play) { + static Vec3f sColliderBasePos = { 0.0f, 8.0f, 10.0f }; + s32 pad; + Vec3f pos; + f32 height; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bjt/func_80BFD5E4.s") + if (this->stateFlags & (TOILET_HAND_STATE_APPEARING | TOILET_HAND_STATE_VISIBLE)) { + Lib_Vec3f_TranslateAndRotateY(&this->actor.world.pos, this->actor.shape.rot.y, &sColliderBasePos, &pos); + Math_Vec3f_ToVec3s(&this->collider.dim.pos, &pos); + height = this->actor.focus.pos.y - this->actor.world.pos.y; + this->collider.dim.height = height; + this->collider.dim.radius = 32; + CollisionCheck_SetOC(play, &play->colChkCtx, &this->collider.base); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bjt/func_80BFD6BC.s") +s32 EnBjt_TakeItem(s32 exchangeItem) { + switch (exchangeItem) { + case PLAYER_AP_LETTER_TO_KAFEI: + Inventory_DeleteItem(ITEM_LETTER_TO_KAFEI, SLOT(ITEM_LETTER_TO_KAFEI)); + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bjt/func_80BFD8F0.s") + case PLAYER_AP_DEED_SWAMP: + Inventory_DeleteItem(ITEM_DEED_SWAMP, SLOT(ITEM_DEED_SWAMP)); + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bjt/func_80BFD984.s") + case PLAYER_AP_DEED_MOUNTAIN: + Inventory_DeleteItem(ITEM_DEED_MOUNTAIN, SLOT(ITEM_DEED_MOUNTAIN)); + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bjt/func_80BFDA48.s") + case PLAYER_AP_DEED_OCEAN: + Inventory_DeleteItem(ITEM_DEED_OCEAN, SLOT(ITEM_DEED_OCEAN)); + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bjt/func_80BFDAE8.s") + case PLAYER_AP_DEED_LAND: + Inventory_DeleteItem(ITEM_DEED_LAND, SLOT(ITEM_DEED_LAND)); + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bjt/EnBjt_Init.s") + case PLAYER_AP_LETTER_MAMA: + Inventory_DeleteItem(ITEM_LETTER_MAMA, SLOT(ITEM_LETTER_MAMA)); + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bjt/EnBjt_Destroy.s") + default: + break; + } + return 0; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bjt/EnBjt_Update.s") +#define FULLY_GROWN_SCALE 0.017f -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bjt/EnBjt_Draw.s") +/** + * @return boolean true if scale is set to final value + */ +s32 EnBjt_Appear(EnBjt* this) { + s32 finished = false; + + if (!this->playedSfx) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_TOILET_HAND_APPEAR); + this->playedSfx = true; + } + + Math_ApproachF(&this->actor.scale.x, FULLY_GROWN_SCALE, 0.21f, 0.3f); + if ((FULLY_GROWN_SCALE - this->actor.scale.x) < FULLY_GROWN_SCALE / 100.0f) { + this->actor.scale.x = FULLY_GROWN_SCALE; + this->stateFlags |= TOILET_HAND_STATE_VISIBLE; + this->stateFlags &= ~TOILET_HAND_STATE_APPEARING; + finished = true; + } + this->heightOffset = (this->actor.scale.x / FULLY_GROWN_SCALE) * 4.0f; + this->actor.world.pos.y = this->actor.home.pos.y + this->heightOffset; + Actor_SetScale(&this->actor, this->actor.scale.x); + + return finished; +} + +/** + * @return boolean true if scale is set to final value + */ +s32 EnBjt_Vanish(EnBjt* this) { + s32 finished = false; + + if (!this->playedSfx) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_TOILET_HAND_VANISH); + this->playedSfx = true; + } + + Math_ApproachF(&this->actor.scale.x, 0.0f, 0.21f, 0.3f); + if (this->actor.scale.x < FULLY_GROWN_SCALE / 100.0f) { + this->actor.scale.x = 0.0f; + this->stateFlags &= ~TOILET_HAND_STATE_VANISHING; + finished = true; + } + this->heightOffset = (this->actor.scale.x / FULLY_GROWN_SCALE) * 4.0f; + this->actor.world.pos.y = this->actor.home.pos.y + this->heightOffset; + Actor_SetScale(&this->actor, this->actor.scale.x); + + return finished; +} + +typedef enum { + /* 0 */ TOILET_HAND_BEHAVIOUR_WAIT_FOR_ITEM, // and check if item is suitable + /* 1 */ TOILET_HAND_BEHAVIOUR_TAKE_ITEM, // take paper and disappear to use it + /* 2 */ TOILET_HAND_BEHAVIOUR_USE_ITEM, // using paper, flushing + /* 3 */ TOILET_HAND_BEHAVIOUR_REAPPEAR, // reappear with reward + /* 4 */ TOILET_HAND_BEHAVIOUR_REWARD_GIVEN, +} ToiletHandBehaviour; + +// msgevent callback/communication. Follow and choose parts of script to run +s32 EnBjt_ChooseBehaviour(Actor* thisx, PlayState* play) { + Player* player = GET_PLAYER(play); + EnBjt* this = THIS; + s32 itemAP; + s32 scriptBranch = 0; + + switch (this->behaviour) { + case TOILET_HAND_BEHAVIOUR_WAIT_FOR_ITEM: + switch (Message_GetState(&play->msgCtx)) { + case TEXT_STATE_CHOICE: + case TEXT_STATE_5: + if (!Message_ShouldAdvance(play)) { + break; + } + // Fallthrough + case TEXT_STATE_16: + itemAP = func_80123810(play); + if ((itemAP == PLAYER_AP_DEED_LAND) || (itemAP == PLAYER_AP_LETTER_TO_KAFEI) || + (itemAP == PLAYER_AP_DEED_SWAMP) || (itemAP == PLAYER_AP_DEED_MOUNTAIN) || + (itemAP == PLAYER_AP_DEED_OCEAN) || (itemAP == PLAYER_AP_LETTER_MAMA)) { + EnBjt_ChangeAnim(this, TOILET_HAND_ANIM_WAITING_MORPH); + this->playedSfx = false; + this->behaviour++; + scriptBranch = 1; // Right item + } else if (itemAP < 0) { + this->playedSfx = false; + this->behaviour++; + scriptBranch = 3; // Not showing item + } else if (itemAP != 0) { + this->playedSfx = false; + this->behaviour++; + scriptBranch = 2; // Wrong item + } + break; + + default: + break; + } + break; + + case TOILET_HAND_BEHAVIOUR_TAKE_ITEM: + if (player->exchangeItemId != PLAYER_AP_NONE) { + EnBjt_TakeItem(player->exchangeItemId); + player->exchangeItemId = PLAYER_AP_NONE; + } + if (EnBjt_Vanish(this)) { + this->timer = 60; + this->behaviour++; + scriptBranch = 1; // Right item + } + break; + + case TOILET_HAND_BEHAVIOUR_USE_ITEM: + if (DECR(this->timer) == 0) { + EnBjt_ChangeAnim(this, TOILET_HAND_ANIM_FIST); // change while not visible + this->playedSfx = false; + this->behaviour++; + } else if (this->timer == 10) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_TOILET_WATER); + } + break; + + case TOILET_HAND_BEHAVIOUR_REAPPEAR: + if (EnBjt_Appear(this)) { + this->behaviour++; + scriptBranch = 1; // Right item + } + break; + + case TOILET_HAND_BEHAVIOUR_REWARD_GIVEN: + EnBjt_ChangeAnim(this, TOILET_HAND_ANIM_OPEN_HAND); + this->behaviour++; + scriptBranch = 1; // Right item + break; + + default: + break; + } + + return scriptBranch; +} + +s32 EnBjt_CheckTalk(EnBjt* this, PlayState* play) { + s32 ret = false; + + if ((this->stateFlags & 7) && Actor_ProcessTalkRequest(&this->actor, &play->state)) { + this->stateFlags |= TOILET_HAND_STATE_TALKING; + SubS_UpdateFlags(&this->stateFlags, 0, 7); + this->msgEventCallback = EnBjt_ChooseBehaviour; + this->behaviour = 0; + this->actionFunc = EnBjt_Talk; + ret = true; + } + return ret; +} + +s32 EnBjt_ChooseAnimation(EnBjt* this, PlayState* play) { + Player* player = GET_PLAYER(play); + u16 curTextId = play->msgCtx.currentTextId; + + if (player->stateFlags1 & (PLAYER_STATE1_40 | PLAYER_STATE1_400)) { // Talking, show item? + this->stateFlags |= TOILET_HAND_STATE_TEXTBOX; + if (this->textId != curTextId) { + switch (curTextId) { + case 0x2949: // Wrong item + EnBjt_ChangeAnim(this, TOILET_HAND_ANIM_WAGGING_FINGER); + break; + + case 0x294A: // Right item + EnBjt_ChangeAnim(this, TOILET_HAND_ANIM_THUMBS_UP); + break; + + default: + break; + } + } + this->textId = curTextId; + } else if (this->stateFlags & TOILET_HAND_STATE_TEXTBOX) { + this->stateFlags &= ~TOILET_HAND_STATE_TEXTBOX; + EnBjt_ChangeAnim(this, TOILET_HAND_ANIM_WAITING); + } + return 0; +} + +// Action function, based on msgEvent +void EnBjt_Talk(EnBjt* this, PlayState* play) { + s16 yaw = this->actor.yawTowardsPlayer; + + // TODO: Casting to remove warning for now + if (func_8010BF58(&this->actor, play, (s32)sMsgEventScript, this->msgEventCallback, &this->msgEventArg4)) { + this->actor.flags &= ~ACTOR_FLAG_100; + SubS_UpdateFlags(&this->stateFlags, 3, 7); + this->stateFlags &= ~TOILET_HAND_STATE_TALKING; + this->msgEventArg4 = 0; + this->actionFunc = EnBjt_FollowSchedule; + } else { + Math_ApproachS(&this->actor.shape.rot.y, yaw, 4, 0x2AA8); + } +} + +// Change state based on schedule and stateFlags +void EnBjt_FollowSchedule(EnBjt* this, PlayState* play) { + ScheduleOutput scheduleOutput; + + if (!Schedule_RunScript(play, sScheduleScript, &scheduleOutput)) { + scheduleOutput.result = TOILET_HAND_SCH_NONE; + } + if (scheduleOutput.result == TOILET_HAND_SCH_AVAILABLE) { + if (this->stateFlags & TOILET_HAND_STATE_APPEARING) { + if (EnBjt_Appear(this)) { + SubS_UpdateFlags(&this->stateFlags, 3, 7); + } + } else if (this->stateFlags & TOILET_HAND_STATE_VANISHING) { + EnBjt_Vanish(this); + } else if (this->stateFlags & TOILET_HAND_STATE_VISIBLE) { + // Vanish if player goes too far away or heart piece given + if ((fabsf(this->actor.playerHeightRel) > 70.0f) || (this->actor.xzDistToPlayer > 140.0f) || + (gSaveContext.save.weekEventReg[90] & 0x80)) { + SubS_UpdateFlags(&this->stateFlags, 0, 7); + this->playedSfx = false; + this->stateFlags &= ~TOILET_HAND_STATE_VISIBLE; + this->stateFlags |= TOILET_HAND_STATE_VANISHING; + } + } else { + // Appear if player approaches and heart piece not given + if ((fabsf(this->actor.playerHeightRel) < 20.0f) && (this->actor.xzDistToPlayer < 70.0f) && + !(gSaveContext.save.weekEventReg[90] & 0x80)) { + this->stateFlags |= TOILET_HAND_STATE_APPEARING; + this->playedSfx = false; + } + } + this->scheduleResult = scheduleOutput.result; + } else { + this->actor.flags |= ACTOR_FLAG_8000000; + Actor_SetScale(&this->actor, 0.0f); + this->stateFlags = 0; + this->msgEventCallback = NULL; + this->scheduleResult = TOILET_HAND_SCH_NONE; + } +} + +void EnBjt_Init(Actor* thisx, PlayState* play) { + EnBjt* this = THIS; + + ActorShape_Init(&this->actor.shape, 0.0f, NULL, 0.0f); + SkelAnime_InitFlex(play, &this->skelAnime, &gToiletHandSkel, NULL, this->jointTable, this->morphTable, + TOILET_HAND_LIMB_MAX); + + this->animIndex = TOILET_HAND_ANIM_NONE; + EnBjt_ChangeAnim(this, TOILET_HAND_ANIM_WAITING); + + Collider_InitAndSetCylinder(play, &this->collider, &this->actor, &sCylinderInit); + CollisionCheck_SetInfo2(&this->actor.colChkInfo, DamageTable_Get(0x16), &sColChkInfoInit); + this->actor.flags |= ACTOR_FLAG_8000000; + Actor_SetScale(&this->actor, 0.0f); + + this->scheduleResult = TOILET_HAND_SCH_NONE; + this->stateFlags = 0; + this->actionFunc = EnBjt_FollowSchedule; +} + +void EnBjt_Destroy(Actor* thisx, PlayState* play) { +} + +void EnBjt_Update(Actor* thisx, PlayState* play) { + EnBjt* this = THIS; + + EnBjt_CheckTalk(this, play); + this->actionFunc(this, play); + EnBjt_ChooseAnimation(this, play); + + if (this->scheduleResult != TOILET_HAND_SCH_NONE) { + EnBjt_UpdateSkelAnime(this); + func_8013C964(&this->actor, play, 60.0f, 10.0f, PLAYER_AP_NONE, this->stateFlags & 7); + Actor_SetFocus(&this->actor, 26.0f); + EnBjt_UpdateCollision(this, play); + } +} + +void EnBjt_Draw(Actor* thisx, PlayState* play) { + EnBjt* this = THIS; + + if (this->scheduleResult != TOILET_HAND_SCH_NONE) { + func_8012C28C(play->state.gfxCtx); + SkelAnime_DrawFlexOpa(play, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, + NULL, NULL, &this->actor); + } +} diff --git a/src/overlays/actors/ovl_En_Bjt/z_en_bjt.h b/src/overlays/actors/ovl_En_Bjt/z_en_bjt.h index 72802294c..f26be4d22 100644 --- a/src/overlays/actors/ovl_En_Bjt/z_en_bjt.h +++ b/src/overlays/actors/ovl_En_Bjt/z_en_bjt.h @@ -2,18 +2,36 @@ #define Z_EN_BJT_H #include "global.h" +#include "objects/object_bjt/object_bjt.h" struct EnBjt; -typedef void (*EnBjtActionFunc)(struct EnBjt*, GlobalContext*); +typedef void (*EnBjtActionFunc)(struct EnBjt*, PlayState*); +typedef s32 (*MsgEventFunc)(Actor*, PlayState*); typedef struct EnBjt { - /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x44]; - /* 0x0188 */ EnBjtActionFunc actionFunc; - /* 0x018C */ char unk_18C[0xD0]; + /* 0x000 */ Actor actor; + /* 0x144 */ SkelAnime skelAnime; + /* 0x188 */ EnBjtActionFunc actionFunc; + /* 0x18C */ ColliderCylinder collider; + /* 0x1D8 */ u8 scheduleResult; + /* 0x1DC */ s32 msgEventArg4; + /* 0x1E0 */ Vec3s jointTable[TOILET_HAND_LIMB_MAX]; + /* 0x20A */ Vec3s morphTable[TOILET_HAND_LIMB_MAX]; + /* 0x234 */ u16 stateFlags; + /* 0x236 */ u16 textId; + /* 0x238 */ f32 animPlaySpeed; + /* 0x23C */ f32 heightOffset; + /* 0x240 */ s16 behaviour; + /* 0x242 */ s16 timer; + /* 0x244 */ UNK_TYPE1 unk_244[4]; + /* 0x248 */ s32 playedSfx; // to only play once + /* 0x24C */ MsgEventFunc msgEventCallback; + /* 0x250 */ s32 animIndex; + /* 0x254 */ UNK_TYPE1 pad_254[8]; } EnBjt; // size = 0x25C + extern const ActorInit En_Bjt_InitVars; #endif // Z_EN_BJT_H diff --git a/src/overlays/actors/ovl_En_Boj_01/z_en_boj_01.c b/src/overlays/actors/ovl_En_Boj_01/z_en_boj_01.c index 5d827f4da..29510c9d7 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 @@ -10,10 +10,10 @@ #define THIS ((EnBoj01*)thisx) -void EnBoj01_Init(Actor* thisx, GlobalContext* globalCtx); -void EnBoj01_Destroy(Actor* thisx, GlobalContext* globalCtx); -void EnBoj01_Update(Actor* thisx, GlobalContext* globalCtx); -void EnBoj01_Draw(Actor* thisx, GlobalContext* globalCtx); +void EnBoj01_Init(Actor* thisx, PlayState* play); +void EnBoj01_Destroy(Actor* thisx, PlayState* play); +void EnBoj01_Update(Actor* thisx, PlayState* play); +void EnBoj01_Draw(Actor* thisx, PlayState* play); const ActorInit En_Boj_01_InitVars = { ACTOR_EN_BOJ_01, @@ -27,11 +27,11 @@ const ActorInit En_Boj_01_InitVars = { (ActorFunc)EnBoj01_Draw, }; -void EnBoj01_Init(Actor* thisx, GlobalContext* globalCtx) { +void EnBoj01_Init(Actor* thisx, PlayState* play) { } -void EnBoj01_Destroy(Actor* thisx, GlobalContext* globalCtx) { +void EnBoj01_Destroy(Actor* thisx, PlayState* play) { } -void EnBoj01_Update(Actor* thisx, GlobalContext* globalCtx) { +void EnBoj01_Update(Actor* thisx, PlayState* play) { } -void EnBoj01_Draw(Actor* thisx, GlobalContext* globalCtx) { +void EnBoj01_Draw(Actor* thisx, PlayState* play) { } 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 8e26fa09c..d68f44bd5 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 @@ -10,10 +10,10 @@ #define THIS ((EnBoj02*)thisx) -void EnBoj02_Init(Actor* thisx, GlobalContext* globalCtx); -void EnBoj02_Destroy(Actor* thisx, GlobalContext* globalCtx); -void EnBoj02_Update(Actor* thisx, GlobalContext* globalCtx); -void EnBoj02_Draw(Actor* thisx, GlobalContext* globalCtx); +void EnBoj02_Init(Actor* thisx, PlayState* play); +void EnBoj02_Destroy(Actor* thisx, PlayState* play); +void EnBoj02_Update(Actor* thisx, PlayState* play); +void EnBoj02_Draw(Actor* thisx, PlayState* play); const ActorInit En_Boj_02_InitVars = { ACTOR_EN_BOJ_02, @@ -27,11 +27,11 @@ const ActorInit En_Boj_02_InitVars = { (ActorFunc)EnBoj02_Draw, }; -void EnBoj02_Init(Actor* thisx, GlobalContext* globalCtx) { +void EnBoj02_Init(Actor* thisx, PlayState* play) { } -void EnBoj02_Destroy(Actor* thisx, GlobalContext* globalCtx) { +void EnBoj02_Destroy(Actor* thisx, PlayState* play) { } -void EnBoj02_Update(Actor* thisx, GlobalContext* globalCtx) { +void EnBoj02_Update(Actor* thisx, PlayState* play) { } -void EnBoj02_Draw(Actor* thisx, GlobalContext* globalCtx) { +void EnBoj02_Draw(Actor* thisx, PlayState* play) { } 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 4f9325e9d..46477ec33 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 @@ -10,10 +10,10 @@ #define THIS ((EnBoj03*)thisx) -void EnBoj03_Init(Actor* thisx, GlobalContext* globalCtx); -void EnBoj03_Destroy(Actor* thisx, GlobalContext* globalCtx); -void EnBoj03_Update(Actor* thisx, GlobalContext* globalCtx); -void EnBoj03_Draw(Actor* thisx, GlobalContext* globalCtx); +void EnBoj03_Init(Actor* thisx, PlayState* play); +void EnBoj03_Destroy(Actor* thisx, PlayState* play); +void EnBoj03_Update(Actor* thisx, PlayState* play); +void EnBoj03_Draw(Actor* thisx, PlayState* play); const ActorInit En_Boj_03_InitVars = { ACTOR_EN_BOJ_03, @@ -27,11 +27,11 @@ const ActorInit En_Boj_03_InitVars = { (ActorFunc)EnBoj03_Draw, }; -void EnBoj03_Init(Actor* thisx, GlobalContext* globalCtx) { +void EnBoj03_Init(Actor* thisx, PlayState* play) { } -void EnBoj03_Destroy(Actor* thisx, GlobalContext* globalCtx) { +void EnBoj03_Destroy(Actor* thisx, PlayState* play) { } -void EnBoj03_Update(Actor* thisx, GlobalContext* globalCtx) { +void EnBoj03_Update(Actor* thisx, PlayState* play) { } -void EnBoj03_Draw(Actor* thisx, GlobalContext* globalCtx) { +void EnBoj03_Draw(Actor* thisx, PlayState* play) { } 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 09eed96c7..2e080483d 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 @@ -10,10 +10,10 @@ #define THIS ((EnBoj04*)thisx) -void EnBoj04_Init(Actor* thisx, GlobalContext* globalCtx); -void EnBoj04_Destroy(Actor* thisx, GlobalContext* globalCtx); -void EnBoj04_Update(Actor* thisx, GlobalContext* globalCtx); -void EnBoj04_Draw(Actor* thisx, GlobalContext* globalCtx); +void EnBoj04_Init(Actor* thisx, PlayState* play); +void EnBoj04_Destroy(Actor* thisx, PlayState* play); +void EnBoj04_Update(Actor* thisx, PlayState* play); +void EnBoj04_Draw(Actor* thisx, PlayState* play); const ActorInit En_Boj_04_InitVars = { ACTOR_EN_BOJ_04, @@ -27,11 +27,11 @@ const ActorInit En_Boj_04_InitVars = { (ActorFunc)EnBoj04_Draw, }; -void EnBoj04_Init(Actor* thisx, GlobalContext* globalCtx) { +void EnBoj04_Init(Actor* thisx, PlayState* play) { } -void EnBoj04_Destroy(Actor* thisx, GlobalContext* globalCtx) { +void EnBoj04_Destroy(Actor* thisx, PlayState* play) { } -void EnBoj04_Update(Actor* thisx, GlobalContext* globalCtx) { +void EnBoj04_Update(Actor* thisx, PlayState* play) { } -void EnBoj04_Draw(Actor* thisx, GlobalContext* globalCtx) { +void EnBoj04_Draw(Actor* thisx, PlayState* play) { } 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 d6ccba734..3b1508b7b 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 @@ -10,10 +10,10 @@ #define THIS ((EnBoj05*)thisx) -void EnBoj05_Init(Actor* thisx, GlobalContext* globalCtx); -void EnBoj05_Destroy(Actor* thisx, GlobalContext* globalCtx); -void EnBoj05_Update(Actor* thisx, GlobalContext* globalCtx); -void EnBoj05_Draw(Actor* thisx, GlobalContext* globalCtx); +void EnBoj05_Init(Actor* thisx, PlayState* play); +void EnBoj05_Destroy(Actor* thisx, PlayState* play); +void EnBoj05_Update(Actor* thisx, PlayState* play); +void EnBoj05_Draw(Actor* thisx, PlayState* play); const ActorInit En_Boj_05_InitVars = { ACTOR_EN_BOJ_05, @@ -27,11 +27,11 @@ const ActorInit En_Boj_05_InitVars = { (ActorFunc)EnBoj05_Draw, }; -void EnBoj05_Init(Actor* thisx, GlobalContext* globalCtx) { +void EnBoj05_Init(Actor* thisx, PlayState* play) { } -void EnBoj05_Destroy(Actor* thisx, GlobalContext* globalCtx) { +void EnBoj05_Destroy(Actor* thisx, PlayState* play) { } -void EnBoj05_Update(Actor* thisx, GlobalContext* globalCtx) { +void EnBoj05_Update(Actor* thisx, PlayState* play) { } -void EnBoj05_Draw(Actor* thisx, GlobalContext* globalCtx) { +void EnBoj05_Draw(Actor* thisx, PlayState* play) { } 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 eeae2b8de..6b79d6021 100644 --- a/src/overlays/actors/ovl_En_Bom/z_en_bom.c +++ b/src/overlays/actors/ovl_En_Bom/z_en_bom.c @@ -5,31 +5,32 @@ */ #include "z_en_bom.h" +#include "z64rumble.h" #include "objects/gameplay_keep/gameplay_keep.h" #define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_20) #define THIS ((EnBom*)thisx) -void EnBom_Init(Actor* thisx, GlobalContext* globalCtx); -void EnBom_Destroy(Actor* thisx, GlobalContext* globalCtx); -void EnBom_Update(Actor* thisx, GlobalContext* globalCtx); -void EnBom_Draw(Actor* thisx, GlobalContext* globalCtx); +void EnBom_Init(Actor* thisx, PlayState* play); +void EnBom_Destroy(Actor* thisx, PlayState* play); +void EnBom_Update(Actor* thisx, PlayState* play); +void EnBom_Draw(Actor* thisx, PlayState* play); -void func_80871058(EnBom* this, GlobalContext* globalCtx); -void func_808714D4(EnBom* this, GlobalContext* globalCtx); -void func_80872648(GlobalContext* globalCtx, Vec3f* arg1); -void func_808726DC(GlobalContext* globalCtx, Vec3f* arg1, Vec3f* arg2, Vec3f* arg3, s32 arg4); -void func_80872BC0(GlobalContext* globalCtx, s32 arg1); +void func_80871058(EnBom* this, PlayState* play); +void func_808714D4(EnBom* this, PlayState* play); +void func_80872648(PlayState* play, Vec3f* arg1); +void func_808726DC(PlayState* play, Vec3f* arg1, Vec3f* arg2, Vec3f* arg3, s32 arg4); +void func_80872BC0(PlayState* play, s32 arg1); typedef struct { - /* 0x00 */ Vec3f unk_00; - /* 0x0C */ Vec3f unk_0C; - /* 0x18 */ s16 unk_18; - /* 0x1A */ s16 unk_1A; -} EnBomStruct; // size = 0x1C + /* 0x00 */ Vec3f pos; + /* 0x0C */ Vec3f velocity; + /* 0x18 */ s16 rotY; + /* 0x1A */ s16 rotX; +} PowderKegFuseSegment; // size = 0x1C -static EnBomStruct D_80874650[16]; +static PowderKegFuseSegment sPowderKegFuseSegments[16]; const ActorInit En_Bom_InitVars = { ACTOR_EN_BOM, @@ -88,7 +89,7 @@ static ColliderJntSphInit sJntSphInit1 = { OC2_NONE, COLSHAPE_JNTSPH, }, - 1, + ARRAY_COUNT(sJntSphElementsInit1), sJntSphElementsInit1, }; @@ -115,7 +116,7 @@ static ColliderJntSphInit sJntSphInit2 = { OC2_NONE, COLSHAPE_JNTSPH, }, - 1, + ARRAY_COUNT(sJntSphElementsInit2), sJntSphElementsInit2, }; @@ -125,7 +126,7 @@ static InitChainEntry sInitChain[] = { ICHAIN_F32_DIV1000(gravity, -4000, ICHAIN_STOP), }; -void EnBom_Init(Actor* thisx, GlobalContext* globalCtx) { +void EnBom_Init(Actor* thisx, PlayState* play) { EnBom* this = THIS; s32 params; @@ -138,25 +139,25 @@ void EnBom_Init(Actor* thisx, GlobalContext* globalCtx) { this->flashSpeedScale = 7; this->isPowderKeg = ENBOM_GETX_1(&this->actor); if (this->isPowderKeg) { - globalCtx->actorCtx.unk5 |= 1; + play->actorCtx.unk5 |= 1; this->timer = gSaveContext.powderKegTimer; } else { this->timer = 70; } - Collider_InitCylinder(globalCtx, &this->collider1); - Collider_InitJntSph(globalCtx, &this->collider2); - Collider_SetCylinder(globalCtx, &this->collider1, &this->actor, &sCylinderInit); + Collider_InitCylinder(play, &this->collider1); + Collider_InitJntSph(play, &this->collider2); + Collider_SetCylinder(play, &this->collider1, &this->actor, &sCylinderInit); if (!this->isPowderKeg) { - Collider_SetJntSph(globalCtx, &this->collider2, &this->actor, &sJntSphInit1, &this->collider3); + Collider_SetJntSph(play, &this->collider2, &this->actor, &sJntSphInit1, &this->collider3); this->collider1.dim.radius = 6; this->collider1.dim.height = 11; } else { - Collider_SetJntSph(globalCtx, &this->collider2, &this->actor, &sJntSphInit2, &this->collider3); + Collider_SetJntSph(play, &this->collider2, &this->actor, &sJntSphInit2, &this->collider3); this->collider1.dim.radius = 20; this->collider1.dim.height = 36; - func_80872648(globalCtx, &this->actor.world.pos); + func_80872648(play, &this->actor.world.pos); } this->collider3.info.toucher.damage += ENBOM_GETZ_FF00(thisx); @@ -171,7 +172,7 @@ void EnBom_Init(Actor* thisx, GlobalContext* globalCtx) { this->actor.flags |= ACTOR_FLAG_100000; - if (Actor_HasParent(&this->actor, globalCtx)) { + if (Actor_HasParent(&this->actor, play)) { this->actionFunc = func_808714D4; this->actor.room = -1; Actor_SetScale(&this->actor, enBomScales[this->isPowderKeg]); @@ -181,24 +182,24 @@ void EnBom_Init(Actor* thisx, GlobalContext* globalCtx) { } } -void EnBom_Destroy(Actor* thisx, GlobalContext* globalCtx) { +void EnBom_Destroy(Actor* thisx, PlayState* play) { EnBom* this = THIS; - Collider_DestroyJntSph(globalCtx, &this->collider2); - Collider_DestroyCylinder(globalCtx, &this->collider1); + Collider_DestroyJntSph(play, &this->collider2); + Collider_DestroyCylinder(play, &this->collider1); if (this->isPowderKeg) { - globalCtx->actorCtx.unk5 &= ~1; + play->actorCtx.unk5 &= ~1; } } -void func_80871058(EnBom* this, GlobalContext* globalCtx) { +void func_80871058(EnBom* this, PlayState* play) { static Vec3f D_80872E68[] = { { 2.0f, -6.0f, -0.3f }, { 1.5f, -5.0f, -0.6f }, { 0.2f, -6.0f, -0.1f }, }; - if (Actor_HasParent(&this->actor, globalCtx)) { + if (Actor_HasParent(&this->actor, play)) { this->actionFunc = func_808714D4; this->actor.room = -1; return; @@ -226,7 +227,7 @@ void func_80871058(EnBom* this, GlobalContext* globalCtx) { Math_StepToF(&this->actor.speedXZ, 0.0f, 0.08f); } else { Vec3f* sp58; - u32 sp54 = func_800C99D4(&globalCtx->colCtx, this->actor.floorPoly, this->actor.floorBgId); + u32 sp54 = func_800C99D4(&play->colCtx, this->actor.floorPoly, this->actor.floorBgId); Vec3f sp48; s16 sp46; f32 sp40; @@ -259,7 +260,7 @@ void func_80871058(EnBom* this, GlobalContext* globalCtx) { sp38 = sqrtf(SQ(sp40) + SQ(sp3C)); if ((sp38 < this->actor.speedXZ) || - (SurfaceType_GetSlope(&globalCtx->colCtx, this->actor.floorPoly, this->actor.floorBgId) == 1)) { + (SurfaceType_GetSlope(&play->colCtx, this->actor.floorPoly, this->actor.floorBgId) == 1)) { if (sp38 > 16.0f) { this->actor.speedXZ = 16.0f; } else { @@ -290,24 +291,24 @@ void func_80871058(EnBom* this, GlobalContext* globalCtx) { this->actor.bgCheckFlags &= ~1; } } else if (this->timer >= 4) { - Actor_LiftActor(&this->actor, globalCtx); + Actor_LiftActor(&this->actor, play); } } Actor_MoveWithGravity(&this->actor); } -void func_808714D4(EnBom* this, GlobalContext* globalCtx) { - if (Actor_HasNoParent(&this->actor, globalCtx)) { +void func_808714D4(EnBom* this, PlayState* play) { + if (Actor_HasNoParent(&this->actor, play)) { this->actionFunc = func_80871058; - this->actor.room = globalCtx->roomCtx.currRoom.num; + this->actor.room = play->roomCtx.currRoom.num; this->actor.flags &= ~ACTOR_FLAG_100000; this->actor.bgCheckFlags &= ~1; Math_Vec3s_ToVec3f(&this->actor.prevPos, &this->actor.home.rot); if (this->isPowderKeg) { gSaveContext.powderKegTimer = 0; } - func_80871058(this, globalCtx); + func_80871058(this, play); } else { Math_Vec3f_ToVec3s(&this->actor.home.rot, &this->actor.parent->world.pos); if (this->isPowderKeg) { @@ -317,7 +318,7 @@ void func_808714D4(EnBom* this, GlobalContext* globalCtx) { Math_ScaledStepToS(&this->unk_1FA, 0, 2000); } -void func_808715B8(EnBom* this, GlobalContext* globalCtx) { +void func_808715B8(EnBom* this, PlayState* play) { static s16 D_80872E8C[] = { 100, 200 }; static Color_RGBA8 D_80872E90 = { 185, 140, 70, 255 }; static Color_RGBA8 D_80872E94 = { 255, 255, 255, 255 }; @@ -338,7 +339,7 @@ void func_808715B8(EnBom* this, GlobalContext* globalCtx) { if (this->collider2.elements->dim.modelSphere.radius == 0) { this->actor.flags |= ACTOR_FLAG_20; - func_8013ECE0(this->actor.xzDistToPlayer, 255, 20, 150); + Rumble_Request(this->actor.xzDistToPlayer, 255, 20, 150); } this->collider2.elements->dim.worldSphere.radius = D_80872E8C[this->isPowderKeg]; @@ -347,35 +348,35 @@ void func_808715B8(EnBom* this, GlobalContext* globalCtx) { } if (this->actor.params == ENBOM_1) { - CollisionCheck_SetAT(globalCtx, &globalCtx->colChkCtx, &this->collider2.base); + CollisionCheck_SetAT(play, &play->colChkCtx, &this->collider2.base); } - if (globalCtx->envCtx.lightSettings.diffuseColor1[0] != 0) { - globalCtx->envCtx.lightSettings.diffuseColor1[0] -= 25; + if (play->envCtx.lightSettings.diffuseColor1[0] != 0) { + play->envCtx.lightSettings.diffuseColor1[0] -= 25; } - if (globalCtx->envCtx.lightSettings.diffuseColor1[1] != 0) { - globalCtx->envCtx.lightSettings.diffuseColor1[1] -= 25; + if (play->envCtx.lightSettings.diffuseColor1[1] != 0) { + play->envCtx.lightSettings.diffuseColor1[1] -= 25; } - if (globalCtx->envCtx.lightSettings.diffuseColor1[2] != 0) { - globalCtx->envCtx.lightSettings.diffuseColor1[2] -= 25; + if (play->envCtx.lightSettings.diffuseColor1[2] != 0) { + play->envCtx.lightSettings.diffuseColor1[2] -= 25; } - if (globalCtx->envCtx.lightSettings.ambientColor[0] != 0) { - globalCtx->envCtx.lightSettings.ambientColor[0] -= 25; + if (play->envCtx.lightSettings.ambientColor[0] != 0) { + play->envCtx.lightSettings.ambientColor[0] -= 25; } - if (globalCtx->envCtx.lightSettings.ambientColor[1] != 0) { - globalCtx->envCtx.lightSettings.ambientColor[1] -= 25; + if (play->envCtx.lightSettings.ambientColor[1] != 0) { + play->envCtx.lightSettings.ambientColor[1] -= 25; } - if (globalCtx->envCtx.lightSettings.ambientColor[2] != 0) { - globalCtx->envCtx.lightSettings.ambientColor[2] -= 25; + if (play->envCtx.lightSettings.ambientColor[2] != 0) { + play->envCtx.lightSettings.ambientColor[2] -= 25; } if (this->timer == 0) { - func_80123590(globalCtx, &this->actor); + func_80123590(play, &this->actor); Actor_MarkForDeath(&this->actor); } @@ -383,14 +384,14 @@ 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; - if (BgCheck_EntityRaycastFloor3(&globalCtx->colCtx, &spB0, &spAC, &spB4) != BGCHECK_Y_MIN) { - temp_s0 = func_800C99D4(&globalCtx->colCtx, spB0, spAC); - temp_f20 = BgCheck_EntityRaycastFloor1(&globalCtx->colCtx, &spB0, &spB4); + if (BgCheck_EntityRaycastFloor3(&play->colCtx, &spB0, &spAC, &spB4) != BGCHECK_Y_MIN) { + temp_s0 = func_800C99D4(&play->colCtx, spB0, spAC); + temp_f20 = BgCheck_EntityRaycastFloor1(&play->colCtx, &spB0, &spB4); if ((temp_s0 == 4) || (temp_s0 == 15) || (temp_s0 == 14)) { if (temp_s0 == 4) { @@ -400,7 +401,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; @@ -410,7 +411,7 @@ void func_808715B8(EnBom* this, GlobalContext* globalCtx) { spA0.z = spB4.z; temp_f20 = Rand_ZeroFloat(250.0f); - func_800B0F18(globalCtx, &spA0, &sp94, &sp88, &sp84, &sp80, temp_f20 + 950.0f, 10, + func_800B0F18(play, &spA0, &sp94, &sp88, &sp84, &sp80, temp_f20 + 950.0f, 10, Rand_ZeroFloat(5.0f) + 14.0f); } } @@ -421,7 +422,7 @@ void func_808715B8(EnBom* this, GlobalContext* globalCtx) { static s16 D_80872E98[] = { 3, 5 }; static s16 D_80872E9C[] = { 10, 15 }; -void EnBom_Update(Actor* thisx, GlobalContext* globalCtx) { +void EnBom_Update(Actor* thisx, PlayState* play) { Vec3f spA4 = { 0.0f, 0.0f, 0.0f }; Vec3f sp98 = { 0.0f, 0.1f, 0.0f }; Vec3f sp8C = { 0.0f, 0.0f, 0.0f }; @@ -430,13 +431,13 @@ void EnBom_Update(Actor* thisx, GlobalContext* globalCtx) { Color_RGBA8 sp70 = { 255, 255, 255, 255 }; EnBom* this = THIS; s32 pad; - Player* player = GET_PLAYER(globalCtx); + Player* player = GET_PLAYER(play); if (player->stateFlags1 & 2) { return; } - if (Player_GetMask(globalCtx) == PLAYER_MASK_GIANT) { + if (Player_GetMask(play) == PLAYER_MASK_GIANT) { Actor_MarkForDeath(thisx); return; } @@ -445,7 +446,7 @@ void EnBom_Update(Actor* thisx, GlobalContext* globalCtx) { this->unk_1FC--; Math_ApproachZeroF(&thisx->speedXZ, 1.0f, 1.0f); Actor_MoveWithGravity(thisx); - Actor_UpdateBgCheckInfo(globalCtx, thisx, 35.0f, 10.0f, 36.0f, 4); + Actor_UpdateBgCheckInfo(play, thisx, 35.0f, 10.0f, 36.0f, 4); if (this->unk_1FC == 0) { if (this->isPowderKeg) { gSaveContext.powderKegTimer = 0; @@ -455,7 +456,7 @@ void EnBom_Update(Actor* thisx, GlobalContext* globalCtx) { } else { thisx->gravity = -1.2f; if (this->timer != 0) { - if (!this->isPowderKeg || (func_808715B8 == this->actionFunc) || !Play_InCsMode(globalCtx)) { + if (!this->isPowderKeg || (func_808715B8 == this->actionFunc) || !Play_InCsMode(play)) { this->timer--; } } @@ -469,9 +470,9 @@ void EnBom_Update(Actor* thisx, GlobalContext* globalCtx) { this->unk_1F8 = 1; } - this->actionFunc(this, globalCtx); + this->actionFunc(this, play); - Actor_UpdateBgCheckInfo(globalCtx, thisx, 35.0f, 10.0f, 36.0f, 0x1F); + Actor_UpdateBgCheckInfo(play, thisx, 35.0f, 10.0f, 36.0f, 0x1F); if (thisx->params == ENBOM_0) { static Vec3us D_80872ED4[] = { { 40, 20, 100 }, @@ -481,8 +482,8 @@ void EnBom_Update(Actor* thisx, GlobalContext* globalCtx) { sp74.y = 0.2f; Math_Vec3f_Copy(&sp80, &thisx->home.pos); - if ((globalCtx->gameplayFrames % 2) == 0) { - EffectSsGSpk_SpawnFuse(globalCtx, thisx, &sp80, &spA4, &sp8C); + if ((play->gameplayFrames % 2) == 0) { + EffectSsGSpk_SpawnFuse(play, thisx, &sp80, &spA4, &sp8C); } if (this->isPowderKeg) { func_801A0810(&thisx->projectedPos, NA_SE_IT_BIG_BOMB_IGNIT - SFX_FLAG, @@ -494,14 +495,14 @@ void EnBom_Update(Actor* thisx, GlobalContext* globalCtx) { } sp80.y += 3.0f; - func_800B0DE0(globalCtx, &sp80, &spA4, &sp74, &sp70, &sp70, 50, 5); + func_800B0DE0(play, &sp80, &spA4, &sp74, &sp70, &sp70, 50, 5); if ((this->collider1.base.acFlags & AC_HIT) || ((this->collider1.base.ocFlags1 & OC1_HIT) && ((this->collider1.base.oc->category == ACTORCAT_ENEMY) || (this->collider1.base.oc->category == ACTORCAT_BOSS)))) { this->timer = 0; thisx->shape.rot.z = 0; - } else if ((this->timer > 100) && (func_80123F48(globalCtx, &thisx->world.pos, 30.0f, 50.0f))) { + } else if ((this->timer > 100) && (Player_IsBurningStickInRange(play, &thisx->world.pos, 30.0f, 50.0f))) { this->timer = 100; } @@ -527,17 +528,17 @@ void EnBom_Update(Actor* thisx, GlobalContext* globalCtx) { if (this->timer == 0) { sp80 = thisx->world.pos; sp80.y += 10.0f; - if (Actor_HasParent(thisx, globalCtx)) { + if (Actor_HasParent(thisx, play)) { sp80.y += 30.0f; } - 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.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); + Actor_Spawn(&play->actorCtx, play, ACTOR_EN_CLEAR_TAG, sp80.x, sp80.y - 10.0f, sp80.z, 0, 0, 0, + this->isPowderKeg); + func_800BC848(thisx, play, D_80872E98[this->isPowderKeg], D_80872E9C[this->isPowderKeg]); + play->envCtx.lightSettings.diffuseColor1[0] = play->envCtx.lightSettings.diffuseColor1[1] = + play->envCtx.lightSettings.diffuseColor1[2] = 250; + play->envCtx.lightSettings.ambientColor[0] = play->envCtx.lightSettings.ambientColor[1] = + play->envCtx.lightSettings.ambientColor[2] = 250; + Camera_AddQuake(&play->mainCamera, 2, 11, 8); thisx->params = ENBOM_1; this->timer = 10; thisx->flags |= (0x100000 | 0x20); @@ -555,10 +556,10 @@ void EnBom_Update(Actor* thisx, GlobalContext* globalCtx) { if (thisx->params <= ENBOM_0) { Collider_UpdateCylinder(thisx, &this->collider1); - if (!Actor_HasParent(thisx, globalCtx) && (this->unk_1F8 != 0)) { - CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider1.base); + if (!Actor_HasParent(thisx, play) && (this->unk_1F8 != 0)) { + CollisionCheck_SetOC(play, &play->colChkCtx, &this->collider1.base); } - CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->collider1.base); + CollisionCheck_SetAC(play, &play->colChkCtx, &this->collider1.base); } if ((enBomScales[this->isPowderKeg] <= thisx->scale.x) && (thisx->params != ENBOM_1)) { @@ -568,12 +569,12 @@ void EnBom_Update(Actor* thisx, GlobalContext* globalCtx) { sp54.x = thisx->world.pos.x; sp54.y = thisx->world.pos.y + thisx->depthInWater; sp54.z = thisx->world.pos.z; - EffectSsGRipple_Spawn(globalCtx, &sp54, 70, 500, 0); - EffectSsGRipple_Spawn(globalCtx, &sp54, 70, 500, 10); + EffectSsGRipple_Spawn(play, &sp54, 70, 500, 0); + EffectSsGRipple_Spawn(play, &sp54, 70, 500, 10); sp54.y += 10.0f; - EffectSsGSplash_Spawn(globalCtx, &sp54, NULL, NULL, 1, 500); - Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_CLEAR_TAG, sp54.x, sp54.y, sp54.z, 0, 0, 1, 200); - SoundSource_PlaySfxAtFixedWorldPos(globalCtx, &thisx->world.pos, 30, NA_SE_IT_BOMB_UNEXPLOSION); + EffectSsGSplash_Spawn(play, &sp54, NULL, NULL, 1, 500); + Actor_Spawn(&play->actorCtx, play, ACTOR_EN_CLEAR_TAG, sp54.x, sp54.y, sp54.z, 0, 0, 1, 200); + SoundSource_PlaySfxAtFixedWorldPos(play, &thisx->world.pos, 30, NA_SE_IT_BOMB_UNEXPLOSION); this->unk_1F4 = 0.0f; thisx->velocity.y = (KREG(83) * 0.1f) + -2.0f; thisx->gravity = (KREG(84) * 0.1f) + -0.5f; @@ -593,34 +594,32 @@ static Vec3f D_80872F04 = { 0.0f, 0.0f, 0.0f }; #include "overlays/ovl_En_Bom/ovl_En_Bom.c" -void EnBom_Draw(Actor* thisx, GlobalContext* globalCtx) { +void EnBom_Draw(Actor* thisx, PlayState* play) { s32 pad; EnBom* this = THIS; - OPEN_DISPS(globalCtx->state.gfxCtx); + OPEN_DISPS(play->state.gfxCtx); if (this->actor.params == ENBOM_0) { - func_8012C28C(globalCtx->state.gfxCtx); + func_8012C28C(play->state.gfxCtx); Collider_UpdateSpheres(0, &this->collider2); if (!this->isPowderKeg) { - func_800B8050(&this->actor, globalCtx, 0); - Matrix_MultiplyVector3fByState(&D_80872EE0, &this->actor.home.pos); + func_800B8050(&this->actor, play, 0); + 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); + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_OPA_DISP++, gBombCapDL); - Matrix_NormalizeXYZ(&globalCtx->billboardMtxF); - Matrix_InsertXRotation_s(0x4000, MTXMODE_APPLY); + Matrix_ReplaceRotation(&play->billboardMtxF); + Matrix_RotateXS(0x4000, MTXMODE_APPLY); - gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), - G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gDPPipeSync(POLY_OPA_DISP++); gDPSetEnvColor(POLY_OPA_DISP++, (s8)this->unk_1F4, 0, 40, 255); gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, (s8)this->unk_1F4, 0, 40, 255); - gSPDisplayList(POLY_OPA_DISP++, gameplay_keep_DL_015DB0); + gSPDisplayList(POLY_OPA_DISP++, gBombBodyDL); } else { Vec3f sp58; Vec3f sp4C; @@ -629,64 +628,63 @@ 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), - G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - gSPDisplayList(POLY_OPA_DISP++, ovl_En_Bom_DL_80873CA0); - gSPDisplayList(POLY_OPA_DISP++, ovl_En_Bom_DL_808742F8); + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_OPA_DISP++, gPowderKegBarrelDL); + gSPDisplayList(POLY_OPA_DISP++, gPowderKegGoronSkullDL); - func_808726DC(globalCtx, &this->actor.home.pos, &sp58, &sp4C, this->timer); - func_80872BC0(globalCtx, this->timer); + func_808726DC(play, &this->actor.home.pos, &sp58, &sp4C, this->timer); + func_80872BC0(play, this->timer); } } - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->state.gfxCtx); } -void func_80872648(GlobalContext* globalCtx, Vec3f* arg1) { - EnBomStruct* ptr = &D_80874650[0]; +void func_80872648(PlayState* play, Vec3f* arg1) { + PowderKegFuseSegment* fuseSegmentPtr = &sPowderKegFuseSegments[0]; s32 i; - for (i = 0; i < ARRAY_COUNT(D_80874650); i++, ptr++) { - Math_Vec3f_Copy(&ptr->unk_00, arg1); - Math_Vec3f_Copy(&ptr->unk_0C, &gZeroVec3f); - ptr->unk_18 = 0; - ptr->unk_1A = 0x4000; + for (i = 0; i < ARRAY_COUNT(sPowderKegFuseSegments); i++, fuseSegmentPtr++) { + Math_Vec3f_Copy(&fuseSegmentPtr->pos, arg1); + Math_Vec3f_Copy(&fuseSegmentPtr->velocity, &gZeroVec3f); + fuseSegmentPtr->rotY = 0; + fuseSegmentPtr->rotX = 0x4000; } } -void func_808726DC(GlobalContext* globalCtx, Vec3f* arg1, Vec3f* arg2, Vec3f* arg3, s32 arg4) { +void func_808726DC(PlayState* play, Vec3f* arg1, Vec3f* arg2, Vec3f* arg3, s32 arg4) { s32 i; f32 temp_f20; Vec3f spCC; Vec3f spC0; - EnBomStruct* ptr = &D_80874650[0]; - EnBomStruct* ptr2 = &D_80874650[1]; + PowderKegFuseSegment* fuseSegmentPtr = &sPowderKegFuseSegments[0]; + PowderKegFuseSegment* fuseSegmentPtr2 = &sPowderKegFuseSegments[1]; 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_Copy(&fuseSegmentPtr->pos, 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); + fuseSegmentPtr->rotY = Math_FAtan2F(spCC.z, spCC.x); + distXZ = sqrtf(SQXZ(spCC)); + fuseSegmentPtr->rotX = Math_FAtan2F(distXZ, spCC.y); spB0 = (arg4 / 240) + 1; - for (i = 0; i < spB0; i++, ptr++, ptr2++, arg4 -= 240) { + for (i = 0; i < spB0; i++, fuseSegmentPtr++, fuseSegmentPtr2++, arg4 -= 240) { f32 phi_f22; CollisionPoly* spA0; s32 sp9C; @@ -698,8 +696,8 @@ void func_808726DC(GlobalContext* globalCtx, Vec3f* arg1, Vec3f* arg2, Vec3f* ar phi_f22 = (arg4 % 240) * (1.0f / 240) * 8.0f; } - Math_Vec3f_Sum(&ptr2->unk_00, &ptr2->unk_0C, &ptr2->unk_00); - temp_f20 = Math_Vec3f_DistXYZAndStoreDiff(arg3, &ptr2->unk_00, &spCC); + Math_Vec3f_Sum(&fuseSegmentPtr2->pos, &fuseSegmentPtr2->velocity, &fuseSegmentPtr2->pos); + temp_f20 = Math_Vec3f_DistXYZAndStoreDiff(arg3, &fuseSegmentPtr2->pos, &spCC); if (temp_f20 < temp_f26) { if (temp_f20 == 0.0f) { spCC.x = 0.0f; @@ -711,33 +709,35 @@ void func_808726DC(GlobalContext* globalCtx, Vec3f* arg1, Vec3f* arg2, Vec3f* ar spCC.y *= temp_f20; spCC.z *= temp_f20; } - Math_Vec3f_Sum(arg3, &spCC, &ptr2->unk_00); + Math_Vec3f_Sum(arg3, &spCC, &fuseSegmentPtr2->pos); } - if (Math_Vec3f_DistXYZAndStoreDiff(&ptr->unk_00, &ptr2->unk_00, &spCC) == 0.0f) { + if (Math_Vec3f_DistXYZAndStoreDiff(&fuseSegmentPtr->pos, &fuseSegmentPtr2->pos, &spCC) == 0.0f) { spCC.x = 0.0f; spCC.y = phi_f22; spCC.z = 0.0f; } - 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); + fuseSegmentPtr2->rotY = Math_FAtan2F(spCC.z, spCC.x); + distXZ = sqrtf(SQXZ(spCC)); + fuseSegmentPtr2->rotX = 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; + fuseSegmentPtr2->rotY = + (s16)CLAMP(BINANG_SUB(fuseSegmentPtr2->rotY, fuseSegmentPtr->rotY), -8000, 8000) + fuseSegmentPtr->rotY; + fuseSegmentPtr2->rotX = + (s16)CLAMP(BINANG_SUB(fuseSegmentPtr2->rotX, fuseSegmentPtr->rotX), -8000, 8000) + fuseSegmentPtr->rotX; - temp_f20 = Math_CosS(ptr2->unk_1A) * phi_f22; - spC0.x = Math_SinS(ptr2->unk_18) * temp_f20; - spC0.z = Math_CosS(ptr2->unk_18) * temp_f20; - spC0.y = Math_SinS(ptr2->unk_1A) * phi_f22; + temp_f20 = Math_CosS(fuseSegmentPtr2->rotX) * phi_f22; + spC0.x = Math_SinS(fuseSegmentPtr2->rotY) * temp_f20; + spC0.z = Math_CosS(fuseSegmentPtr2->rotY) * temp_f20; + spC0.y = Math_SinS(fuseSegmentPtr2->rotX) * phi_f22; - Math_Vec3f_Sum(&ptr->unk_00, &spC0, &ptr2->unk_00); - Math_Vec3f_Copy(&sp90, &ptr2->unk_00); + Math_Vec3f_Sum(&fuseSegmentPtr->pos, &spC0, &fuseSegmentPtr2->pos); + Math_Vec3f_Copy(&sp90, &fuseSegmentPtr2->pos); sp90.y += 50.0f; - temp_f2 = BgCheck_EntityRaycastFloor3(&globalCtx->colCtx, &spA0, &sp9C, &sp90) - ptr2->unk_00.y; + temp_f2 = BgCheck_EntityRaycastFloor3(&play->colCtx, &spA0, &sp9C, &sp90) - fuseSegmentPtr2->pos.y; if (temp_f2 >= 0.0f) { spC0.y += temp_f2; if (phi_f22 < spC0.y) { @@ -755,50 +755,50 @@ void func_808726DC(GlobalContext* globalCtx, Vec3f* arg1, Vec3f* arg2, Vec3f* ar spC0.z *= temp_f2; } - Math_Vec3f_Sum(&ptr->unk_00, &spC0, &ptr2->unk_00); - Math_Vec3f_Copy(&ptr2->unk_0C, &gZeroVec3f); + Math_Vec3f_Sum(&fuseSegmentPtr->pos, &spC0, &fuseSegmentPtr2->pos); + Math_Vec3f_Copy(&fuseSegmentPtr2->velocity, &gZeroVec3f); } - ptr2->unk_0C.y += -1.0f; - if (ptr2->unk_0C.y < -10.0f) { - ptr2->unk_0C.y = -10.0f; + fuseSegmentPtr2->velocity.y += -1.0f; + if (fuseSegmentPtr2->velocity.y < -10.0f) { + fuseSegmentPtr2->velocity.y = -10.0f; } } - Math_Vec3f_Copy(arg1, &ptr->unk_00); + Math_Vec3f_Copy(arg1, &fuseSegmentPtr->pos); } -void func_80872BC0(GlobalContext* globalCtx, s32 arg1) { +void func_80872BC0(PlayState* play, s32 arg1) { s32 temp_s5; s32 i; - EnBomStruct* ptr = &D_80874650[0]; - EnBomStruct* ptr2; + PowderKegFuseSegment* fuseSegmentPtr = &sPowderKegFuseSegments[0]; + PowderKegFuseSegment* fuseSegmentPtr2; - OPEN_DISPS(globalCtx->state.gfxCtx); + OPEN_DISPS(play->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(fuseSegmentPtr->pos.x, fuseSegmentPtr->pos.y, fuseSegmentPtr->pos.z, MTXMODE_NEW); + Matrix_RotateZYX(fuseSegmentPtr->rotX, fuseSegmentPtr->rotY, 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); - gSPDisplayList(POLY_OPA_DISP++, ovl_En_Bom_DL_80872F98); + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_OPA_DISP++, gPowderKegFuseMaterialDL); temp_s5 = (arg1 / 240) + 1; - ptr2 = &D_80874650[1]; + fuseSegmentPtr2 = &sPowderKegFuseSegments[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); + for (i = 1; i < temp_s5; i++, fuseSegmentPtr2++) { + Matrix_Translate(fuseSegmentPtr2->pos.x, fuseSegmentPtr2->pos.y, fuseSegmentPtr2->pos.z, MTXMODE_NEW); + Matrix_RotateZYX(fuseSegmentPtr2->rotX, fuseSegmentPtr2->rotY, 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); + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); if ((i % 2) == 0) { - gSPDisplayList(POLY_OPA_DISP++, ovl_En_Bom_DL_80873020); + gSPDisplayList(POLY_OPA_DISP++, gPowderKegFuseModel1DL); } else { - gSPDisplayList(POLY_OPA_DISP++, ovl_En_Bom_DL_80873040); + gSPDisplayList(POLY_OPA_DISP++, gPowderKegFuseModel2DL); } } - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->state.gfxCtx); } diff --git a/src/overlays/actors/ovl_En_Bom/z_en_bom.h b/src/overlays/actors/ovl_En_Bom/z_en_bom.h index a0555ab24..fe8eaadf1 100644 --- a/src/overlays/actors/ovl_En_Bom/z_en_bom.h +++ b/src/overlays/actors/ovl_En_Bom/z_en_bom.h @@ -5,7 +5,7 @@ struct EnBom; -typedef void (*EnBomActionFunc)(struct EnBom*, GlobalContext*); +typedef void (*EnBomActionFunc)(struct EnBom*, PlayState*); #define ENBOM_GETX_1(thisx) ((thisx)->shape.rot.x & 1) #define ENBOM_GETZ_80(thisx) ((thisx)->shape.rot.z & 0x80) 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 321468424..21fc9901f 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 @@ -11,27 +11,27 @@ #define THIS ((EnBomBowlMan*)thisx) -void EnBomBowlMan_Init(Actor* thisx, GlobalContext* globalCtx); -void EnBomBowlMan_Destroy(Actor* thisx, GlobalContext* globalCtx); -void EnBomBowlMan_Update(Actor* thisx, GlobalContext* globalCtx); -void EnBomBowlMan_Draw(Actor* thisx, GlobalContext* globalCtx); +void EnBomBowlMan_Init(Actor* thisx, PlayState* play); +void EnBomBowlMan_Destroy(Actor* thisx, PlayState* play); +void EnBomBowlMan_Update(Actor* thisx, PlayState* play); +void EnBomBowlMan_Draw(Actor* thisx, PlayState* play); -void func_809C4BC4(EnBomBowlMan* this, GlobalContext* globalCtx); -void func_809C4DA4(EnBomBowlMan* this, GlobalContext* globalCtx); -void func_809C51B4(EnBomBowlMan* this, GlobalContext* globalCtx); +void func_809C4BC4(EnBomBowlMan* this, PlayState* play); +void func_809C4DA4(EnBomBowlMan* this, PlayState* play); +void func_809C51B4(EnBomBowlMan* this, PlayState* play); void func_809C52B4(EnBomBowlMan* this); -void func_809C5310(EnBomBowlMan* this, GlobalContext* globalCtx); +void func_809C5310(EnBomBowlMan* this, PlayState* play); 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_809C5408(EnBomBowlMan* this, PlayState* play); +void func_809C5524(EnBomBowlMan* this, PlayState* play); +void func_809C5598(EnBomBowlMan* this, PlayState* play); +void func_809C5738(EnBomBowlMan* this, PlayState* play); +void func_809C59A4(EnBomBowlMan* this, PlayState* play); +void func_809C59F0(EnBomBowlMan* this, PlayState* play); +void func_809C5AA4(EnBomBowlMan* this, PlayState* play); +void func_809C5B1C(EnBomBowlMan* this, PlayState* play); void func_809C5BA0(EnBomBowlMan* this); -void func_809C5BF4(EnBomBowlMan* this, GlobalContext* globalCtx); +void func_809C5BF4(EnBomBowlMan* this, PlayState* play); s32 D_809C6100 = 0; @@ -70,13 +70,13 @@ Vec3f D_809C61A0[] = { { -610.0f, 200.0f, -2350.0f }, { -570.0f, 200.0f, -2350.0f }, }; -void EnBomBowlMan_Init(Actor* thisx, GlobalContext* globalCtx) { +void EnBomBowlMan_Init(Actor* thisx, PlayState* play) { EnBomBowlMan* this = THIS; 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, + SkelAnime_InitFlex(play, &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); @@ -85,7 +85,7 @@ void EnBomBowlMan_Init(Actor* thisx, GlobalContext* globalCtx) { if (this->unk_2F6 == ENBOMBOWLMAN_F0_0) { if (this->unk_2F4 == 0) { - func_809C4BC4(this, globalCtx); + func_809C4BC4(this, play); } else { this->unk_2F4--; func_809C5BA0(this); @@ -94,11 +94,11 @@ void EnBomBowlMan_Init(Actor* thisx, GlobalContext* globalCtx) { } this->unk_29A = ENBOMBOWLMAN_GET_FF00(&this->actor); - this->path = SubS_GetPathByIndex(globalCtx, this->unk_29A, 0x3F); + this->path = SubS_GetPathByIndex(play, this->unk_29A, 0x3F); this->unk_2C8 = 80.0f; - if ((gSaveContext.save.entranceIndex == 0xD220) && (gSaveContext.save.weekEventReg[73] & 0x80) && - !CHECK_QUEST_ITEM(ITEM_BOTTLE)) { + if ((gSaveContext.save.entrance == ENTRANCE(EAST_CLOCK_TOWN, 2)) && (gSaveContext.save.weekEventReg[73] & 0x80) && + !CHECK_QUEST_ITEM(QUEST_BOMBERS_NOTEBOOK)) { this->unk_2D6 = this->actor.cutscene; if (this->unk_2D6 == 0) { Actor_MarkForDeath(&this->actor); @@ -109,7 +109,7 @@ void EnBomBowlMan_Init(Actor* thisx, GlobalContext* globalCtx) { } } -void EnBomBowlMan_Destroy(Actor* thisx, GlobalContext* globalCtx) { +void EnBomBowlMan_Destroy(Actor* thisx, PlayState* play) { } void func_809C493C(EnBomBowlMan* this, s32 arg1, f32 arg2) { @@ -163,7 +163,7 @@ void func_809C4B6C(EnBomBowlMan* this) { } } -void func_809C4BC4(EnBomBowlMan* this, GlobalContext* globalCtx) { +void func_809C4BC4(EnBomBowlMan* this, PlayState* play) { s32 pad; s32 i; Vec3f sp7C; @@ -181,9 +181,8 @@ void func_809C4BC4(EnBomBowlMan* this, GlobalContext* globalCtx) { 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); + bomBowlMan = (EnBomBowlMan*)Actor_SpawnAsChild(&play->actorCtx, &this->actor, play, 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; @@ -209,11 +208,11 @@ void func_809C4BC4(EnBomBowlMan* this, GlobalContext* globalCtx) { this->actionFunc = func_809C4DA4; } -void func_809C4DA4(EnBomBowlMan* this, GlobalContext* globalCtx) { +void func_809C4DA4(EnBomBowlMan* this, PlayState* play) { Math_SmoothStepToS(&this->unk_290, this->unk_2D4, 1, 5000, 0); if (this->unk_2B8 == 0) { - Player* player = GET_PLAYER(globalCtx); + Player* player = GET_PLAYER(play); if (ActorCutscene_GetCurrentIndex() == 0x7C) { ActorCutscene_Stop(0x7C); @@ -232,24 +231,24 @@ void func_809C4DA4(EnBomBowlMan* this, GlobalContext* globalCtx) { 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); + Message_StartTextbox(play, D_809C618C[0], &this->actor); } else { - Message_StartTextbox(globalCtx, D_809C6198[0], &this->actor); + Message_StartTextbox(play, D_809C6198[0], &this->actor); } } - if ((this->unk_2BC == 0) && (Message_GetState(&globalCtx->msgCtx) == 5) && Message_ShouldAdvance(globalCtx)) { - Player* player = GET_PLAYER(globalCtx); + if ((this->unk_2BC == 0) && (Message_GetState(&play->msgCtx) == TEXT_STATE_5) && Message_ShouldAdvance(play)) { + Player* player = GET_PLAYER(play); s32 pad; s32 sp28 = false; - func_801477B4(globalCtx); + func_801477B4(play); switch (this->unk_2C0) { case 0: this->unk_2C0 = 1; D_809C6104 = 1; - Camera_SetTargetActor(Play_GetCamera(globalCtx, ActorCutscene_GetCurrentCamera(this->unk_2D0)), + Camera_SetTargetActor(Play_GetCamera(play, ActorCutscene_GetCurrentSubCamId(this->unk_2D0)), &this->unk_2D8[0]->actor); this->unk_2D4 = 0; this->unk_2BC = 10; @@ -261,7 +260,7 @@ void func_809C4DA4(EnBomBowlMan* this, GlobalContext* globalCtx) { func_809C493C(this, 3, 1.0f); this->unk_2D4 = this->actor.yawTowardsPlayer; this->unk_2C0 = 2; - if ((player->transformation == PLAYER_FORM_HUMAN) && CHECK_QUEST_ITEM(ITEM_BOTTLE)) { + if ((player->transformation == PLAYER_FORM_HUMAN) && CHECK_QUEST_ITEM(QUEST_BOMBERS_NOTEBOOK)) { this->unk_2C0 = 4; } break; @@ -270,11 +269,11 @@ void func_809C4DA4(EnBomBowlMan* this, GlobalContext* globalCtx) { if (player->transformation == PLAYER_FORM_HUMAN) { this->unk_2B8 = 2; ActorCutscene_Stop(this->unk_2D0); - func_809C59A4(this, globalCtx); + func_809C59A4(this, play); sp28 = true; } else { this->unk_2C0 = 3; - globalCtx->msgCtx.unk11F10 = 0; + play->msgCtx.msgLength = 0; func_809C493C(this, 1, 1.0f); D_809C6100 = 1; if (ActorCutscene_GetCurrentIndex() == 0x7C) { @@ -302,7 +301,7 @@ void func_809C4DA4(EnBomBowlMan* this, GlobalContext* globalCtx) { if (this->unk_2B8 != 2) { ActorCutscene_Stop(this->unk_2D0); } - globalCtx->msgCtx.unk11F10 = 0; + play->msgCtx.msgLength = 0; func_809C493C(this, 1, 1.0f); D_809C6100 = 1; this->actionFunc = func_809C5B1C; @@ -310,9 +309,9 @@ void func_809C4DA4(EnBomBowlMan* this, GlobalContext* globalCtx) { break; case 5: - func_80151BB4(globalCtx, 0x24); - func_80151BB4(globalCtx, 0x25); - func_80151BB4(globalCtx, 0); + func_80151BB4(play, 0x24); + func_80151BB4(play, 0x25); + func_80151BB4(play, 0); this->actionFunc = func_809C51B4; sp28 = true; break; @@ -320,24 +319,24 @@ void func_809C4DA4(EnBomBowlMan* this, GlobalContext* globalCtx) { if (!sp28) { if (player->transformation == PLAYER_FORM_HUMAN) { - func_80151938(globalCtx, D_809C618C[this->unk_2C0]); + func_80151938(play, D_809C618C[this->unk_2C0]); } else { - func_80151938(globalCtx, D_809C6198[this->unk_2C0]); + func_80151938(play, D_809C6198[this->unk_2C0]); } } } } -void func_809C51B4(EnBomBowlMan* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); +void func_809C51B4(EnBomBowlMan* this, PlayState* play) { + Player* player = GET_PLAYER(play); - if ((globalCtx->msgCtx.unk120B1 == 0) && - ((globalCtx->msgCtx.msgMode == 0) || (Message_GetState(&globalCtx->msgCtx) == 6))) { - globalCtx->nextEntranceIndex = Entrance_CreateIndexFromSpawn(6); + if ((play->msgCtx.unk120B1 == 0) && + ((play->msgCtx.msgMode == 0) || (Message_GetState(&play->msgCtx) == TEXT_STATE_DONE))) { + play->nextEntrance = Entrance_CreateFromSpawn(6); gSaveContext.nextCutsceneIndex = 0; - globalCtx->sceneLoadFlag = 0x14; - globalCtx->unk_1887F = 0x56; - gSaveContext.nextTransition = 3; + play->transitionTrigger = TRANS_TRIGGER_START; + play->transitionType = TRANS_TYPE_86; + gSaveContext.nextTransitionType = TRANS_TYPE_03; gSaveContext.save.weekEventReg[75] &= (u8)~0x40; if (player->transformation == PLAYER_FORM_HUMAN) { gSaveContext.save.weekEventReg[84] |= 0x80; @@ -360,13 +359,13 @@ void func_809C52B4(EnBomBowlMan* this) { this->actionFunc = func_809C5310; } -void func_809C5310(EnBomBowlMan* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); +void func_809C5310(EnBomBowlMan* this, PlayState* play) { + Player* player = GET_PLAYER(play); 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_800B7298(play, &this->actor, 7); func_809C53A4(this); } } else { @@ -384,9 +383,9 @@ void func_809C53A4(EnBomBowlMan* this) { this->actionFunc = func_809C5408; } -void func_809C5408(EnBomBowlMan* this, GlobalContext* globalCtx) { +void func_809C5408(EnBomBowlMan* this, PlayState* play) { s32 pad[2]; - Player* player = GET_PLAYER(globalCtx); + Player* player = GET_PLAYER(play); Math_SmoothStepToS(&this->actor.world.rot.y, Math_Vec3f_Yaw(&this->actor.world.pos, &player->actor.world.pos), 1, 0x1388, 0); @@ -396,23 +395,23 @@ void func_809C5408(EnBomBowlMan* this, GlobalContext* globalCtx) { 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); + func_809C5524(this, play); } } -void func_809C5524(EnBomBowlMan* this, GlobalContext* globalCtx) { +void func_809C5524(EnBomBowlMan* this, PlayState* play) { 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); + Message_StartTextbox(play, 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); +void func_809C5598(EnBomBowlMan* this, PlayState* play) { + if ((Message_GetState(&play->msgCtx) == TEXT_STATE_5) && Message_ShouldAdvance(play)) { + func_801477B4(play); if ((this->actor.textId == 0x72F) || (this->actor.textId == 0x730)) { this->actor.textId = 0x731; } else if (this->actor.textId == 0x731) { @@ -424,33 +423,33 @@ void func_809C5598(EnBomBowlMan* this, GlobalContext* globalCtx) { } else if (this->actor.textId == 0x734) { this->actor.textId = 0x715; } else if (this->actor.textId == 0x715) { - func_800B7298(globalCtx, &this->actor, 6); + func_800B7298(play, &this->actor, 6); func_809C493C(this, 17, 1.0f); - func_809C59A4(this, globalCtx); + func_809C59A4(this, play); 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); + func_80151BB4(play, 0x24); + func_80151BB4(play, 0x25); + func_80151BB4(play, 0); + func_800B7298(play, &this->actor, 7); this->actionFunc = func_809C5738; return; } - func_80151938(globalCtx, this->actor.textId); + func_80151938(play, this->actor.textId); } } -void func_809C5738(EnBomBowlMan* this, GlobalContext* globalCtx) { +void func_809C5738(EnBomBowlMan* this, PlayState* play) { 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))) { + if ((play->msgCtx.unk120B1 == 0) && + ((play->msgCtx.msgMode == 0) || (Message_GetState(&play->msgCtx) == TEXT_STATE_DONE))) { this->unk_2C2 = 1; func_809C4B6C(this); if (ActorCutscene_GetCurrentIndex() == 0x7C) { @@ -495,14 +494,14 @@ void func_809C5738(EnBomBowlMan* this, GlobalContext* globalCtx) { } } -void func_809C59A4(EnBomBowlMan* this, GlobalContext* globalCtx) { - Actor_PickUp(&this->actor, globalCtx, GI_50, 300.0f, 300.0f); +void func_809C59A4(EnBomBowlMan* this, PlayState* play) { + Actor_PickUp(&this->actor, play, GI_BOMBERS_NOTEBOOK, 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)) { +void func_809C59F0(EnBomBowlMan* this, PlayState* play) { + if (Actor_HasParent(&this->actor, play)) { this->actor.parent = NULL; if (this->unk_2F6 == ENBOMBOWLMAN_F0_0) { this->unk_2C0 = 3; @@ -510,26 +509,26 @@ void func_809C59F0(EnBomBowlMan* this, GlobalContext* globalCtx) { } else { this->actor.textId = 0x716; } - func_800B8500(&this->actor, globalCtx, 400.0f, 400.0f, -1); + func_800B8500(&this->actor, play, 400.0f, 400.0f, PLAYER_AP_MINUS1); this->actionFunc = func_809C5AA4; } else { - Actor_PickUp(&this->actor, globalCtx, GI_50, 300.0f, 300.0f); + Actor_PickUp(&this->actor, play, GI_BOMBERS_NOTEBOOK, 300.0f, 300.0f); } } -void func_809C5AA4(EnBomBowlMan* this, GlobalContext* globalCtx) { - if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { +void func_809C5AA4(EnBomBowlMan* this, PlayState* play) { + if (Actor_ProcessTalkRequest(&this->actor, &play->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); + func_800B8500(&this->actor, play, 400.0f, 400.0f, PLAYER_AP_MINUS1); } } -void func_809C5B1C(EnBomBowlMan* this, GlobalContext* globalCtx) { +void func_809C5B1C(EnBomBowlMan* this, PlayState* play) { if (ActorCutscene_GetCurrentIndex() == 0x7C) { ActorCutscene_Stop(0x7C); ActorCutscene_SetIntentToPlay(this->unk_2D2); @@ -551,9 +550,9 @@ void func_809C5BA0(EnBomBowlMan* this) { this->actionFunc = func_809C5BF4; } -void func_809C5BF4(EnBomBowlMan* this, GlobalContext* globalCtx) { +void func_809C5BF4(EnBomBowlMan* this, PlayState* play) { f32 sp2C = this->skelAnime.curFrame; - s32 sp28; + s32 subCam; if ((D_809C6104 != 0) && (this->unk_2F8 != 15)) { func_809C493C(this, 15, 1.0f); @@ -574,34 +573,34 @@ void func_809C5BF4(EnBomBowlMan* this, GlobalContext* globalCtx) { } if (this->unk_2F4 == 0) { - sp28 = Play_GetCamera(globalCtx, ActorCutscene_GetCurrentCamera(this->unk_2D2)); + subCam = Play_GetCamera(play, ActorCutscene_GetCurrentSubCamId(this->unk_2D2)); if (D_809C6100 > 5) { - Player* player = GET_PLAYER(globalCtx); + Player* player = GET_PLAYER(play); - func_801477B4(globalCtx); - Camera_SetTargetActor(sp28, &this->unk_2D8[0]->actor); + func_801477B4(play); + Camera_SetTargetActor(subCam, &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); + Message_StartTextbox(play, D_809C618C[this->unk_2C0], &this->actor); } else { this->unk_2C0 = 3; - Message_StartTextbox(globalCtx, D_809C6198[this->unk_2C0], &this->actor); + Message_StartTextbox(play, 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); + Camera_SetTargetActor(subCam, &this->unk_2D8[1 + idx]->actor); } } } } -void EnBomBowlMan_Update(Actor* thisx, GlobalContext* globalCtx) { +void EnBomBowlMan_Update(Actor* thisx, PlayState* play) { EnBomBowlMan* this = THIS; if (this->unk_2BA != 0) { @@ -617,7 +616,7 @@ void EnBomBowlMan_Update(Actor* thisx, GlobalContext* globalCtx) { func_809C49CC(this); Actor_SetFocus(&this->actor, 20.0f); - this->actionFunc(this, globalCtx); + this->actionFunc(this, play); Actor_MoveWithGravity(&this->actor); Math_SmoothStepToS(&this->unk_28A, this->unk_290, 1, 0x1388, 0); @@ -630,11 +629,10 @@ void EnBomBowlMan_Update(Actor* thisx, GlobalContext* globalCtx) { this->unk_2F2 = (s32)Rand_ZeroFloat(60.0f) + 20; } } - Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 20.0f, 20.0f, 50.0f, 0x1D); + Actor_UpdateBgCheckInfo(play, &this->actor, 20.0f, 20.0f, 50.0f, 0x1D); } -s32 EnBomBowlMan_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, - Actor* thisx) { +s32 EnBomBowlMan_OverrideLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, Actor* thisx) { EnBomBowlMan* this = THIS; if (limbIndex == 15) { @@ -672,21 +670,21 @@ 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) { +void EnBomBowlMan_Draw(Actor* thisx, PlayState* play) { EnBomBowlMan* this = THIS; - OPEN_DISPS(globalCtx->state.gfxCtx); + OPEN_DISPS(play->state.gfxCtx); - func_8012C28C(globalCtx->state.gfxCtx); - func_8012C2DC(globalCtx->state.gfxCtx); + func_8012C28C(play->state.gfxCtx); + func_8012C2DC(play->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, + Scene_SetRenderModeXlu(play, 0, 1); + SkelAnime_DrawFlexOpa(play, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, EnBomBowlMan_OverrideLimbDraw, NULL, &this->actor); - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->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 6246a6756..5f630e4e6 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 @@ -5,7 +5,7 @@ struct EnBomBowlMan; -typedef void (*EnBomBowlManActionFunc)(struct EnBomBowlMan*, GlobalContext*); +typedef void (*EnBomBowlManActionFunc)(struct EnBomBowlMan*, PlayState*); #define ENBOMBOWLMAN_GET_F(thisx) ((thisx)->params & 0xF) #define ENBOMBOWLMAN_GET_F0(thisx) (((thisx)->params >> 4) & 0xF) 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 fc63795de..b1b9f8d14 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 @@ -14,16 +14,16 @@ #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 EnBomChu_Init(Actor* thisx, PlayState* play); +void EnBomChu_Destroy(Actor* thisx, PlayState* play); +void EnBomChu_Update(Actor* thisx, PlayState* play); +void EnBomChu_Draw(Actor* thisx, PlayState* play); -void EnBomChu_WaitForRelease(EnBomChu* this, GlobalContext* globalCtx); +void EnBomChu_WaitForRelease(EnBomChu* this, PlayState* play); 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); +void EnBomChu_Move(EnBomChu* this, PlayState* play); +void EnBomChu_Explode(EnBomChu* this, PlayState* play); +void EnBomChu_WaitForDeath(EnBomChu* this, PlayState* play); const ActorInit En_Bom_Chu_InitVars = { ACTOR_EN_BOM_CHU, @@ -67,15 +67,15 @@ static EffectBlureInit2 sBlureInit = { 0, 0, 0, { 0, 0, 0, 0 }, { 0, 0, 0, 0 }, }; -void EnBomChu_Init(Actor* thisx, GlobalContext* globalCtx) { +void EnBomChu_Init(Actor* thisx, PlayState* play) { EnBomChu* this = THIS; Actor_ProcessInitChain(&this->actor, sInitChain); - Collider_InitAndSetSphere(globalCtx, &this->collider, &this->actor, &sSphereInit); + Collider_InitAndSetSphere(play, &this->collider, &this->actor, &sSphereInit); this->collider.dim.worldSphere.radius = sSphereInit.dim.modelSphere.radius; - Effect_Add(globalCtx, &this->blure1Index, EFFECT_BLURE2, 0, 0, &sBlureInit); - Effect_Add(globalCtx, &this->blure2Index, EFFECT_BLURE2, 0, 0, &sBlureInit); + Effect_Add(play, &this->blure1Index, EFFECT_BLURE2, 0, 0, &sBlureInit); + Effect_Add(play, &this->blure2Index, EFFECT_BLURE2, 0, 0, &sBlureInit); this->timer = 120; this->actor.room = -1; @@ -84,18 +84,18 @@ void EnBomChu_Init(Actor* thisx, GlobalContext* globalCtx) { this->actionFunc = EnBomChu_WaitForRelease; } -void EnBomChu_Destroy(Actor* thisx, GlobalContext* globalCtx) { +void EnBomChu_Destroy(Actor* thisx, PlayState* play) { EnBomChu* this = THIS; - Effect_Destroy(globalCtx, this->blure1Index); - Effect_Destroy(globalCtx, this->blure2Index); - Collider_DestroySphere(globalCtx, &this->collider); + Effect_Destroy(play, this->blure1Index); + Effect_Destroy(play, this->blure2Index); + Collider_DestroySphere(play, &this->collider); } /** * Returns true if floorPoly is valid for the Bombchu to move on, false otherwise. */ -s32 EnBomChu_UpdateFloorPoly(EnBomChu* this, CollisionPoly* floorPoly, GlobalContext* globalCtx) { +s32 EnBomChu_UpdateFloorPoly(EnBomChu* this, CollisionPoly* floorPoly, PlayState* play) { Vec3f normal; Vec3f vec; f32 angle; @@ -111,12 +111,11 @@ s32 EnBomChu_UpdateFloorPoly(EnBomChu* this, CollisionPoly* floorPoly, GlobalCon normal.y = COLPOLY_GET_NORMAL(floorPoly->normal.y); normal.z = COLPOLY_GET_NORMAL(floorPoly->normal.z); } else { - EnBomChu_Explode(this, globalCtx); + EnBomChu_Explode(this, play); return false; } normDotUp = DOTXYZ(normal, this->axisUp); - if (fabsf(normDotUp) >= 0.999f) { return false; } @@ -129,21 +128,20 @@ s32 EnBomChu_UpdateFloorPoly(EnBomChu* this, CollisionPoly* floorPoly, GlobalCon Math3D_CrossProduct(&this->axisUp, &normal, &vec); magnitude = Math3D_Vec3fMagnitude(&vec); - if (magnitude < 0.001f) { - EnBomChu_Explode(this, globalCtx); + EnBomChu_Explode(this, play); return false; } Math_Vec3f_Scale(&vec, 1.0f / magnitude); - Matrix_InsertRotationAroundUnitVector_f(angle, &vec, MTXMODE_NEW); - Matrix_MultiplyVector3fByState(&this->axisLeft, &vec); + 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); + EnBomChu_Explode(this, play); return false; } @@ -156,34 +154,34 @@ void EnBomChu_UpdateRotation(EnBomChu* this) { MtxF mf; mf.xx = this->axisLeft.x; - mf.xy = this->axisLeft.y; - mf.xz = this->axisLeft.z; + mf.yx = this->axisLeft.y; + mf.zx = this->axisLeft.z; - mf.yx = this->axisUp.x; + mf.xy = this->axisUp.x; mf.yy = this->axisUp.y; - mf.yz = this->axisUp.z; + mf.zy = this->axisUp.z; - mf.zx = this->axisForwards.x; - mf.zy = this->axisForwards.y; + mf.xz = this->axisForwards.x; + mf.yz = this->axisForwards.y; mf.zz = this->axisForwards.z; - func_8018219C(&mf, &this->actor.world.rot, 0); + 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) { +void EnBomChu_WaitForRelease(EnBomChu* this, PlayState* play) { Player* player; if (this->timer == 0) { - EnBomChu_Explode(this, globalCtx); - } else if (Actor_HasNoParent(&this->actor, globalCtx)) { - player = GET_PLAYER(globalCtx); + EnBomChu_Explode(this, play); + } else if (Actor_HasNoParent(&this->actor, play)) { + player = GET_PLAYER(play); Math_Vec3f_Copy(&this->actor.world.pos, &player->actor.world.pos); - Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 0.0f, 0.0f, 0.0f, 4); + Actor_UpdateBgCheckInfo(play, &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); + func_800B8EF4(play, &this->actor); this->isMoving = true; this->actor.speedXZ = 8.0f; @@ -192,10 +190,10 @@ void EnBomChu_WaitForRelease(EnBomChu* this, GlobalContext* globalCtx) { } } -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))) { +s32 EnBomChu_IsOnCollisionPoly(PlayState* play, Vec3f* posA, Vec3f* posB, Vec3f* posResult, CollisionPoly** poly, + s32* bgId) { + if ((BgCheck_EntityLineTest1(&play->colCtx, posA, posB, posResult, poly, true, true, true, true, bgId)) && + (!(func_800C9A4C(&play->colCtx, *poly, *bgId) & 0x30))) { return true; } @@ -205,13 +203,13 @@ s32 EnBomChu_IsOnCollisionPoly(GlobalContext* globalCtx, Vec3f* posA, Vec3f* pos void EnBomChu_SetupMove(EnBomChu* this) { func_800BE3D0(&this->actor, this->actor.shape.rot.y, &this->actor.shape.rot); - Matrix_RotateY(this->actor.shape.rot.y, MTXMODE_NEW); - Matrix_InsertXRotation_s(this->actor.shape.rot.x, MTXMODE_APPLY); - Matrix_InsertZRotation_s(this->actor.shape.rot.z, MTXMODE_APPLY); + Matrix_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_GetStateTranslationAndScaledY(1.0f, &this->axisUp); - Matrix_GetStateTranslationAndScaledZ(1.0f, &this->axisForwards); - Matrix_GetStateTranslationAndScaledX(1.0f, &this->axisLeft); + 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; @@ -219,7 +217,7 @@ void EnBomChu_SetupMove(EnBomChu* this) { this->actionFunc = EnBomChu_Move; } -void EnBomChu_Move(EnBomChu* this, GlobalContext* globalCtx) { +void EnBomChu_Move(EnBomChu* this, PlayState* play) { CollisionPoly* polySide = NULL; CollisionPoly* polyUpDown = NULL; s32 bgIdSide; @@ -239,7 +237,7 @@ void EnBomChu_Move(EnBomChu* this, GlobalContext* globalCtx) { 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); + EnBomChu_Explode(this, play); return; } @@ -251,20 +249,20 @@ void EnBomChu_Move(EnBomChu* this, GlobalContext* globalCtx) { 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)) { + if (EnBomChu_IsOnCollisionPoly(play, &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); + if (EnBomChu_IsOnCollisionPoly(play, &posA, &posB, &posSide, &polySide, &bgIdSide)) { + isFloorPolyValid = EnBomChu_UpdateFloorPoly(this, polySide, play); 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); + isFloorPolyValid = EnBomChu_UpdateFloorPoly(this, polyUpDown, play); } Math_Vec3f_Copy(&this->actor.world.pos, &posUpDown); @@ -293,8 +291,8 @@ void EnBomChu_Move(EnBomChu* this, GlobalContext* globalCtx) { posB.z = posA.z - (this->axisLeft.z * lineLength); } - if (EnBomChu_IsOnCollisionPoly(globalCtx, &posA, &posB, &posSide, &polySide, &bgIdSide)) { - isFloorPolyValid = EnBomChu_UpdateFloorPoly(this, polySide, globalCtx); + if (EnBomChu_IsOnCollisionPoly(play, &posA, &posB, &posSide, &polySide, &bgIdSide)) { + isFloorPolyValid = EnBomChu_UpdateFloorPoly(this, polySide, play); Math_Vec3f_Copy(&this->actor.world.pos, &posSide); this->actor.floorBgId = bgIdSide; break; @@ -303,7 +301,7 @@ void EnBomChu_Move(EnBomChu* this, GlobalContext* globalCtx) { if (i == 3) { // no collision nearby - EnBomChu_Explode(this, globalCtx); + EnBomChu_Explode(this, play); } } @@ -323,12 +321,12 @@ void EnBomChu_Move(EnBomChu* this, GlobalContext* globalCtx) { } } -void EnBomChu_Explode(EnBomChu* this, GlobalContext* globalCtx) { +void EnBomChu_Explode(EnBomChu* this, PlayState* play) { 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); + bomb = (EnBom*)Actor_Spawn(&play->actorCtx, play, ACTOR_EN_BOM, this->actor.world.pos.x, this->actor.world.pos.y, + this->actor.world.pos.z, 0, 0, 0, 0); this->shouldTimerCountDown = true; this->isMoving = false; @@ -342,7 +340,7 @@ void EnBomChu_Explode(EnBomChu* this, GlobalContext* globalCtx) { 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); + EffectSsBubble_Spawn(play, &this->actor.world.pos, 1.0f, 5.0f, 30.0f, 0.25f); } } @@ -350,14 +348,15 @@ void EnBomChu_Explode(EnBomChu* this, GlobalContext* globalCtx) { this->actionFunc = EnBomChu_WaitForDeath; } -void EnBomChu_WaitForDeath(EnBomChu* this, GlobalContext* globalCtx) { +void EnBomChu_WaitForDeath(EnBomChu* this, PlayState* play) { if (this->timer == 0) { Actor_MarkForDeath(&this->actor); } } /** - * Transform coordinates from actor coordinate space to world space, according to current orientation. + * Transform coordinates from actor coordinate space (origin at actor's world.pos, z-axis is facing + * angle, i.e. shape.rot.y) 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) { @@ -371,7 +370,7 @@ void EnBomChu_ActorCoordsToWorld(EnBomChu* this, Vec3f* offset, Vec3f* pos) { (this->axisForwards.z * offset->z); } -void EnBomChu_SpawnRipplesAndSplashes(EnBomChu* this, GlobalContext* globalCtx, f32 y, s32 spawnExtraRipples) { +void EnBomChu_SpawnRipplesAndSplashes(EnBomChu* this, PlayState* play, f32 y, s32 spawnExtraRipples) { s32 pad; Vec3f pos; @@ -379,21 +378,21 @@ void EnBomChu_SpawnRipplesAndSplashes(EnBomChu* this, GlobalContext* globalCtx, pos.y = y; pos.z = this->actor.world.pos.z; - EffectSsGRipple_Spawn(globalCtx, &pos, 70, 500, 0); + EffectSsGRipple_Spawn(play, &pos, 70, 500, 0); if (spawnExtraRipples) { - EffectSsGRipple_Spawn(globalCtx, &pos, 70, 500, 4); - EffectSsGRipple_Spawn(globalCtx, &pos, 70, 500, 8); + EffectSsGRipple_Spawn(play, &pos, 70, 500, 4); + EffectSsGRipple_Spawn(play, &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); + EffectSsGSplash_Spawn(play, &pos, NULL, NULL, 1, 450); } -void EnBomChu_HandleNonSceneCollision(EnBomChu* this, GlobalContext* globalCtx) { +void EnBomChu_HandleNonSceneCollision(EnBomChu* this, PlayState* play) { Vec3f originalWorldPos; Vec3f posA; Vec3f posB; @@ -409,7 +408,7 @@ void EnBomChu_HandleNonSceneCollision(EnBomChu* this, GlobalContext* globalCtx) 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); + BgCheck2_UpdateActorAttachedToMesh(&play->colCtx, this->actor.floorBgId, &this->actor); if (yaw != this->actor.shape.rot.y) { yaw = this->actor.shape.rot.y - yaw; @@ -438,8 +437,8 @@ void EnBomChu_HandleNonSceneCollision(EnBomChu* this, GlobalContext* globalCtx) 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); + if (EnBomChu_IsOnCollisionPoly(play, &posA, &posB, &originalWorldPos, &poly, &bgId)) { + isFloorPolyValid = EnBomChu_UpdateFloorPoly(this, poly, play); Math_Vec3f_Copy(&this->actor.world.pos, &originalWorldPos); this->actor.floorBgId = bgId; this->actor.speedXZ = 0.0f; @@ -453,7 +452,7 @@ void EnBomChu_HandleNonSceneCollision(EnBomChu* this, GlobalContext* globalCtx) } } -void EnBomChu_Update(Actor* thisx, GlobalContext* globalCtx) { +void EnBomChu_Update(Actor* thisx, PlayState* play) { 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 }; @@ -465,18 +464,18 @@ void EnBomChu_Update(Actor* thisx, GlobalContext* globalCtx) { f32 waterY; if (this->actor.floorBgId != BGCHECK_SCENE) { - EnBomChu_HandleNonSceneCollision(this, globalCtx); + EnBomChu_HandleNonSceneCollision(this, play); } if (this->shouldTimerCountDown) { this->timer--; } - this->actionFunc(this, globalCtx); + this->actionFunc(this, play); if ((this->actionFunc != EnBomChu_WaitForDeath) && - (SurfaceType_IsWallDamage(&globalCtx->colCtx, this->actor.floorPoly, this->actor.floorBgId))) { - EnBomChu_Explode(this, globalCtx); + (SurfaceType_IsWallDamage(&play->colCtx, this->actor.floorPoly, this->actor.floorBgId))) { + EnBomChu_Explode(this, play); return; } @@ -486,9 +485,9 @@ void EnBomChu_Update(Actor* thisx, GlobalContext* globalCtx) { 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); + CollisionCheck_SetAC(play, &play->colChkCtx, &this->collider.base); if (this->actionFunc != EnBomChu_WaitForRelease) { - CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + CollisionCheck_SetOC(play, &play->colChkCtx, &this->collider.base); } this->actor.focus.pos.x = this->actor.world.pos.x + (20.0f * this->axisUp.x); @@ -497,7 +496,7 @@ void EnBomChu_Update(Actor* thisx, GlobalContext* globalCtx) { if (this->isMoving) { this->visualJitter = - (5.0f + (Rand_ZeroOne() * 3.0f)) * Math_SinS((((s32)(Rand_ZeroOne() * 512.0f) + 0x3000) * this->timer)); + (5.0f + (Rand_ZeroOne() * 3.0f)) * Math_SinS((((s32)(Rand_ZeroOne() * 0x200) + 0x3000) * this->timer)); EnBomChu_ActorCoordsToWorld(this, &sBlureP1Offset, &blureP1); EnBomChu_ActorCoordsToWorld(this, &sBlureP2LeftOffset, &blureP2); @@ -508,13 +507,13 @@ void EnBomChu_Update(Actor* thisx, GlobalContext* globalCtx) { waterY = this->actor.world.pos.y; - if (WaterBox_GetSurface1(globalCtx, &globalCtx->colCtx, this->actor.world.pos.x, this->actor.world.pos.z, - &waterY, &waterBox)) { + if (WaterBox_GetSurface1(play, &play->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); + EnBomChu_SpawnRipplesAndSplashes(this, play, waterY, true); } this->actor.bgCheckFlags &= ~0x20; @@ -522,9 +521,9 @@ void EnBomChu_Update(Actor* thisx, GlobalContext* globalCtx) { } if (!(this->actor.bgCheckFlags & 0x20) && (this->timer != 120)) { - EnBomChu_SpawnRipplesAndSplashes(this, globalCtx, waterY, true); + EnBomChu_SpawnRipplesAndSplashes(this, play, waterY, true); } else { - EffectSsBubble_Spawn(globalCtx, &this->actor.world.pos, 0.0f, 3.0f, 15.0f, 0.25f); + EffectSsBubble_Spawn(play, &this->actor.world.pos, 0.0f, 3.0f, 15.0f, 0.25f); } this->actor.bgCheckFlags |= 0x20; @@ -535,16 +534,16 @@ void EnBomChu_Update(Actor* thisx, GlobalContext* globalCtx) { } } -void EnBomChu_Draw(Actor* thisx, GlobalContext* globalCtx) { +void EnBomChu_Draw(Actor* thisx, PlayState* play) { EnBomChu* this = THIS; f32 colorIntensity; s32 blinkHalfPeriod; s32 blinkTime; - OPEN_DISPS(globalCtx->state.gfxCtx); + OPEN_DISPS(play->state.gfxCtx); - func_8012C28C(globalCtx->state.gfxCtx); - func_800B8050(&this->actor, globalCtx, 0); + func_8012C28C(play->state.gfxCtx); + func_800B8050(&this->actor, play, 0); if (this->timer >= 40) { blinkTime = this->timer % 20; @@ -564,9 +563,9 @@ void EnBomChu_Draw(Actor* thisx, GlobalContext* globalCtx) { colorIntensity = blinkTime / (f32)blinkHalfPeriod; gDPSetEnvColor(POLY_OPA_DISP++, (s32)(colorIntensity * 209.0f) + 9, (s32)(colorIntensity * 34.0f) + 9, (s32)(colorIntensity * -35.0f) + 35, 255); - Matrix_InsertTranslation(this->visualJitter * (1.0f / BOMBCHU_SCALE), 0.0f, 0.0f, MTXMODE_APPLY); - gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + Matrix_Translate(this->visualJitter * (1.0f / BOMBCHU_SCALE), 0.0f, 0.0f, MTXMODE_APPLY); + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_OPA_DISP++, gBombchuDL); - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->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 30a3dab9a..35998aeac 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 @@ -5,7 +5,7 @@ struct EnBomChu; -typedef void (*EnBomChuActionFunc)(struct EnBomChu*, GlobalContext*); +typedef void (*EnBomChuActionFunc)(struct EnBomChu*, PlayState*); typedef struct EnBomChu { /* 0x000 */ Actor actor; 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 479df5cd7..b4ebb73e6 100644 --- a/src/overlays/actors/ovl_En_Bombal/z_en_bombal.c +++ b/src/overlays/actors/ovl_En_Bombal/z_en_bombal.c @@ -10,14 +10,14 @@ #define THIS ((EnBombal*)thisx) -void EnBombal_Init(Actor* thisx, GlobalContext* globalCtx); -void EnBombal_Destroy(Actor* thisx, GlobalContext* globalCtx); -void EnBombal_Update(Actor* thisx, GlobalContext* globalCtx); -void EnBombal_Draw(Actor* thisx, GlobalContext* globalCtx); +void EnBombal_Init(Actor* thisx, PlayState* play); +void EnBombal_Destroy(Actor* thisx, PlayState* play); +void EnBombal_Update(Actor* thisx, PlayState* play); +void EnBombal_Draw(Actor* thisx, PlayState* play); -void func_80C05B3C(EnBombal* this, GlobalContext* globalCtx); -void func_80C05C44(EnBombal* this, GlobalContext* globalCtx); -void func_80C05DE8(EnBombal* this, GlobalContext* globalCtx); +void func_80C05B3C(EnBombal* this, PlayState* play); +void func_80C05C44(EnBombal* this, PlayState* play); +void func_80C05DE8(EnBombal* this, PlayState* play); #if 0 const ActorInit En_Bombal_InitVars = { diff --git a/src/overlays/actors/ovl_En_Bombal/z_en_bombal.h b/src/overlays/actors/ovl_En_Bombal/z_en_bombal.h index 9ac9fafa0..5731208a4 100644 --- a/src/overlays/actors/ovl_En_Bombal/z_en_bombal.h +++ b/src/overlays/actors/ovl_En_Bombal/z_en_bombal.h @@ -5,7 +5,7 @@ struct EnBombal; -typedef void (*EnBombalActionFunc)(struct EnBombal*, GlobalContext*); +typedef void (*EnBombalActionFunc)(struct EnBombal*, PlayState*); typedef struct EnBombal { /* 0x0000 */ Actor actor; diff --git a/src/overlays/actors/ovl_En_Bombers/z_en_bombers.c b/src/overlays/actors/ovl_En_Bombers/z_en_bombers.c index a76c901eb..7d4fbbafb 100644 --- a/src/overlays/actors/ovl_En_Bombers/z_en_bombers.c +++ b/src/overlays/actors/ovl_En_Bombers/z_en_bombers.c @@ -12,18 +12,18 @@ #define THIS ((EnBombers*)thisx) -void EnBombers_Init(Actor* thisx, GlobalContext* globalCtx); -void EnBombers_Destroy(Actor* thisx, GlobalContext* globalCtx); -void EnBombers_Update(Actor* thisx, GlobalContext* globalCtx); -void EnBombers_Draw(Actor* thisx, GlobalContext* globalCtx); +void EnBombers_Init(Actor* thisx, PlayState* play); +void EnBombers_Destroy(Actor* thisx, PlayState* play); +void EnBombers_Update(Actor* thisx, PlayState* play); +void EnBombers_Draw(Actor* thisx, PlayState* play); void func_80C03ACC(EnBombers* this); -void func_80C03AF4(EnBombers* this, GlobalContext* globalCtx); +void func_80C03AF4(EnBombers* this, PlayState* play); void func_80C03F64(EnBombers* this); -void func_80C03FAC(EnBombers* this, GlobalContext* globalCtx); +void func_80C03FAC(EnBombers* this, PlayState* play); void func_80C042F8(EnBombers* this); -void func_80C04354(EnBombers* this, GlobalContext* globalCtx); -void func_80C043C8(EnBombers* this, GlobalContext* globalCtx); +void func_80C04354(EnBombers* this, PlayState* play); +void func_80C043C8(EnBombers* this, PlayState* play); const ActorInit En_Bombers_InitVars = { ACTOR_EN_BOMBERS, @@ -88,15 +88,15 @@ TexturePtr D_80C04838[] = { object_cs_Tex_00E620, object_cs_Tex_00EA20, object_cs_Tex_00EE20, object_cs_Tex_00DD20, object_cs_Tex_00F220, }; -void EnBombers_Init(Actor* thisx, GlobalContext* globalCtx) { +void EnBombers_Init(Actor* thisx, PlayState* play) { EnBombers* this = THIS; 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, + SkelAnime_InitFlex(play, &this->skelAnime, &object_cs_Skel_00F82C, &gBomberIdleAnim, this->jointTable, this->morphtable, 21); - Collider_InitAndSetCylinder(globalCtx, &this->collider, &this->actor, &sCylinderInit); + Collider_InitAndSetCylinder(play, &this->collider, &this->actor, &sCylinderInit); this->actor.targetMode = 0; Actor_SetScale(&this->actor, 0.01f); @@ -119,8 +119,8 @@ void EnBombers_Init(Actor* thisx, GlobalContext* globalCtx) { 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); + &play->actorCtx, play, 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); if (bomBowlMan != NULL) { s32 cs = this->actor.cutscene; @@ -146,10 +146,10 @@ void EnBombers_Init(Actor* thisx, GlobalContext* globalCtx) { } } -void EnBombers_Destroy(Actor* thisx, GlobalContext* globalCtx) { +void EnBombers_Destroy(Actor* thisx, PlayState* play) { EnBombers* this = THIS; - Collider_DestroyCylinder(globalCtx, &this->collider); + Collider_DestroyCylinder(play, &this->collider); } void func_80C03824(EnBombers* this, s32 arg1, f32 arg2) { @@ -173,9 +173,9 @@ void func_80C038B4(EnBombers* this) { } } -void func_80C039A8(EnBombers* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); - this->unk_2A6 = 5; +void func_80C039A8(EnBombers* this, PlayState* play) { + Player* player = GET_PLAYER(play); + this->unk_2A6 = TEXT_STATE_5; switch (player->transformation) { case PLAYER_FORM_HUMAN: @@ -218,7 +218,7 @@ void func_80C03ACC(EnBombers* this) { this->actionFunc = func_80C03AF4; } -void func_80C03AF4(EnBombers* this, GlobalContext* globalCtx) { +void func_80C03AF4(EnBombers* this, PlayState* play) { CollisionPoly* colPoly; f32 curFrame = this->skelAnime.curFrame; Vec3f sp6C; @@ -238,7 +238,7 @@ void func_80C03AF4(EnBombers* this, GlobalContext* globalCtx) { 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, + if ((abs < 0x4000) && !BgCheck_EntityLineTest1(&play->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); @@ -259,8 +259,8 @@ void func_80C03AF4(EnBombers* this, GlobalContext* globalCtx) { 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)) { + if (BgCheck_EntityLineTest1(&play->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); @@ -293,20 +293,20 @@ void func_80C03AF4(EnBombers* this, GlobalContext* globalCtx) { break; } - if (!Text_GetFaceReaction(globalCtx, 0x12)) { - func_80C039A8(this, globalCtx); + if (!Text_GetFaceReaction(play, 0x12)) { + func_80C039A8(this, play); } else { - this->unk_2A6 = 5; - this->actor.textId = Text_GetFaceReaction(globalCtx, 0x12); + this->unk_2A6 = TEXT_STATE_5; + this->actor.textId = Text_GetFaceReaction(play, 0x12); } - if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { + if (Actor_ProcessTalkRequest(&this->actor, &play->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); + func_800B8614(&this->actor, play, 70.0f); } } @@ -317,8 +317,8 @@ void func_80C03F64(EnBombers* this) { this->actionFunc = func_80C03FAC; } -void func_80C03FAC(EnBombers* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); +void func_80C03FAC(EnBombers* this, PlayState* play) { + Player* player = GET_PLAYER(play); s16 sp2A; Math_SmoothStepToS(&this->actor.world.rot.y, this->unk_2A4, 1, 0x1388, 0); @@ -334,17 +334,17 @@ void func_80C03FAC(EnBombers* this, GlobalContext* globalCtx) { break; } - if ((this->unk_2A6 == Message_GetState(&globalCtx->msgCtx)) && Message_ShouldAdvance(globalCtx)) { + if ((this->unk_2A6 == Message_GetState(&play->msgCtx)) && Message_ShouldAdvance(play)) { sp2A = 0; - func_801477B4(globalCtx); - this->unk_2A6 = 5; + func_801477B4(play); + this->unk_2A6 = TEXT_STATE_5; if ((this->actor.textId == 0x73D) || (this->actor.textId == 0x73E) || (this->actor.textId == 0x73F)) { this->actor.textId = 0x740; - this->unk_2A6 = 4; + this->unk_2A6 = TEXT_STATE_CHOICE; sp2A = 1; } else if (this->actor.textId == 0x740) { - if (globalCtx->msgCtx.choiceIndex == 0) { + if (play->msgCtx.choiceIndex == 0) { func_8019F208(); this->actor.textId = 0x742; sp2A = 1; @@ -361,10 +361,10 @@ void func_80C03FAC(EnBombers* this, GlobalContext* globalCtx) { sp2A = 1; } else if (this->actor.textId == 0x74B) { this->actor.textId = 0x74C; - this->unk_2A6 = 4; + this->unk_2A6 = TEXT_STATE_CHOICE; sp2A = 1; } else if (this->actor.textId == 0x74C) { - if (globalCtx->msgCtx.choiceIndex == 1) { + if (play->msgCtx.choiceIndex == 1) { func_8019F230(); this->actor.textId = 0x737; sp2A = 1; @@ -418,7 +418,7 @@ void func_80C03FAC(EnBombers* this, GlobalContext* globalCtx) { break; case 1: - func_80151938(globalCtx, this->actor.textId); + func_80151938(play, this->actor.textId); break; } } @@ -434,25 +434,25 @@ void func_80C042F8(EnBombers* this) { this->actionFunc = func_80C04354; } -void func_80C04354(EnBombers* this, GlobalContext* globalCtx) { +void func_80C04354(EnBombers* this, PlayState* play) { Math_SmoothStepToS(&this->unk_288, this->unk_28E, 1, 0x3E8, 0); - if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { + if (Actor_ProcessTalkRequest(&this->actor, &play->state)) { this->unk_28E = 0; this->actionFunc = func_80C043C8; } else { - func_800B8614(&this->actor, globalCtx, 70.0f); + func_800B8614(&this->actor, play, 70.0f); } } -void func_80C043C8(EnBombers* this, GlobalContext* globalCtx) { +void func_80C043C8(EnBombers* this, PlayState* play) { Math_SmoothStepToS(&this->unk_288, this->unk_28E, 1, 0x3E8, 0); - if ((Message_GetState(&globalCtx->msgCtx) == 5) && Message_ShouldAdvance(globalCtx)) { - func_801477B4(globalCtx); + if ((Message_GetState(&play->msgCtx) == TEXT_STATE_5) && Message_ShouldAdvance(play)) { + func_801477B4(play); func_80C042F8(this); } } -void EnBombers_Update(Actor* thisx, GlobalContext* globalCtx) { +void EnBombers_Update(Actor* thisx, PlayState* play) { s32 pad; EnBombers* this = THIS; @@ -472,7 +472,7 @@ void EnBombers_Update(Actor* thisx, GlobalContext* globalCtx) { this->actor.shape.rot.y = this->actor.world.rot.y; func_80C038B4(this); Actor_SetFocus(&this->actor, 20.0f); - this->actionFunc(this, globalCtx); + this->actionFunc(this, play); 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); @@ -485,14 +485,13 @@ void EnBombers_Update(Actor* thisx, GlobalContext* globalCtx) { } } - Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 20.0f, 20.0f, 50.0f, 0x1D); + Actor_UpdateBgCheckInfo(play, &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); + CollisionCheck_SetOC(play, &play->colChkCtx, &this->collider.base); } -s32 EnBombers_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, - Actor* thisx) { +s32 EnBombers_OverrideLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, Actor* thisx) { EnBombers* this = THIS; if (limbIndex == OBJECT_CS_LIMB_0F) { @@ -511,21 +510,21 @@ s32 EnBombers_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dL return false; } -void EnBombers_Draw(Actor* thisx, GlobalContext* globalCtx) { +void EnBombers_Draw(Actor* thisx, PlayState* play) { EnBombers* this = THIS; - OPEN_DISPS(globalCtx->state.gfxCtx); + OPEN_DISPS(play->state.gfxCtx); - func_8012C28C(globalCtx->state.gfxCtx); - func_8012C2DC(globalCtx->state.gfxCtx); + func_8012C28C(play->state.gfxCtx); + func_8012C2DC(play->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, + Scene_SetRenderModeXlu(play, 0, 1); + SkelAnime_DrawFlexOpa(play, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, EnBombers_OverrideLimbDraw, NULL, &this->actor); - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->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 c51150df8..538b0d8b5 100644 --- a/src/overlays/actors/ovl_En_Bombers/z_en_bombers.h +++ b/src/overlays/actors/ovl_En_Bombers/z_en_bombers.h @@ -5,7 +5,7 @@ struct EnBombers; -typedef void (*EnBombersActionFunc)(struct EnBombers*, GlobalContext*); +typedef void (*EnBombersActionFunc)(struct EnBombers*, PlayState*); #define ENBOMBERS_GET_F(thisx) ((thisx)->params & 0xF) #define ENBOMBERS_GET_F0(thisx) (((thisx)->params >> 4) & 0xF) @@ -21,33 +21,33 @@ enum { #define ENBOMBERS_F0_0 0 typedef struct EnBombers { - /* 0x0000 */ Actor actor; - /* 0x0144 */ SkelAnime skelAnime; - /* 0x0188 */ Vec3s jointTable[21]; - /* 0x0206 */ Vec3s morphtable[21]; - /* 0x0284 */ EnBombersActionFunc actionFunc; - /* 0x0288 */ s16 unk_288; - /* 0x028A */ s16 unk_28A; - /* 0x028C */ UNK_TYPE1 unk28C[2]; - /* 0x028E */ s16 unk_28E; - /* 0x0290 */ s16 unk_290; - /* 0x0294 */ Vec3f unk_294; - /* 0x02A0 */ s16 unk_2A0; - /* 0x02A2 */ UNK_TYPE1 unk2A2[2]; - /* 0x02A4 */ s16 unk_2A4; - /* 0x02A6 */ s16 unk_2A6; - /* 0x02A8 */ s16 unk_2A8; - /* 0x02AA */ s16 unk_2AA; - /* 0x02AC */ s16 unk_2AC; - /* 0x02B0 */ f32 unk_2B0; - /* 0x02B4 */ f32 unk_2B4; - /* 0x02B8 */ s16 unk_2B8; - /* 0x02BA */ s16 unk_2BA; - /* 0x02BC */ s16 unk_2BC; - /* 0x02BE */ s16 unk_2BE; - /* 0x02C0 */ s16 unk_2C0; - /* 0x02C4 */ s32 unk_2C4; - /* 0x02C8 */ ColliderCylinder collider; + /* 0x000 */ Actor actor; + /* 0x144 */ SkelAnime skelAnime; + /* 0x188 */ Vec3s jointTable[21]; + /* 0x206 */ Vec3s morphtable[21]; + /* 0x284 */ EnBombersActionFunc actionFunc; + /* 0x288 */ s16 unk_288; + /* 0x28A */ s16 unk_28A; + /* 0x28C */ UNK_TYPE1 unk28C[2]; + /* 0x28E */ s16 unk_28E; + /* 0x290 */ s16 unk_290; + /* 0x294 */ Vec3f unk_294; + /* 0x2A0 */ s16 unk_2A0; + /* 0x2A2 */ UNK_TYPE1 unk2A2[2]; + /* 0x2A4 */ s16 unk_2A4; + /* 0x2A6 */ s16 unk_2A6; + /* 0x2A8 */ s16 unk_2A8; + /* 0x2AA */ s16 unk_2AA; + /* 0x2AC */ s16 unk_2AC; + /* 0x2B0 */ f32 unk_2B0; + /* 0x2B4 */ f32 unk_2B4; + /* 0x2B8 */ s16 unk_2B8; + /* 0x2BA */ s16 unk_2BA; + /* 0x2BC */ s16 unk_2BC; + /* 0x2BE */ s16 unk_2BE; + /* 0x2C0 */ s16 unk_2C0; + /* 0x2C4 */ s32 unk_2C4; + /* 0x2C8 */ ColliderCylinder collider; } EnBombers; // size = 0x314 extern const ActorInit En_Bombers_InitVars; diff --git a/src/overlays/actors/ovl_En_Bombers2/z_en_bombers2.c b/src/overlays/actors/ovl_En_Bombers2/z_en_bombers2.c index 8b2fa6d90..9f70629e6 100644 --- a/src/overlays/actors/ovl_En_Bombers2/z_en_bombers2.c +++ b/src/overlays/actors/ovl_En_Bombers2/z_en_bombers2.c @@ -10,18 +10,18 @@ #define THIS ((EnBombers2*)thisx) -void EnBombers2_Init(Actor* thisx, GlobalContext* globalCtx); -void EnBombers2_Destroy(Actor* thisx, GlobalContext* globalCtx); -void EnBombers2_Update(Actor* thisx, GlobalContext* globalCtx); -void EnBombers2_Draw(Actor* thisx, GlobalContext* globalCtx); +void EnBombers2_Init(Actor* thisx, PlayState* play); +void EnBombers2_Destroy(Actor* thisx, PlayState* play); +void EnBombers2_Update(Actor* thisx, PlayState* play); +void EnBombers2_Draw(Actor* thisx, PlayState* play); -void func_80C04BA0(EnBombers2* this, GlobalContext* globalCtx); -void func_80C04D8C(EnBombers2* this, GlobalContext* globalCtx); -void func_80C0520C(EnBombers2* this, GlobalContext* globalCtx); +void func_80C04BA0(EnBombers2* this, PlayState* play); +void func_80C04D8C(EnBombers2* this, PlayState* play); +void func_80C0520C(EnBombers2* this, PlayState* play); 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); +void func_80C050B8(EnBombers2* this, PlayState* play); const ActorInit En_Bombers2_InitVars = { ACTOR_EN_BOMBERS2, @@ -64,7 +64,7 @@ static AnimationHeader* sAnimations[] = { &object_cs_Anim_0060E8, &object_cs_Anim_005DC4, &object_cs_Anim_0026B0, }; -static u8 sAnimModes[] = { +static u8 sAnimationModes[] = { ANIMMODE_LOOP, ANIMMODE_LOOP, ANIMMODE_LOOP, ANIMMODE_ONCE, ANIMMODE_LOOP, ANIMMODE_LOOP, ANIMMODE_ONCE, ANIMMODE_LOOP, }; @@ -84,17 +84,17 @@ static TexturePtr sEyeTextures[] = { static TexturePtr D_80C05920 = object_cs_Tex_00E220; -void EnBombers2_Init(Actor* thisx, GlobalContext* globalCtx) { +void EnBombers2_Init(Actor* thisx, PlayState* play) { f32 cos; EnBombers2* this = (EnBombers2*)thisx; 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, + SkelAnime_InitFlex(play, &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)) { + Collider_InitAndSetCylinder(play, &this->collider, &this->actor, &sCylinderInit); + if ((gSaveContext.save.weekEventReg[73] & 0x80) || (gSaveContext.save.entrance == ENTRANCE(EAST_CLOCK_TOWN, 2))) { 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; @@ -107,10 +107,10 @@ void EnBombers2_Init(Actor* thisx, GlobalContext* globalCtx) { func_80C04B40(this); } -void EnBombers2_Destroy(Actor* thisx, GlobalContext* globalCtx) { +void EnBombers2_Destroy(Actor* thisx, PlayState* play) { EnBombers2* this = THIS; - Collider_DestroyCylinder(globalCtx, &this->collider); + Collider_DestroyCylinder(play, &this->collider); } void EnBombers2_ChangeAnim(EnBombers2* this, s32 animIndex, f32 playSpeed) { @@ -120,7 +120,7 @@ void EnBombers2_ChangeAnim(EnBombers2* this, s32 animIndex, f32 playSpeed) { 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); + sAnimationModes[this->animIndex], -10.0f); } void func_80C04B40(EnBombers2* this) { @@ -133,25 +133,25 @@ void func_80C04B40(EnBombers2* this) { this->actionFunc = func_80C04BA0; } -void func_80C04BA0(EnBombers2* this, GlobalContext* globalCtx) { +void func_80C04BA0(EnBombers2* this, PlayState* play) { s32 yawDiffAbs; s16 yawDiff; Player* player; yawDiff = this->actor.yawTowardsPlayer - this->actor.world.rot.y; yawDiffAbs = ABS_ALT(yawDiff); - player = GET_PLAYER(globalCtx); + player = GET_PLAYER(play); switch (player->transformation) { case PLAYER_FORM_GORON: case PLAYER_FORM_ZORA: this->textIdIndex = 1; - this->unk_2CE = 5; + this->talkState = TEXT_STATE_5; break; case PLAYER_FORM_DEKU: case PLAYER_FORM_HUMAN: this->textIdIndex = 2; - this->unk_2CE = 5; + this->talkState = TEXT_STATE_5; break; } if (this->unk_2AC != 0) { @@ -159,18 +159,18 @@ void func_80C04BA0(EnBombers2* this, GlobalContext* globalCtx) { } this->actor.textId = sTextIds[this->textIdIndex]; - if (Text_GetFaceReaction(globalCtx, 0x15) != 0) { - this->actor.textId = Text_GetFaceReaction(globalCtx, 0x15); + if (Text_GetFaceReaction(play, 0x15) != 0) { + this->actor.textId = Text_GetFaceReaction(play, 0x15); } - if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { + if (Actor_ProcessTalkRequest(&this->actor, &play->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); + func_800B8614(&this->actor, play, 70.0f); } } @@ -189,8 +189,8 @@ void func_80C04D00(EnBombers2* this) { this->actionFunc = func_80C04D8C; } -void func_80C04D8C(EnBombers2* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); +void func_80C04D8C(EnBombers2* this, PlayState* play) { + Player* player = GET_PLAYER(play); f32 temp = this->skelAnime.curFrame; if ((this->unk_2AC == 0) && (this->lastAnimFrame <= temp)) { @@ -213,14 +213,13 @@ void func_80C04D8C(EnBombers2* this, GlobalContext* globalCtx) { default: break; } - if ((this->unk_2CE == Message_GetState(&globalCtx->msgCtx)) && Message_ShouldAdvance(globalCtx)) { - if (this->unk_2CE == 0xF) { + if ((this->talkState == Message_GetState(&play->msgCtx)) && Message_ShouldAdvance(play)) { + if (this->talkState == TEXT_STATE_15) { s32 i; s32 correctDigits; for (i = 0; i < ARRAY_COUNT(this->correctDigitSlots); i++) { - if (!(this->correctDigitSlots[i]) && - (globalCtx->msgCtx.unk12054[i] == gSaveContext.save.bomberCode[i])) { + if (!(this->correctDigitSlots[i]) && (play->msgCtx.unk12054[i] == gSaveContext.save.bomberCode[i])) { this->correctDigitSlots[i] = true; } } @@ -233,15 +232,15 @@ void func_80C04D8C(EnBombers2* this, GlobalContext* globalCtx) { if (correctDigits >= 5) { this->textIdIndex = 6; this->actor.textId = sTextIds[this->textIdIndex]; - func_80151938(globalCtx, this->actor.textId); + func_80151938(play, this->actor.textId); Actor_PlaySfxAtPos(&this->actor, NA_SE_SY_PIECE_OF_HEART); - this->unk_2CE = 5; + this->talkState = TEXT_STATE_5; return; } } - if (Text_GetFaceReaction(globalCtx, 0x15) != 0) { + if (Text_GetFaceReaction(play, 0x15) != 0) { this->unk_28E = 0; - func_801477B4(globalCtx); + func_801477B4(play); func_80C04B40(this); } else { s32 j; @@ -252,14 +251,14 @@ void func_80C04D8C(EnBombers2* this, GlobalContext* globalCtx) { case 5: case 7: this->unk_28E = 0; - func_801477B4(globalCtx); + func_801477B4(play); 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; + func_80151938(play, this->actor.textId); + this->talkState = TEXT_STATE_15; break; case 3: for (j = 0; j < ARRAY_COUNT(this->correctDigitSlots); j++) { @@ -268,26 +267,26 @@ void func_80C04D8C(EnBombers2* this, GlobalContext* globalCtx) { 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; + func_80151938(play, this->actor.textId); + this->talkState = TEXT_STATE_5; break; case 4: this->textIdIndex = 5; this->actor.textId = sTextIds[this->textIdIndex]; - func_80151938(globalCtx, this->actor.textId); - this->unk_2CE = 5; + func_80151938(play, this->actor.textId); + this->talkState = TEXT_STATE_5; break; case 6: - globalCtx->msgCtx.unk11F10 = 0; - func_80C050B8(this, globalCtx); + play->msgCtx.msgLength = 0; + func_80C050B8(this, play); break; } } } } -void func_80C050B8(EnBombers2* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); +void func_80C050B8(EnBombers2* this, PlayState* play) { + Player* player = GET_PLAYER(play); s16 homeYawToPlayer; EnBombers2_ChangeAnim(this, 2, 1.0f); @@ -306,7 +305,7 @@ void func_80C050B8(EnBombers2* this, GlobalContext* globalCtx) { this->actionFunc = func_80C0520C; } -void func_80C0520C(EnBombers2* this, GlobalContext* globalCtx) { +void func_80C0520C(EnBombers2* this, PlayState* play) { if (this->unk_2A8 == 0) { if (ActorCutscene_GetCurrentIndex() == 0x7C) { ActorCutscene_Stop(0x7C); @@ -324,8 +323,8 @@ void func_80C0520C(EnBombers2* this, GlobalContext* globalCtx) { 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; + func_801477B4(play); + this->talkState = TEXT_STATE_5; this->textIdIndex = 7; EnBombers2_ChangeAnim(this, 6, 1.0f); this->unk_2A8 = 0; @@ -334,7 +333,7 @@ void func_80C0520C(EnBombers2* this, GlobalContext* globalCtx) { ActorCutscene_Stop(this->cutscene); this->unk_2AC = 1; this->actor.textId = sTextIds[this->textIdIndex]; - Message_StartTextbox(globalCtx, this->actor.textId, &this->actor); + Message_StartTextbox(play, this->actor.textId, &this->actor); this->actionFunc = func_80C04D8C; } } else { @@ -344,7 +343,7 @@ void func_80C0520C(EnBombers2* this, GlobalContext* globalCtx) { } } -void EnBombers2_Update(Actor* thisx, GlobalContext* globalCtx) { +void EnBombers2_Update(Actor* thisx, PlayState* play) { EnBombers2* this = (EnBombers2*)thisx; f32 temp_f4; Vec3f sp34; @@ -375,7 +374,7 @@ void EnBombers2_Update(Actor* thisx, GlobalContext* globalCtx) { } Actor_SetFocus(&this->actor, 20.0f); Actor_SetScale(&this->actor, 0.008f); - this->actionFunc(this, globalCtx); + this->actionFunc(this, play); 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); @@ -398,14 +397,14 @@ void EnBombers2_Update(Actor* thisx, GlobalContext* globalCtx) { this->collider.dim.height = 0x19; } Collider_UpdateCylinder(&this->actor, &this->collider); - CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + CollisionCheck_SetOC(play, &play->colChkCtx, &this->collider.base); if (this->unk_2AC == 0) { - Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 20.0f, 20.0f, 50.0f, 0x1D); + Actor_UpdateBgCheckInfo(play, &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) { +s32 func_80C056D4(PlayState* play, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, Actor* thisx) { EnBombers2* this = THIS; if (limbIndex == OBJECT_CS_LIMB_08) { @@ -421,18 +420,18 @@ s32 func_80C056D4(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* p return false; } -void EnBombers2_Draw(Actor* thisx, GlobalContext* globalCtx) { +void EnBombers2_Draw(Actor* thisx, PlayState* play) { EnBombers2* this = THIS; - OPEN_DISPS(globalCtx->state.gfxCtx); + OPEN_DISPS(play->state.gfxCtx); - func_8012C28C(globalCtx->state.gfxCtx); - func_8012C2DC(globalCtx->state.gfxCtx); + func_8012C28C(play->state.gfxCtx); + func_8012C2DC(play->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, + Scene_SetRenderModeXlu(play, 0, 1); + SkelAnime_DrawFlexOpa(play, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, func_80C056D4, NULL, &this->actor); - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->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 ed10a84db..0a62fd704 100644 --- a/src/overlays/actors/ovl_En_Bombers2/z_en_bombers2.h +++ b/src/overlays/actors/ovl_En_Bombers2/z_en_bombers2.h @@ -7,38 +7,38 @@ struct EnBombers2; -typedef void (*EnBombers2ActionFunc)(struct EnBombers2*, GlobalContext*); +typedef void (*EnBombers2ActionFunc)(struct EnBombers2*, PlayState*); typedef struct EnBombers2 { - /* 0x0000 */ Actor actor; - /* 0x014C */ SkelAnime skelAnime; - /* 0x0188 */ Vec3s morphTable[OBJECT_CS_LIMB_MAX]; - /* 0x0206 */ Vec3s jointTable[OBJECT_CS_LIMB_MAX]; - /* 0x0284 */ EnBombers2ActionFunc actionFunc; - /* 0x0288 */ s16 unk_288; - /* 0x028A */ s16 unk_28A; - /* 0x028C */ UNK_TYPE1 pad_28C[2]; - /* 0x028E */ s16 unk_28E; - /* 0x0290 */ s16 unk_290; - /* 0x0292 */ UNK_TYPE1 pad_292[4]; - /* 0x0296 */ s16 unk_296; - /* 0x0298 */ UNK_TYPE1 pad_298[4]; - /* 0x029C */ Vec3f unk_29C; - /* 0x02A8 */ s32 unk_2A8; - /* 0x02AC */ u8 unk_2AC; - /* 0x02AE */ s16 animIndex; - /* 0x02B0 */ s16 cutscene; - /* 0x02B2 */ s16 unk_2B2; - /* 0x02B4 */ s16 unk_2B4; - /* 0x02B6 */ s16 unk_2B6; - /* 0x02B8 */ f32 lastAnimFrame; - /* 0x02BC */ s16 eyeIndex; - /* 0x02BE */ s16 unk_2BE; - /* 0x02C0 */ s16 unk_2C0; - /* 0x02C2 */ s16 textIdIndex; - /* 0x02C4 */ s16 correctDigitSlots[5]; - /* 0x02CE */ s16 unk_2CE; - /* 0x02D0 */ ColliderCylinder collider; + /* 0x000 */ Actor actor; + /* 0x14C */ SkelAnime skelAnime; + /* 0x188 */ Vec3s morphTable[OBJECT_CS_LIMB_MAX]; + /* 0x206 */ Vec3s jointTable[OBJECT_CS_LIMB_MAX]; + /* 0x284 */ EnBombers2ActionFunc actionFunc; + /* 0x288 */ s16 unk_288; + /* 0x28A */ s16 unk_28A; + /* 0x28C */ UNK_TYPE1 pad_28C[2]; + /* 0x28E */ s16 unk_28E; + /* 0x290 */ s16 unk_290; + /* 0x292 */ UNK_TYPE1 pad_292[4]; + /* 0x296 */ s16 unk_296; + /* 0x298 */ UNK_TYPE1 pad_298[4]; + /* 0x29C */ Vec3f unk_29C; + /* 0x2A8 */ s32 unk_2A8; + /* 0x2AC */ u8 unk_2AC; + /* 0x2AE */ s16 animIndex; + /* 0x2B0 */ s16 cutscene; + /* 0x2B2 */ s16 unk_2B2; + /* 0x2B4 */ s16 unk_2B4; + /* 0x2B6 */ s16 unk_2B6; + /* 0x2B8 */ f32 lastAnimFrame; + /* 0x2BC */ s16 eyeIndex; + /* 0x2BE */ s16 unk_2BE; + /* 0x2C0 */ s16 unk_2C0; + /* 0x2C2 */ s16 textIdIndex; + /* 0x2C4 */ s16 correctDigitSlots[5]; + /* 0x2CE */ s16 talkState; + /* 0x2D0 */ ColliderCylinder collider; } EnBombers2; // size = 0x31C extern const ActorInit En_Bombers2_InitVars; diff --git a/src/overlays/actors/ovl_En_Bombf/z_en_bombf.c b/src/overlays/actors/ovl_En_Bombf/z_en_bombf.c index fef26002b..4a7ac1baf 100644 --- a/src/overlays/actors/ovl_En_Bombf/z_en_bombf.c +++ b/src/overlays/actors/ovl_En_Bombf/z_en_bombf.c @@ -5,23 +5,24 @@ */ #include "z_en_bombf.h" +#include "z64rumble.h" #include "objects/object_bombf/object_bombf.h" #define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_10) #define THIS ((EnBombf*)thisx) -void EnBombf_Init(Actor* thisx, GlobalContext* globalCtx); -void EnBombf_Destroy(Actor* thisx, GlobalContext* globalCtx); -void EnBombf_Update(Actor* thisx, GlobalContext* globalCtx); -void EnBombf_Draw(Actor* thisx, GlobalContext* globalCtx); +void EnBombf_Init(Actor* thisx, PlayState* play); +void EnBombf_Destroy(Actor* thisx, PlayState* play); +void EnBombf_Update(Actor* thisx, PlayState* play); +void EnBombf_Draw(Actor* thisx, PlayState* play); 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 func_808AEAE0(EnBombf* this, PlayState* play); +void func_808AEE3C(EnBombf* this, PlayState* play); +void func_808AEF68(EnBombf* this, PlayState* play); +void func_808AEFD4(EnBombf* this, PlayState* play); const ActorInit En_Bombf_InitVars = { ACTOR_EN_BOMBF, @@ -78,7 +79,7 @@ static ColliderJntSphInit sJntSphInit = { OC2_NONE, COLSHAPE_JNTSPH, }, - 1, + ARRAY_COUNT(sJntSphElementsInit), sJntSphElementsInit, }; @@ -86,18 +87,18 @@ void EnBombf_SetupAction(EnBombf* this, EnBombfActionFunc actionFunc) { this->actionFunc = actionFunc; } -void EnBombf_Init(Actor* thisx, GlobalContext* globalCtx2) { +void EnBombf_Init(Actor* thisx, PlayState* play2) { f32 yOffset = 0.0f; - GlobalContext* globalCtx = globalCtx2; + PlayState* play = play2; EnBombf* this = THIS; Actor_SetScale(thisx, 0.01f); this->unk_1F8 = 1; - 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); + Collider_InitCylinder(play, &this->colliderCylinder); + Collider_InitJntSph(play, &this->colliderJntSph); + Collider_SetCylinder(play, &this->colliderCylinder, thisx, &sCylinderInit); + Collider_SetJntSph(play, &this->colliderJntSph, thisx, &sJntSphInit, this->colliderJntSphElements); if (ENBOMBF_GET(thisx) == ENBOMBF_0) { yOffset = 1000.0f; @@ -114,7 +115,7 @@ void EnBombf_Init(Actor* thisx, GlobalContext* globalCtx2) { this->timer = 140; this->unk_1FE = 15; thisx->gravity = -1.5f; - func_800BC154(globalCtx, &globalCtx->actorCtx, thisx, 3); + func_800BC154(play, &play->actorCtx, thisx, 3); thisx->colChkInfo.mass = 200; thisx->flags &= ~ACTOR_FLAG_1; EnBombf_SetupAction(this, func_808AEE3C); @@ -129,30 +130,30 @@ void EnBombf_Init(Actor* thisx, GlobalContext* globalCtx2) { thisx->uncullZoneForward += 31000.0f; } -void EnBombf_Destroy(Actor* thisx, GlobalContext* globalCtx) { +void EnBombf_Destroy(Actor* thisx, PlayState* play) { EnBombf* this = THIS; - Collider_DestroyCylinder(globalCtx, &this->colliderCylinder); - Collider_DestroyJntSph(globalCtx, &this->colliderJntSph); + Collider_DestroyCylinder(play, &this->colliderCylinder); + Collider_DestroyJntSph(play, &this->colliderJntSph); } void func_808AEAB8(EnBombf* this, s16 arg1) { EnBombf_SetupAction(this, func_808AEAE0); } -void func_808AEAE0(EnBombf* this, GlobalContext* globalCtx) { +void func_808AEAE0(EnBombf* this, PlayState* play) { s32 pad; s32 pad2; EnBombf* bombf; - Player* player = GET_PLAYER(globalCtx); + Player* player = GET_PLAYER(play); s32 pad3; 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, + if (Actor_HasParent(&this->actor, play)) { + bombf = (EnBombf*)Actor_Spawn(&play->actorCtx, play, ACTOR_EN_BOMBF, this->actor.world.pos.x, this->actor.world.pos.y, this->actor.world.pos.z, 0, 0, 0, ENBOMBF_0); if (bombf != NULL) { - func_800B8C20(&this->actor, &bombf->actor, globalCtx); + func_800B8C20(&this->actor, &bombf->actor, play); this->timer = 180; this->unk_204 = 0.0f; Actor_PlaySfxAtPos(&this->actor, NA_SE_PL_PULL_UP_ROCK); @@ -170,7 +171,7 @@ void func_808AEAE0(EnBombf* this, GlobalContext* globalCtx) { (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, + bombf = (EnBombf*)Actor_Spawn(&play->actorCtx, play, ACTOR_EN_BOMBF, this->actor.world.pos.x, this->actor.world.pos.y, this->actor.world.pos.z, 0, 0, 0, ENBOMBF_0); if (bombf != NULL) { bombf->unk_1F8 = 1; @@ -181,8 +182,8 @@ void func_808AEAE0(EnBombf* this, GlobalContext* globalCtx) { } } } 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, + if (Player_IsBurningStickInRange(play, &this->actor.world.pos, 30.0f, 50.0f)) { + bombf = (EnBombf*)Actor_Spawn(&play->actorCtx, play, ACTOR_EN_BOMBF, this->actor.world.pos.x, this->actor.world.pos.y, this->actor.world.pos.z, 0, 0, 0, ENBOMBF_0); if (bombf != NULL) { bombf->timer = 100; @@ -191,8 +192,8 @@ void func_808AEAE0(EnBombf* this, GlobalContext* globalCtx) { this->unk_204 = 0.0f; } } else { - if (!Actor_HasParent(&this->actor, globalCtx)) { - Actor_LiftActor(&this->actor, globalCtx); + if (!Actor_HasParent(&this->actor, play)) { + Actor_LiftActor(&this->actor, play); return; } player->actor.child = NULL; @@ -211,7 +212,7 @@ void func_808AEAE0(EnBombf* this, GlobalContext* globalCtx) { } } - if (Actor_HasParent(&this->actor, globalCtx)) { + if (Actor_HasParent(&this->actor, play)) { player->actor.child = NULL; player->heldActor = NULL; player->interactRangeActor = NULL; @@ -222,8 +223,8 @@ void func_808AEAE0(EnBombf* this, GlobalContext* globalCtx) { } } -void func_808AEE3C(EnBombf* this, GlobalContext* globalCtx) { - if (Actor_HasParent(&this->actor, globalCtx)) { +void func_808AEE3C(EnBombf* this, PlayState* play) { + if (Actor_HasParent(&this->actor, play)) { this->unk_204 = 0.0f; EnBombf_SetupAction(this, func_808AEF68); this->actor.room = -1; @@ -238,65 +239,65 @@ void func_808AEE3C(EnBombf* this, GlobalContext* globalCtx) { Math_SmoothStepToF(&this->actor.speedXZ, 0.0f, 1.0f, 1.5f, 0.0f); if (this->actor.bgCheckFlags & 2) { - func_800B8EF4(globalCtx, &this->actor); + func_800B8EF4(play, &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); + Actor_LiftActor(&this->actor, play); } } -void func_808AEF68(EnBombf* this, GlobalContext* globalCtx) { - if (Actor_HasNoParent(&this->actor, globalCtx)) { +void func_808AEF68(EnBombf* this, PlayState* play) { + if (Actor_HasNoParent(&this->actor, play)) { EnBombf_SetupAction(this, func_808AEE3C); this->actor.bgCheckFlags &= ~1; - func_808AEE3C(this, globalCtx); + func_808AEE3C(this, play); } else { this->actor.velocity.y = 0.0f; } } -void func_808AEFD4(EnBombf* this, GlobalContext* globalCtx) { +void func_808AEFD4(EnBombf* this, PlayState* play) { if (this->colliderJntSph.elements->dim.modelSphere.radius == 0) { this->actor.flags |= ACTOR_FLAG_20; - func_8013ECE0(this->actor.xzDistToPlayer, 255, 20, 150); + Rumble_Request(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); + CollisionCheck_SetAT(play, &play->colChkCtx, &this->colliderJntSph.base); } - if (globalCtx->envCtx.lightSettings.diffuseColor1[0] != 0) { - globalCtx->envCtx.lightSettings.diffuseColor1[0] -= 25; + if (play->envCtx.lightSettings.diffuseColor1[0] != 0) { + play->envCtx.lightSettings.diffuseColor1[0] -= 25; } - if (globalCtx->envCtx.lightSettings.diffuseColor1[1] != 0) { - globalCtx->envCtx.lightSettings.diffuseColor1[1] -= 25; + if (play->envCtx.lightSettings.diffuseColor1[1] != 0) { + play->envCtx.lightSettings.diffuseColor1[1] -= 25; } - if (globalCtx->envCtx.lightSettings.diffuseColor1[2] != 0) { - globalCtx->envCtx.lightSettings.diffuseColor1[2] -= 25; + if (play->envCtx.lightSettings.diffuseColor1[2] != 0) { + play->envCtx.lightSettings.diffuseColor1[2] -= 25; } - if (globalCtx->envCtx.lightSettings.ambientColor[0] != 0) { - globalCtx->envCtx.lightSettings.ambientColor[0] -= 25; + if (play->envCtx.lightSettings.ambientColor[0] != 0) { + play->envCtx.lightSettings.ambientColor[0] -= 25; } - if (globalCtx->envCtx.lightSettings.ambientColor[1] != 0) { - globalCtx->envCtx.lightSettings.ambientColor[1] -= 25; + if (play->envCtx.lightSettings.ambientColor[1] != 0) { + play->envCtx.lightSettings.ambientColor[1] -= 25; } - if (globalCtx->envCtx.lightSettings.ambientColor[2] != 0) { - globalCtx->envCtx.lightSettings.ambientColor[2] -= 25; + if (play->envCtx.lightSettings.ambientColor[2] != 0) { + play->envCtx.lightSettings.ambientColor[2] -= 25; } if (this->timer == 0) { - Player* player = GET_PLAYER(globalCtx); + Player* player = GET_PLAYER(play); if ((player->stateFlags1 & 0x800) && (&this->actor == player->heldActor)) { player->actor.child = NULL; @@ -308,7 +309,7 @@ void func_808AEFD4(EnBombf* this, GlobalContext* globalCtx) { } } -void EnBombf_Update(Actor* thisx, GlobalContext* globalCtx) { +void EnBombf_Update(Actor* thisx, PlayState* play) { Vec3f sp8C = { 0.0f, 0.0f, 0.0f }; Vec3f sp80 = { 0.0f, 0.1f, 0.0f }; Vec3f sp74 = { 0.0f, 0.0f, 0.0f }; @@ -322,12 +323,12 @@ void EnBombf_Update(Actor* thisx, GlobalContext* globalCtx) { this->timer--; } - if ((this->unk_1FC == 0) && !Actor_HasParent(&this->actor, globalCtx) && + if ((this->unk_1FC == 0) && !Actor_HasParent(&this->actor, play) && ((this->actor.xzDistToPlayer >= 20.0f) || (fabsf(this->actor.playerHeightRel) >= 80.0f))) { this->unk_1FC = 1; } - this->actionFunc(this, globalCtx); + this->actionFunc(this, play); if (ENBOMBF_GET(&this->actor) == ENBOMBF_0) { Actor_MoveWithGravity(&this->actor); @@ -335,7 +336,7 @@ void EnBombf_Update(Actor* thisx, GlobalContext* globalCtx) { if (this->actor.gravity != 0.0f) { DREG(6) = 1; - Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 5.0f, 10.0f, 0.0f, 0x1F); + Actor_UpdateBgCheckInfo(play, &this->actor, 5.0f, 10.0f, 0.0f, 0x1F); DREG(6) = 0; } @@ -354,7 +355,7 @@ void EnBombf_Update(Actor* thisx, GlobalContext* globalCtx) { 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); + Actor_UpdateBgCheckInfo(play, &this->actor, 5.0f, 10.0f, 0.0f, 0x1F); DREG(6) = 0; this->actor.speedXZ *= 0.7f; this->actor.bgCheckFlags &= ~8; @@ -364,7 +365,7 @@ void EnBombf_Update(Actor* thisx, GlobalContext* globalCtx) { ((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)) { + } else if ((this->timer > 100) && Player_IsBurningStickInRange(play, &this->actor.world.pos, 30.0f, 50.0f)) { this->timer = 100; } @@ -374,12 +375,12 @@ void EnBombf_Update(Actor* thisx, GlobalContext* globalCtx) { sp68.y += 25.0f; if (this->timer < 127) { - if ((globalCtx->gameplayFrames % 2) == 0) { - EffectSsGSpk_SpawnFuse(globalCtx, &this->actor, &sp68, &sp8C, &sp74); + if ((play->gameplayFrames % 2) == 0) { + EffectSsGSpk_SpawnFuse(play, &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); + func_800B0DE0(play, &sp68, &sp8C, &sp5C, &sp58, &sp58, 0x32, 5); } if ((this->timer == 3) || (this->timer == 30) || (this->timer == 50) || (this->timer == 70)) { @@ -400,20 +401,20 @@ void EnBombf_Update(Actor* thisx, GlobalContext* globalCtx) { sp68 = this->actor.world.pos; sp68.y += 10.0f; - if (Actor_HasParent(&this->actor, globalCtx)) { + if (Actor_HasParent(&this->actor, play)) { sp68.y += 30.0f; } - Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_CLEAR_TAG, sp68.x, sp68.y, sp68.z, 0, 0, 0, + Actor_Spawn(&play->actorCtx, play, ACTOR_EN_CLEAR_TAG, sp68.x, sp68.y, sp68.z, 0, 0, 0, CLEAR_TAG_SMALL_EXPLOSION); Actor_PlaySfxAtPos(&this->actor, NA_SE_IT_BOMB_EXPLOSION); - 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; + play->envCtx.lightSettings.diffuseColor1[0] = play->envCtx.lightSettings.diffuseColor1[1] = + play->envCtx.lightSettings.diffuseColor1[2] = 250; + play->envCtx.lightSettings.ambientColor[0] = play->envCtx.lightSettings.ambientColor[1] = + play->envCtx.lightSettings.ambientColor[2] = 250; - func_800DFD04(&globalCtx->mainCamera, 2, 11, 8); + Camera_AddQuake(&play->mainCamera, 2, 11, 8); this->actor.params = ENBOMBF_1; this->timer = 10; @@ -430,14 +431,14 @@ void EnBombf_Update(Actor* thisx, GlobalContext* globalCtx) { 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_SetOC(play, &play->colChkCtx, &this->colliderCylinder.base); } - CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->colliderCylinder.base); + CollisionCheck_SetAC(play, &play->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); + SoundSource_PlaySfxAtFixedWorldPos(play, &this->actor.world.pos, 30, NA_SE_IT_BOMB_UNEXPLOSION); Actor_MarkForDeath(&this->actor); } else if (this->actor.bgCheckFlags & 0x40) { this->actor.bgCheckFlags &= ~0x40; @@ -446,11 +447,11 @@ void EnBombf_Update(Actor* thisx, GlobalContext* globalCtx) { } } -Gfx* func_808AF86C(GraphicsContext* gfxCtx, GlobalContext* globalCtx) { +Gfx* func_808AF86C(GraphicsContext* gfxCtx, PlayState* play) { Gfx* head = GRAPH_ALLOC(gfxCtx, sizeof(Gfx) * 6); Gfx* gfx = head; - Matrix_NormalizeXYZ(&globalCtx->billboardMtxF); + Matrix_ReplaceRotation(&play->billboardMtxF); gSPMatrix(gfx++, Matrix_NewMtx(gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPEndDisplayList(gfx++); @@ -458,32 +459,31 @@ Gfx* func_808AF86C(GraphicsContext* gfxCtx, GlobalContext* globalCtx) { return head; } -void EnBombf_Draw(Actor* thisx, GlobalContext* globalCtx) { +void EnBombf_Draw(Actor* thisx, PlayState* play) { s32 pad; EnBombf* this = THIS; - OPEN_DISPS(globalCtx->state.gfxCtx); + OPEN_DISPS(play->state.gfxCtx); if (ENBOMBF_GET(&this->actor) <= ENBOMBF_0) { - func_8012C28C(globalCtx->state.gfxCtx); + func_8012C28C(play->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); + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_OPA_DISP++, object_bombf_DL_000340); gSPDisplayList(POLY_OPA_DISP++, object_bombf_DL_000530); - Matrix_InsertTranslation(0.0f, 1000.0f, 0.0f, MTXMODE_APPLY); + Matrix_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); + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); { - Gfx* gfx = func_808AF86C(globalCtx->state.gfxCtx, globalCtx); + Gfx* gfx = func_808AF86C(play->state.gfxCtx, play); gSPSegment(POLY_OPA_DISP++, 0x08, Lib_SegmentedToVirtual(gfx)); } @@ -493,5 +493,5 @@ void EnBombf_Draw(Actor* thisx, GlobalContext* globalCtx) { Collider_UpdateSpheres(0, &this->colliderJntSph); } - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->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 b72edce8c..18a2a32ed 100644 --- a/src/overlays/actors/ovl_En_Bombf/z_en_bombf.h +++ b/src/overlays/actors/ovl_En_Bombf/z_en_bombf.h @@ -5,7 +5,7 @@ struct EnBombf; -typedef void (*EnBombfActionFunc)(struct EnBombf*, GlobalContext*); +typedef void (*EnBombfActionFunc)(struct EnBombf*, PlayState*); #define ENBOMBF_GET(thisx) ((thisx)->params) @@ -13,17 +13,17 @@ typedef void (*EnBombfActionFunc)(struct EnBombf*, GlobalContext*); #define ENBOMBF_1 1 typedef struct EnBombf { - /* 0x0000 */ Actor actor; - /* 0x0144 */ ColliderCylinder colliderCylinder; - /* 0x0190 */ ColliderJntSph colliderJntSph; - /* 0x01B0 */ ColliderJntSphElement colliderJntSphElements[1]; - /* 0x01F0 */ s16 timer; - /* 0x01F4 */ EnBombfActionFunc actionFunc; - /* 0x01F8 */ s32 unk_1F8; - /* 0x01FC */ u8 unk_1FC; - /* 0x01FE */ s16 unk_1FE; - /* 0x0200 */ f32 unk_200; - /* 0x0204 */ f32 unk_204; + /* 0x000 */ Actor actor; + /* 0x144 */ ColliderCylinder colliderCylinder; + /* 0x190 */ ColliderJntSph colliderJntSph; + /* 0x1B0 */ ColliderJntSphElement colliderJntSphElements[1]; + /* 0x1F0 */ s16 timer; + /* 0x1F4 */ EnBombfActionFunc actionFunc; + /* 0x1F8 */ s32 unk_1F8; + /* 0x1FC */ u8 unk_1FC; + /* 0x1FE */ s16 unk_1FE; + /* 0x200 */ f32 unk_200; + /* 0x204 */ f32 unk_204; } EnBombf; // size = 0x208 extern const ActorInit En_Bombf_InitVars; diff --git a/src/overlays/actors/ovl_En_Bomjima/z_en_bomjima.c b/src/overlays/actors/ovl_En_Bomjima/z_en_bomjima.c index 300679a4e..6c5a6f235 100644 --- a/src/overlays/actors/ovl_En_Bomjima/z_en_bomjima.c +++ b/src/overlays/actors/ovl_En_Bomjima/z_en_bomjima.c @@ -12,32 +12,32 @@ #define THIS ((EnBomjima*)thisx) -void EnBomjima_Init(Actor* thisx, GlobalContext* globalCtx); -void EnBomjima_Destroy(Actor* thisx, GlobalContext* globalCtx); -void EnBomjima_Update(Actor* thisx, GlobalContext* globalCtx); -void EnBomjima_Draw(Actor* thisx, GlobalContext* globalCtx); +void EnBomjima_Init(Actor* thisx, PlayState* play); +void EnBomjima_Destroy(Actor* thisx, PlayState* play); +void EnBomjima_Update(Actor* thisx, PlayState* play); +void EnBomjima_Draw(Actor* thisx, PlayState* play); -void func_80BFEA94(EnBomjima* this, GlobalContext* globalCtx); +void func_80BFEA94(EnBomjima* this, PlayState* play); void func_80BFEB1C(EnBomjima* this); -void func_80BFEB64(EnBomjima* this, GlobalContext* globalCtx); +void func_80BFEB64(EnBomjima* this, PlayState* play); void func_80BFEFF0(EnBomjima* this); -void func_80BFF03C(EnBomjima* this, GlobalContext* globalCtx); +void func_80BFF03C(EnBomjima* this, PlayState* play); void func_80BFF120(EnBomjima* this); -void func_80BFF174(EnBomjima* this, GlobalContext* globalCtx); -void func_80BFF430(EnBomjima* this, GlobalContext* globalCtx); -void func_80BFF52C(EnBomjima* this, GlobalContext* globalCtx); -void func_80BFF6CC(EnBomjima* this, GlobalContext* globalCtx); -void func_80BFF754(EnBomjima* this, GlobalContext* globalCtx); -void func_80BFF9B0(EnBomjima* this, GlobalContext* globalCtx); -void func_80BFFB40(EnBomjima* this, GlobalContext* globalCtx); -void func_80BFFBC4(EnBomjima* this, GlobalContext* globalCtx); +void func_80BFF174(EnBomjima* this, PlayState* play); +void func_80BFF430(EnBomjima* this, PlayState* play); +void func_80BFF52C(EnBomjima* this, PlayState* play); +void func_80BFF6CC(EnBomjima* this, PlayState* play); +void func_80BFF754(EnBomjima* this, PlayState* play); +void func_80BFF9B0(EnBomjima* this, PlayState* play); +void func_80BFFB40(EnBomjima* this, PlayState* play); +void func_80BFFBC4(EnBomjima* this, PlayState* play); void func_80BFFCFC(EnBomjima* this); -void func_80BFFD48(EnBomjima* this, GlobalContext* globalCtx); -void func_80BFFE48(EnBomjima* this, GlobalContext* globalCtx); -void func_80BFFF54(EnBomjima* this, GlobalContext* globalCtx); -void func_80C00168(EnBomjima* this, GlobalContext* globalCtx); +void func_80BFFD48(EnBomjima* this, PlayState* play); +void func_80BFFE48(EnBomjima* this, PlayState* play); +void func_80BFFF54(EnBomjima* this, PlayState* play); +void func_80C00168(EnBomjima* this, PlayState* play); void func_80C00234(EnBomjima* this); -void func_80C00284(EnBomjima* this, GlobalContext* globalCtx); +void func_80C00284(EnBomjima* this, PlayState* play); static s32 D_80C009F0 = 0; static s32 D_80C009F4 = 0; @@ -106,7 +106,7 @@ s16 D_80C00AF8[] = { 0x4000, 60, 0x4000, 30, 0xC000, 30, 0xC000, 60, }; -void EnBomjima_Init(Actor* thisx, GlobalContext* globalCtx) { +void EnBomjima_Init(Actor* thisx, PlayState* play) { EnBomjima* this = THIS; s32 cs; s32 i; @@ -114,9 +114,9 @@ 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, &gBomberIdleAnim, this->jointTable, + SkelAnime_InitFlex(play, &this->skelAnime, &object_cs_Skel_00F82C, &gBomberIdleAnim, this->jointTable, this->morphTable, OBJECT_CS_LIMB_MAX); - Collider_InitAndSetCylinder(globalCtx, &this->collider, &this->actor, &sCylinderInit); + Collider_InitAndSetCylinder(play, &this->collider, &this->actor, &sCylinderInit); gSaveContext.save.weekEventReg[83] &= (u8)~4; this->actor.targetMode = 0; this->unk_2E6 = ENBOMJIMA_GET_F0(&this->actor); @@ -145,14 +145,14 @@ void EnBomjima_Init(Actor* thisx, GlobalContext* globalCtx) { } } -void EnBomjima_Destroy(Actor* thisx, GlobalContext* globalCtx) { +void EnBomjima_Destroy(Actor* thisx, PlayState* play) { EnBomjima* this = THIS; - Collider_DestroyCylinder(globalCtx, &this->collider); + Collider_DestroyCylinder(play, &this->collider); } -void func_80BFE32C(EnBomjima* this, GlobalContext* globalCtx, s32 arg2) { - Player* player = GET_PLAYER(globalCtx); +void func_80BFE32C(EnBomjima* this, PlayState* play, s32 arg2) { + Player* player = GET_PLAYER(play); this->unk_2CA = arg2; if (player->transformation == PLAYER_FORM_GORON) { @@ -235,7 +235,7 @@ void func_80BFE65C(EnBomjima* this) { this->unk_29A = 0; } -void func_80BFE67C(EnBomjima* this, GlobalContext* globalCtx) { +void func_80BFE67C(EnBomjima* this, PlayState* play) { f32 sp84 = this->skelAnime.curFrame; f32 x; f32 z; @@ -259,7 +259,7 @@ void func_80BFE67C(EnBomjima* this, GlobalContext* globalCtx) { sp54.z += randPlusMinusPoint5Scaled(150.0f); abs = ABS_ALT(BINANG_SUB(this->actor.world.rot.y, Math_Vec3f_Yaw(&this->actor.world.pos, &sp54))); - if ((abs < 0x4000) && !BgCheck_EntityLineTest1(&globalCtx->colCtx, &this->actor.world.pos, &sp54, &sp6C, + if ((abs < 0x4000) && !BgCheck_EntityLineTest1(&play->colCtx, &this->actor.world.pos, &sp54, &sp6C, &sp50, true, false, false, true, &sp4C)) { func_80BFE494(this, 5, 1.0f); Math_Vec3f_Copy(&this->unk_2A4, &sp54); @@ -282,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, true, - false, false, true, &sp4C)) { + if (BgCheck_EntityLineTest1(&play->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); @@ -317,8 +317,8 @@ void func_80BFE67C(EnBomjima* this, GlobalContext* globalCtx) { } } -void func_80BFEA94(EnBomjima* this, GlobalContext* globalCtx) { - Actor* actor = globalCtx->actorCtx.actorLists[ACTORCAT_PROP].first; +void func_80BFEA94(EnBomjima* this, PlayState* play) { + Actor* actor = play->actorCtx.actorLists[ACTORCAT_PROP].first; while (actor != NULL) { if (actor->id != ACTOR_EN_BOMBAL) { @@ -343,42 +343,42 @@ void func_80BFEB1C(EnBomjima* this) { this->actionFunc = func_80BFEB64; } -void func_80BFEB64(EnBomjima* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); +void func_80BFEB64(EnBomjima* this, PlayState* play) { + Player* player = GET_PLAYER(play); s32 pad[2]; Vec3f sp40; - func_80BFE32C(this, globalCtx, 0); + func_80BFE32C(this, play, 0); if (player->transformation == PLAYER_FORM_DEKU) { if (gSaveContext.save.weekEventReg[73] & 0x20) { this->unk_2C8 = 3; - func_80BFE32C(this, globalCtx, 3); + func_80BFE32C(this, play, 3); } else if (gSaveContext.save.weekEventReg[77] & 2) { this->unk_2C8 = 11; - func_80BFE32C(this, globalCtx, 2); + func_80BFE32C(this, play, 2); } } else if (player->transformation == PLAYER_FORM_HUMAN) { if (gSaveContext.save.weekEventReg[84] & 0x80) { this->unk_2C8 = 0; - func_80BFE32C(this, globalCtx, 3); + func_80BFE32C(this, play, 3); } else if (gSaveContext.save.weekEventReg[85] & 1) { this->unk_2C8 = 11; - func_80BFE32C(this, globalCtx, 2); + func_80BFE32C(this, play, 2); } } - if (Text_GetFaceReaction(globalCtx, 0x11) != 0) { - this->actor.textId = Text_GetFaceReaction(globalCtx, 0x11); + if (Text_GetFaceReaction(play, 0x11) != 0) { + this->actor.textId = Text_GetFaceReaction(play, 0x11); } - if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { + if (Actor_ProcessTalkRequest(&this->actor, &play->state)) { this->unk_2DC = this->actor.yawTowardsPlayer; func_80C00234(this); return; } if (ActorCutscene_GetCurrentIndex() == -1) { - func_800B8614(&this->actor, globalCtx, 70.0f); + func_800B8614(&this->actor, play, 70.0f); } if ((this->unk_2F0->actor.update == NULL) || (this->unk_2F0->actor.colChkInfo.health == 0)) { @@ -413,8 +413,8 @@ void func_80BFEB64(EnBomjima* this, GlobalContext* globalCtx) { sp40.y = this->unk_2F0->actor.world.pos.y - randPlusMinusPoint5Scaled(40.0f); sp40.z = (Math_CosS(sp3E) * (Rand_ZeroFloat(20.0f) + 40.0f)) + this->unk_2F0->actor.world.pos.z; - SoundSource_PlaySfxAtFixedWorldPos(globalCtx, &sp40, 50, NA_SE_EV_BOMBERS_SHOT_EXPLOSUIN); - EffectSsHitMark_SpawnFixedScale(globalCtx, 0, &sp40); + SoundSource_PlaySfxAtFixedWorldPos(play, &sp40, 50, NA_SE_EV_BOMBERS_SHOT_EXPLOSUIN); + EffectSsHitmark_SpawnFixedScale(play, 0, &sp40); this->unk_2BC++; if (((s16)Rand_ZeroFloat(2.0f) + 3) < this->unk_2BC) { @@ -450,8 +450,8 @@ void func_80BFEFF0(EnBomjima* this) { this->actionFunc = func_80BFF03C; } -void func_80BFF03C(EnBomjima* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); +void func_80BFF03C(EnBomjima* this, PlayState* play) { + Player* player = GET_PLAYER(play); if (ActorCutscene_GetCurrentIndex() == 0x7C) { ActorCutscene_Stop(0x7C); @@ -461,8 +461,8 @@ void func_80BFF03C(EnBomjima* this, GlobalContext* globalCtx) { } else { player->stateFlags1 &= ~0x20; gSaveContext.save.weekEventReg[83] &= (u8)~4; - this->actor.world.rot.y = Camera_GetCamDirYaw(GET_ACTIVE_CAM(globalCtx)); - this->unk_2DC = Camera_GetCamDirYaw(GET_ACTIVE_CAM(globalCtx)); + this->actor.world.rot.y = Camera_GetCamDirYaw(GET_ACTIVE_CAM(play)); + this->unk_2DC = Camera_GetCamDirYaw(GET_ACTIVE_CAM(play)); ActorCutscene_StartAndSetUnkLinkFields(this->unk_2D4[0], &this->actor); func_80BFF120(this); } @@ -477,20 +477,20 @@ void func_80BFF120(EnBomjima* this) { this->actionFunc = func_80BFF174; } -void func_80BFF174(EnBomjima* this, GlobalContext* globalCtx) { +void func_80BFF174(EnBomjima* this, PlayState* play) { f32 sp2C = this->skelAnime.curFrame; - Player* player = GET_PLAYER(globalCtx); + Player* player = GET_PLAYER(play); if (this->unk_2C4 == 1) { ActorCutscene_Stop(this->unk_2D4[0]); this->unk_2DE = 1; } - if (Text_GetFaceReaction(globalCtx, 0x11) != 0) { - this->actor.textId = Text_GetFaceReaction(globalCtx, 0x11); + if (Text_GetFaceReaction(play, 0x11) != 0) { + this->actor.textId = Text_GetFaceReaction(play, 0x11); } - if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { + if (Actor_ProcessTalkRequest(&this->actor, &play->state)) { this->unk_2DC = this->actor.yawTowardsPlayer; func_80C00234(this); return; @@ -508,7 +508,7 @@ void func_80BFF174(EnBomjima* this, GlobalContext* globalCtx) { if (player->transformation == PLAYER_FORM_DEKU) { if (gSaveContext.save.weekEventReg[73] & 0x20) { this->unk_2C8 = 3; - func_80BFE32C(this, globalCtx, 3); + func_80BFE32C(this, play, 3); } else { if (!(gSaveContext.save.weekEventReg[77] & 2)) { if (this->unk_2E8 == 0) { @@ -519,12 +519,12 @@ void func_80BFF174(EnBomjima* this, GlobalContext* globalCtx) { } else { this->unk_2C8 = 11; } - func_80BFE32C(this, globalCtx, 2); + func_80BFE32C(this, play, 2); } } else if (player->transformation == PLAYER_FORM_HUMAN) { if (gSaveContext.save.weekEventReg[84] & 0x80) { this->unk_2C8 = 0; - func_80BFE32C(this, globalCtx, 3); + func_80BFE32C(this, play, 3); } else { if (!(gSaveContext.save.weekEventReg[85] & 1)) { if (this->unk_2EA == 0) { @@ -535,17 +535,17 @@ void func_80BFF174(EnBomjima* this, GlobalContext* globalCtx) { } else { this->unk_2C8 = 11; } - func_80BFE32C(this, globalCtx, 2); + func_80BFE32C(this, play, 2); } } else if (this->unk_2CA != 1) { - func_80BFE32C(this, globalCtx, 1); + func_80BFE32C(this, play, 1); } if (this->unk_2DE != 0) { if (this->unk_2BC >= 5) { - func_80BFE67C(this, globalCtx); + func_80BFE67C(this, play); } - func_800B8614(&this->actor, globalCtx, 70.0f); + func_800B8614(&this->actor, play, 70.0f); } } @@ -555,20 +555,20 @@ void func_80BFF3F0(EnBomjima* this) { this->actionFunc = func_80BFF430; } -void func_80BFF430(EnBomjima* this, GlobalContext* globalCtx) { +void func_80BFF430(EnBomjima* this, PlayState* play) { f32 curFrame = this->skelAnime.curFrame; if (this->unk_2CC <= curFrame) { - EnBombal* bombal = (EnBombal*)Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_BOMBAL, this->unk_2B0.x, + EnBombal* bombal = (EnBombal*)Actor_Spawn(&play->actorCtx, play, ACTOR_EN_BOMBAL, this->unk_2B0.x, this->unk_2B0.y, this->unk_2B0.z, 0, 0, 0, 0); if (bombal != NULL) { bombal->unk_150 = 0.0f; bombal->unk_14C = this->unk_2F4; - Actor_ChangeFocus(&this->actor, globalCtx, &bombal->actor); + Actor_ChangeFocus(&this->actor, play, &bombal->actor); gSaveContext.save.weekEventReg[83] &= (u8)~4; func_80BFE65C(this); - func_801477B4(globalCtx); + func_801477B4(play); this->actionFunc = func_80BFEA94; } } @@ -580,11 +580,11 @@ void func_80BFF4F4(EnBomjima* this) { this->actionFunc = func_80BFF52C; } -void func_80BFF52C(EnBomjima* this, GlobalContext* globalCtx) { - if ((Message_GetState(&globalCtx->msgCtx) == 4) && Message_ShouldAdvance(globalCtx)) { - func_801477B4(globalCtx); - if (globalCtx->msgCtx.choiceIndex == 0) { - Player* player = GET_PLAYER(globalCtx); +void func_80BFF52C(EnBomjima* this, PlayState* play) { + if ((Message_GetState(&play->msgCtx) == TEXT_STATE_CHOICE) && Message_ShouldAdvance(play)) { + func_801477B4(play); + if (play->msgCtx.choiceIndex == 0) { + Player* player = GET_PLAYER(play); func_8019F208(); func_80BFE65C(this); @@ -596,13 +596,13 @@ void func_80BFF52C(EnBomjima* this, GlobalContext* globalCtx) { } else { this->actor.textId = D_80C00A70[this->unk_2C8]; } - func_80151938(globalCtx, this->actor.textId); + func_80151938(play, this->actor.textId); play_sound(NA_SE_SY_FOUND); func_80BFE494(this, 15, 1.0f); this->unk_2A0 = 5; this->actionFunc = func_80BFF6CC; } else { - Player* player = GET_PLAYER(globalCtx); + Player* player = GET_PLAYER(play); func_8019F230(); func_80BFE65C(this); @@ -614,26 +614,26 @@ void func_80BFF52C(EnBomjima* this, GlobalContext* globalCtx) { this->actor.textId = D_80C00A70[this->unk_2C8]; this->unk_2EA = 1; } - func_80151938(globalCtx, this->actor.textId); + func_80151938(play, this->actor.textId); func_80C00234(this); } } } -void func_80BFF6CC(EnBomjima* this, GlobalContext* globalCtx) { +void func_80BFF6CC(EnBomjima* this, PlayState* play) { f32 curFrame = this->skelAnime.curFrame; if (this->unk_2CC <= curFrame) { - if ((Message_GetState(&globalCtx->msgCtx) == 5) && Message_ShouldAdvance(globalCtx)) { - func_801477B4(globalCtx); + if ((Message_GetState(&play->msgCtx) == TEXT_STATE_5) && Message_ShouldAdvance(play)) { + func_801477B4(play); func_80BFE494(this, 1, 1.0f); this->actionFunc = func_80BFF754; } } } -void func_80BFF754(EnBomjima* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); +void func_80BFF754(EnBomjima* this, PlayState* play) { + Player* player = GET_PLAYER(play); Vec3f spA0; EnBombal* temp_s3; s32 i; @@ -663,8 +663,8 @@ void func_80BFF754(EnBomjima* this, GlobalContext* globalCtx) { spA0.y += y * (2.0f + (i * 0.2f)); spA0.z += z * (2.0f + (i * 0.2f)); - temp_s3 = (EnBombal*)Actor_SpawnAsChild(&globalCtx->actorCtx, &this->actor, globalCtx, ACTOR_EN_BOMJIMA, spA0.x, - spA0.y, spA0.z, 0, 0, 0, i + 32); + temp_s3 = (EnBombal*)Actor_SpawnAsChild(&play->actorCtx, &this->actor, play, ACTOR_EN_BOMJIMA, spA0.x, spA0.y, + spA0.z, 0, 0, 0, i + 32); if (temp_s3 != NULL) { s32 index = (i * 2) - 2; @@ -682,9 +682,9 @@ void func_80BFF754(EnBomjima* this, GlobalContext* globalCtx) { this->actionFunc = func_80BFF9B0; } -void func_80BFF9B0(EnBomjima* this, GlobalContext* globalCtx) { +void func_80BFF9B0(EnBomjima* this, PlayState* play) { if (D_80C009F0 >= 4) { - Player* player = GET_PLAYER(globalCtx); + Player* player = GET_PLAYER(play); D_80C009F0 = 0; this->unk_2C8 = 9; @@ -723,14 +723,14 @@ void func_80BFF9B0(EnBomjima* this, GlobalContext* globalCtx) { } else { this->actor.textId = D_80C00A70[this->unk_2C8]; } - func_80151938(globalCtx, this->actor.textId); + func_80151938(play, this->actor.textId); this->actionFunc = func_80BFFB40; } } -void func_80BFFB40(EnBomjima* this, GlobalContext* globalCtx) { - if ((Message_GetState(&globalCtx->msgCtx) == 5) && Message_ShouldAdvance(globalCtx)) { - func_801477B4(globalCtx); +void func_80BFFB40(EnBomjima* this, PlayState* play) { + if ((Message_GetState(&play->msgCtx) == TEXT_STATE_5) && Message_ShouldAdvance(play)) { + func_801477B4(play); func_80BFE494(this, 15, 1.0f); D_80C009F0 = 100; this->unk_2DC = 0; @@ -738,7 +738,7 @@ void func_80BFFB40(EnBomjima* this, GlobalContext* globalCtx) { } } -void func_80BFFBC4(EnBomjima* this, GlobalContext* globalCtx) { +void func_80BFFBC4(EnBomjima* this, PlayState* play) { f32 curFrame = this->skelAnime.curFrame; if ((this->unk_2EC != 1) && (this->unk_2CC <= curFrame)) { @@ -756,12 +756,12 @@ void func_80BFFBC4(EnBomjima* this, GlobalContext* globalCtx) { Math_SmoothStepToS(&this->unk_290, this->unk_2DC, 1, 5000, 0); if (D_80C009F0 >= 104) { D_80C009F0 = 0; - func_801477B4(globalCtx); - globalCtx->nextEntranceIndex = Entrance_CreateIndexFromSpawn(6); + func_801477B4(play); + play->nextEntrance = Entrance_CreateFromSpawn(6); gSaveContext.nextCutsceneIndex = 0; - globalCtx->sceneLoadFlag = 20; - globalCtx->unk_1887F = 0x56; - gSaveContext.nextTransition = 3; + play->transitionTrigger = TRANS_TRIGGER_START; + play->transitionType = TRANS_TYPE_86; + gSaveContext.nextTransitionType = TRANS_TYPE_03; ActorCutscene_Stop(this->unk_2D4[1]); } } @@ -773,7 +773,7 @@ void func_80BFFCFC(EnBomjima* this) { this->actionFunc = func_80BFFD48; } -void func_80BFFD48(EnBomjima* this, GlobalContext* globalCtx) { +void func_80BFFD48(EnBomjima* this, PlayState* play) { s32 pad[2]; this->unk_2DC = Math_Vec3f_Yaw(&this->actor.world.pos, &this->unk_2A4); @@ -788,7 +788,7 @@ void func_80BFFD48(EnBomjima* this, GlobalContext* globalCtx) { } } -void func_80BFFE48(EnBomjima* this, GlobalContext* globalCtx) { +void func_80BFFE48(EnBomjima* this, PlayState* play) { Math_SmoothStepToS(&this->actor.world.rot.y, this->unk_2DC, 1, 5000, 0); Math_ApproachF(&this->actor.world.pos.x, this->unk_2A4.x, 0.3f, 4.0f); Math_ApproachF(&this->actor.world.pos.z, this->unk_2A4.z, 0.3f, 4.0f); @@ -811,7 +811,7 @@ void func_80BFFE48(EnBomjima* this, GlobalContext* globalCtx) { } } -void func_80BFFF54(EnBomjima* this, GlobalContext* globalCtx) { +void func_80BFFF54(EnBomjima* this, PlayState* play) { f32 curFrame = this->skelAnime.curFrame; Math_SmoothStepToS(&this->unk_290, this->unk_2DC, 1, 5000, 0); @@ -857,8 +857,8 @@ void func_80C0011C(EnBomjima* this) { this->actionFunc = func_80C00168; } -void func_80C00168(EnBomjima* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); +void func_80C00168(EnBomjima* this, PlayState* play) { + Player* player = GET_PLAYER(play); if (player->transformation == PLAYER_FORM_HUMAN) { this->unk_2C8 = 4; @@ -866,18 +866,18 @@ void func_80C00168(EnBomjima* this, GlobalContext* globalCtx) { this->unk_2C8 = 7; } - func_80BFE32C(this, globalCtx, 0); - func_80BFE67C(this, globalCtx); + func_80BFE32C(this, play, 0); + func_80BFE67C(this, play); - if (Text_GetFaceReaction(globalCtx, 0x11) != 0) { - this->actor.textId = Text_GetFaceReaction(globalCtx, 0x11); + if (Text_GetFaceReaction(play, 0x11) != 0) { + this->actor.textId = Text_GetFaceReaction(play, 0x11); } - if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { + if (Actor_ProcessTalkRequest(&this->actor, &play->state)) { this->unk_2DC = this->actor.yawTowardsPlayer; func_80C00234(this); } else { - func_800B8614(&this->actor, globalCtx, 70.0f); + func_800B8614(&this->actor, play, 70.0f); } } @@ -889,8 +889,8 @@ void func_80C00234(EnBomjima* this) { this->actionFunc = func_80C00284; } -void func_80C00284(EnBomjima* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); +void func_80C00284(EnBomjima* this, PlayState* play) { + Player* player = GET_PLAYER(play); f32 sp28 = this->skelAnime.curFrame; Math_SmoothStepToS(&this->actor.world.rot.y, this->unk_2DC, 1, 5000, 0); @@ -916,7 +916,7 @@ void func_80C00284(EnBomjima* this, GlobalContext* globalCtx) { break; } - if ((Message_GetState(&globalCtx->msgCtx) == 5) && Message_ShouldAdvance(globalCtx)) { + if ((Message_GetState(&play->msgCtx) == TEXT_STATE_5) && Message_ShouldAdvance(play)) { this->collider.dim.radius = 10; this->collider.dim.height = 30; if ((this->unk_2A0 == 4) || (this->unk_2CA == 1) || ((this->unk_2CA == 3) && (this->unk_2C8 >= 2))) { @@ -930,13 +930,13 @@ void func_80C00284(EnBomjima* this, GlobalContext* globalCtx) { func_80BFF3F0(this); } else { func_80BFE65C(this); - func_801477B4(globalCtx); + func_801477B4(play); this->actionFunc = func_80BFEA94; } return; } - func_801477B4(globalCtx); + func_801477B4(play); switch (this->unk_2CA) { case 0: @@ -970,7 +970,7 @@ void func_80C00284(EnBomjima* this, GlobalContext* globalCtx) { } this->actor.textId = D_80C00A70[this->unk_2C8]; } - func_80151938(globalCtx, this->actor.textId); + func_80151938(play, this->actor.textId); if ((this->unk_2C8 == 7) || (this->unk_2C8 == 12)) { func_80BFF4F4(this); } @@ -979,7 +979,7 @@ void func_80C00284(EnBomjima* this, GlobalContext* globalCtx) { case 3: this->unk_2C8++; this->actor.textId = D_80C00A8C[this->unk_2C8]; - func_80151938(globalCtx, this->actor.textId); + func_80151938(play, this->actor.textId); if (this->unk_2C8 >= 2) { func_80BFE494(this, 17, 1.0f); } @@ -988,7 +988,7 @@ void func_80C00284(EnBomjima* this, GlobalContext* globalCtx) { } } -void EnBomjima_Update(Actor* thisx, GlobalContext* globalCtx) { +void EnBomjima_Update(Actor* thisx, PlayState* play) { s32 pad; EnBomjima* this = THIS; @@ -1016,7 +1016,7 @@ void EnBomjima_Update(Actor* thisx, GlobalContext* globalCtx) { this->actor.shape.rot.y = this->actor.world.rot.y; func_80BFE524(this); Actor_SetFocus(&this->actor, 20.0f); - this->actionFunc(this, globalCtx); + this->actionFunc(this, play); Actor_MoveWithGravity(&this->actor); Math_SmoothStepToS(&this->unk_28A, this->unk_290, 1, 5000, 0); Math_SmoothStepToS(&this->unk_288, this->unk_28E, 1, 1000, 0); @@ -1030,14 +1030,13 @@ void EnBomjima_Update(Actor* thisx, GlobalContext* globalCtx) { } } - Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 20.0f, 20.0f, 50.0f, 0x1D); + Actor_UpdateBgCheckInfo(play, &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); + CollisionCheck_SetOC(play, &play->colChkCtx, &this->collider.base); } -s32 EnBomjima_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, - Actor* thisx) { +s32 EnBomjima_OverrideLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, Actor* thisx) { EnBomjima* this = THIS; if (limbIndex == 8) { @@ -1066,7 +1065,7 @@ s32 EnBomjima_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dL #include "overlays/ovl_En_Bomjima/ovl_En_Bomjima.c" -void EnBomjima_Draw(Actor* thisx, GlobalContext* globalCtx) { +void EnBomjima_Draw(Actor* thisx, PlayState* play) { static Gfx* D_80C00B28[] = { gEnBomjima_D_80C00B08, gEnBomjima_D_80C00B18, gEnBomjima_D_80C00B18, gEnBomjima_D_80C00B18, gEnBomjima_D_80C00B18, @@ -1081,18 +1080,18 @@ void EnBomjima_Draw(Actor* thisx, GlobalContext* globalCtx) { }; EnBomjima* this = THIS; - OPEN_DISPS(globalCtx->state.gfxCtx); + OPEN_DISPS(play->state.gfxCtx); - func_8012C28C(globalCtx->state.gfxCtx); - func_8012C2DC(globalCtx->state.gfxCtx); + func_8012C28C(play->state.gfxCtx); + func_8012C2DC(play->state.gfxCtx); gSPSegment(POLY_OPA_DISP++, 0x08, Lib_SegmentedToVirtual(D_80C00B3C[this->unk_2E0])); gSPSegment(POLY_OPA_DISP++, 0x09, Lib_SegmentedToVirtual(D_80C00B48[this->unk_2E4])); gSPSegment(POLY_OPA_DISP++, 0x0A, Lib_SegmentedToVirtual(D_80C00B28[this->unk_2E4])); - Scene_SetRenderModeXlu(globalCtx, 0, 1); - SkelAnime_DrawFlexOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, + Scene_SetRenderModeXlu(play, 0, 1); + SkelAnime_DrawFlexOpa(play, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, EnBomjima_OverrideLimbDraw, NULL, &this->actor); - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->state.gfxCtx); } diff --git a/src/overlays/actors/ovl_En_Bomjima/z_en_bomjima.h b/src/overlays/actors/ovl_En_Bomjima/z_en_bomjima.h index c01e70bd5..b247e03ea 100644 --- a/src/overlays/actors/ovl_En_Bomjima/z_en_bomjima.h +++ b/src/overlays/actors/ovl_En_Bomjima/z_en_bomjima.h @@ -5,13 +5,13 @@ struct EnBomjima; -typedef void (*EnBomjimaActionFunc)(struct EnBomjima*, GlobalContext*); +typedef void (*EnBomjimaActionFunc)(struct EnBomjima*, PlayState*); #define ENBOMJIMA_GET_F0(thisx) (((thisx)->params >> 4) & 0xF) #define ENBOMJIMA_GET_F(thisx) ((thisx)->params & 0xF) typedef struct EnBomjima { - /* 0x0000 */ Actor actor; + /* 0x000 */ Actor actor; /* 0x144 */ SkelAnime skelAnime; /* 0x188 */ Vec3s jointTable[21]; /* 0x206 */ Vec3s morphTable[21]; diff --git a/src/overlays/actors/ovl_En_Bomjimb/z_en_bomjimb.c b/src/overlays/actors/ovl_En_Bomjimb/z_en_bomjimb.c index c18a94209..a9d9756be 100644 --- a/src/overlays/actors/ovl_En_Bomjimb/z_en_bomjimb.c +++ b/src/overlays/actors/ovl_En_Bomjimb/z_en_bomjimb.c @@ -12,31 +12,31 @@ #define THIS ((EnBomjimb*)thisx) -void EnBomjimb_Init(Actor* thisx, GlobalContext* globalCtx); -void EnBomjimb_Destroy(Actor* thisx, GlobalContext* globalCtx); -void EnBomjimb_Update(Actor* thisx, GlobalContext* globalCtx); -void EnBomjimb_Draw(Actor* thisx, GlobalContext* globalCtx); +void EnBomjimb_Init(Actor* thisx, PlayState* play); +void EnBomjimb_Destroy(Actor* thisx, PlayState* play); +void EnBomjimb_Update(Actor* thisx, PlayState* play); +void EnBomjimb_Draw(Actor* thisx, PlayState* play); void func_80C01494(EnBomjimb* this); -void func_80C014E4(EnBomjimb* this, GlobalContext* globalCtx); -void func_80C01984(EnBomjimb* this, GlobalContext* globalCtx); -void func_80C01A24(EnBomjimb* this, GlobalContext* globalCtx); +void func_80C014E4(EnBomjimb* this, PlayState* play); +void func_80C01984(EnBomjimb* this, PlayState* play); +void func_80C01A24(EnBomjimb* this, PlayState* play); void func_80C01B40(EnBomjimb* this); -void func_80C01B74(EnBomjimb* this, GlobalContext* globalCtx); -void func_80C01C18(EnBomjimb* this, GlobalContext* globalCtx); -void func_80C01CD0(EnBomjimb* this, GlobalContext* globalCtx); -void func_80C0201C(EnBomjimb* this, GlobalContext* globalCtx); +void func_80C01B74(EnBomjimb* this, PlayState* play); +void func_80C01C18(EnBomjimb* this, PlayState* play); +void func_80C01CD0(EnBomjimb* this, PlayState* play); +void func_80C0201C(EnBomjimb* this, PlayState* play); void func_80C02108(EnBomjimb* this); -void func_80C0217C(EnBomjimb* this, GlobalContext* globalCtx); +void func_80C0217C(EnBomjimb* this, PlayState* play); void func_80C0250C(EnBomjimb* this); -void func_80C02570(EnBomjimb* this, GlobalContext* globalCtx); +void func_80C02570(EnBomjimb* this, PlayState* play); void func_80C0267C(EnBomjimb* this); -void func_80C02704(EnBomjimb* this, GlobalContext* globalCtx); -void func_80C02740(EnBomjimb* this, GlobalContext* globalCtx); -void func_80C02A14(EnBomjimb* this, GlobalContext* globalCtx); -void func_80C02BCC(EnBomjimb* this, GlobalContext* globalCtx); -void func_80C02CA4(EnBomjimb* this, GlobalContext* globalCtx); -void func_80C02DAC(EnBomjimb* this, GlobalContext* globalCtx); +void func_80C02704(EnBomjimb* this, PlayState* play); +void func_80C02740(EnBomjimb* this, PlayState* play); +void func_80C02A14(EnBomjimb* this, PlayState* play); +void func_80C02BCC(EnBomjimb* this, PlayState* play); +void func_80C02CA4(EnBomjimb* this, PlayState* play); +void func_80C02DAC(EnBomjimb* this, PlayState* play); static Actor* D_80C03170 = NULL; @@ -72,15 +72,31 @@ static ColliderCylinderInit sCylinderInit = { { 20, 30, 0, { 0, 0, 0 } }, }; -void EnBomjimb_Init(Actor* thisx, GlobalContext* globalCtx) { +static AnimationHeader* sAnimations[] = { + &gBomberIdleAnim, &object_cs_Anim_00FAF4, &object_cs_Anim_0057C8, &object_cs_Anim_0053F4, + &object_cs_Anim_002044, &object_cs_Anim_01007C, &object_cs_Anim_00349C, &object_cs_Anim_004960, + &object_cs_Anim_005128, &object_cs_Anim_004C1C, &object_cs_Anim_002930, &object_cs_Anim_001A1C, + &object_cs_Anim_003EE4, &object_cs_Anim_00478C, &object_cs_Anim_00433C, &object_cs_Anim_0060E8, + &object_cs_Anim_001708, &object_cs_Anim_005DC4, &object_cs_Anim_0026B0, &object_cs_Anim_0036B0, + &object_cs_Anim_0031C4, &object_cs_Anim_010B68, +}; + +static u8 sAnimationModes[] = { + ANIMMODE_LOOP, ANIMMODE_LOOP, ANIMMODE_LOOP, ANIMMODE_LOOP, ANIMMODE_LOOP, ANIMMODE_LOOP, + ANIMMODE_ONCE, ANIMMODE_ONCE, ANIMMODE_LOOP, ANIMMODE_LOOP, ANIMMODE_LOOP, ANIMMODE_LOOP, + ANIMMODE_ONCE, ANIMMODE_LOOP, ANIMMODE_LOOP, ANIMMODE_LOOP, ANIMMODE_ONCE, ANIMMODE_LOOP, + ANIMMODE_ONCE, ANIMMODE_LOOP, ANIMMODE_LOOP, ANIMMODE_ONCE, ANIMMODE_LOOP, ANIMMODE_LOOP, +}; + +void EnBomjimb_Init(Actor* thisx, PlayState* play) { EnBomjimb* this = THIS; 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, &gBomberIdleAnim, this->jointTable, + SkelAnime_InitFlex(play, &this->skelAnime, &object_cs_Skel_00F82C, &gBomberIdleAnim, this->jointTable, this->morphTable, OBJECT_CS_LIMB_MAX); - Collider_InitAndSetCylinder(globalCtx, &this->collider, &this->actor, &sCylinderInit); + Collider_InitAndSetCylinder(play, &this->collider, &this->actor, &sCylinderInit); this->actor.targetMode = 6; Actor_SetScale(&this->actor, 0.01f); @@ -148,33 +164,21 @@ void EnBomjimb_Init(Actor* thisx, GlobalContext* globalCtx) { if ((this->unk_2C6 == ENBOMJIMB_F0_0) || (this->unk_2C6 == ENBOMJIMB_F0_1) || (this->unk_2C6 != ENBOMJIMB_F0_2)) { func_80C01494(this); } else { - func_80C01984(this, globalCtx); + func_80C01984(this, play); } } -void EnBomjimb_Destroy(Actor* thisx, GlobalContext* globalCtx) { +void EnBomjimb_Destroy(Actor* thisx, PlayState* play) { EnBomjimb* this = THIS; - Collider_DestroyCylinder(globalCtx, &this->collider); + Collider_DestroyCylinder(play, &this->collider); } void func_80C0113C(EnBomjimb* this, s32 arg1, f32 arg2) { - static AnimationHeader* sAnimations[] = { - &gBomberIdleAnim, &object_cs_Anim_00FAF4, &object_cs_Anim_0057C8, &object_cs_Anim_0053F4, - &object_cs_Anim_002044, &object_cs_Anim_01007C, &object_cs_Anim_00349C, &object_cs_Anim_004960, - &object_cs_Anim_005128, &object_cs_Anim_004C1C, &object_cs_Anim_002930, &object_cs_Anim_001A1C, - &object_cs_Anim_003EE4, &object_cs_Anim_00478C, &object_cs_Anim_00433C, &object_cs_Anim_0060E8, - &object_cs_Anim_001708, &object_cs_Anim_005DC4, &object_cs_Anim_0026B0, &object_cs_Anim_0036B0, - &object_cs_Anim_0031C4, &object_cs_Anim_010B68, - }; - static u8 D_80C03218[] = { - 0, 0, 0, 0, 0, 0, 2, 2, 0, 0, 0, 0, 2, 0, 0, 0, 2, 0, 2, 0, 0, 2, 0, 0, - }; - this->unk_2DC = arg1; this->unk_2B8 = Animation_GetLastFrame(sAnimations[arg1]); - Animation_Change(&this->skelAnime, sAnimations[this->unk_2DC], arg2, 0.0f, this->unk_2B8, D_80C03218[this->unk_2DC], - -4.0f); + Animation_Change(&this->skelAnime, sAnimations[this->unk_2DC], arg2, 0.0f, this->unk_2B8, + sAnimationModes[this->unk_2DC], -4.0f); } void func_80C011CC(EnBomjimb* this) { @@ -206,13 +210,13 @@ void func_80C012E0(EnBomjimb* this) { this->unk_290 = 0; } -s32 func_80C012FC(EnBomjimb* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); +s32 func_80C012FC(EnBomjimb* this, PlayState* play) { + Player* player = GET_PLAYER(play); - 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)) { + if (!Play_InCsMode(play) && (this->actor.xzDistToPlayer < 40.0f) && + (fabsf(player->actor.world.pos.y - this->actor.world.pos.y) < 50.0f) && (play->msgCtx.msgLength == 0)) { this->actor.speedXZ = 0.0f; - func_80C02740(this, globalCtx); + func_80C02740(this, play); return true; } return false; @@ -226,17 +230,17 @@ s32 func_80C013B4(EnBomjimb* this) { return false; } -s32 func_80C013F0(EnBomjimb* this, GlobalContext* globalCtx) { +s32 func_80C013F0(EnBomjimb* this, PlayState* play) { Actor* sp1C; if (this->collider.base.ocFlags1 & OC1_HIT) { sp1C = this->collider.base.oc; if ((sp1C->id == ACTOR_OBJ_KIBAKO) && (D_80C03170 == NULL) && (sp1C->update != NULL) && - !Actor_HasParent(sp1C, globalCtx)) { + !Actor_HasParent(sp1C, play)) { D_80C03170 = sp1C; this->unk_2E4 = sp1C; - func_80C01C18(this, globalCtx); + func_80C01C18(this, play); return true; } } @@ -250,8 +254,8 @@ void func_80C01494(EnBomjimb* this) { this->actionFunc = func_80C014E4; } -void func_80C014E4(EnBomjimb* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); +void func_80C014E4(EnBomjimb* this, PlayState* play) { + Player* player = GET_PLAYER(play); f32 curFrame = this->skelAnime.curFrame; CollisionPoly* colPoly; s16 abs; @@ -263,7 +267,7 @@ void func_80C014E4(EnBomjimb* this, GlobalContext* globalCtx) { Vec3f sp48; s32 sp44; - if (func_80C012FC(this, globalCtx) || func_80C013B4(this) || func_80C013F0(this, globalCtx)) { + if (func_80C012FC(this, play) || func_80C013B4(this) || func_80C013F0(this, play)) { return; } @@ -275,7 +279,7 @@ void func_80C014E4(EnBomjimb* this, GlobalContext* globalCtx) { sp48.z += randPlusMinusPoint5Scaled(150.0f); 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, + if ((abs < 0x4000) && !BgCheck_EntityLineTest1(&play->colCtx, &this->actor.world.pos, &sp48, &sp60, &colPoly, true, false, false, true, &sp44)) { func_80C0113C(this, 5, 1.0f); Math_Vec3f_Copy(&this->unk_294, &sp48); @@ -295,8 +299,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, true, - false, false, true, &sp44)) { + if (BgCheck_EntityLineTest1(&play->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); @@ -343,11 +347,11 @@ void func_80C014E4(EnBomjimb* this, GlobalContext* globalCtx) { } } -void func_80C01984(EnBomjimb* this, GlobalContext* globalCtx) { +void func_80C01984(EnBomjimb* this, PlayState* play) { func_80C012E0(this); this->unk_2E4 = - Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_NIW, this->actor.world.pos.x, - this->actor.world.pos.y + 30.0f, this->actor.world.pos.z, 0, this->actor.world.rot.y, 0, 2); + Actor_Spawn(&play->actorCtx, play, ACTOR_EN_NIW, this->actor.world.pos.x, this->actor.world.pos.y + 30.0f, + this->actor.world.pos.z, 0, this->actor.world.rot.y, 0, 2); if (this->unk_2E4 != NULL) { func_80C0113C(this, 11, 1.0f); } @@ -355,8 +359,8 @@ void func_80C01984(EnBomjimb* this, GlobalContext* globalCtx) { this->actionFunc = func_80C01A24; } -void func_80C01A24(EnBomjimb* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); +void func_80C01A24(EnBomjimb* this, PlayState* play) { + Player* player = GET_PLAYER(play); this->actor.gravity = -0.1f; if (this->collider.base.acFlags & AC_HIT) { @@ -390,7 +394,7 @@ void func_80C01B40(EnBomjimb* this) { this->actionFunc = func_80C01B74; } -void func_80C01B74(EnBomjimb* this, GlobalContext* globalCtx) { +void func_80C01B74(EnBomjimb* this, PlayState* play) { Math_ApproachF(&this->actor.speedXZ, 6.0f, 0.5f, 2.0f); if ((this->collider.base.acFlags & AC_HIT) || (this->actor.bgCheckFlags & 1)) { this->collider.base.acFlags &= ~AC_HIT; @@ -404,12 +408,12 @@ void func_80C01B74(EnBomjimb* this, GlobalContext* globalCtx) { } } -void func_80C01C18(EnBomjimb* this, GlobalContext* globalCtx) { +void func_80C01C18(EnBomjimb* this, PlayState* play) { func_80C012E0(this); if (this->unk_2E4 != NULL) { if (this->unk_2E4->update != NULL) { this->unk_2E4->velocity.y = 8.0f; - this->unk_2E4->shape.rot.z = BINANG_SUB(4000, ((s16)(globalCtx->gameplayFrames & 2) * 4000)); + this->unk_2E4->shape.rot.z = BINANG_SUB(4000, ((s16)(play->gameplayFrames & 2) * 4000)); this->unk_294.x = this->unk_2E4->world.pos.x; this->unk_294.y = this->actor.world.pos.y; this->unk_294.z = this->unk_2E4->world.pos.z; @@ -420,11 +424,11 @@ void func_80C01C18(EnBomjimb* this, GlobalContext* globalCtx) { this->actionFunc = func_80C01CD0; } -void func_80C01CD0(EnBomjimb* this, GlobalContext* globalCtx) { +void func_80C01CD0(EnBomjimb* this, PlayState* play) { f32 sp3C = this->skelAnime.curFrame; s32 pad[2]; - if ((this->unk_2E4 != NULL) && ((this->unk_2E4->update == NULL) || Actor_HasParent(this->unk_2E4, globalCtx))) { + if ((this->unk_2E4 != NULL) && ((this->unk_2E4->update == NULL) || Actor_HasParent(this->unk_2E4, play))) { this->actor.draw = EnBomjimb_Draw; D_80C03170 = NULL; this->unk_2E4 = NULL; @@ -460,7 +464,7 @@ void func_80C01CD0(EnBomjimb* this, GlobalContext* globalCtx) { this->unk_2AE = 10; if ((this->unk_2E4 != NULL) && (this->unk_2E4->update != NULL)) { - if ((globalCtx->gameplayFrames % 16) == 0) { + if ((play->gameplayFrames % 16) == 0) { this->unk_2E4->shape.rot.z = -this->unk_2E4->shape.rot.z; this->unk_2E4->shape.rot.z *= 0.1f; } @@ -488,7 +492,7 @@ void func_80C01FD4(EnBomjimb* this) { this->actionFunc = func_80C0201C; } -void func_80C0201C(EnBomjimb* this, GlobalContext* globalCtx) { +void func_80C0201C(EnBomjimb* this, PlayState* play) { s16 abs = ABS_ALT(BINANG_SUB(this->actor.yawTowardsPlayer, this->actor.world.rot.y)); this->unk_290 = 0; @@ -501,11 +505,11 @@ void func_80C0201C(EnBomjimb* this, GlobalContext* globalCtx) { } } - if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { + if (Actor_ProcessTalkRequest(&this->actor, &play->state)) { this->unk_2CA = 10; this->actionFunc = func_80C02A14; } else { - func_800B8614(&this->actor, globalCtx, 40.0f); + func_800B8614(&this->actor, play, 40.0f); } } @@ -520,17 +524,17 @@ void func_80C02108(EnBomjimb* this) { this->actionFunc = func_80C0217C; } -void func_80C0217C(EnBomjimb* this, GlobalContext* globalCtx) { +void func_80C0217C(EnBomjimb* this, PlayState* play) { Vec3f sp74; CollisionPoly* sp70; Vec3f sp64; s32 sp60; s32 sp5C = this->actor.floorBgId; CollisionPoly* sp58 = this->actor.floorPoly; - Player* player = GET_PLAYER(globalCtx); + Player* player = GET_PLAYER(play); s32 sp50 = false; - if (func_80C012FC(this, globalCtx) || func_80C013B4(this) || func_80C013F0(this, globalCtx)) { + if (func_80C012FC(this, play) || func_80C013B4(this) || func_80C013F0(this, play)) { return; } @@ -556,8 +560,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, true, false, false, - true, &sp60)) { + if (BgCheck_EntityLineTest1(&play->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; @@ -586,7 +590,7 @@ void func_80C0217C(EnBomjimb* this, GlobalContext* globalCtx) { this->actor.world.rot.y = this->unk_2D6 + this->unk_2D4; - if (SurfaceType_GetSceneExitIndex(&globalCtx->colCtx, sp58, sp5C)) { + if (SurfaceType_GetSceneExitIndex(&play->colCtx, sp58, sp5C)) { s16 temp = BINANG_SUB(this->actor.world.rot.y, this->actor.yawTowardsPlayer - 0x8000); if (temp < 0) { @@ -614,10 +618,10 @@ void func_80C0250C(EnBomjimb* this) { this->actionFunc = func_80C02570; } -void func_80C02570(EnBomjimb* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); +void func_80C02570(EnBomjimb* this, PlayState* play) { + Player* player = GET_PLAYER(play); - if (func_80C012FC(this, globalCtx) || func_80C013B4(this) || func_80C013F0(this, globalCtx)) { + if (func_80C012FC(this, play) || func_80C013B4(this) || func_80C013F0(this, play)) { return; } @@ -645,24 +649,23 @@ void func_80C0267C(EnBomjimb* this) { this->actionFunc = func_80C02704; } -void func_80C02704(EnBomjimb* this, GlobalContext* globalCtx) { - if (!func_80C012FC(this, globalCtx) && (this->unk_2AE == 0)) { +void func_80C02704(EnBomjimb* this, PlayState* play) { + if (!func_80C012FC(this, play) && (this->unk_2AE == 0)) { func_80C0250C(this); } } -void func_80C02740(EnBomjimb* this, GlobalContext* globalCtx) { +void func_80C02740(EnBomjimb* this, PlayState* play) { static u16 D_80C03230[] = { 0x0721, 0x0722, 0x0723, 0x0724, 0x072C, }; - Player* player = GET_PLAYER(globalCtx); - s16 idx; + Player* player = GET_PLAYER(play); 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); - Message_StartTextbox(globalCtx, 0x72E, &this->actor); + Message_StartTextbox(play, 0x72E, &this->actor); player->stateFlags1 |= 0x10000000; player->actor.freezeTimer = 3; func_80C012E0(this); @@ -674,7 +677,7 @@ void func_80C02740(EnBomjimb* this, GlobalContext* globalCtx) { if (((player->transformation == PLAYER_FORM_DEKU) && !(gSaveContext.save.weekEventReg[73] & 0x10)) || ((player->transformation == PLAYER_FORM_HUMAN) && !(gSaveContext.save.weekEventReg[85] & 2))) { func_80C0113C(this, 17, 1.0f); - Message_StartTextbox(globalCtx, 0x72E, &this->actor); + Message_StartTextbox(play, 0x72E, &this->actor); player->stateFlags1 |= 0x10000000; player->actor.freezeTimer = 3; func_80C012E0(this); @@ -683,10 +686,8 @@ void func_80C02740(EnBomjimb* this, GlobalContext* globalCtx) { return; } - idx = gSaveContext.save.bombersCaughtNum; - Message_StartTextbox(globalCtx, D_80C03230[idx], &this->actor); - idx = gSaveContext.save.bombersCaughtNum; - gSaveContext.save.bombersCaughtOrder[idx] = this->unk_2C8 + 1; + Message_StartTextbox(play, D_80C03230[((void)0, gSaveContext.save.bombersCaughtNum)], &this->actor); + gSaveContext.save.bombersCaughtOrder[((void)0, gSaveContext.save.bombersCaughtNum)] = this->unk_2C8 + 1; gSaveContext.save.bombersCaughtNum++; if (gSaveContext.save.bombersCaughtNum > 4) { @@ -722,8 +723,8 @@ void func_80C02740(EnBomjimb* this, GlobalContext* globalCtx) { break; } - if (!Play_InCsMode(globalCtx)) { - Player* player = GET_PLAYER(globalCtx); + if (!Play_InCsMode(play)) { + Player* player = GET_PLAYER(play); player->stateFlags1 |= 0x10000000; player->actor.freezeTimer = 3; @@ -732,8 +733,8 @@ void func_80C02740(EnBomjimb* this, GlobalContext* globalCtx) { this->actionFunc = func_80C02A14; } -void func_80C02A14(EnBomjimb* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); +void func_80C02A14(EnBomjimb* this, PlayState* play) { + Player* player = GET_PLAYER(play); f32 curFrame = this->skelAnime.curFrame; if (this->unk_2DC == 21) { @@ -758,10 +759,10 @@ void func_80C02A14(EnBomjimb* this, GlobalContext* globalCtx) { player->actor.freezeTimer = 3; } - if ((Message_GetState(&globalCtx->msgCtx) == 5) && Message_ShouldAdvance(globalCtx)) { - func_801477B4(globalCtx); + if ((Message_GetState(&play->msgCtx) == TEXT_STATE_5) && Message_ShouldAdvance(play)) { + func_801477B4(play); if ((this->unk_2CA == 8) && (gSaveContext.save.bombersCaughtNum >= 5)) { - func_80C02CA4(this, globalCtx); + func_80C02CA4(this, play); } else { if (this->unk_2CA == 8) { player->stateFlags1 &= ~0x10000000; @@ -771,14 +772,14 @@ void func_80C02A14(EnBomjimb* this, GlobalContext* globalCtx) { } } -void func_80C02BCC(EnBomjimb* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); +void func_80C02BCC(EnBomjimb* this, PlayState* play) { + Player* player = GET_PLAYER(play); Math_SmoothStepToS(&this->actor.world.rot.y, this->actor.yawTowardsPlayer, 1, 5000, 0); if (this->unk_2C0 == 0) { player->actor.freezeTimer = 3; - if ((Message_GetState(&globalCtx->msgCtx) == 5) && Message_ShouldAdvance(globalCtx)) { - func_801477B4(globalCtx); + if ((Message_GetState(&play->msgCtx) == TEXT_STATE_5) && Message_ShouldAdvance(play)) { + func_801477B4(play); this->unk_2C0 = 1; player->stateFlags1 &= ~0x10000000; } @@ -787,32 +788,32 @@ void func_80C02BCC(EnBomjimb* this, GlobalContext* globalCtx) { } } -void func_80C02CA4(EnBomjimb* this, GlobalContext* globalCtx) { +void func_80C02CA4(EnBomjimb* this, PlayState* play) { if (BREG(13) == 0) { - globalCtx->nextEntranceIndex = globalCtx->setupExitList[this->unk_2B2]; + play->nextEntrance = play->setupExitList[this->unk_2B2]; gSaveContext.nextCutsceneIndex = 0; - Scene_SetExitFade(globalCtx); - globalCtx->sceneLoadFlag = 0x14; + Scene_SetExitFade(play); + play->transitionTrigger = TRANS_TRIGGER_START; } else { - globalCtx->nextEntranceIndex = Entrance_CreateIndexFromSpawn(5); + play->nextEntrance = Entrance_CreateFromSpawn(5); gSaveContext.nextCutsceneIndex = 0; - globalCtx->sceneLoadFlag = 0x14; - globalCtx->unk_1887F = 0x56; - gSaveContext.nextTransition = 3; + play->transitionTrigger = TRANS_TRIGGER_START; + play->transitionType = TRANS_TYPE_86; + gSaveContext.nextTransitionType = TRANS_TYPE_03; } gSaveContext.save.weekEventReg[75] |= 0x40; gSaveContext.save.weekEventReg[83] |= 4; this->actionFunc = func_80C02DAC; } -void func_80C02DAC(EnBomjimb* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); +void func_80C02DAC(EnBomjimb* this, PlayState* play) { + Player* player = GET_PLAYER(play); player->actor.freezeTimer = 3; } -void EnBomjimb_Update(Actor* thisx, GlobalContext* globalCtx2) { - GlobalContext* globalCtx = globalCtx2; +void EnBomjimb_Update(Actor* thisx, PlayState* play2) { + PlayState* play = play2; EnBomjimb* this = THIS; if (this->unk_2B0 != 0) { @@ -832,7 +833,7 @@ void EnBomjimb_Update(Actor* thisx, GlobalContext* globalCtx2) { func_80C011CC(this); Actor_SetFocus(&this->actor, 20.0f); - this->actionFunc(this, globalCtx); + this->actionFunc(this, play); Actor_MoveWithGravity(&this->actor); @@ -857,17 +858,16 @@ void EnBomjimb_Update(Actor* thisx, GlobalContext* globalCtx2) { } } - Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 20.0f, 20.0f, 50.0f, 0x1D); + Actor_UpdateBgCheckInfo(play, &this->actor, 20.0f, 20.0f, 50.0f, 0x1D); Collider_UpdateCylinder(&this->actor, &this->collider); - CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + CollisionCheck_SetAC(play, &play->colChkCtx, &this->collider.base); if (this->unk_2CA != 2) { - CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + CollisionCheck_SetOC(play, &play->colChkCtx, &this->collider.base); } } -s32 EnBomjimb_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, - Actor* thisx) { +s32 EnBomjimb_OverrideLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, Actor* thisx) { EnBomjimb* this = THIS; if (limbIndex == 15) { @@ -892,7 +892,7 @@ s32 EnBomjimb_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dL #include "overlays/ovl_En_Bomjimb/ovl_En_Bomjimb.c" -void EnBomjimb_Draw(Actor* thisx, GlobalContext* globalCtx) { +void EnBomjimb_Draw(Actor* thisx, PlayState* play) { static Gfx* D_80C03260[] = { gEnBomjimb_D_80C03240, gEnBomjimb_D_80C03250, gEnBomjimb_D_80C03250, gEnBomjimb_D_80C03250, gEnBomjimb_D_80C03250, @@ -907,18 +907,18 @@ void EnBomjimb_Draw(Actor* thisx, GlobalContext* globalCtx) { }; EnBomjimb* this = THIS; - OPEN_DISPS(globalCtx->state.gfxCtx); + OPEN_DISPS(play->state.gfxCtx); - func_8012C28C(globalCtx->state.gfxCtx); - func_8012C2DC(globalCtx->state.gfxCtx); + func_8012C28C(play->state.gfxCtx); + func_8012C2DC(play->state.gfxCtx); gSPSegment(POLY_OPA_DISP++, 0x08, Lib_SegmentedToVirtual(D_80C03274[this->unk_2C2])); gSPSegment(POLY_OPA_DISP++, 0x09, Lib_SegmentedToVirtual(D_80C03280[this->unk_2C8])); gSPSegment(POLY_OPA_DISP++, 0x0A, Lib_SegmentedToVirtual(D_80C03260[this->unk_2C8])); - Scene_SetRenderModeXlu(globalCtx, 0, 1); - SkelAnime_DrawFlexOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, + Scene_SetRenderModeXlu(play, 0, 1); + SkelAnime_DrawFlexOpa(play, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, EnBomjimb_OverrideLimbDraw, NULL, &this->actor); - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->state.gfxCtx); } diff --git a/src/overlays/actors/ovl_En_Bomjimb/z_en_bomjimb.h b/src/overlays/actors/ovl_En_Bomjimb/z_en_bomjimb.h index 7a961461c..8b73ef972 100644 --- a/src/overlays/actors/ovl_En_Bomjimb/z_en_bomjimb.h +++ b/src/overlays/actors/ovl_En_Bomjimb/z_en_bomjimb.h @@ -5,7 +5,7 @@ struct EnBomjimb; -typedef void (*EnBomjimbActionFunc)(struct EnBomjimb*, GlobalContext*); +typedef void (*EnBomjimbActionFunc)(struct EnBomjimb*, PlayState*); #define ENBOMJIMB_GET_F(thisx) ((thisx)->params & 0xF) #define ENBOMJIMB_GET_F0(thisx) (((thisx)->params >> 4) & 0xF) 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 930b1b597..df4adfc20 100644 --- a/src/overlays/actors/ovl_En_Boom/z_en_boom.c +++ b/src/overlays/actors/ovl_En_Boom/z_en_boom.c @@ -5,21 +5,20 @@ */ #include "z_en_boom.h" +#include "objects/gameplay_keep/gameplay_keep.h" #define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_20) #define THIS ((EnBoom*)thisx) -void EnBoom_Init(Actor* thisx, GlobalContext* globalCtx); -void EnBoom_Destroy(Actor* thisx, GlobalContext* globalCtx); -void EnBoom_Update(Actor* thisx, GlobalContext* globalCtx); -void EnBoom_Draw(Actor* thisx, GlobalContext* globalCtx); - -void func_808A2918(EnBoom* this, GlobalContext* globalCtx); +void EnBoom_Init(Actor* thisx, PlayState* play); +void EnBoom_Destroy(Actor* thisx, PlayState* play); +void EnBoom_Update(Actor* thisx, PlayState* play); +void EnBoom_Draw(Actor* thisx, PlayState* play); void EnBoom_SetupAction(EnBoom* this, EnBoomActionFunc actionFunc); +void func_808A2918(EnBoom* this, PlayState* play); -#if 0 const ActorInit En_Boom_InitVars = { ACTOR_EN_BOOM, ACTORCAT_ITEMACTION, @@ -32,34 +31,314 @@ 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, PlayState* play) { + 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(play, &play->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(play, &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(play, &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(play, &sp34, 100, 500, 0); + EffectSsGRipple_Spawn(play, &sp34, 100, 500, 4); + EffectSsGRipple_Spawn(play, &sp34, 100, 500, 8); + } + + this->actor.bgCheckFlags |= 0x40; +} + +void EnBoom_Init(Actor* thisx, PlayState* play) { + 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(play, &this->effectIndex, 1, 0, 0, &sp30); + + Collider_InitQuad(play, &this->collider); + Collider_SetQuad(play, &this->collider, &this->actor, &sQuadInit); + EnBoom_SetupAction(this, func_808A2918); +} + +void EnBoom_Destroy(Actor* thisx, PlayState* play) { + EnBoom* this = THIS; + Player* player = GET_PLAYER(play); + Actor* temp; + + if (player != NULL) { + Effect_Destroy(play, this->effectIndex); + Collider_DestroyQuad(play, &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, PlayState* play) { + Actor* sp7C; + Player* player = GET_PLAYER(play); + 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, play); + 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(&play->colCtx, &this->actor.prevPos, &this->actor.world.pos, &sp50, + &this->actor.wallPoly, true, true, true, true, &sp5C); + if (sp74 != 0) { + if (func_800B90AC(play, &this->actor, this->actor.wallPoly, sp5C, &sp50)) { + sp74 = 0; + } else { + CollisionCheck_SpawnShieldParticlesMetal(play, &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, PlayState* play) { + EnBoom* this = THIS; + Player* player = GET_PLAYER(play); + Actor* actor; + + if (!(player->stateFlags1 & 0x20000000)) { + this->actionFunc(this, play); + + 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, PlayState* play) { + EnBoom* this = THIS; + EnBoomStruct* sp58 = &D_808A3078[this->actor.params]; + Vec3f sp4C; + Vec3f sp40; + + OPEN_DISPS(play->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(play, &this->collider, &this->weaponInfo, &sp4C, &sp40)) { + EffectBlure_AddVertex(Effect_GetByIndex(this->effectIndex), &sp4C, &sp40); + } + + func_8012C28C(play->state.gfxCtx); + Matrix_RotateYS(this->unk_1CD * 0x2EE0, MTXMODE_APPLY); + + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_OPA_DISP++, sp58->unk_00); + + CLOSE_DISPS(play->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..45e3618ed 100644 --- a/src/overlays/actors/ovl_En_Boom/z_en_boom.h +++ b/src/overlays/actors/ovl_En_Boom/z_en_boom.h @@ -5,12 +5,20 @@ struct EnBoom; -typedef void (*EnBoomActionFunc)(struct EnBoom*, GlobalContext*); +typedef void (*EnBoomActionFunc)(struct EnBoom*, PlayState*); typedef struct EnBoom { - /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0xAC]; - /* 0x01F0 */ EnBoomActionFunc actionFunc; + /* 0x000 */ Actor actor; + /* 0x144 */ ColliderQuad collider; + /* 0x1C4 */ Actor* player; + /* 0x1C8 */ Actor* unk_1C8; + /* 0x1CC */ u8 unk_1CC; + /* 0x1CD */ u8 unk_1CD; + /* 0x1CE */ u8 unk_1CE; + /* 0x1CF */ s8 unk_1CF; + /* 0x1D0 */ s32 effectIndex; + /* 0x1D4 */ WeaponInfo weaponInfo; + /* 0x1F0 */ EnBoomActionFunc actionFunc; } EnBoom; // size = 0x1F4 extern const ActorInit En_Boom_InitVars; diff --git a/src/overlays/actors/ovl_En_Box/z_en_box.c b/src/overlays/actors/ovl_En_Box/z_en_box.c index 7367f49bc..bfc242060 100644 --- a/src/overlays/actors/ovl_En_Box/z_en_box.c +++ b/src/overlays/actors/ovl_En_Box/z_en_box.c @@ -5,17 +5,57 @@ */ #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); -void EnBox_Destroy(Actor* thisx, GlobalContext* globalCtx); -void EnBox_Update(Actor* thisx, GlobalContext* globalCtx); -void EnBox_Draw(Actor* thisx, GlobalContext* globalCtx); +void EnBox_Init(Actor* thisx, PlayState* play); +void EnBox_Destroy(Actor* thisx, PlayState* play); +void EnBox_Update(Actor* thisx, PlayState* play); +void EnBox_Draw(Actor* thisx, PlayState* play); + +void EnBox_FallOnSwitchFlag(EnBox* this, PlayState* play); +void EnBox_AppearSwitchFlag(EnBox* this, PlayState* play); +void EnBox_AppearOnRoomClear(EnBox* this, PlayState* play); +void func_80868AFC(EnBox* this, PlayState* play); +void func_80868B74(EnBox* this, PlayState* play); +void EnBox_WaitOpen(EnBox* this, PlayState* play); +void EnBox_Open(EnBox* this, PlayState* play); + +void func_80867FBC(func_80867BDC_a0* arg0, PlayState* play, s32 arg2); +void func_80867FE4(func_80867BDC_a0* arg0, PlayState* play); -#if 0 const ActorInit En_Box_InitVars = { ACTOR_EN_BOX, ACTORCAT_CHEST, @@ -28,66 +68,653 @@ 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, PlayState* play, 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, PlayState* play) { + 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, play); + } + } + arg0->unk_14++; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Box/func_80867C8C.s") +void func_80867C8C(func_80867BDC_a0* arg0, PlayState* play) { + 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(play->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(play->state.gfxCtx); + Matrix_Mult(&play->billboardMtxF, MTXMODE_APPLY); + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(play->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(play->state.gfxCtx); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Box/func_8086800C.s") +void func_80867FBC(func_80867BDC_a0* arg0, PlayState* play, 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, PlayState* play) { + arg0->unk_0C = NULL; + arg0->unk_10 = NULL; + func_80867BDC(arg0, play, &arg0->pos); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Box/EnBox_Destroy.s") +void EnBox_ClipToGround(EnBox* this, PlayState* play) { + 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(&play->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, PlayState* play) { + 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(play, &play->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(play, &play->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->getItemId = ENBOX_GET_ITEM(thisx); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Box/func_808689E8.s") + if (Flags_GetTreasure(play, ENBOX_GET_CHEST_FLAG(&this->dyna.actor)) || this->getItemId == 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(play, this->switchFlag)) { + func_800C62BC(play, &play->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(play, this->dyna.actor.room)) { + EnBox_SetupAction(this, EnBox_AppearOnRoomClear); + func_800C62BC(play, &play->colCtx.dyna, this->dyna.bgId); + if (this->movementFlags & ENBOX_MOVE_0x80) { + this->dyna.actor.world.pos.y = this->dyna.actor.home.pos.y + 50.0f; + } else { + 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(play, this->switchFlag)) { + EnBox_SetupAction(this, EnBox_AppearSwitchFlag); + func_800C62BC(play, &play->colCtx.dyna, this->dyna.bgId); + if (this->movementFlags & ENBOX_MOVE_0x80) { + this->dyna.actor.world.pos.y = this->dyna.actor.home.pos.y + 50.0f; + } else { + 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->getItemId == GI_STRAY_FAIRY) && !Flags_GetTreasure(play, 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(play, &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, play, &this->dyna.actor.home.pos); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Box/EnBox_Update.s") +void EnBox_Destroy(Actor* thisx, PlayState* play) { + EnBox* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Box/func_80869600.s") + DynaPoly_DeleteBgActor(play, &play->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, PlayState* play) { + s32 i; + Vec3f pos; + Vec3f velocity; + Vec3f accel; + + for (i = 0; i < 20; i++) { + EnBox_RandomDustKinematic(this, &pos, &velocity, &accel); + func_800B1280(play, &pos, &velocity, &accel, 100, 30, 15); + } +} + +void EnBox_Fall(EnBox* this, PlayState* play) { + 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, play); + } + 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, PlayState* play) { + func_800B8C50(&this->dyna.actor, play); + if (this->unk_1A0 >= 0) { + EnBox_SetupAction(this, EnBox_Fall); + func_800C6314(play, &play->colCtx.dyna, this->dyna.bgId); + } else if (this->unk_1A0 >= -11) { + this->unk_1A0++; + } else if (Flags_GetSwitch(play, this->switchFlag)) { + this->unk_1A0++; + } +} + +void EnBox_AppearSwitchFlag(EnBox* this, PlayState* play) { + func_800B8C50(&this->dyna.actor, play); + if (Flags_GetSwitch(play, 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, PlayState* play) { + func_800B8C50(&this->dyna.actor, play); + if (Flags_GetClearTemp(play, this->dyna.actor.room)) { + if (ActorCutscene_GetCanPlayNext(this->cutsceneIdxA)) { + ActorCutscene_StartAndSetUnkLinkFields(this->cutsceneIdxA, &this->dyna.actor); + Flags_SetClear(play, this->dyna.actor.room); + EnBox_SetupAction(this, func_80868AFC); + this->unk_1A0 = -30; + } else { + ActorCutscene_SetIntentToPlay(this->cutsceneIdxA); + } + } +} + +void func_80868AFC(EnBox* this, PlayState* play) { + 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, play, (this->movementFlags & ENBOX_MOVE_0x80) != 0); + Audio_PlaySfxAtPos(&this->dyna.actor.projectedPos, NA_SE_EV_TRE_BOX_APPEAR); + } +} + +void func_80868B74(EnBox* this, PlayState* play) { + func_800C6314(play, &play->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(play, &this->dyna.actor, 4); + } else if (this->unk_1A0 == 22) { + func_800B724C(play, &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, PlayState* play) { + 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(&play->actorCtx, &this->dyna.actor, play, 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->getItemId == GI_STRAY_FAIRY) { + this->movementFlags |= ENBOX_MOVE_0x20; + } else { + if ((this->getItemId == GI_HEART_PIECE) || (this->getItemId == GI_BOTTLE)) { + Flags_SetCollectible(play, this->collectableFlag); + } + Flags_SetTreasure(play, ENBOX_GET_CHEST_FLAG(&this->dyna.actor)); + } + } else { + player = GET_PLAYER(play); + 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, play)) { + if (((this->getItemId == GI_HEART_PIECE) || (this->getItemId == GI_BOTTLE)) && + Flags_GetCollectible(play, this->collectableFlag)) { + this->getItemId = GI_RECOVERY_HEART; + } + if ((this->getItemId == GI_MASK_CAPTAIN) && (INV_CONTENT(ITEM_MASK_CAPTAIN) == ITEM_MASK_CAPTAIN)) { + this->getItemId = GI_RECOVERY_HEART; + } + if ((this->getItemId == GI_MASK_GIANT) && (INV_CONTENT(ITEM_MASK_GIANT) == ITEM_MASK_GIANT)) { + this->getItemId = GI_RECOVERY_HEART; + } + Actor_PickUpNearby(&this->dyna.actor, play, -this->getItemId); + } + if (Flags_GetTreasure(play, ENBOX_GET_CHEST_FLAG(&this->dyna.actor))) { + EnBox_SetupAction(this, EnBox_Open); + } + } +} + +void EnBox_Open(EnBox* this, PlayState* play) { + 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(&play->actorCtx, &this->dyna.actor, play, 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, + STRAY_FAIRY_PARAMS(ENBOX_GET_CHEST_FLAG(&this->dyna.actor), 0, 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(play, &play->colCtx, this->dyna.actor.world.pos.x, this->dyna.actor.world.pos.z, + &waterSurface, &waterBox, &bgId) && + (this->dyna.actor.floorHeight < waterSurface)) { + EffectSsBubble_Spawn(play, &this->dyna.actor.world.pos, 5.0f, 2.0f, 20.0f, 0.3f); + } + } +} + +void EnBox_SpawnIceSmoke(EnBox* this, PlayState* play) { + 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(play, &pos, &velocity, &accel, 150); + } +} + +void EnBox_Update(Actor* thisx, PlayState* play) { + EnBox* this = THIS; + + if (this->movementFlags & ENBOX_MOVE_STICK_TO_GROUND) { + this->movementFlags &= ~ENBOX_MOVE_STICK_TO_GROUND; + EnBox_ClipToGround(this, play); + } + if ((this->getItemId == GI_STRAY_FAIRY) && !Flags_GetTreasure(play, ENBOX_GET_CHEST_FLAG(&this->dyna.actor))) { + play->actorCtx.unk5 |= 8; + } + this->actionFunc(this, play); + if (this->movementFlags & ENBOX_MOVE_0x80) { + this->movementFlags |= ENBOX_MOVE_IMMOBILE; + } + if (!(this->movementFlags & ENBOX_MOVE_IMMOBILE)) { + Actor_MoveWithGravity(&this->dyna.actor); + Actor_UpdateBgCheckInfo(play, &this->dyna.actor, 0.0f, 0.0f, 0.0f, 0x1C); + } + Actor_SetFocus(&this->dyna.actor, 40.0f); + if ((this->getItemId == GI_ICE_TRAP) && (this->actionFunc == EnBox_Open) && (this->skelAnime.curFrame > 45.0f) && + (this->iceSmokeTimer < 100)) { + EnBox_SpawnIceSmoke(this, play); + } + if (this->unk_1F4.unk_0C != NULL) { + this->unk_1F4.unk_0C(&this->unk_1F4, play); + } +} + +void EnBox_PostLimbDraw(PlayState* play, 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(play->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->getItemId == 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(play->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->getItemId == 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, PlayState* play) { + s32 pad; + EnBox* this = THIS; + + OPEN_DISPS(play->state.gfxCtx); + if (this->unk_1F4.unk_10 != NULL) { + this->unk_1F4.unk_10(&this->unk_1F4, play); + } + if (((this->alpha == 255) && (this->type != ENBOX_TYPE_BIG_INVISIBLE) && + (this->type != ENBOX_TYPE_SMALL_INVISIBLE)) || + (!CHECK_FLAG_ALL(this->dyna.actor.flags, ACTOR_FLAG_80) && + ((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(play->state.gfxCtx)); + func_8012C28C(play->state.gfxCtx); + POLY_OPA_DISP = SkelAnime_Draw(play, 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(play->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(play->state.gfxCtx)); + } else { + gSPSegment(POLY_XLU_DISP++, 0x08, EnBox_SetRenderMode2(play->state.gfxCtx)); + } + POLY_XLU_DISP = SkelAnime_Draw(play, this->skelAnime.skeleton, this->skelAnime.jointTable, NULL, + EnBox_PostLimbDraw, &this->dyna.actor, POLY_XLU_DISP); + } + CLOSE_DISPS(play->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..cd164c924 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 (*EnBoxActionFunc)(struct EnBox*, PlayState*); +typedef void (*EnBoxUnkFunc)(struct func_80867BDC_a0* arg0, PlayState* play); + +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]; + /* 0x000 */ DynaPolyActor dyna; + /* 0x15C */ SkelAnime skelAnime; + /* 0x1A0 */ s32 unk_1A0; + /* 0x1A4 */ UNK_TYPE1 unk_1A4[0x04]; + /* 0x1A8 */ f32 unk_1A8; + /* 0x1AC */ EnBoxActionFunc actionFunc; + /* 0x1B0 */ Vec3s jointTable[OBJECT_BOX_CHEST_LIMB_MAX]; + /* 0x1CE */ Vec3s morphTable[OBJECT_BOX_CHEST_LIMB_MAX]; + /* 0x1EC */ s16 unk_1EC; + /* 0x1EE */ u8 movementFlags; + /* 0x1EF */ u8 alpha; + /* 0x1F0 */ u8 switchFlag; + /* 0x1F1 */ u8 type; + /* 0x1F2 */ u8 iceSmokeTimer; + /* 0x1F3 */ s8 unk_1F3; + /* 0x1F4 */ func_80867BDC_a0 unk_1F4; + /* 0x218 */ s16 cutsceneIdxA; + /* 0x21A */ s16 cutsceneIdxB; + /* 0x21C */ s32 getItemId; + /* 0x220 */ 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 e80004a92..5a3ce9cf8 100644 --- a/src/overlays/actors/ovl_En_Bsb/z_en_bsb.c +++ b/src/overlays/actors/ovl_En_Bsb/z_en_bsb.c @@ -5,35 +5,36 @@ */ #include "z_en_bsb.h" +#include "z64rumble.h" #define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_4 | ACTOR_FLAG_10 | ACTOR_FLAG_20 | ACTOR_FLAG_2000000) #define THIS ((EnBsb*)thisx) -void EnBsb_Init(Actor* thisx, GlobalContext* globalCtx); -void EnBsb_Destroy(Actor* thisx, GlobalContext* globalCtx); -void EnBsb_Update(Actor* thisx, GlobalContext* globalCtx); -void EnBsb_Draw(Actor* thisx, GlobalContext* globalCtx); +void EnBsb_Init(Actor* thisx, PlayState* play); +void EnBsb_Destroy(Actor* thisx, PlayState* play); +void EnBsb_Update(Actor* thisx, PlayState* play); +void EnBsb_Draw(Actor* thisx, PlayState* play); -void func_80C0BFE8(EnBsb* this, GlobalContext* globalCtx); -void func_80C0C238(EnBsb* this, GlobalContext* globalCtx); -void func_80C0C364(EnBsb* this, GlobalContext* globalCtx); -void func_80C0C484(EnBsb* this, GlobalContext* globalCtx); -void func_80C0C6A8(EnBsb* this, GlobalContext* globalCtx); -void func_80C0C8EC(EnBsb* this, GlobalContext* globalCtx); -void func_80C0CB3C(EnBsb* this, GlobalContext* globalCtx); -void func_80C0CD04(EnBsb* this, GlobalContext* globalCtx); -void func_80C0CDE4(EnBsb* this, GlobalContext* globalCtx); -void func_80C0CFDC(EnBsb* this, GlobalContext* globalCtx); -void func_80C0D10C(EnBsb* this, GlobalContext* globalCtx); -void func_80C0D27C(EnBsb* this, GlobalContext* globalCtx); -void func_80C0D384(EnBsb* this, GlobalContext* globalCtx); -void func_80C0D51C(EnBsb* this, GlobalContext* globalCtx); -void func_80C0D9B4(EnBsb* this, GlobalContext* globalCtx); -void func_80C0DB18(EnBsb* this, GlobalContext* globalCtx); -void func_80C0E1C0(EnBsb* this, GlobalContext* globalCtx); -void func_80C0E480(EnBsb* this, GlobalContext* globalCtx); -void func_80C0E4FC(EnBsb* this, GlobalContext* globalCtx); +void func_80C0BFE8(EnBsb* this, PlayState* play); +void func_80C0C238(EnBsb* this, PlayState* play); +void func_80C0C364(EnBsb* this, PlayState* play); +void func_80C0C484(EnBsb* this, PlayState* play); +void func_80C0C6A8(EnBsb* this, PlayState* play); +void func_80C0C8EC(EnBsb* this, PlayState* play); +void func_80C0CB3C(EnBsb* this, PlayState* play); +void func_80C0CD04(EnBsb* this, PlayState* play); +void func_80C0CDE4(EnBsb* this, PlayState* play); +void func_80C0CFDC(EnBsb* this, PlayState* play); +void func_80C0D10C(EnBsb* this, PlayState* play); +void func_80C0D27C(EnBsb* this, PlayState* play); +void func_80C0D384(EnBsb* this, PlayState* play); +void func_80C0D51C(EnBsb* this, PlayState* play); +void func_80C0D9B4(EnBsb* this, PlayState* play); +void func_80C0DB18(EnBsb* this, PlayState* play); +void func_80C0E1C0(EnBsb* this, PlayState* play); +void func_80C0E480(EnBsb* this, PlayState* play); +void func_80C0E4FC(EnBsb* this, PlayState* play); #if 0 // static ColliderJntSphElementInit sJntSphElementsInit[7] = { @@ -71,7 +72,7 @@ static ColliderJntSphElementInit D_80C0F8D4[7] = { // static ColliderJntSphInit sJntSphInit = { static ColliderJntSphInit D_80C0F9D0 = { { COLTYPE_HIT6, AT_ON | AT_TYPE_ENEMY, AC_ON | AC_TYPE_PLAYER, OC1_ON | OC1_TYPE_PLAYER, OC2_TYPE_1, COLSHAPE_JNTSPH, }, - 7, D_80C0F8D4, // sJntSphElementsInit, + ARRAY_COUNT(sJntSphElementsInit), D_80C0F8D4, // sJntSphElementsInit, }; // static DamageTable sDamageTable = { diff --git a/src/overlays/actors/ovl_En_Bsb/z_en_bsb.h b/src/overlays/actors/ovl_En_Bsb/z_en_bsb.h index c05fbedc8..38ec4078f 100644 --- a/src/overlays/actors/ovl_En_Bsb/z_en_bsb.h +++ b/src/overlays/actors/ovl_En_Bsb/z_en_bsb.h @@ -5,7 +5,7 @@ struct EnBsb; -typedef void (*EnBsbActionFunc)(struct EnBsb*, GlobalContext*); +typedef void (*EnBsbActionFunc)(struct EnBsb*, PlayState*); typedef struct EnBsb { /* 0x0000 */ Actor actor; 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 937759ff6..fb8c119da 100644 --- a/src/overlays/actors/ovl_En_Bu/z_en_bu.c +++ b/src/overlays/actors/ovl_En_Bu/z_en_bu.c @@ -10,12 +10,12 @@ #define THIS ((EnBu*)thisx) -void EnBu_Init(Actor* thisx, GlobalContext* globalCtx); -void EnBu_Destroy(Actor* thisx, GlobalContext* globalCtx); -void EnBu_Update(Actor* thisx, GlobalContext* globalCtx); -void EnBu_Draw(Actor* thisx, GlobalContext* globalCtx); +void EnBu_Init(Actor* thisx, PlayState* play); +void EnBu_Destroy(Actor* thisx, PlayState* play); +void EnBu_Update(Actor* thisx, PlayState* play); +void EnBu_Draw(Actor* thisx, PlayState* play); -void EnBu_DoNothing(EnBu* this, GlobalContext* globalCtx); +void EnBu_DoNothing(EnBu* this, PlayState* play); const ActorInit En_Bu_InitVars = { ACTOR_EN_BU, @@ -29,37 +29,37 @@ const ActorInit En_Bu_InitVars = { (ActorFunc)EnBu_Draw, }; -void EnBu_Init(Actor* thisx, GlobalContext* globalCtx) { +void EnBu_Init(Actor* thisx, PlayState* play) { EnBu* this = THIS; this->actionFunc = EnBu_DoNothing; } -void EnBu_Destroy(Actor* thisx, GlobalContext* globalCtx) { +void EnBu_Destroy(Actor* thisx, PlayState* play) { } -void EnBu_DoNothing(EnBu* this, GlobalContext* globalCtx) { +void EnBu_DoNothing(EnBu* this, PlayState* play) { } -void EnBu_Update(Actor* thisx, GlobalContext* globalCtx) { +void EnBu_Update(Actor* thisx, PlayState* play) { EnBu* this = THIS; Actor_MoveWithGravity(&this->actor); - this->actionFunc(this, globalCtx); + this->actionFunc(this, play); } -void EnBu_Draw(Actor* thisx, GlobalContext* globalCtx) { +void EnBu_Draw(Actor* thisx, PlayState* play) { EnBu* this = THIS; - OPEN_DISPS(globalCtx->state.gfxCtx); + OPEN_DISPS(play->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); + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_OPA_DISP++, this->displayListPtr); - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->state.gfxCtx); } diff --git a/src/overlays/actors/ovl_En_Bu/z_en_bu.h b/src/overlays/actors/ovl_En_Bu/z_en_bu.h index 6200ca5a7..0f828477c 100644 --- a/src/overlays/actors/ovl_En_Bu/z_en_bu.h +++ b/src/overlays/actors/ovl_En_Bu/z_en_bu.h @@ -5,7 +5,7 @@ struct EnBu; -typedef void (*EnBuActionFunc)(struct EnBu*, GlobalContext*); +typedef void (*EnBuActionFunc)(struct EnBu*, PlayState*); typedef struct EnBu { /* 0x000 */ Actor actor; 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 0f54995be..3030041ca 100644 --- a/src/overlays/actors/ovl_En_Bubble/z_en_bubble.c +++ b/src/overlays/actors/ovl_En_Bubble/z_en_bubble.c @@ -10,14 +10,14 @@ #define THIS ((EnBubble*)thisx) -void EnBubble_Init(Actor* thisx, GlobalContext* globalCtx); -void EnBubble_Destroy(Actor* thisx, GlobalContext* globalCtx); -void EnBubble_Update(Actor* thisx, GlobalContext* globalCtx); -void EnBubble_Draw(Actor* thisx, GlobalContext* globalCtx); +void EnBubble_Init(Actor* thisx, PlayState* play); +void EnBubble_Destroy(Actor* thisx, PlayState* play); +void EnBubble_Update(Actor* thisx, PlayState* play); +void EnBubble_Draw(Actor* thisx, PlayState* play); -void func_808A029C(EnBubble* this, GlobalContext* globalCtx); -void func_808A0350(EnBubble* this, GlobalContext* globalCtx); -void func_808A03E8(EnBubble* this, GlobalContext* globalCtx); +void func_808A029C(EnBubble* this, PlayState* play); +void func_808A0350(EnBubble* this, PlayState* play); +void func_808A03E8(EnBubble* this, PlayState* play); #if 0 const ActorInit En_Bubble_InitVars = { @@ -47,7 +47,7 @@ static ColliderJntSphElementInit D_808A0700[2] = { // static ColliderJntSphInit sJntSphInit = { static ColliderJntSphInit D_808A0748 = { { COLTYPE_HIT6, AT_ON | AT_TYPE_ENEMY, AC_ON | AC_TYPE_PLAYER, OC1_ON | OC1_TYPE_ALL, OC2_TYPE_1, COLSHAPE_JNTSPH, }, - 2, D_808A0700, // sJntSphElementsInit, + ARRAY_COUNT(sJntSphElementsInit), D_808A0700, // sJntSphElementsInit, }; // sColChkInfoInit diff --git a/src/overlays/actors/ovl_En_Bubble/z_en_bubble.h b/src/overlays/actors/ovl_En_Bubble/z_en_bubble.h index f2901b324..2217b86b1 100644 --- a/src/overlays/actors/ovl_En_Bubble/z_en_bubble.h +++ b/src/overlays/actors/ovl_En_Bubble/z_en_bubble.h @@ -5,12 +5,12 @@ struct EnBubble; -typedef void (*EnBubbleActionFunc)(struct EnBubble*, GlobalContext*); +typedef void (*EnBubbleActionFunc)(struct EnBubble*, PlayState*); typedef struct EnBubble { - /* 0x0000 */ Actor actor; - /* 0x0144 */ EnBubbleActionFunc actionFunc; - /* 0x0148 */ char unk_148[0x110]; + /* 0x000 */ Actor actor; + /* 0x144 */ EnBubbleActionFunc actionFunc; + /* 0x148 */ char unk_148[0x110]; } EnBubble; // size = 0x258 extern const ActorInit En_Bubble_InitVars; diff --git a/src/overlays/actors/ovl_En_Butte/z_en_butte.c b/src/overlays/actors/ovl_En_Butte/z_en_butte.c index ea70a1480..93bc67792 100644 --- a/src/overlays/actors/ovl_En_Butte/z_en_butte.c +++ b/src/overlays/actors/ovl_En_Butte/z_en_butte.c @@ -12,19 +12,19 @@ #define THIS ((EnButte*)thisx) -void EnButte_Init(Actor* thisx, GlobalContext* globalCtx); -void EnButte_Destroy(Actor* thisx, GlobalContext* globalCtx); -void EnButte_Update(Actor* thisx, GlobalContext* globalCtx); -void EnButte_Draw(Actor* thisx, GlobalContext* globalCtx); +void EnButte_Init(Actor* thisx, PlayState* play); +void EnButte_Destroy(Actor* thisx, PlayState* play2); +void EnButte_Update(Actor* thisx, PlayState* play); +void EnButte_Draw(Actor* thisx, PlayState* play); void func_8091C748(EnButte* this); -void func_8091C794(EnButte* this, GlobalContext* globalCtx); +void func_8091C794(EnButte* this, PlayState* play); void func_8091CB68(EnButte* this); -void func_8091CBB4(EnButte* this, GlobalContext* globalCtx); +void func_8091CBB4(EnButte* this, PlayState* play); void func_8091CF64(EnButte* this); -void func_8091CFB4(EnButte* this, GlobalContext* globalCtx); +void func_8091CFB4(EnButte* this, PlayState* play); void func_8091D070(EnButte* this); -void func_8091D090(EnButte* this, GlobalContext* globalCtx); +void func_8091D090(EnButte* this, PlayState* play); static ColliderJntSphElementInit sJntSphElementsInit[1] = { { @@ -49,7 +49,7 @@ static ColliderJntSphInit sJntSphInit = { OC2_TYPE_1, COLSHAPE_JNTSPH, }, - 1, + ARRAY_COUNT(sJntSphElementsInit), sJntSphElementsInit, }; @@ -132,35 +132,35 @@ void func_8091C140(void) { D_8091D3A0 += 0xFA0; } -void func_8091C178(EnButte* this, GlobalContext* globalCtx) { +void func_8091C178(EnButte* this, PlayState* play) { Vec3f sp4C; s32 sp48; Vec3s sp40; - OPEN_DISPS(globalCtx->state.gfxCtx); + OPEN_DISPS(play->state.gfxCtx); - func_8012C240(globalCtx->state.gfxCtx); + func_8012C240(play->state.gfxCtx); sp48 = Math_SinS(D_8091D3A0) * 250.0f; sp48 = CLAMP(sp48, 0, 255); - func_800DFC90(&sp40, GET_ACTIVE_CAM(globalCtx)); - Matrix_RotateY(sp40.y, MTXMODE_NEW); - Matrix_InsertXRotation_s(sp40.x, MTXMODE_APPLY); - Matrix_InsertZRotation_s(sp40.z, MTXMODE_APPLY); - Matrix_MultiplyVector3fByState(&D_8091D3A4, &sp4C); - Matrix_SetStateRotationAndTranslation(this->actor.focus.pos.x + sp4C.x, this->actor.focus.pos.y + sp4C.y, - this->actor.focus.pos.z + sp4C.z, &sp40); + Camera_GetCamDir(&sp40, GET_ACTIVE_CAM(play)); + Matrix_RotateYS(sp40.y, MTXMODE_NEW); + Matrix_RotateXS(sp40.x, MTXMODE_APPLY); + Matrix_RotateZS(sp40.z, MTXMODE_APPLY); + 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); - gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gDPSetPrimColor(POLY_XLU_DISP++, 0x80, 0x80, 200, 200, 180, sp48); gDPSetEnvColor(POLY_XLU_DISP++, 200, 200, 210, 255); gSPDisplayList(POLY_XLU_DISP++, gOwlStatueWhiteFlashDL); - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->state.gfxCtx); } -void EnButte_Init(Actor* thisx, GlobalContext* globalCtx) { +void EnButte_Init(Actor* thisx, PlayState* play) { s32 pad; EnButte* this = THIS; @@ -177,10 +177,10 @@ void EnButte_Init(Actor* thisx, GlobalContext* globalCtx) { this->actor.uncullZoneScale = 200.0f; } - SkelAnime_Init(globalCtx, &this->skelAnime, &gameplay_field_keep_Skel_002FA0, &gameplay_field_keep_Anim_001D20, + SkelAnime_Init(play, &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); + Collider_InitJntSph(play, &this->collider); + Collider_SetJntSph(play, &this->collider, &this->actor, &sJntSphInit, this->colldierElements); this->collider.elements[0].dim.worldSphere.radius = this->collider.elements[0].dim.scale * this->collider.elements[0].dim.modelSphere.radius; @@ -190,14 +190,17 @@ void EnButte_Init(Actor* thisx, GlobalContext* globalCtx) { this->unk_256 = Rand_ZeroOne() * 0xFFFF; this->unk_258 = Rand_ZeroOne() * 0xFFFF; - Animation_Change(&this->skelAnime, &gameplay_field_keep_Anim_001D20, 1.0f, 0.0f, 0.0f, 1, 0.0f); + Animation_Change(&this->skelAnime, &gameplay_field_keep_Anim_001D20, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP_INTERP, 0.0f); func_8091C748(this); this->actor.shape.rot.x -= 0x2320; this->unk_250 = 1; } -void EnButte_Destroy(Actor* thisx, GlobalContext* globalCtx) { - Collider_DestroyJntSph(globalCtx, &THIS->collider); +void EnButte_Destroy(Actor* thisx, PlayState* play2) { + PlayState* play = play2; + EnButte* this = THIS; + + Collider_DestroyJntSph(play, &this->collider); } void func_8091C524(EnButte* this) { @@ -225,10 +228,10 @@ void func_8091C748(EnButte* this) { this->actionFunc = func_8091C794; } -void func_8091C794(EnButte* this, GlobalContext* globalCtx) { +void func_8091C794(EnButte* this, PlayState* play) { EnButteStruct* sp4C = &D_8091D324[this->unk_24E]; f32 distSq; - Player* player = GET_PLAYER(globalCtx); + Player* player = GET_PLAYER(play); 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; @@ -302,9 +305,9 @@ void func_8091CB68(EnButte* this) { this->actionFunc = func_8091CBB4; } -void func_8091CBB4(EnButte* this, GlobalContext* globalCtx) { +void func_8091CBB4(EnButte* this, PlayState* play) { EnButteStruct* sp5C = &D_8091D360[this->unk_24E]; - Player* player = GET_PLAYER(globalCtx); + Player* player = GET_PLAYER(play); f32 playSpeed; Vec3f sp48; f32 distSq; @@ -318,13 +321,13 @@ void func_8091CBB4(EnButte* this, GlobalContext* globalCtx) { sp40 = 0.0f; if ((this->unk_24E != 0) && (this->unk_24C < 12)) { - sp48.x = player->swordInfo[0].tip.x + (Math_SinS(player->actor.shape.rot.y) * 10.0f); - sp48.y = player->swordInfo[0].tip.y; - sp48.z = player->swordInfo[0].tip.z + (Math_CosS(player->actor.shape.rot.y) * 10.0f); + sp48.x = player->meleeWeaponInfo[0].tip.x + (Math_SinS(player->actor.shape.rot.y) * 10.0f); + sp48.y = player->meleeWeaponInfo[0].tip.y; + sp48.z = player->meleeWeaponInfo[0].tip.z + (Math_CosS(player->actor.shape.rot.y) * 10.0f); yaw = Math_Vec3f_Yaw(&this->actor.world.pos, &sp48); if (Math_ScaledStepToS(&this->actor.world.rot.y, yaw + (s32)(Rand_ZeroOne() * D_8091D3F0), 0x7D0)) { - if ((globalCtx->gameplayFrames & 0x30) == 0x30) { + if ((play->gameplayFrames & 0x30) == 0x30) { this->actor.world.rot.y += (s16)(Math_SinS(this->unk_254) * 60.0f); } } else { @@ -332,10 +335,10 @@ void func_8091CBB4(EnButte* this, GlobalContext* globalCtx) { } } - if (player->swordInfo[0].tip.y < player->actor.world.pos.y + 30.0f) { + if (player->meleeWeaponInfo[0].tip.y < player->actor.world.pos.y + 30.0f) { this->unk_25C = player->actor.world.pos.y + 30.0f; } else { - this->unk_25C = player->swordInfo[0].tip.y; + this->unk_25C = player->meleeWeaponInfo[0].tip.y; } func_8091C6B4(this); @@ -356,7 +359,7 @@ void func_8091CBB4(EnButte* this, GlobalContext* globalCtx) { !(distSq < SQ(320.0f))) { func_8091C748(this); } else if ((distSq > SQ(240.0f)) && - (Math3D_XZDistanceSquared(player->swordInfo[0].tip.x, player->swordInfo[0].tip.z, + (Math3D_XZDistanceSquared(player->meleeWeaponInfo[0].tip.x, player->meleeWeaponInfo[0].tip.z, this->actor.world.pos.x, this->actor.world.pos.z) < SQ(60.0f))) { func_8091CF64(this); } @@ -370,14 +373,14 @@ void func_8091CF64(EnButte* this) { this->actionFunc = func_8091CFB4; } -void func_8091CFB4(EnButte* this, GlobalContext* globalCtx) { +void func_8091CFB4(EnButte* this, PlayState* play) { 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); + SoundSource_PlaySfxAtFixedWorldPos(play, &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, + Actor_Spawn(&play->actorCtx, play, 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) { @@ -391,13 +394,13 @@ void func_8091D070(EnButte* this) { this->actor.draw = NULL; } -void func_8091D090(EnButte* this, GlobalContext* globalCtx) { +void func_8091D090(EnButte* this, PlayState* play) { if (this->unk_24C <= 0) { Actor_MarkForDeath(&this->actor); } } -void EnButte_Update(Actor* thisx, GlobalContext* globalCtx) { +void EnButte_Update(Actor* thisx, PlayState* play) { EnButte* this = THIS; if ((this->actor.child != NULL) && (this->actor.child->update == NULL) && (&this->actor != this->actor.child)) { @@ -413,7 +416,7 @@ void EnButte_Update(Actor* thisx, GlobalContext* globalCtx) { this->unk_258 += 0x600; if (ENBUTTE_GET_1(&this->actor) == ENBUTTE_1) { - if (GET_PLAYER(globalCtx)->swordState == 0) { + if (GET_PLAYER(play)->meleeWeaponState == 0) { if (this->unk_252 > 0) { this->unk_252--; } @@ -422,7 +425,7 @@ void EnButte_Update(Actor* thisx, GlobalContext* globalCtx) { } } - this->actionFunc(this, globalCtx); + this->actionFunc(this, play); if (this->actor.update != NULL) { Actor_MoveWithGravity(&this->actor); @@ -433,21 +436,21 @@ void EnButte_Update(Actor* thisx, GlobalContext* globalCtx) { 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); + CollisionCheck_SetOC(play, &play->colChkCtx, &this->collider.base); } Actor_SetFocus(&this->actor, this->actor.shape.yOffset * this->actor.scale.y); } } -void EnButte_Draw(Actor* thisx, GlobalContext* globalCtx) { +void EnButte_Draw(Actor* thisx, PlayState* play) { 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); + func_8012C28C(play->state.gfxCtx); + SkelAnime_DrawOpa(play, 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); + func_8091C178(this, play); } } 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 361096961..2d7a6a0bc 100644 --- a/src/overlays/actors/ovl_En_Butte/z_en_butte.h +++ b/src/overlays/actors/ovl_En_Butte/z_en_butte.h @@ -5,7 +5,7 @@ struct EnButte; -typedef void (*EnButteActionFunc)(struct EnButte*, GlobalContext*); +typedef void (*EnButteActionFunc)(struct EnButte*, PlayState*); #define ENBUTTE_GET(thisx) ((thisx)->params) #define ENBUTTE_GET_1(thisx) ((thisx)->params & 1) @@ -15,22 +15,22 @@ typedef void (*EnButteActionFunc)(struct EnButte*, GlobalContext*); #define ENBUTTE_1 1 typedef struct EnButte { - /* 0x0000 */ Actor actor; - /* 0x0144 */ ColliderJntSph collider; - /* 0x0164 */ ColliderJntSphElement colldierElements[1]; - /* 0x01A4 */ SkelAnime skelAnime; - /* 0x01E8 */ Vec3s jointTable[8]; - /* 0x0218 */ Vec3s morphTable[8]; - /* 0x0248 */ EnButteActionFunc actionFunc; - /* 0x024C */ s16 unk_24C; - /* 0x024E */ u8 unk_24E; - /* 0x024F */ u8 unk_24F; - /* 0x0250 */ u8 unk_250; - /* 0x0252 */ s16 unk_252; - /* 0x0254 */ s16 unk_254; - /* 0x0256 */ s16 unk_256; - /* 0x0258 */ s16 unk_258; - /* 0x025C */ f32 unk_25C; + /* 0x000 */ Actor actor; + /* 0x144 */ ColliderJntSph collider; + /* 0x164 */ ColliderJntSphElement colldierElements[1]; + /* 0x1A4 */ SkelAnime skelAnime; + /* 0x1E8 */ Vec3s jointTable[8]; + /* 0x218 */ Vec3s morphTable[8]; + /* 0x248 */ EnButteActionFunc actionFunc; + /* 0x24C */ s16 unk_24C; + /* 0x24E */ u8 unk_24E; + /* 0x24F */ u8 unk_24F; + /* 0x250 */ u8 unk_250; + /* 0x252 */ s16 unk_252; + /* 0x254 */ s16 unk_254; + /* 0x256 */ s16 unk_256; + /* 0x258 */ s16 unk_258; + /* 0x25C */ f32 unk_25C; } EnButte; // size = 0x260 extern const ActorInit En_Butte_InitVars; diff --git a/src/overlays/actors/ovl_En_Cha/z_en_cha.c b/src/overlays/actors/ovl_En_Cha/z_en_cha.c index 0f340da3a..b53f5f620 100644 --- a/src/overlays/actors/ovl_En_Cha/z_en_cha.c +++ b/src/overlays/actors/ovl_En_Cha/z_en_cha.c @@ -11,12 +11,12 @@ #define THIS ((EnCha*)thisx) -void EnCha_Init(Actor* thisx, GlobalContext* globalCtx); -void EnCha_Destroy(Actor* thisx, GlobalContext* globalCtx); -void EnCha_Update(Actor* thisx, GlobalContext* globalCtx); -void EnCha_Draw(Actor* thisx, GlobalContext* globalCtx); +void EnCha_Init(Actor* thisx, PlayState* play); +void EnCha_Destroy(Actor* thisx, PlayState* play); +void EnCha_Update(Actor* thisx, PlayState* play); +void EnCha_Draw(Actor* thisx, PlayState* play); -void EnCha_Idle(EnCha* this, GlobalContext* globalCtx); +void EnCha_Idle(EnCha* this, PlayState* play); const ActorInit En_Cha_InitVars = { ACTOR_EN_CHA, @@ -50,11 +50,11 @@ static ColliderCylinderInit sCylinderInit = { { 10, 40, 0, { 0, 0, 0 } }, }; -void EnCha_Init(Actor* thisx, GlobalContext* globalCtx) { +void EnCha_Init(Actor* thisx, PlayState* play) { EnCha* this = THIS; s32 pad; - Collider_InitAndSetCylinder(globalCtx, &this->collider, &this->actor, &sCylinderInit); + Collider_InitAndSetCylinder(play, &this->collider, &this->actor, &sCylinderInit); this->actor.colChkInfo.mass = MASS_IMMOVABLE; Collider_UpdateCylinder(&this->actor, &this->collider); Actor_SetScale(&this->actor, 0.01f); @@ -64,14 +64,14 @@ void EnCha_Init(Actor* thisx, GlobalContext* globalCtx) { gSaveContext.save.weekEventReg[60] &= (u8)~4; } -void EnCha_Destroy(Actor* thisx, GlobalContext* globalCtx) { +void EnCha_Destroy(Actor* thisx, PlayState* play) { EnCha* this = THIS; - Collider_DestroyCylinder(globalCtx, &this->collider); + Collider_DestroyCylinder(play, &this->collider); } -void EnCha_Ring(EnCha* this, GlobalContext* globalCtx) { - EnCha_Idle(this, globalCtx); +void EnCha_Ring(EnCha* this, PlayState* play) { + EnCha_Idle(this, play); if (this->actor.cutscene == -1) { this->actionFunc = EnCha_Idle; } else if (ActorCutscene_GetCanPlayNext(this->actor.cutscene)) { @@ -82,7 +82,7 @@ void EnCha_Ring(EnCha* this, GlobalContext* globalCtx) { } } -void EnCha_Idle(EnCha* this, GlobalContext* globalCtx) { +void EnCha_Idle(EnCha* this, PlayState* play) { if (gSaveContext.save.weekEventReg[60] & 4) { Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_DOOR_BELL); gSaveContext.save.weekEventReg[60] &= (u8)~4; @@ -101,22 +101,22 @@ void EnCha_Idle(EnCha* this, GlobalContext* globalCtx) { this->actor.home.rot.z *= 0.96f; } -void EnCha_Update(Actor* thisx, GlobalContext* globalCtx2) { - GlobalContext* globalCtx = globalCtx2; +void EnCha_Update(Actor* thisx, PlayState* play2) { + PlayState* play = play2; EnCha* this = THIS; - CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); - this->actionFunc(this, globalCtx); + CollisionCheck_SetOC(play, &play->colChkCtx, &this->collider.base); + this->actionFunc(this, play); if ((this->actor.shape.rot.z > -0x1F40) && (this->actor.shape.rot.z < 0x1F40)) { - CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + CollisionCheck_SetAC(play, &play->colChkCtx, &this->collider.base); } } -void EnCha_Draw(Actor* thisx, GlobalContext* globalCtx) { +void EnCha_Draw(Actor* thisx, PlayState* play) { 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); - Gfx_DrawDListOpa(globalCtx, object_cha_DL_000958); + Gfx_DrawDListOpa(play, object_cha_DL_000710); + Matrix_Translate(-1094.0f, 4950.0f, 9.0f, MTXMODE_APPLY); + Matrix_RotateXS(this->actor.home.rot.x, MTXMODE_APPLY); + Gfx_DrawDListOpa(play, object_cha_DL_000958); } diff --git a/src/overlays/actors/ovl_En_Cha/z_en_cha.h b/src/overlays/actors/ovl_En_Cha/z_en_cha.h index c9a292b2b..b3cfe7312 100644 --- a/src/overlays/actors/ovl_En_Cha/z_en_cha.h +++ b/src/overlays/actors/ovl_En_Cha/z_en_cha.h @@ -5,7 +5,7 @@ struct EnCha; -typedef void (*EnChaActionFunc)(struct EnCha*, struct GlobalContext*); +typedef void (*EnChaActionFunc)(struct EnCha*, struct PlayState*); typedef struct EnCha { /* 0x000 */ Actor actor; 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 cddff71cc..c457a623e 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 @@ -11,13 +11,25 @@ #define THIS ((EnClearTag*)thisx) -void EnClearTag_Init(Actor* thisx, GlobalContext* globalCtx); -void EnClearTag_Destroy(Actor* thisx, GlobalContext* globalCtx); -void EnClearTag_Update(Actor* thisx, GlobalContext* globalCtx); -void EnClearTag_Draw(Actor* thisx, GlobalContext* globalCtx); +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_UpdateEffects(EnClearTag* this, GlobalContext* globalCtx); -void EnClearTag_DrawEffects(Actor* thisx, GlobalContext* globalCtx); +void EnClearTag_Init(Actor* thisx, PlayState* play); +void EnClearTag_Destroy(Actor* thisx, PlayState* play); +void EnClearTag_Update(Actor* thisx, PlayState* play); +void EnClearTag_Draw(Actor* thisx, PlayState* play); + +void EnClearTag_UpdateEffects(EnClearTag* this, PlayState* play); +void EnClearTag_DrawEffects(Actor* thisx, PlayState* play); const ActorInit En_Clear_Tag_InitVars = { ACTOR_EN_CLEAR_TAG, @@ -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; @@ -394,14 +406,14 @@ void EnClearTag_CreateSplashEffect(EnClearTag* this, Vec3f* position, s16 effect * EnClearTag destructor. * No Operation takes place. */ -void EnClearTag_Destroy(Actor* thisx, GlobalContext* globalCtx) { +void EnClearTag_Destroy(Actor* thisx, PlayState* play) { } /** * EnClearTag constructor. * This initializes effects, and sets up ClearTag instance data. */ -void EnClearTag_Init(Actor* thisx, GlobalContext* globalCtx) { +void EnClearTag_Init(Actor* thisx, PlayState* play) { s32 pad[3]; EnClearTag* this = THIS; f32 lightRayMaxScale; @@ -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; @@ -451,7 +463,7 @@ void EnClearTag_Init(Actor* thisx, GlobalContext* globalCtx) { } // Initialize flash effect - Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 50.0f, 30.0f, 100.0f, 4); + Actor_UpdateBgCheckInfo(play, &this->actor, 50.0f, 30.0f, 100.0f, 4); pos = this->actor.world.pos; EnClearTag_CreateFlashEffect(this, &pos, sFlashMaxScale[thisx->params], this->actor.floorHeight); @@ -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; @@ -519,8 +531,8 @@ void EnClearTag_Init(Actor* thisx, GlobalContext* globalCtx) { } } -void EnClearTag_UpdateCamera(EnClearTag* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); +void EnClearTag_UpdateCamera(EnClearTag* this, PlayState* play) { + Player* player = GET_PLAYER(play); Camera* mainCam; s32 pad; @@ -544,21 +556,21 @@ void EnClearTag_UpdateCamera(EnClearTag* this, GlobalContext* globalCtx) { } break; case 1: - 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); - mainCam = Play_GetCamera(globalCtx, CAM_ID_MAIN); + Cutscene_Start(play, &play->csCtx); + this->subCamId = Play_CreateSubCamera(play); + Play_ChangeCameraStatus(play, CAM_ID_MAIN, CAM_STATUS_WAIT); + Play_ChangeCameraStatus(play, this->subCamId, CAM_STATUS_ACTIVE); + func_800B7298(play, &this->actor, 4); + mainCam = Play_GetCamera(play, 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); + Message_StartTextbox(play, 0xF, NULL); this->cameraState = 2; - func_8019FDC8(&D_801DB4A4, NA_SE_VO_NA_LISTEN, 0x20); + func_8019FDC8(&gSfxDefaultPos, NA_SE_VO_NA_LISTEN, 0x20); case 2: if (player->actor.world.pos.z > 0.0f) { player->actor.world.pos.z = 290.0f; @@ -567,23 +579,23 @@ void EnClearTag_UpdateCamera(EnClearTag* this, GlobalContext* globalCtx) { } player->actor.speedXZ = 0.0f; - if (Message_GetState(&globalCtx->msgCtx) == 0) { - mainCam = Play_GetCamera(globalCtx, CAM_ID_MAIN); + if (Message_GetState(&play->msgCtx) == TEXT_STATE_NONE) { + mainCam = Play_GetCamera(play, CAM_ID_MAIN); mainCam->eye = this->subCamEye; mainCam->eyeNext = this->subCamEye; mainCam->at = this->subCamAt; - func_80169AFC(globalCtx, this->subCamId, 0); - Cutscene_End(globalCtx, &globalCtx->csCtx); - func_800B7298(globalCtx, &this->actor, 6); + func_80169AFC(play, this->subCamId, 0); + Cutscene_End(play, &play->csCtx); + func_800B7298(play, &this->actor, 6); this->cameraState = 0; - this->subCamId = CAM_ID_MAIN; + this->subCamId = SUB_CAM_ID_DONE; this->activeTimer = 20; } break; } - if (this->subCamId != CAM_ID_MAIN) { - Play_CameraSetAtEye(globalCtx, this->subCamId, &this->subCamAt, &this->subCamEye); + if (this->subCamId != SUB_CAM_ID_DONE) { + Play_SetCameraAtEye(play, this->subCamId, &this->subCamAt, &this->subCamEye); } } @@ -591,7 +603,7 @@ void EnClearTag_UpdateCamera(EnClearTag* this, GlobalContext* globalCtx) { * EnClear_Tag update function. * Decides whether to update or to mark for death */ -void EnClearTag_Update(Actor* thisx, GlobalContext* globalCtx) { +void EnClearTag_Update(Actor* thisx, PlayState* play) { EnClearTag* this = THIS; if (this->activeTimer != 0) { @@ -599,9 +611,9 @@ void EnClearTag_Update(Actor* thisx, GlobalContext* globalCtx) { } if (this->actor.params < 0) { - EnClearTag_UpdateCamera(this, globalCtx); + EnClearTag_UpdateCamera(this, play); } else if (this->activeTimer != 0) { - EnClearTag_UpdateEffects(this, globalCtx); + EnClearTag_UpdateEffects(this, play); } else { Actor_MarkForDeath(&this->actor); } @@ -611,8 +623,8 @@ void EnClearTag_Update(Actor* thisx, GlobalContext* globalCtx) { * EnClearTag draw function. * Setups DrawEffects */ -void EnClearTag_Draw(Actor* thisx, GlobalContext* globalCtx) { - EnClearTag_DrawEffects(thisx, globalCtx); +void EnClearTag_Draw(Actor* thisx, PlayState* play) { + EnClearTag_DrawEffects(thisx, play); } /** @@ -621,7 +633,7 @@ void EnClearTag_Draw(Actor* thisx, GlobalContext* globalCtx) { * Moves and bounces debris effects. * Fades most effects out of view. When effects are completely faded away they are removed. */ -void EnClearTag_UpdateEffects(EnClearTag* this, GlobalContext* globalCtx) { +void EnClearTag_UpdateEffects(EnClearTag* this, PlayState* play) { EnClearTagEffect* effect = this->effect; s16 i; f32 originalYPosition; @@ -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; + if (BgCheck_SphVsFirstPoly(&play->colCtx, &sphereCenter, 11.0f)) { + 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; } @@ -782,7 +793,7 @@ void EnClearTag_UpdateEffects(EnClearTag* this, GlobalContext* globalCtx) { * Each effect type is drawn before the next. The function will apply a material that * applies to all effects of that type while drawing the first effect of that type. */ -void EnClearTag_DrawEffects(Actor* thisx, GlobalContext* globalCtx) { +void EnClearTag_DrawEffects(Actor* thisx, PlayState* play) { u8 isMaterialApplied = false; s16 i; s16 j; @@ -790,14 +801,14 @@ void EnClearTag_DrawEffects(Actor* thisx, GlobalContext* globalCtx) { WaterBox* waterBox; f32 ySurface; MtxF mtxF; - GraphicsContext* gfxCtx = globalCtx->state.gfxCtx; + GraphicsContext* gfxCtx = play->state.gfxCtx; EnClearTag* this = THIS; EnClearTagEffect* effect = this->effect; EnClearTagEffect* firstEffect = this->effect; OPEN_DISPS(gfxCtx); - func_8012C28C(globalCtx->state.gfxCtx); - func_8012C2DC(globalCtx->state.gfxCtx); + func_8012C28C(play->state.gfxCtx); + func_8012C2DC(play->state.gfxCtx); // Draw all Debris effects. for (i = 0; i < ARRAY_COUNT(this->effect); i++, effect++) { @@ -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); @@ -878,13 +888,12 @@ void EnClearTag_DrawEffects(Actor* thisx, GlobalContext* globalCtx) { 128); gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, (s8)effect->primColor.r, (s8)effect->primColor.g, (s8)effect->primColor.b, (s8)effect->primColor.a); - 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); + gSPSegment(POLY_XLU_DISP++, 0x08, + Gfx_TwoTexScroll(play->state.gfxCtx, 0, 0, -effect->actionTimer * 5, 32, 64, 1, 0, 0, 32, 32)); + Matrix_Translate(effect->pos.x, effect->pos.y, effect->pos.z, MTXMODE_NEW); + Matrix_ReplaceRotation(&play->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); } @@ -904,11 +913,10 @@ void EnClearTag_DrawEffects(Actor* thisx, GlobalContext* globalCtx) { // Draw the fire effect. gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 200, 20, 0, (s8)effect->primColor.a); - 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); + gSPSegment(POLY_XLU_DISP++, 0x08, + Gfx_TwoTexScroll(play->state.gfxCtx, 0, 0, -effect->actionTimer * 15, 32, 64, 1, 0, 0, 32, 32)); + Matrix_Translate(effect->pos.x, effect->pos.y, effect->pos.z, MTXMODE_NEW); + Matrix_ReplaceRotation(&play->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 +937,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(&play->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 +962,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,37 +980,36 @@ 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(play, &play->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); } } } } } - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->state.gfxCtx); } 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 61c4a638b..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,9 +27,11 @@ 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]; 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 e7c6ebc6e..889055ee8 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 @@ -11,14 +11,14 @@ #define THIS ((EnCne01*)thisx) -void EnCne01_Init(Actor* thisx, GlobalContext* globalCtx); -void EnCne01_Destroy(Actor* thisx, GlobalContext* globalCtx); -void EnCne01_Update(Actor* thisx, GlobalContext* globalCtx); -void EnCne01_Draw(Actor* thisx, GlobalContext* globalCtx); +void EnCne01_Init(Actor* thisx, PlayState* play); +void EnCne01_Destroy(Actor* thisx, PlayState* play); +void EnCne01_Update(Actor* thisx, PlayState* play); +void EnCne01_Draw(Actor* thisx, PlayState* play); -void EnCne01_Walk(EnHy* this, GlobalContext* globalCtx); -void EnCne01_FaceForward(EnHy* this, GlobalContext* globalCtx); -void EnCne01_Talk(EnHy* this, GlobalContext* globalCtx); +void EnCne01_Walk(EnHy* this, PlayState* play); +void EnCne01_FaceForward(EnHy* this, PlayState* play); +void EnCne01_Talk(EnHy* this, PlayState* play); const ActorInit En_Cne_01_InitVars = { ACTOR_EN_CNE_01, @@ -89,65 +89,70 @@ static DamageTable sDamageTable = { /* Powder Keg */ DMG_ENTRY(0, 0), }; -u16 D_809CBF58[] = { 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 }, +}; -void EnCne01_UpdateModel(EnCne01* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); - Vec3f focus; +void EnCne01_UpdateModel(EnCne01* this, PlayState* play) { + Player* player = GET_PLAYER(play); + Vec3f point; - EnHy_UpdateSkelAnime(&this->enHy, globalCtx); + EnHy_UpdateSkelAnime(&this->enHy, play); if (SubS_AngleDiffLessEqual(this->enHy.actor.shape.rot.y, 0x36B0, this->enHy.actor.yawTowardsPlayer)) { - focus.x = player->actor.world.pos.x; - focus.y = player->bodyPartsPos[7].y + 3.0f; - focus.z = player->actor.world.pos.z; - func_8013D2E0(&focus, &this->enHy.actor.focus.pos, &this->enHy.actor.shape.rot, &this->enHy.focusTarget, - &this->enHy.headRot, &this->enHy.torsoRot, D_809CBF58); + 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.focusTarget.x, 0, 4, 0x3E8, 1); - Math_SmoothStepToS(&this->enHy.focusTarget.y, 0, 4, 0x3E8, 1); + 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, + SubS_FillLimbRotTables(play, this->enHy.limbRotTableY, this->enHy.limbRotTableZ, ARRAY_COUNT(this->enHy.limbRotTableY)); - EnHy_UpdateCollider(&this->enHy, globalCtx); + EnHy_UpdateCollider(&this->enHy, play); } -s32 EnCne01_TestIsTalking(EnCne01* this, GlobalContext* globalCtx) { +s32 EnCne01_TestIsTalking(EnCne01* this, PlayState* play) { s32 isTalking = false; - if (Actor_ProcessTalkRequest(&this->enHy.actor, &globalCtx->state)) { + if (Actor_ProcessTalkRequest(&this->enHy.actor, &play->state)) { isTalking = true; this->enHy.textId = 0x10B9; // Invalid textId, produces empty textbox - this->enHy.tmpFocusTarget = this->enHy.focusTarget; - this->enHy.tmpHeadRot = this->enHy.headRot; - this->enHy.tmpTorsoRot = this->enHy.torsoRot; - this->enHy.tmpActionFunc = this->enHy.actionFunc; + this->enHy.prevTrackTarget = this->enHy.trackTarget; + this->enHy.prevHeadRot = this->enHy.headRot; + this->enHy.prevTorsoRot = this->enHy.torsoRot; + this->enHy.prevActionFunc = this->enHy.actionFunc; this->enHy.actionFunc = EnCne01_Talk; } return isTalking; } -s32 func_809CB4A0(EnCne01* this, GlobalContext* globalCtx) { +s32 func_809CB4A0(EnCne01* this, PlayState* play) { s16 x; s16 y; - Actor_GetScreenPos(globalCtx, &this->enHy.actor, &x, &y); + Actor_GetScreenPos(play, &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); + func_800B85E0(&this->enHy.actor, play, 30.0f, PLAYER_AP_MAGIC_BEANS); } return true; } -void EnCne01_FinishInit(EnHy* this, GlobalContext* globalCtx) { - if (EnHy_Init(this, globalCtx, &gCneSkel, ENHY_ANIMATION_OS_ANIME_11)) { +void EnCne01_FinishInit(EnHy* this, PlayState* play) { + if (EnHy_Init(this, play, &gCneSkel, ENHY_ANIM_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) { + if (ENCNE01_GET_PATH(&this->actor) == 0x3F) { this->actionFunc = EnCne01_FaceForward; } else { this->actionFunc = EnCne01_Walk; @@ -155,116 +160,117 @@ void EnCne01_FinishInit(EnHy* this, GlobalContext* globalCtx) { } } -void EnCne01_Walk(EnHy* this, GlobalContext* globalCtx) { +void EnCne01_Walk(EnHy* this, PlayState* play) { if (EnHy_MoveForwards(this, 1.0f)) { this->curPoint = 0; } } -void EnCne01_FaceForward(EnHy* this, GlobalContext* globalCtx) { +void EnCne01_FaceForward(EnHy* this, PlayState* play) { this->actor.shape.rot = this->actor.world.rot; } -void EnCne01_Talk(EnHy* this, GlobalContext* globalCtx) { +void EnCne01_Talk(EnHy* this, PlayState* play) { s16 yaw; u8 talkState; Math_SmoothStepToS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer, 4, 0xFA0, 1); - talkState = Message_GetState(&globalCtx->msgCtx); - this->inMsgState3 = (talkState == 3) ? true : false; + + talkState = Message_GetState(&play->msgCtx); + this->inMsgState3 = (talkState == TEXT_STATE_3) ? true : false; switch (talkState) { - case 0: + case TEXT_STATE_NONE: yaw = ABS_ALT(this->actor.shape.rot.y - this->actor.yawTowardsPlayer); if (yaw < 0x64) { - Message_StartTextbox(globalCtx, this->textId, NULL); + Message_StartTextbox(play, this->textId, NULL); } break; - case 2: + + case TEXT_STATE_CLOSING: this->actor.textId = 0; - this->focusTarget = this->tmpFocusTarget; - this->headRot = this->tmpHeadRot; - this->torsoRot = this->tmpTorsoRot; + this->trackTarget = this->prevTrackTarget; + this->headRot = this->prevHeadRot; + this->torsoRot = this->prevTorsoRot; this->actor.shape.rot.y = this->actor.world.rot.y; - this->actionFunc = this->tmpActionFunc; - this->tmpActionFunc = NULL; + this->actionFunc = this->prevActionFunc; + this->prevActionFunc = NULL; break; } } -void EnCne01_Init(Actor* thisx, GlobalContext* globalCtx) { +void EnCne01_Init(Actor* thisx, PlayState* play) { s32 pad; EnCne01* this = THIS; - 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); + this->enHy.animObjIndex = SubS_GetObjectIndex(OBJECT_OS_ANIME, play); + this->enHy.headObjIndex = SubS_GetObjectIndex(OBJECT_CNE, play); + this->enHy.skelUpperObjIndex = SubS_GetObjectIndex(OBJECT_CNE, play); + this->enHy.skelLowerObjIndex = SubS_GetObjectIndex(OBJECT_CNE, play); 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); + Collider_InitCylinder(play, &this->enHy.collider); + Collider_SetCylinder(play, &this->enHy.collider, &this->enHy.actor, &sCylinderInit); CollisionCheck_SetInfo2(&this->enHy.actor.colChkInfo, &sDamageTable, &sColChkInfoInit); this->enHy.actor.flags &= ~ACTOR_FLAG_1; - this->enHy.path = SubS_GetPathByIndex(globalCtx, ENCNE01_GET_PATH(&this->enHy.actor), ENCNE01_NO_PATH); + this->enHy.path = SubS_GetPathByIndex(play, ENCNE01_GET_PATH(&this->enHy.actor), 0x3F); this->enHy.waitingOnInit = true; Actor_SetScale(&this->enHy.actor, 0.01f); this->enHy.actionFunc = EnCne01_FinishInit; } -void EnCne01_Destroy(Actor* thisx, GlobalContext* globalCtx) { +void EnCne01_Destroy(Actor* thisx, PlayState* play) { EnCne01* this = THIS; - Collider_DestroyCylinder(globalCtx, &this->enHy.collider); + Collider_DestroyCylinder(play, &this->enHy.collider); } -void EnCne01_Update(Actor* thisx, GlobalContext* globalCtx) { +void EnCne01_Update(Actor* thisx, PlayState* play) { 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); + EnCne01_TestIsTalking(this, play); + this->enHy.actionFunc(&this->enHy, play); + Actor_UpdateBgCheckInfo(play, &this->enHy.actor, 0.0f, 0.0f, 0.0f, 4); + EnCne01_UpdateModel(this, play); + func_809CB4A0(this, play); } -s32 EnCne01_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, - Actor* thisx) { +s32 EnCne01_OverrideLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, Actor* thisx) { EnCne01* this = THIS; s8 bodyPart; Vec3f zeroVec = { 0.0f, 0.0f, 0.0f }; bodyPart = gEnHyBodyParts[limbIndex]; if (bodyPart >= 0) { - Matrix_MultiplyVector3fByState(&zeroVec, &this->enHy.bodyPartsPos[bodyPart]); + 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); + OPEN_DISPS(play->state.gfxCtx); + gSPSegment(POLY_OPA_DISP++, 0x06, play->objectCtx.status[this->enHy.headObjIndex].segment); + gSegments[6] = PHYSICAL_TO_VIRTUAL(play->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); + gSegments[6] = PHYSICAL_TO_VIRTUAL(play->objectCtx.status[this->enHy.skelLowerObjIndex].segment); + CLOSE_DISPS(play->state.gfxCtx); } if (limbIndex == CNE_LIMB_HEAD) { - Matrix_InsertTranslation(1500.0f, 0.0f, 0.0f, MTXMODE_APPLY); - Matrix_InsertXRotation_s(this->enHy.headRot.y, MTXMODE_APPLY); - Matrix_InsertZRotation_s(-this->enHy.headRot.x, MTXMODE_APPLY); - Matrix_InsertTranslation(-1500.0f, 0.0f, 0.0f, MTXMODE_APPLY); + 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_InsertXRotation_s(-this->enHy.torsoRot.y, MTXMODE_APPLY); - Matrix_InsertZRotation_s(-this->enHy.torsoRot.x, MTXMODE_APPLY); + 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_InsertTranslation(40.0f, 0.0f, 0.0f, MTXMODE_APPLY); + if ((limbIndex == CNE_LIMB_HEAD) && this->enHy.inMsgState3 && ((play->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) || @@ -276,52 +282,52 @@ s32 EnCne01_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dLis return false; } -void EnCne01_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx) { +void EnCne01_PostLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx) { EnCne01* this = THIS; - GraphicsContext* gfxCtx = globalCtx->state.gfxCtx; + GraphicsContext* gfxCtx = play->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); + OPEN_DISPS(play->state.gfxCtx); + gSPSegment(POLY_OPA_DISP++, 0x06, play->objectCtx.status[this->enHy.skelUpperObjIndex].segment); + gSegments[0x06] = PHYSICAL_TO_VIRTUAL(play->objectCtx.status[this->enHy.skelUpperObjIndex].segment); + CLOSE_DISPS(play->state.gfxCtx); } if (limbIndex == CNE_LIMB_HEAD) { - Matrix_MultiplyVector3fByState(&zeroVec, &this->enHy.actor.focus.pos); + Matrix_MultVec3f(&zeroVec, &this->enHy.actor.focus.pos); } } -void EnCne01_TransformLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Actor* thisx) { +void EnCne01_TransformLimbDraw(PlayState* play, s32 limbIndex, Actor* thisx) { } -void EnCne01_Draw(Actor* thisx, GlobalContext* globalCtx) { +void EnCne01_Draw(Actor* thisx, PlayState* play) { EnCne01* this = THIS; s32 i; - u8* shadowTex = GRAPH_ALLOC(globalCtx->state.gfxCtx, sizeof(u8[64][64])); + u8* shadowTex = GRAPH_ALLOC(play->state.gfxCtx, SUBS_SHADOW_TEX_SIZE); u8* shadowTexIter; - OPEN_DISPS(globalCtx->state.gfxCtx); + OPEN_DISPS(play->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)); + func_8012C28C(play->state.gfxCtx); + gSPSegment(POLY_OPA_DISP++, 0x08, Gfx_EnvColor(play->state.gfxCtx, 160, 180, 255, 0)); + gSPSegment(POLY_OPA_DISP++, 0x09, Gfx_EnvColor(play->state.gfxCtx, 160, 180, 255, 0)); + gSPSegment(POLY_OPA_DISP++, 0x0A, Gfx_EnvColor(play->state.gfxCtx, 160, 180, 255, 0)); gDPPipeSync(POLY_OPA_DISP++); - SkelAnime_DrawTransformFlexOpa(globalCtx, this->enHy.skelAnime.skeleton, this->enHy.skelAnime.jointTable, + SkelAnime_DrawTransformFlexOpa(play, this->enHy.skelAnime.skeleton, this->enHy.skelAnime.jointTable, this->enHy.skelAnime.dListCount, EnCne01_OverrideLimbDraw, EnCne01_PostLimbDraw, EnCne01_TransformLimbDraw, &this->enHy.actor); - Matrix_InsertXRotation_s(0, MTXMODE_NEW); + Matrix_RotateXS(0, MTXMODE_NEW); - for (i = 0, shadowTexIter = shadowTex; i < (s32)sizeof(u8[64][64]); i++) { + for (i = 0, shadowTexIter = shadowTex; i < SUBS_SHADOW_TEX_SIZE; i++) { *shadowTexIter++ = 0; } for (i = 0; i < 5; i++) { - func_8013CD64(this->enHy.bodyPartsPos, &this->enHy.actor.world.pos, shadowTex, i / 5.0f, - ARRAY_COUNT(this->enHy.bodyPartsPos), gEnHyShadowSize, gEnHyBodyPartsIndex); + SubS_GenShadowTex(this->enHy.bodyPartsPos, &this->enHy.actor.world.pos, shadowTex, i / 5.0f, + ARRAY_COUNT(this->enHy.bodyPartsPos), gEnHyShadowSizes, gEnHyParentBodyParts); } - func_8013CF04(&this->enHy.actor, &globalCtx->state.gfxCtx, shadowTex); + SubS_DrawShadowTex(&this->enHy.actor, &play->state, shadowTex); - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->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 840d1cf60..0b9e1e08b 100644 --- a/src/overlays/actors/ovl_En_Cne_01/z_en_cne_01.h +++ b/src/overlays/actors/ovl_En_Cne_01/z_en_cne_01.h @@ -5,10 +5,9 @@ struct EnCne01; -typedef void (*EnCne01ActionFunc)(struct EnCne01*, GlobalContext*); +typedef void (*EnCne01ActionFunc)(struct EnCne01*, PlayState*); #define ENCNE01_GET_PATH(thisx) (((thisx)->params & 0x7E00) >> 9) -#define ENCNE01_NO_PATH 0x3F typedef struct EnCne01 { /* 0x000 */ EnHy enHy; diff --git a/src/overlays/actors/ovl_En_Col_Man/z_en_col_man.c b/src/overlays/actors/ovl_En_Col_Man/z_en_col_man.c index 6817c1830..54a78442c 100644 --- a/src/overlays/actors/ovl_En_Col_Man/z_en_col_man.c +++ b/src/overlays/actors/ovl_En_Col_Man/z_en_col_man.c @@ -12,20 +12,20 @@ #define THIS ((EnColMan*)thisx) -void EnColMan_Init(Actor* thisx, GlobalContext* globalCtx); -void EnColMan_Destroy(Actor* thisx, GlobalContext* globalCtx); -void EnColMan_Update(Actor* thisx, GlobalContext* globalCtx); +void EnColMan_Init(Actor* thisx, PlayState* play); +void EnColMan_Destroy(Actor* thisx, PlayState* play); +void EnColMan_Update(Actor* thisx, PlayState* play); void func_80AFDD60(EnColMan* this); -void func_80AFDE00(EnColMan* this, GlobalContext* globalCtx); -void EnColMan_SetHeartPieceCollectedAndKill(EnColMan* this, GlobalContext* globalCtx); +void func_80AFDE00(EnColMan* this, PlayState* play); +void EnColMan_SetHeartPieceCollectedAndKill(EnColMan* this, PlayState* play); void func_80AFDF60(EnColMan* this); -void func_80AFDFB4(EnColMan* this, GlobalContext* globalCtx); +void func_80AFDFB4(EnColMan* this, PlayState* play); void func_80AFE234(EnColMan* this); -void func_80AFE25C(EnColMan* this, GlobalContext* globalCtx); -void func_80AFE414(Actor* thisx, GlobalContext* globalCtx); -void func_80AFE4AC(Actor* thisx, GlobalContext* globalCtx); -void func_80AFE584(Actor* thisx, GlobalContext* globalCtx); -void func_80AFE650(Actor* thisx, GlobalContext* globalCtx); +void func_80AFE25C(EnColMan* this, PlayState* play); +void func_80AFE414(Actor* thisx, PlayState* play); +void func_80AFE4AC(Actor* thisx, PlayState* play); +void func_80AFE584(Actor* thisx, PlayState* play); +void func_80AFE650(Actor* thisx, PlayState* play); static ColliderCylinderInit sCylinderInit = { { @@ -62,10 +62,10 @@ const ActorInit En_Col_Man_InitVars = { static Color_RGBA8 primColor = { 60, 50, 20, 255 }; static Color_RGBA8 envColor = { 40, 30, 30, 255 }; -void EnColMan_Init(Actor* thisx, GlobalContext* globalCtx) { +void EnColMan_Init(Actor* thisx, PlayState* play) { EnColMan* this = THIS; - Collider_InitAndSetCylinder(globalCtx, &this->collider, &this->actor, &sCylinderInit); + Collider_InitAndSetCylinder(play, &this->collider, &this->actor, &sCylinderInit); this->actor.targetMode = 1; this->scale = (BREG(55) / 1000.0f) + 0.01f; @@ -87,10 +87,10 @@ void EnColMan_Init(Actor* thisx, GlobalContext* globalCtx) { } } -void EnColMan_Destroy(Actor* thisx, GlobalContext* globalCtx) { +void EnColMan_Destroy(Actor* thisx, PlayState* play) { EnColMan* this = THIS; - Collider_DestroyCylinder(globalCtx, &this->collider); + Collider_DestroyCylinder(play, &this->collider); } void func_80AFDD60(EnColMan* this) { @@ -113,7 +113,7 @@ void func_80AFDD60(EnColMan* this) { this->actionFunc = func_80AFDE00; } -void func_80AFDE00(EnColMan* this, GlobalContext* globalCtx) { +void func_80AFDE00(EnColMan* this, PlayState* play) { if (this->actor.bgCheckFlags & 1) { if (this->actor.params == EN_COL_MAN_HEART_PIECE) { this->actor.params = EN_COL_MAN_RECOVERY_HEART; @@ -126,19 +126,19 @@ void func_80AFDE00(EnColMan* this, GlobalContext* globalCtx) { if (!(gSaveContext.save.weekEventReg[56] & 2)) { this->actor.shape.rot.y += 0x3E8; } - if (Actor_HasParent(&this->actor, globalCtx)) { + if (Actor_HasParent(&this->actor, play)) { this->actor.parent = NULL; this->actor.draw = NULL; this->actionFunc = EnColMan_SetHeartPieceCollectedAndKill; } else if (!(gSaveContext.save.weekEventReg[56] & 2)) { - Actor_PickUp(&this->actor, globalCtx, GI_HEART_PIECE, 40.0f, 40.0f); + Actor_PickUp(&this->actor, play, GI_HEART_PIECE, 40.0f, 40.0f); } else { - Actor_PickUp(&this->actor, globalCtx, GI_RECOVERY_HEART, 40.0f, 40.0f); + Actor_PickUp(&this->actor, play, GI_RECOVERY_HEART, 40.0f, 40.0f); } } -void EnColMan_SetHeartPieceCollectedAndKill(EnColMan* this, GlobalContext* globalCtx) { - if (Message_GetState(&globalCtx->msgCtx) == 6 && Message_ShouldAdvance(globalCtx)) { +void EnColMan_SetHeartPieceCollectedAndKill(EnColMan* this, PlayState* play) { + if ((Message_GetState(&play->msgCtx) == TEXT_STATE_DONE) && Message_ShouldAdvance(play)) { gSaveContext.save.weekEventReg[56] |= 2; Actor_MarkForDeath(&this->actor); } @@ -154,7 +154,7 @@ void func_80AFDF60(EnColMan* this) { this->actor.gravity = -3.0f; } -void func_80AFDFB4(EnColMan* this, GlobalContext* globalCtx) { +void func_80AFDFB4(EnColMan* this, PlayState* play) { s32 i; Vec3f velocity; Vec3f accel; @@ -179,7 +179,7 @@ void func_80AFDFB4(EnColMan* this, GlobalContext* globalCtx) { accel.z = 0.0f; accel.x = 0.0f; - func_800B0EB0(globalCtx, &this->actor.world.pos, &velocity, &accel, &primColor, &envColor, + func_800B0EB0(play, &this->actor.world.pos, &velocity, &accel, &primColor, &envColor, Rand_ZeroFloat(50.0f) + 60.0f, 30, Rand_ZeroFloat(5.0f) + 20.0f); } @@ -193,16 +193,16 @@ void func_80AFE234(EnColMan* this) { this->actionFunc = func_80AFE25C; } -void func_80AFE25C(EnColMan* this, GlobalContext* globalCtx) { +void func_80AFE25C(EnColMan* this, PlayState* play) { this->scale = BREG(55) * 0.01f + 0.05f; if (BREG(60) || (this->actor.world.rot.z != 0)) { if (this->actor.params == EN_COL_MAN_CUTSCENE_BOMB) { - Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_CLEAR_TAG, this->actor.parent->world.pos.x, + Actor_Spawn(&play->actorCtx, play, ACTOR_EN_CLEAR_TAG, this->actor.parent->world.pos.x, this->actor.parent->world.pos.y, this->actor.parent->world.pos.z, 0, 0, 0, CLEAR_TAG_SMALL_EXPLOSION); } else { - EnBom* bomb = (EnBom*)Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_BOM, this->actor.world.pos.x, + EnBom* bomb = (EnBom*)Actor_Spawn(&play->actorCtx, play, ACTOR_EN_BOM, this->actor.world.pos.x, this->actor.world.pos.y, this->actor.world.pos.z, 0, 0, 0, 0); if (bomb != NULL) { @@ -215,61 +215,61 @@ void func_80AFE25C(EnColMan* this, GlobalContext* globalCtx) { } } -void EnColMan_Update(Actor* thisx, GlobalContext* globalCtx) { +void EnColMan_Update(Actor* thisx, PlayState* play) { s32 pad; EnColMan* this = THIS; Actor_SetScale(&this->actor, this->scale); - this->actionFunc(this, globalCtx); + this->actionFunc(this, play); Actor_MoveWithGravity(&this->actor); - Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 30.0f, 30.0f, 30.0f, 0x1F); + Actor_UpdateBgCheckInfo(play, &this->actor, 30.0f, 30.0f, 30.0f, 0x1F); Collider_UpdateCylinder(&this->actor, &this->collider); - CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + CollisionCheck_SetOC(play, &play->colChkCtx, &this->collider.base); } -void func_80AFE414(Actor* thisx, GlobalContext* globalCtx) { +void func_80AFE414(Actor* thisx, PlayState* play) { EnColMan* this = THIS; - OPEN_DISPS(globalCtx->state.gfxCtx); - func_8012C2DC(globalCtx->state.gfxCtx); - func_800B8118(&this->actor, globalCtx, 0); - gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + OPEN_DISPS(play->state.gfxCtx); + func_8012C2DC(play->state.gfxCtx); + func_800B8118(&this->actor, play, 0); + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_XLU_DISP++, gameplay_keep_DL_05AAB0); - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->state.gfxCtx); } -void func_80AFE4AC(Actor* thisx, GlobalContext* globalCtx) { +void func_80AFE4AC(Actor* thisx, PlayState* play) { EnColMan* this = THIS; - func_8012C2DC(globalCtx->state.gfxCtx); - func_8012C28C(globalCtx->state.gfxCtx); - OPEN_DISPS(globalCtx->state.gfxCtx); - POLY_OPA_DISP = func_801660B8(globalCtx, POLY_OPA_DISP); + func_8012C2DC(play->state.gfxCtx); + func_8012C28C(play->state.gfxCtx); + OPEN_DISPS(play->state.gfxCtx); + POLY_OPA_DISP = func_801660B8(play, POLY_OPA_DISP); POLY_OPA_DISP = func_8012C724(POLY_OPA_DISP); gSPSegment(POLY_OPA_DISP++, 0x08, Lib_SegmentedToVirtual(gameplay_keep_Tex_05E6F0)); - gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_OPA_DISP++, gameplay_keep_DL_05F6F0); - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->state.gfxCtx); } -void func_80AFE584(Actor* thisx, GlobalContext* globalCtx) { - func_8012C2DC(globalCtx->state.gfxCtx); - func_8012C28C(globalCtx->state.gfxCtx); - OPEN_DISPS(globalCtx->state.gfxCtx); - gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); +void func_80AFE584(Actor* thisx, PlayState* play) { + func_8012C2DC(play->state.gfxCtx); + func_8012C28C(play->state.gfxCtx); + OPEN_DISPS(play->state.gfxCtx); + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gDPSetPrimColor(POLY_OPA_DISP++, 0, 0x80, 255, 255, 255, 255); gDPSetEnvColor(POLY_OPA_DISP++, 255, 255, 255, 255); gSPDisplayList(POLY_OPA_DISP++, gameplay_keep_DL_06AB30); - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->state.gfxCtx); } -void func_80AFE650(Actor* thisx, GlobalContext* globalCtx) { - func_8012C28C(globalCtx->state.gfxCtx); - OPEN_DISPS(globalCtx->state.gfxCtx); - POLY_OPA_DISP = func_801660B8(globalCtx, POLY_OPA_DISP); +void func_80AFE650(Actor* thisx, PlayState* play) { + func_8012C28C(play->state.gfxCtx); + OPEN_DISPS(play->state.gfxCtx); + POLY_OPA_DISP = func_801660B8(play, POLY_OPA_DISP); POLY_OPA_DISP = func_8012C724(POLY_OPA_DISP); gSPSegment(POLY_OPA_DISP++, 0x08, Lib_SegmentedToVirtual(gameplay_keep_Tex_05CEF0)); - gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_OPA_DISP++, gameplay_keep_DL_05F6F0); - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->state.gfxCtx); } diff --git a/src/overlays/actors/ovl_En_Col_Man/z_en_col_man.h b/src/overlays/actors/ovl_En_Col_Man/z_en_col_man.h index ab1ac285d..1e8f540dc 100644 --- a/src/overlays/actors/ovl_En_Col_Man/z_en_col_man.h +++ b/src/overlays/actors/ovl_En_Col_Man/z_en_col_man.h @@ -5,7 +5,7 @@ struct EnColMan; -typedef void (*EnColManActionFunc)(struct EnColMan*, GlobalContext*); +typedef void (*EnColManActionFunc)(struct EnColMan*, PlayState*); typedef struct EnColMan { /* 0x000 */ Actor actor; diff --git a/src/overlays/actors/ovl_En_Cow/z_en_cow.c b/src/overlays/actors/ovl_En_Cow/z_en_cow.c index 772d054ab..902f01931 100644 --- a/src/overlays/actors/ovl_En_Cow/z_en_cow.c +++ b/src/overlays/actors/ovl_En_Cow/z_en_cow.c @@ -10,22 +10,22 @@ #define THIS ((EnCow*)thisx) -void EnCow_Init(Actor* thisx, GlobalContext* globalCtx); -void EnCow_Destroy(Actor* thisx, GlobalContext* globalCtx); -void EnCow_Update(Actor* thisx, GlobalContext* globalCtx); -void EnCow_Draw(Actor* thisx, GlobalContext* globalCtx); +void EnCow_Init(Actor* thisx, PlayState* play); +void EnCow_Destroy(Actor* thisx, PlayState* play); +void EnCow_Update(Actor* thisx, PlayState* play); +void EnCow_Draw(Actor* thisx, PlayState* play); -void EnCow_TalkEnd(EnCow* this, GlobalContext* globalCtx); -void EnCow_GiveMilkEnd(EnCow* this, GlobalContext* globalCtx); -void EnCow_GiveMilkWait(EnCow* this, GlobalContext* globalCtx); -void EnCow_GiveMilk(EnCow* this, GlobalContext* globalCtx); -void EnCow_CheckForEmptyBottle(EnCow* this, GlobalContext* globalCtx); -void EnCow_Talk(EnCow* this, GlobalContext* globalCtx); -void EnCow_Idle(EnCow* this, GlobalContext* globalCtx); +void EnCow_TalkEnd(EnCow* this, PlayState* play); +void EnCow_GiveMilkEnd(EnCow* this, PlayState* play); +void EnCow_GiveMilkWait(EnCow* this, PlayState* play); +void EnCow_GiveMilk(EnCow* this, PlayState* play); +void EnCow_CheckForEmptyBottle(EnCow* this, PlayState* play); +void EnCow_Talk(EnCow* this, PlayState* play); +void EnCow_Idle(EnCow* this, PlayState* play); -void EnCow_DoTail(EnCow* this, GlobalContext* globalCtx); -void EnCow_UpdateTail(Actor* this, GlobalContext* globalCtx); -void EnCow_DrawTail(Actor* this, GlobalContext* globalCtx); +void EnCow_DoTail(EnCow* this, PlayState* play); +void EnCow_UpdateTail(Actor* this, PlayState* play); +void EnCow_DrawTail(Actor* this, PlayState* play); const ActorInit En_Cow_InitVars = { ACTOR_EN_COW, @@ -97,7 +97,7 @@ void EnCow_SetTailPos(EnCow* this) { this->actor.world.pos.z += vec.z; } -void EnCow_Init(Actor* thisx, GlobalContext* globalCtx) { +void EnCow_Init(Actor* thisx, PlayState* play) { s32 pad; EnCow* this = THIS; @@ -106,12 +106,12 @@ 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, &gCowSkel, NULL, this->jointTable, this->morphTable, + SkelAnime_InitFlex(play, &this->skelAnime, &gCowSkel, NULL, this->jointTable, this->morphTable, COW_LIMB_MAX); Animation_PlayLoop(&this->skelAnime, &gCowChewAnim); - Collider_InitAndSetCylinder(globalCtx, &this->colliders[0], &this->actor, &sCylinderInit); - Collider_InitAndSetCylinder(globalCtx, &this->colliders[1], &this->actor, &sCylinderInit); + Collider_InitAndSetCylinder(play, &this->colliders[0], &this->actor, &sCylinderInit); + Collider_InitAndSetCylinder(play, &this->colliders[1], &this->actor, &sCylinderInit); EnCow_SetColliderPos(this); this->actionFunc = EnCow_Idle; @@ -122,7 +122,7 @@ void EnCow_Init(Actor* thisx, GlobalContext* globalCtx) { return; } - Actor_SpawnAsChild(&globalCtx->actorCtx, &this->actor, globalCtx, ACTOR_EN_COW, this->actor.world.pos.x, + Actor_SpawnAsChild(&play->actorCtx, &this->actor, play, ACTOR_EN_COW, this->actor.world.pos.x, this->actor.world.pos.y, this->actor.world.pos.z, 0, this->actor.shape.rot.y, 0, EN_COW_TYPE_TAIL); @@ -134,7 +134,7 @@ void EnCow_Init(Actor* thisx, GlobalContext* globalCtx) { func_801A5080(4); break; case EN_COW_TYPE_TAIL: - SkelAnime_InitFlex(globalCtx, &this->skelAnime, &gCowTailSkel, NULL, this->jointTable, this->morphTable, + SkelAnime_InitFlex(play, &this->skelAnime, &gCowTailSkel, NULL, this->jointTable, this->morphTable, COW_TAIL_LIMB_MAX); Animation_PlayLoop(&this->skelAnime, &gCowTailIdleAnim); @@ -156,16 +156,16 @@ void EnCow_Init(Actor* thisx, GlobalContext* globalCtx) { gSaveContext.save.weekEventReg[87] &= (u8)~1; } -void EnCow_Destroy(Actor* thisx, GlobalContext* globalCtx) { +void EnCow_Destroy(Actor* thisx, PlayState* play) { EnCow* this = THIS; if (this->actor.params == EN_COW_TYPE_DEFAULT) { //! @bug EN_COW_TYPE_ABDUCTED do not destroy their cylinders - Collider_DestroyCylinder(globalCtx, &this->colliders[0]); - Collider_DestroyCylinder(globalCtx, &this->colliders[1]); + Collider_DestroyCylinder(play, &this->colliders[0]); + Collider_DestroyCylinder(play, &this->colliders[1]); } } -void EnCow_UpdateAnimation(EnCow* this, GlobalContext* globalCtx) { +void EnCow_UpdateAnimation(EnCow* this, PlayState* play) { if (this->animationTimer > 0) { this->animationTimer--; } else { @@ -199,53 +199,53 @@ void EnCow_UpdateAnimation(EnCow* this, GlobalContext* globalCtx) { } } -void EnCow_TalkEnd(EnCow* this, GlobalContext* globalCtx) { - if ((Message_GetState(&globalCtx->msgCtx) == 5) && Message_ShouldAdvance(globalCtx)) { +void EnCow_TalkEnd(EnCow* this, PlayState* play) { + if ((Message_GetState(&play->msgCtx) == TEXT_STATE_5) && Message_ShouldAdvance(play)) { this->actor.flags &= ~ACTOR_FLAG_10000; - func_801477B4(globalCtx); + func_801477B4(play); this->actionFunc = EnCow_Idle; } } -void EnCow_GiveMilkEnd(EnCow* this, GlobalContext* globalCtx) { - if (Actor_TextboxIsClosing(&this->actor, globalCtx)) { +void EnCow_GiveMilkEnd(EnCow* this, PlayState* play) { + if (Actor_TextboxIsClosing(&this->actor, play)) { this->actor.flags &= ~ACTOR_FLAG_10000; this->actionFunc = EnCow_Idle; } } -void EnCow_GiveMilkWait(EnCow* this, GlobalContext* globalCtx) { - if (Actor_HasParent(&this->actor, globalCtx)) { +void EnCow_GiveMilkWait(EnCow* this, PlayState* play) { + if (Actor_HasParent(&this->actor, play)) { this->actor.parent = NULL; this->actionFunc = EnCow_GiveMilkEnd; } else { - Actor_PickUp(&this->actor, globalCtx, GI_MILK, 10000.0f, 100.0f); + Actor_PickUp(&this->actor, play, GI_MILK, 10000.0f, 100.0f); } } -void EnCow_GiveMilk(EnCow* this, GlobalContext* globalCtx) { - if ((Message_GetState(&globalCtx->msgCtx) == 5) && Message_ShouldAdvance(globalCtx)) { +void EnCow_GiveMilk(EnCow* this, PlayState* play) { + if ((Message_GetState(&play->msgCtx) == TEXT_STATE_5) && Message_ShouldAdvance(play)) { this->actor.flags &= ~ACTOR_FLAG_10000; - func_801477B4(globalCtx); + func_801477B4(play); this->actionFunc = EnCow_GiveMilkWait; - Actor_PickUp(&this->actor, globalCtx, GI_MILK, 10000.0f, 100.0f); + Actor_PickUp(&this->actor, play, GI_MILK, 10000.0f, 100.0f); } } -void EnCow_CheckForEmptyBottle(EnCow* this, GlobalContext* globalCtx) { - if ((Message_GetState(&globalCtx->msgCtx) == 5) && Message_ShouldAdvance(globalCtx)) { - if (Interface_HasEmptyBottle()) { - func_80151938(globalCtx, 0x32C9); // Text to give milk. +void EnCow_CheckForEmptyBottle(EnCow* this, PlayState* play) { + if ((Message_GetState(&play->msgCtx) == TEXT_STATE_5) && Message_ShouldAdvance(play)) { + if (Inventory_HasEmptyBottle()) { + func_80151938(play, 0x32C9); // Text to give milk. this->actionFunc = EnCow_GiveMilk; } else { - func_80151938(globalCtx, 0x32CA); // Text if you don't have an empty bottle. + func_80151938(play, 0x32CA); // Text if you don't have an empty bottle. this->actionFunc = EnCow_TalkEnd; } } } -void EnCow_Talk(EnCow* this, GlobalContext* globalCtx) { - if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { +void EnCow_Talk(EnCow* this, PlayState* play) { + if (Actor_ProcessTalkRequest(&this->actor, &play->state)) { if (this->actor.textId == 0x32C8) { // Text to give milk after playing Epona's Song. this->actionFunc = EnCow_CheckForEmptyBottle; } else if (this->actor.textId == 0x32C9) { // Text to give milk. @@ -255,15 +255,15 @@ void EnCow_Talk(EnCow* this, GlobalContext* globalCtx) { } } else { this->actor.flags |= ACTOR_FLAG_10000; - func_800B8614(&this->actor, globalCtx, 170.0f); + func_800B8614(&this->actor, play, 170.0f); this->actor.textId = 0x32C8; //! @bug textId is reset to this no matter the intial value } - EnCow_UpdateAnimation(this, globalCtx); + EnCow_UpdateAnimation(this, play); } -void EnCow_Idle(EnCow* this, GlobalContext* globalCtx) { - if ((globalCtx->msgCtx.ocarinaMode == 0) || (globalCtx->msgCtx.ocarinaMode == 4)) { +void EnCow_Idle(EnCow* this, PlayState* play) { + if ((play->msgCtx.ocarinaMode == 0) || (play->msgCtx.ocarinaMode == 4)) { if (D_801BDAA4 != 0) { if (this->flags & EN_COW_FLAG_WONT_GIVE_MILK) { this->flags &= ~EN_COW_FLAG_WONT_GIVE_MILK; @@ -273,10 +273,10 @@ void EnCow_Idle(EnCow* this, GlobalContext* globalCtx) { D_801BDAA4 = 0; this->actionFunc = EnCow_Talk; this->actor.flags |= ACTOR_FLAG_10000; - func_800B8614(&this->actor, globalCtx, 170.0f); + func_800B8614(&this->actor, play, 170.0f); this->actor.textId = 0x32C8; // Text to give milk after playing Epona's Song. - EnCow_UpdateAnimation(this, globalCtx); + EnCow_UpdateAnimation(this, play); return; } else { this->flags |= EN_COW_FLAG_WONT_GIVE_MILK; @@ -291,13 +291,13 @@ void EnCow_Idle(EnCow* this, GlobalContext* globalCtx) { if (func_801A5100() == 4) { if (!(gSaveContext.save.weekEventReg[87] & 1)) { gSaveContext.save.weekEventReg[87] |= 1; - if (Interface_HasEmptyBottle()) { + if (Inventory_HasEmptyBottle()) { this->actor.textId = 0x32C9; // Text to give milk. } else { this->actor.textId = 0x32CA; // Text if you don't have an empty bottle. } this->actor.flags |= ACTOR_FLAG_10000; - func_800B8614(&this->actor, globalCtx, 170.0f); + func_800B8614(&this->actor, play, 170.0f); this->actionFunc = EnCow_Talk; } } else { @@ -305,10 +305,10 @@ void EnCow_Idle(EnCow* this, GlobalContext* globalCtx) { } } - EnCow_UpdateAnimation(this, globalCtx); + EnCow_UpdateAnimation(this, play); } -void EnCow_DoTail(EnCow* this, GlobalContext* globalCtx) { +void EnCow_DoTail(EnCow* this, PlayState* play) { if (this->animationTimer > 0) { this->animationTimer--; } else { @@ -328,19 +328,19 @@ void EnCow_DoTail(EnCow* this, GlobalContext* globalCtx) { } } -void EnCow_Update(Actor* thisx, GlobalContext* globalCtx2) { - GlobalContext* globalCtx = globalCtx2; +void EnCow_Update(Actor* thisx, PlayState* play2) { + PlayState* play = play2; EnCow* this = THIS; s16 targetX; s16 targetY; - Player* player = GET_PLAYER(globalCtx); + Player* player = GET_PLAYER(play); - CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->colliders[0].base); - CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->colliders[1].base); + CollisionCheck_SetOC(play, &play->colChkCtx, &this->colliders[0].base); + CollisionCheck_SetOC(play, &play->colChkCtx, &this->colliders[1].base); Actor_MoveWithGravity(&this->actor); - Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 0.0f, 0.0f, 0.0f, 4); + Actor_UpdateBgCheckInfo(play, &this->actor, 0.0f, 0.0f, 0.0f, 4); if (SkelAnime_Update(&this->skelAnime)) { if (this->skelAnime.animation == &gCowChewAnim) { @@ -353,7 +353,7 @@ void EnCow_Update(Actor* thisx, GlobalContext* globalCtx2) { } } - this->actionFunc(this, globalCtx); + this->actionFunc(this, play); if (this->actor.xzDistToPlayer < 150.0f && ABS_ALT(Math_Vec3f_Yaw(&thisx->world.pos, &player->actor.world.pos)) < 0xC000) { @@ -379,7 +379,7 @@ void EnCow_Update(Actor* thisx, GlobalContext* globalCtx2) { Math_SmoothStepToS(&this->headTilt.y, targetY, 10, 200, 10); } -void EnCow_UpdateTail(Actor* thisx, GlobalContext* globalCtx) { +void EnCow_UpdateTail(Actor* thisx, PlayState* play) { s32 pad; EnCow* this = THIS; @@ -393,10 +393,10 @@ void EnCow_UpdateTail(Actor* thisx, GlobalContext* globalCtx) { } } - this->actionFunc(this, globalCtx); + this->actionFunc(this, play); } -s32 EnCow_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, Actor* thisx) { +s32 EnCow_OverrideLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, Actor* thisx) { EnCow* this = THIS; if (limbIndex == COW_LIMB_HEAD) { @@ -410,26 +410,26 @@ s32 EnCow_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, return false; } -void EnCow_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx) { +void EnCow_PostLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx) { EnCow* this = THIS; if (limbIndex == COW_LIMB_HEAD) { - Matrix_MultiplyVector3fByState(&D_8099D63C, &this->actor.focus.pos); + Matrix_MultVec3f(&D_8099D63C, &this->actor.focus.pos); } } -void EnCow_Draw(Actor* thisx, GlobalContext* globalCtx) { +void EnCow_Draw(Actor* thisx, PlayState* play) { EnCow* this = THIS; - func_8012C5B0(globalCtx->state.gfxCtx); - SkelAnime_DrawFlexOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, + func_8012C5B0(play->state.gfxCtx); + SkelAnime_DrawFlexOpa(play, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, EnCow_OverrideLimbDraw, EnCow_PostLimbDraw, &this->actor); } -void EnCow_DrawTail(Actor* thisx, GlobalContext* globalCtx) { +void EnCow_DrawTail(Actor* thisx, PlayState* play) { EnCow* this = THIS; - func_8012C5B0(globalCtx->state.gfxCtx); - SkelAnime_DrawFlexOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, - NULL, NULL, &this->actor); + func_8012C5B0(play->state.gfxCtx); + SkelAnime_DrawFlexOpa(play, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, NULL, + NULL, &this->actor); } diff --git a/src/overlays/actors/ovl_En_Cow/z_en_cow.h b/src/overlays/actors/ovl_En_Cow/z_en_cow.h index bb9319ad9..1fd6a36a9 100644 --- a/src/overlays/actors/ovl_En_Cow/z_en_cow.h +++ b/src/overlays/actors/ovl_En_Cow/z_en_cow.h @@ -17,7 +17,7 @@ typedef enum { struct EnCow; -typedef void (*EnCowActionFunc)(struct EnCow*, GlobalContext*); +typedef void (*EnCowActionFunc)(struct EnCow*, PlayState*); typedef struct EnCow { /* 0x0000 */ Actor actor; 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 bf77b1897..e6980ba4f 100644 --- a/src/overlays/actors/ovl_En_Crow/z_en_crow.c +++ b/src/overlays/actors/ovl_En_Crow/z_en_crow.c @@ -10,22 +10,22 @@ #define THIS ((EnCrow*)thisx) -void EnCrow_Init(Actor* thisx, GlobalContext* globalCtx); -void EnCrow_Destroy(Actor* thisx, GlobalContext* globalCtx); -void EnCrow_Update(Actor* thisx, GlobalContext* globalCtx); -void EnCrow_Draw(Actor* thisx, GlobalContext* globalCtx); +void EnCrow_Init(Actor* thisx, PlayState* play); +void EnCrow_Destroy(Actor* thisx, PlayState* play); +void EnCrow_Update(Actor* thisx, PlayState* play); +void EnCrow_Draw(Actor* thisx, PlayState* play); void EnCrow_SetupFlyIdle(EnCrow* this); -void EnCrow_FlyIdle(EnCrow* this, GlobalContext* globalCtx); +void EnCrow_FlyIdle(EnCrow* this, PlayState* play); 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_DiveAttack(EnCrow* this, PlayState* play); +void EnCrow_CheckIfFrozen(EnCrow* this, PlayState* play); +void EnCrow_Damaged(EnCrow* this, PlayState* play); void EnCrow_SetupDie(EnCrow* this); -void EnCrow_Die(EnCrow* this, GlobalContext* globalCtx); +void EnCrow_Die(EnCrow* this, PlayState* play); void EnCrow_SetupRespawn(EnCrow* this); -void EnCrow_TurnAway(EnCrow* this, GlobalContext* globalCtx); -void EnCrow_Respawn(EnCrow* this, GlobalContext* globalCtx); +void EnCrow_TurnAway(EnCrow* this, PlayState* play); +void EnCrow_Respawn(EnCrow* this, PlayState* play); const ActorInit En_Crow_InitVars = { ACTOR_EN_CROW, @@ -62,48 +62,59 @@ static ColliderJntSphInit sJntSphInit = { OC2_TYPE_1, COLSHAPE_JNTSPH, }, - 1, + ARRAY_COUNT(sJntSphElementsInit), sJntSphElementsInit, }; static CollisionCheckInfoInit sColChkInfoInit = { 1, 15, 30, 30 }; +typedef enum { + /* 0 */ GUAY_DMGEFF_NONE, + /* 1 */ GUAY_DMGEFF_STUN, + /* 2 */ GUAY_DMGEFF_FIRE, + /* 3 */ GUAY_DMGEFF_ICE, + /* 4 */ GUAY_DMGEFF_LIGHT, + /* 5 */ GUAY_DMGEFF_ELECTRIC, +} GuayDamageEffect; + static DamageTable sDamageTable = { - /* Deku Nut */ DMG_ENTRY(0, 0x1), - /* Deku Stick */ DMG_ENTRY(1, 0x0), - /* Horse trample */ DMG_ENTRY(1, 0x0), - /* Explosives */ DMG_ENTRY(1, 0x0), - /* Zora boomerang */ DMG_ENTRY(1, 0x0), - /* Normal arrow */ DMG_ENTRY(1, 0x0), - /* UNK_DMG_0x06 */ DMG_ENTRY(0, 0x0), - /* Hookshot */ DMG_ENTRY(1, 0x0), - /* Goron punch */ DMG_ENTRY(1, 0x0), - /* Sword */ DMG_ENTRY(1, 0x0), - /* Goron pound */ DMG_ENTRY(1, 0x0), - /* Fire arrow */ DMG_ENTRY(2, 0x2), - /* Ice arrow */ DMG_ENTRY(2, 0x3), - /* Light arrow */ DMG_ENTRY(2, 0x4), - /* Goron spikes */ DMG_ENTRY(1, 0x0), - /* Deku spin */ DMG_ENTRY(1, 0x0), - /* Deku bubble */ DMG_ENTRY(1, 0x0), - /* Deku launch */ DMG_ENTRY(2, 0x0), - /* UNK_DMG_0x12 */ DMG_ENTRY(0, 0x1), - /* Zora barrier */ DMG_ENTRY(0, 0x5), - /* Normal shield */ DMG_ENTRY(0, 0x0), - /* Light ray */ DMG_ENTRY(0, 0x0), - /* Thrown object */ DMG_ENTRY(1, 0x0), - /* Zora punch */ DMG_ENTRY(1, 0x0), - /* Spin attack */ DMG_ENTRY(1, 0x0), - /* Sword beam */ DMG_ENTRY(0, 0x0), - /* Normal Roll */ DMG_ENTRY(0, 0x0), - /* UNK_DMG_0x1B */ DMG_ENTRY(0, 0x0), - /* UNK_DMG_0x1C */ DMG_ENTRY(0, 0x0), - /* Unblockable */ DMG_ENTRY(0, 0x0), - /* UNK_DMG_0x1E */ DMG_ENTRY(0, 0x0), - /* Powder Keg */ DMG_ENTRY(1, 0x0), + /* Deku Nut */ DMG_ENTRY(0, GUAY_DMGEFF_STUN), + /* Deku Stick */ DMG_ENTRY(1, GUAY_DMGEFF_NONE), + /* Horse trample */ DMG_ENTRY(1, GUAY_DMGEFF_NONE), + /* Explosives */ DMG_ENTRY(1, GUAY_DMGEFF_NONE), + /* Zora boomerang */ DMG_ENTRY(1, GUAY_DMGEFF_NONE), + /* Normal arrow */ DMG_ENTRY(1, GUAY_DMGEFF_NONE), + /* UNK_DMG_0x06 */ DMG_ENTRY(0, GUAY_DMGEFF_NONE), + /* Hookshot */ DMG_ENTRY(1, GUAY_DMGEFF_NONE), + /* Goron punch */ DMG_ENTRY(1, GUAY_DMGEFF_NONE), + /* Sword */ DMG_ENTRY(1, GUAY_DMGEFF_NONE), + /* Goron pound */ DMG_ENTRY(1, GUAY_DMGEFF_NONE), + /* Fire arrow */ DMG_ENTRY(2, GUAY_DMGEFF_FIRE), + /* Ice arrow */ DMG_ENTRY(2, GUAY_DMGEFF_ICE), + /* Light arrow */ DMG_ENTRY(2, GUAY_DMGEFF_LIGHT), + /* Goron spikes */ DMG_ENTRY(1, GUAY_DMGEFF_NONE), + /* Deku spin */ DMG_ENTRY(1, GUAY_DMGEFF_NONE), + /* Deku bubble */ DMG_ENTRY(1, GUAY_DMGEFF_NONE), + /* Deku launch */ DMG_ENTRY(2, GUAY_DMGEFF_NONE), + /* UNK_DMG_0x12 */ DMG_ENTRY(0, GUAY_DMGEFF_STUN), + /* Zora barrier */ DMG_ENTRY(0, GUAY_DMGEFF_ELECTRIC), + /* Normal shield */ DMG_ENTRY(0, GUAY_DMGEFF_NONE), + /* Light ray */ DMG_ENTRY(0, GUAY_DMGEFF_NONE), + /* Thrown object */ DMG_ENTRY(1, GUAY_DMGEFF_NONE), + /* Zora punch */ DMG_ENTRY(1, GUAY_DMGEFF_NONE), + /* Spin attack */ DMG_ENTRY(1, GUAY_DMGEFF_NONE), + /* Sword beam */ DMG_ENTRY(0, GUAY_DMGEFF_NONE), + /* Normal Roll */ DMG_ENTRY(0, GUAY_DMGEFF_NONE), + /* UNK_DMG_0x1B */ DMG_ENTRY(0, GUAY_DMGEFF_NONE), + /* UNK_DMG_0x1C */ DMG_ENTRY(0, GUAY_DMGEFF_NONE), + /* Unblockable */ DMG_ENTRY(0, GUAY_DMGEFF_NONE), + /* UNK_DMG_0x1E */ DMG_ENTRY(0, GUAY_DMGEFF_NONE), + /* Powder Keg */ DMG_ENTRY(1, GUAY_DMGEFF_NONE), }; -static s32 D_8099C0CC = 0; +#define GUAY_NUMBER_OF_DEAD_TO_SPAWN_MEGAGUAY 10 + +static s32 sDeadCount = 0; static InitChainEntry sInitChain[] = { ICHAIN_F32(uncullZoneForward, 3000, ICHAIN_CONTINUE), @@ -112,27 +123,29 @@ static InitChainEntry sInitChain[] = { ICHAIN_F32(targetArrowOffset, 2000, ICHAIN_STOP), }; -void EnCrow_Init(Actor* thisx, GlobalContext* globalCtx) { +void EnCrow_Init(Actor* thisx, PlayState* play) { EnCrow* this = THIS; Actor_ProcessInitChain(&this->actor, sInitChain); - SkelAnime_InitFlex(globalCtx, &this->skelAnime, &gGuaySkel, &gGuayFlyAnim, this->jointTable, this->morphTable, + SkelAnime_InitFlex(play, &this->skelAnime, &gGuaySkel, &gGuayFlyAnim, this->jointTable, this->morphTable, OBJECT_CROW_LIMB_MAX); - Collider_InitAndSetJntSph(globalCtx, &this->collider, &this->actor, &sJntSphInit, this->colliderItems); + Collider_InitAndSetJntSph(play, &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; + + sDeadCount = 0; + if (this->actor.parent != NULL) { this->actor.flags &= ~ACTOR_FLAG_1; } EnCrow_SetupFlyIdle(this); } -void EnCrow_Destroy(Actor* thisx, GlobalContext* globalCtx) { +void EnCrow_Destroy(Actor* thisx, PlayState* play) { EnCrow* this = THIS; - Collider_DestroyJntSph(globalCtx, &this->collider); + Collider_DestroyJntSph(play, &this->collider); } void EnCrow_SetupFlyIdle(EnCrow* this) { @@ -142,8 +155,8 @@ void EnCrow_SetupFlyIdle(EnCrow* this) { this->skelAnime.playSpeed = 1.0f; } -void EnCrow_FlyIdle(EnCrow* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); +void EnCrow_FlyIdle(EnCrow* this, PlayState* play) { + Player* player = GET_PLAYER(play); f32 dist; s32 onInitialAnimFrame; s16 yaw; @@ -162,40 +175,40 @@ void EnCrow_FlyIdle(EnCrow* this, GlobalContext* globalCtx) { } if (this->actor.bgCheckFlags & 8) { - this->aimRotY = this->actor.wallYaw; + this->yawTarget = this->actor.wallYaw; } else if (Actor_XZDistanceToPoint(&this->actor, &this->actor.home.pos) > 300.0f) { - this->aimRotY = Actor_YawToPoint(&this->actor, &this->actor.home.pos); + this->yawTarget = Actor_YawToPoint(&this->actor, &this->actor.home.pos); } - if ((Math_SmoothStepToS(&this->actor.shape.rot.y, this->aimRotY, 5, 0x300, 0x10) == 0) && onInitialAnimFrame && + if ((Math_SmoothStepToS(&this->actor.shape.rot.y, this->yawTarget, 5, 0x300, 0x10) == 0) && onInitialAnimFrame && (Rand_ZeroOne() < 0.1f)) { yaw = (Actor_YawToPoint(&this->actor, &this->actor.home.pos) - this->actor.shape.rot.y); if (yaw > 0) { - this->aimRotY += Rand_S16Offset(0x1000, 0x1000); + this->yawTarget += Rand_S16Offset(0x1000, 0x1000); } else { - this->aimRotY -= Rand_S16Offset(0x1000, 0x1000); + this->yawTarget -= Rand_S16Offset(0x1000, 0x1000); } Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_KAICHO_CRY); } if ((this->actor.depthInWater > -40.0f) || (this->actor.bgCheckFlags & 1)) { - this->aimRotX = -0x1000; + this->pitchTarget = -0x1000; } else if (this->actor.world.pos.y < (this->actor.home.pos.y - 50.0f)) { - this->aimRotX = -Rand_S16Offset(0x800, 0x800); + this->pitchTarget = -Rand_S16Offset(0x800, 0x800); } else if (this->actor.world.pos.y > (this->actor.home.pos.y + 50.0f)) { - this->aimRotX = Rand_S16Offset(0x800, 0x800); + this->pitchTarget = Rand_S16Offset(0x800, 0x800); } - if ((Math_SmoothStepToS(&this->actor.shape.rot.x, this->aimRotX, 0xA, 0x100, 8) == 0) && onInitialAnimFrame && + if ((Math_SmoothStepToS(&this->actor.shape.rot.x, this->pitchTarget, 0xA, 0x100, 8) == 0) && onInitialAnimFrame && (Rand_ZeroOne() < 0.1f)) { if (this->actor.home.pos.y < this->actor.world.pos.y) { - this->aimRotX -= Rand_S16Offset(0x400, 0x400); + this->pitchTarget -= Rand_S16Offset(0x400, 0x400); } else { - this->aimRotX += Rand_S16Offset(0x400, 0x400); + this->pitchTarget += Rand_S16Offset(0x400, 0x400); } - this->aimRotX = CLAMP(this->aimRotX, -0x1000, 0x1000); + this->pitchTarget = CLAMP(this->pitchTarget, -0x1000, 0x1000); } if (this->actor.bgCheckFlags & 1) { @@ -206,8 +219,8 @@ void EnCrow_FlyIdle(EnCrow* this, GlobalContext* globalCtx) { 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)) { + (((this->actor.xzDistToPlayer < 300.0f) && !(player->stateFlags1 & PLAYER_STATE1_800000)) || (dist < 300.0f)) && + (this->actor.depthInWater < -40.0f) && (Player_GetMask(play) != PLAYER_MASK_STONE)) { if (dist < this->actor.xzDistToPlayer) { this->actor.child = this->actor.parent; } else { @@ -224,12 +237,10 @@ void EnCrow_SetupDiveAttack(EnCrow* this) { this->skelAnime.playSpeed = 2.0f; } -void EnCrow_DiveAttack(EnCrow* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); +void EnCrow_DiveAttack(EnCrow* this, PlayState* play) { + Player* player = GET_PLAYER(play); s32 isFacingActor; - Vec3f pos; - s16 pitch; - s16 pitchTarget; + Vec3f targetPos; SkelAnime_Update(&this->skelAnime); if (this->timer != 0) { @@ -238,27 +249,30 @@ void EnCrow_DiveAttack(EnCrow* this, GlobalContext* globalCtx) { isFacingActor = Actor_ActorAIsFacingActorB(&this->actor, this->actor.child, 0x2800); if (isFacingActor) { + s16 pitchTarget; + if (&player->actor == this->actor.child) { - pos.y = this->actor.child->world.pos.y + 20.0f; + targetPos.y = this->actor.child->world.pos.y + 20.0f; } else { - pos.y = this->actor.child->world.pos.y + 40.0f; + targetPos.y = this->actor.child->world.pos.y + 40.0f; } - pos.x = this->actor.child->world.pos.x; - pos.z = this->actor.child->world.pos.z; - pitch = Actor_PitchToPoint(&this->actor, &pos); - pitchTarget = CLAMP(pitch, -0x3000, 0x3000); - Math_SmoothStepToS(&this->actor.shape.rot.x, pitchTarget, 2, 0x400, 64); + targetPos.x = this->actor.child->world.pos.x; + targetPos.z = this->actor.child->world.pos.z; + pitchTarget = Actor_PitchToPoint(&this->actor, &targetPos); + pitchTarget = CLAMP(pitchTarget, -0x3000, 0x3000); + Math_SmoothStepToS(&this->actor.shape.rot.x, pitchTarget, 2, 0x400, 0x40); } else { - Math_SmoothStepToS(&this->actor.shape.rot.x, -0x800, 2, 0x100, 16); + Math_SmoothStepToS(&this->actor.shape.rot.x, -0x800, 2, 0x100, 0x10); } if (isFacingActor || (Actor_XZDistanceBetweenActors(&this->actor, this->actor.child) > 80.0f)) { Math_SmoothStepToS(&this->actor.shape.rot.y, Actor_YawBetweenActors(&this->actor, this->actor.child), 4, 0xC00, 0xC0); } + if (((this->timer == 0) || ((&player->actor != this->actor.child) && (this->actor.child->home.rot.z != 0)) || ((&player->actor == this->actor.child) && - ((Player_GetMask(globalCtx) == PLAYER_MASK_STONE) || (player->stateFlags1 & 0x800000))) || + ((Player_GetMask(play) == PLAYER_MASK_STONE) || (player->stateFlags1 & PLAYER_STATE1_800000))) || ((this->collider.base.atFlags & AT_HIT) || (this->actor.bgCheckFlags & 9))) || (this->actor.depthInWater > -40.0f)) { @@ -270,15 +284,15 @@ void EnCrow_DiveAttack(EnCrow* this, GlobalContext* globalCtx) { } } -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_CheckIfFrozen(EnCrow* this, PlayState* play) { + if (this->drawDmgEffType == ACTOR_DRAW_DMGEFF_FROZEN_NO_SFX) { + this->drawDmgEffType = ACTOR_DRAW_DMGEFF_FIRE; + this->drawDmgEffAlpha = 0.0f; + Actor_SpawnIceEffects(play, &this->actor, this->bodyPartsPos, 4, 2, 0.2f, 0.2f); } } -void EnCrow_SetupDamaged(EnCrow* this, GlobalContext* globalCtx) { +void EnCrow_SetupDamaged(EnCrow* this, PlayState* play) { f32 scale; this->actor.speedXZ *= Math_CosS(this->actor.world.rot.x); @@ -291,22 +305,22 @@ void EnCrow_SetupDamaged(EnCrow* this, GlobalContext* globalCtx) { 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, + if (this->actor.colChkInfo.damageEffect == GUAY_DMGEFF_ICE) { + this->drawDmgEffType = ACTOR_DRAW_DMGEFF_FROZEN_NO_SFX; + this->drawDmgEffAlpha = 1.0f; + this->drawDmgEffScale = 0.75f; + this->drawDmgEffFrozenSteamScale = 0.5f; + } else if (this->actor.colChkInfo.damageEffect == GUAY_DMGEFF_LIGHT) { + this->drawDmgEffType = ACTOR_DRAW_DMGEFF_LIGHT_ORBS; + this->drawDmgEffAlpha = 4.0f; + this->drawDmgEffFrozenSteamScale = 0.5f; + Actor_Spawn(&play->actorCtx, play, ACTOR_EN_CLEAR_TAG, this->collider.elements->info.bumper.hitPos.x, this->collider.elements->info.bumper.hitPos.y, this->collider.elements->info.bumper.hitPos.z, 0, 0, 0, CLEAR_TAG_SMALL_LIGHT_RAYS); - } else if (this->actor.colChkInfo.damageEffect == 2) { - this->deathMode = 0; // Fire arrows - this->effectAlpha = 4.0f; - this->steamScale = 0.5f; + } else if (this->actor.colChkInfo.damageEffect == GUAY_DMGEFF_FIRE) { + this->drawDmgEffType = ACTOR_DRAW_DMGEFF_FIRE; + this->drawDmgEffAlpha = 4.0f; + this->drawDmgEffFrozenSteamScale = 0.5f; } Actor_SetColorFilter(&this->actor, 0x4000, 255, 0, 40); @@ -320,20 +334,19 @@ void EnCrow_SetupDamaged(EnCrow* this, GlobalContext* globalCtx) { this->actionFunc = EnCrow_Damaged; } -void EnCrow_Damaged(EnCrow* this, GlobalContext* globalCtx) { +void EnCrow_Damaged(EnCrow* this, PlayState* play) { Math_StepToF(&this->actor.speedXZ, 0.0f, 0.5f); this->actor.colorFilterTimer = 40; if (!(this->actor.flags & ACTOR_FLAG_8000)) { - if (this->deathMode != 10) { + if (this->drawDmgEffType != ACTOR_DRAW_DMGEFF_FROZEN_NO_SFX) { Math_ScaledStepToS(&this->actor.shape.rot.x, 0x4000, 0x200); this->actor.shape.rot.z += 0x1780; } 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); + EnCrow_CheckIfFrozen(this, play); + func_800B3030(play, &this->actor.world.pos, &gZeroVec3f, &gZeroVec3f, this->actor.scale.x * 10000.0f, 0, 0); + SoundSource_PlaySfxAtFixedWorldPos(play, &this->actor.world.pos, 11, NA_SE_EN_EXTINCT); if (this->actor.parent != NULL) { Actor_MarkForDeath(&this->actor); @@ -349,20 +362,20 @@ void EnCrow_SetupDie(EnCrow* this) { this->actionFunc = EnCrow_Die; } -void EnCrow_Die(EnCrow* this, GlobalContext* globalCtx) { +void EnCrow_Die(EnCrow* this, PlayState* play) { f32 stepScale; - if (this->actor.params != 0) { + if (this->actor.params != GUAY_TYPE_NORMAL) { stepScale = 0.006f; } else { stepScale = 0.002f; } - if (Math_StepToF(&this->actor.scale.x, 0.0f, stepScale) != 0) { - if (this->actor.params == 0) { - D_8099C0CC++; - Item_DropCollectibleRandom(globalCtx, &this->actor, &this->actor.world.pos, 0x80); + if (Math_StepToF(&this->actor.scale.x, 0.0f, stepScale)) { + if (this->actor.params == GUAY_TYPE_NORMAL) { + sDeadCount++; + Item_DropCollectibleRandom(play, &this->actor, &this->actor.world.pos, 0x80); } else { - Item_DropCollectibleRandom(globalCtx, &this->actor, &this->actor.world.pos, 0x90); + Item_DropCollectibleRandom(play, &this->actor, &this->actor.world.pos, 0x90); } EnCrow_SetupRespawn(this); } @@ -371,11 +384,11 @@ void EnCrow_Die(EnCrow* this, GlobalContext* globalCtx) { void EnCrow_SetupTurnAway(EnCrow* this) { this->timer = 100; - this->aimRotX = -0x1000; + this->pitchTarget = -0x1000; this->actor.speedXZ = 3.5f; - this->aimRotY = this->actor.yawTowardsPlayer + 0x8000; + this->yawTarget = this->actor.yawTowardsPlayer + 0x8000; this->skelAnime.playSpeed = 2.0f; - if (this->actor.colChkInfo.damageEffect == 1) { + if (this->actor.colChkInfo.damageEffect == GUAY_DMGEFF_STUN) { Actor_SetColorFilter(&this->actor, 0, 255, 0, 40); } else { Actor_SetColorFilter(&this->actor, 0, 255, 0, 40); @@ -384,17 +397,17 @@ void EnCrow_SetupTurnAway(EnCrow* this) { this->actionFunc = EnCrow_TurnAway; } -void EnCrow_TurnAway(EnCrow* this, GlobalContext* globalCtx) { +void EnCrow_TurnAway(EnCrow* this, PlayState* play) { SkelAnime_Update(&this->skelAnime); if (this->actor.bgCheckFlags & 8) { - this->aimRotY = this->actor.wallYaw; + this->yawTarget = this->actor.wallYaw; } else { - this->aimRotY = this->actor.yawTowardsPlayer + 0x8000; + this->yawTarget = this->actor.yawTowardsPlayer + 0x8000; } - Math_SmoothStepToS(&this->actor.shape.rot.y, this->aimRotY, 3, 0xC00, 0xC0); - Math_SmoothStepToS(&this->actor.shape.rot.x, this->aimRotX, 5, 0x100, 0x10); + Math_SmoothStepToS(&this->actor.shape.rot.y, this->yawTarget, 3, 0xC00, 0xC0); + Math_SmoothStepToS(&this->actor.shape.rot.x, this->pitchTarget, 5, 0x100, 0x10); if (this->timer != 0) { this->timer--; @@ -406,12 +419,12 @@ void EnCrow_TurnAway(EnCrow* this, GlobalContext* globalCtx) { } void EnCrow_SetupRespawn(EnCrow* this) { - if (D_8099C0CC == 10) { - this->actor.params = 1; - D_8099C0CC = 0; + if (sDeadCount == GUAY_NUMBER_OF_DEAD_TO_SPAWN_MEGAGUAY) { + this->actor.params = GUAY_TYPE_MEGA; + sDeadCount = 0; this->collider.elements->dim.worldSphere.radius = sJntSphInit.elements->dim.modelSphere.radius * 0.03f * 100.0f; } else { - this->actor.params = 0; + this->actor.params = GUAY_TYPE_NORMAL; this->collider.elements->dim.worldSphere.radius = sJntSphInit.elements->dim.modelSphere.radius; } Animation_PlayLoop(&this->skelAnime, &gGuayFlyAnim); @@ -422,12 +435,12 @@ void EnCrow_SetupRespawn(EnCrow* this) { this->actor.draw = NULL; this->actor.shape.yOffset = 2000.0f; this->actor.targetArrowOffset = 2000.0; - this->effectAlpha = 0.0f; + this->drawDmgEffAlpha = 0.0f; this->actionFunc = EnCrow_Respawn; } -void EnCrow_Respawn(EnCrow* this, GlobalContext* globalCtx) { - f32 target; +void EnCrow_Respawn(EnCrow* this, PlayState* play) { + f32 scaleTarget; if (this->timer != 0) { this->timer--; @@ -435,12 +448,12 @@ void EnCrow_Respawn(EnCrow* this, GlobalContext* globalCtx) { if (this->timer == 0) { SkelAnime_Update(&this->skelAnime); this->actor.draw = EnCrow_Draw; - if (this->actor.params != 0) { - target = 0.03f; + if (this->actor.params != GUAY_TYPE_NORMAL) { + scaleTarget = 0.03f; } else { - target = 0.01f; + scaleTarget = 0.01f; } - if (Math_StepToF(&this->actor.scale.x, target, target * 0.1f)) { + if (Math_StepToF(&this->actor.scale.x, scaleTarget, scaleTarget * 0.1f)) { this->actor.flags |= ACTOR_FLAG_1; this->actor.flags &= ~ACTOR_FLAG_10; this->actor.colChkInfo.health = 1; @@ -450,38 +463,37 @@ void EnCrow_Respawn(EnCrow* this, GlobalContext* globalCtx) { } } -void EnCrow_UpdateDamage(EnCrow* this, GlobalContext* globalCtx) { - +void EnCrow_UpdateDamage(EnCrow* this, PlayState* play) { if (this->collider.base.acFlags & AT_HIT) { this->collider.base.acFlags &= ~AT_HIT; Actor_SetDropFlag(&this->actor, &this->collider.elements->info); - if (this->actor.colChkInfo.damageEffect == 1) { + if (this->actor.colChkInfo.damageEffect == GUAY_DMGEFF_STUN) { EnCrow_SetupTurnAway(this); - } else if (this->actor.colChkInfo.damageEffect == 5) { - this->deathMode = 31; // Stunned via deku nuts or zora barrier - this->effectAlpha = 2.0f; - this->steamScale = 0.5f; + } else if (this->actor.colChkInfo.damageEffect == GUAY_DMGEFF_ELECTRIC) { + this->drawDmgEffType = ACTOR_DRAW_DMGEFF_ELECTRIC_SPARKS_MEDIUM; + this->drawDmgEffAlpha = 2.0f; + this->drawDmgEffFrozenSteamScale = 0.5f; EnCrow_SetupTurnAway(this); } else { this->actor.colChkInfo.health = 0; this->actor.flags &= ~ACTOR_FLAG_1; - Enemy_StartFinishingBlow(globalCtx, &this->actor); - EnCrow_SetupDamaged(this, globalCtx); + Enemy_StartFinishingBlow(play, &this->actor); + EnCrow_SetupDamaged(this, play); } } } -void EnCrow_Update(Actor* thisx, GlobalContext* globalCtx) { +void EnCrow_Update(Actor* thisx, PlayState* play) { f32 pad; - EnCrow* this = (EnCrow*)thisx; + EnCrow* this = THIS; f32 height; f32 scale; - EnCrow_UpdateDamage(this, globalCtx); - this->actionFunc(this, globalCtx); + EnCrow_UpdateDamage(this, play); + this->actionFunc(this, play); 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; @@ -494,7 +506,7 @@ void EnCrow_Update(Actor* thisx, GlobalContext* globalCtx) { height = 0.0f; Actor_MoveWithGravity(&this->actor); } - Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 12.0f * scale, 25.0f * scale, 50.0f * scale, 7); + Actor_UpdateBgCheckInfo(play, &this->actor, 12.0f * scale, 25.0f * scale, 50.0f * scale, 7); } else { height = 0.0f; } @@ -504,13 +516,13 @@ void EnCrow_Update(Actor* thisx, GlobalContext* globalCtx) { 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); + CollisionCheck_SetAT(play, &play->colChkCtx, &this->collider.base); } if (this->collider.base.acFlags & AC_ON) { - CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + CollisionCheck_SetAC(play, &play->colChkCtx, &this->collider.base); } if (this->actionFunc != EnCrow_Respawn) { - CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + CollisionCheck_SetOC(play, &play->colChkCtx, &this->collider.base); } Actor_SetFocus(&this->actor, height); @@ -518,24 +530,23 @@ void EnCrow_Update(Actor* thisx, GlobalContext* globalCtx) { if ((this->actor.colChkInfo.health != 0) && (Animation_OnFrame(&this->skelAnime, 3.0f))) { Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_KAICHO_FLUTTER); } - if (this->effectAlpha > 0.0f) { - if (this->deathMode != 10) { - Math_StepToF(&this->effectAlpha, 0.0f, 0.05f); - this->steamScale = (this->effectAlpha + 1.0f) * 0.25f; - if (this->steamScale > 0.5f) { - this->steamScale = 0.5f; + if (this->drawDmgEffAlpha > 0.0f) { + if (this->drawDmgEffType != ACTOR_DRAW_DMGEFF_FROZEN_NO_SFX) { + Math_StepToF(&this->drawDmgEffAlpha, 0.0f, 0.05f); + this->drawDmgEffFrozenSteamScale = (this->drawDmgEffAlpha + 1.0f) * 0.25f; + if (this->drawDmgEffFrozenSteamScale > 0.5f) { + this->drawDmgEffFrozenSteamScale = 0.5f; } else { - this->steamScale = this->steamScale; + this->drawDmgEffFrozenSteamScale = this->drawDmgEffFrozenSteamScale; } - } else if (Math_StepToF(&this->effectScale, 0.5f, 0.0125f) == 0) { + } else if (!Math_StepToF(&this->drawDmgEffScale, 0.5f, 0.5f * 0.025f)) { func_800B9010(&this->actor, NA_SE_EV_ICE_FREEZE - SFX_FLAG); } } } -s32 EnCrow_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, - Actor* thisx) { - EnCrow* this = (EnCrow*)thisx; +s32 EnCrow_OverrideLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, Actor* thisx) { + EnCrow* this = THIS; if (this->actor.colChkInfo.health != 0) { if (limbIndex == OBJECT_CROW_LIMB_UPPER_TAIL) { @@ -547,26 +558,24 @@ s32 EnCrow_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList return false; } -void EnCrow_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx) { - EnCrow* this = (EnCrow*)thisx; +void EnCrow_PostLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx) { + EnCrow* this = THIS; if (limbIndex == OBJECT_CROW_LIMB_BODY) { - Matrix_GetStateTranslationAndScaledX(2500.0f, this->bodyPartsPos); - return; - } - if ((limbIndex == OBJECT_CROW_LIMB_RIGHT_WING_TIP) || (limbIndex == OBJECT_CROW_LIMB_LEFT_WING_TIP) || - (limbIndex == OBJECT_CROW_LIMB_TAIL)) { - Matrix_GetStateTranslation(&this->bodyPartsPos[(limbIndex >> 1) - 1]); + Matrix_MultVecX(2500.0f, this->bodyPartsPos); + } else if ((limbIndex == OBJECT_CROW_LIMB_RIGHT_WING_TIP) || (limbIndex == OBJECT_CROW_LIMB_LEFT_WING_TIP) || + (limbIndex == OBJECT_CROW_LIMB_TAIL)) { + Matrix_MultZero(&this->bodyPartsPos[(limbIndex >> 1) - 1]); } } -void EnCrow_Draw(Actor* thisx, GlobalContext* globalCtx) { - EnCrow* this = (EnCrow*)thisx; +void EnCrow_Draw(Actor* thisx, PlayState* play) { + EnCrow* this = THIS; - func_8012C28C(globalCtx->state.gfxCtx); - SkelAnime_DrawFlexOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, + func_8012C28C(play->state.gfxCtx); + SkelAnime_DrawFlexOpa(play, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, EnCrow_OverrideLimbDraw, EnCrow_PostLimbDraw, &this->actor); - Actor_DrawDamageEffects(globalCtx, &this->actor, this->bodyPartsPos, ARRAY_COUNT(this->bodyPartsPos), - this->actor.scale.x * 100.0f * this->steamScale, this->effectScale, this->effectAlpha, - this->deathMode); + Actor_DrawDamageEffects(play, &this->actor, this->bodyPartsPos, ARRAY_COUNT(this->bodyPartsPos), + this->actor.scale.x * 100.0f * this->drawDmgEffFrozenSteamScale, this->drawDmgEffScale, + this->drawDmgEffAlpha, this->drawDmgEffType); } diff --git a/src/overlays/actors/ovl_En_Crow/z_en_crow.h b/src/overlays/actors/ovl_En_Crow/z_en_crow.h index 9076a198c..86ffba903 100644 --- a/src/overlays/actors/ovl_En_Crow/z_en_crow.h +++ b/src/overlays/actors/ovl_En_Crow/z_en_crow.h @@ -4,26 +4,31 @@ #include "global.h" #include "objects/object_crow/object_crow.h" +typedef enum { + /* 0 */ GUAY_TYPE_NORMAL, + /* 1 */ GUAY_TYPE_MEGA +} GuayType; + struct EnCrow; -typedef void (*EnCrowActionFunc)(struct EnCrow*, GlobalContext*); +typedef void (*EnCrowActionFunc)(struct EnCrow*, PlayState*); typedef struct EnCrow { - /* 0x0000 */ Actor actor; - /* 0x0144 */ SkelAnime skelAnime; - /* 0x0188 */ EnCrowActionFunc actionFunc; - /* 0x18C */ u8 deathMode; + /* 0x000 */ Actor actor; + /* 0x144 */ SkelAnime skelAnime; + /* 0x188 */ EnCrowActionFunc actionFunc; + /* 0x18C */ u8 drawDmgEffType; /* 0x18E */ s16 timer; - /* 0x190 */ s16 aimRotX; - /* 0x192 */ s16 aimRotY; + /* 0x190 */ s16 pitchTarget; + /* 0x192 */ s16 yawTarget; /* 0x194 */ Vec3s jointTable[OBJECT_CROW_LIMB_MAX]; /* 0x1CA */ Vec3s morphTable[OBJECT_CROW_LIMB_MAX]; /* 0x200 */ ColliderJntSph collider; /* 0x220 */ ColliderJntSphElement colliderItems[1]; /* 0x260 */ Vec3f bodyPartsPos[4]; - /* 0x290 */ f32 effectAlpha; - /* 0x294 */ f32 steamScale; - /* 0x298 */ f32 effectScale; + /* 0x290 */ f32 drawDmgEffAlpha; + /* 0x294 */ f32 drawDmgEffFrozenSteamScale; + /* 0x298 */ f32 drawDmgEffScale; } EnCrow; // size = 0x29C extern const ActorInit En_Crow_InitVars; diff --git a/src/overlays/actors/ovl_En_Dai/z_en_dai.c b/src/overlays/actors/ovl_En_Dai/z_en_dai.c index bd7de1418..4f8d5eaaa 100644 --- a/src/overlays/actors/ovl_En_Dai/z_en_dai.c +++ b/src/overlays/actors/ovl_En_Dai/z_en_dai.c @@ -11,13 +11,13 @@ #define THIS ((EnDai*)thisx) -void EnDai_Init(Actor* thisx, GlobalContext* globalCtx); -void EnDai_Destroy(Actor* thisx, GlobalContext* globalCtx); -void EnDai_Update(Actor* thisx, GlobalContext* globalCtx); -void EnDai_Draw(Actor* thisx, GlobalContext* globalCtx); +void EnDai_Init(Actor* thisx, PlayState* play); +void EnDai_Destroy(Actor* thisx, PlayState* play); +void EnDai_Update(Actor* thisx, PlayState* play); +void EnDai_Draw(Actor* thisx, PlayState* play); -void func_80B3F00C(EnDai* this, GlobalContext* globalCtx); -void func_80B3EF90(EnDai* this, GlobalContext* globalCtx); +void func_80B3F00C(EnDai* this, PlayState* play); +void func_80B3EF90(EnDai* this, PlayState* play); const ActorInit En_Dai_InitVars = { ACTOR_EN_DAI, @@ -33,40 +33,39 @@ 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) { - GlobalContext* globalCtx = globalCtx2; +void func_80B3E168(EnDaiEffect* effect, PlayState* play2) { + PlayState* play = play2; s32 pad; s32 isDisplayListSet = false; s32 i; f32 alpha; - OPEN_DISPS(globalCtx->state.gfxCtx); + OPEN_DISPS(play->state.gfxCtx); - func_8012C2DC(globalCtx->state.gfxCtx); + func_8012C2DC(play->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,63 +73,62 @@ 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(play->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(&play->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); + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_XLU_DISP++, object_dai_DL_0002E8); - Matrix_StatePop(); + Matrix_Pop(); } } - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->state.gfxCtx); } 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; } } return count; } -s32 func_80B3E5B4(EnDai* this, GlobalContext* globalCtx) { - func_80B3E168(this->particles, globalCtx); +s32 func_80B3E5B4(EnDai* this, PlayState* play) { + func_80B3E168(this->effects, play); return 0; } s32 func_80B3E5DC(EnDai* this, s32 arg1) { - static AnimationInfoS D_80B3FBFC[] = { + static AnimationInfoS sAnimationInfo[] = { { &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 }, @@ -169,19 +167,19 @@ s32 func_80B3E5DC(EnDai* this, s32 arg1) { if (phi_v1) { this->unk_A70 = arg1; - ret = SubS_ChangeAnimationByInfoS(&this->skelAnime, D_80B3FBFC, arg1); + ret = SubS_ChangeAnimationByInfoS(&this->skelAnime, sAnimationInfo, arg1); } return ret; } -s32 func_80B3E69C(EnDai* this, GlobalContext* globalCtx) { +s32 func_80B3E69C(EnDai* this, PlayState* play) { s32 ret = false; - if ((globalCtx->csCtx.state != 0) && (globalCtx->sceneNum == SCENE_12HAKUGINMAE) && - (globalCtx->csCtx.currentCsIndex == 0) && !(gSaveContext.save.weekEventReg[30] & 1)) { + if ((play->csCtx.state != 0) && (play->sceneNum == SCENE_12HAKUGINMAE) && (play->csCtx.currentCsIndex == 0) && + !(gSaveContext.save.weekEventReg[30] & 1)) { if (!(this->unk_1CE & 0x10)) { - Flags_SetSwitch(globalCtx, 20); + Flags_SetSwitch(play, 20); this->unk_1CE |= (0x80 | 0x10); this->unk_1CE &= ~(0x100 | 0x20); this->unk_1CC = 0xFF; @@ -201,11 +199,11 @@ s32 func_80B3E69C(EnDai* this, GlobalContext* globalCtx) { return ret; } -s32 func_80B3E7C8(EnDai* this, GlobalContext* globalCtx) { +s32 func_80B3E7C8(EnDai* this, PlayState* play) { s32 ret = false; if (this->unk_1CE & 7) { - if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { + if (Actor_ProcessTalkRequest(&this->actor, &play->state)) { SubS_UpdateFlags(&this->unk_1CE, 0, 7); this->actionFunc = func_80B3EF90; ret = true; @@ -278,7 +276,7 @@ s16 func_80B3E8BC(EnDai* this, s32 arg1) { return this->unk_1D6; } -s32 func_80B3E96C(EnDai* this, GlobalContext* globalCtx) { +s32 func_80B3E96C(EnDai* this, PlayState* play) { Vec3f sp74; Vec3f sp68; Vec3f sp5C; @@ -294,7 +292,7 @@ s32 func_80B3E96C(EnDai* this, GlobalContext* globalCtx) { case 1: Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_SNOWSTORM_HARD); - Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_WEATHER_TAG, this->actor.world.pos.x, + Actor_Spawn(&play->actorCtx, play, ACTOR_EN_WEATHER_TAG, this->actor.world.pos.x, this->actor.world.pos.y, this->actor.world.pos.z, 0x1388, 0x708, 0x3E8, 0); func_80B3E5DC(this, 3); this->unk_1DC++; @@ -325,7 +323,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; @@ -400,7 +398,7 @@ s32 func_80B3ED88(EnDai* this) { return ret; } -void func_80B3EE8C(EnDai* this, GlobalContext* globalCtx) { +void func_80B3EE8C(EnDai* this, PlayState* play) { s16 cutscene = this->actor.cutscene; if (ActorCutscene_GetCanPlayNext(cutscene)) { @@ -410,15 +408,15 @@ void func_80B3EE8C(EnDai* this, GlobalContext* globalCtx) { } } -void func_80B3EEDC(EnDai* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); +void func_80B3EEDC(EnDai* this, PlayState* play) { + Player* player = GET_PLAYER(play); - if ((player->transformation == PLAYER_FORM_GORON) && (globalCtx->msgCtx.ocarinaMode == 3) && - (globalCtx->msgCtx.unk1202E == 1)) { + if ((player->transformation == PLAYER_FORM_GORON) && (play->msgCtx.ocarinaMode == 3) && + (play->msgCtx.lastPlayedSong == OCARINA_SONG_GORON_LULLABY)) { func_80B3E5DC(this, 1); this->actionFunc = func_80B3EE8C; } else if (!(player->stateFlags2 & 0x08000000)) { - func_80B3E96C(this, globalCtx); + func_80B3E96C(this, play); this->unk_A6C = 0; } else if (this->unk_A6C == 0) { play_sound(NA_SE_SY_TRE_BOX_APPEAR); @@ -426,8 +424,8 @@ 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)) { +void func_80B3EF90(EnDai* this, PlayState* play) { + if (func_8010BF58(&this->actor, play, D_80B3FC8C, NULL, &this->unk_1D0)) { SubS_UpdateFlags(&this->unk_1CE, 3, 7); this->unk_1D0 = 0; this->actionFunc = func_80B3F00C; @@ -436,20 +434,20 @@ void func_80B3EF90(EnDai* this, GlobalContext* globalCtx) { } } -void func_80B3F00C(EnDai* this, GlobalContext* globalCtx) { +void func_80B3F00C(EnDai* this, PlayState* play) { Math_ApproachS(&this->actor.shape.rot.y, this->actor.world.rot.y, 3, 0x2AA8); } -void func_80B3F044(EnDai* this, GlobalContext* globalCtx) { +void func_80B3F044(EnDai* this, PlayState* play) { static s32 D_80B3FE38[] = { 0, 0, 6, 7, 8, }; s32 sp2C = 0; s32 sp28; - if (Cutscene_CheckActorAction(globalCtx, 472)) { - sp2C = Cutscene_GetActorActionIndex(globalCtx, 472); - sp28 = globalCtx->csCtx.actorActions[sp2C]->action; + if (Cutscene_CheckActorAction(play, 472)) { + sp2C = Cutscene_GetActorActionIndex(play, 472); + sp28 = play->csCtx.actorActions[sp2C]->action; if (this->unk_1CC != (u8)sp28) { func_80B3E5DC(this, D_80B3FE38[sp28]); switch (sp28) { @@ -480,7 +478,7 @@ void func_80B3F044(EnDai* this, GlobalContext* globalCtx) { break; case 2: - if (globalCtx->csCtx.frames == 360) { + if (play->csCtx.frames == 360) { Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_DAIGOLON_SLEEP3 - SFX_FLAG); } if (Animation_OnFrame(&this->skelAnime, 43.0f)) { @@ -507,15 +505,14 @@ void func_80B3F044(EnDai* this, GlobalContext* globalCtx) { break; } - Cutscene_ActorTranslateAndYaw(&this->actor, globalCtx, sp2C); + Cutscene_ActorTranslateAndYaw(&this->actor, play, sp2C); } -void EnDai_Init(Actor* thisx, GlobalContext* globalCtx) { +void EnDai_Init(Actor* thisx, PlayState* play) { EnDai* this = THIS; ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 0.0f); - SkelAnime_InitFlex(globalCtx, &this->skelAnime, &object_dai_Skel_0130D0, NULL, this->jointTable, this->morphTable, - 19); + SkelAnime_InitFlex(play, &this->skelAnime, &object_dai_Skel_0130D0, NULL, this->jointTable, this->morphTable, 19); this->unk_A70 = -1; func_80B3E5DC(this, 0); Actor_SetScale(&this->actor, 0.2f); @@ -545,33 +542,33 @@ void EnDai_Init(Actor* thisx, GlobalContext* globalCtx) { this->actionFunc = func_80B3EEDC; } -void EnDai_Destroy(Actor* thisx, GlobalContext* globalCtx) { +void EnDai_Destroy(Actor* thisx, PlayState* play) { } -void EnDai_Update(Actor* thisx, GlobalContext* globalCtx) { +void EnDai_Update(Actor* thisx, PlayState* play) { EnDai* this = THIS; s32 pad; - Player* player = GET_PLAYER(globalCtx); + Player* player = GET_PLAYER(play); - if (!func_80B3E7C8(this, globalCtx) && func_80B3E69C(this, globalCtx)) { - func_80B3F044(this, globalCtx); + if (!func_80B3E7C8(this, play) && func_80B3E69C(this, play)) { + func_80B3F044(this, play); SkelAnime_Update(&this->skelAnime); func_80B3E834(this); func_80B3E460(this); } else { - this->actionFunc(this, globalCtx); + this->actionFunc(this, play); if (!(player->stateFlags2 & 0x8000000)) { 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, play, 0.0f, 0.0f, PLAYER_AP_NONE, this->unk_1CE & 7); } func_80B3E460(this); } } } -s32 EnDai_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, Actor* thisx, +s32 EnDai_OverrideLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, Actor* thisx, Gfx** gfx) { EnDai* this = THIS; @@ -580,7 +577,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) { @@ -590,7 +587,7 @@ s32 EnDai_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, return false; } -void EnDai_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx, Gfx** gfx) { +void EnDai_PostLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx, Gfx** gfx) { static Vec3f D_80B3FE4C = { 0.0f, 0.0f, 0.0f }; EnDai* this = THIS; @@ -602,20 +599,20 @@ 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; } } -void EnDai_TransformLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Actor* thisx, Gfx** gfx) { +void EnDai_TransformLimbDraw(PlayState* play, s32 limbIndex, Actor* thisx, Gfx** gfx) { EnDai* this = THIS; switch (limbIndex) { @@ -635,45 +632,45 @@ void EnDai_TransformLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Actor* thi } } -void func_80B3F78C(EnDai* this, GlobalContext* globalCtx) { +void func_80B3F78C(EnDai* this, PlayState* play) { static TexturePtr D_80B3FE58[] = { object_dai_Tex_0107B0, object_dai_Tex_010FB0, object_dai_Tex_0117B0, object_dai_Tex_010FB0, object_dai_Tex_011FB0, object_dai_Tex_0127B0, }; s32 pad; - if (globalCtx->actorCtx.unkB != 0) { + if (play->actorCtx.unkB != 0) { this->unk_1CE |= 0x40; } else { - Actor_RecordUndrawnActor(globalCtx, &this->actor); + Actor_RecordUndrawnActor(play, &this->actor); this->unk_1CE &= ~0x40; } - func_8012C2DC(globalCtx->state.gfxCtx); + func_8012C2DC(play->state.gfxCtx); - OPEN_DISPS(globalCtx->state.gfxCtx); + OPEN_DISPS(play->state.gfxCtx); - Scene_SetRenderModeXlu(globalCtx, 2, 2); + Scene_SetRenderModeXlu(play, 2, 2); gDPSetEnvColor(POLY_XLU_DISP++, 0, 0, 0, 255); gSPSegment(POLY_XLU_DISP++, 0x08, Lib_SegmentedToVirtual(D_80B3FE58[this->unk_1D6])); - POLY_XLU_DISP = SubS_DrawTransformFlex(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, + POLY_XLU_DISP = SubS_DrawTransformFlex(play, this->skelAnime.skeleton, this->skelAnime.jointTable, 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); + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_XLU_DISP++, object_dai_DL_00C538); } - func_80B3E5B4(this, globalCtx); + func_80B3E5B4(this, play); - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->state.gfxCtx); } -void func_80B3F920(EnDai* this, GlobalContext* globalCtx) { +void func_80B3F920(EnDai* this, PlayState* play) { static TexturePtr D_80B3FE70[] = { object_dai_Tex_0107B0, object_dai_Tex_010FB0, object_dai_Tex_0117B0, object_dai_Tex_010FB0, object_dai_Tex_011FB0, object_dai_Tex_0127B0, @@ -683,55 +680,55 @@ void func_80B3F920(EnDai* this, GlobalContext* globalCtx) { this->unk_1CE |= 0x40; if (this->unk_1CD == 0xFF) { - func_8012C28C(globalCtx->state.gfxCtx); + func_8012C28C(play->state.gfxCtx); - OPEN_DISPS(globalCtx->state.gfxCtx); + OPEN_DISPS(play->state.gfxCtx); - Scene_SetRenderModeXlu(globalCtx, 0, 1); + Scene_SetRenderModeXlu(play, 0, 1); gSPSegment(POLY_OPA_DISP++, 0x08, Lib_SegmentedToVirtual(D_80B3FE70[this->unk_1D6])); - POLY_OPA_DISP = SubS_DrawTransformFlex(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, + POLY_OPA_DISP = SubS_DrawTransformFlex(play, 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); + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_OPA_DISP++, object_dai_DL_00C538); - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->state.gfxCtx); } else { - func_8012C2DC(globalCtx->state.gfxCtx); + func_8012C2DC(play->state.gfxCtx); - OPEN_DISPS(globalCtx->state.gfxCtx); + OPEN_DISPS(play->state.gfxCtx); - Scene_SetRenderModeXlu(globalCtx, 2, 2); + Scene_SetRenderModeXlu(play, 2, 2); gDPSetEnvColor(POLY_XLU_DISP++, 0, 0, 0, this->unk_1CD); gSPSegment(POLY_XLU_DISP++, 0x08, Lib_SegmentedToVirtual(D_80B3FE70[this->unk_1D6])); - POLY_XLU_DISP = SubS_DrawTransformFlex(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, + POLY_XLU_DISP = SubS_DrawTransformFlex(play, 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); + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_XLU_DISP++, object_dai_DL_00C538); - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->state.gfxCtx); } - func_80B3E5B4(this, globalCtx); + func_80B3E5B4(this, play); } -void EnDai_Draw(Actor* thisx, GlobalContext* globalCtx) { +void EnDai_Draw(Actor* thisx, PlayState* play) { EnDai* this = THIS; if (!(this->unk_1CE & 0x200)) { if (this->unk_1CE & 0x20) { - func_80B3F78C(this, globalCtx); + func_80B3F78C(this, play); } else { - func_80B3F920(this, globalCtx); + func_80B3F920(this, play); } } } 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..0b0316d05 100644 --- a/src/overlays/actors/ovl_En_Dai/z_en_dai.h +++ b/src/overlays/actors/ovl_En_Dai/z_en_dai.h @@ -5,9 +5,9 @@ struct EnDai; -typedef void (*EnDaiActionFunc)(struct EnDai*, GlobalContext*); +typedef void (*EnDaiActionFunc)(struct EnDai*, PlayState*); -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 3d76b7391..45777c681 100644 --- a/src/overlays/actors/ovl_En_Daiku/z_en_daiku.c +++ b/src/overlays/actors/ovl_En_Daiku/z_en_daiku.c @@ -11,15 +11,15 @@ #define THIS ((EnDaiku*)thisx) -void EnDaiku_Init(Actor* thisx, GlobalContext* globalCtx); -void EnDaiku_Destroy(Actor* thisx, GlobalContext* globalCtx); -void EnDaiku_Update(Actor* thisx, GlobalContext* globalCtx); -void EnDaiku_Draw(Actor* thisx, GlobalContext* globalCtx); +void EnDaiku_Init(Actor* thisx, PlayState* play); +void EnDaiku_Destroy(Actor* thisx, PlayState* play); +void EnDaiku_Update(Actor* thisx, PlayState* play); +void EnDaiku_Draw(Actor* thisx, PlayState* play); void func_80943820(EnDaiku* this); void func_80943BC0(EnDaiku* this); -void func_80943BDC(EnDaiku* this, GlobalContext* globalCtx); -void func_809438F8(EnDaiku* this, GlobalContext* globalCtx); +void func_80943BDC(EnDaiku* this, PlayState* play); +void func_809438F8(EnDaiku* this, PlayState* play); const ActorInit En_Daiku_InitVars = { ACTOR_EN_DAIKU, @@ -57,17 +57,28 @@ static ColliderCylinderInit sCylinderInit = { { 20, 60, 0, { 0, 0, 0 } }, }; -void EnDaiku_Init(Actor* thisx, GlobalContext* globalCtx) { +static AnimationHeader* sAnimations[] = { + &object_daiku_Anim_002FA0, &object_daiku_Anim_00ACD0, &object_daiku_Anim_00C92C, + &object_daiku_Anim_000C44, &object_daiku_Anim_00C234, &object_daiku_Anim_000600, + &object_daiku_Anim_001114, &object_daiku_Anim_00B690, &object_daiku_Anim_00BEAC, +}; + +static u8 sAnimationModes[] = { + ANIMMODE_LOOP, ANIMMODE_LOOP, ANIMMODE_LOOP, ANIMMODE_LOOP, ANIMMODE_ONCE, + ANIMMODE_LOOP, ANIMMODE_LOOP, ANIMMODE_ONCE, ANIMMODE_ONCE, +}; + +void EnDaiku_Init(Actor* thisx, PlayState* play) { EnDaiku* this = THIS; this->actor.colChkInfo.mass = MASS_IMMOVABLE; ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 40.0f); this->actor.targetMode = 0; - Collider_InitAndSetCylinder(globalCtx, &this->collider, &this->actor, &sCylinderInit); + Collider_InitAndSetCylinder(play, &this->collider, &this->actor, &sCylinderInit); 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 = SubS_GetPathByIndex(globalCtx, this->unk_288, 0x3F); + this->unk_258 = SubS_GetPathByIndex(play, this->unk_288, 0x3F); } else if (this->unk_278 == ENDAIKU_PARAMS_FF_2) { this->unk_264 = -2000; } @@ -94,17 +105,17 @@ void EnDaiku_Init(Actor* thisx, GlobalContext* globalCtx) { this->unk_27E = this->unk_278 * 4 + 4; case ENDAIKU_PARAMS_FF_1: - SkelAnime_InitFlex(globalCtx, &this->skelAnime, &object_daiku_Skel_00A850, &object_daiku_Anim_002FA0, + SkelAnime_InitFlex(play, &this->skelAnime, &object_daiku_Skel_00A850, &object_daiku_Anim_002FA0, this->jointTable, this->morphTable, 17); break; case ENDAIKU_PARAMS_FF_2: - SkelAnime_InitFlex(globalCtx, &this->skelAnime, &object_daiku_Skel_00A850, &object_daiku_Anim_00B690, + SkelAnime_InitFlex(play, &this->skelAnime, &object_daiku_Skel_00A850, &object_daiku_Anim_00B690, this->jointTable, this->morphTable, 17); break; case ENDAIKU_PARAMS_FF_3: - SkelAnime_InitFlex(globalCtx, &this->skelAnime, &object_daiku_Skel_00A850, &object_daiku_Anim_001114, + SkelAnime_InitFlex(play, &this->skelAnime, &object_daiku_Skel_00A850, &object_daiku_Anim_001114, this->jointTable, this->morphTable, 17); break; } @@ -112,24 +123,15 @@ void EnDaiku_Init(Actor* thisx, GlobalContext* globalCtx) { func_80943820(this); } -void EnDaiku_Destroy(Actor* thisx, GlobalContext* globalCtx) { +void EnDaiku_Destroy(Actor* thisx, PlayState* play) { EnDaiku* this = THIS; - Collider_DestroyCylinder(globalCtx, &this->collider); + Collider_DestroyCylinder(play, &this->collider); } void func_8094373C(EnDaiku* this, s32 arg1) { - static AnimationHeader* D_809440A4[] = { - &object_daiku_Anim_002FA0, &object_daiku_Anim_00ACD0, &object_daiku_Anim_00C92C, - &object_daiku_Anim_000C44, &object_daiku_Anim_00C234, &object_daiku_Anim_000600, - &object_daiku_Anim_001114, &object_daiku_Anim_00B690, &object_daiku_Anim_00BEAC, - }; - static u8 D_809440C8[] = { - 0, 0, 0, 0, 2, 0, 0, 2, 2, - }; - - this->unk_284 = Animation_GetLastFrame(D_809440A4[arg1]); - Animation_Change(&this->skelAnime, D_809440A4[arg1], 1.0f, 0.0f, this->unk_284, D_809440C8[arg1], -4.0f); + this->unk_284 = Animation_GetLastFrame(sAnimations[arg1]); + Animation_Change(&this->skelAnime, sAnimations[arg1], 1.0f, 0.0f, this->unk_284, sAnimationModes[arg1], -4.0f); } void func_809437C8(EnDaiku* this) { @@ -165,13 +167,13 @@ void func_80943820(EnDaiku* this) { this->actionFunc = func_809438F8; } -void func_809438F8(EnDaiku* this, GlobalContext* globalCtx) { +void func_809438F8(EnDaiku* this, PlayState* play) { f32 currentFrame = this->skelAnime.curFrame; s32 pad; s32 day = gSaveContext.save.day - 1; s32 pad2; - if (Player_GetMask(globalCtx) == PLAYER_MASK_KAFEIS_MASK) { + if (Player_GetMask(play) == PLAYER_MASK_KAFEIS_MASK) { if (this->unk_278 == ENDAIKU_PARAMS_FF_1) { this->actor.textId = 0x2365; } else { @@ -182,7 +184,7 @@ void func_809438F8(EnDaiku* this, GlobalContext* globalCtx) { this->actor.textId = sTextIds[this->unk_28C]; } - if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { + if (Actor_ProcessTalkRequest(&this->actor, &play->state)) { func_80943BC0(this); return; } @@ -221,7 +223,7 @@ void func_809438F8(EnDaiku* this, GlobalContext* globalCtx) { s16 angle = ABS_ALT(BINANG_SUB(this->actor.yawTowardsPlayer, this->actor.world.rot.y)); this->unk_280 = this->actor.yawTowardsPlayer; if ((this->unk_278 == ENDAIKU_PARAMS_FF_1) || (this->unk_278 == ENDAIKU_PARAMS_FF_2) || (angle <= 0x2890)) { - func_800B8614(&this->actor, globalCtx, 100.0f); + func_800B8614(&this->actor, play, 100.0f); } } } @@ -231,7 +233,7 @@ void func_80943BC0(EnDaiku* this) { this->actionFunc = func_80943BDC; } -void func_80943BDC(EnDaiku* this, GlobalContext* globalCtx) { +void func_80943BDC(EnDaiku* this, PlayState* play) { f32 currentFrame = this->skelAnime.curFrame; if ((this->unk_278 == ENDAIKU_PARAMS_FF_2) && (this->unk_284 <= currentFrame)) { @@ -242,13 +244,13 @@ void func_80943BDC(EnDaiku* this, GlobalContext* globalCtx) { } } - if ((Message_GetState(&globalCtx->msgCtx) == 5) && Message_ShouldAdvance(globalCtx)) { - func_801477B4(globalCtx); + if ((Message_GetState(&play->msgCtx) == TEXT_STATE_5) && Message_ShouldAdvance(play)) { + func_801477B4(play); func_80943820(this); } } -void EnDaiku_Update(Actor* thisx, GlobalContext* globalCtx) { +void EnDaiku_Update(Actor* thisx, PlayState* play) { EnDaiku* this = THIS; s32 pad; @@ -261,7 +263,7 @@ void EnDaiku_Update(Actor* thisx, GlobalContext* globalCtx) { return; } - this->actionFunc(this, globalCtx); + this->actionFunc(this, play); if (this->unk_27C != 0) { this->unk_27C--; @@ -277,14 +279,13 @@ void EnDaiku_Update(Actor* thisx, GlobalContext* globalCtx) { Actor_MoveWithGravity(&this->actor); Math_SmoothStepToS(&this->unk_260, this->unk_266, 1, 0xBB8, 0); Math_SmoothStepToS(&this->unk_25E, this->unk_264, 1, 0xBB8, 0); - Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 20.0f, 20.0f, 50.0f, 0x1D); + Actor_UpdateBgCheckInfo(play, &this->actor, 20.0f, 20.0f, 50.0f, 0x1D); this->actor.uncullZoneForward = 650.0f; Collider_UpdateCylinder(&this->actor, &this->collider); - CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + CollisionCheck_SetOC(play, &play->colChkCtx, &this->collider.base); } -s32 EnDaiku_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, - Actor* thisx) { +s32 EnDaiku_OverrideLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, Actor* thisx) { EnDaiku* this = THIS; if (limbIndex == 15) { @@ -295,7 +296,7 @@ s32 EnDaiku_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dLis return false; } -void EnDaiku_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx) { +void EnDaiku_PostLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx) { static Gfx* D_809440D4[] = { object_daiku_DL_0070C0, object_daiku_DL_006FB0, @@ -304,7 +305,7 @@ void EnDaiku_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, }; EnDaiku* this = THIS; - OPEN_DISPS(globalCtx->state.gfxCtx); + OPEN_DISPS(play->state.gfxCtx); if (limbIndex == 15) { gSPDisplayList(POLY_OPA_DISP++, D_809440D4[this->unk_278]); @@ -314,15 +315,15 @@ void EnDaiku_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, gSPDisplayList(POLY_OPA_DISP++, object_daiku_DL_008EC8); } - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->state.gfxCtx); } -void EnDaiku_Draw(Actor* thisx, GlobalContext* globalCtx) { +void EnDaiku_Draw(Actor* thisx, PlayState* play) { EnDaiku* this = THIS; - OPEN_DISPS(globalCtx->state.gfxCtx); + OPEN_DISPS(play->state.gfxCtx); - func_8012C28C(globalCtx->state.gfxCtx); + func_8012C28C(play->state.gfxCtx); switch (this->unk_278) { case 0: @@ -346,8 +347,8 @@ void EnDaiku_Draw(Actor* thisx, GlobalContext* globalCtx) { break; } - SkelAnime_DrawFlexOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, + SkelAnime_DrawFlexOpa(play, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, EnDaiku_OverrideLimbDraw, EnDaiku_PostLimbDraw, &this->actor); - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->state.gfxCtx); } diff --git a/src/overlays/actors/ovl_En_Daiku/z_en_daiku.h b/src/overlays/actors/ovl_En_Daiku/z_en_daiku.h index 01395648d..4f93b3ea1 100644 --- a/src/overlays/actors/ovl_En_Daiku/z_en_daiku.h +++ b/src/overlays/actors/ovl_En_Daiku/z_en_daiku.h @@ -5,7 +5,7 @@ struct EnDaiku; -typedef void (*EnDaikuActionFunc)(struct EnDaiku*, GlobalContext*); +typedef void (*EnDaikuActionFunc)(struct EnDaiku*, PlayState*); #define ENDAIKU_GET_FF(thisx) ((thisx)->params & 0xFF); #define ENDAIKU_GET_FF00(thisx) (((thisx)->params >> 8) & 0xFF); 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 64a8c3d9b..b7b46b5af 100644 --- a/src/overlays/actors/ovl_En_Daiku2/z_en_daiku2.c +++ b/src/overlays/actors/ovl_En_Daiku2/z_en_daiku2.c @@ -13,24 +13,24 @@ #define THIS ((EnDaiku2*)thisx) -void EnDaiku2_Init(Actor* thisx, GlobalContext* globalCtx); -void EnDaiku2_Destroy(Actor* thisx, GlobalContext* globalCtx); -void EnDaiku2_Update(Actor* thisx, GlobalContext* globalCtx); -void EnDaiku2_Draw(Actor* thisx, GlobalContext* globalCtx); +void EnDaiku2_Init(Actor* thisx, PlayState* play); +void EnDaiku2_Destroy(Actor* thisx, PlayState* play); +void EnDaiku2_Update(Actor* thisx, PlayState* play); +void EnDaiku2_Draw(Actor* thisx, PlayState* play); -void func_80BE65B4(EnDaiku2* this, GlobalContext* globalCtx); -void func_80BE66E4(EnDaiku2* this, GlobalContext* globalCtx); -void func_80BE6B40(EnDaiku2* this, GlobalContext* globalCtx); -void func_80BE6BC0(EnDaiku2* this, GlobalContext* globalCtx); +void func_80BE65B4(EnDaiku2* this, PlayState* play); +void func_80BE66E4(EnDaiku2* this, PlayState* play); +void func_80BE6B40(EnDaiku2* this, PlayState* play); +void func_80BE6BC0(EnDaiku2* this, PlayState* play); void func_80BE6CFC(EnDaiku2* this); -void func_80BE6D40(EnDaiku2* this, GlobalContext* globalCtx); +void func_80BE6D40(EnDaiku2* this, PlayState* play); void func_80BE6EB0(EnDaiku2* this); -void func_80BE6EF0(EnDaiku2* this, GlobalContext* globalCtx); -void func_80BE7600(EnDaiku2* this, GlobalContext* globalCtx); +void func_80BE6EF0(EnDaiku2* this, PlayState* play); +void func_80BE7600(EnDaiku2* this, PlayState* play); void func_80BE71A0(EnDaiku2* this); -void func_80BE71D8(EnDaiku2* this, GlobalContext* globalCtx); +void func_80BE71D8(EnDaiku2* this, PlayState* play); void func_80BE7504(EnDaiku2* this, Vec3f* arg1, Vec3f* arg2, Vec3f* arg3, f32 arg4, s16 arg5); -void func_80BE7718(EnDaiku2* this, GlobalContext* globalCtx); +void func_80BE7718(EnDaiku2* this, PlayState* play); const ActorInit En_Daiku2_InitVars = { ACTOR_EN_DAIKU2, @@ -76,19 +76,19 @@ void func_80BE61D0(EnDaiku2* this) { } } -void EnDaiku2_Init(Actor* thisx, GlobalContext* globalCtx) { +void EnDaiku2_Init(Actor* thisx, PlayState* play) { EnDaiku2* this = THIS; s32 day = gSaveContext.save.day; this->actor.colChkInfo.mass = MASS_IMMOVABLE; ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 40.0f); - SkelAnime_InitFlex(globalCtx, &this->skelAnime, &object_daiku_Skel_00A850, &object_daiku_Anim_002FA0, - this->jointTable, this->morphTable, 17); + SkelAnime_InitFlex(play, &this->skelAnime, &object_daiku_Skel_00A850, &object_daiku_Anim_002FA0, this->jointTable, + this->morphTable, 17); this->actor.targetMode = 0; - Collider_InitAndSetCylinder(globalCtx, &this->collider, &this->actor, &sCylinderInit); + Collider_InitAndSetCylinder(play, &this->collider, &this->actor, &sCylinderInit); this->unk_278 = ENDAIKU2_GET_7F(&this->actor); this->unk_27A = ENDAIKU2_GET_1F80(&this->actor); - this->unk_258 = SubS_GetPathByIndex(globalCtx, this->unk_27A, 0x3F); + this->unk_258 = SubS_GetPathByIndex(play, this->unk_27A, 0x3F); this->unk_280 = ENDAIKU2_GET_8000(&this->actor); Actor_SetScale(&this->actor, 0.01f); if (!this->unk_280) { @@ -99,7 +99,7 @@ void EnDaiku2_Init(Actor* thisx, GlobalContext* globalCtx) { if (this->unk_278 == ENDAIKU2_GET_7F_127) { this->unk_278 = ENDAIKU2_GET_7F_MINUS1; - } else if (Flags_GetSwitch(globalCtx, this->unk_278)) { + } else if (Flags_GetSwitch(play, this->unk_278)) { this->unk_25C = this->unk_258->count - 1; func_80BE61D0(this); Math_Vec3f_Copy(&this->actor.world.pos, &this->unk_268); @@ -111,13 +111,13 @@ void EnDaiku2_Init(Actor* thisx, GlobalContext* globalCtx) { this->actor.gravity = -3.0f; Math_Vec3f_Copy(&this->unk_268, &this->actor.world.pos); - func_80BE65B4(this, globalCtx); + func_80BE65B4(this, play); } -void EnDaiku2_Destroy(Actor* thisx, GlobalContext* globalCtx) { +void EnDaiku2_Destroy(Actor* thisx, PlayState* play) { EnDaiku2* this = THIS; - Collider_DestroyCylinder(globalCtx, &this->collider); + Collider_DestroyCylinder(play, &this->collider); } void func_80BE6408(EnDaiku2* this, s32 arg1) { @@ -127,7 +127,8 @@ void func_80BE6408(EnDaiku2* this, s32 arg1) { &object_daiku_Anim_001A24, &object_daiku_Anim_002134, &object_daiku_Anim_00D328, }; static u8 D_80BE7958[] = { - 0, 0, 0, 0, 2, 0, 0, 0, 0, 2, 0, + ANIMMODE_LOOP, ANIMMODE_LOOP, ANIMMODE_LOOP, ANIMMODE_LOOP, ANIMMODE_ONCE, ANIMMODE_LOOP, + ANIMMODE_LOOP, ANIMMODE_LOOP, ANIMMODE_LOOP, ANIMMODE_ONCE, ANIMMODE_LOOP, }; f32 sp34 = 1.0f; @@ -140,15 +141,15 @@ void func_80BE6408(EnDaiku2* this, s32 arg1) { -4.0f); } -s32 func_80BE64C0(EnDaiku2* this, GlobalContext* globalCtx) { +s32 func_80BE64C0(EnDaiku2* this, PlayState* play) { EnBom* bomb; Vec3f sp30; Math_Vec3f_Copy(&sp30, &this->actor.world.pos); Math_Vec3f_Copy(&this->actor.world.pos, &this->actor.home.pos); - bomb = (EnBom*)Actor_FindNearby(globalCtx, &this->actor, -1, ACTORCAT_EXPLOSIVES, BREG(7) + 240.0f); + bomb = (EnBom*)Actor_FindNearby(play, &this->actor, -1, ACTORCAT_EXPLOSIVES, BREG(7) + 240.0f); Math_Vec3f_Copy(&this->actor.world.pos, &sp30); - if ((this->unk_278 >= ENDAIKU2_GET_7F_0) && !Flags_GetSwitch(globalCtx, this->unk_278) && (bomb != NULL) && + if ((this->unk_278 >= ENDAIKU2_GET_7F_0) && !Flags_GetSwitch(play, this->unk_278) && (bomb != NULL) && (bomb->actor.id == ACTOR_EN_BOM)) { if (!bomb->isPowderKeg) { this->actor.textId = 0x32D3; @@ -162,7 +163,7 @@ s32 func_80BE64C0(EnDaiku2* this, GlobalContext* globalCtx) { return false; } -void func_80BE65B4(EnDaiku2* this, GlobalContext* globalCtx) { +void func_80BE65B4(EnDaiku2* this, PlayState* play) { switch (gSaveContext.save.day - 1) { case 0: this->unk_28A = 0; @@ -188,7 +189,7 @@ void func_80BE65B4(EnDaiku2* this, GlobalContext* globalCtx) { } this->unk_264 = 1.0f; - if ((this->unk_278 >= ENDAIKU2_GET_7F_0) && Flags_GetSwitch(globalCtx, this->unk_278)) { + if ((this->unk_278 >= ENDAIKU2_GET_7F_0) && Flags_GetSwitch(play, this->unk_278)) { this->unk_28A = 5; if (this->unk_276 != 10) { func_80BE6408(this, 10); @@ -199,7 +200,7 @@ void func_80BE65B4(EnDaiku2* this, GlobalContext* globalCtx) { this->actionFunc = func_80BE66E4; } -void func_80BE66E4(EnDaiku2* this, GlobalContext* globalCtx) { +void func_80BE66E4(EnDaiku2* this, PlayState* play) { f32 sp9C = this->skelAnime.curFrame; s32 sp98 = gSaveContext.save.day - 1; s32 i; @@ -211,7 +212,7 @@ void func_80BE66E4(EnDaiku2* this, GlobalContext* globalCtx) { Math_SmoothStepToS(&this->actor.world.rot.y, this->actor.home.rot.y, 1, 0xBB8, 0x0); if (sp98 != 2) { - if ((this->unk_278 >= ENDAIKU2_GET_7F_0) && Flags_GetSwitch(globalCtx, this->unk_278)) { + if ((this->unk_278 >= ENDAIKU2_GET_7F_0) && Flags_GetSwitch(play, this->unk_278)) { this->unk_28A = 5; if (this->unk_276 != 10) { func_80BE6408(this, 10); @@ -221,17 +222,17 @@ void func_80BE66E4(EnDaiku2* this, GlobalContext* globalCtx) { this->actor.textId = sTextIds[this->unk_28A]; - if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { - func_80BE6B40(this, globalCtx); + if (Actor_ProcessTalkRequest(&this->actor, &play->state)) { + func_80BE6B40(this, play); return; } - if ((this->unk_28A != 5) && (sp98 != 2) && func_80BE64C0(this, globalCtx)) { + if ((this->unk_28A != 5) && (sp98 != 2) && func_80BE64C0(this, play)) { func_80BE6CFC(this); return; } - func_800B8614(&this->actor, globalCtx, 80.0f); + func_800B8614(&this->actor, play, 80.0f); if ((this->unk_276 == 8) && Animation_OnFrame(&this->skelAnime, 6.0f)) { Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_ROCK_BROKEN); @@ -263,7 +264,8 @@ void func_80BE66E4(EnDaiku2* this, GlobalContext* globalCtx) { func_80BE6408(this, 10); } else if ((this->unk_276 == 10) && (this->unk_284 <= sp9C)) { this->unk_284 = Animation_GetLastFrame(&object_daiku_Anim_002134); - Animation_Change(&this->skelAnime, &object_daiku_Anim_002134, -1.0f, this->unk_284, 0.0f, 2, -4.0f); + Animation_Change(&this->skelAnime, &object_daiku_Anim_002134, -1.0f, this->unk_284, 0.0f, ANIMMODE_ONCE, + -4.0f); this->unk_276 = 11; } else if ((this->unk_276 == 11) && (sp9C <= 0.0f)) { func_80BE6408(this, 8); @@ -278,11 +280,11 @@ void func_80BE66E4(EnDaiku2* this, GlobalContext* globalCtx) { } } -void func_80BE6B40(EnDaiku2* this, GlobalContext* globalCtx) { +void func_80BE6B40(EnDaiku2* this, PlayState* play) { s32 day = gSaveContext.save.day; this->unk_288 = 1; - if ((day != 3) && Flags_GetSwitch(globalCtx, this->unk_278)) { + if ((day != 3) && Flags_GetSwitch(play, this->unk_278)) { this->actionFunc = func_80BE6BC0; } else { func_80BE6408(this, 5); @@ -290,12 +292,12 @@ void func_80BE6B40(EnDaiku2* this, GlobalContext* globalCtx) { } } -void func_80BE6BC0(EnDaiku2* this, GlobalContext* globalCtx) { +void func_80BE6BC0(EnDaiku2* this, PlayState* play) { Math_SmoothStepToS(&this->actor.world.rot.y, this->actor.yawTowardsPlayer, 1, 0xBB8, 0x0); - if ((Message_GetState(&globalCtx->msgCtx) == 5) && Message_ShouldAdvance(globalCtx)) { + if ((Message_GetState(&play->msgCtx) == TEXT_STATE_5) && Message_ShouldAdvance(play)) { s32 day = gSaveContext.save.day - 1; - func_801477B4(globalCtx); + func_801477B4(play); if (this->unk_288 == 2) { this->actionFunc = func_80BE6D40; @@ -303,7 +305,7 @@ void func_80BE6BC0(EnDaiku2* this, GlobalContext* globalCtx) { this->actionFunc = func_80BE6EF0; } else if ((this->unk_28A == 0) || (this->unk_28A == 2)) { this->unk_28A++; - func_80151938(globalCtx, sTextIds[this->unk_28A]); + func_80151938(play, sTextIds[this->unk_28A]); } else { switch (day) { case 0: @@ -314,7 +316,7 @@ void func_80BE6BC0(EnDaiku2* this, GlobalContext* globalCtx) { gSaveContext.save.weekEventReg[64] |= 4; break; } - func_80BE65B4(this, globalCtx); + func_80BE65B4(this, play); } } } @@ -326,11 +328,11 @@ void func_80BE6CFC(EnDaiku2* this) { this->unk_264 = 0.0f; } -void func_80BE6D40(EnDaiku2* this, GlobalContext* globalCtx) { +void func_80BE6D40(EnDaiku2* this, PlayState* play) { s32 pad[3]; s16 sp3A = Math_Vec3f_Yaw(&this->actor.world.pos, &this->unk_268); - if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { + if (Actor_ProcessTalkRequest(&this->actor, &play->state)) { this->actionFunc = func_80BE6BC0; return; } @@ -348,7 +350,7 @@ void func_80BE6D40(EnDaiku2* this, GlobalContext* globalCtx) { } func_80BE61D0(this); } - func_800B8614(&this->actor, globalCtx, 80.0f); + func_800B8614(&this->actor, play, 80.0f); } void func_80BE6EB0(EnDaiku2* this) { @@ -358,13 +360,13 @@ void func_80BE6EB0(EnDaiku2* this) { this->actionFunc = func_80BE6EF0; } -void func_80BE6EF0(EnDaiku2* this, GlobalContext* globalCtx) { +void func_80BE6EF0(EnDaiku2* this, PlayState* play) { f32 sp5C = this->skelAnime.curFrame; s32 pad[4]; Vec3f sp40; s16 var; - if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { + if (Actor_ProcessTalkRequest(&this->actor, &play->state)) { this->actionFunc = func_80BE6BC0; return; } @@ -384,17 +386,17 @@ void func_80BE6EF0(EnDaiku2* this, GlobalContext* globalCtx) { if ((sqrtf(SQ(this->actor.world.pos.x - this->unk_268.x) + SQ(this->actor.world.pos.z - this->unk_268.z)) < 4.0f) && (this->unk_258 != 0)) { - if (!func_80BE64C0(this, globalCtx)) { + if (!func_80BE64C0(this, play)) { if (this->unk_276 != 3) { func_80BE6408(this, 3); } - if ((this->unk_278 >= ENDAIKU2_GET_7F_0) && Flags_GetSwitch(globalCtx, this->unk_278)) { + if ((this->unk_278 >= ENDAIKU2_GET_7F_0) && Flags_GetSwitch(play, this->unk_278)) { this->unk_28A = 5; if (this->unk_276 != 10) { func_80BE6408(this, 10); } - func_80BE65B4(this, globalCtx); + func_80BE65B4(this, play); return; } @@ -406,7 +408,7 @@ void func_80BE6EF0(EnDaiku2* this, GlobalContext* globalCtx) { } func_80BE61D0(this); } - } else if (func_80BE64C0(this, globalCtx)) { + } else if (func_80BE64C0(this, play)) { Math_Vec3f_Copy(&sp40, &this->unk_268); var = this->unk_25C; this->unk_25C++; @@ -419,7 +421,7 @@ void func_80BE6EF0(EnDaiku2* this, GlobalContext* globalCtx) { Math_Vec3f_Copy(&this->unk_268, &sp40); } } - func_800B8614(&this->actor, globalCtx, 80.0f); + func_800B8614(&this->actor, play, 80.0f); } void func_80BE71A0(EnDaiku2* this) { @@ -427,46 +429,46 @@ void func_80BE71A0(EnDaiku2* this) { this->actionFunc = func_80BE71D8; } -void func_80BE71D8(EnDaiku2* this, GlobalContext* globalCtx) { +void func_80BE71D8(EnDaiku2* this, PlayState* play) { f32 currentFrame = this->skelAnime.curFrame; - if (func_80BE64C0(this, globalCtx)) { + if (func_80BE64C0(this, play)) { func_80BE6CFC(this); } else if ((this->unk_276 == 9) && (this->unk_284 <= currentFrame)) { func_80BE6408(this, 0); } else if ((this->unk_276 == 0) && (this->unk_284 <= currentFrame)) { func_80BE6408(this, 5); } else if ((this->unk_276 == 5) && (this->unk_284 <= currentFrame)) { - func_80BE65B4(this, globalCtx); + func_80BE65B4(this, play); } } -void EnDaiku2_Update(Actor* thisx, GlobalContext* globalCtx) { +void EnDaiku2_Update(Actor* thisx, PlayState* play) { EnDaiku2* this = THIS; s32 pad; SkelAnime_Update(&this->skelAnime); - this->actionFunc(this, globalCtx); + this->actionFunc(this, play); this->actor.shape.rot.y = this->actor.world.rot.y; Actor_SetFocus(&this->actor, 65.0f); Actor_MoveWithGravity(&this->actor); Math_ApproachF(&this->unk_260, this->unk_264, 0.3f, 2.0f); - Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 20.0f, 20.0f, 50.0f, 0x1D); + Actor_UpdateBgCheckInfo(play, &this->actor, 20.0f, 20.0f, 50.0f, 0x1D); Collider_UpdateCylinder(&this->actor, &this->collider); - CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); - func_80BE7600(this, globalCtx); + CollisionCheck_SetOC(play, &play->colChkCtx, &this->collider.base); + func_80BE7600(this, play); } -void EnDaiku2_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx) { +void EnDaiku2_PostLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx) { EnDaiku2* this = THIS; - OPEN_DISPS(globalCtx->state.gfxCtx); + OPEN_DISPS(play->state.gfxCtx); - func_8012C28C(globalCtx->state.gfxCtx); + func_8012C28C(play->state.gfxCtx); if (limbIndex == 14) { Matrix_Scale(this->unk_260, this->unk_260, this->unk_260, MTXMODE_APPLY); - gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_OPA_DISP++, object_daiku_DL_009638); } @@ -474,95 +476,95 @@ void EnDaiku2_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, gSPDisplayList(POLY_OPA_DISP++, object_daiku_DL_00A390); } - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->state.gfxCtx); } -void EnDaiku2_Draw(Actor* thisx, GlobalContext* globalCtx) { +void EnDaiku2_Draw(Actor* thisx, PlayState* play) { EnDaiku2* this = THIS; - OPEN_DISPS(globalCtx->state.gfxCtx); + OPEN_DISPS(play->state.gfxCtx); - func_8012C28C(globalCtx->state.gfxCtx); + func_8012C28C(play->state.gfxCtx); gDPSetEnvColor(POLY_OPA_DISP++, 245, 155, 0, 255); - SkelAnime_DrawFlexOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, - NULL, EnDaiku2_PostLimbDraw, &this->actor); - func_80BE7718(this, globalCtx); + SkelAnime_DrawFlexOpa(play, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, NULL, + EnDaiku2_PostLimbDraw, &this->actor); + func_80BE7718(this, play); - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->state.gfxCtx); } 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; } } } -void func_80BE7600(EnDaiku2* this, GlobalContext* globalCtx) { +void func_80BE7600(EnDaiku2* this, PlayState* play) { 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; } } } } -void func_80BE7718(EnDaiku2* this, GlobalContext* globalCtx) { +void func_80BE7718(EnDaiku2* this, PlayState* play) { s32 i; - GraphicsContext* gfxCtx = globalCtx->state.gfxCtx; - EnDaiku2Particle* particle = &this->particles[0]; + GraphicsContext* gfxCtx = play->state.gfxCtx; + EnDaiku2Effect* effect = this->effects; s32 objectIdx; - OPEN_DISPS(globalCtx->state.gfxCtx); + OPEN_DISPS(play->state.gfxCtx); - func_8012C28C(globalCtx->state.gfxCtx); + func_8012C28C(play->state.gfxCtx); - objectIdx = Object_GetIndex(&globalCtx->objectCtx, OBJECT_BOMBIWA); - if ((objectIdx >= 0) && Object_IsLoaded(&globalCtx->objectCtx, objectIdx)) { + objectIdx = Object_GetIndex(&play->objectCtx, OBJECT_BOMBIWA); + if ((objectIdx >= 0) && Object_IsLoaded(&play->objectCtx, objectIdx)) { gDPPipeSync(POLY_OPA_DISP++); - gSPSegment(POLY_OPA_DISP++, 0x06, globalCtx->objectCtx.status[objectIdx].segment); + gSPSegment(POLY_OPA_DISP++, 0x06, play->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(); } } } - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->state.gfxCtx); } 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..dab4096c0 100644 --- a/src/overlays/actors/ovl_En_Daiku2/z_en_daiku2.h +++ b/src/overlays/actors/ovl_En_Daiku2/z_en_daiku2.h @@ -5,7 +5,7 @@ struct EnDaiku2; -typedef void (*EnDaiku2ActionFunc)(struct EnDaiku2*, GlobalContext*); +typedef void (*EnDaiku2ActionFunc)(struct EnDaiku2*, PlayState*); #define ENDAIKU2_GET_7F(thisx) ((thisx)->params & 0x7F); #define ENDAIKU2_GET_1F80(thisx) (((thisx)->params >> 7) & 0x3F); @@ -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 6292103ee..edc240cd5 100644 --- a/src/overlays/actors/ovl_En_Death/z_en_death.c +++ b/src/overlays/actors/ovl_En_Death/z_en_death.c @@ -5,36 +5,37 @@ */ #include "z_en_death.h" +#include "z64rumble.h" #define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_4 | ACTOR_FLAG_10 | ACTOR_FLAG_20 | ACTOR_FLAG_1000) #define THIS ((EnDeath*)thisx) -void EnDeath_Init(Actor* thisx, GlobalContext* globalCtx); -void EnDeath_Destroy(Actor* thisx, GlobalContext* globalCtx); -void EnDeath_Update(Actor* thisx, GlobalContext* globalCtx); -void EnDeath_Draw(Actor* thisx, GlobalContext* globalCtx); +void EnDeath_Init(Actor* thisx, PlayState* play); +void EnDeath_Destroy(Actor* thisx, PlayState* play); +void EnDeath_Update(Actor* thisx, PlayState* play); +void EnDeath_Draw(Actor* thisx, PlayState* play); -void func_808C589C(EnDeath* this, GlobalContext* globalCtx); -void func_808C5AB8(EnDeath* this, GlobalContext* globalCtx); -void func_808C5CB4(EnDeath* this, GlobalContext* globalCtx); -void func_808C5E90(EnDeath* this, GlobalContext* globalCtx); -void func_808C6070(EnDeath* this, GlobalContext* globalCtx); -void func_808C64DC(EnDeath* this, GlobalContext* globalCtx); -void func_808C66A8(EnDeath* this, GlobalContext* globalCtx); -void func_808C682C(EnDeath* this, GlobalContext* globalCtx); -void func_808C692C(EnDeath* this, GlobalContext* globalCtx); -void func_808C6AB0(EnDeath* this, GlobalContext* globalCtx); -void func_808C6CDC(EnDeath* this, GlobalContext* globalCtx); -void func_808C6F6C(EnDeath* this, GlobalContext* globalCtx); -void func_808C72AC(EnDeath* this, GlobalContext* globalCtx); -void func_808C74F8(EnDeath* this, GlobalContext* globalCtx); -void func_808C7888(EnDeath* this, GlobalContext* globalCtx); -void func_808C7AAC(EnDeath* this, GlobalContext* globalCtx); -void func_808C7B88(EnDeath* this, GlobalContext* globalCtx); -void func_808C7C88(EnDeath* this, GlobalContext* globalCtx); -void func_808C7D34(EnDeath* this, GlobalContext* globalCtx); -void func_808C7DCC(EnDeath* this, GlobalContext* globalCtx); +void func_808C589C(EnDeath* this, PlayState* play); +void func_808C5AB8(EnDeath* this, PlayState* play); +void func_808C5CB4(EnDeath* this, PlayState* play); +void func_808C5E90(EnDeath* this, PlayState* play); +void func_808C6070(EnDeath* this, PlayState* play); +void func_808C64DC(EnDeath* this, PlayState* play); +void func_808C66A8(EnDeath* this, PlayState* play); +void func_808C682C(EnDeath* this, PlayState* play); +void func_808C692C(EnDeath* this, PlayState* play); +void func_808C6AB0(EnDeath* this, PlayState* play); +void func_808C6CDC(EnDeath* this, PlayState* play); +void func_808C6F6C(EnDeath* this, PlayState* play); +void func_808C72AC(EnDeath* this, PlayState* play); +void func_808C74F8(EnDeath* this, PlayState* play); +void func_808C7888(EnDeath* this, PlayState* play); +void func_808C7AAC(EnDeath* this, PlayState* play); +void func_808C7B88(EnDeath* this, PlayState* play); +void func_808C7C88(EnDeath* this, PlayState* play); +void func_808C7D34(EnDeath* this, PlayState* play); +void func_808C7DCC(EnDeath* this, PlayState* play); #if 0 const ActorInit En_Death_InitVars = { @@ -78,7 +79,7 @@ static ColliderTrisElementInit D_808C9938[2] = { // static ColliderTrisInit sTrisInit = { static ColliderTrisInit D_808C99B0 = { { COLTYPE_METAL, AT_ON | AT_TYPE_ENEMY, AC_ON | AC_HARD | AC_TYPE_PLAYER, OC1_NONE, OC2_TYPE_1, COLSHAPE_TRIS, }, - 2, D_808C9938, // sTrisElementsInit, + ARRAY_COUNT(sTrisElementsInit), D_808C9938, // sTrisElementsInit, }; // static ColliderQuadInit sQuadInit = { diff --git a/src/overlays/actors/ovl_En_Death/z_en_death.h b/src/overlays/actors/ovl_En_Death/z_en_death.h index e80660836..bc4e326bb 100644 --- a/src/overlays/actors/ovl_En_Death/z_en_death.h +++ b/src/overlays/actors/ovl_En_Death/z_en_death.h @@ -5,13 +5,13 @@ struct EnDeath; -typedef void (*EnDeathActionFunc)(struct EnDeath*, GlobalContext*); +typedef void (*EnDeathActionFunc)(struct EnDeath*, PlayState*); typedef struct EnDeath { - /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x44]; - /* 0x0188 */ EnDeathActionFunc actionFunc; - /* 0x018C */ char unk_18C[0x7AC]; + /* 0x000 */ Actor actor; + /* 0x144 */ char unk_144[0x44]; + /* 0x188 */ EnDeathActionFunc actionFunc; + /* 0x18C */ char unk_18C[0x7AC]; } EnDeath; // size = 0x938 extern const ActorInit En_Death_InitVars; diff --git a/src/overlays/actors/ovl_En_Dekubaba/z_en_dekubaba.c b/src/overlays/actors/ovl_En_Dekubaba/z_en_dekubaba.c index 1939a5bcc..d05ac1003 100644 --- a/src/overlays/actors/ovl_En_Dekubaba/z_en_dekubaba.c +++ b/src/overlays/actors/ovl_En_Dekubaba/z_en_dekubaba.c @@ -10,26 +10,26 @@ #define THIS ((EnDekubaba*)thisx) -void EnDekubaba_Init(Actor* thisx, GlobalContext* globalCtx); -void EnDekubaba_Destroy(Actor* thisx, GlobalContext* globalCtx); -void EnDekubaba_Update(Actor* thisx, GlobalContext* globalCtx); -void EnDekubaba_Draw(Actor* thisx, GlobalContext* globalCtx); +void EnDekubaba_Init(Actor* thisx, PlayState* play); +void EnDekubaba_Destroy(Actor* thisx, PlayState* play); +void EnDekubaba_Update(Actor* thisx, PlayState* play); +void EnDekubaba_Draw(Actor* thisx, PlayState* play); -void func_808B1B14(EnDekubaba* this, GlobalContext* globalCtx); -void func_808B1CF0(EnDekubaba* this, GlobalContext* globalCtx); -void func_808B2240(EnDekubaba* this, GlobalContext* globalCtx); -void func_808B2660(EnDekubaba* this, GlobalContext* globalCtx); -void func_808B28B4(EnDekubaba* this, GlobalContext* globalCtx); -void func_808B29C4(EnDekubaba* this, GlobalContext* globalCtx); -void func_808B2CB8(EnDekubaba* this, GlobalContext* globalCtx); -void func_808B3078(EnDekubaba* this, GlobalContext* globalCtx); -void func_808B3280(EnDekubaba* this, GlobalContext* globalCtx); -void func_808B3404(EnDekubaba* this, GlobalContext* globalCtx); -void func_808B37E8(EnDekubaba* this, GlobalContext* globalCtx); -void func_808B3B48(EnDekubaba* this, GlobalContext* globalCtx); -void func_808B3C50(EnDekubaba* this, GlobalContext* globalCtx); -void func_808B3DA8(EnDekubaba* this, GlobalContext* globalCtx); -void func_808B3EE8(EnDekubaba* this, GlobalContext* globalCtx); +void func_808B1B14(EnDekubaba* this, PlayState* play); +void func_808B1CF0(EnDekubaba* this, PlayState* play); +void func_808B2240(EnDekubaba* this, PlayState* play); +void func_808B2660(EnDekubaba* this, PlayState* play); +void func_808B28B4(EnDekubaba* this, PlayState* play); +void func_808B29C4(EnDekubaba* this, PlayState* play); +void func_808B2CB8(EnDekubaba* this, PlayState* play); +void func_808B3078(EnDekubaba* this, PlayState* play); +void func_808B3280(EnDekubaba* this, PlayState* play); +void func_808B3404(EnDekubaba* this, PlayState* play); +void func_808B37E8(EnDekubaba* this, PlayState* play); +void func_808B3B48(EnDekubaba* this, PlayState* play); +void func_808B3C50(EnDekubaba* this, PlayState* play); +void func_808B3DA8(EnDekubaba* this, PlayState* play); +void func_808B3EE8(EnDekubaba* this, PlayState* play); #if 0 const ActorInit En_Dekubaba_InitVars = { @@ -79,7 +79,7 @@ static ColliderJntSphElementInit D_808B4D60[7] = { // static ColliderJntSphInit sJntSphInit = { static ColliderJntSphInit D_808B4E5C = { { COLTYPE_HIT6, AT_ON | AT_TYPE_ENEMY, AC_ON | AC_TYPE_PLAYER, OC1_ON | OC1_TYPE_ALL, OC2_TYPE_1, COLSHAPE_JNTSPH, }, - 7, D_808B4D60, // sJntSphElementsInit, + ARRAY_COUNT(sJntSphElementsInit), D_808B4D60, // sJntSphElementsInit, }; // sColChkInfoInit diff --git a/src/overlays/actors/ovl_En_Dekubaba/z_en_dekubaba.h b/src/overlays/actors/ovl_En_Dekubaba/z_en_dekubaba.h index 8bfdedb03..923f336aa 100644 --- a/src/overlays/actors/ovl_En_Dekubaba/z_en_dekubaba.h +++ b/src/overlays/actors/ovl_En_Dekubaba/z_en_dekubaba.h @@ -5,13 +5,13 @@ struct EnDekubaba; -typedef void (*EnDekubabaActionFunc)(struct EnDekubaba*, GlobalContext*); +typedef void (*EnDekubabaActionFunc)(struct EnDekubaba*, PlayState*); typedef struct EnDekubaba { - /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x44]; - /* 0x0188 */ EnDekubabaActionFunc actionFunc; - /* 0x018C */ char unk_18C[0x290]; + /* 0x000 */ Actor actor; + /* 0x144 */ char unk_144[0x44]; + /* 0x188 */ EnDekubabaActionFunc actionFunc; + /* 0x18C */ char unk_18C[0x290]; } EnDekubaba; // size = 0x41C extern const ActorInit En_Dekubaba_InitVars; diff --git a/src/overlays/actors/ovl_En_Dekunuts/z_en_dekunuts.c b/src/overlays/actors/ovl_En_Dekunuts/z_en_dekunuts.c index 7461239d3..15ae675a1 100644 --- a/src/overlays/actors/ovl_En_Dekunuts/z_en_dekunuts.c +++ b/src/overlays/actors/ovl_En_Dekunuts/z_en_dekunuts.c @@ -5,39 +5,39 @@ */ #include "z_en_dekunuts.h" +#include "overlays/actors/ovl_Obj_Etcetera/z_obj_etcetera.h" #include "overlays/effects/ovl_Effect_Ss_Hahen/z_eff_ss_hahen.h" -#include "objects/object_dekunuts/object_dekunuts.h" #define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_4) #define THIS ((EnDekunuts*)thisx) -void EnDekunuts_Init(Actor* thisx, GlobalContext* globalCtx); -void EnDekunuts_Destroy(Actor* thisx, GlobalContext* globalCtx); -void EnDekunuts_Update(Actor* thisx, GlobalContext* globalCtx); -void EnDekunuts_Draw(Actor* thisx, GlobalContext* globalCtx); +void EnDekunuts_Init(Actor* thisx, PlayState* play); +void EnDekunuts_Destroy(Actor* thisx, PlayState* play); +void EnDekunuts_Update(Actor* thisx, PlayState* play); +void EnDekunuts_Draw(Actor* thisx, PlayState* play); void func_808BD428(EnDekunuts* this); -void func_808BD49C(EnDekunuts* this, GlobalContext* globalCtx); +void func_808BD49C(EnDekunuts* this, PlayState* play); void func_808BD78C(EnDekunuts* this); -void func_808BD7D4(EnDekunuts* this, GlobalContext* globalCtx); +void func_808BD7D4(EnDekunuts* this, PlayState* play); void func_808BD870(EnDekunuts* this); -void func_808BD8D8(EnDekunuts* this, GlobalContext* globalCtx); +void func_808BD8D8(EnDekunuts* this, PlayState* play); void func_808BDA08(EnDekunuts* this); -void func_808BDA4C(EnDekunuts* this, GlobalContext* globalCtx); +void func_808BDA4C(EnDekunuts* this, PlayState* play); void func_808BDC9C(EnDekunuts* this); -void func_808BDD54(EnDekunuts* this, GlobalContext* globalCtx); -void func_808BDEF8(EnDekunuts* this, GlobalContext* globalCtx); +void func_808BDD54(EnDekunuts* this, PlayState* play); +void func_808BDEF8(EnDekunuts* this, PlayState* play); void func_808BDF60(EnDekunuts* this); -void func_808BDFB8(EnDekunuts* this, GlobalContext* globalCtx); +void func_808BDFB8(EnDekunuts* this, PlayState* play); void func_808BE1CC(EnDekunuts* this); -void func_808BE22C(EnDekunuts* this, GlobalContext* globalCtx); -void func_808BE358(EnDekunuts* this, GlobalContext* globalCtx); -void func_808BE3FC(EnDekunuts* this, GlobalContext* globalCtx); +void func_808BE22C(EnDekunuts* this, PlayState* play); +void func_808BE358(EnDekunuts* this, PlayState* play); +void func_808BE3FC(EnDekunuts* this, PlayState* play); void func_808BE484(EnDekunuts* this); -void func_808BE4D4(EnDekunuts* this, GlobalContext* globalCtx); +void func_808BE4D4(EnDekunuts* this, PlayState* play); void func_808BE680(EnDekunuts* this); -void func_808BE6C4(EnDekunuts* this, GlobalContext* globalCtx); +void func_808BE6C4(EnDekunuts* this, PlayState* play); const ActorInit En_Dekunuts_InitVars = { ACTOR_EN_DEKUNUTS, @@ -114,14 +114,14 @@ static InitChainEntry sInitChain[] = { ICHAIN_F32(targetArrowOffset, 2600, ICHAIN_STOP), }; -void EnDekunuts_Init(Actor* thisx, GlobalContext* globalCtx) { +void EnDekunuts_Init(Actor* thisx, PlayState* play) { EnDekunuts* this = THIS; 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); - Collider_InitAndSetCylinder(globalCtx, &this->collider, &this->actor, &sCylinderInit); + SkelAnime_Init(play, &this->skelAnime, &gDekuScrubSkel, &gDekuScrubIdleAnim, this->jointTable, this->morphTable, + DEKU_SCRUB_LIMB_MAX); + Collider_InitAndSetCylinder(play, &this->collider, &this->actor, &sCylinderInit); CollisionCheck_SetInfo(&this->actor.colChkInfo, &sDamageTable, &sColChkInfoInit); this->unk_194 = ENDEKUNUTS_GET_FF00(&this->actor); thisx->params &= 0xFF; @@ -140,10 +140,10 @@ void EnDekunuts_Init(Actor* thisx, GlobalContext* globalCtx) { func_808BD428(this); } -void EnDekunuts_Destroy(Actor* thisx, GlobalContext* globalCtx) { +void EnDekunuts_Destroy(Actor* thisx, PlayState* play) { EnDekunuts* this = THIS; - Collider_DestroyCylinder(globalCtx, &this->collider); + Collider_DestroyCylinder(play, &this->collider); } void func_808BD348(EnDekunuts* this) { @@ -156,17 +156,17 @@ void func_808BD348(EnDekunuts* this) { Actor_SetColorFilter(&this->actor, 0x4000, 255, 0, 80); } -void func_808BD3B4(EnDekunuts* this, GlobalContext* globalCtx) { +void func_808BD3B4(EnDekunuts* this, PlayState* play) { if (this->drawDmgEffType == ACTOR_DRAW_DMGEFF_FROZEN_NO_SFX) { this->drawDmgEffType = ACTOR_DRAW_DMGEFF_FIRE; this->collider.base.colType = COLTYPE_HIT6; this->drawDmgEffAlpha = 0.0f; - Actor_SpawnIceEffects(globalCtx, &this->actor, this->limbPos, 8, 2, 0.2f, 0.2f); + Actor_SpawnIceEffects(play, &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); @@ -174,7 +174,7 @@ void func_808BD428(EnDekunuts* this) { this->actionFunc = func_808BD49C; } -void func_808BD49C(EnDekunuts* this, GlobalContext* globalCtx) { +void func_808BD49C(EnDekunuts* this, PlayState* play) { s32 phi_v1 = false; if (this->skelAnime.playSpeed < 0.5f) { @@ -193,12 +193,12 @@ void func_808BD49C(EnDekunuts* this, GlobalContext* globalCtx) { this->collider.dim.height = (s32)((CLAMP(this->skelAnime.curFrame, 9.0f, 12.0f) - 9.0f) * 9.0f) + 5; - if (!phi_v1 && (this->actor.params == ENDEKUNUTS_GET_FF00_0) && (Player_GetMask(globalCtx) != PLAYER_MASK_STONE) && + if (!phi_v1 && (this->actor.params == ENDEKUNUTS_GET_FF00_0) && (Player_GetMask(play) != PLAYER_MASK_STONE) && (this->actor.xzDistToPlayer < 120.0f)) { func_808BDC9C(this); } else if (SkelAnime_Update(&this->skelAnime)) { if (((this->unk_190 == 0) && (this->actor.xzDistToPlayer > 320.0f)) || - (Player_GetMask(globalCtx) == PLAYER_MASK_STONE)) { + (Player_GetMask(play) == PLAYER_MASK_STONE)) { func_808BD78C(this); } else { if (this->actor.params == ENDEKUNUTS_GET_FF00_1) { @@ -221,12 +221,12 @@ 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; } -void func_808BD7D4(EnDekunuts* this, GlobalContext* globalCtx) { +void func_808BD7D4(EnDekunuts* this, PlayState* play) { SkelAnime_Update(&this->skelAnime); if (Animation_OnFrame(&this->skelAnime, 0.0f)) { if (this->unk_190 != 0) { @@ -234,14 +234,13 @@ void func_808BD7D4(EnDekunuts* this, GlobalContext* globalCtx) { } } - if ((this->unk_190 == 0) || - ((this->actor.xzDistToPlayer < 120.0f) && Player_GetMask(globalCtx) != PLAYER_MASK_STONE)) { + if ((this->unk_190 == 0) || ((this->actor.xzDistToPlayer < 120.0f) && Player_GetMask(play) != PLAYER_MASK_STONE)) { func_808BDC9C(this); } } 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 { @@ -250,7 +249,7 @@ void func_808BD870(EnDekunuts* this) { this->actionFunc = func_808BD8D8; } -void func_808BD8D8(EnDekunuts* this, GlobalContext* globalCtx) { +void func_808BD8D8(EnDekunuts* this, PlayState* play) { SkelAnime_Update(&this->skelAnime); if (Animation_OnFrame(&this->skelAnime, 0.0f)) { if (this->unk_190 != 0) { @@ -265,13 +264,13 @@ void func_808BD8D8(EnDekunuts* this, GlobalContext* globalCtx) { if (this->unk_190 == 0x1000) { if ((this->actor.xzDistToPlayer > 480.0f) || ((this->actor.params == ENDEKUNUTS_GET_FF00_0) && (this->actor.xzDistToPlayer < 120.0f)) || - (Player_GetMask(globalCtx) == PLAYER_MASK_STONE)) { + (Player_GetMask(play) == PLAYER_MASK_STONE)) { func_808BDC9C(this); } else { func_808BDA08(this); } } else if (this->unk_190 == 0) { - if (Player_GetMask(globalCtx) == PLAYER_MASK_STONE) { + if (Player_GetMask(play) == PLAYER_MASK_STONE) { func_808BDC9C(this); } else { func_808BDA08(this); @@ -280,12 +279,12 @@ 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; } -void func_808BDA4C(EnDekunuts* this, GlobalContext* globalCtx) { +void func_808BDA4C(EnDekunuts* this, PlayState* play) { Player* player; Vec3f sp58; s16 pitch; @@ -295,7 +294,7 @@ void func_808BDA4C(EnDekunuts* this, GlobalContext* globalCtx) { Math_ApproachS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer, 2, 0xE38); if (this->actor.params == ENDEKUNUTS_GET_FF00_2) { - player = GET_PLAYER(globalCtx); + player = GET_PLAYER(play); sp58.x = player->actor.world.pos.x; sp58.z = player->actor.world.pos.z; @@ -319,12 +318,12 @@ void func_808BDA4C(EnDekunuts* this, GlobalContext* globalCtx) { pos.z = (Math_CosS(this->actor.shape.rot.y) * val) + this->actor.world.pos.z; params = (this->actor.params == ENDEKUNUTS_GET_FF00_2) ? ENDEKUNUTS_GET_FF00_2 : ENDEKUNUTS_GET_FF00_0; - if (Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_NUTSBALL, pos.x, pos.y, pos.z, - this->actor.world.rot.x, this->actor.shape.rot.y, 0, params) != NULL) { + if (Actor_Spawn(&play->actorCtx, play, ACTOR_EN_NUTSBALL, pos.x, pos.y, pos.z, this->actor.world.rot.x, + this->actor.shape.rot.y, 0, params) != NULL) { Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_NUTS_THROW); } } 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,21 +331,21 @@ 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); this->actionFunc = func_808BDD54; } -void func_808BDD54(EnDekunuts* this, GlobalContext* globalCtx) { +void func_808BDD54(EnDekunuts* this, PlayState* play) { if (SkelAnime_Update(&this->skelAnime)) { if (this->unk_190 != 0) { this->unk_190--; @@ -367,7 +366,7 @@ 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); @@ -377,7 +376,7 @@ void func_808BDE7C(EnDekunuts* this) { this->actionFunc = func_808BDEF8; } -void func_808BDEF8(EnDekunuts* this, GlobalContext* globalCtx) { +void func_808BDEF8(EnDekunuts* this, PlayState* play) { if (SkelAnime_Update(&this->skelAnime)) { this->unk_192 = BINANG_ROT180(this->actor.yawTowardsPlayer); this->unk_18D = 3; @@ -387,14 +386,14 @@ 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; this->actionFunc = func_808BDFB8; } -void func_808BDFB8(EnDekunuts* this, GlobalContext* globalCtx) { +void func_808BDFB8(EnDekunuts* this, PlayState* play) { s16 yaw; s16 yaw2; @@ -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) { @@ -453,7 +452,7 @@ void func_808BE1CC(EnDekunuts* this) { this->actionFunc = func_808BE22C; } -void func_808BE22C(EnDekunuts* this, GlobalContext* globalCtx) { +void func_808BE22C(EnDekunuts* this, PlayState* play) { SkelAnime_Update(&this->skelAnime); if (Animation_OnFrame(&this->skelAnime, 0.0f)) { if (this->unk_190 != 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,10 +479,10 @@ 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) { +void func_808BE358(EnDekunuts* this, PlayState* play) { Math_StepToF(&this->actor.speedXZ, 0.0f, 1.0f); if (SkelAnime_Update(&this->skelAnime)) { func_808BE484(this); @@ -500,13 +499,13 @@ void func_808BE3A8(EnDekunuts* this) { this->actionFunc = func_808BE3FC; } -void func_808BE3FC(EnDekunuts* this, GlobalContext* globalCtx) { +void func_808BE3FC(EnDekunuts* this, PlayState* play) { if (this->unk_190 != 0) { this->unk_190--; } if (this->unk_190 == 0) { - func_808BD3B4(this, globalCtx); + func_808BD3B4(this, play); if (this->actor.params == ENDEKUNUTS_GET_FF00_1) { func_808BDCF0(this); } else if (this->actor.colChkInfo.health == 0) { @@ -519,13 +518,13 @@ 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); } -void func_808BE4D4(EnDekunuts* this, GlobalContext* globalCtx) { +void func_808BE4D4(EnDekunuts* this, PlayState* play) { static Color_RGBA8 D_808BEF90 = { 255, 255, 255, 255 }; static Color_RGBA8 D_808BEF94 = { 150, 150, 150, 0 }; s32 pad; @@ -535,27 +534,28 @@ void func_808BE4D4(EnDekunuts* this, GlobalContext* globalCtx) { sp40.x = this->actor.world.pos.x; sp40.y = this->actor.world.pos.y + 18.0f; sp40.z = this->actor.world.pos.z; - EffectSsDeadDb_Spawn(globalCtx, &sp40, &gZeroVec3f, &gZeroVec3f, &D_808BEF90, &D_808BEF94, 200, 0, 13); - SoundSource_PlaySfxAtFixedWorldPos(globalCtx, &this->actor.world.pos, 11, NA_SE_EN_EXTINCT); + EffectSsDeadDb_Spawn(play, &sp40, &gZeroVec3f, &gZeroVec3f, &D_808BEF90, &D_808BEF94, 200, 0, 13); + SoundSource_PlaySfxAtFixedWorldPos(play, &this->actor.world.pos, 11, NA_SE_EN_EXTINCT); sp40.y = this->actor.world.pos.y + 10.0f; - EffectSsHahen_SpawnBurst(globalCtx, &sp40, 3.0f, 0, 12, 3, 15, HAHEN_OBJECT_DEFAULT, 10, NULL); - Item_DropCollectibleRandom(globalCtx, &this->actor, &this->actor.world.pos, 0xE0); - 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); + EffectSsHahen_SpawnBurst(play, &sp40, 3.0f, 0, 12, 3, 15, HAHEN_OBJECT_DEFAULT, 10, NULL); + Item_DropCollectibleRandom(play, &this->actor, &this->actor.world.pos, 0xE0); + Actor_Spawn(&play->actorCtx, play, ACTOR_OBJ_ETCETERA, this->actor.home.pos.x, this->actor.home.pos.y, + this->actor.home.pos.z, 0, this->actor.home.rot.y, 0, + DEKU_FLOWER_PARAMS(DEKU_FLOWER_TYPE_PINK_WITH_INITIAL_BOUNCE)); + EffectSsHahen_SpawnBurst(play, &this->actor.home.pos, 6.0f, 0, 6, 2, 15, OBJECT_DEKUNUTS, 10, + gDekuScrubFlowerFragmentDL); Actor_MarkForDeath(&this->actor); } } 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; } -void func_808BE6C4(EnDekunuts* this, GlobalContext* globalCtx) { +void func_808BE6C4(EnDekunuts* this, PlayState* play) { SkelAnime_Update(&this->skelAnime); - if (Player_GetMask(globalCtx) != PLAYER_MASK_STONE) { + if (Player_GetMask(play) != PLAYER_MASK_STONE) { Math_ApproachS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer, 2, 0xE38); } @@ -564,16 +564,16 @@ void func_808BE6C4(EnDekunuts* this, GlobalContext* globalCtx) { } } -void func_808BE73C(EnDekunuts* this, GlobalContext* globalCtx) { +void func_808BE73C(EnDekunuts* this, PlayState* play) { 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)) { - func_808BD3B4(this, globalCtx); + func_808BD3B4(this, play); 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)) { - Enemy_StartFinishingBlow(globalCtx, &this->actor); + Enemy_StartFinishingBlow(play, &this->actor); } if (this->actor.params == ENDEKUNUTS_GET_FF00_1) { @@ -607,9 +607,9 @@ void func_808BE73C(EnDekunuts* this, GlobalContext* globalCtx) { 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); + Actor_Spawn(&play->actorCtx, play, ACTOR_EN_CLEAR_TAG, this->collider.info.bumper.hitPos.x, + this->collider.info.bumper.hitPos.y, this->collider.info.bumper.hitPos.z, 0, 0, 0, + CLEAR_TAG_SMALL_LIGHT_RAYS); } else if (this->actor.colChkInfo.damageEffect == 5) { this->drawDmgEffType = ACTOR_DRAW_DMGEFF_ELECTRIC_SPARKS_LARGE; this->drawDmgEffAlpha = 4.0f; @@ -621,7 +621,7 @@ void func_808BE73C(EnDekunuts* this, GlobalContext* globalCtx) { func_808BDE7C(this); } } - } else if ((this->actor.colChkInfo.mass == MASS_IMMOVABLE) && (globalCtx->actorCtx.unk2 != 0) && + } else if ((this->actor.colChkInfo.mass == MASS_IMMOVABLE) && (play->actorCtx.unk2 != 0) && (this->actor.xyzDistToPlayerSq < SQ(200.0f))) { if (this->actor.params == ENDEKUNUTS_GET_FF00_1) { func_808BDCF0(this); @@ -629,27 +629,27 @@ void func_808BE73C(EnDekunuts* this, GlobalContext* globalCtx) { func_808BDE7C(this); } else if (this->actor.colChkInfo.health != 0) { this->actor.colChkInfo.health = 0; - Enemy_StartFinishingBlow(globalCtx, &this->actor); + Enemy_StartFinishingBlow(play, &this->actor); func_808BE294(this, 0); } } } -void EnDekunuts_Update(Actor* thisx, GlobalContext* globalCtx) { +void EnDekunuts_Update(Actor* thisx, PlayState* play) { EnDekunuts* this = THIS; s32 pad; - func_808BE73C(this, globalCtx); - this->actionFunc(this, globalCtx); + func_808BE73C(this, play); + this->actionFunc(this, play); Actor_MoveWithGravity(&this->actor); - Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 20.0f, this->collider.dim.radius, this->collider.dim.height, 0x1D); + Actor_UpdateBgCheckInfo(play, &this->actor, 20.0f, this->collider.dim.radius, this->collider.dim.height, 0x1D); Collider_UpdateCylinder(&this->actor, &this->collider); if (this->collider.base.acFlags & AC_ON) { - CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + CollisionCheck_SetAC(play, &play->colChkCtx, &this->collider.base); } - CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + CollisionCheck_SetOC(play, &play->colChkCtx, &this->collider.base); if (this->drawDmgEffAlpha > 0.0f) { if (this->drawDmgEffType != ACTOR_DRAW_DMGEFF_FROZEN_NO_SFX) { Math_StepToF(&this->drawDmgEffAlpha, 0.0f, 0.05f); @@ -662,14 +662,13 @@ void EnDekunuts_Update(Actor* thisx, GlobalContext* globalCtx) { } } -s32 EnDekunuts_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, - Actor* thisx) { +s32 EnDekunuts_OverrideLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, Actor* thisx) { EnDekunuts* this = THIS; f32 arg1, arg2, arg3; 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); @@ -688,14 +687,14 @@ 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; } } return false; } -void EnDekunuts_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx) { +void EnDekunuts_PostLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx) { static s8 D_808BEF98[] = { -1, -1, -1, 3, -1, 0, -1, 1, -1, 2, 0, 0, }; @@ -711,35 +710,35 @@ void EnDekunuts_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dLis if (value != -1) { if (value < 3) { - Matrix_GetStateTranslationAndScaledX(1000.0f, &this->limbPos[value]); + Matrix_MultVecX(1000.0f, &this->limbPos[value]); } else { - Matrix_GetStateTranslation(&this->limbPos[value]); + Matrix_MultZero(&this->limbPos[value]); ptr1 = &D_808BEFA4[0]; ptr2 = &this->limbPos[value + 1]; for (i = value + 1; i < ARRAY_COUNT(this->limbPos); i++) { - Matrix_MultiplyVector3fByState(ptr1, ptr2); + 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); } } -void EnDekunuts_Draw(Actor* thisx, GlobalContext* globalCtx) { +void EnDekunuts_Draw(Actor* thisx, PlayState* play) { EnDekunuts* this = THIS; - SkelAnime_DrawOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, EnDekunuts_OverrideLimbDraw, + SkelAnime_DrawOpa(play, 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); + func_800AE5A0(play); } - Gfx_DrawDListOpa(globalCtx, object_dekunuts_DL_001E50); - Actor_DrawDamageEffects(globalCtx, &this->actor, this->limbPos, ARRAY_COUNT(this->limbPos), this->drawDmgEffScale, + Gfx_DrawDListOpa(play, gDekuScrubFlowerDL); + Actor_DrawDamageEffects(play, &this->actor, this->limbPos, ARRAY_COUNT(this->limbPos), this->drawDmgEffScale, this->drawDmgEffFrozenSteamScale, this->drawDmgEffAlpha, this->drawDmgEffType); } diff --git a/src/overlays/actors/ovl_En_Dekunuts/z_en_dekunuts.h b/src/overlays/actors/ovl_En_Dekunuts/z_en_dekunuts.h index 3e1af35eb..596369c62 100644 --- a/src/overlays/actors/ovl_En_Dekunuts/z_en_dekunuts.h +++ b/src/overlays/actors/ovl_En_Dekunuts/z_en_dekunuts.h @@ -2,10 +2,11 @@ #define Z_EN_DEKUNUTS_H #include "global.h" +#include "objects/object_dekunuts/object_dekunuts.h" struct EnDekunuts; -typedef void (*EnDekunutsActionFunc)(struct EnDekunuts*, GlobalContext*); +typedef void (*EnDekunutsActionFunc)(struct EnDekunuts*, PlayState*); #define ENDEKUNUTS_GET_FF00(thisx) (((thisx)->params >> 8) & 0xFF); @@ -26,8 +27,8 @@ typedef struct EnDekunuts { /* 0x190 */ s16 unk_190; /* 0x192 */ s16 unk_192; /* 0x194 */ s16 unk_194; - /* 0x196 */ Vec3s jointTable[10]; - /* 0x1D2 */ Vec3s morphTable[10]; + /* 0x196 */ Vec3s jointTable[DEKU_SCRUB_LIMB_MAX]; + /* 0x1D2 */ Vec3s morphTable[DEKU_SCRUB_LIMB_MAX]; /* 0x210 */ f32 drawDmgEffAlpha; /* 0x214 */ f32 drawDmgEffScale; /* 0x218 */ f32 drawDmgEffFrozenSteamScale; 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 76934448a..47e11a2e8 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,32 +5,30 @@ */ #include "z_en_demo_heishi.h" -#include "objects/object_sdn/object_sdn.h" #define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_8) #define THIS ((EnDemoheishi*)thisx) -void EnDemoheishi_Init(Actor* thisx, GlobalContext* globalCtx); -void EnDemoheishi_Destroy(Actor* thisx, GlobalContext* globalCtx); -void EnDemoheishi_Update(Actor* thisx, GlobalContext* globalCtx); -void EnDemoheishi_Draw(Actor* thisx, GlobalContext* globalCtx); +void EnDemoheishi_Init(Actor* thisx, PlayState* play); +void EnDemoheishi_Destroy(Actor* thisx, PlayState* play); +void EnDemoheishi_Update(Actor* thisx, PlayState* play); +void EnDemoheishi_Draw(Actor* thisx, PlayState* play); -void EnDemoheishi_ChangeAnimation(EnDemoheishi* this, s32 animIndex); +void EnDemoheishi_ChangeAnim(EnDemoheishi* this, s32 animIndex); void EnDemoheishi_SetupIdle(EnDemoheishi* this); -void EnDemoheishi_Idle(EnDemoheishi* this, GlobalContext* globalCtx); +void EnDemoheishi_Idle(EnDemoheishi* this, PlayState* play); 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); +void EnDemoheishi_Talk(EnDemoheishi* this, PlayState* play); +s32 EnDemoheishi_OverrideLimbDraw(PlayState* play, 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; + /* 0 */ DEMOHEISHI_ANIM_STAND_HAND_ON_HIP, + /* 1 */ DEMOHEISHI_ANIM_CHEER_WITH_SPEAR, + /* 2 */ DEMOHEISHI_ANIM_WAVE, + /* 3 */ DEMOHEISHI_ANIM_SIT_AND_REACH, + /* 4 */ DEMOHEISHI_ANIM_STAND_UP +} EnDemoheishiAnimation; const ActorInit En_Demo_heishi_InitVars = { ACTOR_EN_DEMO_HEISHI, @@ -66,38 +64,38 @@ static ColliderCylinderInit sCylinderInit = { static u16 sTextIds[] = { 0x1473 }; // Shiro initial intro text -void EnDemoheishi_Init(Actor* thisx, GlobalContext* globalCtx) { +void EnDemoheishi_Init(Actor* thisx, PlayState* play) { EnDemoheishi* this = THIS; ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 25.0f); - SkelAnime_InitFlex(globalCtx, &this->skelAnime, &gSoldierSkeleton, &gSoldierWave, this->jointTable, - this->morphTable, 17); + SkelAnime_InitFlex(play, &this->skelAnime, &gSoldierSkel, &gSoldierWave, this->jointTable, this->morphTable, + SOLDIER_LIMB_MAX); this->actor.colChkInfo.mass = MASS_IMMOVABLE; this->actor.targetMode = 6; this->actor.gravity = -3.0f; - Collider_InitAndSetCylinder(globalCtx, &this->colliderCylinder, &this->actor, &sCylinderInit); + Collider_InitAndSetCylinder(play, &this->colliderCylinder, &this->actor, &sCylinderInit); EnDemoheishi_SetupIdle(this); } -void EnDemoheishi_Destroy(Actor* thisx, GlobalContext* globalCtx) { +void EnDemoheishi_Destroy(Actor* thisx, PlayState* play) { EnDemoheishi* this = THIS; - Collider_DestroyCylinder(globalCtx, &this->colliderCylinder); + Collider_DestroyCylinder(play, &this->colliderCylinder); } -void EnDemoheishi_ChangeAnimation(EnDemoheishi* this, s32 animIndex) { +void EnDemoheishi_ChangeAnim(EnDemoheishi* this, s32 animIndex) { static AnimationHeader* sAnimations[] = { &gSoldierStandHandOnHip, &gSoldierCheerWithSpear, &gSoldierWave, &gSoldierSitAndReach, &gSoldierStandUp, }; - static u8 sAnimModes[] = { + static u8 sAnimationModes[] = { 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, ANIMMODE_LOOP, ANIMMODE_LOOP, }; 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); + sAnimationModes[this->animIndex], -10.0f); } void EnDemoheishi_SetHeadRotation(EnDemoheishi* this) { @@ -116,14 +114,14 @@ void EnDemoheishi_SetHeadRotation(EnDemoheishi* this) { } void EnDemoheishi_SetupIdle(EnDemoheishi* this) { - EnDemoheishi_ChangeAnimation(this, DEMOHEISHI_ANIMATION_STAND_HAND_ON_HIP); + EnDemoheishi_ChangeAnim(this, DEMOHEISHI_ANIM_STAND_HAND_ON_HIP); this->textIdIndex = 0; this->actor.textId = sTextIds[this->textIdIndex]; this->isTalking = false; this->actionFunc = EnDemoheishi_Idle; } -void EnDemoheishi_Idle(EnDemoheishi* this, GlobalContext* globalCtx) { +void EnDemoheishi_Idle(EnDemoheishi* this, PlayState* play) { s32 absYawDiff; s16 yawDiff; @@ -131,10 +129,10 @@ void EnDemoheishi_Idle(EnDemoheishi* this, GlobalContext* globalCtx) { yawDiff = this->actor.yawTowardsPlayer - this->actor.world.rot.y; absYawDiff = ABS_ALT(yawDiff); - if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { + if (Actor_ProcessTalkRequest(&this->actor, &play->state)) { EnDemoheishi_SetupTalk(this); } else if (absYawDiff <= 0x4BB8) { - func_800B8614(&this->actor, globalCtx, 70.0f); + func_800B8614(&this->actor, play, 70.0f); } } @@ -143,14 +141,14 @@ void EnDemoheishi_SetupTalk(EnDemoheishi* this) { this->actionFunc = EnDemoheishi_Talk; } -void EnDemoheishi_Talk(EnDemoheishi* this, GlobalContext* globalCtx) { - if ((Message_GetState(&globalCtx->msgCtx) == 5) && Message_ShouldAdvance(globalCtx)) { - func_801477B4(globalCtx); +void EnDemoheishi_Talk(EnDemoheishi* this, PlayState* play) { + if ((Message_GetState(&play->msgCtx) == TEXT_STATE_5) && Message_ShouldAdvance(play)) { + func_801477B4(play); EnDemoheishi_SetupIdle(this); } } -void EnDemoheishi_Update(Actor* thisx, GlobalContext* globalCtx) { +void EnDemoheishi_Update(Actor* thisx, PlayState* play) { s32 pad; EnDemoheishi* this = THIS; @@ -160,9 +158,9 @@ void EnDemoheishi_Update(Actor* thisx, GlobalContext* globalCtx) { } this->actor.shape.rot.y = this->actor.world.rot.y; - this->actionFunc(this, globalCtx); + this->actionFunc(this, play); Actor_MoveWithGravity(&this->actor); - Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 20.0f, 20.0f, 50.0f, 0x1D); + Actor_UpdateBgCheckInfo(play, &this->actor, 20.0f, 20.0f, 50.0f, 0x1D); Actor_SetScale(&this->actor, 0.01f); EnDemoheishi_SetHeadRotation(this); @@ -170,14 +168,13 @@ void EnDemoheishi_Update(Actor* thisx, GlobalContext* globalCtx) { 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); + CollisionCheck_SetOC(play, &play->colChkCtx, &this->colliderCylinder.base); } -s32 EnDemoheishi_OverrideLimbDraw(GlobalContext* globalctx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, - Actor* thisx) { +s32 EnDemoheishi_OverrideLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, Actor* thisx) { EnDemoheishi* this = THIS; - if (limbIndex == DEMOHEISHI_LIMB_HEAD) { + if (limbIndex == SOLDIER_LIMB_HEAD) { rot->x += this->headRotX; rot->y += this->headRotY; rot->z += this->headRotZ; @@ -186,10 +183,10 @@ s32 EnDemoheishi_OverrideLimbDraw(GlobalContext* globalctx, s32 limbIndex, Gfx** return false; } -void EnDemoheishi_Draw(Actor* thisx, GlobalContext* globalCtx) { +void EnDemoheishi_Draw(Actor* thisx, PlayState* play) { EnDemoheishi* this = THIS; - func_8012C28C(globalCtx->state.gfxCtx); - SkelAnime_DrawFlexOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, + func_8012C28C(play->state.gfxCtx); + SkelAnime_DrawFlexOpa(play, 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 e6a2f9a91..c14fa5326 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 @@ -2,37 +2,17 @@ #define Z_EN_DEMO_HEISHI_H #include "global.h" +#include "objects/object_sdn/object_sdn.h" 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 void (*EnDemoheishiActionFunc)(struct EnDemoheishi*, PlayState*); typedef struct EnDemoheishi { /* 0x000 */ Actor actor; /* 0x144 */ SkelAnime skelAnime; - /* 0x188 */ Vec3s jointTable[DEMOHEISHI_LIMB_MAX]; - /* 0x1EE */ Vec3s morphTable[DEMOHEISHI_LIMB_MAX]; + /* 0x188 */ Vec3s jointTable[SOLDIER_LIMB_MAX]; + /* 0x1EE */ Vec3s morphTable[SOLDIER_LIMB_MAX]; /* 0x254 */ EnDemoheishiActionFunc actionFunc; /* 0x258 */ s16 headRotY; /* 0x25A */ s16 headRotX; 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 dce730c48..ef93a501a 100644 --- a/src/overlays/actors/ovl_En_Dg/z_en_dg.c +++ b/src/overlays/actors/ovl_En_Dg/z_en_dg.c @@ -10,31 +10,31 @@ #define THIS ((EnDg*)thisx) -void EnDg_Init(Actor* thisx, GlobalContext* globalCtx); -void EnDg_Destroy(Actor* thisx, GlobalContext* globalCtx); -void EnDg_Update(Actor* thisx, GlobalContext* globalCtx); -void EnDg_Draw(Actor* thisx, GlobalContext* globalCtx); +void EnDg_Init(Actor* thisx, PlayState* play); +void EnDg_Destroy(Actor* thisx, PlayState* play); +void EnDg_Update(Actor* thisx, PlayState* play); +void EnDg_Draw(Actor* thisx, PlayState* play); -void func_8098A468(EnDg* this, GlobalContext* globalCtx); -void func_8098A55C(EnDg* this, GlobalContext* globalCtx); -void func_8098A618(EnDg* this, GlobalContext* globalCtx); -void func_8098A70C(EnDg* this, GlobalContext* globalCtx); -void func_8098A89C(EnDg* this, GlobalContext* globalCtx); -void func_8098A938(EnDg* this, GlobalContext* globalCtx); -void func_8098AB48(EnDg* this, GlobalContext* globalCtx); -void func_8098AC34(EnDg* this, GlobalContext* globalCtx); -void func_8098AF44(EnDg* this, GlobalContext* globalCtx); -void func_8098AF98(EnDg* this, GlobalContext* globalCtx); -void func_8098B004(EnDg* this, GlobalContext* globalCtx); -void func_8098B198(EnDg* this, GlobalContext* globalCtx); -void func_8098B28C(EnDg* this, GlobalContext* globalCtx); -void func_8098B390(EnDg* this, GlobalContext* globalCtx); -void func_8098B560(EnDg* this, GlobalContext* globalCtx); -void func_8098B88C(EnDg* this, GlobalContext* globalCtx); -void func_8098BA64(EnDg* this, GlobalContext* globalCtx); -void func_8098BB10(EnDg* this, GlobalContext* globalCtx); -void func_8098BBEC(EnDg* this, GlobalContext* globalCtx); -void func_8098BC54(EnDg* this, GlobalContext* globalCtx); +void EnDg_IdleMove(EnDg* this, PlayState* play); +void EnDg_IdleBark(EnDg* this, PlayState* play); +void EnDg_BackAwayFromGoron(EnDg* this, PlayState* play); +void EnDg_RunAwayFromGoron(EnDg* this, PlayState* play); +void EnDg_BarkAtGoron(EnDg* this, PlayState* play); +void EnDg_ApproachPlayerToAttack(EnDg* this, PlayState* play); +void EnDg_SitNextToPlayer(EnDg* this, PlayState* play); +void EnDg_JumpAttack(EnDg* this, PlayState* play); +void EnDg_SetupBremenMaskApproachPlayer(EnDg* this, PlayState* play); +void EnDg_Fall(EnDg* this, PlayState* play); +void EnDg_ApproachPlayer(EnDg* this, PlayState* play); +void EnDg_SlowlyBackUpBeforeAttacking(EnDg* this, PlayState* play); +void EnDg_BackAwayFromPlayer(EnDg* this, PlayState* play); +void EnDg_BarkAtPlayer(EnDg* this, PlayState* play); +void EnDg_Swim(EnDg* this, PlayState* play); +void EnDg_JumpOutOfWater(EnDg* this, PlayState* play); +void EnDg_Held(EnDg* this, PlayState* play); +void EnDg_Thrown(EnDg* this, PlayState* play); +void EnDg_SetupTalk(EnDg* this, PlayState* play); +void EnDg_Talk(EnDg* this, PlayState* play); const ActorInit En_Dg_InitVars = { ACTOR_EN_DG, @@ -48,28 +48,64 @@ const ActorInit En_Dg_InitVars = { (ActorFunc)EnDg_Draw, }; -static u8 D_8098C2A0 = 0; +#define DOG_FLAG_NONE 0 +#define DOG_FLAG_HELD (1 << 0) +#define DOG_FLAG_JUMP_ATTACKING (1 << 1) +#define DOG_FLAG_SWIMMING (1 << 2) +#define DOG_FLAG_BOUNCED (1 << 3) +#define DOG_FLAG_THROWN (1 << 4) +#define DOG_FLAG_FOLLOWING_BREMEN_MASK (1 << 5) +#define ENDG_INDEX_NO_BREMEN_MASK_FOLLOWER 99 + +typedef enum { + /* 0 */ DOG_GRAB_STATE_NONE, + /* 1 */ DOG_GRAB_STATE_HELD, + /* 2 */ DOG_GRAB_STATE_THROWN_OR_SITTING_AFTER_THROW, +} DogGrabState; + +typedef enum { + /* 0 */ DOG_BEHAVIOR_INITIAL, // Gets immediately replaced by DOG_BEHAVIOR_DEFAULT in EnDg_Update + /* 1 */ DOG_BEHAVIOR_HUMAN, // Gets immediately replaced by DOG_BEHAVIOR_DEFAULT in EnDg_Update + /* 2 */ DOG_BEHAVIOR_GORON, + /* 3 */ DOG_BEHAVIOR_GORON_WAIT, + /* 4 */ DOG_BEHAVIOR_ZORA, + /* 5 */ DOG_BEHAVIOR_ZORA_WAIT, + /* 6 */ DOG_BEHAVIOR_DEKU, + /* 7 */ DOG_BEHAVIOR_DEKU_WAIT, + /* 8 */ DOG_BEHAVIOR_DEFAULT, +} DogBehavior; + +static u8 sIsAnyDogHeld = false; + +static s16 sBremenMaskFollowerIndex = ENDG_INDEX_NO_BREMEN_MASK_FOLLOWER; + +/** + * Stores the state for the dogs milling about at the Doggy Racetrack. + */ typedef struct { - s16 unk_00; - s16 unk_02; -} D_8098C2A4_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_8098C2A4_s D_8098C2A4 = { 0x0063, 0x0000 }; - -typedef struct { - s16 unk_00; - s16 unk_02; - s16 unk_04; -} D_8098C2A8_s; - -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 EnDg_TryPickUp. + */ +static RacetrackDogInfo sSelectedRacetrackDogInfo = { DOG_COLOR_DEFAULT, -1, 0x353E }; static ColliderCylinderInit sCylinderInit = { { @@ -128,7 +164,27 @@ static DamageTable sDamageTable = { /* Powder Keg */ DMG_ENTRY(0, 0x0), }; -static AnimationInfoS sAnimations[] = { +typedef enum { + /* 0 */ DOG_ANIM_WALK_AFTER_TALKING, + /* 1 */ DOG_ANIM_WALK, + /* 2 */ DOG_ANIM_RUN, + /* 3 */ DOG_ANIM_BARK, + /* 4 */ DOG_ANIM_SIT_DOWN_ONCE, // unused + /* 5 */ DOG_ANIM_SIT_DOWN, + /* 6 */ DOG_ANIM_LYING_DOWN_START_1, // unused + /* 7 */ DOG_ANIM_LYING_DOWN_LOOP, // unused + /* 8 */ DOG_ANIM_LYING_DOWN_START_2, // unused + /* 9 */ DOG_ANIM_LYING_DOWN_START_3, // unused + /* 10 */ DOG_ANIM_LYING_DOWN_START_4, // unused + /* 11 */ DOG_ANIM_WALK_BACKWARDS, + /* 12 */ DOG_ANIM_JUMP, + /* 13 */ DOG_ANIM_LONG_JUMP, // unused + /* 14 */ DOG_ANIM_JUMP_ATTACK, + /* 15 */ DOG_ANIM_SWIM, + /* 16 */ DOG_ANIM_MAX +} DogAnimation; + +static AnimationInfoS sAnimationInfo[] = { { &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 }, @@ -136,106 +192,113 @@ static AnimationInfoS sAnimations[] = { { &gDogLyingDownAnim, 1.0f, 0, 27, ANIMMODE_ONCE, -6 }, { &gDogLyingDownAnim, 1.0f, 28, -1, ANIMMODE_ONCE, -6 }, { &gDogLyingDownAnim, 1.0f, 54, 54, ANIMMODE_ONCE, -6 }, { &gDogWalkAnim, -1.5f, -1, 0, ANIMMODE_LOOP, -6 }, { &gDogJumpAnim, 1.0f, 0, -1, ANIMMODE_ONCE, 0 }, { &gDogLongJumpAnim, 1.2f, 0, -1, ANIMMODE_ONCE, 0 }, - { &gDogJump2Anim, 1.2f, 0, -1, ANIMMODE_ONCE, 0 }, { &gDogWalkAnim, 0.5f, 0, -1, ANIMMODE_LOOP, 0 }, + { &gDogJumpAttackAnim, 1.2f, 0, -1, ANIMMODE_ONCE, 0 }, { &gDogWalkAnim, 0.5f, 0, -1, ANIMMODE_LOOP, 0 }, }; static InitChainEntry sInitChain[] = { ICHAIN_F32(uncullZoneForward, 1000, ICHAIN_STOP), }; -void func_80989140(SkelAnime* skelAnime, AnimationInfoS arg1[], s32 arg2) { +void EnDg_ChangeAnim(SkelAnime* skelAnime, AnimationInfoS* animationInfo, s32 animIndex) { f32 frameCount; - arg1 += arg2; - if (arg1->frameCount < 0) { - frameCount = Animation_GetLastFrame(arg1->animation); + animationInfo += animIndex; + if (animationInfo->frameCount < 0) { + frameCount = Animation_GetLastFrame(animationInfo->animation); } else { - frameCount = arg1->frameCount; + frameCount = animationInfo->frameCount; } - Animation_Change(skelAnime, arg1->animation, arg1->playSpeed + (BREG(88) * 0.1f), arg1->startFrame, frameCount, - arg1->mode, arg1->morphFrames); + Animation_Change(skelAnime, animationInfo->animation, animationInfo->playSpeed + (BREG(88) * 0.1f), + animationInfo->startFrame, frameCount, animationInfo->mode, animationInfo->morphFrames); } -void func_80989204(EnDg* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); +void EnDg_UpdateCollision(EnDg* this, PlayState* play) { + Player* player = GET_PLAYER(play); this->collider.dim.pos.x = this->actor.world.pos.x; this->collider.dim.pos.y = this->actor.world.pos.y; this->collider.dim.pos.z = this->actor.world.pos.z; Collider_UpdateCylinder(&this->actor, &this->collider); - if ((player->transformation == PLAYER_FORM_DEKU) && (this->actionFunc == func_8098AC34)) { - CollisionCheck_SetAT(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + + if ((player->transformation == PLAYER_FORM_DEKU) && (this->actionFunc == EnDg_JumpAttack)) { + CollisionCheck_SetAT(play, &play->colChkCtx, &this->collider.base); } else { - Collider_ResetCylinderAT(globalCtx, &this->collider.base); + Collider_ResetCylinderAT(play, &this->collider.base); } - if ((this->unk_290 != 1) && !(this->unk_280 & 2)) { - CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + // The check for DOG_FLAG_JUMP_ATTACKING here makes it so the dog passes through the + // player if it hits them with their jump attack. + if ((this->grabState != DOG_GRAB_STATE_HELD) && !(this->dogFlags & DOG_FLAG_JUMP_ATTACKING)) { + CollisionCheck_SetOC(play, &play->colChkCtx, &this->collider.base); } else { - Collider_ResetCylinderOC(globalCtx, &this->collider.base); + Collider_ResetCylinderOC(play, &this->collider.base); } - Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 26.0f, 10.0f, 0.0f, 5); + Actor_UpdateBgCheckInfo(play, &this->actor, 26.0f, 10.0f, 0.0f, 5); } -void func_8098933C(EnDg* this, Vec3f* arg1) { - f32 sp24; - f32 sp20; - f32 sp1C; +void EnDg_GetFloorRot(EnDg* this, Vec3f* floorRot) { + f32 nx; + f32 ny; + f32 nz; if (this->actor.floorPoly != NULL) { - sp24 = COLPOLY_GET_NORMAL(this->actor.floorPoly->normal.x); - sp20 = COLPOLY_GET_NORMAL(this->actor.floorPoly->normal.y); - sp1C = COLPOLY_GET_NORMAL(this->actor.floorPoly->normal.z); + nx = COLPOLY_GET_NORMAL(this->actor.floorPoly->normal.x); + ny = COLPOLY_GET_NORMAL(this->actor.floorPoly->normal.y); + nz = COLPOLY_GET_NORMAL(this->actor.floorPoly->normal.z); - __sinf(0.0f); - __cosf(0.0f); - arg1->x = -Math_Acot2F(1.0f, -sp1C * sp20); - arg1->z = Math_Acot2F(1.0f, -sp24 * sp20); + sinf(0.0f); + cosf(0.0f); + floorRot->x = -Math_Acot2F(1.0f, -nz * ny); + floorRot->z = Math_Acot2F(1.0f, -nx * ny); } } -s32 func_80989418(EnDg* this, Path* arg1, s32 arg2) { - Vec3s* sp5C = Lib_SegmentedToVirtual(arg1->points); - s32 count = arg1->count; - s32 idx = arg2; - s32 sp50 = false; - f32 phi_f12; - f32 phi_f14; - f32 sp44; - f32 sp40; - f32 sp3C; - Vec3f sp30; +s32 EnDg_HasReachedPoint(EnDg* this, Path* path, s32 pointIndex) { + Vec3s* points = Lib_SegmentedToVirtual(path->points); + s32 pathCount = path->count; + s32 currentPoint = pointIndex; + s32 reached = false; + f32 diffX; + f32 diffZ; + f32 px; + f32 pz; + f32 d; + Vec3f point; - Math_Vec3s_ToVec3f(&sp30, &sp5C[idx]); - if (idx == 0) { - phi_f12 = sp5C[1].x - sp5C[0].x; - phi_f14 = sp5C[1].z - sp5C[0].z; - } else if (idx == count - 1) { - phi_f12 = sp5C[count - 1].x - sp5C[count - 2].x; - phi_f14 = sp5C[count - 1].z - sp5C[count - 2].z; + Math_Vec3s_ToVec3f(&point, &points[currentPoint]); + if (currentPoint == 0) { + diffX = points[1].x - points[0].x; + diffZ = points[1].z - points[0].z; + } else if (currentPoint == pathCount - 1) { + diffX = points[pathCount - 1].x - points[pathCount - 2].x; + diffZ = points[pathCount - 1].z - points[pathCount - 2].z; } else { - phi_f12 = sp5C[idx + 1].x - sp5C[idx - 1].x; - phi_f14 = sp5C[idx + 1].z - sp5C[idx - 1].z; + diffX = points[currentPoint + 1].x - points[currentPoint - 1].x; + diffZ = points[currentPoint + 1].z - points[currentPoint - 1].z; } - func_8017B7F8(&sp30, RADF_TO_BINANG(func_80086B30(phi_f12, phi_f14)), &sp44, &sp40, &sp3C); - if (((this->actor.world.pos.x * sp44) + (sp40 * this->actor.world.pos.z) + sp3C) > 0.0f) { - sp50 = true; + func_8017B7F8(&point, RADF_TO_BINANG(func_80086B30(diffX, diffZ)), &px, &pz, &d); + + if (((this->actor.world.pos.x * px) + (pz * this->actor.world.pos.z) + d) > 0.0f) { + reached = true; } - return sp50; + return reached; } -s16 func_809895B4(Path* path, s32 idx, Vec3f* pos, f32* distSQ) { +/** + * Returns the Y-rotation the dog should have to move to the next point along its path. + */ +s16 EnDg_GetYRotation(Path* path, s32 index, Vec3f* pos, f32* distSq) { Vec3s* points; f32 diffX; f32 diffZ; if (path != NULL) { points = Lib_SegmentedToVirtual(path->points); - points = &points[idx]; + points = &points[index]; diffX = points->x - pos->x; diffZ = points->z - pos->z; } else { @@ -243,38 +306,42 @@ s16 func_809895B4(Path* path, s32 idx, Vec3f* pos, f32* distSQ) { diffZ = 0.0f; } - *distSQ = SQ(diffX) + SQ(diffZ); + *distSq = SQ(diffX) + SQ(diffZ); return RADF_TO_BINANG(Math_Acot2F(diffZ, diffX)); } -void func_80989674(EnDg* this, GlobalContext* globalCtx) { - s16 phi_a1; - f32 sp30; +/** + * Updates the dog's Y-rotation and speed so that it moves along its path. + */ +void EnDg_MoveAlongPath(EnDg* this, PlayState* play) { + s16 yRotation; + f32 distSq; - if (this->unk_1DC != NULL) { - phi_a1 = func_809895B4(this->unk_1DC, this->unk_1E0, &this->actor.world.pos, &sp30); + if (this->path != NULL) { + yRotation = EnDg_GetYRotation(this->path, this->currentPoint, &this->actor.world.pos, &distSq); if (this->actor.bgCheckFlags & 8) { - phi_a1 = this->actor.wallYaw; + yRotation = this->actor.wallYaw; } - Math_SmoothStepToS(&this->actor.world.rot.y, phi_a1, 4, 0x3E8, 1); + Math_SmoothStepToS(&this->actor.world.rot.y, yRotation, 4, 0x3E8, 1); this->actor.shape.rot.y = this->actor.world.rot.y; - if (func_80989418(this, this->unk_1DC, this->unk_1E0)) { - if (this->unk_1E0 >= (this->unk_1DC->count - 1)) { - this->unk_1E0 = 0; + if (EnDg_HasReachedPoint(this, this->path, this->currentPoint)) { + if (this->currentPoint >= (this->path->count - 1)) { + this->currentPoint = 0; } else { - this->unk_1E0++; + this->currentPoint++; } } - if ((this->unk_286 == 21) || ((this->unk_286 == 20) && (globalCtx->sceneNum == SCENE_OMOYA))) { + if ((this->index == ENDG_INDEX_SWAMP_SPIDER_HOUSE) || + ((this->index == ENDG_INDEX_ROMANI_RANCH) && (play->sceneNum == SCENE_OMOYA))) { Math_ApproachF(&this->actor.speedXZ, 1.0f, 0.2f, 1.0f); - } else if (this->unk_286 == 20) { + } else if (this->index == ENDG_INDEX_ROMANI_RANCH) { Math_ApproachF(&this->actor.speedXZ, 3.5f, 0.2f, 1.0f); - } else if (globalCtx->sceneNum == SCENE_CLOCKTOWER) { + } else if (play->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); @@ -284,199 +351,233 @@ void func_80989674(EnDg* this, GlobalContext* globalCtx) { } } -void func_80989864(EnDg* this, GlobalContext* globalCtx) { - s16 frame = this->skelAnime.curFrame; +void EnDg_SpawnFloorDustRing(EnDg* this, PlayState* play) { + s16 curFrame = this->skelAnime.curFrame; s16 mod = (this->actor.speedXZ > 6.0f) ? 2 : 3; - Vec3f sp38; + Vec3f pos; - if (((this->unk_286 + frame) % mod) == 0) { - sp38.x = randPlusMinusPoint5Scaled(15.0f) + this->actor.world.pos.x; - sp38.y = this->actor.world.pos.y; - sp38.z = randPlusMinusPoint5Scaled(15.0f) + this->actor.world.pos.z; - Actor_SpawnFloorDustRing(globalCtx, &this->actor, &sp38, 10.0f, 0, 2.0f, 300, 0, 1); + if (((this->index + curFrame) % mod) == 0) { + pos.x = randPlusMinusPoint5Scaled(15.0f) + this->actor.world.pos.x; + pos.y = this->actor.world.pos.y; + pos.z = randPlusMinusPoint5Scaled(15.0f) + this->actor.world.pos.z; + Actor_SpawnFloorDustRing(play, &this->actor, &pos, 10.0f, 0, 2.0f, 300, 0, true); } } -void func_80989974(EnDg* this) { +void EnDg_PlaySfxWalk(EnDg* this) { if (Animation_OnFrame(&this->skelAnime, 1.0f) || Animation_OnFrame(&this->skelAnime, 7.0f)) { Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_MONKEY_WALK); } } -void func_809899C8(EnDg* this, f32 arg1) { - if (Animation_OnFrame(&this->skelAnime, arg1)) { +void EnDg_PlaySfxBark(EnDg* this, f32 frame) { + if (Animation_OnFrame(&this->skelAnime, frame)) { Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_SMALL_DOG_BARK); } } -void func_80989A08(EnDg* this, f32 arg1) { - if (Animation_OnFrame(&this->skelAnime, arg1)) { +void EnDg_PlaySfxAngryBark(EnDg* this, f32 frame) { + if (Animation_OnFrame(&this->skelAnime, frame)) { Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_SMALL_DOG_ANG_BARK); } } -void func_80989A48(EnDg* this) { +void EnDg_PlaySfxWhine(EnDg* this) { if (Animation_OnFrame(&this->skelAnime, 23.0f) || Animation_OnFrame(&this->skelAnime, 28.0f)) { Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_SMALL_DOG_WHINE); } } -void func_80989A9C(EnDg* this, f32 arg1) { - if (Animation_OnFrame(&this->skelAnime, arg1)) { +void EnDg_PlaySfxGrowl(EnDg* this, f32 frame) { + if (Animation_OnFrame(&this->skelAnime, frame)) { Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_SMALL_DOG_GROAN); } } -void func_80989ADC(EnDg* this, GlobalContext* globalCtx) { +void EnDg_SetupIdleMove(EnDg* this, PlayState* play) { if (!(this->actor.bgCheckFlags & 0x20)) { - if ((this->unk_286 == 21) || ((this->unk_286 == 20) && (globalCtx->sceneNum == SCENE_OMOYA))) { - func_80989140(&this->skelAnime, sAnimations, 1); - } else if (this->unk_286 == 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) { - func_80989140(&this->skelAnime, sAnimations, 1); + if ((this->index == ENDG_INDEX_SWAMP_SPIDER_HOUSE) || + ((this->index == ENDG_INDEX_ROMANI_RANCH) && (play->sceneNum == SCENE_OMOYA))) { + EnDg_ChangeAnim(&this->skelAnime, sAnimationInfo, DOG_ANIM_WALK); + } else if (this->index == ENDG_INDEX_ROMANI_RANCH) { + EnDg_ChangeAnim(&this->skelAnime, sAnimationInfo, DOG_ANIM_RUN); + } else if (play->sceneNum == SCENE_CLOCKTOWER) { + EnDg_ChangeAnim(&this->skelAnime, sAnimationInfo, DOG_ANIM_RUN); + } else if (sRacetrackDogInfo[this->index].textId & 0x11) { + EnDg_ChangeAnim(&this->skelAnime, sAnimationInfo, DOG_ANIM_WALK); } else { - func_80989140(&this->skelAnime, sAnimations, 2); + EnDg_ChangeAnim(&this->skelAnime, sAnimationInfo, DOG_ANIM_RUN); } - this->actionFunc = func_8098A468; + + this->actionFunc = EnDg_IdleMove; } } -void func_80989BF8(EnDg* this) { - if (this->unk_286 < 14) { - if (this->unk_286 % 2) { - D_8098C2A8[this->unk_286].unk_04 = - 0x3538 + - ((gSaveContext.save.weekEventReg[42 + (this->unk_286 / 2)] & (0x10 | 0x20 | 0x40 | 0x80)) >> 4); +/** + * Updates the text ID in sRacetrackDogInfo based on what was set in the weekEventRegs by + * En_Aob_01. This makes it sp the proper message can be displayed when the player picks up + * the dog with the Mask of Truth equipped. + */ +void EnDg_UpdateTextId(EnDg* this) { + if (this->index < 14) { + // Assuming that the weekEventRegs haven't been tampered with, then this will produce a text ID in + // the range of 0x3538 to 0x3545. + if (this->index % 2) { + sRacetrackDogInfo[this->index].textId = + 0x3538 + ((gSaveContext.save.weekEventReg[42 + (this->index / 2)] & 0xF0) >> 4); } else { - D_8098C2A8[this->unk_286].unk_04 = - 0x3538 + (gSaveContext.save.weekEventReg[42 + (this->unk_286 / 2)] & (1 | 2 | 4 | 8)); + sRacetrackDogInfo[this->index].textId = + 0x3538 + (gSaveContext.save.weekEventReg[42 + (this->index / 2)] & 0x0F); } } 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; + // As a sanity check, this makes sure the text ID is something in the expected range of 0x3538 to 0x3546. + if ((sRacetrackDogInfo[this->index].textId > 0x3546) || (sRacetrackDogInfo[this->index].textId < 0x3538)) { + sRacetrackDogInfo[this->index].textId = 0x353E; } - if (D_8098C2A8[this->unk_286].unk_04 == 0x353D) { - D_8098C2A8[this->unk_286].unk_04 = 0x3538; + // Text ID 0x353D is the text for the Romani Ranch dog, which is in the middle of the race dog block. If + // the dog ends up with this text ID, adjust it so the dog says a different message indcating it's in + // good condition. + if (sRacetrackDogInfo[this->index].textId == 0x353D) { + sRacetrackDogInfo[this->index].textId = 0x3538; } } -void func_80989D38(EnDg* this, GlobalContext* globalCtx) { - if (this->unk_286 == 21) { +void EnDg_StartTextBox(EnDg* this, PlayState* play) { + if (this->index == ENDG_INDEX_SWAMP_SPIDER_HOUSE) { if (CURRENT_DAY == 1) { - Message_StartTextbox(globalCtx, 0x91C, NULL); + // Stupid master... + Message_StartTextbox(play, 0x91C, NULL); } else { - Message_StartTextbox(globalCtx, 0x91E, NULL); + // I miss the ranch... + Message_StartTextbox(play, 0x91E, NULL); } - } else if ((this->unk_286 >= 0) && (this->unk_286 < 14)) { - Message_StartTextbox(globalCtx, D_8098C2A8[this->unk_286].unk_04, NULL); - } else if (this->unk_286 == 20) { - Message_StartTextbox(globalCtx, 0x353D, NULL); + } else if ((this->index >= ENDG_INDEX_RACETRACK_0) && (this->index <= ENDG_INDEX_RACETRACK_13)) { + Message_StartTextbox(play, sRacetrackDogInfo[this->index].textId, NULL); + } else if (this->index == ENDG_INDEX_ROMANI_RANCH) { + // I wonder if I can stop practicing... + Message_StartTextbox(play, 0x353D, NULL); } else { - Message_StartTextbox(globalCtx, 0x627, NULL); + // Where did that Deku Scrub go? + Message_StartTextbox(play, 0x627, NULL); } } -void func_80989E18(EnDg* this, GlobalContext* globalCtx) { - D_8098C2A8_s* temp; - - if ((D_8098C2A0 != 0) && !(this->unk_280 & 1)) { +/** + * Checks to see if the player picked up the dog and sets the appropriate state if they did. + */ +void EnDg_TryPickUp(EnDg* this, PlayState* play) { + if (sIsAnyDogHeld && !(this->dogFlags & DOG_FLAG_HELD)) { this->actor.flags |= ACTOR_FLAG_8000000; - this->unk_280 |= 1; - } else if ((D_8098C2A0 == 0) && (this->unk_280 & 1)) { + this->dogFlags |= DOG_FLAG_HELD; + } else if (!sIsAnyDogHeld && (this->dogFlags & DOG_FLAG_HELD)) { this->actor.flags &= ~ACTOR_FLAG_8000000; - this->unk_280 &= ~1; + this->dogFlags &= ~DOG_FLAG_HELD; } - if (Actor_HasParent(&this->actor, globalCtx)) { + if (Actor_HasParent(&this->actor, play)) { Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_SMALL_DOG_BARK); - this->unk_290 = 1; - D_8098C2FC = D_8098C2A8[this->unk_286]; - if (D_8098C2A0 == 0) { + this->grabState = DOG_GRAB_STATE_HELD; + sSelectedRacetrackDogInfo = sRacetrackDogInfo[this->index]; + if (!sIsAnyDogHeld) { this->actor.flags |= ACTOR_FLAG_8000000; - D_8098C2A0 = 1; - this->unk_280 |= 1; + sIsAnyDogHeld = true; + this->dogFlags |= DOG_FLAG_HELD; } - func_80989140(&this->skelAnime, sAnimations, 5); + EnDg_ChangeAnim(&this->skelAnime, sAnimationInfo, DOG_ANIM_SIT_DOWN); this->actor.flags &= ~ACTOR_FLAG_1; this->actor.speedXZ = 0.0f; - if (Player_GetMask(globalCtx) == PLAYER_MASK_TRUTH) { + if (Player_GetMask(play) == PLAYER_MASK_TRUTH) { this->actor.flags |= ACTOR_FLAG_10000; - func_800B8614(&this->actor, globalCtx, 100.0f); - this->actionFunc = func_8098BBEC; + func_800B8614(&this->actor, play, 100.0f); + this->actionFunc = EnDg_SetupTalk; } else { - this->actionFunc = func_8098BA64; + this->actionFunc = EnDg_Held; } } else { - Actor_LiftActor(&this->actor, globalCtx); + Actor_LiftActor(&this->actor, play); } } -s32 func_80989FC8(GlobalContext* globalCtx) { - EnDg* enemy = (EnDg*)globalCtx->actorCtx.actorLists[ACTORCAT_ENEMY].first; +/** + * Returns true if it finds a dog to follow the player around while they're marching with + * the Bremen Mask. The index of the dog it finds is stored in sBremenMaskFollowerIndex. + */ +s32 EnDg_FindFollowerForBremenMask(PlayState* play) { + Actor* enemy = play->actorCtx.actorLists[ACTORCAT_ENEMY].first; f32 minDist = 9999.0f; f32 dist; while (enemy != NULL) { - if (enemy->actor.id == ACTOR_EN_DG) { - if (enemy->actor.isTargeted) { - D_8098C2A4.unk_00 = enemy->unk_286; + if (enemy->id == ACTOR_EN_DG) { + if (enemy->isTargeted) { + sBremenMaskFollowerIndex = ((EnDg*)enemy)->index; return true; } - dist = enemy->actor.xzDistToPlayer; + dist = enemy->xzDistToPlayer; if (dist < minDist) { - D_8098C2A4.unk_00 = enemy->unk_286; + sBremenMaskFollowerIndex = ((EnDg*)enemy)->index; minDist = dist; } } - enemy = (EnDg*)enemy->actor.next; + + enemy = enemy->next; } - if (D_8098C2A4.unk_00 != 99) { + if (sBremenMaskFollowerIndex != ENDG_INDEX_NO_BREMEN_MASK_FOLLOWER) { return true; } return false; } -void func_8098A064(EnDg* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); +/** + * This checks for two conditions: + * - If the player has started marching with the Bremen Mask, then it makes the dog + * start following the player around (assuming it's the best candidate found in + * EnDg_FindFollowerForBremenMask above). + * - If the player has stopped marching with the Bremen Mask, and this dog was + * following them around, then it returns the dog to its idle state. + */ +void EnDg_CheckForBremenMaskMarch(EnDg* this, PlayState* play) { + Player* player = GET_PLAYER(play); - if (player->stateFlags3 & 0x20000000) { - if (D_8098C2A4.unk_00 == 99) { - func_80989FC8(globalCtx); + if (player->stateFlags3 & 0x20000000) { // bremen mask march + if (sBremenMaskFollowerIndex == ENDG_INDEX_NO_BREMEN_MASK_FOLLOWER) { + EnDg_FindFollowerForBremenMask(play); } - if (this->unk_286 == D_8098C2A4.unk_00) { - if (!(this->unk_280 & 0x20)) { - this->unk_280 |= 0x20; - func_80989140(&this->skelAnime, sAnimations, 1); - this->actionFunc = func_8098AF44; - } else if ((this->actionFunc == func_8098B004) || (this->actionFunc == func_8098AB48)) { - if (DECR(this->unk_292) == 0) { - this->unk_292 = 10; + if (this->index == sBremenMaskFollowerIndex) { + if (!(this->dogFlags & DOG_FLAG_FOLLOWING_BREMEN_MASK)) { + this->dogFlags |= DOG_FLAG_FOLLOWING_BREMEN_MASK; + EnDg_ChangeAnim(&this->skelAnime, sAnimationInfo, DOG_ANIM_WALK); + this->actionFunc = EnDg_SetupBremenMaskApproachPlayer; + } else if ((this->actionFunc == EnDg_ApproachPlayer) || (this->actionFunc == EnDg_SitNextToPlayer)) { + if (DECR(this->bremenBarkTimer) == 0) { + this->bremenBarkTimer = 10; Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_SMALL_DOG_BARK); } } } - } else if (this->unk_286 == D_8098C2A4.unk_00) { - this->unk_280 &= ~0x20; - D_8098C2A4.unk_00 = 99; - func_80989ADC(this, globalCtx); - this->actionFunc = func_8098A468; + } else if (this->index == sBremenMaskFollowerIndex) { + this->dogFlags &= ~DOG_FLAG_FOLLOWING_BREMEN_MASK; + sBremenMaskFollowerIndex = ENDG_INDEX_NO_BREMEN_MASK_FOLLOWER; + EnDg_SetupIdleMove(this, play); + this->actionFunc = EnDg_IdleMove; } } -s32 func_8098A1B4(EnDg* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); +/** + * Returns true if the player is not human and the dog is close enough to start + * reacting to their current form. + */ +s32 EnDg_ShouldReactToNonHumanPlayer(EnDg* this, PlayState* play) { + Player* player = GET_PLAYER(play); switch (player->transformation) { case PLAYER_FORM_GORON: @@ -484,7 +585,7 @@ s32 func_8098A1B4(EnDg* this, GlobalContext* globalCtx) { if (this->actor.xzDistToPlayer < 300.0f) { return true; } - + // fallthrough case PLAYER_FORM_DEKU: if (this->actor.xzDistToPlayer < 250.0f) { return true; @@ -495,144 +596,167 @@ s32 func_8098A1B4(EnDg* this, GlobalContext* globalCtx) { return false; } -void func_8098A234(EnDg* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); +/** + * Sets the appropriate actionFunc given the player's current form and the dog's current behavior. + * Specifically, it makes sure that the dog doesn't start reacting to the player's form until the + * player starts moving a bit. This was presumably done so the player could more easily react to + * the dog changing its behavior; it would be strange if the dog attacked the player the instant + * they put on the Deku Mask, for example. + */ +void EnDg_ChooseActionForForm(EnDg* this, PlayState* play) { + Player* player = GET_PLAYER(play); if (!(this->actor.bgCheckFlags & 0x20)) { switch (player->transformation) { case PLAYER_FORM_HUMAN: - if (this->unk_28C != 1) { - this->unk_28C = 1; - this->unk_280 &= ~2; - func_80989ADC(this, globalCtx); + if (this->behavior != DOG_BEHAVIOR_HUMAN) { + this->behavior = DOG_BEHAVIOR_HUMAN; + this->dogFlags &= ~DOG_FLAG_JUMP_ATTACKING; + EnDg_SetupIdleMove(this, play); } break; case PLAYER_FORM_ZORA: - this->unk_280 &= ~2; - if ((this->unk_28C != 4) && (player->actor.speedXZ > 1.0f)) { - this->unk_28C = 4; - func_80989140(&this->skelAnime, sAnimations, 2); - this->actionFunc = func_8098B004; + this->dogFlags &= ~DOG_FLAG_JUMP_ATTACKING; + if ((this->behavior != DOG_BEHAVIOR_ZORA) && (player->actor.speedXZ > 1.0f)) { + this->behavior = DOG_BEHAVIOR_ZORA; + EnDg_ChangeAnim(&this->skelAnime, sAnimationInfo, DOG_ANIM_RUN); + this->actionFunc = EnDg_ApproachPlayer; } - if ((this->unk_28C != 5) && (this->unk_28C != 4)) { - this->unk_28C = 5; - func_80989ADC(this, globalCtx); + if ((this->behavior != DOG_BEHAVIOR_ZORA_WAIT) && (this->behavior != DOG_BEHAVIOR_ZORA)) { + this->behavior = DOG_BEHAVIOR_ZORA_WAIT; + EnDg_SetupIdleMove(this, play); } break; case PLAYER_FORM_GORON: - this->unk_280 &= ~2; - if ((this->unk_28C != 2) && (player->actor.speedXZ > 1.0f)) { - this->unk_28C = 2; - func_80989140(&this->skelAnime, sAnimations, 11); - this->unk_282 = 50; - this->actionFunc = func_8098A618; + this->dogFlags &= ~DOG_FLAG_JUMP_ATTACKING; + if ((this->behavior != DOG_BEHAVIOR_GORON) && (player->actor.speedXZ > 1.0f)) { + this->behavior = DOG_BEHAVIOR_GORON; + EnDg_ChangeAnim(&this->skelAnime, sAnimationInfo, DOG_ANIM_WALK_BACKWARDS); + this->timer = 50; + this->actionFunc = EnDg_BackAwayFromGoron; } - if ((this->unk_28C != 3) && (this->unk_28C != 2)) { - this->unk_28C = 3; - func_80989ADC(this, globalCtx); + if ((this->behavior != DOG_BEHAVIOR_GORON_WAIT) && (this->behavior != DOG_BEHAVIOR_GORON)) { + this->behavior = DOG_BEHAVIOR_GORON_WAIT; + EnDg_SetupIdleMove(this, play); } break; case PLAYER_FORM_DEKU: - this->unk_280 &= ~2; - if ((this->unk_28C != 6) && (player->actor.speedXZ > 1.0f)) { - this->unk_28C = 6; - func_80989140(&this->skelAnime, sAnimations, 2); - this->actionFunc = func_8098A938; + this->dogFlags &= ~DOG_FLAG_JUMP_ATTACKING; + if ((this->behavior != DOG_BEHAVIOR_DEKU) && (player->actor.speedXZ > 1.0f)) { + this->behavior = DOG_BEHAVIOR_DEKU; + EnDg_ChangeAnim(&this->skelAnime, sAnimationInfo, DOG_ANIM_RUN); + this->actionFunc = EnDg_ApproachPlayerToAttack; } - if ((this->unk_28C != 7) && (this->unk_28C != 6)) { - this->unk_28C = 7; - func_80989ADC(this, globalCtx); + if ((this->behavior != DOG_BEHAVIOR_DEKU_WAIT) && (this->behavior != DOG_BEHAVIOR_DEKU)) { + this->behavior = DOG_BEHAVIOR_DEKU_WAIT; + EnDg_SetupIdleMove(this, play); } break; } } } -void func_8098A468(EnDg* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); +/** + * Moves the dog along its path, stopping to bark at random intervals. + */ +void EnDg_IdleMove(EnDg* this, PlayState* play) { + Player* player = GET_PLAYER(play); this->actor.velocity.y = 0.0f; this->actor.gravity = -3.0f; - func_80989674(this, globalCtx); + EnDg_MoveAlongPath(this, play); Actor_MoveWithGravity(&this->actor); if (player->transformation == PLAYER_FORM_HUMAN) { - func_80989E18(this, globalCtx); + EnDg_TryPickUp(this, play); } - func_8098A064(this, globalCtx); - func_80989974(this); + EnDg_CheckForBremenMaskMarch(this, play); + EnDg_PlaySfxWalk(this); if (!(this->actor.bgCheckFlags & 1)) { - this->actionFunc = func_8098AF98; + this->actionFunc = EnDg_Fall; } - if (DECR(this->unk_282) == 0) { - this->unk_282 = Rand_S16Offset(20, 20); - func_80989140(&this->skelAnime, sAnimations, 3); - this->actionFunc = func_8098A55C; + if (DECR(this->timer) == 0) { + this->timer = Rand_S16Offset(20, 20); + EnDg_ChangeAnim(&this->skelAnime, sAnimationInfo, DOG_ANIM_BARK); + this->actionFunc = EnDg_IdleBark; } } -void func_8098A55C(EnDg* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); +/** + * Stops and barks, before returning to moving along its path. + */ +void EnDg_IdleBark(EnDg* this, PlayState* play) { + Player* player = GET_PLAYER(play); if (player->transformation == PLAYER_FORM_HUMAN) { - func_80989E18(this, globalCtx); + EnDg_TryPickUp(this, play); } - func_809899C8(this, 13.0f); - func_809899C8(this, 19.0f); + EnDg_PlaySfxBark(this, 13.0f); + EnDg_PlaySfxBark(this, 19.0f); + if (!(this->actor.bgCheckFlags & 1)) { - this->actionFunc = func_8098AF98; + this->actionFunc = EnDg_Fall; } - if (DECR(this->unk_282) == 0) { - this->unk_282 = Rand_S16Offset(60, 60); - func_80989ADC(this, globalCtx); + if (DECR(this->timer) == 0) { + this->timer = Rand_S16Offset(60, 60); + EnDg_SetupIdleMove(this, play); } } -void func_8098A618(EnDg* this, GlobalContext* globalCtx) { +/** + * Slowly back away from the player while growling. After a short time backing away, + * this function will make the dog away from the player. + */ +void EnDg_BackAwayFromGoron(EnDg* this, PlayState* play) { this->actor.velocity.y = 0.0f; this->actor.gravity = -3.0f; - if (DECR(this->unk_282) == 0) { - this->unk_282 = 50; - func_80989140(&this->skelAnime, sAnimations, 2); - this->actionFunc = func_8098A70C; + if (DECR(this->timer) == 0) { + this->timer = 50; + EnDg_ChangeAnim(&this->skelAnime, sAnimationInfo, DOG_ANIM_RUN); + this->actionFunc = EnDg_RunAwayFromGoron; } else { Math_SmoothStepToS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer, 4, 0x3E8, 1); if (this->actor.bgCheckFlags & 8) { this->actor.shape.rot.y = this->actor.wallYaw; } + this->actor.world.rot.y = this->actor.shape.rot.y; Math_ApproachF(&this->actor.speedXZ, -1.5f, 0.2f, 1.0f); Actor_MoveWithGravity(&this->actor); } - func_80989974(this); - func_80989A9C(this, 0); + EnDg_PlaySfxWalk(this); + EnDg_PlaySfxGrowl(this, 0); } -void func_8098A70C(EnDg* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); - s16 phi_a1; +/** + * Quickly run away from the player. Once the dog is far enough from the player, + * this function will make them start barking at them. + */ +void EnDg_RunAwayFromGoron(EnDg* this, PlayState* play) { + Player* player = GET_PLAYER(play); + s16 yRotation; if (this->actor.xzDistToPlayer < 250.0f) { Math_ApproachS(&this->actor.shape.rot.y, -this->actor.yawTowardsPlayer, 4, 0xC00); if (this->actor.bgCheckFlags & 8) { - phi_a1 = this->actor.wallYaw; + yRotation = this->actor.wallYaw; } else { - phi_a1 = 0; + yRotation = 0; } - Math_SmoothStepToS(&this->actor.world.rot.y, phi_a1, 4, 0x3E8, 1); + Math_SmoothStepToS(&this->actor.world.rot.y, yRotation, 4, 0x3E8, 1); this->actor.world.rot.y = this->actor.shape.rot.y; if (player->actor.speedXZ != 0.0f) { Math_ApproachF(&this->actor.speedXZ, player->actor.speedXZ, 0.2f, 1.0f); @@ -640,8 +764,8 @@ void func_8098A70C(EnDg* this, GlobalContext* globalCtx) { Math_ApproachF(&this->actor.speedXZ, 3.5f, 0.2f, 1.0f); } } else { - func_80989140(&this->skelAnime, sAnimations, 3); - this->actionFunc = func_8098A89C; + EnDg_ChangeAnim(&this->skelAnime, sAnimationInfo, DOG_ANIM_BARK); + this->actionFunc = EnDg_BarkAtGoron; } if (this->actor.speedXZ > 7.0f) { @@ -649,7 +773,8 @@ void func_8098A70C(EnDg* this, GlobalContext* globalCtx) { } Actor_MoveWithGravity(&this->actor); - func_80989974(this); + EnDg_PlaySfxWalk(this); + if (Animation_OnFrame(&this->skelAnime, 3.0f)) { Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_SMALL_DOG_CRY); } else if (Animation_OnFrame(&this->skelAnime, 6.0f)) { @@ -657,21 +782,24 @@ void func_8098A70C(EnDg* this, GlobalContext* globalCtx) { } } -void func_8098A89C(EnDg* this, GlobalContext* globalCtx) { +/** + * Bark at the player until they get close enough, at which point the dog starts backing away. + */ +void EnDg_BarkAtGoron(EnDg* this, PlayState* play) { Math_ApproachS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer, 4, 0xC00); this->actor.world.rot.y = this->actor.shape.rot.y; if (this->actor.xzDistToPlayer < 250.0f) { - func_80989140(&this->skelAnime, sAnimations, 11); - this->unk_282 = 50; - this->actionFunc = func_8098A618; + EnDg_ChangeAnim(&this->skelAnime, sAnimationInfo, DOG_ANIM_WALK_BACKWARDS); + this->timer = 50; + this->actionFunc = EnDg_BackAwayFromGoron; } - func_80989A08(this, 13.0f); - func_80989A08(this, 19.0f); + EnDg_PlaySfxAngryBark(this, 13.0f); + EnDg_PlaySfxAngryBark(this, 19.0f); } -void func_8098A938(EnDg* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); +void EnDg_ApproachPlayerToAttack(EnDg* this, PlayState* play) { + Player* player = GET_PLAYER(play); this->actor.velocity.y = 0.0f; this->actor.gravity = -3.0f; @@ -683,16 +811,16 @@ void func_8098A938(EnDg* this, GlobalContext* globalCtx) { if (this->actor.xzDistToPlayer < 70.0f) { Math_ApproachZeroF(&this->actor.speedXZ, 0.2f, 1.0f); if (Animation_OnFrame(&this->skelAnime, 7.0f)) { - s16 y = ABS_ALT(player->actor.shape.rot.y - this->actor.shape.rot.y); + s16 yawDiff = ABS_ALT(player->actor.shape.rot.y - this->actor.shape.rot.y); - this->unk_28E = 20; - if (y < 0x4000) { - func_80989140(&this->skelAnime, sAnimations, 14); - this->actionFunc = func_8098AC34; + this->attackTimer = 20; + if (yawDiff < 0x4000) { + EnDg_ChangeAnim(&this->skelAnime, sAnimationInfo, DOG_ANIM_JUMP_ATTACK); + this->actionFunc = EnDg_JumpAttack; } else { - func_80989140(&this->skelAnime, sAnimations, 11); - sAnimations[11].playSpeed = -1.0f; - this->actionFunc = func_8098B198; + EnDg_ChangeAnim(&this->skelAnime, sAnimationInfo, DOG_ANIM_WALK_BACKWARDS); + sAnimationInfo[DOG_ANIM_WALK_BACKWARDS].playSpeed = -1.0f; + this->actionFunc = EnDg_SlowlyBackUpBeforeAttacking; } } } else { @@ -701,102 +829,121 @@ void func_8098A938(EnDg* this, GlobalContext* globalCtx) { } Actor_MoveWithGravity(&this->actor); - func_80989974(this); - func_80989A08(this, 5.0f); + EnDg_PlaySfxWalk(this); + EnDg_PlaySfxAngryBark(this, 5.0f); } -void func_8098AAAC(EnDg* this, GlobalContext* globalCtx) { - this->unk_280 &= ~8; +/** + * Makes the dog run around for a bit after attacking before it + * starts to approach the player for another attack. + */ +void EnDg_RunAfterAttacking(EnDg* this, PlayState* play) { + this->dogFlags &= ~DOG_FLAG_BOUNCED; Math_ApproachF(&this->actor.speedXZ, 3.5f, 0.1f, 0.5f); Actor_MoveWithGravity(&this->actor); - if (DECR(this->unk_28E) == 0) { - this->unk_28E = 20; - this->actionFunc = func_8098A938; + if (DECR(this->attackTimer) == 0) { + this->attackTimer = 20; + this->actionFunc = EnDg_ApproachPlayerToAttack; } - func_80989974(this); - func_80989A08(this, 3.0f); + EnDg_PlaySfxWalk(this); + EnDg_PlaySfxAngryBark(this, 3.0f); } -void func_8098AB48(EnDg* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); +/** + * Makes the dog sit next to the player until they get too far away, at which point + * it will attempt to approach them again. + */ +void EnDg_SitNextToPlayer(EnDg* this, PlayState* play) { + Player* player = GET_PLAYER(play); if (!(this->actor.bgCheckFlags & 1)) { - this->actionFunc = func_8098AF98; + this->actionFunc = EnDg_Fall; } if (this->actor.xzDistToPlayer < 50.0f) { Math_ApproachS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer, 4, 0xC00); this->actor.world.rot.y = this->actor.shape.rot.y; } else { - if (player->stateFlags3 & 0x20000000) { - func_80989140(&this->skelAnime, sAnimations, 1); + if (player->stateFlags3 & 0x20000000) { // bremen mask march + EnDg_ChangeAnim(&this->skelAnime, sAnimationInfo, DOG_ANIM_WALK); } else { - func_80989140(&this->skelAnime, sAnimations, 2); + EnDg_ChangeAnim(&this->skelAnime, sAnimationInfo, DOG_ANIM_RUN); } - this->actionFunc = func_8098B004; + + this->actionFunc = EnDg_ApproachPlayer; } - func_8098A064(this, globalCtx); - if (!(this->unk_280 & 0x20)) { - func_80989A48(this); + EnDg_CheckForBremenMaskMarch(this, play); + + // If we're in this function, the player is either marching with the Bremen Mask, or + // they're a Zora. The below code will make the dog repeatedly whine in the latter case. + if (!(this->dogFlags & DOG_FLAG_FOLLOWING_BREMEN_MASK)) { + EnDg_PlaySfxWhine(this); } } -void func_8098AC34(EnDg* this, GlobalContext* globalCtx) { - s16 sp26 = this->skelAnime.curFrame; +void EnDg_JumpAttack(EnDg* this, PlayState* play) { + s16 curFrame = this->skelAnime.curFrame; if ((this->actor.xyzDistToPlayerSq < 800.0f) && (this->collider.base.atFlags & AT_BOUNCED)) { - this->unk_28E = 60; - this->unk_280 &= ~2; - this->unk_280 |= 8; + this->attackTimer = 60; + this->dogFlags &= ~DOG_FLAG_JUMP_ATTACKING; + this->dogFlags |= DOG_FLAG_BOUNCED; this->collider.base.atFlags &= ~AT_BOUNCED; this->actor.speedXZ *= -1.0f; - func_80989140(&this->skelAnime, sAnimations, 2); - this->actionFunc = func_8098AAAC; + EnDg_ChangeAnim(&this->skelAnime, sAnimationInfo, DOG_ANIM_RUN); + this->actionFunc = EnDg_RunAfterAttacking; return; } - if (DECR(this->unk_28E) == 0) { - this->unk_28E = 60; - this->unk_280 &= ~2; - func_80989140(&this->skelAnime, sAnimations, 2); - this->actionFunc = func_8098AAAC; + if (DECR(this->attackTimer) == 0) { + this->attackTimer = 60; + this->dogFlags &= ~DOG_FLAG_JUMP_ATTACKING; + EnDg_ChangeAnim(&this->skelAnime, sAnimationInfo, DOG_ANIM_RUN); + this->actionFunc = EnDg_RunAfterAttacking; } - if (sp26 < 9) { + if (curFrame < 9) { if (Animation_OnFrame(&this->skelAnime, 0.0f)) { - sAnimations[14].playSpeed = randPlusMinusPoint5Scaled(1.0f) + 3.0f; + sAnimationInfo[DOG_ANIM_JUMP_ATTACK].playSpeed = randPlusMinusPoint5Scaled(1.0f) + 3.0f; } - func_80989864(this, globalCtx); + + EnDg_SpawnFloorDustRing(this, play); } else { - this->unk_280 |= 2; + this->dogFlags |= DOG_FLAG_JUMP_ATTACKING; if (Animation_OnFrame(&this->skelAnime, 9.0f)) { f32 rand = randPlusMinusPoint5Scaled(1.5f); - sAnimations[14].playSpeed = 1.2f; + sAnimationInfo[DOG_ANIM_JUMP_ATTACK].playSpeed = 1.2f; this->actor.velocity.y = 2.0f * rand + 3.0f; this->actor.speedXZ = 8.0f + rand; - } else if (sp26 >= 0x15) { + } else if (curFrame > 20) { Math_ApproachF(&this->actor.speedXZ, 2.5f, 0.2f, 1.0f); } - if (sp26 >= 0x18) { - func_80989864(this, globalCtx); + + if (curFrame > 23) { + EnDg_SpawnFloorDustRing(this, play); } + Actor_MoveWithGravity(&this->actor); } - func_80989A9C(this, 10.0f); + EnDg_PlaySfxGrowl(this, 10.0f); } -// Unused? -void func_8098AE58(EnDg* this, GlobalContext* globalCtx) { +/** + * An unused function that will make the dog walk slowly towards the player until they're + * in a specific range, at which point they will bark at them. This might be part of an + * unused or early variation of how dogs react to Goron Link. + */ +void EnDg_WalkToPlayer(EnDg* this, PlayState* play) { if (this->actor.xzDistToPlayer < 150.0f) { - func_80989140(&this->skelAnime, sAnimations, 11); - this->actionFunc = func_8098B28C; + EnDg_ChangeAnim(&this->skelAnime, sAnimationInfo, DOG_ANIM_WALK_BACKWARDS); + this->actionFunc = EnDg_BackAwayFromPlayer; } else if (this->actor.xzDistToPlayer < 200.0f) { - func_80989140(&this->skelAnime, sAnimations, 3); - this->actionFunc = func_8098B390; + EnDg_ChangeAnim(&this->skelAnime, sAnimationInfo, DOG_ANIM_BARK); + this->actionFunc = EnDg_BarkAtPlayer; } else { Math_ApproachS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer, 4, 0xC00); this->actor.world.rot.y = this->actor.shape.rot.y; @@ -804,30 +951,34 @@ void func_8098AE58(EnDg* this, GlobalContext* globalCtx) { Actor_MoveWithGravity(&this->actor); } - func_80989974(this); - func_809899C8(this, 5.0f); + EnDg_PlaySfxWalk(this); + EnDg_PlaySfxBark(this, 5.0f); } -void func_8098AF44(EnDg* this, GlobalContext* globalCtx) { +void EnDg_SetupBremenMaskApproachPlayer(EnDg* this, PlayState* play) { if (func_801A46F8() == 1) { - this->unk_292 = 10; + this->bremenBarkTimer = 10; Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_SMALL_DOG_BARK); - this->actionFunc = func_8098B004; + this->actionFunc = EnDg_ApproachPlayer; } } -void func_8098AF98(EnDg* this, GlobalContext* globalCtx) { +void EnDg_Fall(EnDg* this, PlayState* play) { if (this->actor.bgCheckFlags & 1) { - func_80989140(&this->skelAnime, sAnimations, 2); - this->actionFunc = func_8098A468; + EnDg_ChangeAnim(&this->skelAnime, sAnimationInfo, DOG_ANIM_RUN); + this->actionFunc = EnDg_IdleMove; } Actor_MoveWithGravity(&this->actor); - func_809899C8(this, 3.0f); + EnDg_PlaySfxBark(this, 3.0f); } -void func_8098B004(EnDg* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); +/** + * Approach the player non-aggressively. If the player stops moving, then + * eventually the dog will sit down next to them. + */ +void EnDg_ApproachPlayer(EnDg* this, PlayState* play) { + Player* player = GET_PLAYER(play); this->actor.velocity.y = 0.0f; this->actor.gravity = -3.0f; @@ -839,9 +990,9 @@ void func_8098B004(EnDg* this, GlobalContext* globalCtx) { this->actor.world.rot.y = this->actor.shape.rot.y; if (this->actor.xzDistToPlayer < 40.0f) { - func_80989140(&this->skelAnime, sAnimations, 5); - this->actionFunc = func_8098AB48; - } else if (player->stateFlags3 & 0x20000000) { + EnDg_ChangeAnim(&this->skelAnime, sAnimationInfo, DOG_ANIM_SIT_DOWN); + this->actionFunc = EnDg_SitNextToPlayer; + } else if (player->stateFlags3 & 0x20000000) { // bremen mask march if ((this->actor.xzDistToPlayer > 40.0f) && (player->linearVelocity == 0.0f)) { Math_ApproachF(&this->actor.speedXZ, 1.5f, 0.2f, 1.0f); } else { @@ -851,41 +1002,54 @@ void func_8098B004(EnDg* this, GlobalContext* globalCtx) { Math_ApproachF(&this->actor.speedXZ, 3.5f, 0.2f, 1.0f); } - func_8098A064(this, globalCtx); + EnDg_CheckForBremenMaskMarch(this, play); Actor_MoveWithGravity(&this->actor); - func_80989974(this); - if (!(this->unk_280 & 0x20)) { - func_809899C8(this, 3.0f); + EnDg_PlaySfxWalk(this); + + // If we're in this function, the player is either marching with the Bremen Mask, or + // they're a Zora. The below code will make the dog repeatedly bark in the latter case. + if (!(this->dogFlags & DOG_FLAG_FOLLOWING_BREMEN_MASK)) { + EnDg_PlaySfxBark(this, 3.0f); } } -void func_8098B198(EnDg* this, GlobalContext* globalCtx) { +/** + * Makes the dog slowly back up and face the player before performing a jump attack. Used to + * give the dog a bit of time to correct its angle if they were unlikely to hit the player. + */ +void EnDg_SlowlyBackUpBeforeAttacking(EnDg* this, PlayState* play) { if (this->actor.xzDistToPlayer > 72.0f) { - func_80989140(&this->skelAnime, sAnimations, 14); - this->actionFunc = func_8098AC34; + EnDg_ChangeAnim(&this->skelAnime, sAnimationInfo, DOG_ANIM_JUMP_ATTACK); + this->actionFunc = EnDg_JumpAttack; } Math_SmoothStepToS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer, 4, 0x3E8, 1); if (this->actor.bgCheckFlags & 8) { this->actor.shape.rot.y = this->actor.wallYaw; - func_80989140(&this->skelAnime, sAnimations, 14); - this->actionFunc = func_8098AC34; + EnDg_ChangeAnim(&this->skelAnime, sAnimationInfo, DOG_ANIM_JUMP_ATTACK); + this->actionFunc = EnDg_JumpAttack; } this->actor.world.rot.y = this->actor.shape.rot.y; Math_ApproachF(&this->actor.speedXZ, -1.0f, 0.2f, 1.0f); Actor_MoveWithGravity(&this->actor); - func_80989974(this); - func_80989A9C(this, 4.0f); + EnDg_PlaySfxWalk(this); + EnDg_PlaySfxGrowl(this, 4.0f); } -void func_8098B28C(EnDg* this, GlobalContext* globalCtx) { +/** + * An unused function that will make the dog back away from the player while growling. + * It is quite similar to EnDg_BackAwayFromGoron; perhaps this is an earlier version of it? + * Unlike that function, this will make the dog approach the player if they move too far away. + * It also lacks the behavior where the dog runs away in a panic after a short time. + */ +void EnDg_BackAwayFromPlayer(EnDg* this, PlayState* play) { if (this->actor.xzDistToPlayer > 200.0f) { - func_80989140(&this->skelAnime, sAnimations, 1); - this->actionFunc = func_8098AE58; + EnDg_ChangeAnim(&this->skelAnime, sAnimationInfo, DOG_ANIM_WALK); + this->actionFunc = EnDg_WalkToPlayer; } else if (this->actor.xzDistToPlayer > 150.0f) { - func_80989140(&this->skelAnime, sAnimations, 3); - this->actionFunc = func_8098B390; + EnDg_ChangeAnim(&this->skelAnime, sAnimationInfo, DOG_ANIM_BARK); + this->actionFunc = EnDg_BarkAtPlayer; } else { Math_SmoothStepToS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer, 4, 0x3E8, 1); if (this->actor.bgCheckFlags & 8) { @@ -897,69 +1061,86 @@ void func_8098B28C(EnDg* this, GlobalContext* globalCtx) { Actor_MoveWithGravity(&this->actor); } - func_80989974(this); + EnDg_PlaySfxWalk(this); Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_SMALL_DOG_GROAN); } -void func_8098B390(EnDg* this, GlobalContext* globalCtx) { +/** + * An unused function that will make the dog bark at the player endlessly. + * It is quite similar to EnDg_BarkAtGoron; perhaps this is an earlier version of it? + * Unlike that function, this will make the dog approach the player if they move too far away. + * It also mixes in multiple growls into the bark. + */ +void EnDg_BarkAtPlayer(EnDg* this, PlayState* play) { if (this->actor.xzDistToPlayer < 150.0f) { - func_80989140(&this->skelAnime, sAnimations, 11); - this->actionFunc = func_8098B28C; + EnDg_ChangeAnim(&this->skelAnime, sAnimationInfo, DOG_ANIM_WALK_BACKWARDS); + this->actionFunc = EnDg_BackAwayFromPlayer; } else if (this->actor.xzDistToPlayer > 200.0f) { - func_80989140(&this->skelAnime, sAnimations, 1); - this->actionFunc = func_8098AE58; + EnDg_ChangeAnim(&this->skelAnime, sAnimationInfo, DOG_ANIM_WALK); + this->actionFunc = EnDg_WalkToPlayer; } - func_80989A9C(this, 0.0f); - func_80989A9C(this, 1.0f); - func_80989A9C(this, 2.0f); - func_80989A9C(this, 3.0f); - func_809899C8(this, 5.0f); + EnDg_PlaySfxGrowl(this, 0.0f); + EnDg_PlaySfxGrowl(this, 1.0f); + EnDg_PlaySfxGrowl(this, 2.0f); + EnDg_PlaySfxGrowl(this, 3.0f); + EnDg_PlaySfxBark(this, 5.0f); } -void func_8098B464(EnDg* this, GlobalContext* globalCtx) { - Vec3f sp2C; +/** + * Makes a splash effect and plays the splash sfx when the dog enters the water, then + * makes them start swimming. + */ +void EnDg_SetupSwim(EnDg* this, PlayState* play) { + Vec3f pos; + + pos.x = this->actor.world.pos.x; + pos.y = this->actor.world.pos.y + this->actor.depthInWater; + pos.z = this->actor.world.pos.z + 20.0f; + EffectSsGSplash_Spawn(play, &pos, NULL, NULL, 0, 800); + EffectSsGRipple_Spawn(play, &pos, 100, 500, 30); - sp2C.x = this->actor.world.pos.x; - sp2C.y = this->actor.world.pos.y + this->actor.depthInWater; - sp2C.z = this->actor.world.pos.z + 20.0f; - EffectSsGSplash_Spawn(globalCtx, &sp2C, NULL, NULL, 0, 800); - EffectSsGRipple_Spawn(globalCtx, &sp2C, 100, 500, 30); if (this->actor.depthInWater > 0.0f) { this->actor.gravity = 0.0f; this->actor.velocity.y = -3.0f; - this->unk_284 = 10; + this->swimTimer = 10; Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_BOMB_DROP_WATER); - this->actionFunc = func_8098B560; + this->actionFunc = EnDg_Swim; } Math_ApproachF(&this->actor.speedXZ, 1.0f, 0.2f, 1.0f); Actor_MoveWithGravity(&this->actor); } -void func_8098B560(EnDg* this, GlobalContext* globalCtx) { - Vec3f sp54; +/** + * Makes the dog swim until it either: + * - Touches land, at which point it will just resume its idle movement. + * - Touches a wall, at which point it will attempt to jump out of the water. + */ +void EnDg_Swim(EnDg* this, PlayState* play) { + Vec3f ripplePos; Vec3f pos; - s16 sp46 = 0; + s16 yRotation = 0; WaterBox* waterBox; f32 waterSurface; CollisionPoly* poly; - f32 sp34; + f32 floorHeight; - sp54.x = this->actor.world.pos.x; - sp54.y = this->actor.world.pos.y + this->actor.depthInWater; - sp54.z = this->actor.world.pos.z + 20.0f; + ripplePos.x = this->actor.world.pos.x; + ripplePos.y = this->actor.world.pos.y + this->actor.depthInWater; + ripplePos.z = this->actor.world.pos.z + 20.0f; pos.x = (Math_SinS(this->actor.world.rot.y) * 50.0f) + this->actor.world.pos.x; pos.y = this->actor.home.pos.y + 100.0f; pos.z = (Math_CosS(this->actor.world.rot.y) * 50.0f) + this->actor.world.pos.z; - if (DECR(this->unk_284) == 0) { - if (!(this->unk_280 & 4)) { - this->unk_280 |= 4; + if (DECR(this->swimTimer) == 0) { + if (!(this->dogFlags & DOG_FLAG_SWIMMING)) { + this->dogFlags |= DOG_FLAG_SWIMMING; Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_OUT_OF_WATER); } - this->unk_284 = 5; - EffectSsGRipple_Spawn(globalCtx, &sp54, 100, 500, 30); + + this->swimTimer = 5; + EffectSsGRipple_Spawn(play, &ripplePos, 100, 500, 30); } if (this->actor.depthInWater > 15.0f) { @@ -968,52 +1149,63 @@ void func_8098B560(EnDg* this, GlobalContext* globalCtx) { this->actor.velocity.y = -0.5f; } - sp34 = BgCheck_EntityRaycastFloor2(globalCtx, &globalCtx->colCtx, &poly, &pos); + floorHeight = BgCheck_EntityRaycastFloor2(play, &play->colCtx, &poly, &pos); + + // The below code checks *only* that the dog is touching a wall, which can result in + // some strange behavior if the dog is touching a wall that is too tall for it to jump + // over. For example, if the player throws the dog at a tall wall next to some water, + // this code will make the dog "skip" along the water's surface, assuming the floor + // height is low enough to make it try to jump out. if (this->actor.bgCheckFlags & 8) { - if (!WaterBox_GetSurface1(globalCtx, &globalCtx->colCtx, pos.x, pos.z, &waterSurface, &waterBox)) { - if (sp34 > -100.0f) { - this->unk_280 &= ~4; - this->actionFunc = func_8098B88C; + if (!WaterBox_GetSurface1(play, &play->colCtx, pos.x, pos.z, &waterSurface, &waterBox)) { + if (floorHeight > -100.0f) { + this->dogFlags &= ~DOG_FLAG_SWIMMING; + this->actionFunc = EnDg_JumpOutOfWater; } else { - sp46 = this->actor.wallYaw; + yRotation = this->actor.wallYaw; } - } else if (sp34 > -100.0f) { - if (waterSurface < sp34) { - this->unk_280 &= ~4; - this->actionFunc = func_8098B88C; + } else if (floorHeight > -100.0f) { + if (waterSurface < floorHeight) { + this->dogFlags &= ~DOG_FLAG_SWIMMING; + this->actionFunc = EnDg_JumpOutOfWater; } else { - sp46 = this->actor.wallYaw; + yRotation = this->actor.wallYaw; } } else { - sp46 = this->actor.wallYaw; + yRotation = this->actor.wallYaw; } } else if ((this->actor.bgCheckFlags & 1) && !(this->actor.bgCheckFlags & 0x20)) { this->actor.gravity = -3.0f; - this->unk_280 &= ~4; - this->unk_28C = 8; - this->unk_282 = Rand_S16Offset(60, 60); + this->dogFlags &= ~DOG_FLAG_SWIMMING; + this->behavior = DOG_BEHAVIOR_DEFAULT; + this->timer = Rand_S16Offset(60, 60); Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_OUT_OF_WATER); - func_80989140(&this->skelAnime, sAnimations, 2); + EnDg_ChangeAnim(&this->skelAnime, sAnimationInfo, DOG_ANIM_RUN); Math_ApproachF(&this->actor.speedXZ, 3.5f, 0.2f, 1.0f); - this->actionFunc = func_8098A468; + this->actionFunc = EnDg_IdleMove; } - Math_SmoothStepToS(&this->actor.world.rot.y, sp46, 4, 0x3E8, 1); + Math_SmoothStepToS(&this->actor.world.rot.y, yRotation, 4, 0x3E8, 1); this->actor.shape.rot.y = this->actor.world.rot.y; Math_ApproachF(&this->actor.speedXZ, 0.5f, 0.2f, 1.0f); Actor_MoveWithGravity(&this->actor); } -void func_8098B88C(EnDg* this, GlobalContext* globalCtx) { - Vec3f sp34; +/** + * This function attempts to get the dog out of water by making it jump near walls. + * The point of this is seemingly to let the dog escape the shallow water pools in + * South Clock Town. + */ +void EnDg_JumpOutOfWater(EnDg* this, PlayState* play) { + Vec3f pos; - sp34.x = this->actor.world.pos.x; - sp34.y = this->actor.world.pos.y + this->actor.depthInWater; - sp34.z = this->actor.world.pos.z + 20.0f; + pos.x = this->actor.world.pos.x; + pos.y = this->actor.world.pos.y + this->actor.depthInWater; + pos.z = this->actor.world.pos.z + 20.0f; - if (DECR(this->unk_284) == 0) { - this->unk_284 = 5; - EffectSsGRipple_Spawn(globalCtx, &sp34, 100, 500, 30); + if (DECR(this->swimTimer) == 0) { + this->swimTimer = 5; + EffectSsGRipple_Spawn(play, &pos, 100, 500, 30); } if (this->actor.depthInWater > 15.0f) { @@ -1023,19 +1215,19 @@ void func_8098B88C(EnDg* this, GlobalContext* globalCtx) { } if (this->actor.bgCheckFlags & 8) { - this->actor.world.pos.y = sp34.y; + this->actor.world.pos.y = pos.y; this->actor.velocity.y = 10.0f; - EffectSsGSplash_Spawn(globalCtx, &sp34, NULL, NULL, 0, 800); + EffectSsGSplash_Spawn(play, &pos, NULL, NULL, 0, 800); } if (!(this->actor.bgCheckFlags & 0x20)) { - this->unk_28C = 8; + this->behavior = DOG_BEHAVIOR_DEFAULT; this->actor.velocity.y = 10.0f; this->actor.gravity = -3.0f; - this->unk_282 = Rand_S16Offset(60, 60); + this->timer = Rand_S16Offset(60, 60); Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_OUT_OF_WATER); - func_80989140(&this->skelAnime, sAnimations, 2); - this->actionFunc = func_8098A468; + EnDg_ChangeAnim(&this->skelAnime, sAnimationInfo, DOG_ANIM_RUN); + this->actionFunc = EnDg_IdleMove; Math_ApproachF(&this->actor.speedXZ, 3.5f, 0.2f, 1.0f); } else { Math_ApproachF(&this->actor.speedXZ, 0.5f, 0.2f, 1.0f); @@ -1044,187 +1236,196 @@ void func_8098B88C(EnDg* this, GlobalContext* globalCtx) { Actor_MoveWithGravity(&this->actor); } -void func_8098BA64(EnDg* this, GlobalContext* globalCtx) { - if (Actor_HasNoParent(&this->actor, globalCtx)) { - this->unk_290 = 2; +void EnDg_Held(EnDg* this, PlayState* play) { + if (Actor_HasNoParent(&this->actor, play)) { + this->grabState = DOG_GRAB_STATE_THROWN_OR_SITTING_AFTER_THROW; this->actor.flags |= ACTOR_FLAG_1; - if (D_8098C2A0 != 0) { + if (sIsAnyDogHeld) { this->actor.flags &= ~ACTOR_FLAG_8000000; - D_8098C2A0 = 0; - this->unk_280 &= ~1; + sIsAnyDogHeld = false; + this->dogFlags &= ~DOG_FLAG_HELD; } - this->unk_288 = -1; - D_8098C2FC.unk_02 = this->unk_288; - this->unk_28A = 100; + + this->selectedDogIndex = -1; + sSelectedRacetrackDogInfo.index = this->selectedDogIndex; + this->sitAfterThrowTimer = 100; Actor_MoveWithGravity(&this->actor); - this->unk_280 |= 0x10; - this->actionFunc = func_8098BB10; + this->dogFlags |= DOG_FLAG_THROWN; + this->actionFunc = EnDg_Thrown; } } -void func_8098BB10(EnDg* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); +void EnDg_Thrown(EnDg* this, PlayState* play) { + Player* player = GET_PLAYER(play); if (this->actor.bgCheckFlags & 1) { - if (this->unk_280 & 0x10) { - this->unk_280 &= ~0x10; + if (this->dogFlags & DOG_FLAG_THROWN) { + this->dogFlags &= ~DOG_FLAG_THROWN; Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_MONKEY_WALK); } this->actor.speedXZ = 0.0f; this->actor.gravity = -3.0f; if (player->transformation == PLAYER_FORM_HUMAN) { - func_80989E18(this, globalCtx); + EnDg_TryPickUp(this, play); } } - if (DECR(this->unk_28A) == 0) { - this->unk_290 = 0; - func_80989ADC(this, globalCtx); - this->actionFunc = func_8098A468; + if (DECR(this->sitAfterThrowTimer) == 0) { + this->grabState = DOG_GRAB_STATE_NONE; + EnDg_SetupIdleMove(this, play); + this->actionFunc = EnDg_IdleMove; } Actor_MoveWithGravity(&this->actor); } -void func_8098BBEC(EnDg* this, GlobalContext* globalCtx) { - if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { +void EnDg_SetupTalk(EnDg* this, PlayState* play) { + if (Actor_ProcessTalkRequest(&this->actor, &play->state)) { this->actor.flags &= ~ACTOR_FLAG_10000; - func_80989D38(this, globalCtx); - this->actionFunc = func_8098BC54; + EnDg_StartTextBox(this, play); + this->actionFunc = EnDg_Talk; } else { - func_800B8614(&this->actor, globalCtx, 100.0f); + func_800B8614(&this->actor, play, 100.0f); } } -void func_8098BC54(EnDg* this, GlobalContext* globalCtx) { - if (Message_GetState(&globalCtx->msgCtx) == 2) { - func_80989140(&this->skelAnime, sAnimations, 0); - this->actionFunc = func_8098BA64; +void EnDg_Talk(EnDg* this, PlayState* play) { + if (Message_GetState(&play->msgCtx) == TEXT_STATE_CLOSING) { + EnDg_ChangeAnim(&this->skelAnime, sAnimationInfo, DOG_ANIM_WALK_AFTER_TALKING); + this->actionFunc = EnDg_Held; } } -void EnDg_Init(Actor* thisx, GlobalContext* globalCtx) { +void EnDg_Init(Actor* thisx, PlayState* play) { EnDg* this = THIS; s32 pad; 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, &this->collider); - Collider_SetCylinder(globalCtx, &this->collider, &this->actor, &sCylinderInit); + SkelAnime_InitFlex(play, &this->skelAnime, &gDogSkel, NULL, this->jointTable, this->morphTable, DOG_LIMB_MAX); + Collider_InitCylinder(play, &this->collider); + Collider_SetCylinder(play, &this->collider, &this->actor, &sCylinderInit); CollisionCheck_SetInfo2(&this->actor.colChkInfo, &sDamageTable, &sColChkInfoInit); Actor_ProcessInitChain(&this->actor, sInitChain); - this->unk_1DC = SubS_GetPathByIndex(globalCtx, ENDG_GET_FC00(&this->actor), 0x3F); + + this->path = SubS_GetPathByIndex(play, ENDG_GET_PATH(&this->actor), 0x3F); Actor_SetScale(&this->actor, 0.0075f); this->actor.targetMode = 1; this->actor.gravity = -3.0f; - this->unk_282 = Rand_S16Offset(60, 60); - this->unk_280 = 0; - this->unk_28E = 20; - this->unk_284 = 10; - this->unk_286 = ENDG_GET_3E0(&this->actor); - this->unk_28C = 0; - this->unk_290 = 0; - if (globalCtx->sceneNum == SCENE_F01_B) { - this->unk_28A = 100; - func_80989BF8(this); + this->timer = Rand_S16Offset(60, 60); + this->dogFlags = DOG_FLAG_NONE; + this->attackTimer = 20; + this->swimTimer = 10; + this->index = ENDG_GET_INDEX(&this->actor); + this->behavior = DOG_BEHAVIOR_INITIAL; + this->grabState = DOG_GRAB_STATE_NONE; + if (play->sceneNum == SCENE_F01_B) { + this->sitAfterThrowTimer = 100; + EnDg_UpdateTextId(this); } - func_80989ADC(this, globalCtx); + + EnDg_SetupIdleMove(this, play); } -void EnDg_Destroy(Actor* thisx, GlobalContext* globalCtx) { +void EnDg_Destroy(Actor* thisx, PlayState* play) { EnDg* this = THIS; - Collider_DestroyCylinder(globalCtx, &this->collider); + Collider_DestroyCylinder(play, &this->collider); } -void EnDg_Update(Actor* thisx, GlobalContext* globalCtx) { +void EnDg_Update(Actor* thisx, PlayState* play) { EnDg* this = THIS; - Player* player = GET_PLAYER(globalCtx); + Player* player = GET_PLAYER(play); s32 pad; - Vec3f sp28 = { 0.0f, 0.0f, 0.0f }; + Vec3f floorRot = { 0.0f, 0.0f, 0.0f }; - this->unk_288 = D_8098C2FC.unk_02; - if (!(player->stateFlags1 & 0x20) || (globalCtx->sceneNum != SCENE_CLOCKTOWER)) { - if (func_8098A1B4(this, globalCtx)) { - func_8098A234(this, globalCtx); - } else if (this->unk_28C != 8) { - this->unk_28C = 8; - func_80989ADC(this, globalCtx); + this->selectedDogIndex = sSelectedRacetrackDogInfo.index; + if (!(player->stateFlags1 & 0x20) || (play->sceneNum != SCENE_CLOCKTOWER)) { + if (EnDg_ShouldReactToNonHumanPlayer(this, play)) { + EnDg_ChooseActionForForm(this, play); + } else if (this->behavior != DOG_BEHAVIOR_DEFAULT) { + this->behavior = DOG_BEHAVIOR_DEFAULT; + EnDg_SetupIdleMove(this, play); } - if ((this->actor.bgCheckFlags & 0x40) && Actor_HasNoParent(&this->actor, globalCtx)) { - func_80989140(&this->skelAnime, sAnimations, 15); - this->actionFunc = func_8098B464; + if ((this->actor.bgCheckFlags & 0x40) && Actor_HasNoParent(&this->actor, play)) { + EnDg_ChangeAnim(&this->skelAnime, sAnimationInfo, DOG_ANIM_SWIM); + this->actionFunc = EnDg_SetupSwim; } - this->actionFunc(this, globalCtx); - func_80989204(this, globalCtx); - func_8098933C(this, &sp28); - Math_ApproachF(&this->unk_294.x, sp28.x, 0.2f, 0.1f); - Math_ApproachF(&this->unk_294.z, sp28.z, 0.2f, 0.1f); + this->actionFunc(this, play); + EnDg_UpdateCollision(this, play); + EnDg_GetFloorRot(this, &floorRot); + Math_ApproachF(&this->curRot.x, floorRot.x, 0.2f, 0.1f); + Math_ApproachF(&this->curRot.z, floorRot.z, 0.2f, 0.1f); SkelAnime_Update(&this->skelAnime); } } -s32 EnDg_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, Actor* thisx) { +s32 EnDg_OverrideLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, Actor* thisx) { return false; } -void EnDg_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx) { +void EnDg_PostLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx) { EnDg* this = THIS; - Vec3f sp20 = { 0.0f, 20.0f, 0.0f }; + Vec3f sFocusOffset = { 0.0f, 20.0f, 0.0f }; if (limbIndex == DOG_LIMB_HEAD) { - if (this->actionFunc == func_8098BBEC) { - sp20.x = 5000.0f; - Matrix_MultiplyVector3fByState(&sp20, &this->actor.focus.pos); - } else if (this->actionFunc != func_8098BC54) { - Matrix_MultiplyVector3fByState(&sp20, &this->actor.focus.pos); + if (this->actionFunc == EnDg_SetupTalk) { + sFocusOffset.x = 5000.0f; + Matrix_MultVec3f(&sFocusOffset, &this->actor.focus.pos); + } else if (this->actionFunc != EnDg_Talk) { + Matrix_MultVec3f(&sFocusOffset, &this->actor.focus.pos); } } } -void EnDg_Draw(Actor* thisx, GlobalContext* globalCtx) { +void EnDg_Draw(Actor* thisx, PlayState* play) { EnDg* this = THIS; - OPEN_DISPS(globalCtx->state.gfxCtx); + OPEN_DISPS(play->state.gfxCtx); - func_8012C28C(globalCtx->state.gfxCtx); + func_8012C28C(play->state.gfxCtx); 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->curRot.x); + Matrix_RotateZF(this->curRot.z, MTXMODE_APPLY); + Matrix_RotateYS(this->actor.shape.rot.y, MTXMODE_APPLY); Matrix_Scale(this->actor.scale.x, this->actor.scale.y, this->actor.scale.z, MTXMODE_APPLY); - SkelAnime_DrawFlexOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, + SkelAnime_DrawFlexOpa(play, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, EnDg_OverrideLimbDraw, EnDg_PostLimbDraw, &this->actor); - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->state.gfxCtx); } 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 09732ba81..2b2bdd7cb 100644 --- a/src/overlays/actors/ovl_En_Dg/z_en_dg.h +++ b/src/overlays/actors/ovl_En_Dg/z_en_dg.h @@ -4,12 +4,43 @@ #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*); +typedef void (*EnDgActionFunc)(struct EnDg*, PlayState*); -#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) >> 10) +#define ENDG_PARAMS(path, index) ((path << 10) | (index << 5)) + +typedef enum { + /* 0 */ ENDG_INDEX_RACETRACK_0, + /* 1 */ ENDG_INDEX_RACETRACK_1, + /* 2 */ ENDG_INDEX_RACETRACK_2, + /* 3 */ ENDG_INDEX_RACETRACK_3, + /* 4 */ ENDG_INDEX_RACETRACK_4, + /* 5 */ ENDG_INDEX_RACETRACK_5, + /* 6 */ ENDG_INDEX_RACETRACK_6, + /* 7 */ ENDG_INDEX_RACETRACK_7, + /* 8 */ ENDG_INDEX_RACETRACK_8, + /* 9 */ ENDG_INDEX_RACETRACK_9, + /* 10 */ ENDG_INDEX_RACETRACK_10, + /* 11 */ ENDG_INDEX_RACETRACK_11, + /* 12 */ ENDG_INDEX_RACETRACK_12, + /* 13 */ ENDG_INDEX_RACETRACK_13, + /* 20 */ ENDG_INDEX_ROMANI_RANCH = 20, + /* 21 */ ENDG_INDEX_SWAMP_SPIDER_HOUSE, + /* 31 */ ENDG_INDEX_SOUTH_CLOCK_TOWN = 31 +} EnDgIndex; typedef struct EnDg { /* 0x000 */ Actor actor; @@ -17,21 +48,21 @@ typedef struct EnDg { /* 0x148 */ UNK_TYPE1 unk_148[0x4]; /* 0x14C */ SkelAnime skelAnime; /* 0x190 */ ColliderCylinder collider; - /* 0x1DC */ Path* unk_1DC; - /* 0x1E0 */ s32 unk_1E0; + /* 0x1DC */ Path* path; + /* 0x1E0 */ s32 currentPoint; /* 0x1E4 */ Vec3s jointTable[DOG_LIMB_MAX]; /* 0x232 */ Vec3s morphTable[DOG_LIMB_MAX]; - /* 0x280 */ u16 unk_280; - /* 0x282 */ s16 unk_282; - /* 0x284 */ s16 unk_284; - /* 0x286 */ s16 unk_286; - /* 0x288 */ s16 unk_288; - /* 0x28A */ s16 unk_28A; - /* 0x28C */ s16 unk_28C; - /* 0x28E */ s16 unk_28E; - /* 0x290 */ s16 unk_290; - /* 0x292 */ s16 unk_292; - /* 0x294 */ Vec3f unk_294; + /* 0x280 */ u16 dogFlags; + /* 0x282 */ s16 timer; + /* 0x284 */ s16 swimTimer; + /* 0x286 */ s16 index; + /* 0x288 */ s16 selectedDogIndex; + /* 0x28A */ s16 sitAfterThrowTimer; + /* 0x28C */ s16 behavior; + /* 0x28E */ s16 attackTimer; + /* 0x290 */ s16 grabState; + /* 0x292 */ s16 bremenBarkTimer; + /* 0x294 */ Vec3f curRot; } EnDg; // size = 0x2A0 extern const ActorInit En_Dg_InitVars; diff --git a/src/overlays/actors/ovl_En_Dinofos/z_en_dinofos.c b/src/overlays/actors/ovl_En_Dinofos/z_en_dinofos.c index e06e2e776..eb7719150 100644 --- a/src/overlays/actors/ovl_En_Dinofos/z_en_dinofos.c +++ b/src/overlays/actors/ovl_En_Dinofos/z_en_dinofos.c @@ -11,37 +11,37 @@ #define THIS ((EnDinofos*)thisx) -void EnDinofos_Init(Actor* thisx, GlobalContext* globalCtx); -void EnDinofos_Destroy(Actor* thisx, GlobalContext* globalCtx); -void EnDinofos_Update(Actor* thisx, GlobalContext* globalCtx); -void EnDinofos_Draw(Actor* thisx, GlobalContext* globalCtx); +void EnDinofos_Init(Actor* thisx, PlayState* play); +void EnDinofos_Destroy(Actor* thisx, PlayState* play); +void EnDinofos_Update(Actor* thisx, PlayState* play); +void EnDinofos_Draw(Actor* thisx, PlayState* play); -void func_8089B834(EnDinofos* this, GlobalContext* globalCtx); -void func_8089D318(EnDinofos* this, GlobalContext* globalCtx); -void func_8089BBB4(EnDinofos* this, GlobalContext* globalCtx); -void func_8089B8B0(EnDinofos* this, GlobalContext* globalCtx); -void func_8089C56C(EnDinofos* this, GlobalContext* globalCtx); -void func_8089C44C(EnDinofos* this, GlobalContext* globalCtx); -void func_8089BB60(EnDinofos* this, GlobalContext* globalCtx); -void func_8089C0DC(EnDinofos* this, GlobalContext* globalCtx); -void func_8089D018(EnDinofos* this, GlobalContext* globalCtx); -void func_8089B288(EnDinofos* this, GlobalContext* globalCtx); -void func_8089BD28(EnDinofos* this, GlobalContext* globalCtx); -void func_8089D1E0(EnDinofos* this, GlobalContext* globalCtx); -void func_8089B98C(EnDinofos* this, GlobalContext* globalCtx); -void func_8089CA74(EnDinofos* this, GlobalContext* globalCtx); -void func_8089B3D4(EnDinofos* this, GlobalContext* globalCtx); -void func_8089CB10(EnDinofos* this, GlobalContext* globalCtx); -void func_8089CBEC(EnDinofos* this, GlobalContext* globalCtx); -void func_8089CF00(EnDinofos* this, GlobalContext* globalCtx); -void func_8089CF70(EnDinofos* this, GlobalContext* globalCtx); -void func_8089B580(EnDinofos* this, GlobalContext* globalCtx); -void func_8089B72C(EnDinofos* this, GlobalContext* globalCtx); -void func_8089C2A8(EnDinofos* this, GlobalContext* globalCtx); -void func_8089C1F8(EnDinofos* this, GlobalContext* globalCtx); -void func_8089C724(EnDinofos* this, GlobalContext* globalCtx); -void func_8089C7B8(EnDinofos* this, GlobalContext* globalCtx); -void func_8089C938(EnDinofos* this, GlobalContext* globalCtx); +void func_8089B834(EnDinofos* this, PlayState* play); +void func_8089D318(EnDinofos* this, PlayState* play); +void func_8089BBB4(EnDinofos* this, PlayState* play); +void func_8089B8B0(EnDinofos* this, PlayState* play); +void func_8089C56C(EnDinofos* this, PlayState* play); +void func_8089C44C(EnDinofos* this, PlayState* play); +void func_8089BB60(EnDinofos* this, PlayState* play); +void func_8089C0DC(EnDinofos* this, PlayState* play); +void func_8089D018(EnDinofos* this, PlayState* play); +void func_8089B288(EnDinofos* this, PlayState* play); +void func_8089BD28(EnDinofos* this, PlayState* play); +void func_8089D1E0(EnDinofos* this, PlayState* play); +void func_8089B98C(EnDinofos* this, PlayState* play); +void func_8089CA74(EnDinofos* this, PlayState* play); +void func_8089B3D4(EnDinofos* this, PlayState* play); +void func_8089CB10(EnDinofos* this, PlayState* play); +void func_8089CBEC(EnDinofos* this, PlayState* play); +void func_8089CF00(EnDinofos* this, PlayState* play); +void func_8089CF70(EnDinofos* this, PlayState* play); +void func_8089B580(EnDinofos* this, PlayState* play); +void func_8089B72C(EnDinofos* this, PlayState* play); +void func_8089C2A8(EnDinofos* this, PlayState* play); +void func_8089C1F8(EnDinofos* this, PlayState* play); +void func_8089C724(EnDinofos* this, PlayState* play); +void func_8089C7B8(EnDinofos* this, PlayState* play); +void func_8089C938(EnDinofos* this, PlayState* play); void func_8089C4F8(EnDinofos* this); void func_8089BAC0(EnDinofos* this); void func_8089C024(EnDinofos* this, s32 arg1); @@ -180,7 +180,7 @@ static ColliderJntSphInit sJntSphInit = { OC2_TYPE_1, COLSHAPE_JNTSPH, }, - 9, + ARRAY_COUNT(sJntSphElementsInit), sJntSphElementsInit, }; @@ -258,7 +258,7 @@ static InitChainEntry sInitChain[] = { ICHAIN_VEC3F_DIV1000(scale, 15, ICHAIN_STOP), }; -void EnDinofos_Init(Actor* thisx, GlobalContext* globalCtx) { +void EnDinofos_Init(Actor* thisx, PlayState* play) { static s32 D_8089E364 = 0; static EffectBlureInit2 D_8089E368 = { 0, 8, 0, { 255, 255, 255, 255 }, { 255, 255, 255, 64 }, { 255, 255, 255, 0 }, { 255, 255, 255, 0 }, 8, @@ -270,12 +270,11 @@ void EnDinofos_Init(Actor* thisx, GlobalContext* globalCtx) { Actor_ProcessInitChain(&this->actor, sInitChain); ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawFeet, 90.0f); - Effect_Add(globalCtx, &this->unk_2A0, EFFECT_BLURE2, 0, 0, &D_8089E368); - Collider_InitAndSetJntSph(globalCtx, &this->colliderJntSph, &this->actor, &sJntSphInit, - this->colliderJntSphElement); - Collider_InitAndSetQuad(globalCtx, &this->colliderQuad, &this->actor, &sQuadInit); + Effect_Add(play, &this->unk_2A0, EFFECT_BLURE2, 0, 0, &D_8089E368); + Collider_InitAndSetJntSph(play, &this->colliderJntSph, &this->actor, &sJntSphInit, this->colliderJntSphElement); + Collider_InitAndSetQuad(play, &this->colliderQuad, &this->actor, &sQuadInit); CollisionCheck_SetInfo(&this->actor.colChkInfo, &sDamageTable, &sColChkInfoInit); - SkelAnime_InitFlex(globalCtx, &this->skelAnime, &object_dinofos_Skel_009570, &object_dinofos_Anim_002E40, + SkelAnime_InitFlex(play, &this->skelAnime, &object_dinofos_Skel_009570, &object_dinofos_Anim_002E40, this->jointTable, this->morphTable, 21); if (D_8089E364 == 0) { @@ -305,12 +304,12 @@ void EnDinofos_Init(Actor* thisx, GlobalContext* globalCtx) { D_8089E350++; } -void EnDinofos_Destroy(Actor* thisx, GlobalContext* globalCtx) { +void EnDinofos_Destroy(Actor* thisx, PlayState* play) { EnDinofos* this = THIS; - Effect_Destroy(globalCtx, this->unk_2A0); - Collider_DestroyJntSph(globalCtx, &this->colliderJntSph); - Collider_DestroyQuad(globalCtx, &this->colliderQuad); + Effect_Destroy(play, this->unk_2A0); + Collider_DestroyJntSph(play, &this->colliderJntSph); + Collider_DestroyQuad(play, &this->colliderQuad); } void func_8089A900(EnDinofos* this) { @@ -333,27 +332,27 @@ s32 func_8089A968(EnDinofos* this) { return false; } -void func_8089A9B0(EnDinofos* this, GlobalContext* globalCtx) { +void func_8089A9B0(EnDinofos* this, PlayState* play) { if (func_8089A968(this)) { if (this->actor.xzDistToPlayer < 100.0f) { - if (!Actor_OtherIsTargeted(globalCtx, &this->actor) && + if (!Actor_OtherIsTargeted(play, &this->actor) && (((this->actionFunc != func_8089C56C) && (Rand_ZeroOne() > 0.35f)) || ((this->actionFunc == func_8089C56C) && (Rand_ZeroOne() > 0.8f)))) { func_8089C4F8(this); } else { - func_8089BBB4(this, globalCtx); + func_8089BBB4(this, play); } } else if ((this->actor.xzDistToPlayer < 260.0f) && (this->actor.xzDistToPlayer > 180.0f)) { if (((this->actionFunc != func_8089C44C) && (Rand_ZeroOne() < 0.1f)) || ((this->actionFunc == func_8089C44C) && (Rand_ZeroOne() < 0.05f))) { func_8089C024(this, 0); } else { - func_8089BBB4(this, globalCtx); + func_8089BBB4(this, play); } } else if (Rand_ZeroOne() < 0.8f) { - func_8089B8B0(this, globalCtx); + func_8089B8B0(this, play); } else { - func_8089BBB4(this, globalCtx); + func_8089BBB4(this, play); } } else if (Rand_ZeroOne() < 0.6f) { func_8089BAC0(this); @@ -362,15 +361,15 @@ void func_8089A9B0(EnDinofos* this, GlobalContext* globalCtx) { } } -void func_8089ABF4(EnDinofos* this, GlobalContext* globalCtx) { - if (this->subCamId != CAM_ID_MAIN) { - Camera* subCam = Play_GetCamera(globalCtx, this->subCamId); +void func_8089ABF4(EnDinofos* this, PlayState* play) { + if (this->subCamId != SUB_CAM_ID_DONE) { + Camera* subCam = Play_GetCamera(play, this->subCamId); - Play_CameraSetAtEye(globalCtx, CAM_ID_MAIN, &subCam->at, &subCam->eye); - this->subCamId = CAM_ID_MAIN; + Play_SetCameraAtEye(play, CAM_ID_MAIN, &subCam->at, &subCam->eye); + this->subCamId = SUB_CAM_ID_DONE; ActorCutscene_Stop(this->actor.cutscene); if (this->actor.colChkInfo.health == 0) { - func_800B724C(globalCtx, &this->actor, 6); + func_800B724C(play, &this->actor, 6); } } } @@ -386,12 +385,12 @@ void func_8089AC70(EnDinofos* this) { Actor_SetColorFilter(&this->actor, 0x4000, 255, 0, 80); } -void func_8089ACEC(EnDinofos* this, GlobalContext* globalCtx) { +void func_8089ACEC(EnDinofos* this, PlayState* play) { if (this->drawDmgEffType == ACTOR_DRAW_DMGEFF_FROZEN_NO_SFX) { this->drawDmgEffType = ACTOR_DRAW_DMGEFF_FIRE; this->colliderJntSph.base.colType = COLTYPE_HIT0; this->drawDmgEffAlpha = 0.0f; - Actor_SpawnIceEffects(globalCtx, &this->actor, this->limbPos, 12, 2, 0.3f, 0.2f); + Actor_SpawnIceEffects(play, &this->actor, this->limbPos, 12, 2, 0.3f, 0.2f); this->actor.flags |= ACTOR_FLAG_400; } } @@ -407,14 +406,14 @@ void func_8089AD70(EnDinofos* this) { } } -s32 func_8089AE00(EnDinofos* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); +s32 func_8089AE00(EnDinofos* this, PlayState* play) { + Player* player = GET_PLAYER(play); s16 temp_v1; s16 temp_v1_2; Actor* temp_v0; s32 i; - temp_v0 = func_800BC270(globalCtx, &this->actor, 80.0f, 0x138B0); + temp_v0 = func_800BC270(play, &this->actor, 80.0f, 0x138B0); if (temp_v0 != NULL) { temp_v1 = (Actor_YawBetweenActors(&this->actor, temp_v0) - this->actor.shape.rot.y) - this->unk_28E; if (ABS_ALT(temp_v1) < 0x3000) { @@ -424,7 +423,7 @@ s32 func_8089AE00(EnDinofos* this, GlobalContext* globalCtx) { } } - temp_v0 = func_800BC444(globalCtx, &this->actor, 80.0f); + temp_v0 = func_800BC444(play, &this->actor, 80.0f); if ((temp_v0 != NULL) && (temp_v0->id == ACTOR_EN_BOM_CHU)) { temp_v1_2 = (Actor_YawBetweenActors(&this->actor, temp_v0) - this->actor.shape.rot.y) - this->unk_28E; if (ABS_ALT(temp_v1_2) < 0x3000) { @@ -434,13 +433,13 @@ s32 func_8089AE00(EnDinofos* this, GlobalContext* globalCtx) { } } - if (globalCtx->actorCtx.unk2 != 0) { + if (play->actorCtx.unk2 != 0) { func_8089C024(this, 1); return true; } - if ((this->actor.xzDistToPlayer < 100.0f) && (player->swordState != 0) && this->actor.isTargeted && - (Rand_ZeroOne() < 0.5f) && func_8089A968(this) && Player_IsFacingActor(&this->actor, 0x2000, globalCtx)) { + if ((this->actor.xzDistToPlayer < 100.0f) && (player->meleeWeaponState != 0) && this->actor.isTargeted && + (Rand_ZeroOne() < 0.5f) && func_8089A968(this) && Player_IsFacingActor(&this->actor, 0x2000, play)) { if (Rand_ZeroOne() < 0.5f) { func_8089C024(this, 2); } else { @@ -461,14 +460,14 @@ s32 func_8089AE00(EnDinofos* this, GlobalContext* globalCtx) { return false; } -void func_8089B100(EnDinofos* this, GlobalContext* globalCtx) { - Camera* subCam = Play_GetCamera(globalCtx, this->subCamId); - Player* player = GET_PLAYER(globalCtx); +void func_8089B100(EnDinofos* this, PlayState* play) { + Camera* subCam = Play_GetCamera(play, this->subCamId); + Player* player = GET_PLAYER(play); 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); + Animation_GetLastFrame(&object_dinofos_Anim_001CCC), ANIMMODE_ONCE, 0.0f); func_800BE33C(&subCam->eye, &subCam->at, &this->unk_29A, true); Math_Vec3f_Diff(&this->actor.world.pos, &player->actor.world.pos, &sp3C); this->unk_2BC.x = player->actor.world.pos.x + (0.4f * sp3C.x); @@ -483,13 +482,13 @@ void func_8089B100(EnDinofos* this, GlobalContext* globalCtx) { this->actionFunc = func_8089B288; } -void func_8089B288(EnDinofos* this, GlobalContext* globalCtx) { - Camera* subCam = Play_GetCamera(globalCtx, this->subCamId); +void func_8089B288(EnDinofos* this, PlayState* play) { + Camera* subCam = Play_GetCamera(play, this->subCamId); this->unk_290--; 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); + Play_SetCameraAtEye(play, this->subCamId, &subCam->at, &subCam->eye); if (this->unk_290 == 0) { func_8089B320(this); } @@ -505,8 +504,8 @@ void func_8089B320(EnDinofos* this) { this->actionFunc = func_8089B3D4; } -void func_8089B3D4(EnDinofos* this, GlobalContext* globalCtx) { - Camera* subCam = Play_GetCamera(globalCtx, this->subCamId); +void func_8089B3D4(EnDinofos* this, PlayState* play) { + Camera* subCam = Play_GetCamera(play, this->subCamId); Vec3f subCamAt; Math_Vec3f_StepTo(&subCam->eye, &this->unk_2BC, 10.0f); @@ -523,7 +522,7 @@ void func_8089B3D4(EnDinofos* this, GlobalContext* globalCtx) { subCamAt.y = subCam->at.y; } - Play_CameraSetAtEye(globalCtx, this->subCamId, &subCamAt, &subCam->eye); + Play_SetCameraAtEye(play, this->subCamId, &subCamAt, &subCam->eye); if (this->actor.bgCheckFlags & 1) { func_8089B4A4(this); } @@ -543,28 +542,28 @@ void func_8089B4A4(EnDinofos* this) { this->actionFunc = func_8089B580; } -void func_8089B580(EnDinofos* this, GlobalContext* globalCtx) { - Camera* subCam = Play_GetCamera(globalCtx, this->subCamId); +void func_8089B580(EnDinofos* this, PlayState* play) { + Camera* subCam = Play_GetCamera(play, this->subCamId); this->unk_290++; if (this->unk_290 < 8) { - Play_CameraSetAtEye(globalCtx, this->subCamId, &this->actor.focus.pos, &subCam->eye); + Play_SetCameraAtEye(play, 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.lightSettingOverride = 11; + if ((play->sceneNum == SCENE_MITURIN) && Animation_OnFrame(&this->skelAnime, 38.0f)) { + play->envCtx.lightSettingOverride = 11; } Math_Vec3f_StepTo(&subCam->eye, &this->unk_2BC, 10.0f); - Play_CameraSetAtEye(globalCtx, this->subCamId, &this->actor.focus.pos, &subCam->eye); + Play_SetCameraAtEye(play, 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.lightSettingOverride = 0xFF; + if ((play->sceneNum == SCENE_MITURIN) && Animation_OnFrame(&this->skelAnime, 55.0f)) { + play->envCtx.lightSettingOverride = 0xFF; } if (SkelAnime_Update(&this->skelAnime)) { @@ -577,13 +576,13 @@ void func_8089B6E8(EnDinofos* this) { this->actionFunc = func_8089B72C; } -void func_8089B72C(EnDinofos* this, GlobalContext* globalCtx) { +void func_8089B72C(EnDinofos* this, PlayState* play) { if (Animation_OnFrame(&this->skelAnime, 2.0f)) { Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_RIZA_ATTACK); } if (SkelAnime_Update(&this->skelAnime)) { - func_8089ABF4(this, globalCtx); + func_8089ABF4(this, play); this->actor.flags &= ~ACTOR_FLAG_100000; this->actor.cutscene = -1; func_8089B7B0(this); @@ -600,7 +599,7 @@ void func_8089B7B0(EnDinofos* this) { this->actionFunc = func_8089B834; } -void func_8089B834(EnDinofos* this, GlobalContext* globalCtx) { +void func_8089B834(EnDinofos* this, PlayState* play) { SkelAnime_Update(&this->skelAnime); if (this->unk_292 != 0) { this->unk_292--; @@ -611,16 +610,16 @@ void func_8089B834(EnDinofos* this, GlobalContext* globalCtx) { if (this->unk_290 != 0) { this->unk_290--; } else { - func_8089A9B0(this, globalCtx); + func_8089A9B0(this, play); } } -void func_8089B8B0(EnDinofos* this, GlobalContext* globalCtx) { +void func_8089B8B0(EnDinofos* this, PlayState* play) { f32 phi_f0; if (this->actionFunc != func_8089B98C) { Animation_MorphToLoop(&this->skelAnime, &object_dinofos_Anim_000580, -4.0f); - if (Actor_OtherIsTargeted(globalCtx, &this->actor)) { + if (Actor_OtherIsTargeted(play, &this->actor)) { phi_f0 = 170.0f; } else { phi_f0 = 70.0f; @@ -637,12 +636,12 @@ void func_8089B8B0(EnDinofos* this, GlobalContext* globalCtx) { this->actionFunc = func_8089B98C; } -void func_8089B98C(EnDinofos* this, GlobalContext* globalCtx) { +void func_8089B98C(EnDinofos* this, PlayState* play) { f32 phi_f0; SkelAnime_Update(&this->skelAnime); - if (!func_8089AE00(this, globalCtx)) { - if (Actor_OtherIsTargeted(globalCtx, &this->actor)) { + if (!func_8089AE00(this, play)) { + if (Actor_OtherIsTargeted(play, &this->actor)) { phi_f0 = 170.0f; } else { phi_f0 = 70.0f; @@ -663,7 +662,7 @@ void func_8089B98C(EnDinofos* this, GlobalContext* globalCtx) { if (this->unk_292 != 0) { this->unk_292--; } else { - func_8089A9B0(this, globalCtx); + func_8089A9B0(this, play); } if (Animation_OnFrame(&this->skelAnime, 0.0f) || Animation_OnFrame(&this->skelAnime, 6.0f)) { @@ -687,16 +686,16 @@ void func_8089BAC0(EnDinofos* this) { this->actionFunc = func_8089BB60; } -void func_8089BB60(EnDinofos* this, GlobalContext* globalCtx) { +void func_8089BB60(EnDinofos* this, PlayState* play) { SkelAnime_Update(&this->skelAnime); if (Math_ScaledStepToS(&this->actor.shape.rot.y, this->unk_28C, 0x400)) { - func_8089A9B0(this, globalCtx); + func_8089A9B0(this, play); } this->actor.world.rot.y = this->actor.shape.rot.y; } -void func_8089BBB4(EnDinofos* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); +void func_8089BBB4(EnDinofos* this, PlayState* play) { + Player* player = GET_PLAYER(play); if (this->actionFunc != func_8089BD28) { s16 rotY = player->actor.shape.rot.y - this->actor.shape.rot.y; @@ -716,7 +715,7 @@ void func_8089BBB4(EnDinofos* this, GlobalContext* globalCtx) { this->skelAnime.playSpeed = this->actor.speedXZ * 0.166666671634f; } else { Animation_Change(&this->skelAnime, &object_dinofos_Anim_00D62C, this->actor.speedXZ * 0.166666671634f, 0.0f, - 0.0f, 0, -4.0f); + 0.0f, ANIMMODE_LOOP, -4.0f); } this->actor.world.rot.y = BINANG_ADD(this->actor.shape.rot.y, 0x4000); @@ -727,13 +726,13 @@ void func_8089BBB4(EnDinofos* this, GlobalContext* globalCtx) { this->actionFunc = func_8089BD28; } -void func_8089BD28(EnDinofos* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); +void func_8089BD28(EnDinofos* this, PlayState* play) { + Player* player = GET_PLAYER(play); s16 phi_v0; f32 sp2C = 0.0f; Math_ScaledStepToS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer, 0xBB8); - if (!func_8089AE00(this, globalCtx)) { + if (!func_8089AE00(this, play)) { if (this->actor.bgCheckFlags & 8) { if (this->actor.speedXZ >= 0.0f) { phi_v0 = BINANG_ADD(this->actor.shape.rot.y, 0x4000); @@ -766,7 +765,7 @@ void func_8089BD28(EnDinofos* this, GlobalContext* globalCtx) { } this->actor.world.rot.y = BINANG_ADD(this->actor.shape.rot.y, 0x4000); - if (Actor_OtherIsTargeted(globalCtx, &this->actor)) { + if (Actor_OtherIsTargeted(play, &this->actor)) { sp2C = 100.0f; } @@ -784,7 +783,7 @@ void func_8089BD28(EnDinofos* this, GlobalContext* globalCtx) { if (this->unk_292 != 0) { this->unk_292--; } else { - func_8089A9B0(this, globalCtx); + func_8089A9B0(this, play); } if (Animation_OnFrame(&this->skelAnime, 0.0f) || Animation_OnFrame(&this->skelAnime, 5.0f)) { @@ -811,7 +810,7 @@ void func_8089C024(EnDinofos* this, s32 arg1) { this->actionFunc = func_8089C0DC; } -void func_8089C0DC(EnDinofos* this, GlobalContext* globalCtx) { +void func_8089C0DC(EnDinofos* this, PlayState* play) { Math_ScaledStepToS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer, 0x1000); this->actor.world.rot.y = this->actor.shape.rot.y; SkelAnime_Update(&this->skelAnime); @@ -841,7 +840,7 @@ void func_8089C164(EnDinofos* this) { this->actionFunc = func_8089C1F8; } -void func_8089C1F8(EnDinofos* this, GlobalContext* globalCtx) { +void func_8089C1F8(EnDinofos* this, PlayState* play) { SkelAnime_Update(&this->skelAnime); if (this->actor.bgCheckFlags & 1) { func_8089C398(this); @@ -858,14 +857,14 @@ void func_8089C244(EnDinofos* this) { this->actionFunc = func_8089C2A8; } -void func_8089C2A8(EnDinofos* this, GlobalContext* globalCtx) { +void func_8089C2A8(EnDinofos* this, PlayState* play) { SkelAnime_Update(&this->skelAnime); this->unk_290++; Math_ScaledStepToS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer, 0x1800); if ((this->actor.velocity.y < 0.0f) && (this->skelAnime.animation == &object_dinofos_Anim_001CCC)) { this->colliderQuad.base.atFlags |= AT_ON; this->colliderJntSph.base.acFlags |= AC_ON; - Animation_Change(&this->skelAnime, &object_dinofos_Anim_0025B4, 1.0f, 7.0f, 13.0f, 2, -2.0f); + Animation_Change(&this->skelAnime, &object_dinofos_Anim_0025B4, 1.0f, 7.0f, 13.0f, ANIMMODE_ONCE, -2.0f); } if (this->actor.bgCheckFlags & 1) { @@ -893,13 +892,13 @@ void func_8089C398(EnDinofos* this) { this->actionFunc = func_8089C44C; } -void func_8089C44C(EnDinofos* this, GlobalContext* globalCtx) { +void func_8089C44C(EnDinofos* this, PlayState* play) { if (SkelAnime_Update(&this->skelAnime)) { if ((this->unk_290 == 1) && (this->actor.xzDistToPlayer < 280.0f) && func_8089A968(this) && (Rand_ZeroOne() < 0.6f)) { func_8089CA14(this); } else { - func_8089A9B0(this, globalCtx); + func_8089A9B0(this, play); } } } @@ -915,14 +914,14 @@ void func_8089C4F8(EnDinofos* this) { this->actionFunc = func_8089C56C; } -void func_8089C56C(EnDinofos* this, GlobalContext* globalCtx) { +void func_8089C56C(EnDinofos* this, PlayState* play) { this->unk_290++; Math_ScaledStepToS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer, 0x800); this->actor.world.rot.y = this->actor.shape.rot.y; if (SkelAnime_Update(&this->skelAnime)) { EffectBlure_AddSpace(Effect_GetByIndex(this->unk_2A0)); this->colliderQuad.base.atFlags &= ~AT_ON; - func_8089A9B0(this, globalCtx); + func_8089A9B0(this, play); } else if (Animation_OnFrame(&this->skelAnime, 7.0f)) { this->colliderQuad.base.atFlags |= AT_ON; func_8089AD70(this); @@ -931,12 +930,13 @@ void func_8089C56C(EnDinofos* this, GlobalContext* globalCtx) { } else if (Animation_OnFrame(&this->skelAnime, 11.0f)) { Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_RIZA_ATTACK); } else if (this->skelAnime.curFrame < 7.0f) { - func_8089AE00(this, globalCtx); + func_8089AE00(this, play); } } void func_8089C690(EnDinofos* this) { - Animation_Change(&this->skelAnime, &object_dinofos_Anim_0025B4, -1.0f, this->skelAnime.curFrame, 0.0f, 2, 0.0f); + Animation_Change(&this->skelAnime, &object_dinofos_Anim_0025B4, -1.0f, this->skelAnime.curFrame, 0.0f, + ANIMMODE_ONCE, 0.0f); this->colliderQuad.base.atFlags &= ~(AT_ON | AT_BOUNCED); if (this->actionFunc != func_8089C2A8) { this->actor.world.rot.y = this->actor.shape.rot.y; @@ -946,13 +946,13 @@ void func_8089C690(EnDinofos* this) { this->actionFunc = func_8089C724; } -void func_8089C724(EnDinofos* this, GlobalContext* globalCtx) { +void func_8089C724(EnDinofos* this, PlayState* play) { if (this->actor.bgCheckFlags & 1) { Math_StepToF(&this->actor.speedXZ, 0.0f, 0.5f); } if (SkelAnime_Update(&this->skelAnime)) { - func_8089A9B0(this, globalCtx); + func_8089A9B0(this, play); } } @@ -964,13 +964,13 @@ void func_8089C784(EnDinofos* this) { this->actionFunc = func_8089C7B8; } -void func_8089C7B8(EnDinofos* this, GlobalContext* globalCtx) { +void func_8089C7B8(EnDinofos* this, PlayState* play) { if (this->unk_290 != 0) { this->unk_290--; } if (this->unk_290 == 0) { - func_8089ACEC(this, globalCtx); + func_8089ACEC(this, play); if (this->actor.colChkInfo.health == 0) { if (this->actor.cutscene == -1) { func_8089CFAC(this); @@ -980,7 +980,7 @@ void func_8089C7B8(EnDinofos* this, GlobalContext* globalCtx) { } else if (func_8089A968(this) && (this->actor.xzDistToPlayer < 100.0f)) { func_8089CA14(this); } else { - func_8089A9B0(this, globalCtx); + func_8089A9B0(this, play); } } } @@ -1000,7 +1000,7 @@ void func_8089C87C(EnDinofos* this, s32 arg1) { this->actionFunc = func_8089C938; } -void func_8089C938(EnDinofos* this, GlobalContext* globalCtx) { +void func_8089C938(EnDinofos* this, PlayState* play) { Math_StepToF(&this->actor.speedXZ, 0.0f, 0.5f); if (SkelAnime_Update(&this->skelAnime) && (this->actor.bgCheckFlags & 1)) { if (this->actor.colChkInfo.health == 0) { @@ -1013,7 +1013,7 @@ void func_8089C938(EnDinofos* this, GlobalContext* globalCtx) { func_8089CA14(this); } else { this->colliderJntSph.base.acFlags |= AC_ON; - func_8089A9B0(this, globalCtx); + func_8089A9B0(this, play); } } } @@ -1026,17 +1026,17 @@ void func_8089CA14(EnDinofos* this) { this->actionFunc = func_8089CA74; } -void func_8089CA74(EnDinofos* this, GlobalContext* globalCtx) { +void func_8089CA74(EnDinofos* this, PlayState* play) { Math_ScaledStepToS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer, 0x800); Math_StepToF(&this->actor.speedXZ, 0.0f, 0.5f); if (SkelAnime_Update(&this->skelAnime)) { - func_8089CB10(this, globalCtx); - } else if (!func_8089AE00(this, globalCtx) && Animation_OnFrame(&this->skelAnime, 12.0f)) { + func_8089CB10(this, play); + } else if (!func_8089AE00(this, play) && Animation_OnFrame(&this->skelAnime, 12.0f)) { this->actor.speedXZ = 8.0f; } } -void func_8089CB10(EnDinofos* this, GlobalContext* globalCtx) { +void func_8089CB10(EnDinofos* this, PlayState* play) { s32 i; Sphere16* worldSphere; @@ -1053,14 +1053,14 @@ void func_8089CB10(EnDinofos* this, GlobalContext* globalCtx) { worldSphere->center.z = this->limbPos[10].z; } - if (globalCtx->sceneNum == SCENE_MITURIN) { - globalCtx->envCtx.lightSettingOverride = 11; + if (play->sceneNum == SCENE_MITURIN) { + play->envCtx.lightSettingOverride = 11; } this->actionFunc = func_8089CBEC; } -void func_8089CBEC(EnDinofos* this, GlobalContext* globalCtx) { +void func_8089CBEC(EnDinofos* this, PlayState* play) { s16 temp_s3 = ((s32)randPlusMinusPoint5Scaled(0x1000) + this->actor.shape.rot.y) + this->unk_28E; Vec3f sp88; Vec3f sp7C; @@ -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->limbPos[10], &sp88, &sp7C, 30, 22, 255 - (temp_s0 * 20), 20, 3, 8); + EffectSsDFire_Spawn(play, &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))) { @@ -1107,22 +1107,22 @@ void func_8089CBEC(EnDinofos* this, GlobalContext* globalCtx) { if (this->unk_290 != 0) { this->unk_290--; } else { - func_8089CF00(this, globalCtx); + func_8089CF00(this, play); } } -void func_8089CF00(EnDinofos* this, GlobalContext* globalCtx) { +void func_8089CF00(EnDinofos* this, PlayState* play) { Animation_PlayOnce(&this->skelAnime, &object_dinofos_Anim_0017B8); this->colliderJntSph.base.atFlags &= ~AT_ON; - if (globalCtx->sceneNum == SCENE_MITURIN) { - globalCtx->envCtx.lightSettingOverride = 255; + if (play->sceneNum == SCENE_MITURIN) { + play->envCtx.lightSettingOverride = 255; } this->actionFunc = func_8089CF70; } -void func_8089CF70(EnDinofos* this, GlobalContext* globalCtx) { +void func_8089CF70(EnDinofos* this, PlayState* play) { if (SkelAnime_Update(&this->skelAnime)) { - func_8089A9B0(this, globalCtx); + func_8089A9B0(this, play); } } @@ -1135,13 +1135,13 @@ void func_8089CFAC(EnDinofos* this) { this->actionFunc = func_8089D018; } -void func_8089D018(EnDinofos* this, GlobalContext* globalCtx) { +void func_8089D018(EnDinofos* this, PlayState* play) { if (SkelAnime_Update(&this->skelAnime)) { s32 temp_v0 = this->unk_288 - 10; if (this->actor.category == ACTORCAT_ENEMY) { - func_800BC154(globalCtx, &globalCtx->actorCtx, &this->actor, ACTORCAT_PROP); - func_8089ABF4(this, globalCtx); + func_800BC154(play, &play->actorCtx, &this->actor, ACTORCAT_PROP); + func_8089ABF4(this, play); } if (temp_v0 <= 0) { @@ -1167,8 +1167,8 @@ void func_8089D11C(EnDinofos* this, s16 arg1) { } else { this->actor.speedXZ = 15.0f; } - Animation_Change(&this->skelAnime, &object_dinofos_Anim_00D62C, this->actor.speedXZ * (1.0f / 7.5f), 0.0f, 0.0f, 0, - -4.0f); + Animation_Change(&this->skelAnime, &object_dinofos_Anim_00D62C, this->actor.speedXZ * (1.0f / 7.5f), 0.0f, 0.0f, + ANIMMODE_LOOP, -4.0f); this->actor.world.rot.y = BINANG_ADD(this->actor.shape.rot.y, 0x4000); this->unk_292 = 10; this->unk_2A4 = 0.0f; @@ -1176,7 +1176,7 @@ void func_8089D11C(EnDinofos* this, s16 arg1) { this->actionFunc = func_8089D1E0; } -void func_8089D1E0(EnDinofos* this, GlobalContext* globalCtx) { +void func_8089D1E0(EnDinofos* this, PlayState* play) { Math_ScaledStepToS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer, 0xBB8); Math_StepToF(&this->actor.speedXZ, 0.0f, 2.0f); @@ -1187,7 +1187,7 @@ void func_8089D1E0(EnDinofos* this, GlobalContext* globalCtx) { if (this->unk_292 != 0) { this->unk_292--; } else { - func_8089A9B0(this, globalCtx); + func_8089A9B0(this, play); } if (Animation_OnFrame(&this->skelAnime, 0.0f) || Animation_OnFrame(&this->skelAnime, 5.0f)) { @@ -1200,32 +1200,32 @@ void func_8089D2E0(EnDinofos* this) { this->actionFunc = func_8089D318; } -void func_8089D318(EnDinofos* this, GlobalContext* globalCtx) { +void func_8089D318(EnDinofos* this, PlayState* play) { Vec3f subCamEye; if (ActorCutscene_GetCanPlayNext(this->actor.cutscene)) { if (this->actor.colChkInfo.health == 0) { ActorCutscene_Start(this->actor.cutscene, &this->actor); - func_800B724C(globalCtx, &this->actor, 7); + func_800B724C(play, &this->actor, 7); } else { ActorCutscene_StartAndSetUnkLinkFields(this->actor.cutscene, &this->actor); } - this->subCamId = ActorCutscene_GetCurrentCamera(this->actor.cutscene); + this->subCamId = ActorCutscene_GetCurrentSubCamId(this->actor.cutscene); if (this->actor.colChkInfo.health == 0) { subCamEye.x = (Math_SinS(this->actor.shape.rot.y) * 150.0f) + this->actor.focus.pos.x; subCamEye.y = this->actor.focus.pos.y; 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); + Play_SetCameraAtEye(play, this->subCamId, &this->actor.focus.pos, &subCamEye); func_8089CFAC(this); } else { - func_8089B100(this, globalCtx); + func_8089B100(this, play); } } else { ActorCutscene_SetIntentToPlay(this->actor.cutscene); } } -void func_8089D42C(EnDinofos* this, GlobalContext* globalCtx) { +void func_8089D42C(EnDinofos* this, PlayState* play) { s16 temp_v0_2; if ((this->actionFunc == func_8089B834) && (this->unk_290 != 0)) { @@ -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 (!Play_InCsMode(globalCtx)) { + } else if (!Play_InCsMode(play)) { 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); @@ -1243,7 +1243,7 @@ void func_8089D42C(EnDinofos* this, GlobalContext* globalCtx) { } } -s32 func_8089D60C(EnDinofos* this, GlobalContext* globalCtx) { +s32 func_8089D60C(EnDinofos* this, PlayState* play) { s32 i; if (this->colliderJntSph.base.acFlags & AC_HIT) { @@ -1270,7 +1270,7 @@ s32 func_8089D60C(EnDinofos* this, GlobalContext* globalCtx) { } if (!Actor_ApplyDamage(&this->actor)) { - Enemy_StartFinishingBlow(globalCtx, &this->actor); + Enemy_StartFinishingBlow(play, &this->actor); D_8089E350--; if (D_8089E350 == 0) { if (D_8089E34C != -1) { @@ -1283,10 +1283,10 @@ s32 func_8089D60C(EnDinofos* this, GlobalContext* globalCtx) { } } - func_8089ACEC(this, globalCtx); + func_8089ACEC(this, play); func_8089AD70(this); - if (globalCtx->sceneNum == SCENE_MITURIN) { - globalCtx->envCtx.lightSettingOverride = 255; + if (play->sceneNum == SCENE_MITURIN) { + play->envCtx.lightSettingOverride = 255; } this->colliderQuad.base.atFlags &= ~(AT_ON | AT_BOUNCED); @@ -1328,7 +1328,7 @@ s32 func_8089D60C(EnDinofos* this, GlobalContext* globalCtx) { this->drawDmgEffAlpha = 4.0f; this->drawDmgEffScale = 0.55f; this->drawDmgEffType = ACTOR_DRAW_DMGEFF_LIGHT_ORBS; - Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_CLEAR_TAG, + Actor_Spawn(&play->actorCtx, play, ACTOR_EN_CLEAR_TAG, this->colliderJntSph.elements[i].info.bumper.hitPos.x, this->colliderJntSph.elements[i].info.bumper.hitPos.y, this->colliderJntSph.elements[i].info.bumper.hitPos.z, 0, 0, 0, CLEAR_TAG_LARGE_LIGHT_RAYS); @@ -1340,8 +1340,8 @@ s32 func_8089D60C(EnDinofos* this, GlobalContext* globalCtx) { return false; } -void EnDinofos_Update(Actor* thisx, GlobalContext* globalCtx2) { - GlobalContext* globalCtx = globalCtx2; +void EnDinofos_Update(Actor* thisx, PlayState* play2) { + PlayState* play = play2; EnDinofos* this = THIS; s32 pad; Vec3f sp30; @@ -1350,23 +1350,23 @@ void EnDinofos_Update(Actor* thisx, GlobalContext* globalCtx2) { func_8089A900(this); } - if (!func_8089D60C(this, globalCtx) && (this->colliderQuad.base.atFlags & AT_BOUNCED)) { + if (!func_8089D60C(this, play) && (this->colliderQuad.base.atFlags & AT_BOUNCED)) { func_8089C690(this); } - this->actionFunc(this, globalCtx); + this->actionFunc(this, play); Actor_MoveWithGravity(&this->actor); - Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 25.0f, 30.0f, 60.0f, 0x5D); + Actor_UpdateBgCheckInfo(play, &this->actor, 25.0f, 30.0f, 60.0f, 0x5D); if (this->actionFunc != func_8089C7B8) { if ((this->actor.depthInWater > 0.0f) && (this->actor.depthInWater < 10.0f)) { - if (!((globalCtx->gameplayFrames % 4) & 1)) { - Math_Vec3f_Copy(&sp30, &this->limbPos[1 + (globalCtx->gameplayFrames % 4)]); + if (!((play->gameplayFrames % 4) & 1)) { + Math_Vec3f_Copy(&sp30, &this->limbPos[1 + (play->gameplayFrames % 4)]); sp30.y = this->actor.world.pos.y + this->actor.depthInWater; - EffectSsGRipple_Spawn(globalCtx, &sp30, 100, 320, 0); + EffectSsGRipple_Spawn(play, &sp30, 100, 320, 0); } } if (this->actionFunc != func_8089D018) { - func_8089D42C(this, globalCtx); + func_8089D42C(this, play); } } @@ -1377,16 +1377,16 @@ void EnDinofos_Update(Actor* thisx, GlobalContext* globalCtx2) { 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); + CollisionCheck_SetAC(play, &play->colChkCtx, &this->colliderJntSph.base); } - CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->colliderJntSph.base); + CollisionCheck_SetOC(play, &play->colChkCtx, &this->colliderJntSph.base); if (this->colliderJntSph.base.atFlags & AT_ON) { - CollisionCheck_SetAT(globalCtx, &globalCtx->colChkCtx, &this->colliderJntSph.base); + CollisionCheck_SetAT(play, &play->colChkCtx, &this->colliderJntSph.base); } if (this->colliderQuad.base.atFlags & AT_ON) { - CollisionCheck_SetAT(globalCtx, &globalCtx->colChkCtx, &this->colliderQuad.base); + CollisionCheck_SetAT(play, &play->colChkCtx, &this->colliderQuad.base); } if (this->drawDmgEffAlpha > 0.0f) { @@ -1400,8 +1400,7 @@ void EnDinofos_Update(Actor* thisx, GlobalContext* globalCtx2) { } } -s32 func_8089DC4C(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, Actor* thisx, - Gfx** gfx) { +s32 func_8089DC4C(PlayState* play, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, Actor* thisx, Gfx** gfx) { EnDinofos* this = THIS; if (limbIndex == 16) { @@ -1411,7 +1410,7 @@ s32 func_8089DC4C(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* p return 0; } -void func_8089DC84(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx, Gfx** gfx) { +void func_8089DC84(PlayState* play, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx, Gfx** gfx) { static Vec3f D_8089E38C = { 400.0f, -3600.0f, 0.0f }; static Vec3f D_8089E398 = { 300.0f, 500.0f, 0.0f }; static Vec3f D_8089E3A4 = { 700.0f, 400.0f, 0.0f }; @@ -1429,15 +1428,15 @@ void func_8089DC84(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* Collider_UpdateSpheres(limbIndex, &this->colliderJntSph); if (D_8089E3B0[limbIndex] != -1) { - Matrix_GetStateTranslation(&this->limbPos[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); @@ -1446,58 +1445,58 @@ 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->limbPos[10], &sp4C, &gZeroVec3f, 30, 22, 255 - (sp58 * 20), 20, 3, 8); + EffectSsDFire_Spawn(play, &this->limbPos[10], &sp4C, &gZeroVec3f, 30, 22, 255 - (sp58 * 20), 20, 3, 8); this->unk_292 = this->unk_290; } } } -void EnDinofos_Draw(Actor* thisx, GlobalContext* globalCtx) { +void EnDinofos_Draw(Actor* thisx, PlayState* play) { EnDinofos* this = THIS; - OPEN_DISPS(globalCtx->state.gfxCtx); + OPEN_DISPS(play->state.gfxCtx); if (this->unk_288 == 255) { - func_8012C28C(globalCtx->state.gfxCtx); - func_800B8050(&this->actor, globalCtx, 0); + func_8012C28C(play->state.gfxCtx); + func_800B8050(&this->actor, play, 0); gSPSegment(POLY_OPA_DISP++, 0x08, D_8089E33C[this->unk_289]); gDPSetEnvColor(POLY_OPA_DISP++, 20, 40, 40, 255); - Scene_SetRenderModeXlu(globalCtx, 0, 1); + Scene_SetRenderModeXlu(play, 0, 1); POLY_OPA_DISP = - SkelAnime_DrawFlex(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, - this->skelAnime.dListCount, func_8089DC4C, func_8089DC84, &this->actor, POLY_OPA_DISP); + SkelAnime_DrawFlex(play, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, + func_8089DC4C, func_8089DC84, &this->actor, POLY_OPA_DISP); } else { - func_8012C2DC(globalCtx->state.gfxCtx); - func_800B8118(&this->actor, globalCtx, 0); + func_8012C2DC(play->state.gfxCtx); + func_800B8118(&this->actor, play, 0); gSPSegment(POLY_XLU_DISP++, 0x08, D_8089E33C[this->unk_289]); gDPSetEnvColor(POLY_XLU_DISP++, 20, 40, 40, this->unk_288); - Scene_SetRenderModeXlu(globalCtx, 1, 2); + Scene_SetRenderModeXlu(play, 1, 2); POLY_XLU_DISP = - SkelAnime_DrawFlex(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, - this->skelAnime.dListCount, func_8089DC4C, func_8089DC84, &this->actor, POLY_XLU_DISP); + SkelAnime_DrawFlex(play, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, + func_8089DC4C, func_8089DC84, &this->actor, POLY_XLU_DISP); } - Actor_DrawDamageEffects(globalCtx, &this->actor, this->limbPos, ARRAY_COUNT(this->limbPos), this->drawDmgEffScale, + Actor_DrawDamageEffects(play, &this->actor, this->limbPos, ARRAY_COUNT(this->limbPos), this->drawDmgEffScale, this->drawDmgEffFrozenSteamScale, this->drawDmgEffAlpha, this->drawDmgEffType); - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->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 f5c7431f0..fcdf48c32 100644 --- a/src/overlays/actors/ovl_En_Dinofos/z_en_dinofos.h +++ b/src/overlays/actors/ovl_En_Dinofos/z_en_dinofos.h @@ -5,7 +5,7 @@ struct EnDinofos; -typedef void (*EnDinofosActionFunc)(struct EnDinofos*, GlobalContext*); +typedef void (*EnDinofosActionFunc)(struct EnDinofos*, PlayState*); typedef struct EnDinofos { /* 0x000 */ Actor actor; 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 d074753be..0d28281ef 100644 --- a/src/overlays/actors/ovl_En_Dnb/z_en_dnb.c +++ b/src/overlays/actors/ovl_En_Dnb/z_en_dnb.c @@ -12,14 +12,14 @@ #define THIS ((EnDnb*)thisx) -void EnDnb_Init(Actor* thisx, GlobalContext* globalCtx); -void EnDnb_Destroy(Actor* thisx, GlobalContext* globalCtx); -void EnDnb_Update(Actor* thisx, GlobalContext* globalCtx); -void EnDnb_Draw(Actor* thisx, GlobalContext* globalCtx); +void EnDnb_Init(Actor* thisx, PlayState* play); +void EnDnb_Destroy(Actor* thisx, PlayState* play); +void EnDnb_Update(Actor* thisx, PlayState* play); +void EnDnb_Draw(Actor* thisx, PlayState* play); s32 func_80A507C0(EnDnbUnkStruct* arg0, Vec3f arg1, Vec3f arg2, u8 arg3, f32 arg4, f32 arg5); s32 func_80A5086C(EnDnbUnkStruct* arg0); -s32 func_80A50950(EnDnbUnkStruct* arg0, GlobalContext* globalCtx); +s32 func_80A50950(EnDnbUnkStruct* arg0, PlayState* play); const ActorInit En_Dnb_InitVars = { ACTOR_EN_DNB, @@ -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) { @@ -99,35 +99,35 @@ s32 func_80A500F8(EnDnb* this) { return i; } -void EnDnb_Init(Actor* thisx, GlobalContext* globalCtx) { +void EnDnb_Init(Actor* thisx, PlayState* play) { EnDnb* this = THIS; s32 i; s16* alloc; DynaPolyActor_Init(&this->dyna, 1); - DynaPolyActor_LoadMesh(globalCtx, &this->dyna, &object_hanareyama_obj_Colheader_004D8C); + DynaPolyActor_LoadMesh(play, &this->dyna, &object_hanareyama_obj_Colheader_004D8C); alloc = Lib_SegmentedToVirtual(object_hanareyama_obj_Vec_004710); - for (i = 0; i < ARRAY_COUNT(this->particles); i++) { - func_80A4FDD0(&this->particles[i], this, alloc, i); + for (i = 0; i < ARRAY_COUNT(this->effects); i++) { + func_80A4FDD0(&this->effects[i], this, alloc, i); } Actor_SetScale(&this->dyna.actor, 1.0f); } -void EnDnb_Destroy(Actor* thisx, GlobalContext* globalCtx) { +void EnDnb_Destroy(Actor* thisx, PlayState* play) { EnDnb* this = THIS; - DynaPoly_DeleteBgActor(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); + DynaPoly_DeleteBgActor(play, &play->colCtx.dyna, this->dyna.bgId); } -void EnDnb_Update(Actor* thisx, GlobalContext* globalCtx) { +void EnDnb_Update(Actor* thisx, PlayState* play) { EnDnb* this = THIS; 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--; @@ -150,65 +150,63 @@ void EnDnb_Update(Actor* thisx, GlobalContext* globalCtx) { func_80A5086C(this->unk_0D38); } -void func_80A50510(EnDnb* this, GlobalContext* globalCtx) { +void func_80A50510(EnDnb* this, PlayState* play) { s32 i; Gfx** gfx = Lib_SegmentedToVirtual(object_hanareyama_obj_DLArray_004638); - OPEN_DISPS(globalCtx->state.gfxCtx); + OPEN_DISPS(play->state.gfxCtx); - func_8012C2DC(globalCtx->state.gfxCtx); + func_8012C2DC(play->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); + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(play->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); + CLOSE_DISPS(play->state.gfxCtx); } -void func_80A5063C(EnDnb* this, GlobalContext* globalCtx) { +void func_80A5063C(EnDnb* this, PlayState* play) { s32 i; Gfx** gfx = Lib_SegmentedToVirtual(object_hanareyama_obj_DLArray_004638); - OPEN_DISPS(globalCtx->state.gfxCtx); + OPEN_DISPS(play->state.gfxCtx); - func_8012C28C(globalCtx->state.gfxCtx); + func_8012C28C(play->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); + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(play->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); + CLOSE_DISPS(play->state.gfxCtx); } -void EnDnb_Draw(Actor* thisx, GlobalContext* globalCtx) { +void EnDnb_Draw(Actor* thisx, PlayState* play) { EnDnb* this = THIS; - if (globalCtx->actorCtx.unk4 != 0) { - func_80A50510(this, globalCtx); + if (play->actorCtx.unk4 != 0) { + func_80A50510(this, play); } else { - func_80A5063C(this, globalCtx); + func_80A5063C(this, play); } - func_80A50950(this->unk_0D38, globalCtx); + func_80A50950(this->unk_0D38, play); } s32 func_80A507C0(EnDnbUnkStruct* arg0, Vec3f arg1, Vec3f arg2, u8 arg3, f32 arg4, f32 arg5) { @@ -253,19 +251,19 @@ s32 func_80A5086C(EnDnbUnkStruct* arg0) { return count; } -s32 func_80A50950(EnDnbUnkStruct* arg0, GlobalContext* globalCtx2) { +s32 func_80A50950(EnDnbUnkStruct* arg0, PlayState* play2) { static TexturePtr D_80A50CBC[] = { gDust8Tex, gDust7Tex, gDust6Tex, gDust5Tex, gDust4Tex, gDust3Tex, gDust2Tex, gDust1Tex, }; - GlobalContext* globalCtx = globalCtx2; + PlayState* play = play2; s32 isGfxSetup = false; s32 sp5C = 0; s32 idx; s32 i; - OPEN_DISPS(globalCtx->state.gfxCtx); + OPEN_DISPS(play->state.gfxCtx); - func_8012C2DC(globalCtx->state.gfxCtx); + func_8012C2DC(play->state.gfxCtx); for (i = 0; i < 256; i++, arg0++) { if (arg0->isEnabled == 1) { @@ -275,29 +273,28 @@ 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(&play->billboardMtxF); - gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), - G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); idx = (arg0->unk_01 / (f32)arg0->unk_02) * 8.0f; 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; } } - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->state.gfxCtx); return sp5C; } 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 25fbaefac..f1b78f25d 100644 --- a/src/overlays/actors/ovl_En_Dnh/z_en_dnh.c +++ b/src/overlays/actors/ovl_En_Dnh/z_en_dnh.c @@ -10,13 +10,13 @@ #define THIS ((EnDnh*)thisx) -void EnDnh_Init(Actor* thisx, GlobalContext* globalCtx); -void EnDnh_Destroy(Actor* thisx, GlobalContext* globalCtx); -void EnDnh_Update(Actor* thisx, GlobalContext* globalCtx); -void EnDnh_Draw(Actor* thisx, GlobalContext* globalCtx); +void EnDnh_Init(Actor* thisx, PlayState* play); +void EnDnh_Destroy(Actor* thisx, PlayState* play); +void EnDnh_Update(Actor* thisx, PlayState* play); +void EnDnh_Draw(Actor* thisx, PlayState* play); -void func_80A50F38(EnDnh* this, GlobalContext* globalCtx); -void func_80A50F9C(EnDnh* this, GlobalContext* globalCtx); +void func_80A50F38(EnDnh* this, PlayState* play); +void func_80A50F9C(EnDnh* this, PlayState* play); #if 0 const ActorInit En_Dnh_InitVars = { diff --git a/src/overlays/actors/ovl_En_Dnh/z_en_dnh.h b/src/overlays/actors/ovl_En_Dnh/z_en_dnh.h index 21336aa91..e26b9a7c0 100644 --- a/src/overlays/actors/ovl_En_Dnh/z_en_dnh.h +++ b/src/overlays/actors/ovl_En_Dnh/z_en_dnh.h @@ -5,12 +5,12 @@ struct EnDnh; -typedef void (*EnDnhActionFunc)(struct EnDnh*, GlobalContext*); +typedef void (*EnDnhActionFunc)(struct EnDnh*, PlayState*); typedef struct EnDnh { - /* 0x0000 */ Actor actor; - /* 0x0144 */ EnDnhActionFunc actionFunc; - /* 0x0148 */ char unk_148[0x74]; + /* 0x000 */ Actor actor; + /* 0x144 */ EnDnhActionFunc actionFunc; + /* 0x148 */ char unk_148[0x74]; } EnDnh; // size = 0x1BC extern const ActorInit En_Dnh_InitVars; diff --git a/src/overlays/actors/ovl_En_Dnk/z_en_dnk.c b/src/overlays/actors/ovl_En_Dnk/z_en_dnk.c index 969c719fd..7afd4e224 100644 --- a/src/overlays/actors/ovl_En_Dnk/z_en_dnk.c +++ b/src/overlays/actors/ovl_En_Dnk/z_en_dnk.c @@ -13,14 +13,14 @@ #define THIS ((EnDnk*)thisx) -void EnDnk_Init(Actor* thisx, GlobalContext* globalCtx); -void EnDnk_Destroy(Actor* thisx, GlobalContext* globalCtx); -void EnDnk_Update(Actor* thisx, GlobalContext* globalCtx); +void EnDnk_Init(Actor* thisx, PlayState* play); +void EnDnk_Destroy(Actor* thisx, PlayState* play); +void EnDnk_Update(Actor* thisx, PlayState* play); -void func_80A51890(EnDnk* this, GlobalContext* globalCtx); -void EnDnk_DoNothing(EnDnk* this, GlobalContext* globalCtx); -void func_80A52018(Actor* thisx, GlobalContext* globalCtx); -void func_80A52134(EnDnk* this, GlobalContext* globalCtx); +void func_80A51890(EnDnk* this, PlayState* play); +void EnDnk_DoNothing(EnDnk* this, PlayState* play); +void func_80A52018(Actor* thisx, PlayState* play); +void func_80A52134(EnDnk* this, PlayState* play); static s16 D_80A521A0 = 0; @@ -93,7 +93,7 @@ static DamageTable sDamageTable = { /* Powder Keg */ DMG_ENTRY(1, 0x0), }; -static AnimationInfoS sAnimations[] = { +static AnimationInfoS sAnimationInfo[] = { { &gDekuPalaceGuardStartAnim, 1.0f, 0, -1, ANIMMODE_ONCE, 0 }, { &gDekuPalaceGuardStartAnim, 1.0f, 0, -1, ANIMMODE_ONCE, -4 }, { &gDekuPalaceGuardWaitAnim, 1.0f, 0, -1, ANIMMODE_LOOP, -4 }, @@ -116,20 +116,20 @@ static AnimationInfoS sAnimations[] = { { &object_hintnuts_Anim_003128, 1.0f, 0, -1, ANIMMODE_LOOP, -4 }, { &object_hintnuts_Anim_0029BC, 1.0f, 0, -1, ANIMMODE_LOOP, -4 }, { &object_hintnuts_Anim_002E84, 1.0f, 0, -1, ANIMMODE_LOOP, -4 }, - { &object_dekunuts_Anim_000168, 1.0f, 0, -1, ANIMMODE_LOOP, -4 }, - { &object_dekunuts_Anim_00259C, 1.0f, 0, -1, ANIMMODE_ONCE, -4 }, - { &object_dekunuts_Anim_002A5C, 1.0f, 0, -1, ANIMMODE_ONCE, 0 }, - { &object_dekunuts_Anim_002A5C, 1.0f, 0, -1, ANIMMODE_ONCE, -4 }, - { &object_dekunuts_Anim_002BD4, 1.0f, 0, -1, ANIMMODE_ONCE, -4 }, - { &object_dekunuts_Anim_002DD4, 1.0f, 0, -1, ANIMMODE_ONCE, -4 }, - { &object_dekunuts_Anim_002FA4, 1.0f, 0, -1, ANIMMODE_LOOP, -4 }, - { &object_dekunuts_Anim_003180, 1.0f, 0, -1, ANIMMODE_ONCE, -4 }, - { &object_dekunuts_Anim_00326C, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, - { &object_dekunuts_Anim_00326C, 1.0f, 0, -1, ANIMMODE_LOOP, -4 }, - { &object_dekunuts_Anim_0033E4, 1.0f, 0, -1, ANIMMODE_LOOP, -4 }, - { &object_dekunuts_Anim_003780, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, - { &object_dekunuts_Anim_003780, 1.0f, 0, -1, ANIMMODE_LOOP, -4 }, - { &object_dekunuts_Anim_002950, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, + { &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) { @@ -138,18 +138,18 @@ s32 func_80A514F0(SkelAnime* skelAnime, s16 animIndex) { s32 sp30 = false; if (animIndex >= 0) { - if (animIndex < ARRAY_COUNT(sAnimations)) { + if (animIndex < ARRAY_COUNT(sAnimationInfo)) { sp30 = true; - frameCount = sAnimations[animIndex].frameCount; + frameCount = sAnimationInfo[animIndex].frameCount; if (frameCount < 0) { - frameCount = Animation_GetLastFrame(sAnimations[animIndex].animation); + frameCount = Animation_GetLastFrame(sAnimationInfo[animIndex].animation); } - frame = sAnimations[animIndex].startFrame; + frame = sAnimationInfo[animIndex].startFrame; if (frame < 0) { frame = frameCount; } - Animation_Change(skelAnime, sAnimations[animIndex].animation, sAnimations[animIndex].playSpeed, frame, - frameCount, sAnimations[animIndex].mode, sAnimations[animIndex].morphFrames); + Animation_Change(skelAnime, sAnimationInfo[animIndex].animation, sAnimationInfo[animIndex].playSpeed, frame, + frameCount, sAnimationInfo[animIndex].mode, sAnimationInfo[animIndex].morphFrames); } } return sp30; @@ -169,35 +169,35 @@ s32 func_80A515C4(EnDnk* this) { return ret; } -void func_80A51648(EnDnk* this, GlobalContext* globalCtx) { - if (SubS_IsObjectLoaded(this->unk_28E, globalCtx) == true) { - gSegments[0x06] = PHYSICAL_TO_VIRTUAL(globalCtx->objectCtx.status[this->unk_28E].segment); +void func_80A51648(EnDnk* this, PlayState* play) { + if (SubS_IsObjectLoaded(this->unk_28E, play) == true) { + gSegments[0x06] = PHYSICAL_TO_VIRTUAL(play->objectCtx.status[this->unk_28E].segment); this->actor.draw = func_80A52018; this->actor.objBankIndex = this->unk_28E; ActorShape_Init(&this->actor.shape, 0.0f, NULL, 18.0f); switch (ENDNK_GET_3(&this->actor)) { case ENDNK_GET_3_0: - SkelAnime_Init(globalCtx, &this->skelAnime, &gDekuPalaceGuardSkel, NULL, this->jointTable, - this->morphTable, 11); + SkelAnime_Init(play, &this->skelAnime, &gDekuPalaceGuardSkel, NULL, this->jointTable, this->morphTable, + DEKU_PALACE_GUARD_LIMB_MAX); func_80A514F0(&this->skelAnime, 7); break; case ENDNK_GET_3_1: - SkelAnime_Init(globalCtx, &this->skelAnime, &object_hintnuts_Skel_0023B8.sh, NULL, this->jointTable, + SkelAnime_Init(play, &this->skelAnime, &object_hintnuts_Skel_0023B8.sh, NULL, this->jointTable, this->morphTable, 10); func_80A514F0(&this->skelAnime, 18); break; case ENDNK_GET_3_2: - SkelAnime_Init(globalCtx, &this->skelAnime, &object_dekunuts_Skel_002468, NULL, this->jointTable, - this->morphTable, 10); + SkelAnime_Init(play, &this->skelAnime, &gDekuScrubSkel, NULL, this->jointTable, this->morphTable, + DEKU_SCRUB_LIMB_MAX); func_80A514F0(&this->skelAnime, 35); break; } - Collider_InitCylinder(globalCtx, &this->collider); - Collider_SetCylinder(globalCtx, &this->collider, &this->actor, &sCylinderInit); + Collider_InitCylinder(play, &this->collider); + Collider_SetCylinder(play, &this->collider, &this->actor, &sCylinderInit); CollisionCheck_SetInfo2(&this->actor.colChkInfo, &sDamageTable, &sColChkInfoInit); if (ENDNK_GET_3C(&this->actor) == 4) { this->actor.flags &= ~ACTOR_FLAG_1; @@ -212,30 +212,30 @@ void func_80A51648(EnDnk* this, GlobalContext* globalCtx) { } } -void func_80A51890(EnDnk* this, GlobalContext* globalCtx) { - if (Cutscene_CheckActorAction(globalCtx, 126)) { - Cutscene_ActorTranslateAndYaw(&this->actor, globalCtx, Cutscene_GetActorActionIndex(globalCtx, 126)); +void func_80A51890(EnDnk* this, PlayState* play) { + if (Cutscene_CheckActorAction(play, 126)) { + Cutscene_ActorTranslateAndYaw(&this->actor, play, Cutscene_GetActorActionIndex(play, 126)); } } -void EnDnk_DoNothing(EnDnk* this, GlobalContext* globalCtx) { +void EnDnk_DoNothing(EnDnk* this, PlayState* play) { } -void EnDnk_Init(Actor* thisx, GlobalContext* globalCtx) { +void EnDnk_Init(Actor* thisx, PlayState* play) { EnDnk* this = THIS; this->unk_28E = -1; switch (ENDNK_GET_3(&this->actor)) { case ENDNK_GET_3_1: - this->unk_28E = SubS_GetObjectIndex(OBJECT_HINTNUTS, globalCtx); + this->unk_28E = SubS_GetObjectIndex(OBJECT_HINTNUTS, play); break; case ENDNK_GET_3_0: - this->unk_28E = SubS_GetObjectIndex(OBJECT_DNK, globalCtx); + this->unk_28E = SubS_GetObjectIndex(OBJECT_DNK, play); break; case ENDNK_GET_3_2: - this->unk_28E = SubS_GetObjectIndex(OBJECT_DEKUNUTS, globalCtx); + this->unk_28E = SubS_GetObjectIndex(OBJECT_DEKUNUTS, play); break; } @@ -249,27 +249,27 @@ void EnDnk_Init(Actor* thisx, GlobalContext* globalCtx) { D_80A521A0++; } -void EnDnk_Destroy(Actor* thisx, GlobalContext* globalCtx) { +void EnDnk_Destroy(Actor* thisx, PlayState* play) { EnDnk* this = THIS; - Collider_DestroyCylinder(globalCtx, &this->collider); + Collider_DestroyCylinder(play, &this->collider); } -void EnDnk_Update(Actor* thisx, GlobalContext* globalCtx) { +void EnDnk_Update(Actor* thisx, PlayState* play) { EnDnk* this = THIS; s32 pad; - this->actionFunc(this, globalCtx); + this->actionFunc(this, play); SkelAnime_Update(&this->skelAnime); func_80A515C4(this); Actor_SetFocus(&this->actor, 34.0f); Collider_UpdateCylinder(&this->actor, &this->collider); - CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); - CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); - func_80A52134(this, globalCtx); + CollisionCheck_SetAC(play, &play->colChkCtx, &this->collider.base); + CollisionCheck_SetOC(play, &play->colChkCtx, &this->collider.base); + func_80A52134(this, play); } -s32 func_80A51A78(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, Actor* thisx) { +s32 func_80A51A78(PlayState* play, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, Actor* thisx) { EnDnk* this = THIS; this->unk_260[limbIndex] = *dList; @@ -277,7 +277,7 @@ s32 func_80A51A78(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* p return false; } -void func_80A51AA4(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx) { +void func_80A51AA4(PlayState* play, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx) { EnDnk* this = THIS; MtxF sp5C; Vec3f sp50 = gZeroVec3f; @@ -285,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) { @@ -311,20 +311,20 @@ 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); + OPEN_DISPS(play->state.gfxCtx); - gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_OPA_DISP++, this->unk_260[limbIndex]); - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->state.gfxCtx); } -void func_80A51CB8(EnDnk* this, GlobalContext* globalCtx) { +void func_80A51CB8(EnDnk* this, PlayState* play) { static TexturePtr D_80A5245C[] = { gDekuPalaceGuardEyeOpenTex, gDekuPalaceGuardEyeHalfTex, @@ -332,20 +332,20 @@ void func_80A51CB8(EnDnk* this, GlobalContext* globalCtx) { }; s32 pad; - OPEN_DISPS(globalCtx->state.gfxCtx); + OPEN_DISPS(play->state.gfxCtx); - func_8012C28C(globalCtx->state.gfxCtx); + func_8012C28C(play->state.gfxCtx); gSPSegment(POLY_OPA_DISP++, 0x08, Lib_SegmentedToVirtual(D_80A5245C[this->unk_2A0])); gDPPipeSync(POLY_OPA_DISP++); - SkelAnime_DrawOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, func_80A51A78, func_80A51AA4, + SkelAnime_DrawOpa(play, this->skelAnime.skeleton, this->skelAnime.jointTable, func_80A51A78, func_80A51AA4, &this->actor); - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->state.gfxCtx); } -s32 func_80A51D78(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, Actor* thisx) { +s32 func_80A51D78(PlayState* play, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, Actor* thisx) { EnDnk* this = THIS; this->unk_260[limbIndex] = *dList; @@ -353,7 +353,7 @@ s32 func_80A51D78(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* p return false; } -void func_80A51DA4(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx) { +void func_80A51DA4(PlayState* play, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx) { EnDnk* this = THIS; MtxF sp5C; Vec3f sp50 = gZeroVec3f; @@ -361,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) { @@ -388,42 +388,42 @@ 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); + OPEN_DISPS(play->state.gfxCtx); - gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_OPA_DISP++, this->unk_260[limbIndex]); - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->state.gfxCtx); } -void func_80A51FC0(EnDnk* this, GlobalContext* globalCtx) { - func_8012C28C(globalCtx->state.gfxCtx); - SkelAnime_DrawOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, func_80A51D78, func_80A51DA4, +void func_80A51FC0(EnDnk* this, PlayState* play) { + func_8012C28C(play->state.gfxCtx); + SkelAnime_DrawOpa(play, this->skelAnime.skeleton, this->skelAnime.jointTable, func_80A51D78, func_80A51DA4, &this->actor); } -void func_80A52018(Actor* thisx, GlobalContext* globalCtx) { +void func_80A52018(Actor* thisx, PlayState* play) { EnDnk* this = THIS; switch (ENDNK_GET_3(thisx)) { case ENDNK_GET_3_0: - func_80A51CB8(this, globalCtx); + func_80A51CB8(this, play); break; case ENDNK_GET_3_1: case ENDNK_GET_3_2: - func_80A51FC0(this, globalCtx); + func_80A51FC0(this, play); break; } } -void func_80A52074(EnDnk* this, GlobalContext* globalCtx) { - switch (globalCtx->csCtx.frames) { +void func_80A52074(EnDnk* this, PlayState* play) { + switch (play->csCtx.frames) { case 80: func_8019F128(NA_SE_EN_DEKNUTS_DANCE1); break; @@ -441,14 +441,14 @@ void func_80A52074(EnDnk* this, GlobalContext* globalCtx) { break; } - if ((globalCtx->csCtx.frames >= 198) && (globalCtx->csCtx.frames < 438)) { + if ((play->csCtx.frames >= 198) && (play->csCtx.frames < 438)) { func_8019F128(NA_SE_EN_DEKNUTS_DANCE - SFX_FLAG); } } -void func_80A52134(EnDnk* this, GlobalContext* globalCtx) { - if ((globalCtx->csCtx.state != 0) && (ENDNK_GET_3C(&this->actor) == 4) && (globalCtx->sceneNum == SCENE_SPOT00) && +void func_80A52134(EnDnk* this, PlayState* play) { + if ((play->csCtx.state != 0) && (ENDNK_GET_3C(&this->actor) == 4) && (play->sceneNum == SCENE_SPOT00) && (gSaveContext.sceneSetupIndex == 2)) { - func_80A52074(this, globalCtx); + func_80A52074(this, play); } } diff --git a/src/overlays/actors/ovl_En_Dnk/z_en_dnk.h b/src/overlays/actors/ovl_En_Dnk/z_en_dnk.h index 70ecdedae..9b6913548 100644 --- a/src/overlays/actors/ovl_En_Dnk/z_en_dnk.h +++ b/src/overlays/actors/ovl_En_Dnk/z_en_dnk.h @@ -5,7 +5,7 @@ struct EnDnk; -typedef void (*EnDnkActionFunc)(struct EnDnk*, GlobalContext*); +typedef void (*EnDnkActionFunc)(struct EnDnk*, PlayState*); #define ENDNK_GET_3(thisx) ((thisx)->params & 0x3) #define ENDNK_GET_3C(thisx) ((thisx)->params & 0x3C) 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 ceffe3d93..d935a1dae 100644 --- a/src/overlays/actors/ovl_En_Dno/z_en_dno.c +++ b/src/overlays/actors/ovl_En_Dno/z_en_dno.c @@ -13,32 +13,32 @@ #define THIS ((EnDno*)thisx) -void EnDno_Init(Actor* thisx, GlobalContext* globalCtx); -void EnDno_Destroy(Actor* thisx, GlobalContext* globalCtx); -void EnDno_Update(Actor* thisx, GlobalContext* globalCtx); -void EnDno_Draw(Actor* thisx, GlobalContext* globalCtx); +void EnDno_Init(Actor* thisx, PlayState* play); +void EnDno_Destroy(Actor* thisx, PlayState* play); +void EnDno_Update(Actor* thisx, PlayState* play); +void EnDno_Draw(Actor* thisx, PlayState* play); -void func_80A71B04(EnDno* this, GlobalContext* globalCtx); -void EnDno_DoNothing(EnDno* this, GlobalContext* globalCtx); -void func_80A71B68(EnDno* this, GlobalContext* globalCtx); -void func_80A71C3C(EnDno* this, GlobalContext* globalCtx); -void func_80A71E54(EnDno* this, GlobalContext* globalCtx); -void func_80A71F18(EnDno* this, GlobalContext* globalCtx); -void func_80A72438(EnDno* this, GlobalContext* globalCtx); -void func_80A724B8(EnDno* this, GlobalContext* globalCtx); -void func_80A725E0(EnDno* this, GlobalContext* globalCtx); -void func_80A725F8(EnDno* this, GlobalContext* globalCtx); -void func_80A72AE4(EnDno* this, GlobalContext* globalCtx); -void func_80A72B3C(EnDno* this, GlobalContext* globalCtx); -void func_80A72B84(EnDno* this, GlobalContext* globalCtx); -void func_80A72BA4(EnDno* this, GlobalContext* globalCtx); -void func_80A72C04(EnDno* this, GlobalContext* globalCtx); -void func_80A72CF8(EnDno* this, GlobalContext* globalCtx); -void func_80A730A0(EnDno* this, GlobalContext* globalCtx); -void func_80A73244(EnDno* this, GlobalContext* globalCtx); -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); +void func_80A71B04(EnDno* this, PlayState* play); +void EnDno_DoNothing(EnDno* this, PlayState* play); +void func_80A71B68(EnDno* this, PlayState* play); +void func_80A71C3C(EnDno* this, PlayState* play); +void func_80A71E54(EnDno* this, PlayState* play); +void func_80A71F18(EnDno* this, PlayState* play); +void func_80A72438(EnDno* this, PlayState* play); +void func_80A724B8(EnDno* this, PlayState* play); +void func_80A725E0(EnDno* this, PlayState* play); +void func_80A725F8(EnDno* this, PlayState* play); +void func_80A72AE4(EnDno* this, PlayState* play); +void func_80A72B3C(EnDno* this, PlayState* play); +void func_80A72B84(EnDno* this, PlayState* play); +void func_80A72BA4(EnDno* this, PlayState* play); +void func_80A72C04(EnDno* this, PlayState* play); +void func_80A72CF8(EnDno* this, PlayState* play); +void func_80A730A0(EnDno* this, PlayState* play); +void func_80A73244(EnDno* this, PlayState* play); +void func_80A732C8(EnDno* this, PlayState* play); +s32 EnDno_OverrideLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, Actor* thisx); +void EnDno_PostLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx); static AnimationSpeedInfo sAnimations[] = { { &object_dno_Anim_000470, 1.0f, ANIMMODE_ONCE, 0.0f }, { &object_dno_Anim_0008F0, 1.0f, ANIMMODE_ONCE, 0.0f }, @@ -92,7 +92,7 @@ static InitChainEntry sInitChain[] = { ICHAIN_F32(uncullZoneForward, 4000, ICHAIN_STOP), }; -void func_80A711D0(EnDno* this, GlobalContext* globalCtx, Vec3f* vec) { +void func_80A711D0(EnDno* this, PlayState* play, Vec3f* vec) { f32 rand = Rand_ZeroOne() * 0.5f; Lights_PointGlowSetInfo(&this->lightInfo, vec->x, vec->y, vec->z, (127.5f * rand) + 127.5f, @@ -112,14 +112,14 @@ s32 func_80A71424(s16* arg0, s16 arg1, s16 yawToPlayer, s16 rotY, s16 arg4, s16 return ret; } -void func_80A714B4(EnDno* this, GlobalContext* globalCtx) { +void func_80A714B4(EnDno* this, PlayState* play) { Actor* actor = NULL; do { - actor = SubS_FindActor(globalCtx, actor, ACTORCAT_BG, ACTOR_BG_CRACE_MOVEBG); + actor = SubS_FindActor(play, actor, ACTORCAT_BG, ACTOR_BG_CRACE_MOVEBG); if (actor != NULL) { if (ENDNO_GET_F(actor) == ENDNO_GET_F_1) { - Flags_SetSwitch(globalCtx, ENDNO_GET_7F0(actor)); + Flags_SetSwitch(play, ENDNO_GET_7F0(actor)); } actor = actor->next; } @@ -138,7 +138,7 @@ void func_80A7153C(EnDno* this, Vec3f* arg1, Vec3f* arg2) { arg1->y = arg2->y - this->actor.home.pos.y; } -void func_80A715DC(EnDno* this, GlobalContext* globalCtx) { +void func_80A715DC(EnDno* this, PlayState* play) { BgCraceMovebg* crace = NULL; s32 pad[2]; Vec3f sp88; @@ -146,43 +146,43 @@ void func_80A715DC(EnDno* this, GlobalContext* globalCtx) { Vec3f sp70; do { - crace = (BgCraceMovebg*)SubS_FindActor(globalCtx, &crace->actor, ACTORCAT_BG, ACTOR_BG_CRACE_MOVEBG); + crace = (BgCraceMovebg*)SubS_FindActor(play, &crace->dyna.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)) { - 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); + if (ENDNO_GET_F(&crace->dyna.actor) == ENDNO_GET_F_0 && !(crace->unk170 & 1)) { + if (SubS_LineSegVsPlane(&crace->dyna.actor.home.pos, &crace->dyna.actor.home.rot, &D_80A73B2C, + &this->actor.prevPos, &this->actor.world.pos, &sp88)) { + Math_Vec3f_Diff(&this->actor.world.pos, &crace->dyna.actor.home.pos, &sp7C); + Matrix_RotateYS(-crace->dyna.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; + crace->unk170 |= 1; } } } - crace = (BgCraceMovebg*)crace->actor.next; + crace = (BgCraceMovebg*)crace->dyna.actor.next; } } while (crace != NULL); } -void func_80A71788(EnDno* this, GlobalContext* globalCtx) { +void func_80A71788(EnDno* this, PlayState* play) { Actor* actor = NULL; do { - actor = SubS_FindActor(globalCtx, actor, ACTORCAT_BG, ACTOR_BG_CRACE_MOVEBG); + actor = SubS_FindActor(play, actor, ACTORCAT_BG, ACTOR_BG_CRACE_MOVEBG); if (actor != NULL) { - Flags_UnsetSwitch(globalCtx, ENDNO_GET_7F0(actor)); + Flags_UnsetSwitch(play, ENDNO_GET_7F0(actor)); actor = actor->next; } } while (actor != NULL); } -void EnDno_Init(Actor* thisx, GlobalContext* globalCtx) { +void EnDno_Init(Actor* thisx, PlayState* play) { EnDno* this = THIS; s32 pad; Actor* actor = NULL; while (true) { - actor = SubS_FindActor(globalCtx, actor, ACTORCAT_NPC, ACTOR_EN_DNO); + actor = SubS_FindActor(play, actor, ACTORCAT_NPC, ACTOR_EN_DNO); if (actor != NULL) { if (actor != thisx) { Actor_MarkForDeath(thisx); @@ -194,11 +194,11 @@ void EnDno_Init(Actor* thisx, GlobalContext* globalCtx) { if (actor == NULL) { Actor_ProcessInitChain(thisx, sInitChain); ActorShape_Init(&thisx->shape, 0.0f, ActorShadow_DrawCircle, 21.0f); - SkelAnime_InitFlex(globalCtx, &this->skelAnime, &object_dno_Skel_00E1F8, &object_dno_Anim_007CA4, + SkelAnime_InitFlex(play, &this->skelAnime, &object_dno_Skel_00E1F8, &object_dno_Anim_007CA4, this->jointTable, this->morphTable, 28); - Collider_InitCylinder(globalCtx, &this->collider); - Collider_SetCylinder(globalCtx, &this->collider, thisx, &sCylinderInit); - Actor_UpdateBgCheckInfo(globalCtx, thisx, 0.0f, 0.0f, 0.0f, 4); + Collider_InitCylinder(play, &this->collider); + Collider_SetCylinder(play, &this->collider, thisx, &sCylinderInit); + Actor_UpdateBgCheckInfo(play, thisx, 0.0f, 0.0f, 0.0f, 4); Animation_Change(&this->skelAnime, sAnimations[14].animation, 1.0f, 0.0f, Animation_GetLastFrame(sAnimations[14].animation), sAnimations[14].mode, sAnimations[14].morphFrames); @@ -210,14 +210,14 @@ void EnDno_Init(Actor* thisx, GlobalContext* globalCtx) { switch (ENDNO_GET_C000(thisx)) { case ENDNO_GET_C000_0: - func_80A71788(this, globalCtx); + func_80A71788(this, play); if (!(gSaveContext.save.weekEventReg[23] & 0x20) || (gSaveContext.save.weekEventReg[93] & 2)) { Actor_MarkForDeath(thisx); } else { 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); + this->lightNode = LightContext_InsertLight(play, &play->lightCtx, &this->lightInfo); this->unk_3B0 |= 1; this->actionFunc = func_80A72438; this->unk_454 = 0.0f; @@ -229,7 +229,7 @@ void EnDno_Init(Actor* thisx, GlobalContext* globalCtx) { Actor_MarkForDeath(thisx); } else { SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimations, 13, &this->unk_32C); - this->unk_460 = SubS_FindActor(globalCtx, NULL, ACTORCAT_NPC, ACTOR_EN_DNQ); + this->unk_460 = SubS_FindActor(play, NULL, ACTORCAT_NPC, ACTOR_EN_DNQ); if (this->unk_460 == NULL) { Actor_MarkForDeath(thisx); } else { @@ -247,23 +247,23 @@ void EnDno_Init(Actor* thisx, GlobalContext* globalCtx) { } } -void EnDno_Destroy(Actor* thisx, GlobalContext* globalCtx) { +void EnDno_Destroy(Actor* thisx, PlayState* play) { EnDno* this = THIS; - Collider_DestroyCylinder(globalCtx, &this->collider); - LightContext_RemoveLight(globalCtx, &globalCtx->lightCtx, this->lightNode); + Collider_DestroyCylinder(play, &this->collider); + LightContext_RemoveLight(play, &play->lightCtx, this->lightNode); } -void func_80A71B04(EnDno* this, GlobalContext* globalCtx) { +void func_80A71B04(EnDno* this, PlayState* play) { this->unk_452 = 0; SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimations, 19, &this->unk_32C); this->actionFunc = EnDno_DoNothing; } -void EnDno_DoNothing(EnDno* this, GlobalContext* globalCtx) { +void EnDno_DoNothing(EnDno* this, PlayState* play) { } -void func_80A71B68(EnDno* this, GlobalContext* globalCtx) { +void func_80A71B68(EnDno* this, PlayState* play) { this->unk_452 = 0; this->actor.textId = 0; if (CHECK_QUEST_ITEM(QUEST_SONG_SONATA)) { @@ -281,7 +281,7 @@ void func_80A71B68(EnDno* this, GlobalContext* globalCtx) { this->actionFunc = func_80A71C3C; } -void func_80A71C3C(EnDno* this, GlobalContext* globalCtx) { +void func_80A71C3C(EnDno* this, PlayState* play) { switch (this->unk_32C) { case 9: case 16: @@ -320,16 +320,16 @@ void func_80A71C3C(EnDno* this, GlobalContext* globalCtx) { Math_ScaledStepToS(&this->actor.shape.rot.y, this->actor.home.rot.y, 0x222); } - if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { - globalCtx->msgCtx.msgMode = 0; - globalCtx->msgCtx.unk11F10 = 0; - func_80A71E54(this, globalCtx); + if (Actor_ProcessTalkRequest(&this->actor, &play->state)) { + play->msgCtx.msgMode = 0; + play->msgCtx.msgLength = 0; + func_80A71E54(this, play); } else if (this->actor.xzDistToPlayer < 60.0f) { - func_800B8614(&this->actor, globalCtx, 60.0f); + func_800B8614(&this->actor, play, 60.0f); } } -void func_80A71E54(EnDno* this, GlobalContext* globalCtx) { +void func_80A71E54(EnDno* this, PlayState* play) { if (CHECK_QUEST_ITEM(QUEST_SONG_SONATA)) { if (gSaveContext.save.weekEventReg[27] & 1) { this->textId = 0x811; @@ -353,10 +353,10 @@ void func_80A71E54(EnDno* this, GlobalContext* globalCtx) { this->actionFunc = func_80A71F18; } -void func_80A71F18(EnDno* this, GlobalContext* globalCtx) { +void func_80A71F18(EnDno* this, PlayState* play) { Math_ScaledStepToS(&this->unk_466, 0, 0x16C); - switch (Message_GetState(&globalCtx->msgCtx)) { - case 0: + switch (Message_GetState(&play->msgCtx)) { + case TEXT_STATE_NONE: if (!(this->unk_3B0 & 0x10) || Math_ScaledStepToS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer, 0xE38)) { switch (this->textId) { @@ -364,7 +364,7 @@ void func_80A71F18(EnDno* this, GlobalContext* globalCtx) { SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimations, 16, &this->unk_32C); case 0x811: - Message_StartTextbox(globalCtx, this->textId, &this->actor); + Message_StartTextbox(play, this->textId, &this->actor); break; case 0x80C: @@ -373,15 +373,15 @@ void func_80A71F18(EnDno* this, GlobalContext* globalCtx) { SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimations, 4, &this->unk_32C); } else if ((this->unk_32C == 4) && (this->skelAnime.curFrame == this->skelAnime.endFrame)) { SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimations, 11, &this->unk_32C); - Message_StartTextbox(globalCtx, this->textId, &this->actor); + Message_StartTextbox(play, this->textId, &this->actor); } break; } } break; - case 3: - if (globalCtx->msgCtx.currentTextId == 0x80B) { + case TEXT_STATE_3: + if (play->msgCtx.currentTextId == 0x80B) { switch (this->unk_32C) { case 16: if (this->skelAnime.curFrame == this->skelAnime.endFrame) { @@ -393,19 +393,19 @@ void func_80A71F18(EnDno* this, GlobalContext* globalCtx) { case 10: if (this->skelAnime.curFrame == this->skelAnime.endFrame) { - func_801477B4(globalCtx); + func_801477B4(play); SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimations, 13, &this->unk_32C); - func_80A71B68(this, globalCtx); + func_80A71B68(this, play); } break; } } break; - case 4: - case 5: - case 6: - switch (globalCtx->msgCtx.currentTextId) { + case TEXT_STATE_CHOICE: + case TEXT_STATE_5: + case TEXT_STATE_DONE: + switch (play->msgCtx.currentTextId) { case 0x80B: switch (this->unk_32C) { case 16: @@ -415,31 +415,31 @@ void func_80A71F18(EnDno* this, GlobalContext* globalCtx) { break; case 9: - if (Message_ShouldAdvance(globalCtx)) { + if (Message_ShouldAdvance(play)) { SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimations, 10, &this->unk_32C); - globalCtx->msgCtx.msgMode = 0x44; + play->msgCtx.msgMode = 0x44; } break; case 10: if (this->skelAnime.curFrame == this->skelAnime.endFrame) { - func_801477B4(globalCtx); + func_801477B4(play); SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimations, 13, &this->unk_32C); - func_80A71B68(this, globalCtx); + func_80A71B68(this, play); } break; } break; case 0x80C: - if (Message_ShouldAdvance(globalCtx)) { - func_80151938(globalCtx, 0x80D); + if (Message_ShouldAdvance(play)) { + func_80151938(play, 0x80D); } break; case 0x80D: - if (Message_ShouldAdvance(globalCtx)) { - func_80151938(globalCtx, 0x80E); + if (Message_ShouldAdvance(play)) { + func_80151938(play, 0x80E); } break; @@ -450,23 +450,23 @@ void func_80A71F18(EnDno* this, GlobalContext* globalCtx) { if (this->skelAnime.curFrame == this->skelAnime.endFrame) { SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimations, 13, &this->unk_32C); } - } else if ((this->unk_32C == 13) && Message_ShouldAdvance(globalCtx)) { - func_801477B4(globalCtx); - func_80A71B68(this, globalCtx); + } else if ((this->unk_32C == 13) && Message_ShouldAdvance(play)) { + func_801477B4(play); + func_80A71B68(this, play); } break; case 0x80F: - if (Message_ShouldAdvance(globalCtx)) { - func_80151938(globalCtx, 0x810); + if (Message_ShouldAdvance(play)) { + func_80151938(play, 0x810); } break; case 0x810: - if (Message_ShouldAdvance(globalCtx)) { + if (Message_ShouldAdvance(play)) { this->unk_3B0 |= 0x20; - func_801477B4(globalCtx); - func_80A71B68(this, globalCtx); + func_801477B4(play); + func_80A71B68(this, play); break; } @@ -484,9 +484,9 @@ void func_80A71F18(EnDno* this, GlobalContext* globalCtx) { break; case 0x811: - if (Message_ShouldAdvance(globalCtx)) { - func_801477B4(globalCtx); - func_80A71B68(this, globalCtx); + if (Message_ShouldAdvance(play)) { + func_801477B4(play); + func_80A71B68(this, play); } break; } @@ -494,50 +494,50 @@ void func_80A71F18(EnDno* this, GlobalContext* globalCtx) { } } -void func_80A72438(EnDno* this, GlobalContext* globalCtx) { +void func_80A72438(EnDno* this, PlayState* play) { this->unk_452 = 1; SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimations, 14, &this->unk_32C); this->actor.textId = 0; - if (Flags_GetSwitch(globalCtx, ENDNO_GET_3F80(&this->actor))) { + if (Flags_GetSwitch(play, ENDNO_GET_3F80(&this->actor))) { this->unk_454 = 1.0f; } this->actionFunc = func_80A724B8; } -void func_80A724B8(EnDno* this, GlobalContext* globalCtx) { +void func_80A724B8(EnDno* this, PlayState* play) { if (this->actor.xzDistToPlayer < 120.0f) { func_80A71424(&this->unk_466, 0, this->actor.yawTowardsPlayer, this->actor.home.rot.y, 0x2000, 0x2D8); } - if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { - func_80A725E0(this, globalCtx); + if (Actor_ProcessTalkRequest(&this->actor, &play->state)) { + func_80A725E0(this, play); } else if (this->actor.xzDistToPlayer < 60.0f) { - func_800B8614(&this->actor, globalCtx, 60.0f); + func_800B8614(&this->actor, play, 60.0f); } } -void func_80A7256C(EnDno* this, GlobalContext* globalCtx) { - func_800B8500(&this->actor, globalCtx, this->actor.xzDistToPlayer, this->actor.playerHeightRel, EXCH_ITEM_MINUS1); +void func_80A7256C(EnDno* this, PlayState* play) { + func_800B8500(&this->actor, play, this->actor.xzDistToPlayer, this->actor.playerHeightRel, PLAYER_AP_MINUS1); } -void func_80A72598(EnDno* this, GlobalContext* globalCtx) { - if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { - func_80A725E0(this, globalCtx); +void func_80A72598(EnDno* this, PlayState* play) { + if (Actor_ProcessTalkRequest(&this->actor, &play->state)) { + func_80A725E0(this, play); } else { - func_80A7256C(this, globalCtx); + func_80A7256C(this, play); } } -void func_80A725E0(EnDno* this, GlobalContext* globalCtx) { +void func_80A725E0(EnDno* this, PlayState* play) { this->actionFunc = func_80A725F8; } -void func_80A725F8(EnDno* this, GlobalContext* globalCtx) { +void func_80A725F8(EnDno* this, PlayState* play) { s32 pad[2]; func_80A71424(&this->unk_466, 0, 0, 0, 0x2000, 0x16C); - switch (Message_GetState(&globalCtx->msgCtx)) { - case 0: + switch (Message_GetState(&play->msgCtx)) { + case TEXT_STATE_NONE: switch (this->unk_328) { case 0: if (this->unk_32C == 14) { @@ -545,12 +545,12 @@ void func_80A725F8(EnDno* this, GlobalContext* globalCtx) { 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))) { - Message_StartTextbox(globalCtx, 0x801, &this->actor); - } else if (Player_GetMask(globalCtx) == PLAYER_MASK_SCENTS) { - Message_StartTextbox(globalCtx, 0x806, &this->actor); + if (Flags_GetSwitch(play, ENDNO_GET_3F80(&this->actor))) { + Message_StartTextbox(play, 0x801, &this->actor); + } else if (Player_GetMask(play) == PLAYER_MASK_SCENTS) { + Message_StartTextbox(play, 0x806, &this->actor); } else { - Message_StartTextbox(globalCtx, 0x800, &this->actor); + Message_StartTextbox(play, 0x800, &this->actor); } SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimations, 14, &this->unk_32C); } @@ -559,20 +559,20 @@ void func_80A725F8(EnDno* this, GlobalContext* globalCtx) { case 2: if (Math_ScaledStepToS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer, 0x2D8)) { gSaveContext.save.weekEventReg[93] |= 2; - Message_StartTextbox(globalCtx, 0x802, &this->actor); + Message_StartTextbox(play, 0x802, &this->actor); } break; case 3: - Message_StartTextbox(globalCtx, 0x804, &this->actor); + Message_StartTextbox(play, 0x804, &this->actor); break; } break; - case 1: - case 2: - case 3: - if (((globalCtx->msgCtx.currentTextId == 0x800) || (globalCtx->msgCtx.currentTextId == 0x801)) && + case TEXT_STATE_1: + case TEXT_STATE_CLOSING: + case TEXT_STATE_3: + if (((play->msgCtx.currentTextId == 0x800) || (play->msgCtx.currentTextId == 0x801)) && (this->unk_32C == 8)) { Math_SmoothStepToF(&this->unk_454, 1.0f, 1.0f, 0.1f, 0.01f); if (this->skelAnime.curFrame <= 23.0f) { @@ -588,19 +588,19 @@ void func_80A725F8(EnDno* this, GlobalContext* globalCtx) { if (Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) { SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimations, 12, &this->unk_32C); - Message_StartTextbox(globalCtx, 0x803, &this->actor); + Message_StartTextbox(play, 0x803, &this->actor); } } break; - case 4: - case 5: - case 6: - switch (globalCtx->msgCtx.currentTextId) { + case TEXT_STATE_CHOICE: + case TEXT_STATE_5: + case TEXT_STATE_DONE: + switch (play->msgCtx.currentTextId) { case 0x800: case 0x801: - if (Message_ShouldAdvance(globalCtx)) { - globalCtx->msgCtx.msgMode = 0x44; + if (Message_ShouldAdvance(play)) { + play->msgCtx.msgMode = 0x44; this->unk_452 = 1; this->unk_454 = 0.0f; SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimations, 8, &this->unk_32C); @@ -608,103 +608,103 @@ void func_80A725F8(EnDno* this, GlobalContext* globalCtx) { break; case 0x802: - if (Message_ShouldAdvance(globalCtx)) { + if (Message_ShouldAdvance(play)) { if (INV_CONTENT(ITEM_MASK_SCENTS) == ITEM_MASK_SCENTS) { - this->unk_458 = GI_RUPEE_RED; + this->getItemId = GI_RUPEE_RED; } else { - this->unk_458 = GI_MASK_SCENTS; + this->getItemId = GI_MASK_SCENTS; } - Actor_PickUp(&this->actor, globalCtx, this->unk_458, 60.0f, 60.0f); - func_801477B4(globalCtx); - func_80A72B84(this, globalCtx); + Actor_PickUp(&this->actor, play, this->getItemId, 60.0f, 60.0f); + func_801477B4(play); + func_80A72B84(this, play); } break; case 0x803: - if (Message_ShouldAdvance(globalCtx)) { - func_80A72AE4(this, globalCtx); + if (Message_ShouldAdvance(play)) { + func_80A72AE4(this, play); } break; case 0x804: if (this->unk_32C == 14) { - if (Message_ShouldAdvance(globalCtx)) { + if (Message_ShouldAdvance(play)) { SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimations, 5, &this->unk_32C); if (!(this->unk_3B0 & 0x40)) { - func_80A72CF8(this, globalCtx); + func_80A72CF8(this, play); this->unk_3B0 |= 0x40; } } } else if ((this->unk_32C == 5) && (this->skelAnime.curFrame == this->skelAnime.endFrame)) { - func_801477B4(globalCtx); - func_80A72438(this, globalCtx); + func_801477B4(play); + func_80A72438(this, play); } break; case 0x806: - if (Message_ShouldAdvance(globalCtx)) { - func_80151938(globalCtx, 0x800); + if (Message_ShouldAdvance(play)) { + func_80151938(play, 0x800); } break; default: - func_80A72438(this, globalCtx); + func_80A72438(this, play); break; } break; } } -void func_80A72AE4(EnDno* this, GlobalContext* globalCtx) { +void func_80A72AE4(EnDno* this, PlayState* play) { SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimations, 0, &this->unk_32C); - func_80A714B4(this, globalCtx); + func_80A714B4(this, play); this->actionFunc = func_80A72B3C; } -void func_80A72B3C(EnDno* this, GlobalContext* globalCtx) { +void func_80A72B3C(EnDno* this, PlayState* play) { if (Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) { this->unk_44E = 0; - func_80A72C04(this, globalCtx); + func_80A72C04(this, play); } } -void func_80A72B84(EnDno* this, GlobalContext* globalCtx) { +void func_80A72B84(EnDno* this, PlayState* play) { this->unk_328 = 3; this->actionFunc = func_80A72BA4; } -void func_80A72BA4(EnDno* this, GlobalContext* globalCtx) { - if (Actor_HasParent(&this->actor, globalCtx)) { +void func_80A72BA4(EnDno* this, PlayState* play) { + if (Actor_HasParent(&this->actor, play)) { this->actor.parent = NULL; this->actionFunc = func_80A72598; } else { - Actor_PickUp(&this->actor, globalCtx, this->unk_458, 60.0f, 60.0f); + Actor_PickUp(&this->actor, play, this->getItemId, 60.0f, 60.0f); } } -void func_80A72C04(EnDno* this, GlobalContext* globalCtx) { +void func_80A72C04(EnDno* this, PlayState* play) { 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); - SubS_ActorPathing_Init(globalCtx, &this->unk_334, &this->actor, &this->actorPath, globalCtx->setupPathList, + SubS_ActorPathing_Init(play, &this->unk_334, &this->actor, &this->actorPath, play->setupPathList, ENDNO_GET_7F(&this->actor), 1, 0, 1, 0); - SubS_ActorPathing_ComputePointInfo(globalCtx, &this->actorPath); + SubS_ActorPathing_ComputePointInfo(play, &this->actorPath); 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)); + Flags_SetSwitch(play, ENDNO_GET_3F80(&this->actor)); this->actionFunc = func_80A730A0; } -void func_80A72CF8(EnDno* this, GlobalContext* globalCtx) { - Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 0.0f, 0.0f, 0.0f, 4); - Actor_SpawnAsChild(&globalCtx->actorCtx, &this->actor, globalCtx, ACTOR_DOOR_WARP1, this->actor.world.pos.x + 80.0f, +void func_80A72CF8(EnDno* this, PlayState* play) { + Actor_UpdateBgCheckInfo(play, &this->actor, 0.0f, 0.0f, 0.0f, 4); + Actor_SpawnAsChild(&play->actorCtx, &this->actor, play, ACTOR_DOOR_WARP1, this->actor.world.pos.x + 80.0f, this->actor.floorHeight, this->actor.world.pos.z, 0, 0, 0, 0x201); } -s32 EnDno_ActorPathing_UpdateActorInfo(GlobalContext* globalCtx, ActorPathing* actorPath) { +s32 EnDno_ActorPathing_UpdateActorInfo(PlayState* play, ActorPathing* actorPath) { Actor* thisx = actorPath->actor; s32 pad; s32 ret = false; @@ -744,7 +744,7 @@ s32 EnDno_ActorPathing_UpdateActorInfo(GlobalContext* globalCtx, ActorPathing* a return ret; } -s32 EnDno_ActorPathing_Move(GlobalContext* globalCtx, ActorPathing* actorPath) { +s32 EnDno_ActorPathing_Move(PlayState* play, ActorPathing* actorPath) { Actor* thisx = actorPath->actor; EnDno* this = (EnDno*)thisx; f32 sp24 = Math_CosS(-thisx->world.rot.x) * thisx->speedXZ; @@ -761,7 +761,7 @@ s32 EnDno_ActorPathing_Move(GlobalContext* globalCtx, ActorPathing* actorPath) { return false; } -void func_80A730A0(EnDno* this, GlobalContext* globalCtx) { +void func_80A730A0(EnDno* this, PlayState* play) { f32 temp_f10; s32 phi_a2; @@ -786,7 +786,7 @@ void func_80A730A0(EnDno* this, GlobalContext* globalCtx) { } } - SubS_ActorPathing_Update(globalCtx, &this->actorPath, SubS_ActorPathing_ComputePointInfo, + SubS_ActorPathing_Update(play, &this->actorPath, SubS_ActorPathing_ComputePointInfo, EnDno_ActorPathing_UpdateActorInfo, EnDno_ActorPathing_Move, SubS_ActorPathing_SetNextPoint); this->unk_45C += 6553; @@ -799,7 +799,7 @@ void func_80A730A0(EnDno* this, GlobalContext* globalCtx) { this->unk_3AC += 4500; this->unk_3AE += 1000; this->actor.shape.rot.y = this->actor.yawTowardsPlayer; - func_80A715DC(this, globalCtx); + func_80A715DC(this, play); func_800B9010(&this->actor, NA_SE_EV_BUTLER_FRY - SFX_FLAG); if (this->actorPath.flags & ACTOR_PATHING_REACHED_END_PERMANENT) { Math_Vec3f_Copy(&this->actor.world.pos, &this->actorPath.curPoint); @@ -807,22 +807,22 @@ void func_80A730A0(EnDno* this, GlobalContext* globalCtx) { this->actor.velocity.x = 0.0f; this->actor.velocity.y = 0.0f; this->actor.velocity.z = 0.0f; - func_80A73244(this, globalCtx); + func_80A73244(this, play); } } -void func_80A73244(EnDno* this, GlobalContext* globalCtx) { +void func_80A73244(EnDno* this, PlayState* play) { 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)); + Flags_UnsetSwitch(play, ENDNO_GET_3F80(&this->actor)); gSaveContext.unk_3DD0[1] = 5; this->unk_44E = 0; this->actionFunc = func_80A732C8; } -void func_80A732C8(EnDno* this, GlobalContext* globalCtx) { +void func_80A732C8(EnDno* this, PlayState* play) { s32 pad; if (this->unk_44E == 0) { @@ -834,7 +834,7 @@ void func_80A732C8(EnDno* this, GlobalContext* globalCtx) { } else if (this->unk_44E == 3) { if (Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) { SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimations, 14, &this->unk_32C); - func_80A72438(this, globalCtx); + func_80A72438(this, play); } else { if (this->skelAnime.curFrame >= 20.0f) { Math_SmoothStepToF(&this->unk_454, 0.0f, 1.0f, 0.125f, 0.01f); @@ -851,15 +851,15 @@ void func_80A732C8(EnDno* this, GlobalContext* globalCtx) { Actor_MoveWithGravity(&this->actor); } -void func_80A73408(EnDno* this, GlobalContext* globalCtx) { +void func_80A73408(EnDno* this, PlayState* play) { s32 phi_a2; u8 sp33 = true; s32 temp_v0; - 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) { + if (Cutscene_CheckActorAction(play, 475)) { + temp_v0 = Cutscene_GetActorActionIndex(play, 475); + if (this->unk_468 != play->csCtx.actorActions[temp_v0]->action) { + switch (play->csCtx.actorActions[temp_v0]->action) { case 1: phi_a2 = 13; break; @@ -878,7 +878,7 @@ void func_80A73408(EnDno* this, GlobalContext* globalCtx) { SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimations, phi_a2, &this->unk_32C); } } - Cutscene_ActorTranslateAndYaw(&this->actor, globalCtx, temp_v0); + Cutscene_ActorTranslateAndYaw(&this->actor, play, temp_v0); } if ((Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) && (this->unk_32C == 17)) { @@ -887,29 +887,29 @@ void func_80A73408(EnDno* this, GlobalContext* globalCtx) { } } -void EnDno_Update(Actor* thisx, GlobalContext* globalCtx) { +void EnDno_Update(Actor* thisx, PlayState* play) { EnDno* this = THIS; s32 pad; SkelAnime_Update(&this->skelAnime); - func_80A73408(this, globalCtx); - this->actionFunc(this, globalCtx); + func_80A73408(this, play); + this->actionFunc(this, play); if (this->unk_3B0 & 4) { - Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 0.0f, 0.0f, 0.0f, 4); + Actor_UpdateBgCheckInfo(play, &this->actor, 0.0f, 0.0f, 0.0f, 4); } Collider_UpdateCylinder(&this->actor, &this->collider); - CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + CollisionCheck_SetOC(play, &play->colChkCtx, &this->collider.base); Actor_SetFocus(&this->actor, 51.0f); } -void EnDno_Draw(Actor* thisx, GlobalContext* globalCtx) { +void EnDno_Draw(Actor* thisx, PlayState* play) { EnDno* this = THIS; - SkelAnime_DrawFlexOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, + SkelAnime_DrawFlexOpa(play, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, EnDno_OverrideLimbDraw, EnDno_PostLimbDraw, &this->actor); } -s32 EnDno_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, Actor* thisx) { +s32 EnDno_OverrideLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, Actor* thisx) { EnDno* this = THIS; *dList = NULL; @@ -919,7 +919,7 @@ s32 EnDno_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, return false; } -void EnDno_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx) { +void EnDno_PostLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx) { static Vec3f D_80A73B40 = { 0.0f, 0.0f, 0.0f }; Gfx* gfxOpa; Gfx* gfxXlu; @@ -965,47 +965,47 @@ void EnDno_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Ve } if (phi_v0 == true) { - OPEN_DISPS(globalCtx->state.gfxCtx); + OPEN_DISPS(play->state.gfxCtx); - func_8012C28C(globalCtx->state.gfxCtx); + func_8012C28C(play->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; - gSPMatrix(gfxOpa, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPMatrix(gfxOpa, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(&gfxOpa[1], *dList); POLY_OPA_DISP = gfxOpa + 2; - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->state.gfxCtx); } if ((this->unk_3B0 & 1) && (limbIndex == 26)) { u32 frames; - OPEN_DISPS(globalCtx->state.gfxCtx); + OPEN_DISPS(play->state.gfxCtx); - Matrix_StatePush(); - frames = globalCtx->gameplayFrames; - Matrix_MultiplyVector3fByState(&D_80A73B40, &sp84); - func_80A711D0(this, globalCtx, &sp84); - Matrix_NormalizeXYZ(&globalCtx->billboardMtxF); + Matrix_Push(); + frames = play->gameplayFrames; + Matrix_MultVec3f(&D_80A73B40, &sp84); + func_80A711D0(this, play, &sp84); + Matrix_ReplaceRotation(&play->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); + gSPMatrix(gfxXlu, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPSegment(&gfxXlu[1], 0x08, - Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, 0, 0, 0x20, 0x40, 1, 0, -frames * 20, 0x20, 0x80)); + Gfx_TwoTexScroll(play->state.gfxCtx, 0, 0, 0, 0x20, 0x40, 1, 0, -frames * 20, 0x20, 0x80)); gDPSetPrimColor(&gfxXlu[2], 0x80, 0x80, 255, 255, 0, 255); gDPSetEnvColor(&gfxXlu[3], 255, 0, 0, 0); - gSPDisplayList(&gfxXlu[4], gGameplayKeepDrawFlameDL); + gSPDisplayList(&gfxXlu[4], gEffFire1DL); POLY_XLU_DISP = gfxXlu + 5; - Matrix_StatePop(); + Matrix_Pop(); - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->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 dcffee6c9..bf357cad6 100644 --- a/src/overlays/actors/ovl_En_Dno/z_en_dno.h +++ b/src/overlays/actors/ovl_En_Dno/z_en_dno.h @@ -5,7 +5,7 @@ struct EnDno; -typedef void (*EnDnoActionFunc)(struct EnDno*, GlobalContext*); +typedef void (*EnDnoActionFunc)(struct EnDno*, PlayState*); #define ENDNO_GET_F(thisx) ((thisx)->params & 0xF) #define ENDNO_GET_7F(thisx) ((thisx)->params & 0x7F) @@ -48,7 +48,7 @@ typedef struct EnDno { /* 0x44F */ UNK_TYPE1 unk_44F[0x3]; /* 0x452 */ s16 unk_452; /* 0x454 */ f32 unk_454; - /* 0x458 */ s32 unk_458; + /* 0x458 */ s32 getItemId; /* 0x45C */ s16 unk_45C; /* 0x460 */ Actor* unk_460; /* 0x464 */ u16 textId; 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 13a02345d..604453640 100644 --- a/src/overlays/actors/ovl_En_Dnp/z_en_dnp.c +++ b/src/overlays/actors/ovl_En_Dnp/z_en_dnp.c @@ -11,16 +11,16 @@ #define THIS ((EnDnp*)thisx) -void EnDnp_Init(Actor* thisx, GlobalContext* globalCtx); -void EnDnp_Destroy(Actor* thisx, GlobalContext* globalCtx); -void EnDnp_Update(Actor* thisx, GlobalContext* globalCtx); -void EnDnp_Draw(Actor* thisx, GlobalContext* globalCtx); +void EnDnp_Init(Actor* thisx, PlayState* play); +void EnDnp_Destroy(Actor* thisx, PlayState* play); +void EnDnp_Update(Actor* thisx, PlayState* play); +void EnDnp_Draw(Actor* thisx, PlayState* play); -void func_80B3D11C(EnDnp* this, GlobalContext* globalCtx); -void func_80B3D2D4(EnDnp* this, GlobalContext* globalCtx); -void func_80B3D338(EnDnp* this, GlobalContext* globalCtx); -void func_80B3D3F8(EnDnp* this, GlobalContext* globalCtx); -void func_80B3D558(EnDnp* this, GlobalContext* globalCtx); +void func_80B3D11C(EnDnp* this, PlayState* play); +void func_80B3D2D4(EnDnp* this, PlayState* play); +void func_80B3D338(EnDnp* this, PlayState* play); +void func_80B3D3F8(EnDnp* this, PlayState* play); +void func_80B3D558(EnDnp* this, PlayState* play); const ActorInit En_Dnp_InitVars = { ACTOR_EN_DNP, @@ -56,7 +56,7 @@ static ColliderCylinderInit sCylinderInit = { static CollisionCheckInfoInit2 sColChkInfoInit = { 0, 0, 0, 0, MASS_IMMOVABLE }; -static AnimationInfoS sAnimations[] = { +static AnimationInfoS sAnimationInfo[] = { { &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 }, @@ -135,19 +135,19 @@ s32 func_80B3CC38(EnDnp* this, s32 arg1) { if (arg1 != this->unk_340) { this->unk_340 = arg1; - ret = SubS_ChangeAnimationByInfoS(&this->skelAnime, sAnimations, arg1); + ret = SubS_ChangeAnimationByInfoS(&this->skelAnime, sAnimationInfo, arg1); } return ret; } -void func_80B3CC80(EnDnp* this, GlobalContext* globalCtx) { +void func_80B3CC80(EnDnp* this, PlayState* play) { f32 temp_f0 = this->actor.scale.x / 0.0085f; Collider_UpdateCylinder(&this->actor, &this->collider); this->collider.dim.radius = 14.0f * temp_f0; this->collider.dim.height = 38.0f * temp_f0; - CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + CollisionCheck_SetOC(play, &play->colChkCtx, &this->collider.base); } void func_80B3CD1C(EnDnp* this) { @@ -160,8 +160,8 @@ void func_80B3CD1C(EnDnp* this) { } } -s32 func_80B3CDA4(EnDnp* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); +s32 func_80B3CDA4(EnDnp* this, PlayState* play) { + Player* player = GET_PLAYER(play); s16 temp_s0 = this->actor.yawTowardsPlayer - this->actor.shape.rot.y; Vec3f sp3C; Vec3f sp30; @@ -181,9 +181,9 @@ s32 func_80B3CDA4(EnDnp* this, GlobalContext* globalCtx) { return 1; } -s32 func_80B3CEC0(EnDnp* this, GlobalContext* globalCtx) { +s32 func_80B3CEC0(EnDnp* this, PlayState* play) { if (this->unk_322 & 8) { - func_80B3CDA4(this, globalCtx); + func_80B3CDA4(this, play); this->unk_322 &= ~0x10; this->unk_322 |= 64; } else if (this->unk_322 & 0x40) { @@ -198,15 +198,15 @@ s32 func_80B3CEC0(EnDnp* this, GlobalContext* globalCtx) { return 1; } -s32 func_80B3CF60(EnDnp* this, GlobalContext* globalCtx) { +s32 func_80B3CF60(EnDnp* this, PlayState* play) { s32 ret = false; - if ((this->unk_322 & 7) && Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { + if ((this->unk_322 & 7) && Actor_ProcessTalkRequest(&this->actor, &play->state)) { SubS_UpdateFlags(&this->unk_322, 0, 7); this->unk_322 |= 8; this->actionFunc = func_80B3D3F8; ret = true; - } else if (!(gSaveContext.save.weekEventReg[23] & 0x20) && Actor_HasParent(&this->actor, globalCtx)) { + } else if (!(gSaveContext.save.weekEventReg[23] & 0x20) && Actor_HasParent(&this->actor, play)) { SubS_UpdateFlags(&this->unk_322, 0, 7); this->unk_322 &= ~0x500; this->actor.parent = NULL; @@ -218,10 +218,10 @@ s32 func_80B3CF60(EnDnp* this, GlobalContext* globalCtx) { return ret; } -s32 func_80B3D044(EnDnp* this, GlobalContext* globalCtx) { +s32 func_80B3D044(EnDnp* this, PlayState* play) { s32 ret = false; - if (globalCtx->csCtx.state != 0) { + if (play->csCtx.state != 0) { if (!(this->unk_322 & 0x200)) { this->unk_322 |= (0x200 | 0x10); this->actor.flags &= ~ACTOR_FLAG_1; @@ -240,22 +240,22 @@ s32 func_80B3D044(EnDnp* this, GlobalContext* globalCtx) { return ret; } -void func_80B3D11C(EnDnp* this, GlobalContext* globalCtx) { +void func_80B3D11C(EnDnp* this, PlayState* play) { static s32 D_80B3DE74[] = { 0, 16, 14, 10, 18, 12, 5, 7, 2, 19, 21, 22, 24, 8, }; s32 temp_v0; s32 val; - if (!(gSaveContext.save.weekEventReg[29] & 0x40) && (globalCtx->sceneNum == SCENE_MITURIN) && - (globalCtx->csCtx.currentCsIndex == 0)) { + if (!(gSaveContext.save.weekEventReg[29] & 0x40) && (play->sceneNum == SCENE_MITURIN) && + (play->csCtx.currentCsIndex == 0)) { this->unk_322 |= 0x20; gSaveContext.save.weekEventReg[29] |= 0x40; } - if (Cutscene_CheckActorAction(globalCtx, 101)) { - temp_v0 = Cutscene_GetActorActionIndex(globalCtx, 101); - val = globalCtx->csCtx.actorActions[temp_v0]->action; + if (Cutscene_CheckActorAction(play, 101)) { + temp_v0 = Cutscene_GetActorActionIndex(play, 101); + val = play->csCtx.actorActions[temp_v0]->action; if (this->unk_324 != (u8)val) { func_80B3CC38(this, D_80B3DE74[val]); if (this->unk_340 == 16) { @@ -281,11 +281,11 @@ void func_80B3D11C(EnDnp* this, GlobalContext* globalCtx) { Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) { func_80B3CC38(this, this->unk_340 + 1); } - Cutscene_ActorTranslateAndYaw(&this->actor, globalCtx, temp_v0); + Cutscene_ActorTranslateAndYaw(&this->actor, play, temp_v0); } } -void func_80B3D2D4(EnDnp* this, GlobalContext* globalCtx) { +void func_80B3D2D4(EnDnp* this, PlayState* play) { if (this->unk_322 & 0x20) { Math_ApproachS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer, 0x3, 0x2AA8); } else { @@ -293,24 +293,24 @@ void func_80B3D2D4(EnDnp* this, GlobalContext* globalCtx) { } } -void func_80B3D338(EnDnp* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); +void func_80B3D338(EnDnp* this, PlayState* play) { + Player* player = GET_PLAYER(play); - if ((this->unk_32E != 0) && (Message_GetState(&globalCtx->msgCtx) == 2)) { + if ((this->unk_32E != 0) && (Message_GetState(&play->msgCtx) == TEXT_STATE_CLOSING)) { Actor_MarkForDeath(&this->actor); } else if (this->unk_32E == 0) { - if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { + if (Actor_ProcessTalkRequest(&this->actor, &play->state)) { this->unk_32E = 1; } else { this->actor.textId = 0x971; player->actor.textId = this->actor.textId; - func_800B8500(&this->actor, globalCtx, 9999.9f, 9999.9f, EXCH_ITEM_MINUS1); + func_800B8500(&this->actor, play, 9999.9f, 9999.9f, PLAYER_AP_MINUS1); } } } -void func_80B3D3F8(EnDnp* this, GlobalContext* globalCtx) { - if (func_8010BF58(&this->actor, globalCtx, D_80B3DE58, NULL, &this->unk_328)) { +void func_80B3D3F8(EnDnp* this, PlayState* play) { + if (func_8010BF58(&this->actor, play, D_80B3DE58, NULL, &this->unk_328)) { SubS_UpdateFlags(&this->unk_322, 3, 7); this->unk_322 &= ~8; this->actionFunc = func_80B3D2D4; @@ -319,7 +319,7 @@ void func_80B3D3F8(EnDnp* this, GlobalContext* globalCtx) { } } -void func_80B3D47C(EnDnp* this, GlobalContext* globalCtx) { +void func_80B3D47C(EnDnp* this, PlayState* play) { 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) { @@ -334,7 +334,7 @@ void func_80B3D47C(EnDnp* this, GlobalContext* globalCtx) { Actor_SetScale(&this->actor, this->actor.scale.x); } -void func_80B3D558(EnDnp* this, GlobalContext* globalCtx) { +void func_80B3D558(EnDnp* this, PlayState* play) { if (ActorCutscene_GetCanPlayNext(this->actor.cutscene)) { ActorCutscene_StartAndSetUnkLinkFields(this->actor.cutscene, &this->actor); gSaveContext.save.weekEventReg[23] |= 0x20; @@ -343,15 +343,14 @@ void func_80B3D558(EnDnp* this, GlobalContext* globalCtx) { } } -void EnDnp_Init(Actor* thisx, GlobalContext* globalCtx) { +void EnDnp_Init(Actor* thisx, PlayState* play) { EnDnp* this = THIS; ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 16.0f); - SkelAnime_InitFlex(globalCtx, &this->skelAnime, &object_dnp_Skel_010D60, NULL, this->jointTable, this->morphTable, - 26); + SkelAnime_InitFlex(play, &this->skelAnime, &object_dnp_Skel_010D60, NULL, this->jointTable, this->morphTable, 26); this->unk_340 = -1; func_80B3CC38(this, 15); - Collider_InitAndSetCylinder(globalCtx, &this->collider, &this->actor, &sCylinderInit); + Collider_InitAndSetCylinder(play, &this->collider, &this->actor, &sCylinderInit); CollisionCheck_SetInfo2(&this->actor.colChkInfo, DamageTable_Get(0x16), &sColChkInfoInit); this->unk_322 = 0; this->actor.targetMode = 0; @@ -365,13 +364,13 @@ void EnDnp_Init(Actor* thisx, GlobalContext* globalCtx) { this->actor.world.rot.x = this->actor.shape.rot.x; this->actor.cutscene = 0x10; this->actionFunc = func_80B3D47C; - } else if (((ENDNP_GET_7(&this->actor) == ENDNP_GET_7_0) && !Interface_HasItemInBottle(ITEM_DEKU_PRINCESS) && + } else if (((ENDNP_GET_7(&this->actor) == ENDNP_GET_7_0) && !Inventory_HasItemInBottle(ITEM_DEKU_PRINCESS) && !(gSaveContext.save.weekEventReg[23] & 0x20)) || ((ENDNP_GET_7(&this->actor) == ENDNP_GET_7_2) && (gSaveContext.save.weekEventReg[23] & 0x20))) { Actor_SetScale(&this->actor, 0.0085f); SubS_UpdateFlags(&this->unk_322, 3, 7); this->unk_322 |= 0x400; - if ((globalCtx->sceneNum == SCENE_MITURIN) && (gSaveContext.save.weekEventReg[29] & 0x40)) { + if ((play->sceneNum == SCENE_MITURIN) && (gSaveContext.save.weekEventReg[29] & 0x40)) { this->unk_322 |= 0x20; func_80B3CC38(this, 1); } @@ -381,38 +380,38 @@ void EnDnp_Init(Actor* thisx, GlobalContext* globalCtx) { } } -void EnDnp_Destroy(Actor* thisx, GlobalContext* globalCtx) { +void EnDnp_Destroy(Actor* thisx, PlayState* play) { EnDnp* this = THIS; - Collider_DestroyCylinder(globalCtx, &this->collider); + Collider_DestroyCylinder(play, &this->collider); } -void EnDnp_Update(Actor* thisx, GlobalContext* globalCtx) { +void EnDnp_Update(Actor* thisx, PlayState* play) { EnDnp* this = THIS; s32 pad; f32 sp2C; f32 sp28; - if (!func_80B3CF60(this, globalCtx) && func_80B3D044(this, globalCtx)) { - func_80B3D11C(this, globalCtx); + if (!func_80B3CF60(this, play) && func_80B3D044(this, play)) { + func_80B3D11C(this, play); SkelAnime_Update(&this->skelAnime); func_80B3CD1C(this); - func_80B3CEC0(this, globalCtx); + func_80B3CEC0(this, play); } else { - this->actionFunc(this, globalCtx); + this->actionFunc(this, play); SkelAnime_Update(&this->skelAnime); func_80B3CD1C(this); - func_80B3CEC0(this, globalCtx); + func_80B3CEC0(this, play); Actor_MoveWithGravity(&this->actor); - Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 30.0f, 12.0f, 0.0f, 4); + Actor_UpdateBgCheckInfo(play, &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.save.weekEventReg[23] & 0x20)) { - Actor_PickUp(&this->actor, globalCtx, GI_MAX, sp2C, sp28); + Actor_PickUp(&this->actor, play, GI_MAX, sp2C, sp28); } - func_8013C964(&this->actor, globalCtx, sp2C, sp28, 0, this->unk_322 & 7); + func_8013C964(&this->actor, play, sp2C, sp28, PLAYER_AP_NONE, this->unk_322 & 7); Actor_SetFocus(&this->actor, 30.0f); - func_80B3CC80(this, globalCtx); + func_80B3CC80(this, play); } if (this->unk_322 & 0x100) { @@ -425,9 +424,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) { @@ -446,10 +445,10 @@ s32 func_80B3D974(s16 arg0, s16 arg1, Vec3f* arg2, Vec3s* arg3, s32 arg4, s32 ar return 1; } -void EnDnp_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx) { +void EnDnp_PostLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx) { } -void EnDnp_TransformLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Actor* thisx) { +void EnDnp_TransformLimbDraw(PlayState* play, s32 limbIndex, Actor* thisx) { EnDnp* this = THIS; s32 phi_v1 = 1; s32 phi_v0; @@ -468,17 +467,17 @@ 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(); } } -void EnDnp_Draw(Actor* thisx, GlobalContext* globalCtx) { +void EnDnp_Draw(Actor* thisx, PlayState* play) { static TexturePtr D_80B3DEAC[] = { object_dnp_Tex_0103D0, object_dnp_Tex_0105D0, @@ -488,16 +487,16 @@ void EnDnp_Draw(Actor* thisx, GlobalContext* globalCtx) { EnDnp* this = THIS; if (this->unk_322 & 0x100) { - OPEN_DISPS(globalCtx->state.gfxCtx); + OPEN_DISPS(play->state.gfxCtx); - func_8012C28C(globalCtx->state.gfxCtx); + func_8012C28C(play->state.gfxCtx); gSPSegment(POLY_OPA_DISP++, 0x08, Lib_SegmentedToVirtual(D_80B3DEAC[this->unk_336])); - SkelAnime_DrawTransformFlexOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, + SkelAnime_DrawTransformFlexOpa(play, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, NULL, EnDnp_PostLimbDraw, EnDnp_TransformLimbDraw, &this->actor); - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->state.gfxCtx); } } diff --git a/src/overlays/actors/ovl_En_Dnp/z_en_dnp.h b/src/overlays/actors/ovl_En_Dnp/z_en_dnp.h index 7253f2f3d..e76180afe 100644 --- a/src/overlays/actors/ovl_En_Dnp/z_en_dnp.h +++ b/src/overlays/actors/ovl_En_Dnp/z_en_dnp.h @@ -5,7 +5,7 @@ struct EnDnp; -typedef void (*EnDnpActionFunc)(struct EnDnp*, GlobalContext*); +typedef void (*EnDnpActionFunc)(struct EnDnp*, PlayState*); #define ENDNP_GET_7(thisx) ((thisx)->params & 7) 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 917a2d4d9..6b21d3fc1 100644 --- a/src/overlays/actors/ovl_En_Dnq/z_en_dnq.c +++ b/src/overlays/actors/ovl_En_Dnq/z_en_dnq.c @@ -11,12 +11,12 @@ #define THIS ((EnDnq*)thisx) -void EnDnq_Init(Actor* thisx, GlobalContext* globalCtx); -void EnDnq_Destroy(Actor* thisx, GlobalContext* globalCtx); -void EnDnq_Update(Actor* thisx, GlobalContext* globalCtx); -void EnDnq_Draw(Actor* thisx, GlobalContext* globalCtx); +void EnDnq_Init(Actor* thisx, PlayState* play); +void EnDnq_Destroy(Actor* thisx, PlayState* play); +void EnDnq_Update(Actor* thisx, PlayState* play); +void EnDnq_Draw(Actor* thisx, PlayState* play); -void func_80A52FB8(EnDnq* this, GlobalContext* globalCtx); +void func_80A52FB8(EnDnq* this, PlayState* play); static s32 D_80A53400[] = { 0x00120100, 0x150E0899, 0x0C120F08, 0x9A0C0F08, 0x9B0C0F08, 0x9C0C1112, 0x01100E08, 0x980C1000, 0x00120200, @@ -57,7 +57,7 @@ static ColliderCylinderInit sCylinderInit = { static CollisionCheckInfoInit2 sColChkInfoInit = { 1, 0, 0, 0, MASS_IMMOVABLE }; -static AnimationInfoS D_80A5349C[] = { +static AnimationInfoS sAnimationInfo[] = { { &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 }, @@ -80,8 +80,9 @@ static AnimationInfoS D_80A5349C[] = { { &object_dnq_Anim_003DBC, 1.0f, 0, -1, ANIMMODE_LOOP, -4 }, }; -void func_80A52530(GlobalContext* globalCtx, EnDnq* this) { - func_8013A530(globalCtx, &this->actor, 10, &this->actor.focus.pos, &this->actor.world.rot, 120.0f, 480.0f, 0x38E3); +s32 EnDnq_ValidatePictograph(PlayState* play, Actor* thisx) { + return Snap_ValidatePictograph(play, thisx, PICTOGRAPH_DEKU_KING, &thisx->focus.pos, &thisx->world.rot, 120.0f, + 480.0f, 0x38E3); } s32 func_80A5257C(EnDnq* this, s32 arg1) { @@ -104,23 +105,23 @@ s32 func_80A5257C(EnDnq* this, s32 arg1) { if (phi_v1) { this->unk_398 = arg1; - ret = SubS_ChangeAnimationByInfoS(&this->skelAnime, D_80A5349C, arg1); + ret = SubS_ChangeAnimationByInfoS(&this->skelAnime, sAnimationInfo, arg1); } return ret; } -void func_80A52604(EnDnq* this, GlobalContext* globalCtx) { - Collider_UpdateCylinder(&this->actor, &this->collider); - CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); +void func_80A52604(EnDnq* this, PlayState* play) { + Collider_UpdateCylinder(&this->picto.actor, &this->collider); + CollisionCheck_SetOC(play, &play->colChkCtx, &this->collider.base); } -s32 func_80A52648(EnDnq* this, GlobalContext* globalCtx) { +s32 func_80A52648(EnDnq* this, PlayState* play) { s32 ret = false; - if (globalCtx->csCtx.state != 0) { + if (play->csCtx.state != 0) { if (!(this->unk_37C & 0x20)) { - this->actor.flags &= ~ACTOR_FLAG_1; + this->picto.actor.flags &= ~ACTOR_FLAG_1; this->unk_1DC = 0xFF; this->unk_37C |= 0x20; } @@ -128,7 +129,7 @@ s32 func_80A52648(EnDnq* this, GlobalContext* globalCtx) { ret = true; } else { if (this->unk_37C & 0x20) { - this->actor.flags |= ACTOR_FLAG_1; + this->picto.actor.flags |= ACTOR_FLAG_1; this->unk_1DC = 0xFF; this->unk_37C &= ~0x20; SubS_UpdateFlags(&this->unk_37C, 3, 7); @@ -196,10 +197,10 @@ s32 func_80A52944(EnDnq* this) { if (this->unk_386 == 0) { func_80A5257C(this, 12); this->unk_38C = 1; - this->actor.shape.rot.y = this->actor.world.rot.y; + this->picto.actor.shape.rot.y = this->picto.actor.world.rot.y; this->unk_386 = 1; phi_v1 = this->unk_38C * 0x2000; - this->actor.shape.rot.y += phi_v1; + this->picto.actor.shape.rot.y += phi_v1; } else if (Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) { this->unk_386++; if (this->unk_386 >= 6) { @@ -214,15 +215,15 @@ s32 func_80A52944(EnDnq* this) { func_80A5257C(this, 13); this->skelAnime.curFrame = 0.0f; } - this->actor.shape.rot.y = this->actor.world.rot.y; - this->actor.shape.rot.y += phi_v1; + this->picto.actor.shape.rot.y = this->picto.actor.world.rot.y; + this->picto.actor.shape.rot.y += phi_v1; } this->unk_38A = 0; return 0; } -s32 func_80A52A78(EnDnq* this, GlobalContext* globalCtx) { +s32 func_80A52A78(EnDnq* this, PlayState* play) { static s32 D_80A535DC[] = { 17, 12, 14, 13, 16, }; @@ -230,10 +231,10 @@ s32 func_80A52A78(EnDnq* this, GlobalContext* globalCtx) { if (this->unk_38A == 0) { this->unk_38C = 0; this->unk_38A = 1; - this->unk_388 = globalCtx->state.frames % 5; + this->unk_388 = play->state.frames % 5; } - this->actor.shape.rot.y = this->actor.world.rot.y; + this->picto.actor.shape.rot.y = this->picto.actor.world.rot.y; if (this->unk_38C != 0) { this->unk_38C--; } @@ -252,11 +253,11 @@ s32 func_80A52A78(EnDnq* this, GlobalContext* globalCtx) { return 0; } -s32 func_80A52B68(EnDnq* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); - u16 temp = globalCtx->msgCtx.currentTextId; +s32 func_80A52B68(EnDnq* this, PlayState* play) { + Player* player = GET_PLAYER(play); + u16 temp = play->msgCtx.currentTextId; - if ((player->stateFlags1 & 0x40) && (player->targetActor == &this->actor)) { + if ((player->stateFlags1 & 0x40) && (player->targetActor == &this->picto.actor)) { switch (temp) { case 0x89B: func_80A5257C(this, 18); @@ -292,20 +293,20 @@ s32 func_80A52B68(EnDnq* this, GlobalContext* globalCtx) { return 0; } -void func_80A52C6C(EnDnq* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); +void func_80A52C6C(EnDnq* this, PlayState* play) { + Player* player = GET_PLAYER(play); s32 pad; Vec3f sp34 = { 0.0f, 0.0f, 110.0f }; Vec3f sp28; Vec3f sp1C; Math_Vec3f_Copy(&sp1C, &player->actor.world.pos); - Lib_Vec3f_TranslateAndRotateY(&this->actor.world.pos, this->actor.world.rot.y, &sp34, &sp28); + Lib_Vec3f_TranslateAndRotateY(&this->picto.actor.world.pos, this->picto.actor.world.rot.y, &sp34, &sp28); Math_Vec3f_Copy(&this->unk_370, &sp28); - this->actor.xzDistToPlayer = Math_Vec3f_DistXZ(&sp28, &sp1C); + this->picto.actor.xzDistToPlayer = Math_Vec3f_DistXZ(&sp28, &sp1C); } -s32* func_80A52CF8(EnDnq* this, GlobalContext* globalCtx) { +s32* func_80A52CF8(EnDnq* this, PlayState* play) { if (gSaveContext.save.weekEventReg[23] & 0x20) { return &D_80A53400[14]; } @@ -317,12 +318,12 @@ s32* func_80A52CF8(EnDnq* this, GlobalContext* globalCtx) { return &D_80A53400[0]; } -s32 func_80A52D44(EnDnq* this, GlobalContext* globalCtx) { +s32 func_80A52D44(EnDnq* this, PlayState* play) { s32 ret = false; - if ((this->unk_37C & 7) && Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { + if ((this->unk_37C & 7) && Actor_ProcessTalkRequest(&this->picto.actor, &play->state)) { SubS_UpdateFlags(&this->unk_37C, 0, 7); - this->unk_380 = func_80A52CF8(this, globalCtx); + this->unk_380 = func_80A52CF8(this, play); this->actionFunc = func_80A52FB8; ret = true; } @@ -330,9 +331,9 @@ s32 func_80A52D44(EnDnq* this, GlobalContext* globalCtx) { return ret; } -void func_80A52DC8(EnDnq* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); - s16 yaw = this->actor.yawTowardsPlayer - this->actor.world.rot.y; +void func_80A52DC8(EnDnq* this, PlayState* play) { + Player* player = GET_PLAYER(play); + s16 yaw = this->picto.actor.yawTowardsPlayer - this->picto.actor.world.rot.y; if (yaw <= 0x3800) { SubS_UpdateFlags(&this->unk_37C, 3, 7); @@ -342,65 +343,65 @@ void func_80A52DC8(EnDnq* this, GlobalContext* globalCtx) { if (!(gSaveContext.save.weekEventReg[23] & 0x20)) { this->unk_390 = 70.0f; - if (Interface_HasItemInBottle(ITEM_DEKU_PRINCESS) && !Play_InCsMode(globalCtx) && - (Message_GetState(&globalCtx->msgCtx) == 0) && (ActorCutscene_GetCurrentIndex() == -1)) { + if (Inventory_HasItemInBottle(ITEM_DEKU_PRINCESS) && !Play_InCsMode(play) && + (Message_GetState(&play->msgCtx) == TEXT_STATE_NONE) && (ActorCutscene_GetCurrentIndex() == -1)) { if ((DECR(this->unk_384) == 0) && (gSaveContext.save.weekEventReg[29] & 0x40)) { - Message_StartTextbox(globalCtx, 0x969, NULL); + Message_StartTextbox(play, 0x969, NULL); this->unk_384 = 200; } } - this->unk_394 = this->actor.xzDistToPlayer; - func_80A52C6C(this, globalCtx); - if (this->actor.xzDistToPlayer < this->unk_390) { + this->unk_394 = this->picto.actor.xzDistToPlayer; + func_80A52C6C(this, play); + if (this->picto.actor.xzDistToPlayer < this->unk_390) { player->unk_B2B = 0x1A; } - this->actor.xzDistToPlayer = this->unk_394; + this->picto.actor.xzDistToPlayer = this->unk_394; if (gSaveContext.save.weekEventReg[83] & 8) { - func_80A52A78(this, globalCtx); + func_80A52A78(this, play); } else if (this->unk_3A4 == 0) { - Math_ApproachS(&this->actor.shape.rot.y, this->actor.world.rot.y, 3, 0x2AA8); + Math_ApproachS(&this->picto.actor.shape.rot.y, this->picto.actor.world.rot.y, 3, 0x2AA8); func_80A526F8(this); } else { func_80A52944(this); } } else { - Math_ApproachS(&this->actor.shape.rot.y, this->actor.world.rot.y, 3, 0x2AA8); + Math_ApproachS(&this->picto.actor.shape.rot.y, this->picto.actor.world.rot.y, 3, 0x2AA8); this->unk_390 = 70.0f; } } -void func_80A52FB8(EnDnq* this, GlobalContext* globalCtx) { - s16 sp2E = this->actor.yawTowardsPlayer; +void func_80A52FB8(EnDnq* this, PlayState* play) { + s16 sp2E = this->picto.actor.yawTowardsPlayer; - if (func_8010BF58(&this->actor, globalCtx, this->unk_380, NULL, &this->unk_1E0)) { + if (func_8010BF58(&this->picto.actor, play, this->unk_380, NULL, &this->unk_1E0)) { SubS_UpdateFlags(&this->unk_37C, 3, 7); this->unk_386 = 0; this->actionFunc = func_80A52DC8; } else { - Math_ApproachS(&this->actor.shape.rot.y, sp2E, 3, 0x2AA8); + Math_ApproachS(&this->picto.actor.shape.rot.y, sp2E, 3, 0x2AA8); } } -void func_80A53038(EnDnq* this, GlobalContext* globalCtx) { +void func_80A53038(EnDnq* this, PlayState* play) { static s32 D_80A535FC[] = { 0, 1, 2, 3, 5, 6, }; s32 temp_v0; u32 temp_v1; - if (Cutscene_CheckActorAction(globalCtx, 105)) { - temp_v0 = Cutscene_GetActorActionIndex(globalCtx, 105); - temp_v1 = globalCtx->csCtx.actorActions[temp_v0]->action; + if (Cutscene_CheckActorAction(play, 105)) { + temp_v0 = Cutscene_GetActorActionIndex(play, 105); + temp_v1 = play->csCtx.actorActions[temp_v0]->action; if (this->unk_1DC != (u8)temp_v1) { func_80A5257C(this, D_80A535FC[temp_v1]); this->unk_1DC = temp_v1; } if ((this->unk_398 == 4) && Animation_OnFrame(&this->skelAnime, 2.0f)) { - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_KINGNUTS_DAMAGE); + Actor_PlaySfxAtPos(&this->picto.actor, NA_SE_EN_KINGNUTS_DAMAGE); } if (((this->unk_398 == 3) || (this->unk_398 == 6)) && @@ -408,22 +409,21 @@ void func_80A53038(EnDnq* this, GlobalContext* globalCtx) { func_80A5257C(this, this->unk_398 + 1); } - Cutscene_ActorTranslateAndYaw(&this->actor, globalCtx, temp_v0); + Cutscene_ActorTranslateAndYaw(&this->picto.actor, play, temp_v0); } } -void EnDnq_Init(Actor* thisx, GlobalContext* globalCtx) { +void EnDnq_Init(Actor* thisx, PlayState* play) { EnDnq* this = THIS; - ActorShape_Init(&this->actor.shape, 0.0f, NULL, 14.0f); - SkelAnime_InitFlex(globalCtx, &this->skelAnime, &object_dnq_Skel_00EB48, NULL, this->jointTable, this->morphTable, - 33); + ActorShape_Init(&this->picto.actor.shape, 0.0f, NULL, 14.0f); + SkelAnime_InitFlex(play, &this->skelAnime, &object_dnq_Skel_00EB48, NULL, this->jointTable, this->morphTable, 33); this->unk_398 = -1; func_80A5257C(this, 0); - Collider_InitAndSetCylinder(globalCtx, &this->collider, &this->actor, &sCylinderInit); - CollisionCheck_SetInfo2(&this->actor.colChkInfo, DamageTable_Get(0x16), &sColChkInfoInit); - Actor_SetScale(&this->actor, 0.02f); - this->actor.targetMode = 1; + Collider_InitAndSetCylinder(play, &this->collider, &this->picto.actor, &sCylinderInit); + CollisionCheck_SetInfo2(&this->picto.actor.colChkInfo, DamageTable_Get(0x16), &sColChkInfoInit); + Actor_SetScale(&this->picto.actor, 0.02f); + this->picto.actor.targetMode = 1; this->unk_386 = 0; this->unk_37C = 0; SubS_UpdateFlags(&this->unk_37C, 3, 7); @@ -432,41 +432,41 @@ void EnDnq_Init(Actor* thisx, GlobalContext* globalCtx) { } else { this->unk_3A4 = 0; } - this->unk_144 = func_80A52530; + this->picto.validationFunc = EnDnq_ValidatePictograph; this->actionFunc = func_80A52DC8; } -void EnDnq_Destroy(Actor* thisx, GlobalContext* globalCtx) { +void EnDnq_Destroy(Actor* thisx, PlayState* play) { EnDnq* this = THIS; - Collider_DestroyCylinder(globalCtx, &this->collider); + Collider_DestroyCylinder(play, &this->collider); } -void EnDnq_Update(Actor* thisx, GlobalContext* globalCtx) { +void EnDnq_Update(Actor* thisx, PlayState* play) { EnDnq* this = THIS; - if (!func_80A52D44(this, globalCtx) && func_80A52648(this, globalCtx)) { - func_80A53038(this, globalCtx); + if (!func_80A52D44(this, play) && func_80A52648(this, play)) { + func_80A53038(this, play); SkelAnime_Update(&this->skelAnime); } else { - this->actionFunc(this, globalCtx); - func_80A52B68(this, globalCtx); + this->actionFunc(this, play); + func_80A52B68(this, play); SkelAnime_Update(&this->skelAnime); - 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, - this->unk_37C & 7); - this->actor.xzDistToPlayer = this->unk_394; - Actor_SetFocus(&this->actor, 46.0f); - func_80A52604(this, globalCtx); + Actor_UpdateBgCheckInfo(play, &this->picto.actor, 30.0f, 12.0f, 0.0f, 4); + this->unk_394 = this->picto.actor.xzDistToPlayer; + func_80A52C6C(this, play); + func_8013C964(&this->picto.actor, play, this->unk_390, fabsf(this->picto.actor.playerHeightRel) + 1.0f, + PLAYER_AP_NONE, this->unk_37C & 7); + this->picto.actor.xzDistToPlayer = this->unk_394; + Actor_SetFocus(&this->picto.actor, 46.0f); + func_80A52604(this, play); } } -void EnDnq_Draw(Actor* thisx, GlobalContext* globalCtx) { +void EnDnq_Draw(Actor* thisx, PlayState* play) { EnDnq* this = THIS; - func_8012C28C(globalCtx->state.gfxCtx); - SkelAnime_DrawFlexOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, - NULL, NULL, &this->actor); + func_8012C28C(play->state.gfxCtx); + SkelAnime_DrawFlexOpa(play, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, NULL, + NULL, &this->picto.actor); } diff --git a/src/overlays/actors/ovl_En_Dnq/z_en_dnq.h b/src/overlays/actors/ovl_En_Dnq/z_en_dnq.h index 4cc82d131..9e4bbd52a 100644 --- a/src/overlays/actors/ovl_En_Dnq/z_en_dnq.h +++ b/src/overlays/actors/ovl_En_Dnq/z_en_dnq.h @@ -2,15 +2,14 @@ #define Z_EN_DNQ_H #include "global.h" +#include "z64snap.h" struct EnDnq; -typedef void (*EnDnqActionFunc)(struct EnDnq*, GlobalContext*); -typedef void (*EnDnqFunc)(GlobalContext*, struct EnDnq*); +typedef void (*EnDnqActionFunc)(struct EnDnq*, PlayState*); typedef struct EnDnq { - /* 0x000 */ Actor actor; - /* 0x144 */ EnDnqFunc unk_144; + /* 0x000 */ PictoActor picto; /* 0x148 */ SkelAnime skelAnime; /* 0x18C */ EnDnqActionFunc actionFunc; /* 0x190 */ ColliderCylinder collider; 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 e2c07cce7..f8588614f 100644 --- a/src/overlays/actors/ovl_En_Dns/z_en_dns.c +++ b/src/overlays/actors/ovl_En_Dns/z_en_dns.c @@ -10,28 +10,28 @@ #define THIS ((EnDns*)thisx) -void EnDns_Init(Actor* thisx, GlobalContext* globalCtx); -void EnDns_Destroy(Actor* thisx, GlobalContext* globalCtx); -void EnDns_Update(Actor* thisx, GlobalContext* globalCtx); -void EnDns_Draw(Actor* thisx, GlobalContext* globalCtx); +void EnDns_Init(Actor* thisx, PlayState* play); +void EnDns_Destroy(Actor* thisx, PlayState* play); +void EnDns_Update(Actor* thisx, PlayState* play); +void EnDns_Draw(Actor* thisx, PlayState* play); -void func_8092D330(EnDns* this, GlobalContext* globalCtx); -void EnDns_DoNothing(EnDns* this, GlobalContext* globalCtx); -void func_8092D4D8(EnDns* this, GlobalContext* globalCtx); +void func_8092D330(EnDns* this, PlayState* play); +void EnDns_DoNothing(EnDns* this, PlayState* play); +void func_8092D4D8(EnDns* this, PlayState* play); 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; + /* 0 */ EN_DNS_ANIM_IDLE_1, + /* 1 */ EN_DNS_ANIM_IDLE_2, + /* 2 */ EN_DNS_ANIM_WALK_1, + /* 3 */ EN_DNS_ANIM_WALK_2, + /* 4 */ EN_DNS_ANIM_SURPRISE_START, + /* 5 */ EN_DNS_ANIM_SURPRISE_LOOP, + /* 6 */ EN_DNS_ANIM_RUN_START, + /* 7 */ EN_DNS_ANIM_RUN_LOOP, + /* 8 */ EN_DNS_ANIM_DANCE, + /* 9 */ EN_DNS_ANIM_FLIP, + /* 10 */ EN_DNS_ANIM_MAX, +} EnDnsAnimation; static s32 D_8092DCB0[] = { 0x00172000, 0x050E082F, 0x0C100E08, 0x200C1000, 0x00172000, 0x050E0830, 0x0C100E08, 0x210C1000, @@ -73,7 +73,7 @@ static ColliderCylinderInit sCylinderInit = { static CollisionCheckInfoInit2 sColChkInfoInit = { 1, 0, 0, 0, MASS_IMMOVABLE }; -static AnimationInfoS sAnimations[] = { +static AnimationInfoS sAnimationInfo[] = { { &gKingsChamberDekuGuardIdleAnim, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, { &gKingsChamberDekuGuardIdleAnim, 1.0f, 0, -1, ANIMMODE_LOOP, -4 }, { &gKingsChamberDekuGuardWalkAnim, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, @@ -89,8 +89,8 @@ static AnimationInfoS sAnimations[] = { void func_8092C5C0(EnDns* this) { s32 pad; - 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)) && + if (((this->animIndex == EN_DNS_ANIM_WALK_1) || (this->animIndex == EN_DNS_ANIM_WALK_2) || + (this->animIndex == EN_DNS_ANIM_RUN_START) || (this->animIndex == EN_DNS_ANIM_RUN_LOOP)) && (Animation_OnFrame(&this->skelAnime, 0.0f) || Animation_OnFrame(&this->skelAnime, 3.0f))) { Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_NUTS_WALK); } @@ -101,43 +101,41 @@ s32 func_8092C63C(EnDns* this, s32 arg1) { s32 ret = false; switch (arg1) { - 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)) { + case EN_DNS_ANIM_IDLE_1: + case EN_DNS_ANIM_IDLE_2: + if ((this->animIndex != EN_DNS_ANIM_IDLE_1) && (this->animIndex != EN_DNS_ANIM_IDLE_2)) { phi_v1 = true; } break; - 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)) { + case EN_DNS_ANIM_WALK_1: + case EN_DNS_ANIM_WALK_2: + if ((this->animIndex != EN_DNS_ANIM_WALK_1) && (this->animIndex != EN_DNS_ANIM_WALK_2)) { phi_v1 = true; } break; default: - if (this->animationIndex != arg1) { + if (this->animIndex != arg1) { phi_v1 = true; } } if (phi_v1) { - this->animationIndex = arg1; - ret = SubS_ChangeAnimationByInfoS(&this->skelAnime, sAnimations, arg1); + this->animIndex = arg1; + ret = SubS_ChangeAnimationByInfoS(&this->skelAnime, sAnimationInfo, arg1); } return ret; } -void func_8092C6FC(EnDns* this, GlobalContext* globalCtx) { +void func_8092C6FC(EnDns* this, PlayState* play) { Collider_UpdateCylinder(&this->actor, &this->collider); - CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + CollisionCheck_SetOC(play, &play->colChkCtx, &this->collider.base); } -void func_8092C740(EnDns* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); +void func_8092C740(EnDns* this, PlayState* play) { + Player* player = GET_PLAYER(play); s16 temp = this->actor.yawTowardsPlayer - this->actor.shape.rot.y; Vec3f sp34; Vec3f sp28; @@ -154,9 +152,9 @@ void func_8092C740(EnDns* this, GlobalContext* globalCtx) { this->unk_2CC = CLAMP(this->unk_2CC, -0x16C0, 0xE38); } -void func_8092C86C(EnDns* this, GlobalContext* globalCtx) { +void func_8092C86C(EnDns* this, PlayState* play) { if ((this->unk_2C6 & 8) && (DECR(this->unk_2DC) == 0)) { - func_8092C740(this, globalCtx); + func_8092C740(this, play); this->unk_2C6 &= ~0x10; this->unk_2C6 |= 0x20; } else if (this->unk_2C6 & 0x20) { @@ -179,8 +177,8 @@ void func_8092C934(EnDns* this) { } } -s32* func_8092C9BC(EnDns* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); +s32* func_8092C9BC(EnDns* this, PlayState* play) { + Player* player = GET_PLAYER(play); if (!(gSaveContext.save.weekEventReg[23] & 0x20)) { if (player->transformation != PLAYER_FORM_DEKU) { @@ -225,22 +223,22 @@ s32 func_8092CA74(EnDns* this) { return 0; } -s32 func_8092CAD0(EnDns* this, GlobalContext* globalCtx) { +s32 func_8092CAD0(EnDns* this, PlayState* play) { s32 ret = false; if (this->unk_2C6 & 7) { - if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { + if (Actor_ProcessTalkRequest(&this->actor, &play->state)) { 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, EN_DNS_ANIMATION_WALK_1); + func_8092C63C(this, EN_DNS_ANIM_WALK_1); } this->unk_2DA = this->actor.world.rot.y; } - this->unk_1E0 = func_8092C9BC(this, globalCtx); + this->unk_1E0 = func_8092C9BC(this, play); this->actionFunc = func_8092D4D8; ret = true; } @@ -248,10 +246,10 @@ s32 func_8092CAD0(EnDns* this, GlobalContext* globalCtx) { return ret; } -s32 func_8092CB98(EnDns* this, GlobalContext* globalCtx) { +s32 func_8092CB98(EnDns* this, PlayState* play) { s32 phi_v1 = 0; - if (globalCtx->csCtx.state != 0) { + if (play->csCtx.state != 0) { if (!(this->unk_2C6 & 0x80)) { this->unk_2C8 = func_8092CA74(this); this->actor.flags &= ~ACTOR_FLAG_1; @@ -268,15 +266,15 @@ s32 func_8092CB98(EnDns* this, GlobalContext* globalCtx) { return phi_v1; } -s32 func_8092CC68(GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); +s32 func_8092CC68(PlayState* play) { + Player* player = GET_PLAYER(play); s32 pad[2]; s32 ret = false; s16 bgId; - if (!Play_InCsMode(globalCtx) && (player->actor.bgCheckFlags & 1) && (player->transformation != PLAYER_FORM_DEKU)) { + if (!Play_InCsMode(play) && (player->actor.bgCheckFlags & 1) && (player->transformation != PLAYER_FORM_DEKU)) { bgId = player->actor.floorBgId; - if (SurfaceType_GetSceneExitIndex(&globalCtx->colCtx, player->actor.floorPoly, bgId) != 4) { + if (SurfaceType_GetSceneExitIndex(&play->colCtx, player->actor.floorPoly, bgId) != 4) { ret = true; } } @@ -284,8 +282,8 @@ s32 func_8092CC68(GlobalContext* globalCtx) { return ret; } -s32 func_8092CCEC(EnDns* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); +s32 func_8092CCEC(EnDns* this, PlayState* play) { + Player* player = GET_PLAYER(play); s32 pad; Vec3f sp3C = player->actor.world.pos; Vec3f sp30 = this->actor.world.pos; @@ -306,7 +304,7 @@ s32 func_8092CCEC(EnDns* this, GlobalContext* globalCtx) { } s32 func_8092CE38(EnDns* this) { - static s32 D_8092DE00[] = { EN_DNS_ANIMATION_DANCE, EN_DNS_ANIMATION_DANCE, EN_DNS_ANIMATION_FLIP }; + static s32 D_8092DE00[] = { EN_DNS_ANIM_DANCE, EN_DNS_ANIM_DANCE, EN_DNS_ANIM_FLIP }; s16 frame; s32 pad; Vec3f sp2C; @@ -375,23 +373,23 @@ s32 func_8092D068(EnDns* this) { return ret; } -void func_8092D108(EnDns* this, GlobalContext* globalCtx) { - OPEN_DISPS(globalCtx->state.gfxCtx); +void func_8092D108(EnDns* this, PlayState* play) { + OPEN_DISPS(play->state.gfxCtx); - func_8012C28C(globalCtx->state.gfxCtx); + func_8012C28C(play->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); + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_OPA_DISP++, gKingsChamberDekuGuardDekuFlower); - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->state.gfxCtx); } -void func_8092D1B8(EnDns* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); +void func_8092D1B8(EnDns* this, PlayState* play) { + Player* player = GET_PLAYER(play); s16 sp22 = this->actor.world.rot.y; if (ENDNS_GET_4000(&this->actor)) { @@ -399,29 +397,28 @@ void func_8092D1B8(EnDns* this, GlobalContext* globalCtx) { } if (!ENDNS_GET_4000(&this->actor) || (this->unk_2D2 != 0)) { - if (!(gSaveContext.save.weekEventReg[23] & 0x20) && !(gSaveContext.eventInf[1] & 0x20) && - func_8092CC68(globalCtx)) { + if (!(gSaveContext.save.weekEventReg[23] & 0x20) && !(gSaveContext.eventInf[1] & 0x20) && func_8092CC68(play)) { player->stateFlags1 |= 0x20; this->unk_2C6 |= 0x100; 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, EN_DNS_ANIMATION_WALK_1); + func_8092C63C(this, EN_DNS_ANIM_WALK_1); this->actionFunc = EnDns_DoNothing; } else if (gSaveContext.eventInf[1] & 0x40) { - func_8092CCEC(this, globalCtx); - func_8092C63C(this, EN_DNS_ANIMATION_WALK_1); + func_8092CCEC(this, play); + func_8092C63C(this, EN_DNS_ANIM_WALK_1); this->actionFunc = func_8092D330; } Math_ApproachS(&this->actor.shape.rot.y, sp22, 3, 0x2AA8); } } -void EnDns_DoNothing(EnDns* this, GlobalContext* globalCtx) { +void EnDns_DoNothing(EnDns* this, PlayState* play) { } -void func_8092D330(EnDns* this, GlobalContext* globalCtx) { +void func_8092D330(EnDns* this, PlayState* play) { s32 pad; Vec3f sp30 = gZeroVec3f; s16 temp = this->unk_2D6 - this->unk_2D4; @@ -440,29 +437,29 @@ void func_8092D330(EnDns* this, GlobalContext* globalCtx) { } if ((this->unk_2C6 & 0x100) && (DECR(this->unk_2D0) == 0)) { this->unk_2C6 &= ~0x100; - globalCtx->nextEntranceIndex = 0x5010; + play->nextEntrance = ENTRANCE(DEKU_PALACE, 1); gSaveContext.nextCutsceneIndex = 0; - globalCtx->sceneLoadFlag = 0x14; - globalCtx->unk_1887F = 3; - gSaveContext.nextTransition = 3; + play->transitionTrigger = TRANS_TRIGGER_START; + play->transitionType = TRANS_TYPE_03; + gSaveContext.nextTransitionType = TRANS_TYPE_03; } } -void func_8092D4D8(EnDns* this, GlobalContext* globalCtx) { +void func_8092D4D8(EnDns* this, PlayState* play) { s16 sp2E = this->actor.yawTowardsPlayer; if (ENDNS_GET_4000(&this->actor) && (this->unk_2D2 == 0)) { if (func_8092CE38(this)) { - func_8092C63C(this, EN_DNS_ANIMATION_WALK_1); + func_8092C63C(this, EN_DNS_ANIM_WALK_1); } - } else if (func_8010BF58(&this->actor, globalCtx, this->unk_1E0, this->unk_2F4, &this->unk_1DC)) { + } else if (func_8010BF58(&this->actor, play, this->unk_1E0, this->unk_2F4, &this->unk_1DC)) { 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, EN_DNS_ANIMATION_DANCE); + func_8092C63C(this, EN_DNS_ANIM_DANCE); } this->unk_2CC = 0; this->unk_2CE = 0; @@ -474,35 +471,34 @@ void func_8092D4D8(EnDns* this, GlobalContext* globalCtx) { } } -void func_8092D5E8(EnDns* this, GlobalContext* globalCtx) { +void func_8092D5E8(EnDns* this, PlayState* play) { static s32 D_8092DE0C[] = { - EN_DNS_ANIMATION_IDLE_1, - EN_DNS_ANIMATION_IDLE_1, - EN_DNS_ANIMATION_SURPRISE_START, - EN_DNS_ANIMATION_RUN_START, + EN_DNS_ANIM_IDLE_1, + EN_DNS_ANIM_IDLE_1, + EN_DNS_ANIM_SURPRISE_START, + EN_DNS_ANIM_RUN_START, }; s32 temp_v0; u32 temp_v1; - if (Cutscene_CheckActorAction(globalCtx, this->unk_2C8)) { - temp_v0 = Cutscene_GetActorActionIndex(globalCtx, this->unk_2C8); - temp_v1 = globalCtx->csCtx.actorActions[temp_v0]->action; + if (Cutscene_CheckActorAction(play, this->unk_2C8)) { + temp_v0 = Cutscene_GetActorActionIndex(play, this->unk_2C8); + temp_v1 = play->csCtx.actorActions[temp_v0]->action; if (this->unk_1D8 != (u8)temp_v1) { func_8092C63C(this, D_8092DE0C[temp_v1]); this->unk_1D8 = temp_v1; } - if (((this->animationIndex == EN_DNS_ANIMATION_SURPRISE_START) || - (this->animationIndex == EN_DNS_ANIMATION_RUN_START)) && + if (((this->animIndex == EN_DNS_ANIM_SURPRISE_START) || (this->animIndex == EN_DNS_ANIM_RUN_START)) && Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) { - func_8092C63C(this, this->animationIndex + 1); + func_8092C63C(this, this->animIndex + 1); } - Cutscene_ActorTranslateAndYaw(&this->actor, globalCtx, temp_v0); + Cutscene_ActorTranslateAndYaw(&this->actor, play, temp_v0); } } -void EnDns_Init(Actor* thisx, GlobalContext* globalCtx) { +void EnDns_Init(Actor* thisx, PlayState* play) { EnDns* this = THIS; if (!func_8092D068(this)) { @@ -511,11 +507,11 @@ void EnDns_Init(Actor* thisx, GlobalContext* globalCtx) { } ActorShape_Init(&this->actor.shape, 0.0f, NULL, 18.0f); - SkelAnime_Init(globalCtx, &this->skelAnime, &gKingsChamberDekuGuardSkel, NULL, this->jointTable, this->morphTable, + SkelAnime_Init(play, &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); + this->animIndex = -1; + func_8092C63C(this, EN_DNS_ANIM_WALK_1); + Collider_InitAndSetCylinder(play, &this->collider, &this->actor, &sCylinderInit); CollisionCheck_SetInfo2(&this->actor.colChkInfo, DamageTable_Get(0x16), &sColChkInfoInit); Actor_SetScale(&this->actor, 0.01f); this->actor.targetMode = 0; @@ -535,28 +531,28 @@ void EnDns_Init(Actor* thisx, GlobalContext* globalCtx) { gSaveContext.eventInf[1] &= (u8)~0x40; } -void EnDns_Destroy(Actor* thisx, GlobalContext* globalCtx) { +void EnDns_Destroy(Actor* thisx, PlayState* play) { EnDns* this = THIS; - Collider_DestroyCylinder(globalCtx, &this->collider); + Collider_DestroyCylinder(play, &this->collider); } -void EnDns_Update(Actor* thisx, GlobalContext* globalCtx) { +void EnDns_Update(Actor* thisx, PlayState* play) { EnDns* this = THIS; - if (!func_8092CAD0(this, globalCtx) && func_8092CB98(this, globalCtx)) { - func_8092D5E8(this, globalCtx); + if (!func_8092CAD0(this, play) && func_8092CB98(this, play)) { + func_8092D5E8(this, play); SkelAnime_Update(&this->skelAnime); func_8092C5C0(this); } else { - this->actionFunc(this, globalCtx); + this->actionFunc(this, play); SkelAnime_Update(&this->skelAnime); 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_8092C86C(this, play); + Actor_UpdateBgCheckInfo(play, &this->actor, 30.0f, 12.0f, 0.0f, 4); + func_8013C964(&this->actor, play, 80.0f, 40.0f, PLAYER_AP_NONE, this->unk_2C6 & 7); Actor_SetFocus(&this->actor, 34.0f); - func_8092C6FC(this, globalCtx); + func_8092C6FC(this, play); func_8092C5C0(this); } } @@ -566,9 +562,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) { @@ -588,7 +584,7 @@ s32 func_8092D954(s16 arg0, s16 arg1, Vec3f* arg2, Vec3s* arg3, s32 arg4, s32 ar return 1; } -s32 EnDns_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, Actor* thisx) { +s32 EnDns_OverrideLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, Actor* thisx) { EnDns* this = THIS; this->unk_1E4[limbIndex] = *dList; @@ -596,7 +592,7 @@ s32 EnDns_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, return false; } -void EnDns_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx) { +void EnDns_PostLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx) { EnDns* this = THIS; s32 pad; s32 phi_v1; @@ -617,22 +613,22 @@ void EnDns_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Ve 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); + OPEN_DISPS(play->state.gfxCtx); - gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_OPA_DISP++, this->unk_1E4[limbIndex]); - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->state.gfxCtx); } -void EnDns_Draw(Actor* thisx, GlobalContext* globalCtx) { +void EnDns_Draw(Actor* thisx, PlayState* play) { static TexturePtr sEyeTextures[] = { gKingsChamberDekuGuardEyeOpenTex, gKingsChamberDekuGuardEyeHalfTex, @@ -641,16 +637,16 @@ void EnDns_Draw(Actor* thisx, GlobalContext* globalCtx) { }; EnDns* this = THIS; - OPEN_DISPS(globalCtx->state.gfxCtx); + OPEN_DISPS(play->state.gfxCtx); - func_8012C28C(globalCtx->state.gfxCtx); + func_8012C28C(play->state.gfxCtx); 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, + SkelAnime_DrawOpa(play, this->skelAnime.skeleton, this->skelAnime.jointTable, EnDns_OverrideLimbDraw, EnDns_PostLimbDraw, &this->actor); - func_8092D108(this, globalCtx); + func_8092D108(this, play); - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->state.gfxCtx); } 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 257717502..3a382c192 100644 --- a/src/overlays/actors/ovl_En_Dns/z_en_dns.h +++ b/src/overlays/actors/ovl_En_Dns/z_en_dns.h @@ -6,8 +6,8 @@ struct EnDns; -typedef void (*EnDnsActionFunc)(struct EnDns*, GlobalContext*); -typedef s32 (*EnDnsFunc)(struct EnDns*, GlobalContext*); +typedef void (*EnDnsActionFunc)(struct EnDns*, PlayState*); +typedef s32 (*EnDnsFunc)(struct EnDns*, PlayState*); #define ENDNS_GET_7(thisx) ((thisx)->params & 7) #define ENDNS_GET_4000(thisx) ((thisx)->params & 0x4000) @@ -53,7 +53,7 @@ typedef struct EnDns { /* 0x2EC */ f32 unk_2EC; /* 0x2F0 */ f32 unk_2F0; /* 0x2F4 */ EnDnsFunc unk_2F4; - /* 0x2F8 */ s32 animationIndex; + /* 0x2F8 */ s32 animIndex; /* 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 20a44c01d..45311b83f 100644 --- a/src/overlays/actors/ovl_En_Dodongo/z_en_dodongo.c +++ b/src/overlays/actors/ovl_En_Dodongo/z_en_dodongo.c @@ -13,27 +13,27 @@ #define THIS ((EnDodongo*)thisx) -void EnDodongo_Init(Actor* thisx, GlobalContext* globalCtx); -void EnDodongo_Destroy(Actor* thisx, GlobalContext* globalCtx); -void EnDodongo_Update(Actor* thisx, GlobalContext* globalCtx); -void EnDodongo_Draw(Actor* thisx, GlobalContext* globalCtx); +void EnDodongo_Init(Actor* thisx, PlayState* play); +void EnDodongo_Destroy(Actor* thisx, PlayState* play); +void EnDodongo_Update(Actor* thisx, PlayState* play); +void EnDodongo_Draw(Actor* thisx, PlayState* play); void func_808773C4(EnDodongo* this); -void func_80877424(EnDodongo* this, GlobalContext* globalCtx); +void func_80877424(EnDodongo* this, PlayState* play); void func_80877494(EnDodongo* this); -void func_80877500(EnDodongo* this, GlobalContext* globalCtx); +void func_80877500(EnDodongo* this, PlayState* play); void func_808777A8(EnDodongo* this); -void func_8087784C(EnDodongo* this, GlobalContext* globalCtx); +void func_8087784C(EnDodongo* this, PlayState* play); void func_80877D50(EnDodongo* this); -void func_80877D90(EnDodongo* this, GlobalContext* globalCtx); -void func_80877E60(EnDodongo* this, GlobalContext* globalCtx); +void func_80877D90(EnDodongo* this, PlayState* play); +void func_80877E60(EnDodongo* this, PlayState* play); void func_80878354(EnDodongo* this); -void func_80878424(EnDodongo* this, GlobalContext* globalCtx); -void func_808785B0(EnDodongo* this, GlobalContext* globalCtx); +void func_80878424(EnDodongo* this, PlayState* play); +void func_808785B0(EnDodongo* this, PlayState* play); void func_8087864C(EnDodongo* this); -void func_808786C8(EnDodongo* this, GlobalContext* globalCtx); +void func_808786C8(EnDodongo* this, PlayState* play); void func_80878724(EnDodongo* this); -void func_808787B0(EnDodongo* this, GlobalContext* globalCtx); +void func_808787B0(EnDodongo* this, PlayState* play); const ActorInit En_Dodongo_InitVars = { ACTOR_EN_DODONGO, @@ -169,7 +169,7 @@ static ColliderJntSphInit sJntSphInit1 = { OC2_TYPE_1, COLSHAPE_JNTSPH, }, - 10, + ARRAY_COUNT(sJntSphElementsInit1), sJntSphElementsInit1, }; @@ -231,7 +231,7 @@ static ColliderJntSphInit sJntSphInit3 = { OC2_NONE, COLSHAPE_JNTSPH, }, - 3, + ARRAY_COUNT(sJntSphElementsInit2), sJntSphElementsInit2, }; @@ -278,7 +278,7 @@ static InitChainEntry sInitChain[] = { ICHAIN_F32(targetArrowOffset, 1400, ICHAIN_STOP), }; -void EnDodongo_Init(Actor* thisx, GlobalContext* globalCtx) { +void EnDodongo_Init(Actor* thisx, PlayState* play) { static EffectBlureInit2 D_80879308 = { 2, 8, 0, { 255, 255, 255, 255 }, { 255, 255, 255, 64 }, { 255, 255, 255, 0 }, { 255, 255, 255, 0 }, 8, 0, 0, 0, { 0, 0, 0, 0 }, { 0, 0, 0, 0 }, @@ -293,21 +293,21 @@ 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); + SkelAnime_Init(play, &this->skelAnime, &object_dodongo_Skel_008318, &object_dodongo_Anim_004C20, this->jointTable, + this->morphTable, 31); CollisionCheck_SetInfo(&this->actor.colChkInfo, &sDamageTable, &sColChkInfoInit); - Collider_InitAndSetJntSph(globalCtx, &this->collider2, &this->actor, &sJntSphInit2, this->collider2Elements); - Collider_InitAndSetJntSph(globalCtx, &this->collider1, &this->actor, &sJntSphInit1, this->collider1Elements); - Collider_InitAndSetJntSph(globalCtx, &this->collider3, &this->actor, &sJntSphInit3, this->collider3Elements); + Collider_InitAndSetJntSph(play, &this->collider2, &this->actor, &sJntSphInit2, this->collider2Elements); + Collider_InitAndSetJntSph(play, &this->collider1, &this->actor, &sJntSphInit1, this->collider1Elements); + Collider_InitAndSetJntSph(play, &this->collider3, &this->actor, &sJntSphInit3, this->collider3Elements); for (i = 0; i < ARRAY_COUNT(this->collider2Elements); i++) { this->collider2.elements[i].info.elemType = ELEMTYPE_UNK2; this->collider2.elements[i].info.bumper.dmgFlags = 0x77C34FE6; } - Effect_Add(globalCtx, &this->unk_338, EFFECT_BLURE2, 0, 0, &D_80879308); + Effect_Add(play, &this->unk_338, EFFECT_BLURE2, 0, 0, &D_80879308); if (this->actor.params == 0) { Actor_SetScale(&this->actor, 3.0f / 160.0f); this->unk_334 = 1.0f; @@ -333,16 +333,16 @@ void EnDodongo_Init(Actor* thisx, GlobalContext* globalCtx) { func_808773C4(this); } -void EnDodongo_Destroy(Actor* thisx, GlobalContext* globalCtx) { +void EnDodongo_Destroy(Actor* thisx, PlayState* play) { EnDodongo* this = THIS; - Effect_Destroy(globalCtx, this->unk_338); - Collider_DestroyJntSph(globalCtx, &this->collider2); - Collider_DestroyJntSph(globalCtx, &this->collider3); - Collider_DestroyJntSph(globalCtx, &this->collider1); + Effect_Destroy(play, this->unk_338); + Collider_DestroyJntSph(play, &this->collider2); + Collider_DestroyJntSph(play, &this->collider3); + Collider_DestroyJntSph(play, &this->collider1); } -void func_80876930(EnDodongo* this, GlobalContext* globalCtx, Vec3f* arg2) { +void func_80876930(EnDodongo* this, PlayState* play, Vec3f* arg2) { static Color_RGBA8 D_8087932C = { 250, 250, 250, 255 }; static Color_RGBA8 D_80879330 = { 180, 180, 180, 255 }; static Color_RGBA8 D_80879334 = { 170, 130, 90, 255 }; @@ -358,7 +358,7 @@ void func_80876930(EnDodongo* this, GlobalContext* globalCtx, Vec3f* arg2) { s16 temp2; f32 temp3; - if (func_800C9BB8(&globalCtx->colCtx, this->actor.floorPoly, this->actor.floorBgId) == COLPOLY_SURFACE_SNOW) { + if (func_800C9BB8(&play->colCtx, this->actor.floorPoly, this->actor.floorBgId) == COLPOLY_SURFACE_SNOW) { sp80 = &D_8087932C; sp7C = &D_80879330; } else { @@ -376,28 +376,28 @@ void func_80876930(EnDodongo* this, GlobalContext* globalCtx, Vec3f* arg2) { sp88.z = randPlusMinusPoint5Scaled(temp3) + arg2->z; D_8087933C.x = randPlusMinusPoint5Scaled(2.0f); D_8087933C.z = randPlusMinusPoint5Scaled(2.0f); - func_800B0DE0(globalCtx, &sp88, &gZeroVec3f, &D_8087933C, sp80, sp7C, temp1, temp2); + func_800B0DE0(play, &sp88, &gZeroVec3f, &D_8087933C, sp80, sp7C, temp1, temp2); } } -void func_80876B08(EnDodongo* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); +void func_80876B08(EnDodongo* this, PlayState* play) { + Player* player = GET_PLAYER(play); s16 yDiff = this->actor.yawTowardsPlayer - this->actor.shape.rot.y; if (ABS_ALT(yDiff) < 0x4000) { - if (!(player->stateFlags1 & 0x00800000) && (Player_GetMask(globalCtx) != PLAYER_MASK_STONE)) { + if (!(player->stateFlags1 & 0x00800000) && (Player_GetMask(play) != PLAYER_MASK_STONE)) { func_808777A8(this); } else { func_80877494(this); } - } else if (Player_GetMask(globalCtx) != PLAYER_MASK_STONE) { + } else if (Player_GetMask(play) != PLAYER_MASK_STONE) { func_80878354(this); } else { func_80877494(this); } } -void func_80876BD0(EnDodongo* this, GlobalContext* globalCtx, s32 arg2) { +void func_80876BD0(EnDodongo* this, PlayState* play, s32 arg2) { if (this->actor.colChkInfo.damageEffect == 2) { this->drawDmgEffType = ACTOR_DRAW_DMGEFF_FIRE; this->drawDmgEffScale = 0.75f; @@ -406,8 +406,7 @@ void func_80876BD0(EnDodongo* this, GlobalContext* globalCtx, s32 arg2) { 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, + Actor_Spawn(&play->actorCtx, play, ACTOR_EN_CLEAR_TAG, this->collider1.elements[arg2].info.bumper.hitPos.x, this->collider1.elements[arg2].info.bumper.hitPos.y, this->collider1.elements[arg2].info.bumper.hitPos.z, 0, 0, 0, CLEAR_TAG_LARGE_LIGHT_RAYS); } @@ -424,20 +423,19 @@ void func_80876CAC(EnDodongo* this) { Actor_SetColorFilter(&this->actor, 0x4000, 0xFF, 0, 80); } -void func_80876D28(EnDodongo* this, GlobalContext* globalCtx) { +void func_80876D28(EnDodongo* this, PlayState* play) { if (this->drawDmgEffType == ACTOR_DRAW_DMGEFF_FROZEN_NO_SFX) { this->timer = 0; this->actor.colorFilterTimer = 0; this->drawDmgEffType = ACTOR_DRAW_DMGEFF_FIRE; this->collider1.base.colType = COLTYPE_HIT0; this->drawDmgEffAlpha = 0.0f; - Actor_SpawnIceEffects(globalCtx, &this->actor, &this->limbPos[0], 9, 2, this->unk_334 * 0.3f, - this->unk_334 * 0.2f); + Actor_SpawnIceEffects(play, &this->actor, &this->limbPos[0], 9, 2, this->unk_334 * 0.3f, this->unk_334 * 0.2f); this->actor.flags |= ACTOR_FLAG_400; } } -void func_80876DC4(EnDodongo* this, GlobalContext* globalCtx) { +void func_80876DC4(EnDodongo* this, PlayState* play) { s32 pad; Vec3f sp80; Vec3f sp74; @@ -449,7 +447,7 @@ void func_80876DC4(EnDodongo* this, GlobalContext* globalCtx) { f32 temp_f20; Math_Vec3f_Copy(&sp68, &this->limbPos[0]); - sp66 = (Rand_Next() >> 0x12) + this->actor.shape.rot.y; + sp66 = ((s32)Rand_Next() >> 0x12) + this->actor.shape.rot.y; temp_f20 = Math_CosS(sp66); temp_f22 = Math_SinS(sp66); @@ -480,9 +478,9 @@ void func_80876DC4(EnDodongo* this, GlobalContext* globalCtx) { sp74.z = (Rand_ZeroFloat(0.1f) + 0.15f) * -temp_f20 * this->unk_334; sp64 = this->unk_334 * 100.0f; sp62 = this->unk_334 * 25.0f; - func_800B0EB0(globalCtx, &sp68, &sp80, &sp74, &this->unk_32C, &this->unk_330, sp64, sp62, 0x14); + func_800B0EB0(play, &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); @@ -494,7 +492,7 @@ void func_80876DC4(EnDodongo* this, GlobalContext* globalCtx) { sp74.x = (Rand_ZeroFloat(0.1f) + 0.15f) * temp_f20 * this->unk_334; 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); + func_800B0EB0(play, &sp68, &sp80, &sp74, &this->unk_32C, &this->unk_330, sp64, sp62, 0x14); 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); @@ -502,7 +500,7 @@ void func_80876DC4(EnDodongo* this, GlobalContext* globalCtx) { sp80.z = sp80.z * -1.0f; sp74.x = (Rand_ZeroFloat(0.1f) + 0.15f) * -temp_f20 * this->unk_334; 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); + func_800B0EB0(play, &sp68, &sp80, &sp74, &this->unk_32C, &this->unk_330, sp64, sp62, 0x14); } s32 func_8087721C(EnDodongo* this) { @@ -513,9 +511,9 @@ s32 func_8087721C(EnDodongo* this) { return false; } -s32 func_80877278(EnDodongo* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); - Actor* explosive = globalCtx->actorCtx.actorLists[ACTORCAT_EXPLOSIVES].first; +s32 func_80877278(EnDodongo* this, PlayState* play) { + Player* player = GET_PLAYER(play); + Actor* explosive = play->actorCtx.actorLists[ACTORCAT_EXPLOSIVES].first; Vec3f sp44; // Bugfix from OoT @@ -543,7 +541,7 @@ void func_808773C4(EnDodongo* this) { this->actionFunc = func_80877424; } -void func_80877424(EnDodongo* this, GlobalContext* globalCtx) { +void func_80877424(EnDodongo* this, PlayState* play) { SkelAnime_Update(&this->skelAnime); if (this->timer != 0) { this->timer--; @@ -563,8 +561,8 @@ void func_80877494(EnDodongo* this) { this->actionFunc = func_80877500; } -void func_80877500(EnDodongo* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); +void func_80877500(EnDodongo* this, PlayState* play) { + Player* player = GET_PLAYER(play); Vec3f sp30; s16 temp_v1; @@ -574,17 +572,17 @@ void func_80877500(EnDodongo* this, GlobalContext* globalCtx) { sp30.x = this->collider1Elements[2].dim.worldSphere.center.x; sp30.y = this->collider1Elements[2].dim.worldSphere.center.y; sp30.z = this->collider1Elements[2].dim.worldSphere.center.z; - func_80876930(this, globalCtx, &sp30); + func_80876930(this, play, &sp30); } else if (Animation_OnFrame(&this->skelAnime, 39.0f)) { Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_DODO_J_WALK); sp30.x = this->collider1Elements[1].dim.worldSphere.center.x; sp30.y = this->collider1Elements[1].dim.worldSphere.center.y; sp30.z = this->collider1Elements[1].dim.worldSphere.center.z; - func_80876930(this, globalCtx, &sp30); + func_80876930(this, play, &sp30); } if ((Math_Vec3f_DistXZ(&this->actor.home.pos, &player->actor.world.pos) < 400.0f) && - (Player_GetMask(globalCtx) != PLAYER_MASK_STONE)) { + (Player_GetMask(play) != PLAYER_MASK_STONE)) { temp_v1 = this->actor.yawTowardsPlayer - this->actor.shape.rot.y; Math_ScaledStepToS(&this->actor.world.rot.y, this->actor.yawTowardsPlayer, 0x1F4); if (this->actor.xzDistToPlayer < (100.0f * this->unk_334)) { @@ -595,7 +593,7 @@ void func_80877500(EnDodongo* this, GlobalContext* globalCtx) { } } else { if ((Actor_XZDistanceToPoint(&this->actor, &this->actor.home.pos) > 150.0f) || - (Player_GetMask(globalCtx) == PLAYER_MASK_STONE)) { + (Player_GetMask(play) == PLAYER_MASK_STONE)) { Math_ScaledStepToS(&this->actor.world.rot.y, Actor_YawToPoint(&this->actor, &this->actor.home.pos), 0x1F4); } @@ -631,7 +629,7 @@ void func_808777A8(EnDodongo* this) { this->actionFunc = func_8087784C; } -void func_8087784C(EnDodongo* this, GlobalContext* globalCtx) { +void func_8087784C(EnDodongo* this, PlayState* play) { static Vec3f D_80879348 = { 0.0f, 0.9f, 0.0f }; static Vec3f D_80879354 = { 0.0f, 0.0f, 0.0f }; s16 frame; @@ -669,7 +667,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->limbPos[0], &D_80879354, &D_80879348, this->unk_334 * 100.0f, + EffectSsDFire_Spawn(play, &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); @@ -685,7 +683,7 @@ void func_80877D50(EnDodongo* this) { this->actionFunc = func_80877D90; } -void func_80877D90(EnDodongo* this, GlobalContext* globalCtx) { +void func_80877D90(EnDodongo* this, PlayState* play) { if (SkelAnime_Update(&this->skelAnime)) { func_808773C4(this); this->timer = Rand_S16Offset(10, 20); @@ -693,20 +691,20 @@ 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); + Animation_Change(&this->skelAnime, &object_dodongo_Anim_0028F0, -1.0f, 35.0f, 0.0f, ANIMMODE_ONCE, -4.0f); this->actor.flags |= ACTOR_FLAG_10; this->timer = 25; this->actionFunc = func_80877E60; this->actor.speedXZ = 0.0f; } -void func_80877E60(EnDodongo* this, GlobalContext* globalCtx) { +void func_80877E60(EnDodongo* this, PlayState* play) { static Vec3f D_80879360 = { 0.0f, 0.6f, 0.0f }; static Color_RGBA8 D_8087936C = { 255, 255, 255, 255 }; Vec3f sp84; Vec3f sp78; s16 i; - Actor* explosive = globalCtx->actorCtx.actorLists[ACTORCAT_EXPLOSIVES].first; + Actor* explosive = play->actorCtx.actorLists[ACTORCAT_EXPLOSIVES].first; Vec3f sp64; s32 pad; s16 sp5E; @@ -748,14 +746,14 @@ void func_80877E60(EnDodongo* this, GlobalContext* globalCtx) { sp64.x = this->collider1Elements[0].dim.worldSphere.center.x + sp84.x; sp64.y = this->collider1Elements[0].dim.worldSphere.center.y + sp84.y; sp64.z = this->collider1Elements[0].dim.worldSphere.center.z + sp84.z; - func_800B0EB0(globalCtx, &sp64, &sp84, &sp78, &this->unk_32C, &this->unk_330, this->unk_334 * 400.0f, + func_800B0EB0(play, &sp64, &sp84, &sp78, &this->unk_32C, &this->unk_330, this->unk_334 * 400.0f, this->unk_334 * 10.0f, 10); } Actor_PlaySfxAtPos(&this->actor, NA_SE_IT_BOMB_EXPLOSION); if (this->actor.colChkInfo.health <= 4) { this->actor.colChkInfo.health = 0; - Enemy_StartFinishingBlow(globalCtx, &this->actor); + Enemy_StartFinishingBlow(play, &this->actor); } else { this->actor.colChkInfo.health -= 4; } @@ -768,18 +766,18 @@ void func_80877E60(EnDodongo* this, GlobalContext* globalCtx) { if (this->skelAnime.curFrame <= 27.0f) { if ((this->skelAnime.curFrame <= 25.0f) && (this->timer < 11)) { - func_80876DC4(this, globalCtx); + func_80876DC4(this, play); } else { sp5E = this->unk_334 * 50.0f; sp5C = this->unk_334 * 5.0f; Math_Vec3f_Copy(&sp64, &this->limbPos[0]); - func_800B0DE0(globalCtx, &sp64, &gZeroVec3f, &D_80879360, &D_8087936C, &D_8087936C, sp5E, sp5C); + func_800B0DE0(play, &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); + func_800B0DE0(play, &sp64, &gZeroVec3f, &D_80879360, &D_8087936C, &D_8087936C, sp5E, sp5C); 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); + func_800B0DE0(play, &sp64, &gZeroVec3f, &D_80879360, &D_8087936C, &D_8087936C, sp5E, sp5C); } } @@ -819,13 +817,13 @@ void func_80878354(EnDodongo* this) { this->actionFunc = func_80878424; } -void func_80878424(EnDodongo* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); +void func_80878424(EnDodongo* this, PlayState* play) { + Player* player = GET_PLAYER(play); Vec3f sp20; this->timer++; if (SkelAnime_Update(&this->skelAnime)) { - if (!(player->stateFlags1 & 0x800000) && (Player_GetMask(globalCtx) != PLAYER_MASK_STONE)) { + if (!(player->stateFlags1 & 0x800000) && (Player_GetMask(play) != PLAYER_MASK_STONE)) { this->collider1.base.atFlags &= ~AT_ON; func_808777A8(this); } else { @@ -839,12 +837,12 @@ void func_80878424(EnDodongo* this, GlobalContext* globalCtx) { sp20.x = this->collider1Elements[1].dim.worldSphere.center.x; sp20.y = this->collider1Elements[1].dim.worldSphere.center.y; sp20.z = this->collider1Elements[1].dim.worldSphere.center.z; - func_80876930(this, globalCtx, &sp20); + func_80876930(this, play, &sp20); sp20.x = this->collider1Elements[2].dim.worldSphere.center.x; sp20.y = this->collider1Elements[2].dim.worldSphere.center.y; sp20.z = this->collider1Elements[2].dim.worldSphere.center.z; - func_80876930(this, globalCtx, &sp20); - CollisionCheck_SetAT(globalCtx, &globalCtx->colChkCtx, &this->collider1.base); + func_80876930(this, play, &sp20); + CollisionCheck_SetAT(play, &play->colChkCtx, &this->collider1.base); this->actor.flags |= ACTOR_FLAG_1000000; } @@ -853,19 +851,19 @@ void func_80878594(EnDodongo* this) { this->actor.speedXZ = 0.0f; } -void func_808785B0(EnDodongo* this, GlobalContext* globalCtx) { +void func_808785B0(EnDodongo* this, PlayState* play) { if (this->timer != 0) { this->timer--; } if (this->timer == 0) { - func_80876D28(this, globalCtx); + func_80876D28(this, play); if (this->actor.colChkInfo.health == 0) { func_80878724(this); } else if (this->actor.xzDistToPlayer > 100.0f * this->unk_334) { func_80877494(this); } else { - func_80876B08(this, globalCtx); + func_80876B08(this, play); } } } @@ -880,13 +878,13 @@ void func_8087864C(EnDodongo* this) { this->actionFunc = func_808786C8; } -void func_808786C8(EnDodongo* this, GlobalContext* globalCtx) { +void func_808786C8(EnDodongo* this, PlayState* play) { if (this->unk_304 == 1) { - func_80876DC4(this, globalCtx); + func_80876DC4(this, play); } if (SkelAnime_Update(&this->skelAnime)) { - func_80876B08(this, globalCtx); + func_80876B08(this, play); } } @@ -901,12 +899,12 @@ void func_80878724(EnDodongo* this) { this->actionFunc = func_808787B0; } -void func_808787B0(EnDodongo* this, GlobalContext* globalCtx) { +void func_808787B0(EnDodongo* this, PlayState* play) { s32 pad; if (this->skelAnime.curFrame < 35.0f) { if (this->unk_304 != 0) { - func_80876DC4(this, globalCtx); + func_80876DC4(this, play); } } else if (this->actor.colorFilterTimer == 0) { Actor_SetColorFilter(&this->actor, 0x4000, 0x78, 0, 4); @@ -914,7 +912,7 @@ void func_808787B0(EnDodongo* this, GlobalContext* globalCtx) { if (SkelAnime_Update(&this->skelAnime)) { if (this->timer == 0) { - EnBom* bomb = (EnBom*)Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_BOM, this->actor.world.pos.x, + EnBom* bomb = (EnBom*)Actor_Spawn(&play->actorCtx, play, ACTOR_EN_BOM, this->actor.world.pos.x, this->actor.world.pos.y, this->actor.world.pos.z, 0, 0, 0, 0); if (bomb != NULL) { bomb->timer = 0; @@ -929,16 +927,16 @@ void func_808787B0(EnDodongo* this, GlobalContext* globalCtx) { this->timer--; if (this->timer == 0) { if (this->actor.params == 0) { - Item_DropCollectibleRandom(globalCtx, &this->actor, &this->actor.world.pos, 0x90); + Item_DropCollectibleRandom(play, &this->actor, &this->actor.world.pos, 0x90); } else { - Item_DropCollectible(globalCtx, &this->actor.world.pos, ITEM00_RUPEE_PURPLE); + Item_DropCollectible(play, &this->actor.world.pos, ITEM00_RUPEE_PURPLE); } Actor_MarkForDeath(&this->actor); } } } -void EnDodongo_UpdateDamage(EnDodongo* this, GlobalContext* globalCtx) { +void EnDodongo_UpdateDamage(EnDodongo* this, PlayState* play) { Vec3f sp3C; s32 i; @@ -955,14 +953,14 @@ void EnDodongo_UpdateDamage(EnDodongo* this, GlobalContext* globalCtx) { if ((i != ARRAY_COUNT(this->collider2Elements)) && ((this->drawDmgEffType != ACTOR_DRAW_DMGEFF_FROZEN_NO_SFX) || !(this->collider2.elements[i].info.acHitInfo->toucher.dmgFlags & 0xDB0B3))) { - func_80876D28(this, globalCtx); + func_80876D28(this, play); Math_Vec3s_ToVec3f(&sp3C, &this->collider2.elements[i].info.bumper.hitPos); if (this->actor.colChkInfo.damageEffect == 0xF) { - CollisionCheck_BlueBlood(globalCtx, NULL, &sp3C); - EffectSsHitMark_SpawnFixedScale(globalCtx, 0, &sp3C); + CollisionCheck_BlueBlood(play, NULL, &sp3C); + EffectSsHitmark_SpawnFixedScale(play, 0, &sp3C); } else if (this->actor.colChkInfo.damageEffect != 14) { - EffectSsHitMark_SpawnFixedScale(globalCtx, 3, &sp3C); - CollisionCheck_SpawnShieldParticlesMetalSound(globalCtx, &sp3C, &this->actor.projectedPos); + EffectSsHitmark_SpawnFixedScale(play, 3, &sp3C); + CollisionCheck_SpawnShieldParticlesMetalSound(play, &sp3C, &this->actor.projectedPos); } } } else if (this->collider1.base.acFlags & AC_HIT) { @@ -979,10 +977,10 @@ void EnDodongo_UpdateDamage(EnDodongo* this, GlobalContext* globalCtx) { if ((i != ARRAY_COUNT(this->collider1Elements)) && ((this->drawDmgEffType != ACTOR_DRAW_DMGEFF_FROZEN_NO_SFX) || !(this->collider1.elements[i].info.acHitInfo->toucher.dmgFlags & 0xDB0B3))) { - func_80876D28(this, globalCtx); + func_80876D28(this, play); if (this->actor.colChkInfo.damageEffect != 0xF) { if (!Actor_ApplyDamage(&this->actor)) { - Enemy_StartFinishingBlow(globalCtx, &this->actor); + Enemy_StartFinishingBlow(play, &this->actor); if (this->actor.colChkInfo.damageEffect == 3) { func_80876CAC(this); this->timer = 3; @@ -990,7 +988,7 @@ void EnDodongo_UpdateDamage(EnDodongo* this, GlobalContext* globalCtx) { this->collider2.base.acFlags &= ~AC_ON; func_80878594(this); } else { - func_80876BD0(this, globalCtx, i); + func_80876BD0(this, play, i); func_80878724(this); } } else if (this->actor.colChkInfo.damageEffect == 1) { @@ -1010,7 +1008,7 @@ void EnDodongo_UpdateDamage(EnDodongo* this, GlobalContext* globalCtx) { func_80876CAC(this); func_80878594(this); } else { - func_80876BD0(this, globalCtx, i); + func_80876BD0(this, play, i); func_8087864C(this); } } @@ -1018,31 +1016,31 @@ void EnDodongo_UpdateDamage(EnDodongo* this, GlobalContext* globalCtx) { } } -void EnDodongo_Update(Actor* thisx, GlobalContext* globalCtx2) { - GlobalContext* globalCtx = globalCtx2; +void EnDodongo_Update(Actor* thisx, PlayState* play2) { + PlayState* play = play2; EnDodongo* this = THIS; - EnDodongo_UpdateDamage(this, globalCtx); - this->actionFunc(this, globalCtx); + EnDodongo_UpdateDamage(this, play); + this->actionFunc(this, play); Actor_MoveWithGravity(&this->actor); - Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 75.0f, 60.0f, 70.0f, 0x1D); + Actor_UpdateBgCheckInfo(play, &this->actor, 75.0f, 60.0f, 70.0f, 0x1D); if (this->actor.bgCheckFlags & 2) { Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_GERUDOFT_DOWN); } - CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider1.base); + CollisionCheck_SetOC(play, &play->colChkCtx, &this->collider1.base); if (this->actionFunc != func_808787B0) { - CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->collider2.base); + CollisionCheck_SetAC(play, &play->colChkCtx, &this->collider2.base); if ((this->actionFunc != func_808786C8) && (this->actionFunc != func_80877E60)) { - CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->collider1.base); - if ((this->actionFunc != func_8087784C) && func_80877278(this, globalCtx)) { + CollisionCheck_SetAC(play, &play->colChkCtx, &this->collider1.base); + if ((this->actionFunc != func_8087784C) && func_80877278(this, play)) { func_80877DE0(this); } } } if (func_8087721C(this)) { - CollisionCheck_SetAT(globalCtx, &globalCtx->colChkCtx, &this->collider3.base); + CollisionCheck_SetAT(play, &play->colChkCtx, &this->collider3.base); } if (this->drawDmgEffAlpha > 0.0f) { @@ -1056,8 +1054,7 @@ void EnDodongo_Update(Actor* thisx, GlobalContext* globalCtx2) { } } -s32 EnDodongo_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, - Actor* thisx) { +s32 EnDodongo_OverrideLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, Actor* thisx) { EnDodongo* this = THIS; if (limbIndex == 1) { @@ -1069,7 +1066,7 @@ s32 EnDodongo_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dL return false; } -void EnDodongo_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx) { +void EnDodongo_PostLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx) { static Vec3f D_80879370 = { 1800.0f, 1200.0f, 0.0f }; static Vec3f D_8087937C = { 1500.0f, 300.0f, 0.0f }; static s8 D_80879388[] = { @@ -1081,16 +1078,16 @@ 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->limbPos[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->limbPos[0]); - Matrix_GetStateTranslation(&this->actor.focus.pos); - Matrix_GetStateTranslationAndScaledY(-200.0f, &this->limbPos[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)) { @@ -1099,13 +1096,13 @@ void EnDodongo_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList } } -void EnDodongo_Draw(Actor* thisx, GlobalContext* globalCtx) { +void EnDodongo_Draw(Actor* thisx, PlayState* play) { EnDodongo* this = THIS; - func_8012C28C(globalCtx->state.gfxCtx); - SkelAnime_DrawOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, EnDodongo_OverrideLimbDraw, + func_8012C28C(play->state.gfxCtx); + SkelAnime_DrawOpa(play, this->skelAnime.skeleton, this->skelAnime.jointTable, EnDodongo_OverrideLimbDraw, EnDodongo_PostLimbDraw, &this->actor); - Actor_DrawDamageEffects(globalCtx, &this->actor, this->limbPos, ARRAY_COUNT(this->limbPos), + Actor_DrawDamageEffects(play, &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 30562404f..a196b1f8c 100644 --- a/src/overlays/actors/ovl_En_Dodongo/z_en_dodongo.h +++ b/src/overlays/actors/ovl_En_Dodongo/z_en_dodongo.h @@ -5,7 +5,7 @@ struct EnDodongo; -typedef void (*EnDodongoActionFunc)(struct EnDodongo*, GlobalContext*); +typedef void (*EnDodongoActionFunc)(struct EnDodongo*, PlayState*); typedef struct EnDodongo { /* 0x000 */ Actor actor; 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 bb1c574e2..d9bc5cee1 100644 --- a/src/overlays/actors/ovl_En_Door/z_en_door.c +++ b/src/overlays/actors/ovl_En_Door/z_en_door.c @@ -24,118 +24,257 @@ #define THIS ((EnDoor*)thisx) -void EnDoor_Init(Actor* thisx, GlobalContext* globalCtx); -void EnDoor_Destroy(Actor* thisx, GlobalContext* globalCtx); -void EnDoor_Update(Actor* thisx, GlobalContext* globalCtx); -void EnDoor_Draw(Actor* thisx, GlobalContext* globalCtx); +void EnDoor_Init(Actor* thisx, PlayState* play); +void EnDoor_Destroy(Actor* thisx, PlayState* play); +void EnDoor_Update(Actor* thisx, PlayState* play); +void EnDoor_Draw(Actor* thisx, PlayState* play); -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*); +void func_80866B20(EnDoor*, PlayState*); +void func_8086704C(EnDoor*, PlayState*); +void func_80866F94(EnDoor*, PlayState*); +void func_80867080(EnDoor*, PlayState*); +void func_80867144(EnDoor*, PlayState*); +void func_808670F0(EnDoor*, PlayState*); +void func_80866A5C(EnDoor*, PlayState*); u8 D_808675D0[] = { - 0x0C, 0x00, 0x03, 0x0E, 0x02, 0x06, 0x00, 0x17, 0x00, 0x08, - 0x02, 0x00, 0x00, 0x06, 0x00, 0x02, 0x09, 0x07, 0x05, 0x00, + /* 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[] = { - 0x0F, 0x09, 0x00, 0x47, 0x0F, 0x0C, 0x00, 0x15, 0x0C, 0x00, 0x01, 0x13, 0x11, 0x00, 0x0F, 0x0D, - 0x00, 0x0A, 0x0F, 0x0F, 0x00, 0x07, 0x0F, 0x00, 0x00, 0x02, 0x09, 0x09, 0x05, 0x09, 0x08, 0x0C, - 0x00, 0x02, 0x19, 0x00, 0x1C, 0x08, 0x07, 0x0F, 0x0D, 0x00, 0x02, 0x09, 0x09, 0x05, 0x0F, 0x0D, - 0x00, 0xEA, 0x0F, 0x11, 0x00, 0xE7, 0x0F, 0x00, 0x00, 0xE2, 0x09, 0x09, 0x0F, 0x0D, 0x00, 0xDC, - 0x0F, 0x0D, 0x00, 0xD9, 0x0F, 0x12, 0x00, 0x01, 0x05, 0x09, 0x09, 0x09, 0x09, 0x00, 0x00, 0x00, + /* 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[] = { - 0x02, 0x06, 0x00, 0x17, 0x00, 0x02, 0x09, 0x1C, 0x05, 0x00, 0x00, 0x00, + /* 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[] = { - 0x02, 0x15, 0x00, 0x16, 0x00, 0x01, 0x05, 0x09, 0x0B, 0x00, 0x00, 0x00, + /* 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[] = { - 0x02, 0x16, 0x00, 0x05, 0x00, 0x02, 0x09, 0x0A, 0x05, 0x00, 0x00, 0x00, + /* 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[] = { - 0x0C, 0x00, 0x02, 0x0F, 0x00, 0x1C, 0x08, 0x02, 0x09, 0x0C, 0x02, 0x0F, 0x0A, 0x16, 0x00, - 0x02, 0x09, 0x0C, 0x05, 0x0C, 0x00, 0x03, 0x11, 0x0F, 0x0D, 0x00, 0x0D, 0x00, 0x33, 0x08, - 0x02, 0x09, 0x0C, 0x0F, 0x16, 0x00, 0x02, 0x09, 0x0C, 0x05, 0x09, 0x0C, 0x00, 0x00, + /* 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[] = { 0x05, 0x00, 0x00, 0x00 }; +u8 D_80867684[] = { + /* 0x0 */ SCHEDULE_CMD_RET_NONE(), +}; -u8 D_80867688[] = { 0x0F, 0x16, 0x00, 0x02, 0x09, 0x0F, 0x05, 0x00 }; +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[] = { 0x0F, 0x16, 0x00, 0x02, 0x09, 0x10, 0x05, 0x00 }; +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[] = { 0x0F, 0x16, 0x00, 0x02, 0x09, 0x11, 0x05, 0x00 }; +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[] = { - 0x02, 0x0A, 0x00, 0x15, 0x00, 0x0F, 0x02, 0x16, 0x00, 0x05, 0x00, 0x02, - 0x09, 0x12, 0x08, 0x02, 0x02, 0x09, 0x22, 0x09, 0x21, 0x05, 0x00, 0x00, + /* 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[] = { - 0x08, 0x00, 0x14, 0x0C, 0x00, 0x03, 0x07, 0x0F, 0x08, 0x00, 0x01, 0x05, - 0x09, 0x13, 0x02, 0x08, 0x00, 0x14, 0x1E, 0x02, 0x09, 0x13, 0x05, 0x05, + /* 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[] = { 0x05, 0x00, 0x00, 0x00 }; +u8 D_808676D0[] = { + /* 0x0 */ SCHEDULE_CMD_RET_NONE(), +}; -u8 D_808676D4[] = { 0x05, 0x00, 0x00, 0x00 }; +u8 D_808676D4[] = { + /* 0x0 */ SCHEDULE_CMD_RET_NONE(), +}; -u8 D_808676D8[] = { 0x0C, 0x00, 0x03, 0x05, 0x0F, 0x12, 0x00, 0x01, 0x05, 0x09, 0x14, 0x00 }; +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[] = { 0x08, 0x00, 0x02, 0x09, 0x16, 0x05, 0x00, 0x00 }; +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[] = { 0x05, 0x00, 0x00, 0x00 }; +u8 D_808676EC[] = { + /* 0x0 */ SCHEDULE_CMD_RET_NONE(), +}; u8 D_808676F0[] = { - 0x0C, 0x00, 0x03, 0x05, 0x0F, 0x0A, 0x00, 0x07, 0x05, 0x02, - 0x0A, 0x00, 0x14, 0x00, 0xF9, 0x09, 0x15, 0x00, 0x00, 0x00, + /* 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[] = { 0x05, 0x00, 0x00, 0x00 }; -u8 D_80867708[] = { 0x05, 0x00, 0x00, 0x00 }; -u8 D_8086770C[] = { 0x05, 0x00, 0x00, 0x00 }; -u8 D_80867710[] = { 0x05, 0x00, 0x00, 0x00 }; +u8 D_80867704[] = { + /* 0x0 */ SCHEDULE_CMD_RET_NONE(), +}; -u8 D_80867714[] = { 0x0F, 0x14, 0x00, 0x02, 0x09, 0x17, 0x05, 0x00 }; +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[] = { - 0x0C, 0x00, 0x01, 0x07, 0x0F, 0x02, 0x1E, 0x02, 0x09, 0x18, 0x05, 0x0C, - 0x00, 0x03, 0xFB, 0x0F, 0x14, 0x00, 0xF7, 0x09, 0x0C, 0x00, 0x00, 0x00, + /* 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[] = { 0x0F, 0x14, 0x00, 0x02, 0x09, 0x19, 0x05, 0x00 }; +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[] = { 0x0F, 0x14, 0x00, 0x02, 0x09, 0x1A, 0x05, 0x00 }; +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[] = { - 0x0C, 0x00, 0x02, 0x04, 0x00, 0x63, 0x80, 0x06, 0x0F, 0x14, 0x00, 0x08, - 0x09, 0x1B, 0x0F, 0x12, 0x00, 0x02, 0x09, 0x1B, 0x05, 0x00, 0x00, 0x00, + /* 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, 0x34, 0x20, 0x17, 0x00, 0x4B, 0x20, 0x13, 0x00, 0x0E, 0x04, 0x02, 0x09, 0x1D, - 0x00, 0x3B, 0x01, 0x08, 0x00, 0x3D, 0x02, 0x02, 0x09, 0x1E, 0x09, 0x1F, 0x05, 0x05, + /* 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[] = { 0x09, 0x20, 0x00, 0x00 }; -u8 D_8086777C[] = { 0x05, 0x00, 0x00, 0x00 }; -u8 D_80867780[] = { 0x05, 0x00, 0x00, 0x00 }; -u8 D_80867784[] = { 0x0F, 0x16, 0x00, 0x02, 0x09, 0x23, 0x05, 0x00 }; +u8 D_80867778[] = { + /* 0x0 */ SCHEDULE_CMD_RET_VAL_S(32), +}; -// void* seems to keep the compiler happy. -void* D_8086778C[] = { - &D_808675D0, &D_808675E4, &D_80867634, &D_80867640, &D_8086764C, &D_80867658, &D_80867684, &D_80867688, - &D_80867690, &D_80867698, &D_808676A0, &D_808676B8, &D_808676D0, &D_808676D4, &D_808676D8, &D_808676E4, - &D_808676EC, &D_808676F0, &D_80867704, &D_80867708, &D_8086770C, &D_80867710, &D_80867714, &D_8086771C, - &D_80867734, &D_8086773C, &D_80867744, &D_8086775C, &D_80867778, &D_8086777C, &D_80867780, &D_80867784, +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 = { @@ -245,8 +384,8 @@ static Gfx* D_808679A4[14][2] = { { gFieldWoodDoorLeftDL, gFieldWoodDoorRightDL }, }; -void EnDoor_Init(Actor* thisx, GlobalContext* globalCtx2) { - GlobalContext* globalCtx = globalCtx2; +void EnDoor_Init(Actor* thisx, PlayState* play2) { + PlayState* play = play2; s32 objectBankIndex; EnDoorInfo* objectInfo = sObjInfo; EnDoor* this = THIS; @@ -259,28 +398,27 @@ void EnDoor_Init(Actor* thisx, GlobalContext* globalCtx2) { 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); + DynaPolyActor_LoadMesh(play, &this->dyna, &gDoorCol); } - SkelAnime_Init(globalCtx, &this->skelAnime, &gDoorSkel, &gameplay_keep_Anim_020658, this->limbTable, - this->limbTable, 5); + SkelAnime_Init(play, &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) { + if (play->sceneNum == objectInfo->sceneNum) { break; } } - if ((i >= ARRAY_COUNT(sObjInfo) - 34) && (Object_GetIndex(&globalCtx->objectCtx, GAMEPLAY_FIELD_KEEP) >= 0)) { + if ((i >= ARRAY_COUNT(sObjInfo) - 34) && (Object_GetIndex(&play->objectCtx, GAMEPLAY_FIELD_KEEP) >= 0)) { objectInfo++; } } this->dlIndex = objectInfo->dListIndex; - objectBankIndex = Object_GetIndex(&globalCtx->objectCtx, objectInfo->objectId); + objectBankIndex = Object_GetIndex(&play->objectCtx, objectInfo->objectId); if (objectBankIndex < 0) { objectInfo = &sObjInfo[15]; - objectBankIndex = Object_GetIndex(&globalCtx->objectCtx, objectInfo->objectId); + objectBankIndex = Object_GetIndex(&play->objectCtx, objectInfo->objectId); if (objectBankIndex != 0) { Actor_MarkForDeath(&this->dyna.actor); return; @@ -289,56 +427,54 @@ void EnDoor_Init(Actor* thisx, GlobalContext* globalCtx2) { this->requiredObjBankIndex = objectBankIndex; this->dlIndex = objectInfo->dListIndex; // Set twice? if (this->dyna.actor.objBankIndex == this->requiredObjBankIndex) { - func_80866A5C(this, globalCtx); + func_80866A5C(this, play); } else { this->actionFunc = func_80866A5C; } Actor_SetFocus(&this->dyna.actor, 35.0f); } -void EnDoor_Destroy(Actor* thisx, GlobalContext* globalCtx) { +void EnDoor_Destroy(Actor* thisx, PlayState* play) { EnDoor* this = (EnDoor*)thisx; if (this->unk_1A4 != 7) { - TransitionActorEntry* transitionEntry = - &globalCtx->doorCtx.transitionActorList[(u16)this->dyna.actor.params >> 0xA]; + TransitionActorEntry* transitionEntry = &play->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); + DynaPoly_DeleteBgActor(play, &play->colCtx.dyna, this->dyna.bgId); } } -void func_80866A5C(EnDoor* this, GlobalContext* globalCtx) { - if (Object_IsLoaded(&globalCtx->objectCtx, this->requiredObjBankIndex)) { +void func_80866A5C(EnDoor* this, PlayState* play) { + if (Object_IsLoaded(&play->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)) { + if (!Flags_GetSwitch(play, this->switchFlag)) { this->unk_1A6 = 10; } } else if ((this->unk_1A4 == 4) && - (Actor_XZDistanceBetweenActors(&this->dyna.actor, &GET_PLAYER(globalCtx)->actor) > 120.0f)) { + (Actor_XZDistanceBetweenActors(&this->dyna.actor, &GET_PLAYER(play)->actor) > 120.0f)) { this->actionFunc = func_8086704C; this->dyna.actor.world.rot.y = -0x1800; } } } -void func_80866B20(EnDoor* this, GlobalContext* globalCtx) { +void func_80866B20(EnDoor* this, PlayState* play) { static s32 D_80867BC0[4]; - Player* player = GET_PLAYER(globalCtx); + Player* player = GET_PLAYER(play); Vec3f playerPosRelToDoor; s16 temp_a2; s16 yawDiff; s32 temp_a1_2; s32 temp_t0; u8 temp_a1; - s32 pad; - if (Actor_ProcessTalkRequest(&this->dyna.actor, &globalCtx->state) && (this->dyna.actor.textId == 0x1821)) { + if (Actor_ProcessTalkRequest(&this->dyna.actor, &play->state) && (this->dyna.actor.textId == 0x1821)) { D_80867BC0[0] = 1; } if (this->unk_1A1 != 0) { @@ -347,13 +483,13 @@ void func_80866B20(EnDoor* this, GlobalContext* globalCtx) { (player->stateFlags1 & 0x8000000) ? 0.75f : 1.5f); if (this->unk_1A6 != 0) { gSaveContext.save.inventory.dungeonKeys[gSaveContext.mapIndex]--; - Flags_SetSwitch(globalCtx, this->switchFlag); + Flags_SetSwitch(play, 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)) { + } else if (!Player_InCsMode(play)) { Actor_OffsetOfPointInActorCoords(&this->dyna.actor, &playerPosRelToDoor, &player->actor.world.pos); if ((D_80867BC0[0] != 0) || ((fabsf(playerPosRelToDoor.y) < 20.0f) && (fabsf(playerPosRelToDoor.x) < 20.0f) && (fabsf(playerPosRelToDoor.z) < 50.0f))) { @@ -378,9 +514,9 @@ void func_80866B20(EnDoor* this, GlobalContext* globalCtx) { } else if ((this->unk_1A4 == 0) || (this->unk_1A4 == 2) || (this->unk_1A4 == 3)) { s32 textIdOffset; - temp_t0 = (globalCtx->actorCtx.unkC & 0x2AA) >> 1; + temp_t0 = (play->actorCtx.unkC & 0x2AA) >> 1; temp_a2 = D_801AED48[this->switchFlag & 7]; - temp_a1_2 = globalCtx->actorCtx.unkC & 0x155; + temp_a1_2 = play->actorCtx.unkC & 0x155; textIdOffset = (this->switchFlag >> 3) & 0xF; if (((this->unk_1A4 == 0) && (((temp_t0 | temp_a1_2) & temp_a2) == 0)) || ((this->unk_1A4 == 2) && ((temp_a2 & temp_a1_2) == 0)) || @@ -396,10 +532,10 @@ void func_80866B20(EnDoor* this, GlobalContext* globalCtx) { this->dyna.actor.textId = baseTextId + textIdOffset; } } else if ((this->unk_1A4 == 5) && (playerPosRelToDoor.z > 0.0f)) { - struct_80133038_arg2 sp30; + ScheduleOutput sp30; - if (func_80133038(globalCtx, D_8086778C[this->switchFlag], &sp30) != 0) { - this->dyna.actor.textId = sp30.unk0 + 0x1800; + if (Schedule_RunScript(play, 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; } @@ -413,7 +549,7 @@ void func_80866B20(EnDoor* this, GlobalContext* globalCtx) { } } -void func_80866F94(EnDoor* this, GlobalContext* globalCtx) { +void func_80866F94(EnDoor* this, PlayState* play) { s32 direction; if (this->unk_1A7 != 0) { @@ -433,13 +569,13 @@ void func_80866F94(EnDoor* this, GlobalContext* globalCtx) { } } -void func_8086704C(EnDoor* this, GlobalContext* globalCtx) { +void func_8086704C(EnDoor* this, PlayState* play) { if (this->dyna.actor.xzDistToPlayer < 120.0f) { this->actionFunc = func_808670F0; } } -void func_80867080(EnDoor* this, GlobalContext* globalCtx) { +void func_80867080(EnDoor* this, PlayState* play) { if (this->dyna.actor.xzDistToPlayer < 120.0f) { this->actionFunc = func_808670F0; } else if (Math_ScaledStepToS(&this->dyna.actor.world.rot.y, -0x1800, 0x100)) { @@ -447,14 +583,14 @@ void func_80867080(EnDoor* this, GlobalContext* globalCtx) { } } -void func_808670F0(EnDoor* this, GlobalContext* globalCtx) { +void func_808670F0(EnDoor* this, PlayState* play) { if (Math_ScaledStepToS(&this->dyna.actor.world.rot.y, 0, 0x700)) { Actor_PlaySfxAtPos(&this->dyna.actor, NA_SE_EV_DOOR_CLOSE); this->actionFunc = func_80866B20; } } -void func_80867144(EnDoor* this, GlobalContext* globalCtx) { +void func_80867144(EnDoor* this, PlayState* play) { s32 numEffects; s32 i; @@ -467,7 +603,7 @@ void func_80867144(EnDoor* this, GlobalContext* globalCtx) { 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); + EffectSsBubble_Spawn(play, &this->dyna.actor.world.pos, 60.0, 100.0f, 50.0f, 0.15f); } } } else if (Animation_OnFrame(&this->skelAnime, sAnimCloseFrames[this->animIndex])) { @@ -476,14 +612,13 @@ void func_80867144(EnDoor* this, GlobalContext* globalCtx) { } } -void EnDoor_Update(Actor* thisx, GlobalContext* globalCtx) { +void EnDoor_Update(Actor* thisx, PlayState* play) { EnDoor* this = THIS; - this->actionFunc(this, globalCtx); + this->actionFunc(this, play); } -s32 EnDoor_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, - Actor* thisx) { +s32 EnDoor_OverrideLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, Actor* thisx) { TransitionActorEntry* transitionEntry; EnDoor* this = THIS; @@ -495,15 +630,15 @@ s32 EnDoor_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList transitionEntry = NULL; if (this->unk_1A4 != 7) { - transitionEntry = &globalCtx->doorCtx.transitionActorList[(u16)this->dyna.actor.params >> 0xA]; + transitionEntry = &play->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) || + if ((this->unk_1A4 == 7) || (play->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); + Math_Vec3f_Yaw(&play->view.eye, &this->dyna.actor.world.pos); *dList = (ABS_ALT(temp) < 0x4000) ? dl[0] : dl[1]; } else { @@ -517,18 +652,18 @@ s32 EnDoor_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList return false; } -void EnDoor_Draw(Actor* thisx, GlobalContext* globalCtx) { +void EnDoor_Draw(Actor* thisx, PlayState* play) { EnDoor* this = THIS; if (this->dyna.actor.objBankIndex == this->requiredObjBankIndex) { - OPEN_DISPS(globalCtx->state.gfxCtx); + OPEN_DISPS(play->state.gfxCtx); if ((this->unk_1A4 == 7) && (this->switchFlag == 0)) { - Gfx_DrawDListOpa(globalCtx, gameplay_keep_DL_0221B8); + Gfx_DrawDListOpa(play, gameplay_keep_DL_0221B8); } else { - func_8012C28C(globalCtx->state.gfxCtx); + func_8012C28C(play->state.gfxCtx); } - SkelAnime_DrawOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, EnDoor_OverrideLimbDraw, - NULL, &this->dyna.actor); + SkelAnime_DrawOpa(play, 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); @@ -537,8 +672,8 @@ void EnDoor_Draw(Actor* thisx, GlobalContext* globalCtx) { } } if (this->unk_1A6) { - Actor_DrawDoorLock(globalCtx, this->unk_1A6, 0); + Actor_DrawDoorLock(play, this->unk_1A6, 0); } - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->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 bc94e150e..359f34cd2 100644 --- a/src/overlays/actors/ovl_En_Door/z_en_door.h +++ b/src/overlays/actors/ovl_En_Door/z_en_door.h @@ -5,7 +5,7 @@ struct EnDoor; -typedef void (*EnDoorActionFunc)(struct EnDoor*, GlobalContext*); +typedef void (*EnDoorActionFunc)(struct EnDoor*, PlayState*); #define ENDOOR_GET_PARAMS_7(thisx) (((thisx)->params >> 7) & 7) #define ENDOOR_GET_PARAMS_7F(thisx) (((thisx)->params) & 0x7F) 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 9b53c36d2..0d3612145 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 @@ -10,9 +10,9 @@ #define THIS ((EnDoorEtc*)thisx) -void EnDoorEtc_Init(Actor* thisx, GlobalContext* globalCtx); -void EnDoorEtc_Destroy(Actor* thisx, GlobalContext* globalCtx); -void EnDoorEtc_Update(Actor* thisx, GlobalContext* globalCtx); +void EnDoorEtc_Init(Actor* thisx, PlayState* play); +void EnDoorEtc_Destroy(Actor* thisx, PlayState* play); +void EnDoorEtc_Update(Actor* thisx, PlayState* play); #if 0 const ActorInit En_Door_Etc_InitVars = { diff --git a/src/overlays/actors/ovl_En_Door_Etc/z_en_door_etc.h b/src/overlays/actors/ovl_En_Door_Etc/z_en_door_etc.h index 0add11416..18d525f44 100644 --- a/src/overlays/actors/ovl_En_Door_Etc/z_en_door_etc.h +++ b/src/overlays/actors/ovl_En_Door_Etc/z_en_door_etc.h @@ -5,12 +5,12 @@ struct EnDoorEtc; -typedef void (*EnDoorEtcActionFunc)(struct EnDoorEtc*, GlobalContext*); +typedef void (*EnDoorEtcActionFunc)(struct EnDoorEtc*, PlayState*); typedef struct EnDoorEtc { - /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0xB4]; - /* 0x01F8 */ EnDoorEtcActionFunc actionFunc; + /* 0x000 */ Actor actor; + /* 0x144 */ char unk_144[0xB4]; + /* 0x1F8 */ EnDoorEtcActionFunc actionFunc; } EnDoorEtc; // size = 0x1FC extern const ActorInit En_Door_Etc_InitVars; diff --git a/src/overlays/actors/ovl_En_Dragon/z_en_dragon.c b/src/overlays/actors/ovl_En_Dragon/z_en_dragon.c index 5b7091d02..901efc0d2 100644 --- a/src/overlays/actors/ovl_En_Dragon/z_en_dragon.c +++ b/src/overlays/actors/ovl_En_Dragon/z_en_dragon.c @@ -10,36 +10,26 @@ #define THIS ((EnDragon*)thisx) -void EnDragon_Init(Actor* thisx, GlobalContext* globalCtx); -void EnDragon_Destroy(Actor* thisx, GlobalContext* globalCtx); -void EnDragon_Update(Actor* thisx, GlobalContext* globalCtx); -void EnDragon_Draw(Actor* thisx, GlobalContext* globalCtx); +void EnDragon_Init(Actor* thisx, PlayState* play); +void EnDragon_Destroy(Actor* thisx, PlayState* play); +void EnDragon_Update(Actor* thisx, PlayState* play); +void EnDragon_Draw(Actor* thisx, PlayState* play); void EnDragon_SetupRetreatOrIdle(EnDragon* this); -void EnDragon_RetreatOrIdle(EnDragon* this, GlobalContext* globalCtx); +void EnDragon_RetreatOrIdle(EnDragon* this, PlayState* play); void EnDragon_SetupExtend(EnDragon* this); -void EnDragon_Extend(EnDragon* this, GlobalContext* globalCtx); -void EnDragon_Grab(EnDragon* this, GlobalContext* globalCtx); +void EnDragon_Extend(EnDragon* this, PlayState* play); +void EnDragon_Grab(EnDragon* this, PlayState* play); void EnDragon_SetupAttack(EnDragon* this); -void EnDragon_Attack(EnDragon* this, GlobalContext* globalCtx); -void EnDragon_Dead(EnDragon* this, GlobalContext* globalCtx); +void EnDragon_Attack(EnDragon* this, PlayState* play); +void EnDragon_Dead(EnDragon* this, PlayState* play); typedef enum { - /* 0 */ DEEP_PYTHON_ANIMATION_SMALL_SIDE_SWAY, - /* 1 */ DEEP_PYTHON_ANIMATION_LARGE_SIDE_SWAY, - /* 2 */ DEEP_PYTHON_ANIMATION_VERTICAL_SWAY, - /* 3 */ DEEP_PYTHON_ANIMATION_IDLE -} DeepPythonAnimationIndex; - -typedef enum { - /* 0 */ DEEP_PYTHON_ACTION_IDLE, - /* 1 */ DEEP_PYTHON_ACTION_EXTEND, - /* 2 */ DEEP_PYTHON_ACTION_GRAB, - /* 3 */ DEEP_PYTHON_ACTION_DAMAGE, - /* 4 */ DEEP_PYTHON_ACTION_RETREAT, - /* 5 */ DEEP_PYTHON_ACTION_SETUP_DEAD, - /* 6 */ DEEP_PYTHON_ACTION_DEAD, -} DeepPythonAction; + /* 0 */ DEEP_PYTHON_ANIM_SMALL_SIDE_SWAY, + /* 1 */ DEEP_PYTHON_ANIM_LARGE_SIDE_SWAY, + /* 2 */ DEEP_PYTHON_ANIM_VERTICAL_SWAY, + /* 3 */ DEEP_PYTHON_ANIM_IDLE +} DeepPythonAnimation; typedef enum { /* 0 */ DEEP_PYTHON_EXTEND_STATE_NOT_FULLY_EXTENDED, @@ -216,16 +206,16 @@ static ColliderJntSphInit sJntSphInit = { sJntSphElementsInit, }; -void EnDragon_Init(Actor* thisx, GlobalContext* globalCtx) { +void EnDragon_Init(Actor* thisx, PlayState* play) { EnDragon* this = THIS; - SkelAnime_InitFlex(globalCtx, &this->skelAnime, &gDeepPythonSkel, &gDeepPythonSmallSideSwayAnim, this->jointTable, + SkelAnime_InitFlex(play, &this->skelAnime, &gDeepPythonSkel, &gDeepPythonSmallSideSwayAnim, this->jointTable, this->morphTable, DEEP_PYTHON_LIMB_MAX); this->actor.colChkInfo.health = 4; this->actor.colChkInfo.damageTable = &sDamageTable; this->actor.targetMode = 0xA; - Collider_InitAndSetJntSph(globalCtx, &this->collider, &this->actor, &sJntSphInit, this->colliderElements); + Collider_InitAndSetJntSph(play, &this->collider, &this->actor, &sJntSphInit, this->colliderElements); 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 = @@ -259,10 +249,10 @@ void EnDragon_Init(Actor* thisx, GlobalContext* globalCtx) { EnDragon_SetupRetreatOrIdle(this); } -void EnDragon_Destroy(Actor* thisx, GlobalContext* globalCtx) { +void EnDragon_Destroy(Actor* thisx, PlayState* play) { EnDragon* this = THIS; - Collider_DestroyJntSph(globalCtx, &this->collider); + Collider_DestroyJntSph(play, &this->collider); } static AnimationHeader* sAnimations[] = { @@ -274,18 +264,18 @@ static AnimationHeader* sAnimations[] = { static u8 sAnimationModes[] = { ANIMMODE_LOOP, ANIMMODE_LOOP, ANIMMODE_ONCE, ANIMMODE_ONCE }; -void EnDragon_ChangeAnimation(EnDragon* this, s32 animationIndex) { +void EnDragon_ChangeAnim(EnDragon* this, s32 animIndex) { f32 startFrame; - this->animationIndex = animationIndex; - this->endFrame = Animation_GetLastFrame(sAnimations[animationIndex]); + this->animIndex = animIndex; + this->endFrame = Animation_GetLastFrame(sAnimations[animIndex]); startFrame = 0.0f; - if (this->animationIndex == DEEP_PYTHON_ANIMATION_IDLE) { + if (this->animIndex == DEEP_PYTHON_ANIM_IDLE) { startFrame = this->endFrame; } - Animation_Change(&this->skelAnime, sAnimations[animationIndex], 1.0f, startFrame, this->endFrame, - sAnimationModes[this->animationIndex], -4.0f); + Animation_Change(&this->skelAnime, sAnimations[animIndex], 1.0f, startFrame, this->endFrame, + sAnimationModes[this->animIndex], -4.0f); } static Color_RGBA8 sBubblePrimColors[] = { @@ -300,7 +290,7 @@ static Color_RGBA8 sBubbleEnvColors[] = { { 0, 0, 255, 255 }, }; -void EnDragon_SpawnBubbles(EnDragon* this, GlobalContext* globalCtx, Vec3f basePos) { +void EnDragon_SpawnBubbles(EnDragon* this, PlayState* play, Vec3f basePos) { static Vec3f sBubbleVelocity = { 0.0f, 0.0f, 0.0f }; static Vec3f sBubbleAccel = { 0.0f, 0.1f, 0.0f }; s32 bubbleCount; @@ -326,20 +316,20 @@ void EnDragon_SpawnBubbles(EnDragon* this, GlobalContext* globalCtx, Vec3f baseP 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, + EffectSsDtBubble_SpawnCustomColor(play, &bubblePos, &sBubbleVelocity, &sBubbleAccel, &sBubblePrimColors[colorIndex], &sBubbleEnvColors[colorIndex], scale, 30, 0); } } -void EnDragon_RetreatOnceTimerEnds(EnDragon* this, GlobalContext* globalCtx) { +void EnDragon_RetreatOnceTimerEnds(EnDragon* this, PlayState* play) { if (this->timer == 0) { - func_800B8D50(globalCtx, &this->actor, 10.0f, this->actor.world.rot.y, 10.0f, 8); + func_800B8D50(play, &this->actor, 10.0f, this->actor.world.rot.y, 10.0f, 8); EnDragon_SetupRetreatOrIdle(this); } } void EnDragon_SetupRetreatOrIdle(EnDragon* this) { - EnDragon_ChangeAnimation(this, DEEP_PYTHON_ANIMATION_IDLE); + EnDragon_ChangeAnim(this, DEEP_PYTHON_ANIM_IDLE); this->state = 0; this->unk_2CC = 0; this->hasGrabbedPlayer = false; @@ -348,7 +338,7 @@ void EnDragon_SetupRetreatOrIdle(EnDragon* this) { this->actionFunc = EnDragon_RetreatOrIdle; } -void EnDragon_RetreatOrIdle(EnDragon* this, GlobalContext* globalCtx) { +void EnDragon_RetreatOrIdle(EnDragon* this, PlayState* play) { SkelAnime_Update(&this->skelAnime); if (this->action == DEEP_PYTHON_ACTION_EXTEND) { EnDragon_SetupExtend(this); @@ -376,12 +366,12 @@ void EnDragon_SetupExtend(EnDragon* this) { this->actionFunc = EnDragon_Extend; } -void EnDragon_Extend(EnDragon* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); +void EnDragon_Extend(EnDragon* this, PlayState* play) { + Player* player = GET_PLAYER(play); f32 currentFrame = this->skelAnime.curFrame; s16 yaw; - EnDragon_SpawnBubbles(this, globalCtx, this->jawPos); + EnDragon_SpawnBubbles(this, play, this->jawPos); if (this->action >= DEEP_PYTHON_ACTION_DAMAGE) { Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_UTSUBO_BACK); @@ -407,8 +397,8 @@ void EnDragon_Extend(EnDragon* this, GlobalContext* globalCtx) { 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); + if (this->animIndex != DEEP_PYTHON_ANIM_LARGE_SIDE_SWAY) { + EnDragon_ChangeAnim(this, DEEP_PYTHON_ANIM_LARGE_SIDE_SWAY); } this->state = DEEP_PYTHON_EXTEND_STATE_FULLY_EXTENDED; @@ -429,8 +419,8 @@ void EnDragon_Extend(EnDragon* this, GlobalContext* globalCtx) { 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); + if (this->animIndex != DEEP_PYTHON_ANIM_LARGE_SIDE_SWAY) { + EnDragon_ChangeAnim(this, DEEP_PYTHON_ANIM_LARGE_SIDE_SWAY); } this->state = DEEP_PYTHON_EXTEND_STATE_REPEAT_LARGE_SWAY; @@ -440,7 +430,7 @@ void EnDragon_Extend(EnDragon* this, GlobalContext* globalCtx) { } 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); + EnDragon_ChangeAnim(this, DEEP_PYTHON_ANIM_SMALL_SIDE_SWAY); this->largeSwayWaitTimer = Rand_ZeroFloat(20.0f) + this->endFrame; this->state = DEEP_PYTHON_EXTEND_STATE_REPEAT_SMALL_SWAY; } @@ -455,15 +445,15 @@ void EnDragon_Extend(EnDragon* this, GlobalContext* globalCtx) { } } -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_SetSubCamEyeAt(EnDragon* this, PlayState* play, Vec3f subCamEye, Vec3f subCamAt) { + this->subCamId = ActorCutscene_GetCurrentSubCamId(this->actor.cutscene); + Math_Vec3f_Copy(&this->subCamEye, &subCamEye); + Math_Vec3f_Copy(&this->subCamAt, &subCamAt); + Play_SetCameraAtEye(play, this->subCamId, &this->subCamAt, &this->subCamEye); } -void EnDragon_SetupGrab(EnDragon* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); +void EnDragon_SetupGrab(EnDragon* this, PlayState* play) { + Player* player = GET_PLAYER(play); Vec3f extendedPos; s16 yaw; @@ -481,17 +471,17 @@ void EnDragon_SetupGrab(EnDragon* this, GlobalContext* globalCtx) { this->state = DEEP_PYTHON_GRAB_STATE_START; this->grabTimer = 0; this->hasGrabbedPlayer = false; - EnDragon_ChangeAnimation(this, DEEP_PYTHON_ANIMATION_IDLE); + EnDragon_ChangeAnim(this, DEEP_PYTHON_ANIM_IDLE); this->actionFunc = EnDragon_Grab; } } -static Vec3f sCameraEyePerPython[] = { +static Vec3f sSubCamEyePerPython[] = { { 1600.0f, 0.0f, 1400.0f }, { 1400.0f, 0.0f, 400.0f }, { 1800.0f, 0.0f, 1400.f }, { 1100.0f, -200.0f, 1500.0f }, { 2000.0f, 0.0f, 1500.0f }, { 1900.0f, 0.0f, 1800.0f }, { 1700.0f, 0.0f, 1100.0f }, { 1700.0f, 0.0f, 1100.0f }, }; -static Vec3f sCameraAtPerPython[] = { +static Vec3f sSubCamAtPerPython[] = { { 300.0f, -100.0f, 1300.0f }, { 1500.0f, 0.0f, 2400.0f }, { 300.0f, -100.0f, 1300.0f }, { 1900.0f, 500.0f, 600.0f }, { -1000.0f, 0.0f, 1000.0f }, { 1200.0f, 0.0f, 1500.0f }, { 1100.0f, 0.0f, 2000.0f }, { 1100.0f, 0.0f, 2000.0f }, }; @@ -500,12 +490,12 @@ static s16 sZRotPerPython[] = { 0x07D0, 0x07D0, 0x07D0, 0x07D0, 0x07D0, 0x0BB8, 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; +void EnDragon_Grab(EnDragon* this, PlayState* play) { + Player* player = GET_PLAYER(play); + Vec3f pos; // used as both the extended position and the camera eye + Vec3f subCamAt; - this->cameraId = ActorCutscene_GetCurrentCamera(this->actor.cutscene); + this->subCamId = ActorCutscene_GetCurrentSubCamId(this->actor.cutscene); SkelAnime_Update(&this->skelAnime); if (this->grabTimer == 0) { @@ -517,37 +507,38 @@ void EnDragon_Grab(EnDragon* this, GlobalContext* globalCtx) { Math_Vec3f_Copy(&player->actor.world.pos, &this->playerGrabPositionTemp); } - Math_Vec3f_Copy(&sp50, &this->burrowEntrancePos); - sp50.x += Math_SinS(this->actor.world.rot.y) * -930.0f; - sp50.z += Math_CosS(this->actor.world.rot.y) * -930.0f; - Math_Vec3f_Copy(&this->actor.world.pos, &sp50); + Math_Vec3f_Copy(&pos, &this->burrowEntrancePos); + pos.x += Math_SinS(this->actor.world.rot.y) * -930.0f; + pos.z += Math_CosS(this->actor.world.rot.y) * -930.0f; + Math_Vec3f_Copy(&this->actor.world.pos, &pos); this->jawZRotation = 0x1450; this->actor.speedXZ = 60.0f; } this->grabTimer++; Math_SmoothStepToS(&this->actor.shape.rot.z, sZRotPerPython[this->pythonIndex], 0xA, 0x1F4, 0x14); - EnDragon_SpawnBubbles(this, globalCtx, this->jawPos); + EnDragon_SpawnBubbles(this, play, this->jawPos); - Math_Vec3f_Copy(&sp50, &this->burrowEntrancePos); - sp50.x += Math_SinS(this->actor.world.rot.y) * sCameraEyePerPython[this->pythonIndex].x; - sp50.y += sCameraEyePerPython[this->pythonIndex].y; - sp50.z += Math_CosS(this->actor.world.rot.y) * sCameraEyePerPython[this->pythonIndex].z; + Math_Vec3f_Copy(&pos, &this->burrowEntrancePos); - Math_Vec3f_Copy(&at, &this->actor.world.pos); - at.x += Math_SinS(this->actor.world.rot.y) * sCameraAtPerPython[this->pythonIndex].x; - at.y += sCameraAtPerPython[this->pythonIndex].y; - at.z += Math_CosS(this->actor.world.rot.y) * sCameraAtPerPython[this->pythonIndex].z; + pos.x += Math_SinS(this->actor.world.rot.y) * sSubCamEyePerPython[this->pythonIndex].x; + pos.y += sSubCamEyePerPython[this->pythonIndex].y; + pos.z += Math_CosS(this->actor.world.rot.y) * sSubCamEyePerPython[this->pythonIndex].z; - EnDragon_CameraSetAtEye(this, globalCtx, sp50, at); + Math_Vec3f_Copy(&subCamAt, &this->actor.world.pos); + subCamAt.x += Math_SinS(this->actor.world.rot.y) * sSubCamAtPerPython[this->pythonIndex].x; + subCamAt.y += sSubCamAtPerPython[this->pythonIndex].y; + subCamAt.z += Math_CosS(this->actor.world.rot.y) * sSubCamAtPerPython[this->pythonIndex].z; + + EnDragon_SetSubCamEyeAt(this, play, pos, subCamAt); if (this->grabTimer > sMaxGrabTimerPerPython[this->pythonIndex]) { if (this->state == DEEP_PYTHON_GRAB_STATE_START) { - func_800B7298(globalCtx, &this->actor, 6); + func_800B7298(play, &this->actor, 6); this->state = DEEP_PYTHON_GRAB_STATE_GRABBED; } - globalCtx->unk_18770(globalCtx, player); + play->unk_18770(play, player); player->actor.parent = &this->actor; player->unk_AE8 = 50; this->action = DEEP_PYTHON_ACTION_GRAB; @@ -557,8 +548,8 @@ void EnDragon_Grab(EnDragon* this, GlobalContext* globalCtx) { } void EnDragon_SetupAttack(EnDragon* this) { - if (this->animationIndex != DEEP_PYTHON_ANIMATION_LARGE_SIDE_SWAY) { - EnDragon_ChangeAnimation(this, DEEP_PYTHON_ANIMATION_LARGE_SIDE_SWAY); + if (this->animIndex != DEEP_PYTHON_ANIM_LARGE_SIDE_SWAY) { + EnDragon_ChangeAnim(this, DEEP_PYTHON_ANIM_LARGE_SIDE_SWAY); } this->behindJawRetreatTimer = 0; @@ -567,35 +558,35 @@ void EnDragon_SetupAttack(EnDragon* this) { this->actionFunc = EnDragon_Attack; } -void EnDragon_Attack(EnDragon* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); +void EnDragon_Attack(EnDragon* this, PlayState* play) { + Player* player = GET_PLAYER(play); f32 currentFrame = this->skelAnime.curFrame; - Vec3f sp4C; // used as both the extended position and the camera eye - Vec3f at; + Vec3f pos; // used as both the extended position and the camera eye + Vec3f subCamAt; SkelAnime_Update(&this->skelAnime); Math_SmoothStepToS(&this->actor.shape.rot.z, 0, 0xA, 0x1388, 0); - if ((globalCtx->gameplayFrames % 16) == 0) { - globalCtx->damagePlayer(globalCtx, -2); + if ((play->gameplayFrames % 16) == 0) { + play->damagePlayer(play, -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); + CollisionCheck_GreenBlood(play, NULL, &player->actor.world.pos); } - Math_Vec3f_Copy(&sp4C, &this->actor.world.pos); - sp4C.x += Math_SinS(this->actor.world.rot.y) * 3000.0f; - sp4C.y += 600.0f; - sp4C.z += Math_CosS(this->actor.world.rot.y) * 3000.0f; + Math_Vec3f_Copy(&pos, &this->actor.world.pos); + pos.x += Math_SinS(this->actor.world.rot.y) * 3000.0f; + pos.y += 600.0f; + pos.z += Math_CosS(this->actor.world.rot.y) * 3000.0f; - Math_Vec3f_Copy(&at, &this->actor.world.pos); - at.x += Math_SinS(this->actor.world.rot.y) * 1200.0f; - at.y += -100.0f; - at.z += Math_CosS(this->actor.world.rot.y) * 1200.0f; + Math_Vec3f_Copy(&subCamAt, &this->actor.world.pos); + subCamAt.x += Math_SinS(this->actor.world.rot.y) * 1200.0f; + subCamAt.y += -100.0f; + subCamAt.z += Math_CosS(this->actor.world.rot.y) * 1200.0f; - EnDragon_CameraSetAtEye(this, globalCtx, sp4C, at); + EnDragon_SetSubCamEyeAt(this, play, pos, subCamAt); player->actor.world.rot.y = player->actor.shape.rot.y = this->actor.world.rot.y; player->actor.world.rot.x = player->actor.shape.rot.x = this->actor.world.rot.x; @@ -603,17 +594,17 @@ void EnDragon_Attack(EnDragon* this, GlobalContext* globalCtx) { Math_Vec3f_Copy(&player->actor.world.pos, &this->playerGrabPosition); this->jawZRotation = 0xC8; - Math_Vec3f_Copy(&sp4C, &this->burrowEntrancePos); - sp4C.x += Math_SinS(this->actor.world.rot.y) * -530.0f; - sp4C.z += Math_CosS(this->actor.world.rot.y) * -530.0f; - Math_ApproachF(&this->actor.world.pos.x, sp4C.x, 0.3f, 200.0f); - Math_ApproachF(&this->actor.world.pos.y, sp4C.y, 0.3f, 200.0f); - Math_ApproachF(&this->actor.world.pos.z, sp4C.z, 0.3f, 200.0f); + Math_Vec3f_Copy(&pos, &this->burrowEntrancePos); + pos.x += Math_SinS(this->actor.world.rot.y) * -530.0f; + pos.z += Math_CosS(this->actor.world.rot.y) * -530.0f; + Math_ApproachF(&this->actor.world.pos.x, pos.x, 0.3f, 200.0f); + Math_ApproachF(&this->actor.world.pos.y, pos.y, 0.3f, 200.0f); + Math_ApproachF(&this->actor.world.pos.z, pos.z, 0.3f, 200.0f); if ((this->state <= DEEP_PYTHON_ATTACK_STATE_START) && (this->endFrame <= currentFrame)) { Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_UTSUBO_BITE); - if (this->animationIndex != DEEP_PYTHON_ANIMATION_LARGE_SIDE_SWAY) { - EnDragon_ChangeAnimation(this, DEEP_PYTHON_ANIMATION_LARGE_SIDE_SWAY); + if (this->animIndex != DEEP_PYTHON_ANIM_LARGE_SIDE_SWAY) { + EnDragon_ChangeAnim(this, DEEP_PYTHON_ANIM_LARGE_SIDE_SWAY); } this->state++; @@ -641,7 +632,7 @@ void EnDragon_Attack(EnDragon* this, GlobalContext* globalCtx) { } } -void EnDragon_SetupDead(EnDragon* this, GlobalContext* globalCtx) { +void EnDragon_SetupDead(EnDragon* this, PlayState* play) { if (!ActorCutscene_GetCanPlayNext(this->deathCutsceneIndex)) { ActorCutscene_SetIntentToPlay(this->deathCutsceneIndex); } else { @@ -653,21 +644,21 @@ void EnDragon_SetupDead(EnDragon* this, GlobalContext* globalCtx) { } } -void EnDragon_Dead(EnDragon* this, GlobalContext* globalCtx) { +void EnDragon_Dead(EnDragon* this, PlayState* play) { Vec3f seahorsePos; SkelAnime_Update(&this->skelAnime); this->actor.shape.rot.z += 0x1000; this->jawZRotation = 0xFA0; - EnDragon_SpawnBubbles(this, globalCtx, this->jawPos); + EnDragon_SpawnBubbles(this, play, 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); + //! @bug: !play->gameplayFrames is 0 essentially all the time, so this code never runs. + if (((!play->gameplayFrames) & 0x1F)) { + Item_DropCollectibleRandom(play, NULL, &this->jawPos, 0x90); } } @@ -689,7 +680,7 @@ void EnDragon_Dead(EnDragon* this, GlobalContext* globalCtx) { 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, + if (Actor_SpawnAsChildAndCutscene(&play->actorCtx, play, ACTOR_EN_OT, seahorsePos.x, seahorsePos.y, seahorsePos.z, 0, this->actor.shape.rot.y, 0, 0x4000, this->actor.cutscene, this->actor.unk20, NULL)) { gSaveContext.save.weekEventReg[13] |= 1; @@ -731,11 +722,11 @@ void EnDragon_Dead(EnDragon* this, GlobalContext* globalCtx) { Actor_MarkForDeath(&this->actor); } -void EnDragon_UpdateDamage(EnDragon* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); +void EnDragon_UpdateDamage(EnDragon* this, PlayState* play) { + Player* player = GET_PLAYER(play); u32 sp30; - if ((this->action == DEEP_PYTHON_ACTION_EXTEND)) { + 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) || @@ -748,7 +739,7 @@ void EnDragon_UpdateDamage(EnDragon* this, GlobalContext* globalCtx) { Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_UTSUBO_DAMAGE); this->action = DEEP_PYTHON_ACTION_DAMAGE; } else { - Enemy_StartFinishingBlow(globalCtx, &this->actor); + Enemy_StartFinishingBlow(play, &this->actor); Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_UTSUBO_DEAD); this->actor.flags |= ACTOR_FLAG_8000000; this->actor.flags &= ~ACTOR_FLAG_1; @@ -761,7 +752,7 @@ void EnDragon_UpdateDamage(EnDragon* this, GlobalContext* globalCtx) { 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))) { + (!(func_800B64FC(play, 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; @@ -769,7 +760,7 @@ void EnDragon_UpdateDamage(EnDragon* this, GlobalContext* globalCtx) { } } -void EnDragon_Update(Actor* thisx, GlobalContext* globalCtx) { +void EnDragon_Update(Actor* thisx, PlayState* play) { s32 pad; EnDragon* this = THIS; @@ -789,27 +780,26 @@ void EnDragon_Update(Actor* thisx, GlobalContext* globalCtx) { this->grabWaitTimer--; } - EnDragon_UpdateDamage(this, globalCtx); + EnDragon_UpdateDamage(this, play); 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); + this->actionFunc(this, play); Actor_MoveWithGravity(&this->actor); if (this->action != DEEP_PYTHON_ACTION_GRAB) { - CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + CollisionCheck_SetOC(play, &play->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); + CollisionCheck_SetAC(play, &play->colChkCtx, &this->collider.base); + CollisionCheck_SetAT(play, &play->colChkCtx, &this->collider.base); } } -s32 EnDragon_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, - Actor* thisx) { +s32 EnDragon_OverrideLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, Actor* thisx) { EnDragon* this = THIS; if (limbIndex == DEEP_PYTHON_LIMB_JAW) { @@ -821,30 +811,30 @@ s32 EnDragon_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dLi return false; } -void EnDragon_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx) { +void EnDragon_PostLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx) { EnDragon* this = THIS; Vec3f playerGrabOffsetFromJawPos = { 350.0f, -120.0f, -60.0f }; if (limbIndex == DEEP_PYTHON_LIMB_JAW) { - Matrix_MultiplyVector3fByState(&gZeroVec3f, &this->jawPos); + Matrix_MultVec3f(&gZeroVec3f, &this->jawPos); playerGrabOffsetFromJawPos.x = 350.0f; playerGrabOffsetFromJawPos.y = -120.0f; playerGrabOffsetFromJawPos.z = -60.0f; - Matrix_MultiplyVector3fByState(&playerGrabOffsetFromJawPos, &this->playerGrabPosition); + Matrix_MultVec3f(&playerGrabOffsetFromJawPos, &this->playerGrabPosition); } if (limbIndex == DEEP_PYTHON_LIMB_HEAD_AND_COLLAR_ROOT) { - Matrix_MultiplyVector3fByState(&gZeroVec3f, &this->focusPos); + Matrix_MultVec3f(&gZeroVec3f, &this->focusPos); } Collider_UpdateSpheres(limbIndex, &this->collider); } -void EnDragon_Draw(Actor* thisx, GlobalContext* globalCtx) { +void EnDragon_Draw(Actor* thisx, PlayState* play) { 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, + func_8012C28C(play->state.gfxCtx); + func_8012C2DC(play->state.gfxCtx); + SkelAnime_DrawFlexOpa(play, 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 c7ec4d81e..321d0ad95 100644 --- a/src/overlays/actors/ovl_En_Dragon/z_en_dragon.h +++ b/src/overlays/actors/ovl_En_Dragon/z_en_dragon.h @@ -6,9 +6,19 @@ #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 void (*EnDragonActionFunc)(struct EnDragon*, PlayState*); typedef struct EnDragon { /* 0x000 */ Actor actor; @@ -16,13 +26,13 @@ typedef struct EnDragon { /* 0x188 */ Vec3s jointTable[DEEP_PYTHON_LIMB_MAX]; /* 0x1E8 */ Vec3s morphTable[DEEP_PYTHON_LIMB_MAX]; /* 0x248 */ EnDragonActionFunc actionFunc; - /* 0x24C */ s32 animationIndex; + /* 0x24C */ s32 animIndex; /* 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; + /* 0x278 */ Vec3f subCamEye; + /* 0x278 */ Vec3f subCamAt; /* 0x290 */ Vec3f playerGrabPositionTemp; /* 0x29C */ Vec3f focusPos; /* 0x2A8 */ s16 jawZRotation; @@ -40,7 +50,7 @@ typedef struct EnDragon { /* 0x2C0 */ s16 grabCutsceneIndex; /* 0x2C2 */ s16 deathCutsceneIndex; /* 0x2C4 */ UNK_TYPE1 unk_2C4[0x4]; - /* 0x2C8 */ s16 cameraId; + /* 0x2C8 */ s16 subCamId; /* 0x2CA */ s16 grabTimer; // Counts up from the time a grab starts until the time the actor begins attacking /* 0x2CC */ s16 unk_2CC; // Initialized, but never used /* 0x2CE */ UNK_TYPE1 unk_2CE[0x2]; diff --git a/src/overlays/actors/ovl_En_Drs/z_en_drs.c b/src/overlays/actors/ovl_En_Drs/z_en_drs.c index 74f4f19cc..5ecab4fd4 100644 --- a/src/overlays/actors/ovl_En_Drs/z_en_drs.c +++ b/src/overlays/actors/ovl_En_Drs/z_en_drs.c @@ -10,12 +10,12 @@ #define THIS ((EnDrs*)thisx) -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 EnDrs_Init(Actor* thisx, PlayState* play); +void EnDrs_Destroy(Actor* thisx, PlayState* play); +void EnDrs_Update(Actor* thisx, PlayState* play); +void EnDrs_Draw(Actor* thisx, PlayState* play); -void EnDrs_Idle(EnDrs* this, GlobalContext* globalCtx); +void EnDrs_Idle(EnDrs* this, PlayState* play); const ActorInit En_Drs_InitVars = { ACTOR_EN_DRS, @@ -51,22 +51,22 @@ static ColliderCylinderInit sCylinderInit = { static CollisionCheckInfoInit2 sColChkInfoInit = { 0, 0, 0, 0, MASS_IMMOVABLE }; -static AnimationInfoS sAnimations = { &gWeddingDressMannequinIdleAnim, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }; +static AnimationInfoS sAnimationInfo = { &gWeddingDressMannequinIdleAnim, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }; -void EnDrs_CollisionUpdate(EnDrs* this, GlobalContext* globalCtx) { +void EnDrs_CollisionUpdate(EnDrs* this, PlayState* play) { Collider_UpdateCylinder(&this->actor, &this->collider); - CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + CollisionCheck_SetOC(play, &play->colChkCtx, &this->collider.base); } -void EnDrs_Setup(EnDrs* this, GlobalContext* globalCtx) { +void EnDrs_Setup(EnDrs* this, PlayState* play) { s32 pad[2]; - if ((this->moonMaskObjBankIndex >= 0) && SubS_IsObjectLoaded(this->moonMaskObjBankIndex, globalCtx)) { + if ((this->moonMaskObjBankIndex >= 0) && SubS_IsObjectLoaded(this->moonMaskObjBankIndex, play)) { ActorShape_Init(&this->actor.shape, 0.0f, NULL, 0.0f); - SkelAnime_InitFlex(globalCtx, &this->skelAnime, &gWeddingDressMannequinSkel, NULL, this->jointTable, + SkelAnime_InitFlex(play, &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); + SubS_ChangeAnimationByInfoS(&this->skelAnime, &sAnimationInfo, 0); + Collider_InitAndSetCylinder(play, &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; @@ -74,53 +74,53 @@ void EnDrs_Setup(EnDrs* this, GlobalContext* globalCtx) { } } -void EnDrs_Idle(EnDrs* this, GlobalContext* globalCtx) { +void EnDrs_Idle(EnDrs* this, PlayState* play) { } -void EnDrs_Init(Actor* thisx, GlobalContext* globalCtx) { +void EnDrs_Init(Actor* thisx, PlayState* play) { EnDrs* this = THIS; - this->moonMaskObjBankIndex = SubS_GetObjectIndex(OBJECT_MSMO, globalCtx); + this->moonMaskObjBankIndex = SubS_GetObjectIndex(OBJECT_MSMO, play); this->actionFunc = EnDrs_Setup; } -void EnDrs_Destroy(Actor* thisx, GlobalContext* globalCtx) { +void EnDrs_Destroy(Actor* thisx, PlayState* play) { EnDrs* this = THIS; - Collider_DestroyCylinder(globalCtx, &this->collider); + Collider_DestroyCylinder(play, &this->collider); } -void EnDrs_Update(Actor* thisx, GlobalContext* globalCtx) { +void EnDrs_Update(Actor* thisx, PlayState* play) { EnDrs* this = THIS; - this->actionFunc(this, globalCtx); + this->actionFunc(this, play); if (this->actor.draw != NULL) { SkelAnime_Update(&this->skelAnime); - EnDrs_CollisionUpdate(this, globalCtx); + EnDrs_CollisionUpdate(this, play); } } -void EnDrs_PostLimbDraw(GlobalContext* globalCtx2, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx) { +void EnDrs_PostLimbDraw(PlayState* play2, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx) { EnDrs* this = THIS; - GlobalContext* globalCtx = globalCtx2; + PlayState* play = play2; 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); + OPEN_DISPS(play->state.gfxCtx); + gSPSegment(POLY_OPA_DISP++, 0x06, play->objectCtx.status[temp].segment); gSPDisplayList(POLY_OPA_DISP++, &gMoonMaskDL); - gSPSegment(POLY_OPA_DISP++, 0x06, globalCtx->objectCtx.status[temp2].segment); - CLOSE_DISPS(globalCtx->state.gfxCtx); + gSPSegment(POLY_OPA_DISP++, 0x06, play->objectCtx.status[temp2].segment); + CLOSE_DISPS(play->state.gfxCtx); } } -void EnDrs_Draw(Actor* thisx, GlobalContext* globalCtx) { +void EnDrs_Draw(Actor* thisx, PlayState* play) { 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); + func_8012C5B0(play->state.gfxCtx); + SkelAnime_DrawFlexOpa(play, 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 1f59d601b..d86121efb 100644 --- a/src/overlays/actors/ovl_En_Drs/z_en_drs.h +++ b/src/overlays/actors/ovl_En_Drs/z_en_drs.h @@ -7,7 +7,7 @@ struct EnDrs; -typedef void (*EnDrsActionFunc)(struct EnDrs*, GlobalContext*); +typedef void (*EnDrsActionFunc)(struct EnDrs*, PlayState*); typedef struct EnDrs { /* 0x000 */ Actor actor; 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 c47961a6d..7e517ce09 100644 --- a/src/overlays/actors/ovl_En_Ds2n/z_en_ds2n.c +++ b/src/overlays/actors/ovl_En_Ds2n/z_en_ds2n.c @@ -2,6 +2,9 @@ * File: z_en_ds2n.c * Overlay: ovl_En_Ds2n * Description: Potion Shop Owner from OoT (unused) + * + * This actor was placed in the Staff Office of Stockpot inn + * but does not spawn because their object is missing. */ #include "z_en_ds2n.h" @@ -10,12 +13,13 @@ #define THIS ((EnDs2n*)thisx) -void EnDs2n_Init(Actor* thisx, GlobalContext* globalCtx); -void EnDs2n_Destroy(Actor* thisx, GlobalContext* globalCtx); -void EnDs2n_Update(Actor* thisx, GlobalContext* globalCtx); -void EnDs2n_Draw(Actor* thisx, GlobalContext* globalCtx); +void EnDs2n_Init(Actor* thisx, PlayState* play); +void EnDs2n_Destroy(Actor* thisx, PlayState* play); +void EnDs2n_Update(Actor* thisx, PlayState* play); +void EnDs2n_Draw(Actor* thisx, PlayState* play); + +void EnDs2n_Idle(EnDs2n* this, PlayState* play); -#if 0 const ActorInit En_Ds2n_InitVars = { ACTOR_EN_DS2N, ACTORCAT_NPC, @@ -28,24 +32,102 @@ const ActorInit En_Ds2n_InitVars = { (ActorFunc)EnDs2n_Draw, }; -#endif +static AnimationInfo sAnimationInfo[] = { + { &gDs2nIdleAnim, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, 0.0f }, +}; -extern UNK_TYPE D_06008038; +static Vec3f sZeroVec = { 0, 0, 0 }; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ds2n/func_80AE1650.s") +static TexturePtr sEyeTextures[] = { gDs2nEyeOpenTex, gDs2nEyeHalfTex, gDs2nEyeClosedTex }; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ds2n/func_80AE16A0.s") +void EnDs2n_SetupIdle(EnDs2n* this) { + this->blinkTimer = 20; + this->blinkState = 0; + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, 0); + this->actionFunc = EnDs2n_Idle; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ds2n/func_80AE16D8.s") +void EnDs2n_Idle(EnDs2n* this, PlayState* play) { + SubS_FillLimbRotTables(play, this->limbRotTableY, this->limbRotTableZ, DS2N_LIMB_MAX); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ds2n/EnDs2n_Init.s") +void EnDs2n_UpdateEyes(EnDs2n* this) { + s16 nextBlinkTime = this->blinkTimer - 1; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ds2n/EnDs2n_Destroy.s") + if (nextBlinkTime >= 3) { + this->blinkState = 0; + this->blinkTimer = nextBlinkTime; + } else if (nextBlinkTime == 0) { + this->blinkState = 2; + this->blinkTimer = (s32)(Rand_ZeroOne() * 60.0f) + 20; + } else { + this->blinkState = 1; + this->blinkTimer = nextBlinkTime; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ds2n/EnDs2n_Update.s") +void EnDs2n_Init(Actor* thisx, PlayState* play) { + EnDs2n* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ds2n/func_80AE1874.s") + ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 20.0f); + SkelAnime_InitFlex(play, &this->skelAnime, &gDs2nSkeleton, &gDs2nIdleAnim, NULL, NULL, 0); + EnDs2n_SetupIdle(this); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ds2n/func_80AE18B4.s") +void EnDs2n_Destroy(Actor* thisx, PlayState* play) { + EnDs2n* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ds2n/EnDs2n_Draw.s") + SkelAnime_Free(&this->skelAnime, play); +} + +void EnDs2n_Update(Actor* thisx, PlayState* play) { + EnDs2n* this = THIS; + + this->actionFunc(this, play); + Actor_MoveWithGravity(&this->actor); + SkelAnime_Update(&this->skelAnime); + + Actor_TrackPlayer(play, &this->actor, &this->headRot, &this->chestRot, this->actor.focus.pos); + EnDs2n_UpdateEyes(this); +} + +s32 EnDs2n_OverrideLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, Actor* thisx) { + EnDs2n* this = THIS; + + if (limbIndex == DS2N_LIMB_HEAD) { + Matrix_RotateXS(this->headRot.y, MTXMODE_APPLY); + } + + return false; +} + +void EnDs2n_PostLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx) { + EnDs2n* this = THIS; + Vec3f focusOffset = sZeroVec; + + if ((limbIndex == DS2N_LIMB_HIPS) || (limbIndex == DS2N_LIMB_LEFT_UPPER_ARM) || + (limbIndex == DS2N_LIMB_RIGHT_UPPER_ARM)) { + rot->y += (s16)Math_SinS(this->limbRotTableY[limbIndex]) * 0xC8; + rot->z += (s16)Math_CosS(this->limbRotTableZ[limbIndex]) * 0xC8; + } + + if (limbIndex == DS2N_LIMB_HEAD) { + Matrix_MultVec3f(&focusOffset, &thisx->focus.pos); + } +} + +void EnDs2n_Draw(Actor* thisx, PlayState* play) { + EnDs2n* this = THIS; + + OPEN_DISPS(play->state.gfxCtx); + + func_8012C5B0(play->state.gfxCtx); + gSPSegment(POLY_OPA_DISP++, 0x08, Lib_SegmentedToVirtual(sEyeTextures[this->blinkState])); + + gSPSegment(POLY_OPA_DISP++, 0x09, Lib_SegmentedToVirtual(sEyeTextures[this->blinkState])); + + SkelAnime_DrawFlexOpa(play, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, + EnDs2n_OverrideLimbDraw, EnDs2n_PostLimbDraw, &this->actor); + + CLOSE_DISPS(play->state.gfxCtx); +} diff --git a/src/overlays/actors/ovl_En_Ds2n/z_en_ds2n.h b/src/overlays/actors/ovl_En_Ds2n/z_en_ds2n.h index 83a7ac8ec..c7155ed74 100644 --- a/src/overlays/actors/ovl_En_Ds2n/z_en_ds2n.h +++ b/src/overlays/actors/ovl_En_Ds2n/z_en_ds2n.h @@ -2,16 +2,24 @@ #define Z_EN_DS2N_H #include "global.h" +#include "objects/object_ds2n/object_ds2n.h" struct EnDs2n; -typedef void (*EnDs2nActionFunc)(struct EnDs2n*, GlobalContext*); +typedef void (*EnDs2nActionFunc)(struct EnDs2n*, PlayState*); typedef struct EnDs2n { - /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x90]; - /* 0x01D4 */ EnDs2nActionFunc actionFunc; - /* 0x01D8 */ char unk_1D8[0x5C]; + /* 0x000 */ Actor actor; + /* 0x144 */ ColliderCylinder collider; // unused + /* 0x190 */ SkelAnime skelAnime; + /* 0x1D4 */ EnDs2nActionFunc actionFunc; + /* 0x1D8 */ s16 limbRotTableY[DS2N_LIMB_MAX]; + /* 0x1FE */ s16 limbRotTableZ[DS2N_LIMB_MAX]; + /* 0x224 */ Vec3s headRot; + /* 0x22A */ Vec3s chestRot; // set by function, but not applied in limbdraw + /* 0x230 */ s16 blinkState; + /* 0x232 */ s16 blinkTimer; + } EnDs2n; // size = 0x234 extern const ActorInit En_Ds2n_InitVars; diff --git a/src/overlays/actors/ovl_En_Dt/z_en_dt.c b/src/overlays/actors/ovl_En_Dt/z_en_dt.c index 0501b728c..d4b809027 100644 --- a/src/overlays/actors/ovl_En_Dt/z_en_dt.c +++ b/src/overlays/actors/ovl_En_Dt/z_en_dt.c @@ -10,10 +10,10 @@ #define THIS ((EnDt*)thisx) -void EnDt_Init(Actor* thisx, GlobalContext* globalCtx); -void EnDt_Destroy(Actor* thisx, GlobalContext* globalCtx); -void EnDt_Update(Actor* thisx, GlobalContext* globalCtx); -void EnDt_Draw(Actor* thisx, GlobalContext* globalCtx); +void EnDt_Init(Actor* thisx, PlayState* play); +void EnDt_Destroy(Actor* thisx, PlayState* play); +void EnDt_Update(Actor* thisx, PlayState* play); +void EnDt_Draw(Actor* thisx, PlayState* play); #if 0 const ActorInit En_Dt_InitVars = { diff --git a/src/overlays/actors/ovl_En_Dt/z_en_dt.h b/src/overlays/actors/ovl_En_Dt/z_en_dt.h index 0292a8f52..78b098789 100644 --- a/src/overlays/actors/ovl_En_Dt/z_en_dt.h +++ b/src/overlays/actors/ovl_En_Dt/z_en_dt.h @@ -5,13 +5,13 @@ struct EnDt; -typedef void (*EnDtActionFunc)(struct EnDt*, GlobalContext*); +typedef void (*EnDtActionFunc)(struct EnDt*, PlayState*); typedef struct EnDt { - /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0xF8]; - /* 0x023C */ EnDtActionFunc actionFunc; - /* 0x0240 */ char unk_240[0xA0]; + /* 0x000 */ Actor actor; + /* 0x144 */ char unk_144[0xF8]; + /* 0x23C */ EnDtActionFunc actionFunc; + /* 0x240 */ char unk_240[0xA0]; } EnDt; // size = 0x2E0 extern const ActorInit En_Dt_InitVars; diff --git a/src/overlays/actors/ovl_En_Dy_Extra/z_en_dy_extra.c b/src/overlays/actors/ovl_En_Dy_Extra/z_en_dy_extra.c index 40e06787c..7770cc3ec 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 @@ -11,13 +11,13 @@ #define THIS ((EnDyExtra*)thisx) -void EnDyExtra_Init(Actor* thisx, GlobalContext* globalCtx); -void EnDyExtra_Destroy(Actor* thisx, GlobalContext* globalCtx); -void EnDyExtra_Update(Actor* thisx, GlobalContext* globalCtx); -void EnDyExtra_Draw(Actor* thisx, GlobalContext* globalCtx); +void EnDyExtra_Init(Actor* thisx, PlayState* play); +void EnDyExtra_Destroy(Actor* thisx, PlayState* play); +void EnDyExtra_Update(Actor* thisx, PlayState* play); +void EnDyExtra_Draw(Actor* thisx, PlayState* play); -void func_80A61334(EnDyExtra* this, GlobalContext* globalCtx); -void func_80A613C8(EnDyExtra* this, GlobalContext* globalCtx); +void func_80A61334(EnDyExtra* this, PlayState* play); +void func_80A613C8(EnDyExtra* this, PlayState* play); const ActorInit En_Dy_Extra_InitVars = { ACTOR_EN_DY_EXTRA, @@ -31,10 +31,10 @@ const ActorInit En_Dy_Extra_InitVars = { (ActorFunc)EnDyExtra_Draw, }; -void EnDyExtra_Destroy(Actor* thisx, GlobalContext* globalCtx) { +void EnDyExtra_Destroy(Actor* thisx, PlayState* play) { } -void EnDyExtra_Init(Actor* thisx, GlobalContext* globalCtx) { +void EnDyExtra_Init(Actor* thisx, PlayState* play) { EnDyExtra* this = THIS; this->type = this->actor.params; @@ -48,7 +48,7 @@ void EnDyExtra_Init(Actor* thisx, GlobalContext* globalCtx) { this->actionFunc = func_80A61334; } -void func_80A61334(EnDyExtra* this, GlobalContext* globalCtx) { +void func_80A61334(EnDyExtra* this, PlayState* play) { Math_ApproachF(&this->actor.gravity, 0.0f, 0.1f, 0.005f); if (this->actor.world.pos.y < -85.0f) { @@ -61,7 +61,7 @@ void func_80A61334(EnDyExtra* this, GlobalContext* globalCtx) { } } -void func_80A613C8(EnDyExtra* this, GlobalContext* globalCtx) { +void func_80A613C8(EnDyExtra* this, PlayState* play) { Math_ApproachF(&this->actor.gravity, 0.0f, 0.1f, 0.005f); if (this->unk14C == 0 || this->unk150 < 0.02f) { @@ -76,16 +76,16 @@ void func_80A613C8(EnDyExtra* this, GlobalContext* globalCtx) { } } -void EnDyExtra_Update(Actor* thisx, GlobalContext* globalCtx) { +void EnDyExtra_Update(Actor* thisx, PlayState* play) { EnDyExtra* this = THIS; DECR(this->unk14C); Actor_PlaySfxAtPos(&this->actor, NA_SE_PL_SPIRAL_HEAL_BEAM - SFX_FLAG); - this->actionFunc(this, globalCtx); + this->actionFunc(this, play); Actor_MoveWithGravity(&this->actor); } -void EnDyExtra_Draw(Actor* thisx, GlobalContext* globalCtx) { +void EnDyExtra_Draw(Actor* thisx, PlayState* play) { static Color_RGBA8 D_80A61740[] = { { 255, 255, 170, 255 }, { 255, 170, 255, 255 }, { 255, 255, 170, 255 }, { 170, 255, 255, 255 }, { 255, 255, 170, 255 }, @@ -97,7 +97,7 @@ void EnDyExtra_Draw(Actor* thisx, GlobalContext* globalCtx) { 0x00, 0x02, 0x01, 0x00, 0x02, 0x01, 0x00, 0x02, 0x01, 0x00, 0x01, 0x02, 0x00, 0x00 }; EnDyExtra* this = THIS; s32 pad; - GraphicsContext* gfxCtx = globalCtx->state.gfxCtx; + GraphicsContext* gfxCtx = play->state.gfxCtx; Vtx* vertices = Lib_SegmentedToVirtual(object_dy_obj_Vtx_00DD40); s32 i; u8 unk[3]; @@ -114,12 +114,12 @@ void EnDyExtra_Draw(Actor* thisx, GlobalContext* globalCtx) { OPEN_DISPS(gfxCtx); - func_8012C2DC(globalCtx->state.gfxCtx); + func_8012C2DC(play->state.gfxCtx); gSPSegment(POLY_XLU_DISP++, 0x08, - Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, globalCtx->state.frames * 2, 0, 0x20, 0x40, 1, - globalCtx->state.frames, globalCtx->state.frames * -8, 0x10, 0x10)); + Gfx_TwoTexScroll(play->state.gfxCtx, 0, play->state.frames * 2, 0, 0x20, 0x40, 1, play->state.frames, + play->state.frames * -8, 0x10, 0x10)); gDPPipeSync(POLY_XLU_DISP++); - gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gDPSetPrimColor(POLY_XLU_DISP++, 0, 0x80, D_80A61740[this->type].r, D_80A61740[this->type].g, D_80A61740[this->type].b, 255); gDPSetEnvColor(POLY_XLU_DISP++, D_80A61754[this->type].r, D_80A61754[this->type].g, D_80A61754[this->type].b, 128); diff --git a/src/overlays/actors/ovl_En_Dy_Extra/z_en_dy_extra.h b/src/overlays/actors/ovl_En_Dy_Extra/z_en_dy_extra.h index 752612c97..6d5d93ec4 100644 --- a/src/overlays/actors/ovl_En_Dy_Extra/z_en_dy_extra.h +++ b/src/overlays/actors/ovl_En_Dy_Extra/z_en_dy_extra.h @@ -5,7 +5,7 @@ struct EnDyExtra; -typedef void (*EnDyExtraActionFunc)(struct EnDyExtra*, GlobalContext*); +typedef void (*EnDyExtraActionFunc)(struct EnDyExtra*, PlayState*); typedef struct EnDyExtra { /* 0x000 */ Actor actor; @@ -15,7 +15,7 @@ typedef struct EnDyExtra { /* 0x14C */ s16 unk14C; /* 0x14E */ s16 unk14E; /* 0x150 */ f32 unk150; - /* 0x154 */ char unk154[0xC]; + /* 0x154 */ UNK_TYPE1 unk154[0xC]; /* 0x160 */ Vec3f unk160; } EnDyExtra; // size = 0x16C 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 bea655d9a..4607e2909 100644 --- a/src/overlays/actors/ovl_En_Egblock/z_en_egblock.c +++ b/src/overlays/actors/ovl_En_Egblock/z_en_egblock.c @@ -10,10 +10,10 @@ #define THIS ((EnEgblock*)thisx) -void EnEgblock_Init(Actor* thisx, GlobalContext* globalCtx); -void EnEgblock_Destroy(Actor* thisx, GlobalContext* globalCtx); -void EnEgblock_Update(Actor* thisx, GlobalContext* globalCtx); -void EnEgblock_Draw(Actor* thisx, GlobalContext* globalCtx); +void EnEgblock_Init(Actor* thisx, PlayState* play); +void EnEgblock_Destroy(Actor* thisx, PlayState* play); +void EnEgblock_Update(Actor* thisx, PlayState* play); +void EnEgblock_Draw(Actor* thisx, PlayState* play); #if 0 const ActorInit En_Egblock_InitVars = { diff --git a/src/overlays/actors/ovl_En_Egblock/z_en_egblock.h b/src/overlays/actors/ovl_En_Egblock/z_en_egblock.h index 7719d3706..d1222a5eb 100644 --- a/src/overlays/actors/ovl_En_Egblock/z_en_egblock.h +++ b/src/overlays/actors/ovl_En_Egblock/z_en_egblock.h @@ -5,13 +5,13 @@ struct EnEgblock; -typedef void (*EnEgblockActionFunc)(struct EnEgblock*, GlobalContext*); +typedef void (*EnEgblockActionFunc)(struct EnEgblock*, PlayState*); typedef struct EnEgblock { - /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x5C]; - /* 0x01A0 */ EnEgblockActionFunc actionFunc; - /* 0x01A4 */ char unk_1A4[0xC10]; + /* 0x000 */ Actor actor; + /* 0x144 */ char unk_144[0x5C]; + /* 0x1A0 */ EnEgblockActionFunc actionFunc; + /* 0x1A4 */ char unk_1A4[0xC10]; } EnEgblock; // size = 0xDB4 extern const ActorInit En_Egblock_InitVars; diff --git a/src/overlays/actors/ovl_En_Egol/z_en_egol.c b/src/overlays/actors/ovl_En_Egol/z_en_egol.c index 0111c6cd7..373d06583 100644 --- a/src/overlays/actors/ovl_En_Egol/z_en_egol.c +++ b/src/overlays/actors/ovl_En_Egol/z_en_egol.c @@ -10,10 +10,10 @@ #define THIS ((EnEgol*)thisx) -void EnEgol_Init(Actor* thisx, GlobalContext* globalCtx); -void EnEgol_Destroy(Actor* thisx, GlobalContext* globalCtx); -void EnEgol_Update(Actor* thisx, GlobalContext* globalCtx); -void EnEgol_Draw(Actor* thisx, GlobalContext* globalCtx); +void EnEgol_Init(Actor* thisx, PlayState* play); +void EnEgol_Destroy(Actor* thisx, PlayState* play); +void EnEgol_Update(Actor* thisx, PlayState* play); +void EnEgol_Draw(Actor* thisx, PlayState* play); #if 0 // static ColliderJntSphElementInit sJntSphElementsInit[6] = { @@ -47,7 +47,7 @@ static ColliderJntSphElementInit D_80A80C64[6] = { // static ColliderJntSphInit sJntSphInit = { static ColliderJntSphInit D_80A80D3C = { { COLTYPE_METAL, AT_ON | AT_TYPE_ENEMY, AC_ON | AC_TYPE_PLAYER, OC1_ON | OC1_TYPE_ALL, OC2_TYPE_1, COLSHAPE_JNTSPH, }, - 6, D_80A80C64, // sJntSphElementsInit, + ARRAY_COUNT(sJntSphElementsInit), D_80A80C64, // sJntSphElementsInit, }; // static ColliderJntSphElementInit sJntSphElementsInit[1] = { @@ -61,7 +61,7 @@ static ColliderJntSphElementInit D_80A80C40[1] = { // static ColliderJntSphInit sJntSphInit = { static ColliderJntSphInit D_80A80D4C = { { COLTYPE_NONE, AT_ON | AT_TYPE_ENEMY, AC_ON | AC_TYPE_PLAYER, OC1_ON | OC1_TYPE_ALL, OC2_TYPE_1, COLSHAPE_JNTSPH, }, - 1, D_80A80C40, // sJntSphElementsInit, + ARRAY_COUNT(sJntSphElementsInit), D_80A80C40, // sJntSphElementsInit, }; // static ColliderQuadInit sQuadInit = { diff --git a/src/overlays/actors/ovl_En_Egol/z_en_egol.h b/src/overlays/actors/ovl_En_Egol/z_en_egol.h index 29401bc2c..9e0097152 100644 --- a/src/overlays/actors/ovl_En_Egol/z_en_egol.h +++ b/src/overlays/actors/ovl_En_Egol/z_en_egol.h @@ -5,7 +5,7 @@ struct EnEgol; -typedef void (*EnEgolActionFunc)(struct EnEgol*, GlobalContext*); +typedef void (*EnEgolActionFunc)(struct EnEgol*, PlayState*); typedef struct EnEgol { /* 0x0000 */ Actor actor; 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 62d455147..bc84c329b 100644 --- a/src/overlays/actors/ovl_En_Elf/z_en_elf.c +++ b/src/overlays/actors/ovl_En_Elf/z_en_elf.c @@ -11,27 +11,27 @@ #define THIS ((EnElf*)thisx) -void EnElf_Init(Actor* thisx, GlobalContext* globalCtx); -void EnElf_Destroy(Actor* thisx, GlobalContext* globalCtx); -void EnElf_Update(Actor* thisx, GlobalContext* globalCtx); -void EnElf_Draw(Actor* thisx, GlobalContext* globalCtx); +void EnElf_Init(Actor* thisx, PlayState* play); +void EnElf_Destroy(Actor* thisx, PlayState* play); +void EnElf_Update(Actor* thisx, PlayState* play); +void EnElf_Draw(Actor* thisx, PlayState* play); void EnElf_SetupAction(EnElf* this, EnElfActionFunc actionFunc); -void func_8088C9CC(EnElf* this, GlobalContext* globalCtx); -void func_8088D3EC(EnElf* this, GlobalContext* globalCtx); -void func_8088D470(EnElf* this, GlobalContext* globalCtx); -void func_8088D504(EnElf* this, GlobalContext* globalCtx); -void func_8088DD34(EnElf* this, GlobalContext* globalCtx); -void func_8088E018(EnElf* this, GlobalContext* globalCtx); -void func_8088E0E0(EnElf* this, GlobalContext* globalCtx); -void func_8088E0F0(EnElf* this, GlobalContext* globalCtx); -void func_8088E484(EnElf* this, GlobalContext* globalCtx); -void func_8088E850(EnElf* this, GlobalContext* globalCtx); -void func_8088EFA4(EnElf* this, GlobalContext* globalCtx); -void func_8088F214(EnElf* this, GlobalContext* globalCtx); -void func_8088F5F4(EnElf* this, GlobalContext* globalCtx, s32 arg2); -void func_8089010C(Actor* thisx, GlobalContext* globalCtx); -void func_808908D0(Vec3f* arg0, GlobalContext* globalCtx, u32 arg2); +void func_8088C9CC(EnElf* this, PlayState* play); +void func_8088D3EC(EnElf* this, PlayState* play); +void func_8088D470(EnElf* this, PlayState* play); +void func_8088D504(EnElf* this, PlayState* play); +void func_8088DD34(EnElf* this, PlayState* play); +void func_8088E018(EnElf* this, PlayState* play); +void func_8088E0E0(EnElf* this, PlayState* play); +void func_8088E0F0(EnElf* this, PlayState* play); +void func_8088E484(EnElf* this, PlayState* play); +void func_8088E850(EnElf* this, PlayState* play); +void func_8088EFA4(EnElf* this, PlayState* play); +void func_8088F214(EnElf* this, PlayState* play); +void func_8088F5F4(EnElf* this, PlayState* play, s32 arg2); +void func_8089010C(Actor* thisx, PlayState* play); +void func_808908D0(Vec3f* arg0, PlayState* play, u32 arg2); const ActorInit En_Elf_InitVars = { ACTOR_EN_ELF, @@ -185,8 +185,8 @@ s32 func_8088C804(Vec3f* arg0, Vec3f* arg1, f32 arg2) { return SQ(arg2) < SQ(arg1->x - arg0->x) + SQ(arg1->z - arg0->z); } -void func_8088C858(EnElf* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); +void func_8088C858(EnElf* this, PlayState* play) { + Player* player = GET_PLAYER(play); if (!func_8088C804(&this->actor.world.pos, &player->actor.world.pos, 30.0f)) { this->unk_254 = 0.5f; @@ -204,8 +204,8 @@ void func_8088C858(EnElf* this, GlobalContext* globalCtx) { } } -void func_8088C920(EnElf* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); +void func_8088C920(EnElf* this, PlayState* play) { + Player* player = GET_PLAYER(play); if (func_8088C804(&this->actor.world.pos, &player->actor.world.pos, 50.0f)) { if (this->unk_25C > 0) { @@ -220,7 +220,7 @@ void func_8088C920(EnElf* this, GlobalContext* globalCtx) { } } -void func_8088C9CC(EnElf* this, GlobalContext* globalCtx) { +void func_8088C9CC(EnElf* this, PlayState* play) { f32 xzDistToPlayer; if (this->unk_25C > 0) { @@ -266,7 +266,7 @@ void func_8088C9CC(EnElf* this, GlobalContext* globalCtx) { } } -void func_8088CBAC(EnElf* this, GlobalContext* globalCtx) { +void func_8088CBAC(EnElf* this, PlayState* play) { f32 phi_f0; if (this->fairyFlags & 0x4000) { @@ -281,11 +281,11 @@ void func_8088CBAC(EnElf* this, GlobalContext* globalCtx) { this->unk_254 = 1.5f; this->unk_26C = func_8088C9CC; } else { - this->unk_26C(this, globalCtx); + this->unk_26C(this, play); } } -void func_8088CC48(EnElf* this, GlobalContext* globalCtx) { +void func_8088CC48(EnElf* this, PlayState* play) { EnElf_SetupAction(this, func_8088DD34); this->unk_250 = Rand_ZeroFloat(10.0f) + 10.0f; this->unk_246 = 0; @@ -293,10 +293,10 @@ void func_8088CC48(EnElf* this, GlobalContext* globalCtx) { this->unk_224 = this->actor.world.pos; this->unk_258 = randPlusMinusPoint5Scaled(0x7FFF); this->unk_26C = func_8088C9CC; - func_8088CBAC(this, globalCtx); + func_8088CBAC(this, play); this->unk_25C = 0; this->disappearTimer = 240; - if ((this->fairyFlags & 0x400) && Flags_GetCollectible(globalCtx, this->unk_260)) { + if ((this->fairyFlags & 0x400) && Flags_GetCollectible(play, this->unk_260)) { Actor_MarkForDeath(&this->actor); } } @@ -313,25 +313,25 @@ f32 func_8088CD3C(s32 colorFlag) { return 0.0f; } -void EnElf_Init(Actor* thisx, GlobalContext* globalCtx2) { - GlobalContext* globalCtx = globalCtx2; +void EnElf_Init(Actor* thisx, PlayState* play2) { + PlayState* play = play2; EnElf* this = THIS; - Player* player = GET_PLAYER(globalCtx); + Player* player = GET_PLAYER(play); s32 colorConfig; s32 params; Actor_ProcessInitChain(thisx, sInitChain); - SkelAnime_Init(globalCtx, &this->skelAnime, &gameplay_keep_Skel_02AF58.sh, &gameplay_keep_Anim_029140, - this->jointTable, this->morphTable, 7); + SkelAnime_Init(play, &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); thisx->shape.shadowAlpha = 255; Lights_PointGlowSetInfo(&this->lightInfoGlow, thisx->world.pos.x, thisx->world.pos.y, thisx->world.pos.z, 255, 255, 255, 0); - this->lightNodeGlow = LightContext_InsertLight(globalCtx, &globalCtx->lightCtx, &this->lightInfoGlow); + this->lightNodeGlow = LightContext_InsertLight(play, &play->lightCtx, &this->lightInfoGlow); Lights_PointNoGlowSetInfo(&this->lightInfoNoGlow, thisx->world.pos.x, thisx->world.pos.y, thisx->world.pos.z, 255, 255, 255, 0); - this->lightNodeNoGlow = LightContext_InsertLight(globalCtx, &globalCtx->lightCtx, &this->lightInfoNoGlow); + this->lightNodeNoGlow = LightContext_InsertLight(play, &play->lightCtx, &this->lightInfoNoGlow); this->fairyFlags = 0; this->disappearTimer = 600; @@ -358,7 +358,7 @@ void EnElf_Init(Actor* thisx, GlobalContext* globalCtx2) { if ((gSaveContext.save.playerData.tatlTimer >= 25800) || (gSaveContext.save.playerData.tatlTimer < 3000)) { gSaveContext.save.playerData.tatlTimer = 0; } - this->unk_266 = ElfMessage_GetFirstCycleHint(globalCtx); + this->unk_266 = ElfMessage_GetFirstCycleHint(play); break; case 1: @@ -391,7 +391,7 @@ void EnElf_Init(Actor* thisx, GlobalContext* globalCtx2) { colorConfig = -1; this->fairyFlags |= 0x800; this->fairyFlags |= 0x1000; - func_8088CC48(this, globalCtx); + func_8088CC48(this, play); break; case 2: @@ -400,7 +400,7 @@ void EnElf_Init(Actor* thisx, GlobalContext* globalCtx2) { this->fairyFlags |= 0x800; this->fairyFlags |= 0x2000; this->fairyFlags |= 0x1000; - func_8088CC48(this, globalCtx); + func_8088CC48(this, play); break; case 6: @@ -408,7 +408,7 @@ void EnElf_Init(Actor* thisx, GlobalContext* globalCtx2) { this->fairyFlags |= 0x800; this->fairyFlags |= 0x2000; this->fairyFlags |= 0x1000; - func_8088CC48(this, globalCtx); + func_8088CC48(this, play); break; case 9: @@ -416,7 +416,7 @@ void EnElf_Init(Actor* thisx, GlobalContext* globalCtx2) { case 10: colorConfig = -2; - func_8088CC48(this, globalCtx); + func_8088CC48(this, play); break; case 8: @@ -437,8 +437,8 @@ void EnElf_Init(Actor* thisx, GlobalContext* globalCtx2) { s32 i; for (i = 0; i < 8; i++) { - Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_ELF, thisx->world.pos.x, - thisx->world.pos.y - 30.0f, thisx->world.pos.z, 0, 0, 0, 6); + Actor_Spawn(&play->actorCtx, play, ACTOR_EN_ELF, thisx->world.pos.x, thisx->world.pos.y - 30.0f, + thisx->world.pos.z, 0, 0, 0, 6); } } break; @@ -457,15 +457,15 @@ void EnElf_Init(Actor* thisx, GlobalContext* globalCtx2) { } } -void EnElf_Destroy(Actor* thisx, GlobalContext* globalCtx) { +void EnElf_Destroy(Actor* thisx, PlayState* play) { s32 pad; EnElf* this = THIS; - LightContext_RemoveLight(globalCtx, &globalCtx->lightCtx, this->lightNodeGlow); - LightContext_RemoveLight(globalCtx, &globalCtx->lightCtx, this->lightNodeNoGlow); + LightContext_RemoveLight(play, &play->lightCtx, this->lightNodeGlow); + LightContext_RemoveLight(play, &play->lightCtx, this->lightNodeNoGlow); } -void func_8088D3EC(EnElf* this, GlobalContext* globalCtx) { +void func_8088D3EC(EnElf* this, PlayState* play) { this->unk_224.x = Math_SinS(this->unk_248) * this->unk_254; this->unk_224.y = Math_SinS(this->unk_246) * this->unk_250; this->unk_224.z = Math_CosS(this->unk_248) * this->unk_254; @@ -473,7 +473,7 @@ void func_8088D3EC(EnElf* this, GlobalContext* globalCtx) { this->unk_246 += this->unk_24A; } -void func_8088D470(EnElf* this, GlobalContext* globalCtx) { +void func_8088D470(EnElf* this, PlayState* play) { f32 xzScale = (Math_CosS(this->unk_246) * this->unk_250) + this->unk_254; this->unk_224.x = Math_SinS(this->unk_248) * xzScale; @@ -484,8 +484,8 @@ void func_8088D470(EnElf* this, GlobalContext* globalCtx) { this->unk_246 += this->unk_24A; } -void func_8088D504(EnElf* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); +void func_8088D504(EnElf* this, PlayState* play) { + Player* player = GET_PLAYER(play); this->unk_246 = (this->unk_248 * 2) & 0xFFFF; this->unk_224.x = Math_SinS(this->unk_248) * this->unk_254; @@ -551,9 +551,9 @@ void func_8088D8D0(EnElf* this, Vec3f* arg1) { Math_StepToF(&this->actor.velocity.y, yVelAbs * yVelDirection, 1.5f); } -void func_8088D9BC(EnElf* this, GlobalContext* globalCtx) { +void func_8088D9BC(EnElf* this, PlayState* play) { s32 pad[2]; - Player* player = GET_PLAYER(globalCtx); + Player* player = GET_PLAYER(play); s16 targetYaw; Vec3f* vec = &this->unk_224; @@ -634,10 +634,10 @@ s32 func_8088DCA4(EnElf* this) { return false; } -void func_8088DD34(EnElf* this, GlobalContext* globalCtx) { - Player* refActor = GET_PLAYER(globalCtx); +void func_8088DD34(EnElf* this, PlayState* play) { + Player* refActor = GET_PLAYER(play); s32 pad; - Player* player2 = GET_PLAYER(globalCtx); + Player* player2 = GET_PLAYER(play); f32 heightDiff; SkelAnime_Update(&this->skelAnime); @@ -647,22 +647,22 @@ void func_8088DD34(EnElf* this, GlobalContext* globalCtx) { this->unk_24A = (s32)Rand_ZeroFloat(0x400) + 0x200; } - func_8088CBAC(this, globalCtx); + func_8088CBAC(this, play); if (this->fairyFlags & 0x800) { this->unk_224.y = player2->bodyPartsPos[0].y; } func_8088D8D0(this, &this->unk_224); - func_8088D9BC(this, globalCtx); - if (Actor_HasParent(&this->actor, globalCtx)) { + func_8088D9BC(this, play); + if (Actor_HasParent(&this->actor, play)) { if (this->fairyFlags & 0x400) { - Flags_SetCollectible(globalCtx, this->unk_260); + Flags_SetCollectible(play, this->unk_260); } Actor_MarkForDeath(&this->actor); return; } - if (Player_InCsMode(&globalCtx->state)) { + if (Player_InCsMode(play)) { if ((this->fairyFlags & 0x4000) && (this->fairyFlags & 0x100) && func_8088DCA4(this)) { return; } @@ -673,10 +673,10 @@ void func_8088DD34(EnElf* this, GlobalContext* globalCtx) { if ((this->fairyFlags & 0x1000) && (heightDiff > 0.0f) && (heightDiff < 60.0f) && !func_8088C804(&this->actor.world.pos, &refActor->actor.world.pos, 10.0f)) { - func_80115908(globalCtx, 0x80); + Health_ChangeBy(play, 0x80); if (this->fairyFlags & 0x200) { - Parameter_AddMagic(globalCtx, ((void)0, gSaveContext.unk_3F30) + - (gSaveContext.save.playerData.doubleMagic * 0x30) + 0x30); + Parameter_AddMagic(play, ((void)0, gSaveContext.unk_3F30) + + (gSaveContext.save.playerData.doubleMagic * 0x30) + 0x30); } gSaveContext.jinxTimer = 0; this->unk_254 = 50.0f; @@ -687,7 +687,7 @@ void func_8088DD34(EnElf* this, GlobalContext* globalCtx) { this->unk_246 = 0; EnElf_SetupAction(this, func_8088E0F0); if (this->fairyFlags & 0x400) { - Flags_SetCollectible(globalCtx, this->unk_260); + Flags_SetCollectible(play, this->unk_260); } return; } @@ -701,16 +701,16 @@ void func_8088DD34(EnElf* this, GlobalContext* globalCtx) { } if (this->fairyFlags & 0x2000) { - Actor_PickUp(&this->actor, globalCtx, GI_MAX, 80.0f, 60.0f); + Actor_PickUp(&this->actor, play, GI_MAX, 80.0f, 60.0f); } } -void func_8088E018(EnElf* this, GlobalContext* globalCtx) { +void func_8088E018(EnElf* this, PlayState* play) { Vec3f parentPos; Actor* parent; SkelAnime_Update(&this->skelAnime); - func_8088D3EC(this, globalCtx); + func_8088D3EC(this, play); parent = this->actor.parent; if ((parent != NULL) && (parent->update != NULL)) { @@ -723,11 +723,11 @@ void func_8088E018(EnElf* this, GlobalContext* globalCtx) { this->unk_258 = Math_FAtan2F(this->actor.velocity.z, this->actor.velocity.x); } -void func_8088E0E0(EnElf* this, GlobalContext* globalCtx) { +void func_8088E0E0(EnElf* this, PlayState* play) { } -void func_8088E0F0(EnElf* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); +void func_8088E0F0(EnElf* this, PlayState* play) { + Player* player = GET_PLAYER(play); SkelAnime_Update(&this->skelAnime); Math_SmoothStepToF(&this->unk_254, 30.0f, 0.1f, 4.0f, 1.0f); @@ -768,12 +768,12 @@ void func_8088E0F0(EnElf* this, GlobalContext* globalCtx) { } this->unk_258 = Math_FAtan2F(this->actor.velocity.z, this->actor.velocity.x); - func_8088F5F4(this, globalCtx, 32); + func_8088F5F4(this, play, 32); Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_FIATY_HEAL - SFX_FLAG); } -void func_8088E304(EnElf* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); +void func_8088E304(EnElf* this, PlayState* play) { + Player* player = GET_PLAYER(play); SkelAnime_Update(&this->skelAnime); if (this->unk_224.y > 200.0f) { @@ -802,12 +802,12 @@ void func_8088E304(EnElf* this, GlobalContext* globalCtx) { func_8088D7F8(this, &player->bodyPartsPos[0]); this->unk_258 = Math_FAtan2F(this->actor.velocity.z, this->actor.velocity.x); - func_8088F5F4(this, globalCtx, 0x20); + func_8088F5F4(this, play, 0x20); Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_FIATY_HEAL - SFX_FLAG); } -void func_8088E484(EnElf* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); +void func_8088E484(EnElf* this, PlayState* play) { + Player* player = GET_PLAYER(play); SkelAnime_Update(&this->skelAnime); @@ -827,23 +827,23 @@ void func_8088E484(EnElf* this, GlobalContext* globalCtx) { func_8088D7F8(this, &player->bodyPartsPos[0]); Actor_SetScale(&this->actor, (1.0f - (SQ(this->unk_250) * SQ(1.0f / 9.0f))) * 0.008f); this->unk_258 = Math_FAtan2F(this->actor.velocity.z, this->actor.velocity.x); - func_8088F5F4(this, globalCtx, 32); + func_8088F5F4(this, play, 32); Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_FIATY_HEAL - SFX_FLAG); } -void func_8088E5A8(EnElf* this, GlobalContext* globalCtx) { +void func_8088E5A8(EnElf* this, PlayState* play) { if (this->fairyFlags & 4) { - func_8088EFA4(this, globalCtx); + func_8088EFA4(this, play); } SkelAnime_Update(&this->skelAnime); - this->unk_26C(this, globalCtx); + this->unk_26C(this, play); } -void func_8088E60C(EnElf* this, GlobalContext* globalCtx) { +void func_8088E60C(EnElf* this, PlayState* play) { s16 glowLightRadius; - Player* player = GET_PLAYER(globalCtx); + Player* player = GET_PLAYER(play); if (player->stateFlags1 & 0x400) { glowLightRadius = 200; @@ -855,14 +855,14 @@ void func_8088E60C(EnElf* this, GlobalContext* globalCtx) { glowLightRadius = 0; } - if (Cutscene_CheckActorAction(globalCtx, 201)) { - if (globalCtx->csCtx.actorActions[Cutscene_GetActorActionIndex(globalCtx, 201)]->action == 6) { + if (Cutscene_CheckActorAction(play, 201)) { + if (play->csCtx.actorActions[Cutscene_GetActorActionIndex(play, 201)]->action == 6) { glowLightRadius = 0; } } if (this->fairyFlags & 0x20) { - Player* player = GET_PLAYER(globalCtx); + Player* player = GET_PLAYER(play); Lights_PointNoGlowSetInfo(&this->lightInfoNoGlow, player->actor.world.pos.x, player->actor.world.pos.y + 60.0f, player->actor.world.pos.z, 255, 255, 255, 200); @@ -877,25 +877,25 @@ void func_8088E60C(EnElf* this, GlobalContext* globalCtx) { Actor_SetScale(&this->actor, this->actor.scale.x); } -void func_8088E850(EnElf* this, GlobalContext* globalCtx) { +void func_8088E850(EnElf* this, PlayState* play) { Vec3f nextPos; - Player* player = GET_PLAYER(globalCtx); + Player* player = GET_PLAYER(play); Actor* arrowPointedActor; f32 xScale; f32 distFromLinksHead; u32 sp38; - func_8088F214(this, globalCtx); - func_8088E5A8(this, globalCtx); + func_8088F214(this, play); + func_8088E5A8(this, play); xScale = 0.0f; - if (Cutscene_CheckActorAction(globalCtx, 201)) { - sp38 = Cutscene_GetActorActionIndex(globalCtx, 201); - func_808908D0(&nextPos, globalCtx, sp38); - 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); + if (Cutscene_CheckActorAction(play, 201)) { + sp38 = Cutscene_GetActorActionIndex(play, 201); + func_808908D0(&nextPos, play, sp38); + this->actor.shape.rot.y = play->csCtx.actorActions[sp38]->urot.y; + this->actor.shape.rot.x = play->csCtx.actorActions[sp38]->urot.x; + if (play->csCtx.actorActions[sp38]->action == 5) { + func_8088F5F4(this, play, 16); } if (this->unk_244 == 8) { @@ -904,15 +904,14 @@ void func_8088E850(EnElf* this, GlobalContext* globalCtx) { func_8088D660(this, &nextPos, 0.2f); } - if ((globalCtx->sceneNum == SCENE_CLOCKTOWER) && (gSaveContext.sceneSetupIndex == 0) && - (globalCtx->csCtx.currentCsIndex == 0) && - ((globalCtx->csCtx.frames == 149) || (globalCtx->csCtx.frames == 381) || - (globalCtx->csCtx.frames == 591))) { + if ((play->sceneNum == SCENE_CLOCKTOWER) && (gSaveContext.sceneSetupIndex == 0) && + (play->csCtx.currentCsIndex == 0) && + ((play->csCtx.frames == 149) || (play->csCtx.frames == 381) || (play->csCtx.frames == 591))) { Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_WHITE_FAIRY_DASH); } - if ((globalCtx->sceneNum == SCENE_SECOM) && (gSaveContext.sceneSetupIndex == 0) && - (globalCtx->csCtx.currentCsIndex == 4) && (globalCtx->csCtx.frames == 95)) { + if ((play->sceneNum == SCENE_SECOM) && (gSaveContext.sceneSetupIndex == 0) && + (play->csCtx.currentCsIndex == 4) && (play->csCtx.frames == 95)) { Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_WHITE_FAIRY_DASH); } } else { @@ -933,7 +932,7 @@ void func_8088E850(EnElf* this, GlobalContext* globalCtx) { } else { xScale = 0.008f; } - func_8088F5F4(this, globalCtx, 16); + func_8088F5F4(this, play, 16); break; case 6: @@ -946,7 +945,7 @@ void func_8088E850(EnElf* this, GlobalContext* globalCtx) { nextPos.y += 1500.0f * this->actor.scale.y; func_8088D7F8(this, &nextPos); - func_8088F5F4(this, globalCtx, 16); + func_8088F5F4(this, play, 16); if (this->unk_254 <= 19.0f) { this->unk_254 += 1.0f; @@ -962,24 +961,24 @@ void func_8088E850(EnElf* this, GlobalContext* globalCtx) { break; case 10: - nextPos = GET_ACTIVE_CAM(globalCtx)->eye; + nextPos = GET_ACTIVE_CAM(play)->eye; nextPos.y += -2000.0f * this->actor.scale.y; func_8088DB4C(this, &nextPos, 0.0f, 30.0f, 0.2f); break; default: - arrowPointedActor = globalCtx->actorCtx.targetContext.arrowPointedActor; + arrowPointedActor = play->actorCtx.targetContext.arrowPointedActor; if ((player->stateFlags1 & 0x40) && (player->targetActor != NULL)) { Math_Vec3f_Copy(&nextPos, &player->targetActor->focus.pos); } else { - Math_Vec3f_Copy(&nextPos, &globalCtx->actorCtx.targetContext.unk0); + Math_Vec3f_Copy(&nextPos, &play->actorCtx.targetContext.unk0); } nextPos.y += 1500.0f * this->actor.scale.y; if (arrowPointedActor != NULL) { func_8088DB4C(this, &nextPos, 0.0f, 30.0f, 0.2f); if (this->actor.speedXZ >= 5.0f) { - func_8088F5F4(this, globalCtx, 0x10); + func_8088F5F4(this, play, 0x10); } } else { if ((this->timer % 32) == 0) { @@ -991,7 +990,7 @@ void func_8088E850(EnElf* this, GlobalContext* globalCtx) { this->fairyFlags ^= 2; } func_8088DB4C(this, &nextPos, 0.0f, 30.0f, 0.2f); - func_8088F5F4(this, globalCtx, 0x10); + func_8088F5F4(this, play, 0x10); } else { if (distFromLinksHead > 100.0f) { this->fairyFlags |= 2; @@ -1015,9 +1014,9 @@ void func_8088E850(EnElf* this, GlobalContext* globalCtx) { Math_SmoothStepToF(&this->actor.scale.x, 0.008f, 0.3f, 0.00080000004f, 0.000080000005f); } - func_8088E60C(this, globalCtx); + func_8088E60C(this, play); - if (!Cutscene_CheckActorAction(globalCtx, 0xC9)) { + if (!Cutscene_CheckActorAction(play, 0xC9)) { this->actor.shape.rot.y = this->unk_258; } } @@ -1036,9 +1035,9 @@ void func_8088EF18(Color_RGBAf* dest, Color_RGBAf* newColor, Color_RGBAf* curCol dest->a += rgbaDiff.a * rate; } -void func_8088EFA4(EnElf* this, GlobalContext* globalCtx) { - Actor* arrayPointerActor = globalCtx->actorCtx.targetContext.arrowPointedActor; - Player* player = GET_PLAYER(globalCtx); +void func_8088EFA4(EnElf* this, PlayState* play) { + Actor* arrayPointerActor = play->actorCtx.targetContext.arrowPointedActor; + Player* player = GET_PLAYER(play); f32 transitionRate; if (!(this->unk_264 & 8)) { @@ -1062,7 +1061,7 @@ void func_8088EFA4(EnElf* this, GlobalContext* globalCtx) { this->outerColor.b = 80.0f; this->outerColor.a = 0.0f; } - } else if (globalCtx->actorCtx.targetContext.unk40 != 0.0f) { + } else if (play->actorCtx.targetContext.unk40 != 0.0f) { this->unk_268 = 0; this->unk_238 = 1.0f; if (!this->unk_269) { @@ -1070,18 +1069,18 @@ void func_8088EFA4(EnElf* this, GlobalContext* globalCtx) { } } else if (this->unk_268 == 0) { if ((arrayPointerActor == NULL) || - (Math_Vec3f_DistXYZ(&this->actor.world.pos, &globalCtx->actorCtx.targetContext.unk0) < 50.0f)) { + (Math_Vec3f_DistXYZ(&this->actor.world.pos, &play->actorCtx.targetContext.unk0) < 50.0f)) { this->unk_268 = 1; } } else if (this->unk_238 != 0.0f) { if (Math_StepToF(&this->unk_238, 0.0f, 0.25f)) { - this->innerColor = globalCtx->actorCtx.targetContext.fairyInner; - this->outerColor = globalCtx->actorCtx.targetContext.fairyOuter; + this->innerColor = play->actorCtx.targetContext.fairyInner; + this->outerColor = play->actorCtx.targetContext.fairyOuter; } else { transitionRate = 0.25f / this->unk_238; - func_8088EF18(&this->innerColor, &globalCtx->actorCtx.targetContext.fairyInner, &this->innerColor, + func_8088EF18(&this->innerColor, &play->actorCtx.targetContext.fairyInner, &this->innerColor, transitionRate); - func_8088EF18(&this->outerColor, &globalCtx->actorCtx.targetContext.fairyOuter, &this->outerColor, + func_8088EF18(&this->outerColor, &play->actorCtx.targetContext.fairyOuter, &this->outerColor, transitionRate); } } @@ -1101,15 +1100,15 @@ void func_8088EFA4(EnElf* this, GlobalContext* globalCtx) { } } -void func_8088F214(EnElf* this, GlobalContext* globalCtx) { +void func_8088F214(EnElf* this, PlayState* play) { s32 sp34; Actor* arrowPointedActor; - Player* player = GET_PLAYER(globalCtx); + Player* player = GET_PLAYER(play); s32 pad; - if (globalCtx->csCtx.state != 0) { - if (Cutscene_CheckActorAction(globalCtx, 201)) { - switch (globalCtx->csCtx.actorActions[Cutscene_GetActorActionIndex(globalCtx, 201)]->action) { + if (play->csCtx.state != 0) { + if (Cutscene_CheckActorAction(play, 201)) { + switch (play->csCtx.actorActions[Cutscene_GetActorActionIndex(play, 201)]->action) { case 4: sp34 = 7; break; @@ -1134,7 +1133,7 @@ void func_8088F214(EnElf* this, GlobalContext* globalCtx) { sp34 = 1; func_800B9010(&this->actor, NA_SE_EV_BELL_ANGER - SFX_FLAG); } else { - arrowPointedActor = globalCtx->actorCtx.targetContext.arrowPointedActor; + arrowPointedActor = play->actorCtx.targetContext.arrowPointedActor; if (player->stateFlags1 & 0x400) { sp34 = 10; this->unk_25C = 100; @@ -1238,7 +1237,7 @@ void func_8088F214(EnElf* this, GlobalContext* globalCtx) { } } -void func_8088F5F4(EnElf* this, GlobalContext* globalCtx, s32 sparkleLife) { +void func_8088F5F4(EnElf* this, PlayState* play, s32 sparkleLife) { static Vec3f sparkleVelocity = { 0.0f, -0.05f, 0.0f }; static Vec3f sparkleAccel = { 0.0f, -0.025f, 0.0f }; s32 pad; @@ -1259,26 +1258,26 @@ 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, - 1000, sparkleLife); + EffectSsKirakira_SpawnDispersed(play, &sparklePos, &sparkleVelocity, &sparkleAccel, &primColor, &envColor, 1000, + sparkleLife); } } -void func_8088F9E4(Actor* thisx, GlobalContext* globalCtx) { +void func_8088F9E4(Actor* thisx, PlayState* play) { EnElf* this = THIS; s32 bgId; - thisx->floorHeight = BgCheck_EntityRaycastFloor5_2(globalCtx, &globalCtx->colCtx, &thisx->floorPoly, &bgId, - &this->actor, &thisx->world.pos); + thisx->floorHeight = + BgCheck_EntityRaycastFloor5_2(play, &play->colCtx, &thisx->floorPoly, &bgId, &this->actor, &thisx->world.pos); thisx->shape.shadowAlpha = 50; } -void func_8088FA38(EnElf* this, GlobalContext* globalCtx) { +void func_8088FA38(EnElf* this, PlayState* play) { Vec3f refPos; - Player* player = GET_PLAYER(globalCtx); + Player* player = GET_PLAYER(play); if (this->fairyFlags & 0x10) { - refPos = globalCtx->actorCtx.targetContext.unk0; + refPos = play->actorCtx.targetContext.unk0; if (this->unk_234 != NULL) { refPos = this->unk_234->world.pos; @@ -1295,20 +1294,20 @@ void func_8088FA38(EnElf* this, GlobalContext* globalCtx) { this->fairyFlags &= ~0x10; } - func_8088E5A8(this, globalCtx); + func_8088E5A8(this, play); refPos = this->actor.focus.pos; func_8088DB4C(this, &refPos, 0, 30.0f, 0.2f); if (this->actor.speedXZ >= 5.0f) { - func_8088F5F4(this, globalCtx, 0x10); + func_8088F5F4(this, play, 0x10); } Math_SmoothStepToF(&this->actor.scale.x, 0.008f, 0.3f, 0.00080000004f, 0.000080000005f); - func_8088E60C(this, globalCtx); + func_8088E60C(this, play); } -void func_8088FC34(EnElf* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); +void func_8088FC34(EnElf* this, PlayState* play) { + Player* player = GET_PLAYER(play); Math_SmoothStepToS(&this->actor.shape.rot.y, this->unk_258, 5, 0x1000, 0x400); this->timer++; @@ -1319,7 +1318,7 @@ void func_8088FC34(EnElf* this, GlobalContext* globalCtx) { } else { Math_StepToF(&this->unk_240, 1.0f, 0.05f); } - func_800FD2B4(globalCtx, SQ(this->unk_240), player->actor.projectedPos.z + 780.0f, 0.2f, 0.5f); + func_800FD2B4(play, SQ(this->unk_240), player->actor.projectedPos.z + 780.0f, 0.2f, 0.5f); } } @@ -1353,17 +1352,17 @@ void func_8088FDCC(EnElf* this) { this->unk_264 &= ~0x20; } -void func_8088FE64(Actor* thisx, GlobalContext* globalCtx2) { - GlobalContext* globalCtx = globalCtx2; +void func_8088FE64(Actor* thisx, PlayState* play2) { + PlayState* play = play2; EnElf* this = THIS; - func_8088FA38(this, globalCtx); + func_8088FA38(this, play); - switch (Message_GetState(&globalCtx->msgCtx)) { - case 4: - if (Message_ShouldAdvance(globalCtx)) { - if (globalCtx->msgCtx.currentTextId == 0x202) { - switch (globalCtx->msgCtx.choiceIndex) { + switch (Message_GetState(&play->msgCtx)) { + case TEXT_STATE_CHOICE: + if (Message_ShouldAdvance(play)) { + if (play->msgCtx.currentTextId == 0x202) { + switch (play->msgCtx.choiceIndex) { case 0: func_8019F230(); break; @@ -1374,23 +1373,23 @@ void func_8088FE64(Actor* thisx, GlobalContext* globalCtx2) { } } - switch (globalCtx->msgCtx.choiceIndex) { + switch (play->msgCtx.choiceIndex) { case 0: - func_80151938(globalCtx, globalCtx->msgCtx.currentTextId - 1); + func_80151938(play, play->msgCtx.currentTextId - 1); break; case 1: - func_80151938(globalCtx, globalCtx->msgCtx.currentTextId + 1); + func_80151938(play, play->msgCtx.currentTextId + 1); break; } } break; - case 5: - if (Message_ShouldAdvance(globalCtx)) { - switch (globalCtx->msgCtx.currentTextId) { - case 576: - func_80151938(globalCtx, 0x245); + case TEXT_STATE_5: + if (Message_ShouldAdvance(play)) { + switch (play->msgCtx.currentTextId) { + case 0x240: + func_80151938(play, 0x245); break; case 0x21D: @@ -1407,51 +1406,51 @@ void func_8088FE64(Actor* thisx, GlobalContext* globalCtx2) { case 0x244: switch (CURRENT_DAY) { case 1: - func_80151938(globalCtx, 0x246); + func_80151938(play, 0x246); break; case 2: - func_80151938(globalCtx, 0x247); + func_80151938(play, 0x247); break; case 3: if (!gSaveContext.save.isNight) { - func_80151938(globalCtx, 0x248); + func_80151938(play, 0x248); } else if ((gSaveContext.save.time < CLOCK_TIME(6, 0)) && (gSaveContext.save.weekEventReg[74] & 0x20)) { - func_80151938(globalCtx, 0x225); + func_80151938(play, 0x225); } else { - func_80151938(globalCtx, 0x249); + func_80151938(play, 0x249); } break; } break; default: - func_801477B4(globalCtx); + func_801477B4(play); func_8088FDCC(this); break; } } break; - case 2: + case TEXT_STATE_CLOSING: func_8088FDCC(this); break; } - func_8088FC34(this, globalCtx); + func_8088FC34(this, play); if (this->unk_264 & 1) { func_8088FD04(this); } } -void func_8089010C(Actor* thisx, GlobalContext* globalCtx) { +void func_8089010C(Actor* thisx, PlayState* play) { s32 pad; EnElf* this = THIS; - Player* player = GET_PLAYER(globalCtx); - u16 temp_v0 = ElfMessage_GetFirstCycleHint(globalCtx); + Player* player = GET_PLAYER(play); + u16 temp_v0 = ElfMessage_GetFirstCycleHint(play); if (temp_v0 != this->unk_266) { this->unk_266 = temp_v0; @@ -1460,7 +1459,7 @@ void func_8089010C(Actor* thisx, GlobalContext* globalCtx) { if ((player->tatlTextId == 0) && (player->unk_730 == NULL)) { if ((gSaveContext.save.playerData.tatlTimer >= 600) && (gSaveContext.save.playerData.tatlTimer <= 3000)) { - player->tatlTextId = ElfMessage_GetFirstCycleHint(globalCtx); + player->tatlTextId = ElfMessage_GetFirstCycleHint(play); } } @@ -1468,11 +1467,11 @@ void func_8089010C(Actor* thisx, GlobalContext* globalCtx) { thisx->flags |= 0x10000; } - if (Actor_ProcessTalkRequest(thisx, &globalCtx->state)) { - func_8019FDC8(&D_801DB4A4, NA_SE_VO_NA_LISTEN, 0x20); + if (Actor_ProcessTalkRequest(thisx, &play->state)) { + func_8019FDC8(&gSfxDefaultPos, NA_SE_VO_NA_LISTEN, 0x20); thisx->focus.pos = thisx->world.pos; - if (thisx->textId == ElfMessage_GetFirstCycleHint(globalCtx)) { + if (thisx->textId == ElfMessage_GetFirstCycleHint(play)) { this->fairyFlags |= 0x80; gSaveContext.save.playerData.tatlTimer = 3001; } @@ -1489,7 +1488,7 @@ void func_8089010C(Actor* thisx, GlobalContext* globalCtx) { } if (this->elfMsg->home.rot.x == -0x961) { this->unk_234 = this->elfMsg; - Actor_ChangeFocus(thisx, globalCtx, this->elfMsg); + Actor_ChangeFocus(thisx, play, this->elfMsg); } } else { thisx->cutscene = -1; @@ -1502,9 +1501,9 @@ void func_8089010C(Actor* thisx, GlobalContext* globalCtx) { thisx->update = func_8088FE64; func_8088C51C(this, 3); } else { - this->actionFunc(this, globalCtx); + this->actionFunc(this, play); - if (!Play_InCsMode(globalCtx)) { + if (!Play_InCsMode(play)) { if (gSaveContext.save.playerData.tatlTimer < 25800) { gSaveContext.save.playerData.tatlTimer++; } else if (!(this->fairyFlags & 0x80)) { @@ -1516,8 +1515,8 @@ void func_8089010C(Actor* thisx, GlobalContext* globalCtx) { this->elfMsg = NULL; this->timer++; - if ((this->unk_240 >= 0.0f) && func_800FD2B4(globalCtx, SQ(this->unk_240) * this->unk_240, - player->actor.projectedPos.z + 780.0f, 0.2f, 0.5f)) { + if ((this->unk_240 >= 0.0f) && + func_800FD2B4(play, SQ(this->unk_240) * this->unk_240, player->actor.projectedPos.z + 780.0f, 0.2f, 0.5f)) { Math_StepToF(&this->unk_240, -0.05f, 0.05f); } @@ -1525,25 +1524,25 @@ void func_8089010C(Actor* thisx, GlobalContext* globalCtx) { this->unk_269--; } - if (!this->unk_269 && (globalCtx->csCtx.state != 0)) { + if (!this->unk_269 && (play->csCtx.state != 0)) { this->unk_269 = 1; } } -void EnElf_Update(Actor* thisx, GlobalContext* globalCtx) { +void EnElf_Update(Actor* thisx, PlayState* play) { EnElf* this = THIS; - this->actionFunc(this, globalCtx); + this->actionFunc(this, play); thisx->shape.rot.y = this->unk_258; this->timer++; if (this->fairyFlags & 0x200) { - func_8088F9E4(thisx, globalCtx); + func_8088F9E4(thisx, play); } } -s32 EnElf_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, Actor* thisx, +s32 EnElf_OverrideLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, Actor* thisx, Gfx** gfx) { static Vec3f zeroVec = { 0.0f, 0.0f, 0.0f }; s32 pad; @@ -1556,10 +1555,10 @@ s32 EnElf_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, if (this->fairyFlags & 0x200) { scale *= 2.0f; } - scale *= this->actor.scale.x * 124.99999f; + scale *= this->actor.scale.x * (1.0f / 0.008f); - 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); } @@ -1570,24 +1569,24 @@ s32 EnElf_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, return false; } -void EnElf_Draw(Actor* thisx, GlobalContext* globalCtx) { +void EnElf_Draw(Actor* thisx, PlayState* play) { EnElf* this = THIS; - Player* player = GET_PLAYER(globalCtx); + Player* player = GET_PLAYER(play); s32 pad; s32 pad2; if (player->currentMask != PLAYER_MASK_GIANT) { if (!(this->fairyFlags & 8) && - (!Cutscene_CheckActorAction(globalCtx, 201) || - (globalCtx->csCtx.actorActions[Cutscene_GetActorActionIndex(globalCtx, 201)]->action != 6)) && + (!Cutscene_CheckActorAction(play, 201) || + (play->csCtx.actorActions[Cutscene_GetActorActionIndex(play, 201)]->action != 6)) && (!(player->stateFlags1 & 0x100000) || (kREG(90) < this->actor.projectedPos.z))) { - Gfx* dListHead = GRAPH_ALLOC(globalCtx->state.gfxCtx, sizeof(Gfx) * 4); + Gfx* dListHead = GRAPH_ALLOC(play->state.gfxCtx, sizeof(Gfx) * 4); f32 alphaScale; s32 envAlpha; - OPEN_DISPS(globalCtx->state.gfxCtx); + OPEN_DISPS(play->state.gfxCtx); - func_8012C94C(globalCtx->state.gfxCtx); + func_8012C94C(play->state.gfxCtx); envAlpha = (this->timer * 50) & 0x1FF; envAlpha = (envAlpha >= 0x100) ? 511 - envAlpha : envAlpha; @@ -1611,18 +1610,18 @@ void EnElf_Draw(Actor* thisx, GlobalContext* globalCtx) { gDPSetEnvColor(POLY_XLU_DISP++, (u8)(s8)this->outerColor.r, (u8)(s8)this->outerColor.g, (u8)(s8)this->outerColor.b, (u8)(s8)(envAlpha * alphaScale)); - POLY_XLU_DISP = SkelAnime_Draw(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, + POLY_XLU_DISP = SkelAnime_Draw(play, this->skelAnime.skeleton, this->skelAnime.jointTable, EnElf_OverrideLimbDraw, NULL, &this->actor, POLY_XLU_DISP); - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->state.gfxCtx); } } } -void func_808908D0(Vec3f* vec, GlobalContext* globalCtx, u32 action) { +void func_808908D0(Vec3f* vec, PlayState* play, u32 action) { Vec3f startPos; Vec3f endPos; - CsCmdActorAction* npcAction = globalCtx->csCtx.actorActions[action]; + CsCmdActorAction* npcAction = play->csCtx.actorActions[action]; f32 lerp; startPos.x = npcAction->startPos.x; @@ -1633,6 +1632,6 @@ void func_808908D0(Vec3f* vec, GlobalContext* globalCtx, u32 action) { endPos.y = npcAction->endPos.y; endPos.z = npcAction->endPos.z; - lerp = Environment_LerpWeight(npcAction->endFrame, npcAction->startFrame, globalCtx->csCtx.frames); + lerp = Environment_LerpWeight(npcAction->endFrame, npcAction->startFrame, play->csCtx.frames); VEC3F_LERPIMPDST(vec, &startPos, &endPos, lerp); } diff --git a/src/overlays/actors/ovl_En_Elf/z_en_elf.h b/src/overlays/actors/ovl_En_Elf/z_en_elf.h index 52c5e2af1..64d53744f 100644 --- a/src/overlays/actors/ovl_En_Elf/z_en_elf.h +++ b/src/overlays/actors/ovl_En_Elf/z_en_elf.h @@ -5,50 +5,61 @@ struct EnElf; -typedef void (*EnElfActionFunc)(struct EnElf*, GlobalContext*); -typedef void (*EnElfUnkFunc)(struct EnElf*, GlobalContext*); +typedef void (*EnElfActionFunc)(struct EnElf*, PlayState*); +typedef void (*EnElfUnkFunc)(struct EnElf*, PlayState*); #define ENELF_GET_F(thisx) ((thisx)->params & 0xF) #define ENELF_GET_FE00(thisx) (((thisx)->params & 0xFE00) >> 9) typedef struct EnElf { - /* 0x0000 */ Actor actor; - /* 0x0144 */ SkelAnime skelAnime; - /* 0x0188 */ Vec3s jointTable[7]; - /* 0x01B2 */ Vec3s morphTable[7]; - /* 0x01DC */ Color_RGBAf innerColor; - /* 0x01EC */ Color_RGBAf outerColor; - /* 0x01FC */ LightInfo lightInfoGlow; - /* 0x020C */ LightNode* lightNodeGlow; - /* 0x0210 */ LightInfo lightInfoNoGlow; - /* 0x0220 */ LightNode* lightNodeNoGlow; - /* 0x0224 */ Vec3f unk_224; - /* 0x0230 */ Actor* elfMsg; - /* 0x0234 */ Actor* unk_234; - /* 0x0238 */ f32 unk_238; - /* 0x023C */ f32 unk_23C; - /* 0x0240 */ f32 unk_240; - /* 0x0244 */ s16 unk_244; - /* 0x0246 */ s16 unk_246; - /* 0x0248 */ s16 unk_248; - /* 0x024A */ s16 unk_24A; - /* 0x024C */ s16 unk_24C; - /* 0x0250 */ f32 unk_250; - /* 0x0254 */ f32 unk_254; - /* 0x0258 */ s16 unk_258; - /* 0x025A */ u16 timer; - /* 0x025C */ s16 unk_25C; - /* 0x025E */ s16 disappearTimer; - /* 0x0260 */ s16 unk_260; - /* 0x0262 */ u16 fairyFlags; - /* 0x0264 */ u16 unk_264; - /* 0x0266 */ u16 unk_266; - /* 0x0268 */ u8 unk_268; - /* 0x0269 */ u8 unk_269; - /* 0x026C */ EnElfUnkFunc unk_26C; - /* 0x0270 */ EnElfActionFunc actionFunc; + /* 0x000 */ Actor actor; + /* 0x144 */ SkelAnime skelAnime; + /* 0x188 */ Vec3s jointTable[7]; + /* 0x1B2 */ Vec3s morphTable[7]; + /* 0x1DC */ Color_RGBAf innerColor; + /* 0x1EC */ Color_RGBAf outerColor; + /* 0x1FC */ LightInfo lightInfoGlow; + /* 0x20C */ LightNode* lightNodeGlow; + /* 0x210 */ LightInfo lightInfoNoGlow; + /* 0x220 */ LightNode* lightNodeNoGlow; + /* 0x224 */ Vec3f unk_224; + /* 0x230 */ Actor* elfMsg; + /* 0x234 */ Actor* unk_234; + /* 0x238 */ f32 unk_238; + /* 0x23C */ f32 unk_23C; + /* 0x240 */ f32 unk_240; + /* 0x244 */ s16 unk_244; + /* 0x246 */ s16 unk_246; + /* 0x248 */ s16 unk_248; + /* 0x24A */ s16 unk_24A; + /* 0x24C */ s16 unk_24C; + /* 0x250 */ f32 unk_250; + /* 0x254 */ f32 unk_254; + /* 0x258 */ s16 unk_258; + /* 0x25A */ u16 timer; + /* 0x25C */ s16 unk_25C; + /* 0x25E */ s16 disappearTimer; + /* 0x260 */ s16 unk_260; + /* 0x262 */ u16 fairyFlags; + /* 0x264 */ u16 unk_264; + /* 0x266 */ u16 unk_266; + /* 0x268 */ u8 unk_268; + /* 0x269 */ u8 unk_269; + /* 0x26C */ EnElfUnkFunc unk_26C; + /* 0x270 */ EnElfActionFunc actionFunc; } EnElf; // size = 0x274 +typedef enum { + /* 0x00 */ ENELF_TYPE_0, + /* 0x01 */ ENELF_TYPE_1, + /* 0x02 */ ENELF_TYPE_2, + /* 0x03 */ ENELF_TYPE_3, + /* 0x04 */ ENELF_TYPE_4, + /* 0x05 */ ENELF_TYPE_5, + /* 0x06 */ ENELF_TYPE_6, + /* 0x07 */ ENELF_TYPE_7 +} FairyType; + extern const ActorInit En_Elf_InitVars; #endif // Z_EN_ELF_H 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 3693b258b..d0bc05b8b 100644 --- a/src/overlays/actors/ovl_En_Elfbub/z_en_elfbub.c +++ b/src/overlays/actors/ovl_En_Elfbub/z_en_elfbub.c @@ -12,13 +12,13 @@ #define THIS ((EnElfbub*)thisx) -void EnElfbub_Init(Actor* thisx, GlobalContext* globalCtx); -void EnElfbub_Destroy(Actor* thisx, GlobalContext* globalCtx); -void EnElfbub_Update(Actor* thisx, GlobalContext* globalCtx); -void EnElfbub_Draw(Actor* thisx, GlobalContext* globalCtx); +void EnElfbub_Init(Actor* thisx, PlayState* play); +void EnElfbub_Destroy(Actor* thisx, PlayState* play); +void EnElfbub_Update(Actor* thisx, PlayState* play); +void EnElfbub_Draw(Actor* thisx, PlayState* play); -void EnElfbub_Pop(EnElfbub* this, GlobalContext* globalCtx); -void EnElfbub_Idle(EnElfbub* this, GlobalContext* globalCtx); +void EnElfbub_Pop(EnElfbub* this, PlayState* play); +void EnElfbub_Idle(EnElfbub* this, PlayState* play); const ActorInit En_Elfbub_InitVars = { ACTOR_EN_ELFBUB, @@ -52,11 +52,11 @@ static ColliderCylinderInit sCylinderInit = { { 16, 32, 0, { 0, 0, 0 } }, }; -void EnElfbub_Init(Actor* thisx, GlobalContext* globalCtx) { +void EnElfbub_Init(Actor* thisx, PlayState* play) { EnElfbub* this = THIS; Actor* childActor; - if (Flags_GetSwitch(globalCtx, ENELFBUB_GET_SWITCHFLAG(&this->actor))) { + if (Flags_GetSwitch(play, ENELFBUB_GET_SWITCHFLAG(&this->actor))) { Actor_MarkForDeath(&this->actor); return; } @@ -70,13 +70,13 @@ void EnElfbub_Init(Actor* thisx, GlobalContext* globalCtx) { this->zRotDelta = 1000; this->xScale = 0.08f; - Collider_InitAndSetCylinder(globalCtx, &this->collider, &this->actor, &sCylinderInit); + Collider_InitAndSetCylinder(play, &this->collider, &this->actor, &sCylinderInit); this->actor.colChkInfo.mass = MASS_IMMOVABLE; - childActor = Actor_SpawnAsChild(&globalCtx->actorCtx, &this->actor, globalCtx, ACTOR_EN_ELFORG, - this->actor.world.pos.x, this->actor.world.pos.y + 12.0f, this->actor.world.pos.z, - this->actor.world.rot.x, this->actor.world.rot.y, this->actor.world.rot.z, - ((ENELFBUB_GET_SWITCHFLAG(&this->actor) & 0x7F) << 9) | STRAY_FAIRY_TYPE_BUBBLE); + childActor = Actor_SpawnAsChild( + &play->actorCtx, &this->actor, play, ACTOR_EN_ELFORG, this->actor.world.pos.x, this->actor.world.pos.y + 12.0f, + this->actor.world.pos.z, this->actor.world.rot.x, this->actor.world.rot.y, this->actor.world.rot.z, + STRAY_FAIRY_PARAMS(ENELFBUB_GET_SWITCHFLAG(&this->actor), 0, STRAY_FAIRY_TYPE_BUBBLE)); if (childActor != NULL) { childActor->parent = &this->actor; } @@ -85,12 +85,12 @@ void EnElfbub_Init(Actor* thisx, GlobalContext* globalCtx) { this->actor.flags &= ~ACTOR_FLAG_1; } -void EnElfbub_Destroy(Actor* thisx, GlobalContext* globalCtx) { +void EnElfbub_Destroy(Actor* thisx, PlayState* play) { EnElfbub* this = THIS; - Collider_DestroyCylinder(globalCtx, &this->collider); + Collider_DestroyCylinder(play, &this->collider); } -void EnElfbub_Pop(EnElfbub* this, GlobalContext* globalCtx) { +void EnElfbub_Pop(EnElfbub* this, PlayState* play) { static Color_RGBA8 sPrimColor = { 255, 255, 255, 255 }; static Color_RGBA8 sEnvColor = { 150, 150, 150, 0 }; static Vec3f sAccel = { 0.0f, -0.5f, 0.0f }; @@ -112,16 +112,16 @@ void EnElfbub_Pop(EnElfbub* this, GlobalContext* globalCtx) { velocity.x = (Rand_ZeroOne() - 0.5f) * 7.0f; velocity.y = Rand_ZeroOne() * 7.0f; velocity.z = (Rand_ZeroOne() - 0.5f) * 7.0f; - EffectSsDtBubble_SpawnCustomColor(globalCtx, &pos, &velocity, &sAccel, &sPrimColor, &sEnvColor, + EffectSsDtBubble_SpawnCustomColor(play, &pos, &velocity, &sAccel, &sPrimColor, &sEnvColor, Rand_S16Offset(100, 50), 25, 0); } - SoundSource_PlaySfxAtFixedWorldPos(globalCtx, &this->actor.world.pos, 60, NA_SE_EN_AWA_BREAK); + SoundSource_PlaySfxAtFixedWorldPos(play, &this->actor.world.pos, 60, NA_SE_EN_AWA_BREAK); Actor_MarkForDeath(&this->actor); } } -void EnElfbub_Idle(EnElfbub* this, GlobalContext* globalCtx) { +void EnElfbub_Idle(EnElfbub* this, PlayState* play) { s32 pad; this->zRot += this->zRotDelta; @@ -134,34 +134,34 @@ void EnElfbub_Idle(EnElfbub* this, GlobalContext* globalCtx) { return; } - CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); - CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + CollisionCheck_SetAC(play, &play->colChkCtx, &this->collider.base); + CollisionCheck_SetOC(play, &play->colChkCtx, &this->collider.base); } -void EnElfbub_Update(Actor* thisx, GlobalContext* globalCtx) { +void EnElfbub_Update(Actor* thisx, PlayState* play) { EnElfbub* this = THIS; Collider_UpdateCylinder(&this->actor, &this->collider); - this->actionFunc(this, globalCtx); + this->actionFunc(this, play); Actor_SetFocus(&this->actor, this->actor.shape.yOffset); } -void EnElfbub_Draw(Actor* thisx, GlobalContext* globalCtx2) { - GlobalContext* globalCtx = globalCtx2; +void EnElfbub_Draw(Actor* thisx, PlayState* play2) { + PlayState* play = play2; EnElfbub* this = THIS; - OPEN_DISPS(globalCtx->state.gfxCtx); + OPEN_DISPS(play->state.gfxCtx); - func_8012C2DC(globalCtx->state.gfxCtx); + func_8012C2DC(play->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(&play->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); + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_XLU_DISP++, object_bubble_DL_001000); - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->state.gfxCtx); } diff --git a/src/overlays/actors/ovl_En_Elfbub/z_en_elfbub.h b/src/overlays/actors/ovl_En_Elfbub/z_en_elfbub.h index 62a4b69a6..cab77c8a4 100644 --- a/src/overlays/actors/ovl_En_Elfbub/z_en_elfbub.h +++ b/src/overlays/actors/ovl_En_Elfbub/z_en_elfbub.h @@ -7,18 +7,18 @@ struct EnElfbub; -typedef void (*EnElfbubActionFunc)(struct EnElfbub*, GlobalContext*); +typedef void (*EnElfbubActionFunc)(struct EnElfbub*, PlayState*); typedef struct EnElfbub { - /* 0x0000 */ Actor actor; - /* 0x0144 */ ColliderCylinder collider; - /* 0x0190 */ s16 zRot; - /* 0x0192 */ s16 zRotDelta; - /* 0x0194 */ s16 oscillationAngle; - /* 0x0196 */ s16 popTimer; - /* 0x0198 */ f32 xScale; - /* 0x019C */ f32 xyScale; - /* 0x01A0 */ EnElfbubActionFunc actionFunc; + /* 0x000 */ Actor actor; + /* 0x144 */ ColliderCylinder collider; + /* 0x190 */ s16 zRot; + /* 0x192 */ s16 zRotDelta; + /* 0x194 */ s16 oscillationAngle; + /* 0x196 */ s16 popTimer; + /* 0x198 */ f32 xScale; + /* 0x19C */ f32 xyScale; + /* 0x1A0 */ EnElfbubActionFunc actionFunc; } EnElfbub; // size = 0x1A4 extern const ActorInit En_Elfbub_InitVars; diff --git a/src/overlays/actors/ovl_En_Elfgrp/z_en_elfgrp.c b/src/overlays/actors/ovl_En_Elfgrp/z_en_elfgrp.c index 3acd2adf5..ba8cb4f01 100644 --- a/src/overlays/actors/ovl_En_Elfgrp/z_en_elfgrp.c +++ b/src/overlays/actors/ovl_En_Elfgrp/z_en_elfgrp.c @@ -11,27 +11,27 @@ #define THIS ((EnElfgrp*)thisx) -void EnElfgrp_Init(Actor* thisx, GlobalContext* globalCtx); -void EnElfgrp_Destroy(Actor* thisx, GlobalContext* globalCtx); -void EnElfgrp_Update(Actor* thisx, GlobalContext* globalCtx); +void EnElfgrp_Init(Actor* thisx, PlayState* play); +void EnElfgrp_Destroy(Actor* thisx, PlayState* play); +void EnElfgrp_Update(Actor* thisx, PlayState* play); -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); +s32 func_80A39BD0(PlayState* play, s32 arg2); +s32 func_80A39C1C(PlayState* play, s32 arg1); +void func_80A39DC8(EnElfgrp* this, PlayState* play, s32 arg2, s32 arg3); +void func_80A3A0AC(EnElfgrp* this, PlayState* play); +void func_80A3A0F4(EnElfgrp* this, PlayState* play); +void func_80A3A210(EnElfgrp* this, PlayState* play); +void func_80A3A274(EnElfgrp* this, PlayState* play); +void func_80A3A398(EnElfgrp* this, PlayState* play); +void func_80A3A484(EnElfgrp* this, PlayState* play); +void func_80A3A4AC(EnElfgrp* this, PlayState* play); +void func_80A3A520(EnElfgrp* this, PlayState* play); +void func_80A3A600(EnElfgrp* this, PlayState* play); +void func_80A3A610(EnElfgrp* this, PlayState* play); +void func_80A3A6F4(EnElfgrp* this, PlayState* play); +void func_80A3A77C(EnElfgrp* this, PlayState* play); +void func_80A3A7FC(EnElfgrp* this, PlayState* play); +void func_80A3A8F8(EnElfgrp* this, PlayState* play); const ActorInit En_Elfgrp_InitVars = { ACTOR_EN_ELFGRP, @@ -56,7 +56,7 @@ void func_80A396B0(EnElfgrp* this, s32 arg1) { } } -void EnElfgrp_Init(Actor* thisx, GlobalContext* globalCtx) { +void EnElfgrp_Init(Actor* thisx, PlayState* play) { s32 pad; EnElfgrp* this = THIS; s32 sp24; @@ -73,11 +73,11 @@ void EnElfgrp_Init(Actor* thisx, GlobalContext* globalCtx) { case ENELFGRP_3: case ENELFGRP_4: this->unk_148 = this->unk_147 - 1; - sp24 = func_80A39C1C(globalCtx, this->unk_147); + sp24 = func_80A39C1C(play, this->unk_147); this->unk_146 = 1 << this->unk_147; if (sp24 < 25) { - func_80A39DC8(this, globalCtx, sp24, 0); + func_80A39DC8(this, play, sp24, 0); } if (sp24 >= 25) { @@ -86,7 +86,7 @@ void EnElfgrp_Init(Actor* thisx, GlobalContext* globalCtx) { return; } - if ((func_80A39BD0(globalCtx, this->unk_147) + sp24) >= 25) { + if ((func_80A39BD0(play, this->unk_147) + sp24) >= 25) { this->actionFunc = func_80A3A398; switch (this->unk_147) { @@ -118,7 +118,7 @@ void EnElfgrp_Init(Actor* thisx, GlobalContext* globalCtx) { } break; } - } else if (func_80A39BD0(globalCtx, this->unk_147)) { + } else if (func_80A39BD0(play, this->unk_147)) { this->actionFunc = func_80A3A7FC; this->actor.textId = (this->unk_147 * 3) + 0x581; } else { @@ -132,11 +132,11 @@ void EnElfgrp_Init(Actor* thisx, GlobalContext* globalCtx) { break; default: - sp24 = func_80A39C1C(globalCtx, 0); + sp24 = func_80A39C1C(play, 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)) { + if ((this->actor.home.rot.z != 0) && Flags_GetSwitch(play, 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); @@ -147,7 +147,7 @@ void EnElfgrp_Init(Actor* thisx, GlobalContext* globalCtx) { func_80A396B0(this, 6); } } else if ((gSaveContext.save.weekEventReg[8] & 0x80)) { - func_80A39DC8(this, globalCtx, 24, 0); + func_80A39DC8(this, play, 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) { @@ -160,7 +160,7 @@ void EnElfgrp_Init(Actor* thisx, GlobalContext* globalCtx) { func_80A396B0(this, 1); } } else { - func_80A39DC8(this, globalCtx, 24, 0); + func_80A39DC8(this, play, 24, 0); this->actionFunc = func_80A3A8F8; if ((gSaveContext.save.weekEventReg[9] & this->unk_146)) { this->actor.textId = 0x580; @@ -173,21 +173,18 @@ void EnElfgrp_Init(Actor* thisx, GlobalContext* globalCtx) { } } -void EnElfgrp_Destroy(Actor* thisx, GlobalContext* globalCtx) { +void EnElfgrp_Destroy(Actor* thisx, PlayState* play) { } -s32 func_80A39BD0(GlobalContext* globalCtx, s32 arg2) { - s8 sp1F; - +s32 func_80A39BD0(PlayState* play, s32 arg2) { if ((arg2 < 1) || (arg2 >= 5)) { return 0; } - sp1F = gSaveContext.save.inventory.strayFairies[arg2 - 1]; - return (sp1F - func_80A39C1C(globalCtx, arg2)) + 10; + return (((void)0, gSaveContext.save.inventory.strayFairies[arg2 - 1]) - func_80A39C1C(play, arg2)) + 10; } -s32 func_80A39C1C(GlobalContext* globalCtx, s32 arg1) { +s32 func_80A39C1C(PlayState* play, s32 arg1) { // the permanentSceneFlags access here is in the form // struct { // u32 clockTown : 1; @@ -208,13 +205,13 @@ s32 func_80A39C1C(GlobalContext* globalCtx, s32 arg1) { } if (arg1 == 0) { - if (gSaveContext.save.permanentSceneFlags[globalCtx->sceneNum].unk_14 & 1) { + if (gSaveContext.save.permanentSceneFlags[play->sceneNum].unk_14 & 1) { return 25; } return 24; } - temp_v1 = (gSaveContext.save.permanentSceneFlags[globalCtx->sceneNum].unk_14 >> (((arg1 - 1) * 5) + 1)) & 0x1F; + temp_v1 = (gSaveContext.save.permanentSceneFlags[play->sceneNum].unk_14 >> (((arg1 - 1) * 5) + 1)) & 0x1F; if (temp_v1 < 10) { temp_v1 = 10; } else if (temp_v1 > 25) { @@ -223,30 +220,30 @@ s32 func_80A39C1C(GlobalContext* globalCtx, s32 arg1) { return temp_v1; } -void func_80A39CD4(GlobalContext* globalCtx, s32 arg1, s32 arg2) { +void func_80A39CD4(PlayState* play, s32 arg1, s32 arg2) { if ((arg1 < 0) || (arg1 > 4) || (arg2 < 10) || (arg2 > 25)) { return; } if (arg1 == 0) { if (arg2 == 25) { - gSaveContext.save.permanentSceneFlags[globalCtx->sceneNum].unk_14 |= 1; + gSaveContext.save.permanentSceneFlags[play->sceneNum].unk_14 |= 1; } else { - gSaveContext.save.permanentSceneFlags[globalCtx->sceneNum].unk_14 &= ~1; + gSaveContext.save.permanentSceneFlags[play->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); + gSaveContext.save.permanentSceneFlags[play->sceneNum].unk_14 &= ~(0x1F << ((arg1 * 5) - 4)); + gSaveContext.save.permanentSceneFlags[play->sceneNum].unk_14 |= arg2 << ((arg1 * 5) - 4); } } -void func_80A39DC8(EnElfgrp* this, GlobalContext* globalCtx, s32 arg2, s32 arg3) { +void func_80A39DC8(EnElfgrp* this, PlayState* play, s32 arg2, s32 arg3) { s32 pad; s32 i; Actor* elforg; - s32 temp; + s32 params; Vec3f sp6C; - Player* player = GET_PLAYER(globalCtx); + Player* player = GET_PLAYER(play); if (arg3 == 0) { this->unk_14A |= 8; @@ -255,17 +252,16 @@ void func_80A39DC8(EnElfgrp* this, GlobalContext* globalCtx, s32 arg2, s32 arg3) if (arg3 == 0) { sp6C = this->actor.world.pos; sp6C.y += 20.0f; - temp = ((this->unk_147 & 7) << 6) | STRAY_FAIRY_TYPE_FAIRY_FOUNTAIN; + params = STRAY_FAIRY_PARAMS(0, this->unk_147, 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; + params = STRAY_FAIRY_PARAMS(0, this->unk_147, 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); + elforg = Actor_Spawn(&play->actorCtx, play, ACTOR_EN_ELFORG, randPlusMinusPoint5Scaled(20.0f) + sp6C.x, sp6C.y, + randPlusMinusPoint5Scaled(20.0f) + sp6C.z, 0, 0, 0, params); if (elforg == NULL) { continue; } @@ -275,8 +271,8 @@ void func_80A39DC8(EnElfgrp* this, GlobalContext* globalCtx, s32 arg2, s32 arg3) } } -s32 func_80A39F50(GlobalContext* globalCtx) { - Actor* itemAction = globalCtx->actorCtx.actorLists[ACTORCAT_ITEMACTION].first; +s32 func_80A39F50(PlayState* play) { + Actor* itemAction = play->actorCtx.actorLists[ACTORCAT_ITEMACTION].first; EnElforg* elfOrg; while (itemAction != NULL) { @@ -288,8 +284,8 @@ s32 func_80A39F50(GlobalContext* globalCtx) { } elfOrg = (EnElforg*)itemAction; - if (!(elfOrg->flags & STRAY_FAIRY_FLAG_MOVES_QUICKLY_TO_HOME)) { - elfOrg->flags |= STRAY_FAIRY_FLAG_MOVES_QUICKLY_TO_HOME; + if (!(elfOrg->strayFairyFlags & STRAY_FAIRY_FLAG_MOVES_QUICKLY_TO_HOME)) { + elfOrg->strayFairyFlags |= STRAY_FAIRY_FLAG_MOVES_QUICKLY_TO_HOME; } itemAction = itemAction->next; } @@ -297,8 +293,8 @@ s32 func_80A39F50(GlobalContext* globalCtx) { return 0; } -s32 func_80A39FBC(GlobalContext* globalCtx) { - Actor* itemAction = globalCtx->actorCtx.actorLists[ACTORCAT_ITEMACTION].first; +s32 func_80A39FBC(PlayState* play) { + Actor* itemAction = play->actorCtx.actorLists[ACTORCAT_ITEMACTION].first; EnElforg* elfOrg; s32 phi_v1 = 30; @@ -311,8 +307,8 @@ s32 func_80A39FBC(GlobalContext* globalCtx) { } elfOrg = (EnElforg*)itemAction; - if (!(elfOrg->flags & STRAY_FAIRY_FLAG_CIRCLES_QUICKLY_IN_FOUNTAIN)) { - elfOrg->flags |= STRAY_FAIRY_FLAG_CIRCLES_QUICKLY_IN_FOUNTAIN; + if (!(elfOrg->strayFairyFlags & STRAY_FAIRY_FLAG_CIRCLES_QUICKLY_IN_FOUNTAIN)) { + elfOrg->strayFairyFlags |= STRAY_FAIRY_FLAG_CIRCLES_QUICKLY_IN_FOUNTAIN; if (phi_v1 >= 100) { return phi_v1; } @@ -326,8 +322,8 @@ s32 func_80A39FBC(GlobalContext* globalCtx) { return phi_v1; } -void func_80A3A044(GlobalContext* globalCtx) { - Actor* itemAction = globalCtx->actorCtx.actorLists[ACTORCAT_ITEMACTION].first; +void func_80A3A044(PlayState* play) { + Actor* itemAction = play->actorCtx.actorLists[ACTORCAT_ITEMACTION].first; EnElforg* elfOrg; while (itemAction != NULL) { @@ -340,28 +336,28 @@ void func_80A3A044(GlobalContext* globalCtx) { elfOrg = (EnElforg*)itemAction; elfOrg->actor.home.rot.x = 0x14; - elfOrg->flags |= STRAY_FAIRY_FLAG_SPARKLES_AND_SHRINKS; + elfOrg->strayFairyFlags |= STRAY_FAIRY_FLAG_SPARKLES_AND_SHRINKS; itemAction = itemAction->next; } } -void func_80A3A0AC(EnElfgrp* this, GlobalContext* globalCtx) { - if (!Cutscene_CheckActorAction(globalCtx, 0x64)) { +void func_80A3A0AC(EnElfgrp* this, PlayState* play) { + if (!Cutscene_CheckActorAction(play, 0x64)) { this->actionFunc = func_80A3A600; ActorCutscene_Stop(this->actor.cutscene); } } -void func_80A3A0F4(EnElfgrp* this, GlobalContext* globalCtx) { +void func_80A3A0F4(EnElfgrp* this, PlayState* play) { 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, + Actor_Spawn(&play->actorCtx, play, 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, + Actor_Spawn(&play->actorCtx, play, ACTOR_DEMO_EFFECT, this->actor.world.pos.x, this->actor.world.pos.y + 30.0f, this->actor.world.pos.z, 0, 0, 0, 4); } } @@ -375,10 +371,10 @@ void func_80A3A0F4(EnElfgrp* this, GlobalContext* globalCtx) { } } -void func_80A3A210(EnElfgrp* this, GlobalContext* globalCtx) { +void func_80A3A210(EnElfgrp* this, PlayState* play) { if (this->unk_144 == 0) { this->actionFunc = func_80A3A0F4; - func_80A3A044(globalCtx); + func_80A3A044(play); this->unk_144 = 30; } @@ -387,27 +383,27 @@ void func_80A3A210(EnElfgrp* this, GlobalContext* globalCtx) { } } -void func_80A3A274(EnElfgrp* this, GlobalContext* globalCtx) { - if (Cutscene_CheckActorAction(globalCtx, 0x64)) { +void func_80A3A274(EnElfgrp* this, PlayState* play) { + if (Cutscene_CheckActorAction(play, 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) { + switch (play->csCtx.actorActions[Cutscene_GetActorActionIndex(play, 0x64)]->action) { case 2: if (!(this->unk_14A & 1)) { if (this->unk_147 == ENELFGRP_0) { - func_80A39DC8(this, globalCtx, 1, 1); + func_80A39DC8(this, play, 1, 1); } else { - func_80A39DC8(this, globalCtx, func_80A39BD0(globalCtx, this->unk_147), 1); + func_80A39DC8(this, play, func_80A39BD0(play, this->unk_147), 1); } this->unk_14A |= 1; - func_80A39CD4(globalCtx, this->unk_147, 25); + func_80A39CD4(play, this->unk_147, 25); } break; case 3: - func_80A39F50(globalCtx); + func_80A39F50(play); this->actionFunc = func_80A3A210; this->unk_144 = 90; break; @@ -415,13 +411,13 @@ void func_80A3A274(EnElfgrp* this, GlobalContext* globalCtx) { } } -void func_80A3A398(EnElfgrp* this, GlobalContext* globalCtx) { +void func_80A3A398(EnElfgrp* this, PlayState* play) { 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)); + Flags_UnsetSwitch(play, ENELFGRP_GET_FE00(&this->actor)); if (this->unk_14A & 2) { - Item_Give(globalCtx, ITEM_MASK_GREAT_FAIRY); + Item_Give(play, ITEM_MASK_GREAT_FAIRY); } if ((this->unk_14A & 4) != 0) { @@ -429,7 +425,7 @@ void func_80A3A398(EnElfgrp* this, GlobalContext* globalCtx) { } if (this->unk_14A & 0x10) { - Item_Give(globalCtx, ITEM_SWORD_GREAT_FAIRY); + Item_Give(play, ITEM_SWORD_GREAT_FAIRY); } this->unk_14A &= ~8; } else if (this->actor.xzDistToPlayer < 350.0f) { @@ -437,16 +433,16 @@ void func_80A3A398(EnElfgrp* this, GlobalContext* globalCtx) { } } -void func_80A3A484(EnElfgrp* this, GlobalContext* globalCtx) { +void func_80A3A484(EnElfgrp* this, PlayState* play) { 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; +void func_80A3A4AC(EnElfgrp* this, PlayState* play) { + if (Cutscene_CheckActorAction(play, 0x64)) { + s32 temp = play->csCtx.actorActions[Cutscene_GetActorActionIndex(play, 0x64)]->action; if (temp == 3) { this->actionFunc = func_80A3A484; this->unk_144 = 90; @@ -454,34 +450,34 @@ void func_80A3A4AC(EnElfgrp* this, GlobalContext* globalCtx) { } } -void func_80A3A520(EnElfgrp* this, GlobalContext* globalCtx) { - if (Cutscene_CheckActorAction(globalCtx, 0x67)) { +void func_80A3A520(EnElfgrp* this, PlayState* play) { + if (Cutscene_CheckActorAction(play, 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)); + Flags_SetSwitch(play, ENELFGRP_GET_FE00(&this->actor)); if (this->unk_14A & 2) { - Item_Give(globalCtx, ITEM_MASK_GREAT_FAIRY); + Item_Give(play, ITEM_MASK_GREAT_FAIRY); } if (this->actor.home.rot.z != 0) { - Flags_SetSwitch(globalCtx, this->actor.home.rot.z); + Flags_SetSwitch(play, 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_80A3A600(EnElfgrp* this, PlayState* play) { } -void func_80A3A610(EnElfgrp* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); +void func_80A3A610(EnElfgrp* this, PlayState* play) { + Player* player = GET_PLAYER(play); if (this->unk_144 == 60) { - Parameter_AddMagic(globalCtx, + Parameter_AddMagic(play, ((void)0, gSaveContext.unk_3F30) + (gSaveContext.save.playerData.doubleMagic * 0x30) + 0x30); gSaveContext.healthAccumulator = 320; } @@ -498,62 +494,62 @@ void func_80A3A610(EnElfgrp* this, GlobalContext* globalCtx) { } } -void func_80A3A6F4(EnElfgrp* this, GlobalContext* globalCtx) { +void func_80A3A6F4(EnElfgrp* this, PlayState* play) { s32 pad; - Player* player = GET_PLAYER(globalCtx); + Player* player = GET_PLAYER(play); - if (Actor_TextboxIsClosing(&this->actor, globalCtx)) { + if (Actor_TextboxIsClosing(&this->actor, play)) { player->actor.freezeTimer = 100; player->stateFlags1 |= 0x20000000; - this->unk_144 = func_80A39FBC(globalCtx); + this->unk_144 = func_80A39FBC(play); this->actionFunc = func_80A3A610; this->unk_14A &= ~8; } } -void func_80A3A77C(EnElfgrp* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); +void func_80A3A77C(EnElfgrp* this, PlayState* play) { + Player* player = GET_PLAYER(play); player->actor.freezeTimer = 100; player->stateFlags1 |= 0x20000000; - if (Actor_TextboxIsClosing(&this->actor, globalCtx)) { - this->unk_144 = func_80A39FBC(globalCtx); + if (Actor_TextboxIsClosing(&this->actor, play)) { + this->unk_144 = func_80A39FBC(play); this->actionFunc = func_80A3A610; this->unk_14A &= ~8; } } -void func_80A3A7FC(EnElfgrp* this, GlobalContext* globalCtx) { +void func_80A3A7FC(EnElfgrp* this, PlayState* play) { s32 temp_s0; - if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { + if (Actor_ProcessTalkRequest(&this->actor, &play->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); + temp_s0 = func_80A39BD0(play, this->unk_147); + func_80A39DC8(this, play, temp_s0, 1); + temp_s0 += func_80A39C1C(play, this->unk_147); if (temp_s0 > 25) { temp_s0 = 25; } - func_80A39CD4(globalCtx, this->unk_147, temp_s0); + func_80A39CD4(play, 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); + func_800B8614(&this->actor, play, 300.0f); } } -void func_80A3A8F8(EnElfgrp* this, GlobalContext* globalCtx) { +void func_80A3A8F8(EnElfgrp* this, PlayState* play) { s32 pad; - Player* player = GET_PLAYER(globalCtx); + Player* player = GET_PLAYER(play); - if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { + if (Actor_ProcessTalkRequest(&this->actor, &play->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) { + if (func_80A39BD0(play, this->unk_147) > 0) { this->actionFunc = func_80A3A7FC; return; } @@ -564,22 +560,22 @@ void func_80A3A8F8(EnElfgrp* this, GlobalContext* globalCtx) { this->actor.flags &= ~ACTOR_FLAG_10000; player->actor.freezeTimer = 100; player->stateFlags1 |= 0x20000000; - Message_StartTextbox(globalCtx, this->actor.textId, &this->actor); + Message_StartTextbox(play, 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); + func_800B8614(&this->actor, play, 100.0f); } } else { this->actor.flags &= ~ACTOR_FLAG_10000; } } -void EnElfgrp_Update(Actor* thisx, GlobalContext* globalCtx) { +void EnElfgrp_Update(Actor* thisx, PlayState* play) { EnElfgrp* this = THIS; - this->actionFunc(this, globalCtx); + this->actionFunc(this, play); if (this->unk_14A & 8) { Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_FAIRY_GROUP_FRY - SFX_FLAG); 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 375dad55b..8536b806e 100644 --- a/src/overlays/actors/ovl_En_Elfgrp/z_en_elfgrp.h +++ b/src/overlays/actors/ovl_En_Elfgrp/z_en_elfgrp.h @@ -5,7 +5,7 @@ struct EnElfgrp; -typedef void (*EnElfgrpActionFunc)(struct EnElfgrp*, GlobalContext*); +typedef void (*EnElfgrpActionFunc)(struct EnElfgrp*, PlayState*); #define ENELFGRP_GET(thisx) ((thisx)->params & 0xF) #define ENELFGRP_GET_FE00(thisx) (((thisx)->params & 0xFE00) >> 9) @@ -19,13 +19,13 @@ enum { }; typedef struct EnElfgrp { - /* 0x0000 */ Actor actor; - /* 0x0144 */ s16 unk_144; - /* 0x0146 */ u8 unk_146; - /* 0x0147 */ u8 unk_147; - /* 0x0148 */ s8 unk_148; - /* 0x014A */ u16 unk_14A; - /* 0x014C */ EnElfgrpActionFunc actionFunc; + /* 0x000 */ Actor actor; + /* 0x144 */ s16 unk_144; + /* 0x146 */ u8 unk_146; + /* 0x147 */ u8 unk_147; + /* 0x148 */ s8 unk_148; + /* 0x14A */ u16 unk_14A; + /* 0x14C */ EnElfgrpActionFunc actionFunc; } EnElfgrp; // size = 0x150 extern const ActorInit En_Elfgrp_InitVars; diff --git a/src/overlays/actors/ovl_En_Elforg/z_en_elforg.c b/src/overlays/actors/ovl_En_Elforg/z_en_elforg.c index 36ad91c0f..04ad98f8f 100644 --- a/src/overlays/actors/ovl_En_Elforg/z_en_elforg.c +++ b/src/overlays/actors/ovl_En_Elforg/z_en_elforg.c @@ -5,23 +5,22 @@ */ #include "z_en_elforg.h" -#include "objects/gameplay_keep/gameplay_keep.h" #define FLAGS (ACTOR_FLAG_10) #define THIS ((EnElforg*)thisx) -void EnElforg_Init(Actor* thisx, GlobalContext* globalCtx); -void EnElforg_Destroy(Actor* thisx, GlobalContext* globalCtx); -void EnElforg_Update(Actor* thisx, GlobalContext* globalCtx); -void EnElforg_Draw(Actor* thisx, GlobalContext* globalCtx); +void EnElforg_Init(Actor* thisx, PlayState* play); +void EnElforg_Destroy(Actor* thisx, PlayState* play); +void EnElforg_Update(Actor* thisx, PlayState* play); +void EnElforg_Draw(Actor* thisx, PlayState* play); -void EnElforg_TrappedByBubble(EnElforg* this, GlobalContext* globalCtx); -void EnElforg_TurnInFairy(EnElforg* this, GlobalContext* globalCtx); -void EnElforg_FreeFloatingFairyFountain(EnElforg* this, GlobalContext* globalCtx); -void EnElforg_FreeFloating(EnElforg* this, GlobalContext* globalCtx); -void EnElforg_SetupTrappedByEnemy(EnElforg* this, GlobalContext* globalCtx); -void EnElforg_HiddenByCollider(EnElforg* this, GlobalContext* globalCtx); +void EnElforg_TrappedByBubble(EnElforg* this, PlayState* play); +void EnElforg_TurnInFairy(EnElforg* this, PlayState* play); +void EnElforg_FreeFloatingFairyFountain(EnElforg* this, PlayState* play); +void EnElforg_FreeFloating(EnElforg* this, PlayState* play); +void EnElforg_SetupTrappedByEnemy(EnElforg* this, PlayState* play); +void EnElforg_HiddenByCollider(EnElforg* this, PlayState* play); const ActorInit En_Elforg_InitVars = { ACTOR_EN_ELFORG, @@ -66,38 +65,41 @@ void EnElforg_InitializeParams(EnElforg* this) { this->skelAnime.curFrame = (s32)Rand_ZeroFloat(5.0f); } -void EnElforg_Init(Actor* thisx, GlobalContext* globalCtx) { +void EnElforg_Init(Actor* thisx, PlayState* play) { s32 pad; EnElforg* this = THIS; - Actor_SetScale(&this->actor, 0.01f); - this->flags = 0; + Actor_SetScale(thisx, 0.01f); + this->strayFairyFlags = 0; this->direction = 0; - SkelAnime_InitFlex(globalCtx, &this->skelAnime, &gStrayFairySkel, &gStrayFairyFlyingAnim, this->jointTable, + SkelAnime_InitFlex(play, &this->skelAnime, &gStrayFairySkel, &gStrayFairyFlyingAnim, this->jointTable, this->jointTable, STRAY_FAIRY_LIMB_MAX); this->skelAnime.playSpeed = 1.0f; - ActorShape_Init(&this->actor.shape, 0.0f, NULL, 0.0f); - this->actor.shape.shadowAlpha = 255; + ActorShape_Init(&thisx->shape, 0.0f, NULL, 0.0f); + thisx->shape.shadowAlpha = 255; - switch (STRAY_FAIRY_TYPE(&this->actor)) { + switch (STRAY_FAIRY_TYPE(thisx)) { case STRAY_FAIRY_TYPE_CLOCK_TOWN: if (gSaveContext.save.weekEventReg[8] & 0x80) { - Actor_MarkForDeath(&this->actor); + Actor_MarkForDeath(thisx); return; } break; + case STRAY_FAIRY_TYPE_COLLECTIBLE: - if (Flags_GetCollectible(globalCtx, STRAY_FAIRY_FLAG(&this->actor))) { - Actor_MarkForDeath(&this->actor); + if (Flags_GetCollectible(play, STRAY_FAIRY_FLAG(thisx))) { + Actor_MarkForDeath(thisx); return; } break; + default: - if (Flags_GetSwitch(globalCtx, STRAY_FAIRY_FLAG(&this->actor))) { - Actor_MarkForDeath(&this->actor); + if (Flags_GetSwitch(play, STRAY_FAIRY_FLAG(thisx))) { + Actor_MarkForDeath(thisx); return; } break; + case STRAY_FAIRY_TYPE_FAIRY_FOUNTAIN: case STRAY_FAIRY_TYPE_BUBBLE: case STRAY_FAIRY_TYPE_CHEST: @@ -105,58 +107,62 @@ void EnElforg_Init(Actor* thisx, GlobalContext* globalCtx) { break; } - if (func_8010A074(globalCtx)) { - this->area = gSaveContext.unk_48C8 + 1; + if (Map_IsInDungeonOrBossArea(play)) { + this->area = gSaveContext.dungeonIndex + STRAY_FAIRY_AREA_WOODFALL; } else { - // Needs to be thisx in order to match - this->area = STRAY_FAIRY_GET_PARAM_1C0(thisx) >> 6; + this->area = STRAY_FAIRY_GET_NON_DUNGEON_AREA(thisx); } - switch (STRAY_FAIRY_TYPE(&this->actor)) { + switch (STRAY_FAIRY_TYPE(thisx)) { case STRAY_FAIRY_TYPE_FAIRY_FOUNTAIN: EnElforg_InitializeParams(this); this->actionFunc = EnElforg_FreeFloatingFairyFountain; this->targetSpeedXZ = Rand_ZeroFloat(2.0f) + 1.0f; this->targetDistanceFromHome = Rand_ZeroFloat(100.0f) + 50.0f; break; + case STRAY_FAIRY_TYPE_TURN_IN_TO_FAIRY_FOUNTAIN: EnElforg_InitializeParams(this); this->actionFunc = EnElforg_TurnInFairy; this->secondaryTimer = 60; break; + case STRAY_FAIRY_TYPE_BUBBLE: this->timer = 0; this->actionFunc = EnElforg_TrappedByBubble; break; + case STRAY_FAIRY_TYPE_ENEMY: this->actionFunc = EnElforg_SetupTrappedByEnemy; - EnElforg_SetupTrappedByEnemy(this, globalCtx); - this->actor.draw = NULL; + EnElforg_SetupTrappedByEnemy(this, play); + thisx->draw = NULL; break; + case STRAY_FAIRY_TYPE_COLLIDER: this->actionFunc = EnElforg_HiddenByCollider; - this->actor.draw = NULL; - Collider_InitAndSetCylinder(globalCtx, &this->collider, &this->actor, &sCylinderInit); - Collider_UpdateCylinder(&this->actor, &this->collider); + thisx->draw = NULL; + Collider_InitAndSetCylinder(play, &this->collider, thisx, &sCylinderInit); + Collider_UpdateCylinder(thisx, &this->collider); break; + default: EnElforg_InitializeParams(this); this->actionFunc = EnElforg_FreeFloating; break; } - this->actor.shape.rot.y = 0; + thisx->shape.rot.y = 0; } -void EnElforg_Destroy(Actor* thisx, GlobalContext* globalCtx) { +void EnElforg_Destroy(Actor* thisx, PlayState* play) { EnElforg* this = THIS; if (STRAY_FAIRY_TYPE(&this->actor) == STRAY_FAIRY_TYPE_COLLIDER) { - Collider_DestroyCylinder(globalCtx, &this->collider); + Collider_DestroyCylinder(play, &this->collider); } } -void EnElforg_SpawnSparkles(EnElforg* this, GlobalContext* globalCtx, s32 life) { +void EnElforg_SpawnSparkles(EnElforg* this, PlayState* play, s32 life) { static Vec3f sVelocity = { 0.0f, -0.05f, 0.0f }; static Vec3f sAcceleration = { 0.0f, -0.025f, 0.0f }; static Color_RGBA8 sPrimColors[] = { @@ -176,8 +182,8 @@ 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], - &sEnvColors[index], 1000, life); + EffectSsKirakira_SpawnDispersed(play, &pos, &sVelocity, &sAcceleration, &sPrimColors[index], &sEnvColors[index], + 1000, life); } void EnElforg_ApproachTargetYPosition(EnElforg* this, Vec3f* targetPos) { @@ -216,6 +222,7 @@ void EnElforg_MoveToTargetFairyFountain(EnElforg* this, Vec3f* homePos) { zDifference = this->actor.world.pos.z - homePos->z; targetAngle = Math_FAtan2F(-zDifference, -xDifference); xzDistance = sqrtf(SQ(xDifference) + SQ(zDifference)); + if ((this->targetDistanceFromHome + 10.0f) < xzDistance) { angleAdjustment = 0x1000; } else if ((this->targetDistanceFromHome - 10.0f) > xzDistance) { @@ -223,6 +230,7 @@ void EnElforg_MoveToTargetFairyFountain(EnElforg* this, Vec3f* homePos) { } else { angleAdjustment = 0x4000; } + targetAngle += angleAdjustment; Math_SmoothStepToS(&this->actor.world.rot.y, targetAngle, 2, 4000, 1000); EnElforg_ApproachTargetSpeedXZ(this); @@ -240,6 +248,7 @@ void EnElforg_MoveToTarget(EnElforg* this, Vec3f* targetPos) { this->actor.shape.yOffset += 100.0f * Math_SinS(this->timer << 9); EnElforg_ApproachTargetYPosition(this, targetPos); targetAngle = Math_FAtan2F(-(this->actor.world.pos.z - targetPos->z), -(this->actor.world.pos.x - targetPos->x)); + if (this->targetSpeedXZ > 2.0f) { Math_SmoothStepToS(&this->actor.world.rot.y, targetAngle, 2, 0x400, 0x100); } else { @@ -248,16 +257,18 @@ void EnElforg_MoveToTarget(EnElforg* this, Vec3f* targetPos) { targetAngle += 0x2000; Math_SmoothStepToS(&this->actor.world.rot.y, targetAngle, 10, 0x200, 0x80); } + EnElforg_ApproachTargetSpeedXZ(this); Actor_MoveWithGravity(&this->actor); } -void func_80ACCBB8(EnElforg* this, GlobalContext* globalCtx) { - globalCtx->actorCtx.unk5 |= 8; +void func_80ACCBB8(EnElforg* this, PlayState* play) { + play->actorCtx.unk5 |= 8; } -void EnElforg_TrappedByBubble(EnElforg* this, GlobalContext* globalCtx) { +void EnElforg_TrappedByBubble(EnElforg* this, PlayState* play) { SkelAnime_Update(&this->skelAnime); + if ((this->actor.parent == NULL) || (this->actor.parent->update == NULL)) { EnElforg_InitializeParams(this); this->actionFunc = EnElforg_FreeFloating; @@ -266,11 +277,12 @@ void EnElforg_TrappedByBubble(EnElforg* this, GlobalContext* globalCtx) { this->actor.world.pos = this->actor.parent->world.pos; this->actor.world.pos.y += 12.0f; } - func_80ACCBB8(this, globalCtx); + + func_80ACCBB8(this, play); } -void EnElforg_TurnInFairy(EnElforg* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); +void EnElforg_TurnInFairy(EnElforg* this, PlayState* play) { + Player* player = GET_PLAYER(play); f32 xzDistToPlayer; s16 rotationTemp; s16 newAngle; @@ -282,16 +294,18 @@ void EnElforg_TurnInFairy(EnElforg* this, GlobalContext* globalCtx) { this->actor.shape.yOffset *= 0.9f; this->actor.speedXZ = 5.0f; EnElforg_ApproachTargetYPosition(this, &player->bodyPartsPos[0]); + xzDistToPlayer = this->actor.xzDistToPlayer; if (xzDistToPlayer < 0.0f) { xzDistToPlayer = 10.0f; } + newAngle = 0x28000 / xzDistToPlayer; Math_SmoothStepToF(&xzDistToPlayer, 40.0f, 0.2f, 100.0f, 1.0f); rotationTemp = this->actor.yawTowardsPlayer - newAngle; this->actor.world.pos.x = player->actor.world.pos.x - (Math_SinS(rotationTemp) * xzDistToPlayer); this->actor.world.pos.z = player->actor.world.pos.z - (Math_CosS(rotationTemp) * xzDistToPlayer); - EnElforg_SpawnSparkles(this, globalCtx, 16); + EnElforg_SpawnSparkles(this, play, 16); if (this->secondaryTimer > 0) { this->secondaryTimer--; @@ -303,29 +317,31 @@ void EnElforg_TurnInFairy(EnElforg* this, GlobalContext* globalCtx) { this->targetSpeedXZ = 3.0f; this->targetDistanceFromHome = 50.0f; this->actionFunc = EnElforg_FreeFloatingFairyFountain; - this->flags &= ~STRAY_FAIRY_FLAG_CIRCLES_QUICKLY_IN_FOUNTAIN; + this->strayFairyFlags &= ~STRAY_FAIRY_FLAG_CIRCLES_QUICKLY_IN_FOUNTAIN; } } -void EnElforg_QuicklyCircleFairyFountain(EnElforg* this, GlobalContext* globalCtx) { +void EnElforg_QuicklyCircleFairyFountain(EnElforg* this, PlayState* play) { SkelAnime_Update(&this->skelAnime); EnElforg_MoveToTargetFairyFountain(this, &this->actor.home.pos); if (this->secondaryTimer <= 30) { this->actionFunc = EnElforg_TurnInFairy; } + this->secondaryTimer--; } -void EnElforg_FreeFloatingFairyFountain(EnElforg* this, GlobalContext* globalCtx) { +void EnElforg_FreeFloatingFairyFountain(EnElforg* this, PlayState* play) { s32 pad; - if (this->flags & STRAY_FAIRY_FLAG_MOVES_QUICKLY_TO_HOME) { + if (this->strayFairyFlags & STRAY_FAIRY_FLAG_MOVES_QUICKLY_TO_HOME) { // This happens when "turning in" the last batch of Stray Fairies to // a Fairy Fountain. The ones being "turned in" will fly very // quickly to the center of the fountain. if (this->targetSpeedXZ < 8.0f) { this->targetSpeedXZ += 0.1f; } + if (this->targetDistanceFromHome > 0.0f) { this->targetDistanceFromHome -= 2.0f; } @@ -335,22 +351,27 @@ void EnElforg_FreeFloatingFairyFountain(EnElforg* this, GlobalContext* globalCtx } else { this->targetSpeedXZ = Rand_ZeroFloat(2.0f) + 1.0f; } + this->targetDistanceFromHome = Rand_ZeroFloat(100.0f) + 50.0f; } + SkelAnime_Update(&this->skelAnime); EnElforg_MoveToTargetFairyFountain(this, &this->actor.home.pos); - if (this->flags & STRAY_FAIRY_FLAG_CIRCLES_QUICKLY_IN_FOUNTAIN) { + + if (this->strayFairyFlags & STRAY_FAIRY_FLAG_CIRCLES_QUICKLY_IN_FOUNTAIN) { // A small number of fairies will do this when the player walks into // the center of the fountain to be healed. this->actionFunc = EnElforg_QuicklyCircleFairyFountain; } - if (this->flags & STRAY_FAIRY_FLAG_SPARKLES_AND_SHRINKS) { + + if (this->strayFairyFlags & STRAY_FAIRY_FLAG_SPARKLES_AND_SHRINKS) { // This happens right before the Great Fairy appears once all // Stray Fairies are saved. if (this->actor.home.rot.x > 0) { - EnElforg_SpawnSparkles(this, globalCtx, 10); + EnElforg_SpawnSparkles(this, play, 10); this->actor.home.rot.x--; } + Actor_SetScale(&this->actor, this->actor.scale.x * 0.9f); if (this->actor.scale.x < 0.001f) { Actor_MarkForDeath(&this->actor); @@ -358,10 +379,10 @@ void EnElforg_FreeFloatingFairyFountain(EnElforg* this, GlobalContext* globalCtx } } -void EnElforg_CirclePlayer(EnElforg* this, GlobalContext* globalCtx) { +void EnElforg_CirclePlayer(EnElforg* this, PlayState* play) { s32 pad; - Actor* playerActor = &GET_PLAYER(globalCtx)->actor; - Player* player = GET_PLAYER(globalCtx); + Actor* playerActor = &GET_PLAYER(play)->actor; + Player* player = GET_PLAYER(play); f32 distanceFromPlayer; if (gSaveContext.save.playerForm == PLAYER_FORM_GORON) { @@ -369,24 +390,26 @@ void EnElforg_CirclePlayer(EnElforg* this, GlobalContext* globalCtx) { } else { distanceFromPlayer = 20.0f; } + this->actor.world.pos.x = (Math_SinS(this->timer << 12) * distanceFromPlayer) + playerActor->world.pos.x; this->actor.world.pos.z = (Math_CosS(this->timer << 12) * distanceFromPlayer) + playerActor->world.pos.z; this->actor.world.pos.y = player->bodyPartsPos[0].y; - EnElforg_SpawnSparkles(this, globalCtx, 16); + EnElforg_SpawnSparkles(this, play, 16); } -void EnElforg_FairyCollected(EnElforg* this, GlobalContext* globalCtx) { - EnElforg_CirclePlayer(this, globalCtx); +void EnElforg_FairyCollected(EnElforg* this, PlayState* play) { + EnElforg_CirclePlayer(this, play); if (this->timer > 80) { Actor_MarkForDeath(&this->actor); return; } + func_800B9010(&this->actor, NA_SE_PL_CHIBI_FAIRY_HEAL - SFX_FLAG); } -void EnElforg_SetupFairyCollected(EnElforg* this, GlobalContext* globalCtx) { - Actor* playerActor = &GET_PLAYER(globalCtx)->actor; - Player* player = GET_PLAYER(globalCtx); +void EnElforg_SetupFairyCollected(EnElforg* this, PlayState* play) { + Actor* playerActor = &GET_PLAYER(play)->actor; + Player* player = GET_PLAYER(play); this->actor.world.pos.x = playerActor->world.pos.x; this->actor.world.pos.y = player->bodyPartsPos[0].y; @@ -397,13 +420,13 @@ void EnElforg_SetupFairyCollected(EnElforg* this, GlobalContext* globalCtx) { this->actor.shape.yOffset = 0.0f; } -void EnElforg_ClockTownFairyCollected(EnElforg* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); +void EnElforg_ClockTownFairyCollected(EnElforg* this, PlayState* play) { + Player* player = GET_PLAYER(play); - EnElforg_CirclePlayer(this, globalCtx); + EnElforg_CirclePlayer(this, play); player->actor.freezeTimer = 100; player->stateFlags1 |= 0x20000000; - if (Actor_TextboxIsClosing(&this->actor, globalCtx)) { + if (Actor_TextboxIsClosing(&this->actor, play)) { player->actor.freezeTimer = 0; player->stateFlags1 &= ~0x20000000; Actor_MarkForDeath(&this->actor); @@ -421,13 +444,13 @@ void EnElforg_ClockTownFairyCollected(EnElforg* this, GlobalContext* globalCtx) } } -void EnElforg_FreeFloating(EnElforg* this, GlobalContext* globalCtx) { +void EnElforg_FreeFloating(EnElforg* this, PlayState* play) { Vec3f pos; f32 scaledYDistance; - Player* player = GET_PLAYER(globalCtx); + Player* player = GET_PLAYER(play); SkelAnime_Update(&this->skelAnime); - if (Player_GetMask(globalCtx) == PLAYER_MASK_GREAT_FAIRY) { + if (Player_GetMask(play) == PLAYER_MASK_GREAT_FAIRY) { pos = player->bodyPartsPos[0]; this->targetSpeedXZ = 5.0f; EnElforg_MoveToTarget(this, &pos); @@ -437,49 +460,54 @@ void EnElforg_FreeFloating(EnElforg* this, GlobalContext* globalCtx) { } scaledYDistance = this->actor.playerHeightRel - (this->actor.shape.yOffset * this->actor.scale.y); - if (!Player_InCsMode(&globalCtx->state)) { + if (!Player_InCsMode(play)) { if ((this->actor.xzDistToPlayer < 30.0f) && (scaledYDistance < 12.0f) && (scaledYDistance > -68.0f)) { - EnElforg_SetupFairyCollected(this, globalCtx); - func_80115908(globalCtx, 48); + EnElforg_SetupFairyCollected(this, play); + Health_ChangeBy(play, 0x30); switch (STRAY_FAIRY_TYPE(&this->actor)) { case STRAY_FAIRY_TYPE_COLLECTIBLE: - Flags_SetCollectible(globalCtx, STRAY_FAIRY_FLAG(&this->actor)); + Flags_SetCollectible(play, STRAY_FAIRY_FLAG(&this->actor)); break; + case STRAY_FAIRY_TYPE_CHEST: - Flags_SetTreasure(globalCtx, STRAY_FAIRY_FLAG(&this->actor)); + Flags_SetTreasure(play, STRAY_FAIRY_FLAG(&this->actor)); break; + default: - Flags_SetSwitch(globalCtx, STRAY_FAIRY_FLAG(&this->actor)); + Flags_SetSwitch(play, STRAY_FAIRY_FLAG(&this->actor)); break; } if (STRAY_FAIRY_TYPE(&this->actor) == STRAY_FAIRY_TYPE_CLOCK_TOWN) { player->actor.freezeTimer = 100; player->stateFlags1 |= 0x20000000; - Message_StartTextbox(globalCtx, 0x579, NULL); + // Bring me back to North Clock Town! + Message_StartTextbox(play, 0x579, NULL); this->actionFunc = EnElforg_ClockTownFairyCollected; ActorCutscene_SetIntentToPlay(0x7C); return; } - if (func_8010A074(globalCtx)) { - gSaveContext.save.inventory.strayFairies[gSaveContext.unk_48C8]++; - Message_StartTextbox(globalCtx, 0x11, NULL); - if (gSaveContext.save.inventory.strayFairies[(void)0, gSaveContext.unk_48C8] >= 15) { + if (Map_IsInDungeonOrBossArea(play)) { + gSaveContext.save.inventory.strayFairies[gSaveContext.dungeonIndex]++; + // You found a Stray Fairy! + Message_StartTextbox(play, 0x11, NULL); + if (gSaveContext.save.inventory.strayFairies[(void)0, gSaveContext.dungeonIndex] >= 15) { func_801A3098(NA_BGM_GET_ITEM | 0x900); } } } - Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 20.0f, 20.0f, 20.0f, 7); - func_80ACCBB8(this, globalCtx); - if (Player_GetMask(globalCtx) == PLAYER_MASK_GREAT_FAIRY) { - if (!(this->flags & STRAY_FAIRY_FLAG_GREAT_FAIRYS_MASK_EQUIPPED)) { + Actor_UpdateBgCheckInfo(play, &this->actor, 20.0f, 20.0f, 20.0f, 7); + func_80ACCBB8(this, play); + if (Player_GetMask(play) == PLAYER_MASK_GREAT_FAIRY) { + if (!(this->strayFairyFlags & STRAY_FAIRY_FLAG_GREAT_FAIRYS_MASK_EQUIPPED)) { play_sound(NA_SE_SY_FAIRY_MASK_SUCCESS); } - this->flags |= STRAY_FAIRY_FLAG_GREAT_FAIRYS_MASK_EQUIPPED; + + this->strayFairyFlags |= STRAY_FAIRY_FLAG_GREAT_FAIRYS_MASK_EQUIPPED; } else { - this->flags &= ~STRAY_FAIRY_FLAG_GREAT_FAIRYS_MASK_EQUIPPED; + this->strayFairyFlags &= ~STRAY_FAIRY_FLAG_GREAT_FAIRYS_MASK_EQUIPPED; } } } @@ -490,19 +518,20 @@ void EnElforg_FreeFloating(EnElforg* this, GlobalContext* globalCtx) { * works if the enemy and the Stray Fairy have the exact same home * coordinates when the Stray Fairy first spawns. */ -Actor* EnElforg_GetHoldingEnemy(EnElforg* this, GlobalContext* globalCtx) { +Actor* EnElforg_GetHoldingEnemy(EnElforg* this, PlayState* play) { Actor* enemy; - for (enemy = globalCtx->actorCtx.actorLists[ACTORCAT_ENEMY].first; enemy != NULL; enemy = enemy->next) { + for (enemy = play->actorCtx.actorLists[ACTORCAT_ENEMY].first; enemy != NULL; enemy = enemy->next) { if ((enemy->home.pos.x == this->actor.home.pos.x) && (enemy->home.pos.y == this->actor.home.pos.y) && (enemy->home.pos.z == this->actor.home.pos.z)) { return enemy; } } + return NULL; } -void EnElforg_TrappedByEnemy(EnElforg* this, GlobalContext* globalCtx) { +void EnElforg_TrappedByEnemy(EnElforg* this, PlayState* play) { f32 posTemp; if (this->enemy->update == NULL) { @@ -523,11 +552,12 @@ void EnElforg_TrappedByEnemy(EnElforg* this, GlobalContext* globalCtx) { this->actor.world.pos.z = posTemp; this->actor.home.pos.z = posTemp; } - func_80ACCBB8(this, globalCtx); + + func_80ACCBB8(this, play); } -void EnElforg_SetupTrappedByEnemy(EnElforg* this, GlobalContext* globalCtx) { - Actor* enemy = EnElforg_GetHoldingEnemy(this, globalCtx); +void EnElforg_SetupTrappedByEnemy(EnElforg* this, PlayState* play) { + Actor* enemy = EnElforg_GetHoldingEnemy(this, play); if (enemy != NULL && enemy->update != NULL) { this->actionFunc = EnElforg_TrappedByEnemy; @@ -535,7 +565,7 @@ void EnElforg_SetupTrappedByEnemy(EnElforg* this, GlobalContext* globalCtx) { } } -void EnElforg_HiddenByCollider(EnElforg* this, GlobalContext* globalCtx) { +void EnElforg_HiddenByCollider(EnElforg* this, PlayState* play) { if (this->collider.base.acFlags & AC_HIT) { EnElforg_InitializeParams(this); this->actionFunc = EnElforg_FreeFloating; @@ -544,15 +574,16 @@ void EnElforg_HiddenByCollider(EnElforg* this, GlobalContext* globalCtx) { this->actor.home.pos.y += 40.0f; Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_CHIBI_FAIRY_SAVED); } else { - CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + CollisionCheck_SetAC(play, &play->colChkCtx, &this->collider.base); } - func_80ACCBB8(this, globalCtx); + + func_80ACCBB8(this, play); } -void EnElforg_Update(Actor* thisx, GlobalContext* globalCtx) { +void EnElforg_Update(Actor* thisx, PlayState* play) { EnElforg* this = THIS; - this->actionFunc(this, globalCtx); + this->actionFunc(this, play); if (this->timer == 0 && this->secondaryTimer > 0) { this->secondaryTimer--; @@ -572,8 +603,8 @@ void EnElforg_Update(Actor* thisx, GlobalContext* globalCtx) { } } -s32 EnElforg_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, - Actor* thisx, Gfx** gfx) { +s32 EnElforg_OverrideLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, Actor* thisx, + Gfx** gfx) { EnElforg* this = THIS; if (this->direction < 0) { @@ -587,35 +618,40 @@ s32 EnElforg_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dLi return false; } -void EnElforg_Draw(Actor* thisx, GlobalContext* globalCtx) { +void EnElforg_Draw(Actor* thisx, PlayState* play) { s32 pad; EnElforg* this = THIS; - OPEN_DISPS(globalCtx->state.gfxCtx); + OPEN_DISPS(play->state.gfxCtx); - func_8012C2DC(globalCtx->state.gfxCtx); + func_8012C2DC(play->state.gfxCtx); switch (this->area) { case STRAY_FAIRY_AREA_WOODFALL: - AnimatedMat_Draw(globalCtx, Lib_SegmentedToVirtual(gStrayFairyWoodfallTexAnim)); + AnimatedMat_Draw(play, Lib_SegmentedToVirtual(gStrayFairyWoodfallTexAnim)); break; + case STRAY_FAIRY_AREA_SNOWHEAD: - AnimatedMat_Draw(globalCtx, Lib_SegmentedToVirtual(gStrayFairySnowheadTexAnim)); + AnimatedMat_Draw(play, Lib_SegmentedToVirtual(gStrayFairySnowheadTexAnim)); break; + case STRAY_FAIRY_AREA_GREAT_BAY: - AnimatedMat_Draw(globalCtx, Lib_SegmentedToVirtual(gStrayFairyGreatBayTexAnim)); + AnimatedMat_Draw(play, Lib_SegmentedToVirtual(gStrayFairyGreatBayTexAnim)); break; + case STRAY_FAIRY_AREA_STONE_TOWER: - AnimatedMat_Draw(globalCtx, Lib_SegmentedToVirtual(gStrayFairyStoneTowerTexAnim)); + AnimatedMat_Draw(play, Lib_SegmentedToVirtual(gStrayFairyStoneTowerTexAnim)); break; + default: - AnimatedMat_Draw(globalCtx, Lib_SegmentedToVirtual(gStrayFairyClockTownTexAnim)); + AnimatedMat_Draw(play, Lib_SegmentedToVirtual(gStrayFairyClockTownTexAnim)); break; } - Matrix_InsertMatrix(&globalCtx->billboardMtxF, MTXMODE_APPLY); + + Matrix_Mult(&play->billboardMtxF, MTXMODE_APPLY); POLY_XLU_DISP = - SkelAnime_DrawFlex(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, + SkelAnime_DrawFlex(play, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, EnElforg_OverrideLimbDraw, NULL, &this->actor, POLY_XLU_DISP); - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->state.gfxCtx); } diff --git a/src/overlays/actors/ovl_En_Elforg/z_en_elforg.h b/src/overlays/actors/ovl_En_Elforg/z_en_elforg.h index fbf982beb..5de48e955 100644 --- a/src/overlays/actors/ovl_En_Elforg/z_en_elforg.h +++ b/src/overlays/actors/ovl_En_Elforg/z_en_elforg.h @@ -2,10 +2,12 @@ #define Z_EN_ELFORG_H #include "global.h" +#include "objects/gameplay_keep/gameplay_keep.h" #define STRAY_FAIRY_TYPE(thisx) ((thisx)->params & 0xF) -#define STRAY_FAIRY_GET_PARAM_1C0(thisx) ((thisx)->params & 0x1C0) +#define STRAY_FAIRY_GET_NON_DUNGEON_AREA(thisx) (((thisx)->params & 0x1C0) >> 6) #define STRAY_FAIRY_FLAG(thisx) (((thisx)->params & 0xFE00) >> 9) +#define STRAY_FAIRY_PARAMS(flag, nonDungeonArea, type) (((flag & 0x7F) << 9) | ((nonDungeonArea & 7) << 6) | (type & 0xF)) #define STRAY_FAIRY_FLAG_MOVES_QUICKLY_TO_HOME (1 << 0) #define STRAY_FAIRY_FLAG_SPARKLES_AND_SHRINKS (1 << 1) @@ -13,43 +15,29 @@ #define STRAY_FAIRY_FLAG_GREAT_FAIRYS_MASK_EQUIPPED (1 << 3) typedef enum { - STRAY_FAIRY_TYPE_FREE_FLOATING, // The ones just floating around - STRAY_FAIRY_TYPE_FAIRY_FOUNTAIN, // The ones already present when you enter a Fairy Fountain - STRAY_FAIRY_TYPE_BUBBLE, // The ones trapped in bubbles - STRAY_FAIRY_TYPE_CLOCK_TOWN, // The free-floating Stray Fairies in Clock Town - STRAY_FAIRY_TYPE_ENEMY, // The ones trapped inside enemies - STRAY_FAIRY_TYPE_COLLIDER, // Unused in retail. The fairy is hidden until the collider is hit - STRAY_FAIRY_TYPE_CHEST, // The ones in treasure chests - STRAY_FAIRY_TYPE_COLLECTIBLE, // The ones in boxes, pots, beehives, etc. - STRAY_FAIRY_TYPE_TURN_IN_TO_FAIRY_FOUNTAIN // The ones you "turn in" by walking into a Fairy Fountain + /* 0 */ STRAY_FAIRY_TYPE_FREE_FLOATING, // The ones just floating around + /* 1 */ STRAY_FAIRY_TYPE_FAIRY_FOUNTAIN, // The ones already present when you enter a Fairy Fountain + /* 2 */ STRAY_FAIRY_TYPE_BUBBLE, // The ones trapped in bubbles + /* 3 */ STRAY_FAIRY_TYPE_CLOCK_TOWN, // The free-floating Stray Fairies in Clock Town + /* 4 */ STRAY_FAIRY_TYPE_ENEMY, // The ones trapped inside enemies + /* 5 */ STRAY_FAIRY_TYPE_COLLIDER, // Unused in retail. The fairy is hidden until the collider is hit + /* 6 */ STRAY_FAIRY_TYPE_CHEST, // The ones in treasure chests + /* 7 */ STRAY_FAIRY_TYPE_COLLECTIBLE, // The ones in boxes, pots, beehives, etc. + /* 8 */ STRAY_FAIRY_TYPE_TURN_IN_TO_FAIRY_FOUNTAIN // The ones you "turn in" by walking into a Fairy Fountain } StrayFairyType; typedef enum { - STRAY_FAIRY_AREA_CLOCK_TOWN, - STRAY_FAIRY_AREA_WOODFALL, - STRAY_FAIRY_AREA_SNOWHEAD, - STRAY_FAIRY_AREA_GREAT_BAY, - STRAY_FAIRY_AREA_STONE_TOWER, - STRAY_FAIRY_AREA_MAX + /* 0 */ STRAY_FAIRY_AREA_CLOCK_TOWN, + /* 1 */ STRAY_FAIRY_AREA_WOODFALL, + /* 2 */ STRAY_FAIRY_AREA_SNOWHEAD, + /* 3 */ STRAY_FAIRY_AREA_GREAT_BAY, + /* 4 */ STRAY_FAIRY_AREA_STONE_TOWER, + /* 5 */ STRAY_FAIRY_AREA_MAX } StrayFairyArea; -typedef enum { - /* 0 */ STRAY_FAIRY_LIMB_NONE, - /* 1 */ STRAY_FAIRY_LIMB_RIGHT_FACING_HEAD, - /* 2 */ STRAY_FAIRY_LIMB_LEFT_WING, - /* 3 */ STRAY_FAIRY_LIMB_RIGHT_WING, - /* 4 */ STRAY_FAIRY_LIMB_GLOW, - /* 5 */ STRAY_FAIRY_LIMB_TORSO, - /* 6 */ STRAY_FAIRY_LIMB_RIGHT_ARM, - /* 7 */ STRAY_FAIRY_LIMB_PELVIS_AND_LEGS, - /* 8 */ STRAY_FAIRY_LIMB_LEFT_ARM, - /* 9 */ STRAY_FAIRY_LIMB_LEFT_FACING_HEAD, - /* 10 */ STRAY_FAIRY_LIMB_MAX, -} StrayFairyLimbs; - struct EnElforg; -typedef void (*EnElforgActionFunc)(struct EnElforg*, GlobalContext*); +typedef void (*EnElforgActionFunc)(struct EnElforg*, PlayState*); typedef struct EnElforg { /* 0x000 */ Actor actor; @@ -57,7 +45,7 @@ typedef struct EnElforg { /* 0x188 */ Vec3s jointTable[STRAY_FAIRY_LIMB_MAX]; /* 0x1C4 */ ColliderCylinder collider; /* 0x210 */ Actor* enemy; - /* 0x214 */ u16 flags; + /* 0x214 */ u16 strayFairyFlags; /* 0x216 */ s16 direction; // negative when facing right, positive when facing left /* 0x218 */ s16 area; /* 0x21C */ s32 timer; 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 b9a186057..8e68f9205 100644 --- a/src/overlays/actors/ovl_En_Encount1/z_en_encount1.c +++ b/src/overlays/actors/ovl_En_Encount1/z_en_encount1.c @@ -10,10 +10,10 @@ #define THIS ((EnEncount1*)thisx) -void EnEncount1_Init(Actor* thisx, GlobalContext* globalCtx); -void EnEncount1_Update(Actor* thisx, GlobalContext* globalCtx); +void EnEncount1_Init(Actor* thisx, PlayState* play); +void EnEncount1_Update(Actor* thisx, PlayState* play); -void func_808E0954(EnEncount1* this, GlobalContext* globalCtx); +void func_808E0954(EnEncount1* this, PlayState* play); #if 0 const ActorInit En_Encount1_InitVars = { 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 3cf01bd8a..d625f2151 100644 --- a/src/overlays/actors/ovl_En_Encount1/z_en_encount1.h +++ b/src/overlays/actors/ovl_En_Encount1/z_en_encount1.h @@ -5,16 +5,16 @@ struct EnEncount1; -typedef void (*EnEncount1ActionFunc)(struct EnEncount1*, GlobalContext*); +typedef void (*EnEncount1ActionFunc)(struct EnEncount1*, PlayState*); typedef struct EnEncount1 { - /* 0x0000 */ Actor actor; - /* 0x0144 */ EnEncount1ActionFunc actionFunc; - /* 0x0148 */ char unk_148[0x6]; - /* 0x014E */ s16 unk_14E; - /* 0x0150 */ char unk_150[0xA]; - /* 0x015A */ s16 unk_15A; - /* 0x015C */ char unk_15C[0x8]; + /* 0x000 */ Actor actor; + /* 0x144 */ EnEncount1ActionFunc actionFunc; + /* 0x148 */ char unk_148[0x6]; + /* 0x14E */ s16 unk_14E; + /* 0x150 */ char unk_150[0xA]; + /* 0x15A */ s16 unk_15A; + /* 0x15C */ char unk_15C[0x8]; } EnEncount1; // size = 0x164 extern const ActorInit En_Encount1_InitVars; diff --git a/src/overlays/actors/ovl_En_Encount2/z_en_encount2.c b/src/overlays/actors/ovl_En_Encount2/z_en_encount2.c index 83f04b013..d771f3511 100644 --- a/src/overlays/actors/ovl_En_Encount2/z_en_encount2.c +++ b/src/overlays/actors/ovl_En_Encount2/z_en_encount2.c @@ -12,18 +12,18 @@ #define THIS ((EnEncount2*)thisx) -void EnEncount2_Init(Actor* thisx, GlobalContext* globalCtx); -void EnEncount2_Destroy(Actor* thisx, GlobalContext* globalCtx); -void EnEncount2_Update(Actor* thisx, GlobalContext* globalCtx); -void EnEncount2_Draw(Actor* thisx, GlobalContext* globalCtx); +void EnEncount2_Init(Actor* thisx, PlayState* play); +void EnEncount2_Destroy(Actor* thisx, PlayState* play); +void EnEncount2_Update(Actor* thisx, PlayState* play); +void EnEncount2_Draw(Actor* thisx, PlayState* play); -void EnEncount2_Idle(EnEncount2* this, GlobalContext* globalCtx); -void EnEncount2_Popped(EnEncount2* this, GlobalContext* globalCtx); -void EnEncount2_Die(EnEncount2* this, GlobalContext* globalCtx); +void EnEncount2_Idle(EnEncount2* this, PlayState* play); +void EnEncount2_Popped(EnEncount2* this, PlayState* play); +void EnEncount2_Die(EnEncount2* this, PlayState* play); 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, PlayState* play); +void EnEncount2_DrawEffects(EnEncount2* this, PlayState* play); const ActorInit En_Encount2_InitVars = { ACTOR_EN_ENCOUNT2, @@ -60,7 +60,7 @@ static ColliderJntSphInit sJntSphInit = { OC2_TYPE_1, COLSHAPE_JNTSPH, }, - 1, + ARRAY_COUNT(sJntSphElementsInit), sJntSphElementsInit, }; @@ -99,28 +99,28 @@ static DamageTable sDamageTable = { /* Powder Keg */ DMG_ENTRY(0, 0xF), }; -void EnEncount2_Init(Actor* thisx, GlobalContext* globalCtx) { +void EnEncount2_Init(Actor* thisx, PlayState* play) { EnEncount2* this = THIS; s32 pad; CollisionHeader* colHeader = NULL; DynaPolyActor_Init(&this->dyna, 0); CollisionHeader_GetVirtual(&object_fusen_Colheader_002420, &colHeader); - this->dyna.bgId = DynaPoly_SetBgActor(globalCtx, &globalCtx->colCtx.dyna, &this->dyna.actor, colHeader); + this->dyna.bgId = DynaPoly_SetBgActor(play, &play->colCtx.dyna, &this->dyna.actor, colHeader); ActorShape_Init(&this->dyna.actor.shape, 0.0f, ActorShadow_DrawCircle, 25.0f); this->dyna.actor.colChkInfo.mass = MASS_IMMOVABLE; - Collider_InitAndSetJntSph(globalCtx, &this->collider, &this->dyna.actor, &sJntSphInit, &this->colElement); + Collider_InitAndSetJntSph(play, &this->collider, &this->dyna.actor, &sJntSphInit, &this->colElement); this->dyna.actor.targetMode = 6; this->dyna.actor.colChkInfo.health = 1; this->scale = 0.1; - this->switchFlag = GET_ENCOUNT2_SWITCH_FLAG(this); + this->switchFlag = ENCOUNT2_GET_SWITCH_FLAG(&this->dyna.actor); if (this->switchFlag == 0x7F) { this->switchFlag = -1; } - if ((this->switchFlag >= 0) && (Flags_GetSwitch(globalCtx, this->switchFlag))) { + if ((this->switchFlag >= 0) && (Flags_GetSwitch(play, this->switchFlag))) { Actor_MarkForDeath(&this->dyna.actor); return; } @@ -135,10 +135,11 @@ void EnEncount2_Init(Actor* thisx, GlobalContext* globalCtx) { EnEncount2_SetIdle(this); } -void EnEncount2_Destroy(Actor* thisx, GlobalContext* globalCtx) { +void EnEncount2_Destroy(Actor* thisx, PlayState* play) { EnEncount2* this = THIS; - DynaPoly_DeleteBgActor(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); - Collider_DestroyJntSph(globalCtx, &this->collider); + + DynaPoly_DeleteBgActor(play, &play->colCtx.dyna, this->dyna.bgId); + Collider_DestroyJntSph(play, &this->collider); } void EnEncount2_SetIdle(EnEncount2* this) { @@ -146,7 +147,7 @@ void EnEncount2_SetIdle(EnEncount2* this) { this->actionFunc = EnEncount2_Idle; } -void EnEncount2_Idle(EnEncount2* this, GlobalContext* globalCtx) { +void EnEncount2_Idle(EnEncount2* this, PlayState* play) { this->oscillationAngle += 1500.0f; this->dyna.actor.velocity.y = Math_SinS(this->oscillationAngle); Math_ApproachF(&this->scale, 0.1f, 0.3f, 0.01f); @@ -157,17 +158,17 @@ void EnEncount2_Idle(EnEncount2* this, GlobalContext* globalCtx) { } } -void EnEncount2_Popped(EnEncount2* this, GlobalContext* globalCtx) { +void EnEncount2_Popped(EnEncount2* this, PlayState* play) { s32 i; Vec3f curPos; Math_Vec3f_Copy(&curPos, &this->dyna.actor.world.pos); curPos.y += 60.0f; - Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_CLEAR_TAG, curPos.x, curPos.y, curPos.z, 255, 255, 200, + Actor_Spawn(&play->actorCtx, play, 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); @@ -175,16 +176,16 @@ void EnEncount2_Popped(EnEncount2* this, GlobalContext* globalCtx) { this->actionFunc = EnEncount2_Die; } -void EnEncount2_Die(EnEncount2* this, GlobalContext* globalCtx) { +void EnEncount2_Die(EnEncount2* this, PlayState* play) { if (this->deathTimer == 0) { if (this->switchFlag >= 0) { - Flags_SetSwitch(globalCtx, this->switchFlag); + Flags_SetSwitch(play, this->switchFlag); } Actor_MarkForDeath(&this->dyna.actor); } } -void EnEncount2_Update(Actor* thisx, GlobalContext* globalCtx) { +void EnEncount2_Update(Actor* thisx, PlayState* play) { EnEncount2* this = THIS; s32 pad; @@ -193,33 +194,33 @@ void EnEncount2_Update(Actor* thisx, GlobalContext* globalCtx) { this->dyna.actor.shape.rot.y = this->dyna.actor.world.rot.y; Actor_SetFocus(&this->dyna.actor, 30.0f); Actor_SetScale(&this->dyna.actor, this->scale); - this->actionFunc(this, globalCtx); + this->actionFunc(this, play); Actor_MoveWithGravity(&this->dyna.actor); - EnEncount2_UpdateParticles(this, globalCtx); + EnEncount2_UpdateEffects(this, play); if (!this->isPopped) { Collider_UpdateSpheresElement(&this->collider, 0, &this->dyna.actor); - CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); - CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + CollisionCheck_SetAC(play, &play->colChkCtx, &this->collider.base); + CollisionCheck_SetOC(play, &play->colChkCtx, &this->collider.base); } } -void EnEncount2_Draw(Actor* thisx, GlobalContext* globalCtx) { +void EnEncount2_Draw(Actor* thisx, PlayState* play) { EnEncount2* this = THIS; if (this->isPopped != true) { - Gfx_DrawDListOpa(globalCtx, object_fusen_DL_000A00); - Gfx_DrawDListOpa(globalCtx, object_fusen_DL_000D78); + Gfx_DrawDListOpa(play, object_fusen_DL_000A00); + Gfx_DrawDListOpa(play, object_fusen_DL_000D78); } - EnEncount2_DrawParticles(this, globalCtx); + EnEncount2_DrawEffects(this, play); } -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 +229,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,43 +239,43 @@ void EnEncount2_InitParticles(EnEncount2* this, Vec3f* pos, s16 fadeDelay) { } } -void EnEncount2_UpdateParticles(EnEncount2* this, GlobalContext* globalCtx) { +void EnEncount2_UpdateEffects(EnEncount2* this, PlayState* play) { 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, PlayState* play) { s16 i; - EnEncount2Particle* sPtr; - GraphicsContext* gfxCtx = globalCtx->state.gfxCtx; + EnEncount2Effect* sPtr; + GraphicsContext* gfxCtx = play->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); + func_8012C2DC(play->state.gfxCtx); + 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(gSun1Tex)); @@ -282,10 +283,9 @@ void EnEncount2_DrawParticles(EnEncount2* this, GlobalContext* globalCtx) { 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); - gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), - G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + Matrix_Mult(&play->billboardMtxF, MTXMODE_APPLY); + Matrix_RotateZF(DEGF_TO_RADF(play->state.frames * 20.0f), MTXMODE_APPLY); + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_XLU_DISP++, gameplay_keep_DL_07AB58); } } diff --git a/src/overlays/actors/ovl_En_Encount2/z_en_encount2.h b/src/overlays/actors/ovl_En_Encount2/z_en_encount2.h index f2ce8832f..9927653e2 100644 --- a/src/overlays/actors/ovl_En_Encount2/z_en_encount2.h +++ b/src/overlays/actors/ovl_En_Encount2/z_en_encount2.h @@ -5,18 +5,20 @@ struct EnEncount2; -typedef void (*EnEncount2ActionFunc)(struct EnEncount2*, GlobalContext*); +typedef void (*EnEncount2ActionFunc)(struct EnEncount2*, PlayState*); -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,10 +30,10 @@ 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)) +#define ENCOUNT2_GET_SWITCH_FLAG(thisx) ((thisx)->params & 0x7F) extern const ActorInit En_Encount2_InitVars; 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 b9681b5e1..ead07b294 100644 --- a/src/overlays/actors/ovl_En_Encount3/z_en_encount3.c +++ b/src/overlays/actors/ovl_En_Encount3/z_en_encount3.c @@ -10,14 +10,14 @@ #define THIS ((EnEncount3*)thisx) -void EnEncount3_Init(Actor* thisx, GlobalContext* globalCtx); -void EnEncount3_Destroy(Actor* thisx, GlobalContext* globalCtx); -void EnEncount3_Update(Actor* thisx, GlobalContext* globalCtx); -void EnEncount3_Draw(Actor* thisx, GlobalContext* globalCtx); +void EnEncount3_Init(Actor* thisx, PlayState* play); +void EnEncount3_Destroy(Actor* thisx, PlayState* play); +void EnEncount3_Update(Actor* thisx, PlayState* play); +void EnEncount3_Draw(Actor* thisx, PlayState* play); -void func_809AD084(EnEncount3* this, GlobalContext* globalCtx); -void func_809AD194(EnEncount3* this, GlobalContext* globalCtx); -void func_809AD1EC(EnEncount3* this, GlobalContext* globalCtx); +void func_809AD084(EnEncount3* this, PlayState* play); +void func_809AD194(EnEncount3* this, PlayState* play); +void func_809AD1EC(EnEncount3* this, PlayState* play); #if 0 const ActorInit En_Encount3_InitVars = { diff --git a/src/overlays/actors/ovl_En_Encount3/z_en_encount3.h b/src/overlays/actors/ovl_En_Encount3/z_en_encount3.h index dbfe78052..2b0bb59d8 100644 --- a/src/overlays/actors/ovl_En_Encount3/z_en_encount3.h +++ b/src/overlays/actors/ovl_En_Encount3/z_en_encount3.h @@ -5,12 +5,12 @@ struct EnEncount3; -typedef void (*EnEncount3ActionFunc)(struct EnEncount3*, GlobalContext*); +typedef void (*EnEncount3ActionFunc)(struct EnEncount3*, PlayState*); typedef struct EnEncount3 { - /* 0x0000 */ Actor actor; - /* 0x0144 */ EnEncount3ActionFunc actionFunc; - /* 0x0148 */ char unk_148[0x84]; + /* 0x000 */ Actor actor; + /* 0x144 */ EnEncount3ActionFunc actionFunc; + /* 0x148 */ char unk_148[0x84]; } EnEncount3; // size = 0x1CC extern const ActorInit En_Encount3_InitVars; diff --git a/src/overlays/actors/ovl_En_Encount4/z_en_encount4.c b/src/overlays/actors/ovl_En_Encount4/z_en_encount4.c index eaadd8133..a244d6d0a 100644 --- a/src/overlays/actors/ovl_En_Encount4/z_en_encount4.c +++ b/src/overlays/actors/ovl_En_Encount4/z_en_encount4.c @@ -10,15 +10,15 @@ #define THIS ((EnEncount4*)thisx) -void EnEncount4_Init(Actor* thisx, GlobalContext* globalCtx); -void EnEncount4_Destroy(Actor* thisx, GlobalContext* globalCtx); -void EnEncount4_Update(Actor* thisx, GlobalContext* globalCtx); +void EnEncount4_Init(Actor* thisx, PlayState* play); +void EnEncount4_Destroy(Actor* thisx, PlayState* play); +void EnEncount4_Update(Actor* thisx, PlayState* play); -void func_809C3FD8(EnEncount4* this, GlobalContext* globalCtx); -void func_809C4078(EnEncount4* this, GlobalContext* globalCtx); -void func_809C42A8(EnEncount4* this, GlobalContext* globalCtx); -void func_809C4598(EnEncount4* this, GlobalContext* globalCtx); -void func_809C464C(EnEncount4* this, GlobalContext* globalCtx); +void func_809C3FD8(EnEncount4* this, PlayState* play); +void func_809C4078(EnEncount4* this, PlayState* play); +void func_809C42A8(EnEncount4* this, PlayState* play); +void func_809C4598(EnEncount4* this, PlayState* play); +void func_809C464C(EnEncount4* this, PlayState* play); #if 0 const ActorInit En_Encount4_InitVars = { diff --git a/src/overlays/actors/ovl_En_Encount4/z_en_encount4.h b/src/overlays/actors/ovl_En_Encount4/z_en_encount4.h index 891d580a8..499da9663 100644 --- a/src/overlays/actors/ovl_En_Encount4/z_en_encount4.h +++ b/src/overlays/actors/ovl_En_Encount4/z_en_encount4.h @@ -5,7 +5,7 @@ struct EnEncount4; -typedef void (*EnEncount4ActionFunc)(struct EnEncount4*, GlobalContext*); +typedef void (*EnEncount4ActionFunc)(struct EnEncount4*, PlayState*); typedef struct EnEncount4 { /* 0x0000 */ Actor actor; @@ -13,7 +13,8 @@ typedef struct EnEncount4 { /* 0x0148 */ char unk_148[0x4]; /* 0x014C */ s16 unk_14C; /* 0x014E */ s16 unk_14E; - /* 0x0150 */ char unk_150[0x8]; + /* 0x0150 */ s16 unk_150; + /* 0x0152 */ char unk_152[0x6]; } EnEncount4; // size = 0x158 extern const ActorInit En_Encount4_InitVars; diff --git a/src/overlays/actors/ovl_En_Ending_Hero/z_en_ending_hero.c b/src/overlays/actors/ovl_En_Ending_Hero/z_en_ending_hero.c index b366a4dec..946c19c99 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 @@ -11,13 +11,13 @@ #define THIS ((EnEndingHero*)thisx) -void EnEndingHero_Init(Actor* thisx, GlobalContext* globalCtx); -void EnEndingHero_Destroy(Actor* thisx, GlobalContext* globalCtx); -void EnEndingHero_Update(Actor* thisx, GlobalContext* globalCtx); -void EnEndingHero_Draw(Actor* thisx, GlobalContext* globalCtx); +void EnEndingHero_Init(Actor* thisx, PlayState* play); +void EnEndingHero_Destroy(Actor* thisx, PlayState* play); +void EnEndingHero_Update(Actor* thisx, PlayState* play); +void EnEndingHero_Draw(Actor* thisx, PlayState* play); void func_80C1E748(EnEndingHero* this); -void func_80C1E764(EnEndingHero* this, GlobalContext* globalCtx); +void func_80C1E764(EnEndingHero* this, PlayState* play); const ActorInit En_Ending_Hero_InitVars = { ACTOR_EN_ENDING_HERO, @@ -31,20 +31,20 @@ const ActorInit En_Ending_Hero_InitVars = { (ActorFunc)EnEndingHero_Draw, }; -void EnEndingHero_Init(Actor* thisx, GlobalContext* globalCtx) { +void EnEndingHero_Init(Actor* thisx, PlayState* play) { EnEndingHero* this = THIS; 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_dt_Skel_00B0CC, &object_dt_Anim_000BE0, this->jointTable, + SkelAnime_InitFlex(play, &this->skelAnime, &object_dt_Skel_00B0CC, &object_dt_Anim_000BE0, this->jointTable, this->morphTable, 15); ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 25.0f); func_80C1E748(this); } -void EnEndingHero_Destroy(Actor* thisx, GlobalContext* globalCtx) { +void EnEndingHero_Destroy(Actor* thisx, PlayState* play) { } void func_80C1E748(EnEndingHero* this) { @@ -52,11 +52,11 @@ void func_80C1E748(EnEndingHero* this) { this->actionFunc = func_80C1E764; } -void func_80C1E764(EnEndingHero* this, GlobalContext* globalCtx) { +void func_80C1E764(EnEndingHero* this, PlayState* play) { SkelAnime_Update(&this->skelAnime); } -void EnEndingHero_Update(Actor* thisx, GlobalContext* globalCtx) { +void EnEndingHero_Update(Actor* thisx, PlayState* play) { EnEndingHero* this = THIS; if (this->unk240 == 0) { @@ -66,9 +66,9 @@ void EnEndingHero_Update(Actor* thisx, GlobalContext* globalCtx) { this->unk240 = (s16)Rand_ZeroFloat(60.0f) + 0x14; } } - this->actionFunc(this, globalCtx); + this->actionFunc(this, play); Actor_MoveWithGravity(&this->actor); - Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 20.0f, 20.0f, 50.0f, 0x1D); + Actor_UpdateBgCheckInfo(play, &this->actor, 20.0f, 20.0f, 50.0f, 0x1D); } static TexturePtr D_80C1E970[] = { @@ -80,13 +80,13 @@ static TexturePtr D_80C1E984[] = { object_dt_Tex_00A490, }; -void EnEndingHero_Draw(Actor* thisx, GlobalContext* globalCtx) { +void EnEndingHero_Draw(Actor* thisx, PlayState* play) { EnEndingHero* this = THIS; s32 index = 0; - OPEN_DISPS(globalCtx->state.gfxCtx); - func_8012C28C(globalCtx->state.gfxCtx); - func_8012C2DC(globalCtx->state.gfxCtx); + OPEN_DISPS(play->state.gfxCtx); + func_8012C28C(play->state.gfxCtx); + func_8012C2DC(play->state.gfxCtx); gSPSegment(POLY_OPA_DISP++, 0x08, Lib_SegmentedToVirtual(D_80C1E970[this->unk242])); @@ -95,8 +95,8 @@ void EnEndingHero_Draw(Actor* thisx, GlobalContext* globalCtx) { } gSPSegment(POLY_OPA_DISP++, 0x09, Lib_SegmentedToVirtual(D_80C1E984[index])); - SkelAnime_DrawFlexOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, - NULL, NULL, &this->actor); + SkelAnime_DrawFlexOpa(play, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, NULL, + NULL, &this->actor); - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->state.gfxCtx); } diff --git a/src/overlays/actors/ovl_En_Ending_Hero/z_en_ending_hero.h b/src/overlays/actors/ovl_En_Ending_Hero/z_en_ending_hero.h index 95991fee8..098f2ffe0 100644 --- a/src/overlays/actors/ovl_En_Ending_Hero/z_en_ending_hero.h +++ b/src/overlays/actors/ovl_En_Ending_Hero/z_en_ending_hero.h @@ -5,7 +5,7 @@ struct EnEndingHero; -typedef void (*EnEndingHeroActionFunc)(struct EnEndingHero*, GlobalContext*); +typedef void (*EnEndingHeroActionFunc)(struct EnEndingHero*, PlayState*); typedef struct EnEndingHero { /* 0x000 */ Actor actor; diff --git a/src/overlays/actors/ovl_En_Ending_Hero2/z_en_ending_hero2.c b/src/overlays/actors/ovl_En_Ending_Hero2/z_en_ending_hero2.c index f3515787c..f33c9d682 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 @@ -11,13 +11,13 @@ #define THIS ((EnEndingHero2*)thisx) -void EnEndingHero2_Init(Actor* thisx, GlobalContext* globalCtx); -void EnEndingHero2_Destroy(Actor* thisx, GlobalContext* globalCtx); -void EnEndingHero2_Update(Actor* thisx, GlobalContext* globalCtx); -void EnEndingHero2_Draw(Actor* thisx, GlobalContext* globalCtx); +void EnEndingHero2_Init(Actor* thisx, PlayState* play); +void EnEndingHero2_Destroy(Actor* thisx, PlayState* play); +void EnEndingHero2_Update(Actor* thisx, PlayState* play); +void EnEndingHero2_Draw(Actor* thisx, PlayState* play); void func_80C232E8(EnEndingHero2* this); -void func_80C23304(EnEndingHero2* this, GlobalContext* globalCtx); +void func_80C23304(EnEndingHero2* this, PlayState* play); const ActorInit En_Ending_Hero2_InitVars = { ACTOR_EN_ENDING_HERO2, @@ -31,20 +31,20 @@ const ActorInit En_Ending_Hero2_InitVars = { (ActorFunc)EnEndingHero2_Draw, }; -void EnEndingHero2_Init(Actor* thisx, GlobalContext* globalCtx) { +void EnEndingHero2_Init(Actor* thisx, PlayState* play) { EnEndingHero2* this = THIS; 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_bai_Skel_007908, &object_bai_Anim_0011C0, this->jointTable, + SkelAnime_InitFlex(play, &this->skelAnime, &object_bai_Skel_007908, &object_bai_Anim_0011C0, this->jointTable, this->morphTable, 20); ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 25.0f); func_80C232E8(this); } -void EnEndingHero2_Destroy(Actor* thisx, GlobalContext* globalCtx) { +void EnEndingHero2_Destroy(Actor* thisx, PlayState* play) { } void func_80C232E8(EnEndingHero2* this) { @@ -52,23 +52,23 @@ void func_80C232E8(EnEndingHero2* this) { this->actionFunc = func_80C23304; } -void func_80C23304(EnEndingHero2* this, GlobalContext* globalCtx) { +void func_80C23304(EnEndingHero2* this, PlayState* play) { SkelAnime_Update(&this->skelAnime); } -void EnEndingHero2_Update(Actor* thisx, GlobalContext* globalCtx) { +void EnEndingHero2_Update(Actor* thisx, PlayState* play) { EnEndingHero2* this = THIS; - this->actionFunc(this, globalCtx); + this->actionFunc(this, play); Actor_MoveWithGravity(&this->actor); - Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 20.0f, 20.0f, 50.0f, 0x1D); + Actor_UpdateBgCheckInfo(play, &this->actor, 20.0f, 20.0f, 50.0f, 0x1D); } -void EnEndingHero2_Draw(Actor* thisx, GlobalContext* globalCtx) { +void EnEndingHero2_Draw(Actor* thisx, PlayState* play) { EnEndingHero2* this = THIS; - func_8012C28C(globalCtx->state.gfxCtx); - func_8012C2DC(globalCtx->state.gfxCtx); - SkelAnime_DrawFlexOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, - NULL, NULL, &this->actor); + func_8012C28C(play->state.gfxCtx); + func_8012C2DC(play->state.gfxCtx); + SkelAnime_DrawFlexOpa(play, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, NULL, + NULL, &this->actor); } diff --git a/src/overlays/actors/ovl_En_Ending_Hero2/z_en_ending_hero2.h b/src/overlays/actors/ovl_En_Ending_Hero2/z_en_ending_hero2.h index fe7e6bf2e..80ee813fa 100644 --- a/src/overlays/actors/ovl_En_Ending_Hero2/z_en_ending_hero2.h +++ b/src/overlays/actors/ovl_En_Ending_Hero2/z_en_ending_hero2.h @@ -5,7 +5,7 @@ struct EnEndingHero2; -typedef void (*EnEndingHero2ActionFunc)(struct EnEndingHero2*, GlobalContext*); +typedef void (*EnEndingHero2ActionFunc)(struct EnEndingHero2*, PlayState*); typedef struct EnEndingHero2 { /* 0x000 */ Actor actor; 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 91c44e741..6cd6de0f9 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 @@ -11,13 +11,13 @@ #define THIS ((EnEndingHero3*)thisx) -void EnEndingHero3_Init(Actor* thisx, GlobalContext* globalCtx); -void EnEndingHero3_Destroy(Actor* thisx, GlobalContext* globalCtx); -void EnEndingHero3_Update(Actor* thisx, GlobalContext* globalCtx); -void EnEndingHero3_Draw(Actor* thisx, GlobalContext* globalCtx); +void EnEndingHero3_Init(Actor* thisx, PlayState* play); +void EnEndingHero3_Destroy(Actor* thisx, PlayState* play); +void EnEndingHero3_Update(Actor* thisx, PlayState* play); +void EnEndingHero3_Draw(Actor* thisx, PlayState* play); void func_80C23518(EnEndingHero3* this); -void func_80C23534(EnEndingHero3* this, GlobalContext* globalCtx); +void func_80C23534(EnEndingHero3* this, PlayState* play); const ActorInit En_Ending_Hero3_InitVars = { ACTOR_EN_ENDING_HERO3, @@ -31,20 +31,20 @@ const ActorInit En_Ending_Hero3_InitVars = { (ActorFunc)EnEndingHero3_Draw, }; -void EnEndingHero3_Init(Actor* thisx, GlobalContext* globalCtx) { +void EnEndingHero3_Init(Actor* thisx, PlayState* play) { EnEndingHero3* this = THIS; 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_toryo_Skel_007150, &object_toryo_Anim_000E50, - this->jointTable, this->morphTable, 17); + SkelAnime_InitFlex(play, &this->skelAnime, &object_toryo_Skel_007150, &object_toryo_Anim_000E50, this->jointTable, + this->morphTable, 17); ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 25.0f); func_80C23518(this); } -void EnEndingHero3_Destroy(Actor* thisx, GlobalContext* globalCtx) { +void EnEndingHero3_Destroy(Actor* thisx, PlayState* play) { } void func_80C23518(EnEndingHero3* this) { @@ -52,23 +52,23 @@ void func_80C23518(EnEndingHero3* this) { this->actionFunc = func_80C23534; } -void func_80C23534(EnEndingHero3* this, GlobalContext* globalCtx) { +void func_80C23534(EnEndingHero3* this, PlayState* play) { SkelAnime_Update(&this->skelAnime); } -void EnEndingHero3_Update(Actor* thisx, GlobalContext* globalCtx) { +void EnEndingHero3_Update(Actor* thisx, PlayState* play) { EnEndingHero3* this = THIS; - this->actionFunc(this, globalCtx); + this->actionFunc(this, play); Actor_MoveWithGravity(&this->actor); - Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 20.0f, 20.0f, 50.0f, 0x1D); + Actor_UpdateBgCheckInfo(play, &this->actor, 20.0f, 20.0f, 50.0f, 0x1D); } -void EnEndingHero3_Draw(Actor* thisx, GlobalContext* globalCtx) { +void EnEndingHero3_Draw(Actor* thisx, PlayState* play) { EnEndingHero3* this = THIS; - func_8012C28C(globalCtx->state.gfxCtx); - func_8012C2DC(globalCtx->state.gfxCtx); - SkelAnime_DrawFlexOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, - NULL, NULL, &this->actor); + func_8012C28C(play->state.gfxCtx); + func_8012C2DC(play->state.gfxCtx); + SkelAnime_DrawFlexOpa(play, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, NULL, + NULL, &this->actor); } diff --git a/src/overlays/actors/ovl_En_Ending_Hero3/z_en_ending_hero3.h b/src/overlays/actors/ovl_En_Ending_Hero3/z_en_ending_hero3.h index b61452d77..2a30f1d9c 100644 --- a/src/overlays/actors/ovl_En_Ending_Hero3/z_en_ending_hero3.h +++ b/src/overlays/actors/ovl_En_Ending_Hero3/z_en_ending_hero3.h @@ -5,7 +5,7 @@ struct EnEndingHero3; -typedef void (*EnEndingHero3ActionFunc)(struct EnEndingHero3*, GlobalContext*); +typedef void (*EnEndingHero3ActionFunc)(struct EnEndingHero3*, PlayState*); typedef struct EnEndingHero3 { /* 0x000 */ Actor actor; 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 1e54ee8b9..716237321 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 @@ -11,13 +11,13 @@ #define THIS ((EnEndingHero4*)thisx) -void EnEndingHero4_Init(Actor* thisx, GlobalContext* globalCtx); -void EnEndingHero4_Destroy(Actor* thisx, GlobalContext* globalCtx); -void EnEndingHero4_Update(Actor* thisx, GlobalContext* globalCtx); -void EnEndingHero4_Draw(Actor* thisx, GlobalContext* globalCtx); +void EnEndingHero4_Init(Actor* thisx, PlayState* play); +void EnEndingHero4_Destroy(Actor* thisx, PlayState* play); +void EnEndingHero4_Update(Actor* thisx, PlayState* play); +void EnEndingHero4_Draw(Actor* thisx, PlayState* play); void func_80C23748(EnEndingHero4* this); -void func_80C23764(EnEndingHero4* this, GlobalContext* globalCtx); +void func_80C23764(EnEndingHero4* this, PlayState* play); const ActorInit En_Ending_Hero4_InitVars = { ACTOR_EN_ENDING_HERO4, @@ -31,20 +31,20 @@ const ActorInit En_Ending_Hero4_InitVars = { (ActorFunc)EnEndingHero4_Draw, }; -void EnEndingHero4_Init(Actor* thisx, GlobalContext* globalCtx) { +void EnEndingHero4_Init(Actor* thisx, PlayState* play) { EnEndingHero4* this = THIS; 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, &gSoldierSkeleton, &gSoldierCheerWithSpear, this->jointTable, + SkelAnime_InitFlex(play, &this->skelAnime, &gSoldierSkel, &gSoldierCheerWithSpear, this->jointTable, this->morphTable, 17); ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 25.0f); func_80C23748(this); } -void EnEndingHero4_Destroy(Actor* thisx, GlobalContext* globalCtx) { +void EnEndingHero4_Destroy(Actor* thisx, PlayState* play) { } void func_80C23748(EnEndingHero4* this) { @@ -52,23 +52,23 @@ void func_80C23748(EnEndingHero4* this) { this->actionFunc = func_80C23764; } -void func_80C23764(EnEndingHero4* this, GlobalContext* globalCtx) { +void func_80C23764(EnEndingHero4* this, PlayState* play) { SkelAnime_Update(&this->skelAnime); } -void EnEndingHero4_Update(Actor* thisx, GlobalContext* globalCtx) { +void EnEndingHero4_Update(Actor* thisx, PlayState* play) { EnEndingHero4* this = THIS; - this->actionFunc(this, globalCtx); + this->actionFunc(this, play); Actor_MoveWithGravity(&this->actor); - Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 20.0f, 20.0f, 50.0f, 0x1D); + Actor_UpdateBgCheckInfo(play, &this->actor, 20.0f, 20.0f, 50.0f, 0x1D); } -void EnEndingHero4_Draw(Actor* thisx, GlobalContext* globalCtx) { +void EnEndingHero4_Draw(Actor* thisx, PlayState* play) { EnEndingHero4* this = THIS; - func_8012C28C(globalCtx->state.gfxCtx); - func_8012C2DC(globalCtx->state.gfxCtx); - SkelAnime_DrawFlexOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, - NULL, NULL, &this->actor); + func_8012C28C(play->state.gfxCtx); + func_8012C2DC(play->state.gfxCtx); + SkelAnime_DrawFlexOpa(play, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, NULL, + NULL, &this->actor); } diff --git a/src/overlays/actors/ovl_En_Ending_Hero4/z_en_ending_hero4.h b/src/overlays/actors/ovl_En_Ending_Hero4/z_en_ending_hero4.h index 09e3a72ee..2f050f2df 100644 --- a/src/overlays/actors/ovl_En_Ending_Hero4/z_en_ending_hero4.h +++ b/src/overlays/actors/ovl_En_Ending_Hero4/z_en_ending_hero4.h @@ -5,7 +5,7 @@ struct EnEndingHero4; -typedef void (*EnEndingHero4ActionFunc)(struct EnEndingHero4*, GlobalContext*); +typedef void (*EnEndingHero4ActionFunc)(struct EnEndingHero4*, PlayState*); typedef struct EnEndingHero4 { /* 0x000 */ Actor actor; 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 23ac531f3..4d87fe0ed 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 @@ -11,13 +11,13 @@ #define THIS ((EnEndingHero5*)thisx) -void EnEndingHero5_Init(Actor* thisx, GlobalContext* globalCtx); -void EnEndingHero5_Destroy(Actor* thisx, GlobalContext* globalCtx); -void EnEndingHero5_Update(Actor* thisx, GlobalContext* globalCtx); -void EnEndingHero5_Draw(Actor* thisx, GlobalContext* globalCtx); +void EnEndingHero5_Init(Actor* thisx, PlayState* play); +void EnEndingHero5_Destroy(Actor* thisx, PlayState* play); +void EnEndingHero5_Update(Actor* thisx, PlayState* play); +void EnEndingHero5_Draw(Actor* thisx, PlayState* play); void func_80C23980(EnEndingHero5* this); -void func_80C2399C(EnEndingHero5* this, GlobalContext* globalCtx); +void func_80C2399C(EnEndingHero5* this, PlayState* play); const ActorInit En_Ending_Hero5_InitVars = { ACTOR_EN_ENDING_HERO5, @@ -31,21 +31,21 @@ const ActorInit En_Ending_Hero5_InitVars = { (ActorFunc)EnEndingHero5_Draw, }; -void EnEndingHero5_Init(Actor* thisx, GlobalContext* globalCtx) { +void EnEndingHero5_Init(Actor* thisx, PlayState* play) { EnEndingHero5* this = THIS; 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_daiku_Skel_00A850, &object_daiku_Anim_002FA0, - this->jointTable, this->morphTable, 17); + SkelAnime_InitFlex(play, &this->skelAnime, &object_daiku_Skel_00A850, &object_daiku_Anim_002FA0, this->jointTable, + this->morphTable, 17); ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 25.0f); this->unk25C = this->actor.params; func_80C23980(this); } -void EnEndingHero5_Destroy(Actor* thisx, GlobalContext* globalCtx) { +void EnEndingHero5_Destroy(Actor* thisx, PlayState* play) { } void func_80C23980(EnEndingHero5* this) { @@ -53,39 +53,39 @@ void func_80C23980(EnEndingHero5* this) { this->actionFunc = func_80C2399C; } -void func_80C2399C(EnEndingHero5* this, GlobalContext* globalCtx) { +void func_80C2399C(EnEndingHero5* this, PlayState* play) { SkelAnime_Update(&this->skelAnime); } -void EnEndingHero5_Update(Actor* thisx, GlobalContext* globalCtx) { +void EnEndingHero5_Update(Actor* thisx, PlayState* play) { EnEndingHero5* this = THIS; - this->actionFunc(this, globalCtx); + this->actionFunc(this, play); Actor_MoveWithGravity(&this->actor); - Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 20.0f, 20.0f, 50.0f, 0x1D); + Actor_UpdateBgCheckInfo(play, &this->actor, 20.0f, 20.0f, 50.0f, 0x1D); } Gfx* D_80C23BF0[] = { object_daiku_DL_0070C0, object_daiku_DL_006FB0, object_daiku_DL_006E80, object_daiku_DL_006D70, object_daiku_DL_00A390 }; -void EnEndingHero5_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx) { +void EnEndingHero5_PostLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx) { EnEndingHero5* this = THIS; - OPEN_DISPS(globalCtx->state.gfxCtx); + OPEN_DISPS(play->state.gfxCtx); if (limbIndex == 15) { gSPDisplayList(POLY_OPA_DISP++, D_80C23BF0[this->unk25C]); } - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->state.gfxCtx); } -void EnEndingHero5_Draw(Actor* thisx, GlobalContext* globalCtx) { +void EnEndingHero5_Draw(Actor* thisx, PlayState* play) { EnEndingHero5* this = THIS; - func_8012C28C(globalCtx->state.gfxCtx); - func_8012C2DC(globalCtx->state.gfxCtx); - OPEN_DISPS(globalCtx->state.gfxCtx); + func_8012C28C(play->state.gfxCtx); + func_8012C2DC(play->state.gfxCtx); + OPEN_DISPS(play->state.gfxCtx); switch (this->unk25C) { case 0: @@ -105,8 +105,8 @@ void EnEndingHero5_Draw(Actor* thisx, GlobalContext* globalCtx) { break; } - SkelAnime_DrawFlexOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, - NULL, EnEndingHero5_PostLimbDraw, &this->actor); + SkelAnime_DrawFlexOpa(play, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, NULL, + EnEndingHero5_PostLimbDraw, &this->actor); - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->state.gfxCtx); } diff --git a/src/overlays/actors/ovl_En_Ending_Hero5/z_en_ending_hero5.h b/src/overlays/actors/ovl_En_Ending_Hero5/z_en_ending_hero5.h index e9f3ecf18..4b26b03db 100644 --- a/src/overlays/actors/ovl_En_Ending_Hero5/z_en_ending_hero5.h +++ b/src/overlays/actors/ovl_En_Ending_Hero5/z_en_ending_hero5.h @@ -5,7 +5,7 @@ struct EnEndingHero5; -typedef void (*EnEndingHero5ActionFunc)(struct EnEndingHero5*, GlobalContext*); +typedef void (*EnEndingHero5ActionFunc)(struct EnEndingHero5*, PlayState*); typedef struct EnEndingHero5 { /* 0x000 */ Actor actor; 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 82df507c2..d6da2f978 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 @@ -15,14 +15,14 @@ #define THIS ((EnEndingHero6*)thisx) -void EnEndingHero6_Init(Actor* thisx, GlobalContext* globalCtx); -void EnEndingHero6_Destroy(Actor* thisx, GlobalContext* globalCtx); -void EnEndingHero6_Update(Actor* thisx, GlobalContext* globalCtx); -void EnEndingHero6_Draw(Actor* thisx, GlobalContext* globalCtx); +void EnEndingHero6_Init(Actor* thisx, PlayState* play); +void EnEndingHero6_Destroy(Actor* thisx, PlayState* play); +void EnEndingHero6_Update(Actor* thisx, PlayState* play); +void EnEndingHero6_Draw(Actor* thisx, PlayState* play); void EnEndingHero6_InitSkelAnime(EnEndingHero6* this, s32 npcIndex); void EnEndingHero6_SetupIdle(EnEndingHero6* this); -void EnEndingHero6_Idle(EnEndingHero6* this, GlobalContext* globalCtx); +void EnEndingHero6_Idle(EnEndingHero6* this, PlayState* play); const ActorInit En_Ending_Hero6_InitVars = { ACTOR_EN_ENDING_HERO6, @@ -37,9 +37,9 @@ const ActorInit En_Ending_Hero6_InitVars = { }; static FlexSkeletonHeader* sSkeletons[] = { - &object_dt_Skel_00B0CC, &object_bai_Skel_007908, &object_toryo_Skel_007150, - &gSoldierSkeleton, &object_daiku_Skel_00A850, &object_daiku_Skel_00A850, - &object_daiku_Skel_00A850, &object_daiku_Skel_00A850, &object_daiku_Skel_00A850, + &object_dt_Skel_00B0CC, &object_bai_Skel_007908, &object_toryo_Skel_007150, &gSoldierSkel, + &object_daiku_Skel_00A850, &object_daiku_Skel_00A850, &object_daiku_Skel_00A850, &object_daiku_Skel_00A850, + &object_daiku_Skel_00A850, }; static AnimationHeader* sAnimations[] = { @@ -50,26 +50,26 @@ static AnimationHeader* sAnimations[] = { static s32 sLimbCounts[] = { 15, 20, 17, 17, 17, 17, 17, 17, 17 }; -void EnEndingHero6_Init(Actor* thisx, GlobalContext* globalCtx) { +void EnEndingHero6_Init(Actor* thisx, PlayState* play) { EnEndingHero6* this = THIS; 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, sSkeletons[this->npcIndex], sAnimations[this->npcIndex], + SkelAnime_InitFlex(play, &this->skelAnime, sSkeletons[this->npcIndex], sAnimations[this->npcIndex], this->jointTable, this->morphTable, sLimbCounts[this->npcIndex]); ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 25.0f); EnEndingHero6_SetupIdle(this); } -void EnEndingHero6_Destroy(Actor* thisx, GlobalContext* globalCtx) { +void EnEndingHero6_Destroy(Actor* thisx, PlayState* play) { } void EnEndingHero6_InitSkelAnime(EnEndingHero6* this, s32 npcIndex) { this->animIndex = npcIndex; this->frameCount = Animation_GetLastFrame(sAnimations[npcIndex]); - Animation_Change(&this->skelAnime, sAnimations[this->animIndex], 1.0f, 0.f, this->frameCount, 0, 0.0f); + Animation_Change(&this->skelAnime, sAnimations[this->animIndex], 1.0f, 0.f, this->frameCount, ANIMMODE_LOOP, 0.0f); } void EnEndingHero6_SetupIdle(EnEndingHero6* this) { @@ -78,11 +78,11 @@ void EnEndingHero6_SetupIdle(EnEndingHero6* this) { this->actionFunc = EnEndingHero6_Idle; } -void EnEndingHero6_Idle(EnEndingHero6* this, GlobalContext* globalCtx) { +void EnEndingHero6_Idle(EnEndingHero6* this, PlayState* play) { SkelAnime_Update(&this->skelAnime); } -void EnEndingHero6_Update(Actor* thisx, GlobalContext* globalCtx) { +void EnEndingHero6_Update(Actor* thisx, PlayState* play) { EnEndingHero6* this = THIS; if (this->timer != 0) { @@ -99,28 +99,28 @@ void EnEndingHero6_Update(Actor* thisx, GlobalContext* globalCtx) { } } - this->actionFunc(this, globalCtx); + this->actionFunc(this, play); Actor_MoveWithGravity(&this->actor); - Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 20.0f, 20.0f, 50.0f, 0x1D); + Actor_UpdateBgCheckInfo(play, &this->actor, 20.0f, 20.0f, 50.0f, 0x1D); } -void EnEndingHero6_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx) { +void EnEndingHero6_PostLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx) { static Gfx* D_80C2426C[] = { object_daiku_DL_0070C0, object_daiku_DL_006FB0, object_daiku_DL_006E80, object_daiku_DL_006D70, object_daiku_DL_00A390 }; EnEndingHero6* this = THIS; s32 index; - OPEN_DISPS(globalCtx->state.gfxCtx); + OPEN_DISPS(play->state.gfxCtx); if (this->npcIndex >= 4 && limbIndex == 15) { index = this->npcIndex - 4; gSPDisplayList(POLY_OPA_DISP++, D_80C2426C[index]); } - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->state.gfxCtx); } -void EnEndingHero6_Draw(Actor* thisx, GlobalContext* globalCtx) { +void EnEndingHero6_Draw(Actor* thisx, PlayState* play) { static TexturePtr D_80C24280[] = { object_dt_Tex_007350, object_dt_Tex_009590, object_dt_Tex_009F90, object_dt_Tex_00A790, object_dt_Tex_00AB90 }; static TexturePtr D_80C24294[] = { object_dt_Tex_007750, object_dt_Tex_00A390, object_dt_Tex_00A490 }; @@ -129,13 +129,13 @@ void EnEndingHero6_Draw(Actor* thisx, GlobalContext* globalCtx) { s32 index = 0; if (this->isIdle == 1) { - OPEN_DISPS(globalCtx->state.gfxCtx); + OPEN_DISPS(play->state.gfxCtx); - func_8012C28C(globalCtx->state.gfxCtx); - func_8012C2DC(globalCtx->state.gfxCtx); + func_8012C28C(play->state.gfxCtx); + func_8012C2DC(play->state.gfxCtx); - if (this->objectIndex >= 0 && Object_IsLoaded(&globalCtx->objectCtx, this->objectIndex)) { - gSPSegment(POLY_OPA_DISP++, 0x06, globalCtx->objectCtx.status[this->objectIndex].segment); + if (this->objectIndex >= 0 && Object_IsLoaded(&play->objectCtx, this->objectIndex)) { + gSPSegment(POLY_OPA_DISP++, 0x06, play->objectCtx.status[this->objectIndex].segment); switch (this->npcIndex) { case 4: @@ -165,10 +165,10 @@ void EnEndingHero6_Draw(Actor* thisx, GlobalContext* globalCtx) { gSPSegment(POLY_OPA_DISP++, 0x09, Lib_SegmentedToVirtual(D_80C24294[index])); } - SkelAnime_DrawFlexOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, + SkelAnime_DrawFlexOpa(play, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, NULL, EnEndingHero6_PostLimbDraw, &this->actor); } - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->state.gfxCtx); } } diff --git a/src/overlays/actors/ovl_En_Ending_Hero6/z_en_ending_hero6.h b/src/overlays/actors/ovl_En_Ending_Hero6/z_en_ending_hero6.h index 4f8989634..f30d09a7a 100644 --- a/src/overlays/actors/ovl_En_Ending_Hero6/z_en_ending_hero6.h +++ b/src/overlays/actors/ovl_En_Ending_Hero6/z_en_ending_hero6.h @@ -5,22 +5,22 @@ struct EnEndingHero6; -typedef void (*EnEndingHero6ActionFunc)(struct EnEndingHero6*, GlobalContext*); +typedef void (*EnEndingHero6ActionFunc)(struct EnEndingHero6*, PlayState*); typedef struct EnEndingHero6 { - /* 0x0000 */ Actor actor; - /* 0x0144 */ SkelAnime skelAnime; - /* 0x0188 */ Vec3s jointTable[20]; - /* 0x0200 */ Vec3s morphTable[20]; - /* 0x0278 */ EnEndingHero6ActionFunc actionFunc; - /* 0x027C */ s32 animIndex; - /* 0x0280 */ s32 npcIndex; - /* 0x0284 */ s8 objectIndex; - /* 0x0286 */ s16 timer; - /* 0x0288 */ s16 blinkTimer; - /* 0x028A */ s16 eyeState; - /* 0x028C */ f32 frameCount; - /* 0x0290 */ s16 isIdle; + /* 0x000 */ Actor actor; + /* 0x144 */ SkelAnime skelAnime; + /* 0x188 */ Vec3s jointTable[20]; + /* 0x200 */ Vec3s morphTable[20]; + /* 0x278 */ EnEndingHero6ActionFunc actionFunc; + /* 0x27C */ s32 animIndex; + /* 0x280 */ s32 npcIndex; + /* 0x284 */ s8 objectIndex; + /* 0x286 */ s16 timer; + /* 0x288 */ s16 blinkTimer; + /* 0x28A */ s16 eyeState; + /* 0x28C */ f32 frameCount; + /* 0x290 */ s16 isIdle; } EnEndingHero6; // size = 0x294 extern const ActorInit En_Ending_Hero6_InitVars; diff --git a/src/overlays/actors/ovl_En_Estone/z_en_estone.c b/src/overlays/actors/ovl_En_Estone/z_en_estone.c index b1ac6673a..006166e4b 100644 --- a/src/overlays/actors/ovl_En_Estone/z_en_estone.c +++ b/src/overlays/actors/ovl_En_Estone/z_en_estone.c @@ -10,13 +10,13 @@ #define THIS ((EnEstone*)thisx) -void EnEstone_Init(Actor* thisx, GlobalContext* globalCtx); -void EnEstone_Destroy(Actor* thisx, GlobalContext* globalCtx); -void EnEstone_Update(Actor* thisx, GlobalContext* globalCtx); -void EnEstone_Draw(Actor* thisx, GlobalContext* globalCtx); +void EnEstone_Init(Actor* thisx, PlayState* play); +void EnEstone_Destroy(Actor* thisx, PlayState* play); +void EnEstone_Update(Actor* thisx, PlayState* play); +void EnEstone_Draw(Actor* thisx, PlayState* play); -void func_80A9A1DC(EnEstone* this, GlobalContext* globalCtx); -void func_80A9A4B0(EnEstone* this, GlobalContext* globalCtx); +void func_80A9A1DC(EnEstone* this, PlayState* play); +void func_80A9A4B0(EnEstone* this, PlayState* play); #if 0 const ActorInit En_Estone_InitVars = { diff --git a/src/overlays/actors/ovl_En_Estone/z_en_estone.h b/src/overlays/actors/ovl_En_Estone/z_en_estone.h index 848d41f8b..b265bf4de 100644 --- a/src/overlays/actors/ovl_En_Estone/z_en_estone.h +++ b/src/overlays/actors/ovl_En_Estone/z_en_estone.h @@ -5,7 +5,7 @@ struct EnEstone; -typedef void (*EnEstoneActionFunc)(struct EnEstone*, GlobalContext*); +typedef void (*EnEstoneActionFunc)(struct EnEstone*, PlayState*); typedef struct EnEstone { /* 0x0000 */ Actor actor; 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 dabd62e0f..7e3a93fa8 100644 --- a/src/overlays/actors/ovl_En_Fall/z_en_fall.c +++ b/src/overlays/actors/ovl_En_Fall/z_en_fall.c @@ -28,37 +28,39 @@ #define FLAG_FIRE_BALL_INTENSIFIES (1 << 0) #define FLAG_FIRE_RING_APPEARS (1 << 1) -void EnFall_Init(Actor* thisx, GlobalContext* globalCtx); -void EnFall_Destroy(Actor* thisx, GlobalContext* globalCtx); -void EnFall_Update(Actor* thisx, GlobalContext* globalCtx); +void EnFall_Init(Actor* thisx, PlayState* play); +void EnFall_Destroy(Actor* thisx, PlayState* play); +void EnFall_Update(Actor* thisx, PlayState* play); -void EnFall_Setup(EnFall* this, GlobalContext* globalCtx); -void EnFall_CrashingMoon_PerformCutsceneActions(EnFall* this, GlobalContext* globalCtx); -void EnFall_StoppedOpenMouthMoon_PerformCutsceneActions(EnFall* this, GlobalContext* globalCtx); -void EnFall_StoppedClosedMouthMoon_PerformCutsceneActions(EnFall* this, GlobalContext* globalCtx); -void EnFall_ClockTowerOrTitleScreenMoon_PerformCutsceneActions(EnFall* this, GlobalContext* globalCtx); -void EnFall_Moon_PerformDefaultActions(EnFall* this, GlobalContext* globalCtx); -void EnFall_MoonsTear_Fall(EnFall* this, GlobalContext* globalCtx); -void EnFall_Fireball_Update(Actor* thisx, GlobalContext* globalCtx); -void EnFall_RisingDebris_Update(Actor* thisx, GlobalContext* globalCtx); -void EnFall_FireRing_Update(Actor* thisx, GlobalContext* globalCtx); -void EnFall_Moon_Draw(Actor* thisx, GlobalContext* globalCtx); -void EnFall_OpenMouthMoon_Draw(Actor* thisx, GlobalContext* globalCtx); -void EnFall_LodMoon_DrawWithoutLerp(Actor* thisx, GlobalContext* globalCtx); -void EnFall_LodMoon_DrawWithLerp(Actor* thisx, GlobalContext* globalCtx); -void EnFall_Fireball_Draw(Actor* thisx, GlobalContext* globalCtx); -void EnFall_RisingDebris_Draw(Actor* thisx, GlobalContext* globalCtx); -void EnFall_FireRing_Draw(Actor* thisx, GlobalContext* globalCtx); -void EnFall_MoonsTear_Draw(Actor* thisx, GlobalContext* globalCtx); +void EnFall_Setup(EnFall* this, PlayState* play); +void EnFall_CrashingMoon_PerformCutsceneActions(EnFall* this, PlayState* play); +void EnFall_StoppedOpenMouthMoon_PerformCutsceneActions(EnFall* this, PlayState* play); +void EnFall_StoppedClosedMouthMoon_PerformCutsceneActions(EnFall* this, PlayState* play); +void EnFall_ClockTowerOrTitleScreenMoon_PerformCutsceneActions(EnFall* this, PlayState* play); +void EnFall_Moon_PerformDefaultActions(EnFall* this, PlayState* play); +void EnFall_MoonsTear_Fall(EnFall* this, PlayState* play); +void EnFall_Fireball_Update(Actor* thisx, PlayState* play); +void EnFall_RisingDebris_Update(Actor* thisx, PlayState* play); +void EnFall_FireRing_Update(Actor* thisx, PlayState* play); +void EnFall_Moon_Draw(Actor* thisx, PlayState* play); +void EnFall_OpenMouthMoon_Draw(Actor* thisx, PlayState* play); +void EnFall_LodMoon_DrawWithoutLerp(Actor* thisx, PlayState* play); +void EnFall_LodMoon_DrawWithLerp(Actor* thisx, PlayState* play); +void EnFall_Fireball_Draw(Actor* thisx, PlayState* play); +void EnFall_RisingDebris_Draw(Actor* thisx, PlayState* play); +void EnFall_FireRing_Draw(Actor* thisx, PlayState* play); +void EnFall_MoonsTear_Draw(Actor* thisx, PlayState* play); typedef struct { u8 modelIndex; 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, @@ -76,7 +78,7 @@ const ActorInit En_Fall_InitVars = { * Sets the scale of the moon depending on the current day. On the Final Day, * it also moves the moon closer to the ground depending on the current time. */ -void EnFall_Moon_AdjustScaleAndPosition(EnFall* this, GlobalContext* globalCtx) { +void EnFall_Moon_AdjustScaleAndPosition(EnFall* this, PlayState* play) { u16 currentTime = gSaveContext.save.time; u16 dayStartTime = this->dayStartTime; f32 finalDayRelativeHeight; @@ -115,16 +117,16 @@ 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) { +void EnFall_Init(Actor* thisx, PlayState* play) { EnFall* this = THIS; s32 objectIndex; @@ -159,19 +161,19 @@ void EnFall_Init(Actor* thisx, GlobalContext* globalCtx) { case EN_FALL_TYPE_LODMOON_NO_LERP: case EN_FALL_TYPE_LODMOON: case EN_FALL_TYPE_LODMOON_INVERTED_STONE_TOWER: - objectIndex = Object_GetIndex(&globalCtx->objectCtx, OBJECT_LODMOON); + objectIndex = Object_GetIndex(&play->objectCtx, OBJECT_LODMOON); break; case EN_FALL_TYPE_MOONS_TEAR: - objectIndex = Object_GetIndex(&globalCtx->objectCtx, OBJECT_MOONSTON); + objectIndex = Object_GetIndex(&play->objectCtx, OBJECT_MOONSTON); break; case EN_FALL_TYPE_STOPPED_MOON_OPEN_MOUTH: - objectIndex = Object_GetIndex(&globalCtx->objectCtx, OBJECT_FALL2); + objectIndex = Object_GetIndex(&play->objectCtx, OBJECT_FALL2); break; default: - objectIndex = Object_GetIndex(&globalCtx->objectCtx, OBJECT_FALL); + objectIndex = Object_GetIndex(&play->objectCtx, OBJECT_FALL); break; } @@ -183,14 +185,14 @@ void EnFall_Init(Actor* thisx, GlobalContext* globalCtx) { this->actionFunc = EnFall_Setup; } -void EnFall_Destroy(Actor* thisx, GlobalContext* globalCtx) { +void EnFall_Destroy(Actor* thisx, PlayState* play) { } /** * Finds the Termina Field moon so the Moon's Tear can spawn in the correct place. */ -Actor* EnFall_MoonsTear_GetTerminaFieldMoon(GlobalContext* globalCtx) { - Actor* itemAction = globalCtx->actorCtx.actorLists[ACTORCAT_ITEMACTION].first; +Actor* EnFall_MoonsTear_GetTerminaFieldMoon(PlayState* play) { + Actor* itemAction = play->actorCtx.actorLists[ACTORCAT_ITEMACTION].first; while (itemAction != NULL) { if (itemAction->id == ACTOR_EN_FALL && EN_FALL_TYPE(itemAction) == EN_FALL_TYPE_TERMINA_FIELD_MOON) { @@ -201,10 +203,10 @@ Actor* EnFall_MoonsTear_GetTerminaFieldMoon(GlobalContext* globalCtx) { return NULL; } -void EnFall_Setup(EnFall* this, GlobalContext* globalCtx) { +void EnFall_Setup(EnFall* this, PlayState* play) { Actor* moon; - if (Object_IsLoaded(&globalCtx->objectCtx, this->objIndex)) { + if (Object_IsLoaded(&play->objectCtx, this->objIndex)) { this->actor.objBankIndex = this->objIndex; this->actionFunc = EnFall_Moon_PerformDefaultActions; switch (EN_FALL_TYPE(&this->actor)) { @@ -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; @@ -261,7 +263,7 @@ void EnFall_Setup(EnFall* this, GlobalContext* globalCtx) { this->actor.draw = EnFall_LodMoon_DrawWithoutLerp; this->dayStartTime = CLOCK_TIME(6, 0); this->currentDay = CURRENT_DAY; - EnFall_Moon_AdjustScaleAndPosition(this, globalCtx); + EnFall_Moon_AdjustScaleAndPosition(this, play); break; case EN_FALL_TYPE_LODMOON: @@ -269,7 +271,7 @@ void EnFall_Setup(EnFall* this, GlobalContext* globalCtx) { this->actor.draw = EnFall_LodMoon_DrawWithLerp; this->dayStartTime = CLOCK_TIME(6, 0); this->currentDay = CURRENT_DAY; - EnFall_Moon_AdjustScaleAndPosition(this, globalCtx); + EnFall_Moon_AdjustScaleAndPosition(this, play); break; case EN_FALL_TYPE_MOONS_TEAR: @@ -277,10 +279,10 @@ void EnFall_Setup(EnFall* this, GlobalContext* globalCtx) { this->actor.draw = NULL; this->actionFunc = EnFall_MoonsTear_Fall; Actor_SetScale(&this->actor, 0.02f); - if (!(globalCtx->actorCtx.unk5 & 2)) { + if (!(play->actorCtx.unk5 & 2)) { Actor_MarkForDeath(&this->actor); } - moon = EnFall_MoonsTear_GetTerminaFieldMoon(globalCtx); + moon = EnFall_MoonsTear_GetTerminaFieldMoon(play); this->actor.child = moon; if (moon == NULL) { Actor_MarkForDeath(&this->actor); @@ -304,20 +306,19 @@ void EnFall_Setup(EnFall* this, GlobalContext* globalCtx) { this->actor.draw = EnFall_Moon_Draw; this->dayStartTime = CLOCK_TIME(6, 0); this->currentDay = CURRENT_DAY; - EnFall_Moon_AdjustScaleAndPosition(this, globalCtx); + EnFall_Moon_AdjustScaleAndPosition(this, play); break; } } } -void EnFall_CrashingMoon_HandleGiantsCutscene(EnFall* this, GlobalContext* globalCtx) { +void EnFall_CrashingMoon_HandleGiantsCutscene(EnFall* this, PlayState* play) { static s32 sGiantsCutsceneState = 0; - if (globalCtx->sceneNum == SCENE_00KEIKOKU && gSaveContext.sceneSetupIndex == 1 && - globalCtx->csCtx.currentCsIndex == 0) { + if (play->sceneNum == SCENE_00KEIKOKU && gSaveContext.sceneSetupIndex == 1 && play->csCtx.currentCsIndex == 0) { switch (sGiantsCutsceneState) { case 0: - if (globalCtx->csCtx.state != 0) { + if (play->csCtx.state != 0) { sGiantsCutsceneState += 2; } break; @@ -339,34 +340,34 @@ void EnFall_CrashingMoon_HandleGiantsCutscene(EnFall* this, GlobalContext* globa } else { ActorCutscene_SetIntentToPlay(0xB); } - } else if (globalCtx->csCtx.frames > 1600) { - globalCtx->nextEntranceIndex = 0x2C00; + } else if (play->csCtx.frames > 1600) { + play->nextEntrance = ENTRANCE(CLOCK_TOWER_ROOFTOP, 0); gSaveContext.nextCutsceneIndex = 0xFFF2; - globalCtx->sceneLoadFlag = 0x14; - globalCtx->unk_1887F = 2; - gSaveContext.nextTransition = 2; + play->transitionTrigger = TRANS_TRIGGER_START; + play->transitionType = TRANS_TYPE_02; + gSaveContext.nextTransitionType = TRANS_TYPE_02; sGiantsCutsceneState = 9; } break; case 9: - globalCtx->csCtx.frames--; + play->csCtx.frames--; break; } } } -void EnFall_CrashingMoon_PerformCutsceneActions(EnFall* this, GlobalContext* globalCtx) { - EnFall_CrashingMoon_HandleGiantsCutscene(this, globalCtx); - if (Cutscene_CheckActorAction(globalCtx, 0x85)) { - if (Cutscene_CheckActorAction(globalCtx, 133) && - globalCtx->csCtx.actorActions[Cutscene_GetActorActionIndex(globalCtx, 133)]->action == 1) { +void EnFall_CrashingMoon_PerformCutsceneActions(EnFall* this, PlayState* play) { + EnFall_CrashingMoon_HandleGiantsCutscene(this, play); + if (Cutscene_CheckActorAction(play, 0x85)) { + if (Cutscene_CheckActorAction(play, 133) && + play->csCtx.actorActions[Cutscene_GetActorActionIndex(play, 133)]->action == 1) { this->actor.draw = NULL; } else { this->actor.draw = EnFall_Moon_Draw; - if (Cutscene_CheckActorAction(globalCtx, 133) && - globalCtx->csCtx.actorActions[Cutscene_GetActorActionIndex(globalCtx, 133)]->action == 2) { - Cutscene_ActorTranslateAndYaw(&this->actor, globalCtx, Cutscene_GetActorActionIndex(globalCtx, 133)); + if (Cutscene_CheckActorAction(play, 133) && + play->csCtx.actorActions[Cutscene_GetActorActionIndex(play, 133)]->action == 2) { + Cutscene_ActorTranslateAndYaw(&this->actor, play, Cutscene_GetActorActionIndex(play, 133)); } } } else { @@ -374,9 +375,9 @@ void EnFall_CrashingMoon_PerformCutsceneActions(EnFall* this, GlobalContext* glo } } -void EnFall_StoppedOpenMouthMoon_PerformCutsceneActions(EnFall* this, GlobalContext* globalCtx) { - if (Cutscene_CheckActorAction(globalCtx, 133)) { - switch (globalCtx->csCtx.actorActions[Cutscene_GetActorActionIndex(globalCtx, 133)]->action) { +void EnFall_StoppedOpenMouthMoon_PerformCutsceneActions(EnFall* this, PlayState* play) { + if (Cutscene_CheckActorAction(play, 133)) { + switch (play->csCtx.actorActions[Cutscene_GetActorActionIndex(play, 133)]->action) { case 3: if (this->eyeGlowIntensity == 0.0f) { Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_MOON_EYE_FLASH); @@ -394,11 +395,11 @@ void EnFall_StoppedOpenMouthMoon_PerformCutsceneActions(EnFall* this, GlobalCont } } -void EnFall_StoppedClosedMouthMoon_PerformCutsceneActions(EnFall* this, GlobalContext* globalCtx) { - if (Cutscene_CheckActorAction(globalCtx, 133)) { - switch (globalCtx->csCtx.actorActions[Cutscene_GetActorActionIndex(globalCtx, 133)]->action) { +void EnFall_StoppedClosedMouthMoon_PerformCutsceneActions(EnFall* this, PlayState* play) { + if (Cutscene_CheckActorAction(play, 133)) { + switch (play->csCtx.actorActions[Cutscene_GetActorActionIndex(play, 133)]->action) { case 2: - Cutscene_ActorTranslateAndYaw(&this->actor, globalCtx, Cutscene_GetActorActionIndex(globalCtx, 133)); + Cutscene_ActorTranslateAndYaw(&this->actor, play, Cutscene_GetActorActionIndex(play, 133)); break; case 4: @@ -407,10 +408,10 @@ void EnFall_StoppedClosedMouthMoon_PerformCutsceneActions(EnFall* this, GlobalCo } } - if (globalCtx->sceneNum == SCENE_OKUJOU && gSaveContext.sceneSetupIndex == 2) { - switch (globalCtx->csCtx.currentCsIndex) { + if (play->sceneNum == SCENE_OKUJOU && gSaveContext.sceneSetupIndex == 2) { + switch (play->csCtx.currentCsIndex) { case 0: - switch (globalCtx->csCtx.frames) { + switch (play->csCtx.frames) { case 1060: Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_MOON_SCREAM1); break; @@ -423,13 +424,13 @@ void EnFall_StoppedClosedMouthMoon_PerformCutsceneActions(EnFall* this, GlobalCo Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_SLIP_MOON); break; } - if (globalCtx->csCtx.frames >= 1145) { + if (play->csCtx.frames >= 1145) { func_800B9010(&this->actor, NA_SE_EV_FALL_POWER - SFX_FLAG); } break; case 1: - switch (globalCtx->csCtx.frames) { + switch (play->csCtx.frames) { case 561: Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_MOON_SCREAM1); break; @@ -442,7 +443,7 @@ void EnFall_StoppedClosedMouthMoon_PerformCutsceneActions(EnFall* this, GlobalCo Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_SLIP_MOON); break; } - if (globalCtx->csCtx.frames >= 650) { + if (play->csCtx.frames >= 650) { func_800B9010(&this->actor, NA_SE_EV_FALL_POWER - SFX_FLAG); } break; @@ -450,8 +451,8 @@ void EnFall_StoppedClosedMouthMoon_PerformCutsceneActions(EnFall* this, GlobalCo } } -void EnFall_ClockTowerOrTitleScreenMoon_PerformCutsceneActions(EnFall* this, GlobalContext* globalCtx) { - if (globalCtx->csCtx.state != 0 && globalCtx->sceneNum == SCENE_OKUJOU) { +void EnFall_ClockTowerOrTitleScreenMoon_PerformCutsceneActions(EnFall* this, PlayState* play) { + if (play->csCtx.state != 0 && play->sceneNum == SCENE_OKUJOU) { func_800B9010(&this->actor, NA_SE_EV_MOON_FALL - SFX_FLAG); } } @@ -459,19 +460,19 @@ void EnFall_ClockTowerOrTitleScreenMoon_PerformCutsceneActions(EnFall* this, Glo /** * Used by the Moon in Termina Field, as well as all LodMoons. */ -void EnFall_Moon_PerformDefaultActions(EnFall* this, GlobalContext* globalCtx) { +void EnFall_Moon_PerformDefaultActions(EnFall* this, PlayState* play) { u16 currentDay; - if (Cutscene_CheckActorAction(globalCtx, 133)) { - if (Cutscene_CheckActorAction(globalCtx, 133) && - globalCtx->csCtx.actorActions[Cutscene_GetActorActionIndex(globalCtx, 133)]->action == 1) { + if (Cutscene_CheckActorAction(play, 133)) { + if (Cutscene_CheckActorAction(play, 133) && + play->csCtx.actorActions[Cutscene_GetActorActionIndex(play, 133)]->action == 1) { this->actor.draw = NULL; } else { Actor_SetScale(&this->actor, this->scale * 3.6f); this->actor.draw = EnFall_Moon_Draw; - if (Cutscene_CheckActorAction(globalCtx, 133) && - globalCtx->csCtx.actorActions[Cutscene_GetActorActionIndex(globalCtx, 133)]->action == 2) { - Cutscene_ActorTranslateAndYaw(&this->actor, globalCtx, Cutscene_GetActorActionIndex(globalCtx, 133)); + if (Cutscene_CheckActorAction(play, 133) && + play->csCtx.actorActions[Cutscene_GetActorActionIndex(play, 133)]->action == 2) { + Cutscene_ActorTranslateAndYaw(&this->actor, play, Cutscene_GetActorActionIndex(play, 133)); } } } else { @@ -483,7 +484,7 @@ void EnFall_Moon_PerformDefaultActions(EnFall* this, GlobalContext* globalCtx) { this->currentDay = currentDay; this->dayStartTime = gSaveContext.save.time; } - EnFall_Moon_AdjustScaleAndPosition(this, globalCtx); + EnFall_Moon_AdjustScaleAndPosition(this, play); } } @@ -503,15 +504,14 @@ void EnFall_MoonsTear_Initialize(EnFall* this) { this->actor.shape.rot.y = this->actor.world.rot.y; } -void EnFall_MoonsTear_DoNothing(EnFall* this, GlobalContext* globalCtx) { +void EnFall_MoonsTear_DoNothing(EnFall* this, PlayState* play) { } -void EnFall_MoonsTear_Fall(EnFall* this, GlobalContext* globalCtx) { +void EnFall_MoonsTear_Fall(EnFall* this, PlayState* play) { s32 pad; - if (Cutscene_CheckActorAction(globalCtx, 517) && - globalCtx->csCtx.actorActions[Cutscene_GetActorActionIndex(globalCtx, 517)]->action == 2 && - this->actor.draw == NULL) { + if (Cutscene_CheckActorAction(play, 517) && + play->csCtx.actorActions[Cutscene_GetActorActionIndex(play, 517)]->action == 2 && this->actor.draw == NULL) { EnFall_MoonsTear_Initialize(this); } @@ -520,10 +520,10 @@ void EnFall_MoonsTear_Fall(EnFall* this, GlobalContext* globalCtx) { Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_GORON_BOUND_1); 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, + Actor_SpawnAsChild(&play->actorCtx, &this->actor, play, ACTOR_EN_TEST, this->actor.world.pos.x, this->actor.world.pos.y, this->actor.world.pos.z, 0, 0, 0, -2); - Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_CLEAR_TAG, this->actor.world.pos.x, - this->actor.world.pos.y, this->actor.world.pos.z, 0, 0, 0, CLEAR_TAG_LARGE_EXPLOSION); + Actor_Spawn(&play->actorCtx, play, ACTOR_EN_CLEAR_TAG, this->actor.world.pos.x, this->actor.world.pos.y, + this->actor.world.pos.z, 0, 0, 0, CLEAR_TAG_LARGE_EXPLOSION); this->actor.draw = NULL; this->actionFunc = EnFall_MoonsTear_DoNothing; } else { @@ -532,9 +532,10 @@ void EnFall_MoonsTear_Fall(EnFall* this, GlobalContext* globalCtx) { } } -void EnFall_Update(Actor* thisx, GlobalContext* globalCtx) { +void EnFall_Update(Actor* thisx, PlayState* play) { EnFall* this = THIS; - this->actionFunc(this, globalCtx); + + this->actionFunc(this, play); } /** @@ -570,15 +571,14 @@ void EnFall_Fireball_SetPerVertexAlpha(f32 fireballAlpha) { } } -void EnFall_Fireball_Update(Actor* thisx, GlobalContext* globalCtx) { +void EnFall_Fireball_Update(Actor* thisx, PlayState* play) { EnFall* this = THIS; - if (globalCtx->sceneNum == SCENE_00KEIKOKU && gSaveContext.sceneSetupIndex == 0 && - globalCtx->csCtx.currentCsIndex == 2) { - globalCtx->skyboxCtx.rotY -= 0.05f; + if (play->sceneNum == SCENE_00KEIKOKU && gSaveContext.sceneSetupIndex == 0 && play->csCtx.currentCsIndex == 2) { + play->skyboxCtx.rotY -= 0.05f; } - if (Cutscene_CheckActorAction(globalCtx, 450)) { + if (Cutscene_CheckActorAction(play, 450)) { this->actor.draw = EnFall_Fireball_Draw; if (this->flags & FLAG_FIRE_BALL_INTENSIFIES) { this->fireballIntensity += 0.01f; @@ -586,9 +586,9 @@ void EnFall_Fireball_Update(Actor* thisx, GlobalContext* globalCtx) { this->fireballIntensity = 1.0f; } } - Cutscene_ActorTranslateAndYaw(&this->actor, globalCtx, Cutscene_GetActorActionIndex(globalCtx, 450)); + Cutscene_ActorTranslateAndYaw(&this->actor, play, Cutscene_GetActorActionIndex(play, 450)); - switch (globalCtx->csCtx.actorActions[Cutscene_GetActorActionIndex(globalCtx, 450)]->action) { + switch (play->csCtx.actorActions[Cutscene_GetActorActionIndex(play, 450)]->action) { default: this->actor.draw = NULL; this->fireballAlpha = 0; @@ -625,53 +625,53 @@ void EnFall_Fireball_Update(Actor* thisx, GlobalContext* globalCtx) { this->actor.draw = NULL; } - if (Cutscene_CheckActorAction(globalCtx, 0x1C2) && this->fireballAlpha > 0) { + if (Cutscene_CheckActorAction(play, 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; } } @@ -679,28 +679,28 @@ s32 EnFall_RisingDebris_InitializeParticles(EnFall* this) { return false; } -void EnFall_RisingDebris_Update(Actor* thisx, GlobalContext* globalCtx) { +void EnFall_RisingDebris_Update(Actor* thisx, PlayState* play) { EnFall* this = THIS; - if (Cutscene_CheckActorAction(globalCtx, 451)) { - if (Cutscene_CheckActorAction(globalCtx, 451) && - globalCtx->csCtx.actorActions[Cutscene_GetActorActionIndex(globalCtx, 451)]->action == 2) { - EnFall_RisingDebris_UpdateParticles(this); - EnFall_RisingDebris_InitializeParticles(this); - } else if (this->activeDebrisParticleCount != 0) { - EnFall_RisingDebris_ResetParticles(this); + if (Cutscene_CheckActorAction(play, 451)) { + if (Cutscene_CheckActorAction(play, 451) && + play->csCtx.actorActions[Cutscene_GetActorActionIndex(play, 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) { +void EnFall_FireRing_Update(Actor* thisx, PlayState* play) { EnFall* this = THIS; - if (Cutscene_CheckActorAction(globalCtx, 450) && - globalCtx->csCtx.actorActions[Cutscene_GetActorActionIndex(globalCtx, 450)]->action == 5) { + if (Cutscene_CheckActorAction(play, 450) && + play->csCtx.actorActions[Cutscene_GetActorActionIndex(play, 450)]->action == 5) { if (!(this->flags & FLAG_FIRE_RING_APPEARS)) { Actor_PlaySfxAtPos(&this->actor, NA_SE_IT_DM_RING_EXPLOSION); } @@ -726,53 +726,53 @@ void EnFall_FireRing_Update(Actor* thisx, GlobalContext* globalCtx) { * Used for all closed-mouth high-detail moons, including * StoppedClosedMouthMoon and CrashingMoon. */ -void EnFall_Moon_Draw(Actor* thisx, GlobalContext* globalCtx) { +void EnFall_Moon_Draw(Actor* thisx, PlayState* play) { // This offsets the moon's focus so that the Moon's Tear actually falls // out of its eye when looking at it through the telescope. static Vec3f sFocusOffset[] = { 1800.0f, 1000.0f, 4250.0f }; EnFall* this = THIS; s32 primColor; - OPEN_DISPS(globalCtx->state.gfxCtx); + OPEN_DISPS(play->state.gfxCtx); - func_8012C28C(globalCtx->state.gfxCtx); - gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - Matrix_MultiplyVector3fByState(sFocusOffset, &this->actor.focus.pos); + func_8012C28C(play->state.gfxCtx); + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + Matrix_MultVec3f(sFocusOffset, &this->actor.focus.pos); primColor = (this->eyeGlowIntensity * 200.0f) + 40.0f; gDPSetPrimColor(POLY_OPA_DISP++, 0, 0x80, primColor, primColor, primColor, 255); gSPDisplayList(POLY_OPA_DISP++, gMoonDL); - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->state.gfxCtx); } -void EnFall_OpenMouthMoon_Draw(Actor* thisx, GlobalContext* globalCtx) { +void EnFall_OpenMouthMoon_Draw(Actor* thisx, PlayState* play) { EnFall* this = THIS; s32 primColor; - OPEN_DISPS(globalCtx->state.gfxCtx); + OPEN_DISPS(play->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); + func_8012C28C(play->state.gfxCtx); + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); primColor = (this->eyeGlowIntensity * 200.0f) + 40.0f; gDPSetPrimColor(POLY_OPA_DISP++, 0, 0x80, primColor, primColor, primColor, 255); gSPDisplayList(POLY_OPA_DISP++, gOpenMouthMoonDL); - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->state.gfxCtx); } -void EnFall_LodMoon_Draw(Actor* thisx, GlobalContext* globalCtx) { +void EnFall_LodMoon_Draw(Actor* thisx, PlayState* play) { s32 pad; EnFall* this = THIS; s32 primColor; - OPEN_DISPS(globalCtx->state.gfxCtx); + OPEN_DISPS(play->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); + func_8012C28C(play->state.gfxCtx); + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); POLY_OPA_DISP = Gfx_SetFog(POLY_OPA_DISP, 20, 25, 30, 0, 0x3E7, 0x3200); gDPSetRenderMode(POLY_OPA_DISP++, G_RM_PASS, G_RM_AA_ZB_OPA_SURF2); @@ -784,48 +784,48 @@ void EnFall_LodMoon_Draw(Actor* thisx, GlobalContext* globalCtx) { gSPDisplayList(POLY_OPA_DISP++, gLodmoonEyesDL); gSPLoadGeometryMode(POLY_OPA_DISP++, G_ZBUFFER | G_SHADE | G_CULL_BACK | G_LIGHTING | G_SHADING_SMOOTH); gSPDisplayList(POLY_OPA_DISP++, gLodmoonMoonDL); - POLY_OPA_DISP = func_801660B8(globalCtx, POLY_OPA_DISP); + POLY_OPA_DISP = func_801660B8(play, POLY_OPA_DISP); - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->state.gfxCtx); } -void EnFall_LodMoon_DrawWithoutLerp(Actor* thisx, GlobalContext* globalCtx) { - EnFall_LodMoon_Draw(thisx, globalCtx); +void EnFall_LodMoon_DrawWithoutLerp(Actor* thisx, PlayState* play) { + EnFall_LodMoon_Draw(thisx, play); } /** * If the moon is more than 9000 units away from the eye, this will lerp it * to be 9000 units away before drawing it. */ -void EnFall_LodMoon_DrawWithLerp(Actor* thisx, GlobalContext* globalCtx) { - f32 distanceToEye = Actor_DistanceToPoint(thisx, &globalCtx->view.eye); +void EnFall_LodMoon_DrawWithLerp(Actor* thisx, PlayState* play) { + f32 distanceToEye = Actor_DistanceToPoint(thisx, &play->view.eye); f32 scale; Vec3f translation; if (distanceToEye > 9000.0f) { scale = 9000.0f / distanceToEye; - translation.x = (-(globalCtx->view.eye.x - thisx->world.pos.x) * scale) + globalCtx->view.eye.x; - translation.y = (-(globalCtx->view.eye.y - thisx->world.pos.y) * scale) + globalCtx->view.eye.y; - translation.z = (-(globalCtx->view.eye.z - thisx->world.pos.z) * scale) + globalCtx->view.eye.z; - Matrix_InsertTranslation(translation.x, translation.y, translation.z, MTXMODE_NEW); + translation.x = (-(play->view.eye.x - thisx->world.pos.x) * scale) + play->view.eye.x; + translation.y = (-(play->view.eye.y - thisx->world.pos.y) * scale) + play->view.eye.y; + translation.z = (-(play->view.eye.z - thisx->world.pos.z) * scale) + play->view.eye.z; + 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); + EnFall_LodMoon_Draw(thisx, play); } -void EnFall_Fireball_Draw(Actor* thisx, GlobalContext* globalCtx) { +void EnFall_Fireball_Draw(Actor* thisx, PlayState* play) { s32 pad; EnFall* this = THIS; - u32 gameplayFrames = globalCtx->gameplayFrames; + u32 gameplayFrames = play->gameplayFrames; - OPEN_DISPS(globalCtx->state.gfxCtx); + OPEN_DISPS(play->state.gfxCtx); - gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - func_8012C2DC(globalCtx->state.gfxCtx); + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + func_8012C2DC(play->state.gfxCtx); this->fireballYTexScroll1 += (s32)(4.0f + (this->fireballIntensity * 12.0f)); this->fireballYTexScroll2 += (s32)(2.0f + (this->fireballIntensity * 6.0f)); @@ -840,51 +840,48 @@ void EnFall_Fireball_Draw(Actor* thisx, GlobalContext* globalCtx) { // For the glowing sphere of fire gSPSegment(POLY_XLU_DISP++, 0x09, - Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, gameplayFrames, -this->fireballYTexScroll2, 64, 64, 1, + Gfx_TwoTexScroll(play->state.gfxCtx, 0, gameplayFrames, -this->fireballYTexScroll2, 64, 64, 1, -gameplayFrames, -this->fireballYTexScroll1, 64, 64)); // For the "flecks" of fire around the fireball gSPSegment(POLY_XLU_DISP++, 0x0A, - Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, gameplayFrames * 2, -this->fireballYTexScroll1, 64, 64, 1, + Gfx_TwoTexScroll(play->state.gfxCtx, 0, gameplayFrames * 2, -this->fireballYTexScroll1, 64, 64, 1, -gameplayFrames * 2, -this->fireballYTexScroll1, 64, 64)); gDPSetColorDither(POLY_XLU_DISP++, G_CD_NOISE); gDPSetAlphaDither(POLY_XLU_DISP++, G_AD_NOISE); gSPDisplayList(POLY_XLU_DISP++, gMoonFireballDL); - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->state.gfxCtx); } -void EnFall_RisingDebris_Draw(Actor* thisx, GlobalContext* globalCtx) { +void EnFall_RisingDebris_Draw(Actor* thisx, PlayState* play) { static Gfx* sDebrisModelDLists[] = { gMoonDebrisModel1DL, gMoonDebrisModel2DL, gMoonDebrisModel3DL }; EnFall* this = THIS; f32 scale = this->scale * 0.06f; s32 i; - OPEN_DISPS(globalCtx->state.gfxCtx); + OPEN_DISPS(play->state.gfxCtx); - func_8012C28C(globalCtx->state.gfxCtx); + func_8012C28C(play->state.gfxCtx); gSPDisplayList(POLY_OPA_DISP++, gMoonDebrisMaterialDL); 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); - 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]); + Matrix_RotateZYX(debrisEffects[i].rot.x, debrisEffects[i].rot.y, debrisEffects[i].rot.z, MTXMODE_APPLY); + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_OPA_DISP++, sDebrisModelDLists[debrisEffects[i].modelIndex]); } } - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->state.gfxCtx); } -void EnFall_FireRing_Draw(Actor* thisx, GlobalContext* globalCtx) { +void EnFall_FireRing_Draw(Actor* thisx, PlayState* play) { s32 pad; EnFall* this = THIS; @@ -892,11 +889,11 @@ void EnFall_FireRing_Draw(Actor* thisx, GlobalContext* globalCtx) { if (this->fireRingAlpha > 1.0f) { this->fireRingAlpha = 1.0f; } - OPEN_DISPS(globalCtx->state.gfxCtx); + OPEN_DISPS(play->state.gfxCtx); - AnimatedMat_DrawXlu(globalCtx, Lib_SegmentedToVirtual(gMoonFireRingTexAnim)); - gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - func_8012C2DC(globalCtx->state.gfxCtx); + AnimatedMat_DrawXlu(play, Lib_SegmentedToVirtual(gMoonFireRingTexAnim)); + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + func_8012C2DC(play->state.gfxCtx); gDPSetColorDither(POLY_XLU_DISP++, G_CD_NOISE); gDPSetAlphaDither(POLY_XLU_DISP++, G_AD_NOISE); @@ -905,26 +902,26 @@ void EnFall_FireRing_Draw(Actor* thisx, GlobalContext* globalCtx) { gSPDisplayList(POLY_XLU_DISP++, gMoonFireRingDL); - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->state.gfxCtx); } } -void EnFall_MoonsTear_Draw(Actor* thisx, GlobalContext* globalCtx) { +void EnFall_MoonsTear_Draw(Actor* thisx, PlayState* play) { s32 pad; - OPEN_DISPS(globalCtx->state.gfxCtx); + OPEN_DISPS(play->state.gfxCtx); - AnimatedMat_Draw(globalCtx, Lib_SegmentedToVirtual(gFallingMoonsTearTexAnim)); - gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - func_8012C28C(globalCtx->state.gfxCtx); + AnimatedMat_Draw(play, Lib_SegmentedToVirtual(gFallingMoonsTearTexAnim)); + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + func_8012C28C(play->state.gfxCtx); gSPDisplayList(POLY_OPA_DISP++, gFallingMoonsTearDL); Matrix_Scale(3.0f, 3.0f, 6.0f, MTXMODE_APPLY); - gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - func_8012C2DC(globalCtx->state.gfxCtx); + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + func_8012C2DC(play->state.gfxCtx); gSPDisplayList(POLY_XLU_DISP++, gFallingMoonsTearFireDL); - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->state.gfxCtx); } diff --git a/src/overlays/actors/ovl_En_Fall/z_en_fall.h b/src/overlays/actors/ovl_En_Fall/z_en_fall.h index 620c0590a..21746b683 100644 --- a/src/overlays/actors/ovl_En_Fall/z_en_fall.h +++ b/src/overlays/actors/ovl_En_Fall/z_en_fall.h @@ -24,7 +24,7 @@ typedef enum { struct EnFall; -typedef void (*EnFallActionFunc)(struct EnFall*, GlobalContext*); +typedef void (*EnFallActionFunc)(struct EnFall*, PlayState*); typedef struct EnFall { /* 0x000 */ Actor actor; @@ -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 46c365cd3..58ab4e591 100644 --- a/src/overlays/actors/ovl_En_Fall2/z_en_fall2.c +++ b/src/overlays/actors/ovl_En_Fall2/z_en_fall2.c @@ -10,12 +10,17 @@ #define THIS ((EnFall2*)thisx) -void EnFall2_Init(Actor* thisx, GlobalContext* globalCtx); -void EnFall2_Destroy(Actor* thisx, GlobalContext* globalCtx); -void EnFall2_Update(Actor* thisx, GlobalContext* globalCtx); -void EnFall2_Draw(Actor* thisx, GlobalContext* globalCtx); +void EnFall2_Init(Actor* thisx, PlayState* play); +void EnFall2_Destroy(Actor* thisx, PlayState* play); +void EnFall2_Update(Actor* thisx, PlayState* play); +void EnFall2_Draw(Actor* thisx, PlayState* play); + +void func_80C1B724(f32 arg0); +void EnFall2_DoNothing(EnFall2* this, PlayState* play); +void func_80C1B9D4(EnFall2* this, PlayState* play); +void func_80C1B8F0(EnFall2* this); +void func_80C1B9D4(EnFall2* this, PlayState* play); -#if 0 const ActorInit En_Fall2_InitVars = { ACTOR_EN_FALL2, ACTORCAT_ITEMACTION, @@ -28,26 +33,137 @@ const ActorInit En_Fall2_InitVars = { (ActorFunc)EnFall2_Draw, }; -#endif +void EnFall2_Init(Actor* thisx, PlayState* play) { + EnFall2* this = THIS; -extern UNK_TYPE D_06005EF4; -extern UNK_TYPE D_06005F10; -extern UNK_TYPE D_06008840; + Actor_SetScale(&this->actor, 1.0f); + this->actionFunc = EnFall2_DoNothing; + func_80183430(&this->skeletonInfo, object_fall2_Blob_008898, object_fall2_Blob_005EF4, this->unk174, this->unk228, + NULL); + func_801835EC(&this->skeletonInfo, object_fall2_Blob_005EF4); + this->unk2DC = Lib_SegmentedToVirtual(object_fall2_Matanimheader_008840); + Actor_SetScale(&this->actor, 0.02f); + this->actionFunc = func_80C1B9D4; + this->csActionIndex = 0x231; + this->alphaLevel = 0.0f; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Fall2/EnFall2_Init.s") +void EnFall2_Destroy(Actor* thisx, PlayState* play) { + EnFall2* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Fall2/EnFall2_Destroy.s") + func_8018349C(&this->skeletonInfo); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Fall2/func_80C1B724.s") +u8 sAlphaTableIndices[] = { + 0, 2, 0, 0, 4, 0, 4, 4, 2, 0, 0, 0, 0, 0, 0, 2, 4, 4, 4, 2, 0, 4, 2, 2, 0, 4, 4, 4, 4, 0, 2, 2, 4, 0, 2, + 0, 4, 4, 2, 0, 2, 4, 4, 4, 2, 0, 4, 4, 4, 2, 2, 0, 4, 4, 2, 4, 0, 2, 0, 0, 2, 4, 4, 2, 0, 2, 4, 4, 4, 2, + 0, 4, 4, 4, 4, 4, 2, 2, 0, 2, 4, 0, 2, 0, 0, 2, 4, 4, 2, 0, 2, 4, 4, 4, 2, 0, 0, 2, 2, 4, 4, 4, 4, 4, 4, + 2, 0, 2, 0, 0, 2, 4, 4, 2, 0, 2, 4, 4, 4, 2, 0, 2, 0, 5, 2, 5, 5, 5, 5, 0, 2, 5, 0, 2, 0, 2, 5, 5, 2, 0, + 2, 5, 5, 5, 2, 0, 3, 3, 3, 2, 2, 0, 0, 3, 3, 0, 2, 2, 3, 0, 2, 3, 3, 2, 0, 2, 3, 3, 3, 2, 0, 2, 2, 2, 2, + 0, 2, 2, 2, 2, 2, 0, 0, 2, 0, 2, 2, 2, 2, 0, 2, 2, 2, 2, 2, 0, 1, 1, 0, 0, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, + 1, 1, 0, 1, 0, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, +}; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Fall2/func_80C1B8A4.s") +void func_80C1B724(f32 arg0) { + Vtx* vertex = Lib_SegmentedToVirtual(object_fall2_Vtx_005F10); + u8 perVertexAlphaTable[6]; + s32 i; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Fall2/func_80C1B8B4.s") + if (arg0 > 1.0f) { + arg0 = 1.0f; + } + if (arg0 < 0.0f) { + arg0 = 0.0f; + } + perVertexAlphaTable[0] = 0; + perVertexAlphaTable[1] = (s8)(54.0f * arg0); + perVertexAlphaTable[2] = (s8)(104.0f * arg0); + perVertexAlphaTable[3] = (s8)(155.0f * arg0); + perVertexAlphaTable[4] = (s8)(255.0f * arg0); + perVertexAlphaTable[5] = (s8)(205.0f * arg0); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Fall2/func_80C1B8F0.s") + for (i = 0; i < ARRAY_COUNT(sAlphaTableIndices); i++, vertex++) { + vertex->v.cn[3] = perVertexAlphaTable[sAlphaTableIndices[i]]; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Fall2/func_80C1B9D4.s") +void EnFall2_DoNothing(EnFall2* this, PlayState* play) { +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Fall2/EnFall2_Update.s") +void func_80C1B8B4(EnFall2* this) { + this->actor.draw = EnFall2_Draw; + if (this->csActorAction == 1) { + Actor_SetScale(&this->actor, 0.02f); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Fall2/EnFall2_Draw.s") +void func_80C1B8F0(EnFall2* this) { + switch (this->csActorAction) { + case 1: + if (this->alphaLevel < 1.0f) { + this->alphaLevel += 1.0f / 30.0f; + } else { + this->alphaLevel = 1.0f; + } + break; + case 2: + if (this->alphaLevel > 0.0f) { + this->alphaLevel -= 0.1f; + if (this->alphaLevel < 0.0f) { + this->alphaLevel = 0.0f; + } + } + if (this->actor.scale.x > 0.0f) { + this->actor.scale.x -= 20.0f * 0.0001f; + if (this->actor.scale.x < 0.0f) { + this->actor.scale.x = 0.0f; + } + this->actor.scale.z = this->actor.scale.x; + } + } +} + +void func_80C1B9D4(EnFall2* this, PlayState* play) { + func_80183DE0(&this->skeletonInfo); + if (Cutscene_CheckActorAction(play, this->csActionIndex)) { + Cutscene_ActorTranslateAndYaw(&this->actor, play, Cutscene_GetActorActionIndex(play, this->csActionIndex)); + if (this->csActorAction != + play->csCtx.actorActions[Cutscene_GetActorActionIndex(play, this->csActionIndex)]->action) { + this->csActorAction = + play->csCtx.actorActions[Cutscene_GetActorActionIndex(play, this->csActionIndex)]->action; + func_80C1B8B4(this); + } + func_80C1B8F0(this); + if (this->alphaLevel > 0.0f) { + func_800B9010(&this->actor, NA_SE_EV_MOON_LIGHT_PILLAR - SFX_FLAG); + } + } else { + this->actor.draw = NULL; + } + func_80C1B724(this->alphaLevel); +} + +void EnFall2_Update(Actor* thisx, PlayState* play) { + EnFall2* this = THIS; + + this->actionFunc(this, play); +} + +void EnFall2_Draw(Actor* thisx, PlayState* play) { + s32 pad; + EnFall2* this = THIS; + Mtx* mtx; + + if (!(this->alphaLevel <= 0.0f)) { + func_8012C2DC(play->state.gfxCtx); + AnimatedMat_DrawXlu(play, Lib_SegmentedToVirtual(object_fall2_Matanimheader_008840)); + + mtx = GRAPH_ALLOC(play->state.gfxCtx, ALIGN16(this->skeletonInfo.unk_18->unk_1 * sizeof(Mtx))); + + if (mtx != NULL) { + func_8012C2DC(play->state.gfxCtx); + Matrix_RotateYS((s16)(Camera_GetCamDirYaw(GET_ACTIVE_CAM(play)) + 0x8000), MTXMODE_APPLY); + func_8018450C(play, &this->skeletonInfo, mtx, NULL, NULL, &this->actor); + } + } +} diff --git a/src/overlays/actors/ovl_En_Fall2/z_en_fall2.h b/src/overlays/actors/ovl_En_Fall2/z_en_fall2.h index 254b272bf..5ac33b27d 100644 --- a/src/overlays/actors/ovl_En_Fall2/z_en_fall2.h +++ b/src/overlays/actors/ovl_En_Fall2/z_en_fall2.h @@ -2,15 +2,22 @@ #define Z_EN_FALL2_H #include "global.h" +#include "assets/objects/object_fall2/object_fall2.h" struct EnFall2; -typedef void (*EnFall2ActionFunc)(struct EnFall2*, GlobalContext*); +typedef void (*EnFall2ActionFunc)(struct EnFall2*, PlayState*); typedef struct EnFall2 { - /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x1A4]; - /* 0x02E8 */ EnFall2ActionFunc actionFunc; + /* 0x000 */ Actor actor; + /* 0x144 */ SkeletonInfo skeletonInfo; + /* 0x174 */ Vec3s unk174[30]; + /* 0x228 */ Vec3s unk228[30]; + /* 0x2DC */ AnimatedMaterial* unk2DC; + /* 0x2E0 */ f32 alphaLevel; + /* 0x2E4 */ s16 csActorAction; + /* 0x2E6 */ u16 csActionIndex; + /* 0x2E8 */ EnFall2ActionFunc actionFunc; } EnFall2; // size = 0x2EC extern const ActorInit En_Fall2_InitVars; diff --git a/src/overlays/actors/ovl_En_Famos/z_en_famos.c b/src/overlays/actors/ovl_En_Famos/z_en_famos.c index 23da2fb30..cc447a1a1 100644 --- a/src/overlays/actors/ovl_En_Famos/z_en_famos.c +++ b/src/overlays/actors/ovl_En_Famos/z_en_famos.c @@ -1,21 +1,56 @@ /* * 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 "z64rumble.h" +#include "overlays/actors/ovl_En_Bom/z_en_bom.h" +#include "objects/gameplay_keep/gameplay_keep.h" #define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_4) #define THIS ((EnFamos*)thisx) -void EnFamos_Init(Actor* thisx, GlobalContext* globalCtx); -void EnFamos_Destroy(Actor* thisx, GlobalContext* globalCtx); -void EnFamos_Update(Actor* thisx, GlobalContext* globalCtx); -void EnFamos_Draw(Actor* thisx, GlobalContext* globalCtx); +void EnFamos_Init(Actor* thisx, PlayState* play); +void EnFamos_Destroy(Actor* thisx, PlayState* play); +void EnFamos_Update(Actor* thisx, PlayState* play); +void EnFamos_Draw(Actor* thisx, PlayState* play); + +void EnFamos_SetupAttackDebris(EnFamos* this); +void EnFamos_SetupDeathDebris(EnFamos* this); +s32 EnFamos_IsPlayerSeen(EnFamos* this, PlayState* play); +void EnFamos_SetupStillIdle(EnFamos* this); +void EnFamos_StillIdle(EnFamos* this, PlayState* play); +void EnFamos_SetupPathingIdle(EnFamos* this); +void EnFamos_PathingIdle(EnFamos* this, PlayState* play); +void EnFamos_SetupTurnHome(EnFamos* this); +void EnFamos_TurnHome(EnFamos* this, PlayState* play); +void EnFamos_SetupReturnHome(EnFamos* this); +void EnFamos_ReturnHome(EnFamos* this, PlayState* play); +void EnFamos_SetupAlert(EnFamos* this); +void EnFamos_Alert(EnFamos* this, PlayState* play); +void EnFamos_SetupChase(EnFamos* this); +void EnFamos_Chase(EnFamos* this, PlayState* play); +void EnFamos_SetupAttackAim(EnFamos* this); +void EnFamos_AttackAim(EnFamos* this, PlayState* play); +void EnFamos_SetupAttack(EnFamos* this); +void EnFamos_Attack(EnFamos* this, PlayState* play); +void EnFamos_SetupFinishAttack(EnFamos* this); +void EnFamos_FinishAttack(EnFamos* this, PlayState* play); +void EnFamos_SetupAttackRebound(EnFamos* this); +void EnFamos_AttackRebound(EnFamos* this, PlayState* play); +void EnFamos_SetupScanForPlayer(EnFamos* this); +void EnFamos_ScanForPlayer(EnFamos* this, PlayState* play); +void EnFamos_SetupDeathSlam(EnFamos* this); +void EnFamos_DeathSlam(EnFamos* this, PlayState* play); +void EnFamos_SetupDeathExplosion(EnFamos* this); +void EnFamos_DeathExplosion(EnFamos* this, PlayState* play); +void EnFamos_SetupDeathFade(EnFamos* this); +void EnFamos_DeathFade(EnFamos* this, PlayState* play); +void EnFamos_DrawDebris(EnFamos* this, PlayState* play); -#if 0 const ActorInit En_Famos_InitVars = { ACTOR_EN_FAMOS, ACTORCAT_ENEMY, @@ -28,133 +63,807 @@ 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, + }, + ARRAY_COUNT(sJntSphElementsInit), + 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, PlayState* play) { + EnFamos* this = THIS; + Path* path; + s32 i; -extern UNK_TYPE D_060000F8; -extern UNK_TYPE D_06003DC8; + Actor_ProcessInitChain(&this->actor, sInitChain); + if (FAMOS_GET_PATH(thisx) != 0xFF) { + path = &play->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(play, &this->skelAnime, &gFamosSkeleton, &gFamosIdleAnim, this->jointTable, this->morphTable, + FAMOS_LIMB_MAX); + Collider_InitAndSetCylinder(play, &this->collider1, &this->actor, &sCylinderInit1); + Collider_InitAndSetCylinder(play, &this->collider2, &this->actor, &sCylinderInit2); + Collider_InitAndSetJntSph(play, &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 = (FAMOS_GET_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, PlayState* play) { + EnFamos* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Famos/func_808ACF1C.s") + Collider_DestroyCylinder(play, &this->collider1); + Collider_DestroyCylinder(play, &this->collider2); + Collider_DestroyJntSph(play, &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, PlayState* play) { + if ((Player_GetMask(play) != PLAYER_MASK_STONE) && + (Actor_XZDistanceToPoint(&GET_PLAYER(play)->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, PlayState* play) { + EnFamos_UpdateBobbingHeight(this); + if (this->isCalm) { + Math_Vec3f_Copy(&this->calmPos, &this->actor.world.pos); + } + if (EnFamos_IsPlayerSeen(this, play)) { + 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, PlayState* play) { + 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, play)) { + 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, PlayState* play) { + EnFamos_UpdateBobbingHeight(this); + if (EnFamos_IsPlayerSeen(this, play)) { + 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, PlayState* play) { + 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, play)) { + 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, PlayState* play) { + 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, PlayState* play) { + Player* player = GET_PLAYER(play); + 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(&play->colCtx, this->actor.floorPoly, this->actor.floorBgId); + if ((this->actor.xzDistToPlayer < 30.0f) && (this->actor.floorHeight > BGCHECK_Y_MIN) && // close enough + (surfaceType != 0xC && surfaceType != 0xD)) { + EnFamos_SetupAttackAim(this); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Famos/EnFamos_Draw.s") + } else if ((Player_GetMask(play) == PLAYER_MASK_STONE) || + (this->aggroDistance < Actor_XZDistanceToPoint(&GET_PLAYER(play)->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, PlayState* play) { + 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, PlayState* play) { + 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(&play->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) { + Camera_AddQuake(GET_ACTIVE_CAM(play), 2, 15, 10); + Rumble_Request(this->actor.xyzDistToPlayerSq, 180, 20, 100); + EnFamos_SetupAttackDebris(this); + + // spawn crator on floor + Actor_SpawnAsChild(&play->actorCtx, &this->actor, play, 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, PlayState* play) { + 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, PlayState* play) { + 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, PlayState* play) { + EnFamos_UpdateBobbingHeight(this); + this->stateTimer--; + + if (EnFamos_IsPlayerSeen(this, play)) { + 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, PlayState* play) { + 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, PlayState* play) { + 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(&play->actorCtx, play, ACTOR_EN_BOM, this->actor.world.pos.x, + this->actor.world.pos.y + 40.0f, this->actor.world.pos.z, 0, 0, 0, ENBOM_0); + if (explosion != NULL) { + explosion->timer = 0; // instant explosion + } + this->stateTimer--; + + } else if (this->stateTimer == 0) { + Item_DropCollectibleRandom(play, &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, PlayState* play) { + 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, PlayState* play) { + 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, play); + 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(play, &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(play, &play->colChkCtx, &this->collider1.base); + } + + CollisionCheck_SetAC(play, &play->colChkCtx, &this->collider1.base); + CollisionCheck_SetOC(play, &play->colChkCtx, &this->collider1.base); + if (this->emblemCollider.base.acFlags & AC_ON) { + CollisionCheck_SetAC(play, &play->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(play, &play->colChkCtx, &this->collider2.base); + } + } +} + +s32 EnFamos_OverrideLimbDraw(PlayState* play, 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(PlayState* play, 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, PlayState* play) { + s32 i; + + if (this->debrisTimer > 0) { + Gfx* dispOpa; + EnFamosRock* rock; + + OPEN_DISPS(play->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(play->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(play->state.gfxCtx); + } +} + +void EnFamos_Draw(Actor* thisx, PlayState* play) { + EnFamos* this = THIS; + + func_8012C28C(play->state.gfxCtx); + if (this->actionFunc != EnFamos_DeathFade) { + AnimatedMat_Draw(play, sEmblemAnimatedMats[this->animatedMaterialIndex]); + SkelAnime_DrawOpa(play, this->skelAnime.skeleton, this->skelAnime.jointTable, EnFamos_OverrideLimbDraw, + EnFamos_PostLimbDraw, &this->actor); + if (this->actor.colorFilterTimer != 0) { + func_800AE5A0(play); + } + } + EnFamos_DrawDebris(this, play); +} 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..874da9034 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 void (*EnFamosActionFunc)(struct EnFamos*, PlayState*); + +typedef struct EnFamosRock { + /* 0x00 */ Vec3f pos; + /* 0x0C */ Vec3f velocity; + /* 0x18 */ Vec3s rotation; + /* 0x20 */ f32 scale; +} EnFamosRock; // size = 0x24 + +#define FAMOS_GET_PATH(thisx) ((thisx)->params) +#define FAMOS_GET_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 060678506..8ad22ff53 100644 --- a/src/overlays/actors/ovl_En_Fg/z_en_fg.c +++ b/src/overlays/actors/ovl_En_Fg/z_en_fg.c @@ -12,17 +12,17 @@ #define THIS ((EnFg*)thisx) -void EnFg_Init(Actor* thisx, GlobalContext* globalCtx); -void EnFg_Destroy(Actor* thisx, GlobalContext* globalCtx); -void EnFg_Update(Actor* thisx, GlobalContext* globalCtx); -void EnFg_Draw(Actor* thisx, GlobalContext* globalCtx); +void EnFg_Init(Actor* thisx, PlayState* play); +void EnFg_Destroy(Actor* thisx, PlayState* play); +void EnFg_Update(Actor* thisx, PlayState* play); +void EnFg_Draw(Actor* thisx, PlayState* play); -void EnFg_Jump(EnFg* this, GlobalContext* globalCtx); -void EnFg_DoNothing(EnFg* this, GlobalContext* globalCtx); -void EnFg_Knockback(EnFg* this, GlobalContext* globalCtx); +void EnFg_Jump(EnFg* this, PlayState* play); +void EnFg_DoNothing(EnFg* this, PlayState* play); +void EnFg_Knockback(EnFg* this, PlayState* play); void EnFg_AddDust(EnFgEffectDust* dustEffect, Vec3f* worldPos); void EnFg_UpdateDust(EnFgEffectDust* dustEffect); -void EnFg_DrawDust(GlobalContext* globalCtx, EnFgEffectDust* dustEffect); +void EnFg_DrawDust(PlayState* play, EnFgEffectDust* dustEffect); const ActorInit En_Fg_InitVars = { ACTOR_EN_FG, @@ -95,42 +95,42 @@ static DamageTable sDamageTable = { /* Powder Keg */ DMG_ENTRY(0, 0x0), }; -static AnimationInfoS sAnimations[] = { +static AnimationInfoS sAnimationInfo[] = { { &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) { +s32 EnFg_ChangeAnim(SkelAnime* skelAnime, s16 animIndex) { s16 frameCount; s32 ret; ret = false; if (animIndex >= 0 && animIndex < 4) { ret = true; - frameCount = sAnimations[animIndex].frameCount; + frameCount = sAnimationInfo[animIndex].frameCount; if (frameCount < 0) { - frameCount = Animation_GetLastFrame(sAnimations[animIndex].animation); + frameCount = Animation_GetLastFrame(sAnimationInfo[animIndex].animation); } - Animation_Change(skelAnime, sAnimations[animIndex].animation, sAnimations[animIndex].playSpeed, - sAnimations[animIndex].startFrame, frameCount, sAnimations[animIndex].mode, - sAnimations[animIndex].morphFrames); + Animation_Change(skelAnime, sAnimationInfo[animIndex].animation, sAnimationInfo[animIndex].playSpeed, + sAnimationInfo[animIndex].startFrame, frameCount, sAnimationInfo[animIndex].mode, + sAnimationInfo[animIndex].morphFrames); } return ret; } -void func_80A2D348(EnFg* this, GlobalContext* globalCtx) { +void func_80A2D348(EnFg* this, PlayState* play) { if (this->actor.colChkInfo.health != 0) { 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); + CollisionCheck_SetAC(play, &play->colChkCtx, &this->collider.base); + CollisionCheck_SetOC(play, &play->colChkCtx, &this->collider.base); } } -void func_80A2D3D4(EnFg* this, GlobalContext* globalCtx) { +void func_80A2D3D4(EnFg* this, PlayState* play) { SkelAnime_Update(&this->skelAnime); } @@ -170,7 +170,7 @@ s32 EnFg_GetDamageEffect(EnFg* this) { return ret; } -void EnFg_Idle(EnFg* this, GlobalContext* globalCtx) { +void EnFg_Idle(EnFg* this, PlayState* play) { Actor* ac; s16 rotY; s16 rotX; @@ -221,7 +221,7 @@ void EnFg_Idle(EnFg* this, GlobalContext* globalCtx) { default: if (DECR(this->timer) == 0) { Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_FROG_JUMP); - EnFg_UpdateAnimation(&this->skelAnime, 3); + EnFg_ChangeAnim(&this->skelAnime, 3); this->actor.velocity.y = 10.0f; this->timer = Rand_S16Offset(30, 30); this->actionFunc = EnFg_Jump; @@ -230,7 +230,7 @@ void EnFg_Idle(EnFg* this, GlobalContext* globalCtx) { Actor_MoveWithGravity(&this->actor); } -void EnFg_Jump(EnFg* this, GlobalContext* globalCtx) { +void EnFg_Jump(EnFg* this, PlayState* play) { Actor* ac; s32 pad; s16 rotY; @@ -256,7 +256,7 @@ void EnFg_Jump(EnFg* this, GlobalContext* globalCtx) { case FG_DMGEFFECT_EXPLOSION: this->actor.flags &= ~ACTOR_FLAG_1; Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_FROG_CRY_0); - EnFg_UpdateAnimation(&this->skelAnime, 0); + EnFg_ChangeAnim(&this->skelAnime, 0); this->actor.params = FG_BLACK; this->skelAnime.playSpeed = 0.0f; ac = this->collider.base.ac; @@ -276,7 +276,7 @@ void EnFg_Jump(EnFg* this, GlobalContext* globalCtx) { } if ((this->actor.velocity.y <= 0.0f) && (this->actor.bgCheckFlags & 1)) { - EnFg_UpdateAnimation(&this->skelAnime, 0); + EnFg_ChangeAnim(&this->skelAnime, 0); this->actionFunc = EnFg_Idle; this->actor.velocity.y = 0.0f; } else { @@ -285,10 +285,10 @@ void EnFg_Jump(EnFg* this, GlobalContext* globalCtx) { } } -void EnFg_DoNothing(EnFg* this, GlobalContext* globalCtx) { +void EnFg_DoNothing(EnFg* this, PlayState* play) { } -void EnFg_Knockback(EnFg* this, GlobalContext* globalCtx) { +void EnFg_Knockback(EnFg* this, PlayState* play) { if ((this->actor.velocity.y <= 0.0f) && (this->actor.bgCheckFlags & 1)) { this->bounceCounter++; if (this->bounceCounter < 4) { @@ -311,15 +311,14 @@ void EnFg_Knockback(EnFg* this, GlobalContext* globalCtx) { } } -void EnFg_Init(Actor* thisx, GlobalContext* globalCtx) { +void EnFg_Init(Actor* thisx, PlayState* play) { EnFg* this = THIS; ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 10.0f); - SkelAnime_InitFlex(globalCtx, &this->skelAnime, &object_fr_Skel_00B538, NULL, this->jointTable, this->morphTable, - 24); - EnFg_UpdateAnimation(&this->skelAnime, 0); - Collider_InitCylinder(globalCtx, &this->collider); - Collider_SetCylinder(globalCtx, &this->collider, &this->actor, &sCylinderInit); + SkelAnime_InitFlex(play, &this->skelAnime, &object_fr_Skel_00B538, NULL, this->jointTable, this->morphTable, 24); + EnFg_ChangeAnim(&this->skelAnime, 0); + Collider_InitCylinder(play, &this->collider); + Collider_SetCylinder(play, &this->collider, &this->actor, &sCylinderInit); CollisionCheck_SetInfo2(&this->actor.colChkInfo, &sDamageTable, &sColChkInfoInit2); this->actor.flags |= ACTOR_FLAG_4000; Actor_SetScale(&this->actor, 0.01f); @@ -327,13 +326,13 @@ void EnFg_Init(Actor* thisx, GlobalContext* globalCtx) { this->actionFunc = EnFg_Idle; } -void EnFg_Destroy(Actor* thisx, GlobalContext* globalCtx) { +void EnFg_Destroy(Actor* thisx, PlayState* play) { EnFg* this = THIS; - Collider_DestroyCylinder(globalCtx, &this->collider); + Collider_DestroyCylinder(play, &this->collider); } -void EnFg_Update(Actor* thisx, GlobalContext* globalCtx) { +void EnFg_Update(Actor* thisx, PlayState* play) { EnFg* this = THIS; s32 flag; s32 flagSet; @@ -345,17 +344,17 @@ void EnFg_Update(Actor* thisx, GlobalContext* globalCtx) { flagSet = ((flag & 0x8000) == 0x8000); if (1) {} if (!flagSet) { - this->actionFunc(this, globalCtx); - Actor_UpdateBgCheckInfo(globalCtx, &this->actor, BASE_REG(16, 0), BASE_REG(16, 1), 0.0f, 0x5); + this->actionFunc(this, play); + Actor_UpdateBgCheckInfo(play, &this->actor, BASE_REG(16, 0), BASE_REG(16, 1), 0.0f, 0x5); } } - func_80A2D3D4(this, globalCtx); + func_80A2D3D4(this, play); EnFg_UpdateDust(&this->dustEffect[0]); - func_80A2D348(this, globalCtx); + func_80A2D348(this, play); } -s32 EnFg_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, Actor* thisx) { +s32 EnFg_OverrideLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, Actor* thisx) { EnFg* this = THIS; if ((limbIndex == 7) || (limbIndex == 8)) { @@ -370,27 +369,27 @@ s32 EnFg_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, return false; } -void EnFg_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx) { +void EnFg_PostLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx) { EnFg* this = THIS; s16 pad; Vec3f vec1 = { 0.0f, 0.0f, 0.0f }; if ((limbIndex == 7) || (limbIndex == 8)) { - OPEN_DISPS(globalCtx->state.gfxCtx); - Matrix_StatePush(); - Matrix_NormalizeXYZ(&globalCtx->billboardMtxF); - gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + OPEN_DISPS(play->state.gfxCtx); + Matrix_Push(); + Matrix_ReplaceRotation(&play->billboardMtxF); + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_OPA_DISP++, *dList); - Matrix_StatePop(); - CLOSE_DISPS(globalCtx->state.gfxCtx); + Matrix_Pop(); + CLOSE_DISPS(play->state.gfxCtx); } if (limbIndex == 4) { - Matrix_MultiplyVector3fByState(&vec1, &this->actor.focus.pos); + Matrix_MultVec3f(&vec1, &this->actor.focus.pos); } } -void EnFg_Draw(Actor* thisx, GlobalContext* globalCtx) { +void EnFg_Draw(Actor* thisx, PlayState* play) { EnFg* this = THIS; s32 pad; Color_RGBA8 envColor[] = { @@ -398,20 +397,20 @@ void EnFg_Draw(Actor* thisx, GlobalContext* globalCtx) { { 120, 130, 230, 255 }, { 190, 190, 190, 255 }, { 0, 0, 0, 255 }, }; - Matrix_StatePush(); - EnFg_DrawDust(globalCtx, &this->dustEffect[0]); - Matrix_StatePop(); + Matrix_Push(); + EnFg_DrawDust(play, &this->dustEffect[0]); + Matrix_Pop(); - OPEN_DISPS(globalCtx->state.gfxCtx); - func_8012C28C(globalCtx->state.gfxCtx); + OPEN_DISPS(play->state.gfxCtx); + func_8012C28C(play->state.gfxCtx); gDPPipeSync(POLY_OPA_DISP++); gDPSetEnvColor(POLY_OPA_DISP++, envColor[this->actor.params].r, envColor[this->actor.params].g, envColor[this->actor.params].b, envColor[this->actor.params].a); gSPSegment(POLY_OPA_DISP++, 0x08, Lib_SegmentedToVirtual(object_fr_Tex_0059A0)); gSPSegment(POLY_OPA_DISP++, 0x09, Lib_SegmentedToVirtual(object_fr_Tex_0059A0)); - SkelAnime_DrawFlexOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, + SkelAnime_DrawFlexOpa(play, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, EnFg_OverrideLimbDraw, EnFg_PostLimbDraw, &this->actor); - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->state.gfxCtx); } void EnFg_AddDust(EnFgEffectDust* dustEffect, Vec3f* worldPos) { @@ -449,14 +448,14 @@ TexturePtr sDustTex[] = { gDust8Tex, gDust7Tex, gDust6Tex, gDust5Tex, gDust4Tex, gDust3Tex, gDust2Tex, gDust1Tex, }; -void EnFg_DrawDust(GlobalContext* globalCtx, EnFgEffectDust* dustEffect) { +void EnFg_DrawDust(PlayState* play, EnFgEffectDust* dustEffect) { s16 i; s16 alpha; s16 index; s16 firstDone = false; - OPEN_DISPS(globalCtx->state.gfxCtx); - func_8012C2DC(globalCtx->state.gfxCtx); + OPEN_DISPS(play->state.gfxCtx); + func_8012C2DC(play->state.gfxCtx); for (i = 0; i < 10; i++, dustEffect++) { if (dustEffect->type) { @@ -471,15 +470,14 @@ 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(&play->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); + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); index = 0.5f * dustEffect->timer; gSPSegment(POLY_XLU_DISP++, 0x08, Lib_SegmentedToVirtual(sDustTex[index])); gSPDisplayList(POLY_XLU_DISP++, object_fr_DL_00B338); } } - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->state.gfxCtx); } diff --git a/src/overlays/actors/ovl_En_Fg/z_en_fg.h b/src/overlays/actors/ovl_En_Fg/z_en_fg.h index 45f643a1c..6440812ca 100644 --- a/src/overlays/actors/ovl_En_Fg/z_en_fg.h +++ b/src/overlays/actors/ovl_En_Fg/z_en_fg.h @@ -5,36 +5,36 @@ struct EnFg; -typedef void (*EnFgActionFunc)(struct EnFg*, GlobalContext*); +typedef void (*EnFgActionFunc)(struct EnFg*, PlayState*); // Based on the envColor data. Related to params but mostly unused. typedef enum { - /* 0x00 */ FG_YELLOW, - /* 0x01 */ FG_CYAN, - /* 0x02 */ FG_PINK, - /* 0x03 */ FG_BLUE, - /* 0x04 */ FG_WHITE, - /* 0x05 */ FG_BLACK, // All frogs are blackened when hit by an explosion + /* 0x0 */ FG_YELLOW, + /* 0x1 */ FG_CYAN, + /* 0x2 */ FG_PINK, + /* 0x3 */ FG_BLUE, + /* 0x4 */ FG_WHITE, + /* 0x5 */ FG_BLACK, // All frogs are blackened when hit by an explosion } FrogType; typedef enum { - /* 0x00 */ FG_DMGEFFECT_NONE, - /* 0x01 */ FG_DMGEFFECT_EXPLOSION, // Bomb or bombchu, not powderkeg - /* 0x02 */ FG_DMGEFFECT_DEKUSTICK, - /* 0x03 */ FG_DMGEFFECT_HOOKSHOT, - /* 0x04 */ FG_DMGEFFECT_ARROW, - /* 0x05 */ FG_DMGEFFECT_ICEARROW, + /* 0x0 */ FG_DMGEFFECT_NONE, + /* 0x1 */ FG_DMGEFFECT_EXPLOSION, // Bomb or bombchu, not powderkeg + /* 0x2 */ FG_DMGEFFECT_DEKUSTICK, + /* 0x3 */ FG_DMGEFFECT_HOOKSHOT, + /* 0x4 */ FG_DMGEFFECT_ARROW, + /* 0x5 */ FG_DMGEFFECT_ICEARROW, } FrogDamageEffect; typedef struct { - /* 0x0000 */ u8 type; - /* 0x0001 */ u8 timer; - /* 0x0004 */ f32 xyScale; - /* 0x0008 */ UNK_TYPE1 unk_08[0xC]; - /* 0x0014 */ Vec3f pos; - /* 0x0020 */ Vec3f unk_20; // Likely acceleration, set to 0 but unused - /* 0x002C */ Vec3f velocity; - /* 0x0038 */ UNK_TYPE1 unk_38[0x4]; + /* 0x00 */ u8 type; + /* 0x01 */ u8 timer; + /* 0x04 */ f32 xyScale; + /* 0x08 */ UNK_TYPE1 unk_08[0xC]; + /* 0x14 */ Vec3f pos; + /* 0x20 */ Vec3f unk_20; // Likely acceleration, set to 0 but unused + /* 0x2C */ Vec3f velocity; + /* 0x38 */ UNK_TYPE1 unk_38[0x4]; } EnFgEffectDust; // size = 0x3C typedef struct EnFg { diff --git a/src/overlays/actors/ovl_En_Fire_Rock/z_en_fire_rock.c b/src/overlays/actors/ovl_En_Fire_Rock/z_en_fire_rock.c index 77909d2ee..da1c94559 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 @@ -10,10 +10,10 @@ #define THIS ((EnFireRock*)thisx) -void EnFireRock_Init(Actor* thisx, GlobalContext* globalCtx); -void EnFireRock_Destroy(Actor* thisx, GlobalContext* globalCtx); -void EnFireRock_Update(Actor* thisx, GlobalContext* globalCtx); -void EnFireRock_Draw(Actor* thisx, GlobalContext* globalCtx); +void EnFireRock_Init(Actor* thisx, PlayState* play); +void EnFireRock_Destroy(Actor* thisx, PlayState* play); +void EnFireRock_Update(Actor* thisx, PlayState* play); +void EnFireRock_Draw(Actor* thisx, PlayState* play); const ActorInit En_Fire_Rock_InitVars = { ACTOR_EN_FIRE_ROCK, @@ -27,11 +27,11 @@ const ActorInit En_Fire_Rock_InitVars = { (ActorFunc)EnFireRock_Draw, }; -void EnFireRock_Init(Actor* thisx, GlobalContext* globalCtx) { +void EnFireRock_Init(Actor* thisx, PlayState* play) { } -void EnFireRock_Destroy(Actor* thisx, GlobalContext* globalCtx) { +void EnFireRock_Destroy(Actor* thisx, PlayState* play) { } -void EnFireRock_Update(Actor* thisx, GlobalContext* globalCtx) { +void EnFireRock_Update(Actor* thisx, PlayState* play) { } -void EnFireRock_Draw(Actor* thisx, GlobalContext* globalCtx) { +void EnFireRock_Draw(Actor* thisx, PlayState* play) { } 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 711b4ca6e..d8cbe91f5 100644 --- a/src/overlays/actors/ovl_En_Firefly/z_en_firefly.c +++ b/src/overlays/actors/ovl_En_Firefly/z_en_firefly.c @@ -12,25 +12,25 @@ #define THIS ((EnFirefly*)thisx) -void EnFirefly_Init(Actor* thisx, GlobalContext* globalCtx); -void EnFirefly_Destroy(Actor* thisx, GlobalContext* globalCtx); -void EnFirefly_Update(Actor* thisx, GlobalContext* globalCtx); -void EnFirefly_Draw(Actor* thisx, GlobalContext* globalCtx); +void EnFirefly_Init(Actor* thisx, PlayState* play); +void EnFirefly_Destroy(Actor* thisx, PlayState* play); +void EnFirefly_Update(Actor* thisx, PlayState* play); +void EnFirefly_Draw(Actor* thisx, PlayState* play); -void EnFirefly_FlyIdle(EnFirefly* this, GlobalContext* globalCtx); -void EnFirefly_Fall(EnFirefly* this, GlobalContext* globalCtx); +void EnFirefly_FlyIdle(EnFirefly* this, PlayState* play); +void EnFirefly_Fall(EnFirefly* this, PlayState* play); void EnFirefly_SetupDie(EnFirefly* this); -void EnFirefly_Die(EnFirefly* this, GlobalContext* globalCtx); +void EnFirefly_Die(EnFirefly* this, PlayState* play); void EnFirefly_SetupDiveAttack(EnFirefly* this); -void EnFirefly_DiveAttack(EnFirefly* this, GlobalContext* globalCtx); -void EnFirefly_Rebound(EnFirefly* this, GlobalContext* globalCtx); +void EnFirefly_DiveAttack(EnFirefly* this, PlayState* play); +void EnFirefly_Rebound(EnFirefly* this, PlayState* play); void EnFirefly_SetupFlyAway(EnFirefly* this); -void EnFirefly_FlyAway(EnFirefly* this, GlobalContext* globalCtx); -void EnFirefly_Stunned(EnFirefly* this, GlobalContext* globalCtx); +void EnFirefly_FlyAway(EnFirefly* this, PlayState* play); +void EnFirefly_Stunned(EnFirefly* this, PlayState* play); void EnFirefly_SetupPerch(EnFirefly* this); -void EnFirefly_Perch(EnFirefly* this, GlobalContext* globalCtx); +void EnFirefly_Perch(EnFirefly* this, PlayState* play); void EnFirefly_SetupDisturbDiveAttack(EnFirefly* this); -void EnFirefly_DisturbDiveAttack(EnFirefly* this, GlobalContext* globalCtx); +void EnFirefly_DisturbDiveAttack(EnFirefly* this, PlayState* play); typedef enum { /* 0 */ KEESE_FIRE, @@ -78,39 +78,48 @@ static ColliderSphereInit sSphereInit = { static CollisionCheckInfoInit sColChkInfoInit = { 1, 10, 10, 10 }; +typedef enum { + /* 0 */ KEESE_DMGEFF_NONE, + /* 1 */ KEESE_DMGEFF_STUN, + /* 2 */ KEESE_DMGEFF_FIRE, + /* 3 */ KEESE_DMGEFF_ICE, + /* 4 */ KEESE_DMGEFF_LIGHT, + /* 5 */ KEESE_DMGEFF_ELECTRIC +} BatDamageEffect; + static DamageTable sDamageTable = { - /* Deku Nut */ DMG_ENTRY(0, 0x1), - /* Deku Stick */ DMG_ENTRY(1, 0x0), - /* Horse trample */ DMG_ENTRY(0, 0x0), - /* Explosives */ DMG_ENTRY(1, 0x0), - /* Zora boomerang */ DMG_ENTRY(1, 0x0), - /* Normal arrow */ DMG_ENTRY(1, 0x0), - /* UNK_DMG_0x06 */ DMG_ENTRY(0, 0x0), - /* Hookshot */ DMG_ENTRY(1, 0x0), - /* Goron punch */ DMG_ENTRY(1, 0x0), - /* Sword */ DMG_ENTRY(1, 0x0), - /* Goron pound */ DMG_ENTRY(1, 0x0), - /* Fire arrow */ DMG_ENTRY(2, 0x2), - /* Ice arrow */ DMG_ENTRY(2, 0x3), - /* Light arrow */ DMG_ENTRY(2, 0x4), - /* Goron spikes */ DMG_ENTRY(1, 0x0), - /* Deku spin */ DMG_ENTRY(1, 0x0), - /* Deku bubble */ DMG_ENTRY(1, 0x0), - /* Deku launch */ DMG_ENTRY(2, 0x0), - /* UNK_DMG_0x12 */ DMG_ENTRY(0, 0x1), - /* Zora barrier */ DMG_ENTRY(0, 0x5), - /* Normal shield */ DMG_ENTRY(0, 0x0), - /* Light ray */ DMG_ENTRY(0, 0x0), - /* Thrown object */ DMG_ENTRY(1, 0x0), - /* Zora punch */ DMG_ENTRY(1, 0x0), - /* Spin attack */ DMG_ENTRY(1, 0x0), - /* Sword beam */ DMG_ENTRY(0, 0x0), - /* Normal Roll */ DMG_ENTRY(0, 0x0), - /* UNK_DMG_0x1B */ DMG_ENTRY(0, 0x0), - /* UNK_DMG_0x1C */ DMG_ENTRY(0, 0x0), - /* Unblockable */ DMG_ENTRY(0, 0x0), - /* UNK_DMG_0x1E */ DMG_ENTRY(0, 0x0), - /* Powder Keg */ DMG_ENTRY(1, 0x0), + /* Deku Nut */ DMG_ENTRY(0, KEESE_DMGEFF_STUN), + /* Deku Stick */ DMG_ENTRY(1, KEESE_DMGEFF_NONE), + /* Horse trample */ DMG_ENTRY(0, KEESE_DMGEFF_NONE), + /* Explosives */ DMG_ENTRY(1, KEESE_DMGEFF_NONE), + /* Zora boomerang */ DMG_ENTRY(1, KEESE_DMGEFF_NONE), + /* Normal arrow */ DMG_ENTRY(1, KEESE_DMGEFF_NONE), + /* UNK_DMG_0x06 */ DMG_ENTRY(0, KEESE_DMGEFF_NONE), + /* Hookshot */ DMG_ENTRY(1, KEESE_DMGEFF_NONE), + /* Goron punch */ DMG_ENTRY(1, KEESE_DMGEFF_NONE), + /* Sword */ DMG_ENTRY(1, KEESE_DMGEFF_NONE), + /* Goron pound */ DMG_ENTRY(1, KEESE_DMGEFF_NONE), + /* Fire arrow */ DMG_ENTRY(2, KEESE_DMGEFF_FIRE), + /* Ice arrow */ DMG_ENTRY(2, KEESE_DMGEFF_ICE), + /* Light arrow */ DMG_ENTRY(2, KEESE_DMGEFF_LIGHT), + /* Goron spikes */ DMG_ENTRY(1, KEESE_DMGEFF_NONE), + /* Deku spin */ DMG_ENTRY(1, KEESE_DMGEFF_NONE), + /* Deku bubble */ DMG_ENTRY(1, KEESE_DMGEFF_NONE), + /* Deku launch */ DMG_ENTRY(2, KEESE_DMGEFF_NONE), + /* UNK_DMG_0x12 */ DMG_ENTRY(0, KEESE_DMGEFF_STUN), + /* Zora barrier */ DMG_ENTRY(0, KEESE_DMGEFF_ELECTRIC), + /* Normal shield */ DMG_ENTRY(0, KEESE_DMGEFF_NONE), + /* Light ray */ DMG_ENTRY(0, KEESE_DMGEFF_NONE), + /* Thrown object */ DMG_ENTRY(1, KEESE_DMGEFF_NONE), + /* Zora punch */ DMG_ENTRY(1, KEESE_DMGEFF_NONE), + /* Spin attack */ DMG_ENTRY(1, KEESE_DMGEFF_NONE), + /* Sword beam */ DMG_ENTRY(0, KEESE_DMGEFF_NONE), + /* Normal Roll */ DMG_ENTRY(0, KEESE_DMGEFF_NONE), + /* UNK_DMG_0x1B */ DMG_ENTRY(0, KEESE_DMGEFF_NONE), + /* UNK_DMG_0x1C */ DMG_ENTRY(0, KEESE_DMGEFF_NONE), + /* Unblockable */ DMG_ENTRY(0, KEESE_DMGEFF_NONE), + /* UNK_DMG_0x1E */ DMG_ENTRY(0, KEESE_DMGEFF_NONE), + /* Powder Keg */ DMG_ENTRY(1, KEESE_DMGEFF_NONE), }; static InitChainEntry sInitChain[] = { @@ -120,14 +129,14 @@ static InitChainEntry sInitChain[] = { ICHAIN_F32(targetArrowOffset, 4000, ICHAIN_STOP), }; -void EnFirefly_Init(Actor* thisx, GlobalContext* globalCtx) { +void EnFirefly_Init(Actor* thisx, PlayState* play) { EnFirefly* this = THIS; Actor_ProcessInitChain(&this->actor, sInitChain); ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 25.0f); - SkelAnime_Init(globalCtx, &this->skelAnime, &object_firefly_Skel_0018B8, &object_firefly_Anim_00017C, - this->jointTable, this->morphTable, 28); - Collider_InitAndSetSphere(globalCtx, &this->collider, &this->actor, &sSphereInit); + SkelAnime_Init(play, &this->skelAnime, &object_firefly_Skel_0018B8, &object_firefly_Anim_00017C, this->jointTable, + this->morphTable, 28); + Collider_InitAndSetSphere(play, &this->collider, &this->actor, &sSphereInit); CollisionCheck_SetInfo(&this->actor.colChkInfo, &sDamageTable, &sColChkInfoInit); if (this->actor.params & KEESE_INVISIBLE) { @@ -161,17 +170,17 @@ void EnFirefly_Init(Actor* thisx, GlobalContext* globalCtx) { this->collider.dim.worldSphere.radius = sSphereInit.dim.modelSphere.radius; } -void EnFirefly_Destroy(Actor* thisx, GlobalContext* globalCtx) { +void EnFirefly_Destroy(Actor* thisx, PlayState* play) { EnFirefly* this = THIS; - Collider_DestroySphere(globalCtx, &this->collider); + Collider_DestroySphere(play, &this->collider); } -void EnFirefly_SpawnIceEffects(EnFirefly* this, GlobalContext* globalCtx) { +void EnFirefly_SpawnIceEffects(EnFirefly* this, PlayState* play) { 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); + Actor_SpawnIceEffects(play, &this->actor, &this->limbPos[0], 3, 2, 0.2f, 0.2f); } } @@ -191,8 +200,8 @@ void EnFirefly_Ignite(EnFirefly* this) { } } -s32 EnFirefly_ReturnToPerch(EnFirefly* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); +s32 EnFirefly_ReturnToPerch(EnFirefly* this, PlayState* play) { + Player* player = GET_PLAYER(play); f32 distFromHome; if (this->actor.params != KEESE_NORMAL_PERCH) { @@ -220,8 +229,8 @@ s32 EnFirefly_ReturnToPerch(EnFirefly* this, GlobalContext* globalCtx) { return false; } -s32 EnFirefly_SeekTorch(EnFirefly* this, GlobalContext* globalCtx) { - ObjSyokudai* findTorch = (ObjSyokudai*)globalCtx->actorCtx.actorLists[ACTORCAT_PROP].first; +s32 EnFirefly_SeekTorch(EnFirefly* this, PlayState* play) { + ObjSyokudai* findTorch = (ObjSyokudai*)play->actorCtx.actorLists[ACTORCAT_PROP].first; ObjSyokudai* closestTorch = NULL; f32 currentMinDist = 35000.0f; f32 currentDist; @@ -265,12 +274,12 @@ void EnFirefly_SetupFlyIdle(EnFirefly* this) { this->timer = Rand_S16Offset(70, 100); this->actor.speedXZ = (Rand_ZeroOne() * 1.5f) + 1.5f; Math_ScaledStepToS(&this->actor.shape.rot.y, Actor_YawToPoint(&this->actor, &this->actor.home.pos), 0x300); - this->targetPitch = ((this->maxAltitude < this->actor.world.pos.y) ? 0xC00 : -0xC00) + 0x1554; + this->pitchTarget = ((this->maxAltitude < this->actor.world.pos.y) ? 0xC00 : -0xC00) + 0x1554; this->skelAnime.playSpeed = 1.0f; this->actionFunc = EnFirefly_FlyIdle; } -void EnFirefly_FlyIdle(EnFirefly* this, GlobalContext* globalCtx) { +void EnFirefly_FlyIdle(EnFirefly* this, PlayState* play) { s32 isSkelAnimeUpdated; f32 rand; @@ -282,7 +291,7 @@ void EnFirefly_FlyIdle(EnFirefly* this, GlobalContext* globalCtx) { isSkelAnimeUpdated = Animation_OnFrame(&this->skelAnime, 0.0f); this->actor.speedXZ = (Rand_ZeroOne() * 1.5f) + 1.5f; - if (!EnFirefly_ReturnToPerch(this, globalCtx) && !EnFirefly_SeekTorch(this, globalCtx)) { + if (!EnFirefly_ReturnToPerch(this, play) && !EnFirefly_SeekTorch(this, play)) { if (isSkelAnimeUpdated) { rand = Rand_ZeroOne(); @@ -295,41 +304,40 @@ void EnFirefly_FlyIdle(EnFirefly* this, GlobalContext* globalCtx) { // Climb if too close to ground if (this->actor.world.pos.y < this->actor.floorHeight + 20.0f) { - this->targetPitch = 0x954; + this->pitchTarget = 0x954; // Descend if above maxAltitude } else if (this->maxAltitude < this->actor.world.pos.y) { - this->targetPitch = 0x2154; + this->pitchTarget = 0x2154; // Otherwise ascend or descend at random, biased towards ascending } else if (Rand_ZeroOne() > 0.35f) { - this->targetPitch = 0x954; + this->pitchTarget = 0x954; } else { - this->targetPitch = 0x2154; + this->pitchTarget = 0x2154; } } else { if (this->actor.bgCheckFlags & 1) { - this->targetPitch = 0x954; + this->pitchTarget = 0x954; } else if ((this->actor.bgCheckFlags & 0x10) || (this->maxAltitude < this->actor.world.pos.y)) { - this->targetPitch = 0x2154; + this->pitchTarget = 0x2154; } } - Math_ScaledStepToS(&this->actor.shape.rot.x, this->targetPitch, 0x100); + Math_ScaledStepToS(&this->actor.shape.rot.x, this->pitchTarget, 0x100); } if (this->actor.bgCheckFlags & 8) { Math_SmoothStepToS(&this->actor.shape.rot.y, this->actor.wallYaw, 2, 0xC00, 0x300); } - if ((this->timer == 0) && (this->actor.xzDistToPlayer < 200.0f) && - (Player_GetMask(globalCtx) != PLAYER_MASK_STONE)) { + if ((this->timer == 0) && (this->actor.xzDistToPlayer < 200.0f) && (Player_GetMask(play) != PLAYER_MASK_STONE)) { EnFirefly_SetupDiveAttack(this); } } -void EnFirefly_SetupFall(EnFirefly* this, GlobalContext* globalCtx) { +void EnFirefly_SetupFall(EnFirefly* this, PlayState* play) { this->timer = 40; this->actor.velocity.y = 0.0f; - Animation_Change(&this->skelAnime, &object_firefly_Anim_00017C, 0.0f, 6.0f, 6.0f, 2, 0.0f); + Animation_Change(&this->skelAnime, &object_firefly_Anim_00017C, 0.0f, 6.0f, 6.0f, ANIMMODE_ONCE, 0.0f); Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_FFLY_DEAD); this->actor.flags |= ACTOR_FLAG_10; @@ -339,19 +347,19 @@ void EnFirefly_SetupFall(EnFirefly* this, GlobalContext* globalCtx) { Actor_SetColorFilter(&this->actor, 0x4000, 255, 0, 40); } - if (this->actor.colChkInfo.damageEffect == 3) { + if (this->actor.colChkInfo.damageEffect == KEESE_DMGEFF_ICE) { this->drawDmgEffType = ACTOR_DRAW_DMGEFF_FROZEN_NO_SFX; this->drawDmgEffAlpha = 1.0f; this->drawDmgEffScale = 0.55f; - this->drawDmgEffFrozenSteamScale = 0.82500005f; - } else if (this->actor.colChkInfo.damageEffect == 4) { + this->drawDmgEffFrozenSteamScale = 0.55f * 1.5f; + } else if (this->actor.colChkInfo.damageEffect == KEESE_DMGEFF_LIGHT) { this->drawDmgEffType = ACTOR_DRAW_DMGEFF_LIGHT_ORBS; this->drawDmgEffAlpha = 4.0f; this->drawDmgEffScale = 0.55f; - Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_CLEAR_TAG, this->collider.info.bumper.hitPos.x, + Actor_Spawn(&play->actorCtx, play, ACTOR_EN_CLEAR_TAG, this->collider.info.bumper.hitPos.x, this->collider.info.bumper.hitPos.y, this->collider.info.bumper.hitPos.z, 0, 0, 0, CLEAR_TAG_SMALL_LIGHT_RAYS); - } else if (this->actor.colChkInfo.damageEffect == 2) { + } else if (this->actor.colChkInfo.damageEffect == KEESE_DMGEFF_FIRE) { this->drawDmgEffType = ACTOR_DRAW_DMGEFF_FIRE; this->drawDmgEffAlpha = 4.0f; this->drawDmgEffScale = 0.55f; @@ -369,7 +377,7 @@ void EnFirefly_SetupFall(EnFirefly* this, GlobalContext* globalCtx) { } // Fall to the ground after being hit -void EnFirefly_Fall(EnFirefly* this, GlobalContext* globalCtx) { +void EnFirefly_Fall(EnFirefly* this, PlayState* play) { this->actor.colorFilterTimer = 40; Math_StepToF(&this->actor.speedXZ, 0.0f, 0.5f); @@ -380,7 +388,7 @@ void EnFirefly_Fall(EnFirefly* this, GlobalContext* globalCtx) { } if ((this->actor.bgCheckFlags & 1) || (this->actor.floorHeight == BGCHECK_Y_MIN)) { - EnFirefly_SpawnIceEffects(this, globalCtx); + EnFirefly_SpawnIceEffects(this, play); EnFirefly_SetupDie(this); } } @@ -393,7 +401,7 @@ void EnFirefly_SetupDie(EnFirefly* this) { } // Hit the ground or burn up, spawn drops -void EnFirefly_Die(EnFirefly* this, GlobalContext* globalCtx) { +void EnFirefly_Die(EnFirefly* this, PlayState* play) { if (this->timer != 0) { this->timer--; } @@ -402,7 +410,7 @@ void EnFirefly_Die(EnFirefly* this, GlobalContext* globalCtx) { this->actor.scale.y = this->actor.scale.z = this->actor.scale.x; if (this->timer == 0) { - Item_DropCollectibleRandom(globalCtx, &this->actor, &this->actor.world.pos, 0xA0); + Item_DropCollectibleRandom(play, &this->actor, &this->actor.world.pos, 0xA0); Actor_MarkForDeath(&this->actor); } } @@ -410,12 +418,12 @@ void EnFirefly_Die(EnFirefly* this, GlobalContext* globalCtx) { void EnFirefly_SetupDiveAttack(EnFirefly* this) { this->timer = Rand_S16Offset(70, 100); this->skelAnime.playSpeed = 1.0f; - this->targetPitch = ((this->actor.playerHeightRel > 0.0f) ? -0xC00 : 0xC00) + 0x1554; + this->pitchTarget = ((this->actor.playerHeightRel > 0.0f) ? -0xC00 : 0xC00) + 0x1554; this->actionFunc = EnFirefly_DiveAttack; } -void EnFirefly_DiveAttack(EnFirefly* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); +void EnFirefly_DiveAttack(EnFirefly* this, PlayState* play) { + Player* player = GET_PLAYER(play); Vec3f preyPos; SkelAnime_Update(&this->skelAnime); @@ -428,7 +436,7 @@ void EnFirefly_DiveAttack(EnFirefly* this, GlobalContext* globalCtx) { if (this->actor.bgCheckFlags & 8) { Math_SmoothStepToS(&this->actor.shape.rot.y, this->actor.wallYaw, 2, 0xC00, 0x300); - Math_ScaledStepToS(&this->actor.shape.rot.x, this->targetPitch, 0x100); + Math_ScaledStepToS(&this->actor.shape.rot.x, this->pitchTarget, 0x100); } else if (Actor_IsFacingPlayer(&this->actor, 0x2800)) { if (Animation_OnFrame(&this->skelAnime, 4.0f)) { this->skelAnime.playSpeed = 0.0f; @@ -448,19 +456,19 @@ void EnFirefly_DiveAttack(EnFirefly* this, GlobalContext* globalCtx) { } if (this->actor.bgCheckFlags & 1) { - this->targetPitch = 0x954; + this->pitchTarget = 0x954; } if ((this->actor.bgCheckFlags & 0x10) || (this->maxAltitude < this->actor.world.pos.y)) { - this->targetPitch = 0x2154; + this->pitchTarget = 0x2154; } else { - this->targetPitch = 0x954; + this->pitchTarget = 0x954; } - Math_ScaledStepToS(&this->actor.shape.rot.x, this->targetPitch, 0x100); + Math_ScaledStepToS(&this->actor.shape.rot.x, this->pitchTarget, 0x100); } - if ((this->timer == 0) || (Player_GetMask(globalCtx) == PLAYER_MASK_STONE) || (player->stateFlags2 & 0x80) || + if ((this->timer == 0) || (Player_GetMask(play) == PLAYER_MASK_STONE) || (player->stateFlags2 & PLAYER_STATE2_80) || (player->actor.freezeTimer > 0)) { EnFirefly_SetupFlyAway(this); } @@ -475,7 +483,7 @@ void EnFirefly_SetupRebound(EnFirefly* this) { } // Knockback after hitting player -void EnFirefly_Rebound(EnFirefly* this, GlobalContext* globalCtx) { +void EnFirefly_Rebound(EnFirefly* this, PlayState* play) { SkelAnime_Update(&this->skelAnime); Math_ScaledStepToS(&this->actor.shape.rot.x, 0, 0x100); Math_StepToF(&this->actor.velocity.y, 0.0f, 0.4f); @@ -492,12 +500,12 @@ void EnFirefly_Rebound(EnFirefly* this, GlobalContext* globalCtx) { void EnFirefly_SetupFlyAway(EnFirefly* this) { this->timer = 150; - this->targetPitch = 0x954; + this->pitchTarget = 0x954; this->actionFunc = EnFirefly_FlyAway; this->skelAnime.playSpeed = 1.0f; } -void EnFirefly_FlyAway(EnFirefly* this, GlobalContext* globalCtx) { +void EnFirefly_FlyAway(EnFirefly* this, PlayState* play) { SkelAnime_Update(&this->skelAnime); if (this->timer != 0) { @@ -514,11 +522,11 @@ void EnFirefly_FlyAway(EnFirefly* this, GlobalContext* globalCtx) { Math_StepToF(&this->actor.speedXZ, 3.0f, 0.3f); if (this->actor.bgCheckFlags & 1) { - this->targetPitch = 0x954; + this->pitchTarget = 0x954; } else if ((this->actor.bgCheckFlags & 0x10) || (this->maxAltitude < this->actor.world.pos.y)) { - this->targetPitch = 0x2154; + this->pitchTarget = 0x2154; } else { - this->targetPitch = 0x954; + this->pitchTarget = 0x954; } if (this->actor.bgCheckFlags & 8) { @@ -527,7 +535,7 @@ void EnFirefly_FlyAway(EnFirefly* this, GlobalContext* globalCtx) { Math_ScaledStepToS(&this->actor.shape.rot.y, Actor_YawToPoint(&this->actor, &this->actor.home.pos), 0x300); } - Math_ScaledStepToS(&this->actor.shape.rot.x, this->targetPitch, 0x100); + Math_ScaledStepToS(&this->actor.shape.rot.x, this->pitchTarget, 0x100); } void EnFirefly_SetupStunned(EnFirefly* this) { @@ -547,7 +555,7 @@ void EnFirefly_SetupStunned(EnFirefly* this) { this->actionFunc = EnFirefly_Stunned; } -void EnFirefly_Stunned(EnFirefly* this, GlobalContext* globalCtx) { +void EnFirefly_Stunned(EnFirefly* this, PlayState* play) { Math_ScaledStepToS(&this->actor.shape.rot.x, 0x1554, 0x100); if ((this->actor.bgCheckFlags & 1) || (this->actor.floorHeight == BGCHECK_Y_MIN)) { if (this->timer != 0) { @@ -579,7 +587,7 @@ void EnFirefly_SetupPerch(EnFirefly* this) { } // When perching, sit on collision and flap at random intervals -void EnFirefly_Perch(EnFirefly* this, GlobalContext* globalCtx) { +void EnFirefly_Perch(EnFirefly* this, PlayState* play) { Math_ScaledStepToS(&this->actor.shape.rot.x, 0, 0x100); if (this->timer != 0) { SkelAnime_Update(&this->skelAnime); @@ -604,8 +612,8 @@ void EnFirefly_SetupDisturbDiveAttack(EnFirefly* this) { this->actionFunc = EnFirefly_DisturbDiveAttack; } -void EnFirefly_DisturbDiveAttack(EnFirefly* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); +void EnFirefly_DisturbDiveAttack(EnFirefly* this, PlayState* play) { + Player* player = GET_PLAYER(play); Vec3f preyPos; SkelAnime_Update(&this->skelAnime); @@ -628,38 +636,38 @@ void EnFirefly_DisturbDiveAttack(EnFirefly* this, GlobalContext* globalCtx) { } } -void EnFirefly_UpdateDamage(EnFirefly* this, GlobalContext* globalCtx) { +void EnFirefly_UpdateDamage(EnFirefly* this, PlayState* play) { 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 == 1) { + if (this->actor.colChkInfo.damageEffect == KEESE_DMGEFF_STUN) { this->timer = 40; EnFirefly_SetupStunned(this); - } else if (this->actor.colChkInfo.damageEffect == 5) { + } else if (this->actor.colChkInfo.damageEffect == KEESE_DMGEFF_ELECTRIC) { this->timer = 40; this->drawDmgEffType = ACTOR_DRAW_DMGEFF_ELECTRIC_SPARKS_MEDIUM; this->drawDmgEffAlpha = 2.0f; this->drawDmgEffScale = 0.55f; EnFirefly_SetupStunned(this); } else { - Enemy_StartFinishingBlow(globalCtx, &this->actor); + Enemy_StartFinishingBlow(play, &this->actor); this->actor.colChkInfo.health = 0; this->actor.flags &= ~ACTOR_FLAG_1; // Negate effects of fire on Fire Keese and Ice on Ice Keese - if (((this->currentType == KEESE_FIRE) && (this->actor.colChkInfo.damageEffect == 2)) || - ((this->currentType == KEESE_ICE) && (this->actor.colChkInfo.damageEffect == 3))) { - this->actor.colChkInfo.damageEffect = 0; + if (((this->currentType == KEESE_FIRE) && (this->actor.colChkInfo.damageEffect == KEESE_DMGEFF_FIRE)) || + ((this->currentType == KEESE_ICE) && (this->actor.colChkInfo.damageEffect == KEESE_DMGEFF_ICE))) { + this->actor.colChkInfo.damageEffect = KEESE_DMGEFF_NONE; } - EnFirefly_SetupFall(this, globalCtx); + EnFirefly_SetupFall(this, play); } } } -void EnFirefly_Update(Actor* thisx, GlobalContext* globalCtx2) { - GlobalContext* globalCtx = globalCtx2; +void EnFirefly_Update(Actor* thisx, PlayState* play2) { + PlayState* play = play2; EnFirefly* this = THIS; if (this->collider.base.atFlags & AT_HIT) { @@ -675,8 +683,8 @@ void EnFirefly_Update(Actor* thisx, GlobalContext* globalCtx2) { } } - EnFirefly_UpdateDamage(this, globalCtx); - this->actionFunc(this, globalCtx); + EnFirefly_UpdateDamage(this, play); + this->actionFunc(this, play); if (!(this->actor.flags & ACTOR_FLAG_8000)) { if ((this->actor.colChkInfo.health == 0) || (this->actionFunc == EnFirefly_Stunned)) { @@ -690,17 +698,17 @@ void EnFirefly_Update(Actor* thisx, GlobalContext* globalCtx2) { } } - Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 10.0f, 10.0f, 15.0f, 7); + Actor_UpdateBgCheckInfo(play, &this->actor, 10.0f, 10.0f, 15.0f, 7); this->collider.dim.worldSphere.center.x = this->actor.world.pos.x; this->collider.dim.worldSphere.center.y = (s32)this->actor.world.pos.y + 10; this->collider.dim.worldSphere.center.z = this->actor.world.pos.z; if ((this->actionFunc == EnFirefly_DiveAttack) || (this->actionFunc == EnFirefly_DisturbDiveAttack)) { - CollisionCheck_SetAT(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + CollisionCheck_SetAT(play, &play->colChkCtx, &this->collider.base); } if (this->actor.colChkInfo.health != 0) { - CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + CollisionCheck_SetAC(play, &play->colChkCtx, &this->collider.base); this->actor.world.rot.y = this->actor.shape.rot.y; if (Animation_OnFrame(&this->skelAnime, 5.0f)) { @@ -708,14 +716,14 @@ void EnFirefly_Update(Actor* thisx, GlobalContext* globalCtx2) { } } - CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + CollisionCheck_SetOC(play, &play->colChkCtx, &this->collider.base); if (this->drawDmgEffAlpha > 0.0f) { if (this->drawDmgEffType != ACTOR_DRAW_DMGEFF_FROZEN_NO_SFX) { Math_StepToF(&this->drawDmgEffAlpha, 0.0f, 0.05f); this->drawDmgEffScale = (this->drawDmgEffAlpha + 1.0f) * 0.275f; this->drawDmgEffScale = CLAMP_MAX(this->drawDmgEffScale, 0.55f); - } else if (!Math_StepToF(&this->drawDmgEffFrozenSteamScale, 0.55f, 0.01375f)) { + } else if (!Math_StepToF(&this->drawDmgEffFrozenSteamScale, 0.55f, 0.55f / 40.0f)) { func_800B9010(&this->actor, NA_SE_EV_ICE_FREEZE - SFX_FLAG); } } @@ -727,11 +735,11 @@ void EnFirefly_Update(Actor* thisx, GlobalContext* globalCtx2) { 10.0f * Math_SinS(this->actor.shape.rot.x) * Math_CosS(this->actor.shape.rot.y) + this->actor.world.pos.z; } -s32 EnFirefly_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, - Actor* thisx, Gfx** gfx) { +s32 EnFirefly_OverrideLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, Actor* thisx, + Gfx** gfx) { EnFirefly* this = THIS; - if (this->isInvisible && (globalCtx->actorCtx.unk4 != 0x64)) { + if (this->isInvisible && (play->actorCtx.unk4 != 0x64)) { *dList = NULL; } else if (limbIndex == 1) { pos->y += 2300.0f; @@ -739,7 +747,7 @@ s32 EnFirefly_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dL return false; } -void EnFirefly_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx, Gfx** gfx) { +void EnFirefly_PostLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx, Gfx** gfx) { static Color_RGBA8 fireAuraPrimColor = { 255, 255, 100, 255 }; static Color_RGBA8 fireAuraEnvColor = { 255, 50, 0, 0 }; static Color_RGBA8 iceAuraPrimColor = { 100, 200, 255, 255 }; @@ -756,11 +764,11 @@ void EnFirefly_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList if ((this->currentType != KEESE_FIRE) && (limbIndex == 27)) { gSPDisplayList((*gfx)++, object_firefly_DL_001678); - } else if ((this->unk_2F4 != globalCtx->gameplayFrames) && + } else if ((this->lastDrawnFrame != play->gameplayFrames) && ((this->auraType == KEESE_AURA_FIRE) || (this->auraType == KEESE_AURA_ICE)) && ((limbIndex == 15) || (limbIndex == 21))) { if (this->actionFunc != EnFirefly_Die) { - Matrix_GetStateTranslation(&auraPos); + Matrix_MultZero(&auraPos); auraPos.x += Rand_ZeroFloat(5.0f); auraPos.y += Rand_ZeroFloat(5.0f); auraPos.z += Rand_ZeroFloat(5.0f); @@ -788,25 +796,25 @@ void EnFirefly_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList auraEnvColor = &iceAuraEnvColor; } - func_800B0F80(globalCtx, &auraPos, &auraVelocity, &auraAccel, auraPrimColor, auraEnvColor, 250, auraScaleStep, + func_800B0F80(play, &auraPos, &auraVelocity, &auraAccel, auraPrimColor, auraEnvColor, 250, auraScaleStep, auraLife); } if (limbIndex == 15) { - Matrix_GetStateTranslation(&this->limbPos[0]); + Matrix_MultZero(&this->limbPos[0]); } else if (limbIndex == 21) { - Matrix_GetStateTranslation(&this->limbPos[1]); + Matrix_MultZero(&this->limbPos[1]); } else if (limbIndex == 10) { - Matrix_GetStateTranslation(&this->limbPos[2]); + Matrix_MultZero(&this->limbPos[2]); } } -void EnFirefly_Draw(Actor* thisx, GlobalContext* globalCtx) { +void EnFirefly_Draw(Actor* thisx, PlayState* play) { s32 pad; EnFirefly* this = THIS; Gfx* gfx; - OPEN_DISPS(globalCtx->state.gfxCtx); + OPEN_DISPS(play->state.gfxCtx); if (this->isInvisible) { gfx = POLY_XLU_DISP; @@ -822,7 +830,7 @@ void EnFirefly_Draw(Actor* thisx, GlobalContext* globalCtx) { gDPSetEnvColor(&gfx[1], 0, 0, 0, 255); } - gfx = SkelAnime_Draw(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, EnFirefly_OverrideLimbDraw, + gfx = SkelAnime_Draw(play, this->skelAnime.skeleton, this->skelAnime.jointTable, EnFirefly_OverrideLimbDraw, EnFirefly_PostLimbDraw, &this->actor, &gfx[2]); if (this->isInvisible) { POLY_XLU_DISP = gfx; @@ -830,10 +838,10 @@ void EnFirefly_Draw(Actor* thisx, GlobalContext* globalCtx) { POLY_OPA_DISP = gfx; } - Actor_DrawDamageEffects(globalCtx, NULL, this->limbPos, ARRAY_COUNT(this->limbPos), + Actor_DrawDamageEffects(play, NULL, this->limbPos, ARRAY_COUNT(this->limbPos), this->drawDmgEffScale * this->actor.scale.y * 200.0f, this->drawDmgEffFrozenSteamScale, this->drawDmgEffAlpha, this->drawDmgEffType); - this->unk_2F4 = globalCtx->gameplayFrames; + this->lastDrawnFrame = play->gameplayFrames; - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->state.gfxCtx); } diff --git a/src/overlays/actors/ovl_En_Firefly/z_en_firefly.h b/src/overlays/actors/ovl_En_Firefly/z_en_firefly.h index c8e24aa4f..ffb295e6a 100644 --- a/src/overlays/actors/ovl_En_Firefly/z_en_firefly.h +++ b/src/overlays/actors/ovl_En_Firefly/z_en_firefly.h @@ -5,7 +5,7 @@ struct EnFirefly; -typedef void (*EnFireflyActionFunc)(struct EnFirefly*, GlobalContext*); +typedef void (*EnFireflyActionFunc)(struct EnFirefly*, PlayState*); typedef enum { /* 0 */ KEESE_FIRE_FLY, @@ -26,14 +26,14 @@ typedef struct EnFirefly { /* 0x18E */ u8 isInvisible; /* 0x18F */ u8 drawDmgEffType; /* 0x190 */ s16 timer; - /* 0x192 */ s16 targetPitch; + /* 0x192 */ s16 pitchTarget; /* 0x194 */ Vec3s jointTable[28]; /* 0x23C */ Vec3s morphTable[28]; /* 0x2E4 */ f32 maxAltitude; /* 0x2E8 */ f32 drawDmgEffAlpha; /* 0x2E8 */ f32 drawDmgEffScale; /* 0x2E8 */ f32 drawDmgEffFrozenSteamScale; - /* 0x2F4 */ u32 unk_2F4; + /* 0x2F4 */ u32 lastDrawnFrame; /* 0x2F8 */ Vec3f limbPos[3]; /* 0x31C */ ColliderSphere collider; } EnFirefly; // size = 0x374 diff --git a/src/overlays/actors/ovl_En_Firefly2/z_en_firefly2.c b/src/overlays/actors/ovl_En_Firefly2/z_en_firefly2.c index b076e2885..b3b446ef3 100644 --- a/src/overlays/actors/ovl_En_Firefly2/z_en_firefly2.c +++ b/src/overlays/actors/ovl_En_Firefly2/z_en_firefly2.c @@ -10,10 +10,10 @@ #define THIS ((EnFirefly2*)thisx) -void EnFirefly2_Init(Actor* thisx, GlobalContext* globalCtx); -void EnFirefly2_Destroy(Actor* thisx, GlobalContext* globalCtx); -void EnFirefly2_Update(Actor* thisx, GlobalContext* globalCtx); -void EnFirefly2_Draw(Actor* thisx, GlobalContext* globalCtx); +void EnFirefly2_Init(Actor* thisx, PlayState* play); +void EnFirefly2_Destroy(Actor* thisx, PlayState* play); +void EnFirefly2_Update(Actor* thisx, PlayState* play); +void EnFirefly2_Draw(Actor* thisx, PlayState* play); const ActorInit En_Firefly2_InitVars = { ACTOR_EN_FIREFLY2, @@ -27,11 +27,11 @@ const ActorInit En_Firefly2_InitVars = { (ActorFunc)EnFirefly2_Draw, }; -void EnFirefly2_Init(Actor* thisx, GlobalContext* globalCtx) { +void EnFirefly2_Init(Actor* thisx, PlayState* play) { } -void EnFirefly2_Destroy(Actor* thisx, GlobalContext* globalCtx) { +void EnFirefly2_Destroy(Actor* thisx, PlayState* play) { } -void EnFirefly2_Update(Actor* thisx, GlobalContext* globalCtx) { +void EnFirefly2_Update(Actor* thisx, PlayState* play) { } -void EnFirefly2_Draw(Actor* thisx, GlobalContext* globalCtx) { +void EnFirefly2_Draw(Actor* thisx, PlayState* play) { } 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 6c9f813fd..268768660 100644 --- a/src/overlays/actors/ovl_En_Fish/z_en_fish.c +++ b/src/overlays/actors/ovl_En_Fish/z_en_fish.c @@ -11,29 +11,29 @@ #define THIS ((EnFish*)thisx) -void EnFish_Init(Actor* thisx, GlobalContext* globalCtx); -void EnFish_Destroy(Actor* thisx, GlobalContext* globalCtx); -void EnFish_Update(Actor* thisx, GlobalContext* globalCtx); -void EnFish_Draw(Actor* thisx, GlobalContext* globalCtx); +void EnFish_Init(Actor* thisx, PlayState* play); +void EnFish_Destroy(Actor* thisx, PlayState* play); +void EnFish_Update(Actor* thisx, PlayState* play); +void EnFish_Draw(Actor* thisx, PlayState* play); -void func_8091DF68(Actor* thisx, GlobalContext* globalCtx); +void func_8091DF68(Actor* thisx, PlayState* play); void func_8091E070(EnFish* this); -void func_8091E128(Actor* thisx, GlobalContext* globalCtx); +void func_8091E128(Actor* thisx, PlayState* play); void func_8091E2E0(EnFish* this); -void func_8091E34C(Actor* thisx, GlobalContext* globalCtx2); +void func_8091E34C(Actor* thisx, PlayState* play2); void func_8091E5EC(EnFish* this); -void func_8091E658(Actor* thisx, GlobalContext* globalCtx); +void func_8091E658(Actor* thisx, PlayState* play); void func_8091E810(EnFish* this); -void func_8091E880(Actor* thisx, GlobalContext* globalCtx); +void func_8091E880(Actor* thisx, PlayState* play); void func_8091E9A4(EnFish* this); -void func_8091EAF0(Actor* thisx, GlobalContext* globalCtx); +void func_8091EAF0(Actor* thisx, PlayState* play); void func_8091ECF4(EnFish* this); -void func_8091ED70(Actor* thisx, GlobalContext* globalCtx); +void func_8091ED70(Actor* thisx, PlayState* play); void func_8091EF30(EnFish* this); -void func_8091EFE8(Actor* thisx, GlobalContext* globalCtx); +void func_8091EFE8(Actor* thisx, PlayState* play); void func_8091F344(EnFish* this); -void func_8091F3BC(Actor* thisx, GlobalContext* globalCtx); -void func_8091F994(Actor* thisx, GlobalContext* globalCtx); +void func_8091F3BC(Actor* thisx, PlayState* play); +void func_8091F994(Actor* thisx, PlayState* play); static ColliderJntSphElementInit sJntSphElementsInit[1] = { { @@ -58,7 +58,7 @@ static ColliderJntSphInit sJntSphInit = { OC2_TYPE_1, COLSHAPE_JNTSPH, }, - 1, + ARRAY_COUNT(sJntSphElementsInit), sJntSphElementsInit, }; @@ -92,12 +92,12 @@ f32 func_8091D630(Vec3f* arg0, Vec3f* arg1) { void func_8091D660(EnFish* this) { Animation_Change(&this->skelAnime, &gameplay_keep_Anim_02F0EC, 1.0f, 0.0f, - Animation_GetLastFrame(&gameplay_keep_Anim_02F0EC), 1, 2.0f); + Animation_GetLastFrame(&gameplay_keep_Anim_02F0EC), ANIMMODE_LOOP_INTERP, 2.0f); } void func_8091D6C4(EnFish* this) { Animation_Change(&this->skelAnime, &gameplay_keep_Anim_02E65C, 1.0f, 0.0f, - Animation_GetLastFrame(&gameplay_keep_Anim_02E65C), 1, 2.0f); + Animation_GetLastFrame(&gameplay_keep_Anim_02E65C), ANIMMODE_LOOP_INTERP, 2.0f); } void func_8091D728(EnFish* this) { @@ -127,12 +127,12 @@ void func_8091D7C4(EnFish* this) { this->actor.shape.rot = this->actor.world.rot; } -void func_8091D840(Actor* thisx, GlobalContext* globalCtx, s32 arg2, f32 arg3) { +void func_8091D840(Actor* thisx, PlayState* play, s32 arg2, f32 arg3) { EnFish* this = THIS; s32 i; for (i = 0; i < arg2; i++) { - EffectSsBubble_Spawn(globalCtx, &this->actor.world.pos, 0.0f, arg3, arg3, (Rand_ZeroOne() * 0.09f) + 0.06f); + EffectSsBubble_Spawn(play, &this->actor.world.pos, 0.0f, arg3, arg3, (Rand_ZeroOne() * 0.09f) + 0.06f); } } @@ -143,11 +143,11 @@ void func_8091D904(EnFish* this) { this->actor.draw = NULL; } -Actor* func_8091D944(EnFish* this, GlobalContext* globalCtx) { +Actor* func_8091D944(EnFish* this, PlayState* play) { f32 distSq; Actor* retActor = NULL; f32 minDistSq = FLT_MAX; - Actor* foundActor = globalCtx->actorCtx.actorLists[ACTORCAT_ITEMACTION].first; + Actor* foundActor = play->actorCtx.actorLists[ACTORCAT_ITEMACTION].first; while (foundActor != NULL) { if ((foundActor->id == ACTOR_EN_FISH) && (foundActor->params == ENFISH_2) && @@ -166,16 +166,16 @@ Actor* func_8091D944(EnFish* this, GlobalContext* globalCtx) { return retActor; } -s32 func_8091DA14(EnFish* this, GlobalContext* globalCtx) { - return globalCtx->sceneNum == SCENE_LABO && func_8091D944(this, globalCtx); +s32 func_8091DA14(EnFish* this, PlayState* play) { + return play->sceneNum == SCENE_LABO && func_8091D944(this, play); } -void EnFish_Init(Actor* thisx, GlobalContext* globalCtx) { +void EnFish_Init(Actor* thisx, PlayState* play) { s32 pad; EnFish* this = THIS; s16 sp36 = this->actor.params; - Collider_InitJntSph(globalCtx, &this->collider); + Collider_InitJntSph(play, &this->collider); if (sp36 == ENFISH_2) { this->actor.draw = NULL; this->actor.update = func_8091F994; @@ -205,13 +205,13 @@ void EnFish_Init(Actor* thisx, GlobalContext* globalCtx) { this->unk_278 = 0; } - SkelAnime_InitFlex(globalCtx, &this->skelAnime, &gameplay_keep_Skel_02F028, &gameplay_keep_Anim_02F0EC, - this->jointTable, this->morphTable, 7); - Collider_SetJntSph(globalCtx, &this->collider, &this->actor, &sJntSphInit, this->colliderElements); + SkelAnime_InitFlex(play, &this->skelAnime, &gameplay_keep_Skel_02F028, &gameplay_keep_Anim_02F0EC, this->jointTable, + this->morphTable, 7); + Collider_SetJntSph(play, &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 |= ACTOR_FLAG_10; @@ -224,11 +224,11 @@ void EnFish_Init(Actor* thisx, GlobalContext* globalCtx) { } } -void EnFish_Destroy(Actor* thisx, GlobalContext* globalCtx2) { - GlobalContext* globalCtx = globalCtx2; +void EnFish_Destroy(Actor* thisx, PlayState* play2) { + PlayState* play = play2; EnFish* this = THIS; - Collider_DestroyJntSph(globalCtx, &this->collider); + Collider_DestroyJntSph(play, &this->collider); } void func_8091DD48(EnFish* this) { @@ -241,9 +241,9 @@ void func_8091DD48(EnFish* this) { } } -s32 func_8091DDF4(EnFish* this, GlobalContext* globalCtx) { +s32 func_8091DDF4(EnFish* this, PlayState* play) { s32 pad; - Player* player = GET_PLAYER(globalCtx); + Player* player = GET_PLAYER(play); Vec3f sp1C; if (this->actor.xzDistToPlayer < 50.0f) { @@ -274,7 +274,7 @@ void func_8091DEE4(EnFish* this) { this->unkFunc = func_8091DF68; } -void func_8091DF68(Actor* thisx, GlobalContext* globalCtx) { +void func_8091DF68(Actor* thisx, PlayState* play) { EnFish* this = THIS; func_8091DD48(this); @@ -322,7 +322,7 @@ void func_8091E070(EnFish* this) { this->unkFunc = func_8091E128; } -void func_8091E128(Actor* thisx, GlobalContext* globalCtx) { +void func_8091E128(Actor* thisx, PlayState* play) { s32 pad; EnFish* this = THIS; @@ -370,8 +370,8 @@ void func_8091E2E0(EnFish* this) { this->unkFunc = func_8091E34C; } -void func_8091E34C(Actor* thisx, GlobalContext* globalCtx2) { - GlobalContext* globalCtx = globalCtx2; +void func_8091E34C(Actor* thisx, PlayState* play2) { + PlayState* play = play2; EnFish* this = THIS; s32 sp3C = thisx->xzDistToPlayer < 60.0f; s32 sp38 = this->unk_276 > 0; @@ -390,17 +390,17 @@ void func_8091E34C(Actor* thisx, GlobalContext* globalCtx2) { this->unk_24C = 1.0f; } else if (sp3C) { this->unk_26A = BINANG_ROT180(thisx->yawTowardsPlayer); - if ((globalCtx->state.frames & 0x10) == 0) { - if ((globalCtx->state.frames & 0x20) == 0) { + if ((play->state.frames & 0x10) == 0) { + if ((play->state.frames & 0x20) == 0) { this->unk_26A += 0x2000; } - } else if ((globalCtx->state.frames & 0x20) == 0) { + } else if ((play->state.frames & 0x20) == 0) { this->unk_26A -= 0x2000; } this->unk_270 = this->unk_266; this->unk_24C = 1.2f; } else if (sp38 != 0) { - if ((globalCtx->state.frames & 0x10) == 0) { + if ((play->state.frames & 0x10) == 0) { s16 temp = BINANG_SUB(thisx->shape.rot.y, this->unk_274); if (temp < 0) { @@ -444,9 +444,9 @@ void func_8091E5EC(EnFish* this) { this->unkFunc = func_8091E658; } -void func_8091E658(Actor* thisx, GlobalContext* globalCtx) { +void func_8091E658(Actor* thisx, PlayState* play) { EnFish* this = THIS; - Player* player = GET_PLAYER(globalCtx); + Player* player = GET_PLAYER(play); s32 pad; Vec3f sp38; s32 pad2; @@ -460,7 +460,7 @@ void func_8091E658(Actor* thisx, GlobalContext* globalCtx) { this->unk_26A = Math_Vec3f_Yaw(&thisx->world.pos, &thisx->home.pos); this->unk_24C = 1.0f; } else { - if ((globalCtx->state.frames & 0x40) == 0) { + if ((play->state.frames & 0x40) == 0) { sp32 = BINANG_ADD(thisx->yawTowardsPlayer, 0x9000); } else { sp32 = BINANG_ADD(thisx->yawTowardsPlayer, 0x7000); @@ -499,7 +499,7 @@ void func_8091E810(EnFish* this) { this->unk_240 = 300; } -void func_8091E880(Actor* thisx, GlobalContext* globalCtx) { +void func_8091E880(Actor* thisx, PlayState* play) { EnFish* this = THIS; Math_SmoothStepToF(&this->actor.speedXZ, 0.0f, 0.1f, 0.1f, 0.0f); @@ -512,8 +512,8 @@ void func_8091E880(Actor* thisx, GlobalContext* globalCtx) { func_8091E9A4(this); } else if (this->actor.bgCheckFlags & 0x20) { Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_DIVE_INTO_WATER_L); - func_8091D840(thisx, globalCtx, 10, 15.0f); - if (func_8091DA14(this, globalCtx)) { + func_8091D840(thisx, play, 10, 15.0f); + if (func_8091DA14(this, play)) { func_8091EF30(this); } else { func_8091ECF4(this); @@ -558,9 +558,9 @@ void func_8091E9A4(EnFish* this) { } } -void func_8091EAF0(Actor* thisx, GlobalContext* globalCtx) { +void func_8091EAF0(Actor* thisx, PlayState* play) { EnFish* this = THIS; - s32 sp40 = globalCtx->state.frames; + s32 sp40 = play->state.frames; s16 phi_v1; Math_SmoothStepToF(&this->actor.speedXZ, Rand_ZeroOne() * 0.2f, 0.1f, 0.1f, 0.0f); @@ -590,7 +590,7 @@ void func_8091EAF0(Actor* thisx, GlobalContext* globalCtx) { this->actor.draw = NULL; } } else if (this->actor.bgCheckFlags & 0x20) { - if (func_8091DA14(this, globalCtx)) { + if (func_8091DA14(this, play)) { func_8091EF30(this); } else { func_8091ECF4(this); @@ -613,13 +613,13 @@ void func_8091ECF4(EnFish* this) { this->unk_24C = 0.0f; } -void func_8091ED70(Actor* thisx, GlobalContext* globalCtx) { +void func_8091ED70(Actor* thisx, PlayState* play) { EnFish* this = THIS; s32 pad; s16 sp2E; if (this->unk_240 >= 0xBF) { - func_8091D840(thisx, globalCtx, 2, 25.0f); + func_8091D840(thisx, play, 2, 25.0f); } Math_SmoothStepToF(&thisx->speedXZ, 2.8f, 0.1f, 0.4f, 0.0f); @@ -678,10 +678,10 @@ void func_8091EF30(EnFish* this) { this->unk_24C = 0.0f; } -void func_8091EFE8(Actor* thisx, GlobalContext* globalCtx) { +void func_8091EFE8(Actor* thisx, PlayState* play) { EnFish* this = THIS; s32 temp_v0_2; - Actor* sp3C = func_8091D944(this, globalCtx); + Actor* sp3C = func_8091D944(this, play); f32 temp_f0; f32 sp34; f32 sp30; @@ -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; @@ -778,11 +778,11 @@ void func_8091F344(EnFish* this) { this->unk_24C = 0.0f; } -void func_8091F3BC(Actor* thisx, GlobalContext* globalCtx) { +void func_8091F3BC(Actor* thisx, PlayState* play) { static Vec3f D_8091FADC = { 0.0f, 0.04f, 0.09f }; static Vec3f D_8091FAE8 = { 0.5f, 0.1f, 0.15f }; EnFish* this = THIS; - s32 sp40 = globalCtx->gameplayFrames; + s32 sp40 = play->gameplayFrames; Vec3f* sp3C; f32 phi_f0; f32 temp_f2; @@ -825,7 +825,7 @@ void func_8091F3BC(Actor* thisx, GlobalContext* globalCtx) { } } -void func_8091F5A4(Actor* thisx, GlobalContext* globalCtx) { +void func_8091F5A4(Actor* thisx, PlayState* play) { EnFish* this = THIS; Actor* temp_v0_2; s16 temp_v0; @@ -845,7 +845,7 @@ void func_8091F5A4(Actor* thisx, GlobalContext* globalCtx) { this->actor.child = NULL; } - if ((this->unkFunc == NULL) || (this->unkFunc(&this->actor, globalCtx), (this->actor.update != NULL))) { + if ((this->unkFunc == NULL) || (this->unkFunc(&this->actor, play), (this->actor.update != NULL))) { if ((ABS_ALT(BINANG_SUB(this->unk_26A, this->actor.shape.rot.y)) > 0x3000) && (this->unk_270 > 1000)) { this->skelAnime.playSpeed += this->unk_24C; } @@ -853,13 +853,13 @@ void func_8091F5A4(Actor* thisx, GlobalContext* globalCtx) { func_8091D7C4(this); Actor_MoveWithGravity(&this->actor); if (this->unk_248 != 0) { - u32 temp = (globalCtx->sceneNum ^ SCENE_LABO) != 0; + u32 temp = (play->sceneNum ^ SCENE_LABO) != 0; phi_f0 = BREG(1) + 10.0f; if (temp) { phi_f0 = 6.0f; } - Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 17.5f, phi_f0, 0.0f, this->unk_248); + Actor_UpdateBgCheckInfo(play, &this->actor, 17.5f, phi_f0, 0.0f, this->unk_248); } if ((this->actor.xzDistToPlayer < 70.0f) && (this->unkFunc != func_8091EFE8)) { @@ -869,25 +869,25 @@ void func_8091F5A4(Actor* thisx, GlobalContext* globalCtx) { element->dim.worldSphere.center.y = this->actor.world.pos.y; element->dim.worldSphere.center.z = this->actor.world.pos.z; element->dim.worldSphere.radius = this->unk_25C * 500.0f; - CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + CollisionCheck_SetOC(play, &play->colChkCtx, &this->collider.base); } Actor_SetFocus(&this->actor, this->actor.shape.yOffset * 0.01f); - if (Actor_HasParent(&this->actor, globalCtx)) { + if (Actor_HasParent(&this->actor, play)) { this->actor.parent = NULL; if (this->actor.params == ENFISH_0) { Actor_MarkForDeath(&this->actor); } else { func_8091D904(this); } - } else if (func_8091DDF4(this, globalCtx)) { - Actor_PickUp(&this->actor, globalCtx, GI_MAX, 80.0f, 25.0f); + } else if (func_8091DDF4(this, play)) { + Actor_PickUp(&this->actor, play, GI_MAX, 80.0f, 25.0f); } } } -void func_8091F830(Actor* thisx, GlobalContext* globalCtx) { +void func_8091F830(Actor* thisx, PlayState* play) { EnFish* this = THIS; if (this->actor.params == ENFISH_1) { @@ -899,7 +899,7 @@ void func_8091F830(Actor* thisx, GlobalContext* globalCtx) { this->actor.child = NULL; } - if ((this->unkFunc == NULL) || (this->unkFunc(&this->actor, globalCtx), (this->actor.update != NULL))) { + if ((this->unkFunc == NULL) || (this->unkFunc(&this->actor, play), (this->actor.update != NULL))) { func_8091D7C4(this); Actor_MoveWithGravity(&this->actor); @@ -918,14 +918,14 @@ void func_8091F830(Actor* thisx, GlobalContext* globalCtx) { } } -void EnFish_Update(Actor* thisx, GlobalContext* globalCtx) { +void EnFish_Update(Actor* thisx, PlayState* play) { EnFish* this = THIS; if (this->unk_242 > 0) { this->unk_242--; - func_8091F830(thisx, globalCtx); + func_8091F830(thisx, play); } else { - func_8091F5A4(thisx, globalCtx); + func_8091F5A4(thisx, play); } if (this->unk_276 > 0) { @@ -933,21 +933,21 @@ void EnFish_Update(Actor* thisx, GlobalContext* globalCtx) { } } -void func_8091F994(Actor* thisx, GlobalContext* globalCtx) { +void func_8091F994(Actor* thisx, PlayState* play) { } -void EnFish_Draw(Actor* thisx, GlobalContext* globalCtx) { +void EnFish_Draw(Actor* thisx, PlayState* play) { EnFish* this = THIS; Color_RGB8* colour = &D_8091FA94[this->unk_278]; - OPEN_DISPS(globalCtx->state.gfxCtx); + OPEN_DISPS(play->state.gfxCtx); - func_8012C28C(globalCtx->state.gfxCtx); + func_8012C28C(play->state.gfxCtx); gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, colour->r, colour->g, colour->b, 255); - SkelAnime_DrawFlexOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, - NULL, NULL, NULL); + SkelAnime_DrawFlexOpa(play, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, NULL, + NULL, NULL); - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->state.gfxCtx); } diff --git a/src/overlays/actors/ovl_En_Fish/z_en_fish.h b/src/overlays/actors/ovl_En_Fish/z_en_fish.h index fd35ef626..4596c79b1 100644 --- a/src/overlays/actors/ovl_En_Fish/z_en_fish.h +++ b/src/overlays/actors/ovl_En_Fish/z_en_fish.h @@ -5,7 +5,7 @@ struct EnFish; -typedef void (*EnFishUnkFunc)(Actor*, GlobalContext*); +typedef void (*EnFishUnkFunc)(Actor*, PlayState*); enum { /* -1 */ ENFISH_MINUS1 = -1, 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 f86cda7d8..6b8ae91aa 100644 --- a/src/overlays/actors/ovl_En_Fish2/z_en_fish2.c +++ b/src/overlays/actors/ovl_En_Fish2/z_en_fish2.c @@ -14,33 +14,33 @@ #define THIS ((EnFish2*)thisx) -void EnFish2_Init(Actor* thisx, GlobalContext* globalCtx); -void EnFish2_Destroy(Actor* thisx, GlobalContext* globalCtx); -void EnFish2_Update(Actor* thisx, GlobalContext* globalCtx); -void EnFish2_Draw(Actor* thisx, GlobalContext* globalCtx); +void EnFish2_Init(Actor* thisx, PlayState* play); +void EnFish2_Destroy(Actor* thisx, PlayState* play); +void EnFish2_Update(Actor* thisx, PlayState* play); +void EnFish2_Draw(Actor* thisx, PlayState* play); void func_80B28B5C(EnFish2* this); -void func_80B28C14(EnFish2* this, GlobalContext* globalCtx); +void func_80B28C14(EnFish2* this, PlayState* play); void func_80B29128(EnFish2* this); -void func_80B2913C(EnFish2* this, GlobalContext* globalCtx); +void func_80B2913C(EnFish2* this, PlayState* play); void func_80B29194(EnFish2* this); -void func_80B29250(EnFish2* this, GlobalContext* globalCtx); +void func_80B29250(EnFish2* this, PlayState* play); void func_80B2938C(EnFish2* this); -void func_80B293C4(EnFish2* this, GlobalContext* globalCtx); +void func_80B293C4(EnFish2* this, PlayState* play); void func_80B2951C(EnFish2* this); -void func_80B295A4(EnFish2* this, GlobalContext* globalCtx); +void func_80B295A4(EnFish2* this, PlayState* play); void func_80B29778(EnFish2* this); -void func_80B297FC(EnFish2* this, GlobalContext* globalCtx); -void func_80B29E5C(EnFish2* this, GlobalContext* globalCtx); -void func_80B29EE4(EnFish2* this, GlobalContext* globalCtx); -void func_80B2A01C(EnFish2* this, GlobalContext* globalCtx); -void func_80B2A094(EnFish2* this, GlobalContext* globalCtx); -void func_80B2A23C(EnFish2* this, GlobalContext* globalCtx); +void func_80B297FC(EnFish2* this, PlayState* play); +void func_80B29E5C(EnFish2* this, PlayState* play); +void func_80B29EE4(EnFish2* this, PlayState* play); +void func_80B2A01C(EnFish2* this, PlayState* play); +void func_80B2A094(EnFish2* this, PlayState* play); +void func_80B2A23C(EnFish2* this, PlayState* play); void func_80B2A448(EnFish2* this); -void func_80B2A498(EnFish2* this, GlobalContext* globalCtx); +void func_80B2A498(EnFish2* this, PlayState* play); void func_80B2ADB0(EnFish2* this, Vec3f* vec, s16 arg2); -void func_80B2AF80(EnFish2* this, GlobalContext* globalCtx); -void func_80B2B180(EnFish2* this, GlobalContext* globalCtx); +void func_80B2AF80(EnFish2* this, PlayState* play); +void func_80B2B180(EnFish2* this, PlayState* play); static s32 D_80B2B2E0 = 0; static s32 D_80B2B2E4 = 0; @@ -95,7 +95,7 @@ static ColliderJntSphInit sJntSphInit = { OC2_TYPE_1, COLSHAPE_JNTSPH, }, - 2, + ARRAY_COUNT(sJntSphElementsInit), sJntSphElementsInit, }; @@ -107,7 +107,9 @@ void func_80B28370(EnFish2* this, s32 arg0) { &object_fb_Anim_0013AC, &object_fb_Anim_0007D4, &object_fb_Anim_0006D8, &object_fb_Anim_0006D8, &object_fb_Anim_001174, &object_fb_Anim_000ACC, }; - static u8 D_80B2B3A0[] = { 0, 0, 2, 2, 2, 2 }; + static u8 D_80B2B3A0[] = { + ANIMMODE_LOOP, ANIMMODE_LOOP, ANIMMODE_ONCE, ANIMMODE_ONCE, ANIMMODE_ONCE, ANIMMODE_ONCE, + }; f32 sp34; this->unk_2AC = arg0; @@ -146,7 +148,7 @@ s32 func_80B28478(EnFish2* this) { return false; } -void EnFish2_Init(Actor* thisx, GlobalContext* globalCtx) { +void EnFish2_Init(Actor* thisx, PlayState* play) { EnFish2* this = THIS; s32 i; s32 cs; @@ -157,8 +159,8 @@ void EnFish2_Init(Actor* thisx, GlobalContext* globalCtx) { if (this->actor.params == 0) { ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 20.0f); - SkelAnime_InitFlex(globalCtx, &this->skelAnime, &object_fb_Skel_006190, &object_fb_Anim_0013AC, - this->jointTable, this->morphTable, 24); + SkelAnime_InitFlex(play, &this->skelAnime, &object_fb_Skel_006190, &object_fb_Anim_0013AC, this->jointTable, + this->morphTable, 24); this->actor.colChkInfo.mass = MASS_IMMOVABLE; if (this->unk_344 == 0) { if (gSaveContext.save.weekEventReg[81] & 0x10) { @@ -193,7 +195,7 @@ void EnFish2_Init(Actor* thisx, GlobalContext* globalCtx) { while (cs != -1) { this->unk_2BA[i] = cs; cs = ActorCutscene_GetAdditionalCutscene(cs); i++; } // clang-format on - Collider_InitAndSetJntSph(globalCtx, &this->collider, &this->actor, &sJntSphInit, this->colliderElements); + Collider_InitAndSetJntSph(play, &this->collider, &this->actor, &sJntSphInit, this->colliderElements); this->collider.elements[0].dim.modelSphere.radius = 5; this->collider.elements[0].dim.scale = 1.0f; this->collider.elements[0].dim.modelSphere.center.x = 1300; @@ -214,11 +216,11 @@ void EnFish2_Init(Actor* thisx, GlobalContext* globalCtx) { } } -void EnFish2_Destroy(Actor* thisx, GlobalContext* globalCtx) { +void EnFish2_Destroy(Actor* thisx, PlayState* play) { EnFish2* this = THIS; if (this->actor.params != 1) { - Collider_DestroyJntSph(globalCtx, &this->collider); + Collider_DestroyJntSph(play, &this->collider); } } @@ -263,15 +265,15 @@ s32 func_80B288E8(EnFish2* this, Vec3f vec, s32 arg2) { return false; } -s32 func_80B2899C(EnFish2* this, GlobalContext* globalCtx) { - if (BgCheck_SphVsFirstWall(&globalCtx->colCtx, &this->unk_2F4, this->unk_33C)) { +s32 func_80B2899C(EnFish2* this, PlayState* play) { + if (BgCheck_SphVsFirstWall(&play->colCtx, &this->unk_2F4, this->unk_33C)) { return true; } return false; } -void func_80B289DC(EnFish2* this, GlobalContext* globalCtx) { +void func_80B289DC(EnFish2* this, PlayState* play) { WaterBox* sp2C; if (this->unk_2B4 != 0) { @@ -290,7 +292,7 @@ void func_80B289DC(EnFish2* this, GlobalContext* globalCtx) { this->actor.velocity.y = 0.0f; this->actor.gravity = 0.0f; } - } else if (WaterBox_GetSurface1(globalCtx, &globalCtx->colCtx, this->actor.world.pos.x, this->actor.world.pos.z, + } else if (WaterBox_GetSurface1(play, &play->colCtx, this->actor.world.pos.x, this->actor.world.pos.z, &this->unk_334, &sp2C)) { if ((this->unk_334 != BGCHECK_Y_MIN) && (this->actor.world.pos.y < (this->unk_334 - this->unk_2D8))) { this->actor.velocity.y = this->actor.world.rot.x * 0.001f * -0.1f; @@ -323,17 +325,17 @@ void func_80B28B5C(EnFish2* this) { this->actionFunc = func_80B28C14; } -void func_80B28C14(EnFish2* this, GlobalContext* globalCtx) { - Actor* itemAction = globalCtx->actorCtx.actorLists[ACTORCAT_ITEMACTION].first; +void func_80B28C14(EnFish2* this, PlayState* play) { + Actor* itemAction = play->actorCtx.actorLists[ACTORCAT_ITEMACTION].first; WaterBox* waterbox; - if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { + if (Actor_ProcessTalkRequest(&this->actor, &play->state)) { func_80B29128(this); return; } if ((this->unk_2B8 == 0) && (fabsf(this->actor.world.rot.y - this->unk_34A) < 100.0f)) { - if (func_80B2899C(this, globalCtx)) { + if (func_80B2899C(this, play)) { if (this->unk_340 == 0) { this->unk_34A += 0x4000; } else { @@ -343,7 +345,7 @@ void func_80B28C14(EnFish2* this, GlobalContext* globalCtx) { } } - func_80B289DC(this, globalCtx); + func_80B289DC(this, play); if (this->unk_2B6 == 0) { if (this->unk_2B4 == 0) { @@ -369,9 +371,8 @@ void func_80B28C14(EnFish2* this, GlobalContext* globalCtx) { } } - if ((this->unk_334 == BGCHECK_Y_MIN) && - !WaterBox_GetSurface1(globalCtx, &globalCtx->colCtx, this->actor.world.pos.x, this->actor.world.pos.z, - &this->unk_334, &waterbox)) { + if ((this->unk_334 == BGCHECK_Y_MIN) && !WaterBox_GetSurface1(play, &play->colCtx, this->actor.world.pos.x, + this->actor.world.pos.z, &this->unk_334, &waterbox)) { this->unk_334 = this->actor.world.pos.y; } @@ -409,7 +410,7 @@ void func_80B28C14(EnFish2* this, GlobalContext* globalCtx) { EnFish2* fish; this->unk_354 = NULL; - fish = (EnFish2*)Actor_SpawnAsChild(&globalCtx->actorCtx, &this->actor, globalCtx, ACTOR_EN_FISH2, + fish = (EnFish2*)Actor_SpawnAsChild(&play->actorCtx, &this->actor, play, ACTOR_EN_FISH2, this->unk_324.x, this->unk_324.y, this->unk_324.z, 0, 0, 0, 1); this->unk_354 = fish; if (this->unk_354 != NULL) { @@ -425,7 +426,7 @@ void func_80B28C14(EnFish2* this, GlobalContext* globalCtx) { itemAction = itemAction->next; } - func_800B8614(&this->actor, globalCtx, 100.0f); + func_800B8614(&this->actor, play, 100.0f); } } @@ -433,9 +434,9 @@ void func_80B29128(EnFish2* this) { this->actionFunc = func_80B2913C; } -void func_80B2913C(EnFish2* this, GlobalContext* globalCtx) { - if ((Message_GetState(&globalCtx->msgCtx) == 5) && Message_ShouldAdvance(globalCtx)) { - func_801477B4(globalCtx); +void func_80B2913C(EnFish2* this, PlayState* play) { + if ((Message_GetState(&play->msgCtx) == TEXT_STATE_5) && Message_ShouldAdvance(play)) { + func_801477B4(play); func_80B28B5C(this); } } @@ -460,7 +461,7 @@ void func_80B29194(EnFish2* this) { this->actionFunc = func_80B29250; } -void func_80B29250(EnFish2* this, GlobalContext* globalCtx) { +void func_80B29250(EnFish2* this, PlayState* play) { if (!func_80B28478(this)) { Math_ApproachF(&this->actor.speedXZ, (D_80B2B380[0] - this->unk_330) * 1000.0f, 0.3f, 0.3f); @@ -471,7 +472,7 @@ void func_80B29250(EnFish2* this, GlobalContext* globalCtx) { } func_80B287F4(this, 0); - func_80B289DC(this, globalCtx); + func_80B289DC(this, play); if (func_80B288E8(this, this->unk_300, 0) && (((this->unk_2C8 == 0) && (D_80B2B2E4 == 1)) || (this->unk_2C8 != 0))) { Math_Vec3f_Copy(&this->unk_30C, &this->unk_350->world.pos); @@ -486,7 +487,7 @@ void func_80B2938C(EnFish2* this) { this->actionFunc = func_80B293C4; } -void func_80B293C4(EnFish2* this, GlobalContext* globalCtx) { +void func_80B293C4(EnFish2* this, PlayState* play) { f32 currentFrame = this->skelAnime.curFrame; if (func_80B28478(this) == 0) { @@ -507,7 +508,7 @@ void func_80B293C4(EnFish2* this, GlobalContext* globalCtx) { this->actionFunc = func_80B29EE4; } } else { - func_80B289DC(this, globalCtx); + func_80B289DC(this, play); if (func_80B288E8(this, this->unk_318, 1)) { func_80B2951C(this); } @@ -533,15 +534,14 @@ void func_80B2951C(EnFish2* this) { this->actionFunc = func_80B295A4; } -void func_80B295A4(EnFish2* this, GlobalContext* globalCtx) { +void func_80B295A4(EnFish2* this, PlayState* play) { s32 i; f32 currentFrame = this->skelAnime.curFrame; s32 pad; Vec3f sp60; SkelAnime_Update(&this->skelAnime); - Math_SmoothStepToS(&this->actor.world.rot.y, Math_Vec3f_Yaw(&this->actor.world.pos, &globalCtx->view.eye), 1, - 0x1388, 0); + Math_SmoothStepToS(&this->actor.world.rot.y, Math_Vec3f_Yaw(&this->actor.world.pos, &play->view.eye), 1, 0x1388, 0); Math_ApproachZeroF(&this->actor.speedXZ, 0.3f, 0.3f); if (this->unk_2B4 != 0) { Math_Vec3f_Copy(&sp60, &this->unk_318); @@ -549,7 +549,7 @@ void func_80B295A4(EnFish2* this, GlobalContext* globalCtx) { sp60.z += randPlusMinusPoint5Scaled(100.0f); for (i = 0; i < 2; i++) { - EffectSsBubble_Spawn(globalCtx, &sp60, 0.0f, 5.0f, 5.0f, Rand_ZeroFloat(this->unk_330 * 4.0f) + 0.1f); + EffectSsBubble_Spawn(play, &sp60, 0.0f, 5.0f, 5.0f, Rand_ZeroFloat(this->unk_330 * 4.0f) + 0.1f); } } else if (this->unk_2CC <= currentFrame) { if (this->unk_2AC != 5) { @@ -579,7 +579,7 @@ void func_80B29778(EnFish2* this) { this->actor.speedXZ = 0.0f; } -void func_80B297FC(EnFish2* this, GlobalContext* globalCtx) { +void func_80B297FC(EnFish2* this, PlayState* play) { f32 phi_f0 = 0.0f; Vec3f sp48; @@ -598,7 +598,7 @@ void func_80B297FC(EnFish2* this, GlobalContext* globalCtx) { } this->unk_34A = Math_Vec3f_Yaw(&this->actor.world.pos, &this->unk_324); - func_80B289DC(this, globalCtx); + func_80B289DC(this, play); Math_ApproachF(&this->actor.world.pos.x, this->unk_324.x, 0.3f, 3.0f); Math_ApproachF(&this->actor.world.pos.y, this->unk_2D4, 0.3f, 3.0f); Math_ApproachF(&this->actor.world.pos.z, this->unk_324.z, 0.3f, 3.0f); @@ -742,8 +742,8 @@ void func_80B297FC(EnFish2* this, GlobalContext* globalCtx) { Math_SmoothStepToS(&this->actor.world.rot.y, this->unk_34A, 1, 0xFA0, 0); } -void func_80B29E5C(EnFish2* this, GlobalContext* globalCtx) { - Actor* prop = globalCtx->actorCtx.actorLists[ACTORCAT_PROP].first; +void func_80B29E5C(EnFish2* this, PlayState* play) { + Actor* prop = play->actorCtx.actorLists[ACTORCAT_PROP].first; while (prop != NULL) { if (prop->id != ACTOR_EN_FISH2) { @@ -763,7 +763,7 @@ void func_80B29E5C(EnFish2* this, GlobalContext* globalCtx) { } } -void func_80B29EE4(EnFish2* this, GlobalContext* globalCtx) { +void func_80B29EE4(EnFish2* this, PlayState* play) { Vec3f sp2C; if (this->unk_2C4 < 400) { @@ -772,7 +772,7 @@ void func_80B29EE4(EnFish2* this, GlobalContext* globalCtx) { this->unk_338 = 410.0f - this->unk_2C4; Math_ApproachF(&this->actor.speedXZ, 2.0f, 0.3f, 0.3f); Math_ApproachF(&this->unk_350->speedXZ, (D_80B2B380[0] - this->unk_330) * this->unk_338, 0.1f, 0.4f); - func_80B289DC(this, globalCtx); + func_80B289DC(this, play); Math_Vec3f_Copy(&sp2C, &this->unk_350->world.pos); this->unk_34A = Math_Vec3f_Yaw(&this->actor.world.pos, &sp2C); this->unk_348 = Math_Vec3f_Pitch(&this->actor.world.pos, &sp2C); @@ -782,7 +782,7 @@ void func_80B29EE4(EnFish2* this, GlobalContext* globalCtx) { } } -void func_80B2A01C(EnFish2* this, GlobalContext* globalCtx) { +void func_80B2A01C(EnFish2* this, PlayState* play) { if (this->unk_2B4 == 0) { if (!ActorCutscene_GetCanPlayNext(this->unk_2BA[0])) { ActorCutscene_SetIntentToPlay(this->unk_2BA[0]); @@ -794,14 +794,14 @@ void func_80B2A01C(EnFish2* this, GlobalContext* globalCtx) { } } -void func_80B2A094(EnFish2* this, GlobalContext* globalCtx) { - Vec3f sp2C; +void func_80B2A094(EnFish2* this, PlayState* play) { + Vec3f subCamEye; if (this->unk_2B4 == 0) { D_80B2B2E4 = 1; } - this->unk_2CA = ActorCutscene_GetCurrentCamera(this->unk_2BA[0]); + this->subCamId = ActorCutscene_GetCurrentSubCamId(this->unk_2BA[0]); if (D_80B2B2EC != 0) { D_80B2B2EC++; @@ -813,17 +813,17 @@ void func_80B2A094(EnFish2* this, GlobalContext* globalCtx) { } if ((this->unk_350 != NULL) && (this->unk_350->update != NULL)) { - Math_Vec3f_Copy(&sp2C, &this->unk_350->world.pos); - sp2C.x += Math_SinS(-0x3A98) * 110.0f; - sp2C.z += Math_CosS(-0x3A98) * 110.0f; - Math_Vec3f_Copy(&this->unk_2DC, &sp2C); - Math_Vec3f_Copy(&sp2C, &this->unk_350->world.pos); - sp2C.x += Math_SinS(-0x3A98) * 10.0f; - sp2C.z += Math_CosS(-0x3A98) * 10.0f; - Math_Vec3f_Copy(&this->unk_2E8, &sp2C); + Math_Vec3f_Copy(&subCamEye, &this->unk_350->world.pos); + subCamEye.x += Math_SinS(-0x3A98) * 110.0f; + subCamEye.z += Math_CosS(-0x3A98) * 110.0f; + Math_Vec3f_Copy(&this->subCamEye, &subCamEye); + Math_Vec3f_Copy(&subCamEye, &this->unk_350->world.pos); + subCamEye.x += Math_SinS(-0x3A98) * 10.0f; + subCamEye.z += Math_CosS(-0x3A98) * 10.0f; + Math_Vec3f_Copy(&this->subCamAt, &subCamEye); } - Play_CameraSetAtEye(globalCtx, this->unk_2CA, &this->unk_2E8, &this->unk_2DC); + Play_SetCameraAtEye(play, this->subCamId, &this->subCamAt, &this->subCamEye); if ((this->unk_350 == NULL) || (this->unk_350->update == NULL)) { this->unk_350 = NULL; this->unk_2B0++; @@ -834,30 +834,30 @@ void func_80B2A094(EnFish2* this, GlobalContext* globalCtx) { } } -void func_80B2A23C(EnFish2* this, GlobalContext* globalCtx) { - Vec3f sp2C; +void func_80B2A23C(EnFish2* this, PlayState* play) { + Vec3f subCamAt; - Math_Vec3f_Copy(&sp2C, &this->actor.world.pos); + Math_Vec3f_Copy(&subCamAt, &this->actor.world.pos); if (D_80B2B2E4 == 2) { - sp2C.x += (Math_SinS(-0x3A98) * 180.0f); - sp2C.y += 90.0f; - sp2C.z += Math_CosS(-0x3A98) * 180.0f; - Math_Vec3f_Copy(&this->unk_2DC, &sp2C); - Math_Vec3f_Copy(&sp2C, &this->actor.world.pos); - sp2C.y += 70.0f; - Math_Vec3f_Copy(&this->unk_2E8, &sp2C); + subCamAt.x += (Math_SinS(-0x3A98) * 180.0f); + subCamAt.y += 90.0f; + subCamAt.z += Math_CosS(-0x3A98) * 180.0f; + Math_Vec3f_Copy(&this->subCamEye, &subCamAt); + Math_Vec3f_Copy(&subCamAt, &this->actor.world.pos); + subCamAt.y += 70.0f; + Math_Vec3f_Copy(&this->subCamAt, &subCamAt); } else if (D_80B2B2F4 != NULL) { - Math_Vec3f_Copy(&sp2C, &D_80B2B2F4->world.pos); - sp2C.x += Math_SinS(-0x3A98) * 110.0f; - sp2C.z += Math_CosS(-0x3A98) * 110.0f; - Math_Vec3f_Copy(&this->unk_2DC, &sp2C); - Math_Vec3f_Copy(&sp2C, &D_80B2B2F4->world.pos); - sp2C.x += Math_SinS(-0x3A98) * 10.0f; - sp2C.z += Math_CosS(-0x3A98) * 10.0f; - Math_Vec3f_Copy(&this->unk_2E8, &sp2C); + Math_Vec3f_Copy(&subCamAt, &D_80B2B2F4->world.pos); + subCamAt.x += Math_SinS(-0x3A98) * 110.0f; + subCamAt.z += Math_CosS(-0x3A98) * 110.0f; + Math_Vec3f_Copy(&this->subCamEye, &subCamAt); + Math_Vec3f_Copy(&subCamAt, &D_80B2B2F4->world.pos); + subCamAt.x += Math_SinS(-0x3A98) * 10.0f; + subCamAt.z += Math_CosS(-0x3A98) * 10.0f; + Math_Vec3f_Copy(&this->subCamAt, &subCamAt); } - Play_CameraSetAtEye(globalCtx, this->unk_2CA, &this->unk_2E8, &this->unk_2DC); + Play_SetCameraAtEye(play, this->subCamId, &this->subCamAt, &this->subCamEye); if ((this->unk_2B4 == 0) && (D_80B2B2E4 == 3)) { D_80B2B2E0 = D_80B2B2EC = D_80B2B2E4 = 0; @@ -876,7 +876,7 @@ void func_80B2A448(EnFish2* this) { this->actionFunc = func_80B2A498; } -void func_80B2A498(EnFish2* this, GlobalContext* globalCtx) { +void func_80B2A498(EnFish2* this, PlayState* play) { f32 currentFrame = this->skelAnime.curFrame; Vec3f sp80; @@ -884,7 +884,7 @@ void func_80B2A498(EnFish2* this, GlobalContext* globalCtx) { Actor* temp_v0; Math_Vec3f_Copy(&sp80, &this->unk_318); - temp_v0 = Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_COL_MAN, sp80.x, sp80.y, sp80.z, 0, + temp_v0 = Actor_Spawn(&play->actorCtx, play, ACTOR_EN_COL_MAN, sp80.x, sp80.y, sp80.z, 0, this->actor.world.rot.y, 0, 0); if (temp_v0 != NULL) { temp_v0->speedXZ = 4.0f; @@ -903,19 +903,19 @@ void func_80B2A498(EnFish2* this, GlobalContext* globalCtx) { (Animation_OnFrame(&this->skelAnime, 13.0f) || Animation_OnFrame(&this->skelAnime, 31.0f))) { WaterBox* sp78; - if (WaterBox_GetSurface1(globalCtx, &globalCtx->colCtx, this->actor.world.pos.x, this->actor.world.pos.z, - &this->unk_334, &sp78)) { + if (WaterBox_GetSurface1(play, &play->colCtx, this->actor.world.pos.x, this->actor.world.pos.z, &this->unk_334, + &sp78)) { Vec3f sp6C; s32 i; - SoundSource_PlaySfxAtFixedWorldPos(globalCtx, &this->actor.world.pos, 50, NA_SE_EV_BOMB_DROP_WATER); + SoundSource_PlaySfxAtFixedWorldPos(play, &this->actor.world.pos, 50, NA_SE_EV_BOMB_DROP_WATER); for (i = 0; i < 10; i++) { Math_Vec3f_Copy(&sp6C, &this->actor.world.pos); sp6C.x += randPlusMinusPoint5Scaled(70.0f); sp6C.y = this->unk_334 + 10.0f; sp6C.z += randPlusMinusPoint5Scaled(70.0f); - EffectSsGSplash_Spawn(globalCtx, &sp6C, NULL, NULL, 0, (s32)randPlusMinusPoint5Scaled(50.0f) + 350); + EffectSsGSplash_Spawn(play, &sp6C, NULL, NULL, 0, (s32)randPlusMinusPoint5Scaled(50.0f) + 350); } } } @@ -929,11 +929,11 @@ void func_80B2A498(EnFish2* this, GlobalContext* globalCtx) { } } -void EnFish2_Update(Actor* thisx, GlobalContext* globalCtx2) { +void EnFish2_Update(Actor* thisx, PlayState* play2) { static f32 D_80B2B3A8[] = { 0.0f, 40.0f, -40.0f, 0.0f, 0.0f, 0.0f, }; - GlobalContext* globalCtx = globalCtx2; + PlayState* play = play2; EnFish2* this = THIS; if ((this->actionFunc != func_80B295A4) && (this->actor.params != 1)) { @@ -953,7 +953,7 @@ void EnFish2_Update(Actor* thisx, GlobalContext* globalCtx2) { this->unk_2B4--; } - this->actionFunc(this, globalCtx); + this->actionFunc(this, play); Actor_SetFocus(&this->actor, 0); if (this->actor.params != 1) { @@ -968,18 +968,18 @@ void EnFish2_Update(Actor* thisx, GlobalContext* globalCtx2) { } } - if ((globalCtx->gameplayFrames % 8) == 0) { + if ((play->gameplayFrames % 8) == 0) { Math_Vec3f_Copy(&sp5C, &this->unk_324); sp5C.x += randPlusMinusPoint5Scaled(100.0f); sp5C.y = this->actor.floorHeight; sp5C.z += randPlusMinusPoint5Scaled(100.0f); for (i = 0; i < (s32)randPlusMinusPoint5Scaled(5.0f) + 10; i++) { - EffectSsBubble_Spawn(globalCtx, &sp5C, 0, 5.0f, 5.0f, Rand_ZeroFloat(this->unk_330 * 4.0f) + 0.1f); + EffectSsBubble_Spawn(play, &sp5C, 0, 5.0f, 5.0f, Rand_ZeroFloat(this->unk_330 * 4.0f) + 0.1f); } } - func_80B2AF80(this, globalCtx); + func_80B2AF80(this, play); Math_Vec3s_Copy(&this->actor.shape.rot, &this->actor.world.rot); Math_Vec3f_Copy(&this->unk_2F4, &this->actor.world.pos); this->unk_2F4.x += (Math_SinS(this->actor.world.rot.y) * 25.0f) - this->unk_330; @@ -987,7 +987,7 @@ void EnFish2_Update(Actor* thisx, GlobalContext* globalCtx2) { this->unk_33C = 25.0f - ((this->unk_330 - 0.01f) * 1000.0f); Actor_SetScale(&this->actor, this->unk_330); Actor_MoveWithGravity(&this->actor); - Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 0, 15.0f, 10.0f, 7); + Actor_UpdateBgCheckInfo(play, &this->actor, 0, 15.0f, 10.0f, 7); if (this->actor.params != 2) { this->unk_2D4 = this->actor.floorHeight + (this->unk_330 * 1000.0f); @@ -996,7 +996,7 @@ void EnFish2_Update(Actor* thisx, GlobalContext* globalCtx2) { this->actor.world.pos.y = this->unk_2D4 + 0.1f; } - if (WaterBox_GetSurface1(globalCtx, &globalCtx->colCtx, this->actor.world.pos.x, this->actor.world.pos.z, + if (WaterBox_GetSurface1(play, &play->colCtx, this->actor.world.pos.x, this->actor.world.pos.z, &this->unk_334, &sp6C)) { if ((this->unk_334 != BGCHECK_Y_MIN) && (this->unk_334 - this->unk_2D8 < this->actor.world.pos.y)) { this->actor.world.pos.y = this->unk_334 - this->unk_2D8; @@ -1009,8 +1009,8 @@ void EnFish2_Update(Actor* thisx, GlobalContext* globalCtx2) { f32 phi_f20 = 0; WaterBox* sp4C; - if (WaterBox_GetSurface1(globalCtx, &globalCtx->colCtx, this->actor.world.pos.x, - this->actor.world.pos.z, &this->unk_334, &sp4C)) { + if (WaterBox_GetSurface1(play, &play->colCtx, this->actor.world.pos.x, this->actor.world.pos.z, + &this->unk_334, &sp4C)) { phi_f20 = D_80B2B3A8[temp_s0_2] + (this->unk_334 - this->unk_2D8); phi_f2 = D_80B2B3A8[temp_s0_2 + 1] + this->unk_2D4; } @@ -1029,14 +1029,13 @@ void EnFish2_Update(Actor* thisx, GlobalContext* globalCtx2) { } if (D_80B2B2E8 == 0) { - CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + CollisionCheck_SetOC(play, &play->colChkCtx, &this->collider.base); } } } } -s32 EnFish2_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, - Actor* thisx) { +s32 EnFish2_OverrideLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, Actor* thisx) { EnFish2* this = THIS; if ((limbIndex == 20) || (limbIndex == 21)) { @@ -1046,43 +1045,43 @@ s32 EnFish2_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dLis return false; } -void EnFish2_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx) { +void EnFish2_PostLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx) { EnFish2* this = THIS; s32 pad; if ((limbIndex == 20) || (limbIndex == 21)) { - OPEN_DISPS(globalCtx->state.gfxCtx); + OPEN_DISPS(play->state.gfxCtx); - Matrix_StatePush(); - Matrix_NormalizeXYZ(&globalCtx->billboardMtxF); + Matrix_Push(); + Matrix_ReplaceRotation(&play->billboardMtxF); - gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(play->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); + CLOSE_DISPS(play->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); } -void EnFish2_Draw(Actor* thisx, GlobalContext* globalCtx) { +void EnFish2_Draw(Actor* thisx, PlayState* play) { EnFish2* this = THIS; - func_8012C28C(globalCtx->state.gfxCtx); - func_8012C2DC(globalCtx->state.gfxCtx); - SkelAnime_DrawFlexOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, + func_8012C28C(play->state.gfxCtx); + func_8012C2DC(play->state.gfxCtx); + SkelAnime_DrawFlexOpa(play, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, EnFish2_OverrideLimbDraw, EnFish2_PostLimbDraw, &this->actor); - func_80B2B180(this, globalCtx); + func_80B2B180(this, play); } void func_80B2ADB0(EnFish2* this, Vec3f* vec, s16 arg2) { @@ -1113,7 +1112,7 @@ void func_80B2ADB0(EnFish2* this, Vec3f* vec, s16 arg2) { } } -void func_80B2AF80(EnFish2* this, GlobalContext* globalCtx) { +void func_80B2AF80(EnFish2* this, PlayState* play) { EnFish2UnkStruct* ptr = &this->unk_3F8[0]; WaterBox* sp90; f32 sp8C; @@ -1133,7 +1132,7 @@ void func_80B2AF80(EnFish2* this, GlobalContext* globalCtx) { ptr->unk_04.y += 1.0f + ((Rand_ZeroOne() - 0.3f) * 1.2f); ptr->unk_04.z += (0.3f + (Rand_ZeroOne() * 0.5f)) - 0.55f; sp8C = ptr->unk_04.y; - if (!WaterBox_GetSurface1(globalCtx, &globalCtx->colCtx, ptr->unk_04.x, ptr->unk_04.z, &sp8C, &sp90)) { + if (!WaterBox_GetSurface1(play, &play->colCtx, ptr->unk_04.x, ptr->unk_04.z, &sp8C, &sp90)) { ptr->unk_00 = 0; } else if (sp8C < ptr->unk_04.y) { Vec3f sp7C; @@ -1141,7 +1140,7 @@ void func_80B2AF80(EnFish2* this, GlobalContext* globalCtx) { sp7C.x = ptr->unk_04.x; sp7C.y = sp8C; sp7C.z = ptr->unk_04.z; - EffectSsGRipple_Spawn(globalCtx, &sp7C, 0, 80, 0); + EffectSsGRipple_Spawn(play, &sp7C, 0, 80, 0); ptr->unk_00 = 0; } } @@ -1149,10 +1148,10 @@ void func_80B2AF80(EnFish2* this, GlobalContext* globalCtx) { } } -void func_80B2B180(EnFish2* this, GlobalContext* globalCtx) { +void func_80B2B180(EnFish2* this, PlayState* play) { s16 i; EnFish2UnkStruct* ptr; - GraphicsContext* gfxCtx = globalCtx->state.gfxCtx; + GraphicsContext* gfxCtx = play->state.gfxCtx; OPEN_DISPS(gfxCtx); @@ -1161,7 +1160,7 @@ 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); @@ -1172,5 +1171,5 @@ void func_80B2B180(EnFish2* this, GlobalContext* globalCtx) { } } - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->state.gfxCtx); } diff --git a/src/overlays/actors/ovl_En_Fish2/z_en_fish2.h b/src/overlays/actors/ovl_En_Fish2/z_en_fish2.h index 7216d00c8..67dfa98f7 100644 --- a/src/overlays/actors/ovl_En_Fish2/z_en_fish2.h +++ b/src/overlays/actors/ovl_En_Fish2/z_en_fish2.h @@ -5,7 +5,7 @@ struct EnFish2; -typedef void (*EnFish2ActionFunc)(struct EnFish2*, GlobalContext*); +typedef void (*EnFish2ActionFunc)(struct EnFish2*, PlayState*); typedef struct { /* 0x00 */ u8 unk_00; @@ -32,13 +32,13 @@ typedef struct EnFish2 { /* 0x02C0 */ s32 unk_2C0; /* 0x02C4 */ s32 unk_2C4; /* 0x02C8 */ u8 unk_2C8; - /* 0x02CA */ s16 unk_2CA; + /* 0x02CA */ s16 subCamId; /* 0x02CC */ f32 unk_2CC; - /* 0x02D0 */ char unk_2D0[0x4]; + /* 0x02D0 */ UNK_TYPE1 unk_2D0[0x4]; /* 0x02D4 */ f32 unk_2D4; /* 0x02D8 */ f32 unk_2D8; - /* 0x02DC */ Vec3f unk_2DC; - /* 0x02E8 */ Vec3f unk_2E8; + /* 0x02DC */ Vec3f subCamEye; + /* 0x02E8 */ Vec3f subCamAt; /* 0x02F4 */ Vec3f unk_2F4; /* 0x0300 */ Vec3f unk_300; /* 0x030C */ Vec3f unk_30C; @@ -53,7 +53,6 @@ typedef struct EnFish2 { /* 0x0348 */ s16 unk_348; /* 0x034A */ s16 unk_34A; /* 0x034C */ s16 unk_34C; - /* 0x034E */ char unk_34E[0x02]; /* 0x0350 */ Actor* unk_350; /* 0x0354 */ struct EnFish2* unk_354; /* 0x0358 */ ColliderJntSph collider; diff --git a/src/overlays/actors/ovl_En_Fishing/z_en_fishing.c b/src/overlays/actors/ovl_En_Fishing/z_en_fishing.c index eccee0fe9..59e3abdb4 100644 --- a/src/overlays/actors/ovl_En_Fishing/z_en_fishing.c +++ b/src/overlays/actors/ovl_En_Fishing/z_en_fishing.c @@ -4,8 +4,8 @@ * Description: Fishing Pond Elements (Owner, Fish, Props, Effects...) */ -#include "prevent_bss_reordering.h" #include "z_en_fishing.h" +#include "z64rumble.h" #include "objects/object_fish/object_fish.h" #include "overlays/actors/ovl_En_Kanban/z_en_kanban.h" @@ -13,15 +13,15 @@ #define THIS ((EnFishing*)thisx) -#define WATER_SURFACE_Y(globalCtx) globalCtx->colCtx.colHeader->waterBoxes->minPos.y +#define WATER_SURFACE_Y(play) play->colCtx.colHeader->waterBoxes->minPos.y -void EnFishing_Init(Actor* thisx, GlobalContext* globalCtx); -void EnFishing_Destroy(Actor* thisx, GlobalContext* globalCtx); -void EnFishing_UpdateFish(Actor* thisx, GlobalContext* globalCtx); -void EnFishing_DrawFish(Actor* thisx, GlobalContext* globalCtx); +void EnFishing_Init(Actor* thisx, PlayState* play); +void EnFishing_Destroy(Actor* thisx, PlayState* play); +void EnFishing_UpdateFish(Actor* thisx, PlayState* play); +void EnFishing_DrawFish(Actor* thisx, PlayState* play); -void EnFishing_UpdateOwner(Actor* thisx, GlobalContext* globalCtx); -void EnFishing_DrawOwner(Actor* thisx, GlobalContext* globalCtx); +void EnFishing_UpdateOwner(Actor* thisx, PlayState* play); +void EnFishing_DrawOwner(Actor* thisx, PlayState* play); typedef struct { /* 0x00 */ u8 unk_00; @@ -138,11 +138,11 @@ u8 D_80911E28; Vec3f sSinkingLurePos[SINKING_LURE_SEG_COUNT]; s16 D_80911F20; f32 sProjectedW; -Vec3f sCameraEye; -Vec3f sCameraAt; -s16 sCameraId; +Vec3f sSubCamEye; +Vec3f sSubCamAt; +s16 sSubCamId; f32 D_80911F48; -f32 D_80911F4C; +f32 sSubCamVelFactor; f32 D_80911F50; Vec3f sSinkingLureBasePos; f32 D_80911F64; @@ -570,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; } @@ -724,7 +724,7 @@ FishingPropInit sPondPropInits[POND_PROP_COUNT + 1] = { { FS_PROP_INIT_STOP, { 0 } }, }; -void EnFishing_InitPondProps(EnFishing* this, GlobalContext* globalCtx) { +void EnFishing_InitPondProps(EnFishing* this, PlayState* play) { FishingProp* prop = &sPondProps[0]; Vec3f colliderPos; s16 i; @@ -794,8 +794,8 @@ static InitChainEntry sInitChain[] = { ICHAIN_F32(targetArrowOffset, 0, ICHAIN_STOP), }; -void EnFishing_Init(Actor* thisx, GlobalContext* globalCtx2) { - GlobalContext* globalCtx = globalCtx2; +void EnFishing_Init(Actor* thisx, PlayState* play2) { + PlayState* play = play2; EnFishing* this = THIS; u16 fishCount; @@ -810,12 +810,12 @@ void EnFishing_Init(Actor* thisx, GlobalContext* globalCtx2) { D_809171C8 = 0; sFishingMain = this; - Collider_InitJntSph(globalCtx, &sFishingMain->collider); - Collider_SetJntSph(globalCtx, &sFishingMain->collider, thisx, &sJntSphInit, sFishingMain->colliderElements); + Collider_InitJntSph(play, &sFishingMain->collider); + Collider_SetJntSph(play, &sFishingMain->collider, thisx, &sJntSphInit, sFishingMain->colliderElements); thisx->params = 1; - SkelAnime_InitFlex(globalCtx, &this->skelAnime, &gFishingOwnerSkel, &gFishingOwnerAnim, NULL, NULL, 0); + SkelAnime_InitFlex(play, &this->skelAnime, &gFishingOwnerSkel, &gFishingOwnerAnim, NULL, NULL, 0); Animation_MorphToLoop(&this->skelAnime, &gFishingOwnerAnim, 0.0f); thisx->update = EnFishing_UpdateOwner; @@ -844,7 +844,7 @@ void EnFishing_Init(Actor* thisx, GlobalContext* globalCtx2) { } D_8090CD04 = 20; - globalCtx->specialEffects = sFishingEffects; + play->specialEffects = sFishingEffects; REG(15) = 1; // gTimeIncrement in OoT D_809171FC = 0; D_809171F6 = 10; @@ -865,10 +865,10 @@ void EnFishing_Init(Actor* thisx, GlobalContext* globalCtx2) { D_809171D1 = (gSaveContext.save.unk_EE4 & 0xFF0000) >> 0x10; if ((D_809171D1 & 7) == 7) { - globalCtx->roomCtx.unk7A[0] = 90; + play->roomCtx.unk7A[0] = 90; D_809171CA = 1; } else { - globalCtx->roomCtx.unk7A[0] = 40; + play->roomCtx.unk7A[0] = 40; D_809171CA = 0; } @@ -896,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; @@ -921,10 +921,10 @@ void EnFishing_Init(Actor* thisx, GlobalContext* globalCtx2) { } } - EnFishing_InitPondProps(this, globalCtx); - Actor_SpawnAsChild(&globalCtx->actorCtx, thisx, globalCtx, ACTOR_EN_KANBAN, 53.0f, -17.0f, 982.0f, 0, 0, 0, + EnFishing_InitPondProps(this, play); + Actor_SpawnAsChild(&play->actorCtx, thisx, play, ACTOR_EN_KANBAN, 53.0f, -17.0f, 982.0f, 0, 0, 0, ENKANBAN_FISHING); - Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_FISHING, 0.0f, 0.0f, 0.0f, 0, 0, 0, 200); + Actor_Spawn(&play->actorCtx, play, ACTOR_EN_FISHING, 0.0f, 0.0f, 0.0f, 0, 0, 0, 200); if ((D_809171D1 & 3) == 3) { if (sLinkAge != 1) { @@ -937,7 +937,7 @@ void EnFishing_Init(Actor* thisx, GlobalContext* globalCtx2) { } for (i = 0; i < fishCount; i++) { - Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_FISHING, sFishInits[i].pos.x, sFishInits[i].pos.y, + Actor_Spawn(&play->actorCtx, play, ACTOR_EN_FISHING, sFishInits[i].pos.x, sFishInits[i].pos.y, sFishInits[i].pos.z, 0, Rand_ZeroFloat(0x10000), 0, 100 + i); } @@ -947,10 +947,10 @@ void EnFishing_Init(Actor* thisx, GlobalContext* globalCtx2) { thisx->bgCheckFlags |= 0x800; // Added in MM if ((thisx->params < 115) || (thisx->params == 200)) { - SkelAnime_InitFlex(globalCtx, &this->skelAnime, &gFishingFishSkel, &gFishingFishAnim, NULL, NULL, 0); + SkelAnime_InitFlex(play, &this->skelAnime, &gFishingFishSkel, &gFishingFishAnim, NULL, NULL, 0); Animation_MorphToLoop(&this->skelAnime, &gFishingFishAnim, 0.0f); } else { - SkelAnime_InitFlex(globalCtx, &this->skelAnime, &gFishingLoachSkel, &gFishingLoachAnim, NULL, NULL, 0); + SkelAnime_InitFlex(play, &this->skelAnime, &gFishingLoachSkel, &gFishingLoachAnim, NULL, NULL, 0); Animation_MorphToLoop(&this->skelAnime, &gFishingLoachAnim, 0.0f); } @@ -958,10 +958,10 @@ void EnFishing_Init(Actor* thisx, GlobalContext* globalCtx2) { if (thisx->params == 200) { this->unk_150 = 100; - func_800BC154(globalCtx, &globalCtx->actorCtx, thisx, ACTORCAT_PROP); + func_800BC154(play, &play->actorCtx, thisx, ACTORCAT_PROP); thisx->targetMode = 0; thisx->flags |= 9; - this->lightNode = LightContext_InsertLight(globalCtx, &globalCtx->lightCtx, &this->lightInfo); + this->lightNode = LightContext_InsertLight(play, &play->lightCtx, &this->lightInfo); } else { this->unk_150 = 10; this->unk_152 = 10; @@ -982,20 +982,20 @@ void EnFishing_Init(Actor* thisx, GlobalContext* globalCtx2) { } } -void EnFishing_Destroy(Actor* thisx, GlobalContext* globalCtx2) { - GlobalContext* globalCtx = globalCtx2; +void EnFishing_Destroy(Actor* thisx, PlayState* play2) { + PlayState* play = play2; EnFishing* this = THIS; - SkelAnime_Free(&this->skelAnime, globalCtx); + SkelAnime_Free(&this->skelAnime, play); if (thisx->params == 200) { - LightContext_RemoveLight(globalCtx, &globalCtx->lightCtx, this->lightNode); + LightContext_RemoveLight(play, &play->lightCtx, this->lightNode); } else if (thisx->params == 1) { - Collider_DestroyJntSph(globalCtx, &this->collider); + Collider_DestroyJntSph(play, &this->collider); } } -void EnFishing_UpdateEffects(FishingEffect* effect, GlobalContext* globalCtx) { +void EnFishing_UpdateEffects(FishingEffect* effect, PlayState* play) { f32 rippleY; s16 i; @@ -1028,7 +1028,7 @@ void EnFishing_UpdateEffects(FishingEffect* effect, GlobalContext* globalCtx) { Math_ApproachF(&effect->unk_30, effect->unk_34, 0.1f, 0.1f); effect->alpha -= 10; - if (effect->pos.y > (WATER_SURFACE_Y(globalCtx) - 5.0f)) { + if (effect->pos.y > (WATER_SURFACE_Y(play) - 5.0f)) { effect->accel.y = 0.0f; effect->vel.y = 0.0f; effect->alpha -= 5; @@ -1039,7 +1039,7 @@ void EnFishing_UpdateEffects(FishingEffect* effect, GlobalContext* globalCtx) { } } else if (effect->type == FS_EFF_BUBBLE) { if (effect->unk_2C == 0) { - rippleY = WATER_SURFACE_Y(globalCtx); + rippleY = WATER_SURFACE_Y(play); } else { rippleY = 69.0f; } @@ -1050,7 +1050,7 @@ void EnFishing_UpdateEffects(FishingEffect* effect, GlobalContext* globalCtx) { if (Rand_ZeroOne() < 0.3f) { Vec3f pos = effect->pos; pos.y = rippleY; - EnFishing_SpawnRipple(NULL, globalCtx->specialEffects, &pos, 20.0f, 60.0f, 150, 90); + EnFishing_SpawnRipple(NULL, play->specialEffects, &pos, 20.0f, 60.0f, 150, 90); } } } else if (effect->type == FS_EFF_DUST_SPLASH) { @@ -1059,25 +1059,25 @@ void EnFishing_UpdateEffects(FishingEffect* effect, GlobalContext* globalCtx) { effect->accel.y = 0.0f; } - if (effect->pos.y <= WATER_SURFACE_Y(globalCtx)) { + if (effect->pos.y <= WATER_SURFACE_Y(play)) { effect->type = FS_EFF_NONE; if (Rand_ZeroOne() < 0.5f) { Vec3f pos = effect->pos; - pos.y = WATER_SURFACE_Y(globalCtx); - EnFishing_SpawnRipple(NULL, globalCtx->specialEffects, &pos, 40.0f, 110.0f, 150, 90); + pos.y = WATER_SURFACE_Y(play); + EnFishing_SpawnRipple(NULL, play->specialEffects, &pos, 40.0f, 110.0f, 150, 90); } } } else if (effect->type == FS_EFF_RAIN_DROP) { - if (effect->pos.y < WATER_SURFACE_Y(globalCtx)) { - f32 sqDistXZ = SQ(effect->pos.x) + SQ(effect->pos.z); + if (effect->pos.y < WATER_SURFACE_Y(play)) { + f32 sqDistXZ = SQXZ(effect->pos); if (sqDistXZ > SQ(920.0f)) { - effect->pos.y = WATER_SURFACE_Y(globalCtx) + ((sqrtf(sqDistXZ) - 920.0f) * 0.11f); + effect->pos.y = WATER_SURFACE_Y(play) + ((sqrtf(sqDistXZ) - 920.0f) * 0.11f); effect->timer = 2; effect->type = FS_EFF_RAIN_SPLASH; effect->unk_30 = (KREG(18) + 30) * 0.001f; } else { - effect->pos.y = WATER_SURFACE_Y(globalCtx) + 3.0f; + effect->pos.y = WATER_SURFACE_Y(play) + 3.0f; effect->timer = 0; if (Rand_ZeroOne() < 0.75f) { effect->type = FS_EFF_RAIN_RIPPLE; @@ -1106,8 +1106,8 @@ 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); - bottomY = WATER_SURFACE_Y(globalCtx) + ((sqrtf(sqDistXZ) - 920.0f) * 0.147f); + sqDistXZ = SQXZ(effect->pos); + bottomY = WATER_SURFACE_Y(play) + ((sqrtf(sqDistXZ) - 920.0f) * 0.147f); if (effect->pos.y > (bottomY - 10.0f)) { effect->pos.y -= 0.1f; @@ -1115,8 +1115,8 @@ void EnFishing_UpdateEffects(FishingEffect* effect, GlobalContext* globalCtx) { if ((effect->timer % 16) == 0) { Vec3f pos = effect->pos; - pos.y = WATER_SURFACE_Y(globalCtx); - EnFishing_SpawnRipple(NULL, globalCtx->specialEffects, &pos, 30.0f, 300.0f, 150, 90); + pos.y = WATER_SURFACE_Y(play); + EnFishing_SpawnRipple(NULL, play->specialEffects, &pos, 30.0f, 300.0f, 150, 90); } if (effect->unk_2C >= 0) { @@ -1124,13 +1124,13 @@ void EnFishing_UpdateEffects(FishingEffect* effect, GlobalContext* globalCtx) { } if (effect->unk_2C == 30) { - Message_StartTextbox(globalCtx, 0x40B3, NULL); + Message_StartTextbox(play, 0x40B3, NULL); } - if ((effect->unk_2C >= 100) && (Message_GetState(&globalCtx->msgCtx) == 5)) { - if (Message_ShouldAdvance(globalCtx) || Message_GetState(&globalCtx->msgCtx) == 0) { - func_801477B4(globalCtx); - func_801159EC(-50); + if ((effect->unk_2C >= 100) && (Message_GetState(&play->msgCtx) == TEXT_STATE_5)) { + if (Message_ShouldAdvance(play) || (Message_GetState(&play->msgCtx) == TEXT_STATE_NONE)) { + func_801477B4(play); + Rupees_ChangeBy(-50); effect->unk_2C = -1; } } @@ -1141,16 +1141,16 @@ void EnFishing_UpdateEffects(FishingEffect* effect, GlobalContext* globalCtx) { } } -void EnFishing_DrawEffects(FishingEffect* effect, GlobalContext* globalCtx) { +void EnFishing_DrawEffects(FishingEffect* effect, PlayState* play) { u8 flag = 0; f32 rotY; s16 i; s32 pad; FishingEffect* firstEffect = effect; - OPEN_DISPS(globalCtx->state.gfxCtx); + OPEN_DISPS(play->state.gfxCtx); - Matrix_StatePush(); + Matrix_Push(); gDPPipeSync(POLY_XLU_DISP++); @@ -1164,11 +1164,10 @@ 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), - G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_XLU_DISP++, gFishingRippleVtxDL); } @@ -1187,12 +1186,11 @@ 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(&play->billboardMtxF); Matrix_Scale(effect->unk_30, effect->unk_30, 1.0f, MTXMODE_APPLY); - gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), - G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_XLU_DISP++, gFishingDustSplashVtxDL); } @@ -1212,15 +1210,14 @@ void EnFishing_DrawEffects(FishingEffect* effect, GlobalContext* globalCtx) { gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, 40, 90, 80, effect->alpha); gSPSegment(POLY_OPA_DISP++, 0x08, - Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, effect->timer + (i * 3), - (effect->timer + (i * 3)) * 5, 32, 64, 1, 0, 0, 32, 32)); + Gfx_TwoTexScroll(play->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(&play->billboardMtxF); Matrix_Scale(effect->unk_30, effect->unk_30, 1.0f, MTXMODE_APPLY); - gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), - G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_OPA_DISP++, gFishingWaterDustVtxDL); } @@ -1238,12 +1235,11 @@ 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(&play->billboardMtxF); Matrix_Scale(effect->unk_30, effect->unk_30, 1.0f, MTXMODE_APPLY); - gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), - G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_XLU_DISP++, gFishingBubbleVtxDL); } @@ -1261,21 +1257,20 @@ 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), - G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_XLU_DISP++, gFishingRainDropVtxDL); } effect++; } - func_8012C2DC(globalCtx->state.gfxCtx); + func_8012C2DC(play->state.gfxCtx); effect = firstEffect + 30; flag = 0; @@ -1288,11 +1283,10 @@ 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), - G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_XLU_DISP++, gFishingRippleVtxDL); } @@ -1315,13 +1309,12 @@ 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(&play->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), - G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_XLU_DISP++, gFishingRainSplashVtxDL); } @@ -1330,41 +1323,41 @@ 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); - gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + Matrix_Translate(-1250.0f, 0.0f, 0.0f, MTXMODE_APPLY); + Matrix_RotateXFApply(M_PI / 2); + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(play->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); + CLOSE_DISPS(play->state.gfxCtx); } -void EnFishing_DrawStreamSplash(GlobalContext* globalCtx) { +void EnFishing_DrawStreamSplash(PlayState* play) { s32 pad; - OPEN_DISPS(globalCtx->state.gfxCtx); + OPEN_DISPS(play->state.gfxCtx); gSPSegment(POLY_XLU_DISP++, 0x09, - Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, globalCtx->gameplayFrames * 1, - globalCtx->gameplayFrames * 8, 32, 64, 1, -globalCtx->gameplayFrames * 2, 0, 16, 16)); + Gfx_TwoTexScroll(play->state.gfxCtx, 0, play->gameplayFrames * 1, play->gameplayFrames * 8, 32, 64, 1, + -play->gameplayFrames * 2, 0, 16, 16)); gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 195, 225, 235, 50); - Matrix_InsertTranslation(670.0f, -24.0f, -600.0f, MTXMODE_NEW); + Matrix_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); + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_XLU_DISP++, gFishingStreamSplashDL); - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->state.gfxCtx); } s32 func_808FEF70(Vec3f* vec) { @@ -1378,7 +1371,7 @@ s32 func_808FEF70(Vec3f* vec) { return false; } -void EnFishing_UpdateLine(GlobalContext* globalCtx, Vec3f* basePos, Vec3f* pos, Vec3f* rot, Vec3f* unk) { +void EnFishing_UpdateLine(PlayState* play, Vec3f* basePos, Vec3f* pos, Vec3f* rot, Vec3f* unk) { s32 i; s32 k; f32 dx; @@ -1441,16 +1434,16 @@ void EnFishing_UpdateLine(GlobalContext* globalCtx, Vec3f* basePos, Vec3f* pos, sqDistXZ = SQ((pos + i)->x) + SQ((pos + i)->z); if (sqDistXZ > SQ(920.0f)) { - phi_f12 = ((sqrtf(sqDistXZ) - 920.0f) * 0.11f) + WATER_SURFACE_Y(globalCtx); + phi_f12 = ((sqrtf(sqDistXZ) - 920.0f) * 0.11f) + WATER_SURFACE_Y(play); } else { - phi_f12 = WATER_SURFACE_Y(globalCtx); + phi_f12 = WATER_SURFACE_Y(play); } if (D_80917206 == 2) { f32 phi_f2; if (spD8 < phi_f12) { - phi_f12 = ((sqrtf(sqDistXZ) - 920.0f) * 0.147f) + WATER_SURFACE_Y(globalCtx); + phi_f12 = ((sqrtf(sqDistXZ) - 920.0f) * 0.147f) + WATER_SURFACE_Y(play); if (spD8 > phi_f12) { u8 temp; @@ -1494,9 +1487,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; @@ -1527,9 +1520,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; @@ -1537,7 +1530,7 @@ void EnFishing_UpdateLinePos(Vec3f* pos) { } } -void EnFishing_DrawLureHook(GlobalContext* globalCtx, Vec3f* pos, Vec3f* refPos, u8 hookIndex) { +void EnFishing_DrawLureHook(PlayState* play, Vec3f* pos, Vec3f* refPos, u8 hookIndex) { f32 dx; f32 dy; f32 dz; @@ -1547,15 +1540,15 @@ void EnFishing_DrawLureHook(GlobalContext* globalCtx, Vec3f* pos, Vec3f* refPos, f32 offsetY; Vec3f posSrc = { 0.0f, 0.0f, 1.0f }; Vec3f posStep; - Player* player = GET_PLAYER(globalCtx); + Player* player = GET_PLAYER(play); - OPEN_DISPS(globalCtx->state.gfxCtx); + OPEN_DISPS(play->state.gfxCtx); - Matrix_StatePush(); + Matrix_Push(); - if ((D_8090CD14 == 3) && ((pos->y > WATER_SURFACE_Y(globalCtx)) || ((D_8090CD0C != 0) && hookIndex))) { + if ((D_8090CD14 == 3) && ((pos->y > WATER_SURFACE_Y(play)) || ((D_8090CD0C != 0) && hookIndex))) { offsetY = 0.0f; - } else if (pos->y < WATER_SURFACE_Y(globalCtx)) { + } else if (pos->y < WATER_SURFACE_Y(play)) { offsetY = -1.0f; } else { offsetY = -3.0f; @@ -1569,15 +1562,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); @@ -1585,31 +1578,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); + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(play->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); + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(play->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; + FishingEffect* effect = play->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; @@ -1620,20 +1613,20 @@ 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); + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(play->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); + CLOSE_DISPS(play->state.gfxCtx); } -void EnFishing_UpdateSinkingLure(GlobalContext* globalCtx) { +void EnFishing_UpdateSinkingLure(PlayState* play) { s32 i; f32 dx; f32 dy; @@ -1648,7 +1641,7 @@ void EnFishing_UpdateSinkingLure(GlobalContext* globalCtx) { Vec3f sp88; f32 offsetX; f32 offsetZ; - Player* player = GET_PLAYER(globalCtx); + Player* player = GET_PLAYER(play); Vec3f* pos; s32 pad; @@ -1658,18 +1651,18 @@ void EnFishing_UpdateSinkingLure(GlobalContext* globalCtx) { if (D_8090CD54 != 0) { offsetY = -1.0f; - } else if (sLurePos.y < WATER_SURFACE_Y(globalCtx)) { + } else if (sLurePos.y < WATER_SURFACE_Y(play)) { offsetY = 0.5f; } else { offsetY = -5.0f; } 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++) { @@ -1690,9 +1683,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; @@ -1705,72 +1698,72 @@ f32 sSinkingLureSizes[] = { 0.9f, 0.85f, 0.8f, 0.7f, 0.8f, 1.0f, 1.2f, 1.1f, 1.0f, 0.8f, }; -void EnFishing_DrawSinkingLure(GlobalContext* globalCtx) { +void EnFishing_DrawSinkingLure(PlayState* play) { s16 i; f32 scale; - OPEN_DISPS(globalCtx->state.gfxCtx); + OPEN_DISPS(play->state.gfxCtx); - EnFishing_UpdateSinkingLure(globalCtx); + EnFishing_UpdateSinkingLure(play); - if (sLurePos.y < WATER_SURFACE_Y(globalCtx)) { - func_8012C28C(globalCtx->state.gfxCtx); + if (sLurePos.y < WATER_SURFACE_Y(play)) { + func_8012C28C(play->state.gfxCtx); gSPDisplayList(POLY_OPA_DISP++, gFishingSinkingLureSegmentSetupDL); for (i = SINKING_LURE_SEG_COUNT - 1; i >= 0; i--) { if ((i + D_80911F20) < SINKING_LURE_SEG_COUNT) { - Matrix_InsertTranslation(sSinkingLurePos[i].x, sSinkingLurePos[i].y, sSinkingLurePos[i].z, MTXMODE_NEW); + 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(&play->billboardMtxF); - gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_OPA_DISP++, gFishingSinkingLureSegmentVtxDL); } } } else { - func_8012C2DC(globalCtx->state.gfxCtx); + func_8012C2DC(play->state.gfxCtx); gSPDisplayList(POLY_XLU_DISP++, gFishingSinkingLureSegmentSetupDL); for (i = SINKING_LURE_SEG_COUNT - 1; i >= 0; i--) { if ((i + D_80911F20) < SINKING_LURE_SEG_COUNT) { - Matrix_InsertTranslation(sSinkingLurePos[i].x, sSinkingLurePos[i].y, sSinkingLurePos[i].z, MTXMODE_NEW); + 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(&play->billboardMtxF); - gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_XLU_DISP++, gFishingSinkingLureSegmentVtxDL); } } } - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->state.gfxCtx); } -void EnFishing_DrawLureAndLine(GlobalContext* globalCtx, Vec3f* linePos, Vec3f* lineRot) { +void EnFishing_DrawLureAndLine(PlayState* play, Vec3f* linePos, Vec3f* lineRot) { Vec3f posSrc; Vec3f posStep; Vec3f hookPos[2]; s32 i; s32 spB4 = D_809101C0; s32 pad; - Player* player = GET_PLAYER(globalCtx); + Player* player = GET_PLAYER(play); - OPEN_DISPS(globalCtx->state.gfxCtx); + OPEN_DISPS(play->state.gfxCtx); - func_8012C28C(globalCtx->state.gfxCtx); - Matrix_StatePush(); + func_8012C28C(play->state.gfxCtx); + Matrix_Push(); if (D_8090CD54 != 0) { Vec3f posTemp = sLurePos; sLurePos = sSinkingLureBasePos; - EnFishing_DrawSinkingLure(globalCtx); + EnFishing_DrawSinkingLure(play); sLurePos = posTemp; } @@ -1778,11 +1771,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; } @@ -1798,33 +1791,33 @@ 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); + func_8012C28C(play->state.gfxCtx); - gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_OPA_DISP++, gFishingLureFloatDL); posSrc.x = -850.0f; posSrc.y = 0.0f; posSrc.z = 0.0f; - Matrix_MultiplyVector3fByState(&posSrc, &D_80917218); + Matrix_MultVec3f(&posSrc, &D_80917218); posSrc.x = 500.0f; posSrc.z = -300.0f; - Matrix_MultiplyVector3fByState(&posSrc, &hookPos[0]); - EnFishing_DrawLureHook(globalCtx, &hookPos[0], &sLureHookRefPos[0], 0); + Matrix_MultVec3f(&posSrc, &hookPos[0]); + EnFishing_DrawLureHook(play, &hookPos[0], &sLureHookRefPos[0], 0); posSrc.x = 2100.0f; posSrc.z = -50.0f; - Matrix_MultiplyVector3fByState(&posSrc, &hookPos[1]); - EnFishing_DrawLureHook(globalCtx, &hookPos[1], &sLureHookRefPos[1], 1); + Matrix_MultVec3f(&posSrc, &hookPos[1]); + EnFishing_DrawLureHook(play, &hookPos[1], &sLureHookRefPos[1], 1); } POLY_XLU_DISP = Gfx_CallSetupDL(POLY_XLU_DISP, 0x14); @@ -1850,12 +1843,12 @@ 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); + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_XLU_DISP++, gFishingLineVtxDL); } else { for (i = spB4; i < LINE_SEG_COUNT - 1; i++) { @@ -1877,32 +1870,31 @@ 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), + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_XLU_DISP++, gFishingLineVtxDL); break; } - Matrix_InsertTranslation((linePos + i)->x, (linePos + i)->y, (linePos + i)->z, MTXMODE_NEW); - Matrix_InsertYRotation_f((lineRot + i)->y, MTXMODE_APPLY); - Matrix_RotateStateAroundXAxis((lineRot + i)->x); + Matrix_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), - G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_XLU_DISP++, gFishingLineVtxDL); } } - Matrix_StatePop(); - func_8012C2DC(globalCtx->state.gfxCtx); + Matrix_Pop(); + func_8012C2DC(play->state.gfxCtx); - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->state.gfxCtx); } f32 sRodScales[22] = { @@ -1918,16 +1910,16 @@ f32 sRodBendRatios[22] = { Vec3f sRodTipOffset = { 0.0f, 0.0f, 0.0f }; -void EnFishing_DrawRod(GlobalContext* globalCtx) { +void EnFishing_DrawRod(PlayState* play) { s16 i; f32 spC8; f32 spC4; f32 spC0; - Input* input = CONTROLLER1(globalCtx); - Player* player = GET_PLAYER(globalCtx); + Input* input = CONTROLLER1(&play->state); + Player* player = GET_PLAYER(play); s32 pad; - OPEN_DISPS(globalCtx->state.gfxCtx); + OPEN_DISPS(play->state.gfxCtx); if (D_80911E28 != 0) { D_80911E28--; @@ -1995,43 +1987,43 @@ void EnFishing_DrawRod(GlobalContext* globalCtx) { } } - func_8012C28C(globalCtx->state.gfxCtx); + func_8012C28C(play->state.gfxCtx); gSPDisplayList(POLY_OPA_DISP++, gFishingRodSetupDL); 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); + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); if (i < 5) { gDPLoadTextureBlock(POLY_OPA_DISP++, &gFishingRodSegmentBlackTex, G_IM_FMT_RGBA, G_IM_SIZ_16b, 16, 8, 0, @@ -2046,20 +2038,20 @@ 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); + CLOSE_DISPS(play->state.gfxCtx); } Vec3f D_8090D614 = { 0.0f, 0.0f, 0.0f }; -void EnFishing_UpdateLure(EnFishing* this, GlobalContext* globalCtx) { +void EnFishing_UpdateLure(EnFishing* this, PlayState* play) { f32 spE4; f32 spE0; s16 i; @@ -2070,12 +2062,12 @@ void EnFishing_UpdateLure(EnFishing* this, GlobalContext* globalCtx) { f32 phi_f16; f32 spC8; f32 phi_f0; - Player* player = GET_PLAYER(globalCtx); + Player* player = GET_PLAYER(play); Vec3f zeroVec = { 0.0f, 0.0f, 0.0f }; Vec3f spA8; Vec3f sp9C; Vec3f sp90; - Input* input = CONTROLLER1(globalCtx); + Input* input = CONTROLLER1(&play->state); D_809171FE++; @@ -2144,7 +2136,7 @@ void EnFishing_UpdateLure(EnFishing* this, GlobalContext* globalCtx) { } } - SkinMatrix_Vec3fMtxFMultXYZW(&globalCtx->viewProjectionMtxF, &sLurePos, &D_8090D614, &sProjectedW); + SkinMatrix_Vec3fMtxFMultXYZW(&play->viewProjectionMtxF, &sLurePos, &D_8090D614, &sProjectedW); if (D_8090CD14 == 0) { Math_ApproachF(&D_80917258, -800.0f, 1.0f, 20.0f); @@ -2166,7 +2158,7 @@ void EnFishing_UpdateLure(EnFishing* this, GlobalContext* globalCtx) { if (D_80917204 == 0) { if ((D_80917200 == 0) && (player->unk_B28 == 1)) { D_80917204 = 37; - func_801477B4(globalCtx); + func_801477B4(play); } } else { sLureRot.x = sReelLineRot[LINE_SEG_COUNT - 2].x + M_PI; @@ -2175,11 +2167,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; @@ -2237,7 +2229,7 @@ void EnFishing_UpdateLure(EnFishing* this, GlobalContext* globalCtx) { Vec3f sp80 = this->actor.world.pos; this->actor.prevPos = this->actor.world.pos = sLurePos; - Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 15.0f, 30.0f, 30.0f, 0x43); + Actor_UpdateBgCheckInfo(play, &this->actor, 15.0f, 30.0f, 30.0f, 0x43); this->actor.world.pos = sp80; if (this->actor.bgCheckFlags & 0x10) { @@ -2256,7 +2248,7 @@ void EnFishing_UpdateLure(EnFishing* this, GlobalContext* globalCtx) { } } - spE0 = ((sqrtf(spC8) - 920.0f) * 0.11f) + WATER_SURFACE_Y(globalCtx); + spE0 = ((sqrtf(spC8) - 920.0f) * 0.11f) + WATER_SURFACE_Y(play); if (sLurePos.y <= spE0) { sLurePos.y = spE0; D_80917238.x = D_80917238.y = D_80917238.z = 0.0f; @@ -2268,7 +2260,7 @@ void EnFishing_UpdateLure(EnFishing* this, GlobalContext* globalCtx) { NA_SE_EN_WIZ_UNARI - SFX_FLAG); // changed from NA_SE_EN_FANTOM_FLOAT in OoT } } else { - f32 sp7C = WATER_SURFACE_Y(globalCtx); + f32 sp7C = WATER_SURFACE_Y(play); f32 sp78; if (sLurePos.y <= sp7C) { @@ -2282,7 +2274,7 @@ void EnFishing_UpdateLure(EnFishing* this, GlobalContext* globalCtx) { D_809171F2 = 10; } - if ((sLurePos.y <= sp7C) && (sp7C < spE0) && (sp7C == WATER_SURFACE_Y(globalCtx))) { + if ((sLurePos.y <= sp7C) && (sp7C < spE0) && (sp7C == WATER_SURFACE_Y(play))) { D_80917264 = 10; Audio_PlaySfxAtPos(&D_8090D614, NA_SE_EV_BOMB_DROP_WATER); D_80917248.y = 0.0f; @@ -2292,21 +2284,21 @@ 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; spA8.x += (sp9C.x * 3.0f); - spA8.y = WATER_SURFACE_Y(globalCtx); + spA8.y = WATER_SURFACE_Y(play); spA8.z += (sp9C.z * 3.0f); - EnFishing_SpawnDustSplash(NULL, globalCtx->specialEffects, &spA8, &sp9C, + EnFishing_SpawnDustSplash(NULL, play->specialEffects, &spA8, &sp9C, Rand_ZeroFloat(0.02f) + 0.025f); } spA8 = sLurePos; - spA8.y = WATER_SURFACE_Y(globalCtx); - EnFishing_SpawnRipple(NULL, globalCtx->specialEffects, &spA8, 100.0f, 800.0f, 150, 90); + spA8.y = WATER_SURFACE_Y(play); + EnFishing_SpawnRipple(NULL, play->specialEffects, &spA8, 100.0f, 800.0f, 150, 90); } } else { Math_ApproachZeroF(&D_809101C4, 1.0f, 0.05f); @@ -2324,13 +2316,13 @@ void EnFishing_UpdateLure(EnFishing* this, GlobalContext* globalCtx) { break; case 2: - if (sLurePos.y <= WATER_SURFACE_Y(globalCtx)) { + if (sLurePos.y <= WATER_SURFACE_Y(play)) { sLurePos.y += D_80917238.y; Math_ApproachZeroF(&D_80917238.y, 1.0f, 1.0f); if (D_80917206 != 2) { - Math_ApproachF(&sLurePos.y, WATER_SURFACE_Y(globalCtx), 0.5f, 1.0f); + Math_ApproachF(&sLurePos.y, WATER_SURFACE_Y(play), 0.5f, 1.0f); } } @@ -2367,7 +2359,7 @@ void EnFishing_UpdateLure(EnFishing* this, GlobalContext* globalCtx) { } spDC = 0x4000; - spE4 = WATER_SURFACE_Y(globalCtx); + spE4 = WATER_SURFACE_Y(play); spC8 = SQ(sLurePos.x) + SQ(sLurePos.z); if (spC8 < SQ(920.0f)) { @@ -2443,7 +2435,7 @@ void EnFishing_UpdateLure(EnFishing* this, GlobalContext* globalCtx) { } } } else { - spE4 = ((sqrtf(spC8) - 920.0f) * 0.11f) + WATER_SURFACE_Y(globalCtx); + spE4 = ((sqrtf(spC8) - 920.0f) * 0.11f) + WATER_SURFACE_Y(play); if (sLurePos.y <= spE4) { sLurePos.y = spE4; spDC = 0x500; @@ -2471,17 +2463,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) { 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; } @@ -2495,13 +2487,13 @@ void EnFishing_UpdateLure(EnFishing* this, GlobalContext* globalCtx) { } else { D_80917254 = -0.5f; } - } else if (sReelLinePos[LINE_SEG_COUNT - 1].y < (WATER_SURFACE_Y(globalCtx) + phi_f0)) { + } else if (sReelLinePos[LINE_SEG_COUNT - 1].y < (WATER_SURFACE_Y(play) + phi_f0)) { if (D_80917206 == 2) { 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); + Actor_UpdateBgCheckInfo(play, &this->actor, 15.0f, 30.0f, 30.0f, 0x44); this->actor.world.pos = sp58; D_80917278.y += -0.5f; @@ -2516,7 +2508,7 @@ void EnFishing_UpdateLure(EnFishing* this, GlobalContext* globalCtx) { D_80917270 = 1; } } else { - D_80917278.y = fabsf(sReelLinePos[LINE_SEG_COUNT - 1].y - WATER_SURFACE_Y(globalCtx)) * 0.2f; + D_80917278.y = fabsf(sReelLinePos[LINE_SEG_COUNT - 1].y - WATER_SURFACE_Y(play)) * 0.2f; if (D_80917278.y > 1.5f) { D_80917278.y = 1.5f; } @@ -2544,7 +2536,7 @@ void EnFishing_UpdateLure(EnFishing* this, GlobalContext* globalCtx) { Math_ApproachF(&D_809101D0, 1000.0f, 1.0f, 0.2f); } - if (sReelLinePos[LINE_SEG_COUNT - 1].y > (WATER_SURFACE_Y(globalCtx) + 4.0f)) { + if (sReelLinePos[LINE_SEG_COUNT - 1].y > (WATER_SURFACE_Y(play) + 4.0f)) { Math_ApproachF(&D_809101C4, 3.0f, 1.0f, 0.2f); } else { Math_ApproachF(&D_809101C4, 1.0f, 1.0f, 0.2f); @@ -2570,8 +2562,7 @@ void EnFishing_UpdateLure(EnFishing* this, GlobalContext* globalCtx) { D_8090CD4C = 3; } - if ((sLurePos.y <= (WATER_SURFACE_Y(globalCtx) + 4.0f)) && - (sLurePos.y >= (WATER_SURFACE_Y(globalCtx) - 4.0f))) { + if ((sLurePos.y <= (WATER_SURFACE_Y(play) + 4.0f)) && (sLurePos.y >= (WATER_SURFACE_Y(play) - 4.0f))) { s8 phi_v0 = 63; if (CHECK_BTN_ALL(input->cur.button, BTN_A) || (D_809101B4 > 1.0f)) { @@ -2580,8 +2571,8 @@ void EnFishing_UpdateLure(EnFishing* this, GlobalContext* globalCtx) { if ((D_809171FE & phi_v0) == 0) { spA8 = sLurePos; - spA8.y = WATER_SURFACE_Y(globalCtx); - EnFishing_SpawnRipple(NULL, globalCtx->specialEffects, &spA8, 30.0f, 300.0f, 150, 90); + spA8.y = WATER_SURFACE_Y(play); + EnFishing_SpawnRipple(NULL, play->specialEffects, &spA8, 30.0f, 300.0f, 150, 90); } } } break; // must be outside of the block @@ -2620,7 +2611,7 @@ void EnFishing_UpdateLure(EnFishing* this, GlobalContext* globalCtx) { } } -s32 func_809033F0(EnFishing* this, GlobalContext* globalCtx, u8 ignorePosCheck) { +s32 func_809033F0(EnFishing* this, PlayState* play, u8 ignorePosCheck) { s16 i; s16 count; f32 scale; @@ -2629,7 +2620,7 @@ s32 func_809033F0(EnFishing* this, GlobalContext* globalCtx, u8 ignorePosCheck) f32 speedXZ; f32 angle; - if ((this->actor.world.pos.y < (WATER_SURFACE_Y(globalCtx) - 10.0f)) && !ignorePosCheck) { + if ((this->actor.world.pos.y < (WATER_SURFACE_Y(play) - 10.0f)) && !ignorePosCheck) { return false; } @@ -2648,30 +2639,30 @@ 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; pos.x += vel.x * 3.0f; - pos.y = WATER_SURFACE_Y(globalCtx); + pos.y = WATER_SURFACE_Y(play); pos.z += vel.z * 3.0f; - EnFishing_SpawnDustSplash(&this->actor.projectedPos, globalCtx->specialEffects, &pos, &vel, + EnFishing_SpawnDustSplash(&this->actor.projectedPos, play->specialEffects, &pos, &vel, (Rand_ZeroFloat(0.02f) + 0.025f) * scale); } pos = this->actor.world.pos; - pos.y = WATER_SURFACE_Y(globalCtx); + pos.y = WATER_SURFACE_Y(play); - EnFishing_SpawnRipple(&this->actor.projectedPos, globalCtx->specialEffects, &pos, 100.0f, 800.0f, 150, 90); + EnFishing_SpawnRipple(&this->actor.projectedPos, play->specialEffects, &pos, 100.0f, 800.0f, 150, 90); this->unk_149 = 30; return true; } -void func_809036BC(EnFishing* this, GlobalContext* globalCtx) { +void func_809036BC(EnFishing* this, PlayState* play) { s16 count; s16 i; f32 scale; @@ -2695,8 +2686,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; @@ -2704,7 +2695,7 @@ void func_809036BC(EnFishing* this, GlobalContext* globalCtx) { pos.y += (vel.y * 3.0f); pos.z += (vel.z * 3.0f); - EnFishing_SpawnDustSplash(&this->actor.projectedPos, globalCtx->specialEffects, &pos, &vel, + EnFishing_SpawnDustSplash(&this->actor.projectedPos, play->specialEffects, &pos, &vel, (Rand_ZeroFloat(0.02f) + 0.025f) * scale); } } @@ -2721,8 +2712,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))) { @@ -2799,7 +2790,7 @@ void func_80903C60(EnFishing* this, u8 arg1) { Actor_PlaySfxAtPos(&this->actor, sfxId); } -void EnFishing_HandleAquariumDialog(EnFishing* this, GlobalContext* globalCtx) { +void EnFishing_HandleAquariumDialog(EnFishing* this, PlayState* play) { if (sLinkAge == 1) { if (gSaveContext.save.unk_EE4 & 0x7F) { if (gSaveContext.save.unk_EE4 & 0x80) { @@ -2824,23 +2815,23 @@ void EnFishing_HandleAquariumDialog(EnFishing* this, GlobalContext* globalCtx) { if (this->unk_1CC == 0) { this->actor.flags |= ACTOR_FLAG_1; - if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { + if (Actor_ProcessTalkRequest(&this->actor, &play->state)) { D_8090CCF8 = D_809171CC; this->unk_1CB = 1; } else { - func_800B863C(&this->actor, globalCtx); + func_800B863C(&this->actor, play); } } else { this->unk_1CC--; this->actor.flags &= ~ACTOR_FLAG_1; } - } else if (Actor_TextboxIsClosing(&this->actor, globalCtx)) { + } else if (Actor_TextboxIsClosing(&this->actor, play)) { this->unk_1CB = 0; this->unk_1CC = 20; } } -void EnFishing_UpdateFish(Actor* thisx, GlobalContext* globalCtx2) { +void EnFishing_UpdateFish(Actor* thisx, PlayState* play2) { s16 i; s16 sp134 = 10; f32 sp130; @@ -2862,9 +2853,9 @@ void EnFishing_UpdateFish(Actor* thisx, GlobalContext* globalCtx2) { s16 spF0; s16 spEE; EnFishing* this = THIS; - GlobalContext* globalCtx = globalCtx2; - Player* player = GET_PLAYER(globalCtx); - Input* input = CONTROLLER1(globalCtx); + PlayState* play = play2; + Player* player = GET_PLAYER(play); + Input* input = CONTROLLER1(&play->state); f32 spD8; f32 phi_f0; f32 phi_f2; @@ -2883,7 +2874,7 @@ void EnFishing_UpdateFish(Actor* thisx, GlobalContext* globalCtx2) { sp118 = (player->actor.speedXZ * 0.3f) + 0.25f; } - if ((D_80917200 != 0) || (sCameraId != CAM_ID_MAIN) || + if ((D_80917200 != 0) || (sSubCamId != SUB_CAM_ID_DONE) || ((player->actor.world.pos.z > 1150.0f) && (this->unk_150 != 100))) { this->actor.flags &= ~ACTOR_FLAG_1; } else { @@ -2931,7 +2922,7 @@ void EnFishing_UpdateFish(Actor* thisx, GlobalContext* globalCtx2) { } else { phi_f0 = 1.0f; phi_f2 = 1.0f; - if (this->actor.world.pos.y > WATER_SURFACE_Y(globalCtx)) { + if (this->actor.world.pos.y > WATER_SURFACE_Y(play)) { phi_f0 = 1.5f; phi_f2 = 3.0f; } @@ -2945,10 +2936,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); @@ -2959,11 +2950,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; } @@ -2992,7 +2983,7 @@ void EnFishing_UpdateFish(Actor* thisx, GlobalContext* globalCtx2) { switch (this->unk_150) { case 100: - EnFishing_HandleAquariumDialog(this, globalCtx); + EnFishing_HandleAquariumDialog(this, play); this->actor.uncullZoneForward = 500.0f; this->actor.uncullZoneScale = 300.0f; @@ -3001,8 +2992,8 @@ void EnFishing_UpdateFish(Actor* thisx, GlobalContext* globalCtx2) { this->actor.world.pos.z - 50.0f, 255, 255, 255, 255); this->unk_1A4 = D_809171CC; - sp100.y = Math_SinS(globalCtx->gameplayFrames * 300); - sp100.z = Math_SinS(globalCtx->gameplayFrames * 230) * 2.0f; + sp100.y = Math_SinS(play->gameplayFrames * 300); + sp100.z = Math_SinS(play->gameplayFrames * 230) * 2.0f; this->actor.world.pos.x = 130.0f; this->actor.world.pos.y = 55.0f + sp100.y; this->actor.world.pos.z = 1300.0f + sp100.z; @@ -3012,7 +3003,7 @@ void EnFishing_UpdateFish(Actor* thisx, GlobalContext* globalCtx2) { spC4.x = randPlusMinusPoint5Scaled(5.0f) + 130.0f; spC4.y = 40.0f; spC4.z = randPlusMinusPoint5Scaled(5.0f) + 1280.0f; - EnFishing_SpawnBubble(NULL, globalCtx->specialEffects, &spC4, Rand_ZeroFloat(0.02f) + 0.03f, 1); + EnFishing_SpawnBubble(NULL, play->specialEffects, &spC4, Rand_ZeroFloat(0.02f) + 0.03f, 1); } Math_ApproachS(&this->unk_16A, (Math_SinS(this->unk_154 * 0x800) * 2500.0f) + 2500.0f, 2, 0x7D0); @@ -3064,7 +3055,7 @@ void EnFishing_UpdateFish(Actor* thisx, GlobalContext* globalCtx2) { this->unk_172[1] = 50; } - if (Message_GetState(&globalCtx->msgCtx) == 0) { + if (Message_GetState(&play->msgCtx) == TEXT_STATE_NONE) { if ((gSaveContext.save.time >= CLOCK_TIME(18, 0)) && (gSaveContext.save.time <= 0xC01B)) { this->unk_150 = 7; this->unk_172[3] = Rand_ZeroFloat(150.0f) + 200.0f; @@ -3087,7 +3078,7 @@ void EnFishing_UpdateFish(Actor* thisx, GlobalContext* globalCtx2) { this->unk_150 = 1; this->unk_172[0] = Rand_ZeroFloat(30.0f) + 10.0f; this->unk_1AC.x = randPlusMinusPoint5Scaled(300.0f); - this->unk_1AC.y = (WATER_SURFACE_Y(globalCtx) - 50.0f) - Rand_ZeroFloat(50.0f); + this->unk_1AC.y = (WATER_SURFACE_Y(play) - 50.0f) - Rand_ZeroFloat(50.0f); this->unk_1AC.z = randPlusMinusPoint5Scaled(300.0f); this->unk_188 = 1.0f; this->unk_18C = 2000.0f; @@ -3149,7 +3140,7 @@ void EnFishing_UpdateFish(Actor* thisx, GlobalContext* globalCtx2) { this->unk_18C = 4000.0f; Math_ApproachF(&this->unk_1A8, 4096.0f, 1.0f, 256.0f); - if ((globalCtx->gameplayFrames % 32) == 0) { + if ((play->gameplayFrames % 32) == 0) { this->unk_1AC.x = randPlusMinusPoint5Scaled(600.0f); this->unk_1AC.z = randPlusMinusPoint5Scaled(600.0f); this->unk_1AC.y = -120.0f; @@ -3172,7 +3163,7 @@ void EnFishing_UpdateFish(Actor* thisx, GlobalContext* globalCtx2) { } else if (((this->unk_19C & 0x7FF) == 0) && (this->unk_19C < 15000)) { this->unk_150 = -2; this->actor.world.rot.x = this->actor.shape.rot.x = 0; - this->unk_1AC.y = WATER_SURFACE_Y(globalCtx) + 10.0f; + this->unk_1AC.y = WATER_SURFACE_Y(play) + 10.0f; this->unk_1AC.x = Rand_ZeroFloat(50.0f); this->unk_1AC.z = Rand_ZeroFloat(50.0f); } @@ -3190,13 +3181,12 @@ void EnFishing_UpdateFish(Actor* thisx, GlobalContext* globalCtx2) { Math_ApproachS(&this->unk_15E, -0x1000, 0x14, 0x100); - if (this->actor.world.pos.y < (WATER_SURFACE_Y(globalCtx) - 20.0f)) { + if (this->actor.world.pos.y < (WATER_SURFACE_Y(play) - 20.0f)) { Math_ApproachF(&this->actor.speedXZ, 0.5f, 1.0f, 0.1f); } else { Math_ApproachZeroF(&this->actor.speedXZ, 1.0f, 0.01f); - if ((this->actor.speedXZ == 0.0f) || - (this->actor.world.pos.y > (WATER_SURFACE_Y(globalCtx) - 5.0f))) { + if ((this->actor.speedXZ == 0.0f) || (this->actor.world.pos.y > (WATER_SURFACE_Y(play) - 5.0f))) { this->unk_1AC.x = Rand_ZeroFloat(300.0f); this->unk_1AC.z = Rand_ZeroFloat(300.0f); this->unk_1AC.y = this->actor.floorHeight + 10.0f; @@ -3204,11 +3194,11 @@ void EnFishing_UpdateFish(Actor* thisx, GlobalContext* globalCtx2) { this->unk_1A8 = 0.0f; spB8 = this->fishMouthPos; - spB8.y = WATER_SURFACE_Y(globalCtx); - EnFishing_SpawnRipple(&this->actor.projectedPos, globalCtx->specialEffects, &spB8, 10.0f, - 300.0f, 150, 90); - EnFishing_SpawnRipple(&this->actor.projectedPos, globalCtx->specialEffects, &spB8, 30.0f, - 400.0f, 150, 90); + spB8.y = WATER_SURFACE_Y(play); + EnFishing_SpawnRipple(&this->actor.projectedPos, play->specialEffects, &spB8, 10.0f, 300.0f, + 150, 90); + EnFishing_SpawnRipple(&this->actor.projectedPos, play->specialEffects, &spB8, 30.0f, 400.0f, + 150, 90); Actor_PlaySfxAtPos(&this->actor, NA_SE_PL_CATCH_BOOMERANG); break; @@ -3246,8 +3236,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; @@ -3378,8 +3368,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; @@ -3387,7 +3377,7 @@ void EnFishing_UpdateFish(Actor* thisx, GlobalContext* globalCtx2) { this->unk_1A8 = 4096.0f; Math_ApproachF(&this->actor.speedXZ, this->unk_180 * 0.8f, 1.0f, 1.0f); - if ((D_8090CD14 != 3) || (sLurePos.y > (WATER_SURFACE_Y(globalCtx) + 5.0f)) || + if ((D_8090CD14 != 3) || (sLurePos.y > (WATER_SURFACE_Y(play) + 5.0f)) || (sqrtf(SQ(sLurePos.x) + SQ(sLurePos.z)) > 800.0f)) { this->unk_150 = this->unk_152; this->unk_172[0] = 0; @@ -3412,7 +3402,7 @@ void EnFishing_UpdateFish(Actor* thisx, GlobalContext* globalCtx2) { this->unk_1AC = sLurePos; Math_ApproachF(&this->actor.speedXZ, this->unk_180, 1.0f, 1.0f); - if ((D_8090CD14 != 3) || (this->unk_172[0] == 0) || (sLurePos.y > (WATER_SURFACE_Y(globalCtx) + 5.0f)) || + if ((D_8090CD14 != 3) || (this->unk_172[0] == 0) || (sLurePos.y > (WATER_SURFACE_Y(play) + 5.0f)) || (sqrtf(SQ(sLurePos.x) + SQ(sLurePos.z)) > 800.0f)) { this->unk_172[0] = 0; @@ -3422,7 +3412,7 @@ void EnFishing_UpdateFish(Actor* thisx, GlobalContext* globalCtx2) { } else if (sp124 < 10.0f) { s16 phi_v0; - if (func_809033F0(this, globalCtx, false)) { + if (func_809033F0(this, play, false)) { func_80903C60(this, 0); } @@ -3450,7 +3440,7 @@ void EnFishing_UpdateFish(Actor* thisx, GlobalContext* globalCtx2) { } D_80917272 = phi_v0; D_809171F4 = phi_v0; - func_8013EC44(0.0f, 60, phi_v0 * 3, 10); + Rumble_Override(0.0f, 60, phi_v0 * 3, 10); } else { if (this->unk_1A4 > 70.0f) { phi_v0 = Rand_ZeroFloat(5.0f) + 10.0f; @@ -3463,7 +3453,7 @@ void EnFishing_UpdateFish(Actor* thisx, GlobalContext* globalCtx2) { } D_80917272 = phi_v0; D_809171F4 = phi_v0; - func_8013EC44(0.0f, 180, phi_v0 * 3, 10); + Rumble_Override(0.0f, 180, phi_v0 * 3, 10); } D_80917274 = 0; @@ -3477,7 +3467,7 @@ void EnFishing_UpdateFish(Actor* thisx, GlobalContext* globalCtx2) { this->unk_1AC = sLurePos; Math_ApproachF(&this->actor.speedXZ, 2.0f, 1.0f, 1.0f); - if ((D_8090CD14 != 3) || (this->unk_172[0] == 0) || (sLurePos.y > (WATER_SURFACE_Y(globalCtx) + 5.0f)) || + if ((D_8090CD14 != 3) || (this->unk_172[0] == 0) || (sLurePos.y > (WATER_SURFACE_Y(play) + 5.0f)) || (sqrtf(SQ(sLurePos.x) + SQ(sLurePos.z)) > 800.0f)) { this->unk_172[0] = 0; @@ -3485,12 +3475,12 @@ void EnFishing_UpdateFish(Actor* thisx, GlobalContext* globalCtx2) { this->unk_150 = this->unk_152; this->unk_18C = 2000.0f; } else if (sp124 < 10.0f) { - if (sLurePos.y > (WATER_SURFACE_Y(globalCtx) - 10.0f)) { + if (sLurePos.y > (WATER_SURFACE_Y(play) - 10.0f)) { Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_JUMP_OUT_WATER); play_sound(NA_SE_PL_CATCH_BOOMERANG); } - func_809033F0(this, globalCtx, false); + func_809033F0(this, play, false); this->unk_150 = 5; this->unk_188 = 1.2f; this->unk_18C = 5000.0f; @@ -3505,11 +3495,11 @@ void EnFishing_UpdateFish(Actor* thisx, GlobalContext* globalCtx2) { if (D_80917206 == 2) { D_80917272 = 30; D_809171F4 = 100; - func_8013EC44(0.0f, 60, 90, 10); + Rumble_Override(0.0f, 60, 90, 10); } else { D_80917272 = 30; D_809171F4 = 40; - func_8013EC44(0.0f, 180, 90, 10); + Rumble_Override(0.0f, 180, 90, 10); } D_80917274 = 0; @@ -3560,14 +3550,14 @@ void EnFishing_UpdateFish(Actor* thisx, GlobalContext* globalCtx2) { temp2 = 255.0f; } - func_8013EC44(0.0f, temp2, 120, 5); + Rumble_Override(0.0f, temp2, 120, 5); D_809171F4 = 40; D_80911E28 = 10; play_sound(NA_SE_IT_FISHING_HIT); } } - if (this->actor.world.pos.y < WATER_SURFACE_Y(globalCtx)) { + if (this->actor.world.pos.y < WATER_SURFACE_Y(play)) { u8 phi_v0_2; f32 spA4; @@ -3594,7 +3584,7 @@ void EnFishing_UpdateFish(Actor* thisx, GlobalContext* globalCtx2) { spA4 *= 3.0f / 4.0f; } - func_8013EC44(0.0f, spA4, Rand_ZeroFloat(5.0f) + 10.0f, 5); + Rumble_Override(0.0f, spA4, Rand_ZeroFloat(5.0f) + 10.0f, 5); } if (this->unk_172[1] > 30) { @@ -3607,10 +3597,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; @@ -3630,7 +3620,7 @@ void EnFishing_UpdateFish(Actor* thisx, GlobalContext* globalCtx2) { } else { phi_a1 = 180; } - func_8013EC44(0.0f, phi_a1, 90, 2); + Rumble_Override(0.0f, phi_a1, 90, 2); this->unk_172[0] = 20; this->unk_172[1] = 100; this->unk_172[2] = 20; @@ -3758,7 +3748,7 @@ void EnFishing_UpdateFish(Actor* thisx, GlobalContext* globalCtx2) { } } else { // Assignment of OoT's D_80B7E086 here removed in MM - func_8013EC44(0.0f, 1, 3, 1); + Rumble_Override(0.0f, 1, 3, 1); Audio_QueueSeqCmd(0x100A00FF); } @@ -3781,9 +3771,9 @@ void EnFishing_UpdateFish(Actor* thisx, GlobalContext* globalCtx2) { this->unk_150 = 6; this->unk_172[0] = 100; player->unk_B28 = 3; - func_8013EC44(0.0f, 1, 3, 1); + Rumble_Override(0.0f, 1, 3, 1); D_809171D8++; - Cutscene_Start(globalCtx, &globalCtx->csCtx); + Cutscene_Start(play, &play->csCtx); D_8090CD4C = 100; D_80911F48 = 45.0f; D_8090CD14 = 5; @@ -3791,9 +3781,9 @@ void EnFishing_UpdateFish(Actor* thisx, GlobalContext* globalCtx2) { this->unk_18C = 500.0f; this->unk_194 = 5000.0f; - if (this->actor.world.pos.y <= WATER_SURFACE_Y(globalCtx)) { + if (this->actor.world.pos.y <= WATER_SURFACE_Y(play)) { func_80903C60(this, 1); - func_809033F0(this, globalCtx, true); + func_809033F0(this, play, true); } goto case_6; } @@ -3812,18 +3802,18 @@ 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, &sSubCamEye); - sCameraEye.x += player->actor.world.pos.x; - sCameraEye.y += player->actor.world.pos.y; - sCameraEye.z += player->actor.world.pos.z; + sSubCamEye.x += player->actor.world.pos.x; + sSubCamEye.y += player->actor.world.pos.y; + sSubCamEye.z += player->actor.world.pos.z; - sCameraAt = player->actor.world.pos; + sSubCamAt = player->actor.world.pos; if (sLinkAge != 1) { - sCameraAt.y += 40.0f; + sSubCamAt.y += 40.0f; } else { - sCameraAt.y += 25.0f; + sSubCamAt.y += 25.0f; } if (this->unk_172[0] == 90) { @@ -3855,7 +3845,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); @@ -3865,10 +3855,11 @@ 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) == 0) { - if (Message_ShouldAdvance(globalCtx)) { - func_801477B4(globalCtx); - if (globalCtx->msgCtx.choiceIndex == 0) { + if ((Message_GetState(&play->msgCtx) == TEXT_STATE_CHOICE) || + Message_GetState(&play->msgCtx) == TEXT_STATE_NONE) { + if (Message_ShouldAdvance(play)) { + func_801477B4(play); + if (play->msgCtx.choiceIndex == 0) { if (D_8090CCF0 == 0.0f) { D_8090CCF0 = this->unk_1A4; D_809171D0 = this->unk_148; @@ -3878,7 +3869,7 @@ void EnFishing_UpdateFish(Actor* thisx, GlobalContext* globalCtx2) { ((s16)this->unk_1A4 < (s16)D_8090CCF0)) { this->unk_1CD = 1; this->unk_172[0] = 0x3C; - Message_StartTextbox(globalCtx, 0x4098, NULL); + Message_StartTextbox(play, 0x4098, NULL); } else { f32 temp1 = D_8090CCF0; s16 temp2 = D_809171D0; @@ -3896,10 +3887,11 @@ void EnFishing_UpdateFish(Actor* thisx, GlobalContext* globalCtx2) { } break; case 1: - if ((Message_GetState(&globalCtx->msgCtx) == 4) || Message_GetState(&globalCtx->msgCtx) == 0) { - if (Message_ShouldAdvance(globalCtx)) { - func_801477B4(globalCtx); - if (globalCtx->msgCtx.choiceIndex != 0) { + if ((Message_GetState(&play->msgCtx) == TEXT_STATE_CHOICE) || + Message_GetState(&play->msgCtx) == TEXT_STATE_NONE) { + if (Message_ShouldAdvance(play)) { + func_801477B4(play); + if (play->msgCtx.choiceIndex != 0) { f32 temp1 = D_8090CCF0; s16 temp2 = D_809171D0; D_8090CCF0 = this->unk_1A4; @@ -3923,14 +3915,13 @@ void EnFishing_UpdateFish(Actor* thisx, GlobalContext* globalCtx2) { this->unk_172[0] = 0; this->unk_188 = 1.0f; this->unk_18C = 2000.0f; - SkelAnime_Free(&this->skelAnime, globalCtx); + SkelAnime_Free(&this->skelAnime, play); if (this->unk_148 == 0) { - SkelAnime_InitFlex(globalCtx, &this->skelAnime, &gFishingFishSkel, &gFishingFishAnim, 0, 0, 0); + SkelAnime_InitFlex(play, &this->skelAnime, &gFishingFishSkel, &gFishingFishAnim, 0, 0, 0); Animation_MorphToLoop(&this->skelAnime, &gFishingFishAnim, 0.0f); } else { - SkelAnime_InitFlex(globalCtx, &this->skelAnime, &gFishingLoachSkel, &gFishingLoachAnim, 0, 0, - 0); + SkelAnime_InitFlex(play, &this->skelAnime, &gFishingLoachSkel, &gFishingLoachAnim, 0, 0, 0); Animation_MorphToLoop(&this->skelAnime, &gFishingLoachAnim, 0.0f); } } @@ -3964,7 +3955,7 @@ void EnFishing_UpdateFish(Actor* thisx, GlobalContext* globalCtx2) { if (sp124 < 20.0f) { Math_ApproachS(&this->unk_168, 0x4E20, 2, 0xFA0); - if ((this->unk_172[2] == 0) && func_809033F0(this, globalCtx, false)) { + if ((this->unk_172[2] == 0) && func_809033F0(this, play, false)) { func_80903C60(this, Rand_ZeroFloat(1.99f)); this->unk_172[2] = Rand_ZeroFloat(20.0f) + 20.0f; } @@ -3988,7 +3979,7 @@ void EnFishing_UpdateFish(Actor* thisx, GlobalContext* globalCtx2) { Math_ApproachS(&this->unk_16A, (Math_SinS(this->unk_154 * 0x1000) * 5000.0f) + 5000.0f, 2, 0x7D0); if (this->unk_150 != 6) { - if (this->actor.world.pos.y > WATER_SURFACE_Y(globalCtx)) { + if (this->actor.world.pos.y > WATER_SURFACE_Y(play)) { this->unk_188 = 1.5f; this->unk_18C = 5000.0f; @@ -4065,32 +4056,31 @@ void EnFishing_UpdateFish(Actor* thisx, GlobalContext* globalCtx2) { this->actor.shape.rot.y = this->actor.world.rot.y; if ((this->unk_150 != -1) && (this->unk_150 != -2) && (this->unk_150 != -25)) { - if ((this->actor.world.pos.y > WATER_SURFACE_Y(globalCtx)) && - (this->actor.prevPos.y <= WATER_SURFACE_Y(globalCtx))) { - func_809033F0(this, globalCtx, true); + if ((this->actor.world.pos.y > WATER_SURFACE_Y(play)) && (this->actor.prevPos.y <= WATER_SURFACE_Y(play))) { + func_809033F0(this, play, true); func_80903C60(this, 1); this->unk_17C = this->actor.velocity.y; this->actor.velocity.y = 0.0f; this->unk_162 = randPlusMinusPoint5Scaled(32768.0f); - } else if ((this->actor.world.pos.y < WATER_SURFACE_Y(globalCtx)) && - (this->actor.prevPos.y >= WATER_SURFACE_Y(globalCtx))) { + } else if ((this->actor.world.pos.y < WATER_SURFACE_Y(play)) && + (this->actor.prevPos.y >= WATER_SURFACE_Y(play))) { if (this->unk_17C < -5.0f) { this->unk_17C = -5.0f; } this->actor.world.rot.x = -0xFA0; - func_809033F0(this, globalCtx, true); + func_809033F0(this, play, true); this->unk_1CA = 20; func_80903C60(this, 0); } } - if ((this->actor.world.pos.y < WATER_SURFACE_Y(globalCtx)) && - (this->actor.world.pos.y > (WATER_SURFACE_Y(globalCtx) - 10.0f)) && !(this->unk_154 & 1) && + if ((this->actor.world.pos.y < WATER_SURFACE_Y(play)) && + (this->actor.world.pos.y > (WATER_SURFACE_Y(play) - 10.0f)) && !(this->unk_154 & 1) && (this->actor.speedXZ > 0.0f)) { Vec3f pos = this->actor.world.pos; - pos.y = WATER_SURFACE_Y(globalCtx); - EnFishing_SpawnRipple(&this->actor.projectedPos, globalCtx->specialEffects, &pos, 80.0f, 500.0f, 150, 90); + pos.y = WATER_SURFACE_Y(play); + EnFishing_SpawnRipple(&this->actor.projectedPos, play->specialEffects, &pos, 80.0f, 500.0f, 150, 90); } if ((this->actor.speedXZ > 0.0f) || (this->unk_150 == 5)) { @@ -4102,7 +4092,7 @@ void EnFishing_UpdateFish(Actor* thisx, GlobalContext* globalCtx2) { this->actor.prevPos.y -= spD8; this->actor.velocity.y = -1.0f; if (KREG(90) == 0) { // Check added in MM - Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 30.0f, 30.0f, 100.0f, 0x45); + Actor_UpdateBgCheckInfo(play, &this->actor, 30.0f, 30.0f, 100.0f, 0x45); } this->actor.world.pos.y += spD8; this->actor.prevPos.y += spD8; @@ -4114,13 +4104,13 @@ void EnFishing_UpdateFish(Actor* thisx, GlobalContext* globalCtx2) { } if (this->actor.bgCheckFlags & 1) { - if (this->actor.world.pos.y > WATER_SURFACE_Y(globalCtx)) { + if (this->actor.world.pos.y > WATER_SURFACE_Y(play)) { this->unk_17C = Rand_ZeroFloat(3.0f) + 3.0f; this->actor.velocity.x = this->actor.world.pos.x * -0.003f; this->actor.velocity.z = this->actor.world.pos.z * -0.003f; Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_FISH_LEAP); - func_809036BC(this, globalCtx); + func_809036BC(this, play); if (Rand_ZeroOne() < 0.5f) { this->unk_162 = 0x4000; @@ -4147,7 +4137,7 @@ void EnFishing_UpdateFish(Actor* thisx, GlobalContext* globalCtx2) { pos.x = randPlusMinusPoint5Scaled(10.0f) + this->actor.world.pos.x; pos.z = randPlusMinusPoint5Scaled(10.0f) + this->actor.world.pos.z; pos.y = this->actor.floorHeight + 5.0f; - EnFishing_SpawnWaterDust(&this->actor.projectedPos, globalCtx->specialEffects, &pos, + EnFishing_SpawnWaterDust(&this->actor.projectedPos, play->specialEffects, &pos, (this->unk_1A4 * 0.005f) + 0.15f); } } @@ -4166,14 +4156,13 @@ void EnFishing_UpdateFish(Actor* thisx, GlobalContext* globalCtx2) { pos.x = randPlusMinusPoint5Scaled(range) + this->actor.world.pos.x; pos.y = randPlusMinusPoint5Scaled(range) + this->actor.world.pos.y; pos.z = randPlusMinusPoint5Scaled(range) + this->actor.world.pos.z; - EnFishing_SpawnBubble(&this->actor.projectedPos, globalCtx->specialEffects, &pos, - Rand_ZeroFloat(0.035f) + 0.04f, 0); + EnFishing_SpawnBubble(&this->actor.projectedPos, play->specialEffects, &pos, Rand_ZeroFloat(0.035f) + 0.04f, + 0); } } } -s32 EnFishing_FishOverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, - Actor* thisx) { +s32 EnFishing_FishOverrideLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, Actor* thisx) { EnFishing* this = THIS; if (limbIndex == 13) { @@ -4195,16 +4184,15 @@ s32 EnFishing_FishOverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx* return false; } -void EnFishing_FishPostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx) { +void EnFishing_FishPostLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx) { EnFishing* this = THIS; if (limbIndex == 13) { - Matrix_MultiplyVector3fByState(&sFishMouthOffset, &this->fishMouthPos); + Matrix_MultVec3f(&sFishMouthOffset, &this->fishMouthPos); } } -s32 EnFishing_LoachOverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, - Actor* thisx) { +s32 EnFishing_LoachOverrideLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, Actor* thisx) { EnFishing* this = THIS; if (limbIndex == 3) { @@ -4218,42 +4206,40 @@ s32 EnFishing_LoachOverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx return false; } -void EnFishing_LoachPostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx) { +void EnFishing_LoachPostLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx) { static Vec3f sLoachMouthOffset = { 500.0f, 500.0f, 0.0f }; EnFishing* this = THIS; if (limbIndex == 11) { - Matrix_MultiplyVector3fByState(&sLoachMouthOffset, &this->fishMouthPos); + Matrix_MultVec3f(&sLoachMouthOffset, &this->fishMouthPos); } } -void EnFishing_DrawFish(Actor* thisx, GlobalContext* globalCtx) { +void EnFishing_DrawFish(Actor* thisx, PlayState* play) { EnFishing* this = THIS; - func_8012C28C(globalCtx->state.gfxCtx); + func_8012C28C(play->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); + SkelAnime_DrawFlexOpa(play, 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, - &this->actor); + SkelAnime_DrawFlexOpa(play, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, + EnFishing_LoachOverrideLimbDraw, EnFishing_LoachPostLimbDraw, &this->actor); } } @@ -4289,9 +4275,9 @@ void EnFishing_HandleLilyPadContact(FishingProp* prop, Vec3f* entityPos, u8 fish } } -void EnFishing_UpdatePondProps(GlobalContext* globalCtx) { +void EnFishing_UpdatePondProps(PlayState* play) { FishingProp* prop = &sPondProps[0]; - Player* player = GET_PLAYER(globalCtx); + Player* player = GET_PLAYER(play); Actor* actor; s16 i; @@ -4300,7 +4286,7 @@ void EnFishing_UpdatePondProps(GlobalContext* globalCtx) { prop->shouldDraw = false; prop->timer++; - SkinMatrix_Vec3fMtxFMultXYZW(&globalCtx->viewProjectionMtxF, &prop->pos, &prop->projectedPos, &sProjectedW); + SkinMatrix_Vec3fMtxFMultXYZW(&play->viewProjectionMtxF, &prop->pos, &prop->projectedPos, &sProjectedW); if ((prop->projectedPos.z < prop->drawDistance) && (fabsf(prop->projectedPos.x) < (100.0f + prop->projectedPos.z))) { @@ -4311,7 +4297,7 @@ void EnFishing_UpdatePondProps(GlobalContext* globalCtx) { if (prop->type == FS_PROP_REED) { EnFishing_HandleReedContact(prop, &player->actor.world.pos); - actor = globalCtx->actorCtx.actorLists[ACTORCAT_NPC].first; + actor = play->actorCtx.actorLists[ACTORCAT_NPC].first; while (actor != NULL) { if (!((actor->id == ACTOR_EN_FISHING) && (actor->params >= 100))) { actor = actor->next; @@ -4325,7 +4311,7 @@ void EnFishing_UpdatePondProps(GlobalContext* globalCtx) { } else if (prop->type == FS_PROP_LILY_PAD) { EnFishing_HandleLilyPadContact(prop, &player->actor.world.pos, 0); - actor = globalCtx->actorCtx.actorLists[ACTORCAT_NPC].first; + actor = play->actorCtx.actorLists[ACTORCAT_NPC].first; while (actor != NULL) { if (!((actor->id == ACTOR_EN_FISHING) && (actor->params >= 100))) { actor = actor->next; @@ -4337,7 +4323,7 @@ void EnFishing_UpdatePondProps(GlobalContext* globalCtx) { Math_ApproachS(&prop->lilyPadAngle, 0, 20, 80); prop->pos.y = - (Math_SinS(prop->timer * 0x1000) * prop->lilyPadOffset) + (WATER_SURFACE_Y(globalCtx) + 2.0f); + (Math_SinS(prop->timer * 0x1000) * prop->lilyPadOffset) + (WATER_SURFACE_Y(play) + 2.0f); Math_ApproachZeroF(&prop->lilyPadOffset, 0.1f, 0.02f); } } @@ -4346,20 +4332,20 @@ void EnFishing_UpdatePondProps(GlobalContext* globalCtx) { prop++; } - if (sCameraId == CAM_ID_MAIN) { - CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &sFishingMain->collider.base); + if (sSubCamId == SUB_CAM_ID_DONE) { + CollisionCheck_SetOC(play, &play->colChkCtx, &sFishingMain->collider.base); } } -void EnFishing_DrawPondProps(GlobalContext* globalCtx) { +void EnFishing_DrawPondProps(PlayState* play) { u8 flag = 0; FishingProp* prop = &sPondProps[0]; s16 i; s32 pad; - OPEN_DISPS(globalCtx->state.gfxCtx); + OPEN_DISPS(play->state.gfxCtx); - Matrix_StatePush(); + Matrix_Push(); for (i = 0; i < POND_PROP_COUNT; i++) { if (prop->type == FS_PROP_REED) { @@ -4369,13 +4355,13 @@ 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), + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_XLU_DISP++, gFishingReedVtxDL); } @@ -4394,10 +4380,10 @@ 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), + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_OPA_DISP++, gFishingWoodPostVtxDL); } @@ -4416,13 +4402,13 @@ 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), + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_XLU_DISP++, gFishingLilyPadVtxDL); } @@ -4441,11 +4427,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_RotateYF(prop->rotY, MTXMODE_APPLY); - gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_OPA_DISP++, gFishingRockVtxDL); } @@ -4454,14 +4440,14 @@ void EnFishing_DrawPondProps(GlobalContext* globalCtx) { prop++; } - Matrix_StatePop(); + Matrix_Pop(); - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->state.gfxCtx); } -void EnFishing_UpdateGroupFishes(GlobalContext* globalCtx) { +void EnFishing_UpdateGroupFishes(PlayState* play) { s16 groupContactFlags = 0; - Player* player = GET_PLAYER(globalCtx); + Player* player = GET_PLAYER(play); FishingGroupFish* fish = &sGroupFishes[0]; f32 dy; f32 dx; @@ -4487,9 +4473,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; @@ -4499,14 +4485,14 @@ void EnFishing_UpdateGroupFishes(GlobalContext* globalCtx) { groupContactFlags |= 1; } else if (D_8090CF18 != 0) { sFishGroupAngle1 += 0.05f; - basePos[0].y = WATER_SURFACE_Y(globalCtx) - 5.0f; + basePos[0].y = WATER_SURFACE_Y(play) - 5.0f; } else { 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; @@ -4516,14 +4502,14 @@ void EnFishing_UpdateGroupFishes(GlobalContext* globalCtx) { groupContactFlags |= 2; } else if (D_8090CF18 != 0) { sFishGroupAngle2 -= 0.05f; - basePos[1].y = WATER_SURFACE_Y(globalCtx) - 5.0f; + basePos[1].y = WATER_SURFACE_Y(play) - 5.0f; } else { 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; @@ -4533,7 +4519,7 @@ void EnFishing_UpdateGroupFishes(GlobalContext* globalCtx) { groupContactFlags |= 4; } else if (D_8090CF18 != 0) { sFishGroupAngle3 -= 0.05f; - basePos[2].y = WATER_SURFACE_Y(globalCtx) - 5.0f; + basePos[2].y = WATER_SURFACE_Y(play) - 5.0f; } else { Math_ApproachF(&sFishGroupAngle3, 4.6f, 1.0f, 0.001f); } @@ -4548,7 +4534,7 @@ void EnFishing_UpdateGroupFishes(GlobalContext* globalCtx) { if (fish->type != FS_GROUP_FISH_NONE) { fish->timer++; - SkinMatrix_Vec3fMtxFMultXYZW(&globalCtx->viewProjectionMtxF, &fish->pos, &fish->projectedPos, &sProjectedW); + SkinMatrix_Vec3fMtxFMultXYZW(&play->viewProjectionMtxF, &fish->pos, &fish->projectedPos, &sProjectedW); if ((fish->projectedPos.z < 400.0f) && (fabsf(fish->projectedPos.x) < (100.0f + fish->projectedPos.z))) { fish->shouldDraw = true; @@ -4586,8 +4572,8 @@ void EnFishing_UpdateGroupFishes(GlobalContext* globalCtx) { } ripplePos = fish->pos; - ripplePos.y = WATER_SURFACE_Y(globalCtx); - EnFishing_SpawnRipple(&fish->projectedPos, globalCtx->specialEffects, &ripplePos, 20.0f, + ripplePos.y = WATER_SURFACE_Y(play); + EnFishing_SpawnRipple(&fish->projectedPos, play->specialEffects, &ripplePos, 20.0f, Rand_ZeroFloat(50.0f) + 100.0f, 150, 90); if (fish->unk_28 < 1.5f) { @@ -4635,7 +4621,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; } } @@ -4645,7 +4631,7 @@ void EnFishing_UpdateGroupFishes(GlobalContext* globalCtx) { D_8090CF18 = 0; } -void EnFishing_DrawGroupFishes(GlobalContext* globalCtx) { +void EnFishing_DrawGroupFishes(PlayState* play) { u8 flag = 0; FishingGroupFish* fish = &sGroupFishes[0]; f32 scale; @@ -4658,7 +4644,7 @@ void EnFishing_DrawGroupFishes(GlobalContext* globalCtx) { scale = 0.00475f; } - OPEN_DISPS(globalCtx->state.gfxCtx); + OPEN_DISPS(play->state.gfxCtx); for (i = 0; i < GROUP_FISH_COUNT; i++) { if (fish->type != FS_GROUP_FISH_NONE) { @@ -4669,12 +4655,12 @@ 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), + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_OPA_DISP++, gFishingGroupFishVtxDL); } @@ -4682,12 +4668,12 @@ void EnFishing_DrawGroupFishes(GlobalContext* globalCtx) { fish++; } - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->state.gfxCtx); } u16 D_8090D638[] = { 0x4096, 0x408D, 0x408E, 0x408F, 0x4094, 0x4095 }; -void EnFishing_HandleOwnerDialog(EnFishing* this, GlobalContext* globalCtx) { +void EnFishing_HandleOwnerDialog(EnFishing* this, PlayState* play) { switch (this->unk_154) { case 0: if (D_809171FC == 0) { @@ -4706,7 +4692,7 @@ void EnFishing_HandleOwnerDialog(EnFishing* this, GlobalContext* globalCtx) { this->actor.textId = 0x4097; } - if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { + if (Actor_ProcessTalkRequest(&this->actor, &play->state)) { if (D_809171FC == 0) { this->unk_154 = 1; if (sLinkAge != 1) { @@ -4718,32 +4704,32 @@ void EnFishing_HandleOwnerDialog(EnFishing* this, GlobalContext* globalCtx) { this->unk_154 = 10; } } else { - func_800B8614(&this->actor, globalCtx, 100.0f); + func_800B8614(&this->actor, play, 100.0f); } break; case 1: - if ((Message_GetState(&globalCtx->msgCtx) == 4) && Message_ShouldAdvance(globalCtx)) { - func_801477B4(globalCtx); + if ((Message_GetState(&play->msgCtx) == TEXT_STATE_CHOICE) && Message_ShouldAdvance(play)) { + func_801477B4(play); - switch (globalCtx->msgCtx.choiceIndex) { + switch (play->msgCtx.choiceIndex) { case 0: if (gSaveContext.save.playerData.rupees >= 20) { - func_801159EC(-20); - if (func_8013EE04() == 0) { + Rupees_ChangeBy(-20); + if (!Rumble_ControllerOneHasRumblePak()) { this->actor.textId = 0x407C; } else { this->actor.textId = 0x407D; } - func_80151938(globalCtx, this->actor.textId); + func_80151938(play, this->actor.textId); this->unk_154 = 2; } else { - func_80151938(globalCtx, 0x407E); + func_80151938(play, 0x407E); this->unk_154 = 3; } break; case 1: - func_80151938(globalCtx, 0x2D); + func_80151938(play, 0x2D); this->unk_154 = 3; break; } @@ -4751,46 +4737,46 @@ void EnFishing_HandleOwnerDialog(EnFishing* this, GlobalContext* globalCtx) { break; case 2: - if ((Message_GetState(&globalCtx->msgCtx) == 5) && Message_ShouldAdvance(globalCtx)) { - func_801477B4(globalCtx); - func_80151938(globalCtx, 0x407F); + if ((Message_GetState(&play->msgCtx) == TEXT_STATE_5) && Message_ShouldAdvance(play)) { + func_801477B4(play); + func_80151938(play, 0x407F); this->unk_154 = 4; } break; case 3: - if ((Message_GetState(&globalCtx->msgCtx) == 5) && Message_ShouldAdvance(globalCtx)) { - func_801477B4(globalCtx); + if ((Message_GetState(&play->msgCtx) == TEXT_STATE_5) && Message_ShouldAdvance(play)) { + func_801477B4(play); this->unk_154 = 0; } - if (Message_GetState(&globalCtx->msgCtx) == 6) { + if (Message_GetState(&play->msgCtx) == TEXT_STATE_DONE) { this->unk_154 = 0; } break; case 4: - if ((Message_GetState(&globalCtx->msgCtx) == 4) && Message_ShouldAdvance(globalCtx)) { - func_801477B4(globalCtx); + if ((Message_GetState(&play->msgCtx) == TEXT_STATE_CHOICE) && Message_ShouldAdvance(play)) { + func_801477B4(play); - switch (globalCtx->msgCtx.choiceIndex) { + switch (play->msgCtx.choiceIndex) { case 0: D_8090CCF8 = D_809171CC; - func_80151938(globalCtx, 0x4080); + func_80151938(play, 0x4080); this->unk_154 = 5; break; case 1: - func_80151938(globalCtx, 0x407F); + func_80151938(play, 0x407F); break; } } break; case 5: - if ((Message_GetState(&globalCtx->msgCtx) == 5) && Message_ShouldAdvance(globalCtx)) { - func_801477B4(globalCtx); + if ((Message_GetState(&play->msgCtx) == TEXT_STATE_5) && Message_ShouldAdvance(play)) { + func_801477B4(play); - globalCtx->interfaceCtx.unk_27E = 1; - globalCtx->startPlayerFishing(globalCtx); + play->interfaceCtx.unk_27E = 1; + play->startPlayerFishing(play); D_809171FC = 1; D_8090CD04 = 20; this->unk_154 = 0; @@ -4803,12 +4789,12 @@ void EnFishing_HandleOwnerDialog(EnFishing* this, GlobalContext* globalCtx) { case 10: if (D_8090CD0C != 0) { - if ((Message_GetState(&globalCtx->msgCtx) == 4) && Message_ShouldAdvance(globalCtx)) { - func_801477B4(globalCtx); + if ((Message_GetState(&play->msgCtx) == TEXT_STATE_CHOICE) && Message_ShouldAdvance(play)) { + func_801477B4(play); - switch (globalCtx->msgCtx.choiceIndex) { + switch (play->msgCtx.choiceIndex) { case 0: - func_80151938(globalCtx, 0x40B2); + func_80151938(play, 0x40B2); D_8090CD08 = 1; D_8090CD0C = 0; this->unk_154 = 20; @@ -4819,10 +4805,10 @@ void EnFishing_HandleOwnerDialog(EnFishing* this, GlobalContext* globalCtx) { } } } else { - if ((Message_GetState(&globalCtx->msgCtx) == 4) && Message_ShouldAdvance(globalCtx)) { - func_801477B4(globalCtx); + if ((Message_GetState(&play->msgCtx) == TEXT_STATE_CHOICE) && Message_ShouldAdvance(play)) { + func_801477B4(play); - switch (globalCtx->msgCtx.choiceIndex) { + switch (play->msgCtx.choiceIndex) { case 0: if (D_8090CCF0 == 0.0f) { this->actor.textId = 0x408C; @@ -4844,12 +4830,12 @@ void EnFishing_HandleOwnerDialog(EnFishing* this, GlobalContext* globalCtx) { this->actor.textId = 0x409B; this->unk_154 = 11; } - func_80151938(globalCtx, this->actor.textId); + func_80151938(play, this->actor.textId); break; case 1: if (D_8090CD00 > 36000) { D_8090CD00 = 30000; - func_80151938(globalCtx, 0x4088); + func_80151938(play, 0x4088); } else { if (D_809171CA == 0) { if (D_809171D6 == 0) { @@ -4858,9 +4844,9 @@ void EnFishing_HandleOwnerDialog(EnFishing* this, GlobalContext* globalCtx) { } if ((D_80917206 == 2) && (D_8090D638[D_809171D6] == 0x408D)) { - func_80151938(globalCtx, 0x40AF); + func_80151938(play, 0x40AF); } else { - func_80151938(globalCtx, D_8090D638[D_809171D6]); + func_80151938(play, D_8090D638[D_809171D6]); } D_809171D6++; @@ -4879,9 +4865,9 @@ void EnFishing_HandleOwnerDialog(EnFishing* this, GlobalContext* globalCtx) { break; case 2: if (D_809171D8 == 0) { - func_80151938(globalCtx, 0x4085); + func_80151938(play, 0x4085); } else if (sLinkAge == 1) { - func_80151938(globalCtx, 0x4092); + func_80151938(play, 0x4092); } this->unk_154 = 22; break; @@ -4891,11 +4877,12 @@ void EnFishing_HandleOwnerDialog(EnFishing* this, GlobalContext* globalCtx) { break; case 11: - if (((Message_GetState(&globalCtx->msgCtx) == 5) || Message_GetState(&globalCtx->msgCtx) == 0) && - Message_ShouldAdvance(globalCtx)) { + if (((Message_GetState(&play->msgCtx) == TEXT_STATE_5) || + Message_GetState(&play->msgCtx) == TEXT_STATE_NONE) && + Message_ShouldAdvance(play)) { s32 getItemId; - func_801477B4(globalCtx); + func_801477B4(play); if (D_809171D0 == 0) { D_809171CC = D_8090CCF0; @@ -4951,7 +4938,7 @@ void EnFishing_HandleOwnerDialog(EnFishing* this, GlobalContext* globalCtx) { } else { if ((D_809171CC >= 60.0f) && !(gSaveContext.save.unk_EE4 & 0x800)) { gSaveContext.save.unk_EE4 |= 0x800; - getItemId = GI_SCALE_GOLD; + getItemId = GI_SKULL_TOKEN; sSinkingLureLocation = Rand_ZeroFloat(3.999f) + 1.0f; } } @@ -4961,31 +4948,31 @@ void EnFishing_HandleOwnerDialog(EnFishing* this, GlobalContext* globalCtx) { } this->actor.parent = NULL; - Actor_PickUp(&this->actor, globalCtx, getItemId, 2000.0f, 1000.0f); + Actor_PickUp(&this->actor, play, getItemId, 2000.0f, 1000.0f); this->unk_154 = 23; } break; case 20: - if ((Message_GetState(&globalCtx->msgCtx) == 5) && Message_ShouldAdvance(globalCtx)) { - func_801477B4(globalCtx); + if ((Message_GetState(&play->msgCtx) == TEXT_STATE_5) && Message_ShouldAdvance(play)) { + func_801477B4(play); this->unk_154 = 0; } break; case 21: - if ((Message_GetState(&globalCtx->msgCtx) == 4) && Message_ShouldAdvance(globalCtx)) { - func_801477B4(globalCtx); + if ((Message_GetState(&play->msgCtx) == TEXT_STATE_CHOICE) && Message_ShouldAdvance(play)) { + func_801477B4(play); - switch (globalCtx->msgCtx.choiceIndex) { + switch (play->msgCtx.choiceIndex) { case 0: this->unk_154 = 0; break; case 1: if (D_809171D8 == 0) { - func_80151938(globalCtx, 0x4085); + func_80151938(play, 0x4085); } else if (sLinkAge == 1) { - func_80151938(globalCtx, 0x4092); + func_80151938(play, 0x4092); } this->unk_154 = 22; break; @@ -4994,33 +4981,33 @@ void EnFishing_HandleOwnerDialog(EnFishing* this, GlobalContext* globalCtx) { break; case 22: - if (Message_GetState(&globalCtx->msgCtx) == 0) { + if (Message_GetState(&play->msgCtx) == TEXT_STATE_NONE) { this->unk_154 = 0; if (D_8090CD0C != 0) { D_8090CD08 = 1; D_8090CD0C = 0; } D_809171FC = 0; - globalCtx->interfaceCtx.unk_27E = 0; + play->interfaceCtx.unk_27E = 0; } break; case 23: D_8090CCF4 = false; - if (Actor_HasParent(&this->actor, globalCtx)) { + if (Actor_HasParent(&this->actor, play)) { this->unk_154 = 24; } else { - Actor_PickUp(&this->actor, globalCtx, GI_SCALE_GOLD, 2000.0f, 1000.0f); + Actor_PickUp(&this->actor, play, GI_SKULL_TOKEN, 2000.0f, 1000.0f); } break; case 24: D_8090CCF4 = false; - if ((Message_GetState(&globalCtx->msgCtx) == 6) && Message_ShouldAdvance(globalCtx)) { + if ((Message_GetState(&play->msgCtx) == TEXT_STATE_DONE) && Message_ShouldAdvance(play)) { if (D_809171D0 == 0) { this->unk_154 = 0; } else { - Message_StartTextbox(globalCtx, 0x409C, NULL); + Message_StartTextbox(play, 0x409C, NULL); this->unk_154 = 20; } } @@ -5039,8 +5026,8 @@ Vec3s sSinkingLureLocationPos[] = { { 553, -48, -508 }, }; -void EnFishing_UpdateOwner(Actor* thisx, GlobalContext* globalCtx2) { - GlobalContext* globalCtx = globalCtx2; +void EnFishing_UpdateOwner(Actor* thisx, PlayState* play2) { + PlayState* play = play2; EnFishing* this = THIS; Vec3f sp114; Vec3f sp108; @@ -5050,9 +5037,9 @@ void EnFishing_UpdateOwner(Actor* thisx, GlobalContext* globalCtx2) { f32 target; f32 camAtFraction; f32 lureDistXZ; - Camera* camera; - Player* player = GET_PLAYER(globalCtx); - Input* input = CONTROLLER1(globalCtx); + Camera* mainCam; + Player* player = GET_PLAYER(play); + Input* input = CONTROLLER1(&play->state); playerShadowAlpha = player->actor.shape.shadowAlpha; @@ -5066,13 +5053,13 @@ void EnFishing_UpdateOwner(Actor* thisx, GlobalContext* globalCtx2) { SkelAnime_Update(&this->skelAnime); - if ((D_8090CD04 != 0) || Message_GetState(&globalCtx->msgCtx)) { + if ((D_8090CD04 != 0) || Message_GetState(&play->msgCtx) != TEXT_STATE_NONE) { this->actor.flags &= ~ACTOR_FLAG_1; } else { this->actor.flags |= (ACTOR_FLAG_1 | ACTOR_FLAG_20); } - if ((this->actor.xzDistToPlayer < 120.0f) || Message_GetState(&globalCtx->msgCtx)) { + if ((this->actor.xzDistToPlayer < 120.0f) || Message_GetState(&play->msgCtx) != TEXT_STATE_NONE) { headRotTarget = this->actor.shape.rot.y - this->actor.yawTowardsPlayer; } else { headRotTarget = 0; @@ -5086,7 +5073,7 @@ void EnFishing_UpdateOwner(Actor* thisx, GlobalContext* globalCtx2) { Math_ApproachS(&this->unk_15C, headRotTarget, 3, 0x1388); - if (((globalCtx->gameplayFrames % 32) == 0) && (Rand_ZeroOne() < 0.3f)) { + if (((play->gameplayFrames % 32) == 0) && (Rand_ZeroOne() < 0.3f)) { this->unk_15A = 4; } @@ -5108,7 +5095,7 @@ void EnFishing_UpdateOwner(Actor* thisx, GlobalContext* globalCtx2) { if ((sqrtf(SQ(dx) + SQ(dy) + SQ(dz)) < 25.0f)) { D_8090CD08 = 0; D_8090CD0C = 1; - Message_StartTextbox(globalCtx, 0x4087, NULL); + Message_StartTextbox(play, 0x4087, NULL); } } @@ -5121,22 +5108,22 @@ void EnFishing_UpdateOwner(Actor* thisx, GlobalContext* globalCtx2) { if (D_8090CCFC != 0) { D_8090CCFC--; if (D_8090CCFC == 0) { - Message_StartTextbox(globalCtx, D_809171DA, NULL); + Message_StartTextbox(play, D_809171DA, NULL); } } - EnFishing_HandleOwnerDialog(this, globalCtx); + EnFishing_HandleOwnerDialog(this, play); D_809101C8 = 0.0015f; D_8090CD00++; if ((D_809171FC != 0) && D_8090CCF4) { - EnFishing_UpdateLure(this, globalCtx); + EnFishing_UpdateLure(this, play); } - EnFishing_UpdateEffects(globalCtx->specialEffects, globalCtx); - EnFishing_UpdatePondProps(globalCtx); - EnFishing_UpdateGroupFishes(globalCtx); + EnFishing_UpdateEffects(play->specialEffects, play); + EnFishing_UpdatePondProps(play); + EnFishing_UpdateGroupFishes(play); if ((D_809171FC != 0) && (D_8090CD4C == 0) && (player->actor.world.pos.z > 1360.0f) && (fabsf(player->actor.world.pos.x) < 25.0f)) { @@ -5154,7 +5141,7 @@ void EnFishing_UpdateOwner(Actor* thisx, GlobalContext* globalCtx2) { (fabsf(player->actor.world.pos.z - sSinkingLureLocationPos[sSinkingLureLocation - 1].z) < 25.0f)) { sSinkingLureLocation = 0; D_8090CD4C = 20; - func_8013EC44(0.0f, 150, 10, 10); + Rumble_Override(0.0f, 150, 10, 10); play_sound(NA_SE_SY_TRE_BOX_APPEAR); Audio_QueueSeqCmd(0x101400FF); } @@ -5168,33 +5155,32 @@ void EnFishing_UpdateOwner(Actor* thisx, GlobalContext* globalCtx2) { break; case 1: - 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; - sCameraAt.x = camera->at.x; - sCameraAt.y = camera->at.y; - sCameraAt.z = camera->at.z; + sSubCamId = Play_CreateSubCamera(play); + Play_ChangeCameraStatus(play, CAM_ID_MAIN, CAM_STATUS_WAIT); + Play_ChangeCameraStatus(play, sSubCamId, CAM_STATUS_ACTIVE); + mainCam = Play_GetCamera(play, CAM_ID_MAIN); + sSubCamEye.x = mainCam->eye.x; + sSubCamEye.y = mainCam->eye.y; + sSubCamEye.z = mainCam->eye.z; + sSubCamAt.x = mainCam->at.x; + sSubCamAt.y = mainCam->at.y; + sSubCamAt.z = mainCam->at.z; D_8090CD4C = 2; Interface_ChangeAlpha(12); - D_80911F4C = 0.0f; + sSubCamVelFactor = 0.0f; // fallthrough - case 2: ShrinkWindow_SetLetterboxTarget(27); 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; @@ -5202,9 +5188,9 @@ void EnFishing_UpdateOwner(Actor* thisx, GlobalContext* globalCtx2) { camAtFraction = 0.1f; } - Math_ApproachF(&sCameraAt.x, sLurePos.x, camAtFraction, fabsf(spFC.x) * D_80911F4C); - Math_ApproachF(&sCameraAt.y, sLurePos.y, camAtFraction, 50.0f * D_80911F4C); - Math_ApproachF(&sCameraAt.z, sLurePos.z, camAtFraction, fabsf(spFC.z) * D_80911F4C); + Math_ApproachF(&sSubCamAt.x, sLurePos.x, camAtFraction, fabsf(spFC.x) * sSubCamVelFactor); + Math_ApproachF(&sSubCamAt.y, sLurePos.y, camAtFraction, 50.0f * sSubCamVelFactor); + Math_ApproachF(&sSubCamAt.z, sLurePos.z, camAtFraction, fabsf(spFC.z) * sSubCamVelFactor); sp114.x = 0.0f - D_80911F50; if (sLinkAge != 1) { @@ -5214,7 +5200,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; @@ -5270,90 +5256,92 @@ 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); - Math_ApproachF(&sCameraEye.z, sp108.z, 0.3f, fabsf(spFC.z) * D_80911F4C); + Math_ApproachF(&sSubCamEye.x, sp108.x, 0.3f, fabsf(spFC.x) * sSubCamVelFactor); + Math_ApproachF(&sSubCamEye.y, sp108.y, 0.3f, 20.0f * sSubCamVelFactor); + Math_ApproachF(&sSubCamEye.z, sp108.z, 0.3f, fabsf(spFC.z) * sSubCamVelFactor); break; case 3: { - Camera* camera = Play_GetCamera(globalCtx, CAM_ID_MAIN); + Camera* mainCam = Play_GetCamera(play, CAM_ID_MAIN); - camera->eye = sCameraEye; - camera->eyeNext = sCameraEye; - camera->at = sCameraAt; + mainCam->eye = sSubCamEye; + mainCam->eyeNext = sSubCamEye; + mainCam->at = sSubCamAt; } - func_80169AFC(globalCtx, sCameraId, 0); - Cutscene_End(globalCtx, &globalCtx->csCtx); + func_80169AFC(play, sSubCamId, 0); + Cutscene_End(play, &play->csCtx); D_8090CD4C = 0; - sCameraId = CAM_ID_MAIN; - func_800F6834(globalCtx, 0); - globalCtx->envCtx.lightSettings.fogNear = 0; + sSubCamId = SUB_CAM_ID_DONE; + func_800F6834(play, 0); + play->envCtx.lightSettings.fogNear = 0; player->unk_B28 = -5; D_80917200 = 5; break; case 10: - 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, 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; - Message_StartTextbox(globalCtx, 0x409E, NULL); - D_8090CD4C = 11; - func_8013EC44(0.0f, 150, 10, 10); - // fallthrough + Cutscene_Start(play, &play->csCtx); + sSubCamId = Play_CreateSubCamera(play); + Play_ChangeCameraStatus(play, CAM_ID_MAIN, CAM_STATUS_WAIT); + Play_ChangeCameraStatus(play, sSubCamId, CAM_STATUS_ACTIVE); + func_800B7298(play, &this->actor, 4); + mainCam = Play_GetCamera(play, CAM_ID_MAIN); + sSubCamEye.x = mainCam->eye.x; + sSubCamEye.y = mainCam->eye.y; + sSubCamEye.z = mainCam->eye.z; + sSubCamAt.x = mainCam->at.x; + sSubCamAt.y = mainCam->at.y; + sSubCamAt.z = mainCam->at.z; + + Message_StartTextbox(play, 0x409E, NULL); + D_8090CD4C = 11; + Rumble_Override(0.0f, 150, 10, 10); + // fallthrough case 11: player->actor.world.pos.z = 1360.0f; player->actor.speedXZ = 0.0f; - if (Message_GetState(&globalCtx->msgCtx) == 0) { - Camera* camera = Play_GetCamera(globalCtx, CAM_ID_MAIN); + if (Message_GetState(&play->msgCtx) == TEXT_STATE_NONE) { + Camera* mainCam = Play_GetCamera(play, CAM_ID_MAIN); - camera->eye = sCameraEye; - camera->eyeNext = sCameraEye; - camera->at = sCameraAt; - func_80169AFC(globalCtx, sCameraId, 0); - Cutscene_End(globalCtx, &globalCtx->csCtx); - func_800B7298(globalCtx, &this->actor, 6); + mainCam->eye = sSubCamEye; + mainCam->eyeNext = sSubCamEye; + mainCam->at = sSubCamAt; + + func_80169AFC(play, sSubCamId, 0); + Cutscene_End(play, &play->csCtx); + func_800B7298(play, &this->actor, 6); D_8090CD4C = 0; - sCameraId = CAM_ID_MAIN; + sSubCamId = SUB_CAM_ID_DONE; D_8090CD50 = 30; - func_800F6834(globalCtx, 0); - globalCtx->envCtx.lightSettings.fogNear = 0; + func_800F6834(play, 0); + play->envCtx.lightSettings.fogNear = 0; } break; case 20: - 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, 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; - Message_StartTextbox(globalCtx, 0x409A, NULL); + Cutscene_Start(play, &play->csCtx); + sSubCamId = Play_CreateSubCamera(play); + Play_ChangeCameraStatus(play, CAM_ID_MAIN, CAM_STATUS_WAIT); + Play_ChangeCameraStatus(play, sSubCamId, CAM_STATUS_ACTIVE); + func_800B7298(play, &this->actor, 4); + + mainCam = Play_GetCamera(play, CAM_ID_MAIN); + sSubCamEye.x = mainCam->eye.x; + sSubCamEye.y = mainCam->eye.y; + sSubCamEye.z = mainCam->eye.z; + sSubCamAt.x = mainCam->at.x; + sSubCamAt.y = mainCam->at.y; + sSubCamAt.z = mainCam->at.z; + Message_StartTextbox(play, 0x409A, NULL); D_8090CD4C = 21; D_80911F48 = 45.0f; D_8090CD50 = 10; // fallthrough - case 21: - if ((D_8090CD50 == 0) && Message_ShouldAdvance(globalCtx)) { + if ((D_8090CD50 == 0) && Message_ShouldAdvance(play)) { D_8090CD4C = 22; D_8090CD50 = 40; // func_800B7298 call removed in MM @@ -5369,16 +5357,16 @@ 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.x = Math_SinS(play->gameplayFrames * 0x1000); sp114.y = D_80911F64; sp114.z = -5.0f; if (sLinkAge == 1) { 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; @@ -5396,43 +5384,44 @@ void EnFishing_UpdateOwner(Actor* thisx, GlobalContext* globalCtx2) { sp114.z = -35.0f; } - Matrix_MultiplyVector3fByState(&sp114, &sCameraEye); - sCameraEye.x += player->actor.world.pos.x; - sCameraEye.y += player->actor.world.pos.y; - sCameraEye.z += player->actor.world.pos.z; + Matrix_MultVec3f(&sp114, &sSubCamEye); + sSubCamEye.x += player->actor.world.pos.x; + sSubCamEye.y += player->actor.world.pos.y; + sSubCamEye.z += player->actor.world.pos.z; - sCameraAt = player->actor.world.pos; + sSubCamAt = player->actor.world.pos; if (sLinkAge != 1) { - sCameraAt.y += 62.0f; + sSubCamAt.y += 62.0f; } else { - sCameraAt.y += 40.0f; + sSubCamAt.y += 40.0f; } if (D_8090CD50 == 0) { - if ((Message_GetState(&globalCtx->msgCtx) == 4) || Message_GetState(&globalCtx->msgCtx) == 0) { - if (Message_ShouldAdvance(globalCtx)) { - Camera* camera = Play_GetCamera(globalCtx, CAM_ID_MAIN); + if ((Message_GetState(&play->msgCtx) == TEXT_STATE_CHOICE) || + Message_GetState(&play->msgCtx) == TEXT_STATE_NONE) { + if (Message_ShouldAdvance(play)) { + Camera* mainCam = Play_GetCamera(play, CAM_ID_MAIN); - func_801477B4(globalCtx); - if (globalCtx->msgCtx.choiceIndex == 0) { + func_801477B4(play); + if (play->msgCtx.choiceIndex == 0) { D_80917206 = 2; D_809171D6 = 0; } - camera->eye = sCameraEye; - camera->eyeNext = sCameraEye; - camera->at = sCameraAt; - func_80169AFC(globalCtx, sCameraId, 0); - Cutscene_End(globalCtx, &globalCtx->csCtx); - func_800B7298(globalCtx, &this->actor, 6); // arg2 changed from 7 to 6 in MM + mainCam->eye = sSubCamEye; + mainCam->eyeNext = sSubCamEye; + mainCam->at = sSubCamAt; + func_80169AFC(play, sSubCamId, 0); + Cutscene_End(play, &play->csCtx); + func_800B7298(play, &this->actor, 6); // arg2 changed from 7 to 6 in MM D_8090CD4C = 0; - sCameraId = CAM_ID_MAIN; + sSubCamId = SUB_CAM_ID_DONE; player->unk_B28 = -5; D_80917200 = 5; D_8090CD54 = 0; D_809171F6 = 20; - func_800F6834(globalCtx, 0); - globalCtx->envCtx.lightSettings.fogNear = 0; + func_800F6834(play, 0); + play->envCtx.lightSettings.fogNear = 0; } } } @@ -5442,37 +5431,37 @@ void EnFishing_UpdateOwner(Actor* thisx, GlobalContext* globalCtx2) { break; } - if (sCameraId != CAM_ID_MAIN) { - Play_CameraSetAtEye(globalCtx, sCameraId, &sCameraAt, &sCameraEye); - Math_ApproachF(&D_80911F4C, 1.0f, 1.0f, 0.02f); + if (sSubCamId != SUB_CAM_ID_DONE) { + Play_SetCameraAtEye(play, sSubCamId, &sSubCamAt, &sSubCamEye); + Math_ApproachF(&sSubCamVelFactor, 1.0f, 1.0f, 0.02f); - if (sCameraEye.y <= (WATER_SURFACE_Y(globalCtx) + 1.0f)) { - func_800F6834(globalCtx, 1); + if (sSubCamEye.y <= (WATER_SURFACE_Y(play) + 1.0f)) { + func_800F6834(play, 1); if (D_809171CA != 0) { - globalCtx->envCtx.lightSettings.fogNear = -0xB2; + play->envCtx.lightSettings.fogNear = -0xB2; } else { - globalCtx->envCtx.lightSettings.fogNear = -0x2E; + play->envCtx.lightSettings.fogNear = -0x2E; } } else { - func_800F6834(globalCtx, 0); - globalCtx->envCtx.lightSettings.fogNear = 0; + func_800F6834(play, 0); + play->envCtx.lightSettings.fogNear = 0; } } - if ((player->actor.floorHeight < (WATER_SURFACE_Y(globalCtx) - 3.0f)) && + if ((player->actor.floorHeight < (WATER_SURFACE_Y(play) - 3.0f)) && (player->actor.world.pos.y < (player->actor.floorHeight + 3.0f)) && (player->actor.speedXZ > 1.0f) && - ((globalCtx->gameplayFrames % 2) == 0)) { + ((play->gameplayFrames % 2) == 0)) { Vec3f pos; pos.x = randPlusMinusPoint5Scaled(20.0f) + player->actor.world.pos.x; pos.z = randPlusMinusPoint5Scaled(20.0f) + player->actor.world.pos.z; pos.y = player->actor.floorHeight + 5.0f; - EnFishing_SpawnWaterDust(NULL, globalCtx->specialEffects, &pos, 0.5f); + EnFishing_SpawnWaterDust(NULL, play->specialEffects, &pos, 0.5f); } - if ((player->actor.floorHeight < WATER_SURFACE_Y(globalCtx)) && - (player->actor.floorHeight > (WATER_SURFACE_Y(globalCtx) - 10.0f)) && (player->actor.speedXZ >= 4.0f) && - ((globalCtx->gameplayFrames % 4) == 0)) { + if ((player->actor.floorHeight < WATER_SURFACE_Y(play)) && + (player->actor.floorHeight > (WATER_SURFACE_Y(play) - 10.0f)) && (player->actor.speedXZ >= 4.0f) && + ((play->gameplayFrames % 4) == 0)) { s16 i; for (i = 0; i < 10; i++) { @@ -5484,16 +5473,15 @@ 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; pos.x += 2.0f * vel.x; - pos.y = WATER_SURFACE_Y(globalCtx); + pos.y = WATER_SURFACE_Y(play); pos.z += 2.0f * vel.z; - EnFishing_SpawnDustSplash(NULL, globalCtx->specialEffects, &pos, &vel, - Rand_ZeroFloat(0.01f) + 0.020000001f); + EnFishing_SpawnDustSplash(NULL, play->specialEffects, &pos, &vel, Rand_ZeroFloat(0.01f) + 0.020000001f); } } @@ -5501,15 +5489,15 @@ void EnFishing_UpdateOwner(Actor* thisx, GlobalContext* globalCtx2) { D_809171CB--; } - if ((D_809171CB == 1) && Message_GetState(&globalCtx->msgCtx) == 0 && ((D_8090CD00 & 0xFFF) == 0xFFF)) { + if ((D_809171CB == 1) && (Message_GetState(&play->msgCtx) == TEXT_STATE_NONE) && ((D_8090CD00 & 0xFFF) == 0xFFF)) { D_809171CB = 200; if (Rand_ZeroOne() < 0.5f) { D_8090CCD4 = Rand_ZeroFloat(10.0f) + 5.0f; - globalCtx->envCtx.unk_E1 = 1; + play->envCtx.unk_E1 = 1; } else { D_8090CCD4 = 0; - globalCtx->envCtx.unk_E1 = 2; + play->envCtx.unk_E1 = 2; } } @@ -5540,13 +5528,13 @@ void EnFishing_UpdateOwner(Actor* thisx, GlobalContext* globalCtx2) { Math_ApproachZeroF(&D_8090CCD8, 1.0f, 2.0f); } - globalCtx->envCtx.lightSettings.diffuseColor1[0] = globalCtx->envCtx.lightSettings.diffuseColor1[1] = - globalCtx->envCtx.lightSettings.diffuseColor1[2] = D_8090CCD8; + play->envCtx.lightSettings.diffuseColor1[0] = play->envCtx.lightSettings.diffuseColor1[1] = + play->envCtx.lightSettings.diffuseColor1[2] = D_8090CCD8; if ((u8)D_8090CCD0 > 0) { s32 pad; s16 i; - Camera* camera = Play_GetCamera(globalCtx, CAM_ID_MAIN); + Camera* mainCam = Play_GetCamera(play, CAM_ID_MAIN); Vec3f pos; Vec3f rot; Vec3f projectedPos; @@ -5554,27 +5542,26 @@ void EnFishing_UpdateOwner(Actor* thisx, GlobalContext* globalCtx2) { rot.x = 1.6707964f; rot.y = 1.0f; - rot.z = (Camera_GetInputDirYaw(camera) * -(M_PI / 32768)) + rot.y; + rot.z = (Camera_GetInputDirYaw(mainCam) * -(M_PI / 0x8000)) + rot.y; for (i = 0; i < (u8)D_8090CCD0; i++) { - pos.x = randPlusMinusPoint5Scaled(700.0f) + globalCtx->view.eye.x; + pos.x = randPlusMinusPoint5Scaled(700.0f) + play->view.eye.x; pos.y = (Rand_ZeroFloat(100.0f) + 150.0f) - 170.0f; - pos.z = randPlusMinusPoint5Scaled(700.0f) + globalCtx->view.eye.z; + pos.z = randPlusMinusPoint5Scaled(700.0f) + play->view.eye.z; if (pos.z < 1160.0f) { - SkinMatrix_Vec3fMtxFMultXYZW(&globalCtx->viewProjectionMtxF, &pos, &projectedPos, &sProjectedW); + SkinMatrix_Vec3fMtxFMultXYZW(&play->viewProjectionMtxF, &pos, &projectedPos, &sProjectedW); if (projectedPos.z < 0.0f) { i--; } else { - EnFishing_SpawnRainDrop(globalCtx->specialEffects, &pos, &rot); + EnFishing_SpawnRainDrop(play->specialEffects, &pos, &rot); } } } } - SkinMatrix_Vec3fMtxFMultXYZW(&globalCtx->viewProjectionMtxF, &sStreamSoundPos, &sStreamSoundProjectedPos, - &sProjectedW); + SkinMatrix_Vec3fMtxFMultXYZW(&play->viewProjectionMtxF, &sStreamSoundPos, &sStreamSoundProjectedPos, &sProjectedW); Audio_PlaySfxAtPos(&sStreamSoundProjectedPos, NA_SE_EV_WATER_WALL - SFX_FLAG); @@ -5585,8 +5572,7 @@ void EnFishing_UpdateOwner(Actor* thisx, GlobalContext* globalCtx2) { } } -s32 EnFishing_OwnerOverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, - Actor* thisx) { +s32 EnFishing_OwnerOverrideLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, Actor* thisx) { EnFishing* this = THIS; if (limbIndex == 8) { // Head @@ -5596,11 +5582,11 @@ s32 EnFishing_OwnerOverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx return false; } -void EnFishing_OwnerPostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx) { +void EnFishing_OwnerPostLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx) { if (limbIndex == 8) { // Head - OPEN_DISPS(globalCtx->state.gfxCtx); + OPEN_DISPS(play->state.gfxCtx); - Matrix_MultiplyVector3fByState(&sZeroVec, &sOwnerHeadPos); + Matrix_MultVec3f(&sZeroVec, &sOwnerHeadPos); if (D_8090CD08 == 1) { gSPDisplayList(POLY_OPA_DISP++, gFishingOwnerHatDL); @@ -5608,7 +5594,7 @@ void EnFishing_OwnerPostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** gSPDisplayList(POLY_OPA_DISP++, gFishingOwnerHairDL); } - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->state.gfxCtx); } } @@ -5618,29 +5604,28 @@ TexturePtr sFishingOwnerEyeTexs[] = { gFishingOwnerEyeClosedTex, }; -void EnFishing_DrawOwner(Actor* thisx, GlobalContext* globalCtx) { +void EnFishing_DrawOwner(Actor* thisx, PlayState* play) { s32 pad; EnFishing* this = THIS; - Input* input = CONTROLLER1(globalCtx); + Input* input = CONTROLLER1(&play->state); - OPEN_DISPS(globalCtx->state.gfxCtx); + OPEN_DISPS(play->state.gfxCtx); - func_8012C28C(globalCtx->state.gfxCtx); - func_8012C2DC(globalCtx->state.gfxCtx); + func_8012C28C(play->state.gfxCtx); + func_8012C2DC(play->state.gfxCtx); if ((this->actor.projectedPos.z < 1500.0f) && (fabsf(this->actor.projectedPos.x) < (100.0f + this->actor.projectedPos.z))) { gSPSegment(POLY_OPA_DISP++, 0x08, Lib_SegmentedToVirtual(sFishingOwnerEyeTexs[this->unk_158])); - SkelAnime_DrawFlexOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, - this->skelAnime.dListCount, EnFishing_OwnerOverrideLimbDraw, EnFishing_OwnerPostLimbDraw, - &this->actor); + SkelAnime_DrawFlexOpa(play, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, + EnFishing_OwnerOverrideLimbDraw, EnFishing_OwnerPostLimbDraw, &this->actor); } - EnFishing_DrawPondProps(globalCtx); - EnFishing_DrawEffects(globalCtx->specialEffects, globalCtx); - EnFishing_DrawGroupFishes(globalCtx); - EnFishing_DrawStreamSplash(globalCtx); + EnFishing_DrawPondProps(play); + EnFishing_DrawEffects(play->specialEffects, play); + EnFishing_DrawGroupFishes(play); + EnFishing_DrawStreamSplash(play); if (D_809171F6 != 0) { D_809171F6--; @@ -5661,10 +5646,10 @@ void EnFishing_DrawOwner(Actor* thisx, GlobalContext* globalCtx) { } if ((D_809171FC != 0) && D_8090CCF4) { - EnFishing_DrawRod(globalCtx); + EnFishing_DrawRod(play); EnFishing_UpdateLinePos(sReelLinePos); - EnFishing_UpdateLine(globalCtx, &sRodTipPos, sReelLinePos, sReelLineRot, sReelLineUnk); - EnFishing_DrawLureAndLine(globalCtx, sReelLinePos, sReelLineRot); + EnFishing_UpdateLine(play, &sRodTipPos, sReelLinePos, sReelLineRot, sReelLineUnk); + EnFishing_DrawLureAndLine(play, sReelLinePos, sReelLineRot); D_8090CD44 = input->rel.stick_x; D_8090CD48 = input->rel.stick_y; @@ -5672,18 +5657,18 @@ 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); - gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_OPA_DISP++, gFishingAquariumBottomDL); gSPDisplayList(POLY_XLU_DISP++, gFishingAquariumContainerDL); if ((D_809171FC != 0) && (D_80917206 == 2)) { - EnFishing_DrawSinkingLure(globalCtx); + EnFishing_DrawSinkingLure(play); } - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->state.gfxCtx); } diff --git a/src/overlays/actors/ovl_En_Fishing/z_en_fishing.h b/src/overlays/actors/ovl_En_Fishing/z_en_fishing.h index 3cd594b38..5af536dbb 100644 --- a/src/overlays/actors/ovl_En_Fishing/z_en_fishing.h +++ b/src/overlays/actors/ovl_En_Fishing/z_en_fishing.h @@ -5,60 +5,60 @@ struct EnFishing; -typedef void (*EnFishingActionFunc)(struct EnFishing*, GlobalContext*); +typedef void (*EnFishingActionFunc)(struct EnFishing*, PlayState*); typedef struct EnFishing { /* 0x000 */ Actor actor; - /* 0x0144 */ UNK_TYPE1 unk_144[0x004]; - /* 0x0148 */ u8 unk_148; - /* 0x0149 */ u8 unk_149; - /* 0x014A */ u8 unk_14A; - /* 0x014C */ s16 unk_14C; - /* 0x014E */ u8 unk_14E; - /* 0x014F */ u8 unk_14F; - /* 0x0150 */ s16 unk_150; - /* 0x0152 */ s16 unk_152; - /* 0x0154 */ s16 unk_154; - /* 0x0156 */ s16 unk_156; - /* 0x0158 */ s16 unk_158; - /* 0x015A */ s16 unk_15A; - /* 0x015C */ s16 unk_15C; - /* 0x015E */ s16 unk_15E; - /* 0x0160 */ s16 unk_160; - /* 0x0162 */ s16 unk_162; - /* 0x0164 */ s16 unk_164; - /* 0x0166 */ s16 unk_166; - /* 0x0168 */ s16 unk_168; - /* 0x016A */ s16 unk_16A; - /* 0x016C */ s16 unk_16C; - /* 0x016E */ s16 unk_16E; - /* 0x0170 */ s16 unk_170; - /* 0x0172 */ s16 unk_172[4]; - /* 0x017C */ f32 unk_17C; - /* 0x0180 */ f32 unk_180; - /* 0x0184 */ f32 unk_184; - /* 0x0188 */ f32 unk_188; - /* 0x018C */ f32 unk_18C; - /* 0x0190 */ f32 unk_190; - /* 0x0194 */ f32 unk_194; - /* 0x0198 */ s16 unk_198; - /* 0x019A */ s16 unk_19A; - /* 0x019C */ s16 unk_19C; - /* 0x01A0 */ f32 unk_1A0; - /* 0x01A4 */ f32 unk_1A4; - /* 0x01A8 */ f32 unk_1A8; - /* 0x01AC */ Vec3f unk_1AC; - /* 0x01B8 */ Vec3f fishMouthPos; - /* 0x01C4 */ s16 unk_1C4[3]; - /* 0x01CA */ u8 unk_1CA; - /* 0x01CB */ u8 unk_1CB; - /* 0x01CC */ u8 unk_1CC; - /* 0x01CD */ u8 unk_1CD; - /* 0x01D0 */ SkelAnime skelAnime; - /* 0x0214 */ LightNode* lightNode; - /* 0x0218 */ LightInfo lightInfo; - /* 0x0228 */ ColliderJntSph collider; - /* 0x0248 */ ColliderJntSphElement colliderElements[12]; + /* 0x144 */ UNK_TYPE1 unk_144[0x004]; + /* 0x148 */ u8 unk_148; + /* 0x149 */ u8 unk_149; + /* 0x14A */ u8 unk_14A; + /* 0x14C */ s16 unk_14C; + /* 0x14E */ u8 unk_14E; + /* 0x14F */ u8 unk_14F; + /* 0x150 */ s16 unk_150; + /* 0x152 */ s16 unk_152; + /* 0x154 */ s16 unk_154; + /* 0x156 */ s16 unk_156; + /* 0x158 */ s16 unk_158; + /* 0x15A */ s16 unk_15A; + /* 0x15C */ s16 unk_15C; + /* 0x15E */ s16 unk_15E; + /* 0x160 */ s16 unk_160; + /* 0x162 */ s16 unk_162; + /* 0x164 */ s16 unk_164; + /* 0x166 */ s16 unk_166; + /* 0x168 */ s16 unk_168; + /* 0x16A */ s16 unk_16A; + /* 0x16C */ s16 unk_16C; + /* 0x16E */ s16 unk_16E; + /* 0x170 */ s16 unk_170; + /* 0x172 */ s16 unk_172[4]; + /* 0x17C */ f32 unk_17C; + /* 0x180 */ f32 unk_180; + /* 0x184 */ f32 unk_184; + /* 0x188 */ f32 unk_188; + /* 0x18C */ f32 unk_18C; + /* 0x190 */ f32 unk_190; + /* 0x194 */ f32 unk_194; + /* 0x198 */ s16 unk_198; + /* 0x19A */ s16 unk_19A; + /* 0x19C */ s16 unk_19C; + /* 0x1A0 */ f32 unk_1A0; + /* 0x1A4 */ f32 unk_1A4; + /* 0x1A8 */ f32 unk_1A8; + /* 0x1AC */ Vec3f unk_1AC; + /* 0x1B8 */ Vec3f fishMouthPos; + /* 0x1C4 */ s16 unk_1C4[3]; + /* 0x1CA */ u8 unk_1CA; + /* 0x1CB */ u8 unk_1CB; + /* 0x1CC */ u8 unk_1CC; + /* 0x1CD */ u8 unk_1CD; + /* 0x1D0 */ SkelAnime skelAnime; + /* 0x214 */ LightNode* lightNode; + /* 0x218 */ LightInfo lightInfo; + /* 0x228 */ ColliderJntSph collider; + /* 0x248 */ ColliderJntSphElement colliderElements[12]; } EnFishing; // size = 0x548 extern const ActorInit En_Fishing_InitVars; diff --git a/src/overlays/actors/ovl_En_Floormas/z_en_floormas.c b/src/overlays/actors/ovl_En_Floormas/z_en_floormas.c index de7d34024..c5e7b24f1 100644 --- a/src/overlays/actors/ovl_En_Floormas/z_en_floormas.c +++ b/src/overlays/actors/ovl_En_Floormas/z_en_floormas.c @@ -10,54 +10,54 @@ #define THIS ((EnFloormas*)thisx) -void EnFloormas_Init(Actor* thisx, GlobalContext* globalCtx); -void EnFloormas_Destroy(Actor* thisx, GlobalContext* globalCtx); -void EnFloormas_Update(Actor* thisx, GlobalContext* globalCtx); -void EnFloormas_Draw(Actor* thisx, GlobalContext* globalCtx); +void EnFloormas_Init(Actor* thisx, PlayState* play); +void EnFloormas_Destroy(Actor* thisx, PlayState* play); +void EnFloormas_Update(Actor* thisx, PlayState* play); +void EnFloormas_Draw(Actor* thisx, PlayState* play); void func_808D0B08(EnFloormas* this); -void func_808D0B50(EnFloormas* this, GlobalContext* globalCtx); +void func_808D0B50(EnFloormas* this, PlayState* play); void func_808D0C14(EnFloormas* this); -void func_808D0C58(EnFloormas* this, GlobalContext* globalCtx); +void func_808D0C58(EnFloormas* this, PlayState* play); void func_808D0CE4(EnFloormas* this); -void func_808D0D70(EnFloormas* this, GlobalContext* globalCtx); +void func_808D0D70(EnFloormas* this, PlayState* play); void func_808D0ECC(EnFloormas* this); -void func_808D0F14(EnFloormas* this, GlobalContext* globalCtx); +void func_808D0F14(EnFloormas* this, PlayState* play); void func_808D0F50(EnFloormas* this); -void func_808D0F80(EnFloormas* this, GlobalContext* globalCtx); +void func_808D0F80(EnFloormas* this, PlayState* play); void func_808D108C(EnFloormas* this); -void func_808D11BC(EnFloormas* this, GlobalContext* globalCtx); -void func_808D1380(EnFloormas* this, GlobalContext* globalCtx); -void func_808D1458(EnFloormas* this, GlobalContext* globalCtx); +void func_808D11BC(EnFloormas* this, PlayState* play); +void func_808D1380(EnFloormas* this, PlayState* play); +void func_808D1458(EnFloormas* this, PlayState* play); void func_808D161C(EnFloormas* this); -void func_808D1650(EnFloormas* this, GlobalContext* globalCtx); +void func_808D1650(EnFloormas* this, PlayState* play); void func_808D1740(EnFloormas* this); -void func_808D17EC(EnFloormas* this, GlobalContext* globalCtx); +void func_808D17EC(EnFloormas* this, PlayState* play); void func_808D19D4(EnFloormas* this); -void func_808D1B44(EnFloormas* this, GlobalContext* globalCtx); +void func_808D1B44(EnFloormas* this, PlayState* play); void func_808D1BCC(EnFloormas* this); -void func_808D1C1C(EnFloormas* this, GlobalContext* globalCtx); +void func_808D1C1C(EnFloormas* this, PlayState* play); void func_808D1D0C(EnFloormas* this); -void func_808D1D6C(EnFloormas* this, GlobalContext* globalCtx); -void func_808D1ED4(EnFloormas* this, GlobalContext* globalCtx); -void func_808D1F7C(EnFloormas* this, GlobalContext* globalCtx); +void func_808D1D6C(EnFloormas* this, PlayState* play); +void func_808D1ED4(EnFloormas* this, PlayState* play); +void func_808D1F7C(EnFloormas* this, PlayState* play); void func_808D1FD4(EnFloormas* this); -void func_808D2040(EnFloormas* this, GlobalContext* globalCtx); +void func_808D2040(EnFloormas* this, PlayState* play); void func_808D217C(EnFloormas* this, Player* player); -void func_808D22C8(EnFloormas* this, GlobalContext* globalCtx); +void func_808D22C8(EnFloormas* this, PlayState* play); void func_808D2484(EnFloormas* this); -void func_808D24F0(EnFloormas* this, GlobalContext* globalCtx); +void func_808D24F0(EnFloormas* this, PlayState* play); void func_808D2700(EnFloormas* this); -void func_808D2764(EnFloormas* this, GlobalContext* globalCtx); +void func_808D2764(EnFloormas* this, PlayState* play); void func_808D2A20(EnFloormas* this); -void func_808D2AA8(EnFloormas* this, GlobalContext* globalCtx); +void func_808D2AA8(EnFloormas* this, PlayState* play); void func_808D2AB8(EnFloormas* this); -void func_808D2AF4(EnFloormas* this, GlobalContext* globalCtx); -void func_808D2C08(EnFloormas* this, GlobalContext* globalCtx); +void func_808D2AF4(EnFloormas* this, PlayState* play); +void func_808D2C08(EnFloormas* this, PlayState* play); void func_808D2CDC(EnFloormas* this); -void func_808D2D30(EnFloormas* this, GlobalContext* globalCtx); -void func_808D2DC0(EnFloormas* this, GlobalContext* globalCtx); -void func_808D3754(Actor* thisx, GlobalContext* globalCtx); +void func_808D2D30(EnFloormas* this, PlayState* play); +void func_808D2DC0(EnFloormas* this, PlayState* play); +void func_808D3754(Actor* thisx, PlayState* play); const ActorInit En_Floormas_InitVars = { ACTOR_EN_FLOORMAS, @@ -145,17 +145,17 @@ static s8 D_808D393C[] = { static Color_RGBA8 D_808D3958 = { 0, 255, 0, 0 }; -void EnFloormas_Init(Actor* thisx, GlobalContext* globalCtx2) { - GlobalContext* globalCtx = globalCtx2; +void EnFloormas_Init(Actor* thisx, PlayState* play2) { + PlayState* play = play2; EnFloormas* this = THIS; s32 pad; s32 params; Actor_ProcessInitChain(&this->actor, sInitChain); ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 50.0f); - SkelAnime_InitFlex(globalCtx, &this->skelAnime, &gWallmasterSkel, &gWallmasterIdleAnim, this->jointTable, + SkelAnime_InitFlex(play, &this->skelAnime, &gWallmasterSkel, &gWallmasterIdleAnim, this->jointTable, this->morphTable, WALLMASTER_LIMB_MAX); - Collider_InitAndSetCylinder(globalCtx, &this->collider, &this->actor, &sCylinderInit); + Collider_InitAndSetCylinder(play, &this->collider, &this->actor, &sCylinderInit); CollisionCheck_SetInfo(&this->actor.colChkInfo, &sDamageTable, &sColChkInfoInit); this->unk_192 = -1600; @@ -175,16 +175,16 @@ void EnFloormas_Init(Actor* thisx, GlobalContext* globalCtx2) { } this->actor.parent = Actor_SpawnAsChildAndCutscene( - &globalCtx->actorCtx, globalCtx, ACTOR_EN_FLOORMAS, this->actor.world.pos.x, this->actor.world.pos.y, + &play->actorCtx, play, ACTOR_EN_FLOORMAS, this->actor.world.pos.x, this->actor.world.pos.y, this->actor.world.pos.z, 0, 0, 0, params + 0x10, -1, this->actor.unk20, NULL); if (this->actor.parent == NULL) { Actor_MarkForDeath(&this->actor); return; } - this->actor.child = Actor_SpawnAsChildAndCutscene( - &globalCtx->actorCtx, globalCtx, ACTOR_EN_FLOORMAS, this->actor.world.pos.x, this->actor.world.pos.y, - this->actor.world.pos.z, 0, 0, 0, params + 0x10, -1, this->actor.unk20, NULL); + this->actor.child = Actor_SpawnAsChildAndCutscene(&play->actorCtx, play, ACTOR_EN_FLOORMAS, this->actor.world.pos.x, + this->actor.world.pos.y, this->actor.world.pos.z, 0, 0, 0, + params + 0x10, -1, this->actor.unk20, NULL); if (this->actor.child == NULL) { Actor_MarkForDeath(this->actor.parent); Actor_MarkForDeath(&this->actor); @@ -198,10 +198,10 @@ void EnFloormas_Init(Actor* thisx, GlobalContext* globalCtx2) { func_808D0B08(this); } -void EnFloormas_Destroy(Actor* thisx, GlobalContext* globalCtx) { +void EnFloormas_Destroy(Actor* thisx, PlayState* play) { EnFloormas* this = THIS; - Collider_DestroyCylinder(globalCtx, &this->collider); + Collider_DestroyCylinder(play, &this->collider); } void func_808D08D0(EnFloormas* this) { @@ -218,7 +218,7 @@ void func_808D0908(EnFloormas* this) { this->unk_190 = 0; } -void func_808D0930(EnFloormas* this, GlobalContext* globalCtx) { +void func_808D0930(EnFloormas* this, PlayState* play) { if (this->actor.scale.x > 0.009f) { this->actor.shape.rot.y = BINANG_ROT180(this->actor.yawTowardsPlayer); func_808D19D4((EnFloormas*)this->actor.child); @@ -226,8 +226,8 @@ void func_808D0930(EnFloormas* this, GlobalContext* globalCtx) { func_808D19D4(this); Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_KUSAMUSHI_HIDE); } else { - Item_DropCollectibleRandom(globalCtx, &this->actor, &this->actor.world.pos, 0x90); - func_808D1ED4(this, globalCtx); + Item_DropCollectibleRandom(play, &this->actor, &this->actor.world.pos, 0x90); + func_808D1ED4(this, play); } } @@ -242,12 +242,12 @@ void func_808D09CC(EnFloormas* this) { Actor_SetColorFilter(&this->actor, 0x4000, 255, 0, 80); } -void func_808D0A48(EnFloormas* this, GlobalContext* globalCtx) { +void func_808D0A48(EnFloormas* this, PlayState* play) { if (this->drawDmgEffType == ACTOR_DRAW_DMGEFF_FROZEN_NO_SFX) { this->drawDmgEffType = ACTOR_DRAW_DMGEFF_FIRE; this->collider.base.colType = COLTYPE_HIT0; this->drawDmgEffAlpha = 0.0f; - Actor_SpawnIceEffects(globalCtx, &this->actor, this->limbPos, ARRAY_COUNT(this->limbPos), 2, + Actor_SpawnIceEffects(play, &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 |= ACTOR_FLAG_400; @@ -263,13 +263,13 @@ void func_808D0B08(EnFloormas* this) { this->actionFunc = func_808D0B50; } -void func_808D0B50(EnFloormas* this, GlobalContext* globalCtx) { +void func_808D0B50(EnFloormas* this, PlayState* play) { if (SkelAnime_Update(&this->skelAnime)) { if ((this->actor.xzDistToPlayer < 400.0f) && !Actor_IsFacingPlayer(&this->actor, 0x4000)) { this->unk_190 = this->actor.yawTowardsPlayer; func_808D108C(this); } else if ((this->actor.xzDistToPlayer < 280.0f) && Actor_IsFacingPlayer(&this->actor, 0x2000)) { - func_808D1380(this, globalCtx); + func_808D1380(this, play); } else { func_808D0C14(this); } @@ -281,7 +281,7 @@ void func_808D0C14(EnFloormas* this) { this->actionFunc = func_808D0C58; } -void func_808D0C58(EnFloormas* this, GlobalContext* globalCtx) { +void func_808D0C58(EnFloormas* this, PlayState* play) { if (SkelAnime_Update(&this->skelAnime)) { if (this->actor.scale.x > 0.009f) { func_808D0CE4(this); @@ -305,7 +305,7 @@ void func_808D0CE4(EnFloormas* this) { this->actionFunc = func_808D0D70; } -void func_808D0D70(EnFloormas* this, GlobalContext* globalCtx) { +void func_808D0D70(EnFloormas* this, PlayState* play) { s32 temp_v0; SkelAnime_Update(&this->skelAnime); @@ -338,7 +338,7 @@ void func_808D0ECC(EnFloormas* this) { this->actionFunc = func_808D0F14; } -void func_808D0F14(EnFloormas* this, GlobalContext* globalCtx) { +void func_808D0F14(EnFloormas* this, PlayState* play) { if (SkelAnime_Update(&this->skelAnime)) { func_808D0B08(this); } @@ -351,7 +351,7 @@ void func_808D0F50(EnFloormas* this) { this->actionFunc = func_808D0F80; } -void func_808D0F80(EnFloormas* this, GlobalContext* globalCtx) { +void func_808D0F80(EnFloormas* this, PlayState* play) { SkelAnime_Update(&this->skelAnime); if (Animation_OnFrame(&this->skelAnime, 0.0f) || Animation_OnFrame(&this->skelAnime, 12.0f) || Animation_OnFrame(&this->skelAnime, 24.0f) || Animation_OnFrame(&this->skelAnime, 36.0f)) { @@ -361,7 +361,7 @@ void func_808D0F80(EnFloormas* this, GlobalContext* globalCtx) { Math_ApproachS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer, 3, 0x71C); if ((this->actor.xzDistToPlayer < 280.0f) && Actor_IsFacingPlayer(&this->actor, 0x2000) && !(this->actor.bgCheckFlags & 8)) { - func_808D1380(this, globalCtx); + func_808D1380(this, play); } else if (this->actor.xzDistToPlayer > 400.0f) { func_808D0CE4(this); } @@ -388,7 +388,7 @@ void func_808D108C(EnFloormas* this) { this->actionFunc = func_808D11BC; } -void func_808D11BC(EnFloormas* this, GlobalContext* globalCtx) { +void func_808D11BC(EnFloormas* this, PlayState* play) { f32 frame; f32 sp30; f32 sp2C; @@ -416,18 +416,18 @@ void func_808D11BC(EnFloormas* this, GlobalContext* globalCtx) { } } -void func_808D1380(EnFloormas* this, GlobalContext* globalCtx) { +void func_808D1380(EnFloormas* this, PlayState* play) { Animation_Change(&this->skelAnime, &gWallmasterHoverAnim, 3.0f, 0.0f, Animation_GetLastFrame(&gWallmasterHoverAnim), ANIMMODE_ONCE, -3.0f); this->actor.speedXZ = 0.0f; this->actor.gravity = 0.0f; func_808D08D0(this); - Actor_SpawnFloorDustRing(globalCtx, &this->actor, &this->actor.world.pos, 15.0f, 6, 20.0f, 300, 100, 1); + Actor_SpawnFloorDustRing(play, &this->actor, &this->actor.world.pos, 15.0f, 6, 20.0f, 300, 100, 1); Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_FLOORMASTER_ATTACK); this->actionFunc = func_808D1458; } -void func_808D1458(EnFloormas* this, GlobalContext* globalCtx) { +void func_808D1458(EnFloormas* this, PlayState* play) { if (SkelAnime_Update(&this->skelAnime)) { func_808D161C(this); } @@ -438,7 +438,7 @@ void func_808D1458(EnFloormas* this, GlobalContext* globalCtx) { Math_StepToS(&this->unk_192, 1200, 100); } -void func_808D14DC(EnFloormas* this, GlobalContext* globalCtx) { +void func_808D14DC(EnFloormas* this, PlayState* play) { Vec3f sp34; Vec3f sp28; @@ -450,10 +450,10 @@ void func_808D14DC(EnFloormas* this, GlobalContext* globalCtx) { sp28.x = Math_SinS(this->actor.shape.rot.y + 0x6000) * 7.0f; sp28.z = Math_CosS(this->actor.shape.rot.y + 0x6000) * 7.0f; - func_800B1210(globalCtx, &sp34, &sp28, &gZeroVec3f, 0x1C2, 0x64); + func_800B1210(play, &sp34, &sp28, &gZeroVec3f, 0x1C2, 0x64); sp28.x = Math_SinS(this->actor.shape.rot.y - 0x6000) * 7.0f; sp28.z = Math_CosS(this->actor.shape.rot.y - 0x6000) * 7.0f; - func_800B1210(globalCtx, &sp34, &sp28, &gZeroVec3f, 0x1C2, 0x64); + func_800B1210(play, &sp34, &sp28, &gZeroVec3f, 0x1C2, 0x64); func_800B9010(&this->actor, NA_SE_EN_FLOORMASTER_SLIDING - SFX_FLAG); } @@ -464,7 +464,7 @@ void func_808D161C(EnFloormas* this) { this->actionFunc = func_808D1650; } -void func_808D1650(EnFloormas* this, GlobalContext* globalCtx) { +void func_808D1650(EnFloormas* this, PlayState* play) { f32 temp_f0_2; if (this->unk_18E != 0) { @@ -482,7 +482,7 @@ void func_808D1650(EnFloormas* this, GlobalContext* globalCtx) { } if (temp_f0_2 < 12.0f) { - func_808D14DC(this, globalCtx); + func_808D14DC(this, play); } if ((this->actor.bgCheckFlags & 8) || (this->unk_18E == 0)) { @@ -501,7 +501,7 @@ void func_808D1740(EnFloormas* this) { this->actionFunc = func_808D17EC; } -void func_808D17EC(EnFloormas* this, GlobalContext* globalCtx) { +void func_808D17EC(EnFloormas* this, PlayState* play) { s32 sp24 = this->actor.bgCheckFlags & 1; if (this->actor.bgCheckFlags & 2) { @@ -527,7 +527,7 @@ void func_808D17EC(EnFloormas* this, GlobalContext* globalCtx) { } if ((this->actor.speedXZ > 0.0f) && ((this->actor.world.pos.y - this->actor.floorHeight) < 12.0f)) { - func_808D14DC(this, globalCtx); + func_808D14DC(this, play); } if (SkelAnime_Update(&this->skelAnime)) { @@ -580,7 +580,7 @@ void func_808D19D4(EnFloormas* this) { this->actionFunc = func_808D1B44; } -void func_808D1B44(EnFloormas* this, GlobalContext* globalCtx) { +void func_808D1B44(EnFloormas* this, PlayState* play) { if (this->actor.bgCheckFlags & 1) { if (SkelAnime_Update(&this->skelAnime)) { this->actor.flags |= ACTOR_FLAG_1; @@ -600,7 +600,7 @@ void func_808D1BCC(EnFloormas* this) { this->actionFunc = func_808D1C1C; } -void func_808D1C1C(EnFloormas* this, GlobalContext* globalCtx) { +void func_808D1C1C(EnFloormas* this, PlayState* play) { SkelAnime_Update(&this->skelAnime); if (this->unk_194 != 0) { this->unk_194--; @@ -628,7 +628,7 @@ void func_808D1D0C(EnFloormas* this) { this->actionFunc = func_808D1D6C; } -void func_808D1D6C(EnFloormas* this, GlobalContext* globalCtx) { +void func_808D1D6C(EnFloormas* this, PlayState* play) { Actor* sp2C; s32 flags; @@ -664,7 +664,7 @@ void func_808D1D6C(EnFloormas* this, GlobalContext* globalCtx) { } } -void func_808D1ED4(EnFloormas* this, GlobalContext* globalCtx) { +void func_808D1ED4(EnFloormas* this, PlayState* play) { Vec3f sp34; this->actor.speedXZ = 0.0f; @@ -672,12 +672,12 @@ void func_808D1ED4(EnFloormas* this, GlobalContext* globalCtx) { sp34.x = this->actor.world.pos.x; sp34.y = this->actor.world.pos.y + 15.0f; sp34.z = this->actor.world.pos.z; - func_800B3030(globalCtx, &sp34, &gZeroVec3f, &gZeroVec3f, 150, -10, 2); - SoundSource_PlaySfxAtFixedWorldPos(globalCtx, &this->actor.world.pos, 11, NA_SE_EN_EXTINCT); + func_800B3030(play, &sp34, &gZeroVec3f, &gZeroVec3f, 150, -10, 2); + SoundSource_PlaySfxAtFixedWorldPos(play, &this->actor.world.pos, 11, NA_SE_EN_EXTINCT); this->actionFunc = func_808D1F7C; } -void func_808D1F7C(EnFloormas* this, GlobalContext* globalCtx) { +void func_808D1F7C(EnFloormas* this, PlayState* play) { if (Math_StepToF(&this->actor.scale.x, 0.0f, 0.0015f)) { func_808D2A20(this); } @@ -690,8 +690,8 @@ void func_808D1FD4(EnFloormas* this) { this->actionFunc = func_808D2040; } -void func_808D2040(EnFloormas* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); +void func_808D2040(EnFloormas* this, PlayState* play) { + Player* player = GET_PLAYER(play); SkelAnime_Update(&this->skelAnime); if (this->skelAnime.curFrame < 20.0f) { @@ -706,22 +706,20 @@ void func_808D2040(EnFloormas* this, GlobalContext* globalCtx) { func_808D1740(this); } else if ((this->actor.playerHeightRel < -10.0f) && (this->collider.base.ocFlags1 & OC1_HIT) && (&player->actor == this->collider.base.oc)) { - globalCtx->grabPlayer(globalCtx, player); + play->grabPlayer(play, player); func_808D217C(this, player); } } void func_808D217C(EnFloormas* this, Player* player) { Vec3f* ptr; - u8 playerForm; 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.save.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); @@ -730,8 +728,8 @@ void func_808D217C(EnFloormas* this, Player* player) { this->actionFunc = func_808D22C8; } -void func_808D22C8(EnFloormas* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); +void func_808D22C8(EnFloormas* this, PlayState* play) { + Player* player = GET_PLAYER(play); if (SkelAnime_Update(&this->skelAnime)) { if (this->skelAnime.playSpeed > 0.0f) { @@ -765,7 +763,7 @@ void func_808D22C8(EnFloormas* this, GlobalContext* globalCtx) { func_808D1740(this); } else if ((this->unk_190 % 20) == 0) { func_800B8E58(player, NA_SE_VO_LI_DAMAGE_S + player->ageProperties->unk_92); - globalCtx->damagePlayer(globalCtx, -4); + play->damagePlayer(play, -4); } Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_FLOORMASTER_SM_STICK - SFX_FLAG); } @@ -776,7 +774,7 @@ void func_808D2484(EnFloormas* this) { this->actionFunc = func_808D24F0; } -void func_808D24F0(EnFloormas* this, GlobalContext* globalCtx) { +void func_808D24F0(EnFloormas* this, PlayState* play) { Actor* phi_s1; SkelAnime_Update(&this->skelAnime); @@ -824,7 +822,7 @@ void func_808D2700(EnFloormas* this) { this->actionFunc = func_808D2764; } -void func_808D2764(EnFloormas* this, GlobalContext* globalCtx) { +void func_808D2764(EnFloormas* this, PlayState* play) { EnFloormas* parent; EnFloormas* child; s32 phi_a2 = 0; @@ -838,10 +836,10 @@ void func_808D2764(EnFloormas* this, GlobalContext* globalCtx) { child = (EnFloormas*)this->actor.child; if (this->unk_194 == 0) { if (parent->actionFunc != func_808D2AA8) { - func_808D1ED4(parent, globalCtx); + func_808D1ED4(parent, play); } if (child->actionFunc != func_808D2AA8) { - func_808D1ED4(child, globalCtx); + func_808D1ED4(child, play); } } else { if ((parent->actionFunc != func_808D2AA8) && (parent->actionFunc != func_808D1F7C)) { @@ -908,7 +906,7 @@ void func_808D2A20(EnFloormas* this) { } } -void func_808D2AA8(EnFloormas* this, GlobalContext* globalCtx) { +void func_808D2AA8(EnFloormas* this, PlayState* play) { } void func_808D2AB8(EnFloormas* this) { @@ -918,7 +916,7 @@ void func_808D2AB8(EnFloormas* this) { this->actionFunc = func_808D2AF4; } -void func_808D2AF4(EnFloormas* this, GlobalContext* globalCtx) { +void func_808D2AF4(EnFloormas* this, PlayState* play) { Actor_MarkForDeath(&this->actor); } @@ -945,10 +943,10 @@ void func_808D2B18(EnFloormas* this) { this->actionFunc = func_808D2C08; } -void func_808D2C08(EnFloormas* this, GlobalContext* globalCtx) { +void func_808D2C08(EnFloormas* this, PlayState* play) { if (SkelAnime_Update(&this->skelAnime) && (this->actor.bgCheckFlags & 1)) { if (this->actor.colChkInfo.health == 0) { - func_808D0930(this, globalCtx); + func_808D0930(this, play); } else { func_808D2CDC(this); } @@ -973,7 +971,7 @@ void func_808D2CDC(EnFloormas* this) { this->actionFunc = func_808D2D30; } -void func_808D2D30(EnFloormas* this, GlobalContext* globalCtx) { +void func_808D2D30(EnFloormas* this, PlayState* play) { if (SkelAnime_Update(&this->skelAnime)) { func_808D0C14(this); } @@ -988,23 +986,23 @@ void func_808D2D6C(EnFloormas* this) { this->actionFunc = func_808D2DC0; } -void func_808D2DC0(EnFloormas* this, GlobalContext* globalCtx) { +void func_808D2DC0(EnFloormas* this, PlayState* play) { if (this->unk_18E != 0) { this->unk_18E--; } if (this->unk_18E == 0) { - func_808D0A48(this, globalCtx); + func_808D0A48(this, play); if (this->actor.colChkInfo.health == 0) { this->collider.base.acFlags |= AC_ON; - func_808D0930(this, globalCtx); + func_808D0930(this, play); } else { func_808D0C14(this); } } } -void func_808D2E34(EnFloormas* this, GlobalContext* globalCtx) { +void func_808D2E34(EnFloormas* this, PlayState* play) { if (this->collider.base.acFlags & AC_HIT) { this->collider.base.acFlags &= ~AC_HIT; Actor_SetDropFlag(&this->actor, &this->collider.info); @@ -1028,13 +1026,13 @@ void func_808D2E34(EnFloormas* this, GlobalContext* globalCtx) { } else { Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_FLOORMASTER_SM_DEAD); } - Enemy_StartFinishingBlow(globalCtx, &this->actor); + Enemy_StartFinishingBlow(play, &this->actor); this->actor.flags &= ~ACTOR_FLAG_1; } else if (this->actor.colChkInfo.damage != 0) { Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_FALL_DAMAGE); } - func_808D0A48(this, globalCtx); + func_808D0A48(this, play); if (this->actor.colChkInfo.damageEffect != 0xF) { if (this->actor.colChkInfo.damageEffect == 3) { @@ -1066,9 +1064,9 @@ void func_808D2E34(EnFloormas* this, GlobalContext* globalCtx) { 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, + Actor_Spawn(&play->actorCtx, play, ACTOR_EN_CLEAR_TAG, this->collider.info.bumper.hitPos.x, + this->collider.info.bumper.hitPos.y, this->collider.info.bumper.hitPos.z, 0, 0, + 0, (this->actor.scale.x > 0.009f) ? CLEAR_TAG_LARGE_LIGHT_RAYS : CLEAR_TAG_SMALL_LIGHT_RAYS); } @@ -1080,7 +1078,7 @@ void func_808D2E34(EnFloormas* this, GlobalContext* globalCtx) { } } -void EnFloormas_Update(Actor* thisx, GlobalContext* globalCtx) { +void EnFloormas_Update(Actor* thisx, PlayState* play) { EnFloormas* this = THIS; s32 pad; @@ -1093,8 +1091,8 @@ void EnFloormas_Update(Actor* thisx, GlobalContext* globalCtx) { func_808D1740(this); } - func_808D2E34(this, globalCtx); - this->actionFunc(this, globalCtx); + func_808D2E34(this, play); + this->actionFunc(this, play); if (this->actionFunc != func_808D2AF4) { if (this->actionFunc != func_808D2C08) { this->actor.world.rot.y = this->actor.shape.rot.y; @@ -1104,21 +1102,21 @@ void EnFloormas_Update(Actor* thisx, GlobalContext* globalCtx) { Actor_MoveWithGravity(&this->actor); } - Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 20.0f, this->actor.scale.x * 3000.0f, 0.0f, 0x1D); + Actor_UpdateBgCheckInfo(play, &this->actor, 20.0f, this->actor.scale.x * 3000.0f, 0.0f, 0x1D); Collider_UpdateCylinder(&this->actor, &this->collider); if (this->actionFunc == func_808D1650) { this->actor.flags |= ACTOR_FLAG_1000000; - CollisionCheck_SetAT(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + CollisionCheck_SetAT(play, &play->colChkCtx, &this->collider.base); } if (this->actionFunc != func_808D22C8) { if ((this->actionFunc != func_808D1B44) && (this->actionFunc != func_808D2C08) && (this->actionFunc != func_808D1F7C)) { - CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + CollisionCheck_SetAC(play, &play->colChkCtx, &this->collider.base); } if ((this->actionFunc != func_808D24F0) || (this->skelAnime.curFrame < 20.0f)) { - CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + CollisionCheck_SetOC(play, &play->colChkCtx, &this->collider.base); } } @@ -1146,8 +1144,8 @@ void EnFloormas_Update(Actor* thisx, GlobalContext* globalCtx) { } } -s32 EnFloormas_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, - Actor* thisx, Gfx** gfx) { +s32 EnFloormas_OverrideLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, Actor* thisx, + Gfx** gfx) { EnFloormas* this = THIS; if (limbIndex == WALLMASTER_LIMB_ROOT) { @@ -1157,76 +1155,75 @@ s32 EnFloormas_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** d return false; } -void EnFloormas_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx, - Gfx** gfx) { +void EnFloormas_PostLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx, Gfx** gfx) { EnFloormas* this = THIS; if (D_808D393C[limbIndex] != -1) { - Matrix_GetStateTranslation(&this->limbPos[D_808D393C[limbIndex]]); + Matrix_MultZero(&this->limbPos[D_808D393C[limbIndex]]); } if (limbIndex == WALLMASTER_LIMB_WRIST) { - Matrix_GetStateTranslationAndScaledX(1000.0f, &this->limbPos[9]); - Matrix_GetStateTranslationAndScaledX(-1000.0f, &this->limbPos[10]); + Matrix_MultVecX(1000.0f, &this->limbPos[9]); + Matrix_MultVecX(-1000.0f, &this->limbPos[10]); } else if (limbIndex == WALLMASTER_LIMB_HAND) { - Matrix_StatePush(); - Matrix_InsertTranslation(1600.0f, -700.0f, -1700.0f, MTXMODE_APPLY); - Matrix_InsertYRotation_f(M_PI / 3, MTXMODE_APPLY); - Matrix_InsertZRotation_f(M_PI / 12, MTXMODE_APPLY); + 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); + gSPMatrix((*gfx)++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList((*gfx)++, gWallmasterLittleFingerDL); - Matrix_StatePop(); + Matrix_Pop(); } } -void EnFloormas_Draw(Actor* thisx, GlobalContext* globalCtx) { +void EnFloormas_Draw(Actor* thisx, PlayState* play) { EnFloormas* this = THIS; - OPEN_DISPS(globalCtx->state.gfxCtx); + OPEN_DISPS(play->state.gfxCtx); - func_8012C28C(globalCtx->state.gfxCtx); + func_8012C28C(play->state.gfxCtx); if (this->collider.base.colType == COLTYPE_HARD) { - func_800AE2A0(globalCtx, &D_808D3958, this->unk_190 % 40, 40); + func_800AE2A0(play, &D_808D3958, this->unk_190 % 40, 40); } POLY_OPA_DISP = - SkelAnime_DrawFlex(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, + SkelAnime_DrawFlex(play, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, EnFloormas_OverrideLimbDraw, EnFloormas_PostLimbDraw, &this->actor, POLY_OPA_DISP); if (this->collider.base.colType == COLTYPE_HARD) { - func_800AE5A0(globalCtx); + func_800AE5A0(play); } - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->state.gfxCtx); - Actor_DrawDamageEffects(globalCtx, &this->actor, this->limbPos, ARRAY_COUNT(this->limbPos), + Actor_DrawDamageEffects(play, &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) { +void func_808D3754(Actor* thisx, PlayState* play) { EnFloormas* this = THIS; - OPEN_DISPS(globalCtx->state.gfxCtx); + OPEN_DISPS(play->state.gfxCtx); - func_8012C2DC(globalCtx->state.gfxCtx); + func_8012C2DC(play->state.gfxCtx); if (this->collider.base.colType == COLTYPE_HARD) { - func_800AE5E4(globalCtx, &D_808D3958, this->unk_190 % 40, 40); + func_800AE5E4(play, &D_808D3958, this->unk_190 % 40, 40); } POLY_XLU_DISP = - SkelAnime_DrawFlex(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, + SkelAnime_DrawFlex(play, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, EnFloormas_OverrideLimbDraw, EnFloormas_PostLimbDraw, &this->actor, POLY_XLU_DISP); if (this->collider.base.colType == COLTYPE_HARD) { - func_800AE8EC(globalCtx); + func_800AE8EC(play); } - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->state.gfxCtx); - Actor_DrawDamageEffects(globalCtx, &this->actor, this->limbPos, ARRAY_COUNT(this->limbPos), + Actor_DrawDamageEffects(play, &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 5c33ba886..c4500973f 100644 --- a/src/overlays/actors/ovl_En_Floormas/z_en_floormas.h +++ b/src/overlays/actors/ovl_En_Floormas/z_en_floormas.h @@ -6,7 +6,7 @@ struct EnFloormas; -typedef void (*EnFloormasActionFunc)(struct EnFloormas*, GlobalContext*); +typedef void (*EnFloormasActionFunc)(struct EnFloormas*, PlayState*); #define ENFLOORMAS_GET_7FFF(thisx) ((thisx)->params & 0x7FFF) #define ENFLOORMAS_GET_8000(thisx) ((thisx)->params & 0x8000) @@ -19,21 +19,21 @@ enum { }; typedef struct EnFloormas { - /* 0x0000 */ Actor actor; - /* 0x0144 */ SkelAnime skelAnime; - /* 0x0188 */ EnFloormasActionFunc actionFunc; - /* 0x018C */ u8 drawDmgEffType; - /* 0x018E */ s16 unk_18E; - /* 0x0190 */ s16 unk_190; - /* 0x0192 */ s16 unk_192; - /* 0x0194 */ s16 unk_194; - /* 0x0196 */ Vec3s jointTable[WALLMASTER_LIMB_MAX]; - /* 0x022C */ Vec3s morphTable[WALLMASTER_LIMB_MAX]; - /* 0x02C4 */ f32 drawDmgEffAlpha; - /* 0x02C8 */ f32 drawDmgEffScale; - /* 0x02CC */ f32 drawDmgEffFrozenSteamScale; - /* 0x02D0 */ Vec3f limbPos[11]; - /* 0x0354 */ ColliderCylinder collider; + /* 0x000 */ Actor actor; + /* 0x144 */ SkelAnime skelAnime; + /* 0x188 */ EnFloormasActionFunc actionFunc; + /* 0x18C */ u8 drawDmgEffType; + /* 0x18E */ s16 unk_18E; + /* 0x190 */ s16 unk_190; + /* 0x192 */ s16 unk_192; + /* 0x194 */ s16 unk_194; + /* 0x196 */ Vec3s jointTable[WALLMASTER_LIMB_MAX]; + /* 0x22C */ Vec3s morphTable[WALLMASTER_LIMB_MAX]; + /* 0x2C4 */ f32 drawDmgEffAlpha; + /* 0x2C8 */ f32 drawDmgEffScale; + /* 0x2CC */ f32 drawDmgEffFrozenSteamScale; + /* 0x2D0 */ Vec3f limbPos[11]; + /* 0x354 */ ColliderCylinder collider; } EnFloormas; // size = 0x3A0 extern const ActorInit En_Floormas_InitVars; diff --git a/src/overlays/actors/ovl_En_Fr/z_en_fr.c b/src/overlays/actors/ovl_En_Fr/z_en_fr.c index 34b43ef66..a8276e649 100644 --- a/src/overlays/actors/ovl_En_Fr/z_en_fr.c +++ b/src/overlays/actors/ovl_En_Fr/z_en_fr.c @@ -10,9 +10,9 @@ #define THIS ((EnFr*)thisx) -void EnFr_Init(Actor* thisx, GlobalContext* globalCtx); -void EnFr_Destroy(Actor* thisx, GlobalContext* globalCtx); -void EnFr_Update(Actor* thisx, GlobalContext* globalCtx); +void EnFr_Init(Actor* thisx, PlayState* play); +void EnFr_Destroy(Actor* thisx, PlayState* play); +void EnFr_Update(Actor* thisx, PlayState* play); const ActorInit En_Fr_InitVars = { ACTOR_EN_FR, @@ -26,23 +26,23 @@ const ActorInit En_Fr_InitVars = { (ActorFunc)NULL, }; -void EnFr_Init(Actor* thisx, GlobalContext* globalCtx) { +void EnFr_Init(Actor* thisx, PlayState* play) { EnFr* this = THIS; - if (Flags_GetSwitch(globalCtx, ENFR_GET_SWITCHFLAG(&this->actor))) { + if (Flags_GetSwitch(play, ENFR_GET_SWITCHFLAG(&this->actor))) { Actor_MarkForDeath(&this->actor); } else { this->actor.targetMode = ENFR_GET_TARGETMODE(&this->actor); } } -void EnFr_Destroy(Actor* thisx, GlobalContext* globalCtx) { +void EnFr_Destroy(Actor* thisx, PlayState* play) { } -void EnFr_Update(Actor* thisx, GlobalContext* globalCtx) { +void EnFr_Update(Actor* thisx, PlayState* play) { EnFr* this = THIS; - if (Flags_GetSwitch(globalCtx, ENFR_GET_SWITCHFLAG(&this->actor))) { + if (Flags_GetSwitch(play, ENFR_GET_SWITCHFLAG(&this->actor))) { Actor_MarkForDeath(&this->actor); } else if (this->actor.xyzDistToPlayerSq < SQ(IREG(29))) { 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 a69730bed..fe7a91667 100644 --- a/src/overlays/actors/ovl_En_Fsn/z_en_fsn.c +++ b/src/overlays/actors/ovl_En_Fsn/z_en_fsn.c @@ -18,33 +18,33 @@ #define ENFSN_GAVE_KEATONS_MASK (1 << 2) #define ENFSN_GAVE_LETTER_TO_MAMA (1 << 3) -void EnFsn_Init(Actor* thisx, GlobalContext* globalCtx); -void EnFsn_Destroy(Actor* thisx, GlobalContext* globalCtx); -void EnFsn_Update(Actor* thisx, GlobalContext* globalCtx); -void EnFsn_Draw(Actor* thisx, GlobalContext* globalCtx); +void EnFsn_Init(Actor* thisx, PlayState* play); +void EnFsn_Destroy(Actor* thisx, PlayState* play); +void EnFsn_Update(Actor* thisx, PlayState* play); +void EnFsn_Draw(Actor* thisx, PlayState* play); -void EnFsn_Idle(EnFsn* this, GlobalContext* globalCtx); -void EnFsn_ConverseBackroom(EnFsn* this, GlobalContext* globalCtx); -void EnFsn_Haggle(EnFsn* this, GlobalContext* globalCtx); -void EnFsn_BeginInteraction(EnFsn* this, GlobalContext* globalCtx); -void EnFsn_GiveItem(EnFsn* this, GlobalContext* globalCtx); -void EnFsn_AskBuyOrSell(EnFsn* this, GlobalContext* globalCtx); -void EnFsn_StartBuying(EnFsn* this, GlobalContext* globalCtx); -void EnFsn_SetupEndInteractionImmediately(EnFsn* this, GlobalContext* globalCtx); -void EnFsn_SetupResumeInteraction(EnFsn* this, GlobalContext* globalCtx); -void EnFsn_FaceShopkeeperSelling(EnFsn* this, GlobalContext* globalCtx); -void EnFsn_DeterminePrice(EnFsn* this, GlobalContext* globalCtx); -void EnFsn_SetupDeterminePrice(EnFsn* this, GlobalContext* globalCtx); -void EnFsn_SetupEndInteraction(EnFsn* this, GlobalContext* globalCtx); -void EnFsn_MakeOffer(EnFsn* this, GlobalContext* globalCtx); -void EnFsn_ResumeInteraction(EnFsn* this, GlobalContext* globalCtx); -void EnFsn_BrowseShelf(EnFsn* this, GlobalContext* globalCtx); -void EnFsn_ResumeShoppingInteraction(EnFsn* this, GlobalContext* globalCtx); -void EnFsn_AskCanBuyMore(EnFsn* this, GlobalContext* globalCtx); -void EnFsn_AskCanBuyAterRunningOutOfItems(EnFsn* this, GlobalContext* globalCtx); -void EnFsn_SelectItem(EnFsn* this, GlobalContext* globalCtx); -void EnFsn_LookToShopkeeperFromShelf(EnFsn* this, GlobalContext* globalCtx); -void EnFsn_PlayerCannotBuy(EnFsn* this, GlobalContext* globalCtx); +void EnFsn_Idle(EnFsn* this, PlayState* play); +void EnFsn_ConverseBackroom(EnFsn* this, PlayState* play); +void EnFsn_Haggle(EnFsn* this, PlayState* play); +void EnFsn_BeginInteraction(EnFsn* this, PlayState* play); +void EnFsn_GiveItem(EnFsn* this, PlayState* play); +void EnFsn_AskBuyOrSell(EnFsn* this, PlayState* play); +void EnFsn_StartBuying(EnFsn* this, PlayState* play); +void EnFsn_SetupEndInteractionImmediately(EnFsn* this, PlayState* play); +void EnFsn_SetupResumeInteraction(EnFsn* this, PlayState* play); +void EnFsn_FaceShopkeeperSelling(EnFsn* this, PlayState* play); +void EnFsn_DeterminePrice(EnFsn* this, PlayState* play); +void EnFsn_SetupDeterminePrice(EnFsn* this, PlayState* play); +void EnFsn_SetupEndInteraction(EnFsn* this, PlayState* play); +void EnFsn_MakeOffer(EnFsn* this, PlayState* play); +void EnFsn_ResumeInteraction(EnFsn* this, PlayState* play); +void EnFsn_BrowseShelf(EnFsn* this, PlayState* play); +void EnFsn_ResumeShoppingInteraction(EnFsn* this, PlayState* play); +void EnFsn_AskCanBuyMore(EnFsn* this, PlayState* play); +void EnFsn_AskCanBuyAterRunningOutOfItems(EnFsn* this, PlayState* play); +void EnFsn_SelectItem(EnFsn* this, PlayState* play); +void EnFsn_LookToShopkeeperFromShelf(EnFsn* this, PlayState* play); +void EnFsn_PlayerCannotBuy(EnFsn* this, PlayState* play); typedef enum { /* 0 */ ENFSN_CUTSCENESTATE_STOPPED, @@ -53,20 +53,20 @@ typedef enum { } EnFsnCutsceneState; typedef enum { - /* 00 */ FSN_ANIMATION_IDLE, - /* 01 */ FSN_ANIMATION_SCRATCH_BACK, - /* 02 */ FSN_ANIMATION_TURN_AROUND_FORWARD, - /* 03 */ FSN_ANIMATION_TURN_AROUND_REVERSE, - /* 04 */ FSN_ANIMATION_HANDS_ON_COUNTER_START, - /* 05 */ FSN_ANIMATION_HANDS_ON_COUNTER_LOOP, - /* 06 */ FSN_ANIMATION_HAND_ON_FACE_START, - /* 07 */ FSN_ANIMATION_HAND_ON_FACE_LOOP, - /* 08 */ FSN_ANIMATION_LEAN_FORWARD_START, - /* 09 */ FSN_ANIMATION_LEAN_FORWARD_LOOP, - /* 10 */ FSN_ANIMATION_SLAM_COUNTER_START, - /* 11 */ FSN_ANIMATION_SLAM_COUNTER_LOOP, - /* 12 */ FSN_ANIMATION_MAKE_OFFER, - /* 13 */ FSN_ANIMATION_MAX + /* 0 */ FSN_ANIM_IDLE, + /* 1 */ FSN_ANIM_SCRATCH_BACK, + /* 2 */ FSN_ANIM_TURN_AROUND_FORWARD, + /* 3 */ FSN_ANIM_TURN_AROUND_REVERSE, + /* 4 */ FSN_ANIM_HANDS_ON_COUNTER_START, + /* 5 */ FSN_ANIM_HANDS_ON_COUNTER_LOOP, + /* 6 */ FSN_ANIM_HAND_ON_FACE_START, + /* 7 */ FSN_ANIM_HAND_ON_FACE_LOOP, + /* 8 */ FSN_ANIM_LEAN_FORWARD_START, + /* 9 */ FSN_ANIM_LEAN_FORWARD_LOOP, + /* 10 */ FSN_ANIM_SLAM_COUNTER_START, + /* 11 */ FSN_ANIM_SLAM_COUNTER_LOOP, + /* 12 */ FSN_ANIM_MAKE_OFFER, + /* 13 */ FSN_ANIM_MAX } FsnAnimation; const ActorInit En_Fsn_InitVars = { @@ -81,7 +81,7 @@ const ActorInit En_Fsn_InitVars = { (ActorFunc)EnFsn_Draw, }; -static AnimationInfoS sAnimations[] = { +static AnimationInfoS sAnimationInfo[] = { { &gFsnIdleAnim, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, { &gFsnScratchBackAnim, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, { &gFsnTurnAroundAnim, 1.0f, 0, -1, ANIMMODE_ONCE, 0 }, @@ -123,19 +123,19 @@ static Vec3f sShopItemPositions[3] = { { 31.0f, 35.0f, -95.0f }, }; -s32 EnFsn_TestItemSelected(GlobalContext* globalCtx) { - MessageContext* msgCtx = &globalCtx->msgCtx; +s32 EnFsn_TestItemSelected(PlayState* play) { + MessageContext* msgCtx = &play->msgCtx; if (msgCtx->unk12020 == 0x10 || msgCtx->unk12020 == 0x11) { - return CHECK_BTN_ALL(CONTROLLER1(globalCtx)->press.button, BTN_A); + return CHECK_BTN_ALL(CONTROLLER1(&play->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(&play->state)->press.button, BTN_A) || + CHECK_BTN_ALL(CONTROLLER1(&play->state)->press.button, BTN_B) || + CHECK_BTN_ALL(CONTROLLER1(&play->state)->press.button, BTN_CUP); } -u16 EnFsn_GetWelcome(GlobalContext* globalCtx) { - switch (Player_GetMask(globalCtx)) { +u16 EnFsn_GetWelcome(PlayState* play) { + switch (Player_GetMask(play)) { case PLAYER_MASK_NONE: return 0x29CC; case PLAYER_MASK_DEKU: @@ -150,7 +150,7 @@ u16 EnFsn_GetWelcome(GlobalContext* globalCtx) { } } -void EnFsn_HandleConversationBackroom(EnFsn* this, GlobalContext* globalCtx) { +void EnFsn_HandleConversationBackroom(EnFsn* this, PlayState* play) { switch (this->textId) { case 0: if (!(gSaveContext.save.weekEventReg[80] & 0x10)) { @@ -194,25 +194,25 @@ void EnFsn_HandleConversationBackroom(EnFsn* this, GlobalContext* globalCtx) { this->flags |= ENFSN_END_CONVERSATION; break; } - Message_StartTextbox(globalCtx, this->textId, &this->actor); + Message_StartTextbox(play, 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; - func_80151BB4(globalCtx, 34); + func_80151BB4(play, 34); } if (this->flags & ENFSN_GAVE_KEATONS_MASK) { this->flags &= ~ENFSN_GAVE_KEATONS_MASK; - func_80151BB4(globalCtx, 33); + func_80151BB4(play, 33); } - func_80151BB4(globalCtx, 3); + func_80151BB4(play, 3); } } -void EnFsn_HandleSetupResumeInteraction(EnFsn* this, GlobalContext* globalCtx) { - if (Message_GetState(&globalCtx->msgCtx) == 6 && Message_ShouldAdvance(globalCtx) && +void EnFsn_HandleSetupResumeInteraction(EnFsn* this, PlayState* play) { + if ((Message_GetState(&play->msgCtx) == TEXT_STATE_DONE) && Message_ShouldAdvance(play) && this->cutsceneState == ENFSN_CUTSCENESTATE_STOPPED) { - Actor_ProcessTalkRequest(&this->actor, &globalCtx->state); - func_800B85E0(&this->actor, globalCtx, 400.0f, EXCH_ITEM_MINUS1); + Actor_ProcessTalkRequest(&this->actor, &play->state); + func_800B85E0(&this->actor, play, 400.0f, PLAYER_AP_MINUS1); if (ENFSN_IS_SHOP(&this->actor)) { this->actor.textId = 0; } @@ -220,11 +220,11 @@ void EnFsn_HandleSetupResumeInteraction(EnFsn* this, GlobalContext* globalCtx) { } } -void EnFsn_UpdateCollider(EnFsn* this, GlobalContext* globalCtx) { +void EnFsn_UpdateCollider(EnFsn* this, PlayState* play) { this->collider.dim.pos.x = this->actor.world.pos.x; this->collider.dim.pos.y = this->actor.world.pos.y; this->collider.dim.pos.z = this->actor.world.pos.z; - CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + CollisionCheck_SetOC(play, &play->colChkCtx, &this->collider.base); } void EnFsn_HandleLookToShopkeeperBuyingCutscene(EnFsn* this) { @@ -370,7 +370,7 @@ void EnFsn_GetShopItemIds(EnFsn* this) { this->numSellingItems = this->totalSellingItems; } -void EnFsn_SpawnShopItems(EnFsn* this, GlobalContext* globalCtx) { +void EnFsn_SpawnShopItems(EnFsn* this, PlayState* play) { s32 i; EnFsn_GetShopItemIds(this); @@ -379,64 +379,64 @@ void EnFsn_SpawnShopItems(EnFsn* this, GlobalContext* globalCtx) { this->items[i] = NULL; } else { this->items[i] = - (EnGirlA*)Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_GIRLA, sShopItemPositions[i].x, + (EnGirlA*)Actor_Spawn(&play->actorCtx, play, ACTOR_EN_GIRLA, sShopItemPositions[i].x, sShopItemPositions[i].y, sShopItemPositions[i].z, 0, 0, 0, this->itemIds[i]); } } } -void EnFsn_EndInteraction(EnFsn* this, GlobalContext* globalCtx) { +void EnFsn_EndInteraction(EnFsn* this, PlayState* play) { if (this->cutsceneState == ENFSN_CUTSCENESTATE_PLAYING) { ActorCutscene_Stop(this->cutscene); this->cutsceneState = ENFSN_CUTSCENESTATE_STOPPED; } - Actor_ProcessTalkRequest(&this->actor, &globalCtx->state); - globalCtx->msgCtx.msgMode = 0x43; - globalCtx->msgCtx.unk12023 = 4; + Actor_ProcessTalkRequest(&this->actor, &play->state); + play->msgCtx.msgMode = 0x43; + play->msgCtx.stateTimer = 4; Interface_ChangeAlpha(50); this->drawCursor = 0; this->stickLeftPrompt.isEnabled = false; this->stickRightPrompt.isEnabled = false; - globalCtx->interfaceCtx.unk_222 = 0; - globalCtx->interfaceCtx.unk_224 = 0; + play->interfaceCtx.unk_222 = 0; + play->interfaceCtx.unk_224 = 0; this->actor.textId = 0; this->actionFunc = EnFsn_Idle; } -s32 EnFsn_TestEndInteraction(EnFsn* this, GlobalContext* globalCtx, Input* input) { +s32 EnFsn_TestEndInteraction(EnFsn* this, PlayState* play, Input* input) { if (CHECK_BTN_ALL(input->press.button, BTN_B)) { this->actor.textId = (CURRENT_DAY == 3) ? 0x29DF : 0x29D1; - Message_StartTextbox(globalCtx, this->actor.textId, &this->actor); - func_80151BB4(globalCtx, 3); + Message_StartTextbox(play, this->actor.textId, &this->actor); + func_80151BB4(play, 3); this->actionFunc = EnFsn_SetupEndInteraction; return true; } return false; } -s32 EnFsn_TestCancelOption(EnFsn* this, GlobalContext* globalCtx, Input* input) { +s32 EnFsn_TestCancelOption(EnFsn* this, PlayState* play, Input* input) { if (CHECK_BTN_ALL(input->press.button, BTN_B)) { - this->actionFunc = this->tmpActionFunc; - func_80151938(globalCtx, this->items[this->cursorIdx]->actor.textId); + this->actionFunc = this->prevActionFunc; + func_80151938(play, this->items[this->cursorIdx]->actor.textId); return true; } return false; } -void EnFsn_UpdateCursorPos(EnFsn* this, GlobalContext* globalCtx) { +void EnFsn_UpdateCursorPos(EnFsn* this, PlayState* play) { s16 x; s16 y; f32 xOffset = 0.0f; f32 yOffset = 17.0f; - Actor_GetScreenPos(globalCtx, &this->items[this->cursorIdx]->actor, &x, &y); + Actor_GetScreenPos(play, &this->items[this->cursorIdx]->actor, &x, &y); this->cursorPos.x = x + xOffset; this->cursorPos.y = y + yOffset; this->cursorPos.z = 1.2f; } -s32 EnFsn_FacingShopkeeperDialogResult(EnFsn* this, GlobalContext* globalCtx) { - switch (globalCtx->msgCtx.choiceIndex) { +s32 EnFsn_FacingShopkeeperDialogResult(EnFsn* this, PlayState* play) { + switch (play->msgCtx.choiceIndex) { case 0: func_8019F208(); if (CURRENT_DAY != 3) { @@ -448,27 +448,27 @@ s32 EnFsn_FacingShopkeeperDialogResult(EnFsn* this, GlobalContext* globalCtx) { } else { this->actor.textId = 0x29D8; } - Message_StartTextbox(globalCtx, this->actor.textId, &this->actor); + Message_StartTextbox(play, this->actor.textId, &this->actor); return true; case 1: func_8019F230(); this->actor.textId = (CURRENT_DAY == 3) ? 0x29DF : 0x29D1; - Message_StartTextbox(globalCtx, this->actor.textId, &this->actor); - func_80151BB4(globalCtx, 3); + Message_StartTextbox(play, this->actor.textId, &this->actor); + func_80151BB4(play, 3); this->actionFunc = EnFsn_SetupEndInteraction; return true; } return false; } -s32 EnFsn_HasPlayerSelectedItem(EnFsn* this, GlobalContext* globalCtx, Input* input) { - if (EnFsn_TestEndInteraction(this, globalCtx, input)) { +s32 EnFsn_HasPlayerSelectedItem(EnFsn* this, PlayState* play, Input* input) { + if (EnFsn_TestEndInteraction(this, play, input)) { return true; } - if (EnFsn_TestItemSelected(globalCtx)) { + if (EnFsn_TestItemSelected(play)) { if (!this->items[this->cursorIdx]->isOutOfStock) { - this->tmpActionFunc = this->actionFunc; - func_80151938(globalCtx, this->items[this->cursorIdx]->choiceTextId); + this->prevActionFunc = this->actionFunc; + func_80151938(play, this->items[this->cursorIdx]->choiceTextId); play_sound(NA_SE_SY_DECIDE); this->stickLeftPrompt.isEnabled = false; this->stickRightPrompt.isEnabled = false; @@ -482,9 +482,9 @@ s32 EnFsn_HasPlayerSelectedItem(EnFsn* this, GlobalContext* globalCtx, Input* in return false; } -void EnFsn_UpdateJoystickInputState(EnFsn* this, GlobalContext* globalCtx) { - s8 stickX = CONTROLLER1(globalCtx)->rel.stick_x; - s8 stickY = CONTROLLER1(globalCtx)->rel.stick_y; +void EnFsn_UpdateJoystickInputState(EnFsn* this, PlayState* play) { + s8 stickX = CONTROLLER1(&play->state)->rel.stick_x; + s8 stickY = CONTROLLER1(&play->state)->rel.stick_y; if (this->stickAccumX == 0) { if (stickX > 30 || stickX < -30) { @@ -603,7 +603,7 @@ void EnFsn_UpdateCursorAnim(EnFsn* this) { void EnFsn_UpdateStickDirectionPromptAnim(EnFsn* this) { f32 arrowAnimTween = this->arrowAnimTween; f32 stickAnimTween = this->stickAnimTween; - s32 maxColor = 255; // POSSIBLY FAKE + s32 maxColor = 255; //! FAKE: if (this->arrowAnimState == 0) { arrowAnimTween += 0.05f; @@ -659,9 +659,9 @@ void EnFsn_UpdateStickDirectionPromptAnim(EnFsn* this) { this->stickLeftPrompt.stickTexY = 95.0f; } -void EnFsn_InitShop(EnFsn* this, GlobalContext* globalCtx) { +void EnFsn_InitShop(EnFsn* this, PlayState* play) { if (EnFsn_HasItemsToSell()) { - EnFsn_SpawnShopItems(this, globalCtx); + EnFsn_SpawnShopItems(this, play); this->cursorPos.y = this->cursorPos.x = 100.0f; this->stickAccumY = 0; @@ -711,21 +711,21 @@ void EnFsn_InitShop(EnFsn* this, GlobalContext* globalCtx) { this->stickAnimTween = this->arrowAnimTween = 0.0f; } this->blinkTimer = 20; - this->animationIndex = FSN_ANIMATION_HANDS_ON_COUNTER_START; + this->animIndex = FSN_ANIM_HANDS_ON_COUNTER_START; this->eyeTextureIdx = 0; - SubS_ChangeAnimationByInfoS(&this->skelAnime, sAnimations, this->animationIndex); + SubS_ChangeAnimationByInfoS(&this->skelAnime, sAnimationInfo, this->animIndex); this->actionFunc = EnFsn_Idle; } -void EnFsn_Idle(EnFsn* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); +void EnFsn_Idle(EnFsn* this, PlayState* play) { + Player* player = GET_PLAYER(play); - if (this->animationIndex == FSN_ANIMATION_HANDS_ON_COUNTER_START) { + if (this->animIndex == FSN_ANIM_HANDS_ON_COUNTER_START) { s16 curFrame = this->skelAnime.curFrame; - s16 frameCount = Animation_GetLastFrame(sAnimations[this->animationIndex].animation); + s16 frameCount = Animation_GetLastFrame(sAnimationInfo[this->animIndex].animation); if (curFrame == frameCount) { - this->animationIndex = FSN_ANIMATION_HANDS_ON_COUNTER_LOOP; - SubS_ChangeAnimationByInfoS(&this->skelAnime, sAnimations, this->animationIndex); + this->animIndex = FSN_ANIM_HANDS_ON_COUNTER_LOOP; + SubS_ChangeAnimationByInfoS(&this->skelAnime, sAnimationInfo, this->animIndex); } return; } @@ -735,7 +735,7 @@ void EnFsn_Idle(EnFsn* this, GlobalContext* globalCtx) { return; } - if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { + if (Actor_ProcessTalkRequest(&this->actor, &play->state)) { if (this->cutsceneState == ENFSN_CUTSCENESTATE_STOPPED) { if (ActorCutscene_GetCurrentIndex() == 0x7C) { ActorCutscene_Stop(0x7C); @@ -744,43 +744,43 @@ void EnFsn_Idle(EnFsn* this, GlobalContext* globalCtx) { ActorCutscene_SetIntentToPlay(this->cutscene); this->cutsceneState = ENFSN_CUTSCENESTATE_WAITING; } - this->actor.textId = EnFsn_GetWelcome(globalCtx); - Message_StartTextbox(globalCtx, this->actor.textId, &this->actor); + this->actor.textId = EnFsn_GetWelcome(play); + Message_StartTextbox(play, this->actor.textId, &this->actor); player->actor.world.pos.x = 1.0f; player->actor.world.pos.z = -34.0f; this->actionFunc = EnFsn_BeginInteraction; } else if (((player->actor.world.pos.x >= -50.0f) && (player->actor.world.pos.x <= 15.0f)) && (player->actor.world.pos.y > 0.0f) && ((player->actor.world.pos.z >= -35.0f) && (player->actor.world.pos.z <= -20.0f))) { - func_800B8614(&this->actor, globalCtx, 400.0f); + func_800B8614(&this->actor, play, 400.0f); } } -void EnFsn_Haggle(EnFsn* this, GlobalContext* globalCtx) { +void EnFsn_Haggle(EnFsn* this, PlayState* play) { s16 curFrame = this->skelAnime.curFrame; - s16 frameCount = Animation_GetLastFrame(sAnimations[this->animationIndex].animation); + s16 frameCount = Animation_GetLastFrame(sAnimationInfo[this->animIndex].animation); if (this->flags & ENFSN_ANGRY) { this->flags &= ~ENFSN_ANGRY; - this->animationIndex = FSN_ANIMATION_SLAM_COUNTER_LOOP; - SubS_ChangeAnimationByInfoS(&this->skelAnime, sAnimations, this->animationIndex); + this->animIndex = FSN_ANIM_SLAM_COUNTER_LOOP; + SubS_ChangeAnimationByInfoS(&this->skelAnime, sAnimationInfo, this->animIndex); } else { - if (this->animationIndex == FSN_ANIMATION_SLAM_COUNTER_LOOP && Animation_OnFrame(&this->skelAnime, 18.0f)) { + if (this->animIndex == FSN_ANIM_SLAM_COUNTER_LOOP && Animation_OnFrame(&this->skelAnime, 18.0f)) { Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_HANKO); } if (this->flags & ENFSN_CALM_DOWN) { this->flags &= ~ENFSN_CALM_DOWN; - this->animationIndex = FSN_ANIMATION_HANDS_ON_COUNTER_LOOP; - SubS_ChangeAnimationByInfoS(&this->skelAnime, sAnimations, this->animationIndex); + this->animIndex = FSN_ANIM_HANDS_ON_COUNTER_LOOP; + SubS_ChangeAnimationByInfoS(&this->skelAnime, sAnimationInfo, this->animIndex); } else if (this->flags & ENFSN_OFFER_FINAL_PRICE) { this->flags &= ~ENFSN_OFFER_FINAL_PRICE; - this->animationIndex = FSN_ANIMATION_MAKE_OFFER; - SubS_ChangeAnimationByInfoS(&this->skelAnime, sAnimations, this->animationIndex); + this->animIndex = FSN_ANIM_MAKE_OFFER; + SubS_ChangeAnimationByInfoS(&this->skelAnime, sAnimationInfo, this->animIndex); } else { - if (this->animationIndex == FSN_ANIMATION_MAKE_OFFER) { + if (this->animIndex == FSN_ANIM_MAKE_OFFER) { if (curFrame == frameCount) { - this->animationIndex = FSN_ANIMATION_HANDS_ON_COUNTER_LOOP; - SubS_ChangeAnimationByInfoS(&this->skelAnime, sAnimations, this->animationIndex); + this->animIndex = FSN_ANIM_HANDS_ON_COUNTER_LOOP; + SubS_ChangeAnimationByInfoS(&this->skelAnime, sAnimationInfo, this->animIndex); } else { if (Animation_OnFrame(&this->skelAnime, 28.0f)) { Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_HANKO); @@ -795,13 +795,13 @@ void EnFsn_Haggle(EnFsn* this, GlobalContext* globalCtx) { } } -void EnFsn_BeginInteraction(EnFsn* this, GlobalContext* globalCtx) { +void EnFsn_BeginInteraction(EnFsn* this, PlayState* play) { if (this->cutsceneState == ENFSN_CUTSCENESTATE_WAITING) { if (ActorCutscene_GetCanPlayNext(this->cutscene)) { ActorCutscene_StartAndSetFlag(this->cutscene, &this->actor); this->cutsceneState = ENFSN_CUTSCENESTATE_PLAYING; - if (Player_GetMask(globalCtx) == PLAYER_MASK_NONE) { - func_8011552C(globalCtx, 16); + if (Player_GetMask(play) == PLAYER_MASK_NONE) { + func_8011552C(play, 16); if (EnFsn_HasItemsToSell()) { this->actionFunc = EnFsn_AskBuyOrSell; } else { @@ -817,40 +817,40 @@ void EnFsn_BeginInteraction(EnFsn* this, GlobalContext* globalCtx) { } } -void EnFsn_StartBuying(EnFsn* this, GlobalContext* globalCtx) { - u8 talkState = Message_GetState(&globalCtx->msgCtx); - Player* player = GET_PLAYER(globalCtx); +void EnFsn_StartBuying(EnFsn* this, PlayState* play) { + u8 talkState = Message_GetState(&play->msgCtx); + Player* player = GET_PLAYER(play); EnFsn_HandleLookToShopkeeperBuyingCutscene(this); - if (talkState == 5 && Message_ShouldAdvance(globalCtx)) { + if ((talkState == TEXT_STATE_5) && Message_ShouldAdvance(play)) { switch (this->actor.textId) { case 0x29CC: this->actor.textId = 0x29CD; - Message_StartTextbox(globalCtx, this->actor.textId, &this->actor); + Message_StartTextbox(play, this->actor.textId, &this->actor); break; case 0x29CD: this->actor.textId = 0x29CE; EnFsn_HandleLookToShopkeeperBuyingCutscene(this); - Message_StartTextbox(globalCtx, this->actor.textId, &this->actor); + Message_StartTextbox(play, this->actor.textId, &this->actor); break; case 0x29CE: this->actor.textId = 0xFF; - Message_StartTextbox(globalCtx, this->actor.textId, &this->actor); + Message_StartTextbox(play, this->actor.textId, &this->actor); this->actionFunc = EnFsn_DeterminePrice; break; case 0x29CF: - player->exchangeItemId = EXCH_ITEM_NONE; + player->exchangeItemId = PLAYER_AP_NONE; this->actionFunc = EnFsn_SetupDeterminePrice; break; } } } -void EnFsn_AskBuyOrSell(EnFsn* this, GlobalContext* globalCtx) { - u8 talkState = Message_GetState(&globalCtx->msgCtx); +void EnFsn_AskBuyOrSell(EnFsn* this, PlayState* play) { + u8 talkState = Message_GetState(&play->msgCtx); - if (talkState == 5) { - if (Message_ShouldAdvance(globalCtx)) { + if (talkState == TEXT_STATE_5) { + if (Message_ShouldAdvance(play)) { switch (this->actor.textId) { case 0x29CC: if (CURRENT_DAY != 3) { @@ -858,7 +858,7 @@ void EnFsn_AskBuyOrSell(EnFsn* this, GlobalContext* globalCtx) { } else { this->actor.textId = 0x29D2; } - Message_StartTextbox(globalCtx, this->actor.textId, &this->actor); + Message_StartTextbox(play, this->actor.textId, &this->actor); break; case 0x29D2: if (gSaveContext.save.weekEventReg[33] & 4) { @@ -869,28 +869,28 @@ void EnFsn_AskBuyOrSell(EnFsn* this, GlobalContext* globalCtx) { } else { this->actor.textId = 0x29D4; } - Message_StartTextbox(globalCtx, this->actor.textId, &this->actor); + Message_StartTextbox(play, this->actor.textId, &this->actor); break; case 0x29D3: case 0x29D4: case 0x29FA: case 0x2A01: this->actor.textId = 0x29D5; - Message_StartTextbox(globalCtx, this->actor.textId, &this->actor); + Message_StartTextbox(play, this->actor.textId, &this->actor); break; } } - } else if (talkState == 4) { - func_8011552C(globalCtx, 6); - if (!EnFsn_TestEndInteraction(this, globalCtx, CONTROLLER1(globalCtx)) && Message_ShouldAdvance(globalCtx)) { - switch (globalCtx->msgCtx.choiceIndex) { + } else if (talkState == TEXT_STATE_CHOICE) { + func_8011552C(play, 6); + if (!EnFsn_TestEndInteraction(this, play, CONTROLLER1(&play->state)) && Message_ShouldAdvance(play)) { + switch (play->msgCtx.choiceIndex) { case 0: func_8019F208(); this->isSelling = true; this->stickLeftPrompt.isEnabled = false; this->stickRightPrompt.isEnabled = true; this->actor.textId = 0x29D6; - Message_StartTextbox(globalCtx, this->actor.textId, &this->actor); + Message_StartTextbox(play, this->actor.textId, &this->actor); this->actionFunc = EnFsn_FaceShopkeeperSelling; break; case 1: @@ -898,7 +898,7 @@ void EnFsn_AskBuyOrSell(EnFsn* this, GlobalContext* globalCtx) { this->isSelling = false; this->actor.textId = 0x29CE; EnFsn_HandleLookToShopkeeperBuyingCutscene(this); - Message_StartTextbox(globalCtx, this->actor.textId, &this->actor); + Message_StartTextbox(play, this->actor.textId, &this->actor); this->actionFunc = EnFsn_StartBuying; break; } @@ -906,21 +906,21 @@ void EnFsn_AskBuyOrSell(EnFsn* this, GlobalContext* globalCtx) { } } -void EnFsn_SetupDeterminePrice(EnFsn* this, GlobalContext* globalCtx) { - if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { +void EnFsn_SetupDeterminePrice(EnFsn* this, PlayState* play) { + if (Actor_ProcessTalkRequest(&this->actor, &play->state)) { this->actor.textId = 0xFF; - Message_StartTextbox(globalCtx, this->actor.textId, &this->actor); + Message_StartTextbox(play, this->actor.textId, &this->actor); this->actionFunc = EnFsn_DeterminePrice; } } -void EnFsn_DeterminePrice(EnFsn* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); +void EnFsn_DeterminePrice(EnFsn* this, PlayState* play) { + Player* player = GET_PLAYER(play); s32 itemActionParam; u8 buttonItem; - if (Message_GetState(&globalCtx->msgCtx) == 16) { - itemActionParam = func_80123810(globalCtx); + if (Message_GetState(&play->msgCtx) == TEXT_STATE_16) { + itemActionParam = func_80123810(play); if (itemActionParam > PLAYER_AP_NONE) { if (player->heldItemButton == 0) { buttonItem = CUR_FORM_EQUIP(player->heldItemButton); @@ -937,30 +937,30 @@ void EnFsn_DeterminePrice(EnFsn* this, GlobalContext* globalCtx) { this->actionFunc = EnFsn_StartBuying; } this->actor.textId = player->actor.textId; - func_801477B4(globalCtx); + func_801477B4(play); } else if (itemActionParam < PLAYER_AP_NONE) { if (CURRENT_DAY == 3) { this->actor.textId = 0x29DF; } else { this->actor.textId = 0x29D1; } - Message_StartTextbox(globalCtx, this->actor.textId, &this->actor); - func_80151BB4(globalCtx, 3); + Message_StartTextbox(play, this->actor.textId, &this->actor); + func_80151BB4(play, 3); this->actionFunc = EnFsn_SetupEndInteraction; } } } -void EnFsn_MakeOffer(EnFsn* this, GlobalContext* globalCtx) { - u8 talkState = Message_GetState(&globalCtx->msgCtx); - Player* player = GET_PLAYER(globalCtx); +void EnFsn_MakeOffer(EnFsn* this, PlayState* play) { + u8 talkState = Message_GetState(&play->msgCtx); + Player* player = GET_PLAYER(play); - if (talkState == 4 && Message_ShouldAdvance(globalCtx)) { - switch (globalCtx->msgCtx.choiceIndex) { + if (talkState == TEXT_STATE_CHOICE && Message_ShouldAdvance(play)) { + switch (play->msgCtx.choiceIndex) { case 0: func_8019F208(); - globalCtx->msgCtx.msgMode = 0x43; - globalCtx->msgCtx.unk12023 = 4; + play->msgCtx.msgMode = 0x43; + play->msgCtx.stateTimer = 4; if (this->cutsceneState == ENFSN_CUTSCENESTATE_PLAYING) { ActorCutscene_Stop(this->cutscene); this->cutsceneState = ENFSN_CUTSCENESTATE_STOPPED; @@ -986,43 +986,43 @@ void EnFsn_MakeOffer(EnFsn* this, GlobalContext* globalCtx) { break; case 1: func_8019F230(); - player->exchangeItemId = EXCH_ITEM_NONE; + player->exchangeItemId = PLAYER_AP_NONE; this->actionFunc = EnFsn_SetupDeterminePrice; break; } } } -void EnFsn_GiveItem(EnFsn* this, GlobalContext* globalCtx) { - if (Actor_HasParent(&this->actor, globalCtx)) { +void EnFsn_GiveItem(EnFsn* this, PlayState* play) { + if (Actor_HasParent(&this->actor, play)) { if ((this->isSelling == true) && (this->items[this->cursorIdx]->getItemId == GI_MASK_ALL_NIGHT)) { - func_80151BB4(globalCtx, 45); - func_80151BB4(globalCtx, 3); + func_80151BB4(play, 45); + func_80151BB4(play, 3); } this->actor.parent = NULL; if (ENFSN_IS_SHOP(&this->actor) && !this->isSelling) { - func_80123D50(globalCtx, GET_PLAYER(globalCtx), ITEM_BOTTLE, PLAYER_AP_BOTTLE); + func_80123D50(play, GET_PLAYER(play), ITEM_BOTTLE, PLAYER_AP_BOTTLE); } this->actionFunc = EnFsn_SetupResumeInteraction; } else if (this->isSelling == true) { - Actor_PickUp(&this->actor, globalCtx, this->items[this->cursorIdx]->getItemId, 300.0f, 300.0f); + Actor_PickUp(&this->actor, play, this->items[this->cursorIdx]->getItemId, 300.0f, 300.0f); } else { - Actor_PickUp(&this->actor, globalCtx, this->getItemId, 300.0f, 300.0f); + Actor_PickUp(&this->actor, play, this->getItemId, 300.0f, 300.0f); } } -void EnFsn_SetupResumeInteraction(EnFsn* this, GlobalContext* globalCtx) { +void EnFsn_SetupResumeInteraction(EnFsn* this, PlayState* play) { if (CHECK_QUEST_ITEM(QUEST_BOMBERS_NOTEBOOK)) { - if (globalCtx->msgCtx.unk120B1 == 0) { - EnFsn_HandleSetupResumeInteraction(this, globalCtx); + if (play->msgCtx.unk120B1 == 0) { + EnFsn_HandleSetupResumeInteraction(this, play); } } else { - EnFsn_HandleSetupResumeInteraction(this, globalCtx); + EnFsn_HandleSetupResumeInteraction(this, play); } } -void EnFsn_ResumeInteraction(EnFsn* this, GlobalContext* globalCtx) { - if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { +void EnFsn_ResumeInteraction(EnFsn* this, PlayState* play) { + if (Actor_ProcessTalkRequest(&this->actor, &play->state)) { if (ENFSN_IS_SHOP(&this->actor)) { if (!this->isSelling) { this->cutscene = this->lookToShopkeeperBuyingCutscene; @@ -1031,22 +1031,22 @@ void EnFsn_ResumeInteraction(EnFsn* this, GlobalContext* globalCtx) { this->cutscene = this->lookToShopkeeperCutscene; this->actor.textId = (this->numSellingItems <= 0) ? 0x29DE : 0x29D6; } - Message_StartTextbox(globalCtx, this->actor.textId, &this->actor); + Message_StartTextbox(play, this->actor.textId, &this->actor); if (ActorCutscene_GetCurrentIndex() == 0x7C) { ActorCutscene_Stop(0x7C); } ActorCutscene_SetIntentToPlay(this->cutscene); this->actionFunc = EnFsn_ResumeShoppingInteraction; } else { - EnFsn_HandleConversationBackroom(this, globalCtx); + EnFsn_HandleConversationBackroom(this, play); this->actionFunc = EnFsn_ConverseBackroom; } } else { - func_800B85E0(&this->actor, globalCtx, 400.0f, EXCH_ITEM_MINUS1); + func_800B85E0(&this->actor, play, 400.0f, PLAYER_AP_MINUS1); } } -void EnFsn_ResumeShoppingInteraction(EnFsn* this, GlobalContext* globalCtx) { +void EnFsn_ResumeShoppingInteraction(EnFsn* this, PlayState* play) { if (this->cutsceneState == ENFSN_CUTSCENESTATE_STOPPED) { if (ActorCutscene_GetCanPlayNext(this->cutscene)) { ActorCutscene_StartAndSetFlag(this->cutscene, &this->actor); @@ -1056,7 +1056,7 @@ void EnFsn_ResumeShoppingInteraction(EnFsn* this, GlobalContext* globalCtx) { } else if (this->actor.textId != 0x29D6) { this->actionFunc = EnFsn_AskCanBuyAterRunningOutOfItems; } else { - func_8011552C(globalCtx, 6); + func_8011552C(play, 6); this->stickLeftPrompt.isEnabled = false; this->stickRightPrompt.isEnabled = true; this->actionFunc = EnFsn_FaceShopkeeperSelling; @@ -1071,7 +1071,7 @@ void EnFsn_ResumeShoppingInteraction(EnFsn* this, GlobalContext* globalCtx) { } } -void EnFsn_LookToShelf(EnFsn* this, GlobalContext* globalCtx) { +void EnFsn_LookToShelf(EnFsn* this, PlayState* play) { if (this->cutsceneState == ENFSN_CUTSCENESTATE_PLAYING) { ActorCutscene_Stop(this->cutscene); if (ActorCutscene_GetCurrentIndex() == 0x7C) { @@ -1084,17 +1084,17 @@ void EnFsn_LookToShelf(EnFsn* this, GlobalContext* globalCtx) { if (ActorCutscene_GetCanPlayNext(this->cutscene) != 0) { ActorCutscene_StartAndSetFlag(this->cutscene, &this->actor); this->cutsceneState = ENFSN_CUTSCENESTATE_PLAYING; - EnFsn_UpdateCursorPos(this, globalCtx); + EnFsn_UpdateCursorPos(this, play); this->actionFunc = EnFsn_BrowseShelf; - func_80151938(globalCtx, this->items[this->cursorIdx]->actor.textId); + func_80151938(play, this->items[this->cursorIdx]->actor.textId); } else { ActorCutscene_SetIntentToPlay(this->cutscene); } } } -void EnFsn_BrowseShelf(EnFsn* this, GlobalContext* globalCtx) { - u8 talkstate = Message_GetState(&globalCtx->msgCtx); +void EnFsn_BrowseShelf(EnFsn* this, PlayState* play) { + u8 talkstate = Message_GetState(&play->msgCtx); s32 pad; u8 prevCursorIdx = this->cursorIdx; @@ -1105,21 +1105,21 @@ void EnFsn_BrowseShelf(EnFsn* this, GlobalContext* globalCtx) { } else { this->drawCursor = 0xFF; this->stickLeftPrompt.isEnabled = true; - EnFsn_UpdateCursorPos(this, globalCtx); - if (talkstate == 5) { - func_8011552C(globalCtx, 6); - if (!EnFsn_HasPlayerSelectedItem(this, globalCtx, CONTROLLER1(globalCtx))) { + EnFsn_UpdateCursorPos(this, play); + if (talkstate == TEXT_STATE_5) { + func_8011552C(play, 6); + if (!EnFsn_HasPlayerSelectedItem(this, play, CONTROLLER1(&play->state))) { EnFsn_CursorLeftRight(this); if (this->cursorIdx != prevCursorIdx) { play_sound(NA_SE_SY_CURSOR); - func_80151938(globalCtx, this->items[this->cursorIdx]->actor.textId); + func_80151938(play, this->items[this->cursorIdx]->actor.textId); } } } } } -void EnFsn_LookToShopkeeperFromShelf(EnFsn* this, GlobalContext* globalCtx) { +void EnFsn_LookToShopkeeperFromShelf(EnFsn* this, PlayState* play) { if (this->cutsceneState == ENFSN_CUTSCENESTATE_PLAYING) { ActorCutscene_Stop(this->cutscene); if (ActorCutscene_GetCurrentIndex() == 0x7C) { @@ -1135,7 +1135,7 @@ void EnFsn_LookToShopkeeperFromShelf(EnFsn* this, GlobalContext* globalCtx) { this->stickLeftPrompt.isEnabled = false; this->stickRightPrompt.isEnabled = true; this->actor.textId = 0x29D6; - func_80151938(globalCtx, this->actor.textId); + func_80151938(play, this->actor.textId); this->actionFunc = EnFsn_FaceShopkeeperSelling; } else { ActorCutscene_SetIntentToPlay(this->cutscene); @@ -1143,10 +1143,10 @@ void EnFsn_LookToShopkeeperFromShelf(EnFsn* this, GlobalContext* globalCtx) { } } -void EnFsn_HandleCanPlayerBuyItem(EnFsn* this, GlobalContext* globalCtx) { +void EnFsn_HandleCanPlayerBuyItem(EnFsn* this, PlayState* play) { EnGirlA* item = this->items[this->cursorIdx]; - switch (item->canBuyFunc(globalCtx, item)) { + switch (item->canBuyFunc(play, item)) { case CANBUY_RESULT_SUCCESS_2: func_8019F208(); gSaveContext.save.weekEventReg[33] |= 4; @@ -1157,15 +1157,15 @@ void EnFsn_HandleCanPlayerBuyItem(EnFsn* this, GlobalContext* globalCtx) { } func_8019F208(); item = this->items[this->cursorIdx]; - item->buyFanfareFunc(globalCtx, item); - Actor_PickUp(&this->actor, globalCtx, this->items[this->cursorIdx]->getItemId, 300.0f, 300.0f); - globalCtx->msgCtx.msgMode = 0x43; - globalCtx->msgCtx.unk12023 = 4; + item->buyFanfareFunc(play, item); + Actor_PickUp(&this->actor, play, this->items[this->cursorIdx]->getItemId, 300.0f, 300.0f); + play->msgCtx.msgMode = 0x43; + play->msgCtx.stateTimer = 4; Interface_ChangeAlpha(50); this->drawCursor = 0; this->shopItemSelectedTween = 0.0f; item = this->items[this->cursorIdx]; - item->boughtFunc(globalCtx, item); + item->boughtFunc(play, item); if (this->stolenItem1 == this->cursorIdx) { SET_STOLEN_ITEM_1(STOLEN_ITEM_NONE); } else if (this->stolenItem2 == this->cursorIdx) { @@ -1177,62 +1177,62 @@ void EnFsn_HandleCanPlayerBuyItem(EnFsn* this, GlobalContext* globalCtx) { break; case CANBUY_RESULT_NEED_RUPEES: play_sound(NA_SE_SY_ERROR); - func_80151938(globalCtx, 0x29F0); + func_80151938(play, 0x29F0); this->actionFunc = EnFsn_PlayerCannotBuy; break; case CANBUY_RESULT_CANNOT_GET_NOW: play_sound(NA_SE_SY_ERROR); - func_80151938(globalCtx, 0x29DD); + func_80151938(play, 0x29DD); this->actionFunc = EnFsn_PlayerCannotBuy; break; } } -void EnFsn_SetupEndInteraction(EnFsn* this, GlobalContext* globalCtx) { - u8 talkState = Message_GetState(&globalCtx->msgCtx); +void EnFsn_SetupEndInteraction(EnFsn* this, PlayState* play) { + u8 talkState = Message_GetState(&play->msgCtx); - if ((talkState == 5 || talkState == 6) && Message_ShouldAdvance(globalCtx)) { + if (((talkState == TEXT_STATE_5) || (talkState == TEXT_STATE_DONE)) && Message_ShouldAdvance(play)) { if (CHECK_QUEST_ITEM(QUEST_BOMBERS_NOTEBOOK)) { - if (globalCtx->msgCtx.unk120B1 == 0) { - EnFsn_EndInteraction(this, globalCtx); + if (play->msgCtx.unk120B1 == 0) { + EnFsn_EndInteraction(this, play); } else { - globalCtx->msgCtx.msgMode = 0x43; - globalCtx->msgCtx.unk12023 = 4; + play->msgCtx.msgMode = 0x43; + play->msgCtx.stateTimer = 4; } } else { - EnFsn_EndInteraction(this, globalCtx); + EnFsn_EndInteraction(this, play); } } } -void EnFsn_SelectItem(EnFsn* this, GlobalContext* globalCtx) { - u8 talkState = Message_GetState(&globalCtx->msgCtx); +void EnFsn_SelectItem(EnFsn* this, PlayState* play) { + u8 talkState = Message_GetState(&play->msgCtx); - if (EnFsn_TakeItemOffShelf(this) && talkState == 4) { - func_8011552C(globalCtx, 6); - if (!EnFsn_TestCancelOption(this, globalCtx, CONTROLLER1(globalCtx)) && Message_ShouldAdvance(globalCtx)) { - switch (globalCtx->msgCtx.choiceIndex) { + if (EnFsn_TakeItemOffShelf(this) && (talkState == TEXT_STATE_CHOICE)) { + func_8011552C(play, 6); + if (!EnFsn_TestCancelOption(this, play, CONTROLLER1(&play->state)) && Message_ShouldAdvance(play)) { + switch (play->msgCtx.choiceIndex) { case 0: - EnFsn_HandleCanPlayerBuyItem(this, globalCtx); + EnFsn_HandleCanPlayerBuyItem(this, play); break; case 1: func_8019F230(); - this->actionFunc = this->tmpActionFunc; - func_80151938(globalCtx, this->items[this->cursorIdx]->actor.textId); + this->actionFunc = this->prevActionFunc; + func_80151938(play, this->items[this->cursorIdx]->actor.textId); } } } } -void EnFsn_PlayerCannotBuy(EnFsn* this, GlobalContext* globalCtx) { - if (Message_GetState(&globalCtx->msgCtx) == 5 && Message_ShouldAdvance(globalCtx)) { - this->actionFunc = this->tmpActionFunc; - func_80151938(globalCtx, this->items[this->cursorIdx]->actor.textId); +void EnFsn_PlayerCannotBuy(EnFsn* this, PlayState* play) { + if ((Message_GetState(&play->msgCtx) == TEXT_STATE_5) && Message_ShouldAdvance(play)) { + this->actionFunc = this->prevActionFunc; + func_80151938(play, this->items[this->cursorIdx]->actor.textId); } } -void EnFsn_AskCanBuyMore(EnFsn* this, GlobalContext* globalCtx) { - u8 talkState = Message_GetState(&globalCtx->msgCtx); +void EnFsn_AskCanBuyMore(EnFsn* this, PlayState* play) { + u8 talkState = Message_GetState(&play->msgCtx); if (this->cutsceneState == ENFSN_CUTSCENESTATE_STOPPED) { if (ActorCutscene_GetCanPlayNext(this->cutscene)) { @@ -1246,39 +1246,39 @@ void EnFsn_AskCanBuyMore(EnFsn* this, GlobalContext* globalCtx) { ActorCutscene_SetIntentToPlay(this->cutscene); } } - if (talkState == 4) { - if (Message_ShouldAdvance(globalCtx)) { - switch (globalCtx->msgCtx.choiceIndex) { + if (talkState == TEXT_STATE_CHOICE) { + if (Message_ShouldAdvance(play)) { + switch (play->msgCtx.choiceIndex) { case 0: func_8019F208(); this->actor.textId = 0xFF; - Message_StartTextbox(globalCtx, this->actor.textId, &this->actor); + Message_StartTextbox(play, this->actor.textId, &this->actor); this->actionFunc = EnFsn_DeterminePrice; break; case 1: func_8019F230(); this->actor.textId = (CURRENT_DAY == 3) ? 0x29DF : 0x29D1; - Message_StartTextbox(globalCtx, this->actor.textId, &this->actor); - func_80151BB4(globalCtx, 3); + Message_StartTextbox(play, this->actor.textId, &this->actor); + func_80151BB4(play, 3); break; } } - } else if ((talkState == 5 || talkState == 6) && Message_ShouldAdvance(globalCtx)) { + } else if (((talkState == TEXT_STATE_5) || (talkState == TEXT_STATE_DONE)) && Message_ShouldAdvance(play)) { if (CHECK_QUEST_ITEM(QUEST_BOMBERS_NOTEBOOK)) { - if (globalCtx->msgCtx.unk120B1 == 0) { - EnFsn_EndInteraction(this, globalCtx); + if (play->msgCtx.unk120B1 == 0) { + EnFsn_EndInteraction(this, play); } else { - globalCtx->msgCtx.msgMode = 0x43; - globalCtx->msgCtx.unk12023 = 4; + play->msgCtx.msgMode = 0x43; + play->msgCtx.stateTimer = 4; } } else { - EnFsn_EndInteraction(this, globalCtx); + EnFsn_EndInteraction(this, play); } } } -void EnFsn_AskCanBuyAterRunningOutOfItems(EnFsn* this, GlobalContext* globalCtx) { - u8 talkState = Message_GetState(&globalCtx->msgCtx); +void EnFsn_AskCanBuyAterRunningOutOfItems(EnFsn* this, PlayState* play) { + u8 talkState = Message_GetState(&play->msgCtx); if (this->cutsceneState == ENFSN_CUTSCENESTATE_STOPPED) { if (ActorCutscene_GetCanPlayNext(this->cutscene)) { @@ -1292,93 +1292,93 @@ void EnFsn_AskCanBuyAterRunningOutOfItems(EnFsn* this, GlobalContext* globalCtx) ActorCutscene_SetIntentToPlay(this->cutscene); } } - if (talkState == 4) { - if (Message_ShouldAdvance(globalCtx)) { - switch (globalCtx->msgCtx.choiceIndex) { + if (talkState == TEXT_STATE_CHOICE) { + if (Message_ShouldAdvance(play)) { + switch (play->msgCtx.choiceIndex) { case 0: func_8019F208(); this->isSelling = false; this->actor.textId = 0x29CE; - Message_StartTextbox(globalCtx, this->actor.textId, &this->actor); + Message_StartTextbox(play, this->actor.textId, &this->actor); this->actionFunc = EnFsn_StartBuying; break; case 1: func_8019F230(); this->actor.textId = (CURRENT_DAY == 3) ? 0x29DF : 0x29D1; - Message_StartTextbox(globalCtx, this->actor.textId, &this->actor); - func_80151BB4(globalCtx, 3); + Message_StartTextbox(play, this->actor.textId, &this->actor); + func_80151BB4(play, 3); break; } } - } else if ((talkState == 5 || talkState == 6) && Message_ShouldAdvance(globalCtx)) { + } else if (((talkState == TEXT_STATE_5) || (talkState == TEXT_STATE_DONE)) && Message_ShouldAdvance(play)) { if (CHECK_QUEST_ITEM(QUEST_BOMBERS_NOTEBOOK)) { - if (globalCtx->msgCtx.unk120B1 == 0) { - EnFsn_EndInteraction(this, globalCtx); + if (play->msgCtx.unk120B1 == 0) { + EnFsn_EndInteraction(this, play); } else { - globalCtx->msgCtx.msgMode = 0x43; - globalCtx->msgCtx.unk12023 = 4; + play->msgCtx.msgMode = 0x43; + play->msgCtx.stateTimer = 4; } } else { - EnFsn_EndInteraction(this, globalCtx); + EnFsn_EndInteraction(this, play); } } } -void EnFsn_FaceShopkeeperSelling(EnFsn* this, GlobalContext* globalCtx) { - u8 talkState = Message_GetState(&globalCtx->msgCtx); +void EnFsn_FaceShopkeeperSelling(EnFsn* this, PlayState* play) { + u8 talkState = Message_GetState(&play->msgCtx); u8 cursorIdx; - if (talkState == 4) { - func_8011552C(globalCtx, 6); - if (!EnFsn_TestEndInteraction(this, globalCtx, CONTROLLER1(globalCtx)) && - (!Message_ShouldAdvance(globalCtx) || !EnFsn_FacingShopkeeperDialogResult(this, globalCtx)) && + if (talkState == TEXT_STATE_CHOICE) { + func_8011552C(play, 6); + if (!EnFsn_TestEndInteraction(this, play, CONTROLLER1(&play->state)) && + (!Message_ShouldAdvance(play) || !EnFsn_FacingShopkeeperDialogResult(this, play)) && this->stickAccumX > 0) { cursorIdx = EnFsn_SetCursorIndexFromNeutral(this); if (cursorIdx != CURSOR_INVALID) { this->cursorIdx = cursorIdx; this->actionFunc = EnFsn_LookToShelf; - func_8011552C(globalCtx, 6); + func_8011552C(play, 6); this->stickRightPrompt.isEnabled = false; play_sound(NA_SE_SY_CURSOR); } } - } else if (talkState == 5 && Message_ShouldAdvance(globalCtx)) { + } else if ((talkState == TEXT_STATE_5) && Message_ShouldAdvance(play)) { this->actor.textId = 0x29D6; - Message_StartTextbox(globalCtx, this->actor.textId, &this->actor); - if (globalCtx) {} + Message_StartTextbox(play, this->actor.textId, &this->actor); + if (play) {} } } -void EnFsn_SetupEndInteractionImmediately(EnFsn* this, GlobalContext* globalCtx) { - if (Message_GetState(&globalCtx->msgCtx) == 5 && Message_ShouldAdvance(globalCtx)) { - EnFsn_EndInteraction(this, globalCtx); +void EnFsn_SetupEndInteractionImmediately(EnFsn* this, PlayState* play) { + if ((Message_GetState(&play->msgCtx) == TEXT_STATE_5) && Message_ShouldAdvance(play)) { + EnFsn_EndInteraction(this, play); } } -void EnFsn_IdleBackroom(EnFsn* this, GlobalContext* globalCtx) { - if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { +void EnFsn_IdleBackroom(EnFsn* this, PlayState* play) { + if (Actor_ProcessTalkRequest(&this->actor, &play->state)) { this->textId = 0; - EnFsn_HandleConversationBackroom(this, globalCtx); + EnFsn_HandleConversationBackroom(this, play); this->actionFunc = EnFsn_ConverseBackroom; } else if (this->actor.xzDistToPlayer < 100.0f || this->actor.isTargeted) { - func_800B8614(&this->actor, globalCtx, 100.0f); + func_800B8614(&this->actor, play, 100.0f); } } -void EnFsn_ConverseBackroom(EnFsn* this, GlobalContext* globalCtx) { - if (Message_GetState(&globalCtx->msgCtx) == 5 && Message_ShouldAdvance(globalCtx)) { +void EnFsn_ConverseBackroom(EnFsn* this, PlayState* play) { + if ((Message_GetState(&play->msgCtx) == TEXT_STATE_5) && Message_ShouldAdvance(play)) { if (this->flags & ENFSN_END_CONVERSATION) { this->flags &= ~ENFSN_END_CONVERSATION; - globalCtx->msgCtx.msgMode = 0x43; - globalCtx->msgCtx.unk12023 = 4; + play->msgCtx.msgMode = 0x43; + play->msgCtx.stateTimer = 4; this->actionFunc = EnFsn_IdleBackroom; } else if (this->flags & ENFSN_GIVE_ITEM) { this->flags &= ~ENFSN_GIVE_ITEM; - globalCtx->msgCtx.msgMode = 0x43; - globalCtx->msgCtx.unk12023 = 4; + play->msgCtx.msgMode = 0x43; + play->msgCtx.stateTimer = 4; this->actionFunc = EnFsn_GiveItem; } else { - EnFsn_HandleConversationBackroom(this, globalCtx); + EnFsn_HandleConversationBackroom(this, play); } } } @@ -1405,62 +1405,64 @@ void EnFsn_Blink(EnFsn* this) { } } -void EnFsn_Init(Actor* thisx, GlobalContext* globalCtx) { +void EnFsn_Init(Actor* thisx, PlayState* play) { s32 pad; EnFsn* this = THIS; ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 20.0f); - SkelAnime_InitFlex(globalCtx, &this->skelAnime, &gFsnSkel, &gFsnIdleAnim, this->jointTable, this->morphTable, + + // Note: adding 1 to FSN_LIMB_MAX due to bug in object_fsn, see bug in object_fsn.xml + SkelAnime_InitFlex(play, &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 &= ~ACTOR_FLAG_1; EnFsn_GetCutscenes(this); - EnFsn_InitShop(this, globalCtx); + EnFsn_InitShop(this, play); } else { if ((gSaveContext.save.weekEventReg[33] & 8) || (gSaveContext.save.weekEventReg[79] & 0x40)) { Actor_MarkForDeath(&this->actor); return; } - Collider_InitCylinder(globalCtx, &this->collider); - Collider_InitAndSetCylinder(globalCtx, &this->collider, &this->actor, &sCylinderInit); + Collider_InitCylinder(play, &this->collider); + Collider_InitAndSetCylinder(play, &this->collider, &this->actor, &sCylinderInit); this->blinkTimer = 20; this->eyeTextureIdx = 0; this->actor.flags |= ACTOR_FLAG_1; this->actor.targetMode = 0; - this->animationIndex = FSN_ANIMATION_IDLE; - SubS_ChangeAnimationByInfoS(&this->skelAnime, sAnimations, this->animationIndex); + this->animIndex = FSN_ANIM_IDLE; + SubS_ChangeAnimationByInfoS(&this->skelAnime, sAnimationInfo, this->animIndex); this->actionFunc = EnFsn_IdleBackroom; } } -void EnFsn_Destroy(Actor* thisx, GlobalContext* globalCtx) { +void EnFsn_Destroy(Actor* thisx, PlayState* play) { EnFsn* this = THIS; - Collider_DestroyCylinder(globalCtx, &this->collider); + Collider_DestroyCylinder(play, &this->collider); } -void EnFsn_Update(Actor* thisx, GlobalContext* globalCtx) { +void EnFsn_Update(Actor* thisx, PlayState* play) { EnFsn* this = THIS; - this->actionFunc(this, globalCtx); + this->actionFunc(this, play); Actor_MoveWithGravity(&this->actor); - func_800E9250(globalCtx, &this->actor, &this->headRot, &this->unk27A, this->actor.focus.pos); - SubS_FillLimbRotTables(globalCtx, this->limbRotYTable, this->limbRotZTable, ARRAY_COUNT(this->limbRotYTable)); + Actor_TrackPlayer(play, &this->actor, &this->headRot, &this->unk27A, this->actor.focus.pos); + SubS_FillLimbRotTables(play, this->limbRotYTable, this->limbRotZTable, ARRAY_COUNT(this->limbRotYTable)); EnFsn_Blink(this); if (ENFSN_IS_SHOP(&this->actor) && EnFsn_HasItemsToSell()) { - EnFsn_UpdateJoystickInputState(this, globalCtx); + EnFsn_UpdateJoystickInputState(this, play); EnFsn_UpdateItemSelectedProperty(this); EnFsn_UpdateStickDirectionPromptAnim(this); EnFsn_UpdateCursorAnim(this); } SkelAnime_Update(&this->skelAnime); if (ENFSN_IS_BACKROOM(&this->actor)) { - EnFsn_UpdateCollider(this, globalCtx); + EnFsn_UpdateCollider(this, play); } } -void EnFsn_DrawCursor(EnFsn* this, GlobalContext* globalCtx, f32 x, f32 y, f32 z, u8 drawCursor) { +void EnFsn_DrawCursor(EnFsn* this, PlayState* play, f32 x, f32 y, f32 z, u8 drawCursor) { s32 ulx; s32 uly; s32 lrx; @@ -1469,9 +1471,9 @@ void EnFsn_DrawCursor(EnFsn* this, GlobalContext* globalCtx, f32 x, f32 y, f32 z s32 dsdx; s32 pad; - OPEN_DISPS(globalCtx->state.gfxCtx); + OPEN_DISPS(play->state.gfxCtx); if (drawCursor != 0) { - func_8012C654(globalCtx->state.gfxCtx); + func_8012C654(play->state.gfxCtx); gDPSetPrimColor(OVERLAY_DISP++, 0, 0, this->cursorColor.r, this->cursorColor.g, this->cursorColor.b, this->cursorColor.a); gDPLoadTextureBlock_4b(OVERLAY_DISP++, gSelectionCursorTex, G_IM_FMT_IA, 16, 16, 0, G_TX_MIRROR | G_TX_WRAP, @@ -1484,11 +1486,10 @@ void EnFsn_DrawCursor(EnFsn* this, GlobalContext* globalCtx, f32 x, f32 y, f32 z dsdx = (1.0f / z) * 1024.0f; gSPTextureRectangle(OVERLAY_DISP++, ulx, uly, lrx, lry, G_TX_RENDERTILE, 0, 0, dsdx, dsdx); } - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->state.gfxCtx); } -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) { +void EnFsn_DrawTextRec(PlayState* play, 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; s32 uly; @@ -1499,7 +1500,7 @@ void EnFsn_DrawTextRec(GlobalContext* globalCtx, s32 r, s32 g, s32 b, s32 a, f32 s32 dsdx; s32 dtdy; - OPEN_DISPS(globalCtx->state.gfxCtx); + OPEN_DISPS(play->state.gfxCtx); gDPPipeSync(OVERLAY_DISP++); gDPSetPrimColor(OVERLAY_DISP++, 0, 0, r, g, b, a); @@ -1516,28 +1517,28 @@ void EnFsn_DrawTextRec(GlobalContext* globalCtx, s32 r, s32 g, s32 b, s32 a, f32 dtdy = dy * unk; gSPTextureRectangle(OVERLAY_DISP++, ulx, uly, lrx, lry, G_TX_RENDERTILE, s, t, dsdx, dtdy); - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->state.gfxCtx); } -void EnFsn_DrawStickDirectionPrompts(EnFsn* this, GlobalContext* globalCtx) { +void EnFsn_DrawStickDirectionPrompts(EnFsn* this, PlayState* play) { s32 drawStickRightPrompt = this->stickLeftPrompt.isEnabled; s32 drawStickLeftPrompt = this->stickRightPrompt.isEnabled; - OPEN_DISPS(globalCtx->state.gfxCtx); + OPEN_DISPS(play->state.gfxCtx); if (drawStickRightPrompt || drawStickLeftPrompt) { - func_8012C654(globalCtx->state.gfxCtx); + func_8012C654(play->state.gfxCtx); gDPSetCombineMode(OVERLAY_DISP++, G_CC_MODULATEIA_PRIM, G_CC_MODULATEIA_PRIM); 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, + EnFsn_DrawTextRec(play, this->stickLeftPrompt.arrowColor.r, this->stickLeftPrompt.arrowColor.g, this->stickLeftPrompt.arrowColor.b, this->stickLeftPrompt.arrowColor.a, this->stickLeftPrompt.arrowTexX, this->stickLeftPrompt.arrowTexY, this->stickLeftPrompt.texZ, 0, 0, -1.0f, 1.0f); } if (drawStickLeftPrompt) { - EnFsn_DrawTextRec(globalCtx, this->stickRightPrompt.arrowColor.r, this->stickRightPrompt.arrowColor.g, + EnFsn_DrawTextRec(play, this->stickRightPrompt.arrowColor.r, this->stickRightPrompt.arrowColor.g, this->stickRightPrompt.arrowColor.b, this->stickRightPrompt.arrowColor.a, this->stickRightPrompt.arrowTexX, this->stickRightPrompt.arrowTexY, this->stickRightPrompt.texZ, 0, 0, 1.0f, 1.0f); @@ -1546,27 +1547,27 @@ void EnFsn_DrawStickDirectionPrompts(EnFsn* this, GlobalContext* globalCtx) { 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, + EnFsn_DrawTextRec(play, this->stickLeftPrompt.stickColor.r, this->stickLeftPrompt.stickColor.g, this->stickLeftPrompt.stickColor.b, this->stickLeftPrompt.stickColor.a, this->stickLeftPrompt.stickTexX, this->stickLeftPrompt.stickTexY, this->stickLeftPrompt.texZ, 0, 0, -1.0f, 1.0f); } if (drawStickLeftPrompt) { - EnFsn_DrawTextRec(globalCtx, this->stickRightPrompt.stickColor.r, this->stickRightPrompt.stickColor.g, + EnFsn_DrawTextRec(play, this->stickRightPrompt.stickColor.r, this->stickRightPrompt.stickColor.g, this->stickRightPrompt.stickColor.b, this->stickRightPrompt.stickColor.a, this->stickRightPrompt.stickTexX, this->stickRightPrompt.stickTexY, this->stickRightPrompt.texZ, 0, 0, 1.0f, 1.0f); } } - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->state.gfxCtx); } -s32 EnFsn_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, Actor* thisx) { +s32 EnFsn_OverrideLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, Actor* thisx) { EnFsn* this = THIS; s32 limbRotTableIdx; if (limbIndex == FSN_LIMB_HEAD) { - Matrix_InsertXRotation_s(this->headRot.y, MTXMODE_APPLY); + Matrix_RotateXS(this->headRot.y, MTXMODE_APPLY); } if (ENFSN_IS_BACKROOM(&this->actor)) { switch (limbIndex) { @@ -1594,7 +1595,7 @@ s32 EnFsn_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, return false; } -void EnFsn_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx) { +void EnFsn_PostLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx) { EnFsn* this = THIS; if (limbIndex == FSN_LIMB_HEAD) { @@ -1602,24 +1603,24 @@ void EnFsn_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Ve 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); + OPEN_DISPS(play->state.gfxCtx); gSPDisplayList(POLY_OPA_DISP++, gFsnGlassesFrameDL); gSPDisplayList(POLY_OPA_DISP++, gFsnGlassesLensesDL); - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->state.gfxCtx); } } -void EnFsn_Draw(Actor* thisx, GlobalContext* globalCtx) { +void EnFsn_Draw(Actor* thisx, PlayState* play) { static TexturePtr sEyeTextures[] = { gFsnEyeOpenTex, gFsnEyeHalfTex, gFsnEyeClosedTex }; s32 pad; EnFsn* this = THIS; s16 i; - OPEN_DISPS(globalCtx->state.gfxCtx); - func_8012C5B0(globalCtx->state.gfxCtx); + OPEN_DISPS(play->state.gfxCtx); + func_8012C5B0(play->state.gfxCtx); gSPSegment(POLY_OPA_DISP++, 0x08, Lib_SegmentedToVirtual(sEyeTextures[this->eyeTextureIdx])); gSPSegment(POLY_OPA_DISP++, 0x09, Lib_SegmentedToVirtual(sEyeTextures[this->eyeTextureIdx])); - SkelAnime_DrawFlexOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, + SkelAnime_DrawFlexOpa(play, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, EnFsn_OverrideLimbDraw, EnFsn_PostLimbDraw, &this->actor); for (i = 0; i < this->totalSellingItems; i++) { @@ -1628,7 +1629,7 @@ void EnFsn_Draw(Actor* thisx, GlobalContext* globalCtx) { this->items[i]->actor.scale.z = 0.2f; } - EnFsn_DrawCursor(this, globalCtx, this->cursorPos.x, this->cursorPos.y, this->cursorPos.z, this->drawCursor); - EnFsn_DrawStickDirectionPrompts(this, globalCtx); - CLOSE_DISPS(globalCtx->state.gfxCtx); + EnFsn_DrawCursor(this, play, this->cursorPos.x, this->cursorPos.y, this->cursorPos.z, this->drawCursor); + EnFsn_DrawStickDirectionPrompts(this, play); + CLOSE_DISPS(play->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 5fabf59ad..9479e982e 100644 --- a/src/overlays/actors/ovl_En_Fsn/z_en_fsn.h +++ b/src/overlays/actors/ovl_En_Fsn/z_en_fsn.h @@ -15,20 +15,20 @@ struct EnFsn; -typedef void (*EnFsnActionFunc)(struct EnFsn*, GlobalContext*); +typedef void (*EnFsnActionFunc)(struct EnFsn*, PlayState*); typedef struct EnFsn { /* 0x000 */ Actor actor; /* 0x144 */ UNK_TYPE1 pad144[0x4C]; /* 0x190 */ SkelAnime skelAnime; /* 0x1D4 */ EnFsnActionFunc actionFunc; - /* 0x1D8 */ EnFsnActionFunc tmpActionFunc; // Used to return to correct browsing function + /* 0x1D8 */ EnFsnActionFunc prevActionFunc; // Used to return to correct browsing function /* 0x1DC */ ColliderCylinder collider; /* 0x228 */ s16 limbRotYTable[19]; /* 0x24E */ s16 limbRotZTable[19]; /* 0x274 */ Vec3s headRot; /* 0x27A */ Vec3s unk27A; // Set but never used - /* 0x280 */ Vec3s jointTable[FSN_LIMB_MAX + 1]; + /* 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; @@ -64,7 +64,7 @@ typedef struct EnFsn { /* 0x444 */ u8 arrowAnimState; /* 0x445 */ u8 stickAnimState; /* 0x448 */ f32 shopItemSelectedTween; - /* 0x44C */ s16 animationIndex; + /* 0x44C */ s16 animIndex; /* 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 b67a3080e..5e3b46fe6 100644 --- a/src/overlays/actors/ovl_En_Fu/z_en_fu.c +++ b/src/overlays/actors/ovl_En_Fu/z_en_fu.c @@ -16,44 +16,44 @@ #define THIS ((EnFu*)thisx) -void EnFu_Init(Actor* thisx, GlobalContext* globalCtx); -void EnFu_Destroy(Actor* thisx, GlobalContext* globalCtx); -void EnFu_Update(Actor* thisx, GlobalContext* globalCtx); -void EnFu_Draw(Actor* thisx, GlobalContext* globalCtx); +void EnFu_Init(Actor* thisx, PlayState* play); +void EnFu_Destroy(Actor* thisx, PlayState* play); +void EnFu_Update(Actor* thisx, PlayState* play); +void EnFu_Draw(Actor* thisx, PlayState* play); void func_809622FC(EnFu* this); -void func_80962340(EnFu* this, GlobalContext* globalCtx); +void func_80962340(EnFu* this, PlayState* play); void func_809628BC(EnFu* this); -void func_809628D0(EnFu* this, GlobalContext* globalCtx); +void func_809628D0(EnFu* this, PlayState* play); void func_809629F8(EnFu* this); -void func_80962A10(EnFu* this, GlobalContext* globalCtx); +void func_80962A10(EnFu* this, PlayState* play); void func_80962BA8(EnFu* this); -void func_80962BCC(EnFu* this, GlobalContext* globalCtx); +void func_80962BCC(EnFu* this, PlayState* play); void func_80962D48(EnFu* this); -void func_80962D60(EnFu* this, GlobalContext* globalCtx); +void func_80962D60(EnFu* this, PlayState* play); void func_80962F10(EnFu* this); -void func_80962F4C(EnFu* this, GlobalContext* globalCtx); -void func_8096326C(EnFu* this, GlobalContext* globalCtx); +void func_80962F4C(EnFu* this, PlayState* play); +void func_8096326C(EnFu* this, PlayState* play); void func_809632D0(EnFu* this); -void func_80963350(EnFu* this, GlobalContext* globalCtx); +void func_80963350(EnFu* this, PlayState* play); void func_80963540(EnFu* this); -void func_80963560(EnFu* this, GlobalContext* globalCtx); +void func_80963560(EnFu* this, PlayState* play); void func_80963610(EnFu* this); -void func_80963630(EnFu* this, GlobalContext* globalCtx); -s32 func_80963810(GlobalContext* globalCtx, Vec3f pos); -s32 func_809638F8(GlobalContext* globalCtx); -void func_809639D0(EnFu* this, GlobalContext* globalCtx); -void func_80963DE4(EnFu* this, GlobalContext* globalCtx); -void func_80963EAC(EnFu* this, GlobalContext* globalCtx); -void func_80963F44(EnFu* this, GlobalContext* globalCtx); -void func_80963F88(EnFu* this, GlobalContext* globalCtx); -void func_80963FF8(EnFu* this, GlobalContext* globalCtx); -void func_8096413C(EnFu* this, GlobalContext* globalCtx); -void func_80964190(EnFu* this, GlobalContext* globalCtx); -void func_8096426C(EnFu* this, GlobalContext* globalCtx); +void func_80963630(EnFu* this, PlayState* play); +s32 func_80963810(PlayState* play, Vec3f pos); +s32 func_809638F8(PlayState* play); +void func_809639D0(EnFu* this, PlayState* play); +void func_80963DE4(EnFu* this, PlayState* play); +void func_80963EAC(EnFu* this, PlayState* play); +void func_80963F44(EnFu* this, PlayState* play); +void func_80963F88(EnFu* this, PlayState* play); +void func_80963FF8(EnFu* this, PlayState* play); +void func_8096413C(EnFu* this, PlayState* play); +void func_80964190(EnFu* this, PlayState* play); +void func_8096426C(EnFu* this, PlayState* play); void func_80964694(EnFu* this, EnFuUnkStruct* ptr, Vec3f* arg2, s32 len); -void func_809647EC(GlobalContext* globalCtx, EnFuUnkStruct* ptr, s32 len); -void func_80964950(GlobalContext* globalCtx, EnFuUnkStruct* ptr, s32 len); +void func_809647EC(PlayState* play, EnFuUnkStruct* ptr, s32 len); +void func_80964950(PlayState* play, EnFuUnkStruct* ptr, s32 len); const ActorInit En_Fu_InitVars = { ACTOR_EN_FU, @@ -73,7 +73,7 @@ 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 AnimationInfo sAnimations[] = { +static AnimationInfo sAnimationInfo[] = { { &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 }, @@ -103,7 +103,7 @@ static ColliderCylinderInit sCylinderInit = { { 20, 50, 0, { 0, 0, 0 } }, }; -void func_809616E0(EnFu* this, GlobalContext* globalCtx) { +void func_809616E0(EnFu* this, PlayState* play) { s32 i; f32 temp_f20; f32 temp_f22; @@ -122,7 +122,7 @@ void func_809616E0(EnFu* this, GlobalContext* globalCtx) { atan = Math_FAtan2F(temp_f22, temp_f20); if (!spA0 || ((i % 2) != 0)) { - Actor_Spawn(&globalCtx->actorCtx, globalCtx, this->unk_544, this->unk_538[i].x, this->unk_538[i].y, + Actor_Spawn(&play->actorCtx, play, this->unk_544, this->unk_538[i].x, this->unk_538[i].y, this->unk_538[i].z, 0, atan, 0, i); this->unk_54C++; } @@ -136,17 +136,17 @@ void func_809616E0(EnFu* this, GlobalContext* globalCtx) { sp94.x = this->unk_538[i].x; sp94.y = this->unk_538[i].y; sp94.z = this->unk_538[i].z; - func_800B0EB0(globalCtx, &sp94, &sp88, &sp7C, &sp78, &sp74, 100, 150, 10); + func_800B0EB0(play, &sp94, &sp88, &sp7C, &sp78, &sp74, 100, 150, 10); sp94.x -= 0.1f * temp_f20; sp94.z -= 0.1f * temp_f22; - func_800B3030(globalCtx, &sp94, &sp88, &sp7C, 100, 0, 3); + func_800B3030(play, &sp94, &sp88, &sp7C, 100, 0, 3); } } } -void func_809619D0(EnFu* this, GlobalContext* globalCtx) { +void func_809619D0(EnFu* this, PlayState* play) { s32 i; - Path* path = &globalCtx->setupPathList[ENFU_GET_FF00(&this->actor)]; + Path* path = &play->setupPathList[ENFU_GET_FF00(&this->actor)]; switch (CURRENT_DAY) { case 1: @@ -171,18 +171,18 @@ void func_809619D0(EnFu* this, GlobalContext* globalCtx) { } for (i = 0; i < this->unk_542; i++) { - path = &globalCtx->setupPathList[path->unk1]; + path = &play->setupPathList[path->unk1]; } this->unk_520 = path->count; this->unk_538 = Lib_SegmentedToVirtual(path->points); - func_809616E0(this, globalCtx); + func_809616E0(this, play); } -void EnFu_Init(Actor* thisx, GlobalContext* globalCtx) { +void EnFu_Init(Actor* thisx, PlayState* play) { s32 pad; EnFu* this = THIS; - Actor* fuKaiten = globalCtx->actorCtx.actorLists[ACTORCAT_BG].first; + Actor* fuKaiten = play->actorCtx.actorLists[ACTORCAT_BG].first; while (fuKaiten != NULL) { if (fuKaiten->id == ACTOR_BG_FU_KAITEN) { @@ -194,10 +194,10 @@ void EnFu_Init(Actor* thisx, GlobalContext* globalCtx) { if (fuKaiten != NULL) { ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 36.0f); - SkelAnime_InitFlex(globalCtx, &this->skelAnime, &object_mu_Skel_00B2B0, &object_mu_Anim_001F74, - this->jointTable, this->morphTable, 21); - Collider_InitCylinder(globalCtx, &this->collider); - Collider_SetCylinder(globalCtx, &this->collider, &this->actor, &sCylinderInit); + SkelAnime_InitFlex(play, &this->skelAnime, &object_mu_Skel_00B2B0, &object_mu_Anim_001F74, this->jointTable, + this->morphTable, 21); + Collider_InitCylinder(play, &this->collider); + Collider_SetCylinder(play, &this->collider, &this->actor, &sCylinderInit); this->actor.colChkInfo.mass = MASS_IMMOVABLE; Actor_SetScale(&this->actor, 0.01f); this->actor.flags &= ~ACTOR_FLAG_1; @@ -214,24 +214,24 @@ void EnFu_Init(Actor* thisx, GlobalContext* globalCtx) { this->unk_550 = 0; func_809622FC(this); this->actor.targetMode = 6; - func_809619D0(this, globalCtx); + func_809619D0(this, play); if (CURRENT_DAY == 2) { Vec3f sp40 = this->actor.child->home.pos; - this->unk_2D4 = (BgFuMizu*)Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_BG_FU_MIZU, sp40.x, sp40.y, - sp40.z, 0, 0, 0, 0); + this->unk_2D4 = + (BgFuMizu*)Actor_Spawn(&play->actorCtx, play, ACTOR_BG_FU_MIZU, sp40.x, sp40.y, sp40.z, 0, 0, 0, 0); } else { this->unk_2D4 = NULL; } } } -void EnFu_Destroy(Actor* thisx, GlobalContext* globalCtx) { +void EnFu_Destroy(Actor* thisx, PlayState* play) { EnFu* this = THIS; gSaveContext.save.weekEventReg[63] &= (u8)~1; gSaveContext.save.weekEventReg[8] &= (u8)~1; - Collider_DestroyCylinder(globalCtx, &this->collider); + Collider_DestroyCylinder(play, &this->collider); } s32 func_80961D10(EnFu* this) { @@ -250,15 +250,15 @@ s32 func_80961D10(EnFu* this) { return false; } -void func_80961D7C(GlobalContext* globalCtx) { - Actor* explosive = globalCtx->actorCtx.actorLists[ACTORCAT_EXPLOSIVES].first; +void func_80961D7C(PlayState* play) { + Actor* explosive = play->actorCtx.actorLists[ACTORCAT_EXPLOSIVES].first; while (explosive != NULL) { if ((explosive->id == ACTOR_EN_BOM) && (explosive->bgCheckFlags & 1)) { EnBom* bomb = (EnBom*)explosive; if (bomb->actor.floorBgId != BGCHECK_SCENE) { - DynaPolyActor* fuKago = DynaPoly_GetActor(&globalCtx->colCtx, bomb->actor.floorBgId); + DynaPolyActor* fuKago = DynaPoly_GetActor(&play->colCtx, bomb->actor.floorBgId); if ((fuKago != NULL) && (fuKago->actor.id == ACTOR_EN_FU_KAGO)) { Math_SmoothStepToF(&bomb->actor.world.pos.x, fuKago->actor.world.pos.x, 0.1f, 1.0f, 0.5f); @@ -270,8 +270,8 @@ void func_80961D7C(GlobalContext* globalCtx) { } } -void func_80961E88(GlobalContext* globalCtx) { - Actor* explosive = globalCtx->actorCtx.actorLists[ACTORCAT_EXPLOSIVES].first; +void func_80961E88(PlayState* play) { + Actor* explosive = play->actorCtx.actorLists[ACTORCAT_EXPLOSIVES].first; while (explosive != NULL) { Actor_MarkForDeath(explosive); @@ -279,8 +279,8 @@ void func_80961E88(GlobalContext* globalCtx) { } } -void func_80961EC8(GlobalContext* globalCtx) { - Actor* fuMato = globalCtx->actorCtx.actorLists[ACTORCAT_BG].first; +void func_80961EC8(PlayState* play) { + Actor* fuMato = play->actorCtx.actorLists[ACTORCAT_BG].first; while (fuMato != NULL) { if (fuMato->id == ACTOR_EN_FU_MATO) { @@ -290,8 +290,8 @@ void func_80961EC8(GlobalContext* globalCtx) { } } -void func_80961F00(GlobalContext* globalCtx) { - Actor* fuKago = globalCtx->actorCtx.actorLists[ACTORCAT_BG].first; +void func_80961F00(PlayState* play) { + Actor* fuKago = play->actorCtx.actorLists[ACTORCAT_BG].first; while (fuKago != NULL) { if (fuKago->id == ACTOR_EN_FU_KAGO) { @@ -301,8 +301,8 @@ void func_80961F00(GlobalContext* globalCtx) { } } -void func_80961F38(GlobalContext* globalCtx, Vec3f* arg1, s16* arg2, s16 arg3, s16 arg4, s16 arg5) { - Player* player = GET_PLAYER(globalCtx); +void func_80961F38(PlayState* play, Vec3f* arg1, s16* arg2, s16 arg3, s16 arg4, s16 arg5) { + Player* player = GET_PLAYER(play); s16 sp42; s16 sp40; Vec3f sp34 = player->actor.focus.pos; @@ -330,11 +330,11 @@ void func_80961F38(GlobalContext* globalCtx, Vec3f* arg1, s16* arg2, s16 arg3, s Math_SmoothStepToS(&arg2[2], 0, 6, 2000, 100); } -void func_8096209C(EnFu* this, GlobalContext* globalCtx) { +void func_8096209C(EnFu* this, PlayState* play) { Vec3f sp34; if (this->unk_53C & 1) { - func_80961F38(globalCtx, &this->unk_508, this->unk_524, this->actor.shape.rot.y, 0x38E3, 0x6AAA); + func_80961F38(play, &this->unk_508, this->unk_524, this->actor.shape.rot.y, 0x38E3, 0x6AAA); } else { Math_SmoothStepToS(&this->unk_524[0], 0, 6, 6000, 100); Math_SmoothStepToS(&this->unk_524[1], 0, 6, 6000, 100); @@ -344,7 +344,7 @@ void func_8096209C(EnFu* this, GlobalContext* globalCtx) { if (this->unk_53C & 2) { s16 rotY = BINANG_SUB(this->actor.shape.rot.y, 0x8000); - func_80961F38(globalCtx, &this->unk_514, this->unk_52A, rotY, 0x38E3, 0x5555); + func_80961F38(play, &this->unk_514, this->unk_52A, rotY, 0x38E3, 0x5555); } else { Math_SmoothStepToS(&this->unk_52A[0], 0, 6, 6000, 100); Math_SmoothStepToS(&this->unk_52A[1], 0, 6, 6000, 100); @@ -361,101 +361,101 @@ 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_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 1); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, 1); this->actionFunc = func_80962340; } -void func_80962340(EnFu* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); +void func_80962340(EnFu* this, PlayState* play) { + Player* player = GET_PLAYER(play); if (this->unk_54A == 2) { this->actor.flags |= ACTOR_FLAG_10000; } - if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { + if (Actor_ProcessTalkRequest(&this->actor, &play->state)) { if (this->unk_54A == 2) { if (this->unk_552 == 0x287D) { if (gSaveContext.save.playerForm == PLAYER_FORM_DEKU) { - Message_StartTextbox(globalCtx, 0x287E, &this->actor); + Message_StartTextbox(play, 0x287E, &this->actor); this->unk_552 = 0x287E; } else if ((CURRENT_DAY == 3) && (gSaveContext.save.weekEventReg[22] & 0x10) && (gSaveContext.save.weekEventReg[22] & 0x20)) { if ((gSaveContext.save.weekEventReg[22] & 0x40)) { - Message_StartTextbox(globalCtx, 0x2883, &this->actor); + Message_StartTextbox(play, 0x2883, &this->actor); this->unk_552 = 0x2883; } else { - Message_StartTextbox(globalCtx, 0x2880, &this->actor); + Message_StartTextbox(play, 0x2880, &this->actor); this->unk_552 = 0x2880; } } else { - Message_StartTextbox(globalCtx, 0x287E, &this->actor); + Message_StartTextbox(play, 0x287E, &this->actor); this->unk_552 = 0x287E; } } else if ((gSaveContext.unk_3DE0[4] == 0) && (this->unk_552 != 0x2888)) { - Message_StartTextbox(globalCtx, 0x2886, &this->actor); + Message_StartTextbox(play, 0x2886, &this->actor); this->unk_552 = 0x2886; } else { - Message_StartTextbox(globalCtx, 0x2889, &this->actor); + Message_StartTextbox(play, 0x2889, &this->actor); this->unk_552 = 0x2889; } this->actor.flags &= ~ACTOR_FLAG_10000; player->stateFlags1 &= ~0x20; this->unk_54A = 1; } else { - Message_StartTextbox(globalCtx, 0x283C, &this->actor); + Message_StartTextbox(play, 0x283C, &this->actor); this->unk_552 = 0x283C; } func_809628BC(this); } else if (this->unk_54A == 2) { - func_800B8614(&this->actor, globalCtx, 500.0f); + func_800B8614(&this->actor, play, 500.0f); } else { - func_800B8614(&this->actor, globalCtx, 100.0f); + func_800B8614(&this->actor, play, 100.0f); } Math_SmoothStepToS(&this->actor.shape.rot.y, BINANG_SUB(this->actor.child->shape.rot.y, 0x4000), 10, 3000, 100); } -void func_80962588(EnFu* this, GlobalContext* globalCtx) { - if (Message_ShouldAdvance(globalCtx) && (this->unk_552 == 0x2871)) { +void func_80962588(EnFu* this, PlayState* play) { + if (Message_ShouldAdvance(play) && (this->unk_552 == 0x2871)) { if (1) {} - if (globalCtx->msgCtx.choiceIndex == 0) { + if (play->msgCtx.choiceIndex == 0) { if (gSaveContext.save.playerData.rupees >= 10) { func_8019F208(); - func_801159EC(-10); - func_80963DE4(this, globalCtx); + Rupees_ChangeBy(-10); + func_80963DE4(this, play); } else { play_sound(NA_SE_SY_ERROR); - Message_StartTextbox(globalCtx, 0x2873, &this->actor); + Message_StartTextbox(play, 0x2873, &this->actor); this->unk_552 = 0x2873; } } else { func_8019F230(); - Message_StartTextbox(globalCtx, 0x2872, &this->actor); + Message_StartTextbox(play, 0x2872, &this->actor); this->unk_552 = 0x2872; } } } -void func_80962660(EnFu* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); +void func_80962660(EnFu* this, PlayState* play) { + Player* player = GET_PLAYER(play); - if (Message_ShouldAdvance(globalCtx)) { + if (Message_ShouldAdvance(play)) { switch (this->unk_552) { case 0x283C: - func_80963F44(this, globalCtx); + func_80963F44(this, play); break; case 0x283D: - func_809639D0(this, globalCtx); + func_809639D0(this, play); break; case 0x283E: @@ -463,11 +463,11 @@ void func_80962660(EnFu* this, GlobalContext* globalCtx) { case 0x2841: case 0x2843: case 0x2845: - func_80963F44(this, globalCtx); + func_80963F44(this, play); break; case 0x2846: - Message_StartTextbox(globalCtx, 0x2849, &this->actor); + Message_StartTextbox(play, 0x2849, &this->actor); this->unk_552 = 0x2849; break; @@ -497,7 +497,7 @@ void func_80962660(EnFu* this, GlobalContext* globalCtx) { case 0x2877: case 0x2879: case 0x287B: - func_80963F44(this, globalCtx); + func_80963F44(this, play); break; case 0x2848: @@ -518,7 +518,7 @@ void func_80962660(EnFu* this, GlobalContext* globalCtx) { case 0x286A: case 0x286C: case 0x286E: - Message_StartTextbox(globalCtx, 0x2871, &this->actor); + Message_StartTextbox(play, 0x2871, &this->actor); this->unk_552 = 0x2871; break; @@ -526,31 +526,31 @@ void func_80962660(EnFu* this, GlobalContext* globalCtx) { case 0x2878: case 0x287A: case 0x287C: - Message_StartTextbox(globalCtx, 0x287D, &this->actor); + Message_StartTextbox(play, 0x287D, &this->actor); this->unk_552 = 0x287D; break; case 0x287D: gSaveContext.save.weekEventReg[63] |= 1; gSaveContext.save.weekEventReg[63] &= (u8)~2; - func_801477B4(globalCtx); + func_801477B4(play); player->stateFlags1 |= 0x20; this->unk_53C = 0; - Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 3); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, 3); func_801A2BB8(NA_BGM_MINI_GAME_2); if (this->unk_542 == 0) { if (this->unk_546 == 1) { - func_80961EC8(globalCtx); + func_80961EC8(play); } func_809629F8(this); } else if (this->unk_542 == 1) { if (this->unk_546 == 1) { - func_80961F00(globalCtx); + func_80961F00(play); } func_80962BA8(this); } else if (this->unk_542 == 2) { if (this->unk_546 == 1) { - func_80961EC8(globalCtx); + func_80961EC8(play); } func_80962D48(this); } @@ -559,14 +559,14 @@ void func_80962660(EnFu* this, GlobalContext* globalCtx) { case 0x287E: case 0x2880: case 0x2883: - func_801477B4(globalCtx); + func_801477B4(play); func_80963540(this); - func_80963560(this, globalCtx); + func_80963560(this, play); break; case 0x2886: case 0x2889: - func_80963F44(this, globalCtx); + func_80963F44(this, play); break; } } @@ -576,26 +576,26 @@ void func_809628BC(EnFu* this) { this->actionFunc = func_809628D0; } -void func_809628D0(EnFu* this, GlobalContext* globalCtx) { - u8 sp27 = Message_GetState(&globalCtx->msgCtx); +void func_809628D0(EnFu* this, PlayState* play) { + u8 talkState = Message_GetState(&play->msgCtx); - switch (sp27) { - case 0: - case 1: - case 2: - case 3: + switch (talkState) { + case TEXT_STATE_NONE: + case TEXT_STATE_1: + case TEXT_STATE_CLOSING: + case TEXT_STATE_3: break; - case 4: - func_80962588(this, globalCtx); + case TEXT_STATE_CHOICE: + func_80962588(this, play); break; - case 5: - func_80962660(this, globalCtx); + case TEXT_STATE_5: + func_80962660(this, play); break; - case 6: - if (Message_ShouldAdvance(globalCtx)) { + case TEXT_STATE_DONE: + if (Message_ShouldAdvance(play)) { this->unk_54A = 1; switch (this->unk_552) { case 0x287F: @@ -617,12 +617,12 @@ void func_809628D0(EnFu* this, GlobalContext* globalCtx) { break; } - if (sp27 != 3) { - func_80964190(this, globalCtx); - func_8096426C(this, globalCtx); + if (talkState != TEXT_STATE_3) { + func_80964190(this, play); + func_8096426C(this, play); } - func_8096413C(this, globalCtx); + func_8096413C(this, play); } void func_809629F8(EnFu* this) { @@ -630,8 +630,8 @@ void func_809629F8(EnFu* this) { this->actionFunc = func_80962A10; } -void func_80962A10(EnFu* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); +void func_80962A10(EnFu* this, PlayState* play) { + Player* player = GET_PLAYER(play); BgFuKaiten* fuKaiten = (BgFuKaiten*)this->actor.child; this->unk_53C = 0; @@ -646,15 +646,14 @@ void func_80962A10(EnFu* this, GlobalContext* globalCtx) { player->stateFlags1 &= ~0x20; func_8010E9F0(4, 60); if (this->unk_546 == 1) { - func_809616E0(this, globalCtx); + func_809616E0(this, play); } else { this->unk_546 = 1; } if ((gSaveContext.save.playerForm == PLAYER_FORM_DEKU) && gSaveContext.save.playerData.magicAcquired) { - s16 temp = gSaveContext.unk_3F30; - - Parameter_AddMagic(globalCtx, temp + (gSaveContext.save.playerData.doubleMagic * 48) + 48); + Parameter_AddMagic(play, + ((void)0, gSaveContext.unk_3F30) + (gSaveContext.save.playerData.doubleMagic * 48) + 48); } func_80962F10(this); @@ -668,8 +667,8 @@ void func_80962BA8(EnFu* this) { this->actionFunc = func_80962BCC; } -void func_80962BCC(EnFu* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); +void func_80962BCC(EnFu* this, PlayState* play) { + Player* player = GET_PLAYER(play); BgFuKaiten* fuKaiten = (BgFuKaiten*)this->actor.child; if ((fuKaiten->rotationSpeed < 100) || (fuKaiten->bounceHeight < 30.0f) || (fuKaiten->bounceSpeed < 600)) { @@ -686,12 +685,12 @@ void func_80962BCC(EnFu* this, GlobalContext* globalCtx) { func_8010E9F0(4, 60); if (this->unk_546 == 1) { - func_809616E0(this, globalCtx); + func_809616E0(this, play); } else { this->unk_546 = 1; } - globalCtx->unk_1887E = 30; + play->unk_1887E = 30; func_80962F10(this); } @@ -700,8 +699,8 @@ void func_80962D48(EnFu* this) { this->actionFunc = func_80962D60; } -void func_80962D60(EnFu* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); +void func_80962D60(EnFu* this, PlayState* play) { + Player* player = GET_PLAYER(play); BgFuKaiten* fuKaiten = (BgFuKaiten*)this->actor.child; if ((fuKaiten->rotationSpeed < 100) || (fuKaiten->bounceHeight < 40.0f) || (fuKaiten->bounceSpeed < 600)) { @@ -717,19 +716,19 @@ void func_80962D60(EnFu* this, GlobalContext* globalCtx) { func_8010E9F0(4, 60); if (this->unk_546 == 1) { - func_809616E0(this, globalCtx); + func_809616E0(this, play); } else { this->unk_546 = 1; } - globalCtx->unk_1887D = 30; + play->unk_1887D = 30; func_80962F10(this); } -void func_80962EBC(EnFu* this, GlobalContext* globalCtx) { +void func_80962EBC(EnFu* this, PlayState* play) { if (this->unk_542 != 0) { if (this->actor.cutscene != -1) { - Camera_ChangeDataIdx(globalCtx->cameraPtrs[CAM_ID_MAIN], + Camera_ChangeDataIdx(play->cameraPtrs[CAM_ID_MAIN], ActorCutscene_GetCutscene(this->actor.cutscene)->csCamSceneDataId); } } @@ -742,8 +741,8 @@ void func_80962F10(EnFu* this) { this->actionFunc = func_80962F4C; } -void func_80962F4C(EnFu* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); +void func_80962F4C(EnFu* this, PlayState* play) { + Player* player = GET_PLAYER(play); BgFuKaiten* fuKaiten = (BgFuKaiten*)this->actor.child; switch (this->unk_542) { @@ -754,11 +753,11 @@ void func_80962F4C(EnFu* this, GlobalContext* globalCtx) { break; case 1: - globalCtx->unk_1887E = 30; + play->unk_1887E = 30; break; case 2: - globalCtx->unk_1887D = 30; + play->unk_1887D = 30; break; } @@ -773,21 +772,21 @@ void func_80962F4C(EnFu* this, GlobalContext* globalCtx) { } if (func_80961D10(this)) { - Message_StartTextbox(globalCtx, 0x288B, &this->actor); + Message_StartTextbox(play, 0x288B, &this->actor); } if ((!DynaPolyActor_IsInRidingRotatingState((DynaPolyActor*)this->actor.child) && (player->actor.bgCheckFlags & 1)) || (gSaveContext.unk_3DE0[4] < 1) || (this->unk_548 == this->unk_54C)) { player->stateFlags3 &= ~0x400000; - func_80961E88(globalCtx); + func_80961E88(play); player->stateFlags1 |= 0x20; if (this->unk_548 < this->unk_54C) { if (gSaveContext.unk_3DE0[4] == 0) { - Message_StartTextbox(globalCtx, 0x2885, &this->actor); + Message_StartTextbox(play, 0x2885, &this->actor); this->unk_552 = 0x2885; } else { - Message_StartTextbox(globalCtx, 0x2888, &this->actor); + Message_StartTextbox(play, 0x2888, &this->actor); this->unk_552 = 0x2888; } func_801A2C20(); @@ -801,21 +800,21 @@ void func_80962F4C(EnFu* this, GlobalContext* globalCtx) { gSaveContext.unk_3DE0[4] = 0; gSaveContext.unk_3DD0[4] = 5; func_801A3098(NA_BGM_GET_ITEM | 0x900); - func_8011B4E0(globalCtx, 1); + func_8011B4E0(play, 1); this->unk_54A = 3; func_809632D0(this); } } - func_80962EBC(this, globalCtx); + func_80962EBC(this, play); } void func_80963258(EnFu* this) { this->actionFunc = func_8096326C; } -void func_8096326C(EnFu* this, GlobalContext* globalCtx) { - func_80963FF8(this, globalCtx); - if (func_80963810(globalCtx, this->actor.world.pos)) { +void func_8096326C(EnFu* this, PlayState* play) { + func_80963FF8(this, play); + if (func_80963810(play, this->actor.world.pos)) { func_809622FC(this); } } @@ -837,34 +836,35 @@ void func_809632D0(EnFu* this) { this->actionFunc = func_80963350; } -void func_80963350(EnFu* this, GlobalContext* globalCtx) { +void func_80963350(EnFu* this, PlayState* play) { static s32 D_80964C24 = 0; BgFuKaiten* fuKaiten = (BgFuKaiten*)this->actor.child; - if ((this->unk_54A == 0) && (((Message_GetState(&globalCtx->msgCtx) == 5) && Message_ShouldAdvance(globalCtx)) || - ((Message_GetState(&globalCtx->msgCtx) == 2) && (globalCtx->msgCtx.unk12023 == 1)))) { - func_801477B4(globalCtx); + if ((this->unk_54A == 0) && + (((Message_GetState(&play->msgCtx) == TEXT_STATE_5) && Message_ShouldAdvance(play)) || + ((Message_GetState(&play->msgCtx) == TEXT_STATE_CLOSING) && (play->msgCtx.stateTimer == 1)))) { + func_801477B4(play); this->unk_54A = 2; D_80964C24 = 1; } - if ((this->unk_54A == 3) && (globalCtx->interfaceCtx.unk_286 == 0)) { + if ((this->unk_54A == 3) && (play->interfaceCtx.unk_286 == 0)) { this->unk_54A = 2; D_80964C24 = 1; } if ((fuKaiten->rotationSpeed != 0) || (fuKaiten->bounceSpeed != 0) || (fuKaiten->bounceHeight > 0.0f) || - !func_809638F8(globalCtx)) { + !func_809638F8(play)) { Math_SmoothStepToS(&fuKaiten->rotationSpeed, 0, 10, 10, 5); Math_SmoothStepToS(&fuKaiten->bounceSpeed, 0, 10, 15, 5); Math_SmoothStepToF(&fuKaiten->bounceHeight, 0.0f, 0.1f, 1.0f, 1.0f); Math_SmoothStepToF(&fuKaiten->elevation, 0.0f, 0.1f, 1.0f, 1.0f); - func_80962EBC(this, globalCtx); + func_80962EBC(this, play); } else if (D_80964C24 == 1) { D_80964C24 = 0; fuKaiten->bounce = 0; - func_80963F88(this, globalCtx); - globalCtx->actorCtx.unk268 = 1; + func_80963F88(this, play); + play->actorCtx.unk268 = 1; func_80963258(this); } } @@ -874,14 +874,14 @@ void func_80963540(EnFu* this) { this->actionFunc = func_80963560; } -void func_80963560(EnFu* this, GlobalContext* globalCtx) { - if (Actor_HasParent(&this->actor, globalCtx)) { +void func_80963560(EnFu* this, PlayState* play) { + if (Actor_HasParent(&this->actor, play)) { this->actor.parent = NULL; func_80963610(this); } else if ((this->unk_552 == 0x2880) && !(gSaveContext.save.weekEventReg[22] & 0x80)) { - Actor_PickUp(&this->actor, globalCtx, GI_HEART_PIECE, 500.0f, 100.0f); + Actor_PickUp(&this->actor, play, GI_HEART_PIECE, 500.0f, 100.0f); } else { - Actor_PickUp(&this->actor, globalCtx, GI_RUPEE_PURPLE, 500.0f, 100.0f); + Actor_PickUp(&this->actor, play, GI_RUPEE_PURPLE, 500.0f, 100.0f); } this->actor.child->freezeTimer = 10; } @@ -891,25 +891,25 @@ void func_80963610(EnFu* this) { this->actionFunc = func_80963630; } -void func_80963630(EnFu* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); +void func_80963630(EnFu* this, PlayState* play) { + Player* player = GET_PLAYER(play); - if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { + if (Actor_ProcessTalkRequest(&this->actor, &play->state)) { 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); + Message_StartTextbox(play, 0x2884, &this->actor); this->unk_552 = 0x2884; } else if (!(gSaveContext.save.weekEventReg[22] & 0x80)) { gSaveContext.save.weekEventReg[22] |= 0x80; - Message_StartTextbox(globalCtx, 0x2882, &this->actor); + Message_StartTextbox(play, 0x2882, &this->actor); this->unk_552 = 0x2882; } else { - Message_StartTextbox(globalCtx, 0x2881, &this->actor); + Message_StartTextbox(play, 0x2881, &this->actor); this->unk_552 = 0x2881; } } else { - Message_StartTextbox(globalCtx, 0x287F, &this->actor); + Message_StartTextbox(play, 0x287F, &this->actor); this->unk_552 = 0x287F; } @@ -935,12 +935,12 @@ void func_80963630(EnFu* this, GlobalContext* globalCtx) { player->stateFlags1 &= ~0x20; } else { this->actor.child->freezeTimer = 10; - func_800B85E0(&this->actor, globalCtx, 500.0f, EXCH_ITEM_MINUS1); + func_800B85E0(&this->actor, play, 500.0f, PLAYER_AP_MINUS1); } } -s32 func_80963810(GlobalContext* globalCtx, Vec3f pos) { - Player* player = GET_PLAYER(globalCtx); +s32 func_80963810(PlayState* play, Vec3f pos) { + Player* player = GET_PLAYER(play); f32 sp28; f32 phi_f0; s16 sp22; @@ -956,8 +956,8 @@ s32 func_80963810(GlobalContext* globalCtx, Vec3f pos) { phi_f0 = 80.0f; } - globalCtx->actorCtx.unk268 = 1; - func_800B6F20(globalCtx, &globalCtx->actorCtx.unk_26C, phi_f0, sp22); + play->actorCtx.unk268 = 1; + func_800B6F20(play, &play->actorCtx.unk_26C, phi_f0, sp22); if (sp28 < 80.0f) { return true; @@ -965,102 +965,102 @@ s32 func_80963810(GlobalContext* globalCtx, Vec3f pos) { return false; } -s32 func_809638F8(GlobalContext* globalCtx) { +s32 func_809638F8(PlayState* play) { s32 ret = true; - if (globalCtx->envCtx.lightSettings.diffuseColor1[0] > 25) { - globalCtx->envCtx.lightSettings.diffuseColor1[0] -= 25; + if (play->envCtx.lightSettings.diffuseColor1[0] > 25) { + play->envCtx.lightSettings.diffuseColor1[0] -= 25; ret = false; } else { - globalCtx->envCtx.lightSettings.diffuseColor1[0] = 0; + play->envCtx.lightSettings.diffuseColor1[0] = 0; } - if (globalCtx->envCtx.lightSettings.diffuseColor1[1] > 25) { - globalCtx->envCtx.lightSettings.diffuseColor1[1] -= 25; + if (play->envCtx.lightSettings.diffuseColor1[1] > 25) { + play->envCtx.lightSettings.diffuseColor1[1] -= 25; ret = false; } else { - globalCtx->envCtx.lightSettings.diffuseColor1[1] = 0; + play->envCtx.lightSettings.diffuseColor1[1] = 0; } - if (globalCtx->envCtx.lightSettings.diffuseColor1[2] > 25) { - globalCtx->envCtx.lightSettings.diffuseColor1[2] -= 25; + if (play->envCtx.lightSettings.diffuseColor1[2] > 25) { + play->envCtx.lightSettings.diffuseColor1[2] -= 25; ret = false; } else { - globalCtx->envCtx.lightSettings.diffuseColor1[2] = 0; + play->envCtx.lightSettings.diffuseColor1[2] = 0; } - if (globalCtx->envCtx.lightSettings.ambientColor[0] > 25) { - globalCtx->envCtx.lightSettings.ambientColor[0] -= 25; + if (play->envCtx.lightSettings.ambientColor[0] > 25) { + play->envCtx.lightSettings.ambientColor[0] -= 25; ret = false; } else { - globalCtx->envCtx.lightSettings.ambientColor[0] = 0; + play->envCtx.lightSettings.ambientColor[0] = 0; } - if (globalCtx->envCtx.lightSettings.ambientColor[1] > 25) { - globalCtx->envCtx.lightSettings.ambientColor[1] -= 25; + if (play->envCtx.lightSettings.ambientColor[1] > 25) { + play->envCtx.lightSettings.ambientColor[1] -= 25; ret = false; } else { - globalCtx->envCtx.lightSettings.ambientColor[1] = 0; + play->envCtx.lightSettings.ambientColor[1] = 0; } - if (globalCtx->envCtx.lightSettings.ambientColor[2] > 25) { - globalCtx->envCtx.lightSettings.ambientColor[2] -= 25; + if (play->envCtx.lightSettings.ambientColor[2] > 25) { + play->envCtx.lightSettings.ambientColor[2] -= 25; ret = false; } else { - globalCtx->envCtx.lightSettings.ambientColor[2] = 0; + play->envCtx.lightSettings.ambientColor[2] = 0; } return ret; } -void func_809639D0(EnFu* this, GlobalContext* globalCtx) { +void func_809639D0(EnFu* this, PlayState* play) { switch (CURRENT_DAY) { case 1: if (gSaveContext.save.playerForm == PLAYER_FORM_HUMAN) { if (CUR_UPG_VALUE(UPG_BOMB_BAG) == 0) { - Message_StartTextbox(globalCtx, 0x2853, &this->actor); + Message_StartTextbox(play, 0x2853, &this->actor); this->unk_552 = 0x2853; } else if (gSaveContext.save.weekEventReg[22] & 0x10) { - Message_StartTextbox(globalCtx, 0x284D, &this->actor); + Message_StartTextbox(play, 0x284D, &this->actor); this->unk_552 = 0x284D; } else if (this->unk_53E == 1) { - Message_StartTextbox(globalCtx, 0x284F, &this->actor); + Message_StartTextbox(play, 0x284F, &this->actor); this->unk_552 = 0x284F; } else { this->unk_53E = 1; - Message_StartTextbox(globalCtx, 0x2851, &this->actor); + Message_StartTextbox(play, 0x2851, &this->actor); this->unk_552 = 0x2851; } } else { - Message_StartTextbox(globalCtx, 0x286F, &this->actor); + Message_StartTextbox(play, 0x286F, &this->actor); this->unk_552 = 0x286F; } break; case 2: if (gSaveContext.save.playerForm != PLAYER_FORM_HUMAN) { - Message_StartTextbox(globalCtx, 0x286F, &this->actor); + Message_StartTextbox(play, 0x286F, &this->actor); this->unk_552 = 0x286F; } else if (CUR_UPG_VALUE(UPG_BOMB_BAG) == 0) { - Message_StartTextbox(globalCtx, 0x2853, &this->actor); + Message_StartTextbox(play, 0x2853, &this->actor); this->unk_552 = 0x2853; } else if (!(gSaveContext.save.weekEventReg[22] & 0x10)) { if (this->unk_53E == 1) { - Message_StartTextbox(globalCtx, 0x285B, &this->actor); + Message_StartTextbox(play, 0x285B, &this->actor); this->unk_552 = 0x285B; } else { this->unk_53E = 1; - Message_StartTextbox(globalCtx, 0x285D, &this->actor); + Message_StartTextbox(play, 0x285D, &this->actor); this->unk_552 = 0x285D; } } else if (gSaveContext.save.weekEventReg[22] & 0x20) { - Message_StartTextbox(globalCtx, 0x2855, &this->actor); + Message_StartTextbox(play, 0x2855, &this->actor); this->unk_552 = 0x2855; } else if (this->unk_53E == 1) { - Message_StartTextbox(globalCtx, 0x2857, &this->actor); + Message_StartTextbox(play, 0x2857, &this->actor); this->unk_552 = 0x2857; } else { this->unk_53E = 1; - Message_StartTextbox(globalCtx, 0x2859, &this->actor); + Message_StartTextbox(play, 0x2859, &this->actor); this->unk_552 = 0x2859; } break; @@ -1068,121 +1068,121 @@ void func_809639D0(EnFu* this, GlobalContext* globalCtx) { case 3: if (gSaveContext.save.playerForm != PLAYER_FORM_HUMAN) { if (gSaveContext.save.playerForm == PLAYER_FORM_DEKU) { - func_80963EAC(this, globalCtx); + func_80963EAC(this, play); } else { - Message_StartTextbox(globalCtx, 0x2841, &this->actor); + Message_StartTextbox(play, 0x2841, &this->actor); this->unk_552 = 0x2841; } } else if (CUR_UPG_VALUE(UPG_QUIVER) == 0) { - Message_StartTextbox(globalCtx, 0x284B, &this->actor); + Message_StartTextbox(play, 0x284B, &this->actor); this->unk_552 = 0x284B; } else if (gSaveContext.save.weekEventReg[22] & 0x40) { if ((gSaveContext.save.weekEventReg[22] & 0x10) && (gSaveContext.save.weekEventReg[22] & 0x20)) { - Message_StartTextbox(globalCtx, 0x285F, &this->actor); + Message_StartTextbox(play, 0x285F, &this->actor); this->unk_552 = 0x285F; } else { - Message_StartTextbox(globalCtx, 0x2861, &this->actor); + Message_StartTextbox(play, 0x2861, &this->actor); this->unk_552 = 0x2861; } } else if ((gSaveContext.save.weekEventReg[22] & 0x10) && (gSaveContext.save.weekEventReg[22] & 0x20)) { if (this->unk_53E == 1) { - Message_StartTextbox(globalCtx, 0x2863, &this->actor); + Message_StartTextbox(play, 0x2863, &this->actor); this->unk_552 = 0x2863; } else { this->unk_53E = 1; - Message_StartTextbox(globalCtx, 0x2865, &this->actor); + Message_StartTextbox(play, 0x2865, &this->actor); this->unk_552 = 0x2865; } } else if ((gSaveContext.save.weekEventReg[22] & 0x10) || (gSaveContext.save.weekEventReg[22] & 0x20)) { if (this->unk_53E == 1) { - Message_StartTextbox(globalCtx, 0x2867, &this->actor); + Message_StartTextbox(play, 0x2867, &this->actor); this->unk_552 = 0x2867; } else { this->unk_53E = 1; - Message_StartTextbox(globalCtx, 0x2869, &this->actor); + Message_StartTextbox(play, 0x2869, &this->actor); this->unk_552 = 0x2869; } } else if (this->unk_53E == 1) { - Message_StartTextbox(globalCtx, 0x286B, &this->actor); + Message_StartTextbox(play, 0x286B, &this->actor); this->unk_552 = 0x286B; } else { this->unk_53E = 1; - Message_StartTextbox(globalCtx, 0x286D, &this->actor); + Message_StartTextbox(play, 0x286D, &this->actor); this->unk_552 = 0x286D; } break; } } -void func_80963DE4(EnFu* this, GlobalContext* globalCtx) { +void func_80963DE4(EnFu* this, PlayState* play) { switch (this->unk_542) { case 0: if (gSaveContext.save.playerForm != PLAYER_FORM_HUMAN) { - Message_StartTextbox(globalCtx, 0x2875, &this->actor); + Message_StartTextbox(play, 0x2875, &this->actor); this->unk_552 = 0x2875; } else { - Message_StartTextbox(globalCtx, 0x2877, &this->actor); + Message_StartTextbox(play, 0x2877, &this->actor); this->unk_552 = 0x2877; } break; case 1: - Message_StartTextbox(globalCtx, 0x2879, &this->actor); + Message_StartTextbox(play, 0x2879, &this->actor); this->unk_552 = 0x2879; break; case 2: - Message_StartTextbox(globalCtx, 0x287B, &this->actor); + Message_StartTextbox(play, 0x287B, &this->actor); this->unk_552 = 0x287B; break; } } -void func_80963EAC(EnFu* this, GlobalContext* globalCtx) { +void func_80963EAC(EnFu* this, PlayState* play) { if (gSaveContext.save.playerData.magicAcquired) { if (this->unk_540 == 1) { - Message_StartTextbox(globalCtx, 0x2847, &this->actor); + Message_StartTextbox(play, 0x2847, &this->actor); this->unk_552 = 0x2847; } else { this->unk_540 = 1; - Message_StartTextbox(globalCtx, 0x2845, &this->actor); + Message_StartTextbox(play, 0x2845, &this->actor); this->unk_552 = 0x2845; } } else { - Message_StartTextbox(globalCtx, 0x2843, &this->actor); + Message_StartTextbox(play, 0x2843, &this->actor); this->unk_552 = 0x2843; } } -void func_80963F44(EnFu* this, GlobalContext* globalCtx) { +void func_80963F44(EnFu* this, PlayState* play) { u16 sp1E = this->unk_552 + 1; - Message_StartTextbox(globalCtx, sp1E, &this->actor); + Message_StartTextbox(play, sp1E, &this->actor); this->unk_552 = sp1E; } -void func_80963F88(EnFu* this, GlobalContext* globalCtx) { +void func_80963F88(EnFu* this, PlayState* play) { if (this->unk_542 == 1) { - func_800DFAC8(globalCtx->cameraPtrs[CAM_ID_MAIN], 75); - globalCtx->unk_1887E = 0; + Camera_ChangeSetting(play->cameraPtrs[CAM_ID_MAIN], CAM_SET_HONEY_AND_DARLING_2); + play->unk_1887E = 0; } else if (this->unk_542 == 2) { - globalCtx->unk_1887D = 0; - func_800DFAC8(globalCtx->cameraPtrs[CAM_ID_MAIN], 75); + play->unk_1887D = 0; + Camera_ChangeSetting(play->cameraPtrs[CAM_ID_MAIN], CAM_SET_HONEY_AND_DARLING_2); } } -void func_80963FF8(EnFu* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); +void func_80963FF8(EnFu* this, PlayState* play) { + Player* player = GET_PLAYER(play); if (player->stateFlags1 & 0x100000) { - globalCtx->actorCtx.unk268 = 1; - globalCtx->actorCtx.unk_26C.press.button = 0x8000; + play->actorCtx.unk268 = 1; + play->actorCtx.unk_26C.press.button = 0x8000; } else { - globalCtx->actorCtx.unk268 = 1; + play->actorCtx.unk268 = 1; } } -void func_80964034(EnFu* this, GlobalContext* globalCtx) { +void func_80964034(EnFu* this, PlayState* play) { Vec3f sp2C; if (DECR(this->unk_54E) == 0) { @@ -1191,10 +1191,10 @@ void func_80964034(EnFu* this, GlobalContext* globalCtx) { sp2C.y += 62.0f; func_80964694(this, this->unk_2D8, &sp2C, ARRAY_COUNT(this->unk_2D8)); } - func_809647EC(globalCtx, this->unk_2D8, ARRAY_COUNT(this->unk_2D8)); + func_809647EC(play, this->unk_2D8, ARRAY_COUNT(this->unk_2D8)); } -void func_809640D8(EnFu* this, GlobalContext* globalCtx) { +void func_809640D8(EnFu* this, PlayState* play) { if ((this->actionFunc == func_80962A10) || (this->actionFunc == func_80962BCC) || (this->actionFunc == func_80962D60) || (this->actionFunc == func_80962F4C) || (this->actionFunc == func_80963350)) { @@ -1203,18 +1203,18 @@ void func_809640D8(EnFu* this, GlobalContext* globalCtx) { } } -void func_8096413C(EnFu* this, GlobalContext* globalCtx) { +void func_8096413C(EnFu* this, PlayState* play) { Math_SmoothStepToS(&this->actor.shape.rot.y, BINANG_SUB(this->actor.yawTowardsPlayer, 0x4000), 5, 1000, 100); this->actor.world.rot.y = this->actor.shape.rot.y; } -void func_80964190(EnFu* this, GlobalContext* globalCtx) { - if (Message_ShouldAdvance(globalCtx)) { +void func_80964190(EnFu* this, PlayState* play) { + if (Message_ShouldAdvance(play)) { switch (this->unk_552) { case 0x2842: case 0x2844: case 0x2848: - Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 1); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, 1); break; case 0x2840: @@ -1240,28 +1240,28 @@ void func_80964190(EnFu* this, GlobalContext* globalCtx) { case 0x286B: case 0x286D: case 0x2871: - Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 4); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, 4); break; case 0x2860: - Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 5); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, 5); break; case 0x285F: - Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 6); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, 6); break; case 0x287E: case 0x2880: case 0x2883: - Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 2); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, 2); break; } } } -void func_8096426C(EnFu* this, GlobalContext* globalCtx) { - if (Message_ShouldAdvance(globalCtx)) { +void func_8096426C(EnFu* this, PlayState* play) { + if (Message_ShouldAdvance(play)) { switch (this->unk_552) { case 0x2840: case 0x2841: @@ -1321,79 +1321,79 @@ void func_8096426C(EnFu* this, GlobalContext* globalCtx) { } } -void func_809642E0(EnFu* this, GlobalContext* globalCtx) { +void func_809642E0(EnFu* this, PlayState* play) { Collider_UpdateCylinder(&this->actor, &this->collider); if (this->unk_542 == 0) { - CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + CollisionCheck_SetAC(play, &play->colChkCtx, &this->collider.base); } - CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + CollisionCheck_SetOC(play, &play->colChkCtx, &this->collider.base); } -void EnFu_Update(Actor* thisx, GlobalContext* globalCtx) { +void EnFu_Update(Actor* thisx, PlayState* play) { EnFu* this = THIS; - this->actionFunc(this, globalCtx); + this->actionFunc(this, play); - func_809642E0(this, globalCtx); + func_809642E0(this, play); Actor_MoveWithGravity(&this->actor); - func_8096209C(this, globalCtx); - Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 0.0f, 0.0f, 0.0f, 4); + func_8096209C(this, play); + Actor_UpdateBgCheckInfo(play, &this->actor, 0.0f, 0.0f, 0.0f, 4); SkelAnime_Update(&this->skelAnime); - func_80961D7C(globalCtx); - func_809640D8(this, globalCtx); - func_80964034(this, globalCtx); + func_80961D7C(play); + func_809640D8(this, play); + func_80964034(this, play); } -s32 EnFu_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, Actor* thisx) { +s32 EnFu_OverrideLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, Actor* thisx) { 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; } -void EnFu_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx) { +void EnFu_PostLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx) { static Vec3f D_80964C28 = { -2500.0f, 0.0f, 0.0f }; static Vec3f D_80964C34 = { -3500.0f, 0.0f, 0.0f }; 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); } } -void EnFu_Draw(Actor* thisx, GlobalContext* globalCtx) { +void EnFu_Draw(Actor* thisx, PlayState* play) { s32 pad; EnFu* this = THIS; - Matrix_StatePush(); - func_80964950(globalCtx, this->unk_2D8, ARRAY_COUNT(this->unk_2D8)); - Matrix_StatePop(); + Matrix_Push(); + func_80964950(play, this->unk_2D8, ARRAY_COUNT(this->unk_2D8)); + Matrix_Pop(); - OPEN_DISPS(globalCtx->state.gfxCtx); + OPEN_DISPS(play->state.gfxCtx); - func_8012C28C(globalCtx->state.gfxCtx); + func_8012C28C(play->state.gfxCtx); gDPPipeSync(POLY_OPA_DISP++); - gSPSegment(POLY_OPA_DISP++, 0x08, Gfx_EnvColor(globalCtx->state.gfxCtx, 0, 50, 160, 0)); - gSPSegment(POLY_OPA_DISP++, 0x09, Gfx_EnvColor(globalCtx->state.gfxCtx, 255, 255, 255, 0)); - SkelAnime_DrawFlexOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, + gSPSegment(POLY_OPA_DISP++, 0x08, Gfx_EnvColor(play->state.gfxCtx, 0, 50, 160, 0)); + gSPSegment(POLY_OPA_DISP++, 0x09, Gfx_EnvColor(play->state.gfxCtx, 255, 255, 255, 0)); + SkelAnime_DrawFlexOpa(play, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, EnFu_OverrideLimbDraw, EnFu_PostLimbDraw, &this->actor); - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->state.gfxCtx); } void func_80964694(EnFu* this, EnFuUnkStruct* ptr, Vec3f* arg2, s32 len) { @@ -1419,9 +1419,9 @@ void func_80964694(EnFu* this, EnFuUnkStruct* ptr, Vec3f* arg2, s32 len) { } } -void func_809647EC(GlobalContext* globalCtx, EnFuUnkStruct* ptr, s32 len) { +void func_809647EC(PlayState* play, EnFuUnkStruct* ptr, s32 len) { Vec3f sp44 = { 0.0f, 0.0f, 0.0f }; - s16 yaw = Camera_GetInputDirYaw(GET_ACTIVE_CAM(globalCtx)); + s16 yaw = Camera_GetInputDirYaw(GET_ACTIVE_CAM(play)); s32 i; for (i = 0; i < len; i++, ptr++) { @@ -1432,23 +1432,23 @@ 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(yaw, 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; } } } -void func_80964950(GlobalContext* globalCtx, EnFuUnkStruct* ptr, s32 len) { +void func_80964950(PlayState* play, EnFuUnkStruct* ptr, s32 len) { s32 i; s32 flag = false; - OPEN_DISPS(globalCtx->state.gfxCtx); + OPEN_DISPS(play->state.gfxCtx); - POLY_OPA_DISP = func_801660B8(globalCtx, POLY_OPA_DISP); + POLY_OPA_DISP = func_801660B8(play, POLY_OPA_DISP); POLY_OPA_DISP = func_8012C724(POLY_OPA_DISP); for (i = 0; i < len; i++, ptr++) { @@ -1457,16 +1457,15 @@ 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(&play->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)); - gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), - G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_OPA_DISP++, object_mu_DL_00B0E0); } } - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->state.gfxCtx); } 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 6af75768f..e35c961e7 100644 --- a/src/overlays/actors/ovl_En_Fu/z_en_fu.h +++ b/src/overlays/actors/ovl_En_Fu/z_en_fu.h @@ -6,50 +6,50 @@ struct EnFu; -typedef void (*EnFuActionFunc)(struct EnFu*, GlobalContext*); +typedef void (*EnFuActionFunc)(struct EnFu*, PlayState*); #define ENFU_GET_FF00(thisx) (((thisx)->params >> 8) & 0xFF) typedef struct { /* 0x00 */ f32 unk_00; - /* 0x04 */ char unk_04[0x4]; + /* 0x04 */ UNK_TYPE1 unk_04[0x4]; /* 0x08 */ Vec3f unk_08; /* 0x14 */ Vec3f unk_14; /* 0x20 */ Vec3f unk_20; /* 0x2C */ s16 unk_2C; - /* 0x2E */ char unk_2E[0x8]; + /* 0x2E */ UNK_TYPE1 unk_2E[0x8]; /* 0x36 */ u8 unk_36; /* 0x37 */ u8 unk_37; } EnFuUnkStruct; // size = 0x38 typedef struct EnFu { - /* 0x0000 */ Actor actor; - /* 0x0144 */ ColliderCylinder collider; - /* 0x0190 */ SkelAnime skelAnime; - /* 0x01D4 */ EnFuActionFunc actionFunc; - /* 0x01D8 */ Vec3s jointTable[21]; - /* 0x0256 */ Vec3s morphTable[21]; - /* 0x02D4 */ BgFuMizu* unk_2D4; - /* 0x02D8 */ EnFuUnkStruct unk_2D8[10]; - /* 0x0508 */ Vec3f unk_508; - /* 0x0514 */ Vec3f unk_514; - /* 0x0520 */ s32 unk_520; - /* 0x0524 */ s16 unk_524[3]; - /* 0x052A */ s16 unk_52A[3]; - /* 0x0530 */ char unk530[0x8]; - /* 0x0538 */ Vec3s* unk_538; - /* 0x053C */ s16 unk_53C; - /* 0x053E */ s16 unk_53E; - /* 0x0540 */ s16 unk_540; - /* 0x0542 */ s16 unk_542; - /* 0x0544 */ s16 unk_544; - /* 0x0546 */ s16 unk_546; - /* 0x0548 */ s16 unk_548; - /* 0x054A */ s16 unk_54A; - /* 0x054C */ s16 unk_54C; - /* 0x054E */ s16 unk_54E; - /* 0x0550 */ s16 unk_550; - /* 0x0552 */ u16 unk_552; + /* 0x000 */ Actor actor; + /* 0x144 */ ColliderCylinder collider; + /* 0x190 */ SkelAnime skelAnime; + /* 0x1D4 */ EnFuActionFunc actionFunc; + /* 0x1D8 */ Vec3s jointTable[21]; + /* 0x256 */ Vec3s morphTable[21]; + /* 0x2D4 */ BgFuMizu* unk_2D4; + /* 0x2D8 */ EnFuUnkStruct unk_2D8[10]; + /* 0x508 */ Vec3f unk_508; + /* 0x514 */ Vec3f unk_514; + /* 0x520 */ s32 unk_520; + /* 0x524 */ s16 unk_524[3]; + /* 0x52A */ s16 unk_52A[3]; + /* 0x530 */ UNK_TYPE1 unk530[0x8]; + /* 0x538 */ Vec3s* unk_538; + /* 0x53C */ s16 unk_53C; + /* 0x53E */ s16 unk_53E; + /* 0x540 */ s16 unk_540; + /* 0x542 */ s16 unk_542; + /* 0x544 */ s16 unk_544; + /* 0x546 */ s16 unk_546; + /* 0x548 */ s16 unk_548; + /* 0x54A */ s16 unk_54A; + /* 0x54C */ s16 unk_54C; + /* 0x54E */ s16 unk_54E; + /* 0x550 */ s16 unk_550; + /* 0x552 */ u16 unk_552; } EnFu; // size = 0x554 extern const ActorInit En_Fu_InitVars; diff --git a/src/overlays/actors/ovl_En_Fu_Kago/z_en_fu_kago.c b/src/overlays/actors/ovl_En_Fu_Kago/z_en_fu_kago.c index ad92b34d6..a2fc00b22 100644 --- a/src/overlays/actors/ovl_En_Fu_Kago/z_en_fu_kago.c +++ b/src/overlays/actors/ovl_En_Fu_Kago/z_en_fu_kago.c @@ -7,25 +7,26 @@ #include "z_en_fu_kago.h" #include "overlays/actors/ovl_En_Bom/z_en_bom.h" #include "overlays/actors/ovl_En_Fu/z_en_fu.h" +#include "overlays/effects/ovl_Effect_Ss_Hahen/z_eff_ss_hahen.h" #include "objects/object_fu_mato/object_fu_mato.h" #define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_20) #define THIS ((EnFuKago*)thisx) -void EnFuKago_Init(Actor* thisx, GlobalContext* globalCtx); -void EnFuKago_Destroy(Actor* thisx, GlobalContext* globalCtx); -void EnFuKago_Update(Actor* thisx, GlobalContext* globalCtx); -void EnFuKago_Draw(Actor* thisx, GlobalContext* globalCtx); +void EnFuKago_Init(Actor* thisx, PlayState* play); +void EnFuKago_Destroy(Actor* thisx, PlayState* play); +void EnFuKago_Update(Actor* thisx, PlayState* play); +void EnFuKago_Draw(Actor* thisx, PlayState* play); void func_80ACF994(EnFuKago* this); -void func_80ACF9A8(EnFuKago* this, GlobalContext* globalCtx); +void func_80ACF9A8(EnFuKago* this, PlayState* play); 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_80ACF9FC(EnFuKago* this, PlayState* play); +void func_80ACFA78(EnFuKago* this, PlayState* play); +void func_80AD0028(EnFuKago* this, PlayState* play); void func_80AD0274(EnFuKago* this); -void func_80AD0288(EnFuKago* this, GlobalContext* globalCtx); +void func_80AD0288(EnFuKago* this, PlayState* play); const ActorInit En_Fu_Kago_InitVars = { ACTOR_EN_FU_KAGO, @@ -79,15 +80,15 @@ Vec3f D_80AD06C4[] = { { 13.7f, 9.0f, -15.5f }, { -13.7f, 9.0f, -15.5f }, { -13.7f, 9.0f, 0.0f }, }; -void EnFuKago_Init(Actor* thisx, GlobalContext* globalCtx) { +void EnFuKago_Init(Actor* thisx, PlayState* play) { s32 pad; EnFuKago* this = THIS; CollisionHeader* sp34 = NULL; - Actor* npc = globalCtx->actorCtx.actorLists[ACTORCAT_NPC].first; + Actor* npc = play->actorCtx.actorLists[ACTORCAT_NPC].first; 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); + this->dyna.bgId = DynaPoly_SetBgActor(play, &play->colCtx.dyna, &this->dyna.actor, sp34); Actor_SetScale(&this->dyna.actor, 0.1f); while (npc != NULL) { @@ -103,8 +104,8 @@ void EnFuKago_Init(Actor* thisx, GlobalContext* globalCtx) { return; } - Collider_InitSphere(globalCtx, &this->collider); - Collider_SetSphere(globalCtx, &this->collider, &this->dyna.actor, &sSphereInit); + Collider_InitSphere(play, &this->collider); + Collider_SetSphere(play, &this->collider, &this->dyna.actor, &sSphereInit); this->collider.dim.worldSphere.radius = 10; this->unk_33A = 0; this->unk_33C = 0; @@ -112,13 +113,13 @@ void EnFuKago_Init(Actor* thisx, GlobalContext* globalCtx) { func_80ACF994(this); } -void EnFuKago_Destroy(Actor* thisx, GlobalContext* globalCtx) { +void EnFuKago_Destroy(Actor* thisx, PlayState* play) { EnFuKago* this = THIS; - DynaPoly_DeleteBgActor(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); + DynaPoly_DeleteBgActor(play, &play->colCtx.dyna, this->dyna.bgId); } -s32 func_80ACF8B8(EnFuKago* this, GlobalContext* globalCtx) { +s32 func_80ACF8B8(EnFuKago* this, PlayState* play) { 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; @@ -129,7 +130,7 @@ s32 func_80ACF8B8(EnFuKago* this, GlobalContext* globalCtx) { 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); + func_80ACFA78(this, play); return false; } else { return false; @@ -138,7 +139,7 @@ s32 func_80ACF8B8(EnFuKago* this, GlobalContext* globalCtx) { Actor_PlaySfxAtPos(&this->dyna.actor, NA_SE_SY_TRE_BOX_APPEAR); return true; } else { - CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + CollisionCheck_SetOC(play, &play->colChkCtx, &this->collider.base); } return false; } @@ -147,8 +148,8 @@ void func_80ACF994(EnFuKago* this) { this->actionFunc = func_80ACF9A8; } -void func_80ACF9A8(EnFuKago* this, GlobalContext* globalCtx) { - if (func_80ACF8B8(this, globalCtx)) { +void func_80ACF9A8(EnFuKago* this, PlayState* play) { + if (func_80ACF8B8(this, play)) { func_80ACF9DC(this); } } @@ -160,7 +161,7 @@ void func_80ACF9DC(EnFuKago* this) { this->actionFunc = func_80ACF9FC; } -void func_80ACF9FC(EnFuKago* this, GlobalContext* globalCtx) { +void func_80ACF9FC(EnFuKago* this, PlayState* play) { EnBom* bom = (EnBom*)this->dyna.actor.child; EnFu* fu = (EnFu*)this->dyna.actor.parent; @@ -169,14 +170,14 @@ void func_80ACF9FC(EnFuKago* this, GlobalContext* globalCtx) { func_80ACF994(this); } else if (bom->timer == 1) { fu->unk_548++; - func_80ACFA78(this, globalCtx); + func_80ACFA78(this, play); } 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) { +void func_80ACFA78(EnFuKago* this, PlayState* play) { s32 i; Vec3f sp98; Vec3s sp90; @@ -221,19 +222,19 @@ void func_80ACFA78(EnFuKago* this, GlobalContext* globalCtx) { } this->dyna.actor.freezeTimer = 2; - EffectSsHahen_SpawnBurst(globalCtx, &this->dyna.actor.world.pos, 17.0f, 0, 15, 13, 20, -1, 10, NULL); + EffectSsHahen_SpawnBurst(play, &this->dyna.actor.world.pos, 17.0f, 0, 15, 13, 20, HAHEN_OBJECT_DEFAULT, 10, NULL); this->unk_338 = 60; this->unk_33A = 1; Actor_PlaySfxAtPos(&this->dyna.actor, NA_SE_EV_WOODBOX_BREAK); - func_800C62BC(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); + func_800C62BC(play, &play->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) { +void func_80ACFDAC(EnFuKago* this, PlayState* play, EnFuKagoStruct* arg2) { Vec3f sp34; f32 temp_f0; @@ -241,8 +242,8 @@ void func_80ACFDAC(EnFuKago* this, GlobalContext* globalCtx, EnFuKagoStruct* arg 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); + EffectSsGSplash_Spawn(play, &sp34, NULL, NULL, 0, 800); + EffectSsGRipple_Spawn(play, &sp34, 250, 650, 0); arg2->unk_3C = 1; } @@ -271,19 +272,19 @@ void func_80ACFDAC(EnFuKago* this, GlobalContext* globalCtx, EnFuKagoStruct* arg Math_SmoothStepToS(&arg2->unk_36.z, 0, 0xA, 0x64, 0xA); } - if ((globalCtx->gameplayFrames % 8) == 0) { + if ((play->gameplayFrames % 8) == 0) { sp34 = arg2->unk_00; sp34.y = 30.0f; - EffectSsGRipple_Spawn(globalCtx, &sp34, 250, 650, 0); + EffectSsGRipple_Spawn(play, &sp34, 250, 650, 0); } } -void func_80AD0028(EnFuKago* this, GlobalContext* globalCtx) { +void func_80AD0028(EnFuKago* this, PlayState* play) { EnFuKagoStruct* ptr = this->unk_1B8; s32 i; for (i = 0; i < ARRAY_COUNT(this->unk_1B8); i++) { - func_80ACFDAC(this, globalCtx, ptr); + func_80ACFDAC(this, play, ptr); ptr->unk_0C.x += ptr->unk_18.x; ptr->unk_0C.y += ptr->unk_18.y; @@ -333,7 +334,7 @@ void func_80AD0274(EnFuKago* this) { this->actionFunc = func_80AD0288; } -void func_80AD0288(EnFuKago* this, GlobalContext* globalCtx) { +void func_80AD0288(EnFuKago* this, PlayState* play) { s32 pad; Vec3f* scale = &this->dyna.actor.scale; @@ -345,53 +346,53 @@ void func_80AD0288(EnFuKago* this, GlobalContext* globalCtx) { } } -void EnFuKago_Update(Actor* thisx, GlobalContext* globalCtx) { +void EnFuKago_Update(Actor* thisx, PlayState* play) { EnFuKago* this = THIS; - this->actionFunc(this, globalCtx); + this->actionFunc(this, play); if (this->unk_33C == 1) { func_80AD0274(this); } } -void func_80AD0340(EnFuKago* this, GlobalContext* globalCtx) { +void func_80AD0340(EnFuKago* this, PlayState* play) { s32 pad[2]; EnFuKagoStruct* ptr = &this->unk_1B8[0]; s32 i; Vec3f* scale = &this->dyna.actor.scale; - OPEN_DISPS(globalCtx->state.gfxCtx); + OPEN_DISPS(play->state.gfxCtx); - func_8012C28C(globalCtx->state.gfxCtx); + func_8012C28C(play->state.gfxCtx); for (i = 0; i < ARRAY_COUNT(D_80AD061C); i++, ptr++) { - Matrix_StatePush(); - Matrix_SetStateRotationAndTranslation(ptr->unk_00.x, ptr->unk_00.y, ptr->unk_00.z, &this->dyna.actor.shape.rot); - Matrix_InsertTranslation(ptr->unk_24.x, ptr->unk_24.y, ptr->unk_24.z, MTXMODE_APPLY); - Matrix_InsertRotation(ptr->unk_30.x, ptr->unk_30.y, ptr->unk_30.z, MTXMODE_APPLY); - Matrix_InsertTranslation(-ptr->unk_24.x, -ptr->unk_24.y, -ptr->unk_24.z, MTXMODE_APPLY); + Matrix_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); + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_OPA_DISP++, D_80AD061C[i]); - Matrix_StatePop(); + Matrix_Pop(); } - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->state.gfxCtx); } -void EnFuKago_Draw(Actor* thisx, GlobalContext* globalCtx) { +void EnFuKago_Draw(Actor* thisx, PlayState* play) { s32 pad; EnFuKago* this = THIS; if (this->unk_33A == 0) { - OPEN_DISPS(globalCtx->state.gfxCtx); + OPEN_DISPS(play->state.gfxCtx); - func_8012C28C(globalCtx->state.gfxCtx); + func_8012C28C(play->state.gfxCtx); - gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(play->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); @@ -399,8 +400,8 @@ void EnFuKago_Draw(Actor* thisx, GlobalContext* globalCtx) { gSPDisplayList(POLY_OPA_DISP++, object_fu_mato_DL_000920); gSPDisplayList(POLY_OPA_DISP++, object_fu_mato_DL_0009C0); - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->state.gfxCtx); } else { - func_80AD0340(this, globalCtx); + func_80AD0340(this, play); } } 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 19022093e..909e7b24d 100644 --- a/src/overlays/actors/ovl_En_Fu_Kago/z_en_fu_kago.h +++ b/src/overlays/actors/ovl_En_Fu_Kago/z_en_fu_kago.h @@ -5,7 +5,7 @@ struct EnFuKago; -typedef void (*EnFuKagoActionFunc)(struct EnFuKago*, GlobalContext*); +typedef void (*EnFuKagoActionFunc)(struct EnFuKago*, PlayState*); typedef struct { /* 0x00 */ Vec3f unk_00; @@ -18,13 +18,13 @@ typedef struct { } EnFuKagoStruct; // size = 0x40 typedef struct EnFuKago { - /* 0x0000 */ DynaPolyActor dyna; - /* 0x015C */ EnFuKagoActionFunc actionFunc; - /* 0x0160 */ ColliderSphere collider; - /* 0x01B8 */ EnFuKagoStruct unk_1B8[6]; - /* 0x0338 */ s16 unk_338; - /* 0x033A */ s16 unk_33A; - /* 0x033C */ s16 unk_33C; + /* 0x000 */ DynaPolyActor dyna; + /* 0x15C */ EnFuKagoActionFunc actionFunc; + /* 0x160 */ ColliderSphere collider; + /* 0x1B8 */ EnFuKagoStruct unk_1B8[6]; + /* 0x338 */ s16 unk_338; + /* 0x33A */ s16 unk_33A; + /* 0x33C */ s16 unk_33C; } EnFuKago; // size = 0x340 extern const ActorInit En_Fu_Kago_InitVars; diff --git a/src/overlays/actors/ovl_En_Fu_Mato/z_en_fu_mato.c b/src/overlays/actors/ovl_En_Fu_Mato/z_en_fu_mato.c index ec0209729..19aa9dd2a 100644 --- a/src/overlays/actors/ovl_En_Fu_Mato/z_en_fu_mato.c +++ b/src/overlays/actors/ovl_En_Fu_Mato/z_en_fu_mato.c @@ -6,25 +6,26 @@ #include "z_en_fu_mato.h" #include "overlays/actors/ovl_En_Fu/z_en_fu.h" +#include "overlays/effects/ovl_Effect_Ss_Hahen/z_eff_ss_hahen.h" #include "objects/object_fu_mato/object_fu_mato.h" #define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_20) #define THIS ((EnFuMato*)thisx) -void EnFuMato_Init(Actor* thisx, GlobalContext* globalCtx); -void EnFuMato_Destroy(Actor* thisx, GlobalContext* globalCtx); -void EnFuMato_Update(Actor* thisx, GlobalContext* globalCtx); -void EnFuMato_Draw(Actor* thisx, GlobalContext* globalCtx); +void EnFuMato_Init(Actor* thisx, PlayState* play); +void EnFuMato_Destroy(Actor* thisx, PlayState* play); +void EnFuMato_Update(Actor* thisx, PlayState* play); +void EnFuMato_Draw(Actor* thisx, PlayState* play); void func_80ACE4B4(EnFuMato* this); -void func_80ACE4C8(EnFuMato* this, GlobalContext* globalCtx); +void func_80ACE4C8(EnFuMato* this, PlayState* play); 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_80ACE51C(EnFuMato* this, PlayState* play); +void func_80ACE718(EnFuMato* this, PlayState* play); +void func_80ACECFC(EnFuMato* this, PlayState* play); void func_80ACEFC4(EnFuMato* this); -void func_80ACEFD8(EnFuMato* this, GlobalContext* globalCtx); +void func_80ACEFD8(EnFuMato* this, PlayState* play); const ActorInit En_Fu_Mato_InitVars = { ACTOR_EN_FU_MATO, @@ -67,19 +68,19 @@ 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 }, }; -void EnFuMato_Init(Actor* thisx, GlobalContext* globalCtx) { +void EnFuMato_Init(Actor* thisx, PlayState* play) { s32 pad; EnFuMato* this = THIS; CollisionHeader* sp2C = NULL; - Actor* actor = globalCtx->actorCtx.actorLists[ACTORCAT_NPC].first; + Actor* actor = play->actorCtx.actorLists[ACTORCAT_NPC].first; EnFu* fu; 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); + this->dyna.bgId = DynaPoly_SetBgActor(play, &play->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); + Collider_InitSphere(play, &this->collider); + Collider_SetSphere(play, &this->collider, &this->dyna.actor, &sSphereInit); this->collider.dim.worldSphere.radius = 20; while (actor != NULL) { @@ -111,18 +112,18 @@ void EnFuMato_Init(Actor* thisx, GlobalContext* globalCtx) { func_80ACE4B4(this); } -void EnFuMato_Destroy(Actor* thisx, GlobalContext* globalCtx) { +void EnFuMato_Destroy(Actor* thisx, PlayState* play) { EnFuMato* this = THIS; - DynaPoly_DeleteBgActor(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); - Collider_DestroySphere(globalCtx, &this->collider); + DynaPoly_DeleteBgActor(play, &play->colCtx.dyna, this->dyna.bgId); + Collider_DestroySphere(play, &this->collider); } void func_80ACE4B4(EnFuMato* this) { this->actionFunc = func_80ACE4C8; } -void func_80ACE4C8(EnFuMato* this, GlobalContext* globalCtx) { +void func_80ACE4C8(EnFuMato* this, PlayState* play) { EnFu* fu = (EnFu*)this->dyna.actor.parent; if ((fu->unk_54A == 0) && (fu->unk_542 == 0)) { @@ -134,7 +135,7 @@ void func_80ACE508(EnFuMato* this) { this->actionFunc = func_80ACE51C; } -void func_80ACE51C(EnFuMato* this, GlobalContext* globalCtx) { +void func_80ACE51C(EnFuMato* this, PlayState* play) { EnFu* fu = (EnFu*)this->dyna.actor.parent; Vec3f sp30; f32 sp2C; @@ -177,31 +178,31 @@ void func_80ACE680(EnFuMato* this) { this->actionFunc = func_80ACE718; } -void func_80ACE718(EnFuMato* this, GlobalContext* globalCtx) { +void func_80ACE718(EnFuMato* this, PlayState* play) { 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); + Actor_UpdateBgCheckInfo(play, &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); + func_800B3030(play, &this->dyna.actor.world.pos, &sp3C, &sp30, 20, 40, 2); Actor_MarkForDeath(&this->dyna.actor); } } -void func_80ACE850(EnFuMato* this, GlobalContext* globalCtx) { +void func_80ACE850(EnFuMato* this, PlayState* play) { EnFuMatoStruct* ptr = this->unk_1B8; s16 temp_s4 = this->dyna.actor.shape.rot.y; s32 phi_s2; s32 i; - this->unk_308 = (u32)Rand_Next() % ARRAY_COUNT(this->unk_1B8); + this->unk_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(); @@ -239,7 +240,7 @@ void func_80ACE850(EnFuMato* this, GlobalContext* globalCtx) { } this->dyna.actor.freezeTimer = 2; - EffectSsHahen_SpawnBurst(globalCtx, &this->dyna.actor.world.pos, 13.0f, 0, 7, 8, 20, -1, 10, NULL); + EffectSsHahen_SpawnBurst(play, &this->dyna.actor.world.pos, 13.0f, 0, 7, 8, 20, HAHEN_OBJECT_DEFAULT, 10, NULL); Actor_PlaySfxAtPos(&this->dyna.actor, NA_SE_EV_WOODPLATE_BROKEN); this->actionFunc = func_80ACECFC; } @@ -278,7 +279,7 @@ void func_80ACEB2C(EnFuMato* this) { this->actionFunc = func_80ACECFC; } -void func_80ACECFC(EnFuMato* this, GlobalContext* globalCtx) { +void func_80ACECFC(EnFuMato* this, PlayState* play) { EnFuMatoStruct* ptr = this->unk_1B8; s32 phi_s3; s32 i; @@ -328,7 +329,7 @@ void func_80ACECFC(EnFuMato* this, GlobalContext* globalCtx) { } if (this->unk_302 == 1) { - Actor_UpdateBgCheckInfo(globalCtx, &this->dyna.actor, 15.0f, 30.0f, 60.0f, 5); + Actor_UpdateBgCheckInfo(play, &this->dyna.actor, 15.0f, 30.0f, 60.0f, 5); if (this->dyna.actor.bgCheckFlags & 1) { func_80ACEB2C(this); } @@ -345,7 +346,7 @@ void func_80ACEFC4(EnFuMato* this) { this->actionFunc = func_80ACEFD8; } -void func_80ACEFD8(EnFuMato* this, GlobalContext* globalCtx) { +void func_80ACEFD8(EnFuMato* this, PlayState* play) { Vec3f* scale = &this->dyna.actor.scale; Math_SmoothStepToF(&scale->x, 0.0f, 0.1f, 0.005f, 0.005f); @@ -355,7 +356,7 @@ void func_80ACEFD8(EnFuMato* this, GlobalContext* globalCtx) { } } -s32 func_80ACF04C(EnFuMato* this, GlobalContext* globalCtx) { +s32 func_80ACF04C(EnFuMato* this, PlayState* play) { EnFu* fu = (EnFu*)this->dyna.actor.parent; this->collider.dim.worldSphere.center.x = this->dyna.actor.world.pos.x; @@ -374,43 +375,43 @@ s32 func_80ACF04C(EnFuMato* this, GlobalContext* globalCtx) { fu->unk_546 = 1; func_80ACE680(this); } else { - func_80ACE850(this, globalCtx); + func_80ACE850(this, play); } return true; } - CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); - CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + CollisionCheck_SetAC(play, &play->colChkCtx, &this->collider.base); + CollisionCheck_SetOC(play, &play->colChkCtx, &this->collider.base); return false; } -void EnFuMato_Update(Actor* thisx, GlobalContext* globalCtx) { +void EnFuMato_Update(Actor* thisx, PlayState* play) { EnFuMato* this = THIS; - this->actionFunc(this, globalCtx); + this->actionFunc(this, play); - func_80ACF04C(this, globalCtx); + func_80ACF04C(this, play); if (this->unk_30A == 1) { func_80ACEFC4(this); } } -void func_80ACF1F4(EnFuMato* this, GlobalContext* globalCtx) { +void func_80ACF1F4(EnFuMato* this, PlayState* play) { EnFuMatoStruct* ptr = this->unk_1B8; s32 temp_s4 = this->unk_308; s32 i; - OPEN_DISPS(globalCtx->state.gfxCtx); + OPEN_DISPS(play->state.gfxCtx); - func_8012C28C(globalCtx->state.gfxCtx); + func_8012C28C(play->state.gfxCtx); for (i = 0; i < 2; i++) { - Matrix_StatePush(); - Matrix_SetStateRotationAndTranslation(ptr->unk_00.x, ptr->unk_00.y, ptr->unk_00.z, &ptr->unk_24); + Matrix_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); + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_OPA_DISP++, D_80ACF63C[temp_s4]); switch (temp_s4) { @@ -430,55 +431,55 @@ void func_80ACF1F4(EnFuMato* this, GlobalContext* globalCtx) { break; } - Matrix_StatePop(); + Matrix_Pop(); temp_s4 = (temp_s4 + 3) % ARRAY_COUNT(this->unk_1B8); ptr++; } - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->state.gfxCtx); } -void func_80ACF3F4(EnFuMato* this, GlobalContext* globalCtx) { +void func_80ACF3F4(EnFuMato* this, PlayState* play) { EnFuMatoStruct* ptr = this->unk_1B8; Vec3f* scale = &this->dyna.actor.scale; s32 i; - OPEN_DISPS(globalCtx->state.gfxCtx); + OPEN_DISPS(play->state.gfxCtx); - func_8012C28C(globalCtx->state.gfxCtx); + func_8012C28C(play->state.gfxCtx); for (i = 0; i < ARRAY_COUNT(D_80ACF63C); i++, ptr++) { - Matrix_StatePush(); - Matrix_SetStateRotationAndTranslation(ptr->unk_00.x, ptr->unk_00.y, ptr->unk_00.z, &ptr->unk_24); + Matrix_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); + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_OPA_DISP++, D_80ACF63C[i]); - Matrix_StatePop(); + Matrix_Pop(); } - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->state.gfxCtx); } -void EnFuMato_Draw(Actor* thisx, GlobalContext* globalCtx) { +void EnFuMato_Draw(Actor* thisx, PlayState* play) { s32 pad; EnFuMato* this = THIS; - OPEN_DISPS(globalCtx->state.gfxCtx); + OPEN_DISPS(play->state.gfxCtx); - func_8012C28C(globalCtx->state.gfxCtx); + func_8012C28C(play->state.gfxCtx); - gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(play->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); + func_80ACF1F4(this, play); } else { - func_80ACF3F4(this, globalCtx); + func_80ACF3F4(this, play); } - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->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 5666b71fc..d24ac91d5 100644 --- a/src/overlays/actors/ovl_En_Fu_Mato/z_en_fu_mato.h +++ b/src/overlays/actors/ovl_En_Fu_Mato/z_en_fu_mato.h @@ -5,7 +5,7 @@ struct EnFuMato; -typedef void (*EnFuMatoActionFunc)(struct EnFuMato*, GlobalContext*); +typedef void (*EnFuMatoActionFunc)(struct EnFuMato*, PlayState*); #define ENFUMATO_GET(thisx) ((thisx)->params) @@ -19,19 +19,19 @@ typedef struct { } EnFuMatoStruct; // size = 0x34 typedef struct EnFuMato { - /* 0x0000 */ DynaPolyActor dyna; - /* 0x015C */ EnFuMatoActionFunc actionFunc; - /* 0x0160 */ ColliderSphere collider; - /* 0x01B8 */ EnFuMatoStruct unk_1B8[6]; - /* 0x02F0 */ s32 unk_2F0; - /* 0x02F4 */ s32 unk_2F4; - /* 0x02F8 */ Vec3s* unk_2F8; - /* 0x02FC */ Vec3s unk_2FC; - /* 0x0302 */ s16 unk_302; - /* 0x0304 */ s16 unk_304; - /* 0x0306 */ UNK_TYPE1 unk306[2]; - /* 0x0308 */ s16 unk_308; - /* 0x030A */ s16 unk_30A; + /* 0x000 */ DynaPolyActor dyna; + /* 0x15C */ EnFuMatoActionFunc actionFunc; + /* 0x160 */ ColliderSphere collider; + /* 0x1B8 */ EnFuMatoStruct unk_1B8[6]; + /* 0x2F0 */ s32 unk_2F0; + /* 0x2F4 */ s32 unk_2F4; + /* 0x2F8 */ Vec3s* unk_2F8; + /* 0x2FC */ Vec3s unk_2FC; + /* 0x302 */ s16 unk_302; + /* 0x304 */ s16 unk_304; + /* 0x306 */ UNK_TYPE1 unk306[2]; + /* 0x308 */ s16 unk_308; + /* 0x30A */ s16 unk_30A; } EnFuMato; // size = 0x30C extern const ActorInit En_Fu_Mato_InitVars; diff --git a/src/overlays/actors/ovl_En_Fz/z_en_fz.c b/src/overlays/actors/ovl_En_Fz/z_en_fz.c index 067e8c50d..00c47b111 100644 --- a/src/overlays/actors/ovl_En_Fz/z_en_fz.c +++ b/src/overlays/actors/ovl_En_Fz/z_en_fz.c @@ -13,41 +13,41 @@ #define THIS ((EnFz*)thisx) -void EnFz_Init(Actor* thisx, GlobalContext* globalCtx); -void EnFz_Destroy(Actor* thisx, GlobalContext* globalCtx); -void EnFz_Update(Actor* thisx, GlobalContext* globalCtx); -void EnFz_Draw(Actor* thisx, GlobalContext* globalCtx); +void EnFz_Init(Actor* thisx, PlayState* play); +void EnFz_Destroy(Actor* thisx, PlayState* play); +void EnFz_Update(Actor* thisx, PlayState* play); +void EnFz_Draw(Actor* thisx, PlayState* play); -void func_80932784(EnFz* this, GlobalContext* globalCtx); +void func_80932784(EnFz* this, PlayState* play); void func_80932AE8(EnFz* this); void func_80932AF4(EnFz* this); void func_80932BD4(EnFz* this); void func_809330D4(EnFz* this); -void func_80933104(EnFz* this, GlobalContext* globalCtx); +void func_80933104(EnFz* this, PlayState* play); void func_80933184(EnFz* this); -void func_809331F8(EnFz* this, GlobalContext* globalCtx); +void func_809331F8(EnFz* this, PlayState* play); void func_80933248(EnFz* this); -void func_80933274(EnFz* this, GlobalContext* globalCtx); +void func_80933274(EnFz* this, PlayState* play); void func_80933324(EnFz* this); -void func_80933368(EnFz* this, GlobalContext* globalCtx); +void func_80933368(EnFz* this, PlayState* play); void func_809333A4(EnFz* this); -void func_809333D8(EnFz* this, GlobalContext* globalCtx); +void func_809333D8(EnFz* this, PlayState* play); void func_80933414(EnFz* this); -void func_80933444(EnFz* this, GlobalContext* globalCtx); -void func_80933480(EnFz* this, GlobalContext* globalCtx); -void func_809334B8(EnFz* this, GlobalContext* globalCtx); -void func_809336C0(EnFz* this, GlobalContext* globalCtx); -void func_80933760(EnFz* this, GlobalContext* globalCtx); +void func_80933444(EnFz* this, PlayState* play); +void func_80933480(EnFz* this, PlayState* play); +void func_809334B8(EnFz* this, PlayState* play); +void func_809336C0(EnFz* this, PlayState* play); +void func_80933760(EnFz* this, PlayState* play); void func_80933790(EnFz* this); -void func_809337D4(EnFz* this, GlobalContext* globalCtx); +void func_809337D4(EnFz* this, PlayState* play); void func_8093389C(EnFz* this); -void func_809338E0(EnFz* this, GlobalContext* globalCtx); +void func_809338E0(EnFz* this, PlayState* play); void func_80933AF4(EnFz* this); -void func_80933B38(EnFz* this, GlobalContext* globalCtx); +void func_80933B38(EnFz* this, PlayState* play); void func_80934018(EnFz* this, Vec3f* a, Vec3f* b, Vec3f* c, f32 arg4); void func_809340BC(EnFz* this, Vec3f* a, Vec3f* b, Vec3f* c, f32 arg4, f32 arg5, s16 arg6, u8 arg7); -void func_80934178(EnFz* this, GlobalContext* globalCtx); -void func_80934464(EnFz* this, GlobalContext* globalCtx); +void func_80934178(EnFz* this, PlayState* play); +void func_80934464(EnFz* this, PlayState* play); const ActorInit En_Fz_InitVars = { ACTOR_EN_FZ, @@ -162,19 +162,19 @@ static InitChainEntry sInitChain[] = { ICHAIN_F32(targetArrowOffset, 30, ICHAIN_STOP), }; -void EnFz_Init(Actor* thisx, GlobalContext* globalCtx) { +void EnFz_Init(Actor* thisx, PlayState* play) { EnFz* this = THIS; Actor_ProcessInitChain(&this->actor, sInitChain); this->actor.colChkInfo.damageTable = &sDamageTable; this->actor.colChkInfo.health = 3; - Collider_InitCylinder(globalCtx, &this->collider1); - Collider_SetCylinderType1(globalCtx, &this->collider1, &this->actor, &sCylinderInit1); - Collider_InitCylinder(globalCtx, &this->collider2); - Collider_SetCylinderType1(globalCtx, &this->collider2, &this->actor, &sCylinderInit2); - Collider_InitCylinder(globalCtx, &this->collider3); - Collider_SetCylinderType1(globalCtx, &this->collider3, &this->actor, &sCylinderInit3); + Collider_InitCylinder(play, &this->collider1); + Collider_SetCylinderType1(play, &this->collider1, &this->actor, &sCylinderInit1); + Collider_InitCylinder(play, &this->collider2); + Collider_SetCylinderType1(play, &this->collider2, &this->actor, &sCylinderInit2); + Collider_InitCylinder(play, &this->collider3); + Collider_SetCylinderType1(play, &this->collider3, &this->actor, &sCylinderInit3); Actor_SetScale(&this->actor, 0.008f); this->actor.gravity = 0.0f; @@ -230,15 +230,15 @@ void EnFz_Init(Actor* thisx, GlobalContext* globalCtx) { this->drawDmgEffTimer = 0; this->drawDmgEffScale = 0.0f; this->drawDmgEffAlpha = 0.0f; - func_80932784(this, globalCtx); + func_80932784(this, play); } -void EnFz_Destroy(Actor* thisx, GlobalContext* globalCtx) { +void EnFz_Destroy(Actor* thisx, PlayState* play) { EnFz* this = THIS; - Collider_DestroyCylinder(globalCtx, &this->collider1); - Collider_DestroyCylinder(globalCtx, &this->collider2); - Collider_DestroyCylinder(globalCtx, &this->collider3); + Collider_DestroyCylinder(play, &this->collider1); + Collider_DestroyCylinder(play, &this->collider2); + Collider_DestroyCylinder(play, &this->collider3); if ((this->actor.parent != NULL) && (this->unk_BC4 == 0) && (this->actor.parent->id == ACTOR_EN_WIZ) && (this->actor.parent->update != NULL) && (((EnWiz*)this->actor.parent)->unk_448 != 0)) { @@ -248,7 +248,7 @@ void EnFz_Destroy(Actor* thisx, GlobalContext* globalCtx) { } } -void func_80932784(EnFz* this, GlobalContext* globalCtx) { +void func_80932784(EnFz* this, PlayState* play) { Vec3f sp5C; Vec3f sp50; Vec3f sp44; @@ -259,15 +259,14 @@ 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, true, false, false, true, - &sp40)) { + Matrix_MultVec3f(&sp44, &this->unk_22C); + if (BgCheck_EntityLineTest1(&play->colCtx, &sp5C, &this->unk_22C, &sp50, &sp3C, true, false, false, true, &sp40)) { Math_Vec3f_Copy(&this->unk_22C, &sp50); } @@ -286,7 +285,7 @@ s32 func_809328A4(EnFz* this, Vec3f* arg1) { return false; } -void func_809328F4(EnFz* this, GlobalContext* globalCtx, Vec3f* arg2, s32 arg3, f32 arg4) { +void func_809328F4(EnFz* this, PlayState* play, Vec3f* arg2, s32 arg3, f32 arg4) { s32 i; Vec3f spA8; Vec3f sp9C; @@ -315,10 +314,10 @@ void func_809328F4(EnFz* this, GlobalContext* globalCtx, Vec3f* arg2, s32 arg3, sp9C.x = randPlusMinusPoint5Scaled(10.0f); sp9C.y = Rand_ZeroFloat(10.0f) + 2.0f; sp9C.z = randPlusMinusPoint5Scaled(10.0f); - EffectSsEnIce_Spawn(globalCtx, &spA8, temp_f24, &sp9C, &sp90, &sp8C, &sp88, temp_s1); + EffectSsEnIce_Spawn(play, &spA8, temp_f24, &sp9C, &sp90, &sp8C, &sp88, temp_s1); } - CollisionCheck_SpawnShieldParticles(globalCtx, arg2); + CollisionCheck_SpawnShieldParticles(play, arg2); } void func_80932AE8(EnFz* this) { @@ -356,12 +355,12 @@ void func_80932BD4(EnFz* this) { } } -void func_80932C98(EnFz* this, GlobalContext* globalCtx) { +void func_80932C98(EnFz* this, PlayState* play) { Vec3f sp3C; if (this->unk_BCD != 0) { if ((this->actor.bgCheckFlags & 8) || - !Actor_TestFloorInDirection(&this->actor, globalCtx, 60.0f, this->actor.world.rot.y)) { + !Actor_TestFloorInDirection(&this->actor, play, 60.0f, this->actor.world.rot.y)) { this->actor.bgCheckFlags &= ~0x8; this->unk_BCD = 0; this->unk_BBC = 0.0f; @@ -381,8 +380,8 @@ void func_80932C98(EnFz* this, GlobalContext* globalCtx) { sp3C.x = this->actor.world.pos.x; sp3C.y = this->actor.world.pos.y; sp3C.z = this->actor.world.pos.z; - func_809328F4(this, globalCtx, &sp3C, 30, 10.0f); - func_809336C0(this, globalCtx); + func_809328F4(this, play, &sp3C, 30, 10.0f); + func_809336C0(this, play); return; } @@ -394,8 +393,8 @@ void func_80932C98(EnFz* this, GlobalContext* globalCtx) { sp3C.x = this->actor.world.pos.x; sp3C.y = this->actor.world.pos.y; sp3C.z = this->actor.world.pos.z; - func_809328F4(this, globalCtx, &sp3C, 30, 10.0f); - func_809336C0(this, globalCtx); + func_809328F4(this, play, &sp3C, 30, 10.0f); + func_809336C0(this, play); return; } } @@ -427,7 +426,7 @@ void func_80932C98(EnFz* this, GlobalContext* globalCtx) { sp3C.x = this->actor.world.pos.x; sp3C.y = this->actor.world.pos.y; sp3C.z = this->actor.world.pos.z; - func_809328F4(this, globalCtx, &sp3C, 10, 0.0f); + func_809328F4(this, play, &sp3C, 10, 0.0f); this->unk_BCF++; break; } @@ -436,8 +435,8 @@ void func_80932C98(EnFz* this, GlobalContext* globalCtx) { sp3C.x = this->actor.world.pos.x; sp3C.y = this->actor.world.pos.y; sp3C.z = this->actor.world.pos.z; - func_809328F4(this, globalCtx, &sp3C, 30, 10.0f); - func_809336C0(this, globalCtx); + func_809328F4(this, play, &sp3C, 30, 10.0f); + func_809336C0(this, play); break; case 2: @@ -477,7 +476,7 @@ void func_809330D4(EnFz* this) { this->actionFunc = func_80933104; } -void func_80933104(EnFz* this, GlobalContext* globalCtx) { +void func_80933104(EnFz* this, PlayState* play) { this->unk_BC0 -= 16; if (this->unk_BC0 > 255) { this->unk_BC0 = 0; @@ -508,7 +507,7 @@ void func_80933184(EnFz* this) { } } -void func_809331F8(EnFz* this, GlobalContext* globalCtx) { +void func_809331F8(EnFz* this, PlayState* play) { if ((this->unk_BCA == 0) && (this->actor.xzDistToPlayer < 400.0f)) { func_80933248(this); } @@ -521,7 +520,7 @@ void func_80933248(EnFz* this) { this->actionFunc = func_80933274; } -void func_80933274(EnFz* this, GlobalContext* globalCtx) { +void func_80933274(EnFz* this, PlayState* play) { if (this->unk_BCA == 0) { this->unk_BC0 += 8; @@ -549,7 +548,7 @@ void func_80933324(EnFz* this) { this->actionFunc = func_80933368; } -void func_80933368(EnFz* this, GlobalContext* globalCtx) { +void func_80933368(EnFz* this, PlayState* play) { func_80933014(this); if (this->unk_BCA == 0) { func_809333A4(this); @@ -564,7 +563,7 @@ void func_809333A4(EnFz* this) { this->actionFunc = func_809333D8; } -void func_809333D8(EnFz* this, GlobalContext* globalCtx) { +void func_809333D8(EnFz* this, PlayState* play) { if ((this->unk_BCA == 0) || (this->unk_BCD == 0)) { func_80933414(this); } @@ -578,21 +577,21 @@ void func_80933414(EnFz* this) { this->actionFunc = func_80933444; } -void func_80933444(EnFz* this, GlobalContext* globalCtx) { +void func_80933444(EnFz* this, PlayState* play) { func_80933014(this); if (this->unk_BCA == 0) { - func_80933480(this, globalCtx); + func_80933480(this, play); } } -void func_80933480(EnFz* this, GlobalContext* globalCtx) { +void func_80933480(EnFz* this, PlayState* play) { this->unk_BD6 = 1; this->unk_BCA = 80; this->actionFunc = func_809334B8; - func_80932784(this, globalCtx); + func_80932784(this, play); } -void func_809334B8(EnFz* this, GlobalContext* globalCtx) { +void func_809334B8(EnFz* this, PlayState* play) { Vec3f sp64; Vec3f sp58; Vec3f sp4C; @@ -620,7 +619,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, MTXMODE_NEW); + Matrix_RotateYS(this->actor.shape.rot.y, MTXMODE_NEW); sp64.x = 0.0f; sp64.y = -2.0f; @@ -629,7 +628,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; @@ -645,7 +644,7 @@ void func_809334B8(EnFz* this, GlobalContext* globalCtx) { } } -void func_809336C0(EnFz* this, GlobalContext* globalCtx) { +void func_809336C0(EnFz* this, PlayState* play) { this->unk_BD6 = 0; this->unk_BBC = 0.0f; this->actor.gravity = 0.0f; @@ -657,12 +656,12 @@ void func_809336C0(EnFz* this, GlobalContext* globalCtx) { this->actor.flags &= ~ACTOR_FLAG_1; this->unk_BD7 = 0; this->unk_BCA = 60; - func_800BC154(globalCtx, &globalCtx->actorCtx, &this->actor, ACTORCAT_PROP); - Item_DropCollectibleRandom(globalCtx, &this->actor, &this->actor.world.pos, 0xA0); + func_800BC154(play, &play->actorCtx, &this->actor, ACTORCAT_PROP); + Item_DropCollectibleRandom(play, &this->actor, &this->actor.world.pos, 0xA0); this->actionFunc = func_80933760; } -void func_80933760(EnFz* this, GlobalContext* globalCtx) { +void func_80933760(EnFz* this, PlayState* play) { if (this->unk_BCA == 0) { Actor_MarkForDeath(&this->actor); } @@ -678,7 +677,7 @@ void func_80933790(EnFz* this) { this->actionFunc = func_809337D4; } -void func_809337D4(EnFz* this, GlobalContext* globalCtx) { +void func_809337D4(EnFz* this, PlayState* play) { Math_StepToF(&this->actor.scale.y, 0.0006f, 0.0006f); if (this->actor.scale.y < 0.006f) { @@ -694,7 +693,7 @@ void func_809337D4(EnFz* this, GlobalContext* globalCtx) { } if (this->unk_BC0 == 0) { - func_809336C0(this, globalCtx); + func_809336C0(this, play); } } @@ -708,7 +707,7 @@ void func_8093389C(EnFz* this) { this->actionFunc = func_809338E0; } -void func_809338E0(EnFz* this, GlobalContext* globalCtx) { +void func_809338E0(EnFz* this, PlayState* play) { Vec3f sp64; Vec3f sp58; Vec3f sp4C; @@ -718,7 +717,7 @@ void func_809338E0(EnFz* this, GlobalContext* globalCtx) { if (this->unk_BC6 & (0x80 | 0x40)) { func_80933014(this); - func_80932784(this, globalCtx); + func_80932784(this, play); return; } @@ -737,7 +736,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, MTXMODE_NEW); + Matrix_RotateYS(this->actor.shape.rot.y, MTXMODE_NEW); sp64.x = 0.0f; sp64.y = -2.0f; @@ -746,7 +745,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; @@ -769,10 +768,10 @@ void func_80933AF4(EnFz* this) { this->actionFunc = func_80933B38; } -void func_80933B38(EnFz* this, GlobalContext* globalCtx) { +void func_80933B38(EnFz* this, PlayState* play) { } -void func_80933B48(EnFz* this, GlobalContext* globalCtx) { +void func_80933B48(EnFz* this, PlayState* play) { if (this->drawDmgEffTimer != 0) { if (this->drawDmgEffTimer > 0) { this->drawDmgEffTimer--; @@ -787,7 +786,7 @@ void func_80933B48(EnFz* this, GlobalContext* globalCtx) { } } -void EnFz_Update(Actor* thisx, GlobalContext* globalCtx) { +void EnFz_Update(Actor* thisx, PlayState* play) { static EnFzUnkFunc D_809347AC[] = { func_80932AE8, func_80932AF4, func_80932BD4, func_80932BD4 }; s32 pad; EnFz* this = THIS; @@ -806,53 +805,53 @@ void EnFz_Update(Actor* thisx, GlobalContext* globalCtx) { } Actor_SetFocus(&this->actor, 50.0f); - func_80932C98(this, globalCtx); + func_80932C98(this, play); - this->actionFunc(this, globalCtx); + this->actionFunc(this, play); if (this->unk_BD8 == 0) { Collider_UpdateCylinder(&this->actor, &this->collider1); Collider_UpdateCylinder(&this->actor, &this->collider2); if (this->unk_BCE != 0) { if (this->actor.colorFilterTimer == 0) { - CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->collider1.base); - CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->collider2.base); + CollisionCheck_SetAC(play, &play->colChkCtx, &this->collider1.base); + CollisionCheck_SetAC(play, &play->colChkCtx, &this->collider2.base); } - CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider1.base); + CollisionCheck_SetOC(play, &play->colChkCtx, &this->collider1.base); } } Math_StepToF(&this->actor.speedXZ, this->unk_BBC, 0.2f); Actor_MoveWithGravity(&this->actor); if (this->unk_BCC != 0) { - Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 20.0f, 20.0f, 20.0f, 5); + Actor_UpdateBgCheckInfo(play, &this->actor, 20.0f, 20.0f, 20.0f, 5); } D_809347AC[this->unk_BD6](this); - func_80933B48(this, globalCtx); - func_80934178(this, globalCtx); + func_80933B48(this, play); + func_80934178(this, play); } -void EnFz_Draw(Actor* thisx, GlobalContext* globalCtx) { +void EnFz_Draw(Actor* thisx, PlayState* play) { static Gfx* D_809347BC[] = { object_fz_DL_001130, object_fz_DL_0021A0, object_fz_DL_002CA0 }; s32 pad; EnFz* this = THIS; s32 sp9C = 3 - this->actor.colChkInfo.health; - OPEN_DISPS(globalCtx->state.gfxCtx); + OPEN_DISPS(play->state.gfxCtx); if (this->actor.colChkInfo.health == 0) { sp9C = 2; } if (this->unk_BD7 != 0) { - func_800B8118(&this->actor, globalCtx, 0); - func_8012C2DC(globalCtx->state.gfxCtx); + func_800B8118(&this->actor, play, 0); + func_8012C2DC(play->state.gfxCtx); gSPSegment(POLY_XLU_DISP++, 0x08, - Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, 0, globalCtx->state.frames % 128, 0x20, 0x20, 1, 0, - (globalCtx->state.frames * 2) % 128, 0x20, 0x20)); - gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + Gfx_TwoTexScroll(play->state.gfxCtx, 0, 0, play->state.frames % 128, 0x20, 0x20, 1, 0, + (play->state.frames * 2) % 128, 0x20, 0x20)); + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gDPSetCombineLERP(POLY_XLU_DISP++, TEXEL1, PRIMITIVE, PRIM_LOD_FRAC, TEXEL0, TEXEL1, TEXEL0, PRIMITIVE, TEXEL0, PRIMITIVE, ENVIRONMENT, COMBINED, ENVIRONMENT, COMBINED, 0, ENVIRONMENT, 0); gDPSetPrimColor(POLY_XLU_DISP++, 0, 0x80, 155, 255, 255, 255); @@ -860,7 +859,7 @@ void EnFz_Draw(Actor* thisx, GlobalContext* globalCtx) { gSPDisplayList(POLY_XLU_DISP++, D_809347BC[sp9C]); } - func_80934464(this, globalCtx); + func_80934464(this, play); if (this->drawDmgEffTimer > 0) { s32 pad2[6]; @@ -871,11 +870,11 @@ void EnFz_Draw(Actor* thisx, GlobalContext* globalCtx) { 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, + Actor_DrawDamageEffects(play, NULL, limbPos, ARRAY_COUNT(limbPos), this->drawDmgEffScale * 4.0f, 0.5f, this->drawDmgEffAlpha, ACTOR_DRAW_DMGEFF_LIGHT_ORBS); } - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->state.gfxCtx); } void func_80934018(EnFz* this, Vec3f* a, Vec3f* b, Vec3f* c, f32 arg4) { @@ -918,7 +917,7 @@ void func_809340BC(EnFz* this, Vec3f* a, Vec3f* b, Vec3f* c, f32 arg4, f32 arg5, } } -void func_80934178(EnFz* this, GlobalContext* globalCtx) { +void func_80934178(EnFz* this, PlayState* play) { s16 i; EnFzStruct* ptr = this->unk_23C; Vec3f sp64; @@ -969,7 +968,7 @@ void func_80934178(EnFz* this, GlobalContext* globalCtx) { this->collider3.dim.pos.x = ptr->unk_04.x; this->collider3.dim.pos.y = ptr->unk_04.y; this->collider3.dim.pos.z = ptr->unk_04.z; - CollisionCheck_SetAT(globalCtx, &globalCtx->colChkCtx, &this->collider3.base); + CollisionCheck_SetAT(play, &play->colChkCtx, &this->collider3.base); } sp64.x = ptr->unk_04.x; @@ -986,15 +985,15 @@ void func_80934178(EnFz* this, GlobalContext* globalCtx) { } } -void func_80934464(EnFz* this, GlobalContext* globalCtx) { - GraphicsContext* gfxCtx = globalCtx->state.gfxCtx; +void func_80934464(EnFz* this, PlayState* play) { + GraphicsContext* gfxCtx = play->state.gfxCtx; s16 i; u8 flag = 0; EnFzStruct* ptr = this->unk_23C; OPEN_DISPS(gfxCtx); - func_8012C2DC(globalCtx->state.gfxCtx); + func_8012C2DC(play->state.gfxCtx); gDPSetColorDither(POLY_XLU_DISP++, G_CD_BAYER); gDPSetAlphaDither(POLY_XLU_DISP++, G_AD_PATTERN); @@ -1010,11 +1009,11 @@ void func_80934464(EnFz* this, GlobalContext* globalCtx) { gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 195, 225, 235, ptr->unk_2C); gSPSegment(POLY_XLU_DISP++, 0x08, - Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, (ptr->unk_01 + (i * 3)) * 3, + Gfx_TwoTexScroll(play->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(&play->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); @@ -1022,5 +1021,5 @@ void func_80934464(EnFz* this, GlobalContext* globalCtx) { } } - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->state.gfxCtx); } diff --git a/src/overlays/actors/ovl_En_Fz/z_en_fz.h b/src/overlays/actors/ovl_En_Fz/z_en_fz.h index 19f462d0a..58d1fb6d4 100644 --- a/src/overlays/actors/ovl_En_Fz/z_en_fz.h +++ b/src/overlays/actors/ovl_En_Fz/z_en_fz.h @@ -5,7 +5,7 @@ struct EnFz; -typedef void (*EnFzActionFunc)(struct EnFz*, GlobalContext*); +typedef void (*EnFzActionFunc)(struct EnFz*, PlayState*); typedef void (*EnFzUnkFunc)(struct EnFz*); #define ENFZ_GET_F(thisx) ((thisx)->params & 0xF) 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 1d9175b49..cc19acb63 100644 --- a/src/overlays/actors/ovl_En_Gakufu/z_en_gakufu.c +++ b/src/overlays/actors/ovl_En_Gakufu/z_en_gakufu.c @@ -11,19 +11,19 @@ #define THIS ((EnGakufu*)thisx) -void EnGakufu_Init(Actor* thisx, GlobalContext* globalCtx); -void EnGakufu_Destroy(Actor* thisx, GlobalContext* globalCtx); -void EnGakufu_Update(Actor* thisx, GlobalContext* globalCtx); -void EnGakufu_Draw(Actor* thisx, GlobalContext* globalCtx); +void EnGakufu_Init(Actor* thisx, PlayState* play); +void EnGakufu_Destroy(Actor* thisx, PlayState* play); +void EnGakufu_Update(Actor* thisx, PlayState* play); +void EnGakufu_Draw(Actor* thisx, PlayState* play); 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); +s32 EnGakufu_IsPlayerInRange(EnGakufu* this, PlayState* play); +void EnGakufu_DisplayOnTimer(EnGakufu* this, PlayState* play); +void EnGakufu_WaitForTimer(EnGakufu* this, PlayState* play); +void EnGakufu_DoNothing(EnGakufu* this, PlayState* play); +void EnGakufu_GiveReward(EnGakufu* this, PlayState* play); +void EnGakufu_PlayRewardCutscene(EnGakufu* this, PlayState* play); +void EnGakufu_WaitForSong(EnGakufu* this, PlayState* play); const ActorInit En_Gakufu_InitVars = { ACTOR_EN_GAKUFU, @@ -106,12 +106,12 @@ void EnGakufu_ProcessNotes(EnGakufu* this) { s32 songIndex; AudioOcarina_TerminaWallGenerateNotes(); - AudioOcarina_SetInstrumentId(OCARINA_INSTRUMENT_DEFAULT); + AudioOcarina_SetInstrument(OCARINA_INSTRUMENT_DEFAULT); AudioOcarina_StartDefault((1 << this->songIndex) | 0x80000000); playbackStaff = AudioOcarina_GetPlaybackStaff(); playbackStaff->pos = 0; playbackStaff->state = 0xFF; - AudioOcarina_SetInstrumentId(OCARINA_INSTRUMENT_OFF); + AudioOcarina_SetInstrument(OCARINA_INSTRUMENT_OFF); songIndex = this->songIndex; ocarinaSongButtons = &gOcarinaSongButtons[songIndex]; @@ -126,7 +126,7 @@ void EnGakufu_ProcessNotes(EnGakufu* this) { } } -void EnGakufu_Init(Actor* thisx, GlobalContext* globalCtx) { +void EnGakufu_Init(Actor* thisx, PlayState* play) { EnGakufu* this = THIS; this->songIndex = OCARINA_SONG_TERMINA_WALL; @@ -141,7 +141,7 @@ void EnGakufu_Init(Actor* thisx, GlobalContext* globalCtx) { this->actor.flags &= ~ACTOR_FLAG_2000000; - if (EnGakufu_IsPlayerInRange(this, globalCtx)) { + if (EnGakufu_IsPlayerInRange(this, play)) { gSaveContext.eventInf[3] |= 2; } else { gSaveContext.eventInf[3] &= (u8)~2; @@ -151,7 +151,7 @@ void EnGakufu_Init(Actor* thisx, GlobalContext* globalCtx) { gSaveContext.eventInf[3] &= (u8)~4; } -void EnGakufu_Destroy(Actor* thisx, GlobalContext* globalCtx) { +void EnGakufu_Destroy(Actor* thisx, PlayState* play) { EnGakufu* this = THIS; if (GAKUFU_GET_TYPE(&this->actor) != GAKUFU_MILK_BAR) { @@ -164,7 +164,7 @@ void EnGakufu_Destroy(Actor* thisx, GlobalContext* globalCtx) { * 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) { +void EnGakufu_DisplayOnTimer(EnGakufu* this, PlayState* play) { if (this->actor.home.rot.x > 0) { this->actor.draw = EnGakufu_Draw; this->actor.home.rot.x--; @@ -180,17 +180,17 @@ void EnGakufu_DisplayOnTimer(EnGakufu* this, GlobalContext* globalCtx) { * 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) { +void EnGakufu_WaitForTimer(EnGakufu* this, PlayState* play) { if (this->actor.home.rot.x > 0) { EnGakufu_ProcessNotes(this); this->actionFunc = EnGakufu_DisplayOnTimer; } } -void EnGakufu_DoNothing(EnGakufu* this, GlobalContext* globalCtx) { +void EnGakufu_DoNothing(EnGakufu* this, PlayState* play) { } -s32 EnGakufu_IsPlayerInRange(EnGakufu* this, GlobalContext* globalCtx) { +s32 EnGakufu_IsPlayerInRange(EnGakufu* this, PlayState* play) { if (this->actor.xzDistToPlayer < 600.0f) { return true; } else { @@ -201,26 +201,26 @@ s32 EnGakufu_IsPlayerInRange(EnGakufu* this, GlobalContext* globalCtx) { /** * Reward the player with three item drops depending on the time of day */ -void EnGakufu_GiveReward(EnGakufu* this, GlobalContext* globalCtx) { +void EnGakufu_GiveReward(EnGakufu* this, PlayState* play) { s32 hour; s32 i; play_sound(NA_SE_SY_CORRECT_CHIME); - hour = gSaveContext.save.time * (24.0f / 0x10000); + hour = gSaveContext.save.time * (24.0f / 0x10000); // TIME_TO_HOURS_F for (i = 0; i < 3; i++) { - Item_DropCollectible(globalCtx, &sRewardDropsSpawnTerminaFieldPos, sRewardDrops[i + sRewardDropsIndex[hour]]); + Item_DropCollectible(play, &sRewardDropsSpawnTerminaFieldPos, sRewardDrops[i + sRewardDropsIndex[hour]]); } this->actionFunc = EnGakufu_DoNothing; } -void EnGakufu_PlayRewardCutscene(EnGakufu* this, GlobalContext* globalCtx) { +void EnGakufu_PlayRewardCutscene(EnGakufu* this, PlayState* play) { if (this->actor.cutscene == -1) { - EnGakufu_GiveReward(this, globalCtx); + EnGakufu_GiveReward(this, play); } else if (ActorCutscene_GetCanPlayNext(this->actor.cutscene)) { ActorCutscene_StartAndSetUnkLinkFields(this->actor.cutscene, &this->actor); - EnGakufu_GiveReward(this, globalCtx); + EnGakufu_GiveReward(this, play); } else { ActorCutscene_SetIntentToPlay(this->actor.cutscene); } @@ -231,46 +231,45 @@ void EnGakufu_PlayRewardCutscene(EnGakufu* this, GlobalContext* globalCtx) { * (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) { +void EnGakufu_WaitForSong(EnGakufu* this, PlayState* play) { 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); + EnGakufu_PlayRewardCutscene(this, play); this->actor.draw = NULL; - } else if (!EnGakufu_IsPlayerInRange(this, globalCtx)) { + } else if (!EnGakufu_IsPlayerInRange(this, play)) { gSaveContext.eventInf[3] &= (u8)~2; } - } else if (EnGakufu_IsPlayerInRange(this, globalCtx)) { + } else if (EnGakufu_IsPlayerInRange(this, play)) { gSaveContext.eventInf[3] |= 2; } } -void EnGakufu_Update(Actor* thisx, GlobalContext* globalCtx) { +void EnGakufu_Update(Actor* thisx, PlayState* play) { EnGakufu* this = THIS; - this->actionFunc(this, globalCtx); + this->actionFunc(this, play); } -void EnGakufu_Draw(Actor* thisx, GlobalContext* globalCtx) { +void EnGakufu_Draw(Actor* thisx, PlayState* play) { s32 i; s32 pad; EnGakufu* this = THIS; - OPEN_DISPS(globalCtx->state.gfxCtx); + OPEN_DISPS(play->state.gfxCtx); gDPPipeSync(POLY_XLU_DISP++); - gSPSegment(POLY_XLU_DISP++, 0x02, globalCtx->interfaceCtx.parameterSegment); + gSPSegment(POLY_XLU_DISP++, 0x02, play->interfaceCtx.parameterSegment); for (i = 0; (i < ARRAY_COUNT(this->buttonIndex)) && (this->buttonIndex[i] != OCARINA_BTN_INVALID); i++) { - Matrix_StatePush(); - Matrix_InsertTranslation(30 * i - 105, sOcarinaBtnWallYOffsets[this->buttonIndex[i]] * 7.5f, 1.0f, - MTXMODE_APPLY); + Matrix_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); + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(play->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, @@ -284,10 +283,10 @@ void EnGakufu_Draw(Actor* thisx, GlobalContext* globalCtx) { gSPDisplayList(POLY_XLU_DISP++, gGakufuButtonIndexDL); - Matrix_StatePop(); + Matrix_Pop(); } - gSPSegment(POLY_XLU_DISP++, 0x02, globalCtx->sceneSegment); + gSPSegment(POLY_XLU_DISP++, 0x02, play->sceneSegment); - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->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 9ba96a724..c9db31b75 100644 --- a/src/overlays/actors/ovl_En_Gakufu/z_en_gakufu.h +++ b/src/overlays/actors/ovl_En_Gakufu/z_en_gakufu.h @@ -5,13 +5,13 @@ struct EnGakufu; -typedef void (*EnGakufuActionFunc)(struct EnGakufu*, GlobalContext*); +typedef void (*EnGakufuActionFunc)(struct EnGakufu*, PlayState*); #define GAKUFU_GET_TYPE(thisx) ((thisx)->params & 0xF) typedef enum { - /* 0x00 */ GAKUFU_TERMINA_FIELD, - /* 0x01 */ GAKUFU_MILK_BAR + /* 0x0 */ GAKUFU_TERMINA_FIELD, + /* 0x1 */ GAKUFU_MILK_BAR } GakufuType; typedef struct EnGakufu { diff --git a/src/overlays/actors/ovl_En_Gamelupy/z_en_gamelupy.c b/src/overlays/actors/ovl_En_Gamelupy/z_en_gamelupy.c index 16547c112..c2c42fa59 100644 --- a/src/overlays/actors/ovl_En_Gamelupy/z_en_gamelupy.c +++ b/src/overlays/actors/ovl_En_Gamelupy/z_en_gamelupy.c @@ -5,21 +5,24 @@ */ #include "z_en_gamelupy.h" +#include "objects/gameplay_keep/gameplay_keep.h" #define FLAGS (ACTOR_FLAG_10) #define THIS ((EnGamelupy*)thisx) -void EnGamelupy_Init(Actor* thisx, GlobalContext* globalCtx); -void EnGamelupy_Destroy(Actor* thisx, GlobalContext* globalCtx); -void EnGamelupy_Update(Actor* thisx, GlobalContext* globalCtx); -void EnGamelupy_Draw(Actor* thisx, GlobalContext* globalCtx); +void EnGamelupy_Init(Actor* thisx, PlayState* play); +void EnGamelupy_Destroy(Actor* thisx, PlayState* play); +void EnGamelupy_Update(Actor* thisx, PlayState* play); +void EnGamelupy_Draw(Actor* thisx, PlayState* play); -void func_80AF6958(EnGamelupy* this, GlobalContext* globalCtx); -void func_80AF69A8(EnGamelupy* this, GlobalContext* globalCtx); -void func_80AF6A78(EnGamelupy* this, GlobalContext* globalCtx); +void func_80AF6958(EnGamelupy* this, PlayState* play); +void func_80AF69A8(EnGamelupy* this, PlayState* play); +void func_80AF6A78(EnGamelupy* this, PlayState* play); +void func_80AF6944(EnGamelupy* this); +void func_80AF6994(EnGamelupy* this); +void func_80AF6A38(EnGamelupy* this); -#if 0 const ActorInit En_Gamelupy_InitVars = { ACTOR_EN_GAMELUPY, ACTORCAT_PROP, @@ -32,37 +35,158 @@ const ActorInit En_Gamelupy_InitVars = { (ActorFunc)EnGamelupy_Draw, }; -// static ColliderCylinderInit sCylinderInit = { -static ColliderCylinderInit D_80AF6CF0 = { - { COLTYPE_NONE, AT_NONE, AC_NONE, OC1_ON | OC1_NO_PUSH | OC1_TYPE_PLAYER, OC2_TYPE_2, COLSHAPE_CYLINDER, }, - { ELEMTYPE_UNK4, { 0x00000000, 0x00, 0x00 }, { 0x00000000, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_NONE, OCELEM_ON, }, +static ColliderCylinderInit sCylinderInit = { + { + COLTYPE_NONE, + AT_NONE, + AC_NONE, + OC1_ON | OC1_NO_PUSH | OC1_TYPE_PLAYER, + OC2_TYPE_2, + COLSHAPE_CYLINDER, + }, + { + ELEMTYPE_UNK4, + { 0x00000000, 0x00, 0x00 }, + { 0x00000000, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_NONE, + OCELEM_ON, + }, { 10, 30, 0, { 0, 0, 0 } }, }; -#endif +static TexturePtr sRupeeTex[] = { + gameplay_keep_Tex_061FC0, gameplay_keep_Tex_061FE0, gameplay_keep_Tex_062000, + gameplay_keep_Tex_062040, gameplay_keep_Tex_062020, +}; -extern ColliderCylinderInit D_80AF6CF0; +static Color_RGBA8 sPrimColor = { 255, 255, 255, 255 }; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Gamelupy/EnGamelupy_Init.s") +static Color_RGBA8 sEnvColor = { 100, 200, 0, 255 }; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Gamelupy/EnGamelupy_Destroy.s") +void EnGamelupy_Init(Actor* thisx, PlayState* play) { + s32 pad; + EnGamelupy* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Gamelupy/func_80AF6854.s") + Actor_SetScale(&this->actor, 0.03f); + ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 10.0f); + this->actor.shape.yOffset = 700.0f; + Collider_InitCylinder(play, &this->collider); + Collider_SetCylinder(play, &this->collider, &this->actor, &sCylinderInit); + this->actor.gravity = -0.5f; + this->actor.shape.rot.y = Rand_Next(); + this->unk_19C = 0; + this->unk_19E = 0; + this->unk_1A0 = 0x7D0; + if (this->actor.params == 1) { + this->rupeeIndex = 1; + } else { + this->rupeeIndex = 0; + } + func_80AF6944(this); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Gamelupy/func_80AF6944.s") +void EnGamelupy_Destroy(Actor* thisx, PlayState* play) { + EnGamelupy* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Gamelupy/func_80AF6958.s") + Collider_DestroyCylinder(play, &this->collider); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Gamelupy/func_80AF6994.s") +void func_80AF6854(EnGamelupy* this, PlayState* play) { + Vec3f sp4C; + Vec3f sp40; + Vec3f sp30; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Gamelupy/func_80AF69A8.s") + sp4C = this->actor.world.pos; + sp30.x = Math_SinS(this->unk_19E) * 3.0f; + sp30.y = 5.5f; + sp30.z = Math_CosS(this->unk_19E) * 3.0f; + sp40.x = -0.05f * sp30.x; + sp40.y = -0.4f; + sp40.z = -0.05f * sp30.z; + EffectSsKirakira_SpawnDispersed(play, &sp4C, &sp30, &sp40, &sPrimColor, &sEnvColor, 3000, 40); + this->unk_19E += this->unk_1A0; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Gamelupy/func_80AF6A38.s") +void func_80AF6944(EnGamelupy* this) { + this->actionFunc = func_80AF6958; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Gamelupy/func_80AF6A78.s") +void func_80AF6958(EnGamelupy* this, PlayState* play) { + s16* unk_198 = func_800B6680(play, ACTOR_EN_GAMELUPY); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Gamelupy/func_80AF6B40.s") + if (unk_198 != NULL) { + this->unk_198 = unk_198; + func_80AF6994(this); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Gamelupy/EnGamelupy_Update.s") +void func_80AF6994(EnGamelupy* this) { + this->actionFunc = func_80AF69A8; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Gamelupy/EnGamelupy_Draw.s") +void func_80AF69A8(EnGamelupy* this, PlayState* play) { + if (this->collider.base.ocFlags1 & OC1_HIT) { + *this->unk_198 += 0x32; + if (this->rupeeIndex == 1) { + Rupees_ChangeBy(5); + } else { + Rupees_ChangeBy(1); + } + func_80AF6A38(this); + } + this->actor.shape.rot.y += 0x1F4; +} + +void func_80AF6A38(EnGamelupy* this) { + this->unk_19C = 0; + this->actor.gravity = 0.0f; + Actor_PlaySfxAtPos(&this->actor, NA_SE_SY_GET_RUPY); + this->actionFunc = func_80AF6A78; +} + +void func_80AF6A78(EnGamelupy* this, PlayState* play) { + f32 scale; + Player* player = GET_PLAYER(play); + + if (this->unk_19C > 30) { + Actor_MarkForDeath(&this->actor); + } else { + this->unk_19C++; + this->actor.world.pos = player->actor.world.pos; + this->actor.world.pos.y += 40.0f; + scale = (30.0f - this->unk_19C) * 0.001f; + Actor_SetScale(&this->actor, scale); + func_80AF6854(this, play); + } + this->actor.shape.rot.y += 0x3E8; +} + +void func_80AF6B40(EnGamelupy* this, PlayState* play) { + Collider_UpdateCylinder(&this->actor, &this->collider); + CollisionCheck_SetOC(play, &play->colChkCtx, &this->collider.base); +} + +void EnGamelupy_Update(Actor* thisx, PlayState* play) { + EnGamelupy* this = THIS; + + this->actionFunc(this, play); + Actor_MoveWithGravity(&this->actor); + Actor_UpdateBgCheckInfo(play, &this->actor, 32.0f, 30.0f, 0.0f, 0xC); + func_80AF6B40(this, play); +} + +void EnGamelupy_Draw(Actor* thisx, PlayState* play) { + s32 pad; + EnGamelupy* this = THIS; + + OPEN_DISPS(play->state.gfxCtx); + + func_8012C28C(play->state.gfxCtx); + func_800B8050(&this->actor, play, 0); + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPSegment(POLY_OPA_DISP++, 0x08, Lib_SegmentedToVirtual(sRupeeTex[this->rupeeIndex])); + gSPDisplayList(POLY_OPA_DISP++, gameplay_keep_DL_0622C0); + + CLOSE_DISPS(play->state.gfxCtx); +} diff --git a/src/overlays/actors/ovl_En_Gamelupy/z_en_gamelupy.h b/src/overlays/actors/ovl_En_Gamelupy/z_en_gamelupy.h index b09ac42a3..4ee6a5b11 100644 --- a/src/overlays/actors/ovl_En_Gamelupy/z_en_gamelupy.h +++ b/src/overlays/actors/ovl_En_Gamelupy/z_en_gamelupy.h @@ -5,13 +5,17 @@ struct EnGamelupy; -typedef void (*EnGamelupyActionFunc)(struct EnGamelupy*, GlobalContext*); +typedef void (*EnGamelupyActionFunc)(struct EnGamelupy*, PlayState*); typedef struct EnGamelupy { - /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x4C]; - /* 0x0190 */ EnGamelupyActionFunc actionFunc; - /* 0x0194 */ char unk_194[0x10]; + /* 0x000 */ Actor actor; + /* 0x144 */ ColliderCylinder collider; + /* 0x190 */ EnGamelupyActionFunc actionFunc; + /* 0x194 */ s32 rupeeIndex; + /* 0x198 */ s16* unk_198; + /* 0x19C */ s16 unk_19C; + /* 0x19E */ s16 unk_19E; + /* 0x1A0 */ s16 unk_1A0; } EnGamelupy; // size = 0x1A4 extern const ActorInit En_Gamelupy_InitVars; diff --git a/src/overlays/actors/ovl_En_Gb2/z_en_gb2.c b/src/overlays/actors/ovl_En_Gb2/z_en_gb2.c index 82010f193..17bec0df6 100644 --- a/src/overlays/actors/ovl_En_Gb2/z_en_gb2.c +++ b/src/overlays/actors/ovl_En_Gb2/z_en_gb2.c @@ -11,30 +11,30 @@ #define THIS ((EnGb2*)thisx) -void EnGb2_Init(Actor* thisx, GlobalContext* globalCtx); -void EnGb2_Destroy(Actor* thisx, GlobalContext* globalCtx); -void EnGb2_Update(Actor* thisx, GlobalContext* globalCtx); -void EnGb2_Draw(Actor* thisx, GlobalContext* globalCtx); +void EnGb2_Init(Actor* thisx, PlayState* play); +void EnGb2_Destroy(Actor* thisx, PlayState* play); +void EnGb2_Update(Actor* thisx, PlayState* play); +void EnGb2_Draw(Actor* thisx, PlayState* play); -void func_80B0FBF0(EnGb2* this, GlobalContext* globalCtx); -void func_80B0FEBC(EnGb2* this, GlobalContext* globalCtx); -void func_80B0FFA8(EnGb2* this, GlobalContext* globalCtx); -void func_80B10240(EnGb2* this, GlobalContext* globalCtx); -void func_80B10344(EnGb2* this, GlobalContext* globalCtx); -void func_80B10584(EnGb2* this, GlobalContext* globalCtx); -void func_80B10634(EnGb2* this, GlobalContext* globalCtx); -void func_80B10868(EnGb2* this, GlobalContext* globalCtx); -void func_80B10924(EnGb2* this, GlobalContext* globalCtx); -void func_80B109DC(EnGb2* this, GlobalContext* globalCtx); -void func_80B10A48(EnGb2* this, GlobalContext* globalCtx); -void func_80B10B5C(EnGb2* this, GlobalContext* globalCtx); -void func_80B10DAC(EnGb2* this, GlobalContext* globalCtx); -void func_80B10E98(EnGb2* this, GlobalContext* globalCtx); -void func_80B11048(EnGb2* this, GlobalContext* globalCtx); -void func_80B110F8(EnGb2* this, GlobalContext* globalCtx); -void func_80B111AC(EnGb2* this, GlobalContext* globalCtx); -void func_80B11268(EnGb2* this, GlobalContext* globalCtx); -void func_80B11344(EnGb2* this, GlobalContext* globalCtx); +void func_80B0FBF0(EnGb2* this, PlayState* play); +void func_80B0FEBC(EnGb2* this, PlayState* play); +void func_80B0FFA8(EnGb2* this, PlayState* play); +void func_80B10240(EnGb2* this, PlayState* play); +void func_80B10344(EnGb2* this, PlayState* play); +void func_80B10584(EnGb2* this, PlayState* play); +void func_80B10634(EnGb2* this, PlayState* play); +void func_80B10868(EnGb2* this, PlayState* play); +void func_80B10924(EnGb2* this, PlayState* play); +void func_80B109DC(EnGb2* this, PlayState* play); +void func_80B10A48(EnGb2* this, PlayState* play); +void func_80B10B5C(EnGb2* this, PlayState* play); +void func_80B10DAC(EnGb2* this, PlayState* play); +void func_80B10E98(EnGb2* this, PlayState* play); +void func_80B11048(EnGb2* this, PlayState* play); +void func_80B110F8(EnGb2* this, PlayState* play); +void func_80B111AC(EnGb2* this, PlayState* play); +void func_80B11268(EnGb2* this, PlayState* play); +void func_80B11344(EnGb2* this, PlayState* play); const ActorInit En_Gb2_InitVars = { ACTOR_EN_GB2, @@ -87,20 +87,20 @@ static ColliderCylinderInitType1 sCylinderInit = { { 40, 75, 0, { 0, 0, 0 } }, }; -void func_80B0F5E0(EnGb2* this, GlobalContext* globalCtx) { +void func_80B0F5E0(EnGb2* this, PlayState* play) { this->collider.dim.pos.x = this->actor.world.pos.x; this->collider.dim.pos.y = this->actor.world.pos.y; this->collider.dim.pos.z = this->actor.world.pos.z; - CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); - CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + CollisionCheck_SetAC(play, &play->colChkCtx, &this->collider.base); + CollisionCheck_SetOC(play, &play->colChkCtx, &this->collider.base); } -s32 func_80B0F660(EnGb2* this, GlobalContext* globalCtx) { +s32 func_80B0F660(EnGb2* this, PlayState* play) { Actor* temp_v0; Actor* phi_s0 = NULL; while (true) { - temp_v0 = SubS_FindActor(globalCtx, phi_s0, ACTORCAT_NPC, ACTOR_EN_GB2); + temp_v0 = SubS_FindActor(play, phi_s0, ACTORCAT_NPC, ACTOR_EN_GB2); if (temp_v0 == NULL) { break; } @@ -130,9 +130,9 @@ void func_80B0F6DC(EnGb2* this) { this->actionFunc = func_80B0FEBC; } -void func_80B0F728(EnGb2* this, GlobalContext* globalCtx) { +void func_80B0F728(EnGb2* this, PlayState* play) { if (gSaveContext.eventInf[4] & 0x10) { - func_80B0FBF0(this, globalCtx); + func_80B0FBF0(this, play); this->unk_26E = 0x14E1; if (gSaveContext.eventInf[4] & 0x80) { this->unk_288 = 10; @@ -140,7 +140,7 @@ void func_80B0F728(EnGb2* this, GlobalContext* globalCtx) { this->unk_288 = 30; } } else if (gSaveContext.eventInf[4] & 0x20) { - func_80B0FBF0(this, globalCtx); + func_80B0FBF0(this, play); this->unk_26E = 0x14E0; this->unk_26C |= 2; } else { @@ -246,8 +246,8 @@ void func_80B0FA04(EnGb2* this) { this->unk_282[2] = ActorCutscene_GetAdditionalCutscene(this->unk_282[1]); } -s32 func_80B0FA48(EnGb2* this, GlobalContext* globalCtx) { - switch (Player_GetMask(globalCtx)) { +s32 func_80B0FA48(EnGb2* this, PlayState* play) { + switch (Player_GetMask(play)) { case PLAYER_MASK_GIBDO: this->unk_26C |= 4; this->unk_26E = 0x14E6; @@ -318,7 +318,7 @@ u16 func_80B0FB24(EnGb2* this) { return 0; } -void func_80B0FBF0(EnGb2* this, GlobalContext* globalCtx) { +void func_80B0FBF0(EnGb2* this, PlayState* play) { Vec3f sp90[4] = { { 120.0f, 0.0f, 800.0f }, { -120.0f, 0.0f, 750.0f }, @@ -341,58 +341,58 @@ void func_80B0FBF0(EnGb2* this, GlobalContext* globalCtx) { s16 end = ARRAY_COUNT(sp90); for (i = 0; i < end; i++) { - Actor_SpawnAsChild(&globalCtx->actorCtx, &this->actor, globalCtx, ACTOR_EN_PO_SISTERS, sp90[i].x, sp90[i].y, - sp90[i].z, sp78[i].x, sp78[i].y, sp78[i].z, sp68[i]); + Actor_SpawnAsChild(&play->actorCtx, &this->actor, play, ACTOR_EN_PO_SISTERS, sp90[i].x, sp90[i].y, sp90[i].z, + sp78[i].x, sp78[i].y, sp78[i].z, sp68[i]); } } -void func_80B0FD8C(EnGb2* this, GlobalContext* globalCtx) { +void func_80B0FD8C(EnGb2* this, PlayState* play) { this->unk_280++; this->unk_268 = this->actor.child; - Actor_SpawnAsChild(&globalCtx->actorCtx, &this->actor, globalCtx, ACTOR_EN_PO_SISTERS, - D_80B119B0[this->unk_280].unk_04.x, D_80B119B0[this->unk_280].unk_04.y, - D_80B119B0[this->unk_280].unk_04.z, 0, 0, 0, D_80B119B0[this->unk_280].unk_10); + Actor_SpawnAsChild(&play->actorCtx, &this->actor, play, ACTOR_EN_PO_SISTERS, D_80B119B0[this->unk_280].unk_04.x, + D_80B119B0[this->unk_280].unk_04.y, D_80B119B0[this->unk_280].unk_04.z, 0, 0, 0, + D_80B119B0[this->unk_280].unk_10); } -void func_80B0FE18(GlobalContext* globalCtx) { +void func_80B0FE18(PlayState* play) { func_800FD750(0x38); - globalCtx->nextEntranceIndex = 0x9C10; - globalCtx->unk_1887F = 0x40; - gSaveContext.nextTransition = 0x40; - globalCtx->sceneLoadFlag = 0x14; + play->nextEntrance = ENTRANCE(GHOST_HUT, 1); + play->transitionType = TRANS_TYPE_64; + gSaveContext.nextTransitionType = TRANS_TYPE_64; + play->transitionTrigger = TRANS_TRIGGER_START; } -void func_80B0FE7C(GlobalContext* globalCtx) { - globalCtx->nextEntranceIndex = 0x9C20; - globalCtx->unk_1887F = 0x40; - gSaveContext.nextTransition = 0x40; - globalCtx->sceneLoadFlag = 0x14; +void func_80B0FE7C(PlayState* play) { + play->nextEntrance = ENTRANCE(GHOST_HUT, 2); + play->transitionType = TRANS_TYPE_64; + gSaveContext.nextTransitionType = TRANS_TYPE_64; + play->transitionTrigger = TRANS_TRIGGER_START; } -void func_80B0FEBC(EnGb2* this, GlobalContext* globalCtx) { - if ((globalCtx->msgCtx.ocarinaMode == 3) && (globalCtx->msgCtx.unk1202E == 7)) { - globalCtx->msgCtx.ocarinaMode = 4; +void func_80B0FEBC(EnGb2* this, PlayState* play) { + if ((play->msgCtx.ocarinaMode == OCARINA_SONG_ELEGY) && (play->msgCtx.lastPlayedSong == OCARINA_SONG_HEALING)) { + play->msgCtx.ocarinaMode = 4; gSaveContext.eventInf[4] |= 0x80; this->unk_26E = 0x14D1; this->unk_288 = 10; } - if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { - Message_StartTextbox(globalCtx, this->unk_26E, &this->actor); + if (Actor_ProcessTalkRequest(&this->actor, &play->state)) { + Message_StartTextbox(play, this->unk_26E, &this->actor); this->actionFunc = func_80B0FFA8; } else if ((this->actor.xzDistToPlayer < 300.0f) || this->actor.isTargeted) { - func_800B863C(&this->actor, globalCtx); + func_800B863C(&this->actor, play); } } -void func_80B0FFA8(EnGb2* this, GlobalContext* globalCtx) { - u8 temp_v0 = Message_GetState(&globalCtx->msgCtx); +void func_80B0FFA8(EnGb2* this, PlayState* play) { + u8 talkState = Message_GetState(&play->msgCtx); - if (temp_v0 == 5) { - if (Message_ShouldAdvance(globalCtx)) { + if (talkState == TEXT_STATE_5) { + if (Message_ShouldAdvance(play)) { if (this->unk_26C & 2) { - globalCtx->msgCtx.msgMode = 0x43; - globalCtx->msgCtx.unk12023 = 4; + play->msgCtx.msgMode = 0x43; + play->msgCtx.stateTimer = 4; this->unk_26E = 0x14D1; this->unk_288 = 30; gSaveContext.eventInf[4] &= (u8)~0x80; @@ -400,22 +400,22 @@ void func_80B0FFA8(EnGb2* this, GlobalContext* globalCtx) { this->actionFunc = func_80B0FEBC; } else { this->unk_26E = func_80B0F7FC(this); - Message_StartTextbox(globalCtx, this->unk_26E, &this->actor); + Message_StartTextbox(play, this->unk_26E, &this->actor); } } - } else if ((temp_v0 == 4) && Message_ShouldAdvance(globalCtx)) { + } else if ((talkState == TEXT_STATE_CHOICE) && Message_ShouldAdvance(play)) { if (this->unk_26E == 0x14D5) { - switch (globalCtx->msgCtx.choiceIndex) { + switch (play->msgCtx.choiceIndex) { case 0: if (gSaveContext.save.playerData.rupees < this->unk_288) { play_sound(NA_SE_SY_ERROR); this->unk_26E = 0x14D7; this->unk_26C |= 2; - Message_StartTextbox(globalCtx, this->unk_26E, &this->actor); + Message_StartTextbox(play, this->unk_26E, &this->actor); } else { func_8019F208(); this->unk_26E = 0x14D8; - Message_StartTextbox(globalCtx, this->unk_26E, &this->actor); + Message_StartTextbox(play, this->unk_26E, &this->actor); } break; @@ -423,17 +423,17 @@ void func_80B0FFA8(EnGb2* this, GlobalContext* globalCtx) { func_8019F230(); this->unk_26E = 0x14D6; this->unk_26C |= 2; - Message_StartTextbox(globalCtx, this->unk_26E, &this->actor); + Message_StartTextbox(play, this->unk_26E, &this->actor); break; } } else if (this->unk_26E == 0x14DA) { - switch (globalCtx->msgCtx.choiceIndex) { + switch (play->msgCtx.choiceIndex) { case 0: func_8019F208(); - func_801159EC(-this->unk_288); - globalCtx->msgCtx.msgMode = 0x43; - globalCtx->msgCtx.unk12023 = 4; - func_800B7298(globalCtx, NULL, 7); + Rupees_ChangeBy(-this->unk_288); + play->msgCtx.msgMode = 0x43; + play->msgCtx.stateTimer = 4; + func_800B7298(play, NULL, 7); this->actionFunc = func_80B11344; break; @@ -441,23 +441,23 @@ void func_80B0FFA8(EnGb2* this, GlobalContext* globalCtx) { func_8019F230(); this->unk_26E = 0x14DB; this->unk_26C |= 2; - Message_StartTextbox(globalCtx, this->unk_26E, &this->actor); + Message_StartTextbox(play, this->unk_26E, &this->actor); break; } } } } -void func_80B10240(EnGb2* this, GlobalContext* globalCtx) { +void func_80B10240(EnGb2* this, PlayState* play) { this->unk_27C = D_80B119B0[this->unk_280].unk_00; this->unk_27E = D_80B119B0[this->unk_280].unk_10; this->unk_282[0] = this->actor.cutscene; this->unk_268 = NULL; if (ActorCutscene_GetCanPlayNext(this->unk_282[0])) { ActorCutscene_Start(this->unk_282[0], &this->actor); - Actor_SpawnAsChild(&globalCtx->actorCtx, &this->actor, globalCtx, this->unk_27C, - D_80B119B0[this->unk_280].unk_04.x, D_80B119B0[this->unk_280].unk_04.y, - D_80B119B0[this->unk_280].unk_04.z, 0, 0, 0, this->unk_27E); + Actor_SpawnAsChild(&play->actorCtx, &this->actor, play, this->unk_27C, D_80B119B0[this->unk_280].unk_04.x, + D_80B119B0[this->unk_280].unk_04.y, D_80B119B0[this->unk_280].unk_04.z, 0, 0, 0, + this->unk_27E); if (this->unk_280 == 0) { func_8010E9F0(1, 180); } @@ -467,9 +467,9 @@ void func_80B10240(EnGb2* this, GlobalContext* globalCtx) { } } -void func_80B10344(EnGb2* this, GlobalContext* globalCtx) { +void func_80B10344(EnGb2* this, PlayState* play) { if (this->unk_280 == 1) { - func_80B0FD8C(this, globalCtx); + func_80B0FD8C(this, play); } if (this->unk_280 == 2) { @@ -490,7 +490,7 @@ void func_80B10344(EnGb2* this, GlobalContext* globalCtx) { gSaveContext.unk_3DD0[1] = 5; func_800FE498(); gSaveContext.eventInf[4] |= 0x40; - func_80B0FE7C(globalCtx); + func_80B0FE7C(play); } else if (this->unk_280 == 2) { if (this->unk_26C & 0x400) { this->unk_280++; @@ -518,7 +518,7 @@ void func_80B10344(EnGb2* this, GlobalContext* globalCtx) { this->actor.child = NULL; } - func_80B0FE7C(globalCtx); + func_80B0FE7C(play); } else if (gSaveContext.unk_3DE0[1] == 0) { gSaveContext.unk_3DD0[1] = 5; gSaveContext.eventInf[4] |= 0x40; @@ -532,29 +532,29 @@ void func_80B10344(EnGb2* this, GlobalContext* globalCtx) { this->actor.child = NULL; } - func_80B0FE7C(globalCtx); + func_80B0FE7C(play); } } -void func_80B10584(EnGb2* this, GlobalContext* globalCtx) { - if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { - Message_StartTextbox(globalCtx, this->unk_26E, &this->actor); +void func_80B10584(EnGb2* this, PlayState* play) { + if (Actor_ProcessTalkRequest(&this->actor, &play->state)) { + Message_StartTextbox(play, 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 |= ACTOR_FLAG_10000; - func_800B8614(&this->actor, globalCtx, 300.0f); + func_800B8614(&this->actor, play, 300.0f); } } -void func_80B10634(EnGb2* this, GlobalContext* globalCtx) { - u8 temp_v0 = Message_GetState(&globalCtx->msgCtx); +void func_80B10634(EnGb2* this, PlayState* play) { + u8 talkState = Message_GetState(&play->msgCtx); - if (temp_v0 == 5) { - if (Message_ShouldAdvance(globalCtx)) { + if (talkState == TEXT_STATE_5) { + if (Message_ShouldAdvance(play)) { if (this->unk_26C & 2) { - globalCtx->msgCtx.msgMode = 0x43; - globalCtx->msgCtx.unk12023 = 4; + play->msgCtx.msgMode = 0x43; + play->msgCtx.stateTimer = 4; this->unk_26C &= ~2; if (this->unk_26E == 0x14DD) { this->unk_26E = 0x14DE; @@ -569,23 +569,23 @@ void func_80B10634(EnGb2* this, GlobalContext* globalCtx) { } } else { this->unk_26E = func_80B0F8F8(this); - Message_StartTextbox(globalCtx, this->unk_26E, &this->actor); + Message_StartTextbox(play, this->unk_26E, &this->actor); } } - } else if ((temp_v0 == 4) && Message_ShouldAdvance(globalCtx)) { - switch (globalCtx->msgCtx.choiceIndex) { + } else if ((talkState == TEXT_STATE_CHOICE) && Message_ShouldAdvance(play)) { + switch (play->msgCtx.choiceIndex) { case 0: if (gSaveContext.save.playerData.rupees < this->unk_288) { play_sound(NA_SE_SY_ERROR); this->unk_26E = 0x14D7; this->unk_26C |= 2; - Message_StartTextbox(globalCtx, this->unk_26E, &this->actor); + Message_StartTextbox(play, this->unk_26E, &this->actor); } else { func_8019F208(); - func_801159EC(-this->unk_288); - globalCtx->msgCtx.msgMode = 0x43; - globalCtx->msgCtx.unk12023 = 4; - func_800B7298(globalCtx, NULL, 7); + Rupees_ChangeBy(-this->unk_288); + play->msgCtx.msgMode = 0x43; + play->msgCtx.stateTimer = 4; + func_800B7298(play, NULL, 7); this->actionFunc = func_80B11344; } break; @@ -594,13 +594,13 @@ void func_80B10634(EnGb2* this, GlobalContext* globalCtx) { func_8019F230(); this->unk_26E = 0x14E3; this->unk_26C |= 2; - Message_StartTextbox(globalCtx, this->unk_26E, &this->actor); + Message_StartTextbox(play, this->unk_26E, &this->actor); break; } } } -void func_80B10868(EnGb2* this, GlobalContext* globalCtx) { +void func_80B10868(EnGb2* this, PlayState* play) { if (ActorCutscene_GetCurrentIndex() != this->unk_282[2]) { if (ActorCutscene_GetCanPlayNext(this->unk_282[this->unk_290])) { this->actionFunc = func_80B10A48; @@ -614,7 +614,7 @@ void func_80B10868(EnGb2* this, GlobalContext* globalCtx) { } } -void func_80B10924(EnGb2* this, GlobalContext* globalCtx) { +void func_80B10924(EnGb2* this, PlayState* play) { s32 sp24; if (gSaveContext.save.weekEventReg[54] & 0x40) { @@ -623,29 +623,29 @@ void func_80B10924(EnGb2* this, GlobalContext* globalCtx) { sp24 = 12; } - if (Actor_HasParent(&this->actor, globalCtx)) { + if (Actor_HasParent(&this->actor, play)) { this->actor.parent = NULL; if (sp24 == 12) { gSaveContext.save.weekEventReg[54] |= 0x40; } else { - func_801159EC(50); + Rupees_ChangeBy(50); } this->actionFunc = func_80B109DC; } else { - Actor_PickUp(&this->actor, globalCtx, sp24, 300.0f, 300.0f); + Actor_PickUp(&this->actor, play, sp24, 300.0f, 300.0f); } } -void func_80B109DC(EnGb2* this, GlobalContext* globalCtx) { - if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { - Message_StartTextbox(globalCtx, this->unk_26E, &this->actor); +void func_80B109DC(EnGb2* this, PlayState* play) { + if (Actor_ProcessTalkRequest(&this->actor, &play->state)) { + Message_StartTextbox(play, this->unk_26E, &this->actor); this->actionFunc = func_80B10634; } else { - func_800B85E0(&this->actor, globalCtx, 300.0f, -1); + func_800B85E0(&this->actor, play, 300.0f, -1); } } -void func_80B10A48(EnGb2* this, GlobalContext* globalCtx) { +void func_80B10A48(EnGb2* this, PlayState* play) { this->unk_28A -= 5; if (this->unk_28A < 5) { this->unk_28A = 0; @@ -663,7 +663,7 @@ void func_80B10A48(EnGb2* this, GlobalContext* globalCtx) { case ENGB2_7_2: ActorCutscene_Stop(this->unk_282[this->unk_290]); if (this->unk_26E == 0x14FB) { - Flags_SetSwitch(globalCtx, ENGB2_GET_7F8(&this->actor)); + Flags_SetSwitch(play, ENGB2_GET_7F8(&this->actor)); Actor_MarkForDeath(&this->actor); } else { this->actor.draw = NULL; @@ -676,35 +676,35 @@ void func_80B10A48(EnGb2* this, GlobalContext* globalCtx) { } } -void func_80B10B5C(EnGb2* this, GlobalContext* globalCtx) { - s32 mask = Player_GetMask(globalCtx); +void func_80B10B5C(EnGb2* this, PlayState* play) { + s32 mask = Player_GetMask(play); if (this->unk_28C != mask) { - this->unk_28C = Player_GetMask(globalCtx); + this->unk_28C = Player_GetMask(play); this->unk_26C &= ~0x80; this->unk_26C &= ~0x20; this->unk_26C &= ~0x40; } - if (func_80B0FA48(this, globalCtx)) { + if (func_80B0FA48(this, play)) { this->unk_26C &= ~0x20; - if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state) && (this->unk_26C & 0x40)) { + if (Actor_ProcessTalkRequest(&this->actor, &play->state) && (this->unk_26C & 0x40)) { if ((this->unk_26E == 0x14EE) || (this->unk_26E == 0x14F4)) { this->unk_26C |= 2; } - Message_StartTextbox(globalCtx, this->unk_26E, &this->actor); + Message_StartTextbox(play, this->unk_26E, &this->actor); this->unk_290 = 1; this->unk_26C &= ~0x40; this->actionFunc = func_80B10DAC; } else if ((this->actor.xzDistToPlayer < 300.0f) && this->actor.isTargeted) { this->unk_26C |= 0x40; - func_800B8614(&this->actor, globalCtx, 300.0f); + func_800B8614(&this->actor, play, 300.0f); } } else { this->unk_26C &= ~0x40; - if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state) && (this->unk_26C & 0x20)) { + if (Actor_ProcessTalkRequest(&this->actor, &play->state) && (this->unk_26C & 0x20)) { this->actor.flags &= ~ACTOR_FLAG_10000; - Message_StartTextbox(globalCtx, this->unk_26E, &this->actor); + Message_StartTextbox(play, this->unk_26E, &this->actor); if (this->unk_26E == 0x14EB) { gSaveContext.save.weekEventReg[80] |= 0x40; } else if (this->unk_26E == 0x14EF) { @@ -718,19 +718,19 @@ void func_80B10B5C(EnGb2* this, GlobalContext* globalCtx) { if (!(this->unk_26C & 0x80)) { this->actor.flags |= ACTOR_FLAG_10000; this->unk_26C |= 0x20; - func_800B8614(&this->actor, globalCtx, 300.0f); + func_800B8614(&this->actor, play, 300.0f); } } } } -void func_80B10DAC(EnGb2* this, GlobalContext* globalCtx) { +void func_80B10DAC(EnGb2* this, PlayState* play) { if (ActorCutscene_GetCanPlayNext(this->unk_282[this->unk_290])) { if (ENGB2_GET_7(&this->actor) == ENGB2_7_1) { if (this->unk_290 != 2) { this->actionFunc = func_80B10E98; } else { - Flags_SetSwitch(globalCtx, ENGB2_GET_7F8(&this->actor)); + Flags_SetSwitch(play, ENGB2_GET_7F8(&this->actor)); this->actionFunc = func_80B10868; } } else { @@ -745,16 +745,16 @@ void func_80B10DAC(EnGb2* this, GlobalContext* globalCtx) { } } -void func_80B10E98(EnGb2* this, GlobalContext* globalCtx) { - if ((Message_GetState(&globalCtx->msgCtx) == 5) && Message_ShouldAdvance(globalCtx)) { +void func_80B10E98(EnGb2* this, PlayState* play) { + if ((Message_GetState(&play->msgCtx) == TEXT_STATE_5) && Message_ShouldAdvance(play)) { if (this->unk_26C & 2) { this->unk_26C &= ~2; - globalCtx->msgCtx.msgMode = 0x43; - globalCtx->msgCtx.unk12023 = 4; + play->msgCtx.msgMode = 0x43; + play->msgCtx.stateTimer = 4; if ((this->unk_26E != 0x14E8) && (this->unk_26E != 0x14EA)) { ActorCutscene_Stop(this->unk_282[this->unk_290]); this->actionFunc = func_80B10B5C; - } else if (Flags_GetSwitch(globalCtx, ENGB2_GET_7F8(&this->actor))) { + } else if (Flags_GetSwitch(play, ENGB2_GET_7F8(&this->actor))) { this->actionFunc = func_80B10A48; } else { ActorCutscene_Stop(this->unk_282[this->unk_290]); @@ -766,7 +766,7 @@ void func_80B10E98(EnGb2* this, GlobalContext* globalCtx) { s32 temp; this->unk_26E = func_80B0FB24(this); - Message_StartTextbox(globalCtx, this->unk_26E, &this->actor); + Message_StartTextbox(play, this->unk_26E, &this->actor); temp = this->unk_26E; if ((temp == 0x14E7) || (temp == 0x14E9) || (temp == 0x14EC) || (temp == 0x14F0)) { ActorCutscene_Stop(this->unk_282[this->unk_290]); @@ -778,39 +778,39 @@ void func_80B10E98(EnGb2* this, GlobalContext* globalCtx) { } } -void func_80B11048(EnGb2* this, GlobalContext* globalCtx) { - if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { +void func_80B11048(EnGb2* this, PlayState* play) { + if (Actor_ProcessTalkRequest(&this->actor, &play->state)) { this->actor.flags &= ~ACTOR_FLAG_10000; - Message_StartTextbox(globalCtx, this->unk_26E, &this->actor); + Message_StartTextbox(play, this->unk_26E, &this->actor); this->actionFunc = func_80B10DAC; } else if (this->actor.xzDistToPlayer < 300.0f) { this->actor.flags |= ACTOR_FLAG_10000; - func_800B8614(&this->actor, globalCtx, 200.0f); + func_800B8614(&this->actor, play, 200.0f); } } -void func_80B110F8(EnGb2* this, GlobalContext* globalCtx) { - if ((Message_GetState(&globalCtx->msgCtx) == 5) && Message_ShouldAdvance(globalCtx)) { +void func_80B110F8(EnGb2* this, PlayState* play) { + if ((Message_GetState(&play->msgCtx) == TEXT_STATE_5) && Message_ShouldAdvance(play)) { if (this->unk_26C & 2) { - globalCtx->msgCtx.msgMode = 0x43; - globalCtx->msgCtx.unk12023 = 4; + play->msgCtx.msgMode = 0x43; + play->msgCtx.stateTimer = 4; this->unk_26C &= ~2; this->actionFunc = func_80B10A48; } else { this->unk_26E = func_80B0F97C(this); - Message_StartTextbox(globalCtx, this->unk_26E, &this->actor); + Message_StartTextbox(play, this->unk_26E, &this->actor); } } } -void func_80B111AC(EnGb2* this, GlobalContext* globalCtx) { +void func_80B111AC(EnGb2* this, PlayState* play) { s32 index; - if (globalCtx->roomCtx.currRoom.num == 1) { + if (play->roomCtx.currRoom.num == 1) { return; } - switch (globalCtx->roomCtx.currRoom.num) { + switch (play->roomCtx.currRoom.num) { case 2: index = 1; break; @@ -836,12 +836,11 @@ void func_80B111AC(EnGb2* this, GlobalContext* globalCtx) { this->actionFunc = func_80B11268; } -void func_80B11268(EnGb2* this, GlobalContext* globalCtx) { - if (globalCtx->roomCtx.currRoom.num == 1) { +void func_80B11268(EnGb2* this, PlayState* play) { + if (play->roomCtx.currRoom.num == 1) { this->unk_290 = 0; this->unk_282[0] = this->actor.cutscene; - if (Flags_GetClear(globalCtx, 2) && Flags_GetClear(globalCtx, 3) && Flags_GetClear(globalCtx, 4) && - Flags_GetClear(globalCtx, 5)) { + if (Flags_GetClear(play, 2) && Flags_GetClear(play, 3) && Flags_GetClear(play, 4) && Flags_GetClear(play, 5)) { this->unk_28A = 0xFF; this->unk_26C &= ~0x100; this->actor.flags |= ACTOR_FLAG_1; @@ -854,9 +853,9 @@ void func_80B11268(EnGb2* this, GlobalContext* globalCtx) { } } -void func_80B11344(EnGb2* this, GlobalContext* globalCtx) { +void func_80B11344(EnGb2* this, PlayState* play) { if (gSaveContext.rupeeAccumulator == 0) { - func_80B0FE18(globalCtx); + func_80B0FE18(play); } } @@ -865,22 +864,22 @@ static InitChainEntry sInitChain[] = { ICHAIN_F32(targetArrowOffset, 2200, ICHAIN_STOP), }; -void EnGb2_Init(Actor* thisx, GlobalContext* globalCtx) { +void EnGb2_Init(Actor* thisx, PlayState* play) { s32 pad; EnGb2* this = THIS; - if (func_80B0F660(this, globalCtx)) { + if (func_80B0F660(this, play)) { Actor_MarkForDeath(&this->actor); return; } this->actor.room = -1; Actor_ProcessInitChain(&this->actor, sInitChain); - SkelAnime_InitFlex(globalCtx, &this->skelAnime, &object_ps_Skel_007230, &object_ps_Anim_00049C, this->jointTable, + SkelAnime_InitFlex(play, &this->skelAnime, &object_ps_Skel_007230, &object_ps_Anim_00049C, this->jointTable, this->morphTable, 12); ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 35.0f); - Collider_InitCylinder(globalCtx, &this->collider); - Collider_SetCylinderType1(globalCtx, &this->collider, &this->actor, &sCylinderInit); + Collider_InitCylinder(play, &this->collider); + Collider_SetCylinderType1(play, &this->collider, &this->actor, &sCylinderInit); Actor_SetScale(&this->actor, 0.01f); switch (ENGB2_GET_7(&this->actor)) { @@ -891,7 +890,7 @@ void EnGb2_Init(Actor* thisx, GlobalContext* globalCtx) { Actor_MarkForDeath(&this->actor); } - if (gSaveContext.save.entranceIndex == 0x9C10) { + if (gSaveContext.save.entrance == ENTRANCE(GHOST_HUT, 1)) { func_800FE484(); this->actionFunc = func_80B10240; break; @@ -902,40 +901,40 @@ void EnGb2_Init(Actor* thisx, GlobalContext* globalCtx) { this->actor.flags |= ACTOR_FLAG_2000000; if (gSaveContext.eventInf[4] & 0x40) { - func_80B0F728(this, globalCtx); + func_80B0F728(this, play); } else { - func_80B0FBF0(this, globalCtx); + func_80B0FBF0(this, play); func_80B0F6DC(this); } break; case ENGB2_7_1: - if ((globalCtx->curSpawn == 1) || (gSaveContext.save.weekEventReg[80] & 0x80)) { + if ((play->curSpawn == 1) || (gSaveContext.save.weekEventReg[80] & 0x80)) { Actor_MarkForDeath(&this->actor); return; } - if (Flags_GetSwitch(globalCtx, ENGB2_GET_7F8(thisx))) { + if (Flags_GetSwitch(play, ENGB2_GET_7F8(thisx))) { Actor_MarkForDeath(&this->actor); return; } this->unk_28A = 255; func_80B0FA04(this); - this->unk_28C = Player_GetMask(globalCtx); + this->unk_28C = Player_GetMask(play); this->actionFunc = func_80B10B5C; break; case ENGB2_7_2: this->unk_290 = 0; this->unk_282[0] = this->actor.cutscene; - if (Flags_GetSwitch(globalCtx, ENGB2_GET_7F8(thisx))) { + if (Flags_GetSwitch(play, ENGB2_GET_7F8(thisx))) { Actor_MarkForDeath(&this->actor); return; } - if (Flags_GetClear(globalCtx, 2) && Flags_GetClear(globalCtx, 3) && Flags_GetClear(globalCtx, 4) && - Flags_GetClear(globalCtx, 5)) { + if (Flags_GetClear(play, 2) && Flags_GetClear(play, 3) && Flags_GetClear(play, 4) && + Flags_GetClear(play, 5)) { Actor_MarkForDeath(&this->actor); return; } @@ -958,32 +957,31 @@ void EnGb2_Init(Actor* thisx, GlobalContext* globalCtx) { } } -void EnGb2_Destroy(Actor* thisx, GlobalContext* globalCtx) { +void EnGb2_Destroy(Actor* thisx, PlayState* play) { EnGb2* this = THIS; - Collider_DestroyCylinder(globalCtx, &this->collider); + Collider_DestroyCylinder(play, &this->collider); } -void EnGb2_Update(Actor* thisx, GlobalContext* globalCtx) { +void EnGb2_Update(Actor* thisx, PlayState* play) { EnGb2* this = THIS; SkelAnime_Update(&this->skelAnime); - this->actionFunc(this, globalCtx); + this->actionFunc(this, play); if (!(this->unk_26C & 0x100)) { - func_80B0F5E0(this, globalCtx); + func_80B0F5E0(this, play); } - func_800E9250(globalCtx, &this->actor, &this->unk_270, &this->unk_276, this->actor.focus.pos); + Actor_TrackPlayer(play, &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, +s32 EnGb2_OverrideLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, Actor* thisx, Gfx** gfx) { 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) { @@ -993,39 +991,39 @@ s32 EnGb2_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, return false; } -void EnGb2_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx, Gfx** gfx) { +void EnGb2_PostLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx, Gfx** gfx) { EnGb2* this = THIS; 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); } } -void EnGb2_Draw(Actor* thisx, GlobalContext* globalCtx) { +void EnGb2_Draw(Actor* thisx, PlayState* play) { EnGb2* this = THIS; - OPEN_DISPS(globalCtx->state.gfxCtx); + OPEN_DISPS(play->state.gfxCtx); if (this->unk_28A == 255) { - func_8012C28C(globalCtx->state.gfxCtx); + func_8012C28C(play->state.gfxCtx); 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, EnGb2_OverrideLimbDraw, EnGb2_PostLimbDraw, - &this->actor, POLY_OPA_DISP); + Scene_SetRenderModeXlu(play, 0, 1); + POLY_OPA_DISP = + SkelAnime_DrawFlex(play, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, + EnGb2_OverrideLimbDraw, EnGb2_PostLimbDraw, &this->actor, POLY_OPA_DISP); } else { - func_8012C2DC(globalCtx->state.gfxCtx); + func_8012C2DC(play->state.gfxCtx); gDPSetEnvColor(POLY_OPA_DISP++, 255, 255, 255, this->unk_28A); - Scene_SetRenderModeXlu(globalCtx, 1, 2); - POLY_XLU_DISP = SkelAnime_DrawFlex(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, - this->skelAnime.dListCount, EnGb2_OverrideLimbDraw, EnGb2_PostLimbDraw, - &this->actor, POLY_XLU_DISP); + Scene_SetRenderModeXlu(play, 1, 2); + POLY_XLU_DISP = + SkelAnime_DrawFlex(play, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, + EnGb2_OverrideLimbDraw, EnGb2_PostLimbDraw, &this->actor, POLY_XLU_DISP); } - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->state.gfxCtx); } diff --git a/src/overlays/actors/ovl_En_Gb2/z_en_gb2.h b/src/overlays/actors/ovl_En_Gb2/z_en_gb2.h index c054c4ed2..cb53ada3b 100644 --- a/src/overlays/actors/ovl_En_Gb2/z_en_gb2.h +++ b/src/overlays/actors/ovl_En_Gb2/z_en_gb2.h @@ -5,7 +5,7 @@ struct EnGb2; -typedef void (*EnGb2ActionFunc)(struct EnGb2*, GlobalContext*); +typedef void (*EnGb2ActionFunc)(struct EnGb2*, PlayState*); #define ENGB2_GET_7(thisx) ((thisx)->params & 7) #define ENGB2_GET_7F8(thisx) (((thisx)->params & 0x7F8) >> 3) 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 935eacb8c..ad0d3de24 100644 --- a/src/overlays/actors/ovl_En_Ge1/z_en_ge1.c +++ b/src/overlays/actors/ovl_En_Ge1/z_en_ge1.c @@ -10,12 +10,11 @@ #define THIS ((EnGe1*)thisx) -void EnGe1_Init(Actor* thisx, GlobalContext* globalCtx); -void EnGe1_Destroy(Actor* thisx, GlobalContext* globalCtx); -void EnGe1_Update(Actor* thisx, GlobalContext* globalCtx); -void EnGe1_Draw(Actor* thisx, GlobalContext* globalCtx); +void EnGe1_Init(Actor* thisx, PlayState* play); +void EnGe1_Destroy(Actor* thisx, PlayState* play); +void EnGe1_Update(Actor* thisx, PlayState* play); +void EnGe1_Draw(Actor* thisx, PlayState* play); -#if 0 const ActorInit En_Ge1_InitVars = { ACTOR_EN_GE1, ACTORCAT_NPC, @@ -28,45 +27,432 @@ const ActorInit En_Ge1_InitVars = { (ActorFunc)EnGe1_Draw, }; -// static ColliderCylinderInit sCylinderInit = { -static ColliderCylinderInit D_809464D0 = { - { COLTYPE_NONE, AT_NONE, AC_ON | AC_TYPE_ENEMY, OC1_ON | OC1_TYPE_ALL, OC2_TYPE_1, COLSHAPE_CYLINDER, }, - { ELEMTYPE_UNK0, { 0x00000000, 0x00, 0x00 }, { 0x01000202, 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 }, + { 0x01000202, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_ON, + }, { 20, 40, 0, { 0, 0, 0 } }, }; -#endif +//! State flags -extern ColliderCylinderInit D_809464D0; +//! Disable normal movement to let pathing function control it completely. +#define GERUDO_WHITE_STATE_DISABLE_MOVEMENT (1 << 3) -extern UNK_TYPE D_06002B98; +typedef enum { + /* 0 */ GERUDO_WHITE_HAIR_BOB, + /* 1 */ GERUDO_WHITE_HAIR_STRAIGHT, + /* 2 */ GERUDO_WHITE_HAIR_SPIKEY +} GerudoWhiteHairstyle; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ge1/EnGe1_Init.s") +typedef enum { + /* -1 */ GERUDO_WHITE_ANIM_NONE = -1, + /* 0 */ GERUDO_WHITE_ANIM_ARMS_FOLDED, + /* 1 */ GERUDO_WHITE_ANIM_UNFOLDING_ARMS, // Unused + /* 2 */ GERUDO_WHITE_ANIM_STANDING_HEAD_BOWED, + /* 3 */ GERUDO_WHITE_ANIM_STIFFENING, + /* 4 */ GERUDO_WHITE_ANIM_STIFF_SHIVERING, + /* 5 */ GERUDO_WHITE_ANIM_TRUDGING_OFF, + /* 6 */ GERUDO_WHITE_ANIM_EXCITED_CLAPPING, + /* 7 */ GERUDO_WHITE_ANIM_SALUTE, + /* 8 */ GERUDO_WHITE_ANIM_LEADING_BOAT, + /* 9 */ GERUDO_WHITE_ANIM_BLOWN_AWAY, +} GerudoWhiteAnimations; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ge1/EnGe1_Destroy.s") +void EnGe1_ChangeAnim(EnGe1* this, s16 animIndex, u8 mode, f32 morphFrames); +void EnGe1_ShadowDraw(Actor* actor, Lights* lights, PlayState* play); +void EnGe1_Wait(EnGe1* this, PlayState* play); +void EnGe1_PerformCutsceneActions(EnGe1* this, PlayState* play); +s32 EnGe1_ValidatePictograph(PlayState* play, Actor* this); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ge1/func_809457EC.s") +void EnGe1_Init(Actor* thisx, PlayState* play) { + EnGe1* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ge1/func_80945924.s") + ActorShape_Init(&this->picto.actor.shape, 0.0f, EnGe1_ShadowDraw, 30.0f); + SkelAnime_InitFlex(play, &this->skelAnime, &gGerudoWhiteSkel, &gGerudoWhiteArmsFoldedAnim, this->jointTable, + this->morphTable, GERUDO_WHITE_LIMB_MAX); + Collider_InitAndSetCylinder(play, &this->collider, &this->picto.actor, &sCylinderInit); + this->picto.actor.colChkInfo.mass = MASS_IMMOVABLE; + this->picto.actor.targetMode = 6; + Actor_SetScale(&this->picto.actor, 0.01f); + this->animIndex = this->csAction = -1; // GERUDO_WHITE_ANIM_NONE + this->stateFlags = 0; + EnGe1_ChangeAnim(this, GERUDO_WHITE_ANIM_ARMS_FOLDED, ANIMMODE_LOOP, 0.0f); + this->actionFunc = EnGe1_Wait; + this->picto.validationFunc = EnGe1_ValidatePictograph; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ge1/func_80945A00.s") + switch (GERUDO_WHITE_GET_TYPE(&this->picto.actor)) { + default: + this->hairstyle = GERUDO_WHITE_HAIR_BOB; + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ge1/func_80945A9C.s") + case GERUDO_WHITE_TYPE_HAIR_STRAIGHT: + this->hairstyle = GERUDO_WHITE_HAIR_STRAIGHT; + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ge1/func_80945B60.s") + case GERUDO_WHITE_TYPE_HAIR_SPIKEY: + this->hairstyle = GERUDO_WHITE_HAIR_SPIKEY; + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ge1/func_80945C50.s") + case GERUDO_WHITE_TYPE_CUTSCENE: // Only type used in-game + this->hairstyle = GERUDO_WHITE_HAIR_BOB; + this->actionFunc = EnGe1_PerformCutsceneActions; + this->picto.actor.draw = NULL; + this->picto.actor.flags |= ACTOR_FLAG_20 | ACTOR_FLAG_10; + this->picto.actor.flags &= ~ACTOR_FLAG_1; + break; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ge1/func_80945CAC.s") + this->picto.actor.terminalVelocity = -9.0f; + this->picto.actor.velocity.y = -9.0f; + this->picto.actor.gravity = -1.0f; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ge1/func_80945CE4.s") +void EnGe1_Destroy(Actor* thisx, PlayState* play) { + EnGe1* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ge1/EnGe1_Update.s") + Collider_DestroyCylinder(play, &this->collider); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ge1/func_80946190.s") +void EnGe1_ChangeAnim(EnGe1* this, s16 animIndex, u8 mode, f32 morphFrames) { + static AnimationHeader* sAnimations[] = { + &gGerudoWhiteArmsFoldedAnim, // GERUDO_WHITE_ANIM_ARMS_FOLDED, + &gGerudoWhiteUnfoldingArmsAnim, // GERUDO_WHITE_ANIM_UNFOLDING_ARMS + &gGerudoWhiteStandingHeadBowedAnim, // GERUDO_WHITE_ANIM_STANDING_HEAD_BOWED, + &gGerudoWhiteStiffeningAnim, // GERUDO_WHITE_ANIM_STIFFENING, + &gGerudoWhiteStiffShiveringAnim, // GERUDO_WHITE_ANIM_STIFF_SHIVERING, + &gGerudoWhiteTrudgingOffAnim, // GERUDO_WHITE_ANIM_TRUDGING_OFF, + &gGerudoWhiteExcitedClappingAnim, // GERUDO_WHITE_ANIM_EXCITED_CLAPPING, + &gGerudoWhiteSaluteAnim, // GERUDO_WHITE_ANIM_SALUTE, + &gGerudoWhiteGreatBayCutsceneAnim, // GERUDO_WHITE_ANIM_LEADING_BOAT, + &gGerudoWhiteGreatBayCutsceneAnim, // GERUDO_WHITE_ANIM_BLOWN_AWAY, + }; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ge1/func_80946238.s") + // The GERUDO_WHITE_ANIM_LEADING_BOAT / GERUDO_WHITE_ANIM_BLOWN_AWAY cases are single frames of an "animation" used + // as static poses. + switch (animIndex) { + case GERUDO_WHITE_ANIM_LEADING_BOAT: + Animation_Change(&this->skelAnime, sAnimations[animIndex], 0.0f, 0.0f, 0.0f, ANIMMODE_ONCE, 0.0f); + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ge1/func_80946368.s") + case GERUDO_WHITE_ANIM_BLOWN_AWAY: + Animation_Change(&this->skelAnime, sAnimations[animIndex], 0.0f, 1.0f, 1.0f, ANIMMODE_ONCE, 0.0f); + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ge1/EnGe1_Draw.s") + default: + Animation_Change(&this->skelAnime, sAnimations[animIndex], 1.0f, 0.0f, + Animation_GetLastFrame(sAnimations[animIndex]), mode, morphFrames); + break; + } + + this->animIndex = animIndex; +} + +void EnGe1_LookAtPlayer(EnGe1* this, PlayState* play) { + s16 yawDiff = this->picto.actor.yawTowardsPlayer - this->picto.actor.shape.rot.y; + + if ((ABS_ALT(yawDiff) <= 0x4300) && (this->picto.actor.xzDistToPlayer < 100.0f)) { + Actor_TrackPlayer(play, &this->picto.actor, &this->headRot, &this->torsoRot, this->picto.actor.focus.pos); + } else { + Math_SmoothStepToS(&this->headRot.x, 0, 6, 0x1838, 0x64); + Math_SmoothStepToS(&this->headRot.y, 0, 6, 0x1838, 0x64); + } +} + +void EnGe1_ShadowDraw(Actor* thisx, Lights* lights, PlayState* play) { + Vec3f pos; + EnGe1* this = THIS; + + Math_Vec3f_Copy(&pos, &this->picto.actor.world.pos); + Math_Vec3f_Copy(&this->picto.actor.world.pos, &this->waistPos); + func_800B4AEC(play, &this->picto.actor, 50.0f); + this->picto.actor.world.pos.y = MAX(this->picto.actor.floorHeight, pos.y); + ActorShadow_DrawCircle(&this->picto.actor, lights, play); + Math_Vec3f_Copy(&this->picto.actor.world.pos, &pos); +} + +void EnGe1_SetupPath(EnGe1* this, PlayState* play) { + s32 pad; + Vec3s* point; + Vec3f nextPoint; + + this->curPoint = 0; + if (GERUDO_WHITE_GET_PATH(&this->picto.actor) != 0x3F) { + this->path = &play->setupPathList[GERUDO_WHITE_GET_PATH(&this->picto.actor)]; + if (this->path != NULL) { + point = Lib_SegmentedToVirtual(this->path->points); + Math_Vec3s_ToVec3f(&this->picto.actor.world.pos, point); + this->curPoint++; + point++; + Math_Vec3s_ToVec3f(&nextPoint, point); + + this->picto.actor.world.rot.y = Math_Vec3f_Yaw(&this->picto.actor.world.pos, &nextPoint); + this->picto.actor.world.rot.x = Math_Vec3f_Pitch(&this->picto.actor.world.pos, &nextPoint); + this->picto.actor.speedXZ = 15.0f; + } + } else { + this->path = NULL; + } +} + +/** + * @return s32 true if close to next point or no path set. + */ +s32 EnGe1_FollowPath(EnGe1* this) { + s32 pad; + Path* path = this->path; + Vec3s* points; + Vec3f point; + s16 yawTarget; + s16 pitchTarget; + + if (path == NULL) { + return true; + } + + points = Lib_SegmentedToVirtual(this->path->points); + points += this->curPoint; + + Math_Vec3s_ToVec3f(&point, points); + yawTarget = Math_Vec3f_Yaw(&this->picto.actor.world.pos, &point); + pitchTarget = Math_Vec3f_Pitch(&this->picto.actor.world.pos, &point); + Math_SmoothStepToS(&this->picto.actor.world.rot.y, yawTarget, 0xA, 0x3E8, 0x64); + Math_SmoothStepToS(&this->picto.actor.world.rot.x, pitchTarget, 6, 0x7D0, 0xC8); + Actor_MoveWithoutGravityReverse(&this->picto.actor); + + if (Math_Vec3f_DistXYZ(&this->picto.actor.world.pos, &point) < 40.0f) { + return true; + } else { + return false; + } +} + +void EnGe1_Scream(EnGe1* this) { + if ((s32)Rand_ZeroFloat(2.0f) == 0) { + Actor_PlaySfxAtPos(&this->picto.actor, NA_SE_VO_FPVO00); + } else { + Actor_PlaySfxAtPos(&this->picto.actor, NA_SE_VO_FPVO01); + } +} + +void EnGe1_Wait(EnGe1* this, PlayState* play) { + SkelAnime_Update(&this->skelAnime); + EnGe1_LookAtPlayer(this, play); +} + +void EnGe1_PerformCutsceneActions(EnGe1* this, PlayState* play) { + s16 csAction; + + if (SkelAnime_Update(&this->skelAnime) && (this->csAction == 3)) { + EnGe1_ChangeAnim(this, GERUDO_WHITE_ANIM_STIFF_SHIVERING, ANIMMODE_LOOP, 0.0f); + } + + if (Cutscene_CheckActorAction(play, 0x79)) { + this->picto.actor.draw = EnGe1_Draw; + csAction = play->csCtx.actorActions[Cutscene_GetActorActionIndex(play, 0x79)]->action; + switch (csAction) { + case 8: + this->stateFlags &= ~GERUDO_WHITE_STATE_DISABLE_MOVEMENT; + break; + + case 9: + this->stateFlags |= GERUDO_WHITE_STATE_DISABLE_MOVEMENT; + break; + + default: + this->stateFlags &= ~GERUDO_WHITE_STATE_DISABLE_MOVEMENT; + Cutscene_ActorTranslateAndYaw(&this->picto.actor, play, Cutscene_GetActorActionIndex(play, 0x79)); + break; + } + + if (this->csAction != csAction) { + this->csAction = csAction; + + switch (this->csAction) { + // Aveil cutscene + case 1: + EnGe1_ChangeAnim(this, GERUDO_WHITE_ANIM_ARMS_FOLDED, ANIMMODE_LOOP, 0.0f); + break; + + case 2: + EnGe1_ChangeAnim(this, GERUDO_WHITE_ANIM_STANDING_HEAD_BOWED, ANIMMODE_LOOP, 0.0f); + break; + + case 3: + EnGe1_ChangeAnim(this, GERUDO_WHITE_ANIM_STIFFENING, ANIMMODE_ONCE, 0.0f); + break; + + case 4: + EnGe1_ChangeAnim(this, GERUDO_WHITE_ANIM_TRUDGING_OFF, ANIMMODE_ONCE, 0.0f); + break; + + case 5: + EnGe1_ChangeAnim(this, GERUDO_WHITE_ANIM_EXCITED_CLAPPING, ANIMMODE_LOOP, 0.0f); + break; + + case 6: + EnGe1_ChangeAnim(this, GERUDO_WHITE_ANIM_SALUTE, ANIMMODE_ONCE, 0.0f); + break; + + case 7: + Actor_MarkForDeath(&this->picto.actor); + break; + + // Twister cutscene + case 8: + EnGe1_ChangeAnim(this, GERUDO_WHITE_ANIM_LEADING_BOAT, ANIMMODE_ONCE, 0.0f); + break; + + case 9: + EnGe1_ChangeAnim(this, GERUDO_WHITE_ANIM_BLOWN_AWAY, ANIMMODE_ONCE, 0.0f); + EnGe1_SetupPath(this, play); + this->stateFlags |= GERUDO_WHITE_STATE_DISABLE_MOVEMENT; + this->screamTimer = (s32)(Rand_ZeroFloat(10.0f) + 20.0f); + break; + } + + SkelAnime_Update(&this->skelAnime); + } + + if ((this->animIndex == GERUDO_WHITE_ANIM_TRUDGING_OFF) && + (Animation_OnFrame(&this->skelAnime, 12.0f) || Animation_OnFrame(&this->skelAnime, 25.0f))) { + Actor_PlaySfxAtPos(&this->picto.actor, NA_SE_EV_PIRATE_WALK); + } + + if ((this->animIndex == GERUDO_WHITE_ANIM_SALUTE) && Animation_OnFrame(&this->skelAnime, 14.0f)) { + Actor_PlaySfxAtPos(&this->picto.actor, NA_SE_EV_PIRATE_WALK); + } + } else { + this->picto.actor.draw = NULL; + } + + if (this->csAction == 9) { + if ((this->curPoint < this->path->count) && EnGe1_FollowPath(this)) { + this->curPoint++; + } + + // Tumble in the air + this->picto.actor.shape.rot.x += 0x3E8; + this->picto.actor.shape.rot.y += 0x7D0; + this->picto.actor.shape.rot.z += 0x1F4; + + if (this->screamTimer > 0) { + this->screamTimer--; + } else { + this->screamTimer = (s32)(Rand_ZeroFloat(10.0f) + 20.0f); + EnGe1_Scream(this); + } + } +} + +void EnGe1_Update(Actor* thisx, PlayState* play) { + s32 pad; + EnGe1* this = THIS; + + if (this->picto.actor.draw != NULL) { + Collider_UpdateCylinder(&this->picto.actor, &this->collider); + CollisionCheck_SetOC(play, &play->colChkCtx, &this->collider.base); + } + if (!(this->stateFlags & GERUDO_WHITE_STATE_DISABLE_MOVEMENT)) { + Actor_MoveWithGravity(&this->picto.actor); + } + Actor_UpdateBgCheckInfo(play, &this->picto.actor, 40.0f, 25.0f, 40.0f, 5); + this->actionFunc(this, play); + this->torsoRot.x = this->torsoRot.y = this->torsoRot.z = 0; + + if (DECR(this->blinkTimer) == 0) { + this->blinkTimer = Rand_S16Offset(60, 60); + } + + this->eyeIndex = this->blinkTimer; + if (this->eyeIndex >= 3) { + this->eyeIndex = 0; + } +} + +s32 EnGe1_ValidatePictograph(PlayState* play, Actor* thisx) { + s32 ret = Snap_ValidatePictograph(play, thisx, PICTOGRAPH_PIRATE_GOOD, &thisx->focus.pos, &thisx->shape.rot, 10.0f, + 400.0f, -1); + + ret |= Snap_ValidatePictograph(play, thisx, PICTOGRAPH_PIRATE_TOO_FAR, &thisx->focus.pos, &thisx->shape.rot, 10.0f, + 1200.0f, -1); + + return ret; +} + +s32 EnGe1_OverrideLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, Actor* thisx) { + s32 pad; + EnGe1* this = THIS; + + if (limbIndex == GERUDO_WHITE_LIMB_HEAD) { + rot->x += this->headRot.y; + rot->z += this->headRot.x; + } + if (this->animIndex == GERUDO_WHITE_ANIM_ARMS_FOLDED) { + // Make small fidgeting movements if in standing animation. + if ((limbIndex == GERUDO_WHITE_LIMB_TORSO) || (limbIndex == GERUDO_WHITE_LIMB_LEFT_FOREARM) || + (limbIndex == GERUDO_WHITE_LIMB_RIGHT_FOREARM)) { + rot->y += (s16)(Math_SinS(play->state.frames * (limbIndex * 50 + 0x814)) * 200.0f); + rot->z += (s16)(Math_CosS(play->state.frames * (limbIndex * 50 + 0x940)) * 200.0f); + } + } + return false; +} + +void EnGe1_PostLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx) { + static Gfx* sHairstyleDLs[] = { + gGerudoWhiteHairstyleBobDL, + gGerudoWhiteHairstyleStraightFringeDL, + gGerudoWhiteHairstyleSpikyDL, + }; + static Vec3f sInitialFocusPos = { 600.0f, 700.0f, 0.0f }; + static Vec3f sZeroVec = { 0.0f, 0.0f, 0.0f }; + EnGe1* this = THIS; + + OPEN_DISPS(play->state.gfxCtx); + + switch (limbIndex) { + case GERUDO_WHITE_LIMB_WAIST: + Matrix_MultVec3f(&sZeroVec, &this->waistPos); + break; + + case GERUDO_WHITE_LIMB_HEAD: + gSPDisplayList(POLY_OPA_DISP++, sHairstyleDLs[this->hairstyle]); + Matrix_MultVec3f(&sInitialFocusPos, &this->picto.actor.focus.pos); + break; + } + + CLOSE_DISPS(play->state.gfxCtx); +} + +void EnGe1_Draw(Actor* thisx, PlayState* play) { + static TexturePtr sEyeTextures[] = { + gGerudoWhiteEyeOpenTex, + gGerudoWhiteEyeHalfTex, + gGerudoWhiteEyeClosedTex, + }; + s32 pad; + EnGe1* this = THIS; + + OPEN_DISPS(play->state.gfxCtx); + + func_8012C5B0(play->state.gfxCtx); + gSPSegment(POLY_OPA_DISP++, 0x08, Lib_SegmentedToVirtual(sEyeTextures[this->eyeIndex])); + SkelAnime_DrawFlexOpa(play, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, + EnGe1_OverrideLimbDraw, EnGe1_PostLimbDraw, &this->picto.actor); + + CLOSE_DISPS(play->state.gfxCtx); +} diff --git a/src/overlays/actors/ovl_En_Ge1/z_en_ge1.h b/src/overlays/actors/ovl_En_Ge1/z_en_ge1.h index 83b3d2611..ae6cc601e 100644 --- a/src/overlays/actors/ovl_En_Ge1/z_en_ge1.h +++ b/src/overlays/actors/ovl_En_Ge1/z_en_ge1.h @@ -2,15 +2,42 @@ #define Z_EN_GE1_H #include "global.h" +#include "z64snap.h" +#include "objects/object_ge1/object_ge1.h" + +#define GERUDO_WHITE_GET_TYPE(thisx) (((thisx)->params) & 0xF) +#define GERUDO_WHITE_GET_PATH(thisx) ((((thisx)->params) & 0xFC00) >> 10) + +//! Only the first type is used +typedef enum { + /* 0 */ GERUDO_WHITE_TYPE_CUTSCENE, + /* 1 */ GERUDO_WHITE_TYPE_HAIR_STRAIGHT, + /* 2 */ GERUDO_WHITE_TYPE_HAIR_SPIKEY +} GerudoWhiteType; struct EnGe1; -typedef void (*EnGe1ActionFunc)(struct EnGe1*, GlobalContext*); +typedef void (*EnGe1ActionFunc)(struct EnGe1*, PlayState*); typedef struct EnGe1 { - /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x184]; - /* 0x02C8 */ EnGe1ActionFunc actionFunc; + /* 0x000 */ PictoActor picto; + /* 0x148 */ ColliderCylinder collider; + /* 0x194 */ SkelAnime skelAnime; + /* 0x1D8 */ Vec3f waistPos; + /* 0x1E4 */ Vec3s jointTable[GERUDO_WHITE_LIMB_MAX]; + /* 0x244 */ Vec3s morphTable[GERUDO_WHITE_LIMB_MAX]; + /* 0x2A4 */ Vec3s headRot; + /* 0x2AA */ Vec3s torsoRot; + /* 0x2B0 */ Path* path; + /* 0x2B4 */ s32 curPoint; + /* 0x2B8 */ s16 eyeIndex; + /* 0x2BA */ s16 blinkTimer; + /* 0x2BC */ u16 stateFlags; + /* 0x2BE */ s16 animIndex; + /* 0x2C0 */ s16 csAction; + /* 0x2C2 */ s16 screamTimer; + /* 0x2C4 */ u8 hairstyle; + /* 0x2C8 */ EnGe1ActionFunc actionFunc; } EnGe1; // size = 0x2CC extern const ActorInit En_Ge1_InitVars; 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 b8522c2c6..c05db47fd 100644 --- a/src/overlays/actors/ovl_En_Ge2/z_en_ge2.c +++ b/src/overlays/actors/ovl_En_Ge2/z_en_ge2.c @@ -10,21 +10,21 @@ #define THIS ((EnGe2*)thisx) -void EnGe2_Init(Actor* thisx, GlobalContext* globalCtx); -void EnGe2_Destroy(Actor* thisx, GlobalContext* globalCtx); -void EnGe2_Update(Actor* thisx, GlobalContext* globalCtx); -void EnGe2_Draw(Actor* thisx, GlobalContext* globalCtx); +void EnGe2_Init(Actor* thisx, PlayState* play); +void EnGe2_Destroy(Actor* thisx, PlayState* play); +void EnGe2_Update(Actor* thisx, PlayState* play); +void EnGe2_Draw(Actor* thisx, PlayState* play); -void func_80B8BCEC(EnGe2* this, GlobalContext* globalCtx); -void func_80B8BD38(EnGe2* this, GlobalContext* globalCtx); -void func_80B8BE08(EnGe2* this, GlobalContext* globalCtx); -void func_80B8BF04(EnGe2* this, GlobalContext* globalCtx); -void func_80B8C048(EnGe2* this, GlobalContext* globalCtx); -void func_80B8C0B0(EnGe2* this, GlobalContext* globalCtx); -void func_80B8C45C(EnGe2* this, GlobalContext* globalCtx); -void func_80B8C59C(EnGe2* this, GlobalContext* globalCtx); -void func_80B8C644(EnGe2* this, GlobalContext* globalCtx); -void func_80B8C9B8(EnGe2* this, GlobalContext* globalCtx); +void func_80B8BCEC(EnGe2* this, PlayState* play); +void func_80B8BD38(EnGe2* this, PlayState* play); +void func_80B8BE08(EnGe2* this, PlayState* play); +void func_80B8BF04(EnGe2* this, PlayState* play); +void func_80B8C048(EnGe2* this, PlayState* play); +void func_80B8C0B0(EnGe2* this, PlayState* play); +void func_80B8C45C(EnGe2* this, PlayState* play); +void func_80B8C59C(EnGe2* this, PlayState* play); +void func_80B8C644(EnGe2* this, PlayState* play); +void func_80B8C9B8(EnGe2* this, PlayState* play); #if 0 const ActorInit En_Ge2_InitVars = { diff --git a/src/overlays/actors/ovl_En_Ge2/z_en_ge2.h b/src/overlays/actors/ovl_En_Ge2/z_en_ge2.h index 6555dfc73..f0d97869d 100644 --- a/src/overlays/actors/ovl_En_Ge2/z_en_ge2.h +++ b/src/overlays/actors/ovl_En_Ge2/z_en_ge2.h @@ -5,12 +5,12 @@ struct EnGe2; -typedef void (*EnGe2ActionFunc)(struct EnGe2*, GlobalContext*); +typedef void (*EnGe2ActionFunc)(struct EnGe2*, PlayState*); typedef struct EnGe2 { - /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x1C4]; - /* 0x0308 */ EnGe2ActionFunc actionFunc; + /* 0x000 */ Actor actor; + /* 0x144 */ char unk_144[0x1C4]; + /* 0x308 */ EnGe2ActionFunc actionFunc; } EnGe2; // size = 0x30C extern const ActorInit En_Ge2_InitVars; diff --git a/src/overlays/actors/ovl_En_Ge3/z_en_ge3.c b/src/overlays/actors/ovl_En_Ge3/z_en_ge3.c index 593c57a5a..50e4ed613 100644 --- a/src/overlays/actors/ovl_En_Ge3/z_en_ge3.c +++ b/src/overlays/actors/ovl_En_Ge3/z_en_ge3.c @@ -10,10 +10,10 @@ #define THIS ((EnGe3*)thisx) -void EnGe3_Init(Actor* thisx, GlobalContext* globalCtx); -void EnGe3_Destroy(Actor* thisx, GlobalContext* globalCtx); -void EnGe3_Update(Actor* thisx, GlobalContext* globalCtx); -void EnGe3_Draw(Actor* thisx, GlobalContext* globalCtx); +void EnGe3_Init(Actor* thisx, PlayState* play); +void EnGe3_Destroy(Actor* thisx, PlayState* play); +void EnGe3_Update(Actor* thisx, PlayState* play); +void EnGe3_Draw(Actor* thisx, PlayState* play); #if 0 const ActorInit En_Ge3_InitVars = { diff --git a/src/overlays/actors/ovl_En_Ge3/z_en_ge3.h b/src/overlays/actors/ovl_En_Ge3/z_en_ge3.h index 9ffb271d1..10912aae0 100644 --- a/src/overlays/actors/ovl_En_Ge3/z_en_ge3.h +++ b/src/overlays/actors/ovl_En_Ge3/z_en_ge3.h @@ -5,12 +5,12 @@ struct EnGe3; -typedef void (*EnGe3ActionFunc)(struct EnGe3*, GlobalContext*); +typedef void (*EnGe3ActionFunc)(struct EnGe3*, PlayState*); typedef struct EnGe3 { - /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x1D8]; - /* 0x031C */ EnGe3ActionFunc actionFunc; + /* 0x000 */ Actor actor; + /* 0x144 */ char unk_144[0x1D8]; + /* 0x31C */ EnGe3ActionFunc actionFunc; } EnGe3; // size = 0x320 extern const ActorInit En_Ge3_InitVars; diff --git a/src/overlays/actors/ovl_En_Geg/z_en_geg.c b/src/overlays/actors/ovl_En_Geg/z_en_geg.c index d022058dd..1766b8e32 100644 --- a/src/overlays/actors/ovl_En_Geg/z_en_geg.c +++ b/src/overlays/actors/ovl_En_Geg/z_en_geg.c @@ -6,6 +6,7 @@ #include "z_en_geg.h" #include "overlays/actors/ovl_En_Bom/z_en_bom.h" +#include "overlays/effects/ovl_Effect_Ss_Hahen/z_eff_ss_hahen.h" #include "objects/object_oF1d_map/object_oF1d_map.h" #include "objects/object_taisou/object_taisou.h" #include "objects/object_hakugin_demo/object_hakugin_demo.h" @@ -15,26 +16,26 @@ #define THIS ((EnGeg*)thisx) -void EnGeg_Init(Actor* thisx, GlobalContext* globalCtx); -void EnGeg_Destroy(Actor* thisx, GlobalContext* globalCtx); -void EnGeg_Update(Actor* thisx, GlobalContext* globalCtx); -void EnGeg_Draw(Actor* thisx, GlobalContext* globalCtx); +void EnGeg_Init(Actor* thisx, PlayState* play); +void EnGeg_Destroy(Actor* thisx, PlayState* play); +void EnGeg_Update(Actor* thisx, PlayState* play); +void EnGeg_Draw(Actor* thisx, PlayState* play); -void func_80BB217C(EnGeg* this, GlobalContext* globalCtx); -void func_80BB221C(EnGeg* this, GlobalContext* globalCtx); -void func_80BB2520(EnGeg* this, GlobalContext* globalCtx); -void func_80BB26EC(EnGeg* this, GlobalContext* globalCtx); -void func_80BB27D4(EnGeg* this, GlobalContext* globalCtx); -void func_80BB2944(EnGeg* this, GlobalContext* globalCtx); -void func_80BB2A54(EnGeg* this, GlobalContext* globalCtx); -void func_80BB2B1C(EnGeg* this, GlobalContext* globalCtx); -void func_80BB2E00(EnGeg* this, GlobalContext* globalCtx); -void func_80BB2F7C(EnGeg* this, GlobalContext* globalCtx); -void func_80BB30B4(EnGeg* this, GlobalContext* globalCtx); -void func_80BB31B8(EnGeg* this, GlobalContext* globalCtx); -void func_80BB32AC(EnGeg* this, GlobalContext* globalCtx); -void func_80BB3318(EnGeg* this, GlobalContext* globalCtx); -void func_80BB347C(EnGeg* this, GlobalContext* globalCtx); +void func_80BB217C(EnGeg* this, PlayState* play); +void func_80BB221C(EnGeg* this, PlayState* play); +void func_80BB2520(EnGeg* this, PlayState* play); +void func_80BB26EC(EnGeg* this, PlayState* play); +void func_80BB27D4(EnGeg* this, PlayState* play); +void func_80BB2944(EnGeg* this, PlayState* play); +void func_80BB2A54(EnGeg* this, PlayState* play); +void func_80BB2B1C(EnGeg* this, PlayState* play); +void func_80BB2E00(EnGeg* this, PlayState* play); +void func_80BB2F7C(EnGeg* this, PlayState* play); +void func_80BB30B4(EnGeg* this, PlayState* play); +void func_80BB31B8(EnGeg* this, PlayState* play); +void func_80BB32AC(EnGeg* this, PlayState* play); +void func_80BB3318(EnGeg* this, PlayState* play); +void func_80BB347C(EnGeg* this, PlayState* play); const ActorInit En_Geg_InitVars = { ACTOR_EN_GEG, @@ -125,15 +126,15 @@ static DamageTable sDamageTable = { /* Powder Keg */ DMG_ENTRY(1, 0x0), }; -static AnimationInfoS sAnimations[] = { - { &object_oF1d_map_Anim_011D98, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, - { &object_oF1d_map_Anim_011D98, 1.0f, 0, -1, ANIMMODE_LOOP, -4 }, - { &object_oF1d_map_Anim_012DE0, 2.0f, 0, -1, ANIMMODE_ONCE, 0 }, - { &object_oF1d_map_Anim_012DE0, 2.0f, 0, -1, ANIMMODE_ONCE, -4 }, - { &object_oF1d_map_Anim_012DE0, -2.0f, 0, -1, ANIMMODE_ONCE, -4 }, - { &object_oF1d_map_Anim_003E28, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, - { &object_oF1d_map_Anim_003E28, 1.0f, 0, -1, ANIMMODE_LOOP, -4 }, - { &object_oF1d_map_Anim_0039D8, 1.0f, 0, -1, ANIMMODE_ONCE, -4 }, +static AnimationInfoS sAnimationInfo[] = { + { &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 }, @@ -142,11 +143,11 @@ static AnimationInfoS sAnimations[] = { { &object_taisou_Anim_002C48, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, { &object_taisou_Anim_0031D8, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, { &object_taisou_Anim_005790, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, - { &object_oF1d_map_Anim_003650, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, + { &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 }, - { &object_oF1d_map_Anim_0135E8, 1.0f, 0, -1, ANIMMODE_ONCE, 0 }, - { &object_oF1d_map_Anim_014CE0, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, + { &gGoronShiveringSurprisedAnim, 1.0f, 0, -1, ANIMMODE_ONCE, 0 }, + { &gGoronStandingIdleAnim, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, }; u16 func_80BB16D0(EnGeg* this) { @@ -189,7 +190,7 @@ u16 func_80BB16D0(EnGeg* this) { return 0; } -void func_80BB178C(EnGeg* this, GlobalContext* globalCtx) { +void func_80BB178C(EnGeg* this, PlayState* play) { Vec3f sp34 = this->actor.world.pos; Collider* collider; @@ -215,8 +216,8 @@ void func_80BB178C(EnGeg* this, GlobalContext* globalCtx) { } if (collider != NULL) { - CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, collider); - Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 30.0f, 12.0f, 0.0f, 5); + CollisionCheck_SetOC(play, &play->colChkCtx, collider); + Actor_UpdateBgCheckInfo(play, &this->actor, 30.0f, 12.0f, 0.0f, 5); } } @@ -237,8 +238,8 @@ s32 func_80BB18FC(EnGeg* this, Actor* actor) { return false; } -Vec3f* func_80BB19C0(Vec3f* arg0, EnGeg* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); +Vec3f* func_80BB19C0(Vec3f* arg0, EnGeg* this, PlayState* play) { + Player* player = GET_PLAYER(play); Vec3f sp40; Vec3f sp34; s16 sp32 = player->actor.world.rot.y + 0x4000; @@ -267,9 +268,9 @@ Vec3f* func_80BB19C0(Vec3f* arg0, EnGeg* this, GlobalContext* globalCtx) { return arg0; } -u8 func_80BB1B14(EnGeg* this, GlobalContext* globalCtx) { +u8 func_80BB1B14(EnGeg* this, PlayState* play) { Actor* explosive; - Actor* mm = SubS_FindActor(globalCtx, NULL, ACTORCAT_ITEMACTION, ACTOR_EN_MM); + Actor* mm = SubS_FindActor(play, NULL, ACTORCAT_ITEMACTION, ACTOR_EN_MM); if (mm != NULL) { this->unk_4B0 = Math_Vec3f_Yaw(&this->actor.world.pos, &mm->world.pos); @@ -278,7 +279,7 @@ u8 func_80BB1B14(EnGeg* this, GlobalContext* globalCtx) { } } - explosive = globalCtx->actorCtx.actorLists[ACTORCAT_EXPLOSIVES].first; + explosive = play->actorCtx.actorLists[ACTORCAT_EXPLOSIVES].first; while (explosive != NULL) { if ((explosive->id == ACTOR_EN_BOM) && func_80BB18FC(this, explosive)) { @@ -337,8 +338,8 @@ void func_80BB1D04(EnGeg* this) { this->actor.focus.rot.z = this->actor.world.rot.z; } -s32 func_80BB1D64(EnGeg* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); +s32 func_80BB1D64(EnGeg* this, PlayState* play) { + Player* player = GET_PLAYER(play); Vec3f sp40; Vec3f sp34; s16 yaw = (this->actor.yawTowardsPlayer - this->unk_46E) - this->actor.shape.rot.y; @@ -371,17 +372,17 @@ s32 func_80BB1D64(EnGeg* this, GlobalContext* globalCtx) { return true; } -void func_80BB1FCC(EnGeg* this, GlobalContext* globalCtx) { - gSegments[6] = PHYSICAL_TO_VIRTUAL2(globalCtx->objectCtx.status[this->unk_248].segment); +void func_80BB1FCC(EnGeg* this, PlayState* play) { + gSegments[6] = VIRTUAL_TO_PHYSICAL(play->objectCtx.status[this->unk_248].segment); SkelAnime_Update(&this->skelAnime); } -void func_80BB2020(EnGeg* this, GlobalContext* globalCtx) { - gSegments[6] = PHYSICAL_TO_VIRTUAL2(globalCtx->objectCtx.status[this->unk_248].segment); - SubS_ChangeAnimationByInfoS(&this->skelAnime, sAnimations, this->unk_4AC); +void func_80BB2020(EnGeg* this, PlayState* play) { + gSegments[6] = VIRTUAL_TO_PHYSICAL(play->objectCtx.status[this->unk_248].segment); + SubS_ChangeAnimationByInfoS(&this->skelAnime, sAnimationInfo, this->unk_4AC); } -s32 func_80BB2088(EnGeg* this, GlobalContext* globalCtx) { +s32 func_80BB2088(EnGeg* this, PlayState* play) { if (DECR(this->unk_242) != 0) { this->unk_468 = 0; this->unk_46A = 0; @@ -394,7 +395,7 @@ s32 func_80BB2088(EnGeg* this, GlobalContext* globalCtx) { if (Actor_IsFacingAndNearPlayer(&this->actor, 300.0f, 0x7FF8) && ((this->unk_4AC == 5) || ((this->unk_4AC == 13) && (this->unk_496 == 0xD69)))) { this->unk_230 |= 2; - func_80BB1D64(this, globalCtx); + func_80BB1D64(this, play); } else { if (this->unk_230 & 2) { this->unk_242 = 20; @@ -409,10 +410,10 @@ s32 func_80BB2088(EnGeg* this, GlobalContext* globalCtx) { return true; } -void func_80BB217C(EnGeg* this, GlobalContext* globalCtx) { - if (Object_IsLoaded(&globalCtx->objectCtx, this->unk_248)) { +void func_80BB217C(EnGeg* this, PlayState* play) { + if (Object_IsLoaded(&play->objectCtx, this->unk_248)) { this->unk_4AC = 5; - func_80BB2020(this, globalCtx); + func_80BB2020(this, play); Actor_SetScale(&this->actor, 0.01f); this->unk_230 = 0; this->actor.shape.shadowScale = 20.0f; @@ -423,12 +424,12 @@ void func_80BB217C(EnGeg* this, GlobalContext* globalCtx) { } } -void func_80BB221C(EnGeg* this, GlobalContext* globalCtx) { - u8 sp27 = func_80BB1B14(this, globalCtx); +void func_80BB221C(EnGeg* this, PlayState* play) { + u8 sp27 = func_80BB1B14(this, play); if (sp27 != 0) { this->unk_230 &= ~8; - if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state) && (this->unk_230 & 4)) { + if (Actor_ProcessTalkRequest(&this->actor, &play->state) && (this->unk_230 & 4)) { if (sp27 == 1) { this->unk_496 = 0xD66; this->unk_49A = this->unk_49C[3]; @@ -442,43 +443,43 @@ void func_80BB221C(EnGeg* this, GlobalContext* globalCtx) { this->unk_49A = this->unk_49C[2]; this->unk_230 &= ~4; } - Message_StartTextbox(globalCtx, this->unk_496, &this->actor); + Message_StartTextbox(play, this->unk_496, &this->actor); this->actionFunc = func_80BB2520; this->actor.flags &= ~ACTOR_FLAG_10000; } else if (this->actor.xzDistToPlayer < 300.0f) { this->unk_230 |= 4; this->actor.flags |= ACTOR_FLAG_10000; - func_800B8614(&this->actor, globalCtx, 300.0f); + func_800B8614(&this->actor, play, 300.0f); } } else { this->unk_230 &= ~4; if (gSaveContext.save.weekEventReg[35] & 0x40) { - if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state) && (this->unk_230 & 8)) { + if (Actor_ProcessTalkRequest(&this->actor, &play->state) && (this->unk_230 & 8)) { this->unk_496 = 0xD62; - Message_StartTextbox(globalCtx, this->unk_496, &this->actor); + Message_StartTextbox(play, this->unk_496, &this->actor); this->unk_230 &= ~8; this->actionFunc = func_80BB27D4; } else if ((this->actor.xzDistToPlayer < 300.0f) && this->actor.isTargeted) { - func_800B8614(&this->actor, globalCtx, 300.0f); + func_800B8614(&this->actor, play, 300.0f); this->unk_230 |= 8; } - } else if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state) && (this->unk_230 & 8)) { + } else if (Actor_ProcessTalkRequest(&this->actor, &play->state) && (this->unk_230 & 8)) { gSaveContext.save.weekEventReg[35] |= 0x40; this->unk_496 = 0xD5E; this->unk_49A = this->unk_49C[0]; - Message_StartTextbox(globalCtx, this->unk_496, &this->actor); + Message_StartTextbox(play, this->unk_496, &this->actor); this->actionFunc = func_80BB2520; this->unk_230 &= ~8; this->actor.flags &= ~ACTOR_FLAG_10000; } else if (this->actor.xzDistToPlayer < 300.0f) { this->actor.flags |= ACTOR_FLAG_10000; - func_800B8614(&this->actor, globalCtx, 300.0f); + func_800B8614(&this->actor, play, 300.0f); this->unk_230 |= 8; } } } -void func_80BB2520(EnGeg* this, GlobalContext* globalCtx) { +void func_80BB2520(EnGeg* this, PlayState* play) { if (this->unk_230 & 0x10) { ActorCutscene_Stop(this->unk_498); this->unk_230 &= ~0x10; @@ -506,10 +507,10 @@ void func_80BB2520(EnGeg* this, GlobalContext* globalCtx) { break; case 0xD66: - this->unk_248 = Object_GetIndex(&globalCtx->objectCtx, OBJECT_OF1D_MAP); + this->unk_248 = Object_GetIndex(&play->objectCtx, OBJECT_OF1D_MAP); if (this->unk_248 >= 0) { this->unk_4AC = 19; - func_80BB2020(this, globalCtx); + func_80BB2020(this, play); } this->unk_230 |= 0x20; this->actionFunc = func_80BB2944; @@ -524,10 +525,10 @@ void func_80BB2520(EnGeg* this, GlobalContext* globalCtx) { case 0xD72: case 0xD75: case 0xD8B: - this->unk_248 = Object_GetIndex(&globalCtx->objectCtx, OBJECT_OF1D_MAP); + this->unk_248 = Object_GetIndex(&play->objectCtx, OBJECT_OF1D_MAP); if (this->unk_248 >= 0) { this->unk_4AC = 4; - func_80BB2020(this, globalCtx); + func_80BB2020(this, play); } this->actionFunc = func_80BB2E00; break; @@ -541,8 +542,8 @@ void func_80BB2520(EnGeg* this, GlobalContext* globalCtx) { } } -void func_80BB26EC(EnGeg* this, GlobalContext* globalCtx) { - if ((Message_GetState(&globalCtx->msgCtx) == 5) && Message_ShouldAdvance(globalCtx)) { +void func_80BB26EC(EnGeg* this, PlayState* play) { + if ((Message_GetState(&play->msgCtx) == TEXT_STATE_5) && Message_ShouldAdvance(play)) { switch (this->unk_496) { case 0xD5E: this->unk_49A = this->unk_49C[1]; @@ -551,47 +552,47 @@ void func_80BB26EC(EnGeg* this, GlobalContext* globalCtx) { case 0xD61: ActorCutscene_Stop(this->unk_498); - globalCtx->msgCtx.msgMode = 0x43; - globalCtx->msgCtx.unk12023 = 4; + play->msgCtx.msgMode = 0x43; + play->msgCtx.stateTimer = 4; this->unk_230 &= ~0x10; this->actionFunc = func_80BB221C; return; } this->unk_496 = func_80BB16D0(this); - Message_StartTextbox(globalCtx, this->unk_496, &this->actor); + Message_StartTextbox(play, this->unk_496, &this->actor); } } -void func_80BB27D4(EnGeg* this, GlobalContext* globalCtx) { - if ((Message_GetState(&globalCtx->msgCtx) == 5) && Message_ShouldAdvance(globalCtx)) { +void func_80BB27D4(EnGeg* this, PlayState* play) { + if ((Message_GetState(&play->msgCtx) == TEXT_STATE_5) && Message_ShouldAdvance(play)) { switch (this->unk_496) { case 0xD63: - globalCtx->msgCtx.msgMode = 0x43; - globalCtx->msgCtx.unk12023 = 4; + play->msgCtx.msgMode = 0x43; + play->msgCtx.stateTimer = 4; this->actionFunc = func_80BB221C; break; case 0xD69: this->unk_49A = this->unk_49C[6]; - globalCtx->msgCtx.msgMode = 0x43; - globalCtx->msgCtx.unk12023 = 4; + play->msgCtx.msgMode = 0x43; + play->msgCtx.stateTimer = 4; this->actionFunc = func_80BB2520; break; case 0xD6D: case 0xD6F: case 0xD8A: - globalCtx->msgCtx.msgMode = 0x43; - globalCtx->msgCtx.unk12023 = 4; + play->msgCtx.msgMode = 0x43; + play->msgCtx.stateTimer = 4; this->actionFunc = func_80BB31B8; break; case 0xD72: case 0xD75: case 0xD8B: - globalCtx->msgCtx.msgMode = 0x43; - globalCtx->msgCtx.unk12023 = 4; + play->msgCtx.msgMode = 0x43; + play->msgCtx.stateTimer = 4; this->unk_230 &= ~0x10; this->unk_49A = this->unk_49C[7]; this->actionFunc = func_80BB2520; @@ -599,52 +600,52 @@ void func_80BB27D4(EnGeg* this, GlobalContext* globalCtx) { default: this->unk_496 = func_80BB16D0(this); - Message_StartTextbox(globalCtx, this->unk_496, &this->actor); + Message_StartTextbox(play, this->unk_496, &this->actor); break; } } } -void func_80BB2944(EnGeg* this, GlobalContext* globalCtx) { - u8 sp27 = Message_GetState(&globalCtx->msgCtx); +void func_80BB2944(EnGeg* this, PlayState* play) { + u8 talkState = Message_GetState(&play->msgCtx); s16 curFrame = this->skelAnime.curFrame; - s16 lastFrame = Animation_GetLastFrame(sAnimations[this->unk_4AC].animation); + s16 lastFrame = Animation_GetLastFrame(sAnimationInfo[this->unk_4AC].animation); if (this->unk_4AC == 19) { if (curFrame == lastFrame) { this->unk_4AC = 6; - func_80BB2020(this, globalCtx); + func_80BB2020(this, play); } - } else if ((sp27 == 5) && Message_ShouldAdvance(globalCtx)) { + } else if ((talkState == TEXT_STATE_5) && Message_ShouldAdvance(play)) { if (this->unk_496 == 0xD67) { - globalCtx->msgCtx.msgMode = 0x43; - globalCtx->msgCtx.unk12023 = 4; + play->msgCtx.msgMode = 0x43; + play->msgCtx.stateTimer = 4; this->unk_49A = this->unk_49C[4]; this->actionFunc = func_80BB2520; } else { this->unk_496 = func_80BB16D0(this); - func_80151938(globalCtx, this->unk_496); + func_80151938(play, this->unk_496); } } } -void func_80BB2A54(EnGeg* this, GlobalContext* globalCtx) { - if ((Message_GetState(&globalCtx->msgCtx) == 5) && Message_ShouldAdvance(globalCtx)) { +void func_80BB2A54(EnGeg* this, PlayState* play) { + if ((Message_GetState(&play->msgCtx) == TEXT_STATE_5) && Message_ShouldAdvance(play)) { if (this->unk_496 == 0xD65) { ActorCutscene_Stop(this->unk_498); this->unk_230 &= ~0x10; this->unk_244 = 65; - globalCtx->msgCtx.msgMode = 0x43; - globalCtx->msgCtx.unk12023 = 4; + play->msgCtx.msgMode = 0x43; + play->msgCtx.stateTimer = 4; this->actionFunc = func_80BB347C; } else { this->unk_496 = func_80BB16D0(this); - Message_StartTextbox(globalCtx, this->unk_496, &this->actor); + Message_StartTextbox(play, this->unk_496, &this->actor); } } } -void func_80BB2B1C(EnGeg* this, GlobalContext* globalCtx) { +void func_80BB2B1C(EnGeg* this, PlayState* play) { Vec3f sp74; f32 temp_f20; s16 i; @@ -662,11 +663,11 @@ void func_80BB2B1C(EnGeg* this, GlobalContext* globalCtx) { this->unk_230 |= 0x10; ActorCutscene_StartAndSetFlag(this->unk_498, &this->actor); this->unk_496 = 0xD68; - func_80151938(globalCtx, this->unk_496); - this->unk_248 = Object_GetIndex(&globalCtx->objectCtx, OBJECT_TAISOU); + func_80151938(play, this->unk_496); + this->unk_248 = Object_GetIndex(&play->objectCtx, OBJECT_TAISOU); if (this->unk_248 >= 0) { this->unk_4AC = 13; - func_80BB2020(this, globalCtx); + func_80BB2020(this, play); } this->actionFunc = func_80BB27D4; } else { @@ -692,19 +693,19 @@ void func_80BB2B1C(EnGeg* this, GlobalContext* globalCtx) { this->unk_4C0[i].x *= temp_f20; this->unk_4C0[i].y *= temp_f20; this->unk_4C0[i].z *= temp_f20; - EffectSsHahen_Spawn(globalCtx, &this->unk_4B4, &this->unk_4C0[i], &sp74, 1, sp68, 1, 15, - gameplay_keep_DL_06AB30); + EffectSsHahen_Spawn(play, &this->unk_4B4, &this->unk_4C0[i], &sp74, HAHEN_SMALL, sp68, GAMEPLAY_KEEP, + 15, gameplay_keep_DL_06AB30); } } this->unk_4E0--; } - func_8019F570(&this->actor.projectedPos, 1); + AudioSfx_LowerSfxSettingsReverb(&this->actor.projectedPos, true); func_8019F4AC(&this->actor.projectedPos, NA_SE_EN_GOLON_SIRLOIN_EAT - SFX_FLAG); } -void func_80BB2E00(EnGeg* this, GlobalContext* globalCtx) { +void func_80BB2E00(EnGeg* this, PlayState* play) { s16 sp2E = this->skelAnime.curFrame; - s16 sp2C = Animation_GetLastFrame(sAnimations[this->unk_4AC].animation); + s16 sp2C = Animation_GetLastFrame(sAnimationInfo[this->unk_4AC].animation); if (this->unk_4AC == 2) { Math_SmoothStepToS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer, 5, 0x1000, 0x100); @@ -712,7 +713,7 @@ void func_80BB2E00(EnGeg* this, GlobalContext* globalCtx) { if (sp2E == sp2C) { ActorCutscene_Stop(this->unk_498); this->unk_4AC = 20; - func_80BB2020(this, globalCtx); + func_80BB2020(this, play); this->actionFunc = func_80BB30B4; } else if (Animation_OnFrame(&this->skelAnime, 24.0f)) { Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_GOLON_STAND_IMT); @@ -722,7 +723,7 @@ void func_80BB2E00(EnGeg* this, GlobalContext* globalCtx) { this->unk_230 |= 1; this->actor.shape.yOffset = 14.0f; if (this->unk_496 == 0xD69) { - func_80BB19C0(&this->unk_4E4, this, globalCtx); + func_80BB19C0(&this->unk_4E4, this, play); this->actionFunc = func_80BB2F7C; } else { this->actionFunc = func_80BB3318; @@ -733,7 +734,7 @@ void func_80BB2E00(EnGeg* this, GlobalContext* globalCtx) { } } -void func_80BB2F7C(EnGeg* this, GlobalContext* globalCtx) { +void func_80BB2F7C(EnGeg* this, PlayState* play) { Math_SmoothStepToS(&this->actor.world.rot.y, Math_Vec3f_Yaw(&this->actor.world.pos, &this->unk_4E4), 4, 1000, 1); this->actor.shape.rot.y = this->actor.world.rot.y; @@ -743,7 +744,7 @@ void func_80BB2F7C(EnGeg* this, GlobalContext* globalCtx) { this->actor.speedXZ = 0.0f; this->unk_230 &= ~1; this->actor.shape.yOffset = 0.0f; - func_80BB2020(this, globalCtx); + func_80BB2020(this, play); this->actionFunc = func_80BB2E00; } else { this->actor.speedXZ = 5.0f; @@ -760,31 +761,31 @@ void func_80BB2F7C(EnGeg* this, GlobalContext* globalCtx) { } } -void func_80BB30B4(EnGeg* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); +void func_80BB30B4(EnGeg* this, PlayState* play) { + Player* player = GET_PLAYER(play); - if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { + if (Actor_ProcessTalkRequest(&this->actor, &play->state)) { if (player->transformation == PLAYER_FORM_GORON) { this->unk_496 = 0xD6A; - } else if (Player_GetMask(globalCtx) == PLAYER_MASK_DON_GERO) { + } else if (Player_GetMask(play) == PLAYER_MASK_DON_GERO) { this->unk_496 = 0xD89; } else { this->unk_496 = 0xD6E; } - Message_StartTextbox(globalCtx, this->unk_496, &this->actor); + Message_StartTextbox(play, this->unk_496, &this->actor); this->actionFunc = func_80BB27D4; this->actor.flags &= ~ACTOR_FLAG_10000; } else if (this->actor.xzDistToPlayer < 150.0f) { this->actor.flags |= ACTOR_FLAG_10000; - func_800B8614(&this->actor, globalCtx, 150.0f); + func_800B8614(&this->actor, play, 150.0f); } } -void func_80BB31B8(EnGeg* this, GlobalContext* globalCtx) { +void func_80BB31B8(EnGeg* this, PlayState* play) { s32 getItemId = GI_MASK_DON_GERO; if (INV_CONTENT(ITEM_MASK_DON_GERO) == ITEM_MASK_DON_GERO) { - if (Player_GetMask(globalCtx) == PLAYER_MASK_DON_GERO) { + if (Player_GetMask(play) == PLAYER_MASK_DON_GERO) { this->unk_496 = 0xD8B; getItemId = GI_RUPEE_PURPLE; } else { @@ -795,7 +796,7 @@ void func_80BB31B8(EnGeg* this, GlobalContext* globalCtx) { this->unk_496 = 0xD70; } - if (Actor_HasParent(&this->actor, globalCtx)) { + if (Actor_HasParent(&this->actor, play)) { this->actor.parent = NULL; gSaveContext.save.weekEventReg[61] |= 1; if (getItemId == GI_MASK_DON_GERO) { @@ -803,20 +804,20 @@ void func_80BB31B8(EnGeg* this, GlobalContext* globalCtx) { } this->actionFunc = func_80BB32AC; } else { - Actor_PickUp(&this->actor, globalCtx, getItemId, 300.0f, 300.0f); + Actor_PickUp(&this->actor, play, getItemId, 300.0f, 300.0f); } } -void func_80BB32AC(EnGeg* this, GlobalContext* globalCtx) { - if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { - Message_StartTextbox(globalCtx, this->unk_496, &this->actor); +void func_80BB32AC(EnGeg* this, PlayState* play) { + if (Actor_ProcessTalkRequest(&this->actor, &play->state)) { + Message_StartTextbox(play, this->unk_496, &this->actor); this->actionFunc = func_80BB27D4; } else { - func_800B85E0(&this->actor, globalCtx, 400.0f, -1); + func_800B85E0(&this->actor, play, 400.0f, -1); } } -void func_80BB3318(EnGeg* this, GlobalContext* globalCtx) { +void func_80BB3318(EnGeg* this, PlayState* play) { static Vec3f D_80BB4044[] = { { -550.0f, 8.0f, 550.0f }, { 220.0f, 43.0f, 525.0f }, @@ -832,7 +833,7 @@ void func_80BB3318(EnGeg* this, GlobalContext* globalCtx) { this->unk_4D8++; } this->actor.shape.rot.y = this->actor.world.rot.y; - func_800AE930(&globalCtx->colCtx, Effect_GetByIndex(this->unk_4DC), &this->actor.world.pos, 18.0f, + func_800AE930(&play->colCtx, Effect_GetByIndex(this->unk_4DC), &this->actor.world.pos, 18.0f, this->actor.shape.rot.y, this->actor.floorPoly, this->actor.floorBgId); } @@ -847,14 +848,14 @@ void func_80BB3318(EnGeg* this, GlobalContext* globalCtx) { func_800B9010(&this->actor, NA_SE_EN_GOLON_SIRLOIN_ROLL - SFX_FLAG); } -void func_80BB347C(EnGeg* this, GlobalContext* globalCtx) { +void func_80BB347C(EnGeg* this, PlayState* play) { if (DECR(this->unk_244) == 0) { this->unk_244 = 65; this->actionFunc = func_80BB221C; } } -void EnGeg_Init(Actor* thisx, GlobalContext* globalCtx) { +void EnGeg_Init(Actor* thisx, PlayState* play) { s32 pad; EnGeg* this = THIS; s32 pad2; @@ -866,47 +867,47 @@ void EnGeg_Init(Actor* thisx, GlobalContext* globalCtx) { } 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(play, &this->skelAnime, &gGoronSkel, &gGoronUnrollAnim, this->jointTable, this->morphTable, + GORON_LIMB_MAX); - Collider_InitCylinder(globalCtx, &this->colliderCylinder); - Collider_SetCylinder(globalCtx, &this->colliderCylinder, &this->actor, &sCylinderInit); - Collider_InitSphere(globalCtx, &this->colliderSphere); - Collider_SetSphere(globalCtx, &this->colliderSphere, &this->actor, &sSphereInit); + Collider_InitCylinder(play, &this->colliderCylinder); + Collider_SetCylinder(play, &this->colliderCylinder, &this->actor, &sCylinderInit); + Collider_InitSphere(play, &this->colliderSphere); + Collider_SetSphere(play, &this->colliderSphere, &this->actor, &sSphereInit); CollisionCheck_SetInfo2(&this->actor.colChkInfo, &sDamageTable, &sColChkInfoInit); if (this->actor.update != NULL) { - this->unk_248 = Object_GetIndex(&globalCtx->objectCtx, OBJECT_OF1D_MAP); + this->unk_248 = Object_GetIndex(&play->objectCtx, OBJECT_OF1D_MAP); if (this->unk_248 < 0) { Actor_MarkForDeath(&this->actor); } } - Effect_Add(globalCtx, &this->unk_4DC, 4, 0, 0, &sp34); + Effect_Add(play, &this->unk_4DC, 4, 0, 0, &sp34); thisx->draw = NULL; this->unk_4E0 = 100; this->actor.draw = EnGeg_Draw; this->actionFunc = func_80BB217C; } -void EnGeg_Destroy(Actor* thisx, GlobalContext* globalCtx) { +void EnGeg_Destroy(Actor* thisx, PlayState* play) { EnGeg* this = THIS; - Collider_DestroyCylinder(globalCtx, &this->colliderCylinder); - Collider_DestroySphere(globalCtx, &this->colliderSphere); - Effect_Destroy(globalCtx, this->unk_4DC); + Collider_DestroyCylinder(play, &this->colliderCylinder); + Collider_DestroySphere(play, &this->colliderSphere); + Effect_Destroy(play, this->unk_4DC); } -void EnGeg_Update(Actor* thisx, GlobalContext* globalCtx) { +void EnGeg_Update(Actor* thisx, PlayState* play) { EnGeg* this = THIS; - this->actionFunc(this, globalCtx); - func_80BB1FCC(this, globalCtx); - func_80BB2088(this, globalCtx); + this->actionFunc(this, play); + func_80BB1FCC(this, play); + func_80BB2088(this, play); func_80BB1C8C(this); - SubS_FillLimbRotTables(globalCtx, this->unk_238, this->unk_232, ARRAY_COUNT(this->unk_238)); + SubS_FillLimbRotTables(play, this->unk_238, this->unk_232, ARRAY_COUNT(this->unk_238)); func_80BB1D04(this); - func_80BB178C(this, globalCtx); + func_80BB178C(this, play); } s32 func_80BB3728(s16 arg0, s16 arg1, Vec3f* arg2, Vec3s* arg3, s32 arg4, s32 arg5) { @@ -915,9 +916,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) { @@ -938,11 +939,11 @@ s32 func_80BB3728(s16 arg0, s16 arg1, Vec3f* arg2, Vec3s* arg3, s32 arg4, s32 ar return true; } -s32 EnGeg_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, Actor* thisx) { +s32 EnGeg_OverrideLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, Actor* thisx) { return false; } -void EnGeg_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx) { +void EnGeg_PostLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx) { static Vec3f D_80BB407C = { -1500.0f, 1500.0f, 0.0f }; EnGeg* this = THIS; Vec3f sp38 = { 1.0f, 5.0f, -0.5f }; @@ -950,13 +951,13 @@ void EnGeg_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Ve if (limbIndex == 17) { if (!(this->unk_230 & 0x40)) { - func_8012C28C(globalCtx->state.gfxCtx); + func_8012C28C(play->state.gfxCtx); - OPEN_DISPS(globalCtx->state.gfxCtx); + OPEN_DISPS(play->state.gfxCtx); - gSPDisplayList(POLY_OPA_DISP++, object_oF1d_map_DL_004DB0); + gSPDisplayList(POLY_OPA_DISP++, gGoronDonGeroMaskDL); - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->state.gfxCtx); } sp38.x += Rand_Centered(); @@ -967,16 +968,16 @@ 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(); } } -void EnGeg_TransformLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Actor* thisx) { +void EnGeg_TransformLimbDraw(PlayState* play, s32 limbIndex, Actor* thisx) { EnGeg* this = THIS; s32 phi_v0; s32 phi_v1; @@ -998,13 +999,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: @@ -1022,67 +1023,67 @@ 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) { +void func_80BB3BE0(EnGeg* this, PlayState* play) { 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; - OPEN_DISPS(globalCtx->state.gfxCtx); + OPEN_DISPS(play->state.gfxCtx); - func_8012C28C(globalCtx->state.gfxCtx); + func_8012C28C(play->state.gfxCtx); gSPSegment(POLY_OPA_DISP++, 0x08, Lib_SegmentedToVirtual(D_80BB4088[this->unk_23E])); gDPPipeSync(POLY_OPA_DISP++); - SkelAnime_DrawTransformFlexOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, + SkelAnime_DrawTransformFlexOpa(play, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, EnGeg_OverrideLimbDraw, EnGeg_PostLimbDraw, EnGeg_TransformLimbDraw, &this->actor); - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->state.gfxCtx); } -void func_80BB3CB4(EnGeg* this, GlobalContext* globalCtx) { - f32 sp24 = globalCtx->state.frames * this->actor.speedXZ * 1400.0f; +void func_80BB3CB4(EnGeg* this, PlayState* play) { + f32 sp24 = play->state.frames * this->actor.speedXZ * 1400.0f; - OPEN_DISPS(globalCtx->state.gfxCtx); + OPEN_DISPS(play->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); + func_8012C28C(play->state.gfxCtx); + 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); + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_OPA_DISP++, gGoronRolledUpDL); - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->state.gfxCtx); } -void EnGeg_Draw(Actor* thisx, GlobalContext* globalCtx) { +void EnGeg_Draw(Actor* thisx, PlayState* play) { EnGeg* this = THIS; if (this->unk_230 & 1) { - func_80BB3CB4(this, globalCtx); + func_80BB3CB4(this, play); } else { - func_80BB3BE0(this, globalCtx); + func_80BB3BE0(this, play); } } 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 f5e9ad34d..4a20068bd 100644 --- a/src/overlays/actors/ovl_En_Geg/z_en_geg.h +++ b/src/overlays/actors/ovl_En_Geg/z_en_geg.h @@ -5,7 +5,7 @@ struct EnGeg; -typedef void (*EnGegActionFunc)(struct EnGeg*, GlobalContext*); +typedef void (*EnGegActionFunc)(struct EnGeg*, PlayState*); typedef struct EnGeg { /* 0x000 */ Actor actor; 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 3d80cc847..5c4606185 100644 --- a/src/overlays/actors/ovl_En_Gg/z_en_gg.c +++ b/src/overlays/actors/ovl_En_Gg/z_en_gg.c @@ -12,19 +12,19 @@ #define THIS ((EnGg*)thisx) -void EnGg_Init(Actor* thisx, GlobalContext* globalCtx); -void EnGg_Destroy(Actor* thisx, GlobalContext* globalCtx); -void EnGg_Update(Actor* thisx, GlobalContext* globalCtx); -void EnGg_Draw(Actor* thisx, GlobalContext* globalCtx); +void EnGg_Init(Actor* thisx, PlayState* play); +void EnGg_Destroy(Actor* thisx, PlayState* play); +void EnGg_Update(Actor* thisx, PlayState* play); +void EnGg_Draw(Actor* thisx, PlayState* play); -void func_80B352A4(EnGg* this, GlobalContext* globalCtx); -void func_80B35450(EnGg* this, GlobalContext* globalCtx); -void func_80B3556C(EnGg* this, GlobalContext* globalCtx); +void func_80B352A4(EnGg* this, PlayState* play); +void func_80B35450(EnGg* this, PlayState* play); +void func_80B3556C(EnGg* this, PlayState* play); 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); +void func_80B358D8(EnGg* this, PlayState* play); +void func_80B359DC(EnGg* this, PlayState* play); +void func_80B363E8(EnGgStruct* ptr, PlayState* play, Vec3f* arg1, Vec3f* arg2, Vec3f* arg3); +void func_80B364D4(EnGgStruct* ptr, PlayState* play); const ActorInit En_Gg_InitVars = { ACTOR_EN_GG, @@ -95,7 +95,7 @@ static DamageTable sDamageTable = { /* Powder Keg */ DMG_ENTRY(0, 0x0), }; -static AnimationInfo sAnimations[] = { +static AnimationInfo sAnimationInfo[] = { { &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 }, @@ -116,8 +116,8 @@ void func_80B34F70(EnGg* this) { this->actor.focus.rot.z = this->actor.world.rot.z; } -s32 func_80B34FB4(EnGg* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); +s32 func_80B34FB4(EnGg* this, PlayState* play) { + Player* player = GET_PLAYER(play); Vec3f sp40; Vec3f sp34; s16 pitch; @@ -138,13 +138,13 @@ s32 func_80B34FB4(EnGg* this, GlobalContext* globalCtx) { return true; } -void func_80B35108(EnGg* this, GlobalContext* globalCtx) { +void func_80B35108(EnGg* this, PlayState* play) { this->collider.dim.pos.x = this->actor.world.pos.x; this->collider.dim.pos.y = this->actor.world.pos.y; this->collider.dim.pos.z = this->actor.world.pos.z; - CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); - Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 0.0f, 30.0f, 30.0f, 7); + CollisionCheck_SetAC(play, &play->colChkCtx, &this->collider.base); + Actor_UpdateBgCheckInfo(play, &this->actor, 0.0f, 30.0f, 30.0f, 7); } void func_80B351A4(EnGg* this) { @@ -170,46 +170,46 @@ void func_80B35250(EnGg* this) { this->unk_2E4 = 20; this->unk_2E2 = 0; this->unk_2E6 = 0; - Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 0); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, 0); this->actionFunc = func_80B35450; } -void func_80B352A4(EnGg* this, GlobalContext* globalCtx) { +void func_80B352A4(EnGg* this, PlayState* play) { s16 sp26 = this->skelAnime.curFrame; - s16 lastFrame = Animation_GetLastFrame(sAnimations[this->unk_2E6].animation); + s16 lastFrame = Animation_GetLastFrame(sAnimationInfo[this->unk_2E6].animation); if (sp26 == lastFrame) { switch (this->actor.textId) { case 0xCE5: this->unk_2E6 = 1; - Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 1); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, 1); break; case 0xCE6: case 0xCEC: this->unk_2E6 = 0; - Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 0); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, 0); break; case 0xCE8: this->unk_2E6 = 2; - Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 2); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, 2); break; case 0xCE9: this->unk_2E6 = 3; - Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 3); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, 3); break; case 0xCED: case 0xCEE: this->unk_2E6 = 4; - Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 4); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, 4); break; default: this->unk_2E6 = 0; - Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 0); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, 0); break; } gSaveContext.save.weekEventReg[19] |= 0x80; @@ -219,60 +219,60 @@ void func_80B352A4(EnGg* this, GlobalContext* globalCtx) { this->skelAnime.playSpeed = 2.0f; } else { this->unk_2E6 = 4; - Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 4); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, 4); } } } -void func_80B35450(EnGg* this, GlobalContext* globalCtx) { - if ((gSaveContext.save.weekEventReg[91] & 0x10) && (globalCtx->csCtx.state == 0)) { - func_80B359DC(this, globalCtx); +void func_80B35450(EnGg* this, PlayState* play) { + if ((gSaveContext.save.weekEventReg[91] & 0x10) && (play->csCtx.state == 0)) { + func_80B359DC(this, play); } - if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { + if (Actor_ProcessTalkRequest(&this->actor, &play->state)) { if (CHECK_FLAG_ALL(this->actor.flags, ACTOR_FLAG_80)) { - func_800B90F4(globalCtx); + func_800B90F4(play); } 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); + func_800B863C(&this->actor, play); this->actor.textId = 0xCEE; } else if (CHECK_FLAG_ALL(this->actor.flags, ACTOR_FLAG_80)) { - func_800B863C(&this->actor, globalCtx); + func_800B863C(&this->actor, play); this->actor.textId = 0xCE5; } } } -void func_80B3556C(EnGg* this, GlobalContext* globalCtx) { - if ((Message_GetState(&globalCtx->msgCtx) == 5) && Message_ShouldAdvance(globalCtx)) { +void func_80B3556C(EnGg* this, PlayState* play) { + if ((Message_GetState(&play->msgCtx) == TEXT_STATE_5) && Message_ShouldAdvance(play)) { if (this->unk_2E6 == 4) { - globalCtx->msgCtx.msgMode = 0x43; - globalCtx->msgCtx.unk12023 = 4; + play->msgCtx.msgMode = 0x43; + play->msgCtx.stateTimer = 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); + Message_StartTextbox(play, this->actor.textId, &this->actor); this->actionFunc = func_80B352A4; } } } -void func_80B35634(EnGg* this, GlobalContext* globalCtx) { +void func_80B35634(EnGg* this, PlayState* play) { s32 pad; s32 actionIndex; - if (Cutscene_CheckActorAction(globalCtx, 119)) { - actionIndex = Cutscene_GetActorActionIndex(globalCtx, 119); + if (Cutscene_CheckActorAction(play, 119)) { + actionIndex = Cutscene_GetActorActionIndex(play, 119); - if (this->unk_2DB != globalCtx->csCtx.actorActions[actionIndex]->action) { - this->unk_2DB = globalCtx->csCtx.actorActions[actionIndex]->action; + if (this->unk_2DB != play->csCtx.actorActions[actionIndex]->action) { + this->unk_2DB = play->csCtx.actorActions[actionIndex]->action; - switch (globalCtx->csCtx.actorActions[actionIndex]->action) { + switch (play->csCtx.actorActions[actionIndex]->action) { case 1: this->unk_2DA = 0; this->unk_2E6 = 0; @@ -293,7 +293,7 @@ void func_80B35634(EnGg* this, GlobalContext* globalCtx) { this->unk_344.unk_30 = this->unk_2DA = 11; } while (0); this->unk_2E6 = 11; - func_80B364D4(&this->unk_344, globalCtx); + func_80B364D4(&this->unk_344, play); break; case 5: @@ -315,7 +315,7 @@ void func_80B35634(EnGg* this, GlobalContext* globalCtx) { this->unk_344.unk_30 = this->unk_2DA = 14; } while (0); this->unk_2E6 = 14; - func_80B364D4(&this->unk_344, globalCtx); + func_80B364D4(&this->unk_344, play); break; case 8: @@ -326,14 +326,14 @@ void func_80B35634(EnGg* this, GlobalContext* globalCtx) { this->unk_2DA = 0; break; } - Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, this->unk_2DA); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, this->unk_2DA); } if (this->unk_2DA == 14) { - func_80B358D8(this, globalCtx); + func_80B358D8(this, play); } - Cutscene_ActorTranslateAndYaw(&this->actor, globalCtx, actionIndex); + Cutscene_ActorTranslateAndYaw(&this->actor, play, actionIndex); this->actor.shape.yOffset = 0.0f; } else { this->unk_2DB = 99; @@ -364,29 +364,29 @@ void func_80B3584C(EnGg* this) { this->actor.world.rot.y = this->actor.shape.rot.y; } -void func_80B358D8(EnGg* this, GlobalContext* globalCtx) { +void func_80B358D8(EnGg* this, PlayState* play) { s16 sp1E = this->skelAnime.curFrame; - s16 lastFrame = Animation_GetLastFrame(sAnimations[this->unk_2DA].animation); + s16 lastFrame = Animation_GetLastFrame(sAnimationInfo[this->unk_2DA].animation); if ((this->unk_2E6 == 14) && (sp1E == lastFrame)) { this->unk_2E6 = 15; - Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 15); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, 15); } } -void func_80B35968(EnGg* this, GlobalContext* globalCtx) { +void func_80B35968(EnGg* this, PlayState* play) { if (this->unk_344.unk_34 != NULL) { - this->unk_344.unk_34(&this->unk_344, globalCtx); + this->unk_344.unk_34(&this->unk_344, play); } 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); + func_80B363E8(&this->unk_344, play, &this->unk_320, &this->unk_32C, &this->unk_338); } } -void func_80B359DC(EnGg* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); +void func_80B359DC(EnGg* this, PlayState* play) { + Player* player = GET_PLAYER(play); if (this->actor.xzDistToPlayer < 200.0f) { if (this->unk_306 == 0) { @@ -398,8 +398,8 @@ void func_80B359DC(EnGg* this, GlobalContext* globalCtx) { this->unk_306 = 0; } - if ((player->transformation == PLAYER_FORM_HUMAN) && (globalCtx->msgCtx.ocarinaMode == 3) && - (globalCtx->msgCtx.unk1202E == 7)) { + if ((player->transformation == PLAYER_FORM_HUMAN) && (play->msgCtx.ocarinaMode == 3) && + (play->msgCtx.lastPlayedSong == OCARINA_SONG_HEALING)) { if (!(gSaveContext.save.weekEventReg[19] & 0x80)) { gSaveContext.save.weekEventReg[19] |= 0x80; } @@ -423,7 +423,7 @@ void func_80B359DC(EnGg* this, GlobalContext* globalCtx) { } } -void func_80B35B24(EnGgStruct* ptr, GlobalContext* globalCtx) { +void func_80B35B24(EnGgStruct* ptr, PlayState* play) { ptr->unk_34 = NULL; ptr->unk_38 = NULL; ptr->unk_3C = 0; @@ -431,7 +431,7 @@ void func_80B35B24(EnGgStruct* ptr, GlobalContext* globalCtx) { ptr->unk_44 = 0; } -void func_80B35B44(EnGgStruct* ptr, GlobalContext* globalCtx) { +void func_80B35B44(EnGgStruct* ptr, PlayState* play) { if (ptr->unk_30 == 0xE) { ptr->unk_40++; if (ptr->unk_40 > 0x46) { @@ -475,13 +475,13 @@ void func_80B35B44(EnGgStruct* ptr, GlobalContext* globalCtx) { } else { ptr->unk_44++; if (ptr->unk_44 > 0x37) { - func_80B364D4(ptr, globalCtx); + func_80B364D4(ptr, play); } } } } -void func_80B35C84(EnGgStruct* ptr, GlobalContext* globalCtx) { +void func_80B35C84(EnGgStruct* ptr, PlayState* play) { s32 sp74; s32 phi_s7; f32 temp_f22; @@ -507,9 +507,9 @@ void func_80B35C84(EnGgStruct* ptr, GlobalContext* globalCtx) { return; } - OPEN_DISPS(globalCtx->state.gfxCtx); + OPEN_DISPS(play->state.gfxCtx); - Matrix_StatePush(); + Matrix_Push(); for (i = sp74; i < phi_s7; i += temp) { temp_f20 = i * 0.14f; @@ -520,22 +520,22 @@ void func_80B35C84(EnGgStruct* ptr, GlobalContext* globalCtx) { if (1) {} - Matrix_InsertTranslation(temp_f22, temp_f24, temp_f26, MTXMODE_NEW); + 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_InsertMatrix(&globalCtx->billboardMtxF, MTXMODE_APPLY); + func_8012C2DC(play->state.gfxCtx); + Matrix_Mult(&play->billboardMtxF, MTXMODE_APPLY); - gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_XLU_DISP++, gOwlStatueWhiteFlashDL); } - Matrix_StatePop(); + Matrix_Pop(); - Matrix_StatePush(); + Matrix_Push(); for (i = sp74; i < phi_s7; i += temp) { temp_f20 = i * 0.14f; @@ -544,27 +544,27 @@ void func_80B35C84(EnGgStruct* ptr, GlobalContext* globalCtx) { temp_f26 = ptr->unk_0C.z + (ptr->unk_18.z * temp_f20) + (0.5f * ptr->unk_24.z * temp_f20 * temp_f20); temp_f20 = Rand_ZeroOne() * 0.003f; - Matrix_InsertTranslation(temp_f22, temp_f24, temp_f26, MTXMODE_NEW); + Matrix_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_InsertMatrix(&globalCtx->billboardMtxF, MTXMODE_APPLY); + func_8012C2DC(play->state.gfxCtx); + Matrix_Mult(&play->billboardMtxF, MTXMODE_APPLY); - gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_XLU_DISP++, gOwlStatueWhiteFlashDL); } - Matrix_StatePop(); + Matrix_Pop(); gSPMatrix(POLY_XLU_DISP++, &gIdentityMtx, G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->state.gfxCtx); } -void func_80B3610C(EnGgStruct* ptr, GlobalContext* globalCtx) { +void func_80B3610C(EnGgStruct* ptr, PlayState* play) { f32 temp_f20; f32 temp_f24; f32 temp_f26; @@ -581,9 +581,9 @@ void func_80B3610C(EnGgStruct* ptr, GlobalContext* globalCtx) { } if (phi_s4 > 0) { - OPEN_DISPS(globalCtx->state.gfxCtx); + OPEN_DISPS(play->state.gfxCtx); - Matrix_StatePush(); + Matrix_Push(); for (i = 0; i < phi_s4; i++) { if (ptr->unk_48 != 0) { @@ -596,30 +596,29 @@ void func_80B3610C(EnGgStruct* ptr, GlobalContext* globalCtx) { temp_f28 = ptr->unk_0C.z + (ptr->unk_18.z * i) + (0.5f * ptr->unk_24.z * i * i); temp_f20 = Rand_ZeroOne() * 0.003f; - Matrix_InsertTranslation((Rand_Centered() * (100.0f * phi_f22)) + temp_f24, temp_f26, - ((30.0f * phi_f22) * Rand_Centered()) + temp_f28, MTXMODE_NEW); + Matrix_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_InsertMatrix(&globalCtx->billboardMtxF, MTXMODE_APPLY); + func_8012C2DC(play->state.gfxCtx); + Matrix_Mult(&play->billboardMtxF, MTXMODE_APPLY); - gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), - G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_XLU_DISP++, gOwlStatueWhiteFlashDL); } - Matrix_StatePop(); + Matrix_Pop(); gSPMatrix(POLY_XLU_DISP++, &gIdentityMtx, G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->state.gfxCtx); } } -void func_80B363E8(EnGgStruct* ptr, GlobalContext* globalCtx, Vec3f* arg1, Vec3f* arg2, Vec3f* arg3) { +void func_80B363E8(EnGgStruct* ptr, PlayState* play, Vec3f* arg1, Vec3f* arg2, Vec3f* arg3) { ptr->unk_34 = func_80B35B44; ptr->unk_00 = *arg1; ptr->unk_0C = *arg1; @@ -637,13 +636,13 @@ void func_80B363E8(EnGgStruct* ptr, GlobalContext* globalCtx, Vec3f* arg1, Vec3f } } -void func_80B364D4(EnGgStruct* ptr, GlobalContext* globalCtx) { +void func_80B364D4(EnGgStruct* ptr, PlayState* play) { ptr->unk_34 = NULL; ptr->unk_38 = NULL; - func_80B35B24(ptr, globalCtx); + func_80B35B24(ptr, play); } -void EnGg_Init(Actor* thisx, GlobalContext* globalCtx) { +void EnGg_Init(Actor* thisx, PlayState* play) { s32 pad; EnGg* this = THIS; @@ -654,11 +653,11 @@ void EnGg_Init(Actor* thisx, GlobalContext* globalCtx) { 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, + SkelAnime_InitFlex(play, &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); + Collider_InitCylinder(play, &this->collider); + Collider_SetCylinder(play, &this->collider, &this->actor, &sCylinderInit); CollisionCheck_SetInfo2(&this->actor.colChkInfo, &sDamageTable, &sColChkInfoInit); gSaveContext.save.weekEventReg[20] &= (u8)~4; @@ -673,17 +672,17 @@ void EnGg_Init(Actor* thisx, GlobalContext* globalCtx) { this->unk_304 = 0; this->unk_30A = 0; this->actor.flags |= ACTOR_FLAG_10; - func_80B35B24(&this->unk_344, globalCtx); + func_80B35B24(&this->unk_344, play); func_80B35250(this); } -void EnGg_Destroy(Actor* thisx, GlobalContext* globalCtx) { +void EnGg_Destroy(Actor* thisx, PlayState* play) { } -void EnGg_Update(Actor* thisx, GlobalContext* globalCtx) { +void EnGg_Update(Actor* thisx, PlayState* play) { EnGg* this = THIS; - if (globalCtx->actorCtx.unk4 == 100) { + if (play->actorCtx.unk4 == 100) { this->actor.flags |= ACTOR_FLAG_80; this->actor.flags |= ACTOR_FLAG_1; } else { @@ -692,21 +691,21 @@ void EnGg_Update(Actor* thisx, GlobalContext* globalCtx) { } if (gSaveContext.save.weekEventReg[19] & 0x80) { - if (globalCtx->csCtx.state == 0) { + if (play->csCtx.state == 0) { this->actor.flags |= ACTOR_FLAG_1; } else { this->actor.flags &= ~ACTOR_FLAG_1; } } - if ((globalCtx->csCtx.state == 0) && + if ((play->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); + func_80B364D4(&this->unk_344, play); } 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); + func_80B35968(this, play); } if (!(gSaveContext.save.weekEventReg[91] & 0x10) && @@ -715,36 +714,36 @@ void EnGg_Update(Actor* thisx, GlobalContext* globalCtx) { gSaveContext.save.weekEventReg[91] |= 0x10; } - this->actionFunc(this, globalCtx); + this->actionFunc(this, play); func_80B34F70(this); - func_80B35108(this, globalCtx); - func_80B34FB4(this, globalCtx); + func_80B35108(this, play); + func_80B34FB4(this, play); Actor_MoveWithoutGravity(&this->actor); SkelAnime_Update(&this->skelAnime); - if (globalCtx->csCtx.state == 0) { + if (play->csCtx.state == 0) { func_80B3584C(this); } else { this->unk_2E8 = 0; } - func_80B35634(this, globalCtx); - func_800E9250(globalCtx, &this->actor, &this->unk_1D8, &this->unk_1DE, this->actor.focus.pos); + func_80B35634(this, play); + Actor_TrackPlayer(play, &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, +s32 EnGg_OverrideLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, Actor* thisx, Gfx** gfx) { EnGg* this = THIS; if (limbIndex == 2) { - Matrix_InsertZRotation_s(this->unk_2E8, MTXMODE_APPLY); + Matrix_RotateZS(this->unk_2E8, MTXMODE_APPLY); } return false; } -void EnGg_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx, Gfx** gfx) { +void EnGg_PostLimbDraw(PlayState* play, 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 }; @@ -764,12 +763,12 @@ void EnGg_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec } if (limbIndex == 4) { - Matrix_MultiplyVector3fByState(&D_80B36DF0, &this->unk_320); - Matrix_StatePush(); - Matrix_RotateY(this->actor.shape.rot.y, MTXMODE_NEW); - Matrix_MultiplyVector3fByState(&sp30, &this->unk_32C); - Matrix_MultiplyVector3fByState(&sp24, &this->unk_338); - Matrix_StatePop(); + 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(); } } @@ -780,34 +779,34 @@ TexturePtr D_80B36DFC[] = { object_gg_Tex_009E60, }; -void EnGg_Draw(Actor* thisx, GlobalContext* globalCtx) { +void EnGg_Draw(Actor* thisx, PlayState* play) { s32 pad; EnGg* this = THIS; - OPEN_DISPS(globalCtx->state.gfxCtx); + OPEN_DISPS(play->state.gfxCtx); if (this->unk_344.unk_38 != 0) { - this->unk_344.unk_38(&this->unk_344, globalCtx); + this->unk_344.unk_38(&this->unk_344, play); } if (gSaveContext.save.weekEventReg[19] & 0x80) { - func_8012C28C(globalCtx->state.gfxCtx); + func_8012C28C(play->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); + POLY_OPA_DISP = + SkelAnime_DrawFlex(play, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, + EnGg_OverrideLimbDraw, EnGg_PostLimbDraw, &this->actor, POLY_OPA_DISP); } else if (CHECK_FLAG_ALL(this->actor.flags, ACTOR_FLAG_80) || (this->unk_308 == 1)) { - func_8012C2DC(globalCtx->state.gfxCtx); + func_8012C2DC(play->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); + POLY_XLU_DISP = + SkelAnime_DrawFlex(play, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, + EnGg_OverrideLimbDraw, EnGg_PostLimbDraw, &this->actor, POLY_XLU_DISP); } - func_8012C2DC(globalCtx->state.gfxCtx); + func_8012C2DC(play->state.gfxCtx); - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->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 eeb83cbbd..421168e99 100644 --- a/src/overlays/actors/ovl_En_Gg/z_en_gg.h +++ b/src/overlays/actors/ovl_En_Gg/z_en_gg.h @@ -6,8 +6,8 @@ struct EnGg; struct EnGgStruct; -typedef void (*EnGgActionFunc)(struct EnGg*, GlobalContext*); -typedef void (*EnGgUnkFunc)(struct EnGgStruct*, GlobalContext*); +typedef void (*EnGgActionFunc)(struct EnGg*, PlayState*); +typedef void (*EnGgUnkFunc)(struct EnGgStruct*, PlayState*); typedef struct EnGgStruct { /* 0x00 */ Vec3f unk_00; @@ -24,37 +24,37 @@ typedef struct EnGgStruct { } EnGgStruct; // size == 0x4C typedef struct EnGg { - /* 0x0000 */ Actor actor; - /* 0x0144 */ ColliderCylinder collider; - /* 0x0190 */ SkelAnime skelAnime; - /* 0x01D4 */ EnGgActionFunc actionFunc; - /* 0x01D8 */ Vec3s unk_1D8; - /* 0x01DE */ Vec3s unk_1DE; - /* 0x01E4 */ Vec3s jointTable[20]; - /* 0x025C */ Vec3s morphTable[20]; - /* 0x02D4 */ UNK_TYPE1 unk_2D4[0x6]; - /* 0x02DA */ u8 unk_2DA; - /* 0x02DB */ u8 unk_2DB; - /* 0x02DC */ s16 unk_2DC; - /* 0x02DE */ UNK_TYPE1 unk2DE[4]; - /* 0x02E2 */ s16 unk_2E2; - /* 0x02E4 */ s16 unk_2E4; - /* 0x02E6 */ s16 unk_2E6; - /* 0x02E8 */ s16 unk_2E8; - /* 0x02EA */ UNK_TYPE1 unk2EA[0x1A]; - /* 0x0304 */ s16 unk_304; - /* 0x0306 */ u8 unk_306; - /* 0x0307 */ u8 unk_307; - /* 0x0308 */ u8 unk_308; - /* 0x0309 */ u8 unk_309; - /* 0x030A */ s16 unk_30A; - /* 0x030C */ UNK_TYPE1 unk30C[4]; - /* 0x0310 */ f32 unk_310; - /* 0x0314 */ UNK_TYPE1 unk314[0xC]; - /* 0x0320 */ Vec3f unk_320; - /* 0x032C */ Vec3f unk_32C; - /* 0x0338 */ Vec3f unk_338; - /* 0x0344 */ EnGgStruct unk_344; + /* 0x000 */ Actor actor; + /* 0x144 */ ColliderCylinder collider; + /* 0x190 */ SkelAnime skelAnime; + /* 0x1D4 */ EnGgActionFunc actionFunc; + /* 0x1D8 */ Vec3s unk_1D8; + /* 0x1DE */ Vec3s unk_1DE; + /* 0x1E4 */ Vec3s jointTable[20]; + /* 0x25C */ Vec3s morphTable[20]; + /* 0x2D4 */ UNK_TYPE1 unk_2D4[0x6]; + /* 0x2DA */ u8 unk_2DA; + /* 0x2DB */ u8 unk_2DB; + /* 0x2DC */ s16 unk_2DC; + /* 0x2DE */ UNK_TYPE1 unk2DE[4]; + /* 0x2E2 */ s16 unk_2E2; + /* 0x2E4 */ s16 unk_2E4; + /* 0x2E6 */ s16 unk_2E6; + /* 0x2E8 */ s16 unk_2E8; + /* 0x2EA */ UNK_TYPE1 unk2EA[0x1A]; + /* 0x304 */ s16 unk_304; + /* 0x306 */ u8 unk_306; + /* 0x307 */ u8 unk_307; + /* 0x308 */ u8 unk_308; + /* 0x309 */ u8 unk_309; + /* 0x30A */ s16 unk_30A; + /* 0x30C */ UNK_TYPE1 unk30C[4]; + /* 0x310 */ f32 unk_310; + /* 0x314 */ UNK_TYPE1 unk314[0xC]; + /* 0x320 */ Vec3f unk_320; + /* 0x32C */ Vec3f unk_32C; + /* 0x338 */ Vec3f unk_338; + /* 0x344 */ EnGgStruct unk_344; } EnGg; // size = 0x390 extern const ActorInit En_Gg_InitVars; diff --git a/src/overlays/actors/ovl_En_Gg2/z_en_gg2.c b/src/overlays/actors/ovl_En_Gg2/z_en_gg2.c index ebe127fcf..9726a693a 100644 --- a/src/overlays/actors/ovl_En_Gg2/z_en_gg2.c +++ b/src/overlays/actors/ovl_En_Gg2/z_en_gg2.c @@ -11,19 +11,19 @@ #define THIS ((EnGg2*)thisx) -void EnGg2_Init(Actor* thisx, GlobalContext* globalCtx); -void EnGg2_Destroy(Actor* thisx, GlobalContext* globalCtx); -void EnGg2_Update(Actor* thisx, GlobalContext* globalCtx); -void EnGg2_Draw(Actor* thisx, GlobalContext* globalCtx); +void EnGg2_Init(Actor* thisx, PlayState* play); +void EnGg2_Destroy(Actor* thisx, PlayState* play); +void EnGg2_Update(Actor* thisx, PlayState* play); +void EnGg2_Draw(Actor* thisx, PlayState* play); -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); +void func_80B3AE60(EnGg2* this, PlayState* play); +void func_80B3AFB0(EnGg2* this, PlayState* play); +void func_80B3B05C(EnGg2* this, PlayState* play); +void func_80B3B0A0(EnGg2* this, PlayState* play); +void func_80B3B120(EnGg2* this, PlayState* play); +void func_80B3B21C(EnGg2* this, PlayState* play); +void func_80B3B294(EnGg2* this, PlayState* play); +void func_80B3B5D4(EnGg2* this, PlayState* play); s32 func_80B3B648(EnGg2* this, Path* path, s32 arg2_); f32 func_80B3B7E4(Path* path, s32 arg1, Vec3f* arg2, Vec3s* arg3); @@ -74,8 +74,8 @@ void func_80B3AC50(EnGg2* this) { this->actor.focus.rot.z = this->actor.world.rot.z; } -s32 func_80B3AC94(EnGg2* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); +s32 func_80B3AC94(EnGg2* this, PlayState* play) { + Player* player = GET_PLAYER(play); Vec3f sp40; Vec3f sp34; s16 pitch; @@ -114,7 +114,7 @@ void func_80B3ADD8(EnGg2* this) { } } -void func_80B3AE60(EnGg2* this, GlobalContext* globalCtx) { +void func_80B3AE60(EnGg2* this, PlayState* play) { s16 curFrame = this->skelAnime.curFrame; s16 lastFrame = Animation_GetLastFrame(D_80B3BF00[this->unk_2EE].animation); @@ -154,33 +154,33 @@ void func_80B3AE60(EnGg2* this, GlobalContext* globalCtx) { } } -void func_80B3AFB0(EnGg2* this, GlobalContext* globalCtx) { - if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { +void func_80B3AFB0(EnGg2* this, PlayState* play) { + if (Actor_ProcessTalkRequest(&this->actor, &play->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); + func_800B863C(&this->actor, play); this->actor.textId = 0xCE4; } } -void func_80B3B05C(EnGg2* this, GlobalContext* globalCtx) { +void func_80B3B05C(EnGg2* this, PlayState* play) { if ((this->actor.xzDistToPlayer < 100.0f) && CHECK_FLAG_ALL(this->actor.flags, ACTOR_FLAG_80)) { this->actionFunc = func_80B3B5D4; } } -void func_80B3B0A0(EnGg2* this, GlobalContext* globalCtx) { - if ((Message_GetState(&globalCtx->msgCtx) == 5) && Message_ShouldAdvance(globalCtx)) { - globalCtx->msgCtx.msgMode = 0x43; - globalCtx->msgCtx.unk12023 = 4; +void func_80B3B0A0(EnGg2* this, PlayState* play) { + if ((Message_GetState(&play->msgCtx) == TEXT_STATE_5) && Message_ShouldAdvance(play)) { + play->msgCtx.msgMode = 0x43; + play->msgCtx.stateTimer = 4; this->unk_2F0 = 0; this->actionFunc = func_80B3B5D4; } } -void func_80B3B120(EnGg2* this, GlobalContext* globalCtx) { +void func_80B3B120(EnGg2* this, PlayState* play) { Vec3s sp30; if (this->unk_1D8 != NULL) { @@ -201,7 +201,7 @@ void func_80B3B120(EnGg2* this, GlobalContext* globalCtx) { } } -void func_80B3B21C(EnGg2* this, GlobalContext* globalCtx) { +void func_80B3B21C(EnGg2* this, PlayState* play) { this->actor.speedXZ = 0.0f; if ((this->actor.xzDistToPlayer < 100.0f) && CHECK_FLAG_ALL(this->actor.flags, ACTOR_FLAG_80)) { this->unk_2E4 = ActorCutscene_GetAdditionalCutscene(this->unk_2E4); @@ -209,19 +209,19 @@ void func_80B3B21C(EnGg2* this, GlobalContext* globalCtx) { } } -void func_80B3B294(EnGg2* this, GlobalContext* globalCtx) { +void func_80B3B294(EnGg2* this, PlayState* play) { Vec3s sp30; if (this->unk_2F1 == 0) { - if (globalCtx->sceneNum == SCENE_11GORONNOSATO) { + if (play->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) { + } else if (play->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) { + } else if (play->sceneNum == SCENE_10YUKIYAMANOMURA) { gSaveContext.save.weekEventReg[20] &= (u8)~4; gSaveContext.save.weekEventReg[20] &= (u8)~8; gSaveContext.save.weekEventReg[20] |= 0x10; @@ -239,15 +239,15 @@ void func_80B3B294(EnGg2* this, GlobalContext* globalCtx) { this->unk_1DC++; } else { this->unk_2F1 = 1; - if (globalCtx->sceneNum == SCENE_11GORONNOSATO) { + if (play->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) { + } else if (play->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) { + } else if (play->sceneNum == SCENE_10YUKIYAMANOMURA) { gSaveContext.save.weekEventReg[20] &= (u8)~4; gSaveContext.save.weekEventReg[20] &= (u8)~8; gSaveContext.save.weekEventReg[20] |= 0x10; @@ -259,7 +259,7 @@ void func_80B3B294(EnGg2* this, GlobalContext* globalCtx) { Math_ApproachF(&this->actor.speedXZ, 5.0f, 0.2f, 1.0f); } -void func_80B3B4B0(EnGg2* this, GlobalContext* globalCtx) { +void func_80B3B4B0(EnGg2* this, PlayState* play) { Vec3f sp64; Color_RGBA8 sp60 = D_80B3C080; Color_RGBA8 sp5C = D_80B3C084; @@ -269,11 +269,11 @@ void func_80B3B4B0(EnGg2* this, GlobalContext* globalCtx) { 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); + EffectSsKirakira_SpawnDispersed(play, &sp64, &D_80B3C088, &D_80B3C094, &sp60, &sp5C, 3000, 40); } } -void func_80B3B5D4(EnGg2* this, GlobalContext* globalCtx) { +void func_80B3B5D4(EnGg2* this, PlayState* play) { if (ActorCutscene_GetCanPlayNext(this->unk_2E4)) { ActorCutscene_StartAndSetUnkLinkFields(this->unk_2E4, &this->actor); this->actionFunc = func_80B3AE60; @@ -351,8 +351,8 @@ void func_80B3B8A4(EnGg2* this) { this->unk_2F6 = this->actor.yawTowardsPlayer - this->actor.shape.rot.y; } -void EnGg2_Init(Actor* thisx, GlobalContext* globalCtx2) { - GlobalContext* globalCtx = globalCtx2; +void EnGg2_Init(Actor* thisx, PlayState* play2) { + PlayState* play = play2; EnGg2* this = THIS; if (INV_CONTENT(ITEM_MASK_GORON) == ITEM_MASK_GORON) { @@ -367,9 +367,9 @@ void EnGg2_Init(Actor* thisx, GlobalContext* globalCtx2) { 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, + SkelAnime_InitFlex(play, &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->unk_1D8 = SubS_GetPathByIndex(play, ENGG2_GET_FC00(&this->actor), 0x3F); this->actor.flags &= ~ACTOR_FLAG_80; this->unk_2F0 = 0; this->unk_2F1 = 0; @@ -380,14 +380,14 @@ void EnGg2_Init(Actor* thisx, GlobalContext* globalCtx2) { this->unk_2EC = 20; this->unk_2EA = 0; - if (globalCtx->sceneNum == SCENE_11GORONNOSATO) { + if (play->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) { + } else if (play->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; @@ -397,7 +397,7 @@ void EnGg2_Init(Actor* thisx, GlobalContext* globalCtx2) { } else { Actor_MarkForDeath(&this->actor); } - } else if (globalCtx->sceneNum == SCENE_10YUKIYAMANOMURA) { + } else if (play->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; @@ -415,13 +415,13 @@ void EnGg2_Init(Actor* thisx, GlobalContext* globalCtx2) { } } -void EnGg2_Destroy(Actor* thisx, GlobalContext* globalCtx) { +void EnGg2_Destroy(Actor* thisx, PlayState* play) { } -void EnGg2_Update(Actor* thisx, GlobalContext* globalCtx) { +void EnGg2_Update(Actor* thisx, PlayState* play) { EnGg2* this = THIS; - if (globalCtx->actorCtx.unk4 == 100) { + if (play->actorCtx.unk4 == 100) { this->actor.flags |= ACTOR_FLAG_80; this->actor.flags |= ACTOR_FLAG_1; if ((this->unk_2EE == 5) && (this->unk_2EE == 7)) { @@ -432,63 +432,62 @@ void EnGg2_Update(Actor* thisx, GlobalContext* globalCtx) { this->actor.flags &= ~ACTOR_FLAG_1; } - this->actionFunc(this, globalCtx); + this->actionFunc(this, play); func_80B3AC50(this); - func_80B3AC94(this, globalCtx); + func_80B3AC94(this, play); Actor_MoveWithoutGravity(&this->actor); SkelAnime_Update(&this->skelAnime); func_80B3B8A4(this); - func_800E9250(globalCtx, &this->actor, &this->unk_1E0, &this->unk_1E6, this->actor.focus.pos); + Actor_TrackPlayer(play, &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); + if ((play->actorCtx.unk4 == 100) && ((play->state.frames % 4) == 0)) { + func_80B3B4B0(this, play); } } func_80B3ADD8(this); } -s32 func_80B3BD44(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, Actor* thisx, - Gfx** gfx) { +s32 func_80B3BD44(PlayState* play, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, Actor* thisx, Gfx** gfx) { EnGg2* this = THIS; if ((this->unk_2EE != 5) && (this->unk_2EE != 7)) { if (limbIndex == 1) { - Matrix_RotateY(this->unk_2F6, MTXMODE_APPLY); + Matrix_RotateYS(this->unk_2F6, MTXMODE_APPLY); } if (limbIndex == 2) { - Matrix_InsertZRotation_s(this->unk_2F4, MTXMODE_APPLY); + Matrix_RotateZS(this->unk_2F4, MTXMODE_APPLY); } } return false; } -void func_80B3BDC0(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx, Gfx** gfx) { +void func_80B3BDC0(PlayState* play, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx, Gfx** gfx) { EnGg2* this = THIS; if (limbIndex == 4) { - Matrix_MultiplyVector3fByState(&D_80B3C0A0, &this->unk_304); + Matrix_MultVec3f(&D_80B3C0A0, &this->unk_304); } } -void EnGg2_Draw(Actor* thisx, GlobalContext* globalCtx) { +void EnGg2_Draw(Actor* thisx, PlayState* play) { EnGg2* this = THIS; - OPEN_DISPS(globalCtx->state.gfxCtx); + OPEN_DISPS(play->state.gfxCtx); - func_8012C2DC(globalCtx->state.gfxCtx); + func_8012C2DC(play->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); + SkelAnime_DrawFlex(play, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, + func_80B3BD44, func_80B3BDC0, &this->actor, POLY_XLU_DISP); } - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->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 0fea44822..21c1f8441 100644 --- a/src/overlays/actors/ovl_En_Gg2/z_en_gg2.h +++ b/src/overlays/actors/ovl_En_Gg2/z_en_gg2.h @@ -5,34 +5,34 @@ struct EnGg2; -typedef void (*EnGg2ActionFunc)(struct EnGg2*, GlobalContext*); +typedef void (*EnGg2ActionFunc)(struct EnGg2*, PlayState*); #define ENGG2_GET_FC00(thisx) (((thisx)->params & 0xFC00) >> 0xA) typedef struct EnGg2 { - /* 0x0000 */ Actor actor; - /* 0x0144 */ UNK_TYPE1 unk144[0x4C]; - /* 0x0190 */ SkelAnime skelAnime; - /* 0x01D4 */ EnGg2ActionFunc actionFunc; - /* 0x01D8 */ Path* unk_1D8; - /* 0x01DC */ s32 unk_1DC; - /* 0x01E0 */ Vec3s unk_1E0; - /* 0x01E6 */ Vec3s unk_1E6; - /* 0x01EC */ Vec3s jointTable[20]; - /* 0x0264 */ Vec3s morphTable[20]; - /* 0x02DC */ UNK_TYPE1 unk2DC[0x8]; - /* 0x02E4 */ s16 unk_2E4; - /* 0x02E6 */ UNK_TYPE1 unk2E6[4]; - /* 0x02EA */ s16 unk_2EA; - /* 0x02EC */ s16 unk_2EC; - /* 0x02EE */ s16 unk_2EE; - /* 0x02F0 */ u8 unk_2F0; - /* 0x02F1 */ u8 unk_2F1; - /* 0x02F2 */ s16 unk_2F2; - /* 0x02F4 */ s16 unk_2F4; - /* 0x02F6 */ s16 unk_2F6; - /* 0x02F8 */ UNK_TYPE1 unk2F8[0xC]; - /* 0x0304 */ Vec3f unk_304; + /* 0x000 */ Actor actor; + /* 0x144 */ UNK_TYPE1 unk144[0x4C]; + /* 0x190 */ SkelAnime skelAnime; + /* 0x1D4 */ EnGg2ActionFunc actionFunc; + /* 0x1D8 */ Path* unk_1D8; + /* 0x1DC */ s32 unk_1DC; + /* 0x1E0 */ Vec3s unk_1E0; + /* 0x1E6 */ Vec3s unk_1E6; + /* 0x1EC */ Vec3s jointTable[20]; + /* 0x264 */ Vec3s morphTable[20]; + /* 0x2DC */ UNK_TYPE1 unk2DC[0x8]; + /* 0x2E4 */ s16 unk_2E4; + /* 0x2E6 */ UNK_TYPE1 unk2E6[4]; + /* 0x2EA */ s16 unk_2EA; + /* 0x2EC */ s16 unk_2EC; + /* 0x2EE */ s16 unk_2EE; + /* 0x2F0 */ u8 unk_2F0; + /* 0x2F1 */ u8 unk_2F1; + /* 0x2F2 */ s16 unk_2F2; + /* 0x2F4 */ s16 unk_2F4; + /* 0x2F6 */ s16 unk_2F6; + /* 0x2F8 */ UNK_TYPE1 unk2F8[0xC]; + /* 0x304 */ Vec3f unk_304; } EnGg2; // size = 0x310 extern const ActorInit En_Gg2_InitVars; diff --git a/src/overlays/actors/ovl_En_Giant/z_en_giant.c b/src/overlays/actors/ovl_En_Giant/z_en_giant.c index 90d945e2a..7021b0e0c 100644 --- a/src/overlays/actors/ovl_En_Giant/z_en_giant.c +++ b/src/overlays/actors/ovl_En_Giant/z_en_giant.c @@ -10,14 +10,14 @@ #define THIS ((EnGiant*)thisx) -void EnGiant_Init(Actor* thisx, GlobalContext* globalCtx); -void EnGiant_Destroy(Actor* thisx, GlobalContext* globalCtx); -void EnGiant_Update(Actor* thisx, GlobalContext* globalCtx); -void EnGiant_Draw(Actor* thisx, GlobalContext* globalCtx); +void EnGiant_Init(Actor* thisx, PlayState* play); +void EnGiant_Destroy(Actor* thisx, PlayState* play); +void EnGiant_Update(Actor* thisx, PlayState* play); +void EnGiant_Draw(Actor* thisx, PlayState* play); -void EnGiant_PerformClockTowerSuccessActions(EnGiant* this, GlobalContext* globalCtx); -void EnGiant_PlayClockTowerFailureAnimation(EnGiant* this, GlobalContext* globalCtx); -void EnGiant_PerformCutsceneActions(EnGiant* this, GlobalContext* globalCtx); +void EnGiant_PerformClockTowerSuccessActions(EnGiant* this, PlayState* play); +void EnGiant_PlayClockTowerFailureAnimation(EnGiant* this, PlayState* play); +void EnGiant_PerformCutsceneActions(EnGiant* this, PlayState* play); #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) @@ -32,23 +32,23 @@ void EnGiant_PerformCutsceneActions(EnGiant* this, GlobalContext* globalCtx); * 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; + /* 0 */ GIANT_ANIM_LOOK_UP_START, + /* 1 */ GIANT_ANIM_LOOK_UP_LOOP, + /* 2 */ GIANT_ANIM_FALLING_OVER, + /* 3 */ GIANT_ANIM_RAISED_ARMS_START, + /* 4 */ GIANT_ANIM_RAISED_ARMS_LOOP, + /* 5 */ GIANT_ANIM_STRUGGLE_START, + /* 6 */ GIANT_ANIM_STRUGGLE_LOOP, + /* 7 */ GIANT_ANIM_IDLE_LOOP, + /* 8 */ GIANT_ANIM_WALKING_LOOP, + /* 9 */ GIANT_ANIM_BIG_CALL_START, + /* 10 */ GIANT_ANIM_BIG_CALL_LOOP, + /* 11 */ GIANT_ANIM_BIG_CALL_END, + /* 12 */ GIANT_ANIM_SMALL_CALL_START, + /* 13 */ GIANT_ANIM_SMALL_CALL_LOOP, + /* 14 */ GIANT_ANIM_SMALL_CALL_END, + /* 15 */ GIANT_ANIM_MAX +} GiantAnimation; /** * Used as values for csAction. The UNKNOWN ones are never used in-game. @@ -91,16 +91,16 @@ static AnimationHeader* sAnimations[] = { &gGiantSmallCallStartAnim, &gGiantSmallCallLoopAnim, &gGiantSmallCallEndAnim, }; -void EnGiant_ChangeAnimation(EnGiant* this, s16 newAnimationId) { - if (newAnimationId >= GIANT_ANIMATION_LOOK_UP_START && newAnimationId < GIANT_ANIMATION_MAX) { - if ((this->animationId == GIANT_ANIMATION_WALKING_LOOP && newAnimationId != GIANT_ANIMATION_WALKING_LOOP) || - (newAnimationId == GIANT_ANIMATION_WALKING_LOOP && this->animationId != GIANT_ANIMATION_WALKING_LOOP)) { - Animation_Change(&this->skelAnime, sAnimations[newAnimationId], 1.0f, 0.0f, - Animation_GetLastFrame(&sAnimations[newAnimationId]->common), 2, 10.0f); +void EnGiant_ChangeAnim(EnGiant* this, s16 animIndex) { + if (animIndex >= GIANT_ANIM_LOOK_UP_START && animIndex < GIANT_ANIM_MAX) { + if (((this->animIndex == GIANT_ANIM_WALKING_LOOP) && (animIndex != GIANT_ANIM_WALKING_LOOP)) || + ((animIndex == GIANT_ANIM_WALKING_LOOP) && (this->animIndex != GIANT_ANIM_WALKING_LOOP))) { + Animation_Change(&this->skelAnime, sAnimations[animIndex], 1.0f, 0.0f, + Animation_GetLastFrame(&sAnimations[animIndex]->common), ANIMMODE_ONCE, 10.0f); } else { - Animation_PlayOnce(&this->skelAnime, sAnimations[newAnimationId]); + Animation_PlayOnce(&this->skelAnime, sAnimations[animIndex]); } - this->animationId = newAnimationId; + this->animIndex = animIndex; } } @@ -143,7 +143,7 @@ s32 EnGiant_IsImprisoned(EnGiant* this) { return false; } -void EnGiant_Init(Actor* thisx, GlobalContext* globalCtx) { +void EnGiant_Init(Actor* thisx, PlayState* play) { EnGiant* this = THIS; s32 type = GIANT_TYPE(thisx); @@ -151,9 +151,9 @@ void EnGiant_Init(Actor* thisx, GlobalContext* globalCtx) { this->actor.uncullZoneScale = 2000.0f; this->actor.uncullZoneDownward = 2400.0f; Actor_SetScale(&this->actor, 0.32f); - SkelAnime_InitFlex(globalCtx, &this->skelAnime, &gGiantSkel, &gGiantLargeStrideAnim, this->jointTable, - this->morphTable, GIANT_LIMB_MAX); - EnGiant_ChangeAnimation(this, GIANT_ANIMATION_IDLE_LOOP); + SkelAnime_InitFlex(play, &this->skelAnime, &gGiantSkel, &gGiantLargeStrideAnim, this->jointTable, this->morphTable, + GIANT_LIMB_MAX); + EnGiant_ChangeAnim(this, GIANT_ANIM_IDLE_LOOP); this->csAction = GIANT_CS_ACTION_NONE; this->actionFunc = EnGiant_PerformCutsceneActions; this->actor.draw = NULL; @@ -193,7 +193,7 @@ void EnGiant_Init(Actor* thisx, GlobalContext* globalCtx) { this->actionFunc = EnGiant_PerformClockTowerSuccessActions; Animation_Change(&this->skelAnime, &gGiantRaisedArmsStartAnim, 0.0f, Animation_GetLastFrame(&gGiantRaisedArmsStartAnim) - 1.0f, - Animation_GetLastFrame(&gGiantRaisedArmsStartAnim), 2, 0.0f); + Animation_GetLastFrame(&gGiantRaisedArmsStartAnim), ANIMMODE_ONCE, 0.0f); this->actor.draw = EnGiant_Draw; this->actor.velocity.y = 0.0f; this->actor.terminalVelocity = 0.0f; @@ -204,7 +204,7 @@ void EnGiant_Init(Actor* thisx, GlobalContext* globalCtx) { Actor_SetScale(&this->actor, 0.32f); this->actionFunc = EnGiant_PlayClockTowerFailureAnimation; Animation_Change(&this->skelAnime, &gGiantStruggleLoopAnim, 1.0f, 0.0f, - Animation_GetLastFrame(&gGiantStruggleStartAnim), 0, 0.0f); + Animation_GetLastFrame(&gGiantStruggleStartAnim), ANIMMODE_LOOP, 0.0f); this->actor.draw = EnGiant_Draw; this->actor.velocity.y = 0.0f; this->actor.terminalVelocity = 0.0f; @@ -237,7 +237,7 @@ void EnGiant_Init(Actor* thisx, GlobalContext* globalCtx) { } } -void EnGiant_Destroy(Actor* thisx, GlobalContext* globalCtx) { +void EnGiant_Destroy(Actor* thisx, PlayState* play) { } /** @@ -246,14 +246,14 @@ void EnGiant_Destroy(Actor* thisx, GlobalContext* globalCtx) { * this function is to play the requested start animation if it has not been * played yet and play the respetive looping animation otherwise. */ -void EnGiant_ChangeToStartOrLoopAnimation(EnGiant* this, s16 requestedAnimationId) { - s16 nextAnimationId = requestedAnimationId + 1; +void EnGiant_ChangeToStartOrLoopAnimation(EnGiant* this, s16 requestedAnimIndex) { + s16 nextAnimIndex = requestedAnimIndex + 1; - if (this->animationId != nextAnimationId) { - if (this->animationId != requestedAnimationId) { - EnGiant_ChangeAnimation(this, requestedAnimationId); + if (this->animIndex != nextAnimIndex) { + if (this->animIndex != requestedAnimIndex) { + EnGiant_ChangeAnim(this, requestedAnimIndex); } else { - EnGiant_ChangeAnimation(this, nextAnimationId); + EnGiant_ChangeAnim(this, nextAnimIndex); } } } @@ -261,51 +261,51 @@ void EnGiant_ChangeToStartOrLoopAnimation(EnGiant* this, s16 requestedAnimationI /** * Immediately switches to the specified animation for this cutscene action. */ -void EnGiant_ChangeAnimationBasedOnCsAction(EnGiant* this) { +void EnGiant_ChangeAnimBasedOnCsAction(EnGiant* this) { switch (this->csAction) { case GIANT_CS_ACTION_IDLE: - EnGiant_ChangeAnimation(this, GIANT_ANIMATION_IDLE_LOOP); + EnGiant_ChangeAnim(this, GIANT_ANIM_IDLE_LOOP); break; case GIANT_CS_ACTION_WALKING: - EnGiant_ChangeAnimation(this, GIANT_ANIMATION_WALKING_LOOP); + EnGiant_ChangeAnim(this, GIANT_ANIM_WALKING_LOOP); break; case GIANT_CS_ACTION_STRUGGLING: - EnGiant_ChangeAnimation(this, GIANT_ANIMATION_STRUGGLE_START); + EnGiant_ChangeAnim(this, GIANT_ANIM_STRUGGLE_START); break; case GIANT_CS_ACTION_FALLING_OVER: - EnGiant_ChangeAnimation(this, GIANT_ANIMATION_FALLING_OVER); + EnGiant_ChangeAnim(this, GIANT_ANIM_FALLING_OVER); break; case GIANT_CS_ACTION_IDLE_FADE_IN: - EnGiant_ChangeAnimation(this, GIANT_ANIMATION_IDLE_LOOP); + EnGiant_ChangeAnim(this, GIANT_ANIM_IDLE_LOOP); this->alpha = 0; break; case GIANT_CS_ACTION_TALKING: - EnGiant_ChangeAnimation(this, GIANT_ANIMATION_BIG_CALL_START); + EnGiant_ChangeAnim(this, GIANT_ANIM_BIG_CALL_START); break; case GIANT_CS_ACTION_DONE_TALKING: - EnGiant_ChangeAnimation(this, GIANT_ANIMATION_BIG_CALL_END); + EnGiant_ChangeAnim(this, GIANT_ANIM_BIG_CALL_END); break; case GIANT_CS_ACTION_TEACHING_OATH_TO_ORDER: - EnGiant_ChangeAnimation(this, GIANT_ANIMATION_SMALL_CALL_START); + EnGiant_ChangeAnim(this, GIANT_ANIM_SMALL_CALL_START); break; case GIANT_CS_ACTION_PLAYER_LEARNED_OATH_TO_ORDER: - EnGiant_ChangeAnimation(this, GIANT_ANIMATION_SMALL_CALL_END); + EnGiant_ChangeAnim(this, GIANT_ANIM_SMALL_CALL_END); break; case GIANT_CS_ACTION_UNKNOWN_12: - EnGiant_ChangeAnimation(this, GIANT_ANIMATION_IDLE_LOOP); + EnGiant_ChangeAnim(this, GIANT_ANIM_IDLE_LOOP); break; case GIANT_CS_ACTION_UNKNOWN_13: - EnGiant_ChangeAnimation(this, GIANT_ANIMATION_WALKING_LOOP); + EnGiant_ChangeAnim(this, GIANT_ANIM_WALKING_LOOP); break; case GIANT_CS_ACTION_UNKNOWN_14: - if (this->animationId != GIANT_ANIMATION_WALKING_LOOP) { - EnGiant_ChangeAnimation(this, GIANT_ANIMATION_WALKING_LOOP); + if (this->animIndex != GIANT_ANIM_WALKING_LOOP) { + EnGiant_ChangeAnim(this, GIANT_ANIM_WALKING_LOOP); } break; case GIANT_CS_ACTION_HOLDING_UP_MOON_IN_CLOCK_TOWER: Animation_Change(&this->skelAnime, &gGiantRaisedArmsStartAnim, 0.0f, Animation_GetLastFrame(&gGiantRaisedArmsStartAnim) - 1.0f, - Animation_GetLastFrame(&gGiantRaisedArmsStartAnim), 2, 0.0f); + Animation_GetLastFrame(&gGiantRaisedArmsStartAnim), ANIMMODE_ONCE, 0.0f); break; } } @@ -336,31 +336,31 @@ void EnGiant_UpdateAlpha(EnGiant* this) { */ void EnGiant_PlayAndUpdateAnimation(EnGiant* this) { if (SkelAnime_Update(&this->skelAnime) && - (this->animationId != GIANT_ANIMATION_FALLING_OVER || this->csAction != GIANT_CS_ACTION_FALLING_OVER)) { - EnGiant_ChangeAnimation(this, this->animationId); + (this->animIndex != GIANT_ANIM_FALLING_OVER || this->csAction != GIANT_CS_ACTION_FALLING_OVER)) { + EnGiant_ChangeAnim(this, this->animIndex); switch (this->csAction) { case GIANT_CS_ACTION_LOOKING_UP: - EnGiant_ChangeToStartOrLoopAnimation(this, GIANT_ANIMATION_LOOK_UP_START); + EnGiant_ChangeToStartOrLoopAnimation(this, GIANT_ANIM_LOOK_UP_START); break; case GIANT_CS_ACTION_RAISING_ARMS: - EnGiant_ChangeToStartOrLoopAnimation(this, GIANT_ANIMATION_RAISED_ARMS_START); + EnGiant_ChangeToStartOrLoopAnimation(this, GIANT_ANIM_RAISED_ARMS_START); break; case GIANT_CS_ACTION_STRUGGLING: - EnGiant_ChangeToStartOrLoopAnimation(this, GIANT_ANIMATION_STRUGGLE_START); + EnGiant_ChangeToStartOrLoopAnimation(this, GIANT_ANIM_STRUGGLE_START); break; case GIANT_CS_ACTION_FALLING_OVER: // Unused - EnGiant_ChangeToStartOrLoopAnimation(this, GIANT_ANIMATION_FALLING_OVER); + EnGiant_ChangeToStartOrLoopAnimation(this, GIANT_ANIM_FALLING_OVER); break; case GIANT_CS_ACTION_TALKING: - EnGiant_ChangeAnimation(this, GIANT_ANIMATION_BIG_CALL_LOOP); + EnGiant_ChangeAnim(this, GIANT_ANIM_BIG_CALL_LOOP); break; case GIANT_CS_ACTION_DONE_TALKING: case GIANT_CS_ACTION_PLAYER_LEARNED_OATH_TO_ORDER: - EnGiant_ChangeAnimation(this, GIANT_ANIMATION_IDLE_LOOP); + EnGiant_ChangeAnim(this, GIANT_ANIM_IDLE_LOOP); break; case GIANT_CS_ACTION_TEACHING_OATH_TO_ORDER: - EnGiant_ChangeAnimation(this, GIANT_ANIMATION_SMALL_CALL_LOOP); + EnGiant_ChangeAnim(this, GIANT_ANIM_SMALL_CALL_LOOP); break; } SkelAnime_Update(&this->skelAnime); @@ -369,44 +369,43 @@ void EnGiant_PlayAndUpdateAnimation(EnGiant* this) { void EnGiant_PlaySound(EnGiant* this) { if (this->actor.draw != NULL && this->alpha > 0) { - if (this->animationId == GIANT_ANIMATION_WALKING_LOOP && + if (this->animIndex == GIANT_ANIM_WALKING_LOOP && (Animation_OnFrame(&this->skelAnime, 40.0f) || Animation_OnFrame(&this->skelAnime, 100.0f))) { Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_KYOJIN_WALK); } - if (this->animationId == GIANT_ANIMATION_FALLING_OVER && Animation_OnFrame(&this->skelAnime, 40.0f)) { + if (this->animIndex == GIANT_ANIM_FALLING_OVER && Animation_OnFrame(&this->skelAnime, 40.0f)) { Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_KYOJIN_VOICE_FAIL); } if (this->sfxId != 0xFFFF && - ((this->animationId == GIANT_ANIMATION_BIG_CALL_START && this->skelAnime.curFrame >= 18.0f) || - this->animationId == GIANT_ANIMATION_BIG_CALL_LOOP)) { + ((this->animIndex == GIANT_ANIM_BIG_CALL_START && this->skelAnime.curFrame >= 18.0f) || + this->animIndex == GIANT_ANIM_BIG_CALL_LOOP)) { func_800B9010(&this->actor, this->sfxId); } - if ((this->animationId == GIANT_ANIMATION_SMALL_CALL_START && this->skelAnime.curFrame >= 18.0f) || - this->animationId == GIANT_ANIMATION_SMALL_CALL_LOOP) { + if ((this->animIndex == GIANT_ANIM_SMALL_CALL_START && this->skelAnime.curFrame >= 18.0f) || + this->animIndex == GIANT_ANIM_SMALL_CALL_LOOP) { func_800B9010(&this->actor, NA_SE_EV_KYOJIN_SIGN - SFX_FLAG); } } } -void EnGiant_UpdatePosition(EnGiant* this, GlobalContext* globalCtx, u32 actionIndex) { - CsCmdActorAction* actorAction = globalCtx->csCtx.actorActions[actionIndex]; +void EnGiant_UpdatePosition(EnGiant* this, PlayState* play, u32 actionIndex) { + CsCmdActorAction* actorAction = play->csCtx.actorActions[actionIndex]; f32 startPosY = actorAction->startPos.y; s32 pad[2]; f32 endPosY = actorAction->endPos.y; - f32 scale = Environment_LerpWeight(actorAction->endFrame, actorAction->startFrame, globalCtx->csCtx.frames); + f32 scale = Environment_LerpWeight(actorAction->endFrame, actorAction->startFrame, play->csCtx.frames); this->actor.world.pos.y = ((endPosY - startPosY) * scale) + startPosY; } -void EnGiant_PerformClockTowerSuccessActions(EnGiant* this, GlobalContext* globalCtx) { - if (Cutscene_CheckActorAction(globalCtx, this->actorActionCommand)) { - EnGiant_UpdatePosition(this, globalCtx, Cutscene_GetActorActionIndex(globalCtx, this->actorActionCommand)); +void EnGiant_PerformClockTowerSuccessActions(EnGiant* this, PlayState* play) { + if (Cutscene_CheckActorAction(play, this->actorActionCommand)) { + EnGiant_UpdatePosition(this, play, Cutscene_GetActorActionIndex(play, this->actorActionCommand)); if (this->csAction != - globalCtx->csCtx.actorActions[Cutscene_GetActorActionIndex(globalCtx, this->actorActionCommand)]->action) { + play->csCtx.actorActions[Cutscene_GetActorActionIndex(play, this->actorActionCommand)]->action) { this->csAction = - globalCtx->csCtx.actorActions[Cutscene_GetActorActionIndex(globalCtx, this->actorActionCommand)] - ->action; - EnGiant_ChangeAnimationBasedOnCsAction(this); + play->csCtx.actorActions[Cutscene_GetActorActionIndex(play, this->actorActionCommand)]->action; + EnGiant_ChangeAnimBasedOnCsAction(this); } EnGiant_UpdateAlpha(this); } @@ -418,22 +417,20 @@ void EnGiant_PerformClockTowerSuccessActions(EnGiant* this, GlobalContext* globa EnGiant_PlayAndUpdateAnimation(this); } -void EnGiant_PlayClockTowerFailureAnimation(EnGiant* this, GlobalContext* globalCtx) { +void EnGiant_PlayClockTowerFailureAnimation(EnGiant* this, PlayState* play) { SkelAnime_Update(&this->skelAnime); } -void EnGiant_PerformCutsceneActions(EnGiant* this, GlobalContext* globalCtx) { +void EnGiant_PerformCutsceneActions(EnGiant* this, PlayState* play) { this->actor.draw = EnGiant_Draw; - if (Cutscene_CheckActorAction(globalCtx, this->actorActionCommand)) { - Cutscene_ActorTranslateAndYaw(&this->actor, globalCtx, - Cutscene_GetActorActionIndex(globalCtx, this->actorActionCommand)); + if (Cutscene_CheckActorAction(play, this->actorActionCommand)) { + Cutscene_ActorTranslateAndYaw(&this->actor, play, Cutscene_GetActorActionIndex(play, this->actorActionCommand)); if (this->csAction != - globalCtx->csCtx.actorActions[Cutscene_GetActorActionIndex(globalCtx, this->actorActionCommand)]->action) { + play->csCtx.actorActions[Cutscene_GetActorActionIndex(play, this->actorActionCommand)]->action) { this->csAction = - globalCtx->csCtx.actorActions[Cutscene_GetActorActionIndex(globalCtx, this->actorActionCommand)] - ->action; - EnGiant_ChangeAnimationBasedOnCsAction(this); + play->csCtx.actorActions[Cutscene_GetActorActionIndex(play, this->actorActionCommand)]->action; + EnGiant_ChangeAnimBasedOnCsAction(this); } EnGiant_UpdateAlpha(this); } @@ -446,13 +443,13 @@ void EnGiant_PerformCutsceneActions(EnGiant* this, GlobalContext* globalCtx) { EnGiant_PlayAndUpdateAnimation(this); } -void EnGiant_Update(Actor* thisx, GlobalContext* globalCtx) { +void EnGiant_Update(Actor* thisx, PlayState* play) { EnGiant* this = THIS; s32 blinkTimerTemp; - this->actionFunc(this, globalCtx); + this->actionFunc(this, play); Actor_MoveWithGravity(&this->actor); - Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 0.0f, 0.0f, 0.0f, 4); + Actor_UpdateBgCheckInfo(play, &this->actor, 0.0f, 0.0f, 0.0f, 4); if (this->blinkTimer == 0) { blinkTimerTemp = 0; @@ -470,59 +467,57 @@ void EnGiant_Update(Actor* thisx, GlobalContext* globalCtx) { } } -void EnGiant_PostLimbDrawOpa(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx) { +void EnGiant_PostLimbDrawOpa(PlayState* play, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx) { if (limbIndex == GIANT_LIMB_HEAD) { - OPEN_DISPS(globalCtx->state.gfxCtx); + OPEN_DISPS(play->state.gfxCtx); gSPDisplayList(POLY_OPA_DISP++, gGiantBeardDL); - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->state.gfxCtx); } } -void EnGiant_PostLimbDrawXlu(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx, - Gfx** gfx) { +void EnGiant_PostLimbDrawXlu(PlayState* play, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx, Gfx** gfx) { EnGiant* this = THIS; if (limbIndex == GIANT_LIMB_HEAD) { - Matrix_CopyCurrentState(&this->headDrawMtxF); + Matrix_Get(&this->headDrawMtxF); } } -void EnGiant_Draw(Actor* thisx, GlobalContext* globalCtx) { +void EnGiant_Draw(Actor* thisx, PlayState* play) { s32 pad; EnGiant* this = THIS; static TexturePtr sFaceTextures[] = { gGiantFaceEyeOpenTex, gGiantFaceEyeHalfTex, gGiantFaceEyeClosedTex }; if (this->alpha > 0) { - OPEN_DISPS(globalCtx->state.gfxCtx); + OPEN_DISPS(play->state.gfxCtx); if (this->alpha >= 255) { - func_8012C28C(globalCtx->state.gfxCtx); + func_8012C28C(play->state.gfxCtx); gSPSegment(POLY_OPA_DISP++, 0x08, Lib_SegmentedToVirtual(sFaceTextures[this->faceIndex])); gDPSetEnvColor(POLY_OPA_DISP++, 0, 0, 0, 255); - Scene_SetRenderModeXlu(globalCtx, 0, 1); - SkelAnime_DrawFlexOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, + Scene_SetRenderModeXlu(play, 0, 1); + SkelAnime_DrawFlexOpa(play, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, NULL, EnGiant_PostLimbDrawOpa, thisx); } else if (this->alpha > 0) { if (this->alpha >= 129) { func_8012C2B4(POLY_XLU_DISP++); - Scene_SetRenderModeXlu(globalCtx, 2, 2); + Scene_SetRenderModeXlu(play, 2, 2); } else { func_8012C304(POLY_XLU_DISP++); - Scene_SetRenderModeXlu(globalCtx, 1, 2); + Scene_SetRenderModeXlu(play, 1, 2); } gSPSegment(POLY_XLU_DISP++, 0x08, Lib_SegmentedToVirtual(sFaceTextures[this->faceIndex])); gDPSetEnvColor(POLY_XLU_DISP++, 0, 0, 0, this->alpha); POLY_XLU_DISP = - SkelAnime_DrawFlex(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, + SkelAnime_DrawFlex(play, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, NULL, EnGiant_PostLimbDrawXlu, thisx, POLY_XLU_DISP); - Matrix_InsertMatrix(&this->headDrawMtxF, MTXMODE_NEW); - gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), - G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + Matrix_Mult(&this->headDrawMtxF, MTXMODE_NEW); + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_XLU_DISP++, gGiantBeardDL); } - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->state.gfxCtx); } } diff --git a/src/overlays/actors/ovl_En_Giant/z_en_giant.h b/src/overlays/actors/ovl_En_Giant/z_en_giant.h index c8d45ad39..3b2cac192 100644 --- a/src/overlays/actors/ovl_En_Giant/z_en_giant.h +++ b/src/overlays/actors/ovl_En_Giant/z_en_giant.h @@ -40,14 +40,14 @@ typedef enum { struct EnGiant; -typedef void (*EnGiantActionFunc)(struct EnGiant*, GlobalContext*); +typedef void (*EnGiantActionFunc)(struct EnGiant*, PlayState*); typedef struct EnGiant { /* 0x000 */ Actor actor; /* 0x144 */ SkelAnime skelAnime; /* 0x188 */ Vec3s jointTable[GIANT_LIMB_MAX]; /* 0x1E8 */ Vec3s morphTable[GIANT_LIMB_MAX]; - /* 0x248 */ s16 animationId; + /* 0x248 */ s16 animIndex; /* 0x24A */ u16 actorActionCommand; /* 0x24C */ u16 csAction; /* 0x24E */ s16 alpha; 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 34b0e36b4..758d3eae0 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 @@ -11,10 +11,10 @@ #define THIS ((EnGinkoMan*)thisx) -void EnGinkoMan_Init(Actor* thisx, GlobalContext* globalCtx); -void EnGinkoMan_Destroy(Actor* thisx, GlobalContext* globalCtx); -void EnGinkoMan_Update(Actor* thisx, GlobalContext* globalCtx); -void EnGinkoMan_Draw(Actor* thisx, GlobalContext* globalCtx); +void EnGinkoMan_Init(Actor* thisx, PlayState* play); +void EnGinkoMan_Destroy(Actor* thisx, PlayState* play); +void EnGinkoMan_Update(Actor* thisx, PlayState* play); +void EnGinkoMan_Draw(Actor* thisx, PlayState* play); void EnGinkoMan_SetupIdle(EnGinkoMan* this); void EnGinkoMan_SetupDialogue(EnGinkoMan* this); @@ -22,13 +22,13 @@ void EnGinkoMan_SetupBankAward(EnGinkoMan* this); void EnGinkoMan_SetupBankAward2(EnGinkoMan* this); void EnGinkoMan_SetupStamp(EnGinkoMan* this); -void EnGinkoMan_Idle(EnGinkoMan* this, GlobalContext* globalCtx); -void EnGinkoMan_BankAward(EnGinkoMan* this, GlobalContext* globalCtx); -void EnGinkoMan_DepositDialogue(EnGinkoMan* this, GlobalContext* globalCtx); -void EnGinkoMan_BankAward2(EnGinkoMan* this, GlobalContext* globalCtx); -void EnGinkoMan_Stamp(EnGinkoMan* this, GlobalContext* globalCtx); -void EnGinkoMan_Dialogue(EnGinkoMan* this, GlobalContext* globalCtx); -void EnGinkoMan_SwitchAnimation(EnGinkoMan* this, GlobalContext* globalCtx); +void EnGinkoMan_Idle(EnGinkoMan* this, PlayState* play); +void EnGinkoMan_BankAward(EnGinkoMan* this, PlayState* play); +void EnGinkoMan_DepositDialogue(EnGinkoMan* this, PlayState* play); +void EnGinkoMan_BankAward2(EnGinkoMan* this, PlayState* play); +void EnGinkoMan_Stamp(EnGinkoMan* this, PlayState* play); +void EnGinkoMan_Dialogue(EnGinkoMan* this, PlayState* play); +void EnGinkoMan_SwitchAnimation(EnGinkoMan* this, PlayState* play); const ActorInit En_Ginko_Man_InitVars = { ACTOR_EN_GINKO_MAN, @@ -42,7 +42,15 @@ const ActorInit En_Ginko_Man_InitVars = { (ActorFunc)EnGinkoMan_Draw, }; -static AnimationInfo sAnimations[] = { +typedef enum { + /* 0 */ GINKO_ANIM_LEGSMACKING, + /* 1 */ GINKO_ANIM_SITTING, + /* 2 */ GINKO_ANIM_REACHING, + /* 3 */ GINKO_ANIM_AMAZED, + /* 4 */ GINKO_ANIM_ADVERTISING, +} GinkoAnimation; + +static AnimationInfo sAnimationInfo[] = { { &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 }, @@ -50,7 +58,7 @@ static AnimationInfo sAnimations[] = { { &object_boj_Anim_004A7C, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, -4.0f }, }; -void EnGinkoMan_Init(Actor* thisx, GlobalContext* globalCtx) { +void EnGinkoMan_Init(Actor* thisx, PlayState* play) { EnGinkoMan* this = THIS; this->actor.targetMode = 1; @@ -62,70 +70,70 @@ void EnGinkoMan_Init(Actor* thisx, GlobalContext* globalCtx) { this->isStampChecked = false; this->choiceDepositWithdrawl = GINKOMAN_CHOICE_RESET; this->serviceFee = 0; - SkelAnime_InitFlex(globalCtx, &this->skelAnime, &object_boj_Skel_00C240, &object_boj_Anim_0043F0, this->jointTable, + SkelAnime_InitFlex(play, &this->skelAnime, &object_boj_Skel_00C240, &object_boj_Anim_0043F0, this->jointTable, this->morphTable, 16); EnGinkoMan_SetupIdle(this); } -void EnGinkoMan_Destroy(Actor* thisx, GlobalContext* globalCtx) { +void EnGinkoMan_Destroy(Actor* thisx, PlayState* play) { } void EnGinkoMan_SetupIdle(EnGinkoMan* this) { this->actor.flags |= ACTOR_FLAG_1; // targetable - Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, GINKO_SITTING); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, GINKO_ANIM_SITTING); this->actionFunc = EnGinkoMan_Idle; } -void EnGinkoMan_Idle(EnGinkoMan* this, GlobalContext* globalCtx) { +void EnGinkoMan_Idle(EnGinkoMan* this, PlayState* play) { s32 yaw = this->actor.yawTowardsPlayer - this->actor.shape.rot.y; - EnGinkoMan_SwitchAnimation(this, globalCtx); - if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { + EnGinkoMan_SwitchAnimation(this, play); + if (Actor_ProcessTalkRequest(&this->actor, &play->state)) { if ((gSaveContext.save.bankRupees & 0xFFFF) == 0) { - Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, GINKO_FLOORSMACKING); - Message_StartTextbox(globalCtx, 0x44C, &this->actor); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, GINKO_ANIM_LEGSMACKING); + Message_StartTextbox(play, 0x44C, &this->actor); this->curTextId = 0x44C; // would you like to make an account } else { - Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, GINKO_SITTING); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, GINKO_ANIM_SITTING); if ((CURRENT_DAY == 3) && (gSaveContext.save.isNight == true)) { - Message_StartTextbox(globalCtx, 0x467, &this->actor); + Message_StartTextbox(play, 0x467, &this->actor); this->curTextId = 0x467; // "What's this? You need somethin' on a day like this? } else { - Message_StartTextbox(globalCtx, 0x466, &this->actor); + Message_StartTextbox(play, 0x466, &this->actor); this->curTextId = 0x466; // What's this? You need somethin'? } } EnGinkoMan_SetupDialogue(this); } else if (ABS_ALT(yaw) < 0x1555) { - func_800B8614(&this->actor, globalCtx, 100.0f); + func_800B8614(&this->actor, play, 100.0f); } } // action func: non-input dialogue -void EnGinkoMan_DepositDialogue(EnGinkoMan* this, GlobalContext* globalCtx) { - if (!Message_ShouldAdvance(globalCtx)) { +void EnGinkoMan_DepositDialogue(EnGinkoMan* this, PlayState* play) { + if (!Message_ShouldAdvance(play)) { return; } switch (this->curTextId) { case 0x44C: // "Hey there, little guy! Won't you deposit some Rupees? (first dialogue) - Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, GINKO_SITTING); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, GINKO_ANIM_SITTING); if (gSaveContext.save.weekEventReg[10] & 8) { - Message_StartTextbox(globalCtx, 0x44E, &this->actor); + Message_StartTextbox(play, 0x44E, &this->actor); this->curTextId = 0x44E; //" ...So, what'll it be? Deposit Rupees Don't deposit Rupees" } else { - Message_StartTextbox(globalCtx, 0x44D, &this->actor); + Message_StartTextbox(play, 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." - Message_StartTextbox(globalCtx, 0x44E, &this->actor); + Message_StartTextbox(play, 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_ChangeAnimationByInfo(&this->skelAnime, sAnimations, GINKO_FLOORSMACKING); - Message_StartTextbox(globalCtx, 0x450, &this->actor); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, GINKO_ANIM_LEGSMACKING); + Message_StartTextbox(play, 0x450, &this->actor); this->curTextId = 0x450; // "How much? How much? [rupee prompt] break; @@ -135,55 +143,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_ChangeAnimationByInfo(&this->skelAnime, sAnimations, GINKO_SITTING); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, GINKO_ANIM_SITTING); } - Message_StartTextbox(globalCtx, 0x461, &this->actor); + Message_StartTextbox(play, 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_ChangeAnimationByInfo(&this->skelAnime, sAnimations, GINKO_FLOORSMACKING); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, GINKO_ANIM_LEGSMACKING); } - globalCtx->msgCtx.bankRupees = gSaveContext.save.bankRupees & 0xFFFF; - Message_StartTextbox(globalCtx, 0x45A, &this->actor); + play->msgCtx.bankRupees = gSaveContext.save.bankRupees & 0xFFFF; + Message_StartTextbox(play, 0x45A, &this->actor); this->curTextId = 0x45A; // "All right, little guy, now I've got a total of [rupees] from you!" } break; case 0x456: // "Is that so? Think about it, little guy!" case 0x459: // "Heyyy! You don't have that much! - Message_StartTextbox(globalCtx, 0x44E, &this->actor); + Message_StartTextbox(play, 0x44E, &this->actor); this->curTextId = 0x44E; //" ...So, what'll it be? Deposit Rupees Don't deposit Rupees" break; case 0x45A: // "All right, little guy, now I've got a total of [rupees] from you!" if (((gSaveContext.save.bankRupees & 0xFFFF) >= 200) && (this->previousBankValue < 200) && !(gSaveContext.save.weekEventReg[59] & 0x40)) { gSaveContext.save.weekEventReg[59] |= 0x40; - Message_StartTextbox(globalCtx, 0x45B, &this->actor); + Message_StartTextbox(play, 0x45B, &this->actor); this->curTextId = 0x45B; // "What's this? You've already saved up 200 Rupees!?! } else if (((gSaveContext.save.bankRupees & 0xFFFF) >= 1000) && ((this->previousBankValue) < 1000) && !(gSaveContext.save.weekEventReg[59] & 0x80)) { gSaveContext.save.weekEventReg[59] |= 0x80; - Message_StartTextbox(globalCtx, 0x45C, &this->actor); + Message_StartTextbox(play, 0x45C, &this->actor); this->curTextId = 0x45C; // "What's this? You've already saved up 1000 Rupees!?! } else if ((gSaveContext.save.bankRupees & 0xFFFF) >= 5000) { if ((this->previousBankValue < 5000) && !(gSaveContext.save.weekEventReg[60] & 1)) { gSaveContext.save.weekEventReg[60] |= 1; - Message_StartTextbox(globalCtx, 0x45D, &this->actor); + Message_StartTextbox(play, 0x45D, &this->actor); this->curTextId = 0x45D; // "What's this? You've already saved up 5000 Rupees?! } else if (this->previousBankValue < (s16)(gSaveContext.save.bankRupees & 0xFFFF)) { - Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, GINKO_SITTING); - Message_StartTextbox(globalCtx, 0x45E, &this->actor); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, GINKO_ANIM_SITTING); + Message_StartTextbox(play, 0x45E, &this->actor); this->curTextId = 0x45E; // "...Hang on there, little guy. I can't take any more deposits. Sorry..." } else { - Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, GINKO_FLOORSMACKING); - Message_StartTextbox(globalCtx, 0x460, &this->actor); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, GINKO_ANIM_LEGSMACKING); + Message_StartTextbox(play, 0x460, &this->actor); this->curTextId = 0x460; // "Come back and deposit some after you save up a bunch!" } } else { - Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, GINKO_FLOORSMACKING); - Message_StartTextbox(globalCtx, 0x460, &this->actor); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, GINKO_ANIM_LEGSMACKING); + Message_StartTextbox(play, 0x460, &this->actor); this->curTextId = 0x460; // "Come back and deposit some after you save up a bunch!" } break; @@ -191,35 +199,35 @@ void EnGinkoMan_DepositDialogue(EnGinkoMan* this, GlobalContext* globalCtx) { case 0x45C: // given 1000 reward case 0x45D: // given 5000 reward this->isStampChecked = false; - func_801477B4(globalCtx); + func_801477B4(play); EnGinkoMan_SetupBankAward(this); - EnGinkoMan_BankAward(this, globalCtx); + EnGinkoMan_BankAward(this, play); break; case 0x461: // So, little guy, what's your name? - Message_StartTextbox(globalCtx, 0x462, &this->actor); + Message_StartTextbox(play, 0x462, &this->actor); this->curTextId = 0x462; // Hmm... Link is it? break; case 0x462: // Hmm.. Link is it? - Message_StartTextbox(globalCtx, 0x463, &this->actor); + Message_StartTextbox(play, 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 - Message_StartTextbox(globalCtx, 0x464, &this->actor); + Message_StartTextbox(play, 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 - globalCtx->msgCtx.msgMode = 0x44; + play->msgCtx.msgMode = 0x44; EnGinkoMan_SetupStamp(this); // stamp player break; case 0x465: // "There! Now I'll know you when I see you!" - Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, GINKO_FLOORSMACKING); - globalCtx->msgCtx.bankRupees = gSaveContext.save.bankRupees & 0xFFFF; - Message_StartTextbox(globalCtx, 0x45A, &this->actor); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, GINKO_ANIM_LEGSMACKING); + play->msgCtx.bankRupees = gSaveContext.save.bankRupees & 0xFFFF; + Message_StartTextbox(play, 0x45A, &this->actor); this->curTextId = 0x45A; // "All right, little guy, now I've got a total of [rupees] from you!" break; 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? - Message_StartTextbox(globalCtx, 0x468, &this->actor); + Message_StartTextbox(play, 0x468, &this->actor); this->curTextId = 0x468; // " Deposit Rupees Withdraw Rupees Nothing really" break; case 0x469: // "Excuse me, but let me take a look at you..." @@ -230,50 +238,50 @@ void EnGinkoMan_DepositDialogue(EnGinkoMan* this, GlobalContext* globalCtx) { case 0x47E: // "Your deposits total [rupees]." if (this->choiceDepositWithdrawl == GINKOMAN_CHOICE_DEPOSIT) { if ((u32)(gSaveContext.save.bankRupees & 0xFFFF) >= 5000) { - Message_StartTextbox(globalCtx, 0x45F, &this->actor); + Message_StartTextbox(play, 0x45F, &this->actor); this->curTextId = 0x45F; // "Excuuuse me! But I can't take anymore deposits! } else if (gSaveContext.save.playerData.rupees == 0) { - Message_StartTextbox(globalCtx, 0x458, &this->actor); + Message_StartTextbox(play, 0x458, &this->actor); this->curTextId = 0x458; // "Hmm...You play mean jokes, little guy! You haven't even got a single Rupee! } else { - Message_StartTextbox(globalCtx, 0x479, &this->actor); + Message_StartTextbox(play, 0x479, &this->actor); this->curTextId = 0x479; // "Well, are you gonna make a deposit?" } } else if ((CURRENT_DAY == 3) && (gSaveContext.save.isNight == true)) { - Message_StartTextbox(globalCtx, 0x46D, &this->actor); + Message_StartTextbox(play, 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 - Message_StartTextbox(globalCtx, 0x46B, &this->actor); + Message_StartTextbox(play, 0x46B, &this->actor); this->curTextId = 0x46B; // "So..." } this->choiceDepositWithdrawl = GINKOMAN_CHOICE_RESET; break; case 0x46B: // So... - Message_StartTextbox(globalCtx, 0x46E, &this->actor); + Message_StartTextbox(play, 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!" - Message_StartTextbox(globalCtx, 0x46B, &this->actor); + Message_StartTextbox(play, 0x46B, &this->actor); this->curTextId = 0x46B; // So... break; case 0x470: // "Is that so? Come back and deposit some after saving up a bunch!" - if (Message_ShouldAdvance(globalCtx)) { - func_801477B4(globalCtx); + if (Message_ShouldAdvance(play)) { + func_801477B4(play); this->isStampChecked = false; EnGinkoMan_SetupIdle(this); // change to waiting for approach } break; case 0x476: // "...You haven't deposited that many Rupees, so that much isn't available for withdrawal. Do the // math! - Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, GINKO_SITTING); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, GINKO_ANIM_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 - Message_StartTextbox(globalCtx, 0x468, &this->actor); + Message_StartTextbox(play, 0x468, &this->actor); this->curTextId = 0x468; // " Deposit Rupees Withdraw Rupees Nothing really" break; case 0x472: // "What's this? It's a waste to take out such a tiny bit! ...But if you say so!" @@ -281,75 +289,75 @@ void EnGinkoMan_DepositDialogue(EnGinkoMan* this, GlobalContext* globalCtx) { case 0x474: // "Aw, you're taking out all that? If you spend it like that, it'll all be gone before you know // it!" if ((gSaveContext.save.bankRupees & 0xFFFF) == 0) { - Message_StartTextbox(globalCtx, 0x478, &this->actor); + Message_StartTextbox(play, 0x478, &this->actor); // "Look, little guy, all the Rupees you deposited are gone, so you can't use that stamp anymore." this->curTextId = 0x478; } else { - globalCtx->msgCtx.bankRupees = gSaveContext.save.bankRupees & 0xFFFF; - Message_StartTextbox(globalCtx, 0x45A, &this->actor); + play->msgCtx.bankRupees = gSaveContext.save.bankRupees & 0xFFFF; + Message_StartTextbox(play, 0x45A, &this->actor); this->curTextId = 0x45A; // "All right, little guy, now I've got a total of [rupees] from you!" } break; case 0x477: // "...You know, at this time of day there's a 4 Rupee service charge on withdrawals!" - Message_StartTextbox(globalCtx, 0x471, &this->actor); + Message_StartTextbox(play, 0x471, &this->actor); this->curTextId = 0x471; // "Are you really withdrawing [rupees selected]? Y/n" - this->serviceFee = globalCtx->msgCtx.unk1206C; + this->serviceFee = play->msgCtx.unk1206C; break; case 0x479: // Well, are you gonna make a deposit? - Message_StartTextbox(globalCtx, 0x44F, &this->actor); + Message_StartTextbox(play, 0x44F, &this->actor); this->curTextId = 0x44F; // "All right! So..." break; } } // actionfunc: wait for player dialogue input -void EnGinkoMan_WaitForDialogueInput(EnGinkoMan* this, GlobalContext* globalCtx) { - if (!Message_ShouldAdvance(globalCtx)) { +void EnGinkoMan_WaitForDialogueInput(EnGinkoMan* this, PlayState* play) { + if (!Message_ShouldAdvance(play)) { return; } switch (this->curTextId) { case 0x44E: // "...So, what'll it be? - if (globalCtx->msgCtx.choiceIndex == GINKOMAN_CHOICE_YES) { + if (play->msgCtx.choiceIndex == GINKOMAN_CHOICE_YES) { if ((gSaveContext.save.bankRupees & 0xFFFF) >= 5000) { play_sound(NA_SE_SY_ERROR); - Message_StartTextbox(globalCtx, 0x45F, &this->actor); + Message_StartTextbox(play, 0x45F, &this->actor); this->curTextId = 0x45F; // bank full, cannot accept more } else { if (gSaveContext.save.playerData.rupees > 0) { func_8019F208(); - Message_StartTextbox(globalCtx, 0x44F, &this->actor); + Message_StartTextbox(play, 0x44F, &this->actor); this->curTextId = 0x44F; // "All right! so..." } else { play_sound(NA_SE_SY_ERROR); - Message_StartTextbox(globalCtx, 0x458, &this->actor); + Message_StartTextbox(play, 0x458, &this->actor); this->curTextId = 0x458; // you haven't even gotten a single rup } } } else { // GINKOMAN_CHOICE_NO func_8019F230(); - Message_StartTextbox(globalCtx, 0x451, &this->actor); + Message_StartTextbox(play, 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.save.playerData.rupees < globalCtx->msgCtx.bankRupeesSelected) { + if (play->msgCtx.choiceIndex == GINKOMAN_CHOICE_YES) { + if (gSaveContext.save.playerData.rupees < play->msgCtx.bankRupeesSelected) { play_sound(NA_SE_SY_ERROR); - Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, GINKO_SITTING); - Message_StartTextbox(globalCtx, 0x459, &this->actor); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, GINKO_ANIM_SITTING); + Message_StartTextbox(play, 0x459, &this->actor); this->curTextId = 0x459; // HEY you dont have that much } else { func_8019F208(); - if (globalCtx->msgCtx.bankRupeesSelected >= 100) { - Message_StartTextbox(globalCtx, 0x455, &this->actor); + if (play->msgCtx.bankRupeesSelected >= 100) { + Message_StartTextbox(play, 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) { - Message_StartTextbox(globalCtx, 0x454, &this->actor); + } else if (play->msgCtx.bankRupeesSelected >= 10) { + Message_StartTextbox(play, 0x454, &this->actor); this->curTextId = 0x454; // Seriously? that's a lot. A lot! } else { - Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, GINKO_SITTING); - Message_StartTextbox(globalCtx, 0x453, &this->actor); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, GINKO_ANIM_SITTING); + Message_StartTextbox(play, 0x453, &this->actor); this->curTextId = 0x453; // That's it? That aint nothing at all } @@ -357,107 +365,107 @@ void EnGinkoMan_WaitForDialogueInput(EnGinkoMan* this, GlobalContext* globalCtx) this->isNewAccount = true; } - func_801159EC((s16)-globalCtx->msgCtx.bankRupeesSelected); + Rupees_ChangeBy(-play->msgCtx.bankRupeesSelected); this->previousBankValue = gSaveContext.save.bankRupees & 0xFFFF; gSaveContext.save.bankRupees = - ((gSaveContext.save.bankRupees & 0xFFFF) + globalCtx->msgCtx.bankRupeesSelected) | + ((gSaveContext.save.bankRupees & 0xFFFF) + play->msgCtx.bankRupeesSelected) | (gSaveContext.save.bankRupees & 0xFFFF0000); } } else { // GINKOMAN_CHOICE_NO func_8019F230(); - Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, GINKO_SITTING); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, GINKO_ANIM_SITTING); if ((gSaveContext.save.bankRupees & 0xFFFF) == 0) { - Message_StartTextbox(globalCtx, 0x456, &this->actor); + Message_StartTextbox(play, 0x456, &this->actor); this->curTextId = 0x456; // Is that so? think about it } else { - Message_StartTextbox(globalCtx, 0x47D, &this->actor); + Message_StartTextbox(play, 0x47D, &this->actor); this->curTextId = 0x47D; // is that so? think it over } } break; case 0x468: // Deposit OR withdrawl OR cancel screen - if (globalCtx->msgCtx.choiceIndex == GINKOMAN_CHOICE_CANCEL) { + if (play->msgCtx.choiceIndex == GINKOMAN_CHOICE_CANCEL) { func_8019F230(); - Message_StartTextbox(globalCtx, 0x470, &this->actor); + Message_StartTextbox(play, 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; + this->choiceDepositWithdrawl = play->msgCtx.choiceIndex; if (!this->isStampChecked) { this->isStampChecked = true; - Message_StartTextbox(globalCtx, 0x469, &this->actor); + Message_StartTextbox(play, 0x469, &this->actor); this->curTextId = 0x469; // "Excuse me, but let me take a look at you..." } else { - Message_StartTextbox(globalCtx, 0x47E, &this->actor); + Message_StartTextbox(play, 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 (play->msgCtx.choiceIndex == GINKOMAN_CHOICE_YES) { if ((s32)((gSaveContext.save.bankRupees & 0xFFFF)) < - ((s32)(globalCtx->msgCtx.bankRupeesSelected + this->serviceFee))) { + ((s32)(play->msgCtx.bankRupeesSelected + this->serviceFee))) { play_sound(NA_SE_SY_ERROR); - Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, GINKO_FLOORSMACKING); - Message_StartTextbox(globalCtx, 0x476, &this->actor); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, GINKO_ANIM_LEGSMACKING); + Message_StartTextbox(play, 0x476, &this->actor); this->curTextId = 0x476; // you dont have enough deposited to withdrawl } else if (CUR_CAPACITY(UPG_WALLET) < - (globalCtx->msgCtx.bankRupeesSelected + gSaveContext.save.playerData.rupees)) { + (play->msgCtx.bankRupeesSelected + gSaveContext.save.playerData.rupees)) { // check if wallet is big enough play_sound(NA_SE_SY_ERROR); - Message_StartTextbox(globalCtx, 0x475, &this->actor); + Message_StartTextbox(play, 0x475, &this->actor); this->curTextId = 0x475; // You can't hold that many in your wallet } else { func_8019F208(); - if (globalCtx->msgCtx.bankRupeesSelected >= 100) { - Message_StartTextbox(globalCtx, 0x474, &this->actor); + if (play->msgCtx.bankRupeesSelected >= 100) { + Message_StartTextbox(play, 0x474, &this->actor); this->curTextId = 0x474; // Aw, you're taking out all that? - } else if (globalCtx->msgCtx.bankRupeesSelected >= 10) { - Message_StartTextbox(globalCtx, 0x473, &this->actor); + } else if (play->msgCtx.bankRupeesSelected >= 10) { + Message_StartTextbox(play, 0x473, &this->actor); this->curTextId = 0x473; // use it wisely } else { - Message_StartTextbox(globalCtx, 0x472, &this->actor); + Message_StartTextbox(play, 0x472, &this->actor); this->curTextId = 0x472; // It's a waste to take out such a tiny bit } this->previousBankValue = (s16)(gSaveContext.save.bankRupees & 0xFFFF); gSaveContext.save.bankRupees = - (((gSaveContext.save.bankRupees & 0xFFFF) - globalCtx->msgCtx.bankRupeesSelected) - + (((gSaveContext.save.bankRupees & 0xFFFF) - play->msgCtx.bankRupeesSelected) - this->serviceFee) | (gSaveContext.save.bankRupees & 0xFFFF0000); - func_801159EC(globalCtx->msgCtx.bankRupeesSelected); + Rupees_ChangeBy(play->msgCtx.bankRupeesSelected); } } else { func_8019F230(); - Message_StartTextbox(globalCtx, 0x47C, &this->actor); + Message_StartTextbox(play, 0x47C, &this->actor); this->curTextId = 0x47C; // "Is that so? Think it over, little guy! So what are you gonna do?" } break; } } -void EnGinkoMan_WaitForRupeeCount(EnGinkoMan* this, GlobalContext* globalCtx) { - if (Message_ShouldAdvance(globalCtx)) { +void EnGinkoMan_WaitForRupeeCount(EnGinkoMan* this, PlayState* play) { + if (Message_ShouldAdvance(play)) { switch (this->curTextId) { case 0x450: // "How much? How much?" [rupee prompt] Set the amount with [Control Stick] and - if (globalCtx->msgCtx.bankRupeesSelected == 0) { - Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, GINKO_SITTING); - Message_StartTextbox(globalCtx, 0x457, &this->actor); + if (play->msgCtx.bankRupeesSelected == 0) { + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, GINKO_ANIM_SITTING); + Message_StartTextbox(play, 0x457, &this->actor); this->curTextId = 0x457; // Zero Rupees? Cruel joke! } else { - Message_StartTextbox(globalCtx, 0x452, &this->actor); + Message_StartTextbox(play, 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) { - Message_StartTextbox(globalCtx, 0x46F, &this->actor); + if (play->msgCtx.bankRupeesSelected == 0) { + Message_StartTextbox(play, 0x46F, &this->actor); this->curTextId = 0x46F; // "Zero Rupees?!? That's a cruel joke!" } else if (gSaveContext.save.isNight == true) { - Message_StartTextbox(globalCtx, 0x477, &this->actor); + Message_StartTextbox(play, 0x477, &this->actor); this->curTextId = 0x477; // "...You know, at this time of day there's a 4 Rupee service charge... } else { - Message_StartTextbox(globalCtx, 0x471, &this->actor); + Message_StartTextbox(play, 0x471, &this->actor); this->curTextId = 0x471; // "Are you really withdrawing [rupees selected]? Y/n this->serviceFee = 0; } @@ -470,27 +478,32 @@ void EnGinkoMan_SetupDialogue(EnGinkoMan* this) { this->actionFunc = EnGinkoMan_Dialogue; } -void EnGinkoMan_Dialogue(EnGinkoMan* this, GlobalContext* globalCtx) { - switch (Message_GetState(&globalCtx->msgCtx)) { - case 2: +void EnGinkoMan_Dialogue(EnGinkoMan* this, PlayState* play) { + switch (Message_GetState(&play->msgCtx)) { + case TEXT_STATE_CLOSING: EnGinkoMan_SetupIdle(this); break; - case 4: - EnGinkoMan_WaitForDialogueInput(this, globalCtx); + + case TEXT_STATE_CHOICE: + EnGinkoMan_WaitForDialogueInput(this, play); break; - case 5: - EnGinkoMan_DepositDialogue(this, globalCtx); + + case TEXT_STATE_5: + EnGinkoMan_DepositDialogue(this, play); break; - case 6: - if (Message_ShouldAdvance(globalCtx)) { + + case TEXT_STATE_DONE: + if (Message_ShouldAdvance(play)) { this->isStampChecked = false; EnGinkoMan_SetupIdle(this); } break; - case 14: - EnGinkoMan_WaitForRupeeCount(this, globalCtx); + + case TEXT_STATE_14: + EnGinkoMan_WaitForRupeeCount(this, play); break; - case 0: + + case TEXT_STATE_NONE: default: break; } @@ -505,23 +518,23 @@ void EnGinkoMan_SetupBankAward(EnGinkoMan* this) { this->actionFunc = EnGinkoMan_BankAward; } -void EnGinkoMan_BankAward(EnGinkoMan* this, GlobalContext* globalCtx) { - if (Actor_HasParent(&this->actor, globalCtx)) { +void EnGinkoMan_BankAward(EnGinkoMan* this, PlayState* play) { + if (Actor_HasParent(&this->actor, play)) { // Parent is the player when starting to receive the award this->actor.parent = NULL; EnGinkoMan_SetupBankAward2(this); } else if (this->curTextId == 0x45B) { // "Whats this, you already saved up 200?" if (!(gSaveContext.save.weekEventReg[10] & 8)) { - Actor_PickUp(&this->actor, globalCtx, GI_WALLET_ADULT + CUR_UPG_VALUE(UPG_WALLET), 500.0f, 100.0f); + Actor_PickUp(&this->actor, play, 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); + Actor_PickUp(&this->actor, play, GI_RUPEE_BLUE, 500.0f, 100.0f); } } else if (this->curTextId == 0x45C) { // "Whats this, you already saved up 5000?" - Actor_PickUp(&this->actor, globalCtx, GI_RUPEE_BLUE, 500.0f, 100.0f); + Actor_PickUp(&this->actor, play, GI_RUPEE_BLUE, 500.0f, 100.0f); } else if (!(gSaveContext.save.weekEventReg[59] & 8)) { - Actor_PickUp(&this->actor, globalCtx, GI_HEART_PIECE, 500.0f, 100.0f); + Actor_PickUp(&this->actor, play, GI_HEART_PIECE, 500.0f, 100.0f); } else { - Actor_PickUp(&this->actor, globalCtx, GI_RUPEE_BLUE, 500.0f, 100.0f); + Actor_PickUp(&this->actor, play, GI_RUPEE_BLUE, 500.0f, 100.0f); } } @@ -531,39 +544,39 @@ 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)) { +void EnGinkoMan_BankAward2(EnGinkoMan* this, PlayState* play) { + if (Actor_ProcessTalkRequest(&this->actor, &play->state)) { if (!(gSaveContext.save.weekEventReg[10] & 8) && (this->curTextId == 0x45B)) { // "What's this? You've already saved up 200 Rupees!?! Well, little guy, here's your special gift. Take // it!" gSaveContext.save.weekEventReg[10] |= 8; - Message_StartTextbox(globalCtx, 0x47A, &this->actor); + Message_StartTextbox(play, 0x47A, &this->actor); this->curTextId = 0x47A; // Message after receiving reward for depositing 200 rupees. } else { - Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, GINKO_SITTING); - Message_StartTextbox(globalCtx, 0x47B, &this->actor); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, GINKO_ANIM_SITTING); + Message_StartTextbox(play, 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) && Message_ShouldAdvance(globalCtx)) { + if ((Message_GetState(&play->msgCtx) == TEXT_STATE_DONE) && Message_ShouldAdvance(play)) { if (!(gSaveContext.save.weekEventReg[59] & 8)) { gSaveContext.save.weekEventReg[59] |= 8; } EnGinkoMan_SetupIdle(this); } } else { - func_800B85E0(&this->actor, globalCtx, 500.0f, EXCH_ITEM_MINUS1); + func_800B85E0(&this->actor, play, 500.0f, PLAYER_AP_MINUS1); } } void EnGinkoMan_SetupStamp(EnGinkoMan* this) { - Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, GINKO_REACHING); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, GINKO_ANIM_REACHING); this->actionFunc = EnGinkoMan_Stamp; } -void EnGinkoMan_Stamp(EnGinkoMan* this, GlobalContext* globalCtx) { +void EnGinkoMan_Stamp(EnGinkoMan* this, PlayState* play) { if ((this->curTextId == 0x464) // "Hey, relax! It doesn't leave any marks, and it's not gonna hurt." && (Animation_OnFrame(&this->skelAnime, 10.0f))) { Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_HANKO); // "stamp" @@ -572,18 +585,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_ChangeAnimationByInfo(&this->skelAnime, sAnimations, GINKO_SITTING); - Message_StartTextbox(globalCtx, 0x465, &this->actor); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, GINKO_ANIM_SITTING); + Message_StartTextbox(play, 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_ChangeAnimationByInfo(&this->skelAnime, sAnimations, GINKO_SITTING); - globalCtx->msgCtx.bankRupees = (gSaveContext.save.bankRupees & 0xFFFF); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, GINKO_ANIM_SITTING); + play->msgCtx.bankRupees = (gSaveContext.save.bankRupees & 0xFFFF); if ((CURRENT_DAY == 3) && (gSaveContext.save.isNight == true)) { - Message_StartTextbox(globalCtx, 0x46C, &this->actor); + Message_StartTextbox(play, 0x46C, &this->actor); this->curTextId = 0x46C; // "Ah, yes...[Link], right? } else { - Message_StartTextbox(globalCtx, 0x46A, &this->actor); + Message_StartTextbox(play, 0x46A, &this->actor); this->curTextId = 0x46A; // "Ah, yes...[Link]. } break; @@ -593,42 +606,41 @@ void EnGinkoMan_Stamp(EnGinkoMan* this, GlobalContext* globalCtx) { } } -void EnGinkoMan_SwitchAnimation(EnGinkoMan* this, GlobalContext* globalCtx) { +void EnGinkoMan_SwitchAnimation(EnGinkoMan* this, PlayState* play) { if (this->actor.xzDistToPlayer > 160.0f) { if (this->animTimer == 0) { if (this->skelAnime.animation != &object_boj_Anim_004A7C) { this->animTimer = 40; - Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, GINKO_ADVERTISING); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, GINKO_ANIM_ADVERTISING); } } } else if ((this->animTimer == 0) && (this->skelAnime.animation != &object_boj_Anim_000AC4)) { this->animTimer = 40; - Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, GINKO_AMAZED); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, GINKO_ANIM_AMAZED); } DECR(this->animTimer); } -void EnGinkoMan_FacePlayer(EnGinkoMan* this, GlobalContext* globalCtx) { +void EnGinkoMan_FacePlayer(EnGinkoMan* this, PlayState* play) { 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(play, &this->actor, &this->limb15Rot, &this->limb8Rot, this->actor.focus.pos); } else { - func_800E8F08(&this->limb15Rot, &this->limb8Rot); + Actor_TrackNone(&this->limb15Rot, &this->limb8Rot); } } -void EnGinkoMan_Update(Actor* thisx, GlobalContext* globalCtx) { +void EnGinkoMan_Update(Actor* thisx, PlayState* play) { EnGinkoMan* this = THIS; - this->actionFunc(this, globalCtx); + this->actionFunc(this, play); this->actor.focus.pos = this->actor.world.pos; this->actor.focus.pos.y += 30.0f; - EnGinkoMan_FacePlayer(this, globalCtx); + EnGinkoMan_FacePlayer(this, play); } -s32 EnGinkoMan_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, - Actor* thisx) { +s32 EnGinkoMan_OverrideLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, Actor* thisx) { EnGinkoMan* this = THIS; if (limbIndex == 15) { @@ -636,34 +648,34 @@ 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; } -void EnGinkoMan_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx) { +void EnGinkoMan_PostLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx) { } -void EnGinkoMan_Draw(Actor* thisx, GlobalContext* globalCtx) { +void EnGinkoMan_Draw(Actor* thisx, PlayState* play) { EnGinkoMan* this = THIS; - OPEN_DISPS(globalCtx->state.gfxCtx); + OPEN_DISPS(play->state.gfxCtx); - func_8012C28C(globalCtx->state.gfxCtx); + func_8012C28C(play->state.gfxCtx); - gSPSegment(POLY_OPA_DISP++, 0x08, Gfx_EnvColor(globalCtx->state.gfxCtx, 50, 80, 0, 0)); - gSPSegment(POLY_OPA_DISP++, 0x09, Gfx_EnvColor(globalCtx->state.gfxCtx, 50, 80, 0, 0)); + gSPSegment(POLY_OPA_DISP++, 0x08, Gfx_EnvColor(play->state.gfxCtx, 50, 80, 0, 0)); + gSPSegment(POLY_OPA_DISP++, 0x09, Gfx_EnvColor(play->state.gfxCtx, 50, 80, 0, 0)); gDPPipeSync(POLY_OPA_DISP++); - SkelAnime_DrawFlexOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, + SkelAnime_DrawFlexOpa(play, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, EnGinkoMan_OverrideLimbDraw, EnGinkoMan_PostLimbDraw, &this->actor); - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->state.gfxCtx); } diff --git a/src/overlays/actors/ovl_En_Ginko_Man/z_en_ginko_man.h b/src/overlays/actors/ovl_En_Ginko_Man/z_en_ginko_man.h index e605be1d6..808ea7c2f 100644 --- a/src/overlays/actors/ovl_En_Ginko_Man/z_en_ginko_man.h +++ b/src/overlays/actors/ovl_En_Ginko_Man/z_en_ginko_man.h @@ -5,7 +5,7 @@ struct EnGinkoMan; - typedef void (*EnGinkoManActionFunc)(struct EnGinkoMan*, GlobalContext*); + typedef void (*EnGinkoManActionFunc)(struct EnGinkoMan*, PlayState*); typedef struct EnGinkoMan { /* 0x000 */ Actor actor; @@ -34,12 +34,4 @@ extern const ActorInit En_Ginko_Man_InitVars; #define GINKOMAN_CHOICE_YES 0 #define GINKOMAN_CHOICE_NO 1 -typedef enum { - /* 0 */ GINKO_FLOORSMACKING, - /* 1 */ GINKO_SITTING, - /* 2 */ GINKO_REACHING, - /* 3 */ GINKO_AMAZED, - /* 4 */ GINKO_ADVERTISING, -} GinkoAnimationIndex; - #endif // Z_EN_GINKO_MAN_H 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 b509d4500..74486b30c 100644 --- a/src/overlays/actors/ovl_En_GirlA/z_en_girla.c +++ b/src/overlays/actors/ovl_En_GirlA/z_en_girla.c @@ -10,46 +10,46 @@ #define THIS ((EnGirlA*)thisx) -void EnGirlA_Init(Actor* thisx, GlobalContext* globalCtx); -void EnGirlA_Destroy(Actor* thisx, GlobalContext* globalCtx); -void EnGirlA_Update(Actor* thisx, GlobalContext* globalCtx); -void EnGirlA_Draw(Actor* thisx, GlobalContext* globalCtx); +void EnGirlA_Init(Actor* thisx, PlayState* play); +void EnGirlA_Destroy(Actor* thisx, PlayState* play); +void EnGirlA_Update(Actor* thisx, PlayState* play); +void EnGirlA_Draw(Actor* thisx, PlayState* play); -void EnGirlA_InitalUpdate(EnGirlA* this, GlobalContext* globalCtx); -void EnGirlA_Update2(EnGirlA* this, GlobalContext* globalCtx); +void EnGirlA_InitalUpdate(EnGirlA* this, PlayState* play); +void EnGirlA_Update2(EnGirlA* this, PlayState* play); -s32 EnGirlA_CanBuyPotionRed(GlobalContext* globalCtx, EnGirlA* this); -s32 EnGirlA_CanBuyPotionGreen(GlobalContext* globalCtx, EnGirlA* this); -s32 EnGirlA_CanBuyPotionBlue(GlobalContext* globalCtx, EnGirlA* this); -s32 EnGirlA_CanBuyArrows(GlobalContext* globalCtx, EnGirlA* this); -s32 EnGirlA_CanBuyNuts(GlobalContext* globalCtx, EnGirlA* this); -s32 EnGirlA_CanBuyShieldHero(GlobalContext* globalCtx, EnGirlA* this); -s32 EnGirlA_CanBuyStick(GlobalContext* globalCtx, EnGirlA* this); -s32 EnGirlA_CanBuyMaskAllNight(GlobalContext* globalCtx, EnGirlA* this); -s32 EnGirlA_CanBuyBombBagCuriosityShop(GlobalContext* globalCtx, EnGirlA* this); -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_CanBuySword(GlobalContext* globalCtx, EnGirlA* this); -s32 EnGirlA_CanBuyShieldMirror(GlobalContext* globalCtx, EnGirlA* this); -s32 EnGirlA_CanBuyFairy(GlobalContext* globalCtx, EnGirlA* this); +s32 EnGirlA_CanBuyPotionRed(PlayState* play, EnGirlA* this); +s32 EnGirlA_CanBuyPotionGreen(PlayState* play, EnGirlA* this); +s32 EnGirlA_CanBuyPotionBlue(PlayState* play, EnGirlA* this); +s32 EnGirlA_CanBuyArrows(PlayState* play, EnGirlA* this); +s32 EnGirlA_CanBuyNuts(PlayState* play, EnGirlA* this); +s32 EnGirlA_CanBuyShieldHero(PlayState* play, EnGirlA* this); +s32 EnGirlA_CanBuyStick(PlayState* play, EnGirlA* this); +s32 EnGirlA_CanBuyMaskAllNight(PlayState* play, EnGirlA* this); +s32 EnGirlA_CanBuyBombBagCuriosityShop(PlayState* play, EnGirlA* this); +s32 EnGirlA_CanBuyBombBag20BombShop(PlayState* play, EnGirlA* this); +s32 EnGirlA_CanBuyBombBag30BombShop(PlayState* play, EnGirlA* this); +s32 EnGirlA_CanBuyBombchus(PlayState* play, EnGirlA* this); +s32 EnGirlA_CanBuyBombs(PlayState* play, EnGirlA* this); +s32 EnGirlA_CanBuyBottleStolen(PlayState* play, EnGirlA* this); +s32 EnGirlA_CanBuySword(PlayState* play, EnGirlA* this); +s32 EnGirlA_CanBuyShieldMirror(PlayState* play, EnGirlA* this); +s32 EnGirlA_CanBuyFairy(PlayState* play, EnGirlA* this); -void EnGirlA_BuyBottleItem(GlobalContext* globalCtx, EnGirlA* this); -void EnGirlA_BuyArrows(GlobalContext* globalCtx, EnGirlA* this); -void EnGirlA_BuyNuts(GlobalContext* globalCtx, EnGirlA* this); -void EnGirlA_BuyShieldHero(GlobalContext* globalCtx, EnGirlA* this); -void EnGirlA_BuyStick(GlobalContext* globalCtx, EnGirlA* this); -void EnGirlA_BuyMaskAllNight(GlobalContext* globalCtx, EnGirlA* this); -void EnGirlA_BuyBombBag(GlobalContext* globalCtx, EnGirlA* this); -void EnGirlA_BuyBombchus(GlobalContext* globalCtx, EnGirlA* this); -void EnGirlA_BuyBombs(GlobalContext* globalCtx, EnGirlA* this); -void EnGirlA_BuyBottle(GlobalContext* globalCtx, EnGirlA* this); -void EnGirlA_BuySword(GlobalContext* globalCtx, EnGirlA* this); -void EnGirlA_BuyShieldMirror(GlobalContext* globalCtx, EnGirlA* this); +void EnGirlA_BuyBottleItem(PlayState* play, EnGirlA* this); +void EnGirlA_BuyArrows(PlayState* play, EnGirlA* this); +void EnGirlA_BuyNuts(PlayState* play, EnGirlA* this); +void EnGirlA_BuyShieldHero(PlayState* play, EnGirlA* this); +void EnGirlA_BuyStick(PlayState* play, EnGirlA* this); +void EnGirlA_BuyMaskAllNight(PlayState* play, EnGirlA* this); +void EnGirlA_BuyBombBag(PlayState* play, EnGirlA* this); +void EnGirlA_BuyBombchus(PlayState* play, EnGirlA* this); +void EnGirlA_BuyBombs(PlayState* play, EnGirlA* this); +void EnGirlA_BuyBottle(PlayState* play, EnGirlA* this); +void EnGirlA_BuySword(PlayState* play, EnGirlA* this); +void EnGirlA_BuyShieldMirror(PlayState* play, EnGirlA* this); -void EnGirlA_BuyFanfare(GlobalContext* globalCtx, EnGirlA* this); +void EnGirlA_BuyFanfare(PlayState* play, EnGirlA* this); const ActorInit En_GirlA_InitVars = { ACTOR_EN_GIRLA, @@ -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_STOLEN, 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_STOLEN, + EnGirlA_CanBuySword, EnGirlA_BuySword, EnGirlA_BuyFanfare }, + { OBJECT_GI_SWORD_2, GID_SWORD_RAZOR, func_800B8050, 2, 0x29F4, 0x29F5, GI_SWORD_RAZOR_STOLEN, EnGirlA_CanBuySword, EnGirlA_BuySword, EnGirlA_BuyFanfare }, - { 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, - EnGirlA_BuySword, EnGirlA_BuyFanfare }, - { 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_SWORD_3, GID_SWORD_GILDED, func_800B8050, 3, 0x29F4, 0x29F5, GI_SWORD_GILDED_STOLEN, + EnGirlA_CanBuySword, EnGirlA_BuySword, EnGirlA_BuyFanfare }, + { OBJECT_GI_SHIELD_2, GID_SHIELD_HERO, func_800B8050, 1, 0x29F6, 0x29F7, GI_SHIELD_HERO_STOLEN, + EnGirlA_CanBuyShieldHero, EnGirlA_BuyShieldHero, EnGirlA_BuyFanfare }, + { OBJECT_GI_SHIELD_3, GID_SHIELD_MIRROR, func_800B8050, 1, 0x29F6, 0x29F7, GI_SHIELD_MIRROR, EnGirlA_CanBuyShieldMirror, EnGirlA_BuyShieldMirror, EnGirlA_BuyFanfare }, }; @@ -156,7 +156,7 @@ void EnGirlA_SetupAction(EnGirlA* this, EnGirlAActionFunc action) { this->actionFunc = action; } -void EnGirlA_InitObjIndex(EnGirlA* this, GlobalContext* globalCtx) { +void EnGirlA_InitObjIndex(EnGirlA* this, PlayState* play) { s16 params = this->actor.params; //! @bug: Condition is impossible, && should be an || @@ -165,7 +165,7 @@ void EnGirlA_InitObjIndex(EnGirlA* this, GlobalContext* globalCtx) { return; } - this->objIndex = Object_GetIndex(&globalCtx->objectCtx, sShopItemEntries[params].objectId); + this->objIndex = Object_GetIndex(&play->objectCtx, sShopItemEntries[params].objectId); if (this->objIndex < 0) { Actor_MarkForDeath(&this->actor); return; @@ -175,207 +175,207 @@ void EnGirlA_InitObjIndex(EnGirlA* this, GlobalContext* globalCtx) { this->mainActionFunc = EnGirlA_InitalUpdate; } -void EnGirlA_Init(Actor* thisx, GlobalContext* globalCtx) { +void EnGirlA_Init(Actor* thisx, PlayState* play) { EnGirlA* this = THIS; - EnGirlA_InitObjIndex(this, globalCtx); + EnGirlA_InitObjIndex(this, play); } -void EnGirlA_Destroy(Actor* thisx, GlobalContext* globalCtx) { +void EnGirlA_Destroy(Actor* thisx, PlayState* play) { } -s32 EnGirlA_CanBuyPotionRed(GlobalContext* globalCtx, EnGirlA* this) { - if (!Interface_HasEmptyBottle()) { +s32 EnGirlA_CanBuyPotionRed(PlayState* play, EnGirlA* this) { + if (!Inventory_HasEmptyBottle()) { return CANBUY_RESULT_NEED_EMPTY_BOTTLE; } - if (gSaveContext.save.playerData.rupees < globalCtx->msgCtx.unk1206C) { + if (gSaveContext.save.playerData.rupees < play->msgCtx.unk1206C) { return CANBUY_RESULT_NEED_RUPEES; } return CANBUY_RESULT_SUCCESS_2; } -s32 EnGirlA_CanBuyPotionGreen(GlobalContext* globalCtx, EnGirlA* this) { - if (!Interface_HasEmptyBottle()) { +s32 EnGirlA_CanBuyPotionGreen(PlayState* play, EnGirlA* this) { + if (!Inventory_HasEmptyBottle()) { return CANBUY_RESULT_NEED_EMPTY_BOTTLE; } - if (gSaveContext.save.playerData.rupees < globalCtx->msgCtx.unk1206C) { + if (gSaveContext.save.playerData.rupees < play->msgCtx.unk1206C) { return CANBUY_RESULT_NEED_RUPEES; } return CANBUY_RESULT_SUCCESS_2; } -s32 EnGirlA_CanBuyPotionBlue(GlobalContext* globalCtx, EnGirlA* this) { +s32 EnGirlA_CanBuyPotionBlue(PlayState* play, EnGirlA* this) { if (!(gSaveContext.save.weekEventReg[53] & 8)) { return CANBUY_RESULT_CANNOT_GET_NOW; } - if (!Interface_HasEmptyBottle()) { + if (!Inventory_HasEmptyBottle()) { return CANBUY_RESULT_NEED_EMPTY_BOTTLE; } if (!(gSaveContext.save.weekEventReg[53] & 0x10)) { return CANBUY_RESULT_SUCCESS_2; } - if (gSaveContext.save.playerData.rupees < globalCtx->msgCtx.unk1206C) { + if (gSaveContext.save.playerData.rupees < play->msgCtx.unk1206C) { return CANBUY_RESULT_NEED_RUPEES; } return CANBUY_RESULT_SUCCESS_2; } -s32 EnGirlA_CanBuyArrows(GlobalContext* globalCtx, EnGirlA* this) { +s32 EnGirlA_CanBuyArrows(PlayState* play, EnGirlA* this) { 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.save.playerData.rupees < globalCtx->msgCtx.unk1206C) { + if (gSaveContext.save.playerData.rupees < play->msgCtx.unk1206C) { return CANBUY_RESULT_NEED_RUPEES; } return CANBUY_RESULT_SUCCESS_2; } -s32 EnGirlA_CanBuyNuts(GlobalContext* globalCtx, EnGirlA* this) { +s32 EnGirlA_CanBuyNuts(PlayState* play, EnGirlA* this) { if (CUR_CAPACITY(UPG_NUTS) != 0 && CUR_CAPACITY(UPG_NUTS) <= AMMO(ITEM_NUT)) { return CANBUY_RESULT_NO_ROOM; } - if (gSaveContext.save.playerData.rupees < globalCtx->msgCtx.unk1206C) { + if (gSaveContext.save.playerData.rupees < play->msgCtx.unk1206C) { return CANBUY_RESULT_NEED_RUPEES; } - if (func_80114978(ITEM_NUT) == ITEM_NONE) { + if (Item_CheckObtainability(ITEM_NUT) == ITEM_NONE) { return CANBUY_RESULT_SUCCESS_1; } return CANBUY_RESULT_SUCCESS_2; } -s32 EnGirlA_CanBuyShieldHero(GlobalContext* globalCtx, EnGirlA* this) { - if (GET_CUR_EQUIP_VALUE(EQUIP_SHIELD) != 0) { +s32 EnGirlA_CanBuyShieldHero(PlayState* play, EnGirlA* this) { + if (GET_CUR_EQUIP_VALUE(EQUIP_TYPE_SHIELD) != EQUIP_VALUE_SHIELD_NONE) { return CANBUY_RESULT_NO_ROOM; } - if (gSaveContext.save.playerData.rupees < globalCtx->msgCtx.unk1206C) { + if (gSaveContext.save.playerData.rupees < play->msgCtx.unk1206C) { return CANBUY_RESULT_NEED_RUPEES; } return CANBUY_RESULT_SUCCESS_1; } -s32 EnGirlA_CanBuyStick(GlobalContext* globalCtx, EnGirlA* this) { +s32 EnGirlA_CanBuyStick(PlayState* play, EnGirlA* this) { if (CUR_CAPACITY(UPG_STICKS) != 0 && AMMO(ITEM_STICK) >= CUR_CAPACITY(UPG_STICKS)) { return CANBUY_RESULT_NO_ROOM; } - if (gSaveContext.save.playerData.rupees < globalCtx->msgCtx.unk1206C) { + if (gSaveContext.save.playerData.rupees < play->msgCtx.unk1206C) { return CANBUY_RESULT_NEED_RUPEES; } - if (func_80114978(ITEM_STICK) == ITEM_NONE) { + if (Item_CheckObtainability(ITEM_STICK) == ITEM_NONE) { return CANBUY_RESULT_SUCCESS_1; } return CANBUY_RESULT_SUCCESS_2; } -s32 EnGirlA_CanBuyMaskAllNight(GlobalContext* globalCtx, EnGirlA* this) { - if (gSaveContext.save.playerData.rupees < globalCtx->msgCtx.unk1206C) { +s32 EnGirlA_CanBuyMaskAllNight(PlayState* play, EnGirlA* this) { + if (gSaveContext.save.playerData.rupees < play->msgCtx.unk1206C) { return CANBUY_RESULT_NEED_RUPEES; } return CANBUY_RESULT_SUCCESS_2; } -s32 EnGirlA_CanBuyBombBagCuriosityShop(GlobalContext* globalCtx, EnGirlA* this) { +s32 EnGirlA_CanBuyBombBagCuriosityShop(PlayState* play, EnGirlA* this) { if (GET_CUR_UPG_VALUE(UPG_BOMB_BAG) >= 2) { return CANBUY_RESULT_CANNOT_GET_NOW; } - if (gSaveContext.save.playerData.rupees < globalCtx->msgCtx.unk1206C) { + if (gSaveContext.save.playerData.rupees < play->msgCtx.unk1206C) { return CANBUY_RESULT_NEED_RUPEES; } return CANBUY_RESULT_SUCCESS_2; } -s32 EnGirlA_CanBuyBombBag20BombShop(GlobalContext* globalCtx, EnGirlA* this) { +s32 EnGirlA_CanBuyBombBag20BombShop(PlayState* play, EnGirlA* this) { if (GET_CUR_UPG_VALUE(UPG_BOMB_BAG) == 1) { return CANBUY_RESULT_ALREADY_HAVE; } if (GET_CUR_UPG_VALUE(UPG_BOMB_BAG) >= 2) { return CANBUY_RESULT_HAVE_BETTER; } - if (gSaveContext.save.playerData.rupees < globalCtx->msgCtx.unk1206C) { + if (gSaveContext.save.playerData.rupees < play->msgCtx.unk1206C) { return CANBUY_RESULT_NEED_RUPEES; } return CANBUY_RESULT_SUCCESS_1; } -s32 EnGirlA_CanBuyBombBag30BombShop(GlobalContext* globalCtx, EnGirlA* this) { +s32 EnGirlA_CanBuyBombBag30BombShop(PlayState* play, EnGirlA* this) { if (GET_CUR_UPG_VALUE(UPG_BOMB_BAG) == 2) { return CANBUY_RESULT_ALREADY_HAVE; } if (GET_CUR_UPG_VALUE(UPG_BOMB_BAG) == 3) { return CANBUY_RESULT_HAVE_BETTER; } - if (gSaveContext.save.playerData.rupees < globalCtx->msgCtx.unk1206C) { + if (gSaveContext.save.playerData.rupees < play->msgCtx.unk1206C) { return CANBUY_RESULT_NEED_RUPEES; } return CANBUY_RESULT_SUCCESS_1; } -s32 EnGirlA_CanBuyBombchus(GlobalContext* globalCtx, EnGirlA* this) { +s32 EnGirlA_CanBuyBombchus(PlayState* play, EnGirlA* this) { 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.save.playerData.rupees < globalCtx->msgCtx.unk1206C) { + if (gSaveContext.save.playerData.rupees < play->msgCtx.unk1206C) { return CANBUY_RESULT_NEED_RUPEES; } - if (func_80114978(ITEM_BOMBCHU) == ITEM_NONE) { + if (Item_CheckObtainability(ITEM_BOMBCHU) == ITEM_NONE) { return CANBUY_RESULT_SUCCESS_1; } return CANBUY_RESULT_SUCCESS_2; } -s32 EnGirlA_CanBuyBombs(GlobalContext* globalCtx, EnGirlA* this) { +s32 EnGirlA_CanBuyBombs(PlayState* play, EnGirlA* this) { 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.save.playerData.rupees < globalCtx->msgCtx.unk1206C) { + if (gSaveContext.save.playerData.rupees < play->msgCtx.unk1206C) { return CANBUY_RESULT_NEED_RUPEES; } return CANBUY_RESULT_SUCCESS_2; } -s32 EnGirlA_CanBuyBottle(GlobalContext* globalCtx, EnGirlA* this) { - if (gSaveContext.save.playerData.rupees < globalCtx->msgCtx.unk1206C) { +s32 EnGirlA_CanBuyBottleStolen(PlayState* play, EnGirlA* this) { + if (gSaveContext.save.playerData.rupees < play->msgCtx.unk1206C) { return CANBUY_RESULT_NEED_RUPEES; } return CANBUY_RESULT_SUCCESS_1; } -s32 EnGirlA_CanBuySword(GlobalContext* globalCtx, EnGirlA* this) { - if (gSaveContext.save.playerData.rupees < globalCtx->msgCtx.unk1206C) { +s32 EnGirlA_CanBuySword(PlayState* play, EnGirlA* this) { + if (gSaveContext.save.playerData.rupees < play->msgCtx.unk1206C) { return CANBUY_RESULT_NEED_RUPEES; } return CANBUY_RESULT_SUCCESS_1; } -s32 EnGirlA_CanBuyShieldMirror(GlobalContext* globalCtx, EnGirlA* this) { - if (GET_CUR_EQUIP_VALUE(EQUIP_SHIELD) != 0) { +s32 EnGirlA_CanBuyShieldMirror(PlayState* play, EnGirlA* this) { + if (GET_CUR_EQUIP_VALUE(EQUIP_TYPE_SHIELD) != EQUIP_VALUE_SHIELD_NONE) { return CANBUY_RESULT_NO_ROOM; } - if (gSaveContext.save.playerData.rupees < globalCtx->msgCtx.unk1206C) { + if (gSaveContext.save.playerData.rupees < play->msgCtx.unk1206C) { return CANBUY_RESULT_NEED_RUPEES; } return CANBUY_RESULT_SUCCESS_1; } -s32 EnGirlA_CanBuyFairy(GlobalContext* globalCtx, EnGirlA* this) { - if (!Interface_HasEmptyBottle()) { +s32 EnGirlA_CanBuyFairy(PlayState* play, EnGirlA* this) { + if (!Inventory_HasEmptyBottle()) { return CANBUY_RESULT_NEED_EMPTY_BOTTLE; } - if (gSaveContext.save.playerData.rupees < globalCtx->msgCtx.unk1206C) { + if (gSaveContext.save.playerData.rupees < play->msgCtx.unk1206C) { return CANBUY_RESULT_NEED_RUPEES; } return CANBUY_RESULT_SUCCESS_2; } -void EnGirlA_BuyBottleItem(GlobalContext* globalCtx, EnGirlA* this) { +void EnGirlA_BuyBottleItem(PlayState* play, EnGirlA* this) { switch (this->actor.params) { case SI_POTION_RED_1: case SI_POTION_RED_2: @@ -383,134 +383,134 @@ void EnGirlA_BuyBottleItem(GlobalContext* globalCtx, EnGirlA* this) { case SI_POTION_RED_4: case SI_POTION_RED_5: case SI_POTION_RED_6: - Item_Give(globalCtx, ITEM_POTION_RED); + Item_Give(play, ITEM_POTION_RED); break; case SI_POTION_GREEN_1: case SI_POTION_GREEN_2: case SI_POTION_GREEN_3: - Item_Give(globalCtx, ITEM_POTION_GREEN); + Item_Give(play, ITEM_POTION_GREEN); break; case SI_POTION_BLUE: - Item_Give(globalCtx, ITEM_POTION_BLUE); + Item_Give(play, ITEM_POTION_BLUE); break; case SI_FAIRY_1: case SI_FAIRY_2: - Item_Give(globalCtx, ITEM_FAIRY); + Item_Give(play, ITEM_FAIRY); break; } - func_801159EC(-globalCtx->msgCtx.unk1206C); + Rupees_ChangeBy(-play->msgCtx.unk1206C); } -void EnGirlA_BuyArrows(GlobalContext* globalCtx, EnGirlA* this) { - func_80115A14(ITEM_BOW, this->itemParams); - func_801159EC(-globalCtx->msgCtx.unk1206C); +void EnGirlA_BuyArrows(PlayState* play, EnGirlA* this) { + Inventory_ChangeAmmo(ITEM_BOW, this->itemParams); + Rupees_ChangeBy(-play->msgCtx.unk1206C); } -void EnGirlA_BuyNuts(GlobalContext* globalCtx, EnGirlA* this) { +void EnGirlA_BuyNuts(PlayState* play, EnGirlA* this) { switch (this->itemParams) { case 5: - Item_Give(globalCtx, ITEM_NUTS_5); + Item_Give(play, ITEM_NUTS_5); break; case 10: - Item_Give(globalCtx, ITEM_NUTS_10); + Item_Give(play, ITEM_NUTS_10); break; } - func_801159EC(-globalCtx->msgCtx.unk1206C); + Rupees_ChangeBy(-play->msgCtx.unk1206C); } -void EnGirlA_BuyShieldHero(GlobalContext* globalCtx, EnGirlA* this) { - Item_Give(globalCtx, ITEM_SHIELD_HERO); - func_801159EC(-globalCtx->msgCtx.unk1206C); +void EnGirlA_BuyShieldHero(PlayState* play, EnGirlA* this) { + Item_Give(play, ITEM_SHIELD_HERO); + Rupees_ChangeBy(-play->msgCtx.unk1206C); } -void EnGirlA_BuyStick(GlobalContext* globalCtx, EnGirlA* this) { - Item_Give(globalCtx, ITEM_STICK); - func_801159EC(-globalCtx->msgCtx.unk1206C); +void EnGirlA_BuyStick(PlayState* play, EnGirlA* this) { + Item_Give(play, ITEM_STICK); + Rupees_ChangeBy(-play->msgCtx.unk1206C); } -void EnGirlA_BuyMaskAllNight(GlobalContext* globalCtx, EnGirlA* this) { - Item_Give(globalCtx, ITEM_MASK_ALL_NIGHT); - func_801159EC(-globalCtx->msgCtx.unk1206C); +void EnGirlA_BuyMaskAllNight(PlayState* play, EnGirlA* this) { + Item_Give(play, ITEM_MASK_ALL_NIGHT); + Rupees_ChangeBy(-play->msgCtx.unk1206C); } -void EnGirlA_BuyBombBag(GlobalContext* globalCtx, EnGirlA* this) { +void EnGirlA_BuyBombBag(PlayState* play, EnGirlA* this) { //! @bug: Bomb Bag parameters in sShopItemEntries are 1 2 3, not 20 21 22 switch (this->itemParams) { case 20: - Item_Give(globalCtx, ITEM_BOMB_BAG_20); + Item_Give(play, ITEM_BOMB_BAG_20); break; case 21: - Item_Give(globalCtx, ITEM_BOMB_BAG_30); + Item_Give(play, ITEM_BOMB_BAG_30); break; case 22: - Item_Give(globalCtx, ITEM_BOMB_BAG_40); + Item_Give(play, ITEM_BOMB_BAG_40); break; } - func_801159EC(-globalCtx->msgCtx.unk1206C); + Rupees_ChangeBy(-play->msgCtx.unk1206C); } -void EnGirlA_BuyBombchus(GlobalContext* globalCtx, EnGirlA* this) { +void EnGirlA_BuyBombchus(PlayState* play, EnGirlA* this) { if (this->itemParams == 10) { - Item_Give(globalCtx, ITEM_BOMBCHUS_10); + Item_Give(play, ITEM_BOMBCHUS_10); } - func_801159EC(-globalCtx->msgCtx.unk1206C); + Rupees_ChangeBy(-play->msgCtx.unk1206C); } -void EnGirlA_BuyBombs(GlobalContext* globalCtx, EnGirlA* this) { +void EnGirlA_BuyBombs(PlayState* play, EnGirlA* this) { switch (this->itemParams) { case 5: - Item_Give(globalCtx, ITEM_BOMBS_5); + Item_Give(play, ITEM_BOMBS_5); break; case 10: - Item_Give(globalCtx, ITEM_BOMBS_10); + Item_Give(play, ITEM_BOMBS_10); break; case 20: - Item_Give(globalCtx, ITEM_BOMBS_20); + Item_Give(play, ITEM_BOMBS_20); break; case 30: - Item_Give(globalCtx, ITEM_BOMBS_30); + Item_Give(play, ITEM_BOMBS_30); break; } - func_801159EC(-globalCtx->msgCtx.unk1206C); + Rupees_ChangeBy(-play->msgCtx.unk1206C); } -void EnGirlA_BuyBottle(GlobalContext* globalCtx, EnGirlA* this) { - Item_Give(globalCtx, ITEM_BOTTLE); - func_801159EC(-globalCtx->msgCtx.unk1206C); +void EnGirlA_BuyBottle(PlayState* play, EnGirlA* this) { + Item_Give(play, ITEM_BOTTLE); + Rupees_ChangeBy(-play->msgCtx.unk1206C); } -void EnGirlA_BuySword(GlobalContext* globalCtx, EnGirlA* this) { +void EnGirlA_BuySword(PlayState* play, EnGirlA* this) { switch (this->itemParams) { case 1: - Item_Give(globalCtx, ITEM_SWORD_KOKIRI); + Item_Give(play, ITEM_SWORD_KOKIRI); break; case 2: - Item_Give(globalCtx, ITEM_SWORD_RAZOR); + Item_Give(play, ITEM_SWORD_RAZOR); break; case 3: - Item_Give(globalCtx, ITEM_SWORD_GILDED); + Item_Give(play, ITEM_SWORD_GILDED); break; case 4: - Item_Give(globalCtx, ITEM_SWORD_GREAT_FAIRY); + Item_Give(play, ITEM_SWORD_GREAT_FAIRY); break; } - func_801159EC(-globalCtx->msgCtx.unk1206C); + Rupees_ChangeBy(-play->msgCtx.unk1206C); } -void EnGirlA_BuyShieldMirror(GlobalContext* globalCtx, EnGirlA* this) { - Item_Give(globalCtx, ITEM_SHIELD_MIRROR); - func_801159EC(-globalCtx->msgCtx.unk1206C); +void EnGirlA_BuyShieldMirror(PlayState* play, EnGirlA* this) { + Item_Give(play, ITEM_SHIELD_MIRROR); + Rupees_ChangeBy(-play->msgCtx.unk1206C); } -// Fanfare is handled by ovl_en_ossan -void EnGirlA_BuyFanfare(GlobalContext* globalCtx, EnGirlA* this) { - func_801159EC(-globalCtx->msgCtx.unk1206C); +// Fanfare is handled by the shopkeeper +void EnGirlA_BuyFanfare(PlayState* play, EnGirlA* this) { + Rupees_ChangeBy(-play->msgCtx.unk1206C); } -void EnGirlA_DoNothing(EnGirlA* this, GlobalContext* globalCtx) { +void EnGirlA_DoNothing(EnGirlA* this, PlayState* play) { } -void EnGirlA_InitItem(GlobalContext* globalCtx, EnGirlA* this) { +void EnGirlA_InitItem(PlayState* play, EnGirlA* this) { ShopItemEntry* shopItem = &sShopItemEntries[this->actor.params]; this->actor.textId = shopItem->descriptionTextId; @@ -518,34 +518,34 @@ void EnGirlA_InitItem(GlobalContext* globalCtx, EnGirlA* this) { this->actor.draw = EnGirlA_Draw; } -void EnGirlA_Bought(GlobalContext* globalCtx, EnGirlA* this) { +void EnGirlA_Bought(PlayState* play, EnGirlA* this) { this->isOutOfStock = true; this->actor.draw = NULL; } -void EnGirlA_Restock(GlobalContext* globalCtx, EnGirlA* this) { +void EnGirlA_Restock(PlayState* play, EnGirlA* this) { this->isOutOfStock = false; this->actor.draw = EnGirlA_Draw; } // Left over from OOT -s32 EnGirlA_TrySetMaskItemDescription(EnGirlA* this, GlobalContext* globalCtx) { +s32 EnGirlA_TrySetMaskItemDescription(EnGirlA* this, PlayState* play) { return false; } -void EnGirlA_InitalUpdate(EnGirlA* this, GlobalContext* globalCtx) { +void EnGirlA_InitalUpdate(EnGirlA* this, PlayState* play) { s16 params = this->actor.params; ShopItemEntry* shopItem = &sShopItemEntries[params]; - if (Object_IsLoaded(&globalCtx->objectCtx, this->objIndex)) { + if (Object_IsLoaded(&play->objectCtx, this->objIndex)) { this->actor.flags &= ~ACTOR_FLAG_10; this->actor.objBankIndex = this->objIndex; this->actor.textId = shopItem->descriptionTextId; this->choiceTextId = shopItem->choiceTextId; // EnGirlA_TrySetMaskItemDescription always returns false - if (!EnGirlA_TrySetMaskItemDescription(this, globalCtx)) { - EnGirlA_InitItem(globalCtx, this); + if (!EnGirlA_TrySetMaskItemDescription(this, play)) { + EnGirlA_InitItem(play, this); } this->boughtFunc = EnGirlA_Bought; @@ -573,12 +573,12 @@ void EnGirlA_InitalUpdate(EnGirlA* this, GlobalContext* globalCtx) { } } -void EnGirlA_Update2(EnGirlA* this, GlobalContext* globalCtx) { +void EnGirlA_Update2(EnGirlA* this, PlayState* play) { Actor_SetScale(&this->actor, 0.25f); this->actor.shape.yOffset = 24.0f; this->actor.shape.shadowScale = 4.0f; - EnGirlA_TrySetMaskItemDescription(this, globalCtx); - this->actionFunc(this, globalCtx); + EnGirlA_TrySetMaskItemDescription(this, play); + this->actionFunc(this, play); Actor_SetFocus(&this->actor, 5.0f); this->actor.shape.rot.x = 0; if (this->isSelected) { @@ -588,18 +588,18 @@ void EnGirlA_Update2(EnGirlA* this, GlobalContext* globalCtx) { } } -void EnGirlA_Update(Actor* thisx, GlobalContext* globalCtx) { +void EnGirlA_Update(Actor* thisx, PlayState* play) { EnGirlA* this = THIS; - this->mainActionFunc(this, globalCtx); + this->mainActionFunc(this, play); } -void EnGirlA_Draw(Actor* thisx, GlobalContext* globalCtx) { +void EnGirlA_Draw(Actor* thisx, PlayState* play) { 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); + this->drawFunc(&this->actor, play, 0); } - GetItem_Draw(globalCtx, this->getItemDrawId); + GetItem_Draw(play, this->getItemDrawId); } 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 a3d8e0206..cb48f591d 100644 --- a/src/overlays/actors/ovl_En_GirlA/z_en_girla.h +++ b/src/overlays/actors/ovl_En_GirlA/z_en_girla.h @@ -5,10 +5,10 @@ struct EnGirlA; -typedef void (*EnGirlAActionFunc)(struct EnGirlA*, GlobalContext*); -typedef void (*EnGirlADrawFunc)(struct Actor*, GlobalContext*, s32); -typedef s32 (*EnGirlACanBuyFunc)(GlobalContext*, struct EnGirlA*); -typedef void (*EnGirlAShopActionFunc)(GlobalContext*, struct EnGirlA*); // Buying/Restocking +typedef void (*EnGirlAActionFunc)(struct EnGirlA*, PlayState*); +typedef void (*EnGirlADrawFunc)(struct Actor*, PlayState*, s32); +typedef s32 (*EnGirlACanBuyFunc)(PlayState*, struct EnGirlA*); +typedef void (*EnGirlAShopActionFunc)(PlayState*, struct EnGirlA*); // Buying/Restocking typedef struct ShopItemEntry { /* 0x00 */ s16 objectId; @@ -48,63 +48,63 @@ typedef struct EnGirlA { } EnGirlA; // size = 0x1CC typedef enum { - /* 0 */ CANBUY_RESULT_SUCCESS_1, - /* 1 */ CANBUY_RESULT_SUCCESS_2, - /* 2 */ CANBUY_RESULT_NO_ROOM, - /* 3 */ CANBUY_RESULT_NEED_EMPTY_BOTTLE, - /* 4 */ CANBUY_RESULT_NEED_RUPEES, - /* 5 */ CANBUY_RESULT_CANNOT_GET_NOW, - /* 6 */ CANBUY_RESULT_CANNOT_GET_NOW_2, - /* 7 */ CANBUY_RESULT_NO_ROOM_2, - /* 8 */ CANBUY_RESULT_ALREADY_HAVE, - /* 9 */ CANBUY_RESULT_HAVE_BETTER + /* 0x0 */ CANBUY_RESULT_SUCCESS_1, + /* 0x1 */ CANBUY_RESULT_SUCCESS_2, + /* 0x2 */ CANBUY_RESULT_NO_ROOM, + /* 0x3 */ CANBUY_RESULT_NEED_EMPTY_BOTTLE, + /* 0x4 */ CANBUY_RESULT_NEED_RUPEES, + /* 0x5 */ CANBUY_RESULT_CANNOT_GET_NOW, + /* 0x6 */ CANBUY_RESULT_CANNOT_GET_NOW_2, + /* 0x7 */ CANBUY_RESULT_NO_ROOM_2, + /* 0x8 */ CANBUY_RESULT_ALREADY_HAVE, + /* 0x9 */ CANBUY_RESULT_HAVE_BETTER } EnGirlACanBuyResult; typedef enum { - /* 00 */ SI_POTION_RED_1, - /* 01 */ SI_POTION_GREEN_1, - /* 02 */ SI_POTION_BLUE, - /* 03 */ SI_FAIRY_1, - /* 04 */ SI_ARROWS_LARGE_1, - /* 05 */ SI_POTION_GREEN_2, - /* 06 */ SI_SHIELD_HERO_1, - /* 07 */ SI_STICK_1, - /* 08 */ SI_ARROWS_MEDIUM_1, - /* 09 */ SI_NUTS_1, - /* 10 */ SI_POTION_RED_2, - /* 11 */ SI_FAIRY_2, - /* 12 */ SI_ARROWS_MEDIUM_2, - /* 13 */ SI_ARROWS_LARGE_2, - /* 14 */ SI_POTION_GREEN_3, - /* 15 */ SI_NUTS_2, - /* 16 */ SI_STICK_2, - /* 17 */ SI_SHIELD_HERO_2, - /* 18 */ SI_POTION_RED_3, - /* 19 */ SI_MASK_ALL_NIGHT, - /* 20 */ SI_BOMB_BAG_20_1, - /* 21 */ SI_BOMB_BAG_30_1, - /* 22 */ SI_BOMB_BAG_40, - /* 23 */ SI_BOMB_BAG_20_2, - /* 24 */ SI_BOMB_BAG_30_2, - /* 25 */ SI_BOMBCHU, - /* 26 */ SI_BOMB_1, - /* 27 */ SI_SHIELD_HERO_3, - /* 28 */ SI_ARROWS_SMALL_1, - /* 29 */ SI_POTION_RED_4, - /* 30 */ SI_BOMB_2, - /* 31 */ SI_ARROWS_SMALL_2, - /* 32 */ SI_POTION_RED_5, - /* 33 */ SI_BOMB_3, - /* 34 */ SI_ARROWS_SMALL_3, - /* 35 */ SI_POTION_RED_6, - /* 36 */ SI_BOTTLE, - /* 37 */ SI_SWORD_GREAT_FAIRY, - /* 38 */ SI_SWORD_KOKIRI, - /* 39 */ SI_SWORD_RAZOR, - /* 40 */ SI_SWORD_GILDED, - /* 41 */ SI_SHIELD_HERO_4, - /* 42 */ SI_SHIELD_MIRROR, - /* 43 */ SI_MAX + /* 0x00 */ SI_POTION_RED_1, + /* 0x01 */ SI_POTION_GREEN_1, + /* 0x02 */ SI_POTION_BLUE, + /* 0x03 */ SI_FAIRY_1, + /* 0x04 */ SI_ARROWS_LARGE_1, + /* 0x05 */ SI_POTION_GREEN_2, + /* 0x06 */ SI_SHIELD_HERO_1, + /* 0x07 */ SI_STICK_1, + /* 0x08 */ SI_ARROWS_MEDIUM_1, + /* 0x09 */ SI_NUTS_1, + /* 0x0A */ SI_POTION_RED_2, + /* 0x0B */ SI_FAIRY_2, + /* 0x0C */ SI_ARROWS_MEDIUM_2, + /* 0x0D */ SI_ARROWS_LARGE_2, + /* 0x0E */ SI_POTION_GREEN_3, + /* 0x0F */ SI_NUTS_2, + /* 0x10 */ SI_STICK_2, + /* 0x11 */ SI_SHIELD_HERO_2, + /* 0x12 */ SI_POTION_RED_3, + /* 0x13 */ SI_MASK_ALL_NIGHT, + /* 0x14 */ SI_BOMB_BAG_20_1, + /* 0x15 */ SI_BOMB_BAG_30_1, + /* 0x16 */ SI_BOMB_BAG_40, + /* 0x17 */ SI_BOMB_BAG_20_2, + /* 0x18 */ SI_BOMB_BAG_30_2, + /* 0x19 */ SI_BOMBCHU, + /* 0x1A */ SI_BOMB_1, + /* 0x1B */ SI_SHIELD_HERO_3, + /* 0x1C */ SI_ARROWS_SMALL_1, + /* 0x1D */ SI_POTION_RED_4, + /* 0x1E */ SI_BOMB_2, + /* 0x1F */ SI_ARROWS_SMALL_2, + /* 0x20 */ SI_POTION_RED_5, + /* 0x21 */ SI_BOMB_3, + /* 0x22 */ SI_ARROWS_SMALL_3, + /* 0x23 */ SI_POTION_RED_6, + /* 0x24 */ SI_BOTTLE, + /* 0x25 */ SI_SWORD_GREAT_FAIRY, + /* 0x26 */ SI_SWORD_KOKIRI, + /* 0x27 */ SI_SWORD_RAZOR, + /* 0x28 */ SI_SWORD_GILDED, + /* 0x29 */ SI_SHIELD_HERO_4, + /* 0x2A */ SI_SHIELD_MIRROR, + /* 0x2B */ SI_MAX } EnGirlAShopItemId; extern const ActorInit En_GirlA_InitVars; @@ -127,8 +127,8 @@ typedef struct { } StickDirectionPrompt; // size = 0x38 typedef struct ShopItem { - /* 0x00 */ s16 shopItemId; - /* 0x02 */ Vec3s spawnPos; -} ShopItem; // size = 0x8; + /* 0x0 */ s16 shopItemId; + /* 0x2 */ Vec3s spawnPos; +} ShopItem; // size = 0x8 #endif // Z_EN_GIRLA_H diff --git a/src/overlays/actors/ovl_En_Gk/z_en_gk.c b/src/overlays/actors/ovl_En_Gk/z_en_gk.c index 059f18c9c..235b4ba9f 100644 --- a/src/overlays/actors/ovl_En_Gk/z_en_gk.c +++ b/src/overlays/actors/ovl_En_Gk/z_en_gk.c @@ -11,27 +11,27 @@ #define THIS ((EnGk*)thisx) -void EnGk_Init(Actor* thisx, GlobalContext* globalCtx); -void EnGk_Destroy(Actor* thisx, GlobalContext* globalCtx); -void EnGk_Update(Actor* thisx, GlobalContext* globalCtx); -void EnGk_Draw(Actor* thisx, GlobalContext* globalCtx); +void EnGk_Init(Actor* thisx, PlayState* play); +void EnGk_Destroy(Actor* thisx, PlayState* play); +void EnGk_Update(Actor* thisx, PlayState* play); +void EnGk_Draw(Actor* thisx, PlayState* play); -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); +void func_80B51698(EnGk* this, PlayState* play); +void func_80B51760(EnGk* this, PlayState* play); +void func_80B51970(EnGk* this, PlayState* play); +void func_80B51B40(EnGk* this, PlayState* play); +void func_80B51D9C(EnGk* this, PlayState* play); +void func_80B51EA4(EnGk* this, PlayState* play); +void func_80B51FD0(EnGk* this, PlayState* play); +void func_80B5202C(EnGk* this, PlayState* play); +void func_80B5216C(EnGk* this, PlayState* play); +void func_80B521E8(EnGk* this, PlayState* play); +void func_80B5227C(EnGk* this, PlayState* play); +void func_80B52340(EnGk* this, PlayState* play); +void func_80B52430(EnGk* this, PlayState* play); +void func_80B5253C(EnGk* this, PlayState* play); +void func_80B525E0(EnGk* this, PlayState* play); +void func_80B52654(EnGk* this, PlayState* play); const ActorInit En_Gk_InitVars = { ACTOR_EN_GK, @@ -102,7 +102,7 @@ static DamageTable sDamageTable = { /* Powder Keg */ DMG_ENTRY(0, 0x0), }; -static AnimationInfo sAnimations[] = { +static AnimationInfo sAnimationInfo[] = { { &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 }, @@ -115,10 +115,10 @@ static AnimationInfo sAnimations[] = { Color_RGBA8 D_80B533A0 = { 255, 255, 255, 255 }; Color_RGBA8 D_80B533A4 = { 50, 150, 150, 0 }; -u16 func_80B50410(EnGk* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); +u16 func_80B50410(EnGk* this, PlayState* play) { + Player* player = GET_PLAYER(play); - if (globalCtx->sceneNum == SCENE_17SETUGEN2) { + if (play->sceneNum == SCENE_17SETUGEN2) { if (player->transformation == PLAYER_FORM_GORON) { if (!(gSaveContext.save.weekEventReg[40] & 0x80)) { switch (this->unk_31C) { @@ -164,11 +164,11 @@ u16 func_80B50410(EnGk* this, GlobalContext* globalCtx) { this->unk_1E4 |= 1; return 0xE81; } - } else if (globalCtx->sceneNum == SCENE_GORONRACE) { + } else if (play->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()) { + if (!(gSaveContext.save.weekEventReg[41] & 8) || Inventory_HasEmptyBottle()) { return 0xE89; } gSaveContext.save.weekEventReg[41] |= 4; @@ -179,7 +179,7 @@ u16 func_80B50410(EnGk* this, GlobalContext* globalCtx) { } if ((this->unk_31C == 0xE8D) || (this->unk_31C == 0xE98)) { - if (!(gSaveContext.save.weekEventReg[41] & 8) || Interface_HasEmptyBottle()) { + if (!(gSaveContext.save.weekEventReg[41] & 8) || Inventory_HasEmptyBottle()) { return 0xE89; } gSaveContext.save.weekEventReg[41] |= 4; @@ -233,18 +233,18 @@ u16 func_80B50710(EnGk* this) { return 0; } -void func_80B507A0(EnGk* this, GlobalContext* globalCtx) { +void func_80B507A0(EnGk* this, PlayState* play) { this->collider.dim.pos.x = this->actor.world.pos.x; this->collider.dim.pos.y = this->actor.world.pos.y; this->collider.dim.pos.z = this->actor.world.pos.z; - 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); + CollisionCheck_SetAC(play, &play->colChkCtx, &this->collider.base); + CollisionCheck_SetOC(play, &play->colChkCtx, &this->collider.base); + Actor_UpdateBgCheckInfo(play, &this->actor, 10.0f, 30.0f, 30.0f, 7); } -s32 func_80B50854(EnGk* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); +s32 func_80B50854(EnGk* this, PlayState* play) { + Player* player = GET_PLAYER(play); if (!(this->unk_1E4 & 0x40)) { if (player->stateFlags2 & 0x8000000) { @@ -255,11 +255,11 @@ s32 func_80B50854(EnGk* this, GlobalContext* globalCtx) { this->unk_1E4 &= ~0x40; } - if ((player->transformation == PLAYER_FORM_GORON) && (globalCtx->msgCtx.ocarinaMode == 3) && - (globalCtx->msgCtx.unk1202E == 1)) { - Flags_SetSwitch(globalCtx, ENGK_GET_3F00(&this->actor)); + if ((player->transformation == PLAYER_FORM_GORON) && (play->msgCtx.ocarinaMode == 3) && + (play->msgCtx.lastPlayedSong == OCARINA_SONG_GORON_LULLABY)) { + Flags_SetSwitch(play, ENGK_GET_3F00(&this->actor)); this->unk_2E4 = 3; - Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 3); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, 3); this->actionFunc = func_80B521E8; return true; } @@ -272,7 +272,7 @@ void func_80B50954(EnGk* this) { } } -void func_80B509A8(EnGk* this, GlobalContext* globalCtx) { +void func_80B509A8(EnGk* this, PlayState* play) { Vec3f sp4C; s16 phi_s1 = 0; @@ -296,13 +296,13 @@ void func_80B509A8(EnGk* this, GlobalContext* globalCtx) { phi_s1 = 10; } - EffectSsDtBubble_SpawnCustomColor(globalCtx, &this->unk_2E8, &this->unk_300, &sp4C, &D_80B533A0, &D_80B533A4, + EffectSsDtBubble_SpawnCustomColor(play, &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, + EffectSsDtBubble_SpawnCustomColor(play, &this->unk_2F4, &this->unk_30C, &sp4C, &D_80B533A0, &D_80B533A4, Rand_S16Offset(15, 15), phi_s1, 0); } -void func_80B50B38(EnGk* this, GlobalContext* globalCtx) { +void func_80B50B38(EnGk* this, PlayState* play) { s16 i; s16 temp; @@ -310,13 +310,13 @@ void func_80B50B38(EnGk* this, GlobalContext* globalCtx) { case 0: this->unk_2E0 = 3; for (i = 0; i < 2; i++) { - func_80B509A8(this, globalCtx); + func_80B509A8(this, play); } break; case 2: this->unk_2E0 = 3; - func_80B509A8(this, globalCtx); + func_80B509A8(this, play); break; case 1: @@ -329,7 +329,7 @@ void func_80B50B38(EnGk* this, GlobalContext* globalCtx) { case 10: case 11: this->unk_2E0 = 3; - func_80B509A8(this, globalCtx); + func_80B509A8(this, play); break; default: @@ -403,9 +403,9 @@ s32 func_80B50ED4(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; @@ -428,8 +428,8 @@ s32 func_80B50ED4(s16 arg0, s16 arg1, Vec3f* arg2, Vec3s* arg3, s32 arg4, s32 ar return true; } -s32 func_80B5100C(EnGk* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); +s32 func_80B5100C(EnGk* this, PlayState* play) { + Player* player = GET_PLAYER(play); Vec3f sp40; Vec3f sp34; @@ -455,10 +455,7 @@ s32 func_80B5100C(EnGk* this, GlobalContext* globalCtx) { return true; } -s32 func_80B5123C(EnGk* this, GlobalContext* globalCtx) { - s16 temp_v0; - s16 phi_v1; - +s32 func_80B5123C(EnGk* this, PlayState* play) { if (DECR(this->unk_34E) != 0) { this->unk_31E = 0; this->unk_320 = 0; @@ -470,7 +467,7 @@ s32 func_80B5123C(EnGk* this, GlobalContext* globalCtx) { if (Actor_IsFacingAndNearPlayer(&this->actor, 300.0f, 0x7FF8)) { this->unk_1E4 |= 8; - func_80B5100C(this, globalCtx); + func_80B5100C(this, play); } else { if (this->unk_1E4 & 8) { this->unk_34E = 20; @@ -484,32 +481,32 @@ s32 func_80B5123C(EnGk* this, GlobalContext* globalCtx) { return true; } -void func_80B51308(EnGk* this, GlobalContext* globalCtx) { +void func_80B51308(EnGk* this, PlayState* play) { s16 sp1E = this->skelAnime.curFrame; - s16 lastFrame = Animation_GetLastFrame(sAnimations[this->unk_31A].animation); + s16 lastFrame = Animation_GetLastFrame(sAnimationInfo[this->unk_31A].animation); if ((this->unk_2E4 == 7) && (sp1E == lastFrame)) { this->unk_2E4 = 8; - Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 8); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, 8); } } -void func_80B51398(EnGk* this, GlobalContext* globalCtx) { +void func_80B51398(EnGk* this, PlayState* play) { s16 sp1E = this->skelAnime.curFrame; - s16 lastFrame = Animation_GetLastFrame(sAnimations[9].animation); + s16 lastFrame = Animation_GetLastFrame(sAnimationInfo[9].animation); if ((this->unk_2E4 == 9) && (sp1E == lastFrame)) { this->unk_2E4 = 10; - Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 10); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, 10); } } -void func_80B51410(EnGk* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); +void func_80B51410(EnGk* this, PlayState* play) { + Player* player = GET_PLAYER(play); if (this->actor.xzDistToPlayer < 100.0f) { - if ((player->transformation == PLAYER_FORM_GORON) && (globalCtx->msgCtx.ocarinaMode == 3) && - (globalCtx->msgCtx.unk1202E == 0xE)) { + if ((player->transformation == PLAYER_FORM_GORON) && (play->msgCtx.ocarinaMode == 3) && + (play->msgCtx.lastPlayedSong == OCARINA_SONG_GORON_LULLABY_INTRO)) { this->unk_1E4 |= 0x20; } @@ -532,18 +529,18 @@ void func_80B51410(EnGk* this, GlobalContext* globalCtx) { } } -void func_80B51510(EnGk* this, GlobalContext* globalCtx) { +void func_80B51510(EnGk* this, PlayState* play) { s32 pad; s32 actionIndex; if (this) {} - if (Cutscene_CheckActorAction(globalCtx, 479)) { - actionIndex = Cutscene_GetActorActionIndex(globalCtx, 479); + if (Cutscene_CheckActorAction(play, 479)) { + actionIndex = Cutscene_GetActorActionIndex(play, 479); - if (globalCtx->csCtx.actorActions[actionIndex]->action != this->unk_31B) { - this->unk_31B = globalCtx->csCtx.actorActions[actionIndex]->action; - switch (globalCtx->csCtx.actorActions[actionIndex]->action) { + if (play->csCtx.actorActions[actionIndex]->action != this->unk_31B) { + this->unk_31B = play->csCtx.actorActions[actionIndex]->action; + switch (play->csCtx.actorActions[actionIndex]->action) { case 1: this->unk_31A = 0; this->unk_2E4 = 0; @@ -577,79 +574,79 @@ void func_80B51510(EnGk* this, GlobalContext* globalCtx) { break; case 7: - Flags_SetSwitch(globalCtx, ENGK_GET_3F00(&this->actor)); + Flags_SetSwitch(play, ENGK_GET_3F00(&this->actor)); break; } - Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, this->unk_31A); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, this->unk_31A); } if (this->unk_31A == 7) { - func_80B51308(this, globalCtx); + func_80B51308(this, play); } - Cutscene_ActorTranslateAndYaw(&this->actor, globalCtx, actionIndex); + Cutscene_ActorTranslateAndYaw(&this->actor, play, actionIndex); this->actor.shape.yOffset = 0.0f; } else { this->unk_31B = 0x63; } } -void func_80B51698(EnGk* this, GlobalContext* globalCtx) { +void func_80B51698(EnGk* this, PlayState* play) { s16 sp26 = this->skelAnime.curFrame; - s16 lastFrame = Animation_GetLastFrame(sAnimations[this->unk_2E4].animation); + s16 lastFrame = Animation_GetLastFrame(sAnimationInfo[this->unk_2E4].animation); if (sp26 == lastFrame) { switch (this->unk_2E4) { case 0: this->unk_2E4 = 2; - Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 2); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, 2); this->actionFunc = func_80B5216C; break; case 2: this->unk_2E4 = 0; - Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 0); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, 0); this->actionFunc = func_80B5202C; break; } } } -void func_80B51760(EnGk* this, GlobalContext* globalCtx) { +void func_80B51760(EnGk* this, PlayState* play) { s16 sp2E = this->skelAnime.curFrame; s16 lastFrame; if (this->unk_2E4 == 11) { - lastFrame = Animation_GetLastFrame(sAnimations[this->unk_2E4].animation); + lastFrame = Animation_GetLastFrame(sAnimationInfo[this->unk_2E4].animation); if (sp2E == lastFrame) { this->unk_2E4 = 5; - Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, this->unk_2E4); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, this->unk_2E4); } } else if (this->unk_2E4 == 10) { - lastFrame = Animation_GetLastFrame(sAnimations[this->unk_2E4].animation); + lastFrame = Animation_GetLastFrame(sAnimationInfo[this->unk_2E4].animation); if (sp2E == lastFrame) { this->unk_2E4 = 11; - Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, this->unk_2E4); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, this->unk_2E4); } } else { - if (Flags_GetSwitch(globalCtx, ENGK_GET_3F00(&this->actor))) { + if (Flags_GetSwitch(play, ENGK_GET_3F00(&this->actor))) { gSaveContext.save.weekEventReg[40] |= 0x40; this->actionFunc = func_80B51D9C; return; } - if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { + if (Actor_ProcessTalkRequest(&this->actor, &play->state)) { this->unk_1E4 |= 4; - this->unk_31C = func_80B50410(this, globalCtx); - Message_StartTextbox(globalCtx, this->unk_31C, &this->actor); + this->unk_31C = func_80B50410(this, play); + Message_StartTextbox(play, 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); + (gSaveContext.save.entrance != 0xD010)) { + func_800B863C(&this->actor, play); } if (this->unk_1E4 & 4) { @@ -659,10 +656,10 @@ void func_80B51760(EnGk* this, GlobalContext* globalCtx) { } } -void func_80B51970(EnGk* this, GlobalContext* globalCtx) { - u8 temp_v0 = Message_GetState(&globalCtx->msgCtx); +void func_80B51970(EnGk* this, PlayState* play) { + u8 talkState = Message_GetState(&play->msgCtx); - if (((temp_v0 == 6) || (temp_v0 == 5)) && Message_ShouldAdvance(globalCtx)) { + if (((talkState == TEXT_STATE_DONE) || (talkState == TEXT_STATE_5)) && Message_ShouldAdvance(play)) { if ((this->unk_31C == 0xE84) || (this->unk_31C == 0xE99)) { ActorCutscene_Stop(this->unk_318); this->unk_318 = ActorCutscene_GetAdditionalCutscene(this->unk_318); @@ -681,8 +678,8 @@ void func_80B51970(EnGk* this, GlobalContext* globalCtx) { return; } - this->unk_31C = func_80B50410(this, globalCtx); - Message_StartTextbox(globalCtx, this->unk_31C, &this->actor); + this->unk_31C = func_80B50410(this, play); + Message_StartTextbox(play, this->unk_31C, &this->actor); if (this->unk_31C == 0xE80) { this->unk_1E4 |= 2; } else if (this->unk_31C == 0xE89) { @@ -695,9 +692,9 @@ void func_80B51970(EnGk* this, GlobalContext* globalCtx) { if (this->unk_2E4 != 10) { if (this->unk_2E4 != 9) { this->unk_2E4 = 9; - Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 9); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, 9); } else { - func_80B51398(this, globalCtx); + func_80B51398(this, play); } } } @@ -709,11 +706,11 @@ void func_80B51970(EnGk* this, GlobalContext* globalCtx) { } } -void func_80B51B40(EnGk* this, GlobalContext* globalCtx) { - u8 temp_v0 = Message_GetState(&globalCtx->msgCtx); +void func_80B51B40(EnGk* this, PlayState* play) { + u8 talkState = Message_GetState(&play->msgCtx); - if (temp_v0 == 6) { - if (Message_ShouldAdvance(globalCtx)) { + if (talkState == TEXT_STATE_DONE) { + if (Message_ShouldAdvance(play)) { if (this->unk_1E4 & 1) { this->unk_1E4 &= ~1; this->unk_1E4 &= ~4; @@ -723,12 +720,12 @@ void func_80B51B40(EnGk* this, GlobalContext* globalCtx) { } 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); + play->nextEntrance = ENTRANCE(GORON_RACETRACK, 1); + play->transitionTrigger = TRANS_TRIGGER_START; + play->transitionType = TRANS_TYPE_03; + gSaveContext.nextTransitionType = TRANS_TYPE_03; + Parameter_AddMagic(play, ((void)0, gSaveContext.unk_3F30) + + (gSaveContext.save.playerData.doubleMagic * 0x30) + 0x30); } else { this->actionFunc = func_80B51760; } @@ -736,23 +733,23 @@ void func_80B51B40(EnGk* this, GlobalContext* globalCtx) { } this->unk_31C = func_80B50710(this); - Message_StartTextbox(globalCtx, this->unk_31C, &this->actor); + Message_StartTextbox(play, this->unk_31C, &this->actor); if (this->unk_31C == 0xE8C) { this->unk_1E4 |= 2; } } - } else if ((temp_v0 == 4) && (Message_ShouldAdvance(globalCtx) != 0)) { - switch (globalCtx->msgCtx.choiceIndex) { + } else if ((talkState == TEXT_STATE_CHOICE) && Message_ShouldAdvance(play)) { + switch (play->msgCtx.choiceIndex) { case 0: func_8019F208(); this->unk_31C = 0xE8E; - Message_StartTextbox(globalCtx, this->unk_31C, &this->actor); + Message_StartTextbox(play, this->unk_31C, &this->actor); break; case 1: func_8019F230(); this->unk_31C = 0xE8A; - Message_StartTextbox(globalCtx, this->unk_31C, &this->actor); + Message_StartTextbox(play, this->unk_31C, &this->actor); break; } } @@ -762,9 +759,9 @@ void func_80B51B40(EnGk* this, GlobalContext* globalCtx) { if (this->unk_2E4 != 10) { if (this->unk_2E4 != 9) { this->unk_2E4 = 9; - Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 9); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, 9); } else { - func_80B51398(this, globalCtx); + func_80B51398(this, play); } } } @@ -773,15 +770,15 @@ void func_80B51B40(EnGk* this, GlobalContext* globalCtx) { this->actor.world.rot.y = this->actor.shape.rot.y; } -void func_80B51D9C(EnGk* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); +void func_80B51D9C(EnGk* this, PlayState* play) { + Player* player = GET_PLAYER(play); if (ActorCutscene_GetCanPlayNext(this->unk_318)) { ActorCutscene_StartAndSetFlag(this->unk_318, &this->actor); if (this->unk_1E4 & 4) { this->unk_1E4 &= ~4; this->unk_2E4 = 6; - Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 6); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, 6); this->actionFunc = func_80B51EA4; } else { this->unk_1E4 |= 4; @@ -790,7 +787,7 @@ void func_80B51D9C(EnGk* this, GlobalContext* globalCtx) { } else { this->unk_31C = 0xE99; } - Message_StartTextbox(globalCtx, this->unk_31C, &this->actor); + Message_StartTextbox(play, this->unk_31C, &this->actor); this->actionFunc = func_80B51970; } } else { @@ -802,7 +799,7 @@ void func_80B51D9C(EnGk* this, GlobalContext* globalCtx) { func_80B50954(this); } -void func_80B51EA4(EnGk* this, GlobalContext* globalCtx) { +void func_80B51EA4(EnGk* this, PlayState* play) { Vec3s sp38; s16 sp36; @@ -832,7 +829,7 @@ void func_80B51EA4(EnGk* this, GlobalContext* globalCtx) { func_80B50954(this); } -void func_80B51FD0(EnGk* this, GlobalContext* globalCtx) { +void func_80B51FD0(EnGk* this, PlayState* play) { if (!(gSaveContext.save.weekEventReg[22] & 4)) { if (this->unk_1E4 & 2) { func_801A4748(&this->actor.projectedPos, NA_SE_EN_GOLON_KID_CRY - SFX_FLAG); @@ -842,19 +839,19 @@ void func_80B51FD0(EnGk* this, GlobalContext* globalCtx) { } } -void func_80B5202C(EnGk* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); +void func_80B5202C(EnGk* this, PlayState* play) { + Player* player = GET_PLAYER(play); - if (globalCtx->csCtx.state == 0) { - func_80B51410(this, globalCtx); + if (play->csCtx.state == 0) { + func_80B51410(this, play); } - if (!func_80B50854(this, globalCtx)) { - if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { + if (!func_80B50854(this, play)) { + if (Actor_ProcessTalkRequest(&this->actor, &play->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); + func_800B863C(&this->actor, play); if (player->transformation == PLAYER_FORM_GORON) { this->actor.textId = 0xE74; } else { @@ -863,8 +860,7 @@ void func_80B5202C(EnGk* this, GlobalContext* globalCtx) { } if (this->unk_1E4 & 2) { - if ((globalCtx->msgCtx.ocarinaMode != 1) && (globalCtx->msgCtx.ocarinaMode != 3) && - (globalCtx->csCtx.state == 0)) { + if ((play->msgCtx.ocarinaMode != 1) && (play->msgCtx.ocarinaMode != 3) && (play->csCtx.state == 0)) { func_801A4748(&this->actor.projectedPos, NA_SE_EN_GOLON_KID_CRY - SFX_FLAG); } } else { @@ -873,31 +869,31 @@ void func_80B5202C(EnGk* this, GlobalContext* globalCtx) { } } -void func_80B5216C(EnGk* this, GlobalContext* globalCtx) { - if ((Message_GetState(&globalCtx->msgCtx) == 5) && Message_ShouldAdvance(globalCtx)) { - globalCtx->msgCtx.msgMode = 0x43; - globalCtx->msgCtx.unk12023 = 4; +void func_80B5216C(EnGk* this, PlayState* play) { + if ((Message_GetState(&play->msgCtx) == TEXT_STATE_5) && Message_ShouldAdvance(play)) { + play->msgCtx.msgMode = 0x43; + play->msgCtx.stateTimer = 4; this->actionFunc = func_80B51698; } } -void func_80B521E8(EnGk* this, GlobalContext* globalCtx) { +void func_80B521E8(EnGk* this, PlayState* play) { s16 sp1E = this->skelAnime.curFrame; - s16 lastFrame = Animation_GetLastFrame(sAnimations[this->unk_2E4].animation); + s16 lastFrame = Animation_GetLastFrame(sAnimationInfo[this->unk_2E4].animation); if (sp1E == lastFrame) { this->unk_2E4 = 1; - Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 1); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, 1); this->actionFunc = func_80B5227C; } } -void func_80B5227C(EnGk* this, GlobalContext* globalCtx) { +void func_80B5227C(EnGk* this, PlayState* play) { s16 sp26 = this->skelAnime.curFrame; - s16 lastFrame = Animation_GetLastFrame(sAnimations[this->unk_2E4].animation); + s16 lastFrame = Animation_GetLastFrame(sAnimationInfo[this->unk_2E4].animation); if ((sp26 + 1) == lastFrame) { - func_800B14D4(globalCtx, 20.0f, &this->actor.home.pos); + func_800B14D4(play, 20.0f, &this->actor.home.pos); this->unk_350 = 60; if (!(this->unk_1E4 & 0x80)) { gSaveContext.save.weekEventReg[22] |= 4; @@ -908,8 +904,8 @@ void func_80B5227C(EnGk* this, GlobalContext* globalCtx) { } } -void func_80B52340(EnGk* this, GlobalContext* globalCtx) { - if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { +void func_80B52340(EnGk* this, PlayState* play) { + if (Actor_ProcessTalkRequest(&this->actor, &play->state)) { this->unk_1E4 |= 4; if (gSaveContext.eventInf[1] & 2) { this->unk_31C = 0xE90; @@ -918,28 +914,28 @@ void func_80B52340(EnGk* this, GlobalContext* globalCtx) { this->unk_31C = 0xE93; this->actionFunc = func_80B52430; } - Message_StartTextbox(globalCtx, this->unk_31C, &this->actor); + Message_StartTextbox(play, 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); + func_800B8614(&this->actor, play, 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)) { +void func_80B52430(EnGk* this, PlayState* play) { + if ((Message_GetState(&play->msgCtx) == TEXT_STATE_DONE) && Message_ShouldAdvance(play)) { switch (this->unk_31C) { case 0xE93: this->unk_31C = 0xE89; - Message_StartTextbox(globalCtx, this->unk_31C, &this->actor); + Message_StartTextbox(play, this->unk_31C, &this->actor); this->actionFunc = func_80B51B40; return; case 0xE90: this->unk_31C = 0xE91; - Message_StartTextbox(globalCtx, this->unk_31C, &this->actor); + Message_StartTextbox(play, this->unk_31C, &this->actor); return; case 0xE91: @@ -957,7 +953,7 @@ void func_80B52430(EnGk* this, GlobalContext* globalCtx) { this->actor.world.rot.y = this->actor.shape.rot.y; } -void func_80B5253C(EnGk* this, GlobalContext* globalCtx) { +void func_80B5253C(EnGk* this, PlayState* play) { s32 sp24; if (gSaveContext.save.weekEventReg[41] & 8) { @@ -966,30 +962,30 @@ void func_80B5253C(EnGk* this, GlobalContext* globalCtx) { sp24 = 0x6A; } - if (Actor_HasParent(&this->actor, globalCtx)) { + if (Actor_HasParent(&this->actor, play)) { 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); + Actor_PickUp(&this->actor, play, sp24, 300.0f, 300.0f); } } -void func_80B525E0(EnGk* this, GlobalContext* globalCtx) { - if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { +void func_80B525E0(EnGk* this, PlayState* play) { + if (Actor_ProcessTalkRequest(&this->actor, &play->state)) { this->unk_31C = 0xE92; - Message_StartTextbox(globalCtx, this->unk_31C, &this->actor); + Message_StartTextbox(play, this->unk_31C, &this->actor); this->actionFunc = func_80B52430; } else { - func_800B85E0(&this->actor, globalCtx, 400.0f, -1); + func_800B85E0(&this->actor, play, 400.0f, -1); } } -void func_80B52654(EnGk* this, GlobalContext* globalCtx) { +void func_80B52654(EnGk* this, PlayState* play) { this->unk_350 += 0x400; - if ((this->unk_1E4 & 0x80) && (globalCtx->csCtx.frames == 250)) { + if ((this->unk_1E4 & 0x80) && (play->csCtx.frames == 250)) { gSaveContext.save.weekEventReg[22] |= 4; } @@ -1002,15 +998,15 @@ void func_80B52654(EnGk* this, GlobalContext* globalCtx) { } } -void EnGk_Init(Actor* thisx, GlobalContext* globalCtx) { +void EnGk_Init(Actor* thisx, PlayState* play) { s32 pad; EnGk* this = THIS; - SkelAnime_InitFlex(globalCtx, &this->skelAnime, &object_gk_Skel_0079C0, &object_gk_Anim_00787C, this->jointTable, + SkelAnime_InitFlex(play, &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); + Collider_InitCylinder(play, &this->collider); + Collider_SetCylinder(play, &this->collider, &this->actor, &sCylinderInit); CollisionCheck_SetInfo2(&this->actor.colChkInfo, &sDamageTable, &sColChkInfoInit); this->unk_2E2 = 20; @@ -1022,20 +1018,20 @@ void EnGk_Init(Actor* thisx, GlobalContext* globalCtx) { 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_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, 5); + if (play->sceneNum == SCENE_17SETUGEN2) { + if (Flags_GetSwitch(play, 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->path = SubS_GetPathByIndex(play, ENGK_GET_F0(&this->actor), 0xF); this->actionFunc = func_80B51760; } - } else if (globalCtx->sceneNum == SCENE_GORONRACE) { + } else if (play->sceneNum == SCENE_GORONRACE) { if (gSaveContext.save.weekEventReg[33] & 0x80) { - if (gSaveContext.save.entranceIndex == 0xD010) { + if (gSaveContext.save.entrance == ENTRANCE(GORON_RACETRACK, 1)) { this->actionFunc = func_80B51760; - } else if (gSaveContext.save.entranceIndex == 0xD020) { + } else if (gSaveContext.save.entrance == ENTRANCE(GORON_RACETRACK, 2)) { this->actionFunc = func_80B52340; } else { this->actionFunc = func_80B51760; @@ -1060,45 +1056,45 @@ void EnGk_Init(Actor* thisx, GlobalContext* globalCtx) { this->unk_318 = this->actor.cutscene; this->actor.flags |= ACTOR_FLAG_10; this->actor.flags |= ACTOR_FLAG_2000000; - Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 0); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, 0); this->actionFunc = func_80B5202C; } else { this->actionFunc = func_80B52654; } } -void EnGk_Destroy(Actor* thisx, GlobalContext* globalCtx) { +void EnGk_Destroy(Actor* thisx, PlayState* play) { EnGk* this = THIS; - Collider_DestroyCylinder(globalCtx, &this->collider); + Collider_DestroyCylinder(play, &this->collider); } -void EnGk_Update(Actor* thisx, GlobalContext* globalCtx) { +void EnGk_Update(Actor* thisx, PlayState* play) { EnGk* this = THIS; - this->actionFunc(this, globalCtx); + this->actionFunc(this, play); 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); + func_80B507A0(this, play); SkelAnime_Update(&this->skelAnime); - func_800E9250(globalCtx, &this->actor, &this->unk_1D8, &this->unk_1DE, this->actor.focus.pos); + Actor_TrackPlayer(play, &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_80B5123C(this, play); } - func_80B50B38(this, globalCtx); + func_80B50B38(this, play); } if (ENGK_GET_F(&this->actor) == ENGK_F_0) { - func_80B51510(this, globalCtx); + func_80B51510(this, play); } } -s32 EnGk_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, Actor* thisx) { +s32 EnGk_OverrideLimbDraw(PlayState* play, 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) { +void EnGk_PostLimbDraw(PlayState* play, 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 }; @@ -1146,21 +1142,21 @@ void EnGk_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec this->actor.focus.pos.y = this->actor.world.pos.y + phi_f0; this->actor.focus.pos.z = this->actor.world.pos.z; - Matrix_MultiplyVector3fByState(&sp58, &this->actor.focus.pos); - Matrix_MultiplyVector3fByState(&sp34, &this->unk_2E8); - Matrix_MultiplyVector3fByState(&sp28, &this->unk_2F4); + Matrix_MultVec3f(&sp58, &this->actor.focus.pos); + Matrix_MultVec3f(&sp34, &this->unk_2E8); + Matrix_MultVec3f(&sp28, &this->unk_2F4); - Matrix_StatePush(); + Matrix_Push(); - Matrix_RotateY(this->actor.shape.rot.y, MTXMODE_NEW); - Matrix_MultiplyVector3fByState(&sp4C, &this->unk_30C); - Matrix_MultiplyVector3fByState(&sp40, &this->unk_300); + Matrix_RotateYS(this->actor.shape.rot.y, MTXMODE_NEW); + Matrix_MultVec3f(&sp4C, &this->unk_30C); + Matrix_MultVec3f(&sp40, &this->unk_300); - Matrix_StatePop(); + Matrix_Pop(); } } -void EnGk_TransformDraw(GlobalContext* globalCtx, s32 limbIndex, Actor* thisx) { +void EnGk_TransformLimbDraw(PlayState* play, s32 limbIndex, Actor* thisx) { EnGk* this = THIS; s32 phi_v0; s32 phi_v1; @@ -1182,15 +1178,15 @@ void EnGk_TransformDraw(GlobalContext* globalCtx, s32 limbIndex, Actor* thisx) { this->unk_320 + this->unk_324 + this->actor.shape.rot.y + 0x4000, &this->unk_328, &this->unk_334, phi_v0, phi_v1); - Matrix_StatePop(); + Matrix_Pop(); - Matrix_InsertTranslation(this->unk_328.x, this->unk_328.y, this->unk_328.z, MTXMODE_NEW); + 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_RotateY(this->unk_334.y, MTXMODE_APPLY); - Matrix_InsertXRotation_s(this->unk_334.x, MTXMODE_APPLY); - Matrix_InsertZRotation_s(this->unk_334.z, MTXMODE_APPLY); + Matrix_RotateYS(this->unk_334.y, MTXMODE_APPLY); + Matrix_RotateXS(this->unk_334.x, MTXMODE_APPLY); + Matrix_RotateZS(this->unk_334.z, MTXMODE_APPLY); - Matrix_StatePush(); + Matrix_Push(); break; case 9: @@ -1208,15 +1204,15 @@ void EnGk_TransformDraw(GlobalContext* globalCtx, s32 limbIndex, Actor* thisx) { func_80B50ED4(this->unk_322 + 0x4000, this->unk_324 + this->actor.shape.rot.y + 0x4000, &this->unk_33C, &this->unk_348, phi_v0, phi_v1); - Matrix_StatePop(); + Matrix_Pop(); - Matrix_InsertTranslation(this->unk_33C.x, this->unk_33C.y, this->unk_33C.z, MTXMODE_NEW); + 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_RotateY(this->unk_348.y, MTXMODE_APPLY); - Matrix_InsertXRotation_s(this->unk_348.x, MTXMODE_APPLY); - Matrix_InsertZRotation_s(this->unk_348.z, MTXMODE_APPLY); + Matrix_RotateYS(this->unk_348.y, MTXMODE_APPLY); + Matrix_RotateXS(this->unk_348.x, MTXMODE_APPLY); + Matrix_RotateZS(this->unk_348.z, MTXMODE_APPLY); - Matrix_StatePush(); + Matrix_Push(); break; } } @@ -1228,40 +1224,40 @@ TexturePtr D_80B533E4[] = { object_gk_Tex_010F20, }; -void EnGk_Draw(Actor* thisx, GlobalContext* globalCtx) { +void EnGk_Draw(Actor* thisx, PlayState* play) { s32 pad; EnGk* this = THIS; Vec3f sp5C; Vec3f sp50; - OPEN_DISPS(globalCtx->state.gfxCtx); + OPEN_DISPS(play->state.gfxCtx); - func_8012C28C(globalCtx->state.gfxCtx); + func_8012C28C(play->state.gfxCtx); if ((ENGK_GET_F(&this->actor) == ENGK_F_0) && (gSaveContext.save.weekEventReg[22] & 4)) { - 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); + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(play->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); + func_8012C2DC(play->state.gfxCtx); sp5C = this->actor.world.pos; sp50.x = 0.2f; sp50.y = 0.2f; sp50.z = 0.2f; - func_800BC620(&sp5C, &sp50, 255, globalCtx); + func_800BC620(&sp5C, &sp50, 255, play); } else { gSPSegment(POLY_OPA_DISP++, 0x08, Lib_SegmentedToVirtual(D_80B533E4[this->unk_2E0])); - SkelAnime_DrawTransformFlexOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, + SkelAnime_DrawTransformFlexOpa(play, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, EnGk_OverrideLimbDraw, EnGk_PostLimbDraw, - EnGk_TransformDraw, &this->actor); + EnGk_TransformLimbDraw, &this->actor); if (ENGK_GET_F(&this->actor) != ENGK_F_2) { - func_8012C2DC(globalCtx->state.gfxCtx); + func_8012C2DC(play->state.gfxCtx); if ((this->unk_2E4 == 0) || (this->unk_2E4 == 1) || (this->unk_2E4 == 2) || (this->unk_2E4 == 3) || (this->unk_2E4 == 4)) { sp5C.x = this->actor.world.pos.x - 15.0f; @@ -1277,9 +1273,9 @@ void EnGk_Draw(Actor* thisx, GlobalContext* globalCtx) { sp50.y = 0.2f; sp50.z = 0.2f; } - func_800BC620(&sp5C, &sp50, 255, globalCtx); + func_800BC620(&sp5C, &sp50, 255, play); } } - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->state.gfxCtx); } diff --git a/src/overlays/actors/ovl_En_Gk/z_en_gk.h b/src/overlays/actors/ovl_En_Gk/z_en_gk.h index 21863c66f..61610d684 100644 --- a/src/overlays/actors/ovl_En_Gk/z_en_gk.h +++ b/src/overlays/actors/ovl_En_Gk/z_en_gk.h @@ -5,7 +5,7 @@ struct EnGk; -typedef void (*EnGkActionFunc)(struct EnGk*, GlobalContext*); +typedef void (*EnGkActionFunc)(struct EnGk*, PlayState*); #define ENGK_GET_F(thisx) ((thisx)->params & 0xF) #define ENGK_GET_F0(thisx) (((thisx)->params & 0xF0) >> 4) @@ -21,39 +21,39 @@ enum { }; typedef struct EnGk { - /* 0x0000 */ Actor actor; - /* 0x0144 */ ColliderCylinder collider; - /* 0x0190 */ SkelAnime skelAnime; - /* 0x01D4 */ EnGkActionFunc actionFunc; - /* 0x01D8 */ Vec3s unk_1D8; - /* 0x01DE */ Vec3s unk_1DE; - /* 0x01E4 */ u16 unk_1E4; - /* 0x01E8 */ Path* path; - /* 0x01EC */ s32 unk_1EC; - /* 0x01F0 */ Vec3s jointTable[20]; - /* 0x01F0 */ Vec3s morphTable[20]; - /* 0x02E0 */ s16 unk_2E0; - /* 0x02E2 */ s16 unk_2E2; - /* 0x02E4 */ s16 unk_2E4; - /* 0x02E8 */ Vec3f unk_2E8; - /* 0x02F4 */ Vec3f unk_2F4; - /* 0x0300 */ Vec3f unk_300; - /* 0x030C */ Vec3f unk_30C; - /* 0x0318 */ s16 unk_318; - /* 0x031A */ u8 unk_31A; - /* 0x031B */ u8 unk_31B; - /* 0x031C */ u16 unk_31C; - /* 0x031E */ s16 unk_31E; - /* 0x0320 */ s16 unk_320; - /* 0x0322 */ s16 unk_322; - /* 0x0324 */ s16 unk_324; - /* 0x0328 */ Vec3f unk_328; - /* 0x0334 */ Vec3s unk_334; - /* 0x033C */ Vec3f unk_33C; - /* 0x0348 */ Vec3s unk_348; - /* 0x034E */ s16 unk_34E; - /* 0x0350 */ s16 unk_350; - /* 0x0354 */ f32 unk_354; + /* 0x000 */ Actor actor; + /* 0x144 */ ColliderCylinder collider; + /* 0x190 */ SkelAnime skelAnime; + /* 0x1D4 */ EnGkActionFunc actionFunc; + /* 0x1D8 */ Vec3s unk_1D8; + /* 0x1DE */ Vec3s unk_1DE; + /* 0x1E4 */ u16 unk_1E4; + /* 0x1E8 */ Path* path; + /* 0x1EC */ s32 unk_1EC; + /* 0x1F0 */ Vec3s jointTable[20]; + /* 0x1F0 */ Vec3s morphTable[20]; + /* 0x2E0 */ s16 unk_2E0; + /* 0x2E2 */ s16 unk_2E2; + /* 0x2E4 */ s16 unk_2E4; + /* 0x2E8 */ Vec3f unk_2E8; + /* 0x2F4 */ Vec3f unk_2F4; + /* 0x300 */ Vec3f unk_300; + /* 0x30C */ Vec3f unk_30C; + /* 0x318 */ s16 unk_318; + /* 0x31A */ u8 unk_31A; + /* 0x31B */ u8 unk_31B; + /* 0x31C */ u16 unk_31C; + /* 0x31E */ s16 unk_31E; + /* 0x320 */ s16 unk_320; + /* 0x322 */ s16 unk_322; + /* 0x324 */ s16 unk_324; + /* 0x328 */ Vec3f unk_328; + /* 0x334 */ Vec3s unk_334; + /* 0x33C */ Vec3f unk_33C; + /* 0x348 */ Vec3s unk_348; + /* 0x34E */ s16 unk_34E; + /* 0x350 */ s16 unk_350; + /* 0x354 */ f32 unk_354; } EnGk; // size = 0x358 extern const ActorInit En_Gk_InitVars; diff --git a/src/overlays/actors/ovl_En_Gm/z_en_gm.c b/src/overlays/actors/ovl_En_Gm/z_en_gm.c index 107c9a656..3ad077fec 100644 --- a/src/overlays/actors/ovl_En_Gm/z_en_gm.c +++ b/src/overlays/actors/ovl_En_Gm/z_en_gm.c @@ -12,29 +12,110 @@ #define THIS ((EnGm*)thisx) -void EnGm_Init(Actor* thisx, GlobalContext* globalCtx); -void EnGm_Destroy(Actor* thisx, GlobalContext* globalCtx); -void EnGm_Update(Actor* thisx, GlobalContext* globalCtx); -void EnGm_Draw(Actor* thisx, GlobalContext* globalCtx); +void EnGm_Init(Actor* thisx, PlayState* play); +void EnGm_Destroy(Actor* thisx, PlayState* play); +void EnGm_Update(Actor* thisx, PlayState* play); +void EnGm_Draw(Actor* thisx, PlayState* play); -void func_80950CDC(EnGm* this, GlobalContext* globalCtx); -void func_80950DB8(EnGm* this, GlobalContext* globalCtx); +void func_80950CDC(EnGm* this, PlayState* play); +void func_80950DB8(EnGm* this, PlayState* play); -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,7 +209,7 @@ static ColliderSphereInit sSphereInit = { static CollisionCheckInfoInit2 sColChkInfoInit = { 0, 0, 0, 0, MASS_IMMOVABLE }; -static AnimationInfoS D_80951CC0[] = { +static AnimationInfoS sAnimationInfo[] = { { &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 }, @@ -144,12 +225,12 @@ static AnimationInfoS D_80951CC0[] = { { &object_in2_Anim_00B990, 1.0f, 0, -1, ANIMMODE_LOOP, -4 }, }; -Actor* func_8094DEE0(EnGm* this, GlobalContext* globalCtx, u8 arg2, s16 arg3) { +Actor* func_8094DEE0(EnGm* this, PlayState* play, u8 arg2, s16 arg3) { Actor* foundActor = NULL; Actor* actor; while (true) { - actor = SubS_FindActor(globalCtx, foundActor, arg2, arg3); + actor = SubS_FindActor(play, foundActor, arg2, arg3); foundActor = actor; if (actor == NULL) { break; @@ -170,7 +251,7 @@ Actor* func_8094DEE0(EnGm* this, GlobalContext* globalCtx, u8 arg2, s16 arg3) { return foundActor; } -EnDoor* func_8094DF90(GlobalContext* globalCtx, s32 arg1) { +EnDoor* func_8094DF90(PlayState* play, s32 arg1) { s32 phi_a1; switch (arg1) { @@ -202,10 +283,10 @@ EnDoor* func_8094DF90(GlobalContext* globalCtx, s32 arg1) { phi_a1 = -1; } - return SubS_FindDoor(globalCtx, phi_a1); + return SubS_FindDoor(play, phi_a1); } -s32 func_8094DFF8(EnGm* this, GlobalContext* globalCtx) { +s32 func_8094DFF8(EnGm* this, PlayState* play) { s32 ret = false; if (this->unk_262 < 0) { @@ -220,7 +301,7 @@ s32 func_8094DFF8(EnGm* this, GlobalContext* globalCtx) { return ret; } -s32 func_8094E054(EnGm* this, GlobalContext* globalCtx, s32 arg2) { +s32 func_8094E054(EnGm* this, PlayState* play, s32 arg2) { s8 tmp = this->unk_262; s32 phi_v1 = false; s32 ret = false; @@ -236,7 +317,7 @@ s32 func_8094E054(EnGm* this, GlobalContext* globalCtx, s32 arg2) { if (phi_v1) { if (tmp >= 0) { this->unk_3E8 = arg2; - ret = SubS_ChangeAnimationByInfoS(&this->skelAnime, D_80951CC0, arg2); + ret = SubS_ChangeAnimationByInfoS(&this->skelAnime, sAnimationInfo, arg2); this->unk_3A8 = this->skelAnime.playSpeed; } } @@ -244,12 +325,12 @@ s32 func_8094E054(EnGm* this, GlobalContext* globalCtx, s32 arg2) { return ret; } -s32 func_8094E0F8(EnGm* this, GlobalContext* globalCtx) { +s32 func_8094E0F8(EnGm* this, PlayState* play) { s32 ret = false; - if ((this->unk_260 != globalCtx->roomCtx.currRoom.num) && (globalCtx->roomCtx.unk31 == 0)) { - this->unk_260 = globalCtx->roomCtx.currRoom.num; - this->unk_262 = SubS_GetObjectIndex(OBJECT_IN2, globalCtx); + if ((this->unk_260 != play->roomCtx.currRoom.num) && (play->roomCtx.unk31 == 0)) { + this->unk_260 = play->roomCtx.currRoom.num; + this->unk_262 = SubS_GetObjectIndex(OBJECT_IN2, play); this->actor.draw = NULL; this->unk_3FC = 1; } @@ -258,7 +339,7 @@ s32 func_8094E0F8(EnGm* this, GlobalContext* globalCtx) { return false; } - if ((this->unk_262 < 0) || !SubS_IsObjectLoaded(this->unk_262, globalCtx)) { + if ((this->unk_262 < 0) || !SubS_IsObjectLoaded(this->unk_262, play)) { ret = true; } else { this->actor.draw = EnGm_Draw; @@ -272,22 +353,22 @@ s32 func_8094E0F8(EnGm* this, GlobalContext* globalCtx) { return ret; } -void func_8094E1DC(EnGm* this, GlobalContext* globalCtx) { +void func_8094E1DC(EnGm* this, PlayState* play) { s32 pad; f32 temp; if (this->unk_258 == 7) { temp = this->colliderSphere.dim.modelSphere.radius * this->colliderSphere.dim.scale; this->colliderSphere.dim.worldSphere.radius = temp; - CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->colliderSphere.base); + CollisionCheck_SetOC(play, &play->colChkCtx, &this->colliderSphere.base); } else { Collider_UpdateCylinder(&this->actor, &this->colliderCylinder); - CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->colliderCylinder.base); + CollisionCheck_SetOC(play, &play->colChkCtx, &this->colliderCylinder.base); } } -void func_8094E278(GlobalContext* globalCtx) { - Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_DM_CHAR07, 115.0f, 32.0f, -121.0f, 0, 0, 0, 3); +void func_8094E278(PlayState* play) { + Actor_Spawn(&play->actorCtx, play, ACTOR_DM_CHAR07, 115.0f, 32.0f, -121.0f, 0, 0, 0, 3); } void func_8094E2D0(EnGm* this) { @@ -370,7 +451,7 @@ s16 func_8094E4D0(EnGm* this, s32 arg1) { return cutscene; } -s32 func_8094E52C(EnGm* this, GlobalContext* globalCtx) { +s32 func_8094E52C(EnGm* this, PlayState* play) { s32 pad; s16 sp2A = func_8094E4D0(this, 0); s32 ret = false; @@ -385,7 +466,7 @@ s32 func_8094E52C(EnGm* this, GlobalContext* globalCtx) { if (!(gSaveContext.save.weekEventReg[86] & 0x40) && (this->unk_3E0 == 2)) { ActorCutscene_Stop(sp2A); } else { - Camera_SetTargetActor(Play_GetCamera(globalCtx, ActorCutscene_GetCurrentCamera(sp2A)), &this->actor); + Camera_SetTargetActor(Play_GetCamera(play, ActorCutscene_GetCurrentSubCamId(sp2A)), &this->actor); } this->unk_3E0++; ret = true; @@ -393,8 +474,7 @@ s32 func_8094E52C(EnGm* this, GlobalContext* globalCtx) { case 1: if ((this->actor.child != NULL) && (this->actor.child->update != NULL)) { - Camera_SetTargetActor(Play_GetCamera(globalCtx, ActorCutscene_GetCurrentCamera(sp2A)), - this->actor.child); + Camera_SetTargetActor(Play_GetCamera(play, ActorCutscene_GetCurrentSubCamId(sp2A)), this->actor.child); } this->unk_3E0++; ret = true; @@ -410,8 +490,8 @@ s32 func_8094E52C(EnGm* this, GlobalContext* globalCtx) { return ret; } -s32 func_8094E69C(EnGm* this, GlobalContext* globalCtx) { - Camera* camera; +s32 func_8094E69C(EnGm* this, PlayState* play) { + Camera* subCam; s16 sp4A = func_8094E4D0(this, 0); s16 sp48; Vec3f sp3C; @@ -421,7 +501,7 @@ s32 func_8094E69C(EnGm* this, GlobalContext* globalCtx) { switch (this->unk_3E0) { case 0: Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_CHAIR_ROLL); - func_8094E054(this, globalCtx, 2); + func_8094E054(this, play, 2); this->unk_3E2 = 0; this->unk_3E0++; break; @@ -453,8 +533,8 @@ s32 func_8094E69C(EnGm* this, GlobalContext* globalCtx) { if (func_8094E454(this, sp4A)) { case 4: case 6: - camera = Play_GetCamera(globalCtx, ActorCutscene_GetCurrentCamera(sp4A)); - Camera_SetTargetActor(camera, &this->actor); + subCam = Play_GetCamera(play, ActorCutscene_GetCurrentSubCamId(sp4A)); + Camera_SetTargetActor(subCam, &this->actor); this->unk_3E0++; ret = true; } @@ -464,8 +544,8 @@ s32 func_8094E69C(EnGm* this, GlobalContext* globalCtx) { case 5: case 7: if ((this->actor.child != NULL) && (this->actor.child->update != NULL)) { - camera = Play_GetCamera(globalCtx, ActorCutscene_GetCurrentCamera(sp4A)); - Camera_SetTargetActor(camera, this->actor.child); + subCam = Play_GetCamera(play, ActorCutscene_GetCurrentSubCamId(sp4A)); + Camera_SetTargetActor(subCam, this->actor.child); } this->unk_3E0++; ret = true; @@ -484,7 +564,7 @@ s32 func_8094E69C(EnGm* this, GlobalContext* globalCtx) { Math_ApproachS(&this->actor.shape.rot.y, sp48, 3, 0x2AA8); this->unk_3A4 &= ~0x20; } else { - func_8094E054(this, globalCtx, 1); + func_8094E054(this, play, 1); this->actor.shape.rot.y = sp48; this->unk_3E0++; this->unk_3E2 = 0; @@ -495,13 +575,13 @@ s32 func_8094E69C(EnGm* this, GlobalContext* globalCtx) { return ret; } -s32 func_8094EA34(EnGm* this, GlobalContext* globalCtx) { +s32 func_8094EA34(EnGm* this, PlayState* play) { s32 pad[2]; Actor* al; Actor* toto; - al = func_8094DEE0(this, globalCtx, ACTORCAT_NPC, ACTOR_EN_AL); - toto = func_8094DEE0(this, globalCtx, ACTORCAT_NPC, ACTOR_EN_TOTO); + al = func_8094DEE0(this, play, ACTORCAT_NPC, ACTOR_EN_AL); + toto = func_8094DEE0(this, play, ACTORCAT_NPC, ACTOR_EN_TOTO); if ((al == NULL) || (al->update == NULL) || (toto == NULL) || (toto->update == NULL)) { this->unk_3E0++; return true; @@ -545,7 +625,7 @@ s32 func_8094EA34(EnGm* this, GlobalContext* globalCtx) { return true; } -s32 func_8094EB1C(EnGm* this, GlobalContext* globalCtx) { +s32 func_8094EB1C(EnGm* this, PlayState* play) { s32 pad[2]; s32 ret = false; s16 oldYaw; @@ -558,7 +638,7 @@ s32 func_8094EB1C(EnGm* this, GlobalContext* globalCtx) { break; } Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_CHAIR_ROLL); - func_8094E054(this, globalCtx, 2); + func_8094E054(this, play, 2); this->unk_3E2 = 0; this->unk_3E0++; @@ -588,7 +668,7 @@ s32 func_8094EB1C(EnGm* this, GlobalContext* globalCtx) { Math_ApproachS(&this->actor.shape.rot.y, oldYaw, 3, 0x2AA8); this->unk_3A4 &= ~0x20; } else { - func_8094E054(this, globalCtx, 1); + func_8094E054(this, play, 1); this->actor.shape.rot.y = oldYaw; this->unk_3E2 = 0; this->unk_3E0++; @@ -599,7 +679,7 @@ s32 func_8094EB1C(EnGm* this, GlobalContext* globalCtx) { return ret; } -s32* func_8094EDBC(EnGm* this, GlobalContext* globalCtx) { +s32* func_8094EDBC(EnGm* this, PlayState* play) { switch (this->unk_258) { case 1: this->unk_3E4 = func_8094E52C; @@ -648,16 +728,16 @@ s32* func_8094EDBC(EnGm* this, GlobalContext* globalCtx) { return NULL; } -s32 func_8094EE84(EnGm* this, GlobalContext* globalCtx) { +s32 func_8094EE84(EnGm* this, PlayState* play) { s32 ret = false; if (this->unk_3A4 & 7) { - if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { + if (Actor_ProcessTalkRequest(&this->actor, &play->state)) { 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); + this->unk_264 = func_8094EDBC(this, play); if ((this->unk_258 == 5) && !(gSaveContext.save.weekEventReg[50] & 1) && !(gSaveContext.save.weekEventReg[51] & 0x80) && !(gSaveContext.save.weekEventReg[75] & 2)) { @@ -677,13 +757,13 @@ s32 func_8094EE84(EnGm* this, GlobalContext* globalCtx) { return ret; } -s32 func_8094EFC4(EnGm* this, GlobalContext* globalCtx) { +s32 func_8094EFC4(EnGm* this, PlayState* play) { s32 ret = false; - if (globalCtx->csCtx.state != 0) { + if (play->csCtx.state != 0) { if (this->unk_3F8 == 0) { - if ((globalCtx->sceneNum == SCENE_MILK_BAR) && (gSaveContext.sceneSetupIndex == 2)) { - func_8094E054(this, globalCtx, 0); + if ((play->sceneNum == SCENE_MILK_BAR) && (gSaveContext.sceneSetupIndex == 2)) { + func_8094E054(this, play, 0); this->unk_258 = 255; } this->unk_259 = 255; @@ -691,7 +771,7 @@ s32 func_8094EFC4(EnGm* this, GlobalContext* globalCtx) { } ret = true; } else if (this->unk_3F8 != 0) { - if (globalCtx->sceneNum == SCENE_MILK_BAR) { + if (play->sceneNum == SCENE_MILK_BAR) { this->unk_400 = 0; } this->unk_3F8 = 0; @@ -699,12 +779,12 @@ s32 func_8094EFC4(EnGm* this, GlobalContext* globalCtx) { return ret; } -Actor* func_8094F074(EnGm* this, GlobalContext* globalCtx) { +Actor* func_8094F074(EnGm* this, PlayState* play) { Actor* actor; switch (this->unk_258) { case 1: - actor = func_8094DEE0(this, globalCtx, ACTORCAT_NPC, ACTOR_EN_RECEPGIRL); + actor = func_8094DEE0(this, play, ACTORCAT_NPC, ACTOR_EN_RECEPGIRL); break; case 2: @@ -712,11 +792,11 @@ Actor* func_8094F074(EnGm* this, GlobalContext* globalCtx) { break; case 3: - actor = func_8094DEE0(this, globalCtx, ACTORCAT_NPC, ACTOR_EN_TAB); + actor = func_8094DEE0(this, play, ACTORCAT_NPC, ACTOR_EN_TAB); break; default: - actor = &GET_PLAYER(globalCtx)->actor; + actor = &GET_PLAYER(play)->actor; break; } @@ -775,14 +855,14 @@ 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.currentTextId; +void func_8094F3D0(EnGm* this, PlayState* play) { + Player* player = GET_PLAYER(play); + s32 talkState = Message_GetState(&play->msgCtx); + s32 textId = play->msgCtx.currentTextId; - if ((&this->actor == player->targetActor) && ((var < 0xFF) || (var > 0x200)) && (sp28 == 3) && - (this->unk_3F0 == 3)) { - if ((globalCtx->state.frames % 3) == 0) { + if ((&this->actor == player->targetActor) && ((textId < 0xFF) || (textId > 0x200)) && (talkState == TEXT_STATE_3) && + (this->prevTalkState == TEXT_STATE_3)) { + if ((play->state.frames % 3) == 0) { if (this->unk_3AC == 120.0f) { this->unk_3AC = 0.0f; } else { @@ -792,54 +872,55 @@ void func_8094F3D0(EnGm* this, GlobalContext* globalCtx) { } else { 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, MTXMODE_APPLY); - this->unk_3F0 = sp28; + Matrix_Translate(this->unk_3B0, 0.0f, 0.0f, MTXMODE_APPLY); + this->prevTalkState = talkState; } -s32 func_8094F4EC(EnGm* this, GlobalContext* globalCtx) { +s32 func_8094F4EC(EnGm* this, PlayState* play) { if ((this->unk_258 != 6) && (this->unk_3E8 == 12)) { this->unk_3A4 &= ~0x2000; - func_8094E054(this, globalCtx, 8); + func_8094E054(this, play, 8); } return true; } -s32 func_8094F53C(EnGm* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); - 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); +s32 func_8094F53C(EnGm* this, PlayState* play) { + Player* player = GET_PLAYER(play); + u16 sp32 = play->msgCtx.currentTextId; + Actor* al = func_8094DEE0(this, play, ACTORCAT_NPC, ACTOR_EN_AL); + Actor* toto = func_8094DEE0(this, play, ACTORCAT_NPC, ACTOR_EN_TOTO); if (player->stateFlags1 & 0x440) { this->unk_3A4 |= 0x400; if (this->unk_3A6 != sp32) { switch (sp32) { case 0x2B13: - func_8094E054(this, globalCtx, 2); + func_8094E054(this, play, 2); break; case 0x2B14: case 0x2B18: - func_8094E054(this, globalCtx, 0); + func_8094E054(this, play, 0); break; case 0x2B16: - func_8094E054(this, globalCtx, 1); + func_8094E054(this, play, 1); break; case 0x2B15: - func_8094E054(this, globalCtx, 5); + func_8094E054(this, play, 5); break; case 0x2B17: - func_8094E054(this, globalCtx, 6); + func_8094E054(this, play, 6); break; default: if ((this->unk_3E8 == 7) || (this->unk_3E8 == 8)) { this->unk_3A4 |= 0x2000; - func_8094E054(this, globalCtx, 12); + func_8094E054(this, play, 12); } break; } @@ -875,21 +956,21 @@ s32 func_8094F53C(EnGm* this, GlobalContext* globalCtx) { this->unk_3A4 &= ~0x400; this->unk_3CA = this->unk_3C8; this->unk_3CC = 4; - func_8094F4EC(this, globalCtx); + func_8094F4EC(this, play); } if (this->unk_18C != NULL) { - this->unk_18C(this, globalCtx); + this->unk_18C(this, play); } - if ((this->unk_3E8 == 6) && !(globalCtx->actorCtx.unk5 & 0x20) && Animation_OnFrame(&this->skelAnime, 20.0f)) { + if ((this->unk_3E8 == 6) && !(play->actorCtx.unk5 & 0x20) && Animation_OnFrame(&this->skelAnime, 20.0f)) { Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_HANKO); } return false; } -s32 func_8094F7D0(EnGm* this, GlobalContext* globalCtx, struct_80133038_arg2* arg2, u8 arg3, s16 arg4) { +s32 func_8094F7D0(EnGm* this, PlayState* play, ScheduleOutput* scheduleOutput, u8 arg3, s16 arg4) { u8 sp4F = ENGM_GET_FF(&this->actor); Vec3s* sp48; Vec3f sp3C; @@ -898,18 +979,18 @@ s32 func_8094F7D0(EnGm* this, GlobalContext* globalCtx, struct_80133038_arg2* ar s32 pad; s32 ret = false; - this->unk_234 = NULL; - actor = func_8094DEE0(this, globalCtx, arg3, arg4); + this->timePath = NULL; + actor = func_8094DEE0(this, play, arg3, arg4); - if (D_80951A0C[arg2->unk0] >= 0) { - this->unk_234 = SubS_GetAdditionalPath(globalCtx, sp4F, D_80951A0C[arg2->unk0]); + if (D_80951A0C[scheduleOutput->result] >= 0) { + this->timePath = SubS_GetAdditionalPath(play, sp4F, D_80951A0C[scheduleOutput->result]); } if ((actor != NULL) && (actor->update != NULL)) { - if (this->unk_234 != NULL) { - sp48 = Lib_SegmentedToVirtual(this->unk_234->points); - Math_Vec3s_ToVec3f(&sp3C, &sp48[this->unk_234->count - 2]); - Math_Vec3s_ToVec3f(&sp30, &sp48[this->unk_234->count - 1]); + 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); @@ -919,8 +1000,8 @@ 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.save.time - 0x3FFC; +s32 func_8094F904(EnGm* this, PlayState* play, ScheduleOutput* scheduleOutput) { + u16 sp56 = SCHEDULE_TIME_NOW; u8 sp55 = ENGM_GET_FF(&this->actor); EnDoor* door; Vec3s* sp4C; @@ -929,16 +1010,16 @@ s32 func_8094F904(EnGm* this, GlobalContext* globalCtx, struct_80133038_arg2* ar s32 pad; s32 ret = false; - this->unk_234 = NULL; - door = func_8094DF90(globalCtx, arg2->unk0); + this->timePath = NULL; + door = func_8094DF90(play, scheduleOutput->result); - if (D_80951A0C[arg2->unk0] >= 0) { - this->unk_234 = SubS_GetAdditionalPath(globalCtx, sp55, D_80951A0C[arg2->unk0]); + if (D_80951A0C[scheduleOutput->result] >= 0) { + this->timePath = SubS_GetAdditionalPath(play, sp55, D_80951A0C[scheduleOutput->result]); } if ((door != NULL) && (door->dyna.actor.update != NULL)) { - if (this->unk_234 != NULL) { - sp4C = Lib_SegmentedToVirtual(this->unk_234->points); + 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); @@ -952,12 +1033,12 @@ s32 func_8094F904(EnGm* this, GlobalContext* globalCtx, struct_80133038_arg2* ar this->unk_261 = 75; } - this->unk_3B8 = arg2->unk8 - arg2->unk4; - this->unk_3BA = sp56 - arg2->unk4; + this->unk_3B8 = scheduleOutput->time1 - scheduleOutput->time0; + this->unk_3BA = sp56 - scheduleOutput->time0; this->actor.flags &= ~ACTOR_FLAG_1; this->unk_3A4 |= 0x100; this->unk_3A4 |= 0x200; - func_8094E054(this, globalCtx, 7); + func_8094E054(this, play, 7); this->actor.gravity = 0.0f; ret = true; } @@ -965,62 +1046,64 @@ 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.save.time - 0x3FFC; +s32 func_8094FAC4(EnGm* this, PlayState* play, ScheduleOutput* scheduleOutput) { + u16 sp2E = SCHEDULE_TIME_NOW; u16 phi_v1; u8 sp2B = ENGM_GET_FF(&this->actor); - s32 pad; + u16 tmp; + s16 pad; s32 ret = false; - this->unk_234 = NULL; - if (D_80951A0C[arg2->unk0] >= 0) { - this->unk_234 = SubS_GetAdditionalPath(globalCtx, sp2B, D_80951A0C[arg2->unk0]); + this->timePath = NULL; + if (D_80951A0C[scheduleOutput->result] >= 0) { + this->timePath = SubS_GetAdditionalPath(play, sp2B, D_80951A0C[scheduleOutput->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 = scheduleOutput->time0; } - if (arg2->unk8 < phi_v1) { - this->unk_248 = (phi_v1 - arg2->unk8) + 0xFFFF; + if (scheduleOutput->time1 < phi_v1) { + this->timePathTotalTime = (phi_v1 - scheduleOutput->time1) + 0xFFFF; } else { - this->unk_248 = arg2->unk8 - phi_v1; + this->timePathTotalTime = scheduleOutput->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; + tmp = phi_v1 = this->timePath->count - (SUBS_TIME_PATHING_ORDER - 1); + this->timePathWaypointTime = this->timePathTotalTime / tmp; + this->timePathWaypoint = + (this->timePathElapsedTime / this->timePathWaypointTime) + (SUBS_TIME_PATHING_ORDER - 1); this->unk_3A4 &= ~0x8; this->unk_3A4 &= ~0x10; SubS_UpdateFlags(&this->unk_3A4, 3, 7); this->unk_3A4 |= 0x100; this->unk_3A4 |= 0x200; - func_8094E054(this, globalCtx, 7); + func_8094E054(this, play, 7); this->actor.gravity = -1.0f; ret = true; } return ret; } -s32 func_8094FCC4(EnGm* this, GlobalContext* globalCtx, struct_80133038_arg2* arg2) { +s32 func_8094FCC4(EnGm* this, PlayState* play, ScheduleOutput* scheduleOutput) { static Vec3f D_80951D90 = { 64.0f, 0.0f, -122.0f }; s32 ret = false; - if (func_8094F7D0(this, globalCtx, arg2, ACTORCAT_NPC, ACTOR_EN_TAB)) { + if (func_8094F7D0(this, play, scheduleOutput, ACTORCAT_NPC, ACTOR_EN_TAB)) { if (this->unk_258 == 0) { Math_Vec3f_Copy(&this->actor.world.pos, &D_80951D90); SubS_UpdateFlags(&this->unk_3A4, 3, 7); - func_8094E054(this, globalCtx, 0); + func_8094E054(this, play, 0); } else { - func_8094E054(this, globalCtx, 9); + func_8094E054(this, play, 9); this->skelAnime.moveFlags = 0x10; } this->unk_3A4 |= 0x100; @@ -1030,11 +1113,11 @@ 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, PlayState* play, ScheduleOutput* scheduleOutput) { s32 ret = false; - if (func_8094F7D0(this, globalCtx, arg2, ACTORCAT_NPC, ACTOR_EN_RECEPGIRL)) { - func_8094E054(this, globalCtx, 11); + if (func_8094F7D0(this, play, scheduleOutput, ACTORCAT_NPC, ACTOR_EN_RECEPGIRL)) { + func_8094E054(this, play, 11); SubS_UpdateFlags(&this->unk_3A4, 3, 7); this->unk_3A4 |= 0x100; this->unk_3A4 |= 0x200; @@ -1043,13 +1126,14 @@ 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, PlayState* play, ScheduleOutput* scheduleOutput) { 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); + al = func_8094DEE0(this, play, ACTORCAT_NPC, ACTOR_EN_AL); + if (func_8094F7D0(this, play, scheduleOutput, ACTORCAT_NPC, ACTOR_EN_TOTO) && (al != NULL) && + (al->update != NULL)) { + func_8094E054(this, play, 11); SubS_UpdateFlags(&this->unk_3A4, 3, 7); this->unk_268 = al; if (!(gSaveContext.save.weekEventReg[86] & 0x20)) { @@ -1064,7 +1148,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, PlayState* play, ScheduleOutput* scheduleOutput) { static Vec3f D_80951D9C = { 64.0f, 0.0f, -122.0f }; u8 sp4F = ENGM_GET_FF(&this->actor); Vec3s* sp48; @@ -1073,16 +1157,16 @@ 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 = SubS_GetAdditionalPath(globalCtx, sp4F, D_80951A0C[arg2->unk0]); + if (D_80951A0C[scheduleOutput->result] >= 0) { + this->timePath = SubS_GetAdditionalPath(play, sp4F, D_80951A0C[scheduleOutput->result]); } - if (this->unk_234 != NULL) { - sp48 = Lib_SegmentedToVirtual(this->unk_234->points); - Math_Vec3s_ToVec3f(&sp3C, &sp48[this->unk_234->count - 2]); - Math_Vec3s_ToVec3f(&sp30, &sp48[this->unk_234->count - 1]); + 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) { @@ -1091,11 +1175,11 @@ s32 func_8094FF04(EnGm* this, GlobalContext* globalCtx, struct_80133038_arg2* ar this->unk_3C8 = 4; this->unk_3CA = 4; this->unk_3CC = 8; - func_8094E054(this, globalCtx, 0); - func_8094E278(globalCtx); + func_8094E054(this, play, 0); + func_8094E278(play); } else { Math_Vec3f_Copy(&this->actor.world.pos, &sp30); - func_8094E054(this, globalCtx, 9); + func_8094E054(this, play, 9); this->skelAnime.moveFlags = 0x10; } this->unk_400 = 0; @@ -1106,7 +1190,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, PlayState* play, ScheduleOutput* scheduleOutput) { static Vec3f D_80951DA8 = { 278.0f, 0.0f, 223.0f }; static Vec3s D_80951DB4 = { 0x0000, 0xC000, 0x0000 }; s32 pad; @@ -1117,11 +1201,11 @@ s32 func_80950088(EnGm* this, GlobalContext* globalCtx, struct_80133038_arg2* ar SubS_UpdateFlags(&this->unk_3A4, 3, 7); this->unk_3A4 |= (0x2000 | 0x100); this->unk_3A4 |= 0x200; - func_8094E054(this, globalCtx, 12); + func_8094E054(this, play, 12); return true; } -s32 func_80950120(EnGm* this, GlobalContext* globalCtx, struct_80133038_arg2* arg2) { +s32 func_80950120(EnGm* this, PlayState* play, ScheduleOutput* scheduleOutput) { static Vec3f D_80951DBC = { -525.0f, 214.0f, 515.0f }; static Vec3s D_80951DC8 = { 0x0000, 0x38E0, 0x0000 }; s32 pad; @@ -1132,11 +1216,11 @@ s32 func_80950120(EnGm* this, GlobalContext* globalCtx, struct_80133038_arg2* ar SubS_UpdateFlags(&this->unk_3A4, 3, 7); this->unk_3A4 |= (0x800 | 0x100); this->unk_3A4 |= 0x200; - func_8094E054(this, globalCtx, 4); + func_8094E054(this, play, 4); return true; } -s32 func_809501B8(EnGm* this, GlobalContext* globalCtx, struct_80133038_arg2* arg2) { +s32 func_809501B8(EnGm* this, PlayState* play, ScheduleOutput* scheduleOutput) { static Vec3f D_80951DD0 = { -334.0f, 225.0f, 903.0f }; static Vec3s D_80951DDC = { 0x0000, 0x7FFF, 0x0000 }; s32 pad; @@ -1153,11 +1237,11 @@ s32 func_809501B8(EnGm* this, GlobalContext* globalCtx, struct_80133038_arg2* ar this->unk_3CC = 8; this->actor.targetMode = 6; this->unk_3B4 = 60.0f; - func_8094E054(this, globalCtx, 10); + func_8094E054(this, play, 10); return true; } -s32 func_80950280(EnGm* this, GlobalContext* globalCtx, struct_80133038_arg2* arg2) { +s32 func_80950280(EnGm* this, PlayState* play, ScheduleOutput* scheduleOutput) { s32 phi_v1; this->actor.flags |= ACTOR_FLAG_1; @@ -1168,33 +1252,33 @@ s32 func_80950280(EnGm* this, GlobalContext* globalCtx, struct_80133038_arg2* ar this->unk_3CC = 8; this->unk_3B4 = 40.0f; - switch (arg2->unk0) { + switch (scheduleOutput->result) { case 1: - phi_v1 = func_8094FD88(this, globalCtx, arg2); + phi_v1 = func_8094FD88(this, play, scheduleOutput); break; case 2: - phi_v1 = func_8094FE10(this, globalCtx, arg2); + phi_v1 = func_8094FE10(this, play, scheduleOutput); break; case 3: - phi_v1 = func_8094FCC4(this, globalCtx, arg2); + phi_v1 = func_8094FCC4(this, play, scheduleOutput); break; case 5: - phi_v1 = func_8094FF04(this, globalCtx, arg2); + phi_v1 = func_8094FF04(this, play, scheduleOutput); break; case 6: - phi_v1 = func_80950088(this, globalCtx, arg2); + phi_v1 = func_80950088(this, play, scheduleOutput); break; case 7: - phi_v1 = func_809501B8(this, globalCtx, arg2); + phi_v1 = func_809501B8(this, play, scheduleOutput); break; case 8: - phi_v1 = func_80950120(this, globalCtx, arg2); + phi_v1 = func_80950120(this, play, scheduleOutput); break; case 9: @@ -1209,7 +1293,7 @@ s32 func_80950280(EnGm* this, GlobalContext* globalCtx, struct_80133038_arg2* ar case 18: case 19: case 20: - phi_v1 = func_8094F904(this, globalCtx, arg2); + phi_v1 = func_8094F904(this, play, scheduleOutput); break; case 21: @@ -1222,7 +1306,7 @@ s32 func_80950280(EnGm* this, GlobalContext* globalCtx, struct_80133038_arg2* ar case 28: case 29: case 30: - phi_v1 = func_8094FAC4(this, globalCtx, arg2); + phi_v1 = func_8094FAC4(this, play, scheduleOutput); break; default: @@ -1233,7 +1317,7 @@ s32 func_80950280(EnGm* this, GlobalContext* globalCtx, struct_80133038_arg2* ar return phi_v1; } -s32 func_80950388(EnGm* this, GlobalContext* globalCtx) { +s32 func_80950388(EnGm* this, PlayState* play) { Vec3f sp2C; Vec3f sp20; @@ -1246,22 +1330,22 @@ s32 func_80950388(EnGm* this, GlobalContext* globalCtx) { return false; } -s32 func_809503F8(EnGm* this, GlobalContext* globalCtx) { +s32 func_809503F8(EnGm* this, PlayState* play) { s32 pad; if (this->unk_3E8 == 9) { if (Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) { this->actor.shape.shadowDraw = ActorShadow_DrawCircle; SubS_UpdateFlags(&this->unk_3A4, 3, 7); - func_8094E054(this, globalCtx, 0); + func_8094E054(this, play, 0); } else { - AnimationContext_SetMoveActor(globalCtx, &this->actor, &this->skelAnime, 1.0f); + AnimationContext_SetMoveActor(play, &this->actor, &this->skelAnime, 1.0f); } } return false; } -s32 func_80950490(EnGm* this, GlobalContext* globalCtx) { +s32 func_80950490(EnGm* this, PlayState* play) { static s32 D_80951DE4[] = { 1, 5, 5, 1, 6, 5, 1, 5, 6, 1, 5, 6, }; @@ -1273,7 +1357,7 @@ s32 func_80950490(EnGm* this, GlobalContext* globalCtx) { this->unk_3CA = 1; this->unk_3CC = 8; this->unk_400 = 1; - func_8094E054(this, globalCtx, 3); + func_8094E054(this, play, 3); } return false; } @@ -1288,17 +1372,17 @@ s32 func_80950490(EnGm* this, GlobalContext* globalCtx) { this->unk_3C8 = 4; this->unk_3CA = 4; this->unk_3CC = 8; - func_8094E054(this, globalCtx, 0); - func_8094E278(globalCtx); + func_8094E054(this, play, 0); + func_8094E278(play); } else { - AnimationContext_SetMoveActor(globalCtx, &this->actor, &this->skelAnime, 1.0f); + AnimationContext_SetMoveActor(play, &this->actor, &this->skelAnime, 1.0f); } break; case 5: case 6: if (Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) { - func_8094E054(this, globalCtx, D_80951DE4[this->unk_3F4]); + func_8094E054(this, play, D_80951DE4[this->unk_3F4]); this->unk_3F4++; this->unk_3F4 %= 12; this->unk_3DE = Rand_S16Offset(30, 30); @@ -1307,7 +1391,7 @@ s32 func_80950490(EnGm* this, GlobalContext* globalCtx) { default: if (DECR(this->unk_3DE) == 0) { - func_8094E054(this, globalCtx, D_80951DE4[this->unk_3F4]); + func_8094E054(this, play, D_80951DE4[this->unk_3F4]); this->unk_3F4++; this->unk_3F4 %= 12; this->unk_3DE = Rand_S16Offset(30, 30); @@ -1317,15 +1401,15 @@ s32 func_80950490(EnGm* this, GlobalContext* globalCtx) { return false; } -s32 func_80950690(EnGm* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); +s32 func_80950690(EnGm* this, PlayState* play) { + Player* player = GET_PLAYER(play); Actor* al; Actor* toto; switch (this->unk_258) { case 2: - al = func_8094DEE0(this, globalCtx, ACTORCAT_NPC, ACTOR_EN_AL); - toto = func_8094DEE0(this, globalCtx, ACTORCAT_NPC, ACTOR_EN_TOTO); + al = func_8094DEE0(this, play, ACTORCAT_NPC, ACTOR_EN_AL); + toto = func_8094DEE0(this, play, ACTORCAT_NPC, ACTOR_EN_TOTO); if ((al != NULL) && (al->update != NULL) && (toto != NULL) && (toto->update != NULL) && !(player->stateFlags1 & 0x40)) { if (DECR(this->unk_3B8) == 0) { @@ -1351,19 +1435,19 @@ s32 func_80950690(EnGm* this, GlobalContext* globalCtx) { break; } - SubS_FillLimbRotTables(globalCtx, this->unk_3D8, this->unk_3D2, ARRAY_COUNT(this->unk_3D8)); + SubS_FillLimbRotTables(play, this->unk_3D8, this->unk_3D2, ARRAY_COUNT(this->unk_3D8)); return false; } -s32 func_80950804(EnGm* this, GlobalContext* globalCtx) { +s32 func_80950804(EnGm* this, PlayState* play) { EnDoor* door; Vec3f sp38; s32 pad; f32 temp_f0; - door = func_8094DF90(globalCtx, this->unk_258); - if (!func_8013AD6C(globalCtx) && (this->unk_3C4 != 0)) { + door = func_8094DF90(play, this->unk_258); + if (!SubS_InCsMode(play) && (this->timePathTimeSpeed != 0)) { if ((door != NULL) && (door->dyna.actor.update != NULL)) { if ((this->unk_3BA / (f32)this->unk_3B8) <= 0.9f) { door->unk_1A7 = this->unk_261; @@ -1378,7 +1462,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); } @@ -1387,77 +1471,79 @@ s32 func_80950804(EnGm* this, GlobalContext* globalCtx) { return false; } -s32 func_8095097C(EnGm* this, GlobalContext* globalCtx) { - f32 sp7C[0x109]; +s32 func_8095097C(EnGm* this, PlayState* play) { + 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(play, 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(play)) { + 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(play)) { + 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); } return false; } -void func_80950C24(EnGm* this, GlobalContext* globalCtx) { +void func_80950C24(EnGm* this, PlayState* play) { switch (this->unk_258) { case 1: - func_80950388(this, globalCtx); + func_80950388(this, play); break; case 2: case 6: case 7: case 8: - func_80950690(this, globalCtx); + func_80950690(this, play); break; case 3: - func_809503F8(this, globalCtx); + func_809503F8(this, play); break; case 5: - func_80950490(this, globalCtx); + func_80950490(this, play); break; case 9: @@ -1472,7 +1558,7 @@ void func_80950C24(EnGm* this, GlobalContext* globalCtx) { case 18: case 19: case 20: - func_80950804(this, globalCtx); + func_80950804(this, play); break; case 21: @@ -1485,42 +1571,41 @@ void func_80950C24(EnGm* this, GlobalContext* globalCtx) { case 28: case 29: case 30: - func_8095097C(this, globalCtx); + func_8095097C(this, play); break; } Math_ApproachS(&this->actor.shape.rot.y, this->actor.world.rot.y, 3, 0x2AA8); } -void func_80950CDC(EnGm* this, GlobalContext* globalCtx) { - u32* unk_14 = &gSaveContext.save.daySpeed; - struct_80133038_arg2 sp20; +void func_80950CDC(EnGm* this, PlayState* play) { + ScheduleOutput 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(play, D_80951820, &sp20) || + ((this->unk_258 != sp20.result) && !func_80950280(this, play, &sp20))) { this->actor.shape.shadowDraw = NULL; this->actor.flags &= ~ACTOR_FLAG_1; - sp20.unk0 = 0; + sp20.result = 0; } else { this->actor.shape.shadowDraw = ActorShadow_DrawCircle; this->actor.flags |= ACTOR_FLAG_1; } - this->unk_258 = sp20.unk0; - this->unk_268 = func_8094F074(this, globalCtx); - func_80950C24(this, globalCtx); + this->unk_258 = sp20.result; + this->unk_268 = func_8094F074(this, play); + func_80950C24(this, play); } -void func_80950DB8(EnGm* this, GlobalContext* globalCtx) { +void func_80950DB8(EnGm* this, PlayState* play) { s32 pad; Vec3f sp40; Vec3f sp34; Actor* al; - if (func_8010BF58(&this->actor, globalCtx, this->unk_264, this->unk_3E4, &this->unk_25C)) { + if (func_8010BF58(&this->actor, play, this->unk_264, this->unk_3E4, &this->unk_25C)) { SubS_UpdateFlags(&this->unk_3A4, 3, 7); - al = func_8094DEE0(this, globalCtx, ACTORCAT_NPC, ACTOR_EN_AL); + al = func_8094DEE0(this, play, ACTORCAT_NPC, ACTOR_EN_AL); if ((this->unk_258 == 2) && (al != NULL) && (al->update != NULL)) { this->unk_268 = al; this->unk_3B8 = Rand_S16Offset(60, 60); @@ -1539,26 +1624,26 @@ void func_80950DB8(EnGm* this, GlobalContext* globalCtx) { Math_ApproachS(&this->actor.shape.rot.y, Math_Vec3f_Yaw(&sp34, &sp40), 4, 0x2AA8); } } - SubS_FillLimbRotTables(globalCtx, this->unk_3D8, this->unk_3D2, ARRAY_COUNT(this->unk_3D8)); + SubS_FillLimbRotTables(play, this->unk_3D8, this->unk_3D2, ARRAY_COUNT(this->unk_3D8)); } -void func_80950F2C(EnGm* this, GlobalContext* globalCtx) { +void func_80950F2C(EnGm* this, PlayState* play) { s32 sp50[] = { 0, 0, 3, 2 }; - Player* player = GET_PLAYER(globalCtx); + Player* player = GET_PLAYER(play); s32 pad; Vec3f sp3C; Vec3f sp30; s32 sp2C; s16 yaw; - if (Cutscene_CheckActorAction(globalCtx, 526)) { - sp2C = globalCtx->csCtx.actorActions[Cutscene_GetActorActionIndex(globalCtx, 526)]->action; + if (Cutscene_CheckActorAction(play, 526)) { + sp2C = play->csCtx.actorActions[Cutscene_GetActorActionIndex(play, 526)]->action; if (this->unk_259 != (sp2C & 0xFF)) { if (sp2C == 3) { Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_CHAIR_ROLL); } this->unk_259 = sp2C; - func_8094E054(this, globalCtx, sp50[sp2C]); + func_8094E054(this, play, sp50[sp2C]); } if ((this->unk_259 == 3) && (this->unk_268 != NULL) && (this->unk_268->update != NULL)) { @@ -1575,21 +1660,20 @@ void func_80950F2C(EnGm* this, GlobalContext* globalCtx) { } } -void EnGm_Init(Actor* thisx, GlobalContext* globalCtx) { +void EnGm_Init(Actor* thisx, PlayState* play) { EnGm* this = THIS; - if (func_8094DEE0(this, globalCtx, ACTORCAT_NPC, ACTOR_EN_GM)) { + if (func_8094DEE0(this, play, ACTORCAT_NPC, ACTOR_EN_GM)) { Actor_MarkForDeath(&this->actor); return; } ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 22.0f); - SkelAnime_InitFlex(globalCtx, &this->skelAnime, &object_in2_Skel_0078B0, NULL, this->jointTable, this->morphTable, - 20); + SkelAnime_InitFlex(play, &this->skelAnime, &object_in2_Skel_0078B0, NULL, this->jointTable, this->morphTable, 20); this->unk_3E8 = -1; - func_8094E054(this, globalCtx, 0); - Collider_InitAndSetCylinder(globalCtx, &this->colliderCylinder, &this->actor, &sCylinderInit); - Collider_InitAndSetSphere(globalCtx, &this->colliderSphere, &this->actor, &sSphereInit); + func_8094E054(this, play, 0); + Collider_InitAndSetCylinder(play, &this->colliderCylinder, &this->actor, &sCylinderInit); + Collider_InitAndSetSphere(play, &this->colliderSphere, &this->actor, &sSphereInit); CollisionCheck_SetInfo2(&this->actor.colChkInfo, DamageTable_Get(0x16), &sColChkInfoInit); Actor_SetScale(&this->actor, 0.01f); this->actor.room = -1; @@ -1597,52 +1681,52 @@ void EnGm_Init(Actor* thisx, GlobalContext* globalCtx) { this->unk_3FC = 0; this->unk_258 = 0; this->actionFunc = func_80950CDC; - this->actionFunc(this, globalCtx); + this->actionFunc(this, play); } -void EnGm_Destroy(Actor* thisx, GlobalContext* globalCtx) { +void EnGm_Destroy(Actor* thisx, PlayState* play) { EnGm* this = THIS; - Collider_DestroyCylinder(globalCtx, &this->colliderCylinder); - Collider_DestroySphere(globalCtx, &this->colliderSphere); + Collider_DestroyCylinder(play, &this->colliderCylinder); + Collider_DestroySphere(play, &this->colliderSphere); } -void EnGm_Update(Actor* thisx, GlobalContext* globalCtx) { +void EnGm_Update(Actor* thisx, PlayState* play) { EnGm* this = THIS; - if (!func_8094E0F8(this, globalCtx)) { - if (!func_8094EE84(this, globalCtx) && func_8094EFC4(this, globalCtx)) { - func_80950F2C(this, globalCtx); - func_8094DFF8(this, globalCtx); + if (!func_8094E0F8(this, play)) { + if (!func_8094EE84(this, play) && func_8094EFC4(this, play)) { + func_80950F2C(this, play); + func_8094DFF8(this, play); func_8094E2D0(this); return; } - this->actionFunc(this, globalCtx); + this->actionFunc(this, play); - func_8094F53C(this, globalCtx); + func_8094F53C(this, play); if (this->unk_258 != 0) { - func_8094DFF8(this, globalCtx); + func_8094DFF8(this, play); 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, play, this->unk_3B4, 30.0f, PLAYER_AP_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); + Actor_UpdateBgCheckInfo(play, &this->actor, 30.0f, 12.0f, 0.0f, 4); } - func_8094E1DC(this, globalCtx); + func_8094E1DC(this, play); } } } -s32 EnGm_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, Actor* thisx) { +s32 EnGm_OverrideLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, Actor* thisx) { s32 pad; EnGm* this = THIS; s32 phi_v0; if (limbIndex == 16) { - func_8094F3D0(this, globalCtx); + func_8094F3D0(this, play); } switch (limbIndex) { @@ -1671,7 +1755,7 @@ s32 EnGm_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, return false; } -void EnGm_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx) { +void EnGm_PostLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx) { static Vec3f D_80951E24 = { 1400.0f, 0.0f, 0.0f }; EnGm* this = THIS; s32 pad[4]; @@ -1679,81 +1763,81 @@ 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); } - OPEN_DISPS(globalCtx->state.gfxCtx); + OPEN_DISPS(play->state.gfxCtx); if ((limbIndex == 15) && (this->unk_3A4 & 0x800)) { gSPDisplayList(POLY_OPA_DISP++, object_in2_DL_007528); } - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->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) { +void EnGm_TransformLimbDraw(PlayState* play, 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(); } } -void EnGm_Draw(Actor* thisx, GlobalContext* globalCtx) { +void EnGm_Draw(Actor* thisx, PlayState* play) { static TexturePtr D_80951E30[] = { object_in2_Tex_0054A8, object_in2_Tex_005028, object_in2_Tex_006828, object_in2_Tex_005028, object_in2_Tex_005CE8, object_in2_Tex_006C68 }; EnGm* this = THIS; if ((this->unk_258 != 0) && (this->unk_262 >= 0)) { - OPEN_DISPS(globalCtx->state.gfxCtx); + OPEN_DISPS(play->state.gfxCtx); - func_8012C28C(globalCtx->state.gfxCtx); + func_8012C28C(play->state.gfxCtx); gSPSegment(POLY_OPA_DISP++, 0x08, Lib_SegmentedToVirtual(D_80951E30[this->unk_3CE])); - SkelAnime_DrawTransformFlexOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, + SkelAnime_DrawTransformFlexOpa(play, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, EnGm_OverrideLimbDraw, EnGm_PostLimbDraw, EnGm_TransformLimbDraw, &this->actor); - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->state.gfxCtx); } } 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..0f74de16b 100644 --- a/src/overlays/actors/ovl_En_Gm/z_en_gm.h +++ b/src/overlays/actors/ovl_En_Gm/z_en_gm.h @@ -5,75 +5,75 @@ struct EnGm; -typedef void (*EnGmActionFunc)(struct EnGm*, GlobalContext*); -typedef s32 (*EnGmUnkFunc)(struct EnGm*, GlobalContext*); -typedef void (*EnGmUnkFunc2)(struct EnGm*, GlobalContext*); +typedef void (*EnGmActionFunc)(struct EnGm*, PlayState*); +typedef s32 (*EnGmUnkFunc)(struct EnGm*, PlayState*); +typedef void (*EnGmUnkFunc2)(struct EnGm*, PlayState*); #define ENGM_GET_FF(thisx) ((thisx)->params & 0xFF) typedef struct EnGm { - /* 0x0000 */ Actor actor; - /* 0x0144 */ SkelAnime skelAnime; - /* 0x0188 */ EnGmActionFunc actionFunc; - /* 0x018C */ EnGmUnkFunc2 unk_18C; - /* 0x0190 */ ColliderCylinder colliderCylinder; - /* 0x01DC */ ColliderSphere colliderSphere; - /* 0x0234 */ Path* 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; - /* 0x0258 */ u8 unk_258; - /* 0x0259 */ u8 unk_259; - /* 0x025C */ s32 unk_25C; - /* 0x0260 */ s8 unk_260; - /* 0x0261 */ s8 unk_261; - /* 0x0262 */ s8 unk_262; - /* 0x0264 */ s32* unk_264; - /* 0x0268 */ Actor* unk_268; - /* 0x026C */ UNK_TYPE1 unk26C[0xC]; - /* 0x0278 */ Vec3f unk_278; - /* 0x0284 */ Vec3f unk_284; - /* 0x0290 */ Vec3f unk_290; - /* 0x029C */ Vec3f unk_29C; - /* 0x02A8 */ Vec3s unk_2A8; - /* 0x02AE */ Vec3s unk_2AE; - /* 0x02B4 */ Vec3s jointTable[20]; - /* 0x032C */ Vec3s morphTable[20]; - /* 0x03A4 */ u16 unk_3A4; - /* 0x03A6 */ u16 unk_3A6; - /* 0x03A8 */ f32 unk_3A8; - /* 0x03AC */ f32 unk_3AC; - /* 0x03B0 */ f32 unk_3B0; - /* 0x03B4 */ f32 unk_3B4; - /* 0x03B8 */ s16 unk_3B8; - /* 0x03BA */ s16 unk_3BA; - /* 0x03BC */ s16 unk_3BC; - /* 0x03BE */ s16 unk_3BE; - /* 0x03C0 */ s16 unk_3C0; - /* 0x03C2 */ s16 unk_3C2; - /* 0x03C4 */ s16 unk_3C4; - /* 0x03C6 */ s16 unk_3C6; - /* 0x03C8 */ s16 unk_3C8; - /* 0x03CA */ s16 unk_3CA; - /* 0x03CC */ s16 unk_3CC; - /* 0x03CE */ s16 unk_3CE; - /* 0x03D0 */ s16 unk_3D0; - /* 0x03D2 */ s16 unk_3D2[3]; - /* 0x03D8 */ s16 unk_3D8[3]; - /* 0x03DE */ s16 unk_3DE; - /* 0x03E0 */ s16 unk_3E0; - /* 0x03E2 */ s16 unk_3E2; - /* 0x03E4 */ EnGmUnkFunc unk_3E4; - /* 0x03E8 */ s32 unk_3E8; - /* 0x03EC */ UNK_TYPE1 unk3EC[0x4]; - /* 0x03F0 */ s32 unk_3F0; - /* 0x03F4 */ s32 unk_3F4; - /* 0x03F8 */ s32 unk_3F8; - /* 0x03FC */ s32 unk_3FC; - /* 0x0400 */ s32 unk_400; + /* 0x000 */ Actor actor; + /* 0x144 */ SkelAnime skelAnime; + /* 0x188 */ EnGmActionFunc actionFunc; + /* 0x18C */ EnGmUnkFunc2 unk_18C; + /* 0x190 */ ColliderCylinder colliderCylinder; + /* 0x1DC */ ColliderSphere colliderSphere; + /* 0x234 */ Path* timePath; + /* 0x238 */ Vec3f timePathTargetPos; + /* 0x244 */ f32 timePathProgress; + /* 0x248 */ s32 timePathTotalTime; + /* 0x24C */ s32 timePathWaypointTime; + /* 0x250 */ s32 timePathWaypoint; + /* 0x254 */ s32 timePathElapsedTime; + /* 0x258 */ u8 unk_258; + /* 0x259 */ u8 unk_259; + /* 0x25C */ s32 unk_25C; + /* 0x260 */ s8 unk_260; + /* 0x261 */ s8 unk_261; + /* 0x262 */ s8 unk_262; + /* 0x264 */ s32* unk_264; + /* 0x268 */ Actor* unk_268; + /* 0x26C */ UNK_TYPE1 unk_26C[0xC]; + /* 0x278 */ Vec3f unk_278; + /* 0x284 */ Vec3f unk_284; + /* 0x290 */ Vec3f unk_290; + /* 0x29C */ Vec3f unk_29C; + /* 0x2A8 */ Vec3s unk_2A8; + /* 0x2AE */ Vec3s unk_2AE; + /* 0x2B4 */ Vec3s jointTable[20]; + /* 0x32C */ Vec3s morphTable[20]; + /* 0x3A4 */ u16 unk_3A4; + /* 0x3A6 */ u16 unk_3A6; + /* 0x3A8 */ f32 unk_3A8; + /* 0x3AC */ f32 unk_3AC; + /* 0x3B0 */ f32 unk_3B0; + /* 0x3B4 */ f32 unk_3B4; + /* 0x3B8 */ s16 unk_3B8; + /* 0x3BA */ s16 unk_3BA; + /* 0x3BC */ s16 unk_3BC; + /* 0x3BE */ s16 unk_3BE; + /* 0x3C0 */ s16 unk_3C0; + /* 0x3C2 */ s16 unk_3C2; + /* 0x3C4 */ s16 timePathTimeSpeed; + /* 0x3C6 */ s16 unk_3C6; + /* 0x3C8 */ s16 unk_3C8; + /* 0x3CA */ s16 unk_3CA; + /* 0x3CC */ s16 unk_3CC; + /* 0x3CE */ s16 unk_3CE; + /* 0x3D0 */ s16 unk_3D0; + /* 0x3D2 */ s16 unk_3D2[3]; + /* 0x3D8 */ s16 unk_3D8[3]; + /* 0x3DE */ s16 unk_3DE; + /* 0x3E0 */ s16 unk_3E0; + /* 0x3E2 */ s16 unk_3E2; + /* 0x3E4 */ EnGmUnkFunc unk_3E4; + /* 0x3E8 */ s32 unk_3E8; + /* 0x3EC */ UNK_TYPE1 unk3EC[0x4]; + /* 0x3F0 */ s32 prevTalkState; + /* 0x3F4 */ s32 unk_3F4; + /* 0x3F8 */ s32 unk_3F8; + /* 0x3FC */ s32 unk_3FC; + /* 0x400 */ s32 unk_400; } EnGm; // size = 0x404 extern const ActorInit En_Gm_InitVars; diff --git a/src/overlays/actors/ovl_En_Go/z_en_go.c b/src/overlays/actors/ovl_En_Go/z_en_go.c index 57c8dc044..491e1c95e 100644 --- a/src/overlays/actors/ovl_En_Go/z_en_go.c +++ b/src/overlays/actors/ovl_En_Go/z_en_go.c @@ -14,20 +14,20 @@ #define THIS ((EnGo*)thisx) -void EnGo_Init(Actor* thisx, GlobalContext* globalCtx); -void EnGo_Destroy(Actor* thisx, GlobalContext* globalCtx); -void EnGo_Update(Actor* thisx, GlobalContext* globalCtx); +void EnGo_Init(Actor* thisx, PlayState* play); +void EnGo_Destroy(Actor* thisx, PlayState* play); +void EnGo_Update(Actor* thisx, PlayState* play); -void func_80A14798(EnGo* this, GlobalContext* globalCtx); -void func_80A149B0(EnGo* this, GlobalContext* globalCtx); -void func_80A14B30(EnGo* this, GlobalContext* globalCtx); -void func_80A14E14(EnGo* this, GlobalContext* globalCtx); -void func_80A14E74(EnGo* this, GlobalContext* globalCtx); -void func_80A14EB0(EnGo* this, GlobalContext* globalCtx); -void func_80A14FC8(EnGo* this, GlobalContext* globalCtx); -void func_80A153FC(EnGo* this, GlobalContext* globalCtx); -void func_80A157C4(EnGo* this, GlobalContext* globalCtx); -void func_80A15FEC(Actor* thisx, GlobalContext* globalCtx); +void func_80A14798(EnGo* this, PlayState* play); +void func_80A149B0(EnGo* this, PlayState* play); +void func_80A14B30(EnGo* this, PlayState* play); +void func_80A14E14(EnGo* this, PlayState* play); +void func_80A14E74(EnGo* this, PlayState* play); +void func_80A14EB0(EnGo* this, PlayState* play); +void func_80A14FC8(EnGo* this, PlayState* play); +void func_80A153FC(EnGo* this, PlayState* play); +void func_80A157C4(EnGo* this, PlayState* play); +void func_80A15FEC(Actor* thisx, PlayState* play); static s32 D_80A16100[] = { 0x00150800, 0x40010022, 0x00150200, 0x180E0E10, 0x0C0F0E11, 0x0C0F0E12, 0x0C0F0E13, 0x0C0F0E14, 0x0C111502, @@ -186,17 +186,17 @@ static DamageTable sDamageTable = { /* Powder Keg */ DMG_ENTRY(1, 0x0), }; -static AnimationInfoS sAnimations[] = { - { &object_oF1d_map_Anim_011D98, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, - { &object_oF1d_map_Anim_011D98, 1.0f, 0, -1, ANIMMODE_LOOP, -4 }, - { &object_oF1d_map_Anim_012DE0, 2.0f, 0, -1, ANIMMODE_ONCE, 0 }, - { &object_oF1d_map_Anim_012DE0, 2.0f, 0, -1, ANIMMODE_ONCE, -4 }, - { &object_oF1d_map_Anim_012DE0, -2.0f, 0, -1, ANIMMODE_ONCE, 0 }, - { &object_oF1d_map_Anim_003E28, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, - { &object_oF1d_map_Anim_003E28, 1.0f, 0, -1, ANIMMODE_LOOP, -4 }, - { &object_oF1d_map_Anim_0039D8, 1.0f, 0, -1, ANIMMODE_ONCE, -4 }, - { &object_oF1d_map_Anim_003650, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, - { &object_oF1d_map_Anim_0135E8, 1.0f, 0, -1, ANIMMODE_ONCE, -4 }, +static AnimationInfoS sAnimationInfo[] = { + { &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, ANIMMODE_LOOP, 0 }, { &object_taisou_Anim_0016C8, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, @@ -213,7 +213,7 @@ static AnimationInfoS sAnimations[] = { { &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++) { @@ -233,15 +233,15 @@ 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, PlayState* play) { s32 pad; s32 i; s32 flag = false; f32 temp; - OPEN_DISPS(globalCtx->state.gfxCtx); + OPEN_DISPS(play->state.gfxCtx); - func_8012C2DC(globalCtx->state.gfxCtx); + func_8012C2DC(play->state.gfxCtx); for (i = 0; i < 32; i++, ptr++) { @@ -249,37 +249,36 @@ 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; gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 195, 225, 235, (u8)temp); gSPSegment(POLY_XLU_DISP++, 0x08, - Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, (ptr->unk_02 + (i * 3)) * 3, + Gfx_TwoTexScroll(play->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(&play->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); + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_XLU_DISP++, gGoronSteamModelDL); - Matrix_StatePop(); - if (globalCtx->state.gfxCtx) {} + Matrix_Pop(); + if (play->state.gfxCtx) {} } } - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->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++) { @@ -299,7 +298,7 @@ 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, PlayState* play) { static TexturePtr D_80A16644[] = { gDust8Tex, gDust7Tex, gDust6Tex, gDust5Tex, gDust4Tex, gDust3Tex, gDust2Tex, gDust1Tex, }; @@ -317,18 +316,18 @@ void func_80A115B4(EnGoStruct ptr[], GlobalContext* globalCtx) { u8 flag = false; f32 temp; - OPEN_DISPS(globalCtx->state.gfxCtx); + OPEN_DISPS(play->state.gfxCtx); - func_8012C2DC(globalCtx->state.gfxCtx); + func_8012C2DC(play->state.gfxCtx); for (i = 0; i < 32; i++, ptr++) { if ((ptr->unk_00 >= 4) && (ptr->unk_00 < 7)) { if (!flag) { POLY_XLU_DISP = Gfx_CallSetupDL(POLY_XLU_DISP, 0); - gSPDisplayList(POLY_XLU_DISP++, object_oF1d_map_DL_014CF0); + gSPDisplayList(POLY_XLU_DISP++, gGoronDustMaterialDL); flag = true; } - Matrix_StatePush(); + Matrix_Push(); temp = (f32)ptr->unk_02 / ptr->unk_01; @@ -337,25 +336,24 @@ 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(&play->billboardMtxF); - gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), - G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); 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) {} + if (play->state.gfxCtx) {} } - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->state.gfxCtx); } #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, }; @@ -400,10 +398,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; @@ -449,13 +448,13 @@ 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, PlayState* play, Gfx* arg2, Gfx* arg3, u8 arg4) { s32 i; u8 flag = false; - OPEN_DISPS(globalCtx->state.gfxCtx); + OPEN_DISPS(play->state.gfxCtx); - func_8012C28C(globalCtx->state.gfxCtx); + func_8012C28C(play->state.gfxCtx); for (i = 0; i < 16; i++, ptr++) { if (ptr->unk_00 == arg4) { @@ -464,26 +463,27 @@ 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), + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_OPA_DISP++, arg3); } - Matrix_StatePop(); + Matrix_Pop(); } } - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->state.gfxCtx); } #else +void func_80A11EC0(EnGoStruct* ptr, PlayState* play, Gfx* arg2, Gfx* arg3, u8 arg4); #pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Go/func_80A11EC0.s") #endif @@ -513,16 +513,16 @@ 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_80A11144(this->unk_3F8, globalCtx); - func_80A115B4(this->unk_3F8, globalCtx); +void func_80A1213C(EnGo* this, PlayState* play) { + func_80A11EC0(this->unk_3F8, play, gGoronLargeSnowballFragmentMaterialDL, gGoronLargeSnowballFragmentModelDL, 1); + func_80A11EC0(this->unk_3F8, play, gGoronMediumSnowballFragmentMaterialDL, gGoronMediumSnowballFragmentModelDL, 2); + func_80A11EC0(this->unk_3F8, play, gGoronSmallSnowballFragmentMaterialDL, gGoronSmallSnowballFragmentModelDL, 3); + func_80A11144(this->unk_3F8, play); + func_80A115B4(this->unk_3F8, play); } -s32 func_80A121F4(GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); +s32 func_80A121F4(PlayState* play) { + Player* player = GET_PLAYER(play); if ((player->transformation == PLAYER_FORM_GORON) && (player->stateFlags3 & 0x2000000)) { return false; @@ -530,14 +530,15 @@ s32 func_80A121F4(GlobalContext* globalCtx) { return true; } -s32 func_80A1222C(EnGo* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); +s32 func_80A1222C(EnGo* this, PlayState* play) { + Player* player = GET_PLAYER(play); s32 ret = false; - if (((player->transformation == PLAYER_FORM_GORON) && (globalCtx->msgCtx.ocarinaMode == 3) && - (globalCtx->msgCtx.unk1202E == 1) && (this->unk_3EC == 0) && (this->actor.xzDistToPlayer < 400.0f)) || - (!(gSaveContext.save.weekEventReg[22] & 4) && (globalCtx->sceneNum == SCENE_16GORON_HOUSE) && - (gSaveContext.sceneSetupIndex == 0) && (this->unk_3EC == 0) && (globalCtx->csCtx.currentCsIndex == 1))) { + if (((player->transformation == PLAYER_FORM_GORON) && (play->msgCtx.ocarinaMode == 3) && + (play->msgCtx.lastPlayedSong == OCARINA_SONG_GORON_LULLABY) && (this->unk_3EC == 0) && + (this->actor.xzDistToPlayer < 400.0f)) || + (!(gSaveContext.save.weekEventReg[22] & 4) && (play->sceneNum == SCENE_16GORON_HOUSE) && + (gSaveContext.sceneSetupIndex == 0) && (this->unk_3EC == 0) && (play->csCtx.currentCsIndex == 1))) { ret = true; } return ret; @@ -565,7 +566,7 @@ s32 func_80A122EC(EnGo* this) { return false; } -void func_80A123A0(EnGo* this, GlobalContext* globalCtx) { +void func_80A123A0(EnGo* this, PlayState* play) { Vec3f sp2C; Math_Vec3f_Copy(&sp2C, &this->actor.world.pos); @@ -579,21 +580,21 @@ void func_80A123A0(EnGo* this, GlobalContext* globalCtx) { this->colliderSphere.dim.worldSphere.radius = this->colliderSphere.dim.modelSphere.radius * this->colliderSphere.dim.scale; - if (func_80A121F4(globalCtx)) { - CollisionCheck_SetAT(globalCtx, &globalCtx->colChkCtx, &this->colliderSphere.base); + if (func_80A121F4(play)) { + CollisionCheck_SetAT(play, &play->colChkCtx, &this->colliderSphere.base); } - CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->colliderSphere.base); - CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->colliderSphere.base); + CollisionCheck_SetAC(play, &play->colChkCtx, &this->colliderSphere.base); + CollisionCheck_SetOC(play, &play->colChkCtx, &this->colliderSphere.base); } -void func_80A124A0(EnGo* this, GlobalContext* globalCtx) { +void func_80A124A0(EnGo* this, PlayState* play) { this->colliderSphere.dim.worldSphere.radius = this->colliderSphere.dim.modelSphere.radius * this->colliderSphere.dim.scale; - CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->colliderSphere.base); + CollisionCheck_SetOC(play, &play->colChkCtx, &this->colliderSphere.base); } -void func_80A124FC(EnGo* this, GlobalContext* globalCtx) { +void func_80A124FC(EnGo* this, PlayState* play) { Vec3f sp1C; Math_Vec3f_Copy(&sp1C, &this->actor.world.pos); @@ -607,10 +608,10 @@ void func_80A124FC(EnGo* this, GlobalContext* globalCtx) { this->colliderSphere.dim.worldSphere.radius = this->colliderSphere.dim.modelSphere.radius * this->colliderSphere.dim.scale; - CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->colliderSphere.base); + CollisionCheck_SetOC(play, &play->colChkCtx, &this->colliderSphere.base); } -void func_80A125BC(EnGo* this, GlobalContext* globalCtx) { +void func_80A125BC(EnGo* this, PlayState* play) { s32 pad; Math_Vec3f_ToVec3s(&this->colliderCylinder.dim.pos, &this->actor.world.pos); @@ -619,21 +620,21 @@ void func_80A125BC(EnGo* this, GlobalContext* globalCtx) { this->colliderCylinder.dim.height = 78; if (this->unk_3C6 == 0) { - CollisionCheck_SetAT(globalCtx, &globalCtx->colChkCtx, &this->colliderCylinder.base); + CollisionCheck_SetAT(play, &play->colChkCtx, &this->colliderCylinder.base); } - CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->colliderCylinder.base); - CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->colliderCylinder.base); + CollisionCheck_SetAC(play, &play->colChkCtx, &this->colliderCylinder.base); + CollisionCheck_SetOC(play, &play->colChkCtx, &this->colliderCylinder.base); } -void func_80A12660(EnGo* this, GlobalContext* globalCtx) { +void func_80A12660(EnGo* this, PlayState* play) { Math_Vec3f_ToVec3s(&this->colliderCylinder.dim.pos, &this->actor.world.pos); this->colliderCylinder.dim.radius = 24; this->colliderCylinder.dim.height = 62; - CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->colliderCylinder.base); + CollisionCheck_SetOC(play, &play->colChkCtx, &this->colliderCylinder.base); } -void func_80A126BC(EnGo* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); +void func_80A126BC(EnGo* this, PlayState* play) { + Player* player = GET_PLAYER(play); if (!(player->stateFlags2 & 0x4000)) { if (this->unk_3C6 != 0) { @@ -642,20 +643,20 @@ void func_80A126BC(EnGo* this, GlobalContext* globalCtx) { } if (ENGO_GET_F(&this->actor) == ENGO_F_8) { - func_80A124A0(this, globalCtx); + func_80A124A0(this, play); } else if (this->unk_390 & 0x100) { - func_80A123A0(this, globalCtx); + func_80A123A0(this, play); } else if (this->unk_390 & 0x200) { - func_80A124FC(this, globalCtx); + func_80A124FC(this, play); } else if (this->unk_390 & 0x400) { - func_80A125BC(this, globalCtx); + func_80A125BC(this, play); } else { - func_80A12660(this, globalCtx); + func_80A12660(this, play); } } -s32 func_80A12774(EnGo* this, GlobalContext* globalCtx) { - if (!(this->unk_390 & 7) || !Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { +s32 func_80A12774(EnGo* this, PlayState* play) { + if (!(this->unk_390 & 7) || !Actor_ProcessTalkRequest(&this->actor, &play->state)) { return false; } @@ -680,7 +681,7 @@ s32 func_80A12774(EnGo* this, GlobalContext* globalCtx) { return true; } -s32 func_80A12868(EnGo* this, GlobalContext* globalCtx) { +s32 func_80A12868(EnGo* this, PlayState* play) { this->unk_390 &= ~0x800; this->unk_390 &= ~0x1000; this->unk_390 &= ~0x2000; @@ -707,10 +708,10 @@ s32 func_80A12868(EnGo* this, GlobalContext* globalCtx) { return false; } -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.currentCsIndex == 0)) { +s32 func_80A12954(EnGo* this, PlayState* play) { + if ((ENGO_GET_F(&this->actor) == ENGO_F_4) && (play->csCtx.state != 0) && (this->actor.draw != NULL) && + (play->sceneNum == SCENE_10YUKIYAMANOMURA2) && (gSaveContext.sceneSetupIndex == 1) && + (play->csCtx.currentCsIndex == 0)) { if (this->unk_3F0 == 0) { this->actor.flags &= ~ACTOR_FLAG_1; this->unk_394 = 255; @@ -730,7 +731,7 @@ s32 func_80A12954(EnGo* this, GlobalContext* globalCtx) { return false; } -s32 func_80A12A64(EnGo* this, GlobalContext* globalCtx) { +s32 func_80A12A64(EnGo* this, PlayState* play) { s8 objIdx = this->actor.objBankIndex; s8 objIdx2 = -1; s32 ret = 0; @@ -744,17 +745,17 @@ s32 func_80A12A64(EnGo* this, GlobalContext* globalCtx) { } if (objIdx2 >= 0) { - gSegments[6] = PHYSICAL_TO_VIRTUAL2(globalCtx->objectCtx.status[objIdx2].segment); + gSegments[6] = VIRTUAL_TO_PHYSICAL(play->objectCtx.status[objIdx2].segment); this->skelAnime.playSpeed = this->unk_398; ret = SkelAnime_Update(&this->skelAnime); - gSegments[6] = PHYSICAL_TO_VIRTUAL2(globalCtx->objectCtx.status[objIdx].segment); + gSegments[6] = VIRTUAL_TO_PHYSICAL(play->objectCtx.status[objIdx].segment); } return ret; } -s32 func_80A12B78(EnGo* this, GlobalContext* globalCtx) { - if (globalCtx->csCtx.state == 0) { +s32 func_80A12B78(EnGo* this, PlayState* play) { + if (play->csCtx.state == 0) { if (this->unk_3DC == 4) { if (Animation_OnFrame(&this->skelAnime, 2.0f)) { Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_GOLON_CIRCLE); @@ -776,7 +777,7 @@ s32 func_80A12B78(EnGo* this, GlobalContext* globalCtx) { return 0; } -s32 func_80A12C48(EnGo* this, GlobalContext* globalCtx, s32 arg2) { +s32 func_80A12C48(EnGo* this, PlayState* play, s32 arg2) { s8 objIdx = this->actor.objBankIndex; s8 objIdx2 = -1; s32 ret = false; @@ -790,11 +791,11 @@ s32 func_80A12C48(EnGo* this, GlobalContext* globalCtx, s32 arg2) { } if (objIdx2 >= 0) { - gSegments[6] = PHYSICAL_TO_VIRTUAL2(globalCtx->objectCtx.status[objIdx2].segment); + gSegments[6] = VIRTUAL_TO_PHYSICAL(play->objectCtx.status[objIdx2].segment); this->unk_3DC = arg2; - ret = SubS_ChangeAnimationByInfoS(&this->skelAnime, sAnimations, arg2); + ret = SubS_ChangeAnimationByInfoS(&this->skelAnime, sAnimationInfo, arg2); this->unk_398 = this->skelAnime.playSpeed; - gSegments[6] = PHYSICAL_TO_VIRTUAL2(globalCtx->objectCtx.status[objIdx].segment); + gSegments[6] = VIRTUAL_TO_PHYSICAL(play->objectCtx.status[objIdx].segment); } return ret; @@ -810,19 +811,19 @@ void func_80A12D6C(EnGo* this) { } } -void func_80A12DF4(EnGo* this, GlobalContext* globalCtx) { +void func_80A12DF4(EnGo* this, PlayState* play) { if (this->unk_3D4 == 0) { - func_80A12C48(this, globalCtx, 9); + func_80A12C48(this, play, 9); this->unk_3D4++; } else if ((this->unk_3D4 == 1) && Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) { - func_80A12C48(this, globalCtx, 6); + func_80A12C48(this, play, 6); this->unk_3D4++; } } -s32 func_80A12E80(EnGo* this, GlobalContext* globalCtx) { - u16 temp = globalCtx->msgCtx.currentTextId; - Player* player = GET_PLAYER(globalCtx); +s32 func_80A12E80(EnGo* this, PlayState* play) { + u16 temp = play->msgCtx.currentTextId; + Player* player = GET_PLAYER(play); if (ENGO_GET_F(&this->actor) != ENGO_F_4) { return false; @@ -839,7 +840,7 @@ s32 func_80A12E80(EnGo* this, GlobalContext* globalCtx) { case 0xE1D: case 0xE25: if (ENGO_GET_70(&this->actor) == ENGO_70_1) { - this->unk_38C = &GET_PLAYER(globalCtx)->actor; + this->unk_38C = &GET_PLAYER(play)->actor; } break; @@ -855,7 +856,7 @@ s32 func_80A12E80(EnGo* this, GlobalContext* globalCtx) { case 0xE1F: if (ENGO_GET_70(&this->actor) == ENGO_70_0) { - this->unk_38C = &GET_PLAYER(globalCtx)->actor; + this->unk_38C = &GET_PLAYER(play)->actor; } break; } @@ -866,18 +867,18 @@ s32 func_80A12E80(EnGo* this, GlobalContext* globalCtx) { this->unk_3F4 = 0; this->unk_190 = NULL; this->unk_392 = 0; - func_80A12C48(this, globalCtx, 5); + func_80A12C48(this, play, 5); this->unk_390 &= ~8; } if (this->unk_190 != NULL) { - this->unk_190(this, globalCtx); + this->unk_190(this, play); } return false; } -s32 func_80A12FE8(EnGo* this, GlobalContext* globalCtx) { +s32 func_80A12FE8(EnGo* this, PlayState* play) { s32 pad; Vec3f sp40; Vec3f sp34; @@ -910,17 +911,17 @@ s32 func_80A12FE8(EnGo* this, GlobalContext* globalCtx) { return false; } -s32 func_80A131F8(EnGo* this, GlobalContext* globalCtx) { +s32 func_80A131F8(EnGo* this, PlayState* play) { if (this->unk_3F4 == 0) { - this->unk_38C = &GET_PLAYER(globalCtx)->actor; + this->unk_38C = &GET_PLAYER(play)->actor; } - func_80A12E80(this, globalCtx); + func_80A12E80(this, play); if (this->unk_390 & 8) { this->unk_390 &= ~0x40; this->unk_390 |= 0x10; - func_80A12FE8(this, globalCtx); + func_80A12FE8(this, play); } else if (this->unk_390 & 0x10) { this->unk_390 &= ~0x10; this->unk_3B0 = 0; @@ -936,8 +937,8 @@ s32 func_80A131F8(EnGo* this, GlobalContext* globalCtx) { return true; } -void func_80A132C8(EnGo* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); +void func_80A132C8(EnGo* this, PlayState* play) { + Player* player = GET_PLAYER(play); 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)) { @@ -950,7 +951,7 @@ void func_80A132C8(EnGo* this, GlobalContext* globalCtx) { } } -void func_80A133A8(EnGo* this, GlobalContext* globalCtx) { +void func_80A133A8(EnGo* this, PlayState* play) { if (gSaveContext.save.weekEventReg[21] & 8) { SubS_UpdateFlags(&this->unk_390, 3, 7); } else { @@ -958,12 +959,12 @@ void func_80A133A8(EnGo* this, GlobalContext* globalCtx) { } } -Actor* func_80A13400(EnGo* this, GlobalContext* globalCtx) { +Actor* func_80A13400(EnGo* this, PlayState* play) { Actor* actor; Actor* retActor = NULL; while (true) { - actor = SubS_FindActor(globalCtx, retActor, ACTORCAT_NPC, ACTOR_EN_GO); + actor = SubS_FindActor(play, retActor, ACTORCAT_NPC, ACTOR_EN_GO); retActor = actor; if ((actor != NULL) && ((EnGo*)actor != this) && (ENGO_GET_F(actor) == ENGO_F_4) && @@ -985,8 +986,8 @@ Actor* func_80A13400(EnGo* this, GlobalContext* globalCtx) { return NULL; } -void func_80A134B0(EnGo* this, GlobalContext* globalCtx, s32 arg2) { - if ((gSaveContext.save.weekEventReg[18] & 0x80) || (globalCtx->actorCtx.unk5 & 1) || arg2) { +void func_80A134B0(EnGo* this, PlayState* play, s32 arg2) { + if ((gSaveContext.save.weekEventReg[18] & 0x80) || (play->actorCtx.unk5 & 1) || arg2) { this->colliderSphere.dim.modelSphere.radius = 300; } else { this->colliderSphere.dim.modelSphere.radius = 380; @@ -1044,49 +1045,48 @@ s32 func_80A13564(EnGo* this, f32 arg1, f32 arg2, s32 arg3) { return ret; } -void func_80A136B8(GlobalContext* globalCtx, s16 arg1, s16 arg2, s16 arg3) { - s16 sp26 = Quake_Add(Play_GetCamera(globalCtx, CAM_ID_MAIN), 3); +void func_80A136B8(PlayState* play, s16 arg1, s16 arg2, s16 arg3) { + s16 sp26 = Quake_Add(Play_GetCamera(play, CAM_ID_MAIN), 3); Quake_SetCountdown(sp26, arg3); Quake_SetSpeed(sp26, arg1); Quake_SetQuakeValues(sp26, arg2, 0, 0, 0); } -void func_80A13728(EnGo* this, GlobalContext* globalCtx) { - func_80A136B8(globalCtx, 0x6C77, 7, 20); - globalCtx->actorCtx.unk2 = 4; - Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_TEST, this->actor.world.pos.x, this->actor.world.pos.y, +void func_80A13728(EnGo* this, PlayState* play) { + func_80A136B8(play, 0x6C77, 7, 20); + play->actorCtx.unk2 = 4; + Actor_Spawn(&play->actorCtx, play, ACTOR_EN_TEST, this->actor.world.pos.x, this->actor.world.pos.y, this->actor.world.pos.z, 0, 0, 0, 0); - EffectSsBlast_SpawnWhiteShockwave(globalCtx, &this->actor.world.pos, &gZeroVec3f, &gZeroVec3f); + EffectSsBlast_SpawnWhiteShockwave(play, &this->actor.world.pos, &gZeroVec3f, &gZeroVec3f); } -void func_80A137C0(EnGo* this, GlobalContext* globalCtx, f32 arg2, f32 arg3) { +void func_80A137C0(EnGo* this, PlayState* play, f32 arg2, f32 arg3) { u32 frames1; u32 frames2; if (this->unk_390 & 0x400) { - Matrix_StatePush(); + Matrix_Push(); - OPEN_DISPS(globalCtx->state.gfxCtx); + OPEN_DISPS(play->state.gfxCtx); - func_8012C2DC(globalCtx->state.gfxCtx); + func_8012C2DC(play->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); + func_800B8118(&this->actor, play, 0); - gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - frames1 = globalCtx->gameplayFrames % 256; - frames2 = (globalCtx->gameplayFrames * 2) % 256; + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + frames1 = play->gameplayFrames % 256; + frames2 = (play->gameplayFrames * 2) % 256; gSPSegment(POLY_XLU_DISP++, 0x08, - Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, 0, frames1, 0x20, 0x10, 1, 0, frames2, 0x40, 0x20)); + Gfx_TwoTexScroll(play->state.gfxCtx, 0, 0, frames1, 0x20, 0x10, 1, 0, frames2, 0x40, 0x20)); gDPSetEnvColor(POLY_XLU_DISP++, 0, 50, 100, (u8)arg3); - gSPDisplayList(POLY_XLU_DISP++, &gameplay_keep_DL_050D10); + gSPDisplayList(POLY_XLU_DISP++, gEffIceFragment3DL); - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->state.gfxCtx); - Matrix_StatePop(); + Matrix_Pop(); } } @@ -1104,8 +1104,8 @@ void func_80A139E4(EnGo* this) { func_80A10FD0(&this->unk_3F8[16], sp48, D_80A16698, gZeroVec3f, 0.01f, 0.002f, 16); } -s32 func_80A13B1C(EnGo* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); +s32 func_80A13B1C(EnGo* this, PlayState* play) { + Player* player = GET_PLAYER(play); s32 pad; s32 ret = false; @@ -1145,7 +1145,7 @@ s32 func_80A13B1C(EnGo* this, GlobalContext* globalCtx) { switch (this->unk_3C4) { case 1: - func_80A12C48(this, globalCtx, 4); + func_80A12C48(this, play, 4); this->unk_390 |= 0x4000; this->unk_3C4++; break; @@ -1174,7 +1174,7 @@ s32 func_80A13B1C(EnGo* this, GlobalContext* globalCtx) { case 4: if (func_80A13564(this, 10.0f, 0.004f, 6)) { Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_GOLON_LAND_BIG); - func_80A13728(this, globalCtx); + func_80A13728(this, play); this->unk_3C4++; this->unk_3C2 = 0; gSaveContext.save.weekEventReg[88] |= 0x40; @@ -1184,7 +1184,7 @@ s32 func_80A13B1C(EnGo* this, GlobalContext* globalCtx) { case 5: this->unk_3C2++; if (this->unk_3C2 >= 10) { - func_80A12C48(this, globalCtx, 5); + func_80A12C48(this, play, 5); this->actor.shape.rot.x = 0; this->unk_390 &= ~0x200; this->unk_390 |= 0x80; @@ -1196,19 +1196,19 @@ s32 func_80A13B1C(EnGo* this, GlobalContext* globalCtx) { this->unk_3C0++; if (this->unk_3C0 >= 65) { switch (player->transformation) { - case 4: + case PLAYER_FORM_HUMAN: gSaveContext.save.weekEventReg[88] |= 0x80; break; - case 1: + case PLAYER_FORM_GORON: gSaveContext.save.weekEventReg[89] |= 4; break; - case 2: + case PLAYER_FORM_ZORA: gSaveContext.save.weekEventReg[89] |= 2; break; - case 3: + case PLAYER_FORM_DEKU: gSaveContext.save.weekEventReg[89] |= 1; break; } @@ -1221,7 +1221,7 @@ s32 func_80A13B1C(EnGo* this, GlobalContext* globalCtx) { return ret; } -s32 func_80A13E80(EnGo* this, GlobalContext* globalCtx) { +s32 func_80A13E80(EnGo* this, PlayState* play) { static Vec3f D_80A166A4 = { 0.0f, 200.0f, 280.0f }; s32 pad; Vec3f sp48; @@ -1236,7 +1236,7 @@ s32 func_80A13E80(EnGo* this, GlobalContext* globalCtx) { break; case 1: - func_80A12C48(this, globalCtx, 7); + func_80A12C48(this, play, 7); this->unk_3C0++; case 2: @@ -1245,11 +1245,11 @@ s32 func_80A13E80(EnGo* this, GlobalContext* globalCtx) { } if (Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) { - func_80A12C48(this, globalCtx, 1); + func_80A12C48(this, play, 1); Lib_Vec3f_TranslateAndRotateY(&this->actor.world.pos, this->actor.shape.rot.y, &D_80A166A4, &sp48); gSaveContext.powderKegTimer = 2400; - Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_BOM, sp48.x, sp48.y, sp48.z, 1, 0, 0, 0); - func_80A134B0(this, globalCtx, 1); + Actor_Spawn(&play->actorCtx, play, ACTOR_EN_BOM, sp48.x, sp48.y, sp48.z, 1, 0, 0, 0); + func_80A134B0(this, play, 1); this->unk_3C2 = 0; this->unk_3C0++; } @@ -1270,7 +1270,7 @@ s32 func_80A13E80(EnGo* this, GlobalContext* globalCtx) { return ret; } -void func_80A14018(EnGo* this, GlobalContext* globalCtx) { +void func_80A14018(EnGo* this, PlayState* play) { static Vec3f D_80A166B0 = { 0.0f, 0.0f, 40.0f }; static s32 D_80A166BC[] = { 11, 10, 12, 13, 14, 17 }; Vec3f sp2C; @@ -1280,7 +1280,7 @@ void func_80A14018(EnGo* this, GlobalContext* globalCtx) { phi_v0 = ((gSaveContext.eventInf[2] & 0xF) + phi_v0) % 4; } - func_80A12C48(this, globalCtx, D_80A166BC[phi_v0]); + func_80A12C48(this, play, D_80A166BC[phi_v0]); if (this->unk_3DC == 14) { Lib_Vec3f_TranslateAndRotateY(&this->actor.world.pos, this->actor.shape.rot.y, &D_80A166B0, &sp2C); @@ -1294,11 +1294,11 @@ void func_80A14018(EnGo* this, GlobalContext* globalCtx) { this->actor.gravity = 0.0f; } -void func_80A14104(EnGo* this, GlobalContext* globalCtx) { +void func_80A14104(EnGo* this, PlayState* play) { static s32 D_80A166D4[] = { 15, 16 }; s16 temp; - func_80A12C48(this, globalCtx, D_80A166D4[ENGO_GET_70(&this->actor) % 2]); + func_80A12C48(this, play, D_80A166D4[ENGO_GET_70(&this->actor) % 2]); temp = Rand_ZeroOne() * this->skelAnime.endFrame; this->skelAnime.curFrame = temp; this->actor.flags &= ~ACTOR_FLAG_1; @@ -1310,11 +1310,11 @@ void func_80A14104(EnGo* this, GlobalContext* globalCtx) { this->actor.gravity = 0.0f; } -void func_80A141D4(EnGo* this, GlobalContext* globalCtx) { - Collider_InitAndSetCylinder(globalCtx, &this->colliderCylinder, &this->actor, &sCylinderInit1); +void func_80A141D4(EnGo* this, PlayState* play) { + Collider_InitAndSetCylinder(play, &this->colliderCylinder, &this->actor, &sCylinderInit1); CollisionCheck_SetInfo2(&this->actor.colChkInfo, &sDamageTable, &sColChkInfoInit); this->unk_3DC = -1; - func_80A12C48(this, globalCtx, 5); + func_80A12C48(this, play, 5); this->unk_3EC = 0; this->unk_39C = (this->unk_3A4 / 0.01f) * 0.9f; this->unk_3BE = 2; @@ -1324,7 +1324,7 @@ void func_80A141D4(EnGo* this, GlobalContext* globalCtx) { this->unk_3A0 = 100.0f; } -void func_80A1428C(EnGo* this, GlobalContext* globalCtx) { +void func_80A1428C(EnGo* this, PlayState* play) { s16 temp; Vec3f sp30; Vec3f sp24; @@ -1343,8 +1343,8 @@ void func_80A1428C(EnGo* this, GlobalContext* globalCtx) { this->actor.gravity = -1.0f; } -void func_80A14324(EnGo* this, GlobalContext* globalCtx) { - func_80A12C48(this, globalCtx, 8); +void func_80A14324(EnGo* this, PlayState* play) { + func_80A12C48(this, play, 8); Actor_SetScale(&this->actor, this->unk_3A4); this->unk_390 = 0; this->actor.gravity = -1.0f; @@ -1357,8 +1357,8 @@ void func_80A14324(EnGo* this, GlobalContext* globalCtx) { this->unk_3A0 = 0.0f; } -void func_80A143A8(EnGo* this, GlobalContext* globalCtx) { - func_80A12C48(this, globalCtx, 5); +void func_80A143A8(EnGo* this, PlayState* play) { + func_80A12C48(this, play, 5); Actor_SetScale(&this->actor, this->unk_3A4); this->unk_390 = 0; this->actor.gravity = -1.0f; @@ -1372,69 +1372,71 @@ void func_80A143A8(EnGo* this, GlobalContext* globalCtx) { this->unk_3A0 = 0.0f; } -void func_80A14430(EnGo* this, GlobalContext* globalCtx) { - if (((gSaveContext.save.entranceIndex == 0xD000) || (gSaveContext.save.entranceIndex == 0xD020)) && +void func_80A14430(EnGo* this, PlayState* play) { + if (((gSaveContext.save.entrance == ENTRANCE(GORON_RACETRACK, 0)) || + (gSaveContext.save.entrance == ENTRANCE(GORON_RACETRACK, 2))) && (gSaveContext.save.weekEventReg[33] & 0x80)) { - func_80A14018(this, globalCtx); + func_80A14018(this, play); this->actionFunc = func_80A149B0; } else { Actor_MarkForDeath(&this->actor); } } -void func_80A1449C(EnGo* this, GlobalContext* globalCtx) { - if ((gSaveContext.save.entranceIndex == 0xD010) || (gSaveContext.save.entranceIndex == 0x1C00)) { - func_80A14104(this, globalCtx); +void func_80A1449C(EnGo* this, PlayState* play) { + if ((gSaveContext.save.entrance == ENTRANCE(GORON_RACETRACK, 1)) || + (gSaveContext.save.entrance == ENTRANCE(CUTSCENE, 0))) { + func_80A14104(this, play); this->actionFunc = func_80A149B0; } else { Actor_MarkForDeath(&this->actor); } } -void func_80A144F4(EnGo* this, GlobalContext* globalCtx) { +void func_80A144F4(EnGo* this, PlayState* play) { if (gSaveContext.save.day >= 2) { - this->unk_284 = SubS_GetDayDependentPath(globalCtx, ENGO_GET_7F80(&this->actor), 0xFF, &this->unk_3E4); + this->unk_284 = SubS_GetDayDependentPath(play, ENGO_GET_7F80(&this->actor), 0xFF, &this->unk_3E4); if (this->unk_284 != NULL) { this->unk_3E4 = 1; } - func_80A1428C(this, globalCtx); + func_80A1428C(this, play); this->actionFunc = func_80A153FC; this->unk_3D8 = func_80A13B1C; } else { - func_80A143A8(this, globalCtx); + func_80A143A8(this, play); this->actionFunc = func_80A149B0; this->unk_3D8 = func_80A13B1C; } } -void func_80A145AC(EnGo* this, GlobalContext* globalCtx) { +void func_80A145AC(EnGo* this, PlayState* play) { if ((ENGO_GET_70(&this->actor) == ENGO_70_1) && - (((globalCtx->sceneNum == SCENE_10YUKIYAMANOMURA2) && (gSaveContext.sceneSetupIndex == 1) && - (globalCtx->csCtx.currentCsIndex == 0)) || + (((play->sceneNum == SCENE_10YUKIYAMANOMURA2) && (gSaveContext.sceneSetupIndex == 1) && + (play->csCtx.currentCsIndex == 0)) || !(gSaveContext.save.weekEventReg[21] & 8))) { - this->actor.child = func_80A13400(this, globalCtx); + this->actor.child = func_80A13400(this, play); this->actor.child->child = &this->actor; - func_80A141D4(this, globalCtx); + func_80A141D4(this, play); this->actionFunc = func_80A14E14; } else { - func_80A143A8(this, globalCtx); + func_80A143A8(this, play); this->actionFunc = func_80A149B0; } } -void func_80A14668(EnGo* this, GlobalContext* globalCtx) { +void func_80A14668(EnGo* this, PlayState* play) { if (!(gSaveContext.save.weekEventReg[22] & 4)) { - func_80A14324(this, globalCtx); + func_80A14324(this, play); this->actionFunc = func_80A149B0; } else { - func_80A143A8(this, globalCtx); + func_80A143A8(this, play); this->actionFunc = func_80A149B0; } } -void func_80A146CC(EnGo* this, GlobalContext* globalCtx) { - func_80A134B0(this, globalCtx, 0); - func_80A12C48(this, globalCtx, 0); +void func_80A146CC(EnGo* this, PlayState* play) { + func_80A134B0(this, play, 0); + func_80A12C48(this, play, 0); this->unk_3A4 *= 5.0f; Actor_SetScale(&this->actor, this->unk_3A4); this->actor.flags &= ~ACTOR_FLAG_1; @@ -1448,27 +1450,27 @@ void func_80A146CC(EnGo* this, GlobalContext* globalCtx) { this->actionFunc = func_80A149B0; } -void func_80A14798(EnGo* this, GlobalContext* globalCtx) { +void func_80A14798(EnGo* this, PlayState* play) { EffectTireMarkInit sp38 = { 0, 62, { 0, 0, 15, 100 }, }; - if ((this->unk_288 < 0) || SubS_IsObjectLoaded(this->unk_288, globalCtx) || (this->unk_289 < 0) || - SubS_IsObjectLoaded(this->unk_289, globalCtx)) { + if ((this->unk_288 < 0) || SubS_IsObjectLoaded(this->unk_288, play) || (this->unk_289 < 0) || + SubS_IsObjectLoaded(this->unk_289, play)) { 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(play, &this->skelAnime, &gGoronSkel, NULL, this->jointTable, this->morphTable, + GORON_LIMB_MAX); this->unk_3DC = -1; - func_80A12C48(this, globalCtx, 2); + func_80A12C48(this, play, 2); this->actor.draw = func_80A15FEC; - Collider_InitAndSetSphere(globalCtx, &this->colliderSphere, &this->actor, &sSphereInit); - Collider_InitAndSetCylinder(globalCtx, &this->colliderCylinder, &this->actor, &sCylinderInit2); + Collider_InitAndSetSphere(play, &this->colliderSphere, &this->actor, &sSphereInit); + Collider_InitAndSetCylinder(play, &this->colliderCylinder, &this->actor, &sCylinderInit2); CollisionCheck_SetInfo2(&this->actor.colChkInfo, &sDamageTable, &sColChkInfoInit); - Effect_Add(globalCtx, &this->unk_3E8, EFFECT_TIRE_MARK, 0, 0, &sp38); + Effect_Add(play, &this->unk_3E8, EFFECT_TIRE_MARK, 0, 0, &sp38); this->actor.targetMode = 1; this->unk_3A4 = 0.01f; @@ -1476,29 +1478,29 @@ void func_80A14798(EnGo* this, GlobalContext* globalCtx) { switch (ENGO_GET_F(&this->actor)) { case ENGO_F_1: - func_80A14430(this, globalCtx); + func_80A14430(this, play); break; case ENGO_F_2: - func_80A1449C(this, globalCtx); + func_80A1449C(this, play); break; case ENGO_F_3: - func_80A144F4(this, globalCtx); + func_80A144F4(this, play); break; case ENGO_F_4: - func_80A145AC(this, globalCtx); + func_80A145AC(this, play); break; case ENGO_F_5: case ENGO_F_6: case ENGO_F_7: - func_80A14668(this, globalCtx); + func_80A14668(this, play); break; case ENGO_F_8: - func_80A146CC(this, globalCtx); + func_80A146CC(this, play); break; default: @@ -1508,24 +1510,24 @@ void func_80A14798(EnGo* this, GlobalContext* globalCtx) { } } -void func_80A149B0(EnGo* this, GlobalContext* globalCtx) { +void func_80A149B0(EnGo* this, PlayState* play) { s16 sp26 = this->actor.world.rot.y; - if ((ENGO_GET_F(&this->actor) == ENGO_F_2) && (gSaveContext.save.entranceIndex == 0xD010)) { + if ((ENGO_GET_F(&this->actor) == ENGO_F_2) && (gSaveContext.save.entrance == ENTRANCE(GORON_RACETRACK, 1))) { Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_GORON_CHEER - SFX_FLAG); } else if (ENGO_GET_F(&this->actor) != ENGO_F_8) { - if (func_80A1222C(this, globalCtx)) { + if (func_80A1222C(this, play)) { 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) { switch (ENGO_GET_70(&this->actor)) { case ENGO_70_0: - func_80A132C8(this, globalCtx); + func_80A132C8(this, play); break; case ENGO_70_1: - func_80A133A8(this, globalCtx); + func_80A133A8(this, play); break; } } else if (ENGO_GET_F(&this->actor) == ENGO_F_1) { @@ -1539,11 +1541,11 @@ void func_80A149B0(EnGo* this, GlobalContext* globalCtx) { Math_ApproachS(&this->actor.shape.rot.y, sp26, 4, 0x2AA8); } -void func_80A14B30(EnGo* this, GlobalContext* globalCtx) { +void func_80A14B30(EnGo* this, PlayState* play) { s16 sp26 = this->actor.world.rot.y; u16 sfxId; - if (func_80A1222C(this, globalCtx)) { + if (func_80A1222C(this, play)) { this->unk_3EC = 1; } @@ -1563,7 +1565,7 @@ void func_80A14B30(EnGo* this, GlobalContext* globalCtx) { } } else if (this->unk_390 & 0x200) { if ((this->actor.xzDistToPlayer < 160.0f) && (this->actor.playerHeightRel < 20.0f) && (this->unk_3EC == 0)) { - func_80A12C48(this, globalCtx, 3); + func_80A12C48(this, play, 3); this->unk_390 &= ~0x80; this->unk_390 &= ~0x200; this->unk_390 |= 0x8000; @@ -1587,18 +1589,18 @@ void func_80A14B30(EnGo* this, GlobalContext* globalCtx) { } } else if ((this->actor.xzDistToPlayer >= 240.0f) || (this->actor.playerHeightRel >= 20.0f) || (this->unk_3EC != 0)) { - func_80A12C48(this, globalCtx, 4); + func_80A12C48(this, play, 4); this->unk_390 &= ~0x80; this->unk_390 &= ~0x200; this->unk_390 |= 0x4000; this->actor.shape.yOffset = 0.0f; } - SubS_FillLimbRotTables(globalCtx, this->unk_3CE, this->unk_3C8, ARRAY_COUNT(this->unk_3CE)); + SubS_FillLimbRotTables(play, this->unk_3CE, this->unk_3C8, ARRAY_COUNT(this->unk_3CE)); Math_ApproachS(&this->actor.shape.rot.y, sp26, 4, 0x2AA8); } -void func_80A14E14(EnGo* this, GlobalContext* globalCtx) { +void func_80A14E14(EnGo* this, PlayState* play) { Actor* actor = this->colliderCylinder.base.ac; if ((this->unk_390 & 0x1000) && (((actor != NULL) && (actor->id == ACTOR_OBJ_AQUA) && (actor->params & 1)) || @@ -1607,13 +1609,13 @@ void func_80A14E14(EnGo* this, GlobalContext* globalCtx) { } } -void func_80A14E74(EnGo* this, GlobalContext* globalCtx) { +void func_80A14E74(EnGo* this, PlayState* play) { if (func_80A134F4(this, this->actor.cutscene)) { this->actionFunc = func_80A14EB0; } } -void func_80A14EB0(EnGo* this, GlobalContext* globalCtx) { +void func_80A14EB0(EnGo* this, PlayState* play) { EnGo* sp24 = (EnGo*)this->actor.child; if ((s32)(this->unk_39C * 3.0f) != 0) { @@ -1623,17 +1625,17 @@ void func_80A14EB0(EnGo* this, GlobalContext* globalCtx) { func_80A139E4(this); } else { ActorCutscene_Stop(this->actor.cutscene); - func_80A143A8(this, globalCtx); + func_80A143A8(this, play); if ((ENGO_GET_F(&this->actor) == ENGO_F_4) && (ENGO_GET_70(&this->actor) == ENGO_70_1)) { SubS_UpdateFlags(&this->unk_390, 4, 7); - func_80A143A8(sp24, globalCtx); + func_80A143A8(sp24, play); sp24->actionFunc = func_80A149B0; } this->actionFunc = func_80A149B0; } } -void func_80A14FC8(EnGo* this, GlobalContext* globalCtx) { +void func_80A14FC8(EnGo* this, PlayState* play) { s32 sp38[] = { 0, 2, 6, 20, 18, 5, 5, 15, }; @@ -1652,13 +1654,13 @@ void func_80A14FC8(EnGo* this, GlobalContext* globalCtx) { } if ((actorActionCmd == 128) || (actorActionCmd == 129)) { - if (Cutscene_CheckActorAction(globalCtx, actorActionCmd)) { - actionIndex = Cutscene_GetActorActionIndex(globalCtx, actorActionCmd); - sp30 = globalCtx->csCtx.actorActions[actionIndex]->action; + if (Cutscene_CheckActorAction(play, actorActionCmd)) { + actionIndex = Cutscene_GetActorActionIndex(play, actorActionCmd); + sp30 = play->csCtx.actorActions[actionIndex]->action; if (this->unk_394 != (u8)sp30) { this->unk_394 = sp30; - func_80A12C48(this, globalCtx, sp38[sp30]); + func_80A12C48(this, play, sp38[sp30]); this->unk_390 = 0; this->unk_390 |= 0x20; this->unk_3BE = 0; @@ -1673,7 +1675,7 @@ void func_80A14FC8(EnGo* this, GlobalContext* globalCtx) { case 5: case 6: - func_80A141D4(this, globalCtx); + func_80A141D4(this, play); break; } } @@ -1681,13 +1683,13 @@ void func_80A14FC8(EnGo* this, GlobalContext* globalCtx) { switch (this->unk_394) { case 3: if (Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame) && (this->unk_3DC == 20)) { - func_80A12C48(this, globalCtx, 21); + func_80A12C48(this, play, 21); } break; case 4: if (Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame) && (this->unk_3DC == 18)) { - func_80A12C48(this, globalCtx, 19); + func_80A12C48(this, play, 19); } break; @@ -1698,13 +1700,13 @@ void func_80A14FC8(EnGo* this, GlobalContext* globalCtx) { this->unk_3A0 = (this->unk_39C / 0.9f) * 100.0f; func_80A139E4(this); } else if (this->unk_390 & 0x400) { - func_80A143A8(this, globalCtx); + func_80A143A8(this, play); } break; } if (actorActionCmd == 128) { - switch (globalCtx->csCtx.frames) { + switch (play->csCtx.frames) { case 55: case 100: case 130: @@ -1728,7 +1730,7 @@ void func_80A14FC8(EnGo* this, GlobalContext* globalCtx) { break; } } else if (actorActionCmd == 129) { - switch (globalCtx->csCtx.frames) { + switch (play->csCtx.frames) { case 360: case 390: Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_GOLON_COLD); @@ -1748,13 +1750,13 @@ void func_80A14FC8(EnGo* this, GlobalContext* globalCtx) { } } - SubS_FillLimbRotTables(globalCtx, this->unk_3CE, this->unk_3C8, ARRAY_COUNT(this->unk_3CE)); - Cutscene_ActorTranslateAndYaw(&this->actor, globalCtx, actionIndex); + SubS_FillLimbRotTables(play, this->unk_3CE, this->unk_3C8, ARRAY_COUNT(this->unk_3CE)); + Cutscene_ActorTranslateAndYaw(&this->actor, play, actionIndex); } } } -void func_80A153FC(EnGo* this, GlobalContext* globalCtx) { +void func_80A153FC(EnGo* this, PlayState* play) { Vec3s* sp5C; Vec3f sp50; Vec3f sp44; @@ -1772,16 +1774,16 @@ void func_80A153FC(EnGo* this, GlobalContext* globalCtx) { Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_GOLON_COLD); if (gSaveContext.save.day == 3) { - func_80A141D4(this, globalCtx); + func_80A141D4(this, play); this->actionFunc = func_80A14E14; } else { - func_80A143A8(this, globalCtx); + func_80A143A8(this, play); this->actionFunc = func_80A149B0; } } else if (this->unk_284 != NULL) { if (this->unk_390 & 0x800) { - func_800B8E58(GET_PLAYER(globalCtx), NA_SE_PL_BODY_HIT); - func_800B8D50(globalCtx, &this->actor, 2.0f, this->actor.yawTowardsPlayer, 0.0f, 0); + func_800B8E58(GET_PLAYER(play), NA_SE_PL_BODY_HIT); + func_800B8D50(play, &this->actor, 2.0f, this->actor.yawTowardsPlayer, 0.0f, 0); } sp5C = Lib_SegmentedToVirtual(this->unk_284->points); @@ -1800,7 +1802,7 @@ void func_80A153FC(EnGo* this, GlobalContext* globalCtx) { if (this->actor.bgCheckFlags & 1) { Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_BIGBALL_ROLL - SFX_FLAG); - func_800AE930(&globalCtx->colCtx, Effect_GetByIndex(this->unk_3E8), &this->actor.world.pos, 18.0f, + func_800AE930(&play->colCtx, Effect_GetByIndex(this->unk_3E8), &this->actor.world.pos, 18.0f, this->actor.shape.rot.y, this->actor.floorPoly, this->actor.floorBgId); } else { func_800AEF44(Effect_GetByIndex(this->unk_3E8)); @@ -1812,7 +1814,7 @@ void func_80A153FC(EnGo* this, GlobalContext* globalCtx) { } } -s32* func_80A15684(EnGo* this, GlobalContext* globalCtx) { +s32* func_80A15684(EnGo* this, PlayState* play) { static s32 D_80A16704[] = { D_80A16100, D_80A16164, @@ -1857,18 +1859,18 @@ s32* func_80A15684(EnGo* this, GlobalContext* globalCtx) { } } -void func_80A157C4(EnGo* this, GlobalContext* globalCtx) { +void func_80A157C4(EnGo* this, PlayState* play) { s32 pad; Vec3f sp40; Vec3f sp34; - if (!func_8010BF58(&this->actor, globalCtx, func_80A15684(this, globalCtx), this->unk_3D8, &this->unk_28C)) { + if (!func_8010BF58(&this->actor, play, func_80A15684(this, play), this->unk_3D8, &this->unk_28C)) { if ((ENGO_GET_F(&this->actor) != ENGO_F_1) && !(this->unk_390 & 0x200)) { Math_Vec3f_Copy(&sp40, &this->unk_38C->world.pos); Math_Vec3f_Copy(&sp34, &this->actor.world.pos); Math_ApproachS(&this->actor.shape.rot.y, Math_Vec3f_Yaw(&sp34, &sp40), 4, 0x2AA8); } - SubS_FillLimbRotTables(globalCtx, this->unk_3CE, this->unk_3C8, ARRAY_COUNT(this->unk_3CE)); + SubS_FillLimbRotTables(play, this->unk_3CE, this->unk_3C8, ARRAY_COUNT(this->unk_3CE)); return; } @@ -1886,38 +1888,38 @@ void func_80A157C4(EnGo* this, GlobalContext* globalCtx) { this->actionFunc = this->unk_18C; } -void EnGo_Init(Actor* thisx, GlobalContext* globalCtx) { +void EnGo_Init(Actor* thisx, PlayState* play) { EnGo* this = THIS; - this->unk_288 = SubS_GetObjectIndex(OBJECT_TAISOU, globalCtx); - this->unk_289 = SubS_GetObjectIndex(OBJECT_HAKUGIN_DEMO, globalCtx); + this->unk_288 = SubS_GetObjectIndex(OBJECT_TAISOU, play); + this->unk_289 = SubS_GetObjectIndex(OBJECT_HAKUGIN_DEMO, play); this->actionFunc = func_80A14798; } -void EnGo_Destroy(Actor* thisx, GlobalContext* globalCtx) { +void EnGo_Destroy(Actor* thisx, PlayState* play) { EnGo* this = THIS; - Collider_DestroyCylinder(globalCtx, &this->colliderCylinder); - Collider_DestroySphere(globalCtx, &this->colliderSphere); - Effect_Destroy(globalCtx, this->unk_3E8); + Collider_DestroyCylinder(play, &this->colliderCylinder); + Collider_DestroySphere(play, &this->colliderSphere); + Effect_Destroy(play, this->unk_3E8); } -void EnGo_Update(Actor* thisx, GlobalContext* globalCtx) { +void EnGo_Update(Actor* thisx, PlayState* play) { EnGo* this = THIS; f32 phi_f0; - func_80A12868(this, globalCtx); - if (!func_80A12774(this, globalCtx)) { - func_80A12954(this, globalCtx); + func_80A12868(this, play); + if (!func_80A12774(this, play)) { + func_80A12954(this, play); } - this->actionFunc(this, globalCtx); + this->actionFunc(this, play); if (!(this->unk_390 & 0x400)) { func_80A12D6C(this); - func_80A12A64(this, globalCtx); - func_80A131F8(this, globalCtx); - func_80A12B78(this, globalCtx); + func_80A12A64(this, play); + func_80A131F8(this, play); + func_80A12B78(this, play); } if (!(this->unk_390 & 0x100) && !(this->unk_390 & 0x200) && !(this->unk_390 & 0x400)) { @@ -1926,35 +1928,35 @@ 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, play, phi_f0, 20.0f, PLAYER_AP_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, play, phi_f0, 20.0f, PLAYER_AP_NONE, this->unk_390 & 7); } if ((ENGO_GET_F(&this->actor) != ENGO_F_8) && (ENGO_GET_F(&this->actor) != ENGO_F_2) && (ENGO_GET_F(&this->actor) != ENGO_F_1)) { - Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 30.0f, 12.0f, 0.0f, 4); + Actor_UpdateBgCheckInfo(play, &this->actor, 30.0f, 12.0f, 0.0f, 4); } func_80A122EC(this); - func_80A126BC(this, globalCtx); + func_80A126BC(this, play); func_80A1203C(this); } -void func_80A15B80(EnGo* this, GlobalContext* globalCtx) { +void func_80A15B80(EnGo* this, PlayState* play) { Gfx* gfx; - OPEN_DISPS(globalCtx->state.gfxCtx); + OPEN_DISPS(play->state.gfxCtx); - func_8012C28C(globalCtx->state.gfxCtx); + func_8012C28C(play->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); @@ -1962,22 +1964,21 @@ 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); + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_OPA_DISP++, (this->unk_390 & 0x100) ? gGoronSnowballDL : gGoronRolledUpDL); - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->state.gfxCtx); } -s32 EnGo_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, Actor* thisx) { +s32 EnGo_OverrideLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, Actor* thisx) { EnGo* this = THIS; Vec3f sp30; s32 idx; if ((ENGO_GET_F(&this->actor) == ENGO_F_8) && (limbIndex == 10)) { - limbIndex = limbIndex; - Matrix_GetStateTranslation(&sp30); + Matrix_MultZero(&sp30); sp30.y = this->actor.world.pos.y; Math_Vec3f_ToVec3s(&this->colliderSphere.dim.worldSphere.center, &sp30); } @@ -2007,81 +2008,80 @@ s32 EnGo_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, return false; } -void EnGo_TransfromLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Actor* thisx) { +void EnGo_TransfromLimbDraw(PlayState* play, 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) { +void func_80A15FEC(Actor* thisx, PlayState* play) { 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; if (!(this->unk_390 & 0x300)) { - OPEN_DISPS(globalCtx->state.gfxCtx); + OPEN_DISPS(play->state.gfxCtx); - func_8012C28C(globalCtx->state.gfxCtx); + func_8012C28C(play->state.gfxCtx); gSPSegment(POLY_OPA_DISP++, 0x08, Lib_SegmentedToVirtual(D_80A1670C[this->unk_3BE])); if (this->unk_3DC == 14) { - Matrix_InsertTranslation(0.0f, 0.0f, -4000.0f, MTXMODE_APPLY); + Matrix_Translate(0.0f, 0.0f, -4000.0f, MTXMODE_APPLY); } - SkelAnime_DrawTransformFlexOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, + SkelAnime_DrawTransformFlexOpa(play, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, EnGo_OverrideLimbDraw, NULL, EnGo_TransfromLimbDraw, &this->actor); - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->state.gfxCtx); } else { - func_80A15B80(this, globalCtx); + func_80A15B80(this, play); } - func_80A137C0(this, globalCtx, this->unk_39C, this->unk_3A0); - func_80A1213C(this, globalCtx); + func_80A137C0(this, play, this->unk_39C, this->unk_3A0); + func_80A1213C(this, play); } diff --git a/src/overlays/actors/ovl_En_Go/z_en_go.h b/src/overlays/actors/ovl_En_Go/z_en_go.h index ab7f068e1..0278a70df 100644 --- a/src/overlays/actors/ovl_En_Go/z_en_go.h +++ b/src/overlays/actors/ovl_En_Go/z_en_go.h @@ -5,7 +5,7 @@ struct EnGo; -typedef void (*EnGoActionFunc)(struct EnGo*, GlobalContext*); +typedef void (*EnGoActionFunc)(struct EnGo*, PlayState*); #define ENGO_GET_F(thisx) (((thisx)->params & 0xF) & 0xFF) #define ENGO_GET_70(thisx) ((((thisx)->params & 0x70) >> 4) & 0xFF) @@ -46,59 +46,59 @@ typedef struct { } EnGoStruct; // size = 0x3C; typedef struct EnGo { - /* 0x0000 */ Actor actor; - /* 0x0144 */ SkelAnime skelAnime; - /* 0x0188 */ EnGoActionFunc actionFunc; - /* 0x018C */ EnGoActionFunc unk_18C; - /* 0x0190 */ EnGoActionFunc unk_190; - /* 0x0194 */ ColliderCylinder colliderCylinder; - /* 0x01E0 */ UNK_TYPE1 unk1E0[0x4C]; - /* 0x022C */ ColliderSphere colliderSphere; - /* 0x0284 */ Path* unk_284; - /* 0x0288 */ s8 unk_288; - /* 0x0289 */ s8 unk_289; - /* 0x028C */ s32 unk_28C; - /* 0x0290 */ Vec3f unk_290; - /* 0x029C */ Vec3f unk_29C; - /* 0x02A8 */ Vec3s unk_2A8; - /* 0x02AE */ Vec3s unk_2AE; - /* 0x02B4 */ Vec3s jointTable[18]; - /* 0x0320 */ Vec3s morphTable[18]; - /* 0x038C */ Actor* unk_38C; - /* 0x0390 */ u16 unk_390; - /* 0x0392 */ u16 unk_392; - /* 0x0394 */ u8 unk_394; - /* 0x0398 */ f32 unk_398; - /* 0x039C */ f32 unk_39C; - /* 0x03A0 */ f32 unk_3A0; - /* 0x03A4 */ f32 unk_3A4; - /* 0x03A8 */ f32 unk_3A8; - /* 0x03AC */ UNK_TYPE1 unk3AC[0x2]; - /* 0x03AE */ s16 unk_3AE; - /* 0x03B0 */ s16 unk_3B0; - /* 0x03B2 */ s16 unk_3B2; - /* 0x03B4 */ s16 unk_3B4; - /* 0x03B6 */ s16 unk_3B6; - /* 0x03B8 */ s16 unk_3B8; - /* 0x03BA */ s16 unk_3BA; - /* 0x03BC */ s16 unk_3BC; - /* 0x03BE */ s16 unk_3BE; - /* 0x03C0 */ s16 unk_3C0; - /* 0x03C2 */ s16 unk_3C2; - /* 0x03C4 */ s16 unk_3C4; - /* 0x03C6 */ s16 unk_3C6; - /* 0x03C8 */ s16 unk_3C8[3]; - /* 0x03CE */ s16 unk_3CE[3]; - /* 0x03D4 */ s16 unk_3D4; - /* 0x03D8 */ void* unk_3D8; - /* 0x03DC */ s32 unk_3DC; - /* 0x03E0 */ UNK_TYPE1 unk3E0[0x4]; - /* 0x03E4 */ s32 unk_3E4; - /* 0x03E8 */ s32 unk_3E8; - /* 0x03EC */ s32 unk_3EC; - /* 0x03F0 */ s32 unk_3F0; - /* 0x03F4 */ s32 unk_3F4; - /* 0x03F8 */ EnGoStruct unk_3F8[32]; + /* 0x000 */ Actor actor; + /* 0x144 */ SkelAnime skelAnime; + /* 0x188 */ EnGoActionFunc actionFunc; + /* 0x18C */ EnGoActionFunc unk_18C; + /* 0x190 */ EnGoActionFunc unk_190; + /* 0x194 */ ColliderCylinder colliderCylinder; + /* 0x1E0 */ UNK_TYPE1 unk1E0[0x4C]; + /* 0x22C */ ColliderSphere colliderSphere; + /* 0x284 */ Path* unk_284; + /* 0x288 */ s8 unk_288; + /* 0x289 */ s8 unk_289; + /* 0x28C */ s32 unk_28C; + /* 0x290 */ Vec3f unk_290; + /* 0x29C */ Vec3f unk_29C; + /* 0x2A8 */ Vec3s unk_2A8; + /* 0x2AE */ Vec3s unk_2AE; + /* 0x2B4 */ Vec3s jointTable[18]; + /* 0x320 */ Vec3s morphTable[18]; + /* 0x38C */ Actor* unk_38C; + /* 0x390 */ u16 unk_390; + /* 0x392 */ u16 unk_392; + /* 0x394 */ u8 unk_394; + /* 0x398 */ f32 unk_398; + /* 0x39C */ f32 unk_39C; + /* 0x3A0 */ f32 unk_3A0; + /* 0x3A4 */ f32 unk_3A4; + /* 0x3A8 */ f32 unk_3A8; + /* 0x3AC */ UNK_TYPE1 unk3AC[0x2]; + /* 0x3AE */ s16 unk_3AE; + /* 0x3B0 */ s16 unk_3B0; + /* 0x3B2 */ s16 unk_3B2; + /* 0x3B4 */ s16 unk_3B4; + /* 0x3B6 */ s16 unk_3B6; + /* 0x3B8 */ s16 unk_3B8; + /* 0x3BA */ s16 unk_3BA; + /* 0x3BC */ s16 unk_3BC; + /* 0x3BE */ s16 unk_3BE; + /* 0x3C0 */ s16 unk_3C0; + /* 0x3C2 */ s16 unk_3C2; + /* 0x3C4 */ s16 unk_3C4; + /* 0x3C6 */ s16 unk_3C6; + /* 0x3C8 */ s16 unk_3C8[3]; + /* 0x3CE */ s16 unk_3CE[3]; + /* 0x3D4 */ s16 unk_3D4; + /* 0x3D8 */ void* unk_3D8; + /* 0x3DC */ s32 unk_3DC; + /* 0x3E0 */ UNK_TYPE1 unk3E0[0x4]; + /* 0x3E4 */ s32 unk_3E4; + /* 0x3E8 */ s32 unk_3E8; + /* 0x3EC */ s32 unk_3EC; + /* 0x3F0 */ s32 unk_3F0; + /* 0x3F4 */ s32 unk_3F4; + /* 0x3F8 */ EnGoStruct unk_3F8[32]; } EnGo; // size = 0xB78 extern const ActorInit En_Go_InitVars; diff --git a/src/overlays/actors/ovl_En_Goroiwa/z_en_goroiwa.c b/src/overlays/actors/ovl_En_Goroiwa/z_en_goroiwa.c index dd8d95c23..df491dd22 100644 --- a/src/overlays/actors/ovl_En_Goroiwa/z_en_goroiwa.c +++ b/src/overlays/actors/ovl_En_Goroiwa/z_en_goroiwa.c @@ -12,25 +12,25 @@ #define THIS ((EnGoroiwa*)thisx) -void EnGoroiwa_Init(Actor* thisx, GlobalContext* globalCtx); -void EnGoroiwa_Destroy(Actor* thisx, GlobalContext* globalCtx); -void EnGoroiwa_Update(Actor* thisx, GlobalContext* globalCtx); -void EnGoroiwa_Draw(Actor* thisx, GlobalContext* globalCtx); +void EnGoroiwa_Init(Actor* thisx, PlayState* play); +void EnGoroiwa_Destroy(Actor* thisx, PlayState* play); +void EnGoroiwa_Update(Actor* thisx, PlayState* play); +void EnGoroiwa_Draw(Actor* thisx, PlayState* play); void func_809419D0(EnGoroiwa* this); -void func_80941A10(EnGoroiwa* this, GlobalContext* globalCtx); +void func_80941A10(EnGoroiwa* this, PlayState* play); void func_809421E0(EnGoroiwa* this); -void func_8094220C(EnGoroiwa* this, GlobalContext* globalCtx); +void func_8094220C(EnGoroiwa* this, PlayState* play); void func_809425CC(EnGoroiwa* this); -void func_80942604(EnGoroiwa* this, GlobalContext* globalCtx); +void func_80942604(EnGoroiwa* this, PlayState* play); void func_80941DB4(EnGoroiwa* this); -void func_80941E28(EnGoroiwa* this, GlobalContext* globalCtx); +void func_80941E28(EnGoroiwa* this, PlayState* play); void func_80941EB4(EnGoroiwa* this); -void func_80941F10(EnGoroiwa* this, GlobalContext* globalCtx); +void func_80941F10(EnGoroiwa* this, PlayState* play); void func_80941F54(EnGoroiwa* this); -void func_80941FA4(EnGoroiwa* this, GlobalContext* globalCtx); +void func_80941FA4(EnGoroiwa* this, PlayState* play); void func_80942084(EnGoroiwa* this); -void func_809420F0(EnGoroiwa* this, GlobalContext* globalCtx); +void func_809420F0(EnGoroiwa* this, PlayState* play); const ActorInit En_Goroiwa_InitVars = { ACTOR_EN_GOROIWA, @@ -67,7 +67,7 @@ static ColliderJntSphInit sJntSphInit = { OC2_TYPE_2, COLSHAPE_JNTSPH, }, - 1, + ARRAY_COUNT(sJntSphElementsInit), sJntSphElementsInit, }; @@ -144,12 +144,12 @@ void func_8093E938(EnGoroiwa* this) { this->collider.elements->dim.worldSphere.radius = this->unk_1DC - 1.0f; } -void func_8093E9B0(EnGoroiwa* this, GlobalContext* globalCtx) { +void func_8093E9B0(EnGoroiwa* this, PlayState* play) { s32 pad[2]; s32 params = ENGOROIWA_GET_C000(&this->actor); - Collider_InitJntSph(globalCtx, &this->collider); - Collider_SetJntSph(globalCtx, &this->collider, &this->actor, &sJntSphInit, this->colliderElements); + Collider_InitJntSph(play, &this->collider); + Collider_SetJntSph(play, &this->collider, &this->actor, &sJntSphInit, this->colliderElements); func_8093E938(this); this->collider.elements[0].dim.worldSphere.radius = this->unk_1DC - 1.0f; @@ -182,13 +182,13 @@ s32 func_8093EAD4(Vec3f* arg0, Vec3f* arg1) { return true; } -void func_8093EB58(EnGoroiwa* this, GlobalContext* globalCtx) { +void func_8093EB58(EnGoroiwa* this, PlayState* play) { this->unk_1E4 = (this->actor.home.rot.x >> 1) & 3; } -f32 func_8093EB74(EnGoroiwa* this, GlobalContext* globalCtx) { +f32 func_8093EB74(EnGoroiwa* this, PlayState* play) { s32 i; - Path* path = &globalCtx->setupPathList[ENGOROIWA_GET_FF(&this->actor)]; + Path* path = &play->setupPathList[ENGOROIWA_GET_FF(&this->actor)]; s32 temp_s4 = path->count; f32 temp_f20 = 0.0f; Vec3f sp54; @@ -253,15 +253,15 @@ void func_8093EDB0(EnGoroiwa* this) { this->unk_1D8 += this->unk_1DA; } -void func_8093EDD8(EnGoroiwa* this, GlobalContext* globalCtx) { - this->unk_1D4 = globalCtx->setupPathList[ENGOROIWA_GET_FF(&this->actor)].count - 1; +void func_8093EDD8(EnGoroiwa* this, PlayState* play) { + this->unk_1D4 = play->setupPathList[ENGOROIWA_GET_FF(&this->actor)].count - 1; this->unk_1D6 = 0; this->unk_1D8 = 1; this->unk_1DA = 1; } -void func_8093EE18(EnGoroiwa* this, GlobalContext* globalCtx) { - this->unk_1D4 = globalCtx->setupPathList[ENGOROIWA_GET_FF(&this->actor)].count - 1; +void func_8093EE18(EnGoroiwa* this, PlayState* play) { + this->unk_1D4 = play->setupPathList[ENGOROIWA_GET_FF(&this->actor)].count - 1; this->unk_1D6 = this->actor.home.rot.y; this->unk_1D8 = this->unk_1D6 + 1; this->unk_1DA = 1; @@ -294,7 +294,7 @@ s32 func_8093EEDC(EnGoroiwa* this) { return 0; } -void func_8093EF54(GlobalContext* globalCtx, Vec3f* arg1, Color_RGBA8* arg2, Color_RGBA8* arg3, f32 arg4) { +void func_8093EF54(PlayState* play, Vec3f* arg1, Color_RGBA8* arg2, Color_RGBA8* arg3, f32 arg4) { Vec3f spC4; f32 temp_f0; f32 temp_f20; @@ -322,12 +322,12 @@ void func_8093EF54(GlobalContext* globalCtx, Vec3f* arg1, Color_RGBA8* arg2, Col temp_f20 = Rand_ZeroOne(); spC4.z = (Math_CosS(phi_s0) * (temp_f24 * ((temp_f20 * 0.5f) + 0.5f))) + arg1->z; // clang-format on - func_800B0E48(globalCtx, &spC4, &D_80942E48, &D_80942E54, arg2, arg3, (Rand_ZeroOne() * temp_f28) + temp_f26, + func_800B0E48(play, &spC4, &D_80942E48, &D_80942E54, arg2, arg3, (Rand_ZeroOne() * temp_f28) + temp_f26, temp_f26); } } -void func_8093F198(GlobalContext* globalCtx, Vec3f* arg1, f32 arg2) { +void func_8093F198(PlayState* play, Vec3f* arg1, f32 arg2) { Vec3f sp74; f32 temp_f20; s32 temp_f16; @@ -343,10 +343,10 @@ void func_8093F198(GlobalContext* globalCtx, Vec3f* arg1, f32 arg2) { for (i = 0, phi_s0 = 0; i < temp_f16; i++, phi_s0 += temp_lo) { sp74.x = (Math_SinS((s32)(Rand_ZeroOne() * temp_lo) + phi_s0) * temp_f20) + arg1->x; sp74.z = (Math_CosS((s32)(Rand_ZeroOne() * temp_lo) + phi_s0) * temp_f20) + arg1->z; - EffectSsGSplash_Spawn(globalCtx, &sp74, NULL, NULL, 0, 0x15E); + EffectSsGSplash_Spawn(play, &sp74, NULL, NULL, 0, 0x15E); } - EffectSsGRipple_Spawn(globalCtx, arg1, 0x1F4, 0x384, 4); + EffectSsGRipple_Spawn(play, arg1, 0x1F4, 0x384, 4); } s32 func_8093F34C(EnGoroiwa* this) { @@ -433,7 +433,7 @@ s32 func_8093F5EC(EnGoroiwa* this) { return false; } -s32 func_8093F6F8(EnGoroiwa* this, GlobalContext* globalCtx) { +s32 func_8093F6F8(EnGoroiwa* this, PlayState* play) { f32 temp_f14; Vec3s* sp80 = &this->unk_1D0[this->unk_1D8]; f32 sp7C = sp80->y; @@ -450,7 +450,7 @@ s32 func_8093F6F8(EnGoroiwa* this, GlobalContext* globalCtx) { if ((this->actor.velocity.y < 0.0f) && (this->actor.world.pos.y <= sp7C)) { if (this->unk_1CA == 0) { if (this->actor.xzDistToPlayer < 400.0f) { - s16 sp72 = Quake_Add(GET_ACTIVE_CAM(globalCtx), 3); + s16 sp72 = Quake_Add(GET_ACTIVE_CAM(play), 3); Quake_SetSpeed(sp72, 0x4350); Quake_SetQuakeValues(sp72, 3, 0, 0, 0); Quake_SetCountdown(sp72, 7); @@ -469,8 +469,7 @@ s32 func_8093F6F8(EnGoroiwa* this, GlobalContext* globalCtx) { sp60.y = this->actor.world.pos.y + 50.0f; sp60.z = this->actor.world.pos.z; - temp_f14 = - BgCheck_EntityRaycastFloor5_2(globalCtx, &globalCtx->colCtx, &poly, &bgId, &this->actor, &sp60); + temp_f14 = BgCheck_EntityRaycastFloor5_2(play, &play->colCtx, &poly, &bgId, &this->actor, &sp60); temp_f2 = temp_f14 - this->actor.world.pos.y; if (fabsf(temp_f2) < (fabsf(this->actor.velocity.y) + 0.01f)) { @@ -479,7 +478,7 @@ s32 func_8093F6F8(EnGoroiwa* this, GlobalContext* globalCtx) { sp48.y = temp_f14 + 10.0f; sp48.z = this->actor.world.pos.z; - func_8093EF54(globalCtx, &sp48, &D_80942E30[ENGOROIWA_GET_C000(&this->actor)], + func_8093EF54(play, &sp48, &D_80942E30[ENGOROIWA_GET_C000(&this->actor)], &D_80942E3C[ENGOROIWA_GET_C000(&this->actor)], this->actor.scale.x); } Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_BIGBALL_BOUND); @@ -501,8 +500,8 @@ s32 func_8093F6F8(EnGoroiwa* this, GlobalContext* globalCtx) { WaterBox* sp44; f32 sp40; - if (WaterBox_GetSurface1_2(globalCtx, &globalCtx->colCtx, this->actor.world.pos.x, this->actor.world.pos.z, - &sp40, &sp44)) { + if (WaterBox_GetSurface1_2(play, &play->colCtx, this->actor.world.pos.x, this->actor.world.pos.z, &sp40, + &sp44)) { if ((this->actor.world.pos.y + this->unk_1DC) <= sp40) { this->unk_1E5 |= 0x20; if (sp40 < (this->unk_1DC + sp78)) { @@ -512,7 +511,7 @@ s32 func_8093F6F8(EnGoroiwa* this, GlobalContext* globalCtx) { sp34.x = this->actor.world.pos.x; sp34.y = sp40; sp34.z = this->actor.world.pos.z; - func_8093F198(globalCtx, &sp34, this->actor.scale.x); + func_8093F198(play, &sp34, this->actor.scale.x); } this->actor.velocity.y *= 0.2f; } @@ -528,7 +527,7 @@ s32 func_8093F6F8(EnGoroiwa* this, GlobalContext* globalCtx) { return false; } -void func_8093FAA4(EnGoroiwa* this, GlobalContext* globalCtx) { +void func_8093FAA4(EnGoroiwa* this, PlayState* play) { f32 temp; f32 tmp2; f32 sp7C; @@ -560,12 +559,12 @@ 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); } void func_8093FC00(EnGoroiwa* this) { @@ -578,7 +577,7 @@ void func_8093FC00(EnGoroiwa* this) { } } -void func_8093FC6C(EnGoroiwa* this, GlobalContext* globalCtx) { +void func_8093FC6C(EnGoroiwa* this, PlayState* play) { s32 i; Vec3f spC0; Vec3f spB4; @@ -599,7 +598,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); @@ -622,8 +621,7 @@ void func_8093FC6C(EnGoroiwa* this, GlobalContext* globalCtx) { spA8.y = spB4.y * -0.05f; spA8.z = spB4.z * -0.02f; - EffectSsIceSmoke_Spawn(globalCtx, &spC0, &spB4, &spA8, - ((s32)(Rand_ZeroOne() * 170.0f) + 150) * temp_f24 * 10.0f); + EffectSsIceSmoke_Spawn(play, &spC0, &spB4, &spA8, ((s32)(Rand_ZeroOne() * 170.0f) + 150) * temp_f24 * 10.0f); } for (i = 0, phi_s0 = 0; i < sp80; i++, phi_s0 += temp) { @@ -644,11 +642,11 @@ void func_8093FC6C(EnGoroiwa* this, GlobalContext* globalCtx) { spC0.y = (Rand_ZeroOne() * 20.0f) + this->actor.world.pos.y; spC0.z = (spC0.z * temp_f20) + this->actor.world.pos.z; - EffectSsIceSmoke_Spawn(globalCtx, &spC0, &spB4, &spA8, (s32)(Rand_ZeroOne() * 1400.0f * temp_f24) + 100); + EffectSsIceSmoke_Spawn(play, &spC0, &spB4, &spA8, (s32)(Rand_ZeroOne() * 1400.0f * temp_f24) + 100); } } -void func_80940090(EnGoroiwa* this, GlobalContext* globalCtx) { +void func_80940090(EnGoroiwa* this, PlayState* play) { s32 pad; s32 pad2; s32 i; @@ -701,7 +699,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; @@ -720,7 +718,7 @@ void func_80940090(EnGoroiwa* this, GlobalContext* globalCtx) { spF4.z = sp100.z * 0.16f * phi_f22; Math_Vec3f_Sum(&sp100, &sp10C, &sp100); - EffectSsKakera_Spawn(globalCtx, &sp100, &spF4, &sp100, phi_s2, phi_s0, 30, 0, 0, + EffectSsKakera_Spawn(play, &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, OBJECT_GOROIWA, phi_s1); if (this->unk_1E6 == 0) { @@ -728,35 +726,33 @@ void func_80940090(EnGoroiwa* this, GlobalContext* globalCtx) { sp100.y += ((Rand_ZeroOne() * 1400.0f) - 600.0f) * this->actor.scale.y; sp100.z += ((Rand_ZeroOne() * 1200.0f) - 600.0f) * this->actor.scale.z; - func_800B0E48(globalCtx, &sp100, &D_80942E48, &D_80942E54, &D_80942E30[sp120], &D_80942E3C[sp120], + func_800B0E48(play, &sp100, &D_80942E48, &D_80942E54, &D_80942E30[sp120], &D_80942E3C[sp120], (Rand_ZeroOne() * 50.0f) + (400.0f * spEC), (Rand_ZeroOne() * 60.0f) + (500.0f * spEC)); } } if (this->unk_1E6 != 0) { - func_8093FC6C(this, globalCtx); + func_8093FC6C(this, play); } } } -#ifdef NON_MATCHING -// Stack -void func_80940588(GlobalContext* globalCtx, Vec3f* arg1, Gfx* arg2[], Color_RGBA8* arg3, Color_RGBA8* arg4, f32 arg5) { +void func_80940588(PlayState* play, 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; @@ -781,7 +777,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; @@ -803,24 +799,20 @@ void func_80940588(GlobalContext* globalCtx, Vec3f* arg1, Gfx* arg2[], Color_RGB } } - EffectSsKakera_Spawn(globalCtx, &sp100, &spF4, &sp100, phi_fp, phi_s0, 30, 0, 0, + EffectSsKakera_Spawn(play, &sp100, &spF4, &sp100, phi_fp, phi_s0, 30, 0, 0, ((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; spE8.y = (((Rand_ZeroOne() * 1300.0f) - 500.0f) * arg5) + sp100.y; spE8.z = (((Rand_ZeroOne() * 1000.0f) - 500.0f) * arg5) + sp100.z; - func_800B0E48(globalCtx, &spE8, &D_80942E48, &D_80942E54, arg3, arg4, (Rand_ZeroOne() * 80.0f) + spB0, + func_800B0E48(play, &spE8, &D_80942E48, &D_80942E54, arg3, arg4, (Rand_ZeroOne() * 80.0f) + spB0, (Rand_ZeroOne() * 70.0f) + spAC); } } } -#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) { +void func_80940A1C(PlayState* play, Vec3f* arg1, Gfx** arg2, Color_RGBA8* arg3, Color_RGBA8* arg4, f32 arg5) { s32 i; Vec3f spE8; Vec3f spDC; @@ -862,7 +854,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; @@ -870,7 +862,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; @@ -878,19 +870,19 @@ void func_80940A1C(GlobalContext* globalCtx, Vec3f* arg1, Gfx** arg2, Color_RGBA } } - EffectSsKakera_Spawn(globalCtx, &spE8, &spDC, &spE8, phi_s2, phi_s0, 30, 0, 0, + EffectSsKakera_Spawn(play, &spE8, &spDC, &spE8, phi_s2, phi_s0, 30, 0, 0, ((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; spE8.z += ((Rand_ZeroOne() * 800.0f) - 400.0f) * arg5; - func_800B0E48(globalCtx, &spE8, &D_80942E48, &D_80942E54, arg3, arg4, (Rand_ZeroOne() * 60.0f) + spAC, + func_800B0E48(play, &spE8, &D_80942E48, &D_80942E54, arg3, arg4, (Rand_ZeroOne() * 60.0f) + spAC, (Rand_ZeroOne() * 30.0f) + spAC); } } -void func_80940E38(EnGoroiwa* this, GlobalContext* globalCtx) { +void func_80940E38(EnGoroiwa* this, PlayState* play) { f32 sp5C; s32 pad; f32 sp54; @@ -915,7 +907,7 @@ void func_80940E38(EnGoroiwa* this, GlobalContext* globalCtx) { sp48.y = this->actor.world.pos.y + 20.0f; sp48.z = (Math_CosS(sp46) * sp54) + this->actor.world.pos.z; - func_800B0E48(globalCtx, &sp48, &D_80942E48, &D_80942E54, &D_80942E38, &D_80942E44, + func_800B0E48(play, &sp48, &D_80942E48, &D_80942E54, &D_80942E38, &D_80942E44, (Rand_ZeroOne() * 600.0f) + (600.0f * (this->actor.scale.x + 0.1f) * 0.5f), (s32)(Rand_ZeroOne() * 50.0f) + 30); } @@ -923,7 +915,7 @@ void func_80940E38(EnGoroiwa* this, GlobalContext* globalCtx) { } } -void func_80941060(EnGoroiwa* this, GlobalContext* globalCtx) { +void func_80941060(EnGoroiwa* this, PlayState* play) { Vec3f spAC; Vec3f spA0; Vec3f sp94; @@ -943,21 +935,21 @@ void func_80941060(EnGoroiwa* this, GlobalContext* globalCtx) { spAC.y = spA0.y * -0.06f; spAC.z = spA0.z * -0.06f; - func_800B0E48(globalCtx, &sp94, &spA0, &spAC, &D_80942E38, &D_80942E44, (s32)(Rand_ZeroOne() * 30.0f) + 15, + func_800B0E48(play, &sp94, &spA0, &spAC, &D_80942E38, &D_80942E44, (s32)(Rand_ZeroOne() * 30.0f) + 15, (s32)(Rand_ZeroOne() * 40.0f) + 30); } } -void func_80941274(EnGoroiwa* this, GlobalContext* globalCtx) { - SoundSource_PlaySfxAtFixedWorldPos(globalCtx, &this->actor.world.pos, 30, NA_SE_EV_SNOWBALL_BROKEN); +void func_80941274(EnGoroiwa* this, PlayState* play) { + SoundSource_PlaySfxAtFixedWorldPos(play, &this->actor.world.pos, 30, NA_SE_EV_SNOWBALL_BROKEN); } -void EnGoroiwa_Init(Actor* thisx, GlobalContext* globalCtx) { +void EnGoroiwa_Init(Actor* thisx, PlayState* play) { EnGoroiwa* this = THIS; f32 temp_f0; s32 params = ENGOROIWA_GET_FF(&this->actor); s32 sp28 = params * 8; - Path* sp2C = &globalCtx->setupPathList[params]; + Path* sp2C = &play->setupPathList[params]; Actor_ProcessInitChain(&this->actor, sInitChain); this->actor.world.rot.x = 0; @@ -968,7 +960,7 @@ void EnGoroiwa_Init(Actor* thisx, GlobalContext* globalCtx) { this->actor.shape.rot.z = 0; func_8093E8A0(this); func_8093E91C(this); - func_8093E9B0(this, globalCtx); + func_8093E9B0(this, play); if (sp28 == 0x7F8) { Actor_MarkForDeath(&this->actor); @@ -987,22 +979,22 @@ void EnGoroiwa_Init(Actor* thisx, GlobalContext* globalCtx) { CollisionCheck_SetInfo(&this->actor.colChkInfo, NULL, &sColChkInfoInit); ActorShape_Init(&this->actor.shape, 595.0f, ActorShadow_DrawCircle, 9.4f); this->actor.shape.shadowAlpha = 200; - func_8093EB58(this, globalCtx); + func_8093EB58(this, play); this->unk_1D0 = Lib_SegmentedToVirtual(sp2C->points); - func_8093EE18(this, globalCtx); + func_8093EE18(this, play); func_8093EE64(this, this->actor.home.rot.y); func_8093EEBC(this); func_8093EC50(this); if (ENGOROIWA_GET_3000(&this->actor) == ENGOROIWA_3000_2) { - temp_f0 = func_8093EB74(this, globalCtx); + temp_f0 = func_8093EB74(this, play); if (temp_f0 < 0.1f) { this->unk_1E0 = 0.0f; } else { - this->unk_1E0 = (D_80942DFC[this->unk_1E4] * ((s32)globalCtx->state.framerateDivisor * 0.5f)) / temp_f0; + this->unk_1E0 = (D_80942DFC[this->unk_1E4] * ((s32)play->state.framerateDivisor * 0.5f)) / temp_f0; this->unk_1E0 *= 0.020000001f; if (this->unk_1E0 > 0.00037f) { this->unk_1E0 = 0.00037f; @@ -1012,18 +1004,18 @@ void EnGoroiwa_Init(Actor* thisx, GlobalContext* globalCtx) { } } - Effect_Add(globalCtx, &this->unk_248, 4, 0, 0, &D_80942E8C); + Effect_Add(play, &this->unk_248, 4, 0, 0, &D_80942E8C); func_809419D0(this); } -void EnGoroiwa_Destroy(Actor* thisx, GlobalContext* globalCtx) { +void EnGoroiwa_Destroy(Actor* thisx, PlayState* play) { EnGoroiwa* this = THIS; - Collider_DestroyJntSph(globalCtx, &this->collider); - Effect_Destroy(globalCtx, this->unk_248); + Collider_DestroyJntSph(play, &this->collider); + Effect_Destroy(play, this->unk_248); } -s32 func_8094156C(EnGoroiwa* this, GlobalContext* globalCtx) { +s32 func_8094156C(EnGoroiwa* this, PlayState* play) { Actor* actor = &this->actor; s32 params = ENGOROIWA_GET_C000(&this->actor); EnGoroiwaStruct* ptr; @@ -1081,9 +1073,9 @@ s32 func_8094156C(EnGoroiwa* this, GlobalContext* globalCtx) { sp80.x = this->actor.world.pos.x; sp80.y = this->actor.world.pos.y + this->unk_1DC; sp80.z = this->actor.world.pos.z; - func_80940588(globalCtx, &sp80, D_80942E0C[params], &D_80942E30[params], &D_80942E3C[params], + func_80940588(play, &sp80, D_80942E0C[params], &D_80942E30[params], &D_80942E3C[params], this->actor.scale.x); - func_80941274(this, globalCtx); + func_80941274(this, play); phi_s0_2 = true; } else if (((params == ENGOROIWA_C000_1) && (this->collider.elements->info.acHitInfo->toucher.dmgFlags & (0x400 | 0x100))) || @@ -1093,12 +1085,12 @@ s32 func_8094156C(EnGoroiwa* this, GlobalContext* globalCtx) { if ((params == ENGOROIWA_C000_2) && (this->collider.elements->info.acHitInfo->toucher.dmgFlags & 0x800)) { this->unk_1E6 = 1; } - func_80940090(this, globalCtx); - func_80941274(this, globalCtx); + func_80940090(this, play); + func_80941274(this, play); func_809425CC(this); phi_s0_2 = true; } else if ((params == ENGOROIWA_C000_2) && (this->unk_1E7 <= 0)) { - func_80941060(this, globalCtx); + func_80941060(this, play); this->unk_1E7 = 10; } } @@ -1109,7 +1101,7 @@ s32 func_8094156C(EnGoroiwa* this, GlobalContext* globalCtx) { } if (phi_s0_2) { - Item_DropCollectibleRandom(globalCtx, NULL, &this->actor.world.pos, 0x20); + Item_DropCollectibleRandom(play, NULL, &this->actor.world.pos, 0x20); } } return phi_s0_2; @@ -1121,7 +1113,7 @@ void func_809419D0(EnGoroiwa* this) { this->unk_1C4 = 1.0f; } -void func_80941A10(EnGoroiwa* this, GlobalContext* globalCtx) { +void func_80941A10(EnGoroiwa* this, PlayState* play) { static EnGoroiwaUnkFunc D_80942E94[] = { &func_8093F498, &func_8093F34C, @@ -1133,24 +1125,24 @@ void func_80941A10(EnGoroiwa* this, GlobalContext* globalCtx) { { NA_SE_EV_BIGBALL_ROLL - SFX_FLAG, NA_SE_EV_BIGBALL_ROLL_SR - SFX_FLAG }, }; s32 pad; - Player* player = GET_PLAYER(globalCtx); + Player* player = GET_PLAYER(play); s32 sp44 = ENGOROIWA_GET_400(&this->actor); s32 sp40 = ENGOROIWA_GET_3000(&this->actor); s16 y; s32 pad2; - if (!func_8094156C(this, globalCtx)) { + if (!func_8094156C(this, play)) { if ((this->collider.base.atFlags & AT_HIT) && !(player->stateFlags3 & 0x80000)) { s32 sp34 = this->actor.home.rot.z & 3; if (sp34 == 2) { - func_80940090(this, globalCtx); + func_80940090(this, play); if (sp40 == ENGOROIWA_3000_2) { func_8093E8A0(this); func_8093E91C(this); } - func_80941274(this, globalCtx); - func_8093EDD8(this, globalCtx); + func_80941274(this, play); + func_8093EDD8(this, play); func_8093EE64(this, 0); func_8093EEBC(this); } else { @@ -1164,7 +1156,7 @@ void func_80941A10(EnGoroiwa* this, GlobalContext* globalCtx) { } } - func_800B8D50(globalCtx, &this->actor, 2.0f, this->actor.yawTowardsPlayer, 0.0f, 0); + func_800B8D50(play, &this->actor, 2.0f, this->actor.yawTowardsPlayer, 0.0f, 0); if (sp34 == 2) { func_80941EB4(this); @@ -1184,8 +1176,8 @@ void func_80941A10(EnGoroiwa* this, GlobalContext* globalCtx) { s32 sp30 = ENGOROIWA_GET_300(&this->actor); if ((sp30 == ENGOROIWA_300_1) && ((this->unk_1D8 == 0) || (this->unk_1D8 == this->unk_1D4))) { - func_80940090(this, globalCtx); - func_80941274(this, globalCtx); + func_80940090(this, play); + func_80941274(this, play); } if (((sp30 == ENGOROIWA_300_1) || (sp30 == ENGOROIWA_300_0)) && (sp40 == ENGOROIWA_3000_2) && @@ -1229,7 +1221,7 @@ void func_80941DB4(EnGoroiwa* this) { this->unk_1C4 = 1.0f; } -void func_80941E28(EnGoroiwa* this, GlobalContext* globalCtx) { +void func_80941E28(EnGoroiwa* this, PlayState* play) { func_8093F34C(this); if ((this->actor.bgCheckFlags & 1) && (this->actor.velocity.y < 0.0f)) { if ((this->unk_1E5 & 8) && ((this->actor.home.rot.z & 3) == 1)) { @@ -1249,8 +1241,8 @@ void func_80941EB4(EnGoroiwa* this) { this->unk_1C4 = 0.0f; } -void func_80941F10(EnGoroiwa* this, GlobalContext* globalCtx) { - if (!func_8094156C(this, globalCtx)) { +void func_80941F10(EnGoroiwa* this, PlayState* play) { + if (!func_8094156C(this, play)) { if (this->unk_1C8 > 0) { this->unk_1C8--; } else { @@ -1266,12 +1258,12 @@ void func_80941F54(EnGoroiwa* this) { this->actor.velocity.y = fabsf(this->actor.speedXZ) * 0.1f; } -void func_80941FA4(EnGoroiwa* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); +void func_80941FA4(EnGoroiwa* this, PlayState* play) { + Player* player = GET_PLAYER(play); - if (func_8094156C(this, globalCtx) == 0) { + if (func_8094156C(this, play) == 0) { if ((this->collider.base.atFlags & AT_HIT) && !(player->stateFlags3 & 0x80000)) { - func_800B8D50(globalCtx, &this->actor, 2.0f, this->actor.yawTowardsPlayer, 0.0f, 0); + func_800B8D50(play, &this->actor, 2.0f, this->actor.yawTowardsPlayer, 0.0f, 0); func_800B8E58(player, NA_SE_PL_BODY_HIT); if (((this->actor.home.rot.z & 3) == 1) || ((this->actor.home.rot.z & 3) == 2)) { this->unk_1CC = 50; @@ -1294,17 +1286,17 @@ void func_80942084(EnGoroiwa* this) { this->unk_1E5 &= ~0x20; } -void func_809420F0(EnGoroiwa* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); +void func_809420F0(EnGoroiwa* this, PlayState* play) { + Player* player = GET_PLAYER(play); - if (func_8094156C(this, globalCtx) == 0) { + if (func_8094156C(this, play) == 0) { if ((this->collider.base.atFlags & AT_HIT) && !(player->stateFlags3 & 0x80000)) { - func_800B8D50(globalCtx, &this->actor, 2.0f, this->actor.yawTowardsPlayer, 0.0f, 0); + func_800B8D50(play, &this->actor, 2.0f, this->actor.yawTowardsPlayer, 0.0f, 0); func_800B8E58(player, NA_SE_PL_BODY_HIT); if (((this->actor.home.rot.z & 3) == 1) || ((this->actor.home.rot.z & 3) == 2)) { this->unk_1CC = 50; } - } else if (func_8093F6F8(this, globalCtx)) { + } else if (func_8093F6F8(this, play)) { func_8093FC00(this); func_809419D0(this); this->unk_1E5 &= ~0x10; @@ -1318,7 +1310,7 @@ void func_809421E0(EnGoroiwa* this) { func_8093EAB0(this, 0); } -void func_8094220C(EnGoroiwa* this, GlobalContext* globalCtx) { +void func_8094220C(EnGoroiwa* this, PlayState* play) { s32 pad; EnGoroiwaStruct* ptr; s32 i; @@ -1352,11 +1344,11 @@ void func_8094220C(EnGoroiwa* this, GlobalContext* globalCtx) { spC4.y = ptr->unk_00.y + 25.0f; spC4.z = ptr->unk_00.z; - ptr->unk_18 = BgCheck_EntityRaycastFloor5(&globalCtx->colCtx, &ptr->unk_28, &spD0, &this->actor, &spC4); + ptr->unk_18 = BgCheck_EntityRaycastFloor5(&play->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, MTXMODE_NEW); - 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) { @@ -1380,7 +1372,7 @@ void func_8094220C(EnGoroiwa* this, GlobalContext* globalCtx) { sp9C.x = ptr->unk_00.x; sp9C.y = (ptr->unk_00.y - ptr->unk_10) + 10.0f; sp9C.z = ptr->unk_00.z; - func_80940A1C(globalCtx, &sp9C, D_80942E0C[params], &D_80942E30[params], &D_80942E3C[params], + func_80940A1C(play, &sp9C, D_80942E0C[params], &D_80942E30[params], &D_80942E3C[params], this->actor.scale.x); } } @@ -1415,7 +1407,7 @@ void func_809425CC(EnGoroiwa* this) { this->unk_1C8 = 100; } -void func_80942604(EnGoroiwa* this, GlobalContext* globalCtx) { +void func_80942604(EnGoroiwa* this, PlayState* play) { s32 pad; s16 sp22 = this->actor.shape.shadowAlpha; @@ -1428,10 +1420,10 @@ void func_80942604(EnGoroiwa* this, GlobalContext* globalCtx) { } } -void EnGoroiwa_Update(Actor* thisx, GlobalContext* globalCtx) { +void EnGoroiwa_Update(Actor* thisx, PlayState* play) { s32 pad; EnGoroiwa* this = THIS; - Player* player = GET_PLAYER(globalCtx); + Player* player = GET_PLAYER(play); s32 bgId; s32 sp5C = false; Vec3f sp50; @@ -1458,7 +1450,7 @@ void EnGoroiwa_Update(Actor* thisx, GlobalContext* globalCtx) { 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); + temp_v0_2 = func_800C99D4(&play->colCtx, tmp, this->actor.floorBgId); if ((temp_v0_2 == 14) || (temp_v0_2 == 15)) { if (!(this->unk_1E5 & 0x40)) { @@ -1466,7 +1458,7 @@ void EnGoroiwa_Update(Actor* thisx, GlobalContext* globalCtx) { sp50.y = this->actor.floorHeight; sp50.z = this->actor.world.pos.z; sp4C = (((Rand_ZeroOne() * 36.0f) + 250.0f) * this->actor.scale.x) + 10.0f; - func_800AE930(&globalCtx->colCtx, Effect_GetByIndex(this->unk_248), &sp50, sp4C, + func_800AE930(&play->colCtx, Effect_GetByIndex(this->unk_248), &sp50, sp4C, this->actor.world.rot.y, this->actor.floorPoly, this->actor.floorBgId); } sp48 = false; @@ -1479,26 +1471,26 @@ void EnGoroiwa_Update(Actor* thisx, GlobalContext* globalCtx) { func_800AEF44(Effect_GetByIndex(this->unk_248)); } - this->actionFunc(this, globalCtx); + this->actionFunc(this, play); if (this->actor.update != NULL) { func_8093EC50(this); if (sp5C) { - func_80940E38(this, globalCtx); + func_80940E38(this, play); } switch (ENGOROIWA_GET_400(&this->actor)) { case ENGOROIWA_400_1: - Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 0.0f, 0.0f, 0.0f, 0x1C); + Actor_UpdateBgCheckInfo(play, &this->actor, 0.0f, 0.0f, 0.0f, 0x1C); break; case ENGOROIWA_400_0: sp50.x = this->actor.world.pos.x; sp50.y = this->actor.world.pos.y + 50.0f; sp50.z = this->actor.world.pos.z; - this->actor.floorHeight = BgCheck_EntityRaycastFloor5(&globalCtx->colCtx, &this->actor.floorPoly, - &bgId, &this->actor, &sp50); + this->actor.floorHeight = + BgCheck_EntityRaycastFloor5(&play->colCtx, &this->actor.floorPoly, &bgId, &this->actor, &sp50); if (this->actor.floorHeight > BGCHECK_Y_MIN) { this->actor.floorBgId = bgId; if (this->actor.world.pos.y <= (this->actor.floorHeight + 2.0f)) { @@ -1513,7 +1505,7 @@ void EnGoroiwa_Update(Actor* thisx, GlobalContext* globalCtx) { break; } - func_8093FAA4(this, globalCtx); + func_8093FAA4(this, play); if (this->actor.flags & ACTOR_FLAG_40) { s32 params = ENGOROIWA_GET_C000(&this->actor); @@ -1523,19 +1515,19 @@ void EnGoroiwa_Update(Actor* thisx, GlobalContext* globalCtx) { if ((this->unk_1E5 & 1) && (this->unk_1CC <= 0) && (!(player->stateFlags3 & 0x2000000) || (player->transformation != PLAYER_FORM_GORON) || ((params != ENGOROIWA_C000_1) && (params != ENGOROIWA_C000_2)))) { - CollisionCheck_SetAT(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + CollisionCheck_SetAT(play, &play->colChkCtx, &this->collider.base); } else { this->collider.base.atFlags &= ~AT_HIT; } if (this->unk_1E5 & 2) { - CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + CollisionCheck_SetAC(play, &play->colChkCtx, &this->collider.base); } else { this->collider.base.acFlags &= ~AC_HIT; } if ((this->unk_1E5 & 4) && (this->unk_1CC <= 0)) { - CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + CollisionCheck_SetOC(play, &play->colChkCtx, &this->collider.base); } else { this->collider.base.ocFlags1 &= ~OC1_HIT; } @@ -1548,7 +1540,7 @@ void EnGoroiwa_Update(Actor* thisx, GlobalContext* globalCtx) { } } -void func_80942B1C(EnGoroiwa* this, GlobalContext* globalCtx) { +void func_80942B1C(EnGoroiwa* this, PlayState* play) { s32 pad; s32 pad2; s32 i; @@ -1572,34 +1564,34 @@ 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); + Gfx_DrawDListOpa(play, phi_fp); if ((ptr->unk_28 != 0) && (ptr->unk_2C > 0)) { - OPEN_DISPS(globalCtx->state.gfxCtx); + OPEN_DISPS(play->state.gfxCtx); - func_8012C448(globalCtx->state.gfxCtx); + func_8012C448(play->state.gfxCtx); gDPSetCombineLERP(POLY_XLU_DISP++, 0, 0, 0, PRIMITIVE, TEXEL0, 0, PRIMITIVE, 0, 0, 0, 0, COMBINED, 0, 0, 0, COMBINED); gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 0, 0, 0, ptr->unk_2C); func_800C0094(ptr->unk_28, ptr->unk_00.x, ptr->unk_18, ptr->unk_00.z, &sp88); - Matrix_SetCurrentState(&sp88); + Matrix_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), + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_XLU_DISP++, gCircleShadowDL); - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->state.gfxCtx); } } } } -void EnGoroiwa_Draw(Actor* thisx, GlobalContext* globalCtx) { +void EnGoroiwa_Draw(Actor* thisx, PlayState* play) { static Gfx* D_80942EB4[] = { object_goroiwa_DL_005C20, object_goroiwa_DL_003B40, @@ -1609,8 +1601,8 @@ void EnGoroiwa_Draw(Actor* thisx, GlobalContext* globalCtx) { s32 params = ENGOROIWA_GET_C000(&this->actor); if (this->actionFunc == func_8094220C) { - func_80942B1C(this, globalCtx); + func_80942B1C(this, play); } else if (this->actionFunc != func_80942604) { - Gfx_DrawDListOpa(globalCtx, D_80942EB4[params]); + Gfx_DrawDListOpa(play, D_80942EB4[params]); } } diff --git a/src/overlays/actors/ovl_En_Goroiwa/z_en_goroiwa.h b/src/overlays/actors/ovl_En_Goroiwa/z_en_goroiwa.h index 2a3ae2505..fc4f66f51 100644 --- a/src/overlays/actors/ovl_En_Goroiwa/z_en_goroiwa.h +++ b/src/overlays/actors/ovl_En_Goroiwa/z_en_goroiwa.h @@ -5,7 +5,7 @@ struct EnGoroiwa; -typedef void (*EnGoroiwaActionFunc)(struct EnGoroiwa*, GlobalContext*); +typedef void (*EnGoroiwaActionFunc)(struct EnGoroiwa*, PlayState*); typedef s32 (*EnGoroiwaUnkFunc)(struct EnGoroiwa*); #define ENGOROIWA_GET_C000(thisx) (((thisx)->params >> 0xE) & 3) @@ -54,31 +54,31 @@ typedef struct { } EnGoroiwaStruct; // size = 0x30 typedef struct EnGoroiwa { - /* 0x0000 */ Actor actor; - /* 0x0144 */ ColliderJntSph collider; - /* 0x0164 */ ColliderJntSphElement colliderElements[1]; - /* 0x01A4 */ EnGoroiwaActionFunc actionFunc; - /* 0x01A8 */ Vec3f unk_1A8; - /* 0x01B4 */ Vec3f unk_1B4; - /* 0x01C0 */ f32 unk_1C0; - /* 0x01C4 */ f32 unk_1C4; - /* 0x01C8 */ s16 unk_1C8; - /* 0x01CA */ s16 unk_1CA; - /* 0x01CC */ s16 unk_1CC; - /* 0x01CE */ s16 unk_1CE; - /* 0x01D0 */ Vec3s* unk_1D0; - /* 0x01D4 */ s16 unk_1D4; - /* 0x01D6 */ s16 unk_1D6; - /* 0x01D8 */ s16 unk_1D8; - /* 0x01DA */ s16 unk_1DA; - /* 0x01DC */ f32 unk_1DC; - /* 0x01E0 */ f32 unk_1E0; - /* 0x01E4 */ s8 unk_1E4; - /* 0x01E5 */ u8 unk_1E5; - /* 0x01E6 */ s8 unk_1E6; - /* 0x01E7 */ s8 unk_1E7; - /* 0x01E8 */ EnGoroiwaStruct unk_1E8[2]; - /* 0x0248 */ s32 unk_248; + /* 0x000 */ Actor actor; + /* 0x144 */ ColliderJntSph collider; + /* 0x164 */ ColliderJntSphElement colliderElements[1]; + /* 0x1A4 */ EnGoroiwaActionFunc actionFunc; + /* 0x1A8 */ Vec3f unk_1A8; + /* 0x1B4 */ Vec3f unk_1B4; + /* 0x1C0 */ f32 unk_1C0; + /* 0x1C4 */ f32 unk_1C4; + /* 0x1C8 */ s16 unk_1C8; + /* 0x1CA */ s16 unk_1CA; + /* 0x1CC */ s16 unk_1CC; + /* 0x1CE */ s16 unk_1CE; + /* 0x1D0 */ Vec3s* unk_1D0; + /* 0x1D4 */ s16 unk_1D4; + /* 0x1D6 */ s16 unk_1D6; + /* 0x1D8 */ s16 unk_1D8; + /* 0x1DA */ s16 unk_1DA; + /* 0x1DC */ f32 unk_1DC; + /* 0x1E0 */ f32 unk_1E0; + /* 0x1E4 */ s8 unk_1E4; + /* 0x1E5 */ u8 unk_1E5; + /* 0x1E6 */ s8 unk_1E6; + /* 0x1E7 */ s8 unk_1E7; + /* 0x1E8 */ EnGoroiwaStruct unk_1E8[2]; + /* 0x248 */ s32 unk_248; } EnGoroiwa; // size = 0x24C extern const ActorInit En_Goroiwa_InitVars; diff --git a/src/overlays/actors/ovl_En_Grasshopper/z_en_grasshopper.c b/src/overlays/actors/ovl_En_Grasshopper/z_en_grasshopper.c index e19d2fa37..be274690c 100644 --- a/src/overlays/actors/ovl_En_Grasshopper/z_en_grasshopper.c +++ b/src/overlays/actors/ovl_En_Grasshopper/z_en_grasshopper.c @@ -10,10 +10,10 @@ #define THIS ((EnGrasshopper*)thisx) -void EnGrasshopper_Init(Actor* thisx, GlobalContext* globalCtx); -void EnGrasshopper_Destroy(Actor* thisx, GlobalContext* globalCtx); -void EnGrasshopper_Update(Actor* thisx, GlobalContext* globalCtx); -void EnGrasshopper_Draw(Actor* thisx, GlobalContext* globalCtx); +void EnGrasshopper_Init(Actor* thisx, PlayState* play); +void EnGrasshopper_Destroy(Actor* thisx, PlayState* play); +void EnGrasshopper_Update(Actor* thisx, PlayState* play); +void EnGrasshopper_Draw(Actor* thisx, PlayState* play); #if 0 // static DamageTable sDamageTable = { @@ -79,7 +79,7 @@ static ColliderJntSphElementInit D_809A8D1C[2] = { // static ColliderJntSphInit sJntSphInit = { static ColliderJntSphInit D_809A8D64 = { { COLTYPE_HIT2, AT_ON | AT_TYPE_ENEMY, AC_ON | AC_TYPE_PLAYER, OC1_ON | OC1_TYPE_1, OC2_TYPE_1, COLSHAPE_JNTSPH, }, - 2, D_809A8D1C, // sJntSphElementsInit, + ARRAY_COUNT(sJntSphElementsInit), D_809A8D1C, // sJntSphElementsInit, }; #endif diff --git a/src/overlays/actors/ovl_En_Grasshopper/z_en_grasshopper.h b/src/overlays/actors/ovl_En_Grasshopper/z_en_grasshopper.h index 5099fd8c2..dc8e95008 100644 --- a/src/overlays/actors/ovl_En_Grasshopper/z_en_grasshopper.h +++ b/src/overlays/actors/ovl_En_Grasshopper/z_en_grasshopper.h @@ -5,7 +5,7 @@ struct EnGrasshopper; -typedef void (*EnGrasshopperActionFunc)(struct EnGrasshopper*, GlobalContext*); +typedef void (*EnGrasshopperActionFunc)(struct EnGrasshopper*, PlayState*); typedef struct EnGrasshopper { /* 0x0000 */ Actor actor; 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 cfd252d07..e831328f6 100644 --- a/src/overlays/actors/ovl_En_Gs/z_en_gs.c +++ b/src/overlays/actors/ovl_En_Gs/z_en_gs.c @@ -12,29 +12,29 @@ #define THIS ((EnGs*)thisx) -void EnGs_Init(Actor* thisx, GlobalContext* globalCtx); -void EnGs_Destroy(Actor* thisx, GlobalContext* globalCtx); -void EnGs_Update(Actor* thisx, GlobalContext* globalCtx); -void EnGs_Draw(Actor* thisx, GlobalContext* globalCtx); +void EnGs_Init(Actor* thisx, PlayState* play); +void EnGs_Destroy(Actor* thisx, PlayState* play); +void EnGs_Update(Actor* thisx, PlayState* play); +void EnGs_Draw(Actor* thisx, PlayState* play); -void func_80997D14(EnGs* this, GlobalContext* globalCtx); -void func_80997D38(EnGs* this, GlobalContext* globalCtx); -void func_80997E4C(EnGs* this, GlobalContext* globalCtx); -void func_80998040(EnGs* this, GlobalContext* globalCtx); -void func_8099807C(EnGs* this, GlobalContext* globalCtx); -void func_80998300(EnGs* this, GlobalContext* globalCtx); -void func_809984F4(EnGs* this, GlobalContext* globalCtx); -void func_809985B8(EnGs* this, GlobalContext* globalCtx); -void func_80998704(EnGs* this, GlobalContext* globalCtx); -void func_8099874C(EnGs* this, GlobalContext* globalCtx); -void func_809989B4(EnGs* this, GlobalContext* globalCtx); -void func_809989F4(EnGs* this, GlobalContext* globalCtx); -s32 func_80998A48(EnGs* this, GlobalContext* globalCtx); -s32 func_80998BBC(EnGs* this, GlobalContext* globalCtx); -s32 func_80998D44(EnGs* this, GlobalContext* globalCtx); -s32 func_80998F9C(EnGs* this, GlobalContext* globalCtx); -s32 func_809995A4(EnGs* this, GlobalContext* globalCtx); -void func_80999A8C(EnGs* this, GlobalContext* globalCtx); +void func_80997D14(EnGs* this, PlayState* play); +void func_80997D38(EnGs* this, PlayState* play); +void func_80997E4C(EnGs* this, PlayState* play); +void func_80998040(EnGs* this, PlayState* play); +void func_8099807C(EnGs* this, PlayState* play); +void func_80998300(EnGs* this, PlayState* play); +void func_809984F4(EnGs* this, PlayState* play); +void func_809985B8(EnGs* this, PlayState* play); +void func_80998704(EnGs* this, PlayState* play); +void func_8099874C(EnGs* this, PlayState* play); +void func_809989B4(EnGs* this, PlayState* play); +void func_809989F4(EnGs* this, PlayState* play); +s32 func_80998A48(EnGs* this, PlayState* play); +s32 func_80998BBC(EnGs* this, PlayState* play); +s32 func_80998D44(EnGs* this, PlayState* play); +s32 func_80998F9C(EnGs* this, PlayState* play); +s32 func_809995A4(EnGs* this, PlayState* play); +void func_80999A8C(EnGs* this, PlayState* play); void func_80999AC0(EnGs* this); const ActorInit En_Gs_InitVars = { @@ -132,7 +132,7 @@ static InitChainEntry sInitChain[] = { ICHAIN_VEC3F_DIV1000(scale, 100, ICHAIN_STOP), }; -void EnGs_Init(Actor* thisx, GlobalContext* globalCtx) { +void EnGs_Init(Actor* thisx, PlayState* play) { s32 pad; EnGs* this = THIS; @@ -144,7 +144,7 @@ void EnGs_Init(Actor* thisx, GlobalContext* globalCtx) { this->unk_196 = ENGS_GET_FE0(thisx); this->actor.params = ENGS_GET_F000(thisx); this->actor.world.rot.z = 0; - Collider_InitAndSetCylinder(globalCtx, &this->collider, &this->actor, &sCylinderInit); + Collider_InitAndSetCylinder(play, &this->collider, &this->actor, &sCylinderInit); CollisionCheck_SetInfo2(&this->actor.colChkInfo, &sDamageTable, &sColChkInfoInit); this->actor.targetMode = 6; this->unk_216 = 0; @@ -154,8 +154,8 @@ 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); + 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) { @@ -163,38 +163,38 @@ void EnGs_Init(Actor* thisx, GlobalContext* globalCtx) { this->collider.dim.radius *= 1.5f; this->collider.dim.height *= 1.5f; } - func_80997D14(this, globalCtx); + func_80997D14(this, play); } -void EnGs_Destroy(Actor* thisx, GlobalContext* globalCtx) { +void EnGs_Destroy(Actor* thisx, PlayState* play) { EnGs* this = THIS; - Collider_DestroyCylinder(globalCtx, &this->collider); + Collider_DestroyCylinder(play, &this->collider); func_80165690(); } -void func_80997D14(EnGs* this, GlobalContext* globalCtx) { +void func_80997D14(EnGs* this, PlayState* play) { this->unk_19A &= ~0x200; this->actionFunc = func_80997D38; } -void func_80997D38(EnGs* this, GlobalContext* globalCtx) { +void func_80997D38(EnGs* this, PlayState* play) { static f32 D_8099A408[] = { 40.0f, 60.0f, 40.0f, 40.0f }; - if (Message_GetState(&globalCtx->msgCtx) == 0) { + if (Message_GetState(&play->msgCtx) == TEXT_STATE_NONE) { 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, play, D_8099A408[this->actor.params], D_8099A408[this->actor.params], + PLAYER_AP_NONE, 0x2000, 0x2000); } } if (this->actor.params != ENGS_2) { - func_800B874C(&this->actor, globalCtx, 100.0f, 100.0f); + func_800B874C(&this->actor, play, 100.0f, 100.0f); } } -void func_80997DEC(EnGs* this, GlobalContext* globalCtx) { - if (Player_GetMask(globalCtx) == PLAYER_MASK_TRUTH) { +void func_80997DEC(EnGs* this, PlayState* play) { + if (Player_GetMask(play) == PLAYER_MASK_TRUTH) { this->unk_210 = 0x20D1; } else { this->unk_210 = 0x20D0; @@ -203,24 +203,24 @@ void func_80997DEC(EnGs* this, GlobalContext* globalCtx) { this->actionFunc = func_80997E4C; } -void func_80997E4C(EnGs* this, GlobalContext* globalCtx) { - switch (Message_GetState(&globalCtx->msgCtx)) { - case 0: - Message_StartTextbox(globalCtx, this->unk_210, &this->actor); +void func_80997E4C(EnGs* this, PlayState* play) { + switch (Message_GetState(&play->msgCtx)) { + case TEXT_STATE_NONE: + Message_StartTextbox(play, this->unk_210, &this->actor); break; - case 1: - case 2: - case 3: + case TEXT_STATE_1: + case TEXT_STATE_CLOSING: + case TEXT_STATE_3: break; - case 4: - case 5: - case 6: - if (Message_ShouldAdvance(globalCtx)) { - switch (globalCtx->msgCtx.currentTextId) { + case TEXT_STATE_CHOICE: + case TEXT_STATE_5: + case TEXT_STATE_DONE: + if (Message_ShouldAdvance(play)) { + switch (play->msgCtx.currentTextId) { case 0x20D0: - func_80997D14(this, globalCtx); + func_80997D14(this, play); break; case 0x20D1: @@ -249,11 +249,11 @@ void func_80997E4C(EnGs* this, GlobalContext* globalCtx) { this->unk_210 = this->unk_195 + 0x20F7; break; } - func_80151938(globalCtx, this->unk_210); + func_80151938(play, this->unk_210); break; default: - func_80997D14(this, globalCtx); + func_80997D14(this, play); break; } } @@ -261,67 +261,67 @@ void func_80997E4C(EnGs* this, GlobalContext* globalCtx) { } } -void func_80997FF0(EnGs* this, GlobalContext* globalCtx) { - if (SubS_StartActorCutscene(&this->actor, globalCtx->playerActorCsIds[0], -1, SUBS_CUTSCENE_NORMAL)) { - func_80998040(this, globalCtx); +void func_80997FF0(EnGs* this, PlayState* play) { + if (SubS_StartActorCutscene(&this->actor, play->playerActorCsIds[0], -1, SUBS_CUTSCENE_NORMAL)) { + func_80998040(this, play); } } -void func_80998040(EnGs* this, GlobalContext* globalCtx) { - func_80152434(globalCtx, 1); +void func_80998040(EnGs* this, PlayState* play) { + func_80152434(play, 1); this->actionFunc = func_8099807C; } -void func_8099807C(EnGs* this, GlobalContext* globalCtx) { - switch (globalCtx->msgCtx.ocarinaMode) { +void func_8099807C(EnGs* this, PlayState* play) { + switch (play->msgCtx.ocarinaMode) { case 3: - switch (globalCtx->msgCtx.unk1202E) { - case 7: - case 8: - if (!Flags_GetSwitch(globalCtx, this->unk_196)) { - Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_ELF, this->actor.world.pos.x, + switch (play->msgCtx.lastPlayedSong) { + case OCARINA_SONG_HEALING: + case OCARINA_SONG_EPONAS: + if (!Flags_GetSwitch(play, this->unk_196)) { + Actor_Spawn(&play->actorCtx, play, ACTOR_EN_ELF, this->actor.world.pos.x, this->actor.world.pos.y + 40.0f, this->actor.world.pos.z, 0, 0, 0, 2); Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_BUTTERFRY_TO_FAIRY); - Flags_SetSwitch(globalCtx, this->unk_196); + Flags_SetSwitch(play, this->unk_196); } break; - case 10: - if (!Flags_GetSwitch(globalCtx, this->unk_196)) { - Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_ELF, this->actor.world.pos.x, + case OCARINA_SONG_STORMS: + if (!Flags_GetSwitch(play, this->unk_196)) { + Actor_Spawn(&play->actorCtx, play, ACTOR_EN_ELF, this->actor.world.pos.x, this->actor.world.pos.y + 40.0f, this->actor.world.pos.z, 0, 0, 0, 7); Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_BUTTERFRY_TO_FAIRY); - Flags_SetSwitch(globalCtx, this->unk_196); + Flags_SetSwitch(play, this->unk_196); } break; - case 0: + case OCARINA_SONG_SONATA: if ((this->actor.params == ENGS_1) && (gSaveContext.save.playerForm == PLAYER_FORM_DEKU)) { this->unk_194 = 1; this->unk_19C = 5; this->unk_19A |= 1; func_80999AC0(this); - func_809984F4(this, globalCtx); + func_809984F4(this, play); } break; - case 2: + case OCARINA_SONG_NEW_WAVE: if ((this->actor.params == ENGS_1) && (gSaveContext.save.playerForm == PLAYER_FORM_ZORA)) { this->unk_194 = 3; this->unk_19C = 5; this->unk_19A |= 1; func_80999AC0(this); - func_809984F4(this, globalCtx); + func_809984F4(this, play); } break; - case 1: + case OCARINA_SONG_GORON_LULLABY: if ((this->actor.params == ENGS_1) && (gSaveContext.save.playerForm == PLAYER_FORM_GORON)) { this->unk_194 = 2; this->unk_19C = 5; this->unk_19A |= 1; func_80999AC0(this); - func_809984F4(this, globalCtx); + func_809984F4(this, play); } break; } @@ -329,62 +329,62 @@ void func_8099807C(EnGs* this, GlobalContext* globalCtx) { case 0: case 4: - func_80998300(this, globalCtx); + func_80998300(this, play); case 26: - func_80997D14(this, globalCtx); + func_80997D14(this, play); break; } } -void func_80998300(EnGs* this, GlobalContext* globalCtx) { +void func_80998300(EnGs* this, PlayState* play) { if (this->actor.cutscene != -1) { - ActorCutscene_Stop(globalCtx->playerActorCsIds[0]); + ActorCutscene_Stop(play->playerActorCsIds[0]); } } -f32 func_80998334(EnGs* this, GlobalContext* globalCtx, f32* arg2, f32* arg3, s16* arg4, f32 arg5, f32 arg6, f32 arg7, - s32 arg8, s32 arg9) { +f32 func_80998334(EnGs* this, PlayState* play, f32* arg2, f32* arg3, s16* arg4, f32 arg5, f32 arg6, f32 arg7, s32 arg8, + s32 arg9) { f32 sp2C = Math_SmoothStepToF(arg2, *arg3, arg5, arg6, arg7); 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; } -void func_809984F4(EnGs* this, GlobalContext* globalCtx) { +void func_809984F4(EnGs* this, PlayState* play) { EnGs* gossipStone = NULL; do { - gossipStone = (EnGs*)SubS_FindActor(globalCtx, &gossipStone->actor, ACTORCAT_PROP, ACTOR_EN_GS); + gossipStone = (EnGs*)SubS_FindActor(play, &gossipStone->actor, ACTORCAT_PROP, ACTOR_EN_GS); if (gossipStone != NULL) { if ((this != gossipStone) && (this->unk_194 == gossipStone->unk_194)) { gossipStone->unk_19A |= 1; func_80999AC0(gossipStone); gossipStone->unk_19C = 3; - func_80998704(gossipStone, globalCtx); + func_80998704(gossipStone, play); } gossipStone = (EnGs*)gossipStone->actor.next; } } while (gossipStone != NULL); - func_800B7298(globalCtx, &this->actor, 7); + func_800B7298(play, &this->actor, 7); this->actionFunc = func_809985B8; } -void func_809985B8(EnGs* this, GlobalContext* globalCtx) { +void func_809985B8(EnGs* this, PlayState* play) { EnGs* gossipStone; Vec3f sp38; if (SubS_StartActorCutscene(&this->actor, this->unk_212[0], -1, SUBS_CUTSCENE_SET_UNK_LINK_FIELDS)) { - Player* player = GET_PLAYER(globalCtx); + Player* player = GET_PLAYER(play); - 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; @@ -393,7 +393,7 @@ void func_809985B8(EnGs* this, GlobalContext* globalCtx) { gossipStone = NULL; do { - gossipStone = (EnGs*)SubS_FindActor(globalCtx, &gossipStone->actor, ACTORCAT_PROP, ACTOR_EN_GS); + gossipStone = (EnGs*)SubS_FindActor(play, &gossipStone->actor, ACTORCAT_PROP, ACTOR_EN_GS); if (gossipStone != NULL) { if ((gossipStone != this) && (gossipStone->actor.params == ENGS_2) && (gossipStone->unk_198 == this->unk_198)) { @@ -404,40 +404,40 @@ void func_809985B8(EnGs* this, GlobalContext* globalCtx) { } } while (gossipStone != NULL); - func_80998704(this, globalCtx); + func_80998704(this, play); } } -void func_80998704(EnGs* this, GlobalContext* globalCtx) { +void func_80998704(EnGs* this, PlayState* play) { this->unk_19D = 0; this->unk_19A &= ~(0x100 | 0x4); Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_G_STONE_CHANGE_COLOR); this->actionFunc = func_8099874C; } -void func_8099874C(EnGs* this, GlobalContext* globalCtx) { +void func_8099874C(EnGs* this, PlayState* play) { s32 phi_v0 = 0; switch (this->unk_19C) { case 0: - phi_v0 = func_80998A48(this, globalCtx); + phi_v0 = func_80998A48(this, play); break; case 1: - phi_v0 = func_80998BBC(this, globalCtx); + phi_v0 = func_80998BBC(this, play); break; case 2: - phi_v0 = func_80998D44(this, globalCtx); + phi_v0 = func_80998D44(this, play); break; case 3: case 5: - phi_v0 = func_80998F9C(this, globalCtx); + phi_v0 = func_80998F9C(this, play); break; case 4: - phi_v0 = func_809995A4(this, globalCtx); + phi_v0 = func_809995A4(this, play); break; } @@ -486,34 +486,34 @@ void func_8099874C(EnGs* this, GlobalContext* globalCtx) { } if (this->unk_20C > 0) { - func_809989B4(this, globalCtx); + func_809989B4(this, play); } else { - func_80997D14(this, globalCtx); + func_80997D14(this, play); } } else { - func_80997D14(this, globalCtx); + func_80997D14(this, play); } } else { - func_80997D14(this, globalCtx); + func_80997D14(this, play); } } } -void func_809989B4(EnGs* this, GlobalContext* globalCtx) { - Actor_PickUp(&this->actor, globalCtx, this->unk_20C, this->actor.xzDistToPlayer, this->actor.playerHeightRel); +void func_809989B4(EnGs* this, PlayState* play) { + Actor_PickUp(&this->actor, play, this->unk_20C, this->actor.xzDistToPlayer, this->actor.playerHeightRel); this->actionFunc = func_809989F4; } -void func_809989F4(EnGs* this, GlobalContext* globalCtx) { - if (Actor_HasParent(&this->actor, globalCtx)) { +void func_809989F4(EnGs* this, PlayState* play) { + if (Actor_HasParent(&this->actor, play)) { this->actor.parent = NULL; - func_80997D14(this, globalCtx); + func_80997D14(this, play); } else { - Actor_PickUp(&this->actor, globalCtx, this->unk_20C, this->actor.xzDistToPlayer, this->actor.playerHeightRel); + Actor_PickUp(&this->actor, play, this->unk_20C, this->actor.xzDistToPlayer, this->actor.playerHeightRel); } } -s32 func_80998A48(EnGs* this, GlobalContext* globalCtx) { +s32 func_80998A48(EnGs* this, PlayState* play) { s32 sp3C = -1; if (this->unk_19D == 0) { @@ -531,13 +531,13 @@ s32 func_80998A48(EnGs* this, GlobalContext* globalCtx) { this->unk_1DC = 0.5f; this->unk_1E0 = 0.0f; } 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) && !Play_InCsMode(globalCtx) && - (Message_GetState(&globalCtx->msgCtx) == 0)) { + if (func_80998334(this, play, &this->unk_1DC, &this->unk_1E0, &this->unk_1D4, 0.8f, 0.007f, 0.001f, 7, 0) == + 0.0f) { + if ((this->actor.params != ENGS_0) && !Play_InCsMode(play) && + (Message_GetState(&play->msgCtx) == TEXT_STATE_NONE)) { this->unk_216 = 0; Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_FAIVE_LUPY_COUNT); - Message_StartTextbox(globalCtx, 0x20D2, NULL); + Message_StartTextbox(play, 0x20D2, NULL); } this->unk_19A &= ~1; sp3C = 0; @@ -546,7 +546,7 @@ s32 func_80998A48(EnGs* this, GlobalContext* globalCtx) { return sp3C; } -s32 func_80998BBC(EnGs* this, GlobalContext* globalCtx) { +s32 func_80998BBC(EnGs* this, PlayState* play) { s32 sp34 = -1; if (this->unk_19D == 0) { @@ -565,8 +565,8 @@ s32 func_80998BBC(EnGs* this, GlobalContext* globalCtx) { } else if (this->unk_19D == 1) { this->unk_19E[0].z = (this->unk_1D4 % 8) * 0.125f * 360.0f * (0x10000 / 360.0f); this->unk_19E[1].z = -this->unk_19E[0].z; - if (func_80998334(this, globalCtx, &this->unk_1DC, &this->unk_1E0, &this->unk_1D4, 0.8f, 0.005f, 0.001f, 7, - 0) == 0.0f) { + if (func_80998334(this, play, &this->unk_1DC, &this->unk_1E0, &this->unk_1D4, 0.8f, 0.005f, 0.001f, 7, 0) == + 0.0f) { this->unk_19A &= ~1; sp34 = 0; } @@ -574,7 +574,7 @@ s32 func_80998BBC(EnGs* this, GlobalContext* globalCtx) { return sp34; } -s32 func_80998D44(EnGs* this, GlobalContext* globalCtx) { +s32 func_80998D44(EnGs* this, PlayState* play) { s32 sp3C = -1; f32 step; @@ -616,15 +616,15 @@ s32 func_80998D44(EnGs* this, GlobalContext* globalCtx) { Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_STALKID_ATTACK); this->unk_19D += 1; } - } else if ((this->unk_19D == 4) && (func_80998334(this, globalCtx, &this->unk_1DC, &this->unk_1E0, &this->unk_1D4, - 1.0f, 0.03f, 0.001f, 5, 0) == 0.0f)) { + } else if ((this->unk_19D == 4) && (func_80998334(this, play, &this->unk_1DC, &this->unk_1E0, &this->unk_1D4, 1.0f, + 0.03f, 0.001f, 5, 0) == 0.0f)) { this->unk_19A &= ~1; sp3C = 0; } return sp3C; } -s32 func_80998F9C(EnGs* this, GlobalContext* globalCtx) { +s32 func_80998F9C(EnGs* this, PlayState* play) { s32 sp4C = -1; f32 sp48; f32 sp44; @@ -657,7 +657,7 @@ s32 func_80998F9C(EnGs* this, GlobalContext* globalCtx) { if (this->unk_19D == 2) { this->unk_19E[0].y += (s32)(this->unk_1DC * (0x10000 / 360.0f)); - if ((this->unk_1D4++ <= 40) ^ 1) { + if (this->unk_1D4++ > 40) { this->unk_1DC = this->unk_1B0[0].y - 1.0f; this->unk_1E0 = 1.5f; this->unk_1E4 = this->unk_1B0[1].y - 1.0f; @@ -725,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; @@ -747,7 +747,7 @@ void func_80999584(Color_RGB8* arg0, Color_RGB8* arg1) { arg0->b = arg1->b; } -s32 func_809995A4(EnGs* this, GlobalContext* globalCtx) { +s32 func_809995A4(EnGs* this, PlayState* play) { static Color_RGB8 flashColours[] = { { 255, 50, 50 }, { 50, 50, 255 }, @@ -820,13 +820,12 @@ s32 func_809995A4(EnGs* this, GlobalContext* globalCtx) { sp6C.y = this->actor.world.pos.y + 7.0f; sp6C.z = this->actor.world.pos.z + (2.0f * sp60.z); - func_800B0EB0(globalCtx, &sp6C, &sp60, &dustAccel, &dustPrim, &dustEnv, Rand_ZeroFloat(50.0f) + 200.0f, 40, - 15); + func_800B0EB0(play, &sp6C, &sp60, &dustAccel, &dustPrim, &dustEnv, Rand_ZeroFloat(50.0f) + 200.0f, 40, 15); } func_800B9010(&this->actor, NA_SE_EV_FIRE_PILLAR - SFX_FLAG); - if ((this->unk_1D4++ < 40) ^ 1) { + if (this->unk_1D4++ >= 40) { this->unk_19A |= 0x10; this->actor.uncullZoneForward = 12000.0f; @@ -843,7 +842,7 @@ s32 func_809995A4(EnGs* this, GlobalContext* globalCtx) { } if (this->unk_19D == 4) { - Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 20.0f, 20.0f, 60.0f, 3); + Actor_UpdateBgCheckInfo(play, &this->actor, 20.0f, 20.0f, 60.0f, 3); if (this->actor.bgCheckFlags & (0x10 | 0x8)) { Vec3f sp54; @@ -851,7 +850,7 @@ s32 func_809995A4(EnGs* this, GlobalContext* globalCtx) { sp54.y = this->actor.world.pos.y; sp54.z = this->actor.world.pos.z; Actor_PlaySfxAtPos(&this->actor, NA_SE_IT_BOMB_EXPLOSION); - EffectSsBomb2_SpawnLayered(globalCtx, &sp54, &bomb2Velocity, &bomb2Accel, 100, 20); + EffectSsBomb2_SpawnLayered(play, &sp54, &bomb2Velocity, &bomb2Accel, 100, 20); this->unk_1D4 = 10; this->unk_19A |= 8; this->unk_216 = 0; @@ -870,7 +869,7 @@ s32 func_809995A4(EnGs* this, GlobalContext* globalCtx) { } if (this->actor.playerHeightRel < -12000.0f) { - Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_BOM, this->actor.world.pos.x, this->actor.world.pos.y, + Actor_Spawn(&play->actorCtx, play, ACTOR_EN_BOM, this->actor.world.pos.x, this->actor.world.pos.y, this->actor.world.pos.z, 0, this->actor.world.rot.y, 0, 0); Actor_MarkForDeath(&this->actor); sp7C = 0; @@ -880,7 +879,7 @@ s32 func_809995A4(EnGs* this, GlobalContext* globalCtx) { return sp7C; } -void func_80999A8C(EnGs* this, GlobalContext* globalCtx) { +void func_80999A8C(EnGs* this, PlayState* play) { if (this->unk_1D4-- <= 0) { Actor_MarkForDeath(&this->actor); } @@ -917,8 +916,8 @@ void func_80999B34(EnGs* this) { } } -void func_80999BC8(Actor* thisx, GlobalContext* globalCtx2) { - GlobalContext* globalCtx = globalCtx2; +void func_80999BC8(Actor* thisx, PlayState* play2) { + PlayState* play = play2; EnGs* this = THIS; s32 pad; @@ -927,7 +926,7 @@ void func_80999BC8(Actor* thisx, GlobalContext* globalCtx2) { this->unk_19A |= 1; func_80999AC0(this); this->unk_19C = 0; - func_80998704(this, globalCtx); + func_80998704(this, play); this->unk_208 = 0; } @@ -954,7 +953,7 @@ void func_80999BC8(Actor* thisx, GlobalContext* globalCtx2) { this->unk_19A |= 1; func_80999AC0(this); this->unk_19C = 0; - func_80998704(this, globalCtx); + func_80998704(this, play); this->unk_21A = 5; break; @@ -962,14 +961,14 @@ void func_80999BC8(Actor* thisx, GlobalContext* globalCtx2) { this->unk_19A |= 1; func_80999AC0(this); this->unk_19C = 1; - func_80998704(this, globalCtx); + func_80998704(this, play); this->unk_21A = 5; break; case 13: func_80999AC0(this); this->unk_19C = 2; - func_80998704(this, globalCtx); + func_80998704(this, play); this->unk_21A = 5; break; @@ -977,7 +976,7 @@ void func_80999BC8(Actor* thisx, GlobalContext* globalCtx2) { this->unk_19A |= 2; func_80999AC0(this); this->unk_19C = 4; - func_80998704(this, globalCtx); + func_80998704(this, play); this->unk_21A = 5; break; @@ -985,51 +984,51 @@ void func_80999BC8(Actor* thisx, GlobalContext* globalCtx2) { this->unk_19A |= 1; func_80999AC0(this); this->unk_19C = 3; - func_80998704(this, globalCtx); + func_80998704(this, play); this->unk_21A = 5; break; } } Collider_UpdateCylinder(&this->actor, &this->collider); - CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); - CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + CollisionCheck_SetAC(play, &play->colChkCtx, &this->collider.base); + CollisionCheck_SetOC(play, &play->colChkCtx, &this->collider.base); } else { this->collider.base.acFlags &= ~AC_HIT; } - this->actionFunc(this, globalCtx); + this->actionFunc(this, play); } -void EnGs_Update(Actor* thisx, GlobalContext* globalCtx) { +void EnGs_Update(Actor* thisx, PlayState* play) { s32 pad; EnGs* this = THIS; - if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { - globalCtx->msgCtx.msgMode = 0; - globalCtx->msgCtx.unk11F10 = 0; + if (Actor_ProcessTalkRequest(&this->actor, &play->state)) { + play->msgCtx.msgMode = 0; + play->msgCtx.msgLength = 0; this->collider.base.acFlags &= ~AC_HIT; - func_80997DEC(this, globalCtx); - } else if (func_800B8718(&this->actor, &globalCtx->state)) { + func_80997DEC(this, play); + } else if (func_800B8718(&this->actor, &play->state)) { this->unk_19A |= 0x200; this->collider.base.acFlags &= ~AC_HIT; if (this->actor.cutscene != -1) { this->actionFunc = func_80997FF0; } else { - func_80998040(this, globalCtx); + func_80998040(this, play); } } else { s16 sp2E; s16 sp2C; 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); + func_80999BC8(&this->actor, play); + Actor_GetScreenPos(play, &this->actor, &sp2E, &sp2C); 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); + func_800BC848(&this->actor, play, this->unk_21C, this->unk_21E); } } else { this->unk_216 = 0; @@ -1056,7 +1055,7 @@ void EnGs_Update(Actor* thisx, GlobalContext* globalCtx) { } } -void EnGs_Draw(Actor* thisx, GlobalContext* globalCtx) { +void EnGs_Draw(Actor* thisx, PlayState* play) { s32 pad; EnGs* this = THIS; u32 frames; @@ -1065,43 +1064,43 @@ void EnGs_Draw(Actor* thisx, GlobalContext* globalCtx) { return; } - OPEN_DISPS(globalCtx->state.gfxCtx); + OPEN_DISPS(play->state.gfxCtx); - frames = globalCtx->gameplayFrames; + frames = play->gameplayFrames; - func_8012C28C(globalCtx->state.gfxCtx); - Matrix_StatePush(); + func_8012C28C(play->state.gfxCtx); + 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); + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_OPA_DISP++, object_gs_DL_000950); gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, this->unk_1FA.r, this->unk_1FA.g, this->unk_1FA.b, 255); 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); + func_8012C2DC(play->state.gfxCtx); + Matrix_ReplaceRotation(&play->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); + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPSegment(POLY_XLU_DISP++, 0x08, - Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, 0, 0, 0x20, 0x40, 1, 0, -frames * 20, 0x20, 0x80)); + Gfx_TwoTexScroll(play->state.gfxCtx, 0, 0, 0, 0x20, 0x40, 1, 0, -frames * 20, 0x20, 0x80)); gDPSetPrimColor(POLY_XLU_DISP++, 0x80, 0x80, 255, 255, 0, 255); gDPSetEnvColor(POLY_XLU_DISP++, 255, 0, 0, 0); - gSPDisplayList(POLY_XLU_DISP++, gGameplayKeepDrawFlameDL); + gSPDisplayList(POLY_XLU_DISP++, gEffFire1DL); } - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->state.gfxCtx); } 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 c76a0c346..eed8d75f9 100644 --- a/src/overlays/actors/ovl_En_Gs/z_en_gs.h +++ b/src/overlays/actors/ovl_En_Gs/z_en_gs.h @@ -5,7 +5,7 @@ struct EnGs; -typedef void (*EnGsActionFunc)(struct EnGs*, GlobalContext*); +typedef void (*EnGsActionFunc)(struct EnGs*, PlayState*); #define ENGS_GET_1F(thisx) ((thisx)->params & 0x1F) #define ENGS_GET_FE0(thisx) (((thisx)->params >> 5) & 0x7F) 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 2434ca2cf..a08d0835f 100644 --- a/src/overlays/actors/ovl_En_Guard_Nuts/z_en_guard_nuts.c +++ b/src/overlays/actors/ovl_En_Guard_Nuts/z_en_guard_nuts.c @@ -5,24 +5,25 @@ */ #include "z_en_guard_nuts.h" +#include "overlays/effects/ovl_Effect_Ss_Hahen/z_eff_ss_hahen.h" #define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_8 | ACTOR_FLAG_100000 | ACTOR_FLAG_80000000) #define THIS ((EnGuardNuts*)thisx) -void EnGuardNuts_Init(Actor* thisx, GlobalContext* globalCtx); -void EnGuardNuts_Destroy(Actor* thisx, GlobalContext* globalCtx); -void EnGuardNuts_Update(Actor* thisx, GlobalContext* globalCtx); -void EnGuardNuts_Draw(Actor* thisx, GlobalContext* globalCtx); +void EnGuardNuts_Init(Actor* thisx, PlayState* play); +void EnGuardNuts_Destroy(Actor* thisx, PlayState* play); +void EnGuardNuts_Update(Actor* thisx, PlayState* play); +void EnGuardNuts_Draw(Actor* thisx, PlayState* play); -void EnGuardNuts_ChangeAnim(EnGuardNuts* this, s32 index); +void EnGuardNuts_ChangeAnim(EnGuardNuts* this, s32 animIndex); void EnGuardNuts_SetupWait(EnGuardNuts* this); -void EnGuardNuts_Wait(EnGuardNuts* this, GlobalContext* globalCtx); +void EnGuardNuts_Wait(EnGuardNuts* this, PlayState* play); 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); +void func_80ABB590(EnGuardNuts* this, PlayState* play); +void EnGuardNuts_Burrow(EnGuardNuts* this, PlayState* play); +void EnGuardNuts_SetupUnburrow(EnGuardNuts* this, PlayState* play); +void EnGuardNuts_Unburrow(EnGuardNuts* this, PlayState* play); const ActorInit En_Guard_Nuts_InitVars = { ACTOR_EN_GUARD_NUTS, @@ -71,7 +72,7 @@ static AnimationHeader* sAnimations[] = { &gDekuPalaceGuardWalkAnim, }; -static u8 sAnimModes[] = { ANIMMODE_LOOP, ANIMMODE_LOOP, ANIMMODE_ONCE, ANIMMODE_ONCE }; +static u8 sAnimationModes[] = { ANIMMODE_LOOP, ANIMMODE_LOOP, ANIMMODE_ONCE, ANIMMODE_ONCE }; static TexturePtr sEyeTextures[] = { gDekuPalaceGuardEyeOpenTex, @@ -93,15 +94,15 @@ typedef enum { /* 4 */ GUARD_NUTS_UNK_STATE } EnGuardNutsState; -void EnGuardNuts_Init(Actor* thisx, GlobalContext* globalCtx) { +void EnGuardNuts_Init(Actor* thisx, PlayState* play) { EnGuardNuts* this = THIS; ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 20.0f); - SkelAnime_Init(globalCtx, &this->skelAnime, &gDekuPalaceGuardSkel, &gDekuPalaceGuardWaitAnim, this->jointTable, - this->morphTable, OBJECT_DNK_LIMB_MAX); + SkelAnime_Init(play, &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); + Collider_InitAndSetCylinder(play, &this->collider, &this->actor, &sCylinderInit); Actor_SetScale(&this->actor, 0.015f); Math_Vec3f_Copy(&this->guardPos, &this->actor.world.pos); this->guardNumber = sGuardCount; @@ -111,27 +112,27 @@ void EnGuardNuts_Init(Actor* thisx, GlobalContext* globalCtx) { if (!(gSaveContext.save.weekEventReg[23] & 0x20)) { EnGuardNuts_SetupWait(this); } else { - EnGuardNuts_Burrow(this, globalCtx); + EnGuardNuts_Burrow(this, play); } } -void EnGuardNuts_Destroy(Actor* thisx, GlobalContext* globalCtx) { +void EnGuardNuts_Destroy(Actor* thisx, PlayState* play) { EnGuardNuts* this = THIS; - Collider_DestroyCylinder(globalCtx, &this->collider); + Collider_DestroyCylinder(play, &this->collider); } /** * @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 + * @param animIndex the index of sAnimations to change to */ -void EnGuardNuts_ChangeAnim(EnGuardNuts* this, s32 index) { - this->animIndex = index; +void EnGuardNuts_ChangeAnim(EnGuardNuts* this, s32 animIndex) { + this->animIndex = animIndex; 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); + sAnimationModes[this->animIndex], -2.0f); } void EnGuardNuts_SetupWait(EnGuardNuts* this) { @@ -140,14 +141,14 @@ void EnGuardNuts_SetupWait(EnGuardNuts* this) { this->actionFunc = EnGuardNuts_Wait; } -void EnGuardNuts_Wait(EnGuardNuts* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); +void EnGuardNuts_Wait(EnGuardNuts* this, PlayState* play) { + Player* player = GET_PLAYER(play); 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)) { + if (Actor_ProcessTalkRequest(&this->actor, &play->state)) { func_80ABB540(this); return; } @@ -171,7 +172,7 @@ void EnGuardNuts_Wait(EnGuardNuts* this, GlobalContext* globalCtx) { this->actor.textId = sTextIDs[this->guardTextIndex]; phi_a1 = this->actor.world.rot.y; if (D_80ABBE20 == 2) { - EnGuardNuts_Burrow(this, globalCtx); + EnGuardNuts_Burrow(this, play); return; } if (D_80ABBE20 == 1) { @@ -194,7 +195,7 @@ void EnGuardNuts_Wait(EnGuardNuts* this, GlobalContext* globalCtx) { this->targetHeadPos.y = -this->targetHeadPos.y; } } - func_800B8614(&this->actor, globalCtx, 70.0f); + func_800B8614(&this->actor, play, 70.0f); } void func_80ABB540(EnGuardNuts* this) { @@ -205,7 +206,7 @@ void func_80ABB540(EnGuardNuts* this) { this->actionFunc = func_80ABB590; } -void func_80ABB590(EnGuardNuts* this, GlobalContext* globalCtx) { +void func_80ABB590(EnGuardNuts* this, PlayState* play) { s16 yaw = this->actor.yawTowardsPlayer; f32 curFrame; @@ -222,22 +223,22 @@ void func_80ABB590(EnGuardNuts* this, GlobalContext* globalCtx) { SkelAnime_Update(&this->skelAnime); Math_SmoothStepToS(&this->actor.shape.rot.y, yaw, 1, 0xBB8, 0); } - if (Message_GetState(&globalCtx->msgCtx) == 5) { + if (Message_GetState(&play->msgCtx) == TEXT_STATE_5) { this->targetHeadPos.y = 0; this->targetHeadPos.x = 0; if ((this->guardTextIndex == 3) && (this->animIndex == WAIT_HEAD_TILT_ANIM)) { EnGuardNuts_ChangeAnim(this, WAIT_HEAD_TILT_ANIM); } - if (Message_ShouldAdvance(globalCtx) != 0) { + if (Message_ShouldAdvance(play)) { if (D_80ABBE38[this->guardTextIndex] != 1) { if (D_80ABBE38[this->guardTextIndex] == 2) { - func_801477B4(globalCtx); + func_801477B4(play); D_80ABBE20 = 2; gSaveContext.save.weekEventReg[12] |= 0x40; - EnGuardNuts_Burrow(this, globalCtx); + EnGuardNuts_Burrow(this, play); } else { this->guardTextIndex++; - Message_StartTextbox(globalCtx, sTextIDs[this->guardTextIndex], &this->actor); + Message_StartTextbox(play, sTextIDs[this->guardTextIndex], &this->actor); if (D_80ABBE38[this->guardTextIndex] == 2) { D_80ABBE20 = 1; } @@ -246,15 +247,15 @@ void func_80ABB590(EnGuardNuts* this, GlobalContext* globalCtx) { } else if (this->guardTextIndex != 3) { this->targetHeadPos.x = 0; this->targetHeadPos.y = this->targetHeadPos.x; - func_801477B4(globalCtx); + func_801477B4(play); this->state = GUARD_NUTS_UNK_STATE; this->actionFunc = EnGuardNuts_Unburrow; } else { - func_801477B4(globalCtx); + func_801477B4(play); EnGuardNuts_SetupWait(this); } } - } else if ((Message_GetState(&globalCtx->msgCtx) >= 3) && (D_80ABBE20 == 0)) { + } else if ((Message_GetState(&play->msgCtx) >= TEXT_STATE_3) && (D_80ABBE20 == 0)) { if ((this->guardTextIndex == 0) || (this->guardTextIndex == 3) || (this->guardTextIndex >= 7)) { if (this->timer == 0) { this->timer = 2; @@ -267,13 +268,13 @@ void func_80ABB590(EnGuardNuts* this, GlobalContext* globalCtx) { } } -void EnGuardNuts_Burrow(EnGuardNuts* this, GlobalContext* globalCtx) { +void EnGuardNuts_Burrow(EnGuardNuts* this, PlayState* play) { 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); + EffectSsHahen_SpawnBurst(play, &digPos, 4.0f, 0, 10, 3, 15, HAHEN_OBJECT_DEFAULT, 10, NULL); this->targetHeadPos.y = 0; this->actor.flags |= ACTOR_FLAG_8000000; this->targetHeadPos.x = this->targetHeadPos.y; @@ -282,7 +283,7 @@ void EnGuardNuts_Burrow(EnGuardNuts* this, GlobalContext* globalCtx) { this->actionFunc = EnGuardNuts_SetupUnburrow; } -void EnGuardNuts_SetupUnburrow(EnGuardNuts* this, GlobalContext* globalCtx) { +void EnGuardNuts_SetupUnburrow(EnGuardNuts* this, PlayState* play) { f32 curFrame = this->skelAnime.curFrame; SkelAnime_Update(&this->skelAnime); @@ -294,7 +295,7 @@ void EnGuardNuts_SetupUnburrow(EnGuardNuts* this, GlobalContext* globalCtx) { } } -void EnGuardNuts_Unburrow(EnGuardNuts* this, GlobalContext* globalCtx) { +void EnGuardNuts_Unburrow(EnGuardNuts* this, PlayState* play) { s16 yawDiff; Vec3f digPos; @@ -304,7 +305,7 @@ void EnGuardNuts_Unburrow(EnGuardNuts* this, GlobalContext* globalCtx) { 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); + EffectSsHahen_SpawnBurst(play, &digPos, 4.0f, 0, 10, 3, 15, HAHEN_OBJECT_DEFAULT, 10, NULL); Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_NUTS_UP); D_80ABBE20 = 0; if (this->guardTextIndex == 9) { @@ -316,7 +317,7 @@ void EnGuardNuts_Unburrow(EnGuardNuts* this, GlobalContext* globalCtx) { } } -void EnGuardNuts_Update(Actor* thisx, GlobalContext* globalCtx) { +void EnGuardNuts_Update(Actor* thisx, PlayState* play) { EnGuardNuts* this = THIS; s32 pad; @@ -331,7 +332,7 @@ void EnGuardNuts_Update(Actor* thisx, GlobalContext* globalCtx) { Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_NUTS_WALK); } - this->actionFunc(this, globalCtx); + this->actionFunc(this, play); 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); @@ -344,18 +345,17 @@ void EnGuardNuts_Update(Actor* thisx, GlobalContext* globalCtx) { } Actor_MoveWithGravity(&this->actor); - Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 20.0f, 20.0f, 60.0f, 0x1D); + Actor_UpdateBgCheckInfo(play, &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); + CollisionCheck_SetOC(play, &play->colChkCtx, &this->collider.base); } } -s32 EnGuardNuts_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, - Actor* thisx) { +s32 EnGuardNuts_OverrideLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, Actor* thisx) { EnGuardNuts* this = THIS; - if (limbIndex == OBJECT_DNK_LIMB_HEAD) { + if (limbIndex == DEKU_PALACE_GUARD_LIMB_HEAD) { rot->x += this->headRot.x; rot->y += this->headRot.y; rot->z += this->headRot.z; @@ -363,23 +363,23 @@ s32 EnGuardNuts_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** return false; } -void EnGuardNuts_Draw(Actor* thisx, GlobalContext* globalCtx) { +void EnGuardNuts_Draw(Actor* thisx, PlayState* play) { EnGuardNuts* this = THIS; - OPEN_DISPS(globalCtx->state.gfxCtx); + OPEN_DISPS(play->state.gfxCtx); - func_8012C28C(globalCtx->state.gfxCtx); + func_8012C28C(play->state.gfxCtx); gSPSegment(POLY_OPA_DISP++, 0x08, Lib_SegmentedToVirtual(sEyeTextures[this->eyeState])); - SkelAnime_DrawOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, EnGuardNuts_OverrideLimbDraw, - NULL, &this->actor); - Matrix_InsertTranslation(this->guardPos.x, this->actor.floorHeight, this->guardPos.z, MTXMODE_NEW); + SkelAnime_DrawOpa(play, 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); + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_OPA_DISP++, gDekuPalaceGuardFlower); - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->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 59f885563..6f45691ad 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 @@ -6,13 +6,13 @@ struct EnGuardNuts; -typedef void (*EnGuardNutsActionFunc)(struct EnGuardNuts*, GlobalContext*); +typedef void (*EnGuardNutsActionFunc)(struct EnGuardNuts*, PlayState*); typedef struct EnGuardNuts { /* 0x000 */ Actor actor; /* 0x144 */ SkelAnime skelAnime; - /* 0x188 */ Vec3s jointTable[OBJECT_DNK_LIMB_MAX]; - /* 0x1CA */ Vec3s morphTable[OBJECT_DNK_LIMB_MAX]; + /* 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; 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 8844062b8..a57effdcc 100644 --- a/src/overlays/actors/ovl_En_Guruguru/z_en_guruguru.c +++ b/src/overlays/actors/ovl_En_Guruguru/z_en_guruguru.c @@ -11,19 +11,19 @@ #define THIS ((EnGuruguru*)thisx) -void EnGuruguru_Init(Actor* thisx, GlobalContext* globalCtx); -void EnGuruguru_Destroy(Actor* thisx, GlobalContext* globalCtx); -void EnGuruguru_Update(Actor* thisx, GlobalContext* globalCtx); -void EnGuruguru_Draw(Actor* thisx, GlobalContext* globalCtx); +void EnGuruguru_Init(Actor* thisx, PlayState* play); +void EnGuruguru_Destroy(Actor* thisx, PlayState* play); +void EnGuruguru_Update(Actor* thisx, PlayState* play); +void EnGuruguru_Draw(Actor* thisx, PlayState* play); -void EnGuruguru_DoNothing(EnGuruguru* this, GlobalContext* globalCtx); +void EnGuruguru_DoNothing(EnGuruguru* this, PlayState* play); void func_80BC6E10(EnGuruguru* this); -void func_80BC6F14(EnGuruguru* this, GlobalContext* globalCtx); -void func_80BC701C(EnGuruguru* this, GlobalContext* globalCtx); -void func_80BC7068(EnGuruguru* this, GlobalContext* globalCtx); +void func_80BC6F14(EnGuruguru* this, PlayState* play); +void func_80BC701C(EnGuruguru* this, PlayState* play); +void func_80BC7068(EnGuruguru* this, PlayState* play); void func_80BC73F4(EnGuruguru* this); -void func_80BC7440(EnGuruguru* this, GlobalContext* globalCtx); -void func_80BC7520(EnGuruguru* this, GlobalContext* globalCtx); +void func_80BC7440(EnGuruguru* this, PlayState* play); +void func_80BC7520(EnGuruguru* this, PlayState* play); extern ColliderCylinderInit D_80BC79A0; @@ -62,22 +62,22 @@ static ColliderCylinderInit sCylinderInit = { { 15, 20, 0, { 0, 0, 0 } }, }; -static AnimationHeader* D_80BC79CC[] = { &object_fu_Anim_000B04, &object_fu_Anim_00057C }; -static u8 D_80BC79D4[] = { 0 }; -static f32 D_80BC79D8[] = { 1.0f, 1.0f }; +static AnimationHeader* sAnimations[] = { &object_fu_Anim_000B04, &object_fu_Anim_00057C }; +static u8 sAnimationModes[] = { ANIMMODE_LOOP, ANIMMODE_LOOP }; +static f32 sPlaySpeeds[] = { 1.0f, 1.0f }; static TexturePtr sEyeTextures[] = { object_fu_Tex_005F20, object_fu_Tex_006320 }; static TexturePtr sMouthTextures[] = { object_fu_Tex_006720, object_fu_Tex_006920 }; -void EnGuruguru_Init(Actor* thisx, GlobalContext* globalCtx) { +void EnGuruguru_Init(Actor* thisx, PlayState* play) { EnGuruguru* this = THIS; this->actor.colChkInfo.mass = MASS_IMMOVABLE; ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 19.0f); - SkelAnime_InitFlex(globalCtx, &this->skelAnime, &object_fu_Skel_006C90, &object_fu_Anim_000B04, this->jointTable, + SkelAnime_InitFlex(play, &this->skelAnime, &object_fu_Skel_006C90, &object_fu_Anim_000B04, this->jointTable, this->morphTable, 16); this->actor.targetMode = 0; if (this->actor.params != 2) { - Collider_InitAndSetCylinder(globalCtx, &this->collider, &this->actor, &sCylinderInit); + Collider_InitAndSetCylinder(play, &this->collider, &this->actor, &sCylinderInit); } if (!gSaveContext.save.isNight) { if (this->actor.params == 0) { @@ -97,25 +97,25 @@ void EnGuruguru_Init(Actor* thisx, GlobalContext* globalCtx) { } } -void EnGuruguru_Destroy(Actor* thisx, GlobalContext* globalCtx) { +void EnGuruguru_Destroy(Actor* thisx, PlayState* play) { EnGuruguru* this = THIS; if (this->actor.params != 2) { - Collider_DestroyCylinder(globalCtx, &this->collider); + Collider_DestroyCylinder(play, &this->collider); } } -void EnGuruguru_ChangeAnimation(EnGuruguru* this, s32 arg1) { - this->frameCount = Animation_GetLastFrame(D_80BC79CC[arg1]); - Animation_Change(&this->skelAnime, D_80BC79CC[arg1], D_80BC79D8[arg1], 0.0f, this->frameCount, D_80BC79D4[arg1], - -4.0f); +void EnGuruguru_ChangeAnim(EnGuruguru* this, s32 animIndex) { + this->frameCount = Animation_GetLastFrame(sAnimations[animIndex]); + Animation_Change(&this->skelAnime, sAnimations[animIndex], sPlaySpeeds[animIndex], 0.0f, this->frameCount, + sAnimationModes[animIndex], -4.0f); } -void EnGuruguru_DoNothing(EnGuruguru* this, GlobalContext* globalCtx) { +void EnGuruguru_DoNothing(EnGuruguru* this, PlayState* play) { } void func_80BC6E10(EnGuruguru* this) { - EnGuruguru_ChangeAnimation(this, 0); + EnGuruguru_ChangeAnim(this, 0); this->textIdIndex = 0; this->unk270 = 0; if (this->actor.params == 0) { @@ -142,13 +142,13 @@ void func_80BC6E10(EnGuruguru* this) { this->actionFunc = func_80BC6F14; } -void func_80BC6F14(EnGuruguru* this, GlobalContext* globalCtx) { +void func_80BC6F14(EnGuruguru* this, PlayState* play) { s16 yaw; s16 yawTemp; SkelAnime_Update(&this->skelAnime); if (this->unk270 != 0) { - Player* player = GET_PLAYER(globalCtx); + Player* player = GET_PLAYER(play); this->textIdIndex = 3; if (player->transformation == PLAYER_FORM_DEKU) { @@ -164,15 +164,15 @@ void func_80BC6F14(EnGuruguru* this, GlobalContext* globalCtx) { yawTemp = this->actor.yawTowardsPlayer - this->actor.world.rot.y; yaw = ABS_ALT(yawTemp); - if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { - func_80BC701C(this, globalCtx); + if (Actor_ProcessTalkRequest(&this->actor, &play->state)) { + func_80BC701C(this, play); } else if (yaw <= 0x2890) { - func_800B8614(&this->actor, globalCtx, 60.0f); + func_800B8614(&this->actor, play, 60.0f); } } -void func_80BC701C(EnGuruguru* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); +void func_80BC701C(EnGuruguru* this, PlayState* play) { + Player* player = GET_PLAYER(play); if ((this->unk268 != 0) && (player->transformation == PLAYER_FORM_HUMAN || player->transformation == PLAYER_FORM_DEKU)) { @@ -184,14 +184,14 @@ void func_80BC701C(EnGuruguru* this, GlobalContext* globalCtx) { this->actionFunc = func_80BC7068; } -void func_80BC7068(EnGuruguru* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); +void func_80BC7068(EnGuruguru* this, PlayState* play) { + Player* player = GET_PLAYER(play); if (this->unk268 != 0) { SkelAnime_Update(&this->skelAnime); } else if (this->unusedTimer == 0) { this->unusedTimer = 6; - if (Message_GetState(&globalCtx->msgCtx) != 5) { + if (Message_GetState(&play->msgCtx) != TEXT_STATE_5) { if (this->unk266 == 0) { if (this->headZRotTarget != 0) { this->headZRotTarget = 0; @@ -207,11 +207,11 @@ void func_80BC7068(EnGuruguru* this, GlobalContext* globalCtx) { } } } - if ((Message_GetState(&globalCtx->msgCtx) == 5) && (Message_ShouldAdvance(globalCtx))) { - func_801477B4(globalCtx); + if ((Message_GetState(&play->msgCtx) == TEXT_STATE_5) && Message_ShouldAdvance(play)) { + func_801477B4(play); this->headZRotTarget = 0; if ((this->textIdIndex == 13) || (this->textIdIndex == 14)) { - func_80151BB4(globalCtx, 0x13); + func_80151BB4(play, 0x13); gSaveContext.save.weekEventReg[79] |= 4; func_80BC6E10(this); return; @@ -223,7 +223,7 @@ void func_80BC7068(EnGuruguru* this, GlobalContext* globalCtx) { if (this->actor.textId == 0x292A) { gSaveContext.save.weekEventReg[38] |= 0x10; } - func_80151BB4(globalCtx, 0x13); + func_80151BB4(play, 0x13); func_80BC6E10(this); return; } @@ -234,8 +234,8 @@ void func_80BC7068(EnGuruguru* this, GlobalContext* globalCtx) { if (this->textIdIndex == 12) { gSaveContext.save.weekEventReg[38] |= 0x40; func_801A3B48(0); - func_80151BB4(globalCtx, 0x36); - func_80151BB4(globalCtx, 0x13); + func_80151BB4(play, 0x36); + func_80151BB4(play, 0x13); func_80BC6E10(this); return; } @@ -271,11 +271,11 @@ void func_80BC7068(EnGuruguru* this, GlobalContext* globalCtx) { this->skelAnime.playSpeed = 1.0f; } this->unk266 = 1; - func_80151938(globalCtx, textIDs[this->textIdIndex]); + func_80151938(play, textIDs[this->textIdIndex]); return; } func_801A3B48(0); - func_80151BB4(globalCtx, 0x13); + func_80151BB4(play, 0x13); func_80BC6E10(this); } } @@ -288,35 +288,35 @@ void func_80BC73F4(EnGuruguru* this) { this->actionFunc = func_80BC7440; } -void func_80BC7440(EnGuruguru* this, GlobalContext* globalCtx) { +void func_80BC7440(EnGuruguru* this, PlayState* play) { SkelAnime_Update(&this->skelAnime); - if (Actor_HasParent(&this->actor, globalCtx)) { + if (Actor_HasParent(&this->actor, play)) { this->actor.parent = NULL; this->textIdIndex++; this->actor.textId = textIDs[this->textIdIndex]; func_801A3B48(1); - func_800B8500(&this->actor, globalCtx, 400.0f, 400.0f, EXCH_ITEM_MINUS1); + func_800B8500(&this->actor, play, 400.0f, 400.0f, PLAYER_AP_MINUS1); this->unk268 = 0; gSaveContext.save.weekEventReg[38] |= 0x40; this->actionFunc = func_80BC7520; } else { - Actor_PickUp(&this->actor, globalCtx, GI_MASK_BREMEN, 300.0f, 300.0f); + Actor_PickUp(&this->actor, play, GI_MASK_BREMEN, 300.0f, 300.0f); } } -void func_80BC7520(EnGuruguru* this, GlobalContext* globalCtx) { +void func_80BC7520(EnGuruguru* this, PlayState* play) { SkelAnime_Update(&this->skelAnime); - if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { + if (Actor_ProcessTalkRequest(&this->actor, &play->state)) { this->actionFunc = func_80BC7068; } else { - func_800B8500(&this->actor, globalCtx, 400.0f, 400.0f, EXCH_ITEM_MINUS1); + func_800B8500(&this->actor, play, 400.0f, 400.0f, PLAYER_AP_MINUS1); } } -void EnGuruguru_Update(Actor* thisx, GlobalContext* globalCtx) { +void EnGuruguru_Update(Actor* thisx, PlayState* play) { EnGuruguru* this = THIS; s32 yaw; - Player* player = GET_PLAYER(globalCtx); + Player* player = GET_PLAYER(play); s16 yawTemp; if (!gSaveContext.save.isNight) { @@ -329,7 +329,7 @@ void EnGuruguru_Update(Actor* thisx, GlobalContext* globalCtx) { return; } - this->actionFunc(this, globalCtx); + this->actionFunc(this, play); if (this->actor.params == 2) { if (fabsf(player->actor.world.pos.y - this->actor.world.pos.y) < 100.0f) { @@ -363,13 +363,12 @@ void EnGuruguru_Update(Actor* thisx, GlobalContext* globalCtx) { Actor_MoveWithGravity(&this->actor); Math_SmoothStepToS(&this->headXRot, this->headXRotTarget, 1, 3000, 0); Math_SmoothStepToS(&this->headZRot, this->headZRotTarget, 1, 1000, 0); - Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 20.0f, 20.0f, 50.0f, 0x1D); + Actor_UpdateBgCheckInfo(play, &this->actor, 20.0f, 20.0f, 50.0f, 0x1D); Collider_UpdateCylinder(&this->actor, &this->collider); - CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + CollisionCheck_SetOC(play, &play->colChkCtx, &this->collider.base); } -s32 EnGuruguru_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, - Actor* thisx) { +s32 EnGuruguru_OverrideLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, Actor* thisx) { EnGuruguru* this = THIS; if (limbIndex == 14) { @@ -380,15 +379,15 @@ s32 EnGuruguru_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** d return false; } -void EnGuruguru_Draw(Actor* thisx, GlobalContext* globalCtx) { +void EnGuruguru_Draw(Actor* thisx, PlayState* play) { EnGuruguru* this = THIS; - OPEN_DISPS(globalCtx->state.gfxCtx); - func_8012C28C(globalCtx->state.gfxCtx); - func_8012C2DC(globalCtx->state.gfxCtx); + OPEN_DISPS(play->state.gfxCtx); + func_8012C28C(play->state.gfxCtx); + func_8012C2DC(play->state.gfxCtx); gSPSegment(POLY_OPA_DISP++, 0x08, SEGMENTED_TO_VIRTUAL(sEyeTextures[this->texIndex])); gSPSegment(POLY_OPA_DISP++, 0x09, SEGMENTED_TO_VIRTUAL(sMouthTextures[this->texIndex])); - SkelAnime_DrawFlexOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, + SkelAnime_DrawFlexOpa(play, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, EnGuruguru_OverrideLimbDraw, NULL, &this->actor); - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->state.gfxCtx); } diff --git a/src/overlays/actors/ovl_En_Guruguru/z_en_guruguru.h b/src/overlays/actors/ovl_En_Guruguru/z_en_guruguru.h index 98d8d0548..0262cd41d 100644 --- a/src/overlays/actors/ovl_En_Guruguru/z_en_guruguru.h +++ b/src/overlays/actors/ovl_En_Guruguru/z_en_guruguru.h @@ -5,7 +5,7 @@ struct EnGuruguru; -typedef void (*EnGuruguruActionFunc)(struct EnGuruguru*, GlobalContext*); +typedef void (*EnGuruguruActionFunc)(struct EnGuruguru*, PlayState*); typedef struct EnGuruguru { /* 0x000 */ Actor actor; @@ -15,10 +15,10 @@ typedef struct EnGuruguru { /* 0x248 */ EnGuruguruActionFunc actionFunc; /* 0x24C */ s16 headZRot; /* 0x24E */ s16 headXRot; - /* 0x250 */ char unk250[0x2]; + /* 0x250 */ UNK_TYPE1 unk250[0x2]; /* 0x252 */ s16 headZRotTarget; /* 0x254 */ s16 headXRotTarget; - /* 0x256 */ char unk256[0xE]; + /* 0x256 */ UNK_TYPE1 unk256[0xE]; /* 0x264 */ s16 unusedTimer; // set to 6 and decremented, but never has any effect /* 0x266 */ s16 unk266; /* 0x268 */ s16 unk268; 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 108d62afd..174c507d1 100644 --- a/src/overlays/actors/ovl_En_Hakurock/z_en_hakurock.c +++ b/src/overlays/actors/ovl_En_Hakurock/z_en_hakurock.c @@ -13,24 +13,24 @@ #define THIS ((EnHakurock*)thisx) -void EnHakurock_Init(Actor* thisx, GlobalContext* globalCtx); -void EnHakurock_Destroy(Actor* thisx, GlobalContext* globalCtx); -void EnHakurock_Update(Actor* thisx, GlobalContext* globalCtx); +void EnHakurock_Init(Actor* thisx, PlayState* play); +void EnHakurock_Destroy(Actor* thisx, PlayState* play); +void EnHakurock_Update(Actor* thisx, PlayState* play); void func_80B21BE0(BossHakugin* parent, Vec3f* arg1, s32 arg2); void func_80B21EA4(EnHakurock* this, s32 arg1); void func_80B21FFC(EnHakurock* this); -void func_80B22040(EnHakurock* this, GlobalContext* globalCtx); +void func_80B22040(EnHakurock* this, PlayState* play); void func_80B220A8(EnHakurock* this); -void func_80B221E8(EnHakurock* this, GlobalContext* globalCtx); -void func_80B222AC(EnHakurock* this, GlobalContext* globalCtx); -void func_80B2242C(EnHakurock* this, GlobalContext* globalCtx); +void func_80B221E8(EnHakurock* this, PlayState* play); +void func_80B222AC(EnHakurock* this, PlayState* play); +void func_80B2242C(EnHakurock* this, PlayState* play); void func_80B224C0(EnHakurock* this); -void func_80B22500(EnHakurock* this, GlobalContext* globalCtx); +void func_80B22500(EnHakurock* this, PlayState* play); void func_80B226AC(EnHakurock* this); -void func_80B22750(EnHakurock* this, GlobalContext* globalCtx); -void func_80B228F4(Actor* thisx, GlobalContext* globalCtx); -void EnHakurock_Draw(Actor* thisx, GlobalContext* globalCtx); +void func_80B22750(EnHakurock* this, PlayState* play); +void func_80B228F4(Actor* thisx, PlayState* play); +void EnHakurock_Draw(Actor* thisx, PlayState* play); const ActorInit En_Hakurock_InitVars = { ACTOR_EN_HAKUROCK, @@ -68,11 +68,11 @@ static CollisionCheckInfoInit sColChkInfoInit = { 0, 60, 60, MASS_IMMOVABLE }; // Stalactite -void EnHakurock_Init(Actor* thisx, GlobalContext* globalCtx) { +void EnHakurock_Init(Actor* thisx, PlayState* play) { EnHakurock* this = THIS; ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 52.0f); - Collider_InitAndSetCylinder(globalCtx, &this->collider, &this->actor, &sCylinderInit); + Collider_InitAndSetCylinder(play, &this->collider, &this->actor, &sCylinderInit); CollisionCheck_SetInfo(&this->actor.colChkInfo, NULL, &sColChkInfoInit); if (this->actor.params == EN_HAKUROCK_TYPE_BOULDER) { this->actor.gravity = -1.5f; @@ -84,46 +84,46 @@ void EnHakurock_Init(Actor* thisx, GlobalContext* globalCtx) { func_80B21FFC(this); } -void EnHakurock_Destroy(Actor* thisx, GlobalContext* globalCtx) { +void EnHakurock_Destroy(Actor* thisx, PlayState* play) { EnHakurock* this = THIS; - Collider_DestroyCylinder(globalCtx, &this->collider); + Collider_DestroyCylinder(play, &this->collider); } 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; } } @@ -173,11 +173,11 @@ void func_80B21FFC(EnHakurock* this) { this->actionFunc = func_80B22040; } -void func_80B22040(EnHakurock* this, GlobalContext* globalCtx) { +void func_80B22040(EnHakurock* this, PlayState* play) { if (this->actor.params == EN_HAKUROCK_TYPE_BOULDER) { func_80B220A8(this); } else if (this->actor.params == EN_HAKUROCK_TYPE_UNK_2) { - func_80B222AC(this, globalCtx); + func_80B222AC(this, play); } else if (this->actor.params == EN_HAKUROCK_TYPE_FENCE_PILLAR) { func_80B226AC(this); } @@ -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; @@ -201,7 +201,7 @@ void func_80B220A8(EnHakurock* this) { this->actionFunc = func_80B221E8; } -void func_80B221E8(EnHakurock* this, GlobalContext* globalCtx) { +void func_80B221E8(EnHakurock* this, PlayState* play) { if (this->counter > 0) { this->counter--; } @@ -209,7 +209,7 @@ void func_80B221E8(EnHakurock* this, GlobalContext* globalCtx) { this->actor.shape.rot.y += 0x900; this->actor.shape.rot.z += 0xB00; - if (this->collider.base.atFlags & AT_HIT || ((this->counter == 0) && (this->collider.base.ocFlags1 & OC1_HIT)) || + if ((this->collider.base.atFlags & AT_HIT) || ((this->counter == 0) && (this->collider.base.ocFlags1 & OC1_HIT)) || ((this->actor.bgCheckFlags & 1) && (this->actor.velocity.y < 0.0f))) { Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_ROCK_BROKEN); func_80B21EA4(this, 0); @@ -217,13 +217,13 @@ void func_80B221E8(EnHakurock* this, GlobalContext* globalCtx) { } } -void func_80B222AC(EnHakurock* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); +void func_80B222AC(EnHakurock* this, PlayState* play) { + Player* player = GET_PLAYER(play); 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; @@ -240,7 +240,7 @@ void func_80B222AC(EnHakurock* this, GlobalContext* globalCtx) { this->actionFunc = func_80B2242C; } -void func_80B2242C(EnHakurock* this, GlobalContext* globalCtx) { +void func_80B2242C(EnHakurock* this, PlayState* play) { if ((this->collider.base.ocFlags1 & OC1_HIT) && (this->collider.base.oc == this->actor.parent)) { func_80B21EA4(this, 1); func_80B21FFC(this); @@ -259,8 +259,8 @@ void func_80B224C0(EnHakurock* this) { this->actionFunc = func_80B22500; } -void func_80B22500(EnHakurock* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); +void func_80B22500(EnHakurock* this, PlayState* play) { + Player* player = GET_PLAYER(play); if (this->counter > 0) { this->counter--; @@ -307,52 +307,52 @@ void func_80B226AC(EnHakurock* this) { this->actionFunc = func_80B22750; } -void func_80B22750(EnHakurock* this, GlobalContext* globalCtx) { +void func_80B22750(EnHakurock* this, PlayState* play) { if (this->actor.params == EN_HAKUROCK_TYPE_UNK_0) { func_80B21EA4(this, 3); func_80B21FFC(this); } } -void EnHakurock_Update(Actor* thisx, GlobalContext* globalCtx) { +void EnHakurock_Update(Actor* thisx, PlayState* play) { EnHakurock* this = THIS; s16 rockParams; - this->actionFunc(this, globalCtx); + this->actionFunc(this, play); rockParams = this->actor.params; if ((rockParams == EN_HAKUROCK_TYPE_BOULDER) || (rockParams == EN_HAKUROCK_TYPE_UNK_2)) { Actor_MoveWithGravity(&this->actor); - Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 30.0f, this->collider.dim.radius, 0.0f, 0x85); + Actor_UpdateBgCheckInfo(play, &this->actor, 30.0f, this->collider.dim.radius, 0.0f, 0x85); if (this->actor.floorHeight == BGCHECK_Y_MIN) { func_80B21FFC(this); } else { 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); + CollisionCheck_SetAT(play, &play->colChkCtx, &this->collider.base); + CollisionCheck_SetAC(play, &play->colChkCtx, &this->collider.base); + CollisionCheck_SetOC(play, &play->colChkCtx, &this->collider.base); } } else if ((rockParams == EN_HAKUROCK_TYPE_STALACTITE) || (rockParams == EN_HAKUROCK_TYPE_FENCE_PILLAR)) { Collider_UpdateCylinder(&this->actor, &this->collider); - CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); - CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + CollisionCheck_SetAC(play, &play->colChkCtx, &this->collider.base); + CollisionCheck_SetOC(play, &play->colChkCtx, &this->collider.base); } } -void func_80B228F4(Actor* thisx, GlobalContext* globalCtx) { - OPEN_DISPS(globalCtx->state.gfxCtx); - func_8012C28C(globalCtx->state.gfxCtx); +void func_80B228F4(Actor* thisx, PlayState* play) { + OPEN_DISPS(play->state.gfxCtx); + func_8012C28C(play->state.gfxCtx); gDPSetPrimColor(POLY_OPA_DISP++, 0, 0x80, 255, 185, 24, 255); - gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_OPA_DISP++, gameplay_keep_DL_06AB30); - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->state.gfxCtx); } -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); - gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); +void EnHakurock_Draw(Actor* thisx, PlayState* play) { + OPEN_DISPS(play->state.gfxCtx); + func_8012C28C(play->state.gfxCtx); + Matrix_Translate(-100.0f, 0.0f, 0.0f, MTXMODE_APPLY); + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_OPA_DISP++, object_boss_hakugin_DL_011100); gSPDisplayList(POLY_OPA_DISP++, object_boss_hakugin_DL_011178); - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->state.gfxCtx); } diff --git a/src/overlays/actors/ovl_En_Hakurock/z_en_hakurock.h b/src/overlays/actors/ovl_En_Hakurock/z_en_hakurock.h index eb1c4eb5d..93931e9f3 100644 --- a/src/overlays/actors/ovl_En_Hakurock/z_en_hakurock.h +++ b/src/overlays/actors/ovl_En_Hakurock/z_en_hakurock.h @@ -5,7 +5,7 @@ struct EnHakurock; -typedef void (*EnHakurockActionFunc)(struct EnHakurock*, GlobalContext*); +typedef void (*EnHakurockActionFunc)(struct EnHakurock*, PlayState*); typedef enum { /* 0x0 */ EN_HAKUROCK_TYPE_UNK_0, 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 d7ec6103f..de0880e96 100644 --- a/src/overlays/actors/ovl_En_Hanabi/z_en_hanabi.c +++ b/src/overlays/actors/ovl_En_Hanabi/z_en_hanabi.c @@ -11,15 +11,15 @@ #define THIS ((EnHanabi*)thisx) -void EnHanabi_Init(Actor* thisx, GlobalContext* globalCtx); -void EnHanabi_Destroy(Actor* thisx, GlobalContext* globalCtx); -void EnHanabi_Update(Actor* thisx, GlobalContext* globalCtx); +void EnHanabi_Init(Actor* thisx, PlayState* play); +void EnHanabi_Destroy(Actor* thisx, PlayState* play); +void EnHanabi_Update(Actor* thisx, PlayState* play); -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); +void func_80B23894(EnHanabi* this, PlayState* play); +void func_80B238D4(EnHanabi* this, PlayState* play); +void func_80B23910(EnHanabi* this, PlayState* play); +void func_80B23934(EnHanabi* this, PlayState* play); +void EnHanabi_Draw(Actor* thisx, PlayState* play); const ActorInit En_Hanabi_InitVars = { ACTOR_EN_HANABI, @@ -133,15 +133,15 @@ s32 func_80B22F34(EnHanabiStruct* arg0) { return count; } -void func_80B22FA8(EnHanabiStruct* arg0, GlobalContext* globalCtx2) { - GlobalContext* globalCtx = globalCtx2; - GraphicsContext* gfxCtx = globalCtx->state.gfxCtx; +void func_80B22FA8(EnHanabiStruct* arg0, PlayState* play2) { + PlayState* play = play2; + GraphicsContext* gfxCtx = play->state.gfxCtx; s32 i; u8 sp53; OPEN_DISPS(gfxCtx); - func_8012C2DC(globalCtx->state.gfxCtx); + func_8012C2DC(play->state.gfxCtx); POLY_XLU_DISP = Gfx_CallSetupDL(POLY_XLU_DISP, 20); @@ -153,18 +153,17 @@ void func_80B22FA8(EnHanabiStruct* arg0, GlobalContext* globalCtx2) { for (i = 0; i < 400; i++, arg0++) { if (arg0->unk_00 == 1) { - Matrix_InsertTranslation(arg0->unk_08.x, arg0->unk_08.y, arg0->unk_08.z, MTXMODE_NEW); - Matrix_NormalizeXYZ(&globalCtx->billboardMtxF); + Matrix_Translate(arg0->unk_08.x, arg0->unk_08.y, arg0->unk_08.z, MTXMODE_NEW); + Matrix_ReplaceRotation(&play->billboardMtxF); if (arg0->unk_01 < 40) { Matrix_Scale(arg0->unk_04 * 0.025f * arg0->unk_01, arg0->unk_04 * 0.025f * arg0->unk_01, 1.0f, MTXMODE_APPLY); } else { Matrix_Scale(arg0->unk_04, arg0->unk_04, 1.0f, MTXMODE_APPLY); } - Matrix_InsertZRotation_s(globalCtx->gameplayFrames * 4864, MTXMODE_APPLY); + Matrix_RotateZS(play->gameplayFrames * 4864, MTXMODE_APPLY); - gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), - G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); if (sp53 != arg0->unk_02) { gDPPipeSync(POLY_XLU_DISP++); @@ -189,8 +188,8 @@ void func_80B22FA8(EnHanabiStruct* arg0, GlobalContext* globalCtx2) { CLOSE_DISPS(gfxCtx); } -void EnHanabi_Init(Actor* thisx, GlobalContext* globalCtx2) { - GlobalContext* globalCtx = globalCtx2; +void EnHanabi_Init(Actor* thisx, PlayState* play2) { + PlayState* play = play2; EnHanabi* this = THIS; s32 i; @@ -204,7 +203,7 @@ void EnHanabi_Init(Actor* thisx, GlobalContext* globalCtx2) { 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]); + this->unk_4634[i] = LightContext_InsertLight(play, &play->lightCtx, &this->unk_4608[i]); } if (ENHANABI_GET_1F(thisx) == ENHANABI_1F_1) { @@ -213,13 +212,13 @@ void EnHanabi_Init(Actor* thisx, GlobalContext* globalCtx2) { } } -void EnHanabi_Destroy(Actor* thisx, GlobalContext* globalCtx2) { - GlobalContext* globalCtx = globalCtx2; +void EnHanabi_Destroy(Actor* thisx, PlayState* play2) { + PlayState* play = play2; EnHanabi* this = THIS; s32 i; for (i = 0; i < ARRAY_COUNT(this->unk_4634); i++) { - LightContext_RemoveLight(globalCtx, &globalCtx->lightCtx, this->unk_4634[i]); + LightContext_RemoveLight(play, &play->lightCtx, this->unk_4634[i]); } } @@ -264,7 +263,7 @@ void func_80B235CC(EnHanabi* this, Vec3f* arg1, s32 arg2) { } } -void func_80B236C8(EnHanabi* this, GlobalContext* globalCtx) { +void func_80B236C8(EnHanabi* this, PlayState* play) { Vec3f sp34; f32 sp30; s32 pad; @@ -303,52 +302,52 @@ void func_80B236C8(EnHanabi* this, GlobalContext* globalCtx) { } } -void func_80B23894(EnHanabi* this, GlobalContext* globalCtx) { - func_80B236C8(this, globalCtx); +void func_80B23894(EnHanabi* this, PlayState* play) { + func_80B236C8(this, play); if (func_80B22F34(this->unk_148) == 0) { Actor_MarkForDeath(&this->actor); } } -void func_80B238D4(EnHanabi* this, GlobalContext* globalCtx) { - func_80B236C8(this, globalCtx); +void func_80B238D4(EnHanabi* this, PlayState* play) { + func_80B236C8(this, play); if (this->actor.home.rot.x == 0) { this->actionFunc = func_80B23894; } } -void func_80B23910(EnHanabi* this, GlobalContext* globalCtx) { +void func_80B23910(EnHanabi* this, PlayState* play) { 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); +void func_80B23934(EnHanabi* this, PlayState* play) { + if ((gSaveContext.save.entrance == ENTRANCE(TERMINA_FIELD, 1)) && (gSaveContext.sceneSetupIndex == 7)) { + if (play->csCtx.frames > 1650) { + func_80B236C8(this, play); 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)) { + if ((play->sceneNum == SCENE_00KEIKOKU) && (gSaveContext.sceneSetupIndex == 7) && + (play->csCtx.currentCsIndex == 0) && (play->csCtx.frames == 610)) { Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_KYOJIN_GROAN); } } -void EnHanabi_Update(Actor* thisx, GlobalContext* globalCtx) { +void EnHanabi_Update(Actor* thisx, PlayState* play) { EnHanabi* this = THIS; - this->actionFunc(this, globalCtx); + this->actionFunc(this, play); func_80B22E0C(this->unk_148); } -void EnHanabi_Draw(Actor* thisx, GlobalContext* globalCtx) { +void EnHanabi_Draw(Actor* thisx, PlayState* play) { EnHanabi* this = THIS; - Matrix_StatePush(); - func_80B22FA8(this->unk_148, globalCtx); - Matrix_StatePop(); + Matrix_Push(); + func_80B22FA8(this->unk_148, play); + 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 ed4963daf..a219ab2ba 100644 --- a/src/overlays/actors/ovl_En_Hanabi/z_en_hanabi.h +++ b/src/overlays/actors/ovl_En_Hanabi/z_en_hanabi.h @@ -5,7 +5,7 @@ struct EnHanabi; -typedef void (*EnHanabiActionFunc)(struct EnHanabi*, GlobalContext*); +typedef void (*EnHanabiActionFunc)(struct EnHanabi*, PlayState*); #define ENHANABI_GET_1F(thisx) ((thisx)->params & 0x1F) 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..5eb2292fc 100644 --- a/src/overlays/actors/ovl_En_Hata/z_en_hata.c +++ b/src/overlays/actors/ovl_En_Hata/z_en_hata.c @@ -5,17 +5,17 @@ */ #include "z_en_hata.h" +#include "objects/object_hata/object_hata.h" #define FLAGS 0x00000000 #define THIS ((EnHata*)thisx) -void EnHata_Init(Actor* thisx, GlobalContext* globalCtx); -void EnHata_Destroy(Actor* thisx, GlobalContext* globalCtx); -void EnHata_Update(Actor* thisx, GlobalContext* globalCtx); -void EnHata_Draw(Actor* thisx, GlobalContext* globalCtx); +void EnHata_Init(Actor* thisx, PlayState* play); +void EnHata_Destroy(Actor* thisx, PlayState* play); +void EnHata_Update(Actor* thisx, PlayState* play2); +void EnHata_Draw(Actor* thisx, PlayState* play); -#if 0 const ActorInit En_Hata_InitVars = { ACTOR_EN_HATA, ACTORCAT_PROP, @@ -28,16 +28,73 @@ const ActorInit En_Hata_InitVars = { (ActorFunc)EnHata_Draw, }; -#endif +void EnHata_Init(Actor* thisx, PlayState* play) { + EnHata* this = THIS; + s32 rand; + f32 endFrame; -extern UNK_TYPE D_06002FD0; + SkelAnime_Init(play, &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(play, &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, PlayState* play) { + EnHata* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Hata/EnHata_Destroy.s") + DynaPoly_DeleteBgActor(play, &play->colCtx.dyna, this->dyna.bgId); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Hata/EnHata_Update.s") +void EnHata_Update(Actor* thisx, PlayState* play2) { + PlayState* play = play2; + 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(play->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 = play->envCtx.windDir.x; + sp34.y = play->envCtx.windDir.y + ((1.0f - phi_fv0) * 240.0f); + sp34.y = CLAMP(sp34.y, -118.0f, 118.0f); + sp34.z = play->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(PlayState* play, 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, PlayState* play) { + EnHata* this = THIS; + + func_8012C5B0(play->state.gfxCtx); + SkelAnime_DrawOpa(play, 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 bb2fb002b..b69429d1a 100644 --- a/src/overlays/actors/ovl_En_Heishi/z_en_heishi.c +++ b/src/overlays/actors/ovl_En_Heishi/z_en_heishi.c @@ -5,29 +5,28 @@ */ #include "z_en_heishi.h" -#include "objects/object_sdn/object_sdn.h" #define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_8) #define THIS ((EnHeishi*)thisx) -void EnHeishi_Init(Actor* thisx, GlobalContext* globalCtx); -void EnHeishi_Destroy(Actor* thisx, GlobalContext* globalCtx); -void EnHeishi_Update(Actor* thisx, GlobalContext* globalCtx); -void EnHeishi_Draw(Actor* thisx, GlobalContext* globalCtx); +void EnHeishi_Init(Actor* thisx, PlayState* play); +void EnHeishi_Destroy(Actor* thisx, PlayState* play); +void EnHeishi_Update(Actor* thisx, PlayState* play); +void EnHeishi_Draw(Actor* thisx, PlayState* play); -void EnHeishi_ChangeAnimation(EnHeishi* this, s32 animIndex); +void EnHeishi_ChangeAnim(EnHeishi* this, s32 animIndex); void EnHeishi_SetHeadRotation(EnHeishi* this); void EnHeishi_SetupIdle(EnHeishi* this); -void EnHeishi_Idle(EnHeishi* this, GlobalContext* globalCtx); +void EnHeishi_Idle(EnHeishi* this, PlayState* play); 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; + /* 0 */ HEISHI_ANIM_STAND_HAND_ON_HIP, + /* 1 */ HEISHI_ANIM_CHEER_WITH_SPEAR, + /* 2 */ HEISHI_ANIM_WAVE, + /* 3 */ HEISHI_ANIM_SIT_AND_REACH, + /* 4 */ HEISHI_ANIM_STAND_UP +} EnHeishiAnimation; const ActorInit En_Heishi_InitVars = { ACTOR_EN_HEISHI, @@ -61,12 +60,12 @@ static ColliderCylinderInit sCylinderInit = { { 20, 60, 0, { 0, 0, 0 } }, }; -void EnHeishi_Init(Actor* thisx, GlobalContext* globalCtx) { +void EnHeishi_Init(Actor* thisx, PlayState* play) { EnHeishi* this = THIS; 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); + SkelAnime_InitFlex(play, &this->skelAnime, &gSoldierSkel, &gSoldierWave, this->jointTable, this->morphTable, + SOLDIER_LIMB_MAX); this->actor.colChkInfo.mass = MASS_IMMOVABLE; this->paramsCopy = this->actor.params; this->yawTowardsPlayer = this->actor.world.rot.y; @@ -89,22 +88,22 @@ void EnHeishi_Init(Actor* thisx, GlobalContext* globalCtx) { this->actor.targetMode = 6; this->actor.gravity = -3.0f; - Collider_InitAndSetCylinder(globalCtx, &this->colliderCylinder, &this->actor, &sCylinderInit); + Collider_InitAndSetCylinder(play, &this->colliderCylinder, &this->actor, &sCylinderInit); this->actor.flags |= ACTOR_FLAG_8000000; EnHeishi_SetupIdle(this); } -void EnHeishi_Destroy(Actor* thisx, GlobalContext* globalCtx) { +void EnHeishi_Destroy(Actor* thisx, PlayState* play) { EnHeishi* this = THIS; - Collider_DestroyCylinder(globalCtx, &this->colliderCylinder); + Collider_DestroyCylinder(play, &this->colliderCylinder); } -void EnHeishi_ChangeAnimation(EnHeishi* this, s32 animIndex) { +void EnHeishi_ChangeAnim(EnHeishi* this, s32 animIndex) { static AnimationHeader* sAnimations[] = { &gSoldierStandHandOnHip, &gSoldierCheerWithSpear, &gSoldierWave, &gSoldierSitAndReach, &gSoldierStandUp, }; - static u8 sAnimModes[] = { + static u8 sAnimationModes[] = { 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, @@ -113,7 +112,7 @@ void EnHeishi_ChangeAnimation(EnHeishi* this, s32 animIndex) { 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); + sAnimationModes[this->animIndex], -10.0f); } void EnHeishi_SetHeadRotation(EnHeishi* this) { @@ -132,17 +131,17 @@ void EnHeishi_SetHeadRotation(EnHeishi* this) { } void EnHeishi_SetupIdle(EnHeishi* this) { - s8 animIndex = HEISHI_ANIMATION_STAND_HAND_ON_HIP; + s8 animIndex = HEISHI_ANIM_STAND_HAND_ON_HIP; - EnHeishi_ChangeAnimation(this, animIndex); + EnHeishi_ChangeAnim(this, animIndex); this->unk278 = animIndex; this->actionFunc = EnHeishi_Idle; } -void EnHeishi_Idle(EnHeishi* this, GlobalContext* globalCtx) { +void EnHeishi_Idle(EnHeishi* this, PlayState* play) { } -void EnHeishi_Update(Actor* thisx, GlobalContext* globalCtx) { +void EnHeishi_Update(Actor* thisx, PlayState* play) { s32 pad; EnHeishi* this = THIS; @@ -155,9 +154,9 @@ void EnHeishi_Update(Actor* thisx, GlobalContext* globalCtx) { if ((this->paramsCopy != 0) && (gSaveContext.save.day == 3) && gSaveContext.save.isNight) { Actor_MarkForDeath(&this->actor); } else { - this->actionFunc(this, globalCtx); + this->actionFunc(this, play); Actor_MoveWithGravity(&this->actor); - Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 20.0f, 20.0f, 50.0f, 29); + Actor_UpdateBgCheckInfo(play, &this->actor, 20.0f, 20.0f, 50.0f, 29); Actor_SetScale(&this->actor, 0.01f); if (this->shouldSetHeadRotation) { EnHeishi_SetHeadRotation(this); @@ -167,15 +166,14 @@ void EnHeishi_Update(Actor* thisx, GlobalContext* globalCtx) { 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); + CollisionCheck_SetOC(play, &play->colChkCtx, &this->colliderCylinder.base); } } -s32 EnHeishi_OverrideLimbDraw(GlobalContext* globalctx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, - Actor* thisx) { +s32 EnHeishi_OverrideLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, Actor* thisx) { EnHeishi* this = THIS; - if (limbIndex == HEISHI_LIMB_HEAD) { + if (limbIndex == SOLDIER_LIMB_HEAD) { rot->x += this->headRotX; rot->y += this->headRotY; rot->z += this->headRotZ; @@ -184,10 +182,10 @@ s32 EnHeishi_OverrideLimbDraw(GlobalContext* globalctx, s32 limbIndex, Gfx** dLi return false; } -void EnHeishi_Draw(Actor* thisx, GlobalContext* globalCtx) { +void EnHeishi_Draw(Actor* thisx, PlayState* play) { EnHeishi* this = THIS; - func_8012C28C(globalCtx->state.gfxCtx); - SkelAnime_DrawFlexOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, + func_8012C28C(play->state.gfxCtx); + SkelAnime_DrawFlexOpa(play, 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 de65bac72..1758ceae6 100644 --- a/src/overlays/actors/ovl_En_Heishi/z_en_heishi.h +++ b/src/overlays/actors/ovl_En_Heishi/z_en_heishi.h @@ -2,53 +2,33 @@ #define Z_EN_HEISHI_H #include "global.h" +#include "objects/object_sdn/object_sdn.h" 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 void (*EnHeishiActionFunc)(struct EnHeishi*, PlayState*); typedef struct EnHeishi { - /* 0x0000 */ Actor actor; - /* 0x0144 */ SkelAnime skelAnime; - /* 0x0188 */ Vec3s jointTable[HEISHI_LIMB_MAX]; - /* 0x01EE */ Vec3s morphTable[HEISHI_LIMB_MAX]; - /* 0x0254 */ EnHeishiActionFunc actionFunc; - /* 0x0258 */ s16 headRotY; - /* 0x025A */ s16 headRotX; - /* 0x025C */ s16 headRotZ; - /* 0x025E */ s16 headRotYTarget; - /* 0x0260 */ s16 headRotXTarget; - /* 0x0262 */ s16 headRotZTarget; - /* 0x0264 */ s32 animIndex; - /* 0x0268 */ s32 paramsCopy; - /* 0x026C */ s32 shouldSetHeadRotation; - /* 0x0270 */ s16 timer; - /* 0x0272 */ s16 yawTowardsPlayer; - /* 0x0274 */ f32 frameCount; - /* 0x0278 */ s16 unk278; // set and not used - /* 0x027C */ UNK_TYPE1 unk_27C[0x8]; - /* 0x0284 */ ColliderCylinder colliderCylinder; + /* 0x000 */ Actor actor; + /* 0x144 */ SkelAnime skelAnime; + /* 0x188 */ Vec3s jointTable[SOLDIER_LIMB_MAX]; + /* 0x1EE */ Vec3s morphTable[SOLDIER_LIMB_MAX]; + /* 0x254 */ EnHeishiActionFunc actionFunc; + /* 0x258 */ s16 headRotY; + /* 0x25A */ s16 headRotX; + /* 0x25C */ s16 headRotZ; + /* 0x25E */ s16 headRotYTarget; + /* 0x260 */ s16 headRotXTarget; + /* 0x262 */ s16 headRotZTarget; + /* 0x264 */ s32 animIndex; + /* 0x268 */ s32 paramsCopy; + /* 0x26C */ s32 shouldSetHeadRotation; + /* 0x270 */ s16 timer; + /* 0x272 */ s16 yawTowardsPlayer; + /* 0x274 */ f32 frameCount; + /* 0x278 */ s16 unk278; // set and not used + /* 0x27C */ UNK_TYPE1 unk_27C[0x8]; + /* 0x284 */ ColliderCylinder colliderCylinder; } EnHeishi; // size = 0x2D0 #endif // Z_EN_HEISHI_H diff --git a/src/overlays/actors/ovl_En_Hg/z_en_hg.c b/src/overlays/actors/ovl_En_Hg/z_en_hg.c index 0bbef0b9e..83e0935f5 100644 --- a/src/overlays/actors/ovl_En_Hg/z_en_hg.c +++ b/src/overlays/actors/ovl_En_Hg/z_en_hg.c @@ -1,35 +1,34 @@ /* * File: z_en_hg.c * Overlay: ovl_En_Hg - * Description: Pamela's Father (Human) + * Description: Pamela's Father (Gibdo) */ #include "z_en_hg.h" -#include "objects/object_harfgibud/object_harfgibud.h" #define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_8 | ACTOR_FLAG_10 | ACTOR_FLAG_100000 | ACTOR_FLAG_2000000) #define THIS ((EnHg*)thisx) -void EnHg_Init(Actor* thisx, GlobalContext* globalCtx); -void EnHg_Destroy(Actor* thisx, GlobalContext* globalCtx); -void EnHg_Update(Actor* thisx, GlobalContext* globalCtx); -void EnHg_Draw(Actor* thisx, GlobalContext* globalCtx); +void EnHg_Init(Actor* thisx, PlayState* play); +void EnHg_Destroy(Actor* thisx, PlayState* play); +void EnHg_Update(Actor* thisx, PlayState* play); +void EnHg_Draw(Actor* thisx, PlayState* play); void func_80BCF354(EnHg* this); -void func_80BCF398(EnHg* this, GlobalContext* globalCtx); +void func_80BCF398(EnHg* this, PlayState* play); void func_80BCF468(EnHg* this); void func_80BCF468(EnHg* this); -void func_80BCF4AC(EnHg* this, GlobalContext* globalCtx); +void func_80BCF4AC(EnHg* this, PlayState* play); void func_80BCF5F0(EnHg* this); -void func_80BCF634(EnHg* this, GlobalContext* globalCtx); +void func_80BCF634(EnHg* this, PlayState* play); void func_80BCF68C(EnHg* this); -void func_80BCF6D0(EnHg* this, GlobalContext* globalCtx); -void func_80BCF8A0(EnHg* this, GlobalContext* globalCtx); +void func_80BCF6D0(EnHg* this, PlayState* play); +void func_80BCF8A0(EnHg* this, PlayState* play); void func_80BCF93C(EnHg* this); -void func_80BCF95C(EnHg* this, GlobalContext* globalCtx); -s32 EnHg_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, Actor* thisx); -void EnHg_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx); +void func_80BCF95C(EnHg* this, PlayState* play); +s32 EnHg_OverrideLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, Actor* thisx); +void EnHg_PostLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx); const ActorInit En_Hg_InitVars = { ACTOR_EN_HG, @@ -102,7 +101,7 @@ static CollisionCheckInfoInit2 sColChkInfoInit2 = { 0, 0, 0, 0, 0x80, }; -static AnimationInfo sAnimations[] = { +static AnimationInfo sAnimationInfo[] = { { &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 }, @@ -115,16 +114,16 @@ static AnimationInfo sAnimations[] = { static u32 D_80BD00C8 = false; -void EnHg_Init(Actor* thisx, GlobalContext* globalCtx) { +void EnHg_Init(Actor* thisx, PlayState* play) { EnHg* this = THIS; s16 currentCutscene = this->actor.cutscene; s32 i; ActorShape_Init(&this->actor.shape, 0.0f, NULL, 36.0f); - SkelAnime_InitFlex(globalCtx, &this->skelAnime, &object_harfgibud_Skel_008580, &object_harfgibud_Anim_00260C, - this->jointTable, this->morphTable, HG_LIMB_MAX); - Collider_InitCylinder(globalCtx, &this->collider); - Collider_SetCylinder(globalCtx, &this->collider, &this->actor, &sCylinderInit); + SkelAnime_InitFlex(play, &this->skelAnime, &gHarfgibudGibdoSkel, &object_harfgibud_Anim_00260C, this->jointTable, + this->morphTable, HARFGIBUD_GIBDO_LIMB_MAX); + Collider_InitCylinder(play, &this->collider); + Collider_SetCylinder(play, &this->collider, &this->actor, &sCylinderInit); CollisionCheck_SetInfo2(&this->actor.colChkInfo, &sDamageTable, &sColChkInfoInit2); if ((gSaveContext.save.weekEventReg[75] & 0x20) || (gSaveContext.save.weekEventReg[52] & 0x20)) { Actor_MarkForDeath(&this->actor); @@ -142,41 +141,41 @@ void EnHg_Init(Actor* thisx, GlobalContext* globalCtx) { func_80BCF354(this); } -void EnHg_Destroy(Actor* thisx, GlobalContext* globalCtx) { +void EnHg_Destroy(Actor* thisx, PlayState* play) { EnHg* this = THIS; - Collider_DestroyCylinder(globalCtx, &this->collider); + Collider_DestroyCylinder(play, &this->collider); } void func_80BCF354(EnHg* this) { - Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 0); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, 0); this->actionFunc = func_80BCF398; } -void func_80BCF398(EnHg* this, GlobalContext* globalCtx) { +void func_80BCF398(EnHg* this, PlayState* play) { if (this->actor.colChkInfo.health == 1) { if ((this->actor.xzDistToPlayer < 200.0f && this->actor.playerHeightRel < 40.0f) && - !Cutscene_CheckActorAction(globalCtx, 0x1E3)) { + !Cutscene_CheckActorAction(play, 0x1E3)) { func_80BCF468(this); } - if ((gSaveContext.sceneSetupIndex == 0 && globalCtx->csCtx.currentCsIndex == 0) && - (globalCtx->csCtx.frames == 20 || globalCtx->csCtx.frames == 60)) { + if ((gSaveContext.sceneSetupIndex == 0 && play->csCtx.currentCsIndex == 0) && + (play->csCtx.frames == 20 || play->csCtx.frames == 60)) { Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_HALF_REDEAD_SURPRISE); } } } void func_80BCF468(EnHg* this) { - Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 1); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, 1); this->actionFunc = func_80BCF4AC; } -void func_80BCF4AC(EnHg* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); +void func_80BCF4AC(EnHg* this, PlayState* play) { + Player* player = GET_PLAYER(play); s32 pad; this->actor.speedXZ = 1.6f; - if (!(player->stateFlags2 & 0x08000000) && Message_GetState(&globalCtx->msgCtx) == 0) { + if (!(player->stateFlags2 & 0x08000000) && Message_GetState(&play->msgCtx) == TEXT_STATE_NONE) { if (((this->skelAnime.curFrame > 9.0f) && (this->skelAnime.curFrame < 16.0f)) || ((this->skelAnime.curFrame > 44.0f) && (this->skelAnime.curFrame < 51.0f))) { Actor_MoveWithGravity(&this->actor); @@ -191,12 +190,12 @@ void func_80BCF4AC(EnHg* this, GlobalContext* globalCtx) { } void func_80BCF5F0(EnHg* this) { - Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 0); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, 0); this->actionFunc = func_80BCF634; } -void func_80BCF634(EnHg* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); +void func_80BCF634(EnHg* this, PlayState* play) { + Player* player = GET_PLAYER(play); if (Math_Vec3f_DistXZ(&player->actor.world.pos, &this->actor.home.pos) < 200.0f) { func_80BCF468(this); @@ -204,27 +203,27 @@ void func_80BCF634(EnHg* this, GlobalContext* globalCtx) { } void func_80BCF68C(EnHg* this) { - Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 2); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, 2); this->actionFunc = func_80BCF6D0; } -void func_80BCF6D0(EnHg* this, GlobalContext* globalCtx) { +void func_80BCF6D0(EnHg* this, PlayState* play) { if (Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) { func_80BCF5F0(this); } } -void func_80BCF710(EnHg* this, GlobalContext* globalCtx) { - if (Message_GetState(&globalCtx->msgCtx) == 0) { - if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { - Message_StartTextbox(globalCtx, 0x24F, &this->actor); +void func_80BCF710(EnHg* this, PlayState* play) { + if (Message_GetState(&play->msgCtx) == TEXT_STATE_NONE) { + if (Actor_ProcessTalkRequest(&this->actor, &play->state)) { + Message_StartTextbox(play, 0x24F, &this->actor); } else { - func_800B8614(&this->actor, globalCtx, 80.0f); + func_800B8614(&this->actor, play, 80.0f); } } } -void func_80BCF778(EnHg* this, GlobalContext* globalCtx) { +void func_80BCF778(EnHg* this, PlayState* play) { if (this->actor.colChkInfo.health == 1) { if (this->actionFunc == func_80BCF4AC || this->actionFunc == func_80BCF6D0 || this->actionFunc == func_80BCF634) { @@ -233,17 +232,17 @@ void func_80BCF778(EnHg* this, GlobalContext* globalCtx) { } } -void func_80BCF7D8(EnHg* this, GlobalContext* globalCtx) { +void func_80BCF7D8(EnHg* this, PlayState* play) { if (this->actor.colChkInfo.health) { if (this->collider.base.acFlags & AC_HIT) { this->collider.base.acFlags &= ~AC_HIT; func_80BCF68C(this); } Collider_UpdateCylinder(&this->actor, &this->collider); - CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + CollisionCheck_SetOC(play, &play->colChkCtx, &this->collider.base); if (this->actionFunc != func_80BCF6D0 && this->actionFunc != func_80BCF8A0 && this->actionFunc != func_80BCF95C) { - CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + CollisionCheck_SetAC(play, &play->colChkCtx, &this->collider.base); } } } @@ -252,7 +251,7 @@ void func_80BCF88C(EnHg* this) { this->actionFunc = func_80BCF8A0; } -void func_80BCF8A0(EnHg* this, GlobalContext* globalCtx) { +void func_80BCF8A0(EnHg* this, PlayState* play) { if (ActorCutscene_GetCanPlayNext(this->cutscenes[this->unk218])) { ActorCutscene_Start(this->cutscenes[this->unk218], &this->actor); func_80BCF93C(this); @@ -270,38 +269,38 @@ void func_80BCF93C(EnHg* this) { this->actionFunc = func_80BCF95C; } -void func_80BCF95C(EnHg* this, GlobalContext* globalCtx) { - if (Cutscene_CheckActorAction(globalCtx, 484)) { - s32 actionIndex = Cutscene_GetActorActionIndex(globalCtx, 484); +void func_80BCF95C(EnHg* this, PlayState* play) { + if (Cutscene_CheckActorAction(play, 484)) { + s32 actionIndex = Cutscene_GetActorActionIndex(play, 484); - if (this->cutscenes[3] != globalCtx->csCtx.actorActions[actionIndex]->action) { - this->cutscenes[3] = globalCtx->csCtx.actorActions[actionIndex]->action; - switch (globalCtx->csCtx.actorActions[actionIndex]->action) { + if (this->cutscenes[3] != play->csCtx.actorActions[actionIndex]->action) { + this->cutscenes[3] = play->csCtx.actorActions[actionIndex]->action; + switch (play->csCtx.actorActions[actionIndex]->action) { case 1: - this->currentAnimation = 0; - Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 0); + this->animIndex = 0; + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, 0); break; case 2: this->cutscenes[2] = 0; - this->currentAnimation = 3; - Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 3); + this->animIndex = 3; + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, 3); break; case 3: this->cutscenes[2] = 0; - this->currentAnimation = 5; - Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 5); + this->animIndex = 5; + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, 5); break; case 4: this->cutscenes[2] = 0; - this->currentAnimation = 7; + this->animIndex = 7; if ((this->unk218 == 1) || (this->unk218 == 3)) { func_8019F128(NA_SE_EN_HALF_REDEAD_TRANS); } - Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 7); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, 7); break; case 5: - this->currentAnimation = 1; - Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 1); + this->animIndex = 1; + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, 1); break; case 6: gSaveContext.save.weekEventReg[75] |= 0x20; @@ -310,19 +309,19 @@ void func_80BCF95C(EnHg* this, GlobalContext* globalCtx) { } } else { if (Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) { - switch (this->currentAnimation) { + switch (this->animIndex) { case 3: - this->currentAnimation = 4; - Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 4); + this->animIndex = 4; + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, 4); break; case 5: - this->currentAnimation = 6; - Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 6); + this->animIndex = 6; + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, 6); break; } } } - switch (this->currentAnimation) { + switch (this->animIndex) { case 3: case 4: func_800B9010(&this->actor, NA_SE_EN_HALF_REDEAD_LOOP - SFX_FLAG); @@ -337,16 +336,16 @@ void func_80BCF95C(EnHg* this, GlobalContext* globalCtx) { } break; } - Cutscene_ActorTranslateAndYaw(&this->actor, globalCtx, actionIndex); + Cutscene_ActorTranslateAndYaw(&this->actor, play, actionIndex); return; - } else if (globalCtx->csCtx.state == 0) { + } else if (play->csCtx.state == 0) { func_80BCF354(this); } this->cutscenes[3] = 0x63; } -void func_80BCFC0C(EnHg* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); +void func_80BCFC0C(EnHg* this, PlayState* play) { + Player* player = GET_PLAYER(play); if (this->actor.colChkInfo.health == 1 && !(fabsf(this->actor.playerHeightRel) >= 80.0f)) { if (player->stateFlags2 & 0x08000000) { @@ -357,8 +356,9 @@ void func_80BCFC0C(EnHg* this, GlobalContext* globalCtx) { } else { D_80BD00C8 = false; } - if (globalCtx->msgCtx.ocarinaMode == 3) { - if (globalCtx->msgCtx.unk1202E == 7 && gSaveContext.save.playerForm == PLAYER_FORM_HUMAN) { + if (play->msgCtx.ocarinaMode == 3) { + if (play->msgCtx.lastPlayedSong == OCARINA_SONG_HEALING && + gSaveContext.save.playerForm == PLAYER_FORM_HUMAN) { if (INV_CONTENT(ITEM_MASK_GIBDO) == ITEM_MASK_GIBDO) { this->unk218 = 3; } else { @@ -379,44 +379,44 @@ void func_80BCFC0C(EnHg* this, GlobalContext* globalCtx) { return; } } - func_80BCF710(this, globalCtx); + func_80BCF710(this, play); } } } -void EnHg_Update(Actor* thisx, GlobalContext* globalCtx) { +void EnHg_Update(Actor* thisx, PlayState* play) { EnHg* this = THIS; - this->actionFunc(this, globalCtx); + this->actionFunc(this, play); SkelAnime_Update(&this->skelAnime); - func_80BCF7D8(this, globalCtx); - func_80BCFC0C(this, globalCtx); - Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 30.0f, 25.0f, 0.0f, 5); - func_80BCF778(this, globalCtx); + func_80BCF7D8(this, play); + func_80BCFC0C(this, play); + Actor_UpdateBgCheckInfo(play, &this->actor, 30.0f, 25.0f, 0.0f, 5); + func_80BCF778(this, play); } -s32 EnHg_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, Actor* thisx) { +s32 EnHg_OverrideLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, Actor* thisx) { return false; } -void EnHg_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx) { +void EnHg_PostLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx) { EnHg* this = THIS; - if (limbIndex == HG_LIMB_HEAD) { - Matrix_CopyCurrentState(&this->unk1D8); - } else if (limbIndex == HG_LIMB_PELVIS) { - Matrix_GetStateTranslation(&this->actor.focus.pos); + if (limbIndex == HARFGIBUD_GIBDO_LIMB_EYEBROWS) { + Matrix_Get(&this->unk1D8); + } else if (limbIndex == HARFGIBUD_GIBDO_LIMB_HEAD) { + Matrix_MultZero(&this->actor.focus.pos); } } -void EnHg_Draw(Actor* thisx, GlobalContext* globalCtx) { +void EnHg_Draw(Actor* thisx, PlayState* play) { EnHg* this = THIS; - OPEN_DISPS(globalCtx->state.gfxCtx); - func_8012C28C(globalCtx->state.gfxCtx); - SkelAnime_DrawFlexOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, + OPEN_DISPS(play->state.gfxCtx); + func_8012C28C(play->state.gfxCtx); + SkelAnime_DrawFlexOpa(play, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, EnHg_OverrideLimbDraw, EnHg_PostLimbDraw, &this->actor); - Matrix_SetCurrentState(&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); + Matrix_Put(&this->unk1D8); + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_OPA_DISP++, gHarfgibudGibdoEyebrowsDL); + CLOSE_DISPS(play->state.gfxCtx); } diff --git a/src/overlays/actors/ovl_En_Hg/z_en_hg.h b/src/overlays/actors/ovl_En_Hg/z_en_hg.h index 489db0afb..c81d61d49 100644 --- a/src/overlays/actors/ovl_En_Hg/z_en_hg.h +++ b/src/overlays/actors/ovl_En_Hg/z_en_hg.h @@ -2,33 +2,12 @@ #define Z_EN_HG_H #include "global.h" +#include "objects/object_harfgibud/object_harfgibud.h" + struct EnHg; -typedef void (*EnHgActionFunc)(struct EnHg*, GlobalContext*); - -typedef enum { - /* 00 */ HG_LIMB_NONE, - /* 01 */ HG_LIMB_ABDOMEN, - /* 02 */ HG_LIMB_CHEST, - /* 03 */ HG_LIMB_SHOULDER_LEFT, - /* 04 */ HG_LIMB_ARM_LEFT, - /* 05 */ HG_LIMB_HAND_LEFT, - /* 06 */ HG_LIMB_SHOULDER_RIGHT, - /* 07 */ HG_LIMB_ARM_RIGHT, - /* 08 */ HG_LIMB_HAND_RIGHT, - /* 09 */ HG_LIMB_EYEBROW, - /* 10 */ HG_LIMB_HEAD, - /* 11 */ HG_LIMB_PELVIS, - /* 12 */ HG_LIMB_THIGH_LEFT, - /* 13 */ HG_LIMB_LEG_LEFT, - /* 14 */ HG_LIMB_FOOT_LEFT, - /* 15 */ HG_LIMB_THIGH_RIGHT, - /* 16 */ HG_LIMB_LEG_RIGHT, - /* 17 */ HG_LIMB_FOOT_RIGHT, - /* 19 */ HG_LIMB_UNK, - /* 20 */ HG_LIMB_MAX, -} ObjectHgLimbs; +typedef void (*EnHgActionFunc)(struct EnHg*, PlayState*); typedef struct EnHg { /* 0x000 */ Actor actor; @@ -37,9 +16,9 @@ typedef struct EnHg { /* 0x1D4 */ EnHgActionFunc actionFunc; /* 0x1D8 */ MtxF unk1D8; /* 0x218 */ s32 unk218; - /* 0x21C */ s32 currentAnimation; - /* 0x220 */ Vec3s jointTable[HG_LIMB_MAX]; - /* 0x292 */ Vec3s morphTable[HG_LIMB_MAX]; + /* 0x21C */ s32 animIndex; + /* 0x220 */ Vec3s jointTable[HARFGIBUD_GIBDO_LIMB_MAX]; + /* 0x292 */ Vec3s morphTable[HARFGIBUD_GIBDO_LIMB_MAX]; /* 0x304 */ UNK_TYPE1 pad304[0xC]; /* 0x310 */ u16 cutscenes[4]; } EnHg; // size = 0x318 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 2aa217846..83fbe5988 100644 --- a/src/overlays/actors/ovl_En_Hgo/z_en_hgo.c +++ b/src/overlays/actors/ovl_En_Hgo/z_en_hgo.c @@ -1,32 +1,31 @@ /* * File: z_en_hgo.c * Overlay: ovl_En_Hgo - * Description: Pamela's Father (Gibdo) + * Description: Pamela's Father (Human) */ #include "z_en_hgo.h" -#include "objects/object_harfgibud/object_harfgibud.h" #define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_8 | ACTOR_FLAG_10 | ACTOR_FLAG_2000000) #define THIS ((EnHgo*)thisx) -void EnHgo_Init(Actor* thisx, GlobalContext* globalCtx); -void EnHgo_Destroy(Actor* thisx, GlobalContext* globalCtx); -void EnHgo_Update(Actor* thisx, GlobalContext* globalCtx); -void EnHgo_Draw(Actor* thisx, GlobalContext* globalCtx); +void EnHgo_Init(Actor* thisx, PlayState* play); +void EnHgo_Destroy(Actor* thisx, PlayState* play); +void EnHgo_Update(Actor* thisx, PlayState* play); +void EnHgo_Draw(Actor* thisx, PlayState* play); void func_80BD03EC(EnHgo* this); -void func_80BD0410(EnHgo* this, GlobalContext* globalCtx); -void func_80BD0434(EnHgo* this, GlobalContext* globalCtx); +void func_80BD0410(EnHgo* this, PlayState* play); +void func_80BD0434(EnHgo* this, PlayState* play); void func_80BD049C(EnHgo* this); -void func_80BD04E0(EnHgo* this, GlobalContext* globalCtx); +void func_80BD04E0(EnHgo* this, PlayState* play); void EnHgo_SetupDialogueHandler(EnHgo* this); -void EnHgo_DefaultDialogueHandler(EnHgo* this, GlobalContext* globalCtx); -void func_80BD06FC(EnHgo* this, GlobalContext* globalCtx); -s32 func_80BD0898(EnHgo* this, GlobalContext* globalCtx); -s32 EnHgo_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, Actor* thisx); -void EnHgo_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* pos, Actor* thisx); +void EnHgo_DefaultDialogueHandler(EnHgo* this, PlayState* play); +void func_80BD06FC(EnHgo* this, PlayState* play); +s32 func_80BD0898(EnHgo* this, PlayState* play); +s32 EnHgo_OverrideLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, Actor* thisx); +void EnHgo_PostLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3s* pos, Actor* thisx); const ActorInit En_Hgo_InitVars = { ACTOR_EN_HGO, @@ -40,7 +39,7 @@ const ActorInit En_Hgo_InitVars = { (ActorFunc)EnHgo_Draw, }; -static AnimationInfo sAnimations[] = { +static AnimationInfo sAnimationInfo[] = { { &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 }, @@ -78,15 +77,15 @@ static TexturePtr sEyeTextures[] = { object_harfgibud_Tex_012138, }; -void EnHgo_Init(Actor* thisx, GlobalContext* globalCtx) { +void EnHgo_Init(Actor* thisx, PlayState* play) { EnHgo* this = THIS; s32 pad; ActorShape_Init(&thisx->shape, 0.0f, ActorShadow_DrawCircle, 36.0f); - SkelAnime_InitFlex(globalCtx, &this->skelAnime, &object_harfgibud_Skel_012A58, &object_harfgibud_Anim_00B644, - this->jointTable, this->morphTable, HGO_LIMB_MAX); - Collider_InitCylinder(globalCtx, &this->collider); - Collider_SetCylinder(globalCtx, &this->collider, &this->actor, &sCylinderInit); + SkelAnime_InitFlex(play, &this->skelAnime, &gHarfgibudHumanSkel, &object_harfgibud_Anim_00B644, this->jointTable, + this->morphTable, HARFGIBUD_HUMAN_LIMB_MAX); + Collider_InitCylinder(play, &this->collider); + Collider_SetCylinder(play, &this->collider, &this->actor, &sCylinderInit); CollisionCheck_SetInfo2(&thisx->colChkInfo, NULL, &sColChkInfoInit); thisx->targetMode = 6; this->unk_30C = 0; @@ -102,10 +101,10 @@ void EnHgo_Init(Actor* thisx, GlobalContext* globalCtx) { } } -void EnHgo_Destroy(Actor* thisx, GlobalContext* globalCtx) { +void EnHgo_Destroy(Actor* thisx, PlayState* play) { EnHgo* this = THIS; - Collider_DestroyCylinder(globalCtx, &this->collider); + Collider_DestroyCylinder(play, &this->collider); } void func_80BD03EC(EnHgo* this) { @@ -113,59 +112,59 @@ void func_80BD03EC(EnHgo* this) { this->actionFunc = func_80BD0410; } -void func_80BD0410(EnHgo* this, GlobalContext* globalCtx) { +void func_80BD0410(EnHgo* this, PlayState* play) { } void func_80BD0420(EnHgo* this) { this->actionFunc = func_80BD0434; } -void func_80BD0434(EnHgo* this, GlobalContext* globalCtx) { +void func_80BD0434(EnHgo* this, PlayState* play) { this->collider.dim.pos.x = this->actor.focus.pos.x; this->collider.dim.pos.y = this->actor.world.pos.y; this->collider.dim.pos.z = this->actor.focus.pos.z; - CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + CollisionCheck_SetOC(play, &play->colChkCtx, &this->collider.base); } void func_80BD049C(EnHgo* this) { - Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 0); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, 0); this->actionFunc = func_80BD04E0; } -void func_80BD04E0(EnHgo* this, GlobalContext* globalCtx) { - if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { - if (Player_GetMask(globalCtx) == PLAYER_MASK_GIBDO) { +void func_80BD04E0(EnHgo* this, PlayState* play) { + if (Actor_ProcessTalkRequest(&this->actor, &play->state)) { + if (Player_GetMask(play) == PLAYER_MASK_GIBDO) { if (!(this->unk_310 & 4)) { this->unk_310 |= 4; - Message_StartTextbox(globalCtx, 0x15A5, &this->actor); + Message_StartTextbox(play, 0x15A5, &this->actor); this->unk_314 = 0x15A5; // That mask is a gibdo } else { - Message_StartTextbox(globalCtx, 0x15A7, &this->actor); + Message_StartTextbox(play, 0x15A7, &this->actor); this->unk_314 = 0x15A7; // can I research that mask } } else if (gSaveContext.save.playerForm == PLAYER_FORM_HUMAN) { if (!(this->unk_310 & 1)) { this->unk_310 |= 1; - Message_StartTextbox(globalCtx, 0x158F, &this->actor); + Message_StartTextbox(play, 0x158F, &this->actor); this->unk_314 = 0x158F; // Isn't this a fairy } else { - Message_StartTextbox(globalCtx, 0x1593, &this->actor); + Message_StartTextbox(play, 0x1593, &this->actor); this->unk_314 = 0x1593; // Never seen a fairy this lively } } else { if (!(this->unk_310 & 2)) { this->unk_310 |= 2; - Message_StartTextbox(globalCtx, 0x1595, &this->actor); + Message_StartTextbox(play, 0x1595, &this->actor); this->unk_314 = 0x1595; // ghost radar is reacting } else { - Message_StartTextbox(globalCtx, 0x1598, &this->actor); + Message_StartTextbox(play, 0x1598, &this->actor); this->unk_314 = 0x1598; // you seem to be similar to a ghost } } EnHgo_SetupDialogueHandler(this); } else { - func_800B8614(&this->actor, globalCtx, 100.0f); + func_800B8614(&this->actor, play, 100.0f); } } @@ -173,110 +172,114 @@ void EnHgo_SetupDialogueHandler(EnHgo* this) { this->actionFunc = EnHgo_DefaultDialogueHandler; } -void EnHgo_DefaultDialogueHandler(EnHgo* this, GlobalContext* globalCtx) { - switch (Message_GetState(&globalCtx->msgCtx)) { - case 0: - case 1: - case 2: - case 3: - case 4: +void EnHgo_DefaultDialogueHandler(EnHgo* this, PlayState* play) { + switch (Message_GetState(&play->msgCtx)) { + case TEXT_STATE_NONE: + case TEXT_STATE_1: + case TEXT_STATE_CLOSING: + case TEXT_STATE_3: + case TEXT_STATE_CHOICE: break; - case 5: - func_80BD06FC(this, globalCtx); + + case TEXT_STATE_5: + func_80BD06FC(this, play); break; - case 6: - if (Message_ShouldAdvance(globalCtx)) { + + case TEXT_STATE_DONE: + if (Message_ShouldAdvance(play)) { func_80BD049C(this); } + break; } + Math_SmoothStepToS(&this->actor.world.rot.y, this->actor.yawTowardsPlayer, 0xA, 0x71C, 0xB6); this->actor.shape.rot.y = this->actor.world.rot.y; } -void func_80BD06FC(EnHgo* this, GlobalContext* globalCtx) { - if (Message_ShouldAdvance(globalCtx)) { +void func_80BD06FC(EnHgo* this, PlayState* play) { + if (Message_ShouldAdvance(play)) { switch (this->unk_314) { case 0x158F: - Message_StartTextbox(globalCtx, 0x1590, &this->actor); + Message_StartTextbox(play, 0x1590, &this->actor); this->unk_314 = 0x1590; break; case 0x1590: if (gSaveContext.save.weekEventReg[14] & 4) { - Message_StartTextbox(globalCtx, 0x1591, &this->actor); + Message_StartTextbox(play, 0x1591, &this->actor); this->unk_314 = 0x1591; break; } - Message_StartTextbox(globalCtx, 0x1592, &this->actor); + Message_StartTextbox(play, 0x1592, &this->actor); this->unk_314 = 0x1592; break; case 0x1591: - Message_StartTextbox(globalCtx, 0x1592, &this->actor); + Message_StartTextbox(play, 0x1592, &this->actor); this->unk_314 = 0x1592; break; case 0x1593: - Message_StartTextbox(globalCtx, 0x1594, &this->actor); + Message_StartTextbox(play, 0x1594, &this->actor); this->unk_314 = 0x1594; break; case 0x1595: - Message_StartTextbox(globalCtx, 0x1596, &this->actor); + Message_StartTextbox(play, 0x1596, &this->actor); this->unk_314 = 0x1596; break; case 0x1596: - Message_StartTextbox(globalCtx, 0x1597, &this->actor); + Message_StartTextbox(play, 0x1597, &this->actor); this->unk_314 = 0x1597; break; case 0x1598: - Message_StartTextbox(globalCtx, 0x1599, &this->actor); + Message_StartTextbox(play, 0x1599, &this->actor); this->unk_314 = 0x1599; break; case 0x15A5: - Message_StartTextbox(globalCtx, 0x15A6, &this->actor); + Message_StartTextbox(play, 0x15A6, &this->actor); this->unk_314 = 0x15A6; break; case 0x15A6: - Message_StartTextbox(globalCtx, 0x15A7, &this->actor); + Message_StartTextbox(play, 0x15A7, &this->actor); this->unk_314 = 0x15A7; break; case 0x15A7: - func_801477B4(globalCtx); + func_801477B4(play); func_80BD049C(this); break; } } } -s32 func_80BD0898(EnHgo* this, GlobalContext* globalCtx) { +s32 func_80BD0898(EnHgo* this, PlayState* play) { s32 actionIndex; - 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) { + if (Cutscene_CheckActorAction(play, 486)) { + actionIndex = Cutscene_GetActorActionIndex(play, 486); + if (this->unk_316 != play->csCtx.actorActions[actionIndex]->action) { + this->unk_316 = play->csCtx.actorActions[actionIndex]->action; + switch (play->csCtx.actorActions[actionIndex]->action) { case 1: this->unk_218 = 0; - Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 0); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, 0); break; case 2: this->actor.draw = EnHgo_Draw; this->unk_218 = 1; - Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 1); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, 1); break; case 3: this->unk_218 = 2; - Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 2); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, 2); break; case 4: this->unk_218 = 3; - Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 3); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, 3); break; case 5: this->unk_218 = 4; - Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 4); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, 4); break; case 6: this->unk_218 = 5; - Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 5); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, 5); break; } } else if (Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) { @@ -285,28 +288,28 @@ 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.currentCsIndex == 2) || (globalCtx->csCtx.currentCsIndex == 4))) { + ((play->csCtx.currentCsIndex == 2) || (play->csCtx.currentCsIndex == 4))) { Actor_PlaySfxAtPos(&this->actor, NA_SE_VO_GBVO02); } } break; case 2: this->unk_218 = 3; - Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 3); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, 3); break; case 5: this->unk_218 = 6; - Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 6); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, 6); } } - Cutscene_ActorTranslateAndYaw(&this->actor, globalCtx, actionIndex); + Cutscene_ActorTranslateAndYaw(&this->actor, play, actionIndex); return true; } - if ((globalCtx->csCtx.state == 0) && (((gSaveContext.save.weekEventReg[75]) & 0x20)) && + if ((play->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, + Actor_Spawn(&play->actorCtx, play, ACTOR_ELF_MSG2, this->actor.focus.pos.x, this->actor.focus.pos.y, this->actor.focus.pos.z, 7, 0, 0, 0x7F5A); func_80BD0420(this); } @@ -314,8 +317,8 @@ s32 func_80BD0898(EnHgo* this, GlobalContext* globalCtx) { return false; } -void func_80BD0B8C(EnHgo* this, GlobalContext* globalCtx) { - func_800E9250(globalCtx, &this->actor, &this->unk_300, &this->unk_306, this->actor.focus.pos); +void func_80BD0B8C(EnHgo* this, PlayState* play) { + Actor_TrackPlayer(play, &this->actor, &this->headRot, &this->torsoRot, this->actor.focus.pos); if (this->unk_30E > 2) { this->unk_30E--; } else if (this->unk_30E == 2) { @@ -330,52 +333,52 @@ void func_80BD0B8C(EnHgo* this, GlobalContext* globalCtx) { } } -void EnHgo_Update(Actor* thisx, GlobalContext* globalCtx) { +void EnHgo_Update(Actor* thisx, PlayState* play) { EnHgo* this = THIS; s32 pad; - this->actionFunc(this, globalCtx); + this->actionFunc(this, play); SkelAnime_Update(&this->skelAnime); - if (func_80BD0898(this, globalCtx)) { - func_800E8F08(&this->unk_300, &this->unk_306); + if (func_80BD0898(this, play)) { + Actor_TrackNone(&this->headRot, &this->torsoRot); } else if (this->actionFunc != func_80BD0410) { if (this->actionFunc != func_80BD0434) { Collider_UpdateCylinder(&this->actor, &this->collider); - CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); - func_80BD0B8C(this, globalCtx); + CollisionCheck_SetOC(play, &play->colChkCtx, &this->collider.base); + func_80BD0B8C(this, play); } } } -s32 EnHgo_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, Actor* thisx) { +s32 EnHgo_OverrideLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, Actor* thisx) { EnHgo* this = THIS; - if (limbIndex == HGO_LIMB_PELVIS) { - rot->x += this->unk_300.y; - rot->z += this->unk_300.x; + if (limbIndex == HARFGIBUD_HUMAN_LIMB_HEAD) { + rot->x += this->headRot.y; + rot->z += this->headRot.x; } return false; } -void EnHgo_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* pos, Actor* thisx) { +void EnHgo_PostLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3s* pos, Actor* thisx) { EnHgo* this = THIS; - if (limbIndex == HGO_LIMB_PELVIS) { - Matrix_CopyCurrentState(&this->unk_1D8); - Matrix_GetStateTranslation(&this->actor.focus.pos); + if (limbIndex == HARFGIBUD_HUMAN_LIMB_HEAD) { + Matrix_Get(&this->unk_1D8); + Matrix_MultZero(&this->actor.focus.pos); } } -void EnHgo_Draw(Actor* thisx, GlobalContext* globalCtx) { +void EnHgo_Draw(Actor* thisx, PlayState* play) { EnHgo* this = THIS; - OPEN_DISPS(globalCtx->state.gfxCtx); - func_8012C28C(globalCtx->state.gfxCtx); + OPEN_DISPS(play->state.gfxCtx); + func_8012C28C(play->state.gfxCtx); gSPSegment(POLY_OPA_DISP++, 0x08, Lib_SegmentedToVirtual(sEyeTextures[this->unk_30C])); - SkelAnime_DrawFlexOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, + SkelAnime_DrawFlexOpa(play, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, EnHgo_OverrideLimbDraw, &EnHgo_PostLimbDraw, &this->actor); - Matrix_SetCurrentState(&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); + Matrix_Put(&this->unk_1D8); + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_OPA_DISP++, gHarfgibudHumanEyebrowsDL); + CLOSE_DISPS(play->state.gfxCtx); } diff --git a/src/overlays/actors/ovl_En_Hgo/z_en_hgo.h b/src/overlays/actors/ovl_En_Hgo/z_en_hgo.h index f39aab0fd..34e4ebdc4 100644 --- a/src/overlays/actors/ovl_En_Hgo/z_en_hgo.h +++ b/src/overlays/actors/ovl_En_Hgo/z_en_hgo.h @@ -2,34 +2,11 @@ #define Z_EN_HGO_H #include "global.h" +#include "objects/object_harfgibud/object_harfgibud.h" struct EnHgo; -typedef void (*EnHgoActionFunc)(struct EnHgo*, GlobalContext*); - -// Shares the same setup as en_hg -typedef enum { - /* 00 */ HGO_LIMB_NONE, - /* 01 */ HGO_LIMB_ABDOMEN, - /* 02 */ HGO_LIMB_CHEST, - /* 03 */ HGO_LIMB_SHOULDER_LEFT, - /* 04 */ HGO_LIMB_ARM_LEFT, - /* 05 */ HGO_LIMB_HAND_LEFT, - /* 06 */ HGO_LIMB_SHOULDER_RIGHT, - /* 07 */ HGO_LIMB_ARM_RIGHT, - /* 08 */ HGO_LIMB_HAND_RIGHT, - /* 09 */ HGO_LIMB_EYEBROW, - /* 10 */ HGO_LIMB_HEAD, - /* 11 */ HGO_LIMB_PELVIS, - /* 12 */ HGO_LIMB_THIGH_LEFT, - /* 13 */ HGO_LIMB_LEG_LEFT, - /* 14 */ HGO_LIMB_FOOT_LEFT, - /* 15 */ HGO_LIMB_THIGH_RIGHT, - /* 16 */ HGO_LIMB_LEG_RIGHT, - /* 17 */ HGO_LIMB_FOOT_RIGHT, - /* 18 */ HGO_LIMB_UNK, - /* 19 */ HGO_LIMB_MAX, -} ObjectHgoLimbs; +typedef void (*EnHgoActionFunc)(struct EnHgo*, PlayState*); typedef struct EnHgo { /* 0x000 */ Actor actor; @@ -38,10 +15,10 @@ typedef struct EnHgo { /* 0x1D4 */ EnHgoActionFunc actionFunc; /* 0x1D8 */ MtxF unk_1D8; /* 0x218 */ s32 unk_218; - /* 0x21C */ Vec3s jointTable[HGO_LIMB_MAX]; - /* 0x28E */ Vec3s morphTable[HGO_LIMB_MAX]; - /* 0x300 */ Vec3s unk_300; - /* 0x306 */ Vec3s unk_306; + /* 0x21C */ Vec3s jointTable[HARFGIBUD_HUMAN_LIMB_MAX]; + /* 0x28E */ Vec3s morphTable[HARFGIBUD_HUMAN_LIMB_MAX]; + /* 0x300 */ Vec3s headRot; + /* 0x306 */ Vec3s torsoRot; // Set, but not used /* 0x30C */ s16 unk_30C; /* 0x30E */ s16 unk_30E; /* 0x310 */ s16 unk_310; 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 e1432c10a..50f0c1e1e 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,30 +5,31 @@ */ #include "z_en_hidden_nuts.h" +#include "overlays/effects/ovl_Effect_Ss_Hahen/z_eff_ss_hahen.h" #include "objects/object_hintnuts/object_hintnuts.h" #define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_8 | ACTOR_FLAG_2000000) #define THIS ((EnHiddenNuts*)thisx) -void EnHiddenNuts_Init(Actor* thisx, GlobalContext* globalCtx); -void EnHiddenNuts_Destroy(Actor* thisx, GlobalContext* globalCtx); -void EnHiddenNuts_Update(Actor* thisx, GlobalContext* globalCtx); -void EnHiddenNuts_Draw(Actor* thisx, GlobalContext* globalCtx); +void EnHiddenNuts_Init(Actor* thisx, PlayState* play); +void EnHiddenNuts_Destroy(Actor* thisx, PlayState* play); +void EnHiddenNuts_Update(Actor* thisx, PlayState* play); +void EnHiddenNuts_Draw(Actor* thisx, PlayState* play); void func_80BDB268(EnHiddenNuts* this); -void func_80BDB2B8(EnHiddenNuts* this, GlobalContext* globalCtx); +void func_80BDB2B8(EnHiddenNuts* this, PlayState* play); void func_80BDB580(EnHiddenNuts* this); -void func_80BDB59C(EnHiddenNuts* this, GlobalContext* globalCtx); +void func_80BDB59C(EnHiddenNuts* this, PlayState* play); void func_80BDB788(EnHiddenNuts* this); -void func_80BDB7E8(EnHiddenNuts* this, GlobalContext* globalCtx); -void func_80BDB8F4(EnHiddenNuts* this, GlobalContext* globalCtx); +void func_80BDB7E8(EnHiddenNuts* this, PlayState* play); +void func_80BDB8F4(EnHiddenNuts* this, PlayState* play); 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); +void func_80BDB978(EnHiddenNuts* this, PlayState* play); +void func_80BDBA28(EnHiddenNuts* this, PlayState* play); +void func_80BDBB48(EnHiddenNuts* this, PlayState* play); +void func_80BDBE70(EnHiddenNuts* this, PlayState* play); +void func_80BDBED4(EnHiddenNuts* this, PlayState* play); const ActorInit En_Hidden_Nuts_InitVars = { ACTOR_EN_HIDDEN_NUTS, @@ -73,18 +74,18 @@ u8 D_80BDC120[] = { ANIMMODE_LOOP, ANIMMODE_LOOP, ANIMMODE_ONCE, ANIMMODE_ONCE, ANIMMODE_LOOP, }; -void EnHiddenNuts_Init(Actor* thisx, GlobalContext* globalCtx) { +void EnHiddenNuts_Init(Actor* thisx, PlayState* play) { EnHiddenNuts* this = THIS; 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, + SkelAnime_Init(play, &this->skelAnime, &object_hintnuts_Skel_0023B8.sh, &object_hintnuts_Anim_0024CC, this->jointTable, this->morphTable, 10); Actor_SetScale(&this->actor, 0.01f); this->actor.colChkInfo.mass = MASS_IMMOVABLE; this->actor.targetMode = 0; - Collider_InitAndSetCylinder(globalCtx, &this->collider, &this->actor, &sCylinderInit); + Collider_InitAndSetCylinder(play, &this->collider, &this->actor, &sCylinderInit); this->unk_21E = ENHIDDENNUTS_GET_F80(&this->actor); this->switchFlag = ENHIDDENNUTS_GET_SWITCHFLAG(&this->actor); @@ -93,7 +94,7 @@ void EnHiddenNuts_Init(Actor* thisx, GlobalContext* globalCtx) { this->switchFlag = -1; } - if ((this->switchFlag >= 0) && Flags_GetSwitch(globalCtx, this->switchFlag)) { + if ((this->switchFlag >= 0) && Flags_GetSwitch(play, this->switchFlag)) { Actor_MarkForDeath(&this->actor); return; } @@ -103,16 +104,16 @@ void EnHiddenNuts_Init(Actor* thisx, GlobalContext* globalCtx) { return; } - this->path = SubS_GetPathByIndex(globalCtx, this->unk_21E, 0x3F); + this->path = SubS_GetPathByIndex(play, this->unk_21E, 0x3F); this->unk_226 = this->actor.cutscene; func_801A5080(2); func_80BDB268(this); } -void EnHiddenNuts_Destroy(Actor* thisx, GlobalContext* globalCtx) { +void EnHiddenNuts_Destroy(Actor* thisx, PlayState* play) { EnHiddenNuts* this = THIS; - Collider_DestroyCylinder(globalCtx, &this->collider); + Collider_DestroyCylinder(play, &this->collider); } void func_80BDB1B4(EnHiddenNuts* this, s32 arg1) { @@ -140,8 +141,8 @@ void func_80BDB268(EnHiddenNuts* this) { this->actionFunc = func_80BDB2B8; } -void func_80BDB2B8(EnHiddenNuts* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); +void func_80BDB2B8(EnHiddenNuts* this, PlayState* play) { + Player* player = GET_PLAYER(play); s32 i; Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_NEMURI_SLEEP - SFX_FLAG); @@ -155,7 +156,7 @@ void func_80BDB2B8(EnHiddenNuts* this, GlobalContext* globalCtx) { this->unk_20A = 0; } - if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state) != 0) { + if (Actor_ProcessTalkRequest(&this->actor, &play->state) != 0) { func_80BDB580(this); return; } @@ -175,20 +176,19 @@ void func_80BDB2B8(EnHiddenNuts* this, GlobalContext* globalCtx) { sp74.x += randPlusMinusPoint5Scaled(15.0f); sp74.z += randPlusMinusPoint5Scaled(15.0f); - EffectSsDtBubble_SpawnCustomColor(globalCtx, &sp74, &sp94, &sp88, &sp84, &sp80, Rand_S16Offset(120, 90), 30, - 1); + EffectSsDtBubble_SpawnCustomColor(play, &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; + if ((play->msgCtx.ocarinaMode == 3) && (play->msgCtx.lastPlayedSong == OCARINA_SONG_SONATA)) { + play->msgCtx.ocarinaMode = 4; func_80BDB788(this); } else if (func_801A5100() == 2) { func_80BDB788(this); } else { - func_800B8614(&this->actor, globalCtx, BREG(13) + 100.0f); + func_800B8614(&this->actor, play, BREG(13) + 100.0f); } } } @@ -198,7 +198,7 @@ void func_80BDB580(EnHiddenNuts* this) { this->actionFunc = func_80BDB59C; } -void func_80BDB59C(EnHiddenNuts* this, GlobalContext* globalCtx) { +void func_80BDB59C(EnHiddenNuts* this, PlayState* play) { s32 i; Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_NEMURI_SLEEP - SFX_FLAG); @@ -218,14 +218,13 @@ void func_80BDB59C(EnHiddenNuts* this, GlobalContext* globalCtx) { sp78.x += randPlusMinusPoint5Scaled(15.0f); sp78.z += randPlusMinusPoint5Scaled(15.0f); - EffectSsDtBubble_SpawnCustomColor(globalCtx, &sp78, &sp98, &sp8C, &sp88, &sp84, Rand_S16Offset(120, 90), 30, - 1); + EffectSsDtBubble_SpawnCustomColor(play, &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); + if ((Message_GetState(&play->msgCtx) == TEXT_STATE_5) && Message_ShouldAdvance(play)) { + func_801477B4(play); func_80BDB268(this); } } @@ -239,7 +238,7 @@ void func_80BDB788(EnHiddenNuts* this) { this->actionFunc = func_80BDB7E8; } -void func_80BDB7E8(EnHiddenNuts* this, GlobalContext* globalCtx) { +void func_80BDB7E8(EnHiddenNuts* this, PlayState* play) { Vec3f sp3C; if (ActorCutscene_GetCurrentIndex() == 0x7C) { @@ -259,14 +258,14 @@ void func_80BDB7E8(EnHiddenNuts* this, GlobalContext* globalCtx) { 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); + EffectSsHahen_SpawnBurst(play, &sp3C, 4.0f, 0, 10, 3, 15, HAHEN_OBJECT_DEFAULT, 10, NULL); Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_NUTS_UP); func_80BDB1B4(this, 7); this->actionFunc = func_80BDB8F4; } -void func_80BDB8F4(EnHiddenNuts* this, GlobalContext* globalCtx) { +void func_80BDB8F4(EnHiddenNuts* this, PlayState* play) { f32 curFrame = this->skelAnime.curFrame; if (this->unk_22C <= curFrame) { @@ -281,7 +280,7 @@ void func_80BDB930(EnHiddenNuts* this) { this->actionFunc = func_80BDB978; } -void func_80BDB978(EnHiddenNuts* this, GlobalContext* globalCtx) { +void func_80BDB978(EnHiddenNuts* this, PlayState* play) { f32 curFrame = this->skelAnime.curFrame; if (Animation_OnFrame(&this->skelAnime, 0.0f) || Animation_OnFrame(&this->skelAnime, 8.0f) || @@ -292,12 +291,12 @@ void func_80BDB978(EnHiddenNuts* this, GlobalContext* globalCtx) { if (this->unk_22C <= curFrame) { this->unk_224++; if (this->unk_224 >= 2) { - func_80BDBA28(this, globalCtx); + func_80BDBA28(this, play); } } } -void func_80BDBA28(EnHiddenNuts* this, GlobalContext* globalCtx) { +void func_80BDBA28(EnHiddenNuts* this, PlayState* play) { Vec3f sp44; func_80BDB1B4(this, 2); @@ -306,7 +305,7 @@ void func_80BDBA28(EnHiddenNuts* this, GlobalContext* globalCtx) { 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); + EffectSsHahen_SpawnBurst(play, &sp44, 4.0f, 0, 10, 3, 15, HAHEN_OBJECT_DEFAULT, 10, NULL); Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_NUTS_UP); this->unk_208 = 1; @@ -323,7 +322,7 @@ void func_80BDBA28(EnHiddenNuts* this, GlobalContext* globalCtx) { this->actionFunc = func_80BDBB48; } -void func_80BDBB48(EnHiddenNuts* this, GlobalContext* globalCtx) { +void func_80BDBB48(EnHiddenNuts* this, PlayState* play) { s32 pad[3]; f32 sp58 = this->skelAnime.curFrame; WaterBox* sp54; @@ -331,16 +330,15 @@ void func_80BDBB48(EnHiddenNuts* this, GlobalContext* globalCtx) { s16 sp4E = 0; Vec3f sp40; - if (WaterBox_GetSurface1(globalCtx, &globalCtx->colCtx, this->actor.world.pos.x, this->actor.world.pos.z, &sp50, - &sp54) && + if (WaterBox_GetSurface1(play, &play->colCtx, this->actor.world.pos.x, this->actor.world.pos.z, &sp50, &sp54) && (this->actor.world.pos.y < sp50)) { this->actor.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 ((play->gameplayFrames % 8) == 0) { + EffectSsGRipple_Spawn(play, &sp40, 650, 3150, 0); } if (Animation_OnFrame(&this->skelAnime, 0.0f) || Animation_OnFrame(&this->skelAnime, 5.0f) || @@ -375,7 +373,7 @@ void func_80BDBB48(EnHiddenNuts* this, GlobalContext* globalCtx) { (this->path != NULL)) { this->unk_208++; if (this->unk_208 >= this->path->count) { - func_80BDBE70(this, globalCtx); + func_80BDBE70(this, play); } else if ((this->path != NULL) && !SubS_CopyPointFromPath(this->path, this->unk_208, &this->unk_20C)) { Actor_MarkForDeath(&this->actor); } @@ -383,16 +381,16 @@ void func_80BDBB48(EnHiddenNuts* this, GlobalContext* globalCtx) { } } -void func_80BDBE70(EnHiddenNuts* this, GlobalContext* globalCtx) { +void func_80BDBE70(EnHiddenNuts* this, PlayState* play) { if (this->switchFlag >= 0) { - Flags_SetSwitch(globalCtx, this->switchFlag); + Flags_SetSwitch(play, this->switchFlag); } func_80BDB1B4(this, 8); this->unk_21A = 5; this->actionFunc = func_80BDBED4; } -void func_80BDBED4(EnHiddenNuts* this, GlobalContext* globalCtx) { +void func_80BDBED4(EnHiddenNuts* this, PlayState* play) { f32 curFrame = this->skelAnime.curFrame; Vec3f sp38; @@ -401,12 +399,12 @@ void func_80BDBED4(EnHiddenNuts* this, GlobalContext* globalCtx) { 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); + EffectSsHahen_SpawnBurst(play, &sp38, 4.0f, 0, 10, 3, 15, HAHEN_OBJECT_DEFAULT, 10, NULL); Actor_MarkForDeath(&this->actor); } } -void EnHiddenNuts_Update(Actor* thisx, GlobalContext* globalCtx) { +void EnHiddenNuts_Update(Actor* thisx, PlayState* play) { s32 pad; EnHiddenNuts* this = THIS; @@ -417,22 +415,22 @@ void EnHiddenNuts_Update(Actor* thisx, GlobalContext* globalCtx) { Actor_SetFocus(&this->actor, 20.0f); SkelAnime_Update(&this->skelAnime); - this->actionFunc(this, globalCtx); + this->actionFunc(this, play); 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); + Actor_UpdateBgCheckInfo(play, &this->actor, 20.0f, 20.0f, 40.0f, 0x1D); } Collider_UpdateCylinder(&this->actor, &this->collider); - CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + CollisionCheck_SetOC(play, &play->colChkCtx, &this->collider.base); } -void EnHiddenNuts_Draw(Actor* thisx, GlobalContext* globalCtx) { +void EnHiddenNuts_Draw(Actor* thisx, PlayState* play) { EnHiddenNuts* this = THIS; - func_8012C28C(globalCtx->state.gfxCtx); - SkelAnime_DrawOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, NULL, NULL, &this->actor); + func_8012C28C(play->state.gfxCtx); + SkelAnime_DrawOpa(play, 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 baff911b6..a8edd1d75 100644 --- a/src/overlays/actors/ovl_En_Hidden_Nuts/z_en_hidden_nuts.h +++ b/src/overlays/actors/ovl_En_Hidden_Nuts/z_en_hidden_nuts.h @@ -5,32 +5,32 @@ struct EnHiddenNuts; -typedef void (*EnHiddenNutsActionFunc)(struct EnHiddenNuts*, GlobalContext*); +typedef void (*EnHiddenNutsActionFunc)(struct EnHiddenNuts*, PlayState*); #define ENHIDDENNUTS_GET_SWITCHFLAG(thisx) ((thisx)->params & 0x7F) #define ENHIDDENNUTS_GET_F80(thisx) (((thisx)->params >> 7) & 0x1F) typedef struct EnHiddenNuts { - /* 0x0000 */ Actor actor; - /* 0x0144 */ SkelAnime skelAnime; - /* 0x0188 */ Vec3s jointTable[10]; - /* 0x01C4 */ Vec3s morphTable[10]; - /* 0x0200 */ EnHiddenNutsActionFunc actionFunc; - /* 0x0204 */ Path* path; - /* 0x0208 */ s16 unk_208; - /* 0x020A */ u8 unk_20A; - /* 0x020C */ Vec3f unk_20C; - /* 0x0218 */ s16 unk_218; - /* 0x021A */ s16 unk_21A; - /* 0x021C */ s16 switchFlag; - /* 0x021E */ s16 unk_21E; - /* 0x0220 */ s32 unk_220; - /* 0x0224 */ s16 unk_224; - /* 0x0226 */ s16 unk_226; - /* 0x0228 */ f32 unk_228; - /* 0x022C */ f32 unk_22C; - /* 0x0230 */ UNK_TYPE1 unk230[4]; - /* 0x0234 */ ColliderCylinder collider; + /* 0x000 */ Actor actor; + /* 0x144 */ SkelAnime skelAnime; + /* 0x188 */ Vec3s jointTable[10]; + /* 0x1C4 */ Vec3s morphTable[10]; + /* 0x200 */ EnHiddenNutsActionFunc actionFunc; + /* 0x204 */ Path* path; + /* 0x208 */ s16 unk_208; + /* 0x20A */ u8 unk_20A; + /* 0x20C */ Vec3f unk_20C; + /* 0x218 */ s16 unk_218; + /* 0x21A */ s16 unk_21A; + /* 0x21C */ s16 switchFlag; + /* 0x21E */ s16 unk_21E; + /* 0x220 */ s32 unk_220; + /* 0x224 */ s16 unk_224; + /* 0x226 */ s16 unk_226; + /* 0x228 */ f32 unk_228; + /* 0x22C */ f32 unk_22C; + /* 0x230 */ UNK_TYPE1 unk230[4]; + /* 0x234 */ ColliderCylinder collider; } EnHiddenNuts; // size = 0x280 extern const ActorInit En_Hidden_Nuts_InitVars; diff --git a/src/overlays/actors/ovl_En_Hint_Skb/z_en_hint_skb.c b/src/overlays/actors/ovl_En_Hint_Skb/z_en_hint_skb.c index 51a408e6e..3664fcede 100644 --- a/src/overlays/actors/ovl_En_Hint_Skb/z_en_hint_skb.c +++ b/src/overlays/actors/ovl_En_Hint_Skb/z_en_hint_skb.c @@ -5,38 +5,39 @@ */ #include "z_en_hint_skb.h" +#include "overlays/effects/ovl_Effect_Ss_Hahen/z_eff_ss_hahen.h" #include "objects/object_skb/object_skb.h" #define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_8 | ACTOR_FLAG_10) #define THIS ((EnHintSkb*)thisx) -void EnHintSkb_Init(Actor* thisx, GlobalContext* globalCtx); -void EnHintSkb_Destroy(Actor* thisx, GlobalContext* globalCtx); -void EnHintSkb_Update(Actor* thisx, GlobalContext* globalCtx); -void EnHintSkb_Draw(Actor* thisx, GlobalContext* globalCtx); +void EnHintSkb_Init(Actor* thisx, PlayState* play); +void EnHintSkb_Destroy(Actor* thisx, PlayState* play); +void EnHintSkb_Update(Actor* thisx, PlayState* play); +void EnHintSkb_Draw(Actor* thisx, PlayState* play); void func_80C1FE0C(EnHintSkb* this); -void func_80C1FE20(EnHintSkb* this, GlobalContext* globalCtx); -void func_80C1FE80(EnHintSkb* this, GlobalContext* globalCtx); +void func_80C1FE20(EnHintSkb* this, PlayState* play); +void func_80C1FE80(EnHintSkb* this, PlayState* play); void func_80C1FF30(EnHintSkb* this); -void func_80C1FF88(EnHintSkb* this, GlobalContext* globalCtx); +void func_80C1FF88(EnHintSkb* this, PlayState* play); void func_80C2003C(EnHintSkb* this); -void func_80C200B8(EnHintSkb* this, GlobalContext* globalCtx); -void func_80C2016C(EnHintSkb* this, GlobalContext* globalCtx); -void func_80C20334(EnHintSkb* this, GlobalContext* globalCtx); +void func_80C200B8(EnHintSkb* this, PlayState* play); +void func_80C2016C(EnHintSkb* this, PlayState* play); +void func_80C20334(EnHintSkb* this, PlayState* play); void func_80C20484(EnHintSkb* this); -void func_80C204F0(EnHintSkb* this, GlobalContext* globalCtx); -void func_80C20590(EnHintSkb* this, GlobalContext* globalCtx); -void func_80C2069C(EnHintSkb* this, GlobalContext* globalCtx); -void func_80C2077C(EnHintSkb* this, GlobalContext* globalCtx); +void func_80C204F0(EnHintSkb* this, PlayState* play); +void func_80C20590(EnHintSkb* this, PlayState* play); +void func_80C2069C(EnHintSkb* this, PlayState* play); +void func_80C2077C(EnHintSkb* this, PlayState* play); void func_80C208BC(EnHintSkb* this); -void func_80C208D0(EnHintSkb* this, GlobalContext* globalCtx); -void func_80C20B88(EnHintSkb* this, GlobalContext* globalCtx); -void func_80C20C24(EnHintSkb* this, GlobalContext* globalCtx); +void func_80C208D0(EnHintSkb* this, PlayState* play); +void func_80C20B88(EnHintSkb* this, PlayState* play); +void func_80C20C24(EnHintSkb* this, PlayState* play); s32 func_80C21414(EnHintSkb* this); -void func_80C21468(EnHintSkb* this, GlobalContext* globalCtx); -void func_80C215E4(GlobalContext* globalCtx, EnHintSkb* this, Vec3f* arg2); +void func_80C21468(EnHintSkb* this, PlayState* play); +void func_80C215E4(PlayState* play, EnHintSkb* this, Vec3f* arg2); const ActorInit En_Hint_Skb_InitVars = { ACTOR_EN_HINT_SKB, @@ -84,7 +85,7 @@ static ColliderJntSphInit sJntSphInit = { OC2_TYPE_1, COLSHAPE_JNTSPH, }, - 2, + ARRAY_COUNT(sJntSphElementsInit), sJntSphElementsInit, }; @@ -125,7 +126,7 @@ static DamageTable sDamageTable = { /* Powder Keg */ DMG_ENTRY(1, 0xF), }; -static AnimationInfo sAnimations[] = { +static AnimationInfo sAnimationInfo[] = { { &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 }, @@ -146,15 +147,15 @@ static InitChainEntry sInitChain[] = { ICHAIN_F32_DIV1000(gravity, -2000, ICHAIN_STOP), }; -void EnHintSkb_Init(Actor* thisx, GlobalContext* globalCtx) { +void EnHintSkb_Init(Actor* thisx, PlayState* play) { s32 pad; EnHintSkb* this = THIS; ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 36.0f); - SkelAnime_Init(globalCtx, &this->skelAnime, &object_skb_Skel_005EF8, &object_skb_Anim_00697C, this->jointTable, + SkelAnime_Init(play, &this->skelAnime, &object_skb_Skel_005EF8, &object_skb_Anim_00697C, this->jointTable, this->morphtable, 20); - Collider_InitJntSph(globalCtx, &this->collider); - Collider_SetJntSph(globalCtx, &this->collider, &this->actor, &sJntSphInit, this->colliderElement); + Collider_InitJntSph(play, &this->collider); + Collider_SetJntSph(play, &this->collider, &this->actor, &sJntSphInit, this->colliderElement); CollisionCheck_SetInfo2(&this->actor.colChkInfo, &sDamageTable, &sColChkInfoInit); Actor_ProcessInitChain(&this->actor, sInitChain); this->actor.hintId = 0x55; @@ -166,26 +167,26 @@ void EnHintSkb_Init(Actor* thisx, GlobalContext* globalCtx) { func_80C1FE0C(this); } -void EnHintSkb_Destroy(Actor* thisx, GlobalContext* globalCtx) { +void EnHintSkb_Destroy(Actor* thisx, PlayState* play) { EnHintSkb* this = THIS; - Collider_DestroyJntSph(globalCtx, &this->collider); + Collider_DestroyJntSph(play, &this->collider); } void func_80C1FE0C(EnHintSkb* this) { this->actionFunc = func_80C1FE20; } -void func_80C1FE20(EnHintSkb* this, GlobalContext* globalCtx) { +void func_80C1FE20(EnHintSkb* this, PlayState* play) { } void func_80C1FE30(EnHintSkb* this) { - Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 0); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, 0); this->actor.speedXZ = 1.6f; this->actionFunc = func_80C1FE80; } -void func_80C1FE80(EnHintSkb* this, GlobalContext* globalCtx) { +void func_80C1FE80(EnHintSkb* this, PlayState* play) { if (Animation_OnFrame(&this->skelAnime, 8.0f) || Animation_OnFrame(&this->skelAnime, 15.0f)) { Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_STALKID_WALK); } @@ -199,11 +200,11 @@ void func_80C1FE80(EnHintSkb* this, GlobalContext* globalCtx) { void func_80C1FF30(EnHintSkb* this) { this->collider.base.atFlags &= ~AT_BOUNCED; this->actor.speedXZ = 0.0f; - Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 2); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, 2); this->actionFunc = func_80C1FF88; } -void func_80C1FF88(EnHintSkb* this, GlobalContext* globalCtx) { +void func_80C1FF88(EnHintSkb* this, PlayState* play) { if (this->collider.base.atFlags & AT_BOUNCED) { this->collider.base.atFlags &= ~(AT_BOUNCED | AT_HIT); func_80C2003C(this); @@ -214,7 +215,7 @@ void func_80C1FF88(EnHintSkb* this, GlobalContext* globalCtx) { } if (Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) { - if (func_80C21414(this) && (Player_GetMask(globalCtx) != PLAYER_MASK_CAPTAIN)) { + if (func_80C21414(this) && (Player_GetMask(play) != PLAYER_MASK_CAPTAIN)) { func_80C1FF30(this); } else { func_80C1FE30(this); @@ -223,12 +224,13 @@ void func_80C1FF88(EnHintSkb* this, GlobalContext* globalCtx) { } void func_80C2003C(EnHintSkb* this) { - Animation_Change(&this->skelAnime, &object_skb_Anim_002190, -0.4f, this->skelAnime.curFrame - 1.0f, 0.0f, 3, 0.0f); + Animation_Change(&this->skelAnime, &object_skb_Anim_002190, -0.4f, this->skelAnime.curFrame - 1.0f, 0.0f, + ANIMMODE_ONCE_INTERP, 0.0f); this->collider.base.atFlags &= ~AT_BOUNCED; this->actionFunc = func_80C200B8; } -void func_80C200B8(EnHintSkb* this, GlobalContext* globalCtx) { +void func_80C200B8(EnHintSkb* this, PlayState* play) { if (Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) { if (func_80C21414(this)) { func_80C1FF30(this); @@ -246,7 +248,7 @@ void func_80C2011C(EnHintSkb* this) { this->actionFunc = func_80C2016C; } -void func_80C2016C(EnHintSkb* this, GlobalContext* globalCtx) { +void func_80C2016C(EnHintSkb* this, PlayState* play) { if (this->actor.bgCheckFlags & 2) { this->actor.speedXZ = 0.0f; } else if (this->actor.bgCheckFlags & 1) { @@ -257,7 +259,7 @@ void func_80C2016C(EnHintSkb* this, GlobalContext* globalCtx) { if ((this->actor.colorFilterTimer == 0) && (this->actor.bgCheckFlags & 1)) { if (this->actor.colChkInfo.health == 0) { - SoundSource_PlaySfxAtFixedWorldPos(globalCtx, &this->actor.world.pos, 40, NA_SE_EN_STALKID_DEAD); + SoundSource_PlaySfxAtFixedWorldPos(play, &this->actor.world.pos, 40, NA_SE_EN_STALKID_DEAD); func_80C20484(this); } else if (this->skelAnime.animation == &object_skb_Anim_00697C) { func_80C1FE0C(this); @@ -272,12 +274,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_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 8); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, 8); this->actor.gravity = -1.0f; this->actor.speedXZ = 1.0f; } else { this->actor.world.rot.y = this->actor.yawTowardsPlayer; - Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 3); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, 3); if (this->actor.bgCheckFlags & 1) { this->actor.speedXZ = -4.0f; } @@ -286,12 +288,12 @@ void func_80C20274(EnHintSkb* this) { this->actionFunc = func_80C20334; } -void func_80C20334(EnHintSkb* this, GlobalContext* globalCtx) { +void func_80C20334(EnHintSkb* this, PlayState* play) { if (this->actor.bgCheckFlags & 2) { s32 i; for (i = 0; i < 10; i++) { - func_80C215E4(globalCtx, this, &this->actor.world.pos); + func_80C215E4(play, this, &this->actor.world.pos); } this->actor.speedXZ = 0.0f; } @@ -314,7 +316,7 @@ void func_80C20334(EnHintSkb* this, GlobalContext* globalCtx) { } void func_80C20484(EnHintSkb* this) { - Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 4); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, 4); this->unk_3E8 |= 4; if (this->actor.bgCheckFlags & 1) { this->actor.speedXZ = -6.0f; @@ -322,12 +324,12 @@ void func_80C20484(EnHintSkb* this) { this->actionFunc = func_80C204F0; } -void func_80C204F0(EnHintSkb* this, GlobalContext* globalCtx) { +void func_80C204F0(EnHintSkb* this, PlayState* play) { if (!(this->unk_3E8 & 8)) { return; } - Item_DropCollectibleRandom(globalCtx, &this->actor, &this->actor.world.pos, 0x10); + Item_DropCollectibleRandom(play, &this->actor, &this->actor.world.pos, 0x10); Actor_MarkForDeath(&this->actor); } @@ -339,23 +341,23 @@ void func_80C20540(EnHintSkb* this) { this->actionFunc = func_80C20590; } -void func_80C20590(EnHintSkb* this, GlobalContext* globalCtx) { +void func_80C20590(EnHintSkb* this, PlayState* play) { 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_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 3); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, 3); Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_STALKID_DAMAGE); this->unk_3E8 |= 1; func_80C20274(this); } else { - SoundSource_PlaySfxAtFixedWorldPos(globalCtx, &this->actor.world.pos, 40, NA_SE_EN_STALKID_DEAD); + SoundSource_PlaySfxAtFixedWorldPos(play, &this->actor.world.pos, 40, NA_SE_EN_STALKID_DEAD); func_80C20484(this); } } else if (this->drawDmgEffTimer == 1) { - func_80C21468(this, globalCtx); + func_80C21468(this, play); } } @@ -366,19 +368,19 @@ void func_80C2066C(EnHintSkb* this) { this->actionFunc = func_80C2069C; } -void func_80C2069C(EnHintSkb* this, GlobalContext* globalCtx) { +void func_80C2069C(EnHintSkb* this, PlayState* play) { 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_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 3); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, 3); Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_STALKID_DAMAGE); this->unk_3E8 |= 1; func_80C20274(this); } else { - SoundSource_PlaySfxAtFixedWorldPos(globalCtx, &this->actor.world.pos, 40, NA_SE_EN_STALKID_DEAD); + SoundSource_PlaySfxAtFixedWorldPos(play, &this->actor.world.pos, 40, NA_SE_EN_STALKID_DEAD); func_80C20484(this); } } @@ -390,28 +392,28 @@ void func_80C2075C(EnHintSkb* this) { this->actionFunc = func_80C2077C; } -void func_80C2077C(EnHintSkb* this, GlobalContext* globalCtx) { - if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { +void func_80C2077C(EnHintSkb* this, PlayState* play) { + if (Actor_ProcessTalkRequest(&this->actor, &play->state)) { this->unk_3E0 = 1; if (this->unk_3DC == 0) { this->unk_3DC = 1; - Message_StartTextbox(globalCtx, 0x1147, &this->actor); + Message_StartTextbox(play, 0x1147, &this->actor); this->unk_3E6 = 0x1147; if (this->skelAnime.animation == &object_skb_Anim_00697C) { - globalCtx->msgCtx.msgMode = 0x44; + play->msgCtx.msgMode = 0x44; this->actor.speedXZ = 2.4f; this->actor.gravity = -1.0f; this->actor.velocity.y = 3.0f; - Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 8); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, 8); } } else { - Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 11); - Message_StartTextbox(globalCtx, 0x1148, &this->actor); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, 11); + Message_StartTextbox(play, 0x1148, &this->actor); this->unk_3E6 = 0x1148; } func_80C208BC(this); } else if ((this->actor.xzDistToPlayer < 100.0f) && !(this->collider.base.acFlags & AC_HIT)) { - func_800B8614(&this->actor, globalCtx, 100.0f); + func_800B8614(&this->actor, play, 100.0f); } } @@ -419,33 +421,33 @@ void func_80C208BC(EnHintSkb* this) { this->actionFunc = func_80C208D0; } -void func_80C208D0(EnHintSkb* this, GlobalContext* globalCtx) { +void func_80C208D0(EnHintSkb* this, PlayState* play) { this->unk_3DE = 0; - switch (Message_GetState(&globalCtx->msgCtx)) { - case 3: - if ((globalCtx->gameplayFrames % 2) != 0) { + switch (Message_GetState(&play->msgCtx)) { + case TEXT_STATE_3: + if ((play->gameplayFrames % 2) != 0) { this->unk_3DE = 1; } break; - case 4: - func_80C20B88(this, globalCtx); + case TEXT_STATE_CHOICE: + func_80C20B88(this, play); break; - case 5: - func_80C20C24(this, globalCtx); + case TEXT_STATE_5: + func_80C20C24(this, play); break; - case 6: - if (Message_ShouldAdvance(globalCtx)) { + case TEXT_STATE_DONE: + if (Message_ShouldAdvance(play)) { func_80C2075C(this); } break; - case 0: - case 1: - case 2: + case TEXT_STATE_NONE: + case TEXT_STATE_1: + case TEXT_STATE_CLOSING: break; } @@ -456,15 +458,15 @@ void func_80C208D0(EnHintSkb* this, GlobalContext* globalCtx) { this->actor.speedXZ = 0.0f; for (i = 0; i < 10; i++) { - func_80C215E4(globalCtx, this, &this->actor.world.pos); + func_80C215E4(play, this, &this->actor.world.pos); } } if ((this->skelAnime.animation == &object_skb_Anim_003584) && Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) { - Message_StartTextbox(globalCtx, 0x1147, &this->actor); + Message_StartTextbox(play, 0x1147, &this->actor); this->unk_3E6 = 0x1147; - Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 0); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, 0); } } @@ -474,76 +476,76 @@ void func_80C208D0(EnHintSkb* this, GlobalContext* globalCtx) { } } -void func_80C20A74(EnHintSkb* this, GlobalContext* globalCtx) { +void func_80C20A74(EnHintSkb* this, PlayState* play) { s32 params = ENHINTSKB_GET_FF(&this->actor); switch (params) { case 1: - Message_StartTextbox(globalCtx, 0x1149, &this->actor); + Message_StartTextbox(play, 0x1149, &this->actor); this->unk_3E6 = 0x1149; break; case 2: - Message_StartTextbox(globalCtx, 0x114A, &this->actor); + Message_StartTextbox(play, 0x114A, &this->actor); this->unk_3E6 = 0x114A; break; case 3: - Message_StartTextbox(globalCtx, 0x114B, &this->actor); + Message_StartTextbox(play, 0x114B, &this->actor); this->unk_3E6 = 0x114B; break; case 4: - Message_StartTextbox(globalCtx, 0x114C, &this->actor); + Message_StartTextbox(play, 0x114C, &this->actor); this->unk_3E6 = 0x114C; break; case 5: - Message_StartTextbox(globalCtx, 0x114D, &this->actor); + Message_StartTextbox(play, 0x114D, &this->actor); this->unk_3E6 = 0x114D; break; case 6: - Message_StartTextbox(globalCtx, 0x114E, &this->actor); + Message_StartTextbox(play, 0x114E, &this->actor); this->unk_3E6 = 0x114E; break; default: - Message_StartTextbox(globalCtx, 0x1149, &this->actor); + Message_StartTextbox(play, 0x1149, &this->actor); this->unk_3E6 = 0x1149; break; } } -void func_80C20B88(EnHintSkb* this, GlobalContext* globalCtx) { - if (Message_ShouldAdvance(globalCtx)) { - if (globalCtx->msgCtx.choiceIndex == 0) { +void func_80C20B88(EnHintSkb* this, PlayState* play) { + if (Message_ShouldAdvance(play)) { + if (play->msgCtx.choiceIndex == 0) { func_8019F208(); this->unk_3E8 |= 0x10; - Message_StartTextbox(globalCtx, 0x1150, &this->actor); + Message_StartTextbox(play, 0x1150, &this->actor); this->unk_3E6 = 0x1150; } else { func_8019F230(); - Message_StartTextbox(globalCtx, 0x1152, &this->actor); + Message_StartTextbox(play, 0x1152, &this->actor); this->unk_3E6 = 0x1152; } } } -void func_80C20C24(EnHintSkb* this, GlobalContext* globalCtx) { - if (!Message_ShouldAdvance(globalCtx)) { +void func_80C20C24(EnHintSkb* this, PlayState* play) { + if (!Message_ShouldAdvance(play)) { return; } switch (this->unk_3E6) { case 0x1147: - Message_StartTextbox(globalCtx, 0x1148, &this->actor); + Message_StartTextbox(play, 0x1148, &this->actor); this->unk_3E6 = 0x1148; - Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 11); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, 11); break; case 0x1148: - func_80C20A74(this, globalCtx); + func_80C20A74(this, play); break; case 0x1149: @@ -552,24 +554,24 @@ void func_80C20C24(EnHintSkb* this, GlobalContext* globalCtx) { case 0x114C: case 0x114D: case 0x114E: - Message_StartTextbox(globalCtx, 0x114F, &this->actor); + Message_StartTextbox(play, 0x114F, &this->actor); this->unk_3E6 = 0x114F; break; case 0x1152: - Message_StartTextbox(globalCtx, 0x1151, &this->actor); + Message_StartTextbox(play, 0x1151, &this->actor); this->unk_3E6 = 0x1151; break; case 0x1150: - Message_StartTextbox(globalCtx, 0x1151, &this->actor); + Message_StartTextbox(play, 0x1151, &this->actor); this->unk_3E6 = 0x1151; break; case 0x1151: - func_801477B4(globalCtx); + func_801477B4(play); if (this->unk_3E8 & 0x10) { - SoundSource_PlaySfxAtFixedWorldPos(globalCtx, &this->actor.world.pos, 40, NA_SE_EN_STALKID_DEAD); + SoundSource_PlaySfxAtFixedWorldPos(play, &this->actor.world.pos, 40, NA_SE_EN_STALKID_DEAD); func_80C20484(this); } else { func_80C2075C(this); @@ -578,21 +580,21 @@ void func_80C20C24(EnHintSkb* this, GlobalContext* globalCtx) { } } -void func_80C20D64(EnHintSkb* this, GlobalContext* globalCtx) { +void func_80C20D64(EnHintSkb* this, PlayState* play) { if ((this->actionFunc == func_80C1FE20) || (this->actionFunc == func_80C2077C) || (this->actionFunc == func_80C1FE80)) { if (this->actionFunc != func_80C2077C) { - if (Player_GetMask(globalCtx) == PLAYER_MASK_CAPTAIN) { + if (Player_GetMask(play) == PLAYER_MASK_CAPTAIN) { this->actor.flags &= ~(ACTOR_FLAG_1 | ACTOR_FLAG_4); this->actor.flags |= (ACTOR_FLAG_1 | ACTOR_FLAG_8); this->actor.hintId = 255; this->actor.textId = 0; if (this->actionFunc == func_80C1FE80) { - Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 12); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, 12); } func_80C2075C(this); } - } else if (Player_GetMask(globalCtx) != PLAYER_MASK_CAPTAIN) { + } else if (Player_GetMask(play) != PLAYER_MASK_CAPTAIN) { this->actor.flags &= ~(ACTOR_FLAG_1 | ACTOR_FLAG_8); this->actor.flags |= (ACTOR_FLAG_1 | ACTOR_FLAG_4); this->actor.hintId = 0x55; @@ -606,12 +608,12 @@ void func_80C20D64(EnHintSkb* this, GlobalContext* globalCtx) { } } -void func_80C20E90(EnHintSkb* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); +void func_80C20E90(EnHintSkb* this, PlayState* play) { + Player* player = GET_PLAYER(play); if ((this->actor.bgCheckFlags & 0x60) && (this->actor.depthInWater >= 40.0f)) { this->actor.colChkInfo.health = 0; - SoundSource_PlaySfxAtFixedWorldPos(globalCtx, &this->actor.world.pos, 40, NA_SE_EN_STALKID_DEAD); + SoundSource_PlaySfxAtFixedWorldPos(play, &this->actor.world.pos, 40, NA_SE_EN_STALKID_DEAD); func_80C20484(this); return; } @@ -637,7 +639,7 @@ void func_80C20E90(EnHintSkb* this, GlobalContext* globalCtx) { case 10: case 11: if (this->drawDmgEffTimer > 1) { - func_80C21468(this, globalCtx); + func_80C21468(this, play); } this->drawDmgEffTimer = 0; break; @@ -646,7 +648,7 @@ void func_80C20E90(EnHintSkb* this, GlobalContext* globalCtx) { if (!Actor_ApplyDamage(&this->actor)) { if ((this->actor.colChkInfo.damageEffect != 3) && (this->actor.colChkInfo.damageEffect != 4)) { - SoundSource_PlaySfxAtFixedWorldPos(globalCtx, &this->actor.world.pos, 40, NA_SE_EN_STALKID_DEAD); + SoundSource_PlaySfxAtFixedWorldPos(play, &this->actor.world.pos, 40, NA_SE_EN_STALKID_DEAD); this->unk_3E8 |= 4; func_80C20484(this); return; @@ -698,7 +700,7 @@ void func_80C20E90(EnHintSkb* this, GlobalContext* globalCtx) { this->drawDmgEffScale = 0.5f; Actor_SetColorFilter(&this->actor, 0x4000, 255, 0, 8); Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_STALKID_DAMAGE); - Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 3); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, 3); func_80C2066C(this); break; @@ -707,15 +709,17 @@ void func_80C20E90(EnHintSkb* this, GlobalContext* globalCtx) { this->unk_3E8 |= 1; case 15: - if ((player->swordAnimation == 4) || (player->swordAnimation == 11) || (player->swordAnimation == 22) || - (player->swordAnimation == 23)) { + if ((player->meleeWeaponAnimation == PLAYER_MWA_RIGHT_SLASH_1H) || + (player->meleeWeaponAnimation == PLAYER_MWA_LEFT_COMBO_2H) || + (player->meleeWeaponAnimation == PLAYER_MWA_BACKSLASH_RIGHT) || + (player->meleeWeaponAnimation == PLAYER_MWA_BACKSLASH_LEFT)) { this->unk_3E8 |= 1; } case 13: Actor_SetColorFilter(&this->actor, 0x4000, 255, 0, 8); Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_STALKID_DAMAGE); - Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 3); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, 3); func_80C20274(this); break; @@ -730,23 +734,23 @@ void func_80C20E90(EnHintSkb* this, GlobalContext* globalCtx) { } } -void func_80C21250(EnHintSkb* this, GlobalContext* globalCtx) { +void func_80C21250(EnHintSkb* this, PlayState* play) { if (this->unk_3E0 != 1) { - func_80C20E90(this, globalCtx); + func_80C20E90(this, play); if (this->actionFunc == func_80C1FF88) { - CollisionCheck_SetAT(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + CollisionCheck_SetAT(play, &play->colChkCtx, &this->collider.base); } if ((this->actionFunc != func_80C200B8) && (this->actionFunc != func_80C20334) && (this->actionFunc != func_80C204F0)) { - CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + CollisionCheck_SetAC(play, &play->colChkCtx, &this->collider.base); } - CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + CollisionCheck_SetOC(play, &play->colChkCtx, &this->collider.base); } } -void func_80C21320(EnHintSkb* this, GlobalContext* globalCtx) { +void func_80C21320(EnHintSkb* this, PlayState* play) { if (this->drawDmgEffTimer > 0) { this->drawDmgEffTimer--; } @@ -772,7 +776,7 @@ s32 func_80C21414(EnHintSkb* this) { return false; } -void func_80C21468(EnHintSkb* this, GlobalContext* globalCtx) { +void func_80C21468(EnHintSkb* this, PlayState* play) { static Color_RGBA8 D_80C21E44 = { 170, 255, 255, 255 }; static Color_RGBA8 D_80C21E48 = { 200, 200, 255, 255 }; static Vec3f D_80C21E4C = { 0.0f, -1.0f, 0.0f }; @@ -787,7 +791,7 @@ void func_80C21468(EnHintSkb* this, GlobalContext* globalCtx) { phi_s4 = ARRAY_COUNT(this->limbPos); } - SoundSource_PlaySfxAtFixedWorldPos(globalCtx, &this->actor.world.pos, 30, NA_SE_EV_ICE_BROKEN); + SoundSource_PlaySfxAtFixedWorldPos(play, &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->limbPos[i]); @@ -796,11 +800,11 @@ void func_80C21468(EnHintSkb* this, GlobalContext* globalCtx) { sp84.z = Math_CosS(temp_s1) * 3.0f; sp84.y = (Rand_ZeroOne() * 4.0f) + 4.0f; - EffectSsEnIce_Spawn(globalCtx, &this->limbPos[i], 0.6f, &sp84, &D_80C21E4C, &D_80C21E44, &D_80C21E48, 30); + EffectSsEnIce_Spawn(play, &this->limbPos[i], 0.6f, &sp84, &D_80C21E4C, &D_80C21E44, &D_80C21E48, 30); } } -void func_80C215E4(GlobalContext* globalCtx, EnHintSkb* this, Vec3f* arg2) { +void func_80C215E4(PlayState* play, EnHintSkb* this, Vec3f* arg2) { Vec3f sp5C; Vec3f sp50 = { 0.0f, 8.0f, 0.0f }; Vec3f sp44 = { 0.0f, -1.5f, 0.0f }; @@ -816,14 +820,15 @@ void func_80C215E4(GlobalContext* globalCtx, EnHintSkb* this, Vec3f* arg2) { sp50.y += (Rand_ZeroOne() - 0.5f) * 4.0f; - EffectSsHahen_Spawn(globalCtx, &sp5C, &sp50, &sp44, 0, ((Rand_ZeroOne() * 5.0f) + 12.0f) * 0.8f, -1, 10, NULL); - func_800BBFB0(globalCtx, &sp5C, 10.0f, 1, 150, 0, 1); + EffectSsHahen_Spawn(play, &sp5C, &sp50, &sp44, 0, ((Rand_ZeroOne() * 5.0f) + 12.0f) * 0.8f, HAHEN_OBJECT_DEFAULT, + 10, NULL); + func_800BBFB0(play, &sp5C, 10.0f, 1, 150, 0, 1); } -void EnHintSkb_Update(Actor* thisx, GlobalContext* globalCtx) { +void EnHintSkb_Update(Actor* thisx, PlayState* play) { EnHintSkb* this = THIS; - this->actionFunc(this, globalCtx); + this->actionFunc(this, play); if ((this->actionFunc != func_80C2016C) && (this->actionFunc != func_80C20590) && (this->actionFunc != func_80C2069C)) { @@ -831,30 +836,29 @@ void EnHintSkb_Update(Actor* thisx, GlobalContext* globalCtx) { } Actor_MoveWithGravity(&this->actor); - Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 15.0f, 30.0f, 60.0f, 0x1D); - func_80C21250(this, globalCtx); - func_80C20D64(this, globalCtx); - func_80C21320(this, globalCtx); + Actor_UpdateBgCheckInfo(play, &this->actor, 15.0f, 30.0f, 60.0f, 0x1D); + func_80C21250(this, play); + func_80C20D64(this, play); + func_80C21320(this, play); } -s32 EnHintSkb_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, - Actor* thisx) { +s32 EnHintSkb_OverrideLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, Actor* thisx) { EnHintSkb* this = THIS; f32 temp_f10; if (limbIndex == 11) { - OPEN_DISPS(globalCtx->state.gfxCtx); + OPEN_DISPS(play->state.gfxCtx); - temp_f10 = fabsf(Math_SinS(globalCtx->state.frames * 6000) * 95.0f) + 160.0f; + temp_f10 = fabsf(Math_SinS(play->state.frames * 6000) * 95.0f) + 160.0f; gDPPipeSync(POLY_OPA_DISP++); gDPSetEnvColor(POLY_OPA_DISP++, (s16)temp_f10, (s16)temp_f10, (s16)temp_f10, 255); - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->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)) { @@ -864,7 +868,7 @@ s32 EnHintSkb_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dL return false; } -void EnHintSkb_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx) { +void EnHintSkb_PostLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx) { static Vec3f D_80C21E70 = { 800.0f, 1200.0f, 0.0f }; EnHintSkb* this = THIS; @@ -872,36 +876,36 @@ void EnHintSkb_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList Collider_UpdateSpheres(limbIndex, &this->collider); if ((limbIndex == 11) && (this->unk_3E8 & 1) && !(this->unk_3E8 & 2)) { - Actor_SpawnBodyParts(&this->actor, globalCtx, 1, dList); + Actor_SpawnBodyParts(&this->actor, play, 1, dList); this->unk_3E8 |= 2; } else if ((this->unk_3E8 & 4) && !(this->unk_3E8 & 8) && ((limbIndex != 11) || !(this->unk_3E8 & 1)) && (limbIndex != 12)) { - Actor_SpawnBodyParts(&this->actor, globalCtx, 1, dList); + Actor_SpawnBodyParts(&this->actor, play, 1, dList); } 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->limbPos[this->limbCount]); + Matrix_MultZero(&this->limbPos[this->limbCount]); this->limbCount++; } else if ((limbIndex == 11) && !(this->unk_3E8 & 2)) { - Matrix_MultiplyVector3fByState(&D_80C21E70, &this->limbPos[this->limbCount]); + Matrix_MultVec3f(&D_80C21E70, &this->limbPos[this->limbCount]); this->limbCount++; } } } } -void EnHintSkb_Draw(Actor* thisx, GlobalContext* globalCtx) { +void EnHintSkb_Draw(Actor* thisx, PlayState* play) { EnHintSkb* this = THIS; this->limbCount = 0; - func_8012C28C(globalCtx->state.gfxCtx); - SkelAnime_DrawOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, EnHintSkb_OverrideLimbDraw, + func_8012C28C(play->state.gfxCtx); + SkelAnime_DrawOpa(play, this->skelAnime.skeleton, this->skelAnime.jointTable, EnHintSkb_OverrideLimbDraw, EnHintSkb_PostLimbDraw, &this->actor); if (this->drawDmgEffTimer > 0) { - Actor_DrawDamageEffects(globalCtx, &this->actor, this->limbPos, this->limbCount, this->drawDmgEffScale, 0.5f, + Actor_DrawDamageEffects(play, &this->actor, this->limbPos, this->limbCount, this->drawDmgEffScale, 0.5f, this->drawDmgEffAlpha, this->drawDmgEffType); } 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 b67e56352..44fd8c4ef 100644 --- a/src/overlays/actors/ovl_En_Hint_Skb/z_en_hint_skb.h +++ b/src/overlays/actors/ovl_En_Hint_Skb/z_en_hint_skb.h @@ -5,31 +5,31 @@ struct EnHintSkb; -typedef void (*EnHintSkbActionFunc)(struct EnHintSkb*, GlobalContext*); +typedef void (*EnHintSkbActionFunc)(struct EnHintSkb*, PlayState*); #define ENHINTSKB_GET_FF(thisx) ((thisx)->params & 0xFF) typedef struct EnHintSkb { - /* 0x0000 */ Actor actor; - /* 0x0144 */ ColliderJntSph collider; - /* 0x0164 */ ColliderJntSphElement colliderElement[2]; - /* 0x01E4 */ SkelAnime skelAnime; - /* 0x0228 */ EnHintSkbActionFunc actionFunc; - /* 0x022C */ Vec3f limbPos[14]; - /* 0x02D4 */ f32 drawDmgEffAlpha; - /* 0x02D8 */ f32 drawDmgEffScale; - /* 0x02DC */ s32 limbCount; - /* 0x02E0 */ Vec3s jointTable[20]; - /* 0x0358 */ Vec3s morphtable[20]; - /* 0x03D0 */ UNK_TYPE1 unk3D0[0xC]; - /* 0x03DC */ s16 unk_3DC; - /* 0x03DE */ s16 unk_3DE; - /* 0x03E0 */ s16 unk_3E0; - /* 0x03E2 */ s16 drawDmgEffTimer; - /* 0x03E4 */ s16 unk_3E4; - /* 0x03E6 */ u16 unk_3E6; - /* 0x03E8 */ u8 unk_3E8; - /* 0x03E9 */ u8 drawDmgEffType; + /* 0x000 */ Actor actor; + /* 0x144 */ ColliderJntSph collider; + /* 0x164 */ ColliderJntSphElement colliderElement[2]; + /* 0x1E4 */ SkelAnime skelAnime; + /* 0x228 */ EnHintSkbActionFunc actionFunc; + /* 0x22C */ Vec3f limbPos[14]; + /* 0x2D4 */ f32 drawDmgEffAlpha; + /* 0x2D8 */ f32 drawDmgEffScale; + /* 0x2DC */ s32 limbCount; + /* 0x2E0 */ Vec3s jointTable[20]; + /* 0x358 */ Vec3s morphtable[20]; + /* 0x3D0 */ UNK_TYPE1 unk3D0[0xC]; + /* 0x3DC */ s16 unk_3DC; + /* 0x3DE */ s16 unk_3DE; + /* 0x3E0 */ s16 unk_3E0; + /* 0x3E2 */ s16 drawDmgEffTimer; + /* 0x3E4 */ s16 unk_3E4; + /* 0x3E6 */ u16 unk_3E6; + /* 0x3E8 */ u8 unk_3E8; + /* 0x3E9 */ u8 drawDmgEffType; } EnHintSkb; // size = 0x3EC extern const ActorInit En_Hint_Skb_InitVars; diff --git a/src/overlays/actors/ovl_En_Hit_Tag/z_en_hit_tag.c b/src/overlays/actors/ovl_En_Hit_Tag/z_en_hit_tag.c index 78cfa14a0..17dfeb34e 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 @@ -10,11 +10,11 @@ #define THIS ((EnHitTag*)thisx) -void EnHitTag_Init(Actor* thisx, GlobalContext* globalCtx); -void EnHitTag_Destroy(Actor* thisx, GlobalContext* globalCtx); -void EnHitTag_Update(Actor* thisx, GlobalContext* globalCtx); +void EnHitTag_Init(Actor* thisx, PlayState* play); +void EnHitTag_Destroy(Actor* thisx, PlayState* play); +void EnHitTag_Update(Actor* thisx, PlayState* play); -void EnHitTag_WaitForHit(EnHitTag* this, GlobalContext* globalCtx); +void EnHitTag_WaitForHit(EnHitTag* this, PlayState* play); const ActorInit En_Hit_Tag_InitVars = { ACTOR_EN_HIT_TAG, @@ -48,26 +48,26 @@ static ColliderCylinderInit sCylinderInit = { { 16, 32, 0, { 0, 0, 0 } }, }; -void EnHitTag_Init(Actor* thisx, GlobalContext* globalCtx) { +void EnHitTag_Init(Actor* thisx, PlayState* play) { s32 pad; EnHitTag* this = THIS; Actor_SetScale(&this->actor, 1.0f); this->actionFunc = EnHitTag_WaitForHit; - Collider_InitAndSetCylinder(globalCtx, &this->collider, &this->actor, &sCylinderInit); + Collider_InitAndSetCylinder(play, &this->collider, &this->actor, &sCylinderInit); Collider_UpdateCylinder(&this->actor, &this->collider); - if (Flags_GetSwitch(globalCtx, ENHITTAG_GET_SWITCHFLAG(thisx))) { + if (Flags_GetSwitch(play, ENHITTAG_GET_SWITCHFLAG(thisx))) { Actor_MarkForDeath(&this->actor); } } -void EnHitTag_Destroy(Actor* thisx, GlobalContext* globalCtx) { +void EnHitTag_Destroy(Actor* thisx, PlayState* play) { EnHitTag* this = THIS; - Collider_DestroyCylinder(globalCtx, &this->collider); + Collider_DestroyCylinder(play, &this->collider); } -void EnHitTag_WaitForHit(EnHitTag* this, GlobalContext* globalCtx) { +void EnHitTag_WaitForHit(EnHitTag* this, PlayState* play) { Vec3f dropLocation; s32 i; @@ -79,14 +79,14 @@ void EnHitTag_WaitForHit(EnHitTag* this, GlobalContext* globalCtx) { dropLocation.z = this->actor.world.pos.z; for (i = 0; i < 3; i++) { - Item_DropCollectible(globalCtx, &dropLocation, ITEM00_RUPEE_GREEN); + Item_DropCollectible(play, &dropLocation, ITEM00_RUPEE_GREEN); } } else { - CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + CollisionCheck_SetAC(play, &play->colChkCtx, &this->collider.base); } } -void EnHitTag_Update(Actor* thisx, GlobalContext* globalCtx) { +void EnHitTag_Update(Actor* thisx, PlayState* play) { EnHitTag* this = THIS; - this->actionFunc(this, globalCtx); + this->actionFunc(this, play); } diff --git a/src/overlays/actors/ovl_En_Hit_Tag/z_en_hit_tag.h b/src/overlays/actors/ovl_En_Hit_Tag/z_en_hit_tag.h index 2117cb27d..0a1383e0a 100644 --- a/src/overlays/actors/ovl_En_Hit_Tag/z_en_hit_tag.h +++ b/src/overlays/actors/ovl_En_Hit_Tag/z_en_hit_tag.h @@ -5,14 +5,14 @@ struct EnHitTag; -typedef void (*EnHitTagActionFunc)(struct EnHitTag*, GlobalContext*); +typedef void (*EnHitTagActionFunc)(struct EnHitTag*, PlayState*); -#define ENHITTAG_GET_SWITCHFLAG(thisx) (s32)(((thisx)->params & 0xFE00) >> 9) +#define ENHITTAG_GET_SWITCHFLAG(thisx) (((thisx)->params & 0xFE00) >> 9) typedef struct EnHitTag { - /* 0x0000 */ Actor actor; - /* 0x0144 */ ColliderCylinder collider; - /* 0x0190 */ EnHitTagActionFunc actionFunc; + /* 0x000 */ Actor actor; + /* 0x144 */ ColliderCylinder collider; + /* 0x190 */ EnHitTagActionFunc actionFunc; } EnHitTag; // size = 0x194 extern const ActorInit En_Hit_Tag_InitVars; diff --git a/src/overlays/actors/ovl_En_Holl/z_en_holl.c b/src/overlays/actors/ovl_En_Holl/z_en_holl.c index 8d5816c16..3579f23cc 100644 --- a/src/overlays/actors/ovl_En_Holl/z_en_holl.c +++ b/src/overlays/actors/ovl_En_Holl/z_en_holl.c @@ -43,19 +43,19 @@ #define THIS ((EnHoll*)thisx) -void EnHoll_Init(Actor* thisx, GlobalContext* globalCtx); -void EnHoll_Destroy(Actor* thisx, GlobalContext* globalCtx); -void EnHoll_Update(Actor* thisx, GlobalContext* globalCtx); -void EnHoll_Draw(Actor* thisx, GlobalContext* globalCtx); +void EnHoll_Init(Actor* thisx, PlayState* play); +void EnHoll_Destroy(Actor* thisx, PlayState* play); +void EnHoll_Update(Actor* thisx, PlayState* play); +void EnHoll_Draw(Actor* thisx, PlayState* play); void EnHoll_SetupAction(EnHoll* this); -void EnHoll_SetPlayerSide(GlobalContext* globalCtx, EnHoll* this, Vec3f* transformedPlayerPos); -void EnHoll_ChangeRooms(GlobalContext* globalCtx); -void EnHoll_VisibleIdle(EnHoll* this, GlobalContext* globalCtx); -void EnHoll_VerticalIdle(EnHoll* this, GlobalContext* globalCtx); -void EnHoll_TransparentIdle(EnHoll* this, GlobalContext* globalCtx); -void EnHoll_VerticalBgCoverIdle(EnHoll* this, GlobalContext* globalCtx); -void EnHoll_RoomTransitionIdle(EnHoll* this, GlobalContext* globalCtx); +void EnHoll_SetPlayerSide(PlayState* play, EnHoll* this, Vec3f* transformedPlayerPos); +void EnHoll_ChangeRooms(PlayState* play); +void EnHoll_VisibleIdle(EnHoll* this, PlayState* play); +void EnHoll_VerticalIdle(EnHoll* this, PlayState* play); +void EnHoll_TransparentIdle(EnHoll* this, PlayState* play); +void EnHoll_VerticalBgCoverIdle(EnHoll* this, PlayState* play); +void EnHoll_RoomTransitionIdle(EnHoll* this, PlayState* play); const ActorInit En_Holl_InitVars = { ACTOR_EN_HOLL, @@ -96,7 +96,7 @@ static f32 sTranslucencyPlaneDistance = 100.0f; static f32 sTransparencyPlaneDistance = 50.0f; void EnHoll_SetupAction(EnHoll* this) { - this->type = EN_HOLL_GET_TYPE(this); + this->type = EN_HOLL_GET_TYPE(&this->actor); this->actionFunc = sActionFuncs[this->type]; if (EN_HOLL_IS_VISIBLE(this)) { this->alpha = 255; @@ -105,14 +105,14 @@ void EnHoll_SetupAction(EnHoll* this) { } } -void EnHoll_SetPlayerSide(GlobalContext* globalCtx, EnHoll* this, Vec3f* transformedPlayerPos) { - Player* player = GET_PLAYER(globalCtx); +void EnHoll_SetPlayerSide(PlayState* play, EnHoll* this, Vec3f* transformedPlayerPos) { + Player* player = GET_PLAYER(play); Actor_OffsetOfPointInActorCoords(&this->actor, transformedPlayerPos, &player->actor.world.pos); this->playerSide = (transformedPlayerPos->z < 0.0f) ? EN_HOLL_BEHIND : EN_HOLL_BEFORE; } -void EnHoll_Init(Actor* thisx, GlobalContext* globalCtx) { +void EnHoll_Init(Actor* thisx, PlayState* play) { EnHoll* this = THIS; s32 pad; Vec3f transformedPlayerPos; @@ -121,38 +121,38 @@ void EnHoll_Init(Actor* thisx, GlobalContext* globalCtx) { EnHoll_SetupAction(this); this->bgCoverAlphaActive = false; this->alpha = 255; - EnHoll_SetPlayerSide(globalCtx, this, &transformedPlayerPos); + EnHoll_SetPlayerSide(play, this, &transformedPlayerPos); } -void EnHoll_Destroy(Actor* thisx, GlobalContext* globalCtx) { +void EnHoll_Destroy(Actor* thisx, PlayState* play) { EnHoll* this = THIS; if (!EN_HOLL_IS_SCENE_CHANGER(this)) { - u32 enHollId = EN_HOLL_GET_ID_CAST(this); + u32 enHollId = EN_HOLL_GET_ID(&this->actor); - globalCtx->doorCtx.transitionActorList[enHollId].id = -globalCtx->doorCtx.transitionActorList[enHollId].id; + play->doorCtx.transitionActorList[enHollId].id = -play->doorCtx.transitionActorList[enHollId].id; if (this == sInstancePlayingSound) { sInstancePlayingSound = NULL; } } } -void EnHoll_ChangeRooms(GlobalContext* globalCtx) { - Room tempRoom = globalCtx->roomCtx.currRoom; +void EnHoll_ChangeRooms(PlayState* play) { + Room tempRoom = play->roomCtx.currRoom; - globalCtx->roomCtx.currRoom = globalCtx->roomCtx.prevRoom; - globalCtx->roomCtx.prevRoom = tempRoom; - globalCtx->roomCtx.activeMemPage ^= 1; + play->roomCtx.currRoom = play->roomCtx.prevRoom; + play->roomCtx.prevRoom = tempRoom; + play->roomCtx.activeMemPage ^= 1; } -void EnHoll_VisibleIdle(EnHoll* this, GlobalContext* globalCtx) { +void EnHoll_VisibleIdle(EnHoll* this, PlayState* play) { s32 pad; Vec3f transformedPlayerPos; f32 playerDistFromCentralPlane; if (this->type == EN_HOLL_TYPE_DEFAULT) { - u32 actorCtxBitmask = (globalCtx->actorCtx.unkC & 0x2AA) >> 1 | (globalCtx->actorCtx.unkC & 0x155); - u32 zActorBitmask = D_801AED48[EN_HOLL_GET_Z_ACTOR_BITMASK_INDEX(this)]; + u32 actorCtxBitmask = (play->actorCtx.unkC & 0x2AA) >> 1 | (play->actorCtx.unkC & 0x155); + u32 zActorBitmask = D_801AED48[EN_HOLL_GET_Z_ACTOR_BITMASK_INDEX(&this->actor)]; if (!(actorCtxBitmask & zActorBitmask)) { Actor_MarkForDeath(&this->actor); @@ -162,41 +162,41 @@ void EnHoll_VisibleIdle(EnHoll* this, GlobalContext* globalCtx) { func_800B9010(&this->actor, NA_SE_EV_INVISIBLE_MONKEY - SFX_FLAG); } } - if ((globalCtx->sceneLoadFlag != 0) || (globalCtx->unk_18B4A != 0)) { + if ((play->transitionTrigger != TRANS_TRIGGER_OFF) || (play->transitionMode != TRANS_MODE_OFF)) { this->alpha = 255; } else { f32 enHollBottom = EN_HOLL_BOTTOM_DEFAULT; f32 enHollHalfwidth = EN_HOLL_HALFWIDTH_DEFAULT; - EnHoll_SetPlayerSide(globalCtx, this, &transformedPlayerPos); + EnHoll_SetPlayerSide(play, this, &transformedPlayerPos); playerDistFromCentralPlane = fabsf(transformedPlayerPos.z); - if (globalCtx->sceneNum == SCENE_IKANA) { + if (play->sceneNum == SCENE_IKANA) { enHollBottom = EN_HOLL_BOTTOM_IKANA; enHollHalfwidth = EN_HOLL_HALFWIDTH_IKANA; } if ((enHollBottom < transformedPlayerPos.y) && (transformedPlayerPos.y < EN_HOLL_TOP_DEFAULT) && (fabsf(transformedPlayerPos.x) < enHollHalfwidth) && (playerDistFromCentralPlane < sActivationPlaneDistance)) { - u32 enHollId = EN_HOLL_GET_ID_AND(this); + u32 enHollId = EN_HOLL_GET_ID(&this->actor); if (sLoadingPlaneDistance < playerDistFromCentralPlane) { - if ((globalCtx->roomCtx.prevRoom.num >= 0) && (globalCtx->roomCtx.unk31 == 0)) { - this->actor.room = globalCtx->doorCtx.transitionActorList[enHollId].sides[this->playerSide].room; - if (globalCtx->roomCtx.prevRoom.num == this->actor.room) { - EnHoll_ChangeRooms(globalCtx); + if ((play->roomCtx.prevRoom.num >= 0) && (play->roomCtx.unk31 == 0)) { + this->actor.room = play->doorCtx.transitionActorList[enHollId].sides[this->playerSide].room; + if (play->roomCtx.prevRoom.num == this->actor.room) { + EnHoll_ChangeRooms(play); } - func_8012EBF8(globalCtx, &globalCtx->roomCtx); + func_8012EBF8(play, &play->roomCtx); } } else if (this->type == EN_HOLL_TYPE_SCENE_CHANGER) { - globalCtx->nextEntranceIndex = globalCtx->setupExitList[EN_HOLL_GET_EXIT_LIST_INDEX(this)]; + play->nextEntrance = play->setupExitList[EN_HOLL_GET_EXIT_LIST_INDEX(&this->actor)]; gSaveContext.unk_3DBB = 1; - Scene_SetExitFade(globalCtx); - globalCtx->sceneLoadFlag = 0x14; - globalCtx->unk_1878C(globalCtx); + Scene_SetExitFade(play); + play->transitionTrigger = TRANS_TRIGGER_START; + play->unk_1878C(play); } else { - this->actor.room = globalCtx->doorCtx.transitionActorList[enHollId].sides[this->playerSide ^ 1].room; - if (globalCtx->roomCtx.prevRoom.num < 0) { - Room_StartRoomTransition(globalCtx, &globalCtx->roomCtx, this->actor.room); + this->actor.room = play->doorCtx.transitionActorList[enHollId].sides[this->playerSide ^ 1].room; + if (play->roomCtx.prevRoom.num < 0) { + Room_StartRoomTransition(play, &play->roomCtx, this->actor.room); if (this == sInstancePlayingSound) { sInstancePlayingSound = NULL; } @@ -204,123 +204,124 @@ void EnHoll_VisibleIdle(EnHoll* this, GlobalContext* globalCtx) { s32 unclampedAlpha = EN_HOLL_SCALE_ALPHA(playerDistFromCentralPlane); this->alpha = CLAMP(unclampedAlpha, 0, 255); - if (globalCtx->roomCtx.currRoom.num != this->actor.room) { - EnHoll_ChangeRooms(globalCtx); + if (play->roomCtx.currRoom.num != this->actor.room) { + EnHoll_ChangeRooms(play); } } } - } else if ((this->type == EN_HOLL_TYPE_DEFAULT) && (globalCtx->sceneNum == SCENE_26SARUNOMORI) && + } else if ((this->type == EN_HOLL_TYPE_DEFAULT) && (play->sceneNum == SCENE_26SARUNOMORI) && (sInstancePlayingSound == NULL)) { sInstancePlayingSound = this; } } } -void EnHoll_TransparentIdle(EnHoll* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); - s32 useViewEye = D_801D0D50 || globalCtx->csCtx.state != 0; +void EnHoll_TransparentIdle(EnHoll* this, PlayState* play) { + Player* player = GET_PLAYER(play); + s32 useViewEye = gDbgCamEnabled || play->csCtx.state != 0; Vec3f transformedPlayerPos; f32 enHollTop; f32 playerDistFromCentralPlane; Actor_OffsetOfPointInActorCoords(&this->actor, &transformedPlayerPos, - useViewEye ? &globalCtx->view.eye : &player->actor.world.pos); - enHollTop = (globalCtx->sceneNum == SCENE_PIRATE) ? EN_HOLL_TOP_PIRATE : EN_HOLL_TOP_DEFAULT; + useViewEye ? &play->view.eye : &player->actor.world.pos); + enHollTop = (play->sceneNum == SCENE_PIRATE) ? EN_HOLL_TOP_PIRATE : EN_HOLL_TOP_DEFAULT; if ((transformedPlayerPos.y > EN_HOLL_BOTTOM_DEFAULT) && (transformedPlayerPos.y < enHollTop) && (fabsf(transformedPlayerPos.x) < EN_HOLL_HALFWIDTH_TRANSPARENT)) { if (playerDistFromCentralPlane = fabsf(transformedPlayerPos.z), playerDistFromCentralPlane < EN_HOLL_ACTIVATION_PLANE_DISTANCE && playerDistFromCentralPlane > EN_HOLL_LOADING_PLANE_DISTANCE) { - s32 enHollId = EN_HOLL_GET_ID_CAST(this); + s32 enHollId = EN_HOLL_GET_ID(&this->actor); s32 playerSide = (transformedPlayerPos.z < 0.0f) ? EN_HOLL_BEHIND : EN_HOLL_BEFORE; - TransitionActorEntry* transitionActorEntry = &globalCtx->doorCtx.transitionActorList[enHollId]; + TransitionActorEntry* transitionActorEntry = &play->doorCtx.transitionActorList[enHollId]; s8 room = transitionActorEntry->sides[playerSide].room; this->actor.room = room; - if ((this->actor.room != globalCtx->roomCtx.currRoom.num) && - Room_StartRoomTransition(globalCtx, &globalCtx->roomCtx, this->actor.room)) { + if ((this->actor.room != play->roomCtx.currRoom.num) && + Room_StartRoomTransition(play, &play->roomCtx, this->actor.room)) { this->actionFunc = EnHoll_RoomTransitionIdle; } } } } -void EnHoll_VerticalBgCoverIdle(EnHoll* this, GlobalContext* globalCtx) { +void EnHoll_VerticalBgCoverIdle(EnHoll* this, PlayState* play) { f32 playerDistFromCentralPlane; if ((this->actor.xzDistToPlayer < EN_HOLL_RADIUS) && (playerDistFromCentralPlane = fabsf(this->actor.playerHeightRel), playerDistFromCentralPlane < EN_HOLL_ACTIVATION_PLANE_DISTANCE_VERTICAL)) { if (playerDistFromCentralPlane < EN_HOLL_LOADING_PLANE_DISTANCE_VERTICAL) { - globalCtx->bgCoverAlpha = 255; + play->bgCoverAlpha = 255; } else { - globalCtx->bgCoverAlpha = EN_HOLL_SCALE_BG_COVER_ALPHA(playerDistFromCentralPlane); + play->bgCoverAlpha = EN_HOLL_SCALE_BG_COVER_ALPHA(playerDistFromCentralPlane); } if (playerDistFromCentralPlane > EN_HOLL_LOADING_PLANE_DISTANCE_VERTICAL) { - s32 enHollId = EN_HOLL_GET_ID_CAST(this); + s32 enHollId = EN_HOLL_GET_ID(&this->actor); s32 playerSide = (this->actor.playerHeightRel > 0.0f) ? EN_HOLL_ABOVE : EN_HOLL_BELOW; - this->actor.room = globalCtx->doorCtx.transitionActorList[enHollId].sides[playerSide].room; + this->actor.room = play->doorCtx.transitionActorList[enHollId].sides[playerSide].room; - if ((this->actor.room != globalCtx->roomCtx.currRoom.num) && - Room_StartRoomTransition(globalCtx, &globalCtx->roomCtx, this->actor.room)) { + if ((this->actor.room != play->roomCtx.currRoom.num) && + Room_StartRoomTransition(play, &play->roomCtx, this->actor.room)) { this->actionFunc = EnHoll_RoomTransitionIdle; this->bgCoverAlphaActive = true; } } } else if (this->bgCoverAlphaActive) { this->bgCoverAlphaActive = false; - globalCtx->bgCoverAlpha = 0; + play->bgCoverAlpha = 0; } } -void EnHoll_VerticalIdle(EnHoll* this, GlobalContext* globalCtx) { +void EnHoll_VerticalIdle(EnHoll* this, PlayState* play) { if (this->actor.xzDistToPlayer < EN_HOLL_RADIUS) { f32 playerDistFromCentralPlane = fabsf(this->actor.playerHeightRel); if (playerDistFromCentralPlane < EN_HOLL_ACTIVATION_PLANE_DISTANCE_VERTICAL && playerDistFromCentralPlane > EN_HOLL_LOADING_PLANE_DISTANCE_VERTICAL) { - s32 enHollId = EN_HOLL_GET_ID_CAST(this); + s32 enHollId = EN_HOLL_GET_ID(&this->actor); s32 playerSide = (this->actor.playerHeightRel > 0.0f) ? EN_HOLL_ABOVE : EN_HOLL_BELOW; - this->actor.room = globalCtx->doorCtx.transitionActorList[enHollId].sides[playerSide].room; - if ((this->actor.room != globalCtx->roomCtx.currRoom.num) && - Room_StartRoomTransition(globalCtx, &globalCtx->roomCtx, this->actor.room)) { + this->actor.room = play->doorCtx.transitionActorList[enHollId].sides[playerSide].room; + if ((this->actor.room != play->roomCtx.currRoom.num) && + Room_StartRoomTransition(play, &play->roomCtx, this->actor.room)) { this->actionFunc = EnHoll_RoomTransitionIdle; } } } } -void EnHoll_RoomTransitionIdle(EnHoll* this, GlobalContext* globalCtx) { - if (globalCtx->roomCtx.unk31 == 0) { - func_8012EBF8(globalCtx, &globalCtx->roomCtx); - if (globalCtx->bgCoverAlpha == 0) { +void EnHoll_RoomTransitionIdle(EnHoll* this, PlayState* play) { + if (play->roomCtx.unk31 == 0) { + func_8012EBF8(play, &play->roomCtx); + if (play->bgCoverAlpha == 0) { this->bgCoverAlphaActive = false; } EnHoll_SetupAction(this); } } -void EnHoll_Update(Actor* thisx, GlobalContext* globalCtx) { +void EnHoll_Update(Actor* thisx, PlayState* play) { EnHoll* this = THIS; - Player* player = GET_PLAYER(globalCtx); + Player* player = GET_PLAYER(play); - if ((globalCtx->sceneLoadFlag == 0) && (globalCtx->unk_18B4A == 0) && !(player->stateFlags1 & 0x200)) { - this->actionFunc(this, globalCtx); + if ((play->transitionTrigger == TRANS_TRIGGER_OFF) && (play->transitionMode == TRANS_MODE_OFF) && + !(player->stateFlags1 & 0x200)) { + this->actionFunc(this, play); } } -void EnHoll_Draw(Actor* thisx, GlobalContext* globalCtx) { +void EnHoll_Draw(Actor* thisx, PlayState* play) { EnHoll* this = THIS; Gfx* dl; u32 dlIndex; if (this->alpha != 0) { - OPEN_DISPS(globalCtx->state.gfxCtx); + OPEN_DISPS(play->state.gfxCtx); if (this->alpha == 255) { dl = POLY_OPA_DISP; dlIndex = 37; @@ -330,9 +331,9 @@ 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); + gSPMatrix(dl++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gDPSetPrimColor(dl++, 0, 0, 0, 0, 0, this->alpha); gSPDisplayList(dl++, gEnHollCentralPlaneDL); if (this->alpha == 255) { @@ -340,6 +341,6 @@ void EnHoll_Draw(Actor* thisx, GlobalContext* globalCtx) { } else { POLY_XLU_DISP = dl; } - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->state.gfxCtx); } } diff --git a/src/overlays/actors/ovl_En_Holl/z_en_holl.h b/src/overlays/actors/ovl_En_Holl/z_en_holl.h index 868798bb2..39c35220c 100644 --- a/src/overlays/actors/ovl_En_Holl/z_en_holl.h +++ b/src/overlays/actors/ovl_En_Holl/z_en_holl.h @@ -5,7 +5,7 @@ struct EnHoll; -typedef void (*EnHollActionFunc)(struct EnHoll*, GlobalContext*); +typedef void (*EnHollActionFunc)(struct EnHoll*, PlayState*); typedef enum { /* 0 */ EN_HOLL_TYPE_DEFAULT, @@ -60,11 +60,10 @@ typedef struct EnHoll { #define EN_HOLL_LOADING_PLANE_DISTANCE_VERTICAL 50.0f -#define EN_HOLL_GET_ID_AND(this) ((this->actor.params & 0xFFFF) >> 10) -#define EN_HOLL_GET_ID_CAST(this) ((u16) this->actor.params >> 10) -#define EN_HOLL_GET_TYPE(this) ((this->actor.params >> 7) & 0x7) -#define EN_HOLL_GET_EXIT_LIST_INDEX(this) (this->actor.params & 0x7F) -#define EN_HOLL_GET_Z_ACTOR_BITMASK_INDEX(this) (this->actor.params & 0x7) +#define EN_HOLL_GET_ID(thisx) ((u16)(thisx)->params >> 10) +#define EN_HOLL_GET_TYPE(thisx) (((thisx)->params >> 7) & 0x7) +#define EN_HOLL_GET_EXIT_LIST_INDEX(thisx) ((thisx)->params & 0x7F) +#define EN_HOLL_GET_Z_ACTOR_BITMASK_INDEX(thisx) ((thisx)->params & 0x7) #define EN_HOLL_IS_VISIBLE(this) ((this->type == EN_HOLL_TYPE_DEFAULT) || (this->type == EN_HOLL_TYPE_SCENE_CHANGER)) #define EN_HOLL_IS_SCENE_CHANGER(this) (this->type == EN_HOLL_TYPE_SCENE_CHANGER) diff --git a/src/overlays/actors/ovl_En_Honotrap/z_en_honotrap.c b/src/overlays/actors/ovl_En_Honotrap/z_en_honotrap.c index aaea88252..9f6b6b98a 100644 --- a/src/overlays/actors/ovl_En_Honotrap/z_en_honotrap.c +++ b/src/overlays/actors/ovl_En_Honotrap/z_en_honotrap.c @@ -10,25 +10,25 @@ #define THIS ((EnHonotrap*)thisx) -void EnHonotrap_Init(Actor* thisx, GlobalContext* globalCtx); -void EnHonotrap_Destroy(Actor* thisx, GlobalContext* globalCtx); -void EnHonotrap_Update(Actor* thisx, GlobalContext* globalCtx); -void EnHonotrap_Draw(Actor* thisx, GlobalContext* globalCtx); +void EnHonotrap_Init(Actor* thisx, PlayState* play); +void EnHonotrap_Destroy(Actor* thisx, PlayState* play); +void EnHonotrap_Update(Actor* thisx, PlayState* play); +void EnHonotrap_Draw(Actor* thisx, PlayState* play); -void func_8092EBDC(EnHonotrap* this, GlobalContext* globalCtx); -void func_8092ECF0(EnHonotrap* this, GlobalContext* globalCtx); -void func_8092EDD8(EnHonotrap* this, GlobalContext* globalCtx); -void func_8092EE1C(EnHonotrap* this, GlobalContext* globalCtx); -void func_8092EE90(EnHonotrap* this, GlobalContext* globalCtx); -void func_8092EF98(EnHonotrap* this, GlobalContext* globalCtx); -void func_8092F074(EnHonotrap* this, GlobalContext* globalCtx); -void func_8092F0B8(EnHonotrap* this, GlobalContext* globalCtx); -void func_8092F10C(EnHonotrap* this, GlobalContext* globalCtx); -void func_8092F208(EnHonotrap* this, GlobalContext* globalCtx); -void func_8092F3D8(EnHonotrap* this, GlobalContext* globalCtx); -void func_8092F5EC(EnHonotrap* this, GlobalContext* globalCtx); -void func_8092F7BC(EnHonotrap* this, GlobalContext* globalCtx); -void func_8092F878(EnHonotrap* this, GlobalContext* globalCtx); +void func_8092EBDC(EnHonotrap* this, PlayState* play); +void func_8092ECF0(EnHonotrap* this, PlayState* play); +void func_8092EDD8(EnHonotrap* this, PlayState* play); +void func_8092EE1C(EnHonotrap* this, PlayState* play); +void func_8092EE90(EnHonotrap* this, PlayState* play); +void func_8092EF98(EnHonotrap* this, PlayState* play); +void func_8092F074(EnHonotrap* this, PlayState* play); +void func_8092F0B8(EnHonotrap* this, PlayState* play); +void func_8092F10C(EnHonotrap* this, PlayState* play); +void func_8092F208(EnHonotrap* this, PlayState* play); +void func_8092F3D8(EnHonotrap* this, PlayState* play); +void func_8092F5EC(EnHonotrap* this, PlayState* play); +void func_8092F7BC(EnHonotrap* this, PlayState* play); +void func_8092F878(EnHonotrap* this, PlayState* play); #if 0 const ActorInit En_Honotrap_InitVars = { @@ -58,7 +58,7 @@ static ColliderTrisElementInit D_80930424[2] = { // static ColliderTrisInit sTrisInit = { static ColliderTrisInit D_8093049C = { { COLTYPE_NONE, AT_NONE, AC_ON | AC_TYPE_PLAYER, OC1_NONE, OC2_NONE, COLSHAPE_TRIS, }, - 2, D_80930424, // sTrisElementsInit, + ARRAY_COUNT(sTrisElementsInit), D_80930424, // sTrisElementsInit, }; // static ColliderCylinderInit sCylinderInit = { diff --git a/src/overlays/actors/ovl_En_Honotrap/z_en_honotrap.h b/src/overlays/actors/ovl_En_Honotrap/z_en_honotrap.h index f9983e26a..bf4b08fd7 100644 --- a/src/overlays/actors/ovl_En_Honotrap/z_en_honotrap.h +++ b/src/overlays/actors/ovl_En_Honotrap/z_en_honotrap.h @@ -5,12 +5,12 @@ struct EnHonotrap; -typedef void (*EnHonotrapActionFunc)(struct EnHonotrap*, GlobalContext*); +typedef void (*EnHonotrapActionFunc)(struct EnHonotrap*, PlayState*); typedef struct EnHonotrap { - /* 0x0000 */ Actor actor; - /* 0x0144 */ EnHonotrapActionFunc actionFunc; - /* 0x0148 */ char unk_148[0x17C]; + /* 0x000 */ Actor actor; + /* 0x144 */ EnHonotrapActionFunc actionFunc; + /* 0x148 */ char unk_148[0x17C]; } EnHonotrap; // size = 0x2C4 extern const ActorInit En_Honotrap_InitVars; diff --git a/src/overlays/actors/ovl_En_Horse/z_en_horse.c b/src/overlays/actors/ovl_En_Horse/z_en_horse.c index 440ac3578..259594d56 100644 --- a/src/overlays/actors/ovl_En_Horse/z_en_horse.c +++ b/src/overlays/actors/ovl_En_Horse/z_en_horse.c @@ -5,23 +5,27 @@ */ #include "z_en_horse.h" +#include "z64rumble.h" +#include "overlays/actors/ovl_En_In/z_en_in.h" +#include "overlays/actors/ovl_Obj_Um/z_obj_um.h" +#include "overlays/actors/ovl_En_Horse_Game_Check/z_en_horse_game_check.h" #include "objects/object_horse_link_child/object_horse_link_child.h" #define FLAGS (ACTOR_FLAG_10) #define THIS ((EnHorse*)thisx) -void EnHorse_Init(Actor* thisx, GlobalContext* globalCtx); -void EnHorse_Destroy(Actor* thisx, GlobalContext* globalCtx); -void EnHorse_Update(Actor* thisx, GlobalContext* globalCtx); -void EnHorse_Draw(Actor* thisx, GlobalContext* globalCtx); +void EnHorse_Init(Actor* thisx, PlayState* play); +void EnHorse_Destroy(Actor* thisx, PlayState* play); +void EnHorse_Update(Actor* thisx, PlayState* play); +void EnHorse_Draw(Actor* thisx, PlayState* play); -void func_8087D540(Actor* thisx, GlobalContext* globalCtx); +void func_8087D540(Actor* thisx, PlayState* play); void EnHorse_StartMountedIdleResetAnim(EnHorse* this); void EnHorse_StartMountedIdle(EnHorse* this); -void EnHorse_MountedIdle(EnHorse* this, GlobalContext* globalCtx); +void EnHorse_MountedIdle(EnHorse* this, PlayState* play); void EnHorse_MountedIdleAnim(EnHorse* this); -void EnHorse_MountedIdleWhinney(EnHorse* this); +void EnHorse_MountedIdleWhinny(EnHorse* this); void EnHorse_StartTurning(EnHorse* this); void EnHorse_StartWalkingFromIdle(EnHorse* this); void EnHorse_StartWalkingInterruptable(EnHorse* this); @@ -29,62 +33,62 @@ 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_StartBraking(EnHorse* this, PlayState* play); 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_StartLowJump(EnHorse* this, PlayState* play); +void EnHorse_StartHighJump(EnHorse* this, PlayState* play); 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_SetFollowAnimation(EnHorse* this, PlayState* play); 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_80881290(EnHorse* this, PlayState* play); +void func_8088159C(EnHorse* this, PlayState* play); void func_80881634(EnHorse* this); void func_8088168C(EnHorse* this); -void EnHorse_CsMoveInit(EnHorse* this, 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_CsMoveInit(EnHorse* this, PlayState* play, CsCmdActorAction* action); +void EnHorse_CsMoveToPoint(EnHorse* this, PlayState* play, CsCmdActorAction* action); +void EnHorse_CsPlayHighJumpAnim(EnHorse* this, PlayState* play); +void EnHorse_CsJumpInit(EnHorse* this, PlayState* play, CsCmdActorAction* action); +void EnHorse_CsJump(EnHorse* this, PlayState* play, CsCmdActorAction* action); +void EnHorse_CsRearingInit(EnHorse* this, PlayState* play, CsCmdActorAction* action); +void EnHorse_CsRearing(EnHorse* this, PlayState* play, CsCmdActorAction* action); +void EnHorse_WarpMoveInit(EnHorse* this, PlayState* play, CsCmdActorAction* action); +void EnHorse_CsWarpMoveToPoint(EnHorse* this, PlayState* play, CsCmdActorAction* action); +void EnHorse_CsWarpRearingInit(EnHorse* this, PlayState* play, CsCmdActorAction* action); +void EnHorse_CsWarpRearing(EnHorse* this, PlayState* play, CsCmdActorAction* action); +void EnHorse_InitCutscene(EnHorse* this, PlayState* play); 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_80883BEC(EnHorse* this, PlayState* play, CsCmdActorAction* action); +void func_80883CB0(EnHorse* this, PlayState* play, CsCmdActorAction* action); +void func_80883D64(EnHorse* this, PlayState* play, CsCmdActorAction* action); +void func_80883DE0(EnHorse* this, PlayState* play, CsCmdActorAction* action); +void func_80883E10(EnHorse* this, PlayState* play, CsCmdActorAction* action); +void func_80883EA0(EnHorse* this, PlayState* play, CsCmdActorAction* action); +void func_80883F18(EnHorse* this, PlayState* play, CsCmdActorAction* action); +void func_80883F98(EnHorse* this, PlayState* play, CsCmdActorAction* action); +void func_80884010(EnHorse* this, PlayState* play, CsCmdActorAction* action); +void func_808840C4(EnHorse* this, PlayState* play, CsCmdActorAction* action); +void func_80884194(EnHorse* this, PlayState* play, CsCmdActorAction* action); +void func_8088424C(EnHorse* this, PlayState* play, CsCmdActorAction* action); +void func_80884314(EnHorse* this, PlayState* play, CsCmdActorAction* action); +void func_808843B4(EnHorse* this, PlayState* play, CsCmdActorAction* action); +void func_80884444(EnHorse* this, PlayState* play, CsCmdActorAction* action); +void func_808844E0(EnHorse* this, PlayState* play, CsCmdActorAction* action); +void func_80884564(EnHorse* this, PlayState* play, CsCmdActorAction* action); +void func_80884604(EnHorse* this, PlayState* play, CsCmdActorAction* action); +void func_808846B4(EnHorse* this, PlayState* play, CsCmdActorAction* action); +void func_808846DC(EnHorse* this, PlayState* play, CsCmdActorAction* action); +void func_808846F0(EnHorse* this, PlayState* play); void func_80884994(EnHorse* this); -void func_80884D04(EnHorse* this, GlobalContext* globalCtx); +void func_80884D04(EnHorse* this, PlayState* play); void EnHorse_StickDirection(Vec2f* curStick, f32* stickMag, s16* angle); -s32 EnHorse_GetMountSide(EnHorse* this, GlobalContext* globalCtx); +s32 EnHorse_GetMountSide(EnHorse* this, PlayState* play); typedef struct { s32 csAction; @@ -104,23 +108,37 @@ typedef struct { RaceWaypoint* waypoints; } RaceInfo; -static AnimationHeader* sEponaAnimHeaders[] = { +typedef enum { + /* 0 */ ENHORSE_ANIM_IDLE, + /* 1 */ ENHORSE_ANIM_WHINNY, + /* 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 +} EnHorseAnimation; + +static AnimationHeader* sEponaAnimations[] = { &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[] = { +static AnimationHeader* sHniAnimations[] = { &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, + NULL, NULL, sEponaAnimations, sHniAnimations, sHniAnimations, }; -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 f32 sPlaybackSpeeds[] = { + 2.0f / 3.0f, 2.0f / 3.0f, 3.0f / 3.0f, 3.0f / 3.0f, 3.0f / 3.0f, 3.0f / 3.0f, 3.0f / 3.0f, 2.0f / 3.0f, 2.0f / 3.0f, +}; static SkeletonHeader* sSkeletonHeaders[] = { NULL, NULL, &object_horse_link_child_Skel_00A480, NULL, NULL, @@ -201,7 +219,7 @@ static ColliderJntSphInit sJntSphInit = { OC2_TYPE_1 | OC2_UNK1, COLSHAPE_JNTSPH, }, - 1, + ARRAY_COUNT(sJntSphElementsInit), sJntSphElementsInit, }; @@ -222,11 +240,15 @@ static u8 sResetNoInput[] = { true, true, true, false, false, false, false, false, false, false, false, false, }; -static s32 sIdleAnimIds[] = { - 1, 3, 0, 3, 1, 0, +static s32 sIdleAnimIndices[] = { + ENHORSE_ANIM_WHINNY, ENHORSE_ANIM_REARING, ENHORSE_ANIM_IDLE, + ENHORSE_ANIM_REARING, ENHORSE_ANIM_WHINNY, ENHORSE_ANIM_IDLE, }; -static s16 sIngoAnimations[] = { 7, 6, 2, 2, 1, 1, 0, 0, 0, 0 }; +static s16 sIngoAnimIndices[] = { + ENIN_ANIM_7, ENIN_ANIM_6, ENIN_ANIM_2, ENIN_ANIM_2, ENIN_ANIM_1, + ENIN_ANIM_1, ENIN_ANIM_0, ENIN_ANIM_0, ENIN_ANIM_0, ENIN_ANIM_0, +}; static EnHorseCsFunc sCutsceneInitFuncs[] = { NULL, @@ -268,11 +290,11 @@ void EnHorse_RaceWaypointPos(RaceWaypoint* waypoints, s32 idx, Vec3f* pos) { pos->z = waypoints[idx].z; } -void EnHorse_RotateToPoint(EnHorse* this, GlobalContext* globalCtx, Vec3f* pos, s16 turnAmount) { +void EnHorse_RotateToPoint(EnHorse* this, PlayState* play, Vec3f* pos, s16 turnAmount) { func_800F415C(&this->actor, pos, turnAmount); } -void func_8087B7C0(EnHorse* this, GlobalContext* globalCtx, Path* path) { +void func_8087B7C0(EnHorse* this, PlayState* play, Path* path) { s32 spA4; Vec3s* spA0; f32 phi_f12; @@ -324,12 +346,12 @@ void func_8087B7C0(EnHorse* this, GlobalContext* globalCtx, Path* path) { func_8017D7C0(this->actor.world.pos.x, this->actor.world.pos.z, sp80.x, sp80.z, sp8C.x, sp8C.z, &sp70); if ((this->actor.bgCheckFlags & 8) || (this->unk_1EC & 4)) { - EnHorse_RotateToPoint(this, globalCtx, &sp8C, 0xC80); + EnHorse_RotateToPoint(this, play, &sp8C, 0xC80); if (this->unk_1EC & 4) { this->unk_1EC &= ~4; } } else { - EnHorse_RotateToPoint(this, globalCtx, &sp8C, 0x320); + EnHorse_RotateToPoint(this, play, &sp8C, 0x320); if (sp70 < SQ(100.0f)) { if ((this->actor.xzDistToPlayer < 100.0f) || (this->colliderJntSph.elements[0].info.ocElemFlags & OCELEM_HIT)) { @@ -408,7 +430,7 @@ void func_8087B7C0(EnHorse* this, GlobalContext* globalCtx, Path* path) { return; } - sp4A = Actor_YawBetweenActors(&this->actor, &GET_PLAYER(globalCtx)->actor) - this->actor.world.rot.y; + sp4A = Actor_YawBetweenActors(&this->actor, &GET_PLAYER(play)->actor) - this->actor.world.rot.y; if ((fabsf(Math_SinS(sp4A)) < 0.9f) && (Math_CosS(sp4A) > 0.0f)) { if (this->actor.speedXZ < this->unk_398) { @@ -433,7 +455,7 @@ void func_8087B7C0(EnHorse* this, GlobalContext* globalCtx, Path* path) { } 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; + s16 sp48 = Actor_YawBetweenActors(&this->actor, &GET_PLAYER(play)->actor) - this->actor.world.rot.y; if ((fabsf(Math_SinS(sp48)) < 0.9f) && (Math_CosS(sp48) > 0.0f)) { if (this->actor.speedXZ < this->unk_398) { @@ -466,7 +488,7 @@ void EnHorse_PlayWalkingSound(EnHorse* this) { return; } - if (this->type == HORSE_2) { + if (this->type == HORSE_TYPE_2) { Audio_PlaySfxAtPos(&this->actor.projectedPos, NA_SE_EV_KID_HORSE_WALK); } else { Audio_PlaySfxAtPos(&this->actor.projectedPos, NA_SE_EV_HORSE_WALK); @@ -480,7 +502,7 @@ void EnHorse_PlayWalkingSound(EnHorse* this) { } void func_8087C178(EnHorse* this) { - if (this->type == HORSE_2) { + if (this->type == HORSE_TYPE_2) { Audio_PlaySfxAtPos(&this->actor.projectedPos, NA_SE_EV_KID_HORSE_RUN); } else { Audio_PlaySfxAtPos(&this->actor.projectedPos, NA_SE_EV_HORSE_RUN); @@ -488,14 +510,14 @@ void func_8087C178(EnHorse* this) { } void func_8087C1C0(EnHorse* this) { - if (this->type == HORSE_2) { + if (this->type == HORSE_TYPE_2) { Audio_PlaySfxAtPos(&this->actor.projectedPos, NA_SE_EV_KID_HORSE_RUN); } else { Audio_PlaySfxAtPos(&this->actor.projectedPos, NA_SE_EV_HORSE_RUN); } } -f32 EnHorse_SlopeSpeedMultiplier(EnHorse* this, GlobalContext* globalCtx) { +f32 EnHorse_SlopeSpeedMultiplier(EnHorse* this, PlayState* play) { f32 multiplier = 1.0f; if ((Math_CosS(this->actor.shape.rot.x) < 0.939262f) && (Math_SinS(this->actor.shape.rot.x) < 0.0f)) { @@ -504,11 +526,11 @@ f32 EnHorse_SlopeSpeedMultiplier(EnHorse* this, GlobalContext* globalCtx) { return multiplier; } -void func_8087C288(GlobalContext* globalCtx, Vec3f* arg1, Vec3f* arg2, f32* arg3) { - SkinMatrix_Vec3fMtxFMultXYZW(&globalCtx->viewProjectionMtxF, arg1, arg2, arg3); +void func_8087C288(PlayState* play, Vec3f* arg1, Vec3f* arg2, f32* arg3) { + SkinMatrix_Vec3fMtxFMultXYZW(&play->viewProjectionMtxF, arg1, arg2, arg3); } -s32 func_8087C2B8(GlobalContext* globalCtx, EnHorse* this, Vec3f* arg2, f32 arg3) { +s32 func_8087C2B8(PlayState* play, EnHorse* this, Vec3f* arg2, f32 arg3) { f32 phi_f14; if ((arg2->z > 0.0f) && (arg2->z < (this->actor.uncullZoneForward + this->actor.uncullZoneScale))) { @@ -526,37 +548,37 @@ s32 func_8087C2B8(GlobalContext* globalCtx, EnHorse* this, Vec3f* arg2, f32 arg3 return false; } -s32 func_8087C38C(GlobalContext* globalCtx, EnHorse* this, Vec3f* arg2) { +s32 func_8087C38C(PlayState* play, EnHorse* this, Vec3f* arg2) { Vec3f sp24; f32 sp20; f32 eyeDist; - func_8087C288(globalCtx, arg2, &sp24, &sp20); + func_8087C288(play, arg2, &sp24, &sp20); if (fabsf(sp20) < 0.008f) { return false; } - eyeDist = Math3D_Distance(arg2, &globalCtx->view.eye); + eyeDist = Math3D_Distance(arg2, &play->view.eye); - return func_8087C2B8(globalCtx, this, &sp24, sp20) || (eyeDist < 100.0f); + return func_8087C2B8(play, 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))) && +void EnHorse_IdleAnimSounds(EnHorse* this, PlayState* play) { + if ((this->animIndex == ENHORSE_ANIM_IDLE) && + (((this->curFrame > 35.0f) && (this->type == HORSE_TYPE_EPONA)) || + ((this->curFrame > 28.0f) && (this->type == HORSE_TYPE_HNI)) || + ((this->curFrame > 25.0f) && (this->type == HORSE_TYPE_2))) && !(this->stateFlags & ENHORSE_SANDDUST_SOUND)) { this->stateFlags |= ENHORSE_SANDDUST_SOUND; - if (this->type == HORSE_2) { + if (this->type == HORSE_TYPE_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)) { + } else if ((this->animIndex == 3) && (this->curFrame > 25.0f) && !(this->stateFlags & ENHORSE_LAND2_SOUND)) { this->stateFlags |= ENHORSE_LAND2_SOUND; - if (this->type == HORSE_2) { + if (this->type == HORSE_TYPE_2) { Audio_PlaySfxAtPos(&this->actor.projectedPos, NA_SE_EV_KID_HORSE_LAND2); } else { Audio_PlaySfxAtPos(&this->actor.projectedPos, NA_SE_EV_KID_HORSE_LAND2); @@ -564,15 +586,15 @@ void EnHorse_IdleAnimSounds(EnHorse* this, GlobalContext* globalCtx) { } } -s32 EnHorse_Spawn(EnHorse* this, GlobalContext* globalCtx) { +s32 EnHorse_Spawn(EnHorse* this, PlayState* play) { s32 i; f32 dist; Path* path; s32 spawn = false; f32 minDist = 1.0e+38; - Player* player = GET_PLAYER(globalCtx); + Player* player = GET_PLAYER(play); Vec3f spawnPos; - s32 pathIdx = func_800F3940(globalCtx); + s32 pathIdx = func_800F3940(play); s32 pathCount; Vec3s* pathPoints; @@ -580,7 +602,7 @@ s32 EnHorse_Spawn(EnHorse* this, GlobalContext* globalCtx) { return false; } - path = &globalCtx->setupPathList[pathIdx]; + path = &play->setupPathList[pathIdx]; pathCount = path->count; pathPoints = Lib_SegmentedToVirtual(path->points); @@ -590,7 +612,7 @@ s32 EnHorse_Spawn(EnHorse* this, GlobalContext* globalCtx) { spawnPos.z = pathPoints[i].z; dist = Math3D_Distance(&player->actor.world.pos, &spawnPos); - if ((minDist < dist) || func_8087C38C(globalCtx, this, &spawnPos)) { + if ((minDist < dist) || func_8087C38C(play, this, &spawnPos)) { continue; } @@ -600,9 +622,9 @@ s32 EnHorse_Spawn(EnHorse* this, GlobalContext* globalCtx) { 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); + this->actor.shape.rot.y = Actor_YawBetweenActors(&this->actor, &GET_PLAYER(play)->actor); spawn = true; - SkinMatrix_Vec3fMtxFMultXYZW(&globalCtx->viewProjectionMtxF, &this->actor.world.pos, &this->actor.projectedPos, + SkinMatrix_Vec3fMtxFMultXYZW(&play->viewProjectionMtxF, &this->actor.world.pos, &this->actor.projectedPos, &this->actor.projectedW); } @@ -626,38 +648,39 @@ s32 EnHorse_Spawn(EnHorse* this, GlobalContext* globalCtx) { 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); + this->actor.shape.rot.y = Actor_YawBetweenActors(&this->actor, &GET_PLAYER(play)->actor); spawn = true; - SkinMatrix_Vec3fMtxFMultXYZW(&globalCtx->viewProjectionMtxF, &this->actor.world.pos, &this->actor.projectedPos, + SkinMatrix_Vec3fMtxFMultXYZW(&play->viewProjectionMtxF, &this->actor.world.pos, &this->actor.projectedPos, &this->actor.projectedW); } return spawn; } -void EnHorse_ResetCutscene(EnHorse* this, GlobalContext* globalCtx) { +void EnHorse_ResetCutscene(EnHorse* this, PlayState* play) { this->cutsceneAction = -1; this->cutsceneFlags = 0; } -void EnHorse_ResetRace(EnHorse* this, GlobalContext* globalCtx) { +void EnHorse_ResetRace(EnHorse* this, PlayState* play) { this->inRace = false; } -s32 EnHorse_PlayerCanMove(EnHorse* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); +s32 EnHorse_PlayerCanMove(EnHorse* this, PlayState* play) { + Player* player = GET_PLAYER(play); - if ((player->stateFlags1 & 1) || (func_800B7128(GET_PLAYER(globalCtx)) == true) || - (player->stateFlags1 & 0x100000) || + if ((player->stateFlags1 & PLAYER_STATE1_1) || (func_800B7128(GET_PLAYER(play)) == true) || + (player->stateFlags1 & PLAYER_STATE1_100000) || (((this->stateFlags & ENHORSE_FLAG_19) || (this->stateFlags & ENHORSE_FLAG_29)) && !this->inRace) || - (this->action == 19) || (player->actor.flags & ACTOR_FLAG_100) || (globalCtx->csCtx.state != 0) || - (ActorCutscene_GetCurrentIndex() != -1) || (player->stateFlags1 & 0x20) || (player->csMode != 0)) { + (this->action == ENHORSE_ACTION_HBA) || (player->actor.flags & ACTOR_FLAG_100) || + (play->csCtx.state != CS_STATE_0) || (ActorCutscene_GetCurrentIndex() != -1) || + (player->stateFlags1 & PLAYER_STATE1_20) || (player->csMode != 0)) { return false; } return true; } -void EnHorse_ResetHorsebackArchery(EnHorse* this, GlobalContext* globalCtx) { +void EnHorse_ResetHorsebackArchery(EnHorse* this, PlayState* play) { this->unk_39C = 0; this->hbaStarted = 0; this->hbaFlags = 0; @@ -670,19 +693,19 @@ void EnHorse_ClearDustFlags(u16* dustFlags) { void func_8087C9F8(EnHorse* this) { } -void func_8087CA04(EnHorse* this, GlobalContext* globalCtx) { +void func_8087CA04(EnHorse* this, PlayState* play) { } -#ifdef NON_MATCHING -void EnHorse_Init(Actor* thisx, GlobalContext* globalCtx2) { - GlobalContext* globalCtx = globalCtx2; +void EnHorse_Init(Actor* thisx, PlayState* play2) { + PlayState* play = play2; 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 = this->actor.world.pos; + this->riderPos = thisx->world.pos; this->unk_52C = 0; this->noInputTimer = 0; this->riderPos.y += 70.0f; @@ -693,207 +716,202 @@ void EnHorse_Init(Actor* thisx, GlobalContext* globalCtx2) { this->unk_3E8 = 0.0f; this->unk_528 = 100.0f; - if (ENHORSE_GET_8000(&this->actor)) { - this->type = HORSE_4; + if (ENHORSE_IS_DONKEY_TYPE(&this->actor)) { + this->type = HORSE_TYPE_DONKEY; this->unk_528 = 80.0f; this->boostSpeed = 12; - if ((this->bankIndex = Object_GetIndex(&globalCtx->objectCtx, OBJECT_HA)) < 0) { + if ((this->bankIndex = Object_GetIndex(&play->objectCtx, OBJECT_HA)) < 0) { Actor_MarkForDeath(&this->actor); return; } this->unk_1EC |= 1; - this->actor.update = func_8087D540; - } else if (ENHORSE_GET_4000(&this->actor)) { - this->type = HORSE_2; + thisx->update = func_8087D540; + } else if (ENHORSE_IS_4000_TYPE(&this->actor)) { + this->type = HORSE_TYPE_2; this->unk_528 = 64.8f; this->boostSpeed = 15; - if ((this->bankIndex = Object_GetIndex(&globalCtx->objectCtx, OBJECT_HORSE_LINK_CHILD)) < 0) { - this->actor.objBankIndex = Object_Spawn(&globalCtx->objectCtx, OBJECT_HORSE_LINK_CHILD); - Actor_SetObjectDependency(globalCtx, &this->actor); - Skin_Init(&globalCtx->state, &this->skin, sSkeletonHeaders[this->type], sAnimationHeaders[this->type][0]); - Animation_PlayOnce(&this->skin.skelAnime, sAnimationHeaders[this->type][this->animationIdx]); + if ((this->bankIndex = Object_GetIndex(&play->objectCtx, OBJECT_HORSE_LINK_CHILD)) < 0) { + thisx->objBankIndex = Object_Spawn(&play->objectCtx, OBJECT_HORSE_LINK_CHILD); + Actor_SetObjectDependency(play, &this->actor); + Skin_Init(&play->state, &this->skin, sSkeletonHeaders[this->type], sAnimationHeaders[this->type][0]); + Animation_PlayOnce(&this->skin.skelAnime, sAnimationHeaders[this->type][this->animIndex]); this->unk_1EC |= 0x200; } else { - this->actor.update = func_8087D540; + thisx->update = func_8087D540; } - } else if (ENHORSE_GET_2000(&this->actor)) { - this->type = HORSE_3; + } else if (ENHORSE_IS_BANDIT_TYPE(&this->actor)) { + this->type = HORSE_TYPE_BANDIT; this->boostSpeed = 12; - if ((this->bankIndex = Object_GetIndex(&globalCtx->objectCtx, OBJECT_HA)) < 0) { + if ((this->bankIndex = Object_GetIndex(&play->objectCtx, OBJECT_HA)) < 0) { Actor_MarkForDeath(&this->actor); return; } this->unk_1EC |= 1; - this->actor.update = func_8087D540; + thisx->update = func_8087D540; } else { - this->type = HORSE_EPONA; + this->type = HORSE_TYPE_EPONA; this->boostSpeed = 15; Actor_MarkForDeath(&this->actor); } - this->actor.params &= ~0xE000; + this->actor.params &= ~(ENHORSE_PARAM_DONKEY | ENHORSE_PARAM_4000 | ENHORSE_PARAM_BANDIT); if (this->actor.params == 0x1FFF) { this->actor.params = ENHORSE_1; } - if (this->actor.params == ENHORSE_3) { + if (thisx->params == ENHORSE_3) { this->stateFlags = ENHORSE_FLAG_19 | ENHORSE_CANT_JUMP | ENHORSE_UNRIDEABLE; - } else if (this->actor.params == ENHORSE_8) { + } else if (thisx->params == ENHORSE_8) { this->stateFlags = ENHORSE_FLAG_19 | ENHORSE_CANT_JUMP; - if (CHECK_QUEST_ITEM(14)) { + if (CHECK_QUEST_ITEM(QUEST_SONG_EPONA)) { this->stateFlags &= ~ENHORSE_CANT_JUMP; this->stateFlags |= ENHORSE_FLAG_26; } - } else if (this->actor.params == ENHORSE_13) { + } else if (thisx->params == ENHORSE_13) { this->stateFlags = ENHORSE_FLAG_29; this->unk_1EC |= 0x10; - } else if (this->actor.params == ENHORSE_4) { + } else if (thisx->params == ENHORSE_4) { this->stateFlags = ENHORSE_FLAG_29 | ENHORSE_CANT_JUMP; - this->actor.flags |= ACTOR_FLAG_80000000; - } else if (this->actor.params == ENHORSE_5) { + thisx->flags |= ACTOR_FLAG_80000000; + } else if (thisx->params == ENHORSE_5) { this->stateFlags = ENHORSE_FLAG_29 | ENHORSE_CANT_JUMP; - this->actor.flags |= ACTOR_FLAG_80000000; - } else if (this->actor.params == ENHORSE_15) { + thisx->flags |= ACTOR_FLAG_80000000; + } else if (thisx->params == ENHORSE_15) { this->stateFlags = ENHORSE_UNRIDEABLE | ENHORSE_FLAG_7; - } else if (this->actor.params == ENHORSE_17) { + } else if (thisx->params == ENHORSE_17) { this->stateFlags = 0; this->unk_1EC |= 8; - } else if (this->actor.params == ENHORSE_18) { + } else if (thisx->params == ENHORSE_18) { this->stateFlags = ENHORSE_FLAG_29 | ENHORSE_CANT_JUMP; - this->actor.flags |= ACTOR_FLAG_80000000; - } else if (this->actor.params == ENHORSE_1) { + thisx->flags |= ACTOR_FLAG_80000000; + } else if (thisx->params == ENHORSE_1) { this->stateFlags = ENHORSE_FLAG_7; - } else if ((this->actor.params == ENHORSE_19) || (this->actor.params == ENHORSE_20)) { + } 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))) { + if (((play->sceneNum == SCENE_KOEPONARACE) && (GET_RACE_FLAGS == 1)) || + ((gSaveContext.save.entrance == ENTRANCE(ROMANI_RANCH, 0)) && Cutscene_GetSceneSetupIndex(play))) { this->stateFlags |= ENHORSE_FLAG_25; } - this->actor.gravity = -3.5f; - ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawHorse, 20.0f); - this->action = ENHORSE_ACT_IDLE; - this->actor.speedXZ = 0.0f; + thisx->gravity = -3.5f; + ActorShape_Init(&thisx->shape, 0.0f, ActorShadow_DrawHorse, 20.0f); + this->action = ENHORSE_ACTION_IDLE; + thisx->speedXZ = 0.0f; - if (this->type == HORSE_2) { + if (this->type == HORSE_TYPE_2) { sJntSphInit.elements[0].dim.limb = 13; - } else if ((this->type == HORSE_3) || (this->type == HORSE_4)) { + } else if ((this->type == HORSE_TYPE_BANDIT) || (this->type == HORSE_TYPE_DONKEY)) { 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); + Collider_InitCylinder(play, &this->colliderCylinder1); + Collider_SetCylinder(play, &this->colliderCylinder1, &this->actor, &sCylinderInit1); + Collider_InitCylinder(play, &this->colliderCylinder2); + Collider_SetCylinder(play, &this->colliderCylinder2, &this->actor, &sCylinderInit2); + Collider_InitJntSph(play, &this->colliderJntSph); + Collider_SetJntSph(play, &this->colliderJntSph, &this->actor, &sJntSphInit, this->colliderJntSphElements); - if (this->type == HORSE_2) { + if (this->type == HORSE_TYPE_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) { + } else if (this->type == HORSE_TYPE_DONKEY) { this->colliderCylinder1.dim.radius = 50; } - CollisionCheck_SetInfo(&this->actor.colChkInfo, NULL, &sColChkInfoInit); + CollisionCheck_SetInfo(&thisx->colChkInfo, NULL, &sColChkInfoInit); - if (this->type == HORSE_2) { + if (this->type == HORSE_TYPE_2) { Actor_SetScale(&this->actor, 0.00648f); - } else if (this->type == HORSE_4) { + } else if (this->type == HORSE_TYPE_DONKEY) { Actor_SetScale(&this->actor, 0.008f); } else { Actor_SetScale(&this->actor, 0.01f); } - this->actor.focus.pos = this->actor.world.pos; + thisx->focus.pos = thisx->world.pos; this->playerControlled = false; - this->actor.focus.pos.y += 70.0f; + thisx->focus.pos.y += 70.0f; - if (!(this->unk_1EC & 1) && !(this->unk_1EC & 0x200) && (this->actor.update == EnHorse_Update)) { - Skin_Init(&globalCtx->state, &this->skin, sSkeletonHeaders[this->type], sAnimationHeaders[this->type][0]); + if (!(this->unk_1EC & 1) && !(this->unk_1EC & 0x200) && (thisx->update == EnHorse_Update)) { + Skin_Init(&play->state, &this->skin, sSkeletonHeaders[this->type], sAnimationHeaders[this->type][0]); } - this->animationIdx = 0; + this->animIndex = 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); + EnHorse_ResetCutscene(this, play); + EnHorse_ResetRace(this, play); + EnHorse_ResetHorsebackArchery(this, play); - if (this->actor.params == ENHORSE_2) { + if (thisx->params == ENHORSE_2) { this->unk_53C = 0; EnHorse_InitInactive(this); - } else if (this->actor.params == ENHORSE_3) { + } else if (thisx->params == ENHORSE_3) { EnHorse_InitIngoHorse(this); - this->rider = (EnIn*)Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_IN, this->actor.world.pos.x, - this->actor.world.pos.y, this->actor.world.pos.z, this->actor.shape.rot.x, - this->actor.shape.rot.y, 1, 1); + this->rider = (EnIn*)Actor_Spawn(&play->actorCtx, play, 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 (this->actor.params == ENHORSE_4) { + } 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, this->actor.world.pos.x, - this->actor.world.pos.y, this->actor.world.pos.z, this->actor.shape.rot.x, - this->actor.shape.rot.y, 1, 1); + this->rider = (EnIn*)Actor_Spawn(&play->actorCtx, play, 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 (this->actor.params == ENHORSE_5) { + } 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, this->actor.world.pos.x, - this->actor.world.pos.y, this->actor.world.pos.z, this->actor.shape.rot.x, - this->actor.shape.rot.y, 1, 2); + this->rider = (EnIn*)Actor_Spawn(&play->actorCtx, play, 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 (this->actor.params == ENHORSE_9) { - EnHorse_InitCutscene(this, globalCtx); - } else if (this->actor.params == ENHORSE_10) { + } else if (thisx->params == ENHORSE_9) { + EnHorse_InitCutscene(this, play); + } else if (thisx->params == ENHORSE_10) { EnHorse_InitHorsebackArchery(this); - func_80112AFC(globalCtx); - } else if (this->actor.params == ENHORSE_14) { - func_808846F0(this, globalCtx); - if ((globalCtx->sceneNum == SCENE_LOST_WOODS) && !Cutscene_IsPlaying(globalCtx)) { + func_80112AFC(play); + } else if (thisx->params == ENHORSE_14) { + func_808846F0(this, play); + if ((play->sceneNum == SCENE_LOST_WOODS) && !Cutscene_IsPlaying(play)) { Actor_MarkForDeath(&this->actor); } - } else if (this->actor.params == ENHORSE_16) { + } else if (thisx->params == ENHORSE_16) { func_8087C9F8(this); - } else if (this->actor.params == ENHORSE_15) { + } else if (thisx->params == ENHORSE_15) { EnHorse_ResetIdleAnimation(this); - } else if (this->actor.params == ENHORSE_18) { + } else if (thisx->params == ENHORSE_18) { func_80884994(this); - } else if (this->actor.params == ENHORSE_19) { + } else if (thisx->params == ENHORSE_19) { EnIn* in; - func_80884D04(this, globalCtx); - in = (EnIn*)Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_IN, this->actor.world.pos.x, - this->actor.world.pos.y, this->actor.world.pos.z, this->actor.shape.rot.x, - this->actor.shape.rot.y, 1, 1); + func_80884D04(this, play); + in = (EnIn*)Actor_Spawn(&play->actorCtx, play, 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 (this->actor.params == ENHORSE_20) { + } else if (thisx->params == ENHORSE_20) { EnIn* in; - func_80884D04(this, globalCtx); - in = (EnIn*)Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_IN, this->actor.world.pos.x, - this->actor.world.pos.y, this->actor.world.pos.z, this->actor.shape.rot.x, - this->actor.shape.rot.y, 1, 1); + func_80884D04(this, play); + in = (EnIn*)Actor_Spawn(&play->actorCtx, play, 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); } - this->actor.shape.rot.z = 0; - this->actor.world.rot.z = this->actor.shape.rot.z; - this->actor.home.rot.z = this->actor.shape.rot.z; - this->unk_3EC = this->actor.world.rot.y; - this->unk_538 = 0; + 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 = OBJ_UM_ANIM_TROT; if (this->unk_1EC & 0x100) { this->colliderCylinder1.base.colType = COLTYPE_HIT3; @@ -906,57 +924,55 @@ void EnHorse_Init(Actor* thisx, GlobalContext* globalCtx2) { this->colliderCylinder2.info.bumper.dmgFlags = 0x10000 | 0x2000 | 0x1000 | 0x800 | 0x20; } } -#else -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/EnHorse_Init.s") -#endif -void func_8087D540(Actor* thisx, GlobalContext* globalCtx) { +// EnHorse_WaitForObject +void func_8087D540(Actor* thisx, PlayState* play) { EnHorse* this = THIS; - if (Object_IsLoaded(&globalCtx->objectCtx, this->bankIndex)) { + if (Object_IsLoaded(&play->objectCtx, this->bankIndex)) { this->actor.objBankIndex = this->bankIndex; - Actor_SetObjectDependency(globalCtx, &this->actor); + Actor_SetObjectDependency(play, &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, + if (this->type == HORSE_TYPE_BANDIT) { + SkelAnime_InitFlex(play, &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, + SkelAnime_InitFlex(play, &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]); + Skin_Init(&play->state, &this->skin, sSkeletonHeaders[this->type], sAnimationHeaders[this->type][0]); } - Animation_PlayOnce(&this->skin.skelAnime, sAnimationHeaders[this->type][this->animationIdx]); + Animation_PlayOnce(&this->skin.skelAnime, sAnimationHeaders[this->type][this->animIndex]); } } -void EnHorse_Destroy(Actor* thisx, GlobalContext* globalCtx) { +void EnHorse_Destroy(Actor* thisx, PlayState* play) { EnHorse* this = THIS; if (this->stateFlags & ENHORSE_DRAW) { - Audio_StopSfxByPos(&this->unk_218); + AudioSfx_StopByPos(&this->unk_218); } - Skin_Free(&globalCtx->state, &this->skin); - Collider_DestroyCylinder(globalCtx, &this->colliderCylinder1); - Collider_DestroyCylinder(globalCtx, &this->colliderCylinder2); - Collider_DestroyJntSph(globalCtx, &this->colliderJntSph); + Skin_Free(&play->state, &this->skin); + Collider_DestroyCylinder(play, &this->colliderCylinder1); + Collider_DestroyCylinder(play, &this->colliderCylinder2); + Collider_DestroyJntSph(play, &this->colliderJntSph); } -void EnHorse_RotateToPlayer(EnHorse* this, GlobalContext* globalCtx) { - EnHorse_RotateToPoint(this, globalCtx, &GET_PLAYER(globalCtx)->actor.world.pos, 0x320); +void EnHorse_RotateToPlayer(EnHorse* this, PlayState* play) { + EnHorse_RotateToPoint(this, play, &GET_PLAYER(play)->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)) { +void EnHorse_Freeze(EnHorse* this, PlayState* play) { + if ((this->action != ENHORSE_ACTION_CS_UPDATE) && (this->action != ENHORSE_ACTION_21) && + (this->action != ENHORSE_ACTION_HBA)) { if (sResetNoInput[this->actor.params] && (this->actor.params != ENHORSE_6)) { - Player* player = GET_PLAYER(globalCtx); + Player* player = GET_PLAYER(play); this->noInputTimerMax = 0; this->noInputTimer = 0; @@ -964,15 +980,15 @@ void EnHorse_Freeze(EnHorse* this, GlobalContext* globalCtx) { player->actor.world.pos.y += 70.0f; } this->prevAction = this->action; - this->action = ENHORSE_ACT_FROZEN; + this->action = ENHORSE_ACTION_FROZEN; this->colliderCylinder1.base.ocFlags1 &= ~OC1_ON; this->colliderCylinder2.base.ocFlags1 &= ~OC1_ON; this->colliderJntSph.base.ocFlags1 &= ~OC1_ON; - this->animationIdx = ENHORSE_ANIM_IDLE; + this->animIndex = ENHORSE_ANIM_IDLE; } } -void EnHorse_Frozen(EnHorse* this, GlobalContext* globalCtx) { +void EnHorse_Frozen(EnHorse* this, PlayState* play) { this->actor.speedXZ = 0.0f; this->noInputTimer--; if (this->noInputTimer < 0) { @@ -985,13 +1001,13 @@ void EnHorse_Frozen(EnHorse* this, GlobalContext* globalCtx) { EnHorse_StartMountedIdleResetAnim(this); } else if (this->actor.params == ENHORSE_11) { this->actor.params = ENHORSE_7; - if (globalCtx->csCtx.state != 0) { + if (play->csCtx.state != CS_STATE_0) { EnHorse_StartMountedIdle(this); } else { this->actor.speedXZ = 8.0f; EnHorse_StartGalloping(this); } - } else if (this->prevAction == ENHORSE_ACT_IDLE) { + } else if (this->prevAction == ENHORSE_ACTION_IDLE) { EnHorse_StartMountedIdle(this); } else { EnHorse_StartMountedIdleResetAnim(this); @@ -1000,9 +1016,9 @@ void EnHorse_Frozen(EnHorse* this, GlobalContext* globalCtx) { if (this->actor.params != ENHORSE_0) { this->actor.params = ENHORSE_0; } - } else if (this->prevAction == ENHORSE_ACT_MOUNTED_TURN) { + } else if (this->prevAction == ENHORSE_ACTION_MOUNTED_IDLE) { EnHorse_ChangeIdleAnimation(this, 0, 0.0f); - } else if (this->prevAction == ENHORSE_ACT_MOUNTED_WALK) { + } else if (this->prevAction == ENHORSE_ACTION_MOUNTED_IDLE_WHINNYING) { EnHorse_ChangeIdleAnimation(this, 0, 0.0f); } else { EnHorse_ChangeIdleAnimation(this, 0, 0.0f); @@ -1010,15 +1026,15 @@ void EnHorse_Frozen(EnHorse* this, GlobalContext* globalCtx) { } } -void EnHorse_UpdateSpeed(EnHorse* this, GlobalContext* globalCtx, f32 brakeDecel, f32 brakeAngle, f32 minStickMag, - f32 decel, f32 baseSpeed, s16 turnSpeed) { +void EnHorse_UpdateSpeed(EnHorse* this, PlayState* play, 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 (!EnHorse_PlayerCanMove(this, play)) { if (this->actor.speedXZ > 8.0f) { this->actor.speedXZ -= decel; } else if (this->actor.speedXZ < 0.0f) { @@ -1027,7 +1043,7 @@ void EnHorse_UpdateSpeed(EnHorse* this, GlobalContext* globalCtx, f32 brakeDecel return; } - baseSpeed *= EnHorse_SlopeSpeedMultiplier(this, globalCtx); + baseSpeed *= EnHorse_SlopeSpeedMultiplier(this, play); EnHorse_StickDirection(&this->curStick, &stickMag, &stickAngle); if (Math_CosS(stickAngle) <= brakeAngle) { @@ -1049,14 +1065,14 @@ void EnHorse_UpdateSpeed(EnHorse* this, GlobalContext* globalCtx, f32 brakeDecel if (this->stateFlags & ENHORSE_BOOST) { if ((16 - this->boostTimer) > 0) { this->actor.speedXZ = - (((EnHorse_SlopeSpeedMultiplier(this, globalCtx) * this->boostSpeed) - this->actor.speedXZ) / + (((EnHorse_SlopeSpeedMultiplier(this, play) * this->boostSpeed) - this->actor.speedXZ) / (16.0f - this->boostTimer)) + this->actor.speedXZ; } else { - this->actor.speedXZ = EnHorse_SlopeSpeedMultiplier(this, globalCtx) * this->boostSpeed; + this->actor.speedXZ = EnHorse_SlopeSpeedMultiplier(this, play) * this->boostSpeed; } - if ((EnHorse_SlopeSpeedMultiplier(this, globalCtx) * this->boostSpeed) <= this->actor.speedXZ) { + if ((EnHorse_SlopeSpeedMultiplier(this, play) * this->boostSpeed) <= this->actor.speedXZ) { this->stateFlags &= ~ENHORSE_BOOST; this->stateFlags |= ENHORSE_BOOST_DECEL; } @@ -1101,14 +1117,14 @@ void EnHorse_StartMountedIdleResetAnim(EnHorse* this) { void EnHorse_StartMountedIdle(EnHorse* this) { f32 curFrame; - this->action = ENHORSE_ACT_MOUNTED_TURN; - this->animationIdx = ENHORSE_ANIM_IDLE; + this->action = ENHORSE_ACTION_MOUNTED_IDLE; + this->animIndex = ENHORSE_ANIM_IDLE; - if (((this->curFrame > 35.0f) && (this->type == HORSE_EPONA)) || - ((this->curFrame > 28.0f) && (this->type == HORSE_HNI))) { + if (((this->curFrame > 35.0f) && (this->type == HORSE_TYPE_EPONA)) || + ((this->curFrame > 28.0f) && (this->type == HORSE_TYPE_HNI))) { if (!(this->stateFlags & ENHORSE_SANDDUST_SOUND)) { this->stateFlags |= ENHORSE_SANDDUST_SOUND; - if (this->type == HORSE_2) { + if (this->type == HORSE_TYPE_2) { Audio_PlaySfxAtPos(&this->actor.projectedPos, NA_SE_EV_KID_HORSE_SANDDUST); } else { Audio_PlaySfxAtPos(&this->actor.projectedPos, NA_SE_EV_KID_HORSE_SANDDUST); @@ -1116,18 +1132,18 @@ void EnHorse_StartMountedIdle(EnHorse* this) { } } 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); + Animation_Change(&this->skin.skelAnime, sAnimationHeaders[this->type][this->animIndex], 1.0f, curFrame, + Animation_GetLastFrame(sAnimationHeaders[this->type][this->animIndex]), ANIMMODE_ONCE, -3.0f); } -void EnHorse_MountedIdle(EnHorse* this, GlobalContext* globalCtx) { +void EnHorse_MountedIdle(EnHorse* this, PlayState* play) { 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 (EnHorse_PlayerCanMove(this, play) == true) { if (Math_CosS(angle) <= -0.5f) { EnHorse_StartReversingInterruptable(this); } else if (Math_CosS(angle) <= 0.7071f) { @@ -1147,19 +1163,19 @@ void EnHorse_MountedIdle(EnHorse* this, GlobalContext* globalCtx) { void EnHorse_MountedIdleAnim(EnHorse* this) { this->skin.skelAnime.curFrame = 0.0f; - EnHorse_MountedIdleWhinney(this); + EnHorse_MountedIdleWhinny(this); } -void EnHorse_MountedIdleWhinney(EnHorse* this) { +void EnHorse_MountedIdleWhinny(EnHorse* this) { f32 curFrame; - this->action = ENHORSE_ACT_MOUNTED_WALK; - this->animationIdx = ENHORSE_ANIM_WHINNEY; + this->action = ENHORSE_ACTION_MOUNTED_IDLE_WHINNYING; + this->animIndex = ENHORSE_ANIM_WHINNY; curFrame = this->skin.skelAnime.curFrame; - Animation_Change(&this->skin.skelAnime, sAnimationHeaders[this->type][this->animationIdx], 1.0f, curFrame, + Animation_Change(&this->skin.skelAnime, sAnimationHeaders[this->type][this->animIndex], 1.0f, curFrame, Animation_GetLastFrame(sAnimationHeaders[this->type][1]), ANIMMODE_ONCE, -3.0f); if (this->stateFlags & ENHORSE_DRAW) { - if (this->type == HORSE_2) { + if (this->type == HORSE_TYPE_2) { Audio_PlaySfxAtPos(&this->unk_218, NA_SE_EV_KID_HORSE_GROAN); } else { Audio_PlaySfxAtPos(&this->unk_218, NA_SE_EV_HORSE_GROAN); @@ -1167,14 +1183,14 @@ void EnHorse_MountedIdleWhinney(EnHorse* this) { } } -void EnHorse_MountedIdleWhinneying(EnHorse* this, GlobalContext* globalCtx) { +void EnHorse_MountedIdleWhinnying(EnHorse* this, PlayState* play) { 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 (EnHorse_PlayerCanMove(this, play) == true) { if (Math_CosS(stickAngle) <= -0.5f) { EnHorse_StartReversingInterruptable(this); } else if (Math_CosS(stickAngle) <= 0.7071f) { @@ -1193,24 +1209,24 @@ void EnHorse_MountedIdleWhinneying(EnHorse* this, GlobalContext* globalCtx) { } void EnHorse_StartTurning(EnHorse* this) { - this->action = ENHORSE_ACT_MOUNTED_TROT; + this->action = ENHORSE_ACTION_MOUNTED_TURN; this->soundTimer = 0; - this->animationIdx = ENHORSE_ANIM_WALK; - Animation_Change(&this->skin.skelAnime, sAnimationHeaders[this->type][this->animationIdx], 1.0f, 0.0f, + this->animIndex = ENHORSE_ANIM_WALK; + Animation_Change(&this->skin.skelAnime, sAnimationHeaders[this->type][this->animIndex], 1.0f, 0.0f, Animation_GetLastFrame(sAnimationHeaders[this->type][4]), ANIMMODE_ONCE, -3.0f); } -void EnHorse_MountedTurn(EnHorse* this, GlobalContext* globalCtx) { +void EnHorse_MountedTurn(EnHorse* this, PlayState* play) { f32 stickMag; s16 clampedYaw; s16 stickAngle; this->actor.speedXZ = 0.0f; EnHorse_PlayWalkingSound(this); - if (EnHorse_PlayerCanMove(this, globalCtx) == true) { + if (EnHorse_PlayerCanMove(this, play) == true) { EnHorse_StickDirection(&this->curStick, &stickMag, &stickAngle); if (stickMag > 10.0f) { - if (!EnHorse_PlayerCanMove(this, globalCtx)) { + if (!EnHorse_PlayerCanMove(this, play)) { EnHorse_StartMountedIdleResetAnim(this); } else if (Math_CosS(stickAngle) <= -0.5f) { EnHorse_StartReversingInterruptable(this); @@ -1225,7 +1241,7 @@ void EnHorse_MountedTurn(EnHorse* this, GlobalContext* globalCtx) { } if (SkelAnime_Update(&this->skin.skelAnime)) { - if (EnHorse_PlayerCanMove(this, globalCtx) == true) { + if (EnHorse_PlayerCanMove(this, play) == true) { if (Math_CosS(stickAngle) <= 0.7071f) { EnHorse_StartTurning(this); } else { @@ -1256,23 +1272,23 @@ void EnHorse_StartWalkingInterruptable(EnHorse* this) { } void EnHorse_StartWalking(EnHorse* this) { - this->action = ENHORSE_ACT_MOUNTED_GALLOP; + this->action = ENHORSE_ACTION_MOUNTED_WALK; this->soundTimer = 0; - this->animationIdx = ENHORSE_ANIM_WALK; + this->animIndex = ENHORSE_ANIM_WALK; this->waitTimer = 0; - Animation_Change(&this->skin.skelAnime, sAnimationHeaders[this->type][this->animationIdx], 1.0f, 0.0f, + Animation_Change(&this->skin.skelAnime, sAnimationHeaders[this->type][this->animIndex], 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->action = ENHORSE_ACTION_MOUNTED_WALK; this->soundTimer = 0; - this->animationIdx = ENHORSE_ANIM_WALK; + this->animIndex = ENHORSE_ANIM_WALK; this->waitTimer = 0; - Animation_PlayOnce(&this->skin.skelAnime, sAnimationHeaders[this->type][this->animationIdx]); + Animation_PlayOnce(&this->skin.skelAnime, sAnimationHeaders[this->type][this->animIndex]); } -void EnHorse_MountedWalk(EnHorse* this, GlobalContext* globalCtx) { +void EnHorse_MountedWalk(EnHorse* this, PlayState* play) { f32 stickMag; s16 stickAngle; @@ -1281,7 +1297,7 @@ void EnHorse_MountedWalk(EnHorse* this, GlobalContext* globalCtx) { 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); + EnHorse_UpdateSpeed(this, play, 0.3f, -0.5f, 10.0f, 0.06f, 3.0f, 0x320); } else { this->actor.speedXZ = 3.0f; } @@ -1328,23 +1344,23 @@ void EnHorse_MountedWalk(EnHorse* this, GlobalContext* globalCtx) { } 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); + this->action = ENHORSE_ACTION_MOUNTED_TROT; + this->animIndex = ENHORSE_ANIM_TROT; + Animation_Change(&this->skin.skelAnime, sAnimationHeaders[this->type][this->animIndex], 1.0f, 0.0f, + Animation_GetLastFrame(sAnimationHeaders[this->type][this->animIndex]), ANIMMODE_ONCE, -3.0f); } void 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]); + this->action = ENHORSE_ACTION_MOUNTED_TROT; + this->animIndex = ENHORSE_ANIM_TROT; + Animation_PlayOnce(&this->skin.skelAnime, sAnimationHeaders[this->type][this->animIndex]); } -void EnHorse_MountedTrot(EnHorse* this, GlobalContext* globalCtx) { +void EnHorse_MountedTrot(EnHorse* this, PlayState* play) { f32 stickMag; s16 stickAngle; - EnHorse_UpdateSpeed(this, globalCtx, 0.3f, -0.5f, 10.0f, 0.06f, 6.0f, 800); + EnHorse_UpdateSpeed(this, play, 0.3f, -0.5f, 10.0f, 0.06f, 6.0f, 800); EnHorse_StickDirection(&this->curStick, &stickMag, &stickAngle); if (this->actor.speedXZ < 3.0f) { EnHorse_StartWalkingInterruptable(this); @@ -1354,7 +1370,7 @@ void EnHorse_MountedTrot(EnHorse* this, GlobalContext* globalCtx) { if (SkelAnime_Update(&this->skin.skelAnime)) { func_8087C178(this); - func_8013ECE0(0.0f, 60, 8, 255); + Rumble_Request(0.0f, 60, 8, 255); if (this->actor.speedXZ >= 6.0f) { EnHorse_StartGallopingInterruptable(this); } else if (this->actor.speedXZ < 3.0f) { @@ -1372,43 +1388,43 @@ void EnHorse_StartGallopingInterruptable(EnHorse* this) { } void EnHorse_StartGalloping(EnHorse* this) { - this->action = ENHORSE_ACT_STOPPING; - this->animationIdx = ENHORSE_ANIM_GALLOP; + this->action = ENHORSE_ACTION_MOUNTED_GALLOP; + this->animIndex = 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); + Animation_Change(&this->skin.skelAnime, sAnimationHeaders[this->type][this->animIndex], 1.0f, 0.0f, + Animation_GetLastFrame(sAnimationHeaders[this->type][this->animIndex]), ANIMMODE_ONCE, -3.0f); } void EnHorse_MountedGallopReset(EnHorse* this) { this->noInputTimer = 0; this->noInputTimerMax = 0; - this->action = ENHORSE_ACT_STOPPING; - this->animationIdx = ENHORSE_ANIM_GALLOP; + this->action = ENHORSE_ACTION_MOUNTED_GALLOP; + this->animIndex = ENHORSE_ANIM_GALLOP; this->unk_230 = 0; - Animation_PlayOnce(&this->skin.skelAnime, sAnimationHeaders[this->type][this->animationIdx]); + Animation_PlayOnce(&this->skin.skelAnime, sAnimationHeaders[this->type][this->animIndex]); } -void EnHorse_JumpLanding(EnHorse* this, GlobalContext* globalCtx) { +void EnHorse_JumpLanding(EnHorse* this, PlayState* play) { Vec3s* jointTable; f32 y; - this->action = ENHORSE_ACT_STOPPING; - this->animationIdx = ENHORSE_ANIM_GALLOP; - Animation_PlayOnce(&this->skin.skelAnime, sAnimationHeaders[this->type][this->animationIdx]); + this->action = ENHORSE_ACTION_MOUNTED_GALLOP; + this->animIndex = ENHORSE_ANIM_GALLOP; + Animation_PlayOnce(&this->skin.skelAnime, sAnimationHeaders[this->type][this->animIndex]); 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) { +void EnHorse_MountedGallop(EnHorse* this, PlayState* play) { 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); + EnHorse_UpdateSpeed(this, play, 0.3f, -0.5f, 10.0f, 0.06f, 8.0f, 800); } else if (this->noInputTimer > 0) { this->noInputTimer--; this->actor.speedXZ = 8.0f; @@ -1422,10 +1438,10 @@ void EnHorse_MountedGallop(EnHorse* this, GlobalContext* globalCtx) { if (SkelAnime_Update(&this->skin.skelAnime)) { func_8087C1C0(this); - func_8013ECE0(0.0f, 120, 8, 255); - if (EnHorse_PlayerCanMove(this, globalCtx) == true) { + Rumble_Request(0.0f, 120, 8, 255); + if (EnHorse_PlayerCanMove(this, play) == true) { if ((stickMag >= 10.0f) && (Math_CosS(stickAngle) <= -0.5f)) { - EnHorse_StartBraking(this, globalCtx); + EnHorse_StartBraking(this, play); } else if (this->actor.speedXZ < 6.0f) { EnHorse_StartTrotting(this); } else { @@ -1438,19 +1454,19 @@ void EnHorse_MountedGallop(EnHorse* this, GlobalContext* globalCtx) { } void EnHorse_StartRearing(EnHorse* this) { - this->action = ENHORSE_ACT_REVERSE; - this->animationIdx = ENHORSE_ANIM_REARING; + this->action = ENHORSE_ACTION_MOUNTED_REARING; + this->animIndex = ENHORSE_ANIM_REARING; - if (sAnimationHeaders[this->type][this->animationIdx] == NULL) { + if (sAnimationHeaders[this->type][this->animIndex] == NULL) { if (Rand_ZeroOne() > 0.5f) { if (this->stateFlags & ENHORSE_DRAW) { - if (this->type == HORSE_2) { + if (this->type == HORSE_TYPE_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); + Rumble_Request(0.0f, 180, 20, 100); this->stateFlags &= ~ENHORSE_STOPPING_NEIGH_SOUND; } EnHorse_StartMountedIdleResetAnim(this); @@ -1458,19 +1474,19 @@ void EnHorse_StartRearing(EnHorse* this) { this->stateFlags &= ~ENHORSE_LAND2_SOUND; if (this->stateFlags & ENHORSE_DRAW) { - if (this->type == HORSE_2) { + if (this->type == HORSE_TYPE_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); + Rumble_Request(0.0f, 180, 20, 100); + Animation_Change(&this->skin.skelAnime, sAnimationHeaders[this->type][this->animIndex], 1.0f, 0.0f, + Animation_GetLastFrame(sAnimationHeaders[this->type][this->animIndex]), ANIMMODE_ONCE, -3.0f); } -void EnHorse_MountedRearing(EnHorse* this, GlobalContext* globalCtx) { +void EnHorse_MountedRearing(EnHorse* this, PlayState* play) { f32 stickMag; s16 stickAngle; @@ -1478,19 +1494,19 @@ void EnHorse_MountedRearing(EnHorse* this, GlobalContext* globalCtx) { if (this->curFrame > 25.0f) { if (!(this->stateFlags & ENHORSE_LAND2_SOUND)) { this->stateFlags |= ENHORSE_LAND2_SOUND; - if (this->type == HORSE_2) { + if (this->type == HORSE_TYPE_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); + Rumble_Request(0.0f, 180, 20, 100); } } EnHorse_StickDirection(&this->curStick, &stickMag, &stickAngle); if (SkelAnime_Update(&this->skin.skelAnime)) { - if (EnHorse_PlayerCanMove(this, globalCtx) == true) { + if (EnHorse_PlayerCanMove(this, play) == true) { if (this->stateFlags & ENHORSE_FORCE_REVERSING) { this->noInputTimer = 100; this->noInputTimerMax = 100; @@ -1512,37 +1528,37 @@ void EnHorse_MountedRearing(EnHorse* this, GlobalContext* globalCtx) { } } -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) { +void EnHorse_StartBraking(EnHorse* this, PlayState* play) { + this->action = ENHORSE_ACTION_STOPPING; + this->animIndex = ENHORSE_ANIM_STOPPING; + if (sAnimationHeaders[this->type][this->animIndex] == NULL) { if (Rand_ZeroOne() > 0.5f) { if (this->stateFlags & ENHORSE_DRAW) { - if (this->type == HORSE_2) { + if (this->type == HORSE_TYPE_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); + Rumble_Request(0.0f, 180, 20, 100); this->stateFlags &= ~ENHORSE_STOPPING_NEIGH_SOUND; } EnHorse_StartMountedIdleResetAnim(this); } - if (this->type == HORSE_2) { + if (this->type == HORSE_TYPE_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); + Animation_Change(&this->skin.skelAnime, sAnimationHeaders[this->type][this->animIndex], 1.5f, 0.0f, + Animation_GetLastFrame(sAnimationHeaders[this->type][this->animIndex]), ANIMMODE_ONCE, -3.0f); this->stateFlags |= ENHORSE_STOPPING_NEIGH_SOUND; this->stateFlags &= ~ENHORSE_BOOST; } -void EnHorse_Stopping(EnHorse* this, GlobalContext* globalCtx) { +void EnHorse_Stopping(EnHorse* this, PlayState* play) { if (this->actor.speedXZ > 0.0f) { this->actor.speedXZ -= 0.6f; if (this->actor.speedXZ < 0.0f) { @@ -1553,15 +1569,15 @@ void EnHorse_Stopping(EnHorse* this, GlobalContext* globalCtx) { 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))) { + ((gSaveContext.save.entrance != ENTRANCE(ROMANI_RANCH, 0)) || !Cutscene_GetSceneSetupIndex(play))) { if (this->stateFlags & ENHORSE_DRAW) { - if (this->type == HORSE_2) { + if (this->type == HORSE_TYPE_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); + Rumble_Request(0.0f, 180, 20, 100); this->stateFlags &= ~ENHORSE_STOPPING_NEIGH_SOUND; } else { EnHorse_StartMountedIdleResetAnim(this); @@ -1593,22 +1609,22 @@ void EnHorse_StartReversingInterruptable(EnHorse* this) { } void EnHorse_StartReversing(EnHorse* this) { - this->action = ENHORSE_ACT_HIGH_JUMP; - this->animationIdx = ENHORSE_ANIM_WALK; + this->action = ENHORSE_ACTION_REVERSE; + this->animIndex = 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); + Animation_Change(&this->skin.skelAnime, sAnimationHeaders[this->type][this->animIndex], 1.0f, 0.0f, + Animation_GetLastFrame(sAnimationHeaders[this->type][this->animIndex]), ANIMMODE_LOOP, -3.0f); } -void EnHorse_Reverse(EnHorse* this, GlobalContext* globalCtx) { +void EnHorse_Reverse(EnHorse* this, PlayState* play) { f32 stickMag; s16 stickAngle; s16 turnAmount; - Player* player = GET_PLAYER(globalCtx); + Player* player = GET_PLAYER(play); EnHorse_PlayWalkingSound(this); EnHorse_StickDirection(&this->curStick, &stickMag, &stickAngle); - if (EnHorse_PlayerCanMove(this, globalCtx) == true) { + if (EnHorse_PlayerCanMove(this, play) == true) { if ((this->noInputTimerMax == 0) || ((this->noInputTimer > 0) && (this->noInputTimer < (this->noInputTimerMax - 20)))) { if ((stickMag < 10.0f) && (this->noInputTimer <= 0)) { @@ -1626,8 +1642,8 @@ void EnHorse_Reverse(EnHorse* this, GlobalContext* globalCtx) { } 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)) { + } else if ((player->actor.flags & ACTOR_FLAG_100) || (play->csCtx.state != CS_STATE_0) || + (ActorCutscene_GetCurrentIndex() != -1) || (player->stateFlags1 & PLAYER_STATE1_20)) { EnHorse_StartMountedIdleResetAnim(this); this->actor.speedXZ = 0.0f; return; @@ -1651,7 +1667,7 @@ void EnHorse_Reverse(EnHorse* this, GlobalContext* globalCtx) { 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)) { + (EnHorse_PlayerCanMove(this, play) == true)) { if ((stickMag > 10.0f) && (Math_CosS(stickAngle) <= -0.5f)) { this->noInputTimerMax = 0; EnHorse_StartReversingInterruptable(this); @@ -1664,21 +1680,21 @@ void EnHorse_Reverse(EnHorse* this, GlobalContext* globalCtx) { } } -void EnHorse_LowJumpInit(EnHorse* this, GlobalContext* globalCtx) { +void EnHorse_LowJumpInit(EnHorse* this, PlayState* play) { this->skin.skelAnime.curFrame = 0.0f; - EnHorse_StartLowJump(this, globalCtx); + EnHorse_StartLowJump(this, play); } -void EnHorse_StartLowJump(EnHorse* this, GlobalContext* globalCtx) { +void EnHorse_StartLowJump(EnHorse* this, PlayState* play) { f32 curFrame; Vec3s* jointTable; f32 y; - this->action = ENHORSE_ACT_BRIDGE_JUMP; - this->animationIdx = ENHORSE_ANIM_LOW_JUMP; + this->action = ENHORSE_ACTION_LOW_JUMP; + this->animIndex = 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); + Animation_Change(&this->skin.skelAnime, sAnimationHeaders[this->type][this->animIndex], 1.5f, curFrame, + Animation_GetLastFrame(sAnimationHeaders[this->type][this->animIndex]), ANIMMODE_ONCE, -3.0f); this->postDrawFunc = NULL; this->jumpStartY = this->actor.world.pos.y; this->actor.gravity = 0.0f; @@ -1688,18 +1704,18 @@ void EnHorse_StartLowJump(EnHorse* this, GlobalContext* globalCtx) { y = jointTable->y; this->riderPos.y -= ((y * 0.01f) * this->unk_528) * 0.01f; - if (this->type == HORSE_2) { + if (this->type == HORSE_TYPE_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); + Rumble_Request(0.0f, 170, 10, 10); } void EnHorse_Stub1(EnHorse* this) { } -void EnHorse_LowJump(EnHorse* this, GlobalContext* globalCtx) { +void EnHorse_LowJump(EnHorse* this, PlayState* play) { Vec3f pad; f32 temp_f0; f32 curFrame; @@ -1717,8 +1733,7 @@ void EnHorse_LowJump(EnHorse* this, GlobalContext* globalCtx) { 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); + temp_f0 = BgCheck_EntityRaycastFloor5_2(play, &play->colCtx, &colPoly, &floorBgId, &this->actor, &pos); if ((this->actor.floorHeight - 120.0f) < temp_f0) { this->actor.floorHeight = temp_f0; this->actor.floorPoly = colPoly; @@ -1748,34 +1763,34 @@ void EnHorse_LowJump(EnHorse* this, GlobalContext* globalCtx) { 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) { + if (this->type == HORSE_TYPE_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); + Rumble_Request(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); + EnHorse_JumpLanding(this, play); } } -void EnHorse_HighJumpInit(EnHorse* this, GlobalContext* globalCtx) { +void EnHorse_HighJumpInit(EnHorse* this, PlayState* play) { this->skin.skelAnime.curFrame = 0.0f; - EnHorse_StartHighJump(this, globalCtx); + EnHorse_StartHighJump(this, play); } -void EnHorse_StartHighJump(EnHorse* this, GlobalContext* globalCtx) { +void EnHorse_StartHighJump(EnHorse* this, PlayState* play) { f32 curFrame; Vec3s* jointTable; f32 y; - this->action = ENHORSE_ACT_CS_UPDATE; - this->animationIdx = ENHORSE_ANIM_HIGH_JUMP; + this->action = ENHORSE_ACTION_HIGH_JUMP; + this->animIndex = 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); + Animation_Change(&this->skin.skelAnime, sAnimationHeaders[this->type][this->animIndex], 1.5f, curFrame, + Animation_GetLastFrame(sAnimationHeaders[this->type][this->animIndex]), ANIMMODE_ONCE, -3.0f); this->postDrawFunc = NULL; this->jumpStartY = this->actor.world.pos.y; @@ -1787,18 +1802,18 @@ void EnHorse_StartHighJump(EnHorse* this, GlobalContext* globalCtx) { this->riderPos.y -= ((y * 0.01f) * this->unk_528) * 0.01f; this->stateFlags |= ENHORSE_CALC_RIDER_POS; - if (this->type == HORSE_2) { + if (this->type == HORSE_TYPE_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); + Rumble_Request(0.0f, 170, 10, 10); } void EnHorse_Stub2(EnHorse* this) { } -void EnHorse_HighJump(EnHorse* this, GlobalContext* globalCtx) { +void EnHorse_HighJump(EnHorse* this, PlayState* play) { Vec3f pad; f32 temp_f0; f32 curFrame; @@ -1816,8 +1831,7 @@ void EnHorse_HighJump(EnHorse* this, GlobalContext* globalCtx) { 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); + temp_f0 = BgCheck_EntityRaycastFloor5_2(play, &play->colCtx, &colPoly, &floorBgId, &this->actor, &pos); if ((this->actor.floorHeight - 120.0f) < temp_f0) { this->actor.floorHeight = temp_f0; this->actor.floorPoly = colPoly; @@ -1846,17 +1860,17 @@ void EnHorse_HighJump(EnHorse* this, GlobalContext* globalCtx) { 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) { + if (this->type == HORSE_TYPE_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); + Rumble_Request(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); + func_800B1598(play, 25.0f, &this->actor.world.pos); + EnHorse_JumpLanding(this, play); } } @@ -1864,17 +1878,17 @@ 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->action = ENHORSE_ACTION_INACTIVE; + this->animIndex = 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)) { +void EnHorse_Inactive(EnHorse* this, PlayState* play) { + if ((D_801BDAA4 != 0) && (this->type == HORSE_TYPE_2)) { D_801BDAA4 = 0; - if (EnHorse_Spawn(this, globalCtx)) { - if (this->type == HORSE_2) { + if (EnHorse_Spawn(this, play)) { + if (this->type == HORSE_TYPE_2) { Audio_PlaySfxAtPos(&this->actor.projectedPos, NA_SE_EV_KID_HORSE_NEIGH); } this->stateFlags &= ~ENHORSE_INACTIVE; @@ -1883,7 +1897,7 @@ void EnHorse_Inactive(EnHorse* this, GlobalContext* globalCtx) { if (!(this->stateFlags & ENHORSE_INACTIVE)) { this->followTimer = 0; - EnHorse_SetFollowAnimation(this, globalCtx); + EnHorse_SetFollowAnimation(this, play); this->actor.params = ENHORSE_0; this->colliderCylinder1.base.ocFlags1 |= OC1_ON; this->colliderCylinder2.base.ocFlags1 |= OC1_ON; @@ -1892,10 +1906,10 @@ void EnHorse_Inactive(EnHorse* this, GlobalContext* globalCtx) { } void EnHorse_PlayIdleAnimation(EnHorse* this, s32 anim, f32 morphFrames, f32 startFrames) { - this->action = ENHORSE_ACT_IDLE; + this->action = ENHORSE_ACTION_IDLE; this->actor.speedXZ = 0.0f; - if ((anim != ENHORSE_ANIM_IDLE) && (anim != ENHORSE_ANIM_WHINNEY) && (anim != ENHORSE_ANIM_REARING)) { + if ((anim != ENHORSE_ANIM_IDLE) && (anim != ENHORSE_ANIM_WHINNY) && (anim != ENHORSE_ANIM_REARING)) { anim = ENHORSE_ANIM_IDLE; } @@ -1903,22 +1917,22 @@ void EnHorse_PlayIdleAnimation(EnHorse* this, s32 anim, f32 morphFrames, f32 sta anim = ENHORSE_ANIM_IDLE; } - if (anim != this->animationIdx) { - this->animationIdx = anim; + if (anim != this->animIndex) { + this->animIndex = anim; if (anim == ENHORSE_ANIM_IDLE) { this->stateFlags &= ~ENHORSE_SANDDUST_SOUND; } else { - if (this->animationIdx == ENHORSE_ANIM_WHINNEY) { + if (this->animIndex == ENHORSE_ANIM_WHINNY) { if (this->stateFlags & ENHORSE_DRAW) { - if (this->type == HORSE_2) { + if (this->type == HORSE_TYPE_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) { + } else if (this->animIndex == ENHORSE_ANIM_REARING) { if (this->stateFlags & ENHORSE_DRAW) { - if (this->type == HORSE_2) { + if (this->type == HORSE_TYPE_2) { Audio_PlaySfxAtPos(&this->unk_218, NA_SE_EV_KID_HORSE_NEIGH); } else { Audio_PlaySfxAtPos(&this->unk_218, NA_SE_EV_HORSE_NEIGH); @@ -1927,8 +1941,8 @@ void EnHorse_PlayIdleAnimation(EnHorse* this, s32 anim, f32 morphFrames, f32 sta 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, + Animation_Change(&this->skin.skelAnime, sAnimationHeaders[this->type][this->animIndex], 1.0f, startFrames, + Animation_GetLastFrame(sAnimationHeaders[this->type][this->animIndex]), ANIMMODE_ONCE, morphFrames); } } @@ -1938,8 +1952,8 @@ void EnHorse_ChangeIdleAnimation(EnHorse* this, s32 anim, f32 morphFrames) { } void EnHorse_ResetIdleAnimation(EnHorse* this) { - this->animationIdx = ENHORSE_ANIM_WALK; - EnHorse_PlayIdleAnimation(this, this->animationIdx, 0.0f, 0.0f); + this->animIndex = ENHORSE_ANIM_WALK; + EnHorse_PlayIdleAnimation(this, this->animIndex, 0.0f, 0.0f); } void EnHorse_StartIdleRidable(EnHorse* this) { @@ -1947,24 +1961,24 @@ void EnHorse_StartIdleRidable(EnHorse* this) { this->stateFlags &= ~ENHORSE_UNRIDEABLE; } -void EnHorse_Idle(EnHorse* this, GlobalContext* globalCtx) { +void EnHorse_Idle(EnHorse* this, PlayState* play) { this->actor.speedXZ = 0.0f; - EnHorse_IdleAnimSounds(this, globalCtx); + EnHorse_IdleAnimSounds(this, play); - if ((D_801BDAA4 != 0) && (this->type == HORSE_2)) { + if ((D_801BDAA4 != 0) && (this->type == HORSE_TYPE_2)) { D_801BDAA4 = 0; - if (!func_8087C38C(globalCtx, this, &this->actor.world.pos)) { - if (EnHorse_Spawn(this, globalCtx)) { - if (this->type == HORSE_2) { + if (!func_8087C38C(play, this, &this->actor.world.pos)) { + if (EnHorse_Spawn(this, play)) { + if (this->type == HORSE_TYPE_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); + EnHorse_SetFollowAnimation(this, play); } } else { - if (this->type == HORSE_2) { + if (this->type == HORSE_TYPE_2) { Audio_PlaySfxAtPos(&this->actor.projectedPos, NA_SE_EV_KID_HORSE_NEIGH); } else { Audio_PlaySfxAtPos(&this->actor.projectedPos, NA_SE_EV_HORSE_NEIGH); @@ -1975,43 +1989,43 @@ void EnHorse_Idle(EnHorse* this, GlobalContext* globalCtx) { } if (SkelAnime_Update(&this->skin.skelAnime)) { - s32 idleAnimIdx = 0; + s32 idleAnimIndex = 0; - if (this->animationIdx != 0) { - if (this->animationIdx == 1) { - idleAnimIdx = 1; - } else if (this->animationIdx == 3) { - idleAnimIdx = 2; + if (this->animIndex != ENHORSE_ANIM_IDLE) { + if (this->animIndex == ENHORSE_ANIM_WHINNY) { + idleAnimIndex = 1; + } else if (this->animIndex == ENHORSE_ANIM_REARING) { + idleAnimIndex = 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); + EnHorse_PlayIdleAnimation(this, sIdleAnimIndices[((Rand_ZeroOne() > 0.5f) ? 0 : 1) + idleAnimIndex * 2], 0.0f, + 0.0f); } } void EnHorse_StartMovingAnimation(EnHorse* this, s32 anim, f32 morphFrames, f32 startFrames) { - this->action = ENHORSE_ACT_FOLLOW_PLAYER; + this->action = ENHORSE_ACTION_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, + if (anim != this->animIndex) { + this->animIndex = anim; + Animation_Change(&this->skin.skelAnime, sAnimationHeaders[this->type][this->animIndex], 1.0f, startFrames, + Animation_GetLastFrame(sAnimationHeaders[this->type][this->animIndex]), 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); + Animation_Change(&this->skin.skelAnime, sAnimationHeaders[this->type][this->animIndex], 1.0f, startFrames, + Animation_GetLastFrame(sAnimationHeaders[this->type][this->animIndex]), ANIMMODE_ONCE, 0.0f); } } -void EnHorse_SetFollowAnimation(EnHorse* this, GlobalContext* globalCtx) { +void EnHorse_SetFollowAnimation(EnHorse* this, PlayState* play) { s32 anim = ENHORSE_ANIM_WALK; - f32 distToPlayer = Actor_XZDistanceBetweenActors(&this->actor, &GET_PLAYER(globalCtx)->actor); + f32 distToPlayer = Actor_XZDistanceBetweenActors(&this->actor, &GET_PLAYER(play)->actor); if (distToPlayer > 400.0f) { anim = ENHORSE_ANIM_GALLOP; @@ -2019,13 +2033,13 @@ void EnHorse_SetFollowAnimation(EnHorse* this, GlobalContext* globalCtx) { anim = ENHORSE_ANIM_TROT; } - if (this->animationIdx == ENHORSE_ANIM_GALLOP) { + if (this->animIndex == ENHORSE_ANIM_GALLOP) { if (distToPlayer > 400.0f) { anim = ENHORSE_ANIM_GALLOP; } else { anim = ENHORSE_ANIM_TROT; } - } else if (this->animationIdx == ENHORSE_ANIM_TROT) { + } else if (this->animIndex == ENHORSE_ANIM_TROT) { if (distToPlayer > 400.0f) { anim = ENHORSE_ANIM_GALLOP; } else if (distToPlayer < 300.0f) { @@ -2033,7 +2047,7 @@ void EnHorse_SetFollowAnimation(EnHorse* this, GlobalContext* globalCtx) { } else { anim = ENHORSE_ANIM_TROT; } - } else if (this->animationIdx == ENHORSE_ANIM_WALK) { + } else if (this->animIndex == ENHORSE_ANIM_WALK) { if (distToPlayer > 300.0f) { anim = ENHORSE_ANIM_TROT; } else { @@ -2044,19 +2058,19 @@ void EnHorse_SetFollowAnimation(EnHorse* this, GlobalContext* globalCtx) { EnHorse_StartMovingAnimation(this, anim, -3.0f, 0.0f); } -void EnHorse_FollowPlayer(EnHorse* this, GlobalContext* globalCtx) { +void EnHorse_FollowPlayer(EnHorse* this, PlayState* play) { f32 distToPlayer; D_801BDAA4 = 0; - distToPlayer = Actor_XZDistanceBetweenActors(&this->actor, &GET_PLAYER(globalCtx)->actor); + distToPlayer = Actor_XZDistanceBetweenActors(&this->actor, &GET_PLAYER(play)->actor); if (((this->playerDir == PLAYER_DIR_BACK_R) || (this->playerDir == PLAYER_DIR_BACK_L)) && (distToPlayer > 300.0f) && !(this->stateFlags & ENHORSE_TURNING_TO_PLAYER)) { f32 angleDiff; - this->animationIdx = ENHORSE_ANIM_REARING; + this->animIndex = ENHORSE_ANIM_REARING; this->stateFlags |= ENHORSE_TURNING_TO_PLAYER; - this->angleToPlayer = Actor_YawBetweenActors(&this->actor, &GET_PLAYER(globalCtx)->actor); + this->angleToPlayer = Actor_YawBetweenActors(&this->actor, &GET_PLAYER(play)->actor); angleDiff = (f32)this->angleToPlayer - this->actor.world.rot.y; if (angleDiff > 0x7FFF) { @@ -2066,9 +2080,9 @@ void EnHorse_FollowPlayer(EnHorse* this, GlobalContext* globalCtx) { } this->followPlayerTurnSpeed = - angleDiff / Animation_GetLastFrame(sAnimationHeaders[this->type][this->animationIdx]); + angleDiff / Animation_GetLastFrame(sAnimationHeaders[this->type][this->animIndex]); - Animation_PlayOnce(&this->skin.skelAnime, sAnimationHeaders[this->type][this->animationIdx]); + Animation_PlayOnce(&this->skin.skelAnime, sAnimationHeaders[this->type][this->animIndex]); this->skin.skelAnime.playSpeed = 1.0f; this->stateFlags &= ~ENHORSE_LAND2_SOUND; } else if (this->stateFlags & ENHORSE_TURNING_TO_PLAYER) { @@ -2076,24 +2090,24 @@ void EnHorse_FollowPlayer(EnHorse* this, GlobalContext* globalCtx) { 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) { + if (this->type == HORSE_TYPE_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); + EnHorse_RotateToPlayer(this, play); } - if (this->animationIdx == ENHORSE_ANIM_GALLOP) { + if (this->animIndex == ENHORSE_ANIM_GALLOP) { this->actor.speedXZ = 8.0f; this->skin.skelAnime.playSpeed = this->actor.speedXZ * 0.3f; } else { - if (this->animationIdx == ENHORSE_ANIM_TROT) { + if (this->animIndex == ENHORSE_ANIM_TROT) { this->actor.speedXZ = 6.0f; this->skin.skelAnime.playSpeed = this->actor.speedXZ * 0.375f; - } else if (this->animationIdx == ENHORSE_ANIM_WALK) { + } else if (this->animIndex == ENHORSE_ANIM_WALK) { this->actor.speedXZ = 3.0f; EnHorse_PlayWalkingSound(this); this->skin.skelAnime.playSpeed = this->actor.speedXZ * 0.75f; @@ -2108,7 +2122,7 @@ void EnHorse_FollowPlayer(EnHorse* this, GlobalContext* globalCtx) { if (this->followTimer > 300) { EnHorse_StartIdleRidable(this); if (this->stateFlags & ENHORSE_DRAW) { - if (this->type == HORSE_2) { + if (this->type == HORSE_TYPE_2) { Audio_PlaySfxAtPos(&this->unk_218, NA_SE_EV_KID_HORSE_NEIGH); } else { Audio_PlaySfxAtPos(&this->unk_218, NA_SE_EV_HORSE_NEIGH); @@ -2118,9 +2132,9 @@ void EnHorse_FollowPlayer(EnHorse* this, GlobalContext* globalCtx) { } if (SkelAnime_Update(&this->skin.skelAnime)) { - if (this->animationIdx == ENHORSE_ANIM_GALLOP) { + if (this->animIndex == ENHORSE_ANIM_GALLOP) { func_8087C1C0(this); - } else if (this->animationIdx == ENHORSE_ANIM_TROT) { + } else if (this->animIndex == ENHORSE_ANIM_TROT) { func_8087C178(this); } @@ -2129,7 +2143,7 @@ void EnHorse_FollowPlayer(EnHorse* this, GlobalContext* globalCtx) { if (distToPlayer < 100.0f) { EnHorse_StartIdleRidable(this); } else { - EnHorse_SetFollowAnimation(this, globalCtx); + EnHorse_SetFollowAnimation(this, play); } } } @@ -2144,13 +2158,13 @@ void EnHorse_InitIngoHorse(EnHorse* this) { } } -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_SetIngoAnimation(s32 animIndex, f32 curFrame, s32 arg2, s16* animIndexOut) { + *animIndexOut = sIngoAnimIndices[animIndex]; + if (arg2 == ENIN_ANIM_1) { + if (animIndex == ENHORSE_ANIM_TROT) { + *animIndexOut = ENIN_ANIM_4; + } else if (animIndex == ENHORSE_ANIM_GALLOP) { + *animIndexOut = ENIN_ANIM_3; } } } @@ -2159,43 +2173,43 @@ void EnHorse_UpdateIngoHorseAnim(EnHorse* this) { s32 animChanged = false; f32 animSpeed; - this->action = ENHORSE_ACT_INGO_RACE; + this->action = ENHORSE_ACTION_INGO_RACE; this->stateFlags &= ~ENHORSE_SANDDUST_SOUND; if (this->actor.speedXZ == 0.0f) { - if (this->animationIdx != ENHORSE_ANIM_IDLE) { + if (this->animIndex != ENHORSE_ANIM_IDLE) { animChanged = true; } - this->animationIdx = ENHORSE_ANIM_IDLE; + this->animIndex = ENHORSE_ANIM_IDLE; } else if (this->actor.speedXZ <= 3.0f) { - if (this->animationIdx != ENHORSE_ANIM_WALK) { + if (this->animIndex != ENHORSE_ANIM_WALK) { animChanged = true; } - this->animationIdx = ENHORSE_ANIM_WALK; + this->animIndex = ENHORSE_ANIM_WALK; } else if (this->actor.speedXZ <= 6.0f) { - if (this->animationIdx != ENHORSE_ANIM_TROT) { + if (this->animIndex != ENHORSE_ANIM_TROT) { animChanged = true; } - this->animationIdx = ENHORSE_ANIM_TROT; + this->animIndex = ENHORSE_ANIM_TROT; } else { - if (this->animationIdx != ENHORSE_ANIM_GALLOP) { + if (this->animIndex != ENHORSE_ANIM_GALLOP) { animChanged = true; } - this->animationIdx = ENHORSE_ANIM_GALLOP; + this->animIndex = ENHORSE_ANIM_GALLOP; } - if (this->animationIdx == ENHORSE_ANIM_WALK) { + if (this->animIndex == ENHORSE_ANIM_WALK) { animSpeed = this->actor.speedXZ * 0.5f; - } else if (this->animationIdx == ENHORSE_ANIM_TROT) { + } else if (this->animIndex == ENHORSE_ANIM_TROT) { animSpeed = this->actor.speedXZ * 0.25f; - if (this->type == HORSE_2) { + if (this->type == HORSE_TYPE_2) { Audio_PlaySfxAtPos(&this->actor.projectedPos, NA_SE_EV_KID_HORSE_RUN); } else { Audio_PlaySfxAtPos(&this->actor.projectedPos, NA_SE_EV_HORSE_RUN); } - } else if (this->animationIdx == ENHORSE_ANIM_GALLOP) { + } else if (this->animIndex == ENHORSE_ANIM_GALLOP) { animSpeed = this->actor.speedXZ * 0.2f; - if (this->type == HORSE_2) { + if (this->type == HORSE_TYPE_2) { Audio_PlaySfxAtPos(&this->actor.projectedPos, NA_SE_EV_KID_HORSE_RUN); } else { Audio_PlaySfxAtPos(&this->actor.projectedPos, NA_SE_EV_HORSE_RUN); @@ -2205,40 +2219,38 @@ void EnHorse_UpdateIngoHorseAnim(EnHorse* this) { } 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); + Animation_Change(&this->skin.skelAnime, sAnimationHeaders[this->type][this->animIndex], + sPlaybackSpeeds[this->animIndex] * animSpeed * 1.5f, 0.0f, + Animation_GetLastFrame(sAnimationHeaders[this->type][this->animIndex]), 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); + Animation_Change(&this->skin.skelAnime, sAnimationHeaders[this->type][this->animIndex], + sPlaybackSpeeds[this->animIndex] * animSpeed * 1.5f, 0.0f, + Animation_GetLastFrame(sAnimationHeaders[this->type][this->animIndex]), ANIMMODE_ONCE, 0.0f); } } -void EnHorse_UpdateIngoRace(EnHorse* this, GlobalContext* globalCtx) { +void EnHorse_UpdateIngoRace(EnHorse* this, PlayState* play) { f32 playSpeed; - if ((this->animationIdx == ENHORSE_ANIM_IDLE) || (this->animationIdx == ENHORSE_ANIM_WHINNEY)) { - EnHorse_IdleAnimSounds(this, globalCtx); - } else if (this->animationIdx == ENHORSE_ANIM_WALK) { + if ((this->animIndex == ENHORSE_ANIM_IDLE) || (this->animIndex == ENHORSE_ANIM_WHINNY)) { + EnHorse_IdleAnimSounds(this, play); + } else if (this->animIndex == 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) { + if (this->animIndex != ENHORSE_ANIM_IDLE) { EnHorse_UpdateIngoHorseAnim(this); } } - if (this->animationIdx == ENHORSE_ANIM_WALK) { + if (this->animIndex == ENHORSE_ANIM_WALK) { playSpeed = this->actor.speedXZ * 0.5f; - } else if (this->animationIdx == 5) { + } else if (this->animIndex == ENHORSE_ANIM_TROT) { playSpeed = this->actor.speedXZ * 0.25f; - } else if (this->animationIdx == 6) { + } else if (this->animIndex == ENHORSE_ANIM_GALLOP) { playSpeed = this->actor.speedXZ * 0.2f; } else { playSpeed = 1.0f; @@ -2246,37 +2258,37 @@ void EnHorse_UpdateIngoRace(EnHorse* this, GlobalContext* globalCtx) { this->skin.skelAnime.playSpeed = playSpeed; if (SkelAnime_Update(&this->skin.skelAnime) || - ((this->animationIdx == ENHORSE_ANIM_IDLE) && (this->actor.speedXZ != 0.0f))) { + ((this->animIndex == ENHORSE_ANIM_IDLE) && (this->actor.speedXZ != 0.0f))) { EnHorse_UpdateIngoHorseAnim(this); } } -void func_8088126C(EnHorse* this, GlobalContext* globalCtx) { +void func_8088126C(EnHorse* this, PlayState* play) { this->skin.skelAnime.curFrame = 0.0f; - func_80881290(this, globalCtx); + func_80881290(this, play); } -void func_80881290(EnHorse* this, GlobalContext* globalCtx) { +void func_80881290(EnHorse* this, PlayState* play) { f32 curFrame; - this->action = ENHORSE_ACT_MOUNTED_IDLE_WHINNEYING; - this->animationIdx = ENHORSE_ANIM_HIGH_JUMP; + this->action = ENHORSE_ACTION_6; + this->animIndex = 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); + Animation_Change(&this->skin.skelAnime, sAnimationHeaders[this->type][this->animIndex], 1.5f, curFrame, + Animation_GetLastFrame(sAnimationHeaders[this->type][this->animIndex]), 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) { + if (this->type == HORSE_TYPE_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); + Rumble_Request(0.0f, 170, 10, 10); } -void func_80881398(EnHorse* this, GlobalContext* globalCtx) { +void func_80881398(EnHorse* this, PlayState* play) { Vec3s* jointTable; f32 y; s32 animeUpdated; @@ -2308,28 +2320,28 @@ void func_80881398(EnHorse* this, GlobalContext* globalCtx) { if (animeUpdated || ((curFrame > 17.0f) && (this->actor.world.pos.y < ((this->actor.floorHeight - this->actor.velocity.y) + 80.0f)))) { - if (this->type == HORSE_2) { + if (this->type == HORSE_TYPE_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); + Rumble_Request(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); + func_800B1598(play, 25.0f, &this->actor.world.pos); + func_8088159C(this, play); } } -void func_8088159C(EnHorse* this, GlobalContext* globalCtx) { +void func_8088159C(EnHorse* this, PlayState* play) { 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]); + this->action = ENHORSE_ACTION_5; + this->animIndex = ENHORSE_ANIM_GALLOP; + Animation_PlayOnce(&this->skin.skelAnime, sAnimationHeaders[this->type][this->animIndex]); jointTable = this->skin.skelAnime.jointTable; y = jointTable->y; this->riderPos.y += y * 0.01f * this->unk_528 * 0.01f; @@ -2351,43 +2363,43 @@ void func_8088168C(EnHorse* this) { f32 animSpeed; f32 finalAnimSpeed; - this->action = ENHORSE_ACT_MOUNTED_IDLE; + this->action = ENHORSE_ACTION_5; this->stateFlags &= ~ENHORSE_SANDDUST_SOUND; if (this->actor.speedXZ == 0.0f) { - if (this->animationIdx != ENHORSE_ANIM_IDLE) { + if (this->animIndex != ENHORSE_ANIM_IDLE) { animChanged = true; } - this->animationIdx = ENHORSE_ANIM_IDLE; + this->animIndex = ENHORSE_ANIM_IDLE; } else if (this->actor.speedXZ <= 3.0f) { - if (this->animationIdx != ENHORSE_ANIM_WALK) { + if (this->animIndex != ENHORSE_ANIM_WALK) { animChanged = true; } - this->animationIdx = ENHORSE_ANIM_WALK; + this->animIndex = ENHORSE_ANIM_WALK; } else if (this->actor.speedXZ <= 6.0f) { - if (this->animationIdx != ENHORSE_ANIM_TROT) { + if (this->animIndex != ENHORSE_ANIM_TROT) { animChanged = true; } - this->animationIdx = ENHORSE_ANIM_TROT; + this->animIndex = ENHORSE_ANIM_TROT; } else { - if (this->animationIdx != ENHORSE_ANIM_GALLOP) { + if (this->animIndex != ENHORSE_ANIM_GALLOP) { animChanged = true; } - this->animationIdx = ENHORSE_ANIM_GALLOP; + this->animIndex = ENHORSE_ANIM_GALLOP; } - if (this->animationIdx == ENHORSE_ANIM_WALK) { + if (this->animIndex == ENHORSE_ANIM_WALK) { animSpeed = this->actor.speedXZ * 0.5f; - } else if (this->animationIdx == ENHORSE_ANIM_TROT) { + } else if (this->animIndex == ENHORSE_ANIM_TROT) { animSpeed = this->actor.speedXZ * 0.25f; - if (this->type == HORSE_2) { + if (this->type == HORSE_TYPE_2) { Audio_PlaySfxAtPos(&this->actor.projectedPos, NA_SE_EV_KID_HORSE_RUN); } else { Audio_PlaySfxAtPos(&this->actor.projectedPos, NA_SE_EV_HORSE_RUN); } - } else if (this->animationIdx == ENHORSE_ANIM_GALLOP) { + } else if (this->animIndex == ENHORSE_ANIM_GALLOP) { animSpeed = this->actor.speedXZ * 0.2f; - if (this->type == HORSE_2) { + if (this->type == HORSE_TYPE_2) { Audio_PlaySfxAtPos(&this->actor.projectedPos, NA_SE_EV_KID_HORSE_RUN); } else { Audio_PlaySfxAtPos(&this->actor.projectedPos, NA_SE_EV_HORSE_RUN); @@ -2396,60 +2408,58 @@ void func_8088168C(EnHorse* this) { animSpeed = 1.0f; } - finalAnimSpeed = sPlaybackSpeeds[this->animationIdx] * animSpeed * 1.5f; + finalAnimSpeed = sPlaybackSpeeds[this->animIndex] * 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); + Animation_Change(&this->skin.skelAnime, sAnimationHeaders[this->type][this->animIndex], finalAnimSpeed, 0.0f, + Animation_GetLastFrame(sAnimationHeaders[this->type][this->animIndex]), 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); + Animation_Change(&this->skin.skelAnime, sAnimationHeaders[this->type][this->animIndex], finalAnimSpeed, 0.0f, + Animation_GetLastFrame(sAnimationHeaders[this->type][this->animIndex]), ANIMMODE_ONCE, 0.0f); } } -void func_808819D8(EnHorse* this, GlobalContext* globalCtx) { +void func_808819D8(EnHorse* this, PlayState* play) { 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) { + if ((this->animIndex == ENHORSE_ANIM_IDLE) || (this->animIndex == ENHORSE_ANIM_WHINNY)) { + EnHorse_IdleAnimSounds(this, play); + } else if (this->animIndex == 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) { + if (this->animIndex != ENHORSE_ANIM_IDLE) { EnHorse_UpdateIngoHorseAnim(this); } } if (this->actor.params == ENHORSE_4) { - path = &globalCtx->setupPathList[0]; - func_8087B7C0(this, globalCtx, path); + path = &play->setupPathList[0]; + func_8087B7C0(this, play, path); } else if (this->actor.params == ENHORSE_5) { - path = &globalCtx->setupPathList[1]; - func_8087B7C0(this, globalCtx, path); + path = &play->setupPathList[1]; + func_8087B7C0(this, play, path); } if (!this->inRace) { this->actor.speedXZ = 0.0f; - if (this->animationIdx != ENHORSE_ANIM_IDLE) { + if (this->animIndex != ENHORSE_ANIM_IDLE) { func_8088168C(this); } } - if (this->animationIdx == ENHORSE_ANIM_WALK) { + if (this->animIndex == ENHORSE_ANIM_WALK) { animSpeed = this->actor.speedXZ * 0.5f; - } else if (this->animationIdx == ENHORSE_ANIM_TROT) { + } else if (this->animIndex == ENHORSE_ANIM_TROT) { animSpeed = this->actor.speedXZ * 0.25f; - } else if (this->animationIdx == ENHORSE_ANIM_GALLOP) { + } else if (this->animIndex == ENHORSE_ANIM_GALLOP) { animSpeed = this->actor.speedXZ * 0.2f; } else { animSpeed = 1.0f; @@ -2457,26 +2467,26 @@ void func_808819D8(EnHorse* this, GlobalContext* globalCtx) { this->skin.skelAnime.playSpeed = animSpeed; if (SkelAnime_Update(&this->skin.skelAnime) || - ((this->animationIdx == ENHORSE_ANIM_IDLE) && (this->actor.speedXZ != 0.0f))) { + ((this->animIndex == ENHORSE_ANIM_IDLE) && (this->actor.speedXZ != 0.0f))) { func_8088168C(this); } - if ((gSaveContext.save.weekEventReg[92] & (1 | 2 | 4)) == 3) { + if (GET_RACE_FLAGS == 3) { this->rider->unk488 = 7; } else { - EnHorse_SetIngoAnimation(this->animationIdx, this->skin.skelAnime.curFrame, this->unk_394 & 1, + EnHorse_SetIngoAnimation(this->animIndex, 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; +void EnHorse_CsMoveInit(EnHorse* this, PlayState* play, CsCmdActorAction* action) { + this->animIndex = ENHORSE_ANIM_GALLOP; this->cutsceneAction = 1; - Animation_PlayOnceSetSpeed(&this->skin.skelAnime, sAnimationHeaders[this->type][this->animationIdx], + Animation_PlayOnceSetSpeed(&this->skin.skelAnime, sAnimationHeaders[this->type][this->animIndex], this->actor.speedXZ * 0.2f * 1.5f); } -void EnHorse_CsMoveToPoint(EnHorse* this, GlobalContext* globalCtx, CsCmdActorAction* action) { +void EnHorse_CsMoveToPoint(EnHorse* this, PlayState* play, CsCmdActorAction* action) { Vec3f endPos; s32 pad; @@ -2485,7 +2495,7 @@ void EnHorse_CsMoveToPoint(EnHorse* this, GlobalContext* globalCtx, CsCmdActorAc endPos.z = action->endPos.z; if (Math3D_Distance(&endPos, &this->actor.world.pos) > 8.0f) { - EnHorse_RotateToPoint(this, globalCtx, &endPos, 0x320); + EnHorse_RotateToPoint(this, play, &endPos, 0x320); this->actor.speedXZ = 8.0f; this->skin.skelAnime.playSpeed = this->actor.speedXZ * 0.3f; } else { @@ -2495,26 +2505,26 @@ void EnHorse_CsMoveToPoint(EnHorse* this, GlobalContext* globalCtx, CsCmdActorAc 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], + Rumble_Request(0.0f, 120, 8, 255); + Animation_PlayOnceSetSpeed(&this->skin.skelAnime, sAnimationHeaders[this->type][this->animIndex], this->actor.speedXZ * 0.3f); } } -void EnHorse_CsSetAnimHighJump(EnHorse* this, GlobalContext* globalCtx) { +void EnHorse_CsSetAnimHighJump(EnHorse* this, PlayState* play) { this->skin.skelAnime.curFrame = 0.0f; - EnHorse_CsPlayHighJumpAnim(this, globalCtx); + EnHorse_CsPlayHighJumpAnim(this, play); } -void EnHorse_CsPlayHighJumpAnim(EnHorse* this, GlobalContext* globalCtx) { +void EnHorse_CsPlayHighJumpAnim(EnHorse* this, PlayState* play) { f32 curFrame; f32 y; Vec3s* jointTable; - this->animationIdx = ENHORSE_ANIM_HIGH_JUMP; + this->animIndex = 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); + Animation_Change(&this->skin.skelAnime, sAnimationHeaders[this->type][this->animIndex], 1.5f, curFrame, + Animation_GetLastFrame(sAnimationHeaders[this->type][this->animIndex]), ANIMMODE_ONCE, -3.0f); this->postDrawFunc = NULL; this->jumpStartY = this->actor.world.pos.y; this->actor.gravity = 0.0f; @@ -2525,28 +2535,28 @@ void EnHorse_CsPlayHighJumpAnim(EnHorse* this, GlobalContext* globalCtx) { this->riderPos.y -= y * 0.01f * this->unk_528 * 0.01f; this->stateFlags |= ENHORSE_ANIM_HIGH_JUMP; - if (this->type == HORSE_2) { + if (this->type == HORSE_TYPE_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); + Rumble_Request(0.0f, 170, 10, 10); } -void EnHorse_CsJumpInit(EnHorse* this, GlobalContext* globalCtx, CsCmdActorAction* action) { - EnHorse_CsSetAnimHighJump(this, globalCtx); +void EnHorse_CsJumpInit(EnHorse* this, PlayState* play, CsCmdActorAction* action) { + EnHorse_CsSetAnimHighJump(this, play); this->cutsceneAction = 2; this->cutsceneFlags &= ~1; } -void EnHorse_CsJump(EnHorse* this, GlobalContext* globalCtx, CsCmdActorAction* action) { +void EnHorse_CsJump(EnHorse* this, PlayState* play, CsCmdActorAction* action) { f32 curFrame; f32 y; Vec3s* jointTable; s32 pad[2]; if (this->cutsceneFlags & 1) { - EnHorse_CsMoveToPoint(this, globalCtx, action); + EnHorse_CsMoveToPoint(this, play, action); return; } @@ -2575,19 +2585,19 @@ void EnHorse_CsJump(EnHorse* this, GlobalContext* globalCtx, CsCmdActorAction* a ((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) { + if (this->type == HORSE_TYPE_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); + Rumble_Request(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], + func_800B1598(play, 25.0f, &this->actor.world.pos); + this->animIndex = ENHORSE_ANIM_GALLOP; + Animation_PlayOnceSetSpeed(&this->skin.skelAnime, sAnimationHeaders[this->type][this->animIndex], sPlaybackSpeeds[6]); jointTable = this->skin.skelAnime.jointTable; @@ -2598,28 +2608,28 @@ void EnHorse_CsJump(EnHorse* this, GlobalContext* globalCtx, CsCmdActorAction* a } } -void EnHorse_CsRearingInit(EnHorse* this, GlobalContext* globalCtx, CsCmdActorAction* action) { - this->animationIdx = ENHORSE_ANIM_REARING; +void EnHorse_CsRearingInit(EnHorse* this, PlayState* play, CsCmdActorAction* action) { + this->animIndex = ENHORSE_ANIM_REARING; this->cutsceneAction = 3; this->cutsceneFlags &= ~4; this->stateFlags &= ~ENHORSE_LAND2_SOUND; if (this->stateFlags & ENHORSE_DRAW) { - if (this->type == HORSE_2) { + if (this->type == HORSE_TYPE_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); + Animation_Change(&this->skin.skelAnime, sAnimationHeaders[this->type][this->animIndex], 1.0f, 0.0f, + Animation_GetLastFrame(sAnimationHeaders[this->type][this->animIndex]), ANIMMODE_ONCE, -3.0f); } -void EnHorse_CsRearing(EnHorse* this, GlobalContext* globalCtx, CsCmdActorAction* action) { +void EnHorse_CsRearing(EnHorse* this, PlayState* play, 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) { + if (this->type == HORSE_TYPE_2) { Audio_PlaySfxAtPos(&this->actor.projectedPos, NA_SE_EV_KID_HORSE_LAND2); } else { Audio_PlaySfxAtPos(&this->actor.projectedPos, NA_SE_EV_KID_HORSE_LAND2); @@ -2628,21 +2638,21 @@ void EnHorse_CsRearing(EnHorse* this, GlobalContext* globalCtx, CsCmdActorAction } if (SkelAnime_Update(&this->skin.skelAnime)) { - this->animationIdx = ENHORSE_ANIM_IDLE; + this->animIndex = 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, + Animation_Change(&this->skin.skelAnime, sAnimationHeaders[this->type][this->animIndex], 1.0f, 0.0f, + Animation_GetLastFrame(sAnimationHeaders[this->type][this->animIndex]), ANIMMODE_ONCE, -3.0f); } else { - Animation_Change(&this->skin.skelAnime, sAnimationHeaders[this->type][this->animationIdx], 1.0f, 0.0f, - Animation_GetLastFrame(sAnimationHeaders[this->type][this->animationIdx]), ANIMMODE_LOOP, + Animation_Change(&this->skin.skelAnime, sAnimationHeaders[this->type][this->animIndex], 1.0f, 0.0f, + Animation_GetLastFrame(sAnimationHeaders[this->type][this->animIndex]), ANIMMODE_LOOP, 0.0f); } } } -void EnHorse_WarpMoveInit(EnHorse* this, GlobalContext* globalCtx, CsCmdActorAction* action) { +void EnHorse_WarpMoveInit(EnHorse* this, PlayState* play, CsCmdActorAction* action) { this->actor.world.pos.x = action->startPos.x; this->actor.world.pos.y = action->startPos.y; this->actor.world.pos.z = action->startPos.z; @@ -2651,13 +2661,13 @@ void EnHorse_WarpMoveInit(EnHorse* this, GlobalContext* globalCtx, CsCmdActorAct this->actor.world.rot.y = action->urot.y; this->actor.shape.rot = this->actor.world.rot; - this->animationIdx = ENHORSE_ANIM_GALLOP; + this->animIndex = ENHORSE_ANIM_GALLOP; this->cutsceneAction = 4; - Animation_PlayOnceSetSpeed(&this->skin.skelAnime, sAnimationHeaders[this->type][this->animationIdx], + Animation_PlayOnceSetSpeed(&this->skin.skelAnime, sAnimationHeaders[this->type][this->animIndex], this->actor.speedXZ * 0.3f); } -void EnHorse_CsWarpMoveToPoint(EnHorse* this, GlobalContext* globalCtx, CsCmdActorAction* action) { +void EnHorse_CsWarpMoveToPoint(EnHorse* this, PlayState* play, CsCmdActorAction* action) { Vec3f endPos; s32 pad; @@ -2666,7 +2676,7 @@ void EnHorse_CsWarpMoveToPoint(EnHorse* this, GlobalContext* globalCtx, CsCmdAct endPos.z = action->endPos.z; if (Math3D_Distance(&endPos, &this->actor.world.pos) > 8.0f) { - EnHorse_RotateToPoint(this, globalCtx, &endPos, 0x320); + EnHorse_RotateToPoint(this, play, &endPos, 0x320); this->actor.speedXZ = 8.0f; this->skin.skelAnime.playSpeed = this->actor.speedXZ * 0.3f; } else { @@ -2676,13 +2686,13 @@ void EnHorse_CsWarpMoveToPoint(EnHorse* this, GlobalContext* globalCtx, CsCmdAct 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], + Rumble_Request(0.0f, 120, 8, 255); + Animation_PlayOnceSetSpeed(&this->skin.skelAnime, sAnimationHeaders[this->type][this->animIndex], this->actor.speedXZ * 0.3f); } } -void EnHorse_CsWarpRearingInit(EnHorse* this, GlobalContext* globalCtx, CsCmdActorAction* action) { +void EnHorse_CsWarpRearingInit(EnHorse* this, PlayState* play, CsCmdActorAction* action) { this->actor.world.pos.x = action->startPos.x; this->actor.world.pos.y = action->startPos.y; this->actor.world.pos.z = action->startPos.z; @@ -2691,28 +2701,28 @@ void EnHorse_CsWarpRearingInit(EnHorse* this, GlobalContext* globalCtx, CsCmdAct this->actor.world.rot.y = action->urot.y; this->actor.shape.rot = this->actor.world.rot; - this->animationIdx = ENHORSE_ANIM_REARING; + this->animIndex = ENHORSE_ANIM_REARING; this->cutsceneAction = 5; this->cutsceneFlags &= ~4; this->stateFlags &= ~ENHORSE_LAND2_SOUND; if (this->stateFlags & ENHORSE_DRAW) { - if (this->type == HORSE_2) { + if (this->type == HORSE_TYPE_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); + Animation_Change(&this->skin.skelAnime, sAnimationHeaders[this->type][this->animIndex], 1.0f, 0.0f, + Animation_GetLastFrame(sAnimationHeaders[this->type][this->animIndex]), ANIMMODE_ONCE, -3.0f); } -void EnHorse_CsWarpRearing(EnHorse* this, GlobalContext* globalCtx, CsCmdActorAction* action) { +void EnHorse_CsWarpRearing(EnHorse* this, PlayState* play, 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) { + if (this->type == HORSE_TYPE_2) { Audio_PlaySfxAtPos(&this->actor.projectedPos, NA_SE_EV_KID_HORSE_LAND2); } else { Audio_PlaySfxAtPos(&this->actor.projectedPos, NA_SE_EV_KID_HORSE_LAND2); @@ -2721,23 +2731,23 @@ void EnHorse_CsWarpRearing(EnHorse* this, GlobalContext* globalCtx, CsCmdActorAc } if (SkelAnime_Update(&this->skin.skelAnime)) { - this->animationIdx = ENHORSE_ANIM_IDLE; + this->animIndex = 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, + Animation_Change(&this->skin.skelAnime, sAnimationHeaders[this->type][this->animIndex], 1.0f, 0.0f, + Animation_GetLastFrame(sAnimationHeaders[this->type][this->animIndex]), ANIMMODE_ONCE, -3.0f); } else { - Animation_Change(&this->skin.skelAnime, sAnimationHeaders[this->type][this->animationIdx], 1.0f, 0.0f, - Animation_GetLastFrame(sAnimationHeaders[this->type][this->animationIdx]), ANIMMODE_LOOP, + Animation_Change(&this->skin.skelAnime, sAnimationHeaders[this->type][this->animIndex], 1.0f, 0.0f, + Animation_GetLastFrame(sAnimationHeaders[this->type][this->animIndex]), ANIMMODE_LOOP, 0.0f); } } } -void EnHorse_InitCutscene(EnHorse* this, GlobalContext* globalCtx) { +void EnHorse_InitCutscene(EnHorse* this, PlayState* play) { this->playerControlled = false; - this->action = ENHORSE_ACT_HBA; + this->action = ENHORSE_ACTION_CS_UPDATE; this->cutsceneAction = 0; this->actor.speedXZ = 0.0f; } @@ -2758,15 +2768,15 @@ s32 EnHorse_GetCutsceneFunctionIndex(s32 csAction) { return 0; } -void EnHorse_CutsceneUpdate(EnHorse* this, GlobalContext* globalCtx) { +void EnHorse_CutsceneUpdate(EnHorse* this, PlayState* play) { s32 csFunctionIdx; - CsCmdActorAction* playerAction = globalCtx->csCtx.playerAction; + CsCmdActorAction* playerAction = play->csCtx.playerAction; - if (globalCtx->csCtx.state == 3) { + if (play->csCtx.state == CS_STATE_3) { this->playerControlled = true; this->actor.params = ENHORSE_12; - this->action = ENHORSE_ACT_IDLE; - EnHorse_Freeze(this, globalCtx); + this->action = ENHORSE_ACTION_IDLE; + EnHorse_Freeze(this, play); return; } @@ -2784,14 +2794,14 @@ void EnHorse_CutsceneUpdate(EnHorse* this, GlobalContext* globalCtx) { this->actor.prevPos = this->actor.world.pos; } this->cutsceneAction = csFunctionIdx; - sCutsceneInitFuncs[csFunctionIdx](this, globalCtx, playerAction); + sCutsceneInitFuncs[csFunctionIdx](this, play, playerAction); } - sCutsceneActionFuncs[this->cutsceneAction](this, globalCtx, playerAction); + sCutsceneActionFuncs[this->cutsceneAction](this, play, playerAction); } } } -s32 EnHorse_UpdateHbaRaceInfo(EnHorse* this, GlobalContext* globalCtx, RaceInfo* raceInfo) { +s32 EnHorse_UpdateHbaRaceInfo(EnHorse* this, PlayState* play, RaceInfo* raceInfo) { Vec3f pos; f32 px; f32 pz; @@ -2814,7 +2824,7 @@ s32 EnHorse_UpdateHbaRaceInfo(EnHorse* this, GlobalContext* globalCtx, RaceInfo* } if (!(this->hbaFlags & 1)) { - EnHorse_RotateToPoint(this, globalCtx, &pos, 0x640); + EnHorse_RotateToPoint(this, play, &pos, 0x640); } this->actor.shape.rot.y = this->actor.world.rot.y; @@ -2842,104 +2852,102 @@ void EnHorse_UpdateHbaAnim(EnHorse* this) { s32 animChanged = false; f32 animSpeed; - this->action = ENHORSE_ACT_FLEE_PLAYER; + this->action = ENHORSE_ACTION_HBA; if (this->actor.speedXZ == 0.0f) { - if (this->animationIdx != ENHORSE_ANIM_IDLE) { + if (this->animIndex != ENHORSE_ANIM_IDLE) { animChanged = true; } - this->animationIdx = ENHORSE_ANIM_IDLE; + this->animIndex = ENHORSE_ANIM_IDLE; } else if (this->actor.speedXZ <= 3.0f) { - if (this->animationIdx != ENHORSE_ANIM_WALK) { + if (this->animIndex != ENHORSE_ANIM_WALK) { animChanged = true; } - this->animationIdx = ENHORSE_ANIM_WALK; + this->animIndex = ENHORSE_ANIM_WALK; } else if (this->actor.speedXZ <= 6.0f) { - if (this->animationIdx != ENHORSE_ANIM_TROT) { + if (this->animIndex != ENHORSE_ANIM_TROT) { animChanged = true; } - this->animationIdx = ENHORSE_ANIM_TROT; + this->animIndex = ENHORSE_ANIM_TROT; } else { - if (this->animationIdx != ENHORSE_ANIM_GALLOP) { + if (this->animIndex != ENHORSE_ANIM_GALLOP) { animChanged = true; } - this->animationIdx = ENHORSE_ANIM_GALLOP; + this->animIndex = ENHORSE_ANIM_GALLOP; } - if (this->animationIdx == ENHORSE_ANIM_WALK) { + if (this->animIndex == ENHORSE_ANIM_WALK) { animSpeed = this->actor.speedXZ * 0.5f; - } else if (this->animationIdx == ENHORSE_ANIM_TROT) { + } else if (this->animIndex == ENHORSE_ANIM_TROT) { animSpeed = this->actor.speedXZ * 0.25f; - if (this->type == HORSE_2) { + if (this->type == HORSE_TYPE_2) { Audio_PlaySfxAtPos(&this->actor.projectedPos, NA_SE_EV_KID_HORSE_RUN); } else { Audio_PlaySfxAtPos(&this->actor.projectedPos, NA_SE_EV_HORSE_RUN); } - func_8013ECE0(0.0f, 60, 8, 255); - } else if (this->animationIdx == ENHORSE_ANIM_GALLOP) { + Rumble_Request(0.0f, 60, 8, 255); + } else if (this->animIndex == ENHORSE_ANIM_GALLOP) { animSpeed = this->actor.speedXZ * 0.2f; - if (this->type == HORSE_2) { + if (this->type == HORSE_TYPE_2) { Audio_PlaySfxAtPos(&this->actor.projectedPos, NA_SE_EV_KID_HORSE_RUN); } else { Audio_PlaySfxAtPos(&this->actor.projectedPos, NA_SE_EV_HORSE_RUN); } - func_8013ECE0(0.0f, 120, 8, 255); + Rumble_Request(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); + Animation_Change(&this->skin.skelAnime, sAnimationHeaders[this->type][this->animIndex], + sPlaybackSpeeds[this->animIndex] * animSpeed * 1.5f, 0.0f, + Animation_GetLastFrame(sAnimationHeaders[this->type][this->animIndex]), 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); + Animation_Change(&this->skin.skelAnime, sAnimationHeaders[this->type][this->animIndex], + sPlaybackSpeeds[this->animIndex] * animSpeed * 1.5f, 0.0f, + Animation_GetLastFrame(sAnimationHeaders[this->type][this->animIndex]), ANIMMODE_ONCE, 0.0f); } } -void EnHorse_UpdateHorsebackArchery(EnHorse* this, GlobalContext* globalCtx) { +void EnHorse_UpdateHorsebackArchery(EnHorse* this, PlayState* play) { f32 playSpeed; s32 sp28; - if (this->animationIdx == ENHORSE_ANIM_WALK) { + if (this->animIndex == ENHORSE_ANIM_WALK) { EnHorse_PlayWalkingSound(this); } - if (globalCtx->interfaceCtx.hbaAmmo == 0) { + if (play->interfaceCtx.hbaAmmo == 0) { this->hbaTimer++; } sp28 = Audio_IsSequencePlaying(0x41); - EnHorse_UpdateHbaRaceInfo(this, globalCtx, &sHbaInfo); + EnHorse_UpdateHbaRaceInfo(this, play, &sHbaInfo); if (((this->hbaFlags & 1) || (this->hbaTimer > 45)) && (sp28 != 1) && (gSaveContext.minigameState != 3)) { gSaveContext.save.cutscene = 0; - globalCtx->sceneLoadFlag = 0x14; - globalCtx->unk_1887F = 0x40; + play->transitionTrigger = TRANS_TRIGGER_START; + play->transitionType = TRANS_TYPE_64; } - if (globalCtx->interfaceCtx.hbaAmmo) {} + if (play->interfaceCtx.hbaAmmo) {} - if (((globalCtx->interfaceCtx.hbaAmmo == 0) || (this->hbaFlags & 2)) && (this->hbaFlags & 4)) { + if (((play->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) { + if (this->animIndex != ENHORSE_ANIM_IDLE) { EnHorse_UpdateHbaAnim(this); } } - if (this->animationIdx == ENHORSE_ANIM_WALK) { + if (this->animIndex == ENHORSE_ANIM_WALK) { playSpeed = this->actor.speedXZ * 0.5f; - } else if (this->animationIdx == ENHORSE_ANIM_TROT) { + } else if (this->animIndex == ENHORSE_ANIM_TROT) { playSpeed = this->actor.speedXZ * 0.25f; - } else if (this->animationIdx == ENHORSE_ANIM_GALLOP) { + } else if (this->animIndex == ENHORSE_ANIM_GALLOP) { playSpeed = this->actor.speedXZ * 0.2f; } else { playSpeed = 1.0f; @@ -2947,24 +2955,23 @@ void EnHorse_UpdateHorsebackArchery(EnHorse* this, GlobalContext* globalCtx) { this->skin.skelAnime.playSpeed = playSpeed; if (SkelAnime_Update(&this->skin.skelAnime) || - ((this->animationIdx == ENHORSE_ANIM_IDLE) && (this->actor.speedXZ != 0.0f))) { + ((this->animIndex == ENHORSE_ANIM_IDLE) && (this->actor.speedXZ != 0.0f))) { EnHorse_UpdateHbaAnim(this); } } -#ifdef NON_MATCHING -void EnHorse_FleePlayer(EnHorse* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); +void EnHorse_FleePlayer(EnHorse* this, PlayState* play) { + Player* player = GET_PLAYER(play); f32 distToHome; f32 playerDistToHome; f32 distToPlayer; - s32 nextAnim; + s32 nextAnimIndex = this->animIndex; s32 animFinished; s16 yaw; - if ((D_801BDAA4 != 0) || (this->type == HORSE_HNI)) { + if ((D_801BDAA4 != 0) || (this->type == HORSE_TYPE_HNI)) { EnHorse_StartIdleRidable(this); - if (this->type == HORSE_2) { + if (this->type == HORSE_TYPE_2) { Audio_PlaySfxAtPos(&this->actor.projectedPos, NA_SE_EV_KID_HORSE_NEIGH); } else { Audio_PlaySfxAtPos(&this->actor.projectedPos, NA_SE_EV_HORSE_NEIGH); @@ -3001,25 +3008,26 @@ void EnHorse_FleePlayer(EnHorse* this, GlobalContext* globalCtx) { if (this->actor.speedXZ >= 6.0f) { this->skin.skelAnime.playSpeed = this->actor.speedXZ * 0.3f; - nextAnim = ENHORSE_ANIM_GALLOP; + nextAnimIndex = ENHORSE_ANIM_GALLOP; } else if (this->actor.speedXZ >= 3.0f) { this->skin.skelAnime.playSpeed = this->actor.speedXZ * 0.375f; - nextAnim = ENHORSE_ANIM_TROT; + nextAnimIndex = ENHORSE_ANIM_TROT; } else if (this->actor.speedXZ > 0.1f) { this->skin.skelAnime.playSpeed = this->actor.speedXZ * 0.75f; - nextAnim = ENHORSE_ANIM_WALK; + nextAnimIndex = ENHORSE_ANIM_WALK; EnHorse_PlayWalkingSound(this); } else { if (Rand_ZeroOne() > 0.5f) { - nextAnim = ENHORSE_ANIM_WHINNEY; + nextAnimIndex = ENHORSE_ANIM_WHINNY; } else { - nextAnim = ENHORSE_ANIM_IDLE; + nextAnimIndex = ENHORSE_ANIM_IDLE; } - EnHorse_IdleAnimSounds(this, globalCtx); + EnHorse_IdleAnimSounds(this, play); this->skin.skelAnime.playSpeed = 1.0f; } - if ((nextAnim == ENHORSE_ANIM_GALLOP) || (nextAnim == ENHORSE_ANIM_TROT) || (nextAnim == ENHORSE_ANIM_WALK)) { + if ((nextAnimIndex == ENHORSE_ANIM_GALLOP) || (nextAnimIndex == ENHORSE_ANIM_TROT) || + (nextAnimIndex == ENHORSE_ANIM_WALK)) { if (playerDistToHome < 300.0f) { yaw = player->actor.shape.rot.y; yaw += ((Actor_YawBetweenActors(&this->actor, &player->actor) > 0) ? 1 : -1) * 0x3FFF; @@ -3039,69 +3047,65 @@ void EnHorse_FleePlayer(EnHorse* this, GlobalContext* globalCtx) { 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) { + if (((this->animIndex == ENHORSE_ANIM_IDLE) || (this->animIndex == ENHORSE_ANIM_WHINNY)) && + ((nextAnimIndex == ENHORSE_ANIM_GALLOP) || (nextAnimIndex == ENHORSE_ANIM_TROT) || + (nextAnimIndex == ENHORSE_ANIM_WALK))) { + this->animIndex = nextAnimIndex; + Animation_Change(&this->skin.skelAnime, sAnimationHeaders[this->type][this->animIndex], 1.0f, 0.0f, + Animation_GetLastFrame(sAnimationHeaders[this->type][nextAnimIndex]), ANIMMODE_ONCE, -3.0f); + if (this->animIndex == ENHORSE_ANIM_GALLOP) { func_8087C1C0(this); - } else if (this->animationIdx == ENHORSE_ANIM_TROT) { + } else if (this->animIndex == ENHORSE_ANIM_TROT) { func_8087C178(this); } } else if (animFinished) { - if (nextAnim == ENHORSE_ANIM_GALLOP) { + if (nextAnimIndex == ENHORSE_ANIM_GALLOP) { func_8087C1C0(this); - } else if (nextAnim == ENHORSE_ANIM_TROT) { + } else if (nextAnimIndex == 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); + if ((this->animIndex == ENHORSE_ANIM_IDLE) || (this->animIndex == ENHORSE_ANIM_WHINNY)) { + if (nextAnimIndex != this->animIndex) { + this->animIndex = nextAnimIndex; + Animation_Change(&this->skin.skelAnime, sAnimationHeaders[this->type][this->animIndex], 1.0f, 0.0f, + Animation_GetLastFrame(sAnimationHeaders[this->type][this->animIndex]), ANIMMODE_ONCE, + -3.0f); } else { if (Rand_ZeroOne() > 0.5f) { - this->animationIdx = ENHORSE_ANIM_IDLE; + this->animIndex = ENHORSE_ANIM_IDLE; this->stateFlags &= ~ENHORSE_SANDDUST_SOUND; } else { - this->animationIdx = ENHORSE_ANIM_WHINNEY; + this->animIndex = ENHORSE_ANIM_WHINNY; if (this->stateFlags & ENHORSE_DRAW) { - if (this->type == HORSE_2) { + if (this->type == HORSE_TYPE_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); + Animation_Change(&this->skin.skelAnime, sAnimationHeaders[this->type][this->animIndex], 1.0f, 0.0f, + Animation_GetLastFrame(sAnimationHeaders[this->type][this->animIndex]), ANIMMODE_ONCE, + -3.0f); } - } 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, + } else if (nextAnimIndex != this->animIndex) { + this->animIndex = nextAnimIndex; + Animation_Change(&this->skin.skelAnime, sAnimationHeaders[this->type][this->animIndex], 1.0f, 0.0f, + Animation_GetLastFrame(sAnimationHeaders[this->type][this->animIndex]), ANIMMODE_ONCE, -3.0f); } else { - Animation_Change(&this->skin.skelAnime, sAnimationHeaders[this->type][this->animationIdx], 1.0f, 0.0f, - Animation_GetLastFrame(sAnimationHeaders[this->type][this->animationIdx]), ANIMMODE_ONCE, + Animation_Change(&this->skin.skelAnime, sAnimationHeaders[this->type][this->animIndex], 1.0f, 0.0f, + Animation_GetLastFrame(sAnimationHeaders[this->type][this->animIndex]), ANIMMODE_ONCE, 0.0f); } - } else if ((this->animationIdx == ENHORSE_ANIM_WALK) && - ((nextAnim == ENHORSE_ANIM_IDLE) || (nextAnim == ENHORSE_ANIM_WHINNEY))) { - this->animationIdx = nextAnim; - Animation_Change(&this->skin.skelAnime, sAnimationHeaders[this->type][this->animationIdx], 1.0f, 0.0f, - Animation_GetLastFrame(sAnimationHeaders[this->type][this->animationIdx]), ANIMMODE_ONCE, - -3.0f); + } else if ((this->animIndex == ENHORSE_ANIM_WALK) && + ((nextAnimIndex == ENHORSE_ANIM_IDLE) || (nextAnimIndex == ENHORSE_ANIM_WHINNY))) { + this->animIndex = nextAnimIndex; + Animation_Change(&this->skin.skelAnime, sAnimationHeaders[this->type][this->animIndex], 1.0f, 0.0f, + Animation_GetLastFrame(sAnimationHeaders[this->type][this->animIndex]), ANIMMODE_ONCE, -3.0f); } } -#else -void EnHorse_FleePlayer(EnHorse* this, GlobalContext* globalCtx); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/EnHorse_FleePlayer.s") -#endif void func_80883B70(EnHorse* this, CsCmdActorAction* action) { this->actor.world.pos.x = action->startPos.x; @@ -3114,38 +3118,37 @@ void func_80883B70(EnHorse* this, CsCmdActorAction* action) { this->actor.prevPos = this->actor.world.pos; } -void func_80883BEC(EnHorse* this, GlobalContext* globalCtx, CsCmdActorAction* action) { +void func_80883BEC(EnHorse* this, PlayState* play, CsCmdActorAction* action) { func_80883B70(this, action); - this->animationIdx = ENHORSE_ANIM_IDLE; + this->animIndex = 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); + Animation_Change(&this->skin.skelAnime, sAnimationHeaders[this->type][this->animIndex], 1.0f, 0.0f, + Animation_GetLastFrame(sAnimationHeaders[this->type][this->animIndex]), ANIMMODE_ONCE, 0.0f); this->stateFlags |= ENHORSE_SANDDUST_SOUND; } -void func_80883CB0(EnHorse* this, GlobalContext* globalCtx, CsCmdActorAction* action) { - EnHorse_IdleAnimSounds(this, globalCtx); +void func_80883CB0(EnHorse* this, PlayState* play, CsCmdActorAction* action) { + EnHorse_IdleAnimSounds(this, play); 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); + this->animIndex = ENHORSE_ANIM_IDLE; + Animation_Change(&this->skin.skelAnime, sAnimationHeaders[this->type][this->animIndex], 1.0f, 0.0f, + Animation_GetLastFrame(sAnimationHeaders[this->type][this->animIndex]), ANIMMODE_ONCE, 0.0f); } } -void func_80883D64(EnHorse* this, GlobalContext* globalCtx, CsCmdActorAction* action) { +void func_80883D64(EnHorse* this, PlayState* play, 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) { +void func_80883DE0(EnHorse* this, PlayState* play, CsCmdActorAction* action) { SkelAnime_Update(&this->skin.skelAnime); } -void func_80883E10(EnHorse* this, GlobalContext* globalCtx, CsCmdActorAction* action) { +void func_80883E10(EnHorse* this, PlayState* play, 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, @@ -3153,65 +3156,63 @@ void func_80883E10(EnHorse* this, GlobalContext* globalCtx, CsCmdActorAction* ac Audio_PlaySfxAtPos(&this->unk_218, NA_SE_EV_KID_HORSE_NEIGH); } -void func_80883EA0(EnHorse* this, GlobalContext* globalCtx, CsCmdActorAction* action) { +void func_80883EA0(EnHorse* this, PlayState* play, 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) { +void func_80883F18(EnHorse* this, PlayState* play, 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) { +void func_80883F98(EnHorse* this, PlayState* play, 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) { +void func_80884010(EnHorse* this, PlayState* play, 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); + this->animIndex = ENHORSE_ANIM_WALK; + Animation_Change(&this->skin.skelAnime, sAnimationHeaders[this->type][this->animIndex], 1.0f, 0.0f, + Animation_GetLastFrame(sAnimationHeaders[this->type][this->animIndex]), ANIMMODE_ONCE, -3.0f); } -void func_808840C4(EnHorse* this, GlobalContext* globalCtx, CsCmdActorAction* action) { +void func_808840C4(EnHorse* this, PlayState* play, CsCmdActorAction* action) { EnHorse_PlayWalkingSound(this); - Cutscene_ActorTranslateAndYaw(&this->actor, globalCtx, this->unk_530); + Cutscene_ActorTranslateAndYaw(&this->actor, play, 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); + Animation_Change(&this->skin.skelAnime, sAnimationHeaders[this->type][this->animIndex], 1.0f, 0.0f, + Animation_GetLastFrame(sAnimationHeaders[this->type][this->animIndex]), ANIMMODE_ONCE, 0.0f); } } -void func_80884194(EnHorse* this, GlobalContext* globalCtx, CsCmdActorAction* action) { +void func_80884194(EnHorse* this, PlayState* play, 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); + this->animIndex = ENHORSE_ANIM_GALLOP; + Animation_Change(&this->skin.skelAnime, sAnimationHeaders[this->type][this->animIndex], 1.0f, 0.0f, + Animation_GetLastFrame(sAnimationHeaders[this->type][this->animIndex]), ANIMMODE_ONCE, -3.0f); func_8087C1C0(this); } -void func_8088424C(EnHorse* this, GlobalContext* globalCtx, CsCmdActorAction* action) { - Cutscene_ActorTranslateAndYaw(&this->actor, globalCtx, this->unk_530); +void func_8088424C(EnHorse* this, PlayState* play, CsCmdActorAction* action) { + Cutscene_ActorTranslateAndYaw(&this->actor, play, 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); + Animation_Change(&this->skin.skelAnime, sAnimationHeaders[this->type][this->animIndex], 1.0f, 0.0f, + Animation_GetLastFrame(sAnimationHeaders[this->type][this->animIndex]), ANIMMODE_ONCE, 0.0f); func_8087C1C0(this); } } -void func_80884314(EnHorse* this, GlobalContext* globalCtx, CsCmdActorAction* action) { +void func_80884314(EnHorse* this, PlayState* play, CsCmdActorAction* action) { ActorShape_Init(&this->actor.shape, 0.0f, NULL, 20.0f); func_80883B70(this, action); this->unk_3E0 = 7; @@ -3220,17 +3221,17 @@ void func_80884314(EnHorse* this, GlobalContext* globalCtx, CsCmdActorAction* ac Audio_PlaySfxAtPos(&this->unk_218, NA_SE_EV_KID_HORSE_NEIGH); } -void func_808843B4(EnHorse* this, GlobalContext* globalCtx, CsCmdActorAction* action) { +void func_808843B4(EnHorse* this, PlayState* play, 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); + Cutscene_ActorTranslateAndYaw(&this->actor, play, this->unk_530); } } -void func_80884444(EnHorse* this, GlobalContext* globalCtx, CsCmdActorAction* action) { +void func_80884444(EnHorse* this, PlayState* play, CsCmdActorAction* action) { ActorShape_Init(&this->actor.shape, 0.0f, NULL, 20.0f); func_80883B70(this, action); this->cutsceneAction = 8; @@ -3239,8 +3240,8 @@ void func_80884444(EnHorse* this, GlobalContext* globalCtx, CsCmdActorAction* ac func_8087C1C0(this); } -void func_808844E0(EnHorse* this, GlobalContext* globalCtx, CsCmdActorAction* action) { - Cutscene_ActorTranslateAndYaw(&this->actor, globalCtx, this->unk_530); +void func_808844E0(EnHorse* this, PlayState* play, CsCmdActorAction* action) { + Cutscene_ActorTranslateAndYaw(&this->actor, play, 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); @@ -3248,7 +3249,7 @@ void func_808844E0(EnHorse* this, GlobalContext* globalCtx, CsCmdActorAction* ac } } -void func_80884564(EnHorse* this, GlobalContext* globalCtx, CsCmdActorAction* action) { +void func_80884564(EnHorse* this, PlayState* play, CsCmdActorAction* action) { ActorShape_Init(&this->actor.shape, 0.0f, NULL, 20.0f); func_80883B70(this, action); this->cutsceneAction = 8; @@ -3257,8 +3258,8 @@ void func_80884564(EnHorse* this, GlobalContext* globalCtx, CsCmdActorAction* ac func_8087C1C0(this); } -void func_80884604(EnHorse* this, GlobalContext* globalCtx, CsCmdActorAction* action) { - Cutscene_ActorTranslateAndYaw(&this->actor, globalCtx, this->unk_530); +void func_80884604(EnHorse* this, PlayState* play, CsCmdActorAction* action) { + Cutscene_ActorTranslateAndYaw(&this->actor, play, 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); @@ -3269,26 +3270,26 @@ void func_80884604(EnHorse* this, GlobalContext* globalCtx, CsCmdActorAction* ac } } -void func_808846B4(EnHorse* this, GlobalContext* globalCtx, CsCmdActorAction* action) { +void func_808846B4(EnHorse* this, PlayState* play, CsCmdActorAction* action) { Actor_MarkForDeath(&this->actor); } -void func_808846DC(EnHorse* this, GlobalContext* globalCtx, CsCmdActorAction* action) { +void func_808846DC(EnHorse* this, PlayState* play, CsCmdActorAction* action) { } -void func_808846F0(EnHorse* this, GlobalContext* globalCtx) { +void func_808846F0(EnHorse* this, PlayState* play) { this->playerControlled = false; - this->action = ENHORSE_ACT_21; + this->action = ENHORSE_ACTION_21; this->unk_3E0 = -1; this->actor.speedXZ = 0.0f; } -void func_80884718(EnHorse* this, GlobalContext* globalCtx) { +void func_80884718(EnHorse* this, PlayState* play) { CsCmdActorAction* action; - if (Cutscene_CheckActorAction(globalCtx, 0x70)) { - this->unk_530 = Cutscene_GetActorActionIndex(globalCtx, 0x70); - action = globalCtx->csCtx.actorActions[this->unk_530]; + if (Cutscene_CheckActorAction(play, 0x70)) { + this->unk_530 = Cutscene_GetActorActionIndex(play, 0x70); + action = play->csCtx.actorActions[this->unk_530]; this->unk_1EC |= 0x20; if (this->unk_3E0 != action->action) { @@ -3305,24 +3306,24 @@ void func_80884718(EnHorse* this, GlobalContext* globalCtx) { this->unk_3E0 = action->action; if (D_808890F0[this->unk_3E0] != NULL) { - D_808890F0[this->unk_3E0](this, globalCtx, action); + D_808890F0[this->unk_3E0](this, play, action); } } if (D_8088911C[this->unk_3E0] != NULL) { - D_8088911C[this->unk_3E0](this, globalCtx, action); + D_8088911C[this->unk_3E0](this, play, 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->action = ENHORSE_ACTION_23; + this->animIndex = ENHORSE_ANIM_WALK; + Animation_PlayLoop(&this->skin.skelAnime, sAnimationHeaders[this->type][this->animIndex]); this->stateFlags |= ENHORSE_UNRIDEABLE; } -void func_808848C8(EnHorse* this, GlobalContext* globalCtx) { +void func_808848C8(EnHorse* this, PlayState* play) { Vec3f sp24 = { -1916.0f, -106.0f, -523.0f }; EnHorse_PlayWalkingSound(this); @@ -3338,75 +3339,75 @@ void func_808848C8(EnHorse* this, GlobalContext* globalCtx) { 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); + this->animIndex = ENHORSE_ANIM_TROT; + this->action = ENHORSE_ACTION_24; + Animation_Change(&this->skin.skelAnime, sAnimationHeaders[this->type][this->animIndex], 2.0f, 0.0f, + Animation_GetLastFrame(sAnimationHeaders[this->type][this->animIndex]), ANIMMODE_ONCE, -3.0f); } -void func_80884A40(EnHorse* this, GlobalContext* globalCtx) { - s32 sp44[] = { 5, 6, 0 }; +void func_80884A40(EnHorse* this, PlayState* play) { + s32 sp44[] = { ENHORSE_ANIM_TROT, ENHORSE_ANIM_GALLOP, ENHORSE_ANIM_IDLE }; s32 sp40; s32 temp_v0; - if (this->animationIdx == ENHORSE_ANIM_WHINNEY) { - temp_v0 = 0; + if (this->animIndex == ENHORSE_ANIM_WHINNY) { + temp_v0 = ENHORSE_ANIM_IDLE; } else { - temp_v0 = this->animationIdx; + temp_v0 = this->animIndex; } 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; + this->animIndex = sp44[this->unk_538]; + if ((this->animIndex == ENHORSE_ANIM_IDLE) && (Rand_ZeroOne() < 0.5f)) { + this->animIndex = ENHORSE_ANIM_WHINNY; } if (sp40) { - if (this->animationIdx == ENHORSE_ANIM_IDLE) { - Animation_MorphToPlayOnce(&this->skin.skelAnime, sAnimationHeaders[this->type][this->animationIdx], - -3.0f); + if (this->animIndex == ENHORSE_ANIM_IDLE) { + Animation_MorphToPlayOnce(&this->skin.skelAnime, sAnimationHeaders[this->type][this->animIndex], -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); + Animation_Change(&this->skin.skelAnime, sAnimationHeaders[this->type][this->animIndex], 2.0f, 0.0f, + Animation_GetLastFrame(sAnimationHeaders[this->type][this->animIndex]), ANIMMODE_ONCE, + -3.0f); } - } else if (this->animationIdx == ENHORSE_ANIM_IDLE) { - Animation_PlayOnce(&this->skin.skelAnime, sAnimationHeaders[this->type][this->animationIdx]); + } else if (this->animIndex == ENHORSE_ANIM_IDLE) { + Animation_PlayOnce(&this->skin.skelAnime, sAnimationHeaders[this->type][this->animIndex]); } else { - Animation_Change(&this->skin.skelAnime, sAnimationHeaders[this->type][this->animationIdx], 2.0f, 0.0f, - Animation_GetLastFrame(sAnimationHeaders[this->type][this->animationIdx]), ANIMMODE_ONCE, + Animation_Change(&this->skin.skelAnime, sAnimationHeaders[this->type][this->animIndex], 2.0f, 0.0f, + Animation_GetLastFrame(sAnimationHeaders[this->type][this->animIndex]), ANIMMODE_ONCE, 0.0f); } - if ((this->unk_538 == 0) || (this->unk_538 == 1)) { + if ((this->unk_538 == OBJ_UM_ANIM_TROT) || (this->unk_538 == OBJ_UM_ANIM_GALLOP)) { 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) { + } else if (this->unk_538 == OBJ_UM_ANIM_IDLE) { + if (this->animIndex == ENHORSE_ANIM_IDLE) { + EnHorse_IdleAnimSounds(this, play); + } else if (this->animIndex == ENHORSE_ANIM_WHINNY) { Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_HORSE_GROAN); } } } } -void func_80884D04(EnHorse* this, GlobalContext* globalCtx) { +void func_80884D04(EnHorse* this, PlayState* play) { f32 playSpeed; this->actor.speedXZ = 10.0f; - this->action = ENHORSE_ACT_25; + this->action = ENHORSE_ACTION_25; this->unk_540 = this->actor.world.pos; Actor_PlaySfxAtPos(&this->actor, NA_SE_IT_INGO_HORSE_NEIGH); - this->animationIdx = ENHORSE_ANIM_GALLOP; + this->animIndex = 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); + Animation_Change(&this->skin.skelAnime, sAnimationHeaders[this->type][this->animIndex], + sPlaybackSpeeds[this->animIndex] * playSpeed * 2.5f, 0.0f, + Animation_GetLastFrame(sAnimationHeaders[this->type][this->animIndex]), ANIMMODE_ONCE, 0.0f); } -void func_80884E0C(EnHorse* this, GlobalContext* globalCtx) { +// Action func: EnHorse_UpdateBandit? +void func_80884E0C(EnHorse* this, PlayState* play) { f32 playSpeed = (this->unk_56C * 0.2f * 0.5f) + 1.0f; Vec3f pos; CollisionPoly* sp3C; @@ -3414,36 +3415,35 @@ void func_80884E0C(EnHorse* this, GlobalContext* globalCtx) { 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); + Animation_Change(&this->skin.skelAnime, sAnimationHeaders[this->type][this->animIndex], + sPlaybackSpeeds[this->animIndex] * playSpeed * 2.5f, 0.0f, + Animation_GetLastFrame(sAnimationHeaders[this->type][this->animIndex]), ANIMMODE_ONCE, 0.0f); 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->actor.world.pos.x = this->banditPosition.x; + this->actor.world.pos.z = this->banditPosition.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)) { + if (((this->unk_550 == 5) || (this->unk_550 == 7)) && (Player_GetMask(play) != PLAYER_MASK_CIRCUS_LEADER)) { this->rider->unk488 = 7; } else { - EnHorse_SetIngoAnimation(this->animationIdx, this->skin.skelAnime.curFrame, this->unk_394 & 1, + EnHorse_SetIngoAnimation(this->animIndex, 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) { + if (BgCheck_EntityRaycastFloor1(&play->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; + this->actor.world.pos.y = this->banditPosition.y; } } @@ -3453,25 +3453,25 @@ void EnHorse_Vec3fOffset(Vec3f* src, s16 yaw, f32 dist, f32 height, Vec3f* dst) dst->z = (Math_CosS(yaw) * dist) + src->z; } -s32 EnHorse_CalcFloorHeight(EnHorse* this, GlobalContext* globalCtx, Vec3f* pos, CollisionPoly** polyFloor, - f32* floorHeight, s32* bgId) { +s32 EnHorse_CalcFloorHeight(EnHorse* this, PlayState* play, Vec3f* pos, CollisionPoly** polyFloor, f32* floorHeight, + s32* bgId) { f32 waterY; WaterBox* waterbox; *polyFloor = NULL; - *floorHeight = BgCheck_EntityRaycastFloor3(&globalCtx->colCtx, polyFloor, bgId, pos); + *floorHeight = BgCheck_EntityRaycastFloor3(&play->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) && + if ((WaterBox_GetSurface1_2(play, &play->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)) { + SurfaceType_IsHorseBlocked(&play->colCtx, *polyFloor, *bgId) || + (func_800C99D4(&play->colCtx, *polyFloor, *bgId) == 7)) { return 3; // Horse blocked surface } @@ -3486,25 +3486,25 @@ s32 EnHorse_CalcFloorHeight(EnHorse* this, GlobalContext* globalCtx, Vec3f* pos, * 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)) { +void EnHorse_ObstructMovement(EnHorse* this, PlayState* play, s32 obstacleType, s32 galloping) { + if (this->action != ENHORSE_ACTION_CS_UPDATE) { + if ((this->action == ENHORSE_ACTION_5) || (this->action == ENHORSE_ACTION_6)) { this->actor.world.pos = this->actor.prevPos; this->actor.world.rot.y -= 0x640; this->actor.speedXZ = 0.0f; this->actor.shape.rot.y = this->actor.world.rot.y; this->unk_1EC |= 4; - } else if (this->action == ENHORSE_ACT_25) { + } else if (this->action == ENHORSE_ACTION_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)) { + } else if ((play->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->animIndex != 3) {} + } else if (this->action != ENHORSE_ACTION_MOUNTED_REARING) { if (this->stateFlags & ENHORSE_JUMPING) { this->stateFlags &= ~ENHORSE_JUMPING; this->actor.gravity = -3.5f; @@ -3525,7 +3525,7 @@ void EnHorse_ObstructMovement(EnHorse* this, GlobalContext* globalCtx, s32 obsta } } -void EnHorse_CheckFloors(EnHorse* this, GlobalContext* globalCtx) { +void EnHorse_CheckFloors(EnHorse* this, PlayState* play) { s32 pad; CollisionPoly* frontFloor; CollisionPoly* backFloor; @@ -3543,48 +3543,48 @@ void EnHorse_CheckFloors(EnHorse* this, GlobalContext* globalCtx) { WaterBox* waterbox; f32 dist; - if ((WaterBox_GetSurface1_2(globalCtx, &globalCtx->colCtx, this->actor.world.pos.x, this->actor.world.pos.z, - &waterHeight, &waterbox) == true) && + if ((WaterBox_GetSurface1_2(play, &play->colCtx, this->actor.world.pos.x, this->actor.world.pos.z, &waterHeight, + &waterbox) == true) && (this->actor.floorHeight < waterHeight)) { - EnHorse_ObstructMovement(this, globalCtx, 1, galloping); + EnHorse_ObstructMovement(this, play, 1, galloping); return; } - if (this->type != HORSE_2) { + if (this->type != HORSE_TYPE_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); + status = EnHorse_CalcFloorHeight(this, play, &frontPos, &frontFloor, &this->yFront, &this->unk_24C); if (status == 1) { this->actor.shape.rot.x = 0; - EnHorse_ObstructMovement(this, globalCtx, 4, galloping); + EnHorse_ObstructMovement(this, play, 4, galloping); return; } if (status == 3) { this->unk_1EC |= 2; - EnHorse_ObstructMovement(this, globalCtx, 4, galloping); + EnHorse_ObstructMovement(this, play, 4, galloping); return; } - if (this->type != HORSE_2) { + if (this->type != HORSE_TYPE_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); + status = EnHorse_CalcFloorHeight(this, play, &backPos, &backFloor, &this->yBack, &bgId); if (status == 1) { this->actor.shape.rot.x = 0; - EnHorse_ObstructMovement(this, globalCtx, 5, galloping); + EnHorse_ObstructMovement(this, play, 5, galloping); return; } if (status == 3) { this->unk_1EC |= 2; - EnHorse_ObstructMovement(this, globalCtx, 5, galloping); + EnHorse_ObstructMovement(this, play, 5, galloping); return; } @@ -3601,7 +3601,7 @@ void EnHorse_CheckFloors(EnHorse* this, GlobalContext* globalCtx) { 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); + EnHorse_ObstructMovement(this, play, 4, galloping); return; } @@ -3612,17 +3612,17 @@ void EnHorse_CheckFloors(EnHorse* this, GlobalContext* globalCtx) { 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); + EnHorse_ObstructMovement(this, play, 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)) { + SurfaceType_IsHorseBlocked(&play->colCtx, this->actor.floorPoly, this->actor.floorBgId) || + (func_800C99D4(&play->colCtx, this->actor.floorPoly, this->actor.floorBgId) == 7)) { if (this->actor.speedXZ >= 0.0f) { - EnHorse_ObstructMovement(this, globalCtx, 4, galloping); + EnHorse_ObstructMovement(this, play, 4, galloping); } else { - EnHorse_ObstructMovement(this, globalCtx, 5, galloping); + EnHorse_ObstructMovement(this, play, 5, galloping); } } else if (this->stateFlags & 4) { this->actor.shape.rot.x = 0; @@ -3637,24 +3637,24 @@ void EnHorse_CheckFloors(EnHorse* this, GlobalContext* globalCtx) { } } -void EnHorse_MountDismount(EnHorse* this, GlobalContext* globalCtx) { - s32 mountSide = EnHorse_GetMountSide(this, globalCtx); +void EnHorse_MountDismount(EnHorse* this, PlayState* play) { + s32 mountSide = EnHorse_GetMountSide(this, play); if ((mountSide != 0) && !(this->stateFlags & ENHORSE_UNRIDEABLE)) { - Actor_SetRideActor(globalCtx, &this->actor, mountSide); + Actor_SetRideActor(play, &this->actor, mountSide); } - if ((this->playerControlled == false) && (Actor_HasRider(globalCtx, &this->actor) == true)) { + if ((this->playerControlled == false) && (Actor_HasRider(play, &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)) { + EnHorse_Freeze(this, play); + } else if ((this->playerControlled == true) && (Actor_HasNoRider(play, &this->actor) == true)) { this->noInputTimer = 35; this->noInputTimerMax = 35; this->stateFlags &= ~ENHORSE_UNRIDEABLE; this->playerControlled = false; - EnHorse_Freeze(this, globalCtx); + EnHorse_Freeze(this, play); } } @@ -3664,15 +3664,15 @@ void EnHorse_StickDirection(Vec2f* curStick, f32* stickMag, s16* angle) { *angle = Math_Atan2S(-curStick->x, curStick->z); } -void EnHorse_UpdateStick(EnHorse* this, GlobalContext* globalCtx) { - Input* input = &globalCtx->state.input[this->unk_52C]; +void EnHorse_UpdateStick(EnHorse* this, PlayState* play) { + Input* input = &play->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) { +void EnHorse_ResolveCollision(EnHorse* this, PlayState* play, CollisionPoly* colPoly) { f32 dist; f32 nx; f32 ny; @@ -3693,7 +3693,7 @@ void EnHorse_ResolveCollision(EnHorse* this, GlobalContext* globalCtx, Collision } } -void EnHorse_BgCheckSlowMoving(EnHorse* this, GlobalContext* globalCtx) { +void EnHorse_BgCheckSlowMoving(EnHorse* this, PlayState* play) { f32 yOffset = 40.0f; Vec3f start; Vec3f end; @@ -3708,13 +3708,12 @@ void EnHorse_BgCheckSlowMoving(EnHorse* this, GlobalContext* globalCtx) { 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); + if (BgCheck_EntityLineTest1(&play->colCtx, &start, &end, &intersect, &colPoly, true, false, false, true, &bgId)) { + EnHorse_ResolveCollision(this, play, colPoly); } } -void EnHorse_UpdateBgCheckInfo(EnHorse* this, GlobalContext* globalCtx) { +void EnHorse_UpdateBgCheckInfo(EnHorse* this, PlayState* play) { s32 pad2[2]; Vec3f startPos; Vec3f endPos; @@ -3739,15 +3738,15 @@ void EnHorse_UpdateBgCheckInfo(EnHorse* this, GlobalContext* globalCtx) { 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); + Actor_UpdateBgCheckInfo(play, &this->actor, 40.0f, 35.0f, 100.0f, 0x1D); } else { - Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 40.0f, 35.0f, 100.0f, 0x1C); + Actor_UpdateBgCheckInfo(play, &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) { + if (this->type == HORSE_TYPE_2) { Audio_PlaySfxAtPos(&this->actor.projectedPos, NA_SE_EV_KID_HORSE_SANDDUST); } else { Audio_PlaySfxAtPos(&this->actor.projectedPos, NA_SE_EV_KID_HORSE_SANDDUST); @@ -3755,7 +3754,7 @@ void EnHorse_UpdateBgCheckInfo(EnHorse* this, GlobalContext* globalCtx) { } } - horseJump = DynaPoly_GetActor(&globalCtx->colCtx, this->actor.floorBgId); + horseJump = DynaPoly_GetActor(&play->colCtx, this->actor.floorBgId); if (!(this->stateFlags & ENHORSE_JUMPING)) { if ((horseJump != NULL) && (horseJump->actor.id == ACTOR_EN_HORSE_GAME_CHECK) && @@ -3764,7 +3763,7 @@ void EnHorse_UpdateBgCheckInfo(EnHorse* this, GlobalContext* globalCtx) { 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) { + if (this->type == HORSE_TYPE_2) { Audio_PlaySfxAtPos(&this->actor.projectedPos, NA_SE_EV_KID_HORSE_SANDDUST); } else { Audio_PlaySfxAtPos(&this->actor.projectedPos, NA_SE_EV_KID_HORSE_SANDDUST); @@ -3777,7 +3776,7 @@ void EnHorse_UpdateBgCheckInfo(EnHorse* this, GlobalContext* globalCtx) { } 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)) { + (this->action == ENHORSE_ACTION_STOPPING) || (this->action == ENHORSE_ACTION_MOUNTED_REARING)) { return; } @@ -3790,7 +3789,7 @@ void EnHorse_UpdateBgCheckInfo(EnHorse* this, GlobalContext* globalCtx) { movingFast = true; } } else { - EnHorse_BgCheckSlowMoving(this, globalCtx); + EnHorse_BgCheckSlowMoving(this, play); return; } @@ -3805,7 +3804,7 @@ void EnHorse_UpdateBgCheckInfo(EnHorse* this, GlobalContext* globalCtx) { intersect = endPos; wall = NULL; - if (BgCheck_EntityLineTest1(&globalCtx->colCtx, &startPos, &endPos, &intersect, &wall, true, false, false, true, + if (BgCheck_EntityLineTest1(&play->colCtx, &startPos, &endPos, &intersect, &wall, true, false, false, true, &bgId) == true) { intersectDist = sqrtf(Math3D_Vec3fDistSq(&startPos, &intersect)); this->stateFlags |= ENHORSE_OBSTACLE; @@ -3813,29 +3812,28 @@ void EnHorse_UpdateBgCheckInfo(EnHorse* this, GlobalContext* globalCtx) { if (wall != NULL) { if (intersectDist < 30.0f) { - EnHorse_ResolveCollision(this, globalCtx, wall); + EnHorse_ResolveCollision(this, play, 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)) { + if ((Math_CosS(sp7E) < 0.5f) || SurfaceType_IsHorseBlocked(&play->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 ((play->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); + EnHorse_StartBraking(this, play); } } return; } - horseJump = DynaPoly_GetActor(&globalCtx->colCtx, bgId); + horseJump = DynaPoly_GetActor(&play->colCtx, bgId); if ((this->stateFlags & ENHORSE_FLAG_26) && (((horseJump != NULL) && (horseJump->actor.id != ACTOR_BG_UMAJUMP)) || (horseJump == NULL))) { if (this->playerControlled == true) { @@ -3843,7 +3841,7 @@ void EnHorse_UpdateBgCheckInfo(EnHorse* this, GlobalContext* globalCtx) { this->stateFlags |= ENHORSE_FORCE_REVERSING; } else if (movingFast == true) { this->stateFlags |= ENHORSE_FORCE_REVERSING; - EnHorse_StartBraking(this, globalCtx); + EnHorse_StartBraking(this, play); } } return; @@ -3858,7 +3856,7 @@ void EnHorse_UpdateBgCheckInfo(EnHorse* this, GlobalContext* globalCtx) { obstaclePos.z += intersectDist * Math_CosS(this->actor.world.rot.y); obstacleTop = obstaclePos; - obstacleTop.y = BgCheck_EntityRaycastFloor3(&globalCtx->colCtx, &obstacleFloor, &bgId, &obstaclePos); + obstacleTop.y = BgCheck_EntityRaycastFloor3(&play->colCtx, &obstacleFloor, &bgId, &obstaclePos); if (obstacleTop.y == BGCHECK_Y_MIN) { return; @@ -3877,28 +3875,28 @@ void EnHorse_UpdateBgCheckInfo(EnHorse* this, GlobalContext* globalCtx) { (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)) { + if ((movingFast == true) && (this->playerControlled == true) && (this->action != ENHORSE_ACTION_STOPPING) && + (play->sceneNum != SCENE_KOEPONARACE)) { this->stateFlags |= ENHORSE_FORCE_REVERSING; - EnHorse_StartBraking(this, globalCtx); + EnHorse_StartBraking(this, play); } 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 ((temp_f0 < 0.81915206f) || SurfaceType_IsHorseBlocked(&play->colCtx, obstacleFloor, bgId) || + (func_800C99D4(&play->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->action != ENHORSE_ACTION_STOPPING) && (play->sceneNum != SCENE_KOEPONARACE)) { this->stateFlags |= ENHORSE_FORCE_REVERSING; - EnHorse_StartBraking(this, globalCtx); + EnHorse_StartBraking(this, play); } return; } if (wall == NULL) { - horseGameCheck = DynaPoly_GetActor(&globalCtx->colCtx, bgId); + horseGameCheck = DynaPoly_GetActor(&play->colCtx, bgId); if ((horseGameCheck == NULL) || (horseGameCheck->actor.id != ACTOR_EN_HORSE_GAME_CHECK) || ((horseGameCheck->actor.params & 0xFF) != 5)) { return; @@ -3908,12 +3906,12 @@ void EnHorse_UpdateBgCheckInfo(EnHorse* this, GlobalContext* globalCtx) { 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))) { + ((this->stateFlags & ENHORSE_CANT_JUMP) && (this->action != ENHORSE_ACTION_5))) { return; } - if ((this->action == ENHORSE_ACT_MOUNTED_IDLE) && !(this->stateFlags & ENHORSE_FLAG_30)) { - horseGameCheck = DynaPoly_GetActor(&globalCtx->colCtx, bgId); + if ((this->action == ENHORSE_ACTION_5) && !(this->stateFlags & ENHORSE_FLAG_30)) { + horseGameCheck = DynaPoly_GetActor(&play->colCtx, bgId); if ((horseGameCheck != NULL) && (horseGameCheck->actor.id == ACTOR_EN_HORSE_GAME_CHECK) && ((horseGameCheck->actor.params & 0xFF) == 5)) { this->stateFlags |= ENHORSE_FLAG_30; @@ -3937,7 +3935,7 @@ void EnHorse_UpdateBgCheckInfo(EnHorse* this, GlobalContext* globalCtx) { } obstacleTop = obstaclePos; - obstacleTop.y = BgCheck_EntityRaycastFloor3(&globalCtx->colCtx, &obstacleFloor, &bgId, &obstaclePos); + obstacleTop.y = BgCheck_EntityRaycastFloor3(&play->colCtx, &obstacleFloor, &bgId, &obstaclePos); if (obstacleTop.y == BGCHECK_Y_MIN) { return; @@ -3950,18 +3948,18 @@ void EnHorse_UpdateBgCheckInfo(EnHorse* this, GlobalContext* globalCtx) { } 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)) { + if ((temp_f0 < 0.81915206f) || SurfaceType_IsHorseBlocked(&play->colCtx, obstacleFloor, bgId) || + (func_800C99D4(&play->colCtx, obstacleFloor, bgId) == 7)) { + if ((movingFast == true) && (this->playerControlled == true) && (this->action != ENHORSE_ACTION_STOPPING) && + (play->sceneNum != SCENE_KOEPONARACE)) { this->stateFlags |= ENHORSE_FORCE_REVERSING; - EnHorse_StartBraking(this, globalCtx); + EnHorse_StartBraking(this, play); } } else if (behindObstacleHeight < -70.0f) { - if ((movingFast == true) && (this->playerControlled == true) && (this->action != ENHORSE_ACT_LOW_JUMP) && - (globalCtx->sceneNum != SCENE_KOEPONARACE)) { + if ((movingFast == true) && (this->playerControlled == true) && (this->action != ENHORSE_ACTION_STOPPING) && + (play->sceneNum != SCENE_KOEPONARACE)) { this->stateFlags |= ENHORSE_FORCE_REVERSING; - EnHorse_StartBraking(this, globalCtx); + EnHorse_StartBraking(this, play); } } else { temp_f0 = (this->actor.scale.y * 100.0f); @@ -3989,16 +3987,16 @@ void EnHorse_UpdateBgCheckInfo(EnHorse* this, GlobalContext* globalCtx) { } } -void func_80886C00(EnHorse* this, GlobalContext* globalCtx) { - Input* input = &globalCtx->state.input[this->unk_52C]; +void func_80886C00(EnHorse* this, PlayState* play) { + Input* input = &play->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->action == ENHORSE_ACTION_MOUNTED_WALK) || (this->action == ENHORSE_ACTION_MOUNTED_TROT) || + (this->action == ENHORSE_ACTION_MOUNTED_GALLOP)) && + (CHECK_BTN_ALL(input->press.button, BTN_A) || (func_801A5100() == 5)) && (play->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); + Rumble_Request(0.0f, 180, 20, 100); this->stateFlags |= ENHORSE_BOOST; this->stateFlags |= ENHORSE_FIRST_BOOST_REGEN; this->stateFlags |= ENHORSE_FLAG_8; @@ -4006,7 +4004,7 @@ void func_80886C00(EnHorse* this, GlobalContext* globalCtx) { this->boostTimer = 0; if (this->numBoosts == 0) { this->boostRegenTime = 140; - } else if (this->type == HORSE_EPONA) { + } else if (this->type == HORSE_TYPE_EPONA) { if (this->stateFlags & ENHORSE_FIRST_BOOST_REGEN) { this->boostRegenTime = 60; this->stateFlags &= ~ENHORSE_FIRST_BOOST_REGEN; @@ -4017,7 +4015,7 @@ void func_80886C00(EnHorse* this, GlobalContext* globalCtx) { this->boostRegenTime = 70; } } else if ((this->stateFlags & ENHORSE_DRAW) && (Rand_ZeroOne() < 0.1f)) { - if (this->type == HORSE_2) { + if (this->type == HORSE_TYPE_2) { Audio_PlaySfxAtPos(&this->unk_218, NA_SE_EV_KID_HORSE_NEIGH); } else { Audio_PlaySfxAtPos(&this->unk_218, NA_SE_EV_HORSE_NEIGH); @@ -4026,23 +4024,14 @@ void func_80886C00(EnHorse* this, GlobalContext* globalCtx) { } } -void EnHorse_RegenBoost(EnHorse* this, GlobalContext* globalCtx) { - s32 playSfx; - +void EnHorse_RegenBoost(EnHorse* this, PlayState* play) { 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) { + if (!EN_HORSE_CHECK_4(this)) { play_sound(NA_SE_SY_CARROT_RECOVER); } @@ -4056,15 +4045,8 @@ void EnHorse_RegenBoost(EnHorse* this, GlobalContext* globalCtx) { 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) { + if (!EN_HORSE_CHECK_4(this)) { play_sound(NA_SE_SY_CARROT_RECOVER); } } @@ -4072,7 +4054,7 @@ void EnHorse_RegenBoost(EnHorse* this, GlobalContext* globalCtx) { if (this->boostTimer == 8) { if ((Rand_ZeroOne() < 0.25f) && (this->stateFlags & ENHORSE_DRAW)) { - if (this->type == HORSE_2) { + if (this->type == HORSE_TYPE_2) { Audio_PlaySfxAtPos(&this->unk_218, NA_SE_EV_KID_HORSE_NEIGH); } else { Audio_PlaySfxAtPos(&this->unk_218, NA_SE_EV_HORSE_NEIGH); @@ -4080,11 +4062,11 @@ void EnHorse_RegenBoost(EnHorse* this, GlobalContext* globalCtx) { } } - globalCtx->interfaceCtx.numHorseBoosts = this->numBoosts; + play->interfaceCtx.numHorseBoosts = this->numBoosts; } -void EnHorse_UpdatePlayerDir(EnHorse* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); +void EnHorse_UpdatePlayerDir(EnHorse* this, PlayState* play) { + Player* player = GET_PLAYER(play); s16 angle = Actor_YawBetweenActors(&this->actor, &player->actor) - this->actor.world.rot.y; f32 s = Math_SinS(angle); f32 c = Math_CosS(angle); @@ -4106,7 +4088,7 @@ void EnHorse_UpdatePlayerDir(EnHorse* this, GlobalContext* globalCtx) { } } -void EnHorse_TiltBody(EnHorse* this, GlobalContext* globalCtx) { +void EnHorse_TiltBody(EnHorse* this, PlayState* play) { f32 speed; f32 rollDiff; s32 targetRoll; @@ -4130,16 +4112,16 @@ void EnHorse_TiltBody(EnHorse* this, GlobalContext* globalCtx) { this->actor.shape.rot.z = this->actor.world.rot.z; } -s32 EnHorse_UpdateConveyors(EnHorse* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); +s32 EnHorse_UpdateConveyors(EnHorse* this, PlayState* play) { + Player* player = GET_PLAYER(play); s16 conveyorDir; if ((this->actor.floorPoly == NULL) || (&this->actor != player->rideActor) || - !SurfaceType_GetConveyorSpeed(&globalCtx->colCtx, this->actor.floorPoly, this->actor.floorBgId)) { + !SurfaceType_GetConveyorSpeed(&play->colCtx, this->actor.floorPoly, this->actor.floorBgId)) { return false; } - conveyorDir = SurfaceType_GetConveyorDirection(&globalCtx->colCtx, this->actor.floorPoly, this->actor.floorBgId); + conveyorDir = SurfaceType_GetConveyorDirection(&play->colCtx, this->actor.floorPoly, this->actor.floorBgId); conveyorDir = (conveyorDir * 0x400) - this->actor.world.rot.y; if (conveyorDir > 0x640) { this->actor.world.rot.y += 0x640; @@ -4156,56 +4138,55 @@ s32 EnHorse_RandInt(f32 arg0) { return Rand_ZeroOne() * arg0; } -#ifdef NON_MATCHING -void EnHorse_Update(Actor* thisx, GlobalContext* globalCtx) { - static EnHorseActionFunc sActionFuncs[] = { - EnHorse_Frozen, - EnHorse_Inactive, - EnHorse_Idle, - EnHorse_FollowPlayer, - EnHorse_UpdateIngoRace, - func_808819D8, - func_80881398, - EnHorse_MountedIdle, - EnHorse_MountedIdleWhinneying, - EnHorse_MountedTurn, - EnHorse_MountedWalk, - EnHorse_MountedTrot, - EnHorse_MountedGallop, - EnHorse_MountedRearing, - EnHorse_Stopping, - EnHorse_Reverse, - EnHorse_LowJump, - EnHorse_HighJump, - EnHorse_CutsceneUpdate, - EnHorse_UpdateHorsebackArchery, - EnHorse_FleePlayer, - func_80884718, - func_8087CA04, - func_808848C8, - func_80884A40, - func_80884E0C, - }; - s32 pad; +static EnHorseActionFunc sActionFuncs[] = { + EnHorse_Frozen, // ENHORSE_ACTION_FROZEN + EnHorse_Inactive, // ENHORSE_ACTION_INACTIVE + EnHorse_Idle, // ENHORSE_ACTION_IDLE + EnHorse_FollowPlayer, // ENHORSE_ACTION_FOLLOW_PLAYER + EnHorse_UpdateIngoRace, // ENHORSE_ACTION_INGO_RACE + func_808819D8, // ENHORSE_ACTION_5 + func_80881398, // ENHORSE_ACTION_6 + EnHorse_MountedIdle, // ENHORSE_ACTION_MOUNTED_IDLE + EnHorse_MountedIdleWhinnying, // ENHORSE_ACTION_MOUNTED_IDLE_WHINNYING + EnHorse_MountedTurn, // ENHORSE_ACTION_MOUNTED_TURN + EnHorse_MountedWalk, // ENHORSE_ACTION_MOUNTED_WALK + EnHorse_MountedTrot, // ENHORSE_ACTION_MOUNTED_TROT + EnHorse_MountedGallop, // ENHORSE_ACTION_MOUNTED_GALLOP + EnHorse_MountedRearing, // ENHORSE_ACTION_MOUNTED_REARING + EnHorse_Stopping, // ENHORSE_ACTION_STOPPING + EnHorse_Reverse, // ENHORSE_ACTION_REVERSE + EnHorse_LowJump, // ENHORSE_ACTION_LOW_JUMP + EnHorse_HighJump, // ENHORSE_ACTION_HIGH_JUMP + EnHorse_CutsceneUpdate, // ENHORSE_ACTION_CS_UPDATE + EnHorse_UpdateHorsebackArchery, // ENHORSE_ACTION_HBA + EnHorse_FleePlayer, // ENHORSE_ACTION_FLEE_PLAYER + func_80884718, // ENHORSE_ACTION_21 + func_8087CA04, // ENHORSE_ACTION_22 + func_808848C8, // ENHORSE_ACTION_23 + func_80884A40, // ENHORSE_ACTION_24 + func_80884E0C, // ENHORSE_ACTION_25 +}; +void EnHorse_Update(Actor* thisx, PlayState* play2) { + PlayState* play = play2; EnHorse* this = THIS; Vec3f dustAcc = { 0.0f, 0.0f, 0.0f }; Vec3f dustVel = { 0.0f, 1.0f, 0.0f }; - Player* player = GET_PLAYER(globalCtx); + Player* player = GET_PLAYER(play); - if (this->type == HORSE_2) { + if (this->type == HORSE_TYPE_2) { Actor_SetScale(&this->actor, 0.00648f); - } else if (this->type == HORSE_4) { + } else if (this->type == HORSE_TYPE_DONKEY) { Actor_SetScale(&this->actor, 0.008f); } else { Actor_SetScale(&this->actor, 0.01f); } - this->lastYaw = this->actor.shape.rot.y; - EnHorse_UpdateStick(this, globalCtx); - EnHorse_UpdatePlayerDir(this, globalCtx); + this->lastYaw = thisx->shape.rot.y; + EnHorse_UpdateStick(this, play); + EnHorse_UpdatePlayerDir(this, play); if (!(this->stateFlags & ENHORSE_INACTIVE)) { - EnHorse_MountDismount(this, globalCtx); + EnHorse_MountDismount(this, play); } if (this->stateFlags & ENHORSE_FLAG_19) { @@ -4213,78 +4194,78 @@ void EnHorse_Update(Actor* thisx, GlobalContext* globalCtx) { 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->action != ENHORSE_ACTION_MOUNTED_REARING) && (this->inRace == true)) { this->stateFlags &= ~ENHORSE_FLAG_21; EnHorse_StartRearing(this); } } - sActionFuncs[this->action](this, globalCtx); + sActionFuncs[this->action](this, play); this->stateFlags &= ~ENHORSE_OBSTACLE; - this->unk_3EC = this->actor.world.rot.y; - if ((this->animationIdx == ENHORSE_ANIM_STOPPING) || (this->animationIdx == ENHORSE_ANIM_REARING)) { + this->unk_3EC = thisx->world.rot.y; + if ((this->animIndex == ENHORSE_ANIM_STOPPING) || (this->animIndex == ENHORSE_ANIM_REARING)) { this->skin.skelAnime.jointTable[0].y += 0x154; } this->curFrame = this->skin.skelAnime.curFrame; - this->lastPos = this->actor.world.pos; + 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->action == ENHORSE_ACTION_MOUNTED_GALLOP) || (this->action == ENHORSE_ACTION_MOUNTED_TROT) || + (this->action == ENHORSE_ACTION_MOUNTED_WALK)) { + func_80886C00(this, play); } if (this->playerControlled == true) { - EnHorse_RegenBoost(this, globalCtx); + EnHorse_RegenBoost(this, play); } if (ActorCutscene_GetCurrentIndex() != -1) { - this->actor.speedXZ = 0.0f; + thisx->speedXZ = 0.0f; } - if (this->action != ENHORSE_ACT_25) { + if (this->action != ENHORSE_ACTION_25) { Actor_MoveWithGravity(&this->actor); } if (this->rider != NULL) { - if ((this->action == ENHORSE_ACT_INGO_RACE) || (this->action == ENHORSE_ACT_MOUNTED_IDLE) || - (this->action == ENHORSE_ACT_25)) { - this->rider->actor.world.pos.x = this->actor.world.pos.x; - this->rider->actor.world.pos.y = this->actor.world.pos.y + 10.0f; - this->rider->actor.world.pos.z = this->actor.world.pos.z; - this->rider->actor.shape.rot.x = this->actor.shape.rot.x; - this->rider->actor.shape.rot.y = this->actor.shape.rot.y; - } else if (this->action == ENHORSE_ACT_MOUNTED_IDLE_WHINNEYING) { + if ((this->action == ENHORSE_ACTION_INGO_RACE) || (this->action == ENHORSE_ACTION_5) || + (this->action == ENHORSE_ACTION_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_ACTION_6) { EnIn* in = this->rider; s16 jnt = in->jointTable[0].y; in->actor.world.pos.x = this->riderPos.x; in->actor.world.pos.y = this->riderPos.y - (jnt * 0.01f * this->unk_528 * 0.01f); in->actor.world.pos.z = this->riderPos.z; - in->actor.shape.rot.x = this->actor.shape.rot.x; - in->actor.shape.rot.y = this->actor.shape.rot.y; + 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 (this->actor.speedXZ > 10.0f) { - this->actor.speedXZ -= 1.0f; + 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) { + if (this->type == HORSE_TYPE_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->action != ENHORSE_ACTION_INGO_RACE) && (this->action != ENHORSE_ACTION_5) && + (this->action != ENHORSE_ACTION_6)) { + EnHorse_TiltBody(this, play); } if ((this->playerControlled == false) && (this->unk_1EC & 8)) { @@ -4307,57 +4288,57 @@ void EnHorse_Update(Actor* thisx, GlobalContext* globalCtx) { Collider_UpdateCylinder(&this->actor, &this->colliderCylinder1); Collider_UpdateCylinder(&this->actor, &this->colliderCylinder2); - if (this->type == HORSE_2) { + if (this->type == HORSE_TYPE_2) { this->colliderCylinder1.dim.pos.x = - (s16)(Math_SinS(this->actor.shape.rot.y) * 11.0f) + 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(this->actor.shape.rot.y) * 11.0f) + 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(this->actor.shape.rot.y) * -18.0f) + 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(this->actor.shape.rot.y) * -18.0f) + 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(this->actor.shape.rot.y) * 6.6000004f) + 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(this->actor.shape.rot.y) * 6.6000004f) + 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(this->actor.shape.rot.y) * -10.8f) + 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(this->actor.shape.rot.y) * -10.8f) + 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); + CollisionCheck_SetAT(play, &play->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); + CollisionCheck_SetOC(play, &play->colChkCtx, &this->colliderCylinder1.base); + CollisionCheck_SetOC(play, &play->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); + CollisionCheck_SetAC(play, &play->colChkCtx, &this->colliderCylinder1.base); + CollisionCheck_SetAC(play, &play->colChkCtx, &this->colliderCylinder2.base); } - if ((player->stateFlags1 & ENHORSE_BOOST) && (player->rideActor != NULL)) { - EnHorse_UpdateConveyors(this, globalCtx); + if ((player->stateFlags1 & PLAYER_STATE1_1) && (player->rideActor != NULL)) { + EnHorse_UpdateConveyors(this, play); } - EnHorse_UpdateBgCheckInfo(this, globalCtx); - EnHorse_CheckFloors(this, globalCtx); - if (this->actor.world.pos.y < this->yFront) { - if (this->actor.world.pos.y < this->yBack) { + EnHorse_UpdateBgCheckInfo(this, play); + EnHorse_CheckFloors(this, play); + if (thisx->world.pos.y < this->yFront) { + if (thisx->world.pos.y < this->yBack) { if (this->yBack < this->yFront) { - this->actor.world.pos.y = this->yBack; + thisx->world.pos.y = this->yBack; } else { - this->actor.world.pos.y = this->yFront; + thisx->world.pos.y = this->yFront; } } } - this->actor.focus.pos = this->actor.world.pos; - this->actor.focus.pos.y += 70.0f; + thisx->focus.pos = thisx->world.pos; + thisx->focus.pos.y += 70.0f; if ((Rand_ZeroOne() < 0.025f) && (this->blinkTimer == 0)) { this->blinkTimer++; @@ -4368,13 +4349,13 @@ void EnHorse_Update(Actor* thisx, GlobalContext* globalCtx) { } } - if ((this->actor.speedXZ == 0.0f) && !(this->stateFlags & ENHORSE_FLAG_19)) { - this->actor.colChkInfo.mass = MASS_IMMOVABLE; + if ((thisx->speedXZ == 0.0f) && !(this->stateFlags & ENHORSE_FLAG_19)) { + thisx->colChkInfo.mass = MASS_IMMOVABLE; } else { - this->actor.colChkInfo.mass = MASS_HEAVY; + thisx->colChkInfo.mass = MASS_HEAVY; } - if (this->actor.speedXZ >= 5.0f) { + if (thisx->speedXZ >= 5.0f) { this->colliderCylinder1.base.atFlags |= AT_ON; } else { this->colliderCylinder1.base.atFlags &= ~AT_ON; @@ -4382,59 +4363,26 @@ void EnHorse_Update(Actor* thisx, GlobalContext* globalCtx) { if (this->dustFlags & 1) { this->dustFlags &= ~1; - func_800B12F0(globalCtx, &this->frontRightHoof, &dustVel, &dustAcc, EnHorse_RandInt(100.0f) + 200, + func_800B12F0(play, &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, + func_800B12F0(play, &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, + func_800B12F0(play, &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, + func_800B12F0(play, &this->backLeftHoof, &dustVel, &dustAcc, EnHorse_RandInt(100.0f) + 200, EnHorse_RandInt(10.0f) + 30, EnHorse_RandInt(20.0f) + 30); } this->stateFlags &= ~ENHORSE_DRAW; } } -#else -EnHorseActionFunc sActionFuncs[] = { - EnHorse_Frozen, - EnHorse_Inactive, - EnHorse_Idle, - EnHorse_FollowPlayer, - EnHorse_UpdateIngoRace, - func_808819D8, - func_80881398, - EnHorse_MountedIdle, - EnHorse_MountedIdleWhinneying, - EnHorse_MountedTurn, - EnHorse_MountedWalk, - EnHorse_MountedTrot, - EnHorse_MountedGallop, - EnHorse_MountedRearing, - EnHorse_Stopping, - EnHorse_Reverse, - EnHorse_LowJump, - EnHorse_HighJump, - EnHorse_CutsceneUpdate, - EnHorse_UpdateHorsebackArchery, - EnHorse_FleePlayer, - func_80884718, - func_8087CA04, - func_808848C8, - func_80884A40, - func_80884E0C, -}; -Vec3f D_808891C8 = { 0.0f, 0.0f, 0.0f }; -Vec3f D_808891D4 = { 0.0f, 1.0f, 0.0f }; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/EnHorse_Update.s") -#endif -s32 EnHorse_PlayerDirToMountSide(EnHorse* this, GlobalContext* globalCtx, Player* player) { +s32 EnHorse_PlayerDirToMountSide(EnHorse* this, PlayState* play, Player* player) { if (this->playerDir == PLAYER_DIR_SIDE_L) { return -1; } @@ -4446,7 +4394,7 @@ s32 EnHorse_PlayerDirToMountSide(EnHorse* this, GlobalContext* globalCtx, Player return 0; } -s32 EnHorse_MountSideCheck(EnHorse* this, GlobalContext* globalCtx, Player* player) { +s32 EnHorse_MountSideCheck(EnHorse* this, PlayState* play, Player* player) { s32 mountSide; if (Actor_XZDistanceBetweenActors(&this->actor, &player->actor) > 75.0f) { @@ -4462,7 +4410,7 @@ s32 EnHorse_MountSideCheck(EnHorse* this, GlobalContext* globalCtx, Player* play return 0; } - mountSide = EnHorse_PlayerDirToMountSide(this, globalCtx, player); + mountSide = EnHorse_PlayerDirToMountSide(this, play, player); if (mountSide == -1) { return -1; } @@ -4474,16 +4422,16 @@ s32 EnHorse_MountSideCheck(EnHorse* this, GlobalContext* globalCtx, Player* play return 0; } -s32 EnHorse_GetMountSide(EnHorse* this, GlobalContext* globalCtx) { - if (this->action != ENHORSE_ACT_IDLE) { +s32 EnHorse_GetMountSide(EnHorse* this, PlayState* play) { + if (this->action != ENHORSE_ACTION_IDLE) { return 0; } - if ((this->animationIdx != ENHORSE_ANIM_IDLE) && (this->animationIdx != ENHORSE_ANIM_WHINNEY)) { + if ((this->animIndex != ENHORSE_ANIM_IDLE) && (this->animIndex != ENHORSE_ANIM_WHINNY)) { return 0; } - return EnHorse_MountSideCheck(this, globalCtx, GET_PLAYER(globalCtx)); + return EnHorse_MountSideCheck(this, play, GET_PLAYER(play)); } void EnHorse_RandomOffset(Vec3f* src, f32 dist, Vec3f* dst) { @@ -4492,7 +4440,7 @@ void EnHorse_RandomOffset(Vec3f* src, f32 dist, Vec3f* dst) { dst->z = ((Rand_ZeroOne() * (2.0f * dist)) + src->z) - dist; } -void EnHorse_PostDraw(Actor* thisx, GlobalContext* globalCtx, Skin* skin) { +void EnHorse_PostDraw(Actor* thisx, PlayState* play, Skin* skin) { s32 pad; EnHorse* this = THIS; Vec3f sp7C = { 0.0f, 0.0f, 0.0f }; @@ -4506,7 +4454,7 @@ void EnHorse_PostDraw(Actor* thisx, GlobalContext* globalCtx, Skin* skin) { f32 sp34; if (!(this->stateFlags & ENHORSE_CALC_RIDER_POS)) { - if (this->type == HORSE_2) { + if (this->type == HORSE_TYPE_2) { Skin_GetVertexPos(skin, 5, 120, &this->riderPos); this->riderPos.y += 13.0f; } else { @@ -4521,15 +4469,15 @@ void EnHorse_PostDraw(Actor* thisx, GlobalContext* globalCtx, Skin* skin) { this->stateFlags &= ~ENHORSE_CALC_RIDER_POS; } - if (this->type == HORSE_2) { + if (this->type == HORSE_TYPE_2) { Skin_GetLimbPos(skin, 13, &sp7C, &sp38); } else { Skin_GetLimbPos(skin, 13, &sp7C, &sp38); } - SkinMatrix_Vec3fMtxFMultXYZW(&globalCtx->viewProjectionMtxF, &sp38, &this->unk_218, &sp34); + SkinMatrix_Vec3fMtxFMultXYZW(&play->viewProjectionMtxF, &sp38, &this->unk_218, &sp34); - if ((this->animationIdx == ENHORSE_ANIM_IDLE) && (this->action != ENHORSE_ACT_FROZEN) && + if ((this->animIndex == ENHORSE_ANIM_IDLE) && (this->action != ENHORSE_ACTION_FROZEN) && (((curFrame > 40.0f) && (curFrame < 45.0f) && (this->type == 0)) || ((curFrame > 28.0f) && (curFrame < 33.0f) && (this->type == 1)))) { if (Rand_ZeroOne() < 0.02f) { @@ -4538,11 +4486,11 @@ void EnHorse_PostDraw(Actor* thisx, GlobalContext* globalCtx, Skin* skin) { this->frontRightHoof.y -= 5.0f; } } else { - if (this->action == ENHORSE_ACT_LOW_JUMP) { + if (this->action == ENHORSE_ACTION_STOPPING) { 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) { + if (this->type == HORSE_TYPE_2) { Skin_GetLimbPos(skin, 20, &hoofOffset, &sp64); } else { Skin_GetLimbPos(skin, 20, &hoofOffset, &sp64); @@ -4552,10 +4500,9 @@ void EnHorse_PostDraw(Actor* thisx, GlobalContext* globalCtx, Skin* skin) { if (Rand_ZeroOne() < 0.02f) { this->dustFlags |= 1; - if (this->type == HORSE_2) { + if (this->type == HORSE_TYPE_2) { Skin_GetLimbPos(skin, 28, &hoofOffset, &sp64); } else { - curFrame = curFrame; Skin_GetLimbPos(skin, 28, &hoofOffset, &sp64); } EnHorse_RandomOffset(&sp64, 10.0f, &this->frontRightHoof); @@ -4565,7 +4512,7 @@ void EnHorse_PostDraw(Actor* thisx, GlobalContext* globalCtx, Skin* skin) { 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) { + if (this->type == HORSE_TYPE_2) { Skin_GetLimbPos(skin, 36, &hoofOffset, &sp64); } else { Skin_GetLimbPos(skin, 37, &hoofOffset, &sp64); @@ -4577,17 +4524,17 @@ void EnHorse_PostDraw(Actor* thisx, GlobalContext* globalCtx, Skin* skin) { 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) { + if (this->type == HORSE_TYPE_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) { + } else if (this->animIndex == ENHORSE_ANIM_GALLOP) { if ((curFrame > 14.0f) && (curFrame < 16.0f) && (Rand_ZeroOne() < 0.02f)) { this->dustFlags |= 1; - if (this->type == HORSE_2) { + if (this->type == HORSE_TYPE_2) { Skin_GetLimbPos(skin, 28, &hoofOffset, &sp64); } else { Skin_GetLimbPos(skin, 28, &hoofOffset, &sp64); @@ -4595,7 +4542,7 @@ void EnHorse_PostDraw(Actor* thisx, GlobalContext* globalCtx, Skin* skin) { 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) { + if (this->type == HORSE_TYPE_2) { Skin_GetLimbPos(skin, 20, &hoofOffset, &sp64); } else { Skin_GetLimbPos(skin, 20, &hoofOffset, &sp64); @@ -4603,7 +4550,7 @@ void EnHorse_PostDraw(Actor* thisx, GlobalContext* globalCtx, Skin* skin) { 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) { + if (this->type == HORSE_TYPE_2) { Skin_GetLimbPos(skin, 44, &hoofOffset, &sp64); } else { Skin_GetLimbPos(skin, 45, &hoofOffset, &sp64); @@ -4611,18 +4558,18 @@ void EnHorse_PostDraw(Actor* thisx, GlobalContext* globalCtx, Skin* skin) { 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) { + if (this->type == HORSE_TYPE_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) && + } else if ((this->action == ENHORSE_ACTION_LOW_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) { + if (this->type == HORSE_TYPE_2) { Skin_GetLimbPos(skin, 36, &hoofOffset, &sp64); } else { Skin_GetLimbPos(skin, 37, &hoofOffset, &sp64); @@ -4631,18 +4578,18 @@ void EnHorse_PostDraw(Actor* thisx, GlobalContext* globalCtx, Skin* skin) { } if (Rand_ZeroOne() < 0.02f) { this->dustFlags |= 4; - if (this->type == HORSE_2) { + if (this->type == HORSE_TYPE_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)) { + } else if ((this->action == ENHORSE_ACTION_HIGH_JUMP) && (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) { + if (this->type == HORSE_TYPE_2) { Skin_GetLimbPos(skin, 36, &hoofOffset, &sp64); } else { Skin_GetLimbPos(skin, 37, &hoofOffset, &sp64); @@ -4652,7 +4599,7 @@ void EnHorse_PostDraw(Actor* thisx, GlobalContext* globalCtx, Skin* skin) { if (Rand_ZeroOne() < 0.02f) { this->dustFlags |= 4; - if (this->type == HORSE_2) { + if (this->type == HORSE_TYPE_2) { Skin_GetLimbPos(skin, 44, &hoofOffset, &sp64); } else { Skin_GetLimbPos(skin, 45, &hoofOffset, &sp64); @@ -4684,11 +4631,11 @@ void EnHorse_PostDraw(Actor* thisx, GlobalContext* globalCtx, Skin* skin) { //! 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); + CollisionCheck_SetOC(play, &play->colChkCtx, &this->colliderJntSph.base); } } -s32 EnHorse_OverrideLimbDraw(Actor* thisx, GlobalContext* globalCtx, s32 limbIndex, Skin* skin) { +s32 EnHorse_OverrideLimbDraw(Actor* thisx, PlayState* play, s32 limbIndex, Skin* skin) { static TexturePtr D_80889204[] = { object_horse_link_child_Tex_001D28, object_horse_link_child_Tex_001928, @@ -4698,44 +4645,44 @@ s32 EnHorse_OverrideLimbDraw(Actor* thisx, GlobalContext* globalCtx, s32 limbInd EnHorse* this = THIS; s32 drawOriginalLimb = true; - OPEN_DISPS(globalCtx->state.gfxCtx); + OPEN_DISPS(play->state.gfxCtx); - if ((limbIndex != 13) || (this->type != HORSE_EPONA)) { - if ((limbIndex == 13) && (this->type == HORSE_2)) { + if ((limbIndex != 13) || (this->type != HORSE_TYPE_EPONA)) { + if ((limbIndex == 13) && (this->type == HORSE_TYPE_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)) { + } else if ((this->type == HORSE_TYPE_HNI) && (this->stateFlags & ENHORSE_FLAG_18) && (limbIndex == 30)) { drawOriginalLimb = false; } } - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->state.gfxCtx); return drawOriginalLimb; } -s32 func_80888D18(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, Actor* thisx) { +s32 func_80888D18(PlayState* play, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, Actor* thisx) { Vec3f sp1C = { -98.0f, -1454.0f, 0.0f }; EnHorse* this = THIS; if (limbIndex == 3) { - Matrix_MultiplyVector3fByState(&sp1C, &this->riderPos); + Matrix_MultVec3f(&sp1C, &this->riderPos); } return false; } -void EnHorse_Draw(Actor* thisx, GlobalContext* globalCtx) { +void EnHorse_Draw(Actor* thisx, PlayState* play) { EnHorse* this = THIS; if (!(this->stateFlags & ENHORSE_INACTIVE) && (this->actor.update != func_8087D540)) { - func_8012C28C(globalCtx->state.gfxCtx); + func_8012C28C(play->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); + func_80138258(&this->actor, play, &this->skin, EnHorse_PostDraw, EnHorse_OverrideLimbDraw, false); } else { - func_80138258(&this->actor, globalCtx, &this->skin, EnHorse_PostDraw, EnHorse_OverrideLimbDraw, true); + func_80138258(&this->actor, play, &this->skin, EnHorse_PostDraw, EnHorse_OverrideLimbDraw, true); } } else { if (this->stateFlags & ENHORSE_JUMPING) { @@ -4743,12 +4690,12 @@ void EnHorse_Draw(Actor* thisx, GlobalContext* globalCtx) { this->skin.skelAnime.jointTable->y = 0; this->skin.skelAnime.jointTable->z = 0; } - SkelAnime_DrawFlexOpa(globalCtx, this->skin.skelAnime.skeleton, this->skin.skelAnime.jointTable, + SkelAnime_DrawFlexOpa(play, 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); + this->postDrawFunc(this, play); } } } 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 2dc5e44f5..97ab2c898 100644 --- a/src/overlays/actors/ovl_En_Horse/z_en_horse.h +++ b/src/overlays/actors/ovl_En_Horse/z_en_horse.h @@ -3,15 +3,15 @@ #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; +struct EnIn; -typedef void (*EnHorseActionFunc)(struct EnHorse*, GlobalContext*); -typedef void (*EnHorsePostdrawFunc)(struct EnHorse*, GlobalContext*); -typedef void (*EnHorseCsFunc)(struct EnHorse*, GlobalContext*, CsCmdActorAction*); +typedef void (*EnHorseActionFunc)(struct EnHorse*, PlayState*); +typedef void (*EnHorsePostdrawFunc)(struct EnHorse*, PlayState*); +typedef void (*EnHorseCsFunc)(struct EnHorse*, PlayState*, CsCmdActorAction*); #define ENHORSE_BOOST (1 << 0) /* 0x1 */ #define ENHORSE_BOOST_DECEL (1 << 1) /* 0x2 */ @@ -46,33 +46,33 @@ typedef void (*EnHorseCsFunc)(struct EnHorse*, GlobalContext*, CsCmdActorAction* #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, +typedef enum EnHorseAction { + /* 0 */ ENHORSE_ACTION_FROZEN, + /* 1 */ ENHORSE_ACTION_INACTIVE, + /* 2 */ ENHORSE_ACTION_IDLE, + /* 3 */ ENHORSE_ACTION_FOLLOW_PLAYER, + /* 4 */ ENHORSE_ACTION_INGO_RACE, + /* 5 */ ENHORSE_ACTION_5, + /* 6 */ ENHORSE_ACTION_6, + /* 7 */ ENHORSE_ACTION_MOUNTED_IDLE, + /* 8 */ ENHORSE_ACTION_MOUNTED_IDLE_WHINNYING, + /* 9 */ ENHORSE_ACTION_MOUNTED_TURN, + /* 10 */ ENHORSE_ACTION_MOUNTED_WALK, + /* 11 */ ENHORSE_ACTION_MOUNTED_TROT, + /* 12 */ ENHORSE_ACTION_MOUNTED_GALLOP, + /* 13 */ ENHORSE_ACTION_MOUNTED_REARING, + /* 14 */ ENHORSE_ACTION_STOPPING, + /* 15 */ ENHORSE_ACTION_REVERSE, + /* 16 */ ENHORSE_ACTION_LOW_JUMP, + /* 17 */ ENHORSE_ACTION_HIGH_JUMP, + /* 18 */ ENHORSE_ACTION_CS_UPDATE, + /* 19 */ ENHORSE_ACTION_HBA, + /* 20 */ ENHORSE_ACTION_FLEE_PLAYER, + /* 21 */ ENHORSE_ACTION_21, + /* 22 */ ENHORSE_ACTION_22, + /* 23 */ ENHORSE_ACTION_23, + /* 24 */ ENHORSE_ACTION_24, + /* 25 */ ENHORSE_ACTION_25 } EnHorseAction; typedef enum { @@ -85,30 +85,22 @@ typedef enum { } 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 + /* 0 */ HORSE_TYPE_EPONA, + /* 1 */ HORSE_TYPE_HNI, + /* 2 */ HORSE_TYPE_2, + /* 3 */ HORSE_TYPE_BANDIT, + /* 4 */ HORSE_TYPE_DONKEY // Cremia's donkey } 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) +#define ENHORSE_PARAM_BANDIT 0x2000 +#define ENHORSE_PARAM_4000 0x4000 +#define ENHORSE_PARAM_DONKEY 0x8000 -enum { +#define ENHORSE_IS_BANDIT_TYPE(thisx) ((thisx)->params & ENHORSE_PARAM_BANDIT) +#define ENHORSE_IS_4000_TYPE(thisx) ((thisx)->params & ENHORSE_PARAM_4000) +#define ENHORSE_IS_DONKEY_TYPE(thisx) ((thisx)->params & ENHORSE_PARAM_DONKEY) + +typedef enum { /* 0 */ ENHORSE_0, /* 1 */ ENHORSE_1, /* 2 */ ENHORSE_2, @@ -130,11 +122,17 @@ enum { /* 18 */ ENHORSE_18, /* 19 */ ENHORSE_19, /* 20 */ ENHORSE_20, -}; +} EnHorseParam; + +/** + * `paramtype` should be `ENHORSE_PARAM_BANDIT`, `ENHORSE_PARAM_4000` or `ENHORSE_PARAM_DONKEY` + * `lower` should be a value of the enum `EnHorseParam` + */ +#define ENHORSE_PARAMS(type, lower) ((type) | (lower)) typedef struct EnHorse { /* 0x000 */ Actor actor; - /* 0x144 */ s32 action; + /* 0x144 */ EnHorseAction action; /* 0x148 */ s32 noInputTimer; /* 0x14C */ s32 noInputTimerMax; /* 0x150 */ s32 type; @@ -147,7 +145,7 @@ typedef struct EnHorse { /* 0x200 */ s32 curRaceWaypoint; /* 0x204 */ s32 boostSpeed; /* 0x208 */ s32 playerControlled; - /* 0x20C */ s32 animationIdx; + /* 0x20C */ s32 animIndex; /* 0x210 */ f32 curFrame; /* 0x214 */ s32 soundTimer; /* 0x218 */ Vec3f unk_218; @@ -180,7 +178,7 @@ typedef struct EnHorse { /* 0x384 */ u16 cutsceneFlags; /* 0x388 */ s32 inRace; /* 0x38C */ struct EnIn* rider; - /* 0x390 */ UNK_TYPE1 unk390[0x4]; + /* 0x390 */ UNK_TYPE1 unk_390[0x4]; /* 0x394 */ u16 unk_394; /* 0x398 */ f32 unk_398; /* 0x39C */ s32 unk_39C; @@ -193,7 +191,7 @@ typedef struct EnHorse { /* 0x3C8 */ Vec3f backRightHoof; /* 0x3D4 */ Vec3f backLeftHoof; /* 0x3E0 */ s32 unk_3E0; - /* 0x3E4 */ UNK_TYPE1 unk3E4[0x4]; + /* 0x3E4 */ UNK_TYPE1 unk_3E4[0x4]; /* 0x3E8 */ f32 unk_3E8; /* 0x3EC */ s16 unk_3EC; /* 0x3EE */ Vec3s jointTable[OBJECT_HA_1_LIMB_MAX]; @@ -205,17 +203,36 @@ typedef struct EnHorse { /* 0x538 */ s32 unk_538; /* 0x53C */ s32 unk_53C; /* 0x540 */ Vec3f unk_540; - /* 0x54C */ UNK_TYPE1 unk54C[0x4]; + /* 0x54C */ UNK_TYPE unk_54C; /* 0x550 */ s32 unk_550; - /* 0x554 */ UNK_TYPE1 unk554[0x18]; + /* 0x554 */ UNK_TYPE unk_554; + /* 0x558 */ UNK_TYPE unk_558; + /* 0x55C */ s32 unk_55C; // maybe currentDistanceToCart... it isn't really a distance tho + /* 0x560 */ s32 unk_560; // maybe initialDistanceToCart + /* 0x564 */ s32 unk_564; // set but not used + /* 0x568 */ f32 unk_568; // set but not used /* 0x56C */ f32 unk_56C; - /* 0x570 */ Vec3f unk_570; + /* 0x570 */ Vec3f banditPosition; // Milk run minigame bandit /* 0x57C */ Vec3f unk_57C; - /* 0x588 */ UNK_TYPE1 unk588[0x4]; + /* 0x588 */ s16 unk_588; + /* 0x58A */ UNK_TYPE1 unk_58A[0x2]; // struct padding? /* 0x58C */ s32 unk_58C; /* 0x590 */ s32 unk_590; } EnHorse; // size = 0x594 -extern const ActorInit En_Horse_InitVars; +#define EN_HORSE_CHECK_1(horseActor) (((horseActor)->stateFlags & ENHORSE_FLAG_6) ? true : false) + +#define EN_HORSE_CHECK_2(horseActor) (((horseActor)->stateFlags & ENHORSE_FLAG_8) ? true : false) + +#define EN_HORSE_CHECK_3(horseActor) (((horseActor)->stateFlags & ENHORSE_FLAG_9) ? true : false) + +#define EN_HORSE_CHECK_4(horseActor) \ + (((((horseActor)->action == ENHORSE_ACTION_MOUNTED_IDLE) || ((horseActor)->action == ENHORSE_ACTION_FROZEN) || \ + ((horseActor)->action == ENHORSE_ACTION_MOUNTED_IDLE_WHINNYING)) && \ + !((horseActor)->stateFlags & ENHORSE_FLAG_19) && !((horseActor)->stateFlags & ENHORSE_FLAG_25)) \ + ? true \ + : false) + +#define EN_HORSE_CHECK_JUMPING(horseActor) (((horseActor)->stateFlags & ENHORSE_JUMPING) ? true : false) #endif // Z_EN_HORSE_H 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 7b9fa684e..1d2d0352c 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 @@ -11,29 +11,29 @@ #define THIS ((EnHorseGameCheck*)thisx) -void EnHorseGameCheck_Init(Actor* thisx, GlobalContext* globalCtx); -void EnHorseGameCheck_Destroy(Actor* thisx, GlobalContext* globalCtx); -void EnHorseGameCheck_Update(Actor* thisx, GlobalContext* globalCtx); -void EnHorseGameCheck_Draw(Actor* thisx, GlobalContext* globalCtx); +void EnHorseGameCheck_Init(Actor* thisx, PlayState* play); +void EnHorseGameCheck_Destroy(Actor* thisx, PlayState* play); +void EnHorseGameCheck_Update(Actor* thisx, PlayState* play); +void EnHorseGameCheck_Draw(Actor* thisx, PlayState* play); -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); +s32 func_808F8AA0(EnHorseGameCheck* this, PlayState* play); +s32 func_808F8C24(EnHorseGameCheck* this, PlayState* play); +s32 func_808F8C5C(EnHorseGameCheck* this, PlayState* play); +s32 func_808F8C70(EnHorseGameCheck* this, PlayState* play); +s32 func_808F8CCC(EnHorseGameCheck* this, PlayState* play2); +s32 func_808F8E94(EnHorseGameCheck* this, PlayState* play); +s32 func_808F8FAC(EnHorseGameCheck* this, PlayState* play); +s32 func_808F96E4(EnHorseGameCheck* this, PlayState* play); +s32 func_808F9830(EnHorseGameCheck* this, PlayState* play); +s32 func_808F9868(EnHorseGameCheck* this, PlayState* play); +s32 func_808F987C(EnHorseGameCheck* this, PlayState* play); +s32 func_808F990C(EnHorseGameCheck* this, PlayState* play); +s32 func_808F9944(EnHorseGameCheck* this, PlayState* play); +s32 func_808F9958(EnHorseGameCheck* this, PlayState* play); +s32 func_808F999C(EnHorseGameCheck* this, PlayState* play); +s32 func_808F99B0(EnHorseGameCheck* this, PlayState* play); +s32 func_808F99C4(EnHorseGameCheck* this, PlayState* play); +s32 func_808F99D8(EnHorseGameCheck* this, PlayState* play); const ActorInit En_Horse_Game_Check_InitVars = { ACTOR_EN_HORSE_GAME_CHECK, @@ -49,7 +49,7 @@ const ActorInit En_Horse_Game_Check_InitVars = { #include "overlays/ovl_En_Horse_Game_Check/ovl_En_Horse_Game_Check.c" -s32 func_808F8AA0(EnHorseGameCheck* this, GlobalContext* globalCtx) { +s32 func_808F8AA0(EnHorseGameCheck* this, PlayState* play) { s32 pad[3]; CollisionHeader* sp78 = NULL; MtxF sp38; @@ -66,51 +66,51 @@ s32 func_808F8AA0(EnHorseGameCheck* this, GlobalContext* globalCtx) { CollisionHeader_GetVirtual(&object_horse_game_check_Colheader_003918, &sp78); - this->dyna.bgId = DynaPoly_SetBgActor(globalCtx, &globalCtx->colCtx.dyna, &this->dyna.actor, sp78); + this->dyna.bgId = DynaPoly_SetBgActor(play, &play->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.floorHeight = + BgCheck_EntityRaycastFloor2(play, &play->colCtx, &this->dyna.actor.floorPoly, &this->dyna.actor.world.pos); this->dyna.actor.world.pos.y = this->dyna.actor.floorHeight + 3.0f; func_800C0094(this->dyna.actor.floorPoly, this->dyna.actor.world.pos.x, this->dyna.actor.floorHeight, this->dyna.actor.world.pos.z, &sp38); - Matrix_SetCurrentState(&sp38); - Matrix_RotateY(this->dyna.actor.shape.rot.y, MTXMODE_APPLY); + Matrix_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_CopyCurrentState(&sp38); + Matrix_Get(&sp38); - func_8018219C(&sp38, &this->dyna.actor.shape.rot, 1); + 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); +s32 func_808F8C24(EnHorseGameCheck* this, PlayState* play) { + DynaPoly_DeleteBgActor(play, &play->colCtx.dyna, this->dyna.bgId); return true; } -s32 func_808F8C5C(EnHorseGameCheck* this, GlobalContext* globalCtx) { +s32 func_808F8C5C(EnHorseGameCheck* this, PlayState* play) { return true; } -s32 func_808F8C70(EnHorseGameCheck* this, GlobalContext* globalCtx) { - if (Matrix_NewMtx(globalCtx->state.gfxCtx) == NULL) { +s32 func_808F8C70(EnHorseGameCheck* this, PlayState* play) { + if (Matrix_NewMtx(play->state.gfxCtx) == NULL) { return true; } else { - Gfx_DrawDListXlu(globalCtx, object_horse_game_check_DL_003030); - Gfx_DrawDListOpa(globalCtx, object_horse_game_check_DL_0030C0); + Gfx_DrawDListXlu(play, object_horse_game_check_DL_003030); + Gfx_DrawDListOpa(play, object_horse_game_check_DL_0030C0); } return true; } -s32 func_808F8CCC(EnHorseGameCheck* this, GlobalContext* globalCtx2) { - GlobalContext* globalCtx = globalCtx2; +s32 func_808F8CCC(EnHorseGameCheck* this, PlayState* play2) { + PlayState* play = play2; s32 pad; - Vec3f sp4C = { -1262.0f, 15.0f, 780.0f }; - Vec3f sp40 = { -1262.0f, -26.0f, 470.0f }; + Vec3f mainCamEye = { -1262.0f, 15.0f, 780.0f }; + Vec3f mainCamAt = { -1262.0f, -26.0f, 470.0f }; this->unk_164 = 0; this->unk_168 = 0; @@ -122,58 +122,58 @@ s32 func_808F8CCC(EnHorseGameCheck* this, GlobalContext* globalCtx2) { } func_8010E9F0(4, 0); - globalCtx->interfaceCtx.unk_280 = 1; + play->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); + this->horse1 = (EnHorse*)Actor_Spawn(&play->actorCtx, play, ACTOR_EN_HORSE, -1149.0f, -106.0f, 470.0f, 0, 0x7FFF, 0, + ENHORSE_PARAMS(ENHORSE_PARAM_BANDIT, ENHORSE_4)); 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); + this->horse2 = (EnHorse*)Actor_Spawn(&play->actorCtx, play, ACTOR_EN_HORSE, -1376.0f, -106.0f, 470.0f, 0, 0x7FFF, 0, + ENHORSE_PARAMS(ENHORSE_PARAM_BANDIT, ENHORSE_5)); 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); + Camera_ChangeSetting(play->cameraPtrs[CAM_ID_MAIN], CAM_SET_FREE0); + Play_SetCameraAtEye(play, CAM_ID_MAIN, &mainCamAt, &mainCamEye); + Play_SetCameraFov(play, CAM_ID_MAIN, 45.0f); func_800FE484(); return false; } -s32 func_808F8E94(EnHorseGameCheck* this, GlobalContext* globalCtx) { +s32 func_808F8E94(EnHorseGameCheck* this, PlayState* play) { gSaveContext.unk_3DD0[4] = 0; return true; } -s32 func_808F8EB0(EnHorseGameCheck* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); +s32 func_808F8EB0(EnHorseGameCheck* this, PlayState* play) { + Player* player = GET_PLAYER(play); - if (globalCtx->nextEntranceIndex == 0xCE20) { + if (play->nextEntrance == ENTRANCE(GORMAN_TRACK, 2)) { return false; } if (GET_RACE_FLAGS == RACE_FLAG_3) { - globalCtx->unk_1887F = 0x40; - gSaveContext.nextTransition = 2; + play->transitionType = TRANS_TYPE_64; + gSaveContext.nextTransitionType = TRANS_TYPE_02; } else if (GET_RACE_FLAGS == RACE_FLAG_2) { - globalCtx->unk_1887F = 0x50; - gSaveContext.nextTransition = 3; + play->transitionType = TRANS_TYPE_80; + gSaveContext.nextTransitionType = TRANS_TYPE_03; } else if (GET_RACE_FLAGS == RACE_FLAG_4) { SET_RACE_FLAGS(RACE_FLAG_3); - globalCtx->unk_1887F = 2; - gSaveContext.nextTransition = 2; + play->transitionType = TRANS_TYPE_02; + gSaveContext.nextTransitionType = TRANS_TYPE_02; } D_801BDA9C = 0; if (player->stateFlags1 & 0x800000) { D_801BDAA0 = 1; } - globalCtx->nextEntranceIndex = 0xCE20; - globalCtx->sceneLoadFlag = 0x14; + play->nextEntrance = ENTRANCE(GORMAN_TRACK, 2); + play->transitionTrigger = TRANS_TRIGGER_START; return false; } @@ -198,9 +198,9 @@ f32 D_808F9BCC[] = { 5368.0f, }; -s32 func_808F8FAC(EnHorseGameCheck* this, GlobalContext* globalCtx) { +s32 func_808F8FAC(EnHorseGameCheck* this, PlayState* play) { s32 pad[2]; - Player* player = GET_PLAYER(globalCtx); + Player* player = GET_PLAYER(play); s32 pad2; EnHorse* horse = (EnHorse*)player->rideActor; s32 pad3[2]; @@ -212,10 +212,10 @@ s32 func_808F8FAC(EnHorseGameCheck* this, GlobalContext* globalCtx) { if ((this->unk_168 > 50) && !(this->unk_164 & 2)) { this->unk_164 |= 2; - } else if ((globalCtx->interfaceCtx.unk_280 >= 8) && !(this->unk_164 & 1)) { + } else if ((play->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)) { + } else if ((play->interfaceCtx.unk_280 >= 8) && !(this->unk_164 & 8)) { EnHorse* horse = this->horse1; horse->inRace = true; @@ -228,7 +228,7 @@ s32 func_808F8FAC(EnHorseGameCheck* this, GlobalContext* globalCtx) { if ((this->unk_17C != -1) && ((this->unk_168 - this->unk_17C) > 10)) { this->unk_17C = -1; - func_800DFAC8(globalCtx->cameraPtrs[CAM_ID_MAIN], 4); + Camera_ChangeSetting(play->cameraPtrs[CAM_ID_MAIN], CAM_SET_HORSE); } this->unk_168++; @@ -242,7 +242,7 @@ s32 func_808F8FAC(EnHorseGameCheck* this, GlobalContext* globalCtx) { if (this->unk_174 > 0) { this->unk_174--; } else { - func_808F8EB0(this, globalCtx); + func_808F8EB0(this, play); } return true; } @@ -252,7 +252,7 @@ s32 func_808F8FAC(EnHorseGameCheck* this, GlobalContext* globalCtx) { play_sound(NA_SE_SY_START_SHOT); this->unk_164 |= 0x40000; gSaveContext.unk_3DD0[4] = 6; - SET_RACE_FLAGS(RACE_FLAG_4) + SET_RACE_FLAGS(RACE_FLAG_4); this->unk_174 = 60; } @@ -277,7 +277,7 @@ s32 func_808F8FAC(EnHorseGameCheck* this, GlobalContext* globalCtx) { } } - horseGameCheck = (EnHorseGameCheck*)DynaPoly_GetActor(&globalCtx->colCtx, this->horse1->unk_24C); + horseGameCheck = (EnHorseGameCheck*)DynaPoly_GetActor(&play->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)) { @@ -285,7 +285,7 @@ s32 func_808F8FAC(EnHorseGameCheck* this, GlobalContext* globalCtx) { play_sound(NA_SE_SY_START_SHOT); this->unk_164 |= 0x40000; gSaveContext.unk_3DD0[4] = 6; - SET_RACE_FLAGS(RACE_FLAG_3) + SET_RACE_FLAGS(RACE_FLAG_3); this->unk_174 = 60; } @@ -310,7 +310,7 @@ s32 func_808F8FAC(EnHorseGameCheck* this, GlobalContext* globalCtx) { } } - horseGameCheck = (EnHorseGameCheck*)DynaPoly_GetActor(&globalCtx->colCtx, this->horse2->unk_24C); + horseGameCheck = (EnHorseGameCheck*)DynaPoly_GetActor(&play->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)) { @@ -318,7 +318,7 @@ s32 func_808F8FAC(EnHorseGameCheck* this, GlobalContext* globalCtx) { play_sound(NA_SE_SY_START_SHOT); this->unk_164 |= 0x02000000; gSaveContext.unk_3DD0[4] = 6; - SET_RACE_FLAGS(RACE_FLAG_3) + SET_RACE_FLAGS(RACE_FLAG_3); this->unk_174 = 60; } @@ -339,7 +339,7 @@ s32 func_808F8FAC(EnHorseGameCheck* this, GlobalContext* globalCtx) { this->unk_164 |= 0x80; } - horseGameCheck = (EnHorseGameCheck*)DynaPoly_GetActor(&globalCtx->colCtx, horse->unk_24C); + horseGameCheck = (EnHorseGameCheck*)DynaPoly_GetActor(&play->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)) { @@ -347,13 +347,13 @@ s32 func_808F8FAC(EnHorseGameCheck* this, GlobalContext* globalCtx) { play_sound(NA_SE_SY_START_SHOT); this->unk_164 |= 0x800; gSaveContext.unk_3DD0[4] = 6; - SET_RACE_FLAGS(RACE_FLAG_2) + SET_RACE_FLAGS(RACE_FLAG_2); this->unk_174 = 60; } return true; } -s32 func_808F96E4(EnHorseGameCheck* this, GlobalContext* globalCtx) { +s32 func_808F96E4(EnHorseGameCheck* this, PlayState* play) { s32 pad[3]; CollisionHeader* sp78 = NULL; MtxF sp38; @@ -362,33 +362,33 @@ s32 func_808F96E4(EnHorseGameCheck* this, GlobalContext* globalCtx) { 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->dyna.bgId = DynaPoly_SetBgActor(play, &play->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.floorHeight = + BgCheck_EntityRaycastFloor2(play, &play->colCtx, &this->dyna.actor.floorPoly, &this->dyna.actor.world.pos); this->dyna.actor.world.pos.y = this->dyna.actor.floorHeight + 1.0f; func_800C0094(this->dyna.actor.floorPoly, this->dyna.actor.world.pos.x, this->dyna.actor.floorHeight, this->dyna.actor.world.pos.z, &sp38); - Matrix_SetCurrentState(&sp38); - Matrix_RotateY(this->dyna.actor.shape.rot.y, MTXMODE_APPLY); + Matrix_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_CopyCurrentState(&sp38); + Matrix_Get(&sp38); - func_8018219C(&sp38, &this->dyna.actor.shape.rot, 1); + 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); +s32 func_808F9830(EnHorseGameCheck* this, PlayState* play) { + DynaPoly_DeleteBgActor(play, &play->colCtx.dyna, this->dyna.bgId); return true; } -s32 func_808F9868(EnHorseGameCheck* this, GlobalContext* globalCtx) { +s32 func_808F9868(EnHorseGameCheck* this, PlayState* play) { return true; } @@ -397,7 +397,7 @@ static InitChainEntry sInitChain[] = { ICHAIN_F32(uncullZoneDownward, 300, ICHAIN_STOP), }; -s32 func_808F987C(EnHorseGameCheck* this, GlobalContext* globalCtx) { +s32 func_808F987C(EnHorseGameCheck* this, PlayState* play) { s32 pad[3]; CollisionHeader* sp28 = NULL; s32 pad2; @@ -408,39 +408,39 @@ s32 func_808F987C(EnHorseGameCheck* this, GlobalContext* globalCtx) { 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->dyna.bgId = DynaPoly_SetBgActor(play, &play->colCtx.dyna, &this->dyna.actor, sp28); this->unk_15C = ENHORSEGAMECHECK_FF_8; return true; } -s32 func_808F990C(EnHorseGameCheck* this, GlobalContext* globalCtx) { - DynaPoly_DeleteBgActor(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); +s32 func_808F990C(EnHorseGameCheck* this, PlayState* play) { + DynaPoly_DeleteBgActor(play, &play->colCtx.dyna, this->dyna.bgId); return true; } -s32 func_808F9944(EnHorseGameCheck* this, GlobalContext* globalCtx) { +s32 func_808F9944(EnHorseGameCheck* this, PlayState* play) { return true; } -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); +s32 func_808F9958(EnHorseGameCheck* this, PlayState* play) { + Gfx_DrawDListOpa(play, object_horse_game_check_DL_0014B0); + Gfx_DrawDListOpa(play, object_horse_game_check_DL_0013A0); return true; } -s32 func_808F999C(EnHorseGameCheck* this, GlobalContext* globalCtx) { +s32 func_808F999C(EnHorseGameCheck* this, PlayState* play) { return true; } -s32 func_808F99B0(EnHorseGameCheck* this, GlobalContext* globalCtx) { +s32 func_808F99B0(EnHorseGameCheck* this, PlayState* play) { return true; } -s32 func_808F99C4(EnHorseGameCheck* this, GlobalContext* globalCtx) { +s32 func_808F99C4(EnHorseGameCheck* this, PlayState* play) { return true; } -s32 func_808F99D8(EnHorseGameCheck* this, GlobalContext* globalCtx) { +s32 func_808F99D8(EnHorseGameCheck* this, PlayState* play) { return true; } @@ -460,7 +460,7 @@ EnHorseGameCheckUnkFunc D_808F9C5C[] = { NULL, NULL, NULL, NULL, NULL, func_808F8C70, NULL, NULL, func_808F9958, func_808F99D8, }; -void EnHorseGameCheck_Init(Actor* thisx, GlobalContext* globalCtx) { +void EnHorseGameCheck_Init(Actor* thisx, PlayState* play) { EnHorseGameCheck* this = THIS; this->unk_15C = ENHORSEGAMECHECK_GET_FF(&this->dyna.actor); @@ -471,30 +471,30 @@ void EnHorseGameCheck_Init(Actor* thisx, GlobalContext* globalCtx) { } if (D_808F9BE4[this->unk_15C] != NULL) { - D_808F9BE4[this->unk_15C](this, globalCtx); + D_808F9BE4[this->unk_15C](this, play); } } -void EnHorseGameCheck_Destroy(Actor* thisx, GlobalContext* globalCtx) { +void EnHorseGameCheck_Destroy(Actor* thisx, PlayState* play) { EnHorseGameCheck* this = THIS; if (D_808F9C0C[this->unk_15C] != NULL) { - D_808F9C0C[this->unk_15C](this, globalCtx); + D_808F9C0C[this->unk_15C](this, play); } } -void EnHorseGameCheck_Update(Actor* thisx, GlobalContext* globalCtx) { +void EnHorseGameCheck_Update(Actor* thisx, PlayState* play) { EnHorseGameCheck* this = THIS; if (D_808F9C34[this->unk_15C] != NULL) { - D_808F9C34[this->unk_15C](this, globalCtx); + D_808F9C34[this->unk_15C](this, play); } } -void EnHorseGameCheck_Draw(Actor* thisx, GlobalContext* globalCtx) { +void EnHorseGameCheck_Draw(Actor* thisx, PlayState* play) { EnHorseGameCheck* this = THIS; if (D_808F9C5C[this->unk_15C] != NULL) { - D_808F9C5C[this->unk_15C](this, globalCtx); + D_808F9C5C[this->unk_15C](this, play); } } 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 1e4bf4f5a..f07aafc1d 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 @@ -6,7 +6,7 @@ struct EnHorseGameCheck; -typedef s32 (*EnHorseGameCheckUnkFunc)(struct EnHorseGameCheck*, GlobalContext*); +typedef s32 (*EnHorseGameCheckUnkFunc)(struct EnHorseGameCheck*, PlayState*); #define ENHORSEGAMECHECK_GET_FF(thisx) ((thisx)->params & 0xFF) #define ENHORSEGAMECHECK_GET_FF00(thisx) (((thisx)->params & 0xFF00) >> 8) @@ -39,7 +39,7 @@ enum { 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 */ DynaPolyActor dyna; 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 da62a57e0..398bac6ca 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,17 +5,27 @@ */ #include "z_en_horse_link_child.h" +#include "objects/object_horse_link_child/object_horse_link_child.h" #define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_2000000) #define THIS ((EnHorseLinkChild*)thisx) -void EnHorseLinkChild_Init(Actor* thisx, GlobalContext* globalCtx); -void EnHorseLinkChild_Destroy(Actor* thisx, GlobalContext* globalCtx); -void EnHorseLinkChild_Update(Actor* thisx, GlobalContext* globalCtx); -void EnHorseLinkChild_Draw(Actor* thisx, GlobalContext* globalCtx); +void EnHorseLinkChild_Init(Actor* thisx, PlayState* play); +void EnHorseLinkChild_Destroy(Actor* thisx, PlayState* play); +void EnHorseLinkChild_Update(Actor* thisx, PlayState* play); +void EnHorseLinkChild_Draw(Actor* thisx, PlayState* play); + +void func_808DEA0C(EnHorseLinkChild* this, PlayState* play); +void func_808DEB14(EnHorseLinkChild* this, PlayState* play); +void func_808DECA0(EnHorseLinkChild* this); +void func_808DED40(EnHorseLinkChild* this, PlayState* play); +void func_808DEFE8(EnHorseLinkChild* this); +void func_808DF194(EnHorseLinkChild* this, PlayState* play); +void func_808DF620(EnHorseLinkChild* this, PlayState* play); +void func_808DF788(EnHorseLinkChild* this); +void func_808DF838(EnHorseLinkChild* this, PlayState* play); -#if 0 const ActorInit En_Horse_Link_Child_InitVars = { ACTOR_EN_HORSE_LINK_CHILD, ACTORCAT_BG, @@ -28,77 +38,559 @@ 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, PlayState* play) { + 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(&play->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(play, &this->colldierCylinder); + Collider_InitJntSph(play, &this->colliderJntSph); + Collider_SetJntSph(play, &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, PlayState* play) { + EnHorseLinkChild* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse_Link_Child/func_808DF620.s") + Skin_Free(&play->state, &this->skin); + Collider_DestroyCylinder(play, &this->colldierCylinder); + Collider_DestroyJntSph(play, &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, PlayState* play) { + 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, PlayState* play) { + f32 sp44 = Actor_XZDistanceBetweenActors(&this->actor, &GET_PLAYER(play)->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, PlayState* play) { + 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(play)->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(play)->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, PlayState* play) { + if ((this->unk_148 == 4) || (this->unk_148 == 3) || (this->unk_148 == 2)) { + Player* player = GET_PLAYER(play); + 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, PlayState* play) { + Player* player; + f32 sp50; + s32 sp4C; + s32 sp48; + + func_808DF088(this, play); + + player = GET_PLAYER(play); + 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, PlayState* play) { + 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(play)->actor) - this->actor.world.rot.y; + + if ((Math_CosS(sp36) < 0.7071f) && (this->unk_148 == 2)) { + func_800F415C(&this->actor, &GET_PLAYER(play)->actor.world.pos, 0x12C); + } + + 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, PlayState* play) { + Player* player = GET_PLAYER(play); + 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(play)->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, PlayState* play) { + s32 pad; + EnHorseLinkChild* this = THIS; + + D_808DFF30[this->unk_144](this, play); + Actor_MoveWithGravity(&this->actor); + Actor_UpdateBgCheckInfo(play, &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(play, &play->colChkCtx, &this->colldierCylinder.base); + + func_808DE660(this); +} + +void EnHorseLinkChild_PostSkinDraw(Actor* thisx, PlayState* play, 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(play, &play->colChkCtx, &this->colliderJntSph.base); +} + +s32 EnHorseLinkChild_OverrideSkinDraw(Actor* thisx, PlayState* play, s32 limbIndex, Skin* skin) { + EnHorseLinkChild* this = THIS; + + OPEN_DISPS(play->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(play->state.gfxCtx); + + return true; +} + +void EnHorseLinkChild_Draw(Actor* thisx, PlayState* play) { + EnHorseLinkChild* this = THIS; + + func_8012C28C(play->state.gfxCtx); + func_80138258(&this->actor, play, &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 ecc816c52..660261ca2 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 @@ -6,9 +6,21 @@ struct EnHorseLinkChild; +typedef void (*EnHorseLinkChildUnkFunc)(struct EnHorseLinkChild*, PlayState*); + 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 e15e3adb3..5fec47594 100644 --- a/src/overlays/actors/ovl_En_Hs/z_en_hs.c +++ b/src/overlays/actors/ovl_En_Hs/z_en_hs.c @@ -10,18 +10,18 @@ #define THIS ((EnHs*)thisx) -void EnHs_Init(Actor* thisx, GlobalContext* globalCtx); -void EnHs_Destroy(Actor* thisx, GlobalContext* globalCtx); -void EnHs_Update(Actor* thisx, GlobalContext* globalCtx); -void EnHs_Draw(Actor* thisx, GlobalContext* globalCtx); +void EnHs_Init(Actor* thisx, PlayState* play); +void EnHs_Destroy(Actor* thisx, PlayState* play); +void EnHs_Update(Actor* thisx, PlayState* play); +void EnHs_Draw(Actor* thisx, PlayState* play); -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 func_80953354(EnHs* this, GlobalContext* globalCtx); -void func_8095345C(EnHs* this, GlobalContext* globalCtx); +void func_80952FE0(EnHs* this, PlayState* play); +void func_80953098(EnHs* this, PlayState* play); +void func_80953180(EnHs* this, PlayState* play); +void EnHs_DoNothing(EnHs* this, PlayState* play); +void EnHs_SceneTransitToBunnyHoodDialogue(EnHs* this, PlayState* play); +void func_80953354(EnHs* this, PlayState* play); +void func_8095345C(EnHs* this, PlayState* play); const ActorInit En_Hs_InitVars = { ACTOR_EN_HS, @@ -57,280 +57,286 @@ static ColliderCylinderInit sCylinderInit = { Vec3f D_8095393C = { 300.0f, 1000.0f, 0.0f }; -void func_80952C50(EnHs* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); +void func_80952C50(EnHs* this, PlayState* play) { + Player* player = GET_PLAYER(play); s32 i; - for (i = 0; i < ARRAY_COUNT(this->unk_2A4); i++) { - Math_Vec3f_Copy(&this->unk_2A4[i], &player->actor.world.pos); + for (i = 0; i < ARRAY_COUNT(this->nwcPos); i++) { + Math_Vec3f_Copy(&this->nwcPos[i], &player->actor.world.pos); } - this->actor.home.rot.x = 0; - this->actor.home.rot.z = 0; + this->actor.home.rot.x = 0; // reset adult transformed count + this->actor.home.rot.z = 0; // reset chick count } -void EnHs_Init(Actor* thisx, GlobalContext* globalCtx) { +void EnHs_Init(Actor* thisx, PlayState* play) { s32 pad; EnHs* this = THIS; ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 36.0f); - SkelAnime_InitFlex(globalCtx, &this->skelAnime, &object_hs_Skel_006260, &object_hs_Anim_0005C0, this->jointTable, - this->morphTable, OBJECT_HS_LIMB_MAX); - Animation_PlayLoop(&this->skelAnime, &object_hs_Anim_0005C0); - Collider_InitAndSetCylinder(globalCtx, &this->collider, &this->actor, &sCylinderInit); + SkelAnime_InitFlex(play, &this->skelAnime, &gHsSkeleton, &gHsIdleAnim, this->jointTable, this->morphTable, + OBJECT_HS_LIMB_MAX); + Animation_PlayLoop(&this->skelAnime, &gHsIdleAnim); + Collider_InitAndSetCylinder(play, &this->collider, &this->actor, &sCylinderInit); this->actor.colChkInfo.mass = MASS_IMMOVABLE; Actor_SetScale(&this->actor, 0.01f); this->actionFunc = func_8095345C; - if (globalCtx->curSpawn == 1) { + + if (play->curSpawn == 1) { this->actor.flags |= ACTOR_FLAG_10000; } - this->unk_2A0 = 0; + + this->stateFlags = 0; this->actor.targetMode = 6; - func_80952C50(this, globalCtx); + func_80952C50(this, play); } -void EnHs_Destroy(Actor* thisx, GlobalContext* globalCtx) { +void EnHs_Destroy(Actor* thisx, PlayState* play) { EnHs* this = THIS; - Collider_DestroyCylinder(globalCtx, &this->collider); + Collider_DestroyCylinder(play, &this->collider); } -void func_80952DFC(GlobalContext* globalCtx) { +void func_80952DFC(PlayState* play) { if (INV_CONTENT(ITEM_MASK_BUNNY) == ITEM_MASK_BUNNY) { - func_80151BB4(globalCtx, 0x2E); + func_80151BB4(play, 0x2E); } - func_80151BB4(globalCtx, 0x10); + func_80151BB4(play, 0x10); } -void func_80952E50(Vec3f* dst, Vec3f src, f32 arg2) { - Vec3f sp1C; - f32 temp_f0; +void EnHs_UpdateChickPos(Vec3f* dst, Vec3f src, f32 offset) { + Vec3f diff; + f32 distance; - Math_Vec3f_Diff(&src, dst, &sp1C); + Math_Vec3f_Diff(&src, dst, &diff); - temp_f0 = SQ(sp1C.x) + SQ(sp1C.z); + distance = SQ(diff.x) + SQ(diff.z); // gets un-squared after we check if we are too close - if (SQ(arg2) > temp_f0) { + if (SQ(offset) > distance) { return; } - temp_f0 = sqrtf(temp_f0); - sp1C.x *= (temp_f0 - arg2) / temp_f0; - sp1C.z *= (temp_f0 - arg2) / temp_f0; + distance = sqrtf(distance); + diff.x *= (distance - offset) / distance; + diff.z *= (distance - offset) / distance; - dst->x += sp1C.x; - dst->z += sp1C.z; + dst->x += diff.x; + dst->z += diff.z; } -void func_80952F00(EnHs* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); +void func_80952F00(EnHs* this, PlayState* play) { + Player* player = GET_PLAYER(play); s32 i; - f32 phi_f20; + f32 offset; - if (this->actor.home.rot.z >= 20) { - phi_f20 = 15.0f; + if (this->actor.home.rot.z >= 20) { // current chick count >= 10 + offset = 15.0f; } else { - phi_f20 = 10.0f; + offset = 10.0f; } - func_80952E50(&this->unk_2A4[0], player->actor.world.pos, phi_f20); + EnHs_UpdateChickPos(&this->nwcPos[0], player->actor.world.pos, offset); - for (i = 1; i < ARRAY_COUNT(this->unk_2A4); i++) { - func_80952E50(&this->unk_2A4[i], this->unk_2A4[i - 1], phi_f20); + 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->unk_2A2 < 40) { - Math_SmoothStepToS(&this->unk_294.y, 0x1F40, 6, 0x1838, 0x64); - } else if (this->unk_2A2 < 80) { - Math_SmoothStepToS(&this->unk_294.y, -0x1F40, 6, 0x1838, 0x64); +void func_80952FE0(EnHs* this, PlayState* play) { + 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->unk_2A0 &= ~4; - func_80151938(globalCtx, 0x33F6); - func_80952DFC(globalCtx); + this->stateFlags &= ~4; + func_80151938(play, 0x33F6); + func_80952DFC(play); } - this->unk_2A2++; + this->stateTimer++; } -void func_80953098(EnHs* this, GlobalContext* globalCtx) { - if (Actor_HasParent(&this->actor, globalCtx)) { +void func_80953098(EnHs* this, PlayState* play) { + if (Actor_HasParent(&this->actor, play)) { this->actor.parent = NULL; this->actionFunc = func_8095345C; this->actor.flags |= ACTOR_FLAG_10000; - this->unk_2A0 |= 0x10; - func_800B8500(&this->actor, globalCtx, 1000.0f, 1000.0f, -1); + this->stateFlags |= 0x10; + func_800B8500(&this->actor, play, 1000.0f, 1000.0f, PLAYER_AP_MINUS1); } else { - this->unk_2A0 |= 8; + this->stateFlags |= 8; if (INV_CONTENT(ITEM_MASK_BUNNY) == ITEM_MASK_BUNNY) { - Actor_PickUp(&this->actor, globalCtx, GI_RUPEE_RED, 10000.0f, 50.0f); + Actor_PickUp(&this->actor, play, GI_RUPEE_RED, 10000.0f, 50.0f); } else { - Actor_PickUp(&this->actor, globalCtx, GI_MASK_BUNNY, 10000.0f, 50.0f); + Actor_PickUp(&this->actor, play, GI_MASK_BUNNY, 10000.0f, 50.0f); } } } -void func_80953180(EnHs* this, GlobalContext* globalCtx) { - if ((Message_GetState(&globalCtx->msgCtx) == 5) && Message_ShouldAdvance(globalCtx)) { - switch (globalCtx->msgCtx.currentTextId) { - case 0x33F4: - case 0x33F6: - func_801477B4(globalCtx); +void func_80953180(EnHs* this, PlayState* play) { + if ((Message_GetState(&play->msgCtx) == TEXT_STATE_5) && Message_ShouldAdvance(play)) { + switch (play->msgCtx.currentTextId) { + case 0x33F4: // text: laughing that they are all roosters (!) + case 0x33F6: // text: Grog regrets not being able to see his chicks reach adult hood + func_801477B4(play); this->actionFunc = func_8095345C; break; - case 0x33F7: + 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); + func_801477B4(play); this->actionFunc = func_80953098; - func_80953098(this, globalCtx); + func_80953098(this, play); break; - case 0x33F9: + case 0x33F9: // text: laughing that they are all roosters (.) this->actor.flags &= ~ACTOR_FLAG_10000; - func_801477B4(globalCtx); + func_801477B4(play); this->actionFunc = func_8095345C; break; - case 0x33F5: - globalCtx->msgCtx.unk11F10 = 0; + case 0x33F5: // He heard from his gramps (?) the moon is going to fall + play->msgCtx.msgLength = 0; this->actionFunc = func_80952FE0; - this->unk_2A2 = 0; - this->unk_294.z = 0; - this->unk_2A0 |= 4; + this->stateTimer = 0; + this->headRot.z = 0; + this->stateFlags |= 4; break; default: - func_801477B4(globalCtx); + func_801477B4(play); this->actionFunc = func_8095345C; break; } } } -void func_809532C0(EnHs* this, GlobalContext* globalCtx) { +void EnHs_DoNothing(EnHs* this, PlayState* play) { } -void func_809532D0(EnHs* this, GlobalContext* globalCtx) { - if (DECR(this->unk_2A2) == 0) { - globalCtx->nextEntranceIndex = globalCtx->setupExitList[ENHS_GET_F(&this->actor)]; - globalCtx->sceneLoadFlag = 0x14; +void EnHs_SceneTransitToBunnyHoodDialogue(EnHs* this, PlayState* play) { + if (DECR(this->stateTimer) == 0) { + play->nextEntrance = play->setupExitList[HS_GET_EXIT_INDEX(&this->actor)]; + play->transitionTrigger = TRANS_TRIGGER_START; gSaveContext.save.weekEventReg[25] |= 8; - this->actionFunc = func_809532C0; + this->actionFunc = EnHs_DoNothing; } } -void func_80953354(EnHs* this, GlobalContext* globalCtx) { - if (!Play_InCsMode(globalCtx)) { - func_800B7298(globalCtx, &this->actor, 7); - this->actionFunc = func_809532D0; +void func_80953354(EnHs* this, PlayState* play) { + if (!Play_InCsMode(play)) { + func_800B7298(play, &this->actor, 7); + this->actionFunc = EnHs_SceneTransitToBunnyHoodDialogue; } } -void func_809533A0(EnHs* this, GlobalContext* globalCtx) { +void func_809533A0(EnHs* this, PlayState* play) { u16 sp1E; - if ((globalCtx->curSpawn == 1) && !(this->unk_2A0 & 0x20)) { + if ((play->curSpawn == 1) && !(this->stateFlags & 0x20)) { sp1E = 0x33F7; - this->unk_2A0 |= 0x20; - } else if (this->unk_2A0 & 0x10) { + this->stateFlags |= 0x20; + } else if (this->stateFlags & 0x10) { sp1E = 0x33F9; - this->unk_2A0 &= ~0x10; + this->stateFlags &= ~0x10; } else if (gSaveContext.save.weekEventReg[25] & 8) { sp1E = 0x33F4; } else { sp1E = 0x33F5; } - Message_StartTextbox(globalCtx, sp1E, &this->actor); + Message_StartTextbox(play, sp1E, &this->actor); if (sp1E == 0x33F4) { - func_80952DFC(globalCtx); + func_80952DFC(play); } } -void func_8095345C(EnHs* this, GlobalContext* globalCtx) { - if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { +void func_8095345C(EnHs* this, PlayState* play) { + if (Actor_ProcessTalkRequest(&this->actor, &play->state)) { this->actionFunc = func_80953180; - func_809533A0(this, globalCtx); - if (this->unk_2A0 & 8) { - func_80952DFC(globalCtx); - this->unk_2A0 &= ~8; + func_809533A0(this, play); + if (this->stateFlags & 8) { + func_80952DFC(play); + this->stateFlags &= ~8; } - } else if (this->actor.home.rot.x >= 20) { + } else if (this->actor.home.rot.x >= 20) { // chicks turned adult >= 10 this->actionFunc = func_80953354; - this->unk_2A2 = 40; + 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->unk_2A0 |= 1; - } else if ((this->actor.xzDistToPlayer < 120.0f) && Player_IsFacingActor(&this->actor, 0x2000, globalCtx)) { - func_800B8614(&this->actor, globalCtx, 130.0f); - this->unk_2A0 |= 1; + func_800B8500(&this->actor, play, 1000.0f, 1000.0f, PLAYER_AP_MINUS1); + this->stateFlags |= 1; + } else if ((this->actor.xzDistToPlayer < 120.0f) && Player_IsFacingActor(&this->actor, 0x2000, play)) { + func_800B8614(&this->actor, play, 130.0f); + this->stateFlags |= 1; } else { - this->unk_2A0 &= ~1; + this->stateFlags &= ~1; } } -void EnHs_Update(Actor* thisx, GlobalContext* globalCtx) { +void EnHs_Update(Actor* thisx, PlayState* play) { s32 pad; EnHs* this = THIS; Collider_UpdateCylinder(&this->actor, &this->collider); - CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + CollisionCheck_SetOC(play, &play->colChkCtx, &this->collider.base); Actor_MoveWithGravity(&this->actor); - Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 0.0f, 0.0f, 0.0f, 4); + Actor_UpdateBgCheckInfo(play, &this->actor, 0.0f, 0.0f, 0.0f, 4); if (SkelAnime_Update(&this->skelAnime)) { this->skelAnime.curFrame = 0.0f; } - this->actionFunc(this, globalCtx); + this->actionFunc(this, play); - func_80952F00(this, globalCtx); + func_80952F00(this, play); - if (this->unk_2A0 & 4) { - Math_SmoothStepToS(&this->unk_294.x, 0, 6, 0x1838, 0x64); - Math_SmoothStepToS(&this->unk_29A.x, 0, 6, 0x1838, 0x64); - Math_SmoothStepToS(&this->unk_29A.y, 0, 6, 0x1838, 0x64); - } else if (this->unk_2A0 & 1) { - func_800E9250(globalCtx, &this->actor, &this->unk_294, &this->unk_29A, this->actor.focus.pos); + 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(play, &this->actor, &this->headRot, &this->unusedRot, this->actor.focus.pos); } else { - Math_SmoothStepToS(&this->unk_294.x, 0x3200, 6, 0x1838, 0x64); - Math_SmoothStepToS(&this->unk_294.y, 0, 6, 0x1838, 0x64); - Math_SmoothStepToS(&this->unk_29A.x, 0, 6, 0x1838, 0x64); - Math_SmoothStepToS(&this->unk_29A.y, 0, 6, 0x1838, 0x64); + 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) { +s32 EnHs_OverrideLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, Actor* thisx) { EnHs* this = THIS; switch (limbIndex) { - case OBJECT_HS_LIMB_09: - rot->x += this->unk_294.y; - rot->z += this->unk_294.x; + case HS_LIMB_HEAD: + rot->x += this->headRot.y; + rot->z += this->headRot.x; break; - case OBJECT_HS_LIMB_0A: - rot->x += this->unk_294.y; - rot->z += this->unk_294.x; + case HS_LIMB_HAIR_SPIKES: + rot->x += this->headRot.y; + rot->z += this->headRot.x; break; - case OBJECT_HS_LIMB_0B: + 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 == ENHS_1) { + if (this->actor.params == HS_TYPE_UNK1) { *dList = NULL; return false; } break; case OBJECT_HS_LIMB_0D: - if (this->actor.params == ENHS_1) { + if (this->actor.params == HS_TYPE_UNK1) { *dList = NULL; return false; } @@ -339,18 +345,18 @@ s32 EnHs_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, return false; } -void EnHs_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx) { +void EnHs_PostLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx) { EnHs* this = THIS; - if (limbIndex == OBJECT_HS_LIMB_09) { - Matrix_MultiplyVector3fByState(&D_8095393C, &this->actor.focus.pos); + if (limbIndex == HS_LIMB_HEAD) { + Matrix_MultVec3f(&D_8095393C, &this->actor.focus.pos); } } -void EnHs_Draw(Actor* thisx, GlobalContext* globalCtx) { +void EnHs_Draw(Actor* thisx, PlayState* play) { EnHs* this = THIS; - func_8012C5B0(globalCtx->state.gfxCtx); - SkelAnime_DrawFlexOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, + func_8012C5B0(play->state.gfxCtx); + SkelAnime_DrawFlexOpa(play, 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 0a50ee360..d72c72d15 100644 --- a/src/overlays/actors/ovl_En_Hs/z_en_hs.h +++ b/src/overlays/actors/ovl_En_Hs/z_en_hs.h @@ -6,24 +6,32 @@ struct EnHs; -typedef void (*EnHsActionFunc)(struct EnHs*, GlobalContext*); +typedef void (*EnHsActionFunc)(struct EnHs*, PlayState*); -#define ENHS_GET_F(thisx) ((thisx)->params & 0xF) +#define HS_GET_EXIT_INDEX(thisx) ((thisx)->params & 0xF) -#define ENHS_1 1 +#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 */ ColliderCylinder collider; - /* 0x0190 */ SkelAnime skelAnime; - /* 0x01D4 */ Vec3s jointTable[OBJECT_HS_LIMB_MAX]; - /* 0x0234 */ Vec3s morphTable[OBJECT_HS_LIMB_MAX]; - /* 0x0294 */ Vec3s unk_294; - /* 0x029A */ Vec3s unk_29A; - /* 0x02A0 */ u16 unk_2A0; - /* 0x02A2 */ s16 unk_2A2; - /* 0x02A4 */ Vec3f unk_2A4[20]; - /* 0x0394 */ EnHsActionFunc actionFunc; + /* 0x000 */ Actor actor; + /* 0x144 */ ColliderCylinder collider; + /* 0x190 */ SkelAnime skelAnime; + /* 0x1D4 */ Vec3s jointTable[OBJECT_HS_LIMB_MAX]; + /* 0x234 */ Vec3s morphTable[OBJECT_HS_LIMB_MAX]; + /* 0x294 */ Vec3s headRot; + /* 0x29A */ Vec3s unusedRot; // probably not chest, as chest is same limb as lower body + /* 0x2A0 */ u16 stateFlags; + /* 0x2A2 */ s16 stateTimer; // reused for different actionFunc + /* 0x2A4 */ Vec3f nwcPos[20]; // actual chick position are even values, odd values seem to be extra values for smoother chain + /* 0x394 */ EnHsActionFunc actionFunc; } EnHs; // size = 0x398 extern const ActorInit En_Hs_InitVars; diff --git a/src/overlays/actors/ovl_En_Hs2/z_en_hs2.c b/src/overlays/actors/ovl_En_Hs2/z_en_hs2.c index 02625ff9e..3e6ab858f 100644 --- a/src/overlays/actors/ovl_En_Hs2/z_en_hs2.c +++ b/src/overlays/actors/ovl_En_Hs2/z_en_hs2.c @@ -10,12 +10,12 @@ #define THIS ((EnHs2*)thisx) -void EnHs2_Init(Actor* thisx, GlobalContext* globalCtx); -void EnHs2_Destroy(Actor* thisx, GlobalContext* globalCtx); -void EnHs2_Update(Actor* thisx, GlobalContext* globalCtx); -void EnHs2_Draw(Actor* thisx, GlobalContext* globalCtx); +void EnHs2_Init(Actor* thisx, PlayState* play); +void EnHs2_Destroy(Actor* thisx, PlayState* play); +void EnHs2_Update(Actor* thisx, PlayState* play); +void EnHs2_Draw(Actor* thisx, PlayState* play); -void EnHs2_DoNothing(EnHs2* this, GlobalContext* globalCtx); +void EnHs2_DoNothing(EnHs2* this, PlayState* play); const ActorInit En_Hs2_InitVars = { ACTOR_EN_HS2, @@ -29,24 +29,24 @@ const ActorInit En_Hs2_InitVars = { (ActorFunc)EnHs2_Draw, }; -void EnHs2_Init(Actor* thisx, GlobalContext* globalCtx) { +void EnHs2_Init(Actor* thisx, PlayState* play) { EnHs2* this = THIS; Actor_SetScale(&this->actor, 1.0f); this->actionFunc = EnHs2_DoNothing; } -void EnHs2_Destroy(Actor* thisx, GlobalContext* globalCtx) { +void EnHs2_Destroy(Actor* thisx, PlayState* play) { } -void EnHs2_DoNothing(EnHs2* this, GlobalContext* globalCtx) { +void EnHs2_DoNothing(EnHs2* this, PlayState* play) { } -void EnHs2_Update(Actor* thisx, GlobalContext* globalCtx) { +void EnHs2_Update(Actor* thisx, PlayState* play) { EnHs2* this = THIS; - this->actionFunc(this, globalCtx); + this->actionFunc(this, play); } -void EnHs2_Draw(Actor* thisx, GlobalContext* globalCtx) { +void EnHs2_Draw(Actor* thisx, PlayState* play) { } diff --git a/src/overlays/actors/ovl_En_Hs2/z_en_hs2.h b/src/overlays/actors/ovl_En_Hs2/z_en_hs2.h index 3c7145f3a..2c7568235 100644 --- a/src/overlays/actors/ovl_En_Hs2/z_en_hs2.h +++ b/src/overlays/actors/ovl_En_Hs2/z_en_hs2.h @@ -5,7 +5,7 @@ struct EnHs2; -typedef void (*EnHs2ActionFunc)(struct EnHs2*, GlobalContext*); +typedef void (*EnHs2ActionFunc)(struct EnHs2*, PlayState*); typedef struct EnHs2 { /* 0x000 */ Actor actor; 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 7f847cf08..bc1ca559b 100644 --- a/src/overlays/actors/ovl_En_Ig/z_en_ig.c +++ b/src/overlays/actors/ovl_En_Ig/z_en_ig.c @@ -12,21 +12,52 @@ #define THIS ((EnIg*)thisx) -void EnIg_Init(Actor* thisx, GlobalContext* globalCtx); -void EnIg_Destroy(Actor* thisx, GlobalContext* globalCtx); -void EnIg_Update(Actor* thisx, GlobalContext* globalCtx); -void EnIg_Draw(Actor* thisx, GlobalContext* globalCtx); +void EnIg_Init(Actor* thisx, PlayState* play); +void EnIg_Destroy(Actor* thisx, PlayState* play); +void EnIg_Update(Actor* thisx, PlayState* play); +void EnIg_Draw(Actor* thisx, PlayState* play); -void func_80BF2AF8(EnIg* this, GlobalContext* globalCtx); -void func_80BF2BD4(EnIg* this, GlobalContext* globalCtx); +void func_80BF2AF8(EnIg* this, PlayState* play); +void func_80BF2BD4(EnIg* this, PlayState* play); -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,7 +143,7 @@ static ColliderSphereInit sSphereInit = { static CollisionCheckInfoInit2 sColChkInfoInit = { 0, 0, 0, 0, MASS_IMMOVABLE }; -static AnimationInfoS sAnimations[] = { +static AnimationInfoS sAnimationInfo[] = { { &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 }, @@ -125,12 +156,12 @@ static AnimationInfoS sAnimations[] = { { &object_dai_Anim_0040E0, 1.0f, 0, -1, ANIMMODE_LOOP, -4 }, }; -Actor* func_80BF1150(EnIg* this, GlobalContext* globalCtx, u8 actorCat, s16 actorId) { +Actor* func_80BF1150(EnIg* this, PlayState* play, u8 actorCat, s16 actorId) { Actor* foundActor = NULL; Actor* temp_v0; while (true) { - foundActor = SubS_FindActor(globalCtx, foundActor, actorCat, actorId); + foundActor = SubS_FindActor(play, foundActor, actorCat, actorId); if (foundActor == NULL) { break; @@ -151,7 +182,7 @@ Actor* func_80BF1150(EnIg* this, GlobalContext* globalCtx, u8 actorCat, s16 acto return foundActor; } -EnDoor* func_80BF1200(GlobalContext* globalCtx, s32 arg1) { +EnDoor* func_80BF1200(PlayState* play, s32 arg1) { s32 phi_a1; switch (arg1) { @@ -170,7 +201,7 @@ EnDoor* func_80BF1200(GlobalContext* globalCtx, s32 arg1) { phi_a1 = -1; break; } - return SubS_FindDoor(globalCtx, phi_a1); + return SubS_FindDoor(play, phi_a1); } void func_80BF1258(EnIg* this) { @@ -206,18 +237,18 @@ s32 func_80BF1284(EnIg* this, s32 arg1) { if (phi_v1) { this->unk_3FC = arg1; - ret = SubS_ChangeAnimationByInfoS(&this->skelAnime, sAnimations, arg1); + ret = SubS_ChangeAnimationByInfoS(&this->skelAnime, sAnimationInfo, arg1); this->unk_3D4 = this->skelAnime.playSpeed; } return ret; } -void func_80BF1354(EnIg* this, GlobalContext* globalCtx) { +void func_80BF1354(EnIg* this, PlayState* play) { Collider_UpdateCylinder(&this->actor, &this->collider1); - CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider1.base); + CollisionCheck_SetOC(play, &play->colChkCtx, &this->collider1.base); this->collider2.dim.worldSphere.radius = this->collider2.dim.modelSphere.radius * this->collider2.dim.scale; - CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider2.base); + CollisionCheck_SetOC(play, &play->colChkCtx, &this->collider2.base); } void func_80BF13E4(EnIg* this) { @@ -230,13 +261,13 @@ void func_80BF13E4(EnIg* this) { } } -Actor* func_80BF146C(EnIg* this, GlobalContext* globalCtx) { +Actor* func_80BF146C(EnIg* this, PlayState* play) { Actor* retActor; - if (this->unk_298.unk0 == 3) { - retActor = func_80BF1150(this, globalCtx, ACTORCAT_NPC, ACTOR_EN_AN); + if (this->scheduleResult == 3) { + retActor = func_80BF1150(this, play, ACTORCAT_NPC, ACTOR_EN_AN); } else { - retActor = &GET_PLAYER(globalCtx)->actor; + retActor = &GET_PLAYER(play)->actor; } return retActor; } @@ -317,7 +348,7 @@ s16 func_80BF1744(EnIg* this, s32 arg1) { return cs; } -s32 func_80BF17BC(EnIg* this, GlobalContext* globalCtx) { +s32 func_80BF17BC(EnIg* this, PlayState* play) { s32 pad; s16 sp2A; s32 ret; @@ -331,7 +362,7 @@ s32 func_80BF17BC(EnIg* this, GlobalContext* globalCtx) { case 2: case 4: if ((this->actor.child != NULL) && (this->actor.child->update != NULL)) { - Camera_SetTargetActor(Play_GetCamera(globalCtx, ActorCutscene_GetCurrentCamera(sp2A)), + Camera_SetTargetActor(Play_GetCamera(play, ActorCutscene_GetCurrentSubCamId(sp2A)), this->actor.child); } this->unk_3F6++; @@ -345,7 +376,7 @@ s32 func_80BF17BC(EnIg* this, GlobalContext* globalCtx) { ActorCutscene_Stop(sp2A); this->unk_3F6 = 5; } else { - Camera_SetTargetActor(Play_GetCamera(globalCtx, ActorCutscene_GetCurrentCamera(sp2A)), &this->actor); + Camera_SetTargetActor(Play_GetCamera(play, ActorCutscene_GetCurrentSubCamId(sp2A)), &this->actor); } this->unk_3F6++; ret = true; @@ -360,8 +391,8 @@ s32 func_80BF17BC(EnIg* this, GlobalContext* globalCtx) { return ret; } -s32* func_80BF1920(EnIg* this, GlobalContext* globalCtx) { - switch (this->unk_298.unk0) { +s32* func_80BF1920(EnIg* this, PlayState* play) { + switch (this->scheduleResult) { case 3: this->unk_3F8 = func_80BF17BC; return D_80BF335C; @@ -386,17 +417,17 @@ s32* func_80BF1920(EnIg* this, GlobalContext* globalCtx) { } } -s32 func_80BF19A0(EnIg* this, GlobalContext* globalCtx) { +s32 func_80BF19A0(EnIg* this, PlayState* play) { s32 ret = false; if (this->unk_3D0 & 7) { - if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { + if (Actor_ProcessTalkRequest(&this->actor, &play->state)) { 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, play); + if ((this->scheduleResult != 2) && (this->scheduleResult != 3) && (this->scheduleResult != 4)) { this->unk_3D0 |= 0x20; } this->actionFunc = func_80BF2BD4; @@ -406,7 +437,7 @@ s32 func_80BF19A0(EnIg* this, GlobalContext* globalCtx) { return ret; } -void func_80BF1A60(EnIg* this, GlobalContext* globalCtx) { +void func_80BF1A60(EnIg* this, PlayState* play) { if (this->unk_3F4 == 0) { func_80BF1284(this, 4); this->unk_3F4++; @@ -416,8 +447,8 @@ void func_80BF1A60(EnIg* this, GlobalContext* globalCtx) { } } -s32 func_80BF1AE0(EnIg* this, GlobalContext* globalCtx) { - switch (this->unk_298.unk0) { +s32 func_80BF1AE0(EnIg* this, PlayState* play) { + switch (this->scheduleResult) { case 3: func_80BF1284(this, 0); break; @@ -433,9 +464,9 @@ s32 func_80BF1AE0(EnIg* this, GlobalContext* globalCtx) { return true; } -s32 func_80BF1B40(EnIg* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); - u16 temp = globalCtx->msgCtx.currentTextId; +s32 func_80BF1B40(EnIg* this, PlayState* play) { + Player* player = GET_PLAYER(play); + u16 temp = play->msgCtx.currentTextId; s32 pad; if (player->stateFlags1 & 0xC40) { @@ -455,17 +486,17 @@ s32 func_80BF1B40(EnIg* this, GlobalContext* globalCtx) { this->unk_3D2 = 0; this->unk_3D0 &= ~0x400; if (1) {} - func_80BF1AE0(this, globalCtx); + func_80BF1AE0(this, play); } if (this->unk_18C != NULL) { - this->unk_18C(this, globalCtx); + this->unk_18C(this, play); } return false; } -s32 func_80BF1C44(EnIg* this, GlobalContext* globalCtx, struct_80133038_arg2* arg2, s32 arg3, s32 arg4) { +s32 func_80BF1C44(EnIg* this, PlayState* play, ScheduleOutput* scheduleOutput, s32 arg3, s32 arg4) { u8 sp4F = ENIG_GET_FF(&this->actor); Vec3s* sp48; Vec3f sp3C; @@ -474,18 +505,18 @@ s32 func_80BF1C44(EnIg* this, GlobalContext* globalCtx, struct_80133038_arg2* ar s32 pad; s32 sp24 = false; - sp2C = func_80BF1150(this, globalCtx, arg3, arg4); - this->unk_274 = NULL; + sp2C = func_80BF1150(this, play, arg3, arg4); + this->timePath = NULL; - if (D_80BF3318[arg2->unk0] >= 0) { - this->unk_274 = SubS_GetAdditionalPath(globalCtx, sp4F, D_80BF3318[arg2->unk0]); + if (D_80BF3318[scheduleOutput->result] >= 0) { + this->timePath = SubS_GetAdditionalPath(play, sp4F, D_80BF3318[scheduleOutput->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); @@ -495,10 +526,10 @@ 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, PlayState* play, ScheduleOutput* scheduleOutput) { s32 sp2C = 0; - if (func_80BF1C44(this, globalCtx, arg2, ACTORCAT_NPC, ACTOR_EN_AN)) { + if (func_80BF1C44(this, play, scheduleOutput, ACTORCAT_NPC, ACTOR_EN_AN)) { func_80BF1284(this, 0); SubS_UpdateFlags(&this->unk_3D0, 3, 7); this->unk_3D0 |= 0x20; @@ -508,8 +539,8 @@ 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.save.time - 0x3FFC; +s32 func_80BF1DF4(EnIg* this, PlayState* play, ScheduleOutput* scheduleOutput) { + u16 sp56 = SCHEDULE_TIME_NOW; u8 sp55 = ENIG_GET_FF(&this->actor); EnDoor* door; Vec3s* sp4C; @@ -518,16 +549,16 @@ s32 func_80BF1DF4(EnIg* this, GlobalContext* globalCtx, struct_80133038_arg2* ar s32 pad; s32 ret = false; - this->unk_274 = NULL; - door = func_80BF1200(globalCtx, arg2->unk0); + this->timePath = NULL; + door = func_80BF1200(play, scheduleOutput->result); - if (D_80BF3318[arg2->unk0] >= 0) { - this->unk_274 = SubS_GetAdditionalPath(globalCtx, sp55, D_80BF3318[arg2->unk0]); + if (D_80BF3318[scheduleOutput->result] >= 0) { + this->timePath = SubS_GetAdditionalPath(play, sp55, D_80BF3318[scheduleOutput->result]); } if ((door != NULL) && (door->dyna.actor.update != NULL)) { - if (this->unk_274 != NULL) { - sp4C = Lib_SegmentedToVirtual(this->unk_274->points); + 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); @@ -541,8 +572,8 @@ s32 func_80BF1DF4(EnIg* this, GlobalContext* globalCtx, struct_80133038_arg2* ar this->unk_2A4 = 75; } - this->unk_3E0 = arg2->unk8 - arg2->unk4; - this->unk_3E2 = sp56 - arg2->unk4; + this->unk_3E0 = scheduleOutput->time1 - scheduleOutput->time0; + this->unk_3E2 = sp56 - scheduleOutput->time0; this->actor.flags &= ~ACTOR_FLAG_1; this->unk_3D0 |= 0x100; func_80BF1284(this, 3); @@ -553,43 +584,44 @@ 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.save.time - 0x3FFC; +s32 func_80BF1FA8(EnIg* this, PlayState* play, ScheduleOutput* scheduleOutput) { + u16 sp2E = SCHEDULE_TIME_NOW; u16 phi_v1; u8 sp2B = ENIG_GET_FF(&this->actor); - s32 temp_t8; + u16 tmp; + s16 pad; s32 ret = false; - this->unk_274 = NULL; + this->timePath = NULL; - if (D_80BF3318[arg2->unk0] >= 0) { - this->unk_274 = SubS_GetAdditionalPath(globalCtx, sp2B, D_80BF3318[arg2->unk0]); + if (D_80BF3318[scheduleOutput->result] >= 0) { + this->timePath = SubS_GetAdditionalPath(play, sp2B, D_80BF3318[scheduleOutput->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 = scheduleOutput->time0; } - if (arg2->unk8 < phi_v1) { - this->unk_288 = (phi_v1 - arg2->unk8) + 0xFFFF; + if (scheduleOutput->time1 < phi_v1) { + this->timePathTotalTime = (phi_v1 - scheduleOutput->time1) + 0xFFFF; } else { - this->unk_288 = arg2->unk8 - phi_v1; + this->timePathTotalTime = scheduleOutput->time1 - phi_v1; } - this->unk_294 = sp2E - phi_v1; + this->timePathElapsedTime = sp2E - phi_v1; - phi_v1 = (this->unk_274->count - 2) & 0xFFFF; + tmp = 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 / tmp; + this->timePathWaypoint = + (this->timePathElapsedTime / this->timePathWaypointTime) + (SUBS_TIME_PATHING_ORDER - 1); this->unk_3D0 &= ~0x8; this->unk_3D0 &= ~0x10; @@ -602,7 +634,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, PlayState* play, ScheduleOutput* scheduleOutput) { u8 sp4F = ENIG_GET_FF(&this->actor); Vec3f sp40; Vec3f sp34; @@ -610,22 +642,22 @@ 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 = SubS_GetAdditionalPath(globalCtx, sp4F, D_80BF3318[arg2->unk0]); + if (D_80BF3318[scheduleOutput->result] >= 0) { + this->timePath = SubS_GetAdditionalPath(play, sp4F, D_80BF3318[scheduleOutput->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 (scheduleOutput->result) { case 2: this->actor.home.rot.y = this->actor.world.rot.y; this->actor.home.rot.y += 0x8000; @@ -647,20 +679,20 @@ 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, PlayState* play, ScheduleOutput* scheduleOutput) { s32 ret = false; this->actor.targetMode = 0; this->unk_3D0 = 0; this->actor.flags |= ACTOR_FLAG_1; - switch (arg2->unk0) { + switch (scheduleOutput->result) { case 5: case 6: case 7: case 8: case 9: - ret = func_80BF1DF4(this, globalCtx, arg2); + ret = func_80BF1DF4(this, play, scheduleOutput); break; case 10: @@ -668,22 +700,22 @@ s32 func_80BF2368(EnIg* this, GlobalContext* globalCtx, struct_80133038_arg2* ar case 12: case 13: case 14: - ret = func_80BF1FA8(this, globalCtx, arg2); + ret = func_80BF1FA8(this, play, scheduleOutput); break; case 2: case 4: - ret = func_80BF219C(this, globalCtx, arg2); + ret = func_80BF219C(this, play, scheduleOutput); break; case 3: - ret = func_80BF1D78(this, globalCtx, arg2); + ret = func_80BF1D78(this, play, scheduleOutput); break; } return ret; } -s32 func_80BF2400(EnIg* this, GlobalContext* globalCtx) { +s32 func_80BF2400(EnIg* this, PlayState* play) { Vec3f sp2C; Vec3f sp20; @@ -696,13 +728,13 @@ s32 func_80BF2400(EnIg* this, GlobalContext* globalCtx) { return true; } -s32 func_80BF2470(EnIg* this, GlobalContext* globalCtx) { - EnDoor* door = func_80BF1200(globalCtx, this->unk_298.unk0); +s32 func_80BF2470(EnIg* this, PlayState* play) { + EnDoor* door = func_80BF1200(play, this->scheduleResult); Vec3f sp38; f32 temp; s32 pad; - if (!func_8013AD6C(globalCtx) && (this->unk_3EC != 0)) { + if (!SubS_InCsMode(play) && (this->timePathTimeSpeed != 0)) { if ((door != NULL) && (door->dyna.actor.update != NULL)) { if (((f32)this->unk_3E2 / this->unk_3E0) <= 0.9f) { door->unk_1A7 = this->unk_2A4; @@ -716,7 +748,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); } @@ -724,58 +756,60 @@ s32 func_80BF2470(EnIg* this, GlobalContext* globalCtx) { return false; } -s32 func_80BF25E8(EnIg* this, GlobalContext* globalCtx) { - f32 sp7C[265]; +s32 func_80BF25E8(EnIg* this, PlayState* play) { + 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(play, 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(play)) { + 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(play)) { + 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); } return false; } -s32 func_80BF2890(EnIg* this, GlobalContext* globalCtx) { +s32 func_80BF2890(EnIg* this, PlayState* play) { if ((this->unk_3D0 & 0x100) && (this->unk_3F2 == 2)) { this->unk_3D0 &= ~0x100; } @@ -791,7 +825,7 @@ s32 func_80BF2890(EnIg* this, GlobalContext* globalCtx) { return true; } -s32 func_80BF293C(EnIg* this, GlobalContext* globalCtx) { +s32 func_80BF293C(EnIg* this, PlayState* play) { if (this->actor.world.rot.y != this->actor.home.rot.y) { if ((this->actor.world.rot.y / 182) != (this->actor.home.rot.y / 182)) { Math_ApproachS(&this->actor.world.rot.y, this->actor.home.rot.y, 3, 0x2AA8); @@ -806,14 +840,14 @@ s32 func_80BF293C(EnIg* this, GlobalContext* globalCtx) { return true; } -void func_80BF2A50(EnIg* this, GlobalContext* globalCtx) { - switch (this->unk_298.unk0) { +void func_80BF2A50(EnIg* this, PlayState* play) { + switch (this->scheduleResult) { case 10: case 11: case 12: case 13: case 14: - func_80BF25E8(this, globalCtx); + func_80BF25E8(this, play); break; case 5: @@ -821,57 +855,56 @@ void func_80BF2A50(EnIg* this, GlobalContext* globalCtx) { case 7: case 8: case 9: - func_80BF2470(this, globalCtx); + func_80BF2470(this, play); break; case 2: - func_80BF293C(this, globalCtx); + func_80BF293C(this, play); break; case 3: - func_80BF2400(this, globalCtx); + func_80BF2400(this, play); break; case 4: - func_80BF2890(this, globalCtx); + func_80BF2890(this, play); break; } Math_ApproachS(&this->actor.shape.rot.y, this->actor.world.rot.y, 3, 0x2AA8); } -void func_80BF2AF8(EnIg* this, GlobalContext* globalCtx) { - u32* unk_14 = &gSaveContext.save.daySpeed; - struct_80133038_arg2 sp20; +void func_80BF2AF8(EnIg* this, PlayState* play) { + ScheduleOutput 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(play, D_80BF3260, &sp20) || + ((this->scheduleResult != sp20.result) && !func_80BF2368(this, play, &sp20))) { this->actor.shape.shadowDraw = NULL; this->actor.flags &= ~ACTOR_FLAG_1; - sp20.unk0 = 0; + sp20.result = 0; } else { this->actor.shape.shadowDraw = ActorShadow_DrawCircle; this->actor.flags |= ACTOR_FLAG_1; } - this->unk_2A8 = func_80BF146C(this, globalCtx); - this->unk_298.unk0 = sp20.unk0; - func_80BF2A50(this, globalCtx); + this->unk_2A8 = func_80BF146C(this, play); + this->scheduleResult = sp20.result; + func_80BF2A50(this, play); } -void func_80BF2BD4(EnIg* this, GlobalContext* globalCtx) { +void func_80BF2BD4(EnIg* this, PlayState* play) { s16 yaw; Vec3f sp38; Vec3f sp2C; - if (func_8010BF58(&this->actor, globalCtx, this->unk_298.unk4, this->unk_3F8, &this->unk_298.unk8)) { + if (func_8010BF58(&this->actor, play, 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); @@ -880,52 +913,51 @@ void func_80BF2BD4(EnIg* this, GlobalContext* globalCtx) { } } -void EnIg_Init(Actor* thisx, GlobalContext* globalCtx) { +void EnIg_Init(Actor* thisx, PlayState* play) { EnIg* this = THIS; ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 28.0f); - SkelAnime_InitFlex(globalCtx, &this->skelAnime, &object_dai_Skel_0130D0, NULL, this->jointTable, this->morphTable, - 19); + SkelAnime_InitFlex(play, &this->skelAnime, &object_dai_Skel_0130D0, NULL, this->jointTable, this->morphTable, 19); this->unk_3FC = -1; func_80BF1284(this, 0); - Collider_InitAndSetCylinder(globalCtx, &this->collider1, &this->actor, &sCylinderInit); - Collider_InitAndSetSphere(globalCtx, &this->collider2, &this->actor, &sSphereInit); + Collider_InitAndSetCylinder(play, &this->collider1, &this->actor, &sCylinderInit); + Collider_InitAndSetSphere(play, &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); + this->actionFunc(this, play); } -void EnIg_Destroy(Actor* thisx, GlobalContext* globalCtx) { +void EnIg_Destroy(Actor* thisx, PlayState* play) { EnIg* this = THIS; - Collider_DestroyCylinder(globalCtx, &this->collider1); - Collider_DestroySphere(globalCtx, &this->collider2); + Collider_DestroyCylinder(play, &this->collider1); + Collider_DestroySphere(play, &this->collider2); } -void EnIg_Update(Actor* thisx, GlobalContext* globalCtx) { +void EnIg_Update(Actor* thisx, PlayState* play) { EnIg* this = THIS; - func_80BF19A0(this, globalCtx); + func_80BF19A0(this, play); - this->actionFunc(this, globalCtx); + this->actionFunc(this, play); - func_80BF1B40(this, globalCtx); + func_80BF1B40(this, play); - 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, play, 60.0f, 30.0f, PLAYER_AP_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); + Actor_UpdateBgCheckInfo(play, &this->actor, 30.0f, 12.0f, 0.0f, 4); + func_80BF1354(this, play); } } -s32 EnIg_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, Actor* thisx, +s32 EnIg_OverrideLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, Actor* thisx, Gfx** gfx) { EnIg* this = THIS; @@ -935,7 +967,7 @@ s32 EnIg_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, return false; } -void EnIg_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx, Gfx** gfx) { +void EnIg_PostLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx, Gfx** gfx) { static Vec3f D_80BF351C = { 1800.0f, -2000.0f, 0.0f }; static Vec3f D_80BF3528 = { 0.0f, 0.0f, 0.0f }; s32 pad; @@ -943,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); @@ -956,46 +988,46 @@ 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) { +void EnIg_TransformLimbDraw(PlayState* play, 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(); } } -void EnIg_Draw(Actor* thisx, GlobalContext* globalCtx) { +void EnIg_Draw(Actor* thisx, PlayState* play) { static TexturePtr D_80BF3534[] = { object_dai_Tex_0107B0, object_dai_Tex_010FB0, object_dai_Tex_0117B0, object_dai_Tex_011FB0, object_dai_Tex_0127B0, @@ -1003,23 +1035,23 @@ void EnIg_Draw(Actor* thisx, GlobalContext* globalCtx) { s32 pad; EnIg* this = THIS; - if (this->unk_298.unk0 != 0) { - func_8012C28C(globalCtx->state.gfxCtx); + if (this->scheduleResult != 0) { + func_8012C28C(play->state.gfxCtx); - OPEN_DISPS(globalCtx->state.gfxCtx); + OPEN_DISPS(play->state.gfxCtx); - Scene_SetRenderModeXlu(globalCtx, 0, 1); + Scene_SetRenderModeXlu(play, 0, 1); gSPSegment(POLY_OPA_DISP++, 0x08, Lib_SegmentedToVirtual(D_80BF3534[this->unk_3F2])); - POLY_OPA_DISP = SubS_DrawTransformFlex(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, + POLY_OPA_DISP = SubS_DrawTransformFlex(play, 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); + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_OPA_DISP++, object_dai_DL_00C538); - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->state.gfxCtx); } } 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..5ff18dfef 100644 --- a/src/overlays/actors/ovl_En_Ig/z_en_ig.h +++ b/src/overlays/actors/ovl_En_Ig/z_en_ig.h @@ -5,59 +5,61 @@ struct EnIg; -typedef void (*EnIgActionFunc)(struct EnIg*, GlobalContext*); -typedef s32 (*EnIgUnkFunc)(struct EnIg*, GlobalContext*); -typedef void (*EnIgUnkFunc2)(struct EnIg*, GlobalContext*); +typedef void (*EnIgActionFunc)(struct EnIg*, PlayState*); +typedef s32 (*EnIgUnkFunc)(struct EnIg*, PlayState*); +typedef void (*EnIgUnkFunc2)(struct EnIg*, PlayState*); #define ENIG_GET_FF(thisx) ((thisx)->params & 0xFF) typedef struct EnIg { - /* 0x0000 */ Actor actor; - /* 0x0144 */ SkelAnime skelAnime; - /* 0x0188 */ EnIgActionFunc actionFunc; - /* 0x018C */ EnIgUnkFunc2 unk_18C; - /* 0x0190 */ MtxF unk_190; - /* 0x01D0 */ ColliderCylinder collider1; - /* 0x021C */ ColliderSphere collider2; - /* 0x0274 */ Path* 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; - /* 0x02A4 */ s8 unk_2A4; - /* 0x02A8 */ Actor* unk_2A8; - /* 0x02AC */ UNK_TYPE1 unk2AC[0x4]; - /* 0x02B0 */ Vec3f unk_2B0; - /* 0x02BC */ Vec3f unk_2BC; - /* 0x02C8 */ UNK_TYPE1 unk2C8[0xC]; - /* 0x02D4 */ Vec3f unk_2D4; - /* 0x02E0 */ UNK_TYPE1 unk2E0[0x6]; - /* 0x02E6 */ Vec3s unk_2E6; - /* 0x02EC */ Vec3s jointTable[19]; - /* 0x035E */ Vec3s morphTable[19]; - /* 0x03D0 */ u16 unk_3D0; - /* 0x03D2 */ u16 unk_3D2; - /* 0x03D4 */ f32 unk_3D4; - /* 0x03D8 */ UNK_TYPE1 unk3D8[0x8]; - /* 0x03E0 */ s16 unk_3E0; - /* 0x03E2 */ s16 unk_3E2; - /* 0x03E4 */ s16 unk_3E4; - /* 0x03E6 */ s16 unk_3E6; - /* 0x03E8 */ s16 unk_3E8; - /* 0x03EA */ s16 unk_3EA; - /* 0x03EC */ s16 unk_3EC; - /* 0x03EE */ s16 unk_3EE; - /* 0x03F0 */ s16 unk_3F0; - /* 0x03F2 */ s16 unk_3F2; - /* 0x03F4 */ s16 unk_3F4; - /* 0x03F6 */ s16 unk_3F6; - /* 0x03F8 */ EnIgUnkFunc unk_3F8; - /* 0x03FC */ s32 unk_3FC; - /* 0x0400 */ UNK_TYPE1 unk400[0x8]; - /* 0x0408 */ s32 unk_408; + /* 0x000 */ Actor actor; + /* 0x144 */ SkelAnime skelAnime; + /* 0x188 */ EnIgActionFunc actionFunc; + /* 0x18C */ EnIgUnkFunc2 unk_18C; + /* 0x190 */ MtxF unk_190; + /* 0x1D0 */ ColliderCylinder collider1; + /* 0x21C */ ColliderSphere collider2; + /* 0x274 */ Path* timePath; + /* 0x278 */ Vec3f timePathTargetPos; + /* 0x284 */ f32 timePathProgress; + /* 0x288 */ s32 timePathTotalTime; + /* 0x28C */ s32 timePathWaypointTime; + /* 0x290 */ s32 timePathWaypoint; + /* 0x294 */ s32 timePathElapsedTime; + /* 0x298 */ u8 scheduleResult; + /* 0x29C */ s32* unk_29C; + /* 0x2A0 */ s32 unk_2A0; + /* 0x2A4 */ s8 unk_2A4; + /* 0x2A8 */ Actor* unk_2A8; + /* 0x2AC */ UNK_TYPE1 unk2AC[0x4]; + /* 0x2B0 */ Vec3f unk_2B0; + /* 0x2BC */ Vec3f unk_2BC; + /* 0x2C8 */ UNK_TYPE1 unk2C8[0xC]; + /* 0x2D4 */ Vec3f unk_2D4; + /* 0x2E0 */ UNK_TYPE1 unk2E0[0x6]; + /* 0x2E6 */ Vec3s unk_2E6; + /* 0x2EC */ Vec3s jointTable[19]; + /* 0x35E */ Vec3s morphTable[19]; + /* 0x3D0 */ u16 unk_3D0; + /* 0x3D2 */ u16 unk_3D2; + /* 0x3D4 */ f32 unk_3D4; + /* 0x3D8 */ UNK_TYPE1 unk3D8[0x8]; + /* 0x3E0 */ s16 unk_3E0; + /* 0x3E2 */ s16 unk_3E2; + /* 0x3E4 */ s16 unk_3E4; + /* 0x3E6 */ s16 unk_3E6; + /* 0x3E8 */ s16 unk_3E8; + /* 0x3EA */ s16 unk_3EA; + /* 0x3EC */ s16 timePathTimeSpeed; + /* 0x3EE */ s16 unk_3EE; + /* 0x3F0 */ s16 unk_3F0; + /* 0x3F2 */ s16 unk_3F2; + /* 0x3F4 */ s16 unk_3F4; + /* 0x3F6 */ s16 unk_3F6; + /* 0x3F8 */ EnIgUnkFunc unk_3F8; + /* 0x3FC */ s32 unk_3FC; + /* 0x400 */ UNK_TYPE1 unk400[0x8]; + /* 0x408 */ s32 unk_408; } EnIg; // size = 0x40C extern const ActorInit En_Ig_InitVars; diff --git a/src/overlays/actors/ovl_En_Ik/z_en_ik.c b/src/overlays/actors/ovl_En_Ik/z_en_ik.c index b782b82a3..a1c33264e 100644 --- a/src/overlays/actors/ovl_En_Ik/z_en_ik.c +++ b/src/overlays/actors/ovl_En_Ik/z_en_ik.c @@ -5,17 +5,75 @@ */ #include "z_en_ik.h" +#include "z64rumble.h" #define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_4 | ACTOR_FLAG_400) #define THIS ((EnIk*)thisx) -void EnIk_Init(Actor* thisx, GlobalContext* globalCtx); -void EnIk_Destroy(Actor* thisx, GlobalContext* globalCtx); -void EnIk_Update(Actor* thisx, GlobalContext* globalCtx); -void EnIk_Draw(Actor* thisx, GlobalContext* globalCtx); +void EnIk_Init(Actor* thisx, PlayState* play); +void EnIk_Destroy(Actor* thisx, PlayState* play); +void EnIk_Update(Actor* thisx, PlayState* play); +void EnIk_Draw(Actor* thisx, PlayState* play); + +void EnIk_Thaw(EnIk* this, PlayState* play); +s32 EnIk_IsChangingAction(EnIk* this, PlayState* play); +s32 EnIk_ChooseAttack(EnIk* this); +void EnIk_CheckActions(EnIk* this, PlayState* play); +void EnIk_SetupIdle(EnIk* this); +void EnIk_Idle(EnIk* this, PlayState* play); +void EnIk_SetupWalk(EnIk* this); +void EnIk_WalkTowardsPlayer(EnIk* this, PlayState* play); +void EnIk_SetupRun(EnIk* this); +void EnIk_RunTowardsPlayer(EnIk* this, PlayState* play); +void EnIk_SetupVerticalAttack(EnIk* this); +void EnIk_VerticalAttack(EnIk* this, PlayState* play); +void EnIk_SetupTakeOutAxe(EnIk* this); +void EnIk_TakeOutAxe(EnIk* this, PlayState* play); +void EnIk_SetupHorizontalDoubleAttack(EnIk* this); +void EnIk_HorizontalDoubleAttack(EnIk* this, PlayState* play); +void EnIk_SetupSingleHorizontalAttack(EnIk* this); +void EnIk_SingleHorizontalAttack(EnIk* this, PlayState* play); +void EnIk_SetupEndHorizontalAttack(EnIk* this); +void EnIk_EndHorizontalAttack(EnIk* this, PlayState* play); +void EnIk_SetupBlock(EnIk* this); +void EnIk_Block(EnIk* this, PlayState* play); +void EnIk_SetupReactToAttack(EnIk* this, s32 arg1); +void EnIk_ReactToAttack(EnIk* this, PlayState* play); +void EnIk_SetupDie(EnIk* this); +void EnIk_Die(EnIk* this, PlayState* play); +void EnIk_Frozen(EnIk* this, PlayState* play); +void EnIk_SetupCutscene(EnIk* this); +void EnIk_PlayCutscene(EnIk* this, PlayState* play); +void EnIk_UpdateDamage(EnIk* this, PlayState* play); +void EnIk_UpdateArmor(EnIk* this, PlayState* play); + +typedef struct { + /* 0x0 */ Gfx* unk00; + /* 0x4 */ s16 unk04; +} EnIkUnkStruct; // size = 0x8 + +EnIkUnkStruct sIronKnuckleArmorMarkings[] = { + { gIronKnuckleHelmetMarkingDL, 0x0000 }, + { gIronKnuckleFrontTorsoArmorMarkingDL, 0x0000 }, + { gIronKnuckleRearTorsoArmorMarkingDL, 0x7FFF }, + { gIronKnuckleRivetsMarking2DL, 0x4000 }, + { gIronKnuckleRivetsMarking1DL, 0xC000 }, + { NULL, 0x4000 }, + { NULL, 0xC000 }, +}; + +// sIronKnuckleArmorType[PARAM_VALUE][ARMOR_SECTIONS] +// ARMOR SECTIONS: +// 1 - Main armor +// 2 - Armor Accent (Side of armor and boot tips) +// 3 - Axe Color +static Gfx* sIronKnuckleArmorType[3][3] = { + { gIronKnuckleTanArmorMaterialDL, gIronKnuckleBronzeArmorMaterialDL, gIronKnuckleSilverArmorMaterialDL }, + { gIronKnuckleBlackArmorMaterialDL, gIronKnuckleBrownArmorMaterialDL, gIronKnuckleBrownArmorMaterialDL }, + { gIronKnuckleWhiteArmorMaterialDL, gIronKnuckleGoldArmorMaterialDL, gIronKnuckleGoldArmorMaterialDL }, +}; -#if 0 const ActorInit En_Ik_InitVars = { ACTOR_EN_IK, ACTORCAT_ENEMY, @@ -28,219 +86,1014 @@ const ActorInit En_Ik_InitVars = { (ActorFunc)EnIk_Draw, }; -// static ColliderCylinderInit sCylinderInit = { -static ColliderCylinderInit D_8092C01C = { - { COLTYPE_METAL, AT_NONE, AC_ON | AC_TYPE_PLAYER, OC1_ON | OC1_TYPE_ALL, OC2_TYPE_2, COLSHAPE_CYLINDER, }, - { ELEMTYPE_UNK2, { 0x00000000, 0x00, 0x00 }, { 0xF7CFFFFF, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_ON | BUMP_HOOKABLE, OCELEM_ON, }, +static ColliderCylinderInit sCylinderInit = { + { + COLTYPE_METAL, + AT_NONE, + AC_ON | AC_TYPE_PLAYER, + OC1_ON | OC1_TYPE_ALL, + OC2_TYPE_2, + COLSHAPE_CYLINDER, + }, + { + ELEMTYPE_UNK2, + { 0x00000000, 0x00, 0x00 }, + { 0xF7CFFFFF, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_ON | BUMP_HOOKABLE, + OCELEM_ON, + }, { 25, 80, 0, { 0, 0, 0 } }, }; -// static ColliderTrisElementInit sTrisElementsInit[2] = { -static ColliderTrisElementInit D_8092C048[2] = { +static ColliderTrisElementInit sTrisElementsInit[2] = { { - { ELEMTYPE_UNK2, { 0x00000000, 0x00, 0x00 }, { 0xF7CFFFFF, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_NONE, }, + { + ELEMTYPE_UNK2, + { 0x00000000, 0x00, 0x00 }, + { 0xF7CFFFFF, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_NONE, + }, { { { -10.0f, 14.0f, 2.0f }, { -10.0f, -6.0f, 2.0f }, { 9.0f, 14.0f, 2.0f } } }, }, { - { ELEMTYPE_UNK2, { 0x00000000, 0x00, 0x00 }, { 0xF7CFFFFF, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_NONE, }, + { + ELEMTYPE_UNK2, + { 0x00000000, 0x00, 0x00 }, + { 0xF7CFFFFF, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_NONE, + }, { { { -10.0f, -6.0f, 2.0f }, { 9.0f, -6.0f, 2.0f }, { 9.0f, 14.0f, 2.0f } } }, }, }; -// static ColliderTrisInit sTrisInit = { -static ColliderTrisInit D_8092C0C0 = { - { COLTYPE_METAL, AT_NONE, AC_ON | AC_HARD | AC_TYPE_PLAYER, OC1_NONE, OC2_TYPE_2, COLSHAPE_TRIS, }, - 2, D_8092C048, // sTrisElementsInit, +static ColliderTrisInit sTrisInit = { + { + COLTYPE_METAL, + AT_NONE, + AC_ON | AC_HARD | AC_TYPE_PLAYER, + OC1_NONE, + OC2_TYPE_2, + COLSHAPE_TRIS, + }, + ARRAY_COUNT(sTrisElementsInit), + sTrisElementsInit, }; -// static ColliderQuadInit sQuadInit = { -static ColliderQuadInit D_8092C0D0 = { - { COLTYPE_NONE, AT_NONE | AT_TYPE_ENEMY, AC_NONE, OC1_NONE, OC2_TYPE_2, COLSHAPE_QUAD, }, - { ELEMTYPE_UNK0, { 0x20000000, 0x04, 0x40 }, { 0x00000000, 0x00, 0x00 }, TOUCH_ON | TOUCH_SFX_NORMAL | TOUCH_UNK7, BUMP_NONE, OCELEM_NONE, }, +static ColliderQuadInit sQuadInit = { + { + COLTYPE_NONE, + AT_NONE | AT_TYPE_ENEMY, + AC_NONE, + OC1_NONE, + OC2_TYPE_2, + COLSHAPE_QUAD, + }, + { + ELEMTYPE_UNK0, + { 0x20000000, 0x04, 0x40 }, + { 0x00000000, 0x00, 0x00 }, + TOUCH_ON | TOUCH_SFX_NORMAL | TOUCH_UNK7, + BUMP_NONE, + OCELEM_NONE, + }, { { { 0.0f, 0.0f, 0.0f }, { 0.0f, 0.0f, 0.0f }, { 0.0f, 0.0f, 0.0f }, { 0.0f, 0.0f, 0.0f } } }, }; -// static DamageTable sDamageTable = { -static DamageTable D_8092C120 = { - /* Deku Nut */ DMG_ENTRY(0, 0xF), - /* Deku Stick */ DMG_ENTRY(0, 0xF), - /* Horse trample */ DMG_ENTRY(0, 0x0), - /* Explosives */ DMG_ENTRY(1, 0x0), - /* Zora boomerang */ DMG_ENTRY(0, 0xF), - /* Normal arrow */ DMG_ENTRY(0, 0xF), - /* UNK_DMG_0x06 */ DMG_ENTRY(0, 0x0), - /* Hookshot */ DMG_ENTRY(0, 0xF), - /* Goron punch */ DMG_ENTRY(2, 0x0), - /* Sword */ DMG_ENTRY(1, 0x0), - /* Goron pound */ DMG_ENTRY(3, 0x0), - /* Fire arrow */ DMG_ENTRY(0, 0xF), - /* Ice arrow */ DMG_ENTRY(0, 0xF), - /* Light arrow */ DMG_ENTRY(1, 0x4), - /* Goron spikes */ DMG_ENTRY(0, 0xF), - /* Deku spin */ DMG_ENTRY(0, 0xF), - /* Deku bubble */ DMG_ENTRY(0, 0xF), - /* Deku launch */ DMG_ENTRY(0, 0xF), - /* UNK_DMG_0x12 */ DMG_ENTRY(0, 0xF), - /* Zora barrier */ DMG_ENTRY(0, 0x0), - /* Normal shield */ DMG_ENTRY(0, 0x0), - /* Light ray */ DMG_ENTRY(0, 0x0), - /* Thrown object */ DMG_ENTRY(1, 0x0), - /* Zora punch */ DMG_ENTRY(0, 0xF), - /* Spin attack */ DMG_ENTRY(1, 0x0), - /* Sword beam */ DMG_ENTRY(0, 0x0), - /* Normal Roll */ DMG_ENTRY(0, 0x0), - /* UNK_DMG_0x1B */ DMG_ENTRY(0, 0x0), - /* UNK_DMG_0x1C */ DMG_ENTRY(0, 0x0), - /* Unblockable */ DMG_ENTRY(0, 0x0), - /* UNK_DMG_0x1E */ DMG_ENTRY(0, 0x0), - /* Powder Keg */ DMG_ENTRY(1, 0x0), +typedef enum { + /* 0x0 */ DMG_EFF_NONE, + /* 0x4 */ DMG_EFF_FIRE = 0x2, + /* 0x0 */ DMG_EFF_ICE, + /* 0x4 */ DMG_EFF_LIGHT_SPARKS, + /* 0xF */ DMG_EFF_IMMUNE = 0xF, + +} EnIkDmgEff; + +static DamageTable sDamageTableArmor = { + /* Deku Nut */ DMG_ENTRY(0, DMG_EFF_IMMUNE), + /* Deku Stick */ DMG_ENTRY(0, DMG_EFF_IMMUNE), + /* Horse trample */ DMG_ENTRY(0, DMG_EFF_NONE), + /* Explosives */ DMG_ENTRY(1, DMG_EFF_NONE), + /* Zora boomerang */ DMG_ENTRY(0, DMG_EFF_IMMUNE), + /* Normal arrow */ DMG_ENTRY(0, DMG_EFF_IMMUNE), + /* UNK_DMG_0x06 */ DMG_ENTRY(0, DMG_EFF_NONE), + /* Hookshot */ DMG_ENTRY(0, DMG_EFF_IMMUNE), + /* Goron punch */ DMG_ENTRY(2, DMG_EFF_NONE), + /* Sword */ DMG_ENTRY(1, DMG_EFF_NONE), + /* Goron pound */ DMG_ENTRY(3, DMG_EFF_NONE), + /* Fire arrow */ DMG_ENTRY(0, DMG_EFF_IMMUNE), + /* Ice arrow */ DMG_ENTRY(0, DMG_EFF_IMMUNE), + /* Light arrow */ DMG_ENTRY(1, DMG_EFF_LIGHT_SPARKS), + /* Goron spikes */ DMG_ENTRY(0, DMG_EFF_IMMUNE), + /* Deku spin */ DMG_ENTRY(0, DMG_EFF_IMMUNE), + /* Deku bubble */ DMG_ENTRY(0, DMG_EFF_IMMUNE), + /* Deku launch */ DMG_ENTRY(0, DMG_EFF_IMMUNE), + /* UNK_DMG_0x12 */ DMG_ENTRY(0, DMG_EFF_IMMUNE), + /* Zora barrier */ DMG_ENTRY(0, DMG_EFF_NONE), + /* Normal shield */ DMG_ENTRY(0, DMG_EFF_NONE), + /* Light ray */ DMG_ENTRY(0, DMG_EFF_NONE), + /* Thrown object */ DMG_ENTRY(1, DMG_EFF_NONE), + /* Zora punch */ DMG_ENTRY(0, DMG_EFF_IMMUNE), + /* Spin attack */ DMG_ENTRY(1, DMG_EFF_NONE), + /* Sword beam */ DMG_ENTRY(0, DMG_EFF_NONE), + /* Normal Roll */ DMG_ENTRY(0, DMG_EFF_NONE), + /* UNK_DMG_0x1B */ DMG_ENTRY(0, DMG_EFF_NONE), + /* UNK_DMG_0x1C */ DMG_ENTRY(0, DMG_EFF_NONE), + /* Unblockable */ DMG_ENTRY(0, DMG_EFF_NONE), + /* UNK_DMG_0x1E */ DMG_ENTRY(0, DMG_EFF_NONE), + /* Powder Keg */ DMG_ENTRY(1, DMG_EFF_NONE), }; -// static DamageTable sDamageTable = { -static DamageTable D_8092C140 = { - /* Deku Nut */ DMG_ENTRY(0, 0x0), - /* Deku Stick */ DMG_ENTRY(1, 0x0), - /* Horse trample */ DMG_ENTRY(0, 0x0), - /* Explosives */ DMG_ENTRY(1, 0x0), - /* Zora boomerang */ DMG_ENTRY(1, 0x0), - /* Normal arrow */ DMG_ENTRY(1, 0x0), - /* UNK_DMG_0x06 */ DMG_ENTRY(0, 0x0), - /* Hookshot */ DMG_ENTRY(0, 0xF), - /* Goron punch */ DMG_ENTRY(2, 0x0), - /* Sword */ DMG_ENTRY(1, 0x0), - /* Goron pound */ DMG_ENTRY(3, 0x0), - /* Fire arrow */ DMG_ENTRY(2, 0x2), - /* Ice arrow */ DMG_ENTRY(2, 0x3), - /* Light arrow */ DMG_ENTRY(2, 0x4), - /* Goron spikes */ DMG_ENTRY(1, 0x0), - /* Deku spin */ DMG_ENTRY(0, 0x0), - /* Deku bubble */ DMG_ENTRY(1, 0x0), - /* Deku launch */ DMG_ENTRY(0, 0x0), - /* UNK_DMG_0x12 */ DMG_ENTRY(0, 0x0), - /* Zora barrier */ DMG_ENTRY(0, 0x0), - /* Normal shield */ DMG_ENTRY(0, 0x0), - /* Light ray */ DMG_ENTRY(0, 0x0), - /* Thrown object */ DMG_ENTRY(1, 0x0), - /* Zora punch */ DMG_ENTRY(1, 0x0), - /* Spin attack */ DMG_ENTRY(1, 0x0), - /* Sword beam */ DMG_ENTRY(0, 0x0), - /* Normal Roll */ DMG_ENTRY(0, 0x0), - /* UNK_DMG_0x1B */ DMG_ENTRY(0, 0x0), - /* UNK_DMG_0x1C */ DMG_ENTRY(0, 0x0), - /* Unblockable */ DMG_ENTRY(0, 0x0), - /* UNK_DMG_0x1E */ DMG_ENTRY(0, 0x0), - /* Powder Keg */ DMG_ENTRY(1, 0x0), +static DamageTable sDamageTableNoArmor = { + /* Deku Nut */ DMG_ENTRY(0, DMG_EFF_NONE), + /* Deku Stick */ DMG_ENTRY(1, DMG_EFF_NONE), + /* Horse trample */ DMG_ENTRY(0, DMG_EFF_NONE), + /* Explosives */ DMG_ENTRY(1, DMG_EFF_NONE), + /* Zora boomerang */ DMG_ENTRY(1, DMG_EFF_NONE), + /* Normal arrow */ DMG_ENTRY(1, DMG_EFF_NONE), + /* UNK_DMG_0x06 */ DMG_ENTRY(0, DMG_EFF_NONE), + /* Hookshot */ DMG_ENTRY(0, DMG_EFF_IMMUNE), + /* Goron punch */ DMG_ENTRY(2, DMG_EFF_NONE), + /* Sword */ DMG_ENTRY(1, DMG_EFF_NONE), + /* Goron pound */ DMG_ENTRY(3, DMG_EFF_NONE), + /* Fire arrow */ DMG_ENTRY(2, DMG_EFF_FIRE), + /* Ice arrow */ DMG_ENTRY(2, DMG_EFF_ICE), + /* Light arrow */ DMG_ENTRY(2, DMG_EFF_LIGHT_SPARKS), + /* Goron spikes */ DMG_ENTRY(1, DMG_EFF_NONE), + /* Deku spin */ DMG_ENTRY(0, DMG_EFF_NONE), + /* Deku bubble */ DMG_ENTRY(1, DMG_EFF_NONE), + /* Deku launch */ DMG_ENTRY(0, DMG_EFF_NONE), + /* UNK_DMG_0x12 */ DMG_ENTRY(0, DMG_EFF_NONE), + /* Zora barrier */ DMG_ENTRY(0, DMG_EFF_NONE), + /* Normal shield */ DMG_ENTRY(0, DMG_EFF_NONE), + /* Light ray */ DMG_ENTRY(0, DMG_EFF_NONE), + /* Thrown object */ DMG_ENTRY(1, DMG_EFF_NONE), + /* Zora punch */ DMG_ENTRY(1, DMG_EFF_NONE), + /* Spin attack */ DMG_ENTRY(1, DMG_EFF_NONE), + /* Sword beam */ DMG_ENTRY(0, DMG_EFF_NONE), + /* Normal Roll */ DMG_ENTRY(0, DMG_EFF_NONE), + /* UNK_DMG_0x1B */ DMG_ENTRY(0, DMG_EFF_NONE), + /* UNK_DMG_0x1C */ DMG_ENTRY(0, DMG_EFF_NONE), + /* Unblockable */ DMG_ENTRY(0, DMG_EFF_NONE), + /* UNK_DMG_0x1E */ DMG_ENTRY(0, DMG_EFF_NONE), + /* Powder Keg */ DMG_ENTRY(1, DMG_EFF_NONE), }; -// sColChkInfoInit -static CollisionCheckInfoInit D_8092C160 = { 18, 25, 80, MASS_HEAVY }; +static CollisionCheckInfoInit sColChkInfoInit = { 18, 25, 80, MASS_HEAVY }; -// static InitChainEntry sInitChain[] = { -static InitChainEntry D_8092C168[] = { +static InitChainEntry sInitChain[] = { ICHAIN_F32(targetArrowOffset, 2916, ICHAIN_CONTINUE), ICHAIN_VEC3F_DIV1000(scale, 12, ICHAIN_CONTINUE), ICHAIN_F32_DIV1000(gravity, -1000, ICHAIN_STOP), }; -#endif +static EffectBlureInit2 sBlureInit = { + 0, 8, 0, { 255, 255, 150, 200 }, { 255, 255, 255, 64 }, { 255, 255, 150, 0 }, { 255, 255, 255, 0 }, 8, + 0, 2, 0, { 0, 0, 0, 0 }, { 0, 0, 0, 0 }, +}; -extern ColliderCylinderInit D_8092C01C; -extern ColliderTrisElementInit D_8092C048[2]; -extern ColliderTrisInit D_8092C0C0; -extern ColliderQuadInit D_8092C0D0; -extern DamageTable D_8092C120; -extern DamageTable D_8092C140; -extern CollisionCheckInfoInit D_8092C160; -extern InitChainEntry D_8092C168[]; +void EnIk_Init(Actor* thisx, PlayState* play) { + static s32 sDisplayListDesegmented = false; + s32 i; + EnIk* this = THIS; -extern UNK_TYPE D_06000CE8; -extern UNK_TYPE D_060015F8; -extern UNK_TYPE D_06001ABC; -extern UNK_TYPE D_06002484; -extern UNK_TYPE D_0600391C; -extern UNK_TYPE D_06004A04; -extern UNK_TYPE D_06005254; -extern UNK_TYPE D_060057F4; -extern UNK_TYPE D_06006294; + Actor_ProcessInitChain(&this->actor, sInitChain); + SkelAnime_InitFlex(play, &this->skelAnime, &gIronKnuckleSkel, &gIronKnuckleWalkAnim, this->jointTable, + this->morphTable, IRON_KNUCKLE_LIMB_MAX); + Collider_InitAndSetCylinder(play, &this->colliderCylinder, &this->actor, &sCylinderInit); + Collider_UpdateCylinder(&this->actor, &this->colliderCylinder); + Collider_InitAndSetTris(play, &this->colliderTris, &this->actor, &sTrisInit, this->shieldColliderItems); + Collider_InitAndSetQuad(play, &this->colliderQuad, &this->actor, &sQuadInit); + CollisionCheck_SetInfo(&this->actor.colChkInfo, &sDamageTableArmor, &sColChkInfoInit); + this->actor.params = IK_GET_ARMOR_TYPE(&this->actor); + this->actor.params--; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ik/EnIk_Init.s") + Effect_Add(play, &this->effectIndex, EFFECT_BLURE2, 0, 0, &sBlureInit); + if (!sDisplayListDesegmented) { + for (i = 0; i < ARRAY_COUNT(sIronKnuckleArmorType); i++) { + sIronKnuckleArmorType[i][0] = Lib_SegmentedToVirtual(sIronKnuckleArmorType[i][0]); + sIronKnuckleArmorType[i][1] = Lib_SegmentedToVirtual(sIronKnuckleArmorType[i][1]); + sIronKnuckleArmorType[i][2] = Lib_SegmentedToVirtual(sIronKnuckleArmorType[i][2]); + } + sDisplayListDesegmented = true; + } + EnIk_SetupIdle(this); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ik/EnIk_Destroy.s") +void EnIk_Destroy(Actor* thisx, PlayState* play) { + EnIk* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ik/func_80929AF8.s") + Collider_DestroyTris(play, &this->colliderTris); + Collider_DestroyCylinder(play, &this->colliderCylinder); + Collider_DestroyQuad(play, &this->colliderQuad); + Effect_Destroy(play, this->effectIndex); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ik/func_80929B6C.s") +void EnIk_Freeze(EnIk* this) { + this->drawDmgEffType = ACTOR_DRAW_DMGEFF_FROZEN_NO_SFX; + this->drawDmgEffScale = 0.65f; + this->drawDmgEffFrozenSteamScale = 97.5f * 0.01f; + this->drawDmgEffAlpha = 1.0f; + this->timer = 80; + this->actor.flags &= ~ACTOR_FLAG_400; + Actor_SetColorFilter(&this->actor, 0x4000, 255, 0, 80); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ik/func_80929BEC.s") +void EnIk_Thaw(EnIk* this, PlayState* play) { + if (this->drawDmgEffType == ACTOR_DRAW_DMGEFF_FROZEN_NO_SFX) { + this->drawDmgEffType = ACTOR_DRAW_DMGEFF_FIRE; + this->drawDmgEffAlpha = 0.0f; + Actor_SpawnIceEffects(play, &this->actor, this->limbPos, ARRAY_COUNT(this->limbPos), 2, 0.3f, 0.2f); + this->actor.flags |= ACTOR_FLAG_400; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ik/func_80929C80.s") +void EnIk_HitArmor(EnIk* this, PlayState* play) { + this->drawDmgEffAlpha = 4.0f; + this->drawDmgEffScale = 0.65f; + this->drawDmgEffType = ACTOR_DRAW_DMGEFF_LIGHT_ORBS; + Actor_Spawn(&play->actorCtx, play, ACTOR_EN_CLEAR_TAG, this->colliderCylinder.info.bumper.hitPos.x, + this->colliderCylinder.info.bumper.hitPos.y, this->colliderCylinder.info.bumper.hitPos.z, 0, 0, 0, + CLEAR_TAG_LARGE_LIGHT_RAYS); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ik/func_80929D04.s") +s32 EnIk_IsChangingAction(EnIk* this, PlayState* play) { + if ((this->drawArmorFlags) && (this->actionFunc != EnIk_Block) && + func_800BE184(play, &this->actor, 100.0f, 0x2710, 0x4000, this->actor.shape.rot.y)) { + EnIk_SetupBlock(this); + return true; + } + return false; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ik/func_80929E2C.s") +s32 EnIk_ChooseAttack(EnIk* this) { + s32 absYawDiff; + s32 detectionThreshold; // angle threshold an Iron Knuckle will use to trigger a horizontal attack -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ik/func_80929E88.s") + if ((this->actor.xzDistToPlayer < 100.0f) && (fabsf(this->actor.playerHeightRel) < 150.0f)) { -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ik/func_80929F20.s") + detectionThreshold = (this->drawArmorFlags == 0) ? 0xAAA : 0x3FFC; + absYawDiff = ABS_ALT(BINANG_SUB(this->actor.yawTowardsPlayer, this->actor.shape.rot.y)); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ik/func_80929FC8.s") + if (detectionThreshold >= absYawDiff) { + if (Rand_ZeroOne() < 0.5f) { + EnIk_SetupVerticalAttack(this); + return true; + } + EnIk_SetupHorizontalDoubleAttack(this); + return true; + } else if ((this->drawArmorFlags) || ((absYawDiff > 0x4000) && (Rand_ZeroOne() < 0.1f))) { + EnIk_SetupSingleHorizontalAttack(this); + return true; + } + } + return false; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ik/func_8092A020.s") +void EnIk_CheckActions(EnIk* this, PlayState* play) { + if (!EnIk_IsChangingAction(this, play) && !EnIk_ChooseAttack(this)) { + if (this->drawArmorFlags) { + EnIk_SetupRun(this); + } else { + EnIk_SetupWalk(this); + } + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ik/func_8092A124.s") +void EnIk_SetupIdle(EnIk* this) { + f32 frameCount = Animation_GetLastFrame(&gIronKnuckleHorizontalAttackAnim); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ik/func_8092A188.s") + if (this->drawArmorFlags) { + this->timer = 10; + } else { + this->timer = 0; + } + Animation_Change(&this->skelAnime, &gIronKnuckleEndHorizontalAttackAnim, 1.0f, frameCount, frameCount, + ANIMMODE_ONCE, this->timer); + this->actionFunc = EnIk_Idle; + this->actor.speedXZ = 0.0f; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ik/func_8092A28C.s") +void EnIk_Idle(EnIk* this, PlayState* play) { + if (this->timer > 0) { + this->timer--; + SkelAnime_Update(&this->skelAnime); + if (this->timer == 0) { + EnIk_CheckActions(this, play); + } + } else if (this->colliderCylinder.base.acFlags & AC_HIT) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_IRONNACK_ARMOR_HIT); + func_801A2E54(NA_BGM_MINI_BOSS); + this->actor.hintId = 0x35; + this->colliderCylinder.base.acFlags &= ~AC_HIT; + this->invincibilityFrames = 12; + EnIk_SetupWalk(this); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ik/func_8092A33C.s") +void EnIk_SetupWalk(EnIk* this) { + Animation_MorphToLoop(&this->skelAnime, &gIronKnuckleWalkAnim, -4.0f); + this->actor.speedXZ = 0.9f; + this->actor.world.rot.y = this->actor.shape.rot.y; + this->actionFunc = EnIk_WalkTowardsPlayer; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ik/func_8092A570.s") +void EnIk_WalkTowardsPlayer(EnIk* this, PlayState* play) { + s16 yawDiff; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ik/func_8092A5BC.s") + SkelAnime_Update(&this->skelAnime); + if (Animation_OnFrame(&this->skelAnime, 0.0f) || Animation_OnFrame(&this->skelAnime, 16.0f)) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_IRONNACK_WALK); + } + yawDiff = this->actor.wallYaw - this->actor.shape.rot.y; + if ((this->actor.bgCheckFlags & 8) && (ABS_ALT(yawDiff) >= 0x4000)) { + yawDiff = (this->actor.yawTowardsPlayer > 0) ? this->actor.wallYaw - 0x4000 : this->actor.wallYaw + 0x4000; + Math_ScaledStepToS(&this->actor.shape.rot.y, yawDiff, 0x320); + } else { + Math_ScaledStepToS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer, 0x320); + } + this->actor.world.rot.y = this->actor.shape.rot.y; + if (!EnIk_IsChangingAction(this, play)) { + EnIk_ChooseAttack(this); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ik/func_8092A680.s") +void EnIk_SetupRun(EnIk* this) { + Animation_MorphToLoop(&this->skelAnime, &gIronKnuckleRunAnim, -4.0f); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_TWINROBA_SHOOT_VOICE); + this->actor.speedXZ = 2.5f; + this->actor.world.rot.y = this->actor.shape.rot.y; + this->actionFunc = EnIk_RunTowardsPlayer; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ik/func_8092A754.s") +void EnIk_RunTowardsPlayer(EnIk* this, PlayState* play) { + s16 yawDiff; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ik/func_8092A8D8.s") + SkelAnime_Update(&this->skelAnime); + if (Animation_OnFrame(&this->skelAnime, 2.0f) || Animation_OnFrame(&this->skelAnime, 9.0f)) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_IRONNACK_WALK); + } + yawDiff = this->actor.wallYaw - this->actor.shape.rot.y; + if ((this->actor.bgCheckFlags & 8) && (ABS_ALT(yawDiff) >= 0x4000)) { + yawDiff = (this->actor.yawTowardsPlayer > 0) ? this->actor.wallYaw - 0x4000 : this->actor.wallYaw + 0x4000; + Math_ScaledStepToS(&this->actor.shape.rot.y, yawDiff, 0x4B0); + } else { + Math_ScaledStepToS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer, 0x4B0); + } + this->actor.world.rot.y = this->actor.shape.rot.y; + if (!EnIk_IsChangingAction(this, play)) { + EnIk_ChooseAttack(this); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ik/func_8092A994.s") +void EnIk_SetupVerticalAttack(EnIk* this) { + s32 pad; + f32 playbackSpeed; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ik/func_8092AA6C.s") + this->actor.speedXZ = 0.0f; + if (this->drawArmorFlags) { + playbackSpeed = 1.5f; + } else { + playbackSpeed = 1.2f; + } + Animation_Change(&this->skelAnime, &gIronKnuckleVerticalAttackAnim, playbackSpeed, 0.0f, + Animation_GetLastFrame(&gIronKnuckleVerticalAttackAnim.common), 3, -4.0f); + this->timer = 0; + this->blurEffectSpawnLock = -1; + this->actionFunc = EnIk_VerticalAttack; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ik/func_8092AB14.s") +void EnIk_VerticalAttack(EnIk* this, PlayState* play) { + Vec3f particlePos; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ik/func_8092AB50.s") + this->timer++; + if (!(this->skelAnime.curFrame < 7.0f) || !EnIk_IsChangingAction(this, play)) { + if (Animation_OnFrame(&this->skelAnime, 15.0f)) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_IRONNACK_SWING_AXE); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ik/func_8092ABD8.s") + } else if (Animation_OnFrame(&this->skelAnime, 21.0f)) { + particlePos.x = (Math_SinS((this->actor.shape.rot.y + 0x6A4)) * 70.0f) + this->actor.world.pos.x; + particlePos.z = (Math_CosS((this->actor.shape.rot.y + 0x6A4)) * 70.0f) + this->actor.world.pos.z; + particlePos.y = this->actor.world.pos.y; + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_IRONNACK_HIT_GND); + Camera_AddQuake(GET_ACTIVE_CAM(play), 2, 25, 5); + Rumble_Request(this->actor.xyzDistToPlayerSq, 180, 20, 100); + CollisionCheck_SpawnShieldParticles(play, &particlePos); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ik/func_8092AC4C.s") + if ((this->skelAnime.curFrame > 13.0f) && (this->skelAnime.curFrame < 23.0f)) { + this->colliderQuad.base.atFlags |= AT_ON; + if (this->drawArmorFlags) { + this->actor.speedXZ = sin_rad((this->skelAnime.curFrame - 13.0f) * (M_PI / 20)) * 10.0f; + } + } else { + this->colliderQuad.base.atFlags &= ~AT_ON; + this->actor.speedXZ = 0.0f; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ik/func_8092ACFC.s") + if ((this->drawArmorFlags) && (this->skelAnime.curFrame < 13.0f)) { + Math_ScaledStepToS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer, 0x5DC); + this->actor.world.rot.y = this->actor.shape.rot.y; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ik/func_8092ADB4.s") + if (SkelAnime_Update(&this->skelAnime)) { + EnIk_SetupTakeOutAxe(this); + } + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ik/func_8092AE14.s") +void EnIk_SetupTakeOutAxe(EnIk* this) { + Animation_PlayOnce(&this->skelAnime, &gIronKnuckleEndVerticalAttackAnim); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_IRONNACK_PULLOUT); + this->actionFunc = EnIk_TakeOutAxe; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ik/func_8092AFB4.s") +void EnIk_TakeOutAxe(EnIk* this, PlayState* play) { + if (SkelAnime_Update(&this->skelAnime)) { + if (this->skelAnime.animation == &gIronKnuckleRecoverVerticalAttackAnim) { + EnIk_CheckActions(this, play); + } else { + Animation_Change( + &this->skelAnime, &gIronKnuckleRecoverVerticalAttackAnim, (this->drawArmorFlags) ? 1.5f : 1.0f, 0.0f, + Animation_GetLastFrame(&gIronKnuckleRecoverVerticalAttackAnim.common), ANIMMODE_ONCE_INTERP, 0.0f); + } + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ik/func_8092AFD4.s") +void EnIk_SetupHorizontalDoubleAttack(EnIk* this) { + this->actor.speedXZ = 0.0f; + Animation_Change(&this->skelAnime, &gIronKnuckleHorizontalAttackAnim, (this->drawArmorFlags) ? 1.3f : 1.0f, 0.0f, + Animation_GetLastFrame(&gIronKnuckleHorizontalAttackAnim.common), ANIMMODE_ONCE_INTERP, + (this->drawArmorFlags) ? 4.0f : 10.0f); + this->timer = 0; + this->blurEffectSpawnLock = -1; + this->actionFunc = EnIk_HorizontalDoubleAttack; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ik/func_8092B03C.s") +void EnIk_HorizontalDoubleAttack(EnIk* this, PlayState* play) { + f32 phi_f2; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ik/func_8092B098.s") + this->timer++; + if ((Animation_OnFrame(&this->skelAnime, 1.0f)) || (Animation_OnFrame(&this->skelAnime, 13.0f))) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_IRONNACK_SWING_AXE); + } + if (((this->skelAnime.curFrame > 1.0f) && (this->skelAnime.curFrame < 9.0f)) || + ((this->skelAnime.curFrame > 12.0f) && (this->skelAnime.curFrame < 20.0f))) { + if (this->drawArmorFlags) { + Math_ScaledStepToS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer, 0x5DC); + this->actor.world.rot.y = this->actor.shape.rot.y; + if (this->skelAnime.curFrame > 12.0f) { + phi_f2 = this->skelAnime.curFrame - 12.0f; + } else { + phi_f2 = this->skelAnime.curFrame - 1.0f; + } + this->actor.speedXZ = sin_rad((M_PI / 8) * phi_f2) * 4.5f; + } + this->colliderQuad.base.atFlags |= AT_ON; + } else { + this->colliderQuad.base.atFlags &= ~AT_ON; + this->actor.speedXZ = 0.0f; + } + if (SkelAnime_Update(&this->skelAnime)) { + EnIk_SetupEndHorizontalAttack(this); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ik/func_8092B1B4.s") +void EnIk_SetupSingleHorizontalAttack(EnIk* this) { + f32 playSpeed; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ik/func_8092B46C.s") + this->actor.speedXZ = 0.0f; + if (this->drawArmorFlags) { + this->actor.world.rot.z = 0x1000; + playSpeed = 1.3f; + } else { + this->actor.world.rot.z = 0xB00; + playSpeed = 1.0f; + } + Animation_Change(&this->skelAnime, &gIronKnuckleHorizontalAttackAnim, playSpeed, 12.0f, + Animation_GetLastFrame(&gIronKnuckleHorizontalAttackAnim.common), ANIMMODE_ONCE_INTERP, 5.0f); + this->timer = 0; + this->blurEffectSpawnLock = -1; + this->actionFunc = EnIk_SingleHorizontalAttack; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ik/EnIk_Update.s") +void EnIk_SingleHorizontalAttack(EnIk* this, PlayState* play) { + this->timer++; + if (Animation_OnFrame(&this->skelAnime, 13.0f)) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_IRONNACK_SWING_AXE); + } + if ((this->skelAnime.curFrame > 12.0f) && (this->skelAnime.curFrame < 20.0f)) { + this->colliderQuad.base.atFlags |= AT_ON; + } else { + this->colliderQuad.base.atFlags &= ~AT_ON; + } + this->actor.shape.rot.y += this->actor.world.rot.z; + this->actor.world.rot.y = this->actor.shape.rot.y; + if (SkelAnime_Update(&this->skelAnime)) { + EnIk_SetupEndHorizontalAttack(this); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ik/func_8092B900.s") +void EnIk_SetupEndHorizontalAttack(EnIk* this) { + Animation_Change(&this->skelAnime, &gIronKnuckleEndHorizontalAttackAnim, (this->drawArmorFlags) ? 2.0f : 1.0f, 0.0f, + Animation_GetLastFrame(&gIronKnuckleHorizontalAttackAnim), ANIMMODE_ONCE_INTERP, -4.0f); + this->actionFunc = EnIk_EndHorizontalAttack; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ik/func_8092B93C.s") +void EnIk_EndHorizontalAttack(EnIk* this, PlayState* play) { + if (SkelAnime_Update(&this->skelAnime)) { + EnIk_CheckActions(this, play); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ik/func_8092BC6C.s") +void EnIk_SetupBlock(EnIk* this) { + this->actor.speedXZ = 0.0f; + Animation_Change(&this->skelAnime, &gIronKnuckleBlockAnim, 2.0f, 0.0f, + Animation_GetLastFrame(&gIronKnuckleBlockAnim), ANIMMODE_ONCE, -2.0f); + this->timer = 20; + this->actionFunc = EnIk_Block; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ik/EnIk_Draw.s") +void EnIk_Block(EnIk* this, PlayState* play) { + CollisionCheck_SetAC(play, &play->colChkCtx, &this->colliderTris.base); + if (SkelAnime_Update(&this->skelAnime)) { + this->timer--; + if (this->timer == 0) { + EnIk_CheckActions(this, play); + } + } +} + +void EnIk_SetupReactToAttack(EnIk* this, s32 arg1) { + s16 temp_v0; + + if (arg1) { + func_800BE504(&this->actor, &this->colliderCylinder); + } + this->actor.speedXZ = 6.0f; + temp_v0 = (this->actor.world.rot.y - this->actor.shape.rot.y) + 0x8000; + if (ABS_ALT(temp_v0) <= 0x4000) { + Animation_MorphToPlayOnce(&this->skelAnime, &gIronKnuckleFrontHitAnim, -4.0f); + } else { + Animation_MorphToPlayOnce(&this->skelAnime, &gIronKnuckleBackHitAnim, -4.0f); + } + this->actionFunc = EnIk_ReactToAttack; +} + +void EnIk_ReactToAttack(EnIk* this, PlayState* play) { + Math_StepToF(&this->actor.speedXZ, 0.0f, 1.0f); + if (this->subCamId != SUB_CAM_ID_DONE) { + Play_SetCameraAtEye(play, this->subCamId, &this->actor.focus.pos, &Play_GetCamera(play, this->subCamId)->eye); + } + if (SkelAnime_Update(&this->skelAnime)) { + if (this->subCamId != SUB_CAM_ID_DONE) { + ActorCutscene_Stop(this->actor.cutscene); + this->subCamId = SUB_CAM_ID_DONE; + EnIk_SetupIdle(this); + } else { + EnIk_CheckActions(this, play); + } + } else { + this->actor.colorFilterTimer = 12; + this->invincibilityFrames = 12; + } +} + +void EnIk_SetupDie(EnIk* this) { + this->actor.speedXZ = 0.0f; + Animation_MorphToPlayOnce(&this->skelAnime, &gIronKnuckleDeathAnim, -4.0f); + this->timer = 24; + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_IRONNACK_DEAD); + this->actionFunc = EnIk_Die; +} + +void EnIk_Die(EnIk* this, PlayState* play) { + static Vec3f sEffectVelAndAccel = { 0.0f, 0.5f, 0.0f }; + s32 i; + Vec3f effectPos; + + this->invincibilityFrames = 12; + if (SkelAnime_Update(&this->skelAnime)) { + if (this->timer == 24) { + SoundSource_PlaySfxEachFrameAtFixedWorldPos(play, &this->actor.world.pos, 35, + NA_SE_EN_COMMON_EXTINCT_LEV - SFX_FLAG); + } + + if (this->timer != 0) { + this->timer--; + for (i = 6 - (this->timer >> 2); i >= 0; i--) { + effectPos.x = randPlusMinusPoint5Scaled(80.0f) + this->actor.world.pos.x; + effectPos.z = randPlusMinusPoint5Scaled(80.0f) + this->actor.world.pos.z; + effectPos.y = randPlusMinusPoint5Scaled(50.0f) + (this->actor.world.pos.y + 20.0f); + func_800B3030(play, &effectPos, &sEffectVelAndAccel, &sEffectVelAndAccel, 100, 0, 2); + } + if (this->timer == 0) { + Item_DropCollectibleRandom(play, &this->actor, &this->actor.world.pos, 0xB0); + ActorCutscene_Stop(this->actor.cutscene); + Actor_MarkForDeath(&this->actor); + } + } + } else if (Animation_OnFrame(&this->skelAnime, 23.0f)) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_IRONNACK_WALK); + } +} + +void EnIk_SetupFrozen(EnIk* this) { + this->invincibilityFrames = 0; + this->actionFunc = EnIk_Frozen; + this->actor.speedXZ = 0.0f; +} + +void EnIk_Frozen(EnIk* this, PlayState* play) { + if (this->timer != 0) { + this->timer--; + } + if (this->timer == 0) { + EnIk_Thaw(this, play); + if (this->actor.colChkInfo.health == 0) { + EnIk_SetupCutscene(this); + } else { + EnIk_CheckActions(this, play); + } + } +} + +void EnIk_SetupCutscene(EnIk* this) { + ActorCutscene_SetIntentToPlay(this->actor.cutscene); + this->actor.speedXZ = 0.0f; + if (this->actor.colChkInfo.health != 0) { + func_800BE504(&this->actor, &this->colliderCylinder); + } + this->actionFunc = EnIk_PlayCutscene; +} + +void EnIk_PlayCutscene(EnIk* this, PlayState* play) { + Vec3f subCamEye; + + this->invincibilityFrames = 12; + if (ActorCutscene_GetCanPlayNext(this->actor.cutscene)) { + if (this->actor.cutscene != -1) { + ActorCutscene_StartAndSetFlag(this->actor.cutscene, &this->actor); + this->subCamId = ActorCutscene_GetCurrentSubCamId(this->actor.cutscene); + subCamEye.x = (Math_SinS((this->actor.shape.rot.y - 0x2000)) * 120.0f) + this->actor.focus.pos.x; + subCamEye.y = this->actor.focus.pos.y + 20.0f; + subCamEye.z = (Math_CosS((this->actor.shape.rot.y - 0x2000)) * 120.0f) + this->actor.focus.pos.z; + Play_SetCameraAtEye(play, this->subCamId, &this->actor.focus.pos, &subCamEye); + } + if (this->actor.colChkInfo.health != 0) { + EnIk_SetupReactToAttack(this, false); + } else { + EnIk_SetupDie(this); + } + } else { + ActorCutscene_SetIntentToPlay(this->actor.cutscene); + } +} + +void EnIk_UpdateDamage(EnIk* this, PlayState* play) { + s32 pad; + + if (this->actionFunc == EnIk_Idle) { + return; + } + if (this->colliderTris.base.acFlags & AC_BOUNCED) { + f32 frame = Animation_GetLastFrame(&gIronKnuckleBlockAnim) - 2.0f; + + if (this->skelAnime.curFrame < frame) { + this->skelAnime.curFrame = frame; + } + this->colliderTris.base.acFlags &= ~AC_BOUNCED; + this->colliderCylinder.base.acFlags &= ~AC_HIT; + } else if (this->colliderCylinder.base.acFlags & AC_HIT) { + s32 isArmorBroken = false; + + Actor_SetDropFlag(&this->actor, &this->colliderCylinder.info); + this->colliderCylinder.base.acFlags &= ~AC_HIT; + if ((this->actor.colChkInfo.damageEffect != DMG_EFF_IMMUNE) && + ((this->drawDmgEffType != ACTOR_DRAW_DMGEFF_FROZEN_NO_SFX) || + (!(this->colliderCylinder.info.acHitInfo->toucher.dmgFlags & 0xDB0B3)))) { + Actor_SetColorFilter(&this->actor, 0x4000, 255, 0, 12); + this->invincibilityFrames = 12; + EnIk_Thaw(this, play); + this->colliderQuad.base.atFlags &= ~AT_ON; + if (Actor_ApplyDamage(&this->actor) == 0) { + if (this->drawArmorFlags == 0) { + this->actor.colChkInfo.health = 9; + isArmorBroken = true; + } else { + Enemy_StartFinishingBlow(play, &this->actor); + func_801A2ED8(); + } + } + if (isArmorBroken == true) { + this->drawArmorFlags = 1; + this->colliderCylinder.base.colType = 3; + this->actor.colChkInfo.damageTable = &sDamageTableNoArmor; + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_IRONNACK_ARMOR_OFF_DEMO); + EnIk_SetupCutscene(this); + } else if (this->drawArmorFlags) { + if (this->actor.colChkInfo.damageEffect == DMG_EFF_ICE) { + EnIk_Freeze(this); + EnIk_SetupFrozen(this); + if (this->actor.colChkInfo.health == 0) { + this->timer = 3; + this->invincibilityFrames = 12; + } + } else { + if (this->actor.colChkInfo.damageEffect == DMG_EFF_FIRE) { + this->drawDmgEffAlpha = 4.0f; + this->drawDmgEffScale = 0.65f; + this->drawDmgEffType = ACTOR_DRAW_DMGEFF_FIRE; + } else if (this->actor.colChkInfo.damageEffect == DMG_EFF_LIGHT_SPARKS) { + EnIk_HitArmor(this, play); + } + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_IRONNACK_DAMAGE); + if (this->actor.colChkInfo.health != 0) { + EnIk_SetupReactToAttack(this, true); + } else { + EnIk_SetupCutscene(this); + } + } + } else { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_IRONNACK_ARMOR_HIT); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_IRONNACK_DAMAGE); + if (this->actor.colChkInfo.damageEffect == 4) { + EnIk_HitArmor(this, play); + } + } + } + } +} + +void EnIk_UpdateArmor(EnIk* this, PlayState* play) { + s32 pad; + s32 i; + IronKnuckleEffect* ikEffect; + Vec3f effectPos; + + for (i = 0; i < ARRAY_COUNT(this->effects); i++) { + ikEffect = &this->effects[i]; + + if (ikEffect->enabled) { + Math_Vec3f_Sum(&ikEffect->pos, &ikEffect->vel, &ikEffect->pos); + ikEffect->vel.y += -1.5f; + if (ikEffect->pos.y < this->actor.floorHeight) { + ikEffect->enabled = false; + ikEffect->pos.y = this->actor.floorHeight; + + for (i = 0; i < 4; i++) { + effectPos.x = randPlusMinusPoint5Scaled(20.0f) + ikEffect->pos.x; + effectPos.y = Rand_ZeroFloat(20.0f) + ikEffect->pos.y; + effectPos.z = randPlusMinusPoint5Scaled(20.0f) + ikEffect->pos.z; + func_800B3030(play, &effectPos, &gZeroVec3f, &gZeroVec3f, 40, 7, 2); + } + + SoundSource_PlaySfxAtFixedWorldPos(play, &ikEffect->pos, 11, NA_SE_EN_EXTINCT); + } + } + } +} + +void EnIk_Update(Actor* thisx, PlayState* play2) { + PlayState* play = play2; + EnIk* this = THIS; + + if (this->actionFunc != EnIk_PlayCutscene) { + EnIk_UpdateDamage(this, play); + } else { + this->colliderTris.base.acFlags &= ~AC_BOUNCED; + this->colliderCylinder.base.acFlags &= ~AC_HIT; + } + this->actionFunc(this, play); + Actor_MoveWithGravity(&this->actor); + Actor_UpdateBgCheckInfo(play, &this->actor, 75.0f, 30.0f, 30.0f, 0x1D); + this->actor.focus.rot.y = this->actor.shape.rot.y; + CollisionCheck_SetOC(play, &play->colChkCtx, &this->colliderCylinder.base); + if (this->invincibilityFrames == 0) { + CollisionCheck_SetAC(play, &play->colChkCtx, &this->colliderCylinder.base); + } else { + this->invincibilityFrames--; + } + if (this->colliderQuad.base.atFlags & AT_ON) { + CollisionCheck_SetAT(play, &play->colChkCtx, &this->colliderQuad.base); + } + if (this->actionFunc == EnIk_Block) { + f32 cos; + f32 sin; + Vec3f sp5C; + Vec3f sp50; + Vec3f sp44; + + cos = Math_CosS(this->actor.shape.rot.y); + sin = Math_SinS(this->actor.shape.rot.y); + + sp44.x = (this->actor.world.pos.x - (30.0f * cos)) + (20.0f * sin); + sp44.y = this->actor.world.pos.y; + sp44.z = this->actor.world.pos.z + (30.0f * sin) + (20.0f * cos); + + sp50.x = this->actor.world.pos.x + (30.0f * cos) + (20.0f * sin); + sp50.y = this->actor.world.pos.y + 80.0f; + sp50.z = (this->actor.world.pos.z - (30.0f * sin)) + (20.0f * cos); + + sp5C.x = sp44.x; + sp5C.y = sp50.y; + sp5C.z = sp44.z; + + Collider_SetTrisVertices(&this->colliderTris, 0, &sp44, &sp50, &sp5C); + sp5C.x = sp50.x; + sp5C.y = sp44.y; + sp5C.z = sp50.z; + Collider_SetTrisVertices(&this->colliderTris, 1, &sp44, &sp5C, &sp50); + CollisionCheck_SetAC(play, &play->colChkCtx, &this->colliderTris.base); + } + if (this->drawDmgEffAlpha > 0.0f) { + if (this->drawDmgEffType != ACTOR_DRAW_DMGEFF_FROZEN_NO_SFX) { + Math_StepToF(&this->drawDmgEffAlpha, 0.0f, 0.05f); + this->drawDmgEffScale = (this->drawDmgEffAlpha + 1.0f) * 0.325f; + if ((this->drawDmgEffAlpha + 1.0f) * 0.325f > 0.65f) { + this->drawDmgEffScale = 0.65f; + } else { + this->drawDmgEffScale = this->drawDmgEffScale; + } + } else if (!Math_StepToF(&this->drawDmgEffFrozenSteamScale, 0.65f, 0.01625f)) { + func_800B9010(&this->actor, NA_SE_EV_ICE_FREEZE - SFX_FLAG); + } + } + EnIk_UpdateArmor(this, play); +} + +s8 D_8092C1A8[] = { + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 0, -1, -1, -1, + -1, -1, -1, -1, -1, -1, 3, 5, 4, 6, 1, 2, -1, -1, 0, 0, +}; + +s32 EnIk_OverrideLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, Actor* thisx) { + EnIk* this = THIS; + + if (this->drawArmorFlags) { + if (D_8092C1A8[limbIndex] > 0) { + *dList = NULL; + } + } + return false; +} + +void EnIk_PostLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx) { + static Vec3f D_8092C1C8 = { 2000.0f, -200.0f, -5200.0f }; + static Vec3f D_8092C1D4 = { 300.0f, -200.0f, 0.0f }; + static s8 limbPosIndex[] = { + -1, -1, -1, 0, 1, 2, 3, 4, 5, -1, -1, -1, 6, -1, -1, 7, + -1, -1, 8, -1, 9, 10, -1, 11, -1, 12, -1, -1, -1, -1, 0, 0, + }; + + EnIk* this = THIS; + s32 index = D_8092C1A8[limbIndex]; + Gfx* xlu; + IronKnuckleEffect* ikEffect; + s16 sp76; + Vec3f vtxC; + Vec3f vtxD; + Vec3f vtxB; + Vec3f vtxA; + MtxF* mf; + + if (this->drawArmorFlags == 0x1) { + if (index > 0) { + ikEffect = &this->effects[index]; + mf = Matrix_GetCurrent(); + ikEffect->pos.x = mf->mf[3][0]; + ikEffect->pos.y = mf->mf[3][1]; + ikEffect->pos.z = mf->mf[3][2]; + Matrix_MtxFToYXZRot(mf, &ikEffect->rot, false); + ikEffect->enabled = true; + sp76 = sIronKnuckleArmorMarkings[index].unk04 + (((s32)Rand_Next() >> 0x13) + this->actor.shape.rot.y); + ikEffect->vel.x = Math_SinS(sp76) * 5.0f; + ikEffect->vel.y = 6.0f; + ikEffect->vel.z = Math_CosS(sp76) * 5.0f; + ikEffect->dList = *dList; + } + if (limbIndex == IRON_KNUCKLE_LIMB_WAIST) { + this->drawArmorFlags |= 0x2; + } + } + + if (limbIndex == IRON_KNUCKLE_LIMB_ROOT) { + Matrix_MultZero(&this->actor.focus.pos); + this->colliderCylinder.dim.pos.x = this->actor.focus.pos.x; + this->colliderCylinder.dim.pos.y = this->actor.world.pos.y; + this->colliderCylinder.dim.pos.z = this->actor.focus.pos.z; + } + + if ((limbIndex == IRON_KNUCKLE_LIMB_AXE) && (this->blurEffectSpawnLock != this->timer) && + ((this->actionFunc == EnIk_VerticalAttack) || (this->actionFunc == EnIk_HorizontalDoubleAttack) || + (this->actionFunc == EnIk_SingleHorizontalAttack))) { + Math_Vec3f_Copy(&vtxC, &this->colliderQuad.dim.quad[0]); + Math_Vec3f_Copy(&vtxD, &this->colliderQuad.dim.quad[1]); + Matrix_MultVec3f(&D_8092C1C8, &vtxB); + Matrix_MultVec3f(&D_8092C1D4, &vtxA); + Collider_SetQuadVertices(&this->colliderQuad, &vtxA, &vtxB, &vtxC, &vtxD); + if (this->colliderQuad.base.atFlags & AT_ON) { + EffectBlure_AddVertex(Effect_GetByIndex(this->effectIndex), &vtxB, &vtxA); + } + this->blurEffectSpawnLock = this->timer; + } + + if (limbPosIndex[limbIndex] != -1) { + Matrix_MultZero(&this->limbPos[limbPosIndex[limbIndex]]); + } + + if ((index == 0) || + ((index != -1) && (this->drawArmorFlags == 0) && (sIronKnuckleArmorMarkings[index].unk00 != 0))) { + OPEN_DISPS(play->state.gfxCtx); + + xlu = POLY_XLU_DISP; + + gSPMatrix(&xlu[0], Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(&xlu[1], sIronKnuckleArmorMarkings[index].unk00); + POLY_XLU_DISP = &xlu[2]; + + CLOSE_DISPS(play->state.gfxCtx); + } +} + +void EnIk_UpdateArmorDraw(EnIk* this, PlayState* play) { + Gfx* gfxOpa; + Gfx* gfxXlu; + s32 sp54; + IronKnuckleEffect* ikEffect; + s32 i; + + if (this->drawArmorFlags == (0x1 | 0x2)) { + sp54 = 0; + + OPEN_DISPS(play->state.gfxCtx); + gfxOpa = POLY_OPA_DISP; + gfxXlu = POLY_XLU_DISP; + + for (i = 0; i < ARRAY_COUNT(this->effects); i++) { + ikEffect = &this->effects[i]; + if (ikEffect->enabled) { + Matrix_SetTranslateRotateYXZ(ikEffect->pos.x, ikEffect->pos.y, ikEffect->pos.z, &ikEffect->rot); + Matrix_Scale(0.012f, 0.012f, 0.012f, MTXMODE_APPLY); + + gSPMatrix(gfxOpa++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(gfxOpa++, ikEffect->dList); + + if (sIronKnuckleArmorMarkings[i].unk00 != NULL) { + gSPMatrix(gfxXlu++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(gfxXlu++, sIronKnuckleArmorMarkings[i].unk00); + } + } else { + sp54++; + } + } + + if (sp54 == ARRAY_COUNT(this->effects)) { + this->drawArmorFlags = (0x1 | 0x4); + } + + POLY_XLU_DISP = gfxXlu; + POLY_OPA_DISP = gfxOpa; + + CLOSE_DISPS(play->state.gfxCtx); + } +} + +void EnIk_Draw(Actor* thisx, PlayState* play) { + static Vec3f D_8092C200 = { 0.53f, 0.53f, 0.53f }; + EnIk* this = THIS; + Gfx* gfx; + Gfx** gfxArmorType; + s32 pad; + + OPEN_DISPS(play->state.gfxCtx); + + func_800B8050(&this->actor, play, 0); + func_800B8118(&this->actor, play, 0); + gfx = POLY_XLU_DISP; + gSPDisplayList(&gfx[0], &sSetupDL[6 * 25]); + POLY_XLU_DISP = &gfx[1]; + gfx = POLY_OPA_DISP; + gSPDisplayList(&gfx[0], &sSetupDL[6 * 25]); + gfxArmorType = sIronKnuckleArmorType[this->actor.params]; + gSPSegment(&gfx[1], 0x08, gfxArmorType[0]); + gSPSegment(&gfx[2], 0x09, gfxArmorType[1]); + gSPSegment(&gfx[3], 0x0A, gfxArmorType[2]); + POLY_OPA_DISP = &gfx[4]; + + SkelAnime_DrawFlexOpa(play, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, + EnIk_OverrideLimbDraw, EnIk_PostLimbDraw, &this->actor); + EnIk_UpdateArmorDraw(this, play); + if (this->actor.colorFilterTimer != 0) { + func_800AE5A0(play); + } + func_800BC620(&this->actor.focus.pos, &D_8092C200, 255, play); + Actor_DrawDamageEffects(play, &this->actor, this->limbPos, ARRAY_COUNT(this->limbPos), this->drawDmgEffScale, + this->drawDmgEffFrozenSteamScale, this->drawDmgEffAlpha, this->drawDmgEffType); + + CLOSE_DISPS(play->state.gfxCtx); +} diff --git a/src/overlays/actors/ovl_En_Ik/z_en_ik.h b/src/overlays/actors/ovl_En_Ik/z_en_ik.h index ac6d71d82..a02c4845e 100644 --- a/src/overlays/actors/ovl_En_Ik/z_en_ik.h +++ b/src/overlays/actors/ovl_En_Ik/z_en_ik.h @@ -2,16 +2,50 @@ #define Z_EN_IK_H #include "global.h" +#include "objects/object_ik/object_ik.h" struct EnIk; -typedef void (*EnIkActionFunc)(struct EnIk*, GlobalContext*); +typedef void (*EnIkActionFunc)(struct EnIk*, PlayState*); + +#define IK_GET_ARMOR_TYPE(thisx) ((thisx)->params & 0xFF) + +typedef enum { + /* 1 */ IK_TYPE_SILVER = 1, + /* 2 */ IK_TYPE_BLACK, + /* 3 */ IK_TYPE_WHITE +} EnIkType; + +typedef struct { + /* 0x00 */ Gfx* dList; + /* 0x04 */ Vec3f pos; + /* 0x10 */ Vec3f vel; + /* 0x1C */ Vec3s rot; + /* 0x24 */ s32 enabled; +} IronKnuckleEffect; // size = 0x28 typedef struct EnIk { /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x1AC]; + /* 0x0144 */ SkelAnime skelAnime; + /* 0x0188 */ Vec3s jointTable[IRON_KNUCKLE_LIMB_MAX]; + /* 0x023C */ Vec3s morphTable[IRON_KNUCKLE_LIMB_MAX]; /* 0x02F0 */ EnIkActionFunc actionFunc; - /* 0x02F4 */ char unk_2F4[0x374]; + /* 0x02F4 */ u8 drawArmorFlags; // Value is 0 when Iron knuckle has armor, then changes to 5 for when armor is lost + /* 0x02F5 */ u8 drawDmgEffType; + /* 0x02F6 */ s16 timer; + /* 0x02F8 */ s16 blurEffectSpawnLock; + /* 0x02FA */ s16 subCamId; + /* 0x02FC */ s16 invincibilityFrames; + /* 0x0300 */ s32 effectIndex; + /* 0x0304 */ f32 drawDmgEffAlpha; + /* 0x0308 */ f32 drawDmgEffScale; + /* 0x030C */ f32 drawDmgEffFrozenSteamScale; + /* 0x0310 */ Vec3f limbPos[13]; + /* 0x03AC */ ColliderCylinder colliderCylinder; + /* 0x03F8 */ ColliderQuad colliderQuad; + /* 0x0478 */ ColliderTris colliderTris; + /* 0x0498 */ ColliderTrisElement shieldColliderItems[2]; + /* 0x0550 */ IronKnuckleEffect effects[7]; } EnIk; // size = 0x668 extern const ActorInit En_Ik_InitVars; diff --git a/src/overlays/actors/ovl_En_In/z_en_in.c b/src/overlays/actors/ovl_En_In/z_en_in.c index 758543f45..e5f56d857 100644 --- a/src/overlays/actors/ovl_En_In/z_en_in.c +++ b/src/overlays/actors/ovl_En_In/z_en_in.c @@ -12,15 +12,15 @@ #define THIS ((EnIn*)thisx) -void EnIn_Init(Actor* thisx, GlobalContext* globalCtx); -void EnIn_Destroy(Actor* thisx, GlobalContext* globalCtx); -void EnIn_Update(Actor* thisx, GlobalContext* globalCtx); -void EnIn_Draw(Actor* thisx, GlobalContext* globalCtx); +void EnIn_Init(Actor* thisx, PlayState* play); +void EnIn_Destroy(Actor* thisx, PlayState* play); +void EnIn_Update(Actor* thisx, PlayState* play); +void EnIn_Draw(Actor* thisx, PlayState* play); -void func_808F5A94(EnIn* this, GlobalContext* globalCtx); -void func_808F3690(EnIn* this, GlobalContext* globalCtx); -void func_808F5A34(EnIn* this, GlobalContext* globalCtx); -s32 func_808F5994(EnIn* this, GlobalContext* globalCtx, Vec3f* arg2, s16 arg3); +void func_808F5A94(EnIn* this, PlayState* play); +void func_808F3690(EnIn* this, PlayState* play); +void func_808F5A34(EnIn* this, PlayState* play); +s32 func_808F5994(EnIn* this, PlayState* play, Vec3f* arg2, s16 arg3); const ActorInit En_In_InitVars = { ACTOR_EN_IN, @@ -77,7 +77,7 @@ static ColliderJntSphInit sJntSphInit = { OC2_TYPE_2, COLSHAPE_JNTSPH, }, - 1, + ARRAY_COUNT(sJntSphElementsInit), sJntSphElementsInit, }; @@ -118,7 +118,7 @@ static DamageTable sDamageTable = { /* Powder Keg */ DMG_ENTRY(0, 0x0), }; -static AnimationInfoS sAnimations[] = { +static AnimationInfoS sAnimationInfo[] = { { &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 }, @@ -139,37 +139,40 @@ static AnimationInfoS sAnimations[] = { { &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) { +s32 EnIn_ChangeAnim(SkelAnime* skelAnime, s16 animIndex) { s16 frameCount; s32 ret = false; if (animIndex >= 0 && animIndex < 18) { ret = true; - frameCount = sAnimations[animIndex].frameCount; + frameCount = sAnimationInfo[animIndex].frameCount; if (frameCount < 0) { - frameCount = Animation_GetLastFrame(sAnimations[animIndex].animation); + frameCount = Animation_GetLastFrame(sAnimationInfo[animIndex].animation); } - Animation_Change(skelAnime, sAnimations[animIndex].animation, sAnimations[animIndex].playSpeed, - sAnimations[animIndex].startFrame, frameCount, sAnimations[animIndex].mode, - sAnimations[animIndex].morphFrames); + Animation_Change(skelAnime, sAnimationInfo[animIndex].animation, sAnimationInfo[animIndex].playSpeed, + sAnimationInfo[animIndex].startFrame, frameCount, sAnimationInfo[animIndex].mode, + sAnimationInfo[animIndex].morphFrames); } return ret; } -s32 func_808F3178(EnIn* this, GlobalContext* globalCtx) { +s32 func_808F3178(EnIn* this, PlayState* play) { u8 prevUnk260 = this->unk260; u8 prevUnk261 = this->unk261; u8 tmp; - this->unk260 = tmp = SubS_IsFloorAbove(globalCtx, &this->unk248, -6.0f); + this->unk260 = tmp = SubS_IsFloorAbove(play, &this->unk248, -6.0f); if (this->unk260 != 0 && prevUnk260 == 0 && tmp) { Actor_PlaySfxAtPos(&this->actor, NA_SE_PL_WALK_CONCRETE); } - this->unk261 = tmp = SubS_IsFloorAbove(globalCtx, &this->unk254, -6.0f); + this->unk261 = tmp = SubS_IsFloorAbove(play, &this->unk254, -6.0f); if (this->unk261 != 0 && prevUnk261 == 0 && tmp) { Actor_PlaySfxAtPos(&this->actor, NA_SE_PL_WALK_CONCRETE); } @@ -187,24 +190,24 @@ void func_808F322C(EnIn* this, s32 arg1) { } } -void func_808F32A0(EnIn* this, GlobalContext* globalCtx) { +void func_808F32A0(EnIn* this, PlayState* play) { this->colliderCylinder.dim.pos.x = this->actor.world.pos.x; this->colliderCylinder.dim.pos.y = this->actor.world.pos.y; this->colliderCylinder.dim.pos.z = this->actor.world.pos.z; if (this->unk23D == 0) { - CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->colliderCylinder.base); + CollisionCheck_SetOC(play, &play->colChkCtx, &this->colliderCylinder.base); } } -s32 func_808F3310(EnIn* this, GlobalContext* globalCtx) { +s32 func_808F3310(EnIn* this, PlayState* play) { if (this->colliderCylinder.base.acFlags & AC_HIT) { this->colliderCylinder.base.acFlags &= ~AC_HIT; } return 0; } -s32 func_808F3334(EnIn* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); +s32 func_808F3334(EnIn* this, PlayState* play) { + Player* player = GET_PLAYER(play); if (this->colliderJntSph.base.atFlags & AT_HIT) { this->colliderJntSph.base.atFlags &= ~AT_HIT; @@ -212,7 +215,7 @@ s32 func_808F3334(EnIn* this, GlobalContext* globalCtx) { return 0; } Actor_PlaySfxAtPos(&player->actor, NA_SE_PL_BODY_HIT); - func_800B8D98(globalCtx, &this->actor, 3.0f, this->actor.yawTowardsPlayer, 6.0f); + func_800B8D98(play, &this->actor, 3.0f, this->actor.yawTowardsPlayer, 6.0f); } return 1; } @@ -226,52 +229,52 @@ s32 func_808F33B8(void) { return ret; } -void func_808F3414(EnIn* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); - Vec3f sp30; +void func_808F3414(EnIn* this, PlayState* play) { + Player* player = GET_PLAYER(play); + Vec3f point; if (this->unk23D == 0) { this->unk494 = SkelAnime_Update(&this->skelAnime); } if (SubS_AngleDiffLessEqual(this->actor.shape.rot.y, 0x2710, this->actor.yawTowardsPlayer)) { - sp30.x = player->actor.world.pos.x; - sp30.y = player->bodyPartsPos[7].y + 3.0f; - sp30.z = player->actor.world.pos.z; - func_8013D2E0(&sp30, &this->actor.focus.pos, &this->actor.shape.rot, &this->unk352, &this->unk358, - &this->unk35E, D_808F6C0C); + 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); - SubS_FillLimbRotTables(globalCtx, this->unk376, this->unk39E, ARRAY_COUNT(this->unk376)); + func_808F3178(this, play); + SubS_FillLimbRotTables(play, this->unk376, this->unk39E, ARRAY_COUNT(this->unk376)); } -void func_808F35AC(EnIn* this, GlobalContext* globalCtx) { +void func_808F35AC(EnIn* this, PlayState* play) { this->unk4AC |= 0x10; if (this->unk4A4 != NULL) { this->unk4A4->unk4AC |= 0x10; } } -void func_808F35D8(EnIn* this, GlobalContext* globalCtx) { +void func_808F35D8(EnIn* this, PlayState* play) { this->unk4AC &= ~0x10; if (this->unk4A4 != NULL) { this->unk4A4->unk4AC &= ~0x10; } } -void EnIn_DoNothing(EnIn* this, GlobalContext* globalCtx) { +void EnIn_DoNothing(EnIn* this, PlayState* play) { } -void func_808F3618(EnIn* this, GlobalContext* globalCtx) { +void func_808F3618(EnIn* this, PlayState* play) { if (ENIN_GET_PATH(&this->actor) != 0x3F) { - func_808F30B0(&this->skelAnime, 9); + EnIn_ChangeAnim(&this->skelAnime, ENIN_ANIM_9); } if (ENIN_GET_PATH(&this->actor) != 0x3F) { this->actionFunc = func_808F3690; @@ -280,7 +283,7 @@ void func_808F3618(EnIn* this, GlobalContext* globalCtx) { } } -void func_808F3690(EnIn* this, GlobalContext* globalCtx) { +void func_808F3690(EnIn* this, PlayState* play) { s16 sp36; Vec3f sp28; @@ -294,7 +297,7 @@ void func_808F3690(EnIn* this, GlobalContext* globalCtx) { } } -void func_808F374C(EnIn* this, GlobalContext* globalCtx) { +void func_808F374C(EnIn* this, PlayState* play) { 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, @@ -316,15 +319,15 @@ void func_808F374C(EnIn* this, GlobalContext* globalCtx) { this->unk488 %= ARRAY_COUNT(sAnimations); this->unk486 = this->unk488; Animation_Change(&this->skelAnime, sAnimations[this->unk488], 1.0f, 0.0f, - Animation_GetLastFrame(sAnimations[this->unk488]), 2, -10.0f); + Animation_GetLastFrame(sAnimations[this->unk488]), ANIMMODE_ONCE, -10.0f); } } -void func_808F38F8(EnIn* this, GlobalContext* globalCtx) { +void func_808F38F8(EnIn* this, PlayState* play) { this->unk4A4 = NULL; while (true) { //! @bug: Infinite loop if there is only one ACTOR_EN_IN - this->unk4A4 = (EnIn*)SubS_FindActor(globalCtx, &this->unk4A4->actor, ACTORCAT_NPC, ACTOR_EN_IN); + this->unk4A4 = (EnIn*)SubS_FindActor(play, &this->unk4A4->actor, ACTORCAT_NPC, ACTOR_EN_IN); if (this->unk4A4 != NULL && this->unk4A4 != this) { break; } @@ -332,20 +335,20 @@ void func_808F38F8(EnIn* this, GlobalContext* globalCtx) { } } -void func_808F395C(EnIn* this, GlobalContext* globalCtx) { +void func_808F395C(EnIn* this, PlayState* play) { if (this->unk4B0 == RACE_FLAG_END) { this->actionFunc = func_808F5A94; } - if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { + if (Actor_ProcessTalkRequest(&this->actor, &play->state)) { this->actor.flags &= ~ACTOR_FLAG_10000; this->actionFunc = func_808F5A34; this->unk48C = 1; } else { - func_800B8614(&this->actor, globalCtx, 200.0f); + func_800B8614(&this->actor, play, 200.0f); } } -void func_808F39DC(EnIn* this, GlobalContext* globalCtx) { +void func_808F39DC(EnIn* this, PlayState* play) { u16 textId = 0; if (gSaveContext.save.day != 3) { @@ -379,182 +382,180 @@ void func_808F39DC(EnIn* this, GlobalContext* globalCtx) { } } -void func_808F3AD4(EnIn* this, GlobalContext* globalCtx) { - if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { +void func_808F3AD4(EnIn* this, PlayState* play) { + if (Actor_ProcessTalkRequest(&this->actor, &play->state)) { this->actor.flags &= ~ACTOR_FLAG_10000; this->unk48C = 1; this->actionFunc = func_808F5A94; } else { - func_800B85E0(&this->actor, globalCtx, 200.0f, EXCH_ITEM_MINUS1); + func_800B85E0(&this->actor, play, 200.0f, PLAYER_AP_MINUS1); } } -void func_808F3B40(EnIn* this, GlobalContext* globalCtx) { +void func_808F3B40(EnIn* this, PlayState* play) { u16 textId; - if (Actor_HasParent(&this->actor, globalCtx)) { + if (Actor_HasParent(&this->actor, play)) { this->actor.parent = NULL; this->actor.flags |= ACTOR_FLAG_10000; this->actionFunc = func_808F3AD4; textId = gSaveContext.save.day != 3 ? 0x3481 : 0x34A4; this->actor.textId = textId; } else { - Actor_PickUp(&this->actor, globalCtx, GI_MILK, 500.0f, 100.0f); + Actor_PickUp(&this->actor, play, GI_MILK, 500.0f, 100.0f); } } -void func_808F3BD4(EnIn* this, GlobalContext* globalCtx) { - if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { +void func_808F3BD4(EnIn* this, PlayState* play) { + if (Actor_ProcessTalkRequest(&this->actor, &play->state)) { this->actor.flags &= ~ACTOR_FLAG_10000; this->unk48C = 1; this->actionFunc = func_808F5A94; } else { - func_800B85E0(&this->actor, globalCtx, 200.0f, EXCH_ITEM_MINUS1); + func_800B85E0(&this->actor, play, 200.0f, PLAYER_AP_MINUS1); } } -void func_808F3C40(EnIn* this, GlobalContext* globalCtx) { +void func_808F3C40(EnIn* this, PlayState* play) { u16 textId; - if (Actor_HasParent(&this->actor, globalCtx)) { + if (Actor_HasParent(&this->actor, play)) { this->actor.parent = NULL; this->actor.flags |= ACTOR_FLAG_10000; this->actionFunc = func_808F3BD4; textId = gSaveContext.save.day != 3 ? 0x346A : 0x3492; this->actor.textId = textId; } else { - Actor_PickUp(&this->actor, globalCtx, GI_MILK, 500.0f, 100.0f); + Actor_PickUp(&this->actor, play, GI_MILK, 500.0f, 100.0f); } } -void func_808F3CD4(EnIn* this, GlobalContext* globalCtx) { - if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { +void func_808F3CD4(EnIn* this, PlayState* play) { + if (Actor_ProcessTalkRequest(&this->actor, &play->state)) { this->actor.flags &= ~ACTOR_FLAG_10000; this->unk48C = 1; this->actionFunc = func_808F5A94; } else { - func_800B85E0(&this->actor, globalCtx, 200.0f, EXCH_ITEM_MINUS1); + func_800B85E0(&this->actor, play, 200.0f, PLAYER_AP_MINUS1); } } -void func_808F3D40(EnIn* this, GlobalContext* globalCtx) { +void func_808F3D40(EnIn* this, PlayState* play) { u16 textId; - if (Actor_HasParent(&this->actor, globalCtx)) { + if (Actor_HasParent(&this->actor, play)) { this->actor.parent = NULL; this->actionFunc = func_808F3CD4; textId = gSaveContext.save.day != 3 ? 0x347D : 0x34A0; this->actor.textId = textId; this->actor.flags |= ACTOR_FLAG_10000; } else { - Actor_PickUp(&this->actor, globalCtx, GI_MASK_GARO, 500.0f, 100.0f); + Actor_PickUp(&this->actor, play, GI_MASK_GARO, 500.0f, 100.0f); } } -u16 func_808F3DD4(GlobalContext* globalCtx, EnIn* this, u32 arg2) { +u16 func_808F3DD4(PlayState* play, EnIn* this, u32 arg2) { u16 textId = 0; - if (Player_GetMask(globalCtx) == PLAYER_MASK_CIRCUS_LEADER) { - s32 requiredScopeTemp; - + if (Player_GetMask(play) == PLAYER_MASK_CIRCUS_LEADER) { if (!(gSaveContext.save.weekEventReg[63] & 0x40)) { - return 0x34A9; + textId = 0x34A9; } else if (this->unk4AC & 8) { - return 0x34B1; + textId = 0x34B1; } else { textId = 0x34AF; } - } else { - switch (arg2) { - case 0: - if ((gSaveContext.save.playerForm == PLAYER_FORM_ZORA) || - (gSaveContext.save.playerForm == PLAYER_FORM_GORON)) { - textId = 0x345C; - } else if (gSaveContext.save.playerForm == PLAYER_FORM_DEKU) { - textId = 0x3460; - } else if (!(gSaveContext.save.weekEventReg[15] & 8)) { - textId = 0x3458; - } else { - textId = 0x345B; - } - break; - case 1: - if (!(gSaveContext.save.weekEventReg[15] & 0x10)) { - textId = 0x3463; - } else { - textId = 0x346B; - } - break; - case 3: - if (gSaveContext.save.playerForm == PLAYER_FORM_DEKU) { - textId = 0x3485; - } else if (gSaveContext.save.playerForm == PLAYER_FORM_ZORA || - gSaveContext.save.playerForm == PLAYER_FORM_GORON) { - textId = 0x3484; - } else if (!(gSaveContext.save.weekEventReg[56] & 4)) { - textId = 0x346D; - } else { - textId = 0x3482; - } - break; - case 4: - if (gSaveContext.save.playerForm == PLAYER_FORM_ZORA || - gSaveContext.save.playerForm == PLAYER_FORM_GORON) { - textId = 0x348A; - } else if (gSaveContext.save.playerForm == PLAYER_FORM_DEKU) { - textId = 0x348B; - } else if (!(gSaveContext.save.weekEventReg[16] & 1)) { - textId = 0x3486; - } else { - textId = 0x3489; - } - break; - case 5: - if (func_808F33B8()) { - textId = 0x34B3; - } else if (!(gSaveContext.save.weekEventReg[16] & 2)) { - textId = 0x348E; - } else { - textId = 0x3493; - } - break; - case 7: - if (gSaveContext.save.playerForm == PLAYER_FORM_DEKU) { - textId = 0x34A8; - } else if (gSaveContext.save.playerForm == PLAYER_FORM_ZORA || - gSaveContext.save.playerForm == PLAYER_FORM_GORON) { - textId = 0x34A7; - } else if (!(gSaveContext.save.weekEventReg[16] & 4)) { - textId = 0x3495; - } else { - textId = 0x34A5; - } - } - if (textId == 0) { - textId = 1; - } + return textId; + } + + switch (arg2) { + case 0: + if ((gSaveContext.save.playerForm == PLAYER_FORM_ZORA) || + (gSaveContext.save.playerForm == PLAYER_FORM_GORON)) { + textId = 0x345C; + } else if (gSaveContext.save.playerForm == PLAYER_FORM_DEKU) { + textId = 0x3460; + } else if (!(gSaveContext.save.weekEventReg[15] & 8)) { + textId = 0x3458; + } else { + textId = 0x345B; + } + break; + case 1: + if (!(gSaveContext.save.weekEventReg[15] & 0x10)) { + textId = 0x3463; + } else { + textId = 0x346B; + } + break; + case 3: + if (gSaveContext.save.playerForm == PLAYER_FORM_DEKU) { + textId = 0x3485; + } else if (gSaveContext.save.playerForm == PLAYER_FORM_ZORA || + gSaveContext.save.playerForm == PLAYER_FORM_GORON) { + textId = 0x3484; + } else if (!(gSaveContext.save.weekEventReg[56] & 4)) { + textId = 0x346D; + } else { + textId = 0x3482; + } + break; + case 4: + if (gSaveContext.save.playerForm == PLAYER_FORM_ZORA || gSaveContext.save.playerForm == PLAYER_FORM_GORON) { + textId = 0x348A; + } else if (gSaveContext.save.playerForm == PLAYER_FORM_DEKU) { + textId = 0x348B; + } else if (!(gSaveContext.save.weekEventReg[16] & 1)) { + textId = 0x3486; + } else { + textId = 0x3489; + } + break; + case 5: + if (func_808F33B8()) { + textId = 0x34B3; + } else if (!(gSaveContext.save.weekEventReg[16] & 2)) { + textId = 0x348E; + } else { + textId = 0x3493; + } + break; + case 7: + if (gSaveContext.save.playerForm == PLAYER_FORM_DEKU) { + textId = 0x34A8; + } else if (gSaveContext.save.playerForm == PLAYER_FORM_ZORA || + gSaveContext.save.playerForm == PLAYER_FORM_GORON) { + textId = 0x34A7; + } else if (!(gSaveContext.save.weekEventReg[16] & 4)) { + textId = 0x3495; + } else { + textId = 0x34A5; + } + } + if (textId == 0) { + textId = 1; } return textId; } -void func_808F4054(GlobalContext* globalCtx, EnIn* this, s32 arg2, u16 textId) { +void func_808F4054(PlayState* play, EnIn* this, s32 arg2, u16 textId) { s32 unused; if (textId == 0x34AE || textId == 0x34B0 || textId == 0x34B2) { unused = textId; - func_80151BB4(globalCtx, 0x11); + func_80151BB4(play, 0x11); } switch (arg2) { case 1: case 5: case 7: if (textId == 0x3473) { - func_808F35D8(this, globalCtx); + func_808F35D8(this, play); } break; case 2: if (textId == 0x3473) { - func_808F35D8(this, globalCtx); + func_808F35D8(this, play); } break; case 0: @@ -562,71 +563,71 @@ void func_808F4054(GlobalContext* globalCtx, EnIn* this, s32 arg2, u16 textId) { } } -void func_808F4108(EnIn* this, GlobalContext* globalCtx, u16 textId) { - Actor_ChangeFocus(&this->actor, globalCtx, &this->unk4A4->actor); +void func_808F4108(EnIn* this, PlayState* play, u16 textId) { + Actor_ChangeFocus(&this->actor, play, &this->unk4A4->actor); this->actor.textId = 0; this->unk4A4->actor.textId = textId; this->unk4A4->unk48C = 2; this->unk48C = 0; } -s32 func_808F4150(GlobalContext* globalCtx, EnIn* this, s32 arg2, MessageContext* msgCtx) { +s32 func_808F4150(PlayState* play, EnIn* this, s32 arg2, MessageContext* msgCtx) { EnIn* this2 = this; if (msgCtx->choiceIndex == 0) { func_8019F208(); - if (gSaveContext.save.playerData.rupees >= globalCtx->msgCtx.unk1206C) { - func_801159EC(-globalCtx->msgCtx.unk1206C); + if (gSaveContext.save.playerData.rupees >= play->msgCtx.unk1206C) { + Rupees_ChangeBy(-play->msgCtx.unk1206C); if (!(gSaveContext.save.weekEventReg[57] & 1)) { - func_808F4108(this, globalCtx, 0x3474); + func_808F4108(this, play, 0x3474); } else if (this->unk4AC & 8) { - func_808F4108(this, globalCtx, 0x3475); + func_808F4108(this, play, 0x3475); } else { - func_800E8EA0(globalCtx, &this->actor, 0x3475); + Actor_ContinueText(play, &this->actor, 0x3475); } } else { play_sound(NA_SE_SY_ERROR); - func_800E8EA0(globalCtx, &this->actor, 0x3473); + Actor_ContinueText(play, &this->actor, 0x3473); } } else { func_8019F230(); - func_800E8EA0(globalCtx, &this->actor, 0x3472); + Actor_ContinueText(play, &this->actor, 0x3472); } return 0; } -s32 func_808F4270(GlobalContext* globalCtx, EnIn* this, s32 arg2, MessageContext* msgCtx, s32 arg4) { +s32 func_808F4270(PlayState* play, EnIn* this, s32 arg2, MessageContext* msgCtx, s32 arg4) { s32 pad; - s32 fee = globalCtx->msgCtx.unk1206C != 0xFFFF ? globalCtx->msgCtx.unk1206C : 10; + s32 fee = play->msgCtx.unk1206C != 0xFFFF ? play->msgCtx.unk1206C : 10; if (msgCtx->choiceIndex == 0) { func_8019F208(); if (gSaveContext.save.playerData.rupees >= fee) { - func_801159EC(-fee); + Rupees_ChangeBy(-fee); if (!(gSaveContext.save.weekEventReg[57] & 1)) { if (arg4 != 0) { - func_800E8EA0(globalCtx, &this->actor, 0x3474); + Actor_ContinueText(play, &this->actor, 0x3474); } else { - func_808F4108(this, globalCtx, 0x3474); + func_808F4108(this, play, 0x3474); } } else { if (arg4 != 0) { - func_800E8EA0(globalCtx, &this->actor, 0x3475); + Actor_ContinueText(play, &this->actor, 0x3475); } else { - func_808F4108(this, globalCtx, 0x3475); + func_808F4108(this, play, 0x3475); } } } else { play_sound(NA_SE_SY_ERROR); if (arg4 != 0) { - func_800E8EA0(globalCtx, &this->actor, 0x3473); + Actor_ContinueText(play, &this->actor, 0x3473); } else { - func_808F4108(this, globalCtx, 0x3473); + func_808F4108(this, play, 0x3473); } } } else { func_8019F230(); - func_800E8EA0(globalCtx, &this->actor, 0x3472); + Actor_ContinueText(play, &this->actor, 0x3472); } return 0; } @@ -638,40 +639,40 @@ s32 func_808F43E0(EnIn* this) { return 0; } -s32 func_808F4414(GlobalContext* globalCtx, EnIn* this, s32 arg2) { +s32 func_808F4414(PlayState* play, EnIn* this, s32 arg2) { u16 textId = this->actor.textId; s32 ret = true; - MessageContext* msgCtx = &globalCtx->msgCtx; + MessageContext* msgCtx = &play->msgCtx; s32 pad[2]; switch (textId) { case 0x34AF: - func_800E8EA0(globalCtx, &this->actor, 0x34B0); + Actor_ContinueText(play, &this->actor, 0x34B0); ret = false; break; case 0x34A9: - func_808F4108(this, globalCtx, 0x34AA); + func_808F4108(this, play, 0x34AA); gSaveContext.save.weekEventReg[63] |= 0x40; ret = false; break; case 0x34AA: - func_808F4108(this, globalCtx, 0x34AB); + func_808F4108(this, play, 0x34AB); ret = false; break; case 0x34AB: - func_808F4108(this, globalCtx, 0x34AC); + func_808F4108(this, play, 0x34AC); ret = false; break; case 0x34AC: - func_808F4108(this, globalCtx, 0x34AD); + func_808F4108(this, play, 0x34AD); ret = false; break; case 0x34AD: - func_800E8EA0(globalCtx, &this->actor, 0x34AE); + Actor_ContinueText(play, &this->actor, 0x34AE); ret = false; break; case 0x34B1: - func_800E8EA0(globalCtx, &this->actor, 0x34B2); + Actor_ContinueText(play, &this->actor, 0x34B2); ret = false; break; default: @@ -683,47 +684,47 @@ s32 func_808F4414(GlobalContext* globalCtx, EnIn* this, s32 arg2) { switch (textId) { case 0x3458: gSaveContext.save.weekEventReg[15] |= 8; - func_800E8EA0(globalCtx, &this->actor, 0x3459); + Actor_ContinueText(play, &this->actor, 0x3459); ret = false; break; case 0x3459: - func_800E8EA0(globalCtx, &this->actor, 0x345A); + Actor_ContinueText(play, &this->actor, 0x345A); ret = false; break; case 0x345A: - func_80151BB4(globalCtx, 0x11); + func_80151BB4(play, 0x11); ret = true; break; case 0x345B: - func_80151BB4(globalCtx, 0x11); + func_80151BB4(play, 0x11); ret = true; break; case 0x345C: - func_800E8EA0(globalCtx, &this->actor, 0x345D); + Actor_ContinueText(play, &this->actor, 0x345D); ret = false; break; case 0x345D: - func_800E8EA0(globalCtx, &this->actor, 0x345E); + Actor_ContinueText(play, &this->actor, 0x345E); ret = false; break; case 0x345E: - func_800E8EA0(globalCtx, &this->actor, 0x345F); + Actor_ContinueText(play, &this->actor, 0x345F); ret = false; break; case 0x345F: - func_80151BB4(globalCtx, 0x11); + func_80151BB4(play, 0x11); ret = true; break; case 0x3460: - func_800E8EA0(globalCtx, &this->actor, 0x3461); + Actor_ContinueText(play, &this->actor, 0x3461); ret = false; break; case 0x3461: - func_800E8EA0(globalCtx, &this->actor, 0x3462); + Actor_ContinueText(play, &this->actor, 0x3462); ret = false; break; case 0x3462: - func_80151BB4(globalCtx, 0x11); + func_80151BB4(play, 0x11); ret = true; break; } @@ -732,110 +733,110 @@ s32 func_808F4414(GlobalContext* globalCtx, EnIn* this, s32 arg2) { switch (textId) { case 0x3463: gSaveContext.save.weekEventReg[15] |= 0x10; - func_800E8EA0(globalCtx, &this->actor, 0x3464); + Actor_ContinueText(play, &this->actor, 0x3464); ret = false; break; case 0x3464: - func_800E8EA0(globalCtx, &this->actor, 0x3465); + Actor_ContinueText(play, &this->actor, 0x3465); ret = false; break; case 0x3465: - func_800E8EA0(globalCtx, &this->actor, 0x3466); + Actor_ContinueText(play, &this->actor, 0x3466); ret = false; break; case 0x3466: if (msgCtx->choiceIndex == 0) { func_8019F208(); - if (gSaveContext.save.playerData.rupees >= globalCtx->msgCtx.unk1206C) { - if (Interface_HasEmptyBottle()) { + if (gSaveContext.save.playerData.rupees >= play->msgCtx.unk1206C) { + if (Inventory_HasEmptyBottle()) { this->actionFunc = func_808F3C40; - Actor_PickUp(&this->actor, globalCtx, GI_MILK, 500.0f, 100.0f); - func_801159EC(-globalCtx->msgCtx.unk1206C); + Actor_PickUp(&this->actor, play, GI_MILK, 500.0f, 100.0f); + Rupees_ChangeBy(-play->msgCtx.unk1206C); ret = true; } else { - func_800E8EA0(globalCtx, &this->actor, 0x3469); + Actor_ContinueText(play, &this->actor, 0x3469); ret = false; } } else { play_sound(NA_SE_SY_ERROR); - func_800E8EA0(globalCtx, &this->actor, 0x3468); + Actor_ContinueText(play, &this->actor, 0x3468); ret = false; } } else { func_8019F230(); - func_800E8EA0(globalCtx, &this->actor, 0x3467); + Actor_ContinueText(play, &this->actor, 0x3467); ret = false; } break; case 0x3467: case 0x3468: case 0x3469: - func_80151BB4(globalCtx, 0x11); + func_80151BB4(play, 0x11); ret = true; break; case 0x346B: - func_800E8EA0(globalCtx, &this->actor, 0x346C); + Actor_ContinueText(play, &this->actor, 0x346C); ret = false; break; case 0x346C: - func_800E8EA0(globalCtx, &this->actor, 0x3466); + Actor_ContinueText(play, &this->actor, 0x3466); ret = false; break; case 0x346A: this->actionFunc = func_808F5A94; - func_80151BB4(globalCtx, 0x11); + func_80151BB4(play, 0x11); break; } break; case 2: switch (textId) { case 0x346E: - func_808F4108(this, globalCtx, 0x346F); + func_808F4108(this, play, 0x346F); ret = false; break; case 0x3470: - func_800E8EA0(globalCtx, &this->actor, 0x3471); + Actor_ContinueText(play, &this->actor, 0x3471); ret = false; break; case 0x3483: - func_800E8EA0(globalCtx, &this->actor, 0x3471); + Actor_ContinueText(play, &this->actor, 0x3471); ret = false; break; case 0x3471: - func_808F4150(globalCtx, this, arg2, msgCtx); + func_808F4150(play, this, arg2, msgCtx); ret = false; break; case 0x3472: func_808F43E0(this); gSaveContext.save.weekEventReg[56] &= (u8)~8; - func_80151BB4(globalCtx, 0x11); + func_80151BB4(play, 0x11); ret = true; break; case 0x3473: gSaveContext.save.weekEventReg[56] &= (u8)~8; - func_80151BB4(globalCtx, 0x11); + func_80151BB4(play, 0x11); break; case 0x3475: SET_RACE_FLAGS(RACE_FLAG_START); func_800FD750(NA_BGM_HORSE); - globalCtx->nextEntranceIndex = 0xCE50; - globalCtx->unk_1887F = 5; - globalCtx->sceneLoadFlag = 0x14; + play->nextEntrance = ENTRANCE(GORMAN_TRACK, 5); + play->transitionType = TRANS_TYPE_05; + play->transitionTrigger = TRANS_TRIGGER_START; gSaveContext.save.weekEventReg[57] |= 1; break; case 0x3478: if (msgCtx->choiceIndex == 0) { - func_808F4150(globalCtx, this, arg2, msgCtx); + func_808F4150(play, this, arg2, msgCtx); ret = false; } else { func_8019F230(); gSaveContext.save.weekEventReg[56] &= (u8)~8; - func_808F4108(this, globalCtx, 0x3479); + func_808F4108(this, play, 0x3479); ret = false; } break; case 0x347B: - func_808F4108(this, globalCtx, 0x347C); + func_808F4108(this, play, 0x347C); gSaveContext.save.weekEventReg[56] &= (u8)~8; ret = false; break; @@ -844,96 +845,96 @@ s32 func_808F4414(GlobalContext* globalCtx, EnIn* this, s32 arg2) { case 3: switch (textId) { case 0x346D: - func_808F4108(this, globalCtx, 0x346E); + func_808F4108(this, play, 0x346E); gSaveContext.save.weekEventReg[56] |= 4; gSaveContext.save.weekEventReg[56] |= 8; ret = false; break; case 0x346F: - func_808F4108(this, globalCtx, 0x3470); + func_808F4108(this, play, 0x3470); ret = false; break; case 0x3482: - func_808F4108(this, globalCtx, 0x3483); + func_808F4108(this, play, 0x3483); gSaveContext.save.weekEventReg[56] |= 8; ret = false; break; case 0x3484: - func_80151BB4(globalCtx, 0x11); + func_80151BB4(play, 0x11); break; case 0x3485: - func_80151BB4(globalCtx, 0x11); + func_80151BB4(play, 0x11); break; case 0x3474: - func_808F4108(this, globalCtx, 0x3475); + func_808F4108(this, play, 0x3475); ret = false; break; case 0x3476: - func_800E8EA0(globalCtx, &this->actor, 0x3477); - func_808F30B0(&this->skelAnime, 1); - func_808F30B0(&this->unk4A4->skelAnime, 7); + Actor_ContinueText(play, &this->actor, 0x3477); + EnIn_ChangeAnim(&this->skelAnime, ENIN_ANIM_1); + EnIn_ChangeAnim(&this->unk4A4->skelAnime, ENIN_ANIM_7); ret = false; break; case 0x3477: gSaveContext.save.weekEventReg[56] |= 8; - func_808F4108(this, globalCtx, 0x3478); + func_808F4108(this, play, 0x3478); ret = false; break; case 0x347A: - func_808F30B0(&this->skelAnime, 1); - func_808F30B0(&this->unk4A4->skelAnime, 7); + EnIn_ChangeAnim(&this->skelAnime, ENIN_ANIM_1); + EnIn_ChangeAnim(&this->unk4A4->skelAnime, ENIN_ANIM_7); if (INV_CONTENT(ITEM_MASK_GARO) == ITEM_MASK_GARO) { - func_800E8EA0(globalCtx, &this->actor, 0x347E); + Actor_ContinueText(play, &this->actor, 0x347E); ret = false; } else { gSaveContext.save.weekEventReg[56] |= 8; - func_808F4108(this, globalCtx, 0x347B); + func_808F4108(this, play, 0x347B); ret = false; } break; case 0x347E: - func_808F35D8(this, globalCtx); - if (Interface_HasEmptyBottle()) { + func_808F35D8(this, play); + if (Inventory_HasEmptyBottle()) { this->actionFunc = func_808F3B40; - Actor_PickUp(&this->actor, globalCtx, GI_MILK, 500.0f, 100.0f); + Actor_PickUp(&this->actor, play, GI_MILK, 500.0f, 100.0f); ret = true; } else { - func_800E8EA0(globalCtx, &this->actor, 0x347F); + Actor_ContinueText(play, &this->actor, 0x347F); ret = false; } break; case 0x347F: - func_800E8EA0(globalCtx, &this->actor, 0x3480); + Actor_ContinueText(play, &this->actor, 0x3480); ret = false; break; case 0x3480: func_808F43E0(this); - func_80151BB4(globalCtx, 0x11); + func_80151BB4(play, 0x11); ret = true; break; case 0x3479: func_808F43E0(this); - func_808F35D8(this, globalCtx); - func_80151BB4(globalCtx, 0x11); + func_808F35D8(this, play); + func_80151BB4(play, 0x11); ret = true; break; case 0x347C: this->actionFunc = func_808F3D40; - Actor_PickUp(&this->actor, globalCtx, GI_MASK_GARO, 500.0f, 100.0f); - func_808F35D8(this, globalCtx); + Actor_PickUp(&this->actor, play, GI_MASK_GARO, 500.0f, 100.0f); + func_808F35D8(this, play); ret = true; break; case 0x3481: this->actionFunc = func_808F5A34; func_808F43E0(this); - func_80151BB4(globalCtx, 0x11); + func_80151BB4(play, 0x11); ret = true; break; case 0x347D: this->actionFunc = func_808F5A34; func_808F43E0(this); - func_80151BB4(globalCtx, 0x11); - func_80151BB4(globalCtx, 0x2F); + func_80151BB4(play, 0x11); + func_80151BB4(play, 0x2F); ret = true; break; } @@ -941,34 +942,34 @@ s32 func_808F4414(GlobalContext* globalCtx, EnIn* this, s32 arg2) { case 4: switch (textId) { case 0x3486: - func_800E8EA0(globalCtx, &this->actor, 0x3487); + Actor_ContinueText(play, &this->actor, 0x3487); gSaveContext.save.weekEventReg[16] |= 1; ret = false; break; case 0x3487: - func_800E8EA0(globalCtx, &this->actor, 0x3488); + Actor_ContinueText(play, &this->actor, 0x3488); ret = false; break; case 0x3488: - func_80151BB4(globalCtx, 0x11); + func_80151BB4(play, 0x11); ret = true; break; case 0x3489: - func_80151BB4(globalCtx, 0x11); + func_80151BB4(play, 0x11); break; case 0x348A: - func_80151BB4(globalCtx, 0x11); + func_80151BB4(play, 0x11); break; case 0x348B: - func_800E8EA0(globalCtx, &this->actor, 0x348C); + Actor_ContinueText(play, &this->actor, 0x348C); ret = false; break; case 0x348C: - func_800E8EA0(globalCtx, &this->actor, 0x348D); + Actor_ContinueText(play, &this->actor, 0x348D); ret = false; break; case 0x348D: - func_80151BB4(globalCtx, 0x11); + func_80151BB4(play, 0x11); ret = true; break; } @@ -978,167 +979,167 @@ s32 func_808F4414(GlobalContext* globalCtx, EnIn* this, s32 arg2) { case 0x3468: case 0x3469: case 0x3491: - func_80151BB4(globalCtx, 0x11); + func_80151BB4(play, 0x11); break; case 0x348E: case 0x34B3: - func_800E8EA0(globalCtx, &this->actor, 0x348F); + Actor_ContinueText(play, &this->actor, 0x348F); gSaveContext.save.weekEventReg[16] |= 2; ret = false; break; case 0x3493: - func_800E8EA0(globalCtx, &this->actor, 0x3494); + Actor_ContinueText(play, &this->actor, 0x3494); ret = false; break; case 0x348F: case 0x3494: - func_800E8EA0(globalCtx, &this->actor, 0x3490); + Actor_ContinueText(play, &this->actor, 0x3490); ret = false; break; case 0x3490: if (msgCtx->choiceIndex == 0) { func_8019F208(); - if (gSaveContext.save.playerData.rupees >= globalCtx->msgCtx.unk1206C) { - if (Interface_HasEmptyBottle()) { + if (gSaveContext.save.playerData.rupees >= play->msgCtx.unk1206C) { + if (Inventory_HasEmptyBottle()) { this->actionFunc = func_808F3C40; - Actor_PickUp(&this->actor, globalCtx, GI_MILK, 500.0f, 100.0f); - func_801159EC(-globalCtx->msgCtx.unk1206C); + Actor_PickUp(&this->actor, play, GI_MILK, 500.0f, 100.0f); + Rupees_ChangeBy(-play->msgCtx.unk1206C); ret = true; } else { - func_800E8EA0(globalCtx, &this->actor, 0x3469); + Actor_ContinueText(play, &this->actor, 0x3469); ret = false; } } else { play_sound(NA_SE_SY_ERROR); - func_800E8EA0(globalCtx, &this->actor, 0x3468); + Actor_ContinueText(play, &this->actor, 0x3468); ret = false; } } else { func_8019F230(); - func_800E8EA0(globalCtx, &this->actor, 0x3491); + Actor_ContinueText(play, &this->actor, 0x3491); ret = false; } break; case 0x3492: this->actionFunc = func_808F5A94; - func_80151BB4(globalCtx, 0x11); + func_80151BB4(play, 0x11); break; } break; case 7: switch (textId) { case 0x34A8: - func_80151BB4(globalCtx, 0x11); + func_80151BB4(play, 0x11); break; case 0x34A7: - func_80151BB4(globalCtx, 0x11); + func_80151BB4(play, 0x11); break; case 0x3495: - func_808F4108(this, globalCtx, 0x3496); + func_808F4108(this, play, 0x3496); gSaveContext.save.weekEventReg[16] |= 4; gSaveContext.save.weekEventReg[56] |= 8; ret = false; break; case 0x3497: - func_808F4108(this, globalCtx, 0x3498); + func_808F4108(this, play, 0x3498); ret = false; break; case 0x34A4: this->actionFunc = func_808F5A34; func_808F43E0(this); - func_80151BB4(globalCtx, 0x11); + func_80151BB4(play, 0x11); ret = true; break; case 0x34A5: - func_808F4108(this, globalCtx, 0x34A6); + func_808F4108(this, play, 0x34A6); gSaveContext.save.weekEventReg[56] |= 8; ret = false; break; case 0x3473: gSaveContext.save.weekEventReg[56] &= (u8)~8; - func_80151BB4(globalCtx, 0x11); + func_80151BB4(play, 0x11); break; case 0x3474: - func_800E8EA0(globalCtx, &this->actor, 0x3475); + Actor_ContinueText(play, &this->actor, 0x3475); ret = false; break; case 0x3475: SET_RACE_FLAGS(RACE_FLAG_START); func_800FD750(NA_BGM_HORSE); - globalCtx->nextEntranceIndex = 0xCE50; - globalCtx->unk_1887F = 5; - globalCtx->sceneLoadFlag = 0x14; + play->nextEntrance = ENTRANCE(GORMAN_TRACK, 5); + play->transitionType = TRANS_TYPE_05; + play->transitionTrigger = TRANS_TRIGGER_START; gSaveContext.save.weekEventReg[57] |= 1; break; case 0x349D: - func_808F30B0(&this->skelAnime, 1); - func_808F30B0(&this->unk4A4->skelAnime, 7); + EnIn_ChangeAnim(&this->skelAnime, ENIN_ANIM_1); + EnIn_ChangeAnim(&this->unk4A4->skelAnime, ENIN_ANIM_7); if (INV_CONTENT(ITEM_MASK_GARO) == ITEM_MASK_GARO) { - func_800E8EA0(globalCtx, &this->actor, 0x34A1); + Actor_ContinueText(play, &this->actor, 0x34A1); ret = false; } else { gSaveContext.save.weekEventReg[56] |= 8; - func_808F4108(this, globalCtx, 0x349E); + func_808F4108(this, play, 0x349E); ret = false; } break; case 0x349F: this->actionFunc = func_808F3D40; - Actor_PickUp(&this->actor, globalCtx, GI_MASK_GARO, 500.0f, 100.0f); - func_808F35D8(this, globalCtx); + Actor_PickUp(&this->actor, play, GI_MASK_GARO, 500.0f, 100.0f); + func_808F35D8(this, play); ret = true; break; case 0x34A0: this->actionFunc = func_808F5A34; - func_80151BB4(globalCtx, 0x11); - func_80151BB4(globalCtx, 0x2F); + func_80151BB4(play, 0x11); + func_80151BB4(play, 0x2F); func_808F43E0(this); ret = true; break; case 0x34A1: - func_808F35D8(this, globalCtx); - if (Interface_HasEmptyBottle()) { + func_808F35D8(this, play); + if (Inventory_HasEmptyBottle()) { this->actionFunc = func_808F3B40; - Actor_PickUp(&this->actor, globalCtx, GI_MILK, 500.0f, 100.0f); + Actor_PickUp(&this->actor, play, GI_MILK, 500.0f, 100.0f); ret = true; } else { - func_800E8EA0(globalCtx, &this->actor, 0x34A2); + Actor_ContinueText(play, &this->actor, 0x34A2); ret = false; } break; case 0x34A2: - func_800E8EA0(globalCtx, &this->actor, 0x34A3); + Actor_ContinueText(play, &this->actor, 0x34A3); ret = false; break; case 0x34A3: func_808F43E0(this); - func_80151BB4(globalCtx, 0x11); + func_80151BB4(play, 0x11); ret = true; break; case 0x3499: - func_800E8EA0(globalCtx, &this->actor, 0x349A); - func_808F30B0(&this->skelAnime, 1); - func_808F30B0(&this->unk4A4->skelAnime, 7); + Actor_ContinueText(play, &this->actor, 0x349A); + EnIn_ChangeAnim(&this->skelAnime, ENIN_ANIM_1); + EnIn_ChangeAnim(&this->unk4A4->skelAnime, ENIN_ANIM_7); ret = false; break; case 0x349A: - func_800E8EA0(globalCtx, &this->actor, 0x349B); + Actor_ContinueText(play, &this->actor, 0x349B); ret = false; break; case 0x349B: if (msgCtx->choiceIndex == 0) { - func_808F4270(globalCtx, this, arg2, msgCtx, 1); + func_808F4270(play, this, arg2, msgCtx, 1); ret = false; } else { func_8019F230(); - func_800E8EA0(globalCtx, &this->actor, 0x349C); + Actor_ContinueText(play, &this->actor, 0x349C); ret = false; } break; case 0x349C: func_808F43E0(this); - func_808F35D8(this, globalCtx); - func_80151BB4(globalCtx, 0x11); + func_808F35D8(this, play); + func_80151BB4(play, 0x11); ret = true; break; } @@ -1146,26 +1147,26 @@ s32 func_808F4414(GlobalContext* globalCtx, EnIn* this, s32 arg2) { case 6: switch (textId) { case 0x3496: - func_808F4108(this, globalCtx, 0x3497); + func_808F4108(this, play, 0x3497); ret = false; break; case 0x3498: case 0x34A6: - func_800E8EA0(globalCtx, &this->actor, 0x3471); + Actor_ContinueText(play, &this->actor, 0x3471); ret = false; break; case 0x3471: - func_808F4270(globalCtx, this, arg2, msgCtx, 0); + func_808F4270(play, this, arg2, msgCtx, 0); ret = false; break; case 0x3472: func_808F43E0(this); gSaveContext.save.weekEventReg[56] &= (u8)~8; - func_80151BB4(globalCtx, 0x11); + func_80151BB4(play, 0x11); ret = true; break; case 0x349E: - func_808F4108(this, globalCtx, 0x349F); + func_808F4108(this, play, 0x349F); gSaveContext.save.weekEventReg[56] &= (u8)~8; ret = false; break; @@ -1175,19 +1176,19 @@ s32 func_808F4414(GlobalContext* globalCtx, EnIn* this, s32 arg2) { return ret; } -s32 func_808F5674(GlobalContext* globalCtx, EnIn* this, s32 arg2) { +s32 func_808F5674(PlayState* play, EnIn* this, s32 arg2) { s32 pad; s32 ret = false; - switch (Message_GetState(&globalCtx->msgCtx)) { - case 2: - func_808F4054(globalCtx, this, arg2, this->actor.textId); + switch (Message_GetState(&play->msgCtx)) { + case TEXT_STATE_CLOSING: + func_808F4054(play, this, arg2, this->actor.textId); ret = true; break; - case 4: - case 5: - if (Message_ShouldAdvance(globalCtx) && func_808F4414(globalCtx, this, arg2)) { - func_801477B4(globalCtx); + case TEXT_STATE_CHOICE: + case TEXT_STATE_5: + if (Message_ShouldAdvance(play) && func_808F4414(play, this, arg2)) { + func_801477B4(play); ret = true; } break; @@ -1195,7 +1196,7 @@ s32 func_808F5674(GlobalContext* globalCtx, EnIn* this, s32 arg2) { return ret; } -s32 func_808F5728(GlobalContext* globalCtx, EnIn* this, s32 arg2, s32* arg3) { +s32 func_808F5728(PlayState* play, EnIn* this, s32 arg2, s32* arg3) { s16 rotDiff; s16 yawDiff; Player* player; @@ -1204,24 +1205,24 @@ s32 func_808F5728(GlobalContext* globalCtx, EnIn* this, s32 arg2, s32* arg3) { return 0; } if (*arg3 == 2) { - Message_StartTextbox(globalCtx, this->actor.textId, &this->actor); + Message_StartTextbox(play, this->actor.textId, &this->actor); *arg3 = 1; return 0; } if (*arg3 == 3) { - func_80151938(globalCtx, this->actor.textId); + func_80151938(play, this->actor.textId); *arg3 = 1; return 0; } - if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { + if (Actor_ProcessTalkRequest(&this->actor, &play->state)) { *arg3 = 1; return 1; } if (*arg3 == 1) { s32 requiredScopeTemp; - player = GET_PLAYER(globalCtx); - func_808F5994(this, globalCtx, &player->actor.world.pos, 0xC80); + player = GET_PLAYER(play); + func_808F5994(this, play, &player->actor.world.pos, 0xC80); } else { rotDiff = this->actor.home.rot.y - this->actor.world.rot.y; if (rotDiff > 0x320) { @@ -1234,12 +1235,12 @@ s32 func_808F5728(GlobalContext* globalCtx, EnIn* this, s32 arg2, s32* arg3) { this->actor.shape.rot.y = this->actor.world.rot.y; } if (*arg3 == 1) { - if (func_808F5674(globalCtx, this, arg2)) { + if (func_808F5674(play, this, arg2)) { *arg3 = 0; } return 0; } - if (!func_800B8934(globalCtx, &this->actor)) { + if (!Actor_OnScreen(play, &this->actor)) { return 0; } yawDiff = ABS_ALT(BINANG_SUB(this->actor.yawTowardsPlayer, this->actor.shape.rot.y)); @@ -1250,16 +1251,16 @@ s32 func_808F5728(GlobalContext* globalCtx, EnIn* this, s32 arg2, s32* arg3) { return 0; } if (this->actor.xyzDistToPlayerSq <= SQ(80.0f)) { - if (func_800B8614(&this->actor, globalCtx, 80.0f)) { - this->actor.textId = func_808F3DD4(globalCtx, this, arg2); + if (func_800B8614(&this->actor, play, 80.0f)) { + this->actor.textId = func_808F3DD4(play, this, arg2); } - } else if (func_800B863C(&this->actor, globalCtx)) { - this->actor.textId = func_808F3DD4(globalCtx, this, arg2); + } else if (func_800B863C(&this->actor, play)) { + this->actor.textId = func_808F3DD4(play, this, arg2); } return 0; } -s32 func_808F5994(EnIn* this, GlobalContext* globalCtx, Vec3f* arg2, s16 arg3) { +s32 func_808F5994(EnIn* this, PlayState* play, Vec3f* arg2, s16 arg3) { s32 ret = 0; s16 yaw = Math_Vec3f_Yaw(&this->actor.world.pos, arg2) - this->actor.world.rot.y; @@ -1276,60 +1277,60 @@ s32 func_808F5994(EnIn* this, GlobalContext* globalCtx, Vec3f* arg2, s16 arg3) { return ret; } -void func_808F5A34(EnIn* this, GlobalContext* globalCtx) { +void func_808F5A34(EnIn* this, PlayState* play) { if (gSaveContext.save.day != 3) { - func_808F5728(globalCtx, this, 3, &this->unk48C); + func_808F5728(play, this, 3, &this->unk48C); } else { - func_808F5728(globalCtx, this, 7, &this->unk48C); + func_808F5728(play, this, 7, &this->unk48C); } } -void func_808F5A94(EnIn* this, GlobalContext* globalCtx) { - if (func_800F41E4(globalCtx, &globalCtx->actorCtx)) { +void func_808F5A94(EnIn* this, PlayState* play) { + if (func_800F41E4(play, &play->actorCtx)) { if (gSaveContext.save.day == 3) { - func_808F5728(globalCtx, this, 7, &this->unk48C); + func_808F5728(play, this, 7, &this->unk48C); } else { - func_808F5728(globalCtx, this, 3, &this->unk48C); + func_808F5728(play, this, 3, &this->unk48C); } } else { if (gSaveContext.save.day == 3) { - func_808F5728(globalCtx, this, 5, &this->unk48C); + func_808F5728(play, this, 5, &this->unk48C); } else { - func_808F5728(globalCtx, this, 1, &this->unk48C); + func_808F5728(play, this, 1, &this->unk48C); } } } -void func_808F5B58(EnIn* this, GlobalContext* globalCtx) { - if (func_800F41E4(globalCtx, &globalCtx->actorCtx)) { - if ((Player_GetMask(globalCtx) == PLAYER_MASK_CIRCUS_LEADER && gSaveContext.save.weekEventReg[63] & 0x40) || +void func_808F5B58(EnIn* this, PlayState* play) { + if (func_800F41E4(play, &play->actorCtx)) { + if ((Player_GetMask(play) == 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); + func_808F5728(play, this, 6, &this->unk48C); } else { - func_808F5728(globalCtx, this, 2, &this->unk48C); + func_808F5728(play, this, 2, &this->unk48C); } } - } else if (Player_GetMask(globalCtx) != PLAYER_MASK_CIRCUS_LEADER || - (Player_GetMask(globalCtx) == PLAYER_MASK_CIRCUS_LEADER && gSaveContext.save.weekEventReg[63] & 0x40)) { + } else if (Player_GetMask(play) != PLAYER_MASK_CIRCUS_LEADER || + (Player_GetMask(play) == PLAYER_MASK_CIRCUS_LEADER && gSaveContext.save.weekEventReg[63] & 0x40)) { if (gSaveContext.save.day == 3) { - func_808F5728(globalCtx, this, 4, &this->unk48C); + func_808F5728(play, this, 4, &this->unk48C); } else { - func_808F5728(globalCtx, this, 0, &this->unk48C); + func_808F5728(play, this, 0, &this->unk48C); } } } -void func_808F5C98(EnIn* this, GlobalContext* globalCtx) { +void func_808F5C98(EnIn* this, PlayState* play) { if (this->unk4B0 == RACE_FLAG_END) { this->actionFunc = func_808F5B58; } - if ((Player_GetMask(globalCtx) == PLAYER_MASK_CIRCUS_LEADER && gSaveContext.save.weekEventReg[63] & 0x40) || + if ((Player_GetMask(play) == 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); + func_808F5728(play, this, 2, &this->unk48C); } else { - func_808F5728(globalCtx, this, 6, &this->unk48C); + func_808F5728(play, this, 6, &this->unk48C); } } if (this->unk4A8 == 2) { @@ -1349,18 +1350,17 @@ static InitChainEntry sInitChain[] = { ICHAIN_F32(uncullZoneDownward, 300, ICHAIN_STOP), }; -void EnIn_Init(Actor* thisx, GlobalContext* globalCtx) { +void EnIn_Init(Actor* thisx, PlayState* play) { EnIn* this = THIS; s32 pad[2]; s16 type; Actor_ProcessInitChain(&this->actor, sInitChain); ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 30.0f); - SkelAnime_InitFlex(globalCtx, &this->skelAnime, &object_in_Skel_014EA8, NULL, this->jointTable, this->morphTable, - 20); - func_808F30B0(&this->skelAnime, 0); - Collider_InitCylinder(globalCtx, &this->colliderCylinder); - Collider_SetCylinder(globalCtx, &this->colliderCylinder, &this->actor, &sCylinderInit); + SkelAnime_InitFlex(play, &this->skelAnime, &object_in_Skel_014EA8, NULL, this->jointTable, this->morphTable, 20); + EnIn_ChangeAnim(&this->skelAnime, ENIN_ANIM_0); + Collider_InitCylinder(play, &this->colliderCylinder); + Collider_SetCylinder(play, &this->colliderCylinder, &this->actor, &sCylinderInit); CollisionCheck_SetInfo2(&this->actor.colChkInfo, &sDamageTable, &sColChkInfoInit2); this->unk48A = 0; this->unk48C = 0; @@ -1374,30 +1374,30 @@ void EnIn_Init(Actor* thisx, GlobalContext* globalCtx) { ActorShape_Init(&this->actor.shape, 0.0f, NULL, 0.0f); this->unk488 = 1; Animation_Change(&this->skelAnime, &object_in_Anim_016A60, 1.0f, 0.0f, - Animation_GetLastFrame(&object_in_Anim_016A60), 2, 0.0f); + Animation_GetLastFrame(&object_in_Anim_016A60), ANIMMODE_ONCE, 0.0f); Actor_SetScale(&this->actor, 0.01f); this->unk23C = 0; this->unk23D = 1; this->actionFunc = func_808F374C; } else { - Collider_InitJntSph(globalCtx, &this->colliderJntSph); - Collider_SetJntSph(globalCtx, &this->colliderJntSph, &this->actor, &sJntSphInit, &this->colliderJntSphElement); + Collider_InitJntSph(play, &this->colliderJntSph); + Collider_SetJntSph(play, &this->colliderJntSph, &this->actor, &sJntSphInit, &this->colliderJntSphElement); Actor_SetScale(&this->actor, 0.01f); this->actor.gravity = -4.0f; - this->path = SubS_GetPathByIndex(globalCtx, ENIN_GET_PATH(&this->actor), 0x3F); + this->path = SubS_GetPathByIndex(play, ENIN_GET_PATH(&this->actor), 0x3F); this->unk23D = 0; if (type == ENIN_YELLOW_SHIRT || type == ENIN_BLUE_SHIRT) { if (GET_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); + func_808F35AC(this, play); this->unk23C = 0; D_801BDAA0 = 0; if (GET_RACE_FLAGS == RACE_FLAG_2) { - func_808F30B0(&this->skelAnime, 6); + EnIn_ChangeAnim(&this->skelAnime, ENIN_ANIM_6); } else { - func_808F30B0(&this->skelAnime, 4); + EnIn_ChangeAnim(&this->skelAnime, ENIN_ANIM_4); } if (GET_RACE_FLAGS == RACE_FLAG_2) { this->skelAnime.curFrame = ((Rand_ZeroOne() * 0.6f) + 0.2f) * this->skelAnime.endFrame; @@ -1414,16 +1414,16 @@ void EnIn_Init(Actor* thisx, GlobalContext* globalCtx) { this->unk4AC |= 2; if (type == ENIN_BLUE_SHIRT) { if (func_808F33B8()) { - func_808F30B0(&this->skelAnime, 0); + EnIn_ChangeAnim(&this->skelAnime, ENIN_ANIM_0); this->actionFunc = func_808F5A94; } else { if (gSaveContext.save.weekEventReg[52] & 1) { - Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_KANBAN, this->actor.world.pos.x, + Actor_Spawn(&play->actorCtx, play, 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); Actor_MarkForDeath(&this->actor); } else { - func_808F30B0(&this->skelAnime, 0); + EnIn_ChangeAnim(&this->skelAnime, ENIN_ANIM_0); this->actionFunc = func_808F5A94; } } @@ -1431,7 +1431,7 @@ void EnIn_Init(Actor* thisx, GlobalContext* globalCtx) { if (gSaveContext.save.weekEventReg[52] & 1) { Actor_MarkForDeath(&this->actor); } else { - func_808F30B0(&this->skelAnime, 7); + EnIn_ChangeAnim(&this->skelAnime, ENIN_ANIM_7); this->actionFunc = func_808F5B58; } } @@ -1445,54 +1445,53 @@ void EnIn_Init(Actor* thisx, GlobalContext* globalCtx) { } } -void EnIn_Destroy(Actor* thisx, GlobalContext* globalCtx) { +void EnIn_Destroy(Actor* thisx, PlayState* play) { EnIn* this = THIS; - Collider_DestroyCylinder(globalCtx, &this->colliderCylinder); + Collider_DestroyCylinder(play, &this->colliderCylinder); } -void EnIn_Update(Actor* thisx, GlobalContext* globalCtx) { +void EnIn_Update(Actor* thisx, PlayState* play) { EnIn* this = THIS; - func_808F3310(this, globalCtx); - func_808F3334(this, globalCtx); + func_808F3310(this, play); + func_808F3334(this, play); if (this->unk4AC & 2) { this->unk4AC &= ~2; - func_808F38F8(this, globalCtx); + func_808F38F8(this, play); } - if (Player_GetMask(globalCtx) == PLAYER_MASK_CIRCUS_LEADER) { + if (Player_GetMask(play) == PLAYER_MASK_CIRCUS_LEADER) { this->unk4AC |= 0x40; } else { this->unk4AC &= ~0x40; } - this->actionFunc(this, globalCtx); - Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 0.0f, 0.0f, 0.0f, 0x4); - func_808F3414(this, globalCtx); - func_808F32A0(this, globalCtx); + this->actionFunc(this, play); + Actor_UpdateBgCheckInfo(play, &this->actor, 0.0f, 0.0f, 0.0f, 0x4); + func_808F3414(this, play); + func_808F32A0(this, play); } -void func_808F6334(EnIn* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); - s32 newUnk4C8; +void func_808F6334(EnIn* this, PlayState* play) { + Player* player = GET_PLAYER(play); + s32 talkState = Message_GetState(&play->msgCtx); - newUnk4C8 = Message_GetState(&globalCtx->msgCtx); this->unk4C4 += this->unk4C0 != 0.0f ? 40.0f : -40.0f; this->unk4C4 = CLAMP(this->unk4C4, 0.0f, 80.0f); - Matrix_InsertTranslation(this->unk4C4, 0.0f, 0.0f, MTXMODE_APPLY); - if (&this->actor == player->targetActor && - !(globalCtx->msgCtx.currentTextId >= 0xFF && globalCtx->msgCtx.currentTextId <= 0x200) && newUnk4C8 == 3 && - this->unk4C8 == 3) { - if (!(globalCtx->state.frames & 1)) { + Matrix_Translate(this->unk4C4, 0.0f, 0.0f, MTXMODE_APPLY); + if ((&this->actor == player->targetActor) && + !((play->msgCtx.currentTextId >= 0xFF) && (play->msgCtx.currentTextId <= 0x200)) && + (talkState == TEXT_STATE_3) && (this->prevTalkState == TEXT_STATE_3)) { + if (!(play->state.frames & 1)) { this->unk4C0 = this->unk4C0 != 0.0f ? 0.0f : 1.0f; } } else { this->unk4C0 = 0.0f; } - this->unk4C8 = newUnk4C8; + this->prevTalkState = talkState; } -s32 EnIn_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, Actor* thisx) { +s32 EnIn_OverrideLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, Actor* thisx) { EnIn* this = THIS; s32 pad; Gfx* sp50[] = { @@ -1527,28 +1526,27 @@ s32 EnIn_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, *dList = object_in_DL_01C528; } - OPEN_DISPS(globalCtx->state.gfxCtx); + OPEN_DISPS(play->state.gfxCtx); if (limbIndex == 16) { TexturePtr sp38[] = { object_in_Tex_0035E0, object_in_Tex_004820, object_in_Tex_004C20, object_in_Tex_0043E0 }; gSPSegment(POLY_OPA_DISP++, 0x08, Lib_SegmentedToVirtual(sp38[this->unk482])); gSPSegment(POLY_OPA_DISP++, 0x09, Lib_SegmentedToVirtual(object_in_Tex_003520)); } else { - AnimatedMat_DrawStep(globalCtx, Lib_SegmentedToVirtual(object_in_Matanimheader_001C30), - this->unk4AC & 8 ? 1 : 0); + AnimatedMat_DrawStep(play, Lib_SegmentedToVirtual(object_in_Matanimheader_001C30), this->unk4AC & 8 ? 1 : 0); } - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->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); - func_808F6334(this, globalCtx); + 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, play); } 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); @@ -1572,52 +1570,52 @@ s32 EnIn_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, return 0; } -void EnIn_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx) { +void EnIn_PostLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx) { EnIn* this = THIS; Vec3f sp50 = { 1600.0f, 0.0f, 0.0f }; 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)) { - OPEN_DISPS(globalCtx->state.gfxCtx); + OPEN_DISPS(play->state.gfxCtx); if (limbIndex == 12) { gSPDisplayList(POLY_OPA_DISP++, object_in_DL_007A70); } if (limbIndex == 15) { gSPDisplayList(POLY_OPA_DISP++, object_in_DL_007C48); } - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->state.gfxCtx); } } } if (this->unk4AC & 0x20) { - OPEN_DISPS(globalCtx->state.gfxCtx); + OPEN_DISPS(play->state.gfxCtx); if (limbIndex == 12) { gSPDisplayList(POLY_OPA_DISP++, object_in_DL_007C48); } - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->state.gfxCtx); } } -void EnIn_Draw(Actor* thisx, GlobalContext* globalCtx) { +void EnIn_Draw(Actor* thisx, PlayState* play) { EnIn* this = THIS; - OPEN_DISPS(globalCtx->state.gfxCtx); - func_8012C28C(globalCtx->state.gfxCtx); + OPEN_DISPS(play->state.gfxCtx); + func_8012C28C(play->state.gfxCtx); gDPPipeSync(POLY_OPA_DISP++); - SkelAnime_DrawFlexOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, + SkelAnime_DrawFlexOpa(play, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, EnIn_OverrideLimbDraw, EnIn_PostLimbDraw, &this->actor); - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->state.gfxCtx); } 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..9221c94ce 100644 --- a/src/overlays/actors/ovl_En_In/z_en_in.h +++ b/src/overlays/actors/ovl_En_In/z_en_in.h @@ -5,7 +5,7 @@ struct EnIn; -typedef void (*EnInActionFunc)(struct EnIn*, GlobalContext*); +typedef void (*EnInActionFunc)(struct EnIn*, PlayState*); typedef enum { /* 0 */ ENIN_UNK_TYPE, @@ -15,6 +15,27 @@ typedef enum { /* 4 */ ENIN_BLUE_SHIRT } EnInType; +typedef enum { + /* 0 */ ENIN_ANIM_0, + /* 1 */ ENIN_ANIM_1, + /* 2 */ ENIN_ANIM_2, + /* 3 */ ENIN_ANIM_3, + /* 4 */ ENIN_ANIM_4, + /* 5 */ ENIN_ANIM_5, + /* 6 */ ENIN_ANIM_6, + /* 7 */ ENIN_ANIM_7, + /* 8 */ ENIN_ANIM_8, + /* 9 */ ENIN_ANIM_9, + /* 10 */ ENIN_ANIM_10, + /* 11 */ ENIN_ANIM_11, + /* 12 */ ENIN_ANIM_12, + /* 13 */ ENIN_ANIM_13, + /* 14 */ ENIN_ANIM_14, + /* 15 */ ENIN_ANIM_15, + /* 16 */ ENIN_ANIM_16, + /* 17 */ ENIN_ANIM_17, +} EnInAnimation; + #define ENIN_GET_TYPE(thisx) ((thisx)->params & 0x1FF) #define ENIN_GET_PATH(thisx) (((thisx)->params & 0x7E00) >> 9) // Only used with ENIN_UNK_TYPE @@ -25,7 +46,7 @@ typedef struct EnIn { /* 0x18C */ ColliderJntSph colliderJntSph; /* 0x1AC */ ColliderJntSphElement colliderJntSphElement; /* 0x1EC */ ColliderCylinder colliderCylinder; - /* 0x238 */ char unk238[0x4]; + /* 0x238 */ UNK_TYPE1 unk238[0x4]; /* 0x23C */ u8 unk23C; /* 0x23D */ u8 unk23D; /* 0x240 */ Path* path; @@ -36,22 +57,22 @@ typedef struct EnIn { /* 0x261 */ u8 unk261; /* 0x262 */ Vec3s jointTable[20]; /* 0x2DA */ Vec3s morphTable[20]; - /* 0x352 */ Vec3s unk352; - /* 0x358 */ Vec3s unk358; - /* 0x35E */ Vec3s unk35E; - /* 0x364 */ char unk364[0x12]; + /* 0x352 */ Vec3s trackTarget; + /* 0x358 */ Vec3s headRot; + /* 0x35E */ Vec3s torsoRot; + /* 0x364 */ UNK_TYPE1 unk364[0x12]; /* 0x376 */ s16 unk376[20]; /* 0x39E */ s16 unk39E[20]; - /* 0x3C6 */ char unk3C6[0xBC]; + /* 0x3C6 */ UNK_TYPE1 unk3C6[0xBC]; /* 0x482 */ s16 unk482; /* 0x484 */ s16 unk484; /* 0x486 */ s16 unk486; /* 0x488 */ s16 unk488; /* 0x48A */ u16 unk48A; /* 0x48C */ s32 unk48C; - /* 0x490 */ char unk490[0x4]; + /* 0x490 */ UNK_TYPE1 unk490[0x4]; /* 0x494 */ s32 unk494; - /* 0x498 */ char unk498[0xC]; + /* 0x498 */ UNK_TYPE1 unk498[0xC]; /* 0x4A4 */ struct EnIn* unk4A4; /* 0x4A8 */ s32 unk4A8; /* 0x4AC */ s32 unk4AC; @@ -59,7 +80,7 @@ typedef struct EnIn { /* 0x4B4 */ Vec3f unk4B4; /* 0x4C0 */ f32 unk4C0; /* 0x4C0 */ f32 unk4C4; - /* 0x4C0 */ s32 unk4C8; + /* 0x4C0 */ s32 prevTalkState; } EnIn; // size = 0x4CC extern const ActorInit En_In_InitVars; diff --git a/src/overlays/actors/ovl_En_Insect/z_en_insect.c b/src/overlays/actors/ovl_En_Insect/z_en_insect.c index 75c70113e..e985f6b5c 100644 --- a/src/overlays/actors/ovl_En_Insect/z_en_insect.c +++ b/src/overlays/actors/ovl_En_Insect/z_en_insect.c @@ -11,24 +11,24 @@ #define THIS ((EnInsect*)thisx) -void EnInsect_Init(Actor* thisx, GlobalContext* globalCtx); -void EnInsect_Destroy(Actor* thisx, GlobalContext* globalCtx); -void EnInsect_Update(Actor* thisx, GlobalContext* globalCtx); -void EnInsect_Draw(Actor* thisx, GlobalContext* globalCtx); +void EnInsect_Init(Actor* thisx, PlayState* play); +void EnInsect_Destroy(Actor* thisx, PlayState* play2); +void EnInsect_Update(Actor* thisx, PlayState* play); +void EnInsect_Draw(Actor* thisx, PlayState* play); void func_8091AC78(EnInsect* this); -void func_8091ACC4(EnInsect* this, GlobalContext* globalCtx); +void func_8091ACC4(EnInsect* this, PlayState* play); void func_8091AE10(EnInsect* this); -void func_8091AE5C(EnInsect* this, GlobalContext* globalCtx); +void func_8091AE5C(EnInsect* this, PlayState* play); void func_8091B030(EnInsect* this); -void func_8091B07C(EnInsect* this, GlobalContext* globalCtx); -void func_8091B2D8(EnInsect* this, GlobalContext* globalCtx); +void func_8091B07C(EnInsect* this, PlayState* play); +void func_8091B2D8(EnInsect* this, PlayState* play); void func_8091B3D0(EnInsect* this); -void func_8091B440(EnInsect* this, GlobalContext* globalCtx); +void func_8091B440(EnInsect* this, PlayState* play); void func_8091B618(EnInsect* this); -void func_8091B670(EnInsect* this, GlobalContext* globalCtx); +void func_8091B670(EnInsect* this, PlayState* play); void func_8091B928(EnInsect* this); -void func_8091B984(EnInsect* this, GlobalContext* globalCtx); +void func_8091B984(EnInsect* this, PlayState* play); s16 D_8091BD60 = 0; @@ -67,7 +67,7 @@ static ColliderJntSphInit sJntSphInit = { OC2_TYPE_1, COLSHAPE_JNTSPH, }, - 1, + ARRAY_COUNT(sJntSphElementsInit), sJntSphElementsInit, }; @@ -90,9 +90,9 @@ f32 EnInsect_XZDistanceSquared(Vec3f* arg0, Vec3f* arg1) { return SQ(arg0->x - arg1->x) + SQ(arg0->z - arg1->z); } -s32 EnInsect_InBottleRange(EnInsect* this, GlobalContext* globalCtx) { +s32 EnInsect_InBottleRange(EnInsect* this, PlayState* play) { s32 pad; - Player* player = GET_PLAYER(globalCtx); + Player* player = GET_PLAYER(play); Vec3f sp1C; if (this->actor.xzDistToPlayer < 32.0f) { @@ -120,7 +120,7 @@ void func_8091A9E4(EnInsect* this) { } } -void EnInsect_Init(Actor* thisx, GlobalContext* globalCtx) { +void EnInsect_Init(Actor* thisx, PlayState* play) { EnInsect* this = THIS; f32 rand; @@ -131,11 +131,11 @@ void EnInsect_Init(Actor* thisx, GlobalContext* globalCtx) { Actor_ProcessInitChain(&this->actor, sInitChain); func_8091A8A0(this); - 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); + SkelAnime_Init(play, &this->skelAnime, &gameplay_keep_Skel_0527A0, &gameplay_keep_Anim_05140C, this->jointTable, + this->morphTable, 24); + Animation_Change(&this->skelAnime, &gameplay_keep_Anim_05140C, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP_INTERP, 0.0f); + Collider_InitJntSph(play, &this->collider); + Collider_SetJntSph(play, &this->collider, &this->actor, &sJntSphInit, this->colliderElements); { ColliderJntSphElement* colliderElement = &this->collider.elements[0]; @@ -165,8 +165,11 @@ void EnInsect_Init(Actor* thisx, GlobalContext* globalCtx) { } } -void EnInsect_Destroy(Actor* thisx, GlobalContext* globalCtx) { - Collider_DestroyJntSph(globalCtx, &THIS->collider); +void EnInsect_Destroy(Actor* thisx, PlayState* play2) { + PlayState* play = play2; + EnInsect* this = THIS; + + Collider_DestroyJntSph(play, &this->collider); } void func_8091AC78(EnInsect* this) { @@ -175,7 +178,7 @@ void func_8091AC78(EnInsect* this) { this->unk_30C |= 0x100; } -void func_8091ACC4(EnInsect* this, GlobalContext* globalCtx) { +void func_8091ACC4(EnInsect* this, PlayState* play) { f32 temp_f2; Math_SmoothStepToF(&this->actor.speedXZ, 0.0f, 0.1f, 0.5f, 0.0f); @@ -211,7 +214,7 @@ void func_8091AE10(EnInsect* this) { this->unk_30C |= 0x100; } -void func_8091AE5C(EnInsect* this, GlobalContext* globalCtx) { +void func_8091AE5C(EnInsect* this, PlayState* play) { s32 pad; f32 temp_f0; @@ -251,7 +254,7 @@ void func_8091B030(EnInsect* this) { this->unk_30C |= 0x100; } -void func_8091B07C(EnInsect* this, GlobalContext* globalCtx) { +void func_8091B07C(EnInsect* this, PlayState* play) { s32 pad; f32 speed; s16 frames; @@ -265,7 +268,7 @@ void func_8091B07C(EnInsect* this, GlobalContext* globalCtx) { 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; + frames = play->state.frames; yaw = BINANG_ROT180(this->actor.yawTowardsPlayer); if ((frames & 0x10) != 0) { if ((frames & 0x20) != 0) { @@ -275,7 +278,7 @@ void func_8091B07C(EnInsect* this, GlobalContext* globalCtx) { yaw -= 0x2000; } - if (globalCtx) {} + if (play) {} Math_ScaledStepToS(&this->actor.world.rot.y, yaw, 0x7D0); } @@ -302,7 +305,7 @@ void func_8091B274(EnInsect* this) { this->unk_30C &= ~0x100; } -void func_8091B2D8(EnInsect* this, GlobalContext* globalCtx) { +void func_8091B2D8(EnInsect* this, PlayState* play) { if ((this->unk_312 == 20) && !(this->unk_30C & 4)) { this->actor.draw = EnInsect_Draw; } else if (this->unk_312 == 0) { @@ -329,7 +332,7 @@ void func_8091B3D0(EnInsect* this) { this->unk_30C |= 8; } -void func_8091B440(EnInsect* this, GlobalContext* globalCtx) { +void func_8091B440(EnInsect* this, PlayState* play) { s32 pad[2]; Vec3f sp34; @@ -347,7 +350,7 @@ void func_8091B440(EnInsect* this, GlobalContext* globalCtx) { 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, + func_800B1210(play, &this->actor.world.pos, &sp34, &D_8091BDCC, (Rand_ZeroOne() * 5.0f) + 8.0f, (Rand_ZeroOne() * 5.0f) + 8.0f); } @@ -364,7 +367,7 @@ void func_8091B618(EnInsect* this) { this->unk_30C &= ~0x100; } -void func_8091B670(EnInsect* this, GlobalContext* globalCtx) { +void func_8091B670(EnInsect* this, PlayState* play) { s32 pad[2]; s16 temp; Vec3f sp40; @@ -401,7 +404,7 @@ void func_8091B670(EnInsect* this, GlobalContext* globalCtx) { 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); + EffectSsGRipple_Spawn(play, &sp40, 40, 200, 4); } if ((this->unk_312 <= 0) || ((this->unk_30C & 4) && (this->unk_314 <= 0))) { @@ -423,13 +426,13 @@ void func_8091B928(EnInsect* this) { this->unk_30C |= 8; } -void func_8091B984(EnInsect* this, GlobalContext* globalCtx) { +void func_8091B984(EnInsect* this, PlayState* play) { 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); + EffectSsBubble_Spawn(play, &this->actor.world.pos, -5.0f, 5.0f, 5.0f, (Rand_ZeroOne() * 0.04f) + 0.02f); } if (this->unk_312 <= 0) { @@ -437,7 +440,7 @@ void func_8091B984(EnInsect* this, GlobalContext* globalCtx) { } } -void EnInsect_Update(Actor* thisx, GlobalContext* globalCtx) { +void EnInsect_Update(Actor* thisx, PlayState* play) { EnInsect* this = THIS; s32 phi_v0; @@ -453,7 +456,7 @@ void EnInsect_Update(Actor* thisx, GlobalContext* globalCtx) { this->unk_314--; } - this->actionFunc(this, globalCtx); + this->actionFunc(this, play); if (this->actor.update != NULL) { Actor_MoveWithGravity(&this->actor); @@ -474,10 +477,10 @@ void EnInsect_Update(Actor* thisx, GlobalContext* globalCtx) { if (phi_v0 != 0) { phi_v0 |= 0x40; - Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 8.0f, 5.0f, 0.0f, phi_v0); + Actor_UpdateBgCheckInfo(play, &this->actor, 8.0f, 5.0f, 0.0f, phi_v0); } - if (Actor_HasParent(&this->actor, globalCtx)) { + if (Actor_HasParent(&this->actor, play)) { this->actor.parent = NULL; func_8091B274(this); } else if ((this->actor.xzDistToPlayer < 50.0f) && (this->actionFunc != func_8091B2D8)) { @@ -487,11 +490,11 @@ void EnInsect_Update(Actor* thisx, GlobalContext* globalCtx) { 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); + CollisionCheck_SetOC(play, &play->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)) { + if (!(this->unk_30C & 8) && (D_8091BD60 < 4) && EnInsect_InBottleRange(this, play) && + Actor_PickUp(&this->actor, play, GI_MAX, 60.0f, 30.0f)) { D_8091BD60++; } } @@ -500,10 +503,10 @@ void EnInsect_Update(Actor* thisx, GlobalContext* globalCtx) { } } -void EnInsect_Draw(Actor* thisx, GlobalContext* globalCtx) { +void EnInsect_Draw(Actor* thisx, PlayState* play) { EnInsect* this = THIS; - func_8012C28C(globalCtx->state.gfxCtx); - SkelAnime_DrawOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, NULL, NULL, NULL); + func_8012C28C(play->state.gfxCtx); + SkelAnime_DrawOpa(play, 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 612c6ab20..ae8304cae 100644 --- a/src/overlays/actors/ovl_En_Insect/z_en_insect.h +++ b/src/overlays/actors/ovl_En_Insect/z_en_insect.h @@ -5,24 +5,24 @@ struct EnInsect; -typedef void (*EnInsectActionFunc)(struct EnInsect*, GlobalContext*); +typedef void (*EnInsectActionFunc)(struct EnInsect*, PlayState*); #define ENINSECT_GET_1(thisx) ((thisx)->params & 1) typedef struct EnInsect { - /* 0x0000 */ Actor actor; - /* 0x0144 */ ColliderJntSph collider; - /* 0x0164 */ ColliderJntSphElement colliderElements[1]; - /* 0x01A4 */ SkelAnime skelAnime; - /* 0x01E8 */ Vec3s jointTable[24]; - /* 0x0278 */ Vec3s morphTable[24]; - /* 0x0308 */ EnInsectActionFunc actionFunc; - /* 0x030C */ u16 unk_30C; - /* 0x030E */ s16 unk_30E; - /* 0x0310 */ s16 unk_310; - /* 0x0312 */ s16 unk_312; - /* 0x0314 */ s16 unk_314; - /* 0x0316 */ s16 unk_316; + /* 0x000 */ Actor actor; + /* 0x144 */ ColliderJntSph collider; + /* 0x164 */ ColliderJntSphElement colliderElements[1]; + /* 0x1A4 */ SkelAnime skelAnime; + /* 0x1E8 */ Vec3s jointTable[24]; + /* 0x278 */ Vec3s morphTable[24]; + /* 0x308 */ EnInsectActionFunc actionFunc; + /* 0x30C */ u16 unk_30C; + /* 0x30E */ s16 unk_30E; + /* 0x310 */ s16 unk_310; + /* 0x312 */ s16 unk_312; + /* 0x314 */ s16 unk_314; + /* 0x316 */ s16 unk_316; } EnInsect; // size = 0x318 extern const ActorInit En_Insect_InitVars; diff --git a/src/overlays/actors/ovl_En_Invadepoh/z_en_invadepoh.c b/src/overlays/actors/ovl_En_Invadepoh/z_en_invadepoh.c index 8d2f416a7..c351f83c6 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" @@ -16,158 +18,158 @@ #define THIS ((EnInvadepoh*)thisx) -void EnInvadepoh_Init(Actor* thisx, GlobalContext* globalCtx); -void EnInvadepoh_Destroy(Actor* thisx, GlobalContext* globalCtx); -void EnInvadepoh_Update(Actor* thisx, GlobalContext* globalCtx); +void EnInvadepoh_Init(Actor* thisx, PlayState* play); +void EnInvadepoh_Destroy(Actor* thisx, PlayState* play); +void EnInvadepoh_Update(Actor* thisx, PlayState* play); void func_80B46DA8(EnInvadepoh* this); -void func_80B46DC8(EnInvadepoh* this, GlobalContext* globalCtx); +void func_80B46DC8(EnInvadepoh* this, PlayState* play); void func_80B46E20(EnInvadepoh* this); -void func_80B46E44(EnInvadepoh* this, GlobalContext* globalCtx); +void func_80B46E44(EnInvadepoh* this, PlayState* play); void func_80B46EC0(EnInvadepoh* this); -void func_80B46EE8(EnInvadepoh* this, GlobalContext* globalCtx); +void func_80B46EE8(EnInvadepoh* this, PlayState* play); void func_80B46F88(EnInvadepoh* this); -void func_80B46FA8(EnInvadepoh* this, GlobalContext* globalCtx); +void func_80B46FA8(EnInvadepoh* this, PlayState* play); void func_80B47064(EnInvadepoh* this); -void func_80B47084(EnInvadepoh* this, GlobalContext* globalCtx); +void func_80B47084(EnInvadepoh* this, PlayState* play); void func_80B470E0(EnInvadepoh* this); -void func_80B47108(EnInvadepoh* this, GlobalContext* globalCtx); +void func_80B47108(EnInvadepoh* this, PlayState* play); void func_80B471C0(EnInvadepoh* this); -void func_80B471E0(EnInvadepoh* this, GlobalContext* globalCtx); +void func_80B471E0(EnInvadepoh* this, PlayState* play); void func_80B47248(EnInvadepoh* this); -void func_80B47268(EnInvadepoh* this, GlobalContext* globalCtx); -void func_80B47298(EnInvadepoh* this, GlobalContext* globalCtx); +void func_80B47268(EnInvadepoh* this, PlayState* play); +void func_80B47298(EnInvadepoh* this, PlayState* play); void func_80B47304(EnInvadepoh* this); -void func_80B47324(EnInvadepoh* this, GlobalContext* globalCtx); -void func_80B473E4(EnInvadepoh* this, GlobalContext* globalCtx); -void func_80B474DC(EnInvadepoh* this, GlobalContext* globalCtx); -void func_80B47600(EnInvadepoh* this, GlobalContext* globalCtx); -void func_80B477B4(EnInvadepoh* this, GlobalContext* globalCtx); -void func_80B48324(EnInvadepoh* this, GlobalContext* globalCtx); -void func_80B4ACF0(EnInvadepoh* this, GlobalContext* globalCtx); +void func_80B47324(EnInvadepoh* this, PlayState* play); +void func_80B473E4(EnInvadepoh* this, PlayState* play); +void func_80B474DC(EnInvadepoh* this, PlayState* play); +void func_80B47600(EnInvadepoh* this, PlayState* play); +void func_80B477B4(EnInvadepoh* this, PlayState* play); +void func_80B48324(EnInvadepoh* this, PlayState* play); +void func_80B4ACF0(EnInvadepoh* this, PlayState* play); void func_80B4AD3C(EnInvadepoh* this); -void func_80B4AD60(EnInvadepoh* this, GlobalContext* globalCtx); +void func_80B4AD60(EnInvadepoh* this, PlayState* play); void func_80B4ADB8(EnInvadepoh* this); -void func_80B4ADCC(EnInvadepoh* this, GlobalContext* globalCtx); +void func_80B4ADCC(EnInvadepoh* this, PlayState* play); void func_80B4AEC0(EnInvadepoh* this); -void func_80B4AEDC(EnInvadepoh* this, GlobalContext* globalCtx); +void func_80B4AEDC(EnInvadepoh* this, PlayState* play); void func_80B4AF80(EnInvadepoh* this); -void func_80B4AF94(EnInvadepoh* this, GlobalContext* globalCtx); +void func_80B4AF94(EnInvadepoh* this, PlayState* play); void func_80B4B024(EnInvadepoh* this); -void func_80B4B048(EnInvadepoh* this, GlobalContext* globalCtx); -void func_80B4B484(EnInvadepoh* this, GlobalContext* globalCtx); +void func_80B4B048(EnInvadepoh* this, PlayState* play); +void func_80B4B484(EnInvadepoh* this, PlayState* play); void func_80B4B510(EnInvadepoh* this); -void func_80B4B564(EnInvadepoh* this, GlobalContext* globalCtx); +void func_80B4B564(EnInvadepoh* this, PlayState* play); void func_80B4B724(EnInvadepoh* this); -void func_80B4B768(EnInvadepoh* this, GlobalContext* globalCtx); +void func_80B4B768(EnInvadepoh* this, PlayState* play); void func_80B4B820(EnInvadepoh* this); -void func_80B4B864(EnInvadepoh* this, GlobalContext* globalCtx); +void func_80B4B864(EnInvadepoh* this, PlayState* play); void func_80B48374(EnInvadepoh* this); -void func_80B483CC(EnInvadepoh* this, GlobalContext* globalCtx); -void func_80B49A00(EnInvadepoh* this, GlobalContext* globalCtx); -void func_80B4994C(EnInvadepoh* this, GlobalContext* globalCtx); -void func_80B497EC(EnInvadepoh* this, GlobalContext* globalCtx); +void func_80B483CC(EnInvadepoh* this, PlayState* play); +void func_80B49A00(EnInvadepoh* this, PlayState* play); +void func_80B4994C(EnInvadepoh* this, PlayState* play); +void func_80B497EC(EnInvadepoh* this, PlayState* play); void func_80B49628(EnInvadepoh* this); -void func_80B49670(EnInvadepoh* this, GlobalContext* globalCtx); -void func_80B49454(EnInvadepoh* this, GlobalContext* globalCtx); -void func_80B4934C(EnInvadepoh* this, GlobalContext* globalCtx); +void func_80B49670(EnInvadepoh* this, PlayState* play); +void func_80B49454(EnInvadepoh* this, PlayState* play); +void func_80B4934C(EnInvadepoh* this, PlayState* play); void func_80B491EC(EnInvadepoh* this); -void func_80B49228(EnInvadepoh* this, GlobalContext* globalCtx); -void func_80B49C38(EnInvadepoh* this, GlobalContext* globalCtx); -void func_80B49DFC(EnInvadepoh* this, GlobalContext* globalCtx); -void func_80B4A350(EnInvadepoh* this, GlobalContext* globalCtx); -void func_80B4A5E4(EnInvadepoh* this, GlobalContext* globalCtx); -void func_80B4A67C(EnInvadepoh* this, GlobalContext* globalCtx); -void func_80B4A81C(EnInvadepoh* this, GlobalContext* globalCtx); -void func_80B4BC4C(EnInvadepoh* this, GlobalContext* globalCtx); -void func_80B4C058(EnInvadepoh* this, GlobalContext* globalCtx); -void func_80B4C218(EnInvadepoh* this, GlobalContext* globalCtx); -void func_80B4C730(EnInvadepoh* this, GlobalContext* globalCtx); -void func_80B4CB0C(EnInvadepoh* this, GlobalContext* globalCtx); -void func_80B4CCCC(EnInvadepoh* this, GlobalContext* globalCtx); -void func_80B4D480(EnInvadepoh* this, GlobalContext* globalCtx); +void func_80B49228(EnInvadepoh* this, PlayState* play); +void func_80B49C38(EnInvadepoh* this, PlayState* play); +void func_80B49DFC(EnInvadepoh* this, PlayState* play); +void func_80B4A350(EnInvadepoh* this, PlayState* play); +void func_80B4A5E4(EnInvadepoh* this, PlayState* play); +void func_80B4A67C(EnInvadepoh* this, PlayState* play); +void func_80B4A81C(EnInvadepoh* this, PlayState* play); +void func_80B4BC4C(EnInvadepoh* this, PlayState* play); +void func_80B4C058(EnInvadepoh* this, PlayState* play); +void func_80B4C218(EnInvadepoh* this, PlayState* play); +void func_80B4C730(EnInvadepoh* this, PlayState* play); +void func_80B4CB0C(EnInvadepoh* this, PlayState* play); +void func_80B4CCCC(EnInvadepoh* this, PlayState* play); +void func_80B4D480(EnInvadepoh* this, PlayState* play); void func_80B47568(EnInvadepoh* this); -void func_80B478F4(EnInvadepoh* this, GlobalContext* globalCtx); +void func_80B478F4(EnInvadepoh* this, PlayState* play); void func_80B47938(EnInvadepoh* this); -void func_80B479E8(EnInvadepoh* this, GlobalContext* globalCtx); +void func_80B479E8(EnInvadepoh* this, PlayState* play); void func_80B4843C(EnInvadepoh* this); -void func_80B484EC(EnInvadepoh* this, GlobalContext* globalCtx); +void func_80B484EC(EnInvadepoh* this, PlayState* play); void func_80B48588(EnInvadepoh* this); -void func_80B48610(EnInvadepoh* this, GlobalContext* globalCtx); -void func_80B48848(EnInvadepoh* this, GlobalContext* globalCtx); +void func_80B48610(EnInvadepoh* this, PlayState* play); +void func_80B48848(EnInvadepoh* this, PlayState* play); void func_80B47278(EnInvadepoh* this); -void func_80B48AD4(EnInvadepoh* this, GlobalContext* globalCtx); -void func_80B48E4C(EnInvadepoh* this, GlobalContext* globalCtx); +void func_80B48AD4(EnInvadepoh* this, PlayState* play); +void func_80B48E4C(EnInvadepoh* this, PlayState* play); void func_80B49404(EnInvadepoh* this); void func_80B4A570(EnInvadepoh* this); void func_80B4C1BC(EnInvadepoh* this); -void func_80B4D290(EnInvadepoh* this, GlobalContext* globalCtx); +void func_80B4D290(EnInvadepoh* this, PlayState* play); void func_80B4CC70(EnInvadepoh* this); void func_80B4770C(EnInvadepoh* this); void func_80B48948(EnInvadepoh* this); void func_80B49904(EnInvadepoh* this); void func_80B499BC(EnInvadepoh* this); void func_80B492FC(EnInvadepoh* this); -void func_80B4627C(EnInvadepoh* this, GlobalContext* globalCtx); -void EnInvadepoh_InitAlien(EnInvadepoh* this, GlobalContext* globalCtx); -void EnInvadepoh_InitParentCow(EnInvadepoh* this, GlobalContext* globalCtx); -void EnInvadepoh_InitChildCow(EnInvadepoh* this, GlobalContext* globalCtx); -void EnInvadepoh_InitRomani(EnInvadepoh* this, GlobalContext* globalCtx); -void func_80B468B4(EnInvadepoh* this, GlobalContext* globalCtx); -void EnInvadepoh_InitDog(EnInvadepoh* this, GlobalContext* globalCtx); -void EnInvadepoh_InitCremia(EnInvadepoh* this, GlobalContext* globalCtx); -void func_80B46BB0(EnInvadepoh* this, GlobalContext* globalCtx); -void func_80B46BC0(EnInvadepoh* this, GlobalContext* globalCtx); -void func_80B46C08(EnInvadepoh* this, GlobalContext* globalCtx); -void func_80B46C34(EnInvadepoh* this, GlobalContext* globalCtx); -void func_80B46C50(EnInvadepoh* this, GlobalContext* globalCtx); -void func_80B46C50(EnInvadepoh* this, GlobalContext* globalCtx); -void func_80B46C7C(EnInvadepoh* this, GlobalContext* globalCtx); -void func_80B46C50(EnInvadepoh* this, GlobalContext* globalCtx); -void func_80B46C50(EnInvadepoh* this, GlobalContext* globalCtx); -void func_80B46C50(EnInvadepoh* this, GlobalContext* globalCtx); -void func_80B46C94(EnInvadepoh* this, GlobalContext* globalCtx); -void func_80B46CC0(EnInvadepoh* this, GlobalContext* globalCtx); -void func_80B46CF4(EnInvadepoh* this, GlobalContext* globalCtx); -void func_80B46D28(EnInvadepoh* this, GlobalContext* globalCtx); -void func_80B4D670(Actor* thisx, GlobalContext* globalCtx); -void func_80B47BAC(Actor* thisx, GlobalContext* globalCtx); -void func_80B47D30(Actor* thisx, GlobalContext* globalCtx); -void func_80B47FA8(Actor* thisx, GlobalContext* globalCtx); -void func_80B48060(Actor* thisx, GlobalContext* globalCtx); -void func_80B481C4(Actor* thisx, GlobalContext* globalCtx); -void func_80B4827C(Actor* thisx, GlobalContext* globalCtx); -void func_80B48620(Actor* thisx, GlobalContext* globalCtx); -void func_80B48FB0(Actor* thisx, GlobalContext* globalCtx); -void func_80B49F88(Actor* thisx, GlobalContext* globalCtx); -void func_80B4A9C8(Actor* thisx, GlobalContext* globalCtx); -void func_80B4B0C4(Actor* thisx, GlobalContext* globalCtx); -void func_80B4CE54(Actor* thisx, GlobalContext* globalCtx); -void func_80B4B8BC(Actor* thisx, GlobalContext* globalCtx); -void func_80B4C3A0(Actor* thisx, GlobalContext* globalCtx); -void func_80B49B1C(Actor* thisx, GlobalContext* globalCtx); -void func_80B4E158(Actor* thisx, GlobalContext* globalCtx); -void func_80B4E3F0(Actor* thisx, GlobalContext* globalCtx); -void func_80B4D9B4(Actor* thisx, GlobalContext* globalCtx); -void func_80B4E1B0(Actor* thisx, GlobalContext* globalCtx); -void func_80B4E324(Actor* thisx, GlobalContext* globalCtx); -void func_80B4BA84(Actor* thisx, GlobalContext* globalCtx); -void func_80B4E660(Actor* thisx, GlobalContext* globalCtx); -void func_80B4C5C0(Actor* thisx, GlobalContext* globalCtx); -void func_80B4E7BC(Actor* thisx, GlobalContext* globalCtx); -void func_80B4A1B8(Actor* thisx, GlobalContext* globalCtx); -void func_80B4ABDC(Actor* thisx, GlobalContext* globalCtx); -void func_80B4D054(Actor* thisx, GlobalContext* globalCtx); -void func_80B4DB14(Actor* thisx, GlobalContext* globalCtx); -void func_80B4D760(Actor* thisx, GlobalContext* globalCtx); -void func_80B4A168(Actor* thisx, GlobalContext* globalCtx); -void func_80B4873C(Actor* thisx, GlobalContext* globalCtx); -void func_80B490F0(Actor* thisx, GlobalContext* globalCtx); -void func_80B4AB8C(Actor* thisx, GlobalContext* globalCtx); -void func_80B4B218(Actor* thisx, GlobalContext* globalCtx); -void func_80B4BA30(Actor* thisx, GlobalContext* globalCtx); -void func_80B4C568(Actor* thisx, GlobalContext* globalCtx); -void func_80B4CFFC(Actor* thisx, GlobalContext* globalCtx); +void func_80B4627C(EnInvadepoh* this, PlayState* play); +void EnInvadepoh_InitAlien(EnInvadepoh* this, PlayState* play); +void EnInvadepoh_InitParentCow(EnInvadepoh* this, PlayState* play); +void EnInvadepoh_InitChildCow(EnInvadepoh* this, PlayState* play); +void EnInvadepoh_InitRomani(EnInvadepoh* this, PlayState* play); +void func_80B468B4(EnInvadepoh* this, PlayState* play); +void EnInvadepoh_InitDog(EnInvadepoh* this, PlayState* play); +void EnInvadepoh_InitCremia(EnInvadepoh* this, PlayState* play); +void func_80B46BB0(EnInvadepoh* this, PlayState* play); +void func_80B46BC0(EnInvadepoh* this, PlayState* play); +void func_80B46C08(EnInvadepoh* this, PlayState* play); +void func_80B46C34(EnInvadepoh* this, PlayState* play); +void func_80B46C50(EnInvadepoh* this, PlayState* play); +void func_80B46C50(EnInvadepoh* this, PlayState* play); +void func_80B46C7C(EnInvadepoh* this, PlayState* play); +void func_80B46C50(EnInvadepoh* this, PlayState* play); +void func_80B46C50(EnInvadepoh* this, PlayState* play); +void func_80B46C50(EnInvadepoh* this, PlayState* play); +void func_80B46C94(EnInvadepoh* this, PlayState* play); +void func_80B46CC0(EnInvadepoh* this, PlayState* play); +void func_80B46CF4(EnInvadepoh* this, PlayState* play); +void func_80B46D28(EnInvadepoh* this, PlayState* play); +void func_80B4D670(Actor* thisx, PlayState* play); +void func_80B47BAC(Actor* thisx, PlayState* play); +void func_80B47D30(Actor* thisx, PlayState* play); +void func_80B47FA8(Actor* thisx, PlayState* play); +void func_80B48060(Actor* thisx, PlayState* play); +void func_80B481C4(Actor* thisx, PlayState* play); +void func_80B4827C(Actor* thisx, PlayState* play); +void func_80B48620(Actor* thisx, PlayState* play); +void func_80B48FB0(Actor* thisx, PlayState* play); +void func_80B49F88(Actor* thisx, PlayState* play); +void func_80B4A9C8(Actor* thisx, PlayState* play); +void func_80B4B0C4(Actor* thisx, PlayState* play); +void func_80B4CE54(Actor* thisx, PlayState* play); +void func_80B4B8BC(Actor* thisx, PlayState* play); +void func_80B4C3A0(Actor* thisx, PlayState* play); +void func_80B49B1C(Actor* thisx, PlayState* play); +void func_80B4E158(Actor* thisx, PlayState* play); +void func_80B4E3F0(Actor* thisx, PlayState* play); +void func_80B4D9B4(Actor* thisx, PlayState* play); +void func_80B4E1B0(Actor* thisx, PlayState* play); +void func_80B4E324(Actor* thisx, PlayState* play); +void func_80B4BA84(Actor* thisx, PlayState* play); +void func_80B4E660(Actor* thisx, PlayState* play); +void func_80B4C5C0(Actor* thisx, PlayState* play); +void func_80B4E7BC(Actor* thisx, PlayState* play); +void func_80B4A1B8(Actor* thisx, PlayState* play); +void func_80B4ABDC(Actor* thisx, PlayState* play); +void func_80B4D054(Actor* thisx, PlayState* play); +void func_80B4DB14(Actor* thisx, PlayState* play); +void func_80B4D760(Actor* thisx, PlayState* play); +void func_80B4A168(Actor* thisx, PlayState* play); +void func_80B4873C(Actor* thisx, PlayState* play); +void func_80B490F0(Actor* thisx, PlayState* play); +void func_80B4AB8C(Actor* thisx, PlayState* play); +void func_80B4B218(Actor* thisx, PlayState* play); +void func_80B4BA30(Actor* thisx, PlayState* play); +void func_80B4C568(Actor* thisx, PlayState* play); +void func_80B4CFFC(Actor* thisx, PlayState* play); void func_80B46184(unkStruct80B50350* unkStruct); s32 func_80B450C0(f32* arg0, f32* arg1, f32 arg2, f32 arg3, f32 arg4); s32 func_80B4516C(EnInvadepoh* this); @@ -253,29 +255,28 @@ static Vec3f D_80B4E934 = { 216.0f, -20.0f, 1395.0f }; static s32 D_80B4E940 = 0; -static TexturePtr D_80B4E944[] = { - object_ma1_Tex_00FFC8, object_ma1_Tex_0107C8, object_ma1_Tex_010FC8, object_ma1_Tex_0117C8, object_ma1_Tex_011FC8, +static TexturePtr sRomaniEyeTextures[] = { + gRomaniEyeOpenTex, gRomaniEyeHalfTex, gRomaniEyeClosedTex, gRomaniEyeHappyTex, gRomaniEyeSadTex, }; -static TexturePtr D_80B4E958[] = { - object_ma1_Tex_0127C8, - object_ma1_Tex_012BC8, - object_ma1_Tex_012FC8, - object_ma1_Tex_0133C8, +static TexturePtr sRomaniMouthTextures[] = { + gRomaniMouthHappyTex, + gRomaniMouthFrownTex, + gRomaniMouthHangingOpenTex, + gRomaniMouthSmileTex, }; static s8 D_80B4E968 = 0; -static TexturePtr D_80B4E96C[] = { - object_ma2_Tex_011AD8, object_ma2_Tex_0122D8, object_ma2_Tex_012AD8, - object_ma2_Tex_0132D8, object_ma2_Tex_013AD8, object_ma2_Tex_0142D8, +static TexturePtr sCremiaEyeTextures[] = { + gCremiaEyeOpenTex, gCremiaEyeHalfTex, gCremiaEyeClosedTex, gCremiaEyeHappyTex, gCremiaEyeAngryTex, gCremiaEyeSadTex, }; -static TexturePtr D_80B4E984[] = { - object_ma2_Tex_014AD8, - object_ma2_Tex_014ED8, - object_ma2_Tex_0152D8, - object_ma2_Tex_0156D8, +static TexturePtr sCremiaMouthTextures[] = { + gCremiaMouthNormalTex, + gCremiaMouthSlightSmileTex, + gCremiaMouthFrownTex, + gCremiaMouthHangingOpenTex, }; static s8 D_80B4E994 = 0; @@ -325,7 +326,7 @@ static unkstructInvadepoh1 D_80B4EA24[] = { { 1, 1.0f }, }; -static unkstructInvadepoh4 D_80B4EA2C = { 2, &D_80B4E9C4, 4, D_80B4EA04, 0x28, 0x3c }; +static unkstructInvadepoh4 D_80B4EA2C = { 2, &D_80B4E9C4, 4, D_80B4EA04, 0x28, 0x3C }; static unkstructInvadepoh3 D_80B4EA40 = { 1, @@ -616,8 +617,8 @@ unkStruct80B50350 D_80B50350[10]; EnInvadepoh* D_80B503F0; EnInvadepoh* D_80B503F4; EnInvadepoh* D_80B503F8; -AnimatedMaterial* D_80B503FC; -AnimatedMaterial* D_80B50400; +AnimatedMaterial* sAlienEyeBeamTexAnim; +AnimatedMaterial* sAlienEmptyTexAnim; s16 D_80B50404[3]; EnInvadepoh* D_80B5040C; @@ -798,8 +799,8 @@ f32 EnInvadepoh_GetTotalPathLength(EnInvadepoh* this) { return totalDistance; } -void func_80B44024(EnInvadepoh* this, GlobalContext* globalCtx) { - Path* path = &globalCtx->setupPathList[(this->actor.params >> 8) & 0x7F]; +void func_80B44024(EnInvadepoh* this, PlayState* play) { + Path* path = &play->setupPathList[(this->actor.params >> 8) & 0x7F]; this->endPoint = path->count - 1; this->pathPoints = Lib_SegmentedToVirtual(path->points); @@ -872,9 +873,7 @@ s32 func_80B44234(EnInvadepoh* this, Vec3f* vec) { } void func_80B442E4(EnInvadepoh* this) { - s32 pad; - s32 sp18 = gSaveContext.save.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; @@ -923,14 +922,14 @@ void func_80B443A0(EnInvadepoh* this) { } } -void func_80B444BC(EnInvadepoh* this, GlobalContext* globalCtx) { - func_80B44024(this, globalCtx); +void func_80B444BC(EnInvadepoh* this, PlayState* play) { + func_80B44024(this, play); this->pathTotalDist = EnInvadepoh_GetTotalPathLength(this); func_80B443A0(this); } -void func_80B444F4(EnInvadepoh* this, GlobalContext* globalCtx) { - func_80B44024(this, globalCtx); +void func_80B444F4(EnInvadepoh* this, PlayState* play) { + func_80B44024(this, play); } void func_80B44514(EnInvadepoh* this) { @@ -940,8 +939,8 @@ void func_80B44514(EnInvadepoh* this) { } } -void func_80B44540(EnInvadepoh* this, GlobalContext* globalCtx) { - func_80B44024(this, globalCtx); +void func_80B44540(EnInvadepoh* this, PlayState* play) { + func_80B44024(this, play); this->pathTotalDist = EnInvadepoh_GetTotalPathLength(this); } @@ -960,8 +959,8 @@ void func_80B44570(EnInvadepoh* this) { } } -void func_80B44620(EnInvadepoh* this, GlobalContext* globalCtx) { - func_80B44024(this, globalCtx); +void func_80B44620(EnInvadepoh* this, PlayState* play) { + func_80B44024(this, play); } void func_80B44640(EnInvadepoh* this) { @@ -970,8 +969,8 @@ void func_80B44640(EnInvadepoh* this) { } } -void func_80B44664(EnInvadepoh* this, GlobalContext* globalCtx) { - func_80B44024(this, globalCtx); +void func_80B44664(EnInvadepoh* this, PlayState* play) { + func_80B44024(this, play); this->direction = DIRECTION_FORWARD; } @@ -984,8 +983,8 @@ void func_80B44690(EnInvadepoh* this) { } } -void func_80B446D0(EnInvadepoh* this, GlobalContext* globalCtx) { - func_80B44024(this, globalCtx); +void func_80B446D0(EnInvadepoh* this, PlayState* play) { + func_80B44024(this, play); this->pathTotalDist = EnInvadepoh_GetTotalPathLength(this); } @@ -999,12 +998,13 @@ 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); } } -void func_80B447C0(EnInvadepoh* this, GlobalContext* globalCtx) { +void func_80B447C0(EnInvadepoh* this, PlayState* play) { s32 pad1; Vec3s* sp60; s32 pad2; @@ -1045,7 +1045,7 @@ void func_80B447C0(EnInvadepoh* this, GlobalContext* globalCtx) { } Math_Vec3f_Copy(&this->actor.world.pos, &this->curPathPos); - func_800B4AEC(globalCtx, &this->actor, 0.0f); + func_800B4AEC(play, &this->actor, 0.0f); if (this->actor.floorHeight > BGCHECK_Y_MIN + 1) { if (sp40 < this->actor.floorHeight) { if (this->actor.velocity.y < 0.0f) { @@ -1076,7 +1076,7 @@ void func_80B447C0(EnInvadepoh* this, GlobalContext* globalCtx) { } } -void func_80B44A90(EnInvadepoh* this, GlobalContext* globalCtx) { +void func_80B44A90(EnInvadepoh* this, PlayState* play) { if (this->actor.bgCheckFlags & 1) { this->actor.velocity.y *= 0.3f; this->actor.speedXZ *= 0.8f; @@ -1088,33 +1088,33 @@ void func_80B44A90(EnInvadepoh* this, GlobalContext* globalCtx) { this->actor.speedXZ *= 0.8f; } Actor_MoveWithGravity(&this->actor); - Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 30.0f, 40.0f, 0.0f, 5); + Actor_UpdateBgCheckInfo(play, &this->actor, 30.0f, 40.0f, 0.0f, 5); } void func_80B44B78(EnInvadepoh* this) { } -s32 func_80B44B84(EnInvadepoh* this, GlobalContext* globalCtx, f32 speed, f32 arg3) { +s32 func_80B44B84(EnInvadepoh* this, PlayState* play, f32 speed, f32 arg3) { s32 pad; Vec3s* pathPoint = &this->pathPoints[this->pathIndex + 1]; s32 retVal = func_80B450C0(&this->actor.world.pos.x, &this->actor.world.pos.z, pathPoint->x, pathPoint->z, speed); - func_800B4AEC(globalCtx, &this->actor, arg3); + func_800B4AEC(play, &this->actor, arg3); func_80B4516C(this); return retVal; } -void func_80B44C24(EnInvadepoh* this, GlobalContext* globalCtx) { +void func_80B44C24(EnInvadepoh* this, PlayState* play) { s32 pad; f32 worldPosY = this->actor.world.pos.y; func_80B43BC8(this, &this->pathIndex, &this->actor.world.pos); this->actor.world.pos.y = worldPosY; - func_800B4AEC(globalCtx, &this->actor, 50.0f); + func_800B4AEC(play, &this->actor, 50.0f); func_80B4516C(this); } -s32 func_80B44C80(EnInvadepoh* this, GlobalContext* globalCtx) { +s32 func_80B44C80(EnInvadepoh* this, PlayState* play) { s32 pad[6]; Vec3s* temp_a2 = &this->pathPoints[this->pathIndex]; f32 temp_f0; @@ -1170,24 +1170,24 @@ s32 func_80B44C80(EnInvadepoh* this, GlobalContext* globalCtx) { phi_v0 = 5; } - Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 30.0f, 15.0f, 0.0f, phi_v0); + Actor_UpdateBgCheckInfo(play, &this->actor, 30.0f, 15.0f, 0.0f, phi_v0); Math_SmoothStepToS(&this->actor.shape.rot.y, this->actor.world.rot.y, 3, 0x1F40, 0x64); return sp40; } -void func_80B44E90(EnInvadepoh* this, GlobalContext* globalCtx) { +void func_80B44E90(EnInvadepoh* this, PlayState* play) { Actor_MoveWithGravity(&this->actor); - Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 30.0f, 15.0f, 0.0f, 5); + Actor_UpdateBgCheckInfo(play, &this->actor, 30.0f, 15.0f, 0.0f, 5); Math_SmoothStepToS(&this->actor.shape.rot.y, this->actor.world.rot.y, 3, 0x1F40, 0x64); } -void func_80B44EFC(EnInvadepoh* this, GlobalContext* globalCtx) { +void func_80B44EFC(EnInvadepoh* this, PlayState* play) { s32 pad; f32 worldPosY = this->actor.world.pos.y; func_80B43BC8(this, &this->pathIndex, &this->actor.world.pos); this->actor.world.pos.y = worldPosY; - func_800B4AEC(globalCtx, &this->actor, 50.0f); + func_800B4AEC(play, &this->actor, 50.0f); func_80B4516C(this); } @@ -1197,11 +1197,11 @@ void func_80B44F58(void) { if (!D_80B4E968) { D_80B4E968 = true; - for (i = 0, iter = D_80B4E944; i < ARRAY_COUNT(D_80B4E944); i++, iter++) { + for (i = 0, iter = sRomaniEyeTextures; i < ARRAY_COUNT(sRomaniEyeTextures); i++, iter++) { *iter = Lib_SegmentedToVirtual(*iter); } - for (i = 0, iter = D_80B4E958; i < ARRAY_COUNT(D_80B4E958); i++, iter++) { + for (i = 0, iter = sRomaniMouthTextures; i < ARRAY_COUNT(sRomaniMouthTextures); i++, iter++) { *iter = Lib_SegmentedToVirtual(*iter); } } @@ -1213,19 +1213,19 @@ void func_80B44FEC(void) { if (!D_80B4E994) { D_80B4E994 = true; - for (i = 0, iter = D_80B4E96C; i < ARRAY_COUNT(D_80B4E96C); i++, iter++) { + for (i = 0, iter = sCremiaEyeTextures; i < ARRAY_COUNT(sCremiaEyeTextures); i++, iter++) { *iter = Lib_SegmentedToVirtual(*iter); } - for (i = 0, iter = D_80B4E984; i < ARRAY_COUNT(D_80B4E984); i++, iter++) { + for (i = 0, iter = sCremiaMouthTextures; i < ARRAY_COUNT(sCremiaMouthTextures); i++, iter++) { *iter = Lib_SegmentedToVirtual(*iter); } } } void func_80B45080(void) { - D_80B50400 = Lib_SegmentedToVirtual(object_uch_Matanimheader_000560); - D_80B503FC = Lib_SegmentedToVirtual(object_uch_Matanimheader_000550); + sAlienEmptyTexAnim = Lib_SegmentedToVirtual(gAlienEmptyTexAnim); + sAlienEyeBeamTexAnim = Lib_SegmentedToVirtual(gAlienEyeBeamTexAnim); } s32 func_80B450C0(f32* x1, f32* z1, f32 x2, f32 z2, f32 speed) { @@ -1253,7 +1253,7 @@ s32 func_80B4516C(EnInvadepoh* this) { return false; } -void func_80B451A0(EnInvadepoh* this, GlobalContext* globalCtx) { +void func_80B451A0(EnInvadepoh* this, PlayState* play) { s32 currentTime; s32 temp_v0_2; s32 i; @@ -1293,47 +1293,47 @@ void func_80B451A0(EnInvadepoh* this, GlobalContext* globalCtx) { } } -void func_80B452EC(EnInvadepoh* this, GlobalContext* globalCtx) { +void func_80B452EC(EnInvadepoh* this, PlayState* play) { s32 phi_s2 = (this->actor.params >> 8) & 0x7F; s32 i; for (i = 0; i < this->unk379; i++) { - D_80B50320[i] = (EnInvadepoh*)Actor_Spawn( - &globalCtx->actorCtx, globalCtx, ACTOR_EN_INVADEPOH, this->actor.world.pos.x, this->actor.world.pos.y, - this->actor.world.pos.z, 0, 0, 0, (i & 7) | ((phi_s2 << 8) & 0x7F00) | 0x10); + D_80B50320[i] = (EnInvadepoh*)Actor_Spawn(&play->actorCtx, play, ACTOR_EN_INVADEPOH, this->actor.world.pos.x, + this->actor.world.pos.y, this->actor.world.pos.z, 0, 0, 0, + (i & 7) | ((phi_s2 << 8) & 0x7F00) | 0x10); if (phi_s2 != 0xFF) { - Path* path = &globalCtx->setupPathList[phi_s2]; + Path* path = &play->setupPathList[phi_s2]; phi_s2 = path->unk1; } } } -void func_80B453F4(EnInvadepoh* this, GlobalContext* globalCtx, s32 arg2) { - Actor_SpawnAsChild(&globalCtx->actorCtx, &this->actor, globalCtx, ACTOR_EN_INVADEPOH, this->actor.home.pos.x, +void func_80B453F4(EnInvadepoh* this, PlayState* play, s32 arg2) { + Actor_SpawnAsChild(&play->actorCtx, &this->actor, play, ACTOR_EN_INVADEPOH, this->actor.home.pos.x, this->actor.home.pos.y, this->actor.home.pos.z, 0, 0, 0, (arg2 & 7) | 0x20); } -void func_80B45460(EnInvadepoh* this, GlobalContext* globalCtx) { - Actor_SpawnAsChild(&globalCtx->actorCtx, &this->actor, globalCtx, ACTOR_EN_INVADEPOH, this->actor.home.pos.x, +void func_80B45460(EnInvadepoh* this, PlayState* play) { + Actor_SpawnAsChild(&play->actorCtx, &this->actor, play, ACTOR_EN_INVADEPOH, this->actor.home.pos.x, this->actor.home.pos.y, this->actor.home.pos.z, 0, 0, 0, 0x40); } -void func_80B454BC(EnInvadepoh* this, GlobalContext* globalCtx) { - D_80B503F0 = (EnInvadepoh*)Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_INVADEPOH, this->actor.world.pos.x, +void func_80B454BC(EnInvadepoh* this, PlayState* play) { + D_80B503F0 = (EnInvadepoh*)Actor_Spawn(&play->actorCtx, play, ACTOR_EN_INVADEPOH, this->actor.world.pos.x, this->actor.world.pos.y, this->actor.world.pos.z, 0, 0, 0, 0x60); } void EnInvadepoh_SetSysMatrix(Vec3f* vec) { - MtxF* sysMatrix = Matrix_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) { +s32 func_80B45550(EnInvadepoh* this, PlayState* play, f32 range, s32 arg3) { s32 pad; - Actor* actorIterator = globalCtx->actorCtx.actorLists[ACTORCAT_DOOR].first; + Actor* actorIterator = play->actorCtx.actorLists[ACTORCAT_DOOR].first; s32 retVal = false; while (actorIterator != NULL) { @@ -1349,9 +1349,9 @@ s32 func_80B45550(EnInvadepoh* this, GlobalContext* globalCtx, f32 range, s32 ar return retVal; } -void EnInvadepoh_SetTextID(EnInvadepoh* this, GlobalContext* globalCtx, u16 arg2) { +void EnInvadepoh_SetTextID(EnInvadepoh* this, PlayState* play, u16 arg2) { this->textId = arg2; - Message_StartTextbox(globalCtx, arg2, &this->actor); + Message_StartTextbox(play, arg2, &this->actor); } void func_80B45648(EnInvadepoh* this) { @@ -1364,16 +1364,16 @@ void func_80B45648(EnInvadepoh* this) { } } -s32 func_80B456A8(GlobalContext* globalCtx, Vec3f* vec) { - Vec3f multDest; - f32 wDest; +s32 func_80B456A8(PlayState* play, Vec3f* worldPos) { + Vec3f projectedPos; + f32 invW; - Actor_GetProjectedPos(globalCtx, vec, &multDest, &wDest); - if (((multDest.z > 1.0f) && (fabsf(multDest.x * wDest) < 1.0f)) && (fabsf(multDest.y * wDest) < 1.0f)) { - s32 wX = (multDest.x * wDest * 160.0f) + 160.0f; - s32 wY = (multDest.y * wDest * -120.0f) + 120.0f; - s32 wZ = (s32)(multDest.z * wDest * 16352.0f) + 0x3FE0; - s32 zBuf = func_80178A94(wX, wY); + Actor_GetProjectedPos(play, worldPos, &projectedPos, &invW); + if (((projectedPos.z > 1.0f) && (fabsf(projectedPos.x * invW) < 1.0f)) && (fabsf(projectedPos.y * invW) < 1.0f)) { + s32 screenPosX = PROJECTED_TO_SCREEN_X(projectedPos, invW); + s32 screenPosY = PROJECTED_TO_SCREEN_Y(projectedPos, invW); + s32 wZ = (s32)(projectedPos.z * invW * 16352.0f) + 16352; + s32 zBuf = func_80178A94(screenPosX, screenPosY); if (wZ < zBuf) { return true; } @@ -1423,11 +1423,11 @@ EnInvadepoh* func_80B458D8(void) { s8 func_80B45980(unkstructInvadepoh1* arg0, s32 arg1) { f32 rand = Rand_ZeroOne(); s32 i; + unkstructInvadepoh1* ptr = arg0; arg1--; - for (i = 0; i < arg1; i++) { - dummy:; - if (arg0[i].unk04 >= rand) { + for (i = 0; i < arg1; i++, ptr++) { + if (ptr->unk04 >= rand) { break; } } @@ -1549,7 +1549,7 @@ void func_80B45CE0(AlienBehaviorInfo* substruct) { func_80B45BB8(&substruct->unk10); } -void func_80B45EC8(EnInvadepoh* this, GlobalContext* globalCtx, s32 arg2) { +void func_80B45EC8(EnInvadepoh* this, PlayState* play, s32 arg2) { s16 phi_s0 = 0; Vec3f spA8; Vec3f sp9C; @@ -1576,7 +1576,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(play, &spA8, &sp9C, &sp90, &D_80B4EC18, &D_80B4EC1C, 6000, -40); } } @@ -1626,7 +1626,7 @@ s32 func_80B461DC(void) { return phi_s4; } -void func_80B4627C(EnInvadepoh* this, GlobalContext* globalCtx) { +void func_80B4627C(EnInvadepoh* this, PlayState* play) { s32 invadepohType; s32 i; @@ -1634,7 +1634,7 @@ void func_80B4627C(EnInvadepoh* this, GlobalContext* globalCtx) { invadepohType = (this->actor.params >> 8) & 0x7F; for (i = 1; i < 8; i++) { - Path* path = &globalCtx->setupPathList[invadepohType]; + Path* path = &play->setupPathList[invadepohType]; invadepohType = path->unk1; if (invadepohType == 0xFF) { break; @@ -1642,9 +1642,9 @@ void func_80B4627C(EnInvadepoh* this, GlobalContext* globalCtx) { } this->unk379 = i; - func_80B451A0(this, globalCtx); + func_80B451A0(this, play); func_80B45648(this); - func_800BC154(globalCtx, &globalCtx->actorCtx, &this->actor, ACTORCAT_SWITCH); + func_800BC154(play, &play->actorCtx, &this->actor, ACTORCAT_SWITCH); if (D_80B4E940 == 1) { func_80B46DA8(this); @@ -1652,16 +1652,16 @@ void func_80B4627C(EnInvadepoh* this, GlobalContext* globalCtx) { if (gSaveContext.save.time < CLOCK_TIME(2, 31)) { func_80B46DA8(this); } else { - func_80B454BC(this, globalCtx); - func_80B452EC(this, globalCtx); + func_80B454BC(this, play); + func_80B452EC(this, play); Audio_QueueSeqCmd(NA_BGM_ALIEN_INVASION | 0x8000); func_80B46F88(this); } } else if (D_80B4E940 == 3) { - if (gSaveContext.save.entranceIndex == 0x6460) { + if (gSaveContext.save.entrance == ENTRANCE(ROMANI_RANCH, 6)) { func_80B471C0(this); - } else if (gSaveContext.save.entranceIndex == 0x6470) { + } else if (gSaveContext.save.entrance == ENTRANCE(ROMANI_RANCH, 7)) { func_80B47248(this); } else { func_80B47248(this); @@ -1671,61 +1671,60 @@ void func_80B4627C(EnInvadepoh* this, GlobalContext* globalCtx) { } } -void EnInvadepoh_InitAlien(EnInvadepoh* this, GlobalContext* globalCtx) { +void EnInvadepoh_InitAlien(EnInvadepoh* this, PlayState* play) { s32 pad; Actor_ProcessInitChain(&this->actor, D_80B4EC24); - Collider_InitCylinder(globalCtx, &this->collider); + Collider_InitCylinder(play, &this->collider); ActorShape_Init(&this->actor.shape, 6800.0f, ActorShadow_DrawWhiteCircle, 150.0f); this->actor.shape.shadowAlpha = 140; this->actor.flags = (ACTOR_FLAG_10 | ACTOR_FLAG_1000 | ACTOR_FLAG_80000000); - if (INVADEPOH_TYPE(this) == TYPE_ALIEN1) { + if (INVADEPOH_TYPE(&this->actor) == TYPE_ALIEN_CARRYING_COW) { this->actor.update = func_80B4D670; this->actor.world.pos.y = this->actor.home.pos.y + 150.0f; } else { this->actor.update = func_80B47BAC; - Collider_SetCylinder(globalCtx, &this->collider, &this->actor, &sCylinderInitAlien); + Collider_SetCylinder(play, &this->collider, &this->actor, &sCylinderInitAlien); this->actor.colChkInfo.mass = 40; } - this->bankIndex = Object_GetIndex(&globalCtx->objectCtx, OBJECT_UCH); + this->bankIndex = Object_GetIndex(&play->objectCtx, OBJECT_UCH); if (this->bankIndex < 0) { Actor_MarkForDeath(&this->actor); } } -void EnInvadepoh_InitParentCow(EnInvadepoh* this, GlobalContext* globalCtx) { +void EnInvadepoh_InitParentCow(EnInvadepoh* this, PlayState* play) { Actor_ProcessInitChain(&this->actor, sInitChainParentCow); this->actor.update = func_80B47FA8; - Actor_SpawnAsChild(&globalCtx->actorCtx, &this->actor, globalCtx, ACTOR_EN_INVADEPOH, 0.0f, 0.0f, 0.0f, 0, 0, 0, - 0x30); - this->bankIndex = Object_GetIndex(&globalCtx->objectCtx, OBJECT_COW); + Actor_SpawnAsChild(&play->actorCtx, &this->actor, play, ACTOR_EN_INVADEPOH, 0.0f, 0.0f, 0.0f, 0, 0, 0, 0x30); + this->bankIndex = Object_GetIndex(&play->objectCtx, OBJECT_COW); if (this->bankIndex < 0) { Actor_MarkForDeath(&this->actor); } } -void EnInvadepoh_InitChildCow(EnInvadepoh* this, GlobalContext* globalCtx) { +void EnInvadepoh_InitChildCow(EnInvadepoh* this, PlayState* play) { Actor_ProcessInitChain(&this->actor, sInitChainChildCow); this->actor.update = func_80B481C4; - this->bankIndex = Object_GetIndex(&globalCtx->objectCtx, OBJECT_COW); + this->bankIndex = Object_GetIndex(&play->objectCtx, OBJECT_COW); if (this->bankIndex < 0) { Actor_MarkForDeath(&this->actor); } } -void EnInvadepoh_InitRomani(EnInvadepoh* this, GlobalContext* globalCtx) { +void EnInvadepoh_InitRomani(EnInvadepoh* this, PlayState* play) { s32 pad; - s32 temp = INVADEPOH_TYPE(this); + s32 temp = INVADEPOH_TYPE(&this->actor); Actor_ProcessInitChain(&this->actor, sInitChainRomani); this->actor.targetMode = (temp == 7 || temp == 0xC) ? 3 : 6; - func_800BC154(globalCtx, &globalCtx->actorCtx, &this->actor, ACTORCAT_NPC); - Collider_InitCylinder(globalCtx, &this->collider); + func_800BC154(play, &play->actorCtx, &this->actor, ACTORCAT_NPC); + Collider_InitCylinder(play, &this->collider); if (temp != 4) { ActorShape_Init(&this->actor.shape, 0, ActorShadow_DrawCircle, 18.0f); - Collider_SetCylinder(globalCtx, &this->collider, &this->actor, &sCylinderInitRomaniAndCremia); + Collider_SetCylinder(play, &this->collider, &this->actor, &sCylinderInitRomaniAndCremia); this->actor.colChkInfo.mass = MASS_IMMOVABLE; } if (temp == 4) { @@ -1743,7 +1742,7 @@ void EnInvadepoh_InitRomani(EnInvadepoh* this, GlobalContext* globalCtx) { this->actor.update = func_80B4CE54; } - this->bankIndex = Object_GetIndex(&globalCtx->objectCtx, OBJECT_MA1); + this->bankIndex = Object_GetIndex(&play->objectCtx, OBJECT_MA1); if (this->bankIndex < 0) { Actor_MarkForDeath(&this->actor); } @@ -1759,7 +1758,7 @@ void EnInvadepoh_InitRomani(EnInvadepoh* this, GlobalContext* globalCtx) { } } else if (temp != 8) { if (temp == 9) { - if (gSaveContext.save.entranceIndex != 0x6460) { + if (gSaveContext.save.entrance != ENTRANCE(ROMANI_RANCH, 6)) { Actor_MarkForDeath(&this->actor); return; } @@ -1772,11 +1771,11 @@ void EnInvadepoh_InitRomani(EnInvadepoh* this, GlobalContext* globalCtx) { } } -void func_80B468B4(EnInvadepoh* this, GlobalContext* globalCtx) { +void func_80B468B4(EnInvadepoh* this, PlayState* play) { Actor_ProcessInitChain(&this->actor, D_80B4EC68); this->actor.update = func_80B49B1C; this->actor.draw = func_80B4E3F0; - func_800BC154(globalCtx, &globalCtx->actorCtx, &this->actor, ACTORCAT_NPC); + func_800BC154(play, &play->actorCtx, &this->actor, ACTORCAT_NPC); if (D_80B4E940 == 1 || gSaveContext.save.time < CLOCK_TIME(2, 31)) { this->actor.world.pos.x += D_80B4E934.x; this->actor.world.pos.y += D_80B4E934.y + 3000.0f; @@ -1790,32 +1789,32 @@ void func_80B468B4(EnInvadepoh* this, GlobalContext* globalCtx) { } } -void EnInvadepoh_InitDog(EnInvadepoh* this, GlobalContext* globalCtx) { +void EnInvadepoh_InitDog(EnInvadepoh* this, PlayState* play) { s32 pad; Actor_ProcessInitChain(&this->actor, sInitChainDog); this->actor.update = func_80B4B8BC; - Collider_InitCylinder(globalCtx, &this->collider); - Collider_SetCylinder(globalCtx, &this->collider, &this->actor, &sCylinderInitDog); + Collider_InitCylinder(play, &this->collider); + Collider_SetCylinder(play, &this->collider, &this->actor, &sCylinderInitDog); this->actor.colChkInfo.mass = 80; ActorShape_Init(&this->actor.shape, 0, ActorShadow_DrawCircle, 24.0f); - this->bankIndex = Object_GetIndex(&globalCtx->objectCtx, OBJECT_DOG); + this->bankIndex = Object_GetIndex(&play->objectCtx, OBJECT_DOG); if (this->bankIndex < 0) { Actor_MarkForDeath(&this->actor); } } -void EnInvadepoh_InitCremia(EnInvadepoh* this, GlobalContext* globalCtx) { +void EnInvadepoh_InitCremia(EnInvadepoh* this, PlayState* play) { s32 pad; Actor_ProcessInitChain(&this->actor, sInitChainCremia); this->actor.update = func_80B4C3A0; - func_800BC154(globalCtx, &globalCtx->actorCtx, &this->actor, ACTORCAT_NPC); - Collider_InitCylinder(globalCtx, &this->collider); - Collider_SetCylinder(globalCtx, &this->collider, &this->actor, &sCylinderInitRomaniAndCremia); + func_800BC154(play, &play->actorCtx, &this->actor, ACTORCAT_NPC); + Collider_InitCylinder(play, &this->collider); + Collider_SetCylinder(play, &this->collider, &this->actor, &sCylinderInitRomaniAndCremia); this->actor.colChkInfo.mass = MASS_HEAVY; ActorShape_Init(&this->actor.shape, 0, ActorShadow_DrawCircle, 18.0f); - this->bankIndex = Object_GetIndex(&globalCtx->objectCtx, OBJECT_MA2); + this->bankIndex = Object_GetIndex(&play->objectCtx, OBJECT_MA2); if (this->bankIndex < 0) { Actor_MarkForDeath(&this->actor); } @@ -1825,24 +1824,24 @@ void EnInvadepoh_InitCremia(EnInvadepoh* this, GlobalContext* globalCtx) { D_80B503F8 = this; } -void EnInvadepoh_Init(Actor* thisx, GlobalContext* globalCtx) { +void EnInvadepoh_Init(Actor* thisx, PlayState* play) { EnInvadepoh* this = THIS; - D_80B4ECB0[INVADEPOH_TYPE(this)](this, globalCtx); + D_80B4ECB0[INVADEPOH_TYPE(&this->actor)](this, play); } -void func_80B46BB0(EnInvadepoh* this, GlobalContext* globalCtx) { +void func_80B46BB0(EnInvadepoh* this, PlayState* play) { } -void func_80B46BC0(EnInvadepoh* this, GlobalContext* globalCtx) { +void func_80B46BC0(EnInvadepoh* this, PlayState* play) { s32 pad; s32 invadepohType = this->actor.params & 7; - Collider_DestroyCylinder(globalCtx, &this->collider); + Collider_DestroyCylinder(play, &this->collider); D_80B50320[invadepohType] = 0; } -void func_80B46C08(EnInvadepoh* this, GlobalContext* globalCtx) { +void func_80B46C08(EnInvadepoh* this, PlayState* play) { if (this->actor.parent != NULL) { this->actor.parent->child = NULL; } @@ -1852,46 +1851,46 @@ void func_80B46C08(EnInvadepoh* this, GlobalContext* globalCtx) { } } -void func_80B46C34(EnInvadepoh* this, GlobalContext* globalCtx) { +void func_80B46C34(EnInvadepoh* this, PlayState* play) { if (this->actor.parent != NULL) { this->actor.parent->child = NULL; } } -void func_80B46C50(EnInvadepoh* this, GlobalContext* globalCtx) { - Collider_DestroyCylinder(globalCtx, &this->collider); +void func_80B46C50(EnInvadepoh* this, PlayState* play) { + Collider_DestroyCylinder(play, &this->collider); } -void func_80B46C7C(EnInvadepoh* this, GlobalContext* globalCtx) { +void func_80B46C7C(EnInvadepoh* this, PlayState* play) { D_80B503F0 = NULL; } -void func_80B46C94(EnInvadepoh* this, GlobalContext* globalCtx) { - Collider_DestroyCylinder(globalCtx, &this->collider); +void func_80B46C94(EnInvadepoh* this, PlayState* play) { + Collider_DestroyCylinder(play, &this->collider); } -void func_80B46CC0(EnInvadepoh* this, GlobalContext* globalCtx) { - Collider_DestroyCylinder(globalCtx, &this->collider); +void func_80B46CC0(EnInvadepoh* this, PlayState* play) { + Collider_DestroyCylinder(play, &this->collider); D_80B503F8 = NULL; } -void func_80B46CF4(EnInvadepoh* this, GlobalContext* globalCtx) { - Collider_DestroyCylinder(globalCtx, &this->collider); +void func_80B46CF4(EnInvadepoh* this, PlayState* play) { + Collider_DestroyCylinder(play, &this->collider); D_80B503F4 = NULL; } -void func_80B46D28(EnInvadepoh* this, GlobalContext* globalCtx) { - Collider_DestroyCylinder(globalCtx, &this->collider); +void func_80B46D28(EnInvadepoh* this, PlayState* play) { + Collider_DestroyCylinder(play, &this->collider); if (!this) {} // required to match if (this->actor.child != NULL) { this->actor.child->parent = NULL; } } -void EnInvadepoh_Destroy(Actor* thisx, GlobalContext* globalCtx) { +void EnInvadepoh_Destroy(Actor* thisx, PlayState* play) { EnInvadepoh* this = THIS; - D_80B4ECE8[INVADEPOH_TYPE(this)](this, globalCtx); + D_80B4ECE8[INVADEPOH_TYPE(&this->actor)](this, play); } void func_80B46DA8(EnInvadepoh* this) { @@ -1899,10 +1898,10 @@ void func_80B46DA8(EnInvadepoh* this) { this->actionFunc = func_80B46DC8; } -void func_80B46DC8(EnInvadepoh* this, GlobalContext* globalCtx) { +void func_80B46DC8(EnInvadepoh* this, PlayState* play) { if ((gSaveContext.save.time < CLOCK_TIME(6, 0)) && (gSaveContext.save.time >= CLOCK_TIME(2, 30))) { - func_80B454BC(this, globalCtx); - func_80B452EC(this, globalCtx); + func_80B454BC(this, play); + func_80B452EC(this, play); func_80B46E20(this); } } @@ -1913,7 +1912,7 @@ void func_80B46E20(EnInvadepoh* this) { this->actionFunc = func_80B46E44; } -void func_80B46E44(EnInvadepoh* this, GlobalContext* globalCtx) { +void func_80B46E44(EnInvadepoh* this, PlayState* play) { if (this->actionTimer > 0) { this->actionTimer--; } else if (ActorCutscene_GetCanPlayNext(D_80B50404[0])) { @@ -1930,7 +1929,7 @@ void func_80B46EC0(EnInvadepoh* this) { this->actionFunc = func_80B46EE8; } -void func_80B46EE8(EnInvadepoh* this, GlobalContext* globalCtx) { +void func_80B46EE8(EnInvadepoh* this, PlayState* play) { s32 i; for (i = 0; i < 8; i++) { @@ -1952,7 +1951,7 @@ void func_80B46F88(EnInvadepoh* this) { this->actionFunc = func_80B46FA8; } -void func_80B46FA8(EnInvadepoh* this, GlobalContext* globalCtx) { +void func_80B46FA8(EnInvadepoh* this, PlayState* play) { s32 i; if ((gSaveContext.save.time < CLOCK_TIME(6, 0)) && (gSaveContext.save.time >= CLOCK_TIME(5, 15))) { @@ -1974,7 +1973,7 @@ void func_80B47064(EnInvadepoh* this) { this->actionFunc = func_80B47084; } -void func_80B47084(EnInvadepoh* this, GlobalContext* globalCtx) { +void func_80B47084(EnInvadepoh* this, PlayState* play) { if (ActorCutscene_GetCanPlayNext(D_80B50404[1])) { ActorCutscene_StartAndSetUnkLinkFields(D_80B50404[1], &this->actor); func_80B470E0(this); @@ -1989,17 +1988,17 @@ void func_80B470E0(EnInvadepoh* this) { this->actionFunc = func_80B47108; } -void func_80B47108(EnInvadepoh* this, GlobalContext* globalCtx) { +void func_80B47108(EnInvadepoh* this, PlayState* play) { if (this->actionTimer == 100) { func_801A3098(NA_BGM_CLEAR_EVENT); } this->actionTimer--; if (this->actionTimer <= 0) { - globalCtx->nextEntranceIndex = 0x6460; + play->nextEntrance = ENTRANCE(ROMANI_RANCH, 6); gSaveContext.nextCutsceneIndex = 0; - globalCtx->sceneLoadFlag = 0x14; - globalCtx->unk_1887F = 0x49; - gSaveContext.nextTransition = 0x48; + play->transitionTrigger = TRANS_TRIGGER_START; + play->transitionType = TRANS_TYPE_73; + gSaveContext.nextTransitionType = TRANS_TYPE_72; D_801BDAA0 = 1; D_801BDA9C = 0; func_80B47248(this); @@ -2011,13 +2010,13 @@ void func_80B471C0(EnInvadepoh* this) { this->actionFunc = func_80B471E0; } -void func_80B471E0(EnInvadepoh* this, GlobalContext* globalCtx) { +void func_80B471E0(EnInvadepoh* this, PlayState* play) { if (D_80B4E998) { - globalCtx->nextEntranceIndex = 0x6470; + play->nextEntrance = ENTRANCE(ROMANI_RANCH, 7); gSaveContext.nextCutsceneIndex = 0; - globalCtx->sceneLoadFlag = 0x14; - globalCtx->unk_1887F = 0x48; - gSaveContext.nextTransition = 0x48; + play->transitionTrigger = TRANS_TRIGGER_START; + play->transitionType = TRANS_TYPE_72; + gSaveContext.nextTransitionType = TRANS_TYPE_72; func_80B47248(this); } } @@ -2027,7 +2026,7 @@ void func_80B47248(EnInvadepoh* this) { this->actionFunc = func_80B47268; } -void func_80B47268(EnInvadepoh* this, GlobalContext* globalCtx) { +void func_80B47268(EnInvadepoh* this, PlayState* play) { } void func_80B47278(EnInvadepoh* this) { @@ -2035,12 +2034,12 @@ void func_80B47278(EnInvadepoh* this) { this->actionFunc = func_80B47298; } -void func_80B47298(EnInvadepoh* this, GlobalContext* globalCtx) { - globalCtx->nextEntranceIndex = 0x6400; +void func_80B47298(EnInvadepoh* this, PlayState* play) { + play->nextEntrance = ENTRANCE(ROMANI_RANCH, 0); gSaveContext.nextCutsceneIndex = 0xFFF3; - globalCtx->sceneLoadFlag = 0x14; - globalCtx->unk_1887F = 0x48; - gSaveContext.nextTransition = 0x48; + play->transitionTrigger = TRANS_TRIGGER_START; + play->transitionType = TRANS_TYPE_72; + gSaveContext.nextTransitionType = TRANS_TYPE_72; gSaveContext.save.weekEventReg[89] |= 0x10; func_80B47304(this); } @@ -2050,13 +2049,13 @@ void func_80B47304(EnInvadepoh* this) { this->actionFunc = func_80B47324; } -void func_80B47324(EnInvadepoh* this, GlobalContext* globalCtx) { +void func_80B47324(EnInvadepoh* this, PlayState* play) { } -void EnInvadepoh_Update(Actor* thisx, GlobalContext* globalCtx) { +void EnInvadepoh_Update(Actor* thisx, PlayState* play) { EnInvadepoh* this = THIS; - this->actionFunc(this, globalCtx); + this->actionFunc(this, play); if (func_80B461DC()) { this->actor.draw = func_80B4D9B4; } else { @@ -2077,9 +2076,9 @@ void func_80B47380(EnInvadepoh* this) { this->actionFunc = func_80B473E4; } -void func_80B473E4(EnInvadepoh* this, GlobalContext* globalCtx) { +void func_80B473E4(EnInvadepoh* this, PlayState* play) { func_80B442E4(this); - func_80B447C0(this, globalCtx); + func_80B447C0(this, play); func_80B43DD4(this, 800, 0); if (D_80B50340[this->actor.params & 7] & 1) { Actor_SetScale(&this->actor, 0.01f); @@ -2102,9 +2101,9 @@ void func_80B47478(EnInvadepoh* this) { this->actionFunc = func_80B474DC; } -void func_80B474DC(EnInvadepoh* this, GlobalContext* globalCtx) { +void func_80B474DC(EnInvadepoh* this, PlayState* play) { func_80B442E4(this); - func_80B447C0(this, globalCtx); + func_80B447C0(this, play); func_80B43DD4(this, 800, 0); if (this->clockTime > 0.0f) { Actor_SetScale(&this->actor, 0.01f); @@ -2115,7 +2114,7 @@ void func_80B474DC(EnInvadepoh* this, GlobalContext* globalCtx) { } void func_80B47568(EnInvadepoh* this) { - Animation_MorphToLoop(&this->skelAnime, &object_uch_Anim_001D80, -6.0f); + Animation_MorphToLoop(&this->skelAnime, &gAlienFloatAnim, -6.0f); this->collider.base.atFlags &= ~AT_ON; this->collider.base.acFlags &= ~AC_ON; this->collider.base.ocFlags1 &= ~OC1_ON; @@ -2128,9 +2127,9 @@ void func_80B47568(EnInvadepoh* this) { this->actionFunc = func_80B47600; } -void func_80B47600(EnInvadepoh* this, GlobalContext* globalCtx) { +void func_80B47600(EnInvadepoh* this, PlayState* play) { func_80B442E4(this); - func_80B447C0(this, globalCtx); + func_80B447C0(this, play); func_80B43DD4(this, 800, 0); func_800B9010(&this->actor, NA_SE_EN_FOLLOWERS_BEAM_PRE - SFX_FLAG); if (this->clockTime >= 0.9999f) { @@ -2157,8 +2156,8 @@ void func_80B47600(EnInvadepoh* this, GlobalContext* globalCtx) { } void func_80B4770C(EnInvadepoh* this) { - if (this->skelAnime.animation != &object_uch_Anim_001D80) { - Animation_MorphToLoop(&this->skelAnime, &object_uch_Anim_001D80, -6.0f); + if (this->skelAnime.animation != &gAlienFloatAnim) { + Animation_MorphToLoop(&this->skelAnime, &gAlienFloatAnim, -6.0f); } this->collider.base.atFlags |= AT_ON; this->collider.base.acFlags |= AC_ON; @@ -2172,9 +2171,9 @@ void func_80B4770C(EnInvadepoh* this) { this->actionFunc = func_80B477B4; } -void func_80B477B4(EnInvadepoh* this, GlobalContext* globalCtx) { +void func_80B477B4(EnInvadepoh* this, PlayState* play) { func_80B442E4(this); - func_80B447C0(this, globalCtx); + func_80B447C0(this, play); func_80B43DD4(this, 800, 0); func_800B9010(&this->actor, NA_SE_EN_FOLLOWERS_BEAM_PRE - SFX_FLAG); if (this->clockTime >= 0.9999f) { @@ -2186,7 +2185,7 @@ void func_80B47830(EnInvadepoh* this) { this->collider.base.atFlags &= ~AT_ON; this->collider.base.acFlags &= ~AC_ON; this->collider.base.ocFlags1 |= OC1_ON; - Animation_PlayLoop(&this->skelAnime, &object_uch_Anim_0006C8); + Animation_PlayLoop(&this->skelAnime, &gAlienJerkingAnim); Actor_SetColorFilter(&this->actor, 0x4000, 255, 0, 16); this->alienAlpha = 255; this->actor.draw = func_80B4DB14; @@ -2199,8 +2198,8 @@ void func_80B47830(EnInvadepoh* this) { this->actionFunc = func_80B478F4; } -void func_80B478F4(EnInvadepoh* this, GlobalContext* globalCtx) { - func_80B44A90(this, globalCtx); +void func_80B478F4(EnInvadepoh* this, PlayState* play) { + func_80B44A90(this, play); this->actionTimer--; if (this->actionTimer <= 0) { func_80B47938(this); @@ -2211,7 +2210,7 @@ void func_80B47938(EnInvadepoh* this) { this->collider.base.atFlags &= ~AT_ON; this->collider.base.acFlags &= ~AC_ON; this->collider.base.ocFlags1 &= ~OC1_ON; - Animation_PlayLoop(&this->skelAnime, &object_uch_Anim_000608); + Animation_PlayLoop(&this->skelAnime, &gAlienDeathAnim); this->actor.flags &= ~ACTOR_FLAG_1; this->actionTimer = 10; this->alienAlpha = 255; @@ -2223,7 +2222,7 @@ void func_80B47938(EnInvadepoh* this) { this->actionFunc = func_80B479E8; } -void func_80B479E8(EnInvadepoh* this, GlobalContext* globalCtx) { +void func_80B479E8(EnInvadepoh* this, PlayState* play) { s16 unk2F2; u32 index; @@ -2257,37 +2256,37 @@ void func_80B479E8(EnInvadepoh* this, GlobalContext* globalCtx) { this->counter++; if (this->actionTimer == 8) { - Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_CLEAR_TAG, this->actor.world.pos.x, - this->actor.world.pos.y - 10.0f, this->actor.world.pos.z, 0, 0, 3, CLEAR_TAG_SMOKE); + Actor_Spawn(&play->actorCtx, play, ACTOR_EN_CLEAR_TAG, this->actor.world.pos.x, this->actor.world.pos.y - 10.0f, + this->actor.world.pos.z, 0, 0, 3, CLEAR_TAG_SMOKE); } if (this->actionTimer == 8) { - Enemy_StartFinishingBlow(globalCtx, &this->actor); + Enemy_StartFinishingBlow(play, &this->actor); } this->actionTimer--; if (this->actionTimer <= 0) { func_80B43AF0(this->actor.params & 7); func_80B43AB0(); - Item_DropCollectible(globalCtx, &this->actor.world.pos, ITEM00_ARROWS_30); + Item_DropCollectible(play, &this->actor.world.pos, ITEM00_ARROWS_30); func_80B47478(this); } } -void func_80B47BAC(Actor* thisx, GlobalContext* globalCtx) { +void func_80B47BAC(Actor* thisx, PlayState* play) { EnInvadepoh* this = THIS; - if (Object_IsLoaded(&globalCtx->objectCtx, this->bankIndex)) { + if (Object_IsLoaded(&play->objectCtx, this->bankIndex)) { this->actor.objBankIndex = this->bankIndex; - Actor_SetObjectDependency(globalCtx, &this->actor); + Actor_SetObjectDependency(play, &this->actor); func_80B45080(); this->actor.update = func_80B47D30; - SkelAnime_InitFlex(globalCtx, &this->skelAnime, &object_uch_Skel_004E50, &object_uch_Anim_001D80, - this->jointTable, this->morphTable, 14); + SkelAnime_InitFlex(play, &this->skelAnime, &gAlienSkel, &gAlienFloatAnim, this->jointTable, this->morphTable, + ALIEN_LIMB_MAX); this->skelAnime.curFrame = (this->actor.params & 7) * this->skelAnime.endFrame * 0.125f; - func_80B444BC(this, globalCtx); + func_80B444BC(this, play); func_80B442E4(this); - func_80B447C0(this, globalCtx); + func_80B447C0(this, play); func_80B43F0C(this); func_80B4516C(this); if (D_80B4E940 == 1 || gSaveContext.save.time < CLOCK_TIME(2, 31)) { @@ -2304,7 +2303,7 @@ void func_80B47BAC(Actor* thisx, GlobalContext* globalCtx) { } } -void func_80B47D30(Actor* thisx, GlobalContext* globalCtx) { +void func_80B47D30(Actor* thisx, PlayState* play) { EnInvadepoh* this = THIS; s32 pad; @@ -2327,51 +2326,50 @@ void func_80B47D30(Actor* thisx, GlobalContext* globalCtx) { thisx->gravity = 0.0f; thisx->velocity.y = acAttached->velocity.y * 0.5f; thisx->velocity.y = CLAMP(thisx->velocity.y, -30.0f, 30.0f); - SoundSource_PlaySfxAtFixedWorldPos(globalCtx, &thisx->world.pos, 50, NA_SE_EN_INVADER_DEAD); + SoundSource_PlaySfxAtFixedWorldPos(play, &thisx->world.pos, 50, NA_SE_EN_INVADER_DEAD); func_80B47830(this); } - this->actionFunc(this, globalCtx); + this->actionFunc(this, play); if (thisx->draw != NULL) { this->animPlayFlag = SkelAnime_Update(&this->skelAnime); } Collider_UpdateCylinder(&this->actor, &this->collider); if (this->collider.base.atFlags & AT_ON) { - CollisionCheck_SetAT(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + CollisionCheck_SetAT(play, &play->colChkCtx, &this->collider.base); } else { this->collider.base.atFlags &= ~AT_HIT; } if (this->collider.base.acFlags & AC_ON) { - CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + CollisionCheck_SetAC(play, &play->colChkCtx, &this->collider.base); } else { this->collider.base.acFlags &= ~AC_HIT; } if (this->collider.base.ocFlags1 & OC1_ON) { - CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + CollisionCheck_SetOC(play, &play->colChkCtx, &this->collider.base); } else { this->collider.base.ocFlags1 &= ~OC1_HIT; } } -void func_80B47FA8(Actor* thisx, GlobalContext* globalCtx) { +void func_80B47FA8(Actor* thisx, PlayState* play) { EnInvadepoh* this = THIS; s32 pad; - if (Object_IsLoaded(&globalCtx->objectCtx, this->bankIndex)) { + if (Object_IsLoaded(&play->objectCtx, this->bankIndex)) { this->actor.objBankIndex = this->bankIndex; - Actor_SetObjectDependency(globalCtx, thisx); + Actor_SetObjectDependency(play, thisx); this->actor.update = func_80B48060; this->actor.draw = func_80B4E158; - SkelAnime_InitFlex(globalCtx, &this->skelAnime, &gCowSkel, NULL, this->jointTable, this->morphTable, - COW_LIMB_MAX); + SkelAnime_InitFlex(play, &this->skelAnime, &gCowSkel, NULL, this->jointTable, this->morphTable, COW_LIMB_MAX); Animation_PlayLoop(&this->skelAnime, &gCowMooAnim); } } -void func_80B48060(Actor* thisx, GlobalContext* globalCtx) { +void func_80B48060(Actor* thisx, PlayState* play) { EnInvadepoh* this = THIS; s32 pad; s32 temp; @@ -2387,35 +2385,35 @@ 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(); } } -void func_80B481C4(Actor* thisx, GlobalContext* globalCtx) { +void func_80B481C4(Actor* thisx, PlayState* play) { EnInvadepoh* this = THIS; s32 pad; - if (Object_IsLoaded(&globalCtx->objectCtx, this->bankIndex)) { + if (Object_IsLoaded(&play->objectCtx, this->bankIndex)) { this->actor.objBankIndex = this->bankIndex; - Actor_SetObjectDependency(globalCtx, &this->actor); + Actor_SetObjectDependency(play, &this->actor); this->actor.update = func_80B4827C; this->actor.draw = func_80B4E1B0; - SkelAnime_InitFlex(globalCtx, &this->skelAnime, &gCowTailSkel, NULL, this->jointTable, this->morphTable, + SkelAnime_InitFlex(play, &this->skelAnime, &gCowTailSkel, NULL, this->jointTable, this->morphTable, COW_TAIL_LIMB_MAX); Animation_PlayLoop(&this->skelAnime, &gCowTailSwishAnim); } } -void func_80B4827C(Actor* thisx, GlobalContext* globalCtx) { +void func_80B4827C(Actor* thisx, PlayState* play) { EnInvadepoh* this = THIS; if (D_80B503F0 == NULL || this->actor.parent == NULL) { @@ -2428,15 +2426,15 @@ void func_80B4827C(Actor* thisx, GlobalContext* globalCtx) { void func_80B482D4(EnInvadepoh* this) { this->actionTimer = 40; - Animation_MorphToLoop(&this->skelAnime, &object_ma1_Anim_002A8C, -10.0f); + Animation_MorphToLoop(&this->skelAnime, &gRomaniLookAroundAnim, -10.0f); this->actor.draw = NULL; this->actionFunc = func_80B48324; } -void func_80B48324(EnInvadepoh* this, GlobalContext* globalCtx) { +void func_80B48324(EnInvadepoh* this, PlayState* play) { this->actionTimer--; if (this->actionTimer <= 0) { - EnInvadepoh_SetTextID(this, globalCtx, 0x332F); + EnInvadepoh_SetTextID(this, play, 0x332F); this->actor.draw = func_80B4E324; func_80B48374(this); } @@ -2444,12 +2442,12 @@ void func_80B48324(EnInvadepoh* this, GlobalContext* globalCtx) { void func_80B48374(EnInvadepoh* this) { this->actionTimer = 60; - Animation_MorphToLoop(&this->skelAnime, &object_ma1_Anim_002A8C, -10.0f); + Animation_MorphToLoop(&this->skelAnime, &gRomaniLookAroundAnim, -10.0f); this->actor.draw = func_80B4E324; this->actionFunc = func_80B483CC; } -void func_80B483CC(EnInvadepoh* this, GlobalContext* globalCtx) { +void func_80B483CC(EnInvadepoh* this, PlayState* play) { if (this->actionTimer == 20) { f32 unkFloat = 0.1f; @@ -2476,12 +2474,12 @@ void func_80B4843C(EnInvadepoh* this) { this->behaviorInfo.unk44 = 0.1f; this->behaviorInfo.unk48 = 2000; this->actionTimer = 50; - Animation_Change(&this->skelAnime, &object_ma1_Anim_007328, 2.0f, 0.0f, 0.0f, 0, -5.0f); + Animation_Change(&this->skelAnime, &gRomaniRunAnim, 2.0f, 0.0f, 0.0f, ANIMMODE_LOOP, -5.0f); this->actor.draw = func_80B4E324; this->actionFunc = func_80B484EC; } -void func_80B484EC(EnInvadepoh* this, GlobalContext* globalCtx) { +void func_80B484EC(EnInvadepoh* this, PlayState* play) { if (this->actionTimer == 40) { this->behaviorInfo.unk26.y = 7000; } else if (this->actionTimer == 30) { @@ -2506,32 +2504,32 @@ void func_80B48588(EnInvadepoh* this) { this->behaviorInfo.unk42 = 0; this->behaviorInfo.unk44 = 0.28f; this->behaviorInfo.unk48 = 7000; - Animation_MorphToPlayOnce(&this->skelAnime, &object_ma1_Anim_009E58, -10.0f); + Animation_MorphToPlayOnce(&this->skelAnime, &gRomaniIdleAnim, -10.0f); this->actor.draw = func_80B4E324; this->actionFunc = func_80B48610; } -void func_80B48610(EnInvadepoh* this, GlobalContext* globalCtx) { +void func_80B48610(EnInvadepoh* this, PlayState* play) { } -void func_80B48620(Actor* thisx, GlobalContext* globalCtx) { +void func_80B48620(Actor* thisx, PlayState* play) { s32 pad[2]; EnInvadepoh* this = THIS; - if (Object_IsLoaded(&globalCtx->objectCtx, this->bankIndex)) { + if (Object_IsLoaded(&play->objectCtx, this->bankIndex)) { this->actor.objBankIndex = this->bankIndex; - Actor_SetObjectDependency(globalCtx, &this->actor); + Actor_SetObjectDependency(play, &this->actor); func_80B44F58(); this->actor.update = func_80B4873C; - SkelAnime_InitFlex(globalCtx, &this->skelAnime, &object_ma1_Skel_013928, &object_ma1_Anim_009E58, - this->jointTable, this->morphTable, 23); + SkelAnime_InitFlex(play, &this->skelAnime, &gRomaniSkel, &gRomaniIdleAnim, this->jointTable, this->morphTable, + ROMANI_LIMB_MAX); func_80B45C04(&this->behaviorInfo, D_80B4EA90, 6, D_80B4EB00, 2, &gZeroVec3s, 5000, 0.05f, 0.3f, 0.12f); - Animation_PlayLoop(&this->skelAnime, &object_ma1_Anim_009E58); + Animation_PlayLoop(&this->skelAnime, &gRomaniIdleAnim); func_80B482D4(this); } } -void func_80B4873C(Actor* thisx, GlobalContext* globalCtx) { +void func_80B4873C(Actor* thisx, PlayState* play) { EnInvadepoh* this = THIS; s32 pad; AlienBehaviorInfo* substruct = &this->behaviorInfo; @@ -2540,7 +2538,7 @@ void func_80B4873C(Actor* thisx, GlobalContext* globalCtx) { Actor_MarkForDeath(&this->actor); return; } - this->actionFunc(this, globalCtx); + this->actionFunc(this, play); SkelAnime_Update(&this->skelAnime); func_80B45CE0(substruct); if (substruct->unk40 != 0) { @@ -2559,15 +2557,15 @@ void func_80B487B4(EnInvadepoh* this) { substruct->unk26.z = 0; substruct->unk30 = 0.1f; substruct->unk2C = 800; - Animation_MorphToLoop(&this->skelAnime, &object_ma1_Anim_014088, -10.0f); + Animation_MorphToLoop(&this->skelAnime, &gRomaniWalkAnim, -10.0f); this->actionFunc = func_80B48848; } -void func_80B48848(EnInvadepoh* this, GlobalContext* globalCtx) { +void func_80B48848(EnInvadepoh* this, PlayState* play) { s32 pad; Math_StepToF(&this->actor.speedXZ, 1.6f, 0.1f); - if (func_80B44B84(this, globalCtx, this->actor.speedXZ, 50.0f)) { + if (func_80B44B84(this, play, this->actor.speedXZ, 50.0f)) { func_80B44514(this); this->behaviorInfo.unk4C = 0xC8; this->actor.speedXZ *= 0.25f; @@ -2619,11 +2617,11 @@ void func_80B48948(EnInvadepoh* this) { substruct->unk2C = 1000; } - Animation_MorphToLoop(&this->skelAnime, &object_ma1_Anim_009E58, -10.0f); + Animation_MorphToLoop(&this->skelAnime, &gRomaniIdleAnim, -10.0f); this->actionFunc = func_80B48AD4; } -void func_80B48AD4(EnInvadepoh* this, GlobalContext* globalCtx) { +void func_80B48AD4(EnInvadepoh* this, PlayState* play) { AlienBehaviorInfo* substruct = &this->behaviorInfo; Player* player; s16 new_var3; @@ -2631,15 +2629,15 @@ void func_80B48AD4(EnInvadepoh* this, GlobalContext* globalCtx) { s32 temp_v1_3; Math_StepToF(&this->actor.speedXZ, 0.0f, 0.2f); - if (func_80B44B84(this, globalCtx, this->actor.speedXZ, 50.0f)) { + if (func_80B44B84(this, play, this->actor.speedXZ, 50.0f)) { func_80B44514(this); } if (this->rand == 0) { s32 requiredScopeTemp; - if ((this->actor.xzDistToPlayer < 350.0f) && ((globalCtx->gameplayFrames & 0x60) != 0)) { - player = GET_PLAYER(globalCtx); + if ((this->actor.xzDistToPlayer < 350.0f) && ((play->gameplayFrames & 0x60) != 0)) { + player = GET_PLAYER(play); temp_v1 = Math_Vec3f_Pitch(&this->actor.focus.pos, &player->actor.focus.pos) * 0.85f; temp_v1 -= this->actor.shape.rot.x; substruct->unk26.x = CLAMP(temp_v1, -2500, 2500); @@ -2655,7 +2653,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) { @@ -2690,16 +2688,16 @@ void func_80B48DE4(EnInvadepoh* this) { AlienBehaviorInfo* substruct = &this->behaviorInfo; this->actor.speedXZ = 0.0f; - Animation_MorphToLoop(&this->skelAnime, &object_ma1_Anim_009E58, -10.0f); + Animation_MorphToLoop(&this->skelAnime, &gRomaniIdleAnim, -10.0f); this->behaviorInfo.unk4C = 0; substruct->unk30 = 0.05f; substruct->unk2C = 1200; this->actionFunc = func_80B48E4C; } -void func_80B48E4C(EnInvadepoh* this, GlobalContext* globalCtx) { +void func_80B48E4C(EnInvadepoh* this, PlayState* play) { AlienBehaviorInfo* substruct = &this->behaviorInfo; - Player* player = GET_PLAYER(globalCtx); + Player* player = GET_PLAYER(play); s16 temp_v1; s16 diff; @@ -2712,51 +2710,51 @@ void func_80B48E4C(EnInvadepoh* this, GlobalContext* globalCtx) { diff = BINANG_SUB(this->actor.yawTowardsPlayer, this->actor.shape.rot.y); temp_v1 = diff * 0.7f; substruct->unk26.y = CLAMP(temp_v1, -0x1F40, 0x1F40); - if (Actor_TextboxIsClosing(&this->actor, globalCtx)) { + if (Actor_TextboxIsClosing(&this->actor, play)) { func_80B48948(this); } } -void func_80B48FB0(Actor* thisx, GlobalContext* globalCtx) { +void func_80B48FB0(Actor* thisx, PlayState* play) { EnInvadepoh* this = THIS; - if (Object_IsLoaded(&globalCtx->objectCtx, this->bankIndex)) { + if (Object_IsLoaded(&play->objectCtx, this->bankIndex)) { this->actor.objBankIndex = this->bankIndex; - Actor_SetObjectDependency(globalCtx, &this->actor); + Actor_SetObjectDependency(play, &this->actor); func_80B44F58(); this->actor.update = func_80B490F0; this->actor.draw = func_80B4E324; this->actor.textId = 0x3330; - SkelAnime_InitFlex(globalCtx, &this->skelAnime, &object_ma1_Skel_013928, &object_ma1_Anim_009E58, - this->jointTable, this->morphTable, 23); + SkelAnime_InitFlex(play, &this->skelAnime, &gRomaniSkel, &gRomaniIdleAnim, this->jointTable, this->morphTable, + ROMANI_LIMB_MAX); func_80B45C04(&this->behaviorInfo, D_80B4EA90, 6, D_80B4EB00, 2, &gZeroVec3s, 100, 0.03, 0.3, 0.03); - func_80B444F4(this, globalCtx); + func_80B444F4(this, play); EnInvadepoh_SetPathPointToWorldPos(this, 0); - func_800B4AEC(globalCtx, &this->actor, 50.0f); + func_800B4AEC(play, &this->actor, 50.0f); func_80B4516C(this); func_80B487B4(this); } } -void func_80B490F0(Actor* thisx, GlobalContext* globalCtx) { +void func_80B490F0(Actor* thisx, PlayState* play) { s32 pad; EnInvadepoh* this = THIS; s32 sp2C = CHECK_FLAG_ALL(this->actor.flags, ACTOR_FLAG_40); - s32 isTalking = Actor_ProcessTalkRequest(&this->actor, &globalCtx->state); + s32 isTalking = Actor_ProcessTalkRequest(&this->actor, &play->state); if (isTalking) { - func_80151BB4(globalCtx, 5); + func_80151BB4(play, 5); func_80B48DE4(this); } - this->actionFunc(this, globalCtx); + this->actionFunc(this, play); if (sp2C) { SkelAnime_Update(&this->skelAnime); func_80B45CE0(&this->behaviorInfo); if ((this->actionFunc != func_80B48E4C) && !isTalking && this->actor.isTargeted) { - func_800B8614(&this->actor, globalCtx, 100.0f); + func_800B8614(&this->actor, play, 100.0f); } Collider_UpdateCylinder(&this->actor, &this->collider); - CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + CollisionCheck_SetOC(play, &play->colChkCtx, &this->collider.base); } } @@ -2769,7 +2767,7 @@ void func_80B491EC(EnInvadepoh* this) { this->actionFunc = func_80B49228; } -void func_80B49228(EnInvadepoh* this, GlobalContext* globalCtx) { +void func_80B49228(EnInvadepoh* this, PlayState* play) { s32 pad; f32 temp_f0; @@ -2779,7 +2777,7 @@ void func_80B49228(EnInvadepoh* this, GlobalContext* globalCtx) { fabsf(this->actor.velocity.y), 1.0f); func_800B9010(&this->actor, NA_SE_EV_UFO_APPEAR - SFX_FLAG); if (fabsf(temp_f0) < 1.0f) { - func_80B45EC8(this, globalCtx, 50); + func_80B45EC8(this, play, 50); func_80B492FC(this); } } @@ -2793,7 +2791,7 @@ void func_80B492FC(EnInvadepoh* this) { this->actionFunc = func_80B4934C; } -void func_80B4934C(EnInvadepoh* this, GlobalContext* globalCtx) { +void func_80B4934C(EnInvadepoh* this, PlayState* play) { f32 temp = this->actor.home.pos.y + D_80B4E934.y + 300.0f; if (this->actor.world.pos.y < temp) { @@ -2821,7 +2819,7 @@ void func_80B49404(EnInvadepoh* this) { this->actionFunc = func_80B49454; } -void func_80B49454(EnInvadepoh* this, GlobalContext* globalCtx) { +void func_80B49454(EnInvadepoh* this, PlayState* play) { s32 pad; Vec3f sp30; s32 pad2; @@ -2833,7 +2831,7 @@ void func_80B49454(EnInvadepoh* this, GlobalContext* globalCtx) { this->unk3AC++; this->unk3AC = CLAMP_MAX(this->unk3AC, 4); this->actor.gravity = 33.0f; - func_80B45EC8(this, globalCtx, 20); + func_80B45EC8(this, play, 20); } Math_Vec3f_Sum(&D_80B4EDD0[this->unk3AC], &this->actor.home.pos, &sp30); @@ -2870,7 +2868,7 @@ void func_80B49628(EnInvadepoh* this) { this->actionFunc = func_80B49670; } -void func_80B49670(EnInvadepoh* this, GlobalContext* globalCtx) { +void func_80B49670(EnInvadepoh* this, PlayState* play) { s32 pad; Vec3f sp30; @@ -2878,7 +2876,7 @@ void func_80B49670(EnInvadepoh* this, GlobalContext* globalCtx) { sp30.y = this->actor.home.pos.y + 1500.0f; sp30.z = this->actor.home.pos.z; Math_SmoothStepToS(&this->actor.world.rot.y, Math_Vec3f_Yaw(&this->actor.world.pos, &sp30), 0xA, 0xBB8, 0x64); - if ((globalCtx->gameplayFrames % 64) < 14) { + if ((play->gameplayFrames % 64) < 14) { Math_StepToF(&this->actor.speedXZ, 5.0f, 1.0f); } else { this->actor.speedXZ *= 0.97f; @@ -2904,7 +2902,7 @@ void func_80B497A4(EnInvadepoh* this) { this->actionFunc = func_80B497EC; } -void func_80B497EC(EnInvadepoh* this, GlobalContext* globalCtx) { +void func_80B497EC(EnInvadepoh* this, PlayState* play) { s32 pad; Vec3f sp30; @@ -2936,7 +2934,7 @@ void func_80B49904(EnInvadepoh* this) { this->actionFunc = func_80B4994C; } -void func_80B4994C(EnInvadepoh* this, GlobalContext* globalCtx) { +void func_80B4994C(EnInvadepoh* this, PlayState* play) { Math_StepToF(&this->actor.speedXZ, 150.0f, 4.0f); this->actor.velocity.y *= 0.95f; Actor_MoveWithGravity(&this->actor); @@ -2956,7 +2954,7 @@ void func_80B499BC(EnInvadepoh* this) { this->actionFunc = func_80B49A00; } -void func_80B49A00(EnInvadepoh* this, GlobalContext* globalCtx) { +void func_80B49A00(EnInvadepoh* this, PlayState* play) { s32 pad; Vec3f sp30; @@ -2972,7 +2970,7 @@ void func_80B49A00(EnInvadepoh* this, GlobalContext* globalCtx) { this->actor.gravity = 2.0f; } Actor_MoveWithGravity(&this->actor); - Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 0.0f, 0.0f, 0.0f, 4); + Actor_UpdateBgCheckInfo(play, &this->actor, 0.0f, 0.0f, 0.0f, 4); if (this->actionTimer > 0) { this->actionTimer--; } else { @@ -2980,11 +2978,11 @@ void func_80B49A00(EnInvadepoh* this, GlobalContext* globalCtx) { } } -void func_80B49B1C(Actor* thisx, GlobalContext* globalCtx) { +void func_80B49B1C(Actor* thisx, PlayState* play) { EnInvadepoh* this = THIS; f32 scale; - this->actionFunc(this, globalCtx); + this->actionFunc(this, play); this->scaleAdjAngle += this->unk3AA; Math_StepToF(&this->scaleFactorAdj, this->scaleTarget, this->scaleStep); scale = Math_SinS(this->scaleAdjAngle) * this->scaleFactorAdj + 1.0f; @@ -2997,7 +2995,7 @@ void func_80B49B1C(Actor* thisx, GlobalContext* globalCtx) { void func_80B49BD0(EnInvadepoh* this) { AlienBehaviorInfo* substruct = &this->behaviorInfo; - Animation_MorphToLoop(&this->skelAnime, &object_ma1_Anim_014088, -10.0f); + Animation_MorphToLoop(&this->skelAnime, &gRomaniWalkAnim, -10.0f); substruct->unk26.x = 0; substruct->unk26.y = 0; substruct->unk26.z = 0; @@ -3006,20 +3004,20 @@ void func_80B49BD0(EnInvadepoh* this) { this->actionFunc = func_80B49C38; } -void func_80B49C38(EnInvadepoh* this, GlobalContext* globalCtx) { +void func_80B49C38(EnInvadepoh* this, PlayState* play) { s32 pad; s32 temp_v0_2; func_80B44570(this); - func_80B44C24(this, globalCtx); + func_80B44C24(this, play); func_80B43E6C(this, 6, 2000, 100); if (1) {} if (this->pathIndex == 0 || (this->pathIndex + 1) == this->endPoint) { if (this->unk378 == 0) { - temp_v0_2 = func_800FE620(globalCtx); + temp_v0_2 = func_800FE620(play); if (temp_v0_2 > 0) { temp_v0_2 = (REG(15) * -16.0f / temp_v0_2) - 0.5f; - this->unk378 = func_80B45550(this, globalCtx, SQ(80.0f), temp_v0_2); + this->unk378 = func_80B45550(this, play, SQ(80.0f), temp_v0_2); } } this->actor.flags &= ~(ACTOR_FLAG_1 | ACTOR_FLAG_8); @@ -3041,13 +3039,13 @@ void func_80B49DA0(EnInvadepoh* this) { this->behaviorInfo.unk30 = 0.08f; this->behaviorInfo.unk2C = 2000; this->behaviorInfo.unk4C = 0; - Animation_MorphToLoop(&this->skelAnime, &object_ma1_Anim_009E58, -10.0f); + Animation_MorphToLoop(&this->skelAnime, &gRomaniIdleAnim, -10.0f); this->actionFunc = func_80B49DFC; } -void func_80B49DFC(EnInvadepoh* this, GlobalContext* globalCtx) { +void func_80B49DFC(EnInvadepoh* this, PlayState* play) { AlienBehaviorInfo* substruct = &this->behaviorInfo; - Player* player = GET_PLAYER(globalCtx); + Player* player = GET_PLAYER(play); s16 temp_v1; s16 diff; @@ -3060,7 +3058,7 @@ void func_80B49DFC(EnInvadepoh* this, GlobalContext* globalCtx) { temp_v1 = diff; temp_v1 *= 0.7f; substruct->unk26.y = CLAMP(temp_v1, -0x1F40, 0x1F40); - if (Actor_TextboxIsClosing(&this->actor, globalCtx)) { + if (Actor_TextboxIsClosing(&this->actor, play)) { if (this->actor.textId == 0x332D) { gSaveContext.save.weekEventReg[54] |= 0x10; this->actor.textId = 0x332E; @@ -3069,22 +3067,22 @@ void func_80B49DFC(EnInvadepoh* this, GlobalContext* globalCtx) { } } -void func_80B49F88(Actor* thisx, GlobalContext* globalCtx) { +void func_80B49F88(Actor* thisx, PlayState* play) { s32 pad[2]; EnInvadepoh* this = THIS; s32 sp38; - if (Object_IsLoaded(&globalCtx->objectCtx, this->bankIndex)) { + if (Object_IsLoaded(&play->objectCtx, this->bankIndex)) { sp38 = gSaveContext.save.time; this->actor.objBankIndex = this->bankIndex; - Actor_SetObjectDependency(globalCtx, &this->actor); + Actor_SetObjectDependency(play, &this->actor); func_80B44F58(); - SkelAnime_InitFlex(globalCtx, &this->skelAnime, &object_ma1_Skel_013928, &object_ma1_Anim_014088, - this->jointTable, this->morphTable, 23); + SkelAnime_InitFlex(play, &this->skelAnime, &gRomaniSkel, &gRomaniWalkAnim, this->jointTable, this->morphTable, + ROMANI_LIMB_MAX); func_80B45C04(&this->behaviorInfo, D_80B4EA90, 1, D_80B4EB00, 1, &gZeroVec3s, 100, 0.03, 0.3, 0.03); - func_80B44540(this, globalCtx); + func_80B44540(this, play); func_80B44570(this); - func_80B44C24(this, globalCtx); + func_80B44C24(this, play); func_80B43F0C(this); func_80B4516C(this); if (0x20 & gSaveContext.save.weekEventReg[21]) { @@ -3111,7 +3109,7 @@ void func_80B49F88(Actor* thisx, GlobalContext* globalCtx) { } } -void func_80B4A168(Actor* thisx, GlobalContext* globalCtx) { +void func_80B4A168(Actor* thisx, PlayState* play) { EnInvadepoh* this = THIS; if ((gSaveContext.save.time < CLOCK_TIME(6, 0)) && (gSaveContext.save.time >= CLOCK_TIME(2, 0))) { @@ -3121,32 +3119,32 @@ void func_80B4A168(Actor* thisx, GlobalContext* globalCtx) { } } -void func_80B4A1B8(Actor* thisx, GlobalContext* globalCtx) { +void func_80B4A1B8(Actor* thisx, PlayState* play) { s32 pad; EnInvadepoh* this = THIS; s32 sp2C = CHECK_FLAG_ALL(this->actor.flags, ACTOR_FLAG_40); - s32 isTalking = Actor_ProcessTalkRequest(&this->actor, &globalCtx->state); + s32 isTalking = Actor_ProcessTalkRequest(&this->actor, &play->state); if (isTalking) { - func_80151BB4(globalCtx, 5); + func_80151BB4(play, 5); func_80B49DA0(this); } - this->actionFunc(this, globalCtx); + this->actionFunc(this, play); if (sp2C && this->actor.update != NULL) { SkelAnime_Update(&this->skelAnime); func_80B45CE0(&this->behaviorInfo); if ((this->actionFunc != func_80B49DFC) && !isTalking && this->actor.isTargeted) { - func_800B8614(&this->actor, globalCtx, 350.0f); + func_800B8614(&this->actor, play, 350.0f); } Collider_UpdateCylinder(&this->actor, &this->collider); - CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + CollisionCheck_SetOC(play, &play->colChkCtx, &this->collider.base); } } void func_80B4A2C0(EnInvadepoh* this) { AlienBehaviorInfo* substruct = &this->behaviorInfo; - Animation_MorphToLoop(&this->skelAnime, &object_ma1_Anim_009E58, -10.0f); + Animation_MorphToLoop(&this->skelAnime, &gRomaniIdleAnim, -10.0f); substruct->unk26.x = 0; substruct->unk26.y = 0; substruct->unk26.z = 0; @@ -3158,7 +3156,7 @@ void func_80B4A2C0(EnInvadepoh* this) { this->actionFunc = func_80B4A350; } -void func_80B4A350(EnInvadepoh* this, GlobalContext* globalCtx) { +void func_80B4A350(EnInvadepoh* this, PlayState* play) { s16 temp_v0; s16 temp_v1_2; s16 diff; @@ -3166,7 +3164,7 @@ void func_80B4A350(EnInvadepoh* this, GlobalContext* globalCtx) { s16 sp42; AlienBehaviorInfo* substruct = &this->behaviorInfo; - if ((globalCtx->gameplayFrames % 256) == 0) { + if ((play->gameplayFrames % 256) == 0) { Math_Vec3s_ToVec3f(&sp44, this->pathPoints); sp42 = Math_Vec3f_Yaw(&this->actor.world.pos, &sp44); temp_v0 = Rand_S16Offset(-0x1F40, 0x3E80); @@ -3177,7 +3175,7 @@ void func_80B4A350(EnInvadepoh* this, GlobalContext* globalCtx) { Math_StepToS(&this->behaviorInfo.unk4C, 2000, 40); Math_SmoothStepToS(&this->actor.shape.rot.y, this->unk304, 6, this->behaviorInfo.unk4C, 40); if (this->actor.xzDistToPlayer < 300.0f) { - Player* player = GET_PLAYER(globalCtx); + Player* player = GET_PLAYER(play); temp_v1_2 = Math_Vec3f_Pitch(&this->actor.focus.pos, &player->actor.focus.pos); temp_v1_2 *= 0.85f; @@ -3187,7 +3185,7 @@ void func_80B4A350(EnInvadepoh* this, GlobalContext* globalCtx) { temp_v1_2 = diff; temp_v1_2 *= 0.7f; substruct->unk26.y = CLAMP(temp_v1_2, -0x1F40, 0x1F40); - if ((globalCtx->gameplayFrames % 256) == 0) { + if ((play->gameplayFrames % 256) == 0) { substruct->unk26.z = Rand_S16Offset(-0x5DC, 0xBB8); } } else { @@ -3205,7 +3203,7 @@ void func_80B4A350(EnInvadepoh* this, GlobalContext* globalCtx) { void func_80B4A570(EnInvadepoh* this) { AlienBehaviorInfo* substruct = &this->behaviorInfo; - Animation_MorphToPlayOnce(&this->skelAnime, &object_ma1_Anim_002A8C, -10.0f); + Animation_MorphToPlayOnce(&this->skelAnime, &gRomaniLookAroundAnim, -10.0f); substruct->unk26.x = 0; substruct->unk26.y = 0; substruct->unk26.z = 0; @@ -3215,7 +3213,7 @@ void func_80B4A570(EnInvadepoh* this) { this->actionFunc = func_80B4A5E4; } -void func_80B4A5E4(EnInvadepoh* this, GlobalContext* globalCtx) { +void func_80B4A5E4(EnInvadepoh* this, PlayState* play) { if (this->animPlayFlag) { func_80B4A2C0(this); } @@ -3224,7 +3222,7 @@ void func_80B4A5E4(EnInvadepoh* this, GlobalContext* globalCtx) { void func_80B4A614(EnInvadepoh* this) { AlienBehaviorInfo* substruct = &this->behaviorInfo; - Animation_MorphToLoop(&this->skelAnime, &object_ma1_Anim_014088, 0.0f); + Animation_MorphToLoop(&this->skelAnime, &gRomaniWalkAnim, 0.0f); substruct->unk26.x = 0; substruct->unk26.y = 0; substruct->unk26.z = 0; @@ -3233,11 +3231,11 @@ void func_80B4A614(EnInvadepoh* this) { this->actionFunc = func_80B4A67C; } -void func_80B4A67C(EnInvadepoh* this, GlobalContext* globalCtx) { +void func_80B4A67C(EnInvadepoh* this, PlayState* play) { s32 pad; Math_StepToF(&this->actor.speedXZ, 5.0f, 1.0f); - if (func_80B44B84(this, globalCtx, this->actor.speedXZ, 50.0f)) { + if (func_80B44B84(this, play, this->actor.speedXZ, 50.0f)) { func_80B44640(this); this->behaviorInfo.unk4C = 0x5DC; this->actor.speedXZ *= 0.5f; @@ -3247,7 +3245,7 @@ void func_80B4A67C(EnInvadepoh* this, GlobalContext* globalCtx) { func_80B43E6C(this, 6, this->behaviorInfo.unk4C, 0x32); if (this->pathIndex == 0) { if (this->unk378 == 0) { - this->unk378 = func_80B45550(this, globalCtx, SQ(80.0f), -0xF); + this->unk378 = func_80B45550(this, play, SQ(80.0f), -0xF); } this->actor.flags &= ~(ACTOR_FLAG_1 | ACTOR_FLAG_8); } else { @@ -3267,13 +3265,13 @@ void func_80B4A7C0(EnInvadepoh* this) { this->behaviorInfo.unk30 = 0.08f; this->behaviorInfo.unk2C = 2000; this->behaviorInfo.unk4C = 0; - Animation_MorphToLoop(&this->skelAnime, &object_ma1_Anim_009E58, 0.0f); + Animation_MorphToLoop(&this->skelAnime, &gRomaniIdleAnim, 0.0f); this->actionFunc = func_80B4A81C; } -void func_80B4A81C(EnInvadepoh* this, GlobalContext* globalCtx) { +void func_80B4A81C(EnInvadepoh* this, PlayState* play) { AlienBehaviorInfo* substruct = &this->behaviorInfo; - Player* player = GET_PLAYER(globalCtx); + Player* player = GET_PLAYER(play); s16 temp_v1; s16 diff; @@ -3287,7 +3285,7 @@ void func_80B4A81C(EnInvadepoh* this, GlobalContext* globalCtx) { temp_v1 *= 0.7f; substruct->unk26.y = CLAMP(temp_v1, -0x1F40, 0x1F40); - if (Actor_TextboxIsClosing(&this->actor, globalCtx)) { + if (Actor_TextboxIsClosing(&this->actor, play)) { if (this->actor.textId == 0x332D) { gSaveContext.save.weekEventReg[54] |= 0x10; this->actor.textId = 0x332E; @@ -3300,20 +3298,20 @@ void func_80B4A81C(EnInvadepoh* this, GlobalContext* globalCtx) { } } -void func_80B4A9C8(Actor* thisx, GlobalContext* globalCtx) { +void func_80B4A9C8(Actor* thisx, PlayState* play) { EnInvadepoh* this = THIS; s32 pad[2]; s32 sp38; - if (Object_IsLoaded(&globalCtx->objectCtx, this->bankIndex)) { + if (Object_IsLoaded(&play->objectCtx, this->bankIndex)) { sp38 = gSaveContext.save.time; this->actor.objBankIndex = this->bankIndex; - Actor_SetObjectDependency(globalCtx, &this->actor); + Actor_SetObjectDependency(play, &this->actor); func_80B44F58(); - SkelAnime_InitFlex(globalCtx, &this->skelAnime, &object_ma1_Skel_013928, &object_ma1_Anim_014088, - this->jointTable, this->morphTable, 23); + SkelAnime_InitFlex(play, &this->skelAnime, &gRomaniSkel, &gRomaniWalkAnim, this->jointTable, this->morphTable, + ROMANI_LIMB_MAX); func_80B45C04(&this->behaviorInfo, D_80B4EA90, 1, D_80B4EB00, 1, &gZeroVec3s, 100, 0.03f, 0.3f, 0.03f); - func_80B44620(this, globalCtx); + func_80B44620(this, play); if ((sp38 < CLOCK_TIME(2, 15)) || (sp38 >= CLOCK_TIME(6, 0))) { this->pathIndex = 0; this->actor.update = func_80B4AB8C; @@ -3326,7 +3324,7 @@ void func_80B4A9C8(Actor* thisx, GlobalContext* globalCtx) { EnInvadepoh_SetPathPointToWorldPos(this, this->pathIndex); func_80B43F0C(this); - func_800B4AEC(globalCtx, &this->actor, 50.0f); + func_800B4AEC(play, &this->actor, 50.0f); func_80B4516C(this); if (gSaveContext.save.weekEventReg[21] & 0x20) { if (gSaveContext.save.weekEventReg[54] & 0x10) { @@ -3340,7 +3338,7 @@ void func_80B4A9C8(Actor* thisx, GlobalContext* globalCtx) { } } -void func_80B4AB8C(Actor* thisx, GlobalContext* globalCtx) { +void func_80B4AB8C(Actor* thisx, PlayState* play) { EnInvadepoh* this = THIS; if ((gSaveContext.save.time < CLOCK_TIME(6, 0)) && (gSaveContext.save.time >= CLOCK_TIME(2, 15))) { @@ -3350,25 +3348,25 @@ void func_80B4AB8C(Actor* thisx, GlobalContext* globalCtx) { } } -void func_80B4ABDC(Actor* thisx, GlobalContext* globalCtx) { +void func_80B4ABDC(Actor* thisx, PlayState* play) { s32 pad; EnInvadepoh* this = THIS; s32 sp2C = CHECK_FLAG_ALL(this->actor.flags, ACTOR_FLAG_40); - s32 isTalking = Actor_ProcessTalkRequest(&this->actor, &globalCtx->state); + s32 isTalking = Actor_ProcessTalkRequest(&this->actor, &play->state); if (isTalking) { - func_80151BB4(globalCtx, 5); + func_80151BB4(play, 5); func_80B4A7C0(this); } - this->actionFunc(this, globalCtx); + this->actionFunc(this, play); if (sp2C) { this->animPlayFlag = SkelAnime_Update(&this->skelAnime); func_80B45CE0(&this->behaviorInfo); if ((this->actionFunc != func_80B4A81C) && !isTalking && this->actor.isTargeted) { - func_800B8614(&this->actor, globalCtx, 100.0f); + func_800B8614(&this->actor, play, 100.0f); } Collider_UpdateCylinder(&this->actor, &this->collider); - CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + CollisionCheck_SetOC(play, &play->colChkCtx, &this->collider.base); } } @@ -3376,7 +3374,7 @@ void func_80B4ACDC(EnInvadepoh* this) { this->actionFunc = func_80B4ACF0; } -void func_80B4ACF0(EnInvadepoh* this, GlobalContext* globalCtx) { +void func_80B4ACF0(EnInvadepoh* this, PlayState* play) { if (gSaveContext.save.weekEventReg[22] & 1) { this->actor.draw = func_80B4E324; this->actor.flags |= (ACTOR_FLAG_1 | ACTOR_FLAG_8); @@ -3389,12 +3387,12 @@ void func_80B4AD3C(EnInvadepoh* this) { this->actionFunc = func_80B4AD60; } -void func_80B4AD60(EnInvadepoh* this, GlobalContext* globalCtx) { - if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { - EnInvadepoh_SetTextID(this, globalCtx, 0x3331); +void func_80B4AD60(EnInvadepoh* this, PlayState* play) { + if (Actor_ProcessTalkRequest(&this->actor, &play->state)) { + EnInvadepoh_SetTextID(this, play, 0x3331); func_80B4ADB8(this); } else { - func_800B8614(&this->actor, globalCtx, 2000.0f); + func_800B8614(&this->actor, play, 2000.0f); } } @@ -3402,22 +3400,22 @@ void func_80B4ADB8(EnInvadepoh* this) { this->actionFunc = func_80B4ADCC; } -void func_80B4ADCC(EnInvadepoh* this, GlobalContext* globalCtx) { - if ((Message_GetState(&globalCtx->msgCtx) == 5) && Message_ShouldAdvance(globalCtx)) { +void func_80B4ADCC(EnInvadepoh* this, PlayState* play) { + if ((Message_GetState(&play->msgCtx) == TEXT_STATE_5) && Message_ShouldAdvance(play)) { if (this->textId == 0x3331) { if (gSaveContext.save.weekEventReg[22] & 2) { - EnInvadepoh_SetTextID(this, globalCtx, 0x3334); - func_80151BB4(globalCtx, 0x1D); - func_80151BB4(globalCtx, 5); + EnInvadepoh_SetTextID(this, play, 0x3334); + func_80151BB4(play, 0x1D); + func_80151BB4(play, 5); return; } - EnInvadepoh_SetTextID(this, globalCtx, 0x3333); + EnInvadepoh_SetTextID(this, play, 0x3333); return; } if (this->textId == 0x3333) { func_80B4AEC0(this); } else if (this->textId == 0x3334) { - func_801477B4(globalCtx); + func_801477B4(play); func_80B4B024(this); } } @@ -3428,19 +3426,19 @@ void func_80B4AEC0(EnInvadepoh* this) { this->actionFunc = func_80B4AEDC; } -void func_80B4AEDC(EnInvadepoh* this, GlobalContext* globalCtx) { +void func_80B4AEDC(EnInvadepoh* this, PlayState* play) { if (this->actionTimer > 0) { this->actionTimer--; if (this->actionTimer == 0) { - func_801477B4(globalCtx); + func_801477B4(play); } } - if (Actor_HasParent(&this->actor, globalCtx)) { + if (Actor_HasParent(&this->actor, play)) { this->actor.parent = NULL; gSaveContext.save.weekEventReg[22] |= 2; func_80B4AF80(this); } else { - Actor_PickUp(&this->actor, globalCtx, GI_MILK_BOTTLE, 2000.0f, 2000.0f); + Actor_PickUp(&this->actor, play, GI_MILK_BOTTLE, 2000.0f, 2000.0f); } } @@ -3448,15 +3446,15 @@ void func_80B4AF80(EnInvadepoh* this) { this->actionFunc = func_80B4AF94; } -void func_80B4AF94(EnInvadepoh* this, GlobalContext* globalCtx) { - if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { - EnInvadepoh_SetTextID(this, globalCtx, 0x3334); - func_80151BB4(globalCtx, 0x1E); - func_80151BB4(globalCtx, 0x1D); - func_80151BB4(globalCtx, 5); +void func_80B4AF94(EnInvadepoh* this, PlayState* play) { + if (Actor_ProcessTalkRequest(&this->actor, &play->state)) { + EnInvadepoh_SetTextID(this, play, 0x3334); + func_80151BB4(play, 0x1E); + func_80151BB4(play, 0x1D); + func_80151BB4(play, 5); func_80B4ADB8(this); } else { - func_800B85E0(&this->actor, globalCtx, 2000.0f, EXCH_ITEM_MINUS1); + func_800B85E0(&this->actor, play, 2000.0f, PLAYER_AP_MINUS1); } } @@ -3465,40 +3463,41 @@ void func_80B4B024(EnInvadepoh* this) { this->actionFunc = func_80B4B048; } -void func_80B4B048(EnInvadepoh* this, GlobalContext* globalCtx) { - if (globalCtx->msgCtx.unk120B1 == 0) { - if (globalCtx->msgCtx.msgMode == 0) { +void func_80B4B048(EnInvadepoh* this, PlayState* play) { + if (play->msgCtx.unk120B1 == 0) { + if (play->msgCtx.msgMode == 0) { D_80B4E998 = 1; - } else if ((Message_GetState(&globalCtx->msgCtx) == 6) || (Message_GetState(&globalCtx->msgCtx) == 5)) { + } else if ((Message_GetState(&play->msgCtx) == TEXT_STATE_DONE) || + (Message_GetState(&play->msgCtx) == TEXT_STATE_5)) { D_80B4E998 = 1; } } } -void func_80B4B0C4(Actor* thisx, GlobalContext* globalCtx) { +void func_80B4B0C4(Actor* thisx, PlayState* play) { EnInvadepoh* this = THIS; AlienBehaviorInfo* substruct; s32 pad; - if (Object_IsLoaded(&globalCtx->objectCtx, this->bankIndex)) { + if (Object_IsLoaded(&play->objectCtx, this->bankIndex)) { this->actor.objBankIndex = this->bankIndex; - Actor_SetObjectDependency(globalCtx, &this->actor); + Actor_SetObjectDependency(play, &this->actor); func_80B44F58(); this->actor.update = func_80B4B218; - SkelAnime_InitFlex(globalCtx, &this->skelAnime, &object_ma1_Skel_013928, &object_ma1_Anim_014088, - this->jointTable, this->morphTable, 23); - Animation_MorphToLoop(&this->skelAnime, &object_ma1_Anim_009E58, 0.0f); + SkelAnime_InitFlex(play, &this->skelAnime, &gRomaniSkel, &gRomaniWalkAnim, this->jointTable, this->morphTable, + ROMANI_LIMB_MAX); + Animation_MorphToLoop(&this->skelAnime, &gRomaniIdleAnim, 0.0f); substruct = &this->behaviorInfo; func_80B45C04(&this->behaviorInfo, D_80B4EA90, 1, D_80B4EB00, 3, &gZeroVec3s, 2000, 0.08f, 0.3f, 0.03f); substruct->unk30 = 0.08f; substruct->unk2C = 0x7D0; - func_800B4AEC(globalCtx, &this->actor, 50.0f); + func_800B4AEC(play, &this->actor, 50.0f); func_80B4516C(this); func_80B4ACDC(this); } } -void func_80B4B218(Actor* thisx, GlobalContext* globalCtx) { +void func_80B4B218(Actor* thisx, PlayState* play) { s16 diff; EnInvadepoh* this = THIS; s16 temp_v1; @@ -3506,10 +3505,10 @@ void func_80B4B218(Actor* thisx, GlobalContext* globalCtx) { Player* player; AlienBehaviorInfo* substruct = &this->behaviorInfo; - this->actionFunc(this, globalCtx); + this->actionFunc(this, play); if (sp38 && this->actor.update != NULL) { SkelAnime_Update(&this->skelAnime); - player = GET_PLAYER(globalCtx); + player = GET_PLAYER(play); Math_StepToS(&this->behaviorInfo.unk4C, 2000, 40); Math_SmoothStepToS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer, 6, this->behaviorInfo.unk4C, 40); temp_v1 = (Math_Vec3f_Pitch(&this->actor.focus.pos, &player->actor.focus.pos) * 0.9f); @@ -3521,7 +3520,7 @@ void func_80B4B218(Actor* thisx, GlobalContext* globalCtx) { substruct->unk26.y = CLAMP(temp_v1, -0x1F40, 0x1F40); func_80B45CE0(substruct); Collider_UpdateCylinder(&this->actor, &this->collider); - CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + CollisionCheck_SetOC(play, &play->colChkCtx, &this->collider.base); } } @@ -3539,9 +3538,9 @@ void func_80B4B430(EnInvadepoh* this) { this->actionFunc = func_80B4B484; } -void func_80B4B484(EnInvadepoh* this, GlobalContext* globalCtx) { +void func_80B4B484(EnInvadepoh* this, PlayState* play) { Math_StepToF(&this->actor.speedXZ, 1.1f, 0.5f); - if (func_80B44C80(this, globalCtx)) { + if (func_80B44C80(this, play)) { func_80B44690(this); } func_80B4B3DC(this); @@ -3562,7 +3561,7 @@ void func_80B4B510(EnInvadepoh* this) { this->actionFunc = func_80B4B564; } -void func_80B4B564(EnInvadepoh* this, GlobalContext* globalCtx) { +void func_80B4B564(EnInvadepoh* this, PlayState* play) { s32 pad; Vec3f sp28; f32 temp_f0; @@ -3584,7 +3583,7 @@ void func_80B4B564(EnInvadepoh* this, GlobalContext* globalCtx) { } } func_80B4B3DC(this); - if (func_80B44C80(this, globalCtx)) { + if (func_80B44C80(this, play)) { func_80B44690(this); } @@ -3605,13 +3604,13 @@ void func_80B4B724(EnInvadepoh* this) { this->actionFunc = func_80B4B768; } -void func_80B4B768(EnInvadepoh* this, GlobalContext* globalCtx) { +void func_80B4B768(EnInvadepoh* this, PlayState* play) { s32 pad; Math_StepToF(&this->actor.speedXZ, 0.0f, 1.0f); Math_SmoothStepToS(&this->actor.world.rot.y, Actor_YawBetweenActors(&this->actor, &D_80B5040C->actor), 5, 0x1388, 0x64); - func_80B44E90(this, globalCtx); + func_80B44E90(this, play); if (Animation_OnFrame(&this->skelAnime, 13.0f) || Animation_OnFrame(&this->skelAnime, 19.0f)) { Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_SMALL_DOG_ANG_BARK); } @@ -3625,27 +3624,27 @@ void func_80B4B820(EnInvadepoh* this) { this->actionFunc = func_80B4B864; } -void func_80B4B864(EnInvadepoh* this, GlobalContext* globalCtx) { +void func_80B4B864(EnInvadepoh* this, PlayState* play) { Math_StepToF(&this->actor.speedXZ, 0.5f, 1.0f); - func_80B44E90(this, globalCtx); + func_80B44E90(this, play); if (this->animPlayFlag) { func_80B4B510(this); } } -void func_80B4B8BC(Actor* thisx, GlobalContext* globalCtx) { +void func_80B4B8BC(Actor* thisx, PlayState* play) { EnInvadepoh* this = THIS; s32 pad; - if (Object_IsLoaded(&globalCtx->objectCtx, this->bankIndex)) { + if (Object_IsLoaded(&play->objectCtx, this->bankIndex)) { this->actor.objBankIndex = this->bankIndex; - Actor_SetObjectDependency(globalCtx, &this->actor); - SkelAnime_InitFlex(globalCtx, &this->skelAnime, &gDogSkel, &gDogWalkAnim, this->jointTable, this->morphTable, + Actor_SetObjectDependency(play, &this->actor); + SkelAnime_InitFlex(play, &this->skelAnime, &gDogSkel, &gDogWalkAnim, this->jointTable, this->morphTable, DOG_LIMB_MAX); func_80B45C04(&this->behaviorInfo, 0, 0, 0, 0, &gZeroVec3s, 3000, 0.1f, 0.0f, 0.0f); - func_80B44664(this, globalCtx); + func_80B44664(this, play); EnInvadepoh_SetPathPointToWorldPos(this, 0); - func_800B4AEC(globalCtx, &this->actor, 50.0f); + func_800B4AEC(play, &this->actor, 50.0f); func_80B4516C(this); Math_Vec3f_Copy(&this->curPathPos, &this->actor.world.pos); if (D_80B4E940 == 2) { @@ -3662,7 +3661,7 @@ void func_80B4B8BC(Actor* thisx, GlobalContext* globalCtx) { } } -void func_80B4BA30(Actor* thisx, GlobalContext* globalCtx) { +void func_80B4BA30(Actor* thisx, PlayState* play) { EnInvadepoh* this = THIS; if (D_80B4E940 == 2) { @@ -3673,7 +3672,7 @@ void func_80B4BA30(Actor* thisx, GlobalContext* globalCtx) { } } -void func_80B4BA84(Actor* thisx, GlobalContext* globalCtx) { +void func_80B4BA84(Actor* thisx, PlayState* play) { EnInvadepoh* this = THIS; s32 temp_v0_3; s32 sp34 = CHECK_FLAG_ALL(this->actor.flags, ACTOR_FLAG_40); @@ -3684,7 +3683,7 @@ void func_80B4BA84(Actor* thisx, GlobalContext* globalCtx) { D_80B5040C = func_80B458D8(); if (D_80B5040C == NULL) { - temp_v0_2 = (this->unk3BC < 0) ^ 1; + temp_v0_2 = this->unk3BC >= 0; this->unk3BC = -1; if (temp_v0_2) { func_80B4B820(this); @@ -3693,35 +3692,32 @@ void func_80B4BA84(Actor* thisx, GlobalContext* globalCtx) { sp2C = this->unk3BC; this->unk3BC = func_80B44234(this, &D_80B5040C->actor.world.pos); if (sp2C != this->unk3BC) { - phi_v0 = this->pathIndex; phi_v0 = this->unk3BC - this->pathIndex; - temp_v0_3 = phi_v0; - if (temp_v0_3 < 0) { + if (phi_v0 < 0) { phi_v0 += this->endPoint; } - temp_v0_3 = this->endPoint >> 1; - if (temp_v0_3 < phi_v0) { + if ((this->endPoint >> 1) < phi_v0) { this->direction = DIRECTION_BACKWARD; - } else if (phi_v0 < temp_v0_3) { + } else if (phi_v0 < (this->endPoint >> 1)) { this->direction = DIRECTION_FORWARD; } } } - this->actionFunc(this, globalCtx); + this->actionFunc(this, play); this->animPlayFlag = SkelAnime_Update(&this->skelAnime); if (sp34 && (this->actor.update != NULL)) { func_80B45CE0(&this->behaviorInfo); Collider_UpdateCylinder(&this->actor, &this->collider); - CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + CollisionCheck_SetOC(play, &play->colChkCtx, &this->collider.base); } } void func_80B4BBE0(EnInvadepoh* this) { AlienBehaviorInfo* substruct = &this->behaviorInfo; - Animation_MorphToLoop(&this->skelAnime, &object_ma2_Anim_016720, -6.0f); + Animation_MorphToLoop(&this->skelAnime, &gCremiaWalkAnim, -6.0f); substruct->unk26.x = 0; substruct->unk26.y = 0; substruct->unk26.z = 0; @@ -3732,7 +3728,7 @@ void func_80B4BBE0(EnInvadepoh* this) { this->actionFunc = func_80B4BC4C; } -void func_80B4BC4C(EnInvadepoh* this, GlobalContext* globalCtx) { +void func_80B4BC4C(EnInvadepoh* this, PlayState* play) { s8 temp_v0; s16 diff; EnInvadepoh* temp_t6 = D_80B503F4; @@ -3762,14 +3758,14 @@ void func_80B4BC4C(EnInvadepoh* this, GlobalContext* globalCtx) { this->actor.world.pos.x = (Math_SinS(temp_a0) * this->xzPosAdjFactor) + temp_t6->actor.world.pos.x; this->actor.world.pos.y = temp_t6->actor.world.pos.y; this->actor.world.pos.z = (Math_CosS(temp_a0) * this->xzPosAdjFactor) + temp_t6->actor.world.pos.z; - func_800B4AEC(globalCtx, &this->actor, 50.0f); + func_800B4AEC(play, &this->actor, 50.0f); func_80B4516C(this); Math_StepToS(&this->behaviorInfo.unk4C, 0xBB8, 0x1F5); if (Math3D_Vec3fDistSq(&this->actor.prevPos, &this->actor.world.pos) > SQ(0.01f)) { Math_SmoothStepToS(&this->actor.shape.rot.y, Math_Vec3f_Yaw(&this->actor.prevPos, &this->actor.world.pos), 3, this->behaviorInfo.unk4C, 0x1F4); } - temp_v1 = (globalCtx->gameplayFrames + 0x14) % 128; + temp_v1 = (play->gameplayFrames + 0x14) % 128; if ((temp_v1 & 0x40) != 0) { sp40 = Math_Vec3f_Yaw(&this->actor.world.pos, &temp_t6->actor.world.pos); if (temp_v1 == 64) { @@ -3802,14 +3798,14 @@ void func_80B4BC4C(EnInvadepoh* this, GlobalContext* globalCtx) { void func_80B4BFFC(EnInvadepoh* this) { this->behaviorInfo.unk30 = 0.08f; this->behaviorInfo.unk2C = 2000; - Animation_MorphToLoop(&this->skelAnime, &object_ma2_Anim_00A174, -6.0f); + Animation_MorphToLoop(&this->skelAnime, &gCremiaIdleAnim, -6.0f); this->behaviorInfo.unk4C = 0; this->actionFunc = func_80B4C058; } -void func_80B4C058(EnInvadepoh* this, GlobalContext* globalCtx) { +void func_80B4C058(EnInvadepoh* this, PlayState* play) { AlienBehaviorInfo* substruct = &this->behaviorInfo; - Player* player = GET_PLAYER(globalCtx); + Player* player = GET_PLAYER(play); s16 temp_v1; s16 diff; @@ -3826,7 +3822,7 @@ void func_80B4C058(EnInvadepoh* this, GlobalContext* globalCtx) { substruct->unk26.y = CLAMP(temp_v1, -0x1F40, 0x1F40); - if (Actor_TextboxIsClosing(&this->actor, globalCtx)) { + if (Actor_TextboxIsClosing(&this->actor, play)) { func_80B4BBE0(this); } } @@ -3834,14 +3830,14 @@ void func_80B4C058(EnInvadepoh* this, GlobalContext* globalCtx) { void func_80B4C1BC(EnInvadepoh* this) { this->behaviorInfo.unk30 = 0.08f; this->behaviorInfo.unk2C = 2000; - Animation_MorphToLoop(&this->skelAnime, &object_ma2_Anim_00A174, -6.0f); + Animation_MorphToLoop(&this->skelAnime, &gCremiaIdleAnim, -6.0f); this->behaviorInfo.unk4C = 0; this->actionFunc = func_80B4C218; } -void func_80B4C218(EnInvadepoh* this, GlobalContext* globalCtx) { +void func_80B4C218(EnInvadepoh* this, PlayState* play) { AlienBehaviorInfo* substruct = &this->behaviorInfo; - Player* player = GET_PLAYER(globalCtx); + Player* player = GET_PLAYER(play); Actor* temp_v0; s16 temp_v1; s16 diff; @@ -3864,18 +3860,18 @@ void func_80B4C218(EnInvadepoh* this, GlobalContext* globalCtx) { } } -void func_80B4C3A0(Actor* thisx, GlobalContext* globalCtx) { +void func_80B4C3A0(Actor* thisx, PlayState* play) { EnInvadepoh* this = THIS; - if (Object_IsLoaded(&globalCtx->objectCtx, this->bankIndex)) { + if (Object_IsLoaded(&play->objectCtx, this->bankIndex)) { s32 pad[2]; s32 currentTime = gSaveContext.save.time; this->actor.objBankIndex = this->bankIndex; - Actor_SetObjectDependency(globalCtx, &this->actor); + Actor_SetObjectDependency(play, &this->actor); func_80B44FEC(); - SkelAnime_InitFlex(globalCtx, &this->skelAnime, &object_ma2_Skel_015C28, &object_ma2_Anim_016720, - this->jointTable, this->morphTable, 22); + SkelAnime_InitFlex(play, &this->skelAnime, &gCremiaSkel, &gCremiaWalkAnim, this->jointTable, this->morphTable, + CREMIA_LIMB_MAX); func_80B45C04(&this->behaviorInfo, D_80B4EBDC, 1, D_80B4EC08, 0, &gZeroVec3s, 100, 0.03f, 0.3f, 0.03f); this->actor.textId = 0x33CD; if (currentTime < 0xD5A0) { @@ -3902,7 +3898,7 @@ void func_80B4C3A0(Actor* thisx, GlobalContext* globalCtx) { } } -void func_80B4C568(Actor* thisx, GlobalContext* globalCtx) { +void func_80B4C568(Actor* thisx, PlayState* play) { EnInvadepoh* this = THIS; if ((gSaveContext.save.time >= 0xD573) && (gSaveContext.save.time < CLOCK_TIME(20, 15))) { @@ -3912,32 +3908,32 @@ void func_80B4C568(Actor* thisx, GlobalContext* globalCtx) { } } -void func_80B4C5C0(Actor* thisx, GlobalContext* globalCtx) { +void func_80B4C5C0(Actor* thisx, PlayState* play) { s32 pad; EnInvadepoh* this = THIS; s32 sp2C = CHECK_FLAG_ALL(this->actor.flags, ACTOR_FLAG_40); - s32 isTalking = Actor_ProcessTalkRequest(&this->actor, &globalCtx->state); + s32 isTalking = Actor_ProcessTalkRequest(&this->actor, &play->state); if (isTalking) { - func_80151BB4(globalCtx, 6); + func_80151BB4(play, 6); func_80B4BFFC(this); } - this->actionFunc(this, globalCtx); + this->actionFunc(this, play); if (sp2C && (this->actor.update != NULL)) { SkelAnime_Update(&this->skelAnime); func_80B45CE0(&this->behaviorInfo); if ((this->actionFunc != func_80B4C058) && !isTalking && this->actor.isTargeted) { - func_800B8614(&this->actor, globalCtx, 350.0f); + func_800B8614(&this->actor, play, 350.0f); } Collider_UpdateCylinder(&this->actor, &this->collider); - CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + CollisionCheck_SetOC(play, &play->colChkCtx, &this->collider.base); } } void func_80B4C6C8(EnInvadepoh* this) { AlienBehaviorInfo* substruct = &this->behaviorInfo; - Animation_MorphToLoop(&this->skelAnime, &object_ma1_Anim_014088, -10.0f); + Animation_MorphToLoop(&this->skelAnime, &gRomaniWalkAnim, -10.0f); substruct->unk26.x = 0; substruct->unk26.y = 0; substruct->unk26.z = 0; @@ -3946,7 +3942,7 @@ void func_80B4C6C8(EnInvadepoh* this) { this->actionFunc = func_80B4C730; } -void func_80B4C730(EnInvadepoh* this, GlobalContext* globalCtx) { +void func_80B4C730(EnInvadepoh* this, PlayState* play) { AlienBehaviorInfo* substruct = &this->behaviorInfo; EnInvadepoh* sp68 = D_80B503F8; s32 phi_a2; @@ -3956,31 +3952,24 @@ 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_80B44EFC(this, play); 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]); Math_SmoothStepToS(&this->actor.world.rot.y, Math_Vec3f_Yaw(&sp4C, &sp40), 5, 0x7D0, 0x64); if ((this->pathIndex == 0) || ((this->pathIndex + 1) == this->endPoint)) { if (this->unk378 == 0) { - temp_v0_2 = func_800FE620(globalCtx); + temp_v0_2 = func_800FE620(play); if (temp_v0_2 > 0) { temp_v0_2 = (REG(15) * -23.0f / temp_v0_2) - 0.5f; - this->unk378 = func_80B45550(this, globalCtx, SQ(80.0f), temp_v0_2); + this->unk378 = func_80B45550(this, play, SQ(80.0f), temp_v0_2); } } @@ -3990,7 +3979,7 @@ void func_80B4C730(EnInvadepoh* this, GlobalContext* globalCtx) { this->actor.flags |= (ACTOR_FLAG_1 | ACTOR_FLAG_8); } - temp_v1_3 = globalCtx->gameplayFrames % 128; + temp_v1_3 = play->gameplayFrames % 128; if ((temp_v1_3 & 0x40) != 0) { sp3A = Math_Vec3f_Yaw(&this->actor.world.pos, &sp68->actor.world.pos); if (temp_v1_3 == 64) { @@ -4027,14 +4016,14 @@ void func_80B4C730(EnInvadepoh* this, GlobalContext* globalCtx) { void func_80B4CAB0(EnInvadepoh* this) { this->behaviorInfo.unk30 = 0.08f; this->behaviorInfo.unk2C = 4000; - Animation_MorphToLoop(&this->skelAnime, &object_ma1_Anim_009E58, -10.0f); + Animation_MorphToLoop(&this->skelAnime, &gRomaniIdleAnim, -10.0f); this->behaviorInfo.unk4C = 0; this->actionFunc = func_80B4CB0C; } -void func_80B4CB0C(EnInvadepoh* this, GlobalContext* globalCtx) { +void func_80B4CB0C(EnInvadepoh* this, PlayState* play) { AlienBehaviorInfo* substruct = &this->behaviorInfo; - Player* player = GET_PLAYER(globalCtx); + Player* player = GET_PLAYER(play); s16 temp_v1; s16 diff; @@ -4048,7 +4037,7 @@ void func_80B4CB0C(EnInvadepoh* this, GlobalContext* globalCtx) { temp_v1 = diff; temp_v1 *= 0.7f; substruct->unk26.y = CLAMP(temp_v1, -0x1F40, 0x1F40); - if (Actor_TextboxIsClosing(&this->actor, globalCtx)) { + if (Actor_TextboxIsClosing(&this->actor, play)) { func_80B4C6C8(this); } } @@ -4056,14 +4045,14 @@ void func_80B4CB0C(EnInvadepoh* this, GlobalContext* globalCtx) { void func_80B4CC70(EnInvadepoh* this) { this->behaviorInfo.unk30 = 0.08f; this->behaviorInfo.unk2C = 2000; - Animation_MorphToLoop(&this->skelAnime, &object_ma1_Anim_009E58, -10.0f); + Animation_MorphToLoop(&this->skelAnime, &gRomaniIdleAnim, -10.0f); this->behaviorInfo.unk4C = 0; this->actionFunc = func_80B4CCCC; } -void func_80B4CCCC(EnInvadepoh* this, GlobalContext* globalCtx) { +void func_80B4CCCC(EnInvadepoh* this, PlayState* play) { AlienBehaviorInfo* substruct = &this->behaviorInfo; - Player* player = GET_PLAYER(globalCtx); + Player* player = GET_PLAYER(play); s16 temp_v1; s16 diff; @@ -4084,24 +4073,24 @@ void func_80B4CCCC(EnInvadepoh* this, GlobalContext* globalCtx) { } } -void func_80B4CE54(Actor* thisx, GlobalContext* globalCtx) { +void func_80B4CE54(Actor* thisx, PlayState* play) { s32 pad[2]; EnInvadepoh* this = THIS; s32 sp38; - if (Object_IsLoaded(&globalCtx->objectCtx, this->bankIndex)) { + if (Object_IsLoaded(&play->objectCtx, this->bankIndex)) { sp38 = gSaveContext.save.time; this->actor.objBankIndex = this->bankIndex; - Actor_SetObjectDependency(globalCtx, &this->actor); + Actor_SetObjectDependency(play, &this->actor); func_80B44F58(); - SkelAnime_InitFlex(globalCtx, &this->skelAnime, &object_ma1_Skel_013928, &object_ma1_Anim_014088, - this->jointTable, this->morphTable, 23); + SkelAnime_InitFlex(play, &this->skelAnime, &gRomaniSkel, &gRomaniWalkAnim, this->jointTable, this->morphTable, + ROMANI_LIMB_MAX); func_80B45C04(&this->behaviorInfo, D_80B4EA90, 1, D_80B4EB00, 3, &gZeroVec3s, 100, 0.03f, 0.3f, 0.03f); - func_80B446D0(this, globalCtx); + func_80B446D0(this, play); this->actor.world.rot.y = this->actor.shape.rot.y; func_80B44700(this); - func_80B44EFC(this, globalCtx); + func_80B44EFC(this, play); func_80B43F0C(this); func_80B4516C(this); this->actor.textId = 0x33CE; @@ -4118,7 +4107,7 @@ void func_80B4CE54(Actor* thisx, GlobalContext* globalCtx) { } } -void func_80B4CFFC(Actor* thisx, GlobalContext* globalCtx) { +void func_80B4CFFC(Actor* thisx, PlayState* play) { EnInvadepoh* this = THIS; if ((gSaveContext.save.time >= CLOCK_TIME(20, 0)) && (gSaveContext.save.time < 0xD7E1)) { @@ -4128,25 +4117,25 @@ void func_80B4CFFC(Actor* thisx, GlobalContext* globalCtx) { } } -void func_80B4D054(Actor* thisx, GlobalContext* globalCtx) { +void func_80B4D054(Actor* thisx, PlayState* play) { s32 pad; EnInvadepoh* this = THIS; s32 sp2C = CHECK_FLAG_ALL(this->actor.flags, ACTOR_FLAG_40); - s32 isTalking = Actor_ProcessTalkRequest(&this->actor, &globalCtx->state); + s32 isTalking = Actor_ProcessTalkRequest(&this->actor, &play->state); if (isTalking) { - func_80151BB4(globalCtx, 5); + func_80151BB4(play, 5); func_80B4CAB0(this); } - this->actionFunc(this, globalCtx); + this->actionFunc(this, play); if (sp2C && this->actor.update != NULL) { SkelAnime_Update(&this->skelAnime); func_80B45CE0(&this->behaviorInfo); if ((this->actionFunc != func_80B4CB0C) && !isTalking && this->actor.isTargeted) { - func_800B8614(thisx, globalCtx, 350.0f); + func_800B8614(thisx, play, 350.0f); } Collider_UpdateCylinder(&this->actor, &this->collider); - CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + CollisionCheck_SetOC(play, &play->colChkCtx, &this->collider.base); } } @@ -4155,7 +4144,7 @@ void func_80B4D15C(EnInvadepoh* this) { s32 temp_v1 = this->actor.params & 7; unkstruct80B4EE0C* temp_v0; - Animation_PlayLoop(&this->skelAnime, &object_uch_Anim_001674); + Animation_PlayLoop(&this->skelAnime, &gAlienHoldingCowAnim); this->skelAnime.curFrame = ((this->actor.params & 7) * this->skelAnime.endFrame) * 0.25f; this->alienAlpha = 255; this->actor.draw = func_80B4DB14; @@ -4175,7 +4164,7 @@ void func_80B4D15C(EnInvadepoh* this) { this->actor.velocity.y = 0.0f; } -void func_80B4D290(EnInvadepoh* this, GlobalContext* globalCtx) { +void func_80B4D290(EnInvadepoh* this, PlayState* play) { Actor* temp_v1; f32 sp28; @@ -4207,7 +4196,7 @@ void func_80B4D290(EnInvadepoh* this, GlobalContext* globalCtx) { } void func_80B4D3E4(EnInvadepoh* this) { - Animation_PlayLoop(&this->skelAnime, &object_uch_Anim_001674); + Animation_PlayLoop(&this->skelAnime, &gAlienHoldingCowAnim); this->skelAnime.curFrame = (this->actor.params & 7) * this->skelAnime.endFrame * 0.25f; this->alienAlpha = 255; this->actor.draw = NULL; @@ -4221,7 +4210,7 @@ void func_80B4D3E4(EnInvadepoh* this) { this->actionFunc = func_80B4D480; } -void func_80B4D480(EnInvadepoh* this, GlobalContext* globalCtx) { +void func_80B4D480(EnInvadepoh* this, PlayState* play) { f32 target; s32 pad2; s32 sp2C = false; @@ -4273,163 +4262,157 @@ void func_80B4D480(EnInvadepoh* this, GlobalContext* globalCtx) { } } -void func_80B4D670(Actor* thisx, GlobalContext* globalCtx) { +void func_80B4D670(Actor* thisx, PlayState* play) { s32 pad; EnInvadepoh* this = THIS; s32 invadepohType; - if (Object_IsLoaded(&globalCtx->objectCtx, this->bankIndex)) { + if (Object_IsLoaded(&play->objectCtx, this->bankIndex)) { invadepohType = this->actor.params & 7; this->actor.objBankIndex = this->bankIndex; - Actor_SetObjectDependency(globalCtx, &this->actor); + Actor_SetObjectDependency(play, &this->actor); func_80B45080(); this->actor.update = func_80B4D760; - SkelAnime_InitFlex(globalCtx, &this->skelAnime, &object_uch_Skel_004E50, &object_uch_Anim_001674, - this->jointTable, this->morphTable, 14); + SkelAnime_InitFlex(play, &this->skelAnime, &gAlienSkel, &gAlienHoldingCowAnim, this->jointTable, + this->morphTable, ALIEN_LIMB_MAX); if (invadepohType < 3) { - func_80B453F4(this, globalCtx, invadepohType); + func_80B453F4(this, play, invadepohType); func_80B4D15C(this); } else { - func_80B45460(this, globalCtx); + func_80B45460(this, play); func_80B4D3E4(this); } } } -void func_80B4D760(Actor* thisx, GlobalContext* globalCtx) { +void func_80B4D760(Actor* thisx, PlayState* play) { EnInvadepoh* this = THIS; - this->actionFunc(this, globalCtx); + this->actionFunc(this, play); if (this->actor.update != NULL) { SkelAnime_Update(&this->skelAnime); func_800B9010(&this->actor, NA_SE_EN_FOLLOWERS_BEAM_PRE - SFX_FLAG); } } -void func_80B4D7B8(GlobalContext* globalCtx) { - s32 temp_v0; +void func_80B4D7B8(PlayState* play) { u32 temp_s5; u32 temp_s6; unkStruct80B50350* phi_s2; s32 i; - OPEN_DISPS(globalCtx->state.gfxCtx); - func_8012C2DC(globalCtx->state.gfxCtx); + OPEN_DISPS(play->state.gfxCtx); + func_8012C2DC(play->state.gfxCtx); for (phi_s2 = D_80B50350, i = 0; i < 10; phi_s2++, i++) { if (phi_s2->unk1 > 0) { - temp_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); + temp_s5 = (play->gameplayFrames + ((0x10 * i) & 0xFF)) & 0x7F; + temp_s6 = (u8)(play->gameplayFrames * -0xF); + Matrix_Translate(phi_s2->unk4.x, phi_s2->unk4.y, phi_s2->unk4.z, MTXMODE_NEW); Matrix_Scale(0.1f, 0.1f, 0.1f, MTXMODE_APPLY); gDPPipeSync(POLY_XLU_DISP++); gDPSetPrimColor(POLY_XLU_DISP++, 0x80, 0x80, 255, 255, 170, phi_s2->unk2); gDPSetEnvColor(POLY_XLU_DISP++, 255, 50, 0, 0); - temp_v0 = globalCtx->gameplayFrames; gSPSegment(POLY_XLU_DISP++, 0x08, - Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, temp_s5, 0, 0x20, 0x40, 1, 0, temp_s6, 0x20, 0x40)); - gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), - G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + Gfx_TwoTexScroll(play->state.gfxCtx, 0, temp_s5, 0, 0x20, 0x40, 1, 0, temp_s6, 0x20, 0x40)); + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_XLU_DISP++, &gameplay_keep_DL_02E510); } } - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->state.gfxCtx); } -void func_80B4D9B4(Actor* thisx, GlobalContext* globalCtx) { - func_80B4D7B8(globalCtx); +void func_80B4D9B4(Actor* thisx, PlayState* play) { + func_80B4D7B8(play); } -s32 func_80B4D9D8(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, Actor* thisx, - Gfx** gfx) { - return 0; +s32 func_80B4D9D8(PlayState* play, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, Actor* thisx, Gfx** gfx) { + return false; } -void func_80B4D9F4(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx, Gfx** gfx) { +void func_80B4D9F4(PlayState* play, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx, Gfx** gfx) { EnInvadepoh* this = THIS; if ((limbIndex == 12) && (this->alienBeamAlpha != 0)) { - Matrix_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); } } -void func_80B4DB14(Actor* thisx, GlobalContext* globalCtx) { +void func_80B4DB14(Actor* thisx, PlayState* play) { EnInvadepoh* this = THIS; Gfx* gfx; - GraphicsContext* spCC = globalCtx->state.gfxCtx; + GraphicsContext* spCC = play->state.gfxCtx; OPEN_DISPS(spCC); func_8012C2DC(spCC); - Matrix_StatePush(); + Matrix_Push(); if (this->drawAlien) { Gfx* new_var6; Gfx* spBC; GraphicsContext* spB8; if (this->alienAlpha == 255) { - func_8012C28C(globalCtx->state.gfxCtx); - AnimatedMat_Draw(globalCtx, D_80B50400); - Scene_SetRenderModeXlu(globalCtx, 0, 1); + func_8012C28C(play->state.gfxCtx); + AnimatedMat_Draw(play, sAlienEmptyTexAnim); + Scene_SetRenderModeXlu(play, 0, 1); gDPSetEnvColor(spCC->polyOpa.p++, 0, 0, 0, 255); - spCC->polyOpa.p = SkelAnime_DrawFlex(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, + spCC->polyOpa.p = SkelAnime_DrawFlex(play, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, func_80B4D9D8, func_80B4D9F4, &this->actor, spCC->polyOpa.p); } else { - AnimatedMat_Draw(globalCtx, D_80B50400); - Scene_SetRenderModeXlu(globalCtx, 1, 2); + AnimatedMat_Draw(play, sAlienEmptyTexAnim); + Scene_SetRenderModeXlu(play, 1, 2); gDPSetEnvColor(spCC->polyXlu.p++, 0, 0, 0, this->alienAlpha); - spCC->polyXlu.p = SkelAnime_DrawFlex(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, + spCC->polyXlu.p = SkelAnime_DrawFlex(play, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, func_80B4D9D8, func_80B4D9F4, &this->actor, spCC->polyXlu.p); } if (this->alienBeamAlpha != 0) { - AnimatedMat_Draw(globalCtx, D_80B503FC); - spB8 = globalCtx->state.gfxCtx; + AnimatedMat_Draw(play, sAlienEyeBeamTexAnim); + spB8 = play->state.gfxCtx; gfx = spBC = spB8->polyXlu.p; gDPPipeSync(spBC++); gDPSetPrimColor(spBC++, 0, 255, 240, 180, 100, 60); gDPSetEnvColor(spBC++, 255, 255, 255, this->alienBeamAlpha * (150.0f / 255.0f)); - Matrix_InsertMatrix(&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); - gSPMatrix(spBC++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - gSPDisplayList(spBC++, object_uch_DL_000080); + Matrix_Mult(&D_80B502A0, MTXMODE_NEW); + gSPMatrix(spBC++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(spBC++, gAlienEyeBeamDL); + Matrix_Mult(&D_80B502E0, MTXMODE_NEW); + gSPMatrix(spBC++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(spBC++, gAlienEyeBeamDL); spB8->polyXlu.p = spBC; } } if (this->drawAlienDeathEffect) { - Matrix_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), - G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - gSPDisplayList(spCC->polyXlu.p++, object_uch_DL_000720); + gSPMatrix(spCC->polyXlu.p++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(spCC->polyXlu.p++, gAlienDeathFlashDL); } if (this->drawAlien) { Vec3f sp80; Vec3f sp74; s32 alpha2; - GraphicsContext* sp6C = globalCtx->state.gfxCtx; + GraphicsContext* sp6C = play->state.gfxCtx; u32 pad; gfx = sp6C->polyXlu.p; @@ -4437,122 +4420,121 @@ void func_80B4DB14(Actor* thisx, GlobalContext* globalCtx) { 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(&play->billboardMtxF, MTXMODE_NEW); + Matrix_MultVecZ(60.0f, &sp80); sp74.x = thisx->world.pos.x + sp80.x; sp74.y = thisx->world.pos.y + sp80.y + 68.0f; sp74.z = thisx->world.pos.z + sp80.z; - Matrix_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); gDPSetPrimColor(gfx++, 0, 0, 240, 180, 100, alpha2); - gSPMatrix(gfx++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPMatrix(gfx++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(gfx++, gameplay_keep_DL_029CF0); sp6C->polyXlu.p = gfx; - if ((this->alienAlpha > 128) && func_80B456A8(globalCtx, &sp74)) { - func_800F9824(globalCtx, &globalCtx->envCtx, &globalCtx->view, globalCtx->state.gfxCtx, sp74, 10.0f, 9.0f, - 0, 0); + if ((this->alienAlpha > 128) && func_80B456A8(play, &sp74)) { + func_800F9824(play, &play->envCtx, &play->view, play->state.gfxCtx, sp74, 10.0f, 9.0f, 0, 0); } } - Matrix_StatePop(); + Matrix_Pop(); CLOSE_DISPS(spCC); } -s32 func_80B4E120(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, Actor* thisx) { +s32 func_80B4E120(PlayState* play, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, Actor* thisx) { if (limbIndex == 5) { EnInvadepoh* this = THIS; rot->x -= this->actor.shape.rot.x; } - return 0; + return false; } -void func_80B4E158(Actor* thisx, GlobalContext* globalCtx) { +void func_80B4E158(Actor* thisx, PlayState* play) { EnInvadepoh* this = THIS; - func_8012C5B0(globalCtx->state.gfxCtx); - SkelAnime_DrawFlexOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, + func_8012C5B0(play->state.gfxCtx); + SkelAnime_DrawFlexOpa(play, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, func_80B4E120, NULL, &this->actor); } -void func_80B4E1B0(Actor* thisx, GlobalContext* globalCtx) { +void func_80B4E1B0(Actor* thisx, PlayState* play) { EnInvadepoh* this = THIS; - func_8012C5B0(globalCtx->state.gfxCtx); - SkelAnime_DrawFlexOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, - NULL, NULL, &this->actor); + func_8012C5B0(play->state.gfxCtx); + SkelAnime_DrawFlexOpa(play, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, NULL, + NULL, &this->actor); } -s32 func_80B4E200(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, Actor* thisx) { - if (limbIndex == 14) { +s32 func_80B4E200(PlayState* play, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, Actor* thisx) { + if (limbIndex == ROMANI_LIMB_HEAD) { EnInvadepoh* this = THIS; // both of these needed to match rot->x += this->behaviorInfo.unk20.y; rot->y += this->behaviorInfo.unk20.z; rot->z += this->behaviorInfo.unk20.x; - } else if (limbIndex == 13) { + } else if (limbIndex == ROMANI_LIMB_TORSO) { EnInvadepoh* this = THIS; // both of these needed to match rot->x += (s16)(this->behaviorInfo.unk34 * this->behaviorInfo.unk20.y); rot->z += this->behaviorInfo.unk40; } - return 0; + return false; } -void func_80B4E2AC(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx) { +void func_80B4E2AC(PlayState* play, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx) { EnInvadepoh* this = THIS; - if (limbIndex == 19) { - OPEN_DISPS(globalCtx->state.gfxCtx); - 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); + if (limbIndex == ROMANI_LIMB_LEFT_HAND) { + OPEN_DISPS(play->state.gfxCtx); + gSPDisplayList(POLY_OPA_DISP++, gRomaniBowDL); + CLOSE_DISPS(play->state.gfxCtx); + } else if (limbIndex == ROMANI_LIMB_HEAD) { + Matrix_MultVec3f(&D_80B4EE30, &this->actor.focus.pos); } } -void func_80B4E324(Actor* thisx, GlobalContext* globalCtx) { +void func_80B4E324(Actor* thisx, PlayState* play) { EnInvadepoh* this = THIS; - OPEN_DISPS(globalCtx->state.gfxCtx); - func_8012C28C(globalCtx->state.gfxCtx); - gSPSegment(POLY_OPA_DISP++, 0x09, D_80B4E958[this->behaviorInfo.unk10.unkF]); - gSPSegment(POLY_OPA_DISP++, 0x08, D_80B4E944[this->behaviorInfo.unk0.unkF]); - SkelAnime_DrawFlexOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, + OPEN_DISPS(play->state.gfxCtx); + func_8012C28C(play->state.gfxCtx); + gSPSegment(POLY_OPA_DISP++, 0x09, sRomaniMouthTextures[this->behaviorInfo.unk10.unkF]); + gSPSegment(POLY_OPA_DISP++, 0x08, sRomaniEyeTextures[this->behaviorInfo.unk0.unkF]); + SkelAnime_DrawFlexOpa(play, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, func_80B4E200, func_80B4E2AC, &this->actor); - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->state.gfxCtx); } -void func_80B4E3F0(Actor* thisx, GlobalContext* globalCtx) { - s32 pad[2]; +void func_80B4E3F0(Actor* thisx, PlayState* play) { + s32 pad; + EnInvadepoh* this = THIS; Vec3f sp5C; - Matrix_StatePush(); - Matrix_InsertMatrix(&globalCtx->billboardMtxF, MTXMODE_NEW); - Matrix_GetStateTranslationAndScaledZ(200.0f, &sp5C); - Matrix_StatePop(); + Matrix_Push(); + Matrix_Mult(&play->billboardMtxF, MTXMODE_NEW); + Matrix_MultVecZ(200.0f, &sp5C); + Matrix_Pop(); sp5C.x += thisx->world.pos.x; sp5C.y += thisx->world.pos.y; sp5C.z += thisx->world.pos.z; EnInvadepoh_SetSysMatrix(&sp5C); - Matrix_NormalizeXYZ(&globalCtx->billboardMtxF); - Matrix_InsertZRotation_s(((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); + Matrix_ReplaceRotation(&play->billboardMtxF); + Matrix_RotateZS(this->unk304, MTXMODE_APPLY); + OPEN_DISPS(play->state.gfxCtx); + func_8012C2DC(play->state.gfxCtx); + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gDPSetPrimColor(POLY_XLU_DISP++, 0xFF, 0x80, 255, 255, 0, 180); gDPSetEnvColor(POLY_XLU_DISP++, 255, 50, 0, 0); gSPDisplayList(POLY_XLU_DISP++, gOwlStatueWhiteFlashDL); - if (func_80B456A8(globalCtx, &sp5C)) { - func_800F9824(globalCtx, &globalCtx->envCtx, &globalCtx->view, globalCtx->state.gfxCtx, sp5C, 20.0f, 9.0f, 0, - 0); + if (func_80B456A8(play, &sp5C)) { + func_800F9824(play, &play->envCtx, &play->view, play->state.gfxCtx, sp5C, 20.0f, 9.0f, 0, 0); } - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->state.gfxCtx); } -s32 func_80B4E5B0(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, Actor* thisx) { +s32 func_80B4E5B0(PlayState* play, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, Actor* thisx) { if ((limbIndex == DOG_LIMB_HEAD) || (limbIndex == DOG_LIMB_RIGHT_FACE_HAIR) || (limbIndex == DOG_LIMB_LEFT_FACE_HAIR)) { EnInvadepoh* this = THIS; @@ -4562,29 +4544,29 @@ s32 func_80B4E5B0(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* p rot->z += this->behaviorInfo.unk20.z; } - return 0; + return false; } -void func_80B4E61C(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx) { +void func_80B4E61C(PlayState* play, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx) { EnInvadepoh* this = THIS; if (limbIndex == DOG_LIMB_HEAD) { - Matrix_GetStateTranslationAndScaledY(20.0f, &this->actor.focus.pos); + Matrix_MultVecY(20.0f, &this->actor.focus.pos); } } -void func_80B4E660(Actor* thisx, GlobalContext* globalCtx) { +void func_80B4E660(Actor* thisx, PlayState* play) { EnInvadepoh* this = THIS; - OPEN_DISPS(globalCtx->state.gfxCtx); - func_8012C28C(globalCtx->state.gfxCtx); + OPEN_DISPS(play->state.gfxCtx); + func_8012C28C(play->state.gfxCtx); gDPSetEnvColor(POLY_OPA_DISP++, 255, 255, 200, 0); - SkelAnime_DrawFlexOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, + SkelAnime_DrawFlexOpa(play, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, func_80B4E5B0, func_80B4E61C, &this->actor); - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->state.gfxCtx); } -s32 func_80B4E6E4(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, Actor* thisx) { +s32 func_80B4E6E4(PlayState* play, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, Actor* thisx) { if (limbIndex == 9) { EnInvadepoh* this = THIS; // both of these needed to match @@ -4596,25 +4578,25 @@ s32 func_80B4E6E4(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* p rot->x += (s16)(this->behaviorInfo.unk34 * this->behaviorInfo.unk20.y); } - return 0; + return false; } -void func_80B4E784(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx) { +void func_80B4E784(PlayState* play, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx) { EnInvadepoh* this = THIS; if (limbIndex == 9) { - Matrix_GetStateTranslation(&this->actor.focus.pos); + Matrix_MultZero(&this->actor.focus.pos); } } -void func_80B4E7BC(Actor* thisx, GlobalContext* globalCtx) { +void func_80B4E7BC(Actor* thisx, PlayState* play) { EnInvadepoh* this = THIS; - OPEN_DISPS(globalCtx->state.gfxCtx); - func_8012C28C(globalCtx->state.gfxCtx); - gSPSegment(POLY_OPA_DISP++, 0x09, D_80B4E984[this->behaviorInfo.unk10.unkF]); - gSPSegment(POLY_OPA_DISP++, 0x08, D_80B4E96C[this->behaviorInfo.unk0.unkF]); - SkelAnime_DrawFlexOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, + OPEN_DISPS(play->state.gfxCtx); + func_8012C28C(play->state.gfxCtx); + gSPSegment(POLY_OPA_DISP++, 0x09, sCremiaMouthTextures[this->behaviorInfo.unk10.unkF]); + gSPSegment(POLY_OPA_DISP++, 0x08, sCremiaEyeTextures[this->behaviorInfo.unk0.unkF]); + SkelAnime_DrawFlexOpa(play, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, func_80B4E6E4, func_80B4E784, &this->actor); - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->state.gfxCtx); } diff --git a/src/overlays/actors/ovl_En_Invadepoh/z_en_invadepoh.h b/src/overlays/actors/ovl_En_Invadepoh/z_en_invadepoh.h index 3a242eace..cafae5f23 100644 --- a/src/overlays/actors/ovl_En_Invadepoh/z_en_invadepoh.h +++ b/src/overlays/actors/ovl_En_Invadepoh/z_en_invadepoh.h @@ -5,11 +5,11 @@ struct EnInvadepoh; -typedef void (*EnInvadepohInitFunc)(struct EnInvadepoh*, GlobalContext*); -typedef void (*EnInvadepohDestroyFunc)(struct EnInvadepoh*, GlobalContext*); -typedef void (*EnInvadepohActionFunc)(struct EnInvadepoh*, GlobalContext*); +typedef void (*EnInvadepohInitFunc)(struct EnInvadepoh*, PlayState*); +typedef void (*EnInvadepohDestroyFunc)(struct EnInvadepoh*, PlayState*); +typedef void (*EnInvadepohActionFunc)(struct EnInvadepoh*, PlayState*); -#define INVADEPOH_TYPE(x) (x->actor.params >> 4 & 0xF) +#define INVADEPOH_TYPE(thisx) (((thisx)->params >> 4) & 0xF) typedef enum{ /* 0 */ TYPE_UNK0, @@ -25,7 +25,7 @@ typedef enum{ /* 10 */ TYPE_DOG, /* 11 */ TYPE_CREMIA, /* 12 */ TYPE_ROMANI5, - /* 13 */ TYPE_ALIEN1 + /* 13 */ TYPE_ALIEN_CARRYING_COW } EnInvadepohType; typedef enum { @@ -34,32 +34,32 @@ typedef enum { } EnInvadepohDirection; typedef struct unkStruct80B50350 { - /* 0x000 */ s8 unk0; - /* 0x001 */ s8 unk1; - /* 0x002 */ u8 unk2; - /* 0x004 */ Vec3f unk4; + /* 0x0 */ s8 unk0; + /* 0x1 */ s8 unk1; + /* 0x2 */ u8 unk2; + /* 0x4 */ Vec3f unk4; } unkStruct80B50350; // size = 0x10; typedef struct { - /* 0x00 */ s8* unk00; - /* 0x04 */ s8 unk04; -} unkstructInvadepoh0; // size = 0x08 + /* 0x0 */ s8* unk00; + /* 0x4 */ s8 unk04; +} unkstructInvadepoh0; // size = 0x8 typedef struct { - /* 0x00 */ s8 unk00; - /* 0x04 */ f32 unk04; -} unkstructInvadepoh1; // size = 0x08 + /* 0x0 */ s8 unk00; + /* 0x4 */ f32 unk04; +} unkstructInvadepoh1; // size = 0x8 typedef struct { - /* 0x00 */ s8 unk00; - /* 0x04 */ unkstructInvadepoh0* unk04; -} unkstructInvadepoh2; // size = 0x08 + /* 0x0 */ s8 unk00; + /* 0x4 */ unkstructInvadepoh0* unk04; +} unkstructInvadepoh2; // size = 0x8 typedef struct { - /* 0x00 */ s8 unk0; - /* 0x04 */ unkstructInvadepoh0* unk4; - /* 0x08 */ s8 unk8; - /* 0x0C */ unkstructInvadepoh1* unkC; + /* 0x0 */ s8 unk0; + /* 0x4 */ unkstructInvadepoh0* unk4; + /* 0x8 */ s8 unk8; + /* 0xC */ unkstructInvadepoh1* unkC; } unkstructInvadepoh3; // size = 0x10 typedef struct { @@ -72,38 +72,38 @@ typedef struct { } unkstructInvadepoh4; // size = 0x14 typedef struct { - /* 0x00 */ f32 unk00; - /* 0x04 */ s16 unk04; - /* 0x06 */ s16 unk06; -} unkstruct80B4EE0C; // size = 0x08 + /* 0x0 */ f32 unk00; + /* 0x4 */ s16 unk04; + /* 0x6 */ s16 unk06; +} unkstruct80B4EE0C; // size = 0x8 typedef struct EnInvadePohStruct { - /* 0x000 */ unkstructInvadepoh4* unk0; - /* 0x004 */ s8 unk4; - /* 0x008 */ unkstructInvadepoh4* unk8; - /* 0x00C */ s16 unkC; - /* 0x00E */ s8 unkE; - /* 0x00F */ s8 unkF; + /* 0x0 */ unkstructInvadepoh4* unk0; + /* 0x4 */ s8 unk4; + /* 0x8 */ unkstructInvadepoh4* unk8; + /* 0xC */ s16 unkC; + /* 0xE */ s8 unkE; + /* 0xF */ s8 unkF; } EnInvadePohStruct; // size = 0x10; typedef struct AlienBehaviorInfo { - /* 0x000 */ EnInvadePohStruct unk0; - /* 0x010 */ EnInvadePohStruct unk10; - /* 0x020 */ Vec3s unk20; - /* 0x026 */ Vec3s unk26; - /* 0x02C */ s16 unk2C; - /* 0x02E */ u16 unk2E; - /* 0x030 */ f32 unk30; - /* 0x034 */ f32 unk34; - /* 0x038 */ f32 unk38; - /* 0x03C */ f32 unk3C; - /* 0x040 */ s16 unk40; - /* 0x042 */ s16 unk42; - /* 0x044 */ f32 unk44; - /* 0x048 */ s16 unk48; - /* 0x04A */ char unk4A[0x2]; - /* 0x04C */ s16 unk4C; - /* 0x04E */ s16 unk4E; + /* 0x00 */ EnInvadePohStruct unk0; + /* 0x10 */ EnInvadePohStruct unk10; + /* 0x20 */ Vec3s unk20; + /* 0x26 */ Vec3s unk26; + /* 0x2C */ s16 unk2C; + /* 0x2E */ u16 unk2E; + /* 0x30 */ f32 unk30; + /* 0x34 */ f32 unk34; + /* 0x38 */ f32 unk38; + /* 0x3C */ f32 unk3C; + /* 0x40 */ s16 unk40; + /* 0x42 */ s16 unk42; + /* 0x44 */ f32 unk44; + /* 0x48 */ s16 unk48; + /* 0x4A */ UNK_TYPE1 unk4A[0x2]; + /* 0x4C */ s16 unk4C; + /* 0x4E */ s16 unk4E; } AlienBehaviorInfo; // size = 0x50 typedef struct EnInvadepoh { @@ -148,7 +148,7 @@ typedef struct EnInvadepoh { /* 0x3A8 */ s16 scaleAdjAngle; /* 0x3AA */ s16 unk3AA; /* 0x3AC */ s8 unk3AC; // index for D_80B4EDD0 - /* 0x3AD */ char unk3AD[0xF]; + /* 0x3AD */ UNK_TYPE1 unk3AD[0xF]; /* 0x3BC */ s8 unk3BC; } EnInvadepoh; // size = 0x3C0 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 5696764dd..4391beecd 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 @@ -10,17 +10,17 @@ #define THIS ((EnInvadepohDemo*)thisx) -void EnInvadepohDemo_Init(Actor* thisx, GlobalContext* globalCtx); -void EnInvadepohDemo_Destroy(Actor* thisx, GlobalContext* globalCtx); -void EnInvadepohDemo_Update(Actor* thisx, GlobalContext* globalCtx); -void EnInvadepohDemo_Draw(Actor* thisx, GlobalContext* globalCtx); +void EnInvadepohDemo_Init(Actor* thisx, PlayState* play); +void EnInvadepohDemo_Destroy(Actor* thisx, PlayState* play); +void EnInvadepohDemo_Update(Actor* thisx, PlayState* play); +void EnInvadepohDemo_Draw(Actor* thisx, PlayState* play); -void func_80C19AB4(EnInvadepohDemo* this, GlobalContext* globalCtx); -void func_80C19D00(EnInvadepohDemo* this, GlobalContext* globalCtx); -void func_80C19D48(EnInvadepohDemo* this, GlobalContext* globalCtx); -void func_80C19E04(EnInvadepohDemo* this, GlobalContext* globalCtx); -void func_80C19EC0(EnInvadepohDemo* this, GlobalContext* globalCtx); -void func_80C19F7C(EnInvadepohDemo* this, GlobalContext* globalCtx); +void func_80C19AB4(EnInvadepohDemo* this, PlayState* play); +void func_80C19D00(EnInvadepohDemo* this, PlayState* play); +void func_80C19D48(EnInvadepohDemo* this, PlayState* play); +void func_80C19E04(EnInvadepohDemo* this, PlayState* play); +void func_80C19EC0(EnInvadepohDemo* this, PlayState* play); +void func_80C19F7C(EnInvadepohDemo* this, PlayState* play); #if 0 const ActorInit En_Invadepoh_Demo_InitVars = { diff --git a/src/overlays/actors/ovl_En_Invadepoh_Demo/z_en_invadepoh_demo.h b/src/overlays/actors/ovl_En_Invadepoh_Demo/z_en_invadepoh_demo.h index df29dbc60..35cbb4da9 100644 --- a/src/overlays/actors/ovl_En_Invadepoh_Demo/z_en_invadepoh_demo.h +++ b/src/overlays/actors/ovl_En_Invadepoh_Demo/z_en_invadepoh_demo.h @@ -5,12 +5,12 @@ struct EnInvadepohDemo; -typedef void (*EnInvadepohDemoActionFunc)(struct EnInvadepohDemo*, GlobalContext*); +typedef void (*EnInvadepohDemoActionFunc)(struct EnInvadepohDemo*, PlayState*); typedef struct EnInvadepohDemo { - /* 0x0000 */ Actor actor; - /* 0x0144 */ EnInvadepohDemoActionFunc actionFunc; - /* 0x0148 */ char unk_148[0x180]; + /* 0x000 */ Actor actor; + /* 0x144 */ EnInvadepohDemoActionFunc actionFunc; + /* 0x148 */ char unk_148[0x180]; } EnInvadepohDemo; // size = 0x2C8 extern const ActorInit En_Invadepoh_Demo_InitVars; diff --git a/src/overlays/actors/ovl_En_Invisible_Ruppe/z_en_invisible_ruppe.c b/src/overlays/actors/ovl_En_Invisible_Ruppe/z_en_invisible_ruppe.c index 360927533..d7bda5180 100644 --- a/src/overlays/actors/ovl_En_Invisible_Ruppe/z_en_invisible_ruppe.c +++ b/src/overlays/actors/ovl_En_Invisible_Ruppe/z_en_invisible_ruppe.c @@ -10,13 +10,13 @@ #define THIS ((EnInvisibleRuppe*)thisx) -void EnInvisibleRuppe_Init(Actor* thisx, GlobalContext* globalCtx); -void EnInvisibleRuppe_Destroy(Actor* thisx, GlobalContext* globalCtx); -void EnInvisibleRuppe_Update(Actor* thisx, GlobalContext* globalCtx); +void EnInvisibleRuppe_Init(Actor* thisx, PlayState* play); +void EnInvisibleRuppe_Destroy(Actor* thisx, PlayState* play); +void EnInvisibleRuppe_Update(Actor* thisx, PlayState* play); -void func_80C258A0(EnInvisibleRuppe* this, GlobalContext* globalCtx); -void func_80C2590C(EnInvisibleRuppe* this, GlobalContext* globalCtx); -void func_80C259E8(EnInvisibleRuppe* this, GlobalContext* globalCtx); +void func_80C258A0(EnInvisibleRuppe* this, PlayState* play); +void func_80C2590C(EnInvisibleRuppe* this, PlayState* play); +void func_80C259E8(EnInvisibleRuppe* this, PlayState* play); const ActorInit En_Invisible_Ruppe_InitVars = { ACTOR_EN_INVISIBLE_RUPPE, @@ -52,44 +52,44 @@ static ColliderCylinderInit sCylinderInit = { { 10, 30, 0, { 0, 0, 0 } }, }; -void func_80C258A0(EnInvisibleRuppe* this, GlobalContext* globalCtx) { +void func_80C258A0(EnInvisibleRuppe* this, PlayState* play) { 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); + CollisionCheck_SetOC(play, &play->colChkCtx, &this->collider.base); + Actor_UpdateBgCheckInfo(play, &this->actor, 32.0f, 30.0f, 0.0f, 4); } -void func_80C2590C(EnInvisibleRuppe* this, GlobalContext* globalCtx) { +void func_80C2590C(EnInvisibleRuppe* this, PlayState* play) { if (this->collider.base.ocFlags1 & OC1_HIT) { switch (INVISIBLERUPPE_GET_3(this)) { case 0: play_sound(NA_SE_SY_GET_RUPY); - Item_DropCollectible(globalCtx, &this->actor.world.pos, 0x8000 | ITEM00_RUPEE_GREEN); + Item_DropCollectible(play, &this->actor.world.pos, 0x8000 | ITEM00_RUPEE_GREEN); break; case 1: play_sound(NA_SE_SY_GET_RUPY); - Item_DropCollectible(globalCtx, &this->actor.world.pos, 0x8000 | ITEM00_RUPEE_BLUE); + Item_DropCollectible(play, &this->actor.world.pos, 0x8000 | ITEM00_RUPEE_BLUE); break; case 2: play_sound(NA_SE_SY_GET_RUPY); - Item_DropCollectible(globalCtx, &this->actor.world.pos, 0x8000 | ITEM00_RUPEE_RED); + Item_DropCollectible(play, &this->actor.world.pos, 0x8000 | ITEM00_RUPEE_RED); break; } if (this->unk_190 >= 0) { - Flags_SetSwitch(globalCtx, this->unk_190); + Flags_SetSwitch(play, this->unk_190); } this->actionFunc = func_80C259E8; } } -void func_80C259E8(EnInvisibleRuppe* this, GlobalContext* globalCtx) { +void func_80C259E8(EnInvisibleRuppe* this, PlayState* play) { Actor_MarkForDeath(&this->actor); } -void EnInvisibleRuppe_Init(Actor* thisx, GlobalContext* globalCtx) { +void EnInvisibleRuppe_Init(Actor* thisx, PlayState* play) { s32 pad; EnInvisibleRuppe* this = THIS; @@ -99,26 +99,26 @@ void EnInvisibleRuppe_Init(Actor* thisx, GlobalContext* globalCtx) { this->unk_190 = -1; } - if ((this->unk_190 >= 0) && Flags_GetSwitch(globalCtx, this->unk_190)) { + if ((this->unk_190 >= 0) && Flags_GetSwitch(play, this->unk_190)) { Actor_MarkForDeath(&this->actor); return; } - Collider_InitCylinder(globalCtx, &this->collider); - Collider_InitAndSetCylinder(globalCtx, &this->collider, &this->actor, &sCylinderInit); + Collider_InitCylinder(play, &this->collider); + Collider_InitAndSetCylinder(play, &this->collider, &this->actor, &sCylinderInit); this->actionFunc = func_80C2590C; } -void EnInvisibleRuppe_Destroy(Actor* thisx, GlobalContext* globalCtx) { +void EnInvisibleRuppe_Destroy(Actor* thisx, PlayState* play) { EnInvisibleRuppe* this = THIS; - Collider_DestroyCylinder(globalCtx, &this->collider); + Collider_DestroyCylinder(play, &this->collider); } -void EnInvisibleRuppe_Update(Actor* thisx, GlobalContext* globalCtx) { +void EnInvisibleRuppe_Update(Actor* thisx, PlayState* play) { EnInvisibleRuppe* this = THIS; - this->actionFunc(this, globalCtx); - func_80C258A0(this, globalCtx); + this->actionFunc(this, play); + func_80C258A0(this, play); } diff --git a/src/overlays/actors/ovl_En_Invisible_Ruppe/z_en_invisible_ruppe.h b/src/overlays/actors/ovl_En_Invisible_Ruppe/z_en_invisible_ruppe.h index eef1acbfe..49d9bd6ef 100644 --- a/src/overlays/actors/ovl_En_Invisible_Ruppe/z_en_invisible_ruppe.h +++ b/src/overlays/actors/ovl_En_Invisible_Ruppe/z_en_invisible_ruppe.h @@ -5,17 +5,17 @@ struct EnInvisibleRuppe; -typedef void (*EnInvisibleRuppeActionFunc)(struct EnInvisibleRuppe*, GlobalContext*); +typedef void (*EnInvisibleRuppeActionFunc)(struct EnInvisibleRuppe*, PlayState*); #define INVISIBLERUPPE_GET_3(thisx) ((thisx)->actor.params & 3) #define INVISIBLERUPPE_GET_1FC(thisx) (((thisx)->actor.params & 0x1FC) >> 2) typedef struct EnInvisibleRuppe { - /* 0x0000 */ Actor actor; - /* 0x0144 */ ColliderCylinder collider; - /* 0x0190 */ s16 unk_190; - /* 0x0192 */ s16 unk_192; - /* 0x0194 */ EnInvisibleRuppeActionFunc actionFunc; + /* 0x000 */ Actor actor; + /* 0x144 */ ColliderCylinder collider; + /* 0x190 */ s16 unk_190; + /* 0x192 */ s16 unk_192; + /* 0x194 */ EnInvisibleRuppeActionFunc actionFunc; } EnInvisibleRuppe; // size = 0x198 extern const ActorInit En_Invisible_Ruppe_InitVars; diff --git a/src/overlays/actors/ovl_En_Ishi/z_en_ishi.c b/src/overlays/actors/ovl_En_Ishi/z_en_ishi.c index ac42d0c7a..b44d1bb29 100644 --- a/src/overlays/actors/ovl_En_Ishi/z_en_ishi.c +++ b/src/overlays/actors/ovl_En_Ishi/z_en_ishi.c @@ -5,6 +5,7 @@ */ #include "z_en_ishi.h" +#include "z64rumble.h" #include "objects/gameplay_field_keep/gameplay_field_keep.h" #include "objects/gameplay_keep/gameplay_keep.h" #include "objects/object_ishi/object_ishi.h" @@ -13,30 +14,30 @@ #define THIS ((EnIshi*)thisx) -void EnIshi_Init(Actor* thisx, GlobalContext* globalCtx); -void EnIshi_Destroy(Actor* thisx, GlobalContext* globalCtx); -void EnIshi_Update(Actor* thisx, GlobalContext* globalCtx); +void EnIshi_Init(Actor* thisx, PlayState* play); +void EnIshi_Destroy(Actor* thisx, PlayState* play); +void EnIshi_Update(Actor* thisx, PlayState* play); -void func_8095D804(Actor* thisx, GlobalContext* globalCtx); -void func_8095DABC(Actor* thisx, GlobalContext* globalCtx); -void func_8095DDA8(EnIshi* this, GlobalContext* globalCtx); -void func_8095DE9C(EnIshi* this, GlobalContext* globalCtx); +void func_8095D804(Actor* thisx, PlayState* play); +void func_8095DABC(Actor* thisx, PlayState* play); +void func_8095DDA8(EnIshi* this, PlayState* play); +void func_8095DE9C(EnIshi* this, PlayState* play); void func_8095E5AC(EnIshi* this); -void func_8095E5C0(EnIshi* this, GlobalContext* globalCtx); +void func_8095E5C0(EnIshi* this, PlayState* play); void func_8095E64C(EnIshi* this); -void func_8095E660(EnIshi* this, GlobalContext* globalCtx); +void func_8095E660(EnIshi* this, PlayState* play); void func_8095E934(EnIshi* this); -void func_8095E95C(EnIshi* this, GlobalContext* globalCtx); +void func_8095E95C(EnIshi* this, PlayState* play); void func_8095EA70(EnIshi* this); -void func_8095EBDC(EnIshi* this, GlobalContext* globalCtx); +void func_8095EBDC(EnIshi* this, PlayState* play); void func_8095F060(EnIshi* this); -void func_8095F0A4(EnIshi* this, GlobalContext* globalCtx); +void func_8095F0A4(EnIshi* this, PlayState* play); void func_8095F180(EnIshi* this); -void func_8095F194(EnIshi* this, GlobalContext* globalCtx); -void func_8095F210(EnIshi* this, GlobalContext* globalCtx); -void func_8095F36C(EnIshi* this, GlobalContext* globalCtx); -void func_8095F61C(Actor* thisx, GlobalContext* globalCtx); -void func_8095F654(Actor* thisx, GlobalContext* globalCtx); +void func_8095F194(EnIshi* this, PlayState* play); +void func_8095F210(EnIshi* this, PlayState* play); +void func_8095F36C(EnIshi* this, PlayState* play); +void func_8095F61C(Actor* thisx, PlayState* play); +void func_8095F654(Actor* thisx, PlayState* play); static s16 D_8095F690 = 0; @@ -142,15 +143,15 @@ static u16 D_8095F7AC[] = { NA_SE_PL_PULL_UP_ROCK, NA_SE_PL_PULL_UP_BIGROCK }; static EnIshiUnkFunc D_8095F7B0[] = { func_8095F210, func_8095F36C }; -void func_8095D6E0(Actor* thisx, GlobalContext* globalCtx) { +void func_8095D6E0(Actor* thisx, PlayState* play) { EnIshi* this = THIS; - Collider_InitCylinder(globalCtx, &this->collider); - Collider_SetCylinder(globalCtx, &this->collider, &this->actor, &sCylinderInit[ENISHI_GET_1(&this->actor)]); + Collider_InitCylinder(play, &this->collider); + Collider_SetCylinder(play, &this->collider, &this->actor, &sCylinderInit[ENISHI_GET_1(&this->actor)]); Collider_UpdateCylinder(&this->actor, &this->collider); } -s32 func_8095D758(EnIshi* this, GlobalContext* globalCtx, f32 arg2) { +s32 func_8095D758(EnIshi* this, PlayState* play, f32 arg2) { Vec3f sp24; s32 sp20; @@ -158,7 +159,7 @@ s32 func_8095D758(EnIshi* this, GlobalContext* globalCtx, f32 arg2) { sp24.y = this->actor.world.pos.y + 30.0f; sp24.z = this->actor.world.pos.z; this->actor.floorHeight = - BgCheck_EntityRaycastFloor5(&globalCtx->colCtx, &this->actor.floorPoly, &sp20, &this->actor, &sp24); + BgCheck_EntityRaycastFloor5(&play->colCtx, &this->actor.floorPoly, &sp20, &this->actor, &sp24); if (this->actor.floorHeight > BGCHECK_Y_MIN) { this->actor.world.pos.y = this->actor.floorHeight + arg2; Math_Vec3f_Copy(&this->actor.home.pos, &this->actor.world.pos); @@ -167,7 +168,7 @@ s32 func_8095D758(EnIshi* this, GlobalContext* globalCtx, f32 arg2) { return false; } -void func_8095D804(Actor* thisx, GlobalContext* globalCtx) { +void func_8095D804(Actor* thisx, PlayState* play) { EnIshi* this = THIS; s32 i; s16 temp; @@ -203,12 +204,12 @@ 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], + EffectSsKakera_Spawn(play, &spB8, &spC4, &spB8, -420, ((s32)Rand_Next() > 0) ? 65 : 33, 30, 5, 0, D_8095F74C[i], 3, 10, 40, -1, temp, phi_s4); } } -void func_8095DABC(Actor* thisx, GlobalContext* globalCtx) { +void func_8095DABC(Actor* thisx, PlayState* play) { EnIshi* this = THIS; Vec3f spD8; Vec3f spCC; @@ -254,12 +255,12 @@ void func_8095DABC(Actor* thisx, GlobalContext* globalCtx) { phi_v1 = -320; } - EffectSsKakera_Spawn(globalCtx, &spCC, &spD8, &this->actor.world.pos, phi_v1, phi_v0, 30, 5, 0, D_8095F758[i], - 5, 2, 70, 0, GAMEPLAY_FIELD_KEEP, gameplay_field_keep_DL_006420); + EffectSsKakera_Spawn(play, &spCC, &spD8, &this->actor.world.pos, phi_v1, phi_v0, 30, 5, 0, D_8095F758[i], 5, 2, + 70, 0, GAMEPLAY_FIELD_KEEP, gameplay_field_keep_DL_006420); } } -void func_8095DDA8(EnIshi* this, GlobalContext* globalCtx) { +void func_8095DDA8(EnIshi* this, PlayState* play) { Vec3f sp2C; Math_Vec3f_Copy(&sp2C, &this->actor.world.pos); @@ -272,10 +273,10 @@ void func_8095DDA8(EnIshi* this, GlobalContext* globalCtx) { sp2C.y += 2.0f * this->actor.velocity.y; sp2C.z -= 2.0f * this->actor.velocity.z; } - func_800BBFB0(globalCtx, &sp2C, 60.0f, 3, 80, 60, 1); + func_800BBFB0(play, &sp2C, 60.0f, 3, 80, 60, 1); } -void func_8095DE9C(EnIshi* this, GlobalContext* globalCtx) { +void func_8095DE9C(EnIshi* this, PlayState* play) { Vec3f sp2C; Math_Vec3f_Copy(&sp2C, &this->actor.world.pos); @@ -288,16 +289,16 @@ void func_8095DE9C(EnIshi* this, GlobalContext* globalCtx) { sp2C.y += 2.0f * this->actor.velocity.y; sp2C.z -= 2.0f * this->actor.velocity.z; } - func_800BBFB0(globalCtx, &sp2C, 140.0f, 10, 180, 90, 1); + func_800BBFB0(play, &sp2C, 140.0f, 10, 180, 90, 1); } -void func_8095DF90(EnIshi* this, GlobalContext* globalCtx) { +void func_8095DF90(EnIshi* this, PlayState* play) { if (!ENISHI_GET_1(&this->actor) && !ENISHI_GET_100(&this->actor)) { - Item_DropCollectibleRandom(globalCtx, NULL, &this->actor.world.pos, ENISHI_GET_F0(&this->actor) * 0x10); + Item_DropCollectibleRandom(play, NULL, &this->actor.world.pos, ENISHI_GET_F0(&this->actor) * 0x10); } } -void func_8095DFF0(EnIshi* this, GlobalContext* globalCtx) { +void func_8095DFF0(EnIshi* this, PlayState* play) { s32 pad; s32 temp = D_8095F76C[ENISHI_GET_70(&this->actor)]; Actor* sp3C; @@ -307,13 +308,13 @@ void func_8095DFF0(EnIshi* this, GlobalContext* globalCtx) { s16 temp_v1_2; if (temp >= 0) { - sp3C = Item_DropCollectible(globalCtx, &this->actor.world.pos, temp | (ENISHI_GET_FE00(&this->actor) << 8)); + sp3C = Item_DropCollectible(play, &this->actor.world.pos, temp | (ENISHI_GET_FE00(&this->actor) << 8)); if (sp3C != NULL) { - Matrix_StatePush(); - Matrix_RotateY(this->actor.shape.rot.y, MTXMODE_NEW); - Matrix_InsertXRotation_s(this->actor.shape.rot.x, MTXMODE_APPLY); - Matrix_InsertZRotation_s(this->actor.shape.rot.z, MTXMODE_APPLY); - Matrix_GetStateTranslationAndScaledY(1.0f, &sp30); + 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 +327,7 @@ void func_8095DFF0(EnIshi* this, GlobalContext* globalCtx) { } sp3C->velocity.y *= temp_f2; } - Matrix_StatePop(); + Matrix_Pop(); } } } @@ -346,11 +347,11 @@ void func_8095E180(Vec3f* arg0, f32 arg1) { arg0->z -= arg0->z * arg1; } -void func_8095E204(EnIshi* this, GlobalContext* globalCtx) { +void func_8095E204(EnIshi* this, PlayState* play) { s32 i; for (i = 0; i < 3; i++) { - if (Actor_SpawnAsChildAndCutscene(&globalCtx->actorCtx, globalCtx, ACTOR_EN_INSECT, this->actor.world.pos.x, + if (Actor_SpawnAsChildAndCutscene(&play->actorCtx, play, ACTOR_EN_INSECT, this->actor.world.pos.x, this->actor.world.pos.y, this->actor.world.pos.z, 0, 0, 0, 1, this->actor.cutscene, this->actor.unk20, NULL) == NULL) { break; @@ -358,21 +359,21 @@ void func_8095E204(EnIshi* this, GlobalContext* globalCtx) { } } -s32 func_8095E2B0(EnIshi* this, GlobalContext* globalCtx) { +s32 func_8095E2B0(EnIshi* this, PlayState* play) { 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) && + if (WaterBox_GetSurfaceImpl(play, &play->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 EnIshi_Init(Actor* thisx, GlobalContext* globalCtx) { +void EnIshi_Init(Actor* thisx, PlayState* play) { s32 pad; EnIshi* this = THIS; s32 sp34 = ENISHI_GET_1(&this->actor); @@ -384,18 +385,18 @@ void EnIshi_Init(Actor* thisx, GlobalContext* globalCtx) { Actor_ProcessInitChain(&this->actor, sInitChain[sp34]); - if (globalCtx->csCtx.state != 0) { + if (play->csCtx.state != 0) { this->actor.uncullZoneForward += 1000.0f; } if ((this->actor.shape.rot.y == 0) && !(this->unk_197 & 2)) { - this->actor.shape.rot.y = this->actor.world.rot.y = (u32)Rand_Next() >> 0x10; + this->actor.shape.rot.y = this->actor.world.rot.y = Rand_Next() >> 0x10; } Actor_SetScale(&this->actor, D_8095F6B8[sp34]); - func_8095D6E0(&this->actor, globalCtx); + func_8095D6E0(&this->actor, play); - if ((sp34 == 1) && Flags_GetSwitch(globalCtx, ENISHI_GET_FE00(&this->actor))) { + if ((sp34 == 1) && Flags_GetSwitch(play, ENISHI_GET_FE00(&this->actor))) { Actor_MarkForDeath(&this->actor); return; } @@ -412,16 +413,16 @@ void EnIshi_Init(Actor* thisx, GlobalContext* globalCtx) { this->actor.shape.yOffset = D_8095F6C0[sp34]; - if ((sp30 == 0) && !func_8095D758(this, globalCtx, 0)) { + if ((sp30 == 0) && !func_8095D758(this, play, 0)) { Actor_MarkForDeath(&this->actor); return; } - if (func_8095E2B0(this, globalCtx)) { + if (func_8095E2B0(this, play)) { this->unk_197 |= 1; } - this->unk_196 = Object_GetIndex(&globalCtx->objectCtx, D_8095F6E8[ENISHI_GET_8(&this->actor)]); + this->unk_196 = Object_GetIndex(&play->objectCtx, D_8095F6E8[ENISHI_GET_8(&this->actor)]); if (this->unk_196 < 0) { Actor_MarkForDeath(&this->actor); return; @@ -430,19 +431,19 @@ void EnIshi_Init(Actor* thisx, GlobalContext* globalCtx) { func_8095E5AC(this); } -void EnIshi_Destroy(Actor* thisx, GlobalContext* globalCtx2) { - GlobalContext* globalCtx = globalCtx2; +void EnIshi_Destroy(Actor* thisx, PlayState* play2) { + PlayState* play = play2; EnIshi* this = THIS; - Collider_DestroyCylinder(globalCtx, &this->collider); + Collider_DestroyCylinder(play, &this->collider); } void func_8095E5AC(EnIshi* this) { this->actionFunc = func_8095E5C0; } -void func_8095E5C0(EnIshi* this, GlobalContext* globalCtx) { - if (Object_IsLoaded(&globalCtx->objectCtx, this->unk_196)) { +void func_8095E5C0(EnIshi* this, PlayState* play) { + if (Object_IsLoaded(&play->objectCtx, this->unk_196)) { this->actor.objBankIndex = this->unk_196; this->actor.flags &= ~ACTOR_FLAG_10; if (!ENISHI_GET_8(&this->actor)) { @@ -458,7 +459,7 @@ void func_8095E64C(EnIshi* this) { this->actionFunc = func_8095E660; } -void func_8095E660(EnIshi* this, GlobalContext* globalCtx) { +void func_8095E660(EnIshi* this, PlayState* play) { s32 pad; s32 sp38 = ENISHI_GET_1(&this->actor); s32 sp34 = (this->collider.base.acFlags & AC_HIT) != 0; @@ -468,11 +469,11 @@ void func_8095E660(EnIshi* this, GlobalContext* globalCtx) { this->collider.base.acFlags &= ~AC_HIT; } - if (Actor_HasParent(&this->actor, globalCtx)) { + if (Actor_HasParent(&this->actor, play)) { func_8095E934(this); - SoundSource_PlaySfxAtFixedWorldPos(globalCtx, &this->actor.world.pos, 20, D_8095F7AC[sp38]); + SoundSource_PlaySfxAtFixedWorldPos(play, &this->actor.world.pos, 20, D_8095F7AC[sp38]); if (ENISHI_GET_2(&this->actor)) { - func_8095E204(this, globalCtx); + func_8095E204(this, play); } this->actor.shape.shadowDraw = ActorShadow_DrawCircle; return; @@ -480,14 +481,14 @@ void func_8095E660(EnIshi* this, GlobalContext* globalCtx) { if (sp34 && (sp38 == 0) && (this->collider.info.acHitInfo->toucher.dmgFlags & 0x508)) { if (sp30 != 0) { - func_8095DFF0(this, globalCtx); + func_8095DFF0(this, play); func_8095F060(this); return; } - func_8095DF90(this, globalCtx); - SoundSource_PlaySfxAtFixedWorldPos(globalCtx, &this->actor.world.pos, D_8095F6D4[sp38], D_8095F6D0[sp38]); - D_8095F6D8[sp38](&this->actor, globalCtx); - D_8095F6E0[sp38](this, globalCtx); + func_8095DF90(this, play); + SoundSource_PlaySfxAtFixedWorldPos(play, &this->actor.world.pos, D_8095F6D4[sp38], D_8095F6D0[sp38]); + D_8095F6D8[sp38](&this->actor, play); + D_8095F6E0[sp38](this, play); Actor_MarkForDeath(&this->actor); return; } @@ -506,14 +507,14 @@ void func_8095E660(EnIshi* this, GlobalContext* globalCtx) { } } - CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); - CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + CollisionCheck_SetAC(play, &play->colChkCtx, &this->collider.base); + CollisionCheck_SetOC(play, &play->colChkCtx, &this->collider.base); if ((this->actor.xzDistToPlayer < 90.0f) && (sp30 == 0)) { if (sp38 == 1) { - Actor_PickUp(&this->actor, globalCtx, GI_NONE, 80.0f, 20.0f); + Actor_PickUp(&this->actor, play, GI_NONE, 80.0f, 20.0f); } else { - Actor_PickUp(&this->actor, globalCtx, GI_NONE, 50.0f, 10.0f); + Actor_PickUp(&this->actor, play, GI_NONE, 50.0f, 10.0f); } } } @@ -525,27 +526,27 @@ void func_8095E934(EnIshi* this) { this->actor.flags |= ACTOR_FLAG_10; } -void func_8095E95C(EnIshi* this, GlobalContext* globalCtx) { +void func_8095E95C(EnIshi* this, PlayState* play) { s32 pad; Vec3f sp30; s32 sp2C; - if (Actor_HasNoParent(&this->actor, globalCtx)) { - this->actor.room = globalCtx->roomCtx.currRoom.num; + if (Actor_HasNoParent(&this->actor, play)) { + this->actor.room = play->roomCtx.currRoom.num; if (ENISHI_GET_1(&this->actor) == 1) { - Flags_SetSwitch(globalCtx, ENISHI_GET_FE00(&this->actor)); + Flags_SetSwitch(play, ENISHI_GET_FE00(&this->actor)); } func_8095EA70(this); func_8095E14C(this); func_8095E180(&this->actor.velocity, D_8095F6C8[ENISHI_GET_1(&this->actor)]); Actor_UpdatePos(&this->actor); - Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 7.5f, 35.0f, 0.0f, 0xC5); + Actor_UpdateBgCheckInfo(play, &this->actor, 7.5f, 35.0f, 0.0f, 0xC5); } else { sp30.x = this->actor.world.pos.x; sp30.y = this->actor.world.pos.y + 20.0f; sp30.z = this->actor.world.pos.z; this->actor.floorHeight = - BgCheck_EntityRaycastFloor5(&globalCtx->colCtx, &this->actor.floorPoly, &sp2C, &this->actor, &sp30); + BgCheck_EntityRaycastFloor5(&play->colCtx, &this->actor.floorPoly, &sp2C, &this->actor, &sp30); } } @@ -568,7 +569,7 @@ void func_8095EA70(EnIshi* this) { this->actionFunc = func_8095EBDC; } -void func_8095EBDC(EnIshi* this, GlobalContext* globalCtx) { +void func_8095EBDC(EnIshi* this, PlayState* play) { s32 pad; s32 sp70 = ENISHI_GET_1(&this->actor); s16 temp_s0; @@ -584,21 +585,21 @@ void func_8095EBDC(EnIshi* this, GlobalContext* globalCtx) { this->unk_194--; if ((this->actor.bgCheckFlags & 9) || temp_v0 || (this->unk_194 <= 0)) { - func_8095DF90(this, globalCtx); - D_8095F6D8[sp70](&this->actor, globalCtx); + func_8095DF90(this, play); + D_8095F6D8[sp70](&this->actor, play); if (!(this->actor.bgCheckFlags & 0x20)) { - SoundSource_PlaySfxAtFixedWorldPos(globalCtx, &this->actor.world.pos, D_8095F6D4[sp70], D_8095F6D0[sp70]); - D_8095F6E0[sp70](this, globalCtx); + SoundSource_PlaySfxAtFixedWorldPos(play, &this->actor.world.pos, D_8095F6D4[sp70], D_8095F6D0[sp70]); + D_8095F6E0[sp70](this, play); } if (sp70 == 1) { - s16 quake = Quake_Add(GET_ACTIVE_CAM(globalCtx), 3); + s16 quake = Quake_Add(GET_ACTIVE_CAM(play), 3); Quake_SetSpeed(quake, 0x4350); Quake_SetQuakeValues(quake, 3, 0, 0, 0); Quake_SetCountdown(quake, 7); - func_8013ECE0(this->actor.xyzDistToPlayerSq, 255, 20, 150); + Rumble_Request(this->actor.xyzDistToPlayerSq, 255, 20, 150); } Actor_MarkForDeath(&this->actor); @@ -610,20 +611,20 @@ void func_8095EBDC(EnIshi* this, GlobalContext* globalCtx) { sp58.x = this->actor.world.pos.x; sp58.y = this->actor.world.pos.y + this->actor.depthInWater; sp58.z = this->actor.world.pos.z; - EffectSsGSplash_Spawn(globalCtx, &sp58, NULL, NULL, 0, 350); - EffectSsGRipple_Spawn(globalCtx, &sp58, 150, 650, 0); + EffectSsGSplash_Spawn(play, &sp58, NULL, NULL, 0, 350); + EffectSsGRipple_Spawn(play, &sp58, 150, 650, 0); } else { sp58.y = this->actor.world.pos.y + this->actor.depthInWater; for (phi_s0 = 0, i = 0; i < 11; i++, phi_s0 += 0x1746) { sp58.x = (Math_SinS((s32)(Rand_ZeroOne() * 2000.0f) + phi_s0) * 50.0f) + this->actor.world.pos.x; sp58.z = (Math_CosS((s32)(Rand_ZeroOne() * 2000.0f) + phi_s0) * 50.0f) + this->actor.world.pos.z; - EffectSsGSplash_Spawn(globalCtx, &sp58, NULL, NULL, 0, 350); + EffectSsGSplash_Spawn(play, &sp58, NULL, NULL, 0, 350); } sp58.x = this->actor.world.pos.x; sp58.z = this->actor.world.pos.z; - EffectSsGRipple_Spawn(globalCtx, &sp58, 500, 900, 4); + EffectSsGRipple_Spawn(play, &sp58, 500, 900, 4); } this->actor.terminalVelocity = -6.0f; @@ -635,7 +636,7 @@ void func_8095EBDC(EnIshi* this, GlobalContext* globalCtx) { D_8095F690 >>= 2; D_8095F694 >>= 2; - SoundSource_PlaySfxAtFixedWorldPos(globalCtx, &this->actor.world.pos, 40, NA_SE_EV_DIVE_INTO_WATER_L); + SoundSource_PlaySfxAtFixedWorldPos(play, &this->actor.world.pos, 40, NA_SE_EV_DIVE_INTO_WATER_L); this->actor.bgCheckFlags &= ~0x40; } @@ -645,10 +646,10 @@ void func_8095EBDC(EnIshi* this, GlobalContext* globalCtx) { Actor_UpdatePos(&this->actor); this->actor.shape.rot.x += D_8095F690; this->actor.shape.rot.y += D_8095F694; - Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 7.5f, 35.0f, 0.0f, 0xC5); + Actor_UpdateBgCheckInfo(play, &this->actor, 7.5f, 35.0f, 0.0f, 0xC5); Collider_UpdateCylinder(&this->actor, &this->collider); - CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); - CollisionCheck_SetAT(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + CollisionCheck_SetOC(play, &play->colChkCtx, &this->collider.base); + CollisionCheck_SetAT(play, &play->colChkCtx, &this->collider.base); } void func_8095F060(EnIshi* this) { @@ -657,15 +658,15 @@ void func_8095F060(EnIshi* this) { this->actionFunc = func_8095F0A4; } -void func_8095F0A4(EnIshi* this, GlobalContext* globalCtx) { +void func_8095F0A4(EnIshi* this, PlayState* play) { s32 pad; s32 sp28 = ENISHI_GET_1(&this->actor); if (ActorCutscene_GetCanPlayNext(this->actor.cutscene)) { ActorCutscene_StartAndSetUnkLinkFields(this->actor.cutscene, &this->actor); - SoundSource_PlaySfxAtFixedWorldPos(globalCtx, &this->actor.world.pos, D_8095F6D4[sp28], D_8095F6D0[sp28]); - D_8095F6D8[sp28](&this->actor, globalCtx); - D_8095F6E0[sp28](this, globalCtx); + SoundSource_PlaySfxAtFixedWorldPos(play, &this->actor.world.pos, D_8095F6D4[sp28], D_8095F6D0[sp28]); + D_8095F6D8[sp28](&this->actor, play); + D_8095F6E0[sp28](this, play); this->actor.draw = NULL; func_8095F180(this); } else { @@ -677,7 +678,7 @@ void func_8095F180(EnIshi* this) { this->actionFunc = func_8095F194; } -void func_8095F194(EnIshi* this, GlobalContext* globalCtx) { +void func_8095F194(EnIshi* this, PlayState* play) { if (this->actor.cutscene < 0) { Actor_MarkForDeath(&this->actor); } else if (ActorCutscene_GetCurrentIndex() != this->actor.cutscene) { @@ -685,48 +686,48 @@ void func_8095F194(EnIshi* this, GlobalContext* globalCtx) { } } -void EnIshi_Update(Actor* thisx, GlobalContext* globalCtx) { +void EnIshi_Update(Actor* thisx, PlayState* play) { EnIshi* this = THIS; - this->actionFunc(this, globalCtx); + this->actionFunc(this, play); } -void func_8095F210(EnIshi* this, GlobalContext* globalCtx) { +void func_8095F210(EnIshi* this, PlayState* play) { s32 pad; s32 sp28; if ((this->actor.projectedPos.z <= 1200.0f) || ((this->unk_197 & 1) && (this->actor.projectedPos.z < 1300.0f))) { - Gfx_DrawDListOpa(globalCtx, gameplay_field_keep_DL_0066B0); + Gfx_DrawDListOpa(play, gameplay_field_keep_DL_0066B0); return; } if (this->actor.projectedPos.z < 1300.0f) { - OPEN_DISPS(globalCtx->state.gfxCtx); + OPEN_DISPS(play->state.gfxCtx); - func_8012C2DC(globalCtx->state.gfxCtx); + func_8012C2DC(play->state.gfxCtx); sp28 = (1300.0f - this->actor.projectedPos.z) * 2.55f; - gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 255, 255, 255, (s32)sp28); gSPDisplayList(POLY_XLU_DISP++, gameplay_field_keep_DL_006760); - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->state.gfxCtx); } } -void func_8095F36C(EnIshi* this, GlobalContext* globalCtx) { +void func_8095F36C(EnIshi* this, PlayState* play) { s32 pad; - OPEN_DISPS(globalCtx->state.gfxCtx); + OPEN_DISPS(play->state.gfxCtx); if ((this->actor.projectedPos.z <= 2150.0f) || ((this->unk_197 & 1) && (this->actor.projectedPos.z < 2250.0f))) { this->actor.shape.shadowAlpha = 160; - func_8012C28C(globalCtx->state.gfxCtx); + func_8012C28C(play->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); + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, 255, 255, 255, 255); gSPDisplayList(POLY_OPA_DISP++, gameplay_field_keep_DL_0061E8); } else if (this->actor.projectedPos.z < 2250.0f) { @@ -734,25 +735,25 @@ void func_8095F36C(EnIshi* this, GlobalContext* globalCtx) { this->actor.shape.shadowAlpha = sp20 * 0.627451f; - func_8012C2DC(globalCtx->state.gfxCtx); + func_8012C2DC(play->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); + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 255, 255, 255, (s32)sp20); gSPDisplayList(POLY_XLU_DISP++, gameplay_field_keep_DL_0061E8); } else { this->actor.shape.shadowAlpha = 0; } - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->state.gfxCtx); } -void func_8095F61C(Actor* thisx, GlobalContext* globalCtx) { +void func_8095F61C(Actor* thisx, PlayState* play) { EnIshi* this = THIS; - D_8095F7B0[ENISHI_GET_1(&this->actor)](this, globalCtx); + D_8095F7B0[ENISHI_GET_1(&this->actor)](this, play); } -void func_8095F654(Actor* thisx, GlobalContext* globalCtx) { - Gfx_DrawDListOpa(globalCtx, object_ishi_DL_0009B0); +void func_8095F654(Actor* thisx, PlayState* play) { + Gfx_DrawDListOpa(play, object_ishi_DL_0009B0); } diff --git a/src/overlays/actors/ovl_En_Ishi/z_en_ishi.h b/src/overlays/actors/ovl_En_Ishi/z_en_ishi.h index 404fec2b1..080abbf4a 100644 --- a/src/overlays/actors/ovl_En_Ishi/z_en_ishi.h +++ b/src/overlays/actors/ovl_En_Ishi/z_en_ishi.h @@ -5,9 +5,9 @@ struct EnIshi; -typedef void (*EnIshiActionFunc)(struct EnIshi*, GlobalContext*); -typedef void (*EnIshiUnkFunc)(struct EnIshi*, GlobalContext*); -typedef void (*EnIshiUnkFunc2)(Actor*, GlobalContext*); +typedef void (*EnIshiActionFunc)(struct EnIshi*, PlayState*); +typedef void (*EnIshiUnkFunc)(struct EnIshi*, PlayState*); +typedef void (*EnIshiUnkFunc2)(Actor*, PlayState*); #define ENISHI_GET_1(thisx) ((thisx)->params & 1) #define ENISHI_GET_2(thisx) (((thisx)->params >> 1) & 1) @@ -19,13 +19,13 @@ typedef void (*EnIshiUnkFunc2)(Actor*, GlobalContext*); #define ENISHI_GET_FE00(thisx) (((thisx)->params >> 9) & 0x7F) typedef struct EnIshi { - /* 0x0000 */ Actor actor; - /* 0x0144 */ ColliderCylinder collider; - /* 0x0190 */ EnIshiActionFunc actionFunc; - /* 0x0194 */ s8 unk_194; - /* 0x0195 */ s8 unk_195; - /* 0x0196 */ s8 unk_196; - /* 0x0197 */ u8 unk_197; + /* 0x000 */ Actor actor; + /* 0x144 */ ColliderCylinder collider; + /* 0x190 */ EnIshiActionFunc actionFunc; + /* 0x194 */ s8 unk_194; + /* 0x195 */ s8 unk_195; + /* 0x196 */ s8 unk_196; + /* 0x197 */ u8 unk_197; } EnIshi; // size = 0x198 extern const ActorInit En_Ishi_InitVars; diff --git a/src/overlays/actors/ovl_En_Ja/z_en_ja.c b/src/overlays/actors/ovl_En_Ja/z_en_ja.c index 392d8091e..f615c05fe 100644 --- a/src/overlays/actors/ovl_En_Ja/z_en_ja.c +++ b/src/overlays/actors/ovl_En_Ja/z_en_ja.c @@ -11,19 +11,27 @@ #define THIS ((EnJa*)thisx) -void EnJa_Init(Actor* thisx, GlobalContext* globalCtx); -void EnJa_Destroy(Actor* thisx, GlobalContext* globalCtx); -void EnJa_Update(Actor* thisx, GlobalContext* globalCtx); -void EnJa_Draw(Actor* thisx, GlobalContext* globalCtx); +void EnJa_Init(Actor* thisx, PlayState* play); +void EnJa_Destroy(Actor* thisx, PlayState* play); +void EnJa_Update(Actor* thisx, PlayState* play); +void EnJa_Draw(Actor* thisx, PlayState* play); -void func_80BC21A8(EnJa* this, GlobalContext* globalCtx); -void func_80BC22F4(EnJa* this, GlobalContext* globalCtx); +void func_80BC21A8(EnJa* this, PlayState* play); +void func_80BC22F4(EnJa* this, PlayState* play); void func_80BC2EA4(EnJa* this); -void func_80BC32D8(EnJa* this, GlobalContext* globalCtx); -void func_80BC3594(EnJa* this, GlobalContext* globalCtx); +void func_80BC32D8(EnJa* this, PlayState* play); +void func_80BC3594(EnJa* this, PlayState* play); -s32 D_80BC35F0[] = { - 0x0C000301, 0x05020600, 0x1200080A, 0x00610304, 0x0002050A, 0x006C0304, 0x00010500, +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[] = { @@ -81,7 +89,7 @@ static ColliderCylinderInit sCylinderInit = { static CollisionCheckInfoInit2 sColChkInfoInit = { 0, 0, 0, 0, MASS_IMMOVABLE }; -static AnimationInfoS sAnimations[] = { +static AnimationInfoS sAnimationInfo[] = { { &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 }, @@ -97,25 +105,25 @@ s32 func_80BC192C(EnJa* this, s32 arg1) { if (arg1 != this->unk_36C) { this->unk_36C = arg1; - ret = SubS_ChangeAnimationByInfoS(&this->skelAnime, sAnimations, arg1); + ret = SubS_ChangeAnimationByInfoS(&this->skelAnime, sAnimationInfo, arg1); this->unk_344 = this->skelAnime.playSpeed; } return ret; } -void func_80BC1984(EnJa* this, GlobalContext* globalCtx) { +void func_80BC1984(EnJa* this, PlayState* play) { s32 pad[2]; 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); + CollisionCheck_SetOC(play, &play->colChkCtx, &this->collider.base); } -s32 func_80BC19FC(EnJa* this, GlobalContext* globalCtx) { +s32 func_80BC19FC(EnJa* this, PlayState* play) { s32 ret = false; - if ((this->unk_340 & 7) && Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { + if ((this->unk_340 & 7) && Actor_ProcessTalkRequest(&this->actor, &play->state)) { SubS_UpdateFlags(&this->unk_340, 0, 7); this->actionFunc = func_80BC22F4; ret = true; @@ -133,8 +141,8 @@ void func_80BC1A68(EnJa* this) { } } -s32 func_80BC1AE0(EnJa* this, GlobalContext* globalCtx) { - Actor* ja = SubS_FindNearestActor(&this->actor, globalCtx, ACTORCAT_NPC, ACTOR_EN_JA); +s32 func_80BC1AE0(EnJa* this, PlayState* play) { + Actor* ja = SubS_FindNearestActor(&this->actor, play, ACTORCAT_NPC, ACTOR_EN_JA); Vec3f sp30; Vec3f sp24; @@ -149,11 +157,11 @@ s32 func_80BC1AE0(EnJa* this, GlobalContext* globalCtx) { return this->actor.child; } -Player* func_80BC1B50(EnJa* this, GlobalContext* globalCtx) { - return GET_PLAYER(globalCtx); +Player* func_80BC1B50(EnJa* this, PlayState* play) { + return GET_PLAYER(play); } -s32 func_80BC1B60(EnJa* this, GlobalContext* globalCtx) { +s32 func_80BC1B60(EnJa* this, PlayState* play) { s32 pad; Vec3f sp40; Vec3f sp34; @@ -184,11 +192,11 @@ s32 func_80BC1B60(EnJa* this, GlobalContext* globalCtx) { return true; } -s32 func_80BC1D70(EnJa* this, GlobalContext* globalCtx) { +s32 func_80BC1D70(EnJa* this, PlayState* play) { if (this->unk_340 & 8) { - this->unk_1D8.player = func_80BC1B50(this, globalCtx); + this->unk_1D8.player = func_80BC1B50(this, play); if (this->unk_1D8.player != NULL) { - func_80BC1B60(this, globalCtx); + func_80BC1B60(this, play); } this->unk_340 &= ~0x10; this->unk_340 |= 0x20; @@ -206,14 +214,14 @@ s32 func_80BC1D70(EnJa* this, GlobalContext* globalCtx) { return true; } -void func_80BC1E40(EnJa* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); - s32 sp20 = Message_GetState(&globalCtx->msgCtx); +void func_80BC1E40(EnJa* this, PlayState* play) { + Player* player = GET_PLAYER(play); + s32 talkState = Message_GetState(&play->msgCtx); f32 phi_f0; - 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 (((play->msgCtx.currentTextId < 0xFF) || (play->msgCtx.currentTextId > 0x200)) && (talkState == TEXT_STATE_3) && + (this->prevTalkState == TEXT_STATE_3) && (&this->actor == player->targetActor)) { + if ((play->state.frames % 2) == 0) { if (this->unk_348 != 0.0f) { this->unk_348 = 0.0f; } else { @@ -227,14 +235,14 @@ void func_80BC1E40(EnJa* this, GlobalContext* globalCtx) { this->unk_34C += (this->unk_348 != 0.0f) ? 60.0f : -60.0f; this->unk_34C = CLAMP(this->unk_34C, 0.0f, 120.0f); - Matrix_InsertTranslation(this->unk_34C, 0.0f, 0.0f, MTXMODE_APPLY); - this->unk_374 = sp20; + Matrix_Translate(this->unk_34C, 0.0f, 0.0f, MTXMODE_APPLY); + this->prevTalkState = talkState; } -s32 func_80BC1FC8(EnJa* this, GlobalContext* globalCtx, struct_80133038_arg2* arg2) { +s32 func_80BC1FC8(EnJa* this, PlayState* play, ScheduleOutput* scheduleOutput) { s32 ret = false; - if (func_80BC1AE0(this, globalCtx)) { + if (func_80BC1AE0(this, play)) { SubS_UpdateFlags(&this->unk_340, 3, 7); this->unk_340 |= 0x10; func_80BC192C(this, 5); @@ -244,10 +252,10 @@ s32 func_80BC1FC8(EnJa* this, GlobalContext* globalCtx, struct_80133038_arg2* ar return ret; } -s32 func_80BC203C(EnJa* this, GlobalContext* globalCtx, struct_80133038_arg2* arg2) { +s32 func_80BC203C(EnJa* this, PlayState* play, ScheduleOutput* scheduleOutput) { s32 ret = false; - if (func_80BC1AE0(this, globalCtx)) { + if (func_80BC1AE0(this, play)) { if (ENJA_GET_3(&this->actor) == 0) { func_80BC192C(this, 1); } else { @@ -261,54 +269,53 @@ s32 func_80BC203C(EnJa* this, GlobalContext* globalCtx, struct_80133038_arg2* ar return ret; } -s32 func_80BC20D0(EnJa* this, GlobalContext* globalCtx, struct_80133038_arg2* arg2) { +s32 func_80BC20D0(EnJa* this, PlayState* play, ScheduleOutput* scheduleOutput) { s32 ret = false; this->unk_340 = 0; - switch (arg2->unk0) { + switch (scheduleOutput->result) { case 1: - ret = func_80BC1FC8(this, globalCtx, arg2); - if (ret == 1) {} + ret = func_80BC1FC8(this, play, scheduleOutput); + if (ret == true) {} break; case 2: - ret = func_80BC203C(this, globalCtx, arg2); + ret = func_80BC203C(this, play, scheduleOutput); break; } return ret; } -s32 func_80BC213C(EnJa* this, GlobalContext* globalCtx) { +s32 func_80BC213C(EnJa* this, PlayState* play) { return true; } -void func_80BC2150(EnJa* this, GlobalContext* globalCtx) { +void func_80BC2150(EnJa* this, PlayState* play) { if ((this->unk_1D8.unk_00 == 1) || (this->unk_1D8.unk_00 == 2)) { - func_80BC213C(this, globalCtx); + func_80BC213C(this, play); } Math_ApproachS(&this->actor.shape.rot.y, this->actor.world.rot.y, 4, 0x1554); } -void func_80BC21A8(EnJa* this, GlobalContext* globalCtx) { - u32* unk_14 = &gSaveContext.save.daySpeed; - struct_80133038_arg2 sp18; +void func_80BC21A8(EnJa* this, PlayState* play) { + ScheduleOutput sp18; - this->unk_35C = REG(15) + *unk_14; - if (!func_80133038(globalCtx, D_80BC35F0, &sp18) || - ((this->unk_1D8.unk_00 != sp18.unk0) && !func_80BC20D0(this, globalCtx, &sp18))) { + this->unk_35C = REG(15) + ((void)0, gSaveContext.save.daySpeed); + if (!Schedule_RunScript(play, D_80BC35F0, &sp18) || + ((this->unk_1D8.unk_00 != sp18.result) && !func_80BC20D0(this, play, &sp18))) { this->actor.shape.shadowDraw = NULL; this->actor.flags &= ~ACTOR_FLAG_1; - sp18.unk0 = 0; + sp18.result = 0; } else { this->actor.shape.shadowDraw = ActorShadow_DrawCircle; this->actor.flags |= ACTOR_FLAG_1; } - this->unk_1D8.unk_00 = sp18.unk0; - func_80BC2150(this, globalCtx); + this->unk_1D8.unk_00 = sp18.result; + func_80BC2150(this, play); } -s32* func_80BC2274(EnJa* this, GlobalContext* globalCtx) { +s32* func_80BC2274(EnJa* this, PlayState* play) { switch (this->unk_1D8.unk_00) { case 1: if (ENJA_GET_3(&this->actor) == 0) { @@ -325,8 +332,8 @@ s32* func_80BC2274(EnJa* this, GlobalContext* globalCtx) { 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)) { +void func_80BC22F4(EnJa* this, PlayState* play) { + if (func_8010BF58(&this->actor, play, func_80BC2274(this, play), 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; @@ -336,15 +343,14 @@ void func_80BC22F4(EnJa* this, GlobalContext* globalCtx) { } } -void EnJa_Init(Actor* thisx, GlobalContext* globalCtx) { +void EnJa_Init(Actor* thisx, PlayState* play) { 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); + SkelAnime_InitFlex(play, &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); + Collider_InitAndSetCylinder(play, &this->collider, &this->actor, &sCylinderInit); CollisionCheck_SetInfo2(&this->actor.colChkInfo, DamageTable_Get(0x16), &sColChkInfoInit); Actor_SetScale(&this->actor, 0.01f); this->actor.targetMode = 0; @@ -357,52 +363,52 @@ void EnJa_Init(Actor* thisx, GlobalContext* globalCtx) { this->actionFunc = func_80BC21A8; } -void EnJa_Destroy(Actor* thisx, GlobalContext* globalCtx) { +void EnJa_Destroy(Actor* thisx, PlayState* play) { EnJa* this = THIS; - Collider_DestroyCylinder(globalCtx, &this->collider); + Collider_DestroyCylinder(play, &this->collider); } -void EnJa_Update(Actor* thisx, GlobalContext* globalCtx) { +void EnJa_Update(Actor* thisx, PlayState* play) { EnJa* this = THIS; f32 height; f32 radius; - func_80BC19FC(this, globalCtx); + func_80BC19FC(this, play); - this->actionFunc(this, globalCtx); + this->actionFunc(this, play); if (this->unk_1D8.unk_00 != 0) { func_80BC1900(this); func_80BC1A68(this); - func_80BC1D70(this, globalCtx); + func_80BC1D70(this, play); radius = this->collider.dim.radius + 30; height = this->collider.dim.height + 10; - func_8013C964(&this->actor, globalCtx, radius, height, 0, this->unk_340 & 7); + func_8013C964(&this->actor, play, radius, height, PLAYER_AP_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); + Actor_UpdateBgCheckInfo(play, &this->actor, 30.0f, 12.0f, 0.0f, 4); } - func_80BC1984(this, globalCtx); + func_80BC1984(this, play); } if (this->unk_1D8.unk_00 == 1) { - func_80BC32D8(this, globalCtx); + func_80BC32D8(this, play); } } -s32 EnJa_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, Actor* thisx) { +s32 EnJa_OverrideLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, Actor* thisx) { EnJa* this = THIS; if (limbIndex == 15) { - func_80BC1E40(this, globalCtx); + func_80BC1E40(this, play); } return false; } -void EnJa_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx) { +void EnJa_PostLimbDraw(PlayState* play, 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 }; @@ -413,30 +419,30 @@ void EnJa_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec s32 pad2; if (limbIndex == 15) { - Matrix_MultiplyVector3fByState(&D_80BC3780, &this->actor.focus.pos); + 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); + OPEN_DISPS(play->state.gfxCtx); - Matrix_StatePush(); - Matrix_JointPosition(&D_80BC3774, &D_80BC37A4); + 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); + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_OPA_DISP++, object_boj_DL_00BA30); - Matrix_StatePop(); + Matrix_Pop(); - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->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); + OPEN_DISPS(play->state.gfxCtx); - Matrix_StatePush(); - Matrix_InsertTranslation(D_80BC378C.x, D_80BC378C.y, D_80BC378C.z, MTXMODE_APPLY); - Matrix_NormalizeXYZ(&globalCtx->billboardMtxF); + Matrix_Push(); + Matrix_Translate(D_80BC378C.x, D_80BC378C.y, D_80BC378C.z, MTXMODE_APPLY); + Matrix_ReplaceRotation(&play->billboardMtxF); gDPPipeSync(POLY_OPA_DISP++); @@ -462,21 +468,20 @@ void EnJa_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec break; } - gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), - G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_OPA_DISP++, object_boj_DL_00BCC8); - Matrix_StatePop(); + Matrix_Pop(); - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->state.gfxCtx); } else if (limbIndex == 14) { if ((this->skelAnime.curFrame >= 0.0f) && (this->skelAnime.curFrame <= 18.0f)) { - OPEN_DISPS(globalCtx->state.gfxCtx); + OPEN_DISPS(play->state.gfxCtx); - Matrix_StatePush(); + Matrix_Push(); - Matrix_InsertTranslation(D_80BC3798.x, D_80BC3798.y, D_80BC3798.z, MTXMODE_APPLY); - Matrix_NormalizeXYZ(&globalCtx->billboardMtxF); + Matrix_Translate(D_80BC3798.x, D_80BC3798.y, D_80BC3798.z, MTXMODE_APPLY); + Matrix_ReplaceRotation(&play->billboardMtxF); gDPPipeSync(POLY_OPA_DISP++); @@ -502,66 +507,66 @@ void EnJa_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec break; } - gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_OPA_DISP++, object_boj_DL_00BCC8); - Matrix_StatePop(); + Matrix_Pop(); - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->state.gfxCtx); } } } } -void EnJa_TransformLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Actor* thisx) { +void EnJa_TransformLimbDraw(PlayState* play, s32 limbIndex, Actor* thisx) { EnJa* this = THIS; - s32 phi_v1; - s32 phi_v0; + s32 stepRot; + s32 overrideRot; if (this->unk_340 & 0x10) { - phi_v1 = false; + stepRot = false; } else { - phi_v1 = true; + stepRot = true; } if (this->unk_340 & 0x20) { - phi_v0 = true; + overrideRot = true; } else { - phi_v0 = false; + overrideRot = false; } - if (!phi_v1) { - phi_v0 = false; + if (!stepRot) { + overrideRot = false; } if (limbIndex != 8) { if (limbIndex == 15) { - func_8013AD9C(this->unk_354 + this->unk_358 + 0x4000, - this->unk_356 + this->unk_35A + this->actor.shape.rot.y + 0x4000, &this->unk_1EC, - &this->unk_274, phi_v1, phi_v0); - Matrix_StatePop(); - Matrix_InsertTranslation(this->unk_1EC.x, this->unk_1EC.y, this->unk_1EC.z, MTXMODE_NEW); + 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_RotateY(this->unk_274.y, MTXMODE_APPLY); - Matrix_InsertXRotation_s(this->unk_274.x, MTXMODE_APPLY); - Matrix_InsertZRotation_s(this->unk_274.z, MTXMODE_APPLY); - Matrix_StatePush(); + 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 { - func_8013AD9C(this->unk_358 + 0x4000, this->unk_35A + this->actor.shape.rot.y + 0x4000, &this->unk_1F8, - &this->unk_27A, phi_v1, phi_v0); - Matrix_StatePop(); - Matrix_InsertTranslation(this->unk_1F8.x, this->unk_1F8.y, this->unk_1F8.z, MTXMODE_NEW); + 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_RotateY(this->unk_27A.y, MTXMODE_APPLY); - Matrix_InsertXRotation_s(this->unk_27A.x, MTXMODE_APPLY); - Matrix_InsertZRotation_s(this->unk_27A.z, MTXMODE_APPLY); - Matrix_StatePush(); + 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) { +void EnJa_Draw(Actor* thisx, PlayState* play) { static Color_RGBA8 D_80BC37AC[] = { { 200, 0, 80, 0 }, { 0, 130, 220, 0 }, @@ -587,28 +592,28 @@ void EnJa_Draw(Actor* thisx, GlobalContext* globalCtx) { } if (this->unk_1D8.unk_00 != 0) { - OPEN_DISPS(globalCtx->state.gfxCtx); + OPEN_DISPS(play->state.gfxCtx); - func_8012C28C(globalCtx->state.gfxCtx); + func_8012C28C(play->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)); + Gfx_EnvColor(play->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)); + Gfx_EnvColor(play->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, + SkelAnime_DrawTransformFlexOpa(play, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, EnJa_OverrideLimbDraw, EnJa_PostLimbDraw, EnJa_TransformLimbDraw, &this->actor); - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->state.gfxCtx); } if (this->unk_1D8.unk_00 == 1) { - func_80BC3594(this, globalCtx); + func_80BC3594(this, play); } } @@ -684,7 +689,7 @@ void func_80BC3154(EnJa* this, EnJaStruct* ptr) { } } -void func_80BC32D8(EnJa* this, GlobalContext* globalCtx) { +void func_80BC32D8(EnJa* this, PlayState* play) { EnJaStruct* phi_s0 = &this->unk_234[0]; s32 i; @@ -712,14 +717,14 @@ void func_80BC32D8(EnJa* this, GlobalContext* globalCtx) { } } -void func_80BC33C0(EnJaStruct* ptr, GlobalContext* globalCtx) { +void func_80BC33C0(EnJaStruct* ptr, PlayState* play) { s32 pad; if (((ptr->unk_0E < 0) || (ptr->unk_0E >= 19)) && ((ptr->unk_0E < 83) || (ptr->unk_0E >= 103))) { - OPEN_DISPS(globalCtx->state.gfxCtx); + OPEN_DISPS(play->state.gfxCtx); - Matrix_InsertTranslation(ptr->unk_00.x, ptr->unk_00.y, ptr->unk_00.z, MTXMODE_NEW); - Matrix_InsertMatrix(&globalCtx->billboardMtxF, MTXMODE_APPLY); + Matrix_Translate(ptr->unk_00.x, ptr->unk_00.y, ptr->unk_00.z, MTXMODE_NEW); + Matrix_Mult(&play->billboardMtxF, MTXMODE_APPLY); Matrix_Scale(0.01f, 0.01f, 0.01f, MTXMODE_APPLY); switch (ptr->unk_0C) { @@ -744,18 +749,18 @@ void func_80BC33C0(EnJaStruct* ptr, GlobalContext* globalCtx) { break; } - gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_OPA_DISP++, object_boj_DL_00BCC8); - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->state.gfxCtx); } } -void func_80BC3594(EnJa* this, GlobalContext* globalCtx) { +void func_80BC3594(EnJa* this, PlayState* play) { 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); + func_80BC33C0(phi_s0, play); } } 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 561f76f55..e2fd8287f 100644 --- a/src/overlays/actors/ovl_En_Ja/z_en_ja.h +++ b/src/overlays/actors/ovl_En_Ja/z_en_ja.h @@ -5,7 +5,7 @@ struct EnJa; -typedef void (*EnJaActionFunc)(struct EnJa*, GlobalContext*); +typedef void (*EnJaActionFunc)(struct EnJa*, PlayState*); #define ENJA_GET_3(thisx) (((thisx)->params & 3) & 0xFF) @@ -22,42 +22,42 @@ typedef struct { } EnJaStruct2; // size = 0x10 typedef struct EnJa { - /* 0x0000 */ Actor actor; - /* 0x0144 */ SkelAnime skelAnime; - /* 0x0188 */ EnJaActionFunc actionFunc; - /* 0x018C */ ColliderCylinder collider; - /* 0x01D8 */ EnJaStruct2 unk_1D8; - /* 0x01E4 */ Vec3s unk_1E4; - /* 0x01EC */ Vec3f unk_1EC; - /* 0x01F8 */ Vec3f unk_1F8; - /* 0x0204 */ Vec3f unk_204; - /* 0x0210 */ Vec3f unk_210; - /* 0x021C */ Vec3f unk_21C; - /* 0x0228 */ Vec3f unk_228; - /* 0x0234 */ EnJaStruct unk_234[4]; - /* 0x0274 */ Vec3s unk_274; - /* 0x027A */ Vec3s unk_27A; - /* 0x0280 */ Vec3s jointTable[16]; - /* 0x02E0 */ Vec3s morphTable[16]; - /* 0x0340 */ u16 unk_340; - /* 0x0344 */ f32 unk_344; - /* 0x0348 */ f32 unk_348; - /* 0x034C */ f32 unk_34C; - /* 0x0350 */ UNK_TYPE1 unk350[0x4]; - /* 0x0354 */ s16 unk_354; - /* 0x0356 */ s16 unk_356; - /* 0x0358 */ s16 unk_358; - /* 0x035A */ s16 unk_35A; - /* 0x035C */ s16 unk_35C; - /* 0x035E */ s16 unk_35E; - /* 0x0360 */ s16 unk_360; - /* 0x0362 */ s16 unk_362; - /* 0x0364 */ s16 unk_364; - /* 0x0366 */ s16 unk_366; - /* 0x0368 */ void* unk_368; - /* 0x036C */ s32 unk_36C; - /* 0x0370 */ UNK_TYPE1 unk370[4]; - /* 0x0374 */ s32 unk_374; + /* 0x000 */ Actor actor; + /* 0x144 */ SkelAnime skelAnime; + /* 0x188 */ EnJaActionFunc actionFunc; + /* 0x18C */ ColliderCylinder collider; + /* 0x1D8 */ EnJaStruct2 unk_1D8; + /* 0x1E4 */ Vec3s unk_1E4; + /* 0x1EC */ Vec3f unk_1EC; + /* 0x1F8 */ Vec3f unk_1F8; + /* 0x204 */ Vec3f unk_204; + /* 0x210 */ Vec3f unk_210; + /* 0x21C */ Vec3f unk_21C; + /* 0x228 */ Vec3f unk_228; + /* 0x234 */ EnJaStruct unk_234[4]; + /* 0x274 */ Vec3s unk_274; + /* 0x27A */ Vec3s unk_27A; + /* 0x280 */ Vec3s jointTable[16]; + /* 0x2E0 */ Vec3s morphTable[16]; + /* 0x340 */ u16 unk_340; + /* 0x344 */ f32 unk_344; + /* 0x348 */ f32 unk_348; + /* 0x34C */ f32 unk_34C; + /* 0x350 */ UNK_TYPE1 unk350[0x4]; + /* 0x354 */ s16 unk_354; + /* 0x356 */ s16 unk_356; + /* 0x358 */ s16 unk_358; + /* 0x35A */ s16 unk_35A; + /* 0x35C */ s16 unk_35C; + /* 0x35E */ s16 unk_35E; + /* 0x360 */ s16 unk_360; + /* 0x362 */ s16 unk_362; + /* 0x364 */ s16 unk_364; + /* 0x366 */ s16 unk_366; + /* 0x368 */ void* unk_368; + /* 0x36C */ s32 unk_36C; + /* 0x370 */ UNK_TYPE1 unk_370[4]; + /* 0x374 */ s32 prevTalkState; } EnJa; // size = 0x378 extern const ActorInit En_Ja_InitVars; diff --git a/src/overlays/actors/ovl_En_Jc_Mato/z_en_jc_mato.c b/src/overlays/actors/ovl_En_Jc_Mato/z_en_jc_mato.c index 4e50ceba6..99c17772c 100644 --- a/src/overlays/actors/ovl_En_Jc_Mato/z_en_jc_mato.c +++ b/src/overlays/actors/ovl_En_Jc_Mato/z_en_jc_mato.c @@ -11,14 +11,14 @@ #define THIS ((EnJcMato*)thisx) -void EnJcMato_Init(Actor* thisx, GlobalContext* globalCtx); -void EnJcMato_Destroy(Actor* thisx, GlobalContext* globalCtx); -void EnJcMato_Update(Actor* thisx, GlobalContext* globalCtx); -void EnJcMato_Draw(Actor* thisx, GlobalContext* globalCtx); +void EnJcMato_Init(Actor* thisx, PlayState* play); +void EnJcMato_Destroy(Actor* thisx, PlayState* play); +void EnJcMato_Update(Actor* thisx, PlayState* play); +void EnJcMato_Draw(Actor* thisx, PlayState* play); -s32 EnJcMato_CheckForHit(EnJcMato* this, GlobalContext* globalCtx); +s32 EnJcMato_CheckForHit(EnJcMato* this, PlayState* play); void EnJcMato_SetupIdle(EnJcMato* this); -void EnJcMato_Idle(EnJcMato* this, GlobalContext* globalCtx); +void EnJcMato_Idle(EnJcMato* this, PlayState* play); const ActorInit En_Jc_Mato_InitVars = { ACTOR_EN_JC_MATO, @@ -87,19 +87,19 @@ static DamageTable sDamageTable = { /* Powder Keg */ DMG_ENTRY(1, 0x0), }; -s32 EnJcMato_CheckForHit(EnJcMato* this, GlobalContext* globalCtx) { +s32 EnJcMato_CheckForHit(EnJcMato* this, PlayState* play) { this->collider.dim.worldSphere.center.x = this->pos.x; this->collider.dim.worldSphere.center.y = this->pos.y; this->collider.dim.worldSphere.center.z = this->pos.z; if ((this->collider.base.acFlags & AC_HIT) && !this->hitFlag && (this->actor.colChkInfo.damageEffect == 0xF)) { this->collider.base.acFlags &= ~AC_HIT; Actor_PlaySfxAtPos(&this->actor, NA_SE_SY_TRE_BOX_APPEAR); - globalCtx->interfaceCtx.unk_25C = 1; + play->interfaceCtx.unk_25C = 1; this->hitFlag = true; return 1; } else { - CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); - CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + CollisionCheck_SetOC(play, &play->colChkCtx, &this->collider.base); + CollisionCheck_SetAC(play, &play->colChkCtx, &this->collider.base); return 0; } } @@ -108,28 +108,20 @@ void EnJcMato_SetupIdle(EnJcMato* this) { this->actionFunc = EnJcMato_Idle; } -void EnJcMato_Idle(EnJcMato* this, GlobalContext* globalCtx) { - s16 shouldDespawn; - +void EnJcMato_Idle(EnJcMato* this, PlayState* play) { if (this->hitFlag) { - if (this->despawnTimer == 0) { - shouldDespawn = 0; - } else { - this->despawnTimer--; - shouldDespawn = this->despawnTimer; - } - if (shouldDespawn == 0) { + if (DECR(this->despawnTimer) == 0) { Actor_MarkForDeath(&this->actor); } } } -void EnJcMato_Init(Actor* thisx, GlobalContext* globalCtx) { +void EnJcMato_Init(Actor* thisx, PlayState* play) { EnJcMato* this = THIS; ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 24.0f); - Collider_InitSphere(globalCtx, &this->collider); - Collider_SetSphere(globalCtx, &this->collider, &this->actor, &sSphereInit); + Collider_InitSphere(play, &this->collider); + Collider_SetSphere(play, &this->collider, &this->actor, &sSphereInit); this->collider.dim.worldSphere.radius = 0xF; this->actor.colChkInfo.damageTable = &sDamageTable; Actor_SetScale(&this->actor, 0.008f); @@ -138,30 +130,30 @@ void EnJcMato_Init(Actor* thisx, GlobalContext* globalCtx) { EnJcMato_SetupIdle(this); } -void EnJcMato_Destroy(Actor* thisx, GlobalContext* globalCtx) { +void EnJcMato_Destroy(Actor* thisx, PlayState* play) { EnJcMato* this = THIS; - Collider_DestroySphere(globalCtx, &this->collider); + Collider_DestroySphere(play, &this->collider); } -void EnJcMato_Update(Actor* thisx, GlobalContext* globalCtx) { +void EnJcMato_Update(Actor* thisx, PlayState* play) { EnJcMato* this = THIS; - this->actionFunc(this, globalCtx); + this->actionFunc(this, play); if (!(gSaveContext.eventInf[4] & 1)) { - EnJcMato_CheckForHit(this, globalCtx); + EnJcMato_CheckForHit(this, play); } } static Vec3f movement = { 0.0f, -2500.0f, 0.0f }; -void EnJcMato_Draw(Actor* thisx, GlobalContext* globalCtx) { +void EnJcMato_Draw(Actor* thisx, PlayState* play) { EnJcMato* 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); + OPEN_DISPS(play->state.gfxCtx); + func_8012C28C(play->state.gfxCtx); + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_OPA_DISP++, object_tru_DL_000390); - Matrix_MultiplyVector3fByState(&movement, &this->pos); - CLOSE_DISPS(globalCtx->state.gfxCtx); + Matrix_MultVec3f(&movement, &this->pos); + CLOSE_DISPS(play->state.gfxCtx); } diff --git a/src/overlays/actors/ovl_En_Jc_Mato/z_en_jc_mato.h b/src/overlays/actors/ovl_En_Jc_Mato/z_en_jc_mato.h index cb1e69ac8..165a768e2 100644 --- a/src/overlays/actors/ovl_En_Jc_Mato/z_en_jc_mato.h +++ b/src/overlays/actors/ovl_En_Jc_Mato/z_en_jc_mato.h @@ -5,7 +5,7 @@ struct EnJcMato; -typedef void (*EnJcMatoActionFunc)(struct EnJcMato*, GlobalContext*); +typedef void (*EnJcMatoActionFunc)(struct EnJcMato*, PlayState*); typedef struct EnJcMato { /* 0x000 */ Actor actor; diff --git a/src/overlays/actors/ovl_En_Jg/z_en_jg.c b/src/overlays/actors/ovl_En_Jg/z_en_jg.c index 9412e5594..bb5ec72ee 100644 --- a/src/overlays/actors/ovl_En_Jg/z_en_jg.c +++ b/src/overlays/actors/ovl_En_Jg/z_en_jg.c @@ -15,47 +15,47 @@ #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); +void EnJg_Init(Actor* thisx, PlayState* play); +void EnJg_Destroy(Actor* thisx, PlayState* play); +void EnJg_Update(Actor* thisx, PlayState* play); +void EnJg_Draw(Actor* thisx, PlayState* play); -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); +void EnJg_GoronShrineTalk(EnJg* this, PlayState* play); +void EnJg_GoronShrineCheer(EnJg* this, PlayState* play); +void EnJg_AlternateTalkOrWalkInPlace(EnJg* this, PlayState* play); +void EnJg_Walk(EnJg* this, PlayState* play); +void EnJg_Talk(EnJg* this, PlayState* play); +void EnJg_SetupWalk(EnJg* this, PlayState* play); +void EnJg_FrozenIdle(EnJg* this, PlayState* play); +void EnJg_EndFrozenInteraction(EnJg* this, PlayState* play); +void EnJg_TeachLullabyIntro(EnJg* this, PlayState* play); +void EnJg_LullabyIntroCutsceneAction(EnJg* this, PlayState* play); s32 EnJg_GetNextTextId(EnJg* this); -s32 EnJg_GetStartingConversationTextId(EnJg* this, GlobalContext* globalCtx); -void EnJg_CheckIfTalkingToPlayerAndHandleFreezeTimer(EnJg* this, GlobalContext* globalCtx); +s32 EnJg_GetStartingConversationTextId(EnJg* this, PlayState* play); +void EnJg_CheckIfTalkingToPlayerAndHandleFreezeTimer(EnJg* this, PlayState* play); 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; + /* 0 */ EN_JG_ANIM_IDLE, + /* 1 */ EN_JG_ANIM_WALK, + /* 2 */ EN_JG_ANIM_WAVING, + /* 3 */ EN_JG_ANIM_SHAKING_HEAD, + /* 4 */ EN_JG_ANIM_SURPRISE_START, + /* 5 */ EN_JG_ANIM_SURPRISE_LOOP, + /* 6 */ EN_JG_ANIM_ANGRY, + /* 7 */ EN_JG_ANIM_FROZEN_START, + /* 8 */ EN_JG_ANIM_FROZEN_LOOP, + /* 9 */ EN_JG_ANIM_WALK_2, + /* 10 */ EN_JG_ANIM_TAKING_OUT_DRUM, + /* 11 */ EN_JG_ANIM_DRUM_IDLE, + /* 12 */ EN_JG_ANIM_PLAYING_DRUM, + /* 13 */ EN_JG_ANIM_THINKING, + /* 14 */ EN_JG_ANIM_REMEMBERING, + /* 15 */ EN_JG_ANIM_STRONG_REMEMBERING, + /* 16 */ EN_JG_ANIM_DEPRESSED, + /* 17 */ EN_JG_ANIM_CUTSCENE_IDLE, + /* 18 */ EN_JG_ANIM_CRADLE, + /* 19 */ EN_JG_ANIM_MAX, +} EnJgAnimation; typedef enum { /* 0x0 */ EN_JG_ACTION_FIRST_THAW, @@ -133,7 +133,7 @@ static DamageTable sDamageTable = { /* Powder Keg */ DMG_ENTRY(0, 0x0), }; -static AnimationInfoS sAnimations[] = { +static AnimationInfoS sAnimationInfo[] = { { &gGoronElderIdleAnim, 1.0f, 0, -1, ANIMMODE_LOOP, -10 }, { &gGoronElderWalkAnim, 1.0f, 0, -1, ANIMMODE_LOOP, -10 }, { &gGoronElderWavingAnim, 1.0f, 0, -1, ANIMMODE_LOOP, -10 }, @@ -172,12 +172,12 @@ static Vec3f sBreathAccelOffset = { 0.0f, 0.0f, -0.070000000298f }; * 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; +Actor* EnJg_GetShrineGoronToFocusOn(PlayState* play, u8 focusedShrineGoronParam) { + Actor* actorIterator = play->actorCtx.actorLists[ACTORCAT_NPC].first; while (actorIterator != NULL) { if ((actorIterator->id == ACTOR_EN_S_GORO) && - (EN_S_GORO_GET_PARAM_F(actorIterator) == focusedShrineGoronParam)) { + (EN_S_GORO_GET_MAIN_TYPE(actorIterator) == focusedShrineGoronParam)) { return actorIterator; } @@ -187,14 +187,14 @@ Actor* EnJg_GetShrineGoronToFocusOn(GlobalContext* globalCtx, u8 focusedShrineGo return NULL; } -void EnJg_UpdateCollision(EnJg* this, GlobalContext* globalCtx) { +void EnJg_UpdateCollision(EnJg* this, PlayState* play) { this->collider.dim.pos.x = this->actor.world.pos.x; this->collider.dim.pos.y = this->actor.world.pos.y; this->collider.dim.pos.z = this->actor.world.pos.z; - 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); + CollisionCheck_SetAC(play, &play->colChkCtx, &this->collider.base); + CollisionCheck_SetOC(play, &play->colChkCtx, &this->collider.base); + Actor_UpdateBgCheckInfo(play, &this->actor, 0.0f, 30.0f, 30.0f, 7); } s16 EnJg_GetWalkingYRotation(Path* path, s32 pointIndex, Vec3f* pos, f32* distSQ) { @@ -293,23 +293,23 @@ void EnJg_SetupGoronShrineCheer(EnJg* this) { } } -void EnJg_SetupTalk(EnJg* this, GlobalContext* globalCtx) { +void EnJg_SetupTalk(EnJg* this, PlayState* play) { switch (this->textId) { case 0xDAC: // What was I doing? - this->animationIndex = EN_JG_ANIMATION_SHAKING_HEAD; - SubS_ChangeAnimationByInfoS(&this->skelAnime, sAnimations, this->animationIndex); + this->animIndex = EN_JG_ANIM_SHAKING_HEAD; + SubS_ChangeAnimationByInfoS(&this->skelAnime, sAnimationInfo, this->animIndex); this->actionFunc = EnJg_Talk; break; case 0xDAD: // I must hurry! - this->animationIndex = EN_JG_ANIMATION_SURPRISE_START; - SubS_ChangeAnimationByInfoS(&this->skelAnime, sAnimations, this->animationIndex); + this->animIndex = EN_JG_ANIM_SURPRISE_START; + SubS_ChangeAnimationByInfoS(&this->skelAnime, sAnimationInfo, this->animIndex); this->actionFunc = EnJg_AlternateTalkOrWalkInPlace; break; case 0xDB7: // You're Darmani! - this->animationIndex = EN_JG_ANIMATION_SURPRISE_START; - SubS_ChangeAnimationByInfoS(&this->skelAnime, sAnimations, this->animationIndex); + this->animIndex = EN_JG_ANIM_SURPRISE_START; + SubS_ChangeAnimationByInfoS(&this->skelAnime, sAnimationInfo, this->animIndex); this->actionFunc = EnJg_Talk; break; @@ -319,8 +319,8 @@ void EnJg_SetupTalk(EnJg* this, GlobalContext* globalCtx) { 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->animIndex = EN_JG_ANIM_IDLE; + SubS_ChangeAnimationByInfoS(&this->skelAnime, sAnimationInfo, this->animIndex); this->actionFunc = EnJg_Talk; break; @@ -328,51 +328,51 @@ void EnJg_SetupTalk(EnJg* this, GlobalContext* globalCtx) { 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->animIndex = EN_JG_ANIM_ANGRY; + SubS_ChangeAnimationByInfoS(&this->skelAnime, sAnimationInfo, this->animIndex); 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->animIndex = EN_JG_ANIM_WAVING; + SubS_ChangeAnimationByInfoS(&this->skelAnime, sAnimationInfo, this->animIndex); this->actionFunc = EnJg_Talk; break; } } -void EnJg_Idle(EnJg* this, GlobalContext* globalCtx) { - EnJg_CheckIfTalkingToPlayerAndHandleFreezeTimer(this, globalCtx); +void EnJg_Idle(EnJg* this, PlayState* play) { + EnJg_CheckIfTalkingToPlayerAndHandleFreezeTimer(this, play); } -void EnJg_GoronShrineIdle(EnJg* this, GlobalContext* globalCtx) { - if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { +void EnJg_GoronShrineIdle(EnJg* this, PlayState* play) { + if (Actor_ProcessTalkRequest(&this->actor, &play->state)) { this->flags |= FLAG_LOOKING_AT_PLAYER; - Message_StartTextbox(globalCtx, this->textId, &this->actor); + Message_StartTextbox(play, 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); + func_800B863C(&this->actor, play); + this->textId = EnJg_GetStartingConversationTextId(this, play); } } -void EnJg_GoronShrineTalk(EnJg* this, GlobalContext* globalCtx) { - if ((Message_GetState(&globalCtx->msgCtx) == 5) && (Message_ShouldAdvance(globalCtx))) { +void EnJg_GoronShrineTalk(EnJg* this, PlayState* play) { + if ((Message_GetState(&play->msgCtx) == TEXT_STATE_5) && Message_ShouldAdvance(play)) { if ((this->textId == 0xDCC) || (this->textId == 0xDDD) || (this->textId == 0xDE0)) { // There is nothing more to say after these lines, so end the current conversation. - globalCtx->msgCtx.msgMode = 0x43; - globalCtx->msgCtx.unk12023 = 4; + play->msgCtx.msgMode = 0x43; + play->msgCtx.stateTimer = 4; this->flags &= ~FLAG_LOOKING_AT_PLAYER; this->actionFunc = EnJg_GoronShrineIdle; } else { this->textId = EnJg_GetNextTextId(this); - Message_StartTextbox(globalCtx, this->textId, &this->actor); + Message_StartTextbox(play, this->textId, &this->actor); } } } -void EnJg_GoronShrineCheer(EnJg* this, GlobalContext* globalCtx) { +void EnJg_GoronShrineCheer(EnJg* this, PlayState* play) { if (ActorCutscene_GetCanPlayNext(this->cutscene)) { switch (this->textId) { case 0xDD0: // The greatest Goron hero of all? @@ -381,15 +381,15 @@ void EnJg_GoronShrineCheer(EnJg* this, GlobalContext* globalCtx) { 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); + this->shrineGoron = EnJg_GetShrineGoronToFocusOn(play, this->focusedShrineGoronParam); ActorCutscene_Start(this->cutscene, this->shrineGoron); - Camera_SetTargetActor(globalCtx->cameraPtrs[CAM_ID_MAIN], this->shrineGoron); + Camera_SetTargetActor(play->cameraPtrs[CAM_ID_MAIN], this->shrineGoron); break; default: // Focus on the whole group for these lines ActorCutscene_Start(this->cutscene, &this->actor); - Camera_SetTargetActor(globalCtx->cameraPtrs[CAM_ID_MAIN], this->shrineGoron); + Camera_SetTargetActor(play->cameraPtrs[CAM_ID_MAIN], this->shrineGoron); break; } this->actionFunc = EnJg_GoronShrineTalk; @@ -414,32 +414,32 @@ void EnJg_GoronShrineCheer(EnJg* this, GlobalContext* globalCtx) { * 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); +void EnJg_AlternateTalkOrWalkInPlace(EnJg* this, PlayState* play) { + u8 talkState = Message_GetState(&play->msgCtx); s16 currentFrame = this->skelAnime.curFrame; - s16 lastFrame = Animation_GetLastFrame(sAnimations[this->animationIndex].animation); + s16 lastFrame = Animation_GetLastFrame(sAnimationInfo[this->animIndex].animation); - if (this->animationIndex == EN_JG_ANIMATION_SURPRISE_START) { + if (this->animIndex == EN_JG_ANIM_SURPRISE_START) { if (currentFrame == lastFrame) { - this->animationIndex = EN_JG_ANIMATION_SURPRISE_LOOP; - SubS_ChangeAnimationByInfoS(&this->skelAnime, sAnimations, this->animationIndex); + this->animIndex = EN_JG_ANIM_SURPRISE_LOOP; + SubS_ChangeAnimationByInfoS(&this->skelAnime, sAnimationInfo, this->animIndex); } - } else if (this->animationIndex == EN_JG_ANIMATION_SURPRISE_LOOP) { - if ((messageState == 5) && (Message_ShouldAdvance(globalCtx))) { - globalCtx->msgCtx.msgMode = 0x43; - globalCtx->msgCtx.unk12023 = 4; + } else if (this->animIndex == EN_JG_ANIM_SURPRISE_LOOP) { + if ((talkState == TEXT_STATE_5) && Message_ShouldAdvance(play)) { + play->msgCtx.msgMode = 0x43; + play->msgCtx.stateTimer = 4; this->flags &= ~FLAG_LOOKING_AT_PLAYER; - this->animationIndex = EN_JG_ANIMATION_WALK; - SubS_ChangeAnimationByInfoS(&this->skelAnime, sAnimations, this->animationIndex); + this->animIndex = EN_JG_ANIM_WALK; + SubS_ChangeAnimationByInfoS(&this->skelAnime, sAnimationInfo, this->animIndex); this->actionFunc = EnJg_Walk; } - } else if (this->animationIndex == EN_JG_ANIMATION_WALK) { + } else if (this->animIndex == EN_JG_ANIM_WALK) { Math_ApproachF(&this->actor.speedXZ, 0.0f, 0.2f, 1.0f); - EnJg_CheckIfTalkingToPlayerAndHandleFreezeTimer(this, globalCtx); + EnJg_CheckIfTalkingToPlayerAndHandleFreezeTimer(this, play); } } -void EnJg_Walk(EnJg* this, GlobalContext* globalCtx) { +void EnJg_Walk(EnJg* this, PlayState* play) { s16 yRotation; f32 distSQ; @@ -455,7 +455,7 @@ void EnJg_Walk(EnJg* this, GlobalContext* globalCtx) { 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->animIndex = EN_JG_ANIM_WALK; this->actionFunc = EnJg_AlternateTalkOrWalkInPlace; } else { this->currentPoint++; @@ -466,26 +466,26 @@ void EnJg_Walk(EnJg* this, GlobalContext* globalCtx) { } } - EnJg_CheckIfTalkingToPlayerAndHandleFreezeTimer(this, globalCtx); + EnJg_CheckIfTalkingToPlayerAndHandleFreezeTimer(this, play); } -void EnJg_Talk(EnJg* this, GlobalContext* globalCtx) { - u8 messageState = Message_GetState(&globalCtx->msgCtx); +void EnJg_Talk(EnJg* this, PlayState* play) { + u8 talkState = Message_GetState(&play->msgCtx); s16 currentFrame = this->skelAnime.curFrame; - s16 lastFrame = Animation_GetLastFrame(sAnimations[this->animationIndex].animation); + s16 lastFrame = Animation_GetLastFrame(sAnimationInfo[this->animIndex].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 ((this->animIndex == EN_JG_ANIM_SURPRISE_START) && (currentFrame == lastFrame)) { + this->animIndex = EN_JG_ANIM_SURPRISE_LOOP; + SubS_ChangeAnimationByInfoS(&this->skelAnime, sAnimationInfo, this->animIndex); } - if ((messageState == 5) && (Message_ShouldAdvance(globalCtx))) { + if ((talkState == TEXT_STATE_5) && Message_ShouldAdvance(play)) { temp = this->textId; if ((temp == 0xDB4) || (temp == 0xDB5) || (temp == 0xDC4) || (temp == 0xDC6)) { // There is nothing more to say after these lines, so end the current conversation. - globalCtx->msgCtx.msgMode = 0x43; - globalCtx->msgCtx.unk12023 = 4; + play->msgCtx.msgMode = 0x43; + play->msgCtx.stateTimer = 4; this->flags &= ~FLAG_LOOKING_AT_PLAYER; this->actionFunc = EnJg_SetupWalk; return; @@ -496,22 +496,22 @@ void EnJg_Talk(EnJg* this, GlobalContext* globalCtx) { 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; + play->msgCtx.msgMode = 0x43; + play->msgCtx.stateTimer = 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); + Message_StartTextbox(play, 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; + play->msgCtx.msgMode = 0x43; + play->msgCtx.stateTimer = 4; this->flags &= ~FLAG_LOOKING_AT_PLAYER; this->cutscene = EnJg_GetCutsceneForTeachingLullabyIntro(this); if (ActorCutscene_GetCurrentIndex() == 0x7C) { @@ -522,17 +522,17 @@ void EnJg_Talk(EnJg* this, GlobalContext* globalCtx) { } } else { this->textId = EnJg_GetNextTextId(this); - Message_StartTextbox(globalCtx, this->textId, &this->actor); + Message_StartTextbox(play, 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; +void EnJg_SetupWalk(EnJg* this, PlayState* play) { + if (this->animIndex != EN_JG_ANIM_WALK) { + this->animIndex = EN_JG_ANIM_WALK; this->freezeTimer = 1000; - SubS_ChangeAnimationByInfoS(&this->skelAnime, sAnimations, this->animationIndex); + SubS_ChangeAnimationByInfoS(&this->skelAnime, sAnimationInfo, this->animIndex); this->actionFunc = EnJg_Walk; } else { this->freezeTimer = 1000; @@ -540,74 +540,74 @@ void EnJg_SetupWalk(EnJg* this, GlobalContext* globalCtx) { } } -void EnJg_Freeze(EnJg* this, GlobalContext* globalCtx) { +void EnJg_Freeze(EnJg* this, PlayState* play) { s16 currentFrame = this->skelAnime.curFrame; - s16 lastFrame = Animation_GetLastFrame(sAnimations[this->animationIndex].animation); + s16 lastFrame = Animation_GetLastFrame(sAnimationInfo[this->animIndex].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->icePoly = Actor_Spawn(&play->actorCtx, play, 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->animIndex = EN_JG_ANIM_FROZEN_LOOP; + SubS_ChangeAnimationByInfoS(&this->skelAnime, sAnimationInfo, this->animIndex); this->actionFunc = EnJg_FrozenIdle; - } else if (this->animationIndex == EN_JG_ANIMATION_FROZEN_START) { + } else if (this->animIndex == EN_JG_ANIM_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->icePoly = Actor_Spawn(&play->actorCtx, play, 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->animIndex = EN_JG_ANIM_FROZEN_LOOP; + SubS_ChangeAnimationByInfoS(&this->skelAnime, sAnimationInfo, this->animIndex); this->actionFunc = EnJg_FrozenIdle; } } } -void EnJg_FrozenIdle(EnJg* this, GlobalContext* globalCtx) { +void EnJg_FrozenIdle(EnJg* this, PlayState* play) { if (this->icePoly->update == NULL) { this->icePoly = NULL; - if (this->animationIndex == EN_JG_ANIMATION_FROZEN_LOOP) { + if (this->animIndex == EN_JG_ANIM_FROZEN_LOOP) { if (Animation_OnFrame(&this->skelAnime, 0.0f)) { - this->animationIndex = EN_JG_ANIMATION_IDLE; + this->animIndex = EN_JG_ANIM_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); + SubS_ChangeAnimationByInfoS(&this->skelAnime, sAnimationInfo, this->animIndex); this->actionFunc = EnJg_Idle; } else { this->freezeTimer = 1000; - SubS_ChangeAnimationByInfoS(&this->skelAnime, sAnimations, this->animationIndex); + SubS_ChangeAnimationByInfoS(&this->skelAnime, sAnimationInfo, this->animIndex); this->actionFunc = EnJg_Walk; } } } } else { - if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { - Message_StartTextbox(globalCtx, 0x236, &this->actor); // The old Goron is frozen solid! + if (Actor_ProcessTalkRequest(&this->actor, &play->state)) { + Message_StartTextbox(play, 0x236, &this->actor); // The old Goron is frozen solid! this->actionFunc = EnJg_EndFrozenInteraction; } else if (this->actor.isTargeted) { - func_800B863C(&this->actor, globalCtx); + func_800B863C(&this->actor, play); } } } -void EnJg_EndFrozenInteraction(EnJg* this, GlobalContext* globalCtx) { - if (Message_GetState(&globalCtx->msgCtx) == 6 && Message_ShouldAdvance(globalCtx) != 0) { - globalCtx->msgCtx.msgMode = 0x43; - globalCtx->msgCtx.unk12023 = 4; +void EnJg_EndFrozenInteraction(EnJg* this, PlayState* play) { + if ((Message_GetState(&play->msgCtx) == TEXT_STATE_DONE) && Message_ShouldAdvance(play)) { + play->msgCtx.msgMode = 0x43; + play->msgCtx.stateTimer = 4; this->actionFunc = EnJg_FrozenIdle; } } -void EnJg_TeachLullabyIntro(EnJg* this, GlobalContext* globalCtx) { +void EnJg_TeachLullabyIntro(EnJg* this, PlayState* play) { if (ActorCutscene_GetCanPlayNext(this->cutscene)) { ActorCutscene_Start(this->cutscene, &this->actor); this->actionFunc = EnJg_LullabyIntroCutsceneAction; @@ -619,18 +619,18 @@ void EnJg_TeachLullabyIntro(EnJg* this, GlobalContext* globalCtx) { } } -void EnJg_LullabyIntroCutsceneAction(EnJg* this, GlobalContext* globalCtx) { +void EnJg_LullabyIntroCutsceneAction(EnJg* this, PlayState* play) { s32 pad; - if (Cutscene_CheckActorAction(globalCtx, 470)) { - s32 actionIndex = Cutscene_GetActorActionIndex(globalCtx, 470); + if (Cutscene_CheckActorAction(play, 470)) { + s32 actionIndex = Cutscene_GetActorActionIndex(play, 470); - if (this->csAction != globalCtx->csCtx.actorActions[actionIndex]->action) { - this->csAction = globalCtx->csCtx.actorActions[actionIndex]->action; + if (this->csAction != play->csCtx.actorActions[actionIndex]->action) { + this->csAction = play->csCtx.actorActions[actionIndex]->action; - switch (globalCtx->csCtx.actorActions[actionIndex]->action) { + switch (play->csCtx.actorActions[actionIndex]->action) { case 1: - this->cutsceneAnimationIndex = EN_JG_ANIMATION_CUTSCENE_IDLE; + this->cutsceneAnimIndex = EN_JG_ANIM_CUTSCENE_IDLE; if (this->drum != NULL) { Actor_MarkForDeath(this->drum); this->drum = NULL; @@ -638,59 +638,59 @@ void EnJg_LullabyIntroCutsceneAction(EnJg* this, GlobalContext* globalCtx) { break; case 2: - this->cutsceneAnimationIndex = EN_JG_ANIMATION_TAKING_OUT_DRUM; + this->cutsceneAnimIndex = EN_JG_ANIM_TAKING_OUT_DRUM; break; case 3: - this->cutsceneAnimationIndex = EN_JG_ANIMATION_DRUM_IDLE; + this->cutsceneAnimIndex = EN_JG_ANIM_DRUM_IDLE; break; case 4: - this->cutsceneAnimationIndex = EN_JG_ANIMATION_PLAYING_DRUM; + this->cutsceneAnimIndex = EN_JG_ANIM_PLAYING_DRUM; break; case 5: - this->cutsceneAnimationIndex = EN_JG_ANIMATION_THINKING; + this->cutsceneAnimIndex = EN_JG_ANIM_THINKING; break; case 6: - this->cutsceneAnimationIndex = EN_JG_ANIMATION_REMEMBERING; + this->cutsceneAnimIndex = EN_JG_ANIM_REMEMBERING; break; case 7: - this->cutsceneAnimationIndex = EN_JG_ANIMATION_STRONG_REMEMBERING; + this->cutsceneAnimIndex = EN_JG_ANIM_STRONG_REMEMBERING; break; case 8: - this->cutsceneAnimationIndex = EN_JG_ANIMATION_DEPRESSED; + this->cutsceneAnimIndex = EN_JG_ANIM_DEPRESSED; break; case 9: - this->cutsceneAnimationIndex = EN_JG_ANIMATION_CRADLE; + this->cutsceneAnimIndex = EN_JG_ANIM_CRADLE; break; default: - this->cutsceneAnimationIndex = EN_JG_ANIMATION_IDLE; + this->cutsceneAnimIndex = EN_JG_ANIM_IDLE; break; } - SubS_ChangeAnimationByInfoS(&this->skelAnime, sAnimations, this->cutsceneAnimationIndex); + SubS_ChangeAnimationByInfoS(&this->skelAnime, sAnimationInfo, this->cutsceneAnimIndex); } 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->cutsceneAnimIndex == EN_JG_ANIM_TAKING_OUT_DRUM) && (Animation_OnFrame(&this->skelAnime, 14.0f)) && + (this->action != EN_JG_ACTION_LULLABY_INTRO_CS)) || + (((this->cutsceneAnimIndex == EN_JG_ANIM_DRUM_IDLE) || + (this->cutsceneAnimIndex == EN_JG_ANIM_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, + &play->actorCtx, play, ACTOR_OBJ_JG_GAKKI, this->actor.world.pos.x, this->actor.world.pos.y, this->actor.world.pos.z, this->actor.shape.rot.x, this->actor.shape.rot.y, this->actor.shape.rot.z, this->actor.params, this->actor.cutscene, this->actor.unk20, NULL); } - if (this->cutsceneAnimationIndex == EN_JG_ANIMATION_TAKING_OUT_DRUM) { + if (this->cutsceneAnimIndex == EN_JG_ANIM_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)) { @@ -843,8 +843,8 @@ s32 EnJg_GetNextTextId(EnJg* this) { * 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); +s32 EnJg_GetStartingConversationTextId(EnJg* this, PlayState* play) { + Player* player = GET_PLAYER(play); if (!EN_JG_IS_IN_GORON_SHRINE(&this->actor)) { if (player->transformation == PLAYER_FORM_GORON) { @@ -881,11 +881,11 @@ s32 EnJg_GetStartingConversationTextId(EnJg* this, GlobalContext* globalCtx) { return 0xDCB; // Welcome to spring } -void EnJg_SpawnBreath(EnJg* this, GlobalContext* globalCtx) { +void EnJg_SpawnBreath(EnJg* this, PlayState* play) { s16 scale = (Rand_ZeroOne() * 20.0f) + 30.0f; - if (globalCtx->state.frames % 8 == 0) { - EffectSsIceSmoke_Spawn(globalCtx, &this->breathPos, &this->breathVelocity, &this->breathAccel, scale); + if (play->state.frames % 8 == 0) { + EffectSsIceSmoke_Spawn(play, &this->breathPos, &this->breathVelocity, &this->breathAccel, scale); } } @@ -897,11 +897,11 @@ void EnJg_SpawnBreath(EnJg* this, GlobalContext* globalCtx) { * 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) { +void EnJg_CheckIfTalkingToPlayerAndHandleFreezeTimer(EnJg* this, PlayState* play) { s16 currentFrame = this->skelAnime.curFrame; - s16 lastFrame = Animation_GetLastFrame(sAnimations[this->animationIndex].animation); + s16 lastFrame = Animation_GetLastFrame(sAnimationInfo[this->animIndex].animation); - if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { + if (Actor_ProcessTalkRequest(&this->actor, &play->state)) { this->flags |= FLAG_LOOKING_AT_PLAYER; this->actor.speedXZ = 0.0f; @@ -913,125 +913,125 @@ void EnJg_CheckIfTalkingToPlayerAndHandleFreezeTimer(EnJg* this, GlobalContext* gSaveContext.save.weekEventReg[24] |= 0x10; } - Message_StartTextbox(globalCtx, this->textId, &this->actor); + Message_StartTextbox(play, this->textId, &this->actor); this->actionFunc = EnJg_SetupTalk; } else { if ((this->actor.xzDistToPlayer < 100.0f) || (this->actor.isTargeted)) { - func_800B863C(&this->actor, globalCtx); + func_800B863C(&this->actor, play); if (this->action == EN_JG_ACTION_FIRST_THAW) { - this->textId = EnJg_GetStartingConversationTextId(this, globalCtx); + this->textId = EnJg_GetStartingConversationTextId(this, play); } } this->freezeTimer--; if ((this->freezeTimer <= 0) && (currentFrame == lastFrame)) { - this->animationIndex = EN_JG_ANIMATION_FROZEN_START; - SubS_ChangeAnimationByInfoS(&this->skelAnime, sAnimations, this->animationIndex); + this->animIndex = EN_JG_ANIM_FROZEN_START; + SubS_ChangeAnimationByInfoS(&this->skelAnime, sAnimationInfo, this->animIndex); Audio_PlaySfxAtPos(&sSfxPos, NA_SE_EV_FREEZE_S); this->actionFunc = EnJg_Freeze; } } } -void EnJg_Init(Actor* thisx, GlobalContext* globalCtx) { +void EnJg_Init(Actor* thisx, PlayState* play) { 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, + SkelAnime_InitFlex(play, &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); + Collider_InitCylinder(play, &this->collider); + Collider_SetCylinder(play, &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)) { + if ((play->sceneNum == SCENE_SPOT00) && (gSaveContext.sceneSetupIndex == 7) && + (play->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->animIndex = EN_JG_ANIM_IDLE; this->action = EN_JG_ACTION_LULLABY_INTRO_CS; - SubS_ChangeAnimationByInfoS(&this->skelAnime, sAnimations, this->animationIndex); + SubS_ChangeAnimationByInfoS(&this->skelAnime, sAnimationInfo, this->animIndex); 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->path = SubS_GetPathByIndex(play, EN_JG_GET_PATH(thisx), 0x3F); + this->animIndex = EN_JG_ANIM_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); + SubS_ChangeAnimationByInfoS(&this->skelAnime, sAnimationInfo, this->animIndex); this->actionFunc = EnJg_Freeze; } } else { // This is the elder that appears in Goron Shrine in spring. - this->animationIndex = EN_JG_ANIMATION_IDLE; + this->animIndex = EN_JG_ANIM_IDLE; this->cutscene = this->actor.cutscene; - SubS_ChangeAnimationByInfoS(&this->skelAnime, sAnimations, this->animationIndex); + SubS_ChangeAnimationByInfoS(&this->skelAnime, sAnimationInfo, this->animIndex); this->actionFunc = EnJg_GoronShrineIdle; } } -void EnJg_Destroy(Actor* thisx, GlobalContext* globalCtx) { +void EnJg_Destroy(Actor* thisx, PlayState* play) { EnJg* this = THIS; - Collider_DestroyCylinder(globalCtx, &this->collider); + Collider_DestroyCylinder(play, &this->collider); } -void EnJg_Update(Actor* thisx, GlobalContext* globalCtx) { +void EnJg_Update(Actor* thisx, PlayState* play) { EnJg* this = THIS; if ((this->actionFunc != EnJg_FrozenIdle) && (this->actionFunc != EnJg_EndFrozenInteraction)) { - EnJg_UpdateCollision(this, globalCtx); + EnJg_UpdateCollision(this, play); 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); + EnJg_SpawnBreath(this, play); } - func_800E9250(globalCtx, &this->actor, &this->unusedRotation1, &this->unusedRotation2, this->actor.focus.pos); + Actor_TrackPlayer(play, &this->actor, &this->unusedRotation1, &this->unusedRotation2, this->actor.focus.pos); } - this->actionFunc(this, globalCtx); + this->actionFunc(this, play); } -s32 EnJg_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, Actor* thisx) { +s32 EnJg_OverrideLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, Actor* thisx) { EnJg* this = THIS; if (limbIndex == GORON_ELDER_LIMB_ROOT) { if (this->flags & FLAG_LOOKING_AT_PLAYER) { Math_SmoothStepToS(&this->rootRotationWhenTalking, this->actor.yawTowardsPlayer - this->actor.shape.rot.y, 5, 0x1000, 0x100); - Matrix_RotateY(this->rootRotationWhenTalking, MTXMODE_APPLY); + Matrix_RotateYS(this->rootRotationWhenTalking, MTXMODE_APPLY); } else { Math_SmoothStepToS(&this->rootRotationWhenTalking, 0, 5, 0x1000, 0x100); - Matrix_RotateY(this->rootRotationWhenTalking, MTXMODE_APPLY); + Matrix_RotateYS(this->rootRotationWhenTalking, MTXMODE_APPLY); } } return false; } -void EnJg_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx) { +void EnJg_PostLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx) { EnJg* this = THIS; if (limbIndex == GORON_ELDER_LIMB_HEAD) { - Matrix_MultiplyVector3fByState(&sFocusOffset, &this->actor.focus.pos); + Matrix_MultVec3f(&sFocusOffset, &this->actor.focus.pos); } if (limbIndex == GORON_ELDER_LIMB_LOWER_LIP) { - Matrix_MultiplyVector3fByState(&sBreathPosOffset, &this->breathPos); - Matrix_RotateY(this->actor.shape.rot.y, MTXMODE_NEW); - Matrix_MultiplyVector3fByState(&sBreathVelOffset, &this->breathVelocity); - Matrix_MultiplyVector3fByState(&sBreathAccelOffset, &this->breathAccel); + 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) { +void EnJg_Draw(Actor* thisx, PlayState* play) { EnJg* this = THIS; - SkelAnime_DrawFlexOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, + SkelAnime_DrawFlexOpa(play, 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 67ba1d638..8564f8ad1 100644 --- a/src/overlays/actors/ovl_En_Jg/z_en_jg.h +++ b/src/overlays/actors/ovl_En_Jg/z_en_jg.h @@ -9,7 +9,7 @@ struct EnJg; -typedef void (*EnJgActionFunc)(struct EnJg*, GlobalContext*); +typedef void (*EnJgActionFunc)(struct EnJg*, PlayState*); typedef struct EnJg { /* 0x000 */ Actor actor; @@ -26,14 +26,14 @@ typedef struct EnJg { /* 0x1F8 */ Vec3s jointTable[GORON_ELDER_LIMB_MAX]; /* 0x2CA */ Vec3s morphTable[GORON_ELDER_LIMB_MAX]; /* 0x39C */ s16 rootRotationWhenTalking; - /* 0x39E */ s16 animationIndex; + /* 0x39E */ s16 animIndex; /* 0x3A0 */ s16 action; /* 0x3A2 */ s16 freezeTimer; /* 0x3A4 */ Vec3f breathPos; /* 0x3B0 */ Vec3f breathVelocity; /* 0x3BC */ Vec3f breathAccel; /* 0x3C8 */ s16 cutscene; - /* 0x3CA */ u8 cutsceneAnimationIndex; + /* 0x3CA */ u8 cutsceneAnimIndex; /* 0x3CB */ u8 csAction; /* 0x3CC */ u16 flags; /* 0x3CE */ u16 textId; 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 104e2bc3c..8957cfc21 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 @@ -11,30 +11,30 @@ #define THIS ((EnJgameTsn*)thisx) -void EnJgameTsn_Init(Actor* thisx, GlobalContext* globalCtx); -void EnJgameTsn_Destroy(Actor* thisx, GlobalContext* globalCtx); -void EnJgameTsn_Update(Actor* thisx, GlobalContext* globalCtx); -void EnJgameTsn_Draw(Actor* thisx, GlobalContext* globalCtx); +void EnJgameTsn_Init(Actor* thisx, PlayState* play); +void EnJgameTsn_Destroy(Actor* thisx, PlayState* play); +void EnJgameTsn_Update(Actor* thisx, PlayState* play); +void EnJgameTsn_Draw(Actor* thisx, PlayState* play); -void func_80C13A2C(EnJgameTsn* this, GlobalContext* globalCtx); +void func_80C13A2C(EnJgameTsn* this, PlayState* play); void func_80C13B74(EnJgameTsn* this); -void func_80C13BB8(EnJgameTsn* this, GlobalContext* globalCtx); +void func_80C13BB8(EnJgameTsn* this, PlayState* play); void func_80C13E6C(EnJgameTsn* this); -void func_80C13E90(EnJgameTsn* this, GlobalContext* globalCtx); -void func_80C13F9C(EnJgameTsn* this, GlobalContext* globalCtx); +void func_80C13E90(EnJgameTsn* this, PlayState* play); +void func_80C13F9C(EnJgameTsn* this, PlayState* play); void func_80C14030(EnJgameTsn* this); -void func_80C14044(EnJgameTsn* this, GlobalContext* globalCtx); -void func_80C1418C(EnJgameTsn* this, GlobalContext* globalCtx); +void func_80C14044(EnJgameTsn* this, PlayState* play); +void func_80C1418C(EnJgameTsn* this, PlayState* play); 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_80C14230(EnJgameTsn* this, PlayState* play); +void func_80C144F8(EnJgameTsn* this, PlayState* play); +void func_80C14554(EnJgameTsn* this, PlayState* play); 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); +void func_80C14610(EnJgameTsn* this, PlayState* play); +void func_80C14684(EnJgameTsn* this, PlayState* play); +void func_80C147B4(EnJgameTsn* this, PlayState* play); +s32 func_80C149B0(PlayState* play, EnJgameTsnStruct* arg1); +s32 func_80C14BCC(EnJgameTsn* this, PlayState* play); const ActorInit En_Jgame_Tsn_InitVars = { ACTOR_EN_JGAME_TSN, @@ -48,7 +48,7 @@ const ActorInit En_Jgame_Tsn_InitVars = { (ActorFunc)EnJgameTsn_Draw, }; -static AnimationInfo sAnimations[] = { +static AnimationInfo sAnimationInfo[] = { { &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 }, @@ -79,22 +79,22 @@ TexturePtr D_80C150A4[] = { object_tsn_Tex_0085B8, }; -void EnJgameTsn_Init(Actor* thisx, GlobalContext* globalCtx) { +void EnJgameTsn_Init(Actor* thisx, PlayState* play) { s32 pad; EnJgameTsn* this = THIS; 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, + SkelAnime_InitFlex(play, &this->skelAnime, &object_tsn_Skel_008AB8, &object_tsn_Anim_0092FC, this->jointTable, this->morphTable, OBJECT_TSN_LIMB_MAX); - Collider_InitCylinder(globalCtx, &this->collider); - Collider_SetCylinder(globalCtx, &this->collider, &this->actor, &sCylinderInit); + Collider_InitCylinder(play, &this->collider); + Collider_SetCylinder(play, &this->collider, &this->actor, &sCylinderInit); this->actor.targetMode = 6; this->actor.colChkInfo.mass = MASS_IMMOVABLE; this->actor.velocity.y = 0.0f; - if (gSaveContext.save.entranceIndex == 0x68D0) { + if (gSaveContext.save.entrance == ENTRANCE(GREAT_BAY_COAST, 13)) { this->actor.flags |= ACTOR_FLAG_10000; } @@ -103,12 +103,12 @@ void EnJgameTsn_Init(Actor* thisx, GlobalContext* globalCtx) { this->unk_21C = 0; this->unk_2FE = 0; - func_80C13A2C(this, globalCtx); + func_80C13A2C(this, play); func_80C13B74(this); } -void func_80C13A2C(EnJgameTsn* this, GlobalContext* globalCtx) { - Path* path = &globalCtx->setupPathList[ENJGAMETSN_GET_FF(&this->actor)]; +void func_80C13A2C(EnJgameTsn* this, PlayState* play) { + Path* path = &play->setupPathList[ENJGAMETSN_GET_FF(&this->actor)]; s32 i; if (path == NULL) { @@ -119,7 +119,7 @@ void func_80C13A2C(EnJgameTsn* this, GlobalContext* globalCtx) { this->unk_1D8[i].points = Lib_SegmentedToVirtual(path->points); this->unk_1D8[i].count = path->count; - path = &globalCtx->setupPathList[path->unk1]; + path = &play->setupPathList[path->unk1]; if (path == NULL) { Actor_MarkForDeath(&this->actor); } @@ -128,7 +128,7 @@ void func_80C13A2C(EnJgameTsn* this, GlobalContext* globalCtx) { this->unk_1F8.points = Lib_SegmentedToVirtual(path->points); this->unk_1F8.count = path->count; - path = &globalCtx->setupPathList[path->unk1]; + path = &play->setupPathList[path->unk1]; if (path == NULL) { Actor_MarkForDeath(&this->actor); } @@ -137,60 +137,60 @@ void func_80C13A2C(EnJgameTsn* this, GlobalContext* globalCtx) { this->unk_200.count = path->count; } -void EnJgameTsn_Destroy(Actor* thisx, GlobalContext* globalCtx) { +void EnJgameTsn_Destroy(Actor* thisx, PlayState* play) { EnJgameTsn* this = THIS; - Collider_DestroyCylinder(globalCtx, &this->collider); + Collider_DestroyCylinder(play, &this->collider); gSaveContext.save.weekEventReg[90] &= (u8)~0x20; } void func_80C13B74(EnJgameTsn* this) { - Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 0); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, 0); this->actionFunc = func_80C13BB8; } -void func_80C13BB8(EnJgameTsn* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); +void func_80C13BB8(EnJgameTsn* this, PlayState* play) { + Player* player = GET_PLAYER(play); - if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { + if (Actor_ProcessTalkRequest(&this->actor, &play->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); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, 1); + Message_StartTextbox(play, 0x10A2, &this->actor); this->unk_300 = 0x10A2; } else if (gSaveContext.minigameScore < 20) { - Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 1); - Message_StartTextbox(globalCtx, 0x10A2, &this->actor); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, 1); + Message_StartTextbox(play, 0x10A2, &this->actor); this->unk_300 = 0x10A2; } else { - Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 2); - Message_StartTextbox(globalCtx, 0x10A3, &this->actor); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, 2); + Message_StartTextbox(play, 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); + Message_StartTextbox(play, 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); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, 1); + Message_StartTextbox(play, 0x1095, &this->actor); this->unk_300 = 0x1095; } else { - Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 1); - Message_StartTextbox(globalCtx, 0x1096, &this->actor); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, 1); + Message_StartTextbox(play, 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); + func_800B8614(&this->actor, play, 200.0f); } else { - func_800B8614(&this->actor, globalCtx, 80.0f); + func_800B8614(&this->actor, play, 80.0f); } if ((player->actor.bgCheckFlags & 1) && !(player->stateFlags1 & 0x2000) && (this->unk_2FE == 0) && - (gSaveContext.save.playerForm == PLAYER_FORM_HUMAN) && func_80C149B0(globalCtx, &this->unk_1F8)) { + (gSaveContext.save.playerForm == PLAYER_FORM_HUMAN) && func_80C149B0(play, &this->unk_1F8)) { this->unk_2FE = 1; func_80C13E6C(this); } else if (!(player->actor.bgCheckFlags & 1)) { @@ -206,22 +206,22 @@ void func_80C13E6C(EnJgameTsn* this) { this->actionFunc = func_80C13E90; } -void func_80C13E90(EnJgameTsn* this, GlobalContext* globalCtx) { - if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { +void func_80C13E90(EnJgameTsn* this, PlayState* play) { + if (Actor_ProcessTalkRequest(&this->actor, &play->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); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, 2); + Message_StartTextbox(play, 0x1094, &this->actor); this->unk_300 = 0x1094; } else { - Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 1); - Message_StartTextbox(globalCtx, 0x1098, &this->actor); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, 1); + Message_StartTextbox(play, 0x1098, &this->actor); this->unk_300 = 0x1098; } func_80C14030(this); } else { - func_800B8614(&this->actor, globalCtx, 1000.0f); + func_800B8614(&this->actor, play, 1000.0f); } } @@ -229,7 +229,7 @@ void func_80C13F88(EnJgameTsn* this) { this->actionFunc = func_80C13F9C; } -void func_80C13F9C(EnJgameTsn* this, GlobalContext* globalCtx) { +void func_80C13F9C(EnJgameTsn* this, PlayState* play) { if (this->actor.cutscene != -1) { if (ActorCutscene_GetCanPlayNext(this->actor.cutscene)) { ActorCutscene_StartAndSetUnkLinkFields(this->actor.cutscene, &this->actor); @@ -249,24 +249,24 @@ void func_80C14030(EnJgameTsn* this) { this->actionFunc = func_80C14044; } -void func_80C14044(EnJgameTsn* this, GlobalContext* globalCtx) { - switch (Message_GetState(&globalCtx->msgCtx)) { - case 0: - case 1: - case 2: - case 3: +void func_80C14044(EnJgameTsn* this, PlayState* play) { + switch (Message_GetState(&play->msgCtx)) { + case TEXT_STATE_NONE: + case TEXT_STATE_1: + case TEXT_STATE_CLOSING: + case TEXT_STATE_3: break; - case 4: - func_80C14684(this, globalCtx); + case TEXT_STATE_CHOICE: + func_80C14684(this, play); break; - case 5: - func_80C147B4(this, globalCtx); + case TEXT_STATE_5: + func_80C147B4(this, play); break; - case 6: - if (Message_ShouldAdvance(globalCtx)) { + case TEXT_STATE_DONE: + if (Message_ShouldAdvance(play)) { if (ActorCutscene_GetCurrentIndex() == this->actor.cutscene) { ActorCutscene_Stop(this->actor.cutscene); } @@ -279,22 +279,22 @@ void func_80C14044(EnJgameTsn* this, GlobalContext* globalCtx) { this->actor.world.rot.y = this->actor.shape.rot.y; } -void func_80C1410C(EnJgameTsn* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); +void func_80C1410C(EnJgameTsn* this, PlayState* play) { + Player* player = GET_PLAYER(play); player->stateFlags1 |= 0x20; func_801A2BB8(0x25); - globalCtx->interfaceCtx.unk_280 = 1; - func_80112AFC(globalCtx); + play->interfaceCtx.unk_280 = 1; + func_80112AFC(play); gSaveContext.save.weekEventReg[90] |= 0x20; func_8010E9F0(4, 0x78); this->actionFunc = func_80C1418C; } -void func_80C1418C(EnJgameTsn* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); +void func_80C1418C(EnJgameTsn* this, PlayState* play) { + Player* player = GET_PLAYER(play); - if (globalCtx->interfaceCtx.unk_280 == 8) { + if (play->interfaceCtx.unk_280 == 8) { func_80C141DC(this); player->stateFlags1 &= ~0x20; } @@ -303,17 +303,17 @@ void func_80C1418C(EnJgameTsn* this, GlobalContext* globalCtx) { void func_80C141DC(EnJgameTsn* this) { this->unk_218 = Rand_Next() & 3; this->unk_2FC = 0; - *this->unk_208[this->unk_218] |= 1; + *this->unk_208[this->unk_218] |= OBJLUPYGAMELIFT_IGNITE_FIRE; this->actionFunc = func_80C14230; } -void func_80C14230(EnJgameTsn* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); +void func_80C14230(EnJgameTsn* this, PlayState* play) { + Player* player = GET_PLAYER(play); s32 i; s32 rand; - if ((this->unk_2FC > 100) || func_80C14BCC(this, globalCtx)) { - rand = (u32)Rand_Next() % 3; + if ((this->unk_2FC > 100) || func_80C14BCC(this, play)) { + rand = Rand_Next() % 3; this->unk_2FC = 0; if (rand < this->unk_218) { @@ -324,39 +324,39 @@ void func_80C14230(EnJgameTsn* this, GlobalContext* globalCtx) { for (i = 0; i < ARRAY_COUNT(this->unk_208); i++) { if (i == this->unk_218) { - *this->unk_208[i] |= 1; - *this->unk_208[i] &= ~8; + *this->unk_208[i] |= OBJLUPYGAMELIFT_IGNITE_FIRE; + *this->unk_208[i] &= ~OBJLUPYGAMELIFT_SNUFF_FIRE; } else { - *this->unk_208[i] |= 8; + *this->unk_208[i] |= OBJLUPYGAMELIFT_SNUFF_FIRE; } } } 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); + if ((player->actor.bgCheckFlags & 2) && func_80C149B0(play, &this->unk_200)) { + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, 2); + Message_StartTextbox(play, 0x109F, &this->actor); this->unk_300 = 0x109F; player->stateFlags1 |= 0x20; - *this->unk_208[this->unk_218] &= ~1; + *this->unk_208[this->unk_218] &= ~OBJLUPYGAMELIFT_IGNITE_FIRE; func_801A2C20(); func_80C14030(this); } else if ((player->actor.bgCheckFlags & 0x40) || (player->actor.bgCheckFlags & 0x20)) { - Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 2); - Message_StartTextbox(globalCtx, 0x10A0, &this->actor); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, 2); + Message_StartTextbox(play, 0x10A0, &this->actor); this->unk_300 = 0x10A0; player->stateFlags1 |= 0x20; - *this->unk_208[this->unk_218] &= ~1; + *this->unk_208[this->unk_218] &= ~OBJLUPYGAMELIFT_IGNITE_FIRE; func_801A2C20(); func_80C14030(this); } if (gSaveContext.unk_3DE0[4] == 0) { - Message_StartTextbox(globalCtx, 0x10A1, &this->actor); + Message_StartTextbox(play, 0x10A1, &this->actor); this->unk_300 = 0x10A1; player->stateFlags1 |= 0x20; - *this->unk_208[this->unk_218] &= ~1; + *this->unk_208[this->unk_218] &= ~OBJLUPYGAMELIFT_IGNITE_FIRE; func_801A2C20(); func_80C14030(this); } @@ -366,27 +366,27 @@ 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_80C144F8(EnJgameTsn* this, PlayState* play) { + play->nextEntrance = ENTRANCE(GREAT_BAY_COAST, 13); + play->transitionTrigger = TRANS_TRIGGER_START; + play->transitionType = TRANS_TYPE_80; + gSaveContext.nextTransitionType = TRANS_TYPE_03; } void func_80C14540(EnJgameTsn* this) { this->actionFunc = func_80C14554; } -void func_80C14554(EnJgameTsn* this, GlobalContext* globalCtx) { - if (Actor_HasParent(&this->actor, globalCtx)) { +void func_80C14554(EnJgameTsn* this, PlayState* play) { + if (Actor_HasParent(&this->actor, play)) { 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); + Actor_PickUp(&this->actor, play, GI_RUPEE_PURPLE, 500.0f, 100.0f); } else { - Actor_PickUp(&this->actor, globalCtx, GI_HEART_PIECE, 500.0f, 100.0f); + Actor_PickUp(&this->actor, play, GI_HEART_PIECE, 500.0f, 100.0f); } } @@ -394,38 +394,38 @@ 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); +void func_80C14610(EnJgameTsn* this, PlayState* play) { + if (Actor_ProcessTalkRequest(&this->actor, &play->state)) { + Message_StartTextbox(play, 0x10A4, &this->actor); this->unk_300 = 0x10A4; func_80C14030(this); } else { - func_800B85E0(&this->actor, globalCtx, 200.0f, -1); + func_800B85E0(&this->actor, play, 200.0f, -1); } } -void func_80C14684(EnJgameTsn* this, GlobalContext* globalCtx) { - if (Message_ShouldAdvance(globalCtx)) { - if (globalCtx->msgCtx.choiceIndex == 0) { +void func_80C14684(EnJgameTsn* this, PlayState* play) { + if (Message_ShouldAdvance(play)) { + if (play->msgCtx.choiceIndex == 0) { if (gSaveContext.save.playerData.rupees >= 20) { - Message_StartTextbox(globalCtx, 0x109E, &this->actor); + Message_StartTextbox(play, 0x109E, &this->actor); this->unk_300 = 0x109E; - func_801159EC(-20); + Rupees_ChangeBy(-20); } else { - Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 2); - Message_StartTextbox(globalCtx, 0x109D, &this->actor); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, 2); + Message_StartTextbox(play, 0x109D, &this->actor); this->unk_300 = 0x109D; } } else { - Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 2); - Message_StartTextbox(globalCtx, 0x109C, &this->actor); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, 2); + Message_StartTextbox(play, 0x109C, &this->actor); this->unk_300 = 0x109C; } } } -void func_80C1476C(EnJgameTsn* this, GlobalContext* globalCtx) { - Actor* prop = globalCtx->actorCtx.actorLists[ACTORCAT_PROP].first; +void func_80C1476C(EnJgameTsn* this, PlayState* play) { + Actor* prop = play->actorCtx.actorLists[ACTORCAT_PROP].first; while (prop != NULL) { if (prop->id == ACTOR_OBJ_JGAME_LIGHT) { @@ -435,33 +435,33 @@ void func_80C1476C(EnJgameTsn* this, GlobalContext* globalCtx) { } } -void func_80C147B4(EnJgameTsn* this, GlobalContext* globalCtx) { - if (Message_ShouldAdvance(globalCtx)) { +void func_80C147B4(EnJgameTsn* this, PlayState* play) { + if (Message_ShouldAdvance(play)) { switch (this->unk_300) { case 0x1095: - Message_StartTextbox(globalCtx, 0x1096, &this->actor); + Message_StartTextbox(play, 0x1096, &this->actor); this->unk_300 = 0x1096; break; case 0x1096: - Message_StartTextbox(globalCtx, 0x1097, &this->actor); + Message_StartTextbox(play, 0x1097, &this->actor); this->unk_300 = 0x1097; break; case 0x1098: - Message_StartTextbox(globalCtx, 0x1099, &this->actor); + Message_StartTextbox(play, 0x1099, &this->actor); this->unk_300 = 0x1099; func_80C13F88(this); break; case 0x1099: - Message_StartTextbox(globalCtx, 0x109A, &this->actor); + Message_StartTextbox(play, 0x109A, &this->actor); this->unk_300 = 0x109A; break; case 0x109A: - Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 0); - Message_StartTextbox(globalCtx, 0x109B, &this->actor); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, 0); + Message_StartTextbox(play, 0x109B, &this->actor); this->unk_300 = 0x109B; break; @@ -469,15 +469,15 @@ void func_80C147B4(EnJgameTsn* this, GlobalContext* globalCtx) { if (ActorCutscene_GetCurrentIndex() == this->actor.cutscene) { ActorCutscene_Stop(this->actor.cutscene); } - func_801477B4(globalCtx); - func_80C1476C(this, globalCtx); - func_80C1410C(this, globalCtx); + func_801477B4(play); + func_80C1476C(this, play); + func_80C1410C(this, play); break; case 0x109F: case 0x10A0: case 0x10A1: - func_801477B4(globalCtx); + func_801477B4(play); gSaveContext.minigameState = 3; gSaveContext.unk_3DD0[4] = 5; gSaveContext.save.weekEventReg[90] &= (u8)~0x20; @@ -485,9 +485,9 @@ void func_80C147B4(EnJgameTsn* this, GlobalContext* globalCtx) { break; case 0x10A3: - func_801477B4(globalCtx); + func_801477B4(play); func_80C14540(this); - func_80C14554(this, globalCtx); + func_80C14554(this, play); break; } } @@ -504,10 +504,10 @@ s32 func_80C14960(Vec2f arg0, Vec2f arg1) { return phi_v1; } -s32 func_80C149B0(GlobalContext* globalCtx, EnJgameTsnStruct* arg1) { +s32 func_80C149B0(PlayState* play, EnJgameTsnStruct* arg1) { s32 i = 1; s32 temp_s3; - Player* player = GET_PLAYER(globalCtx); + Player* player = GET_PLAYER(play); Vec2f sp64; Vec2f sp5C; s32 sp58 = true; @@ -544,14 +544,14 @@ s32 func_80C149B0(GlobalContext* globalCtx, EnJgameTsnStruct* arg1) { return sp58; } -s32 func_80C14BCC(EnJgameTsn* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); +s32 func_80C14BCC(EnJgameTsn* this, PlayState* play) { + Player* player = GET_PLAYER(play); 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])) { + if (func_80C149B0(play, &this->unk_1D8[i])) { phi_s3 = i; } } @@ -562,17 +562,17 @@ s32 func_80C14BCC(EnJgameTsn* this, GlobalContext* globalCtx) { 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; + *this->unk_208[phi_s3] |= OBJLUPYGAMELIFT_DISPLAY_CORRECT; + play->interfaceCtx.unk_25C = 1; return true; } - if (*this->unk_208[phi_s3] & 1) { + if (*this->unk_208[phi_s3] & OBJLUPYGAMELIFT_IGNITE_FIRE) { Actor_PlaySfxAtPos(&this->actor, NA_SE_SY_TRE_BOX_APPEAR); - *this->unk_208[phi_s3] |= 2; - globalCtx->interfaceCtx.unk_25C = 1; + *this->unk_208[phi_s3] |= OBJLUPYGAMELIFT_DISPLAY_CORRECT; + play->interfaceCtx.unk_25C = 1; } else { - *this->unk_208[phi_s3] |= 4; + *this->unk_208[phi_s3] |= OBJLUPYGAMELIFT_DISPLAY_INCORRECT; Actor_PlaySfxAtPos(&this->actor, NA_SE_SY_ERROR); } } @@ -580,13 +580,13 @@ s32 func_80C14BCC(EnJgameTsn* this, GlobalContext* globalCtx) { return false; } -void func_80C14D14(EnJgameTsn* this, GlobalContext* globalCtx) { +void func_80C14D14(EnJgameTsn* this, PlayState* play) { Collider_UpdateCylinder(&this->actor, &this->collider); - CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + CollisionCheck_SetOC(play, &play->colChkCtx, &this->collider.base); } -void func_80C14D58(EnJgameTsn* this, GlobalContext* globalCtx) { - func_800E9250(globalCtx, &this->actor, &this->unk_2EC, &this->unk_2F2, this->actor.focus.pos); +void func_80C14D58(EnJgameTsn* this, PlayState* play) { + Actor_TrackPlayer(play, &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); @@ -599,18 +599,17 @@ void func_80C14D58(EnJgameTsn* this, GlobalContext* globalCtx) { } } -void EnJgameTsn_Update(Actor* thisx, GlobalContext* globalCtx) { +void EnJgameTsn_Update(Actor* thisx, PlayState* play) { EnJgameTsn* this = THIS; - this->actionFunc(this, globalCtx); + this->actionFunc(this, play); SkelAnime_Update(&this->skelAnime); - func_80C14D14(this, globalCtx); - func_80C14D58(this, globalCtx); + func_80C14D14(this, play); + func_80C14D58(this, play); } -s32 EnJgamesTsn_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, - Actor* thisx) { +s32 EnJgamesTsn_OverrideLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, Actor* thisx) { EnJgameTsn* this = THIS; s16 temp_v0 = this->unk_2EC.x >> 1; @@ -624,24 +623,24 @@ s32 EnJgamesTsn_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** return false; } -void EnJgamesTsn_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx) { +void EnJgamesTsn_PostLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx) { if (limbIndex == OBJECT_TSN_LIMB_0F) { - Matrix_GetStateTranslation(&thisx->focus.pos); + Matrix_MultZero(&thisx->focus.pos); } } -void EnJgameTsn_Draw(Actor* thisx, GlobalContext* globalCtx) { +void EnJgameTsn_Draw(Actor* thisx, PlayState* play) { EnJgameTsn* this = THIS; - OPEN_DISPS(globalCtx->state.gfxCtx); + OPEN_DISPS(play->state.gfxCtx); - func_8012C5B0(globalCtx->state.gfxCtx); + func_8012C5B0(play->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, + SkelAnime_DrawFlexOpa(play, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, EnJgamesTsn_OverrideLimbDraw, EnJgamesTsn_PostLimbDraw, &this->actor); - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->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 08d07376d..5fdf911cc 100644 --- a/src/overlays/actors/ovl_En_Jgame_Tsn/z_en_jgame_tsn.h +++ b/src/overlays/actors/ovl_En_Jgame_Tsn/z_en_jgame_tsn.h @@ -6,7 +6,7 @@ struct EnJgameTsn; -typedef void (*EnJgameTsnActionFunc)(struct EnJgameTsn*, GlobalContext*); +typedef void (*EnJgameTsnActionFunc)(struct EnJgameTsn*, PlayState*); #define ENJGAMETSN_GET_FF(thisx) ((thisx)->params & 0xFF) @@ -16,25 +16,25 @@ typedef struct { } EnJgameTsnStruct; // size = 0x8 typedef struct EnJgameTsn { - /* 0x0000 */ Actor actor; - /* 0x0144 */ ColliderCylinder collider; - /* 0x0190 */ SkelAnime skelAnime; - /* 0x01D4 */ EnJgameTsnActionFunc actionFunc; - /* 0x01D8 */ EnJgameTsnStruct unk_1D8[4]; - /* 0x01F8 */ EnJgameTsnStruct unk_1F8; - /* 0x0200 */ EnJgameTsnStruct unk_200; - /* 0x0208 */ u8* unk_208[4]; - /* 0x0218 */ s32 unk_218; - /* 0x021C */ s32 unk_21C; - /* 0x0220 */ Vec3s jointTable[OBJECT_TSN_LIMB_MAX]; - /* 0x0286 */ Vec3s morphTable[OBJECT_TSN_LIMB_MAX]; - /* 0x02EC */ Vec3s unk_2EC; - /* 0x02F2 */ Vec3s unk_2F2; - /* 0x02F8 */ s16 unk_2F8; - /* 0x02FA */ s16 unk_2FA; - /* 0x02FC */ s16 unk_2FC; - /* 0x02FE */ s16 unk_2FE; - /* 0x0300 */ u16 unk_300; + /* 0x000 */ Actor actor; + /* 0x144 */ ColliderCylinder collider; + /* 0x190 */ SkelAnime skelAnime; + /* 0x1D4 */ EnJgameTsnActionFunc actionFunc; + /* 0x1D8 */ EnJgameTsnStruct unk_1D8[4]; + /* 0x1F8 */ EnJgameTsnStruct unk_1F8; + /* 0x200 */ EnJgameTsnStruct unk_200; + /* 0x208 */ u8* unk_208[4]; + /* 0x218 */ s32 unk_218; + /* 0x21C */ s32 unk_21C; + /* 0x220 */ Vec3s jointTable[OBJECT_TSN_LIMB_MAX]; + /* 0x286 */ Vec3s morphTable[OBJECT_TSN_LIMB_MAX]; + /* 0x2EC */ Vec3s unk_2EC; + /* 0x2F2 */ Vec3s unk_2F2; + /* 0x2F8 */ s16 unk_2F8; + /* 0x2FA */ s16 unk_2FA; + /* 0x2FC */ s16 unk_2FC; + /* 0x2FE */ s16 unk_2FE; + /* 0x300 */ u16 unk_300; } EnJgameTsn; // size = 0x304 extern const ActorInit En_Jgame_Tsn_InitVars; diff --git a/src/overlays/actors/ovl_En_Js/z_en_js.c b/src/overlays/actors/ovl_En_Js/z_en_js.c index 15426db82..57763a190 100644 --- a/src/overlays/actors/ovl_En_Js/z_en_js.c +++ b/src/overlays/actors/ovl_En_Js/z_en_js.c @@ -10,10 +10,10 @@ #define THIS ((EnJs*)thisx) -void EnJs_Init(Actor* thisx, GlobalContext* globalCtx); -void EnJs_Destroy(Actor* thisx, GlobalContext* globalCtx); -void EnJs_Update(Actor* thisx, GlobalContext* globalCtx); -void EnJs_Draw(Actor* thisx, GlobalContext* globalCtx); +void EnJs_Init(Actor* thisx, PlayState* play); +void EnJs_Destroy(Actor* thisx, PlayState* play); +void EnJs_Update(Actor* thisx, PlayState* play); +void EnJs_Draw(Actor* thisx, PlayState* play); #if 0 const ActorInit En_Js_InitVars = { diff --git a/src/overlays/actors/ovl_En_Js/z_en_js.h b/src/overlays/actors/ovl_En_Js/z_en_js.h index db5660518..96c1bbf49 100644 --- a/src/overlays/actors/ovl_En_Js/z_en_js.h +++ b/src/overlays/actors/ovl_En_Js/z_en_js.h @@ -5,12 +5,12 @@ struct EnJs; -typedef void (*EnJsActionFunc)(struct EnJs*, GlobalContext*); +typedef void (*EnJsActionFunc)(struct EnJs*, PlayState*); typedef struct EnJs { - /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x180]; - /* 0x02C4 */ EnJsActionFunc actionFunc; + /* 0x000 */ Actor actor; + /* 0x144 */ char unk_144[0x180]; + /* 0x2C4 */ EnJsActionFunc actionFunc; } EnJs; // size = 0x2C8 extern const ActorInit En_Js_InitVars; diff --git a/src/overlays/actors/ovl_En_Jso/z_en_jso.c b/src/overlays/actors/ovl_En_Jso/z_en_jso.c index 3c7e5ce75..4baeaafa9 100644 --- a/src/overlays/actors/ovl_En_Jso/z_en_jso.c +++ b/src/overlays/actors/ovl_En_Jso/z_en_jso.c @@ -10,27 +10,27 @@ #define THIS ((EnJso*)thisx) -void EnJso_Init(Actor* thisx, GlobalContext* globalCtx); -void EnJso_Destroy(Actor* thisx, GlobalContext* globalCtx); -void EnJso_Update(Actor* thisx, GlobalContext* globalCtx); +void EnJso_Init(Actor* thisx, PlayState* play); +void EnJso_Destroy(Actor* thisx, PlayState* play); +void EnJso_Update(Actor* thisx, PlayState* play); -void func_809ADCB8(EnJso* this, GlobalContext* globalCtx); -void func_809AE87C(EnJso* this, GlobalContext* globalCtx); -void func_809AEA08(EnJso* this, GlobalContext* globalCtx); -void func_809AED00(EnJso* this, GlobalContext* globalCtx); -void func_809AEDAC(EnJso* this, GlobalContext* globalCtx); -void func_809AEEC0(EnJso* this, GlobalContext* globalCtx); -void func_809AF110(EnJso* this, GlobalContext* globalCtx); -void func_809AF2F8(EnJso* this, GlobalContext* globalCtx); -void func_809AF3C0(EnJso* this, GlobalContext* globalCtx); -void func_809AF440(EnJso* this, GlobalContext* globalCtx); -void func_809AF53C(EnJso* this, GlobalContext* globalCtx); -void func_809AF714(EnJso* this, GlobalContext* globalCtx); -void func_809AF7F4(EnJso* this, GlobalContext* globalCtx); -void func_809AF99C(EnJso* this, GlobalContext* globalCtx); -void func_809AFAF4(EnJso* this, GlobalContext* globalCtx); -void func_809AFC10(EnJso* this, GlobalContext* globalCtx); -void func_809AFE38(EnJso* this, GlobalContext* globalCtx); +void func_809ADCB8(EnJso* this, PlayState* play); +void func_809AE87C(EnJso* this, PlayState* play); +void func_809AEA08(EnJso* this, PlayState* play); +void func_809AED00(EnJso* this, PlayState* play); +void func_809AEDAC(EnJso* this, PlayState* play); +void func_809AEEC0(EnJso* this, PlayState* play); +void func_809AF110(EnJso* this, PlayState* play); +void func_809AF2F8(EnJso* this, PlayState* play); +void func_809AF3C0(EnJso* this, PlayState* play); +void func_809AF440(EnJso* this, PlayState* play); +void func_809AF53C(EnJso* this, PlayState* play); +void func_809AF714(EnJso* this, PlayState* play); +void func_809AF7F4(EnJso* this, PlayState* play); +void func_809AF99C(EnJso* this, PlayState* play); +void func_809AFAF4(EnJso* this, PlayState* play); +void func_809AFC10(EnJso* this, PlayState* play); +void func_809AFE38(EnJso* this, PlayState* play); #if 0 // static DamageTable sDamageTable = { diff --git a/src/overlays/actors/ovl_En_Jso/z_en_jso.h b/src/overlays/actors/ovl_En_Jso/z_en_jso.h index 5b7e7630d..e2961c3ae 100644 --- a/src/overlays/actors/ovl_En_Jso/z_en_jso.h +++ b/src/overlays/actors/ovl_En_Jso/z_en_jso.h @@ -5,13 +5,13 @@ struct EnJso; -typedef void (*EnJsoActionFunc)(struct EnJso*, GlobalContext*); +typedef void (*EnJsoActionFunc)(struct EnJso*, PlayState*); typedef struct EnJso { - /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x134]; - /* 0x0278 */ EnJsoActionFunc actionFunc; - /* 0x027C */ char unk_27C[0xD70]; + /* 0x000 */ Actor actor; + /* 0x144 */ char unk_144[0x134]; + /* 0x278 */ EnJsoActionFunc actionFunc; + /* 0x27C */ char unk_27C[0xD70]; } EnJso; // size = 0xFEC extern const ActorInit En_Jso_InitVars; diff --git a/src/overlays/actors/ovl_En_Jso2/z_en_jso2.c b/src/overlays/actors/ovl_En_Jso2/z_en_jso2.c index 8d29b9383..874cac6bd 100644 --- a/src/overlays/actors/ovl_En_Jso2/z_en_jso2.c +++ b/src/overlays/actors/ovl_En_Jso2/z_en_jso2.c @@ -10,29 +10,29 @@ #define THIS ((EnJso2*)thisx) -void EnJso2_Init(Actor* thisx, GlobalContext* globalCtx); -void EnJso2_Destroy(Actor* thisx, GlobalContext* globalCtx); -void EnJso2_Update(Actor* thisx, GlobalContext* globalCtx); -void EnJso2_Draw(Actor* thisx, GlobalContext* globalCtx); +void EnJso2_Init(Actor* thisx, PlayState* play); +void EnJso2_Destroy(Actor* thisx, PlayState* play); +void EnJso2_Update(Actor* thisx, PlayState* play); +void EnJso2_Draw(Actor* thisx, PlayState* play); -void func_80A778F8(EnJso2* this, GlobalContext* globalCtx); -void func_80A785E4(EnJso2* this, GlobalContext* globalCtx); -void func_80A78868(EnJso2* this, GlobalContext* globalCtx); -void func_80A78ACC(EnJso2* this, GlobalContext* globalCtx); -void func_80A78B70(EnJso2* this, GlobalContext* globalCtx); -void func_80A78C7C(EnJso2* this, GlobalContext* globalCtx); -void func_80A78F04(EnJso2* this, GlobalContext* globalCtx); -void func_80A79038(EnJso2* this, GlobalContext* globalCtx); -void func_80A7919C(EnJso2* this, GlobalContext* globalCtx); -void func_80A79364(EnJso2* this, GlobalContext* globalCtx); -void func_80A794C8(EnJso2* this, GlobalContext* globalCtx); -void func_80A79600(EnJso2* this, GlobalContext* globalCtx); -void func_80A7980C(EnJso2* this, GlobalContext* globalCtx); -void func_80A798C8(EnJso2* this, GlobalContext* globalCtx); -void func_80A79A84(EnJso2* this, GlobalContext* globalCtx); -void func_80A79BA0(EnJso2* this, GlobalContext* globalCtx); -void func_80A7A124(EnJso2* this, GlobalContext* globalCtx); -void func_80A7A2EC(EnJso2* this, GlobalContext* globalCtx); +void func_80A778F8(EnJso2* this, PlayState* play); +void func_80A785E4(EnJso2* this, PlayState* play); +void func_80A78868(EnJso2* this, PlayState* play); +void func_80A78ACC(EnJso2* this, PlayState* play); +void func_80A78B70(EnJso2* this, PlayState* play); +void func_80A78C7C(EnJso2* this, PlayState* play); +void func_80A78F04(EnJso2* this, PlayState* play); +void func_80A79038(EnJso2* this, PlayState* play); +void func_80A7919C(EnJso2* this, PlayState* play); +void func_80A79364(EnJso2* this, PlayState* play); +void func_80A794C8(EnJso2* this, PlayState* play); +void func_80A79600(EnJso2* this, PlayState* play); +void func_80A7980C(EnJso2* this, PlayState* play); +void func_80A798C8(EnJso2* this, PlayState* play); +void func_80A79A84(EnJso2* this, PlayState* play); +void func_80A79BA0(EnJso2* this, PlayState* play); +void func_80A7A124(EnJso2* this, PlayState* play); +void func_80A7A2EC(EnJso2* this, PlayState* play); #if 0 // static DamageTable sDamageTable = { diff --git a/src/overlays/actors/ovl_En_Jso2/z_en_jso2.h b/src/overlays/actors/ovl_En_Jso2/z_en_jso2.h index 9a52e20b5..30f7872d5 100644 --- a/src/overlays/actors/ovl_En_Jso2/z_en_jso2.h +++ b/src/overlays/actors/ovl_En_Jso2/z_en_jso2.h @@ -5,7 +5,7 @@ struct EnJso2; -typedef void (*EnJso2ActionFunc)(struct EnJso2*, GlobalContext*); +typedef void (*EnJso2ActionFunc)(struct EnJso2*, PlayState*); typedef struct EnJso2 { /* 0x0000 */ Actor actor; 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 721e8c1a4..6e4130576 100644 --- a/src/overlays/actors/ovl_En_Kaizoku/z_en_kaizoku.c +++ b/src/overlays/actors/ovl_En_Kaizoku/z_en_kaizoku.c @@ -10,9 +10,9 @@ #define THIS ((EnKaizoku*)thisx) -void EnKaizoku_Init(Actor* thisx, GlobalContext* globalCtx); -void EnKaizoku_Destroy(Actor* thisx, GlobalContext* globalCtx); -void EnKaizoku_Update(Actor* thisx, GlobalContext* globalCtx); +void EnKaizoku_Init(Actor* thisx, PlayState* play); +void EnKaizoku_Destroy(Actor* thisx, PlayState* play); +void EnKaizoku_Update(Actor* thisx, PlayState* play); #if 0 // static DamageTable sDamageTable = { diff --git a/src/overlays/actors/ovl_En_Kaizoku/z_en_kaizoku.h b/src/overlays/actors/ovl_En_Kaizoku/z_en_kaizoku.h index db49373f8..8ef208926 100644 --- a/src/overlays/actors/ovl_En_Kaizoku/z_en_kaizoku.h +++ b/src/overlays/actors/ovl_En_Kaizoku/z_en_kaizoku.h @@ -5,16 +5,16 @@ struct EnKaizoku; -typedef void (*EnKaizokuActionFunc)(struct EnKaizoku*, GlobalContext*); +typedef void (*EnKaizokuActionFunc)(struct EnKaizoku*, PlayState*); typedef struct EnKaizoku { - /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x168]; - /* 0x02AC */ EnKaizokuActionFunc actionFunc; - /* 0x02B0 */ char unk_2B0[0x40]; - /* 0x02F0 */ f32 unk_2F0; - /* 0x02F4 */ s16 unk_2F4; - /* 0x02F6 */ char unk_2F6[0x2FA]; + /* 0x000 */ Actor actor; + /* 0x144 */ char unk_144[0x168]; + /* 0x2AC */ EnKaizokuActionFunc actionFunc; + /* 0x2B0 */ char unk_2B0[0x40]; + /* 0x2F0 */ f32 unk_2F0; + /* 0x2F4 */ s16 unk_2F4; + /* 0x2F6 */ char unk_2F6[0x2FA]; } EnKaizoku; // size = 0x5F0 extern const ActorInit En_Kaizoku_InitVars; diff --git a/src/overlays/actors/ovl_En_Kakasi/z_en_kakasi.c b/src/overlays/actors/ovl_En_Kakasi/z_en_kakasi.c index c3194461d..b78b65a19 100644 --- a/src/overlays/actors/ovl_En_Kakasi/z_en_kakasi.c +++ b/src/overlays/actors/ovl_En_Kakasi/z_en_kakasi.c @@ -4,6 +4,7 @@ * Description: Pierre the Scarecorw */ +#include "prevent_bss_reordering.h" #include "z_en_kakasi.h" #include "objects/object_ka/object_ka.h" @@ -11,38 +12,38 @@ #define THIS ((EnKakasi*)thisx) -void EnKakasi_Init(Actor* thisx, GlobalContext* globalCtx); -void EnKakasi_Destroy(Actor* thisx, GlobalContext* globalCtx); -void EnKakasi_Update(Actor* thisx, GlobalContext* globalCtx); -void EnKakasi_Draw(Actor* thisx, GlobalContext* globalCtx); +void EnKakasi_Init(Actor* thisx, PlayState* play); +void EnKakasi_Destroy(Actor* thisx, PlayState* play); +void EnKakasi_Update(Actor* thisx, PlayState* play); +void EnKakasi_Draw(Actor* thisx, PlayState* play); -void EnKakasi_SetupPostSongLearnDialogue(EnKakasi* this, GlobalContext* globalCtx); +void EnKakasi_SetupPostSongLearnDialogue(EnKakasi* this, PlayState* play); void EnKakasi_InitTimeSkipDialogue(EnKakasi* this); void EnKakasi_SetupIdleStanding(EnKakasi* this); -void EnKakasi_8096F88C(GlobalContext* globalCtx, EnKakasi* this); +s32 EnKakasi_ValidatePictograph(PlayState* play, Actor* thisx); -void EnKakasi_TimeSkipDialogue(EnKakasi* this, GlobalContext* globalCtx); -void EnKakasi_IdleStanding(EnKakasi* this, GlobalContext* globalCtx); -void EnKakasi_OcarinaRemark(EnKakasi* this, GlobalContext* globalCtx); -void EnKakasi_TeachingSong(EnKakasi* this, GlobalContext* globalCtx); -void EnKakasi_PostSongLearnTwirl(EnKakasi* this, GlobalContext* globalCtx); -void EnKakasi_PostSongLearnDialogue(EnKakasi* this, GlobalContext* globalCtx); +void EnKakasi_TimeSkipDialogue(EnKakasi* this, PlayState* play); +void EnKakasi_IdleStanding(EnKakasi* this, PlayState* play); +void EnKakasi_OcarinaRemark(EnKakasi* this, PlayState* play); +void EnKakasi_TeachingSong(EnKakasi* this, PlayState* play); +void EnKakasi_PostSongLearnTwirl(EnKakasi* this, PlayState* play); +void EnKakasi_PostSongLearnDialogue(EnKakasi* this, PlayState* play); void EnKakasi_SetupDigAway(EnKakasi* this); -void EnKakasi_DiggingAway(EnKakasi* this, GlobalContext* globalCtx); -void EnKakasi_RisenDialogue(EnKakasi* this, GlobalContext* globalCtx); +void EnKakasi_DiggingAway(EnKakasi* this, PlayState* play); +void EnKakasi_RisenDialogue(EnKakasi* this, PlayState* play); void EnKakasi_SetupIdleUnderground(EnKakasi* this); -void EnKakasi_IdleUnderground(EnKakasi* this, GlobalContext* globalCtx); +void EnKakasi_IdleUnderground(EnKakasi* this, PlayState* play); void EnKakasi_SetupIdleRisen(EnKakasi* this); -void EnKakasi_IdleRisen(EnKakasi* this, GlobalContext* globalCtx); -void EnKakasi_SetupRiseOutOfGround(EnKakasi* this, GlobalContext* globalCtx); -void EnKakasi_RisingOutOfGround(EnKakasi* this, GlobalContext* globalCtx); -void EnKakasi_DancingRemark(EnKakasi* this, GlobalContext* globalCtx); +void EnKakasi_IdleRisen(EnKakasi* this, PlayState* play); +void EnKakasi_SetupRiseOutOfGround(EnKakasi* this, PlayState* play); +void EnKakasi_RisingOutOfGround(EnKakasi* this, PlayState* play); +void EnKakasi_DancingRemark(EnKakasi* this, PlayState* play); void EnKakasi_SetupDanceNightAway(EnKakasi* this); -void EnKakasi_DancingNightAway(EnKakasi* this, GlobalContext* globalCtx); -void EnKakasi_DoNothing(EnKakasi* this, GlobalContext* globalCtx); -void EnKakasi_RegularDialogue(EnKakasi* this, GlobalContext* globalCtx); -void EnKakasi_SetupSongTeach(EnKakasi* this, GlobalContext* globalCtx); +void EnKakasi_DancingNightAway(EnKakasi* this, PlayState* play); +void EnKakasi_DoNothing(EnKakasi* this, PlayState* play); +void EnKakasi_RegularDialogue(EnKakasi* this, PlayState* play); +void EnKakasi_SetupSongTeach(EnKakasi* this, PlayState* play); void EnKakasi_SetupDialogue(EnKakasi* this); @@ -78,7 +79,7 @@ const ActorInit En_Kakasi_InitVars = { (ActorFunc)EnKakasi_Draw, }; -static Vec3f D_80971DCC[] = { +Vec3f D_80971DCC[] = { { 0.0f, 60.0f, 60.0f }, { 40.0f, 40.0f, 50.0f }, { -40.0f, 40.0f, 50.0f }, { 40.0f, 20.0f, 110.0f }, { -40.0f, 20.0f, 110.0f }, { 0.0f, 80.0f, 60.0f }, { 50.0f, 40.0f, -30.0f }, { -50.0f, 40.0f, -30.0f }, { 0.0f, 50.0f, 60.0f }, @@ -121,68 +122,68 @@ typedef enum { /* 0x6 */ ENKAKASI_ANIM_WAVE, // "wave" short sideways shake, stops early, partial? unused? /* 0x7 */ ENKAKASI_ANIM_SLOWROLL, // partial bounch, ends looking left, OFFER anim takes over /* 0x8 */ ENKAKASI_ANIM_IDLE, // slow stretching wiggle, ends in regular position -} EnKakasi_Animations; +} EnKakasiAnimation; -static AnimationHeader* kakasiAnimations[] = { +static AnimationHeader* sAnimations[] = { &object_ka_Anim_007444, &object_ka_Anim_00686C, &object_ka_Anim_0081A4, &object_ka_Anim_007B90, &object_ka_Anim_0071EC, &object_ka_Anim_007444, &object_ka_Anim_00686C, &object_ka_Anim_0081A4, &object_ka_Anim_000214, }; -static u8 sAnimModes[] = { +static u8 sAnimationModes[] = { 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) { +void EnKakasi_Destroy(Actor* thisx, PlayState* play) { EnKakasi* this = THIS; - Collider_DestroyCylinder(globalCtx, &this->collider); + Collider_DestroyCylinder(play, &this->collider); } -void EnKakasi_Init(Actor* thisx, GlobalContext* globalCtx) { +void EnKakasi_Init(Actor* thisx, PlayState* play) { EnKakasi* this = THIS; s32 tempCutscene; s32 i; - Collider_InitAndSetCylinder(globalCtx, &this->collider, &this->actor, &D_80971D80); - SkelAnime_InitFlex(globalCtx, &this->skelanime, &object_ka_Skel_0065B0, &object_ka_Anim_000214, 0, 0, 0); + Collider_InitAndSetCylinder(play, &this->collider, &this->picto.actor, &D_80971D80); + SkelAnime_InitFlex(play, &this->skelanime, &object_ka_Skel_0065B0, &object_ka_Anim_000214, 0, 0, 0); - this->songSummonDist = GET_KAKASI_SUMMON_DISTANCE(this) * 20.0f; + this->songSummonDist = KAKASI_GET_SUMMON_DISTANCE(&this->picto.actor) * 20.0f; if (this->songSummonDist < 40.0f) { this->songSummonDist = 40.0f; } - this->unkHeight = (this->actor.world.rot.z * 20.0f) + 60.0f; - this->actor.world.rot.z = 0; - this->actor.targetMode = 0; - if (this->actor.world.rot.x > 0 && this->actor.world.rot.x < 8) { - this->actor.targetMode = this->actor.world.rot.x - 1; + this->unkHeight = (this->picto.actor.world.rot.z * 20.0f) + 60.0f; + this->picto.actor.world.rot.z = 0; + this->picto.actor.targetMode = 0; + if (this->picto.actor.world.rot.x > 0 && this->picto.actor.world.rot.x < 8) { + this->picto.actor.targetMode = KAKASI_GET_TARGETMODE(thisx); } - this->actor.shape.rot.y = this->actor.world.rot.y; + this->picto.actor.shape.rot.y = this->picto.actor.world.rot.y; - this->aboveGroundStatus = GET_KAKASI_ABOVE_GROUND(this); - this->actor.world.rot.x = 0; - this->actor.flags |= ACTOR_FLAG_400; - this->actor.colChkInfo.mass = MASS_IMMOVABLE; - Actor_SetScale(&this->actor, 0.01f); + this->aboveGroundStatus = KAKASI_GET_ABOVE_GROUND(&this->picto.actor); + this->picto.actor.world.rot.x = 0; + this->picto.actor.flags |= ACTOR_FLAG_400; + this->picto.actor.colChkInfo.mass = MASS_IMMOVABLE; + Actor_SetScale(&this->picto.actor, 0.01f); i = 0; - tempCutscene = this->actor.cutscene; + tempCutscene = this->picto.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 (this->aboveGroundStatus != 0) { 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; + Actor_SetFocus(&this->picto.actor, 60.0f); + this->picto.validationFunc = EnKakasi_ValidatePictograph; if (gSaveContext.save.weekEventReg[83] & 1) { EnKakasi_InitTimeSkipDialogue(this); } else { @@ -194,42 +195,39 @@ void EnKakasi_Init(Actor* thisx, GlobalContext* globalCtx) { } } -void EnKakasi_SetAnimation(EnKakasi* this, s32 index) { - this->animIndex = index; - this->animeFrameCount = Animation_GetLastFrame(&kakasiAnimations[this->animIndex]->common); +void EnKakasi_ChangeAnim(EnKakasi* this, s32 animIndex) { + this->animIndex = animIndex; + this->animeFrameCount = Animation_GetLastFrame(&sAnimations[this->animIndex]->common); // 1: regular playback speed, 0: starting frame - Animation_Change(&this->skelanime, kakasiAnimations[this->animIndex], 1.0f, 0.0f, this->animeFrameCount, - sAnimModes[this->animIndex], -4.0f); + Animation_Change(&this->skelanime, sAnimations[this->animIndex], 1.0f, 0.0f, this->animeFrameCount, + sAnimationModes[this->animIndex], -4.0f); } -/* - * set by init, called... nowhere? left over from OOT? - */ -void EnKakasi_8096F88C(GlobalContext* globalCtx, EnKakasi* this) { - func_8013A530(globalCtx, &this->actor, 0x7, &this->actor.focus.pos, &this->actor.shape.rot, 280.0f, 1800.0f, -1); +s32 EnKakasi_ValidatePictograph(PlayState* play, Actor* thisx) { + return Snap_ValidatePictograph(play, thisx, 0x7, &thisx->focus.pos, &thisx->shape.rot, 280.0f, 1800.0f, -1); } void EnKakasi_CheckAnimationSfx(EnKakasi* this) { if (this->animIndex == ENKAKASI_ANIM_SIDEWAYS_SHAKING || this->animIndex == ENKAKASI_ANIM_ARMS_CROSSED_STILL) { if (Animation_OnFrame(&this->skelanime, 1.0f) || Animation_OnFrame(&this->skelanime, 8.0f)) { - Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_KAKASHI_SWING); + Actor_PlaySfxAtPos(&this->picto.actor, NA_SE_EV_KAKASHI_SWING); } } if (this->animIndex == ENKAKASI_ANIM_HOPPING_REGULAR || this->animIndex == ENKAKASI_ANIM_SLOWROLL) { if (Animation_OnFrame(&this->skelanime, 4.0f) || Animation_OnFrame(&this->skelanime, 8.0f)) { - Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_KAKASHI_SWING); + Actor_PlaySfxAtPos(&this->picto.actor, NA_SE_EV_KAKASHI_SWING); } if (Animation_OnFrame(&this->skelanime, 1.0f) || Animation_OnFrame(&this->skelanime, 9.0f) || Animation_OnFrame(&this->skelanime, 16.0f)) { - Actor_PlaySfxAtPos(&this->actor, NA_SE_IT_KAKASHI_JUMP); + Actor_PlaySfxAtPos(&this->picto.actor, NA_SE_IT_KAKASHI_JUMP); } if (Animation_OnFrame(&this->skelanime, 18.0f)) { - Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_KAKASHI_ROLL); + Actor_PlaySfxAtPos(&this->picto.actor, NA_SE_EV_KAKASHI_ROLL); } } if (this->animIndex == ENKAKASI_ANIM_SPIN_REACH_OFFER || this->animIndex == ENKAKASI_ANIM_TWIRL) { if (Animation_OnFrame(&this->skelanime, 1.0f)) { - Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_KAKASH_LONGI_ROLL); + Actor_PlaySfxAtPos(&this->picto.actor, NA_SE_EV_KAKASH_LONGI_ROLL); } } } @@ -237,90 +235,90 @@ void EnKakasi_CheckAnimationSfx(EnKakasi* this) { /* * moves the player's position relative to scarecrow during song teach, also each frame of dance the night away */ -void EnKakasi_CheckPlayerPosition(EnKakasi* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); +void EnKakasi_CheckPlayerPosition(EnKakasi* this, PlayState* play) { + Player* player = GET_PLAYER(play); - if (globalCtx->sceneNum == SCENE_8ITEMSHOP) { + if (play->sceneNum == SCENE_8ITEMSHOP) { player->actor.world.pos.x = -50.0f; player->actor.world.pos.z = 155.0f; - } else if (globalCtx->sceneNum == SCENE_TENMON_DAI) { + } else if (play->sceneNum == SCENE_TENMON_DAI) { player->actor.world.pos.x = 60.0f; player->actor.world.pos.z = -190.0f; } - Math_SmoothStepToS(&player->actor.shape.rot.y, (this->actor.yawTowardsPlayer + 0x8000), 5, 1000, 0); + Math_SmoothStepToS(&player->actor.shape.rot.y, (this->picto.actor.yawTowardsPlayer + 0x8000), 5, 1000, 0); } /* * this goes off every frame of dancing the night away, and song teaching * something to do with cutscene camera? */ -void func_8096FAAC(EnKakasi* this, GlobalContext* globalCtx) { - 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); +void func_8096FAAC(EnKakasi* this, PlayState* play) { + if (this->subCamId != SUB_CAM_ID_DONE) { + Math_ApproachF(&this->subCamEye.x, this->subCamEyeNext.x, 0.4f, 4.0f); + Math_ApproachF(&this->subCamEye.y, this->subCamEyeNext.y, 0.4f, 4.0f); + Math_ApproachF(&this->subCamEye.z, this->subCamEyeNext.z, 0.4f, 4.0f); - Math_ApproachF(&this->unk220.x, this->unk244.x, 0.4f, 4.0f); - Math_ApproachF(&this->unk220.y, this->unk244.y, 0.4f, 4.0f); - Math_ApproachF(&this->unk220.z, this->unk244.z, 0.4f, 4.0f); + Math_ApproachF(&this->subCamAt.x, this->subCamAtNext.x, 0.4f, 4.0f); + Math_ApproachF(&this->subCamAt.y, this->subCamAtNext.y, 0.4f, 4.0f); + Math_ApproachF(&this->subCamAt.z, this->subCamAtNext.z, 0.4f, 4.0f); - Math_ApproachF(&this->unk20C, this->unk210, 0.3f, 10.0f); + Math_ApproachF(&this->subCamFov, this->subCamFovNext, 0.3f, 10.0f); - Play_CameraSetAtEye(globalCtx, this->cutsceneCamId, &this->unk220, &this->unk214); - Play_CameraSetFov(globalCtx, this->cutsceneCamId, this->unk20C); + Play_SetCameraAtEye(play, this->subCamId, &this->subCamAt, &this->subCamEye); + Play_SetCameraFov(play, this->subCamId, this->subCamFov); } } /* * goes off every frame of song teach, but... doing what? */ -void func_8096FBB8(EnKakasi* this, GlobalContext* globalCtx) { - if (globalCtx->msgCtx.unk12048 == 0 || globalCtx->msgCtx.unk12048 == 1 || globalCtx->msgCtx.unk12048 == 2 || - globalCtx->msgCtx.unk12048 == 3 || globalCtx->msgCtx.unk12048 == 4) { +void func_8096FBB8(EnKakasi* this, PlayState* play) { + if (play->msgCtx.unk12048 == 0 || play->msgCtx.unk12048 == 1 || play->msgCtx.unk12048 == 2 || + play->msgCtx.unk12048 == 3 || play->msgCtx.unk12048 == 4) { // why not 0 < x < 4? fewer branches this->unk190++; } if (this->unk190 != 0 && this->animIndex != ENKAKASI_ANIM_SIDEWAYS_SHAKING) { - EnKakasi_SetAnimation(this, ENKAKASI_ANIM_SIDEWAYS_SHAKING); + EnKakasi_ChangeAnim(this, ENKAKASI_ANIM_SIDEWAYS_SHAKING); } if (this->unk190 > 8) { this->unk190 = 8; } if (this->unk190 != 0) { Math_ApproachF(&this->skelanime.playSpeed, 1.0f, 0.1f, 0.2f); - this->actor.shape.rot.y += 0x800; + this->picto.actor.shape.rot.y += 0x800; } } void EnKakasi_InitTimeSkipDialogue(EnKakasi* this) { - EnKakasi_SetAnimation(this, ENKAKASI_ANIM_SLOWROLL); + EnKakasi_ChangeAnim(this, ENKAKASI_ANIM_SLOWROLL); this->actionFunc = EnKakasi_TimeSkipDialogue; } -void EnKakasi_TimeSkipDialogue(EnKakasi* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); +void EnKakasi_TimeSkipDialogue(EnKakasi* this, PlayState* play) { + Player* player = GET_PLAYER(play); if (gSaveContext.respawnFlag != -4 && gSaveContext.respawnFlag != -8) { if (gSaveContext.save.time != CLOCK_TIME(6, 0) && gSaveContext.save.time != CLOCK_TIME(18, 0) && !(gSaveContext.eventInf[1] & 0x80)) { - if (this->actor.textId == 0) { + if (this->picto.actor.textId == 0) { // dialogue after skipped time 'did you feel that? went by in an instant' - this->actor.textId = 0x1653; + this->picto.actor.textId = 0x1653; gSaveContext.save.weekEventReg[83] &= (u8)~1; - this->unkMsgState1AC = 5; + this->talkState = TEXT_STATE_5; player->stateFlags1 |= 0x20; - this->actor.flags |= ACTOR_FLAG_10000; + this->picto.actor.flags |= ACTOR_FLAG_10000; } - if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { + if (Actor_ProcessTalkRequest(&this->picto.actor, &play->state)) { player->stateFlags1 &= ~0x20; this->unkState196 = 2; - this->actor.flags &= ~ACTOR_FLAG_10000; + this->picto.actor.flags &= ~ACTOR_FLAG_10000; this->actionFunc = EnKakasi_RegularDialogue; } else { - func_800B8500(&this->actor, globalCtx, 9999.9f, 9999.9f, -1); + func_800B8500(&this->picto.actor, play, 9999.9f, 9999.9f, PLAYER_AP_MINUS1); } } } @@ -331,123 +329,123 @@ void EnKakasi_SetupIdleStanding(EnKakasi* this) { this->actionFunc = EnKakasi_IdleStanding; } -void EnKakasi_IdleStanding(EnKakasi* this, GlobalContext* globalCtx) { +void EnKakasi_IdleStanding(EnKakasi* this, PlayState* play) { u32 saveContextDay = gSaveContext.save.day; s16 x; s16 y; // first talk to scarecrow dialogue - this->actor.textId = 0x1644; - if (func_800B8718(&this->actor, &globalCtx->state)) { + this->picto.actor.textId = 0x1644; + if (func_800B8718(&this->picto.actor, &play->state)) { this->skelanime.playSpeed = 1.0f; - EnKakasi_SetupSongTeach(this, globalCtx); + EnKakasi_SetupSongTeach(this, play); return; } - if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { + if (Actor_ProcessTalkRequest(&this->picto.actor, &play->state)) { this->skelanime.playSpeed = 1.0f; EnKakasi_SetupDialogue(this); return; } - if (globalCtx->actorCtx.unk5 & 0x4) { - Actor_GetScreenPos(globalCtx, &this->actor, &x, &y); - if (this->actor.projectedPos.z > -20.0f && x > 0 && x < SCREEN_WIDTH && y > 0 && y < SCREEN_HEIGHT && + if (play->actorCtx.unk5 & 0x4) { + Actor_GetScreenPos(play, &this->picto.actor, &x, &y); + if (this->picto.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); + EnKakasi_ChangeAnim(this, ENKAKASI_ANIM_SIDEWAYS_SHAKING); this->skelanime.playSpeed = 2.0f; } - } else if (Player_GetMask(globalCtx) == PLAYER_MASK_KAMARO) { + } else if (Player_GetMask(play) == PLAYER_MASK_KAMARO) { if (this->animIndex != ENKAKASI_ANIM_SIDEWAYS_SHAKING) { - EnKakasi_SetAnimation(this, ENKAKASI_ANIM_SIDEWAYS_SHAKING); + EnKakasi_ChangeAnim(this, ENKAKASI_ANIM_SIDEWAYS_SHAKING); this->skelanime.playSpeed = 2.0f; } } else if (saveContextDay == 3 && gSaveContext.save.isNight) { this->skelanime.playSpeed = 1.0f; if (this->animIndex != ENKAKASI_ANIM_SIDEWAYS_SHAKING) { - EnKakasi_SetAnimation(this, 1); + EnKakasi_ChangeAnim(this, 1); } } else if (this->animIndex != ENKAKASI_ANIM_IDLE) { - EnKakasi_SetAnimation(this, ENKAKASI_ANIM_IDLE); + EnKakasi_ChangeAnim(this, ENKAKASI_ANIM_IDLE); } - if (this->actor.xzDistToPlayer < 120.0f) { - func_800B8614(&this->actor, globalCtx, 100.0f); - func_800B874C(&this->actor, globalCtx, 100.0f, 80.0f); + if (this->picto.actor.xzDistToPlayer < 120.0f) { + func_800B8614(&this->picto.actor, play, 100.0f); + func_800B874C(&this->picto.actor, play, 100.0f, 80.0f); } } void EnKakasi_SetupDialogue(EnKakasi* this) { // bug? starts one animation then changes it a few lines down? if (this->animIndex != ENKAKASI_ANIM_SIDEWAYS_SHAKING) { - EnKakasi_SetAnimation(this, ENKAKASI_ANIM_SIDEWAYS_SHAKING); + EnKakasi_ChangeAnim(this, ENKAKASI_ANIM_SIDEWAYS_SHAKING); } - this->unkMsgState1AC = 5; + this->talkState = TEXT_STATE_5; this->unkState196 = 1; - EnKakasi_SetAnimation(this, ENKAKASI_ANIM_SPIN_REACH_OFFER); + EnKakasi_ChangeAnim(this, ENKAKASI_ANIM_SPIN_REACH_OFFER); this->actionFunc = EnKakasi_RegularDialogue; } -void EnKakasi_RegularDialogue(EnKakasi* this, GlobalContext* globalCtx) { +void EnKakasi_RegularDialogue(EnKakasi* this, PlayState* play) { u32 saveContextDay = gSaveContext.save.day; f32 currentAnimeFrame = this->skelanime.curFrame; - Math_SmoothStepToS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer, 5, 2000, 0); + Math_SmoothStepToS(&this->picto.actor.shape.rot.y, this->picto.actor.yawTowardsPlayer, 5, 2000, 0); // if first dialogue - if (this->actor.textId != 0x1644 && this->animeFrameCount <= currentAnimeFrame && + if (this->picto.actor.textId != 0x1644 && this->animeFrameCount <= currentAnimeFrame && this->animIndex == ENKAKASI_ANIM_SLOWROLL) { - EnKakasi_SetAnimation(this, ENKAKASI_ANIM_SPIN_REACH_OFFER); + EnKakasi_ChangeAnim(this, ENKAKASI_ANIM_SPIN_REACH_OFFER); this->unkCounter1A4 = 0; } // if dialogue: oh sorry come back again - if (this->actor.textId == 0x1651 || this->actor.textId == 0x1659) { + if (this->picto.actor.textId == 0x1651 || this->picto.actor.textId == 0x1659) { if (this->animeFrameCount <= currentAnimeFrame && this->animIndex != ENKAKASI_ANIM_SPIN_REACH_OFFER) { if (++this->unkCounter1A4 >= 2) { this->unkCounter1A4 = 0; - EnKakasi_SetAnimation(this, ENKAKASI_ANIM_SPIN_REACH_OFFER); + EnKakasi_ChangeAnim(this, ENKAKASI_ANIM_SPIN_REACH_OFFER); } } } if (this->unkState1A8 == 2 && this->unkState196 == 2) { - func_800B7298(globalCtx, &this->actor, 0x49); + func_800B7298(play, &this->picto.actor, 0x49); this->unkState1A8 = 0; } - if (this->unkMsgState1AC == Message_GetState(&globalCtx->msgCtx) && Message_ShouldAdvance(globalCtx) != 0) { - func_801477B4(globalCtx); - if (this->unkMsgState1AC == 5) { + if ((this->talkState == Message_GetState(&play->msgCtx)) && Message_ShouldAdvance(play)) { + func_801477B4(play); + if (this->talkState == TEXT_STATE_5) { // bad song input - if (this->unkState196 == 2 && this->actor.textId == 0x1647) { - func_800B7298(globalCtx, &this->actor, 6); + if (this->unkState196 == 2 && this->picto.actor.textId == 0x1647) { + func_800B7298(play, &this->picto.actor, 6); } // after timeskip - if (this->actor.textId == 0x1653) { + if (this->picto.actor.textId == 0x1653) { u32 saveContextDay2 = gSaveContext.save.day; if (this->animIndex != ENKAKASI_ANIM_SIDEWAYS_SHAKING) { - EnKakasi_SetAnimation(this, ENKAKASI_ANIM_SIDEWAYS_SHAKING); + EnKakasi_ChangeAnim(this, ENKAKASI_ANIM_SIDEWAYS_SHAKING); } if (saveContextDay2 == 3 && gSaveContext.save.isNight) { // text: dangerous outside - this->actor.textId = 0x164F; + this->picto.actor.textId = 0x164F; } else if (gSaveContext.save.isNight) { // text: would you like to skip time? - this->actor.textId = 0x164E; + this->picto.actor.textId = 0x164E; } else { // text: would you like to skip time? 2 - this->actor.textId = 0x1645; + this->picto.actor.textId = 0x1645; } - func_80151938(globalCtx, this->actor.textId); + func_80151938(play, this->picto.actor.textId); return; - } else if (this->actor.textId == 0x165D || this->actor.textId == 0x165F || this->actor.textId == 0x1660 || - this->actor.textId == 0x1652) { - func_800B7298(globalCtx, &this->actor, 4); + } else if (this->picto.actor.textId == 0x165D || this->picto.actor.textId == 0x165F || + this->picto.actor.textId == 0x1660 || this->picto.actor.textId == 0x1652) { + func_800B7298(play, &this->picto.actor, 4); if (ActorCutscene_GetCurrentIndex() == 0x7C) { ActorCutscene_Stop(0x7C); ActorCutscene_SetIntentToPlay(this->actorCutscenes[0]); @@ -457,100 +455,100 @@ void EnKakasi_RegularDialogue(EnKakasi* this, GlobalContext* globalCtx) { ActorCutscene_SetIntentToPlay(this->actorCutscenes[0]); this->actionFunc = EnKakasi_DancingRemark; } else { - ActorCutscene_StartAndSetUnkLinkFields(this->actorCutscenes[0], &this->actor); - this->cutsceneCamId = ActorCutscene_GetCurrentCamera(this->actor.cutscene); + ActorCutscene_StartAndSetUnkLinkFields(this->actorCutscenes[0], &this->picto.actor); + this->subCamId = ActorCutscene_GetCurrentSubCamId(this->picto.actor.cutscene); this->actionFunc = EnKakasi_DancingRemark; } } return; - } else if (this->actor.textId == 0x1645 || this->actor.textId == 0x164E) { - this->actor.textId = 0x1650; // "Shall we dance? No Yes" + } else if (this->picto.actor.textId == 0x1645 || this->picto.actor.textId == 0x164E) { + this->picto.actor.textId = 0x1650; // "Shall we dance? No Yes" if (this->animIndex != ENKAKASI_ANIM_SIDEWAYS_SHAKING) { - EnKakasi_SetAnimation(this, ENKAKASI_ANIM_SIDEWAYS_SHAKING); + EnKakasi_ChangeAnim(this, ENKAKASI_ANIM_SIDEWAYS_SHAKING); } - this->unkMsgState1AC = 4; + this->talkState = TEXT_STATE_CHOICE; - } else if (this->actor.textId == 0x1644) { + } else if (this->picto.actor.textId == 0x1644) { if (this->animIndex != ENKAKASI_ANIM_SIDEWAYS_SHAKING) { - EnKakasi_SetAnimation(this, ENKAKASI_ANIM_SIDEWAYS_SHAKING); + EnKakasi_ChangeAnim(this, ENKAKASI_ANIM_SIDEWAYS_SHAKING); } if (gSaveContext.save.isNight) { - this->actor.textId = 0x164E; + this->picto.actor.textId = 0x164E; } else { - this->actor.textId = 0x1645; + this->picto.actor.textId = 0x1645; } - } else if (this->actor.textId == 0x164F) { + } else if (this->picto.actor.textId == 0x164F) { if (this->animIndex != ENKAKASI_ANIM_SIDEWAYS_SHAKING) { - EnKakasi_SetAnimation(this, ENKAKASI_ANIM_SIDEWAYS_SHAKING); + EnKakasi_ChangeAnim(this, ENKAKASI_ANIM_SIDEWAYS_SHAKING); } - this->actor.textId = 0x165A; - } else if (this->actor.textId == 0x1651) { + this->picto.actor.textId = 0x165A; + } else if (this->picto.actor.textId == 0x1651) { if (this->animIndex != ENKAKASI_ANIM_SIDEWAYS_SHAKING) { - EnKakasi_SetAnimation(this, ENKAKASI_ANIM_SIDEWAYS_SHAKING); + EnKakasi_ChangeAnim(this, ENKAKASI_ANIM_SIDEWAYS_SHAKING); } - this->actor.textId = 0x1654; - } else if (this->actor.textId == 0x1654) { - this->actor.textId = 0x1655; - } else if (this->actor.textId == 0x1655) { - this->actor.textId = 0x1656; - this->unkMsgState1AC = 4; - } else if (this->actor.textId == 0x1658) { - this->actor.textId = 0x1659; - } else if (this->actor.textId == 0x165A) { - this->actor.textId = 0x165B; - } else if (this->actor.textId == 0x165B) { - this->actor.textId = 0x165C; - this->unkMsgState1AC = 4; + this->picto.actor.textId = 0x1654; + } else if (this->picto.actor.textId == 0x1654) { + this->picto.actor.textId = 0x1655; + } else if (this->picto.actor.textId == 0x1655) { + this->picto.actor.textId = 0x1656; + this->talkState = TEXT_STATE_CHOICE; + } else if (this->picto.actor.textId == 0x1658) { + this->picto.actor.textId = 0x1659; + } else if (this->picto.actor.textId == 0x165A) { + this->picto.actor.textId = 0x165B; + } else if (this->picto.actor.textId == 0x165B) { + this->picto.actor.textId = 0x165C; + this->talkState = TEXT_STATE_CHOICE; - } else if (this->actor.textId == 0x165E) { - this->actor.textId = 0x165F; + } else if (this->picto.actor.textId == 0x165E) { + this->picto.actor.textId = 0x165F; } else { EnKakasi_SetupIdleStanding(this); return; } } else { - this->unkMsgState1AC = 5; + this->talkState = TEXT_STATE_5; - if (globalCtx->msgCtx.choiceIndex == 1) { + if (play->msgCtx.choiceIndex == 1) { func_8019F208(); - if (this->actor.textId == 0x1656) { - this->actor.textId = 0x1658; - } else if (this->actor.textId == 0x165C) { - this->actor.textId = 0x165E; + if (this->picto.actor.textId == 0x1656) { + this->picto.actor.textId = 0x1658; + } else if (this->picto.actor.textId == 0x165C) { + this->picto.actor.textId = 0x165E; } else if (saveContextDay == 3 && gSaveContext.save.isNight) { - this->actor.textId = 0x164F; + this->picto.actor.textId = 0x164F; } else { - this->actor.textId = 0x1652; + this->picto.actor.textId = 0x1652; } - EnKakasi_SetAnimation(this, ENKAKASI_ANIM_HOPPING_REGULAR); + EnKakasi_ChangeAnim(this, ENKAKASI_ANIM_HOPPING_REGULAR); } else { func_8019F230(); - if (this->actor.textId == 0x1656) { // would you like to learn a song? yes/no - this->actor.textId = 0x1657; - } else if (this->actor.textId == 0x165C) { // would you like to learn a song? yes/no - this->actor.textId = 0x165D; + if (this->picto.actor.textId == 0x1656) { // would you like to learn a song? yes/no + this->picto.actor.textId = 0x1657; + } else if (this->picto.actor.textId == 0x165C) { // would you like to learn a song? yes/no + this->picto.actor.textId = 0x165D; } else { - this->actor.textId = 0x1651; + this->picto.actor.textId = 0x1651; } this->unkCounter1A4 = 0; if (this->animIndex != ENKAKASI_ANIM_ARMS_CROSSED_ROCKING) { - EnKakasi_SetAnimation(this, ENKAKASI_ANIM_ARMS_CROSSED_ROCKING); + EnKakasi_ChangeAnim(this, ENKAKASI_ANIM_ARMS_CROSSED_ROCKING); } } } - func_80151938(globalCtx, this->actor.textId); + func_80151938(play, this->picto.actor.textId); } } -void EnKakasi_SetupSongTeach(EnKakasi* this, GlobalContext* globalCtx) { - this->actor.textId = 0x1646; - 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); +void EnKakasi_SetupSongTeach(EnKakasi* this, PlayState* play) { + this->picto.actor.textId = 0x1646; + Message_StartTextbox(play, this->picto.actor.textId, &this->picto.actor); + this->subCamId = SUB_CAM_ID_DONE; + this->subCamFov = 0.0f; + this->subCamFovNext = 60.0f; + EnKakasi_ChangeAnim(this, ENKAKASI_ANIM_TWIRL); this->unkState196 = 2; this->actionFunc = EnKakasi_OcarinaRemark; } @@ -559,9 +557,9 @@ void EnKakasi_SetupSongTeach(EnKakasi* this, GlobalContext* globalCtx) { * you took out ocarina hes talking about how he wants to hear you play him a song * before actually teaching */ -void EnKakasi_OcarinaRemark(EnKakasi* this, GlobalContext* globalCtx) { - if (Message_GetState(&globalCtx->msgCtx) == 5 && Message_ShouldAdvance(globalCtx) != 0) { - func_80152434(globalCtx, 0x35); +void EnKakasi_OcarinaRemark(EnKakasi* this, PlayState* play) { + if ((Message_GetState(&play->msgCtx) == TEXT_STATE_5) && Message_ShouldAdvance(play)) { + func_80152434(play, 0x35); this->unkState1A8 = 0; if (ActorCutscene_GetCurrentIndex() == 0x7C) { ActorCutscene_Stop(0x7C); @@ -574,19 +572,19 @@ void EnKakasi_OcarinaRemark(EnKakasi* this, GlobalContext* globalCtx) { } else { this->unkState1A8 = 1; - ActorCutscene_StartAndSetUnkLinkFields(this->actorCutscenes[0], &this->actor); - this->cutsceneCamId = ActorCutscene_GetCurrentCamera(this->actor.cutscene); - Math_Vec3f_Copy(&this->unk22C, &this->actor.home.pos); + ActorCutscene_StartAndSetUnkLinkFields(this->actorCutscenes[0], &this->picto.actor); + this->subCamId = ActorCutscene_GetCurrentSubCamId(this->picto.actor.cutscene); + Math_Vec3f_Copy(&this->unk22C, &this->picto.actor.home.pos); this->actionFunc = EnKakasi_TeachingSong; } } } -void EnKakasi_TeachingSong(EnKakasi* this, GlobalContext* globalCtx) { +void EnKakasi_TeachingSong(EnKakasi* this, PlayState* play) { Vec3f tempVec; - EnKakasi_CheckPlayerPosition(this, globalCtx); - Math_SmoothStepToS(&this->actor.shape.rot.y, this->actor.home.rot.y, 1, 3000, 0); + EnKakasi_CheckPlayerPosition(this, play); + Math_SmoothStepToS(&this->picto.actor.shape.rot.y, this->picto.actor.home.rot.y, 1, 3000, 0); if (this->unkState1A8 == 0) { if (ActorCutscene_GetCurrentIndex() == 0x7C) { ActorCutscene_Stop(0x7C); @@ -597,106 +595,106 @@ void EnKakasi_TeachingSong(EnKakasi* this, GlobalContext* globalCtx) { ActorCutscene_SetIntentToPlay(this->actorCutscenes[0]); return; } - ActorCutscene_StartAndSetUnkLinkFields(this->actorCutscenes[0], &this->actor); - this->cutsceneCamId = ActorCutscene_GetCurrentCamera(this->actor.cutscene); - Math_Vec3f_Copy(&this->unk22C, &this->actor.home.pos); + ActorCutscene_StartAndSetUnkLinkFields(this->actorCutscenes[0], &this->picto.actor); + this->subCamId = ActorCutscene_GetCurrentSubCamId(this->picto.actor.cutscene); + Math_Vec3f_Copy(&this->unk22C, &this->picto.actor.home.pos); this->unkState1A8 = 1; this->unkState1A8 = 1; } if (this->unkState1A8 == 1) { - this->unk22C.y = this->actor.home.pos.y + 50.0f; - this->unk238.x = D_80971DCC[this->unk190].x; - this->unk238.y = D_80971DCC[this->unk190].y; - this->unk238.z = D_80971DCC[this->unk190].z; + this->unk22C.y = this->picto.actor.home.pos.y + 50.0f; + this->subCamEyeNext.x = D_80971DCC[this->unk190].x; + this->subCamEyeNext.y = D_80971DCC[this->unk190].y; + this->subCamEyeNext.z = D_80971DCC[this->unk190].z; - Math_Vec3f_Copy(&tempVec, &this->unk238); - OLib_DbCameraVec3fSum(&this->actor.home, &tempVec, &this->unk238, 1); - Math_Vec3f_Copy(&this->unk244, &this->unk22C); - Math_Vec3f_Copy(&this->unk214, &this->unk238); - Math_Vec3f_Copy(&this->unk220, &this->unk244); - func_8096FAAC(this, globalCtx); - func_8096FBB8(this, globalCtx); + Math_Vec3f_Copy(&tempVec, &this->subCamEyeNext); + OLib_DbCameraVec3fSum(&this->picto.actor.home, &tempVec, &this->subCamEyeNext, 1); + Math_Vec3f_Copy(&this->subCamAtNext, &this->unk22C); + Math_Vec3f_Copy(&this->subCamEye, &this->subCamEyeNext); + Math_Vec3f_Copy(&this->subCamAt, &this->subCamAtNext); + func_8096FAAC(this, play); + func_8096FBB8(this, play); - if (globalCtx->msgCtx.ocarinaMode == 4) { // song failed + if (play->msgCtx.ocarinaMode == 4) { // song failed this->unk190 = 0; this->unkCounter1A4 = 0; ActorCutscene_Stop(this->actorCutscenes[0]); - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_YASE_DEAD); + Actor_PlaySfxAtPos(&this->picto.actor, NA_SE_EN_YASE_DEAD); if (this) {} this->unkState196 = 2; - this->cutsceneCamId = CAM_ID_MAIN; - this->actor.textId = 0x1647; + this->subCamId = SUB_CAM_ID_DONE; + this->picto.actor.textId = 0x1647; this->unkState1A8 = 2; - this->unkMsgState1AC = 5; - EnKakasi_SetAnimation(this, ENKAKASI_ANIM_ARMS_CROSSED_ROCKING); + this->talkState = TEXT_STATE_5; + EnKakasi_ChangeAnim(this, ENKAKASI_ANIM_ARMS_CROSSED_ROCKING); this->actionFunc = EnKakasi_RegularDialogue; - } else if (globalCtx->msgCtx.ocarinaMode == 3) { // song success + } else if (play->msgCtx.ocarinaMode == 3) { // song success this->postTeachTimer = 30; this->skelanime.playSpeed = 2.0f; - EnKakasi_SetAnimation(this, ENKAKASI_ANIM_HOPPING_REGULAR); + EnKakasi_ChangeAnim(this, ENKAKASI_ANIM_HOPPING_REGULAR); this->actionFunc = EnKakasi_PostSongLearnTwirl; } } } -void EnKakasi_PostSongLearnTwirl(EnKakasi* this, GlobalContext* globalCtx) { +void EnKakasi_PostSongLearnTwirl(EnKakasi* this, PlayState* play) { f32 animeFrame = this->skelanime.curFrame; if (this->postTeachTimer == 0 && this->animIndex != ENKAKASI_ANIM_TWIRL) { - EnKakasi_SetAnimation(this, ENKAKASI_ANIM_TWIRL); + EnKakasi_ChangeAnim(this, ENKAKASI_ANIM_TWIRL); this->skelanime.playSpeed = 2.0f; } if (this->postTeachTimer == 0 && this->animIndex == ENKAKASI_ANIM_TWIRL && this->animeFrameCount <= animeFrame) { - EnKakasi_SetupPostSongLearnDialogue(this, globalCtx); + EnKakasi_SetupPostSongLearnDialogue(this, play); } } -void EnKakasi_SetupPostSongLearnDialogue(EnKakasi* this, GlobalContext* globalCtx) { +void EnKakasi_SetupPostSongLearnDialogue(EnKakasi* this, PlayState* play) { ActorCutscene_Stop(this->actorCutscenes[0]); - globalCtx->msgCtx.ocarinaMode = 4; + play->msgCtx.ocarinaMode = 4; this->unk190 = 0; this->unkCounter1A4 = 0; - EnKakasi_SetAnimation(this, ENKAKASI_ANIM_HOPPING_REGULAR); - this->cutsceneCamId = CAM_ID_MAIN; - this->unkMsgState1AC = 5; + EnKakasi_ChangeAnim(this, ENKAKASI_ANIM_HOPPING_REGULAR); + this->subCamId = SUB_CAM_ID_DONE; + this->talkState = TEXT_STATE_5; this->unkState1A8 = 1; this->actionFunc = EnKakasi_PostSongLearnDialogue; - this->unk20C = 0.0f; - this->unk210 = 60.0f; + this->subCamFov = 0.0f; + this->subCamFovNext = 60.0f; } -void EnKakasi_PostSongLearnDialogue(EnKakasi* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); +void EnKakasi_PostSongLearnDialogue(EnKakasi* this, PlayState* play) { + Player* player = GET_PLAYER(play); f32 tempAnimFrame = this->skelanime.curFrame; Vec3f vec3fCopy; - Math_SmoothStepToS(&this->actor.shape.rot.y, this->actor.home.rot.y, 1, 3000, 0); - Math_SmoothStepToS(&player->actor.shape.rot.y, this->actor.yawTowardsPlayer + 0x8000, 5, 1000, 0); + Math_SmoothStepToS(&this->picto.actor.shape.rot.y, this->picto.actor.home.rot.y, 1, 3000, 0); + Math_SmoothStepToS(&player->actor.shape.rot.y, this->picto.actor.yawTowardsPlayer + 0x8000, 5, 1000, 0); if (this->unk190 == 0) { - func_801477B4(globalCtx); - func_800B7298(globalCtx, &this->actor, 0x56); - this->actor.textId = 0x1648; - Message_StartTextbox(globalCtx, (this->actor.textId), &this->actor); + func_801477B4(play); + func_800B7298(play, &this->picto.actor, 0x56); + this->picto.actor.textId = 0x1648; + Message_StartTextbox(play, (this->picto.actor.textId), &this->picto.actor); this->unkState1A8 = 0; this->unk190 = 1; } - if (this->actor.textId == 0x1648 && this->animIndex == ENKAKASI_ANIM_HOPPING_REGULAR && + if (this->picto.actor.textId == 0x1648 && this->animIndex == ENKAKASI_ANIM_HOPPING_REGULAR && this->animeFrameCount <= tempAnimFrame) { this->unkCounter1A4++; if (this->unkCounter1A4 >= 2) { - EnKakasi_SetAnimation(this, ENKAKASI_ANIM_ARMS_CROSSED_ROCKING); + EnKakasi_ChangeAnim(this, ENKAKASI_ANIM_ARMS_CROSSED_ROCKING); } } - if (this->actor.textId == 0x164B && this->animIndex == ENKAKASI_ANIM_ARMS_CROSSED_ROCKING && + if (this->picto.actor.textId == 0x164B && this->animIndex == ENKAKASI_ANIM_ARMS_CROSSED_ROCKING && this->animeFrameCount <= tempAnimFrame) { this->unkCounter1A4++; if (this->unkCounter1A4 >= 2) { - EnKakasi_SetAnimation(this, ENKAKASI_ANIM_SPIN_REACH_OFFER); + EnKakasi_ChangeAnim(this, ENKAKASI_ANIM_SPIN_REACH_OFFER); } } @@ -710,84 +708,84 @@ void EnKakasi_PostSongLearnDialogue(EnKakasi* this, GlobalContext* globalCtx) { ActorCutscene_SetIntentToPlay(this->actorCutscenes[0]); return; } - Math_Vec3f_Copy(&this->unk22C, &this->actor.home.pos); - ActorCutscene_StartAndSetUnkLinkFields(this->actorCutscenes[0], &this->actor); - this->cutsceneCamId = ActorCutscene_GetCurrentCamera(this->actor.cutscene); - func_800B7298(globalCtx, &this->actor, 0x56); + Math_Vec3f_Copy(&this->unk22C, &this->picto.actor.home.pos); + ActorCutscene_StartAndSetUnkLinkFields(this->actorCutscenes[0], &this->picto.actor); + this->subCamId = ActorCutscene_GetCurrentSubCamId(this->picto.actor.cutscene); + func_800B7298(play, &this->picto.actor, 0x56); this->unkState1A8 = 1; } - 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; - this->unk238.y = D_80971FA0[this->unk190].y; - this->unk238.z = D_80971FA0[this->unk190].z; - Math_Vec3f_Copy(&vec3fCopy, &this->unk238); - OLib_DbCameraVec3fSum(&this->actor.home, &vec3fCopy, &this->unk238, 1); - this->unk244.x = D_80971FE8[this->unk190].x + this->unk22C.x; - this->unk244.y = D_80971FE8[this->unk190].y + this->unk22C.y; - this->unk244.z = D_80971FE8[this->unk190].z + this->unk22C.z; - Math_Vec3f_Copy(&this->unk214, &this->unk238); - Math_Vec3f_Copy(&this->unk220, &this->unk244); + if (this->subCamId != SUB_CAM_ID_DONE) { + this->unk22C.y = this->picto.actor.home.pos.y + 50.0f; + EnKakasi_CheckPlayerPosition(this, play); + this->subCamEyeNext.x = D_80971FA0[this->unk190].x; + this->subCamEyeNext.y = D_80971FA0[this->unk190].y; + this->subCamEyeNext.z = D_80971FA0[this->unk190].z; + Math_Vec3f_Copy(&vec3fCopy, &this->subCamEyeNext); + OLib_DbCameraVec3fSum(&this->picto.actor.home, &vec3fCopy, &this->subCamEyeNext, 1); + this->subCamAtNext.x = D_80971FE8[this->unk190].x + this->unk22C.x; + this->subCamAtNext.y = D_80971FE8[this->unk190].y + this->unk22C.y; + this->subCamAtNext.z = D_80971FE8[this->unk190].z + this->unk22C.z; + Math_Vec3f_Copy(&this->subCamEye, &this->subCamEyeNext); + Math_Vec3f_Copy(&this->subCamAt, &this->subCamAtNext); } - func_8096FAAC(this, globalCtx); + func_8096FAAC(this, play); - if (this->unkState1A8 != 0 && Message_GetState(&globalCtx->msgCtx) == this->unkMsgState1AC && - Message_ShouldAdvance(globalCtx) != 0) { + if ((this->unkState1A8 != 0) && (Message_GetState(&play->msgCtx) == this->talkState) && + Message_ShouldAdvance(play)) { - func_801477B4(globalCtx); + func_801477B4(play); - if (this->unkMsgState1AC == 5) { + if (this->talkState == TEXT_STATE_5) { this->unk190++; if (this->unk190 > 5) { this->unk190 = 5; } - if (this->actor.textId == 0x1648) { - func_800B7298(globalCtx, &this->actor, 7); - this->actor.textId = 0x1649; + if (this->picto.actor.textId == 0x1648) { + func_800B7298(play, &this->picto.actor, 7); + this->picto.actor.textId = 0x1649; if (this->animIndex != ENKAKASI_ANIM_ARMS_CROSSED_ROCKING) { - EnKakasi_SetAnimation(this, ENKAKASI_ANIM_ARMS_CROSSED_ROCKING); + EnKakasi_ChangeAnim(this, ENKAKASI_ANIM_ARMS_CROSSED_ROCKING); } - } else if (this->actor.textId == 0x1649) { - this->actor.textId = 0x1660; - this->unkMsgState1AC = 4; + } else if (this->picto.actor.textId == 0x1649) { + this->picto.actor.textId = 0x1660; + this->talkState = TEXT_STATE_CHOICE; - } else if (this->actor.textId == 0x164A) { - this->actor.textId = 0x164B; + } else if (this->picto.actor.textId == 0x164A) { + this->picto.actor.textId = 0x164B; - } else if (this->actor.textId == 0x164B) { - this->actor.textId = 0x164C; - EnKakasi_SetAnimation(this, ENKAKASI_ANIM_TWIRL); + } else if (this->picto.actor.textId == 0x164B) { + this->picto.actor.textId = 0x164C; + EnKakasi_ChangeAnim(this, ENKAKASI_ANIM_TWIRL); } else { - if (this->actor.textId == 0x164C || this->actor.textId == 0x1661) { + if (this->picto.actor.textId == 0x164C || this->picto.actor.textId == 0x1661) { EnKakasi_SetupDigAway(this); return; } } } else { - this->unkMsgState1AC = 5; - if (globalCtx->msgCtx.choiceIndex == 1) { - func_8019F208(); // play 0x4808 sfx (decide) and calls func_801A75E8 - this->actor.textId = 0x164A; + this->talkState = TEXT_STATE_5; + if (play->msgCtx.choiceIndex == 1) { + func_8019F208(); // play 0x4808 sfx (decide) and calls AudioSfx_StopById + this->picto.actor.textId = 0x164A; } else { - func_8019F230(); // play 0x480A sfx (cancel) and calls func_801A75E8 - this->actor.textId = 0x1661; + func_8019F230(); // play 0x480A sfx (cancel) and calls AudioSfx_StopById + this->picto.actor.textId = 0x1661; } } - func_80151938(globalCtx, this->actor.textId); + func_80151938(play, this->picto.actor.textId); } } /* * talking before dancing the night away, and cutscene setup */ -void EnKakasi_DancingRemark(EnKakasi* this, GlobalContext* globalCtx) { +void EnKakasi_DancingRemark(EnKakasi* this, PlayState* play) { u32 currentDay = gSaveContext.save.day; this->unkState196 = 3; @@ -797,8 +795,8 @@ void EnKakasi_DancingRemark(EnKakasi* this, GlobalContext* globalCtx) { } else if (ActorCutscene_GetCanPlayNext(this->actorCutscenes[0]) == 0) { ActorCutscene_SetIntentToPlay(this->actorCutscenes[0]); } else { - ActorCutscene_StartAndSetUnkLinkFields(this->actorCutscenes[0], &this->actor); - this->cutsceneCamId = ActorCutscene_GetCurrentCamera(this->actor.cutscene); + ActorCutscene_StartAndSetUnkLinkFields(this->actorCutscenes[0], &this->picto.actor); + this->subCamId = ActorCutscene_GetCurrentSubCamId(this->picto.actor.cutscene); if (currentDay == 3 && gSaveContext.save.isNight) { EnKakasi_SetupDigAway(this); } else { @@ -811,43 +809,43 @@ void EnKakasi_DancingRemark(EnKakasi* this, GlobalContext* globalCtx) { void EnKakasi_SetupDanceNightAway(EnKakasi* this) { this->unk190 = 0; this->unkCounter1A4 = 0; - this->unk20C = 0.0f; - this->unk210 = 60.0f; - EnKakasi_SetAnimation(this, ENKAKASI_ANIM_TWIRL); - Math_Vec3f_Copy(&this->unk22C, &this->actor.home.pos); + this->subCamFov = 0.0f; + this->subCamFovNext = 60.0f; + EnKakasi_ChangeAnim(this, ENKAKASI_ANIM_TWIRL); + Math_Vec3f_Copy(&this->unk22C, &this->picto.actor.home.pos); func_8016566C(0xB4); this->actionFunc = EnKakasi_DancingNightAway; } -void EnKakasi_DancingNightAway(EnKakasi* this, GlobalContext* globalCtx) { +void EnKakasi_DancingNightAway(EnKakasi* this, PlayState* play) { f32 currentFrame; Vec3f localVec3f; Player* player; currentFrame = this->skelanime.curFrame; - EnKakasi_CheckPlayerPosition(this, globalCtx); - Math_SmoothStepToS(&this->actor.shape.rot.y, this->actor.home.rot.y, 1, 3000, 0); - this->unk22C.y = this->actor.home.pos.y + 50.0f; + EnKakasi_CheckPlayerPosition(this, play); + Math_SmoothStepToS(&this->picto.actor.shape.rot.y, this->picto.actor.home.rot.y, 1, 3000, 0); + this->unk22C.y = this->picto.actor.home.pos.y + 50.0f; - this->unk238.x = D_80971E38[this->unk190].x; - this->unk238.y = D_80971E38[this->unk190].y; - this->unk238.z = D_80971E38[this->unk190].z; - Math_Vec3f_Copy(&localVec3f, &this->unk238); - OLib_DbCameraVec3fSum(&this->actor.home, &localVec3f, &this->unk238, 1); + this->subCamEyeNext.x = D_80971E38[this->unk190].x; + this->subCamEyeNext.y = D_80971E38[this->unk190].y; + this->subCamEyeNext.z = D_80971E38[this->unk190].z; + Math_Vec3f_Copy(&localVec3f, &this->subCamEyeNext); + OLib_DbCameraVec3fSum(&this->picto.actor.home, &localVec3f, &this->subCamEyeNext, 1); if (1) {} - this->unk244.x = D_80971EEC[this->unk190].x + this->unk22C.x; - this->unk244.y = D_80971EEC[this->unk190].y + this->unk22C.y; - this->unk244.z = D_80971EEC[this->unk190].z + this->unk22C.z; + this->subCamAtNext.x = D_80971EEC[this->unk190].x + this->unk22C.x; + this->subCamAtNext.y = D_80971EEC[this->unk190].y + this->unk22C.y; + this->subCamAtNext.z = D_80971EEC[this->unk190].z + this->unk22C.z; if (this->unk190 != 6 && this->unk190 != 7) { - Math_Vec3f_Copy(&this->unk214, &this->unk238); - Math_Vec3f_Copy(&this->unk220, &this->unk244); + Math_Vec3f_Copy(&this->subCamEye, &this->subCamEyeNext); + Math_Vec3f_Copy(&this->subCamAt, &this->subCamAtNext); } if (this->unk190 >= 7 && this->unk190 != 0xE) { - this->actor.shape.rot.y += 0x800; + this->picto.actor.shape.rot.y += 0x800; } - func_8096FAAC(this, globalCtx); + func_8096FAAC(this, play); // switching through manual cutscene states switch (this->unk190) { @@ -861,7 +859,7 @@ void EnKakasi_DancingNightAway(EnKakasi* this, GlobalContext* globalCtx) { if (this->unk204 == 0 && this->animeFrameCount <= currentFrame) { this->unk204 = 0x14; this->unk190++; - EnKakasi_SetAnimation(this, ENKAKASI_ANIM_SIDEWAYS_SHAKING); + EnKakasi_ChangeAnim(this, ENKAKASI_ANIM_SIDEWAYS_SHAKING); } return; case 2: @@ -918,7 +916,7 @@ void EnKakasi_DancingNightAway(EnKakasi* this, GlobalContext* globalCtx) { this->unk190++; this->unk204 = 0xA; if (this->unk190 == 0xE) { - func_800B7298(globalCtx, &this->actor, 0x49); + func_800B7298(play, &this->picto.actor, 0x49); func_80165690(); this->unk204 = 0x14; } @@ -926,14 +924,14 @@ void EnKakasi_DancingNightAway(EnKakasi* this, GlobalContext* globalCtx) { return; case 14: // goes off once for some camera changes, - // otherwise its the end when camera is back to normal and link is confused - Math_SmoothStepToS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer, 5, 1000, 0); + // otherwise it's the end when camera is back to normal and Player is confused + Math_SmoothStepToS(&this->picto.actor.shape.rot.y, this->picto.actor.yawTowardsPlayer, 5, 1000, 0); if (this->unk204 == 0) { - player = GET_PLAYER(globalCtx); + player = GET_PLAYER(play); - Play_SetRespawnData(&globalCtx->state, RESTART_MODE_DOWN, Entrance_CreateIndexFromSpawn(0), - player->unk_3CE, 0xBFF, &player->unk_3C0, player->unk_3CC); - func_80169EFC(&globalCtx->state); + Play_SetRespawnData(&play->state, RESPAWN_MODE_DOWN, Entrance_CreateFromSpawn(0), player->unk_3CE, + 0xBFF, &player->unk_3C0, player->unk_3CC); + func_80169EFC(&play->state); if (0) {} if (gSaveContext.save.time > CLOCK_TIME(18, 0) || gSaveContext.save.time < CLOCK_TIME(6, 0)) { @@ -951,40 +949,40 @@ void EnKakasi_DancingNightAway(EnKakasi* this, GlobalContext* globalCtx) { } } -void EnKakasi_DoNothing(EnKakasi* this, GlobalContext* globalCtx) { +void EnKakasi_DoNothing(EnKakasi* this, PlayState* play) { } void EnKakasi_SetupDigAway(EnKakasi* this) { if (this->animIndex != ENKAKASI_ANIM_SIDEWAYS_SHAKING) { - EnKakasi_SetAnimation(this, ENKAKASI_ANIM_SIDEWAYS_SHAKING); + EnKakasi_ChangeAnim(this, ENKAKASI_ANIM_SIDEWAYS_SHAKING); } this->unk190 = 0; this->unkCounter1A4 = 0; - this->unk210 = 60.0f; - this->unk20C = 60.0f; - Math_Vec3f_Copy(&this->unk22C, &this->actor.home.pos); + this->subCamFovNext = 60.0f; + this->subCamFov = 60.0f; + Math_Vec3f_Copy(&this->unk22C, &this->picto.actor.home.pos); this->unkState196 = 4; this->actionFunc = EnKakasi_DiggingAway; } -void EnKakasi_DiggingAway(EnKakasi* this, GlobalContext* globalCtx) { +void EnKakasi_DiggingAway(EnKakasi* this, PlayState* play) { Vec3f tempunk238; Vec3f tempWorldPos; - 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; - this->unk238.z = D_80972030.z; + if (this->subCamId != SUB_CAM_ID_DONE) { + this->unk22C.y = this->picto.actor.home.pos.y + 50.0f; + this->subCamEyeNext.x = D_80972030.x; + this->subCamEyeNext.y = D_80972030.y; + this->subCamEyeNext.z = D_80972030.z; - Math_Vec3f_Copy(&tempunk238, &this->unk238); - OLib_DbCameraVec3fSum(&this->actor.home, &tempunk238, &this->unk238, 1); - this->unk244.x = ((f32)D_8097203C.x) + this->unk22C.x; // cast req - this->unk244.y = ((f32)D_8097203C.y) + this->unk22C.y; - this->unk244.z = ((f32)D_8097203C.z) + this->unk22C.z; - Math_Vec3f_Copy(&this->unk214, &this->unk238); - Math_Vec3f_Copy(&this->unk220, &this->unk244); - func_8096FAAC(this, globalCtx); + Math_Vec3f_Copy(&tempunk238, &this->subCamEyeNext); + OLib_DbCameraVec3fSum(&this->picto.actor.home, &tempunk238, &this->subCamEyeNext, 1); + this->subCamAtNext.x = ((f32)D_8097203C.x) + this->unk22C.x; // cast req + this->subCamAtNext.y = ((f32)D_8097203C.y) + this->unk22C.y; + this->subCamAtNext.z = ((f32)D_8097203C.z) + this->unk22C.z; + Math_Vec3f_Copy(&this->subCamEye, &this->subCamEyeNext); + Math_Vec3f_Copy(&this->subCamAt, &this->subCamAtNext); + func_8096FAAC(this, play); } if (this->unkCounter1A4 < 15) { @@ -992,29 +990,29 @@ void EnKakasi_DiggingAway(EnKakasi* this, GlobalContext* globalCtx) { return; } - this->actor.shape.rot.y += 0x3000; + this->picto.actor.shape.rot.y += 0x3000; Math_SmoothStepToS(&this->unk190, 500, 5, 50, 0); - if ((globalCtx->gameplayFrames % 4) == 0) { - Math_Vec3f_Copy(&tempWorldPos, &this->actor.world.pos); - tempWorldPos.y = this->actor.floorHeight; + if ((play->gameplayFrames % 4) == 0) { + Math_Vec3f_Copy(&tempWorldPos, &this->picto.actor.world.pos); + tempWorldPos.y = this->picto.actor.floorHeight; tempWorldPos.x += randPlusMinusPoint5Scaled(2.0f); tempWorldPos.z += randPlusMinusPoint5Scaled(2.0f); - if (globalCtx->sceneNum == SCENE_8ITEMSHOP) { - EffectSsGSplash_Spawn(globalCtx, &tempWorldPos, 0, 0, 0, randPlusMinusPoint5Scaled(100.0f) + 200.0f); - SoundSource_PlaySfxAtFixedWorldPos(globalCtx, &tempWorldPos, 0x32, NA_SE_EV_BOMB_DROP_WATER); + if (play->sceneNum == SCENE_8ITEMSHOP) { + EffectSsGSplash_Spawn(play, &tempWorldPos, 0, 0, 0, randPlusMinusPoint5Scaled(100.0f) + 200.0f); + SoundSource_PlaySfxAtFixedWorldPos(play, &tempWorldPos, 0x32, NA_SE_EV_BOMB_DROP_WATER); } else { - Actor_SpawnFloorDustRing(globalCtx, &this->actor, &this->actor.world.pos, - this->actor.shape.shadowScale - 20.0f, 5, 4.0f, 200, 10, 1); - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_AKINDONUTS_HIDE); + Actor_SpawnFloorDustRing(play, &this->picto.actor, &this->picto.actor.world.pos, + this->picto.actor.shape.shadowScale - 20.0f, 5, 4.0f, 200, 10, 1); + Actor_PlaySfxAtPos(&this->picto.actor, NA_SE_EN_AKINDONUTS_HIDE); } } - Math_ApproachF(&this->actor.shape.yOffset, -6000.0f, 0.5f, 200.0f); - if (fabsf(this->actor.shape.yOffset + 6000.0f) < 10.0f) { + Math_ApproachF(&this->picto.actor.shape.yOffset, -6000.0f, 0.5f, 200.0f); + if (fabsf(this->picto.actor.shape.yOffset + 6000.0f) < 10.0f) { gSaveContext.save.weekEventReg[79] |= 8; - func_800B7298(globalCtx, &this->actor, 6); + func_800B7298(play, &this->picto.actor, 6); ActorCutscene_Stop(this->actorCutscenes[0]); this->aboveGroundStatus = ENKAKASI_ABOVE_GROUND_TYPE; this->songSummonDist = 80.0f; @@ -1023,23 +1021,23 @@ 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 |= ACTOR_FLAG_8000000; + this->picto.actor.shape.yOffset = -7000.0; + this->picto.actor.draw = NULL; + this->picto.actor.flags |= ACTOR_FLAG_8000000; this->unkState196 = 5; this->actionFunc = EnKakasi_IdleUnderground; } -void EnKakasi_IdleUnderground(EnKakasi* this, GlobalContext* globalCtx) { - if ((gSaveContext.save.weekEventReg[79] & 8) && this->actor.xzDistToPlayer < this->songSummonDist && - (BREG(1) != 0 || globalCtx->msgCtx.ocarinaMode == 0xD)) { - this->actor.flags &= ~ACTOR_FLAG_8000000; - globalCtx->msgCtx.ocarinaMode = 4; +void EnKakasi_IdleUnderground(EnKakasi* this, PlayState* play) { + if ((gSaveContext.save.weekEventReg[79] & 8) && this->picto.actor.xzDistToPlayer < this->songSummonDist && + (BREG(1) != 0 || play->msgCtx.ocarinaMode == 0xD)) { + this->picto.actor.flags &= ~ACTOR_FLAG_8000000; + play->msgCtx.ocarinaMode = 4; this->actionFunc = EnKakasi_SetupRiseOutOfGround; } } -void EnKakasi_SetupRiseOutOfGround(EnKakasi* this, GlobalContext* globalCtx) { +void EnKakasi_SetupRiseOutOfGround(EnKakasi* this, PlayState* play) { s32 cutsceneIndex; cutsceneIndex = 0; @@ -1055,27 +1053,27 @@ void EnKakasi_SetupRiseOutOfGround(EnKakasi* this, GlobalContext* globalCtx) { ActorCutscene_SetIntentToPlay(this->actorCutscenes[cutsceneIndex]); } else { - ActorCutscene_StartAndSetUnkLinkFields(this->actorCutscenes[cutsceneIndex], &this->actor); - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_AKINDONUTS_HIDE); - this->actor.draw = EnKakasi_Draw; + ActorCutscene_StartAndSetUnkLinkFields(this->actorCutscenes[cutsceneIndex], &this->picto.actor); + Actor_PlaySfxAtPos(&this->picto.actor, NA_SE_EN_AKINDONUTS_HIDE); + this->picto.actor.draw = EnKakasi_Draw; this->unkState196 = 6; this->actionFunc = EnKakasi_RisingOutOfGround; } } -void EnKakasi_RisingOutOfGround(EnKakasi* this, GlobalContext* globalCtx) { - this->actor.shape.rot.y += 0x3000; +void EnKakasi_RisingOutOfGround(EnKakasi* this, PlayState* play) { + this->picto.actor.shape.rot.y += 0x3000; if (this->animIndex != ENKAKASI_ANIM_SIDEWAYS_SHAKING) { - EnKakasi_SetAnimation(this, ENKAKASI_ANIM_SIDEWAYS_SHAKING); + EnKakasi_ChangeAnim(this, ENKAKASI_ANIM_SIDEWAYS_SHAKING); } - if (this->actor.shape.yOffset < -10.0f) { - if ((globalCtx->gameplayFrames % 8) == 0) { - Actor_SpawnFloorDustRing(globalCtx, &this->actor, &this->actor.world.pos, - this->actor.shape.shadowScale - 20.0f, 10, 8.0f, 500, 10, 1); - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_AKINDONUTS_HIDE); + if (this->picto.actor.shape.yOffset < -10.0f) { + if ((play->gameplayFrames % 8) == 0) { + Actor_SpawnFloorDustRing(play, &this->picto.actor, &this->picto.actor.world.pos, + this->picto.actor.shape.shadowScale - 20.0f, 10, 8.0f, 500, 10, 1); + Actor_PlaySfxAtPos(&this->picto.actor, NA_SE_EN_AKINDONUTS_HIDE); } - Math_ApproachF(&this->actor.shape.yOffset, 0.0f, 0.5f, 200.0f); + Math_ApproachF(&this->picto.actor.shape.yOffset, 0.0f, 0.5f, 200.0f); } else { EnKakasi_SetupIdleRisen(this); } @@ -1083,78 +1081,78 @@ void EnKakasi_RisingOutOfGround(EnKakasi* this, GlobalContext* globalCtx) { void EnKakasi_SetupIdleRisen(EnKakasi* this) { // text: great to see you again - this->actor.textId = 0x164D; + this->picto.actor.textId = 0x164D; this->unkState196 = 7; this->actionFunc = EnKakasi_IdleRisen; - this->actor.shape.yOffset = 0.0f; + this->picto.actor.shape.yOffset = 0.0f; } -void EnKakasi_IdleRisen(EnKakasi* this, GlobalContext* globalCtx) { - Math_SmoothStepToS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer, 5, 1000, 0); - if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { +void EnKakasi_IdleRisen(EnKakasi* this, PlayState* play) { + Math_SmoothStepToS(&this->picto.actor.shape.rot.y, this->picto.actor.yawTowardsPlayer, 5, 1000, 0); + if (Actor_ProcessTalkRequest(&this->picto.actor, &play->state)) { this->actionFunc = EnKakasi_RisenDialogue; } else { - func_800B8614(&this->actor, globalCtx, 70.0f); + func_800B8614(&this->picto.actor, play, 70.0f); } } -void EnKakasi_RisenDialogue(EnKakasi* this, GlobalContext* globalCtx) { - Math_SmoothStepToS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer, 5, 1000, 0); +void EnKakasi_RisenDialogue(EnKakasi* this, PlayState* play) { + Math_SmoothStepToS(&this->picto.actor.shape.rot.y, this->picto.actor.yawTowardsPlayer, 5, 1000, 0); - if (Message_GetState(&globalCtx->msgCtx) == 5 && Message_ShouldAdvance(globalCtx) != 0) { - func_801477B4(globalCtx); + if ((Message_GetState(&play->msgCtx) == TEXT_STATE_5) && Message_ShouldAdvance(play)) { + func_801477B4(play); EnKakasi_SetupIdleRisen(this); } } -void EnKakasi_Update(Actor* thisx, GlobalContext* globalCtx) { +void EnKakasi_Update(Actor* thisx, PlayState* play) { EnKakasi* this = THIS; s32 pad; SkelAnime_Update(&this->skelanime); - if (this->actor.draw != NULL) { + if (this->picto.actor.draw != NULL) { EnKakasi_CheckAnimationSfx(this); } - this->actor.world.rot.y = this->actor.shape.rot.y; + this->picto.actor.world.rot.y = this->picto.actor.shape.rot.y; DECR(this->postTeachTimer); DECR(this->unk204); if (this->unkState196 != 5) { if (this->unk1BC.x != 0.0f || this->unk1BC.z != 0.0f) { - Math_Vec3f_Copy(&this->actor.focus.pos, &this->unk1BC); - this->actor.focus.pos.y += 10.0f; - if (this->cutsceneCamId == CAM_ID_MAIN) { - Math_Vec3s_Copy(&this->actor.focus.rot, &this->actor.world.rot); + Math_Vec3f_Copy(&this->picto.actor.focus.pos, &this->unk1BC); + this->picto.actor.focus.pos.y += 10.0f; + if (this->subCamId == CAM_ID_MAIN) { + Math_Vec3s_Copy(&this->picto.actor.focus.rot, &this->picto.actor.world.rot); } else { - Math_Vec3s_Copy(&this->actor.focus.rot, &this->actor.home.rot); + Math_Vec3s_Copy(&this->picto.actor.focus.rot, &this->picto.actor.home.rot); } } } else { - Actor_SetFocus(&this->actor, this->unkHeight); + Actor_SetFocus(&this->picto.actor, this->unkHeight); } - this->actionFunc(this, globalCtx); - Actor_MoveWithGravity(&this->actor); - Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 50.0f, 50.0f, 100.0f, 0x1C); - if (this->actor.draw != NULL) { - Collider_UpdateCylinder(&this->actor, &this->collider); - CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); - CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + this->actionFunc(this, play); + Actor_MoveWithGravity(&this->picto.actor); + Actor_UpdateBgCheckInfo(play, &this->picto.actor, 50.0f, 50.0f, 100.0f, 0x1C); + if (this->picto.actor.draw != NULL) { + Collider_UpdateCylinder(&this->picto.actor, &this->collider); + CollisionCheck_SetAC(play, &play->colChkCtx, &this->collider.base); + CollisionCheck_SetOC(play, &play->colChkCtx, &this->collider.base); } } -void EnKakasi_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx) { +void EnKakasi_PostLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx) { EnKakasi* this = THIS; if (limbIndex == 4) { - Matrix_MultiplyVector3fByState(&gZeroVec3f, &this->unk1BC); + Matrix_MultVec3f(&gZeroVec3f, &this->unk1BC); } } -void EnKakasi_Draw(Actor* thisx, GlobalContext* globalCtx) { +void EnKakasi_Draw(Actor* thisx, PlayState* play) { EnKakasi* this = THIS; - func_8012C28C(globalCtx->state.gfxCtx); - SkelAnime_DrawFlexOpa(globalCtx, this->skelanime.skeleton, this->skelanime.jointTable, this->skelanime.dListCount, - NULL, EnKakasi_PostLimbDraw, &this->actor); + func_8012C28C(play->state.gfxCtx); + SkelAnime_DrawFlexOpa(play, this->skelanime.skeleton, this->skelanime.jointTable, this->skelanime.dListCount, NULL, + EnKakasi_PostLimbDraw, &this->picto.actor); } diff --git a/src/overlays/actors/ovl_En_Kakasi/z_en_kakasi.h b/src/overlays/actors/ovl_En_Kakasi/z_en_kakasi.h index 2cb4f6cba..59ef3272a 100644 --- a/src/overlays/actors/ovl_En_Kakasi/z_en_kakasi.h +++ b/src/overlays/actors/ovl_En_Kakasi/z_en_kakasi.h @@ -2,15 +2,14 @@ #define Z_EN_KAKASI_H #include "global.h" +#include "z64snap.h" struct EnKakasi; -typedef void (*EnKakasiActionFunc)(struct EnKakasi*, GlobalContext*); -typedef void (*EnKakasiUnkFunc)(GlobalContext*, struct EnKakasi*); +typedef void (*EnKakasiActionFunc)(struct EnKakasi*, PlayState*); typedef struct EnKakasi { - /* 0x000 */ Actor actor; - /* 0x144 */ EnKakasiUnkFunc unkFunc; // used for one z_snap calling function? + /* 0x000 */ PictoActor picto; /* 0x148 */ EnKakasiActionFunc actionFunc; /* 0x14C */ SkelAnime skelanime; /* 0x190 */ s16 unk190; // camera index for song teaching angles? @@ -21,7 +20,7 @@ typedef struct EnKakasi { /* 0x1A0 */ s32 animIndex; /* 0x1A4 */ s32 unkCounter1A4; // counter, counts up to F while he digs away, reused elsewhere /* 0x1A8 */ s32 unkState1A8; - /* 0x1AC */ s16 unkMsgState1AC; // might be dialog state, compared against func(msgCtx) + /* 0x1AC */ s16 talkState; /* 0x1AE */ s16 actorCutscenes[3]; /* 0x1B4 */ f32 animeFrameCount; /* 0x1B8 */ f32 unkHeight; @@ -29,14 +28,14 @@ typedef struct EnKakasi { /* 0x1C8 */ UNK_TYPE1 pad1C8[0x3C]; /* 0x204 */ s16 unk204; // set to A, F, 0x14, 0x28 frequently /* 0x206 */ UNK_TYPE1 pad206[2]; - /* 0x208 */ s16 cutsceneCamId; - /* 0x20C */ f32 unk20C; // passed to unknown function - /* 0x210 */ f32 unk210; // used as a target for 20C to approach - /* 0x214 */ Vec3f unk214; // copied from unk238 regularly - /* 0x220 */ Vec3f unk220; //EnKakasi_TeachingSong - /* 0x22C */ Vec3f unk22C; //actor home copied to here - /* 0x238 */ Vec3f unk238; //copied from D_80971E38[unk190] - /* 0x244 */ Vec3f unk244; + /* 0x208 */ s16 subCamId; + /* 0x20C */ f32 subCamFov; + /* 0x210 */ f32 subCamFovNext; + /* 0x214 */ Vec3f subCamEye; + /* 0x220 */ Vec3f subCamAt; + /* 0x22C */ Vec3f unk22C; + /* 0x238 */ Vec3f subCamEyeNext; + /* 0x244 */ Vec3f subCamAtNext; /* 0x250 */ f32 songSummonDist; /* 0x254 */ ColliderCylinder collider; } EnKakasi; // size = 0x2A0 @@ -45,7 +44,8 @@ extern const ActorInit En_Kakasi_InitVars; #define ENKAKASI_ABOVE_GROUND_TYPE 2 -#define GET_KAKASI_SUMMON_DISTANCE(this) ((this->actor.params >> 0x8) & 0xFF) -#define GET_KAKASI_ABOVE_GROUND(this) (this->actor.params & 0x1) +#define KAKASI_GET_SUMMON_DISTANCE(thisx) (((thisx)->params >> 0x8) & 0xFF) +#define KAKASI_GET_ABOVE_GROUND(thisx) ((thisx)->params & 0x1) +#define KAKASI_GET_TARGETMODE(thisx) ((thisx)->world.rot.x - 1) #endif // Z_EN_KAKASI_H diff --git a/src/overlays/actors/ovl_En_Kame/z_en_kame.c b/src/overlays/actors/ovl_En_Kame/z_en_kame.c index e457ec219..b6edc7778 100644 --- a/src/overlays/actors/ovl_En_Kame/z_en_kame.c +++ b/src/overlays/actors/ovl_En_Kame/z_en_kame.c @@ -11,35 +11,35 @@ #define THIS ((EnKame*)thisx) -void EnKame_Init(Actor* thisx, GlobalContext* globalCtx); -void EnKame_Destroy(Actor* thisx, GlobalContext* globalCtx); -void EnKame_Update(Actor* thisx, GlobalContext* globalCtx); -void EnKame_Draw(Actor* thisx, GlobalContext* globalCtx); +void EnKame_Init(Actor* thisx, PlayState* play); +void EnKame_Destroy(Actor* thisx, PlayState* play); +void EnKame_Update(Actor* thisx, PlayState* play); +void EnKame_Draw(Actor* thisx, PlayState* play); void func_80AD70A0(EnKame* this); -void func_80AD70EC(EnKame* this, GlobalContext* globalCtx); +void func_80AD70EC(EnKame* this, PlayState* play); void func_80AD71B4(EnKame* this); -void func_80AD7254(EnKame* this, GlobalContext* globalCtx); +void func_80AD7254(EnKame* this, PlayState* play); void func_80AD73A8(EnKame* this); -void func_80AD7424(EnKame* this, GlobalContext* globalCtx); +void func_80AD7424(EnKame* this, PlayState* play); void func_80AD76CC(EnKame* this); -void func_80AD7798(EnKame* this, GlobalContext* globalCtx); +void func_80AD7798(EnKame* this, PlayState* play); void func_80AD792C(EnKame* this); -void func_80AD7948(EnKame* this, GlobalContext* globalCtx); +void func_80AD7948(EnKame* this, PlayState* play); void func_80AD7B18(EnKame* this); -void func_80AD7B90(EnKame* this, GlobalContext* globalCtx); -void func_80AD7D40(EnKame* this, GlobalContext* globalCtx); +void func_80AD7B90(EnKame* this, PlayState* play); +void func_80AD7D40(EnKame* this, PlayState* play); void func_80AD7DA4(EnKame* this); -void func_80AD7E0C(EnKame* this, GlobalContext* globalCtx); +void func_80AD7E0C(EnKame* this, PlayState* play); void func_80AD7EC0(EnKame* this); -void func_80AD7F10(EnKame* this, GlobalContext* globalCtx); -void func_80AD7FF8(EnKame* this, GlobalContext* globalCtx); -void func_80AD810C(EnKame* this, GlobalContext* globalCtx); -void func_80AD8148(EnKame* this, GlobalContext* globalCtx); -void func_80AD825C(EnKame* this, GlobalContext* globalCtx); +void func_80AD7F10(EnKame* this, PlayState* play); +void func_80AD7FF8(EnKame* this, PlayState* play); +void func_80AD810C(EnKame* this, PlayState* play); +void func_80AD8148(EnKame* this, PlayState* play); +void func_80AD825C(EnKame* this, PlayState* play); void func_80AD8364(EnKame* this); -void func_80AD8388(EnKame* this, GlobalContext* globalCtx); -void func_80AD8D64(Actor* thisx, GlobalContext* globalCtx); +void func_80AD8388(EnKame* this, PlayState* play); +void func_80AD8D64(Actor* thisx, PlayState* play); const ActorInit En_Kame_InitVars = { ACTOR_EN_KAME, @@ -121,16 +121,16 @@ static InitChainEntry sInitChain[] = { static s32 D_80AD8E50 = false; -void EnKame_Init(Actor* thisx, GlobalContext* globalCtx) { +void EnKame_Init(Actor* thisx, PlayState* play) { EnKame* this = THIS; Actor_ProcessInitChain(&this->actor, sInitChain); - SkelAnime_InitFlex(globalCtx, &this->skelAnime1, &object_tl_Skel_007C70, &object_tl_Anim_004210, this->jointTable1, + SkelAnime_InitFlex(play, &this->skelAnime1, &object_tl_Skel_007C70, &object_tl_Anim_004210, this->jointTable1, this->morphTable1, 13); - SkelAnime_InitFlex(globalCtx, &this->skelAnime2, &object_tl_Skel_001A50, &object_tl_Anim_000B30, this->jointTable2, + SkelAnime_InitFlex(play, &this->skelAnime2, &object_tl_Skel_001A50, &object_tl_Anim_000B30, this->jointTable2, this->morphTable2, 4); ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 55.0f); - Collider_InitAndSetCylinder(globalCtx, &this->collider, &this->actor, &sCylinderInit); + Collider_InitAndSetCylinder(play, &this->collider, &this->actor, &sCylinderInit); CollisionCheck_SetInfo(&this->actor.colChkInfo, &sDamageTable, &sColChkInfoInit); if (!D_80AD8E50) { @@ -145,10 +145,10 @@ void EnKame_Init(Actor* thisx, GlobalContext* globalCtx) { func_80AD70A0(this); } -void EnKame_Destroy(Actor* thisx, GlobalContext* globalCtx) { +void EnKame_Destroy(Actor* thisx, PlayState* play) { EnKame* this = THIS; - Collider_DestroyCylinder(globalCtx, &this->collider); + Collider_DestroyCylinder(play, &this->collider); } void func_80AD6F34(EnKame* this) { @@ -173,12 +173,12 @@ void func_80AD6F9C(EnKame* this) { Actor_SetColorFilter(&this->actor, 0x4000, 255, 0, 80); } -void func_80AD7018(EnKame* this, GlobalContext* globalCtx) { +void func_80AD7018(EnKame* this, PlayState* play) { if (this->drawDmgEffType == ACTOR_DRAW_DMGEFF_FROZEN_NO_SFX) { this->drawDmgEffType = ACTOR_DRAW_DMGEFF_FIRE; this->collider.base.colType = COLTYPE_HIT6; this->drawDmgEffAlpha = 0.0f; - Actor_SpawnIceEffects(globalCtx, &this->actor, this->limbPos, 10, 2, 0.3f, 0.2f); + Actor_SpawnIceEffects(play, &this->actor, this->limbPos, 10, 2, 0.3f, 0.2f); this->actor.flags |= ACTOR_FLAG_400; } } @@ -189,15 +189,15 @@ void func_80AD70A0(EnKame* this) { this->actionFunc = func_80AD70EC; } -void func_80AD70EC(EnKame* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); +void func_80AD70EC(EnKame* this, PlayState* play) { + Player* player = GET_PLAYER(play); if (Animation_OnFrame(&this->skelAnime1, 10.0f)) { Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_PAMET_VOICE); this->unk_2A0 = 40; } - if ((Player_GetMask(globalCtx) != PLAYER_MASK_STONE) && !(player->stateFlags1 & 0x800000) && + if ((Player_GetMask(play) != PLAYER_MASK_STONE) && !(player->stateFlags1 & 0x800000) && (this->actor.xzDistToPlayer < 240.0f)) { func_80AD73A8(this); } else if (SkelAnime_Update(&this->skelAnime1)) { @@ -215,10 +215,10 @@ void func_80AD71B4(EnKame* this) { this->actionFunc = func_80AD7254; } -void func_80AD7254(EnKame* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); +void func_80AD7254(EnKame* this, PlayState* play) { + Player* player = GET_PLAYER(play); - if ((Player_GetMask(globalCtx) != PLAYER_MASK_STONE) && !(player->stateFlags1 & 0x800000) && + if ((Player_GetMask(play) != PLAYER_MASK_STONE) && !(player->stateFlags1 & 0x800000) && (this->actor.xzDistToPlayer < 240.0f)) { func_80AD73A8(this); return; @@ -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--; @@ -253,11 +253,11 @@ void func_80AD73A8(EnKame* this) { this->actionFunc = func_80AD7424; } -void func_80AD7424(EnKame* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); +void func_80AD7424(EnKame* this, PlayState* play) { + Player* player = GET_PLAYER(play); if (SkelAnime_Update(&this->skelAnime1)) { - if ((Player_GetMask(globalCtx) != PLAYER_MASK_STONE) && !(player->stateFlags1 & 0x800000) && + if ((Player_GetMask(play) != PLAYER_MASK_STONE) && !(player->stateFlags1 & 0x800000) && ((this->unk_29E == 0) || (this->actor.xzDistToPlayer < 120.0f))) { func_80AD76CC(this); } else { @@ -282,20 +282,20 @@ void func_80AD7568(EnKame* this) { this->actor.shape.rot.z = this->unk_2A6 * 0.11016949f; } -void func_80AD75A8(EnKame* this, GlobalContext* globalCtx) { +void func_80AD75A8(EnKame* this, PlayState* play) { static Color_RGBA8 D_80AD8E54 = { 250, 250, 250, 255 }; static Color_RGBA8 D_80AD8E58 = { 180, 180, 180, 255 }; static Vec3f D_80AD8E5C = { 0.0f, 0.75f, 0.0f }; if ((this->actor.bgCheckFlags & 1) && (this->actor.speedXZ >= 3.0f)) { - if ((globalCtx->gameplayFrames % 2) == 0) { - u32 temp_v0 = func_800C9BB8(&globalCtx->colCtx, this->actor.floorPoly, this->actor.floorBgId); + if ((play->gameplayFrames % 2) == 0) { + u32 temp_v0 = func_800C9BB8(&play->colCtx, this->actor.floorPoly, this->actor.floorBgId); if ((temp_v0 == 0) || (temp_v0 == 1)) { - func_800B1210(globalCtx, &this->actor.world.pos, &D_80AD8E5C, &gZeroVec3f, 550, 100); + func_800B1210(play, &this->actor.world.pos, &D_80AD8E5C, &gZeroVec3f, 550, 100); } else if (temp_v0 == 14) { - func_800B0DE0(globalCtx, &this->actor.world.pos, &D_80AD8E5C, &gZeroVec3f, &D_80AD8E54, &D_80AD8E58, - 550, 100); + func_800B0DE0(play, &this->actor.world.pos, &D_80AD8E5C, &gZeroVec3f, &D_80AD8E54, &D_80AD8E58, 550, + 100); } } } @@ -324,7 +324,7 @@ void func_80AD76CC(EnKame* this) { this->actionFunc = func_80AD7798; } -void func_80AD7798(EnKame* this, GlobalContext* globalCtx) { +void func_80AD7798(EnKame* this, PlayState* play) { if (this->unk_29E == 15) { this->unk_2AC += 0.2f; if (this->unk_2AC > 1.1f) { @@ -348,7 +348,7 @@ void func_80AD7798(EnKame* this, GlobalContext* globalCtx) { if (!(this->unk_2BC.y < this->actor.home.pos.y) || (this->actionFunc != func_80AD7798)) { func_80AD7568(this); } - func_80AD75A8(this, globalCtx); + func_80AD75A8(this, play); } void func_80AD792C(EnKame* this) { @@ -356,11 +356,11 @@ void func_80AD792C(EnKame* this) { this->actionFunc = func_80AD7948; } -void func_80AD7948(EnKame* this, GlobalContext* globalCtx) { +void func_80AD7948(EnKame* this, PlayState* play) { s32 temp_v1; this->actor.shape.rot.y += this->unk_2A6; - func_80AD75A8(this, globalCtx); + func_80AD75A8(this, play); if (this->unk_29E == -1) { s16 temp_v0 = Actor_YawToPoint(&this->actor, &this->unk_2BC) - this->actor.world.rot.y; @@ -408,7 +408,7 @@ void func_80AD7B18(EnKame* this) { this->actionFunc = func_80AD7B90; } -void func_80AD7B90(EnKame* this, GlobalContext* globalCtx) { +void func_80AD7B90(EnKame* this, PlayState* play) { if (SkelAnime_Update(&this->skelAnime1)) { func_80AD71B4(this); } else if (this->skelAnime1.curFrame > 7.0f) { @@ -444,7 +444,7 @@ void func_80AD7C54(EnKame* this) { this->actionFunc = func_80AD7D40; } -void func_80AD7D40(EnKame* this, GlobalContext* globalCtx) { +void func_80AD7D40(EnKame* this, PlayState* play) { if (SkelAnime_Update(&this->skelAnime1)) { if (this->unk_29E == 1) { func_80AD71B4(this); @@ -464,7 +464,7 @@ void func_80AD7DA4(EnKame* this) { this->actionFunc = func_80AD7E0C; } -void func_80AD7E0C(EnKame* this, GlobalContext* globalCtx) { +void func_80AD7E0C(EnKame* this, PlayState* play) { if (this->unk_29E > 0) { this->unk_29E--; if (SkelAnime_Update(&this->skelAnime1)) { @@ -486,7 +486,7 @@ void func_80AD7EC0(EnKame* this) { this->actionFunc = func_80AD7F10; } -void func_80AD7F10(EnKame* this, GlobalContext* globalCtx) { +void func_80AD7F10(EnKame* this, PlayState* play) { if (SkelAnime_Update(&this->skelAnime1)) { this->actor.shape.shadowDraw = ActorShadow_DrawCircle; func_80AD71B4(this); @@ -506,13 +506,13 @@ void func_80AD7FA4(EnKame* this) { this->actionFunc = func_80AD7FF8; } -void func_80AD7FF8(EnKame* this, GlobalContext* globalCtx) { +void func_80AD7FF8(EnKame* this, PlayState* play) { if (this->unk_2A2 != 0) { this->unk_2A2--; } if (this->unk_2A2 == 0) { - func_80AD7018(this, globalCtx); + func_80AD7018(this, play); if (this->actor.colChkInfo.health == 0) { func_80AD8148(this, NULL); } else { @@ -525,20 +525,20 @@ void func_80AD7FF8(EnKame* this, GlobalContext* globalCtx) { void func_80AD8060(EnKame* this) { s16 sp36 = Animation_GetLastFrame(&object_tl_Anim_0008B4); - Animation_Change(&this->skelAnime1, &object_tl_Anim_0008B4, 1.0f, 0.0f, sp36, 2, -3.0f); + Animation_Change(&this->skelAnime1, &object_tl_Anim_0008B4, 1.0f, 0.0f, sp36, ANIMMODE_ONCE, -3.0f); Actor_SetColorFilter(&this->actor, 0x4000, 255, 0, sp36); Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_PAMET_DAMAGE); this->collider.base.acFlags &= ~AC_ON; this->actionFunc = func_80AD810C; } -void func_80AD810C(EnKame* this, GlobalContext* globalCtx) { +void func_80AD810C(EnKame* this, PlayState* play) { if (SkelAnime_Update(&this->skelAnime1)) { func_80AD7DA4(this); } } -void func_80AD8148(EnKame* this, GlobalContext* globalCtx) { +void func_80AD8148(EnKame* this, PlayState* play) { Animation_PlayLoop(&this->skelAnime1, &object_tl_Anim_000AF4); Actor_SetColorFilter(&this->actor, 0x4000, 255, 0, 20); this->collider.base.acFlags &= ~AC_ON; @@ -546,8 +546,8 @@ void func_80AD8148(EnKame* this, GlobalContext* globalCtx) { this->collider.base.atFlags &= ~(AC_HARD | AC_HIT); this->actor.velocity.y = 15.0f; this->actor.speedXZ = 1.5f; - if (globalCtx != NULL) { - Enemy_StartFinishingBlow(globalCtx, &this->actor); + if (play != NULL) { + Enemy_StartFinishingBlow(play, &this->actor); if (this->actor.draw == func_80AD8D64) { this->actor.draw = EnKame_Draw; } else { @@ -562,7 +562,7 @@ void func_80AD8148(EnKame* this, GlobalContext* globalCtx) { this->actionFunc = func_80AD825C; } -void func_80AD825C(EnKame* this, GlobalContext* globalCtx) { +void func_80AD825C(EnKame* this, PlayState* play) { SkelAnime_Update(&this->skelAnime1); if ((this->actor.bgCheckFlags & 1) && (this->actor.velocity.y < 0.0f)) { Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_HIPLOOP_LAND); @@ -585,7 +585,7 @@ void func_80AD8364(EnKame* this) { this->actionFunc = func_80AD8388; } -void func_80AD8388(EnKame* this, GlobalContext* globalCtx) { +void func_80AD8388(EnKame* this, PlayState* play) { Vec3f sp34; SkelAnime_Update(&this->skelAnime1); @@ -593,13 +593,13 @@ void func_80AD8388(EnKame* this, GlobalContext* globalCtx) { if (this->unk_29E > 0) { this->unk_29E--; if (this->unk_29E == 0) { - SoundSource_PlaySfxEachFrameAtFixedWorldPos(globalCtx, &this->actor.world.pos, 21, + SoundSource_PlaySfxEachFrameAtFixedWorldPos(play, &this->actor.world.pos, 21, NA_SE_EN_COMMON_EXTINCT_LEV - SFX_FLAG); } } else { this->actor.scale.x -= 0.001f; if (this->actor.scale.x <= 0.0f) { - Item_DropCollectibleRandom(globalCtx, &this->actor, &this->actor.world.pos, 0x60); + Item_DropCollectibleRandom(play, &this->actor, &this->actor.world.pos, 0x60); Actor_MarkForDeath(&this->actor); } else { this->actor.scale.y = this->actor.scale.x; @@ -608,11 +608,11 @@ void func_80AD8388(EnKame* this, GlobalContext* globalCtx) { sp34.x = randPlusMinusPoint5Scaled(40.0f) + this->actor.world.pos.x; sp34.y = this->actor.world.pos.y + 15.0f; sp34.z = randPlusMinusPoint5Scaled(40.0f) + this->actor.world.pos.z; - func_800B3030(globalCtx, &sp34, &gZeroVec3f, &gZeroVec3f, 100, 0, 2); + func_800B3030(play, &sp34, &gZeroVec3f, &gZeroVec3f, 100, 0, 2); } } -void func_80AD84C0(EnKame* this, GlobalContext* globalCtx) { +void func_80AD84C0(EnKame* this, PlayState* play) { if (this->collider.base.acFlags & AC_HIT) { this->collider.base.acFlags &= ~AC_HIT; @@ -622,18 +622,18 @@ void func_80AD84C0(EnKame* this, GlobalContext* globalCtx) { return; } - func_80AD7018(this, globalCtx); + func_80AD7018(this, play); if (this->actor.colChkInfo.damageEffect == 13) { return; } if (this->actor.colChkInfo.damageEffect == 14) { - func_80AD8148(this, globalCtx); + func_80AD8148(this, play); } else if (this->actor.colChkInfo.damageEffect == 15) { if (this->collider.base.acFlags & AC_HARD) { func_80AD7C54(this); } else if (!Actor_ApplyDamage(&this->actor)) { - func_80AD8148(this, globalCtx); + func_80AD8148(this, play); } else { func_80AD8060(this); } @@ -670,13 +670,13 @@ void func_80AD84C0(EnKame* this, GlobalContext* globalCtx) { 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); + Actor_Spawn(&play->actorCtx, play, ACTOR_EN_CLEAR_TAG, this->collider.info.bumper.hitPos.x, + this->collider.info.bumper.hitPos.y, this->collider.info.bumper.hitPos.z, 0, 0, 0, + CLEAR_TAG_LARGE_LIGHT_RAYS); } if (!Actor_ApplyDamage(&this->actor)) { - func_80AD8148(this, globalCtx); + func_80AD8148(this, play); } else { func_80AD8060(this); } @@ -684,14 +684,14 @@ void func_80AD84C0(EnKame* this, GlobalContext* globalCtx) { } } - if ((globalCtx->actorCtx.unk2 != 0) && (this->actor.xyzDistToPlayerSq < SQ(200.0f)) && + if ((play->actorCtx.unk2 != 0) && (this->actor.xyzDistToPlayerSq < SQ(200.0f)) && (this->collider.base.acFlags & AC_ON)) { - func_80AD7018(this, globalCtx); + func_80AD7018(this, play); func_80AD7C54(this); } } -void EnKame_Update(Actor* thisx, GlobalContext* globalCtx) { +void EnKame_Update(Actor* thisx, PlayState* play) { s32 pad; EnKame* this = THIS; @@ -701,7 +701,7 @@ void EnKame_Update(Actor* thisx, GlobalContext* globalCtx) { this->unk_2A0--; } - func_80AD84C0(this, globalCtx); + func_80AD84C0(this, play); if ((this->collider.base.atFlags & AT_HIT) && (this->collider.base.atFlags & AT_BOUNCED)) { this->collider.base.atFlags &= ~(AT_BOUNCED | AT_HIT); @@ -713,10 +713,10 @@ void EnKame_Update(Actor* thisx, GlobalContext* globalCtx) { func_80AD7568(this); } - this->actionFunc(this, globalCtx); + this->actionFunc(this, play); Actor_MoveWithGravity(&this->actor); - Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 40.0f, 60.0f, 40.0f, 0x1F); + Actor_UpdateBgCheckInfo(play, &this->actor, 40.0f, 60.0f, 40.0f, 0x1F); if (this->actor.shape.shadowDraw != NULL) { Actor_SetFocus(&this->actor, 25.0f); @@ -724,14 +724,14 @@ void EnKame_Update(Actor* thisx, GlobalContext* globalCtx) { } if (this->collider.base.atFlags & AT_ON) { - CollisionCheck_SetAT(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + CollisionCheck_SetAT(play, &play->colChkCtx, &this->collider.base); } if (this->collider.base.acFlags & AC_ON) { - CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + CollisionCheck_SetAC(play, &play->colChkCtx, &this->collider.base); } - CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + CollisionCheck_SetOC(play, &play->colChkCtx, &this->collider.base); if (this->drawDmgEffAlpha > 0.0f) { if (this->drawDmgEffType != ACTOR_DRAW_DMGEFF_FROZEN_NO_SFX) { @@ -748,7 +748,7 @@ void EnKame_Update(Actor* thisx, GlobalContext* globalCtx) { } } -s32 func_80AD8A48(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, Actor* thisx) { +s32 func_80AD8A48(PlayState* play, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, Actor* thisx) { EnKame* this = THIS; if ((this->actionFunc == func_80AD7424) || (this->actionFunc == func_80AD7B90)) { @@ -761,7 +761,7 @@ s32 func_80AD8A48(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* p return false; } -void func_80AD8AF8(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx) { +void func_80AD8AF8(PlayState* play, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx) { static Vec3f D_80AD8E68[] = { { 1500.0f, 0.0f, -2000.0f }, { 1500.0f, 0.0f, 2000.0f }, { 1500.0f, 2000.0f, 0.0f }, { 1500.0f, -2000.0f, 0.0f }, { 2500.0f, 0.0f, 0.0f }, @@ -770,7 +770,7 @@ void func_80AD8AF8(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* EnKame* this = THIS; if (D_80AD8EA4[limbIndex] != -1) { - Matrix_GetStateTranslation(&this->limbPos[D_80AD8EA4[limbIndex]]); + Matrix_MultZero(&this->limbPos[D_80AD8EA4[limbIndex]]); } if (limbIndex == 1) { @@ -779,20 +779,20 @@ 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->limbPos[5]; for (i = 0; i < ARRAY_COUNT(D_80AD8E68); i++) { - Matrix_MultiplyVector3fByState(ptr2, ptr); + Matrix_MultVec3f(ptr2, ptr); ptr2++; ptr++; } } } -void EnKame_Draw(Actor* thisx, GlobalContext* globalCtx) { +void EnKame_Draw(Actor* thisx, PlayState* play) { EnKame* this = THIS; Vec3f sp40; @@ -800,29 +800,28 @@ void EnKame_Draw(Actor* thisx, GlobalContext* globalCtx) { Math_Vec3f_Copy(&sp40, &this->actor.world.pos); } - OPEN_DISPS(globalCtx->state.gfxCtx); + OPEN_DISPS(play->state.gfxCtx); - func_8012C28C(globalCtx->state.gfxCtx); + func_8012C28C(play->state.gfxCtx); gSPSegment(POLY_OPA_DISP++, 0x08, D_80AD8E34[this->unk_29C]); - SkelAnime_DrawFlexOpa(globalCtx, this->skelAnime1.skeleton, this->skelAnime1.jointTable, - this->skelAnime1.dListCount, func_80AD8A48, func_80AD8AF8, &this->actor); - Actor_DrawDamageEffects(globalCtx, &this->actor, this->limbPos, ARRAY_COUNT(this->limbPos), this->drawDmgEffScale, + SkelAnime_DrawFlexOpa(play, this->skelAnime1.skeleton, this->skelAnime1.jointTable, this->skelAnime1.dListCount, + func_80AD8A48, func_80AD8AF8, &this->actor); + Actor_DrawDamageEffects(play, &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); + ActorShadow_DrawCircle(&this->actor, NULL, play); Actor_SetFocus(&this->actor, 25.0f); Collider_UpdateCylinder(&this->actor, &this->collider); Math_Vec3f_Copy(&this->actor.world.pos, &sp40); } - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->state.gfxCtx); } -s32 Enkame_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, - Actor* thisx) { +s32 Enkame_OverrideLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, Actor* thisx) { EnKame* this = THIS; if (limbIndex == 1) { @@ -835,10 +834,10 @@ s32 Enkame_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList return false; } -void func_80AD8D64(Actor* thisx, GlobalContext* globalCtx) { +void func_80AD8D64(Actor* thisx, PlayState* play) { EnKame* this = THIS; - func_8012C28C(globalCtx->state.gfxCtx); - SkelAnime_DrawFlexOpa(globalCtx, this->skelAnime2.skeleton, this->skelAnime2.jointTable, - this->skelAnime2.dListCount, Enkame_OverrideLimbDraw, NULL, &this->actor); + func_8012C28C(play->state.gfxCtx); + SkelAnime_DrawFlexOpa(play, this->skelAnime2.skeleton, this->skelAnime2.jointTable, this->skelAnime2.dListCount, + Enkame_OverrideLimbDraw, NULL, &this->actor); } diff --git a/src/overlays/actors/ovl_En_Kame/z_en_kame.h b/src/overlays/actors/ovl_En_Kame/z_en_kame.h index d47e96d54..6e0aa371b 100644 --- a/src/overlays/actors/ovl_En_Kame/z_en_kame.h +++ b/src/overlays/actors/ovl_En_Kame/z_en_kame.h @@ -5,32 +5,32 @@ struct EnKame; -typedef void (*EnKameActionFunc)(struct EnKame*, GlobalContext*); +typedef void (*EnKameActionFunc)(struct EnKame*, PlayState*); typedef struct EnKame { - /* 0x0000 */ Actor actor; - /* 0x0144 */ SkelAnime skelAnime1; - /* 0x0188 */ Vec3s jointTable1[13]; - /* 0x01D6 */ Vec3s morphTable1[13]; - /* 0x0224 */ SkelAnime skelAnime2; - /* 0x0268 */ Vec3s jointTable2[4]; - /* 0x0280 */ Vec3s morphTable2[4]; - /* 0x0298 */ EnKameActionFunc actionFunc; - /* 0x029C */ u8 unk_29C; - /* 0x029D */ u8 drawDmgEffType; - /* 0x029E */ s16 unk_29E; - /* 0x02A0 */ s16 unk_2A0; - /* 0x02A2 */ s16 unk_2A2; - /* 0x02A4 */ s16 unk_2A4; - /* 0x02A6 */ s16 unk_2A6; - /* 0x02A8 */ f32 unk_2A8; - /* 0x02AC */ f32 unk_2AC; - /* 0x02B0 */ f32 drawDmgEffAlpha; - /* 0x02B4 */ f32 drawDmgEffScale; - /* 0x02B8 */ f32 drawDmgEffFrozenSteamScale; - /* 0x02BC */ Vec3f unk_2BC; - /* 0x02C8 */ Vec3f limbPos[10]; - /* 0x0340 */ ColliderCylinder collider; + /* 0x000 */ Actor actor; + /* 0x144 */ SkelAnime skelAnime1; + /* 0x188 */ Vec3s jointTable1[13]; + /* 0x1D6 */ Vec3s morphTable1[13]; + /* 0x224 */ SkelAnime skelAnime2; + /* 0x268 */ Vec3s jointTable2[4]; + /* 0x280 */ Vec3s morphTable2[4]; + /* 0x298 */ EnKameActionFunc actionFunc; + /* 0x29C */ u8 unk_29C; + /* 0x29D */ u8 drawDmgEffType; + /* 0x29E */ s16 unk_29E; + /* 0x2A0 */ s16 unk_2A0; + /* 0x2A2 */ s16 unk_2A2; + /* 0x2A4 */ s16 unk_2A4; + /* 0x2A6 */ s16 unk_2A6; + /* 0x2A8 */ f32 unk_2A8; + /* 0x2AC */ f32 unk_2AC; + /* 0x2B0 */ f32 drawDmgEffAlpha; + /* 0x2B4 */ f32 drawDmgEffScale; + /* 0x2B8 */ f32 drawDmgEffFrozenSteamScale; + /* 0x2BC */ Vec3f unk_2BC; + /* 0x2C8 */ Vec3f limbPos[10]; + /* 0x340 */ ColliderCylinder collider; } EnKame; // size = 0x38C extern const ActorInit En_Kame_InitVars; diff --git a/src/overlays/actors/ovl_En_Kanban/z_en_kanban.c b/src/overlays/actors/ovl_En_Kanban/z_en_kanban.c index 33474cda5..4499ed44a 100644 --- a/src/overlays/actors/ovl_En_Kanban/z_en_kanban.c +++ b/src/overlays/actors/ovl_En_Kanban/z_en_kanban.c @@ -12,10 +12,10 @@ #define THIS ((EnKanban*)thisx) -void EnKanban_Init(Actor* thisx, GlobalContext* globalCtx); -void EnKanban_Destroy(Actor* thisx, GlobalContext* globalCtx); -void EnKanban_Update(Actor* thisx, GlobalContext* globalCtx); -void EnKanban_Draw(Actor* thisx, GlobalContext* globalCtx); +void EnKanban_Init(Actor* thisx, PlayState* play); +void EnKanban_Destroy(Actor* thisx, PlayState* play); +void EnKanban_Update(Actor* thisx, PlayState* play); +void EnKanban_Draw(Actor* thisx, PlayState* play); const ActorInit En_Kanban_InitVars = { ACTOR_EN_KANBAN, @@ -140,7 +140,7 @@ void func_80954960(EnKanban* this) { } } -void EnKanban_Init(Actor* thisx, GlobalContext* globalCtx) { +void EnKanban_Init(Actor* thisx, PlayState* play) { EnKanban* this = THIS; Actor_SetScale(&this->actor, 0.01f); @@ -148,8 +148,8 @@ void EnKanban_Init(Actor* thisx, GlobalContext* globalCtx) { this->actor.targetMode = 0; 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); + Collider_InitCylinder(play, &this->collider); + Collider_SetCylinder(play, &this->collider, &this->actor, &sCylinderInit); if (this->actor.params == ENKANBAN_FISHING) { if (LINK_IS_CHILD) { @@ -163,36 +163,36 @@ void EnKanban_Init(Actor* thisx, GlobalContext* globalCtx) { this->bounceX = 1; this->partFlags = 0xFFFF; - Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 10.0f, 10.0f, 50.0f, 4); + Actor_UpdateBgCheckInfo(play, &this->actor, 10.0f, 10.0f, 50.0f, 4); func_80954960(this); } } -void EnKanban_Destroy(Actor* thisx, GlobalContext* globalCtx) { +void EnKanban_Destroy(Actor* thisx, PlayState* play) { EnKanban* this = THIS; if (this->actionState == ENKANBAN_SIGN) { - Collider_DestroyCylinder(globalCtx, &this->collider); + Collider_DestroyCylinder(play, &this->collider); } } -void func_80954BE8(EnKanban* this, GlobalContext* globalCtx) { +void func_80954BE8(EnKanban* this, PlayState* play) { s16 yaw; if (!this->msgFlag) { if (this->msgTimer == 0) { yaw = this->actor.yawTowardsPlayer - this->actor.shape.rot.y; if (ABS_ALT(yaw) < 0x2800) { - if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { + if (Actor_ProcessTalkRequest(&this->actor, &play->state)) { this->msgFlag = true; } else { - func_800B8614(&this->actor, globalCtx, 68.0f); + func_800B8614(&this->actor, play, 68.0f); } } } else { this->msgTimer--; } - } else if (Actor_TextboxIsClosing(&this->actor, globalCtx)) { + } else if (Actor_TextboxIsClosing(&this->actor, play)) { this->msgFlag = false; this->msgTimer = 20; } @@ -200,12 +200,12 @@ void func_80954BE8(EnKanban* this, GlobalContext* globalCtx) { #ifdef NON_MATCHING // Lots of branch likely stuff -void EnKanban_Update(Actor* thisx, GlobalContext* globalCtx) { - // GlobalContext* globalCtx = globalCtx2; +void EnKanban_Update(Actor* thisx, PlayState* play) { + // PlayState* play = play2; u8 bounced = false; s32 pad; EnKanban* this = THIS; - Player* player = GET_PLAYER(globalCtx); + Player* player = GET_PLAYER(play); Vec3f offset; EnKanban* piece; EnKanban* signpost; @@ -234,7 +234,7 @@ void EnKanban_Update(Actor* thisx, GlobalContext* globalCtx) { } if (this->partFlags == 0xFFFF) { - func_80954BE8(this, globalCtx); + func_80954BE8(this, play); } if ((this->invincibilityTimer == 0) && (this->collider.base.acFlags & AC_HIT)) { @@ -245,7 +245,7 @@ void EnKanban_Update(Actor* thisx, GlobalContext* globalCtx) { this->invincibilityTimer = 6; piece = (EnKanban*)Actor_SpawnAsChild( - &globalCtx->actorCtx, &this->actor, globalCtx, ACTOR_EN_KANBAN, this->actor.world.pos.x, + &play->actorCtx, &this->actor, play, ACTOR_EN_KANBAN, this->actor.world.pos.x, this->actor.world.pos.y, this->actor.world.pos.z, this->actor.shape.rot.x, this->actor.shape.rot.y, this->actor.shape.rot.z, ENKANBAN_PIECE); if (piece != NULL) { @@ -254,14 +254,14 @@ void EnKanban_Update(Actor* thisx, GlobalContext* globalCtx) { u8 i; if (hitItem->toucher.dmgFlags & 0x200) { - this->cutType = sCutTypes[player->swordAnimation]; + this->cutType = sCutTypes[player->meleeWeaponAnimation]; } else if (hitItem->toucher.dmgFlags & 0x10) { this->invincibilityTimer = 0; this->cutType = this->unk_19A + 3; this->unk_19A = 1 - this->unk_19A; if (this->unk_199 == 0) { this->unk_199++; - Item_DropCollectibleRandom(globalCtx, NULL, &this->actor.focus.pos, 0x60); + Item_DropCollectibleRandom(play, NULL, &this->actor.focus.pos, 0x60); } } else { this->cutType = 0; @@ -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; @@ -393,8 +393,8 @@ void EnKanban_Update(Actor* thisx, GlobalContext* globalCtx) { this->actor.focus.pos.y += 44.0f; Collider_UpdateCylinder(&this->actor, &this->collider); - CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); - CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + CollisionCheck_SetAC(play, &play->colChkCtx, &this->collider.base); + CollisionCheck_SetOC(play, &play->colChkCtx, &this->collider.base); if (this->actor.xzDistToPlayer > 500.0f) { this->actor.flags |= ACTOR_FLAG_1; @@ -433,7 +433,7 @@ void EnKanban_Update(Actor* thisx, GlobalContext* globalCtx) { Actor_MoveWithGravity(&this->actor); } - Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 30.0f, 10.0f, 50.0f, 5); + Actor_UpdateBgCheckInfo(play, &this->actor, 30.0f, 10.0f, 50.0f, 5); tempX = this->actor.world.pos.x; tempY = this->actor.world.pos.y; @@ -442,7 +442,7 @@ void EnKanban_Update(Actor* thisx, GlobalContext* globalCtx) { tempWaterDepth = this->actor.depthInWater; this->actor.world.pos.z += ((this->actor.world.pos.y - this->actor.floorHeight) * -50.0f) / 100.0f; - Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 10.0f, 10.0f, 50.0f, 4); + Actor_UpdateBgCheckInfo(play, &this->actor, 10.0f, 10.0f, 50.0f, 4); func_80954960(this); this->actor.world.pos.x = tempX; @@ -507,16 +507,16 @@ void EnKanban_Update(Actor* thisx, GlobalContext* globalCtx) { Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_BOMB_DROP_WATER); this->bounceX = this->bounceZ = 0; this->actor.world.pos.y += this->actor.depthInWater; - EffectSsGSplash_Spawn(globalCtx, &this->actor.world.pos, NULL, NULL, 0, (this->partCount * 20) + 300); - EffectSsGRipple_Spawn(globalCtx, &this->actor.world.pos, 150, 650, 0); - EffectSsGRipple_Spawn(globalCtx, &this->actor.world.pos, 300, 800, 5); + EffectSsGSplash_Spawn(play, &this->actor.world.pos, NULL, NULL, 0, (this->partCount * 20) + 300); + EffectSsGRipple_Spawn(play, &this->actor.world.pos, 150, 650, 0); + EffectSsGRipple_Spawn(play, &this->actor.world.pos, 300, 800, 5); this->actor.velocity.y = 0.0f; this->actor.gravity = 0.0f; break; } if (onGround) { - temp_v0_18 = func_800C99D4(&globalCtx->colCtx, this->actor.floorPoly, this->actor.floorBgId); + temp_v0_18 = func_800C99D4(&play->colCtx, this->actor.floorPoly, this->actor.floorBgId); if ((temp_v0_18 == 15) || (temp_v0_18 == 14)) { this->unk_197 = 1; @@ -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); @@ -657,7 +657,7 @@ void EnKanban_Update(Actor* thisx, GlobalContext* globalCtx) { for (j = 0; j < dustCount + 3; j++) { pos.x = randPlusMinusPoint5Scaled((this->partCount * 0.5f) + 20.0f) + this->actor.world.pos.x; pos.z = randPlusMinusPoint5Scaled((this->partCount * 0.5f) + 20.0f) + this->actor.world.pos.z; - func_800B0F18(globalCtx, &pos, &velocity, &accel, &primColor, &envColor, 100, 5, + func_800B0F18(play, &pos, &velocity, &accel, &primColor, &envColor, 100, 5, Rand_ZeroFloat(5.0f) + 14.0f); } } @@ -709,7 +709,7 @@ void EnKanban_Update(Actor* thisx, GlobalContext* globalCtx) { Actor_MoveWithGravity(&this->actor); if (this->actor.speedXZ != 0.0f) { - Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 10.0f, 10.0f, 50.0f, 5); + Actor_UpdateBgCheckInfo(play, &this->actor, 10.0f, 10.0f, 50.0f, 5); if (this->actor.bgCheckFlags & 8) { this->actor.speedXZ *= -0.5f; if (this->spinVel.y > 0) { @@ -744,9 +744,9 @@ void EnKanban_Update(Actor* thisx, GlobalContext* globalCtx) { } else { rippleScale = 200; } - EffectSsGRipple_Spawn(globalCtx, &this->actor.world.pos, rippleScale, rippleScale + 500, 0); + EffectSsGRipple_Spawn(play, &this->actor.world.pos, rippleScale, rippleScale + 500, 0); } - } else if ((globalCtx->actorCtx.unk2 != 0) && (this->actor.xyzDistToPlayerSq < SQ(100.0f))) { + } else if ((play->actorCtx.unk2 != 0) && (this->actor.xyzDistToPlayerSq < SQ(100.0f))) { f32 hammerStrength = (100.0f - sqrtf(this->actor.xyzDistToPlayerSq)) * 0.05f; this->actionState = ENKANBAN_AIR; @@ -775,7 +775,7 @@ void EnKanban_Update(Actor* thisx, GlobalContext* globalCtx) { } if (this->bounceX == 0) { - Actor* explosive = globalCtx->actorCtx.actorLists[ACTORCAT_EXPLOSIVES].first; + Actor* explosive = play->actorCtx.actorLists[ACTORCAT_EXPLOSIVES].first; f32 dx; f32 dy; f32 dz; @@ -825,13 +825,13 @@ void EnKanban_Update(Actor* thisx, GlobalContext* globalCtx) { switch (this->ocarinaFlag) { case 0: - if (globalCtx->msgCtx.ocarinaMode == 1) { + if (play->msgCtx.ocarinaMode == 1) { this->ocarinaFlag = 1; } break; case 1: - if ((globalCtx->msgCtx.ocarinaMode == 4) && (globalCtx->msgCtx.unk1202E == 7)) { + if ((play->msgCtx.ocarinaMode == 4) && (play->msgCtx.lastPlayedSong == OCARINA_SONG_HEALING)) { this->actionState = ENKANBAN_REPAIR; this->bounceX = 1; play_sound(NA_SE_SY_TRE_BOX_APPEAR); @@ -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 = @@ -911,42 +911,41 @@ static f32 sCutAngles[] = { #include "overlays/ovl_En_Kanban/ovl_En_Kanban.c" -void EnKanban_Draw(Actor* thisx, GlobalContext* globalCtx) { +void EnKanban_Draw(Actor* thisx, PlayState* play) { EnKanban* this = THIS; f32 zShift; f32 zShift2; s32 i; - Player* player = GET_PLAYER(globalCtx); - u8* shadowTex = GRAPH_ALLOC(globalCtx->state.gfxCtx, ARRAY_COUNT(sShadowTexFlags)); + Player* player = GET_PLAYER(play); + u8* shadowTex = GRAPH_ALLOC(play->state.gfxCtx, ARRAY_COUNT(sShadowTexFlags)); - OPEN_DISPS(globalCtx->state.gfxCtx); + OPEN_DISPS(play->state.gfxCtx); - func_8012C28C(globalCtx->state.gfxCtx); - func_8012C2DC(globalCtx->state.gfxCtx); + func_8012C28C(play->state.gfxCtx); + func_8012C2DC(play->state.gfxCtx); 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); + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); for (i = 0; i < ARRAY_COUNT(sPartFlags); i++) { if (sPartFlags[i] & this->partFlags) { @@ -960,8 +959,8 @@ 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); - gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + Matrix_Translate(0.0f, 0.0f, -100.0f, MTXMODE_APPLY); + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); if (this->partFlags == 0xFFFF) { gSPDisplayList(POLY_OPA_DISP++, gameplay_keep_DL_05AED0); @@ -976,15 +975,14 @@ 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++); gDPSetPrimColor(POLY_XLU_DISP++, 0x00, 0x00, 255, 255, 255, this->cutMarkAlpha); gDPSetEnvColor(POLY_XLU_DISP++, 255, 255, 150, 0); - gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), - G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_XLU_DISP++, object_kanban_DL_001630); } } @@ -995,7 +993,7 @@ void EnKanban_Draw(Actor* thisx, GlobalContext* globalCtx) { f32 shadowAlpha; if (dayTime >= CLOCK_TIME(12, 0)) { - dayTime = 0xFFFF - dayTime; + dayTime = (DAY_LENGTH - 1) - dayTime; } shadowAlpha = (dayTime * 0.00275f) + 10.0f; @@ -1011,22 +1009,22 @@ 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); - gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + 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(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); for (i = 0; i < ARRAY_COUNT(sShadowTexFlags); i++) { if (sShadowTexFlags[i] & this->partFlags) { @@ -1040,5 +1038,5 @@ void EnKanban_Draw(Actor* thisx, GlobalContext* globalCtx) { gSPDisplayList(POLY_XLU_DISP++, gEnKanban_D_80957DE0); } - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->state.gfxCtx); } 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 7a59e702c..5412065f5 100644 --- a/src/overlays/actors/ovl_En_Karebaba/z_en_karebaba.c +++ b/src/overlays/actors/ovl_En_Karebaba/z_en_karebaba.c @@ -5,6 +5,7 @@ */ #include "z_en_karebaba.h" +#include "overlays/effects/ovl_Effect_Ss_Hahen/z_eff_ss_hahen.h" #include "objects/gameplay_keep/gameplay_keep.h" #include "objects/object_dekubaba/object_dekubaba.h" @@ -12,32 +13,32 @@ #define THIS ((EnKarebaba*)thisx) -void EnKarebaba_Init(Actor* thisx, GlobalContext* globalCtx); -void EnKarebaba_Destroy(Actor* thisx, GlobalContext* globalCtx); -void EnKarebaba_Update(Actor* thisx, GlobalContext* globalCtx); -void EnKarebaba_Draw(Actor* thisx, GlobalContext* globalCtx); +void EnKarebaba_Init(Actor* thisx, PlayState* play); +void EnKarebaba_Destroy(Actor* thisx, PlayState* play); +void EnKarebaba_Update(Actor* thisx, PlayState* play); +void EnKarebaba_Draw(Actor* thisx, PlayState* play); void func_808F155C(EnKarebaba* this); -void func_808F15B0(EnKarebaba* this, GlobalContext* globalCtx); +void func_808F15B0(EnKarebaba* this, PlayState* play); void func_808F1648(EnKarebaba* this); -void func_808F169C(EnKarebaba* this, GlobalContext* globalCtx); +void func_808F169C(EnKarebaba* this, PlayState* play); void func_808F16FC(EnKarebaba* this); -void func_808F1778(EnKarebaba* this, GlobalContext* globalCtx); +void func_808F1778(EnKarebaba* this, PlayState* play); void func_808F1878(EnKarebaba* this); -void func_808F190C(EnKarebaba* this, GlobalContext* globalCtx); +void func_808F190C(EnKarebaba* this, PlayState* play); void func_808F1A3C(EnKarebaba* this); -void func_808F1A58(EnKarebaba* this, GlobalContext* globalCtx); +void func_808F1A58(EnKarebaba* this, PlayState* play); void func_808F1BF8(EnKarebaba* this); -void func_808F1C84(EnKarebaba* this, GlobalContext* globalCtx); +void func_808F1C84(EnKarebaba* this, PlayState* play); 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_808F200C(EnKarebaba* this, PlayState* play); +void func_808F20FC(EnKarebaba* this, PlayState* play); +void func_808F21A4(EnKarebaba* this, PlayState* play); void func_808F220C(EnKarebaba* this); -void func_808F228C(EnKarebaba* this, GlobalContext* globalCtx); +void func_808F228C(EnKarebaba* this, PlayState* play); void func_808F238C(EnKarebaba* this); -void func_808F241C(EnKarebaba* this, GlobalContext* globalCtx); -void func_808F254C(EnKarebaba* this, GlobalContext* globalCtx); +void func_808F241C(EnKarebaba* this, PlayState* play); +void func_808F254C(EnKarebaba* this, PlayState* play); const ActorInit En_Karebaba_InitVars = { ACTOR_EN_KAREBABA, @@ -137,17 +138,17 @@ Color_RGBA8 D_808F2E28 = { 0, 0, 0, 0 }; Gfx* D_808F2E2C[] = { object_dekubaba_DL_001330, object_dekubaba_DL_001628, object_dekubaba_DL_001828 }; -void EnKarebaba_Init(Actor* thisx, GlobalContext* globalCtx) { +void EnKarebaba_Init(Actor* thisx, PlayState* play) { EnKarebaba* this = THIS; Actor_ProcessInitChain(&this->actor, sInitChain); ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 22.0f); - SkelAnime_Init(globalCtx, &this->skelAnime, &object_dekubaba_Skel_002A40, &object_dekubaba_Anim_0002B8, - this->jointTable, this->morphTable, 8); + SkelAnime_Init(play, &this->skelAnime, &object_dekubaba_Skel_002A40, &object_dekubaba_Anim_0002B8, this->jointTable, + this->morphTable, 8); - Collider_InitAndSetCylinder(globalCtx, &this->collider2, &this->actor, &sCylinderInit1); + Collider_InitAndSetCylinder(play, &this->collider2, &this->actor, &sCylinderInit1); Collider_UpdateCylinder(&this->actor, &this->collider2); - Collider_InitAndSetCylinder(globalCtx, &this->collider1, &this->actor, &sCylinderInit2); + Collider_InitAndSetCylinder(play, &this->collider1, &this->actor, &sCylinderInit2); Collider_UpdateCylinder(&this->actor, &this->collider1); CollisionCheck_SetInfo(&this->actor.colChkInfo, &sDamageTable, &sColChkInfoInit); @@ -165,14 +166,14 @@ void EnKarebaba_Init(Actor* thisx, GlobalContext* globalCtx) { } } -void EnKarebaba_Destroy(Actor* thisx, GlobalContext* globalCtx) { +void EnKarebaba_Destroy(Actor* thisx, PlayState* play) { EnKarebaba* this = THIS; - Collider_DestroyCylinder(globalCtx, &this->collider2); - Collider_DestroyCylinder(globalCtx, &this->collider1); + Collider_DestroyCylinder(play, &this->collider2); + Collider_DestroyCylinder(play, &this->collider1); } -void func_808F1374(EnKarebaba* this, GlobalContext* globalCtx) { +void func_808F1374(EnKarebaba* this, PlayState* play) { s32 phi_a3; if (this->drawDmgEffType == ACTOR_DRAW_DMGEFF_FROZEN_NO_SFX) { @@ -183,11 +184,11 @@ void func_808F1374(EnKarebaba* this, GlobalContext* globalCtx) { } else { phi_a3 = 4; } - Actor_SpawnIceEffects(globalCtx, &this->actor, this->limbPos, phi_a3, 4, 0.3f, 0.2f); + Actor_SpawnIceEffects(play, &this->actor, this->limbPos, phi_a3, 4, 0.3f, 0.2f); } } -void func_808F13FC(EnKarebaba* this, GlobalContext* globalCtx) { +void func_808F13FC(EnKarebaba* this, PlayState* play) { if (this->actor.colChkInfo.damageEffect == 2) { this->drawDmgEffType = ACTOR_DRAW_DMGEFF_FIRE; this->drawDmgEffScale = 0.75f; @@ -196,7 +197,7 @@ void func_808F13FC(EnKarebaba* this, GlobalContext* globalCtx) { 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, + Actor_Spawn(&play->actorCtx, play, ACTOR_EN_CLEAR_TAG, this->collider2.info.bumper.hitPos.x, this->collider2.info.bumper.hitPos.y, this->collider2.info.bumper.hitPos.z, 0, 0, 0, CLEAR_TAG_SMALL_LIGHT_RAYS); } else if (this->actor.colChkInfo.damageEffect == 3) { @@ -227,7 +228,7 @@ void func_808F155C(EnKarebaba* this) { this->actionFunc = func_808F15B0; } -void func_808F15B0(EnKarebaba* this, GlobalContext* globalCtx) { +void func_808F15B0(EnKarebaba* this, PlayState* play) { f32 sp1C; this->unk_1EE++; @@ -246,7 +247,7 @@ void func_808F1648(EnKarebaba* this) { this->actionFunc = func_808F169C; } -void func_808F169C(EnKarebaba* this, GlobalContext* globalCtx) { +void func_808F169C(EnKarebaba* this, PlayState* play) { if ((this->actor.xzDistToPlayer < 200.0f) && (fabsf(this->actor.playerHeightRel) < 30.0f)) { func_808F16FC(this); } @@ -254,12 +255,12 @@ void func_808F169C(EnKarebaba* this, GlobalContext* globalCtx) { void func_808F16FC(EnKarebaba* this) { Animation_Change(&this->skelAnime, &object_dekubaba_Anim_0002B8, 4.0f, 0.0f, - Animation_GetLastFrame(&object_dekubaba_Anim_0002B8), 0, -3.0f); + Animation_GetLastFrame(&object_dekubaba_Anim_0002B8), ANIMMODE_LOOP, -3.0f); Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_DEKU_WAKEUP); this->actionFunc = func_808F1778; } -void func_808F1778(EnKarebaba* this, GlobalContext* globalCtx) { +void func_808F1778(EnKarebaba* this, PlayState* play) { SkelAnime_Update(&this->skelAnime); if (Math_StepToF(&this->actor.scale.x, 0.01f, 0.0005f) && (this->actor.params == ENKAREBABA_2)) { @@ -275,7 +276,7 @@ void func_808F1778(EnKarebaba* this, GlobalContext* globalCtx) { } this->actor.shape.rot.y += 0x1999; - EffectSsHahen_SpawnBurst(globalCtx, &this->actor.home.pos, 3.0f, 0, 12, 5, 1, -1, 10, NULL); + EffectSsHahen_SpawnBurst(play, &this->actor.home.pos, 3.0f, 0, 12, 5, 1, HAHEN_OBJECT_DEFAULT, 10, NULL); } void func_808F1878(EnKarebaba* this) { @@ -299,8 +300,8 @@ void func_808F1878(EnKarebaba* this) { this->actionFunc = func_808F190C; } -void func_808F190C(EnKarebaba* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); +void func_808F190C(EnKarebaba* this, PlayState* play) { + Player* player = GET_PLAYER(play); SkelAnime_Update(&this->skelAnime); @@ -313,13 +314,13 @@ void func_808F190C(EnKarebaba* this, GlobalContext* globalCtx) { } if (this->collider2.base.acFlags & AC_HIT) { - func_808F13FC(this, globalCtx); + func_808F13FC(this, play); if (this->actor.params == ENKAREBABA_1) { func_808F1BF8(this); } else { func_808F1FAC(this); } - Enemy_StartFinishingBlow(globalCtx, &this->actor); + Enemy_StartFinishingBlow(play, &this->actor); } else if (Math_Vec3f_DistXZ(&this->actor.home.pos, &player->actor.world.pos) > 240.0f) { func_808F220C(this); } else if ((this->unk_1EE == 0) && (this->actor.params == ENKAREBABA_1)) { @@ -332,7 +333,7 @@ void func_808F1A3C(EnKarebaba* this) { this->actionFunc = func_808F1A58; } -void func_808F1A58(EnKarebaba* this, GlobalContext* globalCtx) { +void func_808F1A58(EnKarebaba* this, PlayState* play) { s32 phi_v0; f32 sp28; @@ -362,9 +363,9 @@ void func_808F1A58(EnKarebaba* this, GlobalContext* globalCtx) { 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_808F13FC(this, play); func_808F1BF8(this); - Enemy_StartFinishingBlow(globalCtx, &this->actor); + Enemy_StartFinishingBlow(play, &this->actor); } else if (this->unk_1EE == 0) { func_808F1878(this); } @@ -386,7 +387,7 @@ void func_808F1BF8(EnKarebaba* this) { this->actionFunc = func_808F1C84; } -void func_808F1C84(EnKarebaba* this, GlobalContext* globalCtx) { +void func_808F1C84(EnKarebaba* this, PlayState* play) { s32 i; Vec3f sp78; f32 temp_f20; @@ -400,14 +401,14 @@ void func_808F1C84(EnKarebaba* this, GlobalContext* globalCtx) { 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); + func_808F1374(this, play); } } 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); + EffectSsHahen_SpawnBurst(play, &this->actor.world.pos, 3.0f, 0, 12, 5, 1, HAHEN_OBJECT_DEFAULT, 10, NULL); if ((this->actor.scale.x > 0.005f) && ((this->actor.bgCheckFlags & 2) || (this->actor.bgCheckFlags & 8))) { this->actor.scale.z = 0.0f; @@ -415,7 +416,8 @@ void func_808F1C84(EnKarebaba* this, GlobalContext* globalCtx) { 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); + EffectSsHahen_SpawnBurst(play, &this->actor.world.pos, 3.0f, 0, 12, 5, 15, HAHEN_OBJECT_DEFAULT, 10, + NULL); } if (this->actor.bgCheckFlags & 2) { @@ -430,14 +432,14 @@ void func_808F1C84(EnKarebaba* this, GlobalContext* globalCtx) { 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); + func_800B1210(play, &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); + func_800B1210(play, &this->actor.home.pos, &gZeroVec3f, &gZeroVec3f, 500, 100); + func_808F20FC(this, play); } } } @@ -452,18 +454,18 @@ void func_808F1FAC(EnKarebaba* this) { this->actionFunc = func_808F200C; } -void func_808F200C(EnKarebaba* this, GlobalContext* globalCtx) { +void func_808F200C(EnKarebaba* this, PlayState* play) { if (this->drawDmgEffType == ACTOR_DRAW_DMGEFF_FROZEN_NO_SFX) { this->unk_1EE--; if (this->unk_1EE == 0) { - func_808F1374(this, globalCtx); + func_808F1374(this, play); } } else { if (Math_StepToF(&this->actor.scale.x, 0.0f, 0.0005f)) { - Item_DropCollectible(globalCtx, &this->actor.world.pos, ITEM00_NUTS_1); + Item_DropCollectible(play, &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); + EffectSsHahen_SpawnBurst(play, &this->actor.world.pos, 3.0f, 0, 12, 5, 1, HAHEN_OBJECT_DEFAULT, 10, NULL); Math_StepToF(&this->actor.world.pos.y, this->actor.home.pos.y, 1.0f); } this->actor.scale.y = this->actor.scale.x; @@ -471,40 +473,40 @@ void func_808F200C(EnKarebaba* this, GlobalContext* globalCtx) { } } -void func_808F20FC(EnKarebaba* this, GlobalContext* globalCtx) { +void func_808F20FC(EnKarebaba* this, PlayState* play) { Actor_SetScale(&this->actor, 0.03f); this->actor.shape.rot.x -= 0x4000; this->actor.shape.yOffset = 1000.0f; this->actor.gravity = 0.0f; this->actor.velocity.y = 0.0f; this->actor.shape.shadowScale = 3.0f; - func_800BC154(globalCtx, &globalCtx->actorCtx, &this->actor, 8); + func_800BC154(play, &play->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) { +void func_808F21A4(EnKarebaba* this, PlayState* play) { if (this->unk_1EE != 0) { this->unk_1EE--; } - if (Actor_HasParent(&this->actor, globalCtx) || (this->unk_1EE == 0)) { + if (Actor_HasParent(&this->actor, play) || (this->unk_1EE == 0)) { func_808F238C(this); } else { - Actor_PickUpNearby(&this->actor, globalCtx, GI_STICKS_1); + Actor_PickUpNearby(&this->actor, play, GI_STICKS_1); } } void func_808F220C(EnKarebaba* this) { Animation_Change(&this->skelAnime, &object_dekubaba_Anim_0002B8, -3.0f, - Animation_GetLastFrame(&object_dekubaba_Anim_0002B8), 0.0f, 2, -3.0f); + Animation_GetLastFrame(&object_dekubaba_Anim_0002B8), 0.0f, ANIMMODE_ONCE, -3.0f); func_808F152C(this); this->actionFunc = func_808F228C; } -void func_808F228C(EnKarebaba* this, GlobalContext* globalCtx) { +void func_808F228C(EnKarebaba* this, PlayState* play) { SkelAnime_Update(&this->skelAnime); if (Math_StepToF(&this->actor.scale.x, 0.005f, 0.0005f) && (this->actor.params == ENKAREBABA_2)) { @@ -520,11 +522,11 @@ void func_808F228C(EnKarebaba* this, GlobalContext* globalCtx) { } this->actor.shape.rot.y += 0x1999; - EffectSsHahen_SpawnBurst(globalCtx, &this->actor.home.pos, 3.0f, 0, 12, 5, 1, -1, 10, NULL); + EffectSsHahen_SpawnBurst(play, &this->actor.home.pos, 3.0f, 0, 12, 5, 1, HAHEN_OBJECT_DEFAULT, 10, NULL); } void func_808F238C(EnKarebaba* this) { - Animation_Change(&this->skelAnime, &object_dekubaba_Anim_0002B8, 0.0f, 0.0f, 0.0f, 2, 0.0f); + Animation_Change(&this->skelAnime, &object_dekubaba_Anim_0002B8, 0.0f, 0.0f, 0.0f, ANIMMODE_ONCE, 0.0f); func_808F152C(this); this->actor.shape.rot.x = -0x4000; this->unk_1EE = 200; @@ -535,7 +537,7 @@ void func_808F238C(EnKarebaba* this) { this->actionFunc = func_808F254C; } -void func_808F241C(EnKarebaba* this, GlobalContext* globalCtx) { +void func_808F241C(EnKarebaba* this, PlayState* play) { f32 sp1C; this->unk_1EE++; @@ -547,7 +549,7 @@ void func_808F241C(EnKarebaba* this, GlobalContext* globalCtx) { 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_800BC154(play, &play->actorCtx, &this->actor, 5); } func_808F1648(this); } @@ -561,7 +563,7 @@ void func_808F24F8(EnKarebaba* this) { this->actionFunc = func_808F241C; } -void func_808F254C(EnKarebaba* this, GlobalContext* globalCtx) { +void func_808F254C(EnKarebaba* this, PlayState* play) { SkelAnime_Update(&this->skelAnime); if (this->unk_1EE != 0) { @@ -573,12 +575,12 @@ void func_808F254C(EnKarebaba* this, GlobalContext* globalCtx) { } } -void EnKarebaba_Update(Actor* thisx, GlobalContext* globalCtx2) { - GlobalContext* globalCtx = globalCtx2; +void EnKarebaba_Update(Actor* thisx, PlayState* play2) { + PlayState* play = play2; EnKarebaba* this = THIS; f32 max; - this->actionFunc(this, globalCtx); + this->actionFunc(this, play); if (this->drawDmgEffAlpha > 0.0f) { if (this->drawDmgEffType != ACTOR_DRAW_DMGEFF_FROZEN_NO_SFX) { @@ -597,9 +599,9 @@ void EnKarebaba_Update(Actor* thisx, GlobalContext* globalCtx2) { 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); + Actor_UpdateBgCheckInfo(play, &this->actor, 10.0f, 15.0f, 10.0f, 5); } else { - Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 0.0f, 0.0f, 0.0f, 4); + Actor_UpdateBgCheckInfo(play, &this->actor, 0.0f, 0.0f, 0.0f, 4); if (this->unk_22C == 0) { this->unk_22C = this->actor.floorPoly; } @@ -608,11 +610,11 @@ void EnKarebaba_Update(Actor* thisx, GlobalContext* globalCtx2) { 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_SetAT(play, &play->colChkCtx, &this->collider1.base); + CollisionCheck_SetAC(play, &play->colChkCtx, &this->collider2.base); } - CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider1.base); + CollisionCheck_SetOC(play, &play->colChkCtx, &this->collider1.base); Actor_SetFocus(&this->actor, (this->actor.scale.x * 10.0f) / 0.01f); max = this->actor.home.pos.y + 40.0f; @@ -623,50 +625,48 @@ void EnKarebaba_Update(Actor* thisx, GlobalContext* globalCtx2) { } } -void func_808F280C(EnKarebaba* this, GlobalContext* globalCtx) { +void func_808F280C(EnKarebaba* this, PlayState* play) { MtxF sp40; - OPEN_DISPS(globalCtx->state.gfxCtx); + OPEN_DISPS(play->state.gfxCtx); - func_8012C448(globalCtx->state.gfxCtx); + func_8012C448(play->state.gfxCtx); gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 0, 0, 0, 255); func_800C0094(this->unk_22C, this->actor.home.pos.x, this->actor.home.pos.y, this->actor.home.pos.z, &sp40); - Matrix_InsertMatrix(&sp40, MTXMODE_NEW); + Matrix_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); + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_XLU_DISP++, gCircleShadowDL); - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->state.gfxCtx); } -void EnKarebaba_Draw(Actor* thisx, GlobalContext* globalCtx) { +void EnKarebaba_Draw(Actor* thisx, PlayState* play) { EnKarebaba* this = THIS; s32 i; s32 sp94; s16 limbCount; f32 sp8C = 0.01f; - OPEN_DISPS(globalCtx->state.gfxCtx); + OPEN_DISPS(play->state.gfxCtx); - func_8012C28C(globalCtx->state.gfxCtx); + func_8012C28C(play->state.gfxCtx); Math_Vec3f_Copy(this->limbPos, &this->actor.world.pos); if (this->actionFunc == func_808F21A4) { if ((this->unk_1EE > 40) || (this->unk_1EE & 1)) { - Matrix_InsertTranslation(0.0f, 0.0f, 200.0f, MTXMODE_APPLY); + 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); + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_OPA_DISP++, object_dekubaba_DL_003070); } } else if (this->actionFunc != func_808F254C) { - func_800AE2A0(globalCtx, &D_808F2E28, 1, 2); - SkelAnime_DrawOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, NULL, NULL, NULL); - Matrix_InsertTranslation(this->actor.world.pos.x, this->actor.world.pos.y, this->actor.world.pos.z, - MTXMODE_NEW); + func_800AE2A0(play, &D_808F2E28, 1, 2); + SkelAnime_DrawOpa(play, this->skelAnime.skeleton, this->skelAnime.jointTable, NULL, NULL, NULL); + Matrix_Translate(this->actor.world.pos.x, this->actor.world.pos.y, this->actor.world.pos.z, MTXMODE_NEW); if ((this->actionFunc == func_808F241C) || (this->actionFunc == func_808F200C) || (this->actionFunc == func_808F15B0)) { @@ -674,7 +674,7 @@ void EnKarebaba_Draw(Actor* thisx, GlobalContext* globalCtx) { } Matrix_Scale(sp8C, sp8C, sp8C, MTXMODE_APPLY); - Matrix_InsertRotation(this->actor.shape.rot.x, this->actor.shape.rot.y, 0, 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; @@ -685,44 +685,43 @@ void EnKarebaba_Draw(Actor* thisx, GlobalContext* globalCtx) { } for (i = 0; i < sp94; i++) { - Matrix_InsertTranslation(0.0f, 0.0f, -2000.0f, MTXMODE_APPLY); + 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); + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_OPA_DISP++, D_808F2E2C[i]); - Matrix_GetStateTranslation(&this->limbPos[1 + i]); + Matrix_MultZero(&this->limbPos[1 + i]); if ((i == 0) && (this->actionFunc == func_808F1C84)) { - Matrix_GetStateTranslation(&this->actor.focus.pos); + Matrix_MultZero(&this->actor.focus.pos); } } - func_800AE5A0(globalCtx); + func_800AE5A0(play); } - func_800AE2A0(globalCtx, &D_808F2E28, 1, 2); - Matrix_InsertTranslation(this->actor.home.pos.x, this->actor.home.pos.y, this->actor.home.pos.z, MTXMODE_NEW); + func_800AE2A0(play, &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_RotateY(this->actor.home.rot.y, 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); + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_OPA_DISP++, object_dekubaba_DL_0010F0); if (this->actionFunc == func_808F1C84) { - Matrix_InsertRotation(-0x4000, this->actor.shape.rot.y - this->actor.home.rot.y, 0, MTXMODE_APPLY); + 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); + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_OPA_DISP++, object_dekubaba_DL_001828); - Matrix_GetStateTranslation(&this->limbPos[3]); + Matrix_MultZero(&this->limbPos[3]); } - func_800AE5A0(globalCtx); + func_800AE5A0(play); if (this->actor.params == ENKAREBABA_2) { limbCount = 1; @@ -730,12 +729,12 @@ void EnKarebaba_Draw(Actor* thisx, GlobalContext* globalCtx) { limbCount = ARRAY_COUNT(this->limbPos); } - Actor_DrawDamageEffects(globalCtx, &this->actor, this->limbPos, limbCount, this->drawDmgEffScale, + Actor_DrawDamageEffects(play, &this->actor, this->limbPos, limbCount, this->drawDmgEffScale, this->drawDmgEffFrozenSteamScale, this->drawDmgEffAlpha, this->drawDmgEffType); if (this->unk_22C != 0) { - func_808F280C(this, globalCtx); + func_808F280C(this, play); } - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->state.gfxCtx); } diff --git a/src/overlays/actors/ovl_En_Karebaba/z_en_karebaba.h b/src/overlays/actors/ovl_En_Karebaba/z_en_karebaba.h index e91e151ae..9d41245e6 100644 --- a/src/overlays/actors/ovl_En_Karebaba/z_en_karebaba.h +++ b/src/overlays/actors/ovl_En_Karebaba/z_en_karebaba.h @@ -5,7 +5,7 @@ struct EnKarebaba; -typedef void (*EnKarebabaActionFunc)(struct EnKarebaba*, GlobalContext*); +typedef void (*EnKarebabaActionFunc)(struct EnKarebaba*, PlayState*); enum { /* 0 */ ENKAREBABA_0, @@ -14,20 +14,20 @@ enum { }; typedef struct EnKarebaba { - /* 0x0000 */ Actor actor; - /* 0x0144 */ SkelAnime skelAnime; - /* 0x0188 */ EnKarebabaActionFunc actionFunc; - /* 0x018C */ Vec3s jointTable[8]; - /* 0x01BC */ Vec3s morphTable[8]; - /* 0x01EC */ u8 drawDmgEffType; - /* 0x01EE */ s16 unk_1EE; - /* 0x01F0 */ f32 drawDmgEffAlpha; - /* 0x01F4 */ f32 drawDmgEffScale; - /* 0x01F8 */ f32 drawDmgEffFrozenSteamScale; - /* 0x01FC */ Vec3f limbPos[4]; - /* 0x022C */ CollisionPoly* unk_22C; - /* 0x0230 */ ColliderCylinder collider1; - /* 0x027C */ ColliderCylinder collider2; + /* 0x000 */ Actor actor; + /* 0x144 */ SkelAnime skelAnime; + /* 0x188 */ EnKarebabaActionFunc actionFunc; + /* 0x18C */ Vec3s jointTable[8]; + /* 0x1BC */ Vec3s morphTable[8]; + /* 0x1EC */ u8 drawDmgEffType; + /* 0x1EE */ s16 unk_1EE; + /* 0x1F0 */ f32 drawDmgEffAlpha; + /* 0x1F4 */ f32 drawDmgEffScale; + /* 0x1F8 */ f32 drawDmgEffFrozenSteamScale; + /* 0x1FC */ Vec3f limbPos[4]; + /* 0x22C */ CollisionPoly* unk_22C; + /* 0x230 */ ColliderCylinder collider1; + /* 0x27C */ ColliderCylinder collider2; } EnKarebaba; // size = 0x2C8 extern const ActorInit En_Karebaba_InitVars; diff --git a/src/overlays/actors/ovl_En_Kbt/z_en_kbt.c b/src/overlays/actors/ovl_En_Kbt/z_en_kbt.c index 9a42980db..ad85d9edb 100644 --- a/src/overlays/actors/ovl_En_Kbt/z_en_kbt.c +++ b/src/overlays/actors/ovl_En_Kbt/z_en_kbt.c @@ -10,17 +10,17 @@ #define THIS ((EnKbt*)thisx) -void EnKbt_Init(Actor* thisx, GlobalContext* globalCtx); -void EnKbt_Destroy(Actor* thisx, GlobalContext* globalCtx); -void EnKbt_Update(Actor* thisx, GlobalContext* globalCtx); -void EnKbt_Draw(Actor* thisx, GlobalContext* globalCtx); +void EnKbt_Init(Actor* thisx, PlayState* play); +void EnKbt_Destroy(Actor* thisx, PlayState* play); +void EnKbt_Update(Actor* thisx, PlayState* play); +void EnKbt_Draw(Actor* thisx, PlayState* play); -s32 func_80B33E64(GlobalContext* globalCtx); -s32 func_80B33E8C(GlobalContext* globalCtx); +s32 func_80B33E64(PlayState* play); +s32 func_80B33E8C(PlayState* play); 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); +Actor* func_80B3403C(PlayState* play); +void func_80B34314(EnKbt* this, PlayState* play); +void func_80B34598(EnKbt* this, PlayState* play); const ActorInit En_Kbt_InitVars = { ACTOR_EN_KBT, @@ -34,11 +34,11 @@ const ActorInit En_Kbt_InitVars = { (ActorFunc)EnKbt_Draw, }; -void EnKbt_Init(Actor* thisx, GlobalContext* globalCtx) { +void EnKbt_Init(Actor* thisx, PlayState* play) { EnKbt* this = THIS; Actor_SetScale(&this->actor, 0.01f); - SkelAnime_InitFlex(globalCtx, &this->skelAnime, &object_kbt_Skel_00DEE8, &object_kbt_Anim_004274, this->jointTable, + SkelAnime_InitFlex(play, &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; @@ -46,13 +46,13 @@ void EnKbt_Init(Actor* thisx, GlobalContext* globalCtx) { this->unk_27F = 0; this->unk_280 = 13; this->unk_282 = 13; - this->unk_278 = func_80B3403C(globalCtx); + this->unk_278 = func_80B3403C(play); this->unk_284 = 0; this->actor.textId = 0; - if (func_80B33E64(globalCtx)) { + if (func_80B33E64(play)) { func_80B33EF0(this, 6); this->unk_282 = 11; - if (func_80B33E8C(globalCtx)) { + if (func_80B33E8C(play)) { this->actor.textId = 0xC50; } else { this->actor.textId = 0xC4E; @@ -67,16 +67,16 @@ void EnKbt_Init(Actor* thisx, GlobalContext* globalCtx) { this->actor.flags &= ~ACTOR_FLAG_1; } -void EnKbt_Destroy(Actor* thisx, GlobalContext* globalCtx) { +void EnKbt_Destroy(Actor* thisx, PlayState* play) { } -s32 func_80B33E64(GlobalContext* globalCtx) { - return gSaveContext.save.permanentSceneFlags[globalCtx->sceneNum].unk_14 & 1; +s32 func_80B33E64(PlayState* play) { + return gSaveContext.save.permanentSceneFlags[play->sceneNum].unk_14 & 1; } -s32 func_80B33E8C(GlobalContext* globalCtx) { +s32 func_80B33E8C(PlayState* play) { if ((CURRENT_DAY == 3) || - ((CURRENT_DAY == 2) && (gSaveContext.save.permanentSceneFlags[globalCtx->sceneNum].unk_14 & 2))) { + ((CURRENT_DAY == 2) && (gSaveContext.save.permanentSceneFlags[play->sceneNum].unk_14 & 2))) { return true; } return false; @@ -106,8 +106,8 @@ void func_80B33EF0(EnKbt* this, s16 arg1) { } } -Actor* func_80B3403C(GlobalContext* globalCtx) { - Actor* npc = globalCtx->actorCtx.actorLists[ACTORCAT_NPC].first; +Actor* func_80B3403C(PlayState* play) { + Actor* npc = play->actorCtx.actorLists[ACTORCAT_NPC].first; while (npc != NULL) { if (npc->id == ACTOR_EN_KGY) { @@ -234,14 +234,14 @@ void func_80B3415C(EnKbt* this) { } } -void func_80B34314(EnKbt* this, GlobalContext* globalCtx) { +void func_80B34314(EnKbt* this, PlayState* play) { s32 playerForm; func_80B34078(this); - if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { + if (Actor_ProcessTalkRequest(&this->actor, &play->state)) { this->actionFunc = func_80B34598; - Actor_ChangeFocus(&this->actor, globalCtx, this->unk_278); + Actor_ChangeFocus(&this->actor, play, this->unk_278); this->unk_278->textId = this->actor.textId; this->unk_27C &= ~4; if (this->actor.textId == 0xC4E) { @@ -270,13 +270,13 @@ void func_80B34314(EnKbt* this, GlobalContext* globalCtx) { this->actor.textId = 0xC37; } } else if (gSaveContext.save.playerForm == PLAYER_FORM_HUMAN) { - if (func_80B33E8C(globalCtx)) { + if (func_80B33E8C(play)) { this->actor.textId = 0xC50; } else { this->actor.textId = 0xC4E; } } - func_800B8614(&this->actor, globalCtx, 260.0f); + func_800B8614(&this->actor, play, 260.0f); } } func_80B3415C(this); @@ -289,7 +289,7 @@ void func_80B34574(EnKbt* this) { this->actionFunc = func_80B34314; } -void func_80B34598(EnKbt* this, GlobalContext* globalCtx) { +void func_80B34598(EnKbt* this, PlayState* play) { func_80B34078(this); switch (this->actor.textId) { @@ -333,7 +333,7 @@ void func_80B34598(EnKbt* this, GlobalContext* globalCtx) { this->unk_27E = 4; this->unk_27F = 0; this->unk_282 = 11; - if (func_80B33E8C(globalCtx)) { + if (func_80B33E8C(play)) { this->actor.textId = 0xC50; } else if (this->unk_27C & 0x10) { this->actor.textId = 0xC4F; @@ -516,13 +516,13 @@ void func_80B34598(EnKbt* this, GlobalContext* globalCtx) { func_80B3415C(this); } -void EnKbt_Update(Actor* thisx, GlobalContext* globalCtx) { +void EnKbt_Update(Actor* thisx, PlayState* play) { EnKbt* this = THIS; - this->actionFunc(this, globalCtx); + this->actionFunc(this, play); } -s32 EnKbt_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, Actor* thisx) { +s32 EnKbt_OverrideLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, Actor* thisx) { EnKbt* this = THIS; if (!(this->unk_27C & 1) && (limbIndex == OBJECT_KBT_LIMB_0E)) { @@ -533,11 +533,11 @@ s32 EnKbt_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f D_80B34B84 = { 500.0f, 500.0f, 0.0f }; -void EnKbt_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx) { +void EnKbt_PostLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx) { EnKbt* this = THIS; if (limbIndex == OBJECT_KBT_LIMB_09) { - Matrix_MultiplyVector3fByState(&D_80B34B84, &this->actor.focus.pos); + Matrix_MultVec3f(&D_80B34B84, &this->actor.focus.pos); } } @@ -550,14 +550,14 @@ 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) { +void EnKbt_Draw(Actor* thisx, PlayState* play) { EnKbt* this = THIS; Gfx* gfx; TexturePtr tex; - OPEN_DISPS(globalCtx->state.gfxCtx); + OPEN_DISPS(play->state.gfxCtx); - func_8012C28C(globalCtx->state.gfxCtx); + func_8012C28C(play->state.gfxCtx); gfx = POLY_OPA_DISP; @@ -569,8 +569,8 @@ void EnKbt_Draw(Actor* thisx, GlobalContext* globalCtx) { POLY_OPA_DISP = &gfx[2]; - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->state.gfxCtx); - SkelAnime_DrawFlexOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, + SkelAnime_DrawFlexOpa(play, 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 7556e3f5c..dbbb96e76 100644 --- a/src/overlays/actors/ovl_En_Kbt/z_en_kbt.h +++ b/src/overlays/actors/ovl_En_Kbt/z_en_kbt.h @@ -6,21 +6,21 @@ struct EnKbt; -typedef void (*EnKbtActionFunc)(struct EnKbt*, GlobalContext*); +typedef void (*EnKbtActionFunc)(struct EnKbt*, PlayState*); typedef struct EnKbt { - /* 0x0000 */ Actor actor; - /* 0x0144 */ SkelAnime skelAnime; - /* 0x0188 */ Vec3s jointTable[OBJECT_KBT_LIMB_MAX]; - /* 0x0200 */ Vec3s morphTable[OBJECT_KBT_LIMB_MAX]; - /* 0x0278 */ Actor* unk_278; - /* 0x027C */ u16 unk_27C; - /* 0x027E */ u8 unk_27E; - /* 0x027F */ u8 unk_27F; - /* 0x0280 */ s16 unk_280; - /* 0x0282 */ s16 unk_282; - /* 0x0284 */ s16 unk_284; - /* 0x0288 */ EnKbtActionFunc actionFunc; + /* 0x000 */ Actor actor; + /* 0x144 */ SkelAnime skelAnime; + /* 0x188 */ Vec3s jointTable[OBJECT_KBT_LIMB_MAX]; + /* 0x200 */ Vec3s morphTable[OBJECT_KBT_LIMB_MAX]; + /* 0x278 */ Actor* unk_278; + /* 0x27C */ u16 unk_27C; + /* 0x27E */ u8 unk_27E; + /* 0x27F */ u8 unk_27F; + /* 0x280 */ s16 unk_280; + /* 0x282 */ s16 unk_282; + /* 0x284 */ s16 unk_284; + /* 0x288 */ EnKbtActionFunc actionFunc; } EnKbt; // size = 0x28C extern const ActorInit En_Kbt_InitVars; diff --git a/src/overlays/actors/ovl_En_Kendo_Js/z_en_kendo_js.c b/src/overlays/actors/ovl_En_Kendo_Js/z_en_kendo_js.c index 92053374a..d90bdf93d 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 @@ -12,30 +12,30 @@ #define THIS ((EnKendoJs*)thisx) -void EnKendoJs_Init(Actor* thisx, GlobalContext* globalCtx); -void EnKendoJs_Destroy(Actor* thisx, GlobalContext* globalCtx); -void EnKendoJs_Update(Actor* thisx, GlobalContext* globalCtx); -void EnKendoJs_Draw(Actor* thisx, GlobalContext* globalCtx); +void EnKendoJs_Init(Actor* thisx, PlayState* play); +void EnKendoJs_Destroy(Actor* thisx, PlayState* play); +void EnKendoJs_Update(Actor* thisx, PlayState* play); +void EnKendoJs_Draw(Actor* thisx, PlayState* play); void func_80B26538(EnKendoJs* this); -void func_80B2654C(EnKendoJs* this, GlobalContext* globalCtx); +void func_80B2654C(EnKendoJs* this, PlayState* play); void func_80B26AE8(EnKendoJs* this); -void func_80B26AFC(EnKendoJs* this, GlobalContext* globalCtx); +void func_80B26AFC(EnKendoJs* this, PlayState* play); void func_80B2701C(EnKendoJs* this); -void func_80B27030(EnKendoJs* this, GlobalContext* globalCtx); +void func_80B27030(EnKendoJs* this, PlayState* play); void func_80B2714C(EnKendoJs* this); -void func_80B27188(EnKendoJs* this, GlobalContext* globalCtx); +void func_80B27188(EnKendoJs* this, PlayState* play); void func_80B273D0(EnKendoJs* this); -void func_80B2740C(EnKendoJs* this, GlobalContext* globalCtx); -void func_80B274BC(EnKendoJs* this, GlobalContext* globalCtx); +void func_80B2740C(EnKendoJs* this, PlayState* play); +void func_80B274BC(EnKendoJs* this, PlayState* play); void func_80B276C4(EnKendoJs* this); -void func_80B276D8(EnKendoJs* this, GlobalContext* globalCtx); +void func_80B276D8(EnKendoJs* this, PlayState* play); 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); +void func_80B27774(EnKendoJs* this, PlayState* play); +void func_80B2783C(EnKendoJs* this, PlayState* play); +s32 func_80B278C4(PlayState* play, Vec3f arg1); +void func_80B279F0(EnKendoJs* this, PlayState* play, s32 arg2); +void func_80B27A90(EnKendoJs* this, PlayState* play); const ActorInit En_Kendo_Js_InitVars = { ACTOR_EN_KENDO_JS, @@ -71,10 +71,12 @@ static ColliderCylinderInit sCylinderInit = { static CollisionCheckInfoInit2 sColChkInfoInit = { 0, 0, 0, 0, MASS_IMMOVABLE }; -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 }, +static AnimationInfo sAnimationInfo[] = { + { &object_js_Anim_000C7C, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, -8.0f }, + { &object_js_Anim_000F4C, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, -8.0f }, + { &object_js_Anim_00016C, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, -8.0f }, + { &object_js_Anim_0003DC, 1.0f, 0.0f, 0.0f, ANIMMODE_ONCE, -8.0f }, + { &object_js_Anim_000AD4, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, -8.0f }, }; s16 D_80B27CE0[][3] = { @@ -96,37 +98,37 @@ s16 D_80B27D10[] = { 0x271B, 0x271D, 0x271F, 0x2721, 0x2723, 0x2725, 0x2727, }; -void EnKendoJs_Init(Actor* thisx, GlobalContext* globalCtx) { +void EnKendoJs_Init(Actor* thisx, PlayState* play) { s32 pad; EnKendoJs* this = THIS; ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 36.0f); - Collider_InitCylinder(globalCtx, &this->collider); - Collider_SetCylinder(globalCtx, &this->collider, &this->actor, &sCylinderInit); + Collider_InitCylinder(play, &this->collider); + Collider_SetCylinder(play, &this->collider, &this->actor, &sCylinderInit); CollisionCheck_SetInfo2(&this->actor.colChkInfo, DamageTable_Get(0x16), &sColChkInfoInit); - SkelAnime_InitFlex(globalCtx, &this->skelAnime, &object_js_Skel_006990, &object_js_Anim_000F4C, this->jointTable, + SkelAnime_InitFlex(play, &this->skelAnime, &object_js_Skel_006990, &object_js_Anim_000F4C, this->jointTable, this->morphTable, 13); 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_Spawn(&play->actorCtx, play, 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); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, 4); } } else if (ENKENDOJS_GET_FF(&this->actor) == ENKENDOJS_FF_1) { Actor_MarkForDeath(&this->actor); } - Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 0.0f, 0.0f, 0.0f, 4); + Actor_UpdateBgCheckInfo(play, &this->actor, 0.0f, 0.0f, 0.0f, 4); if (ENKENDOJS_GET_FF(&this->actor) != ENKENDOJS_FF_1) { - Path* path = &globalCtx->setupPathList[ENKENDOJS_GET_FF00(&this->actor)]; + Path* path = &play->setupPathList[ENKENDOJS_GET_FF00(&this->actor)]; this->unk_274 = Lib_SegmentedToVirtual(path->points); } @@ -142,10 +144,10 @@ void EnKendoJs_Init(Actor* thisx, GlobalContext* globalCtx) { func_80B26538(this); } -void EnKendoJs_Destroy(Actor* thisx, GlobalContext* globalCtx) { +void EnKendoJs_Destroy(Actor* thisx, PlayState* play) { EnKendoJs* this = THIS; - Collider_DestroyCylinder(globalCtx, &this->collider); + Collider_DestroyCylinder(play, &this->collider); gSaveContext.save.weekEventReg[82] &= (u8)~8; } @@ -153,11 +155,11 @@ void func_80B26538(EnKendoJs* this) { this->actionFunc = func_80B2654C; } -void func_80B2654C(EnKendoJs* this, GlobalContext* globalCtx) { +void func_80B2654C(EnKendoJs* this, PlayState* play) { s32 phi_v0; s32 sp30; - if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state) != 0) { + if (Actor_ProcessTalkRequest(&this->actor, &play->state) != 0) { if (CURRENT_DAY != 0) { sp30 = CURRENT_DAY - 1; } else { @@ -165,7 +167,7 @@ void func_80B2654C(EnKendoJs* this, GlobalContext* globalCtx) { } if (ENKENDOJS_GET_FF(&this->actor) == ENKENDOJS_FF_1) { - Message_StartTextbox(globalCtx, 0x273C, &this->actor); + Message_StartTextbox(play, 0x273C, &this->actor); this->unk_288 = 0x273C; } else if (gSaveContext.save.playerForm != PLAYER_FORM_HUMAN) { switch (gSaveContext.save.playerForm) { @@ -186,14 +188,14 @@ void func_80B2654C(EnKendoJs* this, GlobalContext* globalCtx) { break; } - Message_StartTextbox(globalCtx, D_80B27CE0[phi_v0][sp30], &this->actor); + Message_StartTextbox(play, 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; + } else if ((Player_GetMask(play) != PLAYER_MASK_NONE) && (Player_GetMask(play) < PLAYER_MASK_GIANT)) { + u16 sp2E = Player_GetMask(play) + 0x273C; if (0) {} - Message_StartTextbox(globalCtx, sp2E, &this->actor); + Message_StartTextbox(play, sp2E, &this->actor); this->unk_288 = sp2E; } else { if (this->unk_28A == 0) { @@ -202,67 +204,67 @@ void func_80B2654C(EnKendoJs* this, GlobalContext* globalCtx) { } else { phi_v0 = 1; } - Message_StartTextbox(globalCtx, D_80B27CF4[phi_v0][sp30], &this->actor); + Message_StartTextbox(play, D_80B27CF4[phi_v0][sp30], &this->actor); this->unk_288 = D_80B27CF4[phi_v0][sp30]; } func_80B26AE8(this); } else { - func_800B8614(&this->actor, globalCtx, 100.0f); + func_800B8614(&this->actor, play, 100.0f); } } -void func_80B26758(EnKendoJs* this, GlobalContext* globalCtx) { - if (Message_ShouldAdvance(globalCtx) && (this->unk_288 == 0x2716)) { - switch (globalCtx->msgCtx.choiceIndex) { +void func_80B26758(EnKendoJs* this, PlayState* play) { + if (Message_ShouldAdvance(play) && (this->unk_288 == 0x2716)) { + switch (play->msgCtx.choiceIndex) { case 0: - if (GET_CUR_EQUIP_VALUE(EQUIP_SWORD) == EQUIP_SWORD) { + if (GET_CUR_EQUIP_VALUE(EQUIP_TYPE_SWORD) == EQUIP_VALUE_SWORD_NONE) { play_sound(NA_SE_SY_ERROR); - Message_StartTextbox(globalCtx, 0x272C, &this->actor); + Message_StartTextbox(play, 0x272C, &this->actor); this->unk_288 = 0x272C; - Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 2); - } else if (gSaveContext.save.playerData.rupees < globalCtx->msgCtx.unk1206C) { + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, 2); + } else if (gSaveContext.save.playerData.rupees < play->msgCtx.unk1206C) { play_sound(NA_SE_SY_ERROR); - Message_StartTextbox(globalCtx, 0x2718, &this->actor); + Message_StartTextbox(play, 0x2718, &this->actor); this->unk_288 = 0x2718; } else { func_8019F208(); - func_801159EC(-globalCtx->msgCtx.unk1206C); - Message_StartTextbox(globalCtx, 0x2719, &this->actor); + Rupees_ChangeBy(-play->msgCtx.unk1206C); + Message_StartTextbox(play, 0x2719, &this->actor); this->unk_288 = 0x2719; } break; case 1: - if (GET_CUR_EQUIP_VALUE(EQUIP_SWORD) == EQUIP_SWORD) { + if (GET_CUR_EQUIP_VALUE(EQUIP_TYPE_SWORD) == EQUIP_VALUE_SWORD_NONE) { play_sound(NA_SE_SY_ERROR); - Message_StartTextbox(globalCtx, 0x272C, &this->actor); + Message_StartTextbox(play, 0x272C, &this->actor); this->unk_288 = 0x272C; - Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 2); - } else if (gSaveContext.save.playerData.rupees < globalCtx->msgCtx.unk12070) { + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, 2); + } else if (gSaveContext.save.playerData.rupees < play->msgCtx.unk12070) { play_sound(NA_SE_SY_ERROR); - Message_StartTextbox(globalCtx, 0x2718, &this->actor); + Message_StartTextbox(play, 0x2718, &this->actor); this->unk_288 = 0x2718; } else { func_8019F208(); - func_801159EC(-globalCtx->msgCtx.unk12070); - Message_StartTextbox(globalCtx, 0x273A, &this->actor); + Rupees_ChangeBy(-play->msgCtx.unk12070); + Message_StartTextbox(play, 0x273A, &this->actor); this->unk_288 = 0x273A; } break; case 2: func_8019F230(); - Message_StartTextbox(globalCtx, 0x2717, &this->actor); + Message_StartTextbox(play, 0x2717, &this->actor); this->unk_288 = 0x2717; } } } -void func_80B269A4(EnKendoJs* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); +void func_80B269A4(EnKendoJs* this, PlayState* play) { + Player* player = GET_PLAYER(play); - if (!Message_ShouldAdvance(globalCtx)) { + if (!Message_ShouldAdvance(play)) { return; } @@ -273,38 +275,38 @@ void func_80B269A4(EnKendoJs* this, GlobalContext* globalCtx) { case 0x2713: case 0x2714: case 0x2715: - Message_StartTextbox(globalCtx, 0x2716, &this->actor); + Message_StartTextbox(play, 0x2716, &this->actor); this->unk_288 = 0x2716; break; case 0x2719: - func_801477B4(globalCtx); + func_801477B4(play); player->stateFlags1 |= 0x20; func_80B2701C(this); break; case 0x271A: - func_801477B4(globalCtx); + func_801477B4(play); func_80B2714C(this); break; case 0x273A: - Message_StartTextbox(globalCtx, 0x273B, &this->actor); + Message_StartTextbox(play, 0x273B, &this->actor); this->unk_288 = 0x273B; break; case 0x273B: - func_801477B4(globalCtx); - func_80112AFC(globalCtx); + func_801477B4(play); + func_80112AFC(play); player->stateFlags1 |= 0x20; func_80B273D0(this); break; case 0x272D: - func_801477B4(globalCtx); + func_801477B4(play); gSaveContext.minigameState = 3; func_80B276C4(this); - func_80B276D8(this, globalCtx); + func_80B276D8(this, play); break; } } @@ -313,22 +315,22 @@ void func_80B26AE8(EnKendoJs* this) { this->actionFunc = func_80B26AFC; } -void func_80B26AFC(EnKendoJs* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); +void func_80B26AFC(EnKendoJs* this, PlayState* play) { + Player* player = GET_PLAYER(play); - switch (Message_GetState(&globalCtx->msgCtx)) { - case 4: - func_80B26758(this, globalCtx); + switch (Message_GetState(&play->msgCtx)) { + case TEXT_STATE_CHOICE: + func_80B26758(this, play); break; - case 5: - func_80B269A4(this, globalCtx); + case TEXT_STATE_5: + func_80B269A4(this, play); break; - case 6: - if (Message_ShouldAdvance(globalCtx)) { + case TEXT_STATE_DONE: + if (Message_ShouldAdvance(play)) { if (this->unk_288 == 0x272C) { - Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 3); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, 3); } if ((this->unk_288 == 0x272E) || (this->unk_288 == 0x272F) || (this->unk_288 == 0x2730)) { @@ -339,24 +341,25 @@ void func_80B26AFC(EnKendoJs* this, GlobalContext* globalCtx) { func_80B26538(this); } - case 0: - case 1: - case 2: - case 3: + case TEXT_STATE_NONE: + case TEXT_STATE_1: + case TEXT_STATE_CLOSING: + case TEXT_STATE_3: break; } } -s32 func_80B26BF8(EnKendoJs* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); +s32 func_80B26BF8(EnKendoJs* this, PlayState* play) { + Player* player = GET_PLAYER(play); switch (this->unk_284) { case 0: - if (func_80122FCC(globalCtx)) { + if (func_80122FCC(play)) { return 0; } - if ((player->swordState != 0) || (player->stateFlags3 & 0x8000000) || (player->stateFlags2 & 0x80000)) { + if ((player->meleeWeaponState != 0) || (player->stateFlags3 & 0x8000000) || + (player->stateFlags2 & 0x80000)) { return 1; } break; @@ -366,24 +369,26 @@ s32 func_80B26BF8(EnKendoJs* this, GlobalContext* globalCtx) { return 0; } - if ((player->swordState != 0) || (player->stateFlags2 & 0x80000)) { + if ((player->meleeWeaponState != 0) || (player->stateFlags2 & 0x80000)) { return 1; } break; case 2: - if (func_80122F9C(globalCtx)) { + if (func_80122F9C(play)) { return 0; } - if ((player->swordState != 0) || (player->stateFlags3 & 0x8000000) || (player->stateFlags2 & 0x80000)) { + if ((player->meleeWeaponState != 0) || (player->stateFlags3 & 0x8000000) || + (player->stateFlags2 & 0x80000)) { return 1; } this->unk_28E = 0; break; case 3: - if ((this->unk_28E == 1) && ((player->swordAnimation == 4) || (player->swordAnimation == 6))) { + if ((this->unk_28E == 1) && ((player->meleeWeaponAnimation == PLAYER_MWA_RIGHT_SLASH_1H) || + (player->meleeWeaponAnimation == PLAYER_MWA_RIGHT_COMBO_1H))) { this->unk_28E = 0; return 0; } @@ -395,7 +400,8 @@ s32 func_80B26BF8(EnKendoJs* this, GlobalContext* globalCtx) { break; case 4: - if ((this->unk_28E == 1) && ((player->swordAnimation == 0) || (player->swordAnimation == 2))) { + if ((this->unk_28E == 1) && ((player->meleeWeaponAnimation == PLAYER_MWA_FORWARD_SLASH_1H) || + (player->meleeWeaponAnimation == PLAYER_MWA_FORWARD_COMBO_1H))) { this->unk_28E = 0; return 0; } @@ -407,7 +413,7 @@ s32 func_80B26BF8(EnKendoJs* this, GlobalContext* globalCtx) { break; case 5: - if ((this->unk_28E == 1) && (player->swordAnimation == 12)) { + if ((this->unk_28E == 1) && (player->meleeWeaponAnimation == PLAYER_MWA_STAB_1H)) { this->unk_28E = 0; return 0; } @@ -419,7 +425,8 @@ s32 func_80B26BF8(EnKendoJs* this, GlobalContext* globalCtx) { break; case 6: - if ((this->unk_28E == 1) && ((player->swordAnimation == 17) || (player->swordAnimation == 20))) { + if ((this->unk_28E == 1) && ((player->meleeWeaponAnimation == PLAYER_MWA_JUMPSLASH_START) || + (player->meleeWeaponAnimation == PLAYER_MWA_JUMPSLASH_FINISH))) { this->unk_28E = 0; return 0; } @@ -433,24 +440,24 @@ s32 func_80B26BF8(EnKendoJs* this, GlobalContext* globalCtx) { return 2; } -void func_80B26EB4(EnKendoJs* this, GlobalContext* globalCtx) { - Message_StartTextbox(globalCtx, D_80B27D00[this->unk_284], &this->actor); +void func_80B26EB4(EnKendoJs* this, PlayState* play) { + Message_StartTextbox(play, 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); +void func_80B26F14(EnKendoJs* this, PlayState* play) { + Message_StartTextbox(play, 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); +s32 func_80B26F6C(EnKendoJs* this, PlayState* play) { + Player* player = GET_PLAYER(play); switch (this->unk_288) { case 0x271D: - if (func_80124190(player)) { - Message_StartTextbox(globalCtx, 0x272A, &this->actor); + if (Player_GetMeleeWeaponHeld(player) != 0) { + Message_StartTextbox(play, 0x272A, &this->actor); this->unk_288 = 0x272A; return true; } @@ -458,7 +465,7 @@ s32 func_80B26F6C(EnKendoJs* this, GlobalContext* globalCtx) { case 0x2721: if (this->unk_292 != 0) { - Message_StartTextbox(globalCtx, 0x272B, &this->actor); + Message_StartTextbox(play, 0x272B, &this->actor); this->unk_288 = 0x272B; return true; } @@ -471,23 +478,23 @@ void func_80B2701C(EnKendoJs* this) { this->actionFunc = func_80B27030; } -void func_80B27030(EnKendoJs* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); +void func_80B27030(EnKendoJs* this, PlayState* play) { + Player* player = GET_PLAYER(play); Vec3f sp20 = this->actor.world.pos; sp20.z += 200.0f; - if (func_80B278C4(globalCtx, sp20)) { + if (func_80B278C4(play, sp20)) { this->actor.flags |= ACTOR_FLAG_10000; - if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { + if (Actor_ProcessTalkRequest(&this->actor, &play->state)) { this->actor.flags &= ~ACTOR_FLAG_10000; player->stateFlags1 &= ~0x20; - func_80B279F0(this, globalCtx, 0); - Message_StartTextbox(globalCtx, 0x271A, &this->actor); + func_80B279F0(this, play, 0); + Message_StartTextbox(play, 0x271A, &this->actor); this->unk_288 = 0x271A; func_80B26AE8(this); } else { - func_800B8614(&this->actor, globalCtx, 800.0f); + func_800B8614(&this->actor, play, 800.0f); } } } @@ -501,18 +508,18 @@ void func_80B2714C(EnKendoJs* this) { this->actionFunc = func_80B27188; } -void func_80B27188(EnKendoJs* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); +void func_80B27188(EnKendoJs* this, PlayState* play) { + Player* player = GET_PLAYER(play); - if ((Message_GetState(&globalCtx->msgCtx) == 5) && Message_ShouldAdvance(globalCtx)) { + if ((Message_GetState(&play->msgCtx) == TEXT_STATE_5) && Message_ShouldAdvance(play)) { if (this->unk_288 == 0x2729) { - func_80B26F14(this, globalCtx); - } else if (!func_80B26F6C(this, globalCtx)) { + func_80B26F14(this, play); + } else if (!func_80B26F6C(this, play)) { if (this->skelAnime.animation == &object_js_Anim_00016C) { - Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 3); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, 3); } this->unk_286 = 2; - func_801477B4(globalCtx); + func_801477B4(play); player->stateFlags1 &= ~0x20; } } else if (this->unk_286 == 2) { @@ -520,21 +527,21 @@ void func_80B27188(EnKendoJs* this, GlobalContext* globalCtx) { } if (this->unk_286 == 1) { - switch (func_80B26BF8(this, globalCtx)) { + switch (func_80B26BF8(this, play)) { case 0: this->unk_286 = 0; Actor_PlaySfxAtPos(&this->actor, NA_SE_SY_TRE_BOX_APPEAR); player->stateFlags1 |= 0x20; - func_80B26EB4(this, globalCtx); + func_80B26EB4(this, play); break; case 1: Actor_PlaySfxAtPos(&this->actor, NA_SE_SY_ERROR); this->unk_286 = 0; player->stateFlags1 |= 0x20; - Message_StartTextbox(globalCtx, 0x2729, &this->actor); + Message_StartTextbox(play, 0x2729, &this->actor); this->unk_288 = 0x2729; - Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 2); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, 2); break; default: @@ -542,7 +549,7 @@ void func_80B27188(EnKendoJs* this, GlobalContext* globalCtx) { this->unk_290++; if (this->unk_290 == 30) { this->unk_290 = 0; - func_80B279F0(this, globalCtx, 0); + func_80B279F0(this, play, 0); } } break; @@ -550,7 +557,7 @@ void func_80B27188(EnKendoJs* this, GlobalContext* globalCtx) { if ((this->skelAnime.animation == &object_js_Anim_0003DC) && Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) { - Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 1); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, 1); } if (this->unk_284 == 7) { @@ -568,29 +575,29 @@ void func_80B273D0(EnKendoJs* this) { this->actionFunc = func_80B2740C; } -void func_80B2740C(EnKendoJs* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); +void func_80B2740C(EnKendoJs* this, PlayState* play) { + Player* player = GET_PLAYER(play); Vec3f sp18 = this->actor.world.pos; sp18.z += 300.0f; - if (func_80B278C4(globalCtx, sp18)) { + if (func_80B278C4(play, sp18)) { this->unk_28C = 0; player->stateFlags1 &= ~0x20; this->actionFunc = func_80B274BC; } } -void func_80B274BC(EnKendoJs* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); +void func_80B274BC(EnKendoJs* this, PlayState* play) { + Player* player = GET_PLAYER(play); if (this->unk_290 >= 140) { if (this->unk_284 == 5) { if (gSaveContext.minigameScore == 30) { - Message_StartTextbox(globalCtx, 0x272D, &this->actor); + Message_StartTextbox(play, 0x272D, &this->actor); this->unk_288 = 0x272D; } else { - Message_StartTextbox(globalCtx, 0x272E, &this->actor); + Message_StartTextbox(play, 0x272E, &this->actor); this->unk_288 = 0x272E; } player->stateFlags1 |= 0x20; @@ -600,46 +607,47 @@ void func_80B274BC(EnKendoJs* this, GlobalContext* globalCtx) { } play_sound(NA_SE_SY_FOUND); - func_80B279F0(this, globalCtx, ((Rand_Next() & 0xFF) % 3) + 1); - func_80B279F0(this, globalCtx, ((Rand_Next() & 0xFF) % 3) + 4); + func_80B279F0(this, play, ((u8)Rand_Next() % 3) + 1); + func_80B279F0(this, play, ((u8)Rand_Next() % 3) + 4); this->unk_290 = 0; this->unk_284++; } else if (this->unk_290 == 120) { - func_80B27A90(this, globalCtx); + func_80B27A90(this, play); 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 ((player->meleeWeaponAnimation == PLAYER_MWA_JUMPSLASH_START) || + (player->meleeWeaponAnimation == PLAYER_MWA_JUMPSLASH_FINISH)) { + play->interfaceCtx.unk_25C = 3; if (gSaveContext.minigameScore >= 27) { player->stateFlags1 |= 0x20; } - } else if (player->swordAnimation == 12) { - globalCtx->interfaceCtx.unk_25C = 2; + } else if (player->meleeWeaponAnimation == PLAYER_MWA_STAB_1H) { + play->interfaceCtx.unk_25C = 2; } else { - globalCtx->interfaceCtx.unk_25C = 1; + play->interfaceCtx.unk_25C = 1; } Actor_PlaySfxAtPos(&this->actor, NA_SE_SY_TRE_BOX_APPEAR); this->unk_28E = 0; } - func_80B2783C(this, globalCtx); + func_80B2783C(this, play); } void func_80B276C4(EnKendoJs* this) { this->actionFunc = func_80B276D8; } -void func_80B276D8(EnKendoJs* this, GlobalContext* globalCtx) { - if (Actor_HasParent(&this->actor, globalCtx)) { +void func_80B276D8(EnKendoJs* this, PlayState* play) { + if (Actor_HasParent(&this->actor, play)) { 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); + Actor_PickUp(&this->actor, play, GI_HEART_PIECE, 800.0f, 100.0f); } else { - Actor_PickUp(&this->actor, globalCtx, GI_RUPEE_RED, 800.0f, 100.0f); + Actor_PickUp(&this->actor, play, GI_RUPEE_RED, 800.0f, 100.0f); } } @@ -647,34 +655,34 @@ void func_80B27760(EnKendoJs* this) { this->actionFunc = func_80B27774; } -void func_80B27774(EnKendoJs* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); +void func_80B27774(EnKendoJs* this, PlayState* play) { + Player* player = GET_PLAYER(play); - if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { + if (Actor_ProcessTalkRequest(&this->actor, &play->state)) { if (!(gSaveContext.save.weekEventReg[63] & 0x20)) { gSaveContext.save.weekEventReg[63] |= 0x20; - Message_StartTextbox(globalCtx, 0x272F, &this->actor); + Message_StartTextbox(play, 0x272F, &this->actor); this->unk_288 = 0x272F; } else { - Message_StartTextbox(globalCtx, 0x2730, &this->actor); + Message_StartTextbox(play, 0x2730, &this->actor); this->unk_288 = 0x2730; } func_80B26AE8(this); player->stateFlags1 &= ~0x20; } else { - func_800B85E0(&this->actor, globalCtx, 1000.0f, -1); + func_800B85E0(&this->actor, play, 1000.0f, -1); } } -void func_80B2783C(EnKendoJs* this, GlobalContext* globalCtx) { +void func_80B2783C(EnKendoJs* this, PlayState* play) { if (this->actor.cutscene != -1) { - Camera_ChangeDataIdx(globalCtx->cameraPtrs[CAM_ID_MAIN], + Camera_ChangeDataIdx(play->cameraPtrs[CAM_ID_MAIN], ActorCutscene_GetCutscene(this->actor.cutscene)->csCamSceneDataId); } } -void func_80B27880(EnKendoJs* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); +void func_80B27880(EnKendoJs* this, PlayState* play) { + Player* player = GET_PLAYER(play); 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)) { @@ -682,8 +690,8 @@ void func_80B27880(EnKendoJs* this, GlobalContext* globalCtx) { } } -s32 func_80B278C4(GlobalContext* globalCtx, Vec3f arg1) { - Player* player = GET_PLAYER(globalCtx); +s32 func_80B278C4(PlayState* play, Vec3f arg1) { + Player* player = GET_PLAYER(play); f32 temp_f0; f32 sp28; s16 sp22 = Math_Vec3f_Yaw(&player->actor.world.pos, &arg1); @@ -698,8 +706,8 @@ s32 func_80B278C4(GlobalContext* globalCtx, Vec3f arg1) { sp28 = 80.0f; } - globalCtx->actorCtx.unk268 = 1; - func_800B6F20(globalCtx, &globalCtx->actorCtx.unk_26C, sp28, sp22); + play->actorCtx.unk268 = 1; + func_800B6F20(play, &play->actorCtx.unk_26C, sp28, sp22); if (temp_f0 < 20.0f) { return true; @@ -708,22 +716,22 @@ s32 func_80B278C4(GlobalContext* globalCtx, Vec3f arg1) { } } -void func_80B279AC(EnKendoJs* this, GlobalContext* globalCtx) { +void func_80B279AC(EnKendoJs* this, PlayState* play) { Collider_UpdateCylinder(&this->actor, &this->collider); - CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + CollisionCheck_SetOC(play, &play->colChkCtx, &this->collider.base); } -void func_80B279F0(EnKendoJs* this, GlobalContext* globalCtx, s32 arg2) { +void func_80B279F0(EnKendoJs* this, PlayState* play, 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); + Actor_SpawnAsChild(&play->actorCtx, &this->actor, play, 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; +void func_80B27A90(EnKendoJs* this, PlayState* play) { + Actor* actor = play->actorCtx.actorLists[ACTORCAT_PROP].first; while (actor != NULL) { if (actor->id == ACTOR_EN_MARUTA) { @@ -735,19 +743,18 @@ void func_80B27A90(EnKendoJs* this, GlobalContext* globalCtx) { this->unk_28C = 0; } -void EnKendoJs_Update(Actor* thisx, GlobalContext* globalCtx) { +void EnKendoJs_Update(Actor* thisx, PlayState* play) { EnKendoJs* this = THIS; - this->actionFunc(this, globalCtx); + this->actionFunc(this, play); SkelAnime_Update(&this->skelAnime); - func_800E9250(globalCtx, &this->actor, &this->unk_278, &this->unk_27E, this->actor.focus.pos); - func_80B279AC(this, globalCtx); - func_80B27880(this, globalCtx); + Actor_TrackPlayer(play, &this->actor, &this->unk_278, &this->unk_27E, this->actor.focus.pos); + func_80B279AC(this, play); + func_80B27880(this, play); } -s32 EnKendoJs_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, - Actor* thisx) { +s32 EnKendoJs_OverrideLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, Actor* thisx) { EnKendoJs* this = THIS; if (limbIndex == 12) { @@ -756,13 +763,13 @@ s32 EnKendoJs_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dL return false; } -void EnKendoJs_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx) { +void EnKendoJs_PostLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx) { } -void EnKendoJs_Draw(Actor* thisx, GlobalContext* globalCtx) { +void EnKendoJs_Draw(Actor* thisx, PlayState* play) { EnKendoJs* this = THIS; - func_8012C28C(globalCtx->state.gfxCtx); - SkelAnime_DrawFlexOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, + func_8012C28C(play->state.gfxCtx); + SkelAnime_DrawFlexOpa(play, 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 2820aac21..2d49058e8 100644 --- a/src/overlays/actors/ovl_En_Kendo_Js/z_en_kendo_js.h +++ b/src/overlays/actors/ovl_En_Kendo_Js/z_en_kendo_js.h @@ -5,7 +5,7 @@ struct EnKendoJs; -typedef void (*EnKendoJsActionFunc)(struct EnKendoJs*, GlobalContext*); +typedef void (*EnKendoJsActionFunc)(struct EnKendoJs*, PlayState*); #define ENKENDOJS_GET_FF(thisx) ((thisx)->params & 0xFF) #define ENKENDOJS_GET_FF00(thisx) (((thisx)->params & 0xFF00) >> 8) @@ -13,23 +13,23 @@ typedef void (*EnKendoJsActionFunc)(struct EnKendoJs*, GlobalContext*); #define ENKENDOJS_FF_1 1 typedef struct EnKendoJs { - /* 0x0000 */ Actor actor; - /* 0x0144 */ ColliderCylinder collider; - /* 0x0190 */ SkelAnime skelAnime; - /* 0x01D4 */ EnKendoJsActionFunc actionFunc; - /* 0x01D8 */ Vec3s jointTable[13]; - /* 0x0226 */ Vec3s morphTable[13]; - /* 0x0274 */ Vec3s* unk_274; - /* 0x0278 */ Vec3s unk_278; - /* 0x027E */ Vec3s unk_27E; - /* 0x0284 */ s16 unk_284; - /* 0x0286 */ s16 unk_286; - /* 0x0288 */ s16 unk_288; - /* 0x028A */ s16 unk_28A; - /* 0x028C */ s16 unk_28C; - /* 0x028E */ s16 unk_28E; - /* 0x0290 */ s16 unk_290; - /* 0x0292 */ u8 unk_292; + /* 0x000 */ Actor actor; + /* 0x144 */ ColliderCylinder collider; + /* 0x190 */ SkelAnime skelAnime; + /* 0x1D4 */ EnKendoJsActionFunc actionFunc; + /* 0x1D8 */ Vec3s jointTable[13]; + /* 0x226 */ Vec3s morphTable[13]; + /* 0x274 */ Vec3s* unk_274; + /* 0x278 */ Vec3s unk_278; + /* 0x27E */ Vec3s unk_27E; + /* 0x284 */ s16 unk_284; + /* 0x286 */ s16 unk_286; + /* 0x288 */ s16 unk_288; + /* 0x28A */ s16 unk_28A; + /* 0x28C */ s16 unk_28C; + /* 0x28E */ s16 unk_28E; + /* 0x290 */ s16 unk_290; + /* 0x292 */ u8 unk_292; } EnKendoJs; // size = 0x294 extern const ActorInit En_Kendo_Js_InitVars; diff --git a/src/overlays/actors/ovl_En_Kgy/z_en_kgy.c b/src/overlays/actors/ovl_En_Kgy/z_en_kgy.c index 176a556e5..de2d1c207 100644 --- a/src/overlays/actors/ovl_En_Kgy/z_en_kgy.c +++ b/src/overlays/actors/ovl_En_Kgy/z_en_kgy.c @@ -4,8 +4,6 @@ * Description: Blacksmith - Gabora */ -#include "overlays/actors/ovl_En_Kbt/z_en_kbt.h" -#include "overlays/actors/ovl_Obj_Ice_Poly/z_obj_ice_poly.h" #include "z_en_kgy.h" #include "objects/object_kgy/object_kgy.h" #include "objects/gameplay_keep/gameplay_keep.h" @@ -14,24 +12,24 @@ #define THIS ((EnKgy*)thisx) -void EnKgy_Init(Actor* thisx, GlobalContext* globalCtx); -void EnKgy_Destroy(Actor* thisx, GlobalContext* globalCtx); -void EnKgy_Update(Actor* thisx, GlobalContext* globalCtx); -void EnKgy_Draw(Actor* thisx, GlobalContext* globalCtx); +void EnKgy_Init(Actor* thisx, PlayState* play); +void EnKgy_Destroy(Actor* thisx, PlayState* play); +void EnKgy_Update(Actor* thisx, PlayState* play); +void EnKgy_Draw(Actor* thisx, PlayState* play); -void EnKgy_ChangeAnim(EnKgy* this, s16 arg1, u8 arg2, f32 arg3); -EnKbt* EnKgy_FindZubora(GlobalContext* globalCtx); -ObjIcePoly* EnKgy_FindIceBlock(GlobalContext* globalCtx); -void func_80B40D30(GlobalContext* globalCtx); -s32 func_80B40D64(GlobalContext* globalCtx); -s32 func_80B40DB4(GlobalContext* globalCtx); -void func_80B419B0(EnKgy* this, GlobalContext* globalCtx); -void func_80B41A48(EnKgy* this, GlobalContext* globalCtx); -void func_80B41E18(EnKgy* this, GlobalContext* globalCtx); -void func_80B42508(EnKgy* this, GlobalContext* globalCtx); -void func_80B425A0(EnKgy* this, GlobalContext* globalCtx); -void func_80B42714(EnKgy* this, GlobalContext* globalCtx); -void func_80B42D28(EnKgy* this, GlobalContext* globalCtx); +void EnKgy_ChangeAnim(EnKgy* this, s16 animIndex, u8 mode, f32 morphFrames); +EnKbt* EnKgy_FindZubora(PlayState* play); +ObjIcePoly* EnKgy_FindIceBlock(PlayState* play); +void func_80B40D30(PlayState* play); +s32 func_80B40D64(PlayState* play); +s32 func_80B40DB4(PlayState* play); +void func_80B419B0(EnKgy* this, PlayState* play); +void func_80B41A48(EnKgy* this, PlayState* play); +void func_80B41E18(EnKgy* this, PlayState* play); +void func_80B42508(EnKgy* this, PlayState* play); +void func_80B425A0(EnKgy* this, PlayState* play); +void func_80B42714(EnKgy* this, PlayState* play); +void func_80B42D28(EnKgy* this, PlayState* play); const ActorInit En_Kgy_InitVars = { ACTOR_EN_KGY, @@ -45,45 +43,45 @@ const ActorInit En_Kgy_InitVars = { (ActorFunc)EnKgy_Draw, }; -void EnKgy_Init(Actor* thisx, GlobalContext* globalCtx) { +void EnKgy_Init(Actor* thisx, PlayState* play) { EnKgy* this = THIS; s16 cs; s32 i; Actor_SetScale(&this->actor, 0.01f); - SkelAnime_InitFlex(globalCtx, &this->skelAnime, &object_kgy_Skel_00F910, &object_kgy_Anim_004B98, this->jointTable, + SkelAnime_InitFlex(play, &this->skelAnime, &object_kgy_Skel_00F910, &object_kgy_Anim_004B98, this->jointTable, this->morphTable, 23); this->unk_2D2 = -1; this->unk_29C = 0; this->unk_2E4 = 0; this->unk_2E2 = -1; - 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.save.weekEventReg[33] & 0x80)) { - Flags_SetSwitch(globalCtx, ENKGY_GET_FE00(&this->actor) + 1); - globalCtx->envCtx.lightSettingOverride = 1; + this->zubora = EnKgy_FindZubora(play); + this->iceBlock = EnKgy_FindIceBlock(play); + Flags_UnsetSwitch(play, ENKGY_GET_FE00(&this->actor) + 1); + if (Flags_GetSwitch(play, ENKGY_GET_FE00(&this->actor)) || (gSaveContext.save.weekEventReg[33] & 0x80)) { + Flags_SetSwitch(play, ENKGY_GET_FE00(&this->actor) + 1); + play->envCtx.lightSettingOverride = 1; gSaveContext.save.weekEventReg[21] |= 1; - if (!func_80B40D64(globalCtx)) { - EnKgy_ChangeAnim(this, 4, 0, 0); + if (!func_80B40D64(play)) { + EnKgy_ChangeAnim(this, 4, ANIMMODE_LOOP, 0); this->actionFunc = func_80B425A0; this->actor.textId = 0xC35; - } else if (!func_80B40DB4(globalCtx)) { - EnKgy_ChangeAnim(this, 6, 2, 0); + } else if (!func_80B40DB4(play)) { + EnKgy_ChangeAnim(this, 6, ANIMMODE_ONCE, 0); this->actionFunc = func_80B419B0; this->actor.textId = 0xC4E; this->unk_29C |= 1; this->unk_2EA = 3; } else { - EnKgy_ChangeAnim(this, 4, 0, 0); + EnKgy_ChangeAnim(this, 4, ANIMMODE_LOOP, 0); this->actionFunc = func_80B42714; this->actor.textId = 0xC50; } } else { if (gSaveContext.save.weekEventReg[20] & 0x80) { - EnKgy_ChangeAnim(this, 4, 0, 0); + EnKgy_ChangeAnim(this, 4, ANIMMODE_LOOP, 0); } else { - EnKgy_ChangeAnim(this, 0, 0, 0); + EnKgy_ChangeAnim(this, 0, ANIMMODE_LOOP, 0); } this->actionFunc = func_80B42D28; } @@ -99,18 +97,18 @@ void EnKgy_Init(Actor* thisx, GlobalContext* globalCtx) { Lights_PointNoGlowSetInfo(&this->lightInfo, this->actor.world.pos.x, this->actor.world.pos.y, this->actor.world.pos.z, 255, 64, 64, -1); - this->lightNode = LightContext_InsertLight(globalCtx, &globalCtx->lightCtx, &this->lightInfo); + this->lightNode = LightContext_InsertLight(play, &play->lightCtx, &this->lightInfo); this->unk_300 = -1; this->actor.flags &= ~ACTOR_FLAG_1; } -void EnKgy_Destroy(Actor* thisx, GlobalContext* globalCtx) { +void EnKgy_Destroy(Actor* thisx, PlayState* play) { EnKgy* this = THIS; - LightContext_RemoveLight(globalCtx, &globalCtx->lightCtx, this->lightNode); + LightContext_RemoveLight(play, &play->lightCtx, this->lightNode); } -void EnKgy_ChangeAnim(EnKgy* this, s16 animIndex, u8 mode, f32 transitionRate) { +void EnKgy_ChangeAnim(EnKgy* this, s16 animIndex, u8 mode, f32 morphFrames) { static AnimationHeader* sAnimations[] = { &object_kgy_Anim_004B98, &object_kgy_Anim_0008FC, &object_kgy_Anim_00292C, &object_kgy_Anim_0042E4, &object_kgy_Anim_0101F0, &object_kgy_Anim_001764, &object_kgy_Anim_003334, &object_kgy_Anim_010B84, @@ -118,18 +116,18 @@ void EnKgy_ChangeAnim(EnKgy* this, s16 animIndex, u8 mode, f32 transitionRate) { }; Animation_Change(&this->skelAnime, sAnimations[animIndex], 1.0f, 0.0f, - Animation_GetLastFrame(sAnimations[animIndex]), mode, transitionRate); + Animation_GetLastFrame(sAnimations[animIndex]), mode, morphFrames); this->unk_2D2 = animIndex; } void func_80B40BC0(EnKgy* this, s16 arg1) { if (arg1 != this->unk_2D2) { - EnKgy_ChangeAnim(this, arg1, 0, -5.0f); + EnKgy_ChangeAnim(this, arg1, ANIMMODE_LOOP, -5.0f); } } -EnKbt* EnKgy_FindZubora(GlobalContext* globalCtx) { - Actor* actor = globalCtx->actorCtx.actorLists[ACTORCAT_NPC].first; +EnKbt* EnKgy_FindZubora(PlayState* play) { + Actor* actor = play->actorCtx.actorLists[ACTORCAT_NPC].first; while (actor != NULL) { if (actor->id == ACTOR_EN_KBT) { @@ -140,8 +138,8 @@ EnKbt* EnKgy_FindZubora(GlobalContext* globalCtx) { return NULL; } -ObjIcePoly* EnKgy_FindIceBlock(GlobalContext* globalCtx) { - Actor* actor = globalCtx->actorCtx.actorLists[ACTORCAT_ITEMACTION].first; +ObjIcePoly* EnKgy_FindIceBlock(PlayState* play) { + Actor* actor = play->actorCtx.actorLists[ACTORCAT_ITEMACTION].first; while (actor != NULL) { if (actor->id == ACTOR_OBJ_ICE_POLY) { @@ -152,34 +150,34 @@ ObjIcePoly* EnKgy_FindIceBlock(GlobalContext* globalCtx) { return NULL; } -void func_80B40C74(GlobalContext* globalCtx) { - gSaveContext.save.permanentSceneFlags[globalCtx->sceneNum].unk_14 |= 1; +void func_80B40C74(PlayState* play) { + gSaveContext.save.permanentSceneFlags[play->sceneNum].unk_14 |= 1; if (CURRENT_DAY == 1) { - gSaveContext.save.permanentSceneFlags[globalCtx->sceneNum].unk_14 |= 2; + gSaveContext.save.permanentSceneFlags[play->sceneNum].unk_14 |= 2; } else { - gSaveContext.save.permanentSceneFlags[globalCtx->sceneNum].unk_14 &= ~2; + gSaveContext.save.permanentSceneFlags[play->sceneNum].unk_14 &= ~2; } } -void func_80B40D00(GlobalContext* globalCtx) { - gSaveContext.save.permanentSceneFlags[globalCtx->sceneNum].unk_14 |= 4; +void func_80B40D00(PlayState* play) { + gSaveContext.save.permanentSceneFlags[play->sceneNum].unk_14 |= 4; } -void func_80B40D30(GlobalContext* globalCtx) { - gSaveContext.save.permanentSceneFlags[globalCtx->sceneNum].unk_14 &= ~7; +void func_80B40D30(PlayState* play) { + gSaveContext.save.permanentSceneFlags[play->sceneNum].unk_14 &= ~7; } -s32 func_80B40D64(GlobalContext* globalCtx) { - return gSaveContext.save.permanentSceneFlags[globalCtx->sceneNum].unk_14 & 1; +s32 func_80B40D64(PlayState* play) { + return gSaveContext.save.permanentSceneFlags[play->sceneNum].unk_14 & 1; } -s32 func_80B40D8C(GlobalContext* globalCtx) { - return gSaveContext.save.permanentSceneFlags[globalCtx->sceneNum].unk_14 & 4; +s32 func_80B40D8C(PlayState* play) { + return gSaveContext.save.permanentSceneFlags[play->sceneNum].unk_14 & 4; } -s32 func_80B40DB4(GlobalContext* globalCtx) { +s32 func_80B40DB4(PlayState* play) { if ((CURRENT_DAY == 3) || - ((CURRENT_DAY == 2) && (gSaveContext.save.permanentSceneFlags[globalCtx->sceneNum].unk_14 & 2))) { + ((CURRENT_DAY == 2) && (gSaveContext.save.permanentSceneFlags[play->sceneNum].unk_14 & 2))) { return true; } return false; @@ -204,24 +202,24 @@ s32 func_80B40E54(EnKgy* this) { return 0; } -void func_80B40E74(EnKgy* this, GlobalContext* globalCtx, u16 textId) { - func_80151938(globalCtx, textId); +void func_80B40E74(EnKgy* this, PlayState* play, u16 textId) { + func_80151938(play, textId); this->actor.textId = textId; func_80B40E18(this, this->actor.textId); } -void func_80B40EBC(EnKgy* this, GlobalContext* globalCtx, u16 arg2) { - func_80B40E74(this, globalCtx, ++arg2); +void func_80B40EBC(EnKgy* this, PlayState* play, u16 arg2) { + func_80B40E74(this, play, ++arg2); } -void func_80B40EE8(EnKgy* this, GlobalContext* globalCtx) { +void func_80B40EE8(EnKgy* this, PlayState* play) { s32 pad; if (this->unk_2E4 > 0) { this->unk_2E4--; if ((this->unk_2E4 == 0) && (this->unk_2E2 >= 0)) { if (this->unk_2E2 == 3) { - EnKgy_ChangeAnim(this, 3, 2, -5.0f); + EnKgy_ChangeAnim(this, 3, ANIMMODE_ONCE, -5.0f); } else { func_80B40BC0(this, this->unk_2E2); } @@ -241,18 +239,18 @@ void func_80B40EE8(EnKgy* this, GlobalContext* globalCtx) { } if (this->unk_29C & 2) { - Vec3f sp38; - f32 sp34; + Vec3f projectedPos; + f32 invW; f32 temp_f0; - Actor_GetProjectedPos(globalCtx, &this->unk_2B4, &sp38, &sp34); - temp_f0 = sp38.x * sp34; + Actor_GetProjectedPos(play, &this->unk_2B4, &projectedPos, &invW); + temp_f0 = projectedPos.x * invW; if (this->unk_2E6 > 0) { this->unk_2E6--; } if (((temp_f0 < 0.15f) && (temp_f0 > -0.15f)) || (this->unk_2E6 == 0)) { - func_80151938(globalCtx, this->actor.textId); + func_80151938(play, this->actor.textId); this->unk_29C &= ~0x2; func_80B40E18(this, this->actor.textId); @@ -263,7 +261,7 @@ void func_80B40EE8(EnKgy* this, GlobalContext* globalCtx) { break; case 0xC43: - if (func_80B40D64(globalCtx)) { + if (func_80B40D64(play)) { func_80B40BC0(this, 7); } else { func_80B40BC0(this, 1); @@ -290,17 +288,17 @@ void func_80B40EE8(EnKgy* this, GlobalContext* globalCtx) { if ((this->actor.textId == 0xC1D) || (this->actor.textId == 0xC2D)) { this->unk_2E4 = 20; this->unk_2E2 = 3; - func_80B40EBC(this, globalCtx, this->actor.textId); + func_80B40EBC(this, play, this->actor.textId); } else { - func_80B40EBC(this, globalCtx, this->actor.textId); + func_80B40EBC(this, play, this->actor.textId); } this->unk_29C &= ~4; } } } -void func_80B411DC(EnKgy* this, GlobalContext* globalCtx, s32 arg2) { - Player* player = GET_PLAYER(globalCtx); +void func_80B411DC(EnKgy* this, PlayState* play, s32 arg2) { + Player* player = GET_PLAYER(play); switch (arg2) { case 0: @@ -343,9 +341,9 @@ void func_80B411DC(EnKgy* this, GlobalContext* globalCtx, s32 arg2) { } } -void func_80B41368(EnKgy* this, GlobalContext* globalCtx, s32 arg2) { +void func_80B41368(EnKgy* this, PlayState* play, s32 arg2) { ActorCutscene_Stop(this->unk_2D4[this->unk_2E0]); - func_80B411DC(this, globalCtx, arg2); + func_80B411DC(this, play, arg2); this->unk_2E6 = 20; this->unk_29C |= 2; } @@ -375,7 +373,7 @@ s32 func_80B41460(void) { return 0xC3A; } -s32 func_80B41528(GlobalContext* globalCtx) { +s32 func_80B41528(PlayState* play) { if (CUR_FORM_EQUIP(EQUIP_SLOT_B) == ITEM_SWORD_GILDED) { return 0xC4C; } @@ -387,7 +385,7 @@ s32 func_80B41528(GlobalContext* globalCtx) { return 0xC3B; } -void func_80B415A8(GlobalContext* globalCtx, Vec3f* arg1) { +void func_80B415A8(PlayState* play, Vec3f* arg1) { static EffectShieldParticleInit D_80B43298 = { 16, { 0, 0, 0 }, @@ -413,23 +411,23 @@ void func_80B415A8(GlobalContext* globalCtx, Vec3f* arg1) { D_80B43298.lightPoint.y = D_80B43298.position.y; D_80B43298.lightPoint.z = D_80B43298.position.z; - Effect_Add(globalCtx, &effectIndex, EFFECT_SHIELD_PARTICLE, 0, 1, &D_80B43298); + Effect_Add(play, &effectIndex, EFFECT_SHIELD_PARTICLE, 0, 1, &D_80B43298); } -void func_80B4163C(EnKgy* this, GlobalContext* globalCtx) { +void func_80B4163C(EnKgy* this, PlayState* play) { this->actor.focus.pos = this->unk_2A8; if (SkelAnime_Update(&this->skelAnime)) { if (this->unk_2D2 == 6) { if (this->unk_2EA > 0) { - EnKgy_ChangeAnim(this, 6, 2, 0.0f); + EnKgy_ChangeAnim(this, 6, ANIMMODE_ONCE, 0.0f); this->unk_2EA--; } else { - EnKgy_ChangeAnim(this, 9, 2, -5.0f); + EnKgy_ChangeAnim(this, 9, ANIMMODE_ONCE, -5.0f); this->unk_2EA = (s32)Rand_ZeroFloat(3.0f) + 2; } } else { - EnKgy_ChangeAnim(this, 6, 2, -5.0f); + EnKgy_ChangeAnim(this, 6, ANIMMODE_ONCE, -5.0f); } SkelAnime_Update(&this->skelAnime); } @@ -440,7 +438,7 @@ void func_80B4163C(EnKgy* this, GlobalContext* globalCtx) { case 13: case 19: case 25: - func_80B415A8(globalCtx, &this->unk_2C0); + func_80B415A8(play, &this->unk_2C0); this->lightInfo.params.point.x = this->unk_2C0.x; this->lightInfo.params.point.y = this->unk_2C0.y; this->lightInfo.params.point.z = this->unk_2C0.z; @@ -455,20 +453,20 @@ void func_80B4163C(EnKgy* this, GlobalContext* globalCtx) { } } -void func_80B417B8(EnKgy* this, GlobalContext* globalCtx) { - func_80B4163C(this, globalCtx); - if ((Message_GetState(&globalCtx->msgCtx) == 5) && Message_ShouldAdvance(globalCtx)) { - func_801477B4(globalCtx); +void func_80B417B8(EnKgy* this, PlayState* play) { + func_80B4163C(this, play); + if ((Message_GetState(&play->msgCtx) == TEXT_STATE_5) && Message_ShouldAdvance(play)) { + func_801477B4(play); func_80B413C8(this); this->actor.flags &= ~ACTOR_FLAG_100; this->actionFunc = func_80B419B0; func_80B40E18(this, 7); } - func_80B40EE8(this, globalCtx); + func_80B40EE8(this, play); } -void func_80B41858(EnKgy* this, GlobalContext* globalCtx) { - func_80B4163C(this, globalCtx); +void func_80B41858(EnKgy* this, PlayState* play) { + func_80B4163C(this, play); if (ActorCutscene_GetCanPlayNext(this->unk_2D4[5])) { ActorCutscene_StartAndSetUnkLinkFields(this->unk_2D4[5], &this->actor); this->actionFunc = func_80B419B0; @@ -478,28 +476,28 @@ void func_80B41858(EnKgy* this, GlobalContext* globalCtx) { } } -void func_80B418C4(EnKgy* this, GlobalContext* globalCtx) { - func_80B4163C(this, globalCtx); +void func_80B418C4(EnKgy* this, PlayState* play) { + func_80B4163C(this, play); if ((this->unk_2E4 <= 0) && !(this->unk_29C & 2) && (func_80B40E54(this) == 0) && - (Message_GetState(&globalCtx->msgCtx) == 5) && Message_ShouldAdvance(globalCtx) && - ((globalCtx->msgCtx.currentTextId == 0xC4E) || (globalCtx->msgCtx.currentTextId == 0xC4F))) { - func_801477B4(globalCtx); + (Message_GetState(&play->msgCtx) == TEXT_STATE_5) && Message_ShouldAdvance(play) && + ((play->msgCtx.currentTextId == 0xC4E) || (play->msgCtx.currentTextId == 0xC4F))) { + func_801477B4(play); this->actor.textId = 0xC4F; func_80B413C8(this); ActorCutscene_SetIntentToPlay(this->unk_2D4[5]); this->actionFunc = func_80B41858; this->actor.flags &= ~ACTOR_FLAG_100; } - func_80B40EE8(this, globalCtx); + func_80B40EE8(this, play); } -void func_80B419B0(EnKgy* this, GlobalContext* globalCtx) { +void func_80B419B0(EnKgy* this, PlayState* play) { s32 pad; - Player* player = GET_PLAYER(globalCtx); + Player* player = GET_PLAYER(play); - func_80B4163C(this, globalCtx); - if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state) || (&this->actor == player->targetActor)) { - func_80B411DC(this, globalCtx, 4); + func_80B4163C(this, play); + if (Actor_ProcessTalkRequest(&this->actor, &play->state) || (&this->actor == player->targetActor)) { + func_80B411DC(this, play, 4); func_80B40E18(this, this->actor.textId); if (this->actor.textId == 0xC37) { this->actionFunc = func_80B417B8; @@ -509,29 +507,29 @@ void func_80B419B0(EnKgy* this, GlobalContext* globalCtx) { } } -void func_80B41A48(EnKgy* this, GlobalContext* globalCtx) { +void func_80B41A48(EnKgy* this, PlayState* play) { SkelAnime_Update(&this->skelAnime); if (this->unk_2E4 > 0) { this->unk_2E4--; } else { - globalCtx->nextEntranceIndex = globalCtx->setupExitList[ENKGY_GET_1F(&this->actor)]; - globalCtx->sceneLoadFlag = 20; + play->nextEntrance = play->setupExitList[ENKGY_GET_1F(&this->actor)]; + play->transitionTrigger = TRANS_TRIGGER_START; } } -void func_80B41ACC(EnKgy* this, GlobalContext* globalCtx) { +void func_80B41ACC(EnKgy* this, PlayState* play) { s32 itemActionParam; - Player* player = GET_PLAYER(globalCtx); + Player* player = GET_PLAYER(play); SkelAnime_Update(&this->skelAnime); - if (Message_GetState(&globalCtx->msgCtx) == 0x10) { - itemActionParam = func_80123810(globalCtx); + if (Message_GetState(&play->msgCtx) == TEXT_STATE_16) { + itemActionParam = func_80123810(play); if (itemActionParam != PLAYER_AP_NONE) { this->actionFunc = func_80B41E18; } if (itemActionParam > PLAYER_AP_NONE) { - func_801477B4(globalCtx); + func_801477B4(play); if (itemActionParam == PLAYER_AP_BOTTLE_GOLD_DUST) { if (this->unk_29C & 0x10) { this->actor.textId = 0xC55; @@ -539,7 +537,7 @@ void func_80B41ACC(EnKgy* this, GlobalContext* globalCtx) { } else { this->actor.textId = 0xC46; player->actor.textId = 0xC46; - func_80B40D00(globalCtx); + func_80B40D00(play); } } else if (this->unk_29C & 0x10) { this->actor.textId = 0xC57; @@ -556,100 +554,100 @@ void func_80B41ACC(EnKgy* this, GlobalContext* globalCtx) { this->actor.textId = 0xC47; } player->actor.textId = 0; - globalCtx->msgCtx.unk11F10 = 0; - func_80B41368(this, globalCtx, 4); + play->msgCtx.msgLength = 0; + func_80B41368(this, play, 4); } } - func_80B40EE8(this, globalCtx); + func_80B40EE8(this, play); } -void func_80B41C30(EnKgy* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); +void func_80B41C30(EnKgy* this, PlayState* play) { + Player* player = GET_PLAYER(play); if (&this->actor != player->targetActor) { this->actionFunc = func_80B42508; } } -void func_80B41C54(EnKgy* this, GlobalContext* globalCtx) { +void func_80B41C54(EnKgy* this, PlayState* play) { SkelAnime_Update(&this->skelAnime); - if (Actor_TextboxIsClosing(&this->actor, globalCtx)) { + if (Actor_TextboxIsClosing(&this->actor, play)) { this->actionFunc = func_80B41C30; this->actor.flags &= ~ACTOR_FLAG_100; } - func_80B40EE8(this, globalCtx); + func_80B40EE8(this, play); } -void func_80B41CBC(EnKgy* this, GlobalContext* globalCtx) { +void func_80B41CBC(EnKgy* this, PlayState* play) { SkelAnime_Update(&this->skelAnime); - if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { + if (Actor_ProcessTalkRequest(&this->actor, &play->state)) { this->actor.flags &= ~ACTOR_FLAG_10000; func_80B40E18(this, this->actor.textId); this->actionFunc = func_80B41E18; - func_80B411DC(this, globalCtx, 4); + func_80B411DC(this, play, 4); } else { - func_800B8500(&this->actor, globalCtx, 1000.0f, 1000.0f, EXCH_ITEM_MINUS1); + func_800B8500(&this->actor, play, 1000.0f, 1000.0f, PLAYER_AP_MINUS1); } } -void func_80B41D64(EnKgy* this, GlobalContext* globalCtx) { +void func_80B41D64(EnKgy* this, PlayState* play) { SkelAnime_Update(&this->skelAnime); - if (Actor_HasParent(&this->actor, globalCtx)) { + if (Actor_HasParent(&this->actor, play)) { this->actionFunc = func_80B41CBC; this->actor.flags |= ACTOR_FLAG_10000; - func_800B8500(&this->actor, globalCtx, 1000.0f, 1000.0f, EXCH_ITEM_MINUS1); + func_800B8500(&this->actor, play, 1000.0f, 1000.0f, PLAYER_AP_MINUS1); } else { - Actor_PickUp(&this->actor, globalCtx, this->unk_2EA, 2000.0f, 1000.0f); + Actor_PickUp(&this->actor, play, this->unk_2EA, 2000.0f, 1000.0f); } - func_80B40EE8(this, globalCtx); + func_80B40EE8(this, play); } -void func_80B41E18(EnKgy* this, GlobalContext* globalCtx) { - u16 temp; +void func_80B41E18(EnKgy* this, PlayState* play) { + u16 textId; s32 pad; - Player* player = GET_PLAYER(globalCtx); + Player* player = GET_PLAYER(play); if (SkelAnime_Update(&this->skelAnime) && (this->unk_2D2 == 3)) { func_80B40BC0(this, 4); } if ((this->unk_2E4 <= 0) && !(this->unk_29C & 2) && func_80B40E54(this) == 0) { - switch (Message_GetState(&globalCtx->msgCtx)) { - case 4: - if (Message_ShouldAdvance(globalCtx)) { - temp = globalCtx->msgCtx.currentTextId; + switch (Message_GetState(&play->msgCtx)) { + case TEXT_STATE_CHOICE: + if (Message_ShouldAdvance(play)) { + textId = play->msgCtx.currentTextId; - switch (temp) { + switch (textId) { case 0xC3B: - switch (globalCtx->msgCtx.choiceIndex) { + switch (play->msgCtx.choiceIndex) { case 0: - if (gSaveContext.save.playerData.rupees < globalCtx->msgCtx.unk1206C) { + if (gSaveContext.save.playerData.rupees < play->msgCtx.unk1206C) { play_sound(NA_SE_SY_ERROR); - func_80B40E74(this, globalCtx, 0xC3F); + func_80B40E74(this, play, 0xC3F); } else { func_8019F208(); - func_80B40E74(this, globalCtx, 0xC42); - func_801159EC(-globalCtx->msgCtx.unk1206C); + func_80B40E74(this, play, 0xC42); + Rupees_ChangeBy(-play->msgCtx.unk1206C); } break; case 1: func_8019F230(); - func_80B40EBC(this, globalCtx, temp); + func_80B40EBC(this, play, textId); break; } break; case 0xC3E: - switch (globalCtx->msgCtx.choiceIndex) { + switch (play->msgCtx.choiceIndex) { case 0: func_8019F208(); - func_80B40E74(this, globalCtx, func_80B41460()); + func_80B40E74(this, play, func_80B41460()); break; case 1: func_8019F230(); - func_80B40E74(this, globalCtx, 0xC3C); + func_80B40E74(this, play, 0xC3C); break; } break; @@ -657,22 +655,22 @@ void func_80B41E18(EnKgy* this, GlobalContext* globalCtx) { } break; - case 5: - if (Message_ShouldAdvance(globalCtx)) { - temp = globalCtx->msgCtx.currentTextId; + case TEXT_STATE_5: + if (Message_ShouldAdvance(play)) { + textId = play->msgCtx.currentTextId; - switch (temp) { + switch (textId) { case 0xC35: - globalCtx->msgCtx.unk11F10 = 0; - this->actor.textId = temp; + play->msgCtx.msgLength = 0; + this->actor.textId = textId; this->unk_29C |= 4; this->unk_2E8 = 3; func_80B40E38(this); break; case 0xC36: - globalCtx->msgCtx.unk11F10 = 0; - func_80B41368(this, globalCtx, 4); + play->msgCtx.msgLength = 0; + func_80B41368(this, play, 4); this->actor.textId = func_80B41460(); break; @@ -680,7 +678,7 @@ void func_80B41E18(EnKgy* this, GlobalContext* globalCtx) { case 0xC39: case 0xC52: case 0xC54: - func_801477B4(globalCtx); + func_801477B4(play); this->actionFunc = func_80B425A0; func_80B413C8(this); func_80B40E18(this, 5); @@ -689,18 +687,18 @@ void func_80B41E18(EnKgy* this, GlobalContext* globalCtx) { break; case 0xC3A: - func_80B40E74(this, globalCtx, func_80B41528(globalCtx)); + func_80B40E74(this, play, func_80B41528(play)); func_80B40BC0(this, 4); break; case 0xC3C: case 0xC3F: case 0xC4C: - func_80B40EBC(this, globalCtx, temp); + func_80B40EBC(this, play, textId); break; case 0xC3D: - func_801477B4(globalCtx); + func_801477B4(play); this->actionFunc = func_80B41C54; this->actor.textId = 0xC3E; func_80B413C8(this); @@ -708,19 +706,19 @@ void func_80B41E18(EnKgy* this, GlobalContext* globalCtx) { break; case 0xC40: - globalCtx->msgCtx.unk11F10 = 0; - func_80B41368(this, globalCtx, 0); + play->msgCtx.msgLength = 0; + func_80B41368(this, play, 0); this->actor.textId = 0xC43; break; case 0xC42: - globalCtx->msgCtx.unk11F10 = 0; - func_80B41368(this, globalCtx, 0); + play->msgCtx.msgLength = 0; + func_80B41368(this, play, 0); this->actor.textId = 0xC43; CUR_FORM_EQUIP(EQUIP_SLOT_B) = ITEM_NONE; - SET_EQUIP_VALUE(EQUIP_SWORD, 0); - func_80112B40(globalCtx, 0); - func_80B40C74(globalCtx); + SET_EQUIP_VALUE(EQUIP_TYPE_SWORD, EQUIP_VALUE_SWORD_NONE); + Interface_LoadItemIconImpl(play, EQUIP_SLOT_B); + func_80B40C74(play); break; case 0xC4D: @@ -728,15 +726,15 @@ void func_80B41E18(EnKgy* this, GlobalContext* globalCtx) { this->unk_29C |= 0x10; case 0xC45: - globalCtx->msgCtx.unk11F10 = 0; - func_80B41368(this, globalCtx, 3); + play->msgCtx.msgLength = 0; + func_80B41368(this, play, 3); this->actor.textId = 0xFF; this->actionFunc = func_80B41ACC; break; case 0xC57: this->unk_29C &= ~0x8; - func_801477B4(globalCtx); + func_801477B4(play); this->actionFunc = func_80B41C54; this->actor.textId = 0xC58; func_80B413C8(this); @@ -745,14 +743,14 @@ void func_80B41E18(EnKgy* this, GlobalContext* globalCtx) { case 0xC46: case 0xC55: - func_80123D50(globalCtx, GET_PLAYER(globalCtx), ITEM_BOTTLE, PLAYER_AP_BOTTLE); - player->exchangeItemId = EXCH_ITEM_NONE; + func_80123D50(play, GET_PLAYER(play), ITEM_BOTTLE, PLAYER_AP_BOTTLE); + player->exchangeItemId = PLAYER_AP_NONE; this->unk_29C &= ~0x8; - globalCtx->msgCtx.unk11F10 = 0; - func_80B41368(this, globalCtx, 4); + play->msgCtx.msgLength = 0; + func_80B41368(this, play, 4); if (this->unk_29C & 0x10) { this->actor.textId = 0xC56; - func_801159EC(globalCtx->msgCtx.unk1206C); + Rupees_ChangeBy(play->msgCtx.unk1206C); } else { this->actor.textId = 0xC42; } @@ -761,28 +759,28 @@ void func_80B41E18(EnKgy* this, GlobalContext* globalCtx) { case 0xC47: func_80B40BC0(this, 1); if (this->unk_29C & 8) { - player->exchangeItemId = EXCH_ITEM_NONE; + player->exchangeItemId = PLAYER_AP_NONE; this->unk_29C &= ~8; } - func_80B40EBC(this, globalCtx, temp); + func_80B40EBC(this, play, textId); break; case 0xC48: - globalCtx->msgCtx.unk11F10 = 0; - func_80B41368(this, globalCtx, 0); - this->actor.textId = temp + 1; + play->msgCtx.msgLength = 0; + func_80B41368(this, play, 0); + this->actor.textId = textId + 1; break; case 0xC49: - globalCtx->msgCtx.unk11F10 = 0; - func_80B41368(this, globalCtx, 4); - this->actor.textId = temp + 1; + play->msgCtx.msgLength = 0; + func_80B41368(this, play, 4); + this->actor.textId = textId + 1; break; case 0xC4A: case 0xC4B: func_80B40BC0(this, 4); - func_801477B4(globalCtx); + func_801477B4(play); this->actionFunc = func_80B41C54; this->actor.textId = 0xC4B; func_80B413C8(this); @@ -790,29 +788,29 @@ void func_80B41E18(EnKgy* this, GlobalContext* globalCtx) { break; case 0xC50: - if (func_80B40D8C(globalCtx)) { + if (func_80B40D8C(play)) { this->unk_2EA = 57; this->actor.textId = 0xC53; } else { this->unk_2EA = 56; this->actor.textId = 0xC51; } - func_801477B4(globalCtx); + func_801477B4(play); this->actionFunc = func_80B41D64; func_80B413C8(this); - Actor_PickUp(&this->actor, globalCtx, this->unk_2EA, 2000.0f, 1000.0f); + Actor_PickUp(&this->actor, play, this->unk_2EA, 2000.0f, 1000.0f); break; case 0xC51: case 0xC53: - globalCtx->msgCtx.unk11F10 = 0; - func_80B41368(this, globalCtx, 0); - this->actor.textId = temp + 1; - func_80B40D30(globalCtx); + play->msgCtx.msgLength = 0; + func_80B41368(this, play, 0); + this->actor.textId = textId + 1; + func_80B40D30(play); break; case 0xC56: - func_801477B4(globalCtx); + func_801477B4(play); this->actionFunc = func_80B41C54; this->actor.textId = 0xC56; func_80B413C8(this); @@ -824,56 +822,56 @@ void func_80B41E18(EnKgy* this, GlobalContext* globalCtx) { } } - func_80B40EE8(this, globalCtx); + func_80B40EE8(this, play); } -void func_80B42508(EnKgy* this, GlobalContext* globalCtx) { +void func_80B42508(EnKgy* this, PlayState* play) { s32 pad; - Player* player = GET_PLAYER(globalCtx); + Player* player = GET_PLAYER(play); SkelAnime_Update(&this->skelAnime); this->actor.focus.pos = this->unk_2A8; - if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state) || (&this->actor == player->targetActor)) { + if (Actor_ProcessTalkRequest(&this->actor, &play->state) || (&this->actor == player->targetActor)) { this->actionFunc = func_80B41E18; - func_80B411DC(this, globalCtx, 4); + func_80B411DC(this, play, 4); func_80B40E18(this, this->actor.textId); } } -void func_80B425A0(EnKgy* this, GlobalContext* globalCtx) { +void func_80B425A0(EnKgy* this, PlayState* play) { SkelAnime_Update(&this->skelAnime); this->actor.focus.pos = this->unk_2A8; - if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { + if (Actor_ProcessTalkRequest(&this->actor, &play->state)) { this->actionFunc = func_80B41E18; func_80B40BC0(this, 1); - func_80B411DC(this, globalCtx, 0); + func_80B411DC(this, play, 0); func_80B40E18(this, this->actor.textId); } else if (this->actor.xzDistToPlayer < 200.0f) { - func_800B8614(&this->actor, globalCtx, 210.0f); + func_800B8614(&this->actor, play, 210.0f); } } -void func_80B42660(EnKgy* this, GlobalContext* globalCtx) { +void func_80B42660(EnKgy* this, PlayState* play) { SkelAnime_Update(&this->skelAnime); this->actor.focus.pos = this->unk_2A8; - if ((Message_GetState(&globalCtx->msgCtx) == 5) && Message_ShouldAdvance(globalCtx)) { - func_801477B4(globalCtx); + if ((Message_GetState(&play->msgCtx) == TEXT_STATE_5) && Message_ShouldAdvance(play)) { + func_801477B4(play); func_80B413C8(this); this->actor.flags &= ~ACTOR_FLAG_100; this->actionFunc = func_80B42714; func_80B40E18(this, 7); } - func_80B40EE8(this, globalCtx); + func_80B40EE8(this, play); } -void func_80B42714(EnKgy* this, GlobalContext* globalCtx) { +void func_80B42714(EnKgy* this, PlayState* play) { s32 pad; - Player* player = GET_PLAYER(globalCtx); + Player* player = GET_PLAYER(play); SkelAnime_Update(&this->skelAnime); this->actor.focus.pos = this->unk_2A8; - if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state) || (&this->actor == player->targetActor)) { - func_80B411DC(this, globalCtx, 4); + if (Actor_ProcessTalkRequest(&this->actor, &play->state) || (&this->actor == player->targetActor)) { + func_80B411DC(this, play, 4); func_80B40E18(this, this->actor.textId); if (this->actor.textId == 0xC37) { this->actionFunc = func_80B42660; @@ -883,9 +881,9 @@ void func_80B42714(EnKgy* this, GlobalContext* globalCtx) { } } -void func_80B427C8(EnKgy* this, GlobalContext* globalCtx) { +void func_80B427C8(EnKgy* this, PlayState* play) { s32 pad; - u16 temp_a2; + u16 textId; if (SkelAnime_Update(&this->skelAnime)) { if (this->unk_2D2 == 5) { @@ -897,30 +895,30 @@ 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) && Message_ShouldAdvance(globalCtx)) { - temp_a2 = globalCtx->msgCtx.currentTextId; + (Message_GetState(&play->msgCtx) == TEXT_STATE_5) && Message_ShouldAdvance(play)) { + textId = play->msgCtx.currentTextId; - switch (temp_a2) { + switch (textId) { case 0xC30: - globalCtx->msgCtx.unk11F10 = 0; - this->actor.textId = temp_a2; + play->msgCtx.msgLength = 0; + this->actor.textId = textId; this->unk_29C |= 4; this->unk_2E8 = 3; break; case 0xC31: - globalCtx->msgCtx.unk11F10 = 0; - func_80B41368(this, globalCtx, 4); - this->actor.textId = temp_a2 + 1; + play->msgCtx.msgLength = 0; + func_80B41368(this, play, 4); + this->actor.textId = textId + 1; break; case 0xC32: case 0xC33: - func_80B40EBC(this, globalCtx, temp_a2); + func_80B40EBC(this, play, textId); break; case 0xC34: - func_801477B4(globalCtx); + func_801477B4(play); this->actionFunc = func_80B41C54; func_80B413C8(this); func_80B40E18(this, 6); @@ -929,33 +927,33 @@ void func_80B427C8(EnKgy* this, GlobalContext* globalCtx) { break; } } - func_80B40EE8(this, globalCtx); + func_80B40EE8(this, play); } -void func_80B4296C(EnKgy* this, GlobalContext* globalCtx) { +void func_80B4296C(EnKgy* this, PlayState* play) { if (SkelAnime_Update(&this->skelAnime) && (this->unk_2D2 == 8)) { func_80B40BC0(this, 2); } this->actor.focus.pos = this->unk_2A8; - if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { + if (Actor_ProcessTalkRequest(&this->actor, &play->state)) { this->actionFunc = func_80B427C8; if (this->unk_2D2 == 4) { func_80B40BC0(this, 7); } else { - EnKgy_ChangeAnim(this, 5, 2, -5.0f); + EnKgy_ChangeAnim(this, 5, ANIMMODE_ONCE, -5.0f); } - func_80B411DC(this, globalCtx, 0); + func_80B411DC(this, play, 0); func_80B40E18(this, this->actor.textId); this->actor.flags &= ~ACTOR_FLAG_10000; } else { this->actor.flags |= ACTOR_FLAG_10000; - func_800B8500(&this->actor, globalCtx, 1000.0f, 1000.0f, EXCH_ITEM_NONE); + func_800B8500(&this->actor, play, 1000.0f, 1000.0f, PLAYER_AP_NONE); } } -void func_80B42A8C(EnKgy* this, GlobalContext* globalCtx) { - u16 temp_a2; +void func_80B42A8C(EnKgy* this, PlayState* play) { + u16 textId; s32 pad; if (SkelAnime_Update(&this->skelAnime)) { @@ -969,21 +967,21 @@ 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) && Message_ShouldAdvance(globalCtx)) { - temp_a2 = globalCtx->msgCtx.currentTextId; - switch (temp_a2) { + (Message_GetState(&play->msgCtx) == TEXT_STATE_5) && Message_ShouldAdvance(play)) { + textId = play->msgCtx.currentTextId; + switch (textId) { case 0xC1D: case 0xC2D: - globalCtx->msgCtx.unk11F10 = 0; - this->actor.textId = temp_a2; + play->msgCtx.msgLength = 0; + this->actor.textId = textId; this->unk_29C |= 4; this->unk_2E8 = 3; break; case 0xC1E: - globalCtx->msgCtx.unk11F10 = 0; - func_80B41368(this, globalCtx, 1); - this->actor.textId = temp_a2 + 1; + play->msgCtx.msgLength = 0; + func_80B41368(this, play, 1); + this->actor.textId = textId + 1; func_80B40E38(this); break; @@ -991,77 +989,77 @@ void func_80B42A8C(EnKgy* this, GlobalContext* globalCtx) { case 0xC23: case 0xC24: case 0xC27: - func_80B40EBC(this, globalCtx, temp_a2); + func_80B40EBC(this, play, textId); break; case 0xC20: case 0xC28: func_80B40BC0(this, 1); - globalCtx->msgCtx.unk11F10 = 0; + play->msgCtx.msgLength = 0; this->unk_29C |= 4; this->unk_2E8 = 3; - this->actor.textId = temp_a2; + this->actor.textId = textId; func_80B40E38(this); break; case 0xC21: case 0xC29: - globalCtx->msgCtx.unk11F10 = 0; - func_80B41368(this, globalCtx, 0); - this->actor.textId = temp_a2 + 1; + play->msgCtx.msgLength = 0; + func_80B41368(this, play, 0); + this->actor.textId = textId + 1; break; case 0xC22: case 0xC26: case 0xC2B: case 0xC2E: - globalCtx->msgCtx.unk11F10 = 0; - func_80B41368(this, globalCtx, 1); - this->actor.textId = temp_a2 + 1; + play->msgCtx.msgLength = 0; + func_80B41368(this, play, 1); + this->actor.textId = textId + 1; break; case 0xC25: - globalCtx->msgCtx.unk11F10 = 0; - func_80B41368(this, globalCtx, 2); - this->actor.textId = temp_a2 + 1; + play->msgCtx.msgLength = 0; + func_80B41368(this, play, 2); + this->actor.textId = textId + 1; break; case 0xC2A: this->unk_2E4 = 20; this->unk_2E2 = 3; - func_80B40EBC(this, globalCtx, this->actor.textId); + func_80B40EBC(this, play, this->actor.textId); break; case 0xC2C: case 0xC2F: - func_801477B4(globalCtx); + func_801477B4(play); this->actionFunc = func_80B42D28; func_80B413C8(this); func_80B40E18(this, 1); break; } } - func_80B40EE8(this, globalCtx); + func_80B40EE8(this, play); } -void func_80B42D28(EnKgy* this, GlobalContext* globalCtx) { +void func_80B42D28(EnKgy* this, PlayState* play) { if (SkelAnime_Update(&this->skelAnime) && (this->unk_2D2 == 8)) { func_80B40BC0(this, 2); } this->actor.focus.pos = this->unk_2A8; - if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { + if (Actor_ProcessTalkRequest(&this->actor, &play->state)) { this->actionFunc = func_80B42A8C; if (this->actor.textId == 0xC2D) { func_80B40BC0(this, 1); } else { - EnKgy_ChangeAnim(this, 5, 2, -5.0f); + EnKgy_ChangeAnim(this, 5, ANIMMODE_ONCE, -5.0f); gSaveContext.save.weekEventReg[20] |= 0x80; } - func_80B411DC(this, globalCtx, 0); + func_80B411DC(this, play, 0); func_80B40E18(this, this->actor.textId); } else { - if (Flags_GetSwitch(globalCtx, ENKGY_GET_FE00(&this->actor))) { + if (Flags_GetSwitch(play, ENKGY_GET_FE00(&this->actor))) { this->actor.textId = 0xC30; this->actionFunc = func_80B4296C; gSaveContext.save.weekEventReg[21] |= 1; @@ -1071,33 +1069,33 @@ void func_80B42D28(EnKgy* this, GlobalContext* globalCtx) { } else { this->actor.textId = 0xC1D; } - func_800B8614(&this->actor, globalCtx, 210.0f); + func_800B8614(&this->actor, play, 210.0f); } if ((this->unk_2D2 == 0) && (this->actor.xzDistToPlayer < 200.0f)) { - EnKgy_ChangeAnim(this, 8, 2, 5.0f); + EnKgy_ChangeAnim(this, 8, ANIMMODE_ONCE, 5.0f); } } } -void EnKgy_Update(Actor* thisx, GlobalContext* globalCtx) { +void EnKgy_Update(Actor* thisx, PlayState* play) { EnKgy* this = THIS; s32 pad; Vec3s sp30; - this->actionFunc(this, globalCtx); + this->actionFunc(this, play); if (this->unk_2D2 == 2) { sp30.z = 0; sp30.y = 0; sp30.x = 0; - func_800E9250(globalCtx, &this->actor, &this->unk_2CC, &sp30, this->actor.focus.pos); + Actor_TrackPlayer(play, &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); } } -s32 EnKgy_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, Actor* thisx) { +s32 EnKgy_OverrideLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, Actor* thisx) { EnKgy* this = THIS; if (!(this->unk_29C & 1)) { @@ -1115,42 +1113,42 @@ s32 EnKgy_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, return false; } -void EnKgy_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx) { +void EnKgy_PostLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx) { static Vec3f D_80B432D8 = { 1000.0f, 2000.0f, 0.0f }; static Vec3f D_80B432E4 = { 3000.0f, 4000.0f, 300.0f }; 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); } } -void func_80B43074(EnKgy* this, GlobalContext* globalCtx) { +void func_80B43074(EnKgy* this, PlayState* play) { s32 pad; Gfx* gfx; - OPEN_DISPS(globalCtx->state.gfxCtx); + OPEN_DISPS(play->state.gfxCtx); - 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); + func_8012C28C(play->state.gfxCtx); + func_800B8050(&this->actor, play, MTXMODE_NEW); + 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)); + if (func_80B40D8C(play)) { + AnimatedMat_Draw(play, Lib_SegmentedToVirtual(object_kgy_Matanimheader_00F6A0)); } else { - AnimatedMat_Draw(globalCtx, Lib_SegmentedToVirtual(object_kgy_Matanimheader_00EE58)); + AnimatedMat_Draw(play, Lib_SegmentedToVirtual(object_kgy_Matanimheader_00EE58)); } gfx = POLY_OPA_DISP; - gSPMatrix(gfx, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPMatrix(gfx, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - if (func_80B40D8C(globalCtx)) { + if (func_80B40D8C(play)) { gSPDisplayList(&gfx[1], gameplay_keep_DL_001D00); gSPDisplayList(&gfx[2], object_kgy_DL_00F180); } else { @@ -1159,18 +1157,18 @@ void func_80B43074(EnKgy* this, GlobalContext* globalCtx) { } POLY_OPA_DISP = &gfx[3]; - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->state.gfxCtx); - Matrix_StatePop(); + Matrix_Pop(); } -void EnKgy_Draw(Actor* thisx, GlobalContext* globalCtx) { +void EnKgy_Draw(Actor* thisx, PlayState* play) { EnKgy* this = THIS; - func_8012C28C(globalCtx->state.gfxCtx); + func_8012C28C(play->state.gfxCtx); if (this->unk_29C & 1) { - func_80B43074(this, globalCtx); + func_80B43074(this, play); } - SkelAnime_DrawFlexOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, + SkelAnime_DrawFlexOpa(play, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, EnKgy_OverrideLimbDraw, EnKgy_PostLimbDraw, &this->actor); } diff --git a/src/overlays/actors/ovl_En_Kgy/z_en_kgy.h b/src/overlays/actors/ovl_En_Kgy/z_en_kgy.h index 6f55b2e58..ce7deceb4 100644 --- a/src/overlays/actors/ovl_En_Kgy/z_en_kgy.h +++ b/src/overlays/actors/ovl_En_Kgy/z_en_kgy.h @@ -2,10 +2,12 @@ #define Z_EN_KGY_H #include "global.h" +#include "overlays/actors/ovl_En_Kbt/z_en_kbt.h" +#include "overlays/actors/ovl_Obj_Ice_Poly/z_obj_ice_poly.h" struct EnKgy; -typedef void (*EnKgyActionFunc)(struct EnKgy*, GlobalContext*); +typedef void (*EnKgyActionFunc)(struct EnKgy*, PlayState*); #define ENKGY_GET_1F(thisx) ((thisx)->params & 0x1F) #define ENKGY_GET_FE00(thisx) (((thisx)->params & 0xFE00) >> 9) 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 5a83ecad4..f928c2393 100644 --- a/src/overlays/actors/ovl_En_Kitan/z_en_kitan.c +++ b/src/overlays/actors/ovl_En_Kitan/z_en_kitan.c @@ -10,9 +10,9 @@ #define THIS ((EnKitan*)thisx) -void EnKitan_Init(Actor* thisx, GlobalContext* globalCtx); -void EnKitan_Destroy(Actor* thisx, GlobalContext* globalCtx); -void EnKitan_Update(Actor* thisx, GlobalContext* globalCtx); +void EnKitan_Init(Actor* thisx, PlayState* play); +void EnKitan_Destroy(Actor* thisx, PlayState* play); +void EnKitan_Update(Actor* thisx, PlayState* play); #if 0 const ActorInit En_Kitan_InitVars = { diff --git a/src/overlays/actors/ovl_En_Kitan/z_en_kitan.h b/src/overlays/actors/ovl_En_Kitan/z_en_kitan.h index d7149e877..2ef14c942 100644 --- a/src/overlays/actors/ovl_En_Kitan/z_en_kitan.h +++ b/src/overlays/actors/ovl_En_Kitan/z_en_kitan.h @@ -5,12 +5,12 @@ struct EnKitan; -typedef void (*EnKitanActionFunc)(struct EnKitan*, GlobalContext*); +typedef void (*EnKitanActionFunc)(struct EnKitan*, PlayState*); typedef struct EnKitan { - /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x194]; - /* 0x02D8 */ EnKitanActionFunc actionFunc; + /* 0x000 */ Actor actor; + /* 0x144 */ char unk_144[0x194]; + /* 0x2D8 */ EnKitanActionFunc actionFunc; } EnKitan; // size = 0x2DC extern const ActorInit En_Kitan_InitVars; diff --git a/src/overlays/actors/ovl_En_Knight/z_en_knight.c b/src/overlays/actors/ovl_En_Knight/z_en_knight.c index 8f6464411..095ca5a98 100644 --- a/src/overlays/actors/ovl_En_Knight/z_en_knight.c +++ b/src/overlays/actors/ovl_En_Knight/z_en_knight.c @@ -10,40 +10,40 @@ #define THIS ((EnKnight*)thisx) -void EnKnight_Init(Actor* thisx, GlobalContext* globalCtx); -void EnKnight_Destroy(Actor* thisx, GlobalContext* globalCtx); -void EnKnight_Update(Actor* thisx, GlobalContext* globalCtx); -void EnKnight_Draw(Actor* thisx, GlobalContext* globalCtx); +void EnKnight_Init(Actor* thisx, PlayState* play); +void EnKnight_Destroy(Actor* thisx, PlayState* play); +void EnKnight_Update(Actor* thisx, PlayState* play); +void EnKnight_Draw(Actor* thisx, PlayState* play); -void func_809B331C(EnKnight* this, GlobalContext* globalCtx); -void func_809B33F0(EnKnight* this, GlobalContext* globalCtx); -void func_809B3618(EnKnight* this, GlobalContext* globalCtx); -void func_809B3834(EnKnight* this, GlobalContext* globalCtx); -void func_809B3958(EnKnight* this, GlobalContext* globalCtx); -void func_809B3B94(EnKnight* this, GlobalContext* globalCtx); -void func_809B40E8(EnKnight* this, GlobalContext* globalCtx); -void func_809B41F8(EnKnight* this, GlobalContext* globalCtx); -void func_809B4308(EnKnight* this, GlobalContext* globalCtx); -void func_809B4C58(EnKnight* this, GlobalContext* globalCtx); -void func_809B4ED8(EnKnight* this, GlobalContext* globalCtx); -void func_809B5058(EnKnight* this, GlobalContext* globalCtx); -void func_809B52E8(EnKnight* this, GlobalContext* globalCtx); -void func_809B5698(EnKnight* this, GlobalContext* globalCtx); -void func_809B58D4(EnKnight* this, GlobalContext* globalCtx); -void func_809B5B08(EnKnight* this, GlobalContext* globalCtx); -void func_809B5D54(EnKnight* this, GlobalContext* globalCtx); -void func_809B5ED0(EnKnight* this, GlobalContext* globalCtx); -void func_809B601C(EnKnight* this, GlobalContext* globalCtx); -void func_809B6764(EnKnight* this, GlobalContext* globalCtx); -void func_809B6C54(EnKnight* this, GlobalContext* globalCtx); -void func_809B6D94(EnKnight* this, GlobalContext* globalCtx); -void func_809B6F40(EnKnight* this, GlobalContext* globalCtx); -void func_809B71DC(EnKnight* this, GlobalContext* globalCtx); -void func_809B7778(EnKnight* this, GlobalContext* globalCtx); -void func_809B7950(EnKnight* this, GlobalContext* globalCtx); -void func_809B8458(EnKnight* this, GlobalContext* globalCtx); -void func_809BA0CC(EnKnight* this, GlobalContext* globalCtx); -void func_809BA978(EnKnight* this, GlobalContext* globalCtx); +void func_809B331C(EnKnight* this, PlayState* play); +void func_809B33F0(EnKnight* this, PlayState* play); +void func_809B3618(EnKnight* this, PlayState* play); +void func_809B3834(EnKnight* this, PlayState* play); +void func_809B3958(EnKnight* this, PlayState* play); +void func_809B3B94(EnKnight* this, PlayState* play); +void func_809B40E8(EnKnight* this, PlayState* play); +void func_809B41F8(EnKnight* this, PlayState* play); +void func_809B4308(EnKnight* this, PlayState* play); +void func_809B4C58(EnKnight* this, PlayState* play); +void func_809B4ED8(EnKnight* this, PlayState* play); +void func_809B5058(EnKnight* this, PlayState* play); +void func_809B52E8(EnKnight* this, PlayState* play); +void func_809B5698(EnKnight* this, PlayState* play); +void func_809B58D4(EnKnight* this, PlayState* play); +void func_809B5B08(EnKnight* this, PlayState* play); +void func_809B5D54(EnKnight* this, PlayState* play); +void func_809B5ED0(EnKnight* this, PlayState* play); +void func_809B601C(EnKnight* this, PlayState* play); +void func_809B6764(EnKnight* this, PlayState* play); +void func_809B6C54(EnKnight* this, PlayState* play); +void func_809B6D94(EnKnight* this, PlayState* play); +void func_809B6F40(EnKnight* this, PlayState* play); +void func_809B71DC(EnKnight* this, PlayState* play); +void func_809B7778(EnKnight* this, PlayState* play); +void func_809B7950(EnKnight* this, PlayState* play); +void func_809B8458(EnKnight* this, PlayState* play); +void func_809BA0CC(EnKnight* this, PlayState* play); +void func_809BA978(EnKnight* this, PlayState* play); #if 0 // static DamageTable sDamageTable = { @@ -129,7 +129,7 @@ static ColliderJntSphElementInit D_809BDB44[1] = { // static ColliderJntSphInit sJntSphInit = { static ColliderJntSphInit D_809BDB8C = { { COLTYPE_METAL, AT_ON | AT_TYPE_ENEMY, AC_ON | AC_HARD | AC_TYPE_PLAYER, OC1_ON | OC1_TYPE_PLAYER, OC2_TYPE_1, COLSHAPE_JNTSPH, }, - 1, D_809BDB44, // sJntSphElementsInit, + ARRAY_COUNT(sJntSphElementsInit), D_809BDB44, // sJntSphElementsInit, }; // static ColliderJntSphElementInit sJntSphElementsInit[1] = { @@ -143,7 +143,7 @@ static ColliderJntSphElementInit D_809BDB68[1] = { // static ColliderJntSphInit sJntSphInit = { static ColliderJntSphInit D_809BDB9C = { { COLTYPE_METAL, AT_ON | AT_TYPE_ENEMY, AC_ON | AC_HARD | AC_TYPE_PLAYER, OC1_ON | OC1_TYPE_PLAYER, OC2_TYPE_1, COLSHAPE_JNTSPH, }, - 1, D_809BDB68, // sJntSphElementsInit, + ARRAY_COUNT(sJntSphElementsInit), D_809BDB68, // sJntSphElementsInit, }; // static ColliderJntSphElementInit sJntSphElementsInit[1] = { @@ -157,7 +157,7 @@ static ColliderJntSphElementInit D_809BDBAC[1] = { // static ColliderJntSphInit sJntSphInit = { static ColliderJntSphInit D_809BDBD0 = { { COLTYPE_METAL, AT_ON | AT_TYPE_ENEMY, AC_ON | AC_HARD | AC_TYPE_PLAYER, OC1_ON | OC1_TYPE_PLAYER, OC2_TYPE_1, COLSHAPE_JNTSPH, }, - 1, D_809BDBAC, // sJntSphElementsInit, + ARRAY_COUNT(sJntSphElementsInit), D_809BDBAC, // sJntSphElementsInit, }; // static ColliderJntSphElementInit sJntSphElementsInit[2] = { @@ -175,7 +175,7 @@ static ColliderJntSphElementInit D_809BDBE0[2] = { // static ColliderJntSphInit sJntSphInit = { static ColliderJntSphInit D_809BDC28 = { { COLTYPE_HIT3, AT_ON | AT_TYPE_ENEMY, AC_ON | AC_TYPE_PLAYER, OC1_ON | OC1_TYPE_PLAYER | OC1_TYPE_1, OC2_TYPE_1, COLSHAPE_JNTSPH, }, - 2, D_809BDBE0, // sJntSphElementsInit, + ARRAY_COUNT(sJntSphElementsInit), D_809BDBE0, // sJntSphElementsInit, }; // static ColliderCylinderInit sCylinderInit = { diff --git a/src/overlays/actors/ovl_En_Knight/z_en_knight.h b/src/overlays/actors/ovl_En_Knight/z_en_knight.h index 8191b13a2..167a96682 100644 --- a/src/overlays/actors/ovl_En_Knight/z_en_knight.h +++ b/src/overlays/actors/ovl_En_Knight/z_en_knight.h @@ -5,25 +5,25 @@ struct EnKnight; -typedef void (*EnKnightActionFunc)(struct EnKnight*, GlobalContext*); +typedef void (*EnKnightActionFunc)(struct EnKnight*, PlayState*); typedef struct EnKnight { - /* 0x0000 */ Actor actor; - /* 0x0144 */ s16 unk_144; - /* 0x0146 */ char unk_146[0x2]; - /* 0x0148 */ s8 unk_148; - /* 0x0149 */ char pad149[8]; - /* 0x0151 */ s8 unk_151; - /* 0x0152 */ char pad152[1]; - /* 0x0153 */ u8 unk_153; - /* 0x0154 */ u8 unk_154; - /* 0x0155 */ char pad155[0x2CB]; - /* 0x0420 */ EnKnightActionFunc actionFunc; - /* 0x0424 */ char unk_424[0x25C]; - /* 0x0680 */ u8 unk_680; - /* 0x0681 */ char pad681[9]; - /* 0x068A */ s16 unk_68A; - /* 0x068C */ char pad68C[0x48]; + /* 0x000 */ Actor actor; + /* 0x144 */ s16 unk_144; + /* 0x146 */ char unk_146[0x2]; + /* 0x148 */ s8 unk_148; + /* 0x149 */ char unk_149[0x8]; + /* 0x151 */ s8 unk_151; + /* 0x152 */ char unk_152[0x1]; + /* 0x153 */ u8 unk_153; + /* 0x154 */ u8 unk_154; + /* 0x155 */ char unk_155[0x2CB]; + /* 0x420 */ EnKnightActionFunc actionFunc; + /* 0x424 */ char unk_424[0x25C]; + /* 0x680 */ u8 unk_680; + /* 0x681 */ char unk_681[0x9]; + /* 0x68A */ s16 unk_68A; + /* 0x68C */ char pad68C[0x48]; } EnKnight; // size = 0x6D4 extern const ActorInit En_Knight_InitVars; diff --git a/src/overlays/actors/ovl_En_Kujiya/z_en_kujiya.c b/src/overlays/actors/ovl_En_Kujiya/z_en_kujiya.c index caf235b05..df95a6988 100644 --- a/src/overlays/actors/ovl_En_Kujiya/z_en_kujiya.c +++ b/src/overlays/actors/ovl_En_Kujiya/z_en_kujiya.c @@ -13,26 +13,26 @@ #define THIS ((EnKujiya*)thisx) -void EnKujiya_Init(Actor* thisx, GlobalContext* globalCtx); -void EnKujiya_Destroy(Actor* thisx, GlobalContext* globalCtx); -void EnKujiya_Update(Actor* thisx, GlobalContext* globalCtx); -void EnKujiya_Draw(Actor* thisx, GlobalContext* globalCtx); +void EnKujiya_Init(Actor* thisx, PlayState* play); +void EnKujiya_Destroy(Actor* thisx, PlayState* play); +void EnKujiya_Update(Actor* thisx, PlayState* play); +void EnKujiya_Draw(Actor* thisx, PlayState* play); void EnKujiya_SetupWait(EnKujiya* this); -void EnKujiya_Wait(EnKujiya* this, GlobalContext* globalCtx); +void EnKujiya_Wait(EnKujiya* this, PlayState* play); void EnKujiya_SetupTalk(EnKujiya* this); -void EnKujiya_Talk(EnKujiya* this, GlobalContext* globalCtx); +void EnKujiya_Talk(EnKujiya* this, PlayState* play); void EnKujiya_SetupGivePrize(EnKujiya* this); -void EnKujiya_GivePrize(EnKujiya* this, GlobalContext* globalCtx); +void EnKujiya_GivePrize(EnKujiya* this, PlayState* play); void EnKujiya_SetupFinishGivePrize(EnKujiya* this); -void EnKujiya_FinishGivePrize(EnKujiya* this, GlobalContext* globalCtx); +void EnKujiya_FinishGivePrize(EnKujiya* this, PlayState* play); 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_TurnToOpen(EnKujiya* this, PlayState* play); void EnKujiya_SetupTurnToClosed(EnKujiya* this); -void EnKujiya_TurnToClosed(EnKujiya* this, GlobalContext* globalCtx); +void EnKujiya_TurnToClosed(EnKujiya* this, PlayState* play); const ActorInit En_Kujiya_InitVars = { ACTOR_EN_KUJIYA, @@ -54,7 +54,7 @@ const ActorInit En_Kujiya_InitVars = { ((u32)((void)0, gSaveContext.save.lotteryCodes[CURRENT_DAY - 1][2]) == \ (((void)0, gSaveContext.save.lotteryCodeGuess & 0xFFFF) & 0xF))) -void EnKujiya_Init(Actor* thisx, GlobalContext* globalCtx) { +void EnKujiya_Init(Actor* thisx, PlayState* play) { EnKujiya* this = THIS; Actor_SetScale(&this->actor, 0.1f); @@ -74,28 +74,28 @@ void EnKujiya_Init(Actor* thisx, GlobalContext* globalCtx) { EnKujiya_SetupWait(this); } -void EnKujiya_Destroy(Actor* thisx, GlobalContext* globalCtx) { +void EnKujiya_Destroy(Actor* thisx, PlayState* play) { } void EnKujiya_SetupWait(EnKujiya* this) { this->actionFunc = EnKujiya_Wait; } -void EnKujiya_Wait(EnKujiya* this, GlobalContext* globalCtx) { - if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { +void EnKujiya_Wait(EnKujiya* this, PlayState* play) { + if (Actor_ProcessTalkRequest(&this->actor, &play->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); + Message_StartTextbox(play, 0x2B61, &this->actor); this->textId = 0x2B61; // Come back tomorrow } else { - Message_StartTextbox(globalCtx, 0x2B5C, &this->actor); + Message_StartTextbox(play, 0x2B5C, &this->actor); this->textId = 0x2B5C; // Pick 3 numbers } } else if (EnKujiya_CheckBoughtTicket()) { - Message_StartTextbox(globalCtx, 0x2B64, &this->actor); + Message_StartTextbox(play, 0x2B64, &this->actor); this->textId = 0x2B64; // Announce winning numbers } else { - Message_StartTextbox(globalCtx, 0x2B63, &this->actor); + Message_StartTextbox(play, 0x2B63, &this->actor); this->textId = 0x2B63; // Exchanging winning tickets } @@ -104,32 +104,32 @@ void EnKujiya_Wait(EnKujiya* this, GlobalContext* globalCtx) { (this->actor.shape.rot.y == 0)) { EnKujiya_SetupTurnToOpen(this); } else if (this->actor.xzDistToPlayer < 100.0f) { - func_800B8614(&this->actor, globalCtx, 100.0f); + func_800B8614(&this->actor, play, 100.0f); } } -void EnKujiya_HandlePlayerChoice(EnKujiya* this, GlobalContext* globalCtx) { - if (Message_ShouldAdvance(globalCtx)) { - if (globalCtx->msgCtx.choiceIndex == 0) { // Buy +void EnKujiya_HandlePlayerChoice(EnKujiya* this, PlayState* play) { + if (Message_ShouldAdvance(play)) { + if (play->msgCtx.choiceIndex == 0) { // Buy if (gSaveContext.save.playerData.rupees < 10) { play_sound(NA_SE_SY_ERROR); - Message_StartTextbox(globalCtx, 0x2B62, &this->actor); + Message_StartTextbox(play, 0x2B62, &this->actor); this->textId = 0x2B62; // Not enough Rupees } else { func_8019F208(); - func_801159EC(-10); - Message_StartTextbox(globalCtx, 0x2B5F, &this->actor); + Rupees_ChangeBy(-10); + Message_StartTextbox(play, 0x2B5F, &this->actor); this->textId = 0x2B5F; // Enter number } } else { // Don't buy func_8019F230(); - Message_StartTextbox(globalCtx, 0x2B5E, &this->actor); + Message_StartTextbox(play, 0x2B5E, &this->actor); this->textId = 0x2B5E; // Too bad } } } -void EnKujiya_ChooseNextDialogue(EnKujiya* this, GlobalContext* globalCtx) { +void EnKujiya_ChooseNextDialogue(EnKujiya* this, PlayState* play) { // Build suspense if (this->textId == 0x2B65) { // Your numbers vs winning numbers if (this->timer != 0) { @@ -138,40 +138,40 @@ void EnKujiya_ChooseNextDialogue(EnKujiya* this, GlobalContext* globalCtx) { } } - if (Message_ShouldAdvance(globalCtx)) { + if (Message_ShouldAdvance(play)) { switch (this->textId) { case 0x2B5C: - Message_StartTextbox(globalCtx, 0x2B5D, &this->actor); + Message_StartTextbox(play, 0x2B5D, &this->actor); this->textId = 0x2B5D; // Buy or not break; case 0x2B60: EnKujiya_SetBoughtTicket(); - func_801477B4(globalCtx); + func_801477B4(play); EnKujiya_SetupTurnToClosed(this); break; case 0x2B64: EnKujiya_UnsetBoughtTicket(); this->timer = 20; - Message_StartTextbox(globalCtx, 0x2B65, &this->actor); + Message_StartTextbox(play, 0x2B65, &this->actor); this->textId = 0x2B65; // Your numbers vs winning numbers break; case 0x2B65: if (CHECK_LOTTERY_NUMBERS) { - Message_StartTextbox(globalCtx, 0x2B66, &this->actor); + Message_StartTextbox(play, 0x2B66, &this->actor); this->textId = 0x2B66; // Won 50 Rupees } else { - Message_StartTextbox(globalCtx, 0x2B67, &this->actor); + Message_StartTextbox(play, 0x2B67, &this->actor); this->textId = 0x2B67; // Lost, come back tomorrow } break; case 0x2B66: - func_801477B4(globalCtx); + func_801477B4(play); EnKujiya_SetupGivePrize(this); - EnKujiya_GivePrize(this, globalCtx); + EnKujiya_GivePrize(this, play); break; } } @@ -181,29 +181,29 @@ void EnKujiya_SetupTalk(EnKujiya* this) { this->actionFunc = EnKujiya_Talk; } -void EnKujiya_Talk(EnKujiya* this, GlobalContext* globalCtx) { - switch (Message_GetState(&globalCtx->msgCtx)) { - case 0: +void EnKujiya_Talk(EnKujiya* this, PlayState* play) { + switch (Message_GetState(&play->msgCtx)) { + case TEXT_STATE_NONE: break; - case 4: - EnKujiya_HandlePlayerChoice(this, globalCtx); + case TEXT_STATE_CHOICE: + EnKujiya_HandlePlayerChoice(this, play); break; - case 5: - EnKujiya_ChooseNextDialogue(this, globalCtx); + case TEXT_STATE_5: + EnKujiya_ChooseNextDialogue(this, play); break; - case 6: - if (Message_ShouldAdvance(globalCtx)) { + case TEXT_STATE_DONE: + if (Message_ShouldAdvance(play)) { EnKujiya_SetupWait(this); } break; - case 17: - if (Message_ShouldAdvance(globalCtx)) { - Inventory_SaveLotteryCodeGuess(globalCtx); - Message_StartTextbox(globalCtx, 0x2B60, &this->actor); + case TEXT_STATE_17: + if (Message_ShouldAdvance(play)) { + Inventory_SaveLotteryCodeGuess(play); + Message_StartTextbox(play, 0x2B60, &this->actor); this->textId = 0x2B60; // Will announce winning numbers after 6 } break; @@ -214,11 +214,11 @@ void EnKujiya_SetupGivePrize(EnKujiya* this) { this->actionFunc = EnKujiya_GivePrize; } -void EnKujiya_GivePrize(EnKujiya* this, GlobalContext* globalCtx) { - if (Actor_HasParent(&this->actor, globalCtx)) { +void EnKujiya_GivePrize(EnKujiya* this, PlayState* play) { + if (Actor_HasParent(&this->actor, play)) { EnKujiya_SetupFinishGivePrize(this); } else { - Actor_PickUp(&this->actor, globalCtx, GI_RUPEE_PURPLE, 500.0f, 100.0f); + Actor_PickUp(&this->actor, play, GI_RUPEE_PURPLE, 500.0f, 100.0f); } } @@ -226,8 +226,8 @@ 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)) { +void EnKujiya_FinishGivePrize(EnKujiya* this, PlayState* play) { + if ((Message_GetState(&play->msgCtx) == TEXT_STATE_DONE) && Message_ShouldAdvance(play)) { EnKujiya_SetupWait(this); } } @@ -295,7 +295,7 @@ void EnKujiya_SetupTurnToOpen(EnKujiya* this) { this->actionFunc = EnKujiya_TurnToOpen; } -void EnKujiya_TurnToOpen(EnKujiya* this, GlobalContext* globalCtx) { +void EnKujiya_TurnToOpen(EnKujiya* this, PlayState* play) { if (this->actor.cutscene != -1) { if (ActorCutscene_GetCanPlayNext(this->actor.cutscene)) { ActorCutscene_StartAndSetUnkLinkFields(this->actor.cutscene, &this->actor); @@ -323,7 +323,7 @@ void EnKujiya_SetupTurnToClosed(EnKujiya* this) { this->actionFunc = EnKujiya_TurnToClosed; } -void EnKujiya_TurnToClosed(EnKujiya* this, GlobalContext* globalCtx) { +void EnKujiya_TurnToClosed(EnKujiya* this, PlayState* play) { if (this->actor.cutscene != -1) { if (ActorCutscene_GetCanPlayNext(this->actor.cutscene)) { ActorCutscene_StartAndSetUnkLinkFields(this->actor.cutscene, &this->actor); @@ -346,22 +346,22 @@ void EnKujiya_TurnToClosed(EnKujiya* this, GlobalContext* globalCtx) { } } -void EnKujiya_Update(Actor* thisx, GlobalContext* globalCtx) { +void EnKujiya_Update(Actor* thisx, PlayState* play) { EnKujiya* this = THIS; - this->actionFunc(this, globalCtx); + this->actionFunc(this, play); } -void EnKujiya_Draw(Actor* thisx, GlobalContext* globalCtx) { +void EnKujiya_Draw(Actor* thisx, PlayState* play) { EnKujiya* this = THIS; - AnimatedMat_Draw(globalCtx, Lib_SegmentedToVirtual(gLotteryShopTexAnim)); + AnimatedMat_Draw(play, Lib_SegmentedToVirtual(gLotteryShopTexAnim)); - OPEN_DISPS(globalCtx->state.gfxCtx); + OPEN_DISPS(play->state.gfxCtx); - func_8012C28C(globalCtx->state.gfxCtx); + func_8012C28C(play->state.gfxCtx); - gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(play->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); @@ -373,5 +373,5 @@ void EnKujiya_Draw(Actor* thisx, GlobalContext* globalCtx) { gSPDisplayList(POLY_OPA_DISP++, gLotteryShopScrollingArrowDL); gSPDisplayList(POLY_OPA_DISP++, gLotteryShopMaskDL); - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->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 b95a5bb36..69fad156e 100644 --- a/src/overlays/actors/ovl_En_Kujiya/z_en_kujiya.h +++ b/src/overlays/actors/ovl_En_Kujiya/z_en_kujiya.h @@ -5,7 +5,7 @@ struct EnKujiya; -typedef void (*EnKujiyaActionFunc)(struct EnKujiya*, GlobalContext*); +typedef void (*EnKujiyaActionFunc)(struct EnKujiya*, PlayState*); typedef struct EnKujiya { /* 0x000 */ Actor actor; 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 02bd93aef..dc3ecc56c 100644 --- a/src/overlays/actors/ovl_En_Kusa/z_en_kusa.c +++ b/src/overlays/actors/ovl_En_Kusa/z_en_kusa.c @@ -4,6 +4,7 @@ * Description: Grass / Bush */ +#include "prevent_bss_reordering.h" #include "z_en_kusa.h" #include "objects/object_kusa/object_kusa.h" #include "objects/gameplay_keep/gameplay_keep.h" @@ -13,34 +14,34 @@ #define THIS ((EnKusa*)thisx) -void EnKusa_Init(Actor* thisx, GlobalContext* globalCtx); -void EnKusa_Destroy(Actor* thisx, GlobalContext* globalCtx); -void EnKusa_Update(Actor* thisx, GlobalContext* globalCtx); +void EnKusa_Init(Actor* thisx, PlayState* play); +void EnKusa_Destroy(Actor* thisx, PlayState* play); +void EnKusa_Update(Actor* thisx, PlayState* play); -s32 EnKusa_SnapToFloor(EnKusa* this, GlobalContext* globalCtx, f32 yOffset); -void EnKusa_DropCollectible(EnKusa* this, GlobalContext* globalCtx); +s32 EnKusa_SnapToFloor(EnKusa* this, PlayState* play, f32 yOffset); +void EnKusa_DropCollectible(EnKusa* this, PlayState* play); void EnKusa_UpdateVelY(EnKusa* this); void EnKusa_RandScaleVecToZero(Vec3f* vec, f32 scaleFactor); void EnKusa_SetScaleSmall(EnKusa* this); -s32 EnKusa_GetWaterBox(EnKusa* this, GlobalContext* globalCtx); +s32 EnKusa_GetWaterBox(EnKusa* this, PlayState* play); void EnKusa_SetupWaitObject(EnKusa* this); -void EnKusa_WaitObject(EnKusa* this, GlobalContext* globalCtx); -void EnKusa_WaitForInteract(EnKusa* this, GlobalContext* globalCtx); +void EnKusa_WaitObject(EnKusa* this, PlayState* play); +void EnKusa_WaitForInteract(EnKusa* this, PlayState* play); void EnKusa_SetupLiftedUp(EnKusa* this); -void EnKusa_LiftedUp(EnKusa* this, GlobalContext* globalCtx); -void EnKusa_WaitObject(EnKusa* this, GlobalContext* globalCtx); +void EnKusa_LiftedUp(EnKusa* this, PlayState* play); +void EnKusa_WaitObject(EnKusa* this, PlayState* play); void EnKusa_SetupInteract(EnKusa* this); void EnKusa_SetupFall(EnKusa* this); -void EnKusa_Fall(EnKusa* this, GlobalContext* globalCtx); +void EnKusa_Fall(EnKusa* this, PlayState* play); void EnKusa_SetupCut(EnKusa* this); -void EnKusa_CutWaitRegrow(EnKusa* this, GlobalContext* globalCtx); -void EnKusa_DoNothing(EnKusa* this, GlobalContext* globalCtx); +void EnKusa_CutWaitRegrow(EnKusa* this, PlayState* play); +void EnKusa_DoNothing(EnKusa* this, PlayState* play); void EnKusa_SetupUprootedWaitRegrow(EnKusa* this); -void EnKusa_UprootedWaitRegrow(EnKusa* this, GlobalContext* globalCtx); +void EnKusa_UprootedWaitRegrow(EnKusa* this, PlayState* play); 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); +void EnKusa_Regrow(EnKusa* this, PlayState* play); +void EnKusa_DrawBush(Actor* thisx, PlayState* play2); +void EnKusa_DrawGrass(Actor* thisx, PlayState* play); s16 rotSpeedXtarget = 0; s16 rotSpeedX = 0; @@ -116,7 +117,7 @@ static InitChainEntry sInitChain[] = { * */ void EnKusa_ApplySway(MtxF* matrix) { - MtxF* mtxState = Matrix_GetCurrentState(); + MtxF* mtxState = Matrix_GetCurrent(); f32* tmp = &mtxState->mf[0][0]; f32* tmp2 = &matrix->mf[0][0]; s32 i; @@ -214,11 +215,11 @@ void EnKusa_Sway(void) { * if no poit is found, a false value is returned. * * @param this - * @param globalCtx + * @param play * @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 EnKusa_SnapToFloor(EnKusa* this, PlayState* play, f32 yOffset) { s32 pad; CollisionPoly* poly; Vec3f pos; @@ -229,7 +230,7 @@ s32 EnKusa_SnapToFloor(EnKusa* this, GlobalContext* globalCtx, f32 yOffset) { pos.y = this->actor.world.pos.y + 30.0f; pos.z = this->actor.world.pos.z; - floorY = BgCheck_EntityRaycastFloor5(&globalCtx->colCtx, &poly, &bgId, &this->actor, &pos); + floorY = BgCheck_EntityRaycastFloor5(&play->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); @@ -239,22 +240,22 @@ s32 EnKusa_SnapToFloor(EnKusa* this, GlobalContext* globalCtx, f32 yOffset) { } } -void EnKusa_DropCollectible(EnKusa* this, GlobalContext* globalCtx) { +void EnKusa_DropCollectible(EnKusa* this, PlayState* play) { s32 collectible; s32 collectableParams; - if ((GET_KUSA_TYPE(&this->actor) == ENKUSA_TYPE_GRASS) || (GET_KUSA_TYPE(&this->actor) == ENKUSA_TYPE_BUSH)) { - if (!(KUSA_GET_PARAMS_0C(&this->actor))) { - Item_DropCollectibleRandom(globalCtx, NULL, &this->actor.world.pos, + if ((KUSA_GET_TYPE(&this->actor) == ENKUSA_TYPE_GRASS) || (KUSA_GET_TYPE(&this->actor) == ENKUSA_TYPE_BUSH)) { + if (!KUSA_GET_PARAMS_0C(&this->actor)) { + Item_DropCollectibleRandom(play, 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 if (KUSA_GET_TYPE(&this->actor) == ENKUSA_TYPE_REGROWING_GRASS) { + Item_DropCollectible(play, &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); + Item_DropCollectible(play, &this->actor.world.pos, (collectableParams << 8) | collectible); } } } @@ -285,7 +286,7 @@ void EnKusa_SetScaleSmall(EnKusa* this) { this->actor.scale.z = 120.0f * 0.001f; } -void EnKusa_SpawnFragments(EnKusa* this, GlobalContext* globalCtx) { +void EnKusa_SpawnFragments(EnKusa* this, PlayState* play) { Vec3f velocity; Vec3f pos; s32 i; @@ -305,8 +306,8 @@ void EnKusa_SpawnFragments(EnKusa* this, GlobalContext* globalCtx) { scaleIndex = (s32)(Rand_ZeroOne() * 111.1f) & 7; - EffectSsKakera_Spawn(globalCtx, &pos, &velocity, &pos, -100, 64, 40, 3, 0, sFragmentScales[scaleIndex], 0, 0, - 0x50, -1, 1, gKakeraLeafMiddle); + EffectSsKakera_Spawn(play, &pos, &velocity, &pos, -100, 64, 40, 3, 0, sFragmentScales[scaleIndex], 0, 0, 0x50, + -1, 1, gKakeraLeafMiddle); 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; @@ -317,18 +318,18 @@ void EnKusa_SpawnFragments(EnKusa* this, GlobalContext* globalCtx) { scaleIndex = (s32)(Rand_ZeroOne() * 111.1f) % 7; - EffectSsKakera_Spawn(globalCtx, &pos, &velocity, &pos, -100, 64, 40, 3, 0, sFragmentScales[scaleIndex], 0, 0, - 0x50, -1, 1, gKakeraLeafTip); + EffectSsKakera_Spawn(play, &pos, &velocity, &pos, -100, 64, 40, 3, 0, sFragmentScales[scaleIndex], 0, 0, 0x50, + -1, 1, gKakeraLeafTip); } } -void EnKusa_SpawnBugs(EnKusa* this, GlobalContext* globalCtx) { +void EnKusa_SpawnBugs(EnKusa* this, PlayState* play) { u32 numBugs; 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); + Actor* bug = Actor_SpawnAsChildAndCutscene(&play->actorCtx, play, ACTOR_EN_INSECT, this->actor.world.pos.x, + this->actor.world.pos.y, this->actor.world.pos.z, 0, 0, 0, 1, + this->actor.cutscene, this->actor.unk20, 0); if (bug == NULL) { break; @@ -336,39 +337,39 @@ void EnKusa_SpawnBugs(EnKusa* this, GlobalContext* globalCtx) { } } -s32 EnKusa_GetWaterBox(EnKusa* this, GlobalContext* globalCtx) { +s32 EnKusa_GetWaterBox(EnKusa* this, PlayState* play) { s32 pad; WaterBox* waterBox; f32 ySurface; s32 bgId; - if (WaterBox_GetSurfaceImpl(globalCtx, &globalCtx->colCtx, this->actor.world.pos.x, this->actor.world.pos.z, - &ySurface, &waterBox, &bgId) && + if (WaterBox_GetSurfaceImpl(play, &play->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) { +void EnKusa_InitCollider(Actor* thisx, PlayState* play) { EnKusa* this = THIS; - Collider_InitCylinder(globalCtx, &this->collider); - Collider_SetCylinder(globalCtx, &this->collider, &this->actor, &sCylinderInit); + Collider_InitCylinder(play, &this->collider); + Collider_SetCylinder(play, &this->collider, &this->actor, &sCylinderInit); Collider_UpdateCylinder(thisx, &this->collider); } -void EnKusa_Init(Actor* thisx, GlobalContext* globalCtx) { +void EnKusa_Init(Actor* thisx, PlayState* play) { EnKusa* this = THIS; s32 pad; - s32 kusaType = GET_KUSA_TYPE(&this->actor); + s32 kusaType = KUSA_GET_TYPE(&this->actor); Actor_ProcessInitChain(&this->actor, sInitChain); - if (globalCtx->csCtx.state != 0) { + if (play->csCtx.state != 0) { this->actor.uncullZoneForward += 1000.0f; } - EnKusa_InitCollider(&this->actor, globalCtx); + EnKusa_InitCollider(&this->actor, play); CollisionCheck_SetInfo(&this->actor.colChkInfo, NULL, &sColChkInfoInit); if (kusaType == ENKUSA_TYPE_BUSH) { @@ -380,19 +381,19 @@ void EnKusa_Init(Actor* thisx, GlobalContext* globalCtx) { } if (this->actor.shape.rot.y == 0) { - this->actor.shape.rot.y = ((u32)Rand_Next() >> 0x10); + 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)) { + if (!EnKusa_SnapToFloor(this, play, 0.0f)) { Actor_MarkForDeath(&this->actor); return; } - if (EnKusa_GetWaterBox(this, globalCtx)) { + if (EnKusa_GetWaterBox(this, play)) { this->isInWater |= 1; } - this->objIndex = Object_GetIndex(&globalCtx->objectCtx, objectIds[(GET_KUSA_TYPE(&this->actor))]); + this->objIndex = Object_GetIndex(&play->objectCtx, objectIds[(KUSA_GET_TYPE(&this->actor))]); if (this->objIndex < 0) { Actor_MarkForDeath(&this->actor); return; @@ -400,35 +401,35 @@ void EnKusa_Init(Actor* thisx, GlobalContext* globalCtx) { EnKusa_SetupWaitObject(this); if (D_809366B4) { - D_80936CD8 = ((u32)Rand_Next() >> 0x10); - D_80936CDA = ((u32)Rand_Next() >> 0x10); - D_80936CDC = ((u32)Rand_Next() >> 0x10); - D_80936CDE = ((u32)Rand_Next() >> 0x10); - D_80936CE0 = ((u32)Rand_Next() >> 0x10); + D_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; + kusaGameplayFrames = play->gameplayFrames; } this->kusaMtxIdx = D_809366B0 & 7; D_809366B0++; } -void EnKusa_Destroy(Actor* thisx, GlobalContext* globalCtx) { - GlobalContext* globalCtx2 = globalCtx; +void EnKusa_Destroy(Actor* thisx, PlayState* play) { + PlayState* play2 = play; EnKusa* this = THIS; - Collider_DestroyCylinder(globalCtx, &this->collider); + Collider_DestroyCylinder(play, &this->collider); } void EnKusa_SetupWaitObject(EnKusa* this) { this->actionFunc = EnKusa_WaitObject; } -void EnKusa_WaitObject(EnKusa* this, GlobalContext* globalCtx) { +void EnKusa_WaitObject(EnKusa* this, PlayState* play) { s32 pad; - if (Object_IsLoaded(&globalCtx->objectCtx, this->objIndex)) { - s32 kusaType = GET_KUSA_TYPE(&this->actor); + if (Object_IsLoaded(&play->objectCtx, this->objIndex)) { + s32 kusaType = KUSA_GET_TYPE(&this->actor); if (this->isCut) { EnKusa_SetupCut(this); @@ -450,26 +451,26 @@ void EnKusa_SetupInteract(EnKusa* this) { this->actor.flags &= ~ACTOR_FLAG_10; } -void EnKusa_WaitForInteract(EnKusa* this, GlobalContext* globalCtx) { +void EnKusa_WaitForInteract(EnKusa* this, PlayState* play) { s32 pad; - if (Actor_HasParent(&this->actor, globalCtx)) { + if (Actor_HasParent(&this->actor, play)) { EnKusa_SetupLiftedUp(this); - SoundSource_PlaySfxAtFixedWorldPos(globalCtx, &this->actor.world.pos, 20, NA_SE_PL_PULL_UP_PLANT); + SoundSource_PlaySfxAtFixedWorldPos(play, &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); + EnKusa_SpawnFragments(this, play); + EnKusa_DropCollectible(this, play); + SoundSource_PlaySfxAtFixedWorldPos(play, &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 (KUSA_GET_TYPE(&this->actor) != ENKUSA_TYPE_GRASS_2) { + EnKusa_SpawnBugs(this, play); } } - if (GET_KUSA_TYPE(&this->actor) == ENKUSA_TYPE_BUSH) { + if (KUSA_GET_TYPE(&this->actor) == ENKUSA_TYPE_BUSH) { Actor_MarkForDeath(&this->actor); } else { EnKusa_SetupCut(this); @@ -483,13 +484,13 @@ void EnKusa_WaitForInteract(EnKusa* this, GlobalContext* globalCtx) { if (this->actor.xzDistToPlayer < 600.0f) { Collider_UpdateCylinder(&this->actor, &this->collider); - CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + CollisionCheck_SetAC(play, &play->colChkCtx, &this->collider.base); if (this->actor.xzDistToPlayer < 400.0f) { - CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + CollisionCheck_SetOC(play, &play->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); + if (KUSA_GET_TYPE(&this->actor) != ENKUSA_TYPE_GRASS_2) { + Actor_LiftActor(&this->actor, play); } } } @@ -503,13 +504,13 @@ void EnKusa_SetupLiftedUp(EnKusa* this) { this->actor.flags |= ACTOR_FLAG_10; } -void EnKusa_LiftedUp(EnKusa* this, GlobalContext* globalCtx) { +void EnKusa_LiftedUp(EnKusa* this, PlayState* play) { s32 pad; Vec3f pos; s32 bgId; - if (Actor_HasNoParent(&this->actor, globalCtx)) { - this->actor.room = globalCtx->roomCtx.currRoom.num; + if (Actor_HasNoParent(&this->actor, play)) { + this->actor.room = play->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); @@ -518,14 +519,14 @@ void EnKusa_LiftedUp(EnKusa* this, GlobalContext* globalCtx) { 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); + Actor_UpdateBgCheckInfo(play, &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); + BgCheck_EntityRaycastFloor5(&play->colCtx, &this->actor.floorPoly, &bgId, &this->actor, &pos); } } @@ -538,7 +539,7 @@ void EnKusa_SetupFall(EnKusa* this) { this->timer = 0; } -void EnKusa_Fall(EnKusa* this, GlobalContext* globalCtx) { +void EnKusa_Fall(EnKusa* this, PlayState* play) { s32 pad; s32 wasHit; Vec3f contactPos; @@ -553,11 +554,11 @@ void EnKusa_Fall(EnKusa* this, GlobalContext* globalCtx) { 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); + SoundSource_PlaySfxAtFixedWorldPos(play, &this->actor.world.pos, 20, NA_SE_EV_PLANT_BROKEN); } - EnKusa_SpawnFragments(this, globalCtx); - EnKusa_DropCollectible(this, globalCtx); - switch (GET_KUSA_TYPE(&this->actor)) { + EnKusa_SpawnFragments(this, play); + EnKusa_DropCollectible(this, play); + switch (KUSA_GET_TYPE(&this->actor)) { case ENKUSA_TYPE_BUSH: case ENKUSA_TYPE_GRASS: Actor_MarkForDeath(&this->actor); @@ -577,12 +578,12 @@ void EnKusa_Fall(EnKusa* this, GlobalContext* globalCtx) { (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); + EffectSsGSplash_Spawn(play, &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); + EffectSsGSplash_Spawn(play, &contactPos, NULL, NULL, 0, 280); + EffectSsGRipple_Spawn(play, &contactPos, 300, 700, 0); this->actor.terminalVelocity = -3.0f; this->actor.velocity.x *= 0.1f; this->actor.velocity.y *= 0.4f; @@ -593,7 +594,7 @@ void EnKusa_Fall(EnKusa* this, GlobalContext* globalCtx) { rotSpeedY >>= 1; rotSpeedYtarget >>= 1; this->actor.bgCheckFlags &= ~0x40; - SoundSource_PlaySfxAtFixedWorldPos(globalCtx, &this->actor.world.pos, 40, NA_SE_EV_DIVE_INTO_WATER_L); + SoundSource_PlaySfxAtFixedWorldPos(play, &this->actor.world.pos, 40, NA_SE_EV_DIVE_INTO_WATER_L); } EnKusa_UpdateVelY(this); Math_StepToS(&rotSpeedX, rotSpeedXtarget, 500); @@ -602,15 +603,15 @@ void EnKusa_Fall(EnKusa* this, GlobalContext* globalCtx) { 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); + Actor_UpdateBgCheckInfo(play, &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); + CollisionCheck_SetAT(play, &play->colChkCtx, &this->collider.base); + CollisionCheck_SetOC(play, &play->colChkCtx, &this->collider.base); } } void EnKusa_SetupCut(EnKusa* this) { - switch (GET_KUSA_TYPE(&this->actor)) { + switch (KUSA_GET_TYPE(&this->actor)) { case ENKUSA_TYPE_GRASS: case ENKUSA_TYPE_GRASS_2: this->actionFunc = EnKusa_DoNothing; @@ -622,14 +623,14 @@ void EnKusa_SetupCut(EnKusa* this) { this->timer = 0; } -void EnKusa_CutWaitRegrow(EnKusa* this, GlobalContext* globalCtx) { +void EnKusa_CutWaitRegrow(EnKusa* this, PlayState* play) { this->timer++; if (this->timer >= 120) { EnKusa_SetupRegrow(this); } } -void EnKusa_DoNothing(EnKusa* this, GlobalContext* globalCtx) { +void EnKusa_DoNothing(EnKusa* this, PlayState* play) { } void EnKusa_SetupUprootedWaitRegrow(EnKusa* this) { @@ -642,7 +643,7 @@ void EnKusa_SetupUprootedWaitRegrow(EnKusa* this) { this->actionFunc = EnKusa_UprootedWaitRegrow; } -void EnKusa_UprootedWaitRegrow(EnKusa* this, GlobalContext* globalCtx) { +void EnKusa_UprootedWaitRegrow(EnKusa* this, PlayState* play) { this->timer++; if (this->timer > 120) { if (Math_StepToF(&this->actor.world.pos.y, this->actor.home.pos.y, 0.6f) && (this->timer >= 170)) { @@ -658,7 +659,7 @@ void EnKusa_SetupRegrow(EnKusa* this) { this->actor.shape.rot = this->actor.home.rot; } -void EnKusa_Regrow(EnKusa* this, GlobalContext* globalCtx) { +void EnKusa_Regrow(EnKusa* this, PlayState* play) { s32 isFullyGrown = 1; isFullyGrown &= Math_StepToF(&this->actor.scale.y, 0.4f, 0.014f); @@ -671,63 +672,63 @@ void EnKusa_Regrow(EnKusa* this, GlobalContext* globalCtx) { } } -void EnKusa_Update(Actor* thisx, GlobalContext* globalCtx2) { - GlobalContext* globalCtx = globalCtx2; +void EnKusa_Update(Actor* thisx, PlayState* play2) { + PlayState* play = play2; EnKusa* this = THIS; - this->actionFunc(this, globalCtx); + this->actionFunc(this, play); 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)) { + if ((kusaGameplayFrames != play->gameplayFrames) && (play->roomCtx.currRoom.unk3 == 0)) { EnKusa_Sway(); - kusaGameplayFrames = globalCtx->gameplayFrames; + kusaGameplayFrames = play->gameplayFrames; } } -void EnKusa_DrawBush(Actor* thisx, GlobalContext* globalCtx2) { - GlobalContext* globalCtx = globalCtx2; +void EnKusa_DrawBush(Actor* thisx, PlayState* play2) { + PlayState* play = play2; 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) && + if ((play->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); + Gfx_DrawDListOpa(play, gKusaBushType1); } else if (this->actor.projectedPos.z < 1300.0f) { s32 alpha; - OPEN_DISPS(globalCtx->state.gfxCtx); + OPEN_DISPS(play->state.gfxCtx); alpha = (1300.0f - this->actor.projectedPos.z) * 2.55f; - func_8012C2DC(globalCtx->state.gfxCtx); + func_8012C2DC(play->state.gfxCtx); - gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 255, 255, 255, alpha); gSPDisplayList(POLY_XLU_DISP++, gKusaBushType2); - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->state.gfxCtx); } } -void EnKusa_DrawGrass(Actor* thisx, GlobalContext* globalCtx) { +void EnKusa_DrawGrass(Actor* thisx, PlayState* play) { EnKusa* this = THIS; if (this->isCut) { - Gfx_DrawDListOpa(globalCtx, gKusaStump); + Gfx_DrawDListOpa(play, gKusaStump); } else { - if ((globalCtx->roomCtx.currRoom.unk3 == 0) && (this->actionFunc == EnKusa_WaitForInteract)) { + if ((play->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); + Gfx_DrawDListOpa(play, 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 2f0d29dd9..eca474d5f 100644 --- a/src/overlays/actors/ovl_En_Kusa/z_en_kusa.h +++ b/src/overlays/actors/ovl_En_Kusa/z_en_kusa.h @@ -5,7 +5,7 @@ struct EnKusa; -typedef void (*EnKusaActionFunc)(struct EnKusa*, GlobalContext*); +typedef void (*EnKusaActionFunc)(struct EnKusa*, PlayState*); typedef enum { /* 0 */ ENKUSA_TYPE_BUSH, @@ -27,13 +27,13 @@ typedef struct EnKusa { extern const ActorInit En_Kusa_InitVars; -#define KUSA_GET_COLLECTIBLE_ID(thisx) ((((thisx)->params >> 8) & 0x7F)) +#define KUSA_GET_COLLECTIBLE_ID(thisx) (((thisx)->params >> 8) & 0x7F) #define KUSA_GET_RAND_COLLECTIBLE_ID(thisx) (((thisx)->params >> 8) & 0xF) #define KUSA_SHOULD_SPAWN_BUGS(thisx) (((thisx)->params >> 0x4) & 1) #define KUSA_GET_PARAMS_0C(thisx) (((thisx)->params >> 0xC) & 0x1) #define KUSA_GET_PARAMS_3F(thisx) (((thisx)->params >> 0x2) & 0x3F) -#define GET_KUSA_TYPE(thisx)((thisx)->params & 0x3) +#define KUSA_GET_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 1b8d1ccbc..435d31972 100644 --- a/src/overlays/actors/ovl_En_Kusa2/z_en_kusa2.c +++ b/src/overlays/actors/ovl_En_Kusa2/z_en_kusa2.c @@ -4,6 +4,7 @@ * Description: Keaton grass */ +#include "prevent_bss_reordering.h" #include "z_en_kusa2.h" #include "objects/gameplay_field_keep/gameplay_field_keep.h" #include "objects/gameplay_keep/gameplay_keep.h" @@ -12,37 +13,37 @@ #define THIS ((EnKusa2*)thisx) -void EnKusa2_Init(Actor* thisx, GlobalContext* globalCtx); -void EnKusa2_Destroy(Actor* thisx, GlobalContext* globalCtx); -void EnKusa2_Update(Actor* thisx, GlobalContext* globalCtx); -void EnKusa2_Draw(Actor* thisx, GlobalContext* globalCtx); +void EnKusa2_Init(Actor* thisx, PlayState* play); +void EnKusa2_Destroy(Actor* thisx, PlayState* play); +void EnKusa2_Update(Actor* thisx, PlayState* play); +void EnKusa2_Draw(Actor* thisx, PlayState* play); void func_80A5C70C(EnKusa2UnkBssSubStruct* arg0); void func_80A5CF44(EnKusa2* this); void func_80A5D5E0(EnKusa2* this); -void func_80A5D5F4(EnKusa2* this, GlobalContext* globalCtx); +void func_80A5D5F4(EnKusa2* this, PlayState* play); void func_80A5D618(EnKusa2* this); -void func_80A5D62C(EnKusa2* this, GlobalContext* globalCtx); +void func_80A5D62C(EnKusa2* this, PlayState* play); void func_80A5D6B0(EnKusa2* this); -void func_80A5D6C4(EnKusa2* this, GlobalContext* globalCtx); +void func_80A5D6C4(EnKusa2* this, PlayState* play); void func_80A5D754(EnKusa2* this); -void func_80A5D794(EnKusa2* this, GlobalContext* globalCtx); +void func_80A5D794(EnKusa2* this, PlayState* play); void func_80A5D7A4(EnKusa2* this); -void func_80A5D7C4(EnKusa2* this, GlobalContext* globalCtx); +void func_80A5D7C4(EnKusa2* this, PlayState* play); void func_80A5D964(EnKusa2* this); -void func_80A5D9C8(EnKusa2* this, GlobalContext* globalCtx); +void func_80A5D9C8(EnKusa2* this, PlayState* play); void func_80A5DC70(EnKusa2* this); -void func_80A5DC98(EnKusa2* this, GlobalContext* globalCtx); +void func_80A5DC98(EnKusa2* this, PlayState* play); void func_80A5DE18(EnKusa2* this); -void func_80A5DEB4(EnKusa2* this, GlobalContext* globalCtx); +void func_80A5DEB4(EnKusa2* this, PlayState* play); void func_80A5E1D8(EnKusa2* this); -void func_80A5E210(EnKusa2* this, GlobalContext* globalCtx); +void func_80A5E210(EnKusa2* this, PlayState* play); void func_80A5E418(EnKusa2* this); -void func_80A5E4BC(EnKusa2* this, GlobalContext* globalCtx); -void func_80A5E604(Actor* thisx, GlobalContext* globalCtx); -void func_80A5E6F0(Actor* thisx, GlobalContext* globalCtx); -void func_80A5E9B4(Actor* thisx, GlobalContext* globalCtx); -void func_80A5EA48(Actor* thisx, GlobalContext* globalCtx); +void func_80A5E4BC(EnKusa2* this, PlayState* play); +void func_80A5E604(Actor* thisx, PlayState* play); +void func_80A5E6F0(Actor* thisx, PlayState* play); +void func_80A5E9B4(Actor* thisx, PlayState* play); +void func_80A5EA48(Actor* thisx, PlayState* play); static EnKusa2UnkBssStruct D_80A5F1C0; static u32 D_80A60900; @@ -91,7 +92,7 @@ static Vec3s D_80A5EAF4 = { 0, 0, 0 }; static Vec3s D_80A5EAFC = { 0, 0, 0 }; static Vec3s D_80A5EB04 = { 0, 0, 0 }; -void func_80A5B160(EnKusa2* this, GlobalContext* globalCtx) { +void func_80A5B160(EnKusa2* this, PlayState* play) { s32 i; s16 temp_s1; EnKusa2** ptr; @@ -100,8 +101,8 @@ void func_80A5B160(EnKusa2* this, GlobalContext* globalCtx) { if (this->unk_194[0] == NULL) { ptr = this->unk_194; actor = (EnKusa2*)Actor_SpawnAsChildAndCutscene( - &globalCtx->actorCtx, globalCtx, ACTOR_EN_KUSA2, this->actor.world.pos.x, this->actor.world.pos.y, - this->actor.world.pos.z, 0, (u32)Rand_Next() >> 0x10, 0, 1, this->actor.cutscene, this->actor.unk20, NULL); + &play->actorCtx, play, ACTOR_EN_KUSA2, this->actor.world.pos.x, this->actor.world.pos.y, + this->actor.world.pos.z, 0, Rand_Next() >> 0x10, 0, 1, this->actor.cutscene, this->actor.unk20, NULL); *ptr = actor; if (*ptr != NULL) { @@ -115,9 +116,9 @@ void func_80A5B160(EnKusa2* this, GlobalContext* globalCtx) { if (this->unk_194[i] == NULL) { ptr = &this->unk_194[i]; actor = (EnKusa2*)Actor_SpawnAsChildAndCutscene( - &globalCtx->actorCtx, globalCtx, ACTOR_EN_KUSA2, (Math_SinS(temp_s1) * 80.0f) + this->actor.world.pos.x, - this->actor.world.pos.y, (Math_CosS(temp_s1) * 80.0f) + this->actor.world.pos.z, 0, - (u32)Rand_Next() >> 0x10, 0, 1, this->actor.cutscene, this->actor.unk20, NULL); + &play->actorCtx, play, ACTOR_EN_KUSA2, (Math_SinS(temp_s1) * 80.0f) + this->actor.world.pos.x, + this->actor.world.pos.y, (Math_CosS(temp_s1) * 80.0f) + this->actor.world.pos.z, 0, Rand_Next() >> 0x10, + 0, 1, this->actor.cutscene, this->actor.unk20, NULL); *ptr = actor; if (*ptr != NULL) { (*ptr)->actor.room = this->actor.room; @@ -127,7 +128,7 @@ void func_80A5B160(EnKusa2* this, GlobalContext* globalCtx) { } } -void func_80A5B334(EnKusa2* this, GlobalContext* globalCtx) { +void func_80A5B334(EnKusa2* this, PlayState* play) { s32 i; EnKusa2** ptr; @@ -135,7 +136,7 @@ void func_80A5B334(EnKusa2* this, GlobalContext* globalCtx) { ptr = &this->unk_194[i]; if (*ptr != NULL) { - if (!Actor_HasParent(&(*ptr)->actor, globalCtx)) { + if (!Actor_HasParent(&(*ptr)->actor, play)) { Actor_MarkForDeath(&(*ptr)->actor); } *ptr = NULL; @@ -155,8 +156,8 @@ void func_80A5B3BC(EnKusa2* this) { } } -void func_80A5B490(EnKusa2* this, GlobalContext* globalCtx) { - Actor_SpawnAsChildAndCutscene(&globalCtx->actorCtx, globalCtx, ACTOR_EN_KITAN, this->actor.world.pos.x, +void func_80A5B490(EnKusa2* this, PlayState* play) { + Actor_SpawnAsChildAndCutscene(&play->actorCtx, play, ACTOR_EN_KITAN, this->actor.world.pos.x, this->actor.world.pos.y, this->actor.world.pos.z, 0, 0, 0, ENKUSA2_GET_7F00(&this->actor) << 9, this->actor.cutscene, this->actor.unk20, NULL); } @@ -208,7 +209,7 @@ void func_80A5B508(void) { sp74[7] = (spAC - temp_f20) * temp_f22 * temp_f24 * temp_f2; for (i = 0; i < ARRAY_COUNT(D_80A60908); i++) { - ptr = (f32*)&D_80A60908[i].mf[0]; + ptr = &D_80A60908[i].xx; tempf1 = sp74[(i + 0) & 7]; tempf2 = sp74[(i + 1) & 7]; @@ -240,16 +241,16 @@ void func_80A5B508(void) { void func_80A5B954(MtxF* matrix, f32 arg1) { s32 i; - MtxF* temp = Matrix_GetCurrentState(); - f32* tmp = (f32*)&temp->mf[0]; - f32* tmp2 = (f32*)&matrix->mf[0]; + MtxF* temp = Matrix_GetCurrent(); + f32* tmp = &temp->xx; + f32* tmp2 = &matrix->xx; for (i = 0; i < 16; i++) { *tmp++ += *tmp2++ * arg1; } } -s32 func_80A5BA58(EnKusa2* this, GlobalContext* globalCtx) { +s32 func_80A5BA58(EnKusa2* this, PlayState* play) { Vec3f sp24; s32 sp20; @@ -257,7 +258,7 @@ s32 func_80A5BA58(EnKusa2* this, GlobalContext* globalCtx) { sp24.y = this->actor.world.pos.y + 30.0f; sp24.z = this->actor.world.pos.z; this->actor.floorHeight = - BgCheck_EntityRaycastFloor5(&globalCtx->colCtx, &this->actor.floorPoly, &sp20, &this->actor, &sp24); + BgCheck_EntityRaycastFloor5(&play->colCtx, &this->actor.floorPoly, &sp20, &this->actor, &sp24); if (this->actor.floorHeight > BGCHECK_Y_MIN) { this->actor.floorBgId = sp20; this->actor.world.pos.y = this->actor.floorHeight; @@ -267,11 +268,11 @@ s32 func_80A5BA58(EnKusa2* this, GlobalContext* globalCtx) { return false; } -void func_80A5BAFC(EnKusa2* this, GlobalContext* globalCtx) { - Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 15.0f, 35.0f, 0.0f, 0x45); +void func_80A5BAFC(EnKusa2* this, PlayState* play) { + Actor_UpdateBgCheckInfo(play, &this->actor, 15.0f, 35.0f, 0.0f, 0x45); } -void func_80A5BB40(EnKusa2* this, GlobalContext* globalCtx, s32 arg2) { +void func_80A5BB40(EnKusa2* this, PlayState* play, s32 arg2) { static Vec3f D_80A5EB0C = { 0.0f, 0.3f, 0.0f }; static Vec3f D_80A5EB18 = { 0.0f, 0.0f, 0.0f }; s32 pad; @@ -299,12 +300,12 @@ void func_80A5BB40(EnKusa2* this, GlobalContext* globalCtx, s32 arg2) { D_80A5EB0C.x = D_80A5EB18.x * -0.09f; D_80A5EB0C.z = D_80A5EB18.z * -0.09f; - func_800B1210(globalCtx, &sp84, &D_80A5EB18, &D_80A5EB0C, 10, 50); + func_800B1210(play, &sp84, &D_80A5EB18, &D_80A5EB0C, 10, 50); } } } -void func_80A5BD14(EnKusa2* this, GlobalContext* globalCtx, s32 arg2) { +void func_80A5BD14(EnKusa2* this, PlayState* play, s32 arg2) { static s32 D_80A5EB24[] = { ITEM00_RUPEE_GREEN, ITEM00_RUPEE_GREEN, ITEM00_RUPEE_GREEN, ITEM00_RUPEE_GREEN, ITEM00_RUPEE_GREEN, ITEM00_RUPEE_GREEN, ITEM00_RUPEE_GREEN, ITEM00_RUPEE_GREEN, ITEM00_RUPEE_RED, @@ -315,7 +316,7 @@ void func_80A5BD14(EnKusa2* this, GlobalContext* globalCtx, s32 arg2) { if (kusa2->unk_1BC > 8) { kusa2->unk_1BC = 8; } - Item_DropCollectible(globalCtx, &this->actor.world.pos, D_80A5EB24[kusa2->unk_1BC]); + Item_DropCollectible(play, &this->actor.world.pos, D_80A5EB24[kusa2->unk_1BC]); kusa2->unk_1BC += arg2; } } @@ -326,7 +327,7 @@ void func_80A5BD94(EnKusa2* this) { } } -void func_80A5BDB0(EnKusa2* this, GlobalContext* globalCtx) { +void func_80A5BDB0(EnKusa2* this, PlayState* play) { s32 pad[2]; s32 i; Vec3f sp50; @@ -337,14 +338,14 @@ void func_80A5BDB0(EnKusa2* this, GlobalContext* globalCtx) { for (phi_s0 = 0, i = 0; i < 4; i++, phi_s0 += 0x4000) { sp50.x = (Math_SinS((s32)(Rand_ZeroOne() * 7200.0f) + phi_s0) * 15.0f) + this->actor.world.pos.x; sp50.z = (Math_CosS((s32)(Rand_ZeroOne() * 7200.0f) + phi_s0) * 15.0f) + this->actor.world.pos.z; - EffectSsGSplash_Spawn(globalCtx, &sp50, NULL, NULL, 0, 190); + EffectSsGSplash_Spawn(play, &sp50, NULL, NULL, 0, 190); } sp50.x = this->actor.world.pos.x; sp50.z = this->actor.world.pos.z; - EffectSsGSplash_Spawn(globalCtx, &sp50, NULL, NULL, 0, 280); - EffectSsGRipple_Spawn(globalCtx, &sp50, 300, 700, 0); - SoundSource_PlaySfxAtFixedWorldPos(globalCtx, &this->actor.world.pos, 40, NA_SE_EV_DIVE_INTO_WATER_L); + EffectSsGSplash_Spawn(play, &sp50, NULL, NULL, 0, 280); + EffectSsGRipple_Spawn(play, &sp50, 300, 700, 0); + SoundSource_PlaySfxAtFixedWorldPos(play, &this->actor.world.pos, 40, NA_SE_EV_DIVE_INTO_WATER_L); } void func_80A5BF38(EnKusa2* this, s32 arg1) { @@ -365,19 +366,19 @@ void func_80A5BF60(EnKusa2* this, s32 arg1) { } } -void func_80A5BF84(EnKusa2* this, GlobalContext* globalCtx) { +void func_80A5BF84(EnKusa2* this, PlayState* play) { Collider_UpdateCylinder(&this->actor, &this->collider); - CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); - CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + CollisionCheck_SetAC(play, &play->colChkCtx, &this->collider.base); + CollisionCheck_SetOC(play, &play->colChkCtx, &this->collider.base); } -s32 func_80A5BFD8(EnKusa2* this, GlobalContext* globalCtx) { +s32 func_80A5BFD8(EnKusa2* this, PlayState* play) { if (this->collider.base.acFlags & AC_HIT) { s32 pad; func_80A5CF44(this); - func_80A5BD14(this, globalCtx, (this->collider.info.acHitInfo->toucher.dmgFlags & 0x1000000) ? 1 : 0); - SoundSource_PlaySfxAtFixedWorldPos(globalCtx, &this->actor.world.pos, 20, NA_SE_EV_PLANT_BROKEN); + func_80A5BD14(this, play, (this->collider.info.acHitInfo->toucher.dmgFlags & 0x1000000) ? 1 : 0); + SoundSource_PlaySfxAtFixedWorldPos(play, &this->actor.world.pos, 20, NA_SE_EV_PLANT_BROKEN); func_80A5BD94(this); Actor_MarkForDeath(&this->actor); return true; @@ -390,7 +391,7 @@ EnKusa2UnkBssSubStruct* func_80A5C074(EnKusa2UnkBssStruct* arg0) { EnKusa2UnkBssSubStruct* phi_v1 = &arg0->unk_0000[0]; for (i = 1; i < ARRAY_COUNT(D_80A5F1C0.unk_0000); i++) { - if (!(phi_v1->unk_26 <= arg0->unk_0000[i].unk_26)) { + if (phi_v1->unk_26 > arg0->unk_0000[i].unk_26) { phi_v1 = &arg0->unk_0000[i]; if (phi_v1->unk_26 <= 0) { break; @@ -406,7 +407,7 @@ EnKusa2UnkBssSubStruct2* func_80A5C0B8(EnKusa2UnkBssStruct* arg0) { EnKusa2UnkBssSubStruct2* phi_v1 = &arg0->unk_0480[0]; for (i = 1; i < ARRAY_COUNT(D_80A5F1C0.unk_0480); i++) { - if (!(phi_v1->unk_2C <= arg0->unk_0480[i].unk_2C)) { + if (phi_v1->unk_2C > arg0->unk_0480[i].unk_2C) { phi_v1 = &arg0->unk_0480[i]; if (1) {} if (phi_v1->unk_2C <= 0) { @@ -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); } @@ -852,7 +853,7 @@ static InitChainEntry sInitChain[] = { ICHAIN_F32(uncullZoneScale, 100, ICHAIN_CONTINUE), ICHAIN_F32(uncullZoneDownward, 100, ICHAIN_STOP), }; -void EnKusa2_Init(Actor* thisx, GlobalContext* globalCtx) { +void EnKusa2_Init(Actor* thisx, PlayState* play) { s32 pad; EnKusa2* this = THIS; @@ -861,26 +862,26 @@ void EnKusa2_Init(Actor* thisx, GlobalContext* globalCtx) { this->actor.update = func_80A5E604; this->actor.draw = NULL; this->actor.flags |= ACTOR_FLAG_20; - func_800BC154(globalCtx, &globalCtx->actorCtx, &this->actor, 1); + func_800BC154(play, &play->actorCtx, &this->actor, 1); this->unk_1BE = 0; if (D_80A5EAEC != 0) { D_80A5EAEC = 0; - D_80A60900 = globalCtx->gameplayFrames; + D_80A60900 = play->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); } else { - Collider_InitCylinder(globalCtx, &this->collider); - if (!func_80A5BA58(this, globalCtx)) { + Collider_InitCylinder(play, &this->collider); + if (!func_80A5BA58(this, play)) { Actor_MarkForDeath(&this->actor); } else { - Collider_SetCylinder(globalCtx, &this->collider, &this->actor, &sCylinderInit); + Collider_SetCylinder(play, &this->collider, &this->actor, &sCylinderInit); Collider_UpdateCylinder(&this->actor, &this->collider); this->actor.colChkInfo.mass = MASS_IMMOVABLE; this->unk_1CE = D_80A5EAF0 & 7; @@ -893,11 +894,11 @@ void EnKusa2_Init(Actor* thisx, GlobalContext* globalCtx) { } } -void EnKusa2_Destroy(Actor* thisx, GlobalContext* globalCtx) { +void EnKusa2_Destroy(Actor* thisx, PlayState* play) { EnKusa2* this = THIS; if (ENKUSA2_GET_1(&this->actor) == 1) { - Collider_DestroyCylinder(globalCtx, &this->collider); + Collider_DestroyCylinder(play, &this->collider); } } @@ -905,7 +906,7 @@ void func_80A5D5E0(EnKusa2* this) { this->actionFunc = func_80A5D5F4; } -void func_80A5D5F4(EnKusa2* this, GlobalContext* globalCtx) { +void func_80A5D5F4(EnKusa2* this, PlayState* play) { func_80A5D618(this); } @@ -913,12 +914,12 @@ void func_80A5D618(EnKusa2* this) { this->actionFunc = func_80A5D62C; } -void func_80A5D62C(EnKusa2* this, GlobalContext* globalCtx) { +void func_80A5D62C(EnKusa2* this, PlayState* play) { if (this->unk_1BE != 0) { - func_80A5B490(this, globalCtx); + func_80A5B490(this, play); func_80A5D754(this); } else if (Math3D_XZLengthSquared(this->actor.projectedPos.x, this->actor.projectedPos.z) < SQ(1600.0f)) { - func_80A5B160(this, globalCtx); + func_80A5B160(this, play); func_80A5D6B0(this); } } @@ -927,13 +928,13 @@ void func_80A5D6B0(EnKusa2* this) { this->actionFunc = func_80A5D6C4; } -void func_80A5D6C4(EnKusa2* this, GlobalContext* globalCtx) { +void func_80A5D6C4(EnKusa2* this, PlayState* play) { func_80A5B3BC(this); if (this->unk_1BE != 0) { - func_80A5B490(this, globalCtx); + func_80A5B490(this, play); func_80A5D754(this); } else if (Math3D_XZLengthSquared(this->actor.projectedPos.x, this->actor.projectedPos.z) > SQ(1750.0f)) { - func_80A5B334(this, globalCtx); + func_80A5B334(this, play); func_80A5D618(this); } } @@ -948,7 +949,7 @@ void func_80A5D754(EnKusa2* this) { this->actionFunc = func_80A5D794; } -void func_80A5D794(EnKusa2* this, GlobalContext* globalCtx) { +void func_80A5D794(EnKusa2* this, PlayState* play) { } void func_80A5D7A4(EnKusa2* this) { @@ -956,12 +957,12 @@ void func_80A5D7A4(EnKusa2* this) { this->actionFunc = func_80A5D7C4; } -void func_80A5D7C4(EnKusa2* this, GlobalContext* globalCtx) { +void func_80A5D7C4(EnKusa2* this, PlayState* play) { EnKusa2* this2 = this; s16 sp2A; - if (Actor_HasParent(&this->actor, globalCtx)) { - SoundSource_PlaySfxAtFixedWorldPos(globalCtx, &this->actor.world.pos, 20, NA_SE_PL_PULL_UP_PLANT); + if (Actor_HasParent(&this->actor, play)) { + SoundSource_PlaySfxAtFixedWorldPos(play, &this->actor.world.pos, 20, NA_SE_PL_PULL_UP_PLANT); this->actor.shape.shadowDraw = ActorShadow_DrawCircle; this->actor.shape.shadowAlpha = 60; this->actor.room = -1; @@ -970,7 +971,7 @@ void func_80A5D7C4(EnKusa2* this, GlobalContext* globalCtx) { return; } - if (!func_80A5BFD8(this, globalCtx)) { + if (!func_80A5BFD8(this, play)) { if ((this->unk_1C0 != NULL) && (this->unk_1C0->unk_1BE != 0)) { this->actor.shape.shadowDraw = ActorShadow_DrawCircle; if (this2->unk_1C0 != NULL) { @@ -984,11 +985,11 @@ void func_80A5D7C4(EnKusa2* this, GlobalContext* globalCtx) { } if (this->actor.xzDistToPlayer < 600.0f) { - CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + CollisionCheck_SetAC(play, &play->colChkCtx, &this->collider.base); if (this->actor.xzDistToPlayer < 400.0f) { - CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + CollisionCheck_SetOC(play, &play->colChkCtx, &this->collider.base); if (this->actor.xzDistToPlayer < 100.0f) { - Actor_LiftActor(&this->actor, globalCtx); + Actor_LiftActor(&this->actor, play); } } } @@ -1010,7 +1011,7 @@ void func_80A5D964(EnKusa2* this) { this->unk_1D0 = 30; } -void func_80A5D9C8(EnKusa2* this, GlobalContext* globalCtx) { +void func_80A5D9C8(EnKusa2* this, PlayState* play) { s32 pad; Vec3f sp30; s32 sp2C; @@ -1031,14 +1032,14 @@ void func_80A5D9C8(EnKusa2* this, GlobalContext* globalCtx) { D_80A5EAFC.y = Math_SinS(D_80A5EB04.y) * 1000.0f; D_80A5EAFC.z = Math_SinS(D_80A5EB04.z) * 1000.0f; - if (Actor_HasNoParent(&this->actor, globalCtx)) { - this->actor.room = globalCtx->roomCtx.currRoom.num; + if (Actor_HasNoParent(&this->actor, play)) { + this->actor.room = play->roomCtx.currRoom.num; this->actor.colChkInfo.mass = 80; this->actor.home.rot.y = this->actor.world.rot.y; this->actor.velocity.y = 12.5f; this->actor.speedXZ += 3.0f; Actor_MoveWithGravity(&this->actor); - func_80A5BAFC(this, globalCtx); + func_80A5BAFC(this, play); func_80A5CD0C(this); this->unk_1C8 = 30; func_80A5DC70(this); @@ -1047,18 +1048,18 @@ 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 = - BgCheck_EntityRaycastFloor5(&globalCtx->colCtx, &this->actor.floorPoly, &sp2C, &this->actor, &sp30); + BgCheck_EntityRaycastFloor5(&play->colCtx, &this->actor.floorPoly, &sp2C, &this->actor, &sp30); } } @@ -1068,8 +1069,8 @@ void func_80A5DC70(EnKusa2* this) { this->unk_1CA = 80; } -void func_80A5DC98(EnKusa2* this, GlobalContext* globalCtx) { - if (!func_80A5BFD8(this, globalCtx)) { +void func_80A5DC98(EnKusa2* this, PlayState* play) { + if (!func_80A5BFD8(this, play)) { if (this->actor.velocity.y > 1.0f) { Math_StepToF(&this->actor.scale.y, 0.3f, 0.060000002f); Math_StepToF(&this->actor.scale.x, 0.328f, 0.040000003f); @@ -1081,17 +1082,17 @@ void func_80A5DC98(EnKusa2* this, GlobalContext* globalCtx) { this->actor.scale.z = this->actor.scale.x; Math_StepToF(&this->actor.gravity, -7.0f, 1.8f); Actor_MoveWithGravity(&this->actor); - func_80A5BAFC(this, globalCtx); + func_80A5BAFC(this, play); func_80A5BF38(this, 4); - func_80A5BF84(this, globalCtx); + func_80A5BF84(this, play); if (this->actor.bgCheckFlags & 1) { func_80A5CD0C(this); - func_80A5BB40(this, globalCtx, 1); + func_80A5BB40(this, play, 1); Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_NUTS_WALK); func_80A5DE18(this); } else if (this->actor.bgCheckFlags & 0x20) { - func_80A5BDB0(this, globalCtx); + func_80A5BDB0(this, play); func_80A5E418(this); } else if (this->unk_1CA > 0) { this->unk_1CA--; @@ -1110,13 +1111,13 @@ void func_80A5DE18(EnKusa2* this) { this->unk_1CA = Rand_S16Offset(19, 2); } -void func_80A5DEB4(EnKusa2* this, GlobalContext* globalCtx) { +void func_80A5DEB4(EnKusa2* this, PlayState* play) { s32 pad; s32 pad2; s16 sp24; s32 sp20; - if (!func_80A5BFD8(this, globalCtx)) { + if (!func_80A5BFD8(this, play)) { if (this->unk_1D0 > 0) { this->unk_1D0--; if (this->unk_1D0 == 0) { @@ -1147,22 +1148,22 @@ void func_80A5DEB4(EnKusa2* this, GlobalContext* globalCtx) { this->actor.shape.rot.y = this->actor.world.rot.y; this->actor.shape.rot.x = (s32)(fabsf(Math_SinS(this->unk_1C4)) * 4000.0f) - 0x6A4; - func_80A5BAFC(this, globalCtx); + func_80A5BAFC(this, play); func_80A5BF38(this, 4); - func_80A5BF84(this, globalCtx); + func_80A5BF84(this, play); - if ((u32)Rand_Next() < 0xFFFFFFF) { + if (Rand_Next() < 0xFFFFFFF) { func_80A5CD0C(this); } if (this->actor.bgCheckFlags & 0x20) { - func_80A5BDB0(this, globalCtx); + func_80A5BDB0(this, play); func_80A5E418(this); } else { this->unk_1C8--; if (this->unk_1C8 <= 0) { func_80A5CD0C(this); - func_80A5BB40(this, globalCtx, 4); + func_80A5BB40(this, play, 4); this->actor.speedXZ += 4.0f; this->actor.velocity.y = (Rand_ZeroOne() * 4.0f) + 15.0f; func_80A5E1D8(this); @@ -1170,7 +1171,7 @@ void func_80A5DEB4(EnKusa2* this, GlobalContext* globalCtx) { this->unk_1CA--; if (this->unk_1CA <= 0) { func_80A5CD0C(this); - func_80A5BB40(this, globalCtx, 2); + func_80A5BB40(this, play, 2); this->actor.velocity.y = (Rand_ZeroOne() * 6.0f) + 7.0f; this->actor.speedXZ += 2.0f; if (this->actor.yawTowardsPlayer < this->actor.world.rot.y) { @@ -1195,19 +1196,19 @@ void func_80A5E1D8(EnKusa2* this) { func_80A5CB74(this); } -void func_80A5E210(EnKusa2* this, GlobalContext* globalCtx) { +void func_80A5E210(EnKusa2* this, PlayState* play) { Math_StepToF(&this->actor.gravity, -4.0f, 0.5f); if (this->actor.bgCheckFlags & 1) { this->actor.speedXZ *= 0.4f; if (this->actor.bgCheckFlags & 2) { func_80A5D178(this); - SoundSource_PlaySfxAtFixedWorldPos(globalCtx, &this->actor.world.pos, 40, NA_SE_EN_KUSAMUSHI_HIDE); + SoundSource_PlaySfxAtFixedWorldPos(play, &this->actor.world.pos, 40, NA_SE_EN_KUSAMUSHI_HIDE); } } Actor_MoveWithGravity(&this->actor); - func_80A5BAFC(this, globalCtx); + func_80A5BAFC(this, play); if (this->actor.velocity.y > 0.01f) { func_80A5BF38(this, 4); @@ -1257,18 +1258,18 @@ void func_80A5E418(EnKusa2* this) { this->actionFunc = func_80A5E4BC; } -void func_80A5E4BC(EnKusa2* this, GlobalContext* globalCtx) { +void func_80A5E4BC(EnKusa2* this, PlayState* play) { Math_StepToF(&this->actor.scale.y, 0.4f, 0.032f); Math_StepToF(&this->actor.scale.x, 0.4f, 0.032f); this->actor.scale.z = this->actor.scale.x; Actor_MoveWithGravity(&this->actor); - func_80A5BAFC(this, globalCtx); + func_80A5BAFC(this, play); func_80A5BF60(this, 6); this->actor.shape.rot.x -= 0x5DC; this->actor.shape.rot.y += this->unk_1CC; if ((this->actor.bgCheckFlags & 0x20) && (this->actor.depthInWater > 5.0f) && (Rand_ZeroOne() < 0.8f)) { - EffectSsBubble_Spawn(globalCtx, &this->actor.world.pos, 20.0f, 10.0f, 20.0f, (Rand_ZeroOne() * 0.08f) + 0.04f); + EffectSsBubble_Spawn(play, &this->actor.world.pos, 20.0f, 10.0f, 20.0f, (Rand_ZeroOne() * 0.08f) + 0.04f); } this->unk_1CF -= 15; @@ -1277,38 +1278,38 @@ void func_80A5E4BC(EnKusa2* this, GlobalContext* globalCtx) { } } -void func_80A5E604(Actor* thisx, GlobalContext* globalCtx) { +void func_80A5E604(Actor* thisx, PlayState* play) { s32 pad; EnKusa2* this = THIS; - this->actionFunc(this, globalCtx); + this->actionFunc(this, play); - if (D_80A60900 == globalCtx->gameplayFrames) { + if (D_80A60900 == play->gameplayFrames) { this->actor.draw = NULL; } else { this->actor.draw = func_80A5E6F0; - if (globalCtx->roomCtx.currRoom.unk3 == 0) { + if (play->roomCtx.currRoom.unk3 == 0) { func_80A5B508(); } func_80A5CAF4(&D_80A5F1C0); - D_80A60900 = globalCtx->gameplayFrames; + D_80A60900 = play->gameplayFrames; } } -void EnKusa2_Update(Actor* thisx, GlobalContext* globalCtx) { +void EnKusa2_Update(Actor* thisx, PlayState* play) { EnKusa2* this = THIS; if ((this->unk_1C0 != NULL) && (this->unk_1C0->actor.update == NULL)) { this->unk_1C0 = NULL; } - this->actionFunc(this, globalCtx); + this->actionFunc(this, play); func_80A5CCD4(this); } -void func_80A5E6F0(Actor* thisx, GlobalContext* globalCtx) { +void func_80A5E6F0(Actor* thisx, PlayState* play) { static Gfx* D_80A5EB68[] = { gKakeraLeafTip, gKakeraLeafMiddle, @@ -1316,69 +1317,68 @@ void func_80A5E6F0(Actor* thisx, GlobalContext* globalCtx) { EnKusa2* this = THIS; s32 i; - OPEN_DISPS(globalCtx->state.gfxCtx); + OPEN_DISPS(play->state.gfxCtx); - func_8012C28C(globalCtx->state.gfxCtx); + func_8012C28C(play->state.gfxCtx); for (i = 0; i < ARRAY_COUNT(D_80A5F1C0.unk_0480); i++) { EnKusa2UnkBssSubStruct2* s = &D_80A5F1C0.unk_0480[i]; if (s->unk_2C > 0) { - Matrix_SetStateRotationAndTranslation(s->unk_04.x, s->unk_04.y, s->unk_04.z, &s->unk_20); + Matrix_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), - G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_OPA_DISP++, D_80A5EB68[i & 1]); } } - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->state.gfxCtx); } -void func_80A5E80C(GlobalContext* globalCtx, s32 arg1) { - OPEN_DISPS(globalCtx->state.gfxCtx); +void func_80A5E80C(PlayState* play, s32 arg1) { + OPEN_DISPS(play->state.gfxCtx); - func_8012C2DC(globalCtx->state.gfxCtx); + func_8012C2DC(play->state.gfxCtx); - gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 255, 255, 255, arg1); gSPDisplayList(POLY_XLU_DISP++, gKusaBushType2); - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->state.gfxCtx); } -void EnKusa2_Draw(Actor* thisx, GlobalContext* globalCtx) { +void EnKusa2_Draw(Actor* thisx, PlayState* play) { EnKusa2* this = THIS; if (this->actor.projectedPos.z <= 1200.0f) { - if ((globalCtx->roomCtx.currRoom.unk3 == 0) && (this->actor.projectedPos.z > -150.0f) && + if ((play->roomCtx.currRoom.unk3 == 0) && (this->actor.projectedPos.z > -150.0f) && (this->actor.projectedPos.z < 400.0f)) { func_80A5B954(&D_80A60908[this->unk_1CE], 0.0015f); } - Gfx_DrawDListOpa(globalCtx, gKusaBushType1); + Gfx_DrawDListOpa(play, gKusaBushType1); } else if (this->actor.projectedPos.z < 1300.0f) { - func_80A5E80C(globalCtx, (1300.0f - this->actor.projectedPos.z) * 2.55f); + func_80A5E80C(play, (1300.0f - this->actor.projectedPos.z) * 2.55f); } } -void func_80A5E9B4(Actor* thisx, GlobalContext* globalCtx) { +void func_80A5E9B4(Actor* thisx, PlayState* play) { Vec3s sp18; sp18.x = thisx->shape.rot.x + D_80A5EAFC.x; sp18.y = thisx->shape.rot.y + D_80A5EAFC.y; sp18.z = thisx->shape.rot.z + D_80A5EAFC.z; - Matrix_SetStateRotationAndTranslation(thisx->world.pos.x, thisx->world.pos.y, thisx->world.pos.z, &sp18); + Matrix_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, gKusaBushType1); + Gfx_DrawDListOpa(play, gKusaBushType1); } -void func_80A5EA48(Actor* thisx, GlobalContext* globalCtx) { +void func_80A5EA48(Actor* thisx, PlayState* play) { EnKusa2* this = THIS; if (this->unk_1CF == 0xFF) { - Gfx_DrawDListOpa(globalCtx, gKusaBushType1); + Gfx_DrawDListOpa(play, gKusaBushType1); } else { - func_80A5E80C(globalCtx, this->unk_1CF); + func_80A5E80C(play, this->unk_1CF); } } diff --git a/src/overlays/actors/ovl_En_Kusa2/z_en_kusa2.h b/src/overlays/actors/ovl_En_Kusa2/z_en_kusa2.h index f18c1a6a7..eb8276ac6 100644 --- a/src/overlays/actors/ovl_En_Kusa2/z_en_kusa2.h +++ b/src/overlays/actors/ovl_En_Kusa2/z_en_kusa2.h @@ -6,11 +6,11 @@ struct EnKusa2; struct EnKusa2UnkBssSubStruct; -typedef void (*EnKusa2ActionFunc)(struct EnKusa2*, GlobalContext*); +typedef void (*EnKusa2ActionFunc)(struct EnKusa2*, PlayState*); typedef void (*EnKusa2BssFunc)(struct EnKusa2UnkBssSubStruct*); -#define ENKUSA2_GET_1(thisx) (((thisx)->params) & 1) -#define ENKUSA2_GET_7F00(thisx) (u8)((((thisx)->params) >> 8) & 0x7F) +#define ENKUSA2_GET_1(thisx) ((thisx)->params & 1) +#define ENKUSA2_GET_7F00(thisx) (u8)(((thisx)->params >> 8) & 0x7F) typedef struct EnKusa2UnkBssSubStruct { /* 0x00 */ Vec3f unk_00; @@ -62,23 +62,23 @@ typedef struct { } EnKusa2UnkBssStruct; // size = 0x1740 typedef struct EnKusa2 { - /* 0x0000 */ Actor actor; - /* 0x0144 */ ColliderCylinder collider; - /* 0x0190 */ EnKusa2ActionFunc actionFunc; - /* 0x0194 */ struct EnKusa2* unk_194[9]; - /* 0x01B8 */ EnKusa2UnkBssSubStruct* unk_1B8; - /* 0x01BC */ s16 unk_1BC; - /* 0x01BE */ s8 unk_1BE; - /* 0x01C0 */ struct EnKusa2* unk_1C0; - /* 0x01C4 */ s16 unk_1C4; - /* 0x01C6 */ UNK_TYPE1 unk1C6[0x2]; - /* 0x01C8 */ s16 unk_1C8; - /* 0x01CA */ s16 unk_1CA; - /* 0x01CC */ s16 unk_1CC; - /* 0x01CE */ s8 unk_1CE; - /* 0x01CF */ u8 unk_1CF; - /* 0x01D0 */ s8 unk_1D0; - /* 0x01D1 */ s8 unk_1D1; + /* 0x000 */ Actor actor; + /* 0x144 */ ColliderCylinder collider; + /* 0x190 */ EnKusa2ActionFunc actionFunc; + /* 0x194 */ struct EnKusa2* unk_194[9]; + /* 0x1B8 */ EnKusa2UnkBssSubStruct* unk_1B8; + /* 0x1BC */ s16 unk_1BC; + /* 0x1BE */ s8 unk_1BE; + /* 0x1C0 */ struct EnKusa2* unk_1C0; + /* 0x1C4 */ s16 unk_1C4; + /* 0x1C6 */ UNK_TYPE1 unk1C6[0x2]; + /* 0x1C8 */ s16 unk_1C8; + /* 0x1CA */ s16 unk_1CA; + /* 0x1CC */ s16 unk_1CC; + /* 0x1CE */ s8 unk_1CE; + /* 0x1CF */ u8 unk_1CF; + /* 0x1D0 */ s8 unk_1D0; + /* 0x1D1 */ s8 unk_1D1; } EnKusa2; // size = 0x1D4 extern const ActorInit En_Kusa2_InitVars; diff --git a/src/overlays/actors/ovl_En_Lift_Nuts/z_en_lift_nuts.c b/src/overlays/actors/ovl_En_Lift_Nuts/z_en_lift_nuts.c index 8669a3544..85e57c550 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 @@ -10,10 +10,10 @@ #define THIS ((EnLiftNuts*)thisx) -void EnLiftNuts_Init(Actor* thisx, GlobalContext* globalCtx); -void EnLiftNuts_Destroy(Actor* thisx, GlobalContext* globalCtx); -void EnLiftNuts_Update(Actor* thisx, GlobalContext* globalCtx); -void EnLiftNuts_Draw(Actor* thisx, GlobalContext* globalCtx); +void EnLiftNuts_Init(Actor* thisx, PlayState* play); +void EnLiftNuts_Destroy(Actor* thisx, PlayState* play); +void EnLiftNuts_Update(Actor* thisx, PlayState* play); +void EnLiftNuts_Draw(Actor* thisx, PlayState* play); #if 0 const ActorInit En_Lift_Nuts_InitVars = { diff --git a/src/overlays/actors/ovl_En_Lift_Nuts/z_en_lift_nuts.h b/src/overlays/actors/ovl_En_Lift_Nuts/z_en_lift_nuts.h index fe63bb8f1..ad6014dd9 100644 --- a/src/overlays/actors/ovl_En_Lift_Nuts/z_en_lift_nuts.h +++ b/src/overlays/actors/ovl_En_Lift_Nuts/z_en_lift_nuts.h @@ -5,13 +5,13 @@ struct EnLiftNuts; -typedef void (*EnLiftNutsActionFunc)(struct EnLiftNuts*, GlobalContext*); +typedef void (*EnLiftNutsActionFunc)(struct EnLiftNuts*, PlayState*); typedef struct EnLiftNuts { - /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x90]; - /* 0x01D4 */ EnLiftNutsActionFunc actionFunc; - /* 0x01D8 */ char unk_1D8[0x180]; + /* 0x000 */ Actor actor; + /* 0x144 */ char unk_144[0x90]; + /* 0x1D4 */ EnLiftNutsActionFunc actionFunc; + /* 0x1D8 */ char unk_1D8[0x180]; } EnLiftNuts; // size = 0x358 extern const ActorInit En_Lift_Nuts_InitVars; diff --git a/src/overlays/actors/ovl_En_Light/z_en_light.c b/src/overlays/actors/ovl_En_Light/z_en_light.c index f815147a2..e50cf0da5 100644 --- a/src/overlays/actors/ovl_En_Light/z_en_light.c +++ b/src/overlays/actors/ovl_En_Light/z_en_light.c @@ -11,12 +11,12 @@ #define THIS ((EnLight*)thisx) -void EnLight_Init(Actor* thisx, GlobalContext* globalCtx); -void EnLight_Destroy(Actor* thisx, GlobalContext* globalCtx); -void EnLight_Update(Actor* thisx, GlobalContext* globalCtx); -void EnLight_Draw(Actor* thisx, GlobalContext* globalCtx); +void EnLight_Init(Actor* thisx, PlayState* play); +void EnLight_Destroy(Actor* thisx, PlayState* play); +void EnLight_Update(Actor* thisx, PlayState* play); +void EnLight_Draw(Actor* thisx, PlayState* play); -void func_80865F38(Actor* thisx, GlobalContext* globalCtx); +void func_80865F38(Actor* thisx, PlayState* play); const ActorInit En_Light_InitVars = { ACTOR_EN_LIGHT, @@ -47,7 +47,7 @@ EnLightStruct D_808666D0[] = { { { 170, 255, 255, 255 }, { 0, 0, 255 }, 75 }, { { 170, 255, 255, 255 }, { 0, 150, 255 }, 75 }, }; -void EnLight_Init(Actor* thisx, GlobalContext* globalCtx) { +void EnLight_Init(Actor* thisx, PlayState* play) { s32 pad; EnLight* this = THIS; @@ -61,7 +61,7 @@ void EnLight_Init(Actor* thisx, GlobalContext* globalCtx) { ((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); + this->lightNode = LightContext_InsertLight(play, &play->lightCtx, &this->lightInfo); } Actor_SetScale(&this->actor, D_808666D0[ENLIGHT_GET_F(&this->actor)].unk_07 * 0.0001f); @@ -70,7 +70,7 @@ void EnLight_Init(Actor* thisx, GlobalContext* globalCtx) { if (ENLIGHT_GET_800(&this->actor)) { this->actor.update = func_80865F38; - if (ENLIGHT_GET_1000(&this->actor) && Flags_GetSwitch(globalCtx, ENLIGHT_SWITCHFLAG(&this->actor))) { + if (ENLIGHT_GET_1000(&this->actor) && Flags_GetSwitch(play, ENLIGHT_SWITCHFLAG(&this->actor))) { Actor_SetScale(&this->actor, 0.0f); } } else if (ENLIGHT_GET_2000(&this->actor)) { @@ -78,16 +78,16 @@ void EnLight_Init(Actor* thisx, GlobalContext* globalCtx) { } } -void EnLight_Destroy(Actor* thisx, GlobalContext* globalCtx) { +void EnLight_Destroy(Actor* thisx, PlayState* play) { EnLight* this = THIS; if (!ENLIGHT_GET_4000(&this->actor)) { - LightContext_RemoveLight(globalCtx, &globalCtx->lightCtx, this->lightNode); + LightContext_RemoveLight(play, &play->lightCtx, this->lightNode); } } -void func_80865BF8(EnLight* this, GlobalContext* globalCtx) { - this->actor.shape.rot.y = BINANG_ROT180(Camera_GetCamDirYaw(GET_ACTIVE_CAM(globalCtx))); +void func_80865BF8(EnLight* this, PlayState* play) { + this->actor.shape.rot.y = BINANG_ROT180(Camera_GetCamDirYaw(GET_ACTIVE_CAM(play))); if (this->actor.parent != NULL) { Math_Vec3f_Copy(&this->actor.world.pos, &this->actor.parent->world.pos); @@ -97,7 +97,7 @@ void func_80865BF8(EnLight* this, GlobalContext* globalCtx) { this->unk_144++; } -void EnLight_Update(Actor* thisx, GlobalContext* globalCtx) { +void EnLight_Update(Actor* thisx, PlayState* play) { EnLight* this = THIS; if (!ENLIGHT_GET_4000(&this->actor)) { @@ -109,14 +109,14 @@ void EnLight_Update(Actor* thisx, GlobalContext* globalCtx) { (u8)(sp28->unk_00.b * temp_f2), radius); } - func_80865BF8(this, globalCtx); + func_80865BF8(this, play); 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) { +void func_80865F38(Actor* thisx, PlayState* play) { EnLight* this = THIS; EnLightStruct* sp38 = &D_808666D0[ENLIGHT_GET_F(&this->actor)]; f32 temp_f2; @@ -124,7 +124,7 @@ void func_80865F38(Actor* thisx, GlobalContext* globalCtx) { s32 sp2C = false; if (ENLIGHT_GET_1000(&this->actor)) { - if (Flags_GetSwitch(globalCtx, ENLIGHT_SWITCHFLAG(&this->actor))) { + if (Flags_GetSwitch(play, ENLIGHT_SWITCHFLAG(&this->actor))) { Math_StepToF(&sp30, 1.0f, 0.05f); sp2C = true; } else { @@ -134,7 +134,7 @@ void func_80865F38(Actor* thisx, GlobalContext* globalCtx) { } Math_StepToF(&sp30, 0.0f, 0.05f); } - } else if (Flags_GetSwitch(globalCtx, ENLIGHT_SWITCHFLAG(&this->actor))) { + } else if (Flags_GetSwitch(play, ENLIGHT_SWITCHFLAG(&this->actor))) { if (sp30 < 0.1f) { Actor_SetScale(&this->actor, 0.0f); sp30 = 0.0f; @@ -153,50 +153,49 @@ void func_80865F38(Actor* thisx, GlobalContext* globalCtx) { (u8)(sp38->unk_00.b * temp_f2), 300.0f * sp30); } - func_80865BF8(this, globalCtx); + func_80865BF8(this, play); if ((this->actor.params >= 0) && (sp2C == true)) { Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_TORCH - SFX_FLAG); } } -void EnLight_Draw(Actor* thisx, GlobalContext* globalCtx) { +void EnLight_Draw(Actor* thisx, PlayState* play) { s32 pad; EnLight* this = THIS; EnLightStruct* sp6C = &D_808666D0[ENLIGHT_GET_F(&this->actor)]; Gfx* sp68; - OPEN_DISPS(globalCtx->state.gfxCtx); + OPEN_DISPS(play->state.gfxCtx); - func_8012C2DC(globalCtx->state.gfxCtx); + func_8012C2DC(play->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; + gSPSegment( + POLY_XLU_DISP++, 0x08, + Gfx_TwoTexScroll(play->state.gfxCtx, 0, 0, 0, 0x20, 0x40, 1, 0, (this->unk_144 * -20) & 0x1FF, 0x20, 0x80)); + sp68 = gEffFire1DL; 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, + Gfx_TwoTexScroll(play->state.gfxCtx, 0, 0, 0, 0x10, 0x20, 1, (this->unk_144 * 2) & 0x3F, (this->unk_144 * -6) & 0x7F, 0x10, 0x20)); sp68 = gameplay_keep_DL_01ACF0; gDPSetPrimColor(POLY_XLU_DISP++, 0xC0, 0xC0, 255, 200, 0, 0); gDPSetEnvColor(POLY_XLU_DISP++, 255, 0, 0, 0); } - Matrix_RotateY(BINANG_ROT180(Camera_GetCamDirYaw(GET_ACTIVE_CAM(globalCtx)) - this->actor.shape.rot.y), - MTXMODE_APPLY); + Matrix_RotateYS(BINANG_ROT180(Camera_GetCamDirYaw(GET_ACTIVE_CAM(play)) - this->actor.shape.rot.y), MTXMODE_APPLY); if (ENLIGHT_GET_1(&this->actor)) { - Matrix_InsertYRotation_f(M_PI, MTXMODE_APPLY); + 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); + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_XLU_DISP++, sp68); - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->state.gfxCtx); } 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 07b9e8db0..de053c46a 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 @@ -10,18 +10,18 @@ #define THIS ((EnLookNuts*)thisx) -void EnLookNuts_Init(Actor* thisx, GlobalContext* globalCtx); -void EnLookNuts_Destroy(Actor* thisx, GlobalContext* globalCtx); -void EnLookNuts_Update(Actor* thisx, GlobalContext* globalCtx); -void EnLookNuts_Draw(Actor* thisx, GlobalContext* globalCtx); +void EnLookNuts_Init(Actor* thisx, PlayState* play); +void EnLookNuts_Destroy(Actor* thisx, PlayState* play); +void EnLookNuts_Update(Actor* thisx, PlayState* play); +void EnLookNuts_Draw(Actor* thisx, PlayState* play); void EnLookNuts_SetupPatrol(EnLookNuts* this); -void EnLookNuts_Patrol(EnLookNuts* this, GlobalContext* globalCtx); +void EnLookNuts_Patrol(EnLookNuts* this, PlayState* play); void EnLookNuts_SetupStandAndWait(EnLookNuts* this); -void EnLookNuts_StandAndWait(EnLookNuts* this, GlobalContext* globalCtx); -void EnLookNuts_RunToPlayer(EnLookNuts* this, GlobalContext* globalCtx); +void EnLookNuts_StandAndWait(EnLookNuts* this, PlayState* play); +void EnLookNuts_RunToPlayer(EnLookNuts* this, PlayState* play); void EnLookNuts_SetupSendPlayerToSpawn(EnLookNuts* this); -void EnLookNuts_SendPlayerToSpawn(EnLookNuts* this, GlobalContext* globalCtx); +void EnLookNuts_SendPlayerToSpawn(EnLookNuts* this, PlayState* play); const ActorInit En_Look_Nuts_InitVars = { ACTOR_EN_LOOK_NUTS, @@ -99,17 +99,17 @@ typedef enum { /* 0x03 */ PALACE_GUARD_CAUGHT_PLAYER } PalaceGuardState; -void EnLookNuts_Init(Actor* thisx, GlobalContext* globalCtx) { +void EnLookNuts_Init(Actor* thisx, PlayState* play) { EnLookNuts* this = THIS; ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 20.0f); - SkelAnime_Init(globalCtx, &this->skelAnime, &gDekuPalaceGuardSkel, &gDekuPalaceGuardDigAnim, this->jointTable, - this->morphTable, OBJECT_DNK_LIMB_MAX); + SkelAnime_Init(play, &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); + Collider_InitAndSetCylinder(play, &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); @@ -118,7 +118,7 @@ void EnLookNuts_Init(Actor* thisx, GlobalContext* globalCtx) { if (this->switchFlag == 0x7F) { this->switchFlag = -1; } - if ((this->switchFlag >= 0) && (Flags_GetSwitch(globalCtx, this->switchFlag))) { + if ((this->switchFlag >= 0) && (Flags_GetSwitch(play, this->switchFlag))) { Actor_MarkForDeath(&this->actor); return; } @@ -131,25 +131,25 @@ void EnLookNuts_Init(Actor* thisx, GlobalContext* globalCtx) { EnLookNuts_SetupPatrol(this); } -void EnLookNuts_Destroy(Actor* thisx, GlobalContext* globalCtx) { +void EnLookNuts_Destroy(Actor* thisx, PlayState* play) { EnLookNuts* this = THIS; - Collider_DestroyCylinder(globalCtx, &this->collider); + Collider_DestroyCylinder(play, &this->collider); } void EnLookNuts_SetupPatrol(EnLookNuts* this) { Animation_Change(&this->skelAnime, &gDekuPalaceGuardWalkAnim, 1.0f, 0.0f, - Animation_GetLastFrame(&gDekuPalaceGuardWalkAnim), 0, -10.0f); + Animation_GetLastFrame(&gDekuPalaceGuardWalkAnim), ANIMMODE_LOOP, -10.0f); this->state = PALACE_GUARD_PATROLLING; this->actionFunc = EnLookNuts_Patrol; } -void EnLookNuts_Patrol(EnLookNuts* this, GlobalContext* globalCtx) { +void EnLookNuts_Patrol(EnLookNuts* this, PlayState* play) { f32 sp34 = 0.0f; f32 sp30; SkelAnime_Update(&this->skelAnime); - if (Play_InCsMode(globalCtx)) { + if (Play_InCsMode(play)) { this->actor.speedXZ = 0.0f; return; } @@ -164,11 +164,12 @@ void EnLookNuts_Patrol(EnLookNuts* this, GlobalContext* globalCtx) { return; } - this->path = SubS_GetPathByIndex(globalCtx, this->pathLocation, 0x1F); + this->path = SubS_GetPathByIndex(play, this->pathLocation, 0x1F); if (this->path != NULL) { sp34 = SubS_GetDistSqAndOrientPath(this->path, this->currentPathIndex, &this->actor.world.pos, &sp30); } + //! @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++; @@ -181,13 +182,14 @@ void EnLookNuts_Patrol(EnLookNuts* this, GlobalContext* globalCtx) { } } } + 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); + Animation_GetLastFrame(&gDekuPalaceGuardWalkAnim), ANIMMODE_ONCE, -10.0f); this->waitTimer = Rand_S16Offset(1, 3); this->headRotTarget.y = 10000.0f; @@ -200,12 +202,12 @@ void EnLookNuts_SetupStandAndWait(EnLookNuts* this) { } // Patrol Guards will stand in place and wait for a maximum of ~12 frames. -void EnLookNuts_StandAndWait(EnLookNuts* this, GlobalContext* globalCtx) { +void EnLookNuts_StandAndWait(EnLookNuts* this, PlayState* play) { 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)) { + if (!Play_InCsMode(play) && (D_80A6862C == 0) && (this->eventTimer == 0)) { this->eventTimer = 10; switch (this->waitTimer) { case 0: @@ -258,16 +260,16 @@ void EnLookNuts_StandAndWait(EnLookNuts* this, GlobalContext* globalCtx) { } } -void EnLookNuts_DetectedPlayer(EnLookNuts* this, GlobalContext* globalCtx) { +void EnLookNuts_DetectedPlayer(EnLookNuts* this, PlayState* play) { Animation_Change(&this->skelAnime, &gDekuPalaceGuardWalkAnim, 2.0f, 0.0f, - Animation_GetLastFrame(&gDekuPalaceGuardWalkAnim), 0, -10.0f); + Animation_GetLastFrame(&gDekuPalaceGuardWalkAnim), ANIMMODE_LOOP, -10.0f); this->state = PALACE_GUARD_RUNNING_TO_PLAYER; this->eventTimer = 300; - Message_StartTextbox(globalCtx, 0x833, &this->actor); + Message_StartTextbox(play, 0x833, &this->actor); this->actionFunc = EnLookNuts_RunToPlayer; } -void EnLookNuts_RunToPlayer(EnLookNuts* this, GlobalContext* globalCtx) { +void EnLookNuts_RunToPlayer(EnLookNuts* this, PlayState* play) { SkelAnime_Update(&this->skelAnime); if (Animation_OnFrame(&this->skelAnime, 1.0f) || Animation_OnFrame(&this->skelAnime, 5.0f)) { Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_NUTS_WALK); @@ -283,27 +285,27 @@ void EnLookNuts_RunToPlayer(EnLookNuts* this, GlobalContext* globalCtx) { void EnLookNuts_SetupSendPlayerToSpawn(EnLookNuts* this) { Animation_Change(&this->skelAnime, &gDekuPalaceGuardWalkAnim, 1.0f, 0.0f, - Animation_GetLastFrame(&gDekuPalaceGuardWalkAnim), 2, -10.0f); + Animation_GetLastFrame(&gDekuPalaceGuardWalkAnim), ANIMMODE_ONCE, -10.0f); this->state = PALACE_GUARD_CAUGHT_PLAYER; this->actionFunc = EnLookNuts_SendPlayerToSpawn; } -void EnLookNuts_SendPlayerToSpawn(EnLookNuts* this, GlobalContext* globalCtx) { +void EnLookNuts_SendPlayerToSpawn(EnLookNuts* this, PlayState* play) { SkelAnime_Update(&this->skelAnime); Math_SmoothStepToS(&this->actor.world.rot.y, this->actor.yawTowardsPlayer, 1, 0xBB8, 0); - if ((Message_GetState(&globalCtx->msgCtx) == 5) && Message_ShouldAdvance(globalCtx)) { - func_801477B4(globalCtx); - globalCtx->nextEntranceIndex = Entrance_CreateIndexFromSpawn(this->spawnIndex); + if ((Message_GetState(&play->msgCtx) == TEXT_STATE_5) && Message_ShouldAdvance(play)) { + func_801477B4(play); + play->nextEntrance = Entrance_CreateFromSpawn(this->spawnIndex); gSaveContext.nextCutsceneIndex = 0; - Scene_SetExitFade(globalCtx); - globalCtx->sceneLoadFlag = 0x14; + Scene_SetExitFade(play); + play->transitionTrigger = TRANS_TRIGGER_START; gSaveContext.save.weekEventReg[17] |= 4; } } static Vec3f effectVecInitialize = { 0.0f, 0.0f, 0.0f }; -void EnLookNuts_Update(Actor* thisx, GlobalContext* globalCtx) { +void EnLookNuts_Update(Actor* thisx, PlayState* play) { s32 pad; EnLookNuts* this = THIS; Vec3f effectVelOffset; @@ -317,7 +319,7 @@ void EnLookNuts_Update(Actor* thisx, GlobalContext* globalCtx) { this->blinkTimer = (s16)Rand_ZeroFloat(60.0f) + 20; } } - this->actionFunc(this, globalCtx); + this->actionFunc(this, play); if (this->blinkTimer != 0) { this->blinkTimer--; } @@ -332,34 +334,34 @@ void EnLookNuts_Update(Actor* thisx, GlobalContext* globalCtx) { effectPos.x += Math_SinS((this->actor.world.rot.y + (s16)this->headRotation.y)) * 10.0f; effectPos.y += 30.0f; effectPos.z += Math_CosS((this->actor.world.rot.y + (s16)this->headRotation.y)) * 10.0f; - Matrix_StatePush(); - Matrix_RotateY(this->actor.shape.rot.y, MTXMODE_NEW); + 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->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 (Player_GetMask(play) != PLAYER_MASK_STONE) { + EffectSsSolderSrchBall_Spawn(play, &effectPos, &effectVel, &gZeroVec3f, 50, &this->isPlayerDetected, + drawFlag); } } if ((this->isPlayerDetected == true) || (this->actor.xzDistToPlayer < 20.0f)) { - Player* player = GET_PLAYER(globalCtx); + Player* player = GET_PLAYER(play); - if (!(player->stateFlags3 & 0x100) && !Play_InCsMode(globalCtx)) { + if (!(player->stateFlags3 & 0x100) && !Play_InCsMode(play)) { 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); + func_800B7298(play, &this->actor, 0x1A); D_80A6862C = 1; this->actor.flags |= (ACTOR_FLAG_1 | ACTOR_FLAG_10); this->actor.gravity = 0.0f; - EnLookNuts_DetectedPlayer(this, globalCtx); + EnLookNuts_DetectedPlayer(this, play); } else { this->isPlayerDetected = false; } @@ -370,7 +372,7 @@ void EnLookNuts_Update(Actor* thisx, GlobalContext* globalCtx) { 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); + CollisionCheck_SetAC(play, &play->colChkCtx, &this->collider.base); } } @@ -380,14 +382,14 @@ static TexturePtr sEyeTextures[] = { gDekuPalaceGuardEyeClosedTex, }; -void EnLookNuts_Draw(Actor* thisx, GlobalContext* globalCtx) { +void EnLookNuts_Draw(Actor* thisx, PlayState* play) { EnLookNuts* this = THIS; - OPEN_DISPS(globalCtx->state.gfxCtx); + OPEN_DISPS(play->state.gfxCtx); - func_8012C28C(globalCtx->state.gfxCtx); + func_8012C28C(play->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); + SkelAnime_DrawOpa(play, this->skelAnime.skeleton, this->skelAnime.jointTable, NULL, NULL, &this->actor); - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->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 c06f0e2cd..9d5a1eb24 100644 --- a/src/overlays/actors/ovl_En_Look_Nuts/z_en_look_nuts.h +++ b/src/overlays/actors/ovl_En_Look_Nuts/z_en_look_nuts.h @@ -6,33 +6,33 @@ struct EnLookNuts; -typedef void (*EnLookNutsActionFunc)(struct EnLookNuts*, GlobalContext*); +typedef void (*EnLookNutsActionFunc)(struct EnLookNuts*, PlayState*); #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 */ SkelAnime skelAnime; - /* 0x0188 */ Vec3s jointTable[OBJECT_DNK_LIMB_MAX]; - /* 0x01CA */ Vec3s morphTable[OBJECT_DNK_LIMB_MAX]; - /* 0x020C */ EnLookNutsActionFunc actionFunc; - /* 0x0210 */ Path *path; - /* 0x0214 */ s16 currentPathIndex; // Index for the point where the deku guard is in its path - /* 0x0216 */ s16 eyeState; - /* 0x0218 */ s16 blinkTimer; - /* 0x021A */ s16 eventTimer; // Timer to trigger when another event within the actor will happen - /* 0x021C */ s16 state; - /* 0x021E */ s16 switchFlag; - /* 0x0220 */ s16 pathLocation; // Determines path that a guard will patrol - /* 0x0222 */ s16 isPlayerDetected; - /* 0x0224 */ s16 waitTimer; // Timer for how long the deku guard will take a break for - /* 0x0226 */ s16 spawnIndex; - /* 0x0228 */ UNK_TYPE4 pad228; // Unused necessary padding - /* 0x022C */ Vec3f headRotation; - /* 0x0238 */ Vec3f headRotTarget; // Target value for head rotation - /* 0x0244 */ ColliderCylinder collider; + /* 0x000 */ Actor actor; + /* 0x144 */ SkelAnime skelAnime; + /* 0x188 */ Vec3s jointTable[DEKU_PALACE_GUARD_LIMB_MAX]; + /* 0x1CA */ Vec3s morphTable[DEKU_PALACE_GUARD_LIMB_MAX]; + /* 0x20C */ EnLookNutsActionFunc actionFunc; + /* 0x210 */ Path *path; + /* 0x214 */ s16 currentPathIndex; // Index for the point where the deku guard is in its path + /* 0x216 */ s16 eyeState; + /* 0x218 */ s16 blinkTimer; + /* 0x21A */ s16 eventTimer; // Timer to trigger when another event within the actor will happen + /* 0x21C */ s16 state; + /* 0x21E */ s16 switchFlag; + /* 0x220 */ s16 pathLocation; // Determines path that a guard will patrol + /* 0x222 */ s16 isPlayerDetected; + /* 0x224 */ s16 waitTimer; // Timer for how long the deku guard will take a break for + /* 0x226 */ s16 spawnIndex; + /* 0x228 */ UNK_TYPE4 pad228; // Unused necessary padding + /* 0x22C */ Vec3f headRotation; + /* 0x238 */ Vec3f headRotTarget; // Target value for head rotation + /* 0x244 */ ColliderCylinder collider; } EnLookNuts; // size = 0x290 extern const ActorInit En_Look_Nuts_InitVars; diff --git a/src/overlays/actors/ovl_En_M_Fire1/z_en_m_fire1.c b/src/overlays/actors/ovl_En_M_Fire1/z_en_m_fire1.c index 4da43c3cf..e42e70ca3 100644 --- a/src/overlays/actors/ovl_En_M_Fire1/z_en_m_fire1.c +++ b/src/overlays/actors/ovl_En_M_Fire1/z_en_m_fire1.c @@ -10,9 +10,9 @@ #define THIS ((EnMFire1*)thisx) -void EnMFire1_Init(Actor* thisx, GlobalContext* globalCtx); -void EnMFire1_Destroy(Actor* thisx, GlobalContext* globalCtx); -void EnMFire1_Update(Actor* thisx, GlobalContext* globalCtx); +void EnMFire1_Init(Actor* thisx, PlayState* play); +void EnMFire1_Destroy(Actor* thisx, PlayState* play); +void EnMFire1_Update(Actor* thisx, PlayState* play); const ActorInit En_M_Fire1_InitVars = { ACTOR_EN_M_FIRE1, @@ -46,24 +46,24 @@ static ColliderCylinderInit sCylinderInit = { { 100, 100, 0, { 0, 0, 0 } }, }; -void EnMFire1_Init(Actor* thisx, GlobalContext* globalCtx) { +void EnMFire1_Init(Actor* thisx, PlayState* play) { EnMFire1* this = THIS; s32 pad; - Collider_InitCylinder(globalCtx, &this->collider); - Collider_SetCylinder(globalCtx, &this->collider, &this->actor, &sCylinderInit); + Collider_InitCylinder(play, &this->collider); + Collider_SetCylinder(play, &this->collider, &this->actor, &sCylinderInit); if (this->actor.params != 0) { this->collider.info.toucher.dmgFlags = 0x40000; } } -void EnMFire1_Destroy(Actor* thisx, GlobalContext* globalCtx) { +void EnMFire1_Destroy(Actor* thisx, PlayState* play) { EnMFire1* this = THIS; - Collider_DestroyCylinder(globalCtx, &this->collider); + Collider_DestroyCylinder(play, &this->collider); } -void EnMFire1_Update(Actor* thisx, GlobalContext* globalCtx) { +void EnMFire1_Update(Actor* thisx, PlayState* play) { EnMFire1* this = THIS; s32 pad; @@ -71,6 +71,6 @@ void EnMFire1_Update(Actor* thisx, GlobalContext* globalCtx) { Actor_MarkForDeath(&this->actor); } else { Collider_UpdateCylinder(&this->actor, &this->collider); - CollisionCheck_SetAT(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + CollisionCheck_SetAT(play, &play->colChkCtx, &this->collider.base); } } 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 a7f83a42c..b509cf789 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 @@ -5,15 +5,16 @@ */ #include "z_en_m_thunder.h" +#include "z64rumble.h" #define FLAGS (ACTOR_FLAG_10) #define THIS ((EnMThunder*)thisx) -void EnMThunder_Init(Actor* thisx, GlobalContext* globalCtx); -void EnMThunder_Destroy(Actor* thisx, GlobalContext* globalCtx); -void EnMThunder_Update(Actor* thisx, GlobalContext* globalCtx); -void EnMThunder_Draw(Actor* thisx, GlobalContext* globalCtx); +void EnMThunder_Init(Actor* thisx, PlayState* play); +void EnMThunder_Destroy(Actor* thisx, PlayState* play); +void EnMThunder_Update(Actor* thisx, PlayState* play); +void EnMThunder_Draw(Actor* thisx, PlayState* play); #if 0 const ActorInit En_M_Thunder_InitVars = { diff --git a/src/overlays/actors/ovl_En_M_Thunder/z_en_m_thunder.h b/src/overlays/actors/ovl_En_M_Thunder/z_en_m_thunder.h index a05546ba4..14d022770 100644 --- a/src/overlays/actors/ovl_En_M_Thunder/z_en_m_thunder.h +++ b/src/overlays/actors/ovl_En_M_Thunder/z_en_m_thunder.h @@ -5,13 +5,13 @@ struct EnMThunder; -typedef void (*EnMThunderActionFunc)(struct EnMThunder*, GlobalContext*); +typedef void (*EnMThunderActionFunc)(struct EnMThunder*, PlayState*); typedef struct EnMThunder { - /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x74]; - /* 0x01B8 */ EnMThunderActionFunc actionFunc; - /* 0x01BC */ char unk_1BC[0x8]; + /* 0x000 */ Actor actor; + /* 0x144 */ char unk_144[0x74]; + /* 0x1B8 */ EnMThunderActionFunc actionFunc; + /* 0x1BC */ char unk_1BC[0x8]; } EnMThunder; // size = 0x1C4 extern const ActorInit En_M_Thunder_InitVars; diff --git a/src/overlays/actors/ovl_En_Ma4/z_en_ma4.c b/src/overlays/actors/ovl_En_Ma4/z_en_ma4.c index 031f2113f..a10b26514 100644 --- a/src/overlays/actors/ovl_En_Ma4/z_en_ma4.c +++ b/src/overlays/actors/ovl_En_Ma4/z_en_ma4.c @@ -5,40 +5,39 @@ */ #include "z_en_ma4.h" -#include "objects/object_ma1/object_ma1.h" #define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_8 | ACTOR_FLAG_10 | ACTOR_FLAG_20 | ACTOR_FLAG_2000000) #define THIS ((EnMa4*)thisx) -void EnMa4_Init(Actor* thisx, GlobalContext* globalCtx); -void EnMa4_Destroy(Actor* thisx, GlobalContext* globalCtx); -void EnMa4_Update(Actor* thisx, GlobalContext* globalCtx); -void EnMa4_Draw(Actor* thisx, GlobalContext* globalCtx); +void EnMa4_Init(Actor* thisx, PlayState* play); +void EnMa4_Destroy(Actor* thisx, PlayState* play); +void EnMa4_Update(Actor* thisx, PlayState* play); +void EnMa4_Draw(Actor* thisx, PlayState* play); void EnMa4_SetupWait(EnMa4* this); -void EnMa4_Wait(EnMa4* this, GlobalContext* globalCtx); -void EnMa4_HandlePlayerChoice(EnMa4* this, GlobalContext* globalCtx); -void EnMa4_ChooseNextDialogue(EnMa4* this, GlobalContext* globalCtx); +void EnMa4_Wait(EnMa4* this, PlayState* play); +void EnMa4_HandlePlayerChoice(EnMa4* this, PlayState* play); +void EnMa4_ChooseNextDialogue(EnMa4* this, PlayState* play); void EnMa4_SetupDialogueHandler(EnMa4* this); -void EnMa4_DialogueHandler(EnMa4* this, GlobalContext* globalCtx); +void EnMa4_DialogueHandler(EnMa4* this, PlayState* play); void EnMa4_SetupBeginHorsebackGame(EnMa4* this); -void EnMa4_BeginHorsebackGame(EnMa4* this, GlobalContext* globalCtx); -void EnMa4_HorsebackGameTalking(EnMa4* this, GlobalContext* globalCtx); -void EnMa4_InitHorsebackGame(EnMa4* this, GlobalContext* globalCtx); -void EnMa4_SetupHorsebackGameWait(EnMa4* this, GlobalContext* globalCtx); -void EnMa4_HorsebackGameWait(EnMa4* this, GlobalContext* globalCtx); -void EnMa4_SetupHorsebackGameEnd(EnMa4* this, GlobalContext* globalCtx); -void EnMa4_HorsebackGameEnd(EnMa4* this, GlobalContext* globalCtx); +void EnMa4_BeginHorsebackGame(EnMa4* this, PlayState* play); +void EnMa4_HorsebackGameTalking(EnMa4* this, PlayState* play); +void EnMa4_InitHorsebackGame(EnMa4* this, PlayState* play); +void EnMa4_SetupHorsebackGameWait(EnMa4* this, PlayState* play); +void EnMa4_HorsebackGameWait(EnMa4* this, PlayState* play); +void EnMa4_SetupHorsebackGameEnd(EnMa4* this, PlayState* play); +void EnMa4_HorsebackGameEnd(EnMa4* this, PlayState* play); void EnMa4_SetupBeginEponasSongCs(EnMa4* this); -void EnMa4_BeginEponasSongCs(EnMa4* this, GlobalContext* globalCtx); +void EnMa4_BeginEponasSongCs(EnMa4* this, PlayState* play); void EnMa4_SetupEponasSongCs(EnMa4* this); -void EnMa4_EponasSongCs(EnMa4* this, GlobalContext* globalCtx); +void EnMa4_EponasSongCs(EnMa4* this, PlayState* play); void EnMa4_SetupEndEponasSongCs(EnMa4* this); -void EnMa4_EndEponasSongCs(EnMa4* this, GlobalContext* globalCtx); +void EnMa4_EndEponasSongCs(EnMa4* this, PlayState* play); void EnMa4_SetupBeginDescribeThemCs(EnMa4* this); -void EnMa4_BeginDescribeThemCs(EnMa4* this, GlobalContext* globalCtx); -void EnMa4_StartDialogue(EnMa4* this, GlobalContext* globalCtx); +void EnMa4_BeginDescribeThemCs(EnMa4* this, PlayState* play); +void EnMa4_StartDialogue(EnMa4* this, PlayState* play); void EnMa4_SetFaceExpression(EnMa4* this, s16 overrideEyeTexIndex, s16 mouthTexIndex); void EnMa4_InitFaceExpression(EnMa4* this); @@ -90,14 +89,14 @@ static ColliderCylinderInit sCylinderInit = { static CollisionCheckInfoInit2 D_80AC00DC = { 0, 0, 0, 0, MASS_IMMOVABLE }; static TexturePtr sEyeTextures[] = { - object_ma1_Tex_00FFC8, object_ma1_Tex_0107C8, object_ma1_Tex_010FC8, object_ma1_Tex_0117C8, object_ma1_Tex_011FC8, + gRomaniEyeOpenTex, gRomaniEyeHalfTex, gRomaniEyeClosedTex, gRomaniEyeHappyTex, gRomaniEyeSadTex, }; static TexturePtr sMouthTextures[] = { - object_ma1_Tex_0127C8, - object_ma1_Tex_012BC8, - object_ma1_Tex_012FC8, - object_ma1_Tex_0133C8, + gRomaniMouthHappyTex, + gRomaniMouthFrownTex, + gRomaniMouthHangingOpenTex, + gRomaniMouthSmileTex, }; void EnMa4_UpdateEyes(EnMa4* this) { @@ -113,41 +112,41 @@ void EnMa4_UpdateEyes(EnMa4* this) { } 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 + { &gRomaniIdleAnim, 1.0f, ANIMMODE_LOOP, 0.0f }, + { &gRomaniIdleAnim, 1.0f, ANIMMODE_LOOP, -6.0f }, + { &gRomaniLookAroundAnim, 1.0f, ANIMMODE_LOOP, 0.0f }, + { &gRomaniLookAroundAnim, 1.0f, ANIMMODE_LOOP, -6.0f }, + { &gRomaniSingStartAnim, 1.0f, ANIMMODE_ONCE, 0.0f }, + { &gRomaniSingStartAnim, 1.0f, ANIMMODE_ONCE, -6.0f }, + { &gRomaniSingLoopAnim, 1.0f, ANIMMODE_LOOP, 0.0f }, + { &gRomaniSingLoopAnim, 1.0f, ANIMMODE_LOOP, -6.0f }, + { &gRomaniRunAnim, 1.0f, ANIMMODE_LOOP, 0.0f }, + { &gRomaniRunAnim, 1.0f, ANIMMODE_LOOP, -6.0f }, + { &gRomaniWalkAnim, 1.0f, ANIMMODE_LOOP, 0.0f }, + { &gRomaniWalkAnim, 1.0f, ANIMMODE_LOOP, -6.0f }, + { &gRomaniShootBowAnim, 1.0f, ANIMMODE_ONCE, 0.0f }, + { &gRomaniShootBowAnim, 1.0f, ANIMMODE_ONCE, -6.0f }, + { &gRomaniSittingAnim, 1.0f, ANIMMODE_LOOP, 0.0f }, + { &gRomaniSittingAnim, 1.0f, ANIMMODE_LOOP, -6.0f }, + { &gRomaniSittingHeadShakeAnim, 1.0f, ANIMMODE_LOOP, 0.0f }, + { &gRomaniSittingHeadShakeAnim, 1.0f, ANIMMODE_LOOP, -6.0f }, + { &gRomaniSittingLookDownAnim, 1.0f, ANIMMODE_LOOP, 0.0f }, + { &gRomaniSittingLookDownAnim, 1.0f, ANIMMODE_LOOP, -6.0f }, }; -void EnMa4_ChangeAnim(EnMa4* this, s32 index) { - Animation_Change(&this->skelAnime, sAnimationInfo[index].animation, 1.0f, 0.0f, - Animation_GetLastFrame(sAnimationInfo[index].animation), sAnimationInfo[index].mode, - sAnimationInfo[index].morphFrames); +void EnMa4_ChangeAnim(EnMa4* this, s32 animIndex) { + Animation_Change(&this->skelAnime, sAnimationInfo[animIndex].animation, 1.0f, 0.0f, + Animation_GetLastFrame(sAnimationInfo[animIndex].animation), sAnimationInfo[animIndex].mode, + sAnimationInfo[animIndex].morphFrames); } -void func_80ABDD9C(EnMa4* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); +void func_80ABDD9C(EnMa4* this, PlayState* play) { + Player* player = GET_PLAYER(play); s16 flag; - if (this->unk_1D8.unk_00 == 0 && ((this->skelAnime.animation == &object_ma1_Anim_007328) || - (this->skelAnime.animation == &object_ma1_Anim_002A8C) || - (this->skelAnime.animation == &object_ma1_Anim_015B7C))) { + if (this->unk_1D8.unk_00 == 0 && + ((this->skelAnime.animation == &gRomaniRunAnim) || (this->skelAnime.animation == &gRomaniLookAroundAnim) || + (this->skelAnime.animation == &gRomaniShootBowAnim))) { flag = 1; } else { flag = (this->type == MA4_TYPE_ALIENS_WON && this->actionFunc != EnMa4_DialogueHandler) ? 1 : 0; @@ -158,11 +157,11 @@ void func_80ABDD9C(EnMa4* this, GlobalContext* globalCtx) { func_800BD888(&this->actor, &this->unk_1D8, 0, flag); } -void EnMa4_InitPath(EnMa4* this, GlobalContext* globalCtx) { +void EnMa4_InitPath(EnMa4* this, PlayState* play) { Path* path; Vec3f nextPoint; - path = &globalCtx->setupPathList[(this->actor.params & 0xFF00) >> 8]; + path = &play->setupPathList[(this->actor.params & 0xFF00) >> 8]; this->pathPoints = Lib_SegmentedToVirtual(path->points); this->pathIndex = 0; this->pathPointsCount = path->count; @@ -178,19 +177,18 @@ void EnMa4_InitPath(EnMa4* this, GlobalContext* globalCtx) { this->actor.shape.rot.y = this->actor.world.rot.y = Math_Vec3f_Yaw(&this->actor.world.pos, &nextPoint); } -void EnMa4_Init(Actor* thisx, GlobalContext* globalCtx) { +void EnMa4_Init(Actor* thisx, PlayState* play) { EnMa4* this = THIS; s32 pad; ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 18.0f); - SkelAnime_InitFlex(globalCtx, &this->skelAnime, &object_ma1_Skel_013928, NULL, this->jointTable, this->morphTable, - MA1_LIMB_MAX); + SkelAnime_InitFlex(play, &this->skelAnime, &gRomaniSkel, NULL, this->jointTable, this->morphTable, ROMANI_LIMB_MAX); - Collider_InitCylinder(globalCtx, &this->collider); - Collider_SetCylinder(globalCtx, &this->collider, &this->actor, &sCylinderInit); + Collider_InitCylinder(play, &this->collider); + Collider_SetCylinder(play, &this->collider, &this->actor, &sCylinderInit); CollisionCheck_SetInfo2(&this->actor.colChkInfo, DamageTable_Get(0x16), &D_80AC00DC); - Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 0.0f, 0.0f, 0.0f, 4); + Actor_UpdateBgCheckInfo(play, &this->actor, 0.0f, 0.0f, 0.0f, 4); Actor_SetScale(&this->actor, 0.01f); this->actor.targetMode = 0; @@ -209,17 +207,17 @@ void EnMa4_Init(Actor* thisx, GlobalContext* globalCtx) { this->hasBow = false; } - if (Cutscene_GetSceneSetupIndex(globalCtx) != 0) { // if (sceneSetupIndex != 0) + if (Cutscene_GetSceneSetupIndex(play) != 0) { // if (sceneSetupIndex != 0) EnMa4_ChangeAnim(this, 0); this->state = MA4_STATE_HORSEBACKGAME; - EnMa4_InitHorsebackGame(this, globalCtx); + EnMa4_InitHorsebackGame(this, play); } else { - EnMa4_InitPath(this, globalCtx); + EnMa4_InitPath(this, play); - if (gSaveContext.save.entranceIndex == 0x6410) { + if (gSaveContext.save.entrance == ENTRANCE(ROMANI_RANCH, 1)) { EnMa4_ChangeAnim(this, 0); this->state = MA4_STATE_AFTERHORSEBACKGAME; - } else if (gSaveContext.save.entranceIndex == 0x64A0) { + } else if (gSaveContext.save.entrance == ENTRANCE(ROMANI_RANCH, 10)) { EnMa4_ChangeAnim(this, 0); this->state = MA4_STATE_AFTERDESCRIBETHEMCS; } else { @@ -236,39 +234,39 @@ void EnMa4_Init(Actor* thisx, GlobalContext* globalCtx) { } } -void EnMa4_Destroy(Actor* thisx, GlobalContext* globalCtx) { +void EnMa4_Destroy(Actor* thisx, PlayState* play) { EnMa4* this = THIS; - Collider_DestroyCylinder(globalCtx, &this->collider); + Collider_DestroyCylinder(play, &this->collider); gSaveContext.save.weekEventReg[8] &= (u8)~1; } // Running in circles in the ranch -void EnMa4_RunInCircles(EnMa4* this, GlobalContext* globalCtx) { - static s32 sCurrentAnim = 9; +void EnMa4_RunInCircles(EnMa4* this, PlayState* play) { + static s32 sAnimIndex = 9; static s32 D_80AC0250 = 0; static s16 D_80AC0254 = 10; Vec3f sp34; s32 pad; s16 sp2E; - if (sCurrentAnim != 9 && Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) { - if (sCurrentAnim == 3) { + if (sAnimIndex != 9 && Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) { + if (sAnimIndex == 3) { if (D_80AC0250 < 3) { D_80AC0250++; } else { D_80AC0250 = 0; EnMa4_ChangeAnim(this, 13); - sCurrentAnim = 13; + sAnimIndex = 13; } } else { this->actor.speedXZ = 2.7f; EnMa4_ChangeAnim(this, 9); - sCurrentAnim = 9; + sAnimIndex = 9; } } - if (sCurrentAnim == 13 && Animation_OnFrame(&this->skelAnime, 37.0f)) { + if (sAnimIndex == 13 && Animation_OnFrame(&this->skelAnime, 37.0f)) { Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_ROMANI_BOW_FLICK); } @@ -284,7 +282,7 @@ void EnMa4_RunInCircles(EnMa4* this, GlobalContext* globalCtx) { this->actor.speedXZ = 0.0f; D_80AC0254 = 2; EnMa4_ChangeAnim(this, 3); - sCurrentAnim = 3; + sAnimIndex = 3; } else { if (D_80AC0254 > 0) { D_80AC0254--; @@ -298,9 +296,9 @@ void EnMa4_RunInCircles(EnMa4* this, GlobalContext* globalCtx) { } } - Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 0.0f, 0.0f, 0.0f, 4); + Actor_UpdateBgCheckInfo(play, &this->actor, 0.0f, 0.0f, 0.0f, 4); Actor_MoveWithGravity(&this->actor); - if (this->skelAnime.animation == &object_ma1_Anim_007328) { // Walking animation + if (this->skelAnime.animation == &gRomaniRunAnim) { if (Animation_OnFrame(&this->skelAnime, 0.0f) || Animation_OnFrame(&this->skelAnime, 4.0f)) { Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_ROMANI_WALK); } @@ -327,14 +325,14 @@ void EnMa4_SetupWait(EnMa4* this) { this->actionFunc = EnMa4_Wait; } -void EnMa4_Wait(EnMa4* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); +void EnMa4_Wait(EnMa4* this, PlayState* play) { + Player* player = GET_PLAYER(play); s16 yaw = this->actor.shape.rot.y - this->actor.yawTowardsPlayer; if ((this->state == MA4_STATE_AFTERHORSEBACKGAME) || (this->state == MA4_STATE_AFTERDESCRIBETHEMCS)) { this->actor.flags |= ACTOR_FLAG_10000; } else if (this->type != MA4_TYPE_ALIENS_WON) { - EnMa4_RunInCircles(this, globalCtx); + EnMa4_RunInCircles(this, play); } else if (Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) { this->animTimer++; if (this->animTimer == 5) { @@ -345,233 +343,233 @@ void EnMa4_Wait(EnMa4* this, GlobalContext* globalCtx) { } } - if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state) != 0) { - EnMa4_StartDialogue(this, globalCtx); + if (Actor_ProcessTalkRequest(&this->actor, &play->state) != 0) { + EnMa4_StartDialogue(this, play); EnMa4_SetupDialogueHandler(this); } else if (this->type != MA4_TYPE_ALIENS_WON || ABS_ALT(yaw) < 0x4000) { if (!(player->stateFlags1 & 0x800000)) { - func_800B8614(&this->actor, globalCtx, 100.0f); + func_800B8614(&this->actor, play, 100.0f); } } } // Chooses the next dialogue based on player's selection -void EnMa4_HandlePlayerChoice(EnMa4* this, GlobalContext* globalCtx) { - if (Message_ShouldAdvance(globalCtx) != 0) { +void EnMa4_HandlePlayerChoice(EnMa4* this, PlayState* play) { + if (Message_ShouldAdvance(play)) { switch (this->textId) { case 0x3339: - if (globalCtx->msgCtx.choiceIndex == 0) { + if (play->msgCtx.choiceIndex == 0) { func_8019F208(); - Message_StartTextbox(globalCtx, 0x333A, &this->actor); + Message_StartTextbox(play, 0x333A, &this->actor); this->textId = 0x333A; } else { func_8019F208(); - Message_StartTextbox(globalCtx, 0x333B, &this->actor); + Message_StartTextbox(play, 0x333B, &this->actor); this->textId = 0x333B; } break; case 0x3341: - if (globalCtx->msgCtx.choiceIndex == 0) { + if (play->msgCtx.choiceIndex == 0) { func_8019F208(); gSaveContext.save.weekEventReg[21] |= 0x20; - Message_StartTextbox(globalCtx, 0x3343, &this->actor); + Message_StartTextbox(play, 0x3343, &this->actor); this->textId = 0x3343; } else { func_8019F230(); EnMa4_SetFaceExpression(this, 0, 1); - Message_StartTextbox(globalCtx, 0x3342, &this->actor); + Message_StartTextbox(play, 0x3342, &this->actor); this->textId = 0x3342; this->state = MA4_STATE_DEFAULT; - func_80151BB4(globalCtx, 5); + func_80151BB4(play, 5); } break; case 0x3346: - if (globalCtx->msgCtx.choiceIndex == 0) { + if (play->msgCtx.choiceIndex == 0) { func_8019F208(); gSaveContext.save.weekEventReg[21] |= 0x20; - Message_StartTextbox(globalCtx, 0x3343, &this->actor); + Message_StartTextbox(play, 0x3343, &this->actor); this->textId = 0x3343; } else { func_8019F230(); EnMa4_SetFaceExpression(this, 0, 1); - Message_StartTextbox(globalCtx, 0x3342, &this->actor); + Message_StartTextbox(play, 0x3342, &this->actor); this->textId = 0x3342; } break; case 0x3347: - if (globalCtx->msgCtx.choiceIndex == 0) { + if (play->msgCtx.choiceIndex == 0) { func_8019F208(); - Message_StartTextbox(globalCtx, 0x3349, &this->actor); + Message_StartTextbox(play, 0x3349, &this->actor); this->textId = 0x3349; } else { func_8019F230(); - Message_StartTextbox(globalCtx, 0x3348, &this->actor); + Message_StartTextbox(play, 0x3348, &this->actor); this->textId = 0x3348; - func_80151BB4(globalCtx, 5); + func_80151BB4(play, 5); } break; - case 0x334D: // Asks if you understood her explanation. - if (globalCtx->msgCtx.choiceIndex == 0) { // Yes + case 0x334D: // Asks if you understood her explanation. + if (play->msgCtx.choiceIndex == 0) { // Yes s32 aux; func_8019F208(); - Message_StartTextbox(globalCtx, 0x334E, &this->actor); + Message_StartTextbox(play, 0x334E, &this->actor); this->textId = 0x334E; if (CHECK_QUEST_ITEM(QUEST_SONG_EPONA)) { - func_80151BB4(globalCtx, 0x1C); + func_80151BB4(play, 0x1C); } - func_80151BB4(globalCtx, 5); + func_80151BB4(play, 5); } else { // No. func_8019F230(); EnMa4_SetFaceExpression(this, 0, 0); - Message_StartTextbox(globalCtx, 0x334C, &this->actor); + Message_StartTextbox(play, 0x334C, &this->actor); this->textId = 0x334C; } break; case 0x3354: - if (globalCtx->msgCtx.choiceIndex == 0) { + if (play->msgCtx.choiceIndex == 0) { func_8019F208(); - Message_StartTextbox(globalCtx, 0x3349, &this->actor); + Message_StartTextbox(play, 0x3349, &this->actor); this->textId = 0x3349; } else { func_8019F230(); EnMa4_SetFaceExpression(this, 1, 0); - Message_StartTextbox(globalCtx, 0x3355, &this->actor); + Message_StartTextbox(play, 0x3355, &this->actor); this->textId = 0x3355; - func_80151BB4(globalCtx, 5); + func_80151BB4(play, 5); } break; case 0x3356: // "Try again?" - if (globalCtx->msgCtx.choiceIndex == 0) { // Yes + if (play->msgCtx.choiceIndex == 0) { // Yes func_8019F208(); - func_801477B4(globalCtx); + func_801477B4(play); EnMa4_SetupBeginHorsebackGame(this); } else { // No if (this->type == MA4_TYPE_ALIENS_DEFEATED) { func_8019F230(); EnMa4_SetFaceExpression(this, 3, 3); - Message_StartTextbox(globalCtx, 0x3357, &this->actor); + Message_StartTextbox(play, 0x3357, &this->actor); this->textId = 0x3357; - func_80151BB4(globalCtx, 5); + func_80151BB4(play, 5); } else { func_8019F230(); EnMa4_SetFaceExpression(this, 4, 2); - Message_StartTextbox(globalCtx, 0x335B, &this->actor); + Message_StartTextbox(play, 0x335B, &this->actor); this->textId = 0x335B; - func_80151BB4(globalCtx, 5); + func_80151BB4(play, 5); } } break; case 0x3359: - if (globalCtx->msgCtx.choiceIndex == 0) { + if (play->msgCtx.choiceIndex == 0) { func_8019F208(); - Message_StartTextbox(globalCtx, 0x3349, &this->actor); + Message_StartTextbox(play, 0x3349, &this->actor); this->textId = 0x3349; } else { func_8019F230(); EnMa4_SetFaceExpression(this, 4, 2); - Message_StartTextbox(globalCtx, 0x335A, &this->actor); + Message_StartTextbox(play, 0x335A, &this->actor); this->textId = 0x335A; - func_80151BB4(globalCtx, 5); + func_80151BB4(play, 5); } break; } } } -void EnMa4_ChooseNextDialogue(EnMa4* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); +void EnMa4_ChooseNextDialogue(EnMa4* this, PlayState* play) { + Player* player = GET_PLAYER(play); s32 aux; - if (Message_ShouldAdvance(globalCtx) != 0) { + if (Message_ShouldAdvance(play)) { switch (this->textId) { case 0x2390: - func_801477B4(globalCtx); + func_801477B4(play); EnMa4_SetupBeginHorsebackGame(this); break; case 0x3335: EnMa4_SetFaceExpression(this, 0, 3); - Message_StartTextbox(globalCtx, 0x3336, &this->actor); + Message_StartTextbox(play, 0x3336, &this->actor); this->textId = 0x3336; - func_80151BB4(globalCtx, 5); + func_80151BB4(play, 5); break; case 0x3338: - Message_StartTextbox(globalCtx, 0x3339, &this->actor); + Message_StartTextbox(play, 0x3339, &this->actor); this->textId = 0x3339; break; case 0x333A: case 0x333B: EnMa4_SetFaceExpression(this, 0, 3); - Message_StartTextbox(globalCtx, 0x333C, &this->actor); + Message_StartTextbox(play, 0x333C, &this->actor); this->textId = 0x333C; break; case 0x333C: EnMa4_SetFaceExpression(this, 0, 2); - Message_StartTextbox(globalCtx, 0x333D, &this->actor); + Message_StartTextbox(play, 0x333D, &this->actor); this->textId = 0x333D; break; case 0x333D: - Message_StartTextbox(globalCtx, 0x333E, &this->actor); + Message_StartTextbox(play, 0x333E, &this->actor); this->textId = 0x333E; break; case 0x333E: - func_801477B4(globalCtx); + func_801477B4(play); EnMa4_SetupBeginDescribeThemCs(this); break; case 0x333F: - Message_StartTextbox(globalCtx, 0x3340, &this->actor); + Message_StartTextbox(play, 0x3340, &this->actor); this->textId = 0x3340; break; case 0x3340: EnMa4_SetFaceExpression(this, 0, 3); - Message_StartTextbox(globalCtx, 0x3341, &this->actor); + Message_StartTextbox(play, 0x3341, &this->actor); this->textId = 0x3341; break; case 0x3343: EnMa4_SetFaceExpression(this, 0, 0); - Message_StartTextbox(globalCtx, 0x3344, &this->actor); + Message_StartTextbox(play, 0x3344, &this->actor); this->textId = 0x3344; break; case 0x3344: - Message_StartTextbox(globalCtx, 0x3345, &this->actor); + Message_StartTextbox(play, 0x3345, &this->actor); this->textId = 0x3345; break; case 0x3345: - Message_StartTextbox(globalCtx, 0x3349, &this->actor); + Message_StartTextbox(play, 0x3349, &this->actor); this->textId = 0x3349; break; case 0x3349: - Message_StartTextbox(globalCtx, 0x334A, &this->actor); + Message_StartTextbox(play, 0x334A, &this->actor); this->textId = 0x334A; break; case 0x334A: - func_801477B4(globalCtx); + func_801477B4(play); EnMa4_SetupBeginHorsebackGame(this); break; case 0x334C: - Message_StartTextbox(globalCtx, 0x334D, &this->actor); + Message_StartTextbox(play, 0x334D, &this->actor); this->textId = 0x334D; break; @@ -580,10 +578,10 @@ void EnMa4_ChooseNextDialogue(EnMa4* this, GlobalContext* globalCtx) { case 0x335D: case 0x335E: if (this->type == MA4_TYPE_DAY1) { - Message_StartTextbox(globalCtx, 0x3352, &this->actor); + Message_StartTextbox(play, 0x3352, &this->actor); this->textId = 0x3352; } else { - Message_StartTextbox(globalCtx, 0x3356, &this->actor); + Message_StartTextbox(play, 0x3356, &this->actor); this->textId = 0x3356; } break; @@ -594,23 +592,23 @@ void EnMa4_ChooseNextDialogue(EnMa4* this, GlobalContext* globalCtx) { // Check if player has Epona's song if (CHECK_QUEST_ITEM(QUEST_SONG_EPONA)) { - Message_StartTextbox(globalCtx, 0x334C, &this->actor); + Message_StartTextbox(play, 0x334C, &this->actor); this->textId = 0x334C; } else { - func_801477B4(globalCtx); + func_801477B4(play); player->stateFlags1 |= 0x20; EnMa4_SetupBeginEponasSongCs(this); - EnMa4_BeginEponasSongCs(this, globalCtx); + EnMa4_BeginEponasSongCs(this, play); } break; case 0x3358: if ((gSaveContext.save.playerForm != PLAYER_FORM_HUMAN) || !(CHECK_QUEST_ITEM(QUEST_SONG_EPONA))) { - Message_StartTextbox(globalCtx, 0x335C, &this->actor); + Message_StartTextbox(play, 0x335C, &this->actor); this->textId = 0x335C; - func_80151BB4(globalCtx, 5); + func_80151BB4(play, 5); } else { - Message_StartTextbox(globalCtx, 0x3359, &this->actor); + Message_StartTextbox(play, 0x3359, &this->actor); this->textId = 0x3359; } break; @@ -627,32 +625,30 @@ void EnMa4_SetupDialogueHandler(EnMa4* this) { this->actionFunc = EnMa4_DialogueHandler; } -void EnMa4_DialogueHandler(EnMa4* this, GlobalContext* globalCtx) { - s32 temp_v0; - - switch (Message_GetState(&globalCtx->msgCtx)) { +void EnMa4_DialogueHandler(EnMa4* this, PlayState* play) { + switch (Message_GetState(&play->msgCtx)) { default: break; - case 4: // Player answered a question - EnMa4_HandlePlayerChoice(this, globalCtx); + case TEXT_STATE_CHOICE: // Player answered a question + EnMa4_HandlePlayerChoice(this, play); break; - case 5: // End message block - EnMa4_ChooseNextDialogue(this, globalCtx); + case TEXT_STATE_5: // End message block + EnMa4_ChooseNextDialogue(this, play); break; - case 6: // End conversation - if (Message_ShouldAdvance(globalCtx) != 0) { - if ((globalCtx->msgCtx.unk120B1 == 0) || !CHECK_QUEST_ITEM(QUEST_BOMBERS_NOTEBOOK)) { + case TEXT_STATE_DONE: // End conversation + if (Message_ShouldAdvance(play)) { + if ((play->msgCtx.unk120B1 == 0) || !CHECK_QUEST_ITEM(QUEST_BOMBERS_NOTEBOOK)) { EnMa4_SetupWait(this); } } - case 0: - case 1: - case 2: - case 3: + case TEXT_STATE_NONE: + case TEXT_STATE_1: + case TEXT_STATE_CLOSING: + case TEXT_STATE_3: break; } @@ -665,109 +661,109 @@ void EnMa4_SetupBeginHorsebackGame(EnMa4* this) { this->actionFunc = EnMa4_BeginHorsebackGame; } -void EnMa4_BeginHorsebackGame(EnMa4* this, GlobalContext* globalCtx) { - globalCtx->nextEntranceIndex = 0x6400; +void EnMa4_BeginHorsebackGame(EnMa4* this, PlayState* play) { + play->nextEntrance = ENTRANCE(ROMANI_RANCH, 0); gSaveContext.nextCutsceneIndex = 0xFFF0; - globalCtx->sceneLoadFlag = 0x14; - globalCtx->unk_1887F = 0x50; - gSaveContext.nextTransition = 3; + play->transitionTrigger = TRANS_TRIGGER_START; + play->transitionType = TRANS_TYPE_80; + gSaveContext.nextTransitionType = TRANS_TYPE_03; } -void EnMa4_HorsebackGameCheckPlayerInteractions(EnMa4* this, GlobalContext* globalCtx) { - if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { +void EnMa4_HorsebackGameCheckPlayerInteractions(EnMa4* this, PlayState* play) { + if (Actor_ProcessTalkRequest(&this->actor, &play->state)) { // "You're feeling confident" - Message_StartTextbox(globalCtx, 0x336E, &this->actor); + Message_StartTextbox(play, 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); + func_800B8614(&this->actor, play, 100.0f); } } -void EnMa4_HorsebackGameTalking(EnMa4* this, GlobalContext* globalCtx) { - if (Actor_TextboxIsClosing(&this->actor, globalCtx)) { +void EnMa4_HorsebackGameTalking(EnMa4* this, PlayState* play) { + if (Actor_TextboxIsClosing(&this->actor, play)) { this->actionFunc = EnMa4_HorsebackGameWait; } } -void EnMa4_InitHorsebackGame(EnMa4* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); +void EnMa4_InitHorsebackGame(EnMa4* this, PlayState* play) { + Player* player = GET_PLAYER(play); - globalCtx->interfaceCtx.unk_280 = 1; + play->interfaceCtx.unk_280 = 1; func_8010E9F0(4, 0); gSaveContext.save.weekEventReg[8] |= 1; - func_80112AFC(globalCtx); + func_80112AFC(play); player->stateFlags1 |= 0x20; this->actionFunc = EnMa4_SetupHorsebackGameWait; } -void EnMa4_SetupHorsebackGameWait(EnMa4* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); +void EnMa4_SetupHorsebackGameWait(EnMa4* this, PlayState* play) { + Player* player = GET_PLAYER(play); - if (globalCtx->interfaceCtx.unk_280 == 8) { + if (play->interfaceCtx.unk_280 == 8) { this->actionFunc = EnMa4_HorsebackGameWait; player->stateFlags1 &= ~0x20; } } -void EnMa4_HorsebackGameWait(EnMa4* this, GlobalContext* globalCtx) { +void EnMa4_HorsebackGameWait(EnMa4* this, PlayState* play) { static s16 D_80AC0258 = 0; - Player* player = GET_PLAYER(globalCtx); + Player* player = GET_PLAYER(play); player->stateFlags3 |= 0x400; - EnMa4_HorsebackGameCheckPlayerInteractions(this, globalCtx); + EnMa4_HorsebackGameCheckPlayerInteractions(this, play); if (this->poppedBalloonCounter != D_80AC0258) { D_80AC0258 = this->poppedBalloonCounter; - globalCtx->interfaceCtx.unk_25C = 1; + play->interfaceCtx.unk_25C = 1; } if ((gSaveContext.unk_3DE0[4] >= 2 * 60 * 100) // timer >= 2 minutes || (this->poppedBalloonCounter == 10)) { gSaveContext.unk_3DD0[4] = 6; - EnMa4_SetupHorsebackGameEnd(this, globalCtx); + EnMa4_SetupHorsebackGameEnd(this, play); D_80AC0258 = 0; } } -void EnMa4_SetupHorsebackGameEnd(EnMa4* this, GlobalContext* globalCtx) { +void EnMa4_SetupHorsebackGameEnd(EnMa4* this, PlayState* play) { gSaveContext.save.weekEventReg[8] &= (u8)~1; this->actionFunc = EnMa4_HorsebackGameEnd; Audio_QueueSeqCmd(NA_BGM_STOP); Audio_QueueSeqCmd(NA_BGM_HORSE_GOAL | 0x8000); } -void EnMa4_HorsebackGameEnd(EnMa4* this, GlobalContext* globalCtx) { +void EnMa4_HorsebackGameEnd(EnMa4* this, PlayState* play) { static s32 sFrameCounter = 0; - Player* player = GET_PLAYER(globalCtx); + Player* player = GET_PLAYER(play); if (player->stateFlags1 & 0x100000) { - globalCtx->actorCtx.unk268 = 1; - globalCtx->actorCtx.unk_26C.press.button = BTN_A; + play->actorCtx.unk268 = 1; + play->actorCtx.unk_26C.press.button = BTN_A; } else { - globalCtx->actorCtx.unk268 = 1; + play->actorCtx.unk268 = 1; } if (sFrameCounter == 25) { if (this->poppedBalloonCounter == 10) { - Message_StartTextbox(globalCtx, 0x334F, &this->actor); + Message_StartTextbox(play, 0x334F, &this->actor); this->textId = 0x334F; } else { - Message_StartTextbox(globalCtx, 0x334B, &this->actor); + Message_StartTextbox(play, 0x334B, &this->actor); this->textId = 0x334B; } } else if (sFrameCounter == 50) { - globalCtx->actorCtx.unk268 = 0; - globalCtx->nextEntranceIndex = 0x6410; + play->actorCtx.unk268 = 0; + play->nextEntrance = ENTRANCE(ROMANI_RANCH, 1); gSaveContext.nextCutsceneIndex = 0; sFrameCounter = 0; - globalCtx->sceneLoadFlag = 0x14; + play->transitionTrigger = TRANS_TRIGGER_START; if (this->poppedBalloonCounter == 10) { - globalCtx->unk_1887F = 0x50; - gSaveContext.nextTransition = 3; + play->transitionType = TRANS_TYPE_80; + gSaveContext.nextTransitionType = TRANS_TYPE_03; } else { - globalCtx->unk_1887F = 0x40; - gSaveContext.nextTransition = 2; + play->transitionType = TRANS_TYPE_64; + gSaveContext.nextTransitionType = TRANS_TYPE_02; } this->poppedBalloonCounter = 0; @@ -781,7 +777,7 @@ void EnMa4_SetupBeginEponasSongCs(EnMa4* this) { } // Epona's Song cutscene is an ActorCutscene -void EnMa4_BeginEponasSongCs(EnMa4* this, GlobalContext* globalCtx) { +void EnMa4_BeginEponasSongCs(EnMa4* this, PlayState* play) { s16 cutsceneIndex = this->actor.cutscene; if (ActorCutscene_GetCanPlayNext(cutsceneIndex) != 0) { @@ -801,16 +797,16 @@ void EnMa4_SetupEponasSongCs(EnMa4* this) { } static u16 D_80AC0260 = 99; -void EnMa4_EponasSongCs(EnMa4* this, GlobalContext* globalCtx) { - if (Cutscene_CheckActorAction(globalCtx, 120)) { - s32 actionIndex = Cutscene_GetActorActionIndex(globalCtx, 120); +void EnMa4_EponasSongCs(EnMa4* this, PlayState* play) { + if (Cutscene_CheckActorAction(play, 120)) { + s32 actionIndex = Cutscene_GetActorActionIndex(play, 120); - if (globalCtx->csCtx.frames == globalCtx->csCtx.actorActions[actionIndex]->startFrame) { - if (globalCtx->csCtx.actorActions[actionIndex]->action != D_80AC0260) { - D_80AC0260 = globalCtx->csCtx.actorActions[actionIndex]->action; + if (play->csCtx.frames == play->csCtx.actorActions[actionIndex]->startFrame) { + if (play->csCtx.actorActions[actionIndex]->action != D_80AC0260) { + D_80AC0260 = play->csCtx.actorActions[actionIndex]->action; this->animTimer = 0; - switch (globalCtx->csCtx.actorActions[actionIndex]->action) { + switch (play->csCtx.actorActions[actionIndex]->action) { case 1: this->hasBow = true; EnMa4_ChangeAnim(this, 1); @@ -824,15 +820,15 @@ void EnMa4_EponasSongCs(EnMa4* this, GlobalContext* globalCtx) { } } - Cutscene_ActorTranslateAndYaw(&this->actor, globalCtx, actionIndex); + Cutscene_ActorTranslateAndYaw(&this->actor, play, actionIndex); if (D_80AC0260 == 2 && this->animTimer == 0 && Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) { EnMa4_ChangeAnim(this, 7); } } else { - Player* player = GET_PLAYER(globalCtx); + Player* player = GET_PLAYER(play); player->stateFlags1 |= 0x20; - func_800B85E0(&this->actor, globalCtx, 200.0f, EXCH_ITEM_MINUS1); + func_800B85E0(&this->actor, play, 200.0f, PLAYER_AP_MINUS1); D_80AC0260 = 99; this->hasBow = true; EnMa4_SetupEndEponasSongCs(this); @@ -843,18 +839,18 @@ void EnMa4_SetupEndEponasSongCs(EnMa4* this) { this->actionFunc = EnMa4_EndEponasSongCs; } -void EnMa4_EndEponasSongCs(EnMa4* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); +void EnMa4_EndEponasSongCs(EnMa4* this, PlayState* play) { + Player* player = GET_PLAYER(play); this->actor.flags |= ACTOR_FLAG_10000; - if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state) != 0) { + if (Actor_ProcessTalkRequest(&this->actor, &play->state) != 0) { player->stateFlags1 &= ~0x20; - Message_StartTextbox(globalCtx, 0x334C, &this->actor); + Message_StartTextbox(play, 0x334C, &this->actor); this->textId = 0x334C; this->actor.flags &= ~ACTOR_FLAG_10000; EnMa4_SetupDialogueHandler(this); } else { - func_800B85E0(&this->actor, globalCtx, 200.0f, EXCH_ITEM_MINUS1); + func_800B85E0(&this->actor, play, 200.0f, PLAYER_AP_MINUS1); } } @@ -862,15 +858,15 @@ void EnMa4_SetupBeginDescribeThemCs(EnMa4* this) { this->actionFunc = EnMa4_BeginDescribeThemCs; } -void EnMa4_BeginDescribeThemCs(EnMa4* this, GlobalContext* globalCtx) { - globalCtx->nextEntranceIndex = 0x6400; +void EnMa4_BeginDescribeThemCs(EnMa4* this, PlayState* play) { + play->nextEntrance = ENTRANCE(ROMANI_RANCH, 0); gSaveContext.nextCutsceneIndex = 0xFFF5; - globalCtx->sceneLoadFlag = 0x14; - globalCtx->unk_1887F = 0x40; - gSaveContext.nextTransition = 2; + play->transitionTrigger = TRANS_TRIGGER_START; + play->transitionType = TRANS_TYPE_64; + gSaveContext.nextTransitionType = TRANS_TYPE_02; } -void EnMa4_StartDialogue(EnMa4* this, GlobalContext* globalCtx) { +void EnMa4_StartDialogue(EnMa4* this, PlayState* play) { s32 pad; OSTime time; @@ -879,25 +875,25 @@ void EnMa4_StartDialogue(EnMa4* this, GlobalContext* globalCtx) { if (gSaveContext.save.playerForm != PLAYER_FORM_HUMAN) { if ((gSaveContext.save.weekEventReg[21] & 0x80)) { EnMa4_SetFaceExpression(this, 3, 3); - Message_StartTextbox(globalCtx, 0x3337, &this->actor); + Message_StartTextbox(play, 0x3337, &this->actor); this->textId = 0x3337; - func_80151BB4(globalCtx, 5); + func_80151BB4(play, 5); } else { - Message_StartTextbox(globalCtx, 0x3335, &this->actor); + Message_StartTextbox(play, 0x3335, &this->actor); this->textId = 0x3335; gSaveContext.save.weekEventReg[21] |= 0x80; } } else if (this->state == MA4_STATE_DEFAULT) { if ((gSaveContext.save.weekEventReg[21] & 0x40)) { if (!(gSaveContext.save.weekEventReg[21] & 0x20)) { - Message_StartTextbox(globalCtx, 0x3346, &this->actor); + Message_StartTextbox(play, 0x3346, &this->actor); this->textId = 0x3346; } else { - Message_StartTextbox(globalCtx, 0x3347, &this->actor); + Message_StartTextbox(play, 0x3347, &this->actor); this->textId = 0x3347; } } else { - Message_StartTextbox(globalCtx, 0x3338, &this->actor); + Message_StartTextbox(play, 0x3338, &this->actor); this->textId = 0x3338; gSaveContext.save.weekEventReg[21] |= 0x40; } @@ -905,7 +901,7 @@ void EnMa4_StartDialogue(EnMa4* this, GlobalContext* globalCtx) { if (gSaveContext.unk_3DE0[4] >= 2 * 60 * 100) { // "Too bad Grasshopper" EnMa4_SetFaceExpression(this, 0, 0); - Message_StartTextbox(globalCtx, 0x336D, &this->actor); + Message_StartTextbox(play, 0x336D, &this->actor); this->textId = 0x336D; } else { time = gSaveContext.unk_3DE0[4]; @@ -913,11 +909,11 @@ void EnMa4_StartDialogue(EnMa4* this, GlobalContext* globalCtx) { // [Score] New record! gSaveContext.save.horseBackBalloonHighScore = time; EnMa4_SetFaceExpression(this, 0, 3); - Message_StartTextbox(globalCtx, 0x3350, &this->actor); + Message_StartTextbox(play, 0x3350, &this->actor); this->textId = 0x3350; } else { // [Score] Great. - Message_StartTextbox(globalCtx, 0x3351, &this->actor); + Message_StartTextbox(play, 0x3351, &this->actor); this->textId = 0x3351; } } @@ -925,7 +921,7 @@ void EnMa4_StartDialogue(EnMa4* this, GlobalContext* globalCtx) { this->actor.flags &= ~ACTOR_FLAG_10000; } else if (this->state == MA4_STATE_AFTERDESCRIBETHEMCS) { // "Cremia doesn't believe me..." - Message_StartTextbox(globalCtx, 0x3340, &this->actor); + Message_StartTextbox(play, 0x3340, &this->actor); this->textId = 0x3340; this->actor.flags &= ~ACTOR_FLAG_10000; } @@ -935,31 +931,31 @@ void EnMa4_StartDialogue(EnMa4* this, GlobalContext* globalCtx) { if (gSaveContext.save.playerForm != PLAYER_FORM_HUMAN) { if ((gSaveContext.save.weekEventReg[21] & 0x80)) { EnMa4_SetFaceExpression(this, 3, 3); - Message_StartTextbox(globalCtx, 0x3337, &this->actor); + Message_StartTextbox(play, 0x3337, &this->actor); this->textId = 0x3337; - func_80151BB4(globalCtx, 5); + func_80151BB4(play, 5); } else { - Message_StartTextbox(globalCtx, 0x3335, &this->actor); + Message_StartTextbox(play, 0x3335, &this->actor); this->textId = 0x3335; gSaveContext.save.weekEventReg[21] |= 0x80; } } else if (this->state == MA4_STATE_DEFAULT) { - Message_StartTextbox(globalCtx, 0x3354, &this->actor); + Message_StartTextbox(play, 0x3354, &this->actor); this->textId = 0x3354; } else if (this->state == MA4_STATE_AFTERHORSEBACKGAME) { if (gSaveContext.unk_3DE0[4] >= 2 * 60 * 100) { // "Try again?" - Message_StartTextbox(globalCtx, 0x3356, &this->actor); + Message_StartTextbox(play, 0x3356, &this->actor); this->textId = 0x3356; } else { time = gSaveContext.unk_3DE0[4]; if ((s32)time < (s32)gSaveContext.save.horseBackBalloonHighScore) { gSaveContext.save.horseBackBalloonHighScore = time; EnMa4_SetFaceExpression(this, 0, 3); - Message_StartTextbox(globalCtx, 0x3350, &this->actor); + Message_StartTextbox(play, 0x3350, &this->actor); this->textId = 0x3350; } else { - Message_StartTextbox(globalCtx, 0x3351, &this->actor); + Message_StartTextbox(play, 0x3351, &this->actor); this->textId = 0x3351; } } @@ -971,23 +967,23 @@ void EnMa4_StartDialogue(EnMa4* this, GlobalContext* globalCtx) { case MA4_TYPE_ALIENS_WON: if (this->state == MA4_STATE_DEFAULT) { // "Huh... You?" - Message_StartTextbox(globalCtx, 0x3358, &this->actor); + Message_StartTextbox(play, 0x3358, &this->actor); this->textId = 0x3358; } else if (this->state == MA4_STATE_AFTERHORSEBACKGAME) { if (gSaveContext.unk_3DE0[4] >= 2 * 60 * 100) { // "Try again?" - Message_StartTextbox(globalCtx, 0x3356, &this->actor); + Message_StartTextbox(play, 0x3356, &this->actor); this->textId = 0x3356; } else { time = gSaveContext.unk_3DE0[4]; if ((s32)time < (s32)gSaveContext.save.horseBackBalloonHighScore) { // New record gSaveContext.save.horseBackBalloonHighScore = time; - Message_StartTextbox(globalCtx, 0x335D, &this->actor); + Message_StartTextbox(play, 0x335D, &this->actor); this->textId = 0x335D; } else { // "Old record was: [record]" - Message_StartTextbox(globalCtx, 0x335E, &this->actor); + Message_StartTextbox(play, 0x335E, &this->actor); this->textId = 0x335E; } } @@ -998,7 +994,7 @@ void EnMa4_StartDialogue(EnMa4* this, GlobalContext* globalCtx) { default: // Dead code - Message_StartTextbox(globalCtx, 0x3335, &this->actor); + Message_StartTextbox(play, 0x3335, &this->actor); this->textId = 0x3335; break; } @@ -1017,28 +1013,28 @@ void EnMa4_InitFaceExpression(EnMa4* this) { } } -void EnMa4_Update(Actor* thisx, GlobalContext* globalCtx) { +void EnMa4_Update(Actor* thisx, PlayState* play) { EnMa4* this = THIS; s32 pad; Collider_UpdateCylinder(&this->actor, &this->collider); - CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + CollisionCheck_SetOC(play, &play->colChkCtx, &this->collider.base); SkelAnime_Update(&this->skelAnime); EnMa4_UpdateEyes(this); - this->actionFunc(this, globalCtx); - func_80ABDD9C(this, globalCtx); + this->actionFunc(this, play); + func_80ABDD9C(this, play); } -s32 EnMa4_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, Actor* thisx) { +s32 EnMa4_OverrideLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, Actor* thisx) { EnMa4* this = THIS; Vec3s sp4; - if (limbIndex == MA1_LIMB_HEAD) { + if (limbIndex == ROMANI_LIMB_HEAD) { sp4 = this->unk_1D8.unk_08; rot->x = rot->x + sp4.y; rot->z = rot->z + sp4.x; } - if (limbIndex == MA1_LIMB_TORSO) { + if (limbIndex == ROMANI_LIMB_TORSO) { sp4 = this->unk_1D8.unk_0E; rot->x = rot->x - sp4.y; rot->z = rot->z - sp4.x; @@ -1047,37 +1043,37 @@ s32 EnMa4_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, return false; } -void EnMa4_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx) { +void EnMa4_PostLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx) { EnMa4* this = THIS; Vec3f sp28 = { 800.0f, 0.0f, 0.0f }; - if (limbIndex == MA1_LIMB_HEAD) { - Matrix_MultiplyVector3fByState(&sp28, &this->actor.focus.pos); - } else if (limbIndex == MA1_LIMB_HAND_LEFT) { + if (limbIndex == ROMANI_LIMB_HEAD) { + Matrix_MultVec3f(&sp28, &this->actor.focus.pos); + } else if (limbIndex == ROMANI_LIMB_LEFT_HAND) { if (this->hasBow == true) { - OPEN_DISPS(globalCtx->state.gfxCtx); - gSPDisplayList(POLY_OPA_DISP++, object_ma1_DL_0003B0); - CLOSE_DISPS(globalCtx->state.gfxCtx); + OPEN_DISPS(play->state.gfxCtx); + gSPDisplayList(POLY_OPA_DISP++, gRomaniBowDL); + CLOSE_DISPS(play->state.gfxCtx); } } } -void EnMa4_Draw(Actor* thisx, GlobalContext* globalCtx) { +void EnMa4_Draw(Actor* thisx, PlayState* play) { EnMa4* this = THIS; - OPEN_DISPS(globalCtx->state.gfxCtx); + OPEN_DISPS(play->state.gfxCtx); if (this->type == MA4_TYPE_ALIENS_WON) { - gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - gSPDisplayList(POLY_OPA_DISP++, object_ma1_DL_000A20); + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_OPA_DISP++, gRomaniWoodenBoxDL); } - func_8012C28C(globalCtx->state.gfxCtx); + func_8012C28C(play->state.gfxCtx); gSPSegment(POLY_OPA_DISP++, 0x08, SEGMENTED_TO_VIRTUAL(sEyeTextures[this->eyeTexIndex])); gSPSegment(POLY_OPA_DISP++, 0x09, SEGMENTED_TO_VIRTUAL(sMouthTextures[this->mouthTexIndex])); - SkelAnime_DrawFlexOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, + SkelAnime_DrawFlexOpa(play, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, EnMa4_OverrideLimbDraw, EnMa4_PostLimbDraw, &this->actor); - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->state.gfxCtx); } diff --git a/src/overlays/actors/ovl_En_Ma4/z_en_ma4.h b/src/overlays/actors/ovl_En_Ma4/z_en_ma4.h index b1e25569b..148e2ef30 100644 --- a/src/overlays/actors/ovl_En_Ma4/z_en_ma4.h +++ b/src/overlays/actors/ovl_En_Ma4/z_en_ma4.h @@ -2,11 +2,11 @@ #define Z_EN_MA4_H #include "global.h" -#include "overlays/actors/ovl_En_Ma_Yts/z_en_ma_yts.h" +#include "objects/object_ma1/object_ma1.h" struct EnMa4; -typedef void (*EnMa4ActionFunc)(struct EnMa4*, GlobalContext*); +typedef void (*EnMa4ActionFunc)(struct EnMa4*, PlayState*); typedef struct EnMa4 { /* 0x000 */ Actor actor; @@ -15,9 +15,9 @@ typedef struct EnMa4 { /* 0x18C */ ColliderCylinder collider; /* 0x1D8 */ struct_800BD888_arg1 unk_1D8; /* 0x200 */ Vec3s* pathPoints; - /* 0x204 */ Vec3s jointTable[MA1_LIMB_MAX]; + /* 0x204 */ Vec3s jointTable[ROMANI_LIMB_MAX]; /* 0x28E */ UNK_TYPE1 unk28E[0x6]; - /* 0x294 */ Vec3s morphTable[MA1_LIMB_MAX]; + /* 0x294 */ Vec3s morphTable[ROMANI_LIMB_MAX]; /* 0x31E */ UNK_TYPE1 unk31E[0x6]; /* 0x324 */ s16 pathIndex; /* 0x326 */ s16 pathPointsCount; 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 bd92db4bc..e90b2decc 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 @@ -5,72 +5,68 @@ */ #include "z_en_ma_yto.h" -#include "objects/object_ma2/object_ma2.h" +#include "overlays/actors/ovl_En_Ma_Yts/z_en_ma_yts.h" #define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_8 | ACTOR_FLAG_100000 | ACTOR_FLAG_2000000) #define THIS ((EnMaYto*)thisx) -void EnMaYto_Init(Actor* thisx, GlobalContext* globalCtx); -void EnMaYto_Destroy(Actor* thisx, GlobalContext* globalCtx); -void EnMaYto_Update(Actor* thisx, GlobalContext* globalCtx); -void EnMaYto_Draw(Actor* thisx, GlobalContext* globalCtx); +void EnMaYto_Init(Actor* thisx, PlayState* play); +void EnMaYto_Destroy(Actor* thisx, PlayState* play); +void EnMaYto_Update(Actor* thisx, PlayState* play); +void EnMaYto_Draw(Actor* thisx, PlayState* play); -s32 EnMaYto_CheckValidSpawn(EnMaYto* this, GlobalContext* globalCtx); -void EnMaYto_InitAnimation(EnMaYto* this, GlobalContext* globalCtx); -void EnMaYto_ChooseAction(EnMaYto* this, GlobalContext* globalCtx); -s32 EnMaYto_TryFindRomani(EnMaYto* this, GlobalContext* globalCtx); +s32 EnMaYto_CheckValidSpawn(EnMaYto* this, PlayState* play); +void EnMaYto_InitAnimation(EnMaYto* this, PlayState* play); +void EnMaYto_ChooseAction(EnMaYto* this, PlayState* play); +s32 EnMaYto_TryFindRomani(EnMaYto* this, PlayState* play); void EnMaYto_SetupKeepLookingForRomani(EnMaYto* this); -void EnMaYto_KeepLookingForRomani(EnMaYto* this, GlobalContext* globalCtx); - +void EnMaYto_KeepLookingForRomani(EnMaYto* this, PlayState* play); void EnMaYto_SetupDefaultWait(EnMaYto* this); -void EnMaYto_DefaultWait(EnMaYto* this, GlobalContext* globalCtx); +void EnMaYto_DefaultWait(EnMaYto* this, PlayState* play); void EnMaYto_SetupDefaultDialogueHandler(EnMaYto* this); -void EnMaYto_DefaultDialogueHandler(EnMaYto* this, GlobalContext* globalCtx); -void EnMaYto_DefaultHandlePlayerChoice(EnMaYto* this, GlobalContext* globalCtx); -void EnMaYto_DefaultChooseNextDialogue(EnMaYto* this, GlobalContext* globalCtx); +void EnMaYto_DefaultDialogueHandler(EnMaYto* this, PlayState* play); +void EnMaYto_DefaultHandlePlayerChoice(EnMaYto* this, PlayState* play); +void EnMaYto_DefaultChooseNextDialogue(EnMaYto* this, PlayState* play); void EnMaYto_SetupDinnerWait(EnMaYto* this); -void EnMaYto_DinnerWait(EnMaYto* this, GlobalContext* globalCtx); +void EnMaYto_DinnerWait(EnMaYto* this, PlayState* play); void EnMaYto_SetupDinnerDialogueHandler(EnMaYto* this); -void EnMaYto_DinnerDialogueHandler(EnMaYto* this, GlobalContext* globalCtx); -void EnMaYto_DinnerHandlePlayerChoice(EnMaYto* this, GlobalContext* globalCtx); -void EnMaYto_DinnerChooseNextDialogue(EnMaYto* this, GlobalContext* globalCtx); +void EnMaYto_DinnerDialogueHandler(EnMaYto* this, PlayState* play); +void EnMaYto_DinnerHandlePlayerChoice(EnMaYto* this, PlayState* play); +void EnMaYto_DinnerChooseNextDialogue(EnMaYto* this, PlayState* play); void EnMaYto_SetupBarnWait(EnMaYto* this); -void EnMaYto_BarnWait(EnMaYto* this, GlobalContext* globalCtx); +void EnMaYto_BarnWait(EnMaYto* this, PlayState* play); void EnMaYto_SetupBarnDialogueHandler(EnMaYto* this); -void EnMaYto_BarnDialogueHandler(EnMaYto* this, GlobalContext* globalCtx); -void EnMaYto_BarnChooseNextDialogue(EnMaYto* this, GlobalContext* globalCtx); +void EnMaYto_BarnDialogueHandler(EnMaYto* this, PlayState* play); +void EnMaYto_BarnChooseNextDialogue(EnMaYto* this, PlayState* play); void EnMaYto_SetupAfterMilkRunInit(EnMaYto* this); -void EnMaYto_AfterMilkRunInit(EnMaYto* this, GlobalContext* globalCtx); +void EnMaYto_AfterMilkRunInit(EnMaYto* this, PlayState* play); void EnMaYto_SetupAfterMilkRunDialogueHandler(EnMaYto* this); -void EnMaYto_AfterMilkRunDialogueHandler(EnMaYto* this, GlobalContext* globalCtx); - -void EnMaYto_AfterMilkRunChooseNextDialogue(EnMaYto* this, GlobalContext* globalCtx); +void EnMaYto_AfterMilkRunDialogueHandler(EnMaYto* this, PlayState* play); +void EnMaYto_AfterMilkRunChooseNextDialogue(EnMaYto* this, PlayState* play); void EnMaYto_SetupPostMilkRunGiveReward(EnMaYto* this); -void EnMaYto_PostMilkRunGiveReward(EnMaYto* this, GlobalContext* globalCtx); +void EnMaYto_PostMilkRunGiveReward(EnMaYto* this, PlayState* play); void EnMaYto_SetupPostMilkRunExplainReward(EnMaYto* this); -void EnMaYto_PostMilkRunExplainReward(EnMaYto* this, GlobalContext* globalCtx); +void EnMaYto_PostMilkRunExplainReward(EnMaYto* this, PlayState* play); void EnMaYto_SetupBeginWarmFuzzyFeelingCs(EnMaYto* this); -void EnMaYto_BeginWarmFuzzyFeelingCs(EnMaYto* this, GlobalContext* globalCtx); +void EnMaYto_BeginWarmFuzzyFeelingCs(EnMaYto* this, PlayState* play); void EnMaYto_SetupWarmFuzzyFeelingCs(EnMaYto* this); - -void EnMaYto_WarmFuzzyFeelingCs(EnMaYto* this, GlobalContext* globalCtx); +void EnMaYto_WarmFuzzyFeelingCs(EnMaYto* this, PlayState* play); void EnMaYto_SetupPostMilkRunWaitDialogueEnd(EnMaYto* this); -void EnMaYto_PostMilkRunWaitDialogueEnd(EnMaYto* this, GlobalContext* globalCtx); +void EnMaYto_PostMilkRunWaitDialogueEnd(EnMaYto* this, PlayState* play); void EnMaYto_SetupPostMilkRunEnd(EnMaYto* this); -void EnMaYto_PostMilkRunEnd(EnMaYto* this, GlobalContext* globalCtx); -void EnMaYto_DefaultStartDialogue(EnMaYto* this, GlobalContext* globalCtx); -void EnMaYto_DinnerStartDialogue(EnMaYto* this, GlobalContext* globalCtx); -void EnMaYto_BarnStartDialogue(EnMaYto* this, GlobalContext* globalCtx); -void EnMaYto_ChangeAnim(EnMaYto* this, s32 index); +void EnMaYto_PostMilkRunEnd(EnMaYto* this, PlayState* play); +void EnMaYto_DefaultStartDialogue(EnMaYto* this, PlayState* play); +void EnMaYto_DinnerStartDialogue(EnMaYto* this, PlayState* play); +void EnMaYto_BarnStartDialogue(EnMaYto* this, PlayState* play); +void EnMaYto_ChangeAnim(EnMaYto* this, s32 animIndex); void EnMaYto_UpdateEyes(EnMaYto* this); 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 = { @@ -110,33 +106,44 @@ static CollisionCheckInfoInit2 sColChkInfoInit2 = { }; 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 }, // + { &gCremiaIdleAnim, 1.0f, ANIMMODE_LOOP, 0.0f }, + { &gCremiaIdleAnim, 1.0f, ANIMMODE_LOOP, -6.0f }, + { &gCremiaSpreadArmsStartAnim, 1.0f, ANIMMODE_ONCE, 0.0f }, + { &gCremiaSpreadArmsStartAnim, 1.0f, ANIMMODE_ONCE, -6.0f }, + { &gCremiaSpreadArmsLoopAnim, 1.0f, ANIMMODE_LOOP, 0.0f }, + { &gCremiaSpreadArmsLoopAnim, 1.0f, ANIMMODE_LOOP, -6.0f }, + { &gCremiaWalkAnim, 1.0f, ANIMMODE_LOOP, 0.0f }, + { &gCremiaWalkAnim, 1.0f, ANIMMODE_LOOP, -8.0f }, + { &gCremiaThinkAnim, 1.0f, ANIMMODE_LOOP, 0.0f }, + { &gCremiaThinkAnim, 1.0f, ANIMMODE_LOOP, -8.0f }, + { &gCremiaPetCowAnim, 1.0f, ANIMMODE_LOOP, 0.0f }, + { &gCremiaPetCowAnim, 1.0f, ANIMMODE_LOOP, -10.0f }, + { &gCremiaSittingPetCowAnim, 1.0f, ANIMMODE_LOOP, 0.0f }, + { &gCremiaSittingPetCowAnim, 1.0f, ANIMMODE_LOOP, -8.0f }, + { &gCremiaSittingAnim, 1.0f, ANIMMODE_LOOP, 0.0f }, + { &gCremiaSittingAnim, 1.0f, ANIMMODE_LOOP, -8.0f }, + { &gCremiaSittingLookDownAnim, 1.0f, ANIMMODE_LOOP, 0.0f }, + { &gCremiaSittingLookDownAnim, 1.0f, ANIMMODE_LOOP, -8.0f }, + { &gCremiaHugStartAnim, 1.0f, ANIMMODE_LOOP, 0.0f }, + { &gCremiaHugStartAnim, 1.0f, ANIMMODE_LOOP, -8.0f }, + { &gCremiaHugLoopAnim, 1.0f, ANIMMODE_LOOP, 0.0f }, + { &gCremiaHugLoopAnim, 1.0f, ANIMMODE_LOOP, -8.0f }, + { &gCremiaClapAnim, 1.0f, ANIMMODE_LOOP, 0.0f }, + { &gCremiaClapAnim, 1.0f, ANIMMODE_LOOP, -8.0f }, }; static TexturePtr sMouthTextures[] = { - object_ma2_Tex_014AD8, - object_ma2_Tex_014ED8, - object_ma2_Tex_0152D8, - object_ma2_Tex_0156D8, + gCremiaMouthNormalTex, + gCremiaMouthSlightSmileTex, + gCremiaMouthFrownTex, + gCremiaMouthHangingOpenTex, }; static TexturePtr sEyesTextures[] = { - object_ma2_Tex_011AD8, object_ma2_Tex_0122D8, object_ma2_Tex_012AD8, - object_ma2_Tex_0132D8, object_ma2_Tex_013AD8, object_ma2_Tex_0142D8, + gCremiaEyeOpenTex, gCremiaEyeHalfTex, gCremiaEyeClosedTex, gCremiaEyeHappyTex, gCremiaEyeAngryTex, gCremiaEyeSadTex, }; -void EnMaYto_Init(Actor* thisx, GlobalContext* globalCtx) { +void EnMaYto_Init(Actor* thisx, PlayState* play) { EnMaYto* this = THIS; s32 pad; @@ -154,30 +161,29 @@ void EnMaYto_Init(Actor* thisx, GlobalContext* globalCtx) { this->unk31E = 0; this->blinkTimer = 100; - this->type = EN_MA_YTO_PARSE_TYPE(this->actor.params); - if (!EnMaYto_CheckValidSpawn(this, globalCtx)) { + this->type = EN_MA_YTO_GET_TYPE(&this->actor); + if (!EnMaYto_CheckValidSpawn(this, play)) { Actor_MarkForDeath(&this->actor); return; } ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 18.0f); - SkelAnime_InitFlex(globalCtx, &this->skelAnime, &object_ma2_Skel_015C28, NULL, this->jointTable, this->morphTable, - MA2_LIMB_MAX); - EnMaYto_InitAnimation(this, globalCtx); + SkelAnime_InitFlex(play, &this->skelAnime, &gCremiaSkel, NULL, this->jointTable, this->morphTable, CREMIA_LIMB_MAX); + EnMaYto_InitAnimation(this, play); - Collider_InitCylinder(globalCtx, &this->collider); - Collider_SetCylinder(globalCtx, &this->collider, &this->actor, &sCylinderInit); + Collider_InitCylinder(play, &this->collider); + Collider_SetCylinder(play, &this->collider, &this->actor, &sCylinderInit); CollisionCheck_SetInfo2(&this->actor.colChkInfo, DamageTable_Get(0x16), &sColChkInfoInit2); - Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 0.0f, 0.0f, 0.0f, 4); + Actor_UpdateBgCheckInfo(play, &this->actor, 0.0f, 0.0f, 0.0f, 4); - if (EnMaYto_TryFindRomani(this, globalCtx) == 1) { + if (EnMaYto_TryFindRomani(this, play) == 1) { EnMaYto_SetupKeepLookingForRomani(this); } else { - EnMaYto_ChooseAction(this, globalCtx); + EnMaYto_ChooseAction(this, play); } } -s32 EnMaYto_CheckValidSpawn(EnMaYto* this, GlobalContext* globalCtx) { +s32 EnMaYto_CheckValidSpawn(EnMaYto* this, PlayState* play) { switch (this->type) { case MA_YTO_TYPE_DEFAULT: if (CURRENT_DAY == 3 && !(gSaveContext.save.weekEventReg[22] & 1)) { @@ -219,7 +225,7 @@ s32 EnMaYto_CheckValidSpawn(EnMaYto* this, GlobalContext* globalCtx) { return true; } -void EnMaYto_InitAnimation(EnMaYto* this, GlobalContext* globalCtx) { +void EnMaYto_InitAnimation(EnMaYto* this, PlayState* play) { switch (this->type) { case MA_YTO_TYPE_DEFAULT: EnMaYto_ChangeAnim(this, 10); @@ -256,7 +262,7 @@ void EnMaYto_InitAnimation(EnMaYto* this, GlobalContext* globalCtx) { } } -void EnMaYto_ChooseAction(EnMaYto* this, GlobalContext* globalCtx) { +void EnMaYto_ChooseAction(EnMaYto* this, PlayState* play) { switch (this->type) { case MA_YTO_TYPE_DEFAULT: EnMaYto_SetupDefaultWait(this); @@ -292,13 +298,13 @@ void EnMaYto_ChooseAction(EnMaYto* this, GlobalContext* globalCtx) { } } -s32 EnMaYto_SearchRomani(EnMaYto* this, GlobalContext* globalCtx) { - Actor* npcActor = globalCtx->actorCtx.actorLists[ACTORCAT_NPC].first; +s32 EnMaYto_SearchRomani(EnMaYto* this, PlayState* play) { + Actor* npcActor = play->actorCtx.actorLists[ACTORCAT_NPC].first; while (npcActor != NULL) { if (npcActor->id == ACTOR_EN_MA_YTS) { EnMaYts* romani = (EnMaYts*)npcActor; - s16 romaniType = EN_MA_YTS_PARSE_TYPE(&romani->actor); + s16 romaniType = EN_MA_YTS_GET_TYPE(&romani->actor); if ((this->type == MA_YTO_TYPE_DINNER && romaniType == MA_YTS_TYPE_SITTING) || (this->type == MA_YTO_TYPE_BARN && romaniType == MA_YTS_TYPE_BARN)) { @@ -322,7 +328,7 @@ s32 EnMaYto_SearchRomani(EnMaYto* this, GlobalContext* globalCtx) { * - 1: Romani was not found. * - 0: There's no need to find Romani. */ -s32 EnMaYto_TryFindRomani(EnMaYto* this, GlobalContext* globalCtx) { +s32 EnMaYto_TryFindRomani(EnMaYto* this, PlayState* play) { switch (this->type) { case MA_YTO_TYPE_DEFAULT: return 0; @@ -331,7 +337,7 @@ s32 EnMaYto_TryFindRomani(EnMaYto* this, GlobalContext* globalCtx) { if (!(gSaveContext.save.weekEventReg[22] & 1) && CURRENT_DAY == 2) { return 0; } - if (EnMaYto_SearchRomani(this, globalCtx)) { + if (EnMaYto_SearchRomani(this, play)) { return 2; } return 1; @@ -339,7 +345,7 @@ s32 EnMaYto_TryFindRomani(EnMaYto* this, GlobalContext* globalCtx) { case MA_YTO_TYPE_BARN: // if (AliensDefeated) if (gSaveContext.save.weekEventReg[22] & 1) { - if (EnMaYto_SearchRomani(this, globalCtx)) { + if (EnMaYto_SearchRomani(this, play)) { return 2; } return 1; @@ -356,28 +362,28 @@ s32 EnMaYto_TryFindRomani(EnMaYto* this, GlobalContext* globalCtx) { return 0; } -void EnMaYto_Destroy(Actor* thisx, GlobalContext* globalCtx) { +void EnMaYto_Destroy(Actor* thisx, PlayState* play) { EnMaYto* this = THIS; - Collider_DestroyCylinder(globalCtx, &this->collider); + Collider_DestroyCylinder(play, &this->collider); } void EnMaYto_SetupKeepLookingForRomani(EnMaYto* this) { this->actionFunc = EnMaYto_KeepLookingForRomani; } -void EnMaYto_KeepLookingForRomani(EnMaYto* this, GlobalContext* globalCtx) { - if (EnMaYto_TryFindRomani(this, globalCtx) == 2) { - EnMaYto_ChooseAction(this, globalCtx); +void EnMaYto_KeepLookingForRomani(EnMaYto* this, PlayState* play) { + if (EnMaYto_TryFindRomani(this, play) == 2) { + EnMaYto_ChooseAction(this, play); } } void EnMaYto_SetupDefaultWait(EnMaYto* this) { if (this->actor.shape.rot.y == this->actor.home.rot.y) { - this->currentAnim = 11; + this->animIndex = 11; EnMaYto_ChangeAnim(this, 11); } else { - this->currentAnim = 1; + this->animIndex = 1; EnMaYto_ChangeAnim(this, 1); } @@ -386,22 +392,22 @@ void EnMaYto_SetupDefaultWait(EnMaYto* this) { this->actionFunc = EnMaYto_DefaultWait; } -void EnMaYto_DefaultWait(EnMaYto* this, GlobalContext* globalCtx) { +void EnMaYto_DefaultWait(EnMaYto* this, PlayState* play) { s16 rotY = this->actor.home.rot.y - 0x8000; s16 direction; direction = rotY - this->actor.yawTowardsPlayer; if (Math_SmoothStepToS(&this->actor.shape.rot.y, this->actor.home.rot.y, 5, 0x3000, 0x100) == 0 && - this->currentAnim == 1) { - this->currentAnim = 11; + this->animIndex == 1) { + this->animIndex = 11; EnMaYto_ChangeAnim(this, 11); } - if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { - EnMaYto_DefaultStartDialogue(this, globalCtx); + if (Actor_ProcessTalkRequest(&this->actor, &play->state)) { + EnMaYto_DefaultStartDialogue(this, play); EnMaYto_SetupDefaultDialogueHandler(this); } else if (ABS_ALT(direction) < 0x1555) { - func_800B8614(&this->actor, globalCtx, 100.0f); + func_800B8614(&this->actor, play, 100.0f); } } @@ -411,81 +417,81 @@ void EnMaYto_SetupDefaultDialogueHandler(EnMaYto* this) { this->actionFunc = EnMaYto_DefaultDialogueHandler; } -void EnMaYto_DefaultDialogueHandler(EnMaYto* this, GlobalContext* globalCtx) { - switch (Message_GetState(&globalCtx->msgCtx)) { - case 4: - EnMaYto_DefaultHandlePlayerChoice(this, globalCtx); +void EnMaYto_DefaultDialogueHandler(EnMaYto* this, PlayState* play) { + switch (Message_GetState(&play->msgCtx)) { + case TEXT_STATE_CHOICE: + EnMaYto_DefaultHandlePlayerChoice(this, play); break; - case 5: - EnMaYto_DefaultChooseNextDialogue(this, globalCtx); + case TEXT_STATE_5: + EnMaYto_DefaultChooseNextDialogue(this, play); break; - case 6: - if (Message_ShouldAdvance(globalCtx)) { + case TEXT_STATE_DONE: + if (Message_ShouldAdvance(play)) { this->unk31E = 0; EnMaYto_SetupDefaultWait(this); } break; - case 0: - case 1: - case 2: - case 3: + case TEXT_STATE_NONE: + case TEXT_STATE_1: + case TEXT_STATE_CLOSING: + case TEXT_STATE_3: break; } Math_SmoothStepToS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer, 5, 0x3000, 0x100); - if (this->textId == 0x3395 && this->skelAnime.animation == &object_ma2_Anim_00AF7C && + if (this->textId == 0x3395 && this->skelAnime.animation == &gCremiaSpreadArmsStartAnim && Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) { EnMaYto_ChangeAnim(this, 4); } } -void EnMaYto_DefaultHandlePlayerChoice(EnMaYto* this, GlobalContext* globalCtx) { - if (Message_ShouldAdvance(globalCtx)) { - if (globalCtx->msgCtx.choiceIndex == 0) { // Yes +void EnMaYto_DefaultHandlePlayerChoice(EnMaYto* this, PlayState* play) { + if (Message_ShouldAdvance(play)) { + if (play->msgCtx.choiceIndex == 0) { // Yes func_8019F208(); EnMaYto_SetFaceExpression(this, 0, 3); // "Milk Road is fixed!" - Message_StartTextbox(globalCtx, 0x3392, &this->actor); + Message_StartTextbox(play, 0x3392, &this->actor); this->textId = 0x3392; } else { // No func_8019F230(); // "Don't lie!" - Message_StartTextbox(globalCtx, 0x3391, &this->actor); + Message_StartTextbox(play, 0x3391, &this->actor); this->textId = 0x3391; } } } -void EnMaYto_DefaultChooseNextDialogue(EnMaYto* this, GlobalContext* globalCtx) { - if (Message_ShouldAdvance(globalCtx)) { +void EnMaYto_DefaultChooseNextDialogue(EnMaYto* this, PlayState* play) { + if (Message_ShouldAdvance(play)) { switch (this->textId) { case 0x3391: EnMaYto_SetFaceExpression(this, 0, 3); - Message_StartTextbox(globalCtx, 0x3392, &this->actor); + Message_StartTextbox(play, 0x3392, &this->actor); this->textId = 0x3392; break; case 0x3392: EnMaYto_SetFaceExpression(this, 3, 1); - Message_StartTextbox(globalCtx, 0x3393, &this->actor); + Message_StartTextbox(play, 0x3393, &this->actor); this->textId = 0x3393; - func_80151BB4(globalCtx, 6); + func_80151BB4(play, 6); break; case 0x3394: EnMaYto_ChangeAnim(this, 2); - Message_StartTextbox(globalCtx, 0x3395, &this->actor); + Message_StartTextbox(play, 0x3395, &this->actor); this->textId = 0x3395; break; case 0x3395: EnMaYto_ChangeAnim(this, 1); - Message_StartTextbox(globalCtx, 0x3396, &this->actor); + Message_StartTextbox(play, 0x3396, &this->actor); this->textId = 0x3396; - func_80151BB4(globalCtx, 6); + func_80151BB4(play, 6); break; } } @@ -504,28 +510,28 @@ void EnMaYto_SetupDinnerWait(EnMaYto* this) { this->actionFunc = EnMaYto_DinnerWait; } -void EnMaYto_DinnerWait(EnMaYto* this, GlobalContext* globalCtx) { +void EnMaYto_DinnerWait(EnMaYto* this, PlayState* play) { s16 direction = this->actor.shape.rot.y - this->actor.yawTowardsPlayer; - if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { - EnMaYto_DinnerStartDialogue(this, globalCtx); + if (Actor_ProcessTalkRequest(&this->actor, &play->state)) { + EnMaYto_DinnerStartDialogue(this, play); EnMaYto_SetupDinnerDialogueHandler(this); } else { Actor* child = this->actor.child; - if (child != NULL && Actor_ProcessTalkRequest(child, &globalCtx->state)) { - Actor_ChangeFocus(&this->actor, globalCtx, &this->actor); - EnMaYto_DinnerStartDialogue(this, globalCtx); + if (child != NULL && Actor_ProcessTalkRequest(child, &play->state)) { + Actor_ChangeFocus(&this->actor, play, &this->actor); + EnMaYto_DinnerStartDialogue(this, play); EnMaYto_SetupDinnerDialogueHandler(this); } else if (ABS_ALT(direction) < 0x4000) { - func_800B8614(&this->actor, globalCtx, 120.0f); + func_800B8614(&this->actor, play, 120.0f); child = this->actor.child; if (child != NULL && CURRENT_DAY != 2) { s16 childDirection = child->shape.rot.y - child->yawTowardsPlayer; if (ABS_ALT(childDirection) < 0x4000) { - func_800B8614(child, globalCtx, 120.0f); + func_800B8614(child, play, 120.0f); } } } @@ -543,141 +549,141 @@ void EnMaYto_SetupDinnerDialogueHandler(EnMaYto* this) { this->actionFunc = EnMaYto_DinnerDialogueHandler; } -void EnMaYto_DinnerDialogueHandler(EnMaYto* this, GlobalContext* globalCtx) { - switch (Message_GetState(&globalCtx->msgCtx)) { - case 4: - EnMaYto_DinnerHandlePlayerChoice(this, globalCtx); +void EnMaYto_DinnerDialogueHandler(EnMaYto* this, PlayState* play) { + switch (Message_GetState(&play->msgCtx)) { + case TEXT_STATE_CHOICE: + EnMaYto_DinnerHandlePlayerChoice(this, play); break; - case 5: - EnMaYto_DinnerChooseNextDialogue(this, globalCtx); + case TEXT_STATE_5: + EnMaYto_DinnerChooseNextDialogue(this, play); break; - case 6: - if (Message_ShouldAdvance(globalCtx)) { + case TEXT_STATE_DONE: + if (Message_ShouldAdvance(play)) { EnMaYto_SetupDinnerWait(this); } break; - case 0: - case 1: - case 2: - case 3: + case TEXT_STATE_NONE: + case TEXT_STATE_1: + case TEXT_STATE_CLOSING: + case TEXT_STATE_3: break; } } -void EnMaYto_DinnerHandlePlayerChoice(EnMaYto* this, GlobalContext* globalCtx) { - if (Message_ShouldAdvance(globalCtx)) { - if (globalCtx->msgCtx.choiceIndex == 0) { // Yes +void EnMaYto_DinnerHandlePlayerChoice(EnMaYto* this, PlayState* play) { + if (Message_ShouldAdvance(play)) { + if (play->msgCtx.choiceIndex == 0) { // Yes func_8019F208(); EnMaYto_SetFaceExpression(this, 0, 3); // "Milk Road is fixed!" - Message_StartTextbox(globalCtx, 0x3399, &this->actor); + Message_StartTextbox(play, 0x3399, &this->actor); this->textId = 0x3399; } else { // No func_8019F230(); // "Don't lie!" - Message_StartTextbox(globalCtx, 0x3398, &this->actor); + Message_StartTextbox(play, 0x3398, &this->actor); this->textId = 0x3398; } } } -void EnMaYto_DinnerChooseNextDialogue(EnMaYto* this, GlobalContext* globalCtx) { - if (Message_ShouldAdvance(globalCtx)) { +void EnMaYto_DinnerChooseNextDialogue(EnMaYto* this, PlayState* play) { + if (Message_ShouldAdvance(play)) { switch (this->textId) { case 0x3398: EnMaYto_SetFaceExpression(this, 0, 3); - Message_StartTextbox(globalCtx, 0x3399, &this->actor); + Message_StartTextbox(play, 0x3399, &this->actor); this->textId = 0x3399; break; case 0x3399: EnMaYto_SetFaceExpression(this, 3, 1); - Message_StartTextbox(globalCtx, 0x339A, &this->actor); + Message_StartTextbox(play, 0x339A, &this->actor); this->textId = 0x339A; break; case 0x339A: this->unk31E = 1; EnMaYto_SetFaceExpression(this, 0, 1); - Message_StartTextbox(globalCtx, 0x339B, &this->actor); + Message_StartTextbox(play, 0x339B, &this->actor); this->textId = 0x339B; break; case 0x339B: - Actor_ChangeFocus(&this->actor, globalCtx, this->actor.child); + Actor_ChangeFocus(&this->actor, play, this->actor.child); func_80B90E50(this, 0); EnMaYto_SetRomaniFaceExpression(this, 3, 3); - Message_StartTextbox(globalCtx, 0x339C, &this->actor); + Message_StartTextbox(play, 0x339C, &this->actor); this->textId = 0x339C; break; case 0x339C: this->unk31E = 1; - Actor_ChangeFocus(&this->actor, globalCtx, &this->actor); + Actor_ChangeFocus(&this->actor, play, &this->actor); EnMaYto_SetFaceExpression(this, 0, 2); - Message_StartTextbox(globalCtx, 0x339D, &this->actor); + Message_StartTextbox(play, 0x339D, &this->actor); this->textId = 0x339D; break; case 0x339D: func_80B90E50(this, 1); - Actor_ChangeFocus(&this->actor, globalCtx, this->actor.child); + Actor_ChangeFocus(&this->actor, play, this->actor.child); EnMaYto_SetRomaniFaceExpression(this, 0, 1); - Message_StartTextbox(globalCtx, 0x339E, &this->actor); + Message_StartTextbox(play, 0x339E, &this->actor); this->textId = 0x339E; - func_80151BB4(globalCtx, 6); - func_80151BB4(globalCtx, 5); + func_80151BB4(play, 6); + func_80151BB4(play, 5); break; case 0x339F: this->unk31E = 0; - Message_StartTextbox(globalCtx, 0x33A0, &this->actor); + Message_StartTextbox(play, 0x33A0, &this->actor); this->textId = 0x33A0; break; case 0x33A0: - Message_StartTextbox(globalCtx, 0x33A1, &this->actor); + Message_StartTextbox(play, 0x33A1, &this->actor); this->textId = 0x33A1; break; case 0x33A1: func_80B90E50(this, 1); - Actor_ChangeFocus(&this->actor, globalCtx, this->actor.child); + Actor_ChangeFocus(&this->actor, play, this->actor.child); EnMaYto_SetRomaniFaceExpression(this, 0, 2); - Message_StartTextbox(globalCtx, 0x33A2, &this->actor); + Message_StartTextbox(play, 0x33A2, &this->actor); this->textId = 0x33A2; break; case 0x33A2: this->unk31E = 1; - Actor_ChangeFocus(&this->actor, globalCtx, &this->actor); + Actor_ChangeFocus(&this->actor, play, &this->actor); EnMaYto_SetFaceExpression(this, 4, 3); - Message_StartTextbox(globalCtx, 0x33A3, &this->actor); + Message_StartTextbox(play, 0x33A3, &this->actor); this->textId = 0x33A3; break; case 0x33A3: this->unk31E = 0; EnMaYto_SetFaceExpression(this, 3, 3); - Message_StartTextbox(globalCtx, 0x33A4, &this->actor); + Message_StartTextbox(play, 0x33A4, &this->actor); this->textId = 0x33A4; - func_80151BB4(globalCtx, 6); - func_80151BB4(globalCtx, 5); + func_80151BB4(play, 6); + func_80151BB4(play, 5); break; case 0x33A5: - Message_StartTextbox(globalCtx, 0x33A6, &this->actor); + Message_StartTextbox(play, 0x33A6, &this->actor); this->textId = 0x33A6; - func_80151BB4(globalCtx, 6); + func_80151BB4(play, 6); break; case 0x33A7: - Message_StartTextbox(globalCtx, 0x33A8, &this->actor); + Message_StartTextbox(play, 0x33A8, &this->actor); this->textId = 0x33A8; - func_80151BB4(globalCtx, 6); + func_80151BB4(play, 6); break; } } @@ -698,26 +704,26 @@ void EnMaYto_SetupBarnWait(EnMaYto* this) { this->actionFunc = EnMaYto_BarnWait; } -void EnMaYto_BarnWait(EnMaYto* this, GlobalContext* globalCtx) { +void EnMaYto_BarnWait(EnMaYto* this, PlayState* play) { s16 direction = this->actor.shape.rot.y + 0x471C; direction -= this->actor.yawTowardsPlayer; - if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { - EnMaYto_BarnStartDialogue(this, globalCtx); + if (Actor_ProcessTalkRequest(&this->actor, &play->state)) { + EnMaYto_BarnStartDialogue(this, play); EnMaYto_SetupBarnDialogueHandler(this); } else { Actor* child = this->actor.child; - if (child != NULL && Actor_ProcessTalkRequest(child, &globalCtx->state)) { - Actor_ChangeFocus(&this->actor, globalCtx, &this->actor); - EnMaYto_BarnStartDialogue(this, globalCtx); + if (child != NULL && Actor_ProcessTalkRequest(child, &play->state)) { + Actor_ChangeFocus(&this->actor, play, &this->actor); + EnMaYto_BarnStartDialogue(this, play); EnMaYto_SetupBarnDialogueHandler(this); } else if (!(gSaveContext.save.weekEventReg[22] & 1) || ABS_ALT(direction) < 0x2000) { - func_800B8614(&this->actor, globalCtx, 100.0f); + func_800B8614(&this->actor, play, 100.0f); child = this->actor.child; if (child != NULL) { - func_800B8614(child, globalCtx, 100.0f); + func_800B8614(child, play, 100.0f); } } } @@ -733,136 +739,136 @@ void EnMaYto_SetupBarnDialogueHandler(EnMaYto* this) { this->actionFunc = EnMaYto_BarnDialogueHandler; } -void EnMaYto_BarnDialogueHandler(EnMaYto* this, GlobalContext* globalCtx) { - switch (Message_GetState(&globalCtx->msgCtx)) { - case 5: - EnMaYto_BarnChooseNextDialogue(this, globalCtx); +void EnMaYto_BarnDialogueHandler(EnMaYto* this, PlayState* play) { + switch (Message_GetState(&play->msgCtx)) { + case TEXT_STATE_5: + EnMaYto_BarnChooseNextDialogue(this, play); break; - case 6: - if (Message_ShouldAdvance(globalCtx)) { + case TEXT_STATE_DONE: + if (Message_ShouldAdvance(play)) { this->unk31E = 0; EnMaYto_SetupBarnWait(this); } break; - case 0: - case 1: - case 2: - case 3: - case 4: + case TEXT_STATE_NONE: + case TEXT_STATE_1: + case TEXT_STATE_CLOSING: + case TEXT_STATE_3: + case TEXT_STATE_CHOICE: break; } } -void EnMaYto_BarnChooseNextDialogue(EnMaYto* this, GlobalContext* globalCtx) { - if (Message_ShouldAdvance(globalCtx)) { +void EnMaYto_BarnChooseNextDialogue(EnMaYto* this, PlayState* play) { + if (Message_ShouldAdvance(play)) { switch (this->textId) { case 0x33A9: func_80B90E50(this, 0); - Actor_ChangeFocus(&this->actor, globalCtx, this->actor.child); + Actor_ChangeFocus(&this->actor, play, this->actor.child); EnMaYto_SetRomaniFaceExpression(this, 0, 3); - Message_StartTextbox(globalCtx, 0x33AA, &this->actor); + Message_StartTextbox(play, 0x33AA, &this->actor); this->textId = 0x33AA; break; case 0x33AA: - Actor_ChangeFocus(&this->actor, globalCtx, &this->actor); + Actor_ChangeFocus(&this->actor, play, &this->actor); this->unk31E = 1; - Message_StartTextbox(globalCtx, 0x33AB, &this->actor); + Message_StartTextbox(play, 0x33AB, &this->actor); this->textId = 0x33AB; break; case 0x33AB: func_80B90E50(this, 1); - Actor_ChangeFocus(&this->actor, globalCtx, this->actor.child); + Actor_ChangeFocus(&this->actor, play, this->actor.child); EnMaYto_SetRomaniFaceExpression(this, 0, 1); - Message_StartTextbox(globalCtx, 0x33AC, &this->actor); + Message_StartTextbox(play, 0x33AC, &this->actor); this->textId = 0x33AC; break; case 0x33AC: this->unk31E = 0; - Actor_ChangeFocus(&this->actor, globalCtx, &this->actor); - Message_StartTextbox(globalCtx, 0x33AD, &this->actor); + Actor_ChangeFocus(&this->actor, play, &this->actor); + Message_StartTextbox(play, 0x33AD, &this->actor); this->textId = 0x33AD; - func_80151BB4(globalCtx, 6); - func_80151BB4(globalCtx, 5); + func_80151BB4(play, 6); + func_80151BB4(play, 5); break; case 0x33AE: func_80B90E50(this, 1); - Actor_ChangeFocus(&this->actor, globalCtx, this->actor.child); + Actor_ChangeFocus(&this->actor, play, this->actor.child); EnMaYto_SetRomaniFaceExpression(this, 4, 2); - Message_StartTextbox(globalCtx, 0x33AF, &this->actor); + Message_StartTextbox(play, 0x33AF, &this->actor); this->textId = 0x33AF; break; case 0x33AF: this->unk31E = 1; - Actor_ChangeFocus(&this->actor, globalCtx, &this->actor); + Actor_ChangeFocus(&this->actor, play, &this->actor); EnMaYto_SetFaceExpression(this, 4, 2); - Message_StartTextbox(globalCtx, 0x33B0, &this->actor); + Message_StartTextbox(play, 0x33B0, &this->actor); this->textId = 0x33B0; - func_80151BB4(globalCtx, 6); - func_80151BB4(globalCtx, 5); + func_80151BB4(play, 6); + func_80151BB4(play, 5); break; case 0x33B1: this->unk31E = 2; EnMaYto_SetFaceExpression(this, 5, 3); // "I should had believed what Romani said" - Message_StartTextbox(globalCtx, 0x33B2, &this->actor); + Message_StartTextbox(play, 0x33B2, &this->actor); this->textId = 0x33B2; - func_80151BB4(globalCtx, 6); + func_80151BB4(play, 6); break; case 0x33C6: - Actor_ChangeFocus(&this->actor, globalCtx, this->actor.child); + Actor_ChangeFocus(&this->actor, play, this->actor.child); this->unk31E = 0; EnMaYto_SetFaceExpression(this, 0, 1); - Message_StartTextbox(globalCtx, 0x33C7, &this->actor); + Message_StartTextbox(play, 0x33C7, &this->actor); this->textId = 0x33C7; break; case 0x33C7: - Actor_ChangeFocus(&this->actor, globalCtx, &this->actor); + Actor_ChangeFocus(&this->actor, play, &this->actor); this->unk31E = 1; EnMaYto_SetFaceExpression(this, 0, 1); - Message_StartTextbox(globalCtx, 0x33C8, &this->actor); + Message_StartTextbox(play, 0x33C8, &this->actor); this->textId = 0x33C8; break; case 0x33C8: - Actor_ChangeFocus(&this->actor, globalCtx, this->actor.child); + Actor_ChangeFocus(&this->actor, play, this->actor.child); func_80B90E50(this, 1); EnMaYto_SetRomaniFaceExpression(this, 0, 2); - Message_StartTextbox(globalCtx, 0x33C9, &this->actor); + Message_StartTextbox(play, 0x33C9, &this->actor); this->textId = 0x33C9; break; case 0x33C9: - Actor_ChangeFocus(&this->actor, globalCtx, &this->actor); + Actor_ChangeFocus(&this->actor, play, &this->actor); this->unk31E = 1; EnMaYto_SetFaceExpression(this, 3, 1); - Message_StartTextbox(globalCtx, 0x33CA, &this->actor); + Message_StartTextbox(play, 0x33CA, &this->actor); this->textId = 0x33CA; break; case 0x33CA: this->unk31E = 1; - Message_StartTextbox(globalCtx, 0x33CB, &this->actor); + Message_StartTextbox(play, 0x33CB, &this->actor); this->textId = 0x33CB; break; case 0x33CB: - Actor_ChangeFocus(&this->actor, globalCtx, this->actor.child); + Actor_ChangeFocus(&this->actor, play, this->actor.child); func_80B90E50(this, 1); EnMaYto_SetRomaniFaceExpression(this, 3, 3); - Message_StartTextbox(globalCtx, 0x33CC, &this->actor); + Message_StartTextbox(play, 0x33CC, &this->actor); this->textId = 0x33CC; - func_80151BB4(globalCtx, 6); - func_80151BB4(globalCtx, 5); + func_80151BB4(play, 6); + func_80151BB4(play, 5); break; default: @@ -881,31 +887,31 @@ void EnMaYto_SetupAfterMilkRunInit(EnMaYto* this) { this->actionFunc = EnMaYto_AfterMilkRunInit; } -void EnMaYto_AfterMilkRunInit(EnMaYto* this, GlobalContext* globalCtx) { +void EnMaYto_AfterMilkRunInit(EnMaYto* this, PlayState* play) { this->actor.flags |= ACTOR_FLAG_10000; - if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { + if (Actor_ProcessTalkRequest(&this->actor, &play->state)) { this->actor.flags &= ~ACTOR_FLAG_10000; if (gSaveContext.save.weekEventReg[52] & 1) { // if (ProtectedCremia) - Message_StartTextbox(globalCtx, 0x33C1, &this->actor); + Message_StartTextbox(play, 0x33C1, &this->actor); this->textId = 0x33C1; } else { // Fails milk minigame EnMaYto_SetFaceExpression(this, 5, 2); - Message_StartTextbox(globalCtx, 0x33C0, &this->actor); + Message_StartTextbox(play, 0x33C0, &this->actor); this->textId = 0x33C0; // Attempted Cremia Cart Ride gSaveContext.save.weekEventReg[14] |= 1; this->unk310 = 4; EnMaYto_SetupPostMilkRunWaitDialogueEnd(this); - func_80151BB4(globalCtx, 6); + func_80151BB4(play, 6); return; } EnMaYto_SetupAfterMilkRunDialogueHandler(this); } else { - func_800B8614(&this->actor, globalCtx, 200.0f); + func_800B8614(&this->actor, play, 200.0f); } } @@ -913,38 +919,38 @@ void EnMaYto_SetupAfterMilkRunDialogueHandler(EnMaYto* this) { this->actionFunc = EnMaYto_AfterMilkRunDialogueHandler; } -void EnMaYto_AfterMilkRunDialogueHandler(EnMaYto* this, GlobalContext* globalCtx) { - switch (Message_GetState(&globalCtx->msgCtx)) { - case 0: - case 1: - case 2: - case 3: - case 4: - case 6: +void EnMaYto_AfterMilkRunDialogueHandler(EnMaYto* this, PlayState* play) { + switch (Message_GetState(&play->msgCtx)) { + case TEXT_STATE_NONE: + case TEXT_STATE_1: + case TEXT_STATE_CLOSING: + case TEXT_STATE_3: + case TEXT_STATE_CHOICE: + case TEXT_STATE_DONE: break; - case 5: - EnMaYto_AfterMilkRunChooseNextDialogue(this, globalCtx); + case TEXT_STATE_5: + EnMaYto_AfterMilkRunChooseNextDialogue(this, play); break; } Math_SmoothStepToS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer, 5, 0x71C, 0xB6); } -void EnMaYto_AfterMilkRunChooseNextDialogue(EnMaYto* this, GlobalContext* globalCtx) { - if (Message_ShouldAdvance(globalCtx)) { +void EnMaYto_AfterMilkRunChooseNextDialogue(EnMaYto* this, PlayState* play) { + if (Message_ShouldAdvance(play)) { switch (this->textId) { case 0x33C1: EnMaYto_SetFaceExpression(this, 3, 1); // "Thank you. You were cool back there." - Message_StartTextbox(globalCtx, 0x33C2, &this->actor); + Message_StartTextbox(play, 0x33C2, &this->actor); this->textId = 0x33C2; break; case 0x33C2: - func_801477B4(globalCtx); + func_801477B4(play); EnMaYto_SetupPostMilkRunGiveReward(this); - EnMaYto_PostMilkRunGiveReward(this, globalCtx); + EnMaYto_PostMilkRunGiveReward(this, play); break; } } @@ -954,14 +960,14 @@ void EnMaYto_SetupPostMilkRunGiveReward(EnMaYto* this) { this->actionFunc = EnMaYto_PostMilkRunGiveReward; } -void EnMaYto_PostMilkRunGiveReward(EnMaYto* this, GlobalContext* globalCtx) { - if (Actor_HasParent(&this->actor, globalCtx)) { +void EnMaYto_PostMilkRunGiveReward(EnMaYto* this, PlayState* play) { + if (Actor_HasParent(&this->actor, play)) { EnMaYto_SetupPostMilkRunExplainReward(this); } else if (INV_CONTENT(ITEM_MASK_ROMANI) == ITEM_MASK_ROMANI) { - Actor_PickUp(&this->actor, globalCtx, GI_RUPEE_HUGE, 500.0f, 100.0f); + Actor_PickUp(&this->actor, play, GI_RUPEE_HUGE, 500.0f, 100.0f); this->unk310 = 2; } else { - Actor_PickUp(&this->actor, globalCtx, GI_MASK_ROMANI, 500.0f, 100.0f); + Actor_PickUp(&this->actor, play, GI_MASK_ROMANI, 500.0f, 100.0f); this->unk310 = 1; } } @@ -970,33 +976,33 @@ void EnMaYto_SetupPostMilkRunExplainReward(EnMaYto* this) { this->actionFunc = EnMaYto_PostMilkRunExplainReward; } -void EnMaYto_PostMilkRunExplainReward(EnMaYto* this, GlobalContext* globalCtx) { - if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { +void EnMaYto_PostMilkRunExplainReward(EnMaYto* this, PlayState* play) { + if (Actor_ProcessTalkRequest(&this->actor, &play->state)) { if (this->unk310 == 1) { // Romani's mask explanation EnMaYto_SetFaceExpression(this, 0, 1); - Message_StartTextbox(globalCtx, 0x33C3, &this->actor); + Message_StartTextbox(play, 0x33C3, &this->actor); this->textId = 0x33C3; // Attempted Cremia Cart Ride gSaveContext.save.weekEventReg[14] |= 1; this->unk310 = 3; - func_80151BB4(globalCtx, 0x20); - func_80151BB4(globalCtx, 0x1F); - func_80151BB4(globalCtx, 6); + func_80151BB4(play, 0x20); + func_80151BB4(play, 0x1F); + func_80151BB4(play, 6); EnMaYto_SetupPostMilkRunWaitDialogueEnd(this); } else { // You already have the mask EnMaYto_SetFaceExpression(this, 0, 1); - Message_StartTextbox(globalCtx, 0x33D0, &this->actor); + Message_StartTextbox(play, 0x33D0, &this->actor); this->textId = 0x33D0; // Attempted Cremia Cart Ride gSaveContext.save.weekEventReg[14] |= 1; this->unk310 = 3; - func_80151BB4(globalCtx, 6); + func_80151BB4(play, 6); EnMaYto_SetupPostMilkRunWaitDialogueEnd(this); } } else { - func_800B85E0(&this->actor, globalCtx, 200.0f, EXCH_ITEM_MINUS1); + func_800B85E0(&this->actor, play, 200.0f, PLAYER_AP_MINUS1); } } @@ -1004,7 +1010,7 @@ void EnMaYto_SetupBeginWarmFuzzyFeelingCs(EnMaYto* this) { this->actionFunc = EnMaYto_BeginWarmFuzzyFeelingCs; } -void EnMaYto_BeginWarmFuzzyFeelingCs(EnMaYto* this, GlobalContext* globalCtx) { +void EnMaYto_BeginWarmFuzzyFeelingCs(EnMaYto* this, PlayState* play) { if (ActorCutscene_GetCanPlayNext(this->actor.cutscene)) { ActorCutscene_Start(this->actor.cutscene, &this->actor); EnMaYto_SetupWarmFuzzyFeelingCs(this); @@ -1023,12 +1029,12 @@ void EnMaYto_SetupWarmFuzzyFeelingCs(EnMaYto* this) { static u16 D_80B915F0 = 99; -void EnMaYto_WarmFuzzyFeelingCs(EnMaYto* this, GlobalContext* globalCtx) { - if (Cutscene_CheckActorAction(globalCtx, 556)) { - s32 csActionIndex = Cutscene_GetActorActionIndex(globalCtx, 556); +void EnMaYto_WarmFuzzyFeelingCs(EnMaYto* this, PlayState* play) { + if (Cutscene_CheckActorAction(play, 556)) { + s32 csActionIndex = Cutscene_GetActorActionIndex(play, 556); - if (globalCtx->csCtx.frames == globalCtx->csCtx.actorActions[csActionIndex]->startFrame) { - u16 action = globalCtx->csCtx.actorActions[csActionIndex]->action; + if (play->csCtx.frames == play->csCtx.actorActions[csActionIndex]->startFrame) { + u16 action = play->csCtx.actorActions[csActionIndex]->action; if (1) {} @@ -1052,8 +1058,8 @@ void EnMaYto_WarmFuzzyFeelingCs(EnMaYto* this, GlobalContext* globalCtx) { } } - Cutscene_ActorTranslateAndYaw(&this->actor, globalCtx, csActionIndex); - if (D_80B915F0 == 2 && this->skelAnime.animation == &object_ma2_Anim_001FD0 && + Cutscene_ActorTranslateAndYaw(&this->actor, play, csActionIndex); + if (D_80B915F0 == 2 && this->skelAnime.animation == &gCremiaHugStartAnim && Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) { EnMaYto_ChangeAnim(this, 20); } @@ -1066,15 +1072,15 @@ void EnMaYto_SetupPostMilkRunWaitDialogueEnd(EnMaYto* this) { this->actionFunc = EnMaYto_PostMilkRunWaitDialogueEnd; } -void EnMaYto_PostMilkRunWaitDialogueEnd(EnMaYto* this, GlobalContext* globalCtx) { - if (Message_GetState(&globalCtx->msgCtx) == 6 || Message_GetState(&globalCtx->msgCtx) == 5) { - if (Message_ShouldAdvance(globalCtx) && Message_GetState(&globalCtx->msgCtx) == 5) { - func_800B7298(globalCtx, &this->actor, 7); - func_801477B4(globalCtx); +void EnMaYto_PostMilkRunWaitDialogueEnd(EnMaYto* this, PlayState* play) { + if (Message_GetState(&play->msgCtx) == TEXT_STATE_DONE || Message_GetState(&play->msgCtx) == TEXT_STATE_5) { + if (Message_ShouldAdvance(play) && Message_GetState(&play->msgCtx) == TEXT_STATE_5) { + func_800B7298(play, &this->actor, 7); + func_801477B4(play); } } - if (Message_GetState(&globalCtx->msgCtx) == 0 && globalCtx->msgCtx.unk120B1 == 0) { + if (Message_GetState(&play->msgCtx) == TEXT_STATE_NONE && play->msgCtx.unk120B1 == 0) { EnMaYto_SetupPostMilkRunEnd(this); } } @@ -1083,195 +1089,193 @@ void EnMaYto_SetupPostMilkRunEnd(EnMaYto* this) { this->actionFunc = EnMaYto_PostMilkRunEnd; } -void EnMaYto_PostMilkRunEnd(EnMaYto* this, GlobalContext* globalCtx) { +void EnMaYto_PostMilkRunEnd(EnMaYto* this, PlayState* play) { if (this->unk310 == 3) { - // Termina Field - globalCtx->nextEntranceIndex = 0x54D0; + play->nextEntrance = ENTRANCE(TERMINA_FIELD, 13); } else { - // Romani Ranch - globalCtx->nextEntranceIndex = 0x6480; + play->nextEntrance = ENTRANCE(ROMANI_RANCH, 8); } gSaveContext.nextCutsceneIndex = 0; - globalCtx->sceneLoadFlag = 0x14; - globalCtx->unk_1887F = 0x50; - gSaveContext.nextTransition = 3; + play->transitionTrigger = TRANS_TRIGGER_START; + play->transitionType = TRANS_TYPE_80; + gSaveContext.nextTransitionType = TRANS_TYPE_03; } -void EnMaYto_DefaultStartDialogue(EnMaYto* this, GlobalContext* globalCtx) { +void EnMaYto_DefaultStartDialogue(EnMaYto* this, PlayState* play) { if (CURRENT_DAY == 1) { - if (Player_GetMask(globalCtx) != PLAYER_MASK_NONE && gSaveContext.save.playerForm == PLAYER_FORM_HUMAN) { - switch (Player_GetMask(globalCtx)) { + if (Player_GetMask(play) != PLAYER_MASK_NONE && gSaveContext.save.playerForm == PLAYER_FORM_HUMAN) { + switch (Player_GetMask(play)) { case PLAYER_MASK_ROMANI: - Message_StartTextbox(globalCtx, 0x235D, &this->actor); + Message_StartTextbox(play, 0x235D, &this->actor); this->textId = 0x235D; break; case PLAYER_MASK_CIRCUS_LEADER: EnMaYto_SetFaceExpression(this, 1, 3); - Message_StartTextbox(globalCtx, 0x235E, &this->actor); + Message_StartTextbox(play, 0x235E, &this->actor); this->textId = 0x235E; break; case PLAYER_MASK_KAFEIS_MASK: EnMaYto_SetFaceExpression(this, 1, 2); - Message_StartTextbox(globalCtx, 0x235F, &this->actor); + Message_StartTextbox(play, 0x235F, &this->actor); this->textId = 0x235F; break; case PLAYER_MASK_COUPLE: - Message_StartTextbox(globalCtx, 0x2360, &this->actor); + Message_StartTextbox(play, 0x2360, &this->actor); this->textId = 0x2360; break; default: - Message_StartTextbox(globalCtx, 0x2361, &this->actor); + Message_StartTextbox(play, 0x2361, &this->actor); this->textId = 0x2361; break; } } else { - if (EnMaYto_HasSpokeToPlayer()) { - Message_StartTextbox(globalCtx, 0x3394, &this->actor); + if (EnMaYto_HasSpokenToPlayer()) { + Message_StartTextbox(play, 0x3394, &this->actor); this->textId = 0x3394; } else { EnMaYto_SetTalkedFlag(); // Asks the player if he came from town. - Message_StartTextbox(globalCtx, 0x3390, &this->actor); + Message_StartTextbox(play, 0x3390, &this->actor); this->textId = 0x3390; } } } else if (CURRENT_DAY == 3) { - if (EnMaYto_HasSpokeToPlayerToday()) { + if (EnMaYto_HasSpokenToPlayerToday()) { EnMaYto_SetFaceExpression(this, 0, 3); - Message_StartTextbox(globalCtx, 0x33C5, &this->actor); + Message_StartTextbox(play, 0x33C5, &this->actor); this->textId = 0x33C5; - func_80151BB4(globalCtx, 6); + func_80151BB4(play, 6); } else { EnMaYto_SetTalkedFlag(); EnMaYto_SetFaceExpression(this, 0, 3); - Message_StartTextbox(globalCtx, 0x33C4, &this->actor); + Message_StartTextbox(play, 0x33C4, &this->actor); this->textId = 0x33C4; - func_80151BB4(globalCtx, 6); + func_80151BB4(play, 6); } } } -void EnMaYto_DinnerStartDialogue(EnMaYto* this, GlobalContext* globalCtx) { +void EnMaYto_DinnerStartDialogue(EnMaYto* this, PlayState* play) { switch (CURRENT_DAY) { case 1: - if (Player_GetMask(globalCtx) != PLAYER_MASK_NONE && gSaveContext.save.playerForm == PLAYER_FORM_HUMAN) { - switch (Player_GetMask(globalCtx)) { + if (Player_GetMask(play) != PLAYER_MASK_NONE && gSaveContext.save.playerForm == PLAYER_FORM_HUMAN) { + switch (Player_GetMask(play)) { case PLAYER_MASK_ROMANI: - Message_StartTextbox(globalCtx, 0x235D, &this->actor); + Message_StartTextbox(play, 0x235D, &this->actor); this->textId = 0x235D; break; case PLAYER_MASK_CIRCUS_LEADER: - Message_StartTextbox(globalCtx, 0x235E, &this->actor); + Message_StartTextbox(play, 0x235E, &this->actor); this->textId = 0x235E; break; case PLAYER_MASK_KAFEIS_MASK: - Message_StartTextbox(globalCtx, 0x235F, &this->actor); + Message_StartTextbox(play, 0x235F, &this->actor); this->textId = 0x235F; break; case PLAYER_MASK_COUPLE: - Message_StartTextbox(globalCtx, 0x2360, &this->actor); + Message_StartTextbox(play, 0x2360, &this->actor); this->textId = 0x2360; break; default: - Message_StartTextbox(globalCtx, 0x2361, &this->actor); + Message_StartTextbox(play, 0x2361, &this->actor); this->textId = 0x2361; break; } } else { - if (EnMaYto_HasSpokeToPlayer()) { - Message_StartTextbox(globalCtx, 0x339F, &this->actor); + if (EnMaYto_HasSpokenToPlayer()) { + Message_StartTextbox(play, 0x339F, &this->actor); this->textId = 0x339F; } else { EnMaYto_SetTalkedFlag(); - Message_StartTextbox(globalCtx, 0x3397, &this->actor); + Message_StartTextbox(play, 0x3397, &this->actor); this->textId = 0x3397; } } break; case 2: - if (EnMaYto_HasSpokeToPlayer()) { - Message_StartTextbox(globalCtx, 0x33A6, &this->actor); + if (EnMaYto_HasSpokenToPlayer()) { + Message_StartTextbox(play, 0x33A6, &this->actor); this->textId = 0x33A6; - func_80151BB4(globalCtx, 6); + func_80151BB4(play, 6); } else { EnMaYto_SetTalkedFlag(); - Message_StartTextbox(globalCtx, 0x33A5, &this->actor); + Message_StartTextbox(play, 0x33A5, &this->actor); this->textId = 0x33A5; } break; case 3: - if (EnMaYto_HasSpokeToPlayer()) { - Message_StartTextbox(globalCtx, 0x33A8, &this->actor); + if (EnMaYto_HasSpokenToPlayer()) { + Message_StartTextbox(play, 0x33A8, &this->actor); this->textId = 0x33A8; - func_80151BB4(globalCtx, 6); + func_80151BB4(play, 6); } else { EnMaYto_SetTalkedFlag(); - Message_StartTextbox(globalCtx, 0x33A7, &this->actor); + Message_StartTextbox(play, 0x33A7, &this->actor); this->textId = 0x33A7; } break; } } -void EnMaYto_BarnStartDialogue(EnMaYto* this, GlobalContext* globalCtx) { +void EnMaYto_BarnStartDialogue(EnMaYto* this, PlayState* play) { // if (AliensDefeated) if (gSaveContext.save.weekEventReg[22] & 1) { if (CURRENT_DAY == 2) { if (this->unk310 == 1) { - Message_StartTextbox(globalCtx, 0x33AE, &this->actor); + Message_StartTextbox(play, 0x33AE, &this->actor); this->textId = 0x33AE; } else { this->unk310 = 1; EnMaYto_SetTalkedFlag(); - Message_StartTextbox(globalCtx, 0x33A9, &this->actor); + Message_StartTextbox(play, 0x33A9, &this->actor); this->textId = 0x33A9; } } else if (CURRENT_DAY == 3) { if (this->unk310 == 1) { - Message_StartTextbox(globalCtx, 0x33CB, &this->actor); + Message_StartTextbox(play, 0x33CB, &this->actor); this->textId = 0x33CB; } else { this->unk310 = 1; EnMaYto_SetTalkedFlag(); EnMaYto_SetFaceExpression(this, 0, 1); - Message_StartTextbox(globalCtx, 0x33C6, &this->actor); + Message_StartTextbox(play, 0x33C6, &this->actor); this->textId = 0x33C6; } } } else { - if (EnMaYto_HasSpokeToPlayer()) { + if (EnMaYto_HasSpokenToPlayer()) { this->unk31E = 2; EnMaYto_SetFaceExpression(this, 5, 3); - Message_StartTextbox(globalCtx, 0x33B3, &this->actor); + Message_StartTextbox(play, 0x33B3, &this->actor); this->textId = 0x33B3; - func_80151BB4(globalCtx, 6); + func_80151BB4(play, 6); } else { EnMaYto_SetTalkedFlag(); EnMaYto_SetFaceExpression(this, 5, 3); - Message_StartTextbox(globalCtx, 0x33B1, &this->actor); + Message_StartTextbox(play, 0x33B1, &this->actor); this->textId = 0x33B1; } } } -void EnMaYto_ChangeAnim(EnMaYto* this, s32 index) { - Animation_Change(&this->skelAnime, sAnimationInfo[index].animation, 1.0f, 0.0f, - Animation_GetLastFrame(sAnimationInfo[index].animation), sAnimationInfo[index].mode, - sAnimationInfo[index].morphFrames); +void EnMaYto_ChangeAnim(EnMaYto* this, s32 animIndex) { + Animation_Change(&this->skelAnime, sAnimationInfo[animIndex].animation, 1.0f, 0.0f, + Animation_GetLastFrame(sAnimationInfo[animIndex].animation), sAnimationInfo[animIndex].mode, + sAnimationInfo[animIndex].morphFrames); } -void func_80B90C78(EnMaYto* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); +void func_80B90C78(EnMaYto* this, PlayState* play) { + Player* player = GET_PLAYER(play); s16 flag; SkelAnime_Update(&this->skelAnime); @@ -1300,10 +1304,10 @@ void func_80B90C78(EnMaYto* this, GlobalContext* globalCtx) { EnMaYto_UpdateEyes(this); } -void EnMaYto_UpdateCollision(EnMaYto* this, GlobalContext* globalCtx) { +void EnMaYto_UpdateCollision(EnMaYto* this, PlayState* play) { if (this->actionFunc != EnMaYto_WarmFuzzyFeelingCs) { Collider_UpdateCylinder(&this->actor, &this->collider); - CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + CollisionCheck_SetOC(play, &play->colChkCtx, &this->collider.base); } } @@ -1357,7 +1361,7 @@ void EnMaYto_InitFaceExpression(EnMaYto* this) { } } -s32 EnMaYto_HasSpokeToPlayerToday(void) { +s32 EnMaYto_HasSpokenToPlayerToday(void) { switch (CURRENT_DAY) { case 1: if (gSaveContext.save.weekEventReg[13] & 4) { @@ -1380,7 +1384,7 @@ 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: @@ -1417,33 +1421,31 @@ void EnMaYto_SetTalkedFlag(void) { } } -void EnMaYto_Update(Actor* thisx, GlobalContext* globalCtx) { +void EnMaYto_Update(Actor* thisx, PlayState* play) { EnMaYto* this = THIS; - this->actionFunc(this, globalCtx); - EnMaYto_UpdateCollision(this, globalCtx); - func_80B90C78(this, globalCtx); + this->actionFunc(this, play); + EnMaYto_UpdateCollision(this, play); + func_80B90C78(this, play); } -s32 EnMaYto_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, - Actor* thisx) { +s32 EnMaYto_OverrideLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, Actor* thisx) { EnMaYto* this = THIS; Vec3s sp4; - if (limbIndex == MA2_LIMB_HEAD) { + if (limbIndex == CREMIA_LIMB_HEAD) { sp4 = this->unk_1D8.unk_08; rot->x += sp4.y; rot->z += sp4.x; - } else if (limbIndex == MA2_LIMB_TORSO) { - if (this->skelAnime.animation != &object_ma2_Anim_007E28 && - this->skelAnime.animation != &object_ma2_Anim_003D54) { + } else if (limbIndex == CREMIA_LIMB_TORSO) { + if (this->skelAnime.animation != &gCremiaSittingPetCowAnim && + this->skelAnime.animation != &gCremiaSittingLookDownAnim) { sp4 = this->unk_1D8.unk_0E; rot->x += sp4.y; - if (this->skelAnime.animation == &object_ma2_Anim_00A174 || - this->skelAnime.animation == &object_ma2_Anim_0070EC || - this->skelAnime.animation == &object_ma2_Anim_003D54) { + if (this->skelAnime.animation == &gCremiaIdleAnim || this->skelAnime.animation == &gCremiaSittingAnim || + this->skelAnime.animation == &gCremiaSittingLookDownAnim) { rot->z += sp4.x; } } @@ -1451,30 +1453,30 @@ s32 EnMaYto_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dLis return 0; } -void EnMaYto_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx) { +void EnMaYto_PostLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx) { EnMaYto* this = THIS; - if (limbIndex == MA2_LIMB_HEAD) { - Matrix_GetStateTranslation(&this->actor.focus.pos); + if (limbIndex == CREMIA_LIMB_HEAD) { + Matrix_MultZero(&this->actor.focus.pos); } } -void EnMaYto_Draw(Actor* thisx, GlobalContext* globalCtx) { +void EnMaYto_Draw(Actor* thisx, PlayState* play) { EnMaYto* this = THIS; s32 pad; - OPEN_DISPS(globalCtx->state.gfxCtx); + OPEN_DISPS(play->state.gfxCtx); 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); + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_OPA_DISP++, gCremiaWoodenBoxDL); } - func_8012C28C(globalCtx->state.gfxCtx); + func_8012C28C(play->state.gfxCtx); gSPSegment(POLY_OPA_DISP++, 0x09, Lib_SegmentedToVirtual(sMouthTextures[this->mouthTexIndex])); gSPSegment(POLY_OPA_DISP++, 0x08, Lib_SegmentedToVirtual(sEyesTextures[this->eyeTexIndex])); - SkelAnime_DrawFlexOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, + SkelAnime_DrawFlexOpa(play, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, EnMaYto_OverrideLimbDraw, EnMaYto_PostLimbDraw, &this->actor); - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->state.gfxCtx); } diff --git a/src/overlays/actors/ovl_En_Ma_Yto/z_en_ma_yto.h b/src/overlays/actors/ovl_En_Ma_Yto/z_en_ma_yto.h index 0feaea48a..e21b30c29 100644 --- a/src/overlays/actors/ovl_En_Ma_Yto/z_en_ma_yto.h +++ b/src/overlays/actors/ovl_En_Ma_Yto/z_en_ma_yto.h @@ -2,37 +2,11 @@ #define Z_EN_MA_YTO_H #include "global.h" -#include "overlays/actors/ovl_En_Ma_Yts/z_en_ma_yts.h" +#include "objects/object_ma2/object_ma2.h" struct EnMaYto; -typedef void (*EnMaYtoActionFunc)(struct EnMaYto*, GlobalContext*); - -typedef enum { - /* 00 */ MA2_LIMB_NONE, - /* 01 */ MA2_LIMB_ROOT, - /* 02 */ MA2_LIMB_TORSO, - /* 03 */ MA2_LIMB_ARM_LEFT, - /* 04 */ MA2_LIMB_FOREARM_LEFT, - /* 05 */ MA2_LIMB_HAND_LEFT, - /* 06 */ MA2_LIMB_ARM_RIGHT, - /* 07 */ MA2_LIMB_FOREARM_RIGHT, - /* 08 */ MA2_LIMB_HAND_RIGHT, - /* 09 */ MA2_LIMB_HEAD, - /* 10 */ MA2_LIMB_HAIR, - /* 11 */ MA2_LIMB_PELVIS, - /* 12 */ MA2_LIMB_TIGHT_LEFT, - /* 13 */ MA2_LIMB_LEG_LEFT, - /* 14 */ MA2_LIMB_FOOT_LEFT, - /* 15 */ MA2_LIMB_TIGHT_RIGHT, - /* 16 */ MA2_LIMB_LEG_RIGHT, - /* 17 */ MA2_LIMB_FOOT_RIGHT, - /* 18 */ MA2_LIMB_DRESS_0, - /* 19 */ MA2_LIMB_DRESS_1, - /* 20 */ MA2_LIMB_DRESS_2, - /* 21 */ MA2_LIMB_DRESS_3, - /* 22 */ MA2_LIMB_MAX -} ObjectMa2Limbs; +typedef void (*EnMaYtoActionFunc)(struct EnMaYto*, PlayState*); typedef struct EnMaYto { /* 0x000 */ Actor actor; @@ -42,11 +16,11 @@ typedef struct EnMaYto { /* 0x1D8 */ struct_800BD888_arg1 unk_1D8; /* 0x200 */ s32 unk200; // unused /* 0x204 */ s32 type; - /* 0x208 */ Vec3s jointTable[MA2_LIMB_MAX]; - /* 0x28C */ Vec3s morphTable[MA2_LIMB_MAX]; + /* 0x208 */ Vec3s jointTable[CREMIA_LIMB_MAX]; + /* 0x28C */ Vec3s morphTable[CREMIA_LIMB_MAX]; /* 0x310 */ s16 unk310; // state? /* 0x312 */ UNK_TYPE1 unk_312[0x2]; - /* 0x314 */ s16 currentAnim; // Used only in DefaultWait + /* 0x314 */ s16 animIndex; // Used only in DefaultWait /* 0x316 */ s16 overrideEyeTexIndex; // If non-zero, then this index will be used instead of eyeTexIndex /* 0x318 */ s16 mouthTexIndex; /* 0x31A */ s16 eyeTexIndex; @@ -66,7 +40,7 @@ typedef enum { /* 4 */ MA_YTO_TYPE_4 // HugCutscene? Doesn't seem to work properly in-game } EnMaYtoType; -#define EN_MA_YTO_PARSE_TYPE(params) (((params)&0xF000) >> 12) +#define EN_MA_YTO_GET_TYPE(thisx) (((thisx)->params & 0xF000) >> 12) #define EN_MA_YTO_PARAM(enMaYtsType, arg1) (((enMaYtsType) << 12) | ((arg1) << 8)) #endif // Z_EN_MA_YTO_H 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 29eb6cdcc..5fcf1c7f0 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 @@ -5,30 +5,29 @@ */ #include "z_en_ma_yts.h" -#include "objects/object_ma1/object_ma1.h" #define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_8 | ACTOR_FLAG_100000 | ACTOR_FLAG_2000000) #define THIS ((EnMaYts*)thisx) -void EnMaYts_Init(Actor* thisx, GlobalContext* globalCtx); -void EnMaYts_Destroy(Actor* thisx, GlobalContext* globalCtx); -void EnMaYts_Update(Actor* thisx, GlobalContext* globalCtx); -void EnMaYts_Draw(Actor* thisx, GlobalContext* globalCtx); +void EnMaYts_Init(Actor* thisx, PlayState* play); +void EnMaYts_Destroy(Actor* thisx, PlayState* play); +void EnMaYts_Update(Actor* thisx, PlayState* play); +void EnMaYts_Draw(Actor* thisx, PlayState* play); void EnMaYts_SetupDoNothing(EnMaYts* this); -void EnMaYts_DoNothing(EnMaYts* this, GlobalContext* globalCtx); +void EnMaYts_DoNothing(EnMaYts* this, PlayState* play); void EnMaYts_SetupStartDialogue(EnMaYts* this); -void EnMaYts_StartDialogue(EnMaYts* this, GlobalContext* globalCtx); +void EnMaYts_StartDialogue(EnMaYts* this, PlayState* play); void EnMaYts_SetupDialogueHandler(EnMaYts* this); -void EnMaYts_DialogueHandler(EnMaYts* this, GlobalContext* globalCtx); +void EnMaYts_DialogueHandler(EnMaYts* this, PlayState* play); void EnMaYts_SetupEndCreditsHandler(EnMaYts* this); -void EnMaYts_EndCreditsHandler(EnMaYts* this, GlobalContext* globalCtx); -void EnMaYts_ChooseNextDialogue(EnMaYts* this, GlobalContext* globalCtx); +void EnMaYts_EndCreditsHandler(EnMaYts* this, PlayState* play); +void EnMaYts_ChooseNextDialogue(EnMaYts* this, PlayState* play); void EnMaYts_SetFaceExpression(EnMaYts* this, s16 overrideEyeTexIndex, s16 mouthTexIndex); -void EnMaYts_DrawSleeping(Actor* thisx, GlobalContext* globalCtx); +void EnMaYts_DrawSleeping(Actor* thisx, PlayState* play); const ActorInit En_Ma_Yts_InitVars = { ACTOR_EN_MA_YTS, @@ -79,49 +78,49 @@ static CollisionCheckInfoInit2 sColChkInfoInit2 = { }; 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 + { &gRomaniIdleAnim, 1.0f, ANIMMODE_LOOP, 0.0f }, + { &gRomaniIdleAnim, 1.0f, ANIMMODE_LOOP, -6.0f }, + { &gRomaniSingStartAnim, 1.0f, ANIMMODE_ONCE, 0.0f }, + { &gRomaniSingStartAnim, 1.0f, ANIMMODE_ONCE, -6.0f }, + { &gRomaniSingLoopAnim, 1.0f, ANIMMODE_LOOP, 0.0f }, + { &gRomaniSingLoopAnim, 1.0f, ANIMMODE_LOOP, -6.0f }, + { &gRomaniRunAnim, 1.0f, ANIMMODE_LOOP, 0.0f }, + { &gRomaniRunAnim, 1.0f, ANIMMODE_LOOP, -6.0f }, + { &gRomaniWalkAnim, 1.0f, ANIMMODE_LOOP, 0.0f }, + { &gRomaniWalkAnim, 1.0f, ANIMMODE_LOOP, -6.0f }, + { &gRomaniLookAroundAnim, 1.0f, ANIMMODE_LOOP, 0.0f }, + { &gRomaniLookAroundAnim, 1.0f, ANIMMODE_LOOP, -6.0f }, + { &gRomaniShootBowAnim, 1.0f, ANIMMODE_LOOP, 0.0f }, + { &gRomaniShootBowAnim, 1.0f, ANIMMODE_LOOP, -6.0f }, + { &gRomaniSittingAnim, 1.0f, ANIMMODE_LOOP, 0.0f }, + { &gRomaniSittingAnim, 1.0f, ANIMMODE_LOOP, -6.0f }, + { &gRomaniSittingHeadShakeAnim, 1.0f, ANIMMODE_LOOP, 0.0f }, + { &gRomaniSittingHeadShakeAnim, 1.0f, ANIMMODE_LOOP, -6.0f }, + { &gRomaniSittingLookDownAnim, 1.0f, ANIMMODE_LOOP, 0.0f }, + { &gRomaniSittingLookDownAnim, 1.0f, ANIMMODE_LOOP, -6.0f }, + { &gRomaniTurnAroundAndFlickHairAnim, 1.0f, ANIMMODE_ONCE, 0.0f }, + { &gRomaniTurnAroundAndFlickHairAnim, 1.0f, ANIMMODE_ONCE, -6.0f }, }; static TexturePtr sMouthTextures[] = { - object_ma1_Tex_0127C8, - object_ma1_Tex_012BC8, - object_ma1_Tex_012FC8, - object_ma1_Tex_0133C8, + gRomaniMouthHappyTex, + gRomaniMouthFrownTex, + gRomaniMouthHangingOpenTex, + gRomaniMouthSmileTex, }; static TexturePtr sEyeTextures[] = { - object_ma1_Tex_00FFC8, object_ma1_Tex_0107C8, object_ma1_Tex_010FC8, object_ma1_Tex_0117C8, object_ma1_Tex_011FC8, + gRomaniEyeOpenTex, gRomaniEyeHalfTex, gRomaniEyeClosedTex, gRomaniEyeHappyTex, gRomaniEyeSadTex, }; -void EnMaYts_ChangeAnim(EnMaYts* this, s32 index) { - Animation_Change(&this->skelAnime, sAnimationInfo[index].animation, 1.0f, 0.0f, - Animation_GetLastFrame(sAnimationInfo[index].animation), sAnimationInfo[index].mode, - sAnimationInfo[index].morphFrames); +void EnMaYts_ChangeAnim(EnMaYts* this, s32 animIndex) { + Animation_Change(&this->skelAnime, sAnimationInfo[animIndex].animation, 1.0f, 0.0f, + Animation_GetLastFrame(sAnimationInfo[animIndex].animation), sAnimationInfo[animIndex].mode, + sAnimationInfo[animIndex].morphFrames); } -void func_80B8D12C(EnMaYts* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); +void func_80B8D12C(EnMaYts* this, PlayState* play) { + Player* player = GET_PLAYER(play); s16 flag = this->unk_32C == 2 ? true : false; if (this->unk_32C == 0 || this->actor.parent == NULL) { @@ -135,7 +134,7 @@ void func_80B8D12C(EnMaYts* this, GlobalContext* globalCtx) { func_800BD888(&this->actor, &this->unk_1D8, 0, flag); } -void EnMaYts_InitAnimation(EnMaYts* this, GlobalContext* globalCtx) { +void EnMaYts_InitAnimation(EnMaYts* this, PlayState* play) { switch (this->type) { case MA_YTS_TYPE_BARN: this->actor.targetMode = 0; @@ -169,7 +168,7 @@ void EnMaYts_InitAnimation(EnMaYts* this, GlobalContext* globalCtx) { } } -s32 EnMaYts_CheckValidSpawn(EnMaYts* this, GlobalContext* globalCtx) { +s32 EnMaYts_CheckValidSpawn(EnMaYts* this, PlayState* play) { switch (this->type) { case MA_YTS_TYPE_SITTING: switch (CURRENT_DAY) { @@ -215,29 +214,28 @@ s32 EnMaYts_CheckValidSpawn(EnMaYts* this, GlobalContext* globalCtx) { return true; } -void EnMaYts_Init(Actor* thisx, GlobalContext* globalCtx) { +void EnMaYts_Init(Actor* thisx, PlayState* play) { EnMaYts* this = THIS; s32 pad; - this->type = EN_MA_YTS_PARSE_TYPE(thisx); - if (!EnMaYts_CheckValidSpawn(this, globalCtx)) { + this->type = EN_MA_YTS_GET_TYPE(thisx); + if (!EnMaYts_CheckValidSpawn(this, play)) { Actor_MarkForDeath(&this->actor); } ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 18.0f); - SkelAnime_InitFlex(globalCtx, &this->skelAnime, &object_ma1_Skel_013928, NULL, this->jointTable, this->morphTable, - MA1_LIMB_MAX); - EnMaYts_InitAnimation(this, globalCtx); + SkelAnime_InitFlex(play, &this->skelAnime, &gRomaniSkel, NULL, this->jointTable, this->morphTable, ROMANI_LIMB_MAX); + EnMaYts_InitAnimation(this, play); - Collider_InitCylinder(globalCtx, &this->collider); - Collider_SetCylinder(globalCtx, &this->collider, &this->actor, &sCylinderInit); + Collider_InitCylinder(play, &this->collider); + Collider_SetCylinder(play, &this->collider, &this->actor, &sCylinderInit); CollisionCheck_SetInfo2(&this->actor.colChkInfo, DamageTable_Get(0x16), &sColChkInfoInit2); if (this->type == MA_YTS_TYPE_SLEEPING) { this->collider.dim.radius = 40; } - Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 0.0f, 0.0f, 0.0f, 0x4); + Actor_UpdateBgCheckInfo(play, &this->actor, 0.0f, 0.0f, 0.0f, 0x4); Actor_SetScale(&this->actor, 0.01f); this->unk_1D8.unk_00 = 0; @@ -275,17 +273,17 @@ void EnMaYts_Init(Actor* thisx, GlobalContext* globalCtx) { } } -void EnMaYts_Destroy(Actor* thisx, GlobalContext* globalCtx) { +void EnMaYts_Destroy(Actor* thisx, PlayState* play) { EnMaYts* this = THIS; - Collider_DestroyCylinder(globalCtx, &this->collider); + Collider_DestroyCylinder(play, &this->collider); } void EnMaYts_SetupDoNothing(EnMaYts* this) { this->actionFunc = EnMaYts_DoNothing; } -void EnMaYts_DoNothing(EnMaYts* this, GlobalContext* globalCtx) { +void EnMaYts_DoNothing(EnMaYts* this, PlayState* play) { } void EnMaYts_SetupStartDialogue(EnMaYts* this) { @@ -293,58 +291,58 @@ void EnMaYts_SetupStartDialogue(EnMaYts* this) { this->actionFunc = EnMaYts_StartDialogue; } -void EnMaYts_StartDialogue(EnMaYts* this, GlobalContext* globalCtx) { +void EnMaYts_StartDialogue(EnMaYts* this, PlayState* play) { s16 sp26 = this->actor.shape.rot.y - this->actor.yawTowardsPlayer; - if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { + if (Actor_ProcessTalkRequest(&this->actor, &play->state)) { if (!(gSaveContext.save.playerForm == PLAYER_FORM_HUMAN)) { if (!(gSaveContext.save.weekEventReg[65] & 0x80)) { // Saying to non-human Link: "Cremia went to town." gSaveContext.save.weekEventReg[65] |= 0x80; EnMaYts_SetFaceExpression(this, 0, 0); - Message_StartTextbox(globalCtx, 0x335F, &this->actor); + Message_StartTextbox(play, 0x335F, &this->actor); this->textId = 0x335F; } else { // Saying to non-human Link: "Pretend you did not hear that." EnMaYts_SetFaceExpression(this, 4, 3); - Message_StartTextbox(globalCtx, 0x3362, &this->actor); + Message_StartTextbox(play, 0x3362, &this->actor); this->textId = 0x3362; - func_80151BB4(globalCtx, 5); + func_80151BB4(play, 5); } - } else if (Player_GetMask(globalCtx) != PLAYER_MASK_NONE) { + } else if (Player_GetMask(play) != PLAYER_MASK_NONE) { if (!(gSaveContext.save.weekEventReg[65] & 0x40)) { gSaveContext.save.weekEventReg[65] |= 0x40; EnMaYts_SetFaceExpression(this, 0, 0); - Message_StartTextbox(globalCtx, 0x3363, &this->actor); + Message_StartTextbox(play, 0x3363, &this->actor); this->textId = 0x3363; } else { EnMaYts_SetFaceExpression(this, 4, 2); - Message_StartTextbox(globalCtx, 0x3366, &this->actor); + Message_StartTextbox(play, 0x3366, &this->actor); this->textId = 0x3366; - func_80151BB4(globalCtx, 5); + func_80151BB4(play, 5); } } else if (!(gSaveContext.save.weekEventReg[21] & 0x20)) { EnMaYts_SetFaceExpression(this, 0, 0); - Message_StartTextbox(globalCtx, 0x3367, &this->actor); + Message_StartTextbox(play, 0x3367, &this->actor); this->textId = 0x3367; } else { if (!(gSaveContext.save.weekEventReg[65] & 0x20)) { // Saying to Grasshopper: "Cremia went to town." gSaveContext.save.weekEventReg[65] |= 0x20; EnMaYts_SetFaceExpression(this, 4, 2); - Message_StartTextbox(globalCtx, 0x3369, &this->actor); + Message_StartTextbox(play, 0x3369, &this->actor); this->textId = 0x3369; } else { // Saying to Grasshopper: "You're our bodyguard." EnMaYts_SetFaceExpression(this, 0, 0); - Message_StartTextbox(globalCtx, 0x336C, &this->actor); + Message_StartTextbox(play, 0x336C, &this->actor); this->textId = 0x336C; - func_80151BB4(globalCtx, 5); + func_80151BB4(play, 5); } } EnMaYts_SetupDialogueHandler(this); } else if (ABS_ALT(sp26) < 0x4000) { - func_800B8614(&this->actor, globalCtx, 120.0f); + func_800B8614(&this->actor, play, 120.0f); } } @@ -352,23 +350,23 @@ void EnMaYts_SetupDialogueHandler(EnMaYts* this) { this->actionFunc = EnMaYts_DialogueHandler; } -void EnMaYts_DialogueHandler(EnMaYts* this, GlobalContext* globalCtx) { - switch (Message_GetState(&globalCtx->msgCtx)) { - case 5: // End message block - EnMaYts_ChooseNextDialogue(this, globalCtx); +void EnMaYts_DialogueHandler(EnMaYts* this, PlayState* play) { + switch (Message_GetState(&play->msgCtx)) { + case TEXT_STATE_5: // End message block + EnMaYts_ChooseNextDialogue(this, play); break; - case 6: // End conversation - if (Message_ShouldAdvance(globalCtx) != 0) { + case TEXT_STATE_DONE: // End conversation + if (Message_ShouldAdvance(play)) { EnMaYts_SetupStartDialogue(this); } break; - case 0: - case 1: - case 2: - case 3: - case 4: + case TEXT_STATE_NONE: + case TEXT_STATE_1: + case TEXT_STATE_CLOSING: + case TEXT_STATE_3: + case TEXT_STATE_CHOICE: break; } } @@ -380,15 +378,15 @@ void EnMaYts_SetupEndCreditsHandler(EnMaYts* this) { } static u16 D_80B8E32C = 99; -void EnMaYts_EndCreditsHandler(EnMaYts* this, GlobalContext* globalCtx) { - if (Cutscene_CheckActorAction(globalCtx, 120)) { - s32 actionIndex = Cutscene_GetActorActionIndex(globalCtx, 120); +void EnMaYts_EndCreditsHandler(EnMaYts* this, PlayState* play) { + if (Cutscene_CheckActorAction(play, 120)) { + s32 actionIndex = Cutscene_GetActorActionIndex(play, 120); - if (globalCtx->csCtx.frames == globalCtx->csCtx.actorActions[actionIndex]->startFrame) { - if (globalCtx->csCtx.actorActions[actionIndex]->action != D_80B8E32C) { - D_80B8E32C = globalCtx->csCtx.actorActions[actionIndex]->action; + if (play->csCtx.frames == play->csCtx.actorActions[actionIndex]->startFrame) { + if (play->csCtx.actorActions[actionIndex]->action != D_80B8E32C) { + D_80B8E32C = play->csCtx.actorActions[actionIndex]->action; this->endCreditsFlag = 0; - switch (globalCtx->csCtx.actorActions[actionIndex]->action) { + switch (play->csCtx.actorActions[actionIndex]->action) { case 1: this->hasBow = true; EnMaYts_ChangeAnim(this, 0); @@ -412,7 +410,7 @@ void EnMaYts_EndCreditsHandler(EnMaYts* this, GlobalContext* globalCtx) { } } - Cutscene_ActorTranslateAndYaw(&this->actor, globalCtx, actionIndex); + Cutscene_ActorTranslateAndYaw(&this->actor, play, actionIndex); if ((D_80B8E32C == 2) && (this->endCreditsFlag == 0) && Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) { this->endCreditsFlag++; @@ -425,53 +423,53 @@ 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 (Message_ShouldAdvance(globalCtx) != 0) { +void EnMaYts_ChooseNextDialogue(EnMaYts* this, PlayState* play) { + if (Message_ShouldAdvance(play)) { switch (this->textId) { case 0x335F: EnMaYts_SetFaceExpression(this, 0, 2); - Message_StartTextbox(globalCtx, 0x3360, &this->actor); + Message_StartTextbox(play, 0x3360, &this->actor); this->textId = 0x3360; break; case 0x3360: EnMaYts_SetFaceExpression(this, 4, 3); - Message_StartTextbox(globalCtx, 0x3361, &this->actor); + Message_StartTextbox(play, 0x3361, &this->actor); this->textId = 0x3361; - func_80151BB4(globalCtx, 5); + func_80151BB4(play, 5); break; case 0x3363: EnMaYts_SetFaceExpression(this, 1, 1); - Message_StartTextbox(globalCtx, 0x3364, &this->actor); + Message_StartTextbox(play, 0x3364, &this->actor); this->textId = 0x3364; break; case 0x3364: EnMaYts_SetFaceExpression(this, 4, 2); - Message_StartTextbox(globalCtx, 0x3365, &this->actor); + Message_StartTextbox(play, 0x3365, &this->actor); this->textId = 0x3365; - func_80151BB4(globalCtx, 5); + func_80151BB4(play, 5); break; case 0x3367: EnMaYts_SetFaceExpression(this, 4, 3); - Message_StartTextbox(globalCtx, 0x3368, &this->actor); + Message_StartTextbox(play, 0x3368, &this->actor); this->textId = 0x3368; - func_80151BB4(globalCtx, 5); + func_80151BB4(play, 5); break; case 0x3369: EnMaYts_SetFaceExpression(this, 0, 0); - Message_StartTextbox(globalCtx, 0x336A, &this->actor); + Message_StartTextbox(play, 0x336A, &this->actor); this->textId = 0x336A; break; case 0x336A: EnMaYts_SetFaceExpression(this, 3, 3); - Message_StartTextbox(globalCtx, 0x336B, &this->actor); + Message_StartTextbox(play, 0x336B, &this->actor); this->textId = 0x336B; - func_80151BB4(globalCtx, 5); + func_80151BB4(play, 5); break; default: @@ -488,32 +486,30 @@ void EnMaYts_SetFaceExpression(EnMaYts* this, s16 overrideEyeTexIndex, s16 mouth } } -void EnMaYts_Update(Actor* thisx, GlobalContext* globalCtx) { +void EnMaYts_Update(Actor* thisx, PlayState* play) { EnMaYts* this = THIS; ColliderCylinder* collider; - this->actionFunc(this, globalCtx); + this->actionFunc(this, play); collider = &this->collider; Collider_UpdateCylinder(&this->actor, collider); - CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &collider->base); + CollisionCheck_SetOC(play, &play->colChkCtx, &collider->base); SkelAnime_Update(&this->skelAnime); EnMaYts_UpdateEyes(this); - func_80B8D12C(this, globalCtx); + func_80B8D12C(this, play); } -s32 EnMaYts_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, - Actor* thisx) { +s32 EnMaYts_OverrideLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, Actor* thisx) { EnMaYts* this = THIS; Vec3s sp4; - if (limbIndex == MA1_LIMB_HEAD) { + if (limbIndex == ROMANI_LIMB_HEAD) { sp4 = this->unk_1D8.unk_08; rot->x += sp4.y; - if ((this->skelAnime.animation == &object_ma1_Anim_009E58) || - (this->skelAnime.animation == &object_ma1_Anim_007D98)) { + if ((this->skelAnime.animation == &gRomaniIdleAnim) || (this->skelAnime.animation == &gRomaniSittingAnim)) { rot->z += sp4.x; } - } else if (limbIndex == MA1_LIMB_TORSO) { + } else if (limbIndex == ROMANI_LIMB_TORSO) { sp4 = this->unk_1D8.unk_0E; rot->x += sp4.y; rot->z += sp4.x; @@ -522,42 +518,42 @@ s32 EnMaYts_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dLis return false; } -void EnMaYts_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx) { +void EnMaYts_PostLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx) { EnMaYts* this = THIS; - if (limbIndex == MA1_LIMB_HEAD) { - Matrix_GetStateTranslation(&this->actor.focus.pos); - } else if (limbIndex == MA1_LIMB_HAND_LEFT) { + if (limbIndex == ROMANI_LIMB_HEAD) { + Matrix_MultZero(&this->actor.focus.pos); + } else if (limbIndex == ROMANI_LIMB_LEFT_HAND) { if (this->hasBow == true) { - OPEN_DISPS(globalCtx->state.gfxCtx); - gSPDisplayList(POLY_OPA_DISP++, object_ma1_DL_0003B0); - CLOSE_DISPS(globalCtx->state.gfxCtx); + OPEN_DISPS(play->state.gfxCtx); + gSPDisplayList(POLY_OPA_DISP++, gRomaniBowDL); + CLOSE_DISPS(play->state.gfxCtx); } } } -void EnMaYts_Draw(Actor* thisx, GlobalContext* globalCtx) { +void EnMaYts_Draw(Actor* thisx, PlayState* play) { EnMaYts* this = THIS; - OPEN_DISPS(globalCtx->state.gfxCtx); - func_8012C28C(globalCtx->state.gfxCtx); + OPEN_DISPS(play->state.gfxCtx); + func_8012C28C(play->state.gfxCtx); gSPSegment(POLY_OPA_DISP++, 0x09, SEGMENTED_TO_VIRTUAL(sMouthTextures[this->mouthTexIndex])); gSPSegment(POLY_OPA_DISP++, 0x08, SEGMENTED_TO_VIRTUAL(sEyeTextures[this->eyeTexIndex])); - SkelAnime_DrawFlexOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, + SkelAnime_DrawFlexOpa(play, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, EnMaYts_OverrideLimbDraw, EnMaYts_PostLimbDraw, &this->actor); - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->state.gfxCtx); } // Alternative draw function -void EnMaYts_DrawSleeping(Actor* thisx, GlobalContext* globalCtx) { - OPEN_DISPS(globalCtx->state.gfxCtx); - func_8012C28C(globalCtx->state.gfxCtx); +void EnMaYts_DrawSleeping(Actor* thisx, PlayState* play) { + OPEN_DISPS(play->state.gfxCtx); + func_8012C28C(play->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_ma1_DL_0043A0); + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_OPA_DISP++, gRomaniSleepingDL); - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->state.gfxCtx); } diff --git a/src/overlays/actors/ovl_En_Ma_Yts/z_en_ma_yts.h b/src/overlays/actors/ovl_En_Ma_Yts/z_en_ma_yts.h index 2fcc20509..e34ef3d0e 100644 --- a/src/overlays/actors/ovl_En_Ma_Yts/z_en_ma_yts.h +++ b/src/overlays/actors/ovl_En_Ma_Yts/z_en_ma_yts.h @@ -2,37 +2,11 @@ #define Z_EN_MA_YTS_H #include "global.h" +#include "objects/object_ma1/object_ma1.h" struct EnMaYts; -typedef void (*EnMaYtsActionFunc)(struct EnMaYts*, GlobalContext*); - -typedef enum { - /* 00 */ MA1_LIMB_NONE, - /* 01 */ MA1_LIMB_ROOT, - /* 02 */ MA1_LIMB_PELVIS, - /* 03 */ MA1_LIMB_TIGHT_LEFT, - /* 04 */ MA1_LIMB_LEG_LEFT, - /* 05 */ MA1_LIMB_FOOT_LEFT, - /* 06 */ MA1_LIMB_TIGHT_RIGHT, - /* 07 */ MA1_LIMB_LEG_RIGHT, - /* 08 */ MA1_LIMB_FOOT_RIGHT, - /* 09 */ MA1_LIMB_DRESS_0, - /* 00 */ MA1_LIMB_DRESS_1, - /* 11 */ MA1_LIMB_DRESS_2, - /* 12 */ MA1_LIMB_DRESS_3, - /* 13 */ MA1_LIMB_TORSO, - /* 14 */ MA1_LIMB_HEAD, - /* 15 */ MA1_LIMB_HAIR_TOP, - /* 16 */ MA1_LIMB_HAIR_BOTTOM, - /* 17 */ MA1_LIMB_ARM_LEFT, - /* 18 */ MA1_LIMB_FOREARM_LEFT, - /* 19 */ MA1_LIMB_HAND_LEFT, - /* 20 */ MA1_LIMB_ARM_RIGHT, - /* 21 */ MA1_LIMB_FOREARM_RIGHT, - /* 22 */ MA1_LIMB_HAND_RIGHT, - /* 23 */ MA1_LIMB_MAX -} ObjectMa1Limbs; +typedef void (*EnMaYtsActionFunc)(struct EnMaYts*, PlayState*); typedef struct EnMaYts { /* 0x000 */ Actor actor; @@ -41,17 +15,17 @@ typedef struct EnMaYts { /* 0x18C */ ColliderCylinder collider; /* 0x1D8 */ struct_800BD888_arg1 unk_1D8; /* 0x200 */ s32 unk_200; // Set, but not used - /* 0x204 */ Vec3s jointTable[MA1_LIMB_MAX]; - /* 0x28E */ char unk_28E[0x6]; - /* 0x294 */ Vec3s morphTable[MA1_LIMB_MAX]; - /* 0x31E */ char unk_31E[0x8]; + /* 0x204 */ Vec3s jointTable[ROMANI_LIMB_MAX]; + /* 0x28E */ UNK_TYPE1 unk_28E[0x6]; + /* 0x294 */ Vec3s morphTable[ROMANI_LIMB_MAX]; + /* 0x31E */ UNK_TYPE1 unk_31E[0x8]; /* 0x326 */ s16 blinkTimer; /* 0x328 */ s16 overrideEyeTexIndex; // If non-zero, then this index will be used instead of eyeTexIndex /* 0x32A */ s16 eyeTexIndex; /* 0x32C */ s16 unk_32C; // flag? /* 0x32E */ s16 mouthTexIndex; /* 0x330 */ s16 type; - /* 0x332 */ char unk_332[0x2]; + /* 0x332 */ UNK_TYPE1 unk_332[0x2]; /* 0x334 */ s16 endCreditsFlag; /* 0x336 */ s16 hasBow; /* 0x338 */ u16 textId; @@ -66,7 +40,7 @@ typedef enum { /* 3 */ MA_YTS_TYPE_ENDCREDITS } EnMaYtsType; -#define EN_MA_YTS_PARSE_TYPE(actor) ((((actor)->params)&0xF000) >> 12) +#define EN_MA_YTS_GET_TYPE(thisx) (((thisx)->params & 0xF000) >> 12) #define EN_MA_YTS_PARAM(enMaYtsType) ((enMaYtsType) << 12) /** 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 907ba619b..f71a25621 100644 --- a/src/overlays/actors/ovl_En_Mag/z_en_mag.c +++ b/src/overlays/actors/ovl_En_Mag/z_en_mag.c @@ -11,10 +11,10 @@ #define THIS ((EnMag*)thisx) -void EnMag_Init(Actor* thisx, GlobalContext* globalCtx); -void EnMag_Destroy(Actor* thisx, GlobalContext* globalCtx); -void EnMag_Update(Actor* thisx, GlobalContext* globalCtx); -void EnMag_Draw(Actor* thisx, GlobalContext* globalCtx); +void EnMag_Init(Actor* thisx, PlayState* play); +void EnMag_Destroy(Actor* thisx, PlayState* play); +void EnMag_Update(Actor* thisx, PlayState* play); +void EnMag_Draw(Actor* thisx, PlayState* play); /** * Steps `var` towards `target` linearly, so that it will arrive in `timeRemaining` seconds. Can be used from either @@ -97,7 +97,7 @@ const ActorInit En_Mag_InitVars = { (ActorFunc)EnMag_Draw, }; -void EnMag_Init(Actor* thisx, GlobalContext* globalCtx) { +void EnMag_Init(Actor* thisx, PlayState* play) { EnMag* this = THIS; u16 i; @@ -161,8 +161,8 @@ void EnMag_Init(Actor* thisx, GlobalContext* globalCtx) { gSaveContext.unk_3F1E = 0; this->state = MAG_STATE_FADE_IN_MASK; sInputDelayTimer = 20; - gSaveContext.fadeDuration = 1; - gSaveContext.fadeSpeed = 255; + gSaveContext.transFadeDuration = 1; + gSaveContext.transWipeSpeed = 255; } Font_LoadOrderedFont(&this->font); @@ -184,7 +184,7 @@ void EnMag_Init(Actor* thisx, GlobalContext* globalCtx) { sZeldaEffectColorTargetIndex = 0; } -void EnMag_Destroy(Actor* thisx, GlobalContext* globalCtx) { +void EnMag_Destroy(Actor* thisx, PlayState* play) { } void EnMag_UpdateDisplayEffectColors(Actor* thisx) { @@ -225,7 +225,7 @@ void EnMag_UpdateDisplayEffectColors(Actor* thisx) { * Controls the actions performed using a switch and the `state` struct variable rather than action functions. Most of * these are to do with fading various parts in and out. */ -void EnMag_Update(Actor* thisx, GlobalContext* globalCtx) { +void EnMag_Update(Actor* thisx, PlayState* play) { static s16 sAppearEffectPrimGreenTargets[] = { 255, 155 }; static s16 sAppearEffectEnvRedTargets[] = { 255, 0 }; static s16 sAppearEffectEnvBlueTargets[] = { 0, 155 }; @@ -235,18 +235,18 @@ 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(&play->state)->press.button, BTN_START) || + CHECK_BTN_ALL(CONTROLLER1(&play->state)->press.button, BTN_A) || + CHECK_BTN_ALL(CONTROLLER1(&play->state)->press.button, BTN_B)) { - if (!EnvFlags_Get(globalCtx, 4)) { + if (!EnvFlags_Get(play, 4)) { play_sound(NA_SE_SY_PIECE_OF_HEART); this->state = MAG_STATE_CALLED; this->unk11F00 = 0; this->unk11F02 = 30; sInputDelayTimer = 20; - gSaveContext.fadeDuration = 1; - gSaveContext.fadeSpeed = 255; + gSaveContext.transFadeDuration = 1; + gSaveContext.transWipeSpeed = 255; } } } else { @@ -378,10 +378,10 @@ 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 (globalCtx->sceneLoadFlag != 0x14) { + if (CHECK_BTN_ALL(CONTROLLER1(&play->state)->press.button, BTN_START) || + CHECK_BTN_ALL(CONTROLLER1(&play->state)->press.button, BTN_A) || + CHECK_BTN_ALL(CONTROLLER1(&play->state)->press.button, BTN_B)) { + if (play->transitionTrigger != TRANS_TRIGGER_START) { Audio_SetCutsceneFlag(false); D_801BB12C++; if (D_801BB12C >= 2) { @@ -389,9 +389,9 @@ void EnMag_Update(Actor* thisx, GlobalContext* globalCtx) { } play_sound(NA_SE_SY_PIECE_OF_HEART); gSaveContext.gameMode = 2; // Go to FileChoose - globalCtx->sceneLoadFlag = 0x14; - globalCtx->unk_1887F = 2; - globalCtx->nextEntranceIndex = 0x1C00; + play->transitionTrigger = TRANS_TRIGGER_START; + play->transitionType = TRANS_TYPE_02; + play->nextEntrance = ENTRANCE(CUTSCENE, 0); gSaveContext.save.cutscene = 0; gSaveContext.sceneSetupIndex = 0; } @@ -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(&play->state)->press.button, BTN_START) || + CHECK_BTN_ALL(CONTROLLER1(&play->state)->press.button, BTN_A) || + CHECK_BTN_ALL(CONTROLLER1(&play->state)->press.button, BTN_B)) { play_sound(NA_SE_SY_PIECE_OF_HEART); this->state = MAG_STATE_CALLED; } @@ -438,12 +438,12 @@ void EnMag_Update(Actor* thisx, GlobalContext* globalCtx) { } if (this->state == MAG_STATE_INITIAL) { - if (EnvFlags_Get(globalCtx, 3)) { + if (EnvFlags_Get(play, 3)) { this->unk11F02 = 40; this->state = MAG_STATE_FADE_IN_MASK_EFFECTS; } } else if (this->state < MAG_STATE_FADE_OUT) { - if (EnvFlags_Get(globalCtx, 4)) { + if (EnvFlags_Get(play, 4)) { this->state = MAG_STATE_FADE_OUT; } } @@ -675,7 +675,7 @@ void EnMag_DrawCharTexture(Gfx** gfxp, TexturePtr texture, s32 rectLeft, s32 rec * Loads title, PRESS START text, etc. graphics to gfxp, which is made to live on * POLY_OPA_DISP, but is used by OVERLAY_DISP. */ -void EnMag_DrawInner(Actor* thisx, GlobalContext* globalCtx, Gfx** gfxp) { +void EnMag_DrawInner(Actor* thisx, PlayState* play, Gfx** gfxp) { static u8 pressStartFontIndices[] = { 0x19, 0x1B, 0x0E, 0x1C, 0x1C, 0x1C, 0x1D, 0x0A, 0x1B, 0x1D, }; // Indices into this->font.fontBuf @@ -707,7 +707,7 @@ void EnMag_DrawInner(Actor* thisx, GlobalContext* globalCtx, Gfx** gfxp) { s16 step; // Set segment 6 to the object, since this will be read by OVERLAY_DISP where it is not set by default. - gSPSegment(gfx++, 0x06, globalCtx->objectCtx.status[this->actor.objBankIndex].segment); + gSPSegment(gfx++, 0x06, play->objectCtx.status[this->actor.objBankIndex].segment); func_8012C680(&gfx); @@ -953,22 +953,22 @@ void EnMag_DrawInner(Actor* thisx, GlobalContext* globalCtx, Gfx** gfxp) { * Jumps drawing to POLY_OPA_DISP to take advantage of the extra space available, but jmups back and actually draws * using OVERLAY_DISP. */ -void EnMag_Draw(Actor* thisx, GlobalContext* globalCtx) { +void EnMag_Draw(Actor* thisx, PlayState* play) { s32 pad; Gfx* gfx; Gfx* gfxRef; - OPEN_DISPS(globalCtx->state.gfxCtx); + OPEN_DISPS(play->state.gfxCtx); gfxRef = POLY_OPA_DISP; gfx = Graph_GfxPlusOne(gfxRef); gSPDisplayList(OVERLAY_DISP++, gfx); - EnMag_DrawInner(thisx, globalCtx, &gfx); + EnMag_DrawInner(thisx, play, &gfx); gSPEndDisplayList(gfx++); Graph_BranchDlist(gfxRef, gfx); POLY_OPA_DISP = gfx; - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->state.gfxCtx); } diff --git a/src/overlays/actors/ovl_En_Mag/z_en_mag.h b/src/overlays/actors/ovl_En_Mag/z_en_mag.h index c116ae98d..d55d63ccb 100644 --- a/src/overlays/actors/ovl_En_Mag/z_en_mag.h +++ b/src/overlays/actors/ovl_En_Mag/z_en_mag.h @@ -9,7 +9,6 @@ typedef struct EnMag { /* 0x00000 */ Actor actor; /* 0x00144 */ UNK_TYPE1 unk144[0x2C]; /* 0x00170 */ Font font; - /* 0x11EFC */ UNK_TYPE1 unk11EFC[4]; /* 0x11F00 */ s16 unk11F00; // Set and not used. /* 0x11F02 */ s16 unk11F02; // Set and not used. /* 0x11F04 */ s16 state; // State of whole actor, uses EnMagState enum diff --git a/src/overlays/actors/ovl_En_Maruta/z_en_maruta.c b/src/overlays/actors/ovl_En_Maruta/z_en_maruta.c index 9d6f6312e..4c7a1ddf8 100644 --- a/src/overlays/actors/ovl_En_Maruta/z_en_maruta.c +++ b/src/overlays/actors/ovl_En_Maruta/z_en_maruta.c @@ -12,29 +12,29 @@ #define THIS ((EnMaruta*)thisx) -void EnMaruta_Init(Actor* thisx, GlobalContext* globalCtx); -void EnMaruta_Destroy(Actor* thisx, GlobalContext* globalCtx); -void EnMaruta_Update(Actor* thisx, GlobalContext* globalCtx); -void EnMaruta_Draw(Actor* thisx, GlobalContext* globalCtx); +void EnMaruta_Init(Actor* thisx, PlayState* play); +void EnMaruta_Destroy(Actor* thisx, PlayState* play); +void EnMaruta_Update(Actor* thisx, PlayState* play); +void EnMaruta_Draw(Actor* thisx, PlayState* play); void func_80B372B8(EnMaruta* this); -void func_80B372CC(EnMaruta* this, GlobalContext* globalCtx); +void func_80B372CC(EnMaruta* this, PlayState* play); void func_80B37364(EnMaruta* this); -void func_80B3738C(EnMaruta* this, GlobalContext* globalCtx); +void func_80B3738C(EnMaruta* this, PlayState* play); 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_80B37428(EnMaruta* this, PlayState* play); +void func_80B374FC(EnMaruta* this, PlayState* play); +void func_80B37590(EnMaruta* this, PlayState* play); +void func_80B37950(EnMaruta* this, PlayState* play); +void func_80B379C0(EnMaruta* this, PlayState* play); void func_80B37A14(EnMaruta* this); -void func_80B37A64(EnMaruta* this, GlobalContext* globalCtx); -void func_80B37AA0(EnMaruta* this, GlobalContext* globalCtx); +void func_80B37A64(EnMaruta* this, PlayState* play); +void func_80B37AA0(EnMaruta* this, PlayState* play); void func_80B37C04(s16* arg0); -void func_80B37EC0(EnMaruta* this, GlobalContext* globalCtx); +void func_80B37EC0(EnMaruta* this, PlayState* play); 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); +void func_80B382E4(PlayState* play, Vec3f arg1); const ActorInit En_Maruta_InitVars = { ACTOR_EN_MARUTA, @@ -58,7 +58,40 @@ u8 D_80B386C0[] = { }; s32 D_80B386CC[] = { - 5, 5, 3, 3, 7, 7, 7, 7, 3, 3, 3, 3, 7, 7, 3, 3, 0, 0, 0, 0, 5, 0, 0, 0, 0, 0, 0, 0, 0, 0, 7, 7, 7, 7, + 5, // PLAYER_MWA_FORWARD_SLASH_1H + 5, // PLAYER_MWA_FORWARD_SLASH_2H + 3, // PLAYER_MWA_FORWARD_COMBO_1H + 3, // PLAYER_MWA_FORWARD_COMBO_2H + 7, // PLAYER_MWA_RIGHT_SLASH_1H + 7, // PLAYER_MWA_RIGHT_SLASH_2H + 7, // PLAYER_MWA_RIGHT_COMBO_1H + 7, // PLAYER_MWA_RIGHT_COMBO_2H + 3, // PLAYER_MWA_LEFT_SLASH_1H + 3, // PLAYER_MWA_LEFT_SLASH_2H + 3, // PLAYER_MWA_LEFT_COMBO_1H + 3, // PLAYER_MWA_LEFT_COMBO_2H + 7, // PLAYER_MWA_STAB_1H + 7, // PLAYER_MWA_STAB_2H + 3, // PLAYER_MWA_STAB_COMBO_1H + 3, // PLAYER_MWA_STAB_COMBO_2H + 0, // PLAYER_MWA_FLIPSLASH_START + 0, // PLAYER_MWA_JUMPSLASH_START + 0, // PLAYER_MWA_ZORA_JUMPKICK_START + 0, // PLAYER_MWA_FLIPSLASH_FINISH + 5, // PLAYER_MWA_JUMPSLASH_FINISH + 0, // PLAYER_MWA_ZORA_JUMPKICK_FINISH + 0, // PLAYER_MWA_BACKSLASH_RIGHT + 0, // PLAYER_MWA_BACKSLASH_LEFT + 0, // PLAYER_MWA_GORON_PUNCH_LEFT + 0, // PLAYER_MWA_GORON_PUNCH_RIGHT + 0, // PLAYER_MWA_GORON_PUNCH_BUTT + 0, // PLAYER_MWA_ZORA_PUNCH_LEFT + 0, // PLAYER_MWA_ZORA_PUNCH_COMBO + 0, // PLAYER_MWA_ZORA_PUNCH_KICK + 7, // PLAYER_MWA_SPIN_ATTACK_1H + 7, // PLAYER_MWA_SPIN_ATTACK_2H + 7, // PLAYER_MWA_BIG_SPIN_1H + 7 // PLAYER_MWA_BIG_SPIN_2H }; Vec3f D_80B38754 = { -2.0f, 3.0f, 0.0f }; @@ -174,7 +207,7 @@ static CollisionCheckInfoInit2 sColChkInfoInit = { 8, 0, 0, 0, MASS_HEAVY }; Vec3f D_80B38B54 = { 0.0f, 0.0f, 0.0f }; -void EnMaruta_Init(Actor* thisx, GlobalContext* globalCtx) { +void EnMaruta_Init(Actor* thisx, PlayState* play) { s32 pad; EnMaruta* this = THIS; s32 i; @@ -208,8 +241,8 @@ void EnMaruta_Init(Actor* thisx, GlobalContext* globalCtx) { this->unk_220 = 0; if (this->unk_210 == 0) { - Collider_InitCylinder(globalCtx, &this->collider); - Collider_SetCylinder(globalCtx, &this->collider, &this->actor, &sCylinderInit); + Collider_InitCylinder(play, &this->collider); + Collider_SetCylinder(play, &this->collider, &this->actor, &sCylinderInit); CollisionCheck_SetInfo2(&this->actor.colChkInfo, &sDamageTable, &sColChkInfoInit); } @@ -220,15 +253,15 @@ void EnMaruta_Init(Actor* thisx, GlobalContext* globalCtx) { func_80B37364(this); } } else { - func_80B37590(this, globalCtx); + func_80B37590(this, play); } } -void EnMaruta_Destroy(Actor* thisx, GlobalContext* globalCtx) { +void EnMaruta_Destroy(Actor* thisx, PlayState* play) { EnMaruta* this = THIS; if (this->unk_210 == 0) { - Collider_DestroyCylinder(globalCtx, &this->collider); + Collider_DestroyCylinder(play, &this->collider); } } @@ -236,7 +269,7 @@ void func_80B372B8(EnMaruta* this) { this->actionFunc = func_80B372CC; } -void func_80B372CC(EnMaruta* this, GlobalContext* globalCtx) { +void func_80B372CC(EnMaruta* this, PlayState* play) { s16 temp_v1 = BINANG_SUB(this->actor.yawTowardsPlayer, this->actor.shape.rot.y); if (temp_v1 > 0x1555) { @@ -261,7 +294,7 @@ void func_80B37364(EnMaruta* this) { this->actionFunc = func_80B3738C; } -void func_80B3738C(EnMaruta* this, GlobalContext* globalCtx) { +void func_80B3738C(EnMaruta* this, PlayState* play) { if (Math_SmoothStepToF(&this->actor.world.pos.y, this->actor.home.pos.y, 0.4f, 100.0f, 10.0f) == 0.0f) { func_80B372B8(this); } @@ -274,7 +307,7 @@ void func_80B373F4(EnMaruta* this) { this->actionFunc = func_80B37428; } -void func_80B37428(EnMaruta* this, GlobalContext* globalCtx) { +void func_80B37428(EnMaruta* this, PlayState* play) { 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; @@ -297,7 +330,7 @@ void func_80B374B8(EnMaruta* this) { } } -void func_80B374FC(EnMaruta* this, GlobalContext* globalCtx) { +void func_80B374FC(EnMaruta* this, PlayState* play) { if (this->unk_21E == 40) { Actor_MarkForDeath(&this->actor); return; @@ -311,8 +344,8 @@ void func_80B374FC(EnMaruta* this, GlobalContext* globalCtx) { this->unk_21E++; } -void func_80B37590(EnMaruta* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); +void func_80B37590(EnMaruta* this, PlayState* play) { + Player* player = GET_PLAYER(play); Vec3f sp48; s16 sp46; Vec3f sp38; @@ -328,7 +361,7 @@ void func_80B37590(EnMaruta* this, GlobalContext* globalCtx) { break; case 4: - if (player->swordAnimation == 8) { + if (player->meleeWeaponAnimation == PLAYER_MWA_LEFT_SLASH_1H) { sp48 = D_80B3876C; } else { sp48 = D_80B38778; @@ -337,7 +370,7 @@ void func_80B37590(EnMaruta* this, GlobalContext* globalCtx) { break; case 5: - if (player->swordAnimation == 0) { + if (player->meleeWeaponAnimation == PLAYER_MWA_FORWARD_SLASH_1H) { sp48 = D_80B38784; } else { sp48 = D_80B38790; @@ -346,7 +379,7 @@ void func_80B37590(EnMaruta* this, GlobalContext* globalCtx) { break; case 6: - if (player->swordAnimation == 0) { + if (player->meleeWeaponAnimation == PLAYER_MWA_FORWARD_SLASH_1H) { sp48 = D_80B3879C; } else { sp48 = D_80B387A8; @@ -355,7 +388,7 @@ void func_80B37590(EnMaruta* this, GlobalContext* globalCtx) { break; case 8: - if (player->swordAnimation == 4) { + if (player->meleeWeaponAnimation == PLAYER_MWA_RIGHT_SLASH_1H) { sp48 = D_80B387B4; } else { sp48 = D_80B387C0; @@ -393,10 +426,10 @@ void func_80B37590(EnMaruta* this, GlobalContext* globalCtx) { this->actionFunc = func_80B37950; } -void func_80B37950(EnMaruta* this, GlobalContext* globalCtx) { +void func_80B37950(EnMaruta* this, PlayState* play) { this->unk_218 += this->unk_21A; this->actor.velocity.y += this->actor.gravity; - func_80B37EC0(this, globalCtx); + func_80B37EC0(this, play); Actor_UpdatePos(&this->actor); } @@ -408,7 +441,7 @@ void func_80B37998(EnMaruta* this) { this->actionFunc = func_80B379C0; } -void func_80B379C0(EnMaruta* this, GlobalContext* globalCtx) { +void func_80B379C0(EnMaruta* this, PlayState* play) { if (this->unk_21E == 40) { func_80B37A14(this); } else { @@ -428,7 +461,7 @@ void func_80B37A14(EnMaruta* this) { this->actionFunc = func_80B37A64; } -void func_80B37A64(EnMaruta* this, GlobalContext* globalCtx) { +void func_80B37A64(EnMaruta* this, PlayState* play) { if (this->unk_21E > 100) { this->actor.colChkInfo.health = 0; } else { @@ -440,7 +473,7 @@ void func_80B37A8C(EnMaruta* this) { this->actionFunc = func_80B37AA0; } -void func_80B37AA0(EnMaruta* this, GlobalContext* globalCtx) { +void func_80B37AA0(EnMaruta* this, PlayState* play) { if (this->actor.scale.y == 0.0f) { if (this->actor.scale.x == 0.0f) { Actor_MarkForDeath(&this->actor); @@ -453,14 +486,16 @@ void func_80B37AA0(EnMaruta* this, GlobalContext* globalCtx) { } } -s32 func_80B37B78(EnMaruta* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); +s32 func_80B37B78(EnMaruta* this, PlayState* play) { + Player* player = GET_PLAYER(play); 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)))) { + ((player->meleeWeaponState != 0) && ((player->meleeWeaponAnimation == PLAYER_MWA_RIGHT_SLASH_1H) || + (player->meleeWeaponAnimation == PLAYER_MWA_RIGHT_COMBO_1H) || + (player->meleeWeaponAnimation == PLAYER_MWA_SPIN_ATTACK_1H) || + (player->meleeWeaponAnimation == PLAYER_MWA_BIG_SPIN_1H)))) { return true; } return false; @@ -482,8 +517,8 @@ void func_80B37C60(EnMaruta* this) { } } -void func_80B37CA0(EnMaruta* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); +void func_80B37CA0(EnMaruta* this, PlayState* play) { + Player* player = GET_PLAYER(play); if ((this->actionFunc == func_80B372CC) || (this->actionFunc == func_80B3738C) || (this->actionFunc == func_80B374FC) || (this->actionFunc == func_80B37AA0) || @@ -492,17 +527,18 @@ void func_80B37CA0(EnMaruta* this, GlobalContext* globalCtx) { this->collider.base.acFlags &= ~AC_HIT; Actor_PlaySfxAtPos(&this->actor, NA_SE_IT_SWORD_STRIKE); - if (D_80B386CC[player->swordAnimation] != 0) { - s32 temp = D_80B386CC[player->swordAnimation] + 1; + if (D_80B386CC[player->meleeWeaponAnimation] != 0) { + s32 temp = D_80B386CC[player->meleeWeaponAnimation] + 1; temp = (temp << 8) & 0xFF00; - this->unk_210 = D_80B386CC[player->swordAnimation]; - 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->unk_210 = D_80B386CC[player->meleeWeaponAnimation]; + Actor_SpawnAsChild(&play->actorCtx, &this->actor, play, ACTOR_EN_MARUTA, this->actor.world.pos.x, + this->actor.world.pos.y, this->actor.world.pos.z, 0, this->actor.shape.rot.y, 0, + temp); this->actor.world.rot.y = this->actor.shape.rot.y; - if ((this->unk_210 == 5) || ((this->unk_210 == 7) && (player->swordAnimation == 0xC))) { - func_80B37590(this, globalCtx); + if ((this->unk_210 == 5) || + ((this->unk_210 == 7) && (player->meleeWeaponAnimation == PLAYER_MWA_STAB_1H))) { + func_80B37590(this, play); } else { func_80B374B8(this); } @@ -518,15 +554,15 @@ void func_80B37CA0(EnMaruta* this, GlobalContext* globalCtx) { } Collider_UpdateCylinder(&this->actor, &this->collider); - CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + CollisionCheck_SetOC(play, &play->colChkCtx, &this->collider.base); - if (func_80B37B78(this, globalCtx) && (this->actionFunc == func_80B372CC)) { - CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + if (func_80B37B78(this, play) && (this->actionFunc == func_80B372CC)) { + CollisionCheck_SetAC(play, &play->colChkCtx, &this->collider.base); } } } -void func_80B37EC0(EnMaruta* this, GlobalContext* globalCtx) { +void func_80B37EC0(EnMaruta* this, PlayState* play) { Vec3f sp34 = this->unk_204; s32 phi_a2 = -1; s32 i; @@ -550,7 +586,7 @@ void func_80B37EC0(EnMaruta* this, GlobalContext* globalCtx) { this->actor.world.pos.y += temp; if (this->actor.velocity.y < -this->actor.gravity) { - func_80B382E4(globalCtx, sp34); + func_80B382E4(play, sp34); Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_LOG_BOUND); this->actor.velocity.y *= -0.6f; func_80B38060(this, &sp34); @@ -621,13 +657,13 @@ void func_80B38060(EnMaruta* this, Vec3f* arg1) { } void func_80B3828C(Vec3f* arg0, Vec3f* arg1, s16 arg2, s16 arg3, s32 arg4) { - Matrix_StatePush(); - Matrix_InsertRotation(arg2, arg3, arg4, MTXMODE_NEW); - Matrix_MultiplyVector3fByState(arg0, arg1); - Matrix_StatePop(); + Matrix_Push(); + Matrix_RotateZYX(arg2, arg3, arg4, MTXMODE_NEW); + Matrix_MultVec3f(arg0, arg1); + Matrix_Pop(); } -void func_80B382E4(GlobalContext* globalCtx, Vec3f arg1) { +void func_80B382E4(PlayState* play, Vec3f arg1) { Vec3f sp84 = arg1; Vec3f sp78; Vec3f sp6C; @@ -644,40 +680,40 @@ void func_80B382E4(GlobalContext* globalCtx, Vec3f arg1) { 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); + func_800B0EB0(play, &sp84, &sp78, &sp6C, &sp68, &sp64, 60, 20, 10); } } -void EnMaruta_Update(Actor* thisx, GlobalContext* globalCtx) { +void EnMaruta_Update(Actor* thisx, PlayState* play) { EnMaruta* this = THIS; - this->actionFunc(this, globalCtx); + this->actionFunc(this, play); - func_80B37CA0(this, globalCtx); + func_80B37CA0(this, play); func_80B37C60(this); } -void EnMaruta_Draw(Actor* thisx, GlobalContext* globalCtx) { +void EnMaruta_Draw(Actor* thisx, PlayState* play) { EnMaruta* this = THIS; Vec3f sp50; s32 i; - OPEN_DISPS(globalCtx->state.gfxCtx); + OPEN_DISPS(play->state.gfxCtx); - func_8012C28C(globalCtx->state.gfxCtx); + func_8012C28C(play->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); + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_OPA_DISP++, object_maruta_DL_002EC0); } else { sp50 = D_80B387E4[this->unk_210]; - Matrix_StatePush(); - Matrix_InsertTranslation(sp50.x, sp50.y, sp50.z, MTXMODE_APPLY); - Matrix_InsertRotationAroundUnitVector_s(this->unk_218, &this->unk_194, MTXMODE_APPLY); - Matrix_InsertTranslation(-sp50.x, -sp50.y, -sp50.z, MTXMODE_APPLY); + 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); + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(play->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)) { @@ -687,13 +723,13 @@ void EnMaruta_Draw(Actor* thisx, GlobalContext* globalCtx) { if (this->unk_1A0 != NULL) { for (i = 0; i < ARRAY_COUNT(this->unk_1A4); i++) { - Matrix_MultiplyVector3fByState(&this->unk_1A0[i], &this->unk_1A4[i]); + Matrix_MultVec3f(&this->unk_1A0[i], &this->unk_1A4[i]); } - Matrix_MultiplyVector3fByState(&sp50, &this->unk_204); + Matrix_MultVec3f(&sp50, &this->unk_204); } - Matrix_StatePop(); + Matrix_Pop(); } - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->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 162618fc6..1af506c58 100644 --- a/src/overlays/actors/ovl_En_Maruta/z_en_maruta.h +++ b/src/overlays/actors/ovl_En_Maruta/z_en_maruta.h @@ -5,26 +5,26 @@ struct EnMaruta; -typedef void (*EnMarutaActionFunc)(struct EnMaruta*, GlobalContext*); +typedef void (*EnMarutaActionFunc)(struct EnMaruta*, PlayState*); #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 */ ColliderCylinder collider; - /* 0x0194 */ Vec3f unk_194; - /* 0x01A0 */ Vec3f* unk_1A0; - /* 0x01A4 */ Vec3f unk_1A4[8]; - /* 0x0204 */ Vec3f unk_204; - /* 0x0210 */ s32 unk_210; - /* 0x0214 */ s32 unk_214; - /* 0x0218 */ s16 unk_218; - /* 0x021A */ s16 unk_21A; - /* 0x021C */ s16 unk_21C; - /* 0x021E */ s16 unk_21E; - /* 0x0220 */ s16 unk_220; + /* 0x000 */ Actor actor; + /* 0x144 */ EnMarutaActionFunc actionFunc; + /* 0x148 */ ColliderCylinder collider; + /* 0x194 */ Vec3f unk_194; + /* 0x1A0 */ Vec3f* unk_1A0; + /* 0x1A4 */ Vec3f unk_1A4[8]; + /* 0x204 */ Vec3f unk_204; + /* 0x210 */ s32 unk_210; + /* 0x214 */ s32 unk_214; + /* 0x218 */ s16 unk_218; + /* 0x21A */ s16 unk_21A; + /* 0x21C */ s16 unk_21C; + /* 0x21E */ s16 unk_21E; + /* 0x220 */ s16 unk_220; } EnMaruta; // size = 0x224 extern const ActorInit En_Maruta_InitVars; diff --git a/src/overlays/actors/ovl_En_Minideath/z_en_minideath.c b/src/overlays/actors/ovl_En_Minideath/z_en_minideath.c index d5e15c04d..fd0001166 100644 --- a/src/overlays/actors/ovl_En_Minideath/z_en_minideath.c +++ b/src/overlays/actors/ovl_En_Minideath/z_en_minideath.c @@ -10,23 +10,23 @@ #define THIS ((EnMinideath*)thisx) -void EnMinideath_Init(Actor* thisx, GlobalContext* globalCtx); -void EnMinideath_Destroy(Actor* thisx, GlobalContext* globalCtx); -void EnMinideath_Update(Actor* thisx, GlobalContext* globalCtx); +void EnMinideath_Init(Actor* thisx, PlayState* play); +void EnMinideath_Destroy(Actor* thisx, PlayState* play); +void EnMinideath_Update(Actor* thisx, PlayState* play); -void func_808CA860(EnMinideath* this, GlobalContext* globalCtx); -void func_808CA8F4(EnMinideath* this, GlobalContext* globalCtx); -void func_808CAAEC(EnMinideath* this, GlobalContext* globalCtx); -void func_808CABB0(EnMinideath* this, GlobalContext* globalCtx); -void func_808CACD8(EnMinideath* this, GlobalContext* globalCtx); -void func_808CAE18(EnMinideath* this, GlobalContext* globalCtx); -void func_808CAF68(EnMinideath* this, GlobalContext* globalCtx); -void func_808CB094(EnMinideath* this, GlobalContext* globalCtx); -void func_808CB22C(EnMinideath* this, GlobalContext* globalCtx); -void func_808CB454(EnMinideath* this, GlobalContext* globalCtx); -void func_808CB59C(EnMinideath* this, GlobalContext* globalCtx); -void func_808CB6D4(EnMinideath* this, GlobalContext* globalCtx); -void func_808CB7CC(EnMinideath* this, GlobalContext* globalCtx); +void func_808CA860(EnMinideath* this, PlayState* play); +void func_808CA8F4(EnMinideath* this, PlayState* play); +void func_808CAAEC(EnMinideath* this, PlayState* play); +void func_808CABB0(EnMinideath* this, PlayState* play); +void func_808CACD8(EnMinideath* this, PlayState* play); +void func_808CAE18(EnMinideath* this, PlayState* play); +void func_808CAF68(EnMinideath* this, PlayState* play); +void func_808CB094(EnMinideath* this, PlayState* play); +void func_808CB22C(EnMinideath* this, PlayState* play); +void func_808CB454(EnMinideath* this, PlayState* play); +void func_808CB59C(EnMinideath* this, PlayState* play); +void func_808CB6D4(EnMinideath* this, PlayState* play); +void func_808CB7CC(EnMinideath* this, PlayState* play); #if 0 const ActorInit En_Minideath_InitVars = { @@ -60,7 +60,7 @@ static ColliderJntSphElementInit D_808CBF50[3] = { // static ColliderJntSphInit sJntSphInit = { static ColliderJntSphInit D_808CBFBC = { { COLTYPE_NONE, AT_NONE | AT_TYPE_ENEMY, AC_ON | AC_TYPE_PLAYER, OC1_NONE | OC1_TYPE_ALL, OC2_TYPE_1, COLSHAPE_JNTSPH, }, - 3, D_808CBF50, // sJntSphElementsInit, + ARRAY_COUNT(sJntSphElementsInit), D_808CBF50, // sJntSphElementsInit, }; // static DamageTable sDamageTable = { diff --git a/src/overlays/actors/ovl_En_Minideath/z_en_minideath.h b/src/overlays/actors/ovl_En_Minideath/z_en_minideath.h index 7ac4dee6c..427bafa1e 100644 --- a/src/overlays/actors/ovl_En_Minideath/z_en_minideath.h +++ b/src/overlays/actors/ovl_En_Minideath/z_en_minideath.h @@ -5,12 +5,12 @@ struct EnMinideath; -typedef void (*EnMinideathActionFunc)(struct EnMinideath*, GlobalContext*); +typedef void (*EnMinideathActionFunc)(struct EnMinideath*, PlayState*); typedef struct EnMinideath { - /* 0x0000 */ Actor actor; - /* 0x0144 */ EnMinideathActionFunc actionFunc; - /* 0x0148 */ char unk_148[0x164]; + /* 0x000 */ Actor actor; + /* 0x144 */ EnMinideathActionFunc actionFunc; + /* 0x148 */ char unk_148[0x164]; } EnMinideath; // size = 0x2AC extern const ActorInit En_Minideath_InitVars; diff --git a/src/overlays/actors/ovl_En_Minifrog/z_en_minifrog.c b/src/overlays/actors/ovl_En_Minifrog/z_en_minifrog.c index 27192800e..1e92e1f77 100644 --- a/src/overlays/actors/ovl_En_Minifrog/z_en_minifrog.c +++ b/src/overlays/actors/ovl_En_Minifrog/z_en_minifrog.c @@ -12,19 +12,19 @@ #define THIS ((EnMinifrog*)thisx) -void EnMinifrog_Init(Actor* thisx, GlobalContext* globalCtx); -void EnMinifrog_Destroy(Actor* thisx, GlobalContext* globalCtx); -void EnMinifrog_Update(Actor* thisx, GlobalContext* globalCtx); -void EnMinifrog_Draw(Actor* thisx, GlobalContext* globalCtx); +void EnMinifrog_Init(Actor* thisx, PlayState* play); +void EnMinifrog_Destroy(Actor* thisx, PlayState* play); +void EnMinifrog_Update(Actor* thisx, PlayState* play); +void EnMinifrog_Draw(Actor* thisx, PlayState* play); -EnMinifrog* EnMinifrog_GetFrog(GlobalContext* globalCtx); +EnMinifrog* EnMinifrog_GetFrog(PlayState* play); -void EnMinifrog_SpawnGrowAndShrink(EnMinifrog* this, GlobalContext* globalCtx); -void EnMinifrog_Idle(EnMinifrog* this, GlobalContext* globalCtx); -void EnMinifrog_SetupNextFrogInit(EnMinifrog* this, GlobalContext* globalCtx); -void EnMinifrog_UpdateMissingFrog(Actor* thisx, GlobalContext* globalCtx); -void EnMinifrog_YellowFrogDialog(EnMinifrog* this, GlobalContext* globalCtx); -void EnMinifrog_SetupYellowFrogDialog(EnMinifrog* this, GlobalContext* globalCtx); +void EnMinifrog_SpawnGrowAndShrink(EnMinifrog* this, PlayState* play); +void EnMinifrog_Idle(EnMinifrog* this, PlayState* play); +void EnMinifrog_SetupNextFrogInit(EnMinifrog* this, PlayState* play); +void EnMinifrog_UpdateMissingFrog(Actor* thisx, PlayState* play); +void EnMinifrog_YellowFrogDialog(EnMinifrog* this, PlayState* play); +void EnMinifrog_SetupYellowFrogDialog(EnMinifrog* this, PlayState* play); const ActorInit En_Minifrog_InitVars = { ACTOR_EN_MINIFROG, @@ -82,16 +82,16 @@ static InitChainEntry sInitChain[] = { ICHAIN_F32_DIV1000(gravity, -800, ICHAIN_STOP), }; -void EnMinifrog_Init(Actor* thisx, GlobalContext* globalCtx) { +void EnMinifrog_Init(Actor* thisx, PlayState* play) { EnMinifrog* this = THIS; int i; Actor_ProcessInitChain(&this->actor, sInitChain); ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 15.0f); - SkelAnime_InitFlex(globalCtx, &this->skelAnime, &object_fr_Skel_00B538, &object_fr_Anim_001534, this->jointTable, + SkelAnime_InitFlex(play, &this->skelAnime, &object_fr_Skel_00B538, &object_fr_Anim_001534, this->jointTable, this->morphTable, 24); CollisionCheck_SetInfo(&this->actor.colChkInfo, NULL, &sColChkInfoInit); - Collider_InitAndSetCylinder(globalCtx, &this->collider, &this->actor, &sCylinderInit); + Collider_InitAndSetCylinder(play, &this->collider, &this->actor, &sCylinderInit); if (!isInitialized) { for (i = 0; i < 2; i++) { @@ -112,7 +112,7 @@ void EnMinifrog_Init(Actor* thisx, GlobalContext* globalCtx) { this->timer = 0; if (1) {} - if (!EN_MINIFROG_IS_RETURNED(this)) { + if (!EN_MINIFROG_IS_RETURNED(&this->actor)) { if ((this->frogIndex == MINIFROG_YELLOW) || ((gSaveContext.save.weekEventReg[isFrogReturnedFlags[this->frogIndex] >> 8] & (u8)isFrogReturnedFlags[this->frogIndex]))) { @@ -136,7 +136,7 @@ void EnMinifrog_Init(Actor* thisx, GlobalContext* globalCtx) { this->actor.home.rot.x = this->actor.home.rot.z = 0; this->frog = NULL; } else { - this->frog = EnMinifrog_GetFrog(globalCtx); + this->frog = EnMinifrog_GetFrog(play); this->actor.flags &= ~ACTOR_FLAG_1; // Frog has been returned @@ -151,17 +151,17 @@ void EnMinifrog_Init(Actor* thisx, GlobalContext* globalCtx) { } } -void EnMinifrog_Destroy(Actor* thisx, GlobalContext* globalCtx) { +void EnMinifrog_Destroy(Actor* thisx, PlayState* play) { EnMinifrog* this = THIS; - Collider_DestroyCylinder(globalCtx, &this->collider); + Collider_DestroyCylinder(play, &this->collider); if (this->flags & 0x100) { func_801A1F88(); } } -EnMinifrog* EnMinifrog_GetFrog(GlobalContext* globalCtx) { - EnMinifrog* frog = (EnMinifrog*)globalCtx->actorCtx.actorLists[ACTORCAT_NPC].first; +EnMinifrog* EnMinifrog_GetFrog(PlayState* play) { + EnMinifrog* frog = (EnMinifrog*)play->actorCtx.actorLists[ACTORCAT_NPC].first; while (frog != NULL) { if ((frog->actor.id != ACTOR_EN_MINIFROG) || (frog->actor.params & 0xF)) { @@ -177,7 +177,7 @@ EnMinifrog* EnMinifrog_GetFrog(GlobalContext* globalCtx) { void EnMinifrog_SetJumpState(EnMinifrog* this) { if (this->jumpState == MINIFROG_STATE_GROUND) { this->jumpState = MINIFROG_STATE_JUMP; - Animation_Change(&this->skelAnime, &object_fr_Anim_0007BC, 1.0f, 0.0f, 7.0f, 2, -5.0f); + Animation_Change(&this->skelAnime, &object_fr_Anim_0007BC, 1.0f, 0.0f, 7.0f, ANIMMODE_ONCE, -5.0f); } } @@ -224,14 +224,14 @@ void EnMinifrog_TurnToMissingFrog(EnMinifrog* this) { static Color_RGBA8 sPrimColor = { 255, 255, 255, 255 }; static Color_RGBA8 sEnvColor = { 80, 80, 80, 255 }; -void EnMinifrog_SpawnDust(EnMinifrog* this, GlobalContext* globalCtx) { +void EnMinifrog_SpawnDust(EnMinifrog* this, PlayState* play) { Vec3f pos; Vec3f vec5; Vec3f vel; Vec3f accel; s16 yaw; s16 pitch; - Vec3f eye = GET_ACTIVE_CAM(globalCtx)->eye; + Vec3f eye = GET_ACTIVE_CAM(play)->eye; s32 i; yaw = Math_Vec3f_Yaw(&eye, &this->actor.world.pos); @@ -250,42 +250,43 @@ void EnMinifrog_SpawnDust(EnMinifrog* this, GlobalContext* globalCtx) { pos.x = vec5.x + vel.x; pos.y = vec5.y + vel.y; pos.z = vec5.z + vel.z; - func_800B0F80(globalCtx, &pos, &vel, &accel, &sPrimColor, &sEnvColor, 300, 30, 10); + func_800B0F80(play, &pos, &vel, &accel, &sPrimColor, &sEnvColor, 300, 30, 10); } } -void EnMinifrog_ReturnFrogCutscene(EnMinifrog* this, GlobalContext* globalCtx) { - u8 flag; - +void EnMinifrog_ReturnFrogCutscene(EnMinifrog* this, PlayState* play) { EnMinifrog_TurnToPlayer(this); EnMinifrog_Jump(this); - if ((Message_GetState(&globalCtx->msgCtx) == 5) && Message_ShouldAdvance(globalCtx)) { + + if ((Message_GetState(&play->msgCtx) == TEXT_STATE_5) && Message_ShouldAdvance(play)) { EnMinifrog_SetJumpState(this); - switch (globalCtx->msgCtx.currentTextId) { + switch (play->msgCtx.currentTextId) { case 0xD81: // "Ah! Don Gero! It has been so long." case 0xD83: // "Could it be... Has spring finally come to the mountains?" case 0xD84: // "That look...It is true! Winter was so long that I began to lose all hope." case 0xD86: // "Could it be... You came all this way looking for me?" case 0xD87: // "Ah! You need not say a thing. Upon seeing that face, I understand!" ... - func_80151938(globalCtx, globalCtx->msgCtx.currentTextId + 1); + func_80151938(play, play->msgCtx.currentTextId + 1); break; + 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?" + func_80151938(play, 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?" + func_80151938(play, 0xD86); // "Could it be... You came all this way looking for me?" } - flag = gSaveContext.save.weekEventReg[isFrogReturnedFlags[this->frogIndex] >> 8]; gSaveContext.save.weekEventReg[isFrogReturnedFlags[this->frogIndex] >> 8] = - flag | (u8)isFrogReturnedFlags[this->frogIndex]; + ((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_SpawnDust(this, globalCtx); - SoundSource_PlaySfxAtFixedWorldPos(globalCtx, &this->actor.world.pos, 30, NA_SE_EN_NPC_FADEAWAY); + func_801477B4(play); + EnMinifrog_SpawnDust(this, play); + SoundSource_PlaySfxAtFixedWorldPos(play, &this->actor.world.pos, 30, NA_SE_EN_NPC_FADEAWAY); if (this->actor.cutscene != -1) { if (ActorCutscene_GetCurrentIndex() == this->actor.cutscene) { ActorCutscene_Stop(this->actor.cutscene); @@ -311,7 +312,7 @@ void EnMinifrog_ReturnFrogCutscene(EnMinifrog* this, GlobalContext* globalCtx) { } // This can be seen when the Cyan and Pink frogs spawn after their respective minibosses -void EnMinifrog_SpawnGrowAndShrink(EnMinifrog* this, GlobalContext* globalCtx) { +void EnMinifrog_SpawnGrowAndShrink(EnMinifrog* this, PlayState* play) { EnMinifrog_Jump(this); if (this->timer > 0) { Actor_SetScale(&this->actor, (0.01f + 0.0003f * this->timer * Math_SinS(0x1000 * (this->timer & 7)))); @@ -322,22 +323,22 @@ void EnMinifrog_SpawnGrowAndShrink(EnMinifrog* this, GlobalContext* globalCtx) { } } -void EnMinifrog_Idle(EnMinifrog* this, GlobalContext* globalCtx) { +void EnMinifrog_Idle(EnMinifrog* this, PlayState* play) { EnMinifrog_TurnToPlayer(this); EnMinifrog_Jump(this); EnMinifrog_JumpTimer(this); - if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { + if (Actor_ProcessTalkRequest(&this->actor, &play->state)) { this->actionFunc = EnMinifrog_ReturnFrogCutscene; if (this->actor.cutscene != -1) { this->flags |= 1; } - } else if ((this->actor.xzDistToPlayer < 100.0f) && Player_IsFacingActor(&this->actor, 0x3000, globalCtx) && - (Player_GetMask(globalCtx) == PLAYER_MASK_DON_GERO)) { - func_800B8614(&this->actor, globalCtx, 110.0f); + } else if ((this->actor.xzDistToPlayer < 100.0f) && Player_IsFacingActor(&this->actor, 0x3000, play) && + (Player_GetMask(play) == PLAYER_MASK_DON_GERO)) { + func_800B8614(&this->actor, play, 110.0f); } } -void EnMinifrog_SetupNextFrogInit(EnMinifrog* this, GlobalContext* globalCtx) { +void EnMinifrog_SetupNextFrogInit(EnMinifrog* this, PlayState* play) { EnMinifrog* nextFrog; EnMinifrog* missingFrog; @@ -360,12 +361,12 @@ void EnMinifrog_SetupNextFrogInit(EnMinifrog* this, GlobalContext* globalCtx) { } } -void EnMinifrog_CheckChoirSuccess(EnMinifrog* this, GlobalContext* globalCtx) { +void EnMinifrog_CheckChoirSuccess(EnMinifrog* this, PlayState* play) { this->actionFunc = EnMinifrog_YellowFrogDialog; if (this->frog != NULL) { - func_80151938(globalCtx, 0xD78); // "Unfortunately, it seems not all of our members have gathered." + func_80151938(play, 0xD78); // "Unfortunately, it seems not all of our members have gathered." } else { - func_80151938(globalCtx, + func_80151938(play, 0xD7C); // "The conducting was spectacular. And all of our members rose to the occasion!" } @@ -374,14 +375,14 @@ void EnMinifrog_CheckChoirSuccess(EnMinifrog* this, GlobalContext* globalCtx) { this->actor.home.rot.z = 0; } -void EnMinifrog_ContinueChoirCutscene(EnMinifrog* this, GlobalContext* globalCtx) { +void EnMinifrog_ContinueChoirCutscene(EnMinifrog* this, PlayState* play) { EnMinifrog_Jump(this); if (ActorCutscene_GetCurrentIndex() == 0x7C) { - EnMinifrog_CheckChoirSuccess(this, globalCtx); + EnMinifrog_CheckChoirSuccess(this, play); return; // necessary to match } else if (ActorCutscene_GetCanPlayNext(0x7C)) { ActorCutscene_Start(0x7C, NULL); - EnMinifrog_CheckChoirSuccess(this, globalCtx); + EnMinifrog_CheckChoirSuccess(this, play); return; // necessary to match } else if (this->actor.cutscene != -1 && ActorCutscene_GetCurrentIndex() == this->actor.cutscene) { ActorCutscene_Stop(this->actor.cutscene); @@ -392,7 +393,7 @@ void EnMinifrog_ContinueChoirCutscene(EnMinifrog* this, GlobalContext* globalCtx } } -void EnMinifrog_NextFrogMissing(EnMinifrog* this, GlobalContext* globalCtx) { +void EnMinifrog_NextFrogMissing(EnMinifrog* this, PlayState* play) { EnMinifrog_TurnToMissingFrog(this); EnMinifrog_Jump(this); if (this->timer > 0) { @@ -402,7 +403,7 @@ void EnMinifrog_NextFrogMissing(EnMinifrog* this, GlobalContext* globalCtx) { } } -void EnMinifrog_NextFrogReturned(EnMinifrog* this, GlobalContext* globalCtx) { +void EnMinifrog_NextFrogReturned(EnMinifrog* this, PlayState* play) { EnMinifrog_Jump(this); if (this->timer > 0) { this->timer--; @@ -410,11 +411,11 @@ void EnMinifrog_NextFrogReturned(EnMinifrog* this, GlobalContext* globalCtx) { this->actionFunc = EnMinifrog_ContinueChoirCutscene; this->flags &= ~(0x2 << MINIFROG_YELLOW | 0x2 << MINIFROG_CYAN | 0x2 << MINIFROG_PINK | 0x2 << MINIFROG_BLUE | 0x2 << MINIFROG_WHITE); - globalCtx->setPlayerTalkAnim(globalCtx, &gameplay_keep_Linkanim_00DEA8, 0); + play->setPlayerTalkAnim(play, &gameplay_keep_Linkanim_00DEA8, 0); } } -void EnMinifrog_SetupNextFrogChoir(EnMinifrog* this, GlobalContext* globalCtx) { +void EnMinifrog_SetupNextFrogChoir(EnMinifrog* this, PlayState* play) { u8 frogIndex; EnMinifrog_Jump(this); @@ -441,14 +442,14 @@ void EnMinifrog_SetupNextFrogChoir(EnMinifrog* this, GlobalContext* globalCtx) { this->flags &= ~0x100; this->flags &= ~(0x2 << MINIFROG_YELLOW | 0x2 << MINIFROG_CYAN | 0x2 << MINIFROG_PINK | 0x2 << MINIFROG_BLUE | 0x2 << MINIFROG_WHITE); - globalCtx->setPlayerTalkAnim(globalCtx, &gameplay_keep_Linkanim_00DEA8, 0); + play->setPlayerTalkAnim(play, &gameplay_keep_Linkanim_00DEA8, 0); } else if (this->timer <= 0) { this->actionFunc = EnMinifrog_NextFrogReturned; this->timer = 30; } } -void EnMinifrog_BeginChoirCutscene(EnMinifrog* this, GlobalContext* globalCtx) { +void EnMinifrog_BeginChoirCutscene(EnMinifrog* this, PlayState* play) { EnMinifrog_Jump(this); if (this->actor.cutscene == -1) { this->actionFunc = EnMinifrog_SetupNextFrogChoir; @@ -461,62 +462,63 @@ void EnMinifrog_BeginChoirCutscene(EnMinifrog* this, GlobalContext* globalCtx) { this->timer = 5; func_801A1F00(3, NA_BGM_FROG_SONG); this->flags |= 0x100; - globalCtx->setPlayerTalkAnim(globalCtx, &gameplay_keep_Linkanim_00E2A8, 0); + play->setPlayerTalkAnim(play, &gameplay_keep_Linkanim_00E2A8, 0); } else { ActorCutscene_SetIntentToPlay(this->actor.cutscene); } } -void EnMinifrog_EndChoir(EnMinifrog* this, GlobalContext* globalCtx) { +void EnMinifrog_EndChoir(EnMinifrog* this, PlayState* play) { EnMinifrog_TurnToPlayer(this); EnMinifrog_Jump(this); - if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { - Message_StartTextbox(globalCtx, 0xD7E, &this->actor); // "Let us do it again sometime." + if (Actor_ProcessTalkRequest(&this->actor, &play->state)) { + Message_StartTextbox(play, 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); + func_800B8500(&this->actor, play, 1000.0f, 1000.0f, PLAYER_AP_MINUS1); } } -void EnMinifrog_GetFrogHP(EnMinifrog* this, GlobalContext* globalCtx) { +void EnMinifrog_GetFrogHP(EnMinifrog* this, PlayState* play) { EnMinifrog_TurnToPlayer(this); EnMinifrog_Jump(this); - if (Actor_HasParent(&this->actor, globalCtx)) { + if (Actor_HasParent(&this->actor, play)) { this->actor.parent = NULL; this->actionFunc = EnMinifrog_EndChoir; this->actor.flags |= ACTOR_FLAG_10000; - func_800B8500(&this->actor, globalCtx, 1000.0f, 1000.0f, EXCH_ITEM_NONE); + func_800B8500(&this->actor, play, 1000.0f, 1000.0f, PLAYER_AP_NONE); } else { - Actor_PickUp(&this->actor, globalCtx, GI_HEART_PIECE, 10000.0f, 50.0f); + Actor_PickUp(&this->actor, play, GI_HEART_PIECE, 10000.0f, 50.0f); } } -void EnMinifrog_YellowFrogDialog(EnMinifrog* this, GlobalContext* globalCtx) { +void EnMinifrog_YellowFrogDialog(EnMinifrog* this, PlayState* play) { EnMinifrog_TurnToPlayer(this); EnMinifrog_Jump(this); - switch (Message_GetState(&globalCtx->msgCtx)) { - case 4: - if (Message_ShouldAdvance(globalCtx)) { - switch (globalCtx->msgCtx.choiceIndex) { + switch (Message_GetState(&play->msgCtx)) { + case TEXT_STATE_CHOICE: + if (Message_ShouldAdvance(play)) { + switch (play->msgCtx.choiceIndex) { case 0: // Yes func_8019F208(); this->actionFunc = EnMinifrog_BeginChoirCutscene; - globalCtx->msgCtx.unk11F10 = 0; + play->msgCtx.msgLength = 0; break; case 1: // No func_8019F230(); - func_80151938(globalCtx, 0xD7E); // "Let us do it again sometime." + func_80151938(play, 0xD7E); // "Let us do it again sometime." break; } } break; - case 5: - if (Message_ShouldAdvance(globalCtx)) { + + case TEXT_STATE_5: + if (Message_ShouldAdvance(play)) { EnMinifrog_SetJumpState(this); - switch (globalCtx->msgCtx.currentTextId) { + switch (play->msgCtx.currentTextId) { case 0xD76: // "I have been waiting for you, Don Gero. Forgive me if I'm mistaken, but it looks like // you've lost a little weight..." - func_80151938(globalCtx, globalCtx->msgCtx.currentTextId + 1); + func_80151938(play, play->msgCtx.currentTextId + 1); this->actor.flags &= ~ACTOR_FLAG_10000; gSaveContext.save.weekEventReg[34] |= 1; // Spoken to MINIFROG_YELLOW break; @@ -525,73 +527,74 @@ void EnMinifrog_YellowFrogDialog(EnMinifrog* this, GlobalContext* globalCtx) { // has come to the mountains..." case 0xD7A: // "And when the great Don Gero has come for us, too...What a pity." case 0xD7F: // "Well, if it isn't the great Don Gero." - func_80151938(globalCtx, globalCtx->msgCtx.currentTextId + 1); + func_80151938(play, play->msgCtx.currentTextId + 1); break; case 0xD77: // "Let us begin our chorus" this->actionFunc = EnMinifrog_BeginChoirCutscene; - globalCtx->msgCtx.unk11F10 = 0; + play->msgCtx.msgLength = 0; break; case 0xD7C: // "The conducting was spectacular. And all of our members rose to the occasion!" if (gSaveContext.save.weekEventReg[35] & 0x80) { // Obtained Heart Piece - func_80151938(globalCtx, 0xD7E); + func_80151938(play, 0xD7E); } else { - func_80151938(globalCtx, 0xD7D); // Get Heart Piece + func_80151938(play, 0xD7D); // Get Heart Piece gSaveContext.save.weekEventReg[35] |= 0x80; } break; case 0xD7D: // "This is how deeply we were moved by your spectacular conducting..." - func_801477B4(globalCtx); + func_801477B4(play); this->actionFunc = EnMinifrog_GetFrogHP; - EnMinifrog_GetFrogHP(this, globalCtx); + EnMinifrog_GetFrogHP(this, play); break; case 0xD7B: // "Where in the world could the other members be, and what could they be doing?" case 0xD7E: // "Let us do it again sometime." default: - func_801477B4(globalCtx); + func_801477B4(play); this->actionFunc = EnMinifrog_SetupYellowFrogDialog; this->actor.flags &= ~ACTOR_FLAG_10000; break; } } + break; } } -void EnMinifrog_SetupYellowFrogDialog(EnMinifrog* this, GlobalContext* globalCtx) { +void EnMinifrog_SetupYellowFrogDialog(EnMinifrog* this, PlayState* play) { Math_ScaledStepToS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer, 0x180); this->actor.world.rot.y = this->actor.shape.rot.y; EnMinifrog_TurnToPlayer(this); EnMinifrog_Jump(this); EnMinifrog_JumpTimer(this); - if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { + if (Actor_ProcessTalkRequest(&this->actor, &play->state)) { this->actionFunc = EnMinifrog_YellowFrogDialog; if (!(gSaveContext.save.weekEventReg[34] & 1)) { // Not spoken with MINIFROG_YELLOW - Message_StartTextbox(globalCtx, 0xD76, + Message_StartTextbox(play, 0xD76, &this->actor); // "I have been waiting for you, Don Gero. Forgive me if I'm mistaken, // but it looks like you've lost a little weight..." } else { - Message_StartTextbox(globalCtx, 0xD7F, &this->actor); // "Well, if it isn't the great Don Gero." + Message_StartTextbox(play, 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) || + (Player_IsFacingActor(&this->actor, 0x3000, play) || CHECK_FLAG_ALL(this->actor.flags, ACTOR_FLAG_10000)) && - Player_GetMask(globalCtx) == PLAYER_MASK_DON_GERO) { - func_800B8614(&this->actor, globalCtx, 160.0f); + Player_GetMask(play) == PLAYER_MASK_DON_GERO) { + func_800B8614(&this->actor, play, 160.0f); } } -void EnMinifrog_Update(Actor* thisx, GlobalContext* globalCtx) { +void EnMinifrog_Update(Actor* thisx, PlayState* play) { EnMinifrog* this = THIS; s32 pad; - this->actionFunc(this, globalCtx); + this->actionFunc(this, play); Actor_MoveWithGravity(&this->actor); - Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 25.0f, 12.0f, 0.0f, 0x1D); + Actor_UpdateBgCheckInfo(play, &this->actor, 25.0f, 12.0f, 0.0f, 0x1D); Collider_UpdateCylinder(&this->actor, &this->collider); - CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + CollisionCheck_SetOC(play, &play->colChkCtx, &this->collider.base); this->actor.focus.rot.y = this->actor.shape.rot.y; } -void EnMinifrog_UpdateMissingFrog(Actor* thisx, GlobalContext* globalCtx) { +void EnMinifrog_UpdateMissingFrog(Actor* thisx, PlayState* play) { EnMinifrog* this = THIS; EnMinifrog* missingFrog; @@ -601,8 +604,7 @@ void EnMinifrog_UpdateMissingFrog(Actor* thisx, GlobalContext* globalCtx) { } } -s32 EnMinifrog_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, - Actor* thisx) { +s32 EnMinifrog_OverrideLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, Actor* thisx) { if (limbIndex == 1) { pos->z -= 500.0f; } @@ -614,19 +616,19 @@ s32 EnMinifrog_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** d return false; } -void EnMinifrog_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx) { +void EnMinifrog_PostLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx) { EnMinifrog* this = THIS; if ((limbIndex == 7) || (limbIndex == 8)) { - OPEN_DISPS(globalCtx->state.gfxCtx); - Matrix_NormalizeXYZ(&globalCtx->billboardMtxF); - gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + OPEN_DISPS(play->state.gfxCtx); + Matrix_ReplaceRotation(&play->billboardMtxF); + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_OPA_DISP++, *dList); - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->state.gfxCtx); } if (limbIndex == 4) { - Matrix_GetStateTranslation(&this->actor.focus.pos); + Matrix_MultZero(&this->actor.focus.pos); } } @@ -634,17 +636,17 @@ static Color_RGBA8 sEnMinifrogColor[] = { { 200, 170, 0, 255 }, { 0, 170, 200, 255 }, { 210, 120, 100, 255 }, { 120, 130, 230, 255 }, { 190, 190, 190, 255 }, }; -void EnMinifrog_Draw(Actor* thisx, GlobalContext* globalCtx) { +void EnMinifrog_Draw(Actor* thisx, PlayState* play) { EnMinifrog* this = THIS; Color_RGBA8* envColor; - OPEN_DISPS(globalCtx->state.gfxCtx); - func_8012C28C(globalCtx->state.gfxCtx); + OPEN_DISPS(play->state.gfxCtx); + func_8012C28C(play->state.gfxCtx); envColor = &sEnMinifrogColor[this->frogIndex]; gSPSegment(POLY_OPA_DISP++, 0x08, D_808A4D74[0]); gSPSegment(POLY_OPA_DISP++, 0x09, D_808A4D74[0]); gDPSetEnvColor(POLY_OPA_DISP++, envColor->r, envColor->g, envColor->b, envColor->a); - SkelAnime_DrawFlexOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, + SkelAnime_DrawFlexOpa(play, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, EnMinifrog_OverrideLimbDraw, EnMinifrog_PostLimbDraw, &this->actor); - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->state.gfxCtx); } diff --git a/src/overlays/actors/ovl_En_Minifrog/z_en_minifrog.h b/src/overlays/actors/ovl_En_Minifrog/z_en_minifrog.h index 201ef5c47..a71caa650 100644 --- a/src/overlays/actors/ovl_En_Minifrog/z_en_minifrog.h +++ b/src/overlays/actors/ovl_En_Minifrog/z_en_minifrog.h @@ -5,9 +5,9 @@ struct EnMinifrog; -typedef void (*EnMinifrogActionFunc)(struct EnMinifrog*, GlobalContext*); +typedef void (*EnMinifrogActionFunc)(struct EnMinifrog*, PlayState*); -#define EN_MINIFROG_IS_RETURNED(this) ((((this)->actor.params)&0xF0) >> 4) +#define EN_MINIFROG_IS_RETURNED(thisx) ((((thisx)->params) & 0xF0) >> 4) typedef enum { /* 0x00 */ MINIFROG_YELLOW, // Mountain Village diff --git a/src/overlays/actors/ovl_En_Minislime/z_en_minislime.c b/src/overlays/actors/ovl_En_Minislime/z_en_minislime.c index 4efc18714..cdf3ad957 100644 --- a/src/overlays/actors/ovl_En_Minislime/z_en_minislime.c +++ b/src/overlays/actors/ovl_En_Minislime/z_en_minislime.c @@ -11,35 +11,35 @@ #define THIS ((EnMinislime*)thisx) -void EnMinislime_Init(Actor* thisx, GlobalContext* globalCtx); -void EnMinislime_Destroy(Actor* thisx, GlobalContext* globalCtx); -void EnMinislime_Update(Actor* thisx, GlobalContext* globalCtx); +void EnMinislime_Init(Actor* thisx, PlayState* play); +void EnMinislime_Destroy(Actor* thisx, PlayState* play); +void EnMinislime_Update(Actor* thisx, PlayState* play); void EnMinislime_SetupDisappear(EnMinislime* this); -void EnMinislime_Disappear(EnMinislime* this, GlobalContext* globalCtx); -void EnMinislime_SetupFall(EnMinislime* this, GlobalContext* globalCtx); -void EnMinislime_Fall(EnMinislime* this, GlobalContext* globalCtx); +void EnMinislime_Disappear(EnMinislime* this, PlayState* play); +void EnMinislime_SetupFall(EnMinislime* this, PlayState* play); +void EnMinislime_Fall(EnMinislime* this, PlayState* play); void EnMinislime_SetupBreakFromBigslime(EnMinislime* this); -void EnMinislime_BreakFromBigslime(EnMinislime* this, GlobalContext* globalCtx); -void EnMinislime_IceArrowDamage(EnMinislime* this, GlobalContext* globalCtx); -void EnMinislime_FireArrowDamage(EnMinislime* this, GlobalContext* globalCtx); +void EnMinislime_BreakFromBigslime(EnMinislime* this, PlayState* play); +void EnMinislime_IceArrowDamage(EnMinislime* this, PlayState* play); +void EnMinislime_FireArrowDamage(EnMinislime* this, PlayState* play); void EnMinislime_SetupGrowAndShrink(EnMinislime* this); -void EnMinislime_GrowAndShrink(EnMinislime* this, GlobalContext* globalCtx); +void EnMinislime_GrowAndShrink(EnMinislime* this, PlayState* play); void EnMinislime_SetupIdle(EnMinislime* this); void EnMinislime_SetupBounce(EnMinislime* this); -void EnMinislime_Idle(EnMinislime* this, GlobalContext* globalCtx); -void EnMinislime_Bounce(EnMinislime* this, GlobalContext* globalCtx); +void EnMinislime_Idle(EnMinislime* this, PlayState* play); +void EnMinislime_Bounce(EnMinislime* this, PlayState* play); void EnMinislime_SetupDespawn(EnMinislime* this); -void EnMinislime_Despawn(EnMinislime* this, GlobalContext* globalCtx); -void EnMinislime_MoveToBigslime(EnMinislime* this, GlobalContext* globalCtx); -void EnMinislime_Knockback(EnMinislime* this, GlobalContext* globalCtx); -void EnMinislime_DefeatIdle(EnMinislime* this, GlobalContext* globalCtx); -void EnMinislime_SetupDefeatMelt(EnMinislime* this, GlobalContext* globalCtx); -void EnMinislime_DefeatMelt(EnMinislime* this, GlobalContext* globalCtx); +void EnMinislime_Despawn(EnMinislime* this, PlayState* play); +void EnMinislime_MoveToBigslime(EnMinislime* this, PlayState* play); +void EnMinislime_Knockback(EnMinislime* this, PlayState* play); +void EnMinislime_DefeatIdle(EnMinislime* this, PlayState* play); +void EnMinislime_SetupDefeatMelt(EnMinislime* this, PlayState* play); +void EnMinislime_DefeatMelt(EnMinislime* this, PlayState* play); void EnMinislime_SetupMoveToGekko(EnMinislime* this); -void EnMinislime_MoveToGekko(EnMinislime* this, GlobalContext* globalCtx); +void EnMinislime_MoveToGekko(EnMinislime* this, PlayState* play); void EnMinislime_SetupGekkoThrow(EnMinislime* this); -void EnMinislime_GekkoThrow(EnMinislime* this, GlobalContext* globalCtx); +void EnMinislime_GekkoThrow(EnMinislime* this, PlayState* play); const ActorInit En_Minislime_InitVars = { ACTOR_EN_MINISLIME, @@ -118,21 +118,21 @@ static DamageTable sDamageTable = { /* Powder Keg */ DMG_ENTRY(1, MINISLIME_DMGEFF_BREAK_ICE), }; -void EnMinislime_Init(Actor* thisx, GlobalContext* globalCtx) { +void EnMinislime_Init(Actor* thisx, PlayState* play) { EnMinislime* this = THIS; this->actor.flags &= ~ACTOR_FLAG_1; - Collider_InitAndSetCylinder(globalCtx, &this->collider, &this->actor, &sCylinderInit); + Collider_InitAndSetCylinder(play, &this->collider, &this->actor, &sCylinderInit); CollisionCheck_SetInfo(&this->actor.colChkInfo, &sDamageTable, &sColChkInfoInit); this->id = this->actor.params; this->actor.shape.shadowAlpha = 255; EnMinislime_SetupDisappear(this); } -void EnMinislime_Destroy(Actor* thisx, GlobalContext* globalCtx) { +void EnMinislime_Destroy(Actor* thisx, PlayState* play) { EnMinislime* this = THIS; - Collider_DestroyCylinder(globalCtx, &this->collider); + Collider_DestroyCylinder(play, &this->collider); } void EnMinislime_CheckBackgroundCollision(EnMinislime* this) { @@ -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; } @@ -205,7 +205,7 @@ void EnMinislime_AddIceShardEffect(EnMinislime* this) { Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_ICE_BROKEN); } -void EnMinislime_AddIceSmokeEffect(EnMinislime* this, GlobalContext* globalCtx) { +void EnMinislime_AddIceSmokeEffect(EnMinislime* this, PlayState* play) { Vec3f pos; Vec3f vel; @@ -215,7 +215,7 @@ void EnMinislime_AddIceSmokeEffect(EnMinislime* this, GlobalContext* globalCtx) vel.x = randPlusMinusPoint5Scaled(1.5f); vel.z = randPlusMinusPoint5Scaled(1.5f); vel.y = 2.0f; - EffectSsIceSmoke_Spawn(globalCtx, &pos, &vel, &gZeroVec3f, 500); + EffectSsIceSmoke_Spawn(play, &pos, &vel, &gZeroVec3f, 500); } void EnMinislime_SetupDisappear(EnMinislime* this) { @@ -223,18 +223,18 @@ void EnMinislime_SetupDisappear(EnMinislime* this) { this->actionFunc = EnMinislime_Disappear; } -void EnMinislime_Disappear(EnMinislime* this, GlobalContext* globalCtx) { +void EnMinislime_Disappear(EnMinislime* this, PlayState* play) { if (this->actor.params == MINISLIME_BREAK_BIGSLIME) { EnMinislime_SetupBreakFromBigslime(this); } else if (this->actor.params == MINISLIME_INIT_FALL) { - EnMinislime_SetupFall(this, globalCtx); + EnMinislime_SetupFall(this, play); } else if (this->actor.params == MINISLIME_DESPAWN) { EnMinislime_SetupDespawn(this); } } -void EnMinislime_SetupFall(EnMinislime* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); +void EnMinislime_SetupFall(EnMinislime* this, PlayState* play) { + Player* player = GET_PLAYER(play); s16 yaw; this->collider.base.atFlags |= AT_ON; @@ -255,7 +255,7 @@ void EnMinislime_SetupFall(EnMinislime* this, GlobalContext* globalCtx) { this->actionFunc = EnMinislime_Fall; } -void EnMinislime_Fall(EnMinislime* this, GlobalContext* globalCtx) { +void EnMinislime_Fall(EnMinislime* this, PlayState* play) { Math_StepToF(&this->actor.scale.x, 0.17999999f, 0.003f); Math_StepToF(&this->actor.scale.y, 0.05f, 0.003f); this->actor.scale.z = this->actor.scale.x; @@ -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; @@ -285,7 +285,7 @@ void EnMinislime_SetupBreakFromBigslime(EnMinislime* this) { this->actionFunc = EnMinislime_BreakFromBigslime; } -void EnMinislime_BreakFromBigslime(EnMinislime* this, GlobalContext* globalCtx) { +void EnMinislime_BreakFromBigslime(EnMinislime* this, PlayState* play) { this->actor.shape.rot.x += this->actor.world.rot.x; if (this->actor.velocity.y < 0.0f) { this->collider.base.ocFlags1 |= OC1_ON; @@ -305,7 +305,7 @@ void EnMinislime_SetupIceArrowDamage(EnMinislime* this) { this->actionFunc = EnMinislime_IceArrowDamage; } -void EnMinislime_IceArrowDamage(EnMinislime* this, GlobalContext* globalCtx) { +void EnMinislime_IceArrowDamage(EnMinislime* this, PlayState* play) { f32 invFrozenTimer; s32 pad; f32 randFloat; @@ -358,10 +358,10 @@ void EnMinislime_SetupFireArrowDamage(EnMinislime* this) { this->actionFunc = EnMinislime_FireArrowDamage; } -void EnMinislime_FireArrowDamage(EnMinislime* this, GlobalContext* globalCtx) { +void EnMinislime_FireArrowDamage(EnMinislime* this, PlayState* play) { this->meltTimer--; if ((this->meltTimer % 25) == 0) { - EnMinislime_AddIceSmokeEffect(this, globalCtx); + EnMinislime_AddIceSmokeEffect(this, play); } this->frozenScale = this->meltTimer * 0.0025f; @@ -395,7 +395,7 @@ void EnMinislime_SetupGrowAndShrink(EnMinislime* this) { this->actionFunc = EnMinislime_GrowAndShrink; } -void EnMinislime_GrowAndShrink(EnMinislime* this, GlobalContext* globalCtx) { +void EnMinislime_GrowAndShrink(EnMinislime* this, PlayState* play) { f32 scaleFactor; this->growShrinkTimer--; @@ -420,7 +420,7 @@ void EnMinislime_SetupIdle(EnMinislime* this) { this->actionFunc = EnMinislime_Idle; } -void EnMinislime_Idle(EnMinislime* this, GlobalContext* globalCtx) { +void EnMinislime_Idle(EnMinislime* this, PlayState* play) { f32 speedXZ; this->idleTimer--; @@ -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; @@ -457,7 +457,7 @@ void EnMinislime_SetupBounce(EnMinislime* this) { this->actionFunc = EnMinislime_Bounce; } -void EnMinislime_Bounce(EnMinislime* this, GlobalContext* globalCtx) { +void EnMinislime_Bounce(EnMinislime* this, PlayState* play) { if (this->actor.params == MINISLIME_SETUP_GEKKO_THROW) { EnMinislime_SetupMoveToGekko(this); } else { @@ -512,7 +512,7 @@ void EnMinislime_SetupMoveToBigslime(EnMinislime* this) { this->actionFunc = EnMinislime_MoveToBigslime; } -void EnMinislime_MoveToBigslime(EnMinislime* this, GlobalContext* globalCtx) { +void EnMinislime_MoveToBigslime(EnMinislime* this, PlayState* play) { if (this->actor.params == MINISLIME_DISAPPEAR) { EnMinislime_SetupDisappear(this); } else if ((this->actor.scale.x > 0.0f) && (this->actor.world.pos.y > (GBT_ROOM_5_MAX_Y - 100.0f))) { @@ -531,7 +531,7 @@ void EnMinislime_SetupKnockback(EnMinislime* this) { this->actionFunc = EnMinislime_Knockback; } -void EnMinislime_Knockback(EnMinislime* this, GlobalContext* globalCtx) { +void EnMinislime_Knockback(EnMinislime* this, PlayState* play) { f32 sqrtFrozenTimer; this->knockbackTimer--; @@ -571,7 +571,7 @@ void EnMinislime_SetupDefeatIdle(EnMinislime* this) { this->actionFunc = EnMinislime_DefeatIdle; } -void EnMinislime_DefeatIdle(EnMinislime* this, GlobalContext* globalCtx) { +void EnMinislime_DefeatIdle(EnMinislime* this, PlayState* play) { f32 xzScale; this->idleTimer--; @@ -584,23 +584,23 @@ void EnMinislime_DefeatIdle(EnMinislime* this, GlobalContext* globalCtx) { } if (this->actor.params == MINISLIME_DEFEAT_MELT) { - EnMinislime_SetupDefeatMelt(this, globalCtx); + EnMinislime_SetupDefeatMelt(this, play); } } -void EnMinislime_SetupDefeatMelt(EnMinislime* this, GlobalContext* globalCtx) { +void EnMinislime_SetupDefeatMelt(EnMinislime* this, PlayState* play) { this->actor.gravity = 0.0f; this->actor.velocity.y = -50.0f; this->meltTimer = Rand_ZeroFloat(25.0f); - EnMinislime_AddIceSmokeEffect(this, globalCtx); + EnMinislime_AddIceSmokeEffect(this, play); this->actor.params = MINISLIME_DISAPPEAR; this->actionFunc = EnMinislime_DefeatMelt; } -void EnMinislime_DefeatMelt(EnMinislime* this, GlobalContext* globalCtx) { +void EnMinislime_DefeatMelt(EnMinislime* this, PlayState* play) { this->meltTimer++; if (((this->meltTimer % 25) == 0) && (this->actor.shape.shadowAlpha > 25)) { - EnMinislime_AddIceSmokeEffect(this, globalCtx); + EnMinislime_AddIceSmokeEffect(this, play); } func_800B9010(&this->actor, NA_SE_EV_ICE_MELT_LEVEL - SFX_FLAG); @@ -620,7 +620,7 @@ void EnMinislime_SetupDespawn(EnMinislime* this) { this->actionFunc = EnMinislime_Despawn; } -void EnMinislime_Despawn(EnMinislime* this, GlobalContext* globalCtx) { +void EnMinislime_Despawn(EnMinislime* this, PlayState* play) { Actor_MarkForDeath(&this->actor); } @@ -637,7 +637,7 @@ void EnMinislime_SetupMoveToGekko(EnMinislime* this) { this->actionFunc = EnMinislime_MoveToGekko; } -void EnMinislime_MoveToGekko(EnMinislime* this, GlobalContext* globalCtx) { +void EnMinislime_MoveToGekko(EnMinislime* this, PlayState* play) { Math_StepToF(&this->actor.world.pos.x, this->actor.parent->world.pos.x, 10.0f); Math_StepToF(&this->actor.world.pos.z, this->actor.parent->world.pos.z, 10.0f); Math_StepToF(&this->actor.world.pos.y, this->actor.parent->world.pos.y + 80.0f, 10.0f); @@ -647,7 +647,7 @@ void EnMinislime_MoveToGekko(EnMinislime* this, GlobalContext* globalCtx) { if (this->actor.params == MINISLIME_GEKKO_THROW) { EnMinislime_SetupGekkoThrow(this); } else if (this->actor.params == MINISLIME_IDLE) { - EnMinislime_SetupFall(this, globalCtx); + EnMinislime_SetupFall(this, play); } } @@ -666,7 +666,7 @@ void EnMinislime_SetupGekkoThrow(EnMinislime* this) { this->actionFunc = EnMinislime_GekkoThrow; } -void EnMinislime_GekkoThrow(EnMinislime* this, GlobalContext* globalCtx) { +void EnMinislime_GekkoThrow(EnMinislime* this, PlayState* play) { f32 xzScale; this->throwTimer--; @@ -707,7 +707,7 @@ void EnMinislime_ApplyDamage(EnMinislime* this) { } } -void EnMinislime_Update(Actor* thisx, GlobalContext* globalCtx) { +void EnMinislime_Update(Actor* thisx, PlayState* play) { EnMinislime* this = THIS; Player* player; s32 pad; @@ -716,7 +716,7 @@ void EnMinislime_Update(Actor* thisx, GlobalContext* globalCtx) { if ((this->actor.params == MINISLIME_DEFEAT_IDLE) && (this->actor.bgCheckFlags & 1)) { EnMinislime_SetupDefeatIdle(this); } else if (this->actor.params == MINISLIME_DEFEAT_MELT) { - EnMinislime_SetupDefeatMelt(this, globalCtx); + EnMinislime_SetupDefeatMelt(this, play); } else if ((this->actor.params == MINISLIME_FORM_BIGSLIME) && (this->actionFunc != EnMinislime_MoveToBigslime)) { EnMinislime_SetupMoveToBigslime(this); } else { @@ -732,7 +732,7 @@ void EnMinislime_Update(Actor* thisx, GlobalContext* globalCtx) { this->collider.base.atFlags &= ~AT_HIT; } - this->actionFunc(this, globalCtx); + this->actionFunc(this, play); if ((this->actionFunc != EnMinislime_Disappear) && (this->actionFunc != EnMinislime_Despawn)) { if (this->actionFunc == EnMinislime_MoveToBigslime) { @@ -748,13 +748,13 @@ void EnMinislime_Update(Actor* thisx, GlobalContext* globalCtx) { this->collider.dim.yShift = ((EnMinislime*)thisx)->actor.scale.y * -400.0f; if ((this->attackTimer == 0) && (this->collider.base.atFlags & AT_ON)) { - CollisionCheck_SetAT(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + CollisionCheck_SetAT(play, &play->colChkCtx, &this->collider.base); } if (this->collider.base.acFlags & AC_ON) { - CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + CollisionCheck_SetAC(play, &play->colChkCtx, &this->collider.base); } if (this->collider.base.ocFlags1 & OC1_ON) { - CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + CollisionCheck_SetOC(play, &play->colChkCtx, &this->collider.base); } if (this->attackTimer != 0) { @@ -762,11 +762,11 @@ void EnMinislime_Update(Actor* thisx, GlobalContext* globalCtx) { } if (this->actor.bgCheckFlags & 2) { - player = GET_PLAYER(globalCtx); + player = GET_PLAYER(play); vec1.x = this->actor.world.pos.x; vec1.z = this->actor.world.pos.z; vec1.y = player->actor.world.pos.y + player->actor.depthInWater; - EffectSsGRipple_Spawn(globalCtx, &vec1, 500, 720, 0); + EffectSsGRipple_Spawn(play, &vec1, 500, 720, 0); } } } diff --git a/src/overlays/actors/ovl_En_Minislime/z_en_minislime.h b/src/overlays/actors/ovl_En_Minislime/z_en_minislime.h index e0b86e832..28629f464 100644 --- a/src/overlays/actors/ovl_En_Minislime/z_en_minislime.h +++ b/src/overlays/actors/ovl_En_Minislime/z_en_minislime.h @@ -5,7 +5,7 @@ struct EnMinislime; -typedef void (*EnMinislimeActionFunc)(struct EnMinislime*, GlobalContext*); +typedef void (*EnMinislimeActionFunc)(struct EnMinislime*, PlayState*); #define MINISLIME_NUM_SPAWN 15 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 8c20b4106..cb25445b9 100644 --- a/src/overlays/actors/ovl_En_Mk/z_en_mk.c +++ b/src/overlays/actors/ovl_En_Mk/z_en_mk.c @@ -10,18 +10,18 @@ #define THIS ((EnMk*)thisx) -void EnMk_Init(Actor* thisx, GlobalContext* globalCtx); -void EnMk_Destroy(Actor* thisx, GlobalContext* globalCtx); -void EnMk_Update(Actor* thisx, GlobalContext* globalCtx); -void EnMk_Draw(Actor* thisx, GlobalContext* globalCtx); +void EnMk_Init(Actor* thisx, PlayState* play); +void EnMk_Destroy(Actor* thisx, PlayState* play); +void EnMk_Update(Actor* thisx, PlayState* play); +void EnMk_Draw(Actor* thisx, PlayState* play); -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); -void func_80959C94(EnMk* this, GlobalContext* globalCtx); -void func_80959D28(EnMk* this, GlobalContext* globalCtx); -void func_80959E18(EnMk* this, GlobalContext* globalCtx); +s32 func_80959524(PlayState* play); +void func_809596A0(EnMk* this, PlayState* play); +void func_80959774(EnMk* this, PlayState* play); +void func_80959A24(EnMk* this, PlayState* play); +void func_80959C94(EnMk* this, PlayState* play); +void func_80959D28(EnMk* this, PlayState* play); +void func_80959E18(EnMk* this, PlayState* play); const ActorInit En_Mk_InitVars = { ACTOR_EN_MK, @@ -74,7 +74,7 @@ s32 func_809592E0(EnMk* this, s16 index) { return true; } -void EnMk_Init(Actor* thisx, GlobalContext* globalCtx) { +void EnMk_Init(Actor* thisx, PlayState* play) { EnMk* this = THIS; s16 cs; s32 i; @@ -82,13 +82,13 @@ void EnMk_Init(Actor* thisx, GlobalContext* globalCtx) { 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, + SkelAnime_InitFlex(play, &this->skelAnime, &object_mk_Skel_006CA0, &object_mk_Anim_001C38, this->jointTable, this->morphTable, OBJECT_MK_LIMB_MAX); this->unk_27C = -1; func_809592E0(this, 0); - Collider_InitAndSetCylinder(globalCtx, &this->collider, &this->actor, &sCylinderInit); + Collider_InitAndSetCylinder(play, &this->collider, &this->actor, &sCylinderInit); this->actor.colChkInfo.mass = MASS_IMMOVABLE; Actor_SetScale(&this->actor, 0.01f); @@ -97,7 +97,7 @@ void EnMk_Init(Actor* thisx, GlobalContext* globalCtx) { this->unk_27A = 0; this->actor.targetMode = 6; - if (func_80959524(globalCtx) < 7) { + if (func_80959524(play) < 7) { this->unk_27A |= 2; } @@ -113,28 +113,27 @@ void EnMk_Init(Actor* thisx, GlobalContext* globalCtx) { this->actor.cutscene = this->unk_276[0]; } -void EnMk_Destroy(Actor* thisx, GlobalContext* globalCtx) { +void EnMk_Destroy(Actor* thisx, PlayState* play) { EnMk* this = THIS; - Collider_DestroyCylinder(globalCtx, &this->collider); + Collider_DestroyCylinder(play, &this->collider); } -s32 func_80959524(GlobalContext* globalCtx) { - return gSaveContext.save.permanentSceneFlags[globalCtx->sceneNum].unk_14 & 7; +s32 func_80959524(PlayState* play) { + return gSaveContext.save.permanentSceneFlags[play->sceneNum].unk_14 & 7; } -void func_8095954C(EnMk* this, GlobalContext* globalCtx) { - if (Cutscene_CheckActorAction(globalCtx, 0x7F)) { - Cutscene_ActorTranslateAndYaw(&this->actor, globalCtx, Cutscene_GetActorActionIndex(globalCtx, 0x7F)); +void func_8095954C(EnMk* this, PlayState* play) { + if (Cutscene_CheckActorAction(play, 0x7F)) { + Cutscene_ActorTranslateAndYaw(&this->actor, play, Cutscene_GetActorActionIndex(play, 0x7F)); - switch (globalCtx->csCtx.actorActions[Cutscene_GetActorActionIndex(globalCtx, 0x7F)]->action) { + switch (play->csCtx.actorActions[Cutscene_GetActorActionIndex(play, 0x7F)]->action) { case 1: case 2: case 3: case 4: case 5: - func_809592E0(this, - globalCtx->csCtx.actorActions[Cutscene_GetActorActionIndex(globalCtx, 0x7F)]->action - 1); + func_809592E0(this, play->csCtx.actorActions[Cutscene_GetActorActionIndex(play, 0x7F)]->action - 1); break; } } else { @@ -142,7 +141,7 @@ void func_8095954C(EnMk* this, GlobalContext* globalCtx) { } } -void func_80959624(EnMk* this, GlobalContext* globalCtx) { +void func_80959624(EnMk* this, PlayState* play) { u16 textId; if (gSaveContext.save.playerForm == PLAYER_FORM_ZORA) { @@ -156,58 +155,58 @@ void func_80959624(EnMk* this, GlobalContext* globalCtx) { } else { textId = 0xFBA; } - Message_StartTextbox(globalCtx, textId, &this->actor); + Message_StartTextbox(play, textId, &this->actor); } -void func_809596A0(EnMk* this, GlobalContext* globalCtx) { +void func_809596A0(EnMk* this, PlayState* play) { SkelAnime_Update(&this->skelAnime); - if ((globalCtx->msgCtx.currentTextId == 0xFB9) || (globalCtx->msgCtx.currentTextId == 0xFBB) || - (globalCtx->msgCtx.currentTextId == 0xFBC)) { + if ((play->msgCtx.currentTextId == 0xFB9) || (play->msgCtx.currentTextId == 0xFBB) || + (play->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); + switch (Message_GetState(&play->msgCtx)) { + case TEXT_STATE_5: + if (Message_ShouldAdvance(play)) { + func_801477B4(play); this->actionFunc = func_80959774; } break; - case 2: + case TEXT_STATE_CLOSING: this->actionFunc = func_80959774; break; } } -void func_80959774(EnMk* this, GlobalContext* globalCtx) { +void func_80959774(EnMk* this, PlayState* play) { 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); + if (Actor_ProcessTalkRequest(&this->actor, &play->state)) { + func_80959624(this, play); this->actionFunc = func_809596A0; - } else if ((this->actor.xzDistToPlayer < 120.0f) && Player_IsFacingActor(&this->actor, 0x3000, globalCtx)) { - func_800B8614(&this->actor, globalCtx, 130.0f); + } else if ((this->actor.xzDistToPlayer < 120.0f) && Player_IsFacingActor(&this->actor, 0x3000, play)) { + func_800B8614(&this->actor, play, 130.0f); } - func_8095954C(this, globalCtx); + func_8095954C(this, play); } -void func_80959844(EnMk* this, GlobalContext* globalCtx) { +void func_80959844(EnMk* this, PlayState* play) { u16 textId; - if ((this->unk_27A & 2) && (func_80959524(globalCtx) >= 7)) { + if ((this->unk_27A & 2) && (func_80959524(play) >= 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) { + } else if (func_80959524(play) >= 7) { textId = 0xFB3; } else { switch (gSaveContext.save.playerForm) { @@ -237,7 +236,7 @@ void func_80959844(EnMk* this, GlobalContext* globalCtx) { case PLAYER_FORM_FIERCE_DEITY: case PLAYER_FORM_HUMAN: - if (func_80959524(globalCtx) > 0) { + if (func_80959524(play) > 0) { textId = 0xFA7; } else if (gSaveContext.save.weekEventReg[19] & 4) { if (gSaveContext.save.weekEventReg[55] & 0x80) { @@ -251,7 +250,7 @@ void func_80959844(EnMk* this, GlobalContext* globalCtx) { break; default: - if (func_80959524(globalCtx) > 0) { + if (func_80959524(play) > 0) { textId = 0xFB0; } else if (gSaveContext.save.weekEventReg[19] & 0x20) { textId = 0xFB2; @@ -261,35 +260,35 @@ void func_80959844(EnMk* this, GlobalContext* globalCtx) { break; } } - Message_StartTextbox(globalCtx, textId, &this->actor); + Message_StartTextbox(play, textId, &this->actor); } -void func_80959A24(EnMk* this, GlobalContext* globalCtx) { +void func_80959A24(EnMk* this, PlayState* play) { SkelAnime_Update(&this->skelAnime); this->unk_27A |= 1; - switch (Message_GetState(&globalCtx->msgCtx)) { - case 2: + switch (Message_GetState(&play->msgCtx)) { + case TEXT_STATE_CLOSING: break; - case 5: - if (Message_ShouldAdvance(globalCtx)) { - switch (globalCtx->msgCtx.currentTextId) { + case TEXT_STATE_5: + if (Message_ShouldAdvance(play)) { + switch (play->msgCtx.currentTextId) { case 0xFA1: case 0xFA3: case 0xFA4: case 0xFAA: case 0xFAE: - func_80151938(globalCtx, globalCtx->msgCtx.currentTextId + 1); + func_80151938(play, play->msgCtx.currentTextId + 1); break; case 0xFA2: if (gSaveContext.save.weekEventReg[55] & 0x80) { - func_801477B4(globalCtx); + func_801477B4(play); this->actionFunc = func_80959E18; break; } - func_80151938(globalCtx, globalCtx->msgCtx.currentTextId + 1); + func_80151938(play, play->msgCtx.currentTextId + 1); break; case 0xFA5: @@ -304,53 +303,53 @@ void func_80959A24(EnMk* this, GlobalContext* globalCtx) { case 0xFBD: case 0xFBE: case 0xFBF: - func_801477B4(globalCtx); + func_801477B4(play); this->actionFunc = func_80959E18; break; case 0xFA0: gSaveContext.save.weekEventReg[19] |= 4; - func_80151938(globalCtx, 0xFA1); + func_80151938(play, 0xFA1); break; case 0xFA8: gSaveContext.save.weekEventReg[19] |= 8; if (gSaveContext.save.weekEventReg[55] & 0x80) { - func_80151938(globalCtx, 0xFBD); + func_80151938(play, 0xFBD); break; } - func_80151938(globalCtx, 0xFA9); + func_80151938(play, 0xFA9); break; case 0xFAC: gSaveContext.save.weekEventReg[19] |= 0x10; if (gSaveContext.save.weekEventReg[55] & 0x80) { - func_80151938(globalCtx, 0xFBE); + func_80151938(play, 0xFBE); break; } - func_80151938(globalCtx, 0xFAD); + func_80151938(play, 0xFAD); break; case 0xFB1: gSaveContext.save.weekEventReg[19] |= 0x20; - func_801477B4(globalCtx); + func_801477B4(play); this->actionFunc = func_80959E18; break; case 0xFB3: case 0xFB4: - func_801477B4(globalCtx); + func_801477B4(play); this->actionFunc = func_80959E18; this->actor.flags &= ~ACTOR_FLAG_10000; break; case 0xFB5: - func_801477B4(globalCtx); + func_801477B4(play); this->actionFunc = func_80959E18; break; default: - func_801477B4(globalCtx); + func_801477B4(play); this->actionFunc = func_80959E18; break; } @@ -359,21 +358,21 @@ void func_80959A24(EnMk* this, GlobalContext* globalCtx) { } } -void func_80959C94(EnMk* this, GlobalContext* globalCtx) { - if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { +void func_80959C94(EnMk* this, PlayState* play) { + if (Actor_ProcessTalkRequest(&this->actor, &play->state)) { this->actionFunc = func_80959A24; this->unk_27A &= ~2; - Message_StartTextbox(globalCtx, 0xFB3, &this->actor); + Message_StartTextbox(play, 0xFB3, &this->actor); } else { this->actor.flags |= ACTOR_FLAG_10000; - func_800B8500(&this->actor, globalCtx, 350.0f, 1000.0f, -1); + func_800B8500(&this->actor, play, 350.0f, 1000.0f, PLAYER_AP_MINUS1); } } -void func_80959D28(EnMk* this, GlobalContext* globalCtx) { +void func_80959D28(EnMk* this, PlayState* play) { SkelAnime_Update(&this->skelAnime); - if ((globalCtx->csCtx.state == 0) && (this->actor.cutscene == -1)) { + if ((play->csCtx.state == 0) && (this->actor.cutscene == -1)) { if (gSaveContext.save.weekEventReg[20] & 0x40) { this->unk_27A &= ~1; this->actionFunc = func_80959774; @@ -392,11 +391,11 @@ void func_80959D28(EnMk* this, GlobalContext* globalCtx) { ActorCutscene_SetIntentToPlay(this->actor.cutscene); } } - func_8095954C(this, globalCtx); + func_8095954C(this, play); } } -void func_80959E18(EnMk* this, GlobalContext* globalCtx) { +void func_80959E18(EnMk* this, PlayState* play) { s32 pad; s16 sp22 = this->actor.yawTowardsPlayer - this->actor.shape.rot.y; @@ -409,56 +408,56 @@ void func_80959E18(EnMk* this, GlobalContext* globalCtx) { return; } - if (func_800B8718(&this->actor, &globalCtx->state)) { - globalCtx->msgCtx.ocarinaMode = 4; + if (func_800B8718(&this->actor, &play->state)) { + play->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); + Item_Give(play, 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); + } else if (Actor_ProcessTalkRequest(&this->actor, &play->state)) { + func_80959844(this, play); this->actionFunc = func_80959A24; this->unk_27A |= 1; - } else if ((this->unk_27A & 2) && (func_80959524(globalCtx) >= 7)) { + } else if ((this->unk_27A & 2) && (func_80959524(play) >= 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); + func_800B8614(&this->actor, play, 200.0f); if (!(gSaveContext.save.weekEventReg[20] & 0x40) && (gSaveContext.save.weekEventReg[19] & 0x40)) { - func_800B874C(&this->actor, globalCtx, 200.0f, 100.0f); + func_800B874C(&this->actor, play, 200.0f, 100.0f); } } else { this->unk_27A &= ~1; } - func_8095954C(this, globalCtx); + func_8095954C(this, play); } -void EnMk_Update(Actor* thisx, GlobalContext* globalCtx) { +void EnMk_Update(Actor* thisx, PlayState* play) { s32 pad; EnMk* this = THIS; Vec3s sp38; Collider_UpdateCylinder(&this->actor, &this->collider); - CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + CollisionCheck_SetOC(play, &play->colChkCtx, &this->collider.base); Actor_MoveWithGravity(&this->actor); - Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 0.0f, 0.0f, 0.0f, 4); + Actor_UpdateBgCheckInfo(play, &this->actor, 0.0f, 0.0f, 0.0f, 4); - this->actionFunc(this, globalCtx); + this->actionFunc(this, play); - if ((this->unk_27A & 1) && !Cutscene_CheckActorAction(globalCtx, 0x7F)) { - func_800E9250(globalCtx, &this->actor, &this->unk_270, &sp38, this->actor.focus.pos); + if ((this->unk_27A & 1) && !Cutscene_CheckActorAction(play, 0x7F)) { + Actor_TrackPlayer(play, &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) { +s32 EnMk_OverrideLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, Actor* thisx) { EnMk* this = THIS; if (limbIndex == OBJECT_MK_LIMB_0B) { @@ -470,18 +469,18 @@ s32 EnMk_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f D_8095A2A0 = { 1000.0f, -100.0f, 0.0f }; -void EnMk_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx) { +void EnMk_PostLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx) { EnMk* this = THIS; if (limbIndex == OBJECT_MK_LIMB_0B) { - Matrix_MultiplyVector3fByState(&D_8095A2A0, &this->actor.focus.pos); + Matrix_MultVec3f(&D_8095A2A0, &this->actor.focus.pos); } } -void EnMk_Draw(Actor* thisx, GlobalContext* globalCtx) { +void EnMk_Draw(Actor* thisx, PlayState* play) { EnMk* this = THIS; - func_8012C28C(globalCtx->state.gfxCtx); - SkelAnime_DrawFlexOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, + func_8012C28C(play->state.gfxCtx); + SkelAnime_DrawFlexOpa(play, 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 fee132ccd..ed6cd6997 100644 --- a/src/overlays/actors/ovl_En_Mk/z_en_mk.h +++ b/src/overlays/actors/ovl_En_Mk/z_en_mk.h @@ -6,19 +6,19 @@ struct EnMk; -typedef void (*EnMkActionFunc)(struct EnMk*, GlobalContext*); +typedef void (*EnMkActionFunc)(struct EnMk*, PlayState*); typedef struct EnMk { - /* 0x0000 */ Actor actor; - /* 0x0144 */ ColliderCylinder collider; - /* 0x0190 */ SkelAnime skelAnime; - /* 0x01D4 */ Vec3s jointTable[OBJECT_MK_LIMB_MAX]; - /* 0x0222 */ Vec3s morphTable[OBJECT_MK_LIMB_MAX]; - /* 0x0270 */ Vec3s unk_270; - /* 0x0276 */ s16 unk_276[2]; - /* 0x027A */ u16 unk_27A; - /* 0x027C */ s16 unk_27C; - /* 0x0280 */ EnMkActionFunc actionFunc; + /* 0x000 */ Actor actor; + /* 0x144 */ ColliderCylinder collider; + /* 0x190 */ SkelAnime skelAnime; + /* 0x1D4 */ Vec3s jointTable[OBJECT_MK_LIMB_MAX]; + /* 0x222 */ Vec3s morphTable[OBJECT_MK_LIMB_MAX]; + /* 0x270 */ Vec3s unk_270; + /* 0x276 */ s16 unk_276[2]; + /* 0x27A */ u16 unk_27A; + /* 0x27C */ s16 unk_27C; + /* 0x280 */ EnMkActionFunc actionFunc; } EnMk; // size = 0x284 extern const ActorInit En_Mk_InitVars; diff --git a/src/overlays/actors/ovl_En_Mkk/z_en_mkk.c b/src/overlays/actors/ovl_En_Mkk/z_en_mkk.c index 45eff8050..c8cc1abb1 100644 --- a/src/overlays/actors/ovl_En_Mkk/z_en_mkk.c +++ b/src/overlays/actors/ovl_En_Mkk/z_en_mkk.c @@ -5,25 +5,36 @@ */ #include "z_en_mkk.h" +#include "objects/object_mkk/object_mkk.h" #define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_4) #define THIS ((EnMkk*)thisx) -void EnMkk_Init(Actor* thisx, GlobalContext* globalCtx); -void EnMkk_Destroy(Actor* thisx, GlobalContext* globalCtx); -void EnMkk_Update(Actor* thisx, GlobalContext* globalCtx); -void EnMkk_Draw(Actor* thisx, GlobalContext* globalCtx); +void EnMkk_Init(Actor* thisx, PlayState* play); +void EnMkk_Destroy(Actor* thisx, PlayState* play); +void EnMkk_Update(Actor* thisx, PlayState* play); +void EnMkk_Draw(Actor* thisx, PlayState* play); -void func_80A4E100(EnMkk* this, GlobalContext* globalCtx); -void func_80A4E1F0(EnMkk* this, GlobalContext* globalCtx); -void func_80A4E2E8(EnMkk* this, GlobalContext* globalCtx); -void func_80A4E60C(EnMkk* this, GlobalContext* globalCtx); -void func_80A4E72C(EnMkk* this, GlobalContext* globalCtx); -void func_80A4EE48(EnMkk* this, GlobalContext* globalCtx); -void func_80A4EF74(EnMkk* this, GlobalContext* globalCtx); +void func_80A4E100(EnMkk* this, PlayState* play); +void func_80A4E1F0(EnMkk* this, PlayState* play); +void func_80A4E2E8(EnMkk* this, PlayState* play); +void func_80A4E60C(EnMkk* this, PlayState* play); +void func_80A4E72C(EnMkk* this, PlayState* play); +void func_80A4EE48(EnMkk* this, PlayState* play); +void func_80A4EF74(EnMkk* this, PlayState* play); +void func_80A4E0CC(EnMkk* this); +void func_80A4E190(EnMkk* this); +void func_80A4E2B8(EnMkk* this); +void func_80A4E58C(EnMkk* this); +void func_80A4EDF0(EnMkk* this); +void func_80A4EEF4(EnMkk* this); +void func_80A4F16C(Actor* thisx, PlayState* play); +void func_80A4F4C8(Actor* thisx, PlayState* play); +void func_80A4E67C(EnMkk* this); +void func_80A4E84C(EnMkk* this); +void func_80A4EBBC(EnMkk* this, PlayState* play); -#if 0 const ActorInit En_Mkk_InitVars = { ACTOR_EN_MKK, ACTORCAT_ENEMY, @@ -36,18 +47,36 @@ const ActorInit En_Mkk_InitVars = { (ActorFunc)EnMkk_Draw, }; -// static ColliderSphereInit sSphereInit = { -static ColliderSphereInit D_80A4F720 = { - { COLTYPE_HIT3, AT_NONE | AT_TYPE_ENEMY, AC_NONE | AC_TYPE_PLAYER, OC1_ON | OC1_TYPE_ALL, OC2_TYPE_1, COLSHAPE_SPHERE, }, - { ELEMTYPE_UNK0, { 0xF7CFFFFF, 0x00, 0x04 }, { 0xF7CFFFFF, 0x00, 0x00 }, TOUCH_ON | TOUCH_SFX_HARD, BUMP_ON, OCELEM_ON, }, +static ColliderSphereInit sSphereInit = { + { + COLTYPE_HIT3, + AT_NONE | AT_TYPE_ENEMY, + AC_NONE | AC_TYPE_PLAYER, + OC1_ON | OC1_TYPE_ALL, + OC2_TYPE_1, + COLSHAPE_SPHERE, + }, + { + ELEMTYPE_UNK0, + { 0xF7CFFFFF, 0x00, 0x04 }, + { 0xF7CFFFFF, 0x00, 0x00 }, + TOUCH_ON | TOUCH_SFX_HARD, + BUMP_ON, + OCELEM_ON, + }, { 1, { { 0, 0, 0 }, 15 }, 100 }, }; -// sColChkInfoInit -static CollisionCheckInfoInit D_80A4F74C = { 1, 15, 30, 10 }; +typedef struct EnMkkDlists { + /* 0x00 */ Gfx* unk0; + /* 0x04 */ Gfx* unk4; + /* 0x08 */ Gfx* unk8; + /* 0x0C */ Gfx* unkC; +} EnMkkDlists; // size = 0x10 -// static DamageTable sDamageTable = { -static DamageTable D_80A4F754 = { +static CollisionCheckInfoInit sColChkInfoInit = { 1, 15, 30, 10 }; + +static DamageTable sDamageTable = { /* Deku Nut */ DMG_ENTRY(1, 0x0), /* Deku Stick */ DMG_ENTRY(1, 0x0), /* Horse trample */ DMG_ENTRY(1, 0x0), @@ -82,62 +111,499 @@ static DamageTable D_80A4F754 = { /* Powder Keg */ DMG_ENTRY(1, 0x0), }; -// static InitChainEntry sInitChain[] = { -static InitChainEntry D_80A4F774[] = { +static InitChainEntry sInitChain[] = { ICHAIN_F32_DIV1000(gravity, -500, ICHAIN_CONTINUE), ICHAIN_F32(terminalVelocity, -5, ICHAIN_CONTINUE), ICHAIN_F32(targetArrowOffset, 3000, ICHAIN_STOP), }; -#endif +static Color_RGBA8 D_80A4F780 = { 250, 250, 250, 255 }; -extern ColliderSphereInit D_80A4F720; -extern CollisionCheckInfoInit D_80A4F74C; -extern DamageTable D_80A4F754; -extern InitChainEntry D_80A4F774[]; +static Color_RGBA8 D_80A4F784 = { 180, 180, 180, 255 }; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Mkk/EnMkk_Init.s") +static Vec3f D_80A4F788 = { 0.0f, 0.45f, 0.0f }; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Mkk/EnMkk_Destroy.s") +static Color_RGBA8 sEffPrimColors[] = { { 50, 50, 50, 255 }, { 255, 255, 255, 255 } }; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Mkk/func_80A4E0CC.s") +static Color_RGBA8 sEffEnvColors[] = { { 200, 200, 200, 255 }, { 255, 255, 255, 255 } }; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Mkk/func_80A4E100.s") +static EnMkkDlists sBoeDLists[] = { + { object_mkk_DL_000030, object_mkk_DL_0000B0, object_mkk_DL_0000C8, object_mkk_DL_000140 }, + { object_mkk_DL_0001F0, object_mkk_DL_000278, object_mkk_DL_000290, object_mkk_DL_000310 }, +}; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Mkk/func_80A4E190.s") +static Color_RGBA8 D_80A4F7C4[] = { + { 255, 255, 255, 255 }, { 128, 128, 128, 255 }, { 0, 0, 0, 255 }, + { 0, 0, 0, 255 }, { 128, 128, 128, 255 }, { 255, 255, 255, 255 }, +}; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Mkk/func_80A4E1F0.s") +void EnMkk_Init(Actor* thisx, PlayState* play) { + EnMkk* this = THIS; + s32 paramsFF00; + s32 params2; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Mkk/func_80A4E22C.s") + Actor_ProcessInitChain(&this->actor, sInitChain); + Collider_InitAndSetSphere(play, &this->collider, &this->actor, &sSphereInit); + this->collider.dim.worldSphere.radius = sSphereInit.dim.modelSphere.radius; + CollisionCheck_SetInfo(&this->actor.colChkInfo, &sDamageTable, &sColChkInfoInit); + ActorShape_Init(&this->actor.shape, 1000.0f, NULL, 0.0f); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Mkk/func_80A4E2B8.s") + this->primColorSelect = 0; + this->unk_149 = 0; + this->unk_152 = (this->actor.shape.rot.x >= 0) ? this->actor.shape.rot.x : this->actor.shape.rot.x * -0x50; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Mkk/func_80A4E2E8.s") + this->unk_14C = CLAMP(this->actor.shape.rot.z, 0, 16); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Mkk/func_80A4E58C.s") + this->actor.shape.rot.z = 0; + this->actor.world.rot.z = 0; + this->actor.shape.rot.x = 0; + this->actor.world.rot.x = 0; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Mkk/func_80A4E60C.s") + Math_Vec3f_Copy(&this->unk_154, &this->actor.world.pos); + Math_Vec3f_Copy(&this->unk_160, &this->actor.world.pos); + this->unk_14B = ENMKK_GET_4(thisx) ? 8 : 0; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Mkk/func_80A4E67C.s") + paramsFF00 = ENMKK_GET_FF00(&this->actor); + params2 = ENMKK_GET_2(&this->actor); + this->actor.params &= 1; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Mkk/func_80A4E72C.s") + if (this->actor.params == 1) { + this->actor.hintId = 0x3C; + } else { + this->actor.hintId = 0x2C; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Mkk/func_80A4E84C.s") + if ((paramsFF00 == 0) || (paramsFF00 == 255)) { + func_80A4E0CC(this); + this->unk_178 = 30000.0f; + if (params2 > 0) { + this->unk_14B |= 4; + } + } else { + this->unk_178 = paramsFF00 * 40.0f * 0.1f; + func_80A4EDF0(this); + this->unk_14E = 0; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Mkk/func_80A4EBBC.s") +void EnMkk_Destroy(Actor* thisx, PlayState* play) { + EnMkk* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Mkk/EnMkk_Update.s") + Collider_DestroySphere(play, &this->collider); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Mkk/func_80A4EDF0.s") +void func_80A4E0CC(EnMkk* this) { + this->alpha = 0; + this->unk_14B |= 3; + this->actor.flags &= ~ACTOR_FLAG_1; + this->actionFunc = func_80A4E100; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Mkk/func_80A4EE48.s") +void func_80A4E100(EnMkk* this, PlayState* play) { + s32 newAlpha; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Mkk/func_80A4EEF4.s") + if (this->unk_14B & 4) { + newAlpha = this->alpha + 15; + } else { + newAlpha = this->alpha + 5; + } + if (newAlpha >= 255) { + this->primColorSelect = 3; + this->collider.base.acFlags |= AC_ON; + this->alpha = 255; + this->actor.flags |= ACTOR_FLAG_1; + this->actor.shape.rot.y = this->actor.yawTowardsPlayer; + this->unk_14B &= ~4; + func_80A4E190(this); + } else { + this->alpha = newAlpha; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Mkk/func_80A4EF74.s") +void func_80A4E190(EnMkk* this) { + this->unk_14E = (s32)(Rand_ZeroOne() * 20.0f) + 10; + if (this->unk_149 != 0) { + this->unk_149--; + } + this->actionFunc = func_80A4E1F0; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Mkk/func_80A4F16C.s") +void func_80A4E1F0(EnMkk* this, PlayState* play) { + this->unk_14E--; + if (this->unk_14E == 0) { + func_80A4E2B8(this); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Mkk/EnMkk_Draw.s") +void func_80A4E22C(EnMkk* this, PlayState* play) { + Vec3f pos; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Mkk/func_80A4F4C8.s") + pos.x = this->actor.world.pos.x; + pos.y = this->actor.world.pos.y + 15.0f; + pos.z = this->actor.world.pos.z; + func_800B0DE0(play, &pos, &gZeroVec3f, &D_80A4F788, &D_80A4F780, &D_80A4F784, 350, 20); +} + +void func_80A4E2B8(EnMkk* this) { + this->unk_14E = 30; + this->unk_150 = this->actor.shape.rot.y; + this->unk_14B &= ~1; + this->actionFunc = func_80A4E2E8; +} + +void func_80A4E2E8(EnMkk* this, PlayState* play) { + Player* player = GET_PLAYER(play); + s32 sp20; + + this->unk_14E--; + if ((this->actor.params == 1) && (this->actor.bgCheckFlags & 1) && (this->actor.speedXZ > 2.5f) && + ((play->gameplayFrames % 3) == 0)) { + func_80A4E22C(this, play); + } + if (this->unk_14E > 0) { + Math_StepToF(&this->actor.speedXZ, 5.0f, 0.7f); + sp20 = false; + } else { + sp20 = Math_StepToF(&this->actor.speedXZ, 0.0f, 0.7f); + } + if ((player->stateFlags3 & 0x100) || (Player_GetMask(play) == PLAYER_MASK_STONE)) { + Math_ScaledStepToS(&this->unk_150, Actor_YawToPoint(&this->actor, &this->actor.home.pos), 0x400); + } else if ((player->stateFlags2 & 0x80) || (player->actor.freezeTimer > 0)) { + Math_ScaledStepToS(&this->unk_150, this->actor.yawTowardsPlayer + 0x8000, 0x400); + } else { + Math_ScaledStepToS(&this->unk_150, this->actor.yawTowardsPlayer, 0x400); + } + this->actor.shape.rot.y = + (s32)(sin_rad(this->unk_14E * ((2 * M_PI) / 15)) * (614.4f * this->actor.speedXZ)) + this->unk_150; + func_800B9010(&this->actor, NA_SE_EN_KUROSUKE_MOVE - SFX_FLAG); + if (sp20) { + this->unk_14B &= ~2; + func_80A4E190(this); + } else if ((this->unk_149 == 0) && (!(player->stateFlags3 & 0x100)) && + (Player_GetMask(play) != PLAYER_MASK_STONE) && (this->actor.bgCheckFlags & 1) && + (Actor_IsFacingPlayer(&this->actor, 0x1800)) && (this->actor.xzDistToPlayer < 120.0f) && + (fabsf(this->actor.playerHeightRel) < 100.0f)) { + func_80A4E58C(this); + } +} + +void func_80A4E58C(EnMkk* this) { + this->unk_14B |= 1; + this->actor.speedXZ = 3.0f; + this->actor.velocity.y = 5.0f; + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_KUROSUKE_ATTACK); + this->collider.base.atFlags |= AT_ON; + Math_ScaledStepToS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer, 0x800); + this->actionFunc = func_80A4E60C; +} + +void func_80A4E60C(EnMkk* this, PlayState* play) { + if (this->collider.base.atFlags & AT_HIT) { + this->collider.base.atFlags &= ~(AT_ON | AT_HIT); + } + if ((this->actor.velocity.y < 0.0f) && (this->actor.bgCheckFlags & 1)) { + this->unk_149 = 2; + this->collider.base.atFlags &= ~AT_ON; + func_80A4E2B8(this); + } +} + +void func_80A4E67C(EnMkk* this) { + this->unk_14B |= 1; + this->actor.flags &= ~ACTOR_FLAG_1; + this->collider.base.acFlags &= ~AC_ON; + this->actor.flags |= ACTOR_FLAG_10; + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_PO_DEAD); + this->alpha = 254; + func_800BE568(&this->actor, &this->collider); + this->actor.speedXZ = 7.0f; + this->actor.shape.rot.y = this->actor.world.rot.y; + this->actor.velocity.y = 5.0f; + this->actor.gravity = -1.3f; + this->actor.bgCheckFlags &= ~1; + this->actionFunc = func_80A4E72C; +} + +void func_80A4E72C(EnMkk* this, PlayState* play) { + Vec3f temp; + + if (this->actor.bgCheckFlags & 1) { + if (this->actor.velocity.y > -1.0f) { + temp.x = this->actor.world.pos.x; + temp.y = this->actor.world.pos.y + 15.0f; + temp.z = this->actor.world.pos.z; + EffectSsDeadDb_Spawn(play, &temp, &gZeroVec3f, &gZeroVec3f, &sEffPrimColors[this->actor.params], + &sEffEnvColors[this->actor.params], 0x46, 4, 0xC); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_EXTINCT); + if (this->unk_14C != 0) { + Item_DropCollectibleRandom(play, &this->actor, &this->actor.world.pos, this->unk_14C * 0x10); + } + func_80A4EEF4(this); + } else { + this->actor.velocity.y *= -0.8f; + this->actor.bgCheckFlags &= ~1; + } + } +} + +void func_80A4E84C(EnMkk* this) { + if (this->unk_14B & 3) { + Vec3f sp34; + f32 temp_fv0 = Math_Vec3f_DistXYZ(&this->actor.world.pos, &this->actor.prevPos); + + Math_Vec3f_Copy(&sp34, &this->unk_154); + if (temp_fv0 < 0.001f) { + Math_Vec3f_Copy(&this->unk_154, &this->actor.prevPos); + } else { + temp_fv0 = 1.0f / temp_fv0; + + this->unk_154.x = + ((this->actor.prevPos.x - this->actor.world.pos.x) * temp_fv0 * 10.0f) + this->actor.world.pos.x; + this->unk_154.y = + ((this->actor.prevPos.y - this->actor.world.pos.y) * temp_fv0 * 10.0f) + this->actor.world.pos.y; + this->unk_154.z = + ((this->actor.prevPos.z - this->actor.world.pos.z) * temp_fv0 * 10.0f) + this->actor.world.pos.z; + } + temp_fv0 = Math_Vec3f_DistXYZ(&this->unk_154, &sp34); + if (temp_fv0 < 0.001f) { + Math_Vec3f_Copy(&this->unk_160, &sp34); + } else { + temp_fv0 = 1.0f / temp_fv0; + + this->unk_160.x = ((sp34.x - this->unk_154.x) * temp_fv0 * 12.0f) + this->unk_154.x; + this->unk_160.y = ((sp34.y - this->unk_154.y) * temp_fv0 * 12.0f) + this->unk_154.y; + this->unk_160.z = ((sp34.z - this->unk_154.z) * temp_fv0 * 12.0f) + this->unk_154.z; + } + } else { + this->unk_160.y = this->unk_154.y; + this->unk_154.y = this->actor.world.pos.y; + this->unk_154.x = this->actor.world.pos.x - + 10.0f * Math_SinS(this->actor.shape.rot.y + + (s32)(1228.8f * this->actor.speedXZ * sin_rad(this->unk_14E * (M_PI / 5)))); + this->unk_154.z = this->actor.world.pos.z - + 10.0f * Math_CosS(this->actor.shape.rot.y + + (s32)(1228.8f * this->actor.speedXZ * sin_rad(this->unk_14E * (M_PI / 5)))); + this->unk_160.x = this->unk_154.x - + 12.0f * Math_SinS(this->actor.shape.rot.y - + (s32)(1228.8f * this->actor.speedXZ * sin_rad(this->unk_14E * (M_PI / 5)))); + this->unk_160.z = this->unk_154.z - + 12.0f * Math_CosS(this->actor.shape.rot.y - + (s32)(1228.8f * this->actor.speedXZ * sin_rad(this->unk_14E * (M_PI / 5)))); + } +} + +void func_80A4EBBC(EnMkk* this, PlayState* play) { + if (this->collider.base.acFlags & AC_HIT) { + this->collider.base.acFlags &= ~AC_HIT; + Actor_SetDropFlag(&this->actor, &this->collider.info); + Enemy_StartFinishingBlow(play, &this->actor); + func_80A4E67C(this); + } +} + +void EnMkk_Update(Actor* thisx, PlayState* play) { + s32 pad; + Player* player; + EnMkk* this = THIS; + + if (this->primColorSelect > 0) { + this->primColorSelect--; + } else if ((Rand_ZeroOne() < 0.075f) && (this->actor.params != 1)) { + this->primColorSelect = 6; + } + func_80A4EBBC(this, play); + this->actionFunc(this, play); + this->actor.world.rot.y = this->actor.shape.rot.y; + Actor_MoveWithGravity(&this->actor); + Actor_UpdateBgCheckInfo(play, &this->actor, 20.0f, 20.0f, 20.0f, 0x1D); + if (this->actor.params == 0) { + func_80A4E84C(this); + } + if (Actor_IsFacingPlayer(&this->actor, 0x3000)) { + player = GET_PLAYER(play); + this->actor.shape.rot.x = Actor_PitchToPoint(&this->actor, &player->actor.focus.pos); + this->actor.shape.rot.x = CLAMP(this->actor.shape.rot.x, -0x1800, 0x1800); + } + Actor_SetFocus(&this->actor, 10.0f); + this->collider.dim.worldSphere.center.x = this->actor.focus.pos.x; + this->collider.dim.worldSphere.center.y = this->actor.focus.pos.y; + this->collider.dim.worldSphere.center.z = this->actor.focus.pos.z; + if (this->collider.base.atFlags & AT_ON) { + CollisionCheck_SetAT(play, &play->colChkCtx, &this->collider.base); + } + if (this->collider.base.acFlags & AT_ON) { + CollisionCheck_SetAC(play, &play->colChkCtx, &this->collider.base); + } + CollisionCheck_SetOC(play, &play->colChkCtx, &this->collider.base); +} + +void func_80A4EDF0(EnMkk* this) { + this->alpha = 0; + this->unk_14B |= 3; + this->actor.flags &= ~ACTOR_FLAG_1; + this->actor.draw = NULL; + this->actor.update = func_80A4F16C; + this->actor.gravity = -0.5f; + this->unk_14E = this->unk_152; + this->actionFunc = func_80A4EE48; +} + +void func_80A4EE48(EnMkk* this, PlayState* play) { + if (this->unk_14E > 0) { + this->unk_14E--; + if (this->unk_14E == 0) { + this->actor.flags &= ~ACTOR_FLAG_10; + } + } else if ((this->actor.xzDistToPlayer < this->unk_178) && (Player_GetMask(play) != PLAYER_MASK_STONE)) { + this->actor.update = EnMkk_Update; + this->actor.draw = EnMkk_Draw; + this->actor.flags &= ~ACTOR_FLAG_10; + func_80A4E0CC(this); + } +} + +void func_80A4EEF4(EnMkk* this) { + Math_Vec3f_Copy(&this->unk_16C, &this->actor.world.pos); + Math_Vec3f_Copy(&this->unk_154, &this->actor.world.pos); + Math_Vec3f_Copy(&this->unk_160, &this->actor.world.pos); + Actor_SetScale(&this->actor, 0.005f); + this->actor.update = func_80A4F16C; + this->actor.draw = func_80A4F4C8; + this->actionFunc = func_80A4EF74; +} + +void func_80A4EF74(EnMkk* this, PlayState* play) { + s32 newAlpha = this->alpha - 20; + + if (newAlpha <= 0) { + if (this->unk_14B & 8) { + Actor_SetScale(&this->actor, 0.01f); + this->primColorSelect = 0; + this->unk_149 = 0; + Math_Vec3f_Copy(&this->actor.world.pos, &this->actor.home.pos); + Math_Vec3f_Copy(&this->unk_154, &this->actor.world.pos); + Math_Vec3f_Copy(&this->unk_160, &this->actor.world.pos); + this->actor.speedXZ = 0.0f; + this->actor.velocity.y = 0.0f; + func_80A4EDF0(this); + } else { + Actor_MarkForDeath(&this->actor); + } + } else { + this->alpha = newAlpha; + this->actor.world.pos.x += 0.3f + (3.0f * Rand_ZeroOne()); + this->actor.world.pos.y += 0.5f + (3.5f * Rand_ZeroOne()); + this->unk_16C.x -= 0.3f + (3.0f * Rand_ZeroOne()); + this->unk_16C.y += 0.5f + (3.5f * Rand_ZeroOne()); + this->unk_154.z += 0.3f + (3.0f * Rand_ZeroOne()); + this->unk_154.y += 0.5f + (3.5f * Rand_ZeroOne()); + this->unk_160.z -= 0.3f + (3.0f * Rand_ZeroOne()); + this->unk_160.y += 0.5f + (3.5f * Rand_ZeroOne()); + } +} + +void func_80A4F16C(Actor* thisx, PlayState* play) { + EnMkk* this = THIS; + + this->actionFunc(this, play); +} + +void EnMkk_Draw(Actor* thisx, PlayState* play) { + EnMkkDlists* dLists = &sBoeDLists[thisx->params]; + Gfx* gfx; + Color_RGBA8* primColors; + EnMkk* this = THIS; + + if (this->actor.projectedPos.z > 0.0f) { + MtxF* matrix; + + OPEN_DISPS(play->state.gfxCtx); + + if (this->alpha == 255) { + primColors = &D_80A4F7C4[this->primColorSelect]; + gfx = POLY_OPA_DISP; + gSPDisplayList(&gfx[0], &sSetupDL[6 * 25]); + gDPSetPrimColor(&gfx[1], 0, 0xFF, primColors->r, primColors->g, primColors->b, primColors->a); + gSPSegment(&gfx[2], 0x08, D_801AEFA0); + gSPMatrix(&gfx[3], Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(&gfx[4], dLists->unkC); + POLY_OPA_DISP = &gfx[5]; + } + gfx = POLY_XLU_DISP; + gSPDisplayList(&gfx[0], &sSetupDL[6 * 25]); + gDPSetEnvColor(&gfx[1], 255, 255, 255, this->alpha); + gSPDisplayList(&gfx[2], dLists->unk0); + Matrix_ReplaceRotation(&play->billboardMtxF); + gSPMatrix(&gfx[3], Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(&gfx[4], dLists->unk4); + if (thisx->params == 0) { + matrix = Matrix_GetCurrent(); + matrix->mf[3][0] = this->unk_154.x; + matrix->mf[3][1] = this->unk_154.y + 8.5f; + matrix->mf[3][2] = this->unk_154.z; + + Matrix_Scale(0.85f, 0.85f, 0.85f, MTXMODE_APPLY); + gSPMatrix(&gfx[5], Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(&gfx[6], dLists->unk4); + + matrix->mf[3][0] = this->unk_160.x; + matrix->mf[3][1] = this->unk_160.y + 7.2250004f; + matrix->mf[3][2] = this->unk_160.z; + + Matrix_Scale(0.85f, 0.85f, 0.85f, MTXMODE_APPLY); + gSPMatrix(&gfx[7], Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(&gfx[8], dLists->unk4); + gSPDisplayList(&gfx[9], dLists->unk8); + + POLY_XLU_DISP = &gfx[10]; + } else { + gSPDisplayList(&gfx[5], dLists->unk8); + POLY_XLU_DISP = &gfx[6]; + } + } + CLOSE_DISPS(play->state.gfxCtx); +} + +void func_80A4F4C8(Actor* thisx, PlayState* play) { + s32 pad; + Gfx* gfx; + MtxF* matrix; + EnMkkDlists* dLists = &sBoeDLists[thisx->params]; + EnMkk* this = THIS; + + OPEN_DISPS(play->state.gfxCtx); + + gfx = POLY_XLU_DISP; + gSPDisplayList(&gfx[0], &sSetupDL[6 * 25]); + gDPSetEnvColor(&gfx[1], 255, 255, 255, this->alpha); + gSPDisplayList(&gfx[2], dLists->unk0); + Matrix_ReplaceRotation(&play->billboardMtxF); + gSPMatrix(&gfx[3], Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(&gfx[4], dLists->unk4); + + matrix = Matrix_GetCurrent(); + matrix->mf[3][0] = this->unk_154.x; + matrix->mf[3][1] = this->unk_154.y + 5.0f; + matrix->mf[3][2] = this->unk_154.z; + + gSPMatrix(&gfx[5], Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(&gfx[6], dLists->unk4); + + matrix->mf[3][0] = this->unk_160.x; + matrix->mf[3][1] = this->unk_160.y + 5.0f; + matrix->mf[3][2] = this->unk_160.z; + + gSPMatrix(&gfx[7], Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(&gfx[8], dLists->unk4); + + matrix->mf[3][0] = this->unk_16C.x; + matrix->mf[3][1] = this->unk_16C.y + 5.0f; + matrix->mf[3][2] = this->unk_16C.z; + + gSPMatrix(&gfx[9], Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(&gfx[10], dLists->unk4); + gSPDisplayList(&gfx[11], dLists->unk8); + POLY_XLU_DISP = &gfx[12]; + + CLOSE_DISPS(play->state.gfxCtx); +} diff --git a/src/overlays/actors/ovl_En_Mkk/z_en_mkk.h b/src/overlays/actors/ovl_En_Mkk/z_en_mkk.h index c80fc7a20..a8e047284 100644 --- a/src/overlays/actors/ovl_En_Mkk/z_en_mkk.h +++ b/src/overlays/actors/ovl_En_Mkk/z_en_mkk.h @@ -3,14 +3,30 @@ #include "global.h" +#define ENMKK_GET_2(thisx) ((thisx)->params & 2) +#define ENMKK_GET_4(thisx) ((thisx)->params & 4) +#define ENMKK_GET_FF00(thisx) (((thisx)->params >> 8) & 0xFF) + struct EnMkk; -typedef void (*EnMkkActionFunc)(struct EnMkk*, GlobalContext*); +typedef void (*EnMkkActionFunc)(struct EnMkk*, PlayState*); typedef struct EnMkk { - /* 0x0000 */ Actor actor; - /* 0x0144 */ EnMkkActionFunc actionFunc; - /* 0x0148 */ char unk_148[0x8C]; + /* 0x000 */ Actor actor; + /* 0x144 */ EnMkkActionFunc actionFunc; + /* 0x148 */ u8 primColorSelect; + /* 0x149 */ u8 unk_149; + /* 0x14A */ u8 alpha; + /* 0x14B */ u8 unk_14B; + /* 0x14C */ u8 unk_14C; + /* 0x14E */ s16 unk_14E; + /* 0x150 */ s16 unk_150; + /* 0x152 */ s16 unk_152; + /* 0x154 */ Vec3f unk_154; + /* 0x160 */ Vec3f unk_160; + /* 0x16C */ Vec3f unk_16C; + /* 0x178 */ f32 unk_178; + /* 0x17C */ ColliderSphere collider; } EnMkk; // size = 0x1D4 extern const ActorInit En_Mkk_InitVars; 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 5f79cf9e4..c24bf7601 100644 --- a/src/overlays/actors/ovl_En_Mm/z_en_mm.c +++ b/src/overlays/actors/ovl_En_Mm/z_en_mm.c @@ -11,14 +11,14 @@ #define THIS ((EnMm*)thisx) -void EnMm_Init(Actor* thisx, GlobalContext* globalCtx); -void EnMm_Destroy(Actor* thisx, GlobalContext* globalCtx); -void EnMm_Update(Actor* thisx, GlobalContext* globalCtx); -void EnMm_Draw(Actor* thisx, GlobalContext* globalCtx); +void EnMm_Init(Actor* thisx, PlayState* play); +void EnMm_Destroy(Actor* thisx, PlayState* play); +void EnMm_Update(Actor* thisx, PlayState* play); +void EnMm_Draw(Actor* thisx, PlayState* play); -void func_80965D3C(EnMm* this, GlobalContext* globalCtx); -void func_80965DB4(EnMm* this, GlobalContext* globalCtx); -void func_8096611C(EnMm* this, GlobalContext* globalCtx); +void func_80965D3C(EnMm* this, PlayState* play); +void func_80965DB4(EnMm* this, PlayState* play); +void func_8096611C(EnMm* this, PlayState* play); void EnMm_SetupAction(EnMm* this, EnMmActionFunc actionFunc); const ActorInit En_Mm_InitVars = { @@ -70,7 +70,7 @@ void func_80965BBC(EnMm* this) { } } -void EnMm_Init(Actor* thisx, GlobalContext* globalCtx) { +void EnMm_Init(Actor* thisx, PlayState* play) { EnMm* this = THIS; EnMmActionFunc action; @@ -81,8 +81,8 @@ void EnMm_Init(Actor* thisx, GlobalContext* globalCtx) { } Actor_ProcessInitChain(&this->actor, sInitChain); ActorShape_Init(&this->actor.shape, 50.0f, ActorShadow_DrawCircle, 1.2f); - Collider_InitCylinder(globalCtx, &this->collider); - Collider_SetCylinder(globalCtx, &this->collider, &this->actor, &sCylinderInit); + Collider_InitCylinder(play, &this->collider); + Collider_SetCylinder(play, &this->collider, &this->actor, &sCylinderInit); if (this->actor.parent != NULL) { func_80965BBC(this); return; @@ -95,13 +95,13 @@ void EnMm_Init(Actor* thisx, GlobalContext* globalCtx) { EnMm_SetupAction(this, action); } -void EnMm_Destroy(Actor* thisx, GlobalContext* globalCtx) { +void EnMm_Destroy(Actor* thisx, PlayState* play) { EnMm* this = THIS; - Collider_DestroyCylinder(globalCtx, &this->collider); + Collider_DestroyCylinder(play, &this->collider); } -void func_80965D3C(EnMm* this, GlobalContext* globalCtx) { +void func_80965D3C(EnMm* this, PlayState* play) { s16 cutscene = ActorCutscene_GetAdditionalCutscene(this->actor.cutscene); if (ActorCutscene_GetCanPlayNext(cutscene)) { @@ -112,7 +112,7 @@ void func_80965D3C(EnMm* this, GlobalContext* globalCtx) { } } -void func_80965DB4(EnMm* this, GlobalContext* globalCtx) { +void func_80965DB4(EnMm* this, PlayState* play) { s16 direction; Vec3f sp50; s16 unused; @@ -122,7 +122,7 @@ void func_80965DB4(EnMm* this, GlobalContext* globalCtx) { s32 angle; s32 pad; - if (Actor_HasParent(&this->actor, globalCtx)) { + if (Actor_HasParent(&this->actor, play)) { func_80965BBC(this); Actor_PlaySfxAtPos(&this->actor, NA_SE_PL_PULL_UP_ROCK); } else { @@ -134,7 +134,7 @@ void func_80965DB4(EnMm* this, GlobalContext* globalCtx) { angle = BINANG_SUB(this->actor.world.rot.y, BINANG_ROT180(this->actor.wallYaw)); this->actor.world.rot.y += BINANG_SUB(0x8000, (s16)(angle * 2)); this->actor.speedXZ *= 0.5f; - CollisionCheck_SpawnShieldParticles(globalCtx, &this->actor.world.pos); + CollisionCheck_SpawnShieldParticles(play, &this->actor.world.pos); Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_HUMAN_BOUND); } @@ -149,7 +149,7 @@ void func_80965DB4(EnMm* this, GlobalContext* globalCtx) { temp_f2 = sqrtf(SQ(temp_f14) + SQ(temp_f12)); if ((temp_f2 < this->actor.speedXZ) || - (SurfaceType_GetSlope(&globalCtx->colCtx, this->actor.floorPoly, this->actor.floorBgId) == 1)) { + (SurfaceType_GetSlope(&play->colCtx, this->actor.floorPoly, this->actor.floorBgId) == 1)) { this->actor.speedXZ = CLAMP_MAX(temp_f2, 16.0f); this->actor.world.rot.y = Math_FAtan2F(temp_f12, temp_f14); } @@ -171,7 +171,7 @@ void func_80965DB4(EnMm* this, GlobalContext* globalCtx) { Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_HUMAN_BOUND); } else { - Actor_PickUp(&this->actor, globalCtx, GI_NONE, 50.0f, 30.0f); + Actor_PickUp(&this->actor, play, GI_NONE, 50.0f, 30.0f); } } @@ -179,13 +179,13 @@ void func_80965DB4(EnMm* this, GlobalContext* globalCtx) { } Collider_UpdateCylinder(&this->actor, &this->collider); - CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + CollisionCheck_SetOC(play, &play->colChkCtx, &this->collider.base); } -void func_8096611C(EnMm* this, GlobalContext* globalCtx) { - if (Actor_HasNoParent(&this->actor, globalCtx)) { +void func_8096611C(EnMm* this, PlayState* play) { + if (Actor_HasNoParent(&this->actor, play)) { EnMm_SetupAction(this, func_80965DB4); - this->actor.room = globalCtx->roomCtx.currRoom.num; + this->actor.room = play->roomCtx.currRoom.num; this->actor.bgCheckFlags &= ~1; Math_Vec3s_ToVec3f(&this->actor.prevPos, &this->actor.home.rot); gSaveContext.unk_1014 = 0; @@ -195,28 +195,28 @@ void func_8096611C(EnMm* this, GlobalContext* globalCtx) { Math_ScaledStepToS(&this->unk_190, 0, 2000); } -void EnMm_Update(Actor* thisx, GlobalContext* globalCtx) { +void EnMm_Update(Actor* thisx, PlayState* play) { EnMm* this = THIS; - Collider_ResetCylinderAC(globalCtx, &this->collider.base); - this->actionFunc(this, globalCtx); - Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 20.0f, 10.0f, 20.0f, 31); + Collider_ResetCylinderAC(play, &this->collider.base); + this->actionFunc(this, play); + Actor_UpdateBgCheckInfo(play, &this->actor, 20.0f, 10.0f, 20.0f, 31); Actor_SetFocus(&this->actor, 20.0f); } -void EnMm_Draw(Actor* thisx, GlobalContext* globalCtx) { +void EnMm_Draw(Actor* thisx, PlayState* play) { EnMm* this = THIS; - OPEN_DISPS(globalCtx->state.gfxCtx); - func_8012C28C(globalCtx->state.gfxCtx); + OPEN_DISPS(play->state.gfxCtx); + func_8012C28C(play->state.gfxCtx); 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); + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_OPA_DISP++, gameplay_keep_DL_055628); - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->state.gfxCtx); } diff --git a/src/overlays/actors/ovl_En_Mm/z_en_mm.h b/src/overlays/actors/ovl_En_Mm/z_en_mm.h index d83ebc961..e278c8bfd 100644 --- a/src/overlays/actors/ovl_En_Mm/z_en_mm.h +++ b/src/overlays/actors/ovl_En_Mm/z_en_mm.h @@ -5,13 +5,13 @@ struct EnMm; -typedef void (*EnMmActionFunc)(struct EnMm*, GlobalContext*); +typedef void (*EnMmActionFunc)(struct EnMm*, PlayState*); typedef struct EnMm { - /* 0x0000 */ Actor actor; - /* 0x0144 */ ColliderCylinder collider; - /* 0x0190 */ s16 unk_190; - /* 0x0194 */ EnMmActionFunc actionFunc; + /* 0x000 */ Actor actor; + /* 0x144 */ ColliderCylinder collider; + /* 0x190 */ s16 unk_190; + /* 0x194 */ EnMmActionFunc actionFunc; } EnMm; // size = 0x198 #endif // Z_EN_MM_H diff --git a/src/overlays/actors/ovl_En_Mm2/z_en_mm2.c b/src/overlays/actors/ovl_En_Mm2/z_en_mm2.c index 79b4987e9..d049bdba0 100644 --- a/src/overlays/actors/ovl_En_Mm2/z_en_mm2.c +++ b/src/overlays/actors/ovl_En_Mm2/z_en_mm2.c @@ -10,13 +10,13 @@ #define THIS ((EnMm2*)thisx) -void EnMm2_Init(Actor* thisx, GlobalContext* globalCtx); -void EnMm2_Destroy(Actor* thisx, GlobalContext* globalCtx); -void EnMm2_Update(Actor* thisx, GlobalContext* globalCtx); -void EnMm2_Draw(Actor* thisx, GlobalContext* globalCtx); +void EnMm2_Init(Actor* thisx, PlayState* play); +void EnMm2_Destroy(Actor* thisx, PlayState* play); +void EnMm2_Update(Actor* thisx, PlayState* play); +void EnMm2_Draw(Actor* thisx, PlayState* play); -void EnMm2_Reading(EnMm2* this, GlobalContext* globalCtx); -void EnMm2_WaitForRead(EnMm2* this, GlobalContext* globalCtx); +void EnMm2_Reading(EnMm2* this, PlayState* play); +void EnMm2_WaitForRead(EnMm2* this, PlayState* play); const ActorInit En_Mm2_InitVars = { ACTOR_EN_MM2, @@ -32,29 +32,31 @@ const ActorInit En_Mm2_InitVars = { #include "overlays/ovl_En_Mm2/ovl_En_Mm2.c" -void EnMm2_Init(Actor* thisx, GlobalContext* globalCtx) { +void EnMm2_Init(Actor* thisx, PlayState* play) { EnMm2* this = THIS; Actor_SetScale(&this->actor, 0.015f); this->actionFunc = EnMm2_WaitForRead; } -void EnMm2_Destroy(Actor* thisx, GlobalContext* globalCtx) { +void EnMm2_Destroy(Actor* thisx, PlayState* play) { } /** * Action function whilst Link is reading the letter. */ -void EnMm2_Reading(EnMm2* this, GlobalContext* globalCtx) { - u8 talkState = Message_GetState(&globalCtx->msgCtx); +void EnMm2_Reading(EnMm2* this, PlayState* play) { + switch (Message_GetState(&play->msgCtx)) { + case TEXT_STATE_5: + if (Message_ShouldAdvance(play)) { + func_801477B4(play); + this->actionFunc = EnMm2_WaitForRead; + } + break; - if (talkState != 2) { - if (talkState == 5 && Message_ShouldAdvance(globalCtx)) { - func_801477B4(globalCtx); + case TEXT_STATE_CLOSING: this->actionFunc = EnMm2_WaitForRead; - } - } else { - this->actionFunc = EnMm2_WaitForRead; + break; } } @@ -62,27 +64,27 @@ void EnMm2_Reading(EnMm2* this, GlobalContext* globalCtx) { * Action function that awaits Link to read the letter, changing the A button to "Check" when he is within range to do * so (and facing the letter). */ -void EnMm2_WaitForRead(EnMm2* this, GlobalContext* globalCtx) { - if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { - Message_StartTextbox(globalCtx, 0x277B, &this->actor); +void EnMm2_WaitForRead(EnMm2* this, PlayState* play) { + if (Actor_ProcessTalkRequest(&this->actor, &play->state)) { + Message_StartTextbox(play, 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); + } else if ((this->actor.xzDistToPlayer < 60.0f) && (Player_IsFacingActor(&this->actor, 0x3000, play))) { + func_800B8614(&this->actor, play, 110.0f); } } -void EnMm2_Update(Actor* thisx, GlobalContext* globalCtx) { +void EnMm2_Update(Actor* thisx, PlayState* play) { EnMm2* this = THIS; - this->actionFunc(this, globalCtx); + this->actionFunc(this, play); } -void EnMm2_Draw(Actor* thisx, GlobalContext* globalCtx) { - OPEN_DISPS(globalCtx->state.gfxCtx); +void EnMm2_Draw(Actor* thisx, PlayState* play) { + OPEN_DISPS(play->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); + func_8012C28C(play->state.gfxCtx); + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_OPA_DISP++, sEnMm2DL); - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->state.gfxCtx); } diff --git a/src/overlays/actors/ovl_En_Mm2/z_en_mm2.h b/src/overlays/actors/ovl_En_Mm2/z_en_mm2.h index 9da10240d..1b3dcc0aa 100644 --- a/src/overlays/actors/ovl_En_Mm2/z_en_mm2.h +++ b/src/overlays/actors/ovl_En_Mm2/z_en_mm2.h @@ -5,13 +5,13 @@ struct EnMm2; -typedef void (*EnMm2ActionFunc)(struct EnMm2*, GlobalContext*); +typedef void (*EnMm2ActionFunc)(struct EnMm2*, PlayState*); typedef struct EnMm2 { - /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x44]; - /* 0x0188 */ EnMm2ActionFunc actionFunc; - /* 0x018C */ char unk_18C[0x128]; + /* 0x000 */ Actor actor; + /* 0x144 */ UNK_TYPE1 unk_144[0x44]; + /* 0x188 */ EnMm2ActionFunc actionFunc; + /* 0x18C */ UNK_TYPE1 unk_18C[0x128]; } EnMm2; // size = 0x2B4 extern const ActorInit En_Mm2_InitVars; diff --git a/src/overlays/actors/ovl_En_Mm3/z_en_mm3.c b/src/overlays/actors/ovl_En_Mm3/z_en_mm3.c index 396a3f040..0f7308826 100644 --- a/src/overlays/actors/ovl_En_Mm3/z_en_mm3.c +++ b/src/overlays/actors/ovl_En_Mm3/z_en_mm3.c @@ -11,23 +11,23 @@ #define THIS ((EnMm3*)thisx) -void EnMm3_Init(Actor* thisx, GlobalContext* globalCtx); -void EnMm3_Destroy(Actor* thisx, GlobalContext* globalCtx); -void EnMm3_Update(Actor* thisx, GlobalContext* globalCtx); -void EnMm3_Draw(Actor* thisx, GlobalContext* globalCtx); +void EnMm3_Init(Actor* thisx, PlayState* play); +void EnMm3_Destroy(Actor* thisx, PlayState* play); +void EnMm3_Update(Actor* thisx, PlayState* play); +void EnMm3_Draw(Actor* thisx, PlayState* play); void func_80A6F270(EnMm3* this); -void func_80A6F2C8(EnMm3* this, GlobalContext* globalCtx); +void func_80A6F2C8(EnMm3* this, PlayState* play); void func_80A6F9C8(EnMm3* this); -void func_80A6F9DC(EnMm3* this, GlobalContext* globalCtx); +void func_80A6F9DC(EnMm3* this, PlayState* play); void func_80A6FBA0(EnMm3* this); -void func_80A6FBFC(EnMm3* this, GlobalContext* globalCtx); +void func_80A6FBFC(EnMm3* this, PlayState* play); void func_80A6FE1C(EnMm3* this); -void func_80A6FE30(EnMm3* this, GlobalContext* globalCtx); +void func_80A6FE30(EnMm3* this, PlayState* play); 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); +void func_80A6FEEC(EnMm3* this, PlayState* play); +s32 func_80A6FFAC(EnMm3* this, PlayState* play); +void func_80A70084(EnMm3* this, PlayState* play); const ActorInit En_Mm3_InitVars = { ACTOR_EN_MM3, @@ -63,11 +63,15 @@ static ColliderCylinderInit sCylinderInit = { static CollisionCheckInfoInit2 sColChkInfoInit = { 0, 0, 0, 0, MASS_IMMOVABLE }; -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 }, +static AnimationInfo sAnimationInfo[] = { + { &object_mm_Anim_002238, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, -7.0f }, + { &object_mm_Anim_00A4E0, -1.0f, 0.0f, 0.0f, ANIMMODE_ONCE, -7.0f }, + { &object_mm_Anim_00C640, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, -7.0f }, + { &object_mm_Anim_00A4E0, 1.0f, 0.0f, 0.0f, ANIMMODE_ONCE, -7.0f }, + { &object_mm_Anim_000468, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, -7.0f }, + { &object_mm_Anim_00CD90, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, -12.0f }, + { &object_mm_Anim_00DA50, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, -12.0f }, + { &object_mm_Anim_00DA50, 1.0f, 0.0f, 10.0f, ANIMMODE_ONCE, -10.0f }, }; #include "overlays/ovl_En_Mm3/ovl_En_Mm3.c" @@ -76,19 +80,19 @@ Vec3f D_80A704F0 = { 0.0f, 0.0f, 0.0f }; TexturePtr D_80A704FC[] = { object_mm_Tex_002950, object_mm_Tex_002750 }; -void EnMm3_Init(Actor* thisx, GlobalContext* globalCtx) { +void EnMm3_Init(Actor* thisx, PlayState* play) { s32 pad; EnMm3* this = THIS; 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, + SkelAnime_InitFlex(play, &this->skelAnime, &object_mm_Skel_0096E8, &object_mm_Anim_00A4E0, this->jointTable, this->morphTable, 16); Animation_Change(&this->skelAnime, &object_mm_Anim_00A4E0, -1.0f, Animation_GetLastFrame(&object_mm_Anim_00A4E0), - 0.0f, 2, 0.0f); - Collider_InitCylinder(globalCtx, &this->collider); - Collider_SetCylinder(globalCtx, &this->collider, &this->actor, &sCylinderInit); + 0.0f, ANIMMODE_ONCE, 0.0f); + Collider_InitCylinder(play, &this->collider); + Collider_SetCylinder(play, &this->collider, &this->actor, &sCylinderInit); CollisionCheck_SetInfo2(&this->actor.colChkInfo, NULL, &sColChkInfoInit); - Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 0.0f, 0.0f, 0.0f, 4); + Actor_UpdateBgCheckInfo(play, &this->actor, 0.0f, 0.0f, 0.0f, 4); this->actor.parent = NULL; this->actor.targetMode = 0; this->unk_1DC = 1; @@ -99,11 +103,11 @@ void EnMm3_Init(Actor* thisx, GlobalContext* globalCtx) { func_80A6F270(this); } -void EnMm3_Destroy(Actor* thisx, GlobalContext* globalCtx) { +void EnMm3_Destroy(Actor* thisx, PlayState* play) { EnMm3* this = THIS; gSaveContext.save.weekEventReg[63] &= (u8)~1; - Collider_DestroyCylinder(globalCtx, &this->collider); + Collider_DestroyCylinder(play, &this->collider); } s32 func_80A6F22C(EnMm3* this) { @@ -119,17 +123,17 @@ s32 func_80A6F22C(EnMm3* this) { void func_80A6F270(EnMm3* this) { this->unk_1DC = 1; this->unk_2B0 &= ~1; - Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 5); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, 5); this->actionFunc = func_80A6F2C8; } -void func_80A6F2C8(EnMm3* this, GlobalContext* globalCtx) { - if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { - Message_StartTextbox(globalCtx, 0x278A, &this->actor); +void func_80A6F2C8(EnMm3* this, PlayState* play) { + if (Actor_ProcessTalkRequest(&this->actor, &play->state)) { + Message_StartTextbox(play, 0x278A, &this->actor); this->unk_2B4 = 0x278A; func_80A6F9C8(this); } else if (func_80A6F22C(this)) { - func_800B8614(&this->actor, globalCtx, 100.0f); + func_800B8614(&this->actor, play, 100.0f); } Math_SmoothStepToS(&this->unk_2A0.x, 0, 5, 0x1000, 0x100); @@ -138,159 +142,159 @@ void func_80A6F2C8(EnMm3* this, GlobalContext* globalCtx) { Math_SmoothStepToS(&this->unk_2A6.y, 0, 5, 0x1000, 0x100); } -void func_80A6F3B4(EnMm3* this, GlobalContext* globalCtx) { - if (Message_ShouldAdvance(globalCtx)) { +void func_80A6F3B4(EnMm3* this, PlayState* play) { + if (Message_ShouldAdvance(play)) { switch (this->unk_2B4) { case 0x278E: - if (globalCtx->msgCtx.choiceIndex == 0) { + if (play->msgCtx.choiceIndex == 0) { if (this->unk_2B2 & 0x20) { - if (gSaveContext.save.playerData.rupees >= globalCtx->msgCtx.unk1206C) { + if (gSaveContext.save.playerData.rupees >= play->msgCtx.unk1206C) { func_8019F208(); - Message_StartTextbox(globalCtx, 0x2790, &this->actor); + Message_StartTextbox(play, 0x2790, &this->actor); this->unk_2B4 = 0x2790; - func_801159EC(-globalCtx->msgCtx.unk1206C); + Rupees_ChangeBy(-play->msgCtx.unk1206C); } else { play_sound(NA_SE_SY_ERROR); - Message_StartTextbox(globalCtx, 0x279C, &this->actor); + Message_StartTextbox(play, 0x279C, &this->actor); this->unk_2B4 = 0x279C; - func_80151BB4(globalCtx, 0xB); + func_80151BB4(play, 0xB); } } else { func_8019F208(); - Message_StartTextbox(globalCtx, 0x2790, &this->actor); + Message_StartTextbox(play, 0x2790, &this->actor); this->unk_2B4 = 0x2790; } } else { func_8019F230(); - Message_StartTextbox(globalCtx, 0x278F, &this->actor); + Message_StartTextbox(play, 0x278F, &this->actor); this->unk_2B4 = 0x278F; - func_80151BB4(globalCtx, 0xB); + func_80151BB4(play, 0xB); } break; case 0x279A: - if (globalCtx->msgCtx.choiceIndex == 0) { - if (gSaveContext.save.playerData.rupees >= globalCtx->msgCtx.unk1206C) { + if (play->msgCtx.choiceIndex == 0) { + if (gSaveContext.save.playerData.rupees >= play->msgCtx.unk1206C) { func_8019F208(); - Message_StartTextbox(globalCtx, 0x2790, &this->actor); + Message_StartTextbox(play, 0x2790, &this->actor); this->unk_2B4 = 0x2790; - func_801159EC(-globalCtx->msgCtx.unk1206C); + Rupees_ChangeBy(-play->msgCtx.unk1206C); } else { play_sound(NA_SE_SY_ERROR); - Message_StartTextbox(globalCtx, 0x279C, &this->actor); + Message_StartTextbox(play, 0x279C, &this->actor); this->unk_2B4 = 0x279C; - func_80151BB4(globalCtx, 0xB); + func_80151BB4(play, 0xB); } } else { func_8019F230(); - Message_StartTextbox(globalCtx, 0x279B, &this->actor); + Message_StartTextbox(play, 0x279B, &this->actor); this->unk_2B4 = 0x279B; - func_80151BB4(globalCtx, 0xB); + func_80151BB4(play, 0xB); } break; } } } -void func_80A6F5E4(EnMm3* this, GlobalContext* globalCtx) { - if (((this->unk_2B4 != 0x2791) || (this->unk_2AC == 0)) && Message_ShouldAdvance(globalCtx)) { +void func_80A6F5E4(EnMm3* this, PlayState* play) { + if (((this->unk_2B4 != 0x2791) || (this->unk_2AC == 0)) && Message_ShouldAdvance(play)) { switch (this->unk_2B4) { case 0x278A: - if (func_80A6FFAC(this, globalCtx)) { - Message_StartTextbox(globalCtx, 0x279D, &this->actor); + if (func_80A6FFAC(this, play)) { + Message_StartTextbox(play, 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); + func_80A70084(this, play); + if (Player_GetMask(play) == PLAYER_MASK_BUNNY) { + Message_StartTextbox(play, 0x27A0, &this->actor); this->unk_2B4 = 0x27A0; } else { - Message_StartTextbox(globalCtx, 0x278B, &this->actor); + Message_StartTextbox(play, 0x278B, &this->actor); this->unk_2B4 = 0x278B; } } this->unk_1DC = 0; this->unk_2B0 |= 1; - Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 7); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, 7); break; case 0x278B: case 0x27A0: this->unk_2AE = 0; - Message_StartTextbox(globalCtx, 0x278C, &this->actor); + Message_StartTextbox(play, 0x278C, &this->actor); this->unk_2B4 = 0x278C; break; case 0x278C: - Message_StartTextbox(globalCtx, 0x278D, &this->actor); + Message_StartTextbox(play, 0x278D, &this->actor); this->unk_2B4 = 0x278D; break; case 0x279D: this->unk_2AE = 0; - Message_StartTextbox(globalCtx, 0x279E, &this->actor); + Message_StartTextbox(play, 0x279E, &this->actor); this->unk_2B4 = 0x279E; break; case 0x279E: this->unk_2B2 |= 0x20; - Message_StartTextbox(globalCtx, 0x279F, &this->actor); + Message_StartTextbox(play, 0x279F, &this->actor); this->unk_2B4 = 0x279F; break; case 0x278D: case 0x279F: - Message_StartTextbox(globalCtx, 0x278E, &this->actor); + Message_StartTextbox(play, 0x278E, &this->actor); this->unk_2B4 = 0x278E; break; case 0x2791: if (gSaveContext.unk_3DE0[0] == 1000) { - Message_StartTextbox(globalCtx, 0x2792, &this->actor); + Message_StartTextbox(play, 0x2792, &this->actor); this->unk_2B4 = 0x2792; } else if ((gSaveContext.unk_3DE0[0] >= 1500)) { - Message_StartTextbox(globalCtx, 0x2797, &this->actor); + Message_StartTextbox(play, 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); + Message_StartTextbox(play, 0x2795, &this->actor); this->unk_2B4 = 0x2795; } else { - Message_StartTextbox(globalCtx, 0x2796, &this->actor); + Message_StartTextbox(play, 0x2796, &this->actor); this->unk_2B4 = 0x2796; } break; case 0x2792: - Message_StartTextbox(globalCtx, 0x2793, &this->actor); + Message_StartTextbox(play, 0x2793, &this->actor); this->unk_2B4 = 0x2793; break; case 0x2793: - func_801477B4(globalCtx); + func_801477B4(play); func_80A6FE1C(this); - func_80A6FE30(this, globalCtx); + func_80A6FE30(this, play); break; case 0x2795: case 0x2796: case 0x2797: if (gSaveContext.save.weekEventReg[63] & 2) { - Message_StartTextbox(globalCtx, 0x279B, &this->actor); + Message_StartTextbox(play, 0x279B, &this->actor); this->unk_2B4 = 0x279B; - func_80151BB4(globalCtx, 0xB); + func_80151BB4(play, 0xB); } else { - Message_StartTextbox(globalCtx, 0x2798, &this->actor); + Message_StartTextbox(play, 0x2798, &this->actor); this->unk_2B4 = 0x2798; } break; case 0x2798: - Message_StartTextbox(globalCtx, 0x2799, &this->actor); + Message_StartTextbox(play, 0x2799, &this->actor); this->unk_2B4 = 0x2799; break; case 0x2799: - Message_StartTextbox(globalCtx, 0x279A, &this->actor); + Message_StartTextbox(play, 0x279A, &this->actor); this->unk_2B4 = 0x279A; break; } @@ -310,39 +314,39 @@ void func_80A6F9C8(EnMm3* this) { this->actionFunc = func_80A6F9DC; } -void func_80A6F9DC(EnMm3* this, GlobalContext* globalCtx) { +void func_80A6F9DC(EnMm3* this, PlayState* play) { this->unk_2B0 &= ~2; - switch (Message_GetState(&globalCtx->msgCtx)) { - case 0: - case 1: - case 2: + switch (Message_GetState(&play->msgCtx)) { + case TEXT_STATE_NONE: + case TEXT_STATE_1: + case TEXT_STATE_CLOSING: break; - case 3: + case TEXT_STATE_3: this->unk_2B0 |= 2; break; - case 4: - func_80A6F3B4(this, globalCtx); + case TEXT_STATE_CHOICE: + func_80A6F3B4(this, play); break; - case 5: - func_80A6F5E4(this, globalCtx); + case TEXT_STATE_5: + func_80A6F5E4(this, play); break; - case 6: - if (Message_ShouldAdvance(globalCtx)) { + case TEXT_STATE_DONE: + if (Message_ShouldAdvance(play)) { if (this->unk_2B4 == 0x2790) { - Player* player = GET_PLAYER(globalCtx); + Player* player = GET_PLAYER(play); player->stateFlags1 |= 0x20; - if (Player_GetMask(globalCtx) == PLAYER_MASK_BUNNY) { + if (Player_GetMask(play) == PLAYER_MASK_BUNNY) { func_8010EA9C(0, 2); } else { func_8010EA9C(0, 0); } - func_801477B4(globalCtx); + func_801477B4(play); play_sound(NA_SE_SY_START_SHOT); func_80A6FBA0(this); } else { @@ -355,7 +359,7 @@ void func_80A6F9DC(EnMm3* this, GlobalContext* globalCtx) { } if ((this->skelAnime.mode == 2) && Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) { - Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 2); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, 2); } if (((this->unk_2B4 == 0x279D) || (this->unk_2B4 == 0x27A0) || (this->unk_2B4 == 0x278B)) && @@ -366,41 +370,35 @@ void func_80A6F9DC(EnMm3* this, GlobalContext* globalCtx) { } void func_80A6FBA0(EnMm3* this) { - func_801A5BD0(0x6F); + AudioSfx_MuteBanks((1 << BANK_PLAYER) | (1 << BANK_ITEM) | (1 << BANK_ENV) | (1 << BANK_ENEMY) | + (1 << BANK_OCARINA) | (1 << BANK_VOICE)); func_801A0238(0, 5); gSaveContext.save.weekEventReg[63] |= 1; gSaveContext.save.weekEventReg[63] &= (u8)~2; this->actionFunc = func_80A6FBFC; } -void func_80A6FBFC(EnMm3* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); - OSTime a; - OSTime b; +void func_80A6FBFC(EnMm3* this, PlayState* play) { + Player* player = GET_PLAYER(play); if (gSaveContext.unk_3DD0[0] == 0x10) { player->stateFlags1 &= ~0x20; this->actor.flags |= ACTOR_FLAG_10000; - if (gSaveContext.unk_3DE0[0] >= 0x5DD) { - gSaveContext.unk_3DE0[0] = 0x5DC; - } else { - a = gSaveContext.unk_3DE0[0]; - if (a >= (OSTime)(995 - XREG(16))) { - b = gSaveContext.unk_3DE0[0]; - if ((OSTime)(XREG(17) + 1005) >= b) { - gSaveContext.unk_3DE0[0] = 1000; - } - } + 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] >= 0x5DD) { + } 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); + if (Actor_ProcessTalkRequest(&this->actor, &play->state)) { + AudioSfx_MuteBanks(0); func_801A0238(0x7F, 5); - Message_StartTextbox(globalCtx, 0x2791, &this->actor); + Message_StartTextbox(play, 0x2791, &this->actor); this->unk_2B4 = 0x2791; this->unk_2AC = 7; gSaveContext.unk_3DD0[0] = 0; @@ -408,9 +406,9 @@ void func_80A6FBFC(EnMm3* this, GlobalContext* globalCtx) { 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) { + func_800B8614(&this->actor, play, this->actor.xzDistToPlayer + 10.0f); + func_80123E90(play, &this->actor); + if (Player_GetMask(play) == PLAYER_MASK_BUNNY) { play_sound(NA_SE_SY_STOPWATCH_TIMER_INF - SFX_FLAG); } else { play_sound(NA_SE_SY_STOPWATCH_TIMER_3 - SFX_FLAG); @@ -422,17 +420,17 @@ void func_80A6FE1C(EnMm3* this) { this->actionFunc = func_80A6FE30; } -void func_80A6FE30(EnMm3* this, GlobalContext* globalCtx) { - if (Actor_HasParent(&this->actor, globalCtx)) { +void func_80A6FE30(EnMm3* this, PlayState* play) { + if (Actor_HasParent(&this->actor, play)) { 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); + Actor_PickUp(&this->actor, play, GI_RUPEE_PURPLE, 500.0f, 100.0f); } else { - Actor_PickUp(&this->actor, globalCtx, GI_HEART_PIECE, 500.0f, 100.0f); + Actor_PickUp(&this->actor, play, GI_HEART_PIECE, 500.0f, 100.0f); } } @@ -440,26 +438,26 @@ void func_80A6FED8(EnMm3* this) { this->actionFunc = func_80A6FEEC; } -void func_80A6FEEC(EnMm3* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); +void func_80A6FEEC(EnMm3* this, PlayState* play) { + Player* player = GET_PLAYER(play); - if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { + if (Actor_ProcessTalkRequest(&this->actor, &play->state)) { player->stateFlags1 &= ~0x20; - Message_StartTextbox(globalCtx, 0x2794, &this->actor); + Message_StartTextbox(play, 0x2794, &this->actor); this->unk_2B4 = 0x2794; - func_80151BB4(globalCtx, 0xB); - func_80151BB4(globalCtx, 0x2B); + func_80151BB4(play, 0xB); + func_80151BB4(play, 0x2B); this->actor.flags &= ~ACTOR_FLAG_10000; func_80A6F9C8(this); } else { - func_800B85E0(&this->actor, globalCtx, 200.0f, -1); + func_800B85E0(&this->actor, play, 200.0f, -1); } } -s32 func_80A6FFAC(EnMm3* this, GlobalContext* globalCtx) { +s32 func_80A6FFAC(EnMm3* this, PlayState* play) { switch (gSaveContext.save.playerForm) { case 4: - if (Player_GetMask(globalCtx) == PLAYER_MASK_BUNNY) { + if (Player_GetMask(play) == PLAYER_MASK_BUNNY) { if (this->unk_2B2 & 0x10) { return true; } @@ -490,10 +488,10 @@ s32 func_80A6FFAC(EnMm3* this, GlobalContext* globalCtx) { return false; } -void func_80A70084(EnMm3* this, GlobalContext* globalCtx) { +void func_80A70084(EnMm3* this, PlayState* play) { switch (gSaveContext.save.playerForm) { case 4: - if (Player_GetMask(globalCtx) == PLAYER_MASK_BUNNY) { + if (Player_GetMask(play) == PLAYER_MASK_BUNNY) { this->unk_2B2 |= 0x10; this->unk_2B2 |= 1; } else { @@ -515,23 +513,23 @@ void func_80A70084(EnMm3* this, GlobalContext* globalCtx) { } } -void EnMm3_Update(Actor* thisx, GlobalContext* globalCtx) { +void EnMm3_Update(Actor* thisx, PlayState* play) { s32 pad; EnMm3* this = THIS; - this->actionFunc(this, globalCtx); + this->actionFunc(this, play); SkelAnime_Update(&this->skelAnime); if (this->unk_2B0 & 1) { - func_800E9250(globalCtx, &this->actor, &this->unk_2A0, &this->unk_2A6, this->actor.focus.pos); + Actor_TrackPlayer(play, &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); + CollisionCheck_SetOC(play, &play->colChkCtx, &this->collider.base); } -s32 EnMm3_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, Actor* thisx) { +s32 EnMm3_OverrideLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, Actor* thisx) { EnMm3* this = THIS; if (limbIndex == 8) { @@ -540,33 +538,33 @@ s32 EnMm3_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, } else if (limbIndex == 15) { rot->x += this->unk_2A0.y; rot->z += this->unk_2A0.x; - if ((this->unk_2B0 & 2) && ((globalCtx->gameplayFrames % 3) == 0)) { - Matrix_InsertTranslation(40.0f, 0.0f, 0.0f, MTXMODE_APPLY); + if ((this->unk_2B0 & 2) && ((play->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) { +void EnMm3_PostLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx) { EnMm3* this = THIS; if (limbIndex == 15) { - Matrix_MultiplyVector3fByState(&D_80A704F0, &this->actor.focus.pos); + Matrix_MultVec3f(&D_80A704F0, &this->actor.focus.pos); } } -void EnMm3_Draw(Actor* thisx, GlobalContext* globalCtx) { +void EnMm3_Draw(Actor* thisx, PlayState* play) { EnMm3* this = THIS; - OPEN_DISPS(globalCtx->state.gfxCtx); + OPEN_DISPS(play->state.gfxCtx); - func_8012C28C(globalCtx->state.gfxCtx); + func_8012C28C(play->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, + SkelAnime_DrawFlexOpa(play, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, EnMm3_OverrideLimbDraw, EnMm3_PostLimbDraw, &this->actor); - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->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 fe2e7ba06..b6f653935 100644 --- a/src/overlays/actors/ovl_En_Mm3/z_en_mm3.h +++ b/src/overlays/actors/ovl_En_Mm3/z_en_mm3.h @@ -5,24 +5,24 @@ struct EnMm3; -typedef void (*EnMm3ActionFunc)(struct EnMm3*, GlobalContext*); +typedef void (*EnMm3ActionFunc)(struct EnMm3*, PlayState*); typedef struct EnMm3 { - /* 0x0000 */ Actor actor; - /* 0x0144 */ SkelAnime skelAnime; - /* 0x0188 */ ColliderCylinder collider; - /* 0x01D4 */ EnMm3ActionFunc actionFunc; - /* 0x01D8 */ UNK_TYPE1 unk1D8[4]; - /* 0x01DC */ s32 unk_1DC; - /* 0x01E0 */ Vec3s jointTable[16]; - /* 0x0240 */ Vec3s morphTable[16]; - /* 0x02A0 */ Vec3s unk_2A0; - /* 0x02A6 */ Vec3s unk_2A6; - /* 0x02AC */ s16 unk_2AC; - /* 0x02AE */ s16 unk_2AE; - /* 0x02B0 */ u16 unk_2B0; - /* 0x02B2 */ u16 unk_2B2; - /* 0x02B4 */ u16 unk_2B4; + /* 0x000 */ Actor actor; + /* 0x144 */ SkelAnime skelAnime; + /* 0x188 */ ColliderCylinder collider; + /* 0x1D4 */ EnMm3ActionFunc actionFunc; + /* 0x1D8 */ UNK_TYPE1 unk1D8[4]; + /* 0x1DC */ s32 unk_1DC; + /* 0x1E0 */ Vec3s jointTable[16]; + /* 0x240 */ Vec3s morphTable[16]; + /* 0x2A0 */ Vec3s unk_2A0; + /* 0x2A6 */ Vec3s unk_2A6; + /* 0x2AC */ s16 unk_2AC; + /* 0x2AE */ s16 unk_2AE; + /* 0x2B0 */ u16 unk_2B0; + /* 0x2B2 */ u16 unk_2B2; + /* 0x2B4 */ u16 unk_2B4; } EnMm3; // size = 0x2B8 extern const ActorInit En_Mm3_InitVars; diff --git a/src/overlays/actors/ovl_En_Mnk/z_en_mnk.c b/src/overlays/actors/ovl_En_Mnk/z_en_mnk.c index 85996fe6c..14c235f51 100644 --- a/src/overlays/actors/ovl_En_Mnk/z_en_mnk.c +++ b/src/overlays/actors/ovl_En_Mnk/z_en_mnk.c @@ -10,10 +10,10 @@ #define THIS ((EnMnk*)thisx) -void EnMnk_Init(Actor* thisx, GlobalContext* globalCtx); -void EnMnk_Destroy(Actor* thisx, GlobalContext* globalCtx); -void EnMnk_Update(Actor* thisx, GlobalContext* globalCtx); -void EnMnk_Draw(Actor* thisx, GlobalContext* globalCtx); +void EnMnk_Init(Actor* thisx, PlayState* play); +void EnMnk_Destroy(Actor* thisx, PlayState* play); +void EnMnk_Update(Actor* thisx, PlayState* play); +void EnMnk_Draw(Actor* thisx, PlayState* play); #if 0 const ActorInit En_Mnk_InitVars = { @@ -73,7 +73,7 @@ extern UNK_TYPE D_060105DC; #pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Mnk/func_80AB5A64.s") -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Mnk/func_80AB5B38.s") +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Mnk/EnMnk_ValidatePictograph.s") #pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Mnk/func_80AB5B84.s") diff --git a/src/overlays/actors/ovl_En_Mnk/z_en_mnk.h b/src/overlays/actors/ovl_En_Mnk/z_en_mnk.h index 74afa66e6..9baee87f0 100644 --- a/src/overlays/actors/ovl_En_Mnk/z_en_mnk.h +++ b/src/overlays/actors/ovl_En_Mnk/z_en_mnk.h @@ -2,15 +2,16 @@ #define Z_EN_MNK_H #include "global.h" +#include "z64snap.h" struct EnMnk; -typedef void (*EnMnkActionFunc)(struct EnMnk*, GlobalContext*); +typedef void (*EnMnkActionFunc)(struct EnMnk*, PlayState*); typedef struct EnMnk { - /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x2A4]; - /* 0x03E8 */ EnMnkActionFunc actionFunc; + /* 0x000 */ PictoActor picto; + /* 0x148 */ char unk_148[0x2A0]; + /* 0x3E8 */ EnMnkActionFunc actionFunc; } EnMnk; // size = 0x3EC extern const ActorInit En_Mnk_InitVars; diff --git a/src/overlays/actors/ovl_En_Ms/z_en_ms.c b/src/overlays/actors/ovl_En_Ms/z_en_ms.c index 729e36d49..01b5c4bec 100644 --- a/src/overlays/actors/ovl_En_Ms/z_en_ms.c +++ b/src/overlays/actors/ovl_En_Ms/z_en_ms.c @@ -11,15 +11,15 @@ #define THIS ((EnMs*)thisx) -void EnMs_Init(Actor* thisx, GlobalContext* globalCtx); -void EnMs_Destroy(Actor* thisx, GlobalContext* globalCtx); -void EnMs_Update(Actor* thisx, GlobalContext* globalCtx); -void EnMs_Draw(Actor* thisx, GlobalContext* globalCtx); +void EnMs_Init(Actor* thisx, PlayState* play); +void EnMs_Destroy(Actor* thisx, PlayState* play); +void EnMs_Update(Actor* thisx, PlayState* play); +void EnMs_Draw(Actor* thisx, PlayState* play); -void EnMs_Wait(EnMs* this, GlobalContext* globalCtx); -void EnMs_Talk(EnMs* this, GlobalContext* globalCtx); -void EnMs_Sell(EnMs* this, GlobalContext* globalCtx); -void EnMs_TalkAfterPurchase(EnMs* this, GlobalContext* globalCtx); +void EnMs_Wait(EnMs* this, PlayState* play); +void EnMs_Talk(EnMs* this, PlayState* play); +void EnMs_Sell(EnMs* this, PlayState* play); +void EnMs_TalkAfterPurchase(EnMs* this, PlayState* play); const ActorInit En_Ms_InitVars = { ACTOR_EN_MS, @@ -57,14 +57,14 @@ static InitChainEntry sInitChain[] = { ICHAIN_F32(targetArrowOffset, 500, ICHAIN_STOP), }; -void EnMs_Init(Actor* thisx, GlobalContext* globalCtx) { +void EnMs_Init(Actor* thisx, PlayState* play) { EnMs* this = THIS; Actor_ProcessInitChain(thisx, sInitChain); - SkelAnime_InitFlex(globalCtx, &this->skelAnime, &object_ms_Skel_003DC0, &object_ms_Anim_0005EC, this->jointTable, + SkelAnime_InitFlex(play, &this->skelAnime, &object_ms_Skel_003DC0, &object_ms_Anim_0005EC, this->jointTable, this->morphTable, 9); - Collider_InitCylinder(globalCtx, &this->collider); - Collider_SetCylinderType1(globalCtx, &this->collider, &this->actor, &sCylinderInit); + Collider_InitCylinder(play, &this->collider); + Collider_SetCylinderType1(play, &this->collider, &this->actor, &sCylinderInit); ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 35.0f); Actor_SetScale(&this->actor, 0.015f); this->actor.colChkInfo.mass = MASS_IMMOVABLE; // Eating Magic Beans all day will do that to you @@ -74,13 +74,13 @@ void EnMs_Init(Actor* thisx, GlobalContext* globalCtx) { this->actor.gravity = -1.0f; } -void EnMs_Destroy(Actor* thisx, GlobalContext* globalCtx) { +void EnMs_Destroy(Actor* thisx, PlayState* play) { EnMs* this = THIS; - Collider_DestroyCylinder(globalCtx, &this->collider); + Collider_DestroyCylinder(play, &this->collider); } -void EnMs_Wait(EnMs* this, GlobalContext* globalCtx) { +void EnMs_Wait(EnMs* this, PlayState* play) { s16 yawDiff = this->actor.yawTowardsPlayer - this->actor.shape.rot.y; if (gSaveContext.save.inventory.items[SLOT_MAGIC_BEANS] == ITEM_NONE) { @@ -89,45 +89,45 @@ void EnMs_Wait(EnMs* this, GlobalContext* globalCtx) { this->actor.textId = 0x932; // "[...] So you liked my Magic Beans [...]" } - if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { + if (Actor_ProcessTalkRequest(&this->actor, &play->state)) { this->actionFunc = EnMs_Talk; } else if ((this->actor.xzDistToPlayer < 90.0f) && (ABS_ALT(yawDiff) < 0x2000)) { - func_800B8614(&this->actor, globalCtx, 90.0f); + func_800B8614(&this->actor, play, 90.0f); } } -void EnMs_Talk(EnMs* this, GlobalContext* globalCtx) { - switch (Message_GetState(&globalCtx->msgCtx)) { - case 6: - if (Message_ShouldAdvance(globalCtx) != 0) { +void EnMs_Talk(EnMs* this, PlayState* play) { + switch (Message_GetState(&play->msgCtx)) { + case TEXT_STATE_DONE: + if (Message_ShouldAdvance(play)) { this->actionFunc = EnMs_Wait; } break; - case 5: - if (Message_ShouldAdvance(globalCtx) != 0) { - func_801477B4(globalCtx); - Actor_PickUp(&this->actor, globalCtx, GI_MAGIC_BEANS, this->actor.xzDistToPlayer, + case TEXT_STATE_5: + if (Message_ShouldAdvance(play)) { + func_801477B4(play); + Actor_PickUp(&this->actor, play, GI_MAGIC_BEANS, this->actor.xzDistToPlayer, this->actor.playerHeightRel); this->actionFunc = EnMs_Sell; } break; - case 4: - if (Message_ShouldAdvance(globalCtx) != 0) { - switch (globalCtx->msgCtx.choiceIndex) { + case TEXT_STATE_CHOICE: + if (Message_ShouldAdvance(play)) { + switch (play->msgCtx.choiceIndex) { case 0: // yes - func_801477B4(globalCtx); + func_801477B4(play); if (gSaveContext.save.playerData.rupees < 10) { play_sound(NA_SE_SY_ERROR); - func_80151938(globalCtx, 0x935); // "[...] You don't have enough Rupees." + func_80151938(play, 0x935); // "[...] You don't have enough Rupees." } else if (AMMO(ITEM_MAGIC_BEANS) >= 20) { play_sound(NA_SE_SY_ERROR); - func_80151938(globalCtx, 0x937); // "[...] You can't carry anymore." + func_80151938(play, 0x937); // "[...] You can't carry anymore." } else { func_8019F208(); - Actor_PickUp(&this->actor, globalCtx, GI_MAGIC_BEANS, 90.0f, 10.0f); - func_801159EC(-10); + Actor_PickUp(&this->actor, play, GI_MAGIC_BEANS, 90.0f, 10.0f); + Rupees_ChangeBy(-10); this->actionFunc = EnMs_Sell; } break; @@ -135,36 +135,37 @@ void EnMs_Talk(EnMs* this, GlobalContext* globalCtx) { case 1: // no default: func_8019F230(); - func_80151938(globalCtx, 0x934); // "[...] Well, if your mood changes [...]" + func_80151938(play, 0x934); // "[...] Well, if your mood changes [...]" break; } } break; + default: break; } } -void EnMs_Sell(EnMs* this, GlobalContext* globalCtx) { - if (Actor_HasParent(&this->actor, globalCtx)) { +void EnMs_Sell(EnMs* this, PlayState* play) { + if (Actor_HasParent(&this->actor, play)) { this->actor.textId = 0; - func_800B8500(&this->actor, globalCtx, this->actor.xzDistToPlayer, this->actor.playerHeightRel, 0); + func_800B8500(&this->actor, play, this->actor.xzDistToPlayer, this->actor.playerHeightRel, PLAYER_AP_NONE); this->actionFunc = EnMs_TalkAfterPurchase; } else { - Actor_PickUp(&this->actor, globalCtx, GI_MAGIC_BEANS, this->actor.xzDistToPlayer, this->actor.playerHeightRel); + Actor_PickUp(&this->actor, play, GI_MAGIC_BEANS, this->actor.xzDistToPlayer, this->actor.playerHeightRel); } } -void EnMs_TalkAfterPurchase(EnMs* this, GlobalContext* globalCtx) { - if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { - func_80151938(globalCtx, 0x936); // "You can plant 'em whenever you want [...]" +void EnMs_TalkAfterPurchase(EnMs* this, PlayState* play) { + if (Actor_ProcessTalkRequest(&this->actor, &play->state)) { + func_80151938(play, 0x936); // "You can plant 'em whenever you want [...]" this->actionFunc = EnMs_Talk; } else { - func_800B8500(&this->actor, globalCtx, this->actor.xzDistToPlayer, this->actor.playerHeightRel, -1); + func_800B8500(&this->actor, play, this->actor.xzDistToPlayer, this->actor.playerHeightRel, PLAYER_AP_MINUS1); } } -void EnMs_Update(Actor* thisx, GlobalContext* globalCtx) { +void EnMs_Update(Actor* thisx, PlayState* play) { s32 pad; EnMs* this = THIS; @@ -172,15 +173,15 @@ void EnMs_Update(Actor* thisx, GlobalContext* globalCtx) { this->actor.targetArrowOffset = 500.0f; Actor_SetScale(&this->actor, 0.015f); SkelAnime_Update(&this->skelAnime); - this->actionFunc(this, globalCtx); + this->actionFunc(this, play); Collider_UpdateCylinder(&this->actor, &this->collider); - CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + CollisionCheck_SetOC(play, &play->colChkCtx, &this->collider.base); } -void EnMs_Draw(Actor* thisx, GlobalContext* globalCtx) { +void EnMs_Draw(Actor* thisx, PlayState* play) { EnMs* this = THIS; - func_8012C28C(globalCtx->state.gfxCtx); - SkelAnime_DrawFlexOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, - NULL, NULL, &this->actor); + func_8012C28C(play->state.gfxCtx); + SkelAnime_DrawFlexOpa(play, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, NULL, + NULL, &this->actor); } diff --git a/src/overlays/actors/ovl_En_Ms/z_en_ms.h b/src/overlays/actors/ovl_En_Ms/z_en_ms.h index 2efbdea45..dcff0cb58 100644 --- a/src/overlays/actors/ovl_En_Ms/z_en_ms.h +++ b/src/overlays/actors/ovl_En_Ms/z_en_ms.h @@ -5,7 +5,7 @@ struct EnMs; -typedef void (*EnMsActionFunc)(struct EnMs*, GlobalContext*); +typedef void (*EnMsActionFunc)(struct EnMs*, PlayState*); typedef struct EnMs { /* 0x000 */ Actor actor; 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 6952f10c2..b20edf2b4 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 @@ -10,17 +10,17 @@ #define THIS ((EnMttag*)thisx) -void EnMttag_Init(Actor* thisx, GlobalContext* globalCtx); -void EnMttag_Destroy(Actor* thisx, GlobalContext* globalCtx); -void EnMttag_Update(Actor* thisx, GlobalContext* globalCtx); +void EnMttag_Init(Actor* thisx, PlayState* play); +void EnMttag_Destroy(Actor* thisx, PlayState* play); +void EnMttag_Update(Actor* thisx, PlayState* play); -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); +void EnMttag_ShowIntroCutscene(EnMttag* this, PlayState* play); +void EnMttag_WaitForIntroCutsceneToEnd(EnMttag* this, PlayState* play); +void EnMttag_RaceStart(EnMttag* this, PlayState* play); +void EnMttag_Race(EnMttag* this, PlayState* play); +void EnMttag_RaceFinish(EnMttag* this, PlayState* play); +void EnMttag_PotentiallyRestartRace(EnMttag* this, PlayState* play); +void EnMttag_HandleCantWinChoice(EnMttag* this, PlayState* play); typedef enum { GORON_RACE_CHEAT_NO_CHEATING, @@ -98,13 +98,13 @@ s32 EnMttag_CheckPlayerCheatStatus(Vec3f* pos) { * 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) { +s32 EnMttag_AreFourRaceGoronsPresent(EnMttag* this, PlayState* play) { Actor* actor = NULL; s32 i = 0; s32 areGoronsPresent; do { - actor = SubS_FindActor(globalCtx, actor, ACTORCAT_NPC, ACTOR_EN_RG); + actor = SubS_FindActor(play, actor, ACTORCAT_NPC, ACTOR_EN_RG); if (actor != NULL) { this->raceGorons[i] = (EnRg*)actor; i++; @@ -131,8 +131,8 @@ s32 EnMttag_AreFourRaceGoronsPresent(EnMttag* this, GlobalContext* globalCtx) { * 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 EnMttag_GetCurrentCheckpoint(Actor* actor, PlayState* play, s32* upcomingCheckpoint, f32* outPerpendicularPointX, + f32* outPerpendicularPointZ) { s32 curentCheckpoint = -1; s32 hasSetCurrentCheckpointOnce = false; f32 minLineLengthSq = 0.0f; @@ -144,7 +144,7 @@ s32 EnMttag_GetCurrentCheckpoint(Actor* actor, GlobalContext* globalCtx, s32* up // 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); + sceneExitIndex = SurfaceType_GetSceneExitIndex(&play->colCtx, actor->floorPoly, actor->floorBgId); if ((sceneExitIndex < 4) || (sceneExitIndex >= 19)) { //! @bug - upcomingCheckpoint is not initialized here return -1; @@ -184,8 +184,8 @@ s32 EnMttag_GetCurrentCheckpoint(Actor* actor, GlobalContext* globalCtx, s32* up * 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); +s32 EnMttag_UpdateCheckpoints(EnMttag* this, PlayState* play) { + Player* player = GET_PLAYER(play); EnRg* rg; s32 currentCheckpoints[5]; s32 upcomingCheckpoints[5]; @@ -196,11 +196,11 @@ s32 EnMttag_UpdateCheckpoints(EnMttag* this, GlobalContext* globalCtx) { s32 playerIsLikelyToLose = false; highestCurrentCheckpoint = -1; - currentCheckpoints[0] = EnMttag_GetCurrentCheckpoint(&player->actor, globalCtx, &upcomingCheckpoints[0], + currentCheckpoints[0] = EnMttag_GetCurrentCheckpoint(&player->actor, play, &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], + EnMttag_GetCurrentCheckpoint(&this->raceGorons[i - 1]->actor, play, &upcomingCheckpoints[i], &perpendicularPointsX[i], &perpendicularPointsZ[i]); if (highestCurrentCheckpoint < currentCheckpoints[i]) { highestCurrentCheckpoint = currentCheckpoints[i]; @@ -229,12 +229,12 @@ s32 EnMttag_UpdateCheckpoints(EnMttag* this, GlobalContext* globalCtx) { /** * Exits the race and returns the player back to "normal" gameplay. - * Whether the player won or lost the race is determined by arg1 and nextTransition. + * Whether the player won or lost the race is determined by transitionType and nextTransitionType. */ -s32 EnMttag_ExitRace(GlobalContext* globalCtx, s32 arg1, s32 nextTransition) { +s32 EnMttag_ExitRace(PlayState* play, s32 transitionType, s32 nextTransitionType) { CUR_FORM_EQUIP(EQUIP_SLOT_B) = ITEM_SWORD_KOKIRI; - globalCtx->nextEntranceIndex = 0xD020; - if ((gSaveContext.save.weekEventReg[33] & 0x80)) { + play->nextEntrance = ENTRANCE(GORON_RACETRACK, 2); + if (gSaveContext.save.weekEventReg[33] & 0x80) { // Spring gSaveContext.nextCutsceneIndex = 0xFFF0; } else { @@ -242,20 +242,20 @@ s32 EnMttag_ExitRace(GlobalContext* globalCtx, s32 arg1, s32 nextTransition) { gSaveContext.nextCutsceneIndex = 0; } - globalCtx->sceneLoadFlag = 0x14; - globalCtx->unk_1887F = arg1; - gSaveContext.nextTransition = nextTransition; - func_801477B4(globalCtx); + play->transitionTrigger = TRANS_TRIGGER_START; + play->transitionType = transitionType; + gSaveContext.nextTransitionType = nextTransitionType; + func_801477B4(play); return 1; } /** * Displays the text which says that the player has made a false start. */ -void EnMttag_ShowFalseStartMessage(EnMttag* this, GlobalContext* globalCtx) { +void EnMttag_ShowFalseStartMessage(EnMttag* this, PlayState* play) { gSaveContext.unk_3DD0[4] = 0; - Message_StartTextbox(globalCtx, 0xE95, NULL); // An entrant made a false start - func_800B7298(globalCtx, &this->actor, 7); + Message_StartTextbox(play, 0xE95, NULL); // An entrant made a false start + func_800B7298(play, &this->actor, 7); Audio_QueueSeqCmd(0x101400FF); this->actionFunc = EnMttag_PotentiallyRestartRace; } @@ -264,16 +264,16 @@ void EnMttag_ShowFalseStartMessage(EnMttag* this, GlobalContext* globalCtx) { * 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); +void EnMttag_ShowCantWinMessage(EnMttag* this, PlayState* play) { + Message_StartTextbox(play, 0xE97, NULL); // You can't win now... + func_800B7298(play, &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) { +void EnMttag_ShowIntroCutscene(EnMttag* this, PlayState* play) { if (ActorCutscene_GetCanPlayNext(this->actor.cutscene)) { ActorCutscene_StartAndSetUnkLinkFields(this->actor.cutscene, &this->actor); this->actionFunc = EnMttag_WaitForIntroCutsceneToEnd; @@ -286,7 +286,7 @@ void EnMttag_ShowIntroCutscene(EnMttag* this, GlobalContext* globalCtx) { * 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) { +void EnMttag_WaitForIntroCutsceneToEnd(EnMttag* this, PlayState* play) { if (ActorCutscene_GetCurrentIndex() != this->actor.cutscene) { gSaveContext.save.weekEventReg[12] |= 2; this->actionFunc = EnMttag_RaceStart; @@ -297,8 +297,8 @@ void EnMttag_WaitForIntroCutsceneToEnd(EnMttag* this, GlobalContext* globalCtx) * 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); +void EnMttag_RaceStart(EnMttag* this, PlayState* play) { + Player* player = GET_PLAYER(play); s32 playerCheatStatus; if (this->raceInitialized == true) { @@ -310,23 +310,23 @@ void EnMttag_RaceStart(EnMttag* this, GlobalContext* globalCtx) { this->shouldRestartRace = false; } - EnMttag_ShowFalseStartMessage(this, globalCtx); + EnMttag_ShowFalseStartMessage(this, play); gSaveContext.eventInf[1] |= 8; } else { if (DECR(this->timer) == 60) { func_8010E9F0(4, 0); - globalCtx->interfaceCtx.unk_280 = 1; + play->interfaceCtx.unk_280 = 1; Audio_QueueSeqCmd(NA_BGM_GORON_RACE | 0x8000); - globalCtx->envCtx.unk_E4 = 0xFE; + play->envCtx.unk_E4 = 0xFE; player->stateFlags1 &= ~0x20; - } else if ((this->timer < 60) && (globalCtx->interfaceCtx.unk_280 == 8)) { + } else if ((this->timer < 60) && (play->interfaceCtx.unk_280 == 8)) { this->timer = 0; gSaveContext.eventInf[1] |= 1; this->actionFunc = EnMttag_Race; } } } else { - if (EnMttag_AreFourRaceGoronsPresent(this, globalCtx)) { + if (EnMttag_AreFourRaceGoronsPresent(this, play)) { this->raceInitialized = true; } } @@ -353,8 +353,8 @@ s32 EnMttag_IsAnyRaceGoronOverFinishLine(EnMttag* this) { * 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); +void EnMttag_Race(EnMttag* this, PlayState* play) { + Player* player = GET_PLAYER(play); Vec3f* playerPos = &player->actor.world.pos; s32 playerCheatStatus; @@ -381,10 +381,10 @@ void EnMttag_Race(EnMttag* this, GlobalContext* globalCtx) { this->shouldRestartRace = false; } - EnMttag_ShowFalseStartMessage(this, globalCtx); + EnMttag_ShowFalseStartMessage(this, play); gSaveContext.eventInf[1] |= 8; - } else if ((EnMttag_UpdateCheckpoints(this, globalCtx)) && (this->timer == 0)) { - EnMttag_ShowCantWinMessage(this, globalCtx); + } else if ((EnMttag_UpdateCheckpoints(this, play)) && (this->timer == 0)) { + EnMttag_ShowCantWinMessage(this, play); gSaveContext.eventInf[1] |= 8; } } @@ -394,14 +394,14 @@ void EnMttag_Race(EnMttag* this, GlobalContext* globalCtx) { * 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) { +void EnMttag_RaceFinish(EnMttag* this, PlayState* play) { if (DECR(this->timer) == 0) { if ((gSaveContext.eventInf[1] & 2)) { // Player won - EnMttag_ExitRace(globalCtx, 3, 3); + EnMttag_ExitRace(play, TRANS_TYPE_03, TRANS_TYPE_03); } else { // A non-player Goron won - EnMttag_ExitRace(globalCtx, 2, 2); + EnMttag_ExitRace(play, TRANS_TYPE_02, TRANS_TYPE_02); } Actor_MarkForDeath(&this->actor); @@ -413,12 +413,12 @@ void EnMttag_RaceFinish(EnMttag* this, GlobalContext* globalCtx) { * 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); +void EnMttag_PotentiallyRestartRace(EnMttag* this, PlayState* play) { + u8 talkState = Message_GetState(&play->msgCtx); - if (((talkState == 5 && Message_ShouldAdvance(globalCtx)) || talkState == 2)) { + if (((talkState == TEXT_STATE_5 && Message_ShouldAdvance(play)) || talkState == TEXT_STATE_CLOSING)) { if (this->shouldRestartRace) { - globalCtx->nextEntranceIndex = 0xD010; + play->nextEntrance = ENTRANCE(GORON_RACETRACK, 1); if (gSaveContext.save.weekEventReg[33] & 0x80) { // Spring @@ -428,12 +428,12 @@ void EnMttag_PotentiallyRestartRace(EnMttag* this, GlobalContext* globalCtx) { 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, + play->transitionTrigger = TRANS_TRIGGER_START; + play->transitionType = TRANS_TYPE_02; + gSaveContext.nextTransitionType = TRANS_TYPE_02; + func_801477B4(play); + func_800B7298(play, &this->actor, 7); + Parameter_AddMagic(play, ((void)0, gSaveContext.unk_3F30) + (gSaveContext.save.playerData.doubleMagic * 48) + 48); gSaveContext.eventInf[1] &= (u8)~1; @@ -442,7 +442,7 @@ void EnMttag_PotentiallyRestartRace(EnMttag* this, GlobalContext* globalCtx) { gSaveContext.eventInf[1] &= (u8)~8; gSaveContext.eventInf[2] = ((gSaveContext.eventInf[2] & 0xF) + 1) | (gSaveContext.eventInf[2] & 0xF0); } else { - EnMttag_ExitRace(globalCtx, 2, 2); + EnMttag_ExitRace(play, TRANS_TYPE_02, TRANS_TYPE_02); } Actor_MarkForDeath(&this->actor); } @@ -452,21 +452,21 @@ void EnMttag_PotentiallyRestartRace(EnMttag* this, GlobalContext* globalCtx) { * 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) { +void EnMttag_HandleCantWinChoice(EnMttag* this, PlayState* play) { + if ((Message_GetState(&play->msgCtx) == TEXT_STATE_CHOICE) && Message_ShouldAdvance(play)) { + if (play->msgCtx.choiceIndex != 0) { // Exit the race func_8019F230(); gSaveContext.unk_3DD0[4] = 0; - EnMttag_ExitRace(globalCtx, 2, 2); + EnMttag_ExitRace(play, TRANS_TYPE_02, TRANS_TYPE_02); 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); + func_801477B4(play); + func_800B7298(play, &this->actor, 6); gSaveContext.eventInf[1] &= (u8)~8; this->timer = 100; this->actionFunc = EnMttag_Race; @@ -474,12 +474,12 @@ void EnMttag_HandleCantWinChoice(EnMttag* this, GlobalContext* globalCtx) { } } -void EnMttag_Init(Actor* thisx, GlobalContext* globalCtx) { +void EnMttag_Init(Actor* thisx, PlayState* play) { Player* player; EnMttag* this = THIS; - if (gSaveContext.save.entranceIndex == 0xD010) { - player = GET_PLAYER(globalCtx); + if (gSaveContext.save.entrance == ENTRANCE(GORON_RACETRACK, 1)) { + player = GET_PLAYER(play); player->stateFlags1 |= 0x20; this->raceInitialized = false; this->timer = 100; @@ -501,14 +501,14 @@ void EnMttag_Init(Actor* thisx, GlobalContext* globalCtx) { } } -void EnMttag_Destroy(Actor* thisx, GlobalContext* globalCtx) { +void EnMttag_Destroy(Actor* thisx, PlayState* play) { EnMttag* this = THIS; if (gSaveContext.unk_3DD0[4] != 6) { gSaveContext.unk_3DD0[4] = 5; } } -void EnMttag_Update(Actor* thisx, GlobalContext* globalCtx) { +void EnMttag_Update(Actor* thisx, PlayState* play) { EnMttag* this = THIS; - this->actionFunc(this, globalCtx); + this->actionFunc(this, play); } 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 796dff17a..34f86048c 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 @@ -6,7 +6,7 @@ struct EnMttag; -typedef void (*EnMttagActionFunc)(struct EnMttag*, GlobalContext*); +typedef void (*EnMttagActionFunc)(struct EnMttag*, PlayState*); typedef struct EnMttag { /* 0x000 */ Actor actor; diff --git a/src/overlays/actors/ovl_En_Mushi2/z_en_mushi2.c b/src/overlays/actors/ovl_En_Mushi2/z_en_mushi2.c index 60de87422..4e6c471af 100644 --- a/src/overlays/actors/ovl_En_Mushi2/z_en_mushi2.c +++ b/src/overlays/actors/ovl_En_Mushi2/z_en_mushi2.c @@ -12,25 +12,25 @@ #define THIS ((EnMushi2*)thisx) -void EnMushi2_Init(Actor* thisx, GlobalContext* globalCtx); -void EnMushi2_Destroy(Actor* thisx, GlobalContext* globalCtx); -void EnMushi2_Update(Actor* thisx, GlobalContext* globalCtx); -void EnMushi2_Draw(Actor* thisx, GlobalContext* globalCtx); +void EnMushi2_Init(Actor* thisx, PlayState* play); +void EnMushi2_Destroy(Actor* thisx, PlayState* play); +void EnMushi2_Update(Actor* thisx, PlayState* play); +void EnMushi2_Draw(Actor* thisx, PlayState* play); void func_80A6A300(EnMushi2* this); -void func_80A6A36C(EnMushi2* this, GlobalContext* globalCtx); +void func_80A6A36C(EnMushi2* this, PlayState* play); void func_80A6A508(Actor* thisx); -void func_80A6A5C0(EnMushi2* this, GlobalContext* globalCtx); +void func_80A6A5C0(EnMushi2* this, PlayState* play); void func_80A6A794(EnMushi2* this); -void func_80A6A824(EnMushi2* this, GlobalContext* globalCtx); +void func_80A6A824(EnMushi2* this, PlayState* play); void func_80A6A984(EnMushi2* this); -void func_80A6A9E4(EnMushi2* this, GlobalContext* globalCtx); +void func_80A6A9E4(EnMushi2* this, PlayState* play); void func_80A6AAA4(EnMushi2* this); -void func_80A6AB08(EnMushi2* this, GlobalContext* globalCtx); +void func_80A6AB08(EnMushi2* this, PlayState* play); void func_80A6AE14(EnMushi2* this); -void func_80A6AE7C(EnMushi2* this, GlobalContext* globalCtx); +void func_80A6AE7C(EnMushi2* this, PlayState* play); void func_80A6B078(EnMushi2* this); -void func_80A6B0D8(EnMushi2* this, GlobalContext* globalCtx); +void func_80A6B0D8(EnMushi2* this, PlayState* play); const ActorInit En_Mushi2_InitVars = { ACTOR_EN_MUSHI2, @@ -67,7 +67,7 @@ static ColliderJntSphInit sJntSphInit = { OC2_TYPE_1, COLSHAPE_JNTSPH, }, - 1, + ARRAY_COUNT(sJntSphElementsInit), sJntSphElementsInit, }; @@ -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,17 +114,17 @@ 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); } -s32 func_80A68860(EnMushi2* this, GlobalContext* globalCtx) { +s32 func_80A68860(EnMushi2* this, PlayState* play) { s32 pad; s32 sp40; CollisionPoly* sp3C; - f32 temp_f0 = BgCheck_EntityRaycastFloor5(&globalCtx->colCtx, &sp3C, &sp40, &this->actor, &this->actor.world.pos); + f32 temp_f0 = BgCheck_EntityRaycastFloor5(&play->colCtx, &sp3C, &sp40, &this->actor, &this->actor.world.pos); WaterBox* sp34; f32 sp30; @@ -132,12 +132,11 @@ s32 func_80A68860(EnMushi2* this, GlobalContext* globalCtx) { return true; } - return WaterBox_GetSurface1_2(globalCtx, &globalCtx->colCtx, this->actor.world.pos.x, this->actor.world.pos.z, - &sp30, &sp34); + return WaterBox_GetSurface1_2(play, &play->colCtx, this->actor.world.pos.x, this->actor.world.pos.z, &sp30, &sp34); } -s32 func_80A68910(EnMushi2* this, GlobalContext* globalCtx) { - Actor* bean = globalCtx->actorCtx.actorLists[ACTORCAT_ITEMACTION].first; +s32 func_80A68910(EnMushi2* this, PlayState* play) { + Actor* bean = play->actorCtx.actorLists[ACTORCAT_ITEMACTION].first; f32 minDistSq = SQ(100.0f); s32 ret = false; f32 temp_f0; @@ -172,11 +171,11 @@ s32 func_80A68910(EnMushi2* this, GlobalContext* globalCtx) { return ret; } -void func_80A68A78(EnMushi2* this, GlobalContext* globalCtx) { +void func_80A68A78(EnMushi2* this, PlayState* play) { s32 i; for (i = 0; i < ARRAY_COUNT(D_80A6B998); i++) { - Actor_SpawnAsChildAndCutscene(&globalCtx->actorCtx, globalCtx, ACTOR_EN_MUSHI2, this->actor.world.pos.x, + Actor_SpawnAsChildAndCutscene(&play->actorCtx, play, ACTOR_EN_MUSHI2, this->actor.world.pos.x, this->actor.world.pos.y, this->actor.world.pos.z, this->actor.shape.rot.x, this->actor.shape.rot.y + (D_80A6B998 + i)->unk_02, this->actor.shape.rot.z, (D_80A6B998 + i)->unk_00, this->actor.cutscene, this->actor.unk20, NULL); @@ -254,7 +253,7 @@ s32 func_80A68CE4(Vec3f* arg0, Vec3f* arg1, f32 arg2) { return -1; } -s32 func_80A68DD4(EnMushi2* this, GlobalContext* globalCtx) { +s32 func_80A68DD4(EnMushi2* this, PlayState* play) { s32 pad; Player* player; s16 sp2E; @@ -263,7 +262,7 @@ s32 func_80A68DD4(EnMushi2* this, GlobalContext* globalCtx) { if ((this->actor.xzDistToPlayer < 32.0f) && (this->actor.playerHeightRel > -10.0f) && (this->actor.playerHeightRel < 31.0f)) { - player = GET_PLAYER(globalCtx); + player = GET_PLAYER(play); sp2E = BINANG_ROT180(this->actor.yawTowardsPlayer); sp24 = Math_SinS(sp2E); if (Math3D_XZDistanceSquared((sp24 * 16.0f) + player->actor.world.pos.x, @@ -283,12 +282,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 +297,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 +319,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 +344,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 +366,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,15 +434,15 @@ 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; } -void func_80A69424(EnMushi2* this, GlobalContext* globalCtx) { - Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 8.0f, 9.0f, 0.0f, 0x45); +void func_80A69424(EnMushi2* this, PlayState* play) { + Actor_UpdateBgCheckInfo(play, &this->actor, 8.0f, 9.0f, 0.0f, 0x45); } -s32 func_80A69468(EnMushi2* this, GlobalContext* globalCtx) { +s32 func_80A69468(EnMushi2* this, PlayState* play) { s32 pad; Vec3f sp68; Vec3f posB; @@ -466,15 +465,15 @@ s32 func_80A69468(EnMushi2* this, GlobalContext* globalCtx) { posB.y = (y + sp50.y) + this->actor.world.pos.y; posB.z = (z + sp50.z) + this->actor.world.pos.z; - if (BgCheck_EntityLineTest1(&globalCtx->colCtx, &this->actor.prevPos, &posB, &this->unk_33C, &this->poly, true, - true, true, true, &this->polyBgId)) { + if (BgCheck_EntityLineTest1(&play->colCtx, &this->actor.prevPos, &posB, &this->unk_33C, &this->poly, true, true, + true, true, &this->polyBgId)) { this->unk_30C |= 6; return true; } return false; } -s32 func_80A6958C(EnMushi2* this, GlobalContext* globalCtx) { +s32 func_80A6958C(EnMushi2* this, PlayState* play) { s32 pad; Vec3f posA; Vec3f posB; @@ -487,7 +486,7 @@ s32 func_80A6958C(EnMushi2* this, GlobalContext* globalCtx) { posB.y = (this->unk_31C.y * -4.0f) + this->actor.world.pos.y; posB.z = (this->unk_31C.z * -4.0f) + this->actor.world.pos.z; - if (BgCheck_EntityLineTest1(&globalCtx->colCtx, &posA, &posB, &this->unk_33C, &this->poly, true, true, true, true, + if (BgCheck_EntityLineTest1(&play->colCtx, &posA, &posB, &this->unk_33C, &this->poly, true, true, true, true, &this->polyBgId)) { this->unk_30C |= 0xA; return true; @@ -495,7 +494,7 @@ s32 func_80A6958C(EnMushi2* this, GlobalContext* globalCtx) { return false; } -s32 func_80A6969C(EnMushi2* this, GlobalContext* globalCtx) { +s32 func_80A6969C(EnMushi2* this, PlayState* play) { s32 pad; Vec3f posA; Vec3f posB; @@ -511,7 +510,7 @@ s32 func_80A6969C(EnMushi2* this, GlobalContext* globalCtx) { posB.y = this->actor.prevPos.y + sp38.y + (this->unk_328.y * -4.0f); posB.z = this->actor.prevPos.z + sp38.z + (this->unk_328.z * -4.0f); - if (BgCheck_EntityLineTest1(&globalCtx->colCtx, &posA, &posB, &this->unk_33C, &this->poly, true, true, true, true, + if (BgCheck_EntityLineTest1(&play->colCtx, &posA, &posB, &this->unk_33C, &this->poly, true, true, true, true, &this->polyBgId)) { this->unk_30C |= (0x10 | 0x2); return true; @@ -519,7 +518,7 @@ s32 func_80A6969C(EnMushi2* this, GlobalContext* globalCtx) { return false; } -void func_80A697C4(EnMushi2* this, GlobalContext* globalCtx) { +void func_80A697C4(EnMushi2* this, PlayState* play) { s32 pad; CollisionPoly* poly = this->poly; s32 bgId = this->polyBgId; @@ -529,12 +528,12 @@ void func_80A697C4(EnMushi2* this, GlobalContext* globalCtx) { f32 sp2C; this->unk_30C &= ~(0x40 | 0x8 | 0x2); - if (!func_80A69468(this, globalCtx) && !func_80A6958C(this, globalCtx)) { - func_80A6969C(this, globalCtx); + if (!func_80A69468(this, play) && !func_80A6958C(this, play)) { + func_80A6969C(this, play); } - if (WaterBox_GetSurface1_2(globalCtx, &globalCtx->colCtx, this->actor.world.pos.x, this->actor.world.pos.z, - &sp2C, &sp30)) { + if (WaterBox_GetSurface1_2(play, &play->colCtx, this->actor.world.pos.x, this->actor.world.pos.z, &sp2C, + &sp30)) { this->actor.depthInWater = sp2C - this->actor.world.pos.y; if (this->actor.depthInWater >= 1.0f) { this->unk_30C |= 0x20; @@ -572,7 +571,7 @@ void func_80A697C4(EnMushi2* this, GlobalContext* globalCtx) { } } -s32 func_80A699E4(EnMushi2* this, GlobalContext* globalCtx) { +s32 func_80A699E4(EnMushi2* this, PlayState* play) { s32 pad; WaterBox* sp40; f32 sp3C; @@ -582,7 +581,7 @@ s32 func_80A699E4(EnMushi2* this, GlobalContext* globalCtx) { f32 y = (2.0f * this->unk_328.y) + this->actor.world.pos.y; f32 z = (2.0f * this->unk_328.z) + this->actor.world.pos.z; - if (WaterBox_GetSurface1_2(globalCtx, &globalCtx->colCtx, x, z, &sp3C, &sp40) && (y <= sp3C)) { + if (WaterBox_GetSurface1_2(play, &play->colCtx, x, z, &sp3C, &sp40) && (y <= sp3C)) { return true; } } @@ -618,7 +617,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 +633,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; @@ -676,26 +675,26 @@ void func_80A69D3C(EnMushi2* this) { } } -s32 func_80A69EE4(EnMushi2* this, GlobalContext* globalCtx) { +s32 func_80A69EE4(EnMushi2* this, PlayState* play) { s32 pad; WaterBox* waterBox; f32 waterSurface; s32 bgId; - if (WaterBox_GetSurfaceImpl(globalCtx, &globalCtx->colCtx, this->actor.world.pos.x, this->actor.world.pos.z, - &waterSurface, &waterBox, &bgId) && + if (WaterBox_GetSurfaceImpl(play, &play->colCtx, this->actor.world.pos.x, this->actor.world.pos.z, &waterSurface, + &waterBox, &bgId) && (this->actor.world.pos.y < waterSurface)) { return true; } return false; } -void func_80A69F5C(Actor* thisx, GlobalContext* globalCtx) { +void func_80A69F5C(Actor* thisx, PlayState* play) { EnMushi2* this = THIS; s32 i; for (i = 0; i < 7; i++) { - EffectSsBubble_Spawn(globalCtx, &this->actor.world.pos, -10.0f, 10.0f, 10.0f, (Rand_ZeroOne() * 0.09f) + 0.05f); + EffectSsBubble_Spawn(play, &this->actor.world.pos, -10.0f, 10.0f, 10.0f, (Rand_ZeroOne() * 0.09f) + 0.05f); } } @@ -737,30 +736,29 @@ void func_80A6A0D8(EnMushi2* this) { } } -void EnMushi2_Init(Actor* thisx, GlobalContext* globalCtx) { +void EnMushi2_Init(Actor* thisx, PlayState* play) { EnMushi2* this = THIS; s32 pad; s32 sp3C; Actor_ProcessInitChain(&this->actor, sInitChain); if (!ENMUSHI2_GET_3(&this->actor)) { - func_80A68A78(this, globalCtx); + func_80A68A78(this, play); } this->actor.shape.rot.y += Rand_S16Offset(-2000, 4000); this->actor.home.rot.y = this->actor.shape.rot.y; this->actor.world.rot.y = this->actor.shape.rot.y; func_80A68F24(this); - 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); + SkelAnime_Init(play, &this->skelAnime, &gameplay_keep_Skel_0527A0, &gameplay_keep_Anim_05140C, this->jointTable, + this->morphTable, 24); + Animation_Change(&this->skelAnime, &gameplay_keep_Anim_05140C, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP_INTERP, 0.0f); + Collider_InitJntSph(play, &this->collider); + Collider_SetJntSph(play, &this->collider, &this->actor, &sJntSphInit, this->colliderElements); func_80A68808(this); this->actor.colChkInfo.mass = 30; - sp3C = func_80A69EE4(this, globalCtx); + sp3C = func_80A69EE4(this, play); - if ((sp3C == 0) && func_80A68860(this, globalCtx) && func_80A68910(this, globalCtx) && - !ENMUSHI2_GET_3(&this->actor)) { + if ((sp3C == 0) && func_80A68860(this, play) && func_80A68910(this, play) && !ENMUSHI2_GET_3(&this->actor)) { func_80A6A024(this); } @@ -769,8 +767,8 @@ void EnMushi2_Init(Actor* thisx, GlobalContext* globalCtx) { this->unk_30C = 1; if (sp3C != 0) { - func_80A69F5C(&this->actor, globalCtx); - this->actor.world.rot.y = (u32)Rand_Next() >> 0x10; + func_80A69F5C(&this->actor, play); + this->actor.world.rot.y = Rand_Next() >> 0x10; func_80A6AE14(this); } else { func_80A6A300(this); @@ -779,10 +777,10 @@ void EnMushi2_Init(Actor* thisx, GlobalContext* globalCtx) { func_80A68B3C(this); } -void EnMushi2_Destroy(Actor* thisx, GlobalContext* globalCtx) { +void EnMushi2_Destroy(Actor* thisx, PlayState* play) { EnMushi2* this = THIS; - Collider_DestroyJntSph(globalCtx, &this->collider); + Collider_DestroyJntSph(play, &this->collider); func_80A68B6C(this); } @@ -795,14 +793,14 @@ void func_80A6A300(EnMushi2* this) { this->actionFunc = func_80A6A36C; } -void func_80A6A36C(EnMushi2* this, GlobalContext* globalCtx) { +void func_80A6A36C(EnMushi2* this, PlayState* play) { s32 pad; s32 sp20 = false; Math_StepToF(&this->actor.speedXZ, 0.0f, 0.2f); this->actor.velocity.y -= this->actor.velocity.y * D_80A6BA14[ENMUSHI2_GET_3(&this->actor)]; Actor_MoveWithGravity(&this->actor); - func_80A69424(this, globalCtx); + func_80A69424(this, play); this->actor.shape.rot.y += this->unk_370; this->actor.world.rot.y = this->actor.shape.rot.y; if ((this->actor.floorHeight < this->actor.world.pos.y) && @@ -848,7 +846,7 @@ void func_80A6A508(Actor* thisx) { this->actionFunc = func_80A6A5C0; } -void func_80A6A5C0(EnMushi2* this, GlobalContext* globalCtx) { +void func_80A6A5C0(EnMushi2* this, PlayState* play) { EnMushi2* this2 = this; func_80A69D3C(this); @@ -860,7 +858,7 @@ void func_80A6A5C0(EnMushi2* this, GlobalContext* globalCtx) { } func_80A68ED8(this); - func_80A697C4(this, globalCtx); + func_80A697C4(this, play); if (this->unk_30C & 0x40) { func_80A69388(this); } @@ -876,7 +874,7 @@ void func_80A6A5C0(EnMushi2* this, GlobalContext* globalCtx) { func_80A6AAA4(this); } else if (this->unk_368 <= 0) { func_80A6A794(this); - } else if (((globalCtx->gameplayFrames % 2) != 0) && func_80A699E4(this, globalCtx)) { + } else if (((play->gameplayFrames % 2) != 0) && func_80A699E4(this, play)) { func_80A6A984(this); } } @@ -892,12 +890,12 @@ void func_80A6A794(EnMushi2* this) { this->actionFunc = func_80A6A824; } -void func_80A6A824(EnMushi2* this, GlobalContext* globalCtx) { +void func_80A6A824(EnMushi2* this, PlayState* play) { EnMushi2* this2 = this; Math_SmoothStepToF(&this->actor.speedXZ, this->unk_35C, 0.1f, 0.5f, 0.0f); func_80A68ED8(this); - func_80A697C4(this, globalCtx); + func_80A697C4(this, play); if (this->unk_30C & 0x40) { func_80A69388(this); @@ -928,13 +926,13 @@ void func_80A6A984(EnMushi2* this) { this->actionFunc = func_80A6A9E4; } -void func_80A6A9E4(EnMushi2* this, GlobalContext* globalCtx) { +void func_80A6A9E4(EnMushi2* this, PlayState* play) { func_80A68F9C(this, this->unk_370); func_80A69388(this); if ((this->unk_36A <= 0) || func_80A68BA0(this)) { func_80A6B078(this); } else if (this->unk_368 <= 0) { - func_80A697C4(this, globalCtx); + func_80A697C4(this, play); if (this->unk_30C & 0x40) { func_80A69388(this); } @@ -957,7 +955,7 @@ void func_80A6AAA4(EnMushi2* this) { this->actionFunc = func_80A6AB08; } -void func_80A6AB08(EnMushi2* this, GlobalContext* globalCtx) { +void func_80A6AB08(EnMushi2* this, PlayState* play) { s32 pad; s16 temp; @@ -968,7 +966,7 @@ void func_80A6AB08(EnMushi2* this, GlobalContext* globalCtx) { } Actor_MoveWithGravity(&this->actor); - func_80A69424(this, globalCtx); + func_80A69424(this, play); Math_StepToF(&this->actor.world.pos.y, this->actor.world.pos.y + this->actor.depthInWater, 2.8f); this->skelAnime.playSpeed = this->unk_368 * 0.018f; this->skelAnime.playSpeed = CLAMP(this->skelAnime.playSpeed, 0.1f, 1.9f); @@ -997,7 +995,7 @@ void func_80A6AB08(EnMushi2* this, GlobalContext* globalCtx) { sp3C.x = this->actor.world.pos.x; sp3C.y = this->actor.world.pos.y + this->actor.depthInWater; sp3C.z = this->actor.world.pos.z; - EffectSsGRipple_Spawn(globalCtx, &sp3C, 40, 200, 4); + EffectSsGRipple_Spawn(play, &sp3C, 40, 200, 4); } if ((this->unk_368 <= 0) || (this->unk_36A <= 0) || func_80A68BA0(this)) { @@ -1019,7 +1017,7 @@ void func_80A6AE14(EnMushi2* this) { this->actionFunc = func_80A6AE7C; } -void func_80A6AE7C(EnMushi2* this, GlobalContext* globalCtx) { +void func_80A6AE7C(EnMushi2* this, PlayState* play) { f32 temp_f2; this->actor.shape.rot.x -= 0x1F4; @@ -1030,12 +1028,12 @@ void func_80A6AE7C(EnMushi2* this, GlobalContext* globalCtx) { this->actor.gravity = -0.04f - (Rand_ZeroOne() * 0.02f); this->actor.velocity.y *= 0.95f; Actor_MoveWithGravity(&this->actor); - func_80A69424(this, globalCtx); + func_80A69424(this, play); temp_f2 = this->actor.scale.x - (1.0f / 20000.0f); Actor_SetScale(&this->actor, CLAMP_MIN(temp_f2, 0.001f)); if ((this->actor.flags & ACTOR_FLAG_40) && (this->actor.depthInWater > 5.0f) && - (this->actor.depthInWater < 30.0f) && ((Rand_Next() & 0x1FF) < this->unk_368)) { - EffectSsBubble_Spawn(globalCtx, &this->actor.world.pos, -5.0f, 5.0f, 5.0f, + (this->actor.depthInWater < 30.0f) && ((s32)(Rand_Next() & 0x1FF) < this->unk_368)) { + EffectSsBubble_Spawn(play, &this->actor.world.pos, -5.0f, 5.0f, 5.0f, ((Rand_ZeroOne() * 4.0f) + 2.0f) * this->actor.scale.x); } @@ -1053,7 +1051,7 @@ void func_80A6B078(EnMushi2* this) { this->actionFunc = func_80A6B0D8; } -void func_80A6B0D8(EnMushi2* this, GlobalContext* globalCtx) { +void func_80A6B0D8(EnMushi2* this, PlayState* play) { s32 pad[2]; f32 temp_f2; @@ -1069,7 +1067,7 @@ void func_80A6B0D8(EnMushi2* this, GlobalContext* globalCtx) { func_80A69388(this); } - if ((globalCtx->gameplayFrames % 2) != 0) { + if ((play->gameplayFrames % 2) != 0) { temp_f2 = 0.6f; } else { temp_f2 = -0.6f; @@ -1087,7 +1085,7 @@ void func_80A6B0D8(EnMushi2* this, GlobalContext* globalCtx) { s32 sp44 = 0; if (this->poly != NULL) { - u32 temp_v0 = func_800C99D4(&globalCtx->colCtx, this->poly, this->polyBgId); + u32 temp_v0 = func_800C99D4(&play->colCtx, this->poly, this->polyBgId); if ((temp_v0 == 5) || (temp_v0 == 14) || (temp_v0 == 15)) { sp44 = 1; } @@ -1095,7 +1093,7 @@ void func_80A6B0D8(EnMushi2* this, GlobalContext* globalCtx) { sp48.x = (this->unk_328.x * -0.6f) + (this->unk_31C.x * 0.1f); sp48.y = (this->unk_328.y * -0.6f) + (this->unk_31C.y * 0.1f); sp48.z = (this->unk_328.z * -0.6f) + (this->unk_31C.z * 0.1f); - func_800B0E48(globalCtx, &this->actor.world.pos, &sp48, &gZeroVec3f, &D_80A6B984[sp44], &D_80A6B98C[sp44], + func_800B0E48(play, &this->actor.world.pos, &sp48, &gZeroVec3f, &D_80A6B984[sp44], &D_80A6B98C[sp44], (Rand_ZeroOne() * 5.0f) + 8.0f, (Rand_ZeroOne() * 5.0f) + 8.0f); } @@ -1111,7 +1109,7 @@ void func_80A6B0D8(EnMushi2* this, GlobalContext* globalCtx) { } } -void EnMushi2_Update(Actor* thisx, GlobalContext* globalCtx) { +void EnMushi2_Update(Actor* thisx, PlayState* play) { EnMushi2* this = THIS; s32 pad; f32 sp4C; @@ -1122,7 +1120,7 @@ void EnMushi2_Update(Actor* thisx, GlobalContext* globalCtx) { this->unk_34C = NULL; } - if (Actor_HasParent(&this->actor, globalCtx)) { + if (Actor_HasParent(&this->actor, play)) { func_80A6A094(this); func_80A6A0D8(this); Actor_MarkForDeath(&this->actor); @@ -1158,11 +1156,11 @@ void EnMushi2_Update(Actor* thisx, GlobalContext* globalCtx) { if ((temp != BGCHECK_SCENE) && ((this->actionFunc == func_80A6A5C0) || (this->actionFunc == func_80A6A824) || (this->actionFunc == func_80A6A9E4) || (this->actionFunc == func_80A6B0D8)) && - BgCheck2_UpdateActorAttachedToMesh(&globalCtx->colCtx, temp, &this->actor)) { + BgCheck2_UpdateActorAttachedToMesh(&play->colCtx, temp, &this->actor)) { func_80A68F24(this); } - this->actionFunc(this, globalCtx); + this->actionFunc(this, play); if (this->actor.update != NULL) { if ((this->actionFunc == func_80A6AB08) || (this->actionFunc == func_80A6AE7C)) { @@ -1218,21 +1216,21 @@ void EnMushi2_Update(Actor* thisx, GlobalContext* globalCtx) { 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); + CollisionCheck_SetOC(play, &play->colChkCtx, &this->collider.base); } } } - if ((this->unk_30C & 1) && func_80A68DD4(this, globalCtx)) { - Actor_PickUp(&this->actor, globalCtx, GI_MAX, 60.0f, 30.0f); + if ((this->unk_30C & 1) && func_80A68DD4(this, play)) { + Actor_PickUp(&this->actor, play, GI_MAX, 60.0f, 30.0f); } } } -void EnMushi2_Draw(Actor* thisx, GlobalContext* globalCtx) { +void EnMushi2_Draw(Actor* thisx, PlayState* play) { EnMushi2* this = THIS; func_80A687A0(this); - func_8012C28C(globalCtx->state.gfxCtx); - SkelAnime_DrawOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, NULL, NULL, NULL); + func_8012C28C(play->state.gfxCtx); + SkelAnime_DrawOpa(play, this->skelAnime.skeleton, this->skelAnime.jointTable, NULL, NULL, NULL); } diff --git a/src/overlays/actors/ovl_En_Mushi2/z_en_mushi2.h b/src/overlays/actors/ovl_En_Mushi2/z_en_mushi2.h index f773cd746..159116928 100644 --- a/src/overlays/actors/ovl_En_Mushi2/z_en_mushi2.h +++ b/src/overlays/actors/ovl_En_Mushi2/z_en_mushi2.h @@ -5,44 +5,44 @@ struct EnMushi2; -typedef void (*EnMushi2ActionFunc)(struct EnMushi2*, GlobalContext*); +typedef void (*EnMushi2ActionFunc)(struct EnMushi2*, PlayState*); #define ENMUSHI2_GET_3(thisx) ((thisx)->params & 3) typedef struct { - /* 0x00 */ s16 unk_00; - /* 0x02 */ s16 unk_02; -} EnMushi2Struct; + /* 0x0 */ s16 unk_00; + /* 0x2 */ s16 unk_02; +} EnMushi2Struct; // size = 0x4 typedef struct EnMushi2 { - /* 0x0000 */ Actor actor; - /* 0x0144 */ SkelAnime skelAnime; - /* 0x0188 */ Vec3s jointTable[24]; - /* 0x0218 */ Vec3s morphTable[24]; - /* 0x02A8 */ ColliderJntSph collider; - /* 0x02C8 */ ColliderJntSphElement colliderElements[1]; - /* 0x0308 */ EnMushi2ActionFunc actionFunc; - /* 0x030C */ s32 unk_30C; - /* 0x0310 */ Vec3f unk_310; - /* 0x031C */ Vec3f unk_31C; - /* 0x0328 */ Vec3f unk_328; - /* 0x0334 */ CollisionPoly* poly; - /* 0x0338 */ s32 polyBgId; - /* 0x033C */ Vec3f unk_33C; - /* 0x0348 */ f32 unk_348; - /* 0x034C */ struct ObjBean* unk_34C; - /* 0x0350 */ f32 unk_350; - /* 0x0354 */ f32 unk_354; - /* 0x0358 */ f32 unk_358; - /* 0x035C */ f32 unk_35C; - /* 0x0360 */ f32 unk_360; - /* 0x0364 */ s16 unk_364; - /* 0x0366 */ s16 unk_366; - /* 0x0368 */ s16 unk_368; - /* 0x036A */ s16 unk_36A; - /* 0x036C */ s16 unk_36C; - /* 0x036E */ s16 unk_36E; - /* 0x0370 */ s16 unk_370; + /* 0x000 */ Actor actor; + /* 0x144 */ SkelAnime skelAnime; + /* 0x188 */ Vec3s jointTable[24]; + /* 0x218 */ Vec3s morphTable[24]; + /* 0x2A8 */ ColliderJntSph collider; + /* 0x2C8 */ ColliderJntSphElement colliderElements[1]; + /* 0x308 */ EnMushi2ActionFunc actionFunc; + /* 0x30C */ s32 unk_30C; + /* 0x310 */ Vec3f unk_310; + /* 0x31C */ Vec3f unk_31C; + /* 0x328 */ Vec3f unk_328; + /* 0x334 */ CollisionPoly* poly; + /* 0x338 */ s32 polyBgId; + /* 0x33C */ Vec3f unk_33C; + /* 0x348 */ f32 unk_348; + /* 0x34C */ struct ObjBean* unk_34C; + /* 0x350 */ f32 unk_350; + /* 0x354 */ f32 unk_354; + /* 0x358 */ f32 unk_358; + /* 0x35C */ f32 unk_35C; + /* 0x360 */ f32 unk_360; + /* 0x364 */ s16 unk_364; + /* 0x366 */ s16 unk_366; + /* 0x368 */ s16 unk_368; + /* 0x36A */ s16 unk_36A; + /* 0x36C */ s16 unk_36C; + /* 0x36E */ s16 unk_36E; + /* 0x370 */ s16 unk_370; } EnMushi2; // size = 0x374 extern const ActorInit En_Mushi2_InitVars; diff --git a/src/overlays/actors/ovl_En_Muto/z_en_muto.c b/src/overlays/actors/ovl_En_Muto/z_en_muto.c index 4aed3132f..69861434b 100644 --- a/src/overlays/actors/ovl_En_Muto/z_en_muto.c +++ b/src/overlays/actors/ovl_En_Muto/z_en_muto.c @@ -11,18 +11,18 @@ #define THIS ((EnMuto*)thisx) -void EnMuto_Init(Actor* thisx, GlobalContext* globalCtx); -void EnMuto_Destroy(Actor* thisx, GlobalContext* globalCtx); -void EnMuto_Update(Actor* thisx, GlobalContext* globalCtx); -void EnMuto_Draw(Actor* thisx, GlobalContext* globalCtx); +void EnMuto_Init(Actor* thisx, PlayState* play); +void EnMuto_Destroy(Actor* thisx, PlayState* play); +void EnMuto_Update(Actor* thisx, PlayState* play); +void EnMuto_Draw(Actor* thisx, PlayState* play); -void EnMuto_ChangeAnim(EnMuto* this, s32 arg1); +void EnMuto_ChangeAnim(EnMuto* this, s32 animIndex); void EnMuto_SetHeadRotation(EnMuto* this); void EnMuto_SetupIdle(EnMuto* this); -void EnMuto_Idle(EnMuto* this, GlobalContext* globalCtx); -void EnMuto_SetupDialogue(EnMuto* this, GlobalContext* globalCtx); -void EnMuto_InDialogue(EnMuto* this, GlobalContext* globalCtx); -s32 EnMuto_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, Actor* thisx); +void EnMuto_Idle(EnMuto* this, PlayState* play); +void EnMuto_SetupDialogue(EnMuto* this, PlayState* play); +void EnMuto_InDialogue(EnMuto* this, PlayState* play); +s32 EnMuto_OverrideLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, Actor* thisx); const ActorInit En_Muto_InitVars = { ACTOR_EN_MUTO, @@ -58,13 +58,13 @@ static ColliderCylinderInit sCylinderInit = { { 20, 60, 0, { 0, 0, 0 } }, }; -void EnMuto_Init(Actor* thisx, GlobalContext* globalCtx) { +void EnMuto_Init(Actor* thisx, PlayState* play) { EnMuto* this = THIS; this->actor.colChkInfo.mass = MASS_IMMOVABLE; ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 40.0f); - SkelAnime_InitFlex(globalCtx, &this->skelAnime, &object_toryo_Skel_007150, &object_toryo_Anim_000E50, - this->jointTable, this->morphTable, 17); + SkelAnime_InitFlex(play, &this->skelAnime, &object_toryo_Skel_007150, &object_toryo_Anim_000E50, this->jointTable, + this->morphTable, 17); this->isInMayorsRoom = this->actor.params; if (!this->isInMayorsRoom) { @@ -89,14 +89,14 @@ void EnMuto_Init(Actor* thisx, GlobalContext* globalCtx) { this->actor.targetMode = 6; this->actor.gravity = -3.0f; - Collider_InitAndSetCylinder(globalCtx, &this->collider, &this->actor, &sCylinderInit); + Collider_InitAndSetCylinder(play, &this->collider, &this->actor, &sCylinderInit); EnMuto_SetupIdle(this); } -void EnMuto_Destroy(Actor* thisx, GlobalContext* globalCtx) { +void EnMuto_Destroy(Actor* thisx, PlayState* play) { EnMuto* this = THIS; - Collider_DestroyCylinder(globalCtx, &this->collider); + Collider_DestroyCylinder(play, &this->collider); } void EnMuto_ChangeAnim(EnMuto* this, s32 animIndex) { @@ -129,26 +129,29 @@ void EnMuto_SetupIdle(EnMuto* this) { this->actionFunc = EnMuto_Idle; } -void EnMuto_Idle(EnMuto* this, GlobalContext* globalCtx) { +void EnMuto_Idle(EnMuto* this, PlayState* play) { Player* player; this->actor.textId = sTextIds[this->textIdIndex]; - if (!this->isInMayorsRoom && (player = GET_PLAYER(globalCtx))->transformation == PLAYER_FORM_DEKU) { - if (!(gSaveContext.save.weekEventReg[88] & 8)) { - this->actor.textId = 0x62C; - } else { - this->actor.textId = 0x62B; + if (!this->isInMayorsRoom) { + player = GET_PLAYER(play); + if (player->transformation == PLAYER_FORM_DEKU) { + if (!(gSaveContext.save.weekEventReg[88] & 8)) { + this->actor.textId = 0x62C; + } else { + this->actor.textId = 0x62B; + } } } if (1) {} // Needed to match - if (!this->isInMayorsRoom && Player_GetMask(globalCtx) == PLAYER_MASK_KAFEIS_MASK) { + if (!this->isInMayorsRoom && Player_GetMask(play) == PLAYER_MASK_KAFEIS_MASK) { this->actor.textId = 0x2363; } - if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { - EnMuto_SetupDialogue(this, globalCtx); + if (Actor_ProcessTalkRequest(&this->actor, &play->state)) { + EnMuto_SetupDialogue(this, play); return; } @@ -164,20 +167,20 @@ void EnMuto_Idle(EnMuto* this, GlobalContext* globalCtx) { if (gSaveContext.save.weekEventReg[60] & 8) { this->textIdIndex = 1; } - if (Player_GetMask(globalCtx) == PLAYER_MASK_COUPLE) { + if (Player_GetMask(play) == PLAYER_MASK_COUPLE) { this->textIdIndex = 4; } if (this->cutsceneState == 1) { - EnMuto_SetupDialogue(this, globalCtx); + EnMuto_SetupDialogue(this, play); return; } } - func_800B8614(&this->actor, globalCtx, 80.0f); + func_800B8614(&this->actor, play, 80.0f); } -void EnMuto_SetupDialogue(EnMuto* this, GlobalContext* globalCtx) { +void EnMuto_SetupDialogue(EnMuto* this, PlayState* play) { if (!this->isInMayorsRoom) { this->yawTowardsTarget = 0; } @@ -185,18 +188,18 @@ void EnMuto_SetupDialogue(EnMuto* this, GlobalContext* globalCtx) { if (this->targetActor != NULL) { this->shouldSetHeadRotation = true; this->cutsceneState = 1; - Actor_ChangeFocus(this->targetActor, globalCtx, this->targetActor); + Actor_ChangeFocus(this->targetActor, play, this->targetActor); } this->isInDialogue = true; this->actionFunc = EnMuto_InDialogue; } -void EnMuto_InDialogue(EnMuto* this, GlobalContext* globalCtx) { +void EnMuto_InDialogue(EnMuto* this, PlayState* play) { if (!this->isInMayorsRoom) { this->yawTowardsTarget = this->actor.yawTowardsPlayer; - if (Message_GetState(&globalCtx->msgCtx) == 5 && Message_ShouldAdvance(globalCtx)) { - func_801477B4(globalCtx); + if ((Message_GetState(&play->msgCtx) == TEXT_STATE_5) && Message_ShouldAdvance(play)) { + func_801477B4(play); if (this->actor.textId == 0x62C) { gSaveContext.save.weekEventReg[88] |= 8; @@ -226,13 +229,13 @@ void EnMuto_InDialogue(EnMuto* this, GlobalContext* globalCtx) { } } - if (globalCtx->msgCtx.currentTextId == 0x2AC6 || globalCtx->msgCtx.currentTextId == 0x2AC7 || - globalCtx->msgCtx.currentTextId == 0x2AC8) { + if (play->msgCtx.currentTextId == 0x2AC6 || play->msgCtx.currentTextId == 0x2AC7 || + play->msgCtx.currentTextId == 0x2AC8) { this->skelAnime.playSpeed = 0.0f; this->yawTowardsTarget = this->actor.yawTowardsPlayer; this->skelAnime.curFrame = 30.0f; } - if (globalCtx->msgCtx.currentTextId == 0x2ACF) { + if (play->msgCtx.currentTextId == 0x2ACF) { this->skelAnime.playSpeed = 0.0f; } @@ -241,8 +244,8 @@ void EnMuto_InDialogue(EnMuto* this, GlobalContext* globalCtx) { } } -void EnMuto_Update(Actor* thisx, GlobalContext* globalCtx2) { - GlobalContext* globalCtx = globalCtx2; +void EnMuto_Update(Actor* thisx, PlayState* play2) { + PlayState* play = play2; EnMuto* this = THIS; SkelAnime_Update(&this->skelAnime); @@ -256,7 +259,7 @@ void EnMuto_Update(Actor* thisx, GlobalContext* globalCtx2) { return; } - this->actionFunc(this, globalCtx); + this->actionFunc(this, play); DECR(this->unusedCounter); @@ -269,16 +272,15 @@ void EnMuto_Update(Actor* thisx, GlobalContext* globalCtx2) { Math_SmoothStepToS(&this->headRot.x, this->headRotTarget.x, 1, 0x3E8, 0); Math_SmoothStepToS(&this->waistRot.y, this->waistRotTarget.y, 1, 0xBB8, 0); - Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 20.0f, 20.0f, 50.0f, 0x1DU); + Actor_UpdateBgCheckInfo(play, &this->actor, 20.0f, 20.0f, 50.0f, 0x1D); this->actor.uncullZoneForward = 500.0f; Collider_UpdateCylinder(&this->actor, &this->collider); - CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + CollisionCheck_SetOC(play, &play->colChkCtx, &this->collider.base); } -s32 EnMuto_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, - Actor* thisx) { +s32 EnMuto_OverrideLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, Actor* thisx) { EnMuto* this = THIS; if (limbIndex == 1) { @@ -293,10 +295,10 @@ s32 EnMuto_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList return false; } -void EnMuto_Draw(Actor* thisx, GlobalContext* globalCtx) { +void EnMuto_Draw(Actor* thisx, PlayState* play) { EnMuto* this = THIS; - func_8012C28C(globalCtx->state.gfxCtx); - SkelAnime_DrawFlexOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, + func_8012C28C(play->state.gfxCtx); + SkelAnime_DrawFlexOpa(play, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, EnMuto_OverrideLimbDraw, NULL, &this->actor); } diff --git a/src/overlays/actors/ovl_En_Muto/z_en_muto.h b/src/overlays/actors/ovl_En_Muto/z_en_muto.h index 29af0d624..e05e29492 100644 --- a/src/overlays/actors/ovl_En_Muto/z_en_muto.h +++ b/src/overlays/actors/ovl_En_Muto/z_en_muto.h @@ -5,29 +5,29 @@ struct EnMuto; -typedef void (*EnMutoActionFunc)(struct EnMuto*, GlobalContext*); +typedef void (*EnMutoActionFunc)(struct EnMuto*, PlayState*); typedef struct EnMuto { - /* 0x0000 */ Actor actor; - /* 0x0144 */ SkelAnime skelAnime; - /* 0x0188 */ Vec3s jointTable[17]; - /* 0x01EE */ Vec3s morphTable[17]; - /* 0x0254 */ EnMutoActionFunc actionFunc; - /* 0x0258 */ Vec3s headRot; - /* 0x025E */ Vec3s headRotTarget; - /* 0x0262 */ Vec3s waistRot; - /* 0x026A */ Vec3s waistRotTarget; - /* 0x0270 */ s16 unusedCounter; - /* 0x0274 */ f32 frameIndex; - /* 0x0278 */ s16 isInDialogue; - /* 0x027A */ s16 textIdIndex; - /* 0x027C */ s16 yawTowardsTarget; - /* 0x0280 */ s32 isInMayorsRoom; - /* 0x0284 */ s32 shouldSetHeadRotation; - /* 0x0288 */ Actor* targetActor; - /* 0x028C */ s32 cutsceneState; - /* 0x0290 */ s32 animIndex; - /* 0x0294 */ ColliderCylinder collider; + /* 0x000 */ Actor actor; + /* 0x144 */ SkelAnime skelAnime; + /* 0x188 */ Vec3s jointTable[17]; + /* 0x1EE */ Vec3s morphTable[17]; + /* 0x254 */ EnMutoActionFunc actionFunc; + /* 0x258 */ Vec3s headRot; + /* 0x25E */ Vec3s headRotTarget; + /* 0x262 */ Vec3s waistRot; + /* 0x26A */ Vec3s waistRotTarget; + /* 0x270 */ s16 unusedCounter; + /* 0x274 */ f32 frameIndex; + /* 0x278 */ s16 isInDialogue; + /* 0x27A */ s16 textIdIndex; + /* 0x27C */ s16 yawTowardsTarget; + /* 0x280 */ s32 isInMayorsRoom; + /* 0x284 */ s32 shouldSetHeadRotation; + /* 0x288 */ Actor* targetActor; + /* 0x28C */ s32 cutsceneState; + /* 0x290 */ s32 animIndex; + /* 0x294 */ ColliderCylinder collider; } EnMuto; // size = 0x2E0 extern const ActorInit En_Muto_InitVars; diff --git a/src/overlays/actors/ovl_En_Nb/z_en_nb.c b/src/overlays/actors/ovl_En_Nb/z_en_nb.c index 5f24e5b01..9e27fe605 100644 --- a/src/overlays/actors/ovl_En_Nb/z_en_nb.c +++ b/src/overlays/actors/ovl_En_Nb/z_en_nb.c @@ -10,13 +10,13 @@ #define THIS ((EnNb*)thisx) -void EnNb_Init(Actor* thisx, GlobalContext* globalCtx); -void EnNb_Destroy(Actor* thisx, GlobalContext* globalCtx); -void EnNb_Update(Actor* thisx, GlobalContext* globalCtx); -void EnNb_Draw(Actor* thisx, GlobalContext* globalCtx); +void EnNb_Init(Actor* thisx, PlayState* play); +void EnNb_Destroy(Actor* thisx, PlayState* play); +void EnNb_Update(Actor* thisx, PlayState* play); +void EnNb_Draw(Actor* thisx, PlayState* play); -void func_80BC0D84(EnNb* this, GlobalContext* globalCtx); -void func_80BC0EAC(EnNb* this, GlobalContext* globalCtx); +void func_80BC0D84(EnNb* this, PlayState* play); +void func_80BC0EAC(EnNb* this, PlayState* play); #if 0 const ActorInit En_Nb_InitVars = { diff --git a/src/overlays/actors/ovl_En_Nb/z_en_nb.h b/src/overlays/actors/ovl_En_Nb/z_en_nb.h index f3b5fd026..b094456d9 100644 --- a/src/overlays/actors/ovl_En_Nb/z_en_nb.h +++ b/src/overlays/actors/ovl_En_Nb/z_en_nb.h @@ -5,13 +5,13 @@ struct EnNb; -typedef void (*EnNbActionFunc)(struct EnNb*, GlobalContext*); +typedef void (*EnNbActionFunc)(struct EnNb*, PlayState*); typedef struct EnNb { - /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x44]; - /* 0x0188 */ EnNbActionFunc actionFunc; - /* 0x018C */ char unk_18C[0x110]; + /* 0x000 */ Actor actor; + /* 0x144 */ char unk_144[0x44]; + /* 0x188 */ EnNbActionFunc actionFunc; + /* 0x18C */ char unk_18C[0x110]; } EnNb; // size = 0x29C extern const ActorInit En_Nb_InitVars; diff --git a/src/overlays/actors/ovl_En_Neo_Reeba/z_en_neo_reeba.c b/src/overlays/actors/ovl_En_Neo_Reeba/z_en_neo_reeba.c index 591d4ddcb..bd56373e5 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 @@ -11,30 +11,30 @@ #define THIS ((EnNeoReeba*)thisx) -void EnNeoReeba_Init(Actor* thisx, GlobalContext* globalCtx); -void EnNeoReeba_Destroy(Actor* thisx, GlobalContext* globalCtx); -void EnNeoReeba_Update(Actor* thisx, GlobalContext* globalCtx); -void EnNeoReeba_Draw(Actor* thisx, GlobalContext* globalCtx); +void EnNeoReeba_Init(Actor* thisx, PlayState* play); +void EnNeoReeba_Destroy(Actor* thisx, PlayState* play); +void EnNeoReeba_Update(Actor* thisx, PlayState* play); +void EnNeoReeba_Draw(Actor* thisx, PlayState* play); void EnNeoReeba_SetupWaitUnderground(EnNeoReeba* this); -void EnNeoReeba_WaitUnderground(EnNeoReeba* this, GlobalContext* globalCtx); -void EnNeoReeba_ChooseAction(EnNeoReeba* this, GlobalContext* globalCtx); +void EnNeoReeba_WaitUnderground(EnNeoReeba* this, PlayState* play); +void EnNeoReeba_ChooseAction(EnNeoReeba* this, PlayState* play); void EnNeoReeba_SetupSink(EnNeoReeba* this); -void EnNeoReeba_Sink(EnNeoReeba* this, GlobalContext* globalCtx); +void EnNeoReeba_Sink(EnNeoReeba* this, PlayState* play); void EnNeoReeba_SetupRise(EnNeoReeba* this); -void EnNeoReeba_RiseOutOfGround(EnNeoReeba* this, GlobalContext* globalCtx); +void EnNeoReeba_RiseOutOfGround(EnNeoReeba* this, PlayState* play); void EnNeoReeba_SetupMove(EnNeoReeba* this); -void EnNeoReeba_Move(EnNeoReeba* this, GlobalContext* globalCtx); +void EnNeoReeba_Move(EnNeoReeba* this, PlayState* play); 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_ReturnHome(EnNeoReeba* this, PlayState* play); +void EnNeoReeba_Bounce(EnNeoReeba* this, PlayState* play); +void EnNeoReeba_Stunned(EnNeoReeba* this, PlayState* play); +void EnNeoReeba_Frozen(EnNeoReeba* this, PlayState* play); void EnNeoReeba_SetupDamageAnim(EnNeoReeba* this); -void EnNeoReeba_DamageAnim(EnNeoReeba* this, GlobalContext* globalCtx); +void EnNeoReeba_DamageAnim(EnNeoReeba* this, PlayState* play); void EnNeoReeba_SetupDeathEffects(EnNeoReeba* this); -void EnNeoReeba_PlayDeathEffects(EnNeoReeba* this, GlobalContext* globalCtx); -void EnNeoReeba_SpawnIce(EnNeoReeba* this, GlobalContext* globalCtx); +void EnNeoReeba_PlayDeathEffects(EnNeoReeba* this, PlayState* play); +void EnNeoReeba_SpawnIce(EnNeoReeba* this, PlayState* play); const ActorInit En_Neo_Reeba_InitVars = { ACTOR_EN_NEO_REEBA, @@ -115,11 +115,11 @@ static ColliderCylinderInit sCylinderInit = { { 18, 30, 0, { 0, 0, 0 } }, }; -void EnNeoReeba_Init(Actor* thisx, GlobalContext* globalCtx) { +void EnNeoReeba_Init(Actor* thisx, PlayState* play) { EnNeoReeba* this = THIS; ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 0.0f); - SkelAnime_Init(globalCtx, &this->skelAnime, &gLeeverSkel, &gLeeverSpinAnim, this->jointTable, this->morphTable, + SkelAnime_Init(play, &this->skelAnime, &gLeeverSkel, &gLeeverSpinAnim, this->jointTable, this->morphTable, LEEVER_LIMB_MAX); if (!EN_NEO_REEBA_IS_LARGE(&this->actor)) { @@ -147,16 +147,16 @@ void EnNeoReeba_Init(Actor* thisx, GlobalContext* globalCtx) { this->sinkRiseRate = 0.0f; this->rotationSpeed = 0.0f; - Collider_InitCylinder(globalCtx, &this->collider); - Collider_SetCylinder(globalCtx, &this->collider, &this->actor, &sCylinderInit); + Collider_InitCylinder(play, &this->collider); + Collider_SetCylinder(play, &this->collider, &this->actor, &sCylinderInit); EnNeoReeba_SetupWaitUnderground(this); } -void EnNeoReeba_Destroy(Actor* thisx, GlobalContext* globalCtx) { +void EnNeoReeba_Destroy(Actor* thisx, PlayState* play) { EnNeoReeba* this = THIS; - Collider_DestroyCylinder(globalCtx, &this->collider); + Collider_DestroyCylinder(play, &this->collider); } void EnNeoReeba_SetupWaitUnderground(EnNeoReeba* this) { @@ -167,12 +167,12 @@ void EnNeoReeba_SetupWaitUnderground(EnNeoReeba* this) { this->actor.shape.yOffset = -2000.0f; } -void EnNeoReeba_WaitUnderground(EnNeoReeba* this, GlobalContext* globalCtx) { +void EnNeoReeba_WaitUnderground(EnNeoReeba* this, PlayState* play) { s32 pad; - Player* player = GET_PLAYER(globalCtx); + Player* player = GET_PLAYER(play); if ((Actor_XZDistanceToPoint(&player->actor, &this->actor.home.pos) < 200.0f) && - (Player_GetMask(globalCtx) != PLAYER_MASK_STONE) && (fabsf(this->actor.playerHeightRel) < 100.0f)) { + (Player_GetMask(play) != PLAYER_MASK_STONE) && (fabsf(this->actor.playerHeightRel) < 100.0f)) { EnNeoReeba_SetupRise(this); } @@ -197,8 +197,8 @@ void EnNeoReeba_SetupChooseAction(EnNeoReeba* this) { this->skelAnime.playSpeed = 1.0f; } -void EnNeoReeba_ChooseAction(EnNeoReeba* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); +void EnNeoReeba_ChooseAction(EnNeoReeba* this, PlayState* play) { + Player* player = GET_PLAYER(play); f32 distToPlayer = Actor_XZDistanceToPoint(&player->actor, &this->actor.home.pos); if ((distToPlayer > 200.0f) || (fabsf(this->actor.playerHeightRel) > 100.0f)) { @@ -228,12 +228,12 @@ void EnNeoReeba_SetupSink(EnNeoReeba* this) { this->actionFunc = EnNeoReeba_Sink; } -void EnNeoReeba_Sink(EnNeoReeba* this, GlobalContext* globalCtx) { +void EnNeoReeba_Sink(EnNeoReeba* this, PlayState* play) { 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); + } else if (play->gameplayFrames % 4 == 0) { + Actor_SpawnFloorDustRing(play, &this->actor, &this->actor.world.pos, this->actor.shape.shadowScale, 1, 8.0f, + 500, 10, 1); } if (this->sinkRiseRate < 300.0f) { @@ -252,12 +252,12 @@ void EnNeoReeba_SetupRise(EnNeoReeba* this) { this->actionFunc = EnNeoReeba_RiseOutOfGround; } -void EnNeoReeba_RiseOutOfGround(EnNeoReeba* this, GlobalContext* globalCtx) { +void EnNeoReeba_RiseOutOfGround(EnNeoReeba* this, PlayState* play) { 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); + } else if (play->gameplayFrames % 4 == 0) { + Actor_SpawnFloorDustRing(play, &this->actor, &this->actor.world.pos, this->actor.shape.shadowScale, 1, 8.0f, + 500, 10, 1); } if (this->sinkRiseRate > 20.0f) { @@ -276,11 +276,11 @@ void EnNeoReeba_SetupMove(EnNeoReeba* this) { this->actor.speedXZ = 14.0f; } -void EnNeoReeba_Move(EnNeoReeba* this, GlobalContext* globalCtx) { +void EnNeoReeba_Move(EnNeoReeba* this, PlayState* play) { f32 remainingDist = Math_Vec3f_StepToXZ(&this->actor.world.pos, &this->targetPos, this->actor.speedXZ); - Actor_SpawnFloorDustRing(globalCtx, &this->actor, &this->actor.world.pos, this->actor.shape.shadowScale, 1, 4.0f, - 0xFA, 0xA, 1); + Actor_SpawnFloorDustRing(play, &this->actor, &this->actor.world.pos, this->actor.shape.shadowScale, 1, 4.0f, 0xFA, + 0xA, 1); if (remainingDist < 2.0f) { EnNeoReeba_SetupChooseAction(this); @@ -307,8 +307,8 @@ void EnNeoReeba_SetupReturnHome(EnNeoReeba* this) { this->actor.speedXZ = 6.0f; } -void EnNeoReeba_ReturnHome(EnNeoReeba* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); +void EnNeoReeba_ReturnHome(EnNeoReeba* this, PlayState* play) { + Player* player = GET_PLAYER(play); s32 pad; f32 remainingDist = Math_Vec3f_StepToXZ(&this->actor.world.pos, &this->actor.home.pos, this->actor.speedXZ); @@ -332,7 +332,7 @@ void EnNeoReeba_SetupBounce(EnNeoReeba* this) { this->actionFunc = EnNeoReeba_Bounce; } -void EnNeoReeba_Bounce(EnNeoReeba* this, GlobalContext* globalCtx) { +void EnNeoReeba_Bounce(EnNeoReeba* this, PlayState* play) { if (Math_Vec3f_StepToXZ(&this->actor.world.pos, &this->targetPos, this->actor.speedXZ) < 2.0f) { EnNeoReeba_SetupChooseAction(this); } @@ -349,7 +349,7 @@ void EnNeoReeba_SetupStun(EnNeoReeba* this) { this->actionFunc = EnNeoReeba_Stunned; } -void EnNeoReeba_Stunned(EnNeoReeba* this, GlobalContext* globalCtx) { +void EnNeoReeba_Stunned(EnNeoReeba* this, PlayState* play) { if (this->stunTimer > 0) { this->stunTimer--; } else { @@ -382,7 +382,7 @@ void EnNeoReeba_SetupFrozen(EnNeoReeba* this) { this->actionFunc = EnNeoReeba_Frozen; } -void EnNeoReeba_Frozen(EnNeoReeba* this, GlobalContext* globalCtx) { +void EnNeoReeba_Frozen(EnNeoReeba* this, PlayState* play) { if (this->stunTimer == 0) { this->stunTimer = 0; this->drawEffectScale = 0.0f; @@ -395,7 +395,7 @@ void EnNeoReeba_Frozen(EnNeoReeba* this, GlobalContext* globalCtx) { } } else if (this->stunTimer == 1) { this->stunTimer--; - EnNeoReeba_SpawnIce(this, globalCtx); + EnNeoReeba_SpawnIce(this, play); } else { this->stunTimer--; } @@ -415,7 +415,7 @@ void EnNeoReeba_SetupDamageAnim(EnNeoReeba* this) { 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) { +void EnNeoReeba_DamageAnim(EnNeoReeba* this, PlayState* play) { if (this->actionTimer == 0) { this->rotationSpeed = 0.0f; EnNeoReeba_SetupChooseAction(this); @@ -431,8 +431,8 @@ void EnNeoReeba_DamageAnim(EnNeoReeba* this, GlobalContext* globalCtx) { 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); + Actor_SpawnFloorDustRing(play, &this->actor, &this->actor.world.pos, this->actor.shape.shadowScale, 1, 4.0f, + 250, 10, 1); this->actionTimer--; } } @@ -452,7 +452,7 @@ void EnNeoReeba_SetupDeathEffects(EnNeoReeba* this) { this->actionFunc = EnNeoReeba_PlayDeathEffects; } -void EnNeoReeba_PlayDeathEffects(EnNeoReeba* this, GlobalContext* globalCtx) { +void EnNeoReeba_PlayDeathEffects(EnNeoReeba* this, PlayState* play) { static Vec3f sDeadDbVel = { 0.0f, 0.0f, 0.0f }; static Vec3f sDeadDbAccel = { 0.0f, 4.0f, 0.0f }; @@ -464,8 +464,8 @@ void EnNeoReeba_PlayDeathEffects(EnNeoReeba* this, GlobalContext* globalCtx) { 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); + func_800B3030(play, &this->actor.world.pos, &sDeadDbAccel, &sDeadDbVel, 120, 0, 0); + Item_DropCollectibleRandom(play, &this->actor, &this->actor.world.pos, 0x60); Actor_MarkForDeath(&this->actor); } } else { @@ -502,7 +502,7 @@ void EnNeoReeba_PlayDeathEffects(EnNeoReeba* this, GlobalContext* globalCtx) { } } -void EnNeoReeba_HandleHit(EnNeoReeba* this, GlobalContext* globalCtx) { +void EnNeoReeba_HandleHit(EnNeoReeba* this, PlayState* play) { Actor_SetFocus(&this->actor, 20.0f); if (this->collider.base.acFlags & AC_HIT) { @@ -518,7 +518,7 @@ void EnNeoReeba_HandleHit(EnNeoReeba* this, GlobalContext* globalCtx) { return; default: if (this->stunTimer >= 2) { - EnNeoReeba_SpawnIce(this, globalCtx); + EnNeoReeba_SpawnIce(this, play); } this->stunTimer = 0; } @@ -552,7 +552,7 @@ void EnNeoReeba_HandleHit(EnNeoReeba* this, GlobalContext* globalCtx) { if (this->actor.colChkInfo.health > 0) { EnNeoReeba_SetupDamageAnim(this); } else { - Enemy_StartFinishingBlow(globalCtx, &this->actor); + Enemy_StartFinishingBlow(play, &this->actor); EnNeoReeba_SetupDeathEffects(this); } break; @@ -581,16 +581,16 @@ void EnNeoReeba_HandleHit(EnNeoReeba* this, GlobalContext* globalCtx) { (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); + CollisionCheck_SetOC(play, &play->colChkCtx, &this->collider.base); + CollisionCheck_SetAC(play, &play->colChkCtx, &this->collider.base); if (this->actionFunc != EnNeoReeba_Stunned) { - CollisionCheck_SetAT(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + CollisionCheck_SetAT(play, &play->colChkCtx, &this->collider.base); } } } -void EnNeoReeba_UpdatePosition(EnNeoReeba* this, GlobalContext* globalCtx) { +void EnNeoReeba_UpdatePosition(EnNeoReeba* this, PlayState* play) { if ((this->actionFunc != EnNeoReeba_WaitUnderground) && (this->actionFunc != EnNeoReeba_Sink) && (this->actionFunc != EnNeoReeba_RiseOutOfGround)) { this->actor.velocity.y += this->actor.gravity; @@ -604,11 +604,11 @@ void EnNeoReeba_UpdatePosition(EnNeoReeba* this, GlobalContext* globalCtx) { 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); + Actor_UpdateBgCheckInfo(play, &this->actor, 10.0f, 40.0f, 40.0f, 5); } } -void EnNeoReeba_DrawFrozenEffects(EnNeoReeba* this, GlobalContext* globalCtx) { +void EnNeoReeba_DrawFrozenEffects(EnNeoReeba* this, PlayState* play) { s32 i; f32 limbPosScale = 10.0f; f32 phi_f2 = 20.0f; @@ -632,11 +632,11 @@ void EnNeoReeba_DrawFrozenEffects(EnNeoReeba* this, GlobalContext* globalCtx) { 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, + Actor_DrawDamageEffects(play, &this->actor, this->limbPos, ARRAY_COUNT(this->limbPos), drawEffectScale, 0.5f, this->drawEffectAlpha, this->drawEffectType); } -void EnNeoReeba_DrawEffects(EnNeoReeba* this, GlobalContext* globalCtx) { +void EnNeoReeba_DrawEffects(EnNeoReeba* this, PlayState* play) { s32 i; f32 scale = 15.0f; @@ -654,12 +654,12 @@ void EnNeoReeba_DrawEffects(EnNeoReeba* this, GlobalContext* globalCtx) { } 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, + Actor_DrawDamageEffects(play, NULL, this->limbPos, ARRAY_COUNT(this->limbPos), this->drawEffectScale, 0.5f, this->drawEffectAlpha, this->drawEffectType); } } -void EnNeoReeba_SpawnIce(EnNeoReeba* this, GlobalContext* globalCtx) { +void EnNeoReeba_SpawnIce(EnNeoReeba* this, PlayState* play) { 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 }; @@ -670,7 +670,7 @@ void EnNeoReeba_SpawnIce(EnNeoReeba* this, GlobalContext* globalCtx) { s16 yaw; s32 j; - SoundSource_PlaySfxAtFixedWorldPos(globalCtx, &this->actor.world.pos, 30, NA_SE_EV_ICE_BROKEN); + SoundSource_PlaySfxAtFixedWorldPos(play, &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]); @@ -681,22 +681,21 @@ void EnNeoReeba_SpawnIce(EnNeoReeba* this, GlobalContext* globalCtx) { 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); + EffectSsEnIce_Spawn(play, &this->limbPos[i], 0.7f, &iceVel, &sIceAccel, &sIcePrimColor, &sIceEnvColor, 30); } } } -void EnNeoReeba_SinkIfStoneMask(EnNeoReeba* this, GlobalContext* globalCtx) { +void EnNeoReeba_SinkIfStoneMask(EnNeoReeba* this, PlayState* play) { if ((this->actionFunc == EnNeoReeba_ChooseAction) || (this->actionFunc == EnNeoReeba_Move) || (this->actionFunc == EnNeoReeba_ReturnHome)) { - if (Player_GetMask(globalCtx) == PLAYER_MASK_STONE) { + if (Player_GetMask(play) == PLAYER_MASK_STONE) { EnNeoReeba_SetupSink(this); } } } -void EnNeoReeba_Update(Actor* thisx, GlobalContext* globalCtx) { +void EnNeoReeba_Update(Actor* thisx, PlayState* play) { EnNeoReeba* this = THIS; if (EN_NEO_REEBA_IS_LARGE(&this->actor)) { @@ -704,20 +703,19 @@ void EnNeoReeba_Update(Actor* thisx, GlobalContext* globalCtx) { this->collider.dim.height = 45; } - this->actionFunc(this, globalCtx); + this->actionFunc(this, play); 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); + EnNeoReeba_HandleHit(this, play); + EnNeoReeba_UpdatePosition(this, play); + EnNeoReeba_SinkIfStoneMask(this, play); } -s32 EnNeoReeba_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, - Actor* thisx) { +s32 EnNeoReeba_OverrideLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, Actor* thisx) { EnNeoReeba* this = THIS; if ((limbIndex == OBJECT_RB_LIMB_03) && (this->rotationSpeed != 0.0f)) { @@ -728,21 +726,21 @@ s32 EnNeoReeba_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** d return false; } -void EnNeoReeba_Draw(Actor* thisx, GlobalContext* globalCtx) { +void EnNeoReeba_Draw(Actor* thisx, PlayState* play) { EnNeoReeba* this = THIS; - func_8012C28C(globalCtx->state.gfxCtx); - OPEN_DISPS(globalCtx->state.gfxCtx); + func_8012C28C(play->state.gfxCtx); + OPEN_DISPS(play->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); + SkelAnime_DrawOpa(play, this->skelAnime.skeleton, this->skelAnime.jointTable, EnNeoReeba_OverrideLimbDraw, NULL, + &this->actor); + CLOSE_DISPS(play->state.gfxCtx); if (this->stunTimer > 0) { if (this->drawEffectType == ACTOR_DRAW_DMGEFF_FROZEN_SFX) { - EnNeoReeba_DrawFrozenEffects(this, globalCtx); + EnNeoReeba_DrawFrozenEffects(this, play); } else { - EnNeoReeba_DrawEffects(this, globalCtx); + EnNeoReeba_DrawEffects(this, play); } } } 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 df6aaab1d..a739d96db 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 @@ -8,7 +8,7 @@ struct EnNeoReeba; -typedef void (*EnNeoReebaActionFunc)(struct EnNeoReeba*, GlobalContext*); +typedef void (*EnNeoReebaActionFunc)(struct EnNeoReeba*, PlayState*); typedef struct EnNeoReeba { /* 0x000 */ Actor actor; 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 779de0b8a..966f3671b 100644 --- a/src/overlays/actors/ovl_En_Nimotsu/z_en_nimotsu.c +++ b/src/overlays/actors/ovl_En_Nimotsu/z_en_nimotsu.c @@ -10,10 +10,10 @@ #define THIS ((EnNimotsu*)thisx) -void EnNimotsu_Init(Actor* thisx, GlobalContext* globalCtx); -void EnNimotsu_Destroy(Actor* thisx, GlobalContext* globalCtx); -void EnNimotsu_Update(Actor* thisx, GlobalContext* globalCtx); -void EnNimotsu_Draw(Actor* thisx, GlobalContext* globalCtx); +void EnNimotsu_Init(Actor* thisx, PlayState* play); +void EnNimotsu_Destroy(Actor* thisx, PlayState* play); +void EnNimotsu_Update(Actor* thisx, PlayState* play); +void EnNimotsu_Draw(Actor* thisx, PlayState* play); #if 0 const ActorInit En_Nimotsu_InitVars = { diff --git a/src/overlays/actors/ovl_En_Niw/z_en_niw.c b/src/overlays/actors/ovl_En_Niw/z_en_niw.c index f6e398a33..112871c90 100644 --- a/src/overlays/actors/ovl_En_Niw/z_en_niw.c +++ b/src/overlays/actors/ovl_En_Niw/z_en_niw.c @@ -5,37 +5,48 @@ */ #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 (ACTOR_FLAG_10 | ACTOR_FLAG_800000) #define THIS ((EnNiw*)thisx) -void EnNiw_Init(Actor* thisx, GlobalContext* globalCtx); -void EnNiw_Destroy(Actor* thisx, GlobalContext* globalCtx); -void EnNiw_Update(Actor* thisx, GlobalContext* globalCtx); -void EnNiw_Draw(Actor* thisx, GlobalContext* globalCtx); +void EnNiw_Init(Actor* thisx, PlayState* play); +void EnNiw_Destroy(Actor* thisx, PlayState* play); +void EnNiw_Update(Actor* thisx, PlayState* play); +void EnNiw_Draw(Actor* thisx, PlayState* play); void EnNiw_SetupIdle(EnNiw* this); -void EnNiw_Idle(EnNiw* this, GlobalContext* globalCtx); -void EnNiw_Thrown(EnNiw* this, GlobalContext* globalCtx); +void EnNiw_Idle(EnNiw* this, PlayState* play); +void EnNiw_Thrown(EnNiw* this, PlayState* play); void EnNiw_SetupRunAway(EnNiw* this); -void EnNiw_RunAway(EnNiw* this, GlobalContext* globalCtx); -void EnNiw_Swimming(EnNiw* this, GlobalContext* globalCtx); -void EnNiw_Trigger(EnNiw* this, GlobalContext* globalCtx); -void EnNiw_Upset(EnNiw* this, GlobalContext* globalCtx); -void EnNiw_SetupCuccoStorm(EnNiw* this, GlobalContext* globalCtx); -void EnNiw_CuccoStorm(EnNiw* this, GlobalContext* globalCtx); -void EnNiw_SpawnAttackNiw(EnNiw* this, GlobalContext* globalCtx); -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_RunAway(EnNiw* this, PlayState* play); +void EnNiw_Swimming(EnNiw* this, PlayState* play); +void EnNiw_Trigger(EnNiw* this, PlayState* play); +void EnNiw_Upset(EnNiw* this, PlayState* play); +void EnNiw_SetupCuccoStorm(EnNiw* this, PlayState* play); +void EnNiw_CuccoStorm(EnNiw* this, PlayState* play); +void EnNiw_SpawnAttackNiw(EnNiw* this, PlayState* play); +void EnNiw_Held(EnNiw* this, PlayState* play); +void EnNiw_UpdateFeather(EnNiw* this, PlayState* play); +void EnNiw_DrawFeathers(EnNiw* this, PlayState* play); +void EnNiw_CheckRage(EnNiw* this, PlayState* play); +void EnNiw_AnimateWingHead(EnNiw* this, PlayState* play, 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 = { { @@ -105,12 +112,12 @@ static Vec3f D_808934E8 = { static s32 pad = 0; -void EnNiw_Init(Actor* thisx, GlobalContext* globalCtx) { +void EnNiw_Init(Actor* thisx, PlayState* play) { 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); @@ -122,32 +129,36 @@ void EnNiw_Init(Actor* thisx, GlobalContext* globalCtx) { 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(play, &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) { - Collider_InitAndSetCylinder(globalCtx, &this->collider, &this->actor, &sCylinderInit); + if (this->niwType == NIW_TYPE_REGULAR) { + Collider_InitAndSetCylinder(play, &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->heldTimer = 30; this->actor.flags &= ~ACTOR_FLAG_1; // targetable OFF - this->unknownState28E = 4; + this->niwState = NIW_STATE_HELD; this->actionFunc = EnNiw_Held; this->actor.speedXZ = 0.0f; this->unk2BC.z = 0.0f; @@ -158,216 +169,233 @@ void EnNiw_Init(Actor* thisx, GlobalContext* globalCtx) { } } -void EnNiw_Destroy(Actor* thisx, GlobalContext* globalCtx) { +void EnNiw_Destroy(Actor* thisx, PlayState* play) { EnNiw* this = THIS; - if (this->niwType == ENNIW_TYPE_REGULAR) { - Collider_DestroyCylinder(globalCtx, &this->collider); + if (this->niwType == NIW_TYPE_REGULAR) { + Collider_DestroyCylinder(play, &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, PlayState* play, 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_ANIM_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_ANIM_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_ANIM_STILL: + this->targetLimbRots[2] = 0.0f; // both wingRotZ + this->targetLimbRots[1] = 0.0f; break; - case 1: + case NIW_ANIM_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_ANIM_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_ANIM_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_ANIM_FREEZE: this->unkTimer24C = 5; break; - case 5: + + case NIW_ANIM_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); } } -void EnNiw_SpawnAttackNiw(EnNiw* this, GlobalContext* globalCtx) { +void EnNiw_SpawnAttackNiw(EnNiw* this, PlayState* play) { f32 xView; f32 yView; f32 zView; Vec3f newNiwPos; Actor* attackNiw; - if ((this->unkTimer252 == 0) && (this->unk290 < 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; - newNiwPos.x = ((Rand_ZeroOne() - 0.5f) * xView) + globalCtx->view.eye.x; - 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); + if (this->attackNiwSpawnTimer == 0 && this->attackNiwCount < 7) { + xView = play->view.at.x - play->view.eye.x; + yView = play->view.at.y - play->view.eye.y; + zView = play->view.at.z - play->view.eye.z; + newNiwPos.x = ((Rand_ZeroOne() - 0.5f) * xView) + play->view.eye.x; + newNiwPos.y = randPlusMinusPoint5Scaled(0.3f) + (play->view.eye.y + 50.0f + (yView * 0.5f)); + newNiwPos.z = ((Rand_ZeroOne() - 0.5f) * zView) + play->view.eye.z; + attackNiw = Actor_SpawnAsChild(&play->actorCtx, &this->actor, play, ACTOR_EN_ATTACK_NIW, newNiwPos.x, + 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, PlayState* play, 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, play, NIW_ANIM_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), ANIMMODE_LOOP, + -10.0f); + this->niwState = NIW_STATE_IDLE; this->actionFunc = EnNiw_Idle; } -void EnNiw_Idle(EnNiw* this, GlobalContext* globalCtx) { +void EnNiw_Idle(EnNiw* this, PlayState* play) { f32 posX2; f32 posZ2; f32 posX1 = randPlusMinusPoint5Scaled(100.0f); f32 posZ1 = randPlusMinusPoint5Scaled(100.0f); - s16 s16tmp; + s16 nextAnimIndex; - 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, play)) { // picked up Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_CHICKEN_CRY_M); // crow this->sfxTimer1 = 30; - this->unkTimer250 = 30; + this->heldTimer = 30; this->actor.flags &= ~ACTOR_FLAG_1; // targetable OFF - this->unknownState28E = 4; + this->niwState = NIW_STATE_HELD; this->actor.speedXZ = 0.0f; this->actionFunc = EnNiw_Held; return; } else { - Actor_LiftActor(&this->actor, globalCtx); + Actor_LiftActor(&this->actor, play); } - } else { - this->unkTimer252 = 10; + } else { // NIW_TYPE_UNK1 || NIW_TYPE_HELD + this->unkIdleTimer2 = 10; } - s16tmp = 0; - if (this->unkTimer252 != 0) { + nextAnimIndex = NIW_ANIM_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 +413,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 + nextAnimIndex = NIW_ANIM_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,33 +439,34 @@ 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, play, nextAnimIndex); } -void EnNiw_Held(EnNiw* this, GlobalContext* globalCtx) { +void EnNiw_Held(EnNiw* this, PlayState* play) { 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 (Actor_HasNoParent(&this->actor, globalCtx)) { + if (this->niwType == NIW_TYPE_REGULAR) { + if (Actor_HasNoParent(&this->actor, play)) { this->actor.shape.rot.z = 0; rotZ = this->actor.shape.rot.z; - this->unknownState28E = 5; + this->niwState = NIW_STATE_FALLING; this->actor.flags |= ACTOR_FLAG_1; // targetable ON this->actionFunc = EnNiw_Thrown; this->actor.shape.rot.y = rotZ; @@ -449,214 +478,215 @@ 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); + Collider_InitAndSetCylinder(play, &this->collider, &this->actor, &sCylinderInit); Math_Vec3f_Copy(&this->unk2BC, &vec3fcopy); this->actor.flags |= ACTOR_FLAG_1; // targetable ON this->actionFunc = EnNiw_Thrown; } - func_80891320(this, globalCtx, 2); + + EnNiw_AnimateWingHead(this, play, NIW_ANIM_PECKING_AND_WAVING); } -// action function: recently thrown, and also hopping on the floor -void EnNiw_Thrown(EnNiw* this, GlobalContext* globalCtx) { +void EnNiw_Thrown(EnNiw* this, PlayState* play) { 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; } } - if (Actor_HasParent(&this->actor, globalCtx)) { + if (Actor_HasParent(&this->actor, play)) { // picked up again before could run off Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_CHICKEN_CRY_M); // crow this->sfxTimer1 = 30; this->unk2EC = 0; - this->unkTimer250 = 30; + this->heldTimer = 30; this->actor.flags &= ~ACTOR_FLAG_1; // targetable OFF - this->unknownState28E = 4; + this->niwState = NIW_STATE_HELD; this->actionFunc = EnNiw_Held; this->actor.speedXZ = 0.0f; } else { - if (this->unkTimer252 > 5) { - Actor_LiftActor(&this->actor, globalCtx); + if (this->hoppingTimer > 5) { + Actor_LiftActor(&this->actor, play); } - func_80891320(this, globalCtx, 2); + EnNiw_AnimateWingHead(this, play, NIW_ANIM_PECKING_AND_WAVING); } } -// action func: swimming and flying away after swimming -void EnNiw_Swimming(EnNiw* this, GlobalContext* globalCtx) { +void EnNiw_Swimming(EnNiw* this, PlayState* play) { Vec3f ripplePos; // even if hitting water, keep calling for reinforcements // this should just be in update if (this->isStormActive) { - EnNiw_SpawnAttackNiw(this, globalCtx); // spawn attack niw + EnNiw_SpawnAttackNiw(this, play); // spawn attack niw } 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); + EffectSsGRipple_Spawn(play, &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, play, NIW_ANIM_PECKING_AND_WAVING); } -void EnNiw_Trigger(EnNiw* this, GlobalContext* globalCtx) { - s32 value; +void EnNiw_Trigger(EnNiw* this, PlayState* play) { + 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->nextAnimIndex = state; // NIW_ANIM_HEAD_PECKING this->actionFunc = EnNiw_Upset; } -void EnNiw_Upset(EnNiw* this, GlobalContext* globalCtx) { +void EnNiw_Upset(EnNiw* this, PlayState* play) { // 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->nextAnimIndex = NIW_ANIM_FREEZE; + this->niwState = NIW_STATE_ANGRY2; this->actionFunc = EnNiw_SetupCuccoStorm; } - func_80891320(this, globalCtx, this->unk29C); + EnNiw_AnimateWingHead(this, play, this->nextAnimIndex); } // the long crow with head back before they descend -void EnNiw_SetupCuccoStorm(EnNiw* this, GlobalContext* globalCtx) { +void EnNiw_SetupCuccoStorm(EnNiw* this, PlayState* play) { 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 &= ~ACTOR_FLAG_1; // targetable OFF - this->unknownState28E = 3; + this->niwState = NIW_STATE_ANGRY3; this->actionFunc = EnNiw_CuccoStorm; } - func_80891320(this, globalCtx, this->unk29C); + + EnNiw_AnimateWingHead(this, play, this->nextAnimIndex); } -void EnNiw_CuccoStorm(EnNiw* this, GlobalContext* globalCtx) { - EnNiw_SpawnAttackNiw(this, globalCtx); - if (this->unkTimer252 == 1) { +void EnNiw_CuccoStorm(EnNiw* this, PlayState* play) { + EnNiw_SpawnAttackNiw(this, play); + if (this->cuccoStormTimer == 1) { // not countdown to 0? mistype? this->actor.speedXZ = 3.0f; - this->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, play, 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), ANIMMODE_LOOP, + -10.0f); + this->isRunningRight = Rand_ZeroFloat(1.99f); + this->niwState = NIW_STATE_RUNNING; this->actionFunc = EnNiw_RunAway; this->actor.speedXZ = 4.0f; } -void EnNiw_RunAway(EnNiw* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); +void EnNiw_RunAway(EnNiw* this, PlayState* play) { + Player* player = GET_PLAYER(play); Vec3f tempVec3f = D_808934E8; s16 temp298; 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 +696,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, play, false); + EnNiw_AnimateWingHead(this, play, NIW_ANIM_PECKING_AND_WAVING); } } -void EnNiw_LandBeforeIdle(EnNiw* this, GlobalContext* globalCtx) { - if (this->actor.bgCheckFlags & 1) { +void EnNiw_LandBeforeIdle(EnNiw* this, PlayState* play) { + 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; +void EnNiw_CheckRage(EnNiw* this, PlayState* play) { + 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 +728,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); } @@ -729,18 +761,17 @@ void EnNiw_CheckRage(EnNiw* this, GlobalContext* globalCtx) { } } -void EnNiw_Update(Actor* thisx, GlobalContext* globalCtx) { +void EnNiw_Update(Actor* thisx, PlayState* play) { EnNiw* this = THIS; s8 pad0; s16 i; - Player* player = GET_PLAYER(globalCtx); + Player* player = GET_PLAYER(play); 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 viewAtToEyeNormY; f32 floorHeight; @@ -749,16 +780,16 @@ void EnNiw_Update(Actor* thisx, GlobalContext* globalCtx) { 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,59 +799,59 @@ 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; } - EnNiw_UpdateFeather(this, globalCtx); + EnNiw_UpdateFeather(this, play); 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; - this->actionFunc(this, globalCtx); + this->actionFunc(this, play); Actor_SetFocus(&this->actor, this->unk308); Actor_MoveWithGravity(&this->actor); - Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 20.0f, 20.0f, 60.0f, 0x1F); + Actor_UpdateBgCheckInfo(play, &this->actor, 20.0f, 20.0f, 60.0f, 0x1F); - // if cucco is off the map? + // if cucco is off the map if (this->actor.floorHeight <= BGCHECK_Y_MIN || this->actor.floorHeight >= BGCHECK_Y_MAX) { 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; + viewAtToEye.x = play->view.at.x - play->view.eye.x; + viewAtToEye.y = play->view.at.y - play->view.eye.y; + viewAtToEye.z = play->view.at.z - play->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) + (viewAtToEyeNormY * 160.0f); + this->actor.world.pos.y = this->actor.home.pos.y + play->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; @@ -833,113 +864,112 @@ 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->nextAnimIndex = 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; - EffectSsGSplash_Spawn(globalCtx, &pos, 0, 0, 0, 400); - this->unkTimer252 = 0; - this->unknownState28E = 6; + this->swimRippleTimer = 30; + EffectSsGSplash_Spawn(play, &pos, 0, 0, 0, 400); + 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(play, &this->actor, 2.0f, this->actor.world.rot.y, 0.0f, 0x10); + } + + EnNiw_CheckRage(this, play); + if (this->flutterSfxTimer == 0 && this->niwState == NIW_STATE_HELD) { + this->flutterSfxTimer = 7; + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_CHICKEN_FLUTTER); + } + + 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(play, &play->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 (play) {} - 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(play, &play->colChkCtx, &this->collider.base); } } } -s32 EnNiw_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, Actor* thisx) { +s32 EnNiw_OverrideLimbDraw(PlayState* play, 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; } -void EnNiw_Draw(Actor* thisx, GlobalContext* globalCtx) { +void EnNiw_Draw(Actor* thisx, PlayState* play) { EnNiw* this = THIS; - func_8012C28C(globalCtx->state.gfxCtx); - SkelAnime_DrawFlexOpa(globalCtx, this->skelanime.skeleton, this->skelanime.jointTable, this->skelanime.dListCount, + func_8012C28C(play->state.gfxCtx); + SkelAnime_DrawFlexOpa(play, this->skelanime.skeleton, this->skelanime.jointTable, this->skelanime.dListCount, EnNiw_OverrideLimbDraw, NULL, &this->actor); - EnNiw_DrawFeathers(this, globalCtx); + EnNiw_DrawFeathers(this, play); } 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) { @@ -956,8 +986,8 @@ void EnNiw_SpawnFeather(EnNiw* this, Vec3f* pos, Vec3f* vel, Vec3f* accel, f32 s } } -void EnNiw_UpdateFeather(EnNiw* this, GlobalContext* globalCtx) { - EnNiwFeather* feather = this->feathers; +void EnNiw_UpdateFeather(EnNiw* this, PlayState* play) { + EnNiwFeather* feather = &this->feathers[0]; f32 featherVelocityGoal = 0.05f; s16 i; @@ -988,15 +1018,14 @@ void EnNiw_UpdateFeather(EnNiw* this, GlobalContext* globalCtx) { } } -// feather draw function -void EnNiw_DrawFeathers(EnNiw* this, GlobalContext* globalCtx) { - GraphicsContext* gfxCtx = globalCtx->state.gfxCtx; +void EnNiw_DrawFeathers(EnNiw* this, PlayState* play) { + GraphicsContext* gfxCtx = play->state.gfxCtx; u8 isMaterialApplied = false; EnNiwFeather* feather = &this->feathers[0]; s16 i; OPEN_DISPS(gfxCtx); - func_8012C2DC(globalCtx->state.gfxCtx); + func_8012C2DC(play->state.gfxCtx); for (i = 0; i < ARRAY_COUNT(this->feathers); i++, feather++) { if (feather->isEnabled == true) { @@ -1006,11 +1035,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(&play->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..c1cec3b88 100644 --- a/src/overlays/actors/ovl_En_Niw/z_en_niw.h +++ b/src/overlays/actors/ovl_En_Niw/z_en_niw.h @@ -2,72 +2,85 @@ #define Z_EN_NIW_H #include "global.h" +#include "objects/object_niw/object_niw.h" struct EnNiw; -typedef void (*EnNiwActionFunc)(struct EnNiw*, GlobalContext*); +typedef void (*EnNiwActionFunc)(struct EnNiw*, PlayState*); typedef struct { - /* 0x0000 */ u8 isEnabled; - /* 0x0004 */ Vec3f pos; - /* 0x0010 */ Vec3f vel; - /* 0x001C */ Vec3f accel; - /* 0x0028 */ s16 life; - /* 0x002A */ s16 zRotStart; - /* 0x002C */ f32 scale; - /* 0x0030 */ f32 zRot; - /* 0x0034 */ u8 timer; + /* 0x00 */ u8 isEnabled; + /* 0x04 */ Vec3f pos; + /* 0x10 */ Vec3f vel; + /* 0x1C */ Vec3f accel; + /* 0x28 */ s16 life; + /* 0x2A */ s16 zRotStart; + /* 0x2C */ f32 scale; + /* 0x30 */ f32 zRot; + /* 0x34 */ u8 timer; } EnNiwFeather; // size = 0x38 -#define 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 nextAnimIndex; + /* 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,25 @@ 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_ANIM_STILL, + /* 1 */ NIW_ANIM_HEAD_PECKING, // forward and backward, feeding + /* 2 */ NIW_ANIM_PECKING_AND_WAVING, // wings move along their axis, like human hand waving + /* 3 */ NIW_ANIM_PECKING_AND_FORFLAPPING, // (unused) low (yaw based) flapping, forward and back + /* 4 */ NIW_ANIM_FREEZE, // used during Cucco Storm + /* 5 */ NIW_ANIM_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 1400e3c06..5597bf9f6 100644 --- a/src/overlays/actors/ovl_En_Nnh/z_en_nnh.c +++ b/src/overlays/actors/ovl_En_Nnh/z_en_nnh.c @@ -11,15 +11,15 @@ #define THIS ((EnNnh*)thisx) -void EnNnh_Init(Actor* thisx, GlobalContext* globalCtx); -void EnNnh_Destroy(Actor* thisx, GlobalContext* globalCtx); -void EnNnh_Update(Actor* thisx, GlobalContext* globalCtx); -void EnNnh_Draw(Actor* thisx, GlobalContext* globalCtx); +void EnNnh_Init(Actor* thisx, PlayState* play); +void EnNnh_Destroy(Actor* thisx, PlayState* play); +void EnNnh_Update(Actor* thisx, PlayState* play); +void EnNnh_Draw(Actor* thisx, PlayState* play); -void func_80C08828(EnNnh* this); -void func_80C0883C(EnNnh* this, GlobalContext* globalCtx); -void func_80C088A4(EnNnh* this); -void func_80C088B8(EnNnh* this, GlobalContext* globalCtx); +void EnNnh_SetupWaitForDialogue(EnNnh* this); +void EnNnh_WaitForDialogue(EnNnh* this, PlayState* play); +void EnNnh_SetupDialogue(EnNnh* this); +void EnNnh_Dialogue(EnNnh* this, PlayState* play); const ActorInit En_Nnh_InitVars = { ACTOR_EN_NNH, @@ -53,61 +53,61 @@ static ColliderCylinderInit sCylinderInit = { { 20, 50, 0, { 0, 0, 0 } }, }; -void EnNnh_Init(Actor* thisx, GlobalContext* globalCtx) { +void EnNnh_Init(Actor* thisx, PlayState* play) { EnNnh* this = THIS; Actor_SetScale(&this->actor, 0.01f); - Collider_InitCylinder(globalCtx, &this->collider); - Collider_SetCylinder(globalCtx, &this->collider, &this->actor, &sCylinderInit); + Collider_InitCylinder(play, &this->collider); + Collider_SetCylinder(play, &this->collider, &this->actor, &sCylinderInit); this->actor.targetMode = 1; this->actor.focus.pos = this->actor.world.pos; this->actor.focus.pos.y += 30.0f; - func_80C08828(this); + EnNnh_SetupWaitForDialogue(this); } -void EnNnh_Destroy(Actor* thisx, GlobalContext* globalCtx) { +void EnNnh_Destroy(Actor* thisx, PlayState* play) { EnNnh* this = THIS; - Collider_DestroyCylinder(globalCtx, &this->collider); + Collider_DestroyCylinder(play, &this->collider); } -void func_80C08828(EnNnh* this) { - this->actionFunc = func_80C0883C; +void EnNnh_SetupWaitForDialogue(EnNnh* this) { + this->actionFunc = EnNnh_WaitForDialogue; } -void func_80C0883C(EnNnh* this, GlobalContext* globalCtx) { - if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { - Message_StartTextbox(globalCtx, 0x228U, &this->actor); - func_80C088A4(this); - return; - } - func_800B8614(&this->actor, globalCtx, 100.0f); -} - -void func_80C088A4(EnNnh* this) { - this->actionFunc = func_80C088B8; -} - -void func_80C088B8(EnNnh* this, GlobalContext* globalCtx) { - if (Actor_TextboxIsClosing(&this->actor, globalCtx)) { - func_80C08828(this); +void EnNnh_WaitForDialogue(EnNnh* this, PlayState* play) { + if (Actor_ProcessTalkRequest(&this->actor, &play->state)) { + Message_StartTextbox(play, 0x228, &this->actor); + EnNnh_SetupDialogue(this); + } else { + func_800B8614(&this->actor, play, 100.0f); } } -void EnNnh_Update(Actor* thisx, GlobalContext* globalCtx) { +void EnNnh_SetupDialogue(EnNnh* this) { + this->actionFunc = EnNnh_Dialogue; +} + +void EnNnh_Dialogue(EnNnh* this, PlayState* play) { + if (Actor_TextboxIsClosing(&this->actor, play)) { + EnNnh_SetupWaitForDialogue(this); + } +} + +void EnNnh_Update(Actor* thisx, PlayState* play) { EnNnh* this = THIS; s32 pad; - this->actionFunc(this, globalCtx); + this->actionFunc(this, play); Collider_UpdateCylinder(&this->actor, &this->collider); - CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + CollisionCheck_SetOC(play, &play->colChkCtx, &this->collider.base); } -void EnNnh_Draw(Actor* thisx, GlobalContext* globalCtx) { - GraphicsContext* gfxCtx = globalCtx->state.gfxCtx; +void EnNnh_Draw(Actor* thisx, PlayState* play) { + GraphicsContext* gfxCtx = play->state.gfxCtx; s32 pad; func_8012C28C(gfxCtx); - gSPMatrix(gfxCtx->polyOpa.p++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - gSPDisplayList(gfxCtx->polyOpa.p++, object_nnh_DL_001510); + gSPMatrix(gfxCtx->polyOpa.p++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(gfxCtx->polyOpa.p++, gButlerSonMainBodyDL); } diff --git a/src/overlays/actors/ovl_En_Nnh/z_en_nnh.h b/src/overlays/actors/ovl_En_Nnh/z_en_nnh.h index a006f1024..344ccb345 100644 --- a/src/overlays/actors/ovl_En_Nnh/z_en_nnh.h +++ b/src/overlays/actors/ovl_En_Nnh/z_en_nnh.h @@ -5,7 +5,7 @@ struct EnNnh; -typedef void (*EnNnhActionFunc)(struct EnNnh*, GlobalContext*); +typedef void (*EnNnhActionFunc)(struct EnNnh*, PlayState*); typedef struct EnNnh { /* 0x000 */ Actor actor; 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 3eed47b71..36fea369b 100644 --- a/src/overlays/actors/ovl_En_Nutsball/z_en_nutsball.c +++ b/src/overlays/actors/ovl_En_Nutsball/z_en_nutsball.c @@ -12,10 +12,10 @@ #define THIS ((EnNutsball*)thisx) -void EnNutsball_Init(Actor* thisx, GlobalContext* globalCtx); -void EnNutsball_Destroy(Actor* thisx, GlobalContext* globalCtx); -void EnNutsball_Update(Actor* thisx, GlobalContext* globalCtx); -void EnNutsball_Draw(Actor* thisx, GlobalContext* globalCtx); +void EnNutsball_Init(Actor* thisx, PlayState* play); +void EnNutsball_Destroy(Actor* thisx, PlayState* play); +void EnNutsball_Update(Actor* thisx, PlayState* play); +void EnNutsball_Draw(Actor* thisx, PlayState* play); void EnNutsball_InitColliderParams(EnNutsball* this); @@ -51,11 +51,11 @@ static ColliderCylinderInit sCylinderInit = { { 13, 13, 0, { 0, 0, 0 } }, }; -void EnNutsball_Init(Actor* thisx, GlobalContext* globalCtx) { +void EnNutsball_Init(Actor* thisx, PlayState* play) { EnNutsball* this = THIS; ActorShape_Init(&this->actor.shape, 400.0f, ActorShadow_DrawCircle, 13.0f); - Collider_InitAndSetCylinder(globalCtx, &this->collider, &this->actor, &sCylinderInit); + Collider_InitAndSetCylinder(play, &this->collider, &this->actor, &sCylinderInit); this->actor.shape.rot.y = 0; this->actor.speedXZ = 10.0f; if (this->actor.params == 2) { @@ -74,9 +74,9 @@ void EnNutsball_Init(Actor* thisx, GlobalContext* globalCtx) { } } -void EnNutsball_Destroy(Actor* thisx, GlobalContext* globalCtx) { +void EnNutsball_Destroy(Actor* thisx, PlayState* play) { EnNutsball* this = THIS; - Collider_DestroyCylinder(globalCtx, &this->collider); + Collider_DestroyCylinder(play, &this->collider); } void EnNutsball_InitColliderParams(EnNutsball* this) { @@ -86,10 +86,10 @@ void EnNutsball_InitColliderParams(EnNutsball* this) { this->collider.info.toucher.damage = 2; } -void EnNutsball_Update(Actor* thisx, GlobalContext* globalCtx2) { - GlobalContext* globalCtx = globalCtx2; +void EnNutsball_Update(Actor* thisx, PlayState* play2) { + PlayState* play = play2; EnNutsball* this = THIS; - Player* player = GET_PLAYER(globalCtx); + Player* player = GET_PLAYER(play); Vec3f worldPos; Vec3s worldRot; Vec3f spawnBurstPos; @@ -112,18 +112,18 @@ 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 { spawnBurstPos.x = this->actor.world.pos.x; spawnBurstPos.y = this->actor.world.pos.y + 4.0f; spawnBurstPos.z = this->actor.world.pos.z; - EffectSsHahen_SpawnBurst(globalCtx, &spawnBurstPos, 6.0f, 0, 7, 3, 15, HAHEN_OBJECT_DEFAULT, 10, NULL); + EffectSsHahen_SpawnBurst(play, &spawnBurstPos, 6.0f, 0, 7, 3, 15, HAHEN_OBJECT_DEFAULT, 10, NULL); if (this->actor.params == 1) { - SoundSource_PlaySfxAtFixedWorldPos(globalCtx, &this->actor.world.pos, 20, NA_SE_EV_NUTS_BROKEN); + SoundSource_PlaySfxAtFixedWorldPos(play, &this->actor.world.pos, 20, NA_SE_EV_NUTS_BROKEN); } else { - SoundSource_PlaySfxAtFixedWorldPos(globalCtx, &this->actor.world.pos, 20, NA_SE_EN_OCTAROCK_ROCK); + SoundSource_PlaySfxAtFixedWorldPos(play, &this->actor.world.pos, 20, NA_SE_EN_OCTAROCK_ROCK); } Actor_MarkForDeath(&this->actor); } @@ -135,14 +135,14 @@ void EnNutsball_Update(Actor* thisx, GlobalContext* globalCtx2) { Actor_MoveWithoutGravity(&this->actor); Math_Vec3f_Copy(&worldPos, &this->actor.world.pos); - Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 10.0f, 5.0f, 10.0f, 0x7); + Actor_UpdateBgCheckInfo(play, &this->actor, 10.0f, 5.0f, 10.0f, 0x7); if (this->actor.bgCheckFlags & 8) { - if (func_800C9A4C(&globalCtx->colCtx, this->actor.wallPoly, this->actor.wallBgId) & 0x30) { + if (func_800C9A4C(&play->colCtx, this->actor.wallPoly, this->actor.wallBgId) & 0x30) { this->actor.bgCheckFlags &= ~8; - if (BgCheck_EntityLineTest1(&globalCtx->colCtx, &this->actor.prevPos, &worldPos, &this->actor.world.pos, + if (BgCheck_EntityLineTest1(&play->colCtx, &this->actor.prevPos, &worldPos, &this->actor.world.pos, &poly, true, false, false, true, &bgId)) { - if (func_800C9A4C(&globalCtx->colCtx, poly, bgId) & 0x30) { + if (func_800C9A4C(&play->colCtx, poly, bgId) & 0x30) { this->actor.world.pos.x += this->actor.velocity.x * 0.01f; this->actor.world.pos.z += this->actor.velocity.z * 0.01f; } else { @@ -157,23 +157,23 @@ void EnNutsball_Update(Actor* thisx, GlobalContext* globalCtx2) { this->actor.flags |= ACTOR_FLAG_1000000; - CollisionCheck_SetAT(globalCtx, &globalCtx->colChkCtx, &this->collider.base); - CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + CollisionCheck_SetAT(play, &play->colChkCtx, &this->collider.base); + CollisionCheck_SetAC(play, &play->colChkCtx, &this->collider.base); if (this->timer < this->timerThreshold) { - CollisionCheck_SetOC(globalCtx, &globalCtx2->colChkCtx, &this->collider.base); + CollisionCheck_SetOC(play, &play2->colChkCtx, &this->collider.base); } } } -void EnNutsball_Draw(Actor* thisx, GlobalContext* globalCtx) { +void EnNutsball_Draw(Actor* thisx, PlayState* play) { EnNutsball* this = THIS; - 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); - gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + OPEN_DISPS(play->state.gfxCtx); + func_8012C28C(play->state.gfxCtx); + Matrix_Mult(&play->billboardMtxF, MTXMODE_APPLY); + Matrix_RotateZS(this->actor.home.rot.z, MTXMODE_APPLY); + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_OPA_DISP++, gameplay_keep_DL_058BA0); - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->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 4c0fdce1e..2f842c8ae 100644 --- a/src/overlays/actors/ovl_En_Nwc/z_en_nwc.c +++ b/src/overlays/actors/ovl_En_Nwc/z_en_nwc.c @@ -2,28 +2,45 @@ * 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 (ACTOR_FLAG_10) #define THIS ((EnNwc*)thisx) -void EnNwc_Init(Actor* thisx, GlobalContext* globalCtx); -void EnNwc_Destroy(Actor* thisx, GlobalContext* globalCtx); -void EnNwc_Update(Actor* thisx, GlobalContext* globalCtx); -void EnNwc_Draw(Actor* thisx, GlobalContext* globalCtx); +void EnNwc_Init(Actor* thisx, PlayState* play); +void EnNwc_Destroy(Actor* thisx, PlayState* play); +void EnNwc_Update(Actor* thisx, PlayState* play); +void EnNwc_Draw(Actor* thisx, PlayState* play); -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, PlayState* play); +void EnNwc_CrowAtTheEnd(EnNwc* this, PlayState* play); +void EnNwc_Follow(EnNwc* this, PlayState* play); +void EnNwc_HopForward(EnNwc* this, PlayState* play); +void EnNwc_RunAway(EnNwc* this, PlayState* play); +void EnNwc_Turn(EnNwc* this, PlayState* play); +void EnNwc_CheckForBreman(EnNwc* this, PlayState* play); + +void EnNwc_DrawAdultBody(Actor* thisx, PlayState* play); +s32 EnNwc_OverrideLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, Actor* thisx); +EnHs* EnNwc_FindGrog(PlayState* play); + +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,475 @@ 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, PlayState* play) { + s32 niwObjectIndex; + EnNwc* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Nwc/EnNwc_Destroy.s") + niwObjectIndex = Object_GetIndex(&play->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(&play->actorCtx, play, 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(play); -#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, PlayState* play) { + EnNwc* this = THIS; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Nwc/func_80944630.s") +void EnNwc_SpawnDust(EnNwc* this, PlayState* play) { + Vec3f pos; + Vec3f vec5; + Vec3f vel; + Vec3f accel; + s16 yaw; + s16 pitch; + Vec3f eye = GET_ACTIVE_CAM(play)->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(play, &pos, &vel, &accel, &sPrimColor, &sEnvColor, 300, 30, 10); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Nwc/func_809449D0.s") +EnHs* EnNwc_FindGrog(PlayState* play) { + Actor* grogSearch = play->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, PlayState* play) { + Player* player = GET_PLAYER(play); -#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, PlayState* play) { + Player* player = GET_PLAYER(play); -#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, PlayState* play) { + if (EnNwc_IsFound(this, play)) { + 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(&gSfxDefaultPos, NA_SE_SY_CHICK_JOIN_CHIME, currentChickCount); + } +} + +void EnNwc_LoadNiwSkeleton(EnNwc* this, PlayState* play) { + if (Object_IsLoaded(&play->objectCtx, this->niwObjectIndex)) { + gSegments[6] = PHYSICAL_TO_VIRTUAL(play->objectCtx.status[this->niwObjectIndex].segment); + + SkelAnime_InitFlex(play, &this->niwSkeleton, &gNiwSkeleton, &gNiwIdleAnim, this->jointTable, this->morphTable, + NIW_LIMB_MAX); + Animation_Change(&this->niwSkeleton, &gNiwIdleAnim, 1.0f, 0.0f, Animation_GetLastFrame(&gNiwIdleAnim), + ANIMMODE_LOOP, 0.0f); + + gSegments[6] = PHYSICAL_TO_VIRTUAL(play->objectCtx.status[this->nwcObjectIndex].segment); + this->state = NWC_STATE_NIW_LOADED; + EnNwc_ToggleState(this); + } +} + +void EnNwc_CrowAtTheEnd(EnNwc* this, PlayState* play) { + // 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, PlayState* play) { + 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, play); + 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, play)) { + 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, play); + } + + 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, PlayState* play) { + 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, PlayState* play) { + 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, PlayState* play) { + 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, PlayState* play) { + if (DECR(this->stateTimer) == 0) { + EnNwc_ToggleState(this); + } + + EnNwc_CheckFound(this, play); +} + +void EnNwc_Update(Actor* thisx, PlayState* play) { + EnNwc* this = THIS; + + Actor_MoveWithGravity(&this->actor); + Actor_UpdateBgCheckInfo(play, &this->actor, 10.0f, 10.0f, 10.0f, 5); + this->actionFunc(this, play); + 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, PlayState* play) { + TexturePtr eyeTextures[] = { gNwcEyeOpenTex, gNwcEyeClosedTex }; + EnNwc* this = THIS; + Gfx* dispHead; + + OPEN_DISPS(play->state.gfxCtx); + + func_8012C28C(play->state.gfxCtx); + + dispHead = POLY_OPA_DISP; + + gSPSegment(&dispHead[0], 0x08, Lib_SegmentedToVirtual(eyeTextures[this->blinkState])); + + gSPMatrix(&dispHead[1], Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + + gSPDisplayList(&dispHead[2], &gNwcBodyDL); + + POLY_OPA_DISP = &dispHead[3]; + + CLOSE_DISPS(play->state.gfxCtx); +} + +s32 EnNwc_OverrideLimbDraw(PlayState* play, 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, PlayState* play) { + EnNwc* this = THIS; + + func_8012C28C(play->state.gfxCtx); + SkelAnime_DrawFlexOpa(play, 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..8d2d34c6a 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 void (*EnNwcActionFunc)(struct EnNwc*, PlayState*); 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 c87e30329..ae3b3f04c 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 @@ -5,18 +5,19 @@ */ #include "z_en_okarina_effect.h" +#include "overlays/kaleido_scope/ovl_kaleido_scope/z_kaleido_scope.h" #define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_2000000) #define THIS ((EnOkarinaEffect*)thisx) -void EnOkarinaEffect_Init(Actor* thisx, GlobalContext* globalCtx); -void EnOkarinaEffect_Destroy(Actor* thisx, GlobalContext* globalCtx); -void EnOkarinaEffect_Update(Actor* thisx, GlobalContext* globalCtx); +void EnOkarinaEffect_Init(Actor* thisx, PlayState* play); +void EnOkarinaEffect_Destroy(Actor* thisx, PlayState* play); +void EnOkarinaEffect_Update(Actor* thisx, PlayState* play); -void func_8096B104(EnOkarinaEffect* this, GlobalContext* globalCtx); -void func_8096B174(EnOkarinaEffect* this, GlobalContext* globalCtx); -void func_8096B1FC(EnOkarinaEffect* this, GlobalContext* globalCtx); +void func_8096B104(EnOkarinaEffect* this, PlayState* play); +void func_8096B174(EnOkarinaEffect* this, PlayState* play); +void func_8096B1FC(EnOkarinaEffect* this, PlayState* play); const ActorInit En_Okarina_Effect_InitVars = { ACTOR_EN_OKARINA_EFFECT, @@ -34,41 +35,41 @@ void EnOkarinaEffect_SetupAction(EnOkarinaEffect* this, EnOkarinaEffectActionFun this->actionFunc = actionFunc; } -void EnOkarinaEffect_Destroy(Actor* thisx, GlobalContext* globalCtx) { +void EnOkarinaEffect_Destroy(Actor* thisx, PlayState* play) { } -void EnOkarinaEffect_Init(Actor* thisx, GlobalContext* globalCtx) { +void EnOkarinaEffect_Init(Actor* thisx, PlayState* play) { EnOkarinaEffect* this = THIS; - if (globalCtx->envCtx.unk_F2[1]) { + if (play->envCtx.unk_F2[1]) { Actor_MarkForDeath(&this->actor); } EnOkarinaEffect_SetupAction(this, func_8096B104); } -void func_8096B104(EnOkarinaEffect* this, GlobalContext* globalCtx) { +void func_8096B104(EnOkarinaEffect* this, PlayState* play) { this->unk144 = 0x50; - globalCtx->envCtx.unk_F2[4] = 0x3C; + play->envCtx.unk_F2[4] = 0x3C; D_801F4E70 = 501.0f; - globalCtx->envCtx.unk_E3 = 2; - func_800FD78C(globalCtx); + play->envCtx.unk_E3 = 2; + func_800FD78C(play); EnOkarinaEffect_SetupAction(this, func_8096B174); } -void func_8096B174(EnOkarinaEffect* this, GlobalContext* globalCtx) { +void func_8096B174(EnOkarinaEffect* this, PlayState* play) { DECR(this->unk144); - if (!globalCtx->pauseCtx.state && !globalCtx->gameOverCtx.state && !globalCtx->msgCtx.unk11F10 && - !FrameAdvance_IsEnabled(&globalCtx->state) && this->unk144 == 0) { + if ((play->pauseCtx.state == 0) && (play->gameOverCtx.state == GAMEOVER_INACTIVE) && + (play->msgCtx.msgLength == 0) && !FrameAdvance_IsEnabled(&play->state) && (this->unk144 == 0)) { EnOkarinaEffect_SetupAction(this, func_8096B1FC); } } -void func_8096B1FC(EnOkarinaEffect* this, GlobalContext* globalCtx) { - if (globalCtx->envCtx.unk_F2[4]) { - if ((globalCtx->state.frames & 3) == 0) { - --globalCtx->envCtx.unk_F2[4]; - if (globalCtx->envCtx.unk_F2[4] == 8) { - func_800FD858(globalCtx); +void func_8096B1FC(EnOkarinaEffect* this, PlayState* play) { + if (play->envCtx.unk_F2[4]) { + if ((play->state.frames & 3) == 0) { + play->envCtx.unk_F2[4]--; + if (play->envCtx.unk_F2[4] == 8) { + func_800FD858(play); } } } else { @@ -76,8 +77,8 @@ void func_8096B1FC(EnOkarinaEffect* this, GlobalContext* globalCtx) { } } -void EnOkarinaEffect_Update(Actor* thisx, GlobalContext* globalCtx) { +void EnOkarinaEffect_Update(Actor* thisx, PlayState* play) { EnOkarinaEffect* this = THIS; - this->actionFunc(this, globalCtx); + this->actionFunc(this, play); } diff --git a/src/overlays/actors/ovl_En_Okarina_Effect/z_en_okarina_effect.h b/src/overlays/actors/ovl_En_Okarina_Effect/z_en_okarina_effect.h index 36413efc7..67fa74b2c 100644 --- a/src/overlays/actors/ovl_En_Okarina_Effect/z_en_okarina_effect.h +++ b/src/overlays/actors/ovl_En_Okarina_Effect/z_en_okarina_effect.h @@ -5,7 +5,7 @@ struct EnOkarinaEffect; -typedef void (*EnOkarinaEffectActionFunc)(struct EnOkarinaEffect*, GlobalContext*); +typedef void (*EnOkarinaEffectActionFunc)(struct EnOkarinaEffect*, PlayState*); typedef struct EnOkarinaEffect { /* 0x000 */ Actor actor; 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 5a54da7b1..40cb4ba24 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 @@ -10,14 +10,13 @@ #define THIS ((EnOkarinaTag*)thisx) -void EnOkarinaTag_Init(Actor* thisx, GlobalContext* globalCtx); -void EnOkarinaTag_Destroy(Actor* thisx, GlobalContext* globalCtx); -void EnOkarinaTag_Update(Actor* thisx, GlobalContext* globalCtx); +void EnOkarinaTag_Init(Actor* thisx, PlayState* play); +void EnOkarinaTag_Destroy(Actor* thisx, PlayState* play); +void EnOkarinaTag_Update(Actor* thisx, PlayState* play); -void func_8093E518(EnOkarinaTag* this, GlobalContext* globalCtx); -void func_8093E68C(EnOkarinaTag* this, GlobalContext* globalCtx); +void func_8093E518(EnOkarinaTag* this, PlayState* play); +void func_8093E68C(EnOkarinaTag* this, PlayState* play); -#if 0 const ActorInit En_Okarina_Tag_InitVars = { ACTOR_EN_OKARINA_TAG, ACTORCAT_SWITCH, @@ -30,14 +29,122 @@ const ActorInit En_Okarina_Tag_InitVars = { (ActorFunc)NULL, }; -#endif +void EnOkarinaTag_Destroy(Actor* thisx, PlayState* play) { +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Okarina_Tag/EnOkarinaTag_Destroy.s") +void EnOkarinaTag_Init(Actor* thisx, PlayState* play) { + EnOkarinaTag* this = THIS; + f32 zRot = 0.0f; + s32 i = 0; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Okarina_Tag/EnOkarinaTag_Init.s") + this->actor.flags &= ~ACTOR_FLAG_1; + this->unk148 = ENOKARINATAG_GET_F800(thisx); + this->unk14A = ENOKARINATAG_GET_780(thisx); + this->switchFlags = ENOKARINATAG_GET_SWITCHFLAGS(thisx); + if (this->actor.world.rot.z > 0) { + zRot = this->actor.world.rot.z; + while (zRot > 10.0f) { + zRot -= 10.0f; + i++; + } + } + this->unk154 = zRot * 50.0f; + this->unk158 = i * 50.0f; + if (this->switchFlags == 0x7F) { + this->switchFlags = -1; + } + if (this->unk14A == 0xF) { + this->unk14A = -1; + } + this->actor.targetMode = 1; + this->actionFunc = func_8093E518; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Okarina_Tag/func_8093E518.s") +void func_8093E518(EnOkarinaTag* this, PlayState* play) { + f32 xzRange; + f32 yRange; + s16 yDiff; + u16 var_v1; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Okarina_Tag/func_8093E68C.s") + if (this->switchFlags >= 0) { + if (this->unk148 == 0) { + if (Flags_GetSwitch(play, this->switchFlags)) { + return; + } + } + if (this->unk148 == 1) { + if (!Flags_GetSwitch(play, this->switchFlags)) { + return; + } + } + } + var_v1 = this->unk14A; + if (var_v1 == 6) { + var_v1 = 0xA; + if (gSaveContext.save.unk_F65 == 0) { + return; + } + } + if (this->unk14A == -1) { + var_v1 = 0; + } + if (func_800B8718(&this->actor, &play->state)) { + func_80152434(play, var_v1 + 0x29); + this->actionFunc = func_8093E68C; + } else { + yDiff = ABS_ALT((s16)(this->actor.yawTowardsPlayer - this->actor.world.rot.y)); + if (yDiff >= 0x4300) { + this->unk150 = 0; + return; + } + xzRange = this->unk154; + this->unk150 = 1; + if (xzRange == 0.0f) { + xzRange = 50000.0f; + } + yRange = this->unk158; + if (yRange == 0.0f) { + yRange = 50000.0f; + } + func_800B874C(&this->actor, play, xzRange, yRange); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Okarina_Tag/EnOkarinaTag_Update.s") +void func_8093E68C(EnOkarinaTag* this, PlayState* play) { + if (play->msgCtx.ocarinaMode == 4) { + this->actionFunc = func_8093E518; + } else { + if ((play->msgCtx.ocarinaMode == 3) || + ((this->unk14A == -1) && + ((play->msgCtx.ocarinaMode == 5) || (play->msgCtx.ocarinaMode == 6) || (play->msgCtx.ocarinaMode == 7) || + (play->msgCtx.ocarinaMode == 8) || (play->msgCtx.ocarinaMode == 0xA) || (play->msgCtx.ocarinaMode == 9) || + (play->msgCtx.ocarinaMode == 0xF)))) { + if (this->switchFlags >= 0) { + switch (this->unk148) { + case 0: + Flags_SetSwitch(play, this->switchFlags); + break; + case 1: + Flags_UnsetSwitch(play, this->switchFlags); + break; + case 2: + if (Flags_GetSwitch(play, this->switchFlags)) { + Flags_UnsetSwitch(play, this->switchFlags); + } else { + Flags_SetSwitch(play, this->switchFlags); + } + break; + } + } + play->msgCtx.ocarinaMode = 4; + play_sound(NA_SE_SY_CORRECT_CHIME); + this->actionFunc = func_8093E518; + } + } +} + +void EnOkarinaTag_Update(Actor* thisx, PlayState* play) { + EnOkarinaTag* this = THIS; + + this->actionFunc(this, play); +} diff --git a/src/overlays/actors/ovl_En_Okarina_Tag/z_en_okarina_tag.h b/src/overlays/actors/ovl_En_Okarina_Tag/z_en_okarina_tag.h index 53b63236e..8dd51805c 100644 --- a/src/overlays/actors/ovl_En_Okarina_Tag/z_en_okarina_tag.h +++ b/src/overlays/actors/ovl_En_Okarina_Tag/z_en_okarina_tag.h @@ -5,12 +5,21 @@ struct EnOkarinaTag; -typedef void (*EnOkarinaTagActionFunc)(struct EnOkarinaTag*, GlobalContext*); +typedef void (*EnOkarinaTagActionFunc)(struct EnOkarinaTag*, PlayState*); + +#define ENOKARINATAG_GET_SWITCHFLAGS(thisx) (((thisx)->params & 0x7F)) +#define ENOKARINATAG_GET_780(thisx) (((thisx)->params >> 0x7) & 0xF) +#define ENOKARINATAG_GET_F800(thisx) (((thisx)->params >> 0xB) & 0x1F) typedef struct EnOkarinaTag { - /* 0x0000 */ Actor actor; - /* 0x0144 */ EnOkarinaTagActionFunc actionFunc; - /* 0x0148 */ char unk_148[0x14]; + /* 0x000 */ Actor actor; + /* 0x144 */ EnOkarinaTagActionFunc actionFunc; + /* 0x148 */ s16 unk148; + /* 0x14A */ s16 unk14A; + /* 0x14C */ s32 switchFlags; + /* 0x150 */ s8 unk150; + /* 0x154 */ f32 unk154; + /* 0x158 */ f32 unk158; } EnOkarinaTag; // size = 0x15C extern const ActorInit En_Okarina_Tag_InitVars; 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 b11997b82..a0de8cc48 100644 --- a/src/overlays/actors/ovl_En_Okuta/z_en_okuta.c +++ b/src/overlays/actors/ovl_En_Okuta/z_en_okuta.c @@ -10,22 +10,22 @@ #define THIS ((EnOkuta*)thisx) -void EnOkuta_Init(Actor* thisx, GlobalContext* globalCtx); -void EnOkuta_Destroy(Actor* thisx, GlobalContext* globalCtx); -void EnOkuta_Update(Actor* thisx, GlobalContext* globalCtx); -void EnOkuta_Draw(Actor* thisx, GlobalContext* globalCtx); +void EnOkuta_Init(Actor* thisx, PlayState* play); +void EnOkuta_Destroy(Actor* thisx, PlayState* play); +void EnOkuta_Update(Actor* thisx, PlayState* play); +void EnOkuta_Draw(Actor* thisx, PlayState* play); -void func_8086E52C(EnOkuta* this, GlobalContext* globalCtx); -void func_8086E658(EnOkuta* this, GlobalContext* globalCtx); -void func_8086E7E8(EnOkuta* this, GlobalContext* globalCtx); -void func_8086E948(EnOkuta* this, GlobalContext* globalCtx); -void func_8086EC00(EnOkuta* this, GlobalContext* globalCtx); -void func_8086EF14(EnOkuta* this, GlobalContext* globalCtx); -void func_8086EFE8(EnOkuta* this, GlobalContext* globalCtx); -void func_8086F434(EnOkuta* this, GlobalContext* globalCtx); -void func_8086F4B0(EnOkuta* this, GlobalContext* globalCtx); -void func_8086F57C(EnOkuta* this, GlobalContext* globalCtx); -void func_8086F694(EnOkuta* this, GlobalContext* globalCtx); +void func_8086E52C(EnOkuta* this, PlayState* play); +void func_8086E658(EnOkuta* this, PlayState* play); +void func_8086E7E8(EnOkuta* this, PlayState* play); +void func_8086E948(EnOkuta* this, PlayState* play); +void func_8086EC00(EnOkuta* this, PlayState* play); +void func_8086EF14(EnOkuta* this, PlayState* play); +void func_8086EFE8(EnOkuta* this, PlayState* play); +void func_8086F434(EnOkuta* this, PlayState* play); +void func_8086F4B0(EnOkuta* this, PlayState* play); +void func_8086F57C(EnOkuta* this, PlayState* play); +void func_8086F694(EnOkuta* this, PlayState* play); #if 0 const ActorInit En_Okuta_InitVars = { diff --git a/src/overlays/actors/ovl_En_Okuta/z_en_okuta.h b/src/overlays/actors/ovl_En_Okuta/z_en_okuta.h index 1e2cfdd7d..c23a4db36 100644 --- a/src/overlays/actors/ovl_En_Okuta/z_en_okuta.h +++ b/src/overlays/actors/ovl_En_Okuta/z_en_okuta.h @@ -5,13 +5,13 @@ struct EnOkuta; -typedef void (*EnOkutaActionFunc)(struct EnOkuta*, GlobalContext*); +typedef void (*EnOkutaActionFunc)(struct EnOkuta*, PlayState*); typedef struct EnOkuta { - /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x44]; - /* 0x0188 */ EnOkutaActionFunc actionFunc; - /* 0x018C */ char unk_18C[0x1A8]; + /* 0x000 */ Actor actor; + /* 0x144 */ char unk_144[0x44]; + /* 0x188 */ EnOkutaActionFunc actionFunc; + /* 0x18C */ char unk_18C[0x1A8]; } EnOkuta; // size = 0x334 extern const ActorInit En_Okuta_InitVars; diff --git a/src/overlays/actors/ovl_En_Onpuman/z_en_onpuman.c b/src/overlays/actors/ovl_En_Onpuman/z_en_onpuman.c index c904cdd42..59b3140bc 100644 --- a/src/overlays/actors/ovl_En_Onpuman/z_en_onpuman.c +++ b/src/overlays/actors/ovl_En_Onpuman/z_en_onpuman.c @@ -10,11 +10,12 @@ #define THIS ((EnOnpuman*)thisx) -void EnOnpuman_Init(Actor* thisx, GlobalContext* globalCtx); -void EnOnpuman_Destroy(Actor* thisx, GlobalContext* globalCtx); -void EnOnpuman_Update(Actor* thisx, GlobalContext* globalCtx); +void EnOnpuman_Init(Actor* thisx, PlayState* play); +void EnOnpuman_Destroy(Actor* thisx, PlayState* play); +void EnOnpuman_Update(Actor* thisx, PlayState* play); + +void func_80B121D8(EnOnpuman* this, PlayState* play); -#if 0 const ActorInit En_Onpuman_InitVars = { ACTOR_EN_ONPUMAN, ACTORCAT_NPC, @@ -27,29 +28,150 @@ const ActorInit En_Onpuman_InitVars = { (ActorFunc)NULL, }; -// static ColliderCylinderInit sCylinderInit = { -static ColliderCylinderInit D_80B12390 = { - { COLTYPE_NONE, AT_NONE, AC_ON | AC_TYPE_PLAYER, OC1_ON | OC1_TYPE_ALL, OC2_TYPE_1, COLSHAPE_CYLINDER, }, - { ELEMTYPE_UNK0, { 0x00000000, 0x00, 0x00 }, { 0x00000000, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_ON, }, +static ColliderCylinderInit sCylinderInit = { + { + COLTYPE_NONE, + AT_NONE, + AC_ON | AC_TYPE_PLAYER, + OC1_ON | OC1_TYPE_ALL, + OC2_TYPE_1, + COLSHAPE_CYLINDER, + }, + { + ELEMTYPE_UNK0, + { 0x00000000, 0x00, 0x00 }, + { 0x00000000, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_ON, + }, { 30, 40, 0, { 0, 0, 0 } }, }; -#endif +void EnOnpuman_Init(Actor* thisx, PlayState* play) { + EnOnpuman* this = THIS; -extern ColliderCylinderInit D_80B12390; + ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 36.0f); + this->actor.flags |= ACTOR_FLAG_2000000; + Collider_InitAndSetCylinder(play, &this->collider, &this->actor, &sCylinderInit); + this->actor.colChkInfo.mass = MASS_IMMOVABLE; + Actor_SetScale(&this->actor, 0.01f); + this->actor.targetMode = 6; + this->unk_2A4 = 0; + this->unk_2A0 = NULL; + this->actionFunc = func_80B121D8; + this->actor.velocity.y = -10.0f; + this->actor.terminalVelocity = -10.0f; + this->actor.gravity = -5.0f; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Onpuman/EnOnpuman_Init.s") +void EnOnpuman_Destroy(Actor* thisx, PlayState* play) { + EnOnpuman* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Onpuman/EnOnpuman_Destroy.s") + Collider_DestroyCylinder(play, &this->collider); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Onpuman/func_80B11F44.s") +Actor* func_80B11F44(PlayState* play) { + Actor* itemAction = play->actorCtx.actorLists[ACTORCAT_ITEMACTION].first; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Onpuman/func_80B11F78.s") + if (itemAction != NULL) { + if (itemAction->id != ACTOR_EN_GAKUFU) { + itemAction = itemAction->next; + } + return itemAction; + } + return NULL; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Onpuman/func_80B1202C.s") +void func_80B11F78(EnOnpuman* this, PlayState* play) { + if (play->msgCtx.ocarinaMode == 4) { + this->actionFunc = func_80B121D8; + if (this->actor.cutscene != -1) { + ActorCutscene_Stop(this->actor.cutscene); + } + } else if (play->msgCtx.ocarinaMode == 3) { + play_sound(NA_SE_SY_CORRECT_CHIME); + play->msgCtx.ocarinaMode = 4; + if (this->actor.cutscene != -1) { + ActorCutscene_Stop(this->actor.cutscene); + } + this->actionFunc = func_80B121D8; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Onpuman/func_80B1217C.s") +void func_80B1202C(EnOnpuman* this, PlayState* play2) { + PlayState* play = play2; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Onpuman/func_80B121D8.s") + if ((Message_GetState(&play->msgCtx) == TEXT_STATE_5) && (Message_ShouldAdvance(play))) { + switch (play->msgCtx.currentTextId) { + case 0x8D4: + this->unk_2A4 |= 1; + func_80151938(play, 0x8DA); + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Onpuman/EnOnpuman_Update.s") + case 0x8DA: + func_80151938(play, 0x8D6); + if (this->unk_2A0 != NULL) { + this->unk_2A0->home.rot.x = 0x50; + } + break; + + case 0x8D6: + this->actionFunc = func_80B11F78; + func_80152434(play, 0x3A); + if (this->unk_2A0 != NULL) { + this->unk_2A0->home.rot.x = 0; + } + break; + } + } + if (this->unk_2A4 & 1) { + if (this->actor.cutscene == -1) { + this->unk_2A4 &= ~1; + } else if (ActorCutscene_GetCanPlayNext(this->actor.cutscene)) { + this->unk_2A4 &= ~1; + ActorCutscene_StartAndSetUnkLinkFields(this->actor.cutscene, &this->actor); + } else { + ActorCutscene_SetIntentToPlay(this->actor.cutscene); + } + } +} + +void func_80B1217C(EnOnpuman* this, PlayState* play) { + if ((Message_GetState(&play->msgCtx) == TEXT_STATE_5) && (Message_ShouldAdvance(play))) { + this->actionFunc = func_80B121D8; + func_801477B4(play); + } +} + +void func_80B121D8(EnOnpuman* this, PlayState* play) { + s16 yaw; + + if (func_800B8718(&this->actor, &play->state)) { + this->actionFunc = func_80B1202C; + Message_StartTextbox(play, 0x8D4, NULL); + this->unk_2A0 = func_80B11F44(play); + } else if (Actor_ProcessTalkRequest(&this->actor, &play->state)) { + this->actionFunc = func_80B1217C; + } else { + yaw = this->actor.yawTowardsPlayer - this->actor.shape.rot.y; + if (this->actor.xzDistToPlayer < 200.0f) { + if (ABS_ALT(yaw) <= 0x4300) { + this->actor.textId = 0x8D3; + func_800B8614(&this->actor, play, 100.0f); + func_800B874C(&this->actor, play, 100.0f, 100.0f); + } + } + } +} + +void EnOnpuman_Update(Actor* thisx, PlayState* play) { + s32 pad; + EnOnpuman* this = THIS; + + Collider_UpdateCylinder(&this->actor, &this->collider); + CollisionCheck_SetOC(play, &play->colChkCtx, &this->collider.base); + Actor_MoveWithGravity(&this->actor); + Actor_UpdateBgCheckInfo(play, &this->actor, 0.0f, 0.0f, 0.0f, 4); + this->actionFunc(this, play); +} diff --git a/src/overlays/actors/ovl_En_Onpuman/z_en_onpuman.h b/src/overlays/actors/ovl_En_Onpuman/z_en_onpuman.h index d38dc75f3..88cd1e4df 100644 --- a/src/overlays/actors/ovl_En_Onpuman/z_en_onpuman.h +++ b/src/overlays/actors/ovl_En_Onpuman/z_en_onpuman.h @@ -5,12 +5,15 @@ struct EnOnpuman; -typedef void (*EnOnpumanActionFunc)(struct EnOnpuman*, GlobalContext*); +typedef void (*EnOnpumanActionFunc)(struct EnOnpuman*, PlayState*); typedef struct EnOnpuman { - /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x164]; - /* 0x02A8 */ EnOnpumanActionFunc actionFunc; + /* 0x000 */ Actor actor; + /* 0x144 */ UNK_TYPE1 pad_144[0x110]; + /* 0x254 */ ColliderCylinder collider; + /* 0x2A0 */ Actor* unk_2A0; + /* 0x2A4 */ u16 unk_2A4; // flags + /* 0x2A8 */ EnOnpumanActionFunc actionFunc; } EnOnpuman; // size = 0x2AC extern const ActorInit En_Onpuman_InitVars; diff --git a/src/overlays/actors/ovl_En_Osk/z_en_osk.c b/src/overlays/actors/ovl_En_Osk/z_en_osk.c index 30d9a1666..0180a2e67 100644 --- a/src/overlays/actors/ovl_En_Osk/z_en_osk.c +++ b/src/overlays/actors/ovl_En_Osk/z_en_osk.c @@ -12,15 +12,15 @@ #define THIS ((EnOsk*)thisx) -void EnOsk_Init(Actor* thisx, GlobalContext* globalCtx); -void EnOsk_Destroy(Actor* thisx, GlobalContext* globalCtx); -void EnOsk_Update(Actor* thisx, GlobalContext* globalCtx); -void EnOsk_Draw(Actor* thisx, GlobalContext* globalCtx); +void EnOsk_Init(Actor* thisx, PlayState* play); +void EnOsk_Destroy(Actor* thisx, PlayState* play); +void EnOsk_Update(Actor* thisx, PlayState* play); +void EnOsk_Draw(Actor* thisx, PlayState* play); -void func_80BF5F60(EnOsk* this, GlobalContext* globalCtx); -void func_80BF61EC(EnOsk* this, GlobalContext* globalCtx); -void func_80BF656C(EnOsk* this, GlobalContext* globalCtx); -void func_80BF6A20(EnOsk* this, GlobalContext* globalCtx); +void func_80BF5F60(EnOsk* this, PlayState* play); +void func_80BF61EC(EnOsk* this, PlayState* play); +void func_80BF656C(EnOsk* this, PlayState* play); +void func_80BF6A20(EnOsk* this, PlayState* play); const ActorInit En_Osk_InitVars = { ACTOR_EN_OSK, @@ -58,7 +58,7 @@ Vec3f D_80BF7018 = { 0.0f, 0.5f, 0.0f }; Vec3f D_80BF7024 = { 0.0f, 0.0f, 0.0f }; -void EnOsk_Init(Actor* thisx, GlobalContext* globalCtx) { +void EnOsk_Init(Actor* thisx, PlayState* play) { EnOsk* this = THIS; Actor_SetScale(&this->actor, 0.013f); @@ -71,7 +71,7 @@ void EnOsk_Init(Actor* thisx, GlobalContext* globalCtx) { switch (ENOSK_GET_F(&this->actor)) { case ENOSK_1: - SkelAnime_InitFlex(globalCtx, &this->skelAnime, &object_ikn_demo_Skel_007B48, &object_ikn_demo_Anim_006808, + SkelAnime_InitFlex(play, &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; @@ -79,7 +79,7 @@ void EnOsk_Init(Actor* thisx, GlobalContext* globalCtx) { break; case ENOSK_2: - SkelAnime_InitFlex(globalCtx, &this->skelAnime, &object_ikn_demo_Skel_00B490, &object_ikn_demo_Anim_009F00, + SkelAnime_InitFlex(play, &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; @@ -88,7 +88,7 @@ void EnOsk_Init(Actor* thisx, GlobalContext* globalCtx) { default: Actor_SetScale(&this->actor, 0.017f); - SkelAnime_InitFlex(globalCtx, &this->skelAnime, &object_ikn_demo_Skel_0038F0, &object_ikn_demo_Anim_0000B8, + SkelAnime_InitFlex(play, &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; @@ -99,7 +99,7 @@ void EnOsk_Init(Actor* thisx, GlobalContext* globalCtx) { } } -void EnOsk_Destroy(Actor* thisx, GlobalContext* globalCtx) { +void EnOsk_Destroy(Actor* thisx, PlayState* play) { } void func_80BF5E00(EnOsk* this, AnimationHeader** animations, s16 index, f32 morphFrame) { @@ -115,17 +115,17 @@ void func_80BF5E68(EnOsk* this, AnimationHeader** animations, s16 index, f32 pla this->unk_254 = index; } -void func_80BF5EBC(EnOsk* this, GlobalContext* globalCtx) { +void func_80BF5EBC(EnOsk* this, PlayState* play) { Vec3f sp2C; 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; - func_800B3030(globalCtx, &sp2C, &D_80BF7018, &D_80BF7018, 100, 0, 2); + func_800B3030(play, &sp2C, &D_80BF7018, &D_80BF7018, 100, 0, 2); } -void func_80BF5F60(EnOsk* this, GlobalContext* globalCtx) { +void func_80BF5F60(EnOsk* this, PlayState* play) { } void func_80BF5F70(EnOsk* this) { @@ -166,10 +166,10 @@ void func_80BF5F70(EnOsk* this) { } } -void func_80BF609C(EnOsk* this, GlobalContext* globalCtx) { +void func_80BF609C(EnOsk* this, PlayState* play) { if (this->actor.draw != NULL) { if (this->actor.home.rot.z != 0) { - if (globalCtx->msgCtx.currentTextId == 0x1531) { + if (play->msgCtx.currentTextId == 0x1531) { this->actor.home.rot.z = 0; } } else { @@ -202,18 +202,16 @@ void func_80BF609C(EnOsk* this, GlobalContext* globalCtx) { } } -void func_80BF61EC(EnOsk* this, GlobalContext* globalCtx) { +void func_80BF61EC(EnOsk* this, PlayState* play) { 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; + if (Cutscene_CheckActorAction(play, this->unk_258)) { + Cutscene_ActorTranslateAndYaw(&this->actor, play, Cutscene_GetActorActionIndex(play, this->unk_258)); + if (this->unk_256 != play->csCtx.actorActions[Cutscene_GetActorActionIndex(play, this->unk_258)]->action) { + this->unk_256 = play->csCtx.actorActions[Cutscene_GetActorActionIndex(play, this->unk_258)]->action; func_80BF5F70(this); } - func_80BF609C(this, globalCtx); + func_80BF609C(this, play); } else { this->actor.draw = NULL; } @@ -222,7 +220,7 @@ void func_80BF61EC(EnOsk* this, GlobalContext* globalCtx) { 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_80BF5EBC(this, play); func_800B9010(&this->actor, NA_SE_EN_COMMON_EXTINCT_LEV - SFX_FLAG); } else { this->actor.draw = NULL; @@ -306,7 +304,7 @@ void func_80BF6478(EnOsk* this) { } } -void func_80BF656C(EnOsk* this, GlobalContext* globalCtx) { +void func_80BF656C(EnOsk* this, PlayState* play) { if (SkelAnime_Update(&this->skelAnime)) { switch (this->unk_254) { case 2: @@ -331,12 +329,10 @@ void func_80BF656C(EnOsk* this, GlobalContext* globalCtx) { } } - 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; + if (Cutscene_CheckActorAction(play, this->unk_258)) { + Cutscene_ActorTranslateAndYaw(&this->actor, play, Cutscene_GetActorActionIndex(play, this->unk_258)); + if (this->unk_256 != play->csCtx.actorActions[Cutscene_GetActorActionIndex(play, this->unk_258)]->action) { + this->unk_256 = play->csCtx.actorActions[Cutscene_GetActorActionIndex(play, this->unk_258)]->action; func_80BF6314(this); } func_80BF6478(this); @@ -353,7 +349,7 @@ void func_80BF656C(EnOsk* this, GlobalContext* globalCtx) { 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_80BF5EBC(this, play); func_800B9010(&this->actor, NA_SE_EN_COMMON_EXTINCT_LEV - SFX_FLAG); } else { this->actor.draw = NULL; @@ -441,7 +437,7 @@ void func_80BF68E0(EnOsk* this) { } } -void func_80BF6A20(EnOsk* this, GlobalContext* globalCtx) { +void func_80BF6A20(EnOsk* this, PlayState* play) { if (SkelAnime_Update(&this->skelAnime)) { switch (this->unk_254) { case 2: @@ -470,12 +466,10 @@ void func_80BF6A20(EnOsk* this, GlobalContext* globalCtx) { } } - 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; + if (Cutscene_CheckActorAction(play, this->unk_258)) { + Cutscene_ActorTranslateAndYaw(&this->actor, play, Cutscene_GetActorActionIndex(play, this->unk_258)); + if (this->unk_256 != play->csCtx.actorActions[Cutscene_GetActorActionIndex(play, this->unk_258)]->action) { + this->unk_256 = play->csCtx.actorActions[Cutscene_GetActorActionIndex(play, this->unk_258)]->action; func_80BF67A8(this); } func_80BF68E0(this); @@ -487,7 +481,7 @@ void func_80BF6A20(EnOsk* this, GlobalContext* globalCtx) { 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_80BF5EBC(this, play); func_800B9010(&this->actor, NA_SE_EN_COMMON_EXTINCT_LEV - SFX_FLAG); } else { this->actor.draw = NULL; @@ -495,42 +489,42 @@ void func_80BF6A20(EnOsk* this, GlobalContext* globalCtx) { } } -void EnOsk_Update(Actor* thisx, GlobalContext* globalCtx) { +void EnOsk_Update(Actor* thisx, PlayState* play) { EnOsk* this = THIS; - this->actionFunc(this, globalCtx); + this->actionFunc(this, play); } -void func_80BF6C54(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx) { +void func_80BF6C54(PlayState* play, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx) { EnOsk* this = THIS; if (limbIndex == 1) { - Matrix_MultiplyVector3fByState(&D_80BF7024, &this->actor.focus.pos); + Matrix_MultVec3f(&D_80BF7024, &this->actor.focus.pos); } } -void EnOsk_Draw(Actor* thisx, GlobalContext* globalCtx) { +void EnOsk_Draw(Actor* thisx, PlayState* play) { s32 pad; EnOsk* this = THIS; Gfx* gfx; Vec3f sp80; s32 pad2[4]; - OPEN_DISPS(globalCtx->state.gfxCtx); + OPEN_DISPS(play->state.gfxCtx); - func_8012C28C(globalCtx->state.gfxCtx); + func_8012C28C(play->state.gfxCtx); - gSPSegment(POLY_OPA_DISP++, 0x08, Gfx_PrimColor(globalCtx->state.gfxCtx, 0x80, 255, 255, 255, 255)); + gSPSegment(POLY_OPA_DISP++, 0x08, Gfx_PrimColor(play->state.gfxCtx, 0x80, 255, 255, 255, 255)); - SkelAnime_DrawFlexOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, - NULL, func_80BF6C54, &this->actor); + SkelAnime_DrawFlexOpa(play, 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; + sp54 = GET_ACTIVE_CAM(play)->eye; sp62 = Math_Vec3f_Yaw(&sp54, &this->actor.focus.pos); sp60 = -Math_Vec3f_Pitch(&sp54, &this->actor.focus.pos); @@ -539,10 +533,10 @@ void EnOsk_Draw(Actor* thisx, GlobalContext* globalCtx) { sp80.y = -(Math_SinS(sp60) * 15.0f); sp80.z = -(15.0f * (Math_CosS(sp62)) * Math_CosS(sp60)); - Matrix_InsertTranslation(this->actor.focus.pos.x + sp80.x, this->actor.focus.pos.y + sp80.y, - sp80.z = this->actor.focus.pos.z + sp80.z, MTXMODE_NEW); + 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 = Math_SinS(play->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); @@ -557,10 +551,10 @@ void EnOsk_Draw(Actor* thisx, GlobalContext* globalCtx) { 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); + gSPMatrix(gfx++, Matrix_NewMtx(play->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); + CLOSE_DISPS(play->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 9515e9705..d8a4be4ce 100644 --- a/src/overlays/actors/ovl_En_Osk/z_en_osk.h +++ b/src/overlays/actors/ovl_En_Osk/z_en_osk.h @@ -5,7 +5,7 @@ struct EnOsk; -typedef void (*EnOskActionFunc)(struct EnOsk*, GlobalContext*); +typedef void (*EnOskActionFunc)(struct EnOsk*, PlayState*); #define ENOSK_GET_F(thisx) ((thisx)->params & 0xF) @@ -13,15 +13,15 @@ typedef void (*EnOskActionFunc)(struct EnOsk*, GlobalContext*); #define ENOSK_2 2 typedef struct EnOsk { - /* 0x0000 */ Actor actor; - /* 0x0144 */ SkelAnime skelAnime; - /* 0x0188 */ Vec3s jointTable[17]; - /* 0x01EE */ Vec3s morphTable[17]; - /* 0x0254 */ s16 unk_254; - /* 0x0256 */ s16 unk_256; - /* 0x0258 */ u16 unk_258; - /* 0x025C */ f32 unk_25C; - /* 0x0260 */ EnOskActionFunc actionFunc; + /* 0x000 */ Actor actor; + /* 0x144 */ SkelAnime skelAnime; + /* 0x188 */ Vec3s jointTable[17]; + /* 0x1EE */ Vec3s morphTable[17]; + /* 0x254 */ s16 unk_254; + /* 0x256 */ s16 unk_256; + /* 0x258 */ u16 unk_258; + /* 0x25C */ f32 unk_25C; + /* 0x260 */ EnOskActionFunc actionFunc; } EnOsk; // size = 0x264 extern const ActorInit En_Osk_InitVars; diff --git a/src/overlays/actors/ovl_En_Osn/z_en_osn.c b/src/overlays/actors/ovl_En_Osn/z_en_osn.c index 48a87b30e..b2fee9d8d 100644 --- a/src/overlays/actors/ovl_En_Osn/z_en_osn.c +++ b/src/overlays/actors/ovl_En_Osn/z_en_osn.c @@ -11,10 +11,10 @@ #define THIS ((EnOsn*)thisx) -void EnOsn_Init(Actor* thisx, GlobalContext* globalCtx); -void EnOsn_Destroy(Actor* thisx, GlobalContext* globalCtx); -void EnOsn_Update(Actor* thisx, GlobalContext* globalCtx); -void EnOsn_Draw(Actor* thisx, GlobalContext* globalCtx); +void EnOsn_Init(Actor* thisx, PlayState* play); +void EnOsn_Destroy(Actor* thisx, PlayState* play); +void EnOsn_Update(Actor* thisx, PlayState* play); +void EnOsn_Draw(Actor* thisx, PlayState* play); const ActorInit En_Osn_InitVars = { ACTOR_EN_OSN, @@ -28,20 +28,32 @@ const ActorInit En_Osn_InitVars = { (ActorFunc)EnOsn_Draw, }; -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 AnimationInfo sAnimationInfo[] = { + { &object_osn_Anim_0201BC, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, 0.0f }, + { &object_osn_Anim_002F74, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, 0.0f }, + { &object_osn_Anim_0037C4, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, 0.0f }, + { &object_osn_Anim_004320, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, 0.0f }, + { &object_osn_Anim_004C8C, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, 0.0f }, + { &object_osn_Anim_0094E4, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, 0.0f }, + { &object_osn_Anim_009BB8, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, 0.0f }, + { &object_osn_Anim_00AC60, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, 0.0f }, + { &object_osn_Anim_001614, 1.0f, 1.0f, 39.0f, ANIMMODE_LOOP, 0.0f }, + { &object_osn_Anim_001034, 1.0f, 1.0f, 70.0f, ANIMMODE_LOOP, 0.0f }, + { &object_osn_Anim_00AE9C, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, 0.0f }, + { &object_osn_Anim_003A1C, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, 0.0f }, + { &object_osn_Anim_0055F8, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, 0.0f }, + { &object_osn_Anim_007220, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, 0.0f }, + { &object_osn_Anim_00A444, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, 0.0f }, + { &object_osn_Anim_0000C4, 0.0f, 0.0f, 0.0f, ANIMMODE_ONCE, 0.0f }, + { &object_osn_Anim_0000C4, 0.0f, 1.0f, 1.0f, ANIMMODE_ONCE, 0.0f }, + { &object_osn_Anim_006D48, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, 0.0f }, + { &object_osn_Anim_001D6C, 1.0f, 0.0f, 0.0f, ANIMMODE_ONCE, 0.0f }, + { &object_osn_Anim_002634, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, 0.0f }, + { &object_osn_Anim_008D80, 1.0f, 0.0f, 0.0f, ANIMMODE_ONCE, 0.0f }, + { &object_osn_Anim_005D78, 1.0f, 0.0f, 0.0f, ANIMMODE_ONCE, 0.0f }, + { &object_osn_Anim_006564, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, 0.0f }, + { &object_osn_Anim_00A444, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, 0.0f }, + { &object_osn_Anim_008D80, 0.0f, 77.0f, 0.0f, ANIMMODE_ONCE, 0.0f }, }; static ColliderCylinderInit sCylinderInit = { @@ -105,21 +117,21 @@ static InitChainEntry sInitChain[] = { ICHAIN_U8(targetMode, 0, ICHAIN_STOP), }; -void func_80AD1634(EnOsn*, GlobalContext*); -void func_80AD16A8(EnOsn*, GlobalContext*); -void func_80AD14C8(EnOsn*, GlobalContext*); -void func_80AD19A0(EnOsn* this, GlobalContext* globalCtx); +void func_80AD1634(EnOsn*, PlayState*); +void func_80AD16A8(EnOsn*, PlayState*); +void func_80AD14C8(EnOsn*, PlayState*); +void func_80AD19A0(EnOsn* this, PlayState* play); -void func_80AD0830(EnOsn* this, GlobalContext* globalCtx) { +void func_80AD0830(EnOsn* this, PlayState* play) { this->collider.dim.pos.x = this->actor.world.pos.x; this->collider.dim.pos.y = this->actor.world.pos.y; this->collider.dim.pos.z = this->actor.world.pos.z; - CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); - CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + CollisionCheck_SetAC(play, &play->colChkCtx, &this->collider.base); + CollisionCheck_SetOC(play, &play->colChkCtx, &this->collider.base); } -s32 func_80AD08B0(GlobalContext* globalCtx) { - switch (Player_GetMask(globalCtx)) { +s32 func_80AD08B0(PlayState* play) { + switch (Player_GetMask(play)) { case PLAYER_MASK_GREAT_FAIRY: return 0x1FD6; case PLAYER_MASK_GIBDO: @@ -167,27 +179,27 @@ s32 func_80AD08B0(GlobalContext* globalCtx) { void func_80AD0998(EnOsn* this) { s16 curFrame = this->skelAnime.curFrame; - s16 lastFrame = Animation_GetLastFrame(sAnimations[this->unk_1EC].animation); + s16 lastFrame = Animation_GetLastFrame(sAnimationInfo[this->unk_1EC].animation); if (this->unk_1EC == 0x12 && curFrame == lastFrame) { this->unk_1EC = 0x13; - Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 0x13); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, 0x13); } } void func_80AD0A24(EnOsn* this) { s16 curFrame = this->skelAnime.curFrame; - s16 lastFrame = Animation_GetLastFrame(sAnimations[this->unk_1EC].animation); + s16 lastFrame = Animation_GetLastFrame(sAnimationInfo[this->unk_1EC].animation); if (this->unk_1EC == 0x15 && curFrame == lastFrame) { this->unk_1EC = 0x16; - Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 0x16); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, 0x16); } } void func_80AD0AB0(EnOsn* this) { s16 curFrame = this->skelAnime.curFrame; - s16 lastFrame = Animation_GetLastFrame(sAnimations[this->unk_1EC].animation); + s16 lastFrame = Animation_GetLastFrame(sAnimationInfo[this->unk_1EC].animation); if (curFrame == lastFrame) { this->unk_1FA -= 8; @@ -198,8 +210,8 @@ void func_80AD0AB0(EnOsn* this) { } } -s32 func_80AD0B38(EnOsn* this, GlobalContext* globalCtx) { - switch (Player_GetMask(globalCtx)) { +s32 func_80AD0B38(EnOsn* this, PlayState* play) { + switch (Player_GetMask(play)) { case PLAYER_MASK_GREAT_FAIRY: if (!(this->unk_1F6 & 1)) { this->unk_1F6 |= 1; @@ -331,8 +343,8 @@ s32 func_80AD0B38(EnOsn* this, GlobalContext* globalCtx) { return 0x1FCD; } -s32 func_80AD0E10(EnOsn* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); +s32 func_80AD0E10(EnOsn* this, PlayState* play) { + Player* player = GET_PLAYER(play); if ((gSaveContext.save.inventory.items[SLOT_OCARINA] != ITEM_NONE) && CHECK_QUEST_ITEM(QUEST_SONG_HEALING)) { if (this->unk_1EA & 1) { @@ -396,7 +408,7 @@ s32 func_80AD0E10(EnOsn* this, GlobalContext* globalCtx) { return 0x1FD0; } - if (Player_GetMask(globalCtx) == PLAYER_MASK_NONE) { + if (Player_GetMask(play) == PLAYER_MASK_NONE) { if (this->unk_1EA & 2) { this->unk_1EA |= 0x20; if ((gSaveContext.save.day == 3) && (gSaveContext.save.time >= CLOCK_TIME(5, 0)) && @@ -409,7 +421,7 @@ s32 func_80AD0E10(EnOsn* this, GlobalContext* globalCtx) { return 0x1FC8; } - return func_80AD0B38(this, globalCtx); + return func_80AD0B38(this, play); } this->unk_1EA |= 0x20; @@ -421,7 +433,7 @@ s32 func_80AD0E10(EnOsn* this, GlobalContext* globalCtx) { return 0x1FAE; } -void func_80AD10FC(EnOsn* this, GlobalContext* globalCtx) { +void func_80AD10FC(EnOsn* this, PlayState* play) { switch (this->unk_1F4) { case 0x1FC8: this->unk_1F4 = 0x1FC9; @@ -457,7 +469,7 @@ void func_80AD10FC(EnOsn* this, GlobalContext* globalCtx) { case 0x1FD1: case 0x1FD2: - this->unk_1F4 = func_80AD08B0(globalCtx); + this->unk_1F4 = func_80AD08B0(play); break; case 0x1FD6: @@ -576,7 +588,7 @@ void func_80AD10FC(EnOsn* this, GlobalContext* globalCtx) { this->unk_1EA |= 0x20; } - Message_StartTextbox(globalCtx, this->unk_1F4, &this->actor); + Message_StartTextbox(play, this->unk_1F4, &this->actor); } void func_80AD1398(EnOsn* this) { @@ -592,11 +604,11 @@ void func_80AD1398(EnOsn* this) { } } -void func_80AD144C(EnOsn* this, GlobalContext* globalCtx) { - u32 sp1C = Flags_GetSwitch(globalCtx, 0); +void func_80AD144C(EnOsn* this, PlayState* play) { + u32 sp1C = Flags_GetSwitch(play, 0); this->cutscene = this->actor.cutscene; - Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 0); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, 0); if (sp1C == 0) { this->actionFunc = func_80AD16A8; } else { @@ -604,30 +616,30 @@ void func_80AD144C(EnOsn* this, GlobalContext* globalCtx) { } } -void func_80AD14C8(EnOsn* this, GlobalContext* globalCtx) { +void func_80AD14C8(EnOsn* this, PlayState* play) { 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)) { + if (Actor_ProcessTalkRequest(&this->actor, &play->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); + func_800B863C(&this->actor, play); 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); + if (Actor_ProcessTalkRequest(&this->actor, &play->state)) { + this->unk_1F4 = func_80AD0E10(this, play); + Message_StartTextbox(play, 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); + func_800B863C(&this->actor, play); } } } -void func_80AD1634(EnOsn* this, GlobalContext* globalCtx) { +void func_80AD1634(EnOsn* this, PlayState* play) { if (ActorCutscene_GetCanPlayNext(this->cutscene)) { ActorCutscene_Start(this->cutscene, &this->actor); this->actionFunc = func_80AD16A8; @@ -639,16 +651,16 @@ void func_80AD1634(EnOsn* this, GlobalContext* globalCtx) { ActorCutscene_SetIntentToPlay(this->cutscene); } -void func_80AD16A8(EnOsn* this, GlobalContext* globalCtx) { +void func_80AD16A8(EnOsn* this, PlayState* play) { u8 pad; s32 actionIndex; - if (Cutscene_CheckActorAction(globalCtx, 130)) { - actionIndex = Cutscene_GetActorActionIndex(globalCtx, 130); + if (Cutscene_CheckActorAction(play, 130)) { + actionIndex = Cutscene_GetActorActionIndex(play, 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) { + if (this->unk_1ED != play->csCtx.actorActions[actionIndex]->action) { + this->unk_1ED = play->csCtx.actorActions[actionIndex]->action; + switch (play->csCtx.actorActions[actionIndex]->action) { case 1: this->unk_1EC = 2; break; @@ -716,11 +728,11 @@ void func_80AD16A8(EnOsn* this, GlobalContext* globalCtx) { this->unk_1EC = 0; break; } - Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, this->unk_1EC); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, this->unk_1EC); } - if ((this->unk_1EC == 5) && (globalCtx->sceneNum == SCENE_SPOT00) && (gSaveContext.sceneSetupIndex == 0xB) && - (globalCtx->csCtx.frames == 400)) { + if ((this->unk_1EC == 5) && (play->sceneNum == SCENE_SPOT00) && (gSaveContext.sceneSetupIndex == 0xB) && + (play->csCtx.frames == 400)) { Actor_PlaySfxAtPos(&this->actor, NA_SE_VO_OMVO00); } if (this->unk_1EC == 0x12) { @@ -738,75 +750,77 @@ void func_80AD16A8(EnOsn* this, GlobalContext* globalCtx) { (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); + Cutscene_ActorTranslateAndYaw(&this->actor, play, actionIndex); } else { this->unk_1F0 = 1; this->unk_1ED = 0x63; - func_80AD144C(this, globalCtx); + func_80AD144C(this, play); } } -void func_80AD19A0(EnOsn* this, GlobalContext* globalCtx) { - u8 temp_v0 = Message_GetState(&globalCtx->msgCtx); +void func_80AD19A0(EnOsn* this, PlayState* play) { + u8 talkState = Message_GetState(&play->msgCtx); - if ((temp_v0 == 6 || temp_v0 == 5) && Message_ShouldAdvance(globalCtx)) { + if (((talkState == TEXT_STATE_DONE) || (talkState == TEXT_STATE_5)) && Message_ShouldAdvance(play)) { if (this->unk_1EA & 0x20) { this->unk_1EA &= ~0x20; - globalCtx->msgCtx.msgMode = 0x43; - globalCtx->msgCtx.unk12023 = 4; + play->msgCtx.msgMode = 0x43; + play->msgCtx.stateTimer = 4; this->actionFunc = func_80AD14C8; } else { - func_80AD10FC(this, globalCtx); + func_80AD10FC(this, play); } } } -void EnOsn_Idle(EnOsn* this, GlobalContext* globalCtx) { +void EnOsn_Idle(EnOsn* this, PlayState* play) { } -void EnOsn_Init(Actor* thisx, GlobalContext* globalCtx) { +void EnOsn_Init(Actor* thisx, PlayState* play) { 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); + SkelAnime_InitFlex(play, &this->skelAnime, &object_osn_Skel_0202F0, &object_osn_Anim_0201BC, NULL, NULL, 0); + Collider_InitCylinder(play, &this->collider); + Collider_SetCylinder(play, &this->collider, &this->actor, &sCylinderInit); CollisionCheck_SetInfo2(&this->actor.colChkInfo, &sDamageTable, &sColChkInfoInit); 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)) { + if (((gSaveContext.save.entrance == ENTRANCE(CLOCK_TOWER_INTERIOR, 2)) || + (gSaveContext.save.entrance == ENTRANCE(CLOCK_TOWER_INTERIOR, 3))) || + (gSaveContext.save.entrance == ENTRANCE(CLOCK_TOWER_INTERIOR, 6))) { this->unk_1EA |= 1; } this->unk_1F0 = 1; - if (globalCtx->sceneNum == SCENE_INSIDETOWER) { - if ((gSaveContext.save.entranceIndex == 0xC020) || (gSaveContext.save.entranceIndex == 0xC060)) { + if (play->sceneNum == SCENE_INSIDETOWER) { + if ((gSaveContext.save.entrance == ENTRANCE(CLOCK_TOWER_INTERIOR, 2)) || + (gSaveContext.save.entrance == ENTRANCE(CLOCK_TOWER_INTERIOR, 6))) { this->actionFunc = func_80AD16A8; return; } - if (gSaveContext.save.entranceIndex == 0xC030) { + if (gSaveContext.save.entrance == ENTRANCE(CLOCK_TOWER_INTERIOR, 3)) { func_80AD1398(this); this->actionFunc = func_80AD1634; return; } - func_80AD144C(this, globalCtx); + func_80AD144C(this, play); return; } - func_80AD144C(this, globalCtx); + func_80AD144C(this, play); break; case 1: this->unk_1EC = 0xF; - Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, this->unk_1EC); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, this->unk_1EC); this->actionFunc = EnOsn_Idle; break; case 2: this->unk_1EC = 0x10; - Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, this->unk_1EC); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, this->unk_1EC); this->actionFunc = EnOsn_Idle; break; @@ -820,41 +834,41 @@ void EnOsn_Init(Actor* thisx, GlobalContext* globalCtx) { } } -void EnOsn_Destroy(Actor* thisx, GlobalContext* globalCtx) { +void EnOsn_Destroy(Actor* thisx, PlayState* play) { EnOsn* this = THIS; - SkelAnime_Free(&this->skelAnime, globalCtx); - Collider_DestroyCylinder(globalCtx, &this->collider); + SkelAnime_Free(&this->skelAnime, play); + Collider_DestroyCylinder(play, &this->collider); } -void EnOsn_Update(Actor* thisx, GlobalContext* globalCtx) { +void EnOsn_Update(Actor* thisx, PlayState* play) { s32 pad; EnOsn* this = THIS; u32 sp34; - sp34 = Flags_GetSwitch(globalCtx, 0); - this->actionFunc(this, globalCtx); + sp34 = Flags_GetSwitch(play, 0); + this->actionFunc(this, play); Actor_MoveWithGravity(&this->actor); SkelAnime_Update(&this->skelAnime); - if (!(ENOSN_GET_3(&this->actor))) { + if (!ENOSN_GET_3(&this->actor)) { if (sp34 != 0) { this->actor.flags |= ACTOR_FLAG_1; - func_80AD0830(this, globalCtx); + func_80AD0830(this, play); this->actor.draw = EnOsn_Draw; } else { this->actor.draw = NULL; this->actor.flags &= ~ACTOR_FLAG_1; } } - func_800E9250(globalCtx, &this->actor, &this->unk_1D8, &this->unk_1DE, this->actor.focus.pos); + Actor_TrackPlayer(play, &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, +s32 EnOsn_OverrideLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, Actor* thisx, Gfx** gfx) { EnOsn* this = (EnOsn*)thisx; if (this->unk_1F0 && limbIndex == 11) { - Matrix_InsertXRotation_s(this->unk_1D8.y, MTXMODE_APPLY); + Matrix_RotateXS(this->unk_1D8.y, MTXMODE_APPLY); } if ((this->unk_1EC == 9 || this->unk_1EC == 8) && limbIndex == 10) { *dList = NULL; @@ -862,28 +876,28 @@ s32 EnOsn_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, return false; } -void EnOsn_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx, Gfx** gfx) { +void EnOsn_PostLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx, Gfx** gfx) { EnOsn* this = (EnOsn*)thisx; Vec3f sp30 = { 0.0f, 0.0f, 0.0f }; Vec3s sp28 = { 0x9920, -0x384, -0x320 }; if (limbIndex == 11) { - Matrix_MultiplyVector3fByState(&sp30, &thisx->focus.pos); + Matrix_MultVec3f(&sp30, &thisx->focus.pos); } if (((this->unk_1EC == 17) || (this->unk_1EC == 21) || (this->unk_1EC == 22)) && (limbIndex == 6)) { - Matrix_StatePush(); - Matrix_InsertTranslation(-400.0f, 1100.0f, -200.0f, MTXMODE_APPLY); - Matrix_InsertXRotation_s(sp28.x, MTXMODE_APPLY); - Matrix_RotateY(sp28.y, MTXMODE_APPLY); - Matrix_InsertZRotation_s(sp28.z, MTXMODE_APPLY); + 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); + gSPMatrix((*gfx)++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList((*gfx)++, &object_osn_DL_0192A0); - Matrix_StatePop(); + Matrix_Pop(); } } -void EnOsn_Draw(Actor* thisx, GlobalContext* globalCtx) { +void EnOsn_Draw(Actor* thisx, PlayState* play) { static TexturePtr D_80AD2588 = object_osn_Tex_0166F8; static TexturePtr D_80AD258C = object_osn_Tex_016EF8; static TexturePtr D_80AD2590 = object_osn_Tex_0176F8; @@ -892,12 +906,12 @@ void EnOsn_Draw(Actor* thisx, GlobalContext* globalCtx) { s32 pad; EnOsn* this = THIS; - OPEN_DISPS(globalCtx->state.gfxCtx); + OPEN_DISPS(play->state.gfxCtx); if (this->unk_1FA == 0xFF) { - func_8012C28C(globalCtx->state.gfxCtx); + func_8012C28C(play->state.gfxCtx); if ((this->unk_1EC == 0xB) || (this->unk_1EC == 0xC) || (this->unk_1EC == 0x17) || - (globalCtx->msgCtx.currentTextId == 0x1FCA)) { + (play->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)) { @@ -908,20 +922,20 @@ void EnOsn_Draw(Actor* thisx, GlobalContext* globalCtx) { 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); + Scene_SetRenderModeXlu(play, 0, 1); + POLY_OPA_DISP = + SkelAnime_DrawFlex(play, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, + EnOsn_OverrideLimbDraw, EnOsn_PostLimbDraw, &this->actor, POLY_OPA_DISP); } else { - func_8012C2DC(globalCtx->state.gfxCtx); + func_8012C2DC(play->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); + Scene_SetRenderModeXlu(play, 1, 2); + POLY_XLU_DISP = + SkelAnime_DrawFlex(play, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, + EnOsn_OverrideLimbDraw, EnOsn_PostLimbDraw, &this->actor, POLY_XLU_DISP); - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->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 4cb99b925..fdc8ed2c7 100644 --- a/src/overlays/actors/ovl_En_Osn/z_en_osn.h +++ b/src/overlays/actors/ovl_En_Osn/z_en_osn.h @@ -5,25 +5,25 @@ struct EnOsn; -typedef void (*EnOsnActionFunc)(struct EnOsn*, GlobalContext*); +typedef void (*EnOsnActionFunc)(struct EnOsn*, PlayState*); typedef struct EnOsn { - /* 0x0000 */ Actor actor; - /* 0x0144 */ ColliderCylinder collider; - /* 0X0190 */ SkelAnime skelAnime; - /* 0x01D4 */ EnOsnActionFunc actionFunc; - /* 0x01D8 */ Vec3s unk_1D8; - /* 0x01DE */ Vec3s unk_1DE; - /* 0x01E4 */ UNK_TYPE1 unk_1E4[0x6]; - /* 0x01EA */ u16 unk_1EA; - /* 0x01EC */ u8 unk_1EC; - /* 0x01ED */ u8 unk_1ED; - /* 0x01EE */ s16 cutscene; - /* 0x01F0 */ u8 unk_1F0; - /* 0x01F1 */ UNK_TYPE1 unk_1F1[0x3]; - /* 0x01F4 */ u16 unk_1F4; - /* 0x01F6 */ s32 unk_1F6; - /* 0x01FA */ u8 unk_1FA; + /* 0x000 */ Actor actor; + /* 0x144 */ ColliderCylinder collider; + /* 0x190 */ SkelAnime skelAnime; + /* 0x1D4 */ EnOsnActionFunc actionFunc; + /* 0x1D8 */ Vec3s unk_1D8; + /* 0x1DE */ Vec3s unk_1DE; + /* 0x1E4 */ UNK_TYPE1 unk_1E4[0x6]; + /* 0x1EA */ u16 unk_1EA; + /* 0x1EC */ u8 unk_1EC; + /* 0x1ED */ u8 unk_1ED; + /* 0x1EE */ s16 cutscene; + /* 0x1F0 */ u8 unk_1F0; + /* 0x1F1 */ UNK_TYPE1 unk_1F1[0x3]; + /* 0x1F4 */ u16 unk_1F4; + /* 0x1F6 */ s32 unk_1F6; + /* 0x1FA */ u8 unk_1FA; } EnOsn; // size = 0x1FB extern const ActorInit En_Osn_InitVars; diff --git a/src/overlays/actors/ovl_En_Ossan/z_en_ossan.c b/src/overlays/actors/ovl_En_Ossan/z_en_ossan.c index 3464314b1..fc5a2a724 100644 --- a/src/overlays/actors/ovl_En_Ossan/z_en_ossan.c +++ b/src/overlays/actors/ovl_En_Ossan/z_en_ossan.c @@ -14,41 +14,41 @@ #define LOOKED_AT_PLAYER (1 << 0) #define END_INTERACTION (1 << 1) -void EnOssan_Init(Actor* thisx, GlobalContext* globalCtx); -void EnOssan_Destroy(Actor* thisx, GlobalContext* globalCtx); -void EnOssan_Update(Actor* thisx, GlobalContext* globalCtx); +void EnOssan_Init(Actor* thisx, PlayState* play); +void EnOssan_Destroy(Actor* thisx, PlayState* play); +void EnOssan_Update(Actor* thisx, PlayState* play); -void EnOssan_CuriosityShopMan_Draw(Actor* thisx, GlobalContext* globalCtx); -void EnOssan_PartTimeWorker_Draw(Actor* thisx, GlobalContext* globalCtx); +void EnOssan_CuriosityShopMan_Draw(Actor* thisx, PlayState* play); +void EnOssan_PartTimer_Draw(Actor* thisx, PlayState* play); -void EnOssan_CuriosityShopMan_Init(EnOssan* this, GlobalContext* globalCtx); -u16 EnOssan_CuriosityShopMan_GetWelcome(EnOssan* this, GlobalContext* globalCtx); +void EnOssan_CuriosityShopMan_Init(EnOssan* this, PlayState* play); +u16 EnOssan_CuriosityShopMan_GetWelcome(EnOssan* this, PlayState* play); -void EnOssan_PartTimeWorker_Init(EnOssan* this, GlobalContext* globalCtx); -u16 EnOssan_PartTimerWorker_GetWelcome(EnOssan* this, GlobalContext* globalCtx); +void EnOssan_PartTimer_Init(EnOssan* this, PlayState* play); +u16 EnOssan_PartTimer_GetWelcome(EnOssan* this, PlayState* play); -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); +void EnOssan_InitShop(EnOssan* this, PlayState* play); +void EnOssan_Idle(EnOssan* this, PlayState* play); +void EnOssan_BeginInteraction(EnOssan* this, PlayState* play); +void EnOssan_Hello(EnOssan* this, PlayState* play); void EnOssan_SetHaveMet(EnOssan* this); -void EnOssan_StartShopping(GlobalContext* globalCtx, EnOssan* this); -void EnOssan_FaceShopkeeper(EnOssan* this, GlobalContext* globalCtx); -void EnOssan_LookToShopkeeperFromShelf(EnOssan* this, GlobalContext* globalCtx); -void EnOssan_TalkToShopkeeper(EnOssan* this, GlobalContext* globalCtx); -void EnOssan_LookToLeftShelf(EnOssan* this, GlobalContext* globalCtx); -void EnOssan_LookToRightShelf(EnOssan* this, GlobalContext* globalCtx); -void EnOssan_BrowseLeftShelf(EnOssan* this, GlobalContext* globalCtx); -void EnOssan_BrowseRightShelf(EnOssan* this, GlobalContext* globalCtx); -void EnOssan_SelectItem(EnOssan* this, GlobalContext* globalCtx); -void EnOssan_BuyItemWithFanfare(EnOssan* this, GlobalContext* globalCtx); -void EnOssan_CannotBuy(EnOssan* this, GlobalContext* globalCtx); -void EnOssan_CanBuy(EnOssan* this, GlobalContext* globalCtx); -void EnOssan_SetupItemPurchased(EnOssan* this, GlobalContext* globalCtx); -void EnOssan_ItemPurchased(EnOssan* this, GlobalContext* globalCtx); +void EnOssan_StartShopping(PlayState* play, EnOssan* this); +void EnOssan_FaceShopkeeper(EnOssan* this, PlayState* play); +void EnOssan_LookToShopkeeperFromShelf(EnOssan* this, PlayState* play); +void EnOssan_TalkToShopkeeper(EnOssan* this, PlayState* play); +void EnOssan_LookToLeftShelf(EnOssan* this, PlayState* play); +void EnOssan_LookToRightShelf(EnOssan* this, PlayState* play); +void EnOssan_BrowseLeftShelf(EnOssan* this, PlayState* play); +void EnOssan_BrowseRightShelf(EnOssan* this, PlayState* play); +void EnOssan_SelectItem(EnOssan* this, PlayState* play); +void EnOssan_BuyItemWithFanfare(EnOssan* this, PlayState* play); +void EnOssan_CannotBuy(EnOssan* this, PlayState* play); +void EnOssan_CanBuy(EnOssan* this, PlayState* play); +void EnOssan_SetupItemPurchased(EnOssan* this, PlayState* play); +void EnOssan_ItemPurchased(EnOssan* this, PlayState* play); void EnOssan_ResetItemPosition(EnOssan* this); void EnOssan_Blink(EnOssan* this); -void EnOssan_GetCutscenes(EnOssan* this, GlobalContext* globalCtx); +void EnOssan_GetCutscenes(EnOssan* this, PlayState* play); s32 EnOssan_ReturnItemToShelf(EnOssan* this); s32 EnOssan_TakeItemOffShelf(EnOssan* this); @@ -60,36 +60,36 @@ typedef enum { } 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 + /* 0 */ FSN_ANIM_IDLE, + /* 1 */ FSN_ANIM_SCRATCH_BACK, + /* 2 */ FSN_ANIM_TURN_AROUND_FORWARD, + /* 3 */ FSN_ANIM_TURN_AROUND_REVERSE, + /* 4 */ FSN_ANIM_HANDS_ON_COUNTER_START, + /* 5 */ FSN_ANIM_HANDS_ON_COUNTER_LOOP, + /* 6 */ FSN_ANIM_HAND_ON_FACE_START, + /* 7 */ FSN_ANIM_HAND_ON_FACE_LOOP, + /* 8 */ FSN_ANIM_LEAN_FORWARD_START, + /* 9 */ FSN_ANIM_LEAN_FORWARD_LOOP, + /* 10 */ FSN_ANIM_SLAM_COUNTER_START, + /* 11 */ FSN_ANIM_SLAM_COUNTER_LOOP, + /* 12 */ FSN_ANIM_MAKE_OFFER, + /* 13 */ FSN_ANIM_MAX } FsnAnimation; 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 + /* 0 */ ANI_ANIM_STANDING_NORMAL_LOOP_1, + /* 1 */ ANI_ANIM_STANDING_NORMAL_LOOP_2, + /* 2 */ ANI_ANIM_STANDING_NORMAL_ONCE_FORWARD_1, + /* 3 */ ANI_ANIM_STANDING_NORMAL_ONCE_REVERSE, + /* 4 */ ANI_ANIM_STANDING_NORMAL_ONCE_FORWARD_2, + /* 5 */ ANI_ANIM_STANDING_NORMAL_LOOP_3, + /* 6 */ ANI_ANIM_STANDING_NORMAL_ONCE_FORWARD_3, + /* 7 */ ANI_ANIM_STANDING_NORMAL_LOOP_4, + /* 8 */ ANI_ANIM_APOLOGY_START, + /* 9 */ ANI_ANIM_APOLOGY_LOOP, + /* 10 */ ANI_ANIM_STANDING_NORMAL_ONCE_FORWARD_4, + /* 11 */ ANI_ANIM_STANDING_NORMAL_LOOP_5, + /* 12 */ ANI_ANIM_MAX } AniAnimation; const ActorInit En_Ossan_InitVars = { @@ -104,7 +104,7 @@ const ActorInit En_Ossan_InitVars = { (ActorFunc)NULL, }; -static AnimationInfoS sAnimationsCuriosityShopMan[] = { +static AnimationInfoS sCuriosityShopManAnimationInfo[] = { { &gFsnIdleAnim, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, { &gFsnScratchBackAnim, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, { &gFsnTurnAroundAnim, 1.0f, 0, -1, ANIMMODE_ONCE, 0 }, @@ -120,7 +120,7 @@ static AnimationInfoS sAnimationsCuriosityShopMan[] = { { &gFsnMakeOfferAnim, 1.0f, 0, -1, ANIMMODE_ONCE, 0 }, }; -static AnimationInfoS sAnimationsPartTimeWorker[] = { +static AnimationInfoS sPartTimerAnimationInfo[] = { { &gAniStandingNormalAnim, 1.0f, 0, -1, ANIMMODE_LOOP, -10 }, { &gAniStandingNormalAnim, 1.0f, 0, -1, ANIMMODE_LOOP, -10 }, { &gAniStandingNormalAnim, 1.0f, 0, -1, ANIMMODE_ONCE, 0 }, @@ -137,7 +137,7 @@ static AnimationInfoS sAnimationsPartTimeWorker[] = { static s16 sObjectIds[] = { OBJECT_FSN, OBJECT_ANI }; -static AnimationInfoS* sAnimations[] = { sAnimationsCuriosityShopMan, sAnimationsPartTimeWorker }; +static AnimationInfoS* sAnimationInfo[] = { sCuriosityShopManAnimationInfo, sPartTimerAnimationInfo }; static f32 sActorScales[] = { 0.01f, 0.01f }; @@ -161,31 +161,31 @@ static ShopItem sShops[][8] = { { SI_POTION_RED_3, { -80, 92, -195 } } }, }; -static u16 sWelcomeHumanTextIds[] = { 0X06A4, 0X06C1 }; +static u16 sWelcomeHumanTextIds[] = { 0x06A4, 0x06C1 }; -static u16 sTalkOptionTextIds[] = { 0X06AB, 0X06C8 }; +static u16 sTalkOptionTextIds[] = { 0x06AB, 0x06C8 }; -static u16 sWelcomeGoronFirstTimeTextIds[] = { 0X06A5, 0X06C2 }; +static u16 sWelcomeGoronFirstTimeTextIds[] = { 0x06A5, 0x06C2 }; -static u16 sWelcomeZoraFirstTimeTextIds[] = { 0X06A7, 0X06C4 }; +static u16 sWelcomeZoraFirstTimeTextIds[] = { 0x06A7, 0x06C4 }; -static u16 sWelcomeDekuFirstTimeTextIds[] = { 0X06A9, 0X06C6 }; +static u16 sWelcomeDekuFirstTimeTextIds[] = { 0x06A9, 0x06C6 }; -static u16 sWelcomeGoronTextIds[] = { 0X06A6, 0X06C3 }; +static u16 sWelcomeGoronTextIds[] = { 0x06A6, 0x06C3 }; -static u16 sWelcomeZoraTextIds[] = { 0X06A8, 0X06C5 }; +static u16 sWelcomeZoraTextIds[] = { 0x06A8, 0x06C5 }; -static u16 sWelcomeDekuTextIds[] = { 0X06AA, 0X06C7 }; +static u16 sWelcomeDekuTextIds[] = { 0x06AA, 0x06C7 }; -static u16 sNeedEmptyBottleTextIds[] = { 0X06BC, 0X06D9 }; +static u16 sNeedEmptyBottleTextIds[] = { 0x06BC, 0x06D9 }; -static u16 sNeedRupeesTextIds[] = { 0X06BD, 0X06DA }; +static u16 sNeedRupeesTextIds[] = { 0x06BD, 0x06DA }; -static u16 sNoRoomTextIds[] = { 0X06BE, 0X06DB }; +static u16 sNoRoomTextIds[] = { 0x06BE, 0x06DB }; -static u16 sBuySuccessTextIds[] = { 0X06BF, 0X06DC }; +static u16 sBuySuccessTextIds[] = { 0x06BF, 0x06DC }; -static u16 sCannotGetNowTextIds[] = { 0X06C0, 0X06DD }; +static u16 sCannotGetNowTextIds[] = { 0x06C0, 0x06DD }; static InitChainEntry sInitChain[] = { ICHAIN_F32(targetArrowOffset, 500, ICHAIN_STOP), @@ -195,15 +195,15 @@ void EnOssan_SetupAction(EnOssan* this, EnOssanActionFunc action) { this->actionFunc = action; } -s32 EnOssan_TestItemSelected(GlobalContext* globalCtx) { - MessageContext* msgCtx = &globalCtx->msgCtx; +s32 EnOssan_TestItemSelected(PlayState* play) { + MessageContext* msgCtx = &play->msgCtx; if (msgCtx->unk12020 == 0x10 || msgCtx->unk12020 == 0x11) { - return CHECK_BTN_ALL(CONTROLLER1(globalCtx)->press.button, BTN_A); + return CHECK_BTN_ALL(CONTROLLER1(&play->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(&play->state)->press.button, BTN_A) || + CHECK_BTN_ALL(CONTROLLER1(&play->state)->press.button, BTN_B) || + CHECK_BTN_ALL(CONTROLLER1(&play->state)->press.button, BTN_CUP); } void EnOssan_CheckValidSpawn(EnOssan* this) { @@ -231,37 +231,37 @@ void EnOssan_CheckValidSpawn(EnOssan* this) { } } -void EnOssan_RotateHead(EnOssan* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); +void EnOssan_RotateHead(EnOssan* this, PlayState* play) { + Player* player = GET_PLAYER(play); if (this->actor.params == ENOSSAN_PART_TIME_WORKER) { if (player->transformation == PLAYER_FORM_ZORA) { - Math_SmoothStepToS(&this->headRotPartTimeWorker.y, this->headRot.y, 3, 2000, 0); + Math_SmoothStepToS(&this->partTimerHeadRot.y, this->headRot.y, 3, 2000, 0); } else if (this->flags & LOOKED_AT_PLAYER) { - Math_SmoothStepToS(&this->headRotPartTimeWorker.y, 8000, 3, 2000, 0); + Math_SmoothStepToS(&this->partTimerHeadRot.y, 8000, 3, 2000, 0); } else { - Math_SmoothStepToS(&this->headRotPartTimeWorker.y, this->headRot.y, 3, 2000, 0); - if (ABS_ALT(this->headRotPartTimeWorker.y - this->headRot.y) < 16) { + Math_SmoothStepToS(&this->partTimerHeadRot.y, this->headRot.y, 3, 2000, 0); + if (ABS_ALT(this->partTimerHeadRot.y - this->headRot.y) < 16) { this->flags |= LOOKED_AT_PLAYER; } } } } -void EnOssan_SpawnShopItems(EnOssan* this, GlobalContext* globalCtx, ShopItem* shop) { +void EnOssan_SpawnShopItems(EnOssan* this, PlayState* play, ShopItem* shop) { s32 i; for (i = 0; i < ARRAY_COUNT(this->items); i++, shop++) { if (shop->shopItemId < 0) { this->items[i] = NULL; } else { - this->items[i] = (EnGirlA*)Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_GIRLA, shop->spawnPos.x, + this->items[i] = (EnGirlA*)Actor_Spawn(&play->actorCtx, play, ACTOR_EN_GIRLA, shop->spawnPos.x, shop->spawnPos.y, shop->spawnPos.z, 0, 0, 0, shop->shopItemId); } } } -void EnOssan_Init(Actor* thisx, GlobalContext* globalCtx) { +void EnOssan_Init(Actor* thisx, PlayState* play) { EnOssan* this = THIS; s16 id; @@ -271,7 +271,7 @@ void EnOssan_Init(Actor* thisx, GlobalContext* globalCtx) { return; } id = sObjectIds[this->actor.params]; - this->objIndex = Object_GetIndex(&globalCtx->objectCtx, id); + this->objIndex = Object_GetIndex(&play->objectCtx, id); if (this->objIndex < 0) { Actor_MarkForDeath(&this->actor); return; @@ -281,34 +281,34 @@ void EnOssan_Init(Actor* thisx, GlobalContext* globalCtx) { EnOssan_SetupAction(this, EnOssan_InitShop); } -void EnOssan_Destroy(Actor* thisx, GlobalContext* globalCtx) { +void EnOssan_Destroy(Actor* thisx, PlayState* play) { EnOssan* this = THIS; - Collider_DestroyCylinder(globalCtx, &this->collider); + Collider_DestroyCylinder(play, &this->collider); } -void EnOssan_UpdateCursorPos(GlobalContext* globalCtx, EnOssan* this) { +void EnOssan_UpdateCursorPos(PlayState* play, EnOssan* this) { s16 x; s16 y; - Actor_GetScreenPos(globalCtx, &this->items[this->cursorIdx]->actor, &x, &y); + Actor_GetScreenPos(play, &this->items[this->cursorIdx]->actor, &x, &y); this->cursorPos.x = x; this->cursorPos.y = y; } -void EnOssan_EndInteraction(GlobalContext* globalCtx, EnOssan* this) { - Player* player = GET_PLAYER(globalCtx); +void EnOssan_EndInteraction(PlayState* play, EnOssan* this) { + Player* player = GET_PLAYER(play); - Actor_ProcessTalkRequest(&this->actor, &globalCtx->state); - globalCtx->msgCtx.msgMode = 0x43; - globalCtx->msgCtx.unk12023 = 4; + Actor_ProcessTalkRequest(&this->actor, &play->state); + play->msgCtx.msgMode = 0x43; + play->msgCtx.stateTimer = 4; Interface_ChangeAlpha(50); this->drawCursor = 0; this->stickLeftPrompt.isEnabled = false; this->stickRightPrompt.isEnabled = false; player->stateFlags2 &= ~0x20000000; - globalCtx->interfaceCtx.unk_222 = 0; - globalCtx->interfaceCtx.unk_224 = 0; + play->interfaceCtx.unk_222 = 0; + play->interfaceCtx.unk_224 = 0; if (this->cutsceneState == ENOSSAN_CUTSCENESTATE_PLAYING) { ActorCutscene_Stop(this->cutscene); this->cutsceneState = ENOSSAN_CUTSCENESTATE_STOPPED; @@ -321,51 +321,51 @@ void EnOssan_EndInteraction(GlobalContext* globalCtx, EnOssan* this) { } } -s32 EnOssan_TestEndInteraction(EnOssan* this, GlobalContext* globalCtx, Input* input) { +s32 EnOssan_TestEndInteraction(EnOssan* this, PlayState* play, Input* input) { if (CHECK_BTN_ALL(input->press.button, BTN_B)) { - EnOssan_EndInteraction(globalCtx, this); + EnOssan_EndInteraction(play, this); return true; } return false; } -s32 EnOssan_TestCancelOption(EnOssan* this, GlobalContext* globalCtx, Input* input) { +s32 EnOssan_TestCancelOption(EnOssan* this, PlayState* play, Input* input) { if (CHECK_BTN_ALL(input->press.button, BTN_B)) { - this->actionFunc = this->tmpActionFunc; - func_80151938(globalCtx, this->items[this->cursorIdx]->actor.textId); + this->actionFunc = this->prevActionFunc; + func_80151938(play, this->items[this->cursorIdx]->actor.textId); return true; } return false; } -void EnOssan_SetupStartShopping(GlobalContext* globalCtx, EnOssan* this, u8 skipHello) { - func_8011552C(globalCtx, 0x10); +void EnOssan_SetupStartShopping(PlayState* play, EnOssan* this, u8 skipHello) { + func_8011552C(play, 0x10); if (!skipHello) { EnOssan_SetupAction(this, EnOssan_Hello); } else { - EnOssan_StartShopping(globalCtx, this); + EnOssan_StartShopping(play, this); } } -void EnOssan_StartShopping(GlobalContext* globalCtx, EnOssan* this) { +void EnOssan_StartShopping(PlayState* play, EnOssan* this) { EnOssan_SetupAction(this, EnOssan_FaceShopkeeper); - func_80151938(globalCtx, 0x640); - func_8011552C(globalCtx, 6); + func_80151938(play, 0x640); + func_8011552C(play, 6); this->stickRightPrompt.isEnabled = true; this->stickLeftPrompt.isEnabled = true; } -void EnOssan_SetupLookToShopkeeperFromShelf(GlobalContext* globalCtx, EnOssan* this) { +void EnOssan_SetupLookToShopkeeperFromShelf(PlayState* play, EnOssan* this) { play_sound(NA_SE_SY_CURSOR); this->drawCursor = 0; EnOssan_SetupAction(this, EnOssan_LookToShopkeeperFromShelf); } -void EnOssan_Idle(EnOssan* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); +void EnOssan_Idle(EnOssan* this, PlayState* play) { + Player* player = GET_PLAYER(play); - SubS_FillLimbRotTables(globalCtx, this->limbRotTableY, this->limbRotTableZ, ARRAY_COUNT(this->limbRotTableY)); - if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { + SubS_FillLimbRotTables(play, this->limbRotTableY, this->limbRotTableZ, ARRAY_COUNT(this->limbRotTableY)); + if (Actor_ProcessTalkRequest(&this->actor, &play->state)) { player->stateFlags2 |= 0x20000000; EnOssan_SetupAction(this, EnOssan_BeginInteraction); if (this->cutsceneState == ENOSSAN_CUTSCENESTATE_STOPPED) { @@ -380,20 +380,20 @@ void EnOssan_Idle(EnOssan* this, GlobalContext* globalCtx) { if (this->actor.xzDistToPlayer < 100.0f && (player->actor.world.pos.x >= -40.0f && player->actor.world.pos.x <= 40.0f) && (player->actor.world.pos.z >= -91.0f && player->actor.world.pos.z <= -60.0f)) { - func_800B8614(&this->actor, globalCtx, 100.0f); + func_800B8614(&this->actor, play, 100.0f); } if (this->actor.params == ENOSSAN_PART_TIME_WORKER) { - Math_SmoothStepToS(&this->headRotPartTimeWorker.y, 8000, 3, 2000, 0); + Math_SmoothStepToS(&this->partTimerHeadRot.y, 8000, 3, 2000, 0); } } } -void EnOssan_BeginInteraction(EnOssan* this, GlobalContext* globalCtx) { - AnimationInfoS* animations = sAnimations[this->actor.params]; +void EnOssan_BeginInteraction(EnOssan* this, PlayState* play) { + AnimationInfoS* animationInfo = sAnimationInfo[this->actor.params]; s16 curFrame = this->skelAnime.curFrame; - s16 frameCount = Animation_GetLastFrame(animations[this->animationIndex].animation); + s16 frameCount = Animation_GetLastFrame(animationInfo[this->animIndex].animation); - if (this->animationIndex == FSN_ANIMATION_TURN_AROUND_REVERSE) { + if (this->animIndex == FSN_ANIM_TURN_AROUND_REVERSE) { frameCount = 0; } if (this->cutsceneState == ENOSSAN_CUTSCENESTATE_WAITING) { @@ -406,55 +406,55 @@ void EnOssan_BeginInteraction(EnOssan* this, GlobalContext* globalCtx) { } if (this->actor.params == ENOSSAN_CURIOSITY_SHOP_MAN) { if (curFrame == frameCount) { - 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); + switch (this->animIndex) { + case FSN_ANIM_SCRATCH_BACK: + this->animIndex = FSN_ANIM_TURN_AROUND_FORWARD; + SubS_ChangeAnimationByInfoS(&this->skelAnime, animationInfo, FSN_ANIM_TURN_AROUND_FORWARD); break; - case FSN_ANIMATION_TURN_AROUND_FORWARD: + case FSN_ANIM_TURN_AROUND_FORWARD: EnOssan_SetHaveMet(this); - this->textId = EnOssan_CuriosityShopMan_GetWelcome(this, globalCtx); - SubS_ChangeAnimationByInfoS(&this->skelAnime, animations, this->animationIndex); + this->textId = EnOssan_CuriosityShopMan_GetWelcome(this, play); + SubS_ChangeAnimationByInfoS(&this->skelAnime, animationInfo, this->animIndex); break; - 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); + case FSN_ANIM_HANDS_ON_COUNTER_START: + case FSN_ANIM_HAND_ON_FACE_START: + case FSN_ANIM_LEAN_FORWARD_START: + case FSN_ANIM_SLAM_COUNTER_START: + this->animIndex++; + SubS_ChangeAnimationByInfoS(&this->skelAnime, animationInfo, this->animIndex); + Message_StartTextbox(play, this->textId, &this->actor); + EnOssan_SetupStartShopping(play, this, false); break; - 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); + case FSN_ANIM_HANDS_ON_COUNTER_LOOP: + case FSN_ANIM_HAND_ON_FACE_LOOP: + case FSN_ANIM_LEAN_FORWARD_LOOP: + case FSN_ANIM_SLAM_COUNTER_LOOP: + this->animIndex = FSN_ANIM_TURN_AROUND_REVERSE; + SubS_ChangeAnimationByInfoS(&this->skelAnime, animationInfo, FSN_ANIM_TURN_AROUND_REVERSE); break; - case FSN_ANIMATION_TURN_AROUND_REVERSE: - this->animationIndex = FSN_ANIMATION_SCRATCH_BACK; - SubS_ChangeAnimationByInfoS(&this->skelAnime, animations, FSN_ANIMATION_SCRATCH_BACK); + case FSN_ANIM_TURN_AROUND_REVERSE: + this->animIndex = FSN_ANIM_SCRATCH_BACK; + SubS_ChangeAnimationByInfoS(&this->skelAnime, animationInfo, FSN_ANIM_SCRATCH_BACK); EnOssan_SetupAction(this, EnOssan_Idle); break; default: - this->animationIndex = FSN_ANIMATION_SCRATCH_BACK; - SubS_ChangeAnimationByInfoS(&this->skelAnime, animations, FSN_ANIMATION_SCRATCH_BACK); + this->animIndex = FSN_ANIM_SCRATCH_BACK; + SubS_ChangeAnimationByInfoS(&this->skelAnime, animationInfo, FSN_ANIM_SCRATCH_BACK); EnOssan_SetupAction(this, EnOssan_Idle); break; } } } else { EnOssan_SetHaveMet(this); - this->textId = EnOssan_PartTimerWorker_GetWelcome(this, globalCtx); - Message_StartTextbox(globalCtx, this->textId, &this->actor); - EnOssan_SetupStartShopping(globalCtx, this, false); + this->textId = EnOssan_PartTimer_GetWelcome(this, play); + Message_StartTextbox(play, this->textId, &this->actor); + EnOssan_SetupStartShopping(play, this, false); } } -void EnOssan_UpdateJoystickInputState(GlobalContext* globalCtx, EnOssan* this) { - s8 stickX = CONTROLLER1(globalCtx)->rel.stick_x; - s8 stickY = CONTROLLER1(globalCtx)->rel.stick_y; +void EnOssan_UpdateJoystickInputState(PlayState* play, EnOssan* this) { + s8 stickX = CONTROLLER1(&play->state)->rel.stick_x; + s8 stickY = CONTROLLER1(&play->state)->rel.stick_y; this->moveHorizontal = this->moveVertical = false; @@ -556,69 +556,69 @@ u8 EnOssan_CursorLeft(EnOssan* this, u8 cursorIdx, u8 shelfSlotMax) { return CURSOR_INVALID; } -void EnOssan_Hello(EnOssan* this, GlobalContext* globalCtx) { - AnimationInfoS* animations = sAnimations[this->actor.params]; - u8 talkState = Message_GetState(&globalCtx->msgCtx); +void EnOssan_Hello(EnOssan* this, PlayState* play) { + AnimationInfoS* animationInfo = sAnimationInfo[this->actor.params]; + u8 talkState = Message_GetState(&play->msgCtx); s32 pad; - Player* player = GET_PLAYER(globalCtx); + Player* player = GET_PLAYER(play); - EnOssan_RotateHead(this, globalCtx); - 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); + EnOssan_RotateHead(this, play); + if ((talkState == TEXT_STATE_5) && Message_ShouldAdvance(play)) { + if ((this->animIndex == ANI_ANIM_APOLOGY_LOOP) && (this->actor.params == ENOSSAN_PART_TIME_WORKER)) { + this->animIndex = ANI_ANIM_STANDING_NORMAL_LOOP_2; + SubS_ChangeAnimationByInfoS(&this->skelAnime, animationInfo, 1); } this->flags &= ~LOOKED_AT_PLAYER; if (player->transformation == PLAYER_FORM_DEKU) { - EnOssan_EndInteraction(globalCtx, this); + EnOssan_EndInteraction(play, this); } else if (this->flags & END_INTERACTION) { this->flags &= ~END_INTERACTION; - EnOssan_EndInteraction(globalCtx, this); - } else if (!EnOssan_TestEndInteraction(this, globalCtx, CONTROLLER1(globalCtx))) { - EnOssan_StartShopping(globalCtx, this); + EnOssan_EndInteraction(play, this); + } else if (!EnOssan_TestEndInteraction(this, play, CONTROLLER1(&play->state))) { + EnOssan_StartShopping(play, this); } else { return; } } - 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 ((talkState == TEXT_STATE_10) && (this->actor.params == ENOSSAN_PART_TIME_WORKER) && + (player->transformation == PLAYER_FORM_ZORA) && Message_ShouldAdvance(play)) { + this->animIndex = ANI_ANIM_APOLOGY_LOOP; + SubS_ChangeAnimationByInfoS(&this->skelAnime, animationInfo, ANI_ANIM_APOLOGY_LOOP); } - if ((this->animationIndex == FSN_ANIMATION_SLAM_COUNTER_LOOP) && Animation_OnFrame(&this->skelAnime, 18.0f)) { + if ((this->animIndex == FSN_ANIM_SLAM_COUNTER_LOOP) && Animation_OnFrame(&this->skelAnime, 18.0f)) { Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_HANKO); } } -s32 EnOssan_FacingShopkeeperDialogResult(EnOssan* this, GlobalContext* globalCtx) { - AnimationInfoS* animations = sAnimations[this->actor.params]; - Player* player = GET_PLAYER(globalCtx); +s32 EnOssan_FacingShopkeeperDialogResult(EnOssan* this, PlayState* play) { + AnimationInfoS* animationInfo = sAnimationInfo[this->actor.params]; + Player* player = GET_PLAYER(play); - switch (globalCtx->msgCtx.choiceIndex) { + switch (play->msgCtx.choiceIndex) { case 0: func_8019F208(); 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); + this->animIndex = ANI_ANIM_APOLOGY_LOOP; + SubS_ChangeAnimationByInfoS(&this->skelAnime, animationInfo, 9); } EnOssan_SetupAction(this, EnOssan_TalkToShopkeeper); - func_80151938(globalCtx, sTalkOptionTextIds[this->actor.params]); - func_8011552C(globalCtx, 6); + func_80151938(play, sTalkOptionTextIds[this->actor.params]); + func_8011552C(play, 6); this->stickLeftPrompt.isEnabled = false; this->stickRightPrompt.isEnabled = false; return true; case 1: func_8019F230(); - EnOssan_EndInteraction(globalCtx, this); + EnOssan_EndInteraction(play, this); return true; } return false; } -void EnOssan_FaceShopkeeper(EnOssan* this, GlobalContext* globalCtx) { - u8 talkState = Message_GetState(&globalCtx->msgCtx); +void EnOssan_FaceShopkeeper(EnOssan* this, PlayState* play) { + u8 talkState = Message_GetState(&play->msgCtx); s32 pad; - Player* player = GET_PLAYER(globalCtx); + Player* player = GET_PLAYER(play); u8 cursorIdx; if (this->cutsceneState == ENOSSAN_CUTSCENESTATE_STOPPED) { @@ -629,16 +629,16 @@ void EnOssan_FaceShopkeeper(EnOssan* this, GlobalContext* globalCtx) { ActorCutscene_SetIntentToPlay(this->cutscene); this->cutsceneState = ENOSSAN_CUTSCENESTATE_WAITING; } else { - if (talkState == 4) { - func_8011552C(globalCtx, 6); - if (!EnOssan_TestEndInteraction(this, globalCtx, CONTROLLER1(globalCtx)) && - (!Message_ShouldAdvance(globalCtx) || !EnOssan_FacingShopkeeperDialogResult(this, globalCtx))) { + if (talkState == TEXT_STATE_CHOICE) { + func_8011552C(play, 6); + if (!EnOssan_TestEndInteraction(this, play, CONTROLLER1(&play->state)) && + (!Message_ShouldAdvance(play) || !EnOssan_FacingShopkeeperDialogResult(this, play))) { if (this->stickAccumX < 0) { cursorIdx = EnOssan_SetCursorIndexFromNeutral(this, 4); if (cursorIdx != CURSOR_INVALID) { this->cursorIdx = cursorIdx; EnOssan_SetupAction(this, EnOssan_LookToLeftShelf); - func_8011552C(globalCtx, 6); + func_8011552C(play, 6); this->stickLeftPrompt.isEnabled = false; play_sound(NA_SE_SY_CURSOR); } @@ -647,7 +647,7 @@ void EnOssan_FaceShopkeeper(EnOssan* this, GlobalContext* globalCtx) { if (cursorIdx != CURSOR_INVALID) { this->cursorIdx = cursorIdx; EnOssan_SetupAction(this, EnOssan_LookToRightShelf); - func_8011552C(globalCtx, 6); + func_8011552C(play, 6); this->stickRightPrompt.isEnabled = false; play_sound(NA_SE_SY_CURSOR); } @@ -657,24 +657,24 @@ void EnOssan_FaceShopkeeper(EnOssan* this, GlobalContext* globalCtx) { } } if (this->actor.params == ENOSSAN_PART_TIME_WORKER && player->transformation != PLAYER_FORM_ZORA) { - Math_SmoothStepToS(&this->headRotPartTimeWorker.y, 8000, 3, 2000, 0); + Math_SmoothStepToS(&this->partTimerHeadRot.y, 8000, 3, 2000, 0); } } } -void EnOssan_TalkToShopkeeper(EnOssan* this, GlobalContext* globalCtx) { - AnimationInfoS* animations = sAnimations[this->actor.params]; +void EnOssan_TalkToShopkeeper(EnOssan* this, PlayState* play) { + AnimationInfoS* animationInfo = sAnimationInfo[this->actor.params]; - 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); + if ((Message_GetState(&play->msgCtx) == TEXT_STATE_5) && Message_ShouldAdvance(play)) { + if ((this->animIndex == ANI_ANIM_APOLOGY_LOOP) && (this->actor.params == ENOSSAN_PART_TIME_WORKER)) { + this->animIndex = ANI_ANIM_STANDING_NORMAL_LOOP_2; + SubS_ChangeAnimationByInfoS(&this->skelAnime, animationInfo, 1); } - EnOssan_StartShopping(globalCtx, this); + EnOssan_StartShopping(play, this); } } -void EnOssan_LookToLeftShelf(EnOssan* this, GlobalContext* globalCtx) { +void EnOssan_LookToLeftShelf(EnOssan* this, PlayState* play) { if (this->cutsceneState == ENOSSAN_CUTSCENESTATE_PLAYING) { ActorCutscene_Stop(this->cutscene); this->cutsceneState = ENOSSAN_CUTSCENESTATE_STOPPED; @@ -691,9 +691,9 @@ void EnOssan_LookToLeftShelf(EnOssan* this, GlobalContext* globalCtx) { if (ActorCutscene_GetCanPlayNext(this->cutscene)) { ActorCutscene_StartAndSetFlag(this->cutscene, &this->actor); this->cutsceneState = ENOSSAN_CUTSCENESTATE_PLAYING; - EnOssan_UpdateCursorPos(globalCtx, this); + EnOssan_UpdateCursorPos(play, this); EnOssan_SetupAction(this, EnOssan_BrowseLeftShelf); - func_80151938(globalCtx, this->items[this->cursorIdx]->actor.textId); + func_80151938(play, this->items[this->cursorIdx]->actor.textId); } else { ActorCutscene_SetIntentToPlay(this->cutscene); } @@ -702,7 +702,7 @@ void EnOssan_LookToLeftShelf(EnOssan* this, GlobalContext* globalCtx) { } } -void EnOssan_LookToRightShelf(EnOssan* this, GlobalContext* globalCtx) { +void EnOssan_LookToRightShelf(EnOssan* this, PlayState* play) { if (this->cutsceneState == ENOSSAN_CUTSCENESTATE_PLAYING) { ActorCutscene_Stop(this->cutscene); this->cutsceneState = ENOSSAN_CUTSCENESTATE_STOPPED; @@ -719,9 +719,9 @@ void EnOssan_LookToRightShelf(EnOssan* this, GlobalContext* globalCtx) { if (ActorCutscene_GetCanPlayNext(this->cutscene)) { ActorCutscene_StartAndSetFlag(this->cutscene, &this->actor); this->cutsceneState = ENOSSAN_CUTSCENESTATE_PLAYING; - EnOssan_UpdateCursorPos(globalCtx, this); + EnOssan_UpdateCursorPos(play, this); EnOssan_SetupAction(this, EnOssan_BrowseRightShelf); - func_80151938(globalCtx, this->items[this->cursorIdx]->actor.textId); + func_80151938(play, this->items[this->cursorIdx]->actor.textId); } else { ActorCutscene_SetIntentToPlay(this->cutscene); } @@ -815,16 +815,16 @@ void EnOssan_CursorUpDown(EnOssan* this) { } } -s32 EnOssan_HasPlayerSelectedItem(GlobalContext* globalCtx, EnOssan* this, Input* input) { +s32 EnOssan_HasPlayerSelectedItem(PlayState* play, EnOssan* this, Input* input) { EnGirlA* item = this->items[this->cursorIdx]; - if (EnOssan_TestEndInteraction(this, globalCtx, input)) { + if (EnOssan_TestEndInteraction(this, play, input)) { return true; } - if (EnOssan_TestItemSelected(globalCtx)) { + if (EnOssan_TestItemSelected(play)) { if (!item->isOutOfStock) { - this->tmpActionFunc = this->actionFunc; - func_80151938(globalCtx, this->items[this->cursorIdx]->choiceTextId); + this->prevActionFunc = this->actionFunc; + func_80151938(play, this->items[this->cursorIdx]->choiceTextId); this->stickLeftPrompt.isEnabled = false; this->stickRightPrompt.isEnabled = false; play_sound(NA_SE_SY_DECIDE); @@ -838,8 +838,8 @@ s32 EnOssan_HasPlayerSelectedItem(GlobalContext* globalCtx, EnOssan* this, Input return false; } -void EnOssan_BrowseLeftShelf(EnOssan* this, GlobalContext* globalCtx) { - u8 talkState = Message_GetState(&globalCtx->msgCtx); +void EnOssan_BrowseLeftShelf(EnOssan* this, PlayState* play) { + u8 talkState = Message_GetState(&play->msgCtx); s32 pad; u8 prevCursorIndex = this->cursorIdx; u8 cursorIdx; @@ -851,17 +851,17 @@ void EnOssan_BrowseLeftShelf(EnOssan* this, GlobalContext* globalCtx) { } else { this->drawCursor = 0xFF; this->stickRightPrompt.isEnabled = true; - EnOssan_UpdateCursorPos(globalCtx, this); - if (talkState == 5) { - func_8011552C(globalCtx, 6); - if (!EnOssan_HasPlayerSelectedItem(globalCtx, this, CONTROLLER1(globalCtx))) { + EnOssan_UpdateCursorPos(play, this); + if (talkState == TEXT_STATE_5) { + func_8011552C(play, 6); + if (!EnOssan_HasPlayerSelectedItem(play, this, CONTROLLER1(&play->state))) { if (this->moveHorizontal) { if (this->stickAccumX > 0) { cursorIdx = EnOssan_CursorRight(this, this->cursorIdx, 4); if (cursorIdx != CURSOR_INVALID) { this->cursorIdx = cursorIdx; } else { - EnOssan_SetupLookToShopkeeperFromShelf(globalCtx, this); + EnOssan_SetupLookToShopkeeperFromShelf(play, this); return; } } else if (this->stickAccumX < 0) { @@ -876,7 +876,7 @@ void EnOssan_BrowseLeftShelf(EnOssan* this, GlobalContext* globalCtx) { if (cursorIdx != CURSOR_INVALID) { this->cursorIdx = cursorIdx; } else { - EnOssan_SetupLookToShopkeeperFromShelf(globalCtx, this); + EnOssan_SetupLookToShopkeeperFromShelf(play, this); return; } } else if (this->stickAccumX < 0 && this->stickAccumX < -500) { @@ -888,7 +888,7 @@ void EnOssan_BrowseLeftShelf(EnOssan* this, GlobalContext* globalCtx) { } EnOssan_CursorUpDown(this); if (this->cursorIdx != prevCursorIndex) { - func_80151938(globalCtx, this->items[this->cursorIdx]->actor.textId); + func_80151938(play, this->items[this->cursorIdx]->actor.textId); play_sound(NA_SE_SY_CURSOR); } } @@ -896,8 +896,8 @@ void EnOssan_BrowseLeftShelf(EnOssan* this, GlobalContext* globalCtx) { } } -void EnOssan_BrowseRightShelf(EnOssan* this, GlobalContext* globalCtx) { - u8 talkState = Message_GetState(&globalCtx->msgCtx); +void EnOssan_BrowseRightShelf(EnOssan* this, PlayState* play) { + u8 talkState = Message_GetState(&play->msgCtx); s32 pad; u8 prevCursorIndex = this->cursorIdx; u8 cursorIdx; @@ -909,17 +909,17 @@ void EnOssan_BrowseRightShelf(EnOssan* this, GlobalContext* globalCtx) { } else { this->drawCursor = 0xFF; this->stickLeftPrompt.isEnabled = true; - EnOssan_UpdateCursorPos(globalCtx, this); - if (talkState == 5) { - func_8011552C(globalCtx, 6); - if (!EnOssan_HasPlayerSelectedItem(globalCtx, this, CONTROLLER1(globalCtx))) { + EnOssan_UpdateCursorPos(play, this); + if (talkState == TEXT_STATE_5) { + func_8011552C(play, 6); + if (!EnOssan_HasPlayerSelectedItem(play, this, CONTROLLER1(&play->state))) { if (this->moveHorizontal != 0) { if (this->stickAccumX < 0) { cursorIdx = EnOssan_CursorRight(this, this->cursorIdx, 0); if (cursorIdx != CURSOR_INVALID) { this->cursorIdx = cursorIdx; } else { - EnOssan_SetupLookToShopkeeperFromShelf(globalCtx, this); + EnOssan_SetupLookToShopkeeperFromShelf(play, this); return; } } else if (this->stickAccumX > 0) { @@ -934,7 +934,7 @@ void EnOssan_BrowseRightShelf(EnOssan* this, GlobalContext* globalCtx) { if (cursorIdx != CURSOR_INVALID) { this->cursorIdx = cursorIdx; } else { - EnOssan_SetupLookToShopkeeperFromShelf(globalCtx, this); + EnOssan_SetupLookToShopkeeperFromShelf(play, this); return; } } else if (this->stickAccumX > 0 && this->stickAccumX > 500) { @@ -946,7 +946,7 @@ void EnOssan_BrowseRightShelf(EnOssan* this, GlobalContext* globalCtx) { } EnOssan_CursorUpDown(this); if (this->cursorIdx != prevCursorIndex) { - func_80151938(globalCtx, this->items[this->cursorIdx]->actor.textId); + func_80151938(play, this->items[this->cursorIdx]->actor.textId); play_sound(NA_SE_SY_CURSOR); } } @@ -954,7 +954,7 @@ void EnOssan_BrowseRightShelf(EnOssan* this, GlobalContext* globalCtx) { } } -void EnOssan_LookToShopkeeperFromShelf(EnOssan* this, GlobalContext* globalCtx) { +void EnOssan_LookToShopkeeperFromShelf(EnOssan* this, PlayState* play) { if (this->cutsceneState == ENOSSAN_CUTSCENESTATE_PLAYING) { ActorCutscene_Stop(this->cutscene); this->cutsceneState = ENOSSAN_CUTSCENESTATE_STOPPED; @@ -970,137 +970,137 @@ void EnOssan_LookToShopkeeperFromShelf(EnOssan* this, GlobalContext* globalCtx) if (ActorCutscene_GetCanPlayNext(this->cutscene)) { ActorCutscene_StartAndSetFlag(this->cutscene, &this->actor); this->cutsceneState = ENOSSAN_CUTSCENESTATE_PLAYING; - EnOssan_UpdateCursorPos(globalCtx, this); - EnOssan_StartShopping(globalCtx, this); + EnOssan_UpdateCursorPos(play, this); + EnOssan_StartShopping(play, this); } else { ActorCutscene_SetIntentToPlay(this->cutscene); } } } -void EnOssan_SetupBuyItemWithFanfare(GlobalContext* globalCtx, EnOssan* this) { - Player* player = GET_PLAYER(globalCtx); +void EnOssan_SetupBuyItemWithFanfare(PlayState* play, EnOssan* this) { + Player* player = GET_PLAYER(play); - Actor_PickUp(&this->actor, globalCtx, this->items[this->cursorIdx]->getItemId, 300.0f, 300.0f); - globalCtx->msgCtx.msgMode = 0x43; - globalCtx->msgCtx.unk12023 = 4; + Actor_PickUp(&this->actor, play, this->items[this->cursorIdx]->getItemId, 300.0f, 300.0f); + play->msgCtx.msgMode = 0x43; + play->msgCtx.stateTimer = 4; player->stateFlags2 &= ~0x20000000; Interface_ChangeAlpha(50); this->drawCursor = 0; EnOssan_SetupAction(this, EnOssan_BuyItemWithFanfare); } -void EnOssan_SetupCannotBuy(GlobalContext* globalCtx, EnOssan* this, u16 textId) { - func_80151938(globalCtx, textId); +void EnOssan_SetupCannotBuy(PlayState* play, EnOssan* this, u16 textId) { + func_80151938(play, textId); EnOssan_SetupAction(this, EnOssan_CannotBuy); } -void EnOssan_SetupBuy(GlobalContext* globalCtx, EnOssan* this, u16 textId) { - func_80151938(globalCtx, textId); +void EnOssan_SetupBuy(PlayState* play, EnOssan* this, u16 textId) { + func_80151938(play, textId); EnOssan_SetupAction(this, EnOssan_CanBuy); } -void EnOssan_HandleCanBuyItem(GlobalContext* globalCtx, EnOssan* this) { +void EnOssan_HandleCanBuyItem(PlayState* play, EnOssan* this) { EnGirlA* item = this->items[this->cursorIdx]; - switch (item->canBuyFunc(globalCtx, item)) { + switch (item->canBuyFunc(play, item)) { case CANBUY_RESULT_SUCCESS_1: if (this->cutsceneState == ENOSSAN_CUTSCENESTATE_PLAYING) { ActorCutscene_Stop(this->cutscene); this->cutsceneState = ENOSSAN_CUTSCENESTATE_STOPPED; } func_8019F208(); - item->buyFanfareFunc(globalCtx, item); - EnOssan_SetupBuyItemWithFanfare(globalCtx, this); + item->buyFanfareFunc(play, item); + EnOssan_SetupBuyItemWithFanfare(play, this); this->drawCursor = 0; this->shopItemSelectedTween = 0.0f; - item->boughtFunc(globalCtx, item); + item->boughtFunc(play, item); break; case CANBUY_RESULT_SUCCESS_2: func_8019F208(); - item->buyFunc(globalCtx, item); - EnOssan_SetupBuy(globalCtx, this, sBuySuccessTextIds[this->actor.params]); + item->buyFunc(play, item); + EnOssan_SetupBuy(play, this, sBuySuccessTextIds[this->actor.params]); this->drawCursor = 0; this->shopItemSelectedTween = 0.0f; - item->boughtFunc(globalCtx, item); + item->boughtFunc(play, item); break; case CANBUY_RESULT_NO_ROOM: case CANBUY_RESULT_NO_ROOM_2: play_sound(NA_SE_SY_ERROR); - EnOssan_SetupCannotBuy(globalCtx, this, sNoRoomTextIds[this->actor.params]); + EnOssan_SetupCannotBuy(play, this, sNoRoomTextIds[this->actor.params]); break; case CANBUY_RESULT_NEED_EMPTY_BOTTLE: play_sound(NA_SE_SY_ERROR); - EnOssan_SetupCannotBuy(globalCtx, this, sNeedEmptyBottleTextIds[this->actor.params]); + EnOssan_SetupCannotBuy(play, this, sNeedEmptyBottleTextIds[this->actor.params]); break; case CANBUY_RESULT_NEED_RUPEES: play_sound(NA_SE_SY_ERROR); - EnOssan_SetupCannotBuy(globalCtx, this, sNeedRupeesTextIds[this->actor.params]); + EnOssan_SetupCannotBuy(play, this, sNeedRupeesTextIds[this->actor.params]); break; case CANBUY_RESULT_CANNOT_GET_NOW_2: play_sound(NA_SE_SY_ERROR); - EnOssan_SetupCannotBuy(globalCtx, this, sCannotGetNowTextIds[this->actor.params]); + EnOssan_SetupCannotBuy(play, this, sCannotGetNowTextIds[this->actor.params]); break; case CANBUY_RESULT_CANNOT_GET_NOW: play_sound(NA_SE_SY_ERROR); - EnOssan_SetupCannotBuy(globalCtx, this, sNoRoomTextIds[this->actor.params]); + EnOssan_SetupCannotBuy(play, this, sNoRoomTextIds[this->actor.params]); break; } } -void EnOssan_SelectItem(EnOssan* this, GlobalContext* globalCtx) { - u8 talkState = Message_GetState(&globalCtx->msgCtx); +void EnOssan_SelectItem(EnOssan* this, PlayState* play) { + u8 talkState = Message_GetState(&play->msgCtx); - if (EnOssan_TakeItemOffShelf(this) && talkState == 4) { - func_8011552C(globalCtx, 6); - if (!EnOssan_TestCancelOption(this, globalCtx, CONTROLLER1(globalCtx)) && Message_ShouldAdvance(globalCtx)) { - switch (globalCtx->msgCtx.choiceIndex) { + if (EnOssan_TakeItemOffShelf(this) && (talkState == TEXT_STATE_CHOICE)) { + func_8011552C(play, 6); + if (!EnOssan_TestCancelOption(this, play, CONTROLLER1(&play->state)) && Message_ShouldAdvance(play)) { + switch (play->msgCtx.choiceIndex) { case 0: - EnOssan_HandleCanBuyItem(globalCtx, this); + EnOssan_HandleCanBuyItem(play, this); break; case 1: func_8019F230(); - this->actionFunc = this->tmpActionFunc; - func_80151938(globalCtx, this->items[this->cursorIdx]->actor.textId); + this->actionFunc = this->prevActionFunc; + func_80151938(play, this->items[this->cursorIdx]->actor.textId); break; } } } } -void EnOssan_CannotBuy(EnOssan* this, GlobalContext* globalCtx) { - if (Message_GetState(&globalCtx->msgCtx) == 5 && Message_ShouldAdvance(globalCtx)) { - this->actionFunc = this->tmpActionFunc; - func_80151938(globalCtx, this->items[this->cursorIdx]->actor.textId); +void EnOssan_CannotBuy(EnOssan* this, PlayState* play) { + if ((Message_GetState(&play->msgCtx) == TEXT_STATE_5) && Message_ShouldAdvance(play)) { + this->actionFunc = this->prevActionFunc; + func_80151938(play, this->items[this->cursorIdx]->actor.textId); } } -void EnOssan_CanBuy(EnOssan* this, GlobalContext* globalCtx) { +void EnOssan_CanBuy(EnOssan* this, PlayState* play) { EnGirlA* item; - if (Message_GetState(&globalCtx->msgCtx) == 5 && Message_ShouldAdvance(globalCtx)) { + if ((Message_GetState(&play->msgCtx) == TEXT_STATE_5) && Message_ShouldAdvance(play)) { this->shopItemSelectedTween = 0.0f; EnOssan_ResetItemPosition(this); item = this->items[this->cursorIdx]; - item->restockFunc(globalCtx, item); - this->actionFunc = this->tmpActionFunc; - func_80151938(globalCtx, this->items[this->cursorIdx]->actor.textId); + item->restockFunc(play, item); + this->actionFunc = this->prevActionFunc; + func_80151938(play, this->items[this->cursorIdx]->actor.textId); } } -void EnOssan_BuyItemWithFanfare(EnOssan* this, GlobalContext* globalCtx) { - if (Actor_HasParent(&this->actor, globalCtx)) { +void EnOssan_BuyItemWithFanfare(EnOssan* this, PlayState* play) { + if (Actor_HasParent(&this->actor, play)) { this->actor.parent = NULL; EnOssan_SetupAction(this, EnOssan_SetupItemPurchased); } else { - Actor_PickUp(&this->actor, globalCtx, this->items[this->cursorIdx]->getItemId, 300.0f, 300.0f); + Actor_PickUp(&this->actor, play, this->items[this->cursorIdx]->getItemId, 300.0f, 300.0f); } } -void EnOssan_SetupItemPurchased(EnOssan* this, GlobalContext* globalCtx) { - if (Message_GetState(&globalCtx->msgCtx) == 6 && Message_ShouldAdvance(globalCtx)) { - globalCtx->msgCtx.msgMode = 0x43; - globalCtx->msgCtx.unk12023 = 4; +void EnOssan_SetupItemPurchased(EnOssan* this, PlayState* play) { + if ((Message_GetState(&play->msgCtx) == TEXT_STATE_DONE) && Message_ShouldAdvance(play)) { + play->msgCtx.msgMode = 0x43; + play->msgCtx.stateTimer = 4; EnOssan_SetupAction(this, EnOssan_ItemPurchased); if (this->cutsceneState == ENOSSAN_CUTSCENESTATE_STOPPED) { if (ActorCutscene_GetCurrentIndex() == 0x7C) { @@ -1109,53 +1109,53 @@ void EnOssan_SetupItemPurchased(EnOssan* this, GlobalContext* globalCtx) { this->cutscene = this->lookToShopkeeperCutscene; ActorCutscene_SetIntentToPlay(this->cutscene); } - func_800B85E0(&this->actor, globalCtx, 400.0f, EXCH_ITEM_MINUS1); + func_800B85E0(&this->actor, play, 400.0f, PLAYER_AP_MINUS1); } } -void EnOssan_ContinueShopping(EnOssan* this, GlobalContext* globalCtx) { - u8 talkState = Message_GetState(&globalCtx->msgCtx); - Player* player = GET_PLAYER(globalCtx); +void EnOssan_ContinueShopping(EnOssan* this, PlayState* play) { + u8 talkState = Message_GetState(&play->msgCtx); + Player* player = GET_PLAYER(play); EnGirlA* item; - if (talkState == 4) { - func_8011552C(globalCtx, 6); - if (Message_ShouldAdvance(globalCtx)) { + if (talkState == TEXT_STATE_CHOICE) { + func_8011552C(play, 6); + if (Message_ShouldAdvance(play)) { EnOssan_ResetItemPosition(this); item = this->items[this->cursorIdx]; - item->restockFunc(globalCtx, item); - if (!EnOssan_TestEndInteraction(this, globalCtx, CONTROLLER1(globalCtx))) { - switch (globalCtx->msgCtx.choiceIndex) { + item->restockFunc(play, item); + if (!EnOssan_TestEndInteraction(this, play, CONTROLLER1(&play->state))) { + switch (play->msgCtx.choiceIndex) { case 0: func_8019F208(); player->actor.shape.rot.y = BINANG_ROT180(player->actor.shape.rot.y); player->stateFlags2 |= 0x20000000; - Message_StartTextbox(globalCtx, this->textId, &this->actor); - EnOssan_SetupStartShopping(globalCtx, this, true); - func_800B85E0(&this->actor, globalCtx, 100.0f, EXCH_ITEM_MINUS1); + Message_StartTextbox(play, this->textId, &this->actor); + EnOssan_SetupStartShopping(play, this, true); + func_800B85E0(&this->actor, play, 100.0f, PLAYER_AP_MINUS1); break; case 1: default: func_8019F230(); - EnOssan_EndInteraction(globalCtx, this); + EnOssan_EndInteraction(play, this); break; } } } - } else if (talkState == 5 && Message_ShouldAdvance(globalCtx)) { + } else if (talkState == TEXT_STATE_5 && Message_ShouldAdvance(play)) { EnOssan_ResetItemPosition(this); item = this->items[this->cursorIdx]; - item->restockFunc(globalCtx, item); + item->restockFunc(play, item); player->actor.shape.rot.y = BINANG_ROT180(player->actor.shape.rot.y); player->stateFlags2 |= 0x20000000; - Message_StartTextbox(globalCtx, this->textId, &this->actor); - EnOssan_SetupStartShopping(globalCtx, this, true); - func_800B85E0(&this->actor, globalCtx, 100.0f, EXCH_ITEM_MINUS1); + Message_StartTextbox(play, this->textId, &this->actor); + EnOssan_SetupStartShopping(play, this, true); + func_800B85E0(&this->actor, play, 100.0f, PLAYER_AP_MINUS1); } } -void EnOssan_ItemPurchased(EnOssan* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); +void EnOssan_ItemPurchased(EnOssan* this, PlayState* play) { + Player* player = GET_PLAYER(play); if (this->cutsceneState == ENOSSAN_CUTSCENESTATE_STOPPED) { if (ActorCutscene_GetCanPlayNext(this->cutscene)) { @@ -1171,10 +1171,10 @@ void EnOssan_ItemPurchased(EnOssan* this, GlobalContext* globalCtx) { ActorCutscene_SetIntentToPlay(this->cutscene); } } - if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { - func_80151938(globalCtx, 0x642); + if (Actor_ProcessTalkRequest(&this->actor, &play->state)) { + func_80151938(play, 0x642); } else { - func_800B85E0(&this->actor, globalCtx, 400.0f, EXCH_ITEM_MINUS1); + func_800B85E0(&this->actor, play, 400.0f, PLAYER_AP_MINUS1); } } @@ -1277,7 +1277,7 @@ void EnOssan_UpdateCursorAnim(EnOssan* this) { void EnOssan_UpdateStickDirectionPromptAnim(EnOssan* this) { f32 arrowAnimTween = this->arrowAnimTween; f32 stickAnimTween = this->stickAnimTween; - s32 maxColor = 255; // POSSIBLY FAKE + s32 maxColor = 255; //! FAKE: if (this->arrowAnimState == 0) { arrowAnimTween += 0.05f; @@ -1362,54 +1362,54 @@ void EnOssan_Blink(EnOssan* this) { } } -void EnOssan_CuriosityShopMan_Init(EnOssan* this, GlobalContext* globalCtx) { - SkelAnime_InitFlex(globalCtx, &this->skelAnime, &gFsnSkel, &gFsnIdleAnim, this->jointTable, this->morphTable, +void EnOssan_CuriosityShopMan_Init(EnOssan* this, PlayState* play) { + SkelAnime_InitFlex(play, &this->skelAnime, &gFsnSkel, &gFsnIdleAnim, this->jointTable, this->morphTable, ENOSSAN_LIMB_MAX); this->actor.draw = EnOssan_CuriosityShopMan_Draw; } -void EnOssan_PartTimeWorker_Init(EnOssan* this, GlobalContext* globalCtx) { - SkelAnime_InitFlex(globalCtx, &this->skelAnime, &gAniSkeleton, &gAniStandingNormalAnim, this->jointTable, +void EnOssan_PartTimer_Init(EnOssan* this, PlayState* play) { + SkelAnime_InitFlex(play, &this->skelAnime, &gAniSkeleton, &gAniStandingNormalAnim, this->jointTable, this->morphTable, 16); - this->actor.draw = EnOssan_PartTimeWorker_Draw; + this->actor.draw = EnOssan_PartTimer_Draw; } -u16 EnOssan_CuriosityShopMan_GetWelcome(EnOssan* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); - u16 textId = Text_GetFaceReaction(globalCtx, 0x2F); +u16 EnOssan_CuriosityShopMan_GetWelcome(EnOssan* this, PlayState* play) { + Player* player = GET_PLAYER(play); + u16 textId = Text_GetFaceReaction(play, 0x2F); if (textId != 0) { - this->animationIndex = FSN_ANIMATION_HANDS_ON_COUNTER_START; + this->animIndex = FSN_ANIM_HANDS_ON_COUNTER_START; this->flags |= END_INTERACTION; return textId; } switch (player->transformation) { case PLAYER_FORM_DEKU: - this->animationIndex = FSN_ANIMATION_SLAM_COUNTER_START; + this->animIndex = FSN_ANIM_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->animationIndex = FSN_ANIMATION_LEAN_FORWARD_START; + this->animIndex = FSN_ANIM_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->animationIndex = FSN_ANIMATION_HAND_ON_FACE_START; + this->animIndex = FSN_ANIM_HAND_ON_FACE_START; if (gSaveContext.save.weekEventReg[18] & 4) { return sWelcomeGoronTextIds[ENOSSAN_CURIOSITY_SHOP_MAN]; } return sWelcomeGoronFirstTimeTextIds[ENOSSAN_CURIOSITY_SHOP_MAN]; } - this->animationIndex = FSN_ANIMATION_HANDS_ON_COUNTER_START; + this->animIndex = FSN_ANIM_HANDS_ON_COUNTER_START; return sWelcomeHumanTextIds[ENOSSAN_CURIOSITY_SHOP_MAN]; } -u16 EnOssan_PartTimerWorker_GetWelcome(EnOssan* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); - u16 textId = Text_GetFaceReaction(globalCtx, 0x36); +u16 EnOssan_PartTimer_GetWelcome(EnOssan* this, PlayState* play) { + Player* player = GET_PLAYER(play); + u16 textId = Text_GetFaceReaction(play, 0x36); if (textId != 0) { this->flags |= END_INTERACTION; @@ -1458,19 +1458,19 @@ void EnOssan_SetHaveMet(EnOssan* this) { } } -void EnOssan_InitShop(EnOssan* this, GlobalContext* globalCtx) { - static EnOssanActionFunc sInitFuncs[] = { EnOssan_CuriosityShopMan_Init, EnOssan_PartTimeWorker_Init }; +void EnOssan_InitShop(EnOssan* this, PlayState* play) { + static EnOssanActionFunc sInitFuncs[] = { EnOssan_CuriosityShopMan_Init, EnOssan_PartTimer_Init }; ShopItem* shopItems; - if (Object_IsLoaded(&globalCtx->objectCtx, this->objIndex)) { + if (Object_IsLoaded(&play->objectCtx, this->objIndex)) { this->actor.flags &= ~ACTOR_FLAG_10; this->actor.objBankIndex = this->objIndex; - Actor_SetObjectDependency(globalCtx, &this->actor); + Actor_SetObjectDependency(play, &this->actor); shopItems = sShops[this->actor.params]; ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 20.0f); - sInitFuncs[this->actor.params](this, globalCtx); + sInitFuncs[this->actor.params](this, play); this->textId = sWelcomeHumanTextIds[this->actor.params]; - EnOssan_GetCutscenes(this, globalCtx); + EnOssan_GetCutscenes(this, play); this->cursorPos.y = this->cursorPos.x = 100.0f; this->cutsceneState = ENOSSAN_CUTSCENESTATE_STOPPED; @@ -1526,9 +1526,9 @@ void EnOssan_InitShop(EnOssan* this, GlobalContext* globalCtx) { this->shopItemSelectedTween = 0.0f; Actor_SetScale(&this->actor, sActorScales[this->actor.params]); - 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->animIndex = 1; // FSN_ANIM_SCRATCH_BACK and ANI_ANIM_STANDING_NORMAL_LOOP_2 + SubS_ChangeAnimationByInfoS(&this->skelAnime, sAnimationInfo[this->actor.params], 1); + EnOssan_SpawnShopItems(this, play, shopItems); this->blinkTimer = 20; this->eyeTexIndex = 0; this->blinkFunc = EnOssan_WaitForBlink; @@ -1537,32 +1537,32 @@ void EnOssan_InitShop(EnOssan* this, GlobalContext* globalCtx) { } } -void EnOssan_GetCutscenes(EnOssan* this, GlobalContext* globalCtx) { +void EnOssan_GetCutscenes(EnOssan* this, PlayState* play) { this->lookToShopkeeperCutscene = this->actor.cutscene; this->lookToLeftShelfCutscene = ActorCutscene_GetAdditionalCutscene(this->lookToShopkeeperCutscene); this->lookToRightShelfCutscene = ActorCutscene_GetAdditionalCutscene(this->lookToLeftShelfCutscene); this->lookToShopKeeperFromShelfCutscene = ActorCutscene_GetAdditionalCutscene(this->lookToRightShelfCutscene); } -void EnOssan_Update(Actor* thisx, GlobalContext* globalCtx) { +void EnOssan_Update(Actor* thisx, PlayState* play) { EnOssan* this = THIS; if (this->actionFunc != EnOssan_InitShop) { this->blinkFunc(this); - EnOssan_UpdateJoystickInputState(globalCtx, this); + EnOssan_UpdateJoystickInputState(play, this); EnOssan_UpdateItemSelectedProperty(this); EnOssan_UpdateStickDirectionPromptAnim(this); EnOssan_UpdateCursorAnim(this); - func_800E9250(globalCtx, &this->actor, &this->headRot, &this->unk2CC, this->actor.focus.pos); - this->actionFunc(this, globalCtx); + Actor_TrackPlayer(play, &this->actor, &this->headRot, &this->unk2CC, this->actor.focus.pos); + this->actionFunc(this, play); Actor_SetFocus(&this->actor, 90.0f); SkelAnime_Update(&this->skelAnime); } else { - this->actionFunc(this, globalCtx); + this->actionFunc(this, play); } } -void EnOssan_DrawCursor(GlobalContext* globalCtx, EnOssan* this, f32 x, f32 y, f32 z, u8 drawCursor) { +void EnOssan_DrawCursor(PlayState* play, EnOssan* this, f32 x, f32 y, f32 z, u8 drawCursor) { s32 ulx; s32 uly; s32 lrx; @@ -1572,9 +1572,9 @@ void EnOssan_DrawCursor(GlobalContext* globalCtx, EnOssan* this, f32 x, f32 y, f (void)"../z_en_oB1.c"; - OPEN_DISPS(globalCtx->state.gfxCtx); + OPEN_DISPS(play->state.gfxCtx); if (drawCursor != 0) { - func_8012C654(globalCtx->state.gfxCtx); + func_8012C654(play->state.gfxCtx); gDPSetPrimColor(OVERLAY_DISP++, 0, 0, this->cursorColor.r, this->cursorColor.g, this->cursorColor.b, this->cursorColor.a); gDPLoadTextureBlock_4b(OVERLAY_DISP++, gSelectionCursorTex, G_IM_FMT_IA, 16, 16, 0, G_TX_MIRROR | G_TX_WRAP, @@ -1587,11 +1587,11 @@ void EnOssan_DrawCursor(GlobalContext* globalCtx, EnOssan* this, f32 x, f32 y, f dsdx = (1.0f / z) * 1024.0f; gSPTextureRectangle(OVERLAY_DISP++, ulx, uly, lrx, lry, G_TX_RENDERTILE, 0, 0, dsdx, dsdx); } - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->state.gfxCtx); } -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) { +void EnOssan_DrawTextRec(PlayState* play, 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; s32 uly; @@ -1604,7 +1604,7 @@ void EnOssan_DrawTextRec(GlobalContext* globalCtx, s32 r, s32 g, s32 b, s32 a, f (void)"../z_en_oB1.c"; - OPEN_DISPS(globalCtx->state.gfxCtx); + OPEN_DISPS(play->state.gfxCtx); gDPPipeSync(OVERLAY_DISP++); gDPSetPrimColor(OVERLAY_DISP++, 0, 0, r, g, b, a); @@ -1621,30 +1621,30 @@ void EnOssan_DrawTextRec(GlobalContext* globalCtx, s32 r, s32 g, s32 b, s32 a, f dtdy = dy * unk; gSPTextureRectangle(OVERLAY_DISP++, ulx, uly, lrx, lry, G_TX_RENDERTILE, s, t, dsdx, dtdy); - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->state.gfxCtx); } -void EnOssan_DrawStickDirectionPrompts(GlobalContext* globalCtx, EnOssan* this) { +void EnOssan_DrawStickDirectionPrompts(PlayState* play, EnOssan* this) { s32 drawStickRightPrompt = this->stickLeftPrompt.isEnabled; s32 drawStickLeftPrompt = this->stickRightPrompt.isEnabled; (void)"../z_en_oB1.c"; - OPEN_DISPS(globalCtx->state.gfxCtx); + OPEN_DISPS(play->state.gfxCtx); if (drawStickRightPrompt || drawStickLeftPrompt) { - func_8012C654(globalCtx->state.gfxCtx); + func_8012C654(play->state.gfxCtx); gDPSetCombineMode(OVERLAY_DISP++, G_CC_MODULATEIA_PRIM, G_CC_MODULATEIA_PRIM); 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, + EnOssan_DrawTextRec(play, this->stickLeftPrompt.arrowColor.r, this->stickLeftPrompt.arrowColor.g, this->stickLeftPrompt.arrowColor.b, this->stickLeftPrompt.arrowColor.a, this->stickLeftPrompt.arrowTexX, this->stickLeftPrompt.arrowTexY, this->stickLeftPrompt.texZ, 0, 0, -1.0f, 1.0f); } if (drawStickLeftPrompt) { - EnOssan_DrawTextRec(globalCtx, this->stickRightPrompt.arrowColor.r, this->stickRightPrompt.arrowColor.g, + EnOssan_DrawTextRec(play, this->stickRightPrompt.arrowColor.r, this->stickRightPrompt.arrowColor.g, this->stickRightPrompt.arrowColor.b, this->stickRightPrompt.arrowColor.a, this->stickRightPrompt.arrowTexX, this->stickRightPrompt.arrowTexY, this->stickRightPrompt.texZ, 0, 0, 1.0f, 1.0f); @@ -1653,44 +1653,43 @@ void EnOssan_DrawStickDirectionPrompts(GlobalContext* globalCtx, EnOssan* this) 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, + EnOssan_DrawTextRec(play, this->stickLeftPrompt.stickColor.r, this->stickLeftPrompt.stickColor.g, this->stickLeftPrompt.stickColor.b, this->stickLeftPrompt.stickColor.a, this->stickLeftPrompt.stickTexX, this->stickLeftPrompt.stickTexY, this->stickLeftPrompt.texZ, 0, 0, -1.0f, 1.0f); } if (drawStickLeftPrompt) { - EnOssan_DrawTextRec(globalCtx, this->stickRightPrompt.stickColor.r, this->stickRightPrompt.stickColor.g, + EnOssan_DrawTextRec(play, this->stickRightPrompt.stickColor.r, this->stickRightPrompt.stickColor.g, this->stickRightPrompt.stickColor.b, this->stickRightPrompt.stickColor.a, this->stickRightPrompt.stickTexX, this->stickRightPrompt.stickTexY, this->stickRightPrompt.texZ, 0, 0, 1.0f, 1.0f); } } - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->state.gfxCtx); } -s32 EnOssan_CuriosityShopMan_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, - Vec3s* rot, Actor* thisx) { +s32 EnOssan_CuriosityShopMan_OverrideLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, + Actor* thisx) { EnOssan* this = THIS; if (limbIndex == FSN_LIMB_HEAD) { - Matrix_InsertXRotation_s(this->headRot.y, MTXMODE_APPLY); + Matrix_RotateXS(this->headRot.y, MTXMODE_APPLY); } return false; } -s32 EnOssan_PartTimeWorker_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, - Vec3s* rot, Actor* thisx) { +s32 EnOssan_PartTimer_OverrideLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, + Actor* thisx) { EnOssan* this = THIS; if (limbIndex == ANI_LIMB_HEAD) { - Matrix_InsertXRotation_s(this->headRotPartTimeWorker.y, MTXMODE_APPLY); - Matrix_InsertZRotation_s(this->headRotPartTimeWorker.x, MTXMODE_APPLY); + Matrix_RotateXS(this->partTimerHeadRot.y, MTXMODE_APPLY); + Matrix_RotateZS(this->partTimerHeadRot.x, MTXMODE_APPLY); } return false; } -void EnOssan_CuriosityShopMan_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, - Actor* thisx) { +void EnOssan_CuriosityShopMan_PostLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx) { EnOssan* this = THIS; if (limbIndex == FSN_LIMB_PELVIS || limbIndex == FSN_LIMB_LEFT_UPPER_ARM || limbIndex == FSN_LIMB_RIGHT_UPPER_ARM) { @@ -1699,43 +1698,42 @@ void EnOssan_CuriosityShopMan_PostLimbDraw(GlobalContext* globalCtx, s32 limbInd } } -void EnOssan_PartTimeWorker_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, - Actor* thisx) { - static Vec3f sPartTimeWorkerFocusOffset = { 800.0f, 500.0f, 0.0f }; +void EnOssan_PartTimer_PostLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx) { + static Vec3f sFocusOffset = { 800.0f, 500.0f, 0.0f }; EnOssan* this = THIS; if (limbIndex == ANI_LIMB_HEAD) { - Matrix_MultiplyVector3fByState(&sPartTimeWorkerFocusOffset, &this->actor.focus.pos); + Matrix_MultVec3f(&sFocusOffset, &this->actor.focus.pos); } } -void EnOssan_CuriosityShopMan_Draw(Actor* thisx, GlobalContext* globalCtx) { +void EnOssan_CuriosityShopMan_Draw(Actor* thisx, PlayState* play) { static TexturePtr sEyeTextures[] = { gFsnEyeOpenTex, gFsnEyeHalfTex, gFsnEyeClosedTex }; s32 pad; EnOssan* this = THIS; - OPEN_DISPS(globalCtx->state.gfxCtx); - func_8012C28C(globalCtx->state.gfxCtx); + OPEN_DISPS(play->state.gfxCtx); + func_8012C28C(play->state.gfxCtx); gSPSegment(POLY_OPA_DISP++, 0x08, Lib_SegmentedToVirtual(sEyeTextures[this->eyeTexIndex])); - SkelAnime_DrawFlexOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, + SkelAnime_DrawFlexOpa(play, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, 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); + EnOssan_DrawCursor(play, this, this->cursorPos.x, this->cursorPos.y, this->cursorPos.z, this->drawCursor); + EnOssan_DrawStickDirectionPrompts(play, this); + CLOSE_DISPS(play->state.gfxCtx); } -void EnOssan_PartTimeWorker_Draw(Actor* thisx, GlobalContext* globalCtx) { +void EnOssan_PartTimer_Draw(Actor* thisx, PlayState* play) { static TexturePtr sEyeTextures[] = { gAniOpenEyeTex, gAniClosingEyeTex, gAniClosedEyeTex }; s32 pad; EnOssan* this = THIS; - OPEN_DISPS(globalCtx->state.gfxCtx); - func_8012C28C(globalCtx->state.gfxCtx); + OPEN_DISPS(play->state.gfxCtx); + func_8012C28C(play->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_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); + SkelAnime_DrawFlexOpa(play, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, + EnOssan_PartTimer_OverrideLimbDraw, EnOssan_PartTimer_PostLimbDraw, &this->actor); + EnOssan_DrawCursor(play, this, this->cursorPos.x, this->cursorPos.y, this->cursorPos.z, this->drawCursor); + EnOssan_DrawStickDirectionPrompts(play, this); + CLOSE_DISPS(play->state.gfxCtx); } diff --git a/src/overlays/actors/ovl_En_Ossan/z_en_ossan.h b/src/overlays/actors/ovl_En_Ossan/z_en_ossan.h index 58c638d8e..539906ea8 100644 --- a/src/overlays/actors/ovl_En_Ossan/z_en_ossan.h +++ b/src/overlays/actors/ovl_En_Ossan/z_en_ossan.h @@ -6,18 +6,19 @@ #include "objects/object_ani/object_ani.h" #include "objects/object_fsn/object_fsn.h" -#define ENOSSAN_LIMB_MAX MAX(FSN_LIMB_MAX + 1, ANI_LIMB_MAX) +// 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; -typedef void (*EnOssanActionFunc)(struct EnOssan*, GlobalContext*); +typedef void (*EnOssanActionFunc)(struct EnOssan*, PlayState*); typedef void (*EnOssanBlinkFunc)(struct EnOssan*); typedef struct EnOssan { /* 0x000 */ Actor actor; /* 0x144 */ SkelAnime skelAnime; /* 0x188 */ EnOssanActionFunc actionFunc; - /* 0x18C */ EnOssanActionFunc tmpActionFunc; // Used to restore back to correct browsing function + /* 0x18C */ EnOssanActionFunc prevActionFunc; // Used to restore back to correct browsing function /* 0x190 */ ColliderCylinder collider; /* 0x1DC */ s16 delayTimer; /* 0x1DE */ s8 objIndex; @@ -55,8 +56,8 @@ typedef struct EnOssan { /* 0x2F8 */ s16 limbRotTableZ[19]; /* 0x31E */ Vec3s jointTable[ENOSSAN_LIMB_MAX]; /* 0x390 */ Vec3s morphTable[ENOSSAN_LIMB_MAX]; - /* 0x402 */ s16 animationIndex; - /* 0x404 */ Vec3s headRotPartTimeWorker; + /* 0x402 */ s16 animIndex; + /* 0x404 */ Vec3s partTimerHeadRot; /* 0x40A */ u16 flags; } EnOssan; // size = 0x40C diff --git a/src/overlays/actors/ovl_En_Ot/z_en_ot.c b/src/overlays/actors/ovl_En_Ot/z_en_ot.c index 7573947e6..6ea2c6153 100644 --- a/src/overlays/actors/ovl_En_Ot/z_en_ot.c +++ b/src/overlays/actors/ovl_En_Ot/z_en_ot.c @@ -13,51 +13,51 @@ #define THIS ((EnOt*)thisx) -void EnOt_Init(Actor* thisx, GlobalContext* globalCtx); -void EnOt_Destroy(Actor* thisx, GlobalContext* globalCtx); -void EnOt_Update(Actor* thisx, GlobalContext* globalCtx); -void EnOt_Draw(Actor* thisx, GlobalContext* globalCtx); +void EnOt_Init(Actor* thisx, PlayState* play); +void EnOt_Destroy(Actor* thisx, PlayState* play); +void EnOt_Update(Actor* thisx, PlayState* play); +void EnOt_Draw(Actor* thisx, PlayState* play); -void func_80B5BDA8(EnOt* this, GlobalContext* globalCtx); -void func_80B5BE04(EnOt* this, GlobalContext* globalCtx); -void func_80B5BE88(EnOt* this, GlobalContext* globalCtx); -void func_80B5BED4(EnOt* this, GlobalContext* globalCtx); -void func_80B5BF60(EnOt* this, GlobalContext* globalCtx); -void func_80B5BFB8(EnOt* this, GlobalContext* globalCtx); -void func_80B5C1CC(EnOt* this, GlobalContext* globalCtx); -void func_80B5C244(EnOt* this, GlobalContext* globalCtx); -void func_80B5C25C(EnOt* this, GlobalContext* globalCtx); -void func_80B5C3B8(EnOt* this, GlobalContext* globalCtx); -void func_80B5C3D8(EnOt* this, GlobalContext* globalCtx); -void func_80B5C634(EnOt* this, GlobalContext* globalCtx); -void func_80B5C64C(EnOt* this, GlobalContext* globalCtx); -void func_80B5C684(EnOt* this, GlobalContext* globalCtx); -void func_80B5C6DC(EnOt* this, GlobalContext* globalCtx); -void func_80B5C910(EnOt* this, GlobalContext* globalCtx); -void func_80B5C950(EnOt* this, GlobalContext* globalCtx); -void func_80B5C9A8(EnOt* this, GlobalContext* globalCtx); -void func_80B5C9C0(EnOt* this, GlobalContext* globalCtx); -void func_80B5C9D0(EnOt* this, GlobalContext* globalCtx); -void func_80B5CA30(EnOt* this, GlobalContext* globalCtx); -void func_80B5CAD0(EnOt* this, GlobalContext* globalCtx); -void func_80B5CB0C(EnOt* this, GlobalContext* globalCtx); -void func_80B5CBEC(EnOt* this, GlobalContext* globalCtx); -void func_80B5CC88(EnOt* this, GlobalContext* globalCtx); -void func_80B5CCA0(EnOt* this, GlobalContext* globalCtx); -void func_80B5CCF4(EnOt* this, GlobalContext* globalCtx); -void func_80B5CD40(EnOt* this, GlobalContext* globalCtx); -void func_80B5CE6C(EnOt* this, GlobalContext* globalCtx); -void func_80B5CEC8(EnOt* this, GlobalContext* globalCtx); -void func_80B5D114(EnOt* this, GlobalContext* globalCtx); -void func_80B5D160(EnOt* this, GlobalContext* globalCtx); -void func_80B5D648(EnOt* this, GlobalContext* globalCtx); -void func_80B5D750(EnOt* this, GlobalContext* globalCtx); -void func_80B5DAEC(Actor* thisx, GlobalContext* globalCtx); -void func_80B5DB6C(Actor* thisx, GlobalContext* globalCtx); -void EnOt_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx); +void func_80B5BDA8(EnOt* this, PlayState* play); +void func_80B5BE04(EnOt* this, PlayState* play); +void func_80B5BE88(EnOt* this, PlayState* play); +void func_80B5BED4(EnOt* this, PlayState* play); +void func_80B5BF60(EnOt* this, PlayState* play); +void func_80B5BFB8(EnOt* this, PlayState* play); +void func_80B5C1CC(EnOt* this, PlayState* play); +void func_80B5C244(EnOt* this, PlayState* play); +void func_80B5C25C(EnOt* this, PlayState* play); +void func_80B5C3B8(EnOt* this, PlayState* play); +void func_80B5C3D8(EnOt* this, PlayState* play); +void func_80B5C634(EnOt* this, PlayState* play); +void func_80B5C64C(EnOt* this, PlayState* play); +void func_80B5C684(EnOt* this, PlayState* play); +void func_80B5C6DC(EnOt* this, PlayState* play); +void func_80B5C910(EnOt* this, PlayState* play); +void func_80B5C950(EnOt* this, PlayState* play); +void func_80B5C9A8(EnOt* this, PlayState* play); +void func_80B5C9C0(EnOt* this, PlayState* play); +void func_80B5C9D0(EnOt* this, PlayState* play); +void func_80B5CA30(EnOt* this, PlayState* play); +void func_80B5CAD0(EnOt* this, PlayState* play); +void func_80B5CB0C(EnOt* this, PlayState* play); +void func_80B5CBEC(EnOt* this, PlayState* play); +void func_80B5CC88(EnOt* this, PlayState* play); +void func_80B5CCA0(EnOt* this, PlayState* play); +void func_80B5CCF4(EnOt* this, PlayState* play); +void func_80B5CD40(EnOt* this, PlayState* play); +void func_80B5CE6C(EnOt* this, PlayState* play); +void func_80B5CEC8(EnOt* this, PlayState* play); +void func_80B5D114(EnOt* this, PlayState* play); +void func_80B5D160(EnOt* this, PlayState* play); +void func_80B5D648(EnOt* this, PlayState* play); +void func_80B5D750(EnOt* this, PlayState* play); +void func_80B5DAEC(Actor* thisx, PlayState* play); +void func_80B5DB6C(Actor* thisx, PlayState* play); +void EnOt_PostLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx); EnOtUnkStruct* func_80B5DF58(EnOtUnkStruct* arg0, u8 arg1, Vec3f* arg2, Vec3s* arg3, s32 arg4); -void func_80B5E078(GlobalContext* globalCtx, EnOtUnkStruct* arg1, s32 arg2); -void func_80B5E1D8(GlobalContext* globalCtx, EnOtUnkStruct* arg1, s32 arg2); +void func_80B5E078(PlayState* play, EnOtUnkStruct* arg1, s32 arg2); +void func_80B5E1D8(PlayState* play, EnOtUnkStruct* arg1, s32 arg2); static EnOt* D_80B5E880; static EnOt* D_80B5E884; @@ -107,9 +107,9 @@ static InitChainEntry sInitChain[] = { ICHAIN_F32(uncullZoneForward, 4000, ICHAIN_STOP), }; -void func_80B5B2E0(GlobalContext* globalCtx, Vec3f* pos, s16 params, Vec3f* vec, s32* index) { +void func_80B5B2E0(PlayState* play, Vec3f* pos, s16 params, Vec3f* vec, s32* index) { s32 i; - Path* path = &globalCtx->setupPathList[params]; + Path* path = &play->setupPathList[params]; f32 dist; Vec3f sp58; Vec3f sp4C; @@ -128,7 +128,7 @@ void func_80B5B2E0(GlobalContext* globalCtx, Vec3f* pos, s16 params, Vec3f* vec, Math_Vec3f_Copy(vec, &sp4C); } -void EnOt_Init(Actor* thisx, GlobalContext* globalCtx) { +void EnOt_Init(Actor* thisx, PlayState* play) { s32 pad; EnOt* this = THIS; s32 bgId; @@ -149,9 +149,9 @@ void EnOt_Init(Actor* thisx, GlobalContext* globalCtx) { } ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 30.0f); - SkelAnime_InitFlex(globalCtx, &this->skelAnime, &object_ot_Skel_004800, &object_ot_Anim_0008D8, this->jointTable, + SkelAnime_InitFlex(play, &this->skelAnime, &object_ot_Skel_004800, &object_ot_Anim_0008D8, this->jointTable, this->morphTable, 19); - Collider_InitAndSetCylinder(globalCtx, &this->collider, &this->actor, &sCylinderInit); + Collider_InitAndSetCylinder(play, &this->collider, &this->actor, &sCylinderInit); 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, @@ -163,9 +163,9 @@ void EnOt_Init(Actor* thisx, GlobalContext* globalCtx) { this->actor.colChkInfo.mass = MASS_IMMOVABLE; this->actor.gravity = 0.0f; SubS_FillCutscenesList(&this->actor, this->cutscenes, ARRAY_COUNT(this->cutscenes)); - SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimations, 0, &this->animIdx); + SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimations, 0, &this->animIndex); this->skelAnime.curFrame = Rand_ZeroOne() * this->skelAnime.endFrame; - this->lightNode = LightContext_InsertLight(globalCtx, &globalCtx->lightCtx, &this->lightInfo); + this->lightNode = LightContext_InsertLight(play, &play->lightCtx, &this->lightInfo); this->unk_744.r = 255; this->unk_744.g = 200; this->unk_744.b = 80; @@ -177,15 +177,15 @@ void EnOt_Init(Actor* thisx, GlobalContext* globalCtx) { switch (this->unk_344) { case 0: - this->actor.world.pos.y = BgCheck_EntityRaycastFloor3(&globalCtx->colCtx, &this->actor.floorPoly, - &bgId, &this->actor.world.pos) + + this->actor.world.pos.y = BgCheck_EntityRaycastFloor3(&play->colCtx, &this->actor.floorPoly, &bgId, + &this->actor.world.pos) + 50.0f; if (gSaveContext.save.weekEventReg[84] & 0x10) { - Matrix_RotateY(this->actor.shape.rot.y, MTXMODE_NEW); - Matrix_GetStateTranslationAndScaledZ(52.519997f, &sp64); + 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, + this->unk_360 = (EnOt*)Actor_Spawn(&play->actorCtx, play, ACTOR_EN_OT, sp64.x, sp64.y, sp64.z, + 0, BINANG_ROT180(this->actor.shape.rot.y), 1, ENOT_GET_3FFF(&this->actor) | 0x8000); if (this->unk_360 != NULL) { this->unk_360->unk_360 = this; @@ -196,9 +196,9 @@ void EnOt_Init(Actor* thisx, GlobalContext* globalCtx) { 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.save.weekEventReg[32] & 1) { - func_80B5C244(this, globalCtx); + func_80B5C244(this, play); } else { - func_80B5C684(this, globalCtx); + func_80B5C684(this, play); } } else { Actor_MarkForDeath(&this->actor); @@ -206,15 +206,15 @@ 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); - func_80B5BDA8(this, globalCtx); - func_80B5BE88(this->unk_360, globalCtx); + func_80B5BDA8(this, play); + func_80B5BE88(this->unk_360, play); } else { - func_80B5CE6C(this, globalCtx); + func_80B5CE6C(this, play); } break; @@ -232,18 +232,18 @@ void EnOt_Init(Actor* thisx, GlobalContext* globalCtx) { Actor_SetScale(&this->actor, 0.0f); if (!(gSaveContext.save.weekEventReg[13] & 1)) { Actor_SetScale(&this->actor, 0.0f); - func_80B5C910(this, globalCtx); + func_80B5C910(this, play); } else { - Player* player = GET_PLAYER(globalCtx); + Player* player = GET_PLAYER(play); - if (SurfaceType_IsHorseBlocked(&globalCtx->colCtx, player->actor.floorPoly, + if (SurfaceType_IsHorseBlocked(&play->colCtx, player->actor.floorPoly, player->actor.floorBgId)) { Actor_SetScale(&this->actor, 0.0f); - func_80B5C910(this, globalCtx); + func_80B5C910(this, play); } else { this->unk_360 = D_80B5E884; this->unk_360->unk_360 = this; - func_80B5C9D0(this, globalCtx); + func_80B5C9D0(this, play); } } break; @@ -252,12 +252,12 @@ void EnOt_Init(Actor* thisx, GlobalContext* globalCtx) { Actor_SetScale(&this->actor, 0.012999999f); if (gSaveContext.save.weekEventReg[84] & 0x10) { if (gSaveContext.save.weekEventReg[32] & 1) { - func_80B5C244(this, globalCtx); + func_80B5C244(this, play); } else { - func_80B5C684(this, globalCtx); + func_80B5C684(this, play); } } else { - func_80B5CE6C(this, globalCtx); + func_80B5CE6C(this, play); } break; } @@ -272,7 +272,7 @@ void EnOt_Init(Actor* thisx, GlobalContext* globalCtx) { this->collider.dim.height *= 0.5f; this->collider.dim.yShift *= 0.5f; this->actor.update = func_80B5DAEC; - func_80B5C634(this, globalCtx); + func_80B5C634(this, play); } else { Actor_MarkForDeath(&this->actor); } @@ -280,11 +280,11 @@ void EnOt_Init(Actor* thisx, GlobalContext* globalCtx) { } } -void EnOt_Destroy(Actor* thisx, GlobalContext* globalCtx) { +void EnOt_Destroy(Actor* thisx, PlayState* play) { EnOt* this = THIS; - Collider_DestroyCylinder(globalCtx, &this->collider); - LightContext_RemoveLight(globalCtx, &globalCtx->lightCtx, this->lightNode); + Collider_DestroyCylinder(play, &this->collider); + LightContext_RemoveLight(play, &play->lightCtx, this->lightNode); } void func_80B5BAAC(LightInfo* lightInfo, Vec3f* arg1, Color_RGB8* arg2, s16 radius) { @@ -299,34 +299,34 @@ void func_80B5BB38(Color_RGB8* arg0, Color_RGB8* arg1, f32 arg2) { arg0->b = (arg1->b * arg2) + (arg1->b * (1.0f - arg2) * rand); } -void func_80B5BDA8(EnOt* this, GlobalContext* globalCtx) { - SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimations, 1, &this->animIdx); +void func_80B5BDA8(EnOt* this, PlayState* play) { + SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimations, 1, &this->animIndex); SubS_FillCutscenesList(&this->actor, this->cutscenes, ARRAY_COUNT(this->cutscenes)); this->actionFunc = func_80B5BE04; } -void func_80B5BE04(EnOt* this, GlobalContext* globalCtx) { +void func_80B5BE04(EnOt* this, PlayState* play) { switch (this->unk_388) { case 0: if (SubS_StartActorCutscene(&this->actor, this->cutscenes[2], -1, SUBS_CUTSCENE_SET_UNK_LINK_FIELDS)) { - func_80B5BF60(this, globalCtx); + func_80B5BF60(this, play); } break; case 1: if (SubS_StartActorCutscene(&this->actor, this->cutscenes[3], -1, SUBS_CUTSCENE_SET_UNK_LINK_FIELDS)) { - func_80B5BF60(this, globalCtx); + func_80B5BF60(this, play); } break; } } -void func_80B5BE88(EnOt* this, GlobalContext* globalCtx) { - SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimations, 1, &this->animIdx); +void func_80B5BE88(EnOt* this, PlayState* play) { + SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimations, 1, &this->animIndex); this->actionFunc = func_80B5BED4; } -void func_80B5BED4(EnOt* this, GlobalContext* globalCtx) { +void func_80B5BED4(EnOt* this, PlayState* play) { func_800BE33C(&this->actor.world.pos, &this->unk_360->actor.world.pos, &this->actor.world.rot, 0); Math_SmoothStepToS(&this->actor.shape.rot.y, Actor_YawBetweenActors(&this->actor, &this->unk_360->actor), 3, 0xE38, 0x38E); @@ -335,13 +335,13 @@ void func_80B5BED4(EnOt* this, GlobalContext* globalCtx) { Actor_MoveWithoutGravityReverse(&this->actor); } -void func_80B5BF60(EnOt* this, GlobalContext* globalCtx) { +void func_80B5BF60(EnOt* this, PlayState* play) { this->unk_32C |= 0x40; - SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimations, 0, &this->animIdx); + SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimations, 0, &this->animIndex); this->actionFunc = func_80B5BFB8; } -void func_80B5BFB8(EnOt* this, GlobalContext* globalCtx) { +void func_80B5BFB8(EnOt* this, PlayState* play) { Vec3f sp34; f32 temp_f0 = this->actor.floorHeight + 50.0f; @@ -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; @@ -368,39 +368,39 @@ void func_80B5BFB8(EnOt* this, GlobalContext* globalCtx) { this->unk_360->unk_394.y = this->unk_394.y; this->unk_360->unk_394.z = this->unk_394.z; - func_80B5C684(this->unk_360, globalCtx); - func_80B5C684(this, globalCtx); + func_80B5C684(this->unk_360, play); + func_80B5C684(this, play); } else { Actor_MoveWithoutGravityReverse(&this->actor); } } -void func_80B5C154(EnOt* this, GlobalContext* globalCtx) { +void func_80B5C154(EnOt* this, PlayState* play) { if (gSaveContext.save.weekEventReg[32] & 1) { - this->unk_38C = GI_RUPEE_RED; + this->getItemId = GI_RUPEE_RED; } else { - this->unk_38C = GI_HEART_PIECE; + this->getItemId = GI_HEART_PIECE; gSaveContext.save.weekEventReg[32] |= 1; } - Actor_PickUp(&this->actor, globalCtx, this->unk_38C, this->actor.xzDistToPlayer, this->actor.playerHeightRel); + Actor_PickUp(&this->actor, play, this->getItemId, this->actor.xzDistToPlayer, this->actor.playerHeightRel); this->actionFunc = func_80B5C1CC; } -void func_80B5C1CC(EnOt* this, GlobalContext* globalCtx) { - if (Actor_HasParent(&this->actor, globalCtx)) { +void func_80B5C1CC(EnOt* this, PlayState* play) { + if (Actor_HasParent(&this->actor, play)) { this->actor.parent = NULL; - func_80B5C244(this, globalCtx); - func_80B5C244(this->unk_360, globalCtx); + func_80B5C244(this, play); + func_80B5C244(this->unk_360, play); } else { - Actor_PickUp(&this->actor, globalCtx, this->unk_38C, this->actor.xzDistToPlayer, this->actor.playerHeightRel); + Actor_PickUp(&this->actor, play, this->getItemId, this->actor.xzDistToPlayer, this->actor.playerHeightRel); } } -void func_80B5C244(EnOt* this, GlobalContext* globalCtx) { +void func_80B5C244(EnOt* this, PlayState* play) { this->actionFunc = func_80B5C25C; } -void func_80B5C25C(EnOt* this, GlobalContext* globalCtx) { +void func_80B5C25C(EnOt* this, PlayState* play) { this->unk_390 = Actor_YawBetweenActors(&this->actor, &this->unk_360->actor); Math_SmoothStepToS(&this->actor.shape.rot.y, this->unk_390, 3, 0xE38, 0x38E); if (BINANG_SUB(BINANG_ROT180(this->unk_360->actor.shape.rot.y), this->actor.shape.rot.y) < 0x38E) { @@ -410,23 +410,23 @@ 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; - SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimations, 2, &this->animIdx); - SubS_ChangeAnimationBySpeedInfo(&this->unk_360->skelAnime, sAnimations, 2, &this->unk_360->animIdx); + SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimations, 2, &this->animIndex); + SubS_ChangeAnimationBySpeedInfo(&this->unk_360->skelAnime, sAnimations, 2, &this->unk_360->animIndex); this->actor.flags |= ACTOR_FLAG_8000000; this->actor.flags &= ~(ACTOR_FLAG_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); + func_80B5C9A8(this->unk_360, play); + func_80B5C3B8(this, play); } } -void func_80B5C3B8(EnOt* this, GlobalContext* globalCtx) { +void func_80B5C3B8(EnOt* this, PlayState* play) { this->unk_740 = 0.0f; this->actionFunc = func_80B5C3D8; } -void func_80B5C3D8(EnOt* this, GlobalContext* globalCtx) { +void func_80B5C3D8(EnOt* this, PlayState* play) { static Color_RGB8 D_80B5E408 = { 255, 200, 80 }; static Color_RGB8 D_80B5E40C = { 255, 60, 200 }; s16 temp; @@ -437,9 +437,9 @@ void func_80B5C3D8(EnOt* this, GlobalContext* globalCtx) { Vec3f sp38; this->unk_3A0 += 0x2D8; - Matrix_RotateY(this->unk_3A0, MTXMODE_NEW); - 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,48 +461,48 @@ void func_80B5C3D8(EnOt* this, GlobalContext* globalCtx) { } if (Animation_OnFrame(&this->skelAnime, 12.0f)) { - Matrix_RotateY(Camera_GetCamDirYaw(GET_ACTIVE_CAM(globalCtx)), MTXMODE_NEW); + Matrix_RotateYS(Camera_GetCamDirYaw(GET_ACTIVE_CAM(play)), 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); } } -void func_80B5C634(EnOt* this, GlobalContext* globalCtx) { +void func_80B5C634(EnOt* this, PlayState* play) { this->actionFunc = func_80B5C64C; } -void func_80B5C64C(EnOt* this, GlobalContext* globalCtx) { +void func_80B5C64C(EnOt* this, PlayState* play) { if (gSaveContext.save.weekEventReg[26] & 8) { Actor_MarkForDeath(&this->actor); } } -void func_80B5C684(EnOt* this, GlobalContext* globalCtx) { +void func_80B5C684(EnOt* this, PlayState* play) { this->actor.speedXZ = 0.0f; - SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimations, 0, &this->animIdx); + SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimations, 0, &this->animIndex); this->actionFunc = func_80B5C6DC; } -void func_80B5C6DC(EnOt* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); +void func_80B5C6DC(EnOt* this, PlayState* play) { + Player* player = GET_PLAYER(play); s32 pad; s16 sp3E; 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.save.weekEventReg[84] |= 0x10; @@ -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; @@ -530,19 +530,19 @@ void func_80B5C6DC(EnOt* this, GlobalContext* globalCtx) { 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)) { + if (Actor_ProcessTalkRequest(&this->actor, &play->state)) { this->unk_3A0 = BINANG_ADD(sp3E, 0x4000); this->unk_360->unk_3A0 = this->unk_3A0; - func_80B5C9A8(this, globalCtx); - func_80B5D114(this, globalCtx); + func_80B5C9A8(this, play); + func_80B5D114(this, play); } else if ((player->actor.bgCheckFlags & 1) && !func_801242B4(player) && (this->actor.xzDistToPlayer < 130.0f)) { - func_800B8614(&this->actor, globalCtx, 130.0f); + func_800B8614(&this->actor, play, 130.0f); } } } -void func_80B5C910(EnOt* this, GlobalContext* globalCtx) { +void func_80B5C910(EnOt* this, PlayState* play) { this->actor.shape.rot.x = 0; this->actor.shape.rot.z = 0; this->actor.shape.rot.y = this->actor.yawTowardsPlayer; @@ -553,22 +553,22 @@ void func_80B5C910(EnOt* this, GlobalContext* globalCtx) { this->actionFunc = func_80B5C950; } -void func_80B5C950(EnOt* this, GlobalContext* globalCtx) { +void func_80B5C950(EnOt* this, PlayState* play) { if (this->unk_32C & 8) { Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_SEAHORSE_OUT_BOTTLE); gSaveContext.save.weekEventReg[25] |= 4; - func_80B5CAD0(this, globalCtx); + func_80B5CAD0(this, play); } } -void func_80B5C9A8(EnOt* this, GlobalContext* globalCtx) { +void func_80B5C9A8(EnOt* this, PlayState* play) { this->actionFunc = func_80B5C9C0; } -void func_80B5C9C0(EnOt* this, GlobalContext* globalCtx) { +void func_80B5C9C0(EnOt* this, PlayState* play) { } -void func_80B5C9D0(EnOt* this, GlobalContext* globalCtx) { +void func_80B5C9D0(EnOt* this, PlayState* play) { this->actor.shape.rot.x = 0; this->actor.shape.rot.z = 0; this->actor.shape.rot.y = this->actor.yawTowardsPlayer; @@ -580,124 +580,124 @@ void func_80B5C9D0(EnOt* this, GlobalContext* globalCtx) { this->actionFunc = func_80B5CA30; } -void func_80B5CA30(EnOt* this, GlobalContext* globalCtx) { +void func_80B5CA30(EnOt* this, PlayState* play) { Math_SmoothStepToF(&this->actor.scale.x, 0.012999999f, 0.7f, 0.0001f, 0.01f); Actor_SetScale(&this->actor, this->actor.scale.x); if (this->actor.scale.x == 0.012999999f) { this->unk_360->unk_32C |= 0x1000; this->unk_360->unk_360 = this; - func_80B5C9A8(this, globalCtx); + func_80B5C9A8(this, play); } } -void func_80B5CAD0(EnOt* this, GlobalContext* globalCtx) { +void func_80B5CAD0(EnOt* this, PlayState* play) { SubS_FillCutscenesList(&this->actor, this->cutscenes, ARRAY_COUNT(this->cutscenes) / 2); this->actionFunc = func_80B5CB0C; } -void func_80B5CB0C(EnOt* this, GlobalContext* globalCtx) { +void func_80B5CB0C(EnOt* this, PlayState* play) { Math_SmoothStepToF(&this->actor.scale.x, 0.012999999f, 0.7f, 0.0001f, 0.01f); Actor_SetScale(&this->actor, this->actor.scale.x); if (this->actor.scale.x == 0.012999999f) { this->unk_32C |= 0x800; - func_80B5CE6C(this, globalCtx); + func_80B5CE6C(this, play); } } -void func_80B5CBA0(EnOt* this, GlobalContext* globalCtx) { +void func_80B5CBA0(EnOt* this, PlayState* play) { this->actor.flags |= ACTOR_FLAG_10000; - func_800B8500(&this->actor, globalCtx, this->actor.xzDistToPlayer, this->actor.playerHeightRel, 0); + func_800B8500(&this->actor, play, this->actor.xzDistToPlayer, this->actor.playerHeightRel, PLAYER_AP_NONE); this->actionFunc = func_80B5CBEC; } -void func_80B5CBEC(EnOt* this, GlobalContext* globalCtx) { - if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { +void func_80B5CBEC(EnOt* this, PlayState* play) { + if (Actor_ProcessTalkRequest(&this->actor, &play->state)) { this->actor.flags &= ~ACTOR_FLAG_10000; - func_80B5CC88(this, globalCtx); + func_80B5CC88(this, play); } else { Math_SmoothStepToS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer, 3, 0xE38, 0x38E); this->actor.world.rot.y = this->actor.shape.rot.y; - func_800B8500(&this->actor, globalCtx, this->actor.xzDistToPlayer, this->actor.playerHeightRel, 0); + func_800B8500(&this->actor, play, this->actor.xzDistToPlayer, this->actor.playerHeightRel, PLAYER_AP_NONE); } } -void func_80B5CC88(EnOt* this, GlobalContext* globalCtx) { +void func_80B5CC88(EnOt* this, PlayState* play) { this->actionFunc = func_80B5CCA0; } -void func_80B5CCA0(EnOt* this, GlobalContext* globalCtx) { +void func_80B5CCA0(EnOt* this, PlayState* play) { if (SubS_StartActorCutscene(&this->actor, this->cutscenes[0], 0x7C, SUBS_CUTSCENE_NORMAL)) { - Player* player = GET_PLAYER(globalCtx); + Player* player = GET_PLAYER(play); player->stateFlags2 |= 0x20000000; - func_80B5CCF4(this, globalCtx); + func_80B5CCF4(this, play); } } -void func_80B5CCF4(EnOt* this, GlobalContext* globalCtx) { - SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimations, 0, &this->animIdx); +void func_80B5CCF4(EnOt* this, PlayState* play) { + SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimations, 0, &this->animIndex); this->actionFunc = func_80B5CD40; } -void func_80B5CD40(EnOt* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); +void func_80B5CD40(EnOt* this, PlayState* play) { + Player* player = GET_PLAYER(play); s32 temp; - switch (Message_GetState(&globalCtx->msgCtx)) { - case 0: + switch (Message_GetState(&play->msgCtx)) { + case TEXT_STATE_NONE: temp = Math_SmoothStepToS(&this->actor.shape.rot.y, - BINANG_ROT180(Camera_GetCamDirYaw(GET_ACTIVE_CAM(globalCtx))), 3, 0xE38, 0x38E); + BINANG_ROT180(Camera_GetCamDirYaw(GET_ACTIVE_CAM(play))), 3, 0xE38, 0x38E); this->actor.world.rot.y = this->actor.shape.rot.y; if (1) {} if (!temp) { gSaveContext.save.weekEventReg[23] |= 0x10; - Message_StartTextbox(globalCtx, 0x1069, NULL); + Message_StartTextbox(play, 0x1069, NULL); } break; - case 1: - case 2: - case 3: + case TEXT_STATE_1: + case TEXT_STATE_CLOSING: + case TEXT_STATE_3: break; - case 4: - case 5: - case 6: - if (Message_ShouldAdvance(globalCtx) && (globalCtx->msgCtx.currentTextId == 0x1069)) { + case TEXT_STATE_CHOICE: + case TEXT_STATE_5: + case TEXT_STATE_DONE: + if (Message_ShouldAdvance(play) && (play->msgCtx.currentTextId == 0x1069)) { this->unk_32C |= 4; ActorCutscene_Stop(this->cutscenes[0]); player->stateFlags2 &= ~0x20000000; - func_80B5CE6C(this, globalCtx); + func_80B5CE6C(this, play); } break; } } -void func_80B5CE6C(EnOt* this, GlobalContext* globalCtx) { +void func_80B5CE6C(EnOt* this, PlayState* play) { this->unk_384 = 0; this->unk_32C |= 0x20; - SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimations, 0, &this->animIdx); + SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimations, 0, &this->animIndex); this->actionFunc = func_80B5CEC8; } -void func_80B5CEC8(EnOt* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); +void func_80B5CEC8(EnOt* this, PlayState* play) { + Player* player = GET_PLAYER(play); s32 pad; this->actor.textId = 0; - if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { - func_80B5D114(this, globalCtx); + if (Actor_ProcessTalkRequest(&this->actor, &play->state)) { + func_80B5D114(this, play); return; } Math_SmoothStepToS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer, 3, 0xE38, 0x38E); if (this->unk_32C & 0x800) { this->actor.flags |= ACTOR_FLAG_10000; - func_800B8500(&this->actor, globalCtx, this->actor.xzDistToPlayer, this->actor.playerHeightRel, 0); + func_800B8500(&this->actor, play, this->actor.xzDistToPlayer, this->actor.playerHeightRel, PLAYER_AP_NONE); } else { 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); + func_800B8614(&this->actor, play, 130.0f); } } @@ -711,39 +711,39 @@ 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; this->unk_360->unk_32C &= ~0x800; - func_80B5BDA8(this, globalCtx); - func_80B5BE88(this->unk_360, globalCtx); + func_80B5BDA8(this, play); + func_80B5BE88(this->unk_360, play); return; } } if (this->unk_32C & 0x1000) { this->unk_388 = 1; - func_80B5BDA8(this, globalCtx); - func_80B5BE88(this->unk_360, globalCtx); + func_80B5BDA8(this, play); + func_80B5BE88(this->unk_360, play); } } -void func_80B5D114(EnOt* this, GlobalContext* globalCtx) { - SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimations, 0, &this->animIdx); +void func_80B5D114(EnOt* this, PlayState* play) { + SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimations, 0, &this->animIndex); this->actionFunc = func_80B5D160; } -void func_80B5D160(EnOt* this, GlobalContext* globalCtx) { +void func_80B5D160(EnOt* this, PlayState* play) { u16 phi_a1; s32 temp; - switch (Message_GetState(&globalCtx->msgCtx)) { - case 0: + switch (Message_GetState(&play->msgCtx)) { + case TEXT_STATE_NONE: temp = Math_SmoothStepToS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer, 3, 0xE38, 0x38E); this->actor.world.rot.y = this->actor.shape.rot.y; - if (!temp) { + if (temp == 0) { switch (this->unk_384) { case 0: if ((this->unk_33C != 1) && (this->unk_33C == 2)) { @@ -753,7 +753,7 @@ void func_80B5D160(EnOt* this, GlobalContext* globalCtx) { } else { phi_a1 = 0x1069; } - } else if (Flags_GetSwitch(globalCtx, ENOT_GET_3F80(&this->actor))) { + } else if (Flags_GetSwitch(play, ENOT_GET_3F80(&this->actor))) { if (gSaveContext.save.weekEventReg[23] & 0x10) { phi_a1 = 0x106C; } else { @@ -765,51 +765,51 @@ void func_80B5D160(EnOt* this, GlobalContext* globalCtx) { } else { phi_a1 = 0x10A5; } - Message_StartTextbox(globalCtx, phi_a1, &this->actor); - func_80B5D114(this, globalCtx); + Message_StartTextbox(play, phi_a1, &this->actor); + func_80B5D114(this, play); break; case 1: - Message_StartTextbox(globalCtx, 0x106D, &this->actor); - func_80B5D114(this, globalCtx); + Message_StartTextbox(play, 0x106D, &this->actor); + func_80B5D114(this, play); break; } break; } break; - case 1: - case 2: - case 3: + case TEXT_STATE_1: + case TEXT_STATE_CLOSING: + case TEXT_STATE_3: break; - case 4: - case 5: - case 6: - if (Message_ShouldAdvance(globalCtx)) { - switch (globalCtx->msgCtx.currentTextId) { + case TEXT_STATE_CHOICE: + case TEXT_STATE_5: + case TEXT_STATE_DONE: + if (Message_ShouldAdvance(play)) { + switch (play->msgCtx.currentTextId) { default: case 0x1068: case 0x106B: case 0x106C: - func_80B5D648(this, globalCtx); + func_80B5D648(this, play); break; case 0x1069: this->unk_32C |= 4; case 0x106A: - func_80B5CE6C(this, globalCtx); + func_80B5CE6C(this, play); break; case 0x10A5: - func_801477B4(globalCtx); - func_80B5CE6C(this, globalCtx); + func_801477B4(play); + func_80B5CE6C(this, play); break; case 0x106D: - func_801477B4(globalCtx); - func_80B5C154(this, globalCtx); + func_801477B4(play); + func_80B5C154(this, play); break; } } @@ -817,7 +817,7 @@ void func_80B5D160(EnOt* this, GlobalContext* globalCtx) { } } -s32 EnOt_ActorPathing_Move(GlobalContext* globalCtx, ActorPathing* actorPath) { +s32 EnOt_ActorPathing_Move(PlayState* play, ActorPathing* actorPath) { Actor* thisx = actorPath->actor; EnOt* this = (EnOt*)thisx; f32 sp24 = Math_CosS(-thisx->world.rot.x) * thisx->speedXZ; @@ -834,7 +834,7 @@ s32 EnOt_ActorPathing_Move(GlobalContext* globalCtx, ActorPathing* actorPath) { return false; } -s32 EnOt_ActorPathing_UpdateActorInfo(GlobalContext* globalCtx, ActorPathing* actorPath) { +s32 EnOt_ActorPathing_UpdateActorInfo(PlayState* play, ActorPathing* actorPath) { Actor* thisx = actorPath->actor; s32 ret = false; s32 pad; @@ -875,27 +875,27 @@ s32 EnOt_ActorPathing_UpdateActorInfo(GlobalContext* globalCtx, ActorPathing* ac return ret; } -void func_80B5D648(EnOt* this, GlobalContext* globalCtx) { - func_80B5B2E0(globalCtx, &this->actor.world.pos, this->unk_346, &this->unk_348, &this->unk_340); +void func_80B5D648(EnOt* this, PlayState* play) { + func_80B5B2E0(play, &this->actor.world.pos, this->unk_346, &this->unk_348, &this->unk_340); Math_Vec3f_Copy(&this->unk_330, &this->actor.world.pos); - SubS_ActorPathing_Init(globalCtx, &this->unk_330, &this->actor, &this->actorPath, globalCtx->setupPathList, - this->unk_346, 0, 0, this->unk_340, 0); + SubS_ActorPathing_Init(play, &this->unk_330, &this->actor, &this->actorPath, play->setupPathList, this->unk_346, 0, + 0, this->unk_340, 0); this->unk_32C = 0; 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; - SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimations, 1, &this->animIdx); + SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimations, 1, &this->animIndex); this->actor.flags |= ACTOR_FLAG_8000000; this->actor.flags &= ~(ACTOR_FLAG_1 | ACTOR_FLAG_8); - Flags_SetSwitch(globalCtx, ENOT_GET_3F80(&this->actor)); + Flags_SetSwitch(play, ENOT_GET_3F80(&this->actor)); this->actionFunc = func_80B5D750; } -void func_80B5D750(EnOt* this, GlobalContext* globalCtx) { +void func_80B5D750(EnOt* this, PlayState* play) { if (!(this->unk_32C & 1) && !(this->unk_32C & 2)) { - SubS_ActorPathing_Update(globalCtx, &this->actorPath, SubS_ActorPathing_ComputePointInfo, + SubS_ActorPathing_Update(play, &this->actorPath, SubS_ActorPathing_ComputePointInfo, EnOt_ActorPathing_UpdateActorInfo, EnOt_ActorPathing_Move, SubS_ActorPathing_SetNextPoint); } @@ -918,36 +918,36 @@ void func_80B5D750(EnOt* this, GlobalContext* globalCtx) { this->actor.flags &= ~ACTOR_FLAG_8000000; this->actor.flags |= (ACTOR_FLAG_1 | ACTOR_FLAG_8); if (D_80B5E884 != 0) { - func_80B5C9A8(this, globalCtx); + func_80B5C9A8(this, play); } else { - func_80B5CBA0(this, globalCtx); + func_80B5CBA0(this, play); } } } -void EnOt_Update(Actor* thisx, GlobalContext* globalCtx) { +void EnOt_Update(Actor* thisx, PlayState* play) { s32 pad; EnOt* this = THIS; - if ((this->animIdx == 1) && Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) { + if ((this->animIndex == 1) && Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) { Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_SEAHORSE_SWIM); } - this->actionFunc(this, globalCtx); + this->actionFunc(this, play); if (this->actor.bgCheckFlags & 0x20) { if (DECR(this->unk_354) == 0) { if (this->actor.flags & ACTOR_FLAG_40) { s32 i; for (i = 0; i < 2; i++) { - EffectSsBubble_Spawn(globalCtx, &this->actor.world.pos, 0.0f, 20.0f, 5.0f, 0.1f); + EffectSsBubble_Spawn(play, &this->actor.world.pos, 0.0f, 20.0f, 5.0f, 0.1f); } this->unk_354 = (Rand_ZeroOne() * 10.0f) + 10.0f; } } } - Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 0.0f, 10.0f, 0.0f, 4); + Actor_UpdateBgCheckInfo(play, &this->actor, 0.0f, 10.0f, 0.0f, 4); if (this->actor.world.pos.y <= this->actor.floorHeight + 50.0f) { this->actor.world.pos.y = this->actor.floorHeight + 50.0f; @@ -957,21 +957,21 @@ void EnOt_Update(Actor* thisx, GlobalContext* globalCtx) { Actor_SetFocus(&this->actor, 12.0f); SkelAnime_Update(&this->skelAnime); Collider_UpdateCylinder(&this->actor, &this->collider); - CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + CollisionCheck_SetOC(play, &play->colChkCtx, &this->collider.base); func_80B5BB38(&this->unk_747, &this->unk_744, 0.7f); if (this->unk_32C & 0x400) { func_80B5BAAC(&this->lightInfo, &this->unk_378, &this->unk_747, 0xD2); } - func_80B5E078(globalCtx, this->unk_3A4, 10); + func_80B5E078(play, this->unk_3A4, 10); } -void func_80B5DAEC(Actor* thisx, GlobalContext* globalCtx) { +void func_80B5DAEC(Actor* thisx, PlayState* play) { s32 pad; EnOt* this = THIS; - this->actionFunc(this, globalCtx); + this->actionFunc(this, play); Actor_SetFocus(&this->actor, 12.0f); SkelAnime_Update(&this->skelAnime); func_80B5BB38(&this->unk_747, &this->unk_744, 0.7f); @@ -980,17 +980,17 @@ void func_80B5DAEC(Actor* thisx, GlobalContext* globalCtx) { } } -void func_80B5DB6C(Actor* thisx, GlobalContext* globalCtx) { +void func_80B5DB6C(Actor* thisx, PlayState* play) { s32 pad; EnOt* this = THIS; - Player* player = GET_PLAYER(globalCtx); + Player* player = GET_PLAYER(play); 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); - if (Actor_SpawnAsChildAndCutscene(&globalCtx->actorCtx, globalCtx, ACTOR_EN_OT, sp50.x, sp50.y, sp50.z, 0, + func_80B5B2E0(play, &this->actor.world.pos, ENOT_GET_7F(&this->actor), &sp50, &this->unk_340); + if (Actor_SpawnAsChildAndCutscene(&play->actorCtx, play, ACTOR_EN_OT, sp50.x, sp50.y, sp50.z, 0, this->actor.shape.rot.y, 1, ENOT_GET_3FFF(&this->actor) | 0x8000, this->actor.cutscene, this->actor.unk20, NULL) != NULL) { this->unk_32C |= 8; @@ -999,7 +999,7 @@ void func_80B5DB6C(Actor* thisx, GlobalContext* globalCtx) { s32 sp4C = false; if (gSaveContext.save.weekEventReg[13] & 1) { - if (!SurfaceType_IsHorseBlocked(&globalCtx->colCtx, player->actor.floorPoly, player->actor.floorBgId)) { + if (!SurfaceType_IsHorseBlocked(&play->colCtx, player->actor.floorPoly, player->actor.floorBgId)) { sp4C = true; } } @@ -1013,35 +1013,35 @@ void func_80B5DB6C(Actor* thisx, GlobalContext* globalCtx) { temp->actor.cutscene = this->actor.cutscene; this->unk_32C |= 8; } - } else if (SurfaceType_IsHorseBlocked(&globalCtx->colCtx, player->actor.floorPoly, player->actor.floorBgId)) { + } else if (SurfaceType_IsHorseBlocked(&play->colCtx, player->actor.floorPoly, player->actor.floorBgId)) { player->unk_B2B = 29; } } } -void EnOt_Draw(Actor* thisx, GlobalContext* globalCtx) { +void EnOt_Draw(Actor* thisx, PlayState* play) { s32 pad[2]; EnOt* this = THIS; Gfx* gfx; - Matrix_StatePush(); - func_80B5E1D8(globalCtx, this->unk_3A4, 10); - Matrix_StatePop(); + Matrix_Push(); + func_80B5E1D8(play, this->unk_3A4, 10); + Matrix_Pop(); - OPEN_DISPS(globalCtx->state.gfxCtx); + OPEN_DISPS(play->state.gfxCtx); POLY_OPA_DISP = Gfx_CallSetupDL(POLY_OPA_DISP, 25); POLY_XLU_DISP = func_8012C2B4(POLY_XLU_DISP); - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->state.gfxCtx); - 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); + AnimatedMat_Draw(play, Lib_SegmentedToVirtual(object_ot_Matanimheader_0005F8)); + SkelAnime_DrawFlexOpa(play, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, NULL, + EnOt_PostLimbDraw, &this->actor); + 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); + OPEN_DISPS(play->state.gfxCtx); gfx = func_8012C7FC(POLY_XLU_DISP); @@ -1050,29 +1050,29 @@ void EnOt_Draw(Actor* thisx, GlobalContext* globalCtx) { 0); gSPDisplayList(&gfx[2], gameplay_keep_DL_029CB0); gDPSetPrimColor(&gfx[3], 0, 0, this->unk_747.r, this->unk_747.g, this->unk_747.b, 50); - gSPMatrix(&gfx[4], Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPMatrix(&gfx[4], Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(&gfx[5], gameplay_keep_DL_029CF0); POLY_XLU_DISP = &gfx[6]; - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->state.gfxCtx); } -void EnOt_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx) { +void EnOt_PostLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx) { static Vec3f D_80B5E410 = { 400.0f, 600.0f, 0.0f }; EnOt* this = THIS; if (limbIndex == 4) { - OPEN_DISPS(globalCtx->state.gfxCtx); + OPEN_DISPS(play->state.gfxCtx); Gfx* gfx = POLY_OPA_DISP; 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); + CLOSE_DISPS(play->state.gfxCtx); } else if (limbIndex == 1) { - Matrix_GetStateTranslation(&this->unk_378); + Matrix_MultZero(&this->unk_378); this->unk_32C |= 0x400; } } @@ -1106,10 +1106,10 @@ EnOtUnkStruct* func_80B5DF58(EnOtUnkStruct* arg0, u8 arg1, Vec3f* arg2, Vec3s* a return arg0; } -void func_80B5E078(GlobalContext* globalCtx, EnOtUnkStruct* arg1, s32 arg2) { +void func_80B5E078(PlayState* play, EnOtUnkStruct* arg1, s32 arg2) { Vec3f sp54; s32 i; - s16 temp = Camera_GetInputDirYaw(GET_ACTIVE_CAM(globalCtx)); + s16 temp = Camera_GetInputDirYaw(GET_ACTIVE_CAM(play)); for (i = 0; i < arg2; i++, arg1++) { if ((arg1->unk_00 == 1) || (arg1->unk_00 == 2)) { @@ -1123,21 +1123,21 @@ 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--; } } } -void func_80B5E1D8(GlobalContext* globalCtx, EnOtUnkStruct* arg1, s32 arg2) { +void func_80B5E1D8(PlayState* play, EnOtUnkStruct* arg1, s32 arg2) { s32 i; s32 flag = 0; - OPEN_DISPS(globalCtx->state.gfxCtx); + OPEN_DISPS(play->state.gfxCtx); - POLY_OPA_DISP = func_801660B8(globalCtx, POLY_OPA_DISP); + POLY_OPA_DISP = func_801660B8(play, POLY_OPA_DISP); POLY_OPA_DISP = func_8012C724(POLY_OPA_DISP); for (i = 0; i < arg2; i++, arg1++) { @@ -1145,19 +1145,18 @@ void func_80B5E1D8(GlobalContext* globalCtx, EnOtUnkStruct* arg1, s32 arg2) { if (!flag) { gSPDisplayList(POLY_OPA_DISP++, object_ot_DL_000040); flag = true; - if (globalCtx) {} + if (play) {} } - Matrix_InsertTranslation(arg1->unk_0C.x, arg1->unk_0C.y, arg1->unk_0C.z, MTXMODE_NEW); - Matrix_RotateY(BINANG_ROT180(Camera_GetCamDirYaw(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(play))), 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)); - gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), - G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_OPA_DISP++, object_ot_DL_000078); } } - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->state.gfxCtx); } 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 902cbecd7..5399e2278 100644 --- a/src/overlays/actors/ovl_En_Ot/z_en_ot.h +++ b/src/overlays/actors/ovl_En_Ot/z_en_ot.h @@ -5,7 +5,7 @@ struct EnOt; -typedef void (*EnOtActionFunc)(struct EnOt*, GlobalContext*); +typedef void (*EnOtActionFunc)(struct EnOt*, PlayState*); #define ENOT_GET_7F(thisx) ((thisx)->params & 0x7F) #define ENOT_GET_3F80(thisx) (((thisx)->params >> 7) & 0x7F) @@ -29,39 +29,39 @@ typedef struct { } EnOtUnkStruct; // size = 0x5C typedef struct EnOt { - /* 0x0000 */ Actor actor; - /* 0x0144 */ EnOtActionFunc actionFunc; - /* 0x0148 */ SkelAnime skelAnime; - /* 0x018C */ ColliderCylinder collider; - /* 0x01D8 */ Vec3s jointTable[19]; - /* 0x024A */ Vec3s morphTable[19]; - /* 0x02BC */ s32 animIdx; - /* 0x02C0 */ ActorPathing actorPath; - /* 0x032C */ u16 unk_32C; - /* 0x0330 */ Vec3f unk_330; - /* 0x033C */ s32 unk_33C; - /* 0x0340 */ s32 unk_340; - /* 0x0344 */ s16 unk_344; - /* 0x0346 */ s16 unk_346; - /* 0x0348 */ Vec3f unk_348; - /* 0x0354 */ s16 unk_354; - /* 0x0356 */ s16 cutscenes[4]; - /* 0x0360 */ struct EnOt* unk_360; - /* 0x0364 */ LightNode* lightNode; - /* 0x0368 */ LightInfo lightInfo; - /* 0x0378 */ Vec3f unk_378; - /* 0x0384 */ u8 unk_384; - /* 0x0388 */ s32 unk_388; - /* 0x038C */ s32 unk_38C; - /* 0x0390 */ s16 unk_390; - /* 0x0394 */ Vec3f unk_394; - /* 0x03A0 */ s16 unk_3A0; - /* 0x03A4 */ EnOtUnkStruct unk_3A4[10]; - /* 0x073C */ s16 unk_73C; - /* 0x0740 */ f32 unk_740; - /* 0x0744 */ Color_RGB8 unk_744; - /* 0x0747 */ Color_RGB8 unk_747; - /* 0x074C */ Vec3f unk_74C; + /* 0x000 */ Actor actor; + /* 0x144 */ EnOtActionFunc actionFunc; + /* 0x148 */ SkelAnime skelAnime; + /* 0x18C */ ColliderCylinder collider; + /* 0x1D8 */ Vec3s jointTable[19]; + /* 0x24A */ Vec3s morphTable[19]; + /* 0x2BC */ s32 animIndex; + /* 0x2C0 */ ActorPathing actorPath; + /* 0x32C */ u16 unk_32C; + /* 0x330 */ Vec3f unk_330; + /* 0x33C */ s32 unk_33C; + /* 0x340 */ s32 unk_340; + /* 0x344 */ s16 unk_344; + /* 0x346 */ s16 unk_346; + /* 0x348 */ Vec3f unk_348; + /* 0x354 */ s16 unk_354; + /* 0x356 */ s16 cutscenes[4]; + /* 0x360 */ struct EnOt* unk_360; + /* 0x364 */ LightNode* lightNode; + /* 0x368 */ LightInfo lightInfo; + /* 0x378 */ Vec3f unk_378; + /* 0x384 */ u8 unk_384; + /* 0x388 */ s32 unk_388; + /* 0x38C */ s32 getItemId; + /* 0x390 */ s16 unk_390; + /* 0x394 */ Vec3f unk_394; + /* 0x3A0 */ s16 unk_3A0; + /* 0x3A4 */ EnOtUnkStruct unk_3A4[10]; + /* 0x73C */ s16 unk_73C; + /* 0x740 */ f32 unk_740; + /* 0x744 */ Color_RGB8 unk_744; + /* 0x747 */ Color_RGB8 unk_747; + /* 0x74C */ Vec3f unk_74C; } EnOt; // size = 0x758 extern const ActorInit En_Ot_InitVars; diff --git a/src/overlays/actors/ovl_En_Owl/z_en_owl.c b/src/overlays/actors/ovl_En_Owl/z_en_owl.c index ab8f721ae..f1bfcd57f 100644 --- a/src/overlays/actors/ovl_En_Owl/z_en_owl.c +++ b/src/overlays/actors/ovl_En_Owl/z_en_owl.c @@ -11,35 +11,35 @@ #define THIS ((EnOwl*)thisx) -void EnOwl_Init(Actor* thisx, GlobalContext* globalCtx); -void EnOwl_Destroy(Actor* thisx, GlobalContext* globalCtx); -void EnOwl_Update(Actor* thisx, GlobalContext* globalCtx); -void EnOwl_Draw(Actor* thisx, GlobalContext* globalCtx); +void EnOwl_Init(Actor* thisx, PlayState* play); +void EnOwl_Destroy(Actor* thisx, PlayState* play); +void EnOwl_Update(Actor* thisx, PlayState* play); +void EnOwl_Draw(Actor* thisx, PlayState* play); -void func_8095AB1C(EnOwl* this, GlobalContext* globalCtx); -void func_8095ABF0(EnOwl* this, GlobalContext* globalCtx); -void func_8095AD54(EnOwl* this, GlobalContext* globalCtx); -void func_8095AE00(EnOwl* this, GlobalContext* globalCtx); -void func_8095AE60(EnOwl* this, GlobalContext* globalCtx); -void func_8095AEC0(EnOwl* this, GlobalContext* globalCtx); -void func_8095AF2C(EnOwl* this, GlobalContext* globalCtx); -void func_8095AFEC(EnOwl* this, GlobalContext* globalCtx); -void func_8095B254(EnOwl* this, GlobalContext* globalCtx); -void func_8095B2F8(EnOwl* this, GlobalContext* globalCtx); -void func_8095B650(EnOwl* this, GlobalContext* globalCtx); -void func_8095B6C8(EnOwl* this, GlobalContext* globalCtx); -void func_8095B76C(EnOwl* this, GlobalContext* globalCtx); -void func_8095B960(EnOwl* this, GlobalContext* globalCtx); -void func_8095BA84(EnOwl* this, GlobalContext* globalCtx); -void func_8095BE0C(EnOwl* this, GlobalContext* globalCtx); -void func_8095BF20(EnOwl* this, GlobalContext* globalCtx); -void func_8095BF58(EnOwl* this, GlobalContext* globalCtx); -void func_8095C1C8(EnOwl* this, GlobalContext* globalCtx); +void func_8095AB1C(EnOwl* this, PlayState* play); +void func_8095ABF0(EnOwl* this, PlayState* play); +void func_8095AD54(EnOwl* this, PlayState* play); +void func_8095AE00(EnOwl* this, PlayState* play); +void func_8095AE60(EnOwl* this, PlayState* play); +void func_8095AEC0(EnOwl* this, PlayState* play); +void func_8095AF2C(EnOwl* this, PlayState* play); +void func_8095AFEC(EnOwl* this, PlayState* play); +void func_8095B254(EnOwl* this, PlayState* play); +void func_8095B2F8(EnOwl* this, PlayState* play); +void func_8095B650(EnOwl* this, PlayState* play); +void func_8095B6C8(EnOwl* this, PlayState* play); +void func_8095B76C(EnOwl* this, PlayState* play); +void func_8095B960(EnOwl* this, PlayState* play); +void func_8095BA84(EnOwl* this, PlayState* play); +void func_8095BE0C(EnOwl* this, PlayState* play); +void func_8095BF20(EnOwl* this, PlayState* play); +void func_8095BF58(EnOwl* this, PlayState* play); +void func_8095C1C8(EnOwl* this, PlayState* play); void func_8095C328(EnOwl* this); void func_8095C408(EnOwl* this); void func_8095C484(EnOwl* this); -void func_8095CCF4(Actor* thisx, GlobalContext* globalCtx); -void func_8095D074(Actor* thisx, GlobalContext* globalCtx); +void func_8095CCF4(Actor* thisx, PlayState* play); +void func_8095D074(Actor* thisx, PlayState* play); void EnOwl_ChangeMode(EnOwl* this, EnOwlActionFunc actionFunc, EnOwlFunc unkFunc, SkelAnime* skelAnime, AnimationHeader* animation, f32 morphFrames); @@ -87,18 +87,18 @@ static InitChainEntry sInitChain[] = { ICHAIN_F32(uncullZoneDownward, 2400, ICHAIN_STOP), }; -void func_8095A510(EnOwl* this, GlobalContext* globalCtx) { +void func_8095A510(EnOwl* this, PlayState* play) { this->unk_3FC = ENOWL_GET_F000(&this->actor); if (this->unk_3FC == 15) { this->unk_3FC = -1; this->path = NULL; } else { this->unk_3F8 = 0; - this->path = &globalCtx->setupPathList[this->unk_3FC]; + this->path = &play->setupPathList[this->unk_3FC]; } } -void EnOwl_Init(Actor* thisx, GlobalContext* globalCtx) { +void EnOwl_Init(Actor* thisx, PlayState* play) { s32 pad; EnOwl* this = THIS; s32 i; @@ -128,11 +128,11 @@ void EnOwl_Init(Actor* thisx, GlobalContext* globalCtx) { } ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 36.0f); - SkelAnime_InitFlex(globalCtx, &this->skelAnime1, &object_owl_Skel_00C5F8, &object_owl_Anim_001ADC, - this->jointTable1, this->morphTable1, 21); - SkelAnime_InitFlex(globalCtx, &this->skelAnime2, &object_owl_Skel_0105C0, &object_owl_Anim_00CDB0, - this->jointTable2, this->morphTable2, 16); - Collider_InitAndSetCylinder(globalCtx, &this->collider, &this->actor, &sCylinderInit); + SkelAnime_InitFlex(play, &this->skelAnime1, &object_owl_Skel_00C5F8, &object_owl_Anim_001ADC, this->jointTable1, + this->morphTable1, 21); + SkelAnime_InitFlex(play, &this->skelAnime2, &object_owl_Skel_0105C0, &object_owl_Anim_00CDB0, this->jointTable2, + this->morphTable2, 16); + Collider_InitAndSetCylinder(play, &this->collider, &this->actor, &sCylinderInit); this->actor.colChkInfo.mass = MASS_IMMOVABLE; this->actor.terminalVelocity = -10.0f; this->actor.targetArrowOffset = 500.0f; @@ -150,7 +150,7 @@ void EnOwl_Init(Actor* thisx, GlobalContext* globalCtx) { switch (owlType) { case ENOWL_GET_TYPE_1: - if ((switchFlag < 0x7F) && Flags_GetSwitch(globalCtx, switchFlag)) { + if ((switchFlag < 0x7F) && Flags_GetSwitch(play, switchFlag)) { Actor_MarkForDeath(&this->actor); return; } @@ -174,7 +174,7 @@ void EnOwl_Init(Actor* thisx, GlobalContext* globalCtx) { this->unk_3DA = 0; this->unk_3F0 = this->actor.home.pos.y; this->unk_3EC = this->actor.home.rot.y; - func_8095A510(this, globalCtx); + func_8095A510(this, play); switch (owlType) { case ENOWL_GET_TYPE_1: @@ -206,43 +206,43 @@ void EnOwl_Init(Actor* thisx, GlobalContext* globalCtx) { } } -void EnOwl_Destroy(Actor* thisx, GlobalContext* globalCtx) { +void EnOwl_Destroy(Actor* thisx, PlayState* play) { EnOwl* this = THIS; if (ENOWL_GET_TYPE(&this->actor) != ENOWL_GET_TYPE_30) { - Collider_DestroyCylinder(globalCtx, &this->collider); + Collider_DestroyCylinder(play, &this->collider); } } -void func_8095A920(EnOwl* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); +void func_8095A920(EnOwl* this, PlayState* play) { + Player* player = GET_PLAYER(play); this->actor.world.rot.y = Math_Vec3f_Yaw(&this->actor.world.pos, &player->actor.world.pos); Math_SmoothStepToS(&this->actor.shape.rot.y, this->actor.world.rot.y, 6, 0x3E8, 0xC8); } -s32 func_8095A978(EnOwl* this, GlobalContext* globalCtx, u16 textId, f32 targetDist, f32 arg4) { - if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { +s32 func_8095A978(EnOwl* this, PlayState* play, u16 textId, f32 targetDist, f32 arg4) { + if (Actor_ProcessTalkRequest(&this->actor, &play->state)) { return true; } this->actor.textId = textId; if (this->actor.xzDistToPlayer < targetDist) { this->actor.flags |= ACTOR_FLAG_10000; - func_800B8500(&this->actor, globalCtx, targetDist, arg4, EXCH_ITEM_NONE); + func_800B8500(&this->actor, play, targetDist, arg4, PLAYER_AP_NONE); } return false; } -s32 func_8095A9FC(EnOwl* this, GlobalContext* globalCtx, u16 textId) { - if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { +s32 func_8095A9FC(EnOwl* this, PlayState* play, u16 textId) { + if (Actor_ProcessTalkRequest(&this->actor, &play->state)) { return true; } this->actor.textId = textId; if (this->actor.xzDistToPlayer < 120.0f) { - func_800B8500(&this->actor, globalCtx, 350.0f, 1000.0f, EXCH_ITEM_NONE); + func_800B8500(&this->actor, play, 350.0f, 1000.0f, PLAYER_AP_NONE); } return false; @@ -254,19 +254,19 @@ void func_8095AA70(EnOwl* this) { this->blinkTimer = Rand_S16Offset(60, 60); } -void func_8095AAD0(EnOwl* this, GlobalContext* globalCtx) { +void func_8095AAD0(EnOwl* this, PlayState* play) { s32 switchFlag = ENOWL_GET_SWITCHFLAG(&this->actor); if (switchFlag < 0x7F) { - Flags_SetSwitch(globalCtx, switchFlag); + Flags_SetSwitch(play, switchFlag); } func_8095AA70(this); } -void func_8095AB1C(EnOwl* this, GlobalContext* globalCtx) { +void func_8095AB1C(EnOwl* this, PlayState* play) { if ((this->unk_3DA % 64) == 0) { - func_8095AAD0(this, globalCtx); + func_8095AAD0(this, play); } } @@ -290,20 +290,20 @@ void func_8095ABA8(EnOwl* this) { this->unk_409 = 4; } -void func_8095ABF0(EnOwl* this, GlobalContext* globalCtx) { - if (Actor_TextboxIsClosing(&this->actor, globalCtx)) { +void func_8095ABF0(EnOwl* this, PlayState* play) { + if (Actor_TextboxIsClosing(&this->actor, play)) { Audio_QueueSeqCmd(0x110000FF); - func_8095AAD0(this, globalCtx); + func_8095AAD0(this, play); this->actor.flags &= ~ACTOR_FLAG_10000; } } // Unused? -void func_8095AC50(EnOwl* this, GlobalContext* globalCtx) { - if (Actor_TextboxIsClosing(&this->actor, globalCtx)) { +void func_8095AC50(EnOwl* this, PlayState* play) { + if (Actor_TextboxIsClosing(&this->actor, play)) { Audio_QueueSeqCmd(0x110000FF); if ((this->unk_3DA % 64) == 0) { - func_8095AAD0(this, globalCtx); + func_8095AAD0(this, play); } else { this->actionFlags &= ~2; func_8095ABA8(this); @@ -323,68 +323,68 @@ void func_8095ACEC(EnOwl* this) { } } -void func_8095AD54(EnOwl* this, GlobalContext* globalCtx) { - if ((Message_GetState(&globalCtx->msgCtx) == 4) && Message_ShouldAdvance(globalCtx)) { - switch (globalCtx->msgCtx.choiceIndex) { +void func_8095AD54(EnOwl* this, PlayState* play) { + if ((Message_GetState(&play->msgCtx) == TEXT_STATE_CHOICE) && Message_ShouldAdvance(play)) { + switch (play->msgCtx.choiceIndex) { case OWL_REPEAT: - func_80151938(globalCtx, 0x7D1); + func_80151938(play, 0x7D1); this->actionFunc = func_8095AE00; break; case OWL_OK: - func_80151938(globalCtx, 0x7D3); + func_80151938(play, 0x7D3); this->actionFunc = func_8095ABF0; break; } } } -void func_8095AE00(EnOwl* this, GlobalContext* globalCtx) { - if ((Message_GetState(&globalCtx->msgCtx) == 5) && Message_ShouldAdvance(globalCtx)) { - func_80151938(globalCtx, 0x7D2); +void func_8095AE00(EnOwl* this, PlayState* play) { + if ((Message_GetState(&play->msgCtx) == TEXT_STATE_5) && Message_ShouldAdvance(play)) { + func_80151938(play, 0x7D2); this->actionFunc = func_8095AD54; } } -void func_8095AE60(EnOwl* this, GlobalContext* globalCtx) { - if ((Message_GetState(&globalCtx->msgCtx) == 5) && Message_ShouldAdvance(globalCtx)) { - func_80151938(globalCtx, 0x7D1); +void func_8095AE60(EnOwl* this, PlayState* play) { + if ((Message_GetState(&play->msgCtx) == TEXT_STATE_5) && Message_ShouldAdvance(play)) { + func_80151938(play, 0x7D1); this->actionFunc = func_8095AE00; } } -void func_8095AEC0(EnOwl* this, GlobalContext* globalCtx) { - func_8095A920(this, globalCtx); - if (func_8095A978(this, globalCtx, 0x7D0, 360.0f, 200.0f)) { +void func_8095AEC0(EnOwl* this, PlayState* play) { + func_8095A920(this, play); + if (func_8095A978(this, play, 0x7D0, 360.0f, 200.0f)) { func_801A3098(NA_BGM_OWL); this->actionFunc = func_8095AE60; } } -void func_8095AF2C(EnOwl* this, GlobalContext* globalCtx) { - switch (Message_GetState(&globalCtx->msgCtx)) { - case 5: - if (Message_ShouldAdvance(globalCtx)) { - if (globalCtx->msgCtx.currentTextId == 0xBFE) { +void func_8095AF2C(EnOwl* this, PlayState* play) { + switch (Message_GetState(&play->msgCtx)) { + case TEXT_STATE_5: + if (Message_ShouldAdvance(play)) { + if (play->msgCtx.currentTextId == 0xBFE) { func_8095ACEC(this); - func_801477B4(globalCtx); + func_801477B4(play); this->actionFunc = func_8095ABF0; } else { - func_80151938(globalCtx, globalCtx->msgCtx.currentTextId + 1); + func_80151938(play, play->msgCtx.currentTextId + 1); } } break; - case 6: + case TEXT_STATE_DONE: func_8095ACEC(this); this->actionFunc = func_8095ABF0; break; } } -void func_8095AFEC(EnOwl* this, GlobalContext* globalCtx) { - func_8095A920(this, globalCtx); - if (func_8095A978(this, globalCtx, 0xBF6, 200.0f, 100.0f)) { +void func_8095AFEC(EnOwl* this, PlayState* play) { + func_8095A920(this, play); + if (func_8095A978(this, play, 0xBF6, 200.0f, 100.0f)) { func_801A3098(NA_BGM_OWL); this->actionFunc = func_8095AF2C; this->unk_406 = 0; @@ -423,7 +423,7 @@ void func_8095B158(EnOwl* this) { } } -void func_8095B1E4(EnOwl* this, GlobalContext* globalCtx) { +void func_8095B1E4(EnOwl* this, PlayState* play) { if (this->actor.speedXZ < 6.0f) { this->actor.speedXZ += 1.0f; } @@ -433,7 +433,7 @@ void func_8095B1E4(EnOwl* this, GlobalContext* globalCtx) { } } -void func_8095B254(EnOwl* this, GlobalContext* globalCtx) { +void func_8095B254(EnOwl* this, PlayState* play) { if (this->actor.speedXZ < 6.0f) { this->actor.speedXZ += 1.0f; } @@ -447,7 +447,7 @@ void func_8095B254(EnOwl* this, GlobalContext* globalCtx) { func_8095B158(this); } -void func_8095B2F8(EnOwl* this, GlobalContext* globalCtx) { +void func_8095B2F8(EnOwl* this, PlayState* play) { func_8095B06C(this); if (this->skelAnime1.curFrame >= 18.0f) { Math_SmoothStepToS(&this->actor.world.rot.y, this->unk_3EC, 2, 0x200, 0x80); @@ -457,17 +457,17 @@ void func_8095B2F8(EnOwl* this, GlobalContext* globalCtx) { if ((this->actor.shape.rot.y == this->unk_3EC) && (this->actionFlags & 1)) { this->actionFunc = func_8095B254; Animation_Change(this->skelAnime3, this->skelAnime3->animation, 1.0f, 19.0f, - Animation_GetLastFrame(&object_owl_Anim_001168), 2, 0.0f); + Animation_GetLastFrame(&object_owl_Anim_001168), ANIMMODE_ONCE, 0.0f); this->unk_414 = func_8095C484; } func_8095B158(this); } -void func_8095B3DC(EnOwl* this, GlobalContext* globalCtx) { +void func_8095B3DC(EnOwl* this, PlayState* play) { if (this->actionFlags & 1) { this->actionFunc = func_8095B2F8; - Animation_Change(this->skelAnime3, &object_owl_Anim_001168, 1.0f, 0.0f, 35.0f, 2, 0.0f); + Animation_Change(this->skelAnime3, &object_owl_Anim_001168, 1.0f, 0.0f, 35.0f, ANIMMODE_ONCE, 0.0f); this->unk_414 = func_8095C408; this->unk_3EC = 0x5500; this->actor.world.pos.y += 100.0f; @@ -475,8 +475,8 @@ void func_8095B3DC(EnOwl* this, GlobalContext* globalCtx) { } } -void func_8095B480(EnOwl* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); +void func_8095B480(EnOwl* this, PlayState* play) { + Player* player = GET_PLAYER(play); if (player->stateFlags3 & 0x10000000) { this->actor.textId = 0xBF1; @@ -490,49 +490,49 @@ void func_8095B480(EnOwl* this, GlobalContext* globalCtx) { this->unk_3F0 = this->actor.home.pos.y; this->unk_3EC = this->actor.home.rot.y; this->actor.world.pos = this->actor.home.pos; - func_8095A510(this, globalCtx); + func_8095A510(this, play); this->actor.speedXZ = 0.0f; this->actionFunc = func_8095BE0C; } } -void func_8095B574(EnOwl* this, GlobalContext* globalCtx) { - func_8095A920(this, globalCtx); - if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { +void func_8095B574(EnOwl* this, PlayState* play) { + func_8095A920(this, play); + if (Actor_ProcessTalkRequest(&this->actor, &play->state)) { this->actionFunc = func_8095BA84; func_801A3098(NA_BGM_OWL); this->actionFlags |= 0x40; this->unk_406 = 2; } else if (this->actor.xzDistToPlayer < 200.0f) { this->actor.flags |= ACTOR_FLAG_10000; - func_800B8500(&this->actor, globalCtx, 200.0f, 400.0f, EXCH_ITEM_NONE); + func_800B8500(&this->actor, play, 200.0f, 400.0f, PLAYER_AP_NONE); } else { this->actor.flags &= ~ACTOR_FLAG_10000; } - func_8095B480(this, globalCtx); + func_8095B480(this, play); } -void func_8095B650(EnOwl* this, GlobalContext* globalCtx) { +void func_8095B650(EnOwl* this, PlayState* play) { if (this->actionFlags & 1) { EnOwl_ChangeMode(this, func_8095B574, func_8095C484, &this->skelAnime2, &object_owl_Anim_00CDB0, 0.0f); this->actor.textId = 0xBF5; this->actionFlags &= ~8; } - func_8095B480(this, globalCtx); + func_8095B480(this, play); } -void func_8095B6C8(EnOwl* this, GlobalContext* globalCtx) { +void func_8095B6C8(EnOwl* this, PlayState* play) { if (this->actionFlags & 1) { Animation_Change(this->skelAnime3, &object_owl_Anim_00CB94, -1.0f, - Animation_GetLastFrame(&object_owl_Anim_00CB94), 0.0f, 2, 0.0f); + Animation_GetLastFrame(&object_owl_Anim_00CB94), 0.0f, ANIMMODE_ONCE, 0.0f); this->unk_414 = func_8095C484; this->actionFunc = func_8095B650; } func_8095B158(this); - func_8095B480(this, globalCtx); + func_8095B480(this, play); } -void func_8095B76C(EnOwl* this, GlobalContext* globalCtx) { +void func_8095B76C(EnOwl* this, PlayState* play) { s32 pad; s16 sp4A; f32 sp44 = Path_OrientAndGetDistSq(&this->actor, this->path, this->unk_3F8, &sp4A); @@ -556,7 +556,7 @@ void func_8095B76C(EnOwl* this, GlobalContext* globalCtx) { return; } - Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_OWL, this->actor.world.pos.x, this->actor.world.pos.y, + Actor_Spawn(&play->actorCtx, play, ACTOR_EN_OWL, this->actor.world.pos.x, this->actor.world.pos.y, this->actor.world.pos.z, 0, 0, 0, 0xF00); this->actor.home.rot.x++; if (this->actor.home.rot.x >= 3) { @@ -575,10 +575,10 @@ void func_8095B76C(EnOwl* this, GlobalContext* globalCtx) { func_8095B06C(this); func_8095B158(this); - func_8095B480(this, globalCtx); + func_8095B480(this, play); } -void func_8095B960(EnOwl* this, GlobalContext* globalCtx) { +void func_8095B960(EnOwl* this, PlayState* play) { if (this->skelAnime1.curFrame >= 18.0f) { Math_SmoothStepToS(&this->actor.world.rot.y, this->unk_3EC, 2, 0x200, 0x80); this->actor.shape.rot.y = this->actor.world.rot.y; @@ -590,54 +590,54 @@ void func_8095B960(EnOwl* this, GlobalContext* globalCtx) { } func_8095B158(this); - func_8095B480(this, globalCtx); + func_8095B480(this, play); } -void func_8095B9FC(EnOwl* this, GlobalContext* globalCtx) { +void func_8095B9FC(EnOwl* this, PlayState* play) { if (this->actionFlags & 1) { this->actionFunc = func_8095B960; - Animation_Change(this->skelAnime3, &object_owl_Anim_001168, 1.0f, 0.0f, 35.0f, 2, 0.0f); + Animation_Change(this->skelAnime3, &object_owl_Anim_001168, 1.0f, 0.0f, 35.0f, ANIMMODE_ONCE, 0.0f); this->unk_414 = func_8095C408; func_8095B0C8(this); } } -void func_8095BA84(EnOwl* this, GlobalContext* globalCtx) { - func_8095A920(this, globalCtx); +void func_8095BA84(EnOwl* this, PlayState* play) { + func_8095A920(this, play); - switch (Message_GetState(&globalCtx->msgCtx)) { - case 4: - if (Message_ShouldAdvance(globalCtx)) { - switch (globalCtx->msgCtx.currentTextId) { + switch (Message_GetState(&play->msgCtx)) { + case TEXT_STATE_CHOICE: + if (Message_ShouldAdvance(play)) { + switch (play->msgCtx.currentTextId) { case 0xBEC: - switch (globalCtx->msgCtx.choiceIndex) { + switch (play->msgCtx.choiceIndex) { case 0: func_8019F208(); if (gSaveContext.save.weekEventReg[9] & 0x40) { - func_80151938(globalCtx, 0xBF4); + func_80151938(play, 0xBF4); } else { gSaveContext.save.weekEventReg[9] |= 0x40; - func_80151938(globalCtx, 0xBED); + func_80151938(play, 0xBED); } break; case 1: func_8019F230(); - func_80151938(globalCtx, 0xBEF); + func_80151938(play, 0xBEF); break; } break; case 0xBF2: - switch (globalCtx->msgCtx.choiceIndex) { + switch (play->msgCtx.choiceIndex) { case 0: func_8019F208(); - func_80151938(globalCtx, 0xBF4); + func_80151938(play, 0xBF4); return; case 1: func_8019F230(); - func_80151938(globalCtx, 0xBF3); + func_80151938(play, 0xBF3); return; } break; @@ -645,26 +645,26 @@ void func_8095BA84(EnOwl* this, GlobalContext* globalCtx) { } break; - case 5: - if (Message_ShouldAdvance(globalCtx)) { - switch (globalCtx->msgCtx.currentTextId) { + case TEXT_STATE_5: + if (Message_ShouldAdvance(play)) { + switch (play->msgCtx.currentTextId) { case 0xBEA: gSaveContext.save.weekEventReg[9] |= 0x20; - func_80151938(globalCtx, 0xBEB); + func_80151938(play, 0xBEB); break; case 0xBEB: case 0xBF0: - func_80151938(globalCtx, 0xBEC); + func_80151938(play, 0xBEC); break; case 0xBED: case 0xBF4: - func_80151938(globalCtx, 0xBEE); + func_80151938(play, 0xBEE); break; case 0xBEE: - func_801477B4(globalCtx); + func_801477B4(play); Audio_QueueSeqCmd(0x110000FF); EnOwl_ChangeMode(this, func_8095B9FC, func_8095C484, &this->skelAnime1, &object_owl_Anim_00CB94, 0.0f); @@ -680,7 +680,7 @@ void func_8095BA84(EnOwl* this, GlobalContext* globalCtx) { case 0xBEF: case 0xBF3: - func_801477B4(globalCtx); + func_801477B4(play); Audio_QueueSeqCmd(0x110000FF); func_8095ACEC(this); this->actor.flags &= ~ACTOR_FLAG_10000; @@ -689,11 +689,11 @@ void func_8095BA84(EnOwl* this, GlobalContext* globalCtx) { break; case 0xBF1: - func_80151938(globalCtx, 0xBF2); + func_80151938(play, 0xBF2); break; case 0xBF5: - func_801477B4(globalCtx); + func_801477B4(play); Audio_QueueSeqCmd(0x110000FF); this->actor.flags &= ~ACTOR_FLAG_10000; EnOwl_ChangeMode(this, func_8095B3DC, func_8095C484, &this->skelAnime1, &object_owl_Anim_00CB94, @@ -709,35 +709,35 @@ void func_8095BA84(EnOwl* this, GlobalContext* globalCtx) { } } -void func_8095BE0C(EnOwl* this, GlobalContext* globalCtx) { - func_8095A920(this, globalCtx); - if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { +void func_8095BE0C(EnOwl* this, PlayState* play) { + func_8095A920(this, play); + if (Actor_ProcessTalkRequest(&this->actor, &play->state)) { this->actionFunc = func_8095BA84; func_801A3098(NA_BGM_OWL); this->unk_406 = 1; this->actionFlags |= 0x40; } else if (this->actor.textId == 0xBF0) { if (this->actor.isTargeted) { - func_800B8500(&this->actor, globalCtx, 200.0f, 200.0f, EXCH_ITEM_NONE); + func_800B8500(&this->actor, play, 200.0f, 200.0f, PLAYER_AP_NONE); } } else if (this->actor.xzDistToPlayer < 200.0f) { this->actor.flags |= ACTOR_FLAG_10000; - func_800B8500(&this->actor, globalCtx, 200.0f, 200.0f, EXCH_ITEM_NONE); + func_800B8500(&this->actor, play, 200.0f, 200.0f, PLAYER_AP_NONE); } else { this->actor.flags &= ~ACTOR_FLAG_10000; } } -void func_8095BF20(EnOwl* this, GlobalContext* globalCtx) { - func_8095A9FC(this, globalCtx, 0x7D0); +void func_8095BF20(EnOwl* this, PlayState* play) { + func_8095A9FC(this, play, 0x7D0); this->actionFunc = func_8095ABF0; } -void func_8095BF58(EnOwl* this, GlobalContext* globalCtx) { - func_8095A920(this, globalCtx); +void func_8095BF58(EnOwl* this, PlayState* play) { + func_8095A920(this, play); } -void func_8095BF78(EnOwl* this, GlobalContext* globalCtx) { +void func_8095BF78(EnOwl* this, PlayState* play) { this->actor.flags |= ACTOR_FLAG_20; if (this->actor.xzDistToPlayer > 6000.0f) { Actor_MarkForDeath(&this->actor); @@ -758,7 +758,7 @@ void func_8095BF78(EnOwl* this, GlobalContext* globalCtx) { } } -void func_8095C09C(EnOwl* this, GlobalContext* globalCtx) { +void func_8095C09C(EnOwl* this, PlayState* play) { if (this->skelAnime1.curFrame > 10.0f) { Math_SmoothStepToS(&this->actor.world.rot.y, this->unk_3EC, 2, 0x400, 0x40); this->actor.shape.rot.y = this->actor.world.rot.y; @@ -783,7 +783,7 @@ void func_8095C09C(EnOwl* this, GlobalContext* globalCtx) { func_8095B158(this); } -void func_8095C1C8(EnOwl* this, GlobalContext* globalCtx) { +void func_8095C1C8(EnOwl* this, PlayState* play) { if (this->actionFlags & 1) { this->unk_3EA = 3; EnOwl_ChangeMode(this, func_8095C09C, func_8095C484, &this->skelAnime1, &object_owl_Anim_001168, 0.0f); @@ -803,7 +803,7 @@ void func_8095C258(EnOwl* this) { this->unk_414 = func_8095C328; this->unk_3EA = 6; Animation_Change(this->skelAnime3, &object_owl_Anim_001ADC, 1.0f, 0.0f, - Animation_GetLastFrame(&object_owl_Anim_001ADC), 2, 5.0f); + Animation_GetLastFrame(&object_owl_Anim_001ADC), ANIMMODE_ONCE, 5.0f); } } @@ -812,19 +812,19 @@ void func_8095C328(EnOwl* this) { if (this->unk_3EA > 0) { this->unk_3EA--; Animation_Change(this->skelAnime3, this->skelAnime3->animation, 1.0f, 0.0f, - Animation_GetLastFrame(this->skelAnime3->animation), 2, 0.0f); + Animation_GetLastFrame(this->skelAnime3->animation), ANIMMODE_ONCE, 0.0f); } else { this->unk_3EA = 160; this->unk_414 = func_8095C258; Animation_Change(this->skelAnime3, &object_owl_Anim_00C6D4, 1.0f, 0.0f, - Animation_GetLastFrame(&object_owl_Anim_00C6D4), 0, 5.0f); + Animation_GetLastFrame(&object_owl_Anim_00C6D4), ANIMMODE_LOOP, 5.0f); } } } void func_8095C408(EnOwl* this) { if (SkelAnime_Update(this->skelAnime3)) { - Animation_Change(this->skelAnime3, this->skelAnime3->animation, 1.0f, 18.0f, 35.0f, 2, 0.0f); + Animation_Change(this->skelAnime3, this->skelAnime3->animation, 1.0f, 18.0f, 35.0f, ANIMMODE_ONCE, 0.0f); this->actionFlags |= 1; } else { this->actionFlags &= ~1; @@ -834,7 +834,7 @@ void func_8095C408(EnOwl* this) { void func_8095C484(EnOwl* this) { if (SkelAnime_Update(this->skelAnime3)) { Animation_Change(this->skelAnime3, this->skelAnime3->animation, 1.0f, 0.0f, - Animation_GetLastFrame(this->skelAnime3->animation), 2, 0.0f); + Animation_GetLastFrame(this->skelAnime3->animation), ANIMMODE_ONCE, 0.0f); this->actionFlags |= 1; } else { this->actionFlags &= ~1; @@ -879,7 +879,7 @@ void func_8095C568(EnOwl* this) { } } -void EnOwl_Update(Actor* thisx, GlobalContext* globalCtx) { +void EnOwl_Update(Actor* thisx, PlayState* play) { s32 pad; EnOwl* this = THIS; s16 sp36; @@ -892,11 +892,11 @@ void EnOwl_Update(Actor* thisx, GlobalContext* globalCtx) { this->unk_414(this); } - this->actionFunc(this, globalCtx); + this->actionFunc(this, play); func_8095C568(this); - Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 10.0f, 10.0f, 10.0f, 4); + Actor_UpdateBgCheckInfo(play, &this->actor, 10.0f, 10.0f, 10.0f, 4); Collider_UpdateCylinder(&this->actor, &this->collider); - CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + CollisionCheck_SetOC(play, &play->colChkCtx, &this->collider.base); if (this->actor.update != NULL) { if ((this->skelAnime1.animation == &object_owl_Anim_001ADC) && Animation_OnFrame(&this->skelAnime1, 4.0f)) { Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_OWL_FLUTTER); @@ -1062,9 +1062,9 @@ void EnOwl_Update(Actor* thisx, GlobalContext* globalCtx) { } } -void func_8095CCF4(Actor* thisx, GlobalContext* globalCtx) { +void func_8095CCF4(Actor* thisx, PlayState* play) { EnOwl* this = THIS; - Player* player = GET_PLAYER(globalCtx); + Player* player = GET_PLAYER(play); if (player->stateFlags3 & 0x10000000) { Actor_MarkForDeath(&this->actor); @@ -1077,7 +1077,7 @@ void func_8095CCF4(Actor* thisx, GlobalContext* globalCtx) { } this->actor.world.pos.y -= 1.0f; - Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 10.0f, 10.0f, 10.0f, 4); + Actor_UpdateBgCheckInfo(play, &this->actor, 10.0f, 10.0f, 10.0f, 4); if (this->actor.bgCheckFlags & 1) { this->unk_3DA = (this->unk_3DA >> 3) * 7; if (this->unk_3DC > 0) { @@ -1092,7 +1092,7 @@ void func_8095CCF4(Actor* thisx, GlobalContext* globalCtx) { this->unk_3DA -= (s16)(this->unk_3D8 >> 6); } -s32 EnOwl_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, Actor* thisx) { +s32 EnOwl_OverrideLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, Actor* thisx) { EnOwl* this = THIS; switch (limbIndex) { @@ -1122,7 +1122,7 @@ s32 EnOwl_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, return false; } -void EnOwl_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx) { +void EnOwl_PostLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx) { EnOwl* this = THIS; Vec3f sp18; @@ -1136,11 +1136,11 @@ 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); } } -void EnOwl_Draw(Actor* thisx, GlobalContext* globalCtx) { +void EnOwl_Draw(Actor* thisx, PlayState* play) { static TexturePtr eyeTextures[] = { object_owl_Tex_008EB8, object_owl_Tex_0092B8, @@ -1149,51 +1149,52 @@ void EnOwl_Draw(Actor* thisx, GlobalContext* globalCtx) { s32 pad; EnOwl* this = THIS; - OPEN_DISPS(globalCtx->state.gfxCtx); + OPEN_DISPS(play->state.gfxCtx); - func_8012C5B0(globalCtx->state.gfxCtx); + func_8012C5B0(play->state.gfxCtx); gSPSegment(POLY_OPA_DISP++, 0x08, Lib_SegmentedToVirtual(eyeTextures[this->eyeTexIndex])); - SkelAnime_DrawFlexOpa(globalCtx, this->skelAnime3->skeleton, this->skelAnime3->jointTable, - this->skelAnime3->dListCount, EnOwl_OverrideLimbDraw, EnOwl_PostLimbDraw, &this->actor); + SkelAnime_DrawFlexOpa(play, this->skelAnime3->skeleton, this->skelAnime3->jointTable, this->skelAnime3->dListCount, + EnOwl_OverrideLimbDraw, EnOwl_PostLimbDraw, &this->actor); - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->state.gfxCtx); } -void func_8095D074(Actor* thisx, GlobalContext* globalCtx) { +void func_8095D074(Actor* thisx, PlayState* play) { EnOwl* this = THIS; - OPEN_DISPS(globalCtx->state.gfxCtx); + OPEN_DISPS(play->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); + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - func_8012C28C(globalCtx->state.gfxCtx); + func_8012C28C(play->state.gfxCtx); gDPSetRenderMode(POLY_OPA_DISP++, G_RM_FOG_SHADE_A, G_RM_AA_ZB_TEX_EDGE2); gDPSetEnvColor(POLY_OPA_DISP++, 0, 0, 0, 255); gSPDisplayList(POLY_OPA_DISP++, object_owl_DL_001200); } else { - gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - func_8012C2DC(globalCtx->state.gfxCtx); + func_8012C2DC(play->state.gfxCtx); gDPSetRenderMode(POLY_XLU_DISP++, G_RM_FOG_SHADE_A, G_RM_AA_XLU_SURF2); gDPSetEnvColor(POLY_XLU_DISP++, 0, 0, 0, (u8)(this->unk_3DC * 8)); gSPDisplayList(POLY_XLU_DISP++, object_owl_DL_001200); } - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->state.gfxCtx); } void EnOwl_ChangeMode(EnOwl* this, EnOwlActionFunc actionFunc, EnOwlFunc unkFunc, SkelAnime* skelAnime, AnimationHeader* animation, f32 morphFrames) { this->skelAnime3 = skelAnime; - Animation_Change(this->skelAnime3, animation, 1.0f, 0.0f, Animation_GetLastFrame(animation), 2, morphFrames); + Animation_Change(this->skelAnime3, animation, 1.0f, 0.0f, Animation_GetLastFrame(animation), ANIMMODE_ONCE, + morphFrames); this->actionFunc = actionFunc; this->unk_414 = unkFunc; } diff --git a/src/overlays/actors/ovl_En_Owl/z_en_owl.h b/src/overlays/actors/ovl_En_Owl/z_en_owl.h index ee9e1fdd8..781fd308c 100644 --- a/src/overlays/actors/ovl_En_Owl/z_en_owl.h +++ b/src/overlays/actors/ovl_En_Owl/z_en_owl.h @@ -5,7 +5,7 @@ struct EnOwl; -typedef void (*EnOwlActionFunc)(struct EnOwl*, GlobalContext*); +typedef void (*EnOwlActionFunc)(struct EnOwl*, PlayState*); typedef void (*EnOwlFunc)(struct EnOwl*); #define ENOWL_GET_F000(thisx) (((thisx)->params & 0xF000) >> 0xC) @@ -21,39 +21,39 @@ typedef enum { } EnOwlType; typedef struct EnOwl { - /* 0x0000 */ Actor actor; - /* 0x0144 */ ColliderCylinder collider; - /* 0x0190 */ SkelAnime skelAnime1; - /* 0x01D4 */ Vec3s jointTable1[21]; - /* 0x0252 */ Vec3s morphTable1[21]; - /* 0x02D0 */ SkelAnime skelAnime2; - /* 0x0314 */ Vec3s jointTable2[16]; - /* 0x0374 */ Vec3s morphTable2[16]; - /* 0x03D4 */ SkelAnime* skelAnime3; - /* 0x03D8 */ s16 unk_3D8; - /* 0x03DA */ s16 unk_3DA; - /* 0x03DC */ s16 unk_3DC; - /* 0x03DE */ s16 unk_3DE; - /* 0x03E0 */ s16 eyeTexIndex; - /* 0x03E2 */ s16 blinkTimer; - /* 0x03E4 */ f32 unk_3E4; - /* 0x03E8 */ u16 actionFlags; - /* 0x03EA */ s16 unk_3EA; - /* 0x03EC */ s16 unk_3EC; - /* 0x03F0 */ f32 unk_3F0; - /* 0x03F4 */ Path* path; - /* 0x03F8 */ s32 unk_3F8; - /* 0x03FC */ s32 unk_3FC; - /* 0x0400 */ s16 unk_400[3]; - /* 0x0406 */ s16 unk_406; - /* 0x0408 */ u8 unk_408; - /* 0x0409 */ u8 unk_409; - /* 0x040A */ u8 unk_40A; - /* 0x040B */ u8 unk_40B; - /* 0x040C */ u8 unk_40C; - /* 0x040D */ u8 unk_40D; - /* 0x0410 */ EnOwlActionFunc actionFunc; - /* 0x0414 */ EnOwlFunc unk_414; + /* 0x000 */ Actor actor; + /* 0x144 */ ColliderCylinder collider; + /* 0x190 */ SkelAnime skelAnime1; + /* 0x1D4 */ Vec3s jointTable1[21]; + /* 0x252 */ Vec3s morphTable1[21]; + /* 0x2D0 */ SkelAnime skelAnime2; + /* 0x314 */ Vec3s jointTable2[16]; + /* 0x374 */ Vec3s morphTable2[16]; + /* 0x3D4 */ SkelAnime* skelAnime3; + /* 0x3D8 */ s16 unk_3D8; + /* 0x3DA */ s16 unk_3DA; + /* 0x3DC */ s16 unk_3DC; + /* 0x3DE */ s16 unk_3DE; + /* 0x3E0 */ s16 eyeTexIndex; + /* 0x3E2 */ s16 blinkTimer; + /* 0x3E4 */ f32 unk_3E4; + /* 0x3E8 */ u16 actionFlags; + /* 0x3EA */ s16 unk_3EA; + /* 0x3EC */ s16 unk_3EC; + /* 0x3F0 */ f32 unk_3F0; + /* 0x3F4 */ Path* path; + /* 0x3F8 */ s32 unk_3F8; + /* 0x3FC */ s32 unk_3FC; + /* 0x400 */ s16 unk_400[3]; + /* 0x406 */ s16 unk_406; + /* 0x408 */ u8 unk_408; + /* 0x409 */ u8 unk_409; + /* 0x40A */ u8 unk_40A; + /* 0x40B */ u8 unk_40B; + /* 0x40C */ u8 unk_40C; + /* 0x40D */ u8 unk_40D; + /* 0x410 */ EnOwlActionFunc actionFunc; + /* 0x414 */ EnOwlFunc unk_414; } EnOwl; // size = 0x418 extern const ActorInit En_Owl_InitVars; diff --git a/src/overlays/actors/ovl_En_Pamera/z_en_pamera.c b/src/overlays/actors/ovl_En_Pamera/z_en_pamera.c index 06cf9b22d..075ced540 100644 --- a/src/overlays/actors/ovl_En_Pamera/z_en_pamera.c +++ b/src/overlays/actors/ovl_En_Pamera/z_en_pamera.c @@ -5,70 +5,69 @@ */ #include "z_en_pamera.h" -#include "../ovl_En_Bom/z_en_bom.h" -#include "../ovl_En_Door/z_en_door.h" -#include "objects/object_pamera/object_pamera.h" +#include "overlays/actors/ovl_En_Bom/z_en_bom.h" +#include "overlays/actors/ovl_En_Door/z_en_door.h" #define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_8 | ACTOR_FLAG_10) #define THIS ((EnPamera*)thisx) -void EnPamera_Init(Actor* thisx, GlobalContext* globalCtx); -void EnPamera_Destroy(Actor* thisx, GlobalContext* globalCtx); -void EnPamera_Update(Actor* thisx, GlobalContext* globalCtx); -void EnPamera_Draw(Actor* thisx, GlobalContext* globalCtx); +void EnPamera_Init(Actor* thisx, PlayState* play); +void EnPamera_Destroy(Actor* thisx, PlayState* play); +void EnPamera_Update(Actor* thisx, PlayState* play); +void EnPamera_Draw(Actor* thisx, PlayState* play); -s32 func_80BD84F0(EnPamera* this, GlobalContext* globalCtx); -void func_80BD8588(EnPamera* this, GlobalContext* globalCtx); +s32 func_80BD84F0(EnPamera* this, PlayState* play); +void func_80BD8588(EnPamera* this, PlayState* play); void func_80BD8658(EnPamera* this); void func_80BD8700(EnPamera* this); -void func_80BD8758(EnPamera* this, GlobalContext* globalCtx); +void func_80BD8758(EnPamera* this, PlayState* play); void func_80BD8908(EnPamera* this); -void func_80BD8964(EnPamera* this, GlobalContext* globalCtx); +void func_80BD8964(EnPamera* this, PlayState* play); void func_80BD8A38(EnPamera* this); -void func_80BD8A7C(EnPamera* this, GlobalContext* globalCtx); +void func_80BD8A7C(EnPamera* this, PlayState* play); void func_80BD8B50(EnPamera* this); -void func_80BD8B70(EnPamera* this, GlobalContext* globalCtx); +void func_80BD8B70(EnPamera* this, PlayState* play); void func_80BD8CCC(EnPamera* this); -void func_80BD8D1C(EnPamera* this, GlobalContext* globalCtx); +void func_80BD8D1C(EnPamera* this, PlayState* play); void func_80BD8D80(EnPamera* this); -void func_80BD8DB0(EnPamera* this, GlobalContext* globalCtx); +void func_80BD8DB0(EnPamera* this, PlayState* play); void EnPamera_LookDownWell(EnPamera* this); -void func_80BD8F60(EnPamera* this, GlobalContext* globalCtx); +void func_80BD8F60(EnPamera* this, PlayState* play); void func_80BD8FF0(EnPamera* this); -void func_80BD909C(EnPamera* this, GlobalContext* globalCtx); -s32 func_80BD9234(EnPamera* this, GlobalContext* globalCtx); -void func_80BD92D0(EnPamera* this, GlobalContext* globalCtx); -void func_80BD9338(EnPamera* this, GlobalContext* globalCtx); -void func_80BD9384(EnPamera* this, GlobalContext* globalCtx); +void func_80BD909C(EnPamera* this, PlayState* play); +s32 func_80BD9234(EnPamera* this, PlayState* play); +void func_80BD92D0(EnPamera* this, PlayState* play); +void func_80BD9338(EnPamera* this, PlayState* play); +void func_80BD9384(EnPamera* this, PlayState* play); void func_80BD93CC(EnPamera* this, s16 arg1, s16 arg2); -void func_80BD93F4(EnPamera* this, GlobalContext* globalCtx); -void func_80BD94E0(EnPamera* this, GlobalContext* globalCtx); -void func_80BD9840(EnPamera* this, GlobalContext* globalCtx); +void func_80BD93F4(EnPamera* this, PlayState* play); +void func_80BD94E0(EnPamera* this, PlayState* play); +void func_80BD9840(EnPamera* this, PlayState* play); void func_80BD9904(EnPamera* this); -void func_80BD9928(EnPamera* this, GlobalContext* globalCtx); +void func_80BD9928(EnPamera* this, PlayState* play); void func_80BD9938(EnPamera* this); -void func_80BD994C(EnPamera* this, GlobalContext* globalCtx); +void func_80BD994C(EnPamera* this, PlayState* play); void func_80BD9A9C(EnPamera* this); -void EnPamera_HandleDialogue(EnPamera* this, GlobalContext* globalCtx); -void func_80BD9B4C(EnPamera* this, GlobalContext* globalCtx); -void func_80BD9C70(EnPamera* this, GlobalContext* globalCtx); -s32 func_80BD9CB8(EnPamera* this, GlobalContext* globalCtx); +void EnPamera_HandleDialogue(EnPamera* this, PlayState* play); +void func_80BD9B4C(EnPamera* this, PlayState* play); +void func_80BD9C70(EnPamera* this, PlayState* play); +s32 func_80BD9CB8(EnPamera* this, PlayState* play); void func_80BD9E60(EnPamera* this); -void func_80BD9E78(EnPamera* this, GlobalContext* globalCtx); +void func_80BD9E78(EnPamera* this, PlayState* play); void func_80BD9E88(EnPamera* this); -void func_80BD9ED0(EnPamera* this, GlobalContext* globalCtx); +void func_80BD9ED0(EnPamera* this, PlayState* play); void func_80BD9EE0(EnPamera* this); -void func_80BD9F3C(EnPamera* this, GlobalContext* globalCtx); +void func_80BD9F3C(EnPamera* this, PlayState* play); void func_80BDA038(EnPamera* this); -void func_80BDA090(EnPamera* this, GlobalContext* globalCtx); +void func_80BDA090(EnPamera* this, PlayState* play); void func_80BDA0A0(EnPamera* this); -void func_80BDA0FC(EnPamera* this, GlobalContext* globalCtx); +void func_80BDA0FC(EnPamera* this, PlayState* play); void func_80BDA170(EnPamera* this); -void func_80BDA1C8(EnPamera* this, GlobalContext* globalCtx); +void func_80BDA1C8(EnPamera* this, PlayState* play); void func_80BDA288(EnPamera* this); -void func_80BDA2E0(EnPamera* this, GlobalContext* globalCtx); -void func_80BDA344(Actor* thisx, GlobalContext* globalCtx); +void func_80BDA2E0(EnPamera* this, PlayState* play); +void func_80BDA344(Actor* thisx, PlayState* play); const ActorInit En_Pamera_InitVars = { ACTOR_EN_PAMERA, @@ -106,7 +105,7 @@ static CollisionCheckInfoInit2 sColChkInfoInit2 = { 0, 0, 0, 0, MASS_IMMOVABLE, }; -static AnimationInfo sAnimations[] = { +static AnimationInfo sAnimationInfo[] = { { &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 }, @@ -130,16 +129,16 @@ static TexturePtr D_80BDA604[] = { object_pamera_Tex_0066E8, object_pamera_Tex_0 static TexturePtr D_80BDA610[] = { object_pamera_Tex_0072E8, object_pamera_Tex_0073E8 }; -void EnPamera_Init(Actor* thisx, GlobalContext* globalCtx) { +void EnPamera_Init(Actor* thisx, PlayState* play) { s32 pad; EnPamera* this = THIS; Vec3f sp44; ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 15.0f); - SkelAnime_InitFlex(globalCtx, &this->skelAnime, &object_pamera_Skel_008448, &object_pamera_Anim_0005BC, - this->jointTable, this->morphTable, PAMERA_LIMB_MAX); - Collider_InitCylinder(globalCtx, &this->collider); - Collider_SetCylinder(globalCtx, &this->collider, &this->actor, &sCylinderInit); + SkelAnime_InitFlex(play, &this->skelAnime, &gPamelaSkel, &object_pamera_Anim_0005BC, this->jointTable, + this->morphTable, PAMELA_LIMB_MAX); + Collider_InitCylinder(play, &this->collider); + Collider_SetCylinder(play, &this->collider, &this->actor, &sCylinderInit); CollisionCheck_SetInfo2(&this->actor.colChkInfo, NULL, &sColChkInfoInit2); this->actor.targetMode = 6; this->unk_312 = 0; @@ -150,18 +149,20 @@ void EnPamera_Init(Actor* thisx, GlobalContext* globalCtx) { this->unk_322 = 0; this->unk_324 = 0; if ((this->actor.params & 0xF000) >> 0xC) { - func_80BD9840(this, globalCtx); + func_80BD9840(this, play); } else { - func_80BD8588(this, globalCtx); + func_80BD8588(this, play); func_80BD8658(this); if (1) {} if (!(gSaveContext.save.weekEventReg[14] & 4) || (gSaveContext.save.weekEventReg[52] & 0x20) || - (gSaveContext.save.weekEventReg[75] & 0x20) || (gSaveContext.save.entranceIndex == 0x2090)) { + (gSaveContext.save.weekEventReg[75] & 0x20) || (gSaveContext.save.entrance == ENTRANCE(IKANA_CANYON, 9))) { Actor_MarkForDeath(&this->actor); } 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)) { + if (!(gSaveContext.save.weekEventReg[59] & 1) || + (gSaveContext.save.entrance != ENTRANCE(IKANA_CANYON, 2))) { + if ((gSaveContext.save.entrance != ENTRANCE(IKANA_CANYON, 2)) && + (gSaveContext.save.weekEventReg[59] & 1)) { gSaveContext.save.weekEventReg[59] &= (u8)~1; } func_80BD8700(this); @@ -179,8 +180,8 @@ void EnPamera_Init(Actor* thisx, GlobalContext* globalCtx) { } } -s32 func_80BD84F0(EnPamera* this, GlobalContext* globalCtx) { - Actor* actor = globalCtx->actorCtx.actorLists[ACTORCAT_DOOR].first; +s32 func_80BD84F0(EnPamera* this, PlayState* play) { + Actor* actor = play->actorCtx.actorLists[ACTORCAT_DOOR].first; while (actor != NULL) { if ((actor->id == ACTOR_EN_DOOR) && (Math_Vec3f_DistXZ(&this->actor.world.pos, &actor->world.pos) < 200.0f)) { @@ -193,15 +194,15 @@ s32 func_80BD84F0(EnPamera* this, GlobalContext* globalCtx) { return false; } -void func_80BD8588(EnPamera* this, GlobalContext* globalCtx) { - Path* path = &globalCtx->setupPathList[((this->actor.params & 0xFF0) >> 4)]; +void func_80BD8588(EnPamera* this, PlayState* play) { + Path* path = &play->setupPathList[((this->actor.params & 0xFF0) >> 4)]; Vec3f sp28; if (path == NULL) { Actor_MarkForDeath(&this->actor); } if (gSaveContext.save.weekEventReg[61] & 4) { - path = &globalCtx->setupPathList[path->unk1]; + path = &play->setupPathList[path->unk1]; } this->pathPoints = Lib_SegmentedToVirtual(path->points); this->pathIndex = 0; @@ -224,39 +225,39 @@ void func_80BD8658(EnPamera* this) { } } -void EnPamera_Destroy(Actor* thisx, GlobalContext* globalCtx) { +void EnPamera_Destroy(Actor* thisx, PlayState* play) { EnPamera* this = THIS; - Collider_DestroyCylinder(globalCtx, &this->collider); + Collider_DestroyCylinder(play, &this->collider); } void func_80BD8700(EnPamera* this) { this->hideInisdeTimer = 0; this->actor.flags &= ~ACTOR_FLAG_1; - Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 0); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, 0); this->actionFunc = func_80BD8758; } -void func_80BD8758(EnPamera* this, GlobalContext* globalCtx) { +void func_80BD8758(EnPamera* this, PlayState* play) { if (this->hideInisdeTimer++ > 1800) { if (ActorCutscene_GetCanPlayNext(this->cutscenes[0]) && (this->cutscenes[0] != -1)) { ActorCutscene_StartAndSetUnkLinkFields(this->cutscenes[0], &this->actor); - Camera_SetToTrackActor(Play_GetCamera(globalCtx, ActorCutscene_GetCurrentCamera(this->cutscenes[0])), + Camera_SetToTrackActor(Play_GetCamera(play, ActorCutscene_GetCurrentSubCamId(this->cutscenes[0])), &this->actor); this->actor.speedXZ = 1.5f; - Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 1); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, 1); this->actor.shape.rot.y = this->actor.home.rot.y; this->actor.world.rot.y = this->actor.home.rot.y; - func_80BD9338(this, globalCtx); + func_80BD9338(this, play); func_80BD8908(this); } else if ((this->cutscenes[0] != -1) && (this->actor.xzDistToPlayer < 1000.0f)) { ActorCutscene_SetIntentToPlay(this->cutscenes[0]); } else { this->actor.speedXZ = 1.5f; - Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 1); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, 1); this->actor.shape.rot.y = this->actor.home.rot.y; this->actor.world.rot.y = this->actor.home.rot.y; - func_80BD9338(this, globalCtx); + func_80BD9338(this, play); func_80BD8908(this); } } @@ -266,7 +267,7 @@ void func_80BD8758(EnPamera* this, GlobalContext* globalCtx) { this->actor.draw = NULL; } } - if (func_80BD9234(this, globalCtx)) { + if (func_80BD9234(this, play)) { // this is 1760 frames, which is ~90sec this->hideInisdeTimer = 88 * 20; } @@ -275,11 +276,11 @@ void func_80BD8758(EnPamera* this, GlobalContext* globalCtx) { void func_80BD8908(EnPamera* this) { this->actor.draw = EnPamera_Draw; this->actor.flags |= ACTOR_FLAG_1; - Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 1); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, 1); this->actionFunc = func_80BD8964; } -void func_80BD8964(EnPamera* this, GlobalContext* globalCtx) { +void func_80BD8964(EnPamera* this, PlayState* play) { Vec3f vec; vec.x = this->pathPoints->x; @@ -288,25 +289,25 @@ 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_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 1); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, 1); gSaveContext.save.weekEventReg[59] |= 1; func_80BD8B50(this); } } void func_80BD8A38(EnPamera* this) { - Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 1); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, 1); this->actionFunc = func_80BD8A7C; } -void func_80BD8A7C(EnPamera* this, GlobalContext* globalCtx) { +void func_80BD8A7C(EnPamera* this, PlayState* play) { Math_SmoothStepToS(&this->actor.shape.rot.y, Math_Vec3f_Yaw(&this->actor.world.pos, &this->actor.home.pos), 0xA, 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.save.weekEventReg[59] &= (u8)~1; if (!(gSaveContext.save.weekEventReg[61] & 4)) { - func_80BD92D0(this, globalCtx); + func_80BD92D0(this, play); gSaveContext.save.weekEventReg[61] |= 4; } func_80BD8700(this); @@ -318,7 +319,7 @@ void func_80BD8B50(EnPamera* this) { this->actor.gravity = -2.0f; } -void func_80BD8B70(EnPamera* this, GlobalContext* globalCtx) { +void func_80BD8B70(EnPamera* this, PlayState* play) { Vec3f vec; s16 sp32; @@ -335,21 +336,21 @@ void func_80BD8B70(EnPamera* this, GlobalContext* globalCtx) { func_80BD8CCC(this); } - Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 0.0f, 0.0f, 0.0f, 4); + Actor_UpdateBgCheckInfo(play, &this->actor, 0.0f, 0.0f, 0.0f, 4); this->actor.world.pos.y += this->actor.gravity; } void func_80BD8CCC(EnPamera* this) { this->hideInisdeTimer = 0; this->actor.speedXZ = 0.0f; - Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 3); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, 3); this->actionFunc = func_80BD8D1C; } -void func_80BD8D1C(EnPamera* this, GlobalContext* globalCtx) { +void func_80BD8D1C(EnPamera* this, PlayState* play) { if (this->hideInisdeTimer++ > 200) { this->actor.speedXZ = 1.5f; - Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 1); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, 1); func_80BD8D80(this); } } @@ -362,7 +363,7 @@ void func_80BD8D80(EnPamera* this) { this->actionFunc = func_80BD8DB0; } -void func_80BD8DB0(EnPamera* this, GlobalContext* globalCtx) { +void func_80BD8DB0(EnPamera* this, PlayState* play) { Vec3f vec; s16 sp32; @@ -376,23 +377,23 @@ void func_80BD8DB0(EnPamera* this, GlobalContext* globalCtx) { } else if (this->pathIndex > 0) { this->pathIndex--; } else { - func_80BD9338(this, globalCtx); + func_80BD9338(this, play); func_80BD8A38(this); } - Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 0.0f, 0.0f, 0.0f, 4); + Actor_UpdateBgCheckInfo(play, &this->actor, 0.0f, 0.0f, 0.0f, 4); this->actor.world.pos.y += this->actor.gravity; } void EnPamera_LookDownWell(EnPamera* this) { func_80BD93CC(this, 1, 1); - Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 4); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, 4); this->actionFunc = func_80BD8F60; } -void func_80BD8F60(EnPamera* this, GlobalContext* globalCtx) { +void func_80BD8F60(EnPamera* this, PlayState* play) { Math_SmoothStepToS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer, 0xA, 0x3000, 0x1000); if (Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) { - Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 2); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, 2); this->actor.speedXZ = 3.0f; func_80BD93CC(this, 0, 0); func_80BD8D80(this); @@ -409,17 +410,17 @@ 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_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 3); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, 3); this->actionFunc = func_80BD909C; } -void func_80BD909C(EnPamera* this, GlobalContext* globalCtx) { +void func_80BD909C(EnPamera* this, PlayState* play) { } -void func_80BD90AC(EnPamera* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); +void func_80BD90AC(EnPamera* this, PlayState* play) { + Player* player = GET_PLAYER(play); - if (Player_GetMask(globalCtx) != PLAYER_MASK_STONE && (this->actionFunc != func_80BD8758) && + if (Player_GetMask(play) != PLAYER_MASK_STONE && (this->actionFunc != func_80BD8758) && (this->actionFunc != func_80BD8964) && (this->actionFunc != func_80BD8A7C) && (this->actionFunc != func_80BD8F60) && ((this->actionFunc != func_80BD8B70) || (this->pathIndex != 0)) && ((this->actionFunc != func_80BD8DB0) || (this->actor.speedXZ != 3.0f)) && @@ -428,7 +429,7 @@ 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); - Camera_SetToTrackActor(Play_GetCamera(globalCtx, ActorCutscene_GetCurrentCamera(this->cutscenes[1])), + Camera_SetToTrackActor(Play_GetCamera(play, ActorCutscene_GetCurrentSubCamId(this->cutscenes[1])), &this->actor); EnPamera_LookDownWell(this); } else if (this->cutscenes[1] != -1) { @@ -439,8 +440,8 @@ void func_80BD90AC(EnPamera* this, GlobalContext* globalCtx) { } } -s32 func_80BD9234(EnPamera* this, GlobalContext* globalCtx) { - Actor* actor = globalCtx->actorCtx.actorLists[ACTORCAT_EXPLOSIVES].first; +s32 func_80BD9234(EnPamera* this, PlayState* play) { + Actor* actor = play->actorCtx.actorLists[ACTORCAT_EXPLOSIVES].first; while (actor != NULL) { if ((actor->id == ACTOR_EN_BOM) && (Math_Vec3f_DistXZ(&this->actor.world.pos, &actor->world.pos) < 500.0f) && @@ -453,11 +454,11 @@ s32 func_80BD9234(EnPamera* this, GlobalContext* globalCtx) { return 0; } -void func_80BD92D0(EnPamera* this, GlobalContext* globalCtx) { +void func_80BD92D0(EnPamera* this, PlayState* play) { Path* path; s32 pathId = this->pathId; - path = &globalCtx->setupPathList[pathId]; + path = &play->setupPathList[pathId]; if (pathId >= 0) { this->pathPoints = Lib_SegmentedToVirtual(path->points); this->pathIndex = 0; @@ -466,17 +467,17 @@ void func_80BD92D0(EnPamera* this, GlobalContext* globalCtx) { } } -void func_80BD9338(EnPamera* this, GlobalContext* globalCtx) { +void func_80BD9338(EnPamera* this, PlayState* play) { Actor* actor; - func_80BD84F0(this, globalCtx); + func_80BD84F0(this, play); actor = this->actor.child; if ((actor != NULL) && (actor->id == ACTOR_EN_DOOR)) { ((EnDoor*)actor)->unk_1A7 = -0x32; } } -void func_80BD9384(EnPamera* this, GlobalContext* globalCtx) { +void func_80BD9384(EnPamera* this, PlayState* play) { if (this->unk_316 < 40) { this->unk_316++; } else { @@ -493,7 +494,7 @@ void func_80BD93CC(EnPamera* this, s16 arg1, s16 arg2) { this->unk_314 = arg2; } -void func_80BD93F4(EnPamera* this, GlobalContext* globalCtx) { +void func_80BD93F4(EnPamera* this, PlayState* play) { if ((this->actionFunc == func_80BD8B70) || (this->actionFunc == func_80BD8DB0) || (this->actionFunc == func_80BD8964) || (this->actionFunc == func_80BD8A7C)) { if (this->skelAnime.animation == &object_pamera_Anim_008AE0) { @@ -507,63 +508,62 @@ void func_80BD93F4(EnPamera* this, GlobalContext* globalCtx) { } } -void func_80BD94E0(EnPamera* this, GlobalContext* globalCtx) { +void func_80BD94E0(EnPamera* this, PlayState* play) { if ((this->actionFunc != func_80BD8B70) && (this->actionFunc != func_80BD8964) && (this->actionFunc != func_80BD909C) && (this->actionFunc != func_80BD8D1C) && ((this->actionFunc != func_80BD8DB0) || (this->actor.speedXZ == 3.0f))) { - func_800E9250(globalCtx, &this->actor, &this->limb9Rot, &this->limb8Rot, this->actor.focus.pos); + Actor_TrackPlayer(play, &this->actor, &this->headRot, &this->torsoRot, this->actor.focus.pos); } else { - func_800E8F08(&this->limb9Rot, &this->limb8Rot); + Actor_TrackNone(&this->headRot, &this->torsoRot); } } -void EnPamera_Update(Actor* thisx, GlobalContext* globalCtx) { +void EnPamera_Update(Actor* thisx, PlayState* play) { s32 pad; EnPamera* this = THIS; - this->actionFunc(this, globalCtx); + this->actionFunc(this, play); SkelAnime_Update(&this->skelAnime); - func_80BD90AC(this, globalCtx); - func_80BD9384(this, globalCtx); - func_80BD94E0(this, globalCtx); + func_80BD90AC(this, play); + func_80BD9384(this, play); + func_80BD94E0(this, play); Collider_UpdateCylinder(&this->actor, &this->collider); - CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); - func_80BD93F4(this, globalCtx); + CollisionCheck_SetOC(play, &play->colChkCtx, &this->collider.base); + func_80BD93F4(this, play); } -s32 EnPamera_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, - Actor* thisx) { +s32 EnPamera_OverrideLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, Actor* thisx) { EnPamera* this = THIS; - if (limbIndex == PAMERA_LIMB_HAIR) { - rot->x += this->limb9Rot.y; - rot->z += this->limb9Rot.x; + if (limbIndex == PAMELA_LIMB_HEAD) { + rot->x += this->headRot.y; + rot->z += this->headRot.x; } return false; } -void EnPamera_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx) { +void EnPamera_PostLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx) { EnPamera* this = THIS; - if (limbIndex == PAMERA_LIMB_HAIR) { - Matrix_MultiplyVector3fByState(&D_80BDA5F0, &this->actor.focus.pos); + if (limbIndex == PAMELA_LIMB_HEAD) { + Matrix_MultVec3f(&D_80BDA5F0, &this->actor.focus.pos); } } -void EnPamera_Draw(Actor* thisx, GlobalContext* globalCtx) { +void EnPamera_Draw(Actor* thisx, PlayState* play) { EnPamera* this = THIS; - OPEN_DISPS(globalCtx->state.gfxCtx); - func_8012C28C(globalCtx->state.gfxCtx); + OPEN_DISPS(play->state.gfxCtx); + func_8012C28C(play->state.gfxCtx); gSPSegment(POLY_OPA_DISP++, 0x08, SEGMENTED_TO_VIRTUAL(D_80BDA604[this->unk_312])); gSPSegment(POLY_OPA_DISP++, 0x09, SEGMENTED_TO_VIRTUAL(D_80BDA610[this->unk_314])); gSPSegment(POLY_OPA_DISP++, 0x0A, SEGMENTED_TO_VIRTUAL(D_80BDA5FC[this->unk_310])); - SkelAnime_DrawFlexOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, + SkelAnime_DrawFlexOpa(play, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, EnPamera_OverrideLimbDraw, EnPamera_PostLimbDraw, &this->actor); - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->state.gfxCtx); } -void func_80BD9840(EnPamera* this, GlobalContext* globalCtx) { +void func_80BD9840(EnPamera* this, PlayState* play) { this->actor.update = func_80BDA344; this->actor.flags |= ACTOR_FLAG_2000000; this->actor.flags |= ACTOR_FLAG_100000; @@ -587,39 +587,39 @@ void func_80BD9904(EnPamera* this) { this->actionFunc = &func_80BD9928; } -void func_80BD9928(EnPamera* this, GlobalContext* globalCtx) { +void func_80BD9928(EnPamera* this, PlayState* play) { } void func_80BD9938(EnPamera* this) { this->actionFunc = func_80BD994C; } -void func_80BD994C(EnPamera* this, GlobalContext* globalCtx) { - if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { - if (Player_GetMask(globalCtx) == PLAYER_MASK_GIBDO) { +void func_80BD994C(EnPamera* this, PlayState* play) { + if (Actor_ProcessTalkRequest(&this->actor, &play->state)) { + if (Player_GetMask(play) == PLAYER_MASK_GIBDO) { if (1) {} func_80BD93CC(this, 0, 1); - Message_StartTextbox(globalCtx, 0x15A8, &this->actor); + Message_StartTextbox(play, 0x15A8, &this->actor); this->unk_324 = 0x15A8; } else if ((gSaveContext.save.playerForm != PLAYER_FORM_HUMAN) || ((gSaveContext.save.weekEventReg[52] & 0x20) && (!(gSaveContext.save.weekEventReg[75] & 0x20)))) { func_80BD93CC(this, 1, 0); - Message_StartTextbox(globalCtx, 0x158E, &this->actor); + Message_StartTextbox(play, 0x158E, &this->actor); this->unk_324 = 0x158E; } else { if (!(this->unk_322 & 1)) { this->unk_322 |= 1; - Message_StartTextbox(globalCtx, 0x1587, &this->actor); + Message_StartTextbox(play, 0x1587, &this->actor); this->unk_324 = 0x1587; } else { - Message_StartTextbox(globalCtx, 0x158C, &this->actor); + Message_StartTextbox(play, 0x158C, &this->actor); this->unk_324 = 0x158C; } } func_80BD9A9C(this); } else { - func_800B8614(&this->actor, globalCtx, 100.0f); + func_800B8614(&this->actor, play, 100.0f); } } @@ -627,22 +627,25 @@ void func_80BD9A9C(EnPamera* this) { this->actionFunc = EnPamera_HandleDialogue; } -void EnPamera_HandleDialogue(EnPamera* this, GlobalContext* globalCtx) { - switch (Message_GetState(&globalCtx->msgCtx)) { - case 0: - case 1: - case 2: - case 3: - case 4: +void EnPamera_HandleDialogue(EnPamera* this, PlayState* play) { + switch (Message_GetState(&play->msgCtx)) { + case TEXT_STATE_NONE: + case TEXT_STATE_1: + case TEXT_STATE_CLOSING: + case TEXT_STATE_3: + case TEXT_STATE_CHOICE: break; - case 5: - func_80BD9B4C(this, globalCtx); + + case TEXT_STATE_5: + func_80BD9B4C(this, play); break; - case 6: - if (Message_ShouldAdvance(globalCtx)) { + + case TEXT_STATE_DONE: + if (Message_ShouldAdvance(play)) { func_80BD9938(this); } break; + default: break; } @@ -650,54 +653,54 @@ void EnPamera_HandleDialogue(EnPamera* this, GlobalContext* globalCtx) { this->actor.shape.rot.y = this->actor.world.rot.y; } -void func_80BD9B4C(EnPamera* this, GlobalContext* globalCtx) { - if (Message_ShouldAdvance(globalCtx)) { +void func_80BD9B4C(EnPamera* this, PlayState* play) { + if (Message_ShouldAdvance(play)) { switch (this->unk_324) { case 0x1587: - Message_StartTextbox(globalCtx, 0x1588, &this->actor); + Message_StartTextbox(play, 0x1588, &this->actor); this->unk_324 = 0x1588; break; case 0x1588: - Message_StartTextbox(globalCtx, 0x1589, &this->actor); + Message_StartTextbox(play, 0x1589, &this->actor); this->unk_324 = 0x1589; break; case 0x1589: - Message_StartTextbox(globalCtx, 0x158A, &this->actor); + Message_StartTextbox(play, 0x158A, &this->actor); this->unk_324 = 0x158A; break; case 0x158A: - Message_StartTextbox(globalCtx, 0x158B, &this->actor); + Message_StartTextbox(play, 0x158B, &this->actor); this->unk_324 = 0x158B; break; case 0x158C: - Message_StartTextbox(globalCtx, 0x158D, &this->actor); + Message_StartTextbox(play, 0x158D, &this->actor); this->unk_324 = 0x158D; break; case 0x158E: case 0x15A8: - func_801477B4(globalCtx); - func_80BD9C70(this, globalCtx); + func_801477B4(play); + func_80BD9C70(this, play); break; } } } -void func_80BD9C70(EnPamera* this, GlobalContext* globalCtx) { - globalCtx->nextEntranceIndex = 0x2020; - globalCtx->sceneLoadFlag = 0x14; - globalCtx->unk_1887F = 0x46; - gSaveContext.nextTransition = 2; +void func_80BD9C70(EnPamera* this, PlayState* play) { + play->nextEntrance = ENTRANCE(IKANA_CANYON, 2); + play->transitionTrigger = TRANS_TRIGGER_START; + play->transitionType = TRANS_TYPE_70; + gSaveContext.nextTransitionType = TRANS_TYPE_02; } -s32 func_80BD9CB8(EnPamera* this, GlobalContext* globalCtx) { +s32 func_80BD9CB8(EnPamera* this, PlayState* play) { s32 actionIndex; - 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; + if (Cutscene_CheckActorAction(play, 0x1E5)) { + actionIndex = Cutscene_GetActorActionIndex(play, 0x1E5); + if (this->unk_326 != play->csCtx.actorActions[actionIndex]->action) { + this->unk_326 = play->csCtx.actorActions[actionIndex]->action; - switch (globalCtx->csCtx.actorActions[actionIndex]->action) { + switch (play->csCtx.actorActions[actionIndex]->action) { case 1: func_80BD9E88(this); break; @@ -722,11 +725,11 @@ s32 func_80BD9CB8(EnPamera* this, GlobalContext* globalCtx) { break; } } - Cutscene_ActorTranslateAndYaw(&this->actor, globalCtx, actionIndex); - this->setupFunc(this, globalCtx); + Cutscene_ActorTranslateAndYaw(&this->actor, play, actionIndex); + this->setupFunc(this, play); return 1; } - if ((globalCtx->csCtx.state == 0) && (gSaveContext.save.weekEventReg[75] & 0x20)) { + if ((play->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); @@ -742,26 +745,26 @@ void func_80BD9E60(EnPamera* this) { this->setupFunc = func_80BD9E78; } -void func_80BD9E78(EnPamera* this, GlobalContext* globalCtx) { +void func_80BD9E78(EnPamera* this, PlayState* play) { } void func_80BD9E88(EnPamera* this) { - Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 0); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, 0); this->unk_31E = 0; this->setupFunc = func_80BD9ED0; } -void func_80BD9ED0(EnPamera* this, GlobalContext* globalCtx) { +void func_80BD9ED0(EnPamera* this, PlayState* play) { } void func_80BD9EE0(EnPamera* this) { - Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 5); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, 5); func_80BD93CC(this, 1, 0); this->unk_31E = 1; this->setupFunc = func_80BD9F3C; } -void func_80BD9F3C(EnPamera* this, GlobalContext* globalCtx) { +void func_80BD9F3C(EnPamera* this, PlayState* play) { if (this->unk_31E == 1) { if (Animation_OnFrame(&this->skelAnime, 2.0f) || Animation_OnFrame(&this->skelAnime, 6.0f) || Animation_OnFrame(&this->skelAnime, 10.0f) || Animation_OnFrame(&this->skelAnime, 14.0f) || @@ -772,34 +775,34 @@ 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_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 6); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, 6); } } } void func_80BDA038(EnPamera* this) { func_80BD93CC(this, 0, 1); - Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 7); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, 7); this->unk_31E = 0; this->setupFunc = func_80BDA090; } -void func_80BDA090(EnPamera* this, GlobalContext* globalCtx) { +void func_80BDA090(EnPamera* this, PlayState* play) { } void func_80BDA0A0(EnPamera* this) { func_80BD93CC(this, 0, 1); - Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 8); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, 8); this->unk_31E = 1; this->setupFunc = func_80BDA0FC; } -void func_80BDA0FC(EnPamera* this, GlobalContext* globalCtx) { +void func_80BDA0FC(EnPamera* this, PlayState* play) { if (this->unk_31E == 1) { if (Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) { this->unk_31E = 0; func_80BD93CC(this, 0, 0); - Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 6); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, 6); } } } @@ -807,11 +810,11 @@ void func_80BDA0FC(EnPamera* this, GlobalContext* globalCtx) { void func_80BDA170(EnPamera* this) { this->unk_31E = 1; func_80BD93CC(this, 0, 1); - Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 9); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, 9); this->setupFunc = func_80BDA1C8; } -void func_80BDA1C8(EnPamera* this, GlobalContext* globalCtx) { +void func_80BDA1C8(EnPamera* this, PlayState* play) { if (this->unk_31E == 1) { if (Animation_OnFrame(&this->skelAnime, 2.0f) || Animation_OnFrame(&this->skelAnime, 6.0f) || Animation_OnFrame(&this->skelAnime, 10.0f) || Animation_OnFrame(&this->skelAnime, 14.0f)) { @@ -820,7 +823,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_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 10); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, 10); } } } @@ -828,27 +831,27 @@ void func_80BDA1C8(EnPamera* this, GlobalContext* globalCtx) { void func_80BDA288(EnPamera* this) { this->unk_31E = 1; func_80BD93CC(this, 0, 0); - Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 11); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, 11); this->setupFunc = func_80BDA2E0; } -void func_80BDA2E0(EnPamera* this, GlobalContext* globalCtx) { +void func_80BDA2E0(EnPamera* this, PlayState* play) { if (this->unk_31E == 1) { if (Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) { this->unk_31E = 0; - Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 12); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, 12); } } } -void func_80BDA344(Actor* thisx, GlobalContext* globalCtx) { +void func_80BDA344(Actor* thisx, PlayState* play) { s32 pad; EnPamera* this = THIS; - this->actionFunc(this, globalCtx); + this->actionFunc(this, play); SkelAnime_Update(&this->skelAnime); - func_80BD9384(this, globalCtx); - if (func_80BD9CB8(this, globalCtx)) { + func_80BD9384(this, play); + if (func_80BD9CB8(this, play)) { // Pamela is outside if (gSaveContext.save.weekEventReg[59] & 1) { gSaveContext.save.weekEventReg[59] &= (u8)~1; @@ -856,15 +859,15 @@ void func_80BDA344(Actor* thisx, GlobalContext* globalCtx) { if (!(gSaveContext.save.weekEventReg[61] & 4)) { gSaveContext.save.weekEventReg[61] |= 4; } - func_800E8F08(&this->limb9Rot, &this->limb8Rot); + Actor_TrackNone(&this->headRot, &this->torsoRot); } else { - func_80BD94E0(this, globalCtx); + func_80BD94E0(this, play); if (this->actionFunc == func_80BD994C) { Collider_UpdateCylinder(&this->actor, &this->collider); - CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + CollisionCheck_SetOC(play, &play->colChkCtx, &this->collider.base); } if (gSaveContext.save.weekEventReg[14] & 4) { - globalCtx->roomCtx.unk7A[0]++; + play->roomCtx.unk7A[0]++; } } } diff --git a/src/overlays/actors/ovl_En_Pamera/z_en_pamera.h b/src/overlays/actors/ovl_En_Pamera/z_en_pamera.h index d19030aae..cf5611c4e 100644 --- a/src/overlays/actors/ovl_En_Pamera/z_en_pamera.h +++ b/src/overlays/actors/ovl_En_Pamera/z_en_pamera.h @@ -2,38 +2,12 @@ #define Z_EN_PAMERA_H #include "global.h" +#include "objects/object_pamera/object_pamera.h" struct EnPamera; -typedef enum { - /* 00 */ PAMERA_LIMB_NONE, - /* 01 */ PAMERA_LIMB_ROOT, - /* 02 */ PAMERA_LIMB_SHOULDER_LEFT, - /* 03 */ PAMERA_LIMB_FOREARM_LEFT, - /* 04 */ PAMERA_LIMB_HAND_LEFT, - /* 05 */ PAMERA_LIMB_SHOULDER_RIGHT, - /* 06 */ PAMERA_LIMB_FOREARM_RIGHT, - /* 07 */ PAMERA_LIMB_HAND_RIGHT, - /* 08 */ PAMERA_LIMB_HEAD_FRONT_AND_TOP, - /* 09 */ PAMERA_LIMB_HAIR, - /* 10 */ PAMERA_LIMB_TORSO_FRONT, - /* 11 */ PAMERA_LIMB_NECK, - /* 12 */ PAMERA_LIMB_THIGH_LEFT, - /* 13 */ PAMERA_LIMB_LEG_LEFT, - /* 14 */ PAMERA_LIMB_FOOT_LEFT, - /* 15 */ PAMERA_LIMB_THIGH_RIGHT, - /* 16 */ PAMERA_LIMB_LEG_RIGHT, - /* 17 */ PAMERA_LIMB_FOOT_RIGHT, - /* 18 */ PAMERA_DRESS_FRONT, - /* 19 */ PAMERA_DRESS_BACK, - /* 20 */ PAMERA_DRESS_SIDES, - /* 21 */ PAMERA_LIMB_UNK, - /* 22 */ PAMERA_LIMB_UNK2, - /* 23 */ PAMERA_LIMB_MAX -} ObjectPameraLimbs; - -typedef void (*EnPameraActionFunc)(struct EnPamera*, GlobalContext*); -typedef void (*EnPameraSetupFunc)(struct EnPamera*, GlobalContext*); +typedef void (*EnPameraActionFunc)(struct EnPamera*, PlayState*); +typedef void (*EnPameraSetupFunc)(struct EnPamera*, PlayState*); typedef struct EnPamera { /* 0x000 */ Actor actor; @@ -46,10 +20,10 @@ typedef struct EnPamera { /* 0x1E4 */ s32 pathPointsCount; /* 0x1E8 */ s32 pathId; /* 0x1EC */ s32 unk_1EC; - /* 0x1F0 */ Vec3s jointTable[PAMERA_LIMB_MAX]; - /* 0x27A */ Vec3s morphTable[PAMERA_LIMB_MAX]; - /* 0x304 */ Vec3s limb9Rot; - /* 0x30A */ Vec3s limb8Rot; + /* 0x1F0 */ Vec3s jointTable[PAMELA_LIMB_MAX]; + /* 0x27A */ Vec3s morphTable[PAMELA_LIMB_MAX]; + /* 0x304 */ Vec3s headRot; + /* 0x30A */ Vec3s torsoRot; // Set, but not used /* 0x310 */ s16 unk_310; /* 0x312 */ s16 unk_312; /* 0x314 */ s16 unk_314; 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 542238a17..5feb50245 100644 --- a/src/overlays/actors/ovl_En_Pametfrog/z_en_pametfrog.c +++ b/src/overlays/actors/ovl_En_Pametfrog/z_en_pametfrog.c @@ -5,66 +5,66 @@ */ #include "z_en_pametfrog.h" +#include "z64rumble.h" #include "overlays/actors/ovl_En_Bigpamet/z_en_bigpamet.h" #include "overlays/effects/ovl_Effect_Ss_Hahen/z_eff_ss_hahen.h" -#include "objects/object_bigslime/object_bigslime.h" #define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_4 | ACTOR_FLAG_10 | ACTOR_FLAG_20) #define THIS ((EnPametfrog*)thisx) -void EnPametfrog_Init(Actor* thisx, GlobalContext* globalCtx); -void EnPametfrog_Destroy(Actor* thisx, GlobalContext* globalCtx); -void EnPametfrog_Update(Actor* thisx, GlobalContext* globalCtx); -void EnPametfrog_Draw(Actor* thisx, GlobalContext* globalCtx); +void EnPametfrog_Init(Actor* thisx, PlayState* play); +void EnPametfrog_Destroy(Actor* thisx, PlayState* play); +void EnPametfrog_Update(Actor* thisx, PlayState* play); +void EnPametfrog_Draw(Actor* thisx, PlayState* play); -void EnPametfrog_JumpWaterEffects(EnPametfrog* this, GlobalContext* globalCtx); -void EnPametfrog_RearOnSnapper(EnPametfrog* this, GlobalContext* globalCtx); -void EnPametfrog_RearOnSnapperWave(EnPametfrog* this, GlobalContext* globalCtx); +void EnPametfrog_JumpWaterEffects(EnPametfrog* this, PlayState* play); +void EnPametfrog_RearOnSnapper(EnPametfrog* this, PlayState* play); +void EnPametfrog_RearOnSnapperWave(EnPametfrog* this, PlayState* play); void EnPametfrog_SetupRearOnSnapperWave(EnPametfrog* this); -void EnPametfrog_RearOnSnapperWave(EnPametfrog* this, GlobalContext* globalCtx); +void EnPametfrog_RearOnSnapperWave(EnPametfrog* this, PlayState* play); void EnPametfrog_SetupRearOnSnapperRise(EnPametfrog* this); -void EnPametfrog_RearOnSnapperRise(EnPametfrog* this, GlobalContext* globalCtx); -void EnPametfrog_FallOffSnapper(EnPametfrog* this, GlobalContext* globalCtx); +void EnPametfrog_RearOnSnapperRise(EnPametfrog* this, PlayState* play); +void EnPametfrog_FallOffSnapper(EnPametfrog* this, PlayState* play); void EnPametfrog_SetupJumpToWall(EnPametfrog* this); -void EnPametfrog_JumpToWall(EnPametfrog* this, GlobalContext* globalCtx); +void EnPametfrog_JumpToWall(EnPametfrog* this, PlayState* play); void EnPametfrog_SetupWallCrawl(EnPametfrog* this); -void EnPametfrog_WallCrawl(EnPametfrog* this, GlobalContext* globalCtx); +void EnPametfrog_WallCrawl(EnPametfrog* this, PlayState* play); void EnPametfrog_SetupWallPause(EnPametfrog* this); -void EnPametfrog_WallPause(EnPametfrog* this, GlobalContext* globalCtx); +void EnPametfrog_WallPause(EnPametfrog* this, PlayState* play); void EnPametfrog_SetupClimbDownWall(EnPametfrog* this); -void EnPametfrog_ClimbDownWall(EnPametfrog* this, GlobalContext* globalCtx); +void EnPametfrog_ClimbDownWall(EnPametfrog* this, PlayState* play); void EnPametfrog_SetupRunToSnapper(EnPametfrog* this); -void EnPametfrog_RunToSnapper(EnPametfrog* this, GlobalContext* globalCtx); +void EnPametfrog_RunToSnapper(EnPametfrog* this, PlayState* play); void EnPametfrog_SetupJumpOnSnapper(EnPametfrog* this); -void EnPametfrog_JumpOnSnapper(EnPametfrog* this, GlobalContext* globalCtx); +void EnPametfrog_JumpOnSnapper(EnPametfrog* this, PlayState* play); void EnPametfrog_SetupLandOnSnapper(EnPametfrog* this); -void EnPametfrog_LandOnSnapper(EnPametfrog* this, GlobalContext* globalCtx); -void EnPametfrog_FallInAir(EnPametfrog* this, GlobalContext* globalCtx); -void EnPametfrog_FallOnGround(EnPametfrog* this, GlobalContext* globalCtx); -void EnPametfrog_SetupFallOnGround(EnPametfrog* this, GlobalContext* globalCtx); -void EnPametfrog_SetupDefeatGekko(EnPametfrog* this, GlobalContext* globalCtx); -void EnPametfrog_DefeatGekko(EnPametfrog* this, GlobalContext* globalCtx); -void EnPametfrog_SetupDefeatSnapper(EnPametfrog* this, GlobalContext* globalCtx); -void EnPametfrog_DefeatSnapper(EnPametfrog* this, GlobalContext* globalCtx); -void EnPametfrog_SetupSpawnFrog(EnPametfrog* this, GlobalContext* globalCtx); -void EnPametfrog_SpawnFrog(EnPametfrog* this, GlobalContext* globalCtx); -void EnPametfrog_PlayCutscene(EnPametfrog* this, GlobalContext* globalCtx); +void EnPametfrog_LandOnSnapper(EnPametfrog* this, PlayState* play); +void EnPametfrog_FallInAir(EnPametfrog* this, PlayState* play); +void EnPametfrog_FallOnGround(EnPametfrog* this, PlayState* play); +void EnPametfrog_SetupFallOnGround(EnPametfrog* this, PlayState* play); +void EnPametfrog_SetupDefeatGekko(EnPametfrog* this, PlayState* play); +void EnPametfrog_DefeatGekko(EnPametfrog* this, PlayState* play); +void EnPametfrog_SetupDefeatSnapper(EnPametfrog* this, PlayState* play); +void EnPametfrog_DefeatSnapper(EnPametfrog* this, PlayState* play); +void EnPametfrog_SetupSpawnFrog(EnPametfrog* this, PlayState* play); +void EnPametfrog_SpawnFrog(EnPametfrog* this, PlayState* play); +void EnPametfrog_PlayCutscene(EnPametfrog* this, PlayState* play); void EnPametfrog_SetupLookAround(EnPametfrog* this); -void EnPametfrog_LookAround(EnPametfrog* this, GlobalContext* globalCtx); +void EnPametfrog_LookAround(EnPametfrog* this, PlayState* play); void EnPametfrog_SetupJumpToLink(EnPametfrog* this); -void EnPametfrog_JumpToLink(EnPametfrog* this, GlobalContext* globalCtx); +void EnPametfrog_JumpToLink(EnPametfrog* this, PlayState* play); void EnPametfrog_SetupMeleeAttack(EnPametfrog* this); -void EnPametfrog_MeleeAttack(EnPametfrog* this, GlobalContext* globalCtx); +void EnPametfrog_MeleeAttack(EnPametfrog* this, PlayState* play); void EnPametfrog_SetupCutscene(EnPametfrog* this); -void EnPametfrog_Damage(EnPametfrog* this, GlobalContext* globalCtx); -void EnPametfrog_Stun(EnPametfrog* this, GlobalContext* globalCtx); -void EnPametfrog_SetupCallSnapper(EnPametfrog* this, GlobalContext* globalCtx); -void EnPametfrog_CallSnapper(EnPametfrog* this, GlobalContext* globalCtx); -void EnPametfrog_SetupSnapperSpawn(EnPametfrog* this, GlobalContext* globalCtx); -void EnPametfrog_SnapperSpawn(EnPametfrog* this, GlobalContext* globalCtx); -void EnPametfrog_SetupTransitionGekkoSnapper(EnPametfrog* this, GlobalContext* globalCtx); -void EnPametfrog_TransitionGekkoSnapper(EnPametfrog* this, GlobalContext* globalCtx); +void EnPametfrog_Damage(EnPametfrog* this, PlayState* play); +void EnPametfrog_Stun(EnPametfrog* this, PlayState* play); +void EnPametfrog_SetupCallSnapper(EnPametfrog* this, PlayState* play); +void EnPametfrog_CallSnapper(EnPametfrog* this, PlayState* play); +void EnPametfrog_SetupSnapperSpawn(EnPametfrog* this, PlayState* play); +void EnPametfrog_SnapperSpawn(EnPametfrog* this, PlayState* play); +void EnPametfrog_SetupTransitionGekkoSnapper(EnPametfrog* this, PlayState* play); +void EnPametfrog_TransitionGekkoSnapper(EnPametfrog* this, PlayState* play); const ActorInit En_Pametfrog_InitVars = { ACTOR_EN_PAMETFROG, @@ -156,7 +156,7 @@ static ColliderJntSphInit sJntSphInit = { OC2_TYPE_1, COLSHAPE_JNTSPH, }, - 2, + ARRAY_COUNT(sJntSphElementsInit), sJntSphElementsInit, }; @@ -179,32 +179,31 @@ static s32 isFrogReturnedFlags[] = { (33 << 8) | 0x02, // Laundry Pool Frog Returned }; -void EnPametfrog_Init(Actor* thisx, GlobalContext* globalCtx) { +void EnPametfrog_Init(Actor* thisx, PlayState* play) { EnPametfrog* this = THIS; s32 i; Actor_ProcessInitChain(&this->actor, sInitChain); ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 55.0f); CollisionCheck_SetInfo(&this->actor.colChkInfo, &sDamageTable, &sColChkInit); - SkelAnime_InitFlex(globalCtx, &this->skelAnime, &gGekkoSkel, &gGekkoBoxingStanceAnim, this->jointTable, - this->morphTable, GEKKO_LIMB_MAX); - Collider_InitAndSetJntSph(globalCtx, &this->collider, &this->actor, &sJntSphInit, this->colElement); + SkelAnime_InitFlex(play, &this->skelAnime, &gGekkoSkel, &gGekkoBoxingStanceAnim, this->jointTable, this->morphTable, + GEKKO_LIMB_MAX); + Collider_InitAndSetJntSph(play, &this->collider, &this->actor, &sJntSphInit, this->colElement); this->params = CLAMP(this->actor.params, 1, 4); - if (Flags_GetClear(globalCtx, globalCtx->roomCtx.currRoom.num)) { + if (Flags_GetClear(play, play->roomCtx.currRoom.num)) { Actor_MarkForDeath(&this->actor); 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); + Actor_Spawn(&play->actorCtx, play, 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); } } else { for (i = 0; i < 2; i++) { this->collider.elements[i].dim.worldSphere.radius = this->collider.elements[i].dim.modelSphere.radius; } - if (Actor_SpawnAsChild(&globalCtx->actorCtx, &this->actor, globalCtx, ACTOR_EN_BIGPAMET, - this->actor.world.pos.x, this->actor.world.pos.y, this->actor.world.pos.z, 0, 0, 0, - 0) == NULL) { + if (Actor_SpawnAsChild(&play->actorCtx, &this->actor, play, ACTOR_EN_BIGPAMET, this->actor.world.pos.x, + this->actor.world.pos.y, this->actor.world.pos.z, 0, 0, 0, 0) == NULL) { Actor_MarkForDeath(&this->actor); } else { this->actor.params = GEKKO_PRE_SNAPPER; @@ -213,10 +212,10 @@ void EnPametfrog_Init(Actor* thisx, GlobalContext* globalCtx) { } } -void EnPametfrog_Destroy(Actor* thisx, GlobalContext* globalCtx) { +void EnPametfrog_Destroy(Actor* thisx, PlayState* play) { EnPametfrog* this = THIS; - Collider_DestroyJntSph(globalCtx, &this->collider); + Collider_DestroyJntSph(play, &this->collider); } u8 EnPametfrog_Vec3fNormalize(Vec3f* vec) { @@ -239,38 +238,38 @@ void EnPametfrog_Freeze(EnPametfrog* this) { this->drawDmgEffAlpha = 1.0f; } -void EnPametfrog_Thaw(EnPametfrog* this, GlobalContext* globalCtx) { +void EnPametfrog_Thaw(EnPametfrog* this, PlayState* play) { this->freezeTimer = 0; 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->drawDmgEffAlpha = 0.0f; - Actor_SpawnIceEffects(globalCtx, &this->actor, this->limbPos, ARRAY_COUNT(this->limbPos), 2, 0.3f, 0.2f); + Actor_SpawnIceEffects(play, &this->actor, this->limbPos, ARRAY_COUNT(this->limbPos), 2, 0.3f, 0.2f); } } -void EnPametfrog_JumpWaterEffects(EnPametfrog* this, GlobalContext* globalCtx) { +void EnPametfrog_JumpWaterEffects(EnPametfrog* this, PlayState* play) { Vec3f pos; if (this->actor.depthInWater > 0.0f) { pos.x = this->actor.world.pos.x; pos.z = this->actor.world.pos.z; pos.y = this->actor.world.pos.y + this->actor.depthInWater; - EffectSsGRipple_Spawn(globalCtx, &pos, 150, 550, 0); + EffectSsGRipple_Spawn(play, &pos, 150, 550, 0); pos.y += 8.0f; - EffectSsGSplash_Spawn(globalCtx, &pos, NULL, NULL, 0, 550); + EffectSsGSplash_Spawn(play, &pos, NULL, NULL, 0, 550); } } -void EnPametfrog_IdleWaterEffects(EnPametfrog* this, GlobalContext* globalCtx) { +void EnPametfrog_IdleWaterEffects(EnPametfrog* this, PlayState* play) { Vec3f pos; - if ((this->actor.depthInWater > 0.0f) && ((globalCtx->gameplayFrames % 14) == 0)) { + if ((this->actor.depthInWater > 0.0f) && ((play->gameplayFrames % 14) == 0)) { pos.x = this->actor.world.pos.x; pos.z = this->actor.world.pos.z; pos.y = this->actor.world.pos.y + this->actor.depthInWater; - EffectSsGRipple_Spawn(globalCtx, &pos, 150, 550, 0); + EffectSsGRipple_Spawn(play, &pos, 150, 550, 0); } } @@ -278,16 +277,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 +314,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); @@ -324,8 +323,8 @@ s32 func_8086A2CC(EnPametfrog* this, CollisionPoly* floorPoly) { return true; } -void EnPametfrog_ShakeCamera(EnPametfrog* this, GlobalContext* globalCtx, f32 magShakeXZ, f32 magShakeY) { - Camera* subCam = Play_GetCamera(globalCtx, this->subCamId); +void EnPametfrog_ShakeCamera(EnPametfrog* this, PlayState* play, f32 magShakeXZ, f32 magShakeY) { + Camera* subCam = Play_GetCamera(play, this->subCamId); s16 subCamYaw; Vec3f subCamEye; @@ -333,22 +332,22 @@ void EnPametfrog_ShakeCamera(EnPametfrog* this, GlobalContext* globalCtx, f32 ma 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); + Play_SetCameraAtEye(play, this->subCamId, &subCam->at, &subCamEye); } -void EnPametfrog_StopCutscene(EnPametfrog* this, GlobalContext* globalCtx) { +void EnPametfrog_StopCutscene(EnPametfrog* this, PlayState* play) { Camera* subCam; - 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; + if (this->subCamId != SUB_CAM_ID_DONE) { + subCam = Play_GetCamera(play, this->subCamId); + Play_SetCameraAtEye(play, CAM_ID_MAIN, &subCam->at, &subCam->eye); + this->subCamId = SUB_CAM_ID_DONE; ActorCutscene_Stop(this->cutscene); - func_800B724C(globalCtx, &this->actor, 6); + func_800B724C(play, &this->actor, 6); } } -void EnPametfrog_PlaceSnapper(EnPametfrog* this, GlobalContext* globalCtx) { +void EnPametfrog_PlaceSnapper(EnPametfrog* this, PlayState* play) { CollisionPoly* poly; s32 bgId; Vec3f vec1; @@ -366,7 +365,7 @@ void EnPametfrog_PlaceSnapper(EnPametfrog* this, GlobalContext* globalCtx) { vec3.x = this->actor.child->world.pos.x; vec3.y = this->actor.child->world.pos.y - 150.0f; vec3.z = this->actor.child->world.pos.z; - if (BgCheck_EntityLineTest1(&globalCtx->colCtx, &vec2, &vec3, &vec1, &poly, false, true, false, true, &bgId)) { + if (BgCheck_EntityLineTest1(&play->colCtx, &vec2, &vec3, &vec1, &poly, false, true, false, true, &bgId)) { this->actor.child->floorHeight = vec1.y; } else { this->actor.child->floorHeight = this->actor.home.pos.y; @@ -376,16 +375,16 @@ void EnPametfrog_PlaceSnapper(EnPametfrog* this, GlobalContext* globalCtx) { child->world.pos.y = child->floorHeight - 60.0f; } -void EnPametfrog_JumpOnGround(EnPametfrog* this, GlobalContext* globalCtx) { +void EnPametfrog_JumpOnGround(EnPametfrog* this, PlayState* play) { if (Animation_OnFrame(&this->skelAnime, 1.0f)) { Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_FROG_JUMP); } else if (Animation_OnFrame(&this->skelAnime, 11.0f)) { - EnPametfrog_JumpWaterEffects(this, globalCtx); + EnPametfrog_JumpWaterEffects(this, play); Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_WALK_WATER); } } -void EnPametfrog_ApplyMagicArrowEffects(EnPametfrog* this, GlobalContext* globalCtx) { +void EnPametfrog_ApplyMagicArrowEffects(EnPametfrog* this, PlayState* play) { if (this->actor.colChkInfo.damageEffect == GEKKO_DMGEFF_FIRE) { this->drawDmgEffType = ACTOR_DRAW_DMGEFF_FIRE; this->drawDmgEffAlpha = 3.0f; @@ -394,9 +393,9 @@ void EnPametfrog_ApplyMagicArrowEffects(EnPametfrog* this, GlobalContext* global 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); + Actor_Spawn(&play->actorCtx, play, 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); } else if (this->actor.colChkInfo.damageEffect == GEKKO_DMGEFF_ICE) { EnPametfrog_Freeze(this); } @@ -431,7 +430,7 @@ void EnPametfrog_SetupRearOnSnapper(EnPametfrog* this) { this->actionFunc = EnPametfrog_RearOnSnapper; } -void EnPametfrog_RearOnSnapper(EnPametfrog* this, GlobalContext* globalCtx) { +void EnPametfrog_RearOnSnapper(EnPametfrog* this, PlayState* play) { Actor* actor; Vec3f rearingPoint; s32 pad; @@ -444,7 +443,7 @@ void EnPametfrog_RearOnSnapper(EnPametfrog* this, GlobalContext* globalCtx) { } } - actor = func_800BC270(globalCtx, &this->actor, 60.0f, 0x138B0); + actor = func_800BC270(play, &this->actor, 60.0f, 0x138B0); if (actor != NULL) { rearingPoint.x = this->actor.world.pos.x; rearingPoint.y = this->actor.world.pos.y + 10.0f; @@ -463,7 +462,7 @@ void EnPametfrog_SetupRearOnSnapperWave(EnPametfrog* this) { this->actionFunc = EnPametfrog_RearOnSnapperWave; } -void EnPametfrog_RearOnSnapperWave(EnPametfrog* this, GlobalContext* globalCtx) { +void EnPametfrog_RearOnSnapperWave(EnPametfrog* this, PlayState* play) { if (SkelAnime_Update(&this->skelAnime) && this->timer > 0) { this->timer--; if (this->timer == 0) { @@ -482,7 +481,7 @@ void EnPametfrog_SetupRearOnSnapperRise(EnPametfrog* this) { this->actionFunc = EnPametfrog_RearOnSnapperRise; } -void EnPametfrog_RearOnSnapperRise(EnPametfrog* this, GlobalContext* globalCtx) { +void EnPametfrog_RearOnSnapperRise(EnPametfrog* this, PlayState* play) { SkelAnime_Update(&this->skelAnime); this->timer--; if (this->timer == 0) { @@ -493,7 +492,7 @@ void EnPametfrog_RearOnSnapperRise(EnPametfrog* this, GlobalContext* globalCtx) } } -void EnPametfrog_SetupFallOffSnapper(EnPametfrog* this, GlobalContext* globalCtx) { +void EnPametfrog_SetupFallOffSnapper(EnPametfrog* this, PlayState* play) { Vec3f subCamEye; s16 yaw; @@ -510,12 +509,12 @@ void EnPametfrog_SetupFallOffSnapper(EnPametfrog* this, GlobalContext* globalCtx 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); + Play_SetCameraAtEye(play, this->subCamId, &this->actor.focus.pos, &subCamEye); Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_FROG_DAMAGE); this->actionFunc = EnPametfrog_FallOffSnapper; } -void EnPametfrog_FallOffSnapper(EnPametfrog* this, GlobalContext* globalCtx) { +void EnPametfrog_FallOffSnapper(EnPametfrog* this, PlayState* play) { f32 sin; SkelAnime_Update(&this->skelAnime); @@ -526,15 +525,15 @@ void EnPametfrog_FallOffSnapper(EnPametfrog* this, GlobalContext* globalCtx) { } sin = sin_rad(this->timer * (M_PI / 3)) * ((0.02f * (this->timer * (1.0f / 6.0f))) + 0.005f) + 1.0f; - EnPametfrog_ShakeCamera(this, globalCtx, 300.0f * sin, 100.0f * sin); + EnPametfrog_ShakeCamera(this, play, 300.0f * sin, 100.0f * sin); if (this->actor.bgCheckFlags & 1) { - EnPametfrog_StopCutscene(this, globalCtx); + EnPametfrog_StopCutscene(this, play); EnPametfrog_SetupJumpToWall(this); } } void EnPametfrog_SetupJumpToWall(EnPametfrog* this) { - Animation_Change(&this->skelAnime, &gGekkoJumpForwardAnim, 2.0f, 0.0f, 0.0f, 0, -2.0f); + Animation_Change(&this->skelAnime, &gGekkoJumpForwardAnim, 2.0f, 0.0f, 0.0f, ANIMMODE_LOOP, -2.0f); this->actor.shape.rot.x = 0; this->actor.shape.rot.z = 0; this->actor.bgCheckFlags &= ~8; @@ -542,9 +541,9 @@ void EnPametfrog_SetupJumpToWall(EnPametfrog* this) { this->actionFunc = EnPametfrog_JumpToWall; } -void EnPametfrog_JumpToWall(EnPametfrog* this, GlobalContext* globalCtx) { +void EnPametfrog_JumpToWall(EnPametfrog* this, PlayState* play) { SkelAnime_Update(&this->skelAnime); - EnPametfrog_JumpOnGround(this, globalCtx); + EnPametfrog_JumpOnGround(this, play); if ((this->actor.bgCheckFlags & 1) && (this->actor.bgCheckFlags & 8) && (this->actor.wallBgId == BGCHECK_SCENE) && (COLPOLY_GET_NORMAL(this->actor.wallPoly->normal.y) < 0.5f)) { EnPametfrog_SetupWallCrawl(this); @@ -587,7 +586,7 @@ void EnPametfrog_SetupWallCrawl(EnPametfrog* this) { this->actionFunc = EnPametfrog_WallCrawl; } -void EnPametfrog_WallCrawl(EnPametfrog* this, GlobalContext* globalCtx) { +void EnPametfrog_WallCrawl(EnPametfrog* this, PlayState* play) { CollisionPoly* poly1 = NULL; CollisionPoly* poly2 = NULL; Vec3f vec1; @@ -612,12 +611,11 @@ void EnPametfrog_WallCrawl(EnPametfrog* this, GlobalContext* globalCtx) { vec2.x = this->actor.world.pos.x - this->unk_2DC.x * 25.0f; vec2.y = this->actor.world.pos.y - this->unk_2DC.y * 25.0f; vec2.z = this->actor.world.pos.z - this->unk_2DC.z * 25.0f; - if (BgCheck_EntityLineTest1(&globalCtx->colCtx, &vec1, &vec2, &worldPos2, &poly2, true, true, true, true, - &bgId2)) { + if (BgCheck_EntityLineTest1(&play->colCtx, &vec1, &vec2, &worldPos2, &poly2, true, true, true, true, &bgId2)) { vec2.x = this->unk_2D0.x * doubleSpeedXZ + vec1.x; vec2.y = this->unk_2D0.y * doubleSpeedXZ + vec1.y; vec2.z = this->unk_2D0.z * doubleSpeedXZ + vec1.z; - if (BgCheck_EntityLineTest1(&globalCtx->colCtx, &vec1, &vec2, &worldPos1, &poly1, true, true, true, true, + if (BgCheck_EntityLineTest1(&play->colCtx, &vec1, &vec2, &worldPos1, &poly1, true, true, true, true, &bgId1)) { isSuccess = func_8086A2CC(this, poly1); Math_Vec3f_Copy(&this->actor.world.pos, &worldPos1); @@ -642,7 +640,7 @@ void EnPametfrog_WallCrawl(EnPametfrog* this, GlobalContext* globalCtx) { Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_BOMCHU_WALK); } - if (((globalCtx->gameplayFrames % 60) == 0) && (Rand_ZeroOne() < 0.8f)) { + if (((play->gameplayFrames % 60) == 0) && (Rand_ZeroOne() < 0.8f)) { Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_FROG_REAL); } @@ -675,7 +673,7 @@ void EnPametfrog_SetupWallPause(EnPametfrog* this) { this->actionFunc = EnPametfrog_WallPause; } -void EnPametfrog_WallPause(EnPametfrog* this, GlobalContext* globalCtx) { +void EnPametfrog_WallPause(EnPametfrog* this, PlayState* play) { Vec3f vec; if (this->freezeTimer > 0) { @@ -683,12 +681,12 @@ void EnPametfrog_WallPause(EnPametfrog* this, GlobalContext* globalCtx) { } else { SkelAnime_Update(&this->skelAnime); this->timer--; - Matrix_InsertRotationAroundUnitVector_f(this->wallRotation, &this->unk_2DC, MTXMODE_NEW); - 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); - if (((globalCtx->gameplayFrames % 60) == 0) && (Rand_ZeroOne() < 0.8f)) { + if (((play->gameplayFrames % 60) == 0) && (Rand_ZeroOne() < 0.8f)) { Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_FROG_REAL); } @@ -702,7 +700,7 @@ void EnPametfrog_SetupClimbDownWall(EnPametfrog* this) { s16 yaw; Animation_Change(&this->skelAnime, &gGekkoJumpForwardAnim, 0.0f, 0.0f, - Animation_GetLastFrame(&gGekkoJumpForwardAnim), 2, 0.0f); + Animation_GetLastFrame(&gGekkoJumpForwardAnim), ANIMMODE_ONCE, 0.0f); this->actor.shape.rot.y = Actor_YawBetweenActors(&this->actor, this->actor.child); this->actor.world.rot.y = this->actor.shape.rot.y; this->actor.shape.rot.x = 0; @@ -720,7 +718,7 @@ void EnPametfrog_SetupClimbDownWall(EnPametfrog* this) { this->actionFunc = EnPametfrog_ClimbDownWall; } -void EnPametfrog_ClimbDownWall(EnPametfrog* this, GlobalContext* globalCtx) { +void EnPametfrog_ClimbDownWall(EnPametfrog* this, PlayState* play) { s16 yaw; if (this->actor.bgCheckFlags & 1) { @@ -736,14 +734,14 @@ void EnPametfrog_ClimbDownWall(EnPametfrog* this, GlobalContext* globalCtx) { } void EnPametfrog_SetupRunToSnapper(EnPametfrog* this) { - Animation_Change(&this->skelAnime, &gGekkoJumpForwardAnim, 2.0f, 0.0f, 0.0f, 0, -2.0f); + Animation_Change(&this->skelAnime, &gGekkoJumpForwardAnim, 2.0f, 0.0f, 0.0f, ANIMMODE_LOOP, -2.0f); this->actor.params = GEKKO_RETURN_TO_SNAPPER; this->actionFunc = EnPametfrog_RunToSnapper; } -void EnPametfrog_RunToSnapper(EnPametfrog* this, GlobalContext* globalCtx) { +void EnPametfrog_RunToSnapper(EnPametfrog* this, PlayState* play) { SkelAnime_Update(&this->skelAnime); - EnPametfrog_JumpOnGround(this, globalCtx); + EnPametfrog_JumpOnGround(this, play); this->actor.shape.rot.y = Actor_YawBetweenActors(&this->actor, this->actor.child); this->actor.world.rot.y = this->actor.shape.rot.y; if (!(this->actor.bgCheckFlags & 1) || ((this->skelAnime.curFrame > 1.0f) && (this->skelAnime.curFrame < 12.0f))) { @@ -772,7 +770,7 @@ void EnPametfrog_SetupJumpOnSnapper(EnPametfrog* this) { this->actionFunc = EnPametfrog_JumpOnSnapper; } -void EnPametfrog_JumpOnSnapper(EnPametfrog* this, GlobalContext* globalCtx) { +void EnPametfrog_JumpOnSnapper(EnPametfrog* this, PlayState* play) { f32 temp_f0; EnBigpamet* bigpamet; @@ -797,14 +795,14 @@ void EnPametfrog_SetupLandOnSnapper(EnPametfrog* this) { this->actionFunc = EnPametfrog_LandOnSnapper; } -void EnPametfrog_LandOnSnapper(EnPametfrog* this, GlobalContext* globalCtx) { +void EnPametfrog_LandOnSnapper(EnPametfrog* this, PlayState* play) { if (SkelAnime_Update(&this->skelAnime)) { - EnPametfrog_StopCutscene(this, globalCtx); + EnPametfrog_StopCutscene(this, play); EnPametfrog_SetupRearOnSnapper(this); } } -void EnPametfrog_SetupFallInAir(EnPametfrog* this, GlobalContext* globalCtx) { +void EnPametfrog_SetupFallInAir(EnPametfrog* this, PlayState* play) { s16 yaw; Vec3f subCamEye; f32 xzDist; @@ -828,7 +826,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->subCamId != CAM_ID_MAIN) { + if (this->subCamId != SUB_CAM_ID_DONE) { xzDist = sqrtf(SQXZ(this->unk_2DC)); if (xzDist > 0.001f) { xzDist = 200.0f / xzDist; @@ -841,13 +839,13 @@ void EnPametfrog_SetupFallInAir(EnPametfrog* this, GlobalContext* globalCtx) { 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); + Play_SetCameraAtEye(play, this->subCamId, &this->actor.world.pos, &subCamEye); } this->actionFunc = EnPametfrog_FallInAir; } -void EnPametfrog_FallInAir(EnPametfrog* this, GlobalContext* globalCtx) { +void EnPametfrog_FallInAir(EnPametfrog* this, PlayState* play) { SkelAnime_Update(&this->skelAnime); this->actor.colorFilterTimer = 0x10; if (this->timer > 0) { @@ -858,37 +856,37 @@ void EnPametfrog_FallInAir(EnPametfrog* this, GlobalContext* globalCtx) { } } else { this->spinYaw += 0xF00; - if (this->subCamId != CAM_ID_MAIN) { - Play_CameraSetAtEye(globalCtx, this->subCamId, &this->actor.world.pos, - &Play_GetCamera(globalCtx, this->subCamId)->eye); + if (this->subCamId != SUB_CAM_ID_DONE) { + Play_SetCameraAtEye(play, this->subCamId, &this->actor.world.pos, + &Play_GetCamera(play, this->subCamId)->eye); } if (this->actor.bgCheckFlags & 1) { - EnPametfrog_SetupFallOnGround(this, globalCtx); + EnPametfrog_SetupFallOnGround(this, play); } } } -void EnPametfrog_SetupFallOnGround(EnPametfrog* this, GlobalContext* globalCtx) { +void EnPametfrog_SetupFallOnGround(EnPametfrog* this, PlayState* play) { Animation_PlayOnce(&this->skelAnime, &gGekkoFallOnGroundAnim); this->actor.shape.rot.x = 0; this->actor.shape.rot.y += this->spinYaw; this->actor.shape.rot.z = 0; this->spinYaw = 0; this->timer = 5; - EnPametfrog_Thaw(this, globalCtx); - EnPametfrog_JumpWaterEffects(this, globalCtx); + EnPametfrog_Thaw(this, play); + EnPametfrog_JumpWaterEffects(this, play); Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_WALK_WATER); this->actionFunc = EnPametfrog_FallOnGround; } -void EnPametfrog_FallOnGround(EnPametfrog* this, GlobalContext* globalCtx) { +void EnPametfrog_FallOnGround(EnPametfrog* this, PlayState* play) { if (SkelAnime_Update(&this->skelAnime)) { if (this->skelAnime.animation == &gGekkoFallOnGroundAnim) { if (this->actor.colChkInfo.health == 0) { this->timer--; if (this->timer == 0) { - EnPametfrog_SetupDefeatGekko(this, globalCtx); + EnPametfrog_SetupDefeatGekko(this, play); } } else { Animation_PlayOnce(&this->skelAnime, &gGekkoRecoverAnim); @@ -899,7 +897,7 @@ void EnPametfrog_FallOnGround(EnPametfrog* this, GlobalContext* globalCtx) { } } -void EnPametfrog_SetupDefeatGekko(EnPametfrog* this, GlobalContext* globalCtx) { +void EnPametfrog_SetupDefeatGekko(EnPametfrog* this, PlayState* play) { Vec3f subCamEye; s16 yaw = Actor_YawToPoint(this->actor.child, &this->actor.home.pos); s16 yawDiff = this->actor.yawTowardsPlayer - yaw; @@ -908,23 +906,23 @@ void EnPametfrog_SetupDefeatGekko(EnPametfrog* this, GlobalContext* globalCtx) { 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); + Play_SetCameraAtEye(play, this->subCamId, &this->actor.child->focus.pos, &subCamEye); this->actor.params = GEKKO_DEFEAT; this->timer = 38; this->actionFunc = EnPametfrog_DefeatGekko; } -void EnPametfrog_DefeatGekko(EnPametfrog* this, GlobalContext* globalCtx) { +void EnPametfrog_DefeatGekko(EnPametfrog* this, PlayState* play) { this->actor.colorFilterTimer = 16; if (this->timer > 0) { this->timer--; if (this->timer == 0) { - EnPametfrog_SetupDefeatSnapper(this, globalCtx); + EnPametfrog_SetupDefeatSnapper(this, play); } } } -void EnPametfrog_SetupDefeatSnapper(EnPametfrog* this, GlobalContext* globalCtx) { +void EnPametfrog_SetupDefeatSnapper(EnPametfrog* this, PlayState* play) { Vec3f subCamEye; s16 yaw = Actor_YawToPoint(&this->actor, &this->actor.home.pos); s16 yawDiff = this->actor.yawTowardsPlayer - yaw; @@ -933,60 +931,60 @@ void EnPametfrog_SetupDefeatSnapper(EnPametfrog* this, GlobalContext* globalCtx) 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); + Play_SetCameraAtEye(play, this->subCamId, &this->actor.world.pos, &subCamEye); this->timer = 20; this->actionFunc = EnPametfrog_DefeatSnapper; } -void EnPametfrog_DefeatSnapper(EnPametfrog* this, GlobalContext* globalCtx) { +void EnPametfrog_DefeatSnapper(EnPametfrog* this, PlayState* play) { this->timer--; Actor_SetScale(&this->actor, this->timer * 0.00035000002f); this->actor.colorFilterTimer = 16; - EnPametfrog_ShakeCamera(this, globalCtx, (this->timer * 3.75f) + 75.0f, (this->timer * 0.5f) + 10.0f); + EnPametfrog_ShakeCamera(this, play, (this->timer * 3.75f) + 75.0f, (this->timer * 0.5f) + 10.0f); if (this->timer == 0) { - EnPametfrog_SetupSpawnFrog(this, globalCtx); + EnPametfrog_SetupSpawnFrog(this, play); } } -void EnPametfrog_SetupSpawnFrog(EnPametfrog* this, GlobalContext* globalCtx) { +void EnPametfrog_SetupSpawnFrog(EnPametfrog* this, PlayState* play) { 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(Camera_GetCamDirYaw(GET_ACTIVE_CAM(globalCtx))); + s16 yaw = BINANG_ROT180(Camera_GetCamDirYaw(GET_ACTIVE_CAM(play))); Vec3f vec1; Vec3f vel; s32 i; - Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_MINIFROG, this->actor.world.pos.x, this->actor.world.pos.y, + Actor_Spawn(&play->actorCtx, play, ACTOR_EN_MINIFROG, this->actor.world.pos.x, this->actor.world.pos.y, this->actor.world.pos.z, 0, yaw, 0, this->params); vec1.x = (Math_SinS(yaw) * 20.0f) + this->actor.world.pos.x; vec1.y = this->actor.world.pos.y + 25.0f; vec1.z = (Math_CosS(yaw) * 20.0f) + this->actor.world.pos.z; this->collider.base.ocFlags1 &= ~OC1_ON; - func_800B0DE0(globalCtx, &vec1, &gZeroVec3f, &gZeroVec3f, &primColor, &envColor, 800, 50); - SoundSource_PlaySfxAtFixedWorldPos(globalCtx, &this->actor.world.pos, 40, NA_SE_EN_NPC_APPEAR); - Flags_SetClearTemp(globalCtx, globalCtx->roomCtx.currRoom.num); + func_800B0DE0(play, &vec1, &gZeroVec3f, &gZeroVec3f, &primColor, &envColor, 800, 50); + SoundSource_PlaySfxAtFixedWorldPos(play, &this->actor.world.pos, 40, NA_SE_EN_NPC_APPEAR); + Flags_SetClearTemp(play, play->roomCtx.currRoom.num); for (i = 0; i < 25; i++) { vel.x = randPlusMinusPoint5Scaled(5.0f); vel.y = Rand_ZeroFloat(3.0f) + 4.0f; vel.z = randPlusMinusPoint5Scaled(5.0f); - EffectSsHahen_Spawn(globalCtx, &this->actor.world.pos, &vel, &sAccel, 0, Rand_S16Offset(12, 3), - HAHEN_OBJECT_DEFAULT, 10, 0); + EffectSsHahen_Spawn(play, &this->actor.world.pos, &vel, &sAccel, 0, Rand_S16Offset(12, 3), HAHEN_OBJECT_DEFAULT, + 10, 0); } this->timer = 40; this->actionFunc = EnPametfrog_SpawnFrog; } -void EnPametfrog_SpawnFrog(EnPametfrog* this, GlobalContext* globalCtx) { +void EnPametfrog_SpawnFrog(EnPametfrog* this, PlayState* play) { f32 magShake; this->timer--; magShake = (sin_rad(this->timer * (M_PI / 5)) * ((0.04f * (this->timer * 0.1f)) + 0.02f)) + 1.0f; - EnPametfrog_ShakeCamera(this, globalCtx, 75.0f * magShake, 10.0f * magShake); + EnPametfrog_ShakeCamera(this, play, 75.0f * magShake, 10.0f * magShake); if (this->timer == 0) { - EnPametfrog_StopCutscene(this, globalCtx); + EnPametfrog_StopCutscene(this, play); Actor_MarkForDeath(&this->actor); } } @@ -1004,19 +1002,19 @@ void EnPametfrog_SetupCutscene(EnPametfrog* this) { this->actor.velocity.y = 0.0f; } -void EnPametfrog_PlayCutscene(EnPametfrog* this, GlobalContext* globalCtx) { +void EnPametfrog_PlayCutscene(EnPametfrog* this, PlayState* play) { if (ActorCutscene_GetCanPlayNext(this->cutscene)) { ActorCutscene_Start(this->cutscene, &this->actor); - this->subCamId = ActorCutscene_GetCurrentCamera(this->cutscene); - func_800B724C(globalCtx, &this->actor, 7); + this->subCamId = ActorCutscene_GetCurrentSubCamId(this->cutscene); + func_800B724C(play, &this->actor, 7); if (this->actor.colChkInfo.health == 0) { if (this->actor.params == GEKKO_PRE_SNAPPER) { - EnPametfrog_SetupCallSnapper(this, globalCtx); + EnPametfrog_SetupCallSnapper(this, play); } else { - EnPametfrog_SetupFallInAir(this, globalCtx); + EnPametfrog_SetupFallInAir(this, play); } } else { - EnPametfrog_SetupFallOffSnapper(this, globalCtx); + EnPametfrog_SetupFallOffSnapper(this, play); } } else { ActorCutscene_SetIntentToPlay(this->cutscene); @@ -1031,11 +1029,11 @@ void EnPametfrog_SetupLookAround(EnPametfrog* this) { this->actionFunc = EnPametfrog_LookAround; } -void EnPametfrog_LookAround(EnPametfrog* this, GlobalContext* globalCtx) { - EnPametfrog_IdleWaterEffects(this, globalCtx); +void EnPametfrog_LookAround(EnPametfrog* this, PlayState* play) { + EnPametfrog_IdleWaterEffects(this, play); 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) && !Play_InCsMode(globalCtx)) { + if (SkelAnime_Update(&this->skelAnime) && !Play_InCsMode(play)) { if (!this->unk_2AE) { func_801A2E54(NA_BGM_MINI_BOSS); this->unk_2AE = true; @@ -1051,11 +1049,11 @@ void EnPametfrog_SetupJumpToLink(EnPametfrog* this) { this->actionFunc = EnPametfrog_JumpToLink; } -void EnPametfrog_JumpToLink(EnPametfrog* this, GlobalContext* globalCtx) { +void EnPametfrog_JumpToLink(EnPametfrog* this, PlayState* play) { Math_SmoothStepToS(&this->actor.world.rot.y, this->actor.yawTowardsPlayer, 5, 0x1000, 0x80); this->actor.shape.rot.y = this->actor.world.rot.y; SkelAnime_Update(&this->skelAnime); - EnPametfrog_JumpOnGround(this, globalCtx); + EnPametfrog_JumpOnGround(this, play); if (!(this->actor.bgCheckFlags & 1) || (this->skelAnime.curFrame > 1.0f && this->skelAnime.curFrame < 12.0f)) { this->actor.speedXZ = 8.0f; } else { @@ -1083,8 +1081,8 @@ static AnimationHeader* sAttackAnimations[] = { &gGekkoWindupPunchAnim, }; -void EnPametfrog_MeleeAttack(EnPametfrog* this, GlobalContext* globalCtx) { - EnPametfrog_IdleWaterEffects(this, globalCtx); +void EnPametfrog_MeleeAttack(EnPametfrog* this, PlayState* play) { + EnPametfrog_IdleWaterEffects(this, play); if (SkelAnime_Update(&this->skelAnime)) { this->timer--; if (this->timer == 0) { @@ -1124,7 +1122,7 @@ void EnPametfrog_SetupDamage(EnPametfrog* this) { this->actionFunc = EnPametfrog_Damage; } -void EnPametfrog_Damage(EnPametfrog* this, GlobalContext* globalCtx) { +void EnPametfrog_Damage(EnPametfrog* this, PlayState* play) { SkelAnime_Update(&this->skelAnime); this->timer--; Math_StepToF(&this->actor.speedXZ, 0.0f, 0.5f); @@ -1153,19 +1151,19 @@ void EnPametfrog_SetupStun(EnPametfrog* this) { this->actionFunc = EnPametfrog_Stun; } -void EnPametfrog_Stun(EnPametfrog* this, GlobalContext* globalCtx) { +void EnPametfrog_Stun(EnPametfrog* this, PlayState* play) { this->freezeTimer--; if (this->freezeTimer == 0) { - EnPametfrog_Thaw(this, globalCtx); + EnPametfrog_Thaw(this, play); EnPametfrog_SetupJumpToLink(this); } else if (this->freezeTimer == 78) { - EnPametfrog_Thaw(this, globalCtx); + EnPametfrog_Thaw(this, play); this->actor.colorFilterTimer = 0; EnPametfrog_SetupCutscene(this); } } -void EnPametfrog_SetupCallSnapper(EnPametfrog* this, GlobalContext* globalCtx) { +void EnPametfrog_SetupCallSnapper(EnPametfrog* this, PlayState* play) { Vec3f subCamEye; Vec3f subCamAt; s16 yawDiff; @@ -1191,24 +1189,24 @@ void EnPametfrog_SetupCallSnapper(EnPametfrog* this, GlobalContext* globalCtx) { subCamEye.y = subCamAt.y + 4.0f; // Zooms in on Gekko - Play_CameraSetAtEye(globalCtx, this->subCamId, &subCamAt, &subCamEye); + Play_SetCameraAtEye(play, this->subCamId, &subCamAt, &subCamEye); this->timer = 0; this->actor.hintId = 0x5F; this->actionFunc = EnPametfrog_CallSnapper; } -void EnPametfrog_CallSnapper(EnPametfrog* this, GlobalContext* globalCtx) { +void EnPametfrog_CallSnapper(EnPametfrog* this, PlayState* play) { if (SkelAnime_Update(&this->skelAnime)) { - EnPametfrog_SetupSnapperSpawn(this, globalCtx); + EnPametfrog_SetupSnapperSpawn(this, play); } } -void EnPametfrog_SetupSnapperSpawn(EnPametfrog* this, GlobalContext* globalCtx) { +void EnPametfrog_SetupSnapperSpawn(EnPametfrog* this, PlayState* play) { Vec3f subCamAt; Vec3f subCamEye; s16 yaw; - EnPametfrog_PlaceSnapper(this, globalCtx); + EnPametfrog_PlaceSnapper(this, play); subCamAt.x = this->actor.child->world.pos.x; subCamAt.z = this->actor.child->world.pos.z; subCamAt.y = this->actor.child->floorHeight + 50.0f; @@ -1223,46 +1221,46 @@ void EnPametfrog_SetupSnapperSpawn(EnPametfrog* this, GlobalContext* globalCtx) subCamEye.z = (Math_CosS(yaw) * 500.0f) + subCamAt.z; // Zooms in on Snapper spawn point - Play_CameraSetAtEye(globalCtx, this->subCamId, &subCamAt, &subCamEye); - this->quake = Quake_Add(GET_ACTIVE_CAM(globalCtx), 6); + Play_SetCameraAtEye(play, this->subCamId, &subCamAt, &subCamEye); + this->quake = Quake_Add(GET_ACTIVE_CAM(play), 6); Quake_SetSpeed(this->quake, 18000); Quake_SetQuakeValues(this->quake, 2, 0, 0, 0); Quake_SetCountdown(this->quake, 15); - func_8013ECE0(this->actor.xyzDistToPlayerSq, 120, 20, 10); + Rumble_Request(this->actor.xyzDistToPlayerSq, 120, 20, 10); this->timer = 40; this->actionFunc = EnPametfrog_SnapperSpawn; } -void EnPametfrog_SnapperSpawn(EnPametfrog* this, GlobalContext* globalCtx) { +void EnPametfrog_SnapperSpawn(EnPametfrog* this, PlayState* play) { this->timer--; - EnPametfrog_ShakeCamera(this, globalCtx, (f32)(this->timer * 7.5f) + 200.0f, + EnPametfrog_ShakeCamera(this, play, (f32)(this->timer * 7.5f) + 200.0f, ((f32)(this->timer * 2) * (15.0f / 16.0f)) + -20.0f); if (this->timer != 0) { - func_8013ECE0(this->actor.xyzDistToPlayerSq, 120, 20, 10); + Rumble_Request(this->actor.xyzDistToPlayerSq, 120, 20, 10); } else { - EnPametfrog_SetupTransitionGekkoSnapper(this, globalCtx); + EnPametfrog_SetupTransitionGekkoSnapper(this, play); } } -void EnPametfrog_SetupTransitionGekkoSnapper(EnPametfrog* this, GlobalContext* globalCtx) { +void EnPametfrog_SetupTransitionGekkoSnapper(EnPametfrog* this, PlayState* play) { this->actor.params = GEKKO_GET_SNAPPER; Quake_RemoveFromIdx(this->quake); - this->quake = Quake_Add(GET_ACTIVE_CAM(globalCtx), 3); + this->quake = Quake_Add(GET_ACTIVE_CAM(play), 3); Quake_SetSpeed(this->quake, 20000); Quake_SetQuakeValues(this->quake, 17, 0, 0, 0); Quake_SetCountdown(this->quake, 12); - func_8013ECE0(this->actor.xyzDistToPlayerSq, 255, 20, 150); + Rumble_Request(this->actor.xyzDistToPlayerSq, 255, 20, 150); this->actionFunc = EnPametfrog_TransitionGekkoSnapper; } -void EnPametfrog_TransitionGekkoSnapper(EnPametfrog* this, GlobalContext* globalCtx) { +void EnPametfrog_TransitionGekkoSnapper(EnPametfrog* this, PlayState* play) { if (this->actor.params == GEKKO_INIT_SNAPPER) { func_801A2E54(NA_BGM_MINI_BOSS); EnPametfrog_SetupRunToSnapper(this); } } -void EnPametfrog_ApplyDamageEffect(EnPametfrog* this, GlobalContext* globalCtx) { +void EnPametfrog_ApplyDamageEffect(EnPametfrog* this, PlayState* play) { if (this->collider.base.acFlags & AC_HIT) { this->collider.base.acFlags &= ~AC_HIT; if ((this->drawDmgEffType != ACTOR_DRAW_DMGEFF_FROZEN_NO_SFX) || @@ -1284,7 +1282,7 @@ void EnPametfrog_ApplyDamageEffect(EnPametfrog* this, GlobalContext* globalCtx) Actor_SetColorFilter(&this->actor, 0x4000, 0xFF, 0, 0x50); EnPametfrog_SetupStun(this); } else { - EnPametfrog_Thaw(this, globalCtx); + EnPametfrog_Thaw(this, play); if (this->actor.colChkInfo.damageEffect == GEKKO_DMGEFF_FIRE) { this->drawDmgEffType = ACTOR_DRAW_DMGEFF_FIRE; this->drawDmgEffScale = 0.75f; @@ -1293,18 +1291,17 @@ void EnPametfrog_ApplyDamageEffect(EnPametfrog* this, GlobalContext* globalCtx) 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, - this->collider.elements[0].info.bumper.hitPos.z, 0, 0, 0, - CLEAR_TAG_LARGE_LIGHT_RAYS); + Actor_Spawn( + &play->actorCtx, play, 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); } EnPametfrog_SetupDamage(this); } } else if (Actor_ApplyDamage(&this->actor) == 0) { this->collider.base.acFlags &= ~AC_ON; - EnPametfrog_ApplyMagicArrowEffects(this, globalCtx); - Enemy_StartFinishingBlow(globalCtx, &this->actor); + EnPametfrog_ApplyMagicArrowEffects(this, play); + Enemy_StartFinishingBlow(play, &this->actor); this->actor.flags &= ~ACTOR_FLAG_1; func_801A2ED8(); EnPametfrog_SetupCutscene(this); @@ -1313,14 +1310,14 @@ void EnPametfrog_ApplyDamageEffect(EnPametfrog* this, GlobalContext* globalCtx) } else if (this->actor.colChkInfo.damageEffect == GEKKO_DMGEFF_STUN) { EnPametfrog_ApplyStun(this); } else { - EnPametfrog_ApplyMagicArrowEffects(this, globalCtx); - EnPametfrog_SetupFallInAir(this, globalCtx); + EnPametfrog_ApplyMagicArrowEffects(this, play); + EnPametfrog_SetupFallInAir(this, play); } } } } -void EnPametfrog_Update(Actor* thisx, GlobalContext* globalCtx) { +void EnPametfrog_Update(Actor* thisx, PlayState* play) { EnPametfrog* this = THIS; f32 unk2C4; f32 arg3; @@ -1328,17 +1325,17 @@ void EnPametfrog_Update(Actor* thisx, GlobalContext* globalCtx) { if (this->actor.params == GEKKO_CUTSCENE) { EnPametfrog_SetupCutscene(this); } else if (this->actionFunc != EnPametfrog_PlayCutscene) { - EnPametfrog_ApplyDamageEffect(this, globalCtx); + EnPametfrog_ApplyDamageEffect(this, play); } else { this->collider.base.acFlags &= ~AC_HIT; } - this->actionFunc(this, globalCtx); + this->actionFunc(this, play); if ((this->actionFunc != EnPametfrog_JumpOnSnapper) && (this->actionFunc != EnPametfrog_RearOnSnapperRise)) { if (this->actor.gravity < -0.1f) { Actor_MoveWithGravity(&this->actor); arg3 = this->actionFunc == EnPametfrog_FallInAir ? 3.0f : 15.0f; - Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 25.0f, arg3, 3.0f, 0x1F); + Actor_UpdateBgCheckInfo(play, &this->actor, 25.0f, arg3, 3.0f, 0x1F); } else if (this->freezeTimer == 0) { Actor_MoveWithoutGravity(&this->actor); this->actor.floorHeight = this->actor.world.pos.y; @@ -1346,15 +1343,15 @@ void EnPametfrog_Update(Actor* thisx, GlobalContext* globalCtx) { } if (this->collider.base.atFlags & AT_ON) { - CollisionCheck_SetAT(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + CollisionCheck_SetAT(play, &play->colChkCtx, &this->collider.base); } if (this->collider.base.acFlags & AC_ON) { - CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + CollisionCheck_SetAC(play, &play->colChkCtx, &this->collider.base); } if (this->collider.base.ocFlags1 & OC1_ON) { - CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + CollisionCheck_SetOC(play, &play->colChkCtx, &this->collider.base); } if (this->drawDmgEffAlpha > 0.0f) { @@ -1372,32 +1369,32 @@ void EnPametfrog_Update(Actor* thisx, GlobalContext* globalCtx) { /* value -1: Limb Not used * value 0: GEKKO_LIMB_WAIST - * value 1: GEKKO_LIMB_L_SHIN - * value 2: GEKKO_LIMB_L_FOOT - * value 3: GEKKO_LIMB_R_SHIN - * value 4: GEKKO_LIMB_R_FOOT - * value 5: GEKKO_LIMB_L_UPPER_ARM - * value 6: GEKKO_LIMB_L_FOREARM - * value 7: GEKKO_LIMB_L_HAND - * value 8: GEKKO_LIMB_R_UPPER_ARM - * value 9: GEKKO_LIMB_R_FOREARM - * value 10: GEKKO_LIMB_R_HAND + * value 1: GEKKO_LIMB_LEFT_SHIN + * value 2: GEKKO_LIMB_LEFT_FOOT + * value 3: GEKKO_LIMB_RIGHT_SHIN + * value 4: GEKKO_LIMB_RIGHT_FOOT + * value 5: GEKKO_LIMB_LEFT_UPPER_ARM + * value 6: GEKKO_LIMB_LEFT_FOREARM + * value 7: GEKKO_LIMB_LEFT_HAND + * value 8: GEKKO_LIMB_RIGHT_UPPER_ARM + * value 9: GEKKO_LIMB_RIGHT_FOREARM + * value 10: GEKKO_LIMB_RIGHT_HAND * value 11: GEKKO_LIMB_JAW */ static s8 limbPosIndex[] = { -1, -1, 0, -1, 1, -1, 2, -1, 3, -1, 4, -1, 5, 6, -1, 7, 8, 9, -1, 10, -1, 11, -1, -1, }; -void EnPametfrog_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx) { +void EnPametfrog_PostLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx) { EnPametfrog* this = THIS; Vec3f vec; Vec3s* center; 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; @@ -1410,17 +1407,17 @@ 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]); } } -void EnPametfrog_Draw(Actor* thisx, GlobalContext* globalCtx) { +void EnPametfrog_Draw(Actor* thisx, PlayState* play) { EnPametfrog* this = THIS; - func_8012C28C(globalCtx->state.gfxCtx); - Matrix_RotateY(this->spinYaw, MTXMODE_APPLY); - SkelAnime_DrawFlexOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, - NULL, EnPametfrog_PostLimbDraw, &this->actor); - Actor_DrawDamageEffects(globalCtx, &this->actor, this->limbPos, ARRAY_COUNT(this->limbPos), this->drawDmgEffScale, + func_8012C28C(play->state.gfxCtx); + Matrix_RotateYS(this->spinYaw, MTXMODE_APPLY); + SkelAnime_DrawFlexOpa(play, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, NULL, + EnPametfrog_PostLimbDraw, &this->actor); + Actor_DrawDamageEffects(play, &this->actor, this->limbPos, ARRAY_COUNT(this->limbPos), this->drawDmgEffScale, this->drawDmgEffFrozenSteamScale, this->drawDmgEffAlpha, this->drawDmgEffType); } diff --git a/src/overlays/actors/ovl_En_Pametfrog/z_en_pametfrog.h b/src/overlays/actors/ovl_En_Pametfrog/z_en_pametfrog.h index 2b21f3ea3..3f3e82165 100644 --- a/src/overlays/actors/ovl_En_Pametfrog/z_en_pametfrog.h +++ b/src/overlays/actors/ovl_En_Pametfrog/z_en_pametfrog.h @@ -2,10 +2,11 @@ #define Z_EN_PAMETFROG_H #include "global.h" +#include "objects/object_bigslime/object_bigslime.h" struct EnPametfrog; -typedef void (*EnPametfrogActionFunc)(struct EnPametfrog*, GlobalContext*); +typedef void (*EnPametfrogActionFunc)(struct EnPametfrog*, PlayState*); typedef enum { /* 0x0 */ GEKKO_PRE_SNAPPER, @@ -20,34 +21,6 @@ typedef enum { /* 0x9 */ GEKKO_DEFEAT, } EnPametfrogState; -typedef enum { - /* 0x00 */ GEKKO_LIMB_NONE, - /* 0x01 */ GEKKO_LIMB_ROOT, - /* 0x02 */ GEKKO_LIMB_WAIST, - /* 0x03 */ GEKKO_LIMB_L_THIGH, - /* 0x04 */ GEKKO_LIMB_L_SHIN, - /* 0x05 */ GEKKO_LIMB_L_ANKLE, - /* 0x06 */ GEKKO_LIMB_L_FOOT, - /* 0x07 */ GEKKO_LIMB_R_THIGH, - /* 0x08 */ GEKKO_LIMB_R_SHIN, - /* 0x09 */ GEKKO_LIMB_R_ANKLE, - /* 0x0A */ GEKKO_LIMB_R_FOOT, - /* 0x0B */ GEKKO_LIMB_TORSO, - /* 0x0C */ GEKKO_LIMB_L_UPPER_ARM, - /* 0x0D */ GEKKO_LIMB_L_FOREARM, - /* 0x0E */ GEKKO_LIMB_L_WRIST, - /* 0x0F */ GEKKO_LIMB_L_HAND, - /* 0x10 */ GEKKO_LIMB_R_UPPER_ARM, - /* 0x11 */ GEKKO_LIMB_R_FOREARM, - /* 0x12 */ GEKKO_LIMB_R_WRIST, - /* 0x13 */ GEKKO_LIMB_R_HAND, - /* 0x14 */ GEKKO_LIMB_HEAD, - /* 0x15 */ GEKKO_LIMB_JAW, - /* 0x16 */ GEKKO_LIMB_L_EYE, - /* 0x17 */ GEKKO_LIMB_R_EYE, - /* 0x18 */ GEKKO_LIMB_MAX, -} EnPametfrogLimb; - typedef struct EnPametfrog { /* 0x000 */ Actor actor; /* 0x144 */ SkelAnime skelAnime; @@ -68,9 +41,9 @@ typedef struct EnPametfrog { /* 0x2C4 */ f32 drawDmgEffAlpha; /* 0x2C8 */ f32 drawDmgEffScale; /* 0x2CC */ f32 drawDmgEffFrozenSteamScale; - /* 0x2D0 */ Vec3f unk_2D0; // MtxF zx/zy/zz - /* 0x2DC */ Vec3f unk_2DC; // MtxF yx/yy/yz: wallNorm/floorNorm/Base of Gekko walking??? - /* 0x2E8 */ Vec3f unk_2E8; // MtxF xx/xy/xz + /* 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 50e364529..fd6ac6778 100644 --- a/src/overlays/actors/ovl_En_Paper/z_en_paper.c +++ b/src/overlays/actors/ovl_En_Paper/z_en_paper.c @@ -5,20 +5,24 @@ */ #include "z_en_paper.h" +#include "objects/object_bal/object_bal.h" #define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_100000 | ACTOR_FLAG_2000000) #define THIS ((EnPaper*)thisx) -void EnPaper_Init(Actor* thisx, GlobalContext* globalCtx); -void EnPaper_Destroy(Actor* thisx, GlobalContext* globalCtx); -void EnPaper_Update(Actor* thisx, GlobalContext* globalCtx); -void EnPaper_Draw(Actor* thisx, GlobalContext* globalCtx); +void EnPaper_Init(Actor* thisx, PlayState* play); +void EnPaper_Destroy(Actor* thisx, PlayState* play); +void EnPaper_Update(Actor* thisx, PlayState* play); +void EnPaper_Draw(Actor* thisx, PlayState* play); -void func_80C1F480(EnPaper* this, GlobalContext* globalCtx); -void func_80C1F4FC(EnPaper* this, GlobalContext* globalCtx); +void func_80C1F480(EnPaper* this, PlayState* play); +void func_80C1F4FC(EnPaper* this, PlayState* play); +void func_80C1F46C(EnPaper* this); +void func_80C1F4E8(EnPaper* this); +void func_80C1F55C(EnPaper* this, EnPaperStruct* arg1); +void func_80C1F6E0(EnPaper* this, EnPaperStruct* arg1); -#if 0 const ActorInit En_Paper_InitVars = { ACTOR_EN_PAPER, ACTORCAT_ITEMACTION, @@ -31,28 +35,165 @@ const ActorInit En_Paper_InitVars = { (ActorFunc)EnPaper_Draw, }; -#endif +Vec3f D_80C1FC60 = { 0.0f, 0.0f, 1.0f }; -extern UNK_TYPE D_0600D5A0; +void EnPaper_Init(Actor* thisx, PlayState* play) { + EnPaper* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Paper/EnPaper_Init.s") + Actor_SetScale(&this->actor, 0.01f); + this->timer = 70; + this->unk_D78 = D_80C1FC60; + Actor_UpdateBgCheckInfo(play, &this->actor, 0.0f, 0.0f, 0.0f, 4); + func_80C1F46C(this); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Paper/EnPaper_Destroy.s") +void EnPaper_Destroy(Actor* thisx, PlayState* play) { +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Paper/func_80C1F46C.s") +void func_80C1F46C(EnPaper* this) { + this->actionFunc = func_80C1F480; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Paper/func_80C1F480.s") +void func_80C1F480(EnPaper* this, PlayState* play) { + s32 i; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Paper/func_80C1F4E8.s") + for (i = 0; i < ARRAY_COUNT(this->unk_148); i++) { + func_80C1F55C(this, &this->unk_148[i]); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Paper/func_80C1F4FC.s") + func_80C1F4E8(this); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Paper/func_80C1F55C.s") +void func_80C1F4E8(EnPaper* this) { + this->actionFunc = func_80C1F4FC; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Paper/func_80C1F6E0.s") +void func_80C1F4FC(EnPaper* this, PlayState* play) { + s32 i; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Paper/func_80C1F87C.s") + for (i = 0; i < ARRAY_COUNT(this->unk_148); i++) { + func_80C1F6E0(this, &this->unk_148[i]); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Paper/EnPaper_Update.s") +void func_80C1F55C(EnPaper* this, EnPaperStruct* arg1) { + Matrix_RotateZYX(Rand_Next(), Rand_Next(), Rand_Next(), MTXMODE_NEW); + Matrix_MultVec3f(&D_80C1FC60, &arg1->unk_0C); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Paper/EnPaper_Draw.s") + arg1->unk_18 = this->actor.world.pos; + + arg1->unk_18.x += Rand_Centered() * 4.0f; + arg1->unk_18.y += Rand_Centered() * 4.0f; + arg1->unk_18.z += Rand_Centered() * 4.0f; + + arg1->unk_24 = this->actor.velocity; + + arg1->unk_24.x += Rand_Centered() * 9.0f; + arg1->unk_24.y += Rand_ZeroOne() * 6.0f; + arg1->unk_24.z += Rand_Centered() * 9.0f; + + arg1->unk_30 = Rand_Next(); + arg1->unk_32 = (Rand_Next() >> 4) + 0x16C; + + Matrix_RotateAxisS(arg1->unk_30, &arg1->unk_0C, MTXMODE_NEW); + Matrix_MultVec3f(&D_80C1FC60, &arg1->unk_00); +} + +void func_80C1F6E0(EnPaper* this, EnPaperStruct* arg1) { + f32 sp1C = Math_CosS(arg1->unk_30); + f32 sp18 = Math_SinS(arg1->unk_30); + f32 temp_ft4 = 1.0f - sp1C; + + if (arg1->unk_18.y < (this->actor.floorHeight - 40.0f)) { + return; + } + + arg1->unk_24.y += this->actor.gravity; + + arg1->unk_24.x -= 0.2f * fabsf(arg1->unk_00.x) * (arg1->unk_24.x + this->unk_D78.x); + arg1->unk_24.y -= 0.2f * fabsf(arg1->unk_00.y) * (arg1->unk_24.y + this->unk_D78.y); + arg1->unk_24.z -= 0.2f * fabsf(arg1->unk_00.z) * (arg1->unk_24.z + this->unk_D78.z); + + arg1->unk_30 += arg1->unk_32; + + arg1->unk_18.x += arg1->unk_24.x; + arg1->unk_18.y += arg1->unk_24.y; + arg1->unk_18.z += arg1->unk_24.z; + + arg1->unk_00.x = (arg1->unk_0C.x * temp_ft4 * arg1->unk_0C.z) - (arg1->unk_0C.y * sp18); + arg1->unk_00.y = (arg1->unk_0C.y * temp_ft4 * arg1->unk_0C.z) + (arg1->unk_0C.x * sp18); + arg1->unk_00.z = (arg1->unk_0C.z * temp_ft4 * arg1->unk_0C.z) + sp1C; +} + +void func_80C1F87C(EnPaper* this) { + f32 sp2C = (Rand_Centered() * 4.0f) + 6.0f; + f32 sp28; + + this->unk_D78.y = Math_SinS(this->actor.shape.rot.x) * -sp2C; + + sp28 = Math_CosS(this->actor.shape.rot.x) * -sp2C; + this->unk_D78.x = Math_SinS(this->actor.shape.rot.y) * sp28; + this->unk_D78.z = Math_CosS(this->actor.shape.rot.y) * sp28; + + this->actor.shape.rot.x += (s16)(Rand_Next() >> 8); + this->actor.shape.rot.y += (s16)(Rand_Next() >> 6); + + if (ABS_ALT(this->actor.shape.rot.x) > 0x1555) { + if (this->actor.shape.rot.x > 0) { + this->actor.shape.rot.x = 0x1555; + } else { + this->actor.shape.rot.x = -0x1555; + } + } +} + +void EnPaper_Update(Actor* thisx, PlayState* play) { + EnPaper* this = THIS; + + this->actionFunc(this, play); + + func_80C1F87C(this); + if (this->timer == 0) { + Actor_MarkForDeath(&this->actor); + } else { + this->timer--; + } +} + +void EnPaper_Draw(Actor* thisx, PlayState* play) { + EnPaper* this = THIS; + EnPaperStruct* ptr = this->unk_148; + s32 i; + + OPEN_DISPS(play->state.gfxCtx); + + func_8012C5B0(play->state.gfxCtx); + + gDPSetRenderMode(POLY_OPA_DISP++, G_RM_FOG_SHADE_A, G_RM_AA_ZB_OPA_SURF2); + gDPSetCombineLERP(POLY_OPA_DISP++, 0, 0, 0, SHADE, 0, 0, 0, SHADE, PRIMITIVE, 0, COMBINED, 0, 0, 0, 0, COMBINED); + gSPLoadGeometryMode(POLY_OPA_DISP++, G_ZBUFFER | G_SHADE | G_CULL_BACK | G_FOG | G_LIGHTING | G_SHADING_SMOOTH); + + for (i = 0; i < ARRAY_COUNT(this->unk_148); i++, ptr++) { + if (i == 0) { + gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, 255, 255, 255, 255); + } else if (i == 30) { + gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, 255, 32, 32, 255); + } else if (i == 40) { + gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, 64, 128, 255, 255); + } else if (i == 50) { + gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, 64, 255, 128, 255); + } + + if ((this->actor.floorHeight - 40.0f) < ptr->unk_18.y) { + MtxF* mf = GRAPH_ALLOC(play->state.gfxCtx, sizeof(MtxF)); + + func_8017842C(mf, this->actor.scale.x, this->actor.scale.y, this->actor.scale.z, ptr->unk_30, ptr->unk_0C.x, + ptr->unk_0C.y, ptr->unk_0C.z, ptr->unk_18.x, ptr->unk_18.y, ptr->unk_18.z); + + gSPMatrix(POLY_OPA_DISP++, mf, G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_OPA_DISP++, object_bal_DL_00D5A0); + } + } + + CLOSE_DISPS(play->state.gfxCtx); +} diff --git a/src/overlays/actors/ovl_En_Paper/z_en_paper.h b/src/overlays/actors/ovl_En_Paper/z_en_paper.h index 0147442a9..457229c3d 100644 --- a/src/overlays/actors/ovl_En_Paper/z_en_paper.h +++ b/src/overlays/actors/ovl_En_Paper/z_en_paper.h @@ -5,12 +5,23 @@ struct EnPaper; -typedef void (*EnPaperActionFunc)(struct EnPaper*, GlobalContext*); +typedef void (*EnPaperActionFunc)(struct EnPaper*, PlayState*); + +typedef struct { + /* 0x00 */ Vec3f unk_00; + /* 0x0C */ Vec3f unk_0C; + /* 0x18 */ Vec3f unk_18; + /* 0x24 */ Vec3f unk_24; + /* 0x30 */ s16 unk_30; + /* 0x32 */ s16 unk_32; +} EnPaperStruct; // size = 0x34 typedef struct EnPaper { - /* 0x0000 */ Actor actor; - /* 0x0144 */ EnPaperActionFunc actionFunc; - /* 0x0148 */ char unk_148[0xC40]; + /* 0x000 */ Actor actor; + /* 0x144 */ EnPaperActionFunc actionFunc; + /* 0x148 */ EnPaperStruct unk_148[60]; + /* 0xD78 */ Vec3f unk_D78; + /* 0xD84 */ s16 timer; } EnPaper; // size = 0xD88 extern const ActorInit En_Paper_InitVars; diff --git a/src/overlays/actors/ovl_En_Part/z_en_part.c b/src/overlays/actors/ovl_En_Part/z_en_part.c index bbf098c92..a2f2c618f 100644 --- a/src/overlays/actors/ovl_En_Part/z_en_part.c +++ b/src/overlays/actors/ovl_En_Part/z_en_part.c @@ -10,12 +10,14 @@ #define THIS ((EnPart*)thisx) -void EnPart_Init(Actor* thisx, GlobalContext* globalCtx); -void EnPart_Destroy(Actor* thisx, GlobalContext* globalCtx); -void EnPart_Update(Actor* thisx, GlobalContext* globalCtx); -void EnPart_Draw(Actor* thisx, GlobalContext* globalCtx); +void EnPart_Init(Actor* thisx, PlayState* play); +void EnPart_Destroy(Actor* thisx, PlayState* play); +void EnPart_Update(Actor* thisx, PlayState* play); +void EnPart_Draw(Actor* thisx, PlayState* play); + +void func_80865390(EnPart* this, PlayState* play); +void func_808654C4(EnPart* this, PlayState* play); -#if 0 const ActorInit En_Part_InitVars = { ACTOR_EN_PART, ACTORCAT_ITEMACTION, @@ -28,16 +30,109 @@ const ActorInit En_Part_InitVars = { (ActorFunc)EnPart_Draw, }; -#endif +void EnPart_Init(Actor* thisx, PlayState* play) { +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Part/EnPart_Init.s") +void EnPart_Destroy(Actor* thisx, PlayState* play) { +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Part/EnPart_Destroy.s") +void func_80865390(EnPart* this, PlayState* play) { + this->actionFuncIndex = 1; + this->actor.world.rot.y = Rand_ZeroOne() * 20000.0f; + switch (this->actor.params) { + case ENPART_TYPE_1: + case ENPART_TYPE_4: + this->unk146 += (s16)(Rand_ZeroOne() * 17.0f) + 5; + this->actor.velocity.y = Rand_ZeroOne() * 5.0f + 4.0f; + this->actor.gravity = -0.6f - (Rand_ZeroOne() * 0.5f); + this->unk14C = 0.15f; + break; + case ENPART_TYPE_15: + this->actor.world.rot.y = this->actor.parent->shape.rot.y + 0x8000; + this->unk146 = 100; + this->actor.velocity.y = 7.0f; + this->actor.speedXZ = 2.0f; + this->actor.gravity = -1.0f; + break; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Part/func_80865390.s") +void func_808654C4(EnPart* this, PlayState* play) { + s16 effectScale; + Vec3f effectPos; + Vec3f effectVelocity = { 0.0f, 0.0f, 0.0f }; + s32 i; + Vec3f pos; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Part/func_808654C4.s") + if (this->actor.params == ENPART_TYPE_15) { + this->unk146--; + if (this->unk146 > 0) { + this->actor.shape.rot.x += 0x3A98; + this->actor.shape.rot.y = this->actor.shape.rot.y; + this->actor.shape.rot.z = this->actor.shape.rot.z; + if (BgCheck_SphVsFirstPoly(&play->colCtx, &this->actor.world.pos, 20.0f)) { + this->unk146 = 0; + } + } else { + Math_Vec3f_Copy(&pos, &this->actor.world.pos); + pos.y = this->actor.floorHeight; + func_800B3030(play, &pos, &gZeroVec3f, &gZeroVec3f, this->actor.scale.y * 1400.0f, 7, 0); + SoundSource_PlaySfxAtFixedWorldPos(play, &this->actor.world.pos, 10, NA_SE_EN_EXTINCT); + Actor_MarkForDeath(&this->actor); + } + } else if (this->unk146 <= 0) { + switch (this->actor.params) { + case ENPART_TYPE_1: + func_800B3030(play, &this->actor.world.pos, &gZeroVec3f, &gZeroVec3f, this->actor.scale.y * 4000.0f, 7, + 1); + SoundSource_PlaySfxAtFixedWorldPos(play, &this->actor.world.pos, 10, NA_SE_EN_EXTINCT); + break; + case ENPART_TYPE_4: + for (i = 7; i >= 0; i--) { + effectPos.x = randPlusMinusPoint5Scaled(60.0f) + this->actor.world.pos.x; + effectPos.y = randPlusMinusPoint5Scaled(50.0f) + + (this->actor.world.pos.y + (this->actor.shape.yOffset * this->actor.scale.y)); + effectPos.z = randPlusMinusPoint5Scaled(60.0f) + this->actor.world.pos.z; + effectVelocity.y = Rand_ZeroOne() + 1.0f; + effectScale = Rand_S16Offset(80, 100); + EffectSsDtBubble_SpawnColorProfile(play, &effectPos, &effectVelocity, &gZeroVec3f, effectScale, 25, + 0, 1); + } + break; + } + Actor_MarkForDeath(&this->actor); + } else { + this->unk146--; + this->zRot += this->unk14C; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Part/EnPart_Update.s") +EnPartActionFunc sActionFuncs[] = { func_80865390, func_808654C4 }; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Part/EnPart_Draw.s") +void EnPart_Update(Actor* thisx, PlayState* play) { + EnPart* this = THIS; + + Actor_MoveWithGravity(&this->actor); + (*sActionFuncs[this->actionFuncIndex])(this, play); +} + +void EnPart_Draw(Actor* thisx, PlayState* play) { + EnPart* this = THIS; + + OPEN_DISPS(play->state.gfxCtx); + + if (this->actor.params > ENPART_TYPE_0) { + Matrix_RotateZF(this->zRot, MTXMODE_APPLY); + } + func_8012C28C(play->state.gfxCtx); + func_800B8050(&this->actor, play, 0); + if (this->actor.params == ENPART_TYPE_15) { + gSPSegment(POLY_OPA_DISP++, 0x0C, gEmptyDL); + } + if (this->dList != NULL) { + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_OPA_DISP++, this->dList); + } + + CLOSE_DISPS(play->state.gfxCtx); +} diff --git a/src/overlays/actors/ovl_En_Part/z_en_part.h b/src/overlays/actors/ovl_En_Part/z_en_part.h index fa3dd410f..53a03f281 100644 --- a/src/overlays/actors/ovl_En_Part/z_en_part.h +++ b/src/overlays/actors/ovl_En_Part/z_en_part.h @@ -5,10 +5,22 @@ struct EnPart; +typedef void (*EnPartActionFunc)(struct EnPart*, PlayState*); + +typedef enum { + ENPART_TYPE_0 = 0, + ENPART_TYPE_1 = 1, + ENPART_TYPE_4 = 4, + ENPART_TYPE_15 = 15 +} EnPartParams; + typedef struct EnPart { /* 0x000 */ Actor actor; - /* 0x144 */ char unk_144[0xC]; - /* 0x150 */ Gfx* unk_150; + /* 0x144 */ u8 actionFuncIndex; + /* 0x146 */ s16 unk146; + /* 0x148 */ f32 zRot; + /* 0x14C */ f32 unk14C; + /* 0x150 */ Gfx* dList; } EnPart; // size = 0x154 extern const ActorInit En_Part_InitVars; diff --git a/src/overlays/actors/ovl_En_Peehat/z_en_peehat.c b/src/overlays/actors/ovl_En_Peehat/z_en_peehat.c index a5321bf26..d0598ce79 100644 --- a/src/overlays/actors/ovl_En_Peehat/z_en_peehat.c +++ b/src/overlays/actors/ovl_En_Peehat/z_en_peehat.c @@ -6,36 +6,37 @@ #include "z_en_peehat.h" #include "overlays/actors/ovl_En_Bom/z_en_bom.h" +#include "overlays/effects/ovl_Effect_Ss_Hahen/z_eff_ss_hahen.h" #include "objects/object_ph/object_ph.h" #define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_4 | ACTOR_FLAG_10) #define THIS ((EnPeehat*)thisx) -void EnPeehat_Init(Actor* thisx, GlobalContext* globalCtx); -void EnPeehat_Destroy(Actor* thisx, GlobalContext* globalCtx); -void EnPeehat_Update(Actor* thisx, GlobalContext* globalCtx); -void EnPeehat_Draw(Actor* thisx, GlobalContext* globalCtx); +void EnPeehat_Init(Actor* thisx, PlayState* play); +void EnPeehat_Destroy(Actor* thisx, PlayState* play); +void EnPeehat_Update(Actor* thisx, PlayState* play); +void EnPeehat_Draw(Actor* thisx, PlayState* play); void func_80897498(EnPeehat* this); -void func_80897520(EnPeehat* this, GlobalContext* globalCtx); +void func_80897520(EnPeehat* this, PlayState* play); void func_80897648(EnPeehat* this); -void func_808976DC(EnPeehat* this, GlobalContext* globalCtx); -void func_80897910(EnPeehat* this, GlobalContext* globalCtx); +void func_808976DC(EnPeehat* this, PlayState* play); +void func_80897910(EnPeehat* this, PlayState* play); void func_80897A34(EnPeehat* this); -void func_80897A94(EnPeehat* this, GlobalContext* globalCtx); -void func_80897D48(EnPeehat* this, GlobalContext* globalCtx); +void func_80897A94(EnPeehat* this, PlayState* play); +void func_80897D48(EnPeehat* this, PlayState* play); void func_80897EAC(EnPeehat* this); -void func_80897F44(EnPeehat* this, GlobalContext* globalCtx); +void func_80897F44(EnPeehat* this, PlayState* play); void func_80898124(EnPeehat* this); -void func_80898144(EnPeehat* this, GlobalContext* globalCtx); +void func_80898144(EnPeehat* this, PlayState* play); void func_808982E0(EnPeehat* this); -void func_80898338(EnPeehat* this, GlobalContext* globalCtx); -void func_80898454(EnPeehat* this, GlobalContext* globalCtx); +void func_80898338(EnPeehat* this, PlayState* play); +void func_80898454(EnPeehat* this, PlayState* play); void func_808984E0(EnPeehat* this); -void func_80898594(EnPeehat* this, GlobalContext* globalCtx); +void func_80898594(EnPeehat* this, PlayState* play); void func_80898654(EnPeehat* this); -void func_808986A4(EnPeehat* this, GlobalContext* globalCtx); +void func_808986A4(EnPeehat* this, PlayState* play); const ActorInit En_Peehat_InitVars = { ACTOR_EN_PEEHAT, @@ -123,7 +124,7 @@ static ColliderTrisInit sTrisInit = { OC2_TYPE_1, COLSHAPE_TRIS, }, - 2, + ARRAY_COUNT(sTrisElementsInit), sTrisElementsInit, }; @@ -173,19 +174,19 @@ static InitChainEntry sInitChain[] = { ICHAIN_F32(targetArrowOffset, 700, ICHAIN_STOP), }; -void EnPeehat_Init(Actor* thisx, GlobalContext* globalCtx) { +void EnPeehat_Init(Actor* thisx, PlayState* play) { EnPeehat* this = THIS; Actor_ProcessInitChain(&this->actor, sInitChain); - SkelAnime_Init(globalCtx, &this->skelAnime, &object_ph_Skel_001C80, &object_ph_Anim_0009C4, this->jointTable, + SkelAnime_Init(play, &this->skelAnime, &object_ph_Skel_001C80, &object_ph_Anim_0009C4, this->jointTable, this->morphTable, 24); ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 27.0f); this->unk_2B0 = 0; Math_Vec3f_Copy(&this->actor.focus.pos, &this->actor.world.pos); this->actor.floorHeight = this->actor.world.pos.y; - Collider_InitAndSetCylinder(globalCtx, &this->colliderCylinder, &this->actor, &sCylinderInit); - Collider_InitAndSetSphere(globalCtx, &this->colliderSphere, &this->actor, &sSphereInit); - Collider_InitAndSetTris(globalCtx, &this->colliderTris, &this->actor, &sTrisInit, this->colliderTriElements); + Collider_InitAndSetCylinder(play, &this->colliderCylinder, &this->actor, &sCylinderInit); + Collider_InitAndSetSphere(play, &this->colliderSphere, &this->actor, &sSphereInit); + Collider_InitAndSetTris(play, &this->colliderTris, &this->actor, &sTrisInit, this->colliderTriElements); if (this->actor.params == 0) { CollisionCheck_SetInfo2(&this->actor.colChkInfo, &sDamageTable, &sColChkInfoInit1); @@ -211,12 +212,12 @@ void EnPeehat_Init(Actor* thisx, GlobalContext* globalCtx) { } } -void EnPeehat_Destroy(Actor* thisx, GlobalContext* globalCtx) { +void EnPeehat_Destroy(Actor* thisx, PlayState* play) { EnPeehat* this = THIS; - Collider_DestroyCylinder(globalCtx, &this->colliderCylinder); - Collider_DestroySphere(globalCtx, &this->colliderSphere); - Collider_DestroyTris(globalCtx, &this->colliderTris); + Collider_DestroyCylinder(play, &this->colliderCylinder); + Collider_DestroySphere(play, &this->colliderSphere); + Collider_DestroyTris(play, &this->colliderTris); if (this->actor.params != 0) { EnPeehat* parent = (EnPeehat*)this->actor.parent; @@ -236,20 +237,20 @@ void func_80897170(EnPeehat* this) { Actor_SetColorFilter(&this->actor, 0x4000, 255, 0, 80); } -void func_808971DC(EnPeehat* this, GlobalContext* globalCtx) { +void func_808971DC(EnPeehat* this, PlayState* play) { if (this->drawDmgEffType == ACTOR_DRAW_DMGEFF_FROZEN_NO_SFX) { this->drawDmgEffType = ACTOR_DRAW_DMGEFF_FIRE; this->colliderSphere.base.colType = COLTYPE_HIT6; this->drawDmgEffAlpha = 0.0f; - Actor_SpawnIceEffects(globalCtx, &this->actor, this->limbPos, ARRAY_COUNT(this->limbPos), 2, 0.5f, 0.35f); + Actor_SpawnIceEffects(play, &this->actor, this->limbPos, ARRAY_COUNT(this->limbPos), 2, 0.5f, 0.35f); } } -void func_80897258(GlobalContext* globalCtx, EnPeehat* this, Vec3f* arg2, f32 arg3, f32 arg4) { +void func_80897258(PlayState* play, EnPeehat* this, Vec3f* arg2, f32 arg3, f32 arg4) { static Vec3f D_80899558 = { 0.0f, 8.0f, 0.0f }; static Vec3f D_80899564 = { 0.0f, -1.5f, 0.0f }; Vec3f sp44; - s16 sp42 = Rand_Next() >> 0x10; + s16 sp42 = (s32)Rand_Next() >> 0x10; s32 temp_v1; sp44.y = this->actor.floorHeight; @@ -260,11 +261,11 @@ void func_80897258(GlobalContext* globalCtx, EnPeehat* this, Vec3f* arg2, f32 ar D_80899564.z = randPlusMinusPoint5Scaled(1.05f); D_80899558.y = randPlusMinusPoint5Scaled(4.0f) + 8.0f; - EffectSsHahen_Spawn(globalCtx, &sp44, &D_80899558, &D_80899564, 0, (Rand_ZeroFloat(5.0f) + 12.0f) * arg4, -1, 10, - NULL); + EffectSsHahen_Spawn(play, &sp44, &D_80899558, &D_80899564, 0, (Rand_ZeroFloat(5.0f) + 12.0f) * arg4, + HAHEN_OBJECT_DEFAULT, 10, NULL); } -void func_80897390(EnPeehat* this, GlobalContext* globalCtx) { +void func_80897390(EnPeehat* this, PlayState* play) { s32 i; s16 phi_s2 = BINANG_ROT180(this->actor.yawTowardsPlayer); Actor* actor; @@ -272,9 +273,8 @@ void func_80897390(EnPeehat* this, GlobalContext* globalCtx) { this->colliderCylinder.base.acFlags &= ~AC_HIT; for (i = 3 - this->unk_2AC; i > 0; i--) { - actor = - Actor_SpawnAsChild(&globalCtx->actorCtx, &this->actor, globalCtx, ACTOR_EN_PEEHAT, this->actor.world.pos.x, - this->actor.world.pos.y + 50.0f, this->actor.world.pos.z, 0, phi_s2, 0, 1); + actor = Actor_SpawnAsChild(&play->actorCtx, &this->actor, play, ACTOR_EN_PEEHAT, this->actor.world.pos.x, + this->actor.world.pos.y + 50.0f, this->actor.world.pos.z, 0, phi_s2, 0, 1); phi_s2 += 0x5555; if (actor != NULL) { @@ -288,14 +288,14 @@ void func_80897390(EnPeehat* this, GlobalContext* globalCtx) { void func_80897498(EnPeehat* this) { Animation_Change(&this->skelAnime, &object_ph_Anim_0009C4, 0.0f, 3.0f, - Animation_GetLastFrame(&object_ph_Anim_0009C4), 2, 0.0f); + Animation_GetLastFrame(&object_ph_Anim_0009C4), ANIMMODE_ONCE, 0.0f); this->unk_2B0 = 0; this->unk_2AD = 1; this->colliderCylinder.base.acFlags &= ~AC_HIT; this->actionFunc = func_80897520; } -void func_80897520(EnPeehat* this, GlobalContext* globalCtx) { +void func_80897520(EnPeehat* this, PlayState* play) { if (!gSaveContext.save.isNight) { this->actor.flags |= ACTOR_FLAG_1; this->colliderSphere.base.acFlags |= AC_ON; @@ -316,7 +316,7 @@ void func_80897520(EnPeehat* this, GlobalContext* globalCtx) { Math_StepToF(&this->unk_2C4, 0.0f, 0.005f); } } else if (this->colliderCylinder.base.acFlags & AC_HIT) { - func_80897390(this, globalCtx); + func_80897390(this, play); } } } @@ -324,14 +324,14 @@ void func_80897520(EnPeehat* this, GlobalContext* globalCtx) { void func_80897648(EnPeehat* this) { if (this->actionFunc != func_80898454) { Animation_Change(&this->skelAnime, &object_ph_Anim_0009C4, 0.0f, 3.0f, - Animation_GetLastFrame(&object_ph_Anim_0009C4), 2, 0.0f); + Animation_GetLastFrame(&object_ph_Anim_0009C4), ANIMMODE_ONCE, 0.0f); } this->unk_2B0 = 16; Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_PIHAT_UP); this->actionFunc = func_808976DC; } -void func_808976DC(EnPeehat* this, GlobalContext* globalCtx) { +void func_808976DC(EnPeehat* this, PlayState* play) { Vec3f sp34; Math_StepToF(&this->actor.shape.yOffset, 0.0f, 50.0f); @@ -354,11 +354,11 @@ void func_808976DC(EnPeehat* this, GlobalContext* globalCtx) { if ((this->actor.world.pos.y - this->actor.floorHeight) < 80.0f) { Math_Vec3f_Copy(&sp34, &this->actor.world.pos); sp34.y = this->actor.floorHeight; - func_800BBFB0(globalCtx, &sp34, 90.0f, 1, 150, 100, 1); + func_800BBFB0(play, &sp34, 90.0f, 1, 150, 100, 1); } } - func_80897258(globalCtx, this, &this->actor.world.pos, 75.0f, 2.0f); + func_80897258(play, this, &this->actor.world.pos, 75.0f, 2.0f); Math_StepToF(&this->unk_2C4, 0.075f, 0.005f); this->unk_2B4 += this->unk_2B2; } @@ -375,8 +375,8 @@ void func_80897864(EnPeehat* this) { this->actionFunc = func_80897910; } -void func_80897910(EnPeehat* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); +void func_80897910(EnPeehat* this, PlayState* play) { + Player* player = GET_PLAYER(play); Math_StepToF(&this->actor.speedXZ, 3.0f, 0.25f); Math_StepToF(&this->actor.world.pos.y, this->actor.floorHeight + 80.0f, 3.0f); @@ -401,7 +401,7 @@ void func_80897A34(EnPeehat* this) { this->actionFunc = func_80897A94; } -void func_80897A94(EnPeehat* this, GlobalContext* globalCtx) { +void func_80897A94(EnPeehat* this, PlayState* play) { s32 pad; if ((this->actor.parent != NULL) && (this->actor.parent->update == NULL)) { @@ -433,10 +433,10 @@ void func_80897A94(EnPeehat* this, GlobalContext* globalCtx) { this->actor.colChkInfo.health = 0; func_808982E0(this); } else if ((this->colliderCylinder.base.acFlags & AC_HIT) || (this->actor.bgCheckFlags & 1)) { - func_800B3030(globalCtx, &this->actor.world.pos, &gZeroVec3f, &gZeroVec3f, 40, 7, 0); - SoundSource_PlaySfxAtFixedWorldPos(globalCtx, &this->actor.world.pos, 11, NA_SE_EN_EXTINCT); + func_800B3030(play, &this->actor.world.pos, &gZeroVec3f, &gZeroVec3f, 40, 7, 0); + SoundSource_PlaySfxAtFixedWorldPos(play, &this->actor.world.pos, 11, NA_SE_EN_EXTINCT); if (!(this->actor.bgCheckFlags & 1)) { - SoundSource_PlaySfxAtFixedWorldPos(globalCtx, &this->actor.world.pos, 40, NA_SE_EN_PIHAT_SM_DEAD); + SoundSource_PlaySfxAtFixedWorldPos(play, &this->actor.world.pos, 40, NA_SE_EN_PIHAT_SM_DEAD); } Actor_MarkForDeath(&this->actor); } else if (this->colliderTris.base.atFlags & AT_HIT) { @@ -465,7 +465,7 @@ void func_80897D00(EnPeehat* this) { this->actionFunc = func_80897D48; } -void func_80897D48(EnPeehat* this, GlobalContext* globalCtx) { +void func_80897D48(EnPeehat* this, PlayState* play) { Vec3f sp34; Math_StepToF(&this->actor.shape.yOffset, -1000.0f, 50.0f); @@ -480,8 +480,8 @@ void func_80897D48(EnPeehat* this, GlobalContext* globalCtx) { if ((this->actor.world.pos.y - this->actor.floorHeight) < 60.0f) { Math_Vec3f_Copy(&sp34, &this->actor.world.pos); sp34.y = this->actor.floorHeight; - func_800BBFB0(globalCtx, &sp34, 80.0f, 1, 150, 100, 1); - func_80897258(globalCtx, this, &sp34, 75.0f, 2.0f); + func_800BBFB0(play, &sp34, 80.0f, 1, 150, 100, 1); + func_80897258(play, this, &sp34, 75.0f, 2.0f); } } Math_ScaledStepToS(&this->unk_2B2, 0, 100); @@ -497,10 +497,10 @@ void func_80897EAC(EnPeehat* this) { this->actionFunc = func_80897F44; } -void func_80897F44(EnPeehat* this, GlobalContext* globalCtx) { +void func_80897F44(EnPeehat* this, PlayState* play) { s32 pad; f32 cos; - Player* player = GET_PLAYER(globalCtx); + Player* player = GET_PLAYER(play); if ((this->actor.world.pos.y - this->actor.floorHeight) > 75.0f) { this->actor.world.pos.y -= 1.0f; @@ -539,10 +539,10 @@ void func_80898124(EnPeehat* this) { this->actor.speedXZ = 2.5f; } -void func_80898144(EnPeehat* this, GlobalContext* globalCtx) { +void func_80898144(EnPeehat* this, PlayState* play) { s32 step; f32 cos; - Player* player = GET_PLAYER(globalCtx); + Player* player = GET_PLAYER(play); if ((this->actor.world.pos.y - this->actor.floorHeight) > 75.0f) { this->actor.world.pos.y -= 1.0f; @@ -579,15 +579,15 @@ void func_808982E0(EnPeehat* this) { this->actionFunc = func_80898338; } -void func_80898338(EnPeehat* this, GlobalContext* globalCtx) { +void func_80898338(EnPeehat* this, PlayState* play) { this->unk_2B4 += this->unk_2B2; SkelAnime_Update(&this->skelAnime); if (Math_StepToF(&this->actor.speedXZ, 0.0f, 0.5f)) { if (this->actor.params != 0) { - func_800B3030(globalCtx, &this->actor.world.pos, &gZeroVec3f, &gZeroVec3f, 40, 7, 0); - SoundSource_PlaySfxAtFixedWorldPos(globalCtx, &this->actor.world.pos, 30, NA_SE_EN_EXTINCT); - SoundSource_PlaySfxAtFixedWorldPos(globalCtx, &this->actor.world.pos, 40, NA_SE_EN_PIHAT_SM_DEAD); + func_800B3030(play, &this->actor.world.pos, &gZeroVec3f, &gZeroVec3f, 40, 7, 0); + SoundSource_PlaySfxAtFixedWorldPos(play, &this->actor.world.pos, 30, NA_SE_EN_EXTINCT); + SoundSource_PlaySfxAtFixedWorldPos(play, &this->actor.world.pos, 40, NA_SE_EN_PIHAT_SM_DEAD); Actor_MarkForDeath(&this->actor); } else { func_80897864(this); @@ -603,7 +603,7 @@ void func_80898414(EnPeehat* this) { this->actionFunc = func_80898454; } -void func_80898454(EnPeehat* this, GlobalContext* globalCtx) { +void func_80898454(EnPeehat* this, PlayState* play) { if (this->unk_2B0 != 0) { this->unk_2B0--; } @@ -611,7 +611,7 @@ void func_80898454(EnPeehat* this, GlobalContext* globalCtx) { Math_StepToF(&this->actor.world.pos.y, this->actor.floorHeight, 8.0f); if (this->unk_2B0 == 0) { - func_808971DC(this, globalCtx); + func_808971DC(this, play); if (this->actor.colChkInfo.health == 0) { func_808984E0(this); } else { @@ -635,7 +635,7 @@ void func_808984E0(EnPeehat* this) { this->actionFunc = func_80898594; } -void func_80898594(EnPeehat* this, GlobalContext* globalCtx) { +void func_80898594(EnPeehat* this, PlayState* play) { SkelAnime_Update(&this->skelAnime); this->unk_2B4 += this->unk_2B2; Math_ScaledStepToS(&this->unk_2B2, 4000, 250); @@ -658,9 +658,9 @@ void func_80898654(EnPeehat* this) { this->actionFunc = func_808986A4; } -void func_808986A4(EnPeehat* this, GlobalContext* globalCtx) { +void func_808986A4(EnPeehat* this, PlayState* play) { if (this->unk_2B0 == 5) { - EnBom* bomb = (EnBom*)Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_BOM, this->actor.world.pos.x, + EnBom* bomb = (EnBom*)Actor_Spawn(&play->actorCtx, play, ACTOR_EN_BOM, this->actor.world.pos.x, this->actor.world.pos.y, this->actor.world.pos.z, 0, 0, 0x602, 0); if (bomb != NULL) { @@ -671,12 +671,12 @@ void func_808986A4(EnPeehat* this, GlobalContext* globalCtx) { this->unk_2B0--; if (this->unk_2B0 == 0) { - Item_DropCollectibleRandom(globalCtx, &this->actor, &this->actor.world.pos, 0xE0); + Item_DropCollectibleRandom(play, &this->actor, &this->actor.world.pos, 0xE0); Actor_MarkForDeath(&this->actor); } } -void func_8089874C(EnPeehat* this, GlobalContext* globalCtx) { +void func_8089874C(EnPeehat* this, PlayState* play) { if (this->colliderTris.base.acFlags & AC_BOUNCED) { this->colliderTris.base.acFlags &= ~AC_BOUNCED; this->colliderSphere.base.acFlags &= ~AC_HIT; @@ -688,12 +688,12 @@ void func_8089874C(EnPeehat* this, GlobalContext* globalCtx) { 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); + Enemy_StartFinishingBlow(play, &this->actor); } this->colliderTris.base.atFlags &= ~(AT_HIT | AT_ON); Actor_SetDropFlag(&this->actor, &this->colliderSphere.info); - func_808971DC(this, globalCtx); + func_808971DC(this, play); if (this->actor.colChkInfo.damageEffect == 5) { this->unk_2B0 = 40; @@ -724,9 +724,9 @@ void func_8089874C(EnPeehat* this, GlobalContext* globalCtx) { 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); + Actor_Spawn(&play->actorCtx, play, ACTOR_EN_CLEAR_TAG, this->colliderSphere.info.bumper.hitPos.x, + this->colliderSphere.info.bumper.hitPos.y, this->colliderSphere.info.bumper.hitPos.z, 0, + 0, 0, CLEAR_TAG_LARGE_LIGHT_RAYS); } func_800BE568(&this->actor, &this->colliderSphere); func_808984E0(this); @@ -736,25 +736,25 @@ void func_8089874C(EnPeehat* this, GlobalContext* globalCtx) { (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); + func_808971DC(this, play); this->actor.colorFilterTimer = 0; func_80897648(this); } } -void EnPeehat_Update(Actor* thisx, GlobalContext* globalCtx2) { - GlobalContext* globalCtx = globalCtx2; +void EnPeehat_Update(Actor* thisx, PlayState* play2) { + PlayState* play = play2; EnPeehat* this = THIS; if (thisx->params == 0) { - func_8089874C(this, globalCtx); + func_8089874C(this, play); } Actor_MoveWithGravity(thisx); - Actor_UpdateBgCheckInfo(globalCtx, thisx, 25.0f, 30.0f, 30.0f, 5); + Actor_UpdateBgCheckInfo(play, thisx, 25.0f, 30.0f, 30.0f, 5); - this->actionFunc(this, globalCtx); + this->actionFunc(this, play); - if ((globalCtx->gameplayFrames % 128) == 0) { + if ((play->gameplayFrames % 128) == 0) { this->unk_2C0 = Rand_ZeroFloat(0.25f) + 0.5f; } @@ -772,13 +772,13 @@ void EnPeehat_Update(Actor* thisx, GlobalContext* globalCtx2) { Collider_UpdateCylinder(thisx, &this->colliderCylinder); this->colliderCylinder.dim.pos.y += (s16)(thisx->shape.yOffset * thisx->scale.y); if (this->colliderCylinder.base.ocFlags1 & OC1_ON) { - CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->colliderCylinder.base); + CollisionCheck_SetOC(play, &play->colChkCtx, &this->colliderCylinder.base); } if (thisx->params == 0) { - CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->colliderSphere.base); + CollisionCheck_SetOC(play, &play->colChkCtx, &this->colliderSphere.base); if (this->colliderSphere.base.acFlags & AC_ON) { - CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->colliderSphere.base); + CollisionCheck_SetAC(play, &play->colChkCtx, &this->colliderSphere.base); } } @@ -789,7 +789,7 @@ void EnPeehat_Update(Actor* thisx, GlobalContext* globalCtx2) { if (this->colliderTris.base.atFlags & AT_ON) { thisx->flags |= 0x1000000; - CollisionCheck_SetAT(globalCtx, &globalCtx->colChkCtx, &this->colliderTris.base); + CollisionCheck_SetAT(play, &play->colChkCtx, &this->colliderTris.base); if (thisx->params == 0) { Vec3f sp74; CollisionPoly* sp70; @@ -797,19 +797,19 @@ void EnPeehat_Update(Actor* thisx, GlobalContext* globalCtx2) { s32 i; sp70 = NULL; - CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->colliderTris.base); + CollisionCheck_SetAC(play, &play->colChkCtx, &this->colliderTris.base); for (i = 1; i >= 0; i--) { - 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); + if (BgCheck_EntityLineTest1(&play->colCtx, &thisx->world.pos, &this->unk_2D4[i], &sp74, &sp70, true, + true, false, true, &sp6C)) { + func_800BBFB0(play, &sp74, 0.0f, 1, 300, 150, 1); + func_80897258(play, this, &sp74, 0.0f, 1.5f); } } } } - CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->colliderCylinder.base); + CollisionCheck_SetAC(play, &play->colChkCtx, &this->colliderCylinder.base); if (this->actionFunc != func_80898454) { Math_StepToF(&this->unk_2C4, 0.0f, 0.001f); @@ -831,8 +831,7 @@ void EnPeehat_Update(Actor* thisx, GlobalContext* globalCtx2) { } } -s32 EnPeehat_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, - Actor* thisx) { +s32 EnPeehat_OverrideLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, Actor* thisx) { EnPeehat* this = THIS; s32 pad; @@ -840,32 +839,32 @@ s32 EnPeehat_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dLi rot->x = -this->unk_2B4; } else if ((limbIndex == 3) || ((limbIndex == 23) && ((this->actionFunc == func_80898594) || (this->actionFunc == func_80897520)))) { - OPEN_DISPS(globalCtx->state.gfxCtx); + OPEN_DISPS(play->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); + gSPMatrix(&gfx[0], Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(&gfx[1], *dList); - Matrix_StatePop(); + Matrix_Pop(); POLY_OPA_DISP = &gfx[2]; - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->state.gfxCtx); return true; } return false; } -void EnPeehat_PostLimbDraw(GlobalContext* globalCtx2, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx) { +void EnPeehat_PostLimbDraw(PlayState* play2, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx) { static Vec3f D_80899570[] = { { 1300.0f, 1200.0f, 0.0f }, { 1300.0f, -1200.0f, 0.0f }, @@ -875,68 +874,68 @@ void EnPeehat_PostLimbDraw(GlobalContext* globalCtx2, s32 limbIndex, Gfx** dList static s8 D_808995A0[] = { -1, -1, -1, -1, -1, -1, -1, 0, -1, -1, 2, -1, -1, 4, -1, -1, 6, -1, -1, 8, -1, -1, 10, -1, }; - GlobalContext* globalCtx = globalCtx2; + PlayState* play = play2; EnPeehat* this = THIS; s32 i; s32 index = D_808995A0[limbIndex]; Gfx* gfx; if (index != -1) { - Matrix_GetStateTranslationAndScaledX(2000.0f, &this->limbPos[index]); - Matrix_GetStateTranslationAndScaledX(4000.0f, &this->limbPos[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->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); + OPEN_DISPS(play->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); + gSPMatrix(&gfx[0], Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(&gfx[1], *dList); POLY_OPA_DISP = &gfx[2]; Math_Vec3s_ToVec3f(&this->actor.focus.pos, &this->colliderSphere.dim.worldSphere.center); - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->state.gfxCtx); } } -void EnPeehat_Draw(Actor* thisx, GlobalContext* globalCtx) { +void EnPeehat_Draw(Actor* thisx, PlayState* play) { EnPeehat* this = THIS; Vec3f sp58; Vec3f sp4C; Vec3f sp40; s32 i; - func_8012C28C(globalCtx->state.gfxCtx); + func_8012C28C(play->state.gfxCtx); - SkelAnime_DrawOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, EnPeehat_OverrideLimbDraw, + SkelAnime_DrawOpa(play, this->skelAnime.skeleton, this->skelAnime.jointTable, EnPeehat_OverrideLimbDraw, (this->actor.params == 0) ? EnPeehat_PostLimbDraw : NULL, &this->actor); if ((this->actor.speedXZ != 0.0f) || (this->actor.velocity.y != 0.0f)) { - 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); } @@ -946,6 +945,6 @@ void EnPeehat_Draw(Actor* thisx, GlobalContext* globalCtx) { } } - Actor_DrawDamageEffects(globalCtx, &this->actor, this->limbPos, ARRAY_COUNT(this->limbPos), this->drawDmgEffScale, + Actor_DrawDamageEffects(play, &this->actor, this->limbPos, ARRAY_COUNT(this->limbPos), this->drawDmgEffScale, this->drawDmgEffFrozenSteamScale, this->drawDmgEffAlpha, this->drawDmgEffType); } diff --git a/src/overlays/actors/ovl_En_Peehat/z_en_peehat.h b/src/overlays/actors/ovl_En_Peehat/z_en_peehat.h index a7bda3577..182dd9175 100644 --- a/src/overlays/actors/ovl_En_Peehat/z_en_peehat.h +++ b/src/overlays/actors/ovl_En_Peehat/z_en_peehat.h @@ -5,7 +5,7 @@ struct EnPeehat; -typedef void (*EnPeehatActionFunc)(struct EnPeehat*, GlobalContext*); +typedef void (*EnPeehatActionFunc)(struct EnPeehat*, PlayState*); typedef struct EnPeehat { /* 0x000 */ Actor actor; 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 2736fc71a..3995207e9 100644 --- a/src/overlays/actors/ovl_En_Pm/z_en_pm.c +++ b/src/overlays/actors/ovl_En_Pm/z_en_pm.c @@ -12,77 +12,373 @@ #define THIS ((EnPm*)thisx) -void EnPm_Init(Actor* thisx, GlobalContext* globalCtx); -void EnPm_Destroy(Actor* thisx, GlobalContext* globalCtx); -void EnPm_Update(Actor* thisx, GlobalContext* globalCtx); -void EnPm_Draw(Actor* thisx, GlobalContext* globalCtx); +void EnPm_Init(Actor* thisx, PlayState* play); +void EnPm_Destroy(Actor* thisx, PlayState* play); +void EnPm_Update(Actor* thisx, PlayState* play); +void EnPm_Draw(Actor* thisx, PlayState* play); -void func_80AFA4D0(EnPm* this, GlobalContext* globalCtx); -void func_80AFA5FC(EnPm* this, GlobalContext* globalCtx); +void func_80AFA4D0(EnPm* this, PlayState* play); +void func_80AFA5FC(EnPm* this, PlayState* play); -// 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,7 +526,7 @@ static ColliderSphereInit sSphereInit = { static CollisionCheckInfoInit2 sColChkInfoInit = { 0, 0, 0, 0, MASS_IMMOVABLE }; -static AnimationInfoS sAnimations[] = { +static AnimationInfoS sAnimationInfo[] = { { &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 }, @@ -301,12 +597,12 @@ s32 func_80AF7BAC(EnPm* this) { return true; } -Actor* func_80AF7CB0(EnPm* this, GlobalContext* globalCtx, u8 actorCat, s16 actorId) { +Actor* func_80AF7CB0(EnPm* this, PlayState* play, u8 actorCat, s16 actorId) { Actor* phi_s0 = NULL; Actor* actor; while (true) { - actor = SubS_FindActor(globalCtx, phi_s0, actorCat, actorId); + actor = SubS_FindActor(play, phi_s0, actorCat, actorId); phi_s0 = actor; if (actor == NULL) { @@ -329,7 +625,7 @@ Actor* func_80AF7CB0(EnPm* this, GlobalContext* globalCtx, u8 actorCat, s16 acto return phi_s0; } -EnDoor* func_80AF7D60(GlobalContext* globalCtx, s32 arg1) { +EnDoor* func_80AF7D60(PlayState* play, s32 arg1) { s32 phi_a1; switch (arg1) { @@ -358,15 +654,15 @@ EnDoor* func_80AF7D60(GlobalContext* globalCtx, s32 arg1) { return NULL; } - return SubS_FindDoor(globalCtx, phi_a1); + return SubS_FindDoor(play, phi_a1); } -Actor* func_80AF7DC4(EnPm* this, GlobalContext* globalCtx, s32 arg2) { +Actor* func_80AF7DC4(EnPm* this, PlayState* play, s32 arg2) { Actor* phi_s0 = NULL; Actor* actor; while (true) { - actor = SubS_FindActor(globalCtx, phi_s0, ACTORCAT_PROP, ACTOR_EN_PST); + actor = SubS_FindActor(play, phi_s0, ACTORCAT_PROP, ACTOR_EN_PST); phi_s0 = actor; if (actor == NULL) { @@ -422,14 +718,14 @@ s32 func_80AF7E98(EnPm* this, s32 arg1) { if (phi_v1) { this->unk_384 = arg1; - ret = SubS_ChangeAnimationByInfoS(&this->skelAnime, sAnimations, arg1); + ret = SubS_ChangeAnimationByInfoS(&this->skelAnime, sAnimationInfo, arg1); this->unk_35C = this->skelAnime.playSpeed; } return ret; } -void func_80AF7F68(EnPm* this, GlobalContext* globalCtx) { +void func_80AF7F68(EnPm* this, PlayState* play) { f32 temp; s32 pad; @@ -441,32 +737,32 @@ void func_80AF7F68(EnPm* this, GlobalContext* globalCtx) { case 24: temp = this->colliderSphere.dim.modelSphere.radius * this->colliderSphere.dim.scale; this->colliderSphere.dim.worldSphere.radius = temp; - CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->colliderSphere.base); + CollisionCheck_SetOC(play, &play->colChkCtx, &this->colliderSphere.base); break; default: Collider_UpdateCylinder(&this->actor, &this->colliderCylinder); temp = this->actor.focus.pos.y - this->actor.world.pos.y; this->colliderCylinder.dim.height = temp; - CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->colliderCylinder.base); + CollisionCheck_SetOC(play, &play->colChkCtx, &this->colliderCylinder.base); break; } } -Actor* func_80AF8040(EnPm* this, GlobalContext* globalCtx) { +Actor* func_80AF8040(EnPm* this, PlayState* play) { Actor* actor; switch (this->unk_258) { case 16: - actor = func_80AF7CB0(this, globalCtx, ACTORCAT_NPC, ACTOR_EN_AN); + actor = func_80AF7CB0(this, play, ACTORCAT_NPC, ACTOR_EN_AN); break; case 17: - actor = func_80AF7CB0(this, globalCtx, ACTORCAT_NPC, ACTOR_EN_TEST3); + actor = func_80AF7CB0(this, play, ACTORCAT_NPC, ACTOR_EN_TEST3); break; case 28: - actor = func_80AF7CB0(this, globalCtx, ACTORCAT_NPC, ACTOR_EN_AL); + actor = func_80AF7CB0(this, play, ACTORCAT_NPC, ACTOR_EN_AL); break; case 3: @@ -474,19 +770,19 @@ Actor* func_80AF8040(EnPm* this, GlobalContext* globalCtx) { case 5: case 6: case 7: - actor = func_80AF7DC4(this, globalCtx, this->unk_258 - 3); + actor = func_80AF7DC4(this, play, this->unk_258 - 3); break; case 19: - actor = func_80AF7DC4(this, globalCtx, 4); + actor = func_80AF7DC4(this, play, 4); break; case 18: - actor = func_80AF7DC4(this, globalCtx, 4); + actor = func_80AF7DC4(this, play, 4); break; default: - actor = &GET_PLAYER(globalCtx)->actor; + actor = &GET_PLAYER(play)->actor; break; } @@ -522,7 +818,7 @@ s16 func_80AF8170(EnPm* this, s32 arg1) { return cs; } -s32 func_80AF81E8(EnPm* this, GlobalContext* globalCtx) { +s32 func_80AF81E8(EnPm* this, PlayState* play) { s32 pad; s16 sp2A = func_80AF8170(this, 0); s32 ret = false; @@ -537,8 +833,7 @@ s32 func_80AF81E8(EnPm* this, GlobalContext* globalCtx) { case 4: case 6: if ((this->actor.child != NULL) && (this->actor.child->update != NULL)) { - Camera_SetTargetActor(Play_GetCamera(globalCtx, ActorCutscene_GetCurrentCamera(sp2A)), - this->actor.child); + Camera_SetTargetActor(Play_GetCamera(play, ActorCutscene_GetCurrentSubCamId(sp2A)), this->actor.child); } this->unk_378++; ret = true; @@ -550,7 +845,7 @@ s32 func_80AF81E8(EnPm* this, GlobalContext* globalCtx) { if ((gSaveContext.save.weekEventReg[86] & 8) && (this->unk_378 == 3)) { ActorCutscene_Stop(sp2A); } else { - Camera_SetTargetActor(Play_GetCamera(globalCtx, ActorCutscene_GetCurrentCamera(sp2A)), &this->actor); + Camera_SetTargetActor(Play_GetCamera(play, ActorCutscene_GetCurrentSubCamId(sp2A)), &this->actor); } this->unk_378++; ret = true; @@ -565,7 +860,7 @@ s32 func_80AF81E8(EnPm* this, GlobalContext* globalCtx) { return ret; } -s32 func_80AF8348(EnPm* this, GlobalContext* globalCtx) { +s32 func_80AF8348(EnPm* this, PlayState* play) { s32 pad; s16 sp2A = func_80AF8170(this, 0); s32 ret = false; @@ -580,7 +875,7 @@ s32 func_80AF8348(EnPm* this, GlobalContext* globalCtx) { case 4: case 6: case 8: - Camera_SetTargetActor(Play_GetCamera(globalCtx, ActorCutscene_GetCurrentCamera(sp2A)), &this->actor); + Camera_SetTargetActor(Play_GetCamera(play, ActorCutscene_GetCurrentSubCamId(sp2A)), &this->actor); this->unk_378++; ret = true; break; @@ -590,8 +885,7 @@ s32 func_80AF8348(EnPm* this, GlobalContext* globalCtx) { case 5: case 7: if ((this->actor.child != NULL) && (this->actor.child->update != NULL)) { - Camera_SetTargetActor(Play_GetCamera(globalCtx, ActorCutscene_GetCurrentCamera(sp2A)), - this->actor.child); + Camera_SetTargetActor(Play_GetCamera(play, ActorCutscene_GetCurrentSubCamId(sp2A)), this->actor.child); } this->unk_378++; ret = true; @@ -607,7 +901,7 @@ s32 func_80AF8348(EnPm* this, GlobalContext* globalCtx) { return ret; } -s32 func_80AF8478(EnPm* this, GlobalContext* globalCtx) { +s32 func_80AF8478(EnPm* this, PlayState* play) { s32 pad; s32 ret = false; @@ -632,7 +926,7 @@ s32 func_80AF8478(EnPm* this, GlobalContext* globalCtx) { return ret; } -UNK_TYPE* func_80AF8540(EnPm* this, GlobalContext* globalCtx) { +UNK_TYPE* func_80AF8540(EnPm* this, PlayState* play) { switch (this->unk_258) { case 28: this->unk_37C = func_80AF8348; @@ -664,7 +958,7 @@ UNK_TYPE* func_80AF8540(EnPm* this, GlobalContext* globalCtx) { return D_80AFB650; default: - if (Player_GetMask(globalCtx) == PLAYER_MASK_KAFEIS_MASK) { + if (Player_GetMask(play) == PLAYER_MASK_KAFEIS_MASK) { return D_80AFB744; } @@ -700,16 +994,16 @@ UNK_TYPE* func_80AF8540(EnPm* this, GlobalContext* globalCtx) { } } -s32 func_80AF86F0(EnPm* this, GlobalContext* globalCtx) { +s32 func_80AF86F0(EnPm* this, PlayState* play) { s32 ret = false; - if ((this->unk_356 & 7) && Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { + if ((this->unk_356 & 7) && Actor_ProcessTalkRequest(&this->actor, &play->state)) { SubS_UpdateFlags(&this->unk_356, 0, 7); this->unk_398 = 0; this->unk_378 = 0; this->unk_37C = NULL; this->actor.child = this->unk_268; - this->unk_25C = func_80AF8540(this, globalCtx); + this->unk_25C = func_80AF8540(this, play); if ((this->unk_258 != 24) && (this->unk_258 != 9) && (this->unk_258 != 20) && (this->unk_258 != 21) && (this->unk_258 != 22)) { this->unk_356 |= 0x20; @@ -720,11 +1014,11 @@ s32 func_80AF86F0(EnPm* this, GlobalContext* globalCtx) { return ret; } -s32 func_80AF87C4(EnPm* this, GlobalContext* globalCtx) { +s32 func_80AF87C4(EnPm* this, PlayState* play) { s32 ret = false; - if ((globalCtx->csCtx.state != 0) && (globalCtx->sceneNum == SCENE_00KEIKOKU) && - (gSaveContext.sceneSetupIndex == 9) && (globalCtx->curSpawn == 1)) { + if ((play->csCtx.state != 0) && (play->sceneNum == SCENE_00KEIKOKU) && (gSaveContext.sceneSetupIndex == 9) && + (play->curSpawn == 1)) { if (!this->unk_380) { func_80AF7E98(this, 0); this->unk_258 = 255; @@ -742,7 +1036,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: @@ -764,7 +1058,7 @@ void func_80AF8890(EnPm* this, Gfx** gfx, s32 arg2) { break; } - Matrix_StatePop(); + Matrix_Pop(); } void func_80AF898C(EnPm* this) { @@ -809,12 +1103,11 @@ 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.save.weekEventReg[88] & 2)) { if (gSaveContext.save.weekEventReg[D_80AFB8D4[arg0] >> 8] & @@ -833,19 +1126,18 @@ void func_80AF8BA8(s32 arg0) { } } - temp = gSaveContext.save.weekEventReg[D_80AFB8E0[arg0] >> 8]; gSaveContext.save.weekEventReg[D_80AFB8E0[arg0] >> 8] = - temp | (D_80AFB8E0[arg0] & (1 | 2 | 4 | 0x38 | 0x40 | 0x80)); + ((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.currentTextId; +void func_80AF8C68(EnPm* this, PlayState* play) { + Player* player = GET_PLAYER(play); + s32 talkState = Message_GetState(&play->msgCtx); + u16 textId = play->msgCtx.currentTextId; - if ((player->targetActor == &this->actor) && ((temp_a0 < 255) || (temp_a0 > 512)) && (sp28 == 3) && - (this->unk_388 == 3)) { - if ((globalCtx->state.frames % 3) == 0) { + if ((player->targetActor == &this->actor) && ((textId < 0xFF) || (textId > 0x200)) && (talkState == TEXT_STATE_3) && + (this->prevTalkState == TEXT_STATE_3)) { + if ((play->state.frames % 3) == 0) { if (this->unk_360 == 120.0f) { this->unk_360 = 0.0f; } else { @@ -856,11 +1148,11 @@ 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); - this->unk_388 = sp28; + Matrix_Translate(this->unk_364, 0.0f, 0.0f, MTXMODE_APPLY); + this->prevTalkState = talkState; } -s32 func_80AF8D84(EnPm* this, GlobalContext* globalCtx) { +s32 func_80AF8D84(EnPm* this, PlayState* play) { switch (this->unk_384) { case 10: func_80AF7E98(this, 9); @@ -873,38 +1165,38 @@ s32 func_80AF8D84(EnPm* this, GlobalContext* globalCtx) { return true; } -s32 func_80AF8DD4(EnPm* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); - u16 temp = globalCtx->msgCtx.currentTextId; +s32 func_80AF8DD4(EnPm* this, PlayState* play) { + Player* player = GET_PLAYER(play); + u16 textId = play->msgCtx.currentTextId; s32 pad; if (player->stateFlags1 & (0x400 | 0x40)) { this->unk_356 |= 0x400; - if (this->unk_358 != temp) { + if (this->unk_358 != textId) { if ((this->unk_384 == 0) || (this->unk_384 == 1)) { func_80AF7E98(this, 7); } - if ((temp == 0x277C) || (temp == 0x277D)) { + if ((textId == 0x277C) || (textId == 0x277D)) { func_80AF7E98(this, 10); } } - this->unk_358 = temp; + this->unk_358 = textId; } else { if (this->unk_356 & 0x400) { this->unk_358 = 0; this->unk_356 &= ~0x400; - func_80AF8D84(this, globalCtx); + func_80AF8D84(this, play); } } if (this->unk_18C != NULL) { - this->unk_18C(this, globalCtx); + this->unk_18C(this, play); } return 0; } -s32 func_80AF8ED4(EnPm* this, GlobalContext* globalCtx, struct_80133038_arg2* arg2, u8 actorCat, s16 actorId) { +s32 func_80AF8ED4(EnPm* this, PlayState* play, ScheduleOutput* scheduleOutput, u8 actorCat, s16 actorId) { u8 sp4F = this->actor.params & 0xFF; Vec3s* sp48; Vec3f sp3C; @@ -913,17 +1205,17 @@ s32 func_80AF8ED4(EnPm* this, GlobalContext* globalCtx, struct_80133038_arg2* ar s32 pad; s32 ret = false; - this->unk_234 = NULL; - sp2C = func_80AF7CB0(this, globalCtx, actorCat, actorId); - if (D_80AFB430[arg2->unk0] >= 0) { - this->unk_234 = SubS_GetAdditionalPath(globalCtx, sp4F, D_80AFB430[arg2->unk0]); + this->timePath = NULL; + sp2C = func_80AF7CB0(this, play, actorCat, actorId); + if (D_80AFB430[scheduleOutput->result] >= 0) { + this->timePath = SubS_GetAdditionalPath(play, sp4F, D_80AFB430[scheduleOutput->result]); } if ((sp2C != NULL) && (sp2C->update != NULL)) { - if (this->unk_234 != NULL) { - sp48 = Lib_SegmentedToVirtual(this->unk_234->points); - Math_Vec3s_ToVec3f(&sp3C, &sp48[this->unk_234->count - 2]); - Math_Vec3s_ToVec3f(&sp30, &sp48[this->unk_234->count - 1]); + 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); @@ -934,8 +1226,8 @@ 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.save.time - 0x3FFC; +s32 func_80AF9008(EnPm* this, PlayState* play, ScheduleOutput* scheduleOutput) { + u16 sp56 = SCHEDULE_TIME_NOW; u8 sp55 = this->actor.params & 0xFF; EnDoor* door; Vec3s* sp4C; @@ -944,15 +1236,15 @@ s32 func_80AF9008(EnPm* this, GlobalContext* globalCtx, struct_80133038_arg2* ar s16 temp; s32 ret = false; - this->unk_234 = NULL; - door = func_80AF7D60(globalCtx, arg2->unk0); - if (D_80AFB430[arg2->unk0] >= 0) { - this->unk_234 = SubS_GetAdditionalPath(globalCtx, sp55, D_80AFB430[arg2->unk0]); + this->timePath = NULL; + door = func_80AF7D60(play, scheduleOutput->result); + if (D_80AFB430[scheduleOutput->result] >= 0) { + this->timePath = SubS_GetAdditionalPath(play, sp55, D_80AFB430[scheduleOutput->result]); } if ((door != NULL) && (door->dyna.actor.update != NULL)) { - if (this->unk_234 != 0) { - sp4C = Lib_SegmentedToVirtual(this->unk_234->points); + 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); @@ -966,8 +1258,8 @@ s32 func_80AF9008(EnPm* this, GlobalContext* globalCtx, struct_80133038_arg2* ar this->unk_260 = 0x4B; } - this->unk_36C = arg2->unk8 - arg2->unk4; - this->unk_36E = sp56 - arg2->unk4; + this->unk_36C = scheduleOutput->time1 - scheduleOutput->time0; + this->unk_36E = sp56 - scheduleOutput->time0; this->actor.flags &= ~ACTOR_FLAG_1; if (gSaveContext.save.weekEventReg[90] & 8) { this->unk_356 |= 0x800; @@ -982,48 +1274,50 @@ 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.save.time - 0x3FFC); +s32 func_80AF91E8(EnPm* this, PlayState* play, ScheduleOutput* scheduleOutput) { + u16 sp2E = SCHEDULE_TIME_NOW; u16 phi_v1; u8 sp2B = this->actor.params & 0xFF; - s32 pad; + u16 tmp; + s16 pad; s32 ret = false; - this->unk_234 = NULL; + this->timePath = NULL; - if (D_80AFB430[arg2->unk0] >= 0) { - this->unk_234 = SubS_GetAdditionalPath(globalCtx, sp2B, D_80AFB430[arg2->unk0]); + if (D_80AFB430[scheduleOutput->result] >= 0) { + this->timePath = SubS_GetAdditionalPath(play, sp2B, D_80AFB430[scheduleOutput->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 = scheduleOutput->time0; } - if (arg2->unk8 < phi_v1) { - this->unk_248 = (phi_v1 - arg2->unk8) + 0xFFFF; + if (scheduleOutput->time1 < phi_v1) { + this->timePathTotalTime = (phi_v1 - scheduleOutput->time1) + 0xFFFF; } else { - this->unk_248 = arg2->unk8 - phi_v1; + this->timePathTotalTime = scheduleOutput->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; + tmp = phi_v1 = this->timePath->count - (SUBS_TIME_PATHING_ORDER - 1); + this->timePathWaypointTime = this->timePathTotalTime / tmp; + this->timePathWaypoint = + (this->timePathElapsedTime / this->timePathWaypointTime) + (SUBS_TIME_PATHING_ORDER - 1); this->unk_356 &= ~8; this->unk_356 &= ~0x10; if (this->unk_258 == 27) { Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_ROOM_CARTAIN); - Flags_UnsetSwitch(globalCtx, 0); + Flags_UnsetSwitch(play, 0); } - switch (arg2->unk0) { + switch (scheduleOutput->result) { case 83: case 84: case 85: @@ -1062,7 +1356,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, PlayState* play, ScheduleOutput* scheduleOutput) { u8 sp4F = this->actor.params & 0xFF; Vec3f sp40; Vec3f sp34; @@ -1070,23 +1364,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 = SubS_GetAdditionalPath(globalCtx, sp4F, D_80AFB430[arg2->unk0]); + this->timePath = NULL; + if (D_80AFB430[scheduleOutput->result] >= 0) { + this->timePath = SubS_GetAdditionalPath(play, sp4F, D_80AFB430[scheduleOutput->result]); } - if ((this->unk_234 != 0) && (this->unk_234->count >= 2)) { - sp30 = 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) { - Flags_UnsetSwitch(globalCtx, 0); - Flags_UnsetSwitch(globalCtx, 1); - this->unk_394 = 0; + if (scheduleOutput->result == 24) { + Flags_UnsetSwitch(play, 0); + Flags_UnsetSwitch(play, 1); + this->unk_394 = PLAYER_AP_NONE; this->unk_368 = 60.0f; func_80AF7E98(this, 9); } @@ -1095,7 +1389,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, PlayState* play, ScheduleOutput* scheduleOutput) { u8 sp4F = this->actor.params & 0xFF; Vec3f sp40; Vec3f sp34; @@ -1104,13 +1398,13 @@ s32 func_80AF95E8(EnPm* this, GlobalContext* globalCtx, struct_80133038_arg2* ar s32 ret = false; s32 phi_a3 = -1; - switch (arg2->unk0) { + switch (scheduleOutput->result) { case 3: case 4: case 5: case 6: case 7: - phi_a3 = arg2->unk0 - 3; + phi_a3 = scheduleOutput->result - 3; break; case 19: @@ -1118,29 +1412,29 @@ s32 func_80AF95E8(EnPm* this, GlobalContext* globalCtx, struct_80133038_arg2* ar break; } - if ((phi_a3 >= 0) && !func_80AF7DC4(this, globalCtx, phi_a3)) { + if ((phi_a3 >= 0) && !func_80AF7DC4(this, play, phi_a3)) { return ret; } - this->unk_234 = NULL; - phi_a3 = D_80AFB430[arg2->unk0]; + this->timePath = NULL; + phi_a3 = D_80AFB430[scheduleOutput->result]; if (phi_a3 >= 0) { - this->unk_234 = SubS_GetAdditionalPath(globalCtx, sp4F, phi_a3); + this->timePath = SubS_GetAdditionalPath(play, sp4F, phi_a3); } - if ((this->unk_234 != 0) && (this->unk_234->count >= 2)) { - sp30 = Lib_SegmentedToVirtual(this->unk_234->points); - Math_Vec3s_ToVec3f(&sp40, &sp30[this->unk_234->count - 1]); - Math_Vec3s_ToVec3f(&sp34, &sp30[this->unk_234->count - 2]); + 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 (scheduleOutput->result) { case 27: Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_ROOM_CARTAIN); - Flags_SetSwitch(globalCtx, 0); + Flags_SetSwitch(play, 0); this->unk_36C = 20; SubS_UpdateFlags(&this->unk_356, 3, 7); func_80AF7E98(this, 3); @@ -1169,7 +1463,7 @@ s32 func_80AF95E8(EnPm* this, GlobalContext* globalCtx, struct_80133038_arg2* ar gSaveContext.save.weekEventReg[60] |= 4; default: - if (arg2->unk0 == 0x1D) { + if (scheduleOutput->result == 29) { this->actor.world.rot.y = BINANG_ROT180(this->actor.world.rot.y); } SubS_UpdateFlags(&this->unk_356, 3, 7); @@ -1182,18 +1476,18 @@ 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, PlayState* play, ScheduleOutput* scheduleOutput) { s32 ret = false; - if (Actor_SpawnAsChild(&globalCtx->actorCtx, &this->actor, globalCtx, ACTOR_EN_MM3, 116.0f, 26.0f, -219.0f, 0, - -0x3F46, 0, 0) != NULL) { + if (Actor_SpawnAsChild(&play->actorCtx, &this->actor, play, ACTOR_EN_MM3, 116.0f, 26.0f, -219.0f, 0, -0x3F46, 0, + 0) != NULL) { Actor_MarkForDeath(&this->actor); ret = true; } return ret; } -s32 func_80AF992C(EnPm* this, GlobalContext* globalCtx, struct_80133038_arg2* arg2) { +s32 func_80AF992C(EnPm* this, PlayState* play, ScheduleOutput* scheduleOutput) { static Vec3f D_80AFB8EC = { 116.0f, 26.0f, -219.0f }; static Vec3s D_80AFB8F8 = { 0x0000, 0xC0BA, 0x0000 }; s32 pad; @@ -1205,7 +1499,7 @@ s32 func_80AF992C(EnPm* this, GlobalContext* globalCtx, struct_80133038_arg2* ar this->actor.targetMode = 6; this->actor.gravity = -1.0f; this->unk_368 = 80.0f; - if (arg2->unk0 == 14) { + if (scheduleOutput->result == 14) { this->unk_356 &= ~0x200; func_80AF7E98(this, 13); } else { @@ -1215,10 +1509,10 @@ 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, PlayState* play, ScheduleOutput* scheduleOutput) { s32 ret = false; - if (func_80AF8ED4(this, globalCtx, arg2, ACTORCAT_NPC, ACTOR_EN_AN)) { + if (func_80AF8ED4(this, play, scheduleOutput, ACTORCAT_NPC, ACTOR_EN_AN)) { SubS_UpdateFlags(&this->unk_356, 3, 7); this->unk_356 |= 0x20; this->unk_356 |= 0x9000; @@ -1233,10 +1527,10 @@ 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, PlayState* play, ScheduleOutput* scheduleOutput) { s32 ret = false; - if (func_80AF8ED4(this, globalCtx, arg2, ACTORCAT_NPC, ACTOR_EN_TEST3)) { + if (func_80AF8ED4(this, play, scheduleOutput, ACTORCAT_NPC, ACTOR_EN_TEST3)) { SubS_UpdateFlags(&this->unk_356, 3, 7); this->unk_356 |= 0x20; this->unk_356 |= 0x9000; @@ -1251,10 +1545,10 @@ 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, PlayState* play, ScheduleOutput* scheduleOutput) { s32 ret = false; - if (func_80AF8ED4(this, globalCtx, arg2, ACTORCAT_NPC, ACTOR_EN_AL)) { + if (func_80AF8ED4(this, play, scheduleOutput, ACTORCAT_NPC, ACTOR_EN_AL)) { SubS_UpdateFlags(&this->unk_356, 3, 7); this->unk_356 |= 0x9000; this->unk_356 |= 0x20; @@ -1269,34 +1563,34 @@ 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, PlayState* play, ScheduleOutput* scheduleOutput) { s32 ret; this->actor.flags |= ACTOR_FLAG_1; this->actor.targetMode = 0; - this->unk_394 = 0; + this->unk_394 = PLAYER_AP_NONE; this->unk_356 = 0; this->unk_368 = 40.0f; - switch (arg2->unk0) { + switch (scheduleOutput->result) { case 16: - ret = func_80AF9A0C(this, globalCtx, arg2); + ret = func_80AF9A0C(this, play, scheduleOutput); break; case 17: - ret = func_80AF9AB0(this, globalCtx, arg2); + ret = func_80AF9AB0(this, play, scheduleOutput); break; case 28: - ret = func_80AF9B54(this, globalCtx, arg2); + ret = func_80AF9B54(this, play, scheduleOutput); break; case 24: - ret = func_80AF94AC(this, globalCtx, arg2); + ret = func_80AF94AC(this, play, scheduleOutput); break; case 29: - ret = func_80AF95E8(this, globalCtx, arg2); + ret = func_80AF95E8(this, play, scheduleOutput); break; case 1: @@ -1311,7 +1605,7 @@ s32 func_80AF9BF8(EnPm* this, GlobalContext* globalCtx, struct_80133038_arg2* ar case 35: case 36: case 37: - ret = func_80AF9008(this, globalCtx, arg2); + ret = func_80AF9008(this, play, scheduleOutput); break; case 3: @@ -1324,11 +1618,11 @@ s32 func_80AF9BF8(EnPm* this, GlobalContext* globalCtx, struct_80133038_arg2* ar case 23: case 25: case 27: - ret = func_80AF95E8(this, globalCtx, arg2); + ret = func_80AF95E8(this, play, scheduleOutput); break; case 8: - ret = func_80AF98A0(this, globalCtx, arg2); + ret = func_80AF98A0(this, play, scheduleOutput); break; case 9: @@ -1336,7 +1630,7 @@ s32 func_80AF9BF8(EnPm* this, GlobalContext* globalCtx, struct_80133038_arg2* ar case 20: case 21: case 22: - ret = func_80AF992C(this, globalCtx, arg2); + ret = func_80AF992C(this, play, scheduleOutput); break; case 38: @@ -1393,7 +1687,7 @@ s32 func_80AF9BF8(EnPm* this, GlobalContext* globalCtx, struct_80133038_arg2* ar case 89: case 90: case 91: - ret = func_80AF91E8(this, globalCtx, arg2); + ret = func_80AF91E8(this, play, scheduleOutput); break; default: @@ -1403,13 +1697,13 @@ s32 func_80AF9BF8(EnPm* this, GlobalContext* globalCtx, struct_80133038_arg2* ar return ret; } -s32 func_80AF9D04(EnPm* this, GlobalContext* globalCtx) { - EnDoor* door = (EnDoor*)func_80AF7D60(globalCtx, this->unk_258); +s32 func_80AF9D04(EnPm* this, PlayState* play) { + EnDoor* door = (EnDoor*)func_80AF7D60(play, this->unk_258); Vec3f sp38; - Vec3f* sp28; + s32 pad; f32 temp; - if (!func_8013AD6C(globalCtx) && (this->unk_374 != 0)) { + if (!SubS_InCsMode(play) && (this->timePathTimeSpeed != 0)) { if ((door != NULL) && (door->dyna.actor.update != NULL)) { if (((f32)this->unk_36E / this->unk_36C) <= 0.9f) { door->unk_1A7 = this->unk_260; @@ -1423,7 +1717,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); } @@ -1431,53 +1725,55 @@ s32 func_80AF9D04(EnPm* this, GlobalContext* globalCtx) { return false; } -s32 func_80AF9E7C(EnPm* this, GlobalContext* globalCtx) { - f32 sp7C[265]; +s32 func_80AF9E7C(EnPm* this, PlayState* play) { + 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(play, 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(play)) { + 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(play)) { + 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); @@ -1495,7 +1791,7 @@ s32 func_80AF9E7C(EnPm* this, GlobalContext* globalCtx) { return false; } -s32 func_80AFA170(EnPm* this, GlobalContext* globalCtx) { +s32 func_80AFA170(EnPm* this, PlayState* play) { Vec3f sp34; Vec3f sp28; @@ -1548,7 +1844,7 @@ s32 func_80AFA170(EnPm* this, GlobalContext* globalCtx) { return true; } -s32 func_80AFA334(EnPm* this, GlobalContext* globalCtx) { +s32 func_80AFA334(EnPm* this, PlayState* play) { s16 temp_v0; switch (this->unk_258) { @@ -1564,7 +1860,7 @@ s32 func_80AFA334(EnPm* this, GlobalContext* globalCtx) { case 27: if (DECR(this->unk_36C) == 0) { - Flags_SetSwitch(globalCtx, 1); + Flags_SetSwitch(play, 1); } break; @@ -1584,7 +1880,7 @@ s32 func_80AFA334(EnPm* this, GlobalContext* globalCtx) { return false; } -void func_80AFA438(EnPm* this, GlobalContext* globalCtx) { +void func_80AFA438(EnPm* this, PlayState* play) { switch (this->unk_258) { case 3: case 4: @@ -1595,7 +1891,7 @@ void func_80AFA438(EnPm* this, GlobalContext* globalCtx) { case 17: case 18: case 28: - func_80AFA170(this, globalCtx); + func_80AFA170(this, play); break; case 1: @@ -1610,7 +1906,7 @@ void func_80AFA438(EnPm* this, GlobalContext* globalCtx) { case 35: case 36: case 37: - func_80AF9D04(this, globalCtx); + func_80AF9D04(this, play); break; case 9: @@ -1623,7 +1919,7 @@ void func_80AFA438(EnPm* this, GlobalContext* globalCtx) { case 25: case 27: case 29: - func_80AFA334(this, globalCtx); + func_80AFA334(this, play); break; case 38: @@ -1680,53 +1976,52 @@ void func_80AFA438(EnPm* this, GlobalContext* globalCtx) { case 89: case 90: case 91: - func_80AF9E7C(this, globalCtx); + func_80AF9E7C(this, play); break; } Math_ApproachS(&this->actor.shape.rot.y, this->actor.world.rot.y, 3, 0x2AA8); } -void func_80AFA4D0(EnPm* this, GlobalContext* globalCtx) { - static UNK_PTR D_80AFB900[] = { +void func_80AFA4D0(EnPm* this, PlayState* play) { + static u8* D_80AFB900[] = { D_80AFAD80, D_80AFB30C, D_80AFB3C0, D_80AFB3FC, D_80AFB41C, }; u16 time = gSaveContext.save.time; u16 sp3C = 0; - u32* unk_14 = &gSaveContext.save.daySpeed; - struct_80133038_arg2 sp2C; + ScheduleOutput sp2C; - this->unk_374 = REG(15) + *unk_14; + this->timePathTimeSpeed = REG(15) + ((void)0, gSaveContext.save.daySpeed); if (this->unk_38C != 0) { 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(play, D_80AFB900[this->unk_38C], &sp2C) || + ((this->unk_258 != sp2C.result) && !func_80AF9BF8(this, play, &sp2C))) { this->actor.shape.shadowDraw = NULL; this->actor.flags &= ~ACTOR_FLAG_1; - sp2C.unk0 = 0; + sp2C.result = 0; } else { this->actor.shape.shadowDraw = ActorShadow_DrawCircle; this->actor.flags |= ACTOR_FLAG_1; } - this->unk_258 = sp2C.unk0; - this->unk_268 = func_80AF8040(this, globalCtx); - func_80AFA438(this, globalCtx); + this->unk_258 = sp2C.result; + this->unk_268 = func_80AF8040(this, play); + func_80AFA438(this, play); if (this->unk_38C != 0) { gSaveContext.save.time = sp3C; } } -void func_80AFA5FC(EnPm* this, GlobalContext* globalCtx) { +void func_80AFA5FC(EnPm* this, PlayState* play) { s16 yaw; Vec3f sp38; Vec3f sp2C; - if (func_8010BF58(&this->actor, globalCtx, this->unk_25C, this->unk_37C, &this->unk_264)) { + if (func_8010BF58(&this->actor, play, this->unk_25C, this->unk_37C, &this->unk_264)) { SubS_UpdateFlags(&this->unk_356, 3, 7); this->unk_356 &= ~0x20; this->unk_356 |= 0x200; @@ -1749,73 +2044,72 @@ void func_80AFA5FC(EnPm* this, GlobalContext* globalCtx) { } } -void func_80AFA724(EnPm* this, GlobalContext* globalCtx) { +void func_80AFA724(EnPm* this, PlayState* play) { Actor_MoveWithGravity(&this->actor); - Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 30.0f, 12.0f, 0.0f, 4); + Actor_UpdateBgCheckInfo(play, &this->actor, 30.0f, 12.0f, 0.0f, 4); if (Animation_OnFrame(&this->skelAnime, 3.0f) || Animation_OnFrame(&this->skelAnime, 8.0f)) { Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_POSTMAN_WALK); } } -void EnPm_Init(Actor* thisx, GlobalContext* globalCtx) { +void EnPm_Init(Actor* thisx, PlayState* play) { EnPm* this = THIS; ActorShape_Init(&this->actor.shape, 0.0f, NULL, 14.0f); - SkelAnime_InitFlex(globalCtx, &this->skelAnime, &object_mm_Skel_0096E8, NULL, this->jointTable, this->morphTable, - 16); + SkelAnime_InitFlex(play, &this->skelAnime, &object_mm_Skel_0096E8, NULL, this->jointTable, this->morphTable, 16); this->unk_384 = -1; func_80AF7E98(this, 0); - Collider_InitAndSetCylinder(globalCtx, &this->colliderCylinder, &this->actor, &sCylinderInit); - Collider_InitAndSetSphere(globalCtx, &this->colliderSphere, &this->actor, &sSphereInit); + Collider_InitAndSetCylinder(play, &this->colliderCylinder, &this->actor, &sCylinderInit); + Collider_InitAndSetSphere(play, &this->colliderSphere, &this->actor, &sSphereInit); CollisionCheck_SetInfo2(&this->actor.colChkInfo, DamageTable_Get(0x16), &sColChkInfoInit); Actor_SetScale(&this->actor, 0.01f); this->unk_38C = func_80AF7B40(); this->unk_258 = 0; this->unk_356 = 0; this->actionFunc = func_80AFA4D0; - this->actionFunc(this, globalCtx); + this->actionFunc(this, play); } -void EnPm_Destroy(Actor* thisx, GlobalContext* globalCtx) { +void EnPm_Destroy(Actor* thisx, PlayState* play) { EnPm* this = THIS; - Collider_DestroyCylinder(globalCtx, &this->colliderCylinder); - Collider_DestroySphere(globalCtx, &this->colliderSphere); + Collider_DestroyCylinder(play, &this->colliderCylinder); + Collider_DestroySphere(play, &this->colliderSphere); } -void EnPm_Update(Actor* thisx, GlobalContext* globalCtx) { +void EnPm_Update(Actor* thisx, PlayState* play) { EnPm* this = THIS; - if (!func_80AF86F0(this, globalCtx) && func_80AF87C4(this, globalCtx)) { - func_80AFA724(this, globalCtx); + if (!func_80AF86F0(this, play) && func_80AF87C4(this, play)) { + func_80AFA724(this, play); func_80AF7E6C(this); func_80AF8AC8(this); } else { - this->actionFunc(this, globalCtx); + this->actionFunc(this, play); func_80AF7BAC(this); if (this->unk_258 != 0) { - func_80AF8DD4(this, globalCtx); + func_80AF8DD4(this, play); func_80AF7E6C(this); func_80AF8AC8(this); - func_8013C964(&this->actor, globalCtx, this->unk_368, 30.0f, this->unk_394, this->unk_356 & 7); + func_8013C964(&this->actor, play, this->unk_368, 30.0f, this->unk_394, this->unk_356 & 7); Actor_MoveWithGravity(&this->actor); - Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 30.0f, 12.0f, 0.0f, 4); - func_80AF7F68(this, globalCtx); + Actor_UpdateBgCheckInfo(play, &this->actor, 30.0f, 12.0f, 0.0f, 4); + func_80AF7F68(this, play); } } } -s32 EnPm_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, Actor* thisx, +s32 EnPm_OverrideLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, Actor* thisx, Gfx** gfx) { EnPm* this = THIS; if (limbIndex == 15) { - func_80AF8C68(this, globalCtx); + func_80AF8C68(this, play); } return false; } -void EnPm_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx, Gfx** gfx) { +void EnPm_PostLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx, Gfx** gfx) { EnPm* this = THIS; s32 pad; Vec3f sp2C; @@ -1823,7 +2117,7 @@ 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.save.weekEventReg[90] & 4)) { @@ -1839,10 +2133,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); @@ -1850,37 +2144,37 @@ void EnPm_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec } } -void EnPm_TransformLimbDraw(GlobalContext* globalCtx, s32 arg1, Actor* thisx, Gfx** gfx) { +void EnPm_TransformLimbDraw(PlayState* play, 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(); } } -void EnPm_Draw(Actor* thisx, GlobalContext* globalCtx) { +void EnPm_Draw(Actor* thisx, PlayState* play) { static TexturePtr D_80AFB914[] = { object_mm_Tex_002950, object_mm_Tex_002750, @@ -1889,18 +2183,18 @@ void EnPm_Draw(Actor* thisx, GlobalContext* globalCtx) { s32 pad; if (this->unk_258 != 0) { - func_8012C28C(globalCtx->state.gfxCtx); + func_8012C28C(play->state.gfxCtx); - OPEN_DISPS(globalCtx->state.gfxCtx); + OPEN_DISPS(play->state.gfxCtx); - Scene_SetRenderModeXlu(globalCtx, 0, 1); + Scene_SetRenderModeXlu(play, 0, 1); gSPSegment(POLY_OPA_DISP++, 0x08, Lib_SegmentedToVirtual(D_80AFB914[0])); - POLY_OPA_DISP = SubS_DrawTransformFlex(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, + POLY_OPA_DISP = SubS_DrawTransformFlex(play, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, EnPm_OverrideLimbDraw, EnPm_PostLimbDraw, EnPm_TransformLimbDraw, &this->actor, POLY_OPA_DISP); - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->state.gfxCtx); } } 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..de7359d93 100644 --- a/src/overlays/actors/ovl_En_Pm/z_en_pm.h +++ b/src/overlays/actors/ovl_En_Pm/z_en_pm.h @@ -5,57 +5,57 @@ struct EnPm; -typedef void (*EnPmActionFunc)(struct EnPm*, GlobalContext*); -typedef s32 (*EnPmFunc)(struct EnPm*, GlobalContext*); -typedef s32 (*EnPmFunc2)(struct EnPm*, GlobalContext*); +typedef void (*EnPmActionFunc)(struct EnPm*, PlayState*); +typedef s32 (*EnPmFunc)(struct EnPm*, PlayState*); +typedef s32 (*EnPmFunc2)(struct EnPm*, PlayState*); typedef struct EnPm { - /* 0x0000 */ Actor actor; - /* 0x0144 */ SkelAnime skelAnime; - /* 0x0188 */ EnPmActionFunc actionFunc; - /* 0x018C */ EnPmFunc2 unk_18C; - /* 0x0190 */ ColliderCylinder colliderCylinder; - /* 0x01DC */ ColliderSphere colliderSphere; - /* 0x0234 */ Path* 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; - /* 0x0258 */ u8 unk_258; - /* 0x025C */ UNK_TYPE* unk_25C; - /* 0x0260 */ s8 unk_260; - /* 0x0264 */ s32 unk_264; - /* 0x0268 */ Actor* unk_268; - /* 0x026C */ Vec3f unk_26C; - /* 0x0278 */ Vec3f unk_278; - /* 0x0284 */ Vec3f unk_284; - /* 0x0290 */ Vec3s unk_290; - /* 0x0296 */ Vec3s jointTable[16]; - /* 0x02F6 */ Vec3s morphTable[16]; - /* 0x0356 */ u16 unk_356; - /* 0x0358 */ u16 unk_358; - /* 0x035C */ f32 unk_35C; - /* 0x0360 */ f32 unk_360; - /* 0x0364 */ f32 unk_364; - /* 0x0368 */ f32 unk_368; - /* 0x036C */ s16 unk_36C; - /* 0x036E */ s16 unk_36E; - /* 0x0370 */ s16 unk_370; - /* 0x0372 */ s16 unk_372; - /* 0x0374 */ s16 unk_374; - /* 0x0376 */ s16 unk_376; - /* 0x0378 */ s16 unk_378; - /* 0x037C */ EnPmFunc unk_37C; - /* 0x0380 */ s32 unk_380; - /* 0x0384 */ s32 unk_384; - /* 0x0388 */ s32 unk_388; - /* 0x038C */ s32 unk_38C; - /* 0x0390 */ UNK_TYPE1 unk390[0x4]; - /* 0x0394 */ s32 unk_394; - /* 0x0398 */ s32 unk_398; - /* 0x039C */ UNK_TYPE1 unk39C[0x4]; + /* 0x000 */ Actor actor; + /* 0x144 */ SkelAnime skelAnime; + /* 0x188 */ EnPmActionFunc actionFunc; + /* 0x18C */ EnPmFunc2 unk_18C; + /* 0x190 */ ColliderCylinder colliderCylinder; + /* 0x1DC */ ColliderSphere colliderSphere; + /* 0x234 */ Path* timePath; + /* 0x238 */ Vec3f timePathTargetPos; + /* 0x244 */ f32 timePathProgress; + /* 0x248 */ s32 timePathTotalTime; + /* 0x24C */ s32 timePathWaypointTime; + /* 0x250 */ s32 timePathWaypoint; + /* 0x254 */ s32 timePathElapsedTime; + /* 0x258 */ u8 unk_258; + /* 0x25C */ UNK_TYPE* unk_25C; + /* 0x260 */ s8 unk_260; + /* 0x264 */ s32 unk_264; + /* 0x268 */ Actor* unk_268; + /* 0x26C */ Vec3f unk_26C; + /* 0x278 */ Vec3f unk_278; + /* 0x284 */ Vec3f unk_284; + /* 0x290 */ Vec3s unk_290; + /* 0x296 */ Vec3s jointTable[16]; + /* 0x2F6 */ Vec3s morphTable[16]; + /* 0x356 */ u16 unk_356; + /* 0x358 */ u16 unk_358; + /* 0x35C */ f32 unk_35C; + /* 0x360 */ f32 unk_360; + /* 0x364 */ f32 unk_364; + /* 0x368 */ f32 unk_368; + /* 0x36C */ s16 unk_36C; + /* 0x36E */ s16 unk_36E; + /* 0x370 */ s16 unk_370; + /* 0x372 */ s16 unk_372; + /* 0x374 */ s16 timePathTimeSpeed; + /* 0x376 */ s16 unk_376; + /* 0x378 */ s16 unk_378; + /* 0x37C */ EnPmFunc unk_37C; + /* 0x380 */ s32 unk_380; + /* 0x384 */ s32 unk_384; + /* 0x388 */ s32 prevTalkState; + /* 0x38C */ s32 unk_38C; + /* 0x390 */ UNK_TYPE1 unk_390[0x4]; + /* 0x394 */ s32 unk_394; + /* 0x398 */ s32 unk_398; + /* 0x39C */ UNK_TYPE1 unk_39C[0x4]; } EnPm; // size = 0x3A0 extern const ActorInit En_Pm_InitVars; diff --git a/src/overlays/actors/ovl_En_Po_Composer/z_en_po_composer.c b/src/overlays/actors/ovl_En_Po_Composer/z_en_po_composer.c index 744644e58..e18897cf2 100644 --- a/src/overlays/actors/ovl_En_Po_Composer/z_en_po_composer.c +++ b/src/overlays/actors/ovl_En_Po_Composer/z_en_po_composer.c @@ -10,22 +10,22 @@ #define THIS ((EnPoComposer*)thisx) -void EnPoComposer_Init(Actor* thisx, GlobalContext* globalCtx); -void EnPoComposer_Destroy(Actor* thisx, GlobalContext* globalCtx); -void EnPoComposer_Update(Actor* thisx, GlobalContext* globalCtx); -void EnPoComposer_Draw(Actor* thisx, GlobalContext* globalCtx); +void EnPoComposer_Init(Actor* thisx, PlayState* play); +void EnPoComposer_Destroy(Actor* thisx, PlayState* play); +void EnPoComposer_Update(Actor* thisx, PlayState* play); +void EnPoComposer_Draw(Actor* thisx, PlayState* play); -void func_80BC5294(EnPoComposer* this, GlobalContext* globalCtx); -void func_80BC52F0(EnPoComposer* this, GlobalContext* globalCtx); -void func_80BC53A0(EnPoComposer* this, GlobalContext* globalCtx); -void func_80BC5404(EnPoComposer* this, GlobalContext* globalCtx); -void func_80BC5570(EnPoComposer* this, GlobalContext* globalCtx); -void func_80BC55E0(EnPoComposer* this, GlobalContext* globalCtx); -void func_80BC5670(EnPoComposer* this, GlobalContext* globalCtx); -void func_80BC56D0(EnPoComposer* this, GlobalContext* globalCtx); -void func_80BC5780(EnPoComposer* this, GlobalContext* globalCtx); -void func_80BC5830(EnPoComposer* this, GlobalContext* globalCtx); -void func_80BC58E0(EnPoComposer* this, GlobalContext* globalCtx); +void func_80BC5294(EnPoComposer* this, PlayState* play); +void func_80BC52F0(EnPoComposer* this, PlayState* play); +void func_80BC53A0(EnPoComposer* this, PlayState* play); +void func_80BC5404(EnPoComposer* this, PlayState* play); +void func_80BC5570(EnPoComposer* this, PlayState* play); +void func_80BC55E0(EnPoComposer* this, PlayState* play); +void func_80BC5670(EnPoComposer* this, PlayState* play); +void func_80BC56D0(EnPoComposer* this, PlayState* play); +void func_80BC5780(EnPoComposer* this, PlayState* play); +void func_80BC5830(EnPoComposer* this, PlayState* play); +void func_80BC58E0(EnPoComposer* this, PlayState* play); #if 0 const ActorInit En_Po_Composer_InitVars = { @@ -58,7 +58,7 @@ static ColliderJntSphElementInit D_80BC67AC[1] = { // static ColliderJntSphInit sJntSphInit = { static ColliderJntSphInit D_80BC67D0 = { { COLTYPE_HIT3, AT_ON | AT_TYPE_ENEMY, AC_ON | AC_TYPE_PLAYER, OC1_ON | OC1_TYPE_ALL, OC2_TYPE_1, COLSHAPE_JNTSPH, }, - 1, D_80BC67AC, // sJntSphElementsInit, + ARRAY_COUNT(sJntSphElementsInit), D_80BC67AC, // sJntSphElementsInit, }; // sColChkInfoInit diff --git a/src/overlays/actors/ovl_En_Po_Composer/z_en_po_composer.h b/src/overlays/actors/ovl_En_Po_Composer/z_en_po_composer.h index 965e9cc6c..3d70aa8a4 100644 --- a/src/overlays/actors/ovl_En_Po_Composer/z_en_po_composer.h +++ b/src/overlays/actors/ovl_En_Po_Composer/z_en_po_composer.h @@ -5,13 +5,13 @@ struct EnPoComposer; -typedef void (*EnPoComposerActionFunc)(struct EnPoComposer*, GlobalContext*); +typedef void (*EnPoComposerActionFunc)(struct EnPoComposer*, PlayState*); typedef struct EnPoComposer { - /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0xF0]; - /* 0x0234 */ EnPoComposerActionFunc actionFunc; - /* 0x0238 */ char unk_238[0x108]; + /* 0x000 */ Actor actor; + /* 0x144 */ char unk_144[0xF0]; + /* 0x234 */ EnPoComposerActionFunc actionFunc; + /* 0x238 */ char unk_238[0x108]; } EnPoComposer; // size = 0x340 extern const ActorInit En_Po_Composer_InitVars; diff --git a/src/overlays/actors/ovl_En_Po_Fusen/z_en_po_fusen.c b/src/overlays/actors/ovl_En_Po_Fusen/z_en_po_fusen.c index d6c9d7065..a2c537606 100644 --- a/src/overlays/actors/ovl_En_Po_Fusen/z_en_po_fusen.c +++ b/src/overlays/actors/ovl_En_Po_Fusen/z_en_po_fusen.c @@ -12,22 +12,18 @@ #define THIS ((EnPoFusen*)thisx) -#define GET_FUSE_LEN_PARAM(this) (((Actor*)(this))->params & 0x3FF) -#define GET_IS_FUSE_TYPE_PARAM(this) (((Actor*)(this))->params & 0x8000) +void EnPoFusen_Init(Actor* thisx, PlayState* play); +void EnPoFusen_Destroy(Actor* thisx, PlayState* play); +void EnPoFusen_Update(Actor* thisx, PlayState* play); +void EnPoFusen_Draw(Actor* thisx, PlayState* play); -void EnPoFusen_Init(Actor* thisx, GlobalContext* globalCtx); -void EnPoFusen_Destroy(Actor* thisx, GlobalContext* globalCtx); -void EnPoFusen_Update(Actor* thisx, GlobalContext* globalCtx); -void EnPoFusen_Draw(Actor* thisx, GlobalContext* globalCtx); - -u16 EnPoFusen_CheckParent(EnPoFusen* this, GlobalContext* globalCtx); +u16 EnPoFusen_CheckParent(EnPoFusen* this, PlayState* play); void EnPoFusen_InitNoFuse(EnPoFusen* this); void EnPoFusen_InitFuse(EnPoFusen* this); -void EnPoFusen_Pop(EnPoFusen* this, GlobalContext* globalCtx); -void EnPoFusen_Idle(EnPoFusen* this, GlobalContext* globalCtx); -void EnPoFusen_IdleFuse(EnPoFusen* this, GlobalContext* globalCtx); -s32 EnPoFusen_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, - Actor* thisx); +void EnPoFusen_Pop(EnPoFusen* this, PlayState* play); +void EnPoFusen_Idle(EnPoFusen* this, PlayState* play); +void EnPoFusen_IdleFuse(EnPoFusen* this, PlayState* play); +s32 EnPoFusen_OverrideLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, Actor* thisx); const ActorInit En_Po_Fusen_InitVars = { ACTOR_EN_PO_FUSEN, @@ -96,7 +92,7 @@ static DamageTable sDamageTable = { /* Powder Keg */ DMG_ENTRY(0, 0x0), }; -void EnPoFusen_Init(Actor* thisx, GlobalContext* globalCtx) { +void EnPoFusen_Init(Actor* thisx, PlayState* play) { EnPoFusen* this = THIS; f32 heightTemp; @@ -104,17 +100,17 @@ void EnPoFusen_Init(Actor* thisx, GlobalContext* globalCtx) { this->actor.targetMode = 6; this->actor.colChkInfo.damageTable = &sDamageTable; - Collider_InitSphere(globalCtx, &this->collider); - Collider_SetSphere(globalCtx, &this->collider, &this->actor, &sSphereInit); + Collider_InitSphere(play, &this->collider); + Collider_SetSphere(play, &this->collider, &this->actor, &sSphereInit); if (0) {} this->collider.dim.worldSphere.radius = 40; - SkelAnime_InitFlex(globalCtx, &this->anime, &object_po_fusen_Skel_0024F0, &object_po_fusen_Anim_000040, - this->jointTable, this->morphTable, 10); + SkelAnime_InitFlex(play, &this->anime, &object_po_fusen_Skel_0024F0, &object_po_fusen_Anim_000040, this->jointTable, + this->morphTable, 10); ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 25.0f); - Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 0.0f, 0.0f, 0.0f, 0x4); + Actor_UpdateBgCheckInfo(play, &this->actor, 0.0f, 0.0f, 0.0f, 0x4); - if (EnPoFusen_CheckParent(this, globalCtx) == 0) { + if (!EnPoFusen_CheckParent(this, play)) { Actor_MarkForDeath(&this->actor); } @@ -123,9 +119,9 @@ void EnPoFusen_Init(Actor* thisx, GlobalContext* globalCtx) { this->actor.home.pos.y = heightTemp; } - this->randScaleChange = ((Rand_Next() % 0xFFFEU) - 0x7FFF); - this->randYRotChange = ((Rand_Next() % 0x4B0U) - 0x258); - this->avgBaseRotation = 0x1555; + this->randScaleChange = (Rand_Next() % 0xFFFE) - 0x7FFF; + this->randYRotChange = (Rand_Next() % 0x4B0) - 0x258; + this->avgBaseRotation = 0x10000 / 12; this->limb3Rot = 0; this->limb46Rot = 0; this->limb57Rot = 0; @@ -133,7 +129,7 @@ void EnPoFusen_Init(Actor* thisx, GlobalContext* globalCtx) { this->limb9Rot = 0x71C; this->randBaseRotChange = 0; - if (GET_IS_FUSE_TYPE_PARAM(this)) { + if (ENPOFUSEN_IS_FUSE_TYPE(&this->actor)) { EnPoFusen_InitFuse(this); return; } @@ -141,50 +137,49 @@ void EnPoFusen_Init(Actor* thisx, GlobalContext* globalCtx) { EnPoFusen_InitNoFuse(this); } -void EnPoFusen_Destroy(Actor* thisx, GlobalContext* globalCtx) { +void EnPoFusen_Destroy(Actor* thisx, PlayState* play) { EnPoFusen* this = THIS; - Collider_DestroySphere(globalCtx, &this->collider); + + Collider_DestroySphere(play, &this->collider); } -u16 EnPoFusen_CheckParent(EnPoFusen* this, GlobalContext* globalCtx) { +u16 EnPoFusen_CheckParent(EnPoFusen* this, PlayState* play) { Actor* actorPtr; - actorPtr = globalCtx->actorCtx.actorLists[ACTORCAT_NPC].first; - if (GET_IS_FUSE_TYPE_PARAM(this)) { - return 1; + actorPtr = play->actorCtx.actorLists[ACTORCAT_NPC].first; + if (ENPOFUSEN_IS_FUSE_TYPE(&this->actor)) { + return true; } - if (actorPtr != 0) { - do { - if (actorPtr->id == ACTOR_EN_MA4) { - this->actor.parent = actorPtr; - return 1; - } - actorPtr = actorPtr->next; - } while (actorPtr != 0); + while (actorPtr != NULL) { + if (actorPtr->id == ACTOR_EN_MA4) { + this->actor.parent = actorPtr; + return true; + } + actorPtr = actorPtr->next; } - return 0; + return false; } -u16 EnPoFusen_CheckCollision(EnPoFusen* this, GlobalContext* globalCtx) { +u16 EnPoFusen_CheckCollision(EnPoFusen* this, PlayState* play) { if (this->actionFunc == EnPoFusen_IdleFuse) { - return 0; + return false; } this->collider.dim.worldSphere.center.x = this->actor.world.pos.x; - this->collider.dim.worldSphere.center.y = (this->actor.world.pos.y + 20.0f); + this->collider.dim.worldSphere.center.y = this->actor.world.pos.y + 20.0f; this->collider.dim.worldSphere.center.z = this->actor.world.pos.z; if ((this->collider.base.acFlags & AC_HIT) && (this->actor.colChkInfo.damageEffect == 0xF)) { this->collider.base.acFlags &= ~AC_HIT; - return 1; + return true; } - CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); - CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + CollisionCheck_SetOC(play, &play->colChkCtx, &this->collider.base); + CollisionCheck_SetAC(play, &play->colChkCtx, &this->collider.base); - return 0; + return false; } void EnPoFusen_InitNoFuse(EnPoFusen* this) { @@ -192,7 +187,7 @@ void EnPoFusen_InitNoFuse(EnPoFusen* this) { this->actionFunc = EnPoFusen_Idle; } -void EnPoFusen_Idle(EnPoFusen* this, GlobalContext* globalCtx) { +void EnPoFusen_Idle(EnPoFusen* this, PlayState* play) { f32 shadowScaleTmp; f32 shadowAlphaTmp; f32 heightOffset; @@ -239,38 +234,37 @@ void EnPoFusen_IncrementRomaniPop(EnPoFusen* this) { this->actionFunc = EnPoFusen_Pop; } -void EnPoFusen_Pop(EnPoFusen* this, GlobalContext* globalCtx) { - Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_CLEAR_TAG, this->actor.world.pos.x, - this->actor.world.pos.y + 20.0f, this->actor.world.pos.z, 255, 255, 200, CLEAR_TAG_POP); +void EnPoFusen_Pop(EnPoFusen* this, PlayState* play) { + Actor_Spawn(&play->actorCtx, play, ACTOR_EN_CLEAR_TAG, this->actor.world.pos.x, this->actor.world.pos.y + 20.0f, + this->actor.world.pos.z, 255, 255, 200, CLEAR_TAG_POP); Actor_PlaySfxAtPos(&this->actor, NA_SE_IT_BOMB_EXPLOSION); Actor_MarkForDeath(&this->actor); } void EnPoFusen_InitFuse(EnPoFusen* this) { s16 rotZ = this->actor.shape.rot.z; - this->fuse = GET_FUSE_LEN_PARAM(this); + this->fuse = ENPOFUSEN_GET_FUSE_LEN(&this->actor); this->actor.shape.rot.z = 0; - this->randScaleChange = rotZ & 0xFFFFu; + this->randScaleChange = rotZ & 0xFFFF; this->actionFunc = EnPoFusen_IdleFuse; } -void EnPoFusen_IdleFuse(EnPoFusen* this, GlobalContext* globalCtx) { - EnPoFusen_Idle(this, globalCtx); +void EnPoFusen_IdleFuse(EnPoFusen* this, PlayState* play) { + EnPoFusen_Idle(this, play); if (this->fuse-- == 0) { EnPoFusen_IncrementRomaniPop(this); } } -void EnPoFusen_Update(Actor* thisx, GlobalContext* globalCtx) { +void EnPoFusen_Update(Actor* thisx, PlayState* play) { EnPoFusen* this = THIS; - this->actionFunc(this, globalCtx); - if (EnPoFusen_CheckCollision(this, globalCtx) != 0) { + this->actionFunc(this, play); + if (EnPoFusen_CheckCollision(this, play)) { EnPoFusen_IncrementRomaniPop(this); } } -s32 EnPoFusen_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, - Actor* thisx) { +s32 EnPoFusen_OverrideLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, Actor* thisx) { EnPoFusen* this = THIS; f32 zScale; f32 yScale; @@ -288,10 +282,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) { @@ -309,16 +303,16 @@ s32 EnPoFusen_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dL return false; } -void EnPoFusen_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx) { +void EnPoFusen_PostLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx) { } -void EnPoFusen_TransformLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Actor* thisx) { +void EnPoFusen_TransformLimbDraw(PlayState* play, s32 limbIndex, Actor* thisx) { } -void EnPoFusen_Draw(Actor* thisx, GlobalContext* globalCtx) { +void EnPoFusen_Draw(Actor* thisx, PlayState* play) { EnPoFusen* this = THIS; - func_8012C28C(globalCtx->state.gfxCtx); - SkelAnime_DrawTransformFlexOpa(globalCtx, this->anime.skeleton, this->anime.jointTable, this->anime.dListCount, + func_8012C28C(play->state.gfxCtx); + SkelAnime_DrawTransformFlexOpa(play, this->anime.skeleton, this->anime.jointTable, this->anime.dListCount, EnPoFusen_OverrideLimbDraw, EnPoFusen_PostLimbDraw, EnPoFusen_TransformLimbDraw, &this->actor); } diff --git a/src/overlays/actors/ovl_En_Po_Fusen/z_en_po_fusen.h b/src/overlays/actors/ovl_En_Po_Fusen/z_en_po_fusen.h index 5a879ddb1..991b0cf9e 100644 --- a/src/overlays/actors/ovl_En_Po_Fusen/z_en_po_fusen.h +++ b/src/overlays/actors/ovl_En_Po_Fusen/z_en_po_fusen.h @@ -5,7 +5,10 @@ struct EnPoFusen; -typedef void (*EnPoFusenActionFunc)(struct EnPoFusen*, GlobalContext*); +#define ENPOFUSEN_GET_FUSE_LEN(thisx) ((thisx)->params & 0x3FF) +#define ENPOFUSEN_IS_FUSE_TYPE(thisx) ((thisx)->params & 0x8000) + +typedef void (*EnPoFusenActionFunc)(struct EnPoFusen*, PlayState*); typedef struct EnPoFusen { /* 0x000 */ Actor actor; diff --git a/src/overlays/actors/ovl_En_Po_Sisters/z_en_po_sisters.c b/src/overlays/actors/ovl_En_Po_Sisters/z_en_po_sisters.c index 1cd7a4f83..b9afa5229 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 @@ -1,65 +1,64 @@ /* * File: z_en_po_sisters.c * Overlay: ovl_En_Po_Sisters - * Description: Poe Sisters + * Description: Poe Sisters (fought in a mini-game in Ikana for a HP) */ #include "z_en_po_sisters.h" #include "objects/gameplay_keep/gameplay_keep.h" -#include "objects/object_po_sisters/object_po_sisters.h" #define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_4 | ACTOR_FLAG_10 | ACTOR_FLAG_1000 | ACTOR_FLAG_4000) #define THIS ((EnPoSisters*)thisx) -void EnPoSisters_Init(Actor* thisx, GlobalContext* globalCtx); -void EnPoSisters_Destroy(Actor* thisx, GlobalContext* globalCtx); -void EnPoSisters_Update(Actor* thisx, GlobalContext* globalCtx); -void EnPoSisters_Draw(Actor* thisx, GlobalContext* globalCtx); +void EnPoSisters_Init(Actor* thisx, PlayState* play); +void EnPoSisters_Destroy(Actor* thisx, PlayState* play); +void EnPoSisters_Update(Actor* thisx, PlayState* play); +void EnPoSisters_Draw(Actor* thisx, PlayState* play); -void func_80B1AA88(EnPoSisters* this); -void func_80B1AAE8(EnPoSisters* this, GlobalContext* globalCtx); -void func_80B1ABB8(EnPoSisters* this, GlobalContext* globalCtx); -void func_80B1AC40(EnPoSisters* this); -void func_80B1ACB8(EnPoSisters* this, GlobalContext* globalCtx); -void func_80B1AE28(EnPoSisters* this); -void func_80B1AE3C(EnPoSisters* this, GlobalContext* globalCtx); -void func_80B1AF8C(EnPoSisters* this); -void func_80B1B020(EnPoSisters* this, GlobalContext* globalCtx); -void func_80B1B0E0(EnPoSisters* this); -void func_80B1B168(EnPoSisters* this, GlobalContext* globalCtx); -void func_80B1B2F0(EnPoSisters* this, GlobalContext* globalCtx); -void func_80B1B444(EnPoSisters* this, GlobalContext* globalCtx); -void func_80B1B5B4(EnPoSisters* this); -void func_80B1B628(EnPoSisters* this, GlobalContext* globalCtx); -void func_80B1B70C(EnPoSisters* this); -void func_80B1B7BC(EnPoSisters* this, GlobalContext* globalCtx); -void func_80B1B860(EnPoSisters* this, GlobalContext* globalCtx); -void func_80B1B940(EnPoSisters* this, GlobalContext* globalCtx); -void func_80B1BA3C(EnPoSisters* this); -void func_80B1BA90(EnPoSisters* this, GlobalContext* globalCtx); -void func_80B1BC4C(EnPoSisters* this, GlobalContext* globalCtx); -void func_80B1BCA0(EnPoSisters* this, GlobalContext* globalCtx); -void func_80B1BCF0(EnPoSisters* this, GlobalContext* globalCtx); -void func_80B1BE4C(EnPoSisters* this, s32 arg1); -void func_80B1BF2C(EnPoSisters* this, GlobalContext* globalCtx); -void func_80B1C030(EnPoSisters* this); -void func_80B1C0A4(EnPoSisters* this, GlobalContext* globalCtx); -void func_80B1C2E8(EnPoSisters* this); -void func_80B1C340(EnPoSisters* this, GlobalContext* globalCtx); +void EnPoSisters_SetupObserverIdle(EnPoSisters* this); +void EnPoSisters_ObserverIdle(EnPoSisters* this, PlayState* play); +void EnPoSisters_AimlessIdleFlying2(EnPoSisters* this, PlayState* play); +void EnPoSisters_SetupAimlessIdleFlying(EnPoSisters* this); +void EnPoSisters_AimlessIdleFlying(EnPoSisters* this, PlayState* play); +void EnPoSisters_SetupInvestigating(EnPoSisters* this); +void EnPoSisters_Investigating(EnPoSisters* this, PlayState* play); +void EnPoSisters_SetupSpinUp(EnPoSisters* this); +void EnPoSisters_SpinUp(EnPoSisters* this, PlayState* play); +void EnPoSisters_SetupSpinAttack(EnPoSisters* this); +void EnPoSisters_SpinAttack(EnPoSisters* this, PlayState* play); +void EnPoSisters_AttackConnectDrift(EnPoSisters* this, PlayState* play); +void EnPoSisters_DamageFlinch(EnPoSisters* this, PlayState* play); +void EnPoSisters_SetupFlee(EnPoSisters* this); +void EnPoSisters_Flee(EnPoSisters* this, PlayState* play); +void EnPoSisters_SetupSpinToInvis(EnPoSisters* this); +void EnPoSisters_SpinToInvis(EnPoSisters* this, PlayState* play); +void EnPoSisters_SetupSpinBackToVisible(EnPoSisters* this, PlayState* play); +void EnPoSisters_SpinBackToVisible(EnPoSisters* this, PlayState* play); +void EnPoSisters_SetupDeathStage1(EnPoSisters* this); +void EnPoSisters_DeathStage1(EnPoSisters* this, PlayState* play); +void EnPoSisters_SetupDeathStage2(EnPoSisters* this, PlayState* play); +void EnPoSisters_DeathStage2(EnPoSisters* this, PlayState* play); +void EnPoSisters_SpawnMegClones(EnPoSisters* this, PlayState* play); +void EnPoSisters_MegCloneVanish(EnPoSisters* this, PlayState* play); +void EnPoSisters_MegCloneWaitForSpinBack(EnPoSisters* this, PlayState* play); +void EnPoSisters_SetupMegSurroundPlayer(EnPoSisters* this); +void EnPoSisters_MegSurroundPlayer(EnPoSisters* this, PlayState* play); +void EnPoSisters_SetupSpawnPo(EnPoSisters* this); +void EnPoSisters_PoeSpawn(EnPoSisters* this, PlayState* play); -static Color_RGBA8 D_80B1DA30[] = { - { 255, 170, 255, 255 }, - { 255, 200, 0, 255 }, - { 0, 170, 255, 255 }, - { 170, 255, 0, 255 }, +static Color_RGBA8 sPoSisterFlameColors[] = { + { 255, 170, 255, 255 }, // Meg + { 255, 200, 0, 255 }, // Jo + { 0, 170, 255, 255 }, // Beth + { 170, 255, 0, 255 }, // Amy }; -static Color_RGBA8 D_80B1DA40[] = { - { 100, 0, 255, 255 }, - { 255, 0, 0, 255 }, - { 0, 0, 255, 255 }, - { 0, 150, 0, 255 }, +static Color_RGBA8 sPoSisterEnvColors[] = { + { 100, 0, 255, 255 }, // Meg + { 255, 0, 0, 255 }, // Jo + { 0, 0, 255, 255 }, // Beth + { 0, 150, 0, 255 }, // Amy }; const ActorInit En_Po_Sisters_InitVars = { @@ -94,41 +93,50 @@ static ColliderCylinderInit sCylinderInit = { { 18, 60, 15, { 0, 0, 0 } }, }; +// health:6, mass:50 static CollisionCheckInfoInit sColChkInfoInit = { 6, 25, 60, 50 }; +typedef enum { + /* 0x0 */ POSISTERS_DAMAGEEFFECT_NOEFFECT, + /* 0x1 */ POSISTERS_DAMAGEEFFECT_UNKDMG12, // set in DamageTable, but unused + /* 0x4 */ POSISTERS_DAMAGEEFFECT_LIGHTARROWS = 0x4, + /* 0xE */ POSISTERS_DAMAGEEFFECT_SPINATTACK = 0xE, + /* 0xF */ POSISTERS_DAMAGEEFFECT_DEKUNUT = 0xF, +} PoSisterDamageEffect; + static DamageTable sDamageTable = { - /* Deku Nut */ DMG_ENTRY(0, 0xF), - /* Deku Stick */ DMG_ENTRY(1, 0x0), - /* Horse trample */ DMG_ENTRY(1, 0x0), - /* Explosives */ DMG_ENTRY(1, 0x0), - /* Zora boomerang */ DMG_ENTRY(1, 0x0), - /* Normal arrow */ DMG_ENTRY(1, 0x0), - /* UNK_DMG_0x06 */ DMG_ENTRY(0, 0x0), - /* Hookshot */ DMG_ENTRY(1, 0x0), - /* Goron punch */ DMG_ENTRY(1, 0x0), - /* Sword */ DMG_ENTRY(1, 0x0), - /* Goron pound */ DMG_ENTRY(0, 0x0), - /* Fire arrow */ DMG_ENTRY(1, 0x0), - /* Ice arrow */ DMG_ENTRY(1, 0x0), - /* 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, 0x0), - /* Normal shield */ DMG_ENTRY(0, 0x0), - /* Light ray */ DMG_ENTRY(0, 0x0), - /* Thrown object */ DMG_ENTRY(1, 0x0), - /* Zora punch */ DMG_ENTRY(1, 0x0), - /* Spin attack */ DMG_ENTRY(1, 0xE), - /* Sword beam */ DMG_ENTRY(0, 0x0), - /* Normal Roll */ DMG_ENTRY(0, 0x0), - /* UNK_DMG_0x1B */ DMG_ENTRY(0, 0x0), - /* UNK_DMG_0x1C */ DMG_ENTRY(0, 0x0), - /* Unblockable */ DMG_ENTRY(0, 0x0), - /* UNK_DMG_0x1E */ DMG_ENTRY(0, 0x0), - /* Powder Keg */ DMG_ENTRY(1, 0x0), + /* Deku Nut */ DMG_ENTRY(0, POSISTERS_DAMAGEEFFECT_DEKUNUT), + /* Deku Stick */ DMG_ENTRY(1, POSISTERS_DAMAGEEFFECT_NOEFFECT), + /* Horse trample */ DMG_ENTRY(1, POSISTERS_DAMAGEEFFECT_NOEFFECT), + /* Explosives */ DMG_ENTRY(1, POSISTERS_DAMAGEEFFECT_NOEFFECT), + /* Zora boomerang */ DMG_ENTRY(1, POSISTERS_DAMAGEEFFECT_NOEFFECT), + /* Normal arrow */ DMG_ENTRY(1, POSISTERS_DAMAGEEFFECT_NOEFFECT), + /* UNK_DMG_0x06 */ DMG_ENTRY(0, POSISTERS_DAMAGEEFFECT_NOEFFECT), + /* Hookshot */ DMG_ENTRY(1, POSISTERS_DAMAGEEFFECT_NOEFFECT), + /* Goron punch */ DMG_ENTRY(1, POSISTERS_DAMAGEEFFECT_NOEFFECT), + /* Sword */ DMG_ENTRY(1, POSISTERS_DAMAGEEFFECT_NOEFFECT), + /* Goron pound */ DMG_ENTRY(0, POSISTERS_DAMAGEEFFECT_NOEFFECT), + /* Fire arrow */ DMG_ENTRY(1, POSISTERS_DAMAGEEFFECT_NOEFFECT), + /* Ice arrow */ DMG_ENTRY(1, POSISTERS_DAMAGEEFFECT_NOEFFECT), + /* Light arrow */ DMG_ENTRY(2, POSISTERS_DAMAGEEFFECT_LIGHTARROWS), + /* Goron spikes */ DMG_ENTRY(1, POSISTERS_DAMAGEEFFECT_NOEFFECT), + /* Deku spin */ DMG_ENTRY(1, POSISTERS_DAMAGEEFFECT_NOEFFECT), + /* Deku bubble */ DMG_ENTRY(1, POSISTERS_DAMAGEEFFECT_NOEFFECT), + /* Deku launch */ DMG_ENTRY(2, POSISTERS_DAMAGEEFFECT_NOEFFECT), + /* UNK_DMG_0x12 */ DMG_ENTRY(0, POSISTERS_DAMAGEEFFECT_UNKDMG12), + /* Zora barrier */ DMG_ENTRY(0, POSISTERS_DAMAGEEFFECT_NOEFFECT), + /* Normal shield */ DMG_ENTRY(0, POSISTERS_DAMAGEEFFECT_NOEFFECT), + /* Light ray */ DMG_ENTRY(0, POSISTERS_DAMAGEEFFECT_NOEFFECT), + /* Thrown object */ DMG_ENTRY(1, POSISTERS_DAMAGEEFFECT_NOEFFECT), + /* Zora punch */ DMG_ENTRY(1, POSISTERS_DAMAGEEFFECT_NOEFFECT), + /* Spin attack */ DMG_ENTRY(1, POSISTERS_DAMAGEEFFECT_SPINATTACK), + /* Sword beam */ DMG_ENTRY(0, POSISTERS_DAMAGEEFFECT_NOEFFECT), + /* Normal Roll */ DMG_ENTRY(0, POSISTERS_DAMAGEEFFECT_NOEFFECT), + /* UNK_DMG_0x1B */ DMG_ENTRY(0, POSISTERS_DAMAGEEFFECT_NOEFFECT), + /* UNK_DMG_0x1C */ DMG_ENTRY(0, POSISTERS_DAMAGEEFFECT_NOEFFECT), + /* Unblockable */ DMG_ENTRY(0, POSISTERS_DAMAGEEFFECT_NOEFFECT), + /* UNK_DMG_0x1E */ DMG_ENTRY(0, POSISTERS_DAMAGEEFFECT_NOEFFECT), + /* Powder Keg */ DMG_ENTRY(1, POSISTERS_DAMAGEEFFECT_NOEFFECT), }; static InitChainEntry sInitChain[] = { @@ -136,114 +144,140 @@ static InitChainEntry sInitChain[] = { ICHAIN_F32(targetArrowOffset, 6000, ICHAIN_STOP), }; -void EnPoSisters_Init(Actor* thisx, GlobalContext* globalCtx) { +// clang-format off +// PoSisters have their own flags variable for cross function behavior detection +#define POSISTERS_FLAG_CLEAR (0) +#define POSISTERS_FLAG_CHECK_AC (1 << 0) +#define POSISTERS_FLAG_UPDATE_SHAPE_ROT (1 << 1) +#define POSISTERS_FLAG_CHECK_Z_TARGET (1 << 2) // meg doesnt go invis if you ztarget her for too long +#define POSISTERS_FLAG_MATCH_PLAYER_HEIGHT (1 << 3) // the po is attempting to level with player's height +#define POSISTERS_FLAG_UPDATE_BGCHECK_INFO (1 << 4) +#define POSISTERS_FLAG_UPDATE_FIRES (1 << 5) // firePos updated to match limb in PostLimbDraw +#define POSISTERS_FLAG_REAL_MEG_ROTATION (1 << 6) // real meg rotates different than her clones for one cycle +#define POSISTERS_FLAG_DRAW_TORCH (1 << 7) +// clang-format on + +void EnPoSisters_Init(Actor* thisx, PlayState* play) { s32 pad; EnPoSisters* this = THIS; Actor_ProcessInitChain(&this->actor, sInitChain); ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 50.0f); - SkelAnime_Init(globalCtx, &this->skelAnime, &object_po_sisters_Skel_0065C8, &object_po_sisters_Anim_0014CC, - this->jointTable, this->morphTable, 12); - this->unk_226 = 255; - this->unk_227 = 255; - this->unk_228 = 210; - this->unk_229 = 255; - this->lightNode = LightContext_InsertLight(globalCtx, &globalCtx->lightCtx, &this->lightInfo); + SkelAnime_Init(play, &this->skelAnime, &gPoSistersSkel, &gPoeSistersSwayAnim, this->jointTable, this->morphTable, + POSISTERS_LIMB_MAX); + + this->color.r = 255; + this->color.g = 255; + this->color.b = 210; + this->color.a = 255; + this->lightNode = LightContext_InsertLight(play, &play->lightCtx, &this->lightInfo); Lights_PointGlowSetInfo(&this->lightInfo, this->actor.home.pos.x, this->actor.home.pos.y, this->actor.home.pos.z, 0, 0, 0, 0); - Collider_InitAndSetCylinder(globalCtx, &this->collider, &this->actor, &sCylinderInit); - CollisionCheck_SetInfo(&this->actor.colChkInfo, &sDamageTable, &sColChkInfoInit); - this->unk_18C = ENPOSISTERS_GET_300(thisx); - this->actor.hintId = this->unk_18C + 80; - this->unk_18D = ENPOSISTERS_GET_C00(thisx); - this->unk_18E = 32; - this->unk_18F = 20; - this->unk_190 = 1; - this->unk_191 = 0x20; - this->unk_2EC = 110.0f; - thisx->flags &= ~1; - if (ENPOSISTERS_GET_1000(&this->actor)) { - func_80B1AA88(this); - } else if (this->unk_18C == 0) { - if (this->unk_18D == 0) { + Collider_InitAndSetCylinder(play, &this->collider, &this->actor, &sCylinderInit); + CollisionCheck_SetInfo(&this->actor.colChkInfo, &sDamageTable, &sColChkInfoInit); + this->type = ENPOSISTERS_GET_TYPE(thisx); + this->actor.hintId = this->type + 80; + this->megCloneId = ENPOSISTERS_GET_MEG_CLONE_ID(thisx); + this->floatingBobbingTimer = 32; + this->zTargetTimer = 20; + this->fireCount = 1; + this->poSisterFlags = POSISTERS_FLAG_UPDATE_FIRES; + this->megDistToPlayer = 110.0f; + thisx->flags &= ~ACTOR_FLAG_1; + + if (ENPOSISTERS_GET_OBSERVER_FLAG(&this->actor)) { + // if flagged observer, they are a floating prop spawned by EnGb2 (po hut proprieter) + EnPoSisters_SetupObserverIdle(this); + } else if (this->type == POSISTER_TYPE_MEG) { + if (this->megCloneId == POSISTER_MEG_REAL) { this->actor.colChkInfo.health = 8; this->collider.info.toucher.damage = 16; this->collider.base.ocFlags1 = (OC1_TYPE_PLAYER | OC1_ON); - func_80B1BCF0(this, globalCtx); - func_80B1C2E8(this); + EnPoSisters_SpawnMegClones(this, play); + EnPoSisters_SetupSpawnPo(this); } else { 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; - func_80B1BE4C(this, false); + EnPoSisters_MegCloneVanish(this, NULL); } } else { - func_80B1C2E8(this); + EnPoSisters_SetupSpawnPo(this); } + + // ! @Weird: this actor doesn't accept params in this range, so params is just cleared this->actor.params &= 0xFF; } -void EnPoSisters_Destroy(Actor* thisx, GlobalContext* globalCtx) { +void EnPoSisters_Destroy(Actor* thisx, PlayState* play) { EnPoSisters* this = THIS; - LightContext_RemoveLight(globalCtx, &globalCtx->lightCtx, this->lightNode); - Collider_DestroyCylinder(globalCtx, &this->collider); + LightContext_RemoveLight(play, &play->lightCtx, this->lightNode); + Collider_DestroyCylinder(play, &this->collider); } -void func_80B1A648(EnPoSisters* this, s32 arg1, Vec3f* pos) { +/** + * For some reason, it uses both deathTimer (param) and this->deathTimer. + */ +void EnPoSisters_UpdateDeathFlameSwirl(EnPoSisters* this, s32 deathTimerParam, Vec3f* pos) { s32 i; - Vec3f* ptr; - f32 temp_f20 = arg1; + Vec3f* firePos; + f32 deathTimerParamF = deathTimerParam; - for (i = 0; i < this->unk_190; i++) { - ptr = &this->unk_22C[i]; - ptr->x = Math_SinS(this->actor.shape.rot.y + (this->unk_192 * 0x800) + (i * 0x2000)) * (SQ(temp_f20) * 0.1f) + - pos->x; - ptr->z = Math_CosS(this->actor.shape.rot.y + (this->unk_192 * 0x800) + (i * 0x2000)) * (SQ(temp_f20) * 0.1f) + - pos->z; - ptr->y = pos->y + temp_f20; + for (i = 0; i < this->fireCount; i++) { + firePos = &this->firePos[i]; + firePos->x = Math_SinS(this->actor.shape.rot.y + (this->deathTimer * 0x800) + (i * 0x2000)) * + (SQ(deathTimerParamF) * 0.1f) + + pos->x; + firePos->z = Math_CosS(this->actor.shape.rot.y + (this->deathTimer * 0x800) + (i * 0x2000)) * + (SQ(deathTimerParamF) * 0.1f) + + pos->z; + firePos->y = pos->y + deathTimerParamF; } } -void func_80B1A768(EnPoSisters* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); - f32 sp20; +void EnPoSisters_MatchPlayerXZ(EnPoSisters* this, PlayState* play) { + Player* player = GET_PLAYER(play); + f32 dist; - if ((this->unk_18D == 0) || (this->actionFunc != func_80B1B444)) { - if (((player->swordState == 0) || (player->swordAnimation >= 30)) && + if (this->megCloneId == POSISTER_MEG_REAL || this->actionFunc != EnPoSisters_DamageFlinch) { + if ((player->meleeWeaponState == 0 || player->meleeWeaponAnimation >= PLAYER_MWA_SPIN_ATTACK_1H) && ((player->actor.world.pos.y - player->actor.floorHeight) < 1.0f)) { - Math_StepToF(&this->unk_2EC, 110.0f, 3.0f); + Math_StepToF(&this->megDistToPlayer, 110.0f, 3.0f); } else { - Math_StepToF(&this->unk_2EC, 170.0f, 10.0f); + Math_StepToF(&this->megDistToPlayer, 170.0f, 10.0f); } - sp20 = this->unk_2EC; - } else if (this->unk_18D != 0) { - sp20 = this->actor.parent->xzDistToPlayer; + dist = this->megDistToPlayer; + } else if (this->megCloneId != POSISTER_MEG_REAL) { + dist = this->actor.parent->xzDistToPlayer; } - this->actor.world.pos.x = (Math_SinS(BINANG_ROT180(this->actor.shape.rot.y)) * sp20) + player->actor.world.pos.x; - this->actor.world.pos.z = (Math_CosS(BINANG_ROT180(this->actor.shape.rot.y)) * sp20) + player->actor.world.pos.z; + this->actor.world.pos.x = (Math_SinS(BINANG_ROT180(this->actor.shape.rot.y)) * dist) + player->actor.world.pos.x; + this->actor.world.pos.z = (Math_CosS(BINANG_ROT180(this->actor.shape.rot.y)) * dist) + player->actor.world.pos.z; } -void func_80B1A894(EnPoSisters* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); +void EnPoSisters_MatchPlayerY(EnPoSisters* this, PlayState* play) { + Player* player = GET_PLAYER(play); + // equalize to player height Math_ApproachF(&this->actor.world.pos.y, player->actor.world.pos.y + 5.0f, 0.5f, 3.0f); - if (this->unk_18E == 0) { - this->unk_18E = 32; - if (this->unk_18E) {} + if (this->floatingBobbingTimer == 0) { + this->floatingBobbingTimer = 32; + //! FAKE: + if (this->floatingBobbingTimer) {} } - if (this->unk_18E != 0) { - this->unk_18E--; - } + DECR(this->floatingBobbingTimer); - this->actor.world.pos.y += (2.0f + (0.5f * Rand_ZeroOne())) * Math_SinS(this->unk_18E * 0x800); - if ((this->unk_229 == 255) && (this->actionFunc != func_80B1B168) && (this->actionFunc != func_80B1B020)) { - if (this->actionFunc == func_80B1B628) { + // random float/flying wobble + this->actor.world.pos.y += (2.0f + (0.5f * Rand_ZeroOne())) * Math_SinS(this->floatingBobbingTimer * 0x800); + + // fully opaque + if (this->color.a == 255 && this->actionFunc != EnPoSisters_SpinAttack && this->actionFunc != EnPoSisters_SpinUp) { + if (this->actionFunc == EnPoSisters_Flee) { func_800B9010(&this->actor, NA_SE_EN_PO_AWAY - SFX_FLAG); } else { func_800B9010(&this->actor, NA_SE_EN_PO_FLY - SFX_FLAG); @@ -251,683 +285,711 @@ void func_80B1A894(EnPoSisters* this, GlobalContext* globalCtx) { } } -void func_80B1A9B0(EnPoSisters* this, GlobalContext* globalCtx) { - if (this->actor.isTargeted && (this->unk_229 == 255)) { - if (this->unk_18F != 0) { - this->unk_18F--; - } +// check for z target +void EnPoSisters_CheckZTarget(EnPoSisters* this, PlayState* play) { + if (this->actor.isTargeted && (this->color.a == 255)) { + DECR(this->zTargetTimer); } else { - this->unk_18F = 20; + this->zTargetTimer = 20; } - if (this->unk_229 == 0) { - if (this->unk_194 != 0) { - this->unk_194--; - } + if (this->color.a == 0) { + DECR(this->invisibleTimer); } - if ((this->actionFunc != func_80B1B020) && (this->actionFunc != func_80B1B168) && - (this->actionFunc != func_80B1B444)) { - if (this->unk_18F == 0) { - func_80B1B70C(this); - } else if ((this->unk_194 == 0) && (this->unk_229 == 0)) { - func_80B1B860(this, globalCtx); + if ((this->actionFunc != EnPoSisters_SpinUp) && (this->actionFunc != EnPoSisters_SpinAttack) && + (this->actionFunc != EnPoSisters_DamageFlinch)) { + if (this->zTargetTimer == 0) { + EnPoSisters_SetupSpinToInvis(this); + } else if ((this->invisibleTimer == 0) && (this->color.a == 0)) { + EnPoSisters_SetupSpinBackToVisible(this, play); } } } -void func_80B1AA88(EnPoSisters* this) { - Animation_MorphToLoop(&this->skelAnime, &object_po_sisters_Anim_0014CC, -3.0f); +void EnPoSisters_SetupObserverIdle(EnPoSisters* this) { + Animation_MorphToLoop(&this->skelAnime, &gPoeSistersSwayAnim, -3.0f); this->actor.speedXZ = 0.0f; - this->unk_192 = Rand_S16Offset(100, 50); - this->actionFunc = func_80B1AAE8; + this->laughTimer = Rand_S16Offset(100, 50); + this->actionFunc = EnPoSisters_ObserverIdle; } -void func_80B1AAE8(EnPoSisters* this, GlobalContext* globalCtx) { +void EnPoSisters_ObserverIdle(EnPoSisters* this, PlayState* play) { SkelAnime_Update(&this->skelAnime); - if (DECR(this->unk_192) == 0) { - this->unk_192 = Rand_S16Offset(100, 50); + if (DECR(this->laughTimer) == 0) { + this->laughTimer = Rand_S16Offset(100, 50); Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_PO_LAUGH2); } } -void func_80B1AB5C(EnPoSisters* this) { - Animation_MorphToLoop(&this->skelAnime, &object_po_sisters_Anim_0014CC, -3.0f); - this->unk_192 = Rand_S16Offset(2, 3); +/** + * Change animation, but keep flying idle in straight line. Flying through walls possible. + * + * This is never reached because conditions are never met in EnPoSisters_AimlessIdleFlying + */ +void EnPoSisters_SetupAimlessIdleFlying2(EnPoSisters* this) { + Animation_MorphToLoop(&this->skelAnime, &gPoeSistersSwayAnim, -3.0f); + this->idleFlyingAnimationCounter = Rand_S16Offset(2, 3); this->actor.speedXZ = 0.0f; - this->actionFunc = func_80B1ABB8; + this->actionFunc = EnPoSisters_AimlessIdleFlying2; } -void func_80B1ABB8(EnPoSisters* this, GlobalContext* globalCtx) { +void EnPoSisters_AimlessIdleFlying2(EnPoSisters* this, PlayState* play) { SkelAnime_Update(&this->skelAnime); if (Animation_OnFrame(&this->skelAnime, 0.0f)) { - if (this->unk_192 != 0) { - this->unk_192--; - } + DECR(this->idleFlyingAnimationCounter); } - if ((this->unk_192 == 0) || (this->actor.xzDistToPlayer < 600.0f)) { - func_80B1AC40(this); + if ((this->idleFlyingAnimationCounter == 0) || (this->actor.xzDistToPlayer < 600.0f)) { + EnPoSisters_SetupAimlessIdleFlying(this); } } -void func_80B1AC40(EnPoSisters* this) { - if (this->actionFunc != func_80B1AE3C) { - Animation_MorphToLoop(&this->skelAnime, &object_po_sisters_Anim_000D40, -3.0f); +/** + * Flying in a straight line, until wall or player comes near. + */ +void EnPoSisters_SetupAimlessIdleFlying(EnPoSisters* this) { + if (this->actionFunc != EnPoSisters_Investigating) { + Animation_MorphToLoop(&this->skelAnime, &gPoeSistersFloatAnim, -3.0f); } - this->unk_192 = Rand_S16Offset(15, 3); - this->unk_191 |= (0x6 | 0x1); - this->actionFunc = func_80B1ACB8; + this->idleFlyingAnimationCounter = Rand_S16Offset(15, 3); + this->poSisterFlags |= (POSISTERS_FLAG_CHECK_Z_TARGET | POSISTERS_FLAG_UPDATE_SHAPE_ROT | POSISTERS_FLAG_CHECK_AC); + this->actionFunc = EnPoSisters_AimlessIdleFlying; } -void func_80B1ACB8(EnPoSisters* this, GlobalContext* globalCtx) { +void EnPoSisters_AimlessIdleFlying(EnPoSisters* this, PlayState* play) { SkelAnime_Update(&this->skelAnime); Math_StepToF(&this->actor.speedXZ, 1.0f, 0.2f); if (Animation_OnFrame(&this->skelAnime, 0.0f)) { - if (this->unk_192 != 0) { - this->unk_192--; - } + DECR(this->idleFlyingAnimationCounter); } if ((this->actor.xzDistToPlayer < 600.0f) && (fabsf(this->actor.playerHeightRel + 5.0f) < 30.0f)) { - func_80B1AE28(this); - } else if ((this->unk_192 == 0) && Math_StepToF(&this->actor.speedXZ, 0.0f, 0.2f)) { - func_80B1AB5C(this); + EnPoSisters_SetupInvestigating(this); + } else if ((this->idleFlyingAnimationCounter == 0) && Math_StepToF(&this->actor.speedXZ, 0.0f, 0.2f)) { + // ! @bug: this is never reached because speedXZ is reduced + // at the same rate it is increased at the top of this function + EnPoSisters_SetupAimlessIdleFlying2(this); } - if (this->actor.bgCheckFlags & 8) { + if (this->actor.bgCheckFlags & 8) { // touching a wall Math_ScaledStepToS(&this->actor.world.rot.y, Actor_YawToPoint(&this->actor, &this->actor.home.pos), 0x71C); } else if (Actor_XZDistanceToPoint(&this->actor, &this->actor.home.pos) > 600.0f) { Math_ScaledStepToS(&this->actor.world.rot.y, Actor_YawToPoint(&this->actor, &this->actor.home.pos), 0x71C); } } -void func_80B1AE28(EnPoSisters* this) { - this->actionFunc = func_80B1AE3C; +/** + * Not yet agressive, gently flying/steering toward the player. + */ +void EnPoSisters_SetupInvestigating(EnPoSisters* this) { + this->actionFunc = EnPoSisters_Investigating; } -void func_80B1AE3C(EnPoSisters* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); - s16 sp22; +void EnPoSisters_Investigating(EnPoSisters* this, PlayState* play) { + Player* player = GET_PLAYER(play); + s16 yawDiff; SkelAnime_Update(&this->skelAnime); - sp22 = this->actor.yawTowardsPlayer - player->actor.shape.rot.y; + yawDiff = this->actor.yawTowardsPlayer - player->actor.shape.rot.y; Math_StepToF(&this->actor.speedXZ, 2.0f, 0.2f); - if (sp22 > 0x3000) { + if (yawDiff > 0x3000) { Math_ScaledStepToS(&this->actor.world.rot.y, this->actor.yawTowardsPlayer + 0x3000, 0x71C); - } else if (sp22 < -0x3000) { + } else if (yawDiff < -0x3000) { Math_ScaledStepToS(&this->actor.world.rot.y, this->actor.yawTowardsPlayer - 0x3000, 0x71C); } else { Math_ScaledStepToS(&this->actor.world.rot.y, this->actor.yawTowardsPlayer, 0x71C); } if ((this->actor.xzDistToPlayer < 320.0f) && (fabsf(this->actor.playerHeightRel + 5.0f) < 30.0f)) { - func_80B1AF8C(this); + EnPoSisters_SetupSpinUp(this); } else if (this->actor.xzDistToPlayer > 720.0f) { - func_80B1AC40(this); + EnPoSisters_SetupAimlessIdleFlying(this); } } -void func_80B1AF8C(EnPoSisters* this) { - if (this->unk_229 != 0) { +/** + * Gaining speed for spin attack before the actual attack, winding up. + */ +void EnPoSisters_SetupSpinUp(EnPoSisters* this) { + if (this->color.a != 0) { this->collider.base.colType = COLTYPE_METAL; this->collider.base.acFlags |= AC_HARD; } - Animation_MorphToLoop(&this->skelAnime, &object_po_sisters_Anim_000114, -5.0f); + Animation_MorphToLoop(&this->skelAnime, &gPoSistersAttackAnim, -5.0f); this->actor.speedXZ = 0.0f; - this->unk_192 = Animation_GetLastFrame(&object_po_sisters_Anim_000114.common) * 3 + 3; - this->unk_191 &= ~2; - this->actionFunc = func_80B1B020; + this->spinupTimer = Animation_GetLastFrame(&gPoSistersAttackAnim.common) * 3 + 3; + this->poSisterFlags &= ~POSISTERS_FLAG_UPDATE_SHAPE_ROT; + this->actionFunc = EnPoSisters_SpinUp; } -void func_80B1B020(EnPoSisters* this, GlobalContext* globalCtx) { +void EnPoSisters_SpinUp(EnPoSisters* this, PlayState* play) { SkelAnime_Update(&this->skelAnime); - if (this->unk_192 != 0) { - this->unk_192--; - } - - this->actor.shape.rot.y += ((s32)((this->skelAnime.endFrame + 1.0f) * 3.0f) - this->unk_192) * 0x180; - - if ((this->unk_192 == 18) || (this->unk_192 == 7)) { + DECR(this->spinupTimer); + this->actor.shape.rot.y += ((s32)((this->skelAnime.endFrame + 1.0f) * 3.0f) - this->spinupTimer) * 0x180; + if ((this->spinupTimer == 18) || (this->spinupTimer == 7)) { Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_PO_ROLL); - } else if (this->unk_192 == 0) { - func_80B1B0E0(this); + } else if (this->spinupTimer == 0) { + EnPoSisters_SetupSpinAttack(this); } } -void func_80B1B0E0(EnPoSisters* this) { +void EnPoSisters_SetupSpinAttack(EnPoSisters* this) { this->actor.speedXZ = 5.0f; - if (this->unk_18C == 0) { + if (this->type == POSISTER_TYPE_MEG) { this->collider.base.colType = COLTYPE_METAL; this->collider.base.acFlags |= AC_HARD; - Animation_MorphToLoop(&this->skelAnime, &object_po_sisters_Anim_000114, -5.0f); + Animation_MorphToLoop(&this->skelAnime, &gPoSistersAttackAnim, -5.0f); } - this->unk_192 = 5; + + this->spinTimer = 5; this->actor.world.rot.y = this->actor.yawTowardsPlayer; - this->unk_191 |= 8; - this->actionFunc = func_80B1B168; + this->poSisterFlags |= POSISTERS_FLAG_MATCH_PLAYER_HEIGHT; + this->actionFunc = EnPoSisters_SpinAttack; } -void func_80B1B168(EnPoSisters* this, GlobalContext* globalCtx) { +void EnPoSisters_SpinAttack(EnPoSisters* this, PlayState* play) { SkelAnime_Update(&this->skelAnime); if (Animation_OnFrame(&this->skelAnime, 0.0f)) { - if (this->unk_192 != 0) { - this->unk_192--; - } + DECR(this->spinTimer); } this->actor.shape.rot.y += (s32)(1152.0f * this->skelAnime.endFrame); - if (this->unk_192 == 0) { + if (this->spinTimer == 0) { s16 rotY = this->actor.shape.rot.y - this->actor.world.rot.y; if (ABS_ALT(rotY) < 0x1000) { - if (this->unk_18C != 0) { + if (this->type != POSISTER_TYPE_MEG) { this->collider.base.colType = COLTYPE_HIT3; this->collider.base.acFlags &= ~AC_HARD; - func_80B1AC40(this); + EnPoSisters_SetupAimlessIdleFlying(this); } else { Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_PO_LAUGH2); - func_80B1BE4C(this, globalCtx); + EnPoSisters_MegCloneVanish(this, play); } } } + if (Animation_OnFrame(&this->skelAnime, 1.0f)) { Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_PO_ROLL); } } -void func_80B1B280(EnPoSisters* this) { - Animation_MorphToLoop(&this->skelAnime, &object_po_sisters_Anim_000D40, -3.0f); +/** + * Attack has connected with player. + */ +void EnPoSisters_SetupAttackConnect(EnPoSisters* this) { + Animation_MorphToLoop(&this->skelAnime, &gPoeSistersFloatAnim, -3.0f); this->actor.world.rot.y = BINANG_ROT180(this->actor.yawTowardsPlayer); - if (this->unk_18C != 0) { + if (this->type != POSISTER_TYPE_MEG) { this->collider.base.colType = COLTYPE_HIT3; this->collider.base.acFlags &= ~AC_HARD; } - this->actionFunc = func_80B1B2F0; + + this->actionFunc = EnPoSisters_AttackConnectDrift; } -void func_80B1B2F0(EnPoSisters* this, GlobalContext* globalCtx) { +void EnPoSisters_AttackConnectDrift(EnPoSisters* this, PlayState* play) { SkelAnime_Update(&this->skelAnime); this->actor.shape.rot.y -= (s16)(this->actor.speedXZ * 10.0f * 128.0f); - if (Math_StepToF(&this->actor.speedXZ, 0.0f, 0.1f)) { + + if (Math_StepToF(&this->actor.speedXZ, 0.0f, 0.1f)) { // wait to stop moving this->actor.world.rot.y = this->actor.shape.rot.y; - if (this->unk_18C != 0) { - func_80B1AC40(this); + if (this->type != POSISTER_TYPE_MEG) { + EnPoSisters_SetupAimlessIdleFlying(this); } else { Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_PO_LAUGH2); - func_80B1BE4C(this, globalCtx); + EnPoSisters_MegCloneVanish(this, play); } } } -void func_80B1B3A8(EnPoSisters* this) { - Animation_MorphToPlayOnce(&this->skelAnime, &object_po_sisters_Anim_0008C0, -3.0f); +void EnPoSisters_SetupDamageFlinch(EnPoSisters* this) { + Animation_MorphToPlayOnce(&this->skelAnime, &gPoeSistersDamagedAnim, -3.0f); if (this->collider.base.ac != NULL) { func_800BE504(&this->actor, &this->collider); } - if (this->unk_18C != 0) { + if (this->type != POSISTER_TYPE_MEG) { this->actor.speedXZ = 10.0f; } - this->unk_191 &= ~(0x8 | 0x2 | 0x1); + this->poSisterFlags &= + ~(POSISTERS_FLAG_MATCH_PLAYER_HEIGHT | POSISTERS_FLAG_UPDATE_SHAPE_ROT | POSISTERS_FLAG_CHECK_AC); Actor_SetColorFilter(&this->actor, 0x4000, 255, 0, 16); - this->actionFunc = func_80B1B444; + this->actionFunc = EnPoSisters_DamageFlinch; } -void func_80B1B444(EnPoSisters* this, GlobalContext* globalCtx) { - s32 temp_f18; - +void EnPoSisters_DamageFlinch(EnPoSisters* this, PlayState* play) { if (SkelAnime_Update(&this->skelAnime) && !(this->actor.flags & ACTOR_FLAG_8000)) { if (this->actor.colChkInfo.health != 0) { - if (this->unk_18C != 0) { - func_80B1B5B4(this); - } else if (this->unk_18D != 0) { - func_80B1BE4C(this, 0); + if (this->type != POSISTER_TYPE_MEG) { + EnPoSisters_SetupFlee(this); + } else if (this->megCloneId != POSISTER_MEG_REAL) { + EnPoSisters_MegCloneVanish(this, NULL); } else { - func_80B1BE4C(this, globalCtx); + EnPoSisters_MegCloneVanish(this, play); } } else { - func_80B1BA3C(this); + EnPoSisters_SetupDeathStage1(this); } } - if (this->unk_18D != 0) { + if (this->megCloneId != POSISTER_MEG_REAL) { + s32 alpha; + Math_ScaledStepToS(&this->actor.shape.rot.y, this->actor.parent->shape.rot.y, - (this->unk_18D == 2) ? 0x800 : 0x400); - temp_f18 = ((this->skelAnime.endFrame - this->skelAnime.curFrame) * 255.0f) / this->skelAnime.endFrame; - this->unk_229 = CLAMP(temp_f18, 0, 255); + (this->megCloneId == POSISTER_MEG_CLONE2) ? 0x800 : 0x400); + alpha = ((this->skelAnime.endFrame - this->skelAnime.curFrame) * 255.0f) / this->skelAnime.endFrame; + this->color.a = CLAMP(alpha, 0, 255); this->actor.world.pos.y = this->actor.parent->world.pos.y; - func_80B1A768(this, globalCtx); - } else if (this->unk_18C != 0) { + EnPoSisters_MatchPlayerXZ(this, play); + + } else if (this->type != POSISTER_TYPE_MEG) { Math_StepToF(&this->actor.speedXZ, 0.0f, 0.5f); } } -void func_80B1B5B4(EnPoSisters* this) { - Animation_MorphToLoop(&this->skelAnime, &object_po_sisters_Anim_000A54, -3.0f); +void EnPoSisters_SetupFlee(EnPoSisters* this) { + Animation_MorphToLoop(&this->skelAnime, &gPoSistersFleeAnim, -3.0f); this->actor.world.rot.y = BINANG_ROT180(this->actor.shape.rot.y); - this->unk_192 = 5; - this->unk_191 |= (0x8 | 0x2 | 0x1); + this->fleeTimer = 5; + this->poSisterFlags |= + (POSISTERS_FLAG_MATCH_PLAYER_HEIGHT | POSISTERS_FLAG_UPDATE_SHAPE_ROT | POSISTERS_FLAG_CHECK_AC); this->actor.speedXZ = 5.0f; - this->actionFunc = func_80B1B628; + this->actionFunc = EnPoSisters_Flee; } -void func_80B1B628(EnPoSisters* this, GlobalContext* globalCtx) { +void EnPoSisters_Flee(EnPoSisters* this, PlayState* play) { SkelAnime_Update(&this->skelAnime); Math_ScaledStepToS(&this->actor.world.rot.y, BINANG_ROT180(this->actor.yawTowardsPlayer), 0x71C); if (Animation_OnFrame(&this->skelAnime, 0.0f)) { - if (this->unk_192 != 0) { - this->unk_192--; - } + DECR(this->fleeTimer); } - if (this->actor.bgCheckFlags & 8) { + if (this->actor.bgCheckFlags & 8) { // touching a wall this->actor.world.rot.y = this->actor.shape.rot.y; - this->unk_191 |= 2; - func_80B1B70C(this); - } else if ((this->unk_192 == 0) && (this->actor.xzDistToPlayer > 480.0f)) { + this->poSisterFlags |= POSISTERS_FLAG_UPDATE_SHAPE_ROT; + EnPoSisters_SetupSpinToInvis(this); + } else if (this->fleeTimer == 0 && this->actor.xzDistToPlayer > 480.0f) { this->actor.world.rot.y = this->actor.shape.rot.y; - func_80B1AC40(this); + EnPoSisters_SetupAimlessIdleFlying(this); } } -void func_80B1B70C(EnPoSisters* this) { - Animation_Change(&this->skelAnime, &object_po_sisters_Anim_00119C, 1.5f, 0.0f, - Animation_GetLastFrame(&object_po_sisters_Anim_00119C.common), 2, -3.0f); - this->unk_194 = 100; +void EnPoSisters_SetupSpinToInvis(EnPoSisters* this) { + Animation_Change(&this->skelAnime, &gPoeSistersAppearDisappearAnim, 1.5f, 0.0f, + Animation_GetLastFrame(&gPoeSistersAppearDisappearAnim.common), ANIMMODE_ONCE, -3.0f); + this->invisibleTimer = 100; // 5 seconds this->actor.speedXZ = 0.0f; this->actor.world.rot.y = this->actor.shape.rot.y; - this->unk_191 &= ~(0x4 | 0x1); + this->poSisterFlags &= ~(POSISTERS_FLAG_CHECK_Z_TARGET | POSISTERS_FLAG_CHECK_AC); Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_PO_DISAPPEAR); Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_PO_LAUGH2); - this->actionFunc = func_80B1B7BC; + this->actionFunc = EnPoSisters_SpinToInvis; } -void func_80B1B7BC(EnPoSisters* this, GlobalContext* globalCtx) { - s32 temp_f18; - +void EnPoSisters_SpinToInvis(EnPoSisters* this, PlayState* play) { if (SkelAnime_Update(&this->skelAnime)) { - this->unk_229 = 0; + this->color.a = 0; this->collider.info.bumper.dmgFlags = (0x40000 | 0x1); - func_80B1AC40(this); + EnPoSisters_SetupAimlessIdleFlying(this); } else { - temp_f18 = ((this->skelAnime.endFrame - this->skelAnime.curFrame) * 255.0f) / this->skelAnime.endFrame; - this->unk_229 = CLAMP(temp_f18, 0, 255); + s32 alpha = ((this->skelAnime.endFrame - this->skelAnime.curFrame) * 255.0f) / this->skelAnime.endFrame; + + this->color.a = CLAMP(alpha, 0, 255); } } -void func_80B1B860(EnPoSisters* this, GlobalContext* globalCtx) { - Animation_Change(&this->skelAnime, &object_po_sisters_Anim_00119C, 1.5f, 0.0f, - Animation_GetLastFrame(&object_po_sisters_Anim_00119C.common), 2, -3.0f); - if (this->unk_18C == 0) { - this->unk_2EC = 110.0f; - func_80B1A768(this, globalCtx); - this->unk_229 = 0; +void EnPoSisters_SetupSpinBackToVisible(EnPoSisters* this, PlayState* play) { + Animation_Change(&this->skelAnime, &gPoeSistersAppearDisappearAnim, 1.5f, 0.0f, + Animation_GetLastFrame(&gPoeSistersAppearDisappearAnim.common), ANIMMODE_ONCE, -3.0f); + if (this->type == POSISTER_TYPE_MEG) { + this->megDistToPlayer = 110.0f; + EnPoSisters_MatchPlayerXZ(this, play); + this->color.a = 0; this->actor.draw = EnPoSisters_Draw; } else { this->actor.world.rot.y = this->actor.shape.rot.y; } - this->unk_192 = 15; + this->spinInvisibleTimer = 15; this->actor.speedXZ = 0.0f; Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_STALKIDS_APPEAR); - this->unk_191 &= ~0x1; - this->actionFunc = func_80B1B940; + this->poSisterFlags &= ~POSISTERS_FLAG_CHECK_AC; + this->actionFunc = EnPoSisters_SpinBackToVisible; } -void func_80B1B940(EnPoSisters* this, GlobalContext* globalCtx) { - if (SkelAnime_Update(&this->skelAnime) != 0) { - this->unk_229 = 255; - if (this->unk_18C != 0) { - this->unk_191 |= 1; +void EnPoSisters_SpinBackToVisible(EnPoSisters* this, PlayState* play) { + if (SkelAnime_Update(&this->skelAnime)) { + this->color.a = 255; // fully visible + if (this->type != POSISTER_TYPE_MEG) { + this->poSisterFlags |= POSISTERS_FLAG_CHECK_AC; this->collider.info.bumper.dmgFlags = ~(0x8000000 | 0x200000 | 0x100000 | 0x40000 | 0x1); - if (this->unk_192 != 0) { - this->unk_192--; - } - if (this->unk_192 == 0) { - this->unk_18F = 20; - func_80B1AC40(this); + DECR(this->spinInvisibleTimer); + + if (this->spinInvisibleTimer == 0) { + this->zTargetTimer = 20; + EnPoSisters_SetupAimlessIdleFlying(this); } } else { - func_80B1C030(this); + EnPoSisters_SetupMegSurroundPlayer(this); } } else { - s32 temp_f18 = (this->skelAnime.curFrame * 255.0f) / this->skelAnime.endFrame; + s32 alpha = (this->skelAnime.curFrame * 255.0f) / this->skelAnime.endFrame; - this->unk_229 = CLAMP(temp_f18, 0, 255); - if (this->unk_18C == 0) { - func_80B1A768(this, globalCtx); + this->color.a = CLAMP(alpha, 0, 255); + if (this->type == POSISTER_TYPE_MEG) { + EnPoSisters_MatchPlayerXZ(this, play); } } } -void func_80B1BA3C(EnPoSisters* this) { - this->unk_192 = 0; +void EnPoSisters_SetupDeathStage1(EnPoSisters* this) { + this->deathTimer = 0; this->actor.speedXZ = 0.0f; this->actor.world.pos.y += 42.0f; this->actor.shape.yOffset = -6000.0f; this->actor.flags &= ~ACTOR_FLAG_1; - this->unk_191 = 0; - this->actionFunc = func_80B1BA90; + this->poSisterFlags = POSISTERS_FLAG_CLEAR; + this->actionFunc = EnPoSisters_DeathStage1; } -void func_80B1BA90(EnPoSisters* this, GlobalContext* globalCtx) { +void EnPoSisters_DeathStage1(EnPoSisters* this, PlayState* play) { s32 i; - s32 end = this->unk_190; + s32 end = this->fireCount; - this->unk_192++; + this->deathTimer++; end++; - if (end > ARRAY_COUNT(this->unk_22C)) { - this->unk_190 = 8; + if (end > ARRAY_COUNT(this->firePos)) { + this->fireCount = 8; } else { - this->unk_190 = end; + this->fireCount = end; } - for (end = this->unk_190 - 1; end > 0; end--) { - this->unk_22C[end] = this->unk_22C[end - 1]; + for (end = this->fireCount - 1; end > 0; end--) { + this->firePos[end] = this->firePos[end - 1]; } - this->unk_22C[0].x = - (Math_SinS((this->actor.shape.rot.y + (this->unk_192 * 0x3000)) - 0x4000) * (3000.0f * this->actor.scale.x)) + - this->actor.world.pos.x; - this->unk_22C[0].z = - (Math_CosS((this->actor.shape.rot.y + (this->unk_192 * 0x3000)) - 0x4000) * (3000.0f * this->actor.scale.x)) + - this->actor.world.pos.z; - if (this->unk_192 < 8) { - this->unk_22C[0].y = this->unk_22C[1].y - 9.0f; + this->firePos[0].x = (Math_SinS((this->actor.shape.rot.y + (this->deathTimer * 0x3000)) - 0x4000) * + (3000.0f * this->actor.scale.x)) + + this->actor.world.pos.x; + this->firePos[0].z = (Math_CosS((this->actor.shape.rot.y + (this->deathTimer * 0x3000)) - 0x4000) * + (3000.0f * this->actor.scale.x)) + + this->actor.world.pos.z; + + if (this->deathTimer < 8) { + this->firePos[0].y = this->firePos[1].y - 9.0f; } else { - this->unk_22C[0].y = this->unk_22C[1].y + 2.0f; - if (this->unk_192 >= 16) { + this->firePos[0].y = this->firePos[1].y + 2.0f; + if (this->deathTimer >= 16) { if (Math_StepToF(&this->actor.scale.x, 0.0f, 0.001f)) { - func_80B1BC4C(this, globalCtx); + EnPoSisters_SetupDeathStage2(this, play); } this->actor.scale.z = this->actor.scale.x; this->actor.scale.y = this->actor.scale.x; } } - if (this->unk_192 == 16) { + if (this->deathTimer == 16) { Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_WIZ_DISAPPEAR); } } -void func_80B1BC4C(EnPoSisters* this, GlobalContext* globalCtx) { - this->unk_192 = 0; - this->actor.world.pos.y = this->unk_22C[0].y; - Item_DropCollectibleRandom(globalCtx, &this->actor, &this->actor.world.pos, 0x80); - this->actionFunc = func_80B1BCA0; +/** + * Fading away, the fire has split and circles outward and away. + */ +void EnPoSisters_SetupDeathStage2(EnPoSisters* this, PlayState* play) { + this->deathTimer = 0; + this->actor.world.pos.y = this->firePos[0].y; + Item_DropCollectibleRandom(play, &this->actor, &this->actor.world.pos, (0x8 << 4)); // drop table 8 + this->actionFunc = EnPoSisters_DeathStage2; } -void func_80B1BCA0(EnPoSisters* this, GlobalContext* globalCtx) { - this->unk_192++; - if (this->unk_192 == 32) { +void EnPoSisters_DeathStage2(EnPoSisters* this, PlayState* play) { + this->deathTimer++; + + if (this->deathTimer == 32) { Actor_MarkForDeath(&this->actor); } else { - func_80B1A648(this, this->unk_192, &this->actor.world.pos); + EnPoSisters_UpdateDeathFlameSwirl(this, this->deathTimer, &this->actor.world.pos); } } -void func_80B1BCF0(EnPoSisters* this, GlobalContext* globalCtx) { - Actor* sp4C = - Actor_SpawnAsChild(&globalCtx->actorCtx, &this->actor, globalCtx, ACTOR_EN_PO_SISTERS, this->actor.world.pos.x, - this->actor.world.pos.y, this->actor.world.pos.z, 0, 0, 0, 0x400); - Actor* sp48 = - Actor_SpawnAsChild(&globalCtx->actorCtx, &this->actor, globalCtx, ACTOR_EN_PO_SISTERS, this->actor.world.pos.x, - this->actor.world.pos.y, this->actor.world.pos.z, 0, 0, 0, 0x800); - Actor* sp44 = - Actor_SpawnAsChild(&globalCtx->actorCtx, &this->actor, globalCtx, ACTOR_EN_PO_SISTERS, this->actor.world.pos.x, - this->actor.world.pos.y, this->actor.world.pos.z, 0, 0, 0, 0xC00); +void EnPoSisters_SpawnMegClones(EnPoSisters* this, PlayState* play) { + Actor* clone1 = Actor_SpawnAsChild(&play->actorCtx, &this->actor, play, ACTOR_EN_PO_SISTERS, + this->actor.world.pos.x, this->actor.world.pos.y, this->actor.world.pos.z, 0, 0, + 0, ENPOSISTERS_PARAMS(false, POSISTER_MEG_CLONE1, POSISTER_TYPE_MEG)); + Actor* clone2 = Actor_SpawnAsChild(&play->actorCtx, &this->actor, play, ACTOR_EN_PO_SISTERS, + this->actor.world.pos.x, this->actor.world.pos.y, this->actor.world.pos.z, 0, 0, + 0, ENPOSISTERS_PARAMS(false, POSISTER_MEG_CLONE2, POSISTER_TYPE_MEG)); + Actor* clone3 = Actor_SpawnAsChild(&play->actorCtx, &this->actor, play, ACTOR_EN_PO_SISTERS, + this->actor.world.pos.x, this->actor.world.pos.y, this->actor.world.pos.z, 0, 0, + 0, ENPOSISTERS_PARAMS(false, POSISTER_MEG_CLONE3, POSISTER_TYPE_MEG)); - if ((sp4C == NULL) || (sp48 == NULL) || (sp44 == NULL)) { - if (sp4C != NULL) { - Actor_MarkForDeath(sp4C); + // if we cannot spawn all clones: abort + if ((clone1 == NULL) || (clone2 == NULL) || (clone3 == NULL)) { + if (clone1 != NULL) { + Actor_MarkForDeath(clone1); } - - if (sp48 != NULL) { - Actor_MarkForDeath(sp48); + if (clone2 != NULL) { + Actor_MarkForDeath(clone2); } - - if (sp44 != NULL) { - Actor_MarkForDeath(sp44); + if (clone3 != NULL) { + Actor_MarkForDeath(clone3); } Actor_MarkForDeath(&this->actor); } } -void func_80B1BE4C(EnPoSisters* this, s32 arg1) { - Vec3f sp34; +/** + * Meg and her clones vanish instantly and surround the player, instead of slowing fading while spinning to get + * Invulnerability. + * + * PlayState is an optional parameter, passed only when drawing the fire flash as they vanish. + */ +void EnPoSisters_MegCloneVanish(EnPoSisters* this, PlayState* play) { + Vec3f pos; this->actor.draw = NULL; this->actor.flags &= ~ACTOR_FLAG_1; - this->unk_194 = 100; - this->unk_191 = 0x20; + this->invisibleTimer = 100; // 5 seconds + this->poSisterFlags = POSISTERS_FLAG_UPDATE_FIRES; this->collider.base.colType = COLTYPE_HIT3; this->collider.base.acFlags &= ~AC_HARD; - if (arg1) { - sp34.x = this->actor.world.pos.x; - sp34.y = this->actor.world.pos.y + 45.0f; - sp34.z = this->actor.world.pos.z; - func_800B3030(arg1, &sp34, &gZeroVec3f, &gZeroVec3f, 150, 0, 3); + + if (play != NULL) { + pos.x = this->actor.world.pos.x; + pos.y = this->actor.world.pos.y + 45.0f; + pos.z = this->actor.world.pos.z; + func_800B3030(play, &pos, &gZeroVec3f, &gZeroVec3f, 150, 0, 3); // spawns EffectSsDeadDb } - Lights_PointSetColorAndRadius(&this->lightInfo, 0, 0, 0, 0); - this->actionFunc = func_80B1BF2C; + + Lights_PointSetColorAndRadius(&this->lightInfo, 0, 0, 0, 0); // light OFF + this->actionFunc = EnPoSisters_MegCloneWaitForSpinBack; } -void func_80B1BF2C(EnPoSisters* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); +void EnPoSisters_MegCloneWaitForSpinBack(EnPoSisters* this, PlayState* play) { + Player* player = GET_PLAYER(play); EnPoSisters* parent = (EnPoSisters*)this->actor.parent; - if (this->unk_18D == 0) { - if (this->unk_194 != 0) { - this->unk_194--; - } - - if (this->unk_194 == 0) { + if (this->megCloneId == POSISTER_MEG_REAL) { + DECR(this->invisibleTimer); + if (this->invisibleTimer == 0) { s32 rand = Rand_ZeroFloat(4.0f); this->actor.shape.rot.y = (rand * 0x4000) + this->actor.yawTowardsPlayer; this->actor.world.pos.y = player->actor.world.pos.y + 5.0f; - func_80B1B860(this, globalCtx); + EnPoSisters_SetupSpinBackToVisible(this, play); } - } else if (parent->actionFunc == func_80B1B940) { - this->actor.shape.rot.y = this->actor.parent->shape.rot.y + (this->unk_18D * 0x4000); + + } else if (parent->actionFunc == EnPoSisters_SpinBackToVisible) { + this->actor.shape.rot.y = this->actor.parent->shape.rot.y + (this->megCloneId * 0x4000); this->actor.world.pos.y = player->actor.world.pos.y + 5.0f; - func_80B1B860(this, globalCtx); - } else if (parent->actionFunc == func_80B1BA90) { + EnPoSisters_SetupSpinBackToVisible(this, play); + + } else if (parent->actionFunc == EnPoSisters_DeathStage1) { Actor_MarkForDeath(&this->actor); } } -void func_80B1C030(EnPoSisters* this) { - Animation_MorphToLoop(&this->skelAnime, &object_po_sisters_Anim_000D40, -3.0f); - this->unk_229 = 255; - this->unk_192 = 300; - this->unk_194 = 3; - this->unk_191 |= (0x8 | 0x1); +void EnPoSisters_SetupMegSurroundPlayer(EnPoSisters* this) { + Animation_MorphToLoop(&this->skelAnime, &gPoeSistersFloatAnim, -3.0f); + this->color.a = 255; + this->megSurroundTimer = 300; // 15 seconds + this->megClonesRemaining = 3; + this->poSisterFlags |= (POSISTERS_FLAG_MATCH_PLAYER_HEIGHT | POSISTERS_FLAG_CHECK_AC); this->actor.flags |= ACTOR_FLAG_1; - this->actionFunc = func_80B1C0A4; + this->actionFunc = EnPoSisters_MegSurroundPlayer; } -void func_80B1C0A4(EnPoSisters* this, GlobalContext* globalCtx) { +void EnPoSisters_MegSurroundPlayer(EnPoSisters* this, PlayState* play) { EnPoSisters* parent; - if (this->unk_192 != 0) { - this->unk_192--; - } + DECR(this->megSurroundTimer); - if (this->unk_194 > 0) { - if (this->unk_192 >= 16) { - SkelAnime_Update(&this->skelAnime); - if (this->unk_18D == 0) { - if (ABS_ALT(16 - this->unk_18E) < 14) { - this->actor.shape.rot.y += - (s16)((0x580 - (this->unk_194 * 0x180)) * fabsf(Math_SinS(this->unk_18E * 0x800))); - } - - if ((this->unk_192 >= 284) || (this->unk_192 < 31)) { - this->unk_191 |= 0x40; - } else { - this->unk_191 &= ~0x40; - } - } else { - this->actor.shape.rot.y = this->actor.parent->shape.rot.y + (this->unk_18D * 0x4000); + if (this->megClonesRemaining > 0 && this->megSurroundTimer >= 16) { + SkelAnime_Update(&this->skelAnime); + if (this->megCloneId == POSISTER_MEG_REAL) { + if (ABS_ALT(16 - this->floatingBobbingTimer) < 14) { + // every x frames rotate around player, the fewer meg clones remaining the faster they spin + this->actor.shape.rot.y += (s16)((0x580 - (this->megClonesRemaining * 0x180)) * + fabsf(Math_SinS(this->floatingBobbingTimer * 0x800))); } + + // twirl the real meg backwards for a bit for visual tell to player + if ((this->megSurroundTimer >= 284) || (this->megSurroundTimer <= 30)) { + this->poSisterFlags |= POSISTERS_FLAG_REAL_MEG_ROTATION; + } else { + this->poSisterFlags &= ~POSISTERS_FLAG_REAL_MEG_ROTATION; + } + } else { + this->actor.shape.rot.y = this->actor.parent->shape.rot.y + (this->megCloneId * 0x4000); } } - if (this->unk_18D == 0) { - if ((this->unk_192 >= 284) || ((this->unk_192 < 31) && (this->unk_192 >= 16))) { - this->unk_191 |= 0x40; + if (this->megCloneId == POSISTER_MEG_REAL) { + if ((this->megSurroundTimer >= 284) || ((this->megSurroundTimer <= 30) && (this->megSurroundTimer >= 16))) { + this->poSisterFlags |= POSISTERS_FLAG_REAL_MEG_ROTATION; } else { - this->unk_191 &= ~0x40; + this->poSisterFlags &= ~POSISTERS_FLAG_REAL_MEG_ROTATION; } } - if (this->unk_192 == 0) { - if (this->unk_18D == 0) { - func_80B1B0E0(this); + if (this->megSurroundTimer == 0) { + if (this->megCloneId == POSISTER_MEG_REAL) { + EnPoSisters_SetupSpinAttack(this); } else { - func_80B1BE4C(this, globalCtx); + EnPoSisters_MegCloneVanish(this, play); } - } else if (this->unk_18D != 0) { + } else if (this->megCloneId != POSISTER_MEG_REAL) { parent = (EnPoSisters*)this->actor.parent; - if (parent->actionFunc == func_80B1B444) { - func_80B1B3A8(this); + if (parent->actionFunc == EnPoSisters_DamageFlinch) { + // flinch clones if you hit the real meg + EnPoSisters_SetupDamageFlinch(this); } - } else if (this->unk_194 == 0) { - this->unk_194 = -15; - } else if (this->unk_194 < 0) { - this->unk_194++; - if (this->unk_194 == 0) { - func_80B1B0E0(this); + } else if (this->megClonesRemaining == 0) { + // all meg clones have been killed, meg waits 15 frames then spin attacks + // timer is negative because megClonesRemaining and megAttackTimer are the same union'd variable + this->megAttackTimer = -15; + } else if (this->megAttackTimer < 0) { + this->megAttackTimer++; + if (this->megAttackTimer == 0) { + EnPoSisters_SetupSpinAttack(this); } } - func_80B1A768(this, globalCtx); + + EnPoSisters_MatchPlayerXZ(this, play); } -void func_80B1C2E8(EnPoSisters* this) { - Animation_PlayOnce(&this->skelAnime, &object_po_sisters_Anim_00119C); +/** + * First ActionFunc for all Combat variants (including Meg) + */ +void EnPoSisters_SetupSpawnPo(EnPoSisters* this) { + Animation_PlayOnce(&this->skelAnime, &gPoeSistersAppearDisappearAnim); Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_STALKIDS_APPEAR); - this->unk_229 = 0; - this->unk_191 = 0x20; - this->actionFunc = func_80B1C340; + this->color.a = 0; + this->poSisterFlags = POSISTERS_FLAG_UPDATE_FIRES; + this->actionFunc = EnPoSisters_PoeSpawn; } -void func_80B1C340(EnPoSisters* this, GlobalContext* globalCtx) { +void EnPoSisters_PoeSpawn(EnPoSisters* this, PlayState* play) { if (SkelAnime_Update(&this->skelAnime)) { - this->unk_229 = 255; + this->color.a = 255; this->actor.flags |= ACTOR_FLAG_1; - this->unk_191 |= (0x10 | 0x8); - if (this->unk_18C == 0) { - func_80B1BE4C(this, globalCtx); + this->poSisterFlags |= (POSISTERS_FLAG_UPDATE_BGCHECK_INFO | POSISTERS_FLAG_MATCH_PLAYER_HEIGHT); + if (this->type == POSISTER_TYPE_MEG) { + EnPoSisters_MegCloneVanish(this, play); } else { - func_80B1AC40(this); + EnPoSisters_SetupAimlessIdleFlying(this); } } else { - f32 temp = this->skelAnime.curFrame / this->skelAnime.endFrame; - s32 temp_f16 = 255.0f * temp; + f32 alphaPercent = this->skelAnime.curFrame / this->skelAnime.endFrame; + s32 alpha = 255.0f * alphaPercent; - this->unk_229 = CLAMP(temp_f16, 0, 255); + this->color.a = CLAMP(alpha, 0, 255); } } -void func_80B1C408(EnPoSisters* this, GlobalContext* globalCtx) { - Vec3f sp3C; +void EnPoSisters_CheckCollision(EnPoSisters* this, PlayState* play) { + Vec3f pos; if (this->collider.base.acFlags & AC_HIT) { this->collider.base.acFlags &= ~AC_HIT; Actor_SetDropFlag(&this->actor, &this->collider.info); - if (this->unk_18D != 0) { - ((EnPoSisters*)this->actor.parent)->unk_194--; + if (this->megCloneId != POSISTER_MEG_REAL) { + ((EnPoSisters*)this->actor.parent)->megClonesRemaining--; Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_PO_LAUGH2); - func_80B1BE4C(this, globalCtx); + EnPoSisters_MegCloneVanish(this, play); if (Rand_ZeroOne() < 0.2f) { - sp3C.x = this->actor.world.pos.x; - sp3C.y = this->actor.world.pos.y; - sp3C.z = this->actor.world.pos.z; - Item_DropCollectible(globalCtx, &sp3C, ITEM00_ARROWS_10); + pos.x = this->actor.world.pos.x; + pos.y = this->actor.world.pos.y; + pos.z = this->actor.world.pos.z; + Item_DropCollectible(play, &pos, ITEM00_ARROWS_10); } } else if (this->collider.base.colType != 9) { - if (this->actor.colChkInfo.damageEffect == 0xF) { + if (this->actor.colChkInfo.damageEffect == POSISTERS_DAMAGEEFFECT_DEKUNUT) { this->actor.world.rot.y = this->actor.shape.rot.y; - this->unk_191 |= 2; - func_80B1B860(this, globalCtx); - } else if ((this->unk_18C == 0) && (this->actor.colChkInfo.damageEffect == 0xE) && - (this->actionFunc == func_80B1C0A4)) { - if (this->unk_194 == 0) { - this->unk_194 = -45; + this->poSisterFlags |= POSISTERS_FLAG_UPDATE_SHAPE_ROT; + EnPoSisters_SetupSpinBackToVisible(this, play); + } else if ((this->type == POSISTER_TYPE_MEG) && + (this->actor.colChkInfo.damageEffect == POSISTERS_DAMAGEEFFECT_SPINATTACK) && + (this->actionFunc == EnPoSisters_MegSurroundPlayer)) { + if (this->megClonesRemaining == 0) { + // all meg clones have been killed, meg waits 45 frames then spin attacks + // timer is negative because megClonesRemaining and megAttackTimer are the same union'd variable + this->megAttackTimer = -45; } } else { if (Actor_ApplyDamage(&this->actor)) { Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_PO_DAMAGE); } else { - Enemy_StartFinishingBlow(globalCtx, &this->actor); + Enemy_StartFinishingBlow(play, &this->actor); Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_PO_SISTER_DEAD); } - if (this->actor.colChkInfo.damageEffect == 4) { + if (this->actor.colChkInfo.damageEffect == POSISTERS_DAMAGEEFFECT_LIGHTARROWS) { 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); + Actor_Spawn(&play->actorCtx, play, ACTOR_EN_CLEAR_TAG, this->collider.info.bumper.hitPos.x, + this->collider.info.bumper.hitPos.y, this->collider.info.bumper.hitPos.z, 0, 0, 0, + CLEAR_TAG_LARGE_LIGHT_RAYS); } - func_80B1B3A8(this); + EnPoSisters_SetupDamageFlinch(this); } } } } -void EnPoSisters_Update(Actor* thisx, GlobalContext* globalCtx) { +void EnPoSisters_Update(Actor* thisx, PlayState* play) { s32 pad; EnPoSisters* this = THIS; - f32 temp_f2; + f32 alpha; Vec3f checkPos; s32 bgId; if (this->collider.base.atFlags & AT_HIT) { this->collider.base.atFlags &= ~AT_HIT; - func_80B1B280(this); + EnPoSisters_SetupAttackConnect(this); } - func_80B1C408(this, globalCtx); - if (this->unk_191 & 0x4) { - func_80B1A9B0(this, globalCtx); + EnPoSisters_CheckCollision(this, play); + if (this->poSisterFlags & POSISTERS_FLAG_CHECK_Z_TARGET) { + EnPoSisters_CheckZTarget(this, play); } - this->actionFunc(this, globalCtx); + this->actionFunc(this, play); - if (this->unk_191 & 0x8) { - func_80B1A894(this, globalCtx); + if (this->poSisterFlags & POSISTERS_FLAG_MATCH_PLAYER_HEIGHT) { + EnPoSisters_MatchPlayerY(this, play); } Actor_MoveWithGravity(&this->actor); - if (this->unk_191 & 0x10) { - Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 20.0f, 20.0f, 0.0f, 5); + if (this->poSisterFlags & POSISTERS_FLAG_UPDATE_BGCHECK_INFO) { + Actor_UpdateBgCheckInfo(play, &this->actor, 20.0f, 20.0f, 0.0f, 5); } else { checkPos.x = this->actor.world.pos.x; checkPos.y = this->actor.world.pos.y + 10.0f; checkPos.z = this->actor.world.pos.z; this->actor.floorHeight = - BgCheck_EntityRaycastFloor5(&globalCtx->colCtx, &this->actor.floorPoly, &bgId, &this->actor, &checkPos); + BgCheck_EntityRaycastFloor5(&play->colCtx, &this->actor.floorPoly, &bgId, &this->actor, &checkPos); } - this->actor.shape.shadowAlpha = this->unk_229; + this->actor.shape.shadowAlpha = this->color.a; Actor_SetFocus(&this->actor, 40.0f); 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->drawDmgEffAlpha = temp_f2; + if (this->color.a != 255) { + alpha = this->color.a * (1.0f / 255); + if (alpha < this->color.a) { + this->drawDmgEffAlpha = alpha; } } @@ -935,83 +997,87 @@ void EnPoSisters_Update(Actor* thisx, GlobalContext* globalCtx) { this->drawDmgEffScale = CLAMP_MAX(this->drawDmgEffScale, 0.5f); } - if (this->unk_191 & (0x10 | 0x8 | 0x4 | 0x2 | 0x1)) { + if (this->poSisterFlags & + (POSISTERS_FLAG_UPDATE_BGCHECK_INFO | POSISTERS_FLAG_MATCH_PLAYER_HEIGHT | POSISTERS_FLAG_CHECK_Z_TARGET | + POSISTERS_FLAG_UPDATE_SHAPE_ROT | POSISTERS_FLAG_CHECK_AC)) { Collider_UpdateCylinder(&this->actor, &this->collider); - if ((this->actionFunc == func_80B1B168) || (this->actionFunc == func_80B1B020)) { - this->unk_190++; - this->unk_190 = CLAMP_MAX(this->unk_190, ARRAY_COUNT(this->unk_22C)); - } else if (this->actionFunc != func_80B1BA90) { - this->unk_190 = CLAMP_MIN(this->unk_190 - 1, 1); + if ((this->actionFunc == EnPoSisters_SpinAttack) || (this->actionFunc == EnPoSisters_SpinUp)) { + this->fireCount++; + this->fireCount = CLAMP_MAX(this->fireCount, ARRAY_COUNT(this->firePos)); + } else if (this->actionFunc != EnPoSisters_DeathStage1) { + this->fireCount = CLAMP_MIN(this->fireCount - 1, 1); } - if (this->actionFunc == func_80B1B168) { + if (this->actionFunc == EnPoSisters_SpinAttack) { this->actor.flags |= ACTOR_FLAG_1000000; - CollisionCheck_SetAT(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + CollisionCheck_SetAT(play, &play->colChkCtx, &this->collider.base); } - if (this->unk_191 & 0x1) { - CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + if (this->poSisterFlags & POSISTERS_FLAG_CHECK_AC) { + CollisionCheck_SetAC(play, &play->colChkCtx, &this->collider.base); } - if (this->actionFunc != func_80B1BF2C) { - CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + if (this->actionFunc != EnPoSisters_MegCloneWaitForSpinBack) { + CollisionCheck_SetOC(play, &play->colChkCtx, &this->collider.base); } - if (this->actionFunc == func_80B1B628) { + if (this->actionFunc == EnPoSisters_Flee) { this->actor.shape.rot.y = BINANG_ROT180(this->actor.world.rot.y); - } else if (this->unk_191 & 0x2) { + } else if (this->poSisterFlags & POSISTERS_FLAG_UPDATE_SHAPE_ROT) { this->actor.shape.rot.y = this->actor.world.rot.y; } } } -void func_80B1C974(EnPoSisters* this) { - if (this->skelAnime.animation == &object_po_sisters_Anim_000114) { - this->unk_226 = CLAMP_MAX(this->unk_226 + 5, 255); - this->unk_227 = CLAMP_MIN(this->unk_227 - 5, 50); - this->unk_228 = CLAMP_MIN(this->unk_228 - 5, 0); - } else if (this->skelAnime.animation == &object_po_sisters_Anim_000A54) { - this->unk_226 = CLAMP_MAX(this->unk_226 + 5, 80); - this->unk_227 = CLAMP_MAX(this->unk_227 + 5, 255); - this->unk_228 = CLAMP_MAX(this->unk_228 + 5, 225); - } else if (this->skelAnime.animation == &object_po_sisters_Anim_0008C0) { +void EnPoSisters_UpdateColors(EnPoSisters* this) { + if (this->skelAnime.animation == &gPoSistersAttackAnim) { + this->color.r = CLAMP_MAX(this->color.r + 5, 255); + this->color.g = CLAMP_MIN(this->color.g - 5, 50); + this->color.b = CLAMP_MIN(this->color.b - 5, 0); + } else if (this->skelAnime.animation == &gPoSistersFleeAnim) { + this->color.r = CLAMP_MAX(this->color.r + 5, 80); + this->color.g = CLAMP_MAX(this->color.g + 5, 255); + this->color.b = CLAMP_MAX(this->color.b + 5, 225); + } else if (this->skelAnime.animation == &gPoeSistersDamagedAnim) { + // flash every other frame after taking damage if (this->actor.colorFilterTimer & 0x2) { - this->unk_226 = 0; - this->unk_227 = 0; - this->unk_228 = 0; + this->color.r = 0; + this->color.g = 0; + this->color.b = 0; } else { - this->unk_226 = 80; - this->unk_227 = 255; - this->unk_228 = 225; + this->color.r = 80; + this->color.g = 255; + this->color.b = 225; } } else { - this->unk_226 = CLAMP_MAX(this->unk_226 + 5, 255); - this->unk_227 = CLAMP_MAX(this->unk_227 + 5, 255); + this->color.r = CLAMP_MAX(this->color.r + 5, 255); + this->color.g = CLAMP_MAX(this->color.g + 5, 255); - if (this->unk_228 > 210) { - if (this->unk_228 && this->unk_228 && this->unk_228) {} - this->unk_228 = CLAMP_MIN(this->unk_228 - 5, 210); + if (this->color.b > 210) { + //! FAKE: + if (this->color.b && this->color.b && this->color.b) {} + this->color.b = CLAMP_MIN(this->color.b - 5, 210); } else { - this->unk_228 = CLAMP_MAX(this->unk_228 + 5, 210); + this->color.b = CLAMP_MAX(this->color.b + 5, 210); } } } -s32 EnPoSisters_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, - Actor* thisx, Gfx** gfx) { - static Gfx* D_80B1DACC[] = { - object_po_sisters_DL_001DE0, - object_po_sisters_DL_002F88, - object_po_sisters_DL_003628, - object_po_sisters_DL_003DC8, +s32 EnPoSisters_OverrideLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, Actor* thisx, + Gfx** gfx) { + static Gfx* gPoSisterBodyDisplayLists[] = { + gPoSistersMegBodyDL, + gPoSistersJoelleBodyDL, + gPoSistersBethBodyDL, + gPoSistersAmyBodyDL, }; - static Gfx* D_80B1DADC[] = { - object_po_sisters_DL_001CB0, - object_po_sisters_DL_002EB8, - object_po_sisters_DL_003880, - object_po_sisters_DL_004020, + static Gfx* gPoSisterFaceDisplayLists[] = { + gPoSistersMegFaceDL, + gPoSistersJoelleFaceDL, + gPoSistersBethFaceDL, + gPoSistersAmyFaceDL, }; - static Color_RGBA8 D_80B1DAEC[] = { + static Color_RGBA8 gPoSisterColors[] = { { 80, 0, 100, 0 }, { 80, 15, 0, 0 }, { 0, 70, 50, 0 }, @@ -1019,169 +1085,179 @@ s32 EnPoSisters_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** }; EnPoSisters* this = THIS; - if ((limbIndex == 1) && (this->unk_191 & 0x40)) { - if (this->unk_192 >= 284) { - rot->x += (this->unk_192 - 284) * 0x1000; + if (limbIndex == POSISTERS_LIMB_ROOT && (this->poSisterFlags & POSISTERS_FLAG_REAL_MEG_ROTATION)) { + if (this->megSurroundTimer >= 284) { + rot->x += (this->megSurroundTimer - 284) * 0x1000; } else { - rot->x += (this->unk_192 - 15) * 0x1000; + rot->x += (this->megSurroundTimer - 15) * 0x1000; } } - if ((this->unk_229 == 0) || (limbIndex == 8) || ((this->actionFunc == func_80B1BA90) && (this->unk_192 >= 8))) { + if ((this->color.a == 0) || (limbIndex == POSISTERS_LIMB_TORCH) || + ((this->actionFunc == EnPoSisters_DeathStage1) && (this->deathTimer >= 8))) { *dList = NULL; - } else if (limbIndex == 9) { - *dList = D_80B1DACC[this->unk_18C]; - } else if (limbIndex == 10) { - *dList = D_80B1DADC[this->unk_18C]; + } else if (limbIndex == POSISTERS_LIMB_MAIN_BODY) { + *dList = gPoSisterBodyDisplayLists[this->type]; + } else if (limbIndex == POSISTERS_LIMB_FACE) { + *dList = gPoSisterFaceDisplayLists[this->type]; gDPPipeSync((*gfx)++); - gDPSetEnvColor((*gfx)++, this->unk_226, this->unk_227, this->unk_228, this->unk_229); - } else if (limbIndex == 11) { - Color_RGBA8* colour = &D_80B1DAEC[this->unk_18C]; + gDPSetEnvColor((*gfx)++, this->color.r, this->color.g, this->color.b, this->color.a); + } else if (limbIndex == POSISTERS_LIMB_LOWER_BODY) { + Color_RGBA8* color = &gPoSisterColors[this->type]; gDPPipeSync((*gfx)++); - gDPSetEnvColor((*gfx)++, colour->r, colour->g, colour->b, this->unk_229); + gDPSetEnvColor((*gfx)++, color->r, color->g, color->b, this->color.a); } return false; } -void EnPoSisters_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx, - Gfx** gfx) { +#define POSISTER_LIMBPOS_INVALID -1 + +void EnPoSisters_PostLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx, Gfx** gfx) { static Vec3f D_80B1DAFC = { 1000.0f, -1700.0f, 0.0f }; static s8 D_80B1DB08[] = { - -1, -1, 0, 1, 2, -1, 3, -1, -1, -1, -1, -1, + POSISTER_LIMBPOS_INVALID, + POSISTER_LIMBPOS_INVALID, + 0, + 1, + 2, + POSISTER_LIMBPOS_INVALID, + 3, + POSISTER_LIMBPOS_INVALID, + POSISTER_LIMBPOS_INVALID, + POSISTER_LIMBPOS_INVALID, + POSISTER_LIMBPOS_INVALID, + POSISTER_LIMBPOS_INVALID, }; EnPoSisters* this = THIS; s32 end; - f32 temp_f2; + f32 brightness; - if (D_80B1DB08[limbIndex] != -1) { - Matrix_GetStateTranslation(&this->limbPos[D_80B1DB08[limbIndex]]); - } else if (limbIndex == 9) { - Matrix_GetStateTranslationAndScaledY(-2500.0f, &this->limbPos[4]); - Matrix_GetStateTranslationAndScaledY(3000.0f, &this->limbPos[5]); - } else if (limbIndex == 10) { - Matrix_GetStateTranslationAndScaledY(-4000.0f, &this->limbPos[6]); - } else if (limbIndex == 11) { - Matrix_GetStateTranslationAndScaledX(3000.0f, &this->limbPos[7]); + if (D_80B1DB08[limbIndex] != POSISTER_LIMBPOS_INVALID) { + Matrix_MultZero(&this->limbPos[D_80B1DB08[limbIndex]]); + } else if (limbIndex == POSISTERS_LIMB_MAIN_BODY) { + Matrix_MultVecY(-2500.0f, &this->limbPos[4]); + Matrix_MultVecY(3000.0f, &this->limbPos[5]); + } else if (limbIndex == POSISTERS_LIMB_FACE) { + Matrix_MultVecY(-4000.0f, &this->limbPos[6]); + } else if (limbIndex == POSISTERS_LIMB_LOWER_BODY) { + Matrix_MultVecX(3000.0f, &this->limbPos[7]); } - if ((this->actionFunc == func_80B1BA90) && (this->unk_192 >= 8) && (limbIndex == 9)) { - gSPMatrix((*gfx)++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - gSPDisplayList((*gfx)++, object_po_sisters_DL_0046E0); + if (this->actionFunc == EnPoSisters_DeathStage1 && this->deathTimer >= 8 && limbIndex == POSISTERS_LIMB_MAIN_BODY) { + gSPMatrix((*gfx)++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList((*gfx)++, gPoSistersBurnBodyDL); } - if (limbIndex == 8) { - if (this->unk_191 & 0x20) { - for (end = this->unk_190 - 1; end > 0; end--) { - this->unk_22C[end] = this->unk_22C[end - 1]; + if (limbIndex == POSISTERS_LIMB_TORCH) { + if (this->poSisterFlags & POSISTERS_FLAG_UPDATE_FIRES) { + for (end = this->fireCount - 1; end > 0; end--) { + this->firePos[end] = this->firePos[end - 1]; } - Matrix_MultiplyVector3fByState(&D_80B1DAFC, this->unk_22C); + Matrix_MultVec3f(&D_80B1DAFC, this->firePos); } - if (this->unk_190 > 0) { - Color_RGBA8* sp38 = &D_80B1DA30[this->unk_18C]; + if (this->fireCount > 0) { + Color_RGBA8* flameColor = &sPoSisterFlameColors[this->type]; - temp_f2 = Rand_ZeroFloat(0.3f) + 0.7f; + brightness = Rand_ZeroFloat(0.3f) + 0.7f; // flickering torch light level - if (this->actionFunc == func_80B1BCA0) { - Lights_PointNoGlowSetInfo(&this->lightInfo, this->unk_22C[0].x, this->unk_22C[0].y + 15.0f, - this->unk_22C[0].z, sp38->r * temp_f2, sp38->g * temp_f2, sp38->b * temp_f2, - 200); + if (this->actionFunc == EnPoSisters_DeathStage2) { + Lights_PointNoGlowSetInfo(&this->lightInfo, this->firePos[0].x, this->firePos[0].y + 15.0f, + this->firePos[0].z, flameColor->r * brightness, flameColor->g * brightness, + flameColor->b * brightness, 200); } else { - Lights_PointGlowSetInfo(&this->lightInfo, this->unk_22C[0].x, this->unk_22C[0].y + 15.0f, - this->unk_22C[0].z, sp38->r * temp_f2, sp38->g * temp_f2, sp38->b * temp_f2, - 200); + Lights_PointGlowSetInfo(&this->lightInfo, this->firePos[0].x, this->firePos[0].y + 15.0f, + this->firePos[0].z, flameColor->r * brightness, flameColor->g * brightness, + flameColor->b * brightness, 200); } } else { Lights_PointSetColorAndRadius(&this->lightInfo, 0, 0, 0, 0); } - if (!(this->unk_191 & 0x80)) { - Matrix_CopyCurrentState(&this->unk_358); + if (!(this->poSisterFlags & POSISTERS_FLAG_DRAW_TORCH)) { + Matrix_Get(&this->mtxf); } } } -void EnPoSisters_Draw(Actor* thisx, GlobalContext* globalCtx) { +void EnPoSisters_Draw(Actor* thisx, PlayState* play) { EnPoSisters* this = THIS; - Color_RGBA8* temp_s1 = &D_80B1DA40[this->unk_18C]; - Color_RGBA8* temp_s7 = &D_80B1DA30[this->unk_18C]; + Color_RGBA8* sisterEnvColor = &sPoSisterEnvColors[this->type]; + Color_RGBA8* flameColor = &sPoSisterFlameColors[this->type]; s32 pad; s32 i; - s32 phi_s5; - f32 phi_f20; + u8 alpha; + f32 scale; s32 pad2; - OPEN_DISPS(globalCtx->state.gfxCtx); + OPEN_DISPS(play->state.gfxCtx); - func_80B1C974(this); - func_8012C28C(globalCtx->state.gfxCtx); - func_8012C2DC(globalCtx->state.gfxCtx); + EnPoSisters_UpdateColors(this); + func_8012C28C(play->state.gfxCtx); + func_8012C2DC(play->state.gfxCtx); - if ((this->unk_229 == 255) || (this->unk_229 == 0)) { - gDPSetEnvColor(POLY_OPA_DISP++, this->unk_226, this->unk_227, this->unk_228, this->unk_229); - gSPSegment(POLY_OPA_DISP++, 0x09, D_801AEFA0); + if ((this->color.a == 255) || (this->color.a == 0)) { + gDPSetEnvColor(POLY_OPA_DISP++, this->color.r, this->color.g, this->color.b, this->color.a); + gSPSegment(POLY_OPA_DISP++, 0x09, D_801AEFA0); // empty POLY_OPA_DISP = - SkelAnime_Draw(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, - EnPoSisters_OverrideLimbDraw, EnPoSisters_PostLimbDraw, &this->actor, POLY_OPA_DISP); + SkelAnime_Draw(play, this->skelAnime.skeleton, this->skelAnime.jointTable, EnPoSisters_OverrideLimbDraw, + EnPoSisters_PostLimbDraw, &this->actor, POLY_OPA_DISP); } else { - gDPSetEnvColor(POLY_XLU_DISP++, 255, 255, 255, this->unk_229); - gSPSegment(POLY_XLU_DISP++, 0x09, D_801AEF88); + gDPSetEnvColor(POLY_XLU_DISP++, 255, 255, 255, this->color.a); + gSPSegment(POLY_XLU_DISP++, 0x09, D_801AEF88); // xlu only DL POLY_XLU_DISP = - SkelAnime_Draw(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, - EnPoSisters_OverrideLimbDraw, EnPoSisters_PostLimbDraw, &this->actor, POLY_XLU_DISP); + SkelAnime_Draw(play, this->skelAnime.skeleton, this->skelAnime.jointTable, EnPoSisters_OverrideLimbDraw, + EnPoSisters_PostLimbDraw, &this->actor, POLY_XLU_DISP); } - if (!(this->unk_191 & 0x80)) { - Matrix_SetCurrentState(&this->unk_358); + if (!(this->poSisterFlags & POSISTERS_FLAG_DRAW_TORCH)) { + Matrix_Put(&this->mtxf); - 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); + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_OPA_DISP++, gPoSistersDrawTorchDL); } - gSPSegment(POLY_XLU_DISP++, 0x08, - Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, 0, 0, 32, 64, 1, 0, (globalCtx->gameplayFrames * -20) % 512, - 32, 128)); - gDPSetEnvColor(POLY_XLU_DISP++, temp_s1->r, temp_s1->g, temp_s1->b, temp_s1->a); + gSPSegment( + POLY_XLU_DISP++, 0x08, + Gfx_TwoTexScroll(play->state.gfxCtx, 0, 0, 0, 32, 64, 1, 0, (play->gameplayFrames * -20) % 512, 32, 128)); + gDPSetEnvColor(POLY_XLU_DISP++, sisterEnvColor->r, sisterEnvColor->g, sisterEnvColor->b, sisterEnvColor->a); - if (this->actionFunc == func_80B1BCA0) { - phi_s5 = (((-this->unk_192 * 255) + 0x1FE0) / 32) & 0xFF; - phi_f20 = 0.0056000003f; + if (this->actionFunc == EnPoSisters_DeathStage2) { + alpha = ((-this->deathTimer * 255) + 0x1FE0) / 32; + scale = (7 / 1.2500 * 0.001f); } else { - phi_s5 = 0; - phi_f20 = this->actor.scale.x * 0.5f; + alpha = 0; + scale = this->actor.scale.x * 0.5f; } - for (i = 0; i < this->unk_190; i++) { - if (this->actionFunc != func_80B1BCA0) { - phi_s5 = ((-i * 31) + 248) & 0xFF; + for (i = 0; i < this->fireCount; i++) { + if (this->actionFunc != EnPoSisters_DeathStage2) { + alpha = (-i * 31) + 248; } gDPPipeSync(POLY_XLU_DISP++); - gDPSetPrimColor(POLY_XLU_DISP++, 0x80, 0x80, temp_s7->r, temp_s7->g, temp_s7->b, phi_s5); + gDPSetPrimColor(POLY_XLU_DISP++, 0x80, 0x80, flameColor->r, flameColor->g, flameColor->b, alpha); - Matrix_InsertTranslation(this->unk_22C[i].x, this->unk_22C[i].y, this->unk_22C[i].z, MTXMODE_NEW); - Matrix_InsertRotation(0, BINANG_ROT180(Camera_GetCamDirYaw(GET_ACTIVE_CAM(globalCtx))), 0, MTXMODE_APPLY); + Matrix_Translate(this->firePos[i].x, this->firePos[i].y, this->firePos[i].z, MTXMODE_NEW); + Matrix_RotateZYX(0, BINANG_ROT180(Camera_GetCamDirYaw(GET_ACTIVE_CAM(play))), 0, MTXMODE_APPLY); - if (this->actionFunc == func_80B1BA90) { - f32 phi_f0; - - phi_f20 = ((this->unk_192 - i) * 0.025f) + 0.5f; - phi_f0 = CLAMP(phi_f20, 0.5f, 0.8f); - phi_f20 = phi_f0 * 0.007f; + if (this->actionFunc == EnPoSisters_DeathStage1) { + scale = ((this->deathTimer - i) * 0.025f) + 0.5f; + scale = CLAMP(scale, 0.5f, 0.8f) * 0.007f; } - Matrix_Scale(phi_f20, phi_f20, phi_f20, MTXMODE_APPLY); + Matrix_Scale(scale, scale, scale, MTXMODE_APPLY); - gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - gSPDisplayList(POLY_XLU_DISP++, gGameplayKeepDrawFlameDL); + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_XLU_DISP++, gEffFire1DL); } - Actor_DrawDamageEffects(globalCtx, &this->actor, this->limbPos, ARRAY_COUNT(this->limbPos), - this->actor.scale.x * 142.857131958f * this->drawDmgEffScale, 0.0f, this->drawDmgEffAlpha, + Actor_DrawDamageEffects(play, &this->actor, this->limbPos, ARRAY_COUNT(this->limbPos), + this->actor.scale.x * (1.0f / 0.007f) * this->drawDmgEffScale, 0.0f, this->drawDmgEffAlpha, ACTOR_DRAW_DMGEFF_LIGHT_ORBS); - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->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 3350f8f03..368ad9da1 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 @@ -2,42 +2,70 @@ #define Z_EN_PO_SISTERS_H #include "global.h" +#include "objects/object_po_sisters/object_po_sisters.h" struct EnPoSisters; -typedef void (*EnPoSistersActionFunc)(struct EnPoSisters*, GlobalContext*); +typedef void (*EnPoSistersActionFunc)(struct EnPoSisters*, PlayState*); -#define ENPOSISTERS_GET_300(thisx) (((thisx)->params >> 8) & 3) -#define ENPOSISTERS_GET_C00(thisx) (((thisx)->params >> 0xA) & 3) -#define ENPOSISTERS_GET_1000(thisx) ((thisx)->params & 0x1000) +#define ENPOSISTERS_GET_OBSERVER_FLAG(thisx) ((thisx)->params & 0x1000) +#define ENPOSISTERS_GET_MEG_CLONE_ID(thisx) (((thisx)->params >> 0xA) & 3) +#define ENPOSISTERS_GET_TYPE(thisx) (((thisx)->params >> 8) & 3) + +#define ENPOSISTERS_PARAMS(observerFlag, megClone, type) (((observerFlag) << 0xC) | ((megClone & 3) << 0xA) | ((type & 3) << 8)) + +typedef enum { + /* 0 */ POSISTER_TYPE_MEG, // purple + /* 1 */ POSISTER_TYPE_JO, // red + /* 2 */ POSISTER_TYPE_BETH, // blue + /* 3 */ POSISTER_TYPE_AMY, // green +} EnPoSisterType; + +typedef enum { + /* 0 */ POSISTER_MEG_REAL, + /* 1 */ POSISTER_MEG_CLONE1, + /* 2 */ POSISTER_MEG_CLONE2, + /* 3 */ POSISTER_MEG_CLONE3, +} EnPoSisterMegCloneID; typedef struct EnPoSisters { - /* 0x0000 */ Actor actor; - /* 0x0144 */ SkelAnime skelAnime; - /* 0x0188 */ EnPoSistersActionFunc actionFunc; - /* 0x018C */ u8 unk_18C; - /* 0x018D */ u8 unk_18D; - /* 0x018E */ u8 unk_18E; - /* 0x018F */ u8 unk_18F; - /* 0x0190 */ u8 unk_190; - /* 0x0191 */ u8 unk_191; - /* 0x0192 */ s16 unk_192; - /* 0x0194 */ s16 unk_194; - /* 0x0196 */ Vec3s jointTable[12]; - /* 0x01DE */ Vec3s morphTable[12]; - /* 0x0226 */ u8 unk_226; - /* 0x0227 */ u8 unk_227; - /* 0x0228 */ u8 unk_228; - /* 0x0229 */ u8 unk_229; - /* 0x022C */ Vec3f unk_22C[8]; - /* 0x028C */ Vec3f limbPos[8]; - /* 0x02EC */ f32 unk_2EC; - /* 0x02F0 */ f32 drawDmgEffAlpha; - /* 0x02F4 */ f32 drawDmgEffScale; - /* 0x02F8 */ LightNode* lightNode; - /* 0x02FC */ LightInfo lightInfo; - /* 0x030C */ ColliderCylinder collider; - /* 0x0358 */ MtxF unk_358; + /* 0x000 */ Actor actor; + /* 0x144 */ SkelAnime skelAnime; + /* 0x188 */ EnPoSistersActionFunc actionFunc; + /* 0x18C */ u8 type; + /* 0x18D */ u8 megCloneId; + /* 0x18E */ u8 floatingBobbingTimer; // counts down from 32 to zero, reset + /* 0x18F */ u8 zTargetTimer; // how many frames the player is z targeting, if zero -> invis + /* 0x190 */ u8 fireCount; + /* 0x191 */ u8 poSisterFlags; + /* 0x192 */ union { + s16 stateTimer; // generic name for resets + s16 spinTimer; // frames of spinning since spin attack starts, when zero checks collision + s16 fleeTimer; // after being hit, 5 frames of flying away + s16 deathTimer; // (incr) controls timings of the death cutscene, reset between the two stages + s16 laughTimer; // if observer, will laugh once in awhile + s16 spinupTimer; // frames of spinning up (gaining speed) for attack (jo/beth/amy attack) + s16 megSurroundTimer; // frames of meg circling the player menacingly until spin attack + s16 spinInvisibleTimer; // frames of spining away to invisible and back to visible + s16 idleFlyingAnimationCounter; // count: animations completed since entering actionFunc + }; + /* 0x194 */ union { + s16 invisibleTimer; // frames until coming back to fight from invisible (all combat variants) + s16 megAttackTimer; // delay until meg spin attacks player (negative frames counting up to 0) + s16 megClonesRemaining; // positive count of meg clones remaining + }; + /* 0x196 */ Vec3s jointTable[POSISTERS_LIMB_MAX]; + /* 0x1DE */ Vec3s morphTable[POSISTERS_LIMB_MAX]; + /* 0x226 */ Color_RGBA8 color; + /* 0x22C */ Vec3f firePos[8]; + /* 0x28C */ Vec3f limbPos[8]; // passed to Actor_DrawDamageEffects + /* 0x2EC */ f32 megDistToPlayer; + /* 0x2F0 */ f32 drawDmgEffAlpha; + /* 0x2F4 */ f32 drawDmgEffScale; + /* 0x2F8 */ LightNode* lightNode; + /* 0x2FC */ LightInfo lightInfo; + /* 0x30C */ ColliderCylinder collider; + /* 0x358 */ MtxF mtxf; } EnPoSisters; // size = 0x398 extern const ActorInit En_Po_Sisters_InitVars; diff --git a/src/overlays/actors/ovl_En_Poh/z_en_poh.c b/src/overlays/actors/ovl_En_Poh/z_en_poh.c index 22f590c44..9d1dca75e 100644 --- a/src/overlays/actors/ovl_En_Poh/z_en_poh.c +++ b/src/overlays/actors/ovl_En_Poh/z_en_poh.c @@ -11,40 +11,40 @@ #define THIS ((EnPoh*)thisx) -void EnPoh_Init(Actor* thisx, GlobalContext* globalCtx); -void EnPoh_Destroy(Actor* thisx, GlobalContext* globalCtx); -void EnPoh_Update(Actor* thisx, GlobalContext* globalCtx); -void EnPoh_Draw(Actor* thisx, GlobalContext* globalCtx); +void EnPoh_Init(Actor* thisx, PlayState* play); +void EnPoh_Destroy(Actor* thisx, PlayState* play); +void EnPoh_Update(Actor* thisx, PlayState* play); +void EnPoh_Draw(Actor* thisx, PlayState* play); -void func_80B2CAA4(EnPoh* this, GlobalContext* globalCtx); +void func_80B2CAA4(EnPoh* this, PlayState* play); void func_80B2CB60(EnPoh* this); -void func_80B2CBBC(EnPoh* this, GlobalContext* globalCtx); +void func_80B2CBBC(EnPoh* this, PlayState* play); void func_80B2CD14(EnPoh* this); -void func_80B2CD64(EnPoh* this, GlobalContext* globalCtx); +void func_80B2CD64(EnPoh* this, PlayState* play); void func_80B2CEC8(EnPoh* this); -void func_80B2CF28(EnPoh* this, GlobalContext* globalCtx); -void func_80B2D07C(EnPoh* this, GlobalContext* globalCtx); +void func_80B2CF28(EnPoh* this, PlayState* play); +void func_80B2D07C(EnPoh* this, PlayState* play); void func_80B2D0E8(EnPoh* this); -void func_80B2D140(EnPoh* this, GlobalContext* globalCtx); +void func_80B2D140(EnPoh* this, PlayState* play); void func_80B2D2C0(EnPoh* this); -void func_80B2D300(EnPoh* this, GlobalContext* globalCtx); -void func_80B2D628(EnPoh* this, GlobalContext* globalCtx); +void func_80B2D300(EnPoh* this, PlayState* play); +void func_80B2D628(EnPoh* this, PlayState* play); void func_80B2D694(EnPoh* this); -void func_80B2D6EC(EnPoh* this, GlobalContext* globalCtx); -void func_80B2D7D4(EnPoh* this, GlobalContext* globalCtx); -void func_80B2D980(EnPoh* this, GlobalContext* globalCtx); +void func_80B2D6EC(EnPoh* this, PlayState* play); +void func_80B2D7D4(EnPoh* this, PlayState* play); +void func_80B2D980(EnPoh* this, PlayState* play); void func_80B2DAD0(EnPoh* this); -void func_80B2DB44(EnPoh* this, GlobalContext* globalCtx); -void func_80B2DC50(EnPoh* this, GlobalContext* globalCtx); -void func_80B2DD2C(EnPoh* this, GlobalContext* globalCtx); +void func_80B2DB44(EnPoh* this, PlayState* play); +void func_80B2DC50(EnPoh* this, PlayState* play); +void func_80B2DD2C(EnPoh* this, PlayState* play); void func_80B2E0B0(EnPoh* this); -void func_80B2E180(EnPoh* this, GlobalContext* globalCtx); +void func_80B2E180(EnPoh* this, PlayState* play); void func_80B2E1D8(EnPoh* this); -void func_80B2E230(EnPoh* this, GlobalContext* globalCtx); +void func_80B2E230(EnPoh* this, PlayState* play); void func_80B2E3B0(EnPoh* this); -void func_80B2E3F8(EnPoh* this, GlobalContext* globalCtx); -void func_80B2F328(Actor* thisx, GlobalContext* globalCtx); -void func_80B2F37C(Actor* thisx, GlobalContext* globalCtx); +void func_80B2E3F8(EnPoh* this, PlayState* play); +void func_80B2F328(Actor* thisx, PlayState* play); +void func_80B2F37C(Actor* thisx, PlayState* play); const ActorInit En_Poh_InitVars = { ACTOR_EN_POH, @@ -101,7 +101,7 @@ static ColliderJntSphInit sJntSphInit = { OC2_TYPE_1, COLSHAPE_JNTSPH, }, - 1, + ARRAY_COUNT(sJntSphElementsInit), sJntSphElementsInit, }; @@ -147,40 +147,40 @@ static InitChainEntry sInitChain[] = { ICHAIN_F32(targetArrowOffset, 3200, ICHAIN_STOP), }; -void EnPoh_Init(Actor* thisx, GlobalContext* globalCtx) { +void EnPoh_Init(Actor* thisx, PlayState* play) { EnPoh* this = THIS; s32 pad; Actor_ProcessInitChain(&this->actor, sInitChain); ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 30.0f); - Collider_InitAndSetJntSph(globalCtx, &this->colliderSph, &this->actor, &sJntSphInit, this->colliderSphElements); + Collider_InitAndSetJntSph(play, &this->colliderSph, &this->actor, &sJntSphInit, this->colliderSphElements); this->colliderSph.elements[0].dim.worldSphere.radius = 0; this->colliderSph.elements[0].dim.worldSphere.center.x = this->actor.world.pos.x; this->colliderSph.elements[0].dim.worldSphere.center.y = this->actor.world.pos.y; this->colliderSph.elements[0].dim.worldSphere.center.z = this->actor.world.pos.z; - Collider_InitAndSetCylinder(globalCtx, &this->colliderCylinder, &this->actor, &sCylinderInit); + Collider_InitAndSetCylinder(play, &this->colliderCylinder, &this->actor, &sCylinderInit); CollisionCheck_SetInfo(&this->actor.colChkInfo, &sDamageTable, &sColChkInfoInit); this->unk_18D = 32; this->unk_190 = Rand_S16Offset(700, 300); - this->lightNode = LightContext_InsertLight(globalCtx, &globalCtx->lightCtx, &this->lightInfo); + this->lightNode = LightContext_InsertLight(play, &play->lightCtx, &this->lightInfo); Lights_PointGlowSetInfo(&this->lightInfo, this->actor.home.pos.x, this->actor.home.pos.y, this->actor.home.pos.z, 255, 255, 255, 0); - SkelAnime_Init(globalCtx, &this->skelAnime, &object_po_Skel_0050D0, &object_po_Anim_000A60, this->jointTable, + SkelAnime_Init(play, &this->skelAnime, &object_po_Skel_0050D0, &object_po_Anim_000A60, this->jointTable, this->morphTable, 21); this->actor.bgCheckFlags |= 0x400; func_80B2D0E8(this); } -void EnPoh_Destroy(Actor* thisx, GlobalContext* globalCtx) { +void EnPoh_Destroy(Actor* thisx, PlayState* play) { EnPoh* this = THIS; - LightContext_RemoveLight(globalCtx, &globalCtx->lightCtx, this->lightNode); - Collider_DestroyJntSph(globalCtx, &this->colliderSph); - Collider_DestroyCylinder(globalCtx, &this->colliderCylinder); + LightContext_RemoveLight(play, &play->lightCtx, this->lightNode); + Collider_DestroyJntSph(play, &this->colliderSph); + Collider_DestroyCylinder(play, &this->colliderCylinder); } -void func_80B2C910(Vec3f* vec, GlobalContext* globalCtx) { - Camera* activeCam = GET_ACTIVE_CAM(globalCtx); +void func_80B2C910(Vec3f* vec, PlayState* play) { + Camera* activeCam = GET_ACTIVE_CAM(play); Vec3f sp20; f32 temp_f0; @@ -198,8 +198,8 @@ void func_80B2C910(Vec3f* vec, GlobalContext* globalCtx) { } } -void func_80B2C9B8(EnPoh* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); +void func_80B2C9B8(EnPoh* this, PlayState* play) { + Player* player = GET_PLAYER(play); Math_StepToF(&this->actor.world.pos.y, player->actor.world.pos.y, 1.0f); this->actor.world.pos.y += 2.5f * Math_SinS(this->unk_18D * 0x800); @@ -219,13 +219,13 @@ void func_80B2CA4C(EnPoh* this) { this->actor.speedXZ = 0.0f; } -void func_80B2CAA4(EnPoh* this, GlobalContext* globalCtx) { +void func_80B2CAA4(EnPoh* this, PlayState* play) { SkelAnime_Update(&this->skelAnime); if (Animation_OnFrame(&this->skelAnime, 0.0f) && (this->unk_18E != 0)) { this->unk_18E--; } - func_80B2C9B8(this, globalCtx); + func_80B2C9B8(this, play); if (this->actor.xzDistToPlayer < 200.0f) { func_80B2CD14(this); @@ -245,7 +245,7 @@ void func_80B2CB60(EnPoh* this) { this->actionFunc = func_80B2CBBC; } -void func_80B2CBBC(EnPoh* this, GlobalContext* globalCtx) { +void func_80B2CBBC(EnPoh* this, PlayState* play) { SkelAnime_Update(&this->skelAnime); Math_StepToF(&this->actor.speedXZ, 1.0f, 0.2f); if (Animation_OnFrame(&this->skelAnime, 0.0f) && (this->unk_18E != 0)) { @@ -257,7 +257,7 @@ void func_80B2CBBC(EnPoh* this, GlobalContext* globalCtx) { } Math_ScaledStepToS(&this->actor.world.rot.y, this->unk_192, 0x71C); - func_80B2C9B8(this, globalCtx); + func_80B2C9B8(this, play); if ((this->actor.xzDistToPlayer < 200.0f) && (this->unk_18E < 19)) { func_80B2CD14(this); } else if (this->unk_18E == 0) { @@ -280,8 +280,8 @@ void func_80B2CD14(EnPoh* this) { this->actor.speedXZ = 2.0f; } -void func_80B2CD64(EnPoh* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); +void func_80B2CD64(EnPoh* this, PlayState* play) { + Player* player = GET_PLAYER(play); s16 yawDiff; SkelAnime_Update(&this->skelAnime); @@ -298,12 +298,12 @@ void func_80B2CD64(EnPoh* this, GlobalContext* globalCtx) { Math_ScaledStepToS(&this->actor.world.rot.y, this->actor.yawTowardsPlayer, 0x71C); } - func_80B2C9B8(this, globalCtx); + func_80B2C9B8(this, play); if (this->actor.xzDistToPlayer > 280.0f) { func_80B2CB60(this); } else if ((this->unk_18E == 0) && (this->actor.xzDistToPlayer < 140.0f) && - !Player_IsFacingActor(&this->actor, 0x2AAA, globalCtx)) { + !Player_IsFacingActor(&this->actor, 0x2AAA, play)) { func_80B2CEC8(this); } @@ -320,7 +320,7 @@ void func_80B2CEC8(EnPoh* this) { this->actionFunc = func_80B2CF28; } -void func_80B2CF28(EnPoh* this, GlobalContext* globalCtx) { +void func_80B2CF28(EnPoh* this, PlayState* play) { SkelAnime_Update(&this->skelAnime); if (Animation_OnFrame(&this->skelAnime, 0.0f)) { Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_PO_KANTERA); @@ -329,7 +329,7 @@ void func_80B2CF28(EnPoh* this, GlobalContext* globalCtx) { } } - func_80B2C9B8(this, globalCtx); + func_80B2C9B8(this, play); if (this->unk_18E >= 10) { Math_ScaledStepToS(&this->actor.world.rot.y, this->actor.yawTowardsPlayer, 0xAAA); } else if (this->unk_18E == 9) { @@ -350,7 +350,7 @@ void func_80B2CFF8(EnPoh* this) { this->actionFunc = func_80B2D07C; } -void func_80B2D07C(EnPoh* this, GlobalContext* globalCtx) { +void func_80B2D07C(EnPoh* this, PlayState* play) { Math_StepToF(&this->actor.speedXZ, 0.0f, 0.5f); if (SkelAnime_Update(&this->skelAnime)) { if (this->actor.colChkInfo.health != 0) { @@ -368,7 +368,7 @@ void func_80B2D0E8(EnPoh* this) { this->actionFunc = func_80B2D140; } -void func_80B2D140(EnPoh* this, GlobalContext* globalCtx) { +void func_80B2D140(EnPoh* this, PlayState* play) { if (SkelAnime_Update(&this->skelAnime)) { this->unk_197 = 255; this->unk_190 = Rand_S16Offset(700, 300); @@ -393,7 +393,7 @@ void func_80B2D2C0(EnPoh* this) { this->actionFunc = func_80B2D300; } -void func_80B2D300(EnPoh* this, GlobalContext* globalCtx) { +void func_80B2D300(EnPoh* this, PlayState* play) { static Vec3f D_80B2F710 = { 0.0f, 3.0f, 0.0f }; Vec3f sp44; f32 sp40; @@ -404,7 +404,7 @@ void func_80B2D300(EnPoh* this, GlobalContext* globalCtx) { this->unk_18E++; if (this->unk_18E < 8) { - sp38 = Camera_GetCamDirYaw(GET_ACTIVE_CAM(globalCtx)) + 0x4800; + sp38 = Camera_GetCamDirYaw(GET_ACTIVE_CAM(play)) + 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); @@ -417,15 +417,15 @@ void func_80B2D300(EnPoh* this, GlobalContext* globalCtx) { sp44.z = (Math_CosS(sp38) * 23.0f) + this->actor.world.pos.z; } sp36 = (this->unk_18E * 10) + 80; - func_800B3030(globalCtx, &sp44, &D_80B2F710, &gZeroVec3f, sp36, 0, 2); + func_800B3030(play, &sp44, &D_80B2F710, &gZeroVec3f, sp36, 0, 2); sp44.x = (2.0f * this->actor.world.pos.x) - sp44.x; sp44.z = (2.0f * this->actor.world.pos.z) - sp44.z; - func_800B3030(globalCtx, &sp44, &D_80B2F710, &gZeroVec3f, sp36, 0, 2); + func_800B3030(play, &sp44, &D_80B2F710, &gZeroVec3f, sp36, 0, 2); sp44.x = this->actor.world.pos.x; sp44.z = this->actor.world.pos.z; - func_800B3030(globalCtx, &sp44, &D_80B2F710, &gZeroVec3f, sp36, 0, 2); + func_800B3030(play, &sp44, &D_80B2F710, &gZeroVec3f, sp36, 0, 2); } else if (this->unk_18E == 28) { - func_80B2DC50(this, globalCtx); + func_80B2DC50(this, play); } else if (this->unk_18E > 18) { this->actor.scale.x = (28 - this->unk_18E) * 0.001f; this->actor.scale.y = (28 - this->unk_18E) * 0.001f; @@ -448,7 +448,7 @@ void func_80B2D5DC(EnPoh* this) { this->actor.speedXZ = -5.0f; } -void func_80B2D628(EnPoh* this, GlobalContext* globalCtx) { +void func_80B2D628(EnPoh* this, PlayState* play) { if (SkelAnime_Update(&this->skelAnime)) { this->actor.world.rot.y = this->actor.shape.rot.y; func_80B2CB60(this); @@ -466,7 +466,7 @@ void func_80B2D694(EnPoh* this) { this->actor.speedXZ = 0.0f; } -void func_80B2D6EC(EnPoh* this, GlobalContext* globalCtx) { +void func_80B2D6EC(EnPoh* this, PlayState* play) { SkelAnime_Update(&this->skelAnime); if (Math_ScaledStepToS(&this->actor.world.rot.y, this->unk_192, 0x71C)) { func_80B2CB60(this); @@ -476,7 +476,7 @@ void func_80B2D6EC(EnPoh* this, GlobalContext* globalCtx) { func_80B2CD14(this); } - func_80B2C9B8(this, globalCtx); + func_80B2C9B8(this, play); } void func_80B2D76C(EnPoh* this) { @@ -490,7 +490,7 @@ void func_80B2D76C(EnPoh* this) { this->actionFunc = func_80B2D7D4; } -void func_80B2D7D4(EnPoh* this, GlobalContext* globalCtx) { +void func_80B2D7D4(EnPoh* this, PlayState* play) { if (this->unk_18C != 0) { this->unk_18C--; } @@ -501,7 +501,7 @@ void func_80B2D7D4(EnPoh* this, GlobalContext* globalCtx) { Math_ScaledStepToS(&this->unk_192, 0, 0x200); } - func_80B2C9B8(this, globalCtx); + func_80B2C9B8(this, play); this->unk_197 = this->unk_18C * (255.0f / 32.0f); if (this->unk_18C == 0) { this->unk_190 = Rand_S16Offset(100, 50); @@ -520,14 +520,14 @@ void func_80B2D924(EnPoh* this) { this->actionFunc = func_80B2D980; } -void func_80B2D980(EnPoh* this, GlobalContext* globalCtx) { +void func_80B2D980(EnPoh* this, PlayState* play) { this->unk_18C++; this->actor.world.rot.y -= this->unk_192; if (this->unk_18C > 15) { Math_ScaledStepToS(&this->unk_192, 0, 0x200); } - func_80B2C9B8(this, globalCtx); + func_80B2C9B8(this, play); this->unk_197 = this->unk_18C * (255.0f / 32.0f); if (this->unk_18C == 32) { this->unk_190 = Rand_S16Offset(700, 300); @@ -546,7 +546,7 @@ void func_80B2DAD0(EnPoh* this) { this->actionFunc = func_80B2DB44; } -void func_80B2DB44(EnPoh* this, GlobalContext* globalCtx) { +void func_80B2DB44(EnPoh* this, PlayState* play) { f32 sp24; SkelAnime_Update(&this->skelAnime); @@ -554,7 +554,7 @@ void func_80B2DB44(EnPoh* this, GlobalContext* globalCtx) { this->actor.world.pos.x -= sp24 * Math_CosS(this->actor.shape.rot.y); this->actor.world.pos.z += sp24 * Math_SinS(this->actor.shape.rot.y); Math_ScaledStepToS(&this->actor.world.rot.y, BINANG_ROT180(this->actor.yawTowardsPlayer), 0x71C); - func_80B2C9B8(this, globalCtx); + func_80B2C9B8(this, play); this->unk_18E--; if ((this->unk_18E == 0) || (this->actor.xzDistToPlayer > 250.0f)) { this->actor.world.rot.y = this->actor.shape.rot.y; @@ -563,33 +563,32 @@ void func_80B2DB44(EnPoh* this, GlobalContext* globalCtx) { func_800B9010(&this->actor, NA_SE_EN_PO_AWAY - SFX_FLAG); } -void func_80B2DC50(EnPoh* this, GlobalContext* globalCtx) { +void func_80B2DC50(EnPoh* this, PlayState* play) { 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 |= 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); + func_800BC154(play, &play->actorCtx, &this->actor, 8); this->actor.flags &= ~(ACTOR_FLAG_1 | ACTOR_FLAG_4); this->actionFunc = func_80B2DD2C; } -void func_80B2DD2C(EnPoh* this, GlobalContext* globalCtx) { +void func_80B2DD2C(EnPoh* this, PlayState* play) { if ((this->actor.bgCheckFlags & 1) || (this->actor.floorHeight <= BGCHECK_Y_MIN)) { - EffectSsHahen_SpawnBurst(globalCtx, &this->actor.world.pos, 6.0f, 0, 1, 1, 15, OBJECT_PO, 10, - object_po_DL_002D28); + EffectSsHahen_SpawnBurst(play, &this->actor.world.pos, 6.0f, 0, 1, 1, 15, OBJECT_PO, 10, object_po_DL_002D28); func_80B2E0B0(this); } Actor_MoveWithGravity(&this->actor); - Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 10.0f, 10.0f, 10.0f, 4); + Actor_UpdateBgCheckInfo(play, &this->actor, 10.0f, 10.0f, 10.0f, 4); } void func_80B2DDF8(EnPoh* this, s32 arg1) { @@ -634,7 +633,7 @@ void func_80B2E0B0(EnPoh* this) { this->actionFunc = func_80B2E180; } -void func_80B2E180(EnPoh* this, GlobalContext* globalCtx) { +void func_80B2E180(EnPoh* this, PlayState* play) { this->actor.home.pos.y += 2.0f; func_80B2DDF8(this, 20); if (this->unk_197 == 255) { @@ -651,9 +650,9 @@ void func_80B2E1D8(EnPoh* this) { this->actionFunc = func_80B2E230; } -void func_80B2E230(EnPoh* this, GlobalContext* globalCtx) { +void func_80B2E230(EnPoh* this, PlayState* play) { - if (Actor_HasParent(&this->actor, globalCtx)) { + if (Actor_HasParent(&this->actor, play)) { Actor_MarkForDeath(&this->actor); return; } @@ -664,7 +663,7 @@ void func_80B2E230(EnPoh* this, GlobalContext* globalCtx) { return; } - Actor_PickUp(&this->actor, globalCtx, GI_MAX, 35.0f, 60.0f); + Actor_PickUp(&this->actor, play, GI_MAX, 35.0f, 60.0f); this->actor.world.pos.y = (Math_SinS(this->unk_18D * 0x800) * 5.0f) + this->actor.home.pos.y; if (this->unk_18D) { this->unk_18D--; @@ -680,23 +679,23 @@ void func_80B2E230(EnPoh* this, GlobalContext* globalCtx) { } void func_80B2E3B0(EnPoh* this) { - func_801A7328(&this->actor.projectedPos, NA_SE_EN_PO_BIG_CRY - SFX_FLAG); + AudioSfx_StopByPosAndId(&this->actor.projectedPos, NA_SE_EN_PO_BIG_CRY - SFX_FLAG); Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_PO_LAUGH); this->actionFunc = func_80B2E3F8; } -void func_80B2E3F8(EnPoh* this, GlobalContext* globalCtx) { +void func_80B2E3F8(EnPoh* this, PlayState* play) { func_80B2DDF8(this, -13); if (this->unk_197 == 0) { Actor_MarkForDeath(&this->actor); } } -void func_80B2E438(EnPoh* this, GlobalContext* globalCtx) { +void func_80B2E438(EnPoh* this, PlayState* play) { if (this->colliderCylinder.base.acFlags & AC_HIT) { this->colliderCylinder.base.acFlags &= ~AC_HIT; if (!Actor_ApplyDamage(&this->actor)) { - Enemy_StartFinishingBlow(globalCtx, &this->actor); + Enemy_StartFinishingBlow(play, &this->actor); Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_PO_DEAD); } else if (this->actor.colChkInfo.damage != 0) { Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_PO_DAMAGE); @@ -709,8 +708,7 @@ void func_80B2E438(EnPoh* this, GlobalContext* globalCtx) { if (this->actor.colChkInfo.damageEffect == 4) { this->drawDmgEffAlpha = 4.0f; this->drawDmgEffScale = 0.45f; - Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_CLEAR_TAG, - this->colliderCylinder.info.bumper.hitPos.x, + Actor_Spawn(&play->actorCtx, play, ACTOR_EN_CLEAR_TAG, this->colliderCylinder.info.bumper.hitPos.x, this->colliderCylinder.info.bumper.hitPos.y, this->colliderCylinder.info.bumper.hitPos.z, 0, 0, 0, CLEAR_TAG_LARGE_LIGHT_RAYS); } @@ -796,8 +794,8 @@ void func_80B2E8E0(EnPoh* this) { } } -void EnPoh_Update(Actor* thisx, GlobalContext* globalCtx2) { - GlobalContext* globalCtx = globalCtx2; +void EnPoh_Update(Actor* thisx, PlayState* play2) { + PlayState* play = play2; EnPoh* this = THIS; s32 pad; @@ -806,22 +804,22 @@ void EnPoh_Update(Actor* thisx, GlobalContext* globalCtx2) { func_80B2D5DC(this); } - func_80B2E438(this, globalCtx); + func_80B2E438(this, play); func_80B2E55C(this); - this->actionFunc(this, globalCtx); + this->actionFunc(this, play); Actor_MoveWithGravity(&this->actor); if ((this->actionFunc == func_80B2CF28) && (this->unk_18E < 10)) { this->actor.flags |= ACTOR_FLAG_1000000; - CollisionCheck_SetAT(globalCtx, &globalCtx->colChkCtx, &this->colliderSph.base); + CollisionCheck_SetAT(play, &play->colChkCtx, &this->colliderSph.base); } Collider_UpdateCylinder(&this->actor, &this->colliderCylinder); if (this->colliderCylinder.base.acFlags & AC_ON) { - CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->colliderCylinder.base); + CollisionCheck_SetAC(play, &play->colChkCtx, &this->colliderCylinder.base); } - CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->colliderCylinder.base); - CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->colliderSph.base); + CollisionCheck_SetOC(play, &play->colChkCtx, &this->colliderCylinder.base); + CollisionCheck_SetOC(play, &play->colChkCtx, &this->colliderSph.base); Actor_SetFocus(&this->actor, 42.0f); if ((this->actionFunc != func_80B2D07C) && (this->actionFunc != func_80B2D628)) { @@ -847,7 +845,7 @@ void EnPoh_Update(Actor* thisx, GlobalContext* globalCtx2) { } } -s32 EnPoh_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, Actor* thisx, +s32 EnPoh_OverrideLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, Actor* thisx, Gfx** gfx) { EnPoh* this = THIS; @@ -863,7 +861,7 @@ s32 EnPoh_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, return false; } -void EnPoh_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx, Gfx** gfx) { +void EnPoh_PostLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx, Gfx** gfx) { static s8 D_80B2F71C[] = { -1, -1, -1, -1, 4, 5, -1, -1, -1, 0, 1, -1, -1, -1, -1, -1, 2, -1, -1, 3, -1, }; @@ -879,7 +877,7 @@ void EnPoh_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Ve Collider_UpdateSpheres(limbIndex, &this->colliderSph); if ((this->actionFunc == func_80B2D300) && (this->unk_18E >= 2) && (limbIndex == 5)) { - gSPMatrix((*gfx)++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPMatrix((*gfx)++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList((*gfx)++, object_po_DL_002608); } @@ -888,8 +886,8 @@ 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); - func_80B2C910(&sp60, globalCtx); + Matrix_Get(&this->unk_3D8); + func_80B2C910(&sp60, play); 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, this->colliderSph.elements[0].dim.worldSphere.center.z + (s32)sp60.z, this->unk_198, @@ -899,29 +897,29 @@ 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->limbPos[temp_s3]); + Matrix_MultZero(&this->limbPos[temp_s3]); } else if (temp_s3 == 4) { - Matrix_GetStateTranslationAndScaledX(2000.0f, &this->limbPos[temp_s3]); + Matrix_MultVecX(2000.0f, &this->limbPos[temp_s3]); } else { s32 i; Vec3f* vec = &this->limbPos[temp_s3 + 2]; Vec3f* vec2 = &D_80B2F734[0]; - Matrix_GetStateTranslationAndScaledX(-2000.0f, &this->limbPos[temp_s3]); - Matrix_GetStateTranslationAndScaledY(-2000.0f, &this->limbPos[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->limbPos); i++, vec++, vec2++) { - Matrix_MultiplyVector3fByState(vec2, vec); + Matrix_MultVec3f(vec2, vec); } } } } -void EnPoh_Draw(Actor* thisx, GlobalContext* globalCtx) { +void EnPoh_Draw(Actor* thisx, PlayState* play) { EnPoh* this = THIS; Gfx* gfx; - OPEN_DISPS(globalCtx->state.gfxCtx); + OPEN_DISPS(play->state.gfxCtx); func_80B2E6C0(this); if ((this->unk_197 == 255) || (this->unk_197 == 0)) { @@ -931,7 +929,7 @@ void EnPoh_Draw(Actor* thisx, GlobalContext* globalCtx) { gDPSetEnvColor(&gfx[1], this->unk_194, this->unk_195, this->unk_196, this->unk_197); gSPSegment(&gfx[2], 0x08, D_801AEFA0); - gfx = SkelAnime_Draw(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, EnPoh_OverrideLimbDraw, + gfx = SkelAnime_Draw(play, this->skelAnime.skeleton, this->skelAnime.jointTable, EnPoh_OverrideLimbDraw, EnPoh_PostLimbDraw, &this->actor, &gfx[3]); POLY_OPA_DISP = gfx; @@ -942,7 +940,7 @@ void EnPoh_Draw(Actor* thisx, GlobalContext* globalCtx) { gDPSetEnvColor(&gfx[1], 255, 255, 255, this->unk_197); gSPSegment(&gfx[2], 0x08, D_801AEF88); - POLY_XLU_DISP = SkelAnime_Draw(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, + POLY_XLU_DISP = SkelAnime_Draw(play, this->skelAnime.skeleton, this->skelAnime.jointTable, EnPoh_OverrideLimbDraw, EnPoh_PostLimbDraw, &this->actor, &gfx[3]); gfx = POLY_OPA_DISP; @@ -952,23 +950,23 @@ 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); + gSPMatrix(&gfx[2], Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(&gfx[3], object_po_DL_002D28); POLY_OPA_DISP = &gfx[4]; - Actor_DrawDamageEffects(globalCtx, &this->actor, this->limbPos, ARRAY_COUNT(this->limbPos), + Actor_DrawDamageEffects(play, &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); + CLOSE_DISPS(play->state.gfxCtx); } -void func_80B2F328(Actor* thisx, GlobalContext* globalCtx) { +void func_80B2F328(Actor* thisx, PlayState* play) { EnPoh* this = THIS; - this->actionFunc(this, globalCtx); + this->actionFunc(this, play); if (this->actionFunc != func_80B2DD2C) { this->unk_190++; } @@ -976,13 +974,13 @@ void func_80B2F328(Actor* thisx, GlobalContext* globalCtx) { func_80B2E8E0(this); } -void func_80B2F37C(Actor* thisx, GlobalContext* globalCtx) { +void func_80B2F37C(Actor* thisx, PlayState* play) { EnPoh* this = THIS; s32 pad; Vec3f sp7C; Gfx* gfx; - OPEN_DISPS(globalCtx->state.gfxCtx); + OPEN_DISPS(play->state.gfxCtx); if (this->actionFunc == func_80B2DD2C) { gfx = POLY_OPA_DISP; @@ -990,29 +988,28 @@ void func_80B2F37C(Actor* thisx, GlobalContext* globalCtx) { gSPDisplayList(&gfx[0], &sSetupDL[6 * 25]); gDPSetEnvColor(&gfx[1], this->unk_198, this->unk_199, this->unk_19A, 255); - func_80B2C910(&sp7C, globalCtx); + func_80B2C910(&sp7C, play); Lights_PointGlowSetInfo(&this->lightInfo, this->actor.world.pos.x + sp7C.x, this->actor.world.pos.y + sp7C.y, this->actor.world.pos.z + sp7C.z, this->unk_198, this->unk_199, this->unk_19A, 200); - gSPMatrix(&gfx[2], Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPMatrix(&gfx[2], Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(&gfx[3], object_po_DL_002D28); POLY_OPA_DISP = &gfx[4]; } else { - func_8012C2DC(globalCtx->state.gfxCtx); + func_8012C2DC(play->state.gfxCtx); - gSPSegment(POLY_XLU_DISP++, 0x08, - Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, 0, 0, 0x20, 0x40, 1, 0, (this->unk_190 * -8) & 0x1FF, - 0x20, 0x80)); + gSPSegment( + POLY_XLU_DISP++, 0x08, + Gfx_TwoTexScroll(play->state.gfxCtx, 0, 0, 0, 0x20, 0x40, 1, 0, (this->unk_190 * -8) & 0x1FF, 0x20, 0x80)); 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((Camera_GetCamDirYaw(GET_ACTIVE_CAM(globalCtx)) + 0x8000) * (M_PI / 32768), - MTXMODE_APPLY); + Matrix_RotateYF((Camera_GetCamDirYaw(GET_ACTIVE_CAM(play)) + 0x8000) * (M_PI / 32768), MTXMODE_APPLY); - gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_XLU_DISP++, object_po_DL_003850); } - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->state.gfxCtx); } 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 f4787b357..083b44f3f 100644 --- a/src/overlays/actors/ovl_En_Poh/z_en_poh.h +++ b/src/overlays/actors/ovl_En_Poh/z_en_poh.h @@ -5,36 +5,36 @@ struct EnPoh; -typedef void (*EnPohActionFunc)(struct EnPoh*, GlobalContext*); +typedef void (*EnPohActionFunc)(struct EnPoh*, PlayState*); typedef struct EnPoh { - /* 0x0000 */ Actor actor; - /* 0x0144 */ SkelAnime skelAnime; - /* 0x0188 */ EnPohActionFunc actionFunc; - /* 0x018C */ u8 unk_18C; - /* 0x018D */ u8 unk_18D; - /* 0x018E */ s16 unk_18E; - /* 0x0190 */ s16 unk_190; - /* 0x0192 */ s16 unk_192; - /* 0x0194 */ u8 unk_194; - /* 0x0195 */ u8 unk_195; - /* 0x0196 */ u8 unk_196; - /* 0x0197 */ u8 unk_197; - /* 0x0198 */ u8 unk_198; - /* 0x0199 */ u8 unk_199; - /* 0x019A */ u8 unk_19A; - /* 0x019B */ u8 unk_19B; - /* 0x019C */ Vec3s jointTable[21]; - /* 0x021A */ Vec3s morphTable[21]; - /* 0x0298 */ f32 drawDmgEffAlpha; - /* 0x029C */ f32 drawDmgEffScale; - /* 0x02A0 */ Vec3f limbPos[10]; - /* 0x0318 */ LightNode* lightNode; - /* 0x031C */ LightInfo lightInfo; - /* 0x032C */ ColliderCylinder colliderCylinder; - /* 0x0378 */ ColliderJntSph colliderSph; - /* 0x0398 */ ColliderJntSphElement colliderSphElements[1]; - /* 0x03D8 */ MtxF unk_3D8; + /* 0x000 */ Actor actor; + /* 0x144 */ SkelAnime skelAnime; + /* 0x188 */ EnPohActionFunc actionFunc; + /* 0x18C */ u8 unk_18C; + /* 0x18D */ u8 unk_18D; + /* 0x18E */ s16 unk_18E; + /* 0x190 */ s16 unk_190; + /* 0x192 */ s16 unk_192; + /* 0x194 */ u8 unk_194; + /* 0x195 */ u8 unk_195; + /* 0x196 */ u8 unk_196; + /* 0x197 */ u8 unk_197; + /* 0x198 */ u8 unk_198; + /* 0x199 */ u8 unk_199; + /* 0x19A */ u8 unk_19A; + /* 0x19B */ u8 unk_19B; + /* 0x19C */ Vec3s jointTable[21]; + /* 0x21A */ Vec3s morphTable[21]; + /* 0x298 */ f32 drawDmgEffAlpha; + /* 0x29C */ f32 drawDmgEffScale; + /* 0x2A0 */ Vec3f limbPos[10]; + /* 0x318 */ LightNode* lightNode; + /* 0x31C */ LightInfo lightInfo; + /* 0x32C */ ColliderCylinder colliderCylinder; + /* 0x378 */ ColliderJntSph colliderSph; + /* 0x398 */ ColliderJntSphElement colliderSphElements[1]; + /* 0x3D8 */ MtxF unk_3D8; } EnPoh; // size = 0x418 extern const ActorInit En_Poh_InitVars; diff --git a/src/overlays/actors/ovl_En_Pp/z_en_pp.c b/src/overlays/actors/ovl_En_Pp/z_en_pp.c index 67f951299..7766fa8fa 100644 --- a/src/overlays/actors/ovl_En_Pp/z_en_pp.c +++ b/src/overlays/actors/ovl_En_Pp/z_en_pp.c @@ -5,51 +5,114 @@ */ #include "z_en_pp.h" +#include "objects/gameplay_keep/gameplay_keep.h" #define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_4) #define THIS ((EnPp*)thisx) -void EnPp_Init(Actor* thisx, GlobalContext* globalCtx); -void EnPp_Destroy(Actor* thisx, GlobalContext* globalCtx); -void EnPp_Update(Actor* thisx, GlobalContext* globalCtx); -void EnPp_Draw(Actor* thisx, GlobalContext* globalCtx); +void EnPp_Init(Actor* thisx, PlayState* play); +void EnPp_Destroy(Actor* thisx, PlayState* play); +void EnPp_Update(Actor* thisx, PlayState* play); +void EnPp_Draw(Actor* thisx, PlayState* play); -#if 0 -// static DamageTable sDamageTable = { -static DamageTable D_80B21624 = { - /* Deku Nut */ DMG_ENTRY(0, 0x1), - /* Deku Stick */ DMG_ENTRY(1, 0xF), - /* Horse trample */ DMG_ENTRY(0, 0x0), - /* Explosives */ DMG_ENTRY(1, 0xC), - /* Zora boomerang */ DMG_ENTRY(1, 0xF), - /* Normal arrow */ DMG_ENTRY(1, 0xF), - /* UNK_DMG_0x06 */ DMG_ENTRY(0, 0x0), - /* Hookshot */ DMG_ENTRY(1, 0xD), - /* Goron punch */ DMG_ENTRY(1, 0xC), - /* Sword */ DMG_ENTRY(1, 0xF), - /* Goron pound */ DMG_ENTRY(0, 0xE), - /* Fire arrow */ DMG_ENTRY(1, 0x2), - /* Ice arrow */ DMG_ENTRY(1, 0x3), - /* Light arrow */ DMG_ENTRY(2, 0x4), - /* Goron spikes */ DMG_ENTRY(1, 0xF), - /* Deku spin */ DMG_ENTRY(0, 0x1), - /* Deku bubble */ DMG_ENTRY(1, 0xF), - /* Deku launch */ DMG_ENTRY(2, 0xC), - /* UNK_DMG_0x12 */ DMG_ENTRY(0, 0x1), - /* Zora barrier */ DMG_ENTRY(0, 0x5), - /* Normal shield */ DMG_ENTRY(0, 0x0), - /* Light ray */ DMG_ENTRY(0, 0x0), - /* Thrown object */ DMG_ENTRY(1, 0xF), - /* Zora punch */ DMG_ENTRY(1, 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, 0xC), +void EnPp_SetupIdle(EnPp* this); +void EnPp_Idle(EnPp* this, PlayState* play); +void EnPp_SetupCharge(EnPp* this); +void EnPp_Charge(EnPp* this, PlayState* play); +void EnPp_SetupAttack(EnPp* this); +void EnPp_Attack(EnPp* this, PlayState* play); +void EnPp_SetupBounced(EnPp* this); +void EnPp_Bounced(EnPp* this, PlayState* play); +void EnPp_SetupRoar(EnPp* this); +void EnPp_Roar(EnPp* this, PlayState* play); +void EnPp_SetupJump(EnPp* this); +void EnPp_Jump(EnPp* this, PlayState* play); +void EnPp_StunnedOrFrozen(EnPp* this, PlayState* play); +void EnPp_Damaged(EnPp* this, PlayState* play); +void EnPp_SetupDead(EnPp* this, PlayState* play); +void EnPp_Dead(EnPp* this, PlayState* play); +void EnPp_Mask_Detach(EnPp* this, PlayState* play); +void EnPp_BodyPart_SetupMove(EnPp* this); +void EnPp_BodyPart_Move(EnPp* this, PlayState* play); + +typedef enum { + /* 0 */ EN_PP_COLLISION_RESULT_OK, + /* 1 */ EN_PP_COLLISION_RESULT_ABOUT_TO_RUN_INTO_WALL, + /* 2 */ EN_PP_COLLISION_RESULT_ABOUT_TO_RUN_OFF_LEDGE, +} EnPpCollisionResult; + +typedef enum { + /* 0 */ EN_PP_ACTION_IDLE, + /* 1 */ EN_PP_ACTION_CHARGE, + /* 2 */ EN_PP_ACTION_ATTACK, + /* 3 */ EN_PP_ACTION_BOUNCED, + /* 4 */ EN_PP_ACTION_ROAR, + /* 5 */ EN_PP_ACTION_JUMP, + /* 6 */ EN_PP_ACTION_STUNNED_OR_FROZEN, + /* 7 */ EN_PP_ACTION_MASK_DETACH, + /* 8 */ EN_PP_ACTION_DAMAGED, + /* 9 */ EN_PP_ACTION_DEAD, + /* 10 */ EN_PP_ACTION_MASK_DEAD, + /* 11 */ EN_PP_ACTION_SPAWN_BODY_PARTS, + /* 12 */ EN_PP_ACTION_DONE_SPAWNING_BODY_PARTS, + /* 13 */ EN_PP_ACTION_BODY_PART_MOVE, +} EnPpAction; + +typedef enum { + /* 0 */ EN_PP_MASK_DETACH_STATE_START, + /* 1 */ EN_PP_MASK_DETACH_STATE_FALL, + /* 2 */ EN_PP_MASK_DETACH_STATE_DIE, +} EnPpMaskDetachState; + +static s32 sCurrentDeadBodyPartIndex = 0; + +typedef enum { + /* 0x0 */ EN_PP_DMGEFF_JUMP, // Forces the Hiploop to jump + /* 0x1 */ EN_PP_DMGEFF_STUN, // Stuns the Hiploop + /* 0x2 */ EN_PP_DMGEFF_FIRE, // Damages and sets the Hiploop on fire + /* 0x3 */ EN_PP_DMGEFF_FREEZE, // Damages and freezes the Hiploop in ice + /* 0x4 */ EN_PP_DMGEFF_LIGHT_ORB, // Damages and surrounds the Hiploop with light orbs + /* 0x5 */ EN_PP_DMGEFF_ELECTRIC_STUN, // Stuns and surrounds the Hiploop with electric sparks + /* 0xC */ EN_PP_DMGEFF_KNOCK_OFF_MASK = 0xC, // Knocks off the Hiploop's mask or deals regular damage + /* 0xD */ EN_PP_DMGEFF_HOOKSHOT, // Pulls the Hiploop's mask to the player or deals regular damage + /* 0xE */ EN_PP_DMGEFF_GORON_POUND, // Knocks off the Hiploop's mask or forces it to jump + /* 0xF */ EN_PP_DMGEFF_DAMAGE, // Deals regular damage +} EnPpDamageEffect; + +static DamageTable sDamageTable = { + /* Deku Nut */ DMG_ENTRY(0, EN_PP_DMGEFF_STUN), + /* Deku Stick */ DMG_ENTRY(1, EN_PP_DMGEFF_DAMAGE), + /* Horse trample */ DMG_ENTRY(0, EN_PP_DMGEFF_JUMP), + /* Explosives */ DMG_ENTRY(1, EN_PP_DMGEFF_KNOCK_OFF_MASK), + /* Zora boomerang */ DMG_ENTRY(1, EN_PP_DMGEFF_DAMAGE), + /* Normal arrow */ DMG_ENTRY(1, EN_PP_DMGEFF_DAMAGE), + /* UNK_DMG_0x06 */ DMG_ENTRY(0, EN_PP_DMGEFF_JUMP), + /* Hookshot */ DMG_ENTRY(1, EN_PP_DMGEFF_HOOKSHOT), + /* Goron punch */ DMG_ENTRY(1, EN_PP_DMGEFF_KNOCK_OFF_MASK), + /* Sword */ DMG_ENTRY(1, EN_PP_DMGEFF_DAMAGE), + /* Goron pound */ DMG_ENTRY(0, EN_PP_DMGEFF_GORON_POUND), + /* Fire arrow */ DMG_ENTRY(1, EN_PP_DMGEFF_FIRE), + /* Ice arrow */ DMG_ENTRY(1, EN_PP_DMGEFF_FREEZE), + /* Light arrow */ DMG_ENTRY(2, EN_PP_DMGEFF_LIGHT_ORB), + /* Goron spikes */ DMG_ENTRY(1, EN_PP_DMGEFF_DAMAGE), + /* Deku spin */ DMG_ENTRY(0, EN_PP_DMGEFF_STUN), + /* Deku bubble */ DMG_ENTRY(1, EN_PP_DMGEFF_DAMAGE), + /* Deku launch */ DMG_ENTRY(2, EN_PP_DMGEFF_KNOCK_OFF_MASK), + /* UNK_DMG_0x12 */ DMG_ENTRY(0, EN_PP_DMGEFF_STUN), + /* Zora barrier */ DMG_ENTRY(0, EN_PP_DMGEFF_ELECTRIC_STUN), + /* Normal shield */ DMG_ENTRY(0, EN_PP_DMGEFF_JUMP), + /* Light ray */ DMG_ENTRY(0, EN_PP_DMGEFF_JUMP), + /* Thrown object */ DMG_ENTRY(1, EN_PP_DMGEFF_DAMAGE), + /* Zora punch */ DMG_ENTRY(1, EN_PP_DMGEFF_DAMAGE), + /* Spin attack */ DMG_ENTRY(1, EN_PP_DMGEFF_DAMAGE), + /* Sword beam */ DMG_ENTRY(0, EN_PP_DMGEFF_JUMP), + /* Normal Roll */ DMG_ENTRY(0, EN_PP_DMGEFF_JUMP), + /* UNK_DMG_0x1B */ DMG_ENTRY(0, EN_PP_DMGEFF_JUMP), + /* UNK_DMG_0x1C */ DMG_ENTRY(0, EN_PP_DMGEFF_JUMP), + /* Unblockable */ DMG_ENTRY(0, EN_PP_DMGEFF_JUMP), + /* UNK_DMG_0x1E */ DMG_ENTRY(0, EN_PP_DMGEFF_JUMP), + /* Powder Keg */ DMG_ENTRY(1, EN_PP_DMGEFF_KNOCK_OFF_MASK), }; const ActorInit En_Pp_InitVars = { @@ -64,116 +127,1500 @@ const ActorInit En_Pp_InitVars = { (ActorFunc)EnPp_Draw, }; -// static ColliderJntSphElementInit sJntSphElementsInit[1] = { -static ColliderJntSphElementInit D_80B21664[1] = { +static ColliderJntSphElementInit sMaskColliderJntSphElementsInit[1] = { { - { ELEMTYPE_UNK2, { 0xF7CFFFFF, 0x04, 0x10 }, { 0xF7CFFFFF, 0x00, 0x00 }, TOUCH_ON | TOUCH_SFX_NORMAL, BUMP_ON | BUMP_HOOKABLE, OCELEM_ON, }, + { + ELEMTYPE_UNK2, + { 0xF7CFFFFF, 0x04, 0x10 }, + { 0xF7CFFFFF, 0x00, 0x00 }, + TOUCH_ON | TOUCH_SFX_NORMAL, + BUMP_ON | BUMP_HOOKABLE, + OCELEM_ON, + }, { 1, { { 0, 0, 0 }, 0 }, 1 }, }, }; -// static ColliderJntSphInit sJntSphInit = { -static ColliderJntSphInit D_80B21688 = { - { COLTYPE_HARD, AT_ON | AT_TYPE_ENEMY, AC_ON | AC_TYPE_PLAYER, OC1_ON | OC1_TYPE_ALL, OC2_TYPE_1, COLSHAPE_JNTSPH, }, - 1, D_80B21664, // sJntSphElementsInit, +static ColliderJntSphInit sMaskColliderJntSphInit = { + { + COLTYPE_HARD, + AT_ON | AT_TYPE_ENEMY, + AC_ON | AC_TYPE_PLAYER, + OC1_ON | OC1_TYPE_ALL, + OC2_TYPE_1, + COLSHAPE_JNTSPH, + }, + ARRAY_COUNT(sMaskColliderJntSphElementsInit), + sMaskColliderJntSphElementsInit, }; -// static ColliderJntSphElementInit sJntSphElementsInit[1] = { -static ColliderJntSphElementInit D_80B21698[1] = { +static ColliderJntSphElementInit sBodyColliderJntSphElementsInit[1] = { { - { ELEMTYPE_UNK0, { 0xF7CFFFFF, 0x04, 0x04 }, { 0xF7CFFFFF, 0x00, 0x00 }, TOUCH_ON | TOUCH_SFX_NORMAL, BUMP_ON | BUMP_HOOKABLE, OCELEM_ON, }, + { + ELEMTYPE_UNK0, + { 0xF7CFFFFF, 0x04, 0x04 }, + { 0xF7CFFFFF, 0x00, 0x00 }, + TOUCH_ON | TOUCH_SFX_NORMAL, + BUMP_ON | BUMP_HOOKABLE, + OCELEM_ON, + }, { 1, { { 0, 0, 0 }, 0 }, 1 }, }, }; -// static ColliderJntSphInit sJntSphInit = { -static ColliderJntSphInit D_80B216BC = { - { COLTYPE_HARD, AT_ON | AT_TYPE_ENEMY, AC_ON | AC_TYPE_PLAYER, OC1_ON | OC1_TYPE_ALL, OC2_TYPE_1, COLSHAPE_JNTSPH, }, - 1, D_80B21698, // sJntSphElementsInit, +static ColliderJntSphInit sBodyColliderJntSphInit = { + { + COLTYPE_HARD, + AT_ON | AT_TYPE_ENEMY, + AC_ON | AC_TYPE_PLAYER, + OC1_ON | OC1_TYPE_ALL, + OC2_TYPE_1, + COLSHAPE_JNTSPH, + }, + ARRAY_COUNT(sBodyColliderJntSphElementsInit), + sBodyColliderJntSphElementsInit, }; -// static ColliderQuadInit sQuadInit = { -static ColliderQuadInit D_80B216CC = { - { COLTYPE_NONE, AT_ON | AT_TYPE_ENEMY, AC_NONE, OC1_NONE, OC2_NONE, COLSHAPE_QUAD, }, - { ELEMTYPE_UNK0, { 0xF7CFFFFF, 0x04, 0x08 }, { 0x00000000, 0x00, 0x00 }, TOUCH_ON | TOUCH_SFX_NORMAL | TOUCH_UNK7, BUMP_NONE, OCELEM_NONE, }, +static ColliderQuadInit sQuadInit = { + { + COLTYPE_NONE, + AT_ON | AT_TYPE_ENEMY, + AC_NONE, + OC1_NONE, + OC2_NONE, + COLSHAPE_QUAD, + }, + { + ELEMTYPE_UNK0, + { 0xF7CFFFFF, 0x04, 0x08 }, + { 0x00000000, 0x00, 0x00 }, + TOUCH_ON | TOUCH_SFX_NORMAL | TOUCH_UNK7, + BUMP_NONE, + OCELEM_NONE, + }, { { { 0.0f, 0.0f, 0.0f }, { 0.0f, 0.0f, 0.0f }, { 0.0f, 0.0f, 0.0f }, { 0.0f, 0.0f, 0.0f } } }, }; -#endif +static Color_RGBA8 sDustPrimColor = { 60, 50, 20, 255 }; -extern DamageTable D_80B21624; -extern ColliderJntSphElementInit D_80B21664[1]; -extern ColliderJntSphInit D_80B21688; -extern ColliderJntSphElementInit D_80B21698[1]; -extern ColliderJntSphInit D_80B216BC; -extern ColliderQuadInit D_80B216CC; +static Color_RGBA8 sDustEnvColor = { 40, 30, 30, 255 }; -extern UNK_TYPE D_0600A844; +typedef enum { + /* 0 */ EN_PP_ANIM_IDLE, + /* 1 */ EN_PP_ANIM_WALK, + /* 2 */ EN_PP_ANIM_WIND_UP, + /* 3 */ EN_PP_ANIM_CHARGE, + /* 4 */ EN_PP_ANIM_ATTACK, + /* 5 */ EN_PP_ANIM_DAMAGE, + /* 6 */ EN_PP_ANIM_ROAR, + /* 7 */ EN_PP_ANIM_TURN_TO_FACE_PLAYER, + /* 8 */ EN_PP_ANIM_JUMP, + /* 9 */ EN_PP_ANIM_LAND +} EnPpAnimation; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Pp/EnPp_Init.s") +static AnimationHeader* sAnimations[] = { + &gHiploopIdleAnim, &gHiploopWalkAnim, &gHiploopWindUpAnim, &gHiploopChargeAnim, &gHiploopAttackAnim, + &gHiploopDamageAnim, &gHiploopRoarAnim, &gHiploopWalkAnim, &gHiploopWindUpAnim, &gHiploopWalkAnim, +}; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Pp/EnPp_Destroy.s") +static u8 sAnimationModes[] = { + ANIMMODE_LOOP, ANIMMODE_LOOP, ANIMMODE_ONCE, ANIMMODE_LOOP, ANIMMODE_ONCE, + ANIMMODE_LOOP, ANIMMODE_LOOP, ANIMMODE_LOOP, ANIMMODE_ONCE, ANIMMODE_ONCE, +}; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Pp/func_80B1E29C.s") +static s16 sLedgeCheckAngles[] = { 0x0000, 0x1000, 0xF000 }; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Pp/func_80B1E3D4.s") +void EnPp_Init(Actor* thisx, PlayState* play) { + EnPp* this = THIS; + EffectBlureInit1 blureInit; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Pp/func_80B1E5A8.s") + this->actor.targetMode = 4; + this->actor.colChkInfo.mass = 60; + this->actor.colChkInfo.health = 3; + this->actor.colChkInfo.damageTable = &sDamageTable; + SkelAnime_InitFlex(play, &this->skelAnime, &gHiploopSkel, &gHiploopIdleAnim, this->jointTable, this->morphTable, + HIPLOOP_LIMB_MAX); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Pp/func_80B1E680.s") + if (EN_PP_GET_ATTACK_RANGE(&this->actor) == 0) { + this->attackRange = 200.0f; + } else { + this->attackRange = EN_PP_GET_ATTACK_RANGE(&this->actor) * 40.0f; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Pp/func_80B1E778.s") + this->chargesInStraightLines = EN_PP_DOES_CHARGE_IN_STRAIGHT_LINES(&this->actor); + if (this->chargesInStraightLines) { + this->actor.params &= 1; + this->actor.colChkInfo.mass = MASS_IMMOVABLE; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Pp/func_80B1E958.s") + if (this->actor.params < 0) { + this->actor.params = EN_PP_TYPE_MASKED; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Pp/func_80B1E970.s") + if (EN_PP_GET_TYPE(&this->actor) >= EN_PP_TYPE_BODY_PART_BASE) { + this->deadBodyPartIndex = sCurrentDeadBodyPartIndex; + sCurrentDeadBodyPartIndex++; + this->actor.shape.rot.y = this->actor.world.rot.y; + Actor_SetScale(&this->actor, 0.03f); + EnPp_BodyPart_SetupMove(this); + } else { + Collider_InitAndSetJntSph(play, &this->maskCollider, &this->actor, &sMaskColliderJntSphInit, + this->maskColliderElements); + Collider_InitAndSetJntSph(play, &this->bodyCollider, &this->actor, &sBodyColliderJntSphInit, + this->bodyColliderElements); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Pp/func_80B1EBD8.s") + this->bodyCollider.elements[0].dim.scale = 1.0f; + if (EN_PP_GET_TYPE(&this->actor) > EN_PP_TYPE_MASKED) { + this->actor.hintId = 0x25; + this->maskColliderElements[0].info.toucherFlags &= ~TOUCH_ON; + this->maskColliderElements[0].info.bumperFlags &= ~BUMP_ON; + this->maskColliderElements[0].info.ocElemFlags &= ~OCELEM_ON; + this->maskCollider.base.colType = COLTYPE_HIT2; + this->maskCollider.elements[0].dim.modelSphere.radius = 42; + this->maskCollider.elements[0].dim.scale = 1.0f; + this->maskCollider.elements[0].dim.modelSphere.center.x = 400; + this->maskCollider.elements[0].dim.modelSphere.center.y = -400; + this->bodyCollider.elements[0].dim.modelSphere.radius = 20; + this->bodyCollider.elements[0].dim.scale = 1.0f; + this->bodyCollider.elements[0].dim.modelSphere.center.x = 400; + this->bodyCollider.elements[0].dim.modelSphere.center.y = -400; + } else { + this->actor.hintId = 0x26; + this->maskCollider.elements[0].dim.modelSphere.radius = 10; + this->maskCollider.elements[0].dim.scale = 1.0f; + this->maskCollider.elements[0].dim.modelSphere.center.x = 1000; + this->maskCollider.elements[0].dim.modelSphere.center.y = -500; + this->bodyCollider.elements[0].dim.modelSphere.radius = 25; + this->bodyCollider.elements[0].dim.scale = 1.0f; + this->bodyCollider.elements[0].dim.modelSphere.center.x = 400; + this->bodyCollider.elements[0].dim.modelSphere.center.y = -400; + this->bodyColliderElements[0].info.bumperFlags |= BUMP_HOOKABLE; + this->maskCollider.elements[0].info.toucher.damage = 0x10; + //! FAKE: Needed to fix some regs + //! https://decomp.me/scratch/6Yd1B + if (this->actor.world.rot.z) {} + if (this->actor.world.rot.z) {} + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Pp/func_80B1EC24.s") + Collider_InitQuad(play, &this->hornCollider); + Collider_SetQuad(play, &this->hornCollider, &this->actor, &sQuadInit); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Pp/func_80B1EFFC.s") + blureInit.p1StartColor[0] = blureInit.p1StartColor[1] = blureInit.p1StartColor[2] = blureInit.p1StartColor[3] = + blureInit.p2StartColor[0] = blureInit.p2StartColor[1] = blureInit.p2StartColor[2] = + blureInit.p1EndColor[0] = blureInit.p1EndColor[1] = blureInit.p1EndColor[2] = blureInit.p2EndColor[0] = + blureInit.p2EndColor[1] = blureInit.p2EndColor[2] = 255; + blureInit.p2StartColor[3] = 64; + blureInit.p1EndColor[3] = blureInit.p2EndColor[3] = 0; + blureInit.elemDuration = 8; + blureInit.unkFlag = false; + blureInit.calcMode = 2; + Effect_Add(play, &this->blureIndex, EFFECT_BLURE1, 0, 0, &blureInit); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Pp/func_80B1F048.s") + Actor_SetScale(&this->actor, 0.03f); + this->floorPolyForCircleShadow = NULL; + this->actor.gravity = -3.0f; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Pp/func_80B1F0A4.s") + if ((EN_PP_GET_TYPE(&this->actor) == EN_PP_TYPE_MASKED) || + (EN_PP_GET_TYPE(&this->actor) == EN_PP_TYPE_NO_MASK)) { + EnPp_SetupIdle(this); + } else { + EnPp_SetupJump(this); + } + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Pp/func_80B1F188.s") +void EnPp_Destroy(Actor* thisx, PlayState* play) { + EnPp* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Pp/func_80B1F244.s") + if (EN_PP_GET_TYPE(&this->actor) < EN_PP_TYPE_BODY_PART_BASE) { + Collider_DestroyJntSph(play, &this->maskCollider); + Collider_DestroyJntSph(play, &this->bodyCollider); + Collider_DestroyQuad(play, &this->hornCollider); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Pp/func_80B1F29C.s") + Effect_Destroy(play, this->blureIndex); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Pp/func_80B1F4A0.s") +/** + * This function converts the Hiploop's world position to polar coordinates, + * converts those polar coordinates back into Cartesian coordinates, and then + * checks to see if this doubly-converted position is similar to the original + * world position. This seemingly always returns true, and logically it should + * always return true unless there are errors in how math is implemented. + */ +s32 EnPp_PointlessPosCheck(EnPp* this) { + f32 diffX = this->actor.home.pos.x - this->actor.world.pos.x; + f32 diffZ = this->actor.home.pos.z - this->actor.world.pos.z; + f32 radius; + s16 angle; + Vec3f nearDuplicateWorldPos; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Pp/func_80B1F560.s") + // This converts the vector between the Hiploop's home and world positions into polar + // coordinates. In other words, if the home position is at the origin, then the world + // position can be found at (radius, angle). + radius = sqrtf(SQ(diffX) + SQ(diffZ)); + angle = Math_Vec3f_Yaw(&this->actor.home.pos, &this->actor.world.pos); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Pp/func_80B1F664.s") + // This takes the polar coordinates we found earlier and converts them *back* into + // Cartesian coordinates by adding them back to the home position. This ends up creating + // a near-duplicate of the Hiploop's original world position. + Math_Vec3f_Copy(&nearDuplicateWorldPos, &this->actor.home.pos); + nearDuplicateWorldPos.x += Math_SinS(angle) * radius; + nearDuplicateWorldPos.z += Math_CosS(angle) * radius; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Pp/func_80B1F6B4.s") + Math_ApproachF(&this->actor.world.pos.x, nearDuplicateWorldPos.x, 0.3f, 2.0f); + Math_ApproachF(&this->actor.world.pos.z, nearDuplicateWorldPos.z, 0.3f, 2.0f); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Pp/func_80B1F770.s") + // This computes the difference between the Hiploop's original world position and the + // near-duplicate position created earlier. Since the two positions are almost identical, + // the differences are tiny. + diffX = this->actor.world.pos.x - nearDuplicateWorldPos.x; + diffZ = this->actor.world.pos.z - nearDuplicateWorldPos.z; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Pp/func_80B1F940.s") + // Since the two differences are always tiny, this is always true. + if (sqrtf(SQ(diffX) + SQ(diffZ)) < 2.0f) { + this->actor.world.pos.x = nearDuplicateWorldPos.x; + this->actor.world.pos.z = nearDuplicateWorldPos.z; + return true; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Pp/func_80B1FAD0.s") + return false; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Pp/func_80B1FC7C.s") +/** + * Spawns dust behind the Hiploop's back feet. + */ +void EnPp_SpawnDust(EnPp* this, PlayState* play) { + s32 i; + Vec3f pos; + Vec3f velocity; + Vec3f accel; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Pp/func_80B1FF20.s") + for (i = 0; i < ARRAY_COUNT(this->backFootPos); i++) { + velocity.x = randPlusMinusPoint5Scaled(2.0f); + velocity.y = Rand_ZeroFloat(2.0f) + 1.0f; + velocity.z = randPlusMinusPoint5Scaled(2.0f); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Pp/func_80B20030.s") + accel.y = -0.1f; + accel.z = 0.0f; + accel.x = 0.0f; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Pp/func_80B202B8.s") + pos.x = this->backFootPos[i].x + randPlusMinusPoint5Scaled(10.0f); + pos.y = Rand_ZeroFloat(3.0f) + this->actor.floorHeight + 1.0f; + pos.z = this->backFootPos[i].z + randPlusMinusPoint5Scaled(10.0f); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Pp/func_80B203BC.s") + func_800B0EB0(play, &pos, &velocity, &accel, &sDustPrimColor, &sDustEnvColor, (Rand_ZeroFloat(50.0f) + 60.0f), + 30, (Rand_ZeroFloat(5.0f) + 20.0f)); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Pp/func_80B20668.s") +void EnPp_ChangeAnim(EnPp* this, s32 animIndex) { + f32 morphFrames = -10.0f; + f32 playSpeed; + f32 startFrame; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Pp/EnPp_Update.s") + this->animIndex = animIndex; + this->endFrame = Animation_GetLastFrame(sAnimations[this->animIndex]); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Pp/func_80B20E6C.s") + if (this->animIndex >= EN_PP_ANIM_WIND_UP) { + morphFrames = 0.0f; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Pp/func_80B20F70.s") + playSpeed = 1.0f; + if (this->animIndex == EN_PP_ANIM_TURN_TO_FACE_PLAYER) { + playSpeed = 2.0f; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Pp/EnPp_Draw.s") + startFrame = 0.0f; + if (this->action == EN_PP_ACTION_BODY_PART_MOVE) { + startFrame = this->endFrame; + } + + Animation_Change(&this->skelAnime, sAnimations[this->animIndex], playSpeed, startFrame, this->endFrame, + sAnimationModes[this->animIndex], morphFrames); +} + +void EnPp_PlaySfxForAnimation(EnPp* this) { + if (this->action != EN_PP_ACTION_STUNNED_OR_FROZEN) { + switch (this->animIndex) { + case EN_PP_ANIM_WALK: + case EN_PP_ANIM_TURN_TO_FACE_PLAYER: + if (Animation_OnFrame(&this->skelAnime, 0.0f)) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_HIPLOOP_FOOTSTEP); + } + break; + + case EN_PP_ANIM_WIND_UP: + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_HIPLOOP_FOOT - SFX_FLAG); + break; + + case EN_PP_ANIM_CHARGE: + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_HIPLOOP_RUN - SFX_FLAG); + break; + + case EN_PP_ANIM_ATTACK: + if (Animation_OnFrame(&this->skelAnime, 0.0f)) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_HIPLOOP_PAUSE); + } + break; + + case EN_PP_ANIM_ROAR: + if (Animation_OnFrame(&this->skelAnime, 6.0f)) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_HIPLOOP_PAUSE); + } + break; + + default: + break; + } + } +} + +/** + * Checks to see if the Hiploop is about to walk off a ledge or into a wall. + */ +s32 EnPp_CheckCollision(EnPp* this, PlayState* play) { + s16 angle; + s32 i; + + angle = this->actor.world.rot.y; + if (this->action == EN_PP_ACTION_DAMAGED) { + angle = this->targetRotY; + } + + Math_Vec3f_Copy(&this->wallCheckPos, &this->actor.world.pos); + for (i = 0; i < ARRAY_COUNT(this->ledgeCheckPos); i++) { + Math_Vec3f_Copy(&this->ledgeCheckPos[i], &this->actor.world.pos); + this->ledgeCheckPos[i].x += Math_SinS(sLedgeCheckAngles[i] + angle) * 70.0f; + this->ledgeCheckPos[i].y = this->actor.floorHeight - 10.0f; + this->ledgeCheckPos[i].z += Math_CosS(sLedgeCheckAngles[i] + angle) * 70.0f; + if (!BgCheck_SphVsFirstPoly(&play->colCtx, &this->ledgeCheckPos[i], 20.0f)) { + return EN_PP_COLLISION_RESULT_ABOUT_TO_RUN_OFF_LEDGE; + } + } + + this->wallCheckPos.x += Math_SinS(angle) * 40.0f; + this->wallCheckPos.y = this->actor.world.pos.y + 20.0f; + if (this->chargesInStraightLines) { + // This prevents the Hiploops in Woodfall from acting strangely when they move from + // a wooden platform onto one of the ramps; without this, they'll suddenly slow down + // and start roaring when they try to climb the small lip. + this->wallCheckPos.y += 20.0f; + } + + this->wallCheckPos.z += Math_CosS(angle) * 40.0f; + if (BgCheck_SphVsFirstWall(&play->colCtx, &this->wallCheckPos, 10.0f)) { + return EN_PP_COLLISION_RESULT_ABOUT_TO_RUN_INTO_WALL; + } + + return EN_PP_COLLISION_RESULT_OK; +} + +void EnPp_SetupIdle(EnPp* this) { + this->action = EN_PP_ACTION_IDLE; + this->actionFunc = EnPp_Idle; +} + +/** + * Alternates between stopping in place, spinning around in random directions, and walking forward. + */ +void EnPp_Idle(EnPp* this, PlayState* play) { + Vec3f posToLookAt; + + SkelAnime_Update(&this->skelAnime); + if (this->hasBeenDamaged || (this->actor.xzDistToPlayer < this->attackRange)) { + EnPp_SetupCharge(this); + } else { + if ((this->timer == 0) && (this->secondaryTimer == 0)) { + this->secondaryTimer = Rand_ZeroFloat(20.0f) + 20.0f; + Math_Vec3f_Copy(&posToLookAt, &this->actor.home.pos); + posToLookAt.x += randPlusMinusPoint5Scaled(50.0f); + posToLookAt.z += randPlusMinusPoint5Scaled(50.0f); + this->targetRotY = Math_Vec3f_Yaw(&this->actor.world.pos, &posToLookAt); + this->actor.speedXZ = 0.0f; + if (this->animIndex != EN_PP_ANIM_IDLE) { + EnPp_ChangeAnim(this, EN_PP_ANIM_IDLE); + } + } + + if (this->secondaryTimer == 1) { + this->timer = Rand_ZeroFloat(40.0f) + 40.0f; + } + + if (EnPp_CheckCollision(this, play) != EN_PP_COLLISION_RESULT_OK) { + this->timer = 0; + if (this->animIndex != EN_PP_ANIM_WALK) { + EnPp_ChangeAnim(this, EN_PP_ANIM_WALK); + } + + Math_SmoothStepToS(&this->actor.world.rot.y, this->targetRotY, 1, 0x258, 0); + } else if ((this->secondaryTimer == 0) && (this->timer != 0)) { + if (this->animIndex == EN_PP_ANIM_IDLE) { + EnPp_ChangeAnim(this, EN_PP_ANIM_WALK); + } + + if ((this->maskBounceRotationalVelocity < 0x64) && + (fabsf(this->actor.world.rot.y - this->targetRotY) < 100.0f)) { + Math_ApproachF(&this->actor.speedXZ, 1.0f, 0.3f, 1.0f); + } + + Math_SmoothStepToS(&this->actor.world.rot.y, this->targetRotY, 1, + (this->maskBounceRotationalVelocity + 0x258), 0); + Math_SmoothStepToS(&this->maskBounceRotationalVelocity, 0, 1, 0x1F4, 0); + } + } +} + +void EnPp_SetupCharge(EnPp* this) { + this->secondaryTimer = this->timer = 0; + this->actionVar.isCharging = false; + EnPp_ChangeAnim(this, EN_PP_ANIM_TURN_TO_FACE_PLAYER); + this->action = EN_PP_ACTION_CHARGE; + this->actionFunc = EnPp_Charge; +} + +/** + * Charges either directly at the player or in a straight line, depending on the type of Hiploop. + */ +void EnPp_Charge(EnPp* this, PlayState* play) { + f32 curFrame = this->skelAnime.curFrame; + s32 yawDiff; + Vec3f distanceFromWorldPos; + + SkelAnime_Update(&this->skelAnime); + + if (!this->actionVar.isCharging || (this->animIndex == EN_PP_ANIM_WIND_UP)) { + this->targetRotY = this->actor.yawTowardsPlayer; + if (this->chargesInStraightLines) { + yawDiff = ABS_ALT(BINANG_SUB(this->actor.yawTowardsPlayer, this->actor.home.rot.y)); + this->targetRotY = this->actor.home.rot.y + 0x8000; + if (yawDiff < 0x3000) { + this->targetRotY = this->actor.home.rot.y; + } + + Math_Vec3f_Copy(&this->targetPos, &this->actor.world.pos); + Matrix_RotateYS(this->targetRotY, MTXMODE_NEW); + Matrix_MultVecZ(300.0f, &distanceFromWorldPos); + this->targetPos.x += distanceFromWorldPos.x; + this->targetPos.z += distanceFromWorldPos.z; + } + + Math_SmoothStepToS(&this->actor.world.rot.y, this->targetRotY, 1, (this->maskBounceRotationalVelocity + 0x7D0), + 0); + } + + Math_SmoothStepToS(&this->maskBounceRotationalVelocity, 0, 1, 0x1F4, 0); + if (!this->actionVar.isCharging) { + Math_ApproachZeroF(&this->actor.speedXZ, 0.5f, 1.0f); + if (fabsf(this->actor.world.rot.y - this->targetRotY) < 100.0f) { + if (this->chargesInStraightLines) { + this->actor.world.rot.y = this->targetRotY; + } + + this->actionVar.isCharging = true; + } + } else if (this->animIndex == EN_PP_ANIM_TURN_TO_FACE_PLAYER) { + EnPp_ChangeAnim(this, EN_PP_ANIM_WIND_UP); + } else if (this->animIndex == EN_PP_ANIM_WIND_UP) { + if (this->endFrame <= curFrame) { + this->chargeAndBounceSpeed = 14.0f; + this->timer = 20; + EnPp_ChangeAnim(this, EN_PP_ANIM_CHARGE); + } + } else if (this->animIndex == EN_PP_ANIM_CHARGE) { + if (EnPp_CheckCollision(this, play) != EN_PP_COLLISION_RESULT_OK) { + this->actor.speedXZ = 0.0f; + EnPp_SetupRoar(this); + return; + } + + if (!this->chargesInStraightLines) { + Math_ApproachF(&this->actor.speedXZ, 10.0f, 0.3f, 1.0f); + } else { + Math_ApproachF(&this->actor.world.pos.x, this->targetPos.x, 0.5f, + fabsf(Math_SinS(this->targetRotY) * this->chargeAndBounceSpeed)); + Math_ApproachF(&this->actor.world.pos.z, this->targetPos.z, 0.5f, + fabsf(Math_CosS(this->targetRotY) * this->chargeAndBounceSpeed)); + if (this->timer < 10) { + Math_ApproachZeroF(&this->chargeAndBounceSpeed, 0.3f, 0.2f); + } + } + + if (this->timer == 0) { + EnPp_SetupRoar(this); + return; + } + + if (!(this->maskCollider.base.atFlags & AT_BOUNCED) && (!(this->bodyCollider.base.atFlags & AT_BOUNCED))) { + if ((this->maskCollider.base.atFlags & AT_HIT) || (this->bodyCollider.base.atFlags & AT_HIT)) { + EnPp_SetupAttack(this); + return; + } + } else if (this->chargesInStraightLines) { + EnPp_SetupBounced(this); + return; + } else { + if (EN_PP_GET_TYPE(&this->actor) != EN_PP_TYPE_MASKED) { + this->actor.speedXZ *= -1.0f; + } else { + this->actor.speedXZ *= -0.5f; + } + + EnPp_SetupRoar(this); + return; + } + } + + if (((this->animIndex == EN_PP_ANIM_WIND_UP) || (this->animIndex == EN_PP_ANIM_CHARGE)) && + (this->secondaryTimer == 0)) { + EnPp_SpawnDust(this, play); + this->secondaryTimer = 3; + } +} + +void EnPp_SetupAttack(EnPp* this) { + EnPp_ChangeAnim(this, EN_PP_ANIM_ATTACK); + this->hornColliderOn = true; + this->action = EN_PP_ACTION_ATTACK; + this->actor.speedXZ = 0.0f; + this->actionFunc = EnPp_Attack; +} + +void EnPp_Attack(EnPp* this, PlayState* play) { + f32 curFrame = this->skelAnime.curFrame; + + SkelAnime_Update(&this->skelAnime); + if (this->endFrame <= curFrame) { + EnPp_SetupCharge(this); + } +} + +void EnPp_SetupBounced(EnPp* this) { + Vec3f distanceFromWorldPos; + s32 yawDiff = ABS_ALT(BINANG_SUB(this->actor.yawTowardsPlayer, this->actor.home.rot.y)); + + this->targetRotY = this->actor.home.rot.y + 0x8000; + if (yawDiff < 0x3000) { + this->targetRotY = this->actor.home.rot.y; + } + + Math_Vec3f_Copy(&this->targetPos, &this->actor.world.pos); + Matrix_RotateYS(this->targetRotY, MTXMODE_NEW); + Matrix_MultVecZ(-200.0f, &distanceFromWorldPos); + this->timer = 10; + this->targetPos.x += distanceFromWorldPos.x; + this->targetPos.z += distanceFromWorldPos.z; + EnPp_ChangeAnim(this, EN_PP_ANIM_DAMAGE); + this->actor.speedXZ = 0.0f; + this->action = EN_PP_ACTION_BOUNCED; + this->chargeAndBounceSpeed = 14.0f; + this->actionFunc = EnPp_Bounced; +} + +/** + * Pushes the Hiploop back for a half-second, then forces it to charge again. + */ +void EnPp_Bounced(EnPp* this, PlayState* play) { + Math_ApproachF(&this->actor.world.pos.x, this->targetPos.x, 0.5f, + fabsf(Math_SinS(this->targetRotY) * this->chargeAndBounceSpeed)); + Math_ApproachF(&this->actor.world.pos.z, this->targetPos.z, 0.5f, + fabsf(Math_CosS(this->targetRotY) * this->chargeAndBounceSpeed)); + Math_ApproachZeroF(&this->chargeAndBounceSpeed, 0.3f, 0.2f); + if ((this->timer == 0) && (EnPp_PointlessPosCheck(this))) { + EnPp_SetupCharge(this); + } +} + +void EnPp_SetupRoar(EnPp* this) { + this->actionVar.hasDoneFirstRoar = false; + this->timer = 20; + this->secondaryTimer = 0; + this->chargeAndBounceSpeed = 14.0f; + EnPp_ChangeAnim(this, EN_PP_ANIM_ROAR); + this->action = EN_PP_ACTION_ROAR; + this->actionFunc = EnPp_Roar; +} + +/** + * Slows the Hiploop down and makes it do two roars. Afterwards, it will make the Hiploop charge again. + */ +void EnPp_Roar(EnPp* this, PlayState* play) { + Player* player = GET_PLAYER(play); + f32 curFrame = this->skelAnime.curFrame; + + SkelAnime_Update(&this->skelAnime); + + if (EnPp_CheckCollision(this, play) == EN_PP_COLLISION_RESULT_ABOUT_TO_RUN_OFF_LEDGE) { + this->actor.speedXZ = 0.0f; + this->chargeAndBounceSpeed = 0.0f; + } + + if (!this->chargesInStraightLines) { + if ((fabsf(this->actor.home.pos.y - this->actor.world.pos.y) > 100.0f) && + (fabsf(this->actor.floorHeight - player->actor.floorHeight) > 100.0f)) { + EnPp_SetupDead(this, play); + return; + } + } else if (this->chargeAndBounceSpeed) { + Math_ApproachF(&this->actor.world.pos.x, this->targetPos.x, 0.5f, + fabsf(Math_SinS(this->targetRotY) * this->chargeAndBounceSpeed)); + Math_ApproachF(&this->actor.world.pos.z, this->targetPos.z, 0.5f, + fabsf(Math_CosS(this->targetRotY) * this->chargeAndBounceSpeed)); + if (this->timer < 10) { + Math_ApproachZeroF(&this->chargeAndBounceSpeed, 0.3f, 0.2f); + } + } + + Math_ApproachZeroF(&this->actor.speedXZ, 0.5f, 1.0f); + if ((this->actor.speedXZ > 0.3f) && (this->secondaryTimer == 0)) { + EnPp_SpawnDust(this, play); + this->secondaryTimer = 3; + } + + if (!this->actionVar.hasDoneFirstRoar && (this->endFrame <= curFrame)) { + this->skelAnime.startFrame = 6.0f; + this->actionVar.hasDoneFirstRoar = true; + } + + if (this->timer == 0) { + EnPp_SetupCharge(this); + } +} + +void EnPp_SetupJump(EnPp* this) { + s32 yawDiff; + + this->secondaryTimer = 0; + this->actionVar.hasLandedFromJump = false; + this->timer = this->secondaryTimer; + this->actor.speedXZ = 0.0f; + this->actor.velocity.y = 20.0f; + this->actor.gravity = -3.0f; + EnPp_ChangeAnim(this, EN_PP_ANIM_JUMP); + + if (this->chargesInStraightLines) { + yawDiff = ABS_ALT(BINANG_SUB(this->actor.yawTowardsPlayer, this->actor.home.rot.y)); + this->actor.world.rot.y = this->actor.home.rot.y + 0x8000; + if (yawDiff < 0x3000) { + this->actor.world.rot.y = this->actor.home.rot.y; + } + + this->targetRotY = this->actor.world.rot.y; + } + + this->actionVar.hasLandedFromJump = false; + this->action = EN_PP_ACTION_JUMP; + this->actionFunc = EnPp_Jump; +} + +/** + * Makes the Hiploop jump straight up. Once it lands, the Hiploop will be forced to be idle. + */ +void EnPp_Jump(EnPp* this, PlayState* play) { + f32 curFrame = this->skelAnime.curFrame; + s32 yawDiff; + + SkelAnime_Update(&this->skelAnime); + + if (this->chargesInStraightLines) { + yawDiff = ABS_ALT(BINANG_SUB(this->actor.yawTowardsPlayer, this->actor.home.rot.y)); + this->targetRotY = this->actor.home.rot.y + 0x8000; + if (yawDiff < 0x3000) { + this->targetRotY = this->actor.home.rot.y; + } + + EnPp_PointlessPosCheck(this); + } else { + this->targetRotY = this->actor.yawTowardsPlayer; + } + + Math_SmoothStepToS(&this->actor.world.rot.y, this->targetRotY, 1, 0x1388, 0); + if (!this->actionVar.hasLandedFromJump) { + if (this->actor.bgCheckFlags & 1) { + this->actionVar.hasLandedFromJump = true; + EnPp_ChangeAnim(this, EN_PP_ANIM_LAND); + } + } else if (this->endFrame <= curFrame) { + EnPp_SetupIdle(this); + } +} + +void EnPp_SetupStunnedOrFrozen(EnPp* this) { + if (((this->drawDmgEffType == ACTOR_DRAW_DMGEFF_FROZEN_SFX) || + (this->drawDmgEffType == ACTOR_DRAW_DMGEFF_FROZEN_NO_SFX)) && + (this->drawDmgEffTimer == 0)) { + this->drawDmgEffTimer = 0; + this->drawDmgEffType = ACTOR_DRAW_DMGEFF_FIRE; + } + + this->actor.speedXZ = 0.0f; + this->action = EN_PP_ACTION_STUNNED_OR_FROZEN; + this->actionFunc = EnPp_StunnedOrFrozen; +} + +/** + * Locks the Hiploop in place until the draw damage effect timer or the stun timer reaches 0. + * When the stun wears off, this forces the Hiploop to charge. + */ +void EnPp_StunnedOrFrozen(EnPp* this, PlayState* play) { + if (this->drawDmgEffType == ACTOR_DRAW_DMGEFF_FROZEN_SFX) { + if ((this->drawDmgEffTimer != 0) && (this->drawDmgEffTimer < 60)) { + this->drawDmgEffType = ACTOR_DRAW_DMGEFF_FROZEN_NO_SFX; + } + } + + if ((this->secondaryTimer == 0) && (this->drawDmgEffTimer == 0)) { + if ((this->drawDmgEffType == ACTOR_DRAW_DMGEFF_FROZEN_SFX) || + (this->drawDmgEffType == ACTOR_DRAW_DMGEFF_FROZEN_NO_SFX)) { + Actor_SpawnIceEffects(play, &this->actor, this->bodyPartsPos, ARRAY_COUNT(this->bodyPartsPos), 2, 0.7f, + 0.4f); + this->drawDmgEffTimer = 0; + this->drawDmgEffType = ACTOR_DRAW_DMGEFF_FIRE; + } + + EnPp_SetupCharge(this); + } +} + +void EnPp_SetupDamaged(EnPp* this, PlayState* play) { + Vec3f temp; + s32 pad; + s32 yawDiff; + + if (!this->chargesInStraightLines) { + Matrix_RotateYS(this->actor.yawTowardsPlayer, MTXMODE_NEW); + Matrix_MultVecZ(-30.0f, &temp); + Math_Vec3f_Copy(&this->damagedVelocity, &temp); + } else { + yawDiff = ABS_ALT(BINANG_SUB(this->actor.yawTowardsPlayer, this->actor.home.rot.y)); + this->targetRotY = this->actor.home.rot.y + 0x8000; + if (yawDiff < 0x3000) { + this->targetRotY = this->actor.home.rot.y; + } + + Math_Vec3f_Copy(&this->targetPos, &this->actor.world.pos); + Matrix_RotateYS(this->targetRotY, MTXMODE_NEW); + Matrix_MultVecZ(-200.0f, &temp); + this->timer = 10; + this->targetPos.x += temp.x; + this->targetPos.z += temp.z; + } + + if (((this->drawDmgEffType == ACTOR_DRAW_DMGEFF_FROZEN_SFX) || + (this->drawDmgEffType == ACTOR_DRAW_DMGEFF_FROZEN_NO_SFX)) && + (this->drawDmgEffTimer != 0)) { + Actor_SpawnIceEffects(play, &this->actor, this->bodyPartsPos, ARRAY_COUNT(this->bodyPartsPos), 2, 0.7f, 0.4f); + this->drawDmgEffTimer = 0; + this->drawDmgEffType = ACTOR_DRAW_DMGEFF_FIRE; + } + + Actor_SetColorFilter(&this->actor, 0x4000, 255, 0, 8); + this->secondaryTimer = 0; + EnPp_ChangeAnim(this, EN_PP_ANIM_DAMAGE); + this->targetRotY = this->actor.yawTowardsPlayer + 0x8000; + this->action = EN_PP_ACTION_DAMAGED; + if (EnPp_CheckCollision(this, play) == EN_PP_COLLISION_RESULT_ABOUT_TO_RUN_OFF_LEDGE) { + this->damagedVelocity.z = 0.0f; + this->damagedVelocity.x = 0.0f; + this->actor.speedXZ = 0.0f; + } + + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_HIPLOOP_DAMAGE); + this->actionFunc = EnPp_Damaged; +} + +/** + * Makes the Hiploop move backwards and spin quickly. + */ +void EnPp_Damaged(EnPp* this, PlayState* play) { + Player* player = GET_PLAYER(play); + + SkelAnime_Update(&this->skelAnime); + this->actor.world.rot.y += 0x1000; + if (this->secondaryTimer == 0) { + EnPp_SpawnDust(this, play); + this->secondaryTimer = 3; + } + + if (this->chargesInStraightLines) { + Math_ApproachF(&this->actor.world.pos.x, this->targetPos.x, 0.5f, 25.0f); + Math_ApproachF(&this->actor.world.pos.z, this->targetPos.z, 0.5f, 25.0f); + this->actor.world.rot.y += 0x1000; + if ((this->timer == 0) && (EnPp_PointlessPosCheck(this))) { + EnPp_SetupCharge(this); + } + } else if ((this->actor.colorFilterTimer == 0) && (this->damagedVelocity.x < 1.0f) && + (this->damagedVelocity.z < 1.0f)) { + EnPp_SetupCharge(this); + } + + if (EnPp_CheckCollision(this, play) == EN_PP_COLLISION_RESULT_ABOUT_TO_RUN_OFF_LEDGE) { + this->damagedVelocity.z = 0.0f; + this->damagedVelocity.x = 0.0f; + this->actor.speedXZ = 0.0f; + } + + if ((fabsf(this->actor.home.pos.y - this->actor.world.pos.y) > 100.0f) && + (fabsf(this->actor.floorHeight - player->actor.floorHeight) > 100.0f)) { + EnPp_SetupDead(this, play); + } +} + +void EnPp_SetupDead(EnPp* this, PlayState* play) { + Vec3f deadVelocity; + s32 yawDiff; + + this->secondaryTimer = this->timer = 0; + if (!this->chargesInStraightLines) { + Matrix_RotateYS(this->actor.yawTowardsPlayer, MTXMODE_NEW); + Matrix_MultVecZ(-30.0f, &deadVelocity); + Math_Vec3f_Copy(&this->damagedVelocity, &deadVelocity); + } else { + yawDiff = ABS_ALT(BINANG_SUB(this->actor.yawTowardsPlayer, this->actor.home.rot.y)); + this->targetRotY = this->actor.home.rot.y + 0x8000; + if (yawDiff < 0x3000) { + this->targetRotY = this->actor.home.rot.y; + } + + Math_Vec3f_Copy(&this->targetPos, &this->actor.world.pos); + Matrix_RotateYS(this->targetRotY, MTXMODE_NEW); + Matrix_MultVecZ(-200.0f, &deadVelocity); + this->targetPos.x += deadVelocity.x; + this->targetPos.z += deadVelocity.z; + } + + this->maskBounceRotationalVelocity = this->actionVar.isCharging = 0; + EnPp_ChangeAnim(this, EN_PP_ANIM_DAMAGE); + this->timer = 15; + if (((this->drawDmgEffType == ACTOR_DRAW_DMGEFF_FROZEN_SFX) || + (this->drawDmgEffType == ACTOR_DRAW_DMGEFF_FROZEN_NO_SFX)) && + (this->drawDmgEffTimer == 0)) { + this->drawDmgEffType = ACTOR_DRAW_DMGEFF_FIRE; + } + + Actor_SetColorFilter(&this->actor, 0x4000, 255, 0, 25); + Enemy_StartFinishingBlow(play, &this->actor); + SoundSource_PlaySfxAtFixedWorldPos(play, &this->actor.world.pos, 30, NA_SE_EN_HIPLOOP_DEAD); + this->actor.flags |= ACTOR_FLAG_8000000; + this->actor.flags &= ~ACTOR_FLAG_1; + this->action = EN_PP_ACTION_DEAD; + this->actionFunc = EnPp_Dead; +} + +/** + * Makes the Hiploop move backwards and spin even quicker than when it's damaged. + * If the Hiploop ends up in the water while it's moving backwards, this function + * will make some splashes too. After a short amount of time, this will spawn body + * parts that fly away from the Hiploop. + */ +void EnPp_Dead(EnPp* this, PlayState* play) { + Vec3f splashPos; + WaterBox* waterBox; + f32 waterSurface; + s32 isUnderWater; + s32 i; + + SkelAnime_Update(&this->skelAnime); + this->actor.world.rot.y += 0x3000; + waterSurface = this->actor.world.pos.y - 30.0f; + if ((this->drawDmgEffType == ACTOR_DRAW_DMGEFF_FROZEN_SFX) || + (this->drawDmgEffType == ACTOR_DRAW_DMGEFF_FROZEN_NO_SFX)) { + if (this->drawDmgEffTimer == 0) { + return; + } + + Actor_SpawnIceEffects(play, &this->actor, this->bodyPartsPos, ARRAY_COUNT(this->bodyPartsPos), 2, 0.7f, 0.4f); + this->drawDmgEffTimer = 0; + this->drawDmgEffType = ACTOR_DRAW_DMGEFF_FIRE; + } + + if (this->secondaryTimer == 0) { + EnPp_SpawnDust(this, play); + this->secondaryTimer = 3; + } + + isUnderWater = false; + if ((this->action == EN_PP_ACTION_DEAD) && + (WaterBox_GetSurface1(play, &play->colCtx, this->actor.world.pos.x, this->actor.world.pos.z, &waterSurface, + &waterBox))) { + if (this->actor.world.pos.y < waterSurface) { + for (i = 0; i < 5; i++) { + Math_Vec3f_Copy(&splashPos, &this->actor.world.pos); + splashPos.x += randPlusMinusPoint5Scaled(10 + (5 * i)); + splashPos.z += randPlusMinusPoint5Scaled(40 + (5 * i)); + EffectSsGSplash_Spawn(play, &splashPos, NULL, NULL, 0, (Rand_ZeroOne() * 100.0f) + 400.0f); + } + + SoundSource_PlaySfxAtFixedWorldPos(play, &this->actor.world.pos, 50, NA_SE_EV_BOMB_DROP_WATER); + isUnderWater = true; + } + } + + if (this->chargesInStraightLines) { + Math_ApproachF(&this->actor.world.pos.x, this->targetPos.x, 0.5f, 25.0f); + Math_ApproachF(&this->actor.world.pos.z, this->targetPos.z, 0.5f, 25.0f); + } + + if ((this->action == EN_PP_ACTION_DEAD) && (isUnderWater || (this->timer == 1))) { + this->action = EN_PP_ACTION_SPAWN_BODY_PARTS; + } + + if (this->action == EN_PP_ACTION_DONE_SPAWNING_BODY_PARTS) { + if (EN_PP_GET_TYPE(&this->actor) == EN_PP_TYPE_UNMASKED) { + Item_DropCollectibleRandom(play, NULL, &this->actor.world.pos, 0x70); + } else { + Item_DropCollectibleRandom(play, NULL, &this->actor.world.pos, 0xE0); + } + + Actor_MarkForDeath(&this->actor); + } +} + +/** + * Spawns an unmasked Hiploop and prepares the mask to fly through the air. + */ +void EnPp_Mask_SetupDetach(EnPp* this, PlayState* play) { + s32 yawDiff; + EnPp* pp = (EnPp*)Actor_Spawn(&play->actorCtx, play, ACTOR_EN_PP, this->actor.world.pos.x, this->actor.world.pos.y, + this->actor.world.pos.z, this->actor.world.rot.x, this->actor.shape.rot.y, + this->actor.world.rot.z, EN_PP_TYPE_UNMASKED); + + if (pp != NULL) { + if (this->chargesInStraightLines) { + yawDiff = ABS_ALT(BINANG_SUB(this->actor.yawTowardsPlayer, this->actor.home.rot.y)); + pp->chargesInStraightLines = true; + pp->actor.world.rot.y = this->actor.home.rot.y + 0x8000; + if (yawDiff < 0x3000) { + pp->actor.world.rot.y = this->actor.home.rot.y; + } + } + + this->actor.gravity = 0.0f; + this->actor.flags |= ACTOR_FLAG_8000000; + this->actor.flags &= ~ACTOR_FLAG_1; + this->actionVar.maskDetachState = EN_PP_MASK_DETACH_STATE_START; + EnPp_ChangeAnim(this, EN_PP_ANIM_IDLE); + SkelAnime_Update(&this->skelAnime); + this->action = EN_PP_ACTION_MASK_DETACH; + this->actionFunc = EnPp_Mask_Detach; + } +} + +/** + * Moves the mask through the air and eventually makes it burst into flames. + */ +void EnPp_Mask_Detach(EnPp* this, PlayState* play) { + if (((this->actor.flags & ACTOR_FLAG_2000) != ACTOR_FLAG_2000) || (this->action == EN_PP_ACTION_MASK_DEAD)) { + switch (this->actionVar.maskDetachState) { + case EN_PP_MASK_DETACH_STATE_START: + this->action = EN_PP_ACTION_MASK_DEAD; + this->maskAccelY = 50.0f; + this->maskVelocity.y = -230.0f; + this->maskVelocity.x = -150.0f; + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_HIPLOOP_MASC_OFF); + this->actionVar.maskDetachState = EN_PP_MASK_DETACH_STATE_FALL; + break; + + case EN_PP_MASK_DETACH_STATE_FALL: + if (this->maskPos.y > 800.0f) { + this->maskAccelY = 50.0f; + this->actionVar.maskDetachState++; + this->maskVelocity.y = -200.0f; + this->maskVelocity.x = -150.0f; + } + break; + + case EN_PP_MASK_DETACH_STATE_DIE: + if (this->maskPos.y > 900.0f) { + if (this->maskVelocity.y > 0.0f) { + Vec3f maskFirePos; + Vec3f sMaskFireVelocityAndAccel[] = { + { 1.0f, 0.0f, 0.5f }, { 1.0f, 0.0f, -0.5f }, { -1.0f, 0.0f, 0.5f }, + { -1.0f, 0.0f, -0.5f }, { 0.5f, 0.0f, 1.0f }, { -0.5f, 0.0f, 1.0f }, + { 0.5f, 0.0f, -1.0f }, { -0.5f, 0.0f, -1.0f }, { 0.0f, 0.0f, 0.0f }, + }; + s32 i; + + for (i = 0; i < ARRAY_COUNT(sMaskFireVelocityAndAccel); i++) { + Math_Vec3f_Copy(&maskFirePos, &this->maskFlamesBasePos); + maskFirePos.x += randPlusMinusPoint5Scaled(20.0f); + maskFirePos.y = this->actor.floorHeight; + maskFirePos.z += randPlusMinusPoint5Scaled(20.0f); + func_800B3030(play, &maskFirePos, &sMaskFireVelocityAndAccel[i], + &sMaskFireVelocityAndAccel[i], 70, 0, 2); + } + + Actor_MarkForDeath(&this->actor); + } + } + break; + } + + this->maskVelocity.y += this->maskAccelY; + this->maskRot.z += 0x2000; + this->maskPos.x += this->maskVelocity.x; + this->maskPos.y += this->maskVelocity.y; + this->maskPos.z += this->maskVelocity.z; + } +} + +void EnPp_BodyPart_SetupMove(EnPp* this) { + EnPp_ChangeAnim(this, EN_PP_ANIM_DAMAGE); + this->actor.velocity.y = Rand_ZeroFloat(5.0f) + 13.0f; + this->actor.gravity = -2.0f; + this->timer = Rand_S16Offset(30, 30); + this->deadBodyPartRotationalVelocity.x = (this->deadBodyPartIndex * 0x2E) + 0xFF00; + this->deadBodyPartRotationalVelocity.z = (this->deadBodyPartIndex * 0x2E) + 0xFF00; + if (EN_PP_GET_TYPE(&this->actor) != EN_PP_TYPE_BODY_PART_BODY) { + this->actor.speedXZ = Rand_ZeroFloat(4.0f) + 4.0f; + this->actor.world.rot.y = ((s32)randPlusMinusPoint5Scaled(223.0f) + 0x1999) * this->deadBodyPartIndex; + } + + this->action = EN_PP_ACTION_BODY_PART_MOVE; + this->actionFunc = EnPp_BodyPart_Move; +} + +/** + * Makes the body part fly through the air. If it touches water, it will make a splash. + */ +void EnPp_BodyPart_Move(EnPp* this, PlayState* play) { + s32 pad; + Vec3f splashPos; + WaterBox* waterBox; + f32 waterSurface; + s32 i; + + SkelAnime_Update(&this->skelAnime); + if (EN_PP_GET_TYPE(&this->actor) == EN_PP_TYPE_BODY_PART_BODY) { + this->deadBodyPartDrawDmgEffCount = 10; + for (i = 0; i < ARRAY_COUNT(this->deadBodyPartDrawDmgEffPos); i++) { + Math_Vec3f_Copy(&this->deadBodyPartDrawDmgEffPos[i], &this->deadBodyPartPos); + this->deadBodyPartDrawDmgEffPos[i].x += Math_SinS(0xCCC * i) * 15.0f; + this->deadBodyPartDrawDmgEffPos[i].y += -5.0f; + this->deadBodyPartDrawDmgEffPos[i].z += Math_CosS(0xCCC * i) * 15.0f; + } + } else { + Math_Vec3f_Copy(&this->deadBodyPartDrawDmgEffPos[0], &this->deadBodyPartPos); + this->deadBodyPartDrawDmgEffCount = 1; + this->actor.shape.rot.x += this->deadBodyPartRotationalVelocity.x; + this->actor.shape.rot.z += this->deadBodyPartRotationalVelocity.z; + } + + if (WaterBox_GetSurface1(play, &play->colCtx, this->actor.world.pos.x, this->actor.world.pos.z, &waterSurface, + &waterBox) && + (this->actor.world.pos.y < (waterSurface + 5.0f))) { + this->timer = 0; + if (EN_PP_GET_TYPE(&this->actor) == EN_PP_TYPE_BODY_PART_BODY) { + for (i = 0; i < 6; i++) { + Math_Vec3f_Copy(&splashPos, &this->actor.world.pos); + splashPos.x += randPlusMinusPoint5Scaled(10 + (5 * i)); + splashPos.z += randPlusMinusPoint5Scaled(40 + (5 * i)); + EffectSsGSplash_Spawn(play, &splashPos, NULL, NULL, 0, (Rand_ZeroOne() * 100.0f) + 400.0f); + } + } else { + EffectSsGSplash_Spawn(play, &this->actor.world.pos, NULL, NULL, 0, 400); + } + + SoundSource_PlaySfxAtFixedWorldPos(play, &this->actor.world.pos, 50, NA_SE_EV_BOMB_DROP_WATER); + } + + if ((this->timer == 0) || (this->actor.bgCheckFlags & 1)) { + Actor_MarkForDeath(&this->actor); + } +} + +void EnPp_UpdateDamage(EnPp* this, PlayState* play) { + s16 yawDiff = ABS_ALT(BINANG_SUB(this->actor.yawTowardsPlayer, this->actor.world.rot.y)); + s32 attackBouncedOffMask = false; + s32 attackDealsDamage = false; + + if (EN_PP_GET_TYPE(&this->actor) == EN_PP_TYPE_MASKED) { + if ((yawDiff < (BREG(2) + 0x4A9C)) || (EN_PP_GET_TYPE(&this->actor) > EN_PP_TYPE_MASKED)) { + this->actor.flags |= ACTOR_FLAG_200; + } else { + this->actor.flags &= ~ACTOR_FLAG_200; + } + } + + if ((EN_PP_GET_TYPE(&this->actor) == EN_PP_TYPE_MASKED) && (this->action < EN_PP_ACTION_MASK_DETACH)) { + if (this->maskCollider.elements[0].info.bumperFlags & BUMP_HIT) { + if (yawDiff < (BREG(2) + 0x4A9C)) { + if (this->actor.colChkInfo.damageEffect == EN_PP_DMGEFF_HOOKSHOT) { + EnPp_Mask_SetupDetach(this, play); + } else if ((this->actor.colChkInfo.damageEffect == EN_PP_DMGEFF_GORON_POUND) || + (this->actor.colChkInfo.damageEffect == EN_PP_DMGEFF_KNOCK_OFF_MASK)) { + EnPp_Mask_SetupDetach(this, play); + this->action = EN_PP_ACTION_MASK_DEAD; + } + } else { + attackBouncedOffMask = true; + } + } else if (this->maskCollider.elements[0].info.bumperFlags & BUMP_HIT) { + attackBouncedOffMask = true; + } + } + + if (this->bodyCollider.elements[0].info.bumperFlags & BUMP_HIT) { + if (EN_PP_GET_TYPE(&this->actor) != EN_PP_TYPE_MASKED) { + if ((this->action < EN_PP_ACTION_DAMAGED) && (this->action != EN_PP_ACTION_JUMP)) { + if (this->actor.colChkInfo.damageEffect == EN_PP_DMGEFF_HOOKSHOT) { + if (EN_PP_GET_TYPE(&this->actor) == EN_PP_TYPE_MASKED) { + return; + } + attackDealsDamage = true; + } + + if (this->actor.colChkInfo.damageEffect == EN_PP_DMGEFF_ELECTRIC_STUN) { + if (((this->drawDmgEffType != ACTOR_DRAW_DMGEFF_FROZEN_SFX) && + (this->drawDmgEffType != ACTOR_DRAW_DMGEFF_FROZEN_NO_SFX)) || + (this->drawDmgEffTimer == 0)) { + this->drawDmgEffTimer = 40; + this->drawDmgEffType = ACTOR_DRAW_DMGEFF_ELECTRIC_SPARKS_SMALL; + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_COMMON_FREEZE); + Actor_SetColorFilter(&this->actor, 0, 255, 0, 40); + EnPp_SetupStunnedOrFrozen(this); + } + return; + } else if (this->actor.colChkInfo.damageEffect == EN_PP_DMGEFF_STUN) { + if (((this->drawDmgEffType != ACTOR_DRAW_DMGEFF_FROZEN_SFX) && + (this->drawDmgEffType != ACTOR_DRAW_DMGEFF_FROZEN_NO_SFX)) || + (this->drawDmgEffTimer == 0)) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_COMMON_FREEZE); + Actor_SetColorFilter(&this->actor, 0, 255, 0, 40); + this->secondaryTimer = 40; + EnPp_SetupStunnedOrFrozen(this); + } + return; + } else if ((this->actor.colChkInfo.damageEffect != EN_PP_DMGEFF_GORON_POUND) && + (this->actor.colChkInfo.damageEffect != EN_PP_DMGEFF_JUMP)) { + attackDealsDamage = true; + this->hasBeenDamaged = true; + this->actor.speedXZ = 0.0f; + if (this->actor.colChkInfo.damageEffect == EN_PP_DMGEFF_FIRE) { + this->drawDmgEffTimer = 40; + this->drawDmgEffType = ACTOR_DRAW_DMGEFF_FIRE; + } else if (this->actor.colChkInfo.damageEffect == EN_PP_DMGEFF_FREEZE) { + if (((this->drawDmgEffType != ACTOR_DRAW_DMGEFF_FROZEN_SFX) && + (this->drawDmgEffType != ACTOR_DRAW_DMGEFF_FROZEN_NO_SFX)) || + (this->drawDmgEffTimer == 0)) { + Actor_ApplyDamage(&this->actor); + this->drawDmgEffTimer = 80; + this->drawDmgEffType = ACTOR_DRAW_DMGEFF_FROZEN_SFX; + this->drawDmgEffScale = 0.0f; + this->drawDmgEffFrozenSteamScale = 1.5f; + } + + if (this->actor.colChkInfo.health <= 0) { + EnPp_SetupDead(this, play); + } else { + EnPp_SetupStunnedOrFrozen(this); + } + return; + } else if ((this->actor.colChkInfo.damageEffect == EN_PP_DMGEFF_LIGHT_ORB) && + ((((this->drawDmgEffType != ACTOR_DRAW_DMGEFF_FROZEN_SFX)) && + (this->drawDmgEffType != ACTOR_DRAW_DMGEFF_FROZEN_NO_SFX)) || + (this->drawDmgEffTimer == 0))) { + Actor_Spawn(&play->actorCtx, play, ACTOR_EN_CLEAR_TAG, this->actor.focus.pos.x, + this->actor.focus.pos.y, this->actor.focus.pos.z, 0, 0, 0, + CLEAR_TAG_LARGE_LIGHT_RAYS); + Actor_SetColorFilter(&this->actor, 0x8000, 255, 0, 25); + this->drawDmgEffTimer = 20; + this->drawDmgEffType = ACTOR_DRAW_DMGEFF_LIGHT_ORBS; + } + } else if (this->action != EN_PP_ACTION_JUMP) { + EnPp_SetupJump(this); + } + } + + if (attackDealsDamage) { + Actor_ApplyDamage(&this->actor); + if (this->actor.colChkInfo.health > 0) { + EnPp_SetupDamaged(this, play); + } else { + EnPp_SetupDead(this, play); + } + } + } else { + attackBouncedOffMask = true; + } + } + + if (attackBouncedOffMask && (((this->action == EN_PP_ACTION_IDLE)) || (this->action == EN_PP_ACTION_CHARGE) || + (this->action == EN_PP_ACTION_ROAR))) { + this->secondaryTimer = 0; + this->timer = 10; + this->maskBounceRotationalVelocity = 0x20D0; + this->actor.speedXZ = 0.0f; + if (this->action == EN_PP_ACTION_CHARGE) { + this->actionVar.isCharging = false; + EnPp_ChangeAnim(this, EN_PP_ANIM_TURN_TO_FACE_PLAYER); + this->maskBounceRotationalVelocity = 0x1B58; + } + + this->targetRotY = this->actor.yawTowardsPlayer; + if (EN_PP_GET_TYPE(&this->actor) == EN_PP_TYPE_MASKED) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_IT_SHIELD_BOUND); + } + } +} + +void EnPp_Update(Actor* thisx, PlayState* play) { + s32 pad; + EnPp* this = THIS; + WaterBox* waterBox; + f32 waterSurface; + + DECR(this->timer); + + if (this->secondaryTimer != 0) { + this->secondaryTimer--; + } + + if (this->drawDmgEffTimer != 0) { + this->drawDmgEffTimer--; + } + + this->actionFunc(this, play); + EnPp_PlaySfxForAnimation(this); + Actor_MoveWithGravity(&this->actor); + + if (this->action != EN_PP_ACTION_BODY_PART_MOVE) { + if (EN_PP_GET_TYPE(&this->actor) > EN_PP_TYPE_MASKED) { + this->maskCollider.elements[0].dim.modelSphere.radius = 42; + this->maskCollider.elements[0].dim.modelSphere.center.x = 400; + this->maskCollider.elements[0].dim.modelSphere.center.y = -400; + this->bodyCollider.elements[0].dim.modelSphere.radius = 20; + this->bodyCollider.elements[0].dim.modelSphere.center.x = 400; + this->bodyCollider.elements[0].dim.modelSphere.center.y = -400; + } else { + this->maskCollider.elements[0].dim.modelSphere.radius = 25; + this->maskCollider.elements[0].dim.modelSphere.center.x = 780; + this->maskCollider.elements[0].dim.modelSphere.center.y = -500; + this->bodyCollider.elements[0].dim.modelSphere.radius = 25; + this->bodyCollider.elements[0].dim.modelSphere.center.x = 400; + this->bodyCollider.elements[0].dim.modelSphere.center.y = -400; + } + } + + if ((this->action < EN_PP_ACTION_DEAD) && + (WaterBox_GetSurface1(play, &play->colCtx, this->actor.world.pos.x, this->actor.world.pos.z, &waterSurface, + &waterBox)) && + (this->actor.world.pos.y < waterSurface)) { + EnPp_SetupDead(this, play); + return; + } + + if (this->action != EN_PP_ACTION_BODY_PART_MOVE) { + EnPp_UpdateDamage(this, play); + Actor_SetFocus(&this->actor, 40.0f); + if ((this->action == EN_PP_ACTION_DEAD) || (this->actor.bgCheckFlags & 1)) { + this->actor.world.pos.x += this->damagedVelocity.x; + this->actor.world.pos.z += this->damagedVelocity.z; + Math_ApproachZeroF(&this->damagedVelocity.x, 1.0f, 2.0f); + Math_ApproachZeroF(&this->damagedVelocity.z, 1.0f, 2.0f); + } + } + + Actor_UpdateBgCheckInfo(play, &this->actor, 35.0f, 40.0f, 40.0f, 0x1F); + if (this->action != EN_PP_ACTION_BODY_PART_MOVE) { + this->actor.shape.rot.y = this->actor.world.rot.y; + } + + if (this->action != EN_PP_ACTION_BODY_PART_MOVE) { + if (this->floorPolyForCircleShadow == NULL) { + this->floorPolyForCircleShadow = this->actor.floorPoly; + } + + if ((this->action < EN_PP_ACTION_DEAD) || (this->action == EN_PP_ACTION_JUMP)) { + CollisionCheck_SetAC(play, &play->colChkCtx, &this->maskCollider.base); + CollisionCheck_SetAC(play, &play->colChkCtx, &this->bodyCollider.base); + } + + if ((this->action < EN_PP_ACTION_MASK_DETACH) && (this->action != EN_PP_ACTION_STUNNED_OR_FROZEN)) { + CollisionCheck_SetAT(play, &play->colChkCtx, &this->maskCollider.base); + CollisionCheck_SetAT(play, &play->colChkCtx, &this->bodyCollider.base); + } + + CollisionCheck_SetOC(play, &play->colChkCtx, &this->bodyCollider.base); + if (this->hornColliderOn) { + CollisionCheck_SetAT(play, &play->colChkCtx, &this->hornCollider.base); + } + } +} + +s32 EnPp_OverrideLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, Actor* thisx) { + EnPp* this = THIS; + + if (this->action != EN_PP_ACTION_BODY_PART_MOVE) { + if ((limbIndex != HIPLOOP_LIMB_MASK) && + ((this->action == EN_PP_ACTION_MASK_DETACH) || (this->action == EN_PP_ACTION_MASK_DEAD))) { + *dList = NULL; + } + + if ((limbIndex == HIPLOOP_LIMB_MASK) && (EN_PP_GET_TYPE(&this->actor) != EN_PP_TYPE_MASKED)) { + *dList = NULL; + } + + if (limbIndex == HIPLOOP_LIMB_MASK) { + rot->x += (s16)this->maskRot.x; + rot->y += (s16)this->maskRot.y; + rot->z += (s16)this->maskRot.z; + pos->x += this->maskPos.x; + pos->y += this->maskPos.y; + pos->z += this->maskPos.z; + } + } else if ((limbIndex + EN_PP_TYPE_BODY_PART_BASE) != EN_PP_GET_TYPE(&this->actor)) { + *dList = NULL; + } + + return false; +} + +void EnPp_PostLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx) { + static Vec3f sVertexOffset1 = { 0.0f, 0.0f, 0.0f }; + static Vec3f sVertexOffset2 = { 0.0f, 0.0f, 0.0f }; + EnPp* this = THIS; + Vec3f blureVertex1; + Vec3f blureVertex2; + + Matrix_Push(); + + if (this->action != EN_PP_ACTION_BODY_PART_MOVE) { + if (limbIndex == HIPLOOP_LIMB_BACK_RIGHT_FOOT) { + Matrix_MultVec3f(&gZeroVec3f, &this->backFootPos[0]); + } + + if (limbIndex == HIPLOOP_LIMB_BACK_LEFT_FOOT) { + Matrix_MultVec3f(&gZeroVec3f, &this->backFootPos[1]); + } + + if ((limbIndex == HIPLOOP_LIMB_MASK) && (EN_PP_GET_TYPE(&this->actor) == EN_PP_TYPE_MASKED)) { + Matrix_MultVec3f(&gZeroVec3f, &this->maskFlamesBasePos); + if (this->hornColliderOn) { + if ((this->skelAnime.curFrame > 26.0f) || (this->action >= EN_PP_ACTION_MASK_DETACH)) { + this->hornColliderOn = false; + EffectBlure_AddSpace(Effect_GetByIndex(this->blureIndex)); + } else if ((this->skelAnime.curFrame > 0.0f) && (this->skelAnime.curFrame < 10.0f)) { + Matrix_Translate(0.0f, 0.0f, 0.0f, MTXMODE_APPLY); + sVertexOffset1.x = 1160.0f; + sVertexOffset1.y = -900.0f; + sVertexOffset1.z = 0.0f; + sVertexOffset2.x = 100.0f; + sVertexOffset2.y = 300.0f; + sVertexOffset2.z = 0.0f; + Math_Vec3f_Copy(&this->hornCollider.dim.quad[3], &this->hornCollider.dim.quad[1]); + Math_Vec3f_Copy(&this->hornCollider.dim.quad[2], &this->hornCollider.dim.quad[0]); + Matrix_MultVec3f(&sVertexOffset1, &this->hornCollider.dim.quad[1]); + Matrix_MultVec3f(&sVertexOffset2, &this->hornCollider.dim.quad[0]); + Collider_SetQuadVertices(&this->hornCollider, &this->hornCollider.dim.quad[0], + &this->hornCollider.dim.quad[1], &this->hornCollider.dim.quad[2], + &this->hornCollider.dim.quad[3]); + Matrix_MultVec3f(&sVertexOffset1, &blureVertex1); + Matrix_MultVec3f(&sVertexOffset2, &blureVertex2); + EffectBlure_AddVertex(Effect_GetByIndex(this->blureIndex), &blureVertex1, &blureVertex2); + } + } + } + } else { + if ((EN_PP_GET_TYPE(&this->actor) >= EN_PP_TYPE_BODY_PART_BASE) && + ((limbIndex + EN_PP_TYPE_BODY_PART_BASE) == EN_PP_GET_TYPE(&this->actor))) { + Matrix_MultVec3f(&gZeroVec3f, &this->deadBodyPartPos); + } + } + + Matrix_Pop(); + + if (this->action != EN_PP_ACTION_BODY_PART_MOVE) { + Collider_UpdateSpheres(limbIndex, &this->maskCollider); + Collider_UpdateSpheres(limbIndex, &this->bodyCollider); + if ((limbIndex == HIPLOOP_LIMB_BODY) || (limbIndex == HIPLOOP_LIMB_FRONT_LEFT_LOWER_LEG) || + (limbIndex == HIPLOOP_LIMB_FRONT_RIGHT_LOWER_LEG) || (limbIndex == HIPLOOP_LIMB_LEFT_WING_MIDDLE) || + (limbIndex == HIPLOOP_LIMB_BACK_RIGHT_LOWER_LEG) || (limbIndex == HIPLOOP_LIMB_RIGHT_WING_MIDDLE) || + (limbIndex == HIPLOOP_LIMB_CENTER_WING_BASE) || (limbIndex == HIPLOOP_LIMB_CENTER_WING_MIDDLE) || + (limbIndex == HIPLOOP_LIMB_BACK_LEFT_LOWER_LEG) || (limbIndex == HIPLOOP_LIMB_RIGHT_EYE) || + (limbIndex == HIPLOOP_LIMB_LEFT_EYE)) { + Matrix_MultZero(&this->bodyPartsPos[this->bodyPartsPosCount]); + this->bodyPartsPosCount++; + if (this->bodyPartsPosCount >= ARRAY_COUNT(this->bodyPartsPos)) { + this->bodyPartsPosCount = 0; + } + + if ((this->action == EN_PP_ACTION_SPAWN_BODY_PARTS) && (this->deadBodyPartsSpawnedCount < 6) && + ((limbIndex == HIPLOOP_LIMB_BODY) || (limbIndex == HIPLOOP_LIMB_FRONT_LEFT_LOWER_LEG) || + (limbIndex == HIPLOOP_LIMB_FRONT_RIGHT_LOWER_LEG) || (limbIndex == HIPLOOP_LIMB_LEFT_WING_MIDDLE) || + (limbIndex == HIPLOOP_LIMB_RIGHT_WING_MIDDLE) || (limbIndex == HIPLOOP_LIMB_CENTER_WING_MIDDLE))) { + Actor_Spawn(&play->actorCtx, play, ACTOR_EN_PP, 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, limbIndex + 7); + this->deadBodyPartsSpawnedCount++; + if (this->deadBodyPartsSpawnedCount >= 6) { + this->action = EN_PP_ACTION_DONE_SPAWNING_BODY_PARTS; + } + } + } + } +} + +void EnPp_Draw(Actor* thisx, PlayState* play) { + EnPp* this = THIS; + MtxF mtxF; + Vec3f pos; + f32 scale; + f32 alpha; + + func_8012C2DC(play->state.gfxCtx); + func_8012C28C(play->state.gfxCtx); + SkelAnime_DrawFlexOpa(play, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, + EnPp_OverrideLimbDraw, EnPp_PostLimbDraw, &this->actor); + + if (this->deadBodyPartDrawDmgEffCount != 0) { + scale = 0.4f; + if (EN_PP_GET_TYPE(&this->actor) == EN_PP_TYPE_BODY_PART_BODY) { + scale = 0.6f; + } + + Actor_DrawDamageEffects(play, &this->actor, this->deadBodyPartDrawDmgEffPos, this->deadBodyPartDrawDmgEffCount, + scale, scale, 1.0f, ACTOR_DRAW_DMGEFF_BLUE_FIRE); + } + + if (this->drawDmgEffTimer != 0) { + alpha = this->drawDmgEffTimer * 0.05f; + if ((this->drawDmgEffType == ACTOR_DRAW_DMGEFF_FROZEN_SFX) || + (this->drawDmgEffType == ACTOR_DRAW_DMGEFF_FROZEN_NO_SFX)) { + this->drawDmgEffScale += 0.3f; + if (this->drawDmgEffScale > 0.5f) { + this->drawDmgEffScale = 0.5f; + } + + Math_ApproachF(&this->drawDmgEffFrozenSteamScale, this->drawDmgEffScale, 0.1f, 0.04f); + } else { + this->drawDmgEffScale = 0.8f; + this->drawDmgEffFrozenSteamScale = 0.8f; + } + + Actor_DrawDamageEffects(play, &this->actor, this->bodyPartsPos, ARRAY_COUNT(this->bodyPartsPos), + this->drawDmgEffScale, this->drawDmgEffFrozenSteamScale, alpha, this->drawDmgEffType); + } + + if (this->floorPolyForCircleShadow != NULL) { + if ((this->action != EN_PP_ACTION_MASK_DETACH) && (this->action < EN_PP_ACTION_DEAD)) { + OPEN_DISPS(play->state.gfxCtx); + + func_8012C448(play->state.gfxCtx); + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 0, 0, 0, 255); + + Math_Vec3f_Copy(&pos, &this->actor.world.pos); + pos.x += (Math_SinS(this->actor.world.rot.y) * -13.0f); + pos.y = this->actor.floorHeight; + pos.z += (Math_CosS(this->actor.world.rot.y) * -13.0f); + func_800C0094(this->actor.floorPoly, pos.x, pos.y, pos.z, &mtxF); + + Matrix_Mult(&mtxF, MTXMODE_NEW); + Matrix_Scale(0.5f, 1.0f, 0.5f, MTXMODE_APPLY); + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_XLU_DISP++, gCircleShadowDL); + + CLOSE_DISPS(play->state.gfxCtx); + } + } +} diff --git a/src/overlays/actors/ovl_En_Pp/z_en_pp.h b/src/overlays/actors/ovl_En_Pp/z_en_pp.h index 7a5bf2c33..291c6473b 100644 --- a/src/overlays/actors/ovl_En_Pp/z_en_pp.h +++ b/src/overlays/actors/ovl_En_Pp/z_en_pp.h @@ -2,16 +2,82 @@ #define Z_EN_PP_H #include "global.h" +#include "objects/object_pp/object_pp.h" struct EnPp; -typedef void (*EnPpActionFunc)(struct EnPp*, GlobalContext*); +typedef void (*EnPpActionFunc)(struct EnPp*, PlayState*); + +#define EN_PP_GET_TYPE(thisx) ((thisx)->params) +#define EN_PP_DOES_CHARGE_IN_STRAIGHT_LINES(thisx) (((thisx)->params >> 8) & 1) +#define EN_PP_GET_ATTACK_RANGE(thisx) ((thisx)->world.rot.z) + +typedef enum { + /* 0 */ EN_PP_TYPE_MASKED, + /* 1 */ EN_PP_TYPE_NO_MASK, + /* 2 */ EN_PP_TYPE_UNMASKED, + /* 7 */ EN_PP_TYPE_BODY_PART_BASE = 7, + /* 8 */ EN_PP_TYPE_BODY_PART_BODY, + /* 10 */ EN_PP_TYPE_BODY_PART_FRONT_LEFT_LOWER_LEG = 10, + /* 13 */ EN_PP_TYPE_BODY_PART_FRONT_RIGHT_LOWER_LEG = 13, + /* 17 */ EN_PP_TYPE_BODY_PART_LEFT_WING_MIDDLE = 17, + /* 23 */ EN_PP_TYPE_BODY_PART_RIGHT_WING_MIDDLE = 23, + /* 26 */ EN_PP_TYPE_BODY_PART_CENTER_WING_MIDDLE = 26, +} EnPpType; typedef struct EnPp { - /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x17C]; - /* 0x02C0 */ EnPpActionFunc actionFunc; - /* 0x02C4 */ char unk_2C4[0x328]; + /* 0x000 */ Actor actor; + /* 0x144 */ SkelAnime skelAnime; + /* 0x188 */ Vec3s jointTable[HIPLOOP_LIMB_MAX]; + /* 0x224 */ Vec3s morphTable[HIPLOOP_LIMB_MAX]; + /* 0x2C0 */ EnPpActionFunc actionFunc; + /* 0x2C4 */ s16 chargesInStraightLines; // If false, the Hiploop will instead charge directly at the player. + /* 0x2C6 */ s16 deadBodyPartIndex; + /* 0x2C8 */ s16 action; + /* 0x2CA */ s16 timer; + /* 0x2CC */ s16 secondaryTimer; + /* 0x2C8 */ s16 hornColliderOn; + /* 0x2D0 */ s16 targetRotY; + /* 0x2D2 */ union { + s16 isCharging; + s16 hasDoneFirstRoar; + s16 hasLandedFromJump; + s16 maskDetachState; + } actionVar; + /* 0x2D4 */ s16 maskBounceRotationalVelocity; // Controls the speed that the Hiploop rotates to face the player when an attack bounces off the mask. + /* 0x2D6 */ s16 deadBodyPartsSpawnedCount; + /* 0x2D8 */ f32 endFrame; + /* 0x2DC */ f32 chargeAndBounceSpeed; + /* 0x2DC */ Vec3f ledgeCheckPos[3]; + /* 0x304 */ Vec3f wallCheckPos; + /* 0x310 */ Vec3f backFootPos[2]; + /* 0x328 */ Vec3f maskFlamesBasePos; + /* 0x334 */ Vec3f maskPos; + /* 0x340 */ Vec3f maskRot; + /* 0x34C */ Vec3f maskVelocity; + /* 0x358 */ Vec3f targetPos; + /* 0x364 */ Vec3f deadBodyPartPos; + /* 0x370 */ s32 deadBodyPartDrawDmgEffCount; + /* 0x374 */ Vec3f deadBodyPartDrawDmgEffPos[10]; + /* 0x3EC */ Vec3s deadBodyPartRotationalVelocity; + /* 0x3F2 */ s16 drawDmgEffTimer; + /* 0x3F4 */ s16 drawDmgEffType; + /* 0x3F8 */ f32 drawDmgEffScale; + /* 0x3FC */ f32 drawDmgEffFrozenSteamScale; + /* 0x400 */ f32 attackRange; + /* 0x404 */ s32 hasBeenDamaged; + /* 0x408 */ Vec3f bodyPartsPos[11]; + /* 0x48C */ s16 bodyPartsPosCount; + /* 0x490 */ f32 maskAccelY; + /* 0x494 */ ColliderJntSph maskCollider; + /* 0x4B4 */ ColliderJntSphElement maskColliderElements[1]; + /* 0x4F4 */ ColliderJntSph bodyCollider; + /* 0x514 */ ColliderJntSphElement bodyColliderElements[1]; + /* 0x554 */ ColliderQuad hornCollider; + /* 0x5D4 */ CollisionPoly* floorPolyForCircleShadow; + /* 0x5D8 */ s32 blureIndex; + /* 0x5DC */ s32 animIndex; + /* 0x5DC */ Vec3f damagedVelocity; } EnPp; // size = 0x5EC extern const ActorInit En_Pp_InitVars; diff --git a/src/overlays/actors/ovl_En_Pr/z_en_pr.c b/src/overlays/actors/ovl_En_Pr/z_en_pr.c index 8c5d417f3..c7fae7c88 100644 --- a/src/overlays/actors/ovl_En_Pr/z_en_pr.c +++ b/src/overlays/actors/ovl_En_Pr/z_en_pr.c @@ -12,24 +12,24 @@ #define THIS ((EnPr*)thisx) -void EnPr_Init(Actor* thisx, GlobalContext* globalCtx); -void EnPr_Destroy(Actor* thisx, GlobalContext* globalCtx); -void EnPr_Update(Actor* thisx, GlobalContext* globalCtx); -void EnPr_Draw(Actor* thisx, GlobalContext* globalCtx); +void EnPr_Init(Actor* thisx, PlayState* play); +void EnPr_Destroy(Actor* thisx, PlayState* play); +void EnPr_Update(Actor* thisx, PlayState* play); +void EnPr_Draw(Actor* thisx, PlayState* play); void func_80A326F0(EnPr* this); -void func_80A32740(EnPr* this, GlobalContext* globalCtx); +void func_80A32740(EnPr* this, PlayState* play); void func_80A32854(EnPr* this); -void func_80A3289C(EnPr* this, GlobalContext* globalCtx); +void func_80A3289C(EnPr* this, PlayState* play); void func_80A3295C(EnPr* this); -void func_80A32984(EnPr* this, GlobalContext* globalCtx); -void func_80A32A40(EnPr* this, GlobalContext* globalCtx); +void func_80A32984(EnPr* this, PlayState* play); +void func_80A32A40(EnPr* this, PlayState* play); void func_80A32AF8(EnPr* this); -void func_80A32B20(EnPr* this, GlobalContext* globalCtx); +void func_80A32B20(EnPr* this, PlayState* play); 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); +void func_80A32D28(EnPr* this, PlayState* play); +void func_80A32EA4(EnPr* this, PlayState* play); +void func_80A32F48(EnPr* this, PlayState* play); static DamageTable sDamageTable = { /* Deku Nut */ DMG_ENTRY(0, 0x0), @@ -106,11 +106,11 @@ static AnimationHeader* sAnimations[] = { }; u8 D_80A33934[] = { - 0, 2, 0, 0, 2, + ANIMMODE_LOOP, ANIMMODE_ONCE, ANIMMODE_LOOP, ANIMMODE_LOOP, ANIMMODE_ONCE, }; -void EnPr_Init(Actor* thisx, GlobalContext* globalCtx2) { - GlobalContext* globalCtx = globalCtx2; +void EnPr_Init(Actor* thisx, PlayState* play2) { + PlayState* play = play2; EnPr* this = THIS; EnPrz* prz; s32 i; @@ -120,7 +120,7 @@ void EnPr_Init(Actor* thisx, GlobalContext* globalCtx2) { this->actor.colChkInfo.mass = 50; this->actor.hintId = 0x5C; - Collider_InitAndSetCylinder(globalCtx, &this->collider, &this->actor, &sCylinderInit); + Collider_InitAndSetCylinder(play, &this->collider, &this->actor, &sCylinderInit); this->unk_208 = 255; this->unk_2CC = 0.01f; @@ -132,7 +132,7 @@ void EnPr_Init(Actor* thisx, GlobalContext* globalCtx2) { this->actor.shape.yOffset = 1500.0f; this->actor.colChkInfo.damageTable = &sDamageTable; - SkelAnime_InitFlex(globalCtx, &this->skelAnime, &object_pr_Skel_0038B8, &object_pr_Anim_0021E8, this->jointTable, + SkelAnime_InitFlex(play, &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; @@ -151,9 +151,9 @@ void EnPr_Init(Actor* thisx, GlobalContext* globalCtx2) { this->unk_2F8 = &this->actor; 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); + prz = (EnPrz*)Actor_SpawnAsChild(&play->actorCtx, &this->actor, play, 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; @@ -169,10 +169,10 @@ void EnPr_Init(Actor* thisx, GlobalContext* globalCtx2) { func_80A326F0(this); } -void EnPr_Destroy(Actor* thisx, GlobalContext* globalCtx) { +void EnPr_Destroy(Actor* thisx, PlayState* play) { EnPr* this = THIS; - Collider_DestroyCylinder(globalCtx, &this->collider); + Collider_DestroyCylinder(play, &this->collider); } void func_80A3242C(EnPr* this, s32 arg0) { @@ -190,19 +190,19 @@ void func_80A3242C(EnPr* this, s32 arg0) { -2.0f); } -s32 func_80A324E0(EnPr* this, GlobalContext* globalCtx) { +s32 func_80A324E0(EnPr* this, PlayState* play) { CollisionPoly* sp54; Vec3f sp48; s32 sp44; WaterBox* sp40; - if (BgCheck_EntityLineTest1(&globalCtx->colCtx, &this->actor.world.pos, &this->unk_2E0, &sp48, &sp54, 1, 0, 0, 1, + if (BgCheck_EntityLineTest1(&play->colCtx, &this->actor.world.pos, &this->unk_2E0, &sp48, &sp54, 1, 0, 0, 1, &sp44)) { return 1; } - if (WaterBox_GetSurface1(globalCtx, &globalCtx->colCtx, this->actor.world.pos.x, this->actor.world.pos.z, - &this->unk_2B4, &sp40)) { + if (WaterBox_GetSurface1(play, &play->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; @@ -245,10 +245,10 @@ void func_80A326F0(EnPr* this) { this->actionFunc = func_80A32740; } -void func_80A32740(EnPr* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); +void func_80A32740(EnPr* this, PlayState* play) { + Player* player = GET_PLAYER(play); - switch (func_80A324E0(this, globalCtx)) { + switch (func_80A324E0(this, play)) { case 1: func_80A3295C(this); return; @@ -278,7 +278,7 @@ void func_80A32854(EnPr* this) { this->actionFunc = func_80A3289C; } -void func_80A3289C(EnPr* this, GlobalContext* globalCtx) { +void func_80A3289C(EnPr* this, PlayState* play) { this->unk_22C = Math_Vec3f_Yaw(&this->actor.world.pos, &this->actor.home.pos); func_80A325E4(this); @@ -295,14 +295,14 @@ void func_80A3295C(EnPr* this) { this->actionFunc = func_80A32984; } -void func_80A32984(EnPr* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); +void func_80A32984(EnPr* this, PlayState* play) { + Player* player = GET_PLAYER(play); 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)) { + if (func_80A324E0(this, play)) { this->unk_22C += 0x1000; } else { if (this->unk_21C != 0) { @@ -314,15 +314,15 @@ void func_80A32984(EnPr* this, GlobalContext* globalCtx) { } } -void func_80A32A40(EnPr* this, GlobalContext* globalCtx) { +void func_80A32A40(EnPr* this, PlayState* play) { 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 (WaterBox_GetSurface1(play, &play->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 { @@ -340,13 +340,13 @@ void func_80A32AF8(EnPr* this) { this->actionFunc = func_80A32B20; } -void func_80A32B20(EnPr* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); +void func_80A32B20(EnPr* this, PlayState* play) { + Player* player = GET_PLAYER(play); 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); + func_80A324E0(this, play); if (!(player->stateFlags1 & 0x8000000)) { this->skelAnime.playSpeed = 1.0f; @@ -372,8 +372,8 @@ void func_80A32CDC(EnPr* this) { this->actionFunc = func_80A32D28; } -void func_80A32D28(EnPr* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); +void func_80A32D28(EnPr* this, PlayState* play) { + Player* player = GET_PLAYER(play); if (!(player->stateFlags1 & 0x8000000)) { this->skelAnime.playSpeed = 1.0f; @@ -383,7 +383,7 @@ void func_80A32D28(EnPr* this, GlobalContext* globalCtx) { 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); + func_80A324E0(this, play); if (this->unk_2C8 < sqrtf(SQ(player->actor.world.pos.x - this->actor.home.pos.x) + SQ(player->actor.world.pos.z - this->actor.home.pos.z))) { this->skelAnime.playSpeed = 1.0f; @@ -400,7 +400,7 @@ void func_80A32E60(EnPr* this) { this->actionFunc = func_80A32EA4; } -void func_80A32EA4(EnPr* this, GlobalContext* globalCtx) { +void func_80A32EA4(EnPr* this, PlayState* play) { f32 curFrame = this->skelAnime.curFrame; if (this->unk_2BC <= curFrame) { @@ -409,7 +409,7 @@ void func_80A32EA4(EnPr* this, GlobalContext* globalCtx) { this->unk_20A = 50; this->actor.flags |= ACTOR_FLAG_8000000; this->unk_2C4 = 0.0f; - Enemy_StartFinishingBlow(globalCtx, &this->actor); + Enemy_StartFinishingBlow(play, &this->actor); Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_BUBLEWALK_DEAD); this->unk_216 = 0; this->actionFunc = func_80A32F48; @@ -419,7 +419,7 @@ void func_80A32EA4(EnPr* this, GlobalContext* globalCtx) { } } -void func_80A32F48(EnPr* this, GlobalContext* globalCtx) { +void func_80A32F48(EnPr* this, PlayState* play) { WaterBox* sp2C; if (this->unk_208 > 0) { @@ -428,8 +428,8 @@ void func_80A32F48(EnPr* this, GlobalContext* globalCtx) { 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 (WaterBox_GetSurface1(play, &play->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); @@ -450,8 +450,8 @@ void func_80A32F48(EnPr* this, GlobalContext* globalCtx) { } } -void func_80A33098(EnPr* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); +void func_80A33098(EnPr* this, PlayState* play) { + Player* player = GET_PLAYER(play); if ((this->unk_206 != 7) && (this->unk_206 != 6)) { if (this->collider.base.acFlags & AC_HIT) { @@ -459,8 +459,8 @@ void func_80A33098(EnPr* this, GlobalContext* globalCtx) { 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); + Actor_Spawn(&play->actorCtx, play, ACTOR_EN_CLEAR_TAG, this->actor.focus.pos.x, this->actor.focus.pos.y, + this->actor.focus.pos.z, 0, 0, 0, CLEAR_TAG_LARGE_LIGHT_RAYS); } if ((player->stateFlags1 & 0x8000000) && (this->actor.colChkInfo.damageEffect == 5)) { @@ -478,7 +478,7 @@ void func_80A33098(EnPr* this, GlobalContext* globalCtx) { } } -void EnPr_Update(Actor* thisx, GlobalContext* globalCtx) { +void EnPr_Update(Actor* thisx, PlayState* play) { s32 pad; EnPr* this = THIS; s32 i; @@ -501,10 +501,10 @@ void EnPr_Update(Actor* thisx, GlobalContext* globalCtx) { this->unk_210--; } - this->actionFunc(this, globalCtx); + this->actionFunc(this, play); Actor_SetFocus(&this->actor, 20.0f); - func_80A33098(this, globalCtx); + func_80A33098(this, play); Math_Vec3f_Copy(&this->unk_2E0, &this->actor.world.pos); this->unk_2E0.x += (Math_SinS(this->actor.world.rot.y) * 70.0f); @@ -536,13 +536,13 @@ void EnPr_Update(Actor* thisx, GlobalContext* globalCtx) { } } - Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 0.0f, 30.0f, 20.0f, 0x1D); + Actor_UpdateBgCheckInfo(play, &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); + CollisionCheck_SetAC(play, &play->colChkCtx, &this->collider.base); + CollisionCheck_SetAT(play, &play->colChkCtx, &this->collider.base); if (this->unk_204 != 0) { Vec3f sp40; @@ -554,13 +554,13 @@ void EnPr_Update(Actor* thisx, GlobalContext* globalCtx) { 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); + EffectSsBubble_Spawn(play, &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) { +s32 EnPr_OverrideLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, Actor* thisx) { EnPr* this = THIS; if (limbIndex == 2) { @@ -569,18 +569,18 @@ s32 EnPr_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, return false; } -void EnPr_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx) { +void EnPr_PostLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx) { Vec3f sp24 = { 0.0f, 0.0f, 0.0f }; EnPr* this = THIS; if (limbIndex == 2) { - Matrix_InsertTranslation(0.0f, 0.0f, 0.0f, MTXMODE_APPLY); - Matrix_MultiplyVector3fByState(&sp24, &this->unk_2D4); + 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_GetStateTranslation(&this->limbPos[this->unk_228]); + Matrix_MultZero(&this->limbPos[this->unk_228]); this->unk_228++; if (this->unk_228 >= ARRAY_COUNT(this->limbPos)) { this->unk_228 = 0; @@ -588,28 +588,28 @@ void EnPr_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec } } -void EnPr_Draw(Actor* thisx, GlobalContext* globalCtx) { +void EnPr_Draw(Actor* thisx, PlayState* play) { EnPr* this = THIS; - OPEN_DISPS(globalCtx->state.gfxCtx); + OPEN_DISPS(play->state.gfxCtx); - func_8012C28C(globalCtx->state.gfxCtx); - func_8012C2DC(globalCtx->state.gfxCtx); + func_8012C28C(play->state.gfxCtx); + func_8012C2DC(play->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); + Scene_SetRenderModeXlu(play, 0, 1); + SkelAnime_DrawFlexOpa(play, 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, + Scene_SetRenderModeXlu(play, 1, 2); + POLY_XLU_DISP = SkelAnime_DrawFlex(play, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, NULL, NULL, &this->actor, POLY_XLU_DISP); } @@ -618,9 +618,9 @@ void EnPr_Draw(Actor* thisx, GlobalContext* globalCtx) { 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, + Actor_DrawDamageEffects(play, &this->actor, this->limbPos, ARRAY_COUNT(this->limbPos), 0.8f, 0.8f, drawDmgEffAlpha, this->drawDmgEffType); } - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->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 18123e119..6a5fe8b5a 100644 --- a/src/overlays/actors/ovl_En_Pr/z_en_pr.h +++ b/src/overlays/actors/ovl_En_Pr/z_en_pr.h @@ -5,7 +5,7 @@ struct EnPr; -typedef void (*EnPrActionFunc)(struct EnPr*, GlobalContext*); +typedef void (*EnPrActionFunc)(struct EnPr*, PlayState*); #define ENPR_GET_FF00(thisx) (((thisx)->params >> 8) & 0xFF) @@ -13,45 +13,45 @@ typedef void (*EnPrActionFunc)(struct EnPr*, GlobalContext*); #define ENPR_FF00_MIN 0 typedef struct EnPr { - /* 0x0000 */ Actor actor; - /* 0x0144 */ SkelAnime skelAnime; - /* 0x0188 */ Vec3s jointTable[10]; - /* 0x01C4 */ Vec3s morphTable[10]; - /* 0x0200 */ EnPrActionFunc actionFunc; - /* 0x0204 */ u8 unk_204; - /* 0x0206 */ s16 unk_206; - /* 0x0208 */ s16 unk_208; - /* 0x020A */ s16 unk_20A; - /* 0x020C */ s16 unk_20C; - /* 0x020E */ s16 unk_20E; - /* 0x0210 */ s16 unk_210; - /* 0x0212 */ s16 unk_212; - /* 0x0214 */ s16 unk_214; - /* 0x0216 */ s16 unk_216; - /* 0x0218 */ UNK_TYPE1 unk218[4]; - /* 0x021C */ s32 unk_21C; - /* 0x0220 */ UNK_TYPE1 unk220[0x8]; - /* 0x0228 */ s32 unk_228; - /* 0x022C */ s16 unk_22C; - /* 0x022E */ s16 drawDmgEffAlpha; - /* 0x0230 */ s16 drawDmgEffType; - /* 0x0234 */ f32 unk_234; - /* 0x0238 */ f32 unk_238; - /* 0x023C */ Vec3f limbPos[10]; - /* 0x02B4 */ f32 unk_2B4; - /* 0x02B8 */ f32 unk_2B8; - /* 0x02BC */ f32 unk_2BC; - /* 0x02C0 */ f32 unk_2C0; - /* 0x02C4 */ f32 unk_2C4; - /* 0x02C8 */ f32 unk_2C8; - /* 0x02CC */ f32 unk_2CC; - /* 0x02D0 */ s16 unk_2D0; - /* 0x02D2 */ s16 unk_2D2; - /* 0x02D4 */ Vec3f unk_2D4; - /* 0x02E0 */ Vec3f unk_2E0; - /* 0x02EC */ UNK_TYPE1 unk2EC[0xC]; - /* 0x02F8 */ Actor* unk_2F8; - /* 0x02FC */ ColliderCylinder collider; + /* 0x000 */ Actor actor; + /* 0x144 */ SkelAnime skelAnime; + /* 0x188 */ Vec3s jointTable[10]; + /* 0x1C4 */ Vec3s morphTable[10]; + /* 0x200 */ EnPrActionFunc actionFunc; + /* 0x204 */ u8 unk_204; + /* 0x206 */ s16 unk_206; + /* 0x208 */ s16 unk_208; + /* 0x20A */ s16 unk_20A; + /* 0x20C */ s16 unk_20C; + /* 0x20E */ s16 unk_20E; + /* 0x210 */ s16 unk_210; + /* 0x212 */ s16 unk_212; + /* 0x214 */ s16 unk_214; + /* 0x216 */ s16 unk_216; + /* 0x218 */ UNK_TYPE1 unk218[4]; + /* 0x21C */ s32 unk_21C; + /* 0x220 */ UNK_TYPE1 unk220[0x8]; + /* 0x228 */ s32 unk_228; + /* 0x22C */ s16 unk_22C; + /* 0x22E */ s16 drawDmgEffAlpha; + /* 0x230 */ s16 drawDmgEffType; + /* 0x234 */ f32 unk_234; + /* 0x238 */ f32 unk_238; + /* 0x23C */ Vec3f limbPos[10]; + /* 0x2B4 */ f32 unk_2B4; + /* 0x2B8 */ f32 unk_2B8; + /* 0x2BC */ f32 unk_2BC; + /* 0x2C0 */ f32 unk_2C0; + /* 0x2C4 */ f32 unk_2C4; + /* 0x2C8 */ f32 unk_2C8; + /* 0x2CC */ f32 unk_2CC; + /* 0x2D0 */ s16 unk_2D0; + /* 0x2D2 */ s16 unk_2D2; + /* 0x2D4 */ Vec3f unk_2D4; + /* 0x2E0 */ Vec3f unk_2E0; + /* 0x2EC */ UNK_TYPE1 unk2EC[0xC]; + /* 0x2F8 */ Actor* unk_2F8; + /* 0x2FC */ ColliderCylinder collider; } EnPr; // size = 0x348 extern const ActorInit En_Pr_InitVars; diff --git a/src/overlays/actors/ovl_En_Pr2/z_en_pr2.c b/src/overlays/actors/ovl_En_Pr2/z_en_pr2.c index 6bb60f174..2454639c5 100644 --- a/src/overlays/actors/ovl_En_Pr2/z_en_pr2.c +++ b/src/overlays/actors/ovl_En_Pr2/z_en_pr2.c @@ -12,19 +12,19 @@ #define THIS ((EnPr2*)thisx) -void EnPr2_Init(Actor* thisx, GlobalContext* globalCtx); -void EnPr2_Destroy(Actor* thisx, GlobalContext* globalCtx); -void EnPr2_Update(Actor* thisx, GlobalContext* globalCtx); -void EnPr2_Draw(Actor* thisx, GlobalContext* globalCtx); +void EnPr2_Init(Actor* thisx, PlayState* play); +void EnPr2_Destroy(Actor* thisx, PlayState* play); +void EnPr2_Update(Actor* thisx, PlayState* play); +void EnPr2_Draw(Actor* thisx, PlayState* play); void func_80A745C4(EnPr2* this); -void func_80A745FC(EnPr2* this, GlobalContext* globalCtx); +void func_80A745FC(EnPr2* this, PlayState* play); 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_80A748E8(EnPr2* this, PlayState* play); +void func_80A74DEC(EnPr2* this, PlayState* play); +void func_80A74E90(EnPr2* this, PlayState* play); void func_80A751B4(EnPr2* this); -void func_80A75310(EnPr2* this, GlobalContext* globalCtx); +void func_80A75310(EnPr2* this, PlayState* play); static DamageTable sDamageTable = { /* Deku Nut */ DMG_ENTRY(0, 0x0), @@ -99,13 +99,13 @@ static AnimationHeader* sAnimations[] = { &object_pr_Anim_003904, }; -u8 D_80A75C38[] = { 0, 0, 2, 0 }; +u8 D_80A75C38[] = { ANIMMODE_LOOP, ANIMMODE_LOOP, ANIMMODE_ONCE, ANIMMODE_LOOP }; s16 D_80A75C3C[] = { 0x00, 0x10, 0x20, 0x30, 0x40, 0x50, 0x60, 0x70, 0x80, 0x90, 0xA0, 0xB0, 0xC0, 0xD0, 0xE0, 0xF0, }; -void EnPr2_Init(Actor* thisx, GlobalContext* globalCtx) { +void EnPr2_Init(Actor* thisx, PlayState* play) { EnPr2* this = THIS; this->actor.targetMode = 3; @@ -114,7 +114,7 @@ void EnPr2_Init(Actor* thisx, GlobalContext* globalCtx) { this->actor.colChkInfo.health = 1; this->actor.colChkInfo.damageTable = &sDamageTable; - SkelAnime_InitFlex(globalCtx, &this->skelAnime, &object_pr_Skel_004188, &object_pr_Anim_004340, this->jointTable, + SkelAnime_InitFlex(play, &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; @@ -129,7 +129,7 @@ void EnPr2_Init(Actor* thisx, GlobalContext* globalCtx) { if (this->unk_1E0 < 10) { ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 19.0f); - Collider_InitAndSetCylinder(globalCtx, &this->collider, &this->actor, &sCylinderInit); + Collider_InitAndSetCylinder(play, &this->collider, &this->actor, &sCylinderInit); this->unk_218 = -1; this->unk_204 = 0.0f; @@ -152,7 +152,7 @@ void EnPr2_Init(Actor* thisx, GlobalContext* globalCtx) { if (parent->update != NULL) { this->unk_1C8 = ((EnEncount1*)parent)->unk_15A; - this->path = SubS_GetPathByIndex(globalCtx, this->unk_1C8, 0x3F); + this->path = SubS_GetPathByIndex(play, this->unk_1C8, 0x3F); this->unk_208 = parent->world.rot.z * 20.0f; if (this->unk_208 < 20.0f) { this->unk_208 = 20.0f; @@ -171,18 +171,18 @@ void EnPr2_Init(Actor* thisx, GlobalContext* globalCtx) { func_80A751B4(this); } - Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 0.0f, 20.0f, 20.0f, 0x1D); + Actor_UpdateBgCheckInfo(play, &this->actor, 0.0f, 20.0f, 20.0f, 0x1D); if (!(this->actor.bgCheckFlags & 0x60)) { Actor_MarkForDeath(&this->actor); } } -void EnPr2_Destroy(Actor* thisx, GlobalContext* globalCtx) { +void EnPr2_Destroy(Actor* thisx, PlayState* play) { EnPr2* this = THIS; if (this->unk_1E0 < 10) { - Collider_DestroyCylinder(globalCtx, &this->collider); + Collider_DestroyCylinder(play, &this->collider); } if (this->actor.parent != NULL) { @@ -194,12 +194,12 @@ void EnPr2_Destroy(Actor* thisx, GlobalContext* globalCtx) { } } -s32 func_80A7429C(EnPr2* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); +s32 func_80A7429C(EnPr2* this, PlayState* play) { + Player* player = GET_PLAYER(play); s16 sp1A; s16 sp18; - Actor_GetScreenPos(globalCtx, &this->actor, &sp1A, &sp18); + Actor_GetScreenPos(play, &this->actor, &sp1A, &sp18); 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)) { @@ -257,7 +257,7 @@ void func_80A745C4(EnPr2* this) { this->actionFunc = func_80A745FC; } -void func_80A745FC(EnPr2* this, GlobalContext* globalCtx) { +void func_80A745FC(EnPr2* this, PlayState* play) { f32 x; f32 y; f32 z; @@ -316,8 +316,8 @@ void func_80A74888(EnPr2* this) { this->actionFunc = func_80A748E8; } -void func_80A748E8(EnPr2* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); +void func_80A748E8(EnPr2* this, PlayState* play) { + Player* player = GET_PLAYER(play); f32 temp_f12; f32 temp_f2; f32 sqrtXZ; @@ -344,8 +344,8 @@ void func_80A748E8(EnPr2* this, GlobalContext* globalCtx) { case 1: if (this->unk_1DC == 0) { sp4C = true; - func_80A74DEC(this, globalCtx); - } else if (!func_80A7429C(this, globalCtx) && (this->unk_1F4 == 255)) { + func_80A74DEC(this, play); + } else if (!func_80A7429C(this, play) && (this->unk_1F4 == 255)) { this->unk_1F4 = 254; } break; @@ -358,7 +358,7 @@ void func_80A748E8(EnPr2* this, GlobalContext* globalCtx) { if (sp48 && (player->stateFlags1 & 0x8000000) && (sqrtXZ < this->unk_208)) { sp4C = true; - func_80A74DEC(this, globalCtx); + func_80A74DEC(this, play); } } else { temp_f2 = this->actor.world.pos.x - this->unk_228.x; @@ -398,7 +398,7 @@ void func_80A748E8(EnPr2* this, GlobalContext* globalCtx) { 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)) { + if (BgCheck_SphVsFirstPoly(&play->colCtx, &sp3C, 20.0f) || (this->actor.bgCheckFlags & 8)) { this->unk_1DC = 0; this->unk_1F2++; Math_Vec3f_Copy(&this->unk_21C, &this->unk_228); @@ -425,8 +425,8 @@ void func_80A748E8(EnPr2* this, GlobalContext* globalCtx) { } } -void func_80A74DEC(EnPr2* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); +void func_80A74DEC(EnPr2* this, PlayState* play) { + Player* player = GET_PLAYER(play); this->unk_1F0 = 0; func_80A74510(this, 1); @@ -441,8 +441,8 @@ void func_80A74DEC(EnPr2* this, GlobalContext* globalCtx) { this->actionFunc = func_80A74E90; } -void func_80A74E90(EnPr2* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); +void func_80A74E90(EnPr2* this, PlayState* play) { + Player* player = GET_PLAYER(play); WaterBox* sp40; Math_ApproachF(&this->unk_204, 0.02f, 0.1f, 0.005f); @@ -487,14 +487,14 @@ void func_80A74E90(EnPr2* this, GlobalContext* globalCtx) { 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 (WaterBox_GetSurface1(play, &play->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_1E0 == 1) && !func_80A7429C(this, play)) { if (this->unk_1F4 == 255) { this->unk_1F4 = 254; } @@ -520,7 +520,8 @@ void func_80A751B4(EnPr2* this) { func_80A74510(this, 2); } else { this->unk_1F8 = Animation_GetLastFrame(&object_pr_Anim_003904); - Animation_Change(&this->skelAnime, &object_pr_Anim_003904, 1.0f, this->unk_1F8, this->unk_1F8, 2, 0.0f); + Animation_Change(&this->skelAnime, &object_pr_Anim_003904, 1.0f, this->unk_1F8, this->unk_1F8, ANIMMODE_ONCE, + 0.0f); this->unk_1D8 = Rand_S16Offset(20, 30); this->unk_1E4 = 0x4000; if (Rand_ZeroOne() < 0.5f) { @@ -539,7 +540,7 @@ void func_80A751B4(EnPr2* this) { this->actionFunc = func_80A75310; } -void func_80A75310(EnPr2* this, GlobalContext* globalCtx) { +void func_80A75310(EnPr2* this, PlayState* play) { s32 temp; f32 frame; WaterBox* sp74; @@ -552,7 +553,7 @@ void func_80A75310(EnPr2* this, GlobalContext* globalCtx) { 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, + Actor_Spawn(&play->actorCtx, play, 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); } @@ -572,8 +573,8 @@ void func_80A75310(EnPr2* this, GlobalContext* globalCtx) { this->unk_1D6 = true; } - if (WaterBox_GetSurface1(globalCtx, &globalCtx->colCtx, this->actor.world.pos.x, this->actor.world.pos.z, - &this->unk_200, &sp74)) { + if (WaterBox_GetSurface1(play, &play->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) { @@ -597,7 +598,7 @@ void func_80A75310(EnPr2* this, GlobalContext* globalCtx) { sp64.z += randPlusMinusPoint5Scaled(20.0f); frame = Rand_ZeroFloat(0.03f) + 0.07f; - EffectSsBubble_Spawn(globalCtx, &sp64, 0.0f, 5.0f, 5.0f, frame); + EffectSsBubble_Spawn(play, &sp64, 0.0f, 5.0f, 5.0f, frame); } Actor_MarkForDeath(&this->actor); @@ -606,18 +607,18 @@ void func_80A75310(EnPr2* this, GlobalContext* globalCtx) { } } -void func_80A755D8(EnPr2* this, GlobalContext* globalCtx) { +void func_80A755D8(EnPr2* this, PlayState* play) { 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); + Enemy_StartFinishingBlow(play, &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]); + Item_DropCollectibleRandom(play, NULL, &this->actor.world.pos, D_80A75C3C[this->unk_218]); } this->actor.colChkInfo.health = 0; @@ -630,7 +631,7 @@ void func_80A755D8(EnPr2* this, GlobalContext* globalCtx) { } } -void EnPr2_Update(Actor* thisx, GlobalContext* globalCtx) { +void EnPr2_Update(Actor* thisx, PlayState* play) { EnPr2* this = THIS; f32 rand; @@ -638,7 +639,7 @@ void EnPr2_Update(Actor* thisx, GlobalContext* globalCtx) { Actor_SetScale(&this->actor, this->unk_204); - this->actionFunc(this, globalCtx); + this->actionFunc(this, play); if (this->unk_1DA != 0) { this->unk_1DA--; @@ -657,9 +658,9 @@ void EnPr2_Update(Actor* thisx, GlobalContext* globalCtx) { } Actor_SetFocus(&this->actor, 10.0f); - func_80A755D8(this, globalCtx); + func_80A755D8(this, play); Actor_MoveWithGravity(&this->actor); - Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 0, 10.0f, 20.0f, 0x1F); + Actor_UpdateBgCheckInfo(play, &this->actor, 0, 10.0f, 20.0f, 0x1F); if (this->unk_1D6) { s32 i; @@ -675,7 +676,7 @@ void EnPr2_Update(Actor* thisx, GlobalContext* globalCtx) { for (i = 0; i < 2; i++) { rand = Rand_ZeroFloat(0.03f) + 0.07f; - EffectSsBubble_Spawn(globalCtx, &sp58, 0, 5.0f, 5.0f, rand); + EffectSsBubble_Spawn(play, &sp58, 0, 5.0f, 5.0f, rand); } } @@ -685,14 +686,14 @@ void EnPr2_Update(Actor* thisx, GlobalContext* globalCtx) { 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); + CollisionCheck_SetOC(play, &play->colChkCtx, &this->collider.base); + CollisionCheck_SetAC(play, &play->colChkCtx, &this->collider.base); + CollisionCheck_SetAT(play, &play->colChkCtx, &this->collider.base); } } } -s32 func_80A758E8(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, Actor* thisx) { +s32 func_80A758E8(PlayState* play, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, Actor* thisx) { EnPr2* this = THIS; if (this->unk_1E0 < 10) { @@ -705,20 +706,19 @@ s32 func_80A758E8(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* p return false; } -void func_80A75950(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx) { +void func_80A75950(PlayState* play, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx) { EnPr2* this = THIS; if (this->unk_1E0 < 10) { if (limbIndex == 2) { - Matrix_InsertTranslation(0.0f, 0.0f, 0.0f, MTXMODE_APPLY); - Matrix_GetStateTranslation(&this->unk_270); + Matrix_Translate(0.0f, 0.0f, 0.0f, MTXMODE_APPLY); + Matrix_MultZero(&this->unk_270); } - Matrix_GetStateTranslation(&this->unk_234[limbIndex]); + Matrix_MultZero(&this->unk_234[limbIndex]); } } -s32 func_80A759D8(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, Actor* thisx, - Gfx** gfx) { +s32 func_80A759D8(PlayState* play, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, Actor* thisx, Gfx** gfx) { EnPr2* this = THIS; if (this->unk_1E0 < 10) { @@ -731,30 +731,30 @@ s32 func_80A759D8(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* p return false; } -void EnPr2_Draw(Actor* thisx, GlobalContext* globalCtx) { +void EnPr2_Draw(Actor* thisx, PlayState* play) { EnPr2* this = THIS; - OPEN_DISPS(globalCtx->state.gfxCtx); + OPEN_DISPS(play->state.gfxCtx); - func_8012C28C(globalCtx->state.gfxCtx); + func_8012C28C(play->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); + Scene_SetRenderModeXlu(play, 0, 1); + SkelAnime_DrawFlexOpa(play, 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); + Scene_SetRenderModeXlu(play, 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); + SkelAnime_DrawFlex(play, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, + func_80A759D8, NULL, &this->actor, POLY_XLU_DISP); } - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->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 4ae14db77..df5afef4e 100644 --- a/src/overlays/actors/ovl_En_Pr2/z_en_pr2.h +++ b/src/overlays/actors/ovl_En_Pr2/z_en_pr2.h @@ -5,50 +5,50 @@ struct EnPr2; -typedef void (*EnPr2ActionFunc)(struct EnPr2*, GlobalContext*); +typedef void (*EnPr2ActionFunc)(struct EnPr2*, PlayState*); #define ENPR2_GET_F(thisx) ((thisx)->params & 0xF) #define ENPR2_GET_FF0(thisx) (((thisx)->params >> 4) & 0xFF) typedef struct EnPr2 { - /* 0x0000 */ Actor actor; - /* 0x0144 */ SkelAnime skelAnime; - /* 0x0188 */ Vec3s jointTable[5]; - /* 0x01A6 */ Vec3s morphtable[5]; - /* 0x01C4 */ EnPr2ActionFunc actionFunc; - /* 0x01C8 */ s16 unk_1C8; - /* 0x01CC */ Path* path; - /* 0x01D0 */ s32 unk_1D0; - /* 0x01D4 */ s16 unk_1D4; - /* 0x01D6 */ s16 unk_1D6; - /* 0x01D8 */ s16 unk_1D8; - /* 0x01DA */ s16 unk_1DA; - /* 0x01DC */ s16 unk_1DC; - /* 0x01DE */ s16 unk_1DE; - /* 0x01E0 */ s16 unk_1E0; - /* 0x01E2 */ UNK_TYPE1 unk1E2[2]; - /* 0x01E4 */ s16 unk_1E4; - /* 0x01E6 */ s16 unk_1E6; - /* 0x01E8 */ UNK_TYPE1 unk1E8[4]; - /* 0x01EC */ s16 unk_1EC; - /* 0x01EE */ s16 unk_1EE; - /* 0x01F0 */ s16 unk_1F0; - /* 0x01F2 */ s16 unk_1F2; - /* 0x01F4 */ s16 unk_1F4; - /* 0x01F8 */ f32 unk_1F8; - /* 0x01FC */ f32 unk_1FC; - /* 0x0200 */ f32 unk_200; - /* 0x0204 */ f32 unk_204; - /* 0x0208 */ f32 unk_208; - /* 0x020C */ f32 unk_20C; - /* 0x0210 */ s32 unk_210; - /* 0x0214 */ UNK_TYPE1 unk214[4]; - /* 0x0218 */ s32 unk_218; - /* 0x021C */ Vec3f unk_21C; - /* 0x0228 */ Vec3f unk_228; - /* 0x0234 */ Vec3f unk_234[5]; - /* 0x0270 */ Vec3f unk_270; - /* 0x027C */ ColliderCylinder collider; + /* 0x000 */ Actor actor; + /* 0x144 */ SkelAnime skelAnime; + /* 0x188 */ Vec3s jointTable[5]; + /* 0x1A6 */ Vec3s morphtable[5]; + /* 0x1C4 */ EnPr2ActionFunc actionFunc; + /* 0x1C8 */ s16 unk_1C8; + /* 0x1CC */ Path* path; + /* 0x1D0 */ s32 unk_1D0; + /* 0x1D4 */ s16 unk_1D4; + /* 0x1D6 */ s16 unk_1D6; + /* 0x1D8 */ s16 unk_1D8; + /* 0x1DA */ s16 unk_1DA; + /* 0x1DC */ s16 unk_1DC; + /* 0x1DE */ s16 unk_1DE; + /* 0x1E0 */ s16 unk_1E0; + /* 0x1E2 */ UNK_TYPE1 unk1E2[2]; + /* 0x1E4 */ s16 unk_1E4; + /* 0x1E6 */ s16 unk_1E6; + /* 0x1E8 */ UNK_TYPE1 unk1E8[4]; + /* 0x1EC */ s16 unk_1EC; + /* 0x1EE */ s16 unk_1EE; + /* 0x1F0 */ s16 unk_1F0; + /* 0x1F2 */ s16 unk_1F2; + /* 0x1F4 */ s16 unk_1F4; + /* 0x1F8 */ f32 unk_1F8; + /* 0x1FC */ f32 unk_1FC; + /* 0x200 */ f32 unk_200; + /* 0x204 */ f32 unk_204; + /* 0x208 */ f32 unk_208; + /* 0x20C */ f32 unk_20C; + /* 0x210 */ s32 unk_210; + /* 0x214 */ UNK_TYPE1 unk214[4]; + /* 0x218 */ s32 unk_218; + /* 0x21C */ Vec3f unk_21C; + /* 0x228 */ Vec3f unk_228; + /* 0x234 */ Vec3f unk_234[5]; + /* 0x270 */ Vec3f unk_270; + /* 0x27C */ ColliderCylinder collider; } EnPr2; // size = 0x2C8 extern const ActorInit En_Pr2_InitVars; diff --git a/src/overlays/actors/ovl_En_Prz/z_en_prz.c b/src/overlays/actors/ovl_En_Prz/z_en_prz.c index 29df2aa2c..6fc5ea24a 100644 --- a/src/overlays/actors/ovl_En_Prz/z_en_prz.c +++ b/src/overlays/actors/ovl_En_Prz/z_en_prz.c @@ -12,18 +12,18 @@ #define THIS ((EnPrz*)thisx) -void EnPrz_Init(Actor* thisx, GlobalContext* globalCtx); -void EnPrz_Destroy(Actor* thisx, GlobalContext* globalCtx); -void EnPrz_Update(Actor* thisx, GlobalContext* globalCtx); -void EnPrz_Draw(Actor* thisx, GlobalContext* globalCtx); +void EnPrz_Init(Actor* thisx, PlayState* play); +void EnPrz_Destroy(Actor* thisx, PlayState* play); +void EnPrz_Update(Actor* thisx, PlayState* play); +void EnPrz_Draw(Actor* thisx, PlayState* play); 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_80A763E8(EnPrz* this, PlayState* play); +void func_80A76604(EnPrz* this, PlayState* play); +void func_80A76634(EnPrz* this, PlayState* play); void func_80A76748(EnPrz* this); -void func_80A767A8(EnPrz* this, GlobalContext* globalCtx); -void func_80A76B14(EnPrz* this, GlobalContext* globalCtx); +void func_80A767A8(EnPrz* this, PlayState* play); +void func_80A76B14(EnPrz* this, PlayState* play); static DamageTable sDamageTable = { /* Deku Nut */ DMG_ENTRY(0, 0x0), @@ -96,11 +96,11 @@ const ActorInit En_Prz_InitVars = { AnimationHeader* D_80A77240[] = { &object_pr_Anim_004340, &object_pr_Anim_004274 }; -u8 D_80A77248[] = { 0, 0 }; +u8 D_80A77248[] = { ANIMMODE_LOOP, ANIMMODE_LOOP }; Vec3f D_80A7724C = { 0.0f, 0.0f, 0.0f }; -void EnPrz_Init(Actor* thisx, GlobalContext* globalCtx) { +void EnPrz_Init(Actor* thisx, PlayState* play) { EnPrz* this = THIS; this->unk_20C = 0.01f; @@ -114,7 +114,7 @@ void EnPrz_Init(Actor* thisx, GlobalContext* globalCtx) { this->actor.colChkInfo.damageTable = &sDamageTable; this->actor.colChkInfo.health = 1; - SkelAnime_InitFlex(globalCtx, &this->skelAnime, &object_pr_Skel_004188, &object_pr_Anim_004340, this->jointTable, + SkelAnime_InitFlex(play, &this->skelAnime, &object_pr_Skel_004188, &object_pr_Anim_004340, this->jointTable, this->morphTable, 5); this->unk_1E6 = ENPRZ_GET(&this->actor); @@ -122,7 +122,7 @@ void EnPrz_Init(Actor* thisx, GlobalContext* globalCtx) { this->actor.flags |= ACTOR_FLAG_8000000; this->actor.flags &= ~ACTOR_FLAG_1; - Collider_InitAndSetCylinder(globalCtx, &this->collider, &this->actor, &sCylinderInit); + Collider_InitAndSetCylinder(play, &this->collider, &this->actor, &sCylinderInit); Math_Vec3f_Copy(&this->unk_1D8, &this->actor.world.pos); this->unk_220 = &this->actor; @@ -132,7 +132,7 @@ void EnPrz_Init(Actor* thisx, GlobalContext* globalCtx) { func_80A76388(this); } -void EnPrz_Destroy(Actor* thisx, GlobalContext* globalCtx) { +void EnPrz_Destroy(Actor* thisx, PlayState* play) { } void func_80A75F18(EnPrz* this, s32 arg1) { @@ -141,12 +141,12 @@ void func_80A75F18(EnPrz* this, s32 arg1) { D_80A77248[arg1], -2.0f); } -s32 func_80A75FA4(EnPrz* this, GlobalContext* globalCtx) { +s32 func_80A75FA4(EnPrz* this, PlayState* play) { WaterBox* sp2C; f32 temp_f0; - if (WaterBox_GetSurface1(globalCtx, &globalCtx->colCtx, this->actor.world.pos.x, this->actor.world.pos.z, - &this->unk_210, &sp2C)) { + if (WaterBox_GetSurface1(play, &play->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; @@ -163,7 +163,7 @@ s32 func_80A75FA4(EnPrz* this, GlobalContext* globalCtx) { return 0; } -void func_80A76070(EnPrz* this, s16 arg1, GlobalContext* globalCtx) { +void func_80A76070(EnPrz* this, s16 arg1, PlayState* play) { s16 temp_s0 = arg1 - this->actor.world.rot.y; temp_s0 *= 0.01f; @@ -188,7 +188,7 @@ void func_80A76070(EnPrz* this, s16 arg1, GlobalContext* globalCtx) { } Math_SmoothStepToS(&this->actor.world.rot.y, arg1, temp_s0, this->unk_202 + 0x1388, 0); - func_80A75FA4(this, globalCtx); + func_80A75FA4(this, play); 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; @@ -199,7 +199,7 @@ void func_80A76070(EnPrz* this, s16 arg1, GlobalContext* globalCtx) { } } -s32 func_80A762C0(EnPrz* this, GlobalContext* globalCtx) { +s32 func_80A762C0(EnPrz* this, PlayState* play) { CollisionPoly* sp54; Vec3f sp48; s32 sp44; @@ -210,8 +210,8 @@ s32 func_80A762C0(EnPrz* this, GlobalContext* globalCtx) { 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)) { + if (BgCheck_EntityLineTest1(&play->colCtx, &this->actor.world.pos, &sp38, &sp48, &sp54, true, false, false, true, + &sp44)) { return true; } return false; @@ -224,9 +224,9 @@ void func_80A76388(EnPrz* this) { this->actionFunc = func_80A763E8; } -void func_80A763E8(EnPrz* this, GlobalContext* globalCtx) { +void func_80A763E8(EnPrz* this, PlayState* play) { Actor* sp3C = this->actor.parent; - Player* player = GET_PLAYER(globalCtx); + Player* player = GET_PLAYER(play); s16 yaw; s32 pad; @@ -239,8 +239,8 @@ void func_80A763E8(EnPrz* this, GlobalContext* globalCtx) { return; } - if (func_80A762C0(this, globalCtx)) { - func_80A76604(this, globalCtx); + if (func_80A762C0(this, play)) { + func_80A76604(this, play); return; } @@ -272,23 +272,23 @@ void func_80A763E8(EnPrz* this, GlobalContext* globalCtx) { } yaw = Math_Vec3f_Yaw(&this->actor.world.pos, &this->unk_1D8); - func_80A76070(this, yaw, globalCtx); + func_80A76070(this, yaw, play); } -void func_80A76604(EnPrz* this, GlobalContext* globalCtx) { +void func_80A76604(EnPrz* this, PlayState* play) { 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); +void func_80A76634(EnPrz* this, PlayState* play) { + Player* player = GET_PLAYER(play); - func_80A76070(this, this->unk_1E4, globalCtx); + func_80A76070(this, this->unk_1E4, play); if (ABS_ALT(BINANG_SUB(this->actor.world.rot.y, this->unk_1E4)) < 0x100) { - if (func_80A762C0(this, globalCtx) != 0) { + if (func_80A762C0(this, play) != 0) { this->unk_1E4 += 0x1500; this->unk_1E4 += (s16)Rand_ZeroFloat(5000.0f); } else if ((player->stateFlags1 & 0x8000000) && (player->actor.floorHeight < 30.0f)) { @@ -309,24 +309,23 @@ void func_80A76748(EnPrz* this) { this->actionFunc = func_80A767A8; } -void func_80A767A8(EnPrz* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); +void func_80A767A8(EnPrz* this, PlayState* play) { + Player* player = GET_PLAYER(play); EnPr* pr = (EnPr*)this->actor.parent; - f32 sqrt; + f32 distXZ; s32 pad[2]; - u8 playerForm; - if (func_80A762C0(this, globalCtx)) { + if (func_80A762C0(this, play)) { func_80A75F18(this, 0); this->actor.speedXZ = randPlusMinusPoint5Scaled(1.0f) + 4.0f; - func_80A76604(this, globalCtx); + func_80A76604(this, play); return; } - sqrt = sqrtf(SQ(player->actor.world.pos.x - this->actor.parent->home.pos.x) + - SQ(player->actor.world.pos.z - this->actor.parent->home.pos.z)); + 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 < sqrt)) { + if (!(player->stateFlags1 & 0x8000000) || (pr->unk_2C8 < distXZ)) { this->unk_1F2 = 100; this->skelAnime.playSpeed = 1.0f; func_80A76388(this); @@ -354,10 +353,9 @@ void func_80A767A8(EnPrz* this, GlobalContext* globalCtx) { this->unk_1C8 = 1; } - playerForm = gSaveContext.save.playerForm; - this->unk_1D8.y = - (player->actor.world.pos.y + D_80A771E0[playerForm]) + randPlusMinusPoint5Scaled((2.0f * this->unk_1E6) + 1.0f); - func_80A76070(this, Math_Vec3f_Yaw(&this->actor.world.pos, &this->unk_1D8), globalCtx); + 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), play); } void func_80A76A1C(EnPrz* this) { @@ -385,7 +383,7 @@ void func_80A76A1C(EnPrz* this) { this->actionFunc = func_80A76B14; } -void func_80A76B14(EnPrz* this, GlobalContext* globalCtx) { +void func_80A76B14(EnPrz* this, PlayState* play) { WaterBox* sp7C; s32 i; Vec3f sp6C; @@ -395,8 +393,8 @@ void func_80A76B14(EnPrz* this, GlobalContext* globalCtx) { 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 (WaterBox_GetSurface1(play, &play->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 { @@ -415,14 +413,14 @@ void func_80A76B14(EnPrz* this, GlobalContext* globalCtx) { 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); + EffectSsBubble_Spawn(play, &sp6C, 0.0f, 5.0f, 5.0f, Rand_ZeroFloat(0.03f) + 0.07f); } Actor_MarkForDeath(&this->actor); } } } -void EnPrz_Update(Actor* thisx, GlobalContext* globalCtx) { +void EnPrz_Update(Actor* thisx, PlayState* play) { s32 pad; EnPrz* this = THIS; s32 sp44 = false; @@ -432,7 +430,7 @@ void EnPrz_Update(Actor* thisx, GlobalContext* globalCtx) { SkelAnime_Update(&this->skelAnime); } - this->actionFunc(this, globalCtx); + this->actionFunc(this, play); if (this->unk_1EE != 0) { this->unk_1EE--; @@ -443,7 +441,7 @@ void EnPrz_Update(Actor* thisx, GlobalContext* globalCtx) { } Actor_MoveWithGravity(&this->actor); - Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 0.0f, 10.0f, 10.0f, 0x1D); + Actor_UpdateBgCheckInfo(play, &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); @@ -466,8 +464,8 @@ void EnPrz_Update(Actor* thisx, GlobalContext* globalCtx) { } Collider_UpdateCylinder(&this->actor, &this->collider); - CollisionCheck_SetAT(globalCtx, &globalCtx->colChkCtx, &this->collider.base); - CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + CollisionCheck_SetAT(play, &play->colChkCtx, &this->collider.base); + CollisionCheck_SetAC(play, &play->colChkCtx, &this->collider.base); if (this->unk_1C8 != 0) { Math_Vec3f_Copy(&sp38, &this->unk_1CC); @@ -477,12 +475,12 @@ void EnPrz_Update(Actor* thisx, GlobalContext* globalCtx) { 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); + EffectSsBubble_Spawn(play, &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) { +s32 func_80A76F70(PlayState* play, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, Actor* thisx) { EnPrz* this = THIS; if (limbIndex == 2) { @@ -491,39 +489,39 @@ s32 func_80A76F70(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* p return false; } -void func_80A76FCC(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx) { +void func_80A76FCC(PlayState* play, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx) { Vec3f sp1C = D_80A7724C; EnPrz* this = THIS; if (limbIndex == 2) { - Matrix_InsertTranslation(0.0f, 0.0f, 0.0f, MTXMODE_APPLY); - Matrix_MultiplyVector3fByState(&sp1C, &this->unk_1CC); + Matrix_Translate(0.0f, 0.0f, 0.0f, MTXMODE_APPLY); + Matrix_MultVec3f(&sp1C, &this->unk_1CC); } } -void EnPrz_Draw(Actor* thisx, GlobalContext* globalCtx) { +void EnPrz_Draw(Actor* thisx, PlayState* play) { EnPrz* this = THIS; - OPEN_DISPS(globalCtx->state.gfxCtx); + OPEN_DISPS(play->state.gfxCtx); - func_8012C28C(globalCtx->state.gfxCtx); + func_8012C28C(play->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); + Scene_SetRenderModeXlu(play, 0, 1); + SkelAnime_DrawFlexOpa(play, 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, + Scene_SetRenderModeXlu(play, 1, 2); + POLY_XLU_DISP = SkelAnime_DrawFlex(play, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, NULL, NULL, &this->actor, POLY_XLU_DISP); } - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->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 28f8152a8..75087c9bc 100644 --- a/src/overlays/actors/ovl_En_Prz/z_en_prz.h +++ b/src/overlays/actors/ovl_En_Prz/z_en_prz.h @@ -5,41 +5,41 @@ struct EnPrz; -typedef void (*EnPrzActionFunc)(struct EnPrz*, GlobalContext*); +typedef void (*EnPrzActionFunc)(struct EnPrz*, PlayState*); #define ENPRZ_GET(thisx) ((thisx)->params & 0xFF) typedef struct EnPrz { - /* 0x0000 */ Actor actor; - /* 0x0144 */ SkelAnime skelAnime; - /* 0x0188 */ Vec3s jointTable[5]; - /* 0x01A6 */ Vec3s morphTable[5]; - /* 0x01C4 */ EnPrzActionFunc actionFunc; - /* 0x01C8 */ u8 unk_1C8; - /* 0x01CC */ Vec3f unk_1CC; - /* 0x01D8 */ Vec3f unk_1D8; - /* 0x01E4 */ s16 unk_1E4; - /* 0x01E6 */ s16 unk_1E6; - /* 0x01E8 */ s16 unk_1E8; - /* 0x01EA */ s16 unk_1EA; - /* 0x01EC */ s16 unk_1EC; - /* 0x01EE */ s16 unk_1EE; - /* 0x01F0 */ UNK_TYPE1 unk1F0[2]; - /* 0x01F2 */ s16 unk_1F2; - /* 0x01F4 */ UNK_TYPE1 unk1F4[8]; - /* 0x01FC */ s16 unk_1FC; - /* 0x01FE */ s16 unk_1FE; - /* 0x0200 */ UNK_TYPE1 unk200[2]; - /* 0x0202 */ s16 unk_202; - /* 0x0204 */ s32 unk_204; - /* 0x0208 */ f32 unk_208; - /* 0x020C */ f32 unk_20C; - /* 0x0210 */ f32 unk_210; - /* 0x0214 */ f32 unk_214; - /* 0x0218 */ f32 unk_218; - /* 0x021C */ UNK_TYPE1 unk21C[4]; - /* 0x0220 */ Actor* unk_220; - /* 0x0224 */ ColliderCylinder collider; + /* 0x000 */ Actor actor; + /* 0x144 */ SkelAnime skelAnime; + /* 0x188 */ Vec3s jointTable[5]; + /* 0x1A6 */ Vec3s morphTable[5]; + /* 0x1C4 */ EnPrzActionFunc actionFunc; + /* 0x1C8 */ u8 unk_1C8; + /* 0x1CC */ Vec3f unk_1CC; + /* 0x1D8 */ Vec3f unk_1D8; + /* 0x1E4 */ s16 unk_1E4; + /* 0x1E6 */ s16 unk_1E6; + /* 0x1E8 */ s16 unk_1E8; + /* 0x1EA */ s16 unk_1EA; + /* 0x1EC */ s16 unk_1EC; + /* 0x1EE */ s16 unk_1EE; + /* 0x1F0 */ UNK_TYPE1 unk1F0[2]; + /* 0x1F2 */ s16 unk_1F2; + /* 0x1F4 */ UNK_TYPE1 unk1F4[8]; + /* 0x1FC */ s16 unk_1FC; + /* 0x1FE */ s16 unk_1FE; + /* 0x200 */ UNK_TYPE1 unk200[2]; + /* 0x202 */ s16 unk_202; + /* 0x204 */ s32 unk_204; + /* 0x208 */ f32 unk_208; + /* 0x20C */ f32 unk_20C; + /* 0x210 */ f32 unk_210; + /* 0x214 */ f32 unk_214; + /* 0x218 */ f32 unk_218; + /* 0x21C */ UNK_TYPE1 unk21C[4]; + /* 0x220 */ Actor* unk_220; + /* 0x224 */ ColliderCylinder collider; } EnPrz; // size = 0x270 extern const ActorInit En_Prz_InitVars; diff --git a/src/overlays/actors/ovl_En_Pst/z_en_pst.c b/src/overlays/actors/ovl_En_Pst/z_en_pst.c index 02a9ea743..78458e062 100644 --- a/src/overlays/actors/ovl_En_Pst/z_en_pst.c +++ b/src/overlays/actors/ovl_En_Pst/z_en_pst.c @@ -10,15 +10,114 @@ #define THIS ((EnPst*)thisx) -void EnPst_Init(Actor* thisx, GlobalContext* globalCtx); -void EnPst_Destroy(Actor* thisx, GlobalContext* globalCtx); -void EnPst_Update(Actor* thisx, GlobalContext* globalCtx); -void EnPst_Draw(Actor* thisx, GlobalContext* globalCtx); +void EnPst_Init(Actor* thisx, PlayState* play); +void EnPst_Destroy(Actor* thisx, PlayState* play); +void EnPst_Update(Actor* thisx, PlayState* play); +void EnPst_Draw(Actor* thisx, PlayState* play); -void func_80B2BD98(EnPst* this, GlobalContext* globalCtx); -void func_80B2BE54(EnPst* this, GlobalContext* globalCtx); +void EnPst_FollowSchedule(EnPst* this, PlayState* play); +void EnPst_Talk(EnPst* this, PlayState* play); + +typedef enum { + /* 0 */ POSTBOX_SCH_NONE, + /* 1 */ POSTBOX_SCH_AVAILABLE, + /* 2 */ POSTBOX_SCH_CHECKED_BY_POSTMAN +} PostboxScheduleResult; + +typedef enum { + /* 0 */ POSTBOX_BEHAVIOUR_WAIT_FOR_ITEM, + /* 1 */ POSTBOX_BEHAVIOUR_TAKE_ITEM, +} PostboxBehaviour; + +static u8 D_80B2C200[] = { + /* 0x0 */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(9, 31, 9, 35, 0x9 - 0x6), + /* 0x6 */ SCHEDULE_CMD_RET_VAL_L(POSTBOX_SCH_AVAILABLE), + /* 0x9 */ SCHEDULE_CMD_RET_VAL_L(POSTBOX_SCH_CHECKED_BY_POSTMAN), +}; + +static u8 D_80B2C20C[] = { + /* 0x0 */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(10, 3, 10, 7, 0x9 - 0x6), + /* 0x6 */ SCHEDULE_CMD_RET_VAL_L(POSTBOX_SCH_AVAILABLE), + /* 0x9 */ SCHEDULE_CMD_RET_VAL_L(POSTBOX_SCH_CHECKED_BY_POSTMAN), +}; + +static u8 D_80B2C218[] = { + /* 0x0 */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(10, 35, 10, 39, 0x9 - 0x6), + /* 0x6 */ SCHEDULE_CMD_RET_VAL_L(POSTBOX_SCH_AVAILABLE), + /* 0x9 */ SCHEDULE_CMD_RET_VAL_L(POSTBOX_SCH_CHECKED_BY_POSTMAN), +}; + +static u8 D_80B2C224[] = { + /* 0x0 */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(10, 53, 10, 57, 0x9 - 0x6), + /* 0x6 */ SCHEDULE_CMD_RET_VAL_L(POSTBOX_SCH_AVAILABLE), + /* 0x9 */ SCHEDULE_CMD_RET_VAL_L(POSTBOX_SCH_CHECKED_BY_POSTMAN), +}; + +static u8 D_80B2C230[] = { + /* 0x0 */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(11, 25, 11, 29, 0x9 - 0x6), + /* 0x6 */ SCHEDULE_CMD_RET_VAL_L(POSTBOX_SCH_AVAILABLE), + /* 0x9 */ SCHEDULE_CMD_RET_VAL_L(POSTBOX_SCH_CHECKED_BY_POSTMAN), +}; + +s32 D_80B2C23C[] = { + 0x0E27840C, 0x0E00FF2B, 0x00000031, 0x00392800, 0x0A122C27, 0xA40C2F00, 0x000C1012, + 0x2C27870C, 0x2F00000C, 0x111B022A, 0x002F001B, 0x4000080F, 0x27882D00, 0x180C100F, + 0x27892D00, 0x180C1012, 0x2C27850C, 0x2FFFD20E, 0x27860C10, +}; + +s32 D_80B2C288[] = { + 0x0E27840C, 0x0E00FF2B, 0x00000031, 0x00392800, 0x0A122C27, 0xA40C2F00, 0x000C1012, + 0x2C27870C, 0x2F00000C, 0x111B042A, 0x002F001B, 0x8000080F, 0x27882D00, 0x180C100F, + 0x27892D00, 0x180C1012, 0x2C27850C, 0x2FFFD20E, 0x27860C10, +}; + +s32 D_80B2C2D4[] = { + 0x0E27840C, 0x0E00FF2B, 0x00000031, 0x00392800, 0x0A122C27, 0xA40C2F00, 0x000C1012, + 0x2C27870C, 0x2F00000C, 0x111B082A, 0x002F001C, 0x0100080F, 0x27882D00, 0x180C100F, + 0x27892D00, 0x180C1012, 0x2C27850C, 0x2FFFD20E, 0x27860C10, +}; + +s32 D_80B2C320[] = { + 0x0E27840C, 0x0E00FF2B, 0x00000031, 0x00392800, 0x0A122C27, 0xA40C2F00, 0x000C1012, + 0x2C27870C, 0x2F00000C, 0x111B102A, 0x002F001C, 0x0200080F, 0x27882D00, 0x180C100F, + 0x27892D00, 0x180C1012, 0x2C27850C, 0x2FFFD20E, 0x27860C10, +}; + +s32 D_80B2C36C[] = { + 0x0E27840C, 0x0E00FF2B, 0x00000031, 0x00392800, 0x0A122C27, 0xA40C2F00, 0x000C1012, + 0x2C27870C, 0x2F00000C, 0x111B202A, 0x002F001C, 0x0400080F, 0x27882D00, 0x180C100F, + 0x27892D00, 0x180C1012, 0x2C27850C, 0x2FFFD20E, 0x27860C10, +}; + +s32 D_80B2C3B8[] = { + 0x0E27A10C, 0x0F27A20C, 0x12005108, 0x000F0600, 0x0C000013, 0x000C0C11, + 0x51080700, 0x0C060001, 0x00001300, 0x010C0700, 0x000E27A3, 0x0C161000, +}; + +s32 D_80B2C3E8[] = { + 0x2C27870C, 0x111B022A, 0x002F001B, 0x4000080F, 0x27882D00, 0x180C100F, 0x27892D00, 0x180C1000, +}; + +s32 D_80B2C408[] = { + 0x2C27870C, 0x111B042A, 0x002F001B, 0x8000080F, 0x27882D00, 0x180C100F, 0x27892D00, 0x180C1000, +}; + +s32 D_80B2C428[] = { + 0x2C27870C, 0x111B082A, 0x002F001C, 0x0100080F, 0x27882D00, 0x180C100F, 0x27892D00, 0x180C1000, +}; + +s32 D_80B2C448[] = { + 0x2C27870C, 0x111B102A, 0x002F001C, 0x0200080F, 0x27882D00, 0x180C100F, 0x27892D00, 0x180C1000, +}; + +s32 D_80B2C468[] = { + 0x2C27870C, 0x111B202A, 0x002F001C, 0x0400080F, 0x27882D00, 0x180C100F, 0x27892D00, 0x180C1000, +}; + +s32 D_80B2C488[] = { 0x2C27A40C, 0x10000000 }; + +s32 D_80B2C490[] = { 0x2C27850C, 0x10000000 }; -#if 0 const ActorInit En_Pst_InitVars = { ACTOR_EN_PST, ACTORCAT_PROP, @@ -31,51 +130,315 @@ const ActorInit En_Pst_InitVars = { (ActorFunc)EnPst_Draw, }; -// static ColliderCylinderInit sCylinderInit = { -static ColliderCylinderInit D_80B2C4B8 = { - { 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, + }, { 28, 72, 0, { 0, 0, 0 } }, }; -// sColChkInfoInit -static CollisionCheckInfoInit2 D_80B2C4E4 = { 1, 0, 0, 0, MASS_IMMOVABLE }; +static CollisionCheckInfoInit2 sColChkInfoInit = { 1, 0, 0, 0, MASS_IMMOVABLE }; -#endif +static AnimationInfoS sAnimationInfo[] = { { &gPostboxOpenSlotAnim, 1.0f, 0, -1, ANIMMODE_ONCE, 0 } }; -extern ColliderCylinderInit D_80B2C4B8; -extern CollisionCheckInfoInit2 D_80B2C4E4; +void EnPst_UpdateCollision(EnPst* this, PlayState* play) { + Collider_UpdateCylinder(&this->actor, &this->collider); + CollisionCheck_SetOC(play, &play->colChkCtx, &this->collider.base); +} -extern UNK_TYPE D_06001A80; +s32 EnPst_HandleLetterDay1(EnPst* this) { + switch (this->actor.params) { + case POSTBOX_SOUTH_UPPER_CLOCKTOWN: + return gSaveContext.save.weekEventReg[27] & 0x2; + case POSTBOX_NORTH_CLOCKTOWN: + return gSaveContext.save.weekEventReg[27] & 0x4; + case POSTBOX_EAST_UPPER_CLOCKTOWN: + return gSaveContext.save.weekEventReg[27] & 0x8; + case POSTBOX_EAST_LOWER_CLOCKTOWN: + return gSaveContext.save.weekEventReg[27] & 0x10; + case POSTBOX_SOUTH_LOWER_CLOCKTOWN: + return gSaveContext.save.weekEventReg[27] & 0x20; + default: + return false; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Pst/func_80B2B830.s") +s32 EnPst_HandleLetterDay2(EnPst* this) { + switch (this->actor.params) { + case POSTBOX_SOUTH_UPPER_CLOCKTOWN: + return gSaveContext.save.weekEventReg[27] & 0x40; + case POSTBOX_NORTH_CLOCKTOWN: + return gSaveContext.save.weekEventReg[27] & 0x80; + case POSTBOX_EAST_UPPER_CLOCKTOWN: + return gSaveContext.save.weekEventReg[28] & 0x1; + case POSTBOX_EAST_LOWER_CLOCKTOWN: + return gSaveContext.save.weekEventReg[28] & 0x2; + case POSTBOX_SOUTH_LOWER_CLOCKTOWN: + return gSaveContext.save.weekEventReg[28] & 0x4; + default: + return false; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Pst/func_80B2B874.s") +s32 EnPst_ChooseBehaviour(Actor* thisx, PlayState* play) { + s32 itemActionParam = 0; + s32 scriptBranch = 0; + EnPst* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Pst/func_80B2B8F4.s") + switch (this->behaviour) { + case POSTBOX_BEHAVIOUR_WAIT_FOR_ITEM: + switch (Message_GetState(&play->msgCtx)) { + case TEXT_STATE_CHOICE: + case TEXT_STATE_5: + if (Message_ShouldAdvance(play)) { + case TEXT_STATE_16: + itemActionParam = func_80123810(play); + scriptBranch = 0; + if ((itemActionParam == PLAYER_AP_LETTER_TO_KAFEI) || + (itemActionParam == PLAYER_AP_LETTER_MAMA)) { + this->exchangeItemId = itemActionParam; + this->behaviour++; + scriptBranch = 1; + } else if (itemActionParam < PLAYER_AP_NONE) { + this->behaviour++; + scriptBranch = 3; + } else if (itemActionParam != PLAYER_AP_NONE) { + this->behaviour++; + scriptBranch = 2; + } + } + break; + } + break; + case POSTBOX_BEHAVIOUR_TAKE_ITEM: + if (this->exchangeItemId == PLAYER_AP_LETTER_TO_KAFEI) { + scriptBranch = 1; + } + break; + } + return scriptBranch; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Pst/func_80B2B974.s") +s32* EnPst_GetMsgEventScript(EnPst* this, PlayState* play) { + if (Player_GetMask(play) == PLAYER_MASK_POSTMAN) { + return D_80B2C3B8; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Pst/func_80B2BAA4.s") + if (this->stateFlags & 0x10) { + switch (this->actor.params) { + case POSTBOX_SOUTH_UPPER_CLOCKTOWN: + return D_80B2C3E8; + case POSTBOX_NORTH_CLOCKTOWN: + return D_80B2C408; + case POSTBOX_EAST_UPPER_CLOCKTOWN: + return D_80B2C428; + case POSTBOX_EAST_LOWER_CLOCKTOWN: + return D_80B2C448; + case POSTBOX_SOUTH_LOWER_CLOCKTOWN: + return D_80B2C468; + default: + return NULL; + } + } else if (this->stateFlags & 0x20) { + if (this->exchangeItemId == PLAYER_AP_LETTER_MAMA) { + return D_80B2C488; + } else { + return D_80B2C490; + } + } else { + this->msgEventCallback = EnPst_ChooseBehaviour; + switch (this->actor.params) { + case POSTBOX_SOUTH_UPPER_CLOCKTOWN: + return D_80B2C23C; + case POSTBOX_NORTH_CLOCKTOWN: + return D_80B2C288; + case POSTBOX_EAST_UPPER_CLOCKTOWN: + return D_80B2C2D4; + case POSTBOX_EAST_LOWER_CLOCKTOWN: + return D_80B2C320; + case POSTBOX_SOUTH_LOWER_CLOCKTOWN: + return D_80B2C36C; + default: + return NULL; + } + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Pst/func_80B2BBFC.s") +s32 EnPst_CheckTalk(EnPst* this, PlayState* play) { + Player* player = GET_PLAYER(play); + s32 ret = false; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Pst/func_80B2BCF8.s") + if (this->stateFlags & 7) { + if (Actor_ProcessTalkRequest(&this->actor, &play->state)) { + this->stateFlags &= ~0x30; + if (player->exchangeItemId == PLAYER_AP_LETTER_TO_KAFEI) { + this->stateFlags |= 0x10; + this->exchangeItemId = player->exchangeItemId; + } else if (player->exchangeItemId != PLAYER_AP_NONE) { + this->stateFlags |= 0x20; + this->exchangeItemId = player->exchangeItemId; + } + // If Letter to Kafei is deposited, value is set to 2 + this->isLetterToKafeiDeposited = EnPst_HandleLetterDay1(this); + SubS_UpdateFlags(&this->stateFlags, 0, 7); + this->behaviour = 0; + this->msgEventCallback = NULL; + this->stateFlags |= 0x40; + this->msgEventScript = EnPst_GetMsgEventScript(this, play); + this->actionFunc = EnPst_Talk; + ret = true; + } + } + return ret; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Pst/func_80B2BD30.s") +s32 EnPst_UpdateFlagsSubs(EnPst* this, PlayState* play, ScheduleOutput* scheduleOutput) { + SubS_UpdateFlags(&this->stateFlags, 3, 7); + return true; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Pst/func_80B2BD88.s") +s32 EnPst_ProcessScheduleOutput(EnPst* this, PlayState* play, ScheduleOutput* scheduleOutput) { + s32 ret = false; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Pst/func_80B2BD98.s") + this->stateFlags = 0; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Pst/func_80B2BE54.s") + switch (scheduleOutput->result) { + case POSTBOX_SCH_AVAILABLE: + ret = EnPst_UpdateFlagsSubs(this, play, scheduleOutput); + break; + case POSTBOX_SCH_CHECKED_BY_POSTMAN: + ret = true; + break; + } + return ret; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Pst/EnPst_Init.s") +/* The postbox does not have any necessary custom logic when following their schedule, + * instead it is all done in the process step. This is why this function is empty + */ +void EnPst_HandleSchedule(EnPst* this, PlayState* play) { +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Pst/EnPst_Destroy.s") +void EnPst_FollowSchedule(EnPst* this, PlayState* play) { + static u8* sScheduleScripts[] = { + D_80B2C200, D_80B2C20C, D_80B2C218, D_80B2C224, D_80B2C230, + }; + s16 params = this->actor.params; + ScheduleOutput scheduleOutput; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Pst/EnPst_Update.s") + if (!Schedule_RunScript(play, sScheduleScripts[params], &scheduleOutput) || + ((this->scheduleResult != scheduleOutput.result) && + !EnPst_ProcessScheduleOutput(this, play, &scheduleOutput))) { + this->actor.shape.shadowDraw = NULL; + this->actor.flags &= ~ACTOR_FLAG_1; + scheduleOutput.result = POSTBOX_SCH_NONE; + } else { + this->actor.shape.shadowDraw = ActorShadow_DrawCircle; + this->actor.flags |= ACTOR_FLAG_1; + } + this->scheduleResult = scheduleOutput.result; + EnPst_HandleSchedule(this, play); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Pst/func_80B2C11C.s") +void EnPst_Talk(EnPst* this, PlayState* play) { + if (func_8010BF58(&this->actor, play, this->msgEventScript, this->msgEventCallback, &this->msgEventArg4)) { + if (EnPst_HandleLetterDay1(this) != this->isLetterToKafeiDeposited) { + switch (gSaveContext.save.day) { + case 1: + gSaveContext.save.weekEventReg[91] |= 4; + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Pst/EnPst_Draw.s") + case 2: + if (EnPst_HandleLetterDay2(this)) { + gSaveContext.save.weekEventReg[91] |= 8; + } else { + gSaveContext.save.weekEventReg[91] |= 4; + } + break; + + default: + gSaveContext.save.weekEventReg[91] |= 8; + break; + } + } + SubS_UpdateFlags(&this->stateFlags, 3, 7); + this->msgEventArg4 = 0; + this->actionFunc = EnPst_FollowSchedule; + } +} + +void EnPst_Init(Actor* thisx, PlayState* play) { + s32 pad; + EnPst* this = THIS; + + ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 18.0f); + SkelAnime_InitFlex(play, &this->skelAnime, &gPostboxSkel, NULL, this->jointTable, this->morphTable, + POSTBOX_LIMB_MAX); + Collider_InitAndSetCylinder(play, &this->collider, &this->actor, &sCylinderInit); + CollisionCheck_SetInfo2(&this->actor.colChkInfo, DamageTable_Get(0x16), &sColChkInfoInit); + SubS_UpdateFlags(&this->stateFlags, 3, 7); + SubS_ChangeAnimationByInfoS(&this->skelAnime, sAnimationInfo, 0); + this->actor.targetMode = 0; + Actor_SetScale(&this->actor, 0.02f); + this->actionFunc = EnPst_FollowSchedule; + Actor_UpdateBgCheckInfo(play, &this->actor, 0.0f, 0.0f, 0.0f, 4); +} + +void EnPst_Destroy(Actor* thisx, PlayState* play) { + EnPst* this = THIS; + + Collider_DestroyCylinder(play, &this->collider); +} + +void EnPst_Update(Actor* thisx, PlayState* play) { + EnPst* this = THIS; + + EnPst_CheckTalk(this, play); + this->actionFunc(this, play); + if (this->scheduleResult != POSTBOX_SCH_NONE) { + if (Actor_IsFacingPlayer(&this->actor, 0x1FFE)) { + this->unk214 = 0; + func_8013C964(&this->actor, play, 60.0f, 20.0f, 0, this->stateFlags & 7); + } + Actor_SetFocus(&this->actor, 20.0f); + EnPst_UpdateCollision(this, play); + } +} + +s32 EnPst_OverrideLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, Actor* thisx) { + EnPst* this = THIS; + f32 yTranslation; + + if (limbIndex == POSTBOX_LIMB_MAIL_SLOT) { + if (this->stateFlags & 0x40) { + yTranslation = -100.0f; + } else { + yTranslation = 0.0f; + } + Matrix_Translate(0.0f, yTranslation, 0.0f, MTXMODE_APPLY); + } + return false; +} + +void EnPst_Draw(Actor* thisx, PlayState* play) { + EnPst* this = THIS; + + if (this->scheduleResult != POSTBOX_SCH_NONE) { + func_8012C28C(play->state.gfxCtx); + SkelAnime_DrawFlexOpa(play, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, + EnPst_OverrideLimbDraw, NULL, &this->actor); + } +} diff --git a/src/overlays/actors/ovl_En_Pst/z_en_pst.h b/src/overlays/actors/ovl_En_Pst/z_en_pst.h index 4a4fdd647..1f85a1dec 100644 --- a/src/overlays/actors/ovl_En_Pst/z_en_pst.h +++ b/src/overlays/actors/ovl_En_Pst/z_en_pst.h @@ -2,16 +2,38 @@ #define Z_EN_PST_H #include "global.h" +#include "objects/object_pst/object_pst.h" + +typedef enum { + /* 0 */ POSTBOX_SOUTH_UPPER_CLOCKTOWN, + /* 1 */ POSTBOX_NORTH_CLOCKTOWN, + /* 2 */ POSTBOX_EAST_UPPER_CLOCKTOWN, + /* 3 */ POSTBOX_EAST_LOWER_CLOCKTOWN, + /* 4 */ POSTBOX_SOUTH_LOWER_CLOCKTOWN, +} PostboxType; struct EnPst; -typedef void (*EnPstActionFunc)(struct EnPst*, GlobalContext*); +typedef void (*EnPstActionFunc)(struct EnPst*, PlayState*); +typedef s32 (*MsgEventFunc)(Actor*, PlayState*); typedef struct EnPst { - /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x44]; - /* 0x0188 */ EnPstActionFunc actionFunc; - /* 0x018C */ char unk_18C[0x94]; + /* 0x000 */ Actor actor; + /* 0x144 */ SkelAnime skelAnime; + /* 0x188 */ EnPstActionFunc actionFunc; + /* 0x18C */ ColliderCylinder collider; + /* 0x1D8 */ u8 scheduleResult; + /* 0x1DC */ s32* msgEventScript; + /* 0x1E0 */ s32 msgEventArg4; + /* 0x1E4 */ Vec3s jointTable[POSTBOX_LIMB_MAX]; + /* 0x1F6 */ Vec3s morphTable[POSTBOX_LIMB_MAX]; + /* 0x208 */ u16 stateFlags; + /* 0x20A */ UNK_TYPE1 pad20A[4]; + /* 0x20E */ s16 behaviour; + /* 0x210 */ MsgEventFunc msgEventCallback; + /* 0x214 */ s32 unk214; // Set and not used + /* 0x218 */ s32 exchangeItemId; + /* 0x21C */ s32 isLetterToKafeiDeposited; } EnPst; // size = 0x220 extern const ActorInit En_Pst_InitVars; diff --git a/src/overlays/actors/ovl_En_Racedog/z_en_racedog.c b/src/overlays/actors/ovl_En_Racedog/z_en_racedog.c index 0166ed423..66b2a0a1e 100644 --- a/src/overlays/actors/ovl_En_Racedog/z_en_racedog.c +++ b/src/overlays/actors/ovl_En_Racedog/z_en_racedog.c @@ -9,36 +9,65 @@ */ #include "z_en_racedog.h" +#include "overlays/actors/ovl_En_Dg/z_en_dg.h" #define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_80000000) #define THIS ((EnRacedog*)thisx) -void EnRacedog_Init(Actor* thisx, GlobalContext* globalCtx); -void EnRacedog_Destroy(Actor* thisx, GlobalContext* globalCtx); -void EnRacedog_Update(Actor* thisx, GlobalContext* globalCtx); -void EnRacedog_Draw(Actor* thisx, GlobalContext* globalCtx); +void EnRacedog_Init(Actor* thisx, PlayState* play); +void EnRacedog_Destroy(Actor* thisx, PlayState* play); +void EnRacedog_Update(Actor* thisx, PlayState* play); +void EnRacedog_Draw(Actor* thisx, PlayState* play); -void func_80B24C14(EnRacedog* this, GlobalContext* globalCtx); -void func_80B24CB4(EnRacedog* this, GlobalContext* globalCtx); -void func_80B24E14(EnRacedog* this); -void func_80B24F08(EnRacedog* this); -void func_80B251EC(EnRacedog* this); -void func_80B252F8(EnRacedog* this); -void func_80B2538C(EnRacedog* this); -void func_80B25448(EnRacedog* this); -s32 func_80B25490(EnRacedog* this, Vec2f* arg1); -void func_80B255AC(EnRacedog* this, GlobalContext* globalCtx); -void func_80B256BC(EnRacedog* this); +void EnRacedog_RaceStart(EnRacedog* this, PlayState* play); +void EnRacedog_Race(EnRacedog* this, PlayState* play); +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, PlayState* play); +void EnRacedog_PlaySfxWalk(EnRacedog* this); +/** + * Dogs can be in three conditions, which is, for the most part, indicated by the + * message it says when you pick it up prior to entering the race. + * If it starts with "Ruff!", it's in good condition. + * If it starts with "Rrr-Ruff!", it's in normal condition. + * If it starts with "Hoo-whine", it's in bad condition. + * These text boxes are grouped up like so: + * - 0x3538 - 0x353D: Good condition + * - 0x353E - 0x3541: Normal condition + * - 0x3542 - 0x3546: Bad condition + * + * There are two caveats, though, that are useful to keep in mind: + * - Because of differences between how EnDg computes the text ID and how EnRacedog + * computes it, there are two dogs whose text upon picking them up does not + * accurately reflect their condition during the race. Check the comment above + * EnRacedog_UpdateTextId for more information on this phenomenon. + * - Note that text ID 0x353D is actually used for the Romani Ranch dog; its text + * just so happens to be in the middle of the race dog text block. In EnDg, the + * dog that gets this text ID will instead use text ID 0x3538 when the player + * picks it up. Since EnRacedog cannot be picked up, however, it can use 0x353D + * as an additional good condition text ID. + */ +#define DOG_IS_IN_GOOD_CONDITION(this) (sDogInfo[this->index].textId < 0x353E) +#define DOG_IS_IN_BAD_CONDITION(this) (sDogInfo[this->index].textId >= 0x3542) + +/** + * Stores various information for each dog in the race, mostly related to speed. + */ typedef struct { - f32 unk_00; - f32 unk_04; - s16 unk_08; - s16 unk_0A; - s16 unk_0C; - s16 unk_0E; -} UnkRacedogStruct; + 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; const ActorInit En_Racedog_InitVars = { ACTOR_EN_RACEDOG, @@ -52,31 +81,65 @@ const ActorInit En_Racedog_InitVars = { (ActorFunc)EnRacedog_Draw, }; -static s16 D_80B25D40 = 0; +static s16 sNumberOfDogsFinished = 0; -static s16 D_80B25D44 = -1; +/** + * The furthest point along the race track path that any dog has reached. + */ +static s16 sFurthestPoint = -1; -static s16 D_80B25D48 = 0; +/** + * 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; -static s16 D_80B25D4C = -1; +/** + * 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; -static f32 D_80B25D50[][2] = { +/** + * 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 }, }; -static UnkRacedogStruct D_80B25D88[] = { - { -1.0f, 1.20000004768f, 3, 0, 9, 0x3539 }, { -1.0f, 1.20000004768f, 1, 1, 9, 0x353A }, - { -1.0f, 1.20000004768f, 5, 2, 10, 0x353B }, { -1.0f, 1.20000004768f, 2, 3, 9, 0x353C }, - { -1.0f, 1.20000004768f, 4, 4, 8, 0x353D }, { -1.0f, 1.20000004768f, 2, 5, 9, 0x353E }, - { -1.0f, 1.20000004768f, 3, 6, 9, 0x353F }, { -1.0f, 1.20000004768f, 1, 7, 9, 0x3540 }, - { -1.0f, 1.20000004768f, 1, 8, 9, 0x3541 }, { -1.0f, 1.20000004768f, 6, 9, 8, 0x3542 }, - { -1.0f, 1.20000004768f, 2, 10, 9, 0x3543 }, { -1.0f, 1.20000004768f, 3, 11, 9, 0x3544 }, - { -1.0f, 1.20000004768f, 1, 12, 9, 0x3545 }, { -1.0f, 1.20000004768f, 4, 13, 8, 0x3546 }, +/** + * 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 }, }; -static UnkRacedogStruct D_80B25E68 = { -1.0f, 1.0, 0, -1, 0, 0x353E }; +/** + * 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 }; -static Vec2f D_80B25E78[] = { +/** + * 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 }, @@ -140,7 +203,27 @@ static DamageTable sDamageTable = { /* Powder Keg */ DMG_ENTRY(0, 0x0), }; -static AnimationInfoS D_80B25EF0[] = { +typedef enum { + /* 0 */ RACEDOG_ANIM_IDLE, + /* 1 */ RACEDOG_ANIM_WALK_1, // unused + /* 2 */ RACEDOG_ANIM_RUN, + /* 3 */ RACEDOG_ANIM_BARK, // unused + /* 4 */ RACEDOG_ANIM_SIT_DOWN_ONCE, // unused + /* 5 */ RACEDOG_ANIM_SIT_DOWN, // unused + /* 6 */ RACEDOG_ANIM_LYING_DOWN_START_1, // unused + /* 7 */ RACEDOG_ANIM_LYING_DOWN_LOOP, // unused + /* 8 */ RACEDOG_ANIM_LYING_DOWN_START_2, // unused + /* 9 */ RACEDOG_ANIM_LYING_DOWN_START_3, // unused + /* 10 */ RACEDOG_ANIM_LYING_DOWN_START_4, // unused + /* 11 */ RACEDOG_ANIM_WALK_BACKWARDS, // unused + /* 12 */ RACEDOG_ANIM_JUMP, + /* 13 */ RACEDOG_ANIM_LONG_JUMP, // unused + /* 14 */ RACEDOG_ANIM_JUMP_ATTACK, // unused + /* 15 */ RACEDOG_ANIM_SWIM, // unused + /* 16 */ RACEDOG_ANIM_MAX +} RacedogAnimation; + +static AnimationInfoS sAnimationInfo[] = { { &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 }, @@ -148,247 +231,292 @@ static AnimationInfoS D_80B25EF0[] = { { &gDogLyingDownAnim, 1.0f, 0, 27, ANIMMODE_ONCE, -6 }, { &gDogLyingDownAnim, 1.0f, 28, -1, ANIMMODE_ONCE, -6 }, { &gDogLyingDownAnim, 1.0f, 54, 54, ANIMMODE_ONCE, -6 }, { &gDogWalkAnim, -1.5f, -1, 0, ANIMMODE_LOOP, -6 }, { &gDogJumpAnim, 1.0f, 0, -1, ANIMMODE_ONCE, 0 }, { &gDogLongJumpAnim, 1.2f, 0, -1, ANIMMODE_ONCE, 0 }, - { &gDogJump2Anim, 1.2f, 0, -1, ANIMMODE_ONCE, 0 }, { &gDogWalkAnim, 0.5f, 0, -1, ANIMMODE_LOOP, 0 }, + { &gDogJumpAttackAnim, 1.2f, 0, -1, ANIMMODE_ONCE, 0 }, { &gDogWalkAnim, 0.5f, 0, -1, ANIMMODE_LOOP, 0 }, }; static InitChainEntry sInitChain[] = { ICHAIN_F32(uncullZoneForward, 1000, ICHAIN_STOP), }; -void func_80B24630(SkelAnime* skelAnime, AnimationInfoS arg1[], s32 arg2) { +void EnRacedog_ChangeAnim(SkelAnime* skelAnime, AnimationInfoS* animationInfo, s32 animIndex) { f32 frameCount; - arg1 += arg2; - if (arg1->frameCount < 0) { - frameCount = Animation_GetLastFrame(arg1->animation); + animationInfo += animIndex; + if (animationInfo->frameCount < 0) { + frameCount = Animation_GetLastFrame(animationInfo->animation); } else { - frameCount = arg1->frameCount; + frameCount = animationInfo->frameCount; } - Animation_Change(skelAnime, arg1->animation, arg1->playSpeed + (BREG(88) * 0.1f), arg1->startFrame, frameCount, - arg1->mode, arg1->morphFrames); + Animation_Change(skelAnime, animationInfo->animation, animationInfo->playSpeed + (BREG(88) * 0.1f), + animationInfo->startFrame, frameCount, animationInfo->mode, animationInfo->morphFrames); } -void func_80B246F4(EnRacedog* this, GlobalContext* globalCtx) { +void EnRacedog_UpdateCollision(EnRacedog* this, PlayState* play) { this->collider.dim.pos.x = this->actor.world.pos.x; this->collider.dim.pos.y = this->actor.world.pos.y; this->collider.dim.pos.z = this->actor.world.pos.z; - CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); - Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 26.0f, 10.0f, 0.0f, 5); + CollisionCheck_SetOC(play, &play->colChkCtx, &this->collider.base); + Actor_UpdateBgCheckInfo(play, &this->actor, 26.0f, 10.0f, 0.0f, 5); } -s16 func_80B2478C(Path* path, s32 arg1, Vec3f* pos, f32* arg3) { +/** + * 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 phi_f14; - f32 sp1C; - f32 xDiff; - f32 zDiff; + f32 diffXRand; + f32 diffZRand; + f32 diffX; + f32 diffZ; if (path != NULL) { point = Lib_SegmentedToVirtual(path->points); - point = &point[arg1]; - phi_f14 = (randPlusMinusPoint5Scaled(100.0f) + point->x) - pos->x; - sp1C = (randPlusMinusPoint5Scaled(100.0f) + point->z) - pos->z; - xDiff = point->x - pos->x; - zDiff = point->z - pos->z; + point = &point[pointIndex]; + diffXRand = (randPlusMinusPoint5Scaled(100.0f) + point->x) - pos->x; + diffZRand = (randPlusMinusPoint5Scaled(100.0f) + point->z) - pos->z; + diffX = point->x - pos->x; + diffZ = point->z - pos->z; } else { - phi_f14 = 0.0f; - sp1C = 0.0f; - xDiff = 0.0f; - zDiff = 0.0f; + diffXRand = 0.0f; + diffZRand = 0.0f; + diffX = 0.0f; + diffZ = 0.0f; } - *arg3 = SQ(xDiff) + SQ(zDiff); - return RADF_TO_BINANG(Math_Acot2F(sp1C, phi_f14)); + *distSQ = SQ(diffX) + SQ(diffZ); + return RADF_TO_BINANG(Math_Acot2F(diffZRand, diffXRand)); } -void func_80B248B8(EnRacedog* this, Vec3f* arg1) { - f32 sp20; - f32 sp1C; +void EnRacedog_GetFloorRot(EnRacedog* this, Vec3f* floorRot) { + f32 ny; + f32 nz; if (this->actor.floorPoly != NULL) { - sp20 = COLPOLY_GET_NORMAL(this->actor.floorPoly->normal.y); - sp1C = COLPOLY_GET_NORMAL(this->actor.floorPoly->normal.z); + ny = COLPOLY_GET_NORMAL(this->actor.floorPoly->normal.y); + nz = COLPOLY_GET_NORMAL(this->actor.floorPoly->normal.z); - arg1->x = -Math_Acot2F(1.0f, -sp1C * sp20); + floorRot->x = -Math_Acot2F(1.0f, -nz * ny); } } -void EnRacedog_Init(Actor* thisx, GlobalContext* globalCtx) { +void EnRacedog_Init(Actor* thisx, PlayState* play) { EnRacedog* this = THIS; ColliderCylinder* collider = &this->collider; 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); + SkelAnime_InitFlex(play, &this->skelAnime, &gDogSkel, NULL, this->jointTable, this->morphTable, DOG_LIMB_MAX); + Collider_InitCylinder(play, collider); + Collider_SetCylinder(play, collider, &this->actor, &sCylinderInit); CollisionCheck_SetInfo2(&this->actor.colChkInfo, &sDamageTable, &sColChkInfoInit); Actor_ProcessInitChain(&this->actor, sInitChain); - this->unk_1E0 = SubS_GetPathByIndex(globalCtx, ENRACEDOG_GET_PATH(&this->actor), 0x3F); + this->path = SubS_GetPathByIndex(play, ENRACEDOG_GET_PATH(&this->actor), 0x3F); Actor_SetScale(&this->actor, 0.0075f); this->actor.gravity = -3.0f; - if (ENRACEDOG_GET_3E0(&this->actor) < 14) { - this->unk_290 = ENRACEDOG_GET_3E0(&this->actor); + if (ENRACEDOG_GET_INDEX(&this->actor) < 14) { + this->index = ENRACEDOG_GET_INDEX(&this->actor); } else { Actor_MarkForDeath(&this->actor); } - this->unk_2BC = 0xFF; - this->unk_2C0 = 0x32; - this->unk_288 = 0xC; - this->unk_2A0.x = 0.0f; - this->unk_2A0.y = 0.0f; - this->unk_2A0.z = 0.0f; - this->unk_2C4 = 1.0f; + 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; - if ((D_80B25D88[this->unk_290].unk_0E >= 0x353F) && (this->unk_290 == (s16)Rand_ZeroFloat(20.0f))) { - this->unk_28C = 5; + // 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->unk_28C = 0; + this->extraTimeBeforeRaceStart = 0; } - this->unk_28A = 60; - this->unk_28A += this->unk_28C; - this->unk_298 = D_80B25D50[D_80B25D88[this->unk_290].unk_08][0]; - this->unk_29C = 0; - this->unk_2B8 = -1; + 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; - func_80B24E14(this); + EnRacedog_UpdateTextId(this); this->actor.flags |= ACTOR_FLAG_10; this->actor.flags |= ACTOR_FLAG_20; - D_80B25E68 = D_80B25D88[(s16)((gSaveContext.eventInf[0] & 0xF8) >> 3)]; - this->unk_292 = D_80B25E68.unk_0A; - func_80B24630(&this->skelAnime, D_80B25EF0, 0); - D_80B25EF0->playSpeed = Rand_ZeroFloat(0.5f) + 1.0f; - this->actionFunc = func_80B24C14; + + sSelectedDogInfo = sDogInfo[(s16)((gSaveContext.eventInf[0] & 0xF8) >> 3)]; + this->selectedDogIndex = sSelectedDogInfo.index; + + EnRacedog_ChangeAnim(&this->skelAnime, sAnimationInfo, RACEDOG_ANIM_IDLE); + sAnimationInfo[RACEDOG_ANIM_IDLE].playSpeed = Rand_ZeroFloat(0.5f) + 1.0f; + this->actionFunc = EnRacedog_RaceStart; } -void EnRacedog_Destroy(Actor* thisx, GlobalContext* globalCtx) { +void EnRacedog_Destroy(Actor* thisx, PlayState* play) { EnRacedog* this = THIS; - Collider_DestroyCylinder(globalCtx, &this->collider); + Collider_DestroyCylinder(play, &this->collider); } -void func_80B24C14(EnRacedog* this, GlobalContext* globalCtx) { - s16 phi_v1; - - if (this->unk_28A == 0) { - phi_v1 = 0; - } else { - this->unk_28A--; - phi_v1 = this->unk_28A; - } - - if (phi_v1 == 0) { - this->unk_28A = Rand_S16Offset(50, 50); - if (this->unk_28C == 0) { +/** + * 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, PlayState* play) { + if (DECR(this->raceStartTimer) == 0) { + this->raceStartTimer = Rand_S16Offset(50, 50); + if (this->extraTimeBeforeRaceStart == 0) { play_sound(NA_SE_SY_START_SHOT); } - func_80B24630(&this->skelAnime, D_80B25EF0, 2); - this->actionFunc = func_80B24CB4; + EnRacedog_ChangeAnim(&this->skelAnime, sAnimationInfo, RACEDOG_ANIM_RUN); + this->actionFunc = EnRacedog_Race; } } -void func_80B24CB4(EnRacedog* this, GlobalContext* globalCtx) { - s16 phi_a1; - f32 sp30; +/** + * This function handles the dog's behavior and state for the entire time the race is going. + */ +void EnRacedog_Race(EnRacedog* this, PlayState* play) { + s16 yRotation; + f32 distSq; this->collider.dim.radius = 15; - if (this->unk_1E0 != 0) { - phi_a1 = func_80B2478C(this->unk_1E0, this->unk_1E8, &this->actor.world.pos, &sp30); + if (this->path != NULL) { + yRotation = EnRacedog_GetYRotation(this->path, this->currentPoint, &this->actor.world.pos, &distSq); if (this->actor.bgCheckFlags & 8) { - phi_a1 = this->actor.wallYaw; + yRotation = this->actor.wallYaw; } - Math_SmoothStepToS(&this->actor.world.rot.y, phi_a1, 4, 0x3E8, 1); + Math_SmoothStepToS(&this->actor.world.rot.y, yRotation, 4, 0x3E8, 1); this->actor.shape.rot.y = this->actor.world.rot.y; - if (sp30 <= 2500.0f) { - this->unk_1E8++; - if (this->unk_1E8 >= (this->unk_1E0->count - 1)) { - this->unk_1E8 = 0; + if (distSq <= SQ(50.0f)) { + this->currentPoint++; + if (this->currentPoint >= (this->path->count - 1)) { + this->currentPoint = 0; } } - func_80B24F08(this); - if ((this->unk_1E8 >= ((this->unk_1E0->count / 4) * 3)) && (this->unk_290 == D_80B25D4C)) { - D_80B25D48++; + 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++; } - func_80B252F8(this); - func_80B2538C(this); + EnRacedog_UpdateRaceVariables(this); + EnRacedog_CheckForFinish(this); Actor_MoveWithGravity(&this->actor); } - func_80B25448(this); - func_80B256BC(this); - func_80B255AC(this, globalCtx); + EnRacedog_UpdateRunAnimationPlaySpeed(this); + EnRacedog_PlaySfxWalk(this); + EnRacedog_SpawnFloorDustRing(this, play); } -void func_80B24E14(EnRacedog* this) { - if (this->unk_290 % 2) { - D_80B25D88[this->unk_290].unk_0E = - (((gSaveContext.save.weekEventReg[42 + (this->unk_290 / 2)]) & (0x10 | 0x20 | 0x40 | 0x80)) >> 4) + 0x3539; +/** + * Updates the text ID in sDogInfo based on what was set in the weekEventRegs by + * En_Aob_01. This makes it so sDogInfo can be used in other functions to determine + * the condition of the dog. + * + * Note that the text IDs generated by this function are off-by-one compared to the + * similar function in EnDg. The end result of this is that one of the dogs that says + * it's in good condition when you pick it up is actually in normal condition once the + * race starts, and one of the dogs that says it's in normal condition when you pick + * it up is actually in bad condition. It's unknown whether this is a simple oversight + * or an intentional choice to introduce a bit of extra variance to the race. + */ +void EnRacedog_UpdateTextId(EnRacedog* this) { + // Assuming that the weekEventRegs haven't been tampered with, then this will produce a text ID in the + // range of 0x3539 to 0x3546. + if (this->index % 2) { + sDogInfo[this->index].textId = + (((gSaveContext.save.weekEventReg[42 + (this->index / 2)]) & 0xF0) >> 4) + 0x3539; } else { - D_80B25D88[this->unk_290].unk_0E = - ((gSaveContext.save.weekEventReg[42 + (this->unk_290 / 2)]) & (1 | 2 | 4 | 8)) + 0x3539; + sDogInfo[this->index].textId = ((gSaveContext.save.weekEventReg[42 + (this->index / 2)]) & 0x0F) + 0x3539; } - if ((D_80B25D88[this->unk_290].unk_0E >= 0x3547) || (D_80B25D88[this->unk_290].unk_0E < 0x3539)) { - D_80B25D88[this->unk_290].unk_0E = 0x353E; + // As a sanity check, this makes sure the text ID is something in the expected range of 0x3539 to 0x3546. + if ((sDogInfo[this->index].textId > 0x3546) || (sDogInfo[this->index].textId < 0x3539)) { + sDogInfo[this->index].textId = 0x353E; } - if (D_80B25D88[this->unk_290].unk_0E == 0x3547) { - D_80B25D88[this->unk_290].unk_0E = 0x3538; + + // 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; } } -void func_80B24F08(EnRacedog* this) { - s32 temp_a0; - s32 temp_v1 = this->unk_1E0->count; +/** + * 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; - if (this->unk_2B8 < this->unk_1E8) { - this->unk_2B8 = this->unk_1E8; - if (this->unk_1E8 == 0) { - this->unk_298 = D_80B25D50[D_80B25D88[this->unk_290].unk_08][0]; + // 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 { - temp_a0 = temp_v1 / 4; - if (this->unk_1E8 < temp_a0) { - if (D_80B25D88[this->unk_290].unk_08 == 5) { - this->unk_298 = D_80B25D50[D_80B25D88[this->unk_290].unk_08][0] + randPlusMinusPoint5Scaled(1.0f); + 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->unk_298 = 5.0f + randPlusMinusPoint5Scaled(1.0f); + this->targetSpeed = 5.0f + randPlusMinusPoint5Scaled(1.0f); } - if ((D_80B25D88[this->unk_290].unk_0E < 0x353E) && (this->unk_290 != D_80B25D4C)) { - this->unk_298 *= D_80B25D88[this->unk_290].unk_04; + if (DOG_IS_IN_GOOD_CONDITION(this) && (this->index != sFirstPlaceIndex)) { + this->targetSpeed *= sDogInfo[this->index].goodConditionSpeedMultiplier; } - } else if (this->unk_1E8 < (temp_a0 * 3)) { - if (this->unk_1E8 < D_80B25D88[this->unk_290].unk_0C) { - this->unk_298 = 5.0f + randPlusMinusPoint5Scaled(1.0f); + } else 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->unk_298 = D_80B25D50[D_80B25D88[this->unk_290].unk_08][1] + randPlusMinusPoint5Scaled(1.0f); + this->targetSpeed = sBaseSpeeds[sDogInfo[this->index].color][1] + randPlusMinusPoint5Scaled(1.0f); - if ((D_80B25D88[this->unk_290].unk_0E < 0x353E) && (this->unk_290 != D_80B25D4C)) { - this->unk_298 *= D_80B25D88[this->unk_290].unk_04; + if (DOG_IS_IN_GOOD_CONDITION(this) && (this->index != sFirstPlaceIndex)) { + this->targetSpeed *= sDogInfo[this->index].goodConditionSpeedMultiplier; } } - } else if (this->unk_1E8 < temp_v1) { - func_80B251EC(this); + } else if (this->currentPoint < pathCount) { + // The dog is more than 3/4ths of the way through the race track. + EnRacedog_CalculateFinalStretchTargetSpeed(this); } else { - this->unk_298 = randPlusMinusPoint5Scaled(1.0f) + 5.0f; + this->targetSpeed = randPlusMinusPoint5Scaled(1.0f) + 5.0f; } } } - if ((this->unk_1E8 != 0) || (this->unk_29C != 0)) { + // 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->unk_298, 0.5f, 3.0f); + Math_ApproachF(&this->actor.speedXZ, this->targetSpeed, 0.5f, 3.0f); - if (this->unk_290 == this->unk_292) { + // 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; } @@ -399,66 +527,90 @@ void func_80B24F08(EnRacedog* this) { } } -void func_80B251EC(EnRacedog* this) { - f32 temp; +/** + * 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; - if (D_80B25D88[this->unk_290].unk_00 == -1.0f) { - if (D_80B25D48 < 100.0f) { - D_80B25D88[this->unk_290].unk_00 = 200.0f / (200.0f - D_80B25D48); + // 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 { - D_80B25D88[this->unk_290].unk_00 = 2.0f; + sDogInfo[this->index].sprintSpeedMultiplier = 2.0f; } } - if (D_80B25D88[this->unk_290].unk_0E < 0x3542) { - temp = D_80B25D88[this->unk_290].unk_00; - this->unk_298 = temp * D_80B25D50[D_80B25D88[this->unk_290].unk_08][1]; + if (!DOG_IS_IN_BAD_CONDITION(this)) { + sprintSpeedMultiplier = sDogInfo[this->index].sprintSpeedMultiplier; + this->targetSpeed = sprintSpeedMultiplier * sBaseSpeeds[sDogInfo[this->index].color][1]; } - if ((D_80B25D88[this->unk_290].unk_0E < 0x353E) && (this->unk_290 != D_80B25D4C)) { - this->unk_298 *= D_80B25D88[this->unk_290].unk_04; + if (DOG_IS_IN_GOOD_CONDITION(this) && (this->index != sFirstPlaceIndex)) { + this->targetSpeed *= sDogInfo[this->index].goodConditionSpeedMultiplier; } } -void func_80B252F8(EnRacedog* this) { - if ((this->unk_1E8 >= 9) && (this->unk_29C == 0)) { - this->unk_29C = 1; +/** + * 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->unk_1E8 >= 0xB) && (this->unk_29C == 1)) { - this->unk_29C = 2; + if ((this->currentPoint >= 11) && (this->raceStatus == RACEDOG_RACE_STATUS_BETWEEN_POINTS_9_AND_11)) { + this->raceStatus = RACEDOG_RACE_STATUS_AFTER_POINT_11; } - if (((this->unk_1E8 >= D_80B25D44) || (this->unk_29C <= 0)) && (this->unk_1E8 > D_80B25D44)) { - D_80B25D44 = this->unk_1E8; - D_80B25D4C = this->unk_290; + if (((this->currentPoint >= sFurthestPoint) || (this->raceStatus <= RACEDOG_RACE_STATUS_BEFORE_POINT_9)) && + (this->currentPoint > sFurthestPoint)) { + sFurthestPoint = this->currentPoint; + sFirstPlaceIndex = this->index; } } -void func_80B2538C(EnRacedog* this) { - if (func_80B25490(this, D_80B25E78) && this->unk_29C == 2) { - D_80B25D40++; - if (D_80B25D40 == 1) { +/** + * 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->unk_29C = 3; - if (this->unk_290 == this->unk_292) { - gSaveContext.eventInf[0] = (gSaveContext.eventInf[0] & 7) | (D_80B25D40 * 8); + this->raceStatus = RACEDOG_RACE_STATUS_FINISHED; + if (this->index == this->selectedDogIndex) { + gSaveContext.eventInf[0] = (gSaveContext.eventInf[0] & 7) | (sNumberOfDogsFinished * 8); } } } -void func_80B25448(EnRacedog* this) { +/** + * 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) { - D_80B25EF0[2].playSpeed = 0.9f; + sAnimationInfo[RACEDOG_ANIM_RUN].playSpeed = 0.9f; } else { - D_80B25EF0[2].playSpeed = 1.0f; + sAnimationInfo[RACEDOG_ANIM_RUN].playSpeed = 1.0f; } } -s32 func_80B25490(EnRacedog* this, Vec2f* arg1) { +/** + * 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; @@ -467,53 +619,57 @@ s32 func_80B25490(EnRacedog* this, Vec2f* arg1) { f32 zDistToBottomFront; f32 zDistToTopBack; f32 xDistToTopBack; - f32 temp_f0; - f32 temp; + f32 frontPointsCrossProduct; + f32 crossProductTemp; - xDistToTopFront = this->actor.world.pos.x - arg1[0].x; - zDistToTopFront = this->actor.world.pos.z - arg1[0].z; - xDistToBottomFront = this->actor.world.pos.x - arg1[1].x; - zDistToBottomFront = this->actor.world.pos.z - arg1[1].z; - xDistToBottomBack = this->actor.world.pos.x - arg1[2].x; - zDistToBottomBack = this->actor.world.pos.z - arg1[2].z; - xDistToTopBack = this->actor.world.pos.x - arg1[3].x; - zDistToTopBack = this->actor.world.pos.z - arg1[3].z; + 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; - temp_f0 = ((xDistToTopFront * zDistToBottomFront) - (xDistToBottomFront * zDistToTopFront)); - temp = (((xDistToBottomFront * zDistToBottomBack) - (xDistToBottomBack * zDistToBottomFront))); - if (temp_f0 * temp < 0.0f) { + // 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; } - temp_f0 = ((xDistToTopFront * zDistToBottomFront) - (xDistToBottomFront * zDistToTopFront)); - temp = ((xDistToBottomBack * zDistToTopBack) - (xDistToTopBack * zDistToBottomBack)); - if (temp_f0 * temp < 0.0f) { + // 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; } - temp_f0 = ((xDistToTopFront * zDistToBottomFront) - (xDistToBottomFront * zDistToTopFront)); - temp = ((xDistToTopBack * zDistToTopFront) - (xDistToTopFront * zDistToTopBack)); - if (temp_f0 * temp < 0.0f) { + // 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 func_80B255AC(EnRacedog* this, GlobalContext* globalCtx) { +void EnRacedog_SpawnFloorDustRing(EnRacedog* this, PlayState* play) { s16 curFrame = this->skelAnime.curFrame; s16 mod = (this->actor.speedXZ > 6.0f) ? 2 : 3; - Vec3f sp38; + Vec3f pos; - if (((this->unk_290 + curFrame) % mod) == 0) { - sp38.x = this->actor.world.pos.x + randPlusMinusPoint5Scaled(15.0f); - sp38.y = this->actor.world.pos.y; - sp38.z = this->actor.world.pos.z + randPlusMinusPoint5Scaled(15.0f); - Actor_SpawnFloorDustRing(globalCtx, &this->actor, &sp38, 10.0f, 0, 2.0f, 300, 0, true); + 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(play, &this->actor, &pos, 10.0f, 0, 2.0f, 300, 0, true); } } -void func_80B256BC(EnRacedog* this) { +void EnRacedog_PlaySfxWalk(EnRacedog* this) { s16 curFrame = this->skelAnime.curFrame; if ((curFrame == 1) || (curFrame == 7)) { @@ -521,21 +677,23 @@ void func_80B256BC(EnRacedog* this) { } } -void EnRacedog_Update(Actor* thisx, GlobalContext* globalCtx) { +void EnRacedog_Update(Actor* thisx, PlayState* play) { s32 pad; EnRacedog* this = THIS; - Vec3f sp2C = { 0.0f, 0.0f, 0.0f }; + Vec3f floorRot = { 0.0f, 0.0f, 0.0f }; - this->unk_292 = D_80B25E68.unk_0A; + this->selectedDogIndex = sSelectedDogInfo.index; - this->actionFunc(this, globalCtx); + this->actionFunc(this, play); - func_80B246F4(this, globalCtx); - func_80B248B8(this, &sp2C); - Math_ApproachF(&this->unk_2AC.x, sp2C.x, 0.2f, 0.1f); + EnRacedog_UpdateCollision(this, play); + EnRacedog_GetFloorRot(this, &floorRot); + Math_ApproachF(&this->curRot.x, floorRot.x, 0.2f, 0.1f); - if (this->unk_2A0.x > 0.0f) { - if ((this->unk_2AC.x < 0.0f) && (this->unk_2AC.x > -0.1f)) { + 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; } @@ -545,118 +703,115 @@ void EnRacedog_Update(Actor* thisx, GlobalContext* globalCtx) { this->skelAnime.curFrame = 0.0f; } - this->unk_2A0 = this->unk_2AC; + this->prevRot = this->curRot; SkelAnime_Update(&this->skelAnime); } -void func_80B2583C(EnRacedog* this) { - s16 phi_v1; - - if (this->unk_288 >= 7) { - this->unk_2BC -= 0x10; - this->unk_2C0 += 8; - this->unk_2C4 += 0.05f; +void EnRacedog_UpdateSelectionArrow(EnRacedog* this) { + if (this->selectionArrowTimer > 6) { + this->selectionArrowGreenPrimColor -= 16; + this->selectionArrowGreenEnvColor += 8; + this->selectionArrowScale += 0.05f; } else { - this->unk_2BC += 0x10; - this->unk_2C0 -= 8; - this->unk_2C4 -= 0.05f; + this->selectionArrowGreenPrimColor += 16; + this->selectionArrowGreenEnvColor -= 8; + this->selectionArrowScale -= 0.05f; } - if (this->unk_288 == 0) { - phi_v1 = 0; - } else { - this->unk_288--; - phi_v1 = this->unk_288; - } - - if (phi_v1 == 0) { - this->unk_288 = 0xC; + if (DECR(this->selectionArrowTimer) == 0) { + this->selectionArrowTimer = 12; } } -void func_80B258D8(EnRacedog* this, GlobalContext* globalCtx) { - Vec3s sp48 = gZeroVec3s; - s32 phi_v0 = (this->unk_290 == this->unk_292) ? true : false; +void EnRacedog_DrawSelectionArrow(EnRacedog* this, PlayState* play) { + Vec3s rotation = gZeroVec3s; + s32 shouldDrawSelectionArrow = (this->index == this->selectedDogIndex) ? true : false; - if (phi_v0) { - OPEN_DISPS(globalCtx->state.gfxCtx); + if (shouldDrawSelectionArrow) { + OPEN_DISPS(play->state.gfxCtx); - func_8012C28C(globalCtx->state.gfxCtx); - func_80B2583C(this); - Matrix_SetStateRotationAndTranslation(this->actor.world.pos.x, this->actor.world.pos.y + 40.0f, - this->actor.world.pos.z, &sp48); + func_8012C28C(play->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->unk_2BC, 0, 255); - gDPSetEnvColor(POLY_OPA_DISP++, 255, this->unk_2C0, 0, 255); - Matrix_Scale(this->unk_2C4 * 2.0f, this->unk_2C4 * 2.0f, this->unk_2C4 * 2.0f, MTXMODE_APPLY); - gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + 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(play->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); + CLOSE_DISPS(play->state.gfxCtx); } } -s32 EnRacedog_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, - Actor* thisx) { +s32 EnRacedog_OverrideLimbDraw(PlayState* play, 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) { +void EnRacedog_PostLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx) { s32 pad; EnRacedog* this = THIS; - Vec3f sp1C = { 0.0f, 20.0f, 0.0f }; + Vec3f focusOffset = { 0.0f, 20.0f, 0.0f }; if (limbIndex == DOG_LIMB_HEAD) { - Matrix_MultiplyVector3fByState(&sp1C, &this->actor.focus.pos); + Matrix_MultVec3f(&focusOffset, &this->actor.focus.pos); } if (limbIndex == DOG_LIMB_TAIL) { - func_80B258D8(this, globalCtx); + EnRacedog_DrawSelectionArrow(this, play); } } -void EnRacedog_Draw(Actor* thisx, GlobalContext* globalCtx) { +void EnRacedog_Draw(Actor* thisx, PlayState* play) { EnRacedog* this = THIS; - OPEN_DISPS(globalCtx->state.gfxCtx); + OPEN_DISPS(play->state.gfxCtx); - func_8012C28C(globalCtx->state.gfxCtx); + func_8012C28C(play->state.gfxCtx); gDPPipeSync(POLY_OPA_DISP++); - switch (D_80B25D88[this->unk_290].unk_08) { - case 3: + switch (sDogInfo[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_2AC.x); - Matrix_InsertZRotation_s(this->actor.shape.rot.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->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, + SkelAnime_DrawFlexOpa(play, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, EnRacedog_OverrideLimbDraw, EnRacedog_PostLimbDraw, &this->actor); - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->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 19f7af7a5..b0b40be64 100644 --- a/src/overlays/actors/ovl_En_Racedog/z_en_racedog.h +++ b/src/overlays/actors/ovl_En_Racedog/z_en_racedog.h @@ -4,12 +4,23 @@ #include "global.h" #include "objects/object_dog/object_dog.h" -#define ENRACEDOG_GET_3E0(thisx) (((thisx)->params & 0x3E0) >> 5) +#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 void (*EnRacedogActionFunc)(struct EnRacedog*, PlayState*); typedef struct EnRacedog { /* 0x000 */ Actor actor; @@ -18,26 +29,26 @@ typedef struct EnRacedog { /* 0x14C */ SkelAnime skelAnime; /* 0x190 */ ColliderCylinder collider; /* 0x1DC */ UNK_TYPE1 unk_1DC[0x4]; - /* 0x1E0 */ Path* unk_1E0; + /* 0x1E0 */ Path* path; /* 0x1E4 */ UNK_TYPE1 unk_1E4[0x4]; - /* 0x1E8 */ s32 unk_1E8; + /* 0x1E8 */ s32 currentPoint; /* 0x1EC */ Vec3s jointTable[DOG_LIMB_MAX]; /* 0x23A */ Vec3s morphTable[DOG_LIMB_MAX]; - /* 0x288 */ s16 unk_288; - /* 0x28A */ s16 unk_28A; - /* 0x28C */ s16 unk_28C; + /* 0x288 */ s16 selectionArrowTimer; + /* 0x28A */ s16 raceStartTimer; + /* 0x28C */ s16 extraTimeBeforeRaceStart; /* 0x28A */ UNK_TYPE1 unk_28E[0x2]; - /* 0x290 */ s16 unk_290; - /* 0x292 */ s16 unk_292; + /* 0x290 */ s16 index; + /* 0x292 */ s16 selectedDogIndex; /* 0x294 */ UNK_TYPE1 unk_294[0x4]; - /* 0x298 */ f32 unk_298; - /* 0x29C */ s16 unk_29C; - /* 0x2A0 */ Vec3f unk_2A0; - /* 0x2AC */ Vec3f unk_2AC; - /* 0x2B8 */ s32 unk_2B8; - /* 0x2BC */ s32 unk_2BC; - /* 0x2C0 */ s32 unk_2C0; - /* 0x2C4 */ f32 unk_2C4; + /* 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 a32811620..a3d91bba9 100644 --- a/src/overlays/actors/ovl_En_Raf/z_en_raf.c +++ b/src/overlays/actors/ovl_En_Raf/z_en_raf.c @@ -1,7 +1,7 @@ /* * File: z_en_raf.c * Overlay: ovl_En_Raf - * Description: Carnivorous Lilypad + * Description: Carnivorous Lily Pad */ #include "z_en_raf.h" @@ -10,21 +10,63 @@ #define THIS ((EnRaf*)thisx) -void EnRaf_Init(Actor* thisx, GlobalContext* globalCtx); -void EnRaf_Destroy(Actor* thisx, GlobalContext* globalCtx); -void EnRaf_Update(Actor* thisx, GlobalContext* globalCtx); -void EnRaf_Draw(Actor* thisx, GlobalContext* globalCtx); +void EnRaf_Init(Actor* thisx, PlayState* play); +void EnRaf_Destroy(Actor* thisx, PlayState* play); +void EnRaf_Update(Actor* thisx, PlayState* play); +void EnRaf_Draw(Actor* thisx, PlayState* play); -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, PlayState* play); +void EnRaf_SetupGrab(EnRaf* this); +void EnRaf_Grab(EnRaf* this, PlayState* play); +void EnRaf_SetupChew(EnRaf* this); +void EnRaf_Chew(EnRaf* this, PlayState* play); +void EnRaf_SetupThrow(EnRaf* this, PlayState* play); +void EnRaf_Throw(EnRaf* this, PlayState* play); +void EnRaf_Explode(EnRaf* this, PlayState* play); +void EnRaf_PostDetonation(EnRaf* this, PlayState* play); +void EnRaf_Convulse(EnRaf* this, PlayState* play); +void EnRaf_SetupDissolve(EnRaf* this); +void EnRaf_Dissolve(EnRaf* this, PlayState* play); +void EnRaf_SetupDormant(EnRaf* this); +void EnRaf_Dormant(EnRaf* this, PlayState* play); +void EnRaf_InitializeEffect(EnRaf* this, Vec3f* pos, Vec3f* velocity, Vec3f* accel, f32 scale, s16 timer); +void EnRaf_UpdateEffects(EnRaf* this, PlayState* play); +void EnRaf_DrawEffects(EnRaf* this, PlayState* play); + +typedef enum { + /* 0 */ EN_RAF_ANIM_IDLE, + /* 1 */ EN_RAF_ANIM_CLOSE, + /* 2 */ EN_RAF_ANIM_CHEW, + /* 3 */ EN_RAF_ANIM_SPIT, + /* 4 */ EN_RAF_ANIM_CONVULSE, + /* 5 */ EN_RAF_ANIM_DEATH, +} EnRafAnimation; + +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, PlayState* play) { + 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(play, &play->colCtx.dyna, &this->dyna.actor, colHeader); + Collider_InitAndSetCylinder(play, &this->collider, &this->dyna.actor, &sCylinderInit); + this->dyna.actor.targetMode = 3; + this->dyna.actor.colChkInfo.mass = MASS_IMMOVABLE; + SkelAnime_InitFlex(play, &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(play, 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, PlayState* play) { + EnRaf* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Raf/func_80A17464.s") + DynaPoly_DeleteBgActor(play, &play->colCtx.dyna, this->dyna.bgId); + Collider_DestroyCylinder(play, &this->collider); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Raf/func_80A17530.s") +void EnRaf_ChangeAnim(EnRaf* this, s32 animIndex) { + 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[animIndex]); + if (animIndex == EN_RAF_ANIM_IDLE) { + startFrame = this->endFrame; + } else if (animIndex == EN_RAF_ANIM_CLOSE) { + playSpeed = 2.0f; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Raf/func_80A17848.s") + Animation_Change(&this->skelAnime, sAnimations[animIndex], playSpeed, startFrame, this->endFrame, + sAnimationModes[animIndex], -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_ChangeAnim(this, EN_RAF_ANIM_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, PlayState* play) { + Player* player = GET_PLAYER(play); + 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) && + play->grabPlayer(play, 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 ((play->gameplayFrames % 2) == 0) { + return; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Raf/EnRaf_Update.s") + explosive = play->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_ChangeAnim(this, EN_RAF_ANIM_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, PlayState* play) { + Player* player = GET_PLAYER(play); + 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_ChangeAnim(this, EN_RAF_ANIM_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, PlayState* play) { + f32 targetChewScale; + f32 curFrame; + Player* player = GET_PLAYER(play); + + 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: + play->damagePlayer(play, -2); + func_800B8E58((Player*)this, player->ageProperties->unk_92 + NA_SE_VO_LI_DAMAGE_S); + CollisionCheck_GreenBlood(play, NULL, &player->actor.world.pos); + if ((this->chewCount > (BREG(53) + 5)) || !(player->stateFlags2 & 0x80)) { + player->actor.freezeTimer = 10; + EnRaf_SetupThrow(this, play); + return; + } + break; + + case EN_RAF_GRAB_TARGET_EXPLOSIVE: + Actor_ApplyDamage(&this->dyna.actor); + if (this->chewCount > (BREG(54) + 4)) { + EnRaf_Explode(this, play); + 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, play); + } + break; + } + } +} + +void EnRaf_SetupThrow(EnRaf* this, PlayState* play) { + Player* player = GET_PLAYER(play); + + EnRaf_ChangeAnim(this, EN_RAF_ANIM_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, PlayState* play) { + Player* player = GET_PLAYER(play); + 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(play, &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, PlayState* play) { + 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(&play->actorCtx, play, ACTOR_EN_CLEAR_TAG, explosionPos.x, explosionPos.y, explosionPos.z, 0, 0, 0, + CLEAR_TAG_SMALL_EXPLOSION); + Actor_PlaySfxAtPos(&this->dyna.actor, NA_SE_IT_BOMB_EXPLOSION); + Actor_PlaySfxAtPos(&this->dyna.actor, NA_SE_EN_SUISEN_DEAD); + if (this->switchFlag >= 0) { + Flags_SetSwitch(play, 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(play, &play->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, PlayState* play) { + if (this->timer == 0) { + this->collider.dim.radius = 50; + this->collider.dim.height = 10; + func_800BC154(play, &play->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(play, &play->colChkCtx, &this->collider.base); + } +} + +void EnRaf_SetupConvulse(EnRaf* this) { + EnRaf_ChangeAnim(this, EN_RAF_ANIM_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, PlayState* play) { + f32 curFrame = this->skelAnime.curFrame; + + if (this->endFrame <= curFrame) { + this->chewCount++; + if (this->chewCount > (BREG(2) + 2)) { + if (this->switchFlag >= 0) { + Flags_SetSwitch(play, this->switchFlag); + } + + EnRaf_SetupDissolve(this); + } + } +} + +void EnRaf_SetupDissolve(EnRaf* this) { + EnRaf_ChangeAnim(this, EN_RAF_ANIM_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, PlayState* play) { + 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, PlayState* play) { + 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_ChangeAnim(this, EN_RAF_ANIM_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, PlayState* play) { + 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, play); + + 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(play, &play->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(play, &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, play); + } + + 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(play, &play->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(PlayState* play2, s32 limbIndex, Actor* thisx) { + PlayState* play = play2; + 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 * play->gameplayFrames), MTXMODE_APPLY); + Matrix_RotateXS((this->chewLimbRot[limbIndex].x * play->gameplayFrames), MTXMODE_APPLY); + Matrix_RotateZS((this->chewLimbRot[limbIndex].z * play->gameplayFrames), MTXMODE_APPLY); + Matrix_Scale(this->chewScale + 1.0f, 1.0f, 1.0f, MTXMODE_APPLY); + Matrix_RotateZS(-(this->chewLimbRot[limbIndex].z * play->gameplayFrames), MTXMODE_APPLY); + Matrix_RotateXS(-(this->chewLimbRot[limbIndex].x * play->gameplayFrames), MTXMODE_APPLY); + Matrix_RotateYS(-(this->chewLimbRot[limbIndex].y * play->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, PlayState* play) { + EnRaf* this = THIS; + + func_8012C28C(play->state.gfxCtx); + func_8012C2DC(play->state.gfxCtx); + SkelAnime_DrawTransformFlexOpa(play, 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, play); + } +} + +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, PlayState* play) { + 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(play, &effect->pos, NULL, NULL, 0, effect->scale * 200000.0f); + SoundSource_PlaySfxAtFixedWorldPos(play, &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, PlayState* play) { + s16 i; + EnRafEffect* effect = this->effects; + GraphicsContext* gfxCtx = play->state.gfxCtx; + + OPEN_DISPS(gfxCtx); + + func_8012C28C(play->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..831346d38 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 void (*EnRafActionFunc)(struct EnRaf*, PlayState*); + +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 e1971c182..095ee3fec 100644 --- a/src/overlays/actors/ovl_En_Rail_Skb/z_en_rail_skb.c +++ b/src/overlays/actors/ovl_En_Rail_Skb/z_en_rail_skb.c @@ -4,49 +4,49 @@ * Description: Ikana Graveyard - Circle of Stalchildren */ -#include "overlays/actors/ovl_Obj_Hakaisi/z_obj_hakaisi.h" #include "z_en_rail_skb.h" +#include "overlays/effects/ovl_Effect_Ss_Hahen/z_eff_ss_hahen.h" #include "objects/object_skb/object_skb.h" #define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_4 | ACTOR_FLAG_10) #define THIS ((EnRailSkb*)thisx) -void EnRailSkb_Init(Actor* thisx, GlobalContext* globalCtx); -void EnRailSkb_Destroy(Actor* thisx, GlobalContext* globalCtx); -void EnRailSkb_Update(Actor* thisx, GlobalContext* globalCtx); -void EnRailSkb_Draw(Actor* thisx, GlobalContext* globalCtx); +void EnRailSkb_Init(Actor* thisx, PlayState* play); +void EnRailSkb_Destroy(Actor* thisx, PlayState* play); +void EnRailSkb_Update(Actor* thisx, PlayState* play); +void EnRailSkb_Draw(Actor* thisx, PlayState* play); void func_80B70FA0(EnRailSkb* this); -void func_80B70FF8(EnRailSkb* this, GlobalContext* globalCtx); -void func_80B710E4(EnRailSkb* this, GlobalContext* globalCtx); -void func_80B7114C(EnRailSkb* this, GlobalContext* globalCtx); -void func_80B7123C(EnRailSkb* this, GlobalContext* globalCtx); +void func_80B70FF8(EnRailSkb* this, PlayState* play); +void func_80B710E4(EnRailSkb* this, PlayState* play); +void func_80B7114C(EnRailSkb* this, PlayState* play); +void func_80B7123C(EnRailSkb* this, PlayState* play); void func_80B712FC(EnRailSkb* this); -void func_80B71314(EnRailSkb* this, GlobalContext* globalCtx); +void func_80B71314(EnRailSkb* this, PlayState* play); void func_80B71354(EnRailSkb* this); -void func_80B713A4(EnRailSkb* this, GlobalContext* globalCtx); +void func_80B713A4(EnRailSkb* this, PlayState* play); void func_80B71488(EnRailSkb* this); -void func_80B714D8(EnRailSkb* this, GlobalContext* globalCtx); +void func_80B714D8(EnRailSkb* this, PlayState* play); void func_80B7151C(EnRailSkb* this); -void func_80B715AC(EnRailSkb* this, GlobalContext* globalCtx); -void func_80B716A8(EnRailSkb* this, GlobalContext* globalCtx); +void func_80B715AC(EnRailSkb* this, PlayState* play); +void func_80B716A8(EnRailSkb* this, PlayState* play); void func_80B717C8(EnRailSkb* this); -void func_80B717E0(EnRailSkb* this, GlobalContext* globalCtx); -void func_80B718C4(EnRailSkb* this, GlobalContext* globalCtx); +void func_80B717E0(EnRailSkb* this, PlayState* play); +void func_80B718C4(EnRailSkb* this, PlayState* play); void func_80B71910(EnRailSkb* this); -void func_80B71954(EnRailSkb* this, GlobalContext* globalCtx); +void func_80B71954(EnRailSkb* this, PlayState* play); void func_80B71A08(EnRailSkb* this); -void func_80B71A58(EnRailSkb* this, GlobalContext* globalCtx); +void func_80B71A58(EnRailSkb* this, PlayState* play); void func_80B71B6C(EnRailSkb* this); -void func_80B71BB8(EnRailSkb* this, GlobalContext* globalCtx); -void func_80B71D8C(EnRailSkb* this, GlobalContext* globalCtx, EnRailSkbUnkFunc unkFunc); -void func_80B71EA8(EnRailSkb* this, GlobalContext* globalCtx); -void func_80B71F3C(EnRailSkb* this, GlobalContext* globalCtx); -void func_80B72100(EnRailSkb* this, GlobalContext* globalCtx); +void func_80B71BB8(EnRailSkb* this, PlayState* play); +void func_80B71D8C(EnRailSkb* this, PlayState* play, EnRailSkbUnkFunc unkFunc); +void func_80B71EA8(EnRailSkb* this, PlayState* play); +void func_80B71F3C(EnRailSkb* this, PlayState* play); +void func_80B72100(EnRailSkb* this, PlayState* play); void func_80B723F8(EnRailSkb* this); -void func_80B72430(EnRailSkb* this, GlobalContext* globalCtx, s32 arg2); -void func_80B726B4(EnRailSkb* this, GlobalContext* globalCtx); +void func_80B72430(EnRailSkb* this, PlayState* play, s32 arg2); +void func_80B726B4(EnRailSkb* this, PlayState* play); void func_80B72830(EnRailSkb* this, s16 arg1); s32 func_80B7285C(EnRailSkb* this); @@ -62,7 +62,7 @@ const ActorInit En_Rail_Skb_InitVars = { (ActorFunc)EnRailSkb_Draw, }; -static AnimationInfo sAnimations[] = { +static AnimationInfo sAnimationInfo[] = { { &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 }, @@ -112,7 +112,7 @@ static ColliderJntSphInit sJntSphInit = { OC2_TYPE_1, COLSHAPE_JNTSPH, }, - 2, + ARRAY_COUNT(sJntSphElementsInit), sJntSphElementsInit, }; @@ -153,9 +153,9 @@ static DamageTable sDamageTable = { /* Powder Keg */ DMG_ENTRY(1, 0xF), }; -void func_80B708C0(EnRailSkb* this, GlobalContext* globalCtx) { +void func_80B708C0(EnRailSkb* this, PlayState* play) { static s32 D_80B7348C = 0; - Path* path = &globalCtx->setupPathList[ENRAILSKB_GET_FF00(&this->actor)]; + Path* path = &play->setupPathList[ENRAILSKB_GET_FF00(&this->actor)]; Vec3f sp70; s32 phi_a3; @@ -168,8 +168,8 @@ void func_80B708C0(EnRailSkb* this, GlobalContext* globalCtx) { for (i = 1; (i < this->unk_2E8) && (i < 10); i++) { D_80B7348C++; - Actor_SpawnAsChild(&globalCtx->actorCtx, &this->actor, globalCtx, ACTOR_EN_RAIL_SKB, 0.0f, 0.0f, 0.0f, 0, 0, - 0, this->actor.params); + Actor_SpawnAsChild(&play->actorCtx, &this->actor, play, ACTOR_EN_RAIL_SKB, 0.0f, 0.0f, 0.0f, 0, 0, 0, + this->actor.params); } D_80B7348C = 0; } @@ -242,12 +242,12 @@ s32 func_80B70B04(EnRailSkb* this, Vec3f pos) { return ret; } -void func_80B70D24(EnRailSkb* this, GlobalContext* globalCtx) { - Actor* actor = globalCtx->actorCtx.actorLists[ACTORCAT_PROP].first; +void func_80B70D24(EnRailSkb* this, PlayState* play) { + Actor* actor = play->actorCtx.actorLists[ACTORCAT_PROP].first; while (actor != NULL) { if ((actor->id == ACTOR_OBJ_HAKAISI) && func_80B70B04(this, actor->world.pos)) { - if (Flags_GetSwitch(globalCtx, (actor->params & 0xFF00) >> 8)) { + if (Flags_GetSwitch(play, (actor->params & 0xFF00) >> 8)) { Actor_MarkForDeath(&this->actor); return; } @@ -264,19 +264,19 @@ static InitChainEntry sInitChain[] = { ICHAIN_F32_DIV1000(gravity, -2000, ICHAIN_STOP), }; -void EnRailSkb_Init(Actor* thisx, GlobalContext* globalCtx) { +void EnRailSkb_Init(Actor* thisx, PlayState* play) { s32 pad; EnRailSkb* this = THIS; - func_80B708C0(this, globalCtx); + func_80B708C0(this, play); ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 36.0f); - SkelAnime_Init(globalCtx, &this->skelAnime, &object_skb_Skel_005EF8, &object_skb_Anim_0064E0, this->jointTable, + SkelAnime_Init(play, &this->skelAnime, &object_skb_Skel_005EF8, &object_skb_Anim_0064E0, this->jointTable, this->morphTable, 20); - Collider_InitJntSph(globalCtx, &this->collider); - Collider_SetJntSph(globalCtx, &this->collider, &this->actor, &sJntSphInit, this->colliderElements); + Collider_InitJntSph(play, &this->collider); + Collider_SetJntSph(play, &this->collider, &this->actor, &sJntSphInit, this->colliderElements); CollisionCheck_SetInfo2(&this->actor.colChkInfo, &sDamageTable, &sColChkInfoInit); - if (Flags_GetSwitch(globalCtx, ENRAILSKB_GET_FF(&this->actor))) { + if (Flags_GetSwitch(play, ENRAILSKB_GET_FF(&this->actor))) { Actor_MarkForDeath(&this->actor); } @@ -296,29 +296,28 @@ void EnRailSkb_Init(Actor* thisx, GlobalContext* globalCtx) { this->unk_3F8 = 0; } - if ((globalCtx->sceneNum == SCENE_BOTI) && (gSaveContext.sceneSetupIndex == 1) && - (globalCtx->csCtx.currentCsIndex == 0)) { + if ((play->sceneNum == SCENE_BOTI) && (gSaveContext.sceneSetupIndex == 1) && (play->csCtx.currentCsIndex == 0)) { this->actor.flags |= ACTOR_FLAG_100000; } func_80B70FA0(this); } -void EnRailSkb_Destroy(Actor* thisx, GlobalContext* globalCtx) { +void EnRailSkb_Destroy(Actor* thisx, PlayState* play) { EnRailSkb* this = THIS; - Collider_DestroyJntSph(globalCtx, &this->collider); + Collider_DestroyJntSph(play, &this->collider); } void func_80B70FA0(EnRailSkb* this) { this->unk_3F2 = 0; if (this->actionFunc != func_80B716A8) { - Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 0); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, 0); } this->actionFunc = func_80B70FF8; } -void func_80B70FF8(EnRailSkb* this, GlobalContext* globalCtx) { +void func_80B70FF8(EnRailSkb* this, PlayState* play) { s16 temp_v0 = this->actor.yawTowardsPlayer - this->actor.shape.rot.y; if (this->actor.xzDistToPlayer < 65.0f) { @@ -339,7 +338,7 @@ void func_80B710AC(EnRailSkb* this) { this->actionFunc = func_80B710E4; } -void func_80B710E4(EnRailSkb* this, GlobalContext* globalCtx) { +void func_80B710E4(EnRailSkb* this, PlayState* play) { if (this->actor.colorFilterTimer == 0) { func_80B70FA0(this); } @@ -350,23 +349,23 @@ void func_80B71114(EnRailSkb* this) { this->actionFunc = func_80B7114C; } -void func_80B7114C(EnRailSkb* this, GlobalContext* globalCtx) { +void func_80B7114C(EnRailSkb* this, PlayState* play) { 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_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 3); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, 3); Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_STALKID_DAMAGE); this->unk_402 |= 1; func_80B712FC(this); } else { - SoundSource_PlaySfxAtFixedWorldPos(globalCtx, &this->actor.world.pos, 40, NA_SE_EN_STALKID_DEAD); + SoundSource_PlaySfxAtFixedWorldPos(play, &this->actor.world.pos, 40, NA_SE_EN_STALKID_DEAD); func_80B71488(this); } } else if (this->drawDmgEffTimer == 1) { - func_80B726B4(this, globalCtx); + func_80B726B4(this, play); } } @@ -374,19 +373,19 @@ void func_80B71228(EnRailSkb* this) { this->actionFunc = func_80B7123C; } -void func_80B7123C(EnRailSkb* this, GlobalContext* globalCtx) { +void func_80B7123C(EnRailSkb* this, PlayState* play) { 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_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 3); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, 3); Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_STALKID_DAMAGE); this->unk_402 |= 1; func_80B712FC(this); } else { - SoundSource_PlaySfxAtFixedWorldPos(globalCtx, &this->actor.world.pos, 40, NA_SE_EN_STALKID_DEAD); + SoundSource_PlaySfxAtFixedWorldPos(play, &this->actor.world.pos, 40, NA_SE_EN_STALKID_DEAD); func_80B71488(this); } } @@ -397,7 +396,7 @@ void func_80B712FC(EnRailSkb* this) { this->actionFunc = func_80B71314; } -void func_80B71314(EnRailSkb* this, GlobalContext* globalCtx) { +void func_80B71314(EnRailSkb* this, PlayState* play) { if (this->unk_3F2 >= 6) { func_80B70FA0(this); } else { @@ -407,16 +406,16 @@ void func_80B71314(EnRailSkb* this, GlobalContext* globalCtx) { void func_80B71354(EnRailSkb* this) { Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_STALKID_ATTACK); - Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 2); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, 2); this->actionFunc = func_80B713A4; } -void func_80B713A4(EnRailSkb* this, GlobalContext* globalCtx) { +void func_80B713A4(EnRailSkb* this, PlayState* play) { if (Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) { - if ((this->actor.xzDistToPlayer > 65.0f) || (Player_GetMask(globalCtx) == PLAYER_MASK_CAPTAIN)) { + if ((this->actor.xzDistToPlayer > 65.0f) || (Player_GetMask(play) == PLAYER_MASK_CAPTAIN)) { func_80B70FA0(this); } else { - Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 2); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, 2); } } @@ -438,7 +437,7 @@ void func_80B71488(EnRailSkb* this) { this->actionFunc = func_80B714D8; } -void func_80B714D8(EnRailSkb* this, GlobalContext* globalCtx) { +void func_80B714D8(EnRailSkb* this, PlayState* play) { if (this->actor.draw != NULL) { this->actor.draw = NULL; } @@ -457,15 +456,15 @@ void func_80B7151C(EnRailSkb* this) { this->actor.draw = EnRailSkb_Draw; this->actor.shape.shadowAlpha = 0; this->actor.shape.rot.y = this->actor.world.rot.y; - Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 1); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, 1); this->actionFunc = func_80B715AC; } -void func_80B715AC(EnRailSkb* this, GlobalContext* globalCtx) { +void func_80B715AC(EnRailSkb* this, PlayState* play) { if (Math_SmoothStepToF(&this->actor.shape.yOffset, 0.0f, 0.5f, 500.0f, 10.0f) == 0.0f) { func_80B70FA0(this); } else { - func_80B72430(this, globalCtx, 1); + func_80B72430(this, play, 1); } if (this->actor.shape.shadowAlpha != 255) { @@ -480,27 +479,27 @@ void func_80B715AC(EnRailSkb* this, GlobalContext* globalCtx) { void func_80B71650(EnRailSkb* this) { this->unk_3FE = 0; if (this->actionFunc != func_80B70FF8) { - Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 0); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, 0); } this->actionFunc = func_80B716A8; } -void func_80B716A8(EnRailSkb* this, GlobalContext* globalCtx) { - if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { +void func_80B716A8(EnRailSkb* this, PlayState* play) { + if (Actor_ProcessTalkRequest(&this->actor, &play->state)) { this->unk_3FE = 1; - func_80B71D8C(this, globalCtx, func_80B723F8); + func_80B71D8C(this, play, func_80B723F8); if (!func_80B7285C(this)) { - Message_StartTextbox(globalCtx, 0x13EC, &this->actor); + Message_StartTextbox(play, 0x13EC, &this->actor); this->unk_400 = 0x13EC; func_80B72830(this, 1); } else { - Message_StartTextbox(globalCtx, 0x13F5, &this->actor); + Message_StartTextbox(play, 0x13F5, &this->actor); this->unk_400 = 0x13F5; } - Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 12); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, 12); func_80B717C8(this); } else if ((this->actor.xzDistToPlayer < 100.0f) && !(this->collider.base.acFlags & AC_HIT)) { - func_800B8614(&this->actor, globalCtx, 100.0f); + func_800B8614(&this->actor, play, 100.0f); } Math_SmoothStepToS(&this->actor.shape.rot.y, this->actor.world.rot.y, 1, 0x71C, 0xB6); } @@ -510,31 +509,31 @@ void func_80B717C8(EnRailSkb* this) { this->actionFunc = func_80B717E0; } -void func_80B717E0(EnRailSkb* this, GlobalContext* globalCtx) { +void func_80B717E0(EnRailSkb* this, PlayState* play) { this->unk_3FA = 0; - switch (Message_GetState(&globalCtx->msgCtx)) { - case 0: - case 1: - case 2: + switch (Message_GetState(&play->msgCtx)) { + case TEXT_STATE_NONE: + case TEXT_STATE_1: + case TEXT_STATE_CLOSING: break; - case 3: - if ((globalCtx->gameplayFrames % 2) != 0) { + case TEXT_STATE_3: + if ((play->gameplayFrames % 2) != 0) { this->unk_3FA = 1; } break; - case 4: - func_80B72100(this, globalCtx); + case TEXT_STATE_CHOICE: + func_80B72100(this, play); break; - case 5: - func_80B71F3C(this, globalCtx); + case TEXT_STATE_5: + func_80B71F3C(this, play); break; - case 6: - if (Message_ShouldAdvance(globalCtx)) { + case TEXT_STATE_DONE: + if (Message_ShouldAdvance(play)) { func_80B71650(this); } break; @@ -546,8 +545,8 @@ void func_80B718B0(EnRailSkb* this) { this->actionFunc = func_80B718C4; } -void func_80B718C4(EnRailSkb* this, GlobalContext* globalCtx) { - func_80B70D24(this, globalCtx); +void func_80B718C4(EnRailSkb* this, PlayState* play) { + func_80B70D24(this, play); if (this->actor.parent == NULL) { if (this->unk_22C != NULL) { ObjHakaisi* hakasi = this->unk_22C; @@ -559,11 +558,11 @@ void func_80B718C4(EnRailSkb* this, GlobalContext* globalCtx) { } void func_80B71910(EnRailSkb* this) { - Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 0); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, 0); this->actionFunc = func_80B71954; } -void func_80B71954(EnRailSkb* this, GlobalContext* globalCtx) { +void func_80B71954(EnRailSkb* this, PlayState* play) { 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); @@ -577,16 +576,16 @@ void func_80B71954(EnRailSkb* this, GlobalContext* globalCtx) { void func_80B71A08(EnRailSkb* this) { Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_STALKID_ATTACK); - Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 2); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, 2); this->actionFunc = func_80B71A58; } -void func_80B71A58(EnRailSkb* this, GlobalContext* globalCtx) { +void func_80B71A58(EnRailSkb* this, PlayState* play) { s16 sp36 = Math_Vec3f_Yaw(&this->actor.world.pos, &this->unk_22C->dyna.actor.world.pos); if (Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) { Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_STALKID_ATTACK); - Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 2); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, 2); if (this->unk_2E8 < this->unk_22C->dyna.actor.colChkInfo.health) { this->unk_22C->dyna.actor.colChkInfo.health--; } else { @@ -609,11 +608,11 @@ void func_80B71A58(EnRailSkb* this, GlobalContext* globalCtx) { void func_80B71B6C(EnRailSkb* this) { this->unk_3F2 = 10; - Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 0); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, 0); this->actionFunc = func_80B71BB8; } -void func_80B71BB8(EnRailSkb* this, GlobalContext* globalCtx) { +void func_80B71BB8(EnRailSkb* this, PlayState* play) { s32 pad; s32 i; f32 sp34 = Math_Vec3f_DistXZ(&this->actor.world.pos, &this->unk_22C->dyna.actor.world.pos); @@ -642,17 +641,17 @@ 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_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 9); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, 9); this->actor.velocity.y = 10.0f; for (i = 0; i < 4; i++) { - func_80B72430(this, globalCtx, 0); + func_80B72430(this, play, 0); } } } -void func_80B71D8C(EnRailSkb* this, GlobalContext* globalCtx, EnRailSkbUnkFunc unkFunc) { - Actor* actor = globalCtx->actorCtx.actorLists[ACTORCAT_ENEMY].first; +void func_80B71D8C(EnRailSkb* this, PlayState* play, EnRailSkbUnkFunc unkFunc) { + Actor* actor = play->actorCtx.actorLists[ACTORCAT_ENEMY].first; while (actor != NULL) { if (actor->id == ACTOR_EN_RAIL_SKB) { @@ -675,13 +674,13 @@ void func_80B71DF0(EnRailSkb* this) { this->drawDmgEffTimer = 0; } - Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 11); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, 11); this->actionFunc = func_80B71EA8; } -void func_80B71EA8(EnRailSkb* this, GlobalContext* globalCtx) { +void func_80B71EA8(EnRailSkb* this, PlayState* play) { if (Math_SmoothStepToF(&this->actor.shape.yOffset, 0.0f, 0.5f, 500.0f, 10.0f) != 0.0f) { - func_80B72430(this, globalCtx, 1); + func_80B72430(this, play, 1); } if (this->actor.shape.shadowAlpha != 255) { @@ -693,80 +692,80 @@ void func_80B71EA8(EnRailSkb* this, GlobalContext* globalCtx) { } } -void func_80B71F3C(EnRailSkb* this, GlobalContext* globalCtx) { +void func_80B71F3C(EnRailSkb* this, PlayState* play) { if (((this->unk_400 == 0x13ED) || (this->unk_400 == 0x13F5)) && (this->unk_3F2 != 1)) { - func_80B71D8C(this, globalCtx, func_80B71DF0); + func_80B71D8C(this, play, func_80B71DF0); func_80B717C8(this); this->unk_3F2 = 1; } - if (Message_ShouldAdvance(globalCtx)) { + if (Message_ShouldAdvance(play)) { switch (this->unk_400) { case 0x13EC: - Message_StartTextbox(globalCtx, 0x13ED, &this->actor); + Message_StartTextbox(play, 0x13ED, &this->actor); this->unk_400 = 0x13ED; break; case 0x13ED: - Message_StartTextbox(globalCtx, 0x13EE, &this->actor); + Message_StartTextbox(play, 0x13EE, &this->actor); this->unk_400 = 0x13EE; break; case 0x13EE: - Message_StartTextbox(globalCtx, 0x13EF, &this->actor); + Message_StartTextbox(play, 0x13EF, &this->actor); this->unk_400 = 0x13EF; break; case 0x13EF: case 0x13F5: - Message_StartTextbox(globalCtx, 0x13F0, &this->actor); + Message_StartTextbox(play, 0x13F0, &this->actor); this->unk_400 = 0x13F0; break; case 0x13F1: - Message_StartTextbox(globalCtx, 0x13F2, &this->actor); + Message_StartTextbox(play, 0x13F2, &this->actor); this->unk_400 = 0x13F2; break; case 0x13F2: if (this->unk_3FC == 1) { - Message_StartTextbox(globalCtx, 0x13F4, &this->actor); + Message_StartTextbox(play, 0x13F4, &this->actor); this->unk_400 = 0x13F4; } else { - func_801477B4(globalCtx); - func_80B71D8C(this, globalCtx, func_80B71650); + func_801477B4(play); + func_80B71D8C(this, play, func_80B71650); } break; case 0x13F3: - Message_StartTextbox(globalCtx, 0x13F2, &this->actor); + Message_StartTextbox(play, 0x13F2, &this->actor); this->unk_400 = 0x13F2; this->unk_3FC = 1; break; case 0x13F4: - func_801477B4(globalCtx); - func_80B71D8C(this, globalCtx, func_80B718B0); + func_801477B4(play); + func_80B71D8C(this, play, func_80B718B0); break; } } } -void func_80B72100(EnRailSkb* this, GlobalContext* globalCtx) { - if (Message_ShouldAdvance(globalCtx)) { - if (globalCtx->msgCtx.choiceIndex == 0) { +void func_80B72100(EnRailSkb* this, PlayState* play) { + if (Message_ShouldAdvance(play)) { + if (play->msgCtx.choiceIndex == 0) { func_8019F208(); - Message_StartTextbox(globalCtx, 0x13F1, &this->actor); + Message_StartTextbox(play, 0x13F1, &this->actor); this->unk_400 = 0x13F1; } else { func_8019F208(); - Message_StartTextbox(globalCtx, 0x13F3, &this->actor); + Message_StartTextbox(play, 0x13F3, &this->actor); this->unk_400 = 0x13F3; } } } -void func_80B72190(EnRailSkb* this, GlobalContext* globalCtx) { +void func_80B72190(EnRailSkb* this, PlayState* play) { EnRailSkb* parent; Vec3f sp38; s32 pad; @@ -830,14 +829,14 @@ void func_80B723F8(EnRailSkb* this) { this->actor.textId = 0; } -void func_80B72430(EnRailSkb* this, GlobalContext* globalCtx, s32 arg2) { +void func_80B72430(EnRailSkb* this, PlayState* play, s32 arg2) { Vec3f sp5C = this->actor.world.pos; Vec3f sp50 = { 0.0f, 8.0f, 0.0f }; Vec3f sp44 = { 0.0f, -1.5f, 0.0f }; s16 sp42; s32 pad; - if ((globalCtx->gameplayFrames & arg2) == 0) { + if ((play->gameplayFrames & arg2) == 0) { sp42 = Rand_Next(); sp5C.x += 15.0f * Math_SinS(sp42); @@ -849,12 +848,12 @@ void func_80B72430(EnRailSkb* this, GlobalContext* globalCtx, s32 arg2) { sp50.y += Rand_Centered() * 4.0f; - EffectSsHahen_Spawn(globalCtx, &sp5C, &sp50, &sp44, 0, (Rand_Next() & 7) + 10, -1, 10, NULL); - func_800BBFB0(globalCtx, &sp5C, 10.0f, 1, 150, 0, 1); + EffectSsHahen_Spawn(play, &sp5C, &sp50, &sp44, 0, (Rand_Next() & 7) + 10, HAHEN_OBJECT_DEFAULT, 10, NULL); + func_800BBFB0(play, &sp5C, 10.0f, 1, 150, 0, 1); } } -void func_80B725C0(EnRailSkb* this, GlobalContext* globalCtx) { +void func_80B725C0(EnRailSkb* this, PlayState* play) { if (this->drawDmgEffTimer > 0) { this->drawDmgEffTimer--; } @@ -873,7 +872,7 @@ void func_80B725C0(EnRailSkb* this, GlobalContext* globalCtx) { } } -void func_80B726B4(EnRailSkb* this, GlobalContext* globalCtx) { +void func_80B726B4(EnRailSkb* this, PlayState* play) { static Color_RGBA8 D_80B734B0 = { 170, 255, 255, 255 }; static Color_RGBA8 D_80B734B4 = { 200, 200, 255, 255 }; static Vec3f D_80B734B8 = { 0.0f, -1.0f, 0.0f }; @@ -888,7 +887,7 @@ void func_80B726B4(EnRailSkb* this, GlobalContext* globalCtx) { end = ARRAY_COUNT(this->limbPos); } - SoundSource_PlaySfxAtFixedWorldPos(globalCtx, &this->actor.world.pos, 30, NA_SE_EV_ICE_BROKEN); + SoundSource_PlaySfxAtFixedWorldPos(play, &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->limbPos[i]); @@ -897,7 +896,7 @@ void func_80B726B4(EnRailSkb* this, GlobalContext* globalCtx) { sp84.z = Math_CosS(yaw) * 3.0f; sp84.y = (Rand_ZeroOne() * 4.0f) + 4.0f; - EffectSsEnIce_Spawn(globalCtx, &this->limbPos[i], 0.6f, &sp84, &D_80B734B8, &D_80B734B0, &D_80B734B4, 30); + EffectSsEnIce_Spawn(play, &this->limbPos[i], 0.6f, &sp84, &D_80B734B8, &D_80B734B0, &D_80B734B4, 30); } } @@ -920,10 +919,10 @@ s32 func_80B7285C(EnRailSkb* this) { return phi_v1; } -void func_80B72880(EnRailSkb* this, GlobalContext* globalCtx) { +void func_80B72880(EnRailSkb* this, PlayState* play) { if ((this->actionFunc == func_80B70FF8) || (this->actionFunc == func_80B716A8)) { if (this->actionFunc != func_80B716A8) { - if (Player_GetMask(globalCtx) == PLAYER_MASK_CAPTAIN) { + if (Player_GetMask(play) == PLAYER_MASK_CAPTAIN) { this->actor.flags &= ~(ACTOR_FLAG_1 | ACTOR_FLAG_4); this->actor.flags |= (ACTOR_FLAG_1 | ACTOR_FLAG_8); this->actor.flags |= ACTOR_FLAG_100000; @@ -931,7 +930,7 @@ void func_80B72880(EnRailSkb* this, GlobalContext* globalCtx) { this->actor.textId = 0; func_80B71650(this); } - } else if (Player_GetMask(globalCtx) != PLAYER_MASK_CAPTAIN) { + } else if (Player_GetMask(play) != PLAYER_MASK_CAPTAIN) { this->actor.flags &= ~(ACTOR_FLAG_1 | ACTOR_FLAG_8); this->actor.flags &= ~ACTOR_FLAG_100000; this->actor.flags |= (ACTOR_FLAG_1 | ACTOR_FLAG_4); @@ -942,8 +941,8 @@ void func_80B72880(EnRailSkb* this, GlobalContext* globalCtx) { } } -void func_80B72970(EnRailSkb* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); +void func_80B72970(EnRailSkb* this, PlayState* play) { + Player* player = GET_PLAYER(play); s32 pad; if ((this->actionFunc == func_80B714D8) || (this->actionFunc == func_80B7123C) || @@ -965,7 +964,7 @@ void func_80B72970(EnRailSkb* this, GlobalContext* globalCtx) { default: if (this->drawDmgEffTimer >= 2) { - func_80B726B4(this, globalCtx); + func_80B726B4(this, play); } this->drawDmgEffTimer = 0; break; @@ -974,7 +973,7 @@ void func_80B72970(EnRailSkb* this, GlobalContext* globalCtx) { if ((Actor_ApplyDamage(&this->actor) == 0) && (this->actor.colChkInfo.damageEffect != 3) && (this->actor.colChkInfo.damageEffect != 4)) { - SoundSource_PlaySfxAtFixedWorldPos(globalCtx, &this->actor.world.pos, 40, NA_SE_EN_STALKID_DEAD); + SoundSource_PlaySfxAtFixedWorldPos(play, &this->actor.world.pos, 40, NA_SE_EN_STALKID_DEAD); func_80B71488(this); return; } @@ -1001,7 +1000,7 @@ void func_80B72970(EnRailSkb* this, GlobalContext* globalCtx) { this->drawDmgEffScale = 0.0f; Actor_SetColorFilter(&this->actor, 0x4000, 255, 0, 8); Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_STALKID_DAMAGE); - Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 3); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, 3); this->unk_402 |= 1; func_80B712FC(this); break; @@ -1027,7 +1026,7 @@ void func_80B72970(EnRailSkb* this, GlobalContext* globalCtx) { this->drawDmgEffScale = 0.5f; Actor_SetColorFilter(&this->actor, 0x4000, 255, 0, 8); Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_STALKID_DAMAGE); - Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 3); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, 3); func_80B71228(this); break; @@ -1036,15 +1035,17 @@ void func_80B72970(EnRailSkb* this, GlobalContext* globalCtx) { this->unk_402 |= 1; case 15: - if ((player->swordAnimation == 4) || (player->swordAnimation == 11) || (player->swordAnimation == 22) || - (player->swordAnimation == 23)) { + if ((player->meleeWeaponAnimation == PLAYER_MWA_RIGHT_SLASH_1H) || + (player->meleeWeaponAnimation == PLAYER_MWA_LEFT_COMBO_2H) || + (player->meleeWeaponAnimation == PLAYER_MWA_BACKSLASH_RIGHT) || + (player->meleeWeaponAnimation == PLAYER_MWA_BACKSLASH_LEFT)) { this->unk_402 |= 1; } case 13: Actor_SetColorFilter(&this->actor, 0x4000, 255, 0, 8); Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_STALKID_DAMAGE); - Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 3); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, 3); func_80B712FC(this); break; @@ -1054,54 +1055,53 @@ void func_80B72970(EnRailSkb* this, GlobalContext* globalCtx) { } if (this->actionFunc == func_80B713A4) { - CollisionCheck_SetAT(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + CollisionCheck_SetAT(play, &play->colChkCtx, &this->collider.base); } if (this->actionFunc != func_80B71314) { - CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + CollisionCheck_SetAC(play, &play->colChkCtx, &this->collider.base); } - CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + CollisionCheck_SetOC(play, &play->colChkCtx, &this->collider.base); } -void EnRailSkb_Update(Actor* thisx, GlobalContext* globalCtx) { +void EnRailSkb_Update(Actor* thisx, PlayState* play) { EnRailSkb* this = THIS; - this->actionFunc(this, globalCtx); + this->actionFunc(this, play); - func_80B72190(this, globalCtx); - Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 15.0f, 30.0f, 60.0f, 5); - func_80B72970(this, globalCtx); + func_80B72190(this, play); + Actor_UpdateBgCheckInfo(play, &this->actor, 15.0f, 30.0f, 60.0f, 5); + func_80B72970(this, play); if ((this->actionFunc != func_80B710E4) && (this->actionFunc != func_80B7114C) && (this->actionFunc != func_80B7123C)) { SkelAnime_Update(&this->skelAnime); } - func_80B72880(this, globalCtx); - func_80B725C0(this, globalCtx); + func_80B72880(this, play); + func_80B725C0(this, play); } -s32 EnRailSkb_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, - Actor* thisx) { +s32 EnRailSkb_OverrideLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, Actor* thisx) { EnRailSkb* this = THIS; s16 abs; if (limbIndex == 11) { - OPEN_DISPS(globalCtx->state.gfxCtx); + OPEN_DISPS(play->state.gfxCtx); - abs = fabsf(Math_SinS(globalCtx->state.frames * 6000) * 95.0f) + 160.0f; + abs = fabsf(Math_SinS(play->state.frames * 6000) * 95.0f) + 160.0f; gDPPipeSync(POLY_OPA_DISP++); gDPSetEnvColor(POLY_OPA_DISP++, abs, abs, abs, 255); - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->state.gfxCtx); } 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)) { @@ -1111,7 +1111,7 @@ s32 EnRailSkb_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dL return false; } -void EnRailSkb_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx) { +void EnRailSkb_PostLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx) { static Vec3f D_80B734D0 = { 800.0f, 1200.0f, 0.0f }; EnRailSkb* this = THIS; @@ -1119,35 +1119,35 @@ void EnRailSkb_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList Collider_UpdateSpheres(limbIndex, &this->collider); if ((limbIndex == 11) && (this->unk_402 & 1) && !(this->unk_402 & 2)) { - Actor_SpawnBodyParts(&this->actor, globalCtx, 1, dList); + Actor_SpawnBodyParts(&this->actor, play, 1, dList); this->unk_402 |= 2; } else if ((this->unk_402 & 0x40) && ((limbIndex != 11) || !(this->unk_402 & 1)) && (limbIndex != 12)) { - Actor_SpawnBodyParts(&this->actor, globalCtx, 1, dList); + Actor_SpawnBodyParts(&this->actor, play, 1, dList); } 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->limbPos[this->limbCount]); + Matrix_MultZero(&this->limbPos[this->limbCount]); this->limbCount++; } else if ((limbIndex == 11) && !(this->unk_402 & 2)) { - Matrix_MultiplyVector3fByState(&D_80B734D0, &this->limbPos[this->limbCount]); + Matrix_MultVec3f(&D_80B734D0, &this->limbPos[this->limbCount]); this->limbCount++; } } } } -void EnRailSkb_Draw(Actor* thisx, GlobalContext* globalCtx) { +void EnRailSkb_Draw(Actor* thisx, PlayState* play) { EnRailSkb* this = THIS; this->limbCount = 0; - func_8012C28C(globalCtx->state.gfxCtx); - SkelAnime_DrawOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, EnRailSkb_OverrideLimbDraw, + func_8012C28C(play->state.gfxCtx); + SkelAnime_DrawOpa(play, this->skelAnime.skeleton, this->skelAnime.jointTable, EnRailSkb_OverrideLimbDraw, EnRailSkb_PostLimbDraw, &this->actor); if (this->drawDmgEffTimer > 0) { - Actor_DrawDamageEffects(globalCtx, &this->actor, this->limbPos, this->limbCount, this->drawDmgEffScale, 0.5f, + Actor_DrawDamageEffects(play, &this->actor, this->limbPos, this->limbCount, this->drawDmgEffScale, 0.5f, this->drawDmgEffAlpha, this->drawDmgEffType); } 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 6346eebe2..09d3b4c4c 100644 --- a/src/overlays/actors/ovl_En_Rail_Skb/z_en_rail_skb.h +++ b/src/overlays/actors/ovl_En_Rail_Skb/z_en_rail_skb.h @@ -2,10 +2,11 @@ #define Z_EN_RAIL_SKB_H #include "global.h" +#include "overlays/actors/ovl_Obj_Hakaisi/z_obj_hakaisi.h" struct EnRailSkb; -typedef void (*EnRailSkbActionFunc)(struct EnRailSkb*, GlobalContext*); +typedef void (*EnRailSkbActionFunc)(struct EnRailSkb*, PlayState*); typedef void (*EnRailSkbUnkFunc)(struct EnRailSkb*); #define ENRAILSKB_GET_FF00(thisx) (((thisx)->params >> 8) & 0xFF) 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 70d9fb708..10bbf2f83 100644 --- a/src/overlays/actors/ovl_En_Railgibud/z_en_railgibud.c +++ b/src/overlays/actors/ovl_En_Railgibud/z_en_railgibud.c @@ -5,71 +5,72 @@ */ #include "z_en_railgibud.h" -#include "objects/object_rd/object_rd.h" +#include "z64rumble.h" +#include "overlays/effects/ovl_Effect_Ss_Hahen/z_eff_ss_hahen.h" #define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_4 | ACTOR_FLAG_10 | ACTOR_FLAG_400) #define THIS ((EnRailgibud*)thisx) -void EnRailgibud_Init(Actor* thisx, GlobalContext* globalCtx); -void EnRailgibud_Destroy(Actor* thisx, GlobalContext* globalCtx); -void EnRailgibud_Update(Actor* thisx, GlobalContext* globalCtx); -void EnRailgibud_Draw(Actor* thisx, GlobalContext* globalCtx); +void EnRailgibud_Init(Actor* thisx, PlayState* play); +void EnRailgibud_Destroy(Actor* thisx, PlayState* play); +void EnRailgibud_Update(Actor* thisx, PlayState* play); +void EnRailgibud_Draw(Actor* thisx, PlayState* play); void EnRailgibud_SetupWalkInCircles(EnRailgibud* this); -void EnRailgibud_WalkInCircles(EnRailgibud* this, GlobalContext* globalCtx); +void EnRailgibud_WalkInCircles(EnRailgibud* this, PlayState* play); void EnRailgibud_SetupAttemptPlayerFreeze(EnRailgibud* this); -void EnRailgibud_AttemptPlayerFreeze(EnRailgibud* this, GlobalContext* globalCtx); +void EnRailgibud_AttemptPlayerFreeze(EnRailgibud* this, PlayState* play); void EnRailgibud_SetupWalkToPlayer(EnRailgibud* this); -void EnRailgibud_WalkToPlayer(EnRailgibud* this, GlobalContext* globalCtx); +void EnRailgibud_WalkToPlayer(EnRailgibud* this, PlayState* play); void EnRailgibud_SetupGrab(EnRailgibud* this); -void EnRailgibud_Grab(EnRailgibud* this, GlobalContext* globalCtx); +void EnRailgibud_Grab(EnRailgibud* this, PlayState* play); void EnRailgibud_SetupGrabFail(EnRailgibud* this); -void EnRailgibud_GrabFail(EnRailgibud* this, GlobalContext* globalCtx); +void EnRailgibud_GrabFail(EnRailgibud* this, PlayState* play); void EnRailgibud_SetupTurnAwayAndShakeHead(EnRailgibud* this); -void EnRailgibud_TurnAwayAndShakeHead(EnRailgibud* this, GlobalContext* globalCtx); +void EnRailgibud_TurnAwayAndShakeHead(EnRailgibud* this, PlayState* play); 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_WalkToHome(EnRailgibud* this, PlayState* play); +void EnRailgibud_Damage(EnRailgibud* this, PlayState* play); +void EnRailgibud_Stunned(EnRailgibud* this, PlayState* play); 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_Dead(EnRailgibud* this, PlayState* play); +void EnRailgibud_SpawnDust(PlayState* play, Vec3f* vec, f32 arg2, s32 arg3, s16 arg4, s16 arg5); +void EnRailgibud_TurnTowardsPlayer(EnRailgibud* this, PlayState* play); +s32 EnRailgibud_PlayerInRangeWithCorrectState(EnRailgibud* this, PlayState* play); +s32 EnRailgibud_PlayerOutOfRange(EnRailgibud* this, PlayState* play); +s32 EnRailgibud_MoveToIdealGrabPositionAndRotation(EnRailgibud* this, PlayState* play); +void EnRailgibud_CheckIfTalkingToPlayer(EnRailgibud* this, PlayState* play); +void EnRailgibud_MainGibdo_DeadUpdate(Actor* thisx, PlayState* play); +void EnRailgibud_InitCutsceneGibdo(EnRailgibud* this, PlayState* play); void EnRailgibud_InitActorActionCommand(EnRailgibud* this); void EnRailgibud_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); +void EnRailgibud_DoNothing(EnRailgibud* this, PlayState* play); +void EnRailgibud_SinkIntoGround(EnRailgibud* this, PlayState* play); +void EnRailgibud_Cutscene_Update(Actor* thisx, PlayState* play); 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; + /* 0 */ EN_RAILGIBUD_ANIM_GRAB_ATTACK, + /* 1 */ EN_RAILGIBUD_ANIM_GRAB_END, + /* 2 */ EN_RAILGIBUD_ANIM_GRAB_START, + /* 3 */ EN_RAILGIBUD_ANIM_LOOK_BACK, + /* 4 */ EN_RAILGIBUD_ANIM_CROUCH_WIPING_TEARS, + /* 5 */ EN_RAILGIBUD_ANIM_CROUCH_CRYING, + /* 6 */ EN_RAILGIBUD_ANIM_DEATH, + /* 7 */ EN_RAILGIBUD_ANIM_DAMAGE, + /* 8 */ EN_RAILGIBUD_ANIM_CROUCH_END, + /* 9 */ EN_RAILGIBUD_ANIM_IDLE, + /* 10 */ EN_RAILGIBUD_ANIM_WALK, + /* 11 */ EN_RAILGIBUD_ANIM_DANCE_SQUAT, + /* 12 */ EN_RAILGIBUD_ANIM_DANCE_PIROUETTE, + /* 13 */ EN_RAILGIBUD_ANIM_DANCE_CLAP, + /* 14 */ EN_RAILGIBUD_ANIM_CROUCH_END_2, + /* 15 */ EN_RAILGIBUD_ANIM_SLUMP_START, + /* 16 */ EN_RAILGIBUD_ANIM_SLUMP_LOOP, + /* 17 */ EN_RAILGIBUD_ANIM_CONVULSION, + /* 18 */ EN_RAILGIBUD_ANIM_ARMS_UP_START, + /* 19 */ EN_RAILGIBUD_ANIM_ARMS_UP_LOOP, +} EnRailgibudAnimation; typedef enum { /* 0 */ EN_RAILGIBUD_TYPE_GIBDO, @@ -94,7 +95,7 @@ const ActorInit En_Railgibud_InitVars = { (ActorFunc)EnRailgibud_Draw, }; -static AnimationInfo sAnimations[] = { +static AnimationInfo sAnimationInfo[] = { { &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 }, @@ -190,11 +191,11 @@ static CollisionCheckInfoInit2 sColChkInfoInit = { 8, 0, 0, 0, MASS_IMMOVABLE }; * 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) { +void EnRailgibud_SpawnOtherGibdosAndSetPositionAndRotation(EnRailgibud* this, PlayState* play) { static s32 currentGibdoIndex = 0; s32 nextPoint; Vec3f targetPos; - Path* path = &globalCtx->setupPathList[ENRAILGIBUD_GET_PATH(&this->actor)]; + Path* path = &play->setupPathList[ENRAILGIBUD_GET_PATH(&this->actor)]; this->points = Lib_SegmentedToVirtual(path->points); this->currentPoint = currentGibdoIndex; @@ -209,8 +210,8 @@ void EnRailgibud_SpawnOtherGibdosAndSetPositionAndRotation(EnRailgibud* this, Gl 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); + Actor_SpawnAsChild(&play->actorCtx, &this->actor, play, ACTOR_EN_RAILGIBUD, 0.0f, 0.0f, 0.0f, 0, 0, 0, + this->actor.params); } currentGibdoIndex = 0; @@ -239,7 +240,7 @@ static InitChainEntry sInitChain[] = { ICHAIN_F32_DIV1000(gravity, -3500, ICHAIN_STOP), }; -void EnRailgibud_Init(Actor* thisx, GlobalContext* globalCtx) { +void EnRailgibud_Init(Actor* thisx, PlayState* play) { EnRailgibud* this = THIS; s32 pad; @@ -248,11 +249,11 @@ void EnRailgibud_Init(Actor* thisx, GlobalContext* globalCtx) { this->actor.hintId = 0x2D; this->actor.textId = 0; if (ENRAILGIBUD_IS_CUTSCENE_TYPE(&this->actor)) { - EnRailgibud_InitCutsceneGibdo(this, globalCtx); + EnRailgibud_InitCutsceneGibdo(this, play); return; } - EnRailgibud_SpawnOtherGibdosAndSetPositionAndRotation(this, globalCtx); + EnRailgibud_SpawnOtherGibdosAndSetPositionAndRotation(this, play); this->playerStunWaitTimer = 0; this->timeInitialized = gSaveContext.save.time; this->drawDmgEffType = ACTOR_DRAW_DMGEFF_FIRE; @@ -265,10 +266,10 @@ void EnRailgibud_Init(Actor* thisx, GlobalContext* globalCtx) { } ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 28.0f); - 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); + SkelAnime_InitFlex(play, &this->skelAnime, &gGibdoSkel, &gGibdoRedeadIdleAnim, this->jointTable, this->morphTable, + GIBDO_LIMB_MAX); + Collider_InitCylinder(play, &this->collider); + Collider_SetCylinder(play, &this->collider, &this->actor, &sCylinderInit); CollisionCheck_SetInfo2(&this->actor.colChkInfo, &sDamageTable, &sColChkInfoInit); if (gSaveContext.save.weekEventReg[14] & 4) { Actor_MarkForDeath(&this->actor); @@ -277,19 +278,19 @@ void EnRailgibud_Init(Actor* thisx, GlobalContext* globalCtx) { EnRailgibud_SetupWalkInCircles(this); } -void EnRailgibud_Destroy(Actor* thisx, GlobalContext* globalCtx) { +void EnRailgibud_Destroy(Actor* thisx, PlayState* play) { EnRailgibud* this = THIS; - Collider_DestroyCylinder(globalCtx, &this->collider); + Collider_DestroyCylinder(play, &this->collider); } void EnRailgibud_SetupWalkInCircles(EnRailgibud* this) { this->actor.speedXZ = 0.6f; - Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, EN_RAILGIBUD_ANIMATION_WALK); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, EN_RAILGIBUD_ANIM_WALK); this->actionFunc = EnRailgibud_WalkInCircles; } -void EnRailgibud_WalkInCircles(EnRailgibud* this, GlobalContext* globalCtx) { +void EnRailgibud_WalkInCircles(EnRailgibud* this, PlayState* play) { Vec3f targetPos; s32 pad; s16 yRotation; @@ -298,8 +299,7 @@ void EnRailgibud_WalkInCircles(EnRailgibud* this, GlobalContext* globalCtx) { 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)) { + if ((this->actor.xzDistToPlayer <= 100.0f) && func_800B715C(play) && (Player_GetMask(play) != PLAYER_MASK_GIBDO)) { this->actor.home = this->actor.world; EnRailgibud_SetupAttemptPlayerFreeze(this); } @@ -336,28 +336,28 @@ void EnRailgibud_WalkInCircles(EnRailgibud* this, GlobalContext* globalCtx) { } void EnRailgibud_SetupAttemptPlayerFreeze(EnRailgibud* this) { - Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, EN_RAILGIBUD_ANIMATION_IDLE); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, EN_RAILGIBUD_ANIM_IDLE); this->actionFunc = EnRailgibud_AttemptPlayerFreeze; } -void EnRailgibud_AttemptPlayerFreeze(EnRailgibud* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); +void EnRailgibud_AttemptPlayerFreeze(EnRailgibud* this, PlayState* play) { + Player* player = GET_PLAYER(play); 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) { player->actor.freezeTimer = 60; - func_8013ECE0(this->actor.xzDistToPlayer, 255, 20, 150); - func_80123E90(globalCtx, &this->actor); + Rumble_Request(this->actor.xzDistToPlayer, 255, 20, 150); + func_80123E90(play, &this->actor); Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_REDEAD_AIM); EnRailgibud_SetupWalkToPlayer(this); } - EnRailgibud_TurnTowardsPlayer(this, globalCtx); + EnRailgibud_TurnTowardsPlayer(this, play); } void EnRailgibud_SetupWalkToPlayer(EnRailgibud* this) { - Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, EN_RAILGIBUD_ANIMATION_WALK); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, EN_RAILGIBUD_ANIM_WALK); this->actor.speedXZ = 0.4f; if (this->actionFunc == EnRailgibud_AttemptPlayerFreeze) { @@ -369,8 +369,8 @@ void EnRailgibud_SetupWalkToPlayer(EnRailgibud* this) { this->actionFunc = EnRailgibud_WalkToPlayer; } -void EnRailgibud_WalkToPlayer(EnRailgibud* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); +void EnRailgibud_WalkToPlayer(EnRailgibud* this, PlayState* play) { + Player* player = GET_PLAYER(play); s32 pad; Math_ScaledStepToS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer, 0xFA); @@ -378,7 +378,7 @@ void EnRailgibud_WalkToPlayer(EnRailgibud* this, GlobalContext* globalCtx) { 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 (EnRailgibud_PlayerInRangeWithCorrectState(this, play) && Actor_IsFacingPlayer(&this->actor, 0x38E3)) { if ((this->grabWaitTimer == 0) && (this->actor.xzDistToPlayer <= 45.0f)) { player->actor.freezeTimer = 0; if ((gSaveContext.save.playerForm == PLAYER_FORM_GORON) || @@ -386,15 +386,15 @@ void EnRailgibud_WalkToPlayer(EnRailgibud* this, GlobalContext* globalCtx) { // 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)) { + } else if (play->grabPlayer(play, player)) { EnRailgibud_SetupGrab(this); } } else { if (this->playerStunWaitTimer == 0) { player->actor.freezeTimer = 40; this->playerStunWaitTimer = 60; - func_8013ECE0(this->actor.xzDistToPlayer, 255, 20, 150); - func_80123E90(globalCtx, &this->actor); + Rumble_Request(this->actor.xzDistToPlayer, 255, 20, 150); + func_80123E90(play, &this->actor); Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_REDEAD_AIM); } else { this->playerStunWaitTimer--; @@ -402,7 +402,7 @@ void EnRailgibud_WalkToPlayer(EnRailgibud* this, GlobalContext* globalCtx) { } } else if ((this->grabWaitTimer == 0) && (this->actor.xzDistToPlayer <= 45.0f)) { EnRailgibud_SetupWalkToHome(this); - } else if (EnRailgibud_PlayerOutOfRange(this, globalCtx)) { + } else if (EnRailgibud_PlayerOutOfRange(this, play)) { EnRailgibud_SetupWalkToHome(this); } @@ -412,33 +412,33 @@ void EnRailgibud_WalkToPlayer(EnRailgibud* this, GlobalContext* globalCtx) { 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)) { + } else if (!(play->gameplayFrames & 95)) { Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_REDEAD_CRY); } } void EnRailgibud_SetupGrab(EnRailgibud* this) { - Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, EN_RAILGIBUD_ANIMATION_GRAB_START); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, EN_RAILGIBUD_ANIM_GRAB_START); this->grabDamageTimer = 0; this->actor.flags &= ~ACTOR_FLAG_1; this->grabState = EN_RAILGIBUD_GRAB_START; this->actionFunc = EnRailgibud_Grab; } -void EnRailgibud_Grab(EnRailgibud* this, GlobalContext* globalCtx) { - Player* player2 = GET_PLAYER(globalCtx); +void EnRailgibud_Grab(EnRailgibud* this, PlayState* play) { + Player* player2 = GET_PLAYER(play); Player* player = player2; s32 inPositionToAttack; u16 damageSfxId; switch (this->grabState) { case EN_RAILGIBUD_GRAB_START: - inPositionToAttack = EnRailgibud_MoveToIdealGrabPositionAndRotation(this, globalCtx); + inPositionToAttack = EnRailgibud_MoveToIdealGrabPositionAndRotation(this, play); 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); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, EN_RAILGIBUD_ANIM_GRAB_ATTACK); } else if (!(player->stateFlags2 & 0x80)) { - Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, EN_RAILGIBUD_ANIMATION_GRAB_END); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, EN_RAILGIBUD_ANIM_GRAB_END); this->actor.flags |= ACTOR_FLAG_1; this->grabState = EN_RAILGIBUD_GRAB_RELEASE; this->grabDamageTimer = 0; @@ -450,9 +450,9 @@ void EnRailgibud_Grab(EnRailgibud* this, GlobalContext* globalCtx) { s16 requiredScopeTemp; damageSfxId = player->ageProperties->unk_92 + NA_SE_VO_LI_DAMAGE_S; - globalCtx->damagePlayer(globalCtx, -8); + play->damagePlayer(play, -8); func_800B8E58(player, damageSfxId); - func_8013ECE0(this->actor.xzDistToPlayer, 240, 1, 12); + Rumble_Request(this->actor.xzDistToPlayer, 240, 1, 12); this->grabDamageTimer = 0; } else { this->grabDamageTimer++; @@ -468,7 +468,7 @@ void EnRailgibud_Grab(EnRailgibud* this, GlobalContext* globalCtx) { player->unk_AE8 = 100; } - Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, EN_RAILGIBUD_ANIMATION_GRAB_END); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, EN_RAILGIBUD_ANIM_GRAB_END); this->actor.flags |= ACTOR_FLAG_1; this->grabState = EN_RAILGIBUD_GRAB_RELEASE; this->grabDamageTimer = 0; @@ -488,13 +488,13 @@ void EnRailgibud_Grab(EnRailgibud* this, GlobalContext* globalCtx) { } void EnRailgibud_SetupGrabFail(EnRailgibud* this) { - Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, EN_RAILGIBUD_ANIMATION_DAMAGE); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, EN_RAILGIBUD_ANIM_DAMAGE); Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_REDEAD_DAMAGE); this->actor.speedXZ = -2.0f; this->actionFunc = EnRailgibud_GrabFail; } -void EnRailgibud_GrabFail(EnRailgibud* this, GlobalContext* globalCtx) { +void EnRailgibud_GrabFail(EnRailgibud* this, PlayState* play) { if (this->actor.speedXZ < 0.0f) { this->actor.speedXZ += 0.15f; } @@ -510,11 +510,11 @@ void EnRailgibud_GrabFail(EnRailgibud* this, GlobalContext* globalCtx) { void EnRailgibud_SetupTurnAwayAndShakeHead(EnRailgibud* this) { this->headShakeTimer = 0; - Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, EN_RAILGIBUD_ANIMATION_WALK); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, EN_RAILGIBUD_ANIM_WALK); this->actionFunc = EnRailgibud_TurnAwayAndShakeHead; } -void EnRailgibud_TurnAwayAndShakeHead(EnRailgibud* this, GlobalContext* globalCtx) { +void EnRailgibud_TurnAwayAndShakeHead(EnRailgibud* this, PlayState* play) { Math_SmoothStepToS(&this->actor.world.rot.y, BINANG_ROT180(this->actor.yawTowardsPlayer), 5, 3500, 200); this->actor.shape.rot.y = this->actor.world.rot.y; if (this->headShakeTimer > 60) { @@ -528,12 +528,12 @@ void EnRailgibud_TurnAwayAndShakeHead(EnRailgibud* this, GlobalContext* globalCt } void EnRailgibud_SetupWalkToHome(EnRailgibud* this) { - Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, EN_RAILGIBUD_ANIMATION_WALK); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, EN_RAILGIBUD_ANIM_WALK); this->actor.speedXZ = 0.4f; this->actionFunc = EnRailgibud_WalkToHome; } -void EnRailgibud_WalkToHome(EnRailgibud* this, GlobalContext* globalCtx) { +void EnRailgibud_WalkToHome(EnRailgibud* this, PlayState* play) { Math_SmoothStepToS(&this->headRotation.y, 0, 1, 100, 0); Math_SmoothStepToS(&this->upperBodyRotation.y, 0, 1, 100, 0); if (Actor_XZDistanceToPoint(&this->actor, &this->actor.home.pos) < 5.0f) { @@ -552,7 +552,7 @@ void EnRailgibud_WalkToHome(EnRailgibud* this, GlobalContext* globalCtx) { 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 (EnRailgibud_PlayerInRangeWithCorrectState(this, globalCtx)) { + if (EnRailgibud_PlayerInRangeWithCorrectState(this, play)) { if ((gSaveContext.save.playerForm != PLAYER_FORM_GORON) && (gSaveContext.save.playerForm != PLAYER_FORM_DEKU) && Actor_IsFacingPlayer(&this->actor, 0x38E3)) { EnRailgibud_SetupWalkToPlayer(this); @@ -561,7 +561,7 @@ void EnRailgibud_WalkToHome(EnRailgibud* this, GlobalContext* globalCtx) { } void EnRailgibud_SetupDamage(EnRailgibud* this) { - Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, EN_RAILGIBUD_ANIMATION_DAMAGE); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, EN_RAILGIBUD_ANIM_DAMAGE); Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_REDEAD_DAMAGE); this->stunTimer = 0; this->grabWaitTimer = 0; @@ -570,7 +570,7 @@ void EnRailgibud_SetupDamage(EnRailgibud* this) { this->actionFunc = EnRailgibud_Damage; } -void EnRailgibud_Damage(EnRailgibud* this, GlobalContext* globalCtx) { +void EnRailgibud_Damage(EnRailgibud* this, PlayState* play) { if (this->actor.speedXZ < 0.0f) { this->actor.speedXZ += 0.15f; } @@ -581,7 +581,7 @@ void EnRailgibud_Damage(EnRailgibud* this, GlobalContext* globalCtx) { 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, &gRedeadSkel, NULL, this->jointTable, this->morphTable, + SkelAnime_InitFlex(play, &this->skelAnime, &gRedeadSkel, NULL, this->jointTable, this->morphTable, GIBDO_LIMB_MAX); this->type = EN_RAILGIBUD_TYPE_REDEAD; } @@ -603,7 +603,7 @@ void EnRailgibud_SetupStunned(EnRailgibud* this) { this->actionFunc = EnRailgibud_Stunned; } -void EnRailgibud_Stunned(EnRailgibud* this, GlobalContext* globalCtx) { +void EnRailgibud_Stunned(EnRailgibud* this, PlayState* play) { if (this->actor.colorFilterTimer == 0) { if (this->actor.colChkInfo.health == 0) { EnRailgibud_SetupDead(this); @@ -618,14 +618,14 @@ void EnRailgibud_Stunned(EnRailgibud* this, GlobalContext* globalCtx) { } void EnRailgibud_SetupDead(EnRailgibud* this) { - Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, EN_RAILGIBUD_ANIMATION_DEATH); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, EN_RAILGIBUD_ANIM_DEATH); this->actor.flags &= ~ACTOR_FLAG_1; Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_REDEAD_DEAD); this->deathTimer = 0; this->actionFunc = EnRailgibud_Dead; } -void EnRailgibud_Dead(EnRailgibud* this, GlobalContext* globalCtx) { +void EnRailgibud_Dead(EnRailgibud* this, PlayState* play) { if (this->deathTimer > 300) { if (this->actor.shape.shadowAlpha == 0) { if (this->actor.parent != NULL) { @@ -653,33 +653,33 @@ void EnRailgibud_Dead(EnRailgibud* this, GlobalContext* globalCtx) { 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, + SkelAnime_InitFlex(play, &this->skelAnime, &gRedeadSkel, NULL, this->jointTable, this->morphTable, GIBDO_LIMB_MAX); this->type = EN_RAILGIBUD_TYPE_REDEAD; } } -void EnRailgibud_SpawnEffectsForSinkingIntoTheGround(EnRailgibud* this, GlobalContext* globalCtx, s32 arg2) { +void EnRailgibud_SpawnEffectsForSinkingIntoTheGround(EnRailgibud* this, PlayState* play, 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) { + if ((play->gameplayFrames & arg2) == 0) { rand = Rand_Next(); 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); + EffectSsHahen_Spawn(play, &rockFragmentPos, &rockFragmentVelocity, &rockFragmentAccel, 0, + (Rand_Next() & 7) + 10, HAHEN_OBJECT_DEFAULT, 10, NULL); + EnRailgibud_SpawnDust(play, &rockFragmentPos, 10.0f, 10, 150, 0); } } -void EnRailgibud_SpawnDust(GlobalContext* globalCtx, Vec3f* basePos, f32 randomnessScale, s32 dustCount, s16 dustScale, +void EnRailgibud_SpawnDust(PlayState* play, Vec3f* basePos, f32 randomnessScale, s32 dustCount, s16 dustScale, s16 scaleStep) { Vec3f dustPos; Vec3f dustAccel = { 0.0f, 0.3f, 0.0f }; @@ -699,8 +699,8 @@ void EnRailgibud_SpawnDust(GlobalContext* globalCtx, Vec3f* basePos, f32 randomn dustVelocity.x *= 0.5f; dustVelocity.z *= 0.5f; - func_800B1210(globalCtx, &dustPos, &dustVelocity, &dustAccel, - (s16)(Rand_ZeroOne() * dustScale * 0.2f) + dustScale, scaleStep); + func_800B1210(play, &dustPos, &dustVelocity, &dustAccel, (s16)(Rand_ZeroOne() * dustScale * 0.2f) + dustScale, + scaleStep); } } @@ -723,7 +723,7 @@ void EnRailgibud_UpdateWalkForwardState(EnRailgibud* this) { } } -void EnRailgibud_TurnTowardsPlayer(EnRailgibud* this, GlobalContext* globalCtx) { +void EnRailgibud_TurnTowardsPlayer(EnRailgibud* this, PlayState* play) { s16 headAngle = (this->actor.yawTowardsPlayer - this->actor.shape.rot.y) - this->upperBodyRotation.y; s16 upperBodyAngle = CLAMP(headAngle, -500, 500); @@ -742,10 +742,10 @@ void EnRailgibud_TurnTowardsPlayer(EnRailgibud* this, GlobalContext* globalCtx) this->headRotation.y = CLAMP(this->headRotation.y, -0x256F, 0x256F); } -s32 EnRailgibud_PlayerInRangeWithCorrectState(EnRailgibud* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); +s32 EnRailgibud_PlayerInRangeWithCorrectState(EnRailgibud* this, PlayState* play) { + Player* player = GET_PLAYER(play); - if (Player_GetMask(globalCtx) == PLAYER_MASK_GIBDO) { + if (Player_GetMask(play) == PLAYER_MASK_GIBDO) { return false; } @@ -763,8 +763,8 @@ s32 EnRailgibud_PlayerInRangeWithCorrectState(EnRailgibud* this, GlobalContext* * 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); +s32 EnRailgibud_PlayerOutOfRange(EnRailgibud* this, PlayState* play) { + Player* player = GET_PLAYER(play); if (Actor_DistanceToPoint(&player->actor, &this->actor.home.pos) >= 100.0f) { return true; @@ -773,8 +773,8 @@ s32 EnRailgibud_PlayerOutOfRange(EnRailgibud* this, GlobalContext* globalCtx) { return false; } -void EnRailgibud_UpdateDamage(EnRailgibud* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); +void EnRailgibud_UpdateDamage(EnRailgibud* this, PlayState* play) { + Player* player = GET_PLAYER(play); if ((this->isInvincible != true) && (this->collider.base.acFlags & AC_HIT)) { if (this->actionFunc == EnRailgibud_WalkInCircles) { @@ -853,8 +853,8 @@ void EnRailgibud_UpdateDamage(EnRailgibud* this, GlobalContext* globalCtx) { * 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); +s32 EnRailgibud_MoveToIdealGrabPositionAndRotation(EnRailgibud* this, PlayState* play) { + Player* player = GET_PLAYER(play); Vec3f targetPos; f32 distanceFromTargetPos; f32 distanceFromTargetYOffset = 0.0f; @@ -878,7 +878,7 @@ s32 EnRailgibud_MoveToIdealGrabPositionAndRotation(EnRailgibud* this, GlobalCont return false; } -void EnRailgibud_MoveWithGravity(EnRailgibud* this, GlobalContext* globalCtx) { +void EnRailgibud_MoveWithGravity(EnRailgibud* this, PlayState* play) { if ((this->actionFunc == EnRailgibud_WalkToPlayer) || (this->actionFunc == EnRailgibud_WalkToHome) || (this->actionFunc == EnRailgibud_Damage)) { Actor_MoveWithGravity(&this->actor); @@ -893,14 +893,14 @@ void EnRailgibud_MoveWithGravity(EnRailgibud* this, GlobalContext* globalCtx) { * 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); +void EnRailgibud_MoveGrabbedPlayerAwayFromWall(EnRailgibud* this, PlayState* play) { + Player* player = GET_PLAYER(play); Vec3f targetPos; if ((this->actionFunc == EnRailgibud_Grab) && (this->grabState != EN_RAILGIBUD_GRAB_RELEASE)) { - Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 30.0f, 20.0f, 35.0f, 1); + Actor_UpdateBgCheckInfo(play, &this->actor, 30.0f, 20.0f, 35.0f, 1); } else { - Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 30.0f, 20.0f, 35.0f, 0x1D); + Actor_UpdateBgCheckInfo(play, &this->actor, 30.0f, 20.0f, 35.0f, 0x1D); } if ((this->actionFunc == EnRailgibud_Grab) && (this->grabState == EN_RAILGIBUD_GRAB_START) && @@ -912,7 +912,7 @@ void EnRailgibud_MoveGrabbedPlayerAwayFromWall(EnRailgibud* this, GlobalContext* } } -void EnRailgibud_UpdateEffect(EnRailgibud* this, GlobalContext* globalCtx) { +void EnRailgibud_UpdateEffect(EnRailgibud* this, PlayState* play) { if (this->drawDmgEffTimer > 0) { this->drawDmgEffTimer--; } @@ -925,12 +925,12 @@ void EnRailgibud_UpdateEffect(EnRailgibud* this, GlobalContext* globalCtx) { } } -void EnRailgibud_CheckForGibdoMask(EnRailgibud* this, GlobalContext* globalCtx) { +void EnRailgibud_CheckForGibdoMask(EnRailgibud* this, PlayState* play) { 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) { + if (Player_GetMask(play) == PLAYER_MASK_GIBDO) { this->actor.flags &= ~(ACTOR_FLAG_4 | ACTOR_FLAG_1); this->actor.flags |= (ACTOR_FLAG_8 | ACTOR_FLAG_1); this->actor.hintId = 0xFF; @@ -939,7 +939,7 @@ void EnRailgibud_CheckForGibdoMask(EnRailgibud* this, GlobalContext* globalCtx) EnRailgibud_SetupWalkToHome(this); } } - } else if (Player_GetMask(globalCtx) != PLAYER_MASK_GIBDO) { + } else if (Player_GetMask(play) != PLAYER_MASK_GIBDO) { 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) { @@ -950,93 +950,93 @@ void EnRailgibud_CheckForGibdoMask(EnRailgibud* this, GlobalContext* globalCtx) this->actor.textId = 0; } - EnRailgibud_CheckIfTalkingToPlayer(this, globalCtx); + EnRailgibud_CheckIfTalkingToPlayer(this, play); } } -void EnRailgibud_CheckIfTalkingToPlayer(EnRailgibud* this, GlobalContext* globalCtx) { +void EnRailgibud_CheckIfTalkingToPlayer(EnRailgibud* this, PlayState* play) { if ((this->textId == 0) && (this->type == EN_RAILGIBUD_TYPE_GIBDO)) { - if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { + if (Actor_ProcessTalkRequest(&this->actor, &play->state)) { this->isInvincible = true; - Message_StartTextbox(globalCtx, 0x13B2, &this->actor); + Message_StartTextbox(play, 0x13B2, &this->actor); this->textId = 0x13B2; Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_REDEAD_AIM); this->actor.speedXZ = 0.0f; } else if (CHECK_FLAG_ALL(this->actor.flags, (ACTOR_FLAG_1 | ACTOR_FLAG_8)) && !(this->collider.base.acFlags & AC_HIT)) { - func_800B8614(&this->actor, globalCtx, 100.0f); + func_800B8614(&this->actor, play, 100.0f); } } else { - switch (Message_GetState(&globalCtx->msgCtx)) { - case 5: - if (Message_ShouldAdvance(globalCtx)) { - Message_StartTextbox(globalCtx, 0x13B3, &this->actor); + switch (Message_GetState(&play->msgCtx)) { + case TEXT_STATE_5: + if (Message_ShouldAdvance(play)) { + Message_StartTextbox(play, 0x13B3, &this->actor); this->textId = 0x13B3; } break; - case 6: - if (Message_ShouldAdvance(globalCtx)) { + case TEXT_STATE_DONE: + if (Message_ShouldAdvance(play)) { this->textId = 0; this->isInvincible = false; this->actor.speedXZ = 0.6f; } break; - case 0: - case 1: - case 2: - case 3: - case 4: + case TEXT_STATE_NONE: + case TEXT_STATE_1: + case TEXT_STATE_CLOSING: + case TEXT_STATE_3: + case TEXT_STATE_CHOICE: break; } } } -void EnRailgibud_UpdateCollision(EnRailgibud* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); +void EnRailgibud_UpdateCollision(EnRailgibud* this, PlayState* play) { + Player* player = GET_PLAYER(play); 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); + CollisionCheck_SetOC(play, &play->colChkCtx, &this->collider.base); 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); + CollisionCheck_SetAC(play, &play->colChkCtx, &this->collider.base); } } } -void EnRailgibud_Update(Actor* thisx, GlobalContext* globalCtx) { +void EnRailgibud_Update(Actor* thisx, PlayState* play) { EnRailgibud* this = THIS; EnRailgibud_UpdateWalkForwardState(this); - EnRailgibud_CheckForGibdoMask(this, globalCtx); - EnRailgibud_UpdateDamage(this, globalCtx); + EnRailgibud_CheckForGibdoMask(this, play); + EnRailgibud_UpdateDamage(this, play); - this->actionFunc(this, globalCtx); + this->actionFunc(this, play); if (this->actionFunc != EnRailgibud_Stunned) { SkelAnime_Update(&this->skelAnime); } - EnRailgibud_MoveWithGravity(this, globalCtx); - EnRailgibud_UpdateCollision(this, globalCtx); - EnRailgibud_MoveGrabbedPlayerAwayFromWall(this, globalCtx); - EnRailgibud_UpdateEffect(this, globalCtx); + EnRailgibud_MoveWithGravity(this, play); + EnRailgibud_UpdateCollision(this, play); + EnRailgibud_MoveGrabbedPlayerAwayFromWall(this, play); + EnRailgibud_UpdateEffect(this, play); this->actor.focus.pos = this->actor.world.pos; this->actor.focus.pos.y += 50.0f; } -void EnRailgibud_MainGibdo_DeadUpdate(Actor* thisx, GlobalContext* globalCtx) { +void EnRailgibud_MainGibdo_DeadUpdate(Actor* thisx, PlayState* play) { EnRailgibud* this = THIS; EnRailgibud_UpdateWalkForwardState(this); } -s32 EnRailgibud_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, - Actor* thisx, Gfx** gfx) { +s32 EnRailgibud_OverrideLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, Actor* thisx, + Gfx** gfx) { EnRailgibud* this = THIS; if (limbIndex == GIBDO_LIMB_UPPER_BODY_ROOT) { @@ -1048,8 +1048,7 @@ s32 EnRailgibud_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** return false; } -void EnRailgibud_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx, - Gfx** gfx) { +void EnRailgibud_PostLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx, Gfx** gfx) { EnRailgibud* this = THIS; if ((this->drawDmgEffTimer != 0) && @@ -1060,46 +1059,46 @@ void EnRailgibud_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dLi (limbIndex == GIBDO_LIMB_LEFT_FOREARM) || (limbIndex == GIBDO_LIMB_LEFT_HAND) || (limbIndex == GIBDO_LIMB_RIGHT_SHOULDER_AND_UPPER_ARM) || (limbIndex == GIBDO_LIMB_RIGHT_FOREARM) || (limbIndex == GIBDO_LIMB_RIGHT_HAND) || (limbIndex == GIBDO_LIMB_HEAD) || (limbIndex == GIBDO_LIMB_PELVIS))) { - Matrix_GetStateTranslation(&this->limbPos[this->limbIndex]); + Matrix_MultZero(&this->limbPos[this->limbIndex]); this->limbIndex++; } } -void EnRailgibud_Draw(Actor* thisx, GlobalContext* globalCtx) { +void EnRailgibud_Draw(Actor* thisx, PlayState* play) { EnRailgibud* this = THIS; - OPEN_DISPS(globalCtx->state.gfxCtx); + OPEN_DISPS(play->state.gfxCtx); this->limbIndex = 0; if (this->actor.shape.shadowAlpha == 255) { - func_8012C28C(globalCtx->state.gfxCtx); + func_8012C28C(play->state.gfxCtx); gDPSetEnvColor(POLY_OPA_DISP++, 0, 0, 0, this->actor.shape.shadowAlpha); gSPSegment(POLY_OPA_DISP++, 0x08, D_801AEFA0); - POLY_OPA_DISP = SkelAnime_DrawFlex(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, - this->skelAnime.dListCount, EnRailgibud_OverrideLimbDraw, - EnRailgibud_PostLimbDraw, &this->actor, POLY_OPA_DISP); + POLY_OPA_DISP = + SkelAnime_DrawFlex(play, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, + EnRailgibud_OverrideLimbDraw, EnRailgibud_PostLimbDraw, &this->actor, POLY_OPA_DISP); } else { - func_8012C2DC(globalCtx->state.gfxCtx); + func_8012C2DC(play->state.gfxCtx); gDPSetEnvColor(POLY_XLU_DISP++, 0, 0, 0, this->actor.shape.shadowAlpha); gSPSegment(POLY_XLU_DISP++, 0x08, D_801AEF88); - POLY_XLU_DISP = SkelAnime_DrawFlex(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, - this->skelAnime.dListCount, EnRailgibud_OverrideLimbDraw, - EnRailgibud_PostLimbDraw, &this->actor, POLY_XLU_DISP); + POLY_XLU_DISP = + SkelAnime_DrawFlex(play, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, + EnRailgibud_OverrideLimbDraw, EnRailgibud_PostLimbDraw, &this->actor, POLY_XLU_DISP); } if (this->drawDmgEffTimer > 0) { - Actor_DrawDamageEffects(globalCtx, &this->actor, this->limbPos, ARRAY_COUNT(this->limbPos), - this->drawDmgEffScale, 0.5f, this->drawDmgEffAlpha, this->drawDmgEffType); + Actor_DrawDamageEffects(play, &this->actor, this->limbPos, ARRAY_COUNT(this->limbPos), this->drawDmgEffScale, + 0.5f, this->drawDmgEffAlpha, this->drawDmgEffType); } - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->state.gfxCtx); } -void EnRailgibud_InitCutsceneGibdo(EnRailgibud* this, GlobalContext* globalCtx) { +void EnRailgibud_InitCutsceneGibdo(EnRailgibud* this, PlayState* play) { s32 pad[2]; EnRailgibud_InitActorActionCommand(this); @@ -1108,12 +1107,13 @@ void EnRailgibud_InitCutsceneGibdo(EnRailgibud* this, GlobalContext* globalCtx) this->actor.flags |= ACTOR_FLAG_10; ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 28.0f); - 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); + SkelAnime_InitFlex(play, &this->skelAnime, &gGibdoSkel, &gGibdoRedeadIdleAnim, this->jointTable, this->morphTable, + GIBDO_LIMB_MAX); + Collider_InitCylinder(play, &this->collider); + Collider_SetCylinder(play, &this->collider, &this->actor, &sCylinderInit); CollisionCheck_SetInfo2(&this->actor.colChkInfo, &sDamageTable, &sColChkInfoInit); - if (gSaveContext.save.entranceIndex != 0x2090) { // NOT Cutscene: Music Box House Opens + + if (gSaveContext.save.entrance != ENTRANCE(IKANA_CANYON, 9)) { // NOT Cutscene: Music Box House Opens Actor_MarkForDeath(&this->actor); } @@ -1153,7 +1153,7 @@ void EnRailgibud_SetupDoNothing(EnRailgibud* this) { this->actionFunc = EnRailgibud_DoNothing; } -void EnRailgibud_DoNothing(EnRailgibud* this, GlobalContext* globalCtx) { +void EnRailgibud_DoNothing(EnRailgibud* this, PlayState* play) { } void EnRailgibud_SetupSinkIntoGround(EnRailgibud* this) { @@ -1161,57 +1161,57 @@ void EnRailgibud_SetupSinkIntoGround(EnRailgibud* this) { this->actionFunc = EnRailgibud_SinkIntoGround; } -void EnRailgibud_SinkIntoGround(EnRailgibud* this, GlobalContext* globalCtx) { +void EnRailgibud_SinkIntoGround(EnRailgibud* this, PlayState* play) { 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 { - EnRailgibud_SpawnEffectsForSinkingIntoTheGround(this, globalCtx, 0); + EnRailgibud_SpawnEffectsForSinkingIntoTheGround(this, play, 0); } } -s32 EnRailgibud_PerformCutsceneActions(EnRailgibud* this, GlobalContext* globalCtx) { +s32 EnRailgibud_PerformCutsceneActions(EnRailgibud* this, PlayState* play) { s32 actionIndex; - 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) { + if (Cutscene_CheckActorAction(play, this->actorActionCommand)) { + actionIndex = Cutscene_GetActorActionIndex(play, this->actorActionCommand); + if (this->csAction != play->csCtx.actorActions[actionIndex]->action) { + this->csAction = play->csCtx.actorActions[actionIndex]->action; + switch (play->csCtx.actorActions[actionIndex]->action) { case 1: - this->cutsceneAnimationIndex = EN_RAILGIBUD_ANIMATION_IDLE; - Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, EN_RAILGIBUD_ANIMATION_IDLE); + this->cutsceneAnimIndex = EN_RAILGIBUD_ANIM_IDLE; + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, EN_RAILGIBUD_ANIM_IDLE); break; case 2: - this->cutsceneAnimationIndex = EN_RAILGIBUD_ANIMATION_SLUMP_START; + this->cutsceneAnimIndex = EN_RAILGIBUD_ANIM_SLUMP_START; Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_REDEAD_WEAKENED2); - Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, EN_RAILGIBUD_ANIMATION_SLUMP_START); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, EN_RAILGIBUD_ANIM_SLUMP_START); break; case 3: - this->cutsceneAnimationIndex = EN_RAILGIBUD_ANIMATION_CONVULSION; - Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, EN_RAILGIBUD_ANIMATION_CONVULSION); + this->cutsceneAnimIndex = EN_RAILGIBUD_ANIM_CONVULSION; + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, EN_RAILGIBUD_ANIM_CONVULSION); break; case 4: - this->cutsceneAnimationIndex = EN_RAILGIBUD_ANIMATION_ARMS_UP_START; - Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, EN_RAILGIBUD_ANIMATION_ARMS_UP_START); + this->cutsceneAnimIndex = EN_RAILGIBUD_ANIM_ARMS_UP_START; + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, EN_RAILGIBUD_ANIM_ARMS_UP_START); break; case 5: - this->cutsceneAnimationIndex = EN_RAILGIBUD_ANIMATION_WALK; - Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, EN_RAILGIBUD_ANIMATION_WALK); + this->cutsceneAnimIndex = EN_RAILGIBUD_ANIM_WALK; + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, EN_RAILGIBUD_ANIM_WALK); break; } } else if (Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) { - 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); + if (this->cutsceneAnimIndex == EN_RAILGIBUD_ANIM_SLUMP_START) { + this->cutsceneAnimIndex = EN_RAILGIBUD_ANIM_SLUMP_LOOP; + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, EN_RAILGIBUD_ANIM_SLUMP_LOOP); + } else if (this->cutsceneAnimIndex == EN_RAILGIBUD_ANIM_ARMS_UP_START) { + this->cutsceneAnimIndex = EN_RAILGIBUD_ANIM_ARMS_UP_LOOP; + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, EN_RAILGIBUD_ANIM_ARMS_UP_LOOP); EnRailgibud_SetupSinkIntoGround(this); } } @@ -1228,7 +1228,7 @@ s32 EnRailgibud_PerformCutsceneActions(EnRailgibud* this, GlobalContext* globalC case 5: if (Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) { - if (globalCtx->csCtx.frames < 280) { + if (play->csCtx.frames < 280) { Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_REDEAD_CRY); } else { Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_REDEAD_WEAKENED1); @@ -1237,7 +1237,7 @@ s32 EnRailgibud_PerformCutsceneActions(EnRailgibud* this, GlobalContext* globalC break; } - Cutscene_ActorTranslateAndYaw(&this->actor, globalCtx, actionIndex); + Cutscene_ActorTranslateAndYaw(&this->actor, play, actionIndex); return true; } @@ -1245,10 +1245,10 @@ s32 EnRailgibud_PerformCutsceneActions(EnRailgibud* this, GlobalContext* globalC return false; } -void EnRailgibud_Cutscene_Update(Actor* thisx, GlobalContext* globalCtx) { +void EnRailgibud_Cutscene_Update(Actor* thisx, PlayState* play) { EnRailgibud* this = THIS; - this->actionFunc(this, globalCtx); - EnRailgibud_PerformCutsceneActions(this, globalCtx); + this->actionFunc(this, play); + EnRailgibud_PerformCutsceneActions(this, play); 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 a51fd37d4..78655f870 100644 --- a/src/overlays/actors/ovl_En_Railgibud/z_en_railgibud.h +++ b/src/overlays/actors/ovl_En_Railgibud/z_en_railgibud.h @@ -6,36 +6,36 @@ struct EnRailgibud; -typedef void (*EnRailgibudActionFunc)(struct EnRailgibud*, GlobalContext*); +typedef void (*EnRailgibudActionFunc)(struct EnRailgibud*, PlayState*); #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 limbPos[15]; - /* 0x028C */ s32 limbIndex; - /* 0x0290 */ UNK_TYPE1 unk290[0x4]; - /* 0x0294 */ Vec3s* points; - /* 0x0298 */ s32 currentPoint; - /* 0x029C */ s32 pathCount; - /* 0x02A0 */ f32 drawDmgEffAlpha; - /* 0x02A4 */ f32 drawDmgEffScale; - /* 0x02A8 */ Vec3s jointTable[GIBDO_LIMB_MAX]; - /* 0x0344 */ Vec3s morphTable[GIBDO_LIMB_MAX]; - /* 0x03E0 */ Vec3s headRotation; - /* 0x03E6 */ Vec3s upperBodyRotation; - /* 0x03EC */ s16 shouldWalkForward; // Only used by the "main" Gibdo - /* 0x03EE */ s16 shouldWalkForwardNextFrame; // Only used by the "main" Gibdo - /* 0x03F0 */ union { + /* 0x000 */ Actor actor; + /* 0x144 */ ColliderCylinder collider; + /* 0x190 */ SkelAnime skelAnime; + /* 0x1D4 */ EnRailgibudActionFunc actionFunc; + /* 0x1D8 */ Vec3f limbPos[15]; + /* 0x28C */ s32 limbIndex; + /* 0x290 */ UNK_TYPE1 unk290[0x4]; + /* 0x294 */ Vec3s* points; + /* 0x298 */ s32 currentPoint; + /* 0x29C */ s32 pathCount; + /* 0x2A0 */ f32 drawDmgEffAlpha; + /* 0x2A4 */ f32 drawDmgEffScale; + /* 0x2A8 */ Vec3s jointTable[GIBDO_LIMB_MAX]; + /* 0x344 */ Vec3s morphTable[GIBDO_LIMB_MAX]; + /* 0x3E0 */ Vec3s headRotation; + /* 0x3E6 */ Vec3s upperBodyRotation; + /* 0x3EC */ s16 shouldWalkForward; // Only used by the "main" Gibdo + /* 0x3EE */ s16 shouldWalkForwardNextFrame; // Only used by the "main" Gibdo + /* 0x3F0 */ union { s16 grabState; - s16 cutsceneAnimationIndex; + s16 cutsceneAnimIndex; }; - /* 0x03F2 */ union { + /* 0x3F2 */ union { s16 playerStunWaitTimer; // Cannot stun the player if this is non-zero s16 grabDamageTimer; s16 headShakeTimer; @@ -43,16 +43,16 @@ typedef struct EnRailgibud { s16 deathTimer; s16 sinkTimer; }; - /* 0x03F4 */ s16 grabWaitTimer; // Cannot grab the player if this is non-zero - /* 0x03F6 */ s16 drawDmgEffTimer; - /* 0x03F8 */ s16 type; - /* 0x03FA */ s16 isInvincible; - /* 0x03FC */ u16 actorActionCommand; - /* 0x03FE */ u16 csAction; - /* 0x0400 */ u16 textId; - /* 0x0402 */ s16 timeInitialized; // unused other than setting it - /* 0x0404 */ u8 drawDmgEffType; - /* 0x0405 */ s8 unk_405; // related to player->unk_ADD + /* 0x3F4 */ s16 grabWaitTimer; // Cannot grab the player if this is non-zero + /* 0x3F6 */ s16 drawDmgEffTimer; + /* 0x3F8 */ s16 type; + /* 0x3FA */ s16 isInvincible; + /* 0x3FC */ u16 actorActionCommand; + /* 0x3FE */ u16 csAction; + /* 0x400 */ u16 textId; + /* 0x402 */ s16 timeInitialized; // unused other than setting it + /* 0x404 */ u8 drawDmgEffType; + /* 0x405 */ s8 unk_405; // related to player->unk_ADD } EnRailgibud; // size = 0x408 extern const ActorInit En_Railgibud_InitVars; diff --git a/src/overlays/actors/ovl_En_Rat/z_en_rat.c b/src/overlays/actors/ovl_En_Rat/z_en_rat.c index 583d3637c..1054876aa 100644 --- a/src/overlays/actors/ovl_En_Rat/z_en_rat.c +++ b/src/overlays/actors/ovl_En_Rat/z_en_rat.c @@ -5,17 +5,36 @@ */ #include "z_en_rat.h" +#include "objects/gameplay_keep/gameplay_keep.h" +#include "overlays/actors/ovl_En_Bom/z_en_bom.h" #define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_4 | ACTOR_FLAG_200) #define THIS ((EnRat*)thisx) -void EnRat_Init(Actor* thisx, GlobalContext* globalCtx); -void EnRat_Destroy(Actor* thisx, GlobalContext* globalCtx); -void EnRat_Update(Actor* thisx, GlobalContext* globalCtx); -void EnRat_Draw(Actor* thisx, GlobalContext* globalCtx); +void EnRat_Init(Actor* thisx, PlayState* play); +void EnRat_Destroy(Actor* thisx, PlayState* play); +void EnRat_Update(Actor* thisx, PlayState* play); +void EnRat_Draw(Actor* thisx, PlayState* play); + +void EnRat_InitializeAxes(EnRat* this); +void EnRat_UpdateRotation(EnRat* this); +void EnRat_Revive(EnRat* this, PlayState* play); +void EnRat_SetupIdle(EnRat* this); +void EnRat_Idle(EnRat* this, PlayState* play); +void EnRat_SetupSpottedPlayer(EnRat* this); +void EnRat_SpottedPlayer(EnRat* this, PlayState* play); +void EnRat_SetupChasePlayer(EnRat* this); +void EnRat_ChasePlayer(EnRat* this, PlayState* play); +void EnRat_Bounced(EnRat* this, PlayState* play); +void EnRat_Explode(EnRat* this, PlayState* play); +void EnRat_PostDetonation(EnRat* this, PlayState* play); + +typedef enum { + /* -2 */ EN_RAT_HOOK_STARTED = -2, + /* -1 */ EN_RAT_HOOKED, +} EnRatHookedState; -#if 0 const ActorInit En_Rat_InitVars = { ACTOR_EN_RAT, ACTORCAT_ENEMY, @@ -28,123 +47,920 @@ const ActorInit En_Rat_InitVars = { (ActorFunc)EnRat_Draw, }; -// static ColliderSphereInit sSphereInit = { -static ColliderSphereInit D_80A58400 = { - { COLTYPE_NONE, AT_ON | 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_HARD, BUMP_ON | BUMP_HOOKABLE, OCELEM_ON, }, +static ColliderSphereInit sSphereInit = { + { + COLTYPE_NONE, + AT_ON | AT_TYPE_ENEMY, + AC_ON | AC_TYPE_PLAYER, + OC1_ON | OC1_TYPE_ALL, + OC2_TYPE_1, + COLSHAPE_SPHERE, + }, + { + ELEMTYPE_UNK0, + { 0xF7CFFFFF, 0x00, 0x08 }, + { 0xF7CFFFFF, 0x00, 0x00 }, + TOUCH_ON | TOUCH_SFX_HARD, + BUMP_ON | BUMP_HOOKABLE, + OCELEM_ON, + }, { 1, { { 0, 0, 0 }, 23 }, 100 }, }; -// static DamageTable sDamageTable = { -static DamageTable D_80A5842C = { - /* 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, 0xF), - /* Goron punch */ DMG_ENTRY(1, 0x0), - /* Sword */ DMG_ENTRY(1, 0x0), - /* Goron pound */ DMG_ENTRY(1, 0x0), - /* Fire arrow */ DMG_ENTRY(2, 0x0), - /* Ice arrow */ DMG_ENTRY(2, 0x0), - /* Light arrow */ DMG_ENTRY(2, 0x0), - /* 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(1, 0x0), - /* Normal shield */ DMG_ENTRY(0, 0x0), - /* Light ray */ DMG_ENTRY(0, 0x0), - /* Thrown object */ DMG_ENTRY(1, 0x0), - /* Zora punch */ DMG_ENTRY(1, 0x0), - /* Spin attack */ DMG_ENTRY(1, 0x0), - /* Sword beam */ DMG_ENTRY(0, 0x0), - /* Normal Roll */ DMG_ENTRY(0, 0x0), - /* UNK_DMG_0x1B */ DMG_ENTRY(0, 0x0), - /* UNK_DMG_0x1C */ DMG_ENTRY(0, 0x0), - /* Unblockable */ DMG_ENTRY(0, 0x0), - /* UNK_DMG_0x1E */ DMG_ENTRY(0, 0x0), - /* Powder Keg */ DMG_ENTRY(1, 0x0), +typedef enum { + /* 0x0 */ EN_RAT_DMGEFF_NONE, + /* 0x1 */ EN_RAT_DMGEFF_STUN, + /* 0xF */ EN_RAT_DMGEFF_HOOKSHOT = 0xF, // Pulls the Real Bombchu towards the player +} EnRatDamageEffect; + +static DamageTable sDamageTable = { + /* Deku Nut */ DMG_ENTRY(0, EN_RAT_DMGEFF_STUN), + /* Deku Stick */ DMG_ENTRY(1, EN_RAT_DMGEFF_NONE), + /* Horse trample */ DMG_ENTRY(1, EN_RAT_DMGEFF_NONE), + /* Explosives */ DMG_ENTRY(1, EN_RAT_DMGEFF_NONE), + /* Zora boomerang */ DMG_ENTRY(1, EN_RAT_DMGEFF_NONE), + /* Normal arrow */ DMG_ENTRY(1, EN_RAT_DMGEFF_NONE), + /* UNK_DMG_0x06 */ DMG_ENTRY(0, EN_RAT_DMGEFF_NONE), + /* Hookshot */ DMG_ENTRY(0, EN_RAT_DMGEFF_HOOKSHOT), + /* Goron punch */ DMG_ENTRY(1, EN_RAT_DMGEFF_NONE), + /* Sword */ DMG_ENTRY(1, EN_RAT_DMGEFF_NONE), + /* Goron pound */ DMG_ENTRY(1, EN_RAT_DMGEFF_NONE), + /* Fire arrow */ DMG_ENTRY(2, EN_RAT_DMGEFF_NONE), + /* Ice arrow */ DMG_ENTRY(2, EN_RAT_DMGEFF_NONE), + /* Light arrow */ DMG_ENTRY(2, EN_RAT_DMGEFF_NONE), + /* Goron spikes */ DMG_ENTRY(1, EN_RAT_DMGEFF_NONE), + /* Deku spin */ DMG_ENTRY(1, EN_RAT_DMGEFF_NONE), + /* Deku bubble */ DMG_ENTRY(1, EN_RAT_DMGEFF_NONE), + /* Deku launch */ DMG_ENTRY(2, EN_RAT_DMGEFF_NONE), + /* UNK_DMG_0x12 */ DMG_ENTRY(0, EN_RAT_DMGEFF_STUN), + /* Zora barrier */ DMG_ENTRY(1, EN_RAT_DMGEFF_NONE), + /* Normal shield */ DMG_ENTRY(0, EN_RAT_DMGEFF_NONE), + /* Light ray */ DMG_ENTRY(0, EN_RAT_DMGEFF_NONE), + /* Thrown object */ DMG_ENTRY(1, EN_RAT_DMGEFF_NONE), + /* Zora punch */ DMG_ENTRY(1, EN_RAT_DMGEFF_NONE), + /* Spin attack */ DMG_ENTRY(1, EN_RAT_DMGEFF_NONE), + /* Sword beam */ DMG_ENTRY(0, EN_RAT_DMGEFF_NONE), + /* Normal Roll */ DMG_ENTRY(0, EN_RAT_DMGEFF_NONE), + /* UNK_DMG_0x1B */ DMG_ENTRY(0, EN_RAT_DMGEFF_NONE), + /* UNK_DMG_0x1C */ DMG_ENTRY(0, EN_RAT_DMGEFF_NONE), + /* Unblockable */ DMG_ENTRY(0, EN_RAT_DMGEFF_NONE), + /* UNK_DMG_0x1E */ DMG_ENTRY(0, EN_RAT_DMGEFF_NONE), + /* Powder Keg */ DMG_ENTRY(1, EN_RAT_DMGEFF_NONE), }; -// sColChkInfoInit -static CollisionCheckInfoInit D_80A5844C = { 1, 30, 30, 50 }; +static CollisionCheckInfoInit sColChkInfoInit = { 1, 30, 30, 50 }; -// static InitChainEntry sInitChain[] = { -static InitChainEntry D_80A58464[] = { +static TexturePtr sSparkTextures[] = { + gElectricSpark1Tex, + gElectricSpark2Tex, + gElectricSpark3Tex, + gElectricSpark4Tex, +}; + +static InitChainEntry sInitChain[] = { ICHAIN_S8(hintId, 97, ICHAIN_CONTINUE), ICHAIN_VEC3F_DIV1000(scale, 15, ICHAIN_CONTINUE), ICHAIN_F32(targetArrowOffset, 5000, 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_80A58400; -extern DamageTable D_80A5842C; -extern CollisionCheckInfoInit D_80A5844C; -extern InitChainEntry D_80A58464[]; +static s32 sTexturesDesegmented = false; -extern UNK_TYPE D_06000174; -extern UNK_TYPE D_0600026C; +void EnRat_Init(Actor* thisx, PlayState* play) { + s32 pad; + EnRat* this = THIS; + s32 attackRange; + s32 i; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Rat/EnRat_Init.s") + Actor_ProcessInitChain(&this->actor, sInitChain); + Collider_InitAndSetSphere(play, &this->collider, &this->actor, &sSphereInit); + this->collider.dim.worldSphere.radius = sSphereInit.dim.modelSphere.radius; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Rat/EnRat_Destroy.s") + attackRange = EN_RAT_GET_ATTACK_RANGE(&this->actor); + if (EN_RAT_IS_OVERWORLD_TYPE(&this->actor)) { + this->actor.params = EN_RAT_TYPE_OVERWORLD; + } else { + this->actor.params = EN_RAT_TYPE_DUNGEON; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Rat/func_80A563CC.s") + SkelAnime_InitFlex(play, &this->skelAnime, &gRealBombchuSkel, &gRealBombchuRunAnim, this->jointTable, + this->morphTable, REAL_BOMBCHU_LIMB_MAX); + ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 25.0f); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Rat/func_80A56444.s") + if (EN_RAT_GET_TYPE(&this->actor) == EN_RAT_TYPE_DUNGEON) { + Effect_Add(play, &this->blure1Index, EFFECT_BLURE2, 0, 0, &sBlureInit); + Effect_Add(play, &this->blure2Index, EFFECT_BLURE2, 0, 0, &sBlureInit); + this->timer = 30; + } else { + this->timer = 150; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Rat/func_80A5665C.s") + CollisionCheck_SetInfo(&this->actor.colChkInfo, &sDamageTable, &sColChkInfoInit); + EnRat_InitializeAxes(this); + EnRat_UpdateRotation(this); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Rat/func_80A566E0.s") + if ((attackRange == 255) || (attackRange == 0)) { + this->attackRange = 350.0f; + } else if (EN_RAT_GET_TYPE(&this->actor) == EN_RAT_TYPE_DUNGEON) { + this->attackRange = attackRange * 0.1f * 40.0f; + } else { + this->attackRange = attackRange * 0.5f * 40.0f; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Rat/func_80A56994.s") + if (!sTexturesDesegmented) { + for (i = 0; i < ARRAY_COUNT(sSparkTextures); i++) { + sSparkTextures[i] = Lib_SegmentedToVirtual(sSparkTextures[i]); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Rat/func_80A56AFC.s") + sTexturesDesegmented = true; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Rat/func_80A56EB8.s") + EnRat_SetupIdle(this); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Rat/func_80A56F68.s") +void EnRat_Destroy(Actor* thisx, PlayState* play) { + EnRat* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Rat/func_80A57010.s") + if (EN_RAT_GET_TYPE(&this->actor) == EN_RAT_TYPE_DUNGEON) { + Effect_Destroy(play, this->blure1Index); + Effect_Destroy(play, this->blure2Index); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Rat/func_80A57118.s") + Collider_DestroySphere(play, &this->collider); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Rat/func_80A57180.s") +void EnRat_InitializeAxes(EnRat* this) { + 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); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Rat/func_80A5723C.s") + Matrix_MultVecZ(1.0f, &this->axisForwards); + Matrix_MultVecY(1.0f, &this->axisUp); + Matrix_MultVecX(1.0f, &this->axisLeft); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Rat/func_80A57330.s") +/** + * Returns true if floorPoly is valid for the Real Bombchu to move on, false otherwise. + */ +s32 EnRat_UpdateFloorPoly(EnRat* this, CollisionPoly* floorPoly, PlayState* play) { + Vec3f normal; + Vec3f vec; + f32 angle; + f32 magnitude; + f32 normDotUp; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Rat/func_80A57384.s") + this->actor.floorPoly = floorPoly; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Rat/func_80A57488.s") + 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 { + normal.x = 0.0f; + normal.z = 0.0f; + normal.y = 1.0f; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Rat/func_80A574E8.s") + normDotUp = DOTXYZ(normal, this->axisUp); + if (fabsf(normDotUp) >= 0.999f) { + return false; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Rat/func_80A57570.s") + angle = func_80086C48(normDotUp); + if (angle < 0.001f) { + return false; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Rat/func_80A575F4.s") + Math3D_CrossProduct(&this->axisUp, &normal, &vec); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Rat/func_80A5764C.s") + magnitude = Math3D_Vec3fMagnitude(&vec); + if (magnitude < 0.001f) { + EnRat_Explode(this, play); + return false; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Rat/func_80A57918.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); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Rat/func_80A57984.s") + magnitude = Math3D_Vec3fMagnitude(&this->axisForwards); + if (magnitude < 0.001f) { + EnRat_Explode(this, play); + return false; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Rat/func_80A57A08.s") + Math_Vec3f_Scale(&this->axisForwards, 1.0f / magnitude); + Math_Vec3f_Copy(&this->axisUp, &normal); + return true; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Rat/func_80A57A9C.s") +void EnRat_UpdateRotation(EnRat* this) { + MtxF mf; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Rat/EnRat_Update.s") + mf.xx = this->axisLeft.x; + mf.yx = this->axisLeft.y; + mf.zx = this->axisLeft.z; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Rat/func_80A57F10.s") + mf.xy = this->axisUp.x; + mf.yy = this->axisUp.y; + mf.zy = this->axisUp.z; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Rat/func_80A57F4C.s") + mf.xz = this->axisForwards.x; + mf.yz = this->axisForwards.y; + mf.zz = this->axisForwards.z; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Rat/EnRat_Draw.s") + Matrix_MtxFToYXZRot(&mf, &this->actor.world.rot, false); + this->actor.world.rot.x = -this->actor.world.rot.x; +} + +/** + * Chooses to either look at the player (if the Real Bombchu has spotted the player or + * is chasing after them) or at some other semi-random point (if the Bombchu is idle). + */ +void EnRat_ChooseDirection(EnRat* this) { + Vec3f newAxisForwards; + s16 angle; + + if (this->actionFunc != EnRat_Idle) { + angle = this->actor.yawTowardsPlayer - this->actor.shape.rot.y; + if (this->axisUp.y < -0.25f) { + angle -= 0x8000; + } + } else { + if (Actor_DistanceToPoint(&this->actor, &this->actor.home.pos) > 50.0f) { + Vec3f homeInHome; + Vec3f worldInHome; + Vec3f worldPlusForwardInHome; + Vec3f upInHome; + + // Set up matrix to unrotate, to make the "home rot" the new basis triad + Matrix_RotateZS(-this->actor.home.rot.z, MTXMODE_NEW); + Matrix_RotateXS(-this->actor.home.rot.x, MTXMODE_APPLY); + Matrix_RotateYS(-this->actor.home.rot.y, MTXMODE_APPLY); + + // Unrotate axisUp into "home rot" triad and store in upfInHome + Matrix_MultVec3f(&this->axisUp, &upInHome); + + // Move world.pos forward by axisForwards and store in homeInHome + Math_Vec3f_Sum(&this->actor.world.pos, &this->axisForwards, &homeInHome); + + // Unrotate homeInHome into "home rot" triad and store in worldPlusForwardInHome + Matrix_MultVec3f(&homeInHome, &worldPlusForwardInHome); + + // Unrotate home into "home rot" triad + Matrix_MultVec3f(&this->actor.home.pos, &homeInHome); + + // Unrotate world into "home rot" triad + Matrix_MultVec3f(&this->actor.world.pos, &worldInHome); + + angle = Math_Vec3f_Yaw(&worldInHome, &homeInHome) - Math_Vec3f_Yaw(&worldInHome, &worldPlusForwardInHome); + if (upInHome.y < -0.25f) { + angle -= 0x8000; + } + + angle += (s16)randPlusMinusPoint5Scaled(0x800); + } else { + angle = (Rand_ZeroOne() < 0.1f) ? (s16)randPlusMinusPoint5Scaled(0x800) : 0; + } + } + + angle = CLAMP(angle, -0x800, 0x800); + Matrix_RotateAxisF(angle * (M_PI / 0x8000), &this->axisUp, MTXMODE_NEW); + Matrix_MultVec3f(&this->axisForwards, &newAxisForwards); + Math_Vec3f_Copy(&this->axisForwards, &newAxisForwards); + Math3D_CrossProduct(&this->axisUp, &this->axisForwards, &this->axisLeft); + this->shouldRotateOntoSurfaces = true; +} + +/** + * Returns true if the Real Bombchu is on a collision poly or is on the water's surface. + */ +s32 EnRat_IsOnCollisionPoly(PlayState* play, Vec3f* posA, Vec3f* posB, Vec3f* posResult, CollisionPoly** poly, + s32* bgId) { + WaterBox* waterBox; + s32 isOnWater; + f32 waterSurface; + + if (WaterBox_GetSurface1(play, &play->colCtx, posB->x, posB->z, &waterSurface, &waterBox) && + (waterSurface <= posA->y) && (posB->y <= waterSurface)) { + isOnWater = true; + } else { + isOnWater = false; + } + + if (BgCheck_EntityLineTest1(&play->colCtx, posA, posB, posResult, poly, 1, 1, 1, 1, bgId)) { + if (!(func_800C9A4C(&play->colCtx, *poly, *bgId) & 0x30) && (!isOnWater || (waterSurface <= posResult->y))) { + return true; + } + } + + if (isOnWater) { + posResult->x = posB->x; + posResult->y = waterSurface; + posResult->z = posB->z; + *poly = NULL; + *bgId = BGCHECK_SCENE; + return true; + } + + return false; +} + +s32 EnRat_IsTouchingSurface(EnRat* this, PlayState* play) { + CollisionPoly* polySide = NULL; + CollisionPoly* polyUpDown = NULL; + s32 bgIdSide; + s32 bgIdUpDown; + s32 i; + f32 lineLength; + Vec3f posA; + Vec3f posB; + Vec3f posSide; + Vec3f posUpDown; + + bgIdUpDown = bgIdSide = BGCHECK_SCENE; + + lineLength = 2.0f * this->actor.speedXZ; + + posA.x = this->actor.world.pos.x + (this->axisUp.x * 5.0f); + posA.y = this->actor.world.pos.y + (this->axisUp.y * 5.0f); + posA.z = this->actor.world.pos.z + (this->axisUp.z * 5.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 (EnRat_IsOnCollisionPoly(play, &posA, &posB, &posUpDown, &polyUpDown, &bgIdUpDown)) { + 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 (EnRat_IsOnCollisionPoly(play, &posA, &posB, &posSide, &polySide, &bgIdSide)) { + if ((polySide != NULL) && this->hasLostTrackOfPlayer) { + return false; + } + + this->shouldRotateOntoSurfaces |= EnRat_UpdateFloorPoly(this, polySide, play); + Math_Vec3f_Copy(&this->actor.world.pos, &posSide); + this->actor.floorBgId = bgIdSide; + this->actor.speedXZ = 0.0f; + } else { + if (polyUpDown != this->actor.floorPoly) { + this->shouldRotateOntoSurfaces |= EnRat_UpdateFloorPoly(this, polyUpDown, play); + } + + 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 (EnRat_IsOnCollisionPoly(play, &posA, &posB, &posSide, &polySide, &bgIdSide)) { + this->shouldRotateOntoSurfaces |= EnRat_UpdateFloorPoly(this, polySide, play); + Math_Vec3f_Copy(&this->actor.world.pos, &posSide); + this->actor.floorBgId = bgIdSide; + break; + } + } + + if (i == 3) { + // no collision nearby + return false; + } + } + + return true; +} + +/** + * Transform coordinates from actor coordinate space (origin at actor's world.pos, z-axis is facing + * angle, i.e. shape.rot.y) to world space, according to current orientation. + * `offset` is expected to already be at world scale. + */ +void EnRat_ActorCoordsToWorld(EnRat* 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); +} + +/** + * This function will spawn splashes and ripples as the Real Bombchu runs across the water's surface. + */ +void EnRat_SpawnWaterEffects(EnRat* this, PlayState* play) { + s32 pad; + Vec3f splashPos; + + EffectSsGRipple_Spawn(play, &this->actor.world.pos, 70, 500, 0); + splashPos.x = this->actor.world.pos.x - (this->axisForwards.x * 10.0f); + splashPos.z = this->actor.world.pos.z - (this->axisForwards.z * 10.0f); + splashPos.y = this->actor.world.pos.y + 5.0f; + EffectSsGSplash_Spawn(play, &splashPos, NULL, NULL, 1, 450); +} + +void EnRat_HandleNonSceneCollision(EnRat* this, PlayState* play) { + s16 yaw = this->actor.shape.rot.y; + f32 sin; + f32 cos; + f32 tempX; + + BgCheck2_UpdateActorAttachedToMesh(&play->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); + } +} + +static Vec3f sSmokeAccel = { 0.0f, 0.6f, 0.0f }; +static Color_RGBA8 sSmokeColor = { 255, 255, 255, 255 }; + +void EnRat_SpawnSmoke(EnRat* this, PlayState* play) { + func_800B0EB0(play, &this->smokePos, &gZeroVec3f, &sSmokeAccel, &sSmokeColor, &sSmokeColor, 75, 7, 8); +} + +void EnRat_SetupRevive(EnRat* this) { + this->hasLostTrackOfPlayer = false; + this->timer = 200; + this->damageReaction.stunTimer = 0; + Math_Vec3f_Copy(&this->actor.world.pos, &this->actor.home.pos); + this->actor.shape.yOffset = 0.0f; + this->actor.shape.rot.x = this->actor.home.rot.x; + this->actor.shape.rot.y = this->actor.home.rot.y; + this->actor.shape.rot.z = this->actor.home.rot.z; + EnRat_InitializeAxes(this); + EnRat_UpdateRotation(this); + this->actor.flags &= ~ACTOR_FLAG_1; + this->actor.speedXZ = 0.0f; + Animation_PlayLoopSetSpeed(&this->skelAnime, &gRealBombchuSpotAnim, 0.0f); + this->revivePosY = 2666.6667f; + this->actor.draw = NULL; + this->actor.shape.shadowDraw = NULL; + this->actionFunc = EnRat_Revive; +} + +/** + * Makes the Real Bombchu respawn after a certain amount of time by tunneling up from underground. + * Used only by Overworld-type Bombchu. + */ +void EnRat_Revive(EnRat* this, PlayState* play) { + if (this->timer > 0) { + this->timer--; + if (this->timer == 0) { + this->actor.flags |= ACTOR_FLAG_1; + this->actor.draw = EnRat_Draw; + this->skelAnime.playSpeed = 1.0f; + } + } else { + Math_StepToF(&this->revivePosY, 0.0f, 666.6667f); + if (Animation_OnFrame(&this->skelAnime, 2.0f)) { + func_800B1210(play, &this->actor.world.pos, &this->axisUp, &gZeroVec3f, 600, 100); + this->actor.shape.shadowDraw = ActorShadow_DrawCircle; + } + + if (Animation_OnFrame(&this->skelAnime, 0.0f)) { + this->actor.flags &= ~ACTOR_FLAG_10; + this->timer = 150; + EnRat_SetupIdle(this); + } + } +} + +void EnRat_SetupIdle(EnRat* this) { + Animation_PlayLoop(&this->skelAnime, &gRealBombchuRunAnim); + this->animLoopCounter = 5; + this->actor.speedXZ = 2.0f; + this->actionFunc = EnRat_Idle; +} + +/** + * Move around randomly near the Bombchu's home until it spots the player. + */ +void EnRat_Idle(EnRat* this, PlayState* play) { + Player* player = GET_PLAYER(play); + + this->actor.speedXZ = 2.0f; + if (Animation_OnFrame(&this->skelAnime, 0.0f)) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_BOMCHU_WALK); + if (this->animLoopCounter != 0) { + this->animLoopCounter--; + } + } + + if ((this->animLoopCounter == 0) && (Rand_ZeroOne() < 0.05f)) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_BOMCHU_VOICE); + this->animLoopCounter = 5; + } + + if (!(player->stateFlags3 & PLAYER_STATE3_100) && (this->actor.xzDistToPlayer < this->attackRange) && + (Player_GetMask(play) != PLAYER_MASK_STONE) && Actor_IsFacingPlayer(&this->actor, 0x3800)) { + EnRat_SetupSpottedPlayer(this); + } +} + +void EnRat_SetupSpottedPlayer(EnRat* this) { + this->actor.flags |= ACTOR_FLAG_10; + Animation_MorphToLoop(&this->skelAnime, &gRealBombchuSpotAnim, -5.0f); + this->animLoopCounter = 3; + this->actor.speedXZ = 0.0f; + this->actionFunc = EnRat_SpottedPlayer; +} + +/** + * Play the "spotted" animation a few times, then start chasing the player. + */ +void EnRat_SpottedPlayer(EnRat* this, PlayState* play) { + if ((this->animLoopCounter == 3) && Animation_OnFrame(&this->skelAnime, 5.0f)) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_BOMCHU_AIM); + } + + if (Animation_OnFrame(&this->skelAnime, 0.0f)) { + this->animLoopCounter--; + if (this->animLoopCounter == 0) { + EnRat_SetupChasePlayer(this); + } + } +} + +void EnRat_UpdateSparkOffsets(EnRat* this) { + s32 i; + Vec3f* ptr; + + for (i = 0; i < ARRAY_COUNT(this->sparkOffsets); i++) { + ptr = &this->sparkOffsets[i]; + ptr->x = randPlusMinusPoint5Scaled(6.0f); + ptr->y = randPlusMinusPoint5Scaled(6.0f); + ptr->z = randPlusMinusPoint5Scaled(6.0f); + } +} + +void EnRat_SetupChasePlayer(EnRat* this) { + Animation_MorphToLoop(&this->skelAnime, &gRealBombchuRunAnim, -5.0f); + this->actor.speedXZ = 6.1f; + EnRat_UpdateSparkOffsets(this); + this->actionFunc = EnRat_ChasePlayer; +} + +static Vec3f sBlureP1Offset = { 0.0f, 10.5f, -9.0f }; +static Vec3f sBlureP2LeftOffset = { 18.0f, 0.0f, -7.5f }; +static Vec3f sBlureP2RightOffset = { -18.0f, 0.0f, -7.5f }; +static Vec3f sDustVelocity = { 0.0f, 3.0f, 0.0f }; + +/** + * Run towards the player. If the player puts on the Stone Mask or burrows into a Deku + * Flower, the Real Bombchu will lose track of the player and run in a straight line. + */ +void EnRat_ChasePlayer(EnRat* this, PlayState* play) { + Player* player = GET_PLAYER(play); + Vec3f blureP1; + Vec3f blureP2; + + this->actor.speedXZ = 6.1f; + if (this->hasLostTrackOfPlayer) { + if (!(player->stateFlags3 & PLAYER_STATE3_100) && (Player_GetMask(play) != PLAYER_MASK_STONE) && + Actor_IsFacingPlayer(&this->actor, 0x3000)) { + this->hasLostTrackOfPlayer = false; + } + } else if ((player->stateFlags3 & PLAYER_STATE3_100) || (Player_GetMask(play) == PLAYER_MASK_STONE)) { + this->hasLostTrackOfPlayer = true; + } + + if (Animation_OnFrame(&this->skelAnime, 0.0f)) { + if (this->animLoopCounter != 0) { + this->animLoopCounter--; + } + + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_BOMCHU_WALK); + } + + DECR(this->timer); + + if ((this->timer == 0) && (EN_RAT_GET_TYPE(&this->actor) == EN_RAT_TYPE_DUNGEON)) { + this->timer = 30; + } + + EnRat_SpawnSmoke(this, play); + this->visualJitter = + (5.0f + (Rand_ZeroOne() * 3.0f)) * Math_SinS(((Rand_ZeroOne() * 0x200) + 0x3000) * this->timer); + + if (EN_RAT_GET_TYPE(&this->actor) == EN_RAT_TYPE_DUNGEON) { + EnRat_ActorCoordsToWorld(this, &sBlureP1Offset, &blureP1); + + EnRat_ActorCoordsToWorld(this, &sBlureP2LeftOffset, &blureP2); + EffectBlure_AddVertex(Effect_GetByIndex(this->blure1Index), &blureP1, &blureP2); + + EnRat_ActorCoordsToWorld(this, &sBlureP2RightOffset, &blureP2); + EffectBlure_AddVertex(Effect_GetByIndex(this->blure2Index), &blureP1, &blureP2); + } else if ((this->actor.floorPoly != NULL) && ((play->gameplayFrames % 4) == 0)) { + func_800B1210(play, &this->actor.world.pos, &sDustVelocity, &gZeroVec3f, 550, 50); + } + + if ((this->actor.floorPoly == NULL) && (Animation_OnFrame(&this->skelAnime, 0.0f))) { + EnRat_SpawnWaterEffects(this, play); + } + + if ((this->animLoopCounter == 0) && (Rand_ZeroOne() < 0.05f)) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_BOMCHU_AIM); + this->animLoopCounter = 5; + } + + func_800B9010(&this->actor, NA_SE_EN_BOMCHU_RUN - SFX_FLAG); + EnRat_UpdateSparkOffsets(this); +} + +void EnRat_SetupBounced(EnRat* this) { + this->actor.speedXZ = 5.0f; + this->actor.velocity.y = 8.0f; + this->actor.world.rot.y = this->actor.yawTowardsPlayer + 0x8000; + this->actor.gravity = -1.0f; + EnRat_UpdateSparkOffsets(this); + this->actor.bgCheckFlags &= ~(0x10 | 0x8 | 0x1); + this->actionFunc = EnRat_Bounced; +} + +/** + * Fly backwards until the Real Bombchu touches a wall, ceiling, or floor, then explode. + */ +void EnRat_Bounced(EnRat* this, PlayState* play) { + this->actor.shape.rot.x -= 0x700; + Math_StepToF(&this->actor.shape.yOffset, 1700.0f, 170.0f); + this->timer--; + if (this->timer == 0) { + this->timer = 30; + } + + if (this->actor.bgCheckFlags & (0x10 | 0x8 | 0x1)) { + EnRat_Explode(this, play); + } +} + +void EnRat_Explode(EnRat* this, PlayState* play) { + EnBom* bomb = (EnBom*)Actor_Spawn(&play->actorCtx, play, ACTOR_EN_BOM, this->actor.world.pos.x, + this->actor.world.pos.y, this->actor.world.pos.z, 0, 0, 0, ENBOM_0); + + if (bomb != NULL) { + bomb->timer = 0; + } + + if (EN_RAT_GET_TYPE(&this->actor) == EN_RAT_TYPE_OVERWORLD) { + Item_DropCollectibleRandom(play, &this->actor, &this->actor.world.pos, 0x100); + } + + this->actor.speedXZ = 0.0f; + this->actionFunc = EnRat_PostDetonation; +} + +/** + * If the Real Bombchu is an Overworld-type Bombchu, this will set it up to revive. + * Otherwise, it will simply kill the Bombchu. + */ +void EnRat_PostDetonation(EnRat* this, PlayState* play) { + if (EN_RAT_GET_TYPE(&this->actor) == EN_RAT_TYPE_OVERWORLD) { + EnRat_SetupRevive(this); + } else { + Actor_MarkForDeath(&this->actor); + } +} + +void EnRat_Update(Actor* thisx, PlayState* play) { + s32 pad; + EnRat* this = THIS; + + this->shouldRotateOntoSurfaces = false; + if (this->damageReaction.stunTimer == 0) { + SkelAnime_Update(&this->skelAnime); + } + + if (this->collider.base.atFlags & AT_HIT) { + this->collider.base.atFlags &= ~AT_HIT; + this->collider.base.acFlags &= ~AC_HIT; + this->collider.base.ocFlags1 &= ~OC1_HIT; + if (this->collider.base.atFlags & AT_BOUNCED) { + EnRat_SetupBounced(this); + } else { + EnRat_Explode(this, play); + return; + } + } else if (this->collider.base.acFlags & AC_HIT) { + this->collider.base.acFlags &= ~AC_HIT; + if (this->actor.colChkInfo.damageEffect == EN_RAT_DMGEFF_HOOKSHOT) { + this->damageReaction.hookedState = EN_RAT_HOOK_STARTED; + } else if (this->actor.colChkInfo.damageEffect == EN_RAT_DMGEFF_STUN) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_COMMON_FREEZE); + Actor_SetColorFilter(&this->actor, 0, 120, 0, 40); + if (this->actionFunc == EnRat_Bounced) { + this->actor.speedXZ = 0.0f; + if (this->actor.velocity.y > 0.0f) { + this->actor.velocity.y = 0.0f; + } + } else { + this->damageReaction.stunTimer = 40; + } + } else { + EnRat_Explode(this, play); + return; + } + } else if (((this->collider.base.ocFlags1 & OC1_HIT) && (((this->collider.base.oc->category == ACTORCAT_ENEMY)) || + (this->collider.base.oc->category == ACTORCAT_BOSS) || + (this->collider.base.oc->category == ACTORCAT_PLAYER))) || + ((this->actionFunc == EnRat_ChasePlayer) && (this->timer == 0))) { + this->collider.base.ocFlags1 &= ~OC1_HIT; + EnRat_Explode(this, play); + return; + } + + this->actionFunc(this, play); + + if ((this->actionFunc != EnRat_PostDetonation) && (this->actionFunc != EnRat_Revive)) { + if (this->damageReaction.stunTimer > 0) { + this->damageReaction.stunTimer--; + } else if (this->damageReaction.hookedState < 0) { + if (this->damageReaction.hookedState == EN_RAT_HOOK_STARTED) { + // The player just hit the Real Bombchu with the Hookshot. + this->damageReaction.hookedState = EN_RAT_HOOKED; + } else if ((this->actor.flags & ACTOR_FLAG_2000) != ACTOR_FLAG_2000) { + // The player has hooked the Real Bombchu for more than one frame, but + // the actor flag indicating that the Hookshot is attached is *not* set. + EnRat_Explode(this, play); + return; + } + } else if (this->actionFunc != EnRat_Bounced) { + if (this->actor.floorBgId != BGCHECK_SCENE) { + EnRat_HandleNonSceneCollision(this, play); + } + + if (!this->hasLostTrackOfPlayer) { + EnRat_ChooseDirection(this); + } + + if ((this->actionFunc != EnRat_SpottedPlayer) && !EnRat_IsTouchingSurface(this, play)) { + EnRat_Explode(this, play); + return; + } + + if (this->shouldRotateOntoSurfaces) { + EnRat_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; + } + + Actor_MoveWithoutGravity(&this->actor); + this->actor.floorHeight = this->actor.world.pos.y; + } else { + Actor_MoveWithGravity(&this->actor); + Actor_UpdateBgCheckInfo(play, &this->actor, 20.0f, 30.0f, 60.0f, 7); + } + + if (SurfaceType_IsWallDamage(&play->colCtx, this->actor.floorPoly, this->actor.floorBgId)) { + EnRat_Explode(this, play); + return; + } + + this->collider.dim.worldSphere.center.x = this->actor.world.pos.x + (this->axisUp.x * 10.0f); + this->collider.dim.worldSphere.center.y = this->actor.world.pos.y + (this->axisUp.y * 10.0f); + this->collider.dim.worldSphere.center.z = this->actor.world.pos.z + (this->axisUp.z * 10.0f); + + if (this->actionFunc != EnRat_Revive) { + if (this->damageReaction.stunTimer == 0) { + CollisionCheck_SetAT(play, &play->colChkCtx, &this->collider.base); + } + + CollisionCheck_SetAC(play, &play->colChkCtx, &this->collider.base); + CollisionCheck_SetOC(play, &play->colChkCtx, &this->collider.base); + } + + Actor_SetFocus(&this->actor, this->actor.shape.yOffset * 0.015f); + } +} + +s32 EnRat_OverrideLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, Actor* thisx) { + EnRat* this = THIS; + + if (limbIndex == REAL_BOMBCHU_LIMB_BODY) { + pos->y -= this->revivePosY; + } + + if (limbIndex == REAL_BOMBCHU_LIMB_TAIL_END) { + *dList = NULL; + } + + return false; +} + +void EnRat_PostLimbDraw(PlayState* play2, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx) { + PlayState* play = play2; + EnRat* this = THIS; + MtxF* currentMatrixState; + Vec3f* ptr; + f32 redModifier; + + if (limbIndex == REAL_BOMBCHU_LIMB_TAIL_END) { + OPEN_DISPS(play->state.gfxCtx); + + Matrix_ReplaceRotation(&play->billboardMtxF); + Matrix_MultZero(&this->smokePos); + this->smokePos.y += 15.0f; + currentMatrixState = Matrix_GetCurrent(); + + if (this->actionFunc == EnRat_ChasePlayer) { + s32 i; + + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 255, 255, 150, 255); + gDPSetEnvColor(POLY_XLU_DISP++, 255, 0, 0, 0); + Matrix_Scale(45.0f, 45.0f, 45.0f, MTXMODE_APPLY); + + for (i = 0; i < ARRAY_COUNT(this->sparkOffsets); i++) { + ptr = &this->sparkOffsets[i]; + currentMatrixState->mf[3][0] = this->smokePos.x + ptr->x; + currentMatrixState->mf[3][1] = this->smokePos.y + ptr->y; + currentMatrixState->mf[3][2] = this->smokePos.z + ptr->z; + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(play->state.gfxCtx), + G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPSegment(POLY_XLU_DISP++, 0x08, sSparkTextures[(play->gameplayFrames + i) & 3]); + gSPDisplayList(POLY_XLU_DISP++, gEffSparkDL); + } + + Matrix_Scale(1.0f / 45.0f, 1.0f / 45.0f, 1.0f / 45.0f, MTXMODE_APPLY); + currentMatrixState->mf[3][0] = this->smokePos.x; + currentMatrixState->mf[3][1] = this->smokePos.y - 15.0f; + currentMatrixState->mf[3][2] = this->smokePos.z; + } + + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_OPA_DISP++, gBombCapDL); + if (EN_RAT_GET_TYPE(&this->actor) == EN_RAT_TYPE_DUNGEON) { + redModifier = fabsf(cos_rad(this->timer * (M_PI / 30.f))); + } else { + if (this->timer >= 120) { + redModifier = fabsf(cos_rad((this->timer % 30) * (M_PI / 30.0f))); + } else if (this->timer >= 30) { + redModifier = fabsf(cos_rad((this->timer % 6) * (M_PI / 6.0f))); + } else { + redModifier = fabsf(cos_rad((this->timer % 3) * (M_PI / 3.0f))); + } + } + + gDPSetEnvColor(POLY_OPA_DISP++, (s32)((1.0f - redModifier) * 255.0f), 0, 40, 255); + gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, (s32)((1.0f - redModifier) * 255.0f), 0, 40, 255); + Matrix_RotateZYX(0x4000, 0, 0, MTXMODE_APPLY); + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_OPA_DISP++, gBombBodyDL); + + CLOSE_DISPS(play->state.gfxCtx); + } +} + +void EnRat_Draw(Actor* thisx, PlayState* play) { + EnRat* this = THIS; + + func_8012C28C(play->state.gfxCtx); + func_8012C974(play->state.gfxCtx); + func_800B8050(&this->actor, play, 0); + SkelAnime_DrawFlexOpa(play, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, + EnRat_OverrideLimbDraw, EnRat_PostLimbDraw, &this->actor); +} diff --git a/src/overlays/actors/ovl_En_Rat/z_en_rat.h b/src/overlays/actors/ovl_En_Rat/z_en_rat.h index c3ad7eedc..6dd51d10a 100644 --- a/src/overlays/actors/ovl_En_Rat/z_en_rat.h +++ b/src/overlays/actors/ovl_En_Rat/z_en_rat.h @@ -2,12 +2,57 @@ #define Z_EN_RAT_H #include "global.h" +#include "objects/object_rat/object_rat.h" + +#define EN_RAT_IS_OVERWORLD_TYPE(thisx) ((thisx)->params & 0x8000) +#define EN_RAT_GET_TYPE(thisx) ((thisx)->params) +#define EN_RAT_GET_ATTACK_RANGE(thisx) ((thisx)->params & 0xFF) + +/** + * There are many differences between the two types of Real Bombchu: + * - Dungeon-type don't respawn, while Overworld-type do. + * - Dungeon-type leave a blure trail behind them as they chase the player, + * while Overworld-type spawn dust around themselves instead. + * - Dungeon-type won't detonate automatically, while Overworld-type will + * detonate after 150 frames of chasing the player. + * - So long as EN_RAT_GET_ATTACK_RANGE returns something other than 0 or 255, + * Dungeon-type have 1/5th of the attack range compared to Overworld-type. + * - Dungeon-type do not drop items upon defeat, while Overworld-type do. + */ +typedef enum { + /* 0 */ EN_RAT_TYPE_DUNGEON, + /* 1 */ EN_RAT_TYPE_OVERWORLD, +} EnRatType; struct EnRat; +typedef void (*EnRatActionFunc)(struct EnRat*, PlayState*); + typedef struct EnRat { /* 0x000 */ Actor actor; - /* 0x144 */ char unk_144[0x17C]; + /* 0x144 */ SkelAnime skelAnime; + /* 0x188 */ EnRatActionFunc actionFunc; + /* 0x18C */ u8 hasLostTrackOfPlayer; + /* 0x18D */ u8 shouldRotateOntoSurfaces; + /* 0x18E */ s16 animLoopCounter; + /* 0x190 */ s16 timer; // Used for both exploding and reviving + /* 0x192 */ union { + s16 stunTimer; + s16 hookedState; + } damageReaction; + /* 0x194 */ Vec3s jointTable[REAL_BOMBCHU_LIMB_MAX]; + /* 0x1D0 */ Vec3s morphTable[REAL_BOMBCHU_LIMB_MAX]; + /* 0x20C */ Vec3f axisForwards; + /* 0x218 */ Vec3f axisUp; + /* 0x224 */ Vec3f axisLeft; + /* 0x230 */ Vec3f smokePos; + /* 0x23C */ Vec3f sparkOffsets[2]; + /* 0x254 */ f32 visualJitter; + /* 0x258 */ f32 attackRange; + /* 0x25C */ f32 revivePosY; + /* 0x260 */ s32 blure1Index; + /* 0x264 */ s32 blure2Index; + /* 0x268 */ ColliderSphere collider; } EnRat; // size = 0x2C0 extern const ActorInit En_Rat_InitVars; diff --git a/src/overlays/actors/ovl_En_Rd/z_en_rd.c b/src/overlays/actors/ovl_En_Rd/z_en_rd.c index 0326c13b7..1f4c10281 100644 --- a/src/overlays/actors/ovl_En_Rd/z_en_rd.c +++ b/src/overlays/actors/ovl_En_Rd/z_en_rd.c @@ -23,50 +23,51 @@ */ #include "z_en_rd.h" +#include "z64rumble.h" #include "objects/object_rd/object_rd.h" #define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_4 | ACTOR_FLAG_10 | ACTOR_FLAG_400) #define THIS ((EnRd*)thisx) -void EnRd_Init(Actor* thisx, GlobalContext* globalCtx); -void EnRd_Destroy(Actor* thisx, GlobalContext* globalCtx); -void EnRd_Update(Actor* thisx, GlobalContext* globalCtx); -void EnRd_Draw(Actor* thisx, GlobalContext* globalCtx); +void EnRd_Init(Actor* thisx, PlayState* play); +void EnRd_Destroy(Actor* thisx, PlayState* play); +void EnRd_Update(Actor* thisx, PlayState* play); +void EnRd_Draw(Actor* thisx, PlayState* play); -s32 EnRd_ShouldNotDance(GlobalContext* globalCtx); +s32 EnRd_ShouldNotDance(PlayState* play); void EnRd_SetupIdle(EnRd* this); -void EnRd_Idle(EnRd* this, GlobalContext* globalCtx); +void EnRd_Idle(EnRd* this, PlayState* play); void EnRd_SetupSquattingDance(EnRd* this); -void EnRd_SquattingDance(EnRd* this, GlobalContext* globalCtx); +void EnRd_SquattingDance(EnRd* this, PlayState* play); void EnRd_SetupClappingDance(EnRd* this); -void EnRd_ClappingDance(EnRd* this, GlobalContext* globalCtx); -void EnRd_EndClappingOrSquattingDanceWhenPlayerIsClose(EnRd* this, GlobalContext* globalCtx); +void EnRd_ClappingDance(EnRd* this, PlayState* play); +void EnRd_EndClappingOrSquattingDanceWhenPlayerIsClose(EnRd* this, PlayState* play); void EnRd_SetupPirouette(EnRd* this); -void EnRd_Pirouette(EnRd* this, GlobalContext* globalCtx); -void EnRd_EndPirouetteWhenPlayerIsClose(EnRd* this, GlobalContext* globalCtx); +void EnRd_Pirouette(EnRd* this, PlayState* play); +void EnRd_EndPirouetteWhenPlayerIsClose(EnRd* this, PlayState* play); 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_RiseFromCoffin(EnRd* this, PlayState* play); +void EnRd_WalkToPlayer(EnRd* this, PlayState* play); +void EnRd_SetupWalkToHome(EnRd* this, PlayState* play); +void EnRd_WalkToHome(EnRd* this, PlayState* play); void EnRd_SetupWalkToParent(EnRd* this); -void EnRd_WalkToParent(EnRd* this, GlobalContext* globalCtx); +void EnRd_WalkToParent(EnRd* this, PlayState* play); void EnRd_SetupGrab(EnRd* this); -void EnRd_Grab(EnRd* this, GlobalContext* globalCtx); +void EnRd_Grab(EnRd* this, PlayState* play); void EnRd_SetupAttemptPlayerFreeze(EnRd* this); -void EnRd_AttemptPlayerFreeze(EnRd* this, GlobalContext* globalCtx); +void EnRd_AttemptPlayerFreeze(EnRd* this, PlayState* play); void EnRd_SetupGrabFail(EnRd* this); -void EnRd_GrabFail(EnRd* this, GlobalContext* globalCtx); +void EnRd_GrabFail(EnRd* this, PlayState* play); void EnRd_SetupTurnAwayAndShakeHead(EnRd* this); -void EnRd_TurnAwayAndShakeHead(EnRd* this, GlobalContext* globalCtx); +void EnRd_TurnAwayAndShakeHead(EnRd* this, PlayState* play); void EnRd_SetupStandUp(EnRd* this); -void EnRd_StandUp(EnRd* this, GlobalContext* globalCtx); +void EnRd_StandUp(EnRd* this, PlayState* play); 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); +void EnRd_Crouch(EnRd* this, PlayState* play); +void EnRd_Damage(EnRd* this, PlayState* play); +void EnRd_Dead(EnRd* this, PlayState* play); +void EnRd_Stunned(EnRd* this, PlayState* play); typedef enum { /* 0 */ EN_RD_ACTION_IDLE, @@ -182,7 +183,7 @@ static InitChainEntry sInitChain[] = { ICHAIN_F32_DIV1000(gravity, -3500, ICHAIN_STOP), }; -void EnRd_Init(Actor* thisx, GlobalContext* globalCtx) { +void EnRd_Init(Actor* thisx, PlayState* play) { EnRd* this = THIS; s32 pad; @@ -206,20 +207,20 @@ void EnRd_Init(Actor* thisx, GlobalContext* globalCtx) { } if (EN_RD_GET_TYPE(&this->actor) > EN_RD_TYPE_GIBDO) { - SkelAnime_InitFlex(globalCtx, &this->skelAnime, &gRedeadSkel, &gGibdoRedeadIdleAnim, this->jointTable, + SkelAnime_InitFlex(play, &this->skelAnime, &gRedeadSkel, &gGibdoRedeadIdleAnim, this->jointTable, this->morphTable, REDEAD_LIMB_MAX); } else { - SkelAnime_InitFlex(globalCtx, &this->skelAnime, &gGibdoSkel, &gGibdoRedeadIdleAnim, this->jointTable, + SkelAnime_InitFlex(play, &this->skelAnime, &gGibdoSkel, &gGibdoRedeadIdleAnim, this->jointTable, this->morphTable, REDEAD_LIMB_MAX); } - Collider_InitCylinder(globalCtx, &this->collider); - Collider_SetCylinder(globalCtx, &this->collider, &this->actor, &sCylinderInit); + Collider_InitCylinder(play, &this->collider); + Collider_SetCylinder(play, &this->collider, &this->actor, &sCylinderInit); 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)) { + if (!EnRd_ShouldNotDance(play)) { EnRd_SetupSquattingDance(this); } else { this->actor.hintId = 0x2A; @@ -229,7 +230,7 @@ void EnRd_Init(Actor* thisx, GlobalContext* globalCtx) { break; case EN_RD_TYPE_CLAPPING_DANCE: - if (!EnRd_ShouldNotDance(globalCtx)) { + if (!EnRd_ShouldNotDance(play)) { EnRd_SetupClappingDance(this); } else { this->actor.hintId = 0x2A; @@ -239,7 +240,7 @@ void EnRd_Init(Actor* thisx, GlobalContext* globalCtx) { break; case EN_RD_TYPE_PIROUETTE: - if (!EnRd_ShouldNotDance(globalCtx)) { + if (!EnRd_ShouldNotDance(play)) { EnRd_SetupPirouette(this); } else { this->actor.hintId = 0x2A; @@ -271,19 +272,19 @@ void EnRd_Init(Actor* thisx, GlobalContext* globalCtx) { 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, + Actor_SpawnAsChild(&play->actorCtx, &this->actor, play, 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, 0xFF4B); } } -void EnRd_Destroy(Actor* thisx, GlobalContext* globalCtx) { +void EnRd_Destroy(Actor* thisx, PlayState* play) { EnRd* this = THIS; if (gSaveContext.sunsSongState != SUNSSONG_INACTIVE) { gSaveContext.sunsSongState = SUNSSONG_INACTIVE; } - Collider_DestroyCylinder(globalCtx, &this->collider); + Collider_DestroyCylinder(play, &this->collider); } /** @@ -295,8 +296,8 @@ void EnRd_Destroy(Actor* thisx, GlobalContext* globalCtx) { * 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; +void EnRd_UpdateParentForOtherRedeads(PlayState* play, Actor* thisx, s32 setParent) { + Actor* enemyIterator = play->actorCtx.actorLists[ACTORCAT_ENEMY].first; while (enemyIterator != NULL) { if ((enemyIterator->id != ACTOR_EN_RD) || (enemyIterator == thisx) || @@ -321,9 +322,9 @@ void EnRd_UpdateParentForOtherRedeads(GlobalContext* globalCtx, Actor* thisx, s3 * 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)) { +s32 EnRd_ShouldNotDance(PlayState* play) { + if ((Player_GetMask(play) == PLAYER_MASK_GIBDO) || (Player_GetMask(play) == PLAYER_MASK_CAPTAIN) || + (Player_GetMask(play) == PLAYER_MASK_GARO)) { return false; } @@ -335,12 +336,12 @@ s32 EnRd_ShouldNotDance(GlobalContext* globalCtx) { * 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) { +void EnRd_SetupDanceIfConditionsMet(EnRd* this, PlayState* play) { 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)) { + if (!EnRd_ShouldNotDance(play)) { this->setupDanceFunc(this); } } @@ -360,7 +361,7 @@ void EnRd_SetupIdle(EnRd* this) { this->actionFunc = EnRd_Idle; } -void EnRd_Idle(EnRd* this, GlobalContext* globalCtx) { +void EnRd_Idle(EnRd* this, PlayState* play) { SkelAnime_Update(&this->skelAnime); Math_SmoothStepToS(&this->headYRotation, 0, 1, 100, 0); Math_SmoothStepToS(&this->upperBodyYRotation, 0, 1, 100, 0); @@ -399,7 +400,7 @@ void EnRd_Idle(EnRd* this, GlobalContext* globalCtx) { } this->isMourning = false; - if ((this->actor.xzDistToPlayer <= 150.0f) && func_800B715C(globalCtx)) { + if ((this->actor.xzDistToPlayer <= 150.0f) && func_800B715C(play)) { if ((EN_RD_GET_TYPE(&this->actor) != EN_RD_TYPE_CRYING) && (!this->isMourning)) { EnRd_SetupAttemptPlayerFreeze(this); } else { @@ -408,7 +409,7 @@ void EnRd_Idle(EnRd* this, GlobalContext* globalCtx) { } } - if ((globalCtx->gameplayFrames & 0x5F) == 0) { + if ((play->gameplayFrames & 0x5F) == 0) { Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_REDEAD_CRY); } } @@ -423,7 +424,7 @@ void EnRd_SetupSquattingDance(EnRd* this) { this->actionFunc = EnRd_SquattingDance; } -void EnRd_SquattingDance(EnRd* this, GlobalContext* globalCtx) { +void EnRd_SquattingDance(EnRd* this, PlayState* play) { SkelAnime_Update(&this->skelAnime); Math_SmoothStepToS(&this->headYRotation, 0, 1, 100, 0); Math_SmoothStepToS(&this->upperBodyYRotation, 0, 1, 100, 0); @@ -433,17 +434,17 @@ void EnRd_SquattingDance(EnRd* this, GlobalContext* globalCtx) { } this->isMourning = false; - if ((this->actor.xzDistToPlayer <= 150.0f) && EnRd_ShouldNotDance(globalCtx) && func_800B715C(globalCtx)) { + if ((this->actor.xzDistToPlayer <= 150.0f) && EnRd_ShouldNotDance(play) && func_800B715C(play)) { if (EN_RD_GET_TYPE(&this->actor) == EN_RD_TYPE_GIBDO) { this->actor.hintId = 0x2D; } else { this->actor.hintId = 0x2A; } - Animation_Change(&this->skelAnime, &gGibdoRedeadLookBackAnim, 0.0f, 0.0f, 19.0f, 2, -10.0f); + Animation_Change(&this->skelAnime, &gGibdoRedeadLookBackAnim, 0.0f, 0.0f, 19.0f, ANIMMODE_ONCE, -10.0f); this->actionFunc = EnRd_EndClappingOrSquattingDanceWhenPlayerIsClose; } - if (EnRd_ShouldNotDance(globalCtx)) { + if (EnRd_ShouldNotDance(play)) { if (EN_RD_GET_TYPE(&this->actor) == EN_RD_TYPE_GIBDO) { this->actor.hintId = 0x2D; } else { @@ -452,7 +453,7 @@ void EnRd_SquattingDance(EnRd* this, GlobalContext* globalCtx) { EnRd_SetupIdle(this); } - if ((globalCtx->gameplayFrames & 0x5F) == 0) { + if ((play->gameplayFrames & 0x5F) == 0) { Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_REDEAD_CRY); } } @@ -467,7 +468,7 @@ void EnRd_SetupClappingDance(EnRd* this) { this->actionFunc = EnRd_ClappingDance; } -void EnRd_ClappingDance(EnRd* this, GlobalContext* globalCtx) { +void EnRd_ClappingDance(EnRd* this, PlayState* play) { SkelAnime_Update(&this->skelAnime); Math_SmoothStepToS(&this->headYRotation, 0, 1, 100, 0); Math_SmoothStepToS(&this->upperBodyYRotation, 0, 1, 100, 0); @@ -477,17 +478,17 @@ void EnRd_ClappingDance(EnRd* this, GlobalContext* globalCtx) { } this->isMourning = false; - if ((this->actor.xzDistToPlayer <= 150.0f) && EnRd_ShouldNotDance(globalCtx) && func_800B715C(globalCtx)) { + if ((this->actor.xzDistToPlayer <= 150.0f) && EnRd_ShouldNotDance(play) && func_800B715C(play)) { if (EN_RD_GET_TYPE(&this->actor) == EN_RD_TYPE_GIBDO) { this->actor.hintId = 0x2D; } else { this->actor.hintId = 0x2A; } - Animation_Change(&this->skelAnime, &gGibdoRedeadLookBackAnim, 0.0f, 0.0f, 19.0f, 2, -10.0f); + Animation_Change(&this->skelAnime, &gGibdoRedeadLookBackAnim, 0.0f, 0.0f, 19.0f, ANIMMODE_ONCE, -10.0f); this->actionFunc = EnRd_EndClappingOrSquattingDanceWhenPlayerIsClose; } - if (EnRd_ShouldNotDance(globalCtx)) { + if (EnRd_ShouldNotDance(play)) { if (EN_RD_GET_TYPE(&this->actor) == EN_RD_TYPE_GIBDO) { this->actor.hintId = 0x2D; } else { @@ -496,14 +497,14 @@ void EnRd_ClappingDance(EnRd* this, GlobalContext* globalCtx) { EnRd_SetupIdle(this); } - if ((globalCtx->gameplayFrames & 0x5F) == 0) { + if ((play->gameplayFrames & 0x5F) == 0) { Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_REDEAD_CRY); } } -void EnRd_EndClappingOrSquattingDanceWhenPlayerIsClose(EnRd* this, GlobalContext* globalCtx) { +void EnRd_EndClappingOrSquattingDanceWhenPlayerIsClose(EnRd* this, PlayState* play) { SkelAnime_Update(&this->skelAnime); - if ((globalCtx->gameplayFrames & 0x5F) == 0) { + if ((play->gameplayFrames & 0x5F) == 0) { Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_REDEAD_CRY); } @@ -528,7 +529,7 @@ void EnRd_SetupPirouette(EnRd* this) { this->actionFunc = EnRd_Pirouette; } -void EnRd_Pirouette(EnRd* this, GlobalContext* globalCtx) { +void EnRd_Pirouette(EnRd* this, PlayState* play) { SkelAnime_Update(&this->skelAnime); Math_SmoothStepToS(&this->headYRotation, 0, 1, 100, 0); Math_SmoothStepToS(&this->upperBodyYRotation, 0, 1, 100, 0); @@ -538,7 +539,7 @@ void EnRd_Pirouette(EnRd* this, GlobalContext* globalCtx) { } this->isMourning = false; - if ((this->actor.xzDistToPlayer <= 150.0f) && EnRd_ShouldNotDance(globalCtx) && func_800B715C(globalCtx)) { + if ((this->actor.xzDistToPlayer <= 150.0f) && EnRd_ShouldNotDance(play) && func_800B715C(play)) { if (EN_RD_GET_TYPE(&this->actor) == EN_RD_TYPE_GIBDO) { this->actor.hintId = 0x2D; } else { @@ -547,7 +548,7 @@ void EnRd_Pirouette(EnRd* this, GlobalContext* globalCtx) { this->actionFunc = EnRd_EndPirouetteWhenPlayerIsClose; } - if (EnRd_ShouldNotDance(globalCtx)) { + if (EnRd_ShouldNotDance(play)) { if (EN_RD_GET_TYPE(&this->actor) == EN_RD_TYPE_GIBDO) { this->actor.hintId = 0x2D; } else { @@ -556,7 +557,7 @@ void EnRd_Pirouette(EnRd* this, GlobalContext* globalCtx) { EnRd_SetupIdle(this); } - if ((globalCtx->gameplayFrames & 0x5F) == 0) { + if ((play->gameplayFrames & 0x5F) == 0) { Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_REDEAD_CRY); } @@ -570,9 +571,9 @@ void EnRd_Pirouette(EnRd* this, GlobalContext* globalCtx) { this->actor.shape.rot.y = this->actor.world.rot.y; } -void EnRd_EndPirouetteWhenPlayerIsClose(EnRd* this, GlobalContext* globalCtx) { +void EnRd_EndPirouetteWhenPlayerIsClose(EnRd* this, PlayState* play) { SkelAnime_Update(&this->skelAnime); - if ((globalCtx->gameplayFrames & 0x5F) == 0) { + if ((play->gameplayFrames & 0x5F) == 0) { Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_REDEAD_CRY); } @@ -581,7 +582,7 @@ void EnRd_EndPirouetteWhenPlayerIsClose(EnRd* this, GlobalContext* globalCtx) { this->pirouetteRotationalVelocity -= 0x64; if ((this->pirouetteRotationalVelocity < 0x834) && (this->pirouetteRotationalVelocity >= 0x7D0)) { - Animation_Change(&this->skelAnime, &gGibdoRedeadLookBackAnim, 0.0f, 0.0f, 19.0f, 2, -10.0f); + Animation_Change(&this->skelAnime, &gGibdoRedeadLookBackAnim, 0.0f, 0.0f, 19.0f, ANIMMODE_ONCE, -10.0f); } else if (this->pirouetteRotationalVelocity < 0x3E8) { if ((EN_RD_GET_TYPE(&this->actor) != EN_RD_TYPE_CRYING) && (!this->isMourning)) { EnRd_SetupAttemptPlayerFreeze(this); @@ -593,7 +594,7 @@ void EnRd_EndPirouetteWhenPlayerIsClose(EnRd* this, GlobalContext* globalCtx) { void EnRd_SetupRiseFromCoffin(EnRd* this) { Animation_Change(&this->skelAnime, &gGibdoRedeadIdleAnim, 0.0f, 0.0f, Animation_GetLastFrame(&gGibdoRedeadIdleAnim), - 0, -6.0f); + ANIMMODE_LOOP, -6.0f); this->action = EN_RD_ACTION_RISING_FROM_COFFIN; this->coffinRiseForwardAccelTimer = 6; this->actor.shape.rot.x = -0x4000; @@ -603,7 +604,7 @@ void EnRd_SetupRiseFromCoffin(EnRd* this) { this->actionFunc = EnRd_RiseFromCoffin; } -void EnRd_RiseFromCoffin(EnRd* this, GlobalContext* globalCtx) { +void EnRd_RiseFromCoffin(EnRd* this, PlayState* play) { 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) { @@ -626,17 +627,17 @@ void EnRd_RiseFromCoffin(EnRd* this, GlobalContext* globalCtx) { } } -void EnRd_SetupWalkToPlayer(EnRd* this, GlobalContext* globalCtx) { +void EnRd_SetupWalkToPlayer(EnRd* this, PlayState* play) { f32 frameCount = Animation_GetLastFrame(&gGibdoRedeadWalkAnim); - Animation_Change(&this->skelAnime, &gGibdoRedeadWalkAnim, 1.0f, 4.0f, frameCount, 1, -4.0f); + Animation_Change(&this->skelAnime, &gGibdoRedeadWalkAnim, 1.0f, 4.0f, frameCount, ANIMMODE_LOOP_INTERP, -4.0f); this->actor.speedXZ = 0.4f; this->action = EN_RD_ACTION_WALKING_TO_PLAYER_OR_RELEASING_GRAB; this->actionFunc = EnRd_WalkToPlayer; } -void EnRd_WalkToPlayer(EnRd* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); +void EnRd_WalkToPlayer(EnRd* this, PlayState* play) { + Player* player = GET_PLAYER(play); s32 pad; s16 yaw = ((this->actor.yawTowardsPlayer - this->actor.shape.rot.y) - this->headYRotation) - this->upperBodyYRotation; @@ -649,7 +650,7 @@ void EnRd_WalkToPlayer(EnRd* this, GlobalContext* globalCtx) { SkelAnime_Update(&this->skelAnime); if (Actor_DistanceToPoint(&player->actor, &this->actor.home.pos) >= 150.0f) { - EnRd_SetupWalkToHome(this, globalCtx); + EnRd_SetupWalkToHome(this, play); } if ((ABS_ALT(yaw) < 0x1554) && (Actor_DistanceBetweenActors(&this->actor, &player->actor) <= 150.0f)) { @@ -658,15 +659,15 @@ void EnRd_WalkToPlayer(EnRd* this, GlobalContext* globalCtx) { 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); + func_80123E90(play, &this->actor); + GET_PLAYER(play)->unk_A78 = &this->actor; + Rumble_Request(this->actor.xzDistToPlayer, 255, 20, 150); } this->playerStunWaitTimer = 60; Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_REDEAD_AIM); } } else { - EnRd_SetupWalkToHome(this, globalCtx); + EnRd_SetupWalkToHome(this, play); } } @@ -683,9 +684,9 @@ void EnRd_WalkToPlayer(EnRd* this, GlobalContext* globalCtx) { // do so. It will appear to take damage and shake its head side-to-side. EnRd_SetupGrabFail(this); } else { - EnRd_SetupWalkToHome(this, globalCtx); + EnRd_SetupWalkToHome(this, play); } - } else if (globalCtx->grabPlayer(globalCtx, player)) { + } else if (play->grabPlayer(play, player)) { this->actor.flags &= ~ACTOR_FLAG_1; EnRd_SetupGrab(this); } @@ -699,20 +700,20 @@ void EnRd_WalkToPlayer(EnRd* this, GlobalContext* globalCtx) { 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) == 0) { + } else if ((play->gameplayFrames & 0x5F) == 0) { Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_REDEAD_CRY); } } -void EnRd_SetupWalkToHome(EnRd* this, GlobalContext* globalCtx) { +void EnRd_SetupWalkToHome(EnRd* this, PlayState* play) { Animation_Change(&this->skelAnime, &gGibdoRedeadWalkAnim, 0.5f, 0.0f, Animation_GetLastFrame(&gGibdoRedeadWalkAnim), - 1, -4.0f); + ANIMMODE_LOOP_INTERP, -4.0f); this->action = EN_RD_ACTION_WALKING_TO_HOME; this->actionFunc = EnRd_WalkToHome; } -void EnRd_WalkToHome(EnRd* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); +void EnRd_WalkToHome(EnRd* this, PlayState* play) { + Player* player = GET_PLAYER(play); s32 pad; s16 sp36 = Actor_YawToPoint(&this->actor, &this->actor.home.pos); @@ -739,7 +740,7 @@ void EnRd_WalkToHome(EnRd* this, GlobalContext* globalCtx) { (player->transformation != PLAYER_FORM_DEKU) && (Actor_DistanceToPoint(&player->actor, &this->actor.home.pos) < 150.0f)) { this->actor.targetMode = 0; - EnRd_SetupWalkToPlayer(this, globalCtx); + EnRd_SetupWalkToPlayer(this, play); } else if (EN_RD_GET_TYPE(&this->actor) > EN_RD_TYPE_DOES_NOT_MOURN_IF_WALKING) { if (this->actor.parent != NULL) { EnRd_SetupWalkToParent(this); @@ -750,7 +751,7 @@ void EnRd_WalkToHome(EnRd* this, GlobalContext* globalCtx) { 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) == 0) { + } else if ((play->gameplayFrames & 0x5F) == 0) { Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_REDEAD_CRY); } } @@ -758,7 +759,7 @@ void EnRd_WalkToHome(EnRd* this, GlobalContext* globalCtx) { void EnRd_SetupWalkToParent(EnRd* this) { f32 frameCount = Animation_GetLastFrame(&gGibdoRedeadWalkAnim); - Animation_Change(&this->skelAnime, &gGibdoRedeadWalkAnim, 0.5f, 0.0f, frameCount, 1, -4.0f); + Animation_Change(&this->skelAnime, &gGibdoRedeadWalkAnim, 0.5f, 0.0f, frameCount, ANIMMODE_LOOP_INTERP, -4.0f); this->action = EN_RD_ACTION_WALKING_TO_PARENT; this->isMourning = true; this->actionFunc = EnRd_WalkToParent; @@ -770,7 +771,7 @@ void EnRd_SetupWalkToParent(EnRd* this) { * these Redeads walk over to the corpse and stand near until it begins to * fade away. */ -void EnRd_WalkToParent(EnRd* this, GlobalContext* globalCtx) { +void EnRd_WalkToParent(EnRd* this, PlayState* play) { s32 pad; s16 yaw; Vec3f parentPos; @@ -793,7 +794,7 @@ void EnRd_WalkToParent(EnRd* this, GlobalContext* globalCtx) { Math_SmoothStepToS(&this->headYRotation, 0, 1, 100, 0); Math_SmoothStepToS(&this->upperBodyYRotation, 0, 1, 100, 0); } else { - EnRd_SetupWalkToPlayer(this, globalCtx); + EnRd_SetupWalkToPlayer(this, play); } this->actor.world.rot.y = this->actor.shape.rot.y; @@ -801,7 +802,7 @@ void EnRd_WalkToParent(EnRd* this, GlobalContext* globalCtx) { 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) == 0) { + } else if ((play->gameplayFrames & 0x5F) == 0) { Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_REDEAD_CRY); } } @@ -816,8 +817,8 @@ void EnRd_SetupGrab(EnRd* this) { this->actionFunc = EnRd_Grab; } -void EnRd_Grab(EnRd* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); +void EnRd_Grab(EnRd* this, PlayState* play) { + Player* player = GET_PLAYER(play); s32 pad; if (SkelAnime_Update(&this->skelAnime)) { @@ -828,8 +829,8 @@ void EnRd_Grab(EnRd* this, GlobalContext* globalCtx) { 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); + play->damagePlayer(play, -8); + Rumble_Request(this->actor.xzDistToPlayer, 255, 1, 12); this->grabDamageTimer = 20; case EN_RD_GRAB_START: @@ -843,7 +844,7 @@ void EnRd_Grab(EnRd* this, GlobalContext* globalCtx) { player->unk_AE8 = 100; } Animation_Change(&this->skelAnime, &gGibdoRedeadGrabEndAnim, 0.5f, 0.0f, - Animation_GetLastFrame(&gGibdoRedeadGrabEndAnim), 3, 0.0f); + Animation_GetLastFrame(&gGibdoRedeadGrabEndAnim), ANIMMODE_ONCE_INTERP, 0.0f); this->grabState++; this->action = EN_RD_ACTION_WALKING_TO_PLAYER_OR_RELEASING_GRAB; break; @@ -876,8 +877,8 @@ void EnRd_Grab(EnRd* this, GlobalContext* globalCtx) { this->grabDamageTimer--; if (this->grabDamageTimer == 0) { - globalCtx->damagePlayer(globalCtx, -8); - func_8013ECE0(this->actor.xzDistToPlayer, 240, 1, 12); + play->damagePlayer(play, -8); + Rumble_Request(this->actor.xzDistToPlayer, 240, 1, 12); this->grabDamageTimer = 20; func_800B8E58(player, player->ageProperties->unk_92 + NA_SE_VO_LI_DAMAGE_S); } @@ -897,31 +898,31 @@ void EnRd_Grab(EnRd* this, GlobalContext* globalCtx) { this->actor.flags |= ACTOR_FLAG_1; this->playerStunWaitTimer = 10; this->grabWaitTimer = 15; - EnRd_SetupWalkToPlayer(this, globalCtx); + EnRd_SetupWalkToPlayer(this, play); break; } } void EnRd_SetupAttemptPlayerFreeze(EnRd* this) { Animation_Change(&this->skelAnime, &gGibdoRedeadLookBackAnim, 0.0f, 0.0f, - Animation_GetLastFrame(&gGibdoRedeadLookBackAnim), 2, 0.0f); + Animation_GetLastFrame(&gGibdoRedeadLookBackAnim), ANIMMODE_ONCE, 0.0f); this->action = EN_RD_ACTION_ATTEMPTING_PLAYER_STUN; this->actionFunc = EnRd_AttemptPlayerFreeze; } -void EnRd_AttemptPlayerFreeze(EnRd* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); +void EnRd_AttemptPlayerFreeze(EnRd* this, PlayState* play) { + Player* player = GET_PLAYER(play); s16 yaw = ((this->actor.yawTowardsPlayer - this->actor.shape.rot.y) - this->headYRotation) - this->upperBodyYRotation; 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); + Rumble_Request(this->actor.xzDistToPlayer, 255, 20, 150); + func_80123E90(play, &this->actor); } Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_REDEAD_AIM); - EnRd_SetupWalkToPlayer(this, globalCtx); + EnRd_SetupWalkToPlayer(this, play); } } @@ -934,7 +935,7 @@ void EnRd_SetupGrabFail(EnRd* this) { this->actionFunc = EnRd_GrabFail; } -void EnRd_GrabFail(EnRd* this, GlobalContext* globalCtx) { +void EnRd_GrabFail(EnRd* this, PlayState* play) { if (this->actor.speedXZ < 0.0f) { this->actor.speedXZ += 0.15f; } @@ -951,17 +952,17 @@ void EnRd_GrabFail(EnRd* this, GlobalContext* globalCtx) { void EnRd_SetupTurnAwayAndShakeHead(EnRd* this) { f32 frameCount = Animation_GetLastFrame(&gGibdoRedeadWalkAnim); - Animation_Change(&this->skelAnime, &gGibdoRedeadWalkAnim, 0.5f, 0.0f, frameCount, 1, -4.0f); + Animation_Change(&this->skelAnime, &gGibdoRedeadWalkAnim, 0.5f, 0.0f, frameCount, ANIMMODE_LOOP_INTERP, -4.0f); this->action = EN_RD_ACTION_TURNING_AWAY_AND_SHAKING_HEAD; this->headShakeTimer = 0; this->actionFunc = EnRd_TurnAwayAndShakeHead; } -void EnRd_TurnAwayAndShakeHead(EnRd* this, GlobalContext* globalCtx) { +void EnRd_TurnAwayAndShakeHead(EnRd* this, PlayState* play) { Math_SmoothStepToS(&this->actor.world.rot.y, BINANG_ROT180(this->actor.yawTowardsPlayer), 5, 3500, 200); this->actor.shape.rot.y = this->actor.world.rot.y; if (this->headShakeTimer > 60) { - EnRd_SetupWalkToHome(this, globalCtx); + EnRd_SetupWalkToHome(this, play); this->headShakeTimer = 0; } else { this->headYRotation = Math_SinS(this->headShakeTimer * 4000) * (0x256F * ((60 - this->headShakeTimer) / 60.0f)); @@ -976,7 +977,7 @@ void EnRd_SetupStandUp(EnRd* this) { this->actionFunc = EnRd_StandUp; } -void EnRd_StandUp(EnRd* this, GlobalContext* globalCtx) { +void EnRd_StandUp(EnRd* this, PlayState* play) { if (SkelAnime_Update(&this->skelAnime)) { if (this->actor.parent != NULL) { EnRd_SetupWalkToParent(this); @@ -988,12 +989,12 @@ void EnRd_StandUp(EnRd* this, GlobalContext* globalCtx) { void EnRd_SetupCrouch(EnRd* this) { Animation_Change(&this->skelAnime, &gGibdoRedeadStandUpAnim, -1.0f, - Animation_GetLastFrame(&gGibdoRedeadStandUpAnim), 0.0f, 2, -4.0f); + Animation_GetLastFrame(&gGibdoRedeadStandUpAnim), 0.0f, ANIMMODE_ONCE, -4.0f); this->action = EN_RD_ACTION_CROUCHING; this->actionFunc = EnRd_Crouch; } -void EnRd_Crouch(EnRd* this, GlobalContext* globalCtx) { +void EnRd_Crouch(EnRd* this, PlayState* play) { if (SkelAnime_Update(&this->skelAnime)) { EnRd_SetupIdle(this); } @@ -1012,8 +1013,8 @@ void EnRd_SetupDamage(EnRd* this) { this->actionFunc = EnRd_Damage; } -void EnRd_Damage(EnRd* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); +void EnRd_Damage(EnRd* this, PlayState* play) { + Player* player = GET_PLAYER(play); if (this->actor.speedXZ < 0.0f) { this->actor.speedXZ += 0.15f; @@ -1028,9 +1029,9 @@ void EnRd_Damage(EnRd* this, GlobalContext* globalCtx) { if (this->actor.parent != NULL) { EnRd_SetupWalkToParent(this); } else if (Actor_DistanceToPoint(&player->actor, &this->actor.home.pos) >= 150.0f) { - EnRd_SetupWalkToHome(this, globalCtx); + EnRd_SetupWalkToHome(this, play); } else { - EnRd_SetupWalkToPlayer(this, globalCtx); + EnRd_SetupWalkToPlayer(this, play); } this->unk_3F1 = -1; } @@ -1046,9 +1047,9 @@ void EnRd_SetupDead(EnRd* this) { this->actionFunc = EnRd_Dead; } -void EnRd_Dead(EnRd* this, GlobalContext* globalCtx) { +void EnRd_Dead(EnRd* this, PlayState* play) { if (this->actor.category != ACTORCAT_PROP) { - func_800BC154(globalCtx, &globalCtx->actorCtx, &this->actor, ACTORCAT_PROP); + func_800BC154(play, &play->actorCtx, &this->actor, ACTORCAT_PROP); } Math_SmoothStepToS(&this->headYRotation, 0, 1, 2000, 0); @@ -1056,13 +1057,13 @@ void EnRd_Dead(EnRd* this, GlobalContext* globalCtx) { if (SkelAnime_Update(&this->skelAnime)) { if (this->deathTimer == 0) { - if (!Flags_GetSwitch(globalCtx, EN_RD_GET_SWITCH_FLAG(this))) { - Flags_SetSwitch(globalCtx, EN_RD_GET_SWITCH_FLAG(this)); + if (!Flags_GetSwitch(play, EN_RD_GET_SWITCH_FLAG(this))) { + Flags_SetSwitch(play, EN_RD_GET_SWITCH_FLAG(this)); } if (this->alpha != 0) { if (this->alpha == 180) { - EnRd_UpdateParentForOtherRedeads(globalCtx, &this->actor, false); + EnRd_UpdateParentForOtherRedeads(play, &this->actor, false); } this->actor.scale.y -= (75.0f / 1000000.0f); this->alpha -= 5; @@ -1095,7 +1096,7 @@ void EnRd_SetupStunned(EnRd* this) { this->actionFunc = EnRd_Stunned; } -void EnRd_Stunned(EnRd* this, GlobalContext* globalCtx) { +void EnRd_Stunned(EnRd* this, PlayState* play) { if (this->stunTimer > 0) { this->stunTimer--; } @@ -1116,16 +1117,16 @@ void EnRd_Stunned(EnRd* this, GlobalContext* globalCtx) { if (this->actor.colorFilterTimer == 0) { if (this->actor.colChkInfo.health == 0) { - EnRd_UpdateParentForOtherRedeads(globalCtx, &this->actor, true); + EnRd_UpdateParentForOtherRedeads(play, &this->actor, true); EnRd_SetupDead(this); - Item_DropCollectibleRandom(globalCtx, &this->actor, &this->actor.world.pos, 0x90); + Item_DropCollectibleRandom(play, &this->actor, &this->actor.world.pos, 0x90); } else { EnRd_SetupDamage(this); } } } -void EnRd_TurnTowardsPlayer(EnRd* this, GlobalContext* globalCtx) { +void EnRd_TurnTowardsPlayer(EnRd* this, PlayState* play) { s16 headAngle = (this->actor.yawTowardsPlayer - this->actor.shape.rot.y) - this->upperBodyYRotation; s16 upperBodyAngle = CLAMP(headAngle, -500, 500); @@ -1144,9 +1145,9 @@ void EnRd_TurnTowardsPlayer(EnRd* this, GlobalContext* globalCtx) { this->headYRotation = CLAMP(this->headYRotation, -0x256F, 0x256F); } -void EnRd_UpdateDamage(EnRd* this, GlobalContext* globalCtx) { +void EnRd_UpdateDamage(EnRd* this, PlayState* play) { s32 pad; - Player* player = GET_PLAYER(globalCtx); + Player* player = GET_PLAYER(play); 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) && @@ -1220,29 +1221,29 @@ void EnRd_UpdateDamage(EnRd* this, GlobalContext* globalCtx) { Actor_ApplyDamage(&this->actor); if (this->actor.colChkInfo.health == 0) { - EnRd_UpdateParentForOtherRedeads(globalCtx, &this->actor, true); + EnRd_UpdateParentForOtherRedeads(play, &this->actor, true); EnRd_SetupDead(this); - Item_DropCollectibleRandom(globalCtx, NULL, &this->actor.world.pos, 0x90); + Item_DropCollectibleRandom(play, NULL, &this->actor.world.pos, 0x90); } else { EnRd_SetupDamage(this); } } } -void EnRd_UpdateCollision(EnRd* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); +void EnRd_UpdateCollision(EnRd* this, PlayState* play) { + Player* player = GET_PLAYER(play); 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); + CollisionCheck_SetOC(play, &play->colChkCtx, &this->collider.base); 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); + CollisionCheck_SetAC(play, &play->colChkCtx, &this->collider.base); } } } -void EnRd_UpdateEffect(EnRd* this, GlobalContext* globalCtx) { +void EnRd_UpdateEffect(EnRd* this, PlayState* play) { if (this->drawDmgEffTimer > 0) { this->drawDmgEffTimer--; } @@ -1255,10 +1256,10 @@ void EnRd_UpdateEffect(EnRd* this, GlobalContext* globalCtx) { } } -void EnRd_Update(Actor* thisx, GlobalContext* globalCtx) { +void EnRd_Update(Actor* thisx, PlayState* play) { EnRd* this = THIS; - EnRd_UpdateDamage(this, globalCtx); + EnRd_UpdateDamage(this, play); if ((gSaveContext.sunsSongState != SUNSSONG_INACTIVE) && (!this->stunnedBySunsSong)) { gSaveContext.sunsSongState = SUNSSONG_INACTIVE; } @@ -1269,7 +1270,7 @@ void EnRd_Update(Actor* thisx, GlobalContext* globalCtx) { this->playerStunWaitTimer--; } - this->actionFunc(this, globalCtx); + this->actionFunc(this, play); if ((this->action != EN_RD_ACTION_GRABBING) && (this->actor.speedXZ != 0.0f)) { Actor_MoveWithGravity(&this->actor); @@ -1277,23 +1278,23 @@ void EnRd_Update(Actor* thisx, GlobalContext* globalCtx) { 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); + Actor_UpdateBgCheckInfo(play, &this->actor, 30.0f, 20.0f, 35.0f, 0x1D); } if (this->action == EN_RD_ACTION_ATTEMPTING_PLAYER_STUN) { - EnRd_TurnTowardsPlayer(this, globalCtx); + EnRd_TurnTowardsPlayer(this, play); } } this->actor.focus.pos = this->actor.world.pos; this->actor.focus.pos.y += 50.0f; - EnRd_UpdateCollision(this, globalCtx); - EnRd_SetupDanceIfConditionsMet(this, globalCtx); - EnRd_UpdateEffect(this, globalCtx); + EnRd_UpdateCollision(this, play); + EnRd_SetupDanceIfConditionsMet(this, play); + EnRd_UpdateEffect(this, play); } -s32 EnRd_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, Actor* thisx, +s32 EnRd_OverrideLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, Actor* thisx, Gfx** gfx) { EnRd* this = THIS; @@ -1305,7 +1306,7 @@ s32 EnRd_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, return false; } -void EnRd_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx, Gfx** gfx) { +void EnRd_PostLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx, Gfx** gfx) { EnRd* this = THIS; if ((this->drawDmgEffTimer != 0) && @@ -1317,48 +1318,48 @@ void EnRd_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec (limbIndex == REDEAD_LIMB_RIGHT_SHOULDER_AND_UPPER_ARM) || (limbIndex == REDEAD_LIMB_RIGHT_FOREARM) || (limbIndex == REDEAD_LIMB_RIGHT_HAND) || (limbIndex == REDEAD_LIMB_HEAD) || (limbIndex == REDEAD_LIMB_PELVIS))) { - Matrix_GetStateTranslation(&this->limbPos[this->limbIndex]); + Matrix_MultZero(&this->limbPos[this->limbIndex]); this->limbIndex++; } } -void EnRd_Draw(Actor* thisx, GlobalContext* globalCtx) { +void EnRd_Draw(Actor* thisx, PlayState* play) { static Vec3f D_808D7138 = { 0.25f, 0.25f, 0.25f }; s32 pad; EnRd* this = THIS; Vec3f sp54 = this->actor.world.pos; - OPEN_DISPS(globalCtx->state.gfxCtx); + OPEN_DISPS(play->state.gfxCtx); this->limbIndex = 0; if (this->alpha == 255) { - func_8012C28C(globalCtx->state.gfxCtx); + func_8012C28C(play->state.gfxCtx); 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, - this->skelAnime.dListCount, EnRd_OverrideLimbDraw, EnRd_PostLimbDraw, - &this->actor, POLY_OPA_DISP); + POLY_OPA_DISP = + SkelAnime_DrawFlex(play, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, + EnRd_OverrideLimbDraw, EnRd_PostLimbDraw, &this->actor, POLY_OPA_DISP); - func_800BC620(&sp54, &D_808D7138, 255, globalCtx); + func_800BC620(&sp54, &D_808D7138, 255, play); } else { - func_8012C2DC(globalCtx->state.gfxCtx); + func_8012C2DC(play->state.gfxCtx); 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->alpha, globalCtx); + SkelAnime_DrawFlex(play, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, + EnRd_OverrideLimbDraw, NULL, &this->actor, POLY_XLU_DISP); + func_800BC620(&sp54, &D_808D7138, this->alpha, play); } - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->state.gfxCtx); if (this->drawDmgEffTimer > 0) { - Actor_DrawDamageEffects(globalCtx, &this->actor, this->limbPos, ARRAY_COUNT(this->limbPos), - this->drawDmgEffScale, 0.5f, this->drawDmgEffAlpha, this->drawDmgEffType); + Actor_DrawDamageEffects(play, &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 7bf5a6ddc..0affac4f1 100644 --- a/src/overlays/actors/ovl_En_Rd/z_en_rd.h +++ b/src/overlays/actors/ovl_En_Rd/z_en_rd.h @@ -6,7 +6,7 @@ struct EnRd; -typedef void (*EnRdActionFunc)(struct EnRd*, GlobalContext*); +typedef void (*EnRdActionFunc)(struct EnRd*, PlayState*); typedef void (*EnRdSetupDanceFunc)(struct EnRd*); #define EN_RD_GET_80(thisx) ((thisx)->params & 0x80) @@ -31,45 +31,45 @@ typedef enum { } EnRdType; typedef struct EnRd { - /* 0x0000 */ Actor actor; - /* 0x0144 */ SkelAnime skelAnime; - /* 0x0188 */ EnRdActionFunc actionFunc; - /* 0x018C */ EnRdSetupDanceFunc setupDanceFunc; - /* 0x0190 */ ColliderCylinder collider; - /* 0x01DC */ Vec3f limbPos[15]; - /* 0x0290 */ s32 limbIndex; - /* 0x0294 */ f32 drawDmgEffAlpha; - /* 0x0298 */ f32 drawDmgEffScale; - /* 0x029C */ Vec3s jointTable[REDEAD_LIMB_MAX]; - /* 0x0338 */ Vec3s morphTable[REDEAD_LIMB_MAX]; - /* 0x03D4 */ s16 headShakeTimer; - /* 0x03D6 */ union { + /* 0x000 */ Actor actor; + /* 0x144 */ SkelAnime skelAnime; + /* 0x188 */ EnRdActionFunc actionFunc; + /* 0x18C */ EnRdSetupDanceFunc setupDanceFunc; + /* 0x190 */ ColliderCylinder collider; + /* 0x1DC */ Vec3f limbPos[15]; + /* 0x290 */ s32 limbIndex; + /* 0x294 */ f32 drawDmgEffAlpha; + /* 0x298 */ f32 drawDmgEffScale; + /* 0x29C */ Vec3s jointTable[REDEAD_LIMB_MAX]; + /* 0x338 */ Vec3s morphTable[REDEAD_LIMB_MAX]; + /* 0x3D4 */ s16 headShakeTimer; + /* 0x3D6 */ union { s16 animationJudderTimer; s16 stunTimer; s16 deathTimer; s16 coffinRiseForwardAccelTimer; }; - /* 0x03D8 */ s16 headYRotation; - /* 0x03DA */ s16 upperBodyYRotation; - /* 0x03DC */ s16 flags; - /* 0x03DE */ s16 alpha; - /* 0x03E0 */ s16 sunsSongStunTimer; - /* 0x03E2 */ UNK_TYPE1 unk3E2[0x2]; - /* 0x03E4 */ union { + /* 0x3D8 */ s16 headYRotation; + /* 0x3DA */ s16 upperBodyYRotation; + /* 0x3DC */ s16 flags; + /* 0x3DE */ s16 alpha; + /* 0x3E0 */ s16 sunsSongStunTimer; + /* 0x3E2 */ UNK_TYPE1 unk3E2[0x2]; + /* 0x3E4 */ union { s16 danceEndTimer; s16 pirouetteRotationalVelocity; }; - /* 0x03E6 */ s16 drawDmgEffTimer; - /* 0x03E8 */ u8 drawDmgEffType; - /* 0x03E9 */ u8 stunnedBySunsSong; - /* 0x03EA */ u8 grabDamageTimer; - /* 0x03EB */ u8 grabState; - /* 0x03EC */ u8 isMourning; - /* 0x03ED */ u8 playerStunWaitTimer; // Cannot stun the player if this is non-zero - /* 0x03EE */ u8 grabWaitTimer; // Cannot grab the player if this is non-zero - /* 0x03EF */ u8 action; - /* 0x03F0 */ u8 damageEffect; - /* 0x03F1 */ s8 unk_3F1; // related to player->unk_ADD + /* 0x3E6 */ s16 drawDmgEffTimer; + /* 0x3E8 */ u8 drawDmgEffType; + /* 0x3E9 */ u8 stunnedBySunsSong; + /* 0x3EA */ u8 grabDamageTimer; + /* 0x3EB */ u8 grabState; + /* 0x3EC */ u8 isMourning; + /* 0x3ED */ u8 playerStunWaitTimer; // Cannot stun the player if this is non-zero + /* 0x3EE */ u8 grabWaitTimer; // Cannot grab the player if this is non-zero + /* 0x3EF */ u8 action; + /* 0x3F0 */ u8 damageEffect; + /* 0x3F1 */ s8 unk_3F1; // related to player->unk_ADD } EnRd; // size = 0x3F4 extern const ActorInit En_Rd_InitVars; diff --git a/src/overlays/actors/ovl_En_Recepgirl/z_en_recepgirl.c b/src/overlays/actors/ovl_En_Recepgirl/z_en_recepgirl.c index 8c2f5b6c8..d817d1df4 100644 --- a/src/overlays/actors/ovl_En_Recepgirl/z_en_recepgirl.c +++ b/src/overlays/actors/ovl_En_Recepgirl/z_en_recepgirl.c @@ -11,15 +11,15 @@ #define THIS ((EnRecepgirl*)thisx) -void EnRecepgirl_Init(Actor* thisx, GlobalContext* globalCtx); -void EnRecepgirl_Destroy(Actor* thisx, GlobalContext* globalCtx); -void EnRecepgirl_Update(Actor* thisx, GlobalContext* globalCtx); -void EnRecepgirl_Draw(Actor* thisx, GlobalContext* globalCtx); +void EnRecepgirl_Init(Actor* thisx, PlayState* play); +void EnRecepgirl_Destroy(Actor* thisx, PlayState* play); +void EnRecepgirl_Update(Actor* thisx, PlayState* play); +void EnRecepgirl_Draw(Actor* thisx, PlayState* play); void EnRecepgirl_SetupWait(EnRecepgirl* this); -void EnRecepgirl_Wait(EnRecepgirl* this, GlobalContext* globalCtx); +void EnRecepgirl_Wait(EnRecepgirl* this, PlayState* play); void EnRecepgirl_SetupTalk(EnRecepgirl* this); -void EnRecepgirl_Talk(EnRecepgirl* this, GlobalContext* globalCtx); +void EnRecepgirl_Talk(EnRecepgirl* this, PlayState* play); const ActorInit En_Recepgirl_InitVars = { ACTOR_EN_RECEPGIRL, @@ -41,27 +41,27 @@ static InitChainEntry sInitChain[] = { ICHAIN_F32(targetArrowOffset, 1000, ICHAIN_STOP), }; -static s32 texturesDesegmented = false; +static s32 sTexturesDesegmented = false; -void EnRecepgirl_Init(Actor* thisx, GlobalContext* globalCtx) { +void EnRecepgirl_Init(Actor* thisx, PlayState* play) { EnRecepgirl* this = THIS; s32 i; Actor_ProcessInitChain(&this->actor, sInitChain); ActorShape_Init(&this->actor.shape, -60.0f, NULL, 0.0f); - SkelAnime_InitFlex(globalCtx, &this->skelAnime, &object_bg_Skel_011B60, &object_bg_Anim_009890, this->jointTable, + SkelAnime_InitFlex(play, &this->skelAnime, &object_bg_Skel_011B60, &object_bg_Anim_009890, this->jointTable, this->morphTable, 24); - if (!texturesDesegmented) { + if (!sTexturesDesegmented) { for (i = 0; i < ARRAY_COUNT(sEyeTextures); i++) { sEyeTextures[i] = Lib_SegmentedToVirtual(sEyeTextures[i]); } - texturesDesegmented = true; + sTexturesDesegmented = true; } this->eyeTexIndex = 2; - if (Flags_GetSwitch(globalCtx, this->actor.params)) { + if (Flags_GetSwitch(play, this->actor.params)) { this->actor.textId = 0x2ADC; // hear directions again? } else { this->actor.textId = 0x2AD9; // "Welcome..." @@ -70,7 +70,7 @@ void EnRecepgirl_Init(Actor* thisx, GlobalContext* globalCtx) { EnRecepgirl_SetupWait(this); } -void EnRecepgirl_Destroy(Actor* thisx, GlobalContext* globalCtx) { +void EnRecepgirl_Destroy(Actor* thisx, PlayState* play) { } void EnRecepgirl_UpdateEyes(EnRecepgirl* this) { @@ -91,7 +91,7 @@ void EnRecepgirl_SetupWait(EnRecepgirl* this) { this->actionFunc = EnRecepgirl_Wait; } -void EnRecepgirl_Wait(EnRecepgirl* this, GlobalContext* globalCtx) { +void EnRecepgirl_Wait(EnRecepgirl* this, PlayState* play) { if (SkelAnime_Update(&this->skelAnime) != 0) { if (this->skelAnime.animation == &object_bg_Anim_00A280) { Animation_MorphToPlayOnce(&this->skelAnime, &object_bg_Anim_00AD98, 5.0f); @@ -100,13 +100,13 @@ void EnRecepgirl_Wait(EnRecepgirl* this, GlobalContext* globalCtx) { } } - if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { + if (Actor_ProcessTalkRequest(&this->actor, &play->state)) { EnRecepgirl_SetupTalk(this); } else if (Actor_IsFacingPlayer(&this->actor, 0x2000)) { - func_800B8614(&this->actor, globalCtx, 60.0f); - if (Player_GetMask(globalCtx) == PLAYER_MASK_KAFEIS_MASK) { + func_800B8614(&this->actor, play, 60.0f); + if (Player_GetMask(play) == PLAYER_MASK_KAFEIS_MASK) { this->actor.textId = 0x2367; // "... doesn't Kafei want to break off his engagement ... ?" - } else if (Flags_GetSwitch(globalCtx, this->actor.params)) { + } else if (Flags_GetSwitch(play, this->actor.params)) { this->actor.textId = 0x2ADC; // hear directions again? } else { this->actor.textId = 0x2AD9; // "Welcome..." @@ -119,8 +119,8 @@ void EnRecepgirl_SetupTalk(EnRecepgirl* this) { this->actionFunc = EnRecepgirl_Talk; } -void EnRecepgirl_Talk(EnRecepgirl* this, GlobalContext* globalCtx) { - u8 temp_v0_2; +void EnRecepgirl_Talk(EnRecepgirl* this, PlayState* play) { + u8 talkState; if (SkelAnime_Update(&this->skelAnime)) { if (this->skelAnime.animation == &object_bg_Anim_00A280) { @@ -140,13 +140,13 @@ void EnRecepgirl_Talk(EnRecepgirl* this, GlobalContext* globalCtx) { } } - temp_v0_2 = Message_GetState(&globalCtx->msgCtx); - if (temp_v0_2 == 2) { + talkState = Message_GetState(&play->msgCtx); + if (talkState == TEXT_STATE_CLOSING) { this->actor.textId = 0x2ADC; // hear directions again? EnRecepgirl_SetupWait(this); - } else if ((temp_v0_2 == 5) && (Message_ShouldAdvance(globalCtx) != 0)) { + } else if ((talkState == TEXT_STATE_5) && Message_ShouldAdvance(play)) { if (this->actor.textId == 0x2AD9) { // "Welcome..." - Flags_SetSwitch(globalCtx, this->actor.params); + Flags_SetSwitch(play, this->actor.params); Animation_MorphToPlayOnce(&this->skelAnime, &object_bg_Anim_00AD98, 10.0f); if (gSaveContext.save.weekEventReg[63] & 0x80) { // showed Couple's Mask to meeting @@ -168,22 +168,21 @@ void EnRecepgirl_Talk(EnRecepgirl* this, GlobalContext* globalCtx) { this->actor.textId = 0x2AE0; // drawing room on the right, don't go in without an appointment } } - func_80151938(globalCtx, this->actor.textId); + func_80151938(play, this->actor.textId); } } -void EnRecepgirl_Update(Actor* thisx, GlobalContext* globalCtx) { +void EnRecepgirl_Update(Actor* thisx, PlayState* play) { s32 pad; EnRecepgirl* this = THIS; Vec3s sp30; - this->actionFunc(this, globalCtx); - func_800E9250(globalCtx, &this->actor, &this->headRot, &sp30, this->actor.focus.pos); + this->actionFunc(this, play); + Actor_TrackPlayer(play, &this->actor, &this->headRot, &sp30, this->actor.focus.pos); EnRecepgirl_UpdateEyes(this); } -s32 EnRecepgirl_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, - Actor* thisx) { +s32 EnRecepgirl_OverrideLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, Actor* thisx) { EnRecepgirl* this = THIS; if (limbIndex == 5) { @@ -192,26 +191,26 @@ s32 EnRecepgirl_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** return false; } -void EnRecepgirl_TransformLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Actor* thisx) { +void EnRecepgirl_TransformLimbDraw(PlayState* play, s32 limbIndex, Actor* thisx) { 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); } } -void EnRecepgirl_Draw(Actor* thisx, GlobalContext* globalCtx) { +void EnRecepgirl_Draw(Actor* thisx, PlayState* play) { EnRecepgirl* this = THIS; - OPEN_DISPS(globalCtx->state.gfxCtx); + OPEN_DISPS(play->state.gfxCtx); - func_8012C28C(globalCtx->state.gfxCtx); + func_8012C28C(play->state.gfxCtx); gSPSegment(POLY_OPA_DISP++, 0x08, sEyeTextures[this->eyeTexIndex]); - SkelAnime_DrawTransformFlexOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, + SkelAnime_DrawTransformFlexOpa(play, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, EnRecepgirl_OverrideLimbDraw, NULL, EnRecepgirl_TransformLimbDraw, &this->actor); - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->state.gfxCtx); } diff --git a/src/overlays/actors/ovl_En_Recepgirl/z_en_recepgirl.h b/src/overlays/actors/ovl_En_Recepgirl/z_en_recepgirl.h index a6b858192..b6684fc9e 100644 --- a/src/overlays/actors/ovl_En_Recepgirl/z_en_recepgirl.h +++ b/src/overlays/actors/ovl_En_Recepgirl/z_en_recepgirl.h @@ -5,7 +5,7 @@ struct EnRecepgirl; -typedef void (*EnRecepgirlActionFunc)(struct EnRecepgirl*, GlobalContext*); +typedef void (*EnRecepgirlActionFunc)(struct EnRecepgirl*, PlayState*); typedef struct EnRecepgirl { /* 0x000 */ Actor actor; 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 13d4a93e9..896947fa6 100644 --- a/src/overlays/actors/ovl_En_Rg/z_en_rg.c +++ b/src/overlays/actors/ovl_En_Rg/z_en_rg.c @@ -12,13 +12,13 @@ #define THIS ((EnRg*)thisx) -void EnRg_Init(Actor* thisx, GlobalContext* globalCtx); -void EnRg_Destroy(Actor* thisx, GlobalContext* globalCtx); -void EnRg_Update(Actor* thisx, GlobalContext* globalCtx); -void EnRg_Draw(Actor* thisx, GlobalContext* globalCtx); +void EnRg_Init(Actor* thisx, PlayState* play); +void EnRg_Destroy(Actor* thisx, PlayState* play); +void EnRg_Update(Actor* thisx, PlayState* play); +void EnRg_Draw(Actor* thisx, PlayState* play); -void func_80BF4EBC(EnRg* this, GlobalContext* globalCtx); -void func_80BF4FC4(EnRg* this, GlobalContext* globalCtx); +void func_80BF4EBC(EnRg* this, PlayState* play); +void func_80BF4FC4(EnRg* this, PlayState* play); s32 D_80BF5C10; @@ -119,8 +119,8 @@ s32 D_80BF57E4[][4] = { }; AnimationInfoS D_80BF5914[] = { - { &object_oF1d_map_Anim_012DE0, 2.0f, 0, -1, ANIMMODE_ONCE, 0 }, - { &object_oF1d_map_Anim_012DE0, -2.0f, 0, -1, ANIMMODE_ONCE, 0 }, + { &gGoronUnrollAnim, 2.0f, 0, -1, ANIMMODE_ONCE, 0 }, + { &gGoronUnrollAnim, -2.0f, 0, -1, ANIMMODE_ONCE, 0 }, }; TexturePtr D_80BF5934[] = { @@ -153,31 +153,30 @@ 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) { +void func_80BF3920(EnRgStruct* ptr, PlayState* play) { f32 temp_f20; u8 phi_fp = false; s32 i; s32 idx; - OPEN_DISPS(globalCtx->state.gfxCtx); + OPEN_DISPS(play->state.gfxCtx); - func_8012C2DC(globalCtx->state.gfxCtx); + func_8012C2DC(play->state.gfxCtx); 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) {} + if (play) {} temp_f20 = (f32)ptr->unk_02 / ptr->unk_01; gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, D_80BF5954[ptr->unk_00 - 4].r, D_80BF5954[ptr->unk_00 - 4].g, @@ -185,21 +184,20 @@ 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(&play->billboardMtxF); - gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), - G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); 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(); } } - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->state.gfxCtx); } void func_80BF3C64(EnRg* this) { @@ -224,36 +222,36 @@ void func_80BF3C64(EnRg* this) { } } -void func_80BF3DA0(EnRg* this, GlobalContext* globalCtx) { - func_80BF3920(this->unk_34C, globalCtx); +void func_80BF3DA0(EnRg* this, PlayState* play) { + func_80BF3920(this->unk_34C, play); } -void func_80BF3DC4(EnRg* this, GlobalContext* globalCtx) { +void func_80BF3DC4(EnRg* this, PlayState* play) { this->collider2.dim.worldSphere.center.x = this->actor.world.pos.x; this->collider2.dim.worldSphere.center.y = this->actor.world.pos.y + this->actor.shape.yOffset; this->collider2.dim.worldSphere.center.z = this->actor.world.pos.z; if (this->actor.speedXZ >= 10.0f) { - CollisionCheck_SetAT(globalCtx, &globalCtx->colChkCtx, &this->collider2.base); + CollisionCheck_SetAT(play, &play->colChkCtx, &this->collider2.base); } - CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->collider2.base); - CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider2.base); + CollisionCheck_SetAC(play, &play->colChkCtx, &this->collider2.base); + CollisionCheck_SetOC(play, &play->colChkCtx, &this->collider2.base); } -void func_80BF3E88(EnRg* this, GlobalContext* globalCtx) { +void func_80BF3E88(EnRg* this, PlayState* play) { Math_Vec3f_ToVec3s(&this->collider1.dim.pos, &this->actor.world.pos); - CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider1.base); + CollisionCheck_SetOC(play, &play->colChkCtx, &this->collider1.base); } -void func_80BF3ED4(EnRg* this, GlobalContext* globalCtx) { +void func_80BF3ED4(EnRg* this, PlayState* play) { if (this->unk_310 & 0x10) { - func_80BF3DC4(this, globalCtx); + func_80BF3DC4(this, play); } else { - func_80BF3E88(this, globalCtx); + func_80BF3E88(this, play); } } -s32 func_80BF3F14(EnRg* this, GlobalContext* globalCtx) { +s32 func_80BF3F14(EnRg* this, PlayState* play) { this->unk_310 &= ~0x20; this->unk_310 &= ~0x40; this->unk_310 &= ~0x80; @@ -284,8 +282,8 @@ void func_80BF3FF8(EnRg* this) { SkelAnime_Update(&this->skelAnime); } -s32 func_80BF4024(EnRg* this, GlobalContext* globalCtx) { - if ((globalCtx->csCtx.state == 0) && (this->unk_334 == 1)) { +s32 func_80BF4024(EnRg* this, PlayState* play) { + if ((play->csCtx.state == 0) && (this->unk_334 == 1)) { if (Animation_OnFrame(&this->skelAnime, 2.0f)) { Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_GOLON_CIRCLE); } @@ -319,10 +317,10 @@ void func_80BF40F4(EnRg* this) { } } -s32 func_80BF416C(EnRg* this, GlobalContext* globalCtx) { +s32 func_80BF416C(EnRg* this, PlayState* play) { if ((this->actor.bgCheckFlags & 1) && (this->actor.speedXZ >= 0.01f)) { Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_GOLON_ROLLING - SFX_FLAG); - func_800AE930(&globalCtx->colCtx, Effect_GetByIndex(this->unk_340), &this->actor.world.pos, 18.0f, + func_800AE930(&play->colCtx, Effect_GetByIndex(this->unk_340), &this->actor.world.pos, 18.0f, this->actor.shape.rot.y, this->actor.floorPoly, this->actor.floorBgId); } else { func_800AEF44(Effect_GetByIndex(this->unk_340)); @@ -330,14 +328,14 @@ s32 func_80BF416C(EnRg* this, GlobalContext* globalCtx) { return false; } -s32 func_80BF4220(EnRg* this, GlobalContext* globalCtx, Actor* arg2) { +s32 func_80BF4220(EnRg* this, PlayState* play, Actor* arg2) { CollisionPoly* sp44 = NULL; s32 sp40; Vec3f sp34; if (Actor_ActorAIsFacingAndNearActorB(&this->actor, arg2, 400.0f, 0x2000) && - !BgCheck_EntityLineTest1(&globalCtx->colCtx, &this->actor.world.pos, &arg2->world.pos, &sp34, &sp44, true, - false, false, true, &sp40)) { + !BgCheck_EntityLineTest1(&play->colCtx, &this->actor.world.pos, &arg2->world.pos, &sp34, &sp44, true, false, + false, true, &sp40)) { return true; } return false; @@ -368,7 +366,6 @@ s32 func_80BF42BC(EnRg* this, f32 arg1) { return false; } -#ifdef NON_MATCHING s32 func_80BF43FC(EnRg* this) { Vec3f sp9C; Vec3f sp90; @@ -378,11 +375,11 @@ 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) { + 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, @@ -393,19 +390,13 @@ 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); +s32 func_80BF4560(EnRg* this, PlayState* play) { + s32 temp_v0 = SurfaceType_GetSceneExitIndex(&play->colCtx, this->actor.floorPoly, this->actor.floorBgId); if ((temp_v0 < 4) || (temp_v0 >= 19)) { temp_v0 = -1; @@ -464,8 +455,8 @@ s32 func_80BF45B4(EnRg* this) { return ret; } -s32 func_80BF47AC(EnRg* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); +s32 func_80BF47AC(EnRg* this, PlayState* play) { + Player* player = GET_PLAYER(play); f32 phi_f0; f32 phi_f2; @@ -553,17 +544,17 @@ void func_80BF4964(EnRg* this) { } } -void func_80BF4AB8(EnRg* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); +void func_80BF4AB8(EnRg* this, PlayState* play) { + Player* player = GET_PLAYER(play); Actor* phi_s0; phi_s0 = NULL; if (!(this->unk_310 & 0x800)) { if (this->unk_320 == 0) { do { - phi_s0 = SubS_FindActor(globalCtx, phi_s0, 6, ACTOR_OBJ_TSUBO); + phi_s0 = SubS_FindActor(play, phi_s0, 6, ACTOR_OBJ_TSUBO); if (phi_s0 != NULL) { - if (func_80BF4220(this, globalCtx, phi_s0) && (phi_s0->update != NULL)) { + if (func_80BF4220(this, play, phi_s0) && (phi_s0->update != NULL)) { this->unk_18C = phi_s0; this->unk_310 |= 0x800; break; @@ -574,12 +565,12 @@ void func_80BF4AB8(EnRg* this, GlobalContext* globalCtx) { } if ((phi_s0 == NULL) && (D_80BF5C10 == 0) && (this->unk_326 == 0) && (player->stateFlags3 & 0x80000) && - (player->invincibilityTimer == 0) && func_80BF4220(this, globalCtx, &player->actor)) { + (player->invincibilityTimer == 0) && func_80BF4220(this, play, &player->actor)) { this->unk_18C = &player->actor; this->unk_310 |= 0x800; D_80BF5C10 = 1; } - } else if ((this->unk_18C != NULL) && !func_80BF4220(this, globalCtx, this->unk_18C)) { + } else if ((this->unk_18C != NULL) && !func_80BF4220(this, play, this->unk_18C)) { if (this->unk_18C->id == ACTOR_PLAYER) { D_80BF5C10 = 0; } @@ -658,7 +649,7 @@ s32 func_80BF4DA8(EnRg* this) { return ret; } -void func_80BF4EBC(EnRg* this, GlobalContext* globalCtx) { +void func_80BF4EBC(EnRg* this, PlayState* play) { if (this->unk_310 & 0x100) { if (Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) { this->unk_310 &= ~0x100; @@ -677,13 +668,13 @@ void func_80BF4EBC(EnRg* this, GlobalContext* globalCtx) { this->unk_318 = Rand_S16Offset(0, 20); } } - SubS_FillLimbRotTables(globalCtx, this->unk_32E, this->unk_328, ARRAY_COUNT(this->unk_328)); + SubS_FillLimbRotTables(play, 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); +void func_80BF4FC4(EnRg* this, PlayState* play) { + this->unk_344 = func_80BF4560(this, play); - if (!Play_InCsMode(globalCtx)) { + if (!Play_InCsMode(play)) { if (this->actor.bgCheckFlags & 2) { if (this->unk_310 & 0x400) { this->unk_310 &= ~0x400; @@ -708,10 +699,10 @@ void func_80BF4FC4(EnRg* this, GlobalContext* globalCtx) { if (gSaveContext.eventInf[1] & 1) { if (DECR(this->unk_318) == 0) { - func_80BF47AC(this, globalCtx); + func_80BF47AC(this, play); if ((this->unk_324 == 0) && !func_80BF4DA8(this)) { - func_80BF4AB8(this, globalCtx); + func_80BF4AB8(this, play); } if (func_80BF45B4(this)) { @@ -722,7 +713,7 @@ void func_80BF4FC4(EnRg* this, GlobalContext* globalCtx) { func_80BF4964(this); Actor_UpdateVelocityWithGravity(&this->actor); Actor_UpdatePos(&this->actor); - func_80BF416C(this, globalCtx); + func_80BF416C(this, play); return; } } @@ -730,26 +721,26 @@ void func_80BF4FC4(EnRg* this, GlobalContext* globalCtx) { } } -void EnRg_Init(Actor* thisx, GlobalContext* globalCtx) { +void EnRg_Init(Actor* thisx, PlayState* play) { EnRg* this = THIS; - if (gSaveContext.save.entranceIndex == 0xD010) { + if (gSaveContext.save.entrance == ENTRANCE(GORON_RACETRACK, 1)) { 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(play, &this->skelAnime, &gGoronSkel, NULL, this->jointTable, this->morphTable, + GORON_LIMB_MAX); this->unk_334 = -1; func_80BF409C(this, 0); this->skelAnime.curFrame = this->skelAnime.endFrame; - Collider_InitAndSetSphere(globalCtx, &this->collider2, &this->actor, &sSphereInit); - Collider_InitAndSetCylinder(globalCtx, &this->collider1, &this->actor, &sCylinderInit); + Collider_InitAndSetSphere(play, &this->collider2, &this->actor, &sSphereInit); + Collider_InitAndSetCylinder(play, &this->collider1, &this->actor, &sCylinderInit); this->collider2.dim.worldSphere.radius = this->collider2.dim.modelSphere.radius; CollisionCheck_SetInfo2(&this->actor.colChkInfo, &sDamageTable, &sColChkInfoInit); - Effect_Add(globalCtx, &this->unk_340, EFFECT_TIRE_MARK, 0, 0, &D_80BF59F0); + Effect_Add(play, &this->unk_340, EFFECT_TIRE_MARK, 0, 0, &D_80BF59F0); - this->path = SubS_GetDayDependentPath(globalCtx, ENRG_GET_7F80(&this->actor), 255, &this->unk_33C); + this->path = SubS_GetDayDependentPath(play, ENRG_GET_7F80(&this->actor), 255, &this->unk_33C); if (this->path != NULL) { this->unk_33C = 1; } @@ -771,62 +762,62 @@ void EnRg_Init(Actor* thisx, GlobalContext* globalCtx) { } } -void EnRg_Destroy(Actor* thisx, GlobalContext* globalCtx) { +void EnRg_Destroy(Actor* thisx, PlayState* play) { EnRg* this = THIS; - Collider_DestroyCylinder(globalCtx, &this->collider1); - Collider_DestroySphere(globalCtx, &this->collider2); - Effect_Destroy(globalCtx, this->unk_340); + Collider_DestroyCylinder(play, &this->collider1); + Collider_DestroySphere(play, &this->collider2); + Effect_Destroy(play, this->unk_340); } -void EnRg_Update(Actor* thisx, GlobalContext* globalCtx) { +void EnRg_Update(Actor* thisx, PlayState* play) { EnRg* this = THIS; - func_80BF3F14(this, globalCtx); + func_80BF3F14(this, play); - this->actionFunc(this, globalCtx); + this->actionFunc(this, play); this->actor.shape.rot.y = this->actor.world.rot.y; if (!(this->unk_310 & 0x10)) { func_80BF40F4(this); func_80BF3FF8(this); - func_80BF4024(this, globalCtx); + func_80BF4024(this, play); } - Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 30.0f, 20.0f, 0.0f, 0x1D); + Actor_UpdateBgCheckInfo(play, &this->actor, 30.0f, 20.0f, 0.0f, 0x1D); if (this->actor.floorHeight <= BGCHECK_Y_MIN) { Math_Vec3f_Copy(&this->actor.world.pos, &this->actor.prevPos); } - func_80BF3ED4(this, globalCtx); + func_80BF3ED4(this, play); - if (!Play_InCsMode(globalCtx)) { + if (!Play_InCsMode(play)) { func_80BF3C64(this); } } -void func_80BF547C(EnRg* this, GlobalContext* globalCtx) { - OPEN_DISPS(globalCtx->state.gfxCtx); +void func_80BF547C(EnRg* this, PlayState* play) { + OPEN_DISPS(play->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); + func_8012C28C(play->state.gfxCtx); + 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); + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_OPA_DISP++, gGoronRolledUpDL); - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->state.gfxCtx); } -s32 func_80BF5588(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, Actor* thisx) { +s32 func_80BF5588(PlayState* play, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, Actor* thisx) { EnRg* this = THIS; s32 phi_v0; @@ -856,22 +847,22 @@ s32 func_80BF5588(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* p return false; } -void EnRg_Draw(Actor* thisx, GlobalContext* globalCtx) { +void EnRg_Draw(Actor* thisx, PlayState* play) { EnRg* this = THIS; if (!(this->unk_310 & 0x10)) { - OPEN_DISPS(globalCtx->state.gfxCtx); + OPEN_DISPS(play->state.gfxCtx); - func_8012C28C(globalCtx->state.gfxCtx); + func_8012C28C(play->state.gfxCtx); gSPSegment(POLY_OPA_DISP++, 0x08, Lib_SegmentedToVirtual(D_80BF59F8[this->unk_31E])); - SkelAnime_DrawFlexOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, - this->skelAnime.dListCount, func_80BF5588, NULL, &this->actor); + SkelAnime_DrawFlexOpa(play, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, + func_80BF5588, NULL, &this->actor); - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->state.gfxCtx); } else { - func_80BF547C(this, globalCtx); + func_80BF547C(this, play); } - func_80BF3DA0(this, globalCtx); + func_80BF3DA0(this, play); } 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 9f7e60ba4..fe0a000b6 100644 --- a/src/overlays/actors/ovl_En_Rg/z_en_rg.h +++ b/src/overlays/actors/ovl_En_Rg/z_en_rg.h @@ -5,7 +5,7 @@ struct EnRg; -typedef void (*EnRgActionFunc)(struct EnRg*, GlobalContext*); +typedef void (*EnRgActionFunc)(struct EnRg*, PlayState*); #define ENRG_GET_7F80(thisx) ((((thisx)->params & 0x7F80) >> 7) & 0xFF) @@ -22,34 +22,34 @@ typedef struct { } EnRgStruct; // size = 0x3C typedef struct EnRg { - /* 0x0000 */ Actor actor; - /* 0x0144 */ SkelAnime skelAnime; - /* 0x0188 */ EnRgActionFunc actionFunc; - /* 0x018C */ Actor* unk_18C; - /* 0x0190 */ ColliderCylinder collider1; - /* 0x01DC */ ColliderSphere collider2; - /* 0x0234 */ Path* path; - /* 0x0238 */ Vec3s jointTable[18]; - /* 0x02A4 */ Vec3s morphTable[18]; - /* 0x0310 */ u16 unk_310; - /* 0x0314 */ f32 unk_314; - /* 0x0318 */ s16 unk_318; - /* 0x031A */ UNK_TYPE1 unk31A[2]; - /* 0x031C */ s16 unk_31C; - /* 0x031E */ s16 unk_31E; - /* 0x0320 */ s16 unk_320; - /* 0x0322 */ s16 unk_322; - /* 0x0324 */ s16 unk_324; - /* 0x0326 */ s16 unk_326; - /* 0x0328 */ s16 unk_328[3]; - /* 0x032E */ s16 unk_32E[3]; - /* 0x0334 */ s32 unk_334; - /* 0x0338 */ UNK_TYPE1 unk338[4]; - /* 0x033C */ s32 unk_33C; - /* 0x0340 */ s32 unk_340; - /* 0x0344 */ s32 unk_344; - /* 0x0348 */ s32 numCheckpointsAheadOfPlayer; - /* 0x034C */ EnRgStruct unk_34C[32]; + /* 0x000 */ Actor actor; + /* 0x144 */ SkelAnime skelAnime; + /* 0x188 */ EnRgActionFunc actionFunc; + /* 0x18C */ Actor* unk_18C; + /* 0x190 */ ColliderCylinder collider1; + /* 0x1DC */ ColliderSphere collider2; + /* 0x234 */ Path* path; + /* 0x238 */ Vec3s jointTable[18]; + /* 0x2A4 */ Vec3s morphTable[18]; + /* 0x310 */ u16 unk_310; + /* 0x314 */ f32 unk_314; + /* 0x318 */ s16 unk_318; + /* 0x31A */ UNK_TYPE1 unk31A[2]; + /* 0x31C */ s16 unk_31C; + /* 0x31E */ s16 unk_31E; + /* 0x320 */ s16 unk_320; + /* 0x322 */ s16 unk_322; + /* 0x324 */ s16 unk_324; + /* 0x326 */ s16 unk_326; + /* 0x328 */ s16 unk_328[3]; + /* 0x32E */ s16 unk_32E[3]; + /* 0x334 */ s32 unk_334; + /* 0x338 */ UNK_TYPE1 unk338[4]; + /* 0x33C */ s32 unk_33C; + /* 0x340 */ s32 unk_340; + /* 0x344 */ s32 unk_344; + /* 0x348 */ s32 numCheckpointsAheadOfPlayer; + /* 0x34C */ EnRgStruct unk_34C[32]; } EnRg; // size = 0xACC extern const ActorInit En_Rg_InitVars; diff --git a/src/overlays/actors/ovl_En_River_Sound/z_en_river_sound.c b/src/overlays/actors/ovl_En_River_Sound/z_en_river_sound.c index 2084130ce..b164e6aab 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 @@ -10,9 +10,9 @@ #define THIS ((EnRiverSound*)thisx) -void EnRiverSound_Init(Actor* thisx, GlobalContext* globalCtx); -void EnRiverSound_Update(Actor* thisx, GlobalContext* globalCtx); -void EnRiverSound_Draw(Actor* thisx, GlobalContext* globalCtx); +void EnRiverSound_Init(Actor* thisx, PlayState* play); +void EnRiverSound_Update(Actor* thisx, PlayState* play); +void EnRiverSound_Draw(Actor* thisx, PlayState* play); const ActorInit En_River_Sound_InitVars = { ACTOR_EN_RIVER_SOUND, @@ -26,7 +26,7 @@ const ActorInit En_River_Sound_InitVars = { (ActorFunc)EnRiverSound_Draw, }; -void EnRiverSound_Init(Actor* thisx, GlobalContext* globalCtx) { +void EnRiverSound_Init(Actor* thisx, PlayState* play) { s32 pad; EnRiverSound* this = THIS; Path* path; @@ -40,18 +40,18 @@ void EnRiverSound_Init(Actor* thisx, GlobalContext* globalCtx) { return; } - path = &globalCtx->setupPathList[pathIndex]; + path = &play->setupPathList[pathIndex]; this->pathPoints = Lib_SegmentedToVirtual(path->points); this->numPoints = path->count; } -void EnRiverSound_Update(Actor* thisx, GlobalContext* globalCtx) { +void EnRiverSound_Update(Actor* thisx, PlayState* play) { EnRiverSound* this = THIS; Vec3f* worldPos = &this->actor.world.pos; Vec3f eye; s32 bgId; - Math_Vec3f_Copy(&eye, &globalCtx->view.eye); + Math_Vec3f_Copy(&eye, &play->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 @@ -59,9 +59,9 @@ void EnRiverSound_Update(Actor* thisx, GlobalContext* globalCtx) { 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) != + if (BgCheck_EntityRaycastFloor5(&play->colCtx, &this->actor.floorPoly, &bgId, &this->actor, worldPos) != BGCHECK_Y_MIN) { - this->soundFreqIndex = SurfaceType_GetConveyorSpeed(&globalCtx->colCtx, this->actor.floorPoly, bgId); + this->soundFreqIndex = SurfaceType_GetConveyorSpeed(&play->colCtx, this->actor.floorPoly, bgId); } else { this->soundFreqIndex = 0; } @@ -76,7 +76,7 @@ void EnRiverSound_Update(Actor* thisx, GlobalContext* globalCtx) { } } -void EnRiverSound_Draw(Actor* thisx, GlobalContext* globalCtx) { +void EnRiverSound_Draw(Actor* thisx, PlayState* play) { static f32 freqScale[] = { 0.7f, // 1 / sqrt(2) 1.0f, // 1 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 4bd5bcf32..8fc202ddd 100644 --- a/src/overlays/actors/ovl_En_Rr/z_en_rr.c +++ b/src/overlays/actors/ovl_En_Rr/z_en_rr.c @@ -5,27 +5,28 @@ */ #include "z_en_rr.h" +#include "z64rumble.h" #include "objects/object_rr/object_rr.h" #define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_4 | ACTOR_FLAG_400) #define THIS ((EnRr*)thisx) -void EnRr_Init(Actor* thisx, GlobalContext* globalCtx); -void EnRr_Destroy(Actor* thisx, GlobalContext* globalCtx); -void EnRr_Update(Actor* thisx, GlobalContext* globalCtx); -void EnRr_Draw(Actor* thisx, GlobalContext* globalCtx); +void EnRr_Init(Actor* thisx, PlayState* play); +void EnRr_Destroy(Actor* thisx, PlayState* play); +void EnRr_Update(Actor* thisx, PlayState* play); +void EnRr_Draw(Actor* thisx, PlayState* play); -void func_808FAF94(EnRr* this, GlobalContext* globalCtx); -void func_808FB088(EnRr* this, GlobalContext* globalCtx); -void func_808FB1C0(EnRr* this, GlobalContext* globalCtx); -void func_808FB2C0(EnRr* this, GlobalContext* globalCtx); -void func_808FB42C(EnRr* this, GlobalContext* globalCtx); -void func_808FB680(EnRr* this, GlobalContext* globalCtx); -void func_808FB710(EnRr* this, GlobalContext* globalCtx); +void func_808FAF94(EnRr* this, PlayState* play); +void func_808FB088(EnRr* this, PlayState* play); +void func_808FB1C0(EnRr* this, PlayState* play); +void func_808FB2C0(EnRr* this, PlayState* play); +void func_808FB42C(EnRr* this, PlayState* play); +void func_808FB680(EnRr* this, PlayState* play); +void func_808FB710(EnRr* this, PlayState* play); -void func_808FAD1C(EnRr* this, GlobalContext* globalCtx); -void func_808FB398(EnRr* this, GlobalContext* globalCtx); +void func_808FAD1C(EnRr* this, PlayState* play); +void func_808FB398(EnRr* this, PlayState* play); const ActorInit En_Rr_InitVars = { ACTOR_EN_RR, @@ -124,13 +125,13 @@ static InitChainEntry sInitChain[] = { ICHAIN_F32(targetArrowOffset, 30, ICHAIN_STOP), }; -void EnRr_Init(Actor* thisx, GlobalContext* globalCtx) { +void EnRr_Init(Actor* thisx, PlayState* play) { s32 pad; EnRr* this = THIS; Actor_ProcessInitChain(&this->actor, sInitChain); - Collider_InitAndSetCylinder(globalCtx, &this->collider1, &this->actor, &sCylinderInit1); - Collider_InitAndSetCylinder(globalCtx, &this->collider2, &this->actor, &sCylinderInit2); + Collider_InitAndSetCylinder(play, &this->collider1, &this->actor, &sCylinderInit1); + Collider_InitAndSetCylinder(play, &this->collider2, &this->actor, &sCylinderInit2); if (this->actor.params != ENRR_3) { this->actor.scale.y = 0.015f; this->actor.scale.x = 0.019f; @@ -158,17 +159,17 @@ void EnRr_Init(Actor* thisx, GlobalContext* globalCtx) { } this->actionFunc = func_808FAF94; - func_808FAD1C(this, globalCtx); + func_808FAD1C(this, play); } -void EnRr_Destroy(Actor* thisx, GlobalContext* globalCtx) { +void EnRr_Destroy(Actor* thisx, PlayState* play) { EnRr* this = THIS; - Collider_DestroyCylinder(globalCtx, &this->collider1); - Collider_DestroyCylinder(globalCtx, &this->collider2); + Collider_DestroyCylinder(play, &this->collider1); + Collider_DestroyCylinder(play, &this->collider2); } -void func_808FA01C(EnRr* this, GlobalContext* globalCtx, ColliderCylinder* collider) { +void func_808FA01C(EnRr* this, PlayState* play, ColliderCylinder* collider) { if (this->actor.colChkInfo.damageEffect == 2) { this->drawDmgEffScale = 0.85f; this->drawDmgEffAlpha = 4.0f; @@ -177,7 +178,7 @@ void func_808FA01C(EnRr* this, GlobalContext* globalCtx, ColliderCylinder* colli 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, + Actor_Spawn(&play->actorCtx, play, 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) { @@ -199,14 +200,14 @@ void func_808FA11C(EnRr* this) { Actor_SetColorFilter(&this->actor, 0x4000, 255, 0, 80); } -void func_808FA19C(EnRr* this, GlobalContext* globalCtx) { +void func_808FA19C(EnRr* this, PlayState* play) { this->unk_1EE = 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->drawDmgEffAlpha = 0.0f; - Actor_SpawnIceEffects(globalCtx, &this->actor, this->limbPos, 20, 2, this->actor.scale.y * 23.333334f, + Actor_SpawnIceEffects(play, &this->actor, this->limbPos, 20, 2, this->actor.scale.y * 23.333334f, this->actor.scale.y * 20.000002f); this->actor.flags |= ACTOR_FLAG_400; } @@ -288,8 +289,8 @@ void func_808FA3F8(EnRr* this, Player* player) { Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_SUISEN_DRINK); } -void func_808FA4F4(EnRr* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); +void func_808FA4F4(EnRr* this, PlayState* play) { + Player* player = GET_PLAYER(play); u32 sp38; s32 sp34; f32 sp30; @@ -305,15 +306,15 @@ void func_808FA4F4(EnRr* this, GlobalContext* globalCtx) { this->unk_20C = 0x800; if (((this->unk_1E2 == 0) && (gSaveContext.save.playerForm == PLAYER_FORM_HUMAN)) && - (GET_CUR_EQUIP_VALUE(EQUIP_SHIELD) == 1)) { + (GET_CUR_EQUIP_VALUE(EQUIP_TYPE_SHIELD) == EQUIP_VALUE_SHIELD_HERO)) { sp34 = true; - this->unk_1E2 = Inventory_DeleteEquipment(globalCtx, 1); + this->unk_1E2 = Inventory_DeleteEquipment(play, EQUIP_VALUE_SHIELD_HERO); } else { sp34 = false; } - if (sp34 && (Message_GetState(&globalCtx->msgCtx) == 0)) { - Message_StartTextbox(globalCtx, 0xF6, NULL); + if (sp34 && (Message_GetState(&play->msgCtx) == TEXT_STATE_NONE)) { + Message_StartTextbox(play, 0xF6, NULL); } if (this->actor.params == ENRR_0) { @@ -329,7 +330,7 @@ void func_808FA4F4(EnRr* this, GlobalContext* globalCtx) { player->actor.world.pos.y += sp2C; player->actor.world.pos.z += sp30 * Math_CosS(this->actor.shape.rot.y); - func_800B8D50(globalCtx, &this->actor, sp30, this->actor.shape.rot.y, sp2C, sp38); + func_800B8D50(play, &this->actor, sp30, this->actor.shape.rot.y, sp2C, sp38); Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_SUISEN_THROW); } } @@ -442,7 +443,7 @@ void func_808FA9CC(EnRr* this) { this->actionFunc = func_808FB710; } -s32 func_808FAA94(EnRr* this, GlobalContext* globalCtx) { +s32 func_808FAA94(EnRr* this, PlayState* play) { ColliderCylinder* sp2C; s32 flag = (this->collider1.base.acFlags & AC_HIT) != 0; @@ -466,18 +467,18 @@ s32 func_808FAA94(EnRr* this, GlobalContext* globalCtx) { } Actor_SetDropFlag(&this->actor, &sp2C->info); - func_808FA4F4(this, globalCtx); - func_808FA19C(this, globalCtx); + func_808FA4F4(this, play); + func_808FA19C(this, play); if (!Actor_ApplyDamage(&this->actor)) { - Enemy_StartFinishingBlow(globalCtx, &this->actor); + Enemy_StartFinishingBlow(play, &this->actor); if (this->actor.colChkInfo.damageEffect == 3) { func_808FA11C(this); this->collider1.base.acFlags &= ~AC_ON; this->collider2.base.acFlags &= ~AC_ON; func_808FA9CC(this); } else { - func_808FA01C(this, globalCtx, sp2C); + func_808FA01C(this, play, sp2C); func_808FA910(this); } } else if (this->actor.colChkInfo.damageEffect == 1) { @@ -489,7 +490,7 @@ s32 func_808FAA94(EnRr* this, GlobalContext* globalCtx) { func_808FA11C(this); func_808FA9CC(this); } else { - func_808FA01C(this, globalCtx, sp2C); + func_808FA01C(this, play, sp2C); func_808FA6B8(this); } return true; @@ -497,20 +498,20 @@ s32 func_808FAA94(EnRr* this, GlobalContext* globalCtx) { return false; } -void func_808FAC80(EnRr* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); +void func_808FAC80(EnRr* this, PlayState* play) { + Player* player = GET_PLAYER(play); if ((this->unk_1F0 == 0) && ((this->collider2.base.atFlags & AT_HIT) || (this->collider1.base.atFlags & AT_HIT))) { this->collider1.base.atFlags &= ~AT_HIT; this->collider2.base.atFlags &= ~AT_HIT; - if (globalCtx->grabPlayer(globalCtx, player)) { + if (play->grabPlayer(play, player)) { player->actor.parent = &this->actor; func_808FA3F8(this, player); } } } -void func_808FAD1C(EnRr* this, GlobalContext* globalCtx) { +void func_808FAD1C(EnRr* this, PlayState* play) { s32 i; EnRrStruct* ptr; @@ -541,7 +542,7 @@ void func_808FAD1C(EnRr* this, GlobalContext* globalCtx) { } } -void func_808FAE50(EnRr* this, GlobalContext* globalCtx) { +void func_808FAE50(EnRr* this, PlayState* play) { s32 i; EnRrStruct* ptr; @@ -565,12 +566,12 @@ void func_808FAE50(EnRr* this, GlobalContext* globalCtx) { } } -void func_808FAF94(EnRr* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); +void func_808FAF94(EnRr* this, PlayState* play) { + Player* player = GET_PLAYER(play); Math_SmoothStepToS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer, 10, 500, 0); this->actor.world.rot.y = this->actor.shape.rot.y; - if ((this->unk_1E6 == 0) && !(player->stateFlags2 & 0x80) && (Player_GetMask(globalCtx) != PLAYER_MASK_STONE) && + if ((this->unk_1E6 == 0) && !(player->stateFlags2 & 0x80) && (Player_GetMask(play) != PLAYER_MASK_STONE) && (this->actor.xzDistToPlayer < (8421.053f * this->actor.scale.x))) { func_808FA260(this); } else if ((this->actor.xzDistToPlayer < 400.0f) && (this->actor.speedXZ == 0.0f)) { @@ -578,10 +579,10 @@ void func_808FAF94(EnRr* this, GlobalContext* globalCtx) { } } -void func_808FB088(EnRr* this, GlobalContext* globalCtx) { +void func_808FB088(EnRr* this, PlayState* play) { Math_SmoothStepToS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer, 10, 500, 0); this->actor.world.rot.y = this->actor.shape.rot.y; - if (Player_GetMask(globalCtx) == PLAYER_MASK_STONE) { + if (Player_GetMask(play) == PLAYER_MASK_STONE) { func_808FA344(this); return; } @@ -625,10 +626,10 @@ void func_808FB088(EnRr* this, GlobalContext* globalCtx) { } } -void func_808FB1C0(EnRr* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); +void func_808FB1C0(EnRr* this, PlayState* play) { + Player* player = GET_PLAYER(play); - func_8013ECE0(this->actor.xyzDistToPlayerSq, 120, 2, 120); + Rumble_Request(this->actor.xyzDistToPlayerSq, 120, 2, 120); if (!(this->unk_1E4 & 7)) { Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_EYEGOLE_DEMO_EYE); } @@ -647,8 +648,8 @@ void func_808FB1C0(EnRr* this, GlobalContext* globalCtx) { } } -void func_808FB2C0(EnRr* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); +void func_808FB2C0(EnRr* this, PlayState* play) { + Player* player = GET_PLAYER(play); this->unk_1E6--; player->unk_AE8 = 0; @@ -658,12 +659,12 @@ void func_808FB2C0(EnRr* this, GlobalContext* globalCtx) { Math_StepToF(&this->unk_218, -(f32)this->collider1.dim.height, 5.0f); if (this->unk_1E6 == 0) { this->unk_1E1 = 0; - func_808FA4F4(this, globalCtx); + func_808FA4F4(this, play); func_808FA344(this); } } -void func_808FB398(EnRr* this, GlobalContext* globalCtx) { +void func_808FB398(EnRr* this, PlayState* play) { s32 i; s16 phi_v1; @@ -692,7 +693,7 @@ void func_808FB398(EnRr* this, GlobalContext* globalCtx) { } } -void func_808FB42C(EnRr* this, GlobalContext* globalCtx) { +void func_808FB42C(EnRr* this, PlayState* play) { s32 pad; s32 i; EnRrStruct* ptr; @@ -710,9 +711,9 @@ void func_808FB42C(EnRr* this, GlobalContext* globalCtx) { if (this->unk_1E4 >= 95) { if (this->unk_1E2 != 0) { - Item_DropCollectible(globalCtx, &this->actor.world.pos, ITEM00_SHIELD_HERO); + Item_DropCollectible(play, &this->actor.world.pos, ITEM00_SHIELD_HERO); } - Item_DropCollectibleRandom(globalCtx, &this->actor, &this->actor.world.pos, 0x90); + Item_DropCollectibleRandom(play, &this->actor, &this->actor.world.pos, 0x90); Actor_MarkForDeath(&this->actor); } else if (this->unk_1E4 == 88) { Vec3f sp74; @@ -720,8 +721,8 @@ void func_808FB42C(EnRr* this, GlobalContext* globalCtx) { sp74.x = this->actor.world.pos.x; sp74.y = this->actor.world.pos.y + 20.0f; sp74.z = this->actor.world.pos.z; - func_800B3030(globalCtx, &sp74, &gZeroVec3f, &gZeroVec3f, 100, 0, 0); - SoundSource_PlaySfxAtFixedWorldPos(globalCtx, &sp74, 11, NA_SE_EN_EXTINCT); + func_800B3030(play, &sp74, &gZeroVec3f, &gZeroVec3f, 100, 0, 0); + SoundSource_PlaySfxAtFixedWorldPos(play, &sp74, 11, NA_SE_EN_EXTINCT); } else { temp_f20 = this->actor.scale.y * 66.66667f; @@ -731,7 +732,7 @@ void func_808FB42C(EnRr* this, GlobalContext* globalCtx) { } } -void func_808FB680(EnRr* this, GlobalContext* globalCtx) { +void func_808FB680(EnRr* this, PlayState* play) { if (this->unk_1E6 == 0) { this->actionFunc = func_808FAF94; } else { @@ -743,31 +744,31 @@ void func_808FB680(EnRr* this, GlobalContext* globalCtx) { } } -void func_808FB710(EnRr* this, GlobalContext* globalCtx) { +void func_808FB710(EnRr* this, PlayState* play) { this->unk_1EE--; if (this->unk_1EE == 0) { - func_808FA19C(this, globalCtx); + func_808FA19C(this, play); func_808FA870(this); this->actionFunc = func_808FAF94; } else if ((this->actor.colChkInfo.health == 0) && (this->unk_1EE == 77)) { - func_808FA19C(this, globalCtx); + func_808FA19C(this, play); func_808FA910(this); } } -void func_808FB794(EnRr* this, GlobalContext* globalCtx) { +void func_808FB794(EnRr* this, PlayState* play) { Vec3f sp2C; if ((this->actor.depthInWater < this->collider1.dim.height) && (this->actor.depthInWater > 1.0f) && - ((globalCtx->gameplayFrames % 9) == 0)) { + ((play->gameplayFrames % 9) == 0)) { sp2C.x = this->actor.world.pos.x; sp2C.y = this->actor.world.pos.y + this->actor.depthInWater; sp2C.z = this->actor.world.pos.z; - EffectSsGRipple_Spawn(globalCtx, &sp2C, this->actor.scale.x * 34210.527f, this->actor.scale.x * 60526.316f, 0); + EffectSsGRipple_Spawn(play, &sp2C, this->actor.scale.x * 34210.527f, this->actor.scale.x * 60526.316f, 0); } } -void EnRr_Update(Actor* thisx, GlobalContext* globalCtx) { +void EnRr_Update(Actor* thisx, PlayState* play) { EnRr* this = THIS; EnRrStruct* ptr; s32 i; @@ -787,13 +788,13 @@ void EnRr_Update(Actor* thisx, GlobalContext* globalCtx) { } Actor_SetFocus(&this->actor, this->actor.scale.y * 2000.0f); - func_808FAE50(this, globalCtx); + func_808FAE50(this, play); - if (!func_808FAA94(this, globalCtx)) { - func_808FAC80(this, globalCtx); + if (!func_808FAA94(this, play)) { + func_808FAC80(this, play); } - this->actionFunc(this, globalCtx); + this->actionFunc(this, play); if (this->actor.params == ENRR_2) { this->actor.speedXZ = 0.0f; @@ -802,11 +803,11 @@ void EnRr_Update(Actor* thisx, GlobalContext* globalCtx) { } Actor_MoveWithGravity(&this->actor); - Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 30.0f, this->collider1.dim.radius, 0.0f, 0x5D); - func_808FB794(this, globalCtx); + Actor_UpdateBgCheckInfo(play, &this->actor, 30.0f, this->collider1.dim.radius, 0.0f, 0x5D); + func_808FB794(this, play); if (this->unk_1FC > 0) { - Player* player = GET_PLAYER(globalCtx); + Player* player = GET_PLAYER(play); if (!(player->stateFlags2 & 0x80)) { this->unk_1FC--; @@ -819,11 +820,11 @@ void EnRr_Update(Actor* thisx, GlobalContext* globalCtx) { Collider_UpdateCylinder(&this->actor, &this->collider1); if ((this->actionFunc != func_808FB42C) && (this->actionFunc != func_808FB398)) { - CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->collider1.base); - CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->collider2.base); + CollisionCheck_SetAC(play, &play->colChkCtx, &this->collider1.base); + CollisionCheck_SetAC(play, &play->colChkCtx, &this->collider2.base); if ((this->unk_1F0 == 0) && (this->actionFunc == func_808FB088) && (this->unk_1EE == 0)) { - CollisionCheck_SetAT(globalCtx, &globalCtx->colChkCtx, &this->collider1.base); - CollisionCheck_SetAT(globalCtx, &globalCtx->colChkCtx, &this->collider2.base); + CollisionCheck_SetAT(play, &play->colChkCtx, &this->collider1.base); + CollisionCheck_SetAT(play, &play->colChkCtx, &this->collider2.base); } else { this->collider2.base.atFlags &= ~AT_HIT; this->collider1.base.atFlags &= ~AT_HIT; @@ -835,7 +836,7 @@ void EnRr_Update(Actor* thisx, GlobalContext* globalCtx) { this->collider1.base.acFlags &= ~AC_HIT; } - CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider1.base); + CollisionCheck_SetOC(play, &play->colChkCtx, &this->collider1.base); if (this->unk_1EE == 0) { Math_ScaledStepToS(&this->unk_1F4, this->unk_1F6, 50); @@ -866,8 +867,8 @@ void EnRr_Update(Actor* thisx, GlobalContext* globalCtx) { } } -void EnRr_Draw(Actor* thisx, GlobalContext* globalCtx2) { - GlobalContext* globalCtx = globalCtx2; +void EnRr_Draw(Actor* thisx, PlayState* play2) { + PlayState* play = play2; EnRr* this = THIS; Mtx* matrix; Vec3f* vecPtr; @@ -876,66 +877,66 @@ void EnRr_Draw(Actor* thisx, GlobalContext* globalCtx2) { Vec3f spA4; f32 temp_f20; - matrix = GRAPH_ALLOC(globalCtx->state.gfxCtx, sizeof(Mtx) * 4); + matrix = GRAPH_ALLOC(play->state.gfxCtx, sizeof(Mtx) * 4); - OPEN_DISPS(globalCtx->state.gfxCtx); + OPEN_DISPS(play->state.gfxCtx); - func_8012C28C(globalCtx->state.gfxCtx); + func_8012C28C(play->state.gfxCtx); gSPSegment(POLY_OPA_DISP++, 0x0C, matrix); gSPSegment(POLY_OPA_DISP++, 0x08, - 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)); + Gfx_TwoTexScroll(play->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->limbPos[0]; - gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(play->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); - Actor_DrawDamageEffects(globalCtx, &this->actor, this->limbPos, ARRAY_COUNT(this->limbPos), + Actor_DrawDamageEffects(play, &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); + CLOSE_DISPS(play->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 e2c935b47..072e78105 100644 --- a/src/overlays/actors/ovl_En_Rr/z_en_rr.h +++ b/src/overlays/actors/ovl_En_Rr/z_en_rr.h @@ -5,7 +5,7 @@ struct EnRr; -typedef void (*EnRrActionFunc)(struct EnRr*, GlobalContext*); +typedef void (*EnRrActionFunc)(struct EnRr*, PlayState*); enum { /* 0 */ ENRR_0, 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 cb110f780..d7a4f9170 100644 --- a/src/overlays/actors/ovl_En_Rsn/z_en_rsn.c +++ b/src/overlays/actors/ovl_En_Rsn/z_en_rsn.c @@ -11,12 +11,12 @@ #define THIS ((EnRsn*)thisx) -void EnRsn_Init(Actor* thisx, GlobalContext* globalCtx); -void EnRsn_Destroy(Actor* thisx, GlobalContext* globalCtx); -void EnRsn_Update(Actor* thisx, GlobalContext* globalCtx); -void EnRsn_Draw(Actor* thisx, GlobalContext* globalCtx); +void EnRsn_Init(Actor* thisx, PlayState* play); +void EnRsn_Destroy(Actor* thisx, PlayState* play); +void EnRsn_Update(Actor* thisx, PlayState* play); +void EnRsn_Draw(Actor* thisx, PlayState* play); -void func_80C25D84(EnRsn* this, GlobalContext* globalCtx); +void func_80C25D84(EnRsn* this, PlayState* play); const ActorInit En_Rsn_InitVars = { ACTOR_EN_RSN, @@ -30,67 +30,65 @@ const ActorInit En_Rsn_InitVars = { (ActorFunc)EnRsn_Draw, }; -static AnimationInfo sAnimations[] = { { &object_rs_Anim_00788C, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, 0.0f } }; +static AnimationInfo sAnimationInfo[] = { { &gBombShopkeeperSwayAnim, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, 0.0f } }; void func_80C25D40(EnRsn* this) { - Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 0); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, 0); this->actionFunc = func_80C25D84; } -void func_80C25D84(EnRsn* this, GlobalContext* globalCtx) { +void func_80C25D84(EnRsn* this, PlayState* play) { } -void EnRsn_Init(Actor* thisx, GlobalContext* globalCtx) { +void EnRsn_Init(Actor* thisx, PlayState* play) { 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); + SkelAnime_InitFlex(play, &this->skelAnime, &gBombShopkeeperSkel, &gBombShopkeeperWalkAnim, NULL, NULL, 0); this->actor.flags &= ~ACTOR_FLAG_1; func_80C25D40(this); } -void EnRsn_Destroy(Actor* thisx, GlobalContext* globalCtx) { +void EnRsn_Destroy(Actor* thisx, PlayState* play) { EnRsn* this = THIS; - SkelAnime_Free(&this->skelAnime, globalCtx); + SkelAnime_Free(&this->skelAnime, play); } -void EnRsn_Update(Actor* thisx, GlobalContext* globalCtx) { +void EnRsn_Update(Actor* thisx, PlayState* play) { EnRsn* this = THIS; - this->actionFunc(this, globalCtx); + this->actionFunc(this, play); Actor_MoveWithGravity(&this->actor); SkelAnime_Update(&this->skelAnime); - func_800E9250(globalCtx, &this->actor, &this->unk1D8, &this->unk1DE, this->actor.focus.pos); + Actor_TrackPlayer(play, &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) { +s32 EnRsn_OverrideLimbDraw(PlayState* play, 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) { +void EnRsn_PostLimbDraw(PlayState* play, 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); } } -void EnRsn_Draw(Actor* thisx, GlobalContext* globalCtx) { +void EnRsn_Draw(Actor* thisx, PlayState* play) { EnRsn* this = THIS; - OPEN_DISPS(globalCtx->state.gfxCtx); - func_8012C5B0(globalCtx->state.gfxCtx); - gSPSegment(POLY_OPA_DISP++, 0x08, Lib_SegmentedToVirtual(object_rs_Tex_005458)); - SkelAnime_DrawFlexOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, + OPEN_DISPS(play->state.gfxCtx); + func_8012C5B0(play->state.gfxCtx); + gSPSegment(POLY_OPA_DISP++, 0x08, Lib_SegmentedToVirtual(gBombShopkeeperEyeTex)); + SkelAnime_DrawFlexOpa(play, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, EnRsn_OverrideLimbDraw, EnRsn_PostLimbDraw, &this->actor); - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->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..b54014438 100644 --- a/src/overlays/actors/ovl_En_Rsn/z_en_rsn.h +++ b/src/overlays/actors/ovl_En_Rsn/z_en_rsn.h @@ -5,11 +5,11 @@ struct EnRsn; -typedef void (*EnRsnActionFunc)(struct EnRsn*, GlobalContext*); +typedef void (*EnRsnActionFunc)(struct EnRsn*, PlayState*); 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 3e9538f61..0333cb011 100644 --- a/src/overlays/actors/ovl_En_Ru/z_en_ru.c +++ b/src/overlays/actors/ovl_En_Ru/z_en_ru.c @@ -10,12 +10,12 @@ #define THIS ((EnRu*)thisx) -void EnRu_Init(Actor* thisx, GlobalContext* globalCtx); -void EnRu_Destroy(Actor* thisx, GlobalContext* globalCtx); -void EnRu_Update(Actor* thisx, GlobalContext* globalCtx); -void EnRu_Draw(Actor* thisx, GlobalContext* globalCtx); +void EnRu_Init(Actor* thisx, PlayState* play); +void EnRu_Destroy(Actor* thisx, PlayState* play); +void EnRu_Update(Actor* thisx, PlayState* play); +void EnRu_Draw(Actor* thisx, PlayState* play); -void func_80A38DF4(EnRu* this, GlobalContext* globalCtx); +void func_80A38DF4(EnRu* this, PlayState* play); #if 0 const ActorInit En_Ru_InitVars = { diff --git a/src/overlays/actors/ovl_En_Ru/z_en_ru.h b/src/overlays/actors/ovl_En_Ru/z_en_ru.h index b368fb584..29c903aff 100644 --- a/src/overlays/actors/ovl_En_Ru/z_en_ru.h +++ b/src/overlays/actors/ovl_En_Ru/z_en_ru.h @@ -5,12 +5,12 @@ struct EnRu; -typedef void (*EnRuActionFunc)(struct EnRu*, GlobalContext*); +typedef void (*EnRuActionFunc)(struct EnRu*, PlayState*); typedef struct EnRu { - /* 0x0000 */ Actor actor; - /* 0x0144 */ EnRuActionFunc actionFunc; - /* 0x0148 */ char unk_148[0x30C]; + /* 0x000 */ Actor actor; + /* 0x144 */ EnRuActionFunc actionFunc; + /* 0x148 */ char unk_148[0x30C]; } EnRu; // size = 0x454 extern const ActorInit En_Ru_InitVars; diff --git a/src/overlays/actors/ovl_En_Ruppecrow/z_en_ruppecrow.c b/src/overlays/actors/ovl_En_Ruppecrow/z_en_ruppecrow.c index 2b4026858..66db63c65 100644 --- a/src/overlays/actors/ovl_En_Ruppecrow/z_en_ruppecrow.c +++ b/src/overlays/actors/ovl_En_Ruppecrow/z_en_ruppecrow.c @@ -17,28 +17,28 @@ enum { ENRUPPECROW_EFFECT_LIGHT = 20, }; -void EnRuppecrow_Init(Actor* thisx, GlobalContext* globalCtx); -void EnRuppecrow_Destroy(Actor* thisx, GlobalContext* globalCtx); -void EnRuppecrow_Update(Actor* thisx, GlobalContext* globalCtx); -void EnRuppecrow_Draw(Actor* thisx, GlobalContext* globalCtx); -void EnRuppecrow_HandleSong(EnRuppecrow*, GlobalContext*); -s32 EnRuppecrow_UpdateCollision(EnRuppecrow*, GlobalContext*); +void EnRuppecrow_Init(Actor* thisx, PlayState* play); +void EnRuppecrow_Destroy(Actor* thisx, PlayState* play); +void EnRuppecrow_Update(Actor* thisx, PlayState* play); +void EnRuppecrow_Draw(Actor* thisx, PlayState* play); +void EnRuppecrow_HandleSong(EnRuppecrow*, PlayState*); +s32 EnRuppecrow_UpdateCollision(EnRuppecrow*, PlayState*); void EnRuppecrow_UpdateRupees(EnRuppecrow*); -void EnRuppecrow_UpdateDamage(EnRuppecrow*, GlobalContext*); +void EnRuppecrow_UpdateDamage(EnRuppecrow*, PlayState*); void EnRuppecrow_HandleDeath(EnRuppecrow*); -void EnRuppecrow_FallToDespawn(EnRuppecrow*, GlobalContext*); -void EnRuppecrow_ShatterIce(EnRuppecrow*, GlobalContext*); -void EnRuppecrow_UpdatePosition(EnRuppecrow*, GlobalContext*); -s32 EnRuppecrow_CheckPlayedMatchingSong(GlobalContext*); -void EnRuppecrow_HandleSongCutscene(EnRuppecrow*, GlobalContext*); +void EnRuppecrow_FallToDespawn(EnRuppecrow*, PlayState*); +void EnRuppecrow_ShatterIce(EnRuppecrow*, PlayState*); +void EnRuppecrow_UpdatePosition(EnRuppecrow*, PlayState*); +s32 EnRuppecrow_CheckPlayedMatchingSong(PlayState*); +void EnRuppecrow_HandleSongCutscene(EnRuppecrow*, PlayState*); s32 EnRuppecrow_ReachedPointClockwise(EnRuppecrow*, Path*, s32); s32 EnRuppecrow_ReachedPointCounterClockwise(EnRuppecrow*, Path*, s32); f32 EnRuppecrow_GetPointDirection(Path*, s32, PosRot*, Vec3s*); -s32 EnRuppecrow_CanSpawnBlueRupees(GlobalContext*); -void EnRuppecrow_SpawnRupee(EnRuppecrow*, GlobalContext*); -void EnRuppecrow_FlyWhileDroppingRupees(EnRuppecrow*, GlobalContext*); -void EnRuppecrow_UpdateSpeed(EnRuppecrow*, GlobalContext*); -void EnRuppecrow_FlyToDespawn(EnRuppecrow*, GlobalContext*); +s32 EnRuppecrow_CanSpawnBlueRupees(PlayState*); +void EnRuppecrow_SpawnRupee(EnRuppecrow*, PlayState*); +void EnRuppecrow_FlyWhileDroppingRupees(EnRuppecrow*, PlayState*); +void EnRuppecrow_UpdateSpeed(EnRuppecrow*, PlayState*); +void EnRuppecrow_FlyToDespawn(EnRuppecrow*, PlayState*); const ActorInit En_Ruppecrow_InitVars = { ACTOR_EN_RUPPECROW, @@ -75,7 +75,7 @@ static ColliderJntSphInit sJntSphInit = { OC2_TYPE_1, COLSHAPE_JNTSPH, }, - 1, + ARRAY_COUNT(sJntSphElementsInit), sJntSphElementsInit, }; @@ -121,7 +121,7 @@ static InitChainEntry sInitChain[] = { ICHAIN_F32(targetArrowOffset, 2000, ICHAIN_STOP), }; -s32 EnRuppecrow_UpdateCollision(EnRuppecrow* this, GlobalContext* globalCtx) { +s32 EnRuppecrow_UpdateCollision(EnRuppecrow* this, PlayState* play) { s32 pad; this->collider.elements->dim.worldSphere.center.x = this->actor.world.pos.x; @@ -129,8 +129,8 @@ s32 EnRuppecrow_UpdateCollision(EnRuppecrow* this, GlobalContext* globalCtx) { sJntSphInit.elements->dim.modelSphere.center.y + this->actor.world.pos.y; this->collider.elements->dim.worldSphere.center.z = this->actor.world.pos.z; - CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); - Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 12.0f, 25.0f, 50.0f, 0x07); + CollisionCheck_SetAC(play, &play->colChkCtx, &this->collider.base); + Actor_UpdateBgCheckInfo(play, &this->actor, 12.0f, 25.0f, 50.0f, 0x07); return true; } @@ -221,16 +221,16 @@ f32 EnRuppecrow_GetPointDirection(Path* path, s32 pointIndex, PosRot* world, Vec return point.y - world->pos.y; } -void EnRuppecrow_ShatterIce(EnRuppecrow* this, GlobalContext* globalCtx) { +void EnRuppecrow_ShatterIce(EnRuppecrow* this, PlayState* play) { if (this->currentEffect == ENRUPPECROW_EFFECT_ICE) { this->currentEffect = ENRUPPECROW_EFFECT_NONE; this->unk_2C8 = 0.0f; - Actor_SpawnIceEffects(globalCtx, &this->actor, this->limbPos, ARRAY_COUNT(this->limbPos), 0x2, 0.2f, 0.2f); + Actor_SpawnIceEffects(play, &this->actor, this->limbPos, ARRAY_COUNT(this->limbPos), 0x2, 0.2f, 0.2f); } } -s32 EnRuppecrow_CanSpawnBlueRupees(GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); +s32 EnRuppecrow_CanSpawnBlueRupees(PlayState* play) { + Player* player = GET_PLAYER(play); switch (player->transformation) { case PLAYER_FORM_DEKU: @@ -262,8 +262,8 @@ void EnRuppecrow_UpdateRupees(EnRuppecrow* this) { } } -void EnRuppecrow_SpawnRupee(EnRuppecrow* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); +void EnRuppecrow_SpawnRupee(EnRuppecrow* this, PlayState* play) { + Player* player = GET_PLAYER(play); f32 xOffset; EnItem00* rupee; s16 rupeeIndex = this->rupeeIndex; @@ -274,11 +274,11 @@ void EnRuppecrow_SpawnRupee(EnRuppecrow* this, GlobalContext* globalCtx) { xOffset = 0.0f; } - if (EnRuppecrow_CanSpawnBlueRupees(globalCtx) && (this->rupeeIndex % 5) == 4) { + if (EnRuppecrow_CanSpawnBlueRupees(play) && (this->rupeeIndex % 5) == 4) { if (this->rupeeIndex == 19) { - rupee = (EnItem00*)Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_ITEM00, - this->actor.world.pos.x + xOffset, this->actor.world.pos.y, - this->actor.world.pos.z, 0x0, 0x0, 0x0, ITEM00_RUPEE_RED); + rupee = (EnItem00*)Actor_Spawn(&play->actorCtx, play, ACTOR_EN_ITEM00, this->actor.world.pos.x + xOffset, + this->actor.world.pos.y, this->actor.world.pos.z, 0x0, 0x0, 0x0, + ITEM00_RUPEE_RED); this->rupees[rupeeIndex] = rupee; this->rupees[rupeeIndex]->actor.gravity = -5.0f; this->rupees[rupeeIndex]->actor.velocity.y = 0.0f; @@ -287,9 +287,9 @@ void EnRuppecrow_SpawnRupee(EnRuppecrow* this, GlobalContext* globalCtx) { rupee->unk152 = 60; 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, - this->actor.world.pos.z, 0x0, 0x0, 0x0, ITEM00_RUPEE_BLUE); + rupee = (EnItem00*)Actor_Spawn(&play->actorCtx, play, ACTOR_EN_ITEM00, this->actor.world.pos.x + xOffset, + this->actor.world.pos.y, this->actor.world.pos.z, 0x0, 0x0, 0x0, + ITEM00_RUPEE_BLUE); this->rupees[rupeeIndex] = rupee; this->rupees[rupeeIndex]->actor.gravity = -5.0f; this->rupees[rupeeIndex]->actor.velocity.y = 0.0f; @@ -300,7 +300,7 @@ void EnRuppecrow_SpawnRupee(EnRuppecrow* this, GlobalContext* globalCtx) { } } else if (this->rupeeIndex == 19) { rupee = - (EnItem00*)Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_ITEM00, this->actor.world.pos.x + xOffset, + (EnItem00*)Actor_Spawn(&play->actorCtx, play, ACTOR_EN_ITEM00, this->actor.world.pos.x + xOffset, this->actor.world.pos.y, this->actor.world.pos.z, 0x0, 0x0, 0x0, ITEM00_RUPEE_RED); this->rupees[rupeeIndex] = rupee; this->rupees[rupeeIndex]->actor.gravity = -5.0f; @@ -311,7 +311,7 @@ void EnRuppecrow_SpawnRupee(EnRuppecrow* this, GlobalContext* globalCtx) { 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, + (EnItem00*)Actor_Spawn(&play->actorCtx, play, ACTOR_EN_ITEM00, this->actor.world.pos.x + xOffset, this->actor.world.pos.y, this->actor.world.pos.z, 0x0, 0x0, 0x0, ITEM00_RUPEE_GREEN); this->rupees[rupeeIndex] = rupee; this->rupees[rupeeIndex]->actor.gravity = -5.0f; @@ -325,7 +325,7 @@ void EnRuppecrow_SpawnRupee(EnRuppecrow* this, GlobalContext* globalCtx) { this->rupeeIndex++; } -void EnRuppecrow_UpdatePosition(EnRuppecrow* this, GlobalContext* globalCtx) { +void EnRuppecrow_UpdatePosition(EnRuppecrow* this, PlayState* play) { Vec3s nextPointDirection; EnRuppecrow_GetPointDirection(this->path, this->currentPoint, &this->actor.world, &nextPointDirection); @@ -346,8 +346,8 @@ void EnRuppecrow_UpdatePosition(EnRuppecrow* this, GlobalContext* globalCtx) { } if (this->actionFunc == EnRuppecrow_FlyWhileDroppingRupees && - (!EnRuppecrow_CanSpawnBlueRupees(globalCtx) || (this->currentPoint % -2) == 0)) { - EnRuppecrow_SpawnRupee(this, globalCtx); + (!EnRuppecrow_CanSpawnBlueRupees(play) || (this->currentPoint % -2) == 0)) { + EnRuppecrow_SpawnRupee(this, play); } } } else if (EnRuppecrow_ReachedPointClockwise(this, this->path, this->currentPoint)) { @@ -358,38 +358,38 @@ void EnRuppecrow_UpdatePosition(EnRuppecrow* this, GlobalContext* globalCtx) { } if (this->actionFunc == EnRuppecrow_FlyWhileDroppingRupees && - (!EnRuppecrow_CanSpawnBlueRupees(globalCtx) || (this->currentPoint % -2) == 0)) { - EnRuppecrow_SpawnRupee(this, globalCtx); + (!EnRuppecrow_CanSpawnBlueRupees(play) || (this->currentPoint % -2) == 0)) { + EnRuppecrow_SpawnRupee(this, play); } } } -s32 EnRuppecrow_CheckPlayedMatchingSong(GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); +s32 EnRuppecrow_CheckPlayedMatchingSong(PlayState* play) { + Player* player = GET_PLAYER(play); - if (globalCtx->msgCtx.ocarinaMode == 0x3) { + if (play->msgCtx.ocarinaMode == 0x3) { switch (player->transformation) { case PLAYER_FORM_DEKU: - if (globalCtx->msgCtx.unk1202E == OCARINA_SONG_SONATA) { + if (play->msgCtx.lastPlayedSong == OCARINA_SONG_SONATA) { return true; } break; case PLAYER_FORM_GORON: - if (globalCtx->msgCtx.unk1202E == OCARINA_SONG_GORON_LULLABY) { + if (play->msgCtx.lastPlayedSong == OCARINA_SONG_GORON_LULLABY) { return true; } break; case PLAYER_FORM_ZORA: - if (globalCtx->msgCtx.unk1202E == OCARINA_SONG_NEW_WAVE) { + if (play->msgCtx.lastPlayedSong == OCARINA_SONG_NEW_WAVE) { return true; } break; case PLAYER_FORM_HUMAN: - if (globalCtx->msgCtx.unk1202E == OCARINA_SONG_SONATA) { + if (play->msgCtx.lastPlayedSong == OCARINA_SONG_SONATA) { return true; - } else if (globalCtx->msgCtx.unk1202E == OCARINA_SONG_GORON_LULLABY) { + } else if (play->msgCtx.lastPlayedSong == OCARINA_SONG_GORON_LULLABY) { return true; - } else if (globalCtx->msgCtx.unk1202E == OCARINA_SONG_NEW_WAVE) { + } else if (play->msgCtx.lastPlayedSong == OCARINA_SONG_NEW_WAVE) { return true; } break; @@ -399,8 +399,8 @@ s32 EnRuppecrow_CheckPlayedMatchingSong(GlobalContext* globalCtx) { return false; } -void EnRuppecrow_UpdateSpeed(EnRuppecrow* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); +void EnRuppecrow_UpdateSpeed(EnRuppecrow* this, PlayState* play) { + Player* player = GET_PLAYER(play); switch (player->transformation) { case PLAYER_FORM_DEKU: @@ -440,7 +440,7 @@ void EnRuppecrow_HandleDeath(EnRuppecrow* this) { this->actor.speedXZ *= Math_CosS(this->actor.world.rot.x); this->actor.velocity.y = 0.0f; - Animation_Change(&this->skelAnime, &gGuayFlyAnim, 0.4f, 0.0f, 0.0f, 0x1, -3.0f); + Animation_Change(&this->skelAnime, &gGuayFlyAnim, 0.4f, 0.0f, 0.0f, ANIMMODE_LOOP_INTERP, -3.0f); this->actor.shape.yOffset = 0.0f; this->actor.targetArrowOffset = 0.0f; @@ -474,7 +474,7 @@ void EnRuppecrow_HandleDeath(EnRuppecrow* this) { this->actionFunc = EnRuppecrow_FallToDespawn; } -void EnRuppecrow_UpdateDamage(EnRuppecrow* this, GlobalContext* globalCtx) { +void EnRuppecrow_UpdateDamage(EnRuppecrow* this, PlayState* play) { if (this->collider.base.acFlags & AC_HIT) { this->collider.base.acFlags &= ~AC_HIT; Actor_SetDropFlag(&this->actor, &this->collider.elements->info); @@ -482,17 +482,17 @@ void EnRuppecrow_UpdateDamage(EnRuppecrow* this, GlobalContext* globalCtx) { if (this->actor.colChkInfo.damageEffect != 0x1) { this->actor.colChkInfo.health = 0; this->actor.flags &= ~ACTOR_FLAG_1; - Enemy_StartFinishingBlow(globalCtx, &this->actor); + Enemy_StartFinishingBlow(play, &this->actor); EnRuppecrow_HandleDeath(this); } } } -void EnRuppecrow_HandleSong(EnRuppecrow* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); +void EnRuppecrow_HandleSong(EnRuppecrow* this, PlayState* play) { + Player* player = GET_PLAYER(play); - EnRuppecrow_UpdatePosition(this, globalCtx); - if (this->actor.xzDistToPlayer < 1000.0f && EnRuppecrow_CheckPlayedMatchingSong(globalCtx)) { + EnRuppecrow_UpdatePosition(this, play); + if (this->actor.xzDistToPlayer < 1000.0f && EnRuppecrow_CheckPlayedMatchingSong(play)) { // If Link is in front, the guay will turn around and go the other way if (Actor_IsFacingPlayer(&this->actor, 0x4000)) { this->isGoingCounterClockwise |= 1; @@ -517,17 +517,17 @@ void EnRuppecrow_HandleSong(EnRuppecrow* this, GlobalContext* globalCtx) { this->yOffset += 0x1000; this->actor.shape.yOffset = Math_SinS(this->yOffset) * 500.0f; - if ((globalCtx->state.frames % 43) == 0) { + if ((play->state.frames % 43) == 0) { Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_KAICHO_CRY); } } -void EnRuppecrow_HandleSongCutscene(EnRuppecrow* this, GlobalContext* globalCtx) { - EnRuppecrow_UpdatePosition(this, globalCtx); +void EnRuppecrow_HandleSongCutscene(EnRuppecrow* this, PlayState* play) { + EnRuppecrow_UpdatePosition(this, play); if (ActorCutscene_GetCanPlayNext(this->actor.cutscene)) { ActorCutscene_Start(this->actor.cutscene, &this->actor); - EnRuppecrow_UpdateSpeed(this, globalCtx); + EnRuppecrow_UpdateSpeed(this, play); this->actionFunc = EnRuppecrow_FlyWhileDroppingRupees; } else { ActorCutscene_SetIntentToPlay(this->actor.cutscene); @@ -536,14 +536,14 @@ void EnRuppecrow_HandleSongCutscene(EnRuppecrow* this, GlobalContext* globalCtx) Actor_MoveWithoutGravity(&this->actor); } -void EnRuppecrow_FlyWhileDroppingRupees(EnRuppecrow* this, GlobalContext* globalCtx) { - EnRuppecrow_UpdatePosition(this, globalCtx); +void EnRuppecrow_FlyWhileDroppingRupees(EnRuppecrow* this, PlayState* play) { + EnRuppecrow_UpdatePosition(this, play); if (this->rupeeIndex >= ENRUPPECROW_RUPEE_COUNT) { // Finished spawning rupees; fly up and then despawn this->speedModifier = 6.0f; - // Source of the "Termina Field Guay Glitch"; guay will no longer fall if killed after this point + //! @bug: Source of the "Termina Field Guay Glitch"; guay will no longer fall if killed after this point this->actor.gravity = 0.0f; Math_ApproachF(&this->actor.speedXZ, 6.0f, 0.2f, 0.5f); @@ -554,7 +554,7 @@ void EnRuppecrow_FlyWhileDroppingRupees(EnRuppecrow* this, GlobalContext* global Actor_MoveWithGravity(&this->actor); } else { if (ActorCutscene_GetCurrentIndex() != this->actor.cutscene) { - EnRuppecrow_UpdateSpeed(this, globalCtx); + EnRuppecrow_UpdateSpeed(this, play); Math_ApproachF(&this->actor.speedXZ, this->speedModifier, 0.2f, 0.5f); } @@ -562,13 +562,13 @@ void EnRuppecrow_FlyWhileDroppingRupees(EnRuppecrow* this, GlobalContext* global this->yOffset += 0x1000; this->actor.shape.yOffset = Math_SinS(this->yOffset) * 500.0f; - if ((globalCtx->state.frames % 43) == 0) { + if ((play->state.frames % 43) == 0) { Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_KAICHO_CRY); } } } -void EnRuppecrow_FlyToDespawn(EnRuppecrow* this, GlobalContext* globalCtx) { +void EnRuppecrow_FlyToDespawn(EnRuppecrow* this, PlayState* play) { if (this->actor.bgCheckFlags & 0x8) { this->actor.world.rot.y *= -0x1; } @@ -584,13 +584,13 @@ void EnRuppecrow_FlyToDespawn(EnRuppecrow* this, GlobalContext* globalCtx) { Actor_MoveWithGravity(&this->actor); - if ((globalCtx->state.frames % 43) == 0) { + if ((play->state.frames % 43) == 0) { Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_KAICHO_CRY); } } } -void EnRuppecrow_FallToDespawn(EnRuppecrow* this, GlobalContext* globalCtx) { +void EnRuppecrow_FallToDespawn(EnRuppecrow* this, PlayState* play) { Math_StepToF(&this->actor.speedXZ, 0.0f, 0.5f); if (this->currentEffect != ENRUPPECROW_EFFECT_ICE) { @@ -609,11 +609,11 @@ void EnRuppecrow_FallToDespawn(EnRuppecrow* this, GlobalContext* globalCtx) { } if (this->actor.bgCheckFlags & 0x1 || this->actor.floorHeight == BGCHECK_Y_MIN) { - EnRuppecrow_ShatterIce(this, globalCtx); - func_800B3030(globalCtx, &this->actor.world.pos, &gZeroVec3f, &gZeroVec3f, (this->actor.scale.x * 10000.0f), - 0x0, 0x0); + EnRuppecrow_ShatterIce(this, play); + func_800B3030(play, &this->actor.world.pos, &gZeroVec3f, &gZeroVec3f, (this->actor.scale.x * 10000.0f), 0x0, + 0x0); - SoundSource_PlaySfxAtFixedWorldPos(globalCtx, &this->actor.world.pos, 0xB, NA_SE_EN_EXTINCT); + SoundSource_PlaySfxAtFixedWorldPos(play, &this->actor.world.pos, 0xB, NA_SE_EN_EXTINCT); Actor_MarkForDeath(&this->actor); return; } @@ -622,24 +622,24 @@ void EnRuppecrow_FallToDespawn(EnRuppecrow* this, GlobalContext* globalCtx) { Actor_MoveWithGravity(&this->actor); } -void EnRuppecrow_Init(Actor* thisx, GlobalContext* globalCtx2) { - GlobalContext* globalCtx = globalCtx2; +void EnRuppecrow_Init(Actor* thisx, PlayState* play2) { + PlayState* play = play2; EnRuppecrow* this = THIS; Actor_ProcessInitChain(&this->actor, sInitChain); - SkelAnime_InitFlex(globalCtx, &this->skelAnime, &gGuaySkel, &gGuayFlyAnim, this->joinTable, this->morphTable, + SkelAnime_InitFlex(play, &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); - Collider_InitAndSetJntSph(globalCtx, &this->collider, &this->actor, &sJntSphInit, &this->colliderElement); + Collider_InitJntSph(play, &this->collider); + Collider_InitAndSetJntSph(play, &this->collider, &this->actor, &sJntSphInit, &this->colliderElement); this->collider.elements->dim.worldSphere.radius = sJntSphInit.elements->dim.modelSphere.radius; CollisionCheck_SetInfo(&this->actor.colChkInfo, &sDamageTable, &sColChkInfoInit); Actor_SetScale(&this->actor, 0.01f); this->actor.flags |= ACTOR_FLAG_2000000; - this->path = SubS_GetPathByIndex(globalCtx, ENRUPPECROW_GET_PATH(&this->actor), 0x3F); + this->path = SubS_GetPathByIndex(play, ENRUPPECROW_GET_PATH(&this->actor), 0x3F); if (this->path != NULL) { this->actionFunc = EnRuppecrow_HandleSong; } else { @@ -647,27 +647,27 @@ void EnRuppecrow_Init(Actor* thisx, GlobalContext* globalCtx2) { } } -void EnRuppecrow_Destroy(Actor* thisx, GlobalContext* globalCtx) { +void EnRuppecrow_Destroy(Actor* thisx, PlayState* play) { EnRuppecrow* this = THIS; - Collider_DestroyJntSph(globalCtx, &this->collider); + Collider_DestroyJntSph(play, &this->collider); } -void EnRuppecrow_Update(Actor* thisx, GlobalContext* globalCtx) { +void EnRuppecrow_Update(Actor* thisx, PlayState* play) { EnRuppecrow* this = THIS; - EnRuppecrow_UpdateDamage(this, globalCtx); - this->actionFunc(this, globalCtx); + EnRuppecrow_UpdateDamage(this, play); + this->actionFunc(this, play); EnRuppecrow_UpdateRupees(this); this->actor.focus.pos = this->actor.world.pos; SkelAnime_Update(&this->skelAnime); - EnRuppecrow_UpdateCollision(this, globalCtx); + EnRuppecrow_UpdateCollision(this, play); } -void EnRuppecrow_Draw(Actor* thisx, GlobalContext* globalCtx) { +void EnRuppecrow_Draw(Actor* thisx, PlayState* play) { EnRuppecrow* this = THIS; - func_8012C28C(globalCtx->state.gfxCtx); - SkelAnime_DrawFlexOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, - NULL, NULL, &this->actor); + func_8012C28C(play->state.gfxCtx); + SkelAnime_DrawFlexOpa(play, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, NULL, + NULL, &this->actor); } diff --git a/src/overlays/actors/ovl_En_Ruppecrow/z_en_ruppecrow.h b/src/overlays/actors/ovl_En_Ruppecrow/z_en_ruppecrow.h index de9fceac9..620e4b9ac 100644 --- a/src/overlays/actors/ovl_En_Ruppecrow/z_en_ruppecrow.h +++ b/src/overlays/actors/ovl_En_Ruppecrow/z_en_ruppecrow.h @@ -11,7 +11,7 @@ struct EnRuppecrow; -typedef void (*EnRuppecrowActionFunc)(struct EnRuppecrow*, GlobalContext*); +typedef void (*EnRuppecrowActionFunc)(struct EnRuppecrow*, PlayState*); typedef struct EnRuppecrow { /* 0x000 */ Actor actor; 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 57f679803..902e60419 100644 --- a/src/overlays/actors/ovl_En_Rz/z_en_rz.c +++ b/src/overlays/actors/ovl_En_Rz/z_en_rz.c @@ -10,24 +10,24 @@ #define THIS ((EnRz*)thisx) -void EnRz_Init(Actor* thisx, GlobalContext* globalCtx); -void EnRz_Destroy(Actor* thisx, GlobalContext* globalCtx); -void EnRz_Update(Actor* thisx, GlobalContext* globalCtx); -void EnRz_Draw(Actor* thisx, GlobalContext* globalCtx); +void EnRz_Init(Actor* thisx, PlayState* play); +void EnRz_Destroy(Actor* thisx, PlayState* play); +void EnRz_Update(Actor* thisx, PlayState* play); +void EnRz_Draw(Actor* thisx, PlayState* play); -void func_80BFC058(EnRz* this, GlobalContext* globalCtx); -void func_80BFC078(EnRz* this, GlobalContext* globalCtx); -void func_80BFC19C(EnRz* this, GlobalContext* globalCtx); -void func_80BFC214(EnRz* this, GlobalContext* globalCtx); -void func_80BFC270(EnRz* this, GlobalContext* globalCtx); -void func_80BFC2F4(EnRz* this, GlobalContext* globalCtx); -void func_80BFC36C(EnRz* this, GlobalContext* globalCtx); -void func_80BFC3F8(EnRz* this, GlobalContext* globalCtx); -void func_80BFC608(EnRz* this, GlobalContext* globalCtx); -void func_80BFC674(EnRz* this, GlobalContext* globalCtx); -void func_80BFC728(EnRz* this, GlobalContext* globalCtx); -void func_80BFC7E0(EnRz* this, GlobalContext* globalCtx); -void func_80BFC8F8(EnRz* this, GlobalContext* globalCtx); +void func_80BFC058(EnRz* this, PlayState* play); +void func_80BFC078(EnRz* this, PlayState* play); +void func_80BFC19C(EnRz* this, PlayState* play); +void func_80BFC214(EnRz* this, PlayState* play); +void func_80BFC270(EnRz* this, PlayState* play); +void func_80BFC2F4(EnRz* this, PlayState* play); +void func_80BFC36C(EnRz* this, PlayState* play); +void func_80BFC3F8(EnRz* this, PlayState* play); +void func_80BFC608(EnRz* this, PlayState* play); +void func_80BFC674(EnRz* this, PlayState* play); +void func_80BFC728(EnRz* this, PlayState* play); +void func_80BFC7E0(EnRz* this, PlayState* play); +void func_80BFC8F8(EnRz* this, PlayState* play); #if 0 const ActorInit En_Rz_InitVars = { diff --git a/src/overlays/actors/ovl_En_Rz/z_en_rz.h b/src/overlays/actors/ovl_En_Rz/z_en_rz.h index df78ac04c..5106d1413 100644 --- a/src/overlays/actors/ovl_En_Rz/z_en_rz.h +++ b/src/overlays/actors/ovl_En_Rz/z_en_rz.h @@ -5,12 +5,12 @@ struct EnRz; -typedef void (*EnRzActionFunc)(struct EnRz*, GlobalContext*); +typedef void (*EnRzActionFunc)(struct EnRz*, PlayState*); typedef struct EnRz { - /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x2EC]; - /* 0x0430 */ EnRzActionFunc actionFunc; + /* 0x000 */ Actor actor; + /* 0x144 */ char unk_144[0x2EC]; + /* 0x430 */ EnRzActionFunc actionFunc; } EnRz; // size = 0x434 extern const ActorInit En_Rz_InitVars; diff --git a/src/overlays/actors/ovl_En_S_Goro/z_en_s_goro.c b/src/overlays/actors/ovl_En_S_Goro/z_en_s_goro.c index 99e92b017..ccc11a002 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 @@ -4,18 +4,96 @@ * Description: Goron in Goron Shrine / Bomb Shop Goron */ +/* +This actor appears to be used in three scenes. +-- Goron Shrine: Winter + Three variants (one instance of each used in game). + Main behavior determined by whether the Goron Elder's Son is asleep, and whether they themselves have been put to +sleep. One of them also has a dialogue tree that checks whether you have lit the chandelier (at least if the kid is not +crying) +-- Goron Shrine: Spring + Six variants - one instance of each appearing in a circle around the elder on the upper level of the shrine if +you've beaten Goht during that cycle. Dialogue determined by whether you have talked to elder in that context as a goron +at least once during that cycle. They have a cheering animation used while the elder is talking to you, otherwise they +stand idle. +-- Bomb Shop + Only one variant. Goron who sells you powder kegs in the bomb shop. +*/ + +/* +Week Event Flags: + 22 Bit 2 -- Goron Elder's Son has been pacified (Winter) + 77 Bit 7 -- You have spoken to the Goron Elder in goron form during spring + + 36 All Bits + 37 Bits 0 - 2 + Track whether or not you have ever spoken to each of the three winter shrine gorons + in various forms. ("Ever" being since last time reset, of course) +*/ + #include "z_en_s_goro.h" +#include "overlays/actors/ovl_En_Gk/z_en_gk.h" // Goron Elder's Son +#include "overlays/actors/ovl_En_Jg/z_en_jg.h" // Goron Elder +#include "objects/object_taisou/object_taisou.h" #define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_8 | ACTOR_FLAG_10) - #define THIS ((EnSGoro*)thisx) -void EnSGoro_Init(Actor* thisx, GlobalContext* globalCtx); -void EnSGoro_Destroy(Actor* thisx, GlobalContext* globalCtx); -void EnSGoro_Update(Actor* thisx, GlobalContext* globalCtx); -void EnSGoro_Draw(Actor* thisx, GlobalContext* globalCtx); +#define EN_S_GORO_ROLLEDUP_YOFFSET 14.0f +#define EN_S_GORO_OFTYPE_WSHRINE (EN_S_GORO_GET_MAIN_TYPE(&this->actor) < 3) + +#define EN_S_GORO_ACTIONFLAG_ROLLEDUP (1 << 0) +#define EN_S_GORO_ACTIONFLAG_FACEPLAYER (1 << 1) +#define EN_S_GORO_ACTIONFLAG_EYESOPEN (1 << 2) +#define EN_S_GORO_ACTIONFLAG_EARSCOVERED (1 << 3) +#define EN_S_GORO_ACTIONFLAG_ENGAGED (1 << 4) +#define EN_S_GORO_ACTIONFLAG_LASTMESSAGE (1 << 5) +#define EN_S_GORO_ACTIONFLAG_GKQUIET_ACKNOWLEDGED (1 << 6) +#define EN_S_GORO_ACTIONFLAG_SNOREPHASE (1 << 7) +#define EN_S_GORO_ACTIONFLAG_UNK0100 (1 << 8) +#define EN_S_GORO_ACTIONFLAG_HANDTAP (1 << 9) +#define EN_S_GORO_ACTIONFLAG_TIRED (1 << 10) +#define EN_S_GORO_ACTIONFLAG_SUPPRESS_SNORE (1 << 11) + +#define EN_S_GORO_BOMBBUYFLAG_TALKED_HUMAN (1 << 0) +#define EN_S_GORO_BOMBBUYFLAG_TALKED_GORONPK (1 << 1) +#define EN_S_GORO_BOMBBUYFLAG_TALKED_DEKU (1 << 2) +#define EN_S_GORO_BOMBBUYFLAG_TALKED_ZORA (1 << 3) +#define EN_S_GORO_BOMBBUYFLAG_TALKED_HUMAN_FINALNIGHT (1 << 4) +#define EN_S_GORO_BOMBBUYFLAG_TALKED_GOROKPK_FINALNIGHT (1 << 5) +#define EN_S_GORO_BOMBBUYFLAG_TALKED_DEKU_FINALNIGHT (1 << 6) +#define EN_S_GORO_BOMBBUYFLAG_TALKED_ZORA_FINALNIGHT (1 << 7) +#define EN_S_GORO_BOMBBUYFLAG_TALKED_GORON (1 << 8) +#define EN_S_GORO_BOMBBUYFLAG_TALKED_GORON_FINALNIGHT (1 << 9) +#define EN_S_GORO_BOMBBUYFLAG_YESBUY (1 << 10) + +void EnSGoro_Init(Actor* thisx, PlayState* play); +void EnSGoro_Destroy(Actor* thisx, PlayState* play); +void EnSGoro_Update(Actor* thisx, PlayState* play); +void EnSGoro_Draw(Actor* thisx, PlayState* play); + +typedef enum EnSGoroEyeTexture { + /* 0x0 */ EN_S_GORO_EYETEX_OPEN, + /* 0x1 */ EN_S_GORO_EYETEX_HALF, + /* 0x2 */ EN_S_GORO_EYETEX_CLOSED, + /* 0x3 */ EN_S_GORO_EYETEX_CLOSED2 +} EnSGoroEyeTexture; + +typedef enum EnSGoroAnimation { + /* 0x0 */ EN_S_GORO_ANIM_IDLE_LIEDOWN_A, + /* 0x1 */ EN_S_GORO_ANIM_IDLE_LIEDOWN_B, + /* 0x2 */ EN_S_GORO_ANIM_UNROLL_A, + /* 0x3 */ EN_S_GORO_ANIM_UNROLL_B, + /* 0x4 */ EN_S_GORO_ANIM_ROLLUP, + /* 0x5 */ EN_S_GORO_ANIM_SHIVER_A, + /* 0x6 */ EN_S_GORO_ANIM_SHIVER_B, + /* 0xB */ EN_S_GORO_ANIM_COVEREARS = 11, + /* 0xC */ EN_S_GORO_ANIM_TAISOU_CHEER, + /* 0xD */ EN_S_GORO_ANIM_STAND_HANDTAP, + /* 0xE */ EN_S_GORO_ANIM_SLEEPY, + /* 0xF */ EN_S_GORO_ANIM_IDLE_STAND +} EnSGoroAnimation; -#if 0 const ActorInit En_S_Goro_InitVars = { ACTOR_EN_S_GORO, ACTORCAT_NPC, @@ -28,18 +106,29 @@ const ActorInit En_S_Goro_InitVars = { (ActorFunc)EnSGoro_Draw, }; -// static ColliderCylinderInit sCylinderInit = { -static ColliderCylinderInit D_80BBF820 = { - { COLTYPE_HIT1, AT_NONE, AC_ON | AC_TYPE_PLAYER, OC1_ON | OC1_TYPE_ALL, OC2_TYPE_1, COLSHAPE_CYLINDER, }, - { ELEMTYPE_UNK1, { 0x00000000, 0x00, 0x00 }, { 0xF7CFFFFF, 0x00, 0x00 }, TOUCH_ON | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_ON, }, +static ColliderCylinderInit sCylinderInit = { + { + COLTYPE_HIT1, + AT_NONE, + AC_ON | AC_TYPE_PLAYER, + OC1_ON | OC1_TYPE_ALL, + OC2_TYPE_1, + COLSHAPE_CYLINDER, + }, + { + ELEMTYPE_UNK1, + { 0x00000000, 0x00, 0x00 }, + { 0xF7CFFFFF, 0x00, 0x00 }, + TOUCH_ON, + BUMP_ON, + OCELEM_ON, + }, { 0, 0, 0, { 0, 0, 0 } }, }; -// sColChkInfoInit -static CollisionCheckInfoInit2 D_80BBF84C = { 0, 0, 0, 0, MASS_IMMOVABLE }; +static CollisionCheckInfoInit2 sColChkInfoInit = { 0, 0, 0, 0, MASS_IMMOVABLE }; -// static DamageTable sDamageTable = { -static DamageTable D_80BBF858 = { +static DamageTable sDamageTable = { /* Deku Nut */ DMG_ENTRY(1, 0x0), /* Deku Stick */ DMG_ENTRY(1, 0x0), /* Horse trample */ DMG_ENTRY(1, 0x0), @@ -74,85 +163,1314 @@ static DamageTable D_80BBF858 = { /* Powder Keg */ DMG_ENTRY(1, 0x0), }; -#endif +static AnimationInfoS sAnimationInfo[] = { + { &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 }, + { &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_005790, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, + { &gGoronCoverEarsAnim, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, + { &object_taisou_Anim_002C48, 1.0f, 0, -1, ANIMMODE_LOOP, -4 }, + { &gGoronStandingHandTappingAnim, 1.0f, 0, -1, ANIMMODE_LOOP, -4 }, + { &gGoronSleepyAnim, 1.0f, 0, -1, ANIMMODE_ONCE, -4 }, + { &gGoronStandingIdleAnim, 1.0f, 0, -1, ANIMMODE_LOOP, -8 }, +}; -extern ColliderCylinderInit D_80BBF820; -extern CollisionCheckInfoInit2 D_80BBF84C; -extern DamageTable D_80BBF858; +static TexturePtr sEyeTextures[] = { + gGoronEyeOpenTex, + gGoronEyeHalfTex, + gGoronEyeClosedTex, + gGoronEyeClosed2Tex, +}; -extern UNK_TYPE D_060091A8; -extern UNK_TYPE D_06012DE0; +u16 EnSGoro_ShrineGoron_NextTextId(EnSGoro* this, PlayState* play); +u16 EnSGoro_BombshopGoron_NextTextId(EnSGoro* this, PlayState* play); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_S_Goro/func_80BBCA80.s") +s32 EnSGoro_FindGoronElder(EnSGoro* this, PlayState* play); +s32 EnSGoro_FindGoronChild(EnSGoro* this, PlayState* play); +s32 EnSGoro_CheckLullaby(EnSGoro* this, PlayState* play); +s32 EnSGoro_CheckGKBehavior(EnSGoro* this, PlayState* play); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_S_Goro/func_80BBD348.s") +void EnSGoro_SetupAction(EnSGoro* this, PlayState* play); +void EnSGoro_WinterShrineGoron_Idle(EnSGoro* this, PlayState* play); +void EnSGoro_WinterShrineGoron_Talk(EnSGoro* this, PlayState* play); +void EnSGoro_SpringShrineGoron_Idle(EnSGoro* this, PlayState* play); +void EnSGoro_SpringShrineGoron_Talk(EnSGoro* this, PlayState* play); +void EnSGoro_ShopGoron_Idle(EnSGoro* this, PlayState* play); +void EnSGoro_ShopGoron_FinishUnroll(EnSGoro* this, PlayState* play); +void EnSGoro_ShopGoron_Talk(EnSGoro* this, PlayState* play); +void EnSGoro_ShopGoron_TakePayment(EnSGoro* this, PlayState* play); +void EnSGoro_ShopGoron_FinishTransaction(EnSGoro* this, PlayState* play); +void EnSGoro_Sleep(EnSGoro* this, PlayState* play); +void EnSGoro_SleepTalk(EnSGoro* this, PlayState* play); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_S_Goro/func_80BBD8F0.s") +s32 EnSGoro_UpdateCheerAnimation(EnSGoro* this, PlayState* play); +s32 EnSGoro_UpdateRotationToPlayer(EnSGoro* this, PlayState* play); +s32 EnSGoro_UpdateAttentionTarget(EnSGoro* this, PlayState* play); +void EnSGoro_UpdateToHandtapAnimation(EnSGoro* this); +void EnSGoro_UpdateSleepyAnimation(EnSGoro* this); +void EnSGoro_UpdateToIdleAnimation(EnSGoro* this); +void EnSGoro_UpdateEyes(EnSGoro* this); +void EnSGoro_UpdateActorFocus(EnSGoro* this); +void EnSGoro_UpdateSleeping(EnSGoro* this, PlayState* play); +void EnSGoro_UpdateCollider(EnSGoro* this, PlayState* play); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_S_Goro/func_80BBD93C.s") +s32 EnSGoro_UpdateLimb(s16 newRotZ, s16 newRotY, Vec3f* pos, Vec3s* rot, s32 stepRot, s32 overrideRot); +s32 EnSGoro_OverrideLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, Actor* thisx); +void EnSGoro_TransformLimbDraw(PlayState* play, s32 limbIndex, Actor* thisx); +void EnSGoro_DrawUnrolled(EnSGoro* this, PlayState* play); +void EnSGoro_DrawRolledUp(EnSGoro* this, PlayState* play); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_S_Goro/func_80BBD98C.s") +/** + * Dialogue tree for EnSGoro when use in Goron Shrine context. Returns ID of next message to display. + */ +u16 EnSGoro_ShrineGoron_NextTextId(EnSGoro* this, PlayState* play) { + Player* player = GET_PLAYER(play); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_S_Goro/func_80BBDACC.s") + switch (EN_S_GORO_GET_MAIN_TYPE(&this->actor)) { + case EN_S_GORO_TYPE_SHRINE_WINTER_A: + if (!(gSaveContext.save.weekEventReg[22] & 4)) { + if (player->transformation == PLAYER_FORM_GORON) { + if (!(gSaveContext.save.weekEventReg[36] & 2)) { + switch (this->textId) { + case 0xCFB: + return 0xCFC; + case 0xCFC: + return 0xCFD; + case 0xCFD: + gSaveContext.save.weekEventReg[36] |= 2; + this->actionFlags |= EN_S_GORO_ACTIONFLAG_LASTMESSAGE; + return 0xCFE; + default: + return 0xCFB; + } + } else { + this->actionFlags |= EN_S_GORO_ACTIONFLAG_LASTMESSAGE; + return 0xCFE; + } + } else { + if (!(gSaveContext.save.weekEventReg[36] & 1)) { + gSaveContext.save.weekEventReg[36] |= 1; + return 0xCF9; + } + this->actionFlags |= EN_S_GORO_ACTIONFLAG_LASTMESSAGE; + return 0xCFA; + } + } else { + // Scene flag - Checks whether the chandelier has been lit + if (!Flags_GetSwitch(play, EN_S_GORO_SCENEFLAG_INDEX(&this->actor))) { + if (player->transformation == PLAYER_FORM_GORON) { + if (!(gSaveContext.save.weekEventReg[36] & 8)) { + if (this->textId == 0xD02) { + gSaveContext.save.weekEventReg[36] |= 8; + this->actionFlags |= EN_S_GORO_ACTIONFLAG_LASTMESSAGE; + return 0xD03; + } + return 0xD02; + } + this->actionFlags |= EN_S_GORO_ACTIONFLAG_LASTMESSAGE; + return 0xD04; + } + if (!(gSaveContext.save.weekEventReg[36] & 4)) { + if (this->textId == 0xCFF) { + this->actionFlags |= EN_S_GORO_ACTIONFLAG_LASTMESSAGE; + gSaveContext.save.weekEventReg[36] |= 4; + return 0xD00; + } + return 0xCFF; + } + this->actionFlags |= EN_S_GORO_ACTIONFLAG_LASTMESSAGE; + return 0xD01; + } + if (!(gSaveContext.save.weekEventReg[36] & 0x10)) { + if (this->textId == 0xD05) { + gSaveContext.save.weekEventReg[36] |= 0x10; + this->actionFlags |= EN_S_GORO_ACTIONFLAG_LASTMESSAGE; + return 0xD06; + } + return 0xD05; + } + this->actionFlags |= EN_S_GORO_ACTIONFLAG_LASTMESSAGE; + return 0xD07; + } + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_S_Goro/func_80BBDC34.s") + case EN_S_GORO_TYPE_SHRINE_WINTER_B: + if (!(gSaveContext.save.weekEventReg[22] & 4)) { + if (player->transformation == PLAYER_FORM_GORON) { + if (!(gSaveContext.save.weekEventReg[36] & 0x40)) { + switch (this->textId) { + case 0xD15: + return 0xD16; + case 0xD16: + gSaveContext.save.weekEventReg[36] |= 0x40; + this->actionFlags |= EN_S_GORO_ACTIONFLAG_LASTMESSAGE; + return 0xD17; + default: + return 0xD15; + } + } else { + this->actionFlags |= EN_S_GORO_ACTIONFLAG_LASTMESSAGE; + return 0xD17; + } + } else { + if (!(gSaveContext.save.weekEventReg[36] & 0x20)) { + gSaveContext.save.weekEventReg[36] |= 0x20; + return 0xD13; + } + this->actionFlags |= EN_S_GORO_ACTIONFLAG_LASTMESSAGE; + return 0xD14; + } + } else if (player->transformation == PLAYER_FORM_GORON) { + if (!(gSaveContext.save.weekEventReg[37] & 1)) { + switch (this->textId) { + case 0xD1E: + return 0xD1F; + case 0xD1F: + gSaveContext.save.weekEventReg[37] |= 1; + this->actionFlags |= EN_S_GORO_ACTIONFLAG_LASTMESSAGE; + return 0xD20; + default: + return 0xD1E; + } + } else { + this->actionFlags |= EN_S_GORO_ACTIONFLAG_LASTMESSAGE; + return 0xD21; + } + } else { + if (!(gSaveContext.save.weekEventReg[36] & 0x80)) { + switch (this->textId) { + case 0xD18: + return 0xD19; + case 0xD19: + return 0xD1A; + case 0xD1A: + return 0xD1B; + case 0xD1B: + gSaveContext.save.weekEventReg[36] |= 0x80; + this->actionFlags |= EN_S_GORO_ACTIONFLAG_LASTMESSAGE; + return 0xD1C; + default: + return 0xD18; + } + } else { + this->actionFlags |= EN_S_GORO_ACTIONFLAG_LASTMESSAGE; + return 0xD1D; + } + } + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_S_Goro/func_80BBDCFC.s") + case EN_S_GORO_TYPE_SHRINE_WINTER_C: + if (!(gSaveContext.save.weekEventReg[22] & 4)) { + if (player->transformation == PLAYER_FORM_GORON) { + if (!(gSaveContext.save.weekEventReg[37] & 2)) { + switch (this->textId) { + case 0xD09: + return 0xD0A; + case 0xD0A: + return 0xD0B; + case 0xD0B: + gSaveContext.save.weekEventReg[37] |= 2; + this->actionFlags |= EN_S_GORO_ACTIONFLAG_LASTMESSAGE; + return 0xD0C; + default: + return 0xD09; + } + } else { + this->actionFlags |= EN_S_GORO_ACTIONFLAG_LASTMESSAGE; + return 0xD0D; + } + } else { + this->actionFlags |= EN_S_GORO_ACTIONFLAG_LASTMESSAGE; + return 0xD08; + } + } else if (player->transformation == PLAYER_FORM_GORON) { + if (!(gSaveContext.save.weekEventReg[37] & 4)) { + switch (this->textId) { + case 0xD0E: + return 0xD0F; + case 0xD0F: + gSaveContext.save.weekEventReg[37] |= 4; + this->actionFlags |= EN_S_GORO_ACTIONFLAG_LASTMESSAGE; + return 0xD10; + default: + return 0xD0E; + } + } else { + this->actionFlags |= EN_S_GORO_ACTIONFLAG_LASTMESSAGE; + return 0xD11; + } + } else { + this->actionFlags |= EN_S_GORO_ACTIONFLAG_LASTMESSAGE; + return 0xD12; + } + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_S_Goro/func_80BBDDF8.s") + case EN_S_GORO_TYPE_SHRINE_SPRING_A: + if (player->transformation == PLAYER_FORM_GORON) { + if (gSaveContext.save.weekEventReg[77] & 0x80) { + if (this->textId == 0xDE3) { + this->actionFlags |= EN_S_GORO_ACTIONFLAG_LASTMESSAGE; + return 0xDE4; + } + return 0xDE3; + } + this->actionFlags |= EN_S_GORO_ACTIONFLAG_LASTMESSAGE; + return 0xDE2; + } + this->actionFlags |= EN_S_GORO_ACTIONFLAG_LASTMESSAGE; + return 0xDE1; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_S_Goro/func_80BBDE78.s") + case EN_S_GORO_TYPE_SHRINE_SPRING_B: + if (player->transformation == PLAYER_FORM_GORON) { + if (gSaveContext.save.weekEventReg[77] & 0x80) { + if (this->textId == 0xDE7) { + this->actionFlags |= EN_S_GORO_ACTIONFLAG_LASTMESSAGE; + return 0xDE8; + } + return 0xDE7; + } + this->actionFlags |= EN_S_GORO_ACTIONFLAG_LASTMESSAGE; + return 0xDE6; + } + this->actionFlags |= EN_S_GORO_ACTIONFLAG_LASTMESSAGE; + return 0xDE5; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_S_Goro/func_80BBDF28.s") + case EN_S_GORO_TYPE_SHRINE_SPRING_C: + if (player->transformation == PLAYER_FORM_GORON) { + if (gSaveContext.save.weekEventReg[77] & 0x80) { + if (this->textId == 0xDEB) { + this->actionFlags |= EN_S_GORO_ACTIONFLAG_LASTMESSAGE; + return 0xDEC; + } + return 0xDEB; + } + this->actionFlags |= EN_S_GORO_ACTIONFLAG_LASTMESSAGE; + return 0xDEA; + } + this->actionFlags |= EN_S_GORO_ACTIONFLAG_LASTMESSAGE; + return 0xDE9; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_S_Goro/func_80BBDFA8.s") + case EN_S_GORO_TYPE_SHRINE_SPRING_D: + if (player->transformation == PLAYER_FORM_GORON) { + if (gSaveContext.save.weekEventReg[77] & 0x80) { + if (this->textId == 0xDF1) { + this->actionFlags |= EN_S_GORO_ACTIONFLAG_LASTMESSAGE; + return 0xDF2; + } + return 0xDF1; + } + this->actionFlags |= EN_S_GORO_ACTIONFLAG_LASTMESSAGE; + return 0xDF0; + } + switch (this->textId) { + case 0xDED: + return 0xDEE; + case 0xDEE: + this->actionFlags |= EN_S_GORO_ACTIONFLAG_LASTMESSAGE; + return 0xDEF; + default: + return 0xDED; + } + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_S_Goro/func_80BBE05C.s") + case EN_S_GORO_TYPE_SHRINE_SPRING_E: + if (player->transformation == PLAYER_FORM_GORON) { + if (gSaveContext.save.weekEventReg[77] & 0x80) { + if (this->textId == 0xDF6) { + this->actionFlags |= EN_S_GORO_ACTIONFLAG_LASTMESSAGE; + return 0xDF7; + } + return 0xDF6; + } + this->actionFlags |= EN_S_GORO_ACTIONFLAG_LASTMESSAGE; + return 0xDF5; + } + if (this->textId == 0xDF3) { + this->actionFlags |= EN_S_GORO_ACTIONFLAG_LASTMESSAGE; + return 0xDF4; + } + return 0xDF3; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_S_Goro/func_80BBE0E4.s") + case EN_S_GORO_TYPE_SHRINE_SPRING_F: + if (player->transformation == PLAYER_FORM_GORON) { + if (gSaveContext.save.weekEventReg[77] & 0x80) { + switch (this->textId) { + case 0xDFB: + return 0xDFC; + case 0xDFC: + this->actionFlags |= EN_S_GORO_ACTIONFLAG_LASTMESSAGE; + return 0xDFD; + default: + return 0xDFB; + } + } else { + this->actionFlags |= EN_S_GORO_ACTIONFLAG_LASTMESSAGE; + return 0xDFA; + } + } else { + if (this->textId == 0xDF8) { + this->actionFlags |= EN_S_GORO_ACTIONFLAG_LASTMESSAGE; + return 0xDF9; + } + return 0xDF8; + } + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_S_Goro/func_80BBE144.s") + default: + return 0; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_S_Goro/func_80BBE374.s") +/** + * Dialogue tree for bomb shop goron. Returns ID of next message to display. + */ +u16 EnSGoro_BombshopGoron_NextTextId(EnSGoro* this, PlayState* play) { + Player* player = GET_PLAYER(play); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_S_Goro/func_80BBE498.s") + switch (this->textId) { + case 0x0: + switch (player->transformation) { + case PLAYER_FORM_GORON: + // Check if Powder Keg is in Powder Key slot. + if (INV_CONTENT(ITEM_POWDER_KEG) == ITEM_POWDER_KEG) { + if ((gSaveContext.save.day == 3) && gSaveContext.save.isNight) { + if (!(this->bombbuyFlags & EN_S_GORO_BOMBBUYFLAG_TALKED_GOROKPK_FINALNIGHT)) { + this->bombbuyFlags |= EN_S_GORO_BOMBBUYFLAG_TALKED_GOROKPK_FINALNIGHT; + this->actionFlags |= EN_S_GORO_ACTIONFLAG_HANDTAP; + return 0x677; + } + return 0x67A; + } + if (!(this->bombbuyFlags & EN_S_GORO_BOMBBUYFLAG_TALKED_GORONPK)) { + this->bombbuyFlags |= EN_S_GORO_BOMBBUYFLAG_TALKED_GORONPK; + this->actionFlags |= EN_S_GORO_ACTIONFLAG_HANDTAP; + return 0x66E; + } + return 0x679; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_S_Goro/func_80BBE73C.s") + // No powder keg + if ((gSaveContext.save.day == 3) && gSaveContext.save.isNight) { + if (!(this->bombbuyFlags & EN_S_GORO_BOMBBUYFLAG_TALKED_GORON_FINALNIGHT)) { + this->bombbuyFlags |= EN_S_GORO_BOMBBUYFLAG_TALKED_GORON_FINALNIGHT; + this->actionFlags |= EN_S_GORO_ACTIONFLAG_HANDTAP; + return 0x67E; + } + return 0x683; + } + if (!(this->bombbuyFlags & EN_S_GORO_BOMBBUYFLAG_TALKED_GORON)) { + this->bombbuyFlags |= EN_S_GORO_BOMBBUYFLAG_TALKED_GORON; + this->actionFlags |= EN_S_GORO_ACTIONFLAG_HANDTAP; + return 0x67B; + } + return 0x681; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_S_Goro/func_80BBE844.s") + case PLAYER_FORM_ZORA: + if ((gSaveContext.save.day == 3) && gSaveContext.save.isNight) { + if (!(this->bombbuyFlags & EN_S_GORO_BOMBBUYFLAG_TALKED_ZORA_FINALNIGHT)) { + this->bombbuyFlags |= EN_S_GORO_BOMBBUYFLAG_TALKED_ZORA_FINALNIGHT; + return 0x668; + } + this->actionFlags |= EN_S_GORO_ACTIONFLAG_LASTMESSAGE; + this->actionFlags |= EN_S_GORO_ACTIONFLAG_TIRED; + return 0x66D; + } + if (!(this->bombbuyFlags & EN_S_GORO_BOMBBUYFLAG_TALKED_ZORA)) { + this->bombbuyFlags |= EN_S_GORO_BOMBBUYFLAG_TALKED_ZORA; + return 0x664; + } + this->actionFlags |= EN_S_GORO_ACTIONFLAG_LASTMESSAGE; + this->actionFlags |= EN_S_GORO_ACTIONFLAG_TIRED; + return 0x66C; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_S_Goro/func_80BBE904.s") + case PLAYER_FORM_DEKU: + if ((gSaveContext.save.day == 3) && gSaveContext.save.isNight) { + if (!(this->bombbuyFlags & EN_S_GORO_BOMBBUYFLAG_TALKED_DEKU_FINALNIGHT)) { + this->bombbuyFlags |= EN_S_GORO_BOMBBUYFLAG_TALKED_DEKU_FINALNIGHT; + return 0x668; + } + this->actionFlags |= EN_S_GORO_ACTIONFLAG_LASTMESSAGE; + return 0x66D; + } + if (!(this->bombbuyFlags & EN_S_GORO_BOMBBUYFLAG_TALKED_DEKU)) { + this->bombbuyFlags |= EN_S_GORO_BOMBBUYFLAG_TALKED_DEKU; + return 0x664; + } + this->actionFlags |= EN_S_GORO_ACTIONFLAG_LASTMESSAGE; + return 0x66C; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_S_Goro/func_80BBE9F8.s") + case PLAYER_FORM_HUMAN: + if ((gSaveContext.save.day == 3) && gSaveContext.save.isNight) { + if (!(this->bombbuyFlags & EN_S_GORO_BOMBBUYFLAG_TALKED_HUMAN_FINALNIGHT)) { + this->bombbuyFlags |= EN_S_GORO_BOMBBUYFLAG_TALKED_HUMAN_FINALNIGHT; + return 0x668; + } + this->actionFlags |= EN_S_GORO_ACTIONFLAG_LASTMESSAGE; + return 0x66D; + } + if (!(this->bombbuyFlags & EN_S_GORO_BOMBBUYFLAG_TALKED_HUMAN)) { + this->bombbuyFlags |= EN_S_GORO_BOMBBUYFLAG_TALKED_HUMAN; + return 0x664; + } + this->actionFlags |= EN_S_GORO_ACTIONFLAG_LASTMESSAGE; + return 0x66C; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_S_Goro/func_80BBEAD8.s") + case 0x664: + this->actionFlags |= EN_S_GORO_ACTIONFLAG_HANDTAP; + return 0x665; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_S_Goro/func_80BBEBF8.s") + case 0x665: + this->actionFlags &= ~EN_S_GORO_ACTIONFLAG_HANDTAP; + return 0x666; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_S_Goro/func_80BBECBC.s") + case 0x666: + this->actionFlags |= EN_S_GORO_ACTIONFLAG_LASTMESSAGE; + this->actionFlags |= EN_S_GORO_ACTIONFLAG_TIRED; + return 0x667; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_S_Goro/func_80BBEEB4.s") + case 0x668: + this->actionFlags |= EN_S_GORO_ACTIONFLAG_HANDTAP; + return 0x669; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_S_Goro/func_80BBEF34.s") + case 0x669: + this->actionFlags &= ~EN_S_GORO_ACTIONFLAG_HANDTAP; + return 0x66A; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_S_Goro/func_80BBEFA0.s") + case 0x66A: + this->actionFlags |= EN_S_GORO_ACTIONFLAG_LASTMESSAGE; + this->actionFlags |= EN_S_GORO_ACTIONFLAG_TIRED; + return 0x66B; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_S_Goro/func_80BBF01C.s") + case 0x677: + this->actionFlags &= ~EN_S_GORO_ACTIONFLAG_HANDTAP; + return 0x678; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_S_Goro/EnSGoro_Init.s") + case 0x678: + return 0x670; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_S_Goro/EnSGoro_Destroy.s") + case 0x66E: + this->actionFlags &= ~EN_S_GORO_ACTIONFLAG_HANDTAP; + return 0x66F; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_S_Goro/EnSGoro_Update.s") + case 0x66F: + return 0x670; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_S_Goro/func_80BBF298.s") + case 0x679: + return 0x670; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_S_Goro/func_80BBF3D0.s") + case 0x67A: + return 0x670; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_S_Goro/func_80BBF3EC.s") + case 0x67E: + this->actionFlags &= ~EN_S_GORO_ACTIONFLAG_HANDTAP; + return 0x67F; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_S_Goro/func_80BBF5F0.s") + case 0x67F: + this->actionFlags |= EN_S_GORO_ACTIONFLAG_LASTMESSAGE; + return 0x680; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_S_Goro/func_80BBF6BC.s") + case 0x67B: + this->actionFlags &= ~EN_S_GORO_ACTIONFLAG_HANDTAP; + return 0x67C; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_S_Goro/EnSGoro_Draw.s") + case 0x67C: + this->actionFlags |= EN_S_GORO_ACTIONFLAG_LASTMESSAGE; + return 0x67D; + + case 0x681: + this->actionFlags |= EN_S_GORO_ACTIONFLAG_LASTMESSAGE; + return 0x682; + + case 0x683: + this->actionFlags |= EN_S_GORO_ACTIONFLAG_LASTMESSAGE; + return 0x684; + + case 0x670: + if (this->bombbuyFlags & EN_S_GORO_BOMBBUYFLAG_YESBUY) { + if (AMMO(ITEM_POWDER_KEG) != 0) { + this->actionFlags |= EN_S_GORO_ACTIONFLAG_LASTMESSAGE; + play_sound(NA_SE_SY_ERROR); + return 0x673; + } + this->powderKegPrice = play->msgCtx.unk1206C; + if (gSaveContext.save.playerData.rupees < this->powderKegPrice) { + this->actionFlags |= EN_S_GORO_ACTIONFLAG_LASTMESSAGE; + this->actionFlags |= EN_S_GORO_ACTIONFLAG_TIRED; + play_sound(NA_SE_SY_ERROR); + return 0x674; + } + if ((gSaveContext.save.day == 3) && gSaveContext.save.isNight) { + this->actionFlags |= EN_S_GORO_ACTIONFLAG_LASTMESSAGE; + func_8019F208(); + return 0x676; + } + this->actionFlags |= EN_S_GORO_ACTIONFLAG_LASTMESSAGE; + func_8019F208(); + return 0x675; + } + if ((gSaveContext.save.day == 3) && gSaveContext.save.isNight) { + this->actionFlags |= EN_S_GORO_ACTIONFLAG_LASTMESSAGE; + return 0x672; + } + this->actionFlags |= EN_S_GORO_ACTIONFLAG_LASTMESSAGE; + return 0x671; + } + return 0; +} + +/** + * Links to actor of type EN_JG (Goron Elder), returns whether operation successful. + */ +s32 EnSGoro_FindGoronElder(EnSGoro* this, PlayState* play) { + this->otherGoron = SubS_FindActor(play, this->otherGoron, ACTORCAT_NPC, ACTOR_EN_JG); + if (this->otherGoron != NULL) { + return true; + } + return false; +} + +/** + * Links to actor of type EN_GK (Goron Elder's Son), returns whether operation successful. + */ +s32 EnSGoro_FindGoronChild(EnSGoro* this, PlayState* play) { + this->otherGoron = NULL; + this->otherGoron = SubS_FindActor(play, this->otherGoron, ACTORCAT_NPC, ACTOR_EN_GK); + if (this->otherGoron != NULL) { + return true; + } + return false; +} + +/** + * Looks like it manages the snoring cycle for when rolled up and asleep. + */ +void EnSGoro_UpdateSleeping(EnSGoro* this, PlayState* play) { + s16 curFrame = this->skelAnime.curFrame; + + this->snorePhase += 0x400; + this->scaleFactor = Math_SinS(this->snorePhase) * 0.01f * 0.1f; + this->actor.scale.y = 0.01f - this->scaleFactor; + this->actor.scale.z = 0.01f - this->scaleFactor; + this->actor.scale.x = 0.01f + this->scaleFactor; + + if (!(this->actionFlags & EN_S_GORO_ACTIONFLAG_SUPPRESS_SNORE)) { + if (this->snorePhase == 0) { + if (this->actionFlags & EN_S_GORO_ACTIONFLAG_SNOREPHASE) { + this->actionFlags &= ~EN_S_GORO_ACTIONFLAG_SNOREPHASE; + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_GOLON_SNORE2); + } else { + this->actionFlags |= EN_S_GORO_ACTIONFLAG_SNOREPHASE; + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_GOLON_SNORE1); + } + } + } else if (gSaveContext.save.weekEventReg[22] & 4) { + this->actionFlags &= ~EN_S_GORO_ACTIONFLAG_SUPPRESS_SNORE; + } + + if (!(this->actionFlags & EN_S_GORO_ACTIONFLAG_ROLLEDUP) && (curFrame == 0)) { + this->actionFlags |= EN_S_GORO_ACTIONFLAG_ROLLEDUP; + this->actor.shape.yOffset = EN_S_GORO_ROLLEDUP_YOFFSET; + } + + this->actor.shape.yOffset = (this->actor.scale.y / 0.01f) * EN_S_GORO_ROLLEDUP_YOFFSET; +} + +s32 EnSGoro_UpdateCheerAnimation(EnSGoro* this, PlayState* play) { + if (this->animInfoIndex == EN_S_GORO_ANIM_IDLE_STAND) { + if (((EnJg*)this->otherGoron)->flags & 1) { + this->loadedObjIndex = Object_GetIndex(&play->objectCtx, OBJECT_TAISOU); + if (this->loadedObjIndex >= 0) { + gSegments[6] = PHYSICAL_TO_VIRTUAL(play->objectCtx.status[this->loadedObjIndex].segment); + this->animInfoIndex = EN_S_GORO_ANIM_TAISOU_CHEER; + SubS_ChangeAnimationByInfoS(&this->skelAnime, sAnimationInfo, this->animInfoIndex); + return true; + } + } + } else if ((this->animInfoIndex == EN_S_GORO_ANIM_TAISOU_CHEER) && !(((EnJg*)this->otherGoron)->flags & 1)) { + this->loadedObjIndex = Object_GetIndex(&play->objectCtx, OBJECT_OF1D_MAP); + if (this->loadedObjIndex >= 0) { + gSegments[6] = PHYSICAL_TO_VIRTUAL(play->objectCtx.status[this->loadedObjIndex].segment); + this->animInfoIndex = EN_S_GORO_ANIM_IDLE_STAND; + SubS_ChangeAnimationByInfoS(&this->skelAnime, sAnimationInfo, this->animInfoIndex); + this->skelAnime.curFrame = this->skelAnime.endFrame; + return true; + } + } + return false; +} + +s32 EnSGoro_CheckLullaby(EnSGoro* this, PlayState* play) { + s32 actorType; + Player* player = GET_PLAYER(play); + + if ((player->transformation == PLAYER_FORM_GORON) && (play->msgCtx.ocarinaMode == 3)) { + if (play->msgCtx.lastPlayedSong == OCARINA_SONG_GORON_LULLABY) { + this->animInfoIndex = EN_S_GORO_ANIM_ROLLUP; + SubS_ChangeAnimationByInfoS(&this->skelAnime, sAnimationInfo, this->animInfoIndex); + + actorType = EN_S_GORO_GET_MAIN_TYPE(&this->actor); + this->snorePhase = 0x400 << (actorType + 1); + + /* + * Should be: + * if ((actorType % 2) == 0) + * However, the original code checks the negative case whereas the above does not. + * So unfortunately, this is the only way to get it to match. + */ + if (!(actorType % 2)) { + this->actionFlags |= EN_S_GORO_ACTIONFLAG_SNOREPHASE; + } + this->actionFunc = EnSGoro_Sleep; + return true; + } + } + return false; +} + +s32 EnSGoro_CheckGKBehavior(EnSGoro* this, PlayState* play) { + s32 actorType; + + if (!EnSGoro_FindGoronChild(this, play)) { + return false; + } + if ((!(this->actionFlags & EN_S_GORO_ACTIONFLAG_GKQUIET_ACKNOWLEDGED)) && + ((((EnGk*)this->otherGoron)->unk_1E4 & 0x80) || (gSaveContext.save.weekEventReg[22] & 4))) { + + this->actionFlags |= EN_S_GORO_ACTIONFLAG_GKQUIET_ACKNOWLEDGED; + this->animInfoIndex = EN_S_GORO_ANIM_ROLLUP; + SubS_ChangeAnimationByInfoS(&this->skelAnime, sAnimationInfo, this->animInfoIndex); + + actorType = EN_S_GORO_GET_MAIN_TYPE(&this->actor); + this->snorePhase = 0x400 << (actorType + 1); + + /* + * Should be: + * if ((actorType % 2) == 0) + * However, the original code checks the negative case whereas the above does not. + * So unfortunately, this is the only way to get it to match. + */ + if (!(actorType % 2)) { + this->actionFlags |= EN_S_GORO_ACTIONFLAG_SNOREPHASE; + } + this->actionFlags |= EN_S_GORO_ACTIONFLAG_SUPPRESS_SNORE; + this->actionFunc = EnSGoro_Sleep; + return true; + } + return false; +} + +void EnSGoro_UpdateToHandtapAnimation(EnSGoro* this) { + s16 curFrame = this->skelAnime.curFrame; + s16 lastFrame = Animation_GetLastFrame(sAnimationInfo[this->animInfoIndex].animation); + + if ((this->animInfoIndex != EN_S_GORO_ANIM_STAND_HANDTAP) && (curFrame == lastFrame)) { + this->animInfoIndex = EN_S_GORO_ANIM_STAND_HANDTAP; + SubS_ChangeAnimationByInfoS(&this->skelAnime, sAnimationInfo, this->animInfoIndex); + } +} + +void EnSGoro_UpdateSleepyAnimation(EnSGoro* this) { + s16 curFrame = this->skelAnime.curFrame; + s16 lastFrame = Animation_GetLastFrame(sAnimationInfo[this->animInfoIndex].animation); + + if (this->animInfoIndex != EN_S_GORO_ANIM_SLEEPY) { + if (curFrame == lastFrame) { + this->animInfoIndex = EN_S_GORO_ANIM_SLEEPY; + SubS_ChangeAnimationByInfoS(&this->skelAnime, sAnimationInfo, this->animInfoIndex); + } + } else if (curFrame == lastFrame) { + this->actionFlags &= ~EN_S_GORO_ACTIONFLAG_TIRED; + this->animInfoIndex = EN_S_GORO_ANIM_IDLE_STAND; + SubS_ChangeAnimationByInfoS(&this->skelAnime, sAnimationInfo, this->animInfoIndex); + } +} + +void EnSGoro_UpdateToIdleAnimation(EnSGoro* this) { + s16 curFrame = this->skelAnime.curFrame; + s16 lastFrame = Animation_GetLastFrame(sAnimationInfo[this->animInfoIndex].animation); + + if ((this->animInfoIndex != EN_S_GORO_ANIM_IDLE_STAND) && (curFrame == lastFrame)) { + this->animInfoIndex = EN_S_GORO_ANIM_IDLE_STAND; + SubS_ChangeAnimationByInfoS(&this->skelAnime, sAnimationInfo, this->animInfoIndex); + } +} + +void EnSGoro_UpdateCollider(EnSGoro* this, PlayState* play) { + Vec3f world_pos = this->actor.world.pos; + f32 radius = 24.0f; + f32 height = 62.0f; + + this->collider.dim.pos.x = world_pos.x; + this->collider.dim.pos.y = world_pos.y; + this->collider.dim.pos.z = world_pos.z; + this->collider.dim.radius = radius; + this->collider.dim.height = height; + + //! @bug: It is not clear what this is for. + if ((s32)this != -0x190) { + CollisionCheck_SetOC(play, &play->colChkCtx, &this->collider.base); + } +} + +void EnSGoro_UpdateEyes(EnSGoro* this) { + if (this->actionFlags & EN_S_GORO_ACTIONFLAG_EYESOPEN) { + if (DECR(this->eyeTimer) == 0) { + this->eyeTexIndex++; + if (this->eyeTexIndex > EN_S_GORO_EYETEX_CLOSED) { + this->eyeTimer = Rand_S16Offset(30, 30); + this->eyeTexIndex = EN_S_GORO_EYETEX_OPEN; + } + } + } +} + +void EnSGoro_UpdateActorFocus(EnSGoro* this) { + f32 yDelta; + + if (this->actionFlags & EN_S_GORO_ACTIONFLAG_ROLLEDUP) { + yDelta = this->actor.shape.yOffset; + } else { + yDelta = 58.0f; + } + + this->actor.focus.pos.x = this->actor.world.pos.x; + this->actor.focus.pos.y = this->actor.world.pos.y + yDelta; + this->actor.focus.pos.z = this->actor.world.pos.z; + this->actor.focus.rot.x = this->actor.world.rot.x; + this->actor.focus.rot.y = this->actor.world.rot.y; + this->actor.focus.rot.z = this->actor.world.rot.z; +} + +s32 EnSGoro_UpdateRotationToPlayer(EnSGoro* this, PlayState* play) { + Player* player = GET_PLAYER(play); + Vec3f playerPos; + Vec3f thisPos; + s16 target = (this->actor.yawTowardsPlayer - this->bodyRotY) - this->actor.shape.rot.y; + + Math_SmoothStepToS(&this->headRotY, target, 4, 0x2AA8, 1); + this->headRotY = CLAMP(this->headRotY, -0x1FFE, 0x1FFE); + + target = (this->actor.yawTowardsPlayer - this->headRotY) - this->actor.shape.rot.y; + Math_SmoothStepToS(&this->bodyRotY, target, 4, 0x2AA8, 1); + this->bodyRotY = CLAMP(this->bodyRotY, -0x1C70, 0x1C70); + + playerPos = player->actor.world.pos; + playerPos.y = player->bodyPartsPos[7].y + 3.0f; + thisPos = this->actor.world.pos; + thisPos.y += 70.0f; + + target = Math_Vec3f_Pitch(&thisPos, &playerPos) - this->bodyRotZ; + Math_SmoothStepToS(&this->headRotZ, target, 4, 0x2AA8, 1); + this->headRotZ = CLAMP(this->headRotZ, -0x1C70, 0x1C70); + + target = Math_Vec3f_Pitch(&thisPos, &playerPos) - this->headRotZ; + Math_SmoothStepToS(&this->bodyRotZ, target, 4, 0x2AA8, 1); + this->bodyRotZ = CLAMP(this->bodyRotZ, -0x1C70, 0x1C70); + + return true; +} + +s32 EnSGoro_UpdateAttentionTarget(EnSGoro* this, PlayState* play) { + if (DECR(this->loseAttentionTimer) != 0) { + // EnSGoro is in the process of returning to idle position from previously looking at the player. + if ((this->actionFlags & EN_S_GORO_ACTIONFLAG_EARSCOVERED) && + (this->actionFlags & EN_S_GORO_ACTIONFLAG_EYESOPEN)) { + // If ears are covered, but eyes are open, close eyes. + this->actionFlags &= ~EN_S_GORO_ACTIONFLAG_EYESOPEN; + this->eyeTexIndex = EN_S_GORO_EYETEX_CLOSED2; + } + // Reset position to idle. EnSGoro cannot return attention to player until the timer is up. + this->actionFlags &= ~EN_S_GORO_ACTIONFLAG_FACEPLAYER; + this->headRotZ = 0; + this->headRotY = 0; + this->bodyRotZ = 0; + this->bodyRotY = 0; + return true; + } + + // Turn to face player if either player has engaged EnSGoro or if player is in range and EnSGoro isn't covering his + // ears. + if (this->actionFlags & EN_S_GORO_ACTIONFLAG_ENGAGED) { + this->actionFlags |= EN_S_GORO_ACTIONFLAG_FACEPLAYER; + EnSGoro_UpdateRotationToPlayer(this, play); + } else if (!(this->actionFlags & EN_S_GORO_ACTIONFLAG_EARSCOVERED) && + Actor_IsFacingAndNearPlayer(&this->actor, 120.0f, 0x3FFC)) { + this->actionFlags |= EN_S_GORO_ACTIONFLAG_FACEPLAYER; + EnSGoro_UpdateRotationToPlayer(this, play); + } else { + // Unengaged or player out of range. + if (this->actionFlags & EN_S_GORO_ACTIONFLAG_FACEPLAYER) { + // Previously facing player, but now player out of range. + // Start counter for frames/function calls to ignore player while in process of returning to idle. + this->loseAttentionTimer = 20; + } + // Start animation to return to idle position. + this->actionFlags &= ~EN_S_GORO_ACTIONFLAG_FACEPLAYER; + this->headRotZ = 0; + this->headRotY = 0; + this->bodyRotZ = 0; + this->bodyRotY = 0; + } + return true; +} + +void EnSGoro_SetupAction(EnSGoro* this, PlayState* play) { + if (Object_IsLoaded(&play->objectCtx, this->loadedObjIndex)) { + this->actionFlags = 0; + if (EN_S_GORO_OFTYPE_WSHRINE) { + if (gSaveContext.save.weekEventReg[22] & 4) { + this->actionFlags |= EN_S_GORO_ACTIONFLAG_GKQUIET_ACKNOWLEDGED; + this->actionFlags |= EN_S_GORO_ACTIONFLAG_EYESOPEN; + this->animInfoIndex = EN_S_GORO_ANIM_SHIVER_A; + SubS_ChangeAnimationByInfoS(&this->skelAnime, sAnimationInfo, this->animInfoIndex); + } else { + this->eyeTexIndex = EN_S_GORO_EYETEX_CLOSED2; + this->actionFlags |= EN_S_GORO_ACTIONFLAG_EARSCOVERED; + this->animInfoIndex = EN_S_GORO_ANIM_COVEREARS; + SubS_ChangeAnimationByInfoS(&this->skelAnime, sAnimationInfo, this->animInfoIndex); + } + } else { + this->actionFlags |= EN_S_GORO_ACTIONFLAG_EYESOPEN; + this->animInfoIndex = EN_S_GORO_ANIM_IDLE_STAND; + SubS_ChangeAnimationByInfoS(&this->skelAnime, sAnimationInfo, this->animInfoIndex); + } + + this->scaleFactor = 0.01f; + Actor_SetScale(&this->actor, 0.01f); + this->actor.gravity = -1.0f; + this->actor.flags |= ACTOR_FLAG_10; + this->actor.flags |= ACTOR_FLAG_2000000; + this->actor.targetMode = 1; + + switch (EN_S_GORO_GET_MAIN_TYPE(&this->actor)) { + case EN_S_GORO_TYPE_SHRINE_WINTER_A: + this->actionFunc = EnSGoro_WinterShrineGoron_Idle; + break; + case EN_S_GORO_TYPE_SHRINE_WINTER_B: + this->actionFunc = EnSGoro_WinterShrineGoron_Idle; + break; + case EN_S_GORO_TYPE_SHRINE_WINTER_C: + this->actionFunc = EnSGoro_WinterShrineGoron_Idle; + break; + case EN_S_GORO_TYPE_SHRINE_SPRING_A: + if (EnSGoro_FindGoronElder(this, play)) { + this->actionFunc = EnSGoro_SpringShrineGoron_Idle; + } + break; + case EN_S_GORO_TYPE_SHRINE_SPRING_B: + if (EnSGoro_FindGoronElder(this, play)) { + this->actionFunc = EnSGoro_SpringShrineGoron_Idle; + } + break; + case EN_S_GORO_TYPE_SHRINE_SPRING_C: + if (EnSGoro_FindGoronElder(this, play)) { + this->actionFunc = EnSGoro_SpringShrineGoron_Idle; + } + break; + case EN_S_GORO_TYPE_SHRINE_SPRING_D: + if (EnSGoro_FindGoronElder(this, play)) { + this->actionFunc = EnSGoro_SpringShrineGoron_Idle; + } + break; + case EN_S_GORO_TYPE_SHRINE_SPRING_E: + if (EnSGoro_FindGoronElder(this, play)) { + this->actionFunc = EnSGoro_SpringShrineGoron_Idle; + } + break; + case EN_S_GORO_TYPE_SHRINE_SPRING_F: + if (EnSGoro_FindGoronElder(this, play)) { + this->actionFunc = EnSGoro_SpringShrineGoron_Idle; + } + break; + case EN_S_GORO_TYPE_BOMBSHOP: + this->actionFlags |= EN_S_GORO_ACTIONFLAG_ROLLEDUP; + this->actionFunc = EnSGoro_ShopGoron_Idle; + this->actor.shape.yOffset = EN_S_GORO_ROLLEDUP_YOFFSET; + break; + default: + Actor_MarkForDeath(&this->actor); + break; + } + } +} + +void EnSGoro_WinterShrineGoron_Idle(EnSGoro* this, PlayState* play) { + if (!EnSGoro_CheckLullaby(this, play) && !EnSGoro_CheckGKBehavior(this, play)) { + if (Actor_ProcessTalkRequest(&this->actor, &play->state)) { + this->actionFlags |= EN_S_GORO_ACTIONFLAG_ENGAGED; + if (this->actionFlags & EN_S_GORO_ACTIONFLAG_EARSCOVERED) { + this->actionFlags |= EN_S_GORO_ACTIONFLAG_EYESOPEN; + this->eyeTexIndex = EN_S_GORO_EYETEX_OPEN; + } + this->textId = EnSGoro_ShrineGoron_NextTextId(this, play); + Message_StartTextbox(play, this->textId, &this->actor); + this->actionFunc = EnSGoro_WinterShrineGoron_Talk; + } else if ((this->actor.xzDistToPlayer < 250.0f) || this->actor.isTargeted) { + func_800B863C(&this->actor, play); + } + Math_SmoothStepToS(&this->actor.shape.rot.y, this->actor.home.rot.y, 5, 0x1000, 0x100); + this->actor.world.rot.y = this->actor.shape.rot.y; + } +} + +void EnSGoro_WinterShrineGoron_Talk(EnSGoro* this, PlayState* play) { + if ((Message_GetState(&play->msgCtx) == TEXT_STATE_DONE) && (Message_ShouldAdvance(play))) { + if (this->actionFlags & EN_S_GORO_ACTIONFLAG_LASTMESSAGE) { + this->actionFlags &= ~EN_S_GORO_ACTIONFLAG_LASTMESSAGE; + this->actionFlags &= ~EN_S_GORO_ACTIONFLAG_ENGAGED; + this->actionFunc = EnSGoro_WinterShrineGoron_Idle; + return; + } + this->textId = EnSGoro_ShrineGoron_NextTextId(this, play); + Message_StartTextbox(play, this->textId, &this->actor); + } + Math_SmoothStepToS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer, 5, 0x1000, 0x100); + this->actor.world.rot.y = this->actor.shape.rot.y; +} + +void EnSGoro_SpringShrineGoron_Idle(EnSGoro* this, PlayState* play) { + if ((EN_S_GORO_GET_MAIN_TYPE(&this->actor) == EN_S_GORO_TYPE_SHRINE_SPRING_F) || + !EnSGoro_UpdateCheerAnimation(this, play)) { + if (Actor_ProcessTalkRequest(&this->actor, &play->state)) { + this->actionFlags |= EN_S_GORO_ACTIONFLAG_ENGAGED; + this->textId = EnSGoro_ShrineGoron_NextTextId(this, play); + Message_StartTextbox(play, this->textId, &this->actor); + this->actionFunc = EnSGoro_SpringShrineGoron_Talk; + } else if ((this->actor.xzDistToPlayer < 250.0f) || (this->actor.isTargeted)) { + func_800B863C(&this->actor, play); + } + Math_SmoothStepToS(&this->actor.shape.rot.y, this->actor.home.rot.y, 5, 0x1000, 0x100); + this->actor.world.rot.y = this->actor.shape.rot.y; + } +} + +void EnSGoro_SpringShrineGoron_Talk(EnSGoro* this, PlayState* play) { + if ((Message_GetState(&play->msgCtx) == TEXT_STATE_5) && Message_ShouldAdvance(play)) { + if (this->actionFlags & EN_S_GORO_ACTIONFLAG_LASTMESSAGE) { + this->actionFlags &= ~EN_S_GORO_ACTIONFLAG_LASTMESSAGE; + this->actionFlags &= ~EN_S_GORO_ACTIONFLAG_ENGAGED; + play->msgCtx.msgMode = 0x43; + play->msgCtx.stateTimer = 4; + this->actionFunc = EnSGoro_SpringShrineGoron_Idle; + return; + } + this->textId = EnSGoro_ShrineGoron_NextTextId(this, play); + Message_StartTextbox(play, this->textId, &this->actor); + } + Math_SmoothStepToS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer, 5, 0x1000, 0x100); + this->actor.world.rot.y = this->actor.shape.rot.y; +} + +void EnSGoro_ShopGoron_Idle(EnSGoro* this, PlayState* play) { + if (!(this->actionFlags & EN_S_GORO_ACTIONFLAG_ROLLEDUP)) { + EnSGoro_UpdateToIdleAnimation(this); + } + if (Actor_ProcessTalkRequest(&this->actor, &play->state)) { + this->actionFlags |= EN_S_GORO_ACTIONFLAG_ENGAGED; + this->textId = EnSGoro_BombshopGoron_NextTextId(this, play); + if (this->actionFlags & EN_S_GORO_ACTIONFLAG_ROLLEDUP) { + this->actionFlags &= ~EN_S_GORO_ACTIONFLAG_ROLLEDUP; + this->animInfoIndex = EN_S_GORO_ANIM_UNROLL_A; + SubS_ChangeAnimationByInfoS(&this->skelAnime, sAnimationInfo, this->animInfoIndex); + this->actionFunc = EnSGoro_ShopGoron_FinishUnroll; + } else { + Message_StartTextbox(play, this->textId, &this->actor); + this->actionFunc = EnSGoro_ShopGoron_Talk; + } + } else if ((this->actor.xzDistToPlayer < 250.0f) || this->actor.isTargeted) { + func_800B863C(&this->actor, play); + } + Math_SmoothStepToS(&this->actor.shape.rot.y, this->actor.home.rot.y, 5, 0x1000, 0x100); + this->actor.world.rot.y = this->actor.shape.rot.y; +} + +void EnSGoro_ShopGoron_FinishUnroll(EnSGoro* this, PlayState* play) { + s16 curFrame = this->skelAnime.curFrame; + s16 lastFrame = Animation_GetLastFrame(sAnimationInfo[this->animInfoIndex].animation); + + if ((this->animInfoIndex == EN_S_GORO_ANIM_UNROLL_A) && (curFrame == lastFrame)) { + this->animInfoIndex = EN_S_GORO_ANIM_IDLE_STAND; + SubS_ChangeAnimationByInfoS(&this->skelAnime, sAnimationInfo, this->animInfoIndex); + Message_StartTextbox(play, this->textId, &this->actor); + this->actionFunc = EnSGoro_ShopGoron_Talk; + } + + Math_SmoothStepToS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer, 5, 0x1000, 0x100); + this->actor.world.rot.y = this->actor.shape.rot.y; +} + +void EnSGoro_ShopGoron_Talk(EnSGoro* this, PlayState* play) { + u8 talkState = Message_GetState(&play->msgCtx); + + if (this->actionFlags & EN_S_GORO_ACTIONFLAG_HANDTAP) { + EnSGoro_UpdateToHandtapAnimation(this); + } else if (this->actionFlags & EN_S_GORO_ACTIONFLAG_TIRED) { + EnSGoro_UpdateSleepyAnimation(this); + } else { + EnSGoro_UpdateToIdleAnimation(this); + } + + if (talkState == TEXT_STATE_DONE) { + if (Message_ShouldAdvance(play)) { + if (this->actionFlags & EN_S_GORO_ACTIONFLAG_LASTMESSAGE) { + this->actionFlags &= ~EN_S_GORO_ACTIONFLAG_LASTMESSAGE; + this->actionFlags &= ~EN_S_GORO_ACTIONFLAG_ENGAGED; + this->textId = 0; + this->actionFunc = EnSGoro_ShopGoron_Idle; + return; + } + this->textId = EnSGoro_BombshopGoron_NextTextId(this, play); + Message_StartTextbox(play, this->textId, &this->actor); + } + } else if ((talkState == TEXT_STATE_CHOICE) && (Message_ShouldAdvance(play))) { + switch (play->msgCtx.choiceIndex) { + case 0: + this->bombbuyFlags |= EN_S_GORO_BOMBBUYFLAG_YESBUY; + break; + case 1: + func_8019F230(); + this->bombbuyFlags &= ~EN_S_GORO_BOMBBUYFLAG_YESBUY; + break; + } + + this->textId = EnSGoro_BombshopGoron_NextTextId(this, play); + if ((this->textId == 0x675) || (this->textId == 0x676)) { + play->msgCtx.msgMode = 0x43; + play->msgCtx.stateTimer = 4; + Actor_PickUp(&this->actor, play, GI_POWDER_KEG, 300.0f, 300.0f); + this->actionFunc = EnSGoro_ShopGoron_TakePayment; + } else { + Message_StartTextbox(play, this->textId, &this->actor); + } + } + + Math_SmoothStepToS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer, 5, 0x1000, 0x100); + this->actor.world.rot.y = this->actor.shape.rot.y; +} + +void EnSGoro_ShopGoron_TakePayment(EnSGoro* this, PlayState* play) { + if (Actor_HasParent(&this->actor, play)) { + this->actor.parent = NULL; + Rupees_ChangeBy(-this->powderKegPrice); + this->actionFunc = EnSGoro_ShopGoron_FinishTransaction; + } else { + Actor_PickUp(&this->actor, play, GI_POWDER_KEG, 300.0f, 300.0f); + } +} + +void EnSGoro_ShopGoron_FinishTransaction(EnSGoro* this, PlayState* play) { + if (Actor_ProcessTalkRequest(&this->actor, &play->state)) { + Message_StartTextbox(play, this->textId, &this->actor); + this->actionFunc = EnSGoro_ShopGoron_Talk; + } else { + func_800B85E0(&this->actor, play, 400.0f, -1); + } +} + +void EnSGoro_Sleep(EnSGoro* this, PlayState* play) { + if (Actor_ProcessTalkRequest(&this->actor, &play->state)) { + Message_StartTextbox(play, 0x23A, &this->actor); + this->actionFunc = EnSGoro_SleepTalk; + } else if (this->actor.isTargeted) { + func_800B863C(&this->actor, play); + } + EnSGoro_UpdateSleeping(this, play); +} + +void EnSGoro_SleepTalk(EnSGoro* this, PlayState* play) { + if (Message_GetState(&play->msgCtx) == TEXT_STATE_DONE) { + if (Message_ShouldAdvance(play)) { + play->msgCtx.msgMode = 0x43; + play->msgCtx.stateTimer = 4; + this->actionFunc = EnSGoro_Sleep; + } + } + EnSGoro_UpdateSleeping(this, play); +} + +void EnSGoro_Init(Actor* thisx, PlayState* play) { + s32 pad; + EnSGoro* this = THIS; + + ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 20.0f); + SkelAnime_InitFlex(play, &this->skelAnime, &gGoronSkel, &gGoronUnrollAnim, this->jointTable, this->morphTable, + GORON_LIMB_MAX); + Collider_InitCylinder(play, &this->collider); + Collider_SetCylinder(play, &this->collider, &this->actor, &sCylinderInit); + CollisionCheck_SetInfo2(&this->actor.colChkInfo, &sDamageTable, &sColChkInfoInit); + if (this->actor.update != NULL) { + s32 objIndex = Object_GetIndex(&play->objectCtx, OBJECT_OF1D_MAP); + + this->loadedObjIndex = objIndex; + if (objIndex < 0) { + Actor_MarkForDeath(&this->actor); + } + } + this->actor.draw = EnSGoro_Draw; + this->actionFunc = EnSGoro_SetupAction; +} + +void EnSGoro_Destroy(Actor* thisx, PlayState* play) { + EnSGoro* this = THIS; + + Collider_DestroyCylinder(play, &this->collider); +} + +void EnSGoro_Update(Actor* thisx, PlayState* play) { + EnSGoro* this = (EnSGoro*)thisx; + + this->actionFunc(this, play); + Actor_UpdateBgCheckInfo(play, &this->actor, 30.0f, 12.0f, 0.0f, 5); + gSegments[6] = PHYSICAL_TO_VIRTUAL(play->objectCtx.status[this->loadedObjIndex].segment); + SkelAnime_Update(&this->skelAnime); + if (this->animInfoIndex != EN_S_GORO_ANIM_SLEEPY) { + EnSGoro_UpdateAttentionTarget(this, play); + } + EnSGoro_UpdateEyes(this); + EnSGoro_UpdateActorFocus(this); + EnSGoro_UpdateCollider(this, play); +} + +/** + * This function appears to be identical to SubS_UpdateLimb. But it's here! + */ +s32 EnSGoro_UpdateLimb(s16 newRotZ, s16 newRotY, Vec3f* pos, Vec3s* rot, s32 stepRot, s32 overrideRot) { + Vec3f newPos; + Vec3f zeroVec = gZeroVec3f; + Vec3s newRot; + MtxF curState; + + Matrix_MultVec3f(&zeroVec, &newPos); + Matrix_Get(&curState); + Matrix_MtxFToYXZRot(&curState, &newRot, MTXMODE_NEW); + + *pos = newPos; + + if (!stepRot && !overrideRot) { + rot->x = newRot.x; + rot->y = newRot.y; + rot->z = newRot.z; + return true; + } + + if (overrideRot) { + newRot.z = newRotZ; + newRot.y = newRotY; + } + + 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; +} + +s32 EnSGoro_OverrideLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, Actor* thisx) { + return false; +} + +void EnSGoro_TransformLimbDraw(PlayState* play, s32 limbIndex, Actor* thisx) { + s32 stepRot; + s32 overrideRot; + EnSGoro* this = THIS; + + if (limbIndex != GORON_LIMB_BODY) { + if ((limbIndex == GORON_LIMB_HEAD) && (this->animInfoIndex != EN_S_GORO_ANIM_SLEEPY)) { + if (this->actionFlags & EN_S_GORO_ACTIONFLAG_FACEPLAYER) { + overrideRot = true; + } else { + overrideRot = false; + } + if (this->loseAttentionTimer != 0) { + stepRot = true; + } else { + stepRot = false; + } + + EnSGoro_UpdateLimb(this->headRotZ + this->bodyRotZ + 0x4000, + this->headRotY + this->bodyRotY + this->actor.shape.rot.y + 0x4000, &this->headTranslate, + &this->headRotate, stepRot, overrideRot); + + Matrix_Pop(); + Matrix_Translate(this->headTranslate.x, this->headTranslate.y, this->headTranslate.z, MTXMODE_NEW); + Matrix_Scale(this->actor.scale.x, this->actor.scale.y, this->actor.scale.z, MTXMODE_APPLY); + Matrix_RotateYS(this->headRotate.y, MTXMODE_APPLY); + Matrix_RotateXS(this->headRotate.x, MTXMODE_APPLY); + Matrix_RotateZS(this->headRotate.z, MTXMODE_APPLY); + Matrix_Push(); + } + } else if (this->animInfoIndex != EN_S_GORO_ANIM_SLEEPY) { + if (this->actionFlags & EN_S_GORO_ACTIONFLAG_FACEPLAYER) { + overrideRot = true; + } else { + overrideRot = false; + } + if (this->loseAttentionTimer != 0) { + stepRot = true; + } else { + stepRot = false; + } + + EnSGoro_UpdateLimb(this->bodyRotZ + 0x4000, this->bodyRotY + this->actor.shape.rot.y + 0x4000, + &this->bodyTranslate, &this->bodyRotate, stepRot, overrideRot); + + Matrix_Pop(); + Matrix_Translate(this->bodyTranslate.x, this->bodyTranslate.y, this->bodyTranslate.z, MTXMODE_NEW); + Matrix_Scale(this->actor.scale.x, this->actor.scale.y, this->actor.scale.z, MTXMODE_APPLY); + Matrix_RotateYS(this->bodyRotate.y, MTXMODE_APPLY); + Matrix_RotateXS(this->bodyRotate.x, MTXMODE_APPLY); + Matrix_RotateZS(this->bodyRotate.z, MTXMODE_APPLY); + Matrix_Push(); + } +} + +void EnSGoro_DrawUnrolled(EnSGoro* this, PlayState* play) { + s32 pad; + + OPEN_DISPS(play->state.gfxCtx); + func_8012C28C(play->state.gfxCtx); + + gSPSegment(POLY_OPA_DISP++, 0x8, Lib_SegmentedToVirtual(sEyeTextures[this->eyeTexIndex])); + gDPPipeSync(POLY_OPA_DISP++); + + SkelAnime_DrawTransformFlexOpa(play, this->skelAnime.skeleton, this->skelAnime.jointTable, + this->skelAnime.dListCount, EnSGoro_OverrideLimbDraw, NULL, + EnSGoro_TransformLimbDraw, &this->actor); + + CLOSE_DISPS(play->state.gfxCtx); +} + +void EnSGoro_DrawRolledUp(EnSGoro* this, PlayState* play) { + OPEN_DISPS(play->state.gfxCtx); + func_8012C28C(play->state.gfxCtx); + + 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); + + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_OPA_DISP++, gGoronRolledUpDL); + + CLOSE_DISPS(play->state.gfxCtx); +} + +void EnSGoro_Draw(Actor* thisx, PlayState* play) { + EnSGoro* this = (EnSGoro*)thisx; + + if (this->actionFlags & EN_S_GORO_ACTIONFLAG_ROLLEDUP) { + EnSGoro_DrawRolledUp(this, play); + } else { + EnSGoro_DrawUnrolled(this, play); + } +} 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 99c35127a..0d7ac9edb 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 @@ -2,20 +2,59 @@ #define Z_EN_S_GORO_H #include "global.h" +#include "objects/object_oF1d_map/object_oF1d_map.h" -#define EN_S_GORO_GET_PARAM_F(thisx) ((thisx)->params & 0xF) +#define EN_S_GORO_GET_MAIN_TYPE(thisx) ((thisx)->params & 0xF) +#define EN_S_GORO_SCENEFLAG_INDEX(thisx) (((thisx)->params & 0x7F0) >> 4) struct EnSGoro; -typedef void (*EnSGoroActionFunc)(struct EnSGoro*, GlobalContext*); - -typedef struct EnSGoro { - /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x48]; - /* 0x018C */ EnSGoroActionFunc actionFunc; - /* 0x0190 */ char unk_190[0x180]; -} EnSGoro; // size = 0x310 +typedef void (*EnSGoroActionFunc)(struct EnSGoro*, PlayState*); extern const ActorInit En_S_Goro_InitVars; +typedef struct EnSGoro { + /* 0x000 */ Actor actor; + /* 0x144 */ Actor* otherGoron; + /* 0x148 */ SkelAnime skelAnime; + /* 0x18C */ EnSGoroActionFunc actionFunc; + /* 0x190 */ ColliderCylinder collider; + /* 0x1DC */ u16 actionFlags; + /* 0x1DE */ u16 bombbuyFlags; + /* 0x1E0 */ UNK_TYPE1 unk_1E0[0xC]; + /* 0x1EC */ s16 eyeTexIndex; + /* 0x1EE */ s16 eyeTimer; + /* 0x1F0 */ s16 loseAttentionTimer; + /* 0x1F4 */ s32 loadedObjIndex; + /* 0x1F8 */ Vec3s jointTable[GORON_LIMB_MAX]; + /* 0x264 */ Vec3s morphTable[GORON_LIMB_MAX]; + /* 0x2D0 */ f32 scaleFactor; + /* 0x2D4 */ s16 headRotZ; + /* 0x2D6 */ s16 headRotY; + /* 0x2D8 */ s16 bodyRotZ; + /* 0x2DA */ s16 bodyRotY; + /* 0x2DC */ Vec3f headTranslate; + /* 0x2E8 */ Vec3s headRotate; + /* 0x2F0 */ Vec3f bodyTranslate; + /* 0x2FC */ Vec3s bodyRotate; + /* 0x302 */ UNK_TYPE1 unk_302[2]; + /* 0x304 */ u16 textId; + /* 0x306 */ s16 snorePhase; + /* 0x308 */ s32 animInfoIndex; + /* 0x30C */ s16 powderKegPrice; +} EnSGoro; // size = 0x310 + +typedef enum EnSGoroType { + /* 0x0 */ EN_S_GORO_TYPE_SHRINE_WINTER_A, + /* 0x1 */ EN_S_GORO_TYPE_SHRINE_WINTER_B, + /* 0x2 */ EN_S_GORO_TYPE_SHRINE_WINTER_C, + /* 0x3 */ EN_S_GORO_TYPE_SHRINE_SPRING_A, + /* 0x4 */ EN_S_GORO_TYPE_SHRINE_SPRING_B, + /* 0x5 */ EN_S_GORO_TYPE_SHRINE_SPRING_C, + /* 0x6 */ EN_S_GORO_TYPE_SHRINE_SPRING_D, + /* 0x7 */ EN_S_GORO_TYPE_SHRINE_SPRING_E, + /* 0x8 */ EN_S_GORO_TYPE_SHRINE_SPRING_F, + /* 0x9 */ EN_S_GORO_TYPE_BOMBSHOP +} EnSGoroType; + #endif // Z_EN_S_GORO_H 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 7ffeb543b..acd645d63 100644 --- a/src/overlays/actors/ovl_En_Sb/z_en_sb.c +++ b/src/overlays/actors/ovl_En_Sb/z_en_sb.c @@ -11,19 +11,19 @@ #define THIS ((EnSb*)thisx) -void EnSb_Init(Actor* thisx, GlobalContext* globalCtx); -void EnSb_Destroy(Actor* thisx, GlobalContext* globalCtx); -void EnSb_Update(Actor* thisx, GlobalContext* globalCtx); -void EnSb_Draw(Actor* thisx, GlobalContext* globalCtx); +void EnSb_Init(Actor* thisx, PlayState* play); +void EnSb_Destroy(Actor* thisx, PlayState* play); +void EnSb_Update(Actor* thisx, PlayState* play); +void EnSb_Draw(Actor* thisx, PlayState* play); void EnSb_SetupWaitClosed(EnSb* this); -void EnSb_Idle(EnSb* this, GlobalContext* globalCtx); -void EnSb_Open(EnSb* this, GlobalContext* globalCtx); -void EnSb_WaitOpen(EnSb* this, GlobalContext* globalCtx); -void EnSb_TurnAround(EnSb* this, GlobalContext* globalCtx); -void EnSb_Lunge(EnSb* this, GlobalContext* globalCtx); -void EnSb_Bounce(EnSb* this, GlobalContext* globalCtx); -void EnSb_ReturnToIdle(EnSb* this, GlobalContext* globalCtx); +void EnSb_Idle(EnSb* this, PlayState* play); +void EnSb_Open(EnSb* this, PlayState* play); +void EnSb_WaitOpen(EnSb* this, PlayState* play); +void EnSb_TurnAround(EnSb* this, PlayState* play); +void EnSb_Lunge(EnSb* this, PlayState* play); +void EnSb_Bounce(EnSb* this, PlayState* play); +void EnSb_ReturnToIdle(EnSb* this, PlayState* play); const ActorInit En_Sb_InitVars = { ACTOR_EN_SB, @@ -104,17 +104,17 @@ static Vec3f sFlamePosOffsets[] = { { 0.0f, 0.0f, -5.0f }, }; -void EnSb_Init(Actor* thisx, GlobalContext* globalCtx) { +void EnSb_Init(Actor* thisx, PlayState* play) { EnSb* this = THIS; Actor_ProcessInitChain(&this->actor, sInitChain); this->actor.colChkInfo.damageTable = &sDamageTable; 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, + SkelAnime_InitFlex(play, &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); + Collider_InitCylinder(play, &this->collider); + Collider_SetCylinderType1(play, &this->collider, &this->actor, &sCylinderInit); this->isDead = false; this->actor.colChkInfo.mass = 90; this->actor.shape.rot.y = 0; @@ -127,32 +127,32 @@ void EnSb_Init(Actor* thisx, GlobalContext* globalCtx) { EnSb_SetupWaitClosed(this); } -void EnSb_Destroy(Actor* thisx, GlobalContext* globalCtx) { +void EnSb_Destroy(Actor* thisx, PlayState* play) { EnSb* this = THIS; - Collider_DestroyCylinder(globalCtx, &this->collider); + Collider_DestroyCylinder(play, &this->collider); } -void EnSb_SpawnBubbles(GlobalContext* globalCtx, EnSb* this) { +void EnSb_SpawnBubbles(PlayState* play, EnSb* this) { s32 bubbleCount; if (this->actor.depthInWater > 0.0f) { for (bubbleCount = 0; bubbleCount < 10; bubbleCount++) { - EffectSsBubble_Spawn(globalCtx, &this->actor.world.pos, 10.0f, 10.0f, 30.0f, 0.25f); + EffectSsBubble_Spawn(play, &this->actor.world.pos, 10.0f, 10.0f, 30.0f, 0.25f); } } } void EnSb_SetupWaitClosed(EnSb* this) { Animation_Change(&this->skelAnime, &object_sb_Anim_00004C, 1.0f, 0, Animation_GetLastFrame(&object_sb_Anim_00004C), - 2, 0.0f); + ANIMMODE_ONCE, 0.0f); this->state = SHELLBLADE_WAIT_CLOSED; this->actionFunc = EnSb_Idle; } void EnSb_SetupOpen(EnSb* this) { Animation_Change(&this->skelAnime, &object_sb_Anim_000194, 1.0f, 0, Animation_GetLastFrame(&object_sb_Anim_000194), - 2, 0.0f); + ANIMMODE_ONCE, 0.0f); this->state = SHELLBLADE_OPEN; this->actionFunc = EnSb_Open; Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_KUSAMUSHI_VIBE); @@ -160,7 +160,7 @@ void EnSb_SetupOpen(EnSb* this) { void EnSb_SetupWaitOpen(EnSb* this) { Animation_Change(&this->skelAnime, &object_sb_Anim_002C8C, 1.0f, 0, Animation_GetLastFrame(&object_sb_Anim_002C8C), - 0, 0.0f); + ANIMMODE_LOOP, 0.0f); this->state = SHELLBLADE_WAIT_OPEN; this->actionFunc = EnSb_WaitOpen; } @@ -169,7 +169,7 @@ void EnSb_SetupLunge(EnSb* this) { f32 frameCount = Animation_GetLastFrame(&object_sb_Anim_000124); f32 playbackSpeed = this->actor.depthInWater > 0.0f ? 1.0f : 0.0f; - Animation_Change(&this->skelAnime, &object_sb_Anim_000124, playbackSpeed, 0.0f, frameCount, 2, 0); + Animation_Change(&this->skelAnime, &object_sb_Anim_000124, playbackSpeed, 0.0f, frameCount, ANIMMODE_ONCE, 0); this->state = SHELLBLADE_LUNGE; this->actionFunc = EnSb_Lunge; Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_KUSAMUSHI_VIBE); @@ -177,7 +177,7 @@ void EnSb_SetupLunge(EnSb* this) { void EnSb_SetupBounce(EnSb* this) { Animation_Change(&this->skelAnime, &object_sb_Anim_0000B4, 1.0f, 0, Animation_GetLastFrame(&object_sb_Anim_0000B4), - 2, 0.0f); + ANIMMODE_ONCE, 0.0f); this->state = SHELLBLADE_BOUNCE; this->actionFunc = EnSb_Bounce; } @@ -186,7 +186,7 @@ void EnSb_SetupIdle(EnSb* this, s32 changeSpeed) { f32 frameCount = Animation_GetLastFrame(&object_sb_Anim_00004C); if (this->state != SHELLBLADE_WAIT_CLOSED) { - Animation_Change(&this->skelAnime, &object_sb_Anim_00004C, 1.0f, 0, frameCount, 2, 0.0f); + Animation_Change(&this->skelAnime, &object_sb_Anim_00004C, 1.0f, 0, frameCount, ANIMMODE_ONCE, 0.0f); } this->state = SHELLBLADE_WAIT_CLOSED; if (changeSpeed) { @@ -206,14 +206,14 @@ void EnSb_SetupIdle(EnSb* this, s32 changeSpeed) { this->actionFunc = EnSb_ReturnToIdle; } -void EnSb_Idle(EnSb* this, GlobalContext* globalCtx) { +void EnSb_Idle(EnSb* this, PlayState* play) { Math_SmoothStepToS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer, 0xA, 0x7D0, 0); if (this->actor.xzDistToPlayer <= 240.0f && this->actor.xzDistToPlayer > 0.0f) { EnSb_SetupOpen(this); } } -void EnSb_Open(EnSb* this, GlobalContext* globalCtx) { +void EnSb_Open(EnSb* this, PlayState* play) { f32 currentFrame = this->skelAnime.curFrame; if (Animation_GetLastFrame(&object_sb_Anim_000194) <= currentFrame) { @@ -228,7 +228,7 @@ void EnSb_Open(EnSb* this, GlobalContext* globalCtx) { } } -void EnSb_WaitOpen(EnSb* this, GlobalContext* globalCtx) { +void EnSb_WaitOpen(EnSb* this, PlayState* play) { Math_SmoothStepToS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer, 0xA, 0x7D0, 0); if (this->actor.xzDistToPlayer > 240.0f || this->actor.xzDistToPlayer <= 40.0f) { @@ -245,7 +245,7 @@ void EnSb_WaitOpen(EnSb* this, GlobalContext* globalCtx) { } } -void EnSb_TurnAround(EnSb* this, GlobalContext* globalCtx) { +void EnSb_TurnAround(EnSb* this, PlayState* play) { s16 invertedYaw = BINANG_ROT180(this->yawAngle); Math_SmoothStepToS(&this->actor.shape.rot.y, invertedYaw, 1, 0x1F40, 0xA); @@ -260,13 +260,13 @@ void EnSb_TurnAround(EnSb* this, GlobalContext* globalCtx) { this->actor.speedXZ = 6.0f; this->actor.gravity = -2.0f; } - EnSb_SpawnBubbles(globalCtx, this); + EnSb_SpawnBubbles(play, this); this->bounceCounter = 3; EnSb_SetupLunge(this); } } -void EnSb_Lunge(EnSb* this, GlobalContext* globalCtx) { +void EnSb_Lunge(EnSb* this, PlayState* play) { Math_StepToF(&this->actor.speedXZ, 0.0f, 0.2f); if (this->actor.velocity.y <= -0.1f || this->actor.bgCheckFlags & 2) { if (!(this->actor.depthInWater > 0.0f)) { @@ -277,7 +277,7 @@ void EnSb_Lunge(EnSb* this, GlobalContext* globalCtx) { } } -void EnSb_Bounce(EnSb* this, GlobalContext* globalCtx) { +void EnSb_Bounce(EnSb* this, PlayState* play) { s32 pad; f32 currentFrame = currentFrame = this->skelAnime.curFrame; f32 frameCount = frameCount = Animation_GetLastFrame(&object_sb_Anim_0000B4); @@ -296,7 +296,7 @@ void EnSb_Bounce(EnSb* this, GlobalContext* globalCtx) { this->actor.speedXZ = 6.0f; this->actor.gravity = -2.0f; } - EnSb_SpawnBubbles(globalCtx, this); + EnSb_SpawnBubbles(play, this); EnSb_SetupLunge(this); } else if (this->actor.bgCheckFlags & 1) { this->actor.bgCheckFlags &= ~2; @@ -307,7 +307,7 @@ void EnSb_Bounce(EnSb* this, GlobalContext* globalCtx) { } } -void EnSb_ReturnToIdle(EnSb* this, GlobalContext* globalCtx) { +void EnSb_ReturnToIdle(EnSb* this, PlayState* play) { if (this->attackTimer != 0) { this->attackTimer--; if (this->actor.bgCheckFlags & 1) { @@ -321,7 +321,7 @@ void EnSb_ReturnToIdle(EnSb* this, GlobalContext* globalCtx) { } } -void EnSb_UpdateDamage(EnSb* this, GlobalContext* globalCtx) { +void EnSb_UpdateDamage(EnSb* this, PlayState* play) { Vec3f hitPoint; if (this->collider.base.acFlags & AC_HIT) { @@ -341,14 +341,14 @@ void EnSb_UpdateDamage(EnSb* this, GlobalContext* globalCtx) { this->isDrawn = true; } this->isDead = true; - Enemy_StartFinishingBlow(globalCtx, &this->actor); - SoundSource_PlaySfxAtFixedWorldPos(globalCtx, &this->actor.world.pos, 0x28, NA_SE_EN_BEE_FLY); + Enemy_StartFinishingBlow(play, &this->actor); + SoundSource_PlaySfxAtFixedWorldPos(play, &this->actor.world.pos, 0x28, NA_SE_EN_BEE_FLY); return; } hitPoint.x = this->collider.info.bumper.hitPos.x; hitPoint.y = this->collider.info.bumper.hitPos.y; hitPoint.z = this->collider.info.bumper.hitPos.z; - CollisionCheck_SpawnShieldParticlesMetal2(globalCtx, &hitPoint); + CollisionCheck_SpawnShieldParticlesMetal2(play, &hitPoint); return; } if (this->collider.base.atFlags & AT_HIT) { @@ -356,10 +356,10 @@ void EnSb_UpdateDamage(EnSb* this, GlobalContext* globalCtx) { } } -void EnSb_Update(Actor* thisx, GlobalContext* globalCtx) { +void EnSb_Update(Actor* thisx, PlayState* play) { s32 pad; EnSb* this = THIS; - Player* player = GET_PLAYER(globalCtx); + Player* player = GET_PLAYER(play); if (this->isDead) { if (this->actor.depthInWater > 0.0f) { @@ -367,33 +367,33 @@ void EnSb_Update(Actor* thisx, GlobalContext* globalCtx) { } else { this->actor.params = 1; } - Item_DropCollectibleRandom(globalCtx, &this->actor, &this->actor.world.pos, 0x80); + Item_DropCollectibleRandom(play, &this->actor, &this->actor.world.pos, 0x80); Actor_MarkForDeath(&this->actor); } else { Actor_SetFocus(&this->actor, 20.0f); Actor_MoveWithGravity(&this->actor); - this->actionFunc(this, globalCtx); - Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 20.0f, 25.0f, 20.0f, 5); - EnSb_UpdateDamage(this, globalCtx); + this->actionFunc(this, play); + Actor_UpdateBgCheckInfo(play, &this->actor, 20.0f, 25.0f, 20.0f, 5); + EnSb_UpdateDamage(this, play); if (player->stateFlags1 & 0x8000000) { Collider_UpdateCylinder(&this->actor, &this->collider); if (this->vulnerableTimer == 0) { - CollisionCheck_SetAT(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + CollisionCheck_SetAT(play, &play->colChkCtx, &this->collider.base); } - CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + CollisionCheck_SetAC(play, &play->colChkCtx, &this->collider.base); } SkelAnime_Update(&this->skelAnime); } } -void EnSb_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx) { +void EnSb_PostLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx) { s8 phi_a2; EnSb* this = THIS; - if (this->isDrawn != false) { + if (this->isDrawn) { if (limbIndex < 7) { phi_a2 = (this->actor.depthInWater > 0) ? 4 : 1; - Actor_SpawnBodyParts(thisx, globalCtx, phi_a2, dList); + Actor_SpawnBodyParts(thisx, play, phi_a2, dList); } if (limbIndex == 6) { this->isDrawn = false; @@ -402,15 +402,15 @@ void EnSb_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec } } -void EnSb_Draw(Actor* thisx, GlobalContext* globalCtx) { +void EnSb_Draw(Actor* thisx, PlayState* play) { EnSb* this = THIS; Vec3f flamePos; Vec3f* offset; s16 fireDecr; - func_800B8050(&this->actor, globalCtx, 1); - SkelAnime_DrawFlexOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, - NULL, EnSb_PostLimbDraw, &this->actor); + func_800B8050(&this->actor, play, 1); + SkelAnime_DrawFlexOpa(play, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, NULL, + EnSb_PostLimbDraw, &this->actor); if (this->fireCount != 0) { this->actor.colorFilterTimer++; fireDecr = this->fireCount - 1; @@ -419,7 +419,7 @@ void EnSb_Draw(Actor* thisx, GlobalContext* globalCtx) { flamePos.x = randPlusMinusPoint5Scaled(5.0f) + (this->actor.world.pos.x + offset->x); flamePos.y = randPlusMinusPoint5Scaled(5.0f) + (this->actor.world.pos.y + offset->y); flamePos.z = randPlusMinusPoint5Scaled(5.0f) + (this->actor.world.pos.z + offset->z); - EffectSsEnFire_SpawnVec3f(globalCtx, &this->actor, &flamePos, 100, 0, 0, -1); + EffectSsEnFire_SpawnVec3f(play, &this->actor, &flamePos, 100, 0, 0, -1); } } } diff --git a/src/overlays/actors/ovl_En_Sb/z_en_sb.h b/src/overlays/actors/ovl_En_Sb/z_en_sb.h index 167a0c5c8..f2b3e68e8 100644 --- a/src/overlays/actors/ovl_En_Sb/z_en_sb.h +++ b/src/overlays/actors/ovl_En_Sb/z_en_sb.h @@ -5,14 +5,14 @@ struct EnSb; -typedef void (*EnSbActionFunc)(struct EnSb*, GlobalContext*); +typedef void (*EnSbActionFunc)(struct EnSb*, PlayState*); typedef enum { - /* 0x00 */ SHELLBLADE_OPEN, - /* 0x01 */ SHELLBLADE_WAIT_CLOSED, - /* 0x02 */ SHELLBLADE_WAIT_OPEN, - /* 0x03 */ SHELLBLADE_LUNGE, - /* 0x04 */ SHELLBLADE_BOUNCE + /* 0x0 */ SHELLBLADE_OPEN, + /* 0x1 */ SHELLBLADE_WAIT_CLOSED, + /* 0x2 */ SHELLBLADE_WAIT_OPEN, + /* 0x3 */ SHELLBLADE_LUNGE, + /* 0x4 */ SHELLBLADE_BOUNCE } ShellbladeState; typedef struct EnSb { diff --git a/src/overlays/actors/ovl_En_Sc_Ruppe/z_en_sc_ruppe.c b/src/overlays/actors/ovl_En_Sc_Ruppe/z_en_sc_ruppe.c index 357d41ba7..5aa54307a 100644 --- a/src/overlays/actors/ovl_En_Sc_Ruppe/z_en_sc_ruppe.c +++ b/src/overlays/actors/ovl_En_Sc_Ruppe/z_en_sc_ruppe.c @@ -5,20 +5,24 @@ */ #include "z_en_sc_ruppe.h" +#include "objects/gameplay_keep/gameplay_keep.h" #define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_20) #define THIS ((EnScRuppe*)thisx) -void EnScRuppe_Init(Actor* thisx, GlobalContext* globalCtx); -void EnScRuppe_Destroy(Actor* thisx, GlobalContext* globalCtx); -void EnScRuppe_Update(Actor* thisx, GlobalContext* globalCtx); -void EnScRuppe_Draw(Actor* thisx, GlobalContext* globalCtx); +void EnScRuppe_Init(Actor* thisx, PlayState* play); +void EnScRuppe_Destroy(Actor* thisx, PlayState* play); +void EnScRuppe_Update(Actor* thisx, PlayState* play); +void EnScRuppe_Draw(Actor* thisx, PlayState* play); -void func_80BD6A8C(EnScRuppe* this, GlobalContext* globalCtx); -void func_80BD6B18(EnScRuppe* this, GlobalContext* globalCtx); +void func_80BD6B18(EnScRuppe* this, PlayState* play); + +typedef struct { + /* 0x0 */ TexturePtr tex; + /* 0x4 */ s16 amount; +} RuppeInfo; -#if 0 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, PlayState* play) { + Collider_UpdateCylinder(&this->actor, &this->collider); + CollisionCheck_SetOC(play, &play->colChkCtx, &this->collider.base); + Actor_UpdateBgCheckInfo(play, &this->actor, 32.0f, 30.0f, 0.0f, 4); +} -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, PlayState* play) { + if (this->collider.base.ocFlags1 & OC1_HIT) { + this->ruppeDisplayTime = 0; + this->actor.gravity = 0.0f; + Actor_PlaySfxAtPos(&this->actor, NA_SE_SY_GET_RUPY); + Rupees_ChangeBy(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, PlayState* play) { + Player* player = GET_PLAYER(play); -#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, PlayState* play) { + EnScRuppe* this = THIS; + ColliderCylinder* collider = &this->collider; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Sc_Ruppe/EnScRuppe_Destroy.s") + Collider_InitCylinder(play, collider); + Collider_InitAndSetCylinder(play, 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, PlayState* play) { + EnScRuppe* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Sc_Ruppe/EnScRuppe_Draw.s") + Collider_DestroyCylinder(play, &this->collider); +} + +void EnScRuppe_Update(Actor* thisx, PlayState* play) { + EnScRuppe* this = THIS; + + this->actionFunc(this, play); + EnScRuppe_UpdateCollision(this, play); +} + +void EnScRuppe_Draw(Actor* thisx, PlayState* play) { + s32* pad; + EnScRuppe* this = THIS; + + OPEN_DISPS(play->state.gfxCtx); + + func_8012C28C(play->state.gfxCtx); + func_800B8050(&this->actor, play, 0); + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPSegment(POLY_OPA_DISP++, 0x08, Lib_SegmentedToVirtual(sRupeeInfo[this->ruppeIndex].tex)); + gSPDisplayList(POLY_OPA_DISP++, gameplay_keep_DL_0622C0); + + CLOSE_DISPS(play->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..80d7ed20e 100644 --- a/src/overlays/actors/ovl_En_Sc_Ruppe/z_en_sc_ruppe.h +++ b/src/overlays/actors/ovl_En_Sc_Ruppe/z_en_sc_ruppe.h @@ -3,17 +3,29 @@ #include "global.h" +#define SCRUPPE_GET_TYPE(thisx) ((thisx)->params & 0x1F) + struct EnScRuppe; -typedef void (*EnScRuppeActionFunc)(struct EnScRuppe*, GlobalContext*); +typedef void (*EnScRuppeActionFunc)(struct EnScRuppe*, PlayState*); typedef struct EnScRuppe { - /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x4C]; - /* 0x0190 */ EnScRuppeActionFunc actionFunc; - /* 0x0194 */ char unk_194[0x4]; + /* 0x000 */ Actor actor; + /* 0x144 */ ColliderCylinder collider; + /* 0x190 */ EnScRuppeActionFunc actionFunc; + /* 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 dd6453773..2265fd22e 100644 --- a/src/overlays/actors/ovl_En_Scopecoin/z_en_scopecoin.c +++ b/src/overlays/actors/ovl_En_Scopecoin/z_en_scopecoin.c @@ -11,13 +11,13 @@ #define THIS ((EnScopecoin*)thisx) -void EnScopecoin_Init(Actor* thisx, GlobalContext* globalCtx); -void EnScopecoin_Destroy(Actor* thisx, GlobalContext* globalCtx); -void EnScopecoin_Update(Actor* thisx, GlobalContext* globalCtx); -void EnScopecoin_Draw(Actor* thisx, GlobalContext* globalCtx); +void EnScopecoin_Init(Actor* thisx, PlayState* play); +void EnScopecoin_Destroy(Actor* thisx, PlayState* play); +void EnScopecoin_Update(Actor* thisx, PlayState* play); +void EnScopecoin_Draw(Actor* thisx, PlayState* play); -void func_80BFCFA0(EnScopecoin* this, GlobalContext* globalCtx); -void func_80BFCFB8(EnScopecoin* this, GlobalContext* globalCtx); +void func_80BFCFA0(EnScopecoin* this, PlayState* play); +void func_80BFCFB8(EnScopecoin* this, PlayState* play); const ActorInit En_Scopecoin_InitVars = { ACTOR_EN_SCOPECOIN, @@ -31,18 +31,18 @@ const ActorInit En_Scopecoin_InitVars = { (ActorFunc)EnScopecoin_Draw, }; -void func_80BFCFA0(EnScopecoin* this, GlobalContext* globalCtx) { +void func_80BFCFA0(EnScopecoin* this, PlayState* play) { this->actor.shape.rot.y += 500; } -void func_80BFCFB8(EnScopecoin* this, GlobalContext* globalCtx) { - if (Flags_GetCollectible(globalCtx, (this->actor.params & 0x7F0) >> 4)) { - Item_DropCollectible(globalCtx, &this->actor.world.pos, ITEM00_RUPEE_RED); +void func_80BFCFB8(EnScopecoin* this, PlayState* play) { + if (Flags_GetCollectible(play, (this->actor.params & 0x7F0) >> 4)) { + Item_DropCollectible(play, &this->actor.world.pos, ITEM00_RUPEE_RED); Actor_MarkForDeath(&this->actor); } } -void EnScopecoin_Init(Actor* thisx, GlobalContext* globalCtx) { +void EnScopecoin_Init(Actor* thisx, PlayState* play) { EnScopecoin* this = THIS; Actor_SetScale(&this->actor, 0.01f); @@ -52,9 +52,9 @@ void EnScopecoin_Init(Actor* thisx, GlobalContext* globalCtx) { this->unk148 = 0; } - if (globalCtx->actorCtx.unk5 & 2) { + if (play->actorCtx.unk5 & 2) { if (this->unk148 == 2 || this->unk148 == 6) { - if (Flags_GetCollectible(globalCtx, (this->actor.params & 0x7F0) >> 4)) { + if (Flags_GetCollectible(play, (this->actor.params & 0x7F0) >> 4)) { Actor_MarkForDeath(&this->actor); return; } @@ -64,7 +64,7 @@ void EnScopecoin_Init(Actor* thisx, GlobalContext* globalCtx) { return; } if (this->unk148 == 2 || this->unk148 == 6) { - if (Flags_GetCollectible(globalCtx, (this->actor.params & 0x7F0) >> 4)) { + if (Flags_GetCollectible(play, (this->actor.params & 0x7F0) >> 4)) { Actor_MarkForDeath(&this->actor); } else { this->actor.draw = NULL; @@ -75,13 +75,13 @@ void EnScopecoin_Init(Actor* thisx, GlobalContext* globalCtx) { } } -void EnScopecoin_Destroy(Actor* thisx, GlobalContext* globalCtx) { +void EnScopecoin_Destroy(Actor* thisx, PlayState* play) { } -void EnScopecoin_Update(Actor* thisx, GlobalContext* globalCtx) { +void EnScopecoin_Update(Actor* thisx, PlayState* play) { EnScopecoin* this = THIS; - this->actionFunc(this, globalCtx); + this->actionFunc(this, play); } static TexturePtr D_80BFD280[] = { @@ -89,15 +89,15 @@ static TexturePtr D_80BFD280[] = { gameplay_keep_Tex_062020, gameplay_keep_Tex_062060, gameplay_keep_Tex_062000, }; -void EnScopecoin_Draw(Actor* thisx, GlobalContext* globalCtx) { +void EnScopecoin_Draw(Actor* thisx, PlayState* play) { EnScopecoin* this = THIS; - GraphicsContext* gfxCtx = globalCtx->state.gfxCtx; + GraphicsContext* gfxCtx = play->state.gfxCtx; - func_8012C28C(globalCtx->state.gfxCtx); - func_800B8050(&this->actor, globalCtx, 0); + func_8012C28C(play->state.gfxCtx); + func_800B8050(&this->actor, play, 0); OPEN_DISPS(gfxCtx); - gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPSegment(POLY_OPA_DISP++, 0x08, Lib_SegmentedToVirtual(D_80BFD280[this->unk148])); gSPDisplayList(POLY_OPA_DISP++, gameplay_keep_DL_0622C0); diff --git a/src/overlays/actors/ovl_En_Scopecoin/z_en_scopecoin.h b/src/overlays/actors/ovl_En_Scopecoin/z_en_scopecoin.h index d810e6ad4..37a6bbf8e 100644 --- a/src/overlays/actors/ovl_En_Scopecoin/z_en_scopecoin.h +++ b/src/overlays/actors/ovl_En_Scopecoin/z_en_scopecoin.h @@ -5,7 +5,7 @@ struct EnScopecoin; -typedef void (*EnScopecoinActionFunc)(struct EnScopecoin*, GlobalContext*); +typedef void (*EnScopecoinActionFunc)(struct EnScopecoin*, PlayState*); typedef struct EnScopecoin { /* 0x000 */ Actor actor; 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 bf0b6a839..fce03f2b8 100644 --- a/src/overlays/actors/ovl_En_Scopecrow/z_en_scopecrow.c +++ b/src/overlays/actors/ovl_En_Scopecrow/z_en_scopecrow.c @@ -10,15 +10,14 @@ #define THIS ((EnScopecrow*)thisx) -void EnScopecrow_Init(Actor* thisx, GlobalContext* globalCtx); -void EnScopecrow_Destroy(Actor* thisx, GlobalContext* globalCtx); -void EnScopecrow_Update(Actor* thisx, GlobalContext* globalCtx); -void EnScopecrow_Draw(Actor* thisx, GlobalContext* globalCtx); +void EnScopecrow_Init(Actor* thisx, PlayState* play); +void EnScopecrow_Destroy(Actor* thisx, PlayState* play); +void EnScopecrow_Update(Actor* thisx, PlayState* play); +void EnScopecrow_Draw(Actor* thisx, PlayState* play); -void func_80BCD590(EnScopecrow* this, GlobalContext* globalCtx); -void func_80BCD640(EnScopecrow* this, GlobalContext* globalCtx); +void func_80BCD590(EnScopecrow* this, PlayState* play); +void func_80BCD640(EnScopecrow* this, PlayState* play); -#if 0 const ActorInit En_Scopecrow_InitVars = { ACTOR_EN_SCOPECROW, ACTORCAT_NPC, @@ -31,47 +30,325 @@ 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, PlayState* play) { + 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(play, &play->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, PlayState* play) { + Actor_SpawnAsChildAndCutscene(&play->actorCtx, play, ACTOR_EN_SC_RUPPE, this->actor.world.pos.x, + this->actor.world.pos.y, this->actor.world.pos.z, this->actor.shape.rot.x, + this->actor.shape.rot.y, this->actor.shape.rot.z, this->actor.params, + this->actor.cutscene, this->actor.unk20, NULL); +} + +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, PlayState* play) { + Vec3f screenPos; + + Play_GetScreenPos(play, &this->actor.world.pos, &screenPos); + + if ((screenPos.x >= 130.0f) && (screenPos.x < (SCREEN_WIDTH - 130.0f)) && (screenPos.y >= 90.0f) && + (screenPos.y < (SCREEN_HEIGHT - 90.0f))) { + this->actor.draw = EnScopecrow_Draw; + this->actionFunc = func_80BCD640; + } +} + +void func_80BCD640(EnScopecrow* this, PlayState* play) { + 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, play); + } + + 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, PlayState* play) { + 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(play, 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(&play->colCtx, &sp4C, &sp3C); + if (this->actor.world.pos.y == BGCHECK_Y_MIN) { + Actor_MarkForDeath(&this->actor); + } + + func_80BCD2BC(this, play); + Actor_MarkForDeath(&this->actor); + return; + } + + Actor_MarkForDeath(&this->actor); + return; + } + + if (play->actorCtx.unk5 & 2) { + SkelAnime_InitFlex(play, &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(play, &this->collider); + Collider_InitAndSetJntSph(play, &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(play, 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, PlayState* play) { + EnScopecrow* this = THIS; + + Collider_DestroyJntSph(play, &this->collider); +} + +void EnScopecrow_Update(Actor* thisx, PlayState* play) { + EnScopecrow* this = THIS; + + this->actionFunc(this, play); + + SkelAnime_Update(&this->skelAnime); + func_80BCD000(this, play); +} + +void EnScopecrow_Draw(Actor* thisx, PlayState* play) { + EnScopecrow* this = THIS; + + func_8012C28C(play->state.gfxCtx); + SkelAnime_DrawFlexOpa(play, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, NULL, + NULL, &this->actor); +} diff --git a/src/overlays/actors/ovl_En_Scopecrow/z_en_scopecrow.h b/src/overlays/actors/ovl_En_Scopecrow/z_en_scopecrow.h index 2b5b38eae..60775383e 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*); +typedef void (*EnScopecrowActionFunc)(struct EnScopecrow*, PlayState*); + +#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 dc7715fa0..2553962f9 100644 --- a/src/overlays/actors/ovl_En_Scopenuts/z_en_scopenuts.c +++ b/src/overlays/actors/ovl_En_Scopenuts/z_en_scopenuts.c @@ -12,24 +12,24 @@ #define THIS ((EnScopenuts*)thisx) -void EnScopenuts_Init(Actor* thisx, GlobalContext* globalCtx); -void EnScopenuts_Destroy(Actor* thisx, GlobalContext* globalCtx); -void EnScopenuts_Update(Actor* thisx, GlobalContext* globalCtx); -void EnScopenuts_Draw(Actor* thisx, GlobalContext* globalCtx); +void EnScopenuts_Init(Actor* thisx, PlayState* play); +void EnScopenuts_Destroy(Actor* thisx, PlayState* play); +void EnScopenuts_Update(Actor* thisx, PlayState* play); +void EnScopenuts_Draw(Actor* thisx, PlayState* play); -void func_80BCB078(EnScopenuts* this, GlobalContext* globalCtx); -void func_80BCB1C8(EnScopenuts* this, GlobalContext* globalCtx); -void func_80BCB4DC(EnScopenuts* this, GlobalContext* globalCtx); -void func_80BCB52C(EnScopenuts* this, GlobalContext* globalCtx); -void func_80BCB6D0(EnScopenuts* this, GlobalContext* globalCtx); -void func_80BCB90C(EnScopenuts* this, GlobalContext* globalCtx); -void func_80BCB980(EnScopenuts* this, GlobalContext* globalCtx); -void func_80BCBA00(EnScopenuts* this, GlobalContext* globalCtx); -void func_80BCBC60(EnScopenuts* this, GlobalContext* globalCtx); -void func_80BCBD28(EnScopenuts* this, GlobalContext* globalCtx); -void func_80BCBF0C(EnScopenuts* this, GlobalContext* globalCtx); -void func_80BCBFFC(EnScopenuts* this, GlobalContext* globalCtx); -void func_80BCC288(EnScopenuts* this, GlobalContext* globalCtx); +void func_80BCB078(EnScopenuts* this, PlayState* play); +void func_80BCB1C8(EnScopenuts* this, PlayState* play); +void func_80BCB4DC(EnScopenuts* this, PlayState* play); +void func_80BCB52C(EnScopenuts* this, PlayState* play); +void func_80BCB6D0(EnScopenuts* this, PlayState* play); +void func_80BCB90C(EnScopenuts* this, PlayState* play); +void func_80BCB980(EnScopenuts* this, PlayState* play); +void func_80BCBA00(EnScopenuts* this, PlayState* play); +void func_80BCBC60(EnScopenuts* this, PlayState* play); +void func_80BCBD28(EnScopenuts* this, PlayState* play); +void func_80BCBF0C(EnScopenuts* this, PlayState* play); +void func_80BCBFFC(EnScopenuts* this, PlayState* play); +void func_80BCC288(EnScopenuts* this, PlayState* play); s32 func_80BCC2AC(EnScopenuts* this, Path* path, s32 arg2_); f32 func_80BCC448(Path* path, s32 arg1, Vec3f* arg2, Vec3s* arg3); @@ -64,7 +64,7 @@ static ColliderCylinderInitType1 sCylinderInit = { { 27, 32, 0, { 0, 0, 0 } }, }; -static AnimationInfoS sAnimations[] = { +static AnimationInfoS sAnimationInfo[] = { { &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 }, @@ -109,7 +109,7 @@ s16 func_80BCABF0(Path* path) { return Math_Vec3f_Yaw(&sp28, &sp1C); } -void func_80BCAC40(EnScopenuts* this, GlobalContext* globalCtx) { +void func_80BCAC40(EnScopenuts* this, PlayState* play) { s16 i; Vec3f sp60; Vec3f sp54; @@ -121,7 +121,7 @@ void func_80BCAC40(EnScopenuts* this, GlobalContext* globalCtx) { sp54.x = Rand_Centered() * 10.0f; sp54.y = 2.0f * Rand_Centered(); sp54.z = Rand_Centered() * 10.0f; - EffectSsHahen_Spawn(globalCtx, &sp60, &sp54, &D_80BCCCE4, 0, 0x96, 1, 0x10, D_80BCCCDC[i & 1]); + EffectSsHahen_Spawn(play, &sp60, &sp54, &D_80BCCCE4, 0, 150, GAMEPLAY_KEEP, 16, D_80BCCCDC[i & 1]); } } @@ -156,14 +156,14 @@ void func_80BCAD64(EnScopenuts* this, s16 arg1) { Actor_UpdatePos(&this->actor); } -void func_80BCAE78(EnScopenuts* this, GlobalContext* globalCtx) { +void func_80BCAE78(EnScopenuts* this, PlayState* play) { if (this->unk_328 & 4) { Collider_UpdateCylinder(&this->actor, &this->collider); - CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + CollisionCheck_SetOC(play, &play->colChkCtx, &this->collider.base); } if (this->unk_328 & 2) { - Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 20.0f, 20.0f, 20.0f, 5); + Actor_UpdateBgCheckInfo(play, &this->actor, 20.0f, 20.0f, 20.0f, 5); } } @@ -189,21 +189,21 @@ s16 func_80BCAF0C(EnScopenuts* this) { return 0; } -void func_80BCAFA8(EnScopenuts* this, GlobalContext* globalCtx) { - Vec3f sp1C; +void func_80BCAFA8(EnScopenuts* this, PlayState* play) { + Vec3f screenPos; - func_80169474(globalCtx, &this->actor.world.pos, &sp1C); - if ((sp1C.x >= 130.0f) && (sp1C.x < 190.0f) && (sp1C.y >= 90.0f)) { - if (sp1C.y < 150.0f) { + Play_GetScreenPos(play, &this->actor.world.pos, &screenPos); + if ((screenPos.x >= 130.0f) && (screenPos.x < (SCREEN_WIDTH - 130.0f)) && (screenPos.y >= 90.0f)) { + if (screenPos.y < (SCREEN_HEIGHT - 90.0f)) { this->actor.draw = EnScopenuts_Draw; this->unk_348 = 10; - SubS_ChangeAnimationByInfoS(&this->skelAnime, sAnimations, 10); + SubS_ChangeAnimationByInfoS(&this->skelAnime, sAnimationInfo, 10); this->actionFunc = func_80BCB078; } } } -void func_80BCB078(EnScopenuts* this, GlobalContext* globalCtx) { +void func_80BCB078(EnScopenuts* this, PlayState* play) { Vec3s sp30; if (this->path != NULL) { @@ -235,7 +235,7 @@ void func_80BCB078(EnScopenuts* this, GlobalContext* globalCtx) { Actor_MoveWithoutGravity(&this->actor); } -void func_80BCB1C8(EnScopenuts* this, GlobalContext* globalCtx) { +void func_80BCB1C8(EnScopenuts* this, PlayState* play) { this->unk_350 *= 0.92f; Actor_SetScale(&this->actor, this->unk_350); if (this->actor.bgCheckFlags & 1) { @@ -244,9 +244,9 @@ void func_80BCB1C8(EnScopenuts* this, GlobalContext* globalCtx) { } } -void func_80BCB230(EnScopenuts* this, GlobalContext* globalCtx) { +void func_80BCB230(EnScopenuts* this, PlayState* play) { s16 sp26 = this->skelAnime.curFrame; - s16 sp24 = Animation_GetLastFrame(sAnimations[this->unk_348].animation); + s16 sp24 = Animation_GetLastFrame(sAnimationInfo[this->unk_348].animation); Math_ApproachS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer, 2, 0xE38); @@ -256,94 +256,94 @@ void func_80BCB230(EnScopenuts* this, GlobalContext* globalCtx) { this->actionFunc = func_80BCB4DC; this->unk_348 = 3; this->collider.dim.height = 64; - func_80BCAC40(this, globalCtx); - SubS_ChangeAnimationByInfoS(&this->skelAnime, sAnimations, 3); + func_80BCAC40(this, play); + SubS_ChangeAnimationByInfoS(&this->skelAnime, sAnimationInfo, 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); - SubS_ChangeAnimationByInfoS(&this->skelAnime, sAnimations, 17); + SubS_ChangeAnimationByInfoS(&this->skelAnime, sAnimationInfo, 17); } else if (this->unk_348 == 2) { this->unk_348 = 16; this->collider.dim.height = 32; Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_NUTS_UP); - SubS_ChangeAnimationByInfoS(&this->skelAnime, sAnimations, 16); + SubS_ChangeAnimationByInfoS(&this->skelAnime, sAnimationInfo, 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; - SubS_ChangeAnimationByInfoS(&this->skelAnime, sAnimations, 2); + SubS_ChangeAnimationByInfoS(&this->skelAnime, sAnimationInfo, 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; - SubS_ChangeAnimationByInfoS(&this->skelAnime, sAnimations, 18); + SubS_ChangeAnimationByInfoS(&this->skelAnime, sAnimationInfo, 18); } } } -void func_80BCB4DC(EnScopenuts* this, GlobalContext* globalCtx) { +void func_80BCB4DC(EnScopenuts* this, PlayState* play) { if (this->skelAnime.curFrame == this->skelAnime.endFrame) { this->actionFunc = func_80BCB52C; - SubS_ChangeAnimationByInfoS(&this->skelAnime, sAnimations, 0); + SubS_ChangeAnimationByInfoS(&this->skelAnime, sAnimationInfo, 0); } } -void func_80BCB52C(EnScopenuts* this, GlobalContext* globalCtx) { +void func_80BCB52C(EnScopenuts* this, PlayState* play) { Math_SmoothStepToS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer, 3, 2000, 0); this->actor.world.rot.y = this->actor.shape.rot.y; - if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { + if (Actor_ProcessTalkRequest(&this->actor, &play->state)) { this->unk_33C = func_80BCAF0C(this); - Message_StartTextbox(globalCtx, this->unk_33C, &this->actor); + Message_StartTextbox(play, 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)) || this->actor.isTargeted) { - func_800B8614(&this->actor, globalCtx, 100.0f); + func_800B8614(&this->actor, play, 100.0f); } else if (!(((this->actor.playerHeightRel < 50.0f) && (this->actor.playerHeightRel > -50.0f)) ? true : false) || !((this->actor.xzDistToPlayer < 200.0f) ? true : false)) { this->unk_348 = 4; - SubS_ChangeAnimationByInfoS(&this->skelAnime, sAnimations, 4); + SubS_ChangeAnimationByInfoS(&this->skelAnime, sAnimationInfo, 4); this->actionFunc = func_80BCB230; } } -void func_80BCB6D0(EnScopenuts* this, GlobalContext* globalCtx) { - u8 temp_v0 = Message_GetState(&globalCtx->msgCtx); +void func_80BCB6D0(EnScopenuts* this, PlayState* play) { + u8 talkState = Message_GetState(&play->msgCtx); - if (temp_v0 == 5) { - if (Message_ShouldAdvance(globalCtx)) { + if (talkState == TEXT_STATE_5) { + if (Message_ShouldAdvance(play)) { if (this->unk_328 & 1) { this->unk_328 &= ~1; - globalCtx->msgCtx.msgMode = 0x43; - globalCtx->msgCtx.unk12023 = 4; + play->msgCtx.msgMode = 0x43; + play->msgCtx.stateTimer = 4; this->actor.flags &= ~ACTOR_FLAG_1; this->unk_328 &= ~4; this->unk_348 = 8; - SubS_ChangeAnimationByInfoS(&this->skelAnime, sAnimations, 8); + SubS_ChangeAnimationByInfoS(&this->skelAnime, sAnimationInfo, 8); this->actionFunc = func_80BCBA00; } else { this->unk_33C = func_80BCAF0C(this); - Message_StartTextbox(globalCtx, this->unk_33C, &this->actor); + Message_StartTextbox(play, this->unk_33C, &this->actor); } } - } else if (temp_v0 == 4) { - if (Message_ShouldAdvance(globalCtx) != 0) { - switch (globalCtx->msgCtx.choiceIndex) { + } else if (talkState == TEXT_STATE_CHOICE) { + if (Message_ShouldAdvance(play)) { + switch (play->msgCtx.choiceIndex) { case 0: if (gSaveContext.save.playerData.rupees < this->unk_358) { play_sound(NA_SE_SY_ERROR); this->unk_33C = 0x1636; this->unk_328 |= 1; - Message_StartTextbox(globalCtx, this->unk_33C, &this->actor); + Message_StartTextbox(play, this->unk_33C, &this->actor); } else { func_8019F208(); - globalCtx->msgCtx.msgMode = 0x43; - globalCtx->msgCtx.unk12023 = 4; - func_801159EC(this->unk_358 * -1); + play->msgCtx.msgMode = 0x43; + play->msgCtx.stateTimer = 4; + Rupees_ChangeBy(-this->unk_358); this->actionFunc = func_80BCB90C; } break; @@ -355,40 +355,40 @@ void func_80BCB6D0(EnScopenuts* this, GlobalContext* globalCtx) { this->unk_33C = 0x1635; this->unk_328 |= 1; } - Message_StartTextbox(globalCtx, this->unk_33C, &this->actor); + Message_StartTextbox(play, this->unk_33C, &this->actor); break; } } - } else if (temp_v0 == 6) { - func_800B85E0(&this->actor, globalCtx, 400.0f, -1); + } else if (talkState == TEXT_STATE_DONE) { + func_800B85E0(&this->actor, play, 400.0f, -1); this->actionFunc = func_80BCB980; } } -void func_80BCB90C(EnScopenuts* this, GlobalContext* globalCtx) { - if (Actor_HasParent(&this->actor, globalCtx)) { +void func_80BCB90C(EnScopenuts* this, PlayState* play) { + if (Actor_HasParent(&this->actor, play)) { this->actor.parent = NULL; gSaveContext.save.weekEventReg[53] |= 2; this->actionFunc = func_80BCB6D0; } else { - Actor_PickUp(&this->actor, globalCtx, GI_HEART_PIECE, 300.0f, 300.0f); + Actor_PickUp(&this->actor, play, GI_HEART_PIECE, 300.0f, 300.0f); } } -void func_80BCB980(EnScopenuts* this, GlobalContext* globalCtx) { - if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { +void func_80BCB980(EnScopenuts* this, PlayState* play) { + if (Actor_ProcessTalkRequest(&this->actor, &play->state)) { this->unk_33C = 0x1637; this->unk_328 |= 1; - Message_StartTextbox(globalCtx, this->unk_33C, &this->actor); + Message_StartTextbox(play, this->unk_33C, &this->actor); this->actionFunc = func_80BCB6D0; } else { - func_800B85E0(&this->actor, globalCtx, 400.0f, -1); + func_800B85E0(&this->actor, play, 400.0f, -1); } } -void func_80BCBA00(EnScopenuts* this, GlobalContext* globalCtx) { +void func_80BCBA00(EnScopenuts* this, PlayState* play) { s16 sp26 = this->skelAnime.curFrame; - s16 sp24 = Animation_GetLastFrame(sAnimations[this->unk_348].animation); + s16 sp24 = Animation_GetLastFrame(sAnimationInfo[this->unk_348].animation); switch (sp26) { case 10: @@ -463,7 +463,7 @@ void func_80BCBA00(EnScopenuts* this, GlobalContext* globalCtx) { if (sp26 == sp24) { this->unk_35A = 3; this->unk_348 = 19; - SubS_ChangeAnimationByInfoS(&this->skelAnime, sAnimations, 19); + SubS_ChangeAnimationByInfoS(&this->skelAnime, sAnimationInfo, 19); Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_NUTS_DOWN); this->unk_328 &= ~2; this->unk_34E = 50; @@ -473,7 +473,7 @@ void func_80BCBA00(EnScopenuts* this, GlobalContext* globalCtx) { } } -void func_80BCBC60(EnScopenuts* this, GlobalContext* globalCtx) { +void func_80BCBC60(EnScopenuts* this, PlayState* play) { f32 sp24; Vec3f sp18; @@ -484,7 +484,7 @@ void func_80BCBC60(EnScopenuts* this, GlobalContext* globalCtx) { sp18.x = this->actor.world.pos.x; sp18.y = this->unk_32C; sp18.z = this->actor.world.pos.z; - func_800B14D4(globalCtx, 20.0f, &sp18); + func_800B14D4(play, 20.0f, &sp18); } if (sp24 > 5.0f) { @@ -495,10 +495,10 @@ void func_80BCBC60(EnScopenuts* this, GlobalContext* globalCtx) { } } -void func_80BCBD28(EnScopenuts* this, GlobalContext* globalCtx) { +void func_80BCBD28(EnScopenuts* this, PlayState* play) { Vec3f sp44; s16 sp42 = this->skelAnime.curFrame; - s16 sp40 = Animation_GetLastFrame(sAnimations[this->unk_348].animation); + s16 sp40 = Animation_GetLastFrame(sAnimationInfo[this->unk_348].animation); Vec3s sp38; func_80BCC448(this->path, this->unk_334, &this->actor.world.pos, &sp38); @@ -514,27 +514,27 @@ void func_80BCBD28(EnScopenuts* this, GlobalContext* globalCtx) { if (DECR(this->unk_34E) == 0) { if (!(this->unk_370 & 3)) { sp44 = this->actor.world.pos; - func_800B14D4(globalCtx, 20.0f, &sp44); + func_800B14D4(play, 20.0f, &sp44); } this->actor.velocity.y = 5.0f; } else if (!(this->unk_370 & 3)) { sp44.x = this->actor.world.pos.x; sp44.y = this->unk_32C; sp44.z = this->actor.world.pos.z; - func_800B14D4(globalCtx, 20.0f, &sp44); + func_800B14D4(play, 20.0f, &sp44); } if ((this->actor.home.pos.y + 22.5f) < this->actor.world.pos.y) { this->unk_368 = 0.3f; this->unk_348 = 9; - SubS_ChangeAnimationByInfoS(&this->skelAnime, sAnimations, 9); + SubS_ChangeAnimationByInfoS(&this->skelAnime, sAnimationInfo, 9); Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_AKINDONUTS_HIDE); - func_80BCAC40(this, globalCtx); + func_80BCAC40(this, play); this->actionFunc = func_80BCBF0C; } } -void func_80BCBF0C(EnScopenuts* this, GlobalContext* globalCtx) { +void func_80BCBF0C(EnScopenuts* this, PlayState* play) { this->unk_340 += this->unk_34C; if (this->unk_368 >= 1.0f) { this->unk_368 = 1.0f; @@ -547,14 +547,14 @@ 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; - SubS_ChangeAnimationByInfoS(&this->skelAnime, sAnimations, 10); + SubS_ChangeAnimationByInfoS(&this->skelAnime, sAnimationInfo, 10); this->unk_328 |= 2; this->unk_36E = 0; this->actionFunc = func_80BCBFFC; } } -void func_80BCBFFC(EnScopenuts* this, GlobalContext* globalCtx) { +void func_80BCBFFC(EnScopenuts* this, PlayState* play) { Vec3s sp38; f32 sp34; s16 sp32 = 0; @@ -625,7 +625,7 @@ void func_80BCBFFC(EnScopenuts* this, GlobalContext* globalCtx) { this->unk_36E++; } -void func_80BCC288(EnScopenuts* this, GlobalContext* globalCtx) { +void func_80BCC288(EnScopenuts* this, PlayState* play) { Actor_MarkForDeath(&this->actor); } @@ -680,7 +680,7 @@ f32 func_80BCC448(Path* path, s32 arg1, Vec3f* arg2, Vec3s* arg3) { return sp20.y - arg2->y; } -void EnScopenuts_Init(Actor* thisx, GlobalContext* globalCtx) { +void EnScopenuts_Init(Actor* thisx, PlayState* play) { s32 pad; EnScopenuts* this = THIS; @@ -691,10 +691,10 @@ void EnScopenuts_Init(Actor* thisx, GlobalContext* globalCtx) { } Actor_ProcessInitChain(&this->actor, sInitChain); - SkelAnime_InitFlex(globalCtx, &this->skelAnime, &object_dnt_Skel_00AC70, &object_dnt_Anim_005488, this->jointTable, + SkelAnime_InitFlex(play, &this->skelAnime, &object_dnt_Skel_00AC70, &object_dnt_Anim_005488, this->jointTable, this->morphTable, 28); - Collider_InitCylinder(globalCtx, &this->collider); - Collider_SetCylinderType1(globalCtx, &this->collider, &this->actor, &sCylinderInit); + Collider_InitCylinder(play, &this->collider); + Collider_SetCylinderType1(play, &this->collider, &this->actor, &sCylinderInit); ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 35.0f); this->unk_350 = 0.01f; Actor_SetScale(&this->actor, 0.01f); @@ -707,8 +707,8 @@ void EnScopenuts_Init(Actor* thisx, GlobalContext* globalCtx) { if (ENSCOPENUTS_GET_3E0(&this->actor) == ENSCOPENUTS_3E0_0) { if (gSaveContext.save.weekEventReg[52] & 0x40) { Actor_MarkForDeath(&this->actor); - } else if (globalCtx->actorCtx.unk5 & 2) { - this->path = SubS_GetPathByIndex(globalCtx, ENSCOPENUTS_GET_FC00(&this->actor), 0x3F); + } else if (play->actorCtx.unk5 & 2) { + this->path = SubS_GetPathByIndex(play, ENSCOPENUTS_GET_FC00(&this->actor), 0x3F); this->actor.draw = NULL; this->actionFunc = func_80BCAFA8; this->actor.gravity = 0.0f; @@ -717,7 +717,7 @@ void EnScopenuts_Init(Actor* thisx, GlobalContext* globalCtx) { } } else if (ENSCOPENUTS_GET_3E0(&this->actor) == ENSCOPENUTS_3E0_1) { if (gSaveContext.save.weekEventReg[52] & 0x40) { - this->path = SubS_GetPathByIndex(globalCtx, ENSCOPENUTS_GET_FC00(&this->actor), 0x3F); + this->path = SubS_GetPathByIndex(play, ENSCOPENUTS_GET_FC00(&this->actor), 0x3F); if (this->path == NULL) { Actor_MarkForDeath(&this->actor); } else { @@ -728,7 +728,7 @@ void EnScopenuts_Init(Actor* thisx, GlobalContext* globalCtx) { this->unk_358 = 150; this->unk_348 = 4; this->unk_35A = 0; - SubS_ChangeAnimationByInfoS(&this->skelAnime, sAnimations, 4); + SubS_ChangeAnimationByInfoS(&this->skelAnime, sAnimationInfo, 4); this->actionFunc = func_80BCB230; } } else { @@ -739,29 +739,28 @@ void EnScopenuts_Init(Actor* thisx, GlobalContext* globalCtx) { } } -void EnScopenuts_Destroy(Actor* thisx, GlobalContext* globalCtx) { +void EnScopenuts_Destroy(Actor* thisx, PlayState* play) { EnScopenuts* this = THIS; - Collider_DestroyCylinder(globalCtx, &this->collider); + Collider_DestroyCylinder(play, &this->collider); } -void EnScopenuts_Update(Actor* thisx, GlobalContext* globalCtx) { +void EnScopenuts_Update(Actor* thisx, PlayState* play) { EnScopenuts* this = THIS; Actor_SetFocus(&this->actor, 60.0f); SkelAnime_Update(&this->skelAnime); Actor_MoveWithGravity(&this->actor); - this->actionFunc(this, globalCtx); + this->actionFunc(this, play); if (this->unk_328 & 8) { func_800B9010(&this->actor, NA_SE_EN_AKINDO_FLY - SFX_FLAG); } - func_80BCAE78(this, globalCtx); + func_80BCAE78(this, play); } -s32 EnScopenuts_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, - Actor* thisx) { +s32 EnScopenuts_OverrideLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, Actor* thisx) { EnScopenuts* this = THIS; if (((this->unk_348 == 4) && (this->unk_35A == 0)) || ((this->unk_348 == 8) && (this->unk_35A == 0)) || @@ -802,10 +801,10 @@ s32 EnScopenuts_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** return false; } -void EnScopenuts_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx) { +void EnScopenuts_PostLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx) { } -void EnScopenuts_TransformLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Actor* thisx) { +void EnScopenuts_TransformLimbDraw(PlayState* play, s32 limbIndex, Actor* thisx) { EnScopenuts* this = THIS; if (((this->unk_35A == 1) || (this->unk_35A == 2)) && ((limbIndex == 23) || (limbIndex == 24))) { @@ -817,15 +816,15 @@ 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); } } -void EnScopenuts_Draw(Actor* thisx, GlobalContext* globalCtx) { +void EnScopenuts_Draw(Actor* thisx, PlayState* play) { EnScopenuts* this = THIS; - func_8012C28C(globalCtx->state.gfxCtx); - SkelAnime_DrawTransformFlexOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, + func_8012C28C(play->state.gfxCtx); + SkelAnime_DrawTransformFlexOpa(play, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, EnScopenuts_OverrideLimbDraw, EnScopenuts_PostLimbDraw, EnScopenuts_TransformLimbDraw, &this->actor); } diff --git a/src/overlays/actors/ovl_En_Scopenuts/z_en_scopenuts.h b/src/overlays/actors/ovl_En_Scopenuts/z_en_scopenuts.h index c4a00f84a..3f6f43544 100644 --- a/src/overlays/actors/ovl_En_Scopenuts/z_en_scopenuts.h +++ b/src/overlays/actors/ovl_En_Scopenuts/z_en_scopenuts.h @@ -5,7 +5,7 @@ struct EnScopenuts; -typedef void (*EnScopenutsActionFunc)(struct EnScopenuts*, GlobalContext*); +typedef void (*EnScopenutsActionFunc)(struct EnScopenuts*, PlayState*); #define ENSCOPENUTS_GET_3E0(thisx) (((thisx)->params & 0x3E0) >> 5) #define ENSCOPENUTS_GET_FC00(thisx) (((thisx)->params & 0xFC00) >> 0xA) @@ -14,37 +14,37 @@ typedef void (*EnScopenutsActionFunc)(struct EnScopenuts*, GlobalContext*); #define ENSCOPENUTS_3E0_1 1 typedef struct EnScopenuts { - /* 0x0000 */ Actor actor; - /* 0x0144 */ SkelAnime skelAnime; - /* 0x0188 */ Vec3s jointTable[28]; - /* 0x0230 */ Vec3s morphTable[28]; - /* 0x02D8 */ EnScopenutsActionFunc actionFunc; - /* 0x02DC */ ColliderCylinder collider; - /* 0x0328 */ u16 unk_328; - /* 0x032C */ f32 unk_32C; - /* 0x0330 */ Path* path; - /* 0x0334 */ s32 unk_334; - /* 0x0338 */ s16 unk_338; - /* 0x033A */ UNK_TYPE1 unk33A[2]; - /* 0x033C */ u16 unk_33C; - /* 0x033E */ s16 unk_33E; - /* 0x0340 */ s16 unk_340; - /* 0x0342 */ UNK_TYPE1 unk342[0x6]; - /* 0x0348 */ s32 unk_348; - /* 0x034C */ s16 unk_34C; - /* 0x034E */ s16 unk_34E; - /* 0x0350 */ f32 unk_350; - /* 0x0354 */ UNK_TYPE1 unk354[4]; - /* 0x0358 */ s16 unk_358; - /* 0x035A */ s16 unk_35A; - /* 0x035C */ f32 unk_35C; - /* 0x0360 */ f32 unk_360; - /* 0x0364 */ f32 unk_364; - /* 0x0368 */ f32 unk_368; - /* 0x036C */ s16 unk_36C; - /* 0x036E */ s16 unk_36E; - /* 0x0370 */ s16 unk_370; - /* 0x0372 */ s16 unk_372; + /* 0x000 */ Actor actor; + /* 0x144 */ SkelAnime skelAnime; + /* 0x188 */ Vec3s jointTable[28]; + /* 0x230 */ Vec3s morphTable[28]; + /* 0x2D8 */ EnScopenutsActionFunc actionFunc; + /* 0x2DC */ ColliderCylinder collider; + /* 0x328 */ u16 unk_328; + /* 0x32C */ f32 unk_32C; + /* 0x330 */ Path* path; + /* 0x334 */ s32 unk_334; + /* 0x338 */ s16 unk_338; + /* 0x33A */ UNK_TYPE1 unk33A[2]; + /* 0x33C */ u16 unk_33C; + /* 0x33E */ s16 unk_33E; + /* 0x340 */ s16 unk_340; + /* 0x342 */ UNK_TYPE1 unk342[0x6]; + /* 0x348 */ s32 unk_348; + /* 0x34C */ s16 unk_34C; + /* 0x34E */ s16 unk_34E; + /* 0x350 */ f32 unk_350; + /* 0x354 */ UNK_TYPE1 unk354[4]; + /* 0x358 */ s16 unk_358; + /* 0x35A */ s16 unk_35A; + /* 0x35C */ f32 unk_35C; + /* 0x360 */ f32 unk_360; + /* 0x364 */ f32 unk_364; + /* 0x368 */ f32 unk_368; + /* 0x36C */ s16 unk_36C; + /* 0x36E */ s16 unk_36E; + /* 0x370 */ s16 unk_370; + /* 0x372 */ s16 unk_372; } EnScopenuts; // size = 0x374 extern const ActorInit En_Scopenuts_InitVars; diff --git a/src/overlays/actors/ovl_En_Sda/z_en_sda.c b/src/overlays/actors/ovl_En_Sda/z_en_sda.c index 0103b1d62..19fac24a8 100644 --- a/src/overlays/actors/ovl_En_Sda/z_en_sda.c +++ b/src/overlays/actors/ovl_En_Sda/z_en_sda.c @@ -10,13 +10,13 @@ #define THIS ((EnSda*)thisx) -void EnSda_Init(Actor* thisx, GlobalContext* globalCtx); -void EnSda_Destroy(Actor* thisx, GlobalContext* globalCtx); -void EnSda_Update(Actor* thisx, GlobalContext* globalCtx); -void EnSda_Draw(Actor* thisx, GlobalContext* globalCtx); +void EnSda_Init(Actor* thisx, PlayState* play); +void EnSda_Destroy(Actor* thisx, PlayState* play); +void EnSda_Update(Actor* thisx, PlayState* play); +void EnSda_Draw(Actor* thisx, PlayState* play); -void func_8094702C(EnSda* this, u8* shadowTexture, Player* player, GlobalContext* globalCtx); -void func_80947668(u8* shadowTexture, Player* player, GlobalContext* globalCtx); +void func_8094702C(EnSda* this, u8* shadowTexture, Player* player, PlayState* play); +void func_80947668(u8* shadowTexture, Player* player, PlayState* play); Vec3f D_80947EA0[16]; @@ -72,40 +72,40 @@ static s32 sPad[2] = { 0, 0 }; #include "overlays/ovl_En_Sda/ovl_En_Sda.c" -void EnSda_Init(Actor* thisx, GlobalContext* globalCtx) { +void EnSda_Init(Actor* thisx, PlayState* play) { } -void EnSda_Destroy(Actor* thisx, GlobalContext* globalCtx) { +void EnSda_Destroy(Actor* thisx, PlayState* play) { } -void EnSda_Update(Actor* thisx, GlobalContext* globalCtx) { +void EnSda_Update(Actor* thisx, PlayState* play) { EnSda* this = THIS; Player* player; if (this->actor.params == ENSDA_1) { player = (Player*)this->actor.parent; } else { - player = GET_PLAYER(globalCtx); + player = GET_PLAYER(play); } this->actor.world.pos = player->actor.world.pos; } -void EnSda_Draw(Actor* thisx, GlobalContext* globalCtx) { +void EnSda_Draw(Actor* thisx, PlayState* play) { EnSda* this = THIS; Player* player; - u8* shadowTexture = GRAPH_ALLOC(globalCtx->state.gfxCtx, 64 * 64); + u8* shadowTexture = GRAPH_ALLOC(play->state.gfxCtx, 64 * 64); if (this->actor.params == ENSDA_1) { player = (Player*)this->actor.parent; } else { - player = GET_PLAYER(globalCtx); + player = GET_PLAYER(play); } player->actor.shape.shadowAlpha = 0; - func_8094702C(this, shadowTexture, player, globalCtx); + func_8094702C(this, shadowTexture, player, play); if (KREG(0) < 5) { - func_80947668(shadowTexture, player, globalCtx); + func_80947668(shadowTexture, player, play); } } @@ -138,7 +138,7 @@ void func_809469C0(Player* player, u8* shadowTexture, f32 arg2) { sp88.z = D_80947EA0[i].z - player->actor.world.pos.z; } - Matrix_MultiplyVector3fByState(&sp88, &sp7C); + 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; @@ -209,7 +209,7 @@ void func_809469C0(Player* player, u8* shadowTexture, f32 arg2) { } } -void func_8094702C(EnSda* this, u8* shadowTexture, Player* player, GlobalContext* globalCtx) { +void func_8094702C(EnSda* this, u8* shadowTexture, Player* player, PlayState* play) { s16 temp_t0; s16 temp_t1; s16 temp_v0; @@ -240,7 +240,7 @@ void func_8094702C(EnSda* this, u8* shadowTexture, Player* player, GlobalContext } } - Matrix_SetStateXRotation((BREG(50) + 70) / 100.0f); + Matrix_RotateXFNew((BREG(50) + 70) / 100.0f); for (i = 0; i < 18; i++) { if (D_80947AFC[i] >= 0) { @@ -258,31 +258,31 @@ void func_8094702C(EnSda* this, u8* shadowTexture, Player* player, GlobalContext } if (this->actor.params != ENSDA_1) { - func_8018219C(&player->shieldMf, &sp178, false); + Matrix_MtxFToYXZRot(&player->shieldMf, &sp178, false); sp178.y += (KREG(87) * 0x8000) + 0x8000; sp178.x *= (KREG(88) - 1); - Matrix_InsertMatrix(&player->shieldMf, MTXMODE_NEW); - Matrix_MultiplyVector3fByState(&D_80947A60, &sp16C); - Matrix_RotateY(sp178.y, MTXMODE_NEW); - Matrix_InsertXRotation_s(sp178.x, MTXMODE_APPLY); + 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_MultiplyVector3fByState(&D_80947B10[i], &sp188); + 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_SetStateXRotation((BREG(50) + 70) / 100.0f); + 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_MultiplyVector3fByState(&sp194, &sp188); + Matrix_MultVec3f(&sp194, &sp188); sp188.x *= (1.0f + (KREG(90) / 100.0f)); sp188.y *= (1.0f + (KREG(90) / 100.0f)); @@ -315,32 +315,31 @@ void func_8094702C(EnSda* this, u8* shadowTexture, Player* player, GlobalContext } } -void func_80947668(u8* shadowTexture, Player* player, GlobalContext* globalCtx) { - GraphicsContext* gfxCtx = globalCtx->state.gfxCtx; +void func_80947668(u8* shadowTexture, Player* player, PlayState* play) { + GraphicsContext* gfxCtx = play->state.gfxCtx; f32 tempx; f32 tempz; s16 i; OPEN_DISPS(gfxCtx); - func_8012C448(globalCtx->state.gfxCtx); + func_8012C448(play->state.gfxCtx); gDPSetPrimColor(POLY_XLU_DISP++, 0x00, 0x00, 0, 0, 0, (BREG(52) + 50)); gDPSetEnvColor(POLY_XLU_DISP++, 0, 0, 0, 0); - Matrix_InsertTranslation(player->actor.world.pos.x, player->actor.floorHeight, player->actor.world.pos.z, - MTXMODE_NEW); - Matrix_InsertYRotation_f(BREG(51) / 100.0f, MTXMODE_APPLY); + Matrix_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_InsertTranslation(tempx, 0.0f, tempz, MTXMODE_APPLY); + 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); + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(play->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); @@ -348,7 +347,7 @@ void func_80947668(u8* shadowTexture, Player* player, GlobalContext* globalCtx) 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); + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_XLU_DISP++, ovl_En_Sda_DL_14B8); } 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 5ce4184a6..8e0ad276c 100644 --- a/src/overlays/actors/ovl_En_Sekihi/z_en_sekihi.c +++ b/src/overlays/actors/ovl_En_Sekihi/z_en_sekihi.c @@ -5,21 +5,25 @@ */ #include "z_en_sekihi.h" +#include "objects/object_sekihil/object_sekihil.h" +#include "objects/object_sekihig/object_sekihig.h" +#include "objects/object_sekihin/object_sekihin.h" +#include "objects/object_sekihiz/object_sekihiz.h" +#include "objects/object_zog/object_zog.h" #define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_8 | ACTOR_FLAG_10) #define THIS ((EnSekihi*)thisx) -void EnSekihi_Init(Actor* thisx, GlobalContext* globalCtx); -void EnSekihi_Destroy(Actor* thisx, GlobalContext* globalCtx); -void EnSekihi_Update(Actor* thisx, GlobalContext* globalCtx); +void EnSekihi_Init(Actor* thisx, PlayState* play); +void EnSekihi_Destroy(Actor* thisx, PlayState* play); +void EnSekihi_Update(Actor* thisx, PlayState* play); +void EnSekihi_Draw(Actor* thisx, PlayState* play); -void func_80A44DE8(EnSekihi* this, GlobalContext* globalCtx); -void func_80A44F40(EnSekihi* this, GlobalContext* globalCtx); -void func_80A450B0(EnSekihi* this, GlobalContext* globalCtx); -void func_80A45130(EnSekihi* this, GlobalContext* globalCtx); +void func_80A44DE8(EnSekihi* this, PlayState* play); +void func_80A450B0(EnSekihi* this, PlayState* play); +void EnSekihi_DoNothing(EnSekihi* this, PlayState* play); -#if 0 const ActorInit En_Sekihi_InitVars = { ACTOR_EN_SEKIHI, ACTORCAT_PROP, @@ -32,20 +36,150 @@ const ActorInit En_Sekihi_InitVars = { (ActorFunc)NULL, }; -#endif +static s16 sObjectIds[] = { OBJECT_SEKIHIL, OBJECT_SEKIHIG, OBJECT_SEKIHIN, OBJECT_SEKIHIZ, OBJECT_ZOG }; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Sekihi/EnSekihi_Init.s") +static Gfx* sOpaDLists[] = { + gGraveTriforceSymbolDL, gGraveGoronSymbolDL, gGraveKokiriSymbolDL, gTombSongOfSoaringDL, gMikauGraveDL, +}; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Sekihi/EnSekihi_Destroy.s") +static Gfx* sXluDLists[] = { + gSunSongTriforceSymbolDL, gSunSongGoronSymbolDL, gSunSongKokiriSymbolDL, gSekihizEmptyDL, gMikauGraveDirtDL, +}; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Sekihi/func_80A44DE8.s") +static u16 sTextIds[] = { 0, 0, 0, 0, 0x1018 }; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Sekihi/func_80A44F40.s") +void EnSekihi_Init(Actor* thisx, PlayState* play) { + EnSekihi* this = THIS; + s32 params = ENSIKIHI_GET_TYPE(thisx); + s32 objectIndex; + s32 pad; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Sekihi/func_80A450B0.s") + if ((params < SEKIHI_TYPE_0 || params >= SEKIHI_TYPE_MAX) || sOpaDLists[params] == NULL) { + Actor_MarkForDeath(&this->dyna.actor); + } else { + if ((params == SEKIHI_TYPE_4) && (((gSaveContext.save.skullTokenCount & 0xFFFF)) >= 30)) { + gSaveContext.save.weekEventReg[13] |= 0x20; + } + objectIndex = Object_GetIndex(&play->objectCtx, sObjectIds[params]); + if (objectIndex >= 0) { + this->objectIndex = objectIndex; + } + this->actionFunc = func_80A44DE8; + this->opaDList = sOpaDLists[params]; + this->xluDList = sXluDLists[params]; + this->dyna.actor.textId = sTextIds[params]; + this->dyna.actor.focus.pos.y = this->dyna.actor.world.pos.y + 60.0f; + Actor_SetScale(&this->dyna.actor, 0.1f); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Sekihi/func_80A45130.s") +void EnSekihi_Destroy(Actor* thisx, PlayState* play) { + EnSekihi* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Sekihi/EnSekihi_Update.s") + DynaPoly_DeleteBgActor(play, &play->colCtx.dyna, this->dyna.bgId); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Sekihi/func_80A45164.s") +void func_80A44DE8(EnSekihi* this, PlayState* play) { + CollisionHeader* colHeader = NULL; + s32 params; + CollisionHeader* colHeaders[] = { + &gSekihilCol, &gSekihigCol, &gSekihinCol, &gSekihizCol, &gObjectZogCol, + }; + + params = ENSIKIHI_GET_TYPE(&this->dyna.actor); + if (Object_IsLoaded(&play->objectCtx, this->objectIndex)) { + this->dyna.actor.objBankIndex = this->objectIndex; + this->dyna.actor.draw = EnSekihi_Draw; + if (params == SEKIHI_TYPE_4) { + this->actionFunc = func_80A450B0; + } else { + this->actionFunc = EnSekihi_DoNothing; + } + + Actor_SetObjectDependency(play, &this->dyna.actor); + DynaPolyActor_Init(&this->dyna, 0); + if (colHeaders[params] != NULL) { + CollisionHeader_GetVirtual(colHeaders[params], &colHeader); + } + + this->dyna.bgId = DynaPoly_SetBgActor(play, &play->colCtx.dyna, &this->dyna.actor, colHeader); + if ((params == SEKIHI_TYPE_4) && (INV_CONTENT(ITEM_MASK_ZORA) != ITEM_MASK_ZORA)) { + Actor_MarkForDeath(&this->dyna.actor); + } + } +} + +void func_80A44F40(EnSekihi* this, PlayState* play) { + switch (Message_GetState(&play->msgCtx)) { + case TEXT_STATE_CHOICE: + if (Message_ShouldAdvance(play) && (play->msgCtx.currentTextId == 0x1019)) { + switch (play->msgCtx.choiceIndex) { + case 0: + func_8019F208(); + func_80151938(play, 0x101A); + break; + case 1: + func_8019F208(); + func_80151938(play, 0x101B); + break; + case 2: + func_8019F230(); + func_801477B4(play); + this->actionFunc = func_80A450B0; + break; + } + } else { + break; + } + break; + case TEXT_STATE_5: + if (Message_ShouldAdvance(play)) { + switch (play->msgCtx.currentTextId) { + case 0x1018: + func_80151938(play, play->msgCtx.currentTextId + 1); + break; + case 0x101A: + case 0x101B: + func_801477B4(play); + this->actionFunc = func_80A450B0; + break; + } + } + break; + } +} + +void func_80A450B0(EnSekihi* this, PlayState* play) { + if (Actor_ProcessTalkRequest(&this->dyna.actor, &play->state)) { + this->actionFunc = func_80A44F40; + } else if ((this->dyna.actor.xzDistToPlayer < 100.0f) && (Player_IsFacingActor(&this->dyna.actor, 0x2600, play))) { + func_800B8614(&this->dyna.actor, play, 120.0f); + } +} + +void EnSekihi_DoNothing(EnSekihi* this, PlayState* play) { +} + +void EnSekihi_Update(Actor* thisx, PlayState* play) { + EnSekihi* this = THIS; + + this->actionFunc(this, play); +} + +void EnSekihi_Draw(Actor* thisx, PlayState* play) { + EnSekihi* this = THIS; + + OPEN_DISPS(play->state.gfxCtx); + + if (this->xluDList != NULL) { + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + func_8012C2DC(play->state.gfxCtx); + gSPDisplayList(POLY_XLU_DISP++, this->xluDList); + } + + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + func_8012C28C(play->state.gfxCtx); + gSPDisplayList(POLY_OPA_DISP++, this->opaDList); + + CLOSE_DISPS(play->state.gfxCtx); +} diff --git a/src/overlays/actors/ovl_En_Sekihi/z_en_sekihi.h b/src/overlays/actors/ovl_En_Sekihi/z_en_sekihi.h index ab7d3bfb3..e626b616d 100644 --- a/src/overlays/actors/ovl_En_Sekihi/z_en_sekihi.h +++ b/src/overlays/actors/ovl_En_Sekihi/z_en_sekihi.h @@ -3,16 +3,29 @@ #include "global.h" +#define ENSIKIHI_GET_TYPE(thisx) ((thisx)->params & 0xF) + struct EnSekihi; -typedef void (*EnSekihiActionFunc)(struct EnSekihi*, GlobalContext*); +typedef void (*EnSekihiActionFunc)(struct EnSekihi*, PlayState*); typedef struct EnSekihi { - /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x24]; - /* 0x0168 */ EnSekihiActionFunc actionFunc; + /* 0x000 */ DynaPolyActor dyna; + /* 0x15C */ Gfx* opaDList; + /* 0x160 */ Gfx* xluDList; + /* 0x164 */ s8 objectIndex; + /* 0x168 */ EnSekihiActionFunc actionFunc; } EnSekihi; // size = 0x16C +typedef enum SekihiType { + /* 0x0 */ SEKIHI_TYPE_0, + /* 0x1 */ SEKIHI_TYPE_1, + /* 0x2 */ SEKIHI_TYPE_2, + /* 0x3 */ SEKIHI_TYPE_3, + /* 0x4 */ SEKIHI_TYPE_4, + /* 0x5 */ SEKIHI_TYPE_MAX +} SekihiType; + extern const ActorInit En_Sekihi_InitVars; #endif // Z_EN_SEKIHI_H diff --git a/src/overlays/actors/ovl_En_Sellnuts/z_en_sellnuts.c b/src/overlays/actors/ovl_En_Sellnuts/z_en_sellnuts.c index 5735d1e28..d4a726887 100644 --- a/src/overlays/actors/ovl_En_Sellnuts/z_en_sellnuts.c +++ b/src/overlays/actors/ovl_En_Sellnuts/z_en_sellnuts.c @@ -11,27 +11,27 @@ #define THIS ((EnSellnuts*)thisx) -void EnSellnuts_Init(Actor* thisx, GlobalContext* globalCtx); -void EnSellnuts_Destroy(Actor* thisx, GlobalContext* globalCtx); -void EnSellnuts_Update(Actor* thisx, GlobalContext* globalCtx); -void EnSellnuts_Draw(Actor* thisx, GlobalContext* globalCtx); +void EnSellnuts_Init(Actor* thisx, PlayState* play); +void EnSellnuts_Destroy(Actor* thisx, PlayState* play); +void EnSellnuts_Update(Actor* thisx, PlayState* play); +void EnSellnuts_Draw(Actor* thisx, PlayState* play); -void func_80ADB4F4(EnSellnuts* this, GlobalContext* globalCtx); -void func_80ADB544(EnSellnuts* this, GlobalContext* globalCtx); -void func_80ADB924(EnSellnuts* this, GlobalContext* globalCtx); -void func_80ADBAB8(EnSellnuts* this, GlobalContext* globalCtx); -void func_80ADBBEC(EnSellnuts* this, GlobalContext* globalCtx); -void func_80ADBCE4(EnSellnuts* this, GlobalContext* globalCtx); -void func_80ADBD64(EnSellnuts* this, GlobalContext* globalCtx); -void func_80ADBE80(EnSellnuts* this, GlobalContext* globalCtx); -void func_80ADBFA0(EnSellnuts* this, GlobalContext* globalCtx); -void func_80ADC2CC(EnSellnuts* this, GlobalContext* globalCtx); -void func_80ADC37C(EnSellnuts* this, GlobalContext* globalCtx); -void func_80ADC580(EnSellnuts* this, GlobalContext* globalCtx); -void func_80ADC6D0(EnSellnuts* this, GlobalContext* globalCtx); -void func_80ADC7B4(EnSellnuts* this, GlobalContext* globalCtx); -void func_80ADC8C4(EnSellnuts* this, GlobalContext* globalCtx); -void func_80ADCA64(EnSellnuts* this, GlobalContext* globalCtx); +void func_80ADB4F4(EnSellnuts* this, PlayState* play); +void func_80ADB544(EnSellnuts* this, PlayState* play); +void func_80ADB924(EnSellnuts* this, PlayState* play); +void func_80ADBAB8(EnSellnuts* this, PlayState* play); +void func_80ADBBEC(EnSellnuts* this, PlayState* play); +void func_80ADBCE4(EnSellnuts* this, PlayState* play); +void func_80ADBD64(EnSellnuts* this, PlayState* play); +void func_80ADBE80(EnSellnuts* this, PlayState* play); +void func_80ADBFA0(EnSellnuts* this, PlayState* play); +void func_80ADC2CC(EnSellnuts* this, PlayState* play); +void func_80ADC37C(EnSellnuts* this, PlayState* play); +void func_80ADC580(EnSellnuts* this, PlayState* play); +void func_80ADC6D0(EnSellnuts* this, PlayState* play); +void func_80ADC7B4(EnSellnuts* this, PlayState* play); +void func_80ADC8C4(EnSellnuts* this, PlayState* play); +void func_80ADCA64(EnSellnuts* this, PlayState* play); s32 func_80ADCE4C(EnSellnuts* this, Path* path, s32 arg2); f32 func_80ADCFE8(Path* path, s32 arg1, Vec3f* pos, Vec3s* arg3); @@ -80,7 +80,7 @@ static ColliderCylinderInitType1 sCylinderInit = { { 27, 32, 0, { 0, 0, 0 } }, }; -static AnimationInfoS D_80ADD990[] = { +static AnimationInfoS sAnimationInfo[] = { { &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 }, @@ -111,14 +111,14 @@ static InitChainEntry sInitChain[] = { ICHAIN_F32(targetArrowOffset, 30, ICHAIN_STOP), }; -void func_80ADADD0(EnSellnuts* this, GlobalContext* globalCtx) { +void func_80ADADD0(EnSellnuts* this, PlayState* play) { if (this->unk_338 & 2) { Collider_UpdateCylinder(&this->actor, &this->collider); - CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + CollisionCheck_SetOC(play, &play->colChkCtx, &this->collider.base); } if (this->unk_338 & 1) { - Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 20.0f, 20.0f, 20.0f, 5); + Actor_UpdateBgCheckInfo(play, &this->actor, 20.0f, 20.0f, 20.0f, 5); } } @@ -208,8 +208,8 @@ void func_80ADAFC0(EnSellnuts* this) { } } -Actor* func_80ADB040(GlobalContext* globalCtx) { - Actor* actor = globalCtx->actorCtx.actorLists[ACTORCAT_NPC].first; +Actor* func_80ADB040(PlayState* play) { + Actor* actor = play->actorCtx.actorLists[ACTORCAT_NPC].first; while (actor != NULL) { if ((actor->id == ACTOR_EN_SELLNUTS) && !ENSELLNUTS_GET_1(actor)) { @@ -221,10 +221,10 @@ Actor* func_80ADB040(GlobalContext* globalCtx) { return NULL; } -f32 func_80ADB08C(GlobalContext* globalCtx) { +f32 func_80ADB08C(PlayState* play) { s32 pad; - Player* player = GET_PLAYER(globalCtx); - Actor* sp18 = func_80ADB040(globalCtx); + Player* player = GET_PLAYER(play); + Actor* sp18 = func_80ADB040(play); if (sp18 != NULL) { return Math_Vec3f_DistXZ(&player->actor.world.pos, &sp18->home.pos); @@ -233,27 +233,27 @@ f32 func_80ADB08C(GlobalContext* globalCtx) { return 80.0f; } -void func_80ADB0D8(EnSellnuts* this, GlobalContext* globalCtx) { +void func_80ADB0D8(EnSellnuts* this, PlayState* play) { s16 currentFrame = this->skelAnime.curFrame; - s16 frameCount = Animation_GetLastFrame(D_80ADD990[this->unk_34C].animation); + s16 frameCount = Animation_GetLastFrame(sAnimationInfo[this->unk_34C].animation); if (currentFrame == frameCount) { switch (this->unk_340) { case 0x611: case 0x62A: this->unk_34C = 0; - SubS_ChangeAnimationByInfoS(&this->skelAnime, D_80ADD990, 0); + SubS_ChangeAnimationByInfoS(&this->skelAnime, sAnimationInfo, 0); this->actionFunc = func_80ADBFA0; break; case 0x618: if (this->unk_34C == 1) { this->unk_34C = 0; - SubS_ChangeAnimationByInfoS(&this->skelAnime, D_80ADD990, 0); + SubS_ChangeAnimationByInfoS(&this->skelAnime, sAnimationInfo, 0); this->actionFunc = func_80ADB544; } else { this->unk_34C = 1; - SubS_ChangeAnimationByInfoS(&this->skelAnime, D_80ADD990, 1); + SubS_ChangeAnimationByInfoS(&this->skelAnime, sAnimationInfo, 1); this->actionFunc = func_80ADBFA0; } break; @@ -264,7 +264,7 @@ void func_80ADB0D8(EnSellnuts* this, GlobalContext* globalCtx) { case 0x614: case 0x628: this->unk_34C = 0; - SubS_ChangeAnimationByInfoS(&this->skelAnime, D_80ADD990, 0); + SubS_ChangeAnimationByInfoS(&this->skelAnime, sAnimationInfo, 0); this->actionFunc = func_80ADB924; break; @@ -273,23 +273,23 @@ void func_80ADB0D8(EnSellnuts* this, GlobalContext* globalCtx) { case 0x616: case 0x629: this->unk_34C = 1; - SubS_ChangeAnimationByInfoS(&this->skelAnime, D_80ADD990, 1); + SubS_ChangeAnimationByInfoS(&this->skelAnime, sAnimationInfo, 1); this->actionFunc = func_80ADB924; break; case 0x613: case 0x619: this->unk_34C = 7; - SubS_ChangeAnimationByInfoS(&this->skelAnime, D_80ADD990, 7); + SubS_ChangeAnimationByInfoS(&this->skelAnime, sAnimationInfo, 7); this->actionFunc = func_80ADBD64; break; } } } -void func_80ADB254(EnSellnuts* this, GlobalContext* globalCtx) { +void func_80ADB254(EnSellnuts* this, PlayState* play) { s16 currentFrame = this->skelAnime.curFrame; - s16 frameCount = Animation_GetLastFrame(D_80ADD990[this->unk_34C].animation); + s16 frameCount = Animation_GetLastFrame(sAnimationInfo[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) && @@ -298,50 +298,50 @@ void func_80ADB254(EnSellnuts* this, GlobalContext* globalCtx) { this->actionFunc = func_80ADB4F4; this->unk_34C = 3; this->collider.dim.height = 64; - SubS_ChangeAnimationByInfoS(&this->skelAnime, D_80ADD990, 3); + SubS_ChangeAnimationByInfoS(&this->skelAnime, sAnimationInfo, 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); - SubS_ChangeAnimationByInfoS(&this->skelAnime, D_80ADD990, 17); + SubS_ChangeAnimationByInfoS(&this->skelAnime, sAnimationInfo, 17); } else if (this->unk_34C == 2) { this->unk_34C = 16; this->collider.dim.height = 32; Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_NUTS_UP); - SubS_ChangeAnimationByInfoS(&this->skelAnime, D_80ADD990, 16); + SubS_ChangeAnimationByInfoS(&this->skelAnime, sAnimationInfo, 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; - SubS_ChangeAnimationByInfoS(&this->skelAnime, D_80ADD990, 2); + SubS_ChangeAnimationByInfoS(&this->skelAnime, sAnimationInfo, 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; - SubS_ChangeAnimationByInfoS(&this->skelAnime, D_80ADD990, 18); + SubS_ChangeAnimationByInfoS(&this->skelAnime, sAnimationInfo, 18); } } } } -void func_80ADB4F4(EnSellnuts* this, GlobalContext* globalCtx) { +void func_80ADB4F4(EnSellnuts* this, PlayState* play) { if (this->skelAnime.curFrame == this->skelAnime.endFrame) { this->actionFunc = func_80ADB544; - SubS_ChangeAnimationByInfoS(&this->skelAnime, D_80ADD990, 0); + SubS_ChangeAnimationByInfoS(&this->skelAnime, sAnimationInfo, 0); } } -void func_80ADB544(EnSellnuts* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); +void func_80ADB544(EnSellnuts* this, PlayState* play) { + Player* player = GET_PLAYER(play); Math_SmoothStepToS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer, 3, 0x7D0, 0); this->actor.world.rot.y = this->actor.shape.rot.y; - if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { - if (Player_GetExchangeItemId(globalCtx) == EXCH_ITEM_2A) { + if (Actor_ProcessTalkRequest(&this->actor, &play->state)) { + if (Player_GetExchangeItemId(play) == PLAYER_AP_MOON_TEAR) { player->actor.textId = D_80ADD928[this->unk_33A]; this->unk_340 = player->actor.textId; this->actionFunc = func_80ADBAB8; @@ -350,27 +350,27 @@ void func_80ADB544(EnSellnuts* this, GlobalContext* globalCtx) { case 0x60E: gSaveContext.save.weekEventReg[17] |= 0x20; gSaveContext.save.weekEventReg[86] |= 4; - Message_StartTextbox(globalCtx, this->unk_340, &this->actor); + Message_StartTextbox(play, this->unk_340, &this->actor); this->actionFunc = func_80ADB0D8; break; case 0x628: gSaveContext.save.weekEventReg[77] |= 0x40; gSaveContext.save.weekEventReg[86] |= 4; - Message_StartTextbox(globalCtx, this->unk_340, &this->actor); + Message_StartTextbox(play, this->unk_340, &this->actor); this->actionFunc = func_80ADB0D8; break; case 0x614: gSaveContext.save.weekEventReg[17] |= 0x40; - Message_StartTextbox(globalCtx, this->unk_340, &this->actor); + Message_StartTextbox(play, this->unk_340, &this->actor); this->actionFunc = func_80ADB0D8; break; case 0x610: case 0x616: case 0x629: - Message_StartTextbox(globalCtx, this->unk_340, &this->actor); + Message_StartTextbox(play, this->unk_340, &this->actor); this->actionFunc = func_80ADB0D8; break; @@ -382,7 +382,7 @@ void func_80ADB544(EnSellnuts* this, GlobalContext* globalCtx) { } else if (((this->actor.xzDistToPlayer < 80.0f) && (((this->actor.playerHeightRel < 50.0f) && (this->actor.playerHeightRel > -50.0f)) ? true : false)) || this->actor.isTargeted) { - func_800B85E0(&this->actor, globalCtx, 80.0f, EXCH_ITEM_2A); + func_800B85E0(&this->actor, play, 80.0f, PLAYER_AP_MOON_TEAR); if (player->transformation == PLAYER_FORM_DEKU) { if (gSaveContext.save.day == 3) { this->unk_33A = 2; @@ -409,20 +409,20 @@ 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; - SubS_ChangeAnimationByInfoS(&this->skelAnime, D_80ADD990, 4); + SubS_ChangeAnimationByInfoS(&this->skelAnime, sAnimationInfo, 4); this->actionFunc = func_80ADB254; } } -void func_80ADB924(EnSellnuts* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); - u8 msgState = Message_GetState(&globalCtx->msgCtx); +void func_80ADB924(EnSellnuts* this, PlayState* play) { + Player* player = GET_PLAYER(play); + u8 talkState = Message_GetState(&play->msgCtx); s32 item; - if (msgState == 0x10) { - item = func_80123810(globalCtx); - if (item > EXCH_ITEM_NONE) { - if (item == EXCH_ITEM_2A) { + if (talkState == TEXT_STATE_16) { + item = func_80123810(play); + if (item > PLAYER_AP_NONE) { + if (item == PLAYER_AP_MOON_TEAR) { player->actor.textId = D_80ADD928[this->unk_33A]; this->unk_340 = player->actor.textId; player->exchangeItemId = item; @@ -432,102 +432,102 @@ void func_80ADB924(EnSellnuts* this, GlobalContext* globalCtx) { this->unk_340 = player->actor.textId; this->actionFunc = func_80ADB0D8; } - func_801477B4(globalCtx); - } else if (item < EXCH_ITEM_NONE) { + func_801477B4(play); + } else if (item < PLAYER_AP_NONE) { this->unk_340 = D_80ADD920[this->unk_33A]; - func_80151938(globalCtx, this->unk_340); + func_80151938(play, this->unk_340); this->actionFunc = func_80ADB0D8; } - } else if ((msgState == 5) && Message_ShouldAdvance(globalCtx)) { + } else if ((talkState == TEXT_STATE_5) && Message_ShouldAdvance(play)) { if (this->unk_340 == D_80ADD910[this->unk_33A]) { this->unk_340 = D_80ADD938[this->unk_33A]; - func_80151938(globalCtx, this->unk_340); + func_80151938(play, this->unk_340); this->actionFunc = func_80ADB0D8; } else { this->unk_340 = 0xFF; - func_80151938(globalCtx, this->unk_340); + func_80151938(play, this->unk_340); this->actionFunc = func_80ADB0D8; } } } -void func_80ADBAB8(EnSellnuts* this, GlobalContext* globalCtx) { - u8 sp27 = Message_GetState(&globalCtx->msgCtx); +void func_80ADBAB8(EnSellnuts* this, PlayState* play) { + u8 talkState = Message_GetState(&play->msgCtx); s16 currentFrame = this->skelAnime.curFrame; - s16 frameCount = Animation_GetLastFrame(D_80ADD990[this->unk_34C].animation); + s16 frameCount = Animation_GetLastFrame(sAnimationInfo[this->unk_34C].animation); if (this->unk_368 == 0x28) { this->unk_34C = 5; - SubS_ChangeAnimationByInfoS(&this->skelAnime, D_80ADD990, 5); + SubS_ChangeAnimationByInfoS(&this->skelAnime, sAnimationInfo, 5); } this->unk_368++; if ((currentFrame == frameCount) && (this->unk_34C == 5)) { this->unk_34C = 6; - SubS_ChangeAnimationByInfoS(&this->skelAnime, D_80ADD990, 6); + SubS_ChangeAnimationByInfoS(&this->skelAnime, sAnimationInfo, 6); } - if ((sp27 == 5) && Message_ShouldAdvance(globalCtx)) { - globalCtx->msgCtx.msgMode = 0x43; - globalCtx->msgCtx.unk12023 = 4; + if ((talkState == TEXT_STATE_5) && Message_ShouldAdvance(play)) { + play->msgCtx.msgMode = 0x43; + play->msgCtx.stateTimer = 4; this->actionFunc = func_80ADBBEC; - func_800B7298(globalCtx, NULL, 0x13); + func_800B7298(play, NULL, 0x13); } } -void func_80ADBBEC(EnSellnuts* this, GlobalContext* globalCtx) { - if (Actor_HasParent(&this->actor, globalCtx)) { +void func_80ADBBEC(EnSellnuts* this, PlayState* play) { + if (Actor_HasParent(&this->actor, play)) { this->actor.parent = NULL; gSaveContext.save.weekEventReg[17] |= 0x80; this->actionFunc = func_80ADBCE4; } else { - Actor_PickUp(&this->actor, globalCtx, GI_DEED_LAND, 300.0f, 300.0f); + Actor_PickUp(&this->actor, play, GI_DEED_LAND, 300.0f, 300.0f); } } -void func_80ADBC60(EnSellnuts* this, GlobalContext* globalCtx) { - if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { - Message_StartTextbox(globalCtx, this->unk_340, &this->actor); +void func_80ADBC60(EnSellnuts* this, PlayState* play) { + if (Actor_ProcessTalkRequest(&this->actor, &play->state)) { + Message_StartTextbox(play, this->unk_340, &this->actor); this->actionFunc = func_80ADB0D8; } else { - func_800B85E0(&this->actor, globalCtx, 400.0f, EXCH_ITEM_MINUS1); + func_800B85E0(&this->actor, play, 400.0f, PLAYER_AP_MINUS1); this->unk_340 = D_80ADD930[this->unk_33A]; } } -void func_80ADBCE4(EnSellnuts* this, GlobalContext* globalCtx) { - if ((Message_GetState(&globalCtx->msgCtx) == 6) && Message_ShouldAdvance(globalCtx)) { - func_800B85E0(&this->actor, globalCtx, 400.0f, EXCH_ITEM_MINUS1); +void func_80ADBCE4(EnSellnuts* this, PlayState* play) { + if ((Message_GetState(&play->msgCtx) == TEXT_STATE_DONE) && Message_ShouldAdvance(play)) { + func_800B85E0(&this->actor, play, 400.0f, PLAYER_AP_MINUS1); this->unk_340 = D_80ADD930[this->unk_33A]; this->actionFunc = func_80ADBC60; } } -void func_80ADBD64(EnSellnuts* this, GlobalContext* globalCtx) { - u8 sp27 = Message_GetState(&globalCtx->msgCtx); +void func_80ADBD64(EnSellnuts* this, PlayState* play) { + u8 talkState = Message_GetState(&play->msgCtx); s16 currentFrame = this->skelAnime.curFrame; - s16 frameCount = Animation_GetLastFrame(D_80ADD990[this->unk_34C].animation); + s16 frameCount = Animation_GetLastFrame(sAnimationInfo[this->unk_34C].animation); if ((currentFrame == frameCount) && (this->unk_34C == 7)) { this->unk_34C = 0; - SubS_ChangeAnimationByInfoS(&this->skelAnime, D_80ADD990, 0); + SubS_ChangeAnimationByInfoS(&this->skelAnime, sAnimationInfo, 0); } - if ((sp27 == 5) && Message_ShouldAdvance(globalCtx)) { - globalCtx->msgCtx.msgMode = 0x43; - globalCtx->msgCtx.unk12023 = 4; + if ((talkState == TEXT_STATE_5) && Message_ShouldAdvance(play)) { + play->msgCtx.msgMode = 0x43; + play->msgCtx.stateTimer = 4; this->unk_338 &= ~2; this->actor.flags &= ~ACTOR_FLAG_1; this->unk_34C = 8; - SubS_ChangeAnimationByInfoS(&this->skelAnime, D_80ADD990, 8); + SubS_ChangeAnimationByInfoS(&this->skelAnime, sAnimationInfo, 8); this->actionFunc = func_80ADBE80; } } -void func_80ADBE80(EnSellnuts* this, GlobalContext* globalCtx) { +void func_80ADBE80(EnSellnuts* this, PlayState* play) { s16 currentFrame = this->skelAnime.curFrame; - s16 frameCount = Animation_GetLastFrame(D_80ADD990[this->unk_34C].animation); + s16 frameCount = Animation_GetLastFrame(sAnimationInfo[this->unk_34C].animation); func_80ADAE64(this); if (this->unk_366 == 0) { @@ -546,7 +546,7 @@ void func_80ADBE80(EnSellnuts* this, GlobalContext* globalCtx) { if (currentFrame == frameCount) { this->unk_350 = 4; this->unk_34C = 19; - SubS_ChangeAnimationByInfoS(&this->skelAnime, D_80ADD990, 19); + SubS_ChangeAnimationByInfoS(&this->skelAnime, sAnimationInfo, 19); Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_NUTS_DOWN); this->unk_338 &= ~1; this->unk_338 |= 8; @@ -555,10 +555,10 @@ void func_80ADBE80(EnSellnuts* this, GlobalContext* globalCtx) { } } -void func_80ADBFA0(EnSellnuts* this, GlobalContext* globalCtx) { - if ((Message_GetState(&globalCtx->msgCtx) == 5) && Message_ShouldAdvance(globalCtx)) { - globalCtx->msgCtx.msgMode = 0x43; - globalCtx->msgCtx.unk12023 = 4; +void func_80ADBFA0(EnSellnuts* this, PlayState* play) { + if ((Message_GetState(&play->msgCtx) == TEXT_STATE_5) && Message_ShouldAdvance(play)) { + play->msgCtx.msgMode = 0x43; + play->msgCtx.stateTimer = 4; if (this->unk_34C == 0) { this->actionFunc = func_80ADB544; } else { @@ -567,7 +567,7 @@ void func_80ADBFA0(EnSellnuts* this, GlobalContext* globalCtx) { } } -void func_80ADC034(EnSellnuts* this, GlobalContext* globalCtx) { +void func_80ADC034(EnSellnuts* this, PlayState* play) { this->unk_344 += this->unk_364; if (this->unk_360 >= 1.0f) { this->unk_360 = 1.0f; @@ -580,16 +580,16 @@ 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; - SubS_ChangeAnimationByInfoS(&this->skelAnime, D_80ADD990, 10); + SubS_ChangeAnimationByInfoS(&this->skelAnime, sAnimationInfo, 10); this->unk_368 = 0; this->actionFunc = func_80ADC37C; } } -void func_80ADC118(EnSellnuts* this, GlobalContext* globalCtx) { +void func_80ADC118(EnSellnuts* this, PlayState* play) { Vec3f sp34; s16 currentFrame = this->skelAnime.curFrame; - s16 frameCount = Animation_GetLastFrame(D_80ADD990[this->unk_34C].animation); + s16 frameCount = Animation_GetLastFrame(sAnimationInfo[this->unk_34C].animation); if (currentFrame == frameCount) { Math_SmoothStepToS(&this->unk_364, 0x1C71, 3, 0x100, 0); @@ -602,26 +602,26 @@ void func_80ADC118(EnSellnuts* this, GlobalContext* globalCtx) { if (DECR(this->unk_34A) == 0) { if (!(this->unk_328 & 3)) { sp34 = this->actor.world.pos; - func_800B14D4(globalCtx, 20.0f, &sp34); + func_800B14D4(play, 20.0f, &sp34); } this->actor.velocity.y = 5.0f; } else if (!(this->unk_328 & 3)) { sp34.x = this->actor.world.pos.x; sp34.y = this->unk_32C; sp34.z = this->actor.world.pos.z; - func_800B14D4(globalCtx, 20.0f, &sp34); + func_800B14D4(play, 20.0f, &sp34); } if ((this->actor.home.pos.y + 22.5f) < this->actor.world.pos.y) { this->unk_34C = 9; this->unk_360 = 0.3f; - SubS_ChangeAnimationByInfoS(&this->skelAnime, D_80ADD990, 9); + SubS_ChangeAnimationByInfoS(&this->skelAnime, sAnimationInfo, 9); Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_AKINDONUTS_HIDE); this->actionFunc = func_80ADC034; } } -void func_80ADC2CC(EnSellnuts* this, GlobalContext* globalCtx) { +void func_80ADC2CC(EnSellnuts* this, PlayState* play) { f32 sp24 = this->unk_32C - this->actor.world.pos.y; Vec3f sp18; @@ -630,7 +630,7 @@ void func_80ADC2CC(EnSellnuts* this, GlobalContext* globalCtx) { sp18.x = this->actor.world.pos.x; sp18.y = this->unk_32C; sp18.z = this->actor.world.pos.z; - func_800B14D4(globalCtx, 20.0f, &sp18); + func_800B14D4(play, 20.0f, &sp18); } if (sp24 > 5.0f) { @@ -640,7 +640,7 @@ void func_80ADC2CC(EnSellnuts* this, GlobalContext* globalCtx) { } } -void func_80ADC37C(EnSellnuts* this, GlobalContext* globalCtx) { +void func_80ADC37C(EnSellnuts* this, PlayState* play) { Vec3s sp30; f32 sp2C; @@ -689,17 +689,17 @@ void func_80ADC37C(EnSellnuts* this, GlobalContext* globalCtx) { this->unk_368++; } -void func_80ADC580(EnSellnuts* this, GlobalContext* globalCtx) { +void func_80ADC580(EnSellnuts* this, PlayState* play) { Actor_MarkForDeath(&this->actor); } -void func_80ADC5A4(EnSellnuts* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); +void func_80ADC5A4(EnSellnuts* this, PlayState* play) { + Player* player = GET_PLAYER(play); - if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { + if (Actor_ProcessTalkRequest(&this->actor, &play->state)) { player->linearVelocity = 0.0f; this->actor.flags &= ~ACTOR_FLAG_10000; - Message_StartTextbox(globalCtx, this->unk_340, &this->actor); + Message_StartTextbox(play, this->unk_340, &this->actor); if (this->unk_340 == 0x625) { this->unk_338 |= 1; this->actor.draw = EnSellnuts_Draw; @@ -710,18 +710,18 @@ void func_80ADC5A4(EnSellnuts* this, GlobalContext* globalCtx) { player->stateFlags1 &= ~0x20; this->actionFunc = func_80ADC6D0; } - } else if (func_80ADB08C(globalCtx) < 80.0f) { + } else if (func_80ADB08C(play) < 80.0f) { this->actor.flags |= ACTOR_FLAG_10000; - func_800B8614(&this->actor, globalCtx, this->actor.xzDistToPlayer); + func_800B8614(&this->actor, play, this->actor.xzDistToPlayer); } } -void func_80ADC6D0(EnSellnuts* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); +void func_80ADC6D0(EnSellnuts* this, PlayState* play) { + Player* player = GET_PLAYER(play); - if ((Message_GetState(&globalCtx->msgCtx) == 5) && Message_ShouldAdvance(globalCtx)) { - globalCtx->msgCtx.msgMode = 0x43; - globalCtx->msgCtx.unk12023 = 4; + if ((Message_GetState(&play->msgCtx) == TEXT_STATE_5) && Message_ShouldAdvance(play)) { + play->msgCtx.msgMode = 0x43; + play->msgCtx.stateTimer = 4; if (player->transformation == PLAYER_FORM_DEKU) { if (gSaveContext.save.day == 3) { this->unk_33A = 2; @@ -736,8 +736,8 @@ void func_80ADC6D0(EnSellnuts* this, GlobalContext* globalCtx) { } } -void func_80ADC7B4(EnSellnuts* this, GlobalContext* globalCtx) { - s32 temp = Message_GetState(&globalCtx->msgCtx); +void func_80ADC7B4(EnSellnuts* this, PlayState* play) { + s32 talkState = Message_GetState(&play->msgCtx); if (this->unk_366 == 0) { if (ActorCutscene_GetCanPlayNext(this->cutscene)) { @@ -749,9 +749,9 @@ void func_80ADC7B4(EnSellnuts* this, GlobalContext* globalCtx) { } ActorCutscene_SetIntentToPlay(this->cutscene); } - } else if ((this->unk_366 == 1) && (temp == 5) && Message_ShouldAdvance(globalCtx)) { - globalCtx->msgCtx.msgMode = 0x43; - globalCtx->msgCtx.unk12023 = 4; + } else if ((this->unk_366 == 1) && (talkState == TEXT_STATE_5) && Message_ShouldAdvance(play)) { + play->msgCtx.msgMode = 0x43; + play->msgCtx.stateTimer = 4; this->unk_366 = 0; ActorCutscene_Stop(this->cutscene); this->cutscene = ActorCutscene_GetAdditionalCutscene(this->cutscene); @@ -761,7 +761,7 @@ void func_80ADC7B4(EnSellnuts* this, GlobalContext* globalCtx) { } } -void func_80ADC8C4(EnSellnuts* this, GlobalContext* globalCtx) { +void func_80ADC8C4(EnSellnuts* this, PlayState* play) { Vec3s sp30; if (this->unk_366 == 0) { @@ -793,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; - SubS_ChangeAnimationByInfoS(&this->skelAnime, D_80ADD990, this->unk_34C); + SubS_ChangeAnimationByInfoS(&this->skelAnime, sAnimationInfo, this->unk_34C); this->unk_338 &= ~1; this->unk_338 &= ~2; this->actionFunc = func_80ADCA64; @@ -806,9 +806,9 @@ void func_80ADC8C4(EnSellnuts* this, GlobalContext* globalCtx) { } } -void func_80ADCA64(EnSellnuts* this, GlobalContext* globalCtx) { +void func_80ADCA64(EnSellnuts* this, PlayState* play) { s16 currentFrame = this->skelAnime.curFrame; - s16 frameCount = Animation_GetLastFrame(D_80ADD990[this->unk_34C].animation); + s16 frameCount = Animation_GetLastFrame(sAnimationInfo[this->unk_34C].animation); if (this->unk_34C == 22) { Math_SmoothStepToS(&this->unk_364, 0, 3, 0x100, 0); @@ -821,7 +821,7 @@ void func_80ADCA64(EnSellnuts* this, GlobalContext* globalCtx) { this->unk_350 = 4; this->unk_34C = 19; this->actor.velocity.y = 0.0f; - SubS_ChangeAnimationByInfoS(&this->skelAnime, D_80ADD990, this->unk_34C); + SubS_ChangeAnimationByInfoS(&this->skelAnime, sAnimationInfo, this->unk_34C); Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_NUTS_DOWN); } return; @@ -832,7 +832,7 @@ void func_80ADCA64(EnSellnuts* this, GlobalContext* globalCtx) { if (this->unk_34C == 19) { this->unk_34C = 17; this->collider.dim.height = 0; - SubS_ChangeAnimationByInfoS(&this->skelAnime, D_80ADD990, 17); + SubS_ChangeAnimationByInfoS(&this->skelAnime, sAnimationInfo, 17); } else if (this->unk_34C == 17) { ActorCutscene_Stop(this->cutscene); gSaveContext.save.weekEventReg[73] |= 4; @@ -841,9 +841,9 @@ void func_80ADCA64(EnSellnuts* this, GlobalContext* globalCtx) { } } -void func_80ADCC04(EnSellnuts* this, GlobalContext* globalCtx) { +void func_80ADCC04(EnSellnuts* this, PlayState* play) { s16 currentFrame = this->skelAnime.curFrame; - s16 frameCount = Animation_GetLastFrame(D_80ADD990[this->unk_34C].animation); + s16 frameCount = Animation_GetLastFrame(sAnimationInfo[this->unk_34C].animation); if (this->unk_34C == 3) { if (currentFrame == frameCount) { @@ -852,24 +852,24 @@ void func_80ADCC04(EnSellnuts* this, GlobalContext* globalCtx) { this->unk_354 = 1.0f; this->unk_358 = 1.0f; this->unk_35C = 1.0f; - SubS_ChangeAnimationByInfoS(&this->skelAnime, D_80ADD990, this->unk_34C); + SubS_ChangeAnimationByInfoS(&this->skelAnime, sAnimationInfo, this->unk_34C); } } else if (this->unk_34C == 21) { func_80ADAFC0(this); if (currentFrame == 0) { - if (func_80ADB08C(globalCtx) < 9999.0f) { + if (func_80ADB08C(play) < 9999.0f) { this->actor.flags |= ACTOR_FLAG_10000; - func_800B8614(&this->actor, globalCtx, 9999.0f); + func_800B8614(&this->actor, play, 9999.0f); } this->unk_340 = 0x626; this->unk_34C = 0; - SubS_ChangeAnimationByInfoS(&this->skelAnime, D_80ADD990, this->unk_34C); + SubS_ChangeAnimationByInfoS(&this->skelAnime, sAnimationInfo, this->unk_34C); this->actionFunc = func_80ADC5A4; } } } -void func_80ADCD3C(EnSellnuts* this, GlobalContext* globalCtx) { +void func_80ADCD3C(EnSellnuts* this, PlayState* play) { Math_ApproachS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer, 2, 0xE38); if (gSaveContext.save.weekEventReg[73] & 4) { this->unk_338 |= 2; @@ -884,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); - SubS_ChangeAnimationByInfoS(&this->skelAnime, D_80ADD990, this->unk_34C); + SubS_ChangeAnimationByInfoS(&this->skelAnime, sAnimationInfo, this->unk_34C); this->actionFunc = func_80ADCC04; } else if (D_80ADD940 != 0) { this->collider.dim.height = 64; @@ -941,10 +941,10 @@ f32 func_80ADCFE8(Path* path, s32 arg1, Vec3f* pos, Vec3s* arg3) { return sp20.y - pos->y; } -void EnSellnuts_Init(Actor* thisx, GlobalContext* globalCtx) { +void EnSellnuts_Init(Actor* thisx, PlayState* play) { EnSellnuts* this = THIS; s32 pad; - Player* player = GET_PLAYER(globalCtx); + Player* player = GET_PLAYER(play); s32 pad2; if ((gSaveContext.save.weekEventReg[17] & 0x80) || (gSaveContext.save.weekEventReg[61] & 0x10)) { @@ -952,12 +952,12 @@ void EnSellnuts_Init(Actor* thisx, GlobalContext* globalCtx) { } Actor_ProcessInitChain(&this->actor, sInitChain); - SkelAnime_InitFlex(globalCtx, &this->skelAnime, &object_dnt_Skel_00AC70, &object_dnt_Anim_005488, this->jointTable, + SkelAnime_InitFlex(play, &this->skelAnime, &object_dnt_Skel_00AC70, &object_dnt_Anim_005488, this->jointTable, this->morphTable, 28); - Collider_InitCylinder(globalCtx, &this->collider); - Collider_SetCylinderType1(globalCtx, &this->collider, &this->actor, &sCylinderInit); + Collider_InitCylinder(play, &this->collider); + Collider_SetCylinderType1(play, &this->collider, &this->actor, &sCylinderInit); ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 35.0f); - this->path = SubS_GetPathByIndex(globalCtx, ENSELLNUTS_GET_FC00(&this->actor), 0x3F); + this->path = SubS_GetPathByIndex(play, ENSELLNUTS_GET_FC00(&this->actor), 0x3F); this->cutscene = this->actor.cutscene; Actor_SetScale(&this->actor, 0.01f); this->actor.colChkInfo.cylRadius = 0; @@ -989,7 +989,7 @@ void EnSellnuts_Init(Actor* thisx, GlobalContext* globalCtx) { this->actor.gravity = -1.0f; this->unk_34A = 50; this->unk_34C = 4; - SubS_ChangeAnimationByInfoS(&this->skelAnime, D_80ADD990, this->unk_34C); + SubS_ChangeAnimationByInfoS(&this->skelAnime, sAnimationInfo, this->unk_34C); this->actionFunc = func_80ADB254; return; } @@ -1007,7 +1007,7 @@ void EnSellnuts_Init(Actor* thisx, GlobalContext* globalCtx) { this->unk_358 = 1.0f; this->unk_354 = 1.0f; this->unk_360 = 1.0f; - SubS_ChangeAnimationByInfoS(&this->skelAnime, D_80ADD990, this->unk_34C); + SubS_ChangeAnimationByInfoS(&this->skelAnime, sAnimationInfo, this->unk_34C); this->actionFunc = func_80ADC5A4; } else { this->unk_338 |= 2; @@ -1018,20 +1018,20 @@ void EnSellnuts_Init(Actor* thisx, GlobalContext* globalCtx) { this->unk_34C = 4; this->unk_34E = 20; this->collider.dim.height = 64; - SubS_ChangeAnimationByInfoS(&this->skelAnime, D_80ADD990, this->unk_34C); + SubS_ChangeAnimationByInfoS(&this->skelAnime, sAnimationInfo, this->unk_34C); this->actionFunc = func_80ADCD3C; } } -void EnSellnuts_Destroy(Actor* thisx, GlobalContext* globalCtx) { +void EnSellnuts_Destroy(Actor* thisx, PlayState* play) { EnSellnuts* this = THIS; - Collider_DestroyCylinder(globalCtx, &this->collider); + Collider_DestroyCylinder(play, &this->collider); } -void EnSellnuts_Update(Actor* thisx, GlobalContext* globalCtx) { +void EnSellnuts_Update(Actor* thisx, PlayState* play) { EnSellnuts* this = THIS; - Player* player = GET_PLAYER(globalCtx); + Player* player = GET_PLAYER(play); this->unk_328++; if (player->transformation == PLAYER_FORM_DEKU) { @@ -1048,15 +1048,14 @@ void EnSellnuts_Update(Actor* thisx, GlobalContext* globalCtx) { Actor_SetScale(&this->actor, 0.01f); SkelAnime_Update(&this->skelAnime); Actor_MoveWithGravity(&this->actor); - this->actionFunc(this, globalCtx); + this->actionFunc(this, play); if (this->unk_338 & 8) { func_800B9010(&this->actor, NA_SE_EN_AKINDO_FLY - SFX_FLAG); } - func_80ADADD0(this, globalCtx); + func_80ADADD0(this, play); } -s32 EnSellnuts_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, - Actor* thisx) { +s32 EnSellnuts_OverrideLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, Actor* thisx) { EnSellnuts* this = THIS; if (((this->unk_34C == 4) && (this->unk_350 == 0)) || ((this->unk_34C == 8) && (this->unk_350 == 0)) || @@ -1101,7 +1100,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) { @@ -1115,10 +1114,10 @@ s32 EnSellnuts_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** d return false; } -void EnSellnuts_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx) { +void EnSellnuts_PostLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx) { } -void EnSellnuts_TransformLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Actor* thisx) { +void EnSellnuts_TransformLimbDraw(PlayState* play, s32 limbIndex, Actor* thisx) { EnSellnuts* this = THIS; if (((this->unk_350 == 1) || (this->unk_350 == 3)) && ((limbIndex == 23) || (limbIndex == 24))) { @@ -1131,15 +1130,15 @@ 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); } } -void EnSellnuts_Draw(Actor* thisx, GlobalContext* globalCtx) { +void EnSellnuts_Draw(Actor* thisx, PlayState* play) { EnSellnuts* this = THIS; - func_8012C28C(globalCtx->state.gfxCtx); - SkelAnime_DrawTransformFlexOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, + func_8012C28C(play->state.gfxCtx); + SkelAnime_DrawTransformFlexOpa(play, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, EnSellnuts_OverrideLimbDraw, EnSellnuts_PostLimbDraw, EnSellnuts_TransformLimbDraw, &this->actor); } diff --git a/src/overlays/actors/ovl_En_Sellnuts/z_en_sellnuts.h b/src/overlays/actors/ovl_En_Sellnuts/z_en_sellnuts.h index 24dfbbf9e..49023ce7f 100644 --- a/src/overlays/actors/ovl_En_Sellnuts/z_en_sellnuts.h +++ b/src/overlays/actors/ovl_En_Sellnuts/z_en_sellnuts.h @@ -5,45 +5,45 @@ struct EnSellnuts; -typedef void (*EnSellnutsActionFunc)(struct EnSellnuts*, GlobalContext*); +typedef void (*EnSellnutsActionFunc)(struct EnSellnuts*, PlayState*); #define ENSELLNUTS_GET_1(thisx) ((thisx)->params & 1) #define ENSELLNUTS_GET_FC00(thisx) (((thisx)->params & 0xFC00) >> 0xA) typedef struct EnSellnuts { - /* 0x0000 */ Actor actor; - /* 0x0144 */ SkelAnime skelAnime; - /* 0x0188 */ Vec3s jointTable[28]; - /* 0x0230 */ Vec3s morphTable[28]; - /* 0x02D8 */ EnSellnutsActionFunc actionFunc; - /* 0x02DC */ ColliderCylinder collider; - /* 0x0328 */ s16 unk_328; - /* 0x032C */ f32 unk_32C; - /* 0x0330 */ Path* path; - /* 0x0334 */ s32 unk_334; - /* 0x0338 */ u16 unk_338; - /* 0x033A */ u16 unk_33A; - /* 0x033C */ s16 cutscene; - /* 0x033E */ UNK_TYPE1 unk33E[0x2]; - /* 0x0340 */ u16 unk_340; - /* 0x0342 */ u16 unk_342; - /* 0x0344 */ s16 unk_344; - /* 0x0346 */ UNK_TYPE1 unk346[0x4]; - /* 0x034A */ s16 unk_34A; - /* 0x034C */ s16 unk_34C; - /* 0x034E */ s16 unk_34E; - /* 0x0350 */ s16 unk_350; - /* 0x0354 */ f32 unk_354; - /* 0x0358 */ f32 unk_358; - /* 0x035C */ f32 unk_35C; - /* 0x0360 */ f32 unk_360; - /* 0x0364 */ s16 unk_364; - /* 0x0366 */ s16 unk_366; - /* 0x0368 */ s16 unk_368; - /* 0x036A */ UNK_TYPE1 unk36A[0x2]; - /* 0x036C */ f32 unk_36C; - /* 0x0370 */ f32 unk_370; - /* 0x0374 */ f32 unk_374; + /* 0x000 */ Actor actor; + /* 0x144 */ SkelAnime skelAnime; + /* 0x188 */ Vec3s jointTable[28]; + /* 0x230 */ Vec3s morphTable[28]; + /* 0x2D8 */ EnSellnutsActionFunc actionFunc; + /* 0x2DC */ ColliderCylinder collider; + /* 0x328 */ s16 unk_328; + /* 0x32C */ f32 unk_32C; + /* 0x330 */ Path* path; + /* 0x334 */ s32 unk_334; + /* 0x338 */ u16 unk_338; + /* 0x33A */ u16 unk_33A; + /* 0x33C */ s16 cutscene; + /* 0x33E */ UNK_TYPE1 unk33E[0x2]; + /* 0x340 */ u16 unk_340; + /* 0x342 */ u16 unk_342; + /* 0x344 */ s16 unk_344; + /* 0x346 */ UNK_TYPE1 unk346[0x4]; + /* 0x34A */ s16 unk_34A; + /* 0x34C */ s16 unk_34C; + /* 0x34E */ s16 unk_34E; + /* 0x350 */ s16 unk_350; + /* 0x354 */ f32 unk_354; + /* 0x358 */ f32 unk_358; + /* 0x35C */ f32 unk_35C; + /* 0x360 */ f32 unk_360; + /* 0x364 */ s16 unk_364; + /* 0x366 */ s16 unk_366; + /* 0x368 */ s16 unk_368; + /* 0x36A */ UNK_TYPE1 unk36A[0x2]; + /* 0x36C */ f32 unk_36C; + /* 0x370 */ f32 unk_370; + /* 0x374 */ f32 unk_374; } EnSellnuts; // size = 0x378 extern const ActorInit En_Sellnuts_InitVars; diff --git a/src/overlays/actors/ovl_En_Shn/z_en_shn.c b/src/overlays/actors/ovl_En_Shn/z_en_shn.c index 92d4c7514..93b75e96b 100644 --- a/src/overlays/actors/ovl_En_Shn/z_en_shn.c +++ b/src/overlays/actors/ovl_En_Shn/z_en_shn.c @@ -6,18 +6,18 @@ */ #include "z_en_shn.h" +#include "z64snap.h" #define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_8) #define THIS ((EnShn*)thisx) -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); +void EnShn_Init(Actor* thisx, PlayState* play); +void EnShn_Destroy(Actor* thisx, PlayState* play); +void EnShn_Update(Actor* thisx, PlayState* play); +void EnShn_Draw(Actor* thisx, PlayState* play); + +void func_80AE6A64(EnShn* this, PlayState* play); // Could be something related to text/dialogue? static UNK_TYPE D_80AE6F00[] = { @@ -63,30 +63,27 @@ const ActorInit En_Shn_InitVars = { (ActorFunc)EnShn_Draw, }; -static AnimationInfoS sAnimations[] = { - { &object_shn_Anim_00D9D0, 1.0f, 0, -1, 0, 0 }, - { &object_shn_Anim_00D9D0, 1.0f, 0, -1, 0, -4 }, - { &object_shn_Anim_00E6C4, 1.0f, 0, -1, 0, 0 }, - { &object_shn_Anim_00E6C4, 1.0f, 0, -1, 0, -4 }, -}; - -static s32 D_80AE7258[] = { 0, 2, 3, 8, 10, 1 }; - void func_80AE6130(EnShn* this) { this->skelAnime.playSpeed = this->playSpeed; SkelAnime_Update(&this->skelAnime); } -s32 func_80AE615C(EnShn* this, s32 arg1) { +s32 func_80AE615C(EnShn* this, s32 animIndex) { + static AnimationInfoS sAnimationInfo[] = { + { &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 }, + }; s32 phi_v0 = 0; s32 phi_v1 = 0; - if (arg1 != this->unk_2E8) { + if (animIndex != this->unk_2E8) { phi_v0 = 1; } if (phi_v0 != 0) { - this->unk_2E8 = arg1; - phi_v1 = SubS_ChangeAnimationByInfoS(&this->skelAnime, sAnimations, arg1); + this->unk_2E8 = animIndex; + phi_v1 = SubS_ChangeAnimationByInfoS(&this->skelAnime, sAnimationInfo, animIndex); this->playSpeed = this->skelAnime.playSpeed; } return phi_v1; @@ -104,7 +101,7 @@ s32 EnShn_IsFacingPlayer(EnShn* this) { } if (phi_v1 == 0) { this->unk_2EC ^= 1; - this->unk_2C8 = Rand_S16Offset(0x1E, 0x1E); + this->unk_2C8 = Rand_S16Offset(30, 30); } if (this->unk_2EC != 0) { range = 120.0f; @@ -114,8 +111,8 @@ s32 EnShn_IsFacingPlayer(EnShn* this) { return Actor_IsFacingAndNearPlayer(&this->actor, range, 0x238C); } -Player* EnShn_GetPlayer(EnShn* this, GlobalContext* globalCtx) { - return GET_PLAYER(globalCtx); +Player* EnShn_GetPlayer(EnShn* this, PlayState* play) { + return GET_PLAYER(play); } void func_80AE626C(EnShn* this) { @@ -138,11 +135,11 @@ void func_80AE626C(EnShn* this) { this->unk_2BA = CLAMP(this->unk_2BA, -0x1554, 0x1554); } -void func_80AE63A8(EnShn* this, GlobalContext* globalCtx) { +void func_80AE63A8(EnShn* this, PlayState* play) { s16 phi_v1; s16 phi_v1_2; - this->shnPlayerRef = EnShn_GetPlayer(this, globalCtx); + this->shnPlayerRef = EnShn_GetPlayer(this, play); if ((this->unk_1D8 & 8) && (this->shnPlayerRef != NULL)) { if (this->unk_2CA == 0) { phi_v1 = 0; @@ -175,20 +172,19 @@ void func_80AE63A8(EnShn* this, GlobalContext* globalCtx) { } } -void func_80AE6488(EnShn* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); - s32 tempMsgState; +void func_80AE6488(EnShn* this, PlayState* play) { + Player* player = GET_PLAYER(play); + s32 talkState = Message_GetState(&play->msgCtx); f32 phi_f0_2; f32 phi_f0; - tempMsgState = Message_GetState(&globalCtx->msgCtx); this->unk_2D4 += (this->unk_2D0 != 0.0f) ? 40.0f : -40.0f; this->unk_2D4 = CLAMP(this->unk_2D4, 0.0f, 80.0f); - Matrix_InsertTranslation(this->unk_2D4, 0.0f, 0.0f, 1); + 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) { + ((play->msgCtx.currentTextId < 0xFF) || (play->msgCtx.currentTextId >= 0x201)) && (talkState == TEXT_STATE_3) && + (this->prevTalkState == TEXT_STATE_3)) { + if (play->state.frames % 2 == 0) { if (this->unk_2D0 != 0.0f) { this->unk_2D0 = 0.0f; } else { @@ -198,12 +194,12 @@ void func_80AE6488(EnShn* this, GlobalContext* globalCtx) { } else { this->unk_2D0 = 0.0f; } - this->msgState = tempMsgState; + this->prevTalkState = talkState; } -s32 func_80AE65F4(EnShn* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); - u16 temp = globalCtx->msgCtx.currentTextId; +s32 func_80AE65F4(EnShn* this, PlayState* play) { + Player* player = GET_PLAYER(play); + u16 temp = play->msgCtx.currentTextId; if (player->stateFlags1 & 0x40) { if (this->unk_1DA != temp) { @@ -229,47 +225,53 @@ s32 func_80AE65F4(EnShn* this, GlobalContext* globalCtx) { return false; } -s32 func_80AE6704(EnShn* thisx, GlobalContext* globalCtx) { +s32 func_80AE6704(Actor* thisx, PlayState* play) { + static s32 sPictographFlags[] = { + PICTOGRAPH_0, PICTOGRAPH_MONKEY, PICTOGRAPH_BIG_OCTO, + PICTOGRAPH_TINGLE, PICTOGRAPH_DEKU_KING, PICTOGRAPH_IN_SWAMP, + }; EnShn* this = THIS; s32 ret = 0; switch (this->unk_2C6) { case 0: - if (!CHECK_QUEST_ITEM(QUEST_UNK_19)) { + if (!CHECK_QUEST_ITEM(QUEST_PICTOGRAPH)) { this->unk_2C6 = 6; ret = 1; } else { this->unk_2C6++; } break; + case 1: case 2: case 3: case 4: case 5: - if (func_8013A4C4(D_80AE7258[this->unk_2C6])) { + if (Snap_CheckFlag(sPictographFlags[this->unk_2C6])) { this->unk_2C6 = 6; ret = 1; - REMOVE_QUEST_ITEM(QUEST_UNK_19); + REMOVE_QUEST_ITEM(QUEST_PICTOGRAPH); } else { this->unk_2C6++; } break; + case 6: gSaveContext.save.weekEventReg[90] &= (u8)~0x40; - func_800B7298(globalCtx, &this->actor, 7); - globalCtx->nextEntranceIndex = 0x8460; + func_800B7298(play, &this->actor, 7); + play->nextEntrance = ENTRANCE(SOUTHERN_SWAMP_POISONED, 6); gSaveContext.nextCutsceneIndex = 0; - globalCtx->sceneLoadFlag = 0x14; - globalCtx->unk_1887F = 3; - gSaveContext.nextTransition = 7; + play->transitionTrigger = TRANS_TRIGGER_START; + play->transitionType = TRANS_TYPE_03; + gSaveContext.nextTransitionType = TRANS_TYPE_07; this->unk_2C6++; break; } return ret; } -UNK_TYPE* func_80AE6880(EnShn* this, GlobalContext* globalCtx) { +UNK_TYPE* func_80AE6880(EnShn* this, PlayState* play) { if (this->unk_2BE != 0) { return D_80AE70B0; } @@ -284,34 +286,34 @@ UNK_TYPE* func_80AE6880(EnShn* this, GlobalContext* globalCtx) { return D_80AE6F00; } -s32 func_80AE68F0(EnShn* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); - s32 ret = 0; +s32 func_80AE68F0(EnShn* this, PlayState* play) { + Player* player = GET_PLAYER(play); + s32 ret = false; if (this->unk_1D8 & 7) { - if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { + if (Actor_ProcessTalkRequest(&this->actor, &play->state)) { this->unk_1D8 &= ~0x180; - if (player->exchangeItemId == EXCH_ITEM_13) { + if (player->exchangeItemId == PLAYER_AP_PICTO_BOX) { this->unk_1D8 |= 0x80; this->unk_2E4 = player->exchangeItemId; - } else if (player->exchangeItemId != EXCH_ITEM_NONE) { + } else if (player->exchangeItemId != PLAYER_AP_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_1DC = func_80AE6880(this, play); this->unk_2C6 = 0; if (gSaveContext.save.weekEventReg[23] & 8) { this->unk_1D8 |= 8; } this->actionFunc = func_80AE6A64; - ret = 1; + ret = true; } } return ret; } -void func_80AE69E8(EnShn* this, GlobalContext* globalCtx) { +void func_80AE69E8(EnShn* this, PlayState* play) { 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; @@ -320,12 +322,12 @@ void func_80AE69E8(EnShn* this, GlobalContext* globalCtx) { } } -void func_80AE6A64(EnShn* this, GlobalContext* globalCtx) { +void func_80AE6A64(EnShn* this, PlayState* play) { s16 yawBetweenActors; Vec3f playerPos; Vec3f shnPos; - if (func_8010BF58(&this->actor, globalCtx, this->unk_1DC, this->unk_2D8, &this->unk_1E0)) { + if (func_8010BF58(&this->actor, play, this->unk_1DC, this->unk_2D8, &this->unk_1E0)) { SubS_UpdateFlags(&this->unk_1D8, 3, 7); this->unk_1D8 &= ~8; this->unk_1D8 |= 0x20; @@ -341,12 +343,12 @@ void func_80AE6A64(EnShn* this, GlobalContext* globalCtx) { } } -void EnShn_Init(Actor* thisx, GlobalContext* globalCtx) { +void EnShn_Init(Actor* thisx, PlayState* play) { EnShn* this = THIS; ActorShape_Init(&this->actor.shape, 0.0f, NULL, 0.0f); - SkelAnime_InitFlex(globalCtx, &this->skelAnime, &gObjectShnSkel, NULL, this->jointTable, this->morphTable, - OBJECT_SHN_LIMB_MAX); + SkelAnime_InitFlex(play, &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); @@ -358,7 +360,7 @@ void EnShn_Init(Actor* thisx, GlobalContext* globalCtx) { this->unk_2E0 = 0; this->unk_2D8 = 0; this->unk_1D8 = 0; - if (gSaveContext.save.entranceIndex != 0xA820) { + if (gSaveContext.save.entrance != ENTRANCE(TOURIST_INFORMATION, 2)) { SubS_UpdateFlags(&this->unk_1D8, 3, 7); this->unk_2BE = 0; } else { @@ -368,74 +370,74 @@ void EnShn_Init(Actor* thisx, GlobalContext* globalCtx) { this->actionFunc = func_80AE69E8; } -void EnShn_Destroy(Actor* thisx, GlobalContext* globalCtx) { +void EnShn_Destroy(Actor* thisx, PlayState* play) { } -void EnShn_Update(Actor* thisx, GlobalContext* globalCtx) { +void EnShn_Update(Actor* thisx, PlayState* play) { EnShn* this = THIS; - func_80AE68F0(this, globalCtx); - this->actionFunc(this, globalCtx); - func_80AE65F4(this, globalCtx); + func_80AE68F0(this, play); + this->actionFunc(this, play); + func_80AE65F4(this, play); func_80AE6130(this); - func_80AE63A8(this, globalCtx); + func_80AE63A8(this, play); this->unk_2E0 = 0; - func_8013C964(&this->actor, globalCtx, 120.0f, 40.0f, 0, this->unk_1D8 & 7); + func_8013C964(&this->actor, play, 120.0f, 40.0f, PLAYER_AP_NONE, this->unk_1D8 & 7); } -s32 EnShn_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, Actor* thisx) { +s32 EnShn_OverrideLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, Actor* thisx) { EnShn* this = THIS; - if (limbIndex == OBJECT_SHN_LIMB_HEAD) { - func_80AE6488(this, globalCtx); - *dList = gObjectShnSwampGuideHead; + if (limbIndex == BURLY_GUY_LIMB_HEAD) { + func_80AE6488(this, play); + *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 == OBJECT_SHN_LIMB_HEAD) { - Matrix_MultiplyVector3fByState(&D_80AE7270, &thisx->focus.pos); +void EnShn_PostLimbDraw(PlayState* play, 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) { +void EnShn_TransformLimbDraw(PlayState* play, s32 limbIndex, Actor* thisx) { EnShn* this = THIS; - s32 phi_v0; - s32 phi_v1; + s32 stepRot; + s32 overrideRot; if (!(this->unk_1D8 & 0x20)) { if (this->unk_1D8 & 0x10) { - 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 == OBJECT_SHN_LIMB_HEAD) { - func_8013AD9C((this->unk_2BA + 0x4000), (this->unk_2BC + this->actor.shape.rot.y + 0x4000), &this->unk_1E8, - &this->unk_1F4, phi_v0, phi_v1); - Matrix_StatePop(); - Matrix_InsertTranslation(this->unk_1E8.x, this->unk_1E8.y, this->unk_1E8.z, 0); - Matrix_Scale(this->actor.scale.x, this->actor.scale.y, this->actor.scale.z, 1); - Matrix_RotateY(this->unk_1F4.y, 1); - Matrix_InsertXRotation_s(this->unk_1F4.x, 1); - Matrix_InsertZRotation_s(this->unk_1F4.z, 1); - Matrix_StatePush(); + 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) { +void EnShn_Draw(Actor* thisx, PlayState* play) { EnShn* this = THIS; - func_8012C5B0(globalCtx->state.gfxCtx); - SkelAnime_DrawTransformFlexOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, + func_8012C5B0(play->state.gfxCtx); + SkelAnime_DrawTransformFlexOpa(play, 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 bb54a8815..e373abde2 100644 --- a/src/overlays/actors/ovl_En_Shn/z_en_shn.h +++ b/src/overlays/actors/ovl_En_Shn/z_en_shn.h @@ -6,7 +6,8 @@ struct EnShn; -typedef void (*EnShnActionFunc)(struct EnShn*, GlobalContext*); +typedef void (*EnShnActionFunc)(struct EnShn*, PlayState*); +typedef s32 (*MsgEventFunc)(Actor*, PlayState*); typedef struct EnShn { /* 0x000 */ Actor actor; @@ -20,8 +21,8 @@ typedef struct EnShn { /* 0x1E4 */ Player* shnPlayerRef; /* 0x1E8 */ Vec3f unk_1E8; /* 0x1F4 */ Vec3s unk_1F4; - /* 0x1FA */ Vec3s jointTable[OBJECT_SHN_LIMB_MAX]; - /* 0x25A */ Vec3s morphTable[OBJECT_SHN_LIMB_MAX]; + /* 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; @@ -34,8 +35,8 @@ typedef struct EnShn { /* 0x2CC */ f32 playSpeed; /* 0x2D0 */ f32 unk_2D0; /* 0x2D4 */ f32 unk_2D4; - /* 0x2D8 */ s32 unk_2D8; - /* 0x2DC */ s32 msgState; + /* 0x2D8 */ MsgEventFunc unk_2D8; + /* 0x2DC */ s32 prevTalkState; /* 0x2E0 */ s32 unk_2E0; /* 0x2E4 */ s32 unk_2E4; /* 0x2E8 */ s32 unk_2E8; diff --git a/src/overlays/actors/ovl_En_Si/z_en_si.c b/src/overlays/actors/ovl_En_Si/z_en_si.c index 8933d5305..eccfc5f1e 100644 --- a/src/overlays/actors/ovl_En_Si/z_en_si.c +++ b/src/overlays/actors/ovl_En_Si/z_en_si.c @@ -10,13 +10,13 @@ #define THIS ((EnSi*)thisx) -void EnSi_Init(Actor* thisx, GlobalContext* globalCtx); -void EnSi_Destroy(Actor* thisx, GlobalContext* globalCtx); -void EnSi_Update(Actor* thisx, GlobalContext* globalCtx); -void EnSi_Draw(Actor* thisx, GlobalContext* globalCtx); +void EnSi_Init(Actor* thisx, PlayState* play); +void EnSi_Destroy(Actor* thisx, PlayState* play); +void EnSi_Update(Actor* thisx, PlayState* play); +void EnSi_Draw(Actor* thisx, PlayState* play); -void func_8098CB70(EnSi* this, GlobalContext* globalCtx); -void func_8098CBDC(EnSi* this, GlobalContext* globalCtx); +void func_8098CB70(EnSi* this, PlayState* play); +void func_8098CBDC(EnSi* this, PlayState* play); #if 0 const ActorInit En_Si_InitVars = { diff --git a/src/overlays/actors/ovl_En_Si/z_en_si.h b/src/overlays/actors/ovl_En_Si/z_en_si.h index 26e33e728..032e1f116 100644 --- a/src/overlays/actors/ovl_En_Si/z_en_si.h +++ b/src/overlays/actors/ovl_En_Si/z_en_si.h @@ -5,12 +5,12 @@ struct EnSi; -typedef void (*EnSiActionFunc)(struct EnSi*, GlobalContext*); +typedef void (*EnSiActionFunc)(struct EnSi*, PlayState*); typedef struct EnSi { - /* 0x0000 */ Actor actor; - /* 0x0144 */ EnSiActionFunc actionFunc; - /* 0x0148 */ char unk_148[0x58]; + /* 0x000 */ Actor actor; + /* 0x144 */ EnSiActionFunc actionFunc; + /* 0x148 */ char unk_148[0x58]; } EnSi; // size = 0x1A0 extern const ActorInit En_Si_InitVars; diff --git a/src/overlays/actors/ovl_En_Skb/z_en_skb.c b/src/overlays/actors/ovl_En_Skb/z_en_skb.c index f7fca7448..e3c5b1730 100644 --- a/src/overlays/actors/ovl_En_Skb/z_en_skb.c +++ b/src/overlays/actors/ovl_En_Skb/z_en_skb.c @@ -13,43 +13,43 @@ #define THIS ((EnSkb*)thisx) -void EnSkb_Init(Actor* thisx, GlobalContext* globalCtx); -void EnSkb_Destroy(Actor* thisx, GlobalContext* globalCtx); -void EnSkb_Update(Actor* thisx, GlobalContext* globalCtx); -void EnSkb_Draw(Actor* thisx, GlobalContext* globalCtx); +void EnSkb_Init(Actor* thisx, PlayState* play); +void EnSkb_Destroy(Actor* thisx, PlayState* play); +void EnSkb_Update(Actor* thisx, PlayState* play); +void EnSkb_Draw(Actor* thisx, PlayState* play); void func_80994E2C(EnSkb* this); -void func_80994E94(EnSkb* this, GlobalContext* globalCtx); -void func_80995068(EnSkb* this, GlobalContext* globalCtx); -void func_80995190(EnSkb* this, GlobalContext* globalCtx); -void func_80995244(EnSkb* this, GlobalContext* globalCtx); +void func_80994E94(EnSkb* this, PlayState* play); +void func_80995068(EnSkb* this, PlayState* play); +void func_80995190(EnSkb* this, PlayState* play); +void func_80995244(EnSkb* this, PlayState* play); void func_809952D8(EnSkb* this); -void func_8099533C(EnSkb* this, GlobalContext* globalCtx); +void func_8099533C(EnSkb* this, PlayState* play); void func_809953E8(EnSkb* this); -void func_8099544C(EnSkb* this, GlobalContext* globalCtx); +void func_8099544C(EnSkb* this, PlayState* play); void func_809954F8(EnSkb* this); -void func_8099556C(EnSkb* this, GlobalContext* globalCtx); +void func_8099556C(EnSkb* this, PlayState* play); void func_8099571C(EnSkb* this); -void func_80995818(EnSkb* this, GlobalContext* globalCtx); -void func_8099599C(EnSkb* this, GlobalContext* globalCtx); +void func_80995818(EnSkb* this, PlayState* play); +void func_8099599C(EnSkb* this, PlayState* play); void func_80995A30(EnSkb* this); -void func_80995A8C(EnSkb* this, GlobalContext* globalCtx); +void func_80995A8C(EnSkb* this, PlayState* play); void func_80995C24(EnSkb* this); -void func_80995C84(EnSkb* this, GlobalContext* globalCtx); +void func_80995C84(EnSkb* this, PlayState* play); void func_80995D3C(EnSkb* this); -void func_80995DC4(EnSkb* this, GlobalContext* globalCtx); -void func_80995E64(EnSkb* this, GlobalContext* globalCtx); -void func_809960AC(EnSkb* this, GlobalContext* globalCtx); -void func_809961E4(EnSkb* this, GlobalContext* globalCtx); -void func_80996284(EnSkb* this, GlobalContext* globalCtx); -void func_8099630C(EnSkb* this, GlobalContext* globalCtx); -void func_809963D8(EnSkb* this, GlobalContext* globalCtx); +void func_80995DC4(EnSkb* this, PlayState* play); +void func_80995E64(EnSkb* this, PlayState* play); +void func_809960AC(EnSkb* this, PlayState* play); +void func_809961E4(EnSkb* this, PlayState* play); +void func_80996284(EnSkb* this, PlayState* play); +void func_8099630C(EnSkb* this, PlayState* play); +void func_809963D8(EnSkb* this, PlayState* play); void func_80996474(EnSkb* this); -void func_809964A0(EnSkb* this, GlobalContext* globalCtx); -s32 func_80996594(EnSkb* this, GlobalContext* globalCtx); -void func_80996BEC(EnSkb* this, GlobalContext* globalCtx); +void func_809964A0(EnSkb* this, PlayState* play); +s32 func_80996594(EnSkb* this, PlayState* play); +void func_80996BEC(EnSkb* this, PlayState* play); -static AnimationInfo sAnimations[] = { +static AnimationInfo sAnimationInfo[] = { { &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 }, @@ -106,7 +106,7 @@ static ColliderJntSphInit sJntSphInit = { OC2_TYPE_1, COLSHAPE_JNTSPH, }, - 2, + ARRAY_COUNT(sJntSphElementsInit), sJntSphElementsInit, }; @@ -157,7 +157,7 @@ const ActorInit En_Skb_InitVars = { (ActorFunc)EnSkb_Draw, }; -void func_809947B0(GlobalContext* globalCtx, EnSkb* this, Vec3f* inPos) { +void func_809947B0(PlayState* play, EnSkb* this, Vec3f* inPos) { Vec3f pos; Vec3f velocity = { 0.0f, 8.0f, 0.0f }; Vec3f accel = { 0.0f, -1.5f, 0.0f }; @@ -170,34 +170,34 @@ void func_809947B0(GlobalContext* globalCtx, EnSkb* this, Vec3f* inPos) { accel.x = randPlusMinusPoint5Scaled(1.0f); accel.z = randPlusMinusPoint5Scaled(1.0f); velocity.y += (Rand_ZeroOne() - 0.5f) * 4.0f; - EffectSsHahen_Spawn(globalCtx, &pos, &velocity, &accel, 0, ((Rand_ZeroOne() * 5.0f) + 12.0f) * 0.8f, + EffectSsHahen_Spawn(play, &pos, &velocity, &accel, 0, ((Rand_ZeroOne() * 5.0f) + 12.0f) * 0.8f, HAHEN_OBJECT_DEFAULT, 10, NULL); - func_800BBFB0(globalCtx, &pos, 10.0f, 1, 150, 0, 1); + func_800BBFB0(play, &pos, 10.0f, 1, 150, 0, 1); } -void func_8099495C(EnSkb* this, GlobalContext* globalCtx) { - SkelAnime_Init(globalCtx, &this->skelAnime, &object_skb_Skel_005EF8, &object_skb_Anim_003584, this->jointTable, +void func_8099495C(EnSkb* this, PlayState* play) { + SkelAnime_Init(play, &this->skelAnime, &object_skb_Skel_005EF8, &object_skb_Anim_003584, this->jointTable, this->morphTable, 20); this->unk_3DC = 0; func_80994E2C(this); } -void func_809949C4(EnSkb* this, GlobalContext* globalCtx) { - SkelAnime_Init(globalCtx, &this->skelAnime, &object_skb_Skel_005EF8, &object_skb_Anim_00697C, this->jointTable, +void func_809949C4(EnSkb* this, PlayState* play) { + SkelAnime_Init(play, &this->skelAnime, &object_skb_Skel_005EF8, &object_skb_Anim_00697C, this->jointTable, this->morphTable, 20); this->unk_3DC = 1; func_809952D8(this); } -void func_80994A30(EnSkb* this, GlobalContext* globalCtx) { - SkelAnime_Init(globalCtx, &this->skelAnime, &object_skb_Skel_005EF8, &object_skb_Anim_006D90, this->jointTable, +void func_80994A30(EnSkb* this, PlayState* play) { + SkelAnime_Init(play, &this->skelAnime, &object_skb_Skel_005EF8, &object_skb_Anim_006D90, this->jointTable, this->morphTable, 20); this->unk_3DC = 1; func_809953E8(this); } -void func_80994A9C(EnSkb* this, GlobalContext* globalCtx) { - SkelAnime_Init(globalCtx, &this->skelAnime, &object_skb_Skel_005EF8, &object_skb_Anim_001D1C, this->jointTable, +void func_80994A9C(EnSkb* this, PlayState* play) { + SkelAnime_Init(play, &this->skelAnime, &object_skb_Skel_005EF8, &object_skb_Anim_001D1C, this->jointTable, this->morphTable, 20); this->unk_3DC = 1; func_809954F8(this); @@ -208,7 +208,7 @@ static InitChainEntry sInitChain[] = { ICHAIN_F32_DIV1000(gravity, -2000, ICHAIN_STOP), }; -void EnSkb_Init(Actor* thisx, GlobalContext* globalCtx) { +void EnSkb_Init(Actor* thisx, PlayState* play) { EnSkb* this = THIS; s32 pad; @@ -222,41 +222,40 @@ void EnSkb_Init(Actor* thisx, GlobalContext* globalCtx) { this->actor.colChkInfo.mass = 70; this->actor.colChkInfo.health = 2; this->actor.shape.yOffset = -8000.0f; - Collider_InitJntSph(globalCtx, &this->collider); - Collider_SetJntSph(globalCtx, &this->collider, &this->actor, &sJntSphInit, this->colliderElements); + Collider_InitJntSph(play, &this->collider); + Collider_SetJntSph(play, &this->collider, &this->actor, &sJntSphInit, this->colliderElements); this->collider.elements[0].dim.modelSphere.radius = this->collider.elements[0].dim.worldSphere.radius = 10; this->collider.elements[1].dim.modelSphere.radius = this->collider.elements[1].dim.worldSphere.radius = 20; this->actor.home.pos = this->actor.world.pos; 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.currentCsIndex == 0)) { + if ((play->sceneNum == SCENE_BOTI) && (gSaveContext.sceneSetupIndex == 1) && (play->csCtx.currentCsIndex == 0)) { this->actor.flags |= ACTOR_FLAG_100000; } switch (this->unk_3D6) { case 2: - func_809949C4(this, globalCtx); + func_809949C4(this, play); break; case 3: - func_80994A30(this, globalCtx); + func_80994A30(this, play); break; case 4: - func_80994A9C(this, globalCtx); + func_80994A9C(this, play); break; default: this->actor.flags &= ~ACTOR_FLAG_100000; this->actor.hintId = 0x55; - func_8099495C(this, globalCtx); + func_8099495C(this, play); break; } } -void EnSkb_Destroy(Actor* thisx, GlobalContext* globalCtx) { +void EnSkb_Destroy(Actor* thisx, PlayState* play) { EnSkb* this = THIS; if ((this->actor.parent != NULL) && (this->actor.parent->update != NULL) && @@ -275,12 +274,12 @@ void EnSkb_Destroy(Actor* thisx, GlobalContext* globalCtx) { } } - Collider_DestroyJntSph(globalCtx, &this->collider); + Collider_DestroyJntSph(play, &this->collider); } -void func_80994DA8(EnSkb* this, GlobalContext* globalCtx) { +void func_80994DA8(EnSkb* this, PlayState* play) { if (Actor_IsFacingPlayer(&this->actor, 0x11C7) && (this->actor.xzDistToPlayer < 60.0f) && - (Player_GetMask(globalCtx) != PLAYER_MASK_CAPTAIN)) { + (Player_GetMask(play) != PLAYER_MASK_CAPTAIN)) { func_80995C24(this); } else { func_80995A30(this); @@ -288,7 +287,7 @@ void func_80994DA8(EnSkb* this, GlobalContext* globalCtx) { } void func_80994E2C(EnSkb* this) { - Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 1); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, 1); this->actor.flags &= ~ACTOR_FLAG_1; Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_STALKID_APPEAR); this->unk_3D0 = 0; @@ -296,7 +295,7 @@ void func_80994E2C(EnSkb* this) { this->actionFunc = func_80994E94; } -void func_80994E94(EnSkb* this, GlobalContext* globalCtx) { +void func_80994E94(EnSkb* this, PlayState* play) { if (this->skelAnime.curFrame < 4.0f) { this->actor.world.rot.y = this->actor.yawTowardsPlayer; this->actor.shape.rot.y = this->actor.yawTowardsPlayer; @@ -306,8 +305,8 @@ void func_80994E94(EnSkb* this, GlobalContext* globalCtx) { Math_ApproachZeroF(&this->actor.shape.yOffset, 1.0f, 800.0f); Math_ApproachF(&this->actor.shape.shadowScale, 25.0f, 1.0f, 2.5f); - if ((globalCtx->gameplayFrames % 2) == 0) { - func_809947B0(globalCtx, this, &this->actor.world.pos); + if ((play->gameplayFrames % 2) == 0) { + func_809947B0(play, this, &this->actor.world.pos); } if (Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame) && (this->actor.shape.yOffset == 0.0f)) { @@ -316,19 +315,19 @@ void func_80994E94(EnSkb* this, GlobalContext* globalCtx) { this->unk_3D0++; } -void func_80994F7C(EnSkb* this, GlobalContext* globalCtx) { - if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { +void func_80994F7C(EnSkb* this, PlayState* play) { + if (Actor_ProcessTalkRequest(&this->actor, &play->state)) { this->unk_3E2 = 1; if (this->unk_3E0 == 1) { - Message_StartTextbox(globalCtx, 0x13F8, &this->actor); + Message_StartTextbox(play, 0x13F8, &this->actor); } else { - Message_StartTextbox(globalCtx, 0x13F6, &this->actor); + Message_StartTextbox(play, 0x13F6, &this->actor); this->unk_3E0 = 1; } this->actionFunc = func_80995190; this->actor.speedXZ = 0.0f; } else if (Actor_IsFacingPlayer(&this->actor, 0x2AAA) && !(this->collider.base.acFlags & AC_HIT)) { - func_800B8614(&this->actor, globalCtx, 100.0f); + func_800B8614(&this->actor, play, 100.0f); } } @@ -337,58 +336,58 @@ void func_8099504C(EnSkb* this) { this->actor.speedXZ = 0.0f; } -void func_80995068(EnSkb* this, GlobalContext* globalCtx) { - if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { +void func_80995068(EnSkb* this, PlayState* play) { + if (Actor_ProcessTalkRequest(&this->actor, &play->state)) { this->unk_3E2 = 1; if (this->unk_3E0 == 1) { - Message_StartTextbox(globalCtx, 0x13F8, &this->actor); + Message_StartTextbox(play, 0x13F8, &this->actor); if (this->unk_3DE == 2) { - Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 11); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, 11); } } else { - Message_StartTextbox(globalCtx, 0x13F6, &this->actor); + Message_StartTextbox(play, 0x13F6, &this->actor); this->unk_3E0 = 1; } this->actionFunc = func_80995190; this->actor.speedXZ = 0.0f; - } else if (Player_GetMask(globalCtx) != PLAYER_MASK_CAPTAIN) { + } else if (Player_GetMask(play) != PLAYER_MASK_CAPTAIN) { this->actor.flags |= (ACTOR_FLAG_1 | ACTOR_FLAG_4); this->actor.flags &= ~(ACTOR_FLAG_1 | ACTOR_FLAG_8); this->actor.hintId = 0x55; this->actor.colChkInfo.mass = MASS_HEAVY; func_80995A30(this); } else if (!(this->collider.base.acFlags & AC_HIT)) { - func_800B8614(&this->actor, globalCtx, 100.0f); + func_800B8614(&this->actor, play, 100.0f); } } -void func_80995190(EnSkb* this, GlobalContext* globalCtx) { - switch (Message_GetState(&globalCtx->msgCtx)) { - case 0: - case 1: - case 2: - case 3: - case 4: +void func_80995190(EnSkb* this, PlayState* play) { + switch (Message_GetState(&play->msgCtx)) { + case TEXT_STATE_NONE: + case TEXT_STATE_1: + case TEXT_STATE_CLOSING: + case TEXT_STATE_3: + case TEXT_STATE_CHOICE: break; - case 5: - if (Message_ShouldAdvance(globalCtx)) { - Message_StartTextbox(globalCtx, 0x13F7, &this->actor); + case TEXT_STATE_5: + if (Message_ShouldAdvance(play)) { + Message_StartTextbox(play, 0x13F7, &this->actor); if (this->unk_3DE == 2) { - Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 11); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, 11); } } break; - case 6: - if (Message_ShouldAdvance(globalCtx)) { + case TEXT_STATE_DONE: + if (Message_ShouldAdvance(play)) { this->actionFunc = func_80995244; } break; } } -void func_80995244(EnSkb* this, GlobalContext* globalCtx) { +void func_80995244(EnSkb* this, PlayState* play) { this->actor.flags &= ~(ACTOR_FLAG_1 | ACTOR_FLAG_8); this->actor.flags |= (ACTOR_FLAG_1 | ACTOR_FLAG_4); this->unk_3E2 = 0; @@ -413,7 +412,7 @@ void func_80995244(EnSkb* this, GlobalContext* globalCtx) { } void func_809952D8(EnSkb* this) { - Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 5); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, 5); this->actor.colChkInfo.mass = MASS_IMMOVABLE; this->unk_3DE = 9; this->actionFunc = func_8099533C; @@ -422,11 +421,11 @@ void func_809952D8(EnSkb* this) { this->actor.shape.yOffset = 0.0f; } -void func_8099533C(EnSkb* this, GlobalContext* globalCtx) { - if (Player_GetMask(globalCtx) == PLAYER_MASK_CAPTAIN) { +void func_8099533C(EnSkb* this, PlayState* play) { + if (Player_GetMask(play) == PLAYER_MASK_CAPTAIN) { this->actor.flags &= ~(ACTOR_FLAG_1 | ACTOR_FLAG_4); this->actor.flags |= (ACTOR_FLAG_1 | ACTOR_FLAG_8); - func_80994F7C(this, globalCtx); + func_80994F7C(this, play); } else if (Actor_IsFacingPlayer(&this->actor, 0x2AAA) && (this->actor.xzDistToPlayer < 200.0f)) { this->actor.hintId = 0x55; this->actor.colChkInfo.mass = MASS_HEAVY; @@ -435,7 +434,7 @@ void func_8099533C(EnSkb* this, GlobalContext* globalCtx) { } void func_809953E8(EnSkb* this) { - Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 6); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, 6); this->actor.colChkInfo.mass = MASS_IMMOVABLE; this->unk_3DE = 10; this->actionFunc = func_8099544C; @@ -444,11 +443,11 @@ void func_809953E8(EnSkb* this) { this->actor.shape.yOffset = 0.0f; } -void func_8099544C(EnSkb* this, GlobalContext* globalCtx) { - if (Player_GetMask(globalCtx) == PLAYER_MASK_CAPTAIN) { +void func_8099544C(EnSkb* this, PlayState* play) { + if (Player_GetMask(play) == PLAYER_MASK_CAPTAIN) { this->actor.flags &= ~(ACTOR_FLAG_1 | ACTOR_FLAG_4); this->actor.flags |= (ACTOR_FLAG_1 | ACTOR_FLAG_8); - func_80994F7C(this, globalCtx); + func_80994F7C(this, play); } else if (Actor_IsFacingPlayer(&this->actor, 0x2AAA) && (this->actor.xzDistToPlayer < 200.0f)) { this->actor.hintId = 0x55; this->actor.colChkInfo.mass = MASS_HEAVY; @@ -457,7 +456,7 @@ void func_8099544C(EnSkb* this, GlobalContext* globalCtx) { } void func_809954F8(EnSkb* this) { - Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 7); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, 7); this->actor.colChkInfo.mass = MASS_IMMOVABLE; this->unk_3DE = 11; this->actionFunc = func_8099556C; @@ -468,7 +467,7 @@ void func_809954F8(EnSkb* this) { this->actor.targetArrowOffset = 4000.0f; } -void func_8099556C(EnSkb* this, GlobalContext* globalCtx) { +void func_8099556C(EnSkb* this, PlayState* play) { s16 sp26; if (this->skelAnime.curFrame < 15.0f) { @@ -478,14 +477,14 @@ 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) { + if (Player_GetMask(play) == PLAYER_MASK_CAPTAIN) { this->actor.flags &= ~(ACTOR_FLAG_1 | ACTOR_FLAG_4); this->actor.flags |= (ACTOR_FLAG_1 | ACTOR_FLAG_8); - func_80994F7C(this, globalCtx); + func_80994F7C(this, play); } else if (Actor_IsFacingPlayer(&this->actor, 0x2AAA) && (this->actor.xzDistToPlayer < 200.0f) && (this->skelAnime.curFrame > 24.0f) && (this->skelAnime.curFrame < 28.0f)) { this->actor.hintId = 0x55; @@ -500,14 +499,14 @@ void func_8099571C(EnSkb* this) { this->unk_3DC = 0; this->actor.shape.shadowScale = 0.0f; if (this->unk_3DE == 9) { - Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 8); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, 8); this->actor.speedXZ = 2.4f; this->actor.gravity = -1.0f; this->actor.velocity.y = 3.0f; } else if (this->unk_3DE == 0xA) { - Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 8); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, 8); } else if (this->unk_3DE == 0xB) { - Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 9); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, 9); this->actor.speedXZ = 3.2f; this->actor.gravity = -1.0f; this->actor.velocity.y = 2.0f; @@ -516,7 +515,7 @@ void func_8099571C(EnSkb* this) { this->actionFunc = func_80995818; } -void func_80995818(EnSkb* this, GlobalContext* globalCtx) { +void func_80995818(EnSkb* this, PlayState* play) { s32 i; Math_ApproachF(&this->actor.shape.shadowScale, 25.0f, 1.0f, 2.5f); @@ -530,14 +529,14 @@ void func_80995818(EnSkb* this, GlobalContext* globalCtx) { if (this->actor.bgCheckFlags & 2) { this->actor.speedXZ = 0.0f; for (i = 0; i < 10; i++) { - func_809947B0(globalCtx, this, &this->actor.world.pos); + func_809947B0(play, this, &this->actor.world.pos); } } } void func_809958F4(EnSkb* this) { Animation_Change(&this->skelAnime, &object_skb_Anim_003584, -1.0f, Animation_GetLastFrame(&object_skb_Anim_003584), - 0.0f, 2, -4.0f); + 0.0f, ANIMMODE_ONCE, -4.0f); this->unk_3E4 = 0; this->actor.flags &= ~ACTOR_FLAG_1; this->actor.speedXZ = 0.0f; @@ -546,11 +545,11 @@ void func_809958F4(EnSkb* this) { this->actionFunc = func_8099599C; } -void func_8099599C(EnSkb* this, GlobalContext* globalCtx) { +void func_8099599C(EnSkb* this, PlayState* play) { Math_ApproachF(&this->actor.shape.yOffset, -8000.0f, 1.0f, 500.0f); - if ((globalCtx->gameplayFrames % 2) != 0) { - func_809947B0(globalCtx, this, &this->actor.world.pos); + if ((play->gameplayFrames % 2) != 0) { + func_809947B0(play, this, &this->actor.world.pos); } Math_ApproachF(&this->actor.shape.shadowScale, 0.0f, 1.0f, 2.5f); @@ -561,25 +560,25 @@ void func_8099599C(EnSkb* this, GlobalContext* globalCtx) { } void func_80995A30(EnSkb* this) { - Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 0); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, 0); this->actor.speedXZ = 1.6f; this->unk_3DA = 0; this->unk_3DE = 2; this->actionFunc = func_80995A8C; } -void func_80995A8C(EnSkb* this, GlobalContext* globalCtx) { - if (Player_GetMask(globalCtx) == PLAYER_MASK_CAPTAIN) { +void func_80995A8C(EnSkb* this, PlayState* play) { + if (Player_GetMask(play) == PLAYER_MASK_CAPTAIN) { this->actor.flags &= ~(ACTOR_FLAG_1 | ACTOR_FLAG_4); this->actor.flags |= (ACTOR_FLAG_1 | ACTOR_FLAG_8); this->actor.hintId = 0xFF; this->actor.colChkInfo.mass = MASS_HEAVY; - Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 12); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, 12); func_8099504C(this); return; } - if ((this->unk_3D8 != 0) && ((globalCtx->gameplayFrames % 16) == 0)) { + if ((this->unk_3D8 != 0) && ((play->gameplayFrames % 16) == 0)) { this->unk_3DA = randPlusMinusPoint5Scaled(50000.0f); } @@ -589,7 +588,7 @@ void func_80995A8C(EnSkb* this, GlobalContext* globalCtx) { Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_STALKID_WALK); } - if ((this->actor.xzDistToPlayer > 800.0f) || func_80996594(this, globalCtx)) { + if ((this->actor.xzDistToPlayer > 800.0f) || func_80996594(this, play)) { func_809958F4(this); } else if (Actor_IsFacingPlayer(&this->actor, 0x11C7) && (this->actor.xzDistToPlayer < 60.0f)) { func_80995C24(this); @@ -597,14 +596,14 @@ void func_80995A8C(EnSkb* this, GlobalContext* globalCtx) { } void func_80995C24(EnSkb* this) { - Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 2); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, 2); this->collider.base.atFlags &= ~AT_BOUNCED; this->actor.speedXZ = 0.0f; this->unk_3DE = 3; this->actionFunc = func_80995C84; } -void func_80995C84(EnSkb* this, GlobalContext* globalCtx) { +void func_80995C84(EnSkb* this, PlayState* play) { if (Animation_OnFrame(&this->skelAnime, 3.0f) && (this->unk_3E4 == 0)) { Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_STALKID_ATTACK); this->unk_3E4 = 1; @@ -616,21 +615,22 @@ void func_80995C84(EnSkb* this, GlobalContext* globalCtx) { this->collider.base.atFlags &= ~(AT_BOUNCED | AT_HIT); func_80995D3C(this); } else if (Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) { - func_80994DA8(this, globalCtx); + func_80994DA8(this, play); } } void func_80995D3C(EnSkb* this) { - Animation_Change(&this->skelAnime, &object_skb_Anim_002190, -0.4f, this->skelAnime.curFrame - 1.0f, 0.0f, 3, 0.0f); + Animation_Change(&this->skelAnime, &object_skb_Anim_002190, -0.4f, this->skelAnime.curFrame - 1.0f, 0.0f, + ANIMMODE_ONCE_INTERP, 0.0f); this->collider.base.atFlags &= ~AT_BOUNCED; this->unk_3DE = 4; this->unk_3E4 = 0; this->actionFunc = func_80995DC4; } -void func_80995DC4(EnSkb* this, GlobalContext* globalCtx) { +void func_80995DC4(EnSkb* this, PlayState* play) { if (Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) { - func_80994DA8(this, globalCtx); + func_80994DA8(this, play); } } @@ -644,7 +644,7 @@ void func_80995E08(EnSkb* this) { this->actionFunc = func_80995E64; } -void func_80995E64(EnSkb* this, GlobalContext* globalCtx) { +void func_80995E64(EnSkb* this, PlayState* play) { if (this->actor.bgCheckFlags & 2) { this->actor.speedXZ = 0.0f; } @@ -658,9 +658,9 @@ void func_80995E64(EnSkb* this, GlobalContext* globalCtx) { if ((this->actor.colorFilterTimer == 0) && (this->actor.bgCheckFlags & 1)) { if (this->unk_3DC == 0) { if (this->actor.colChkInfo.health == 0) { - func_809961E4(this, globalCtx); + func_809961E4(this, play); } else { - func_80994DA8(this, globalCtx); + func_80994DA8(this, play); } } else { switch (this->unk_3D6) { @@ -682,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_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 8); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, 8); this->actor.gravity = -1.0f; this->actor.speedXZ = 1.0f; } else if (this->unk_3DE == 0xB) { - Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 9); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, 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_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 3); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, 3); if (this->actor.bgCheckFlags & 1) { this->actor.speedXZ = -4.0f; } @@ -702,12 +702,12 @@ void func_80995F98(EnSkb* this) { this->actionFunc = func_809960AC; } -void func_809960AC(EnSkb* this, GlobalContext* globalCtx) { +void func_809960AC(EnSkb* this, PlayState* play) { if (this->actor.bgCheckFlags & 2) { s32 i; for (i = 0; i < 10; i++) { - func_809947B0(globalCtx, this, &this->actor.world.pos); + func_809947B0(play, this, &this->actor.world.pos); } this->actor.speedXZ = 0.0f; } @@ -723,27 +723,27 @@ void func_809960AC(EnSkb* this, GlobalContext* globalCtx) { if (Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame) && (this->actor.bgCheckFlags & 1)) { this->actor.shape.rot.x = 0; this->actor.world.rot = this->actor.shape.rot; - func_80994DA8(this, globalCtx); + func_80994DA8(this, play); } } -void func_809961E4(EnSkb* this, GlobalContext* globalCtx) { - Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 4); +void func_809961E4(EnSkb* this, PlayState* play) { + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, 4); this->unk_3D8 |= 0x40; if (this->actor.bgCheckFlags & 1) { this->actor.speedXZ = -6.0f; } this->unk_3E4 = 0; this->actor.flags &= ~ACTOR_FLAG_1; - SoundSource_PlaySfxAtFixedWorldPos(globalCtx, &this->actor.world.pos, 40, NA_SE_EN_STALKID_DEAD); + SoundSource_PlaySfxAtFixedWorldPos(play, &this->actor.world.pos, 40, NA_SE_EN_STALKID_DEAD); this->unk_3DE = 7; this->actionFunc = func_80996284; } -void func_80996284(EnSkb* this, GlobalContext* globalCtx) { +void func_80996284(EnSkb* this, PlayState* play) { if (this->unk_3D8 & 0x80) { if (1) {} - Item_DropCollectibleRandom(globalCtx, &this->actor, &this->actor.world.pos, 0x10); + Item_DropCollectibleRandom(play, &this->actor, &this->actor.world.pos, 0x10); func_80996474(this); } } @@ -753,21 +753,21 @@ void func_809962D4(EnSkb* this) { this->actionFunc = func_8099630C; } -void func_8099630C(EnSkb* this, GlobalContext* globalCtx) { +void func_8099630C(EnSkb* this, PlayState* play) { 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_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 3); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, 3); this->unk_3D8 |= 1; func_80995F98(this); } else { - func_809961E4(this, globalCtx); + func_809961E4(this, play); } } else if (this->drawDmgEffTimer == 1) { - func_80996BEC(this, globalCtx); + func_80996BEC(this, play); } } @@ -775,18 +775,18 @@ void func_809963C4(EnSkb* this) { this->actionFunc = func_809963D8; } -void func_809963D8(EnSkb* this, GlobalContext* globalCtx) { +void func_809963D8(EnSkb* this, PlayState* play) { 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_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 3); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, 3); this->unk_3D8 |= 1; func_80995F98(this); } else { - func_809961E4(this, globalCtx); + func_809961E4(this, play); } } } @@ -798,18 +798,18 @@ void func_80996474(EnSkb* this) { this->actionFunc = func_809964A0; } -void func_809964A0(EnSkb* this, GlobalContext* globalCtx) { - if ((this->unk_3D0++ < 19) ^ 1) { +void func_809964A0(EnSkb* this, PlayState* play) { + if (this->unk_3D0++ >= 19) { Actor_MarkForDeath(&this->actor); } } -void func_809964DC(EnSkb* this, GlobalContext* globalCtx) { +void func_809964DC(EnSkb* this, PlayState* play) { if (this->unk_3D6 == 0) { if ((this->actionFunc != func_80994E94) && (this->actionFunc != func_80996284) && (this->actionFunc != func_809964A0) && (gSaveContext.save.weekEventReg[85] & 0x40)) { this->actor.colChkInfo.health = 0; - func_809961E4(this, globalCtx); + func_809961E4(this, play); } } } @@ -826,7 +826,7 @@ s32 func_80996544(Vec2f arg0, Vec2f arg1) { return ret; } -s32 func_80996594(EnSkb* this, GlobalContext* globalCtx) { +s32 func_80996594(EnSkb* this, PlayState* play) { s32 temp_s2; s32 j; Vec2f sp60; @@ -868,15 +868,15 @@ s32 func_80996594(EnSkb* this, GlobalContext* globalCtx) { return sp54; } -void func_8099672C(EnSkb* this, GlobalContext* globalCtx) { +void func_8099672C(EnSkb* this, PlayState* play) { s32 pad; - Player* player = GET_PLAYER(globalCtx); + Player* player = GET_PLAYER(play); if ((this->unk_3DE != 6) && (this->unk_3DE != 7)) { if ((this->actor.bgCheckFlags & 0x60) && (this->actor.depthInWater >= 40.0f)) { this->actor.colChkInfo.health = 0; this->unk_3E4 = 0; - func_809961E4(this, globalCtx); + func_809961E4(this, play); return; } @@ -886,7 +886,7 @@ void func_8099672C(EnSkb* this, GlobalContext* globalCtx) { switch (this->actor.colChkInfo.damageEffect) { default: if (this->drawDmgEffTimer > 1) { - func_80996BEC(this, globalCtx); + func_80996BEC(this, play); } this->drawDmgEffTimer = 0; break; @@ -903,7 +903,7 @@ void func_8099672C(EnSkb* this, GlobalContext* globalCtx) { if (!Actor_ApplyDamage(&this->actor) && (this->actor.colChkInfo.damageEffect != 3) && (this->actor.colChkInfo.damageEffect != 4)) { this->unk_3D8 |= 0x40; - func_809961E4(this, globalCtx); + func_809961E4(this, play); return; } @@ -953,7 +953,7 @@ void func_8099672C(EnSkb* this, GlobalContext* globalCtx) { this->drawDmgEffScale = 0.5f; Actor_SetColorFilter(&this->actor, 0x4000, 0xFF, 0, 8); Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_STALKID_DAMAGE); - Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 3); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, 3); func_809963C4(this); break; @@ -962,14 +962,16 @@ void func_8099672C(EnSkb* this, GlobalContext* globalCtx) { this->unk_3D8 |= 1; case 15: - if ((player->swordAnimation == 4) || (player->swordAnimation == 11) || - (player->swordAnimation == 22) || (player->swordAnimation == 23)) { + if ((player->meleeWeaponAnimation == PLAYER_MWA_RIGHT_SLASH_1H) || + (player->meleeWeaponAnimation == PLAYER_MWA_LEFT_COMBO_2H) || + (player->meleeWeaponAnimation == PLAYER_MWA_BACKSLASH_RIGHT) || + (player->meleeWeaponAnimation == PLAYER_MWA_BACKSLASH_LEFT)) { this->unk_3D8 |= 1; } case 13: Actor_SetColorFilter(&this->actor, 0x4000, 0xFF, 0, 8); - Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 3); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, 3); func_80995F98(this); break; } @@ -977,27 +979,27 @@ void func_8099672C(EnSkb* this, GlobalContext* globalCtx) { } } -void func_80996AD0(EnSkb* this, GlobalContext* globalCtx) { +void func_80996AD0(EnSkb* this, PlayState* play) { if (1) {} if ((this->actionFunc != func_80996284) && (this->unk_3E2 != 1)) { if (this->unk_3E4 != 0) { - CollisionCheck_SetAT(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + CollisionCheck_SetAT(play, &play->colChkCtx, &this->collider.base); } if (((this->unk_3DE != 0) || (this->unk_3D0 >= 11)) && (this->unk_3DE != 1) && (this->unk_3DE != 4) && (this->unk_3DE != 6) && (this->unk_3DE != 7) && ((this->actor.colorFilterTimer == 0) || !(this->actor.colorFilterParams & 0x4000))) { - CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + CollisionCheck_SetAC(play, &play->colChkCtx, &this->collider.base); } if ((this->actionFunc != func_80996284) && (this->actionFunc != func_809964A0)) { - CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + CollisionCheck_SetOC(play, &play->colChkCtx, &this->collider.base); } } } -void func_80996BEC(EnSkb* this, GlobalContext* globalCtx) { +void func_80996BEC(EnSkb* this, PlayState* play) { static Color_RGBA8 D_80997550 = { 170, 255, 255, 255 }; static Color_RGBA8 D_80997554 = { 200, 200, 255, 255 }; static Vec3f D_80997558 = { 0.0f, -1.0, 0.0f }; @@ -1012,18 +1014,18 @@ void func_80996BEC(EnSkb* this, GlobalContext* globalCtx) { end = 14; } - SoundSource_PlaySfxAtFixedWorldPos(globalCtx, &this->actor.world.pos, 30, NA_SE_EV_ICE_BROKEN); + SoundSource_PlaySfxAtFixedWorldPos(play, &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->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->limbPos[i], 0.6f, &sp84, &D_80997558, &D_80997550, &D_80997554, 30); + EffectSsEnIce_Spawn(play, &this->limbPos[i], 0.6f, &sp84, &D_80997558, &D_80997550, &D_80997554, 30); } } -void func_80996D68(EnSkb* this, GlobalContext* globalCtx) { +void func_80996D68(EnSkb* this, PlayState* play) { if (this->drawDmgEffTimer > 0) { this->drawDmgEffTimer--; } @@ -1042,43 +1044,43 @@ void func_80996D68(EnSkb* this, GlobalContext* globalCtx) { } } -void EnSkb_Update(Actor* thisx, GlobalContext* globalCtx) { +void EnSkb_Update(Actor* thisx, PlayState* play) { s32 pad; EnSkb* this = THIS; - this->actionFunc(this, globalCtx); + this->actionFunc(this, play); if ((this->actionFunc != func_80995E64) && (this->actionFunc != func_80996284) && (this->actionFunc != func_8099630C) && (this->actionFunc != func_809963D8)) { SkelAnime_Update(&this->skelAnime); } - func_8099672C(this, globalCtx); + func_8099672C(this, play); if ((this->actionFunc != func_8099630C) && (this->actionFunc != func_809963D8) && (this->actionFunc != func_80995E64)) { Actor_MoveWithGravity(&this->actor); } - Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 15.0f, 30.0f, 60.0f, 0x1D); - func_809964DC(this, globalCtx); - func_80996AD0(this, globalCtx); - func_80996D68(this, globalCtx); + Actor_UpdateBgCheckInfo(play, &this->actor, 15.0f, 30.0f, 60.0f, 0x1D); + func_809964DC(this, play); + func_80996AD0(this, play); + func_80996D68(this, play); } -s32 EnSkb_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, Actor* thisx) { +s32 EnSkb_OverrideLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, Actor* thisx) { EnSkb* this = THIS; s32 pad; s16 sins; if (limbIndex == 11) { if (!(this->unk_3D8 & 2)) { - OPEN_DISPS(globalCtx->state.gfxCtx); + OPEN_DISPS(play->state.gfxCtx); - sins = fabsf(Math_SinS(globalCtx->gameplayFrames * 6000) * 95.0f) + 160.0f; + sins = fabsf(Math_SinS(play->gameplayFrames * 6000) * 95.0f) + 160.0f; gDPPipeSync(POLY_OPA_DISP++); gDPSetEnvColor(POLY_OPA_DISP++, sins, sins, sins, 255); - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->state.gfxCtx); } else { *dList = NULL; } @@ -1087,49 +1089,49 @@ 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; } -void EnSkb_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx) { +void EnSkb_PostLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx) { static Vec3f D_80997564 = { 800.0f, 1200.0f, 0.0f }; EnSkb* this = THIS; Collider_UpdateSpheres(limbIndex, &this->collider); if ((this->unk_3D8 & 1) && !(this->unk_3D8 & 2)) { if (limbIndex == 11) { - Actor_SpawnBodyParts(&this->actor, globalCtx, 1, dList); + Actor_SpawnBodyParts(&this->actor, play, 1, dList); this->unk_3D8 |= 2; } } else if ((this->unk_3D8 & 0x40) && !(this->unk_3D8 & 0x80) && ((limbIndex != 11) || !(this->unk_3D8 & 1)) && (limbIndex != 12)) { - Actor_SpawnBodyParts(&this->actor, globalCtx, 1, dList); + Actor_SpawnBodyParts(&this->actor, play, 1, dList); } 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->limbPos[this->limbCount]); + Matrix_MultZero(&this->limbPos[this->limbCount]); this->limbCount++; } else if ((limbIndex == 11) && !(this->unk_3D8 & 2)) { - Matrix_MultiplyVector3fByState(&D_80997564, &this->limbPos[this->limbCount]); + Matrix_MultVec3f(&D_80997564, &this->limbPos[this->limbCount]); this->limbCount++; } } } -void EnSkb_Draw(Actor* thisx, GlobalContext* globalCtx) { +void EnSkb_Draw(Actor* thisx, PlayState* play) { EnSkb* this = THIS; this->limbCount = 0; - func_8012C28C(globalCtx->state.gfxCtx); - SkelAnime_DrawOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, EnSkb_OverrideLimbDraw, + func_8012C28C(play->state.gfxCtx); + SkelAnime_DrawOpa(play, this->skelAnime.skeleton, this->skelAnime.jointTable, EnSkb_OverrideLimbDraw, EnSkb_PostLimbDraw, &this->actor); if (this->drawDmgEffTimer > 0) { - Actor_DrawDamageEffects(globalCtx, &this->actor, this->limbPos, this->limbCount, this->drawDmgEffScale, 0.5f, + Actor_DrawDamageEffects(play, &this->actor, this->limbPos, this->limbCount, this->drawDmgEffScale, 0.5f, this->drawDmgEffAlpha, this->drawDmgEffType); } 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 fe5722e53..002604838 100644 --- a/src/overlays/actors/ovl_En_Skb/z_en_skb.h +++ b/src/overlays/actors/ovl_En_Skb/z_en_skb.h @@ -5,35 +5,35 @@ struct EnSkb; -typedef void (*EnSkbActionFunc)(struct EnSkb*, GlobalContext*); +typedef void (*EnSkbActionFunc)(struct EnSkb*, PlayState*); #define ENSKB_GET_F0(thisx) (((thisx)->params >> 4) & 0xF) typedef struct EnSkb { - /* 0x0000 */ Actor actor; - /* 0x0144 */ SkelAnime skelAnime; - /* 0x0188 */ ColliderJntSph collider; - /* 0x01A8 */ ColliderJntSphElement colliderElements[2]; - /* 0x0228 */ EnSkbActionFunc actionFunc; - /* 0x022C */ f32 drawDmgEffAlpha; - /* 0x0230 */ f32 drawDmgEffScale; - /* 0x0234 */ Vec3f limbPos[14]; - /* 0x02DC */ s32 limbCount; - /* 0x02E0 */ Vec3s jointTable[20]; - /* 0x0358 */ Vec3s morphTable[20]; - /* 0x03D0 */ s16 unk_3D0; - /* 0x03D2 */ s16 drawDmgEffTimer; - /* 0x03D4 */ s16 unk_3D4; - /* 0x03D6 */ s16 unk_3D6; - /* 0x03D8 */ s16 unk_3D8; - /* 0x03DA */ s16 unk_3DA; - /* 0x03DC */ s16 unk_3DC; - /* 0x03DE */ s16 unk_3DE; - /* 0x03E0 */ s16 unk_3E0; - /* 0x03E2 */ s16 unk_3E2; - /* 0x03E4 */ u8 unk_3E4; - /* 0x03E5 */ u8 unk_3E5; - /* 0x03E6 */ u8 drawDmgEffType; + /* 0x000 */ Actor actor; + /* 0x144 */ SkelAnime skelAnime; + /* 0x188 */ ColliderJntSph collider; + /* 0x1A8 */ ColliderJntSphElement colliderElements[2]; + /* 0x228 */ EnSkbActionFunc actionFunc; + /* 0x22C */ f32 drawDmgEffAlpha; + /* 0x230 */ f32 drawDmgEffScale; + /* 0x234 */ Vec3f limbPos[14]; + /* 0x2DC */ s32 limbCount; + /* 0x2E0 */ Vec3s jointTable[20]; + /* 0x358 */ Vec3s morphTable[20]; + /* 0x3D0 */ s16 unk_3D0; + /* 0x3D2 */ s16 drawDmgEffTimer; + /* 0x3D4 */ s16 unk_3D4; + /* 0x3D6 */ s16 unk_3D6; + /* 0x3D8 */ s16 unk_3D8; + /* 0x3DA */ s16 unk_3DA; + /* 0x3DC */ s16 unk_3DC; + /* 0x3DE */ s16 unk_3DE; + /* 0x3E0 */ s16 unk_3E0; + /* 0x3E2 */ s16 unk_3E2; + /* 0x3E4 */ u8 unk_3E4; + /* 0x3E5 */ u8 unk_3E5; + /* 0x3E6 */ u8 drawDmgEffType; } EnSkb; // size = 0x3E8 extern const ActorInit En_Skb_InitVars; diff --git a/src/overlays/actors/ovl_En_Slime/z_en_slime.c b/src/overlays/actors/ovl_En_Slime/z_en_slime.c index 539d458ad..b9660682f 100644 --- a/src/overlays/actors/ovl_En_Slime/z_en_slime.c +++ b/src/overlays/actors/ovl_En_Slime/z_en_slime.c @@ -10,27 +10,27 @@ #define THIS ((EnSlime*)thisx) -void EnSlime_Init(Actor* thisx, GlobalContext* globalCtx); -void EnSlime_Destroy(Actor* thisx, GlobalContext* globalCtx); -void EnSlime_Update(Actor* thisx, GlobalContext* globalCtx); -void EnSlime_Draw(Actor* thisx, GlobalContext* globalCtx); +void EnSlime_Init(Actor* thisx, PlayState* play); +void EnSlime_Destroy(Actor* thisx, PlayState* play); +void EnSlime_Update(Actor* thisx, PlayState* play); +void EnSlime_Draw(Actor* thisx, PlayState* play); -void func_80A2F140(EnSlime* this, GlobalContext* globalCtx); -void func_80A2F1A4(EnSlime* this, GlobalContext* globalCtx); -void func_80A2F418(EnSlime* this, GlobalContext* globalCtx); -void func_80A2F6CC(EnSlime* this, GlobalContext* globalCtx); -void func_80A2F8E0(EnSlime* this, GlobalContext* globalCtx); -void func_80A2FA88(EnSlime* this, GlobalContext* globalCtx); -void func_80A2FBA0(EnSlime* this, GlobalContext* globalCtx); -void func_80A2FE38(EnSlime* this, GlobalContext* globalCtx); -void func_80A30344(EnSlime* this, GlobalContext* globalCtx); -void func_80A304B8(EnSlime* this, GlobalContext* globalCtx); -void func_80A30820(EnSlime* this, GlobalContext* globalCtx); -void func_80A30944(EnSlime* this, GlobalContext* globalCtx); -void func_80A30A20(EnSlime* this, GlobalContext* globalCtx); -void func_80A30AE4(EnSlime* this, GlobalContext* globalCtx); -void func_80A30C2C(EnSlime* this, GlobalContext* globalCtx); -void func_80A30CEC(EnSlime* this, GlobalContext* globalCtx); +void func_80A2F140(EnSlime* this, PlayState* play); +void func_80A2F1A4(EnSlime* this, PlayState* play); +void func_80A2F418(EnSlime* this, PlayState* play); +void func_80A2F6CC(EnSlime* this, PlayState* play); +void func_80A2F8E0(EnSlime* this, PlayState* play); +void func_80A2FA88(EnSlime* this, PlayState* play); +void func_80A2FBA0(EnSlime* this, PlayState* play); +void func_80A2FE38(EnSlime* this, PlayState* play); +void func_80A30344(EnSlime* this, PlayState* play); +void func_80A304B8(EnSlime* this, PlayState* play); +void func_80A30820(EnSlime* this, PlayState* play); +void func_80A30944(EnSlime* this, PlayState* play); +void func_80A30A20(EnSlime* this, PlayState* play); +void func_80A30AE4(EnSlime* this, PlayState* play); +void func_80A30C2C(EnSlime* this, PlayState* play); +void func_80A30CEC(EnSlime* this, PlayState* play); #if 0 const ActorInit En_Slime_InitVars = { diff --git a/src/overlays/actors/ovl_En_Slime/z_en_slime.h b/src/overlays/actors/ovl_En_Slime/z_en_slime.h index c24cae04e..dacbd824c 100644 --- a/src/overlays/actors/ovl_En_Slime/z_en_slime.h +++ b/src/overlays/actors/ovl_En_Slime/z_en_slime.h @@ -5,12 +5,12 @@ struct EnSlime; -typedef void (*EnSlimeActionFunc)(struct EnSlime*, GlobalContext*); +typedef void (*EnSlimeActionFunc)(struct EnSlime*, PlayState*); typedef struct EnSlime { - /* 0x0000 */ Actor actor; - /* 0x0144 */ EnSlimeActionFunc actionFunc; - /* 0x0148 */ char unk_148[0xC0]; + /* 0x000 */ Actor actor; + /* 0x144 */ EnSlimeActionFunc actionFunc; + /* 0x148 */ char unk_148[0xC0]; } EnSlime; // size = 0x208 extern const ActorInit En_Slime_InitVars; diff --git a/src/overlays/actors/ovl_En_Snowman/z_en_snowman.c b/src/overlays/actors/ovl_En_Snowman/z_en_snowman.c index 32d38ecb9..b07a1667e 100644 --- a/src/overlays/actors/ovl_En_Snowman/z_en_snowman.c +++ b/src/overlays/actors/ovl_En_Snowman/z_en_snowman.c @@ -1,7 +1,7 @@ /* * File: z_en_snowman.c * Overlay: ovl_En_Snowman - * Description: Enos + * Description: Eeno */ #include "z_en_snowman.h" @@ -10,26 +10,57 @@ #define THIS ((EnSnowman*)thisx) -void EnSnowman_Init(Actor* thisx, GlobalContext* globalCtx); -void EnSnowman_Destroy(Actor* thisx, GlobalContext* globalCtx); -void EnSnowman_Update(Actor* thisx, GlobalContext* globalCtx); -void EnSnowman_Draw(Actor* thisx, GlobalContext* globalCtx); +void EnSnowman_Init(Actor* thisx, PlayState* play); +void EnSnowman_Destroy(Actor* thisx, PlayState* play); +void EnSnowman_Update(Actor* thisx, PlayState* play); +void EnSnowman_Draw(Actor* thisx, PlayState* play); -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, PlayState* play); +void EnSnowman_SetupEmerge(EnSnowman* this, PlayState* play); +void EnSnowman_Emerge(EnSnowman* this, PlayState* play); +void EnSnowman_SetupReadySnowball(EnSnowman* this); +void EnSnowman_ReadySnowball(EnSnowman* this, PlayState* play); +void EnSnowman_SetupThrowSnowball(EnSnowman* this); +void EnSnowman_ThrowSnowball(EnSnowman* this, PlayState* play); +void EnSnowman_SetupIdle(EnSnowman* this); +void EnSnowman_Idle(EnSnowman* this, PlayState* play); +void EnSnowman_SetupSubmerge(EnSnowman* this, PlayState* play); +void EnSnowman_Submerge(EnSnowman* this, PlayState* play); +void EnSnowman_Melt(EnSnowman* this, PlayState* play); +void EnSnowman_Stun(EnSnowman* this, PlayState* play); +void EnSnowman_Damaged(EnSnowman* this, PlayState* play); +void EnSnowman_SetupDead(EnSnowman* this); +void EnSnowman_Dead(EnSnowman* this, PlayState* play); +void EnSnowman_SetupSplitDoNothing(EnSnowman* this); +void EnSnowman_SplitDoNothing(EnSnowman* this, PlayState* play); +void EnSnowman_SetupMarkForDeath(EnSnowman* this); +void EnSnowman_MarkForDeath(EnSnowman* this, PlayState* play); +void EnSnowman_CreateSplitEeno(EnSnowman* this, Vec3f* basePos, s32 yRot); +void EnSnowman_SetupCombine(EnSnowman* this, PlayState* play, Vec3f* combinePos); +void EnSnowman_Combine(EnSnowman* this, PlayState* play); +void EnSnowman_UpdateSnowball(Actor* thisx, PlayState* play); +void EnSnowman_DrawSnowPile(Actor* thisx, PlayState* play); +void EnSnowman_DrawSnowball(Actor* thisx, PlayState* play); + +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,1124 @@ 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, PlayState* play) { + 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(play, &this->skelAnime, &gEenoSkel, &gEenoEmergeAnim, this->jointTable, this->morphTable, + EENO_LIMB_MAX); + SkelAnime_InitFlex(play, &this->snowPileSkelAnime, &gEenoSnowPileSkel, &gEenoSnowPileMoveAnim, + this->snowPileJointTable, this->snowPileMorphTable, EENO_SNOW_PILE_LIMB_MAX); + CollisionCheck_SetInfo(&thisx->colChkInfo, &sDamageTable, &sColChkInfoInit); + Collider_InitAndSetCylinder(play, &this->collider, thisx, &sEenoCylinderInit); + if (EN_SNOWMAN_GET_TYPE(thisx) == EN_SNOWMAN_TYPE_LARGE) { + thisx->flags |= ACTOR_FLAG_400; + Actor_SpawnAsChild(&play->actorCtx, thisx, play, 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(&play->actorCtx, play, ACTOR_EN_SNOWMAN, thisx->world.pos.x, + thisx->world.pos.y, thisx->world.pos.z, 0, 0, 0, + EN_SNOWMAN_TYPE_SPLIT, -1, thisx->unk20, NULL); + 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(play); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Snowman/func_80B173D0.s") + thisx->flags &= ~ACTOR_FLAG_1; + Collider_InitAndSetCylinder(play, &this->collider, thisx, &sSnowballCylinderInit); + thisx->world.rot.y = Actor_YawBetweenActors(thisx, &player->actor); + thisx->velocity.y = (Actor_XZDistanceBetweenActors(thisx, &player->actor) * 0.035f) + -5.0f; + thisx->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, PlayState* play) { + EnSnowman* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Snowman/func_80B17A58.s") + Collider_DestroyCylinder(play, &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, PlayState* play) { + 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(play, &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, PlayState* play) { + 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(play, &pos, &velocity, &sAccel, 0, + Rand_S16Offset((((i % 3) * 50) + 50), (((i % 3) * 25) + 25)), OBJECT_SNOWMAN, 20, + sSnowballFragmentDLs[i % 3]); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Snowman/func_80B17F4C.s") + func_800B0DE0(play, &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, PlayState* play) { + Player* player = GET_PLAYER(play); + 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, play, &combinePos); + EnSnowman_SetupCombine((EnSnowman*)this->actor.child, play, &combinePos); + EnSnowman_SetupCombine(this, play, &combinePos); + } else if ((this->work.timer == 0) && (fabsf(this->actor.playerHeightRel) < 60.0f) && + (this->actor.xzDistToPlayer < this->attackRange) && (Player_GetMask(play) != PLAYER_MASK_STONE) && + !(player->stateFlags1 & 0x800000)) { + EnSnowman_SetupEmerge(this, play); + } 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, PlayState* play) { + 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, play); + 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, PlayState* play) { + Player* player = GET_PLAYER(play); -#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, play); + } else if (!(player->stateFlags1 & 0x800000) && (Player_GetMask(play) != 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, PlayState* play) { + 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 && + ((play->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(play, &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) && + ((play->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(play, &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, PlayState* play) { + Player* player = GET_PLAYER(play); + 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(play) != 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(&play->actorCtx, play, 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, PlayState* play) { + SkelAnime_Update(&this->skelAnime); + if (this->work.timer > 0) { + this->work.timer--; + } else { + EnSnowman_SetupSubmerge(this, play); + } +} + +void EnSnowman_SetupSubmerge(EnSnowman* this, PlayState* play) { + Animation_Change(&this->skelAnime, &gEenoEmergeAnim, -1.0f, Animation_GetLastFrame(&gEenoEmergeAnim), 0.0f, + ANIMMODE_ONCE, -3.0f); + EnSnowman_SpawnCircularDustEffect(this, play); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_YMAJIN_HIDE); + this->actionFunc = EnSnowman_Submerge; +} + +/** + * Submerge beneath the snow and become a snow pile. + */ +void EnSnowman_Submerge(EnSnowman* this, PlayState* play) { + 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, play, &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, PlayState* play) { + 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(play, &smokePos, &smokeVelocity, &gZeroVec3f, this->eenoScale * 300.0f); + } + + if (this->work.timer == 0) { + Item_DropCollectibleRandom(play, &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, PlayState* play) { + 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, PlayState* play) { + 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, play); + 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, play); + } else if (this->actor.colChkInfo.health != 0) { + this->collider.base.acFlags |= AC_ON; + EnSnowman_SetupSubmerge(this, play); + } 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, PlayState* play) { + 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(play, &pos, &velocity, &sAccel, 0, + Rand_S16Offset((((i % 3) * 20) + 20), (((i % 3) * 10) + 10)), OBJECT_SNOWMAN, 20, + sSnowballFragmentDLs[i % 3]); + } + + func_800B0DE0(play, &this->actor.world.pos, &gZeroVec3f, &gZeroVec3f, &sDustPrimColor, &sDustEnvColor, 500, 30); + SoundSource_PlaySfxAtFixedWorldPos(play, &this->actor.world.pos, 30, NA_SE_EN_YMAJIN_DEAD_BREAK); + Item_DropCollectibleRandom(play, &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, PlayState* play) { +} + +/** + * 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, PlayState* play) { + 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, PlayState* play, 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, play); + } + } +} + +/** + * Makes the small, split-off Eenos try to combine into a large Eeno by absorbing each other. + */ +void EnSnowman_Combine(EnSnowman* this, PlayState* play) { + 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, PlayState* play) { + 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(play, &this->actor); + Actor_ApplyDamage(&this->actor); + EnSnowman_SetupMelt(this); + } else { + if ((this->actionFunc == EnSnowman_MoveSnowPile) || (this->actionFunc == EnSnowman_Combine)) { + EnSnowman_SetupEmerge(this, play); + } else if (this->actor.colChkInfo.damageEffect == EN_SNOWMAN_DMGEFF_STUN) { + Actor_SetColorFilter(&this->actor, 0, 255, 0, 40); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_COMMON_FREEZE); + 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, play); + } + + EnSnowman_SetupDamaged(this); + } else { + if (Actor_ApplyDamage(&this->actor) == 0) { + Enemy_StartFinishingBlow(play, &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(&play->actorCtx, play, ACTOR_EN_CLEAR_TAG, this->collider.info.bumper.hitPos.x, + this->collider.info.bumper.hitPos.y, this->collider.info.bumper.hitPos.z, 0, 0, 0, + CLEAR_TAG_LARGE_LIGHT_RAYS); + } + } + } +} + +void EnSnowman_Update(Actor* thisx, PlayState* play) { + s32 pad; + EnSnowman* this = THIS; + f32 wallCheckRadius; + + if (this->actionFunc != EnSnowman_SplitDoNothing) { + DECR(this->combineTimer); + + EnSnowman_UpdateDamage(this, play); + this->actionFunc(this, play); + + 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(play, &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(play, &play->colChkCtx, &this->collider.base); + } + CollisionCheck_SetOC(play, &play->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, PlayState* play) { + 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(play, &thisx->world.pos, 5.0f, 0, scale, scale >> 1, 3, OBJECT_SNOWMAN, 20, + sSnowballFragmentDLs[i]); + scale *= 2; + } + + func_800B0DE0(play, &this->actor.world.pos, &gZeroVec3f, &gZeroVec3f, &sDustPrimColor, &sDustEnvColor, 500, + 30); + SoundSource_PlaySfxAtFixedWorldPos(play, &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, play); + SoundSource_PlaySfxAtFixedWorldPos(play, &this->actor.world.pos, 20, NA_SE_EV_SNOWBALL_BROKEN); + } + + SoundSource_PlaySfxAtFixedWorldPos(play, &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(play, &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(play, &play->colChkCtx, &this->collider.base); + CollisionCheck_SetAC(play, &play->colChkCtx, &this->collider.base); + CollisionCheck_SetOC(play, &play->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(PlayState* play, 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(play->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(play->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(play->state.gfxCtx); + + Matrix_MultZero(&this->snowballPos); + } +} + +void EnSnowman_Draw(Actor* thisx, PlayState* play) { + EnSnowman* this = THIS; + + func_8012C28C(play->state.gfxCtx); + SkelAnime_DrawFlexOpa(play, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, NULL, + EnSnowman_PostLimbDraw, &this->actor); + Actor_DrawDamageEffects(play, &this->actor, this->bodyPartsPos, ARRAY_COUNT(this->bodyPartsPos), + this->drawDmgEffScale * this->eenoScale, 0.0f, this->drawDmgEffAlpha, this->drawDmgEffType); +} + +void EnSnowman_DrawSnowPile(Actor* thisx, PlayState* play) { + EnSnowman* this = THIS; + + func_8012C28C(play->state.gfxCtx); + SkelAnime_DrawFlexOpa(play, this->snowPileSkelAnime.skeleton, this->snowPileSkelAnime.jointTable, + this->snowPileSkelAnime.dListCount, NULL, NULL, &this->actor); +} + +void EnSnowman_DrawSnowball(Actor* thisx, PlayState* play) { + Gfx_DrawDListOpa(play, 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..32a1ae352 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 void (*EnSnowmanActionFunc)(struct EnSnowman*, PlayState*); 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_Snowwd/z_en_snowwd.c b/src/overlays/actors/ovl_En_Snowwd/z_en_snowwd.c index 03038d058..7e50201ac 100644 --- a/src/overlays/actors/ovl_En_Snowwd/z_en_snowwd.c +++ b/src/overlays/actors/ovl_En_Snowwd/z_en_snowwd.c @@ -10,12 +10,12 @@ #define THIS ((EnSnowwd*)thisx) -void EnSnowwd_Init(Actor* thisx, GlobalContext* globalCtx); -void EnSnowwd_Destroy(Actor* thisx, GlobalContext* globalCtx); -void EnSnowwd_Update(Actor* thisx, GlobalContext* globalCtx); -void EnSnowwd_Draw(Actor* thisx, GlobalContext* globalCtx); +void EnSnowwd_Init(Actor* thisx, PlayState* play); +void EnSnowwd_Destroy(Actor* thisx, PlayState* play); +void EnSnowwd_Update(Actor* thisx, PlayState* play); +void EnSnowwd_Draw(Actor* thisx, PlayState* play); -void func_80AF76F0(EnSnowwd* this, GlobalContext* globalCtx); +void func_80AF76F0(EnSnowwd* this, PlayState* play); #if 0 const ActorInit En_Snowwd_InitVars = { diff --git a/src/overlays/actors/ovl_En_Snowwd/z_en_snowwd.h b/src/overlays/actors/ovl_En_Snowwd/z_en_snowwd.h index fbe589e1c..6706de846 100644 --- a/src/overlays/actors/ovl_En_Snowwd/z_en_snowwd.h +++ b/src/overlays/actors/ovl_En_Snowwd/z_en_snowwd.h @@ -5,12 +5,12 @@ struct EnSnowwd; -typedef void (*EnSnowwdActionFunc)(struct EnSnowwd*, GlobalContext*); +typedef void (*EnSnowwdActionFunc)(struct EnSnowwd*, PlayState*); typedef struct EnSnowwd { - /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x50]; - /* 0x0194 */ EnSnowwdActionFunc actionFunc; + /* 0x000 */ Actor actor; + /* 0x144 */ char unk_144[0x50]; + /* 0x194 */ EnSnowwdActionFunc actionFunc; } EnSnowwd; // size = 0x198 extern const ActorInit En_Snowwd_InitVars; diff --git a/src/overlays/actors/ovl_En_Sob1/z_en_sob1.c b/src/overlays/actors/ovl_En_Sob1/z_en_sob1.c index fc2ba1432..aa8f651ec 100644 --- a/src/overlays/actors/ovl_En_Sob1/z_en_sob1.c +++ b/src/overlays/actors/ovl_En_Sob1/z_en_sob1.c @@ -5,60 +5,63 @@ */ #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 (ACTOR_FLAG_1 | ACTOR_FLAG_8 | ACTOR_FLAG_10) #define THIS ((EnSob1*)thisx) -void EnSob1_Init(Actor* thisx, GlobalContext* globalCtx); -void EnSob1_Destroy(Actor* thisx, GlobalContext* globalCtx); -void EnSob1_Update(Actor* thisx, GlobalContext* globalCtx); +void EnSob1_Init(Actor* thisx, PlayState* play); +void EnSob1_Destroy(Actor* thisx, PlayState* play); +void EnSob1_Update(Actor* thisx, PlayState* play); -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_Draw(Actor* thisx, PlayState* play); +void EnSob1_GoronShopkeeper_Draw(Actor* thisx, PlayState* play); +void EnSob1_BombShopkeeper_Draw(Actor* thisx, PlayState* play); -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_ZoraShopkeeper_Init(EnSob1* this, PlayState* play); +void EnSob1_GoronShopkeeper_Init(EnSob1* this, PlayState* play); +void EnSob1_BombShopkeeper_Init(EnSob1* this, PlayState* play); -void EnSob1_InitShop(EnSob1* this, GlobalContext* globalCtx); -void EnSob1_Idle(EnSob1* this, GlobalContext* globalCtx); -void EnSob1_Walk(EnSob1* this, GlobalContext* globalCtx); -void EnSob1_Walking(EnSob1* this, GlobalContext* globalCtx); -void EnSob1_Hello(EnSob1* this, GlobalContext* globalCtx); -void EnSob1_StartShopping(GlobalContext* globalCtx, EnSob1* this); -void EnSob1_SetupIdle(EnSob1* this, GlobalContext* globalCtx); -void EnSob1_FaceShopkeeper(EnSob1* this, GlobalContext* globalCtx); -void EnSob1_LookToShelf(EnSob1* this, GlobalContext* globalCtx); -void EnSob1_EndingInteraction(EnSob1* this, GlobalContext* globalCtx); -void EnSob1_BrowseShelf(EnSob1* this, GlobalContext* globalCtx); -void EnSob1_TalkingToShopkeeper(EnSob1* this, GlobalContext* globalCtx); -void EnSob1_SelectItem(EnSob1* this, GlobalContext* globalCtx); -void EnSob1_LookToShopkeeperFromShelf(EnSob1* this, GlobalContext* globalCtx); -void EnSob1_BuyItemWithFanfare(EnSob1* this, GlobalContext* globalCtx); -void EnSob1_CanBuy(EnSob1* this, GlobalContext* globalCtx); -void EnSob1_CannotBuy(EnSob1* this, GlobalContext* globalCtx); -void EnSob1_SetupItemPurchased(EnSob1* this, GlobalContext* globalCtx); -void EnSob1_ContinueShopping(EnSob1* this, GlobalContext* globalCtx); +void EnSob1_InitShop(EnSob1* this, PlayState* play); +void EnSob1_Idle(EnSob1* this, PlayState* play); +void EnSob1_Walk(EnSob1* this, PlayState* play); +void EnSob1_Walking(EnSob1* this, PlayState* play); +void EnSob1_Hello(EnSob1* this, PlayState* play); +void EnSob1_StartShopping(PlayState* play, EnSob1* this); +void EnSob1_SetupIdle(EnSob1* this, PlayState* play); +void EnSob1_FaceShopkeeper(EnSob1* this, PlayState* play); +void EnSob1_LookToShelf(EnSob1* this, PlayState* play); +void EnSob1_EndingInteraction(EnSob1* this, PlayState* play); +void EnSob1_BrowseShelf(EnSob1* this, PlayState* play); +void EnSob1_TalkingToShopkeeper(EnSob1* this, PlayState* play); +void EnSob1_SelectItem(EnSob1* this, PlayState* play); +void EnSob1_LookToShopkeeperFromShelf(EnSob1* this, PlayState* play); +void EnSob1_BuyItemWithFanfare(EnSob1* this, PlayState* play); +void EnSob1_CanBuy(EnSob1* this, PlayState* play); +void EnSob1_CannotBuy(EnSob1* this, PlayState* play); +void EnSob1_SetupItemPurchased(EnSob1* this, PlayState* play); +void EnSob1_ContinueShopping(EnSob1* this, PlayState* play); void EnSob1_ResetItemPosition(EnSob1* this); void EnSob1_Blink(EnSob1* this); s32 EnSob1_TakeItemOffShelf(EnSob1* this); s32 EnSob1_ReturnItemToShelf(EnSob1* this); -s16 EnSob1_GetDistSqAndOrient(Path* path, s32 pointIdx, Vec3f* pos, f32* distSq); +s16 EnSob1_GetDistSqAndOrient(Path* path, s32 pointIndex, Vec3f* pos, f32* distSq); -static AnimationInfoS sAnimationsBombShopkeeper[] = { - { &object_rs_Anim_009120, 2.0f, 0, -1, ANIMMODE_LOOP, 20 }, - { &object_rs_Anim_008268, 1.0f, 0, -1, ANIMMODE_ONCE, 0 }, - { &object_rs_Anim_0087BC, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, +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 sAnimationInfoBombShopkeeper[] = { + { &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 = { @@ -153,10 +156,10 @@ static Vec3f sPosOffset[] = { { 0.0f, -4.0f, 0.0f }, }; -void EnSob1_ChangeAnim(SkelAnime* skelAnime, AnimationInfoS* animations, s32 idx) { +void EnSob1_ChangeAnim(SkelAnime* skelAnime, AnimationInfoS* animations, s32 animIndex) { f32 frameCount; - animations += idx; + animations += animIndex; if (animations->frameCount < 0) { frameCount = Animation_GetLastFrame(animations->animation); } else { @@ -170,19 +173,19 @@ void EnSob1_SetupAction(EnSob1* this, EnSob1ActionFunc action) { this->actionFunc = action; } -s32 EnSob1_TestItemSelected(GlobalContext* globalCtx) { - MessageContext* msgCtx = &globalCtx->msgCtx; +s32 EnSob1_TestItemSelected(PlayState* play) { + MessageContext* msgCtx = &play->msgCtx; if (msgCtx->unk12020 == 0x10 || msgCtx->unk12020 == 0x11) { - return CHECK_BTN_ALL(CONTROLLER1(globalCtx)->press.button, BTN_A); + return CHECK_BTN_ALL(CONTROLLER1(&play->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(&play->state)->press.button, BTN_A) || + CHECK_BTN_ALL(CONTROLLER1(&play->state)->press.button, BTN_B) || + CHECK_BTN_ALL(CONTROLLER1(&play->state)->press.button, BTN_CUP); } -u16 EnSob1_GetTalkOption(EnSob1* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); +u16 EnSob1_GetTalkOption(EnSob1* this, PlayState* play) { + Player* player = GET_PLAYER(play); if (this->shopType == BOMB_SHOP) { if (gSaveContext.save.day == 1 && gSaveContext.save.time >= CLOCK_TIME(6, 00)) { @@ -217,11 +220,11 @@ u16 EnSob1_GetTalkOption(EnSob1* this, GlobalContext* globalCtx) { return 0; } -u16 EnSob1_GetWelcome(EnSob1* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); +u16 EnSob1_GetWelcome(EnSob1* this, PlayState* play) { + Player* player = GET_PLAYER(play); if (this->shopType == BOMB_SHOP) { - switch (Player_GetMask(globalCtx)) { + switch (Player_GetMask(play)) { case PLAYER_MASK_NONE: case PLAYER_MASK_BUNNY: case PLAYER_MASK_POSTMAN: @@ -330,16 +333,16 @@ u16 EnSob1_GetGoodbye(EnSob1* this) { return 0x64C; } -void EnSob1_BombShopkeeper_EndInteraction(EnSob1* this, GlobalContext* globalCtx) { +void EnSob1_BombShopkeeper_EndInteraction(EnSob1* this, PlayState* play) { this->drawCursor = 0; this->stickLeftPrompt.isEnabled = false; this->stickRightPrompt.isEnabled = false; this->goodbyeTextId = EnSob1_GetGoodbye(this); - Message_StartTextbox(globalCtx, this->goodbyeTextId, &this->actor); + Message_StartTextbox(play, this->goodbyeTextId, &this->actor); EnSob1_SetupAction(this, EnSob1_EndingInteraction); } -void EnSob1_SpawnShopItems(EnSob1* this, GlobalContext* globalCtx, ShopItem* shopItem) { +void EnSob1_SpawnShopItems(EnSob1* this, PlayState* play, ShopItem* shopItem) { s32 i; for (i = 0; i < ARRAY_COUNT(this->items); i++, shopItem++) { @@ -347,33 +350,33 @@ void EnSob1_SpawnShopItems(EnSob1* this, GlobalContext* globalCtx, ShopItem* sho this->items[i] = NULL; } else { this->items[i] = - (EnGirlA*)Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_GIRLA, shopItem->spawnPos.x, - shopItem->spawnPos.y, shopItem->spawnPos.z, 0, 0, 0, shopItem->shopItemId); + (EnGirlA*)Actor_Spawn(&play->actorCtx, play, ACTOR_EN_GIRLA, shopItem->spawnPos.x, shopItem->spawnPos.y, + shopItem->spawnPos.z, 0, 0, 0, shopItem->shopItemId); } } } -s32 EnSob1_GetObjIndices(EnSob1* this, GlobalContext* globalCtx, s16* objIds) { +s32 EnSob1_GetObjIndices(EnSob1* this, PlayState* play, 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(&play->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(&play->objectCtx, objIds[2]); + if (this->shopkeeperAnimObjIndex < 0) { return false; } } else { - this->objIndices[2] = -1; + this->shopkeeperAnimObjIndex = -1; } return true; } -void EnSob1_Init(Actor* thisx, GlobalContext* globalCtx) { +void EnSob1_Init(Actor* thisx, PlayState* play) { EnSob1* this = THIS; s32 pad; s16* objIds; @@ -398,12 +401,12 @@ 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(&play->objectCtx, objIds[0]); + if (this->mainObjIndex < 0) { Actor_MarkForDeath(&this->actor); return; } - if (!EnSob1_GetObjIndices(this, globalCtx, objIds)) { + if (!EnSob1_GetObjIndices(this, play, objIds)) { Actor_MarkForDeath(&this->actor); return; } @@ -411,105 +414,105 @@ void EnSob1_Init(Actor* thisx, GlobalContext* globalCtx) { EnSob1_SetupAction(this, EnSob1_InitShop); } -void EnSob1_Destroy(Actor* thisx, GlobalContext* globalCtx) { +void EnSob1_Destroy(Actor* thisx, PlayState* play) { EnSob1* this = THIS; - Collider_DestroyCylinder(globalCtx, &this->collider); + Collider_DestroyCylinder(play, &this->collider); } -void EnSob1_UpdateCursorPos(GlobalContext* globalCtx, EnSob1* this) { +void EnSob1_UpdateCursorPos(PlayState* play, EnSob1* this) { s16 x; s16 y; f32 xOffset = 0.0f; f32 yOffset = 17.0f; - Actor_GetScreenPos(globalCtx, &this->items[this->cursorIdx]->actor, &x, &y); + Actor_GetScreenPos(play, &this->items[this->cursorIndex]->actor, &x, &y); this->cursorPos.x = x + xOffset; this->cursorPos.y = y + yOffset; this->cursorPos.z = 1.2f; } -void EnSob1_EndInteraction(GlobalContext* globalCtx, EnSob1* this) { - Player* player = GET_PLAYER(globalCtx); +void EnSob1_EndInteraction(PlayState* play, EnSob1* this) { + Player* player = GET_PLAYER(play); if (this->cutsceneState == ENSOB1_CUTSCENESTATE_PLAYING) { ActorCutscene_Stop(this->cutscene); this->cutsceneState = ENSOB1_CUTSCENESTATE_STOPPED; } - Actor_ProcessTalkRequest(&this->actor, &globalCtx->state); - globalCtx->msgCtx.msgMode = 0x43; - globalCtx->msgCtx.unk12023 = 4; + Actor_ProcessTalkRequest(&this->actor, &play->state); + play->msgCtx.msgMode = 0x43; + play->msgCtx.stateTimer = 4; Interface_ChangeAlpha(50); this->drawCursor = 0; this->stickLeftPrompt.isEnabled = false; this->stickRightPrompt.isEnabled = false; player->stateFlags2 &= ~0x20000000; - globalCtx->interfaceCtx.unk_222 = 0; - globalCtx->interfaceCtx.unk_224 = 0; + play->interfaceCtx.unk_222 = 0; + play->interfaceCtx.unk_224 = 0; EnSob1_SetupAction(this, EnSob1_Idle); } -s32 EnSob1_TestEndInteraction(EnSob1* this, GlobalContext* globalCtx, Input* input) { +s32 EnSob1_TestEndInteraction(EnSob1* this, PlayState* play, Input* input) { if (CHECK_BTN_ALL(input->press.button, BTN_B)) { if (this->shopType == BOMB_SHOP) { - EnSob1_BombShopkeeper_EndInteraction(this, globalCtx); + EnSob1_BombShopkeeper_EndInteraction(this, play); } else { - EnSob1_EndInteraction(globalCtx, this); + EnSob1_EndInteraction(play, this); } return true; } return false; } -s32 EnSob1_TestCancelOption(EnSob1* this, GlobalContext* globalCtx, Input* input) { +s32 EnSob1_TestCancelOption(EnSob1* this, PlayState* play, Input* input) { if (CHECK_BTN_ALL(input->press.button, BTN_B)) { - this->actionFunc = this->tmpActionFunc; - func_80151938(globalCtx, this->items[this->cursorIdx]->actor.textId); + this->actionFunc = this->prevActionFunc; + func_80151938(play, this->items[this->cursorIndex]->actor.textId); return true; } return false; } -void EnSob1_SetupStartShopping(GlobalContext* globalCtx, EnSob1* this, u8 skipHello) { - func_8011552C(globalCtx, 16); +void EnSob1_SetupStartShopping(PlayState* play, EnSob1* this, u8 skipHello) { + func_8011552C(play, 16); if (!skipHello) { EnSob1_SetupAction(this, EnSob1_Hello); } else { - EnSob1_StartShopping(globalCtx, this); + EnSob1_StartShopping(play, this); } } -void EnSob1_StartShopping(GlobalContext* globalCtx, EnSob1* this) { +void EnSob1_StartShopping(PlayState* play, EnSob1* this) { EnSob1_SetupAction(this, EnSob1_FaceShopkeeper); - func_80151938(globalCtx, sFacingShopkeeperTextIds[this->shopType]); - func_8011552C(globalCtx, 6); + func_80151938(play, sFacingShopkeeperTextIds[this->shopType]); + func_8011552C(play, 6); this->stickLeftPrompt.isEnabled = false; this->stickRightPrompt.isEnabled = true; } -void EnSob1_TalkToShopkeeper(GlobalContext* globalCtx, EnSob1* this) { +void EnSob1_TalkToShopkeeper(PlayState* play, EnSob1* this) { EnSob1_SetupAction(this, EnSob1_TalkingToShopkeeper); - this->talkOptionTextId = EnSob1_GetTalkOption(this, globalCtx); - func_80151938(globalCtx, this->talkOptionTextId); - func_8011552C(globalCtx, 6); + this->talkOptionTextId = EnSob1_GetTalkOption(this, play); + func_80151938(play, this->talkOptionTextId); + func_8011552C(play, 6); this->stickLeftPrompt.isEnabled = false; this->stickRightPrompt.isEnabled = false; } -void EnSob1_SetupLookToShopkeeperFromShelf(GlobalContext* globalCtx, EnSob1* this) { +void EnSob1_SetupLookToShopkeeperFromShelf(PlayState* play, EnSob1* this) { play_sound(NA_SE_SY_CURSOR); this->drawCursor = 0; EnSob1_SetupAction(this, EnSob1_LookToShopkeeperFromShelf); } -void EnSob1_EndingInteraction(EnSob1* this, GlobalContext* globalCtx) { - if (Message_GetState(&globalCtx->msgCtx) == 6 && Message_ShouldAdvance(globalCtx)) { - EnSob1_EndInteraction(globalCtx, this); +void EnSob1_EndingInteraction(EnSob1* this, PlayState* play) { + if ((Message_GetState(&play->msgCtx) == TEXT_STATE_DONE) && Message_ShouldAdvance(play)) { + EnSob1_EndInteraction(play, this); } } -void EnSob1_SetupWalk(EnSob1* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); +void EnSob1_SetupWalk(EnSob1* this, PlayState* play) { + Player* player = GET_PLAYER(play); if ((player->actor.world.pos.x >= 0.0f && player->actor.world.pos.x <= 390.0f) && (player->actor.world.pos.z >= 72.0f && player->actor.world.pos.z <= 365.0f)) { @@ -517,11 +520,11 @@ void EnSob1_SetupWalk(EnSob1* this, GlobalContext* globalCtx) { } } -void EnSob1_Idle(EnSob1* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); +void EnSob1_Idle(EnSob1* this, PlayState* play) { + Player* player = GET_PLAYER(play); this->headRotTarget = this->actor.yawTowardsPlayer - this->actor.shape.rot.y; - if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { + if (Actor_ProcessTalkRequest(&this->actor, &play->state)) { if (this->cutsceneState == ENSOB1_CUTSCENESTATE_STOPPED) { if (ActorCutscene_GetCurrentIndex() == 0x7C) { ActorCutscene_Stop(0x7C); @@ -531,29 +534,29 @@ void EnSob1_Idle(EnSob1* this, GlobalContext* globalCtx) { this->cutsceneState = ENSOB1_CUTSCENESTATE_WAITING; } player->stateFlags2 |= 0x20000000; - this->welcomeTextId = EnSob1_GetWelcome(this, globalCtx); - Message_StartTextbox(globalCtx, this->welcomeTextId, &this->actor); + this->welcomeTextId = EnSob1_GetWelcome(this, play); + Message_StartTextbox(play, this->welcomeTextId, &this->actor); if (ENSOB1_GET_SHOPTYPE(&this->actor) == BOMB_SHOP) { this->headRotTarget = -0x2000; } - EnSob1_SetupStartShopping(globalCtx, this, false); + EnSob1_SetupStartShopping(play, this, false); } else { if ((player->actor.world.pos.x >= this->posXZRange.xMin && player->actor.world.pos.x <= this->posXZRange.xMax) && (player->actor.world.pos.z >= this->posXZRange.zMin && player->actor.world.pos.z <= this->posXZRange.zMax)) { - func_800B8614(&this->actor, globalCtx, 400.0f); + func_800B8614(&this->actor, play, 400.0f); } if (this->wasTalkedToWhileWalking == true) { this->wasTalkedToWhileWalking = false; - EnSob1_SetupStartShopping(globalCtx, this, false); + EnSob1_SetupStartShopping(play, this, false); } } } -void EnSob1_UpdateJoystickInputState(GlobalContext* globalCtx, EnSob1* this) { - s8 stickX = CONTROLLER1(globalCtx)->rel.stick_x; - s8 stickY = CONTROLLER1(globalCtx)->rel.stick_y; +void EnSob1_UpdateJoystickInputState(PlayState* play, EnSob1* this) { + s8 stickX = CONTROLLER1(&play->state)->rel.stick_x; + s8 stickY = CONTROLLER1(&play->state)->rel.stick_y; if (this->stickAccumX == 0) { if (stickX > 30 || stickX < -30) { @@ -596,8 +599,8 @@ u8 EnSob1_SetCursorIndexFromNeutral(EnSob1* this, u8 shelfOffset) { return CURSOR_INVALID; } -void EnSob1_Hello(EnSob1* this, GlobalContext* globalCtx) { - u8 talkState = Message_GetState(&globalCtx->msgCtx); +void EnSob1_Hello(EnSob1* this, PlayState* play) { + u8 talkState = Message_GetState(&play->msgCtx); if (this->cutsceneState == ENSOB1_CUTSCENESTATE_WAITING) { if (ActorCutscene_GetCanPlayNext(this->cutscene)) { @@ -607,38 +610,38 @@ void EnSob1_Hello(EnSob1* this, GlobalContext* globalCtx) { ActorCutscene_SetIntentToPlay(this->cutscene); } } - if ((talkState == 5) && (Message_ShouldAdvance(globalCtx)) && - (!EnSob1_TestEndInteraction(this, globalCtx, CONTROLLER1(globalCtx)))) { + if ((talkState == TEXT_STATE_5) && Message_ShouldAdvance(play) && + !EnSob1_TestEndInteraction(this, play, CONTROLLER1(&play->state))) { if (this->welcomeTextId == 0x68A) { // Welcome text when wearing Kafei's mask - EnSob1_EndInteraction(globalCtx, this); + EnSob1_EndInteraction(play, this); } else { - EnSob1_StartShopping(globalCtx, this); + EnSob1_StartShopping(play, this); } } } -s32 EnSob1_FacingShopkeeperDialogResult(EnSob1* this, GlobalContext* globalCtx) { - switch (globalCtx->msgCtx.choiceIndex) { +s32 EnSob1_FacingShopkeeperDialogResult(EnSob1* this, PlayState* play) { + switch (play->msgCtx.choiceIndex) { case 0: func_8019F208(); - EnSob1_TalkToShopkeeper(globalCtx, this); + EnSob1_TalkToShopkeeper(play, this); return true; case 1: func_8019F230(); if (this->shopType == BOMB_SHOP) { - EnSob1_BombShopkeeper_EndInteraction(this, globalCtx); + EnSob1_BombShopkeeper_EndInteraction(this, play); } else { - EnSob1_EndInteraction(globalCtx, this); + EnSob1_EndInteraction(play, this); } return true; } return false; } -void EnSob1_FaceShopkeeper(EnSob1* this, GlobalContext* globalCtx) { +void EnSob1_FaceShopkeeper(EnSob1* this, PlayState* play) { s32 pad[2]; - u8 talkState = Message_GetState(&globalCtx->msgCtx); - u8 cursorIdx; + u8 talkState = Message_GetState(&play->msgCtx); + u8 cursorIndex; if (this->cutsceneState == ENSOB1_CUTSCENESTATE_WAITING) { if (ActorCutscene_GetCanPlayNext(this->cutscene)) { @@ -656,16 +659,16 @@ void EnSob1_FaceShopkeeper(EnSob1* this, GlobalContext* globalCtx) { ActorCutscene_SetIntentToPlay(this->cutscene); this->cutsceneState = ENSOB1_CUTSCENESTATE_WAITING; } else { - if (talkState == 4) { - func_8011552C(globalCtx, 6); - if (!EnSob1_TestEndInteraction(this, globalCtx, CONTROLLER1(globalCtx))) { - if (!Message_ShouldAdvance(globalCtx) || !EnSob1_FacingShopkeeperDialogResult(this, globalCtx)) { + if (talkState == TEXT_STATE_CHOICE) { + func_8011552C(play, 6); + if (!EnSob1_TestEndInteraction(this, play, CONTROLLER1(&play->state))) { + if (!Message_ShouldAdvance(play) || !EnSob1_FacingShopkeeperDialogResult(this, play)) { 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); + func_8011552C(play, 6); this->stickRightPrompt.isEnabled = false; play_sound(NA_SE_SY_CURSOR); } @@ -676,13 +679,13 @@ void EnSob1_FaceShopkeeper(EnSob1* this, GlobalContext* globalCtx) { } } -void EnSob1_TalkingToShopkeeper(EnSob1* this, GlobalContext* globalCtx) { - if (Message_GetState(&globalCtx->msgCtx) == 5 && Message_ShouldAdvance(globalCtx)) { - EnSob1_StartShopping(globalCtx, this); +void EnSob1_TalkingToShopkeeper(EnSob1* this, PlayState* play) { + if ((Message_GetState(&play->msgCtx) == TEXT_STATE_5) && Message_ShouldAdvance(play)) { + EnSob1_StartShopping(play, this); } } -void EnSob1_LookToShopkeeperFromShelf(EnSob1* this, GlobalContext* globalCtx) { +void EnSob1_LookToShopkeeperFromShelf(EnSob1* this, PlayState* play) { if (this->cutsceneState == ENSOB1_CUTSCENESTATE_PLAYING) { ActorCutscene_Stop(this->cutscene); this->cutsceneState = ENSOB1_CUTSCENESTATE_STOPPED; @@ -698,45 +701,46 @@ void EnSob1_LookToShopkeeperFromShelf(EnSob1* this, GlobalContext* globalCtx) { if (ActorCutscene_GetCanPlayNext(this->cutscene)) { ActorCutscene_StartAndSetFlag(this->cutscene, &this->actor); this->cutsceneState = ENSOB1_CUTSCENESTATE_PLAYING; - EnSob1_StartShopping(globalCtx, this); + EnSob1_StartShopping(play, this); } else { ActorCutscene_SetIntentToPlay(this->cutscene); } } } -void EnSob1_EndWalk(EnSob1* this, GlobalContext* globalCtx) { +void EnSob1_EndWalk(EnSob1* this, PlayState* play) { 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_GetDistSqAndOrient(this->path, this->pathPointsIdx - 1, &this->actor.world.pos, &distSq), - 4, 1000, 1); + 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, sAnimationInfoBombShopkeeper, + BOMB_SHOPKEEPER_ANIM_SIT_AT_COUNTER_START); EnSob1_SetupAction(this, EnSob1_SetupIdle); } } Actor_MoveWithGravity(&this->actor); } -void EnSob1_SetupIdle(EnSob1* this, GlobalContext* globalCtx) { +void EnSob1_SetupIdle(EnSob1* this, PlayState* play) { 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, sAnimationInfoBombShopkeeper, BOMB_SHOPKEEPER_ANIM_SIT_AT_COUNTER_LOOP); EnSob1_SetupAction(this, EnSob1_Idle); } - EnSob1_Walking(this, globalCtx); + EnSob1_Walking(this, play); } -void EnSob1_Walk(EnSob1* this, GlobalContext* globalCtx) { +void EnSob1_Walk(EnSob1* this, PlayState* play) { s32 pad; f32 distSq; @@ -750,24 +754,24 @@ void EnSob1_Walk(EnSob1* this, GlobalContext* globalCtx) { } if (this->path != NULL) { Math_SmoothStepToS(&this->actor.world.rot.y, - EnSob1_GetDistSqAndOrient(this->path, this->pathPointsIdx, &this->actor.world.pos, &distSq), - 4, 1000, 1); + 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); } } } Actor_MoveWithGravity(&this->actor); - EnSob1_Walking(this, globalCtx); + EnSob1_Walking(this, play); } -void EnSob1_Walking(EnSob1* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); +void EnSob1_Walking(EnSob1* this, PlayState* play) { + Player* player = GET_PLAYER(play); if (this->cutsceneState == ENSOB1_CUTSCENESTATE_WAITING) { if (ActorCutscene_GetCanPlayNext(this->cutscene)) { @@ -777,7 +781,7 @@ void EnSob1_Walking(EnSob1* this, GlobalContext* globalCtx) { ActorCutscene_SetIntentToPlay(this->cutscene); } } - if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { + if (Actor_ProcessTalkRequest(&this->actor, &play->state)) { if (this->cutsceneState == ENSOB1_CUTSCENESTATE_STOPPED) { if (ActorCutscene_GetCurrentIndex() == 0x7C) { ActorCutscene_Stop(0x7C); @@ -787,21 +791,21 @@ void EnSob1_Walking(EnSob1* this, GlobalContext* globalCtx) { this->cutsceneState = ENSOB1_CUTSCENESTATE_WAITING; } player->stateFlags2 |= 0x20000000; - this->welcomeTextId = EnSob1_GetWelcome(this, globalCtx); - Message_StartTextbox(globalCtx, this->welcomeTextId, &this->actor); + this->welcomeTextId = EnSob1_GetWelcome(this, play); + Message_StartTextbox(play, this->welcomeTextId, &this->actor); this->wasTalkedToWhileWalking = true; } else { if ((player->actor.world.pos.x >= this->posXZRange.xMin && player->actor.world.pos.x <= this->posXZRange.xMax) && (player->actor.world.pos.z >= this->posXZRange.zMin && player->actor.world.pos.z <= this->posXZRange.zMax)) { - func_800B8614(&this->actor, globalCtx, 400.0f); + func_800B8614(&this->actor, play, 400.0f); } } } -void EnSob1_ItemPurchased(EnSob1* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); +void EnSob1_ItemPurchased(EnSob1* this, PlayState* play) { + Player* player = GET_PLAYER(play); if (this->cutsceneState == ENSOB1_CUTSCENESTATE_STOPPED) { if (ActorCutscene_GetCanPlayNext(this->cutscene)) { @@ -817,14 +821,14 @@ void EnSob1_ItemPurchased(EnSob1* this, GlobalContext* globalCtx) { ActorCutscene_SetIntentToPlay(this->cutscene); } } - if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { - func_80151938(globalCtx, 0x647); + if (Actor_ProcessTalkRequest(&this->actor, &play->state)) { + func_80151938(play, 0x647); } else { - func_800B85E0(&this->actor, globalCtx, 400.0f, EXCH_ITEM_MINUS1); + func_800B85E0(&this->actor, play, 400.0f, PLAYER_AP_MINUS1); } } -void EnSob1_LookToShelf(EnSob1* this, GlobalContext* globalCtx) { +void EnSob1_LookToShelf(EnSob1* this, PlayState* play) { if (this->cutsceneState == ENSOB1_CUTSCENESTATE_PLAYING) { ActorCutscene_Stop(this->cutscene); this->cutsceneState = ENSOB1_CUTSCENESTATE_STOPPED; @@ -840,47 +844,47 @@ void EnSob1_LookToShelf(EnSob1* this, GlobalContext* globalCtx) { if (ActorCutscene_GetCanPlayNext(this->cutscene) != 0) { ActorCutscene_StartAndSetFlag(this->cutscene, &this->actor); this->cutsceneState = ENSOB1_CUTSCENESTATE_PLAYING; - EnSob1_UpdateCursorPos(globalCtx, this); + EnSob1_UpdateCursorPos(play, this); EnSob1_SetupAction(this, EnSob1_BrowseShelf); - func_80151938(globalCtx, this->items[this->cursorIdx]->actor.textId); + func_80151938(play, this->items[this->cursorIndex]->actor.textId); } else { ActorCutscene_SetIntentToPlay(this->cutscene); } } } -void EnSob1_CursorLeftRight(GlobalContext* globalCtx, EnSob1* this) { - u8 curTemp = this->cursorIdx; +void EnSob1_CursorLeftRight(PlayState* play, EnSob1* this) { + u8 curTemp = this->cursorIndex; if (this->stickAccumX < 0) { if (curTemp != 2) { curTemp++; } else { - EnSob1_SetupLookToShopkeeperFromShelf(globalCtx, this); + EnSob1_SetupLookToShopkeeperFromShelf(play, 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]; +s32 EnSob1_HasPlayerSelectedItem(PlayState* play, EnSob1* this, Input* input) { + EnGirlA* item = this->items[this->cursorIndex]; - if (EnSob1_TestEndInteraction(this, globalCtx, input)) { + if (EnSob1_TestEndInteraction(this, play, input)) { return true; } - if (EnSob1_TestItemSelected(globalCtx)) { + if (EnSob1_TestItemSelected(play)) { if (!item->isOutOfStock) { - this->tmpActionFunc = this->actionFunc; - func_80151938(globalCtx, this->items[this->cursorIdx]->choiceTextId); + this->prevActionFunc = this->actionFunc; + func_80151938(play, this->items[this->cursorIndex]->choiceTextId); play_sound(NA_SE_SY_DECIDE); this->stickLeftPrompt.isEnabled = false; this->stickRightPrompt.isEnabled = false; @@ -894,11 +898,11 @@ s32 EnSob1_HasPlayerSelectedItem(GlobalContext* globalCtx, EnSob1* this, Input* return false; } -void EnSob1_BrowseShelf(EnSob1* this, GlobalContext* globalCtx) { - u8 talkState = Message_GetState(&globalCtx->msgCtx); +void EnSob1_BrowseShelf(EnSob1* this, PlayState* play) { + u8 talkState = Message_GetState(&play->msgCtx); s32 pad; - u8 prevCursorIdx = this->cursorIdx; - u8 cursorIdx; + u8 prevCursorIndex = this->cursorIndex; + u8 cursorIndex; if (!EnSob1_ReturnItemToShelf(this)) { this->delayTimer = 3; @@ -907,14 +911,14 @@ void EnSob1_BrowseShelf(EnSob1* this, GlobalContext* globalCtx) { } else { this->drawCursor = 0xFF; this->stickLeftPrompt.isEnabled = true; - EnSob1_UpdateCursorPos(globalCtx, this); - if (talkState == 5) { - func_8011552C(globalCtx, 6); - if (!EnSob1_HasPlayerSelectedItem(globalCtx, this, CONTROLLER1(globalCtx))) { - EnSob1_CursorLeftRight(globalCtx, this); - cursorIdx = this->cursorIdx; - if (cursorIdx != prevCursorIdx) { - func_80151938(globalCtx, this->items[cursorIdx]->actor.textId); + EnSob1_UpdateCursorPos(play, this); + if (talkState == TEXT_STATE_5) { + func_8011552C(play, 6); + if (!EnSob1_HasPlayerSelectedItem(play, this, CONTROLLER1(&play->state))) { + EnSob1_CursorLeftRight(play, this); + cursorIndex = this->cursorIndex; + if (cursorIndex != prevCursorIndex) { + func_80151938(play, this->items[cursorIndex]->actor.textId); play_sound(NA_SE_SY_CURSOR); } } @@ -922,152 +926,152 @@ void EnSob1_BrowseShelf(EnSob1* this, GlobalContext* globalCtx) { } } -void EnSob1_SetupBuyItemWithFanfare(GlobalContext* globalCtx, EnSob1* this) { - Player* player = GET_PLAYER(globalCtx); +void EnSob1_SetupBuyItemWithFanfare(PlayState* play, EnSob1* this) { + Player* player = GET_PLAYER(play); - Actor_PickUp(&this->actor, globalCtx, this->items[this->cursorIdx]->getItemId, 300.0f, 300.0f); - globalCtx->msgCtx.msgMode = 0x43; - globalCtx->msgCtx.unk12023 = 4; + Actor_PickUp(&this->actor, play, this->items[this->cursorIndex]->getItemId, 300.0f, 300.0f); + play->msgCtx.msgMode = 0x43; + play->msgCtx.stateTimer = 4; player->stateFlags2 &= ~0x20000000; Interface_ChangeAlpha(50); this->drawCursor = 0; EnSob1_SetupAction(this, EnSob1_BuyItemWithFanfare); } -void EnSob1_SetupCannotBuy(GlobalContext* globalCtx, EnSob1* this, u16 textId) { - func_80151938(globalCtx, textId); +void EnSob1_SetupCannotBuy(PlayState* play, EnSob1* this, u16 textId) { + func_80151938(play, textId); EnSob1_SetupAction(this, EnSob1_CannotBuy); } -void EnSob1_SetupCanBuy(GlobalContext* globalCtx, EnSob1* this, u16 textId) { - func_80151938(globalCtx, textId); +void EnSob1_SetupCanBuy(PlayState* play, EnSob1* this, u16 textId) { + func_80151938(play, textId); EnSob1_SetupAction(this, EnSob1_CanBuy); } -void EnSob1_HandleCanBuyItem(GlobalContext* globalCtx, EnSob1* this) { - EnGirlA* item = this->items[this->cursorIdx]; +void EnSob1_HandleCanBuyItem(PlayState* play, EnSob1* this) { + EnGirlA* item = this->items[this->cursorIndex]; EnGirlA* item2; - switch (item->canBuyFunc(globalCtx, item)) { + switch (item->canBuyFunc(play, item)) { case CANBUY_RESULT_SUCCESS_1: if (this->cutsceneState == ENSOB1_CUTSCENESTATE_PLAYING) { ActorCutscene_Stop(this->cutscene); this->cutsceneState = ENSOB1_CUTSCENESTATE_STOPPED; } func_8019F208(); - item2 = this->items[this->cursorIdx]; - item2->buyFanfareFunc(globalCtx, item2); - EnSob1_SetupBuyItemWithFanfare(globalCtx, this); + item2 = this->items[this->cursorIndex]; + item2->buyFanfareFunc(play, item2); + EnSob1_SetupBuyItemWithFanfare(play, this); this->drawCursor = 0; this->shopItemSelectedTween = 0.0f; - item->boughtFunc(globalCtx, item); + item->boughtFunc(play, item); break; case CANBUY_RESULT_SUCCESS_2: func_8019F208(); - item->buyFunc(globalCtx, item); + item->buyFunc(play, item); if ((this->shopType == GORON_SHOP) && (item->actor.params == SI_POTION_RED_5)) { - EnSob1_SetupCanBuy(globalCtx, this, 0xBD7); + EnSob1_SetupCanBuy(play, this, 0xBD7); } else if ((this->shopType == ZORA_SHOP) && (item->actor.params == SI_POTION_RED_4)) { - EnSob1_SetupCanBuy(globalCtx, this, 0x12E7); + EnSob1_SetupCanBuy(play, this, 0x12E7); } else if ((this->shopType == GORON_SHOP_SPRING) && (item->actor.params == SI_POTION_RED_6)) { - EnSob1_SetupCanBuy(globalCtx, this, 0xBD7); + EnSob1_SetupCanBuy(play, this, 0xBD7); } else { - EnSob1_SetupCanBuy(globalCtx, this, sBuySuccessTextIds[this->shopType]); + EnSob1_SetupCanBuy(play, this, sBuySuccessTextIds[this->shopType]); } this->drawCursor = 0; this->shopItemSelectedTween = 0.0f; - item->boughtFunc(globalCtx, item); + item->boughtFunc(play, item); break; case CANBUY_RESULT_NO_ROOM: play_sound(NA_SE_SY_ERROR); - EnSob1_SetupCannotBuy(globalCtx, this, sNoRoomTextIds[this->shopType]); + EnSob1_SetupCannotBuy(play, this, sNoRoomTextIds[this->shopType]); break; case CANBUY_RESULT_NEED_EMPTY_BOTTLE: play_sound(NA_SE_SY_ERROR); - EnSob1_SetupCannotBuy(globalCtx, this, sNeedEmptyBottleTextIds[this->shopType]); + EnSob1_SetupCannotBuy(play, this, sNeedEmptyBottleTextIds[this->shopType]); break; case CANBUY_RESULT_NEED_RUPEES: play_sound(NA_SE_SY_ERROR); - EnSob1_SetupCannotBuy(globalCtx, this, sNeedRupeesTextIds[this->shopType]); + EnSob1_SetupCannotBuy(play, this, sNeedRupeesTextIds[this->shopType]); break; case CANBUY_RESULT_CANNOT_GET_NOW: play_sound(NA_SE_SY_ERROR); - EnSob1_SetupCannotBuy(globalCtx, this, sCannotGetNowTextIds[this->shopType]); + EnSob1_SetupCannotBuy(play, this, sCannotGetNowTextIds[this->shopType]); break; case CANBUY_RESULT_CANNOT_GET_NOW_2: play_sound(NA_SE_SY_ERROR); - EnSob1_SetupCannotBuy(globalCtx, this, sCannotGetNow2TextIds[this->shopType]); + EnSob1_SetupCannotBuy(play, this, sCannotGetNow2TextIds[this->shopType]); break; case CANBUY_RESULT_NO_ROOM_2: play_sound(NA_SE_SY_ERROR); - EnSob1_SetupCannotBuy(globalCtx, this, sNoRoom2TextIds[this->shopType]); + EnSob1_SetupCannotBuy(play, this, sNoRoom2TextIds[this->shopType]); break; case CANBUY_RESULT_ALREADY_HAVE: play_sound(NA_SE_SY_ERROR); - EnSob1_SetupCannotBuy(globalCtx, this, 0x658); + EnSob1_SetupCannotBuy(play, this, 0x658); break; case CANBUY_RESULT_HAVE_BETTER: play_sound(NA_SE_SY_ERROR); - EnSob1_SetupCannotBuy(globalCtx, this, 0x659); + EnSob1_SetupCannotBuy(play, this, 0x659); break; } } -void EnSob1_SelectItem(EnSob1* this, GlobalContext* globalCtx) { - u8 talkState = Message_GetState(&globalCtx->msgCtx); +void EnSob1_SelectItem(EnSob1* this, PlayState* play) { + u8 talkState = Message_GetState(&play->msgCtx); - if (EnSob1_TakeItemOffShelf(this) && talkState == 4) { - func_8011552C(globalCtx, 6); - if (!EnSob1_TestCancelOption(this, globalCtx, CONTROLLER1(globalCtx)) && Message_ShouldAdvance(globalCtx)) { - switch (globalCtx->msgCtx.choiceIndex) { + if (EnSob1_TakeItemOffShelf(this) && (talkState == TEXT_STATE_CHOICE)) { + func_8011552C(play, 6); + if (!EnSob1_TestCancelOption(this, play, CONTROLLER1(&play->state)) && Message_ShouldAdvance(play)) { + switch (play->msgCtx.choiceIndex) { case 0: - EnSob1_HandleCanBuyItem(globalCtx, this); + EnSob1_HandleCanBuyItem(play, this); break; case 1: func_8019F230(); - this->actionFunc = this->tmpActionFunc; - func_80151938(globalCtx, this->items[this->cursorIdx]->actor.textId); + this->actionFunc = this->prevActionFunc; + func_80151938(play, this->items[this->cursorIndex]->actor.textId); break; } } } } -void EnSob1_CannotBuy(EnSob1* this, GlobalContext* globalCtx) { - if (Message_GetState(&globalCtx->msgCtx) == 5) { - if (Message_ShouldAdvance(globalCtx)) { - this->actionFunc = this->tmpActionFunc; - func_80151938(globalCtx, this->items[this->cursorIdx]->actor.textId); +void EnSob1_CannotBuy(EnSob1* this, PlayState* play) { + if (Message_GetState(&play->msgCtx) == TEXT_STATE_5) { + if (Message_ShouldAdvance(play)) { + this->actionFunc = this->prevActionFunc; + func_80151938(play, this->items[this->cursorIndex]->actor.textId); } } } -void EnSob1_CanBuy(EnSob1* this, GlobalContext* globalCtx) { +void EnSob1_CanBuy(EnSob1* this, PlayState* play) { EnGirlA* item; - if (Message_GetState(&globalCtx->msgCtx) == 5 && Message_ShouldAdvance(globalCtx)) { + if ((Message_GetState(&play->msgCtx) == TEXT_STATE_5) && Message_ShouldAdvance(play)) { this->shopItemSelectedTween = 0.0f; EnSob1_ResetItemPosition(this); - item = this->items[this->cursorIdx]; - item->restockFunc(globalCtx, item); - this->actionFunc = this->tmpActionFunc; - func_80151938(globalCtx, this->items[this->cursorIdx]->actor.textId); + item = this->items[this->cursorIndex]; + item->restockFunc(play, item); + this->actionFunc = this->prevActionFunc; + func_80151938(play, this->items[this->cursorIndex]->actor.textId); } } -void EnSob1_BuyItemWithFanfare(EnSob1* this, GlobalContext* globalCtx) { - if (Actor_HasParent(&this->actor, globalCtx)) { +void EnSob1_BuyItemWithFanfare(EnSob1* this, PlayState* play) { + if (Actor_HasParent(&this->actor, play)) { 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, play, this->items[this->cursorIndex]->getItemId, 300.0f, 300.0f); } } -void EnSob1_SetupItemPurchased(EnSob1* this, GlobalContext* globalCtx) { - if (Message_GetState(&globalCtx->msgCtx) == 6 && Message_ShouldAdvance(globalCtx)) { - globalCtx->msgCtx.msgMode = 0x43; - globalCtx->msgCtx.unk12023 = 4; +void EnSob1_SetupItemPurchased(EnSob1* this, PlayState* play) { + if ((Message_GetState(&play->msgCtx) == TEXT_STATE_DONE) && Message_ShouldAdvance(play)) { + play->msgCtx.msgMode = 0x43; + play->msgCtx.stateTimer = 4; EnSob1_SetupAction(this, EnSob1_ItemPurchased); if (this->cutsceneState == ENSOB1_CUTSCENESTATE_STOPPED) { if (ActorCutscene_GetCurrentIndex() == 0x7C) { @@ -1076,29 +1080,29 @@ void EnSob1_SetupItemPurchased(EnSob1* this, GlobalContext* globalCtx) { this->cutscene = this->lookToShopkeeperCutscene; ActorCutscene_SetIntentToPlay(this->cutscene); } - func_800B85E0(&this->actor, globalCtx, 400.0f, EXCH_ITEM_MINUS1); + func_800B85E0(&this->actor, play, 400.0f, PLAYER_AP_MINUS1); } } -void EnSob1_ContinueShopping(EnSob1* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); +void EnSob1_ContinueShopping(EnSob1* this, PlayState* play) { + Player* player = GET_PLAYER(play); EnGirlA* item; - if ((Message_GetState(&globalCtx->msgCtx) == 5) && (Message_ShouldAdvance(globalCtx))) { + if ((Message_GetState(&play->msgCtx) == TEXT_STATE_5) && Message_ShouldAdvance(play)) { EnSob1_ResetItemPosition(this); - item = this->items[this->cursorIdx]; - item->restockFunc(globalCtx, item); + item = this->items[this->cursorIndex]; + item->restockFunc(play, item); player->actor.shape.rot.y += 0x8000; player->stateFlags2 |= 0x20000000; - Message_StartTextbox(globalCtx, this->welcomeTextId, &this->actor); - EnSob1_SetupStartShopping(globalCtx, this, true); - func_800B85E0(&this->actor, globalCtx, 200.0f, EXCH_ITEM_MINUS1); + Message_StartTextbox(play, this->welcomeTextId, &this->actor); + EnSob1_SetupStartShopping(play, this, true); + func_800B85E0(&this->actor, play, 200.0f, PLAYER_AP_MINUS1); } } 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; @@ -1159,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; } } } @@ -1191,7 +1195,7 @@ void EnSob1_UpdateCursorAnim(EnSob1* this) { void EnSob1_UpdateStickDirectionPromptAnim(EnSob1* this) { f32 arrowAnimTween = this->arrowAnimTween; f32 stickAnimTween = this->stickAnimTween; - s32 maxColor = 255; // POSSIBLY FAKE + s32 maxColor = 255; //! FAKE: if (this->arrowAnimState == 0) { arrowAnimTween += 0.05f; @@ -1247,14 +1251,14 @@ void EnSob1_UpdateStickDirectionPromptAnim(EnSob1* this) { this->stickLeftPrompt.stickTexY = 95.0f; } -s16 EnSob1_GetDistSqAndOrient(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 = Lib_SegmentedToVirtual(path->points); - points = &points[pointIdx]; + points = &points[pointIndex]; diffX = points->x - pos->x; diffZ = points->z - pos->z; } else { @@ -1283,33 +1287,33 @@ 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); +void EnSob1_ChangeObject(EnSob1* this, PlayState* play) { + gSegments[0x06] = PHYSICAL_TO_VIRTUAL(play->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])) { +s32 EnSob1_AreObjectsLoaded(EnSob1* this, PlayState* play) { + if (Object_IsLoaded(&play->objectCtx, this->mainObjIndex)) { + if (this->unusedObjIndex >= 0 && !Object_IsLoaded(&play->objectCtx, this->unusedObjIndex)) { return false; } - if (this->objIndices[2] >= 0 && !Object_IsLoaded(&globalCtx->objectCtx, this->objIndices[2])) { + if (this->shopkeeperAnimObjIndex >= 0 && !Object_IsLoaded(&play->objectCtx, this->shopkeeperAnimObjIndex)) { return false; } return true; @@ -1317,42 +1321,41 @@ s32 EnSob1_AreObjectsLoaded(EnSob1* this, GlobalContext* globalCtx) { return false; } -void EnSob1_ZoraShopkeeper_Init(EnSob1* this, GlobalContext* globalCtx) { - SkelAnime_InitFlex(globalCtx, &this->skelAnime, &gZoraSkel, NULL, this->jointTable, this->morphTable, 20); - gSegments[6] = PHYSICAL_TO_VIRTUAL(globalCtx->objectCtx.status[this->objIndices[2]].segment); - Animation_Change(&this->skelAnime, &object_masterzoora_Anim_00078C, 1.0f, 0.0f, - Animation_GetLastFrame(&object_masterzoora_Anim_00078C), 0, 0.0f); +void EnSob1_ZoraShopkeeper_Init(EnSob1* this, PlayState* play) { + SkelAnime_InitFlex(play, &this->skelAnime, &gZoraSkel, NULL, this->jointTable, this->morphTable, ZORA_LIMB_MAX); + gSegments[6] = PHYSICAL_TO_VIRTUAL(play->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_GoronShopkeeper_Init(EnSob1* this, GlobalContext* globalCtx) { - SkelAnime_InitFlex(globalCtx, &this->skelAnime, &object_oF1d_map_Skel_011AC8, NULL, this->jointTable, - this->morphTable, 18); - gSegments[6] = PHYSICAL_TO_VIRTUAL(globalCtx->objectCtx.status[this->objIndices[2]].segment); - Animation_Change(&this->skelAnime, &object_mastergolon_Anim_0000FC, 1.0f, 0.0f, - Animation_GetLastFrame(&object_mastergolon_Anim_0000FC), 0, 0.0f); +void EnSob1_GoronShopkeeper_Init(EnSob1* this, PlayState* play) { + SkelAnime_InitFlex(play, &this->skelAnime, &gGoronSkel, NULL, this->jointTable, this->morphTable, GORON_LIMB_MAX); + gSegments[6] = PHYSICAL_TO_VIRTUAL(play->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_BombShopkeeper_Init(EnSob1* this, GlobalContext* globalCtx) { - SkelAnime_InitFlex(globalCtx, &this->skelAnime, &object_rs_Skel_009220, &object_rs_Anim_009120, this->jointTable, - this->morphTable, 16); +void EnSob1_BombShopkeeper_Init(EnSob1* this, PlayState* play) { + SkelAnime_InitFlex(play, &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) { +void EnSob1_InitShop(EnSob1* this, PlayState* play) { ShopItem* shopItems; EnSob1XZRange* xzRange; Vec3f* posOffset; - if (EnSob1_AreObjectsLoaded(this, globalCtx)) { + if (EnSob1_AreObjectsLoaded(this, play)) { this->actor.flags &= ~ACTOR_FLAG_10; - this->actor.objBankIndex = this->objIndices[0]; - Actor_SetObjectDependency(globalCtx, &this->actor); + this->actor.objBankIndex = this->mainObjIndex; + Actor_SetObjectDependency(play, &this->actor); posOffset = &sPosOffset[this->shopType]; this->actor.world.pos.x += posOffset->x; this->actor.world.pos.y += posOffset->y; @@ -1366,14 +1369,14 @@ void EnSob1_InitShop(EnSob1* this, GlobalContext* globalCtx) { EnSob1_GetCutscenes(this); this->cutscene = this->lookFowardCutscene; ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 20.0f); - sInitFuncs[this->shopType](this, globalCtx); + sInitFuncs[this->shopType](this, play); 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 = SubS_GetPathByIndex(globalCtx, ENSOB1_GET_PATH(&this->actor), 0x1F); + this->path = SubS_GetPathByIndex(play, ENSOB1_GET_PATH(&this->actor), 0x1F); } if (this->shopType == BOMB_SHOP) { EnSob1_SetupAction(this, EnSob1_SetupWalk); @@ -1385,7 +1388,7 @@ void EnSob1_InitShop(EnSob1* this, GlobalContext* globalCtx) { this->stickAccumY = 0; this->stickAccumX = 0; - this->cursorIdx = 0; + this->cursorIndex = 0; this->cursorPos.z = 1.2f; this->cursorColor.r = 0; this->cursorColor.g = 80; @@ -1434,7 +1437,7 @@ void EnSob1_InitShop(EnSob1* this, GlobalContext* globalCtx) { this->actor.gravity = 0.0f; this->posXZRange = sPosXZRanges[this->shopType]; Actor_SetScale(&this->actor, sActorScales[this->shopType]); - EnSob1_SpawnShopItems(this, globalCtx, shopItems); + EnSob1_SpawnShopItems(this, play, shopItems); this->headRot = this->headRotTarget = 0; this->blinkTimer = 20; this->eyeTexIndex = 0; @@ -1443,30 +1446,30 @@ void EnSob1_InitShop(EnSob1* this, GlobalContext* globalCtx) { } } -void EnSob1_Update(Actor* thisx, GlobalContext* globalCtx) { +void EnSob1_Update(Actor* thisx, PlayState* play) { EnSob1ActionFunc changeObjectFunc; EnSob1* this = THIS; if (this->actionFunc != EnSob1_InitShop) { this->blinkFunc(this); - EnSob1_UpdateJoystickInputState(globalCtx, this); + EnSob1_UpdateJoystickInputState(play, this); EnSob1_UpdateItemSelectedProperty(this); EnSob1_UpdateStickDirectionPromptAnim(this); EnSob1_UpdateCursorAnim(this); Math_StepToS(&this->headRot, this->headRotTarget, 0x190); - this->actionFunc(this, globalCtx); + this->actionFunc(this, play); Actor_SetFocus(&this->actor, 90.0f); changeObjectFunc = this->changeObjectFunc; if (changeObjectFunc != NULL) { - changeObjectFunc(this, globalCtx); + changeObjectFunc(this, play); } SkelAnime_Update(&this->skelAnime); } else { - this->actionFunc(this, globalCtx); + this->actionFunc(this, play); } } -void EnSob1_DrawCursor(GlobalContext* globalCtx, EnSob1* this, f32 x, f32 y, f32 z, u8 drawCursor) { +void EnSob1_DrawCursor(PlayState* play, EnSob1* this, f32 x, f32 y, f32 z, u8 drawCursor) { s32 ulx; s32 uly; s32 lrx; @@ -1475,9 +1478,9 @@ void EnSob1_DrawCursor(GlobalContext* globalCtx, EnSob1* this, f32 x, f32 y, f32 s32 dsdx; s32 pad; - OPEN_DISPS(globalCtx->state.gfxCtx); + OPEN_DISPS(play->state.gfxCtx); if (drawCursor != 0) { - func_8012C654(globalCtx->state.gfxCtx); + func_8012C654(play->state.gfxCtx); gDPSetPrimColor(OVERLAY_DISP++, 0, 0, this->cursorColor.r, this->cursorColor.g, this->cursorColor.b, this->cursorColor.a); gDPLoadTextureBlock_4b(OVERLAY_DISP++, gSelectionCursorTex, G_IM_FMT_IA, 16, 16, 0, G_TX_MIRROR | G_TX_WRAP, @@ -1490,10 +1493,10 @@ void EnSob1_DrawCursor(GlobalContext* globalCtx, EnSob1* this, f32 x, f32 y, f32 dsdx = (1.0f / z) * 1024.0f; gSPTextureRectangle(OVERLAY_DISP++, ulx, uly, lrx, lry, G_TX_RENDERTILE, 0, 0, dsdx, dsdx); } - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->state.gfxCtx); } -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, +void EnSob1_DrawTextRec(PlayState* play, 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; @@ -1507,7 +1510,7 @@ void EnSob1_DrawTextRec(GlobalContext* globalCtx, s32 r, s32 g, s32 b, s32 a, f3 (void)"../z_en_soB1.c"; - OPEN_DISPS(globalCtx->state.gfxCtx); + OPEN_DISPS(play->state.gfxCtx); gDPPipeSync(OVERLAY_DISP++); gDPSetPrimColor(OVERLAY_DISP++, 0, 0, r, g, b, a); @@ -1524,30 +1527,30 @@ void EnSob1_DrawTextRec(GlobalContext* globalCtx, s32 r, s32 g, s32 b, s32 a, f3 dtdy = dy * unk; gSPTextureRectangle(OVERLAY_DISP++, ulx, uly, lrx, lry, G_TX_RENDERTILE, s, t, dsdx, dtdy); - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->state.gfxCtx); } -void EnSob1_DrawStickDirectionPrompt(GlobalContext* globalCtx, EnSob1* this) { +void EnSob1_DrawStickDirectionPrompt(PlayState* play, EnSob1* this) { s32 drawStickRightPrompt = this->stickLeftPrompt.isEnabled; s32 drawStickLeftPrompt = this->stickRightPrompt.isEnabled; (void)"../z_en_soB1.c"; - OPEN_DISPS(globalCtx->state.gfxCtx); + OPEN_DISPS(play->state.gfxCtx); if (drawStickRightPrompt || drawStickLeftPrompt) { - func_8012C654(globalCtx->state.gfxCtx); + func_8012C654(play->state.gfxCtx); gDPSetCombineMode(OVERLAY_DISP++, G_CC_MODULATEIA_PRIM, G_CC_MODULATEIA_PRIM); 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, + EnSob1_DrawTextRec(play, this->stickLeftPrompt.arrowColor.r, this->stickLeftPrompt.arrowColor.g, this->stickLeftPrompt.arrowColor.b, this->stickLeftPrompt.arrowColor.a, this->stickLeftPrompt.arrowTexX, this->stickLeftPrompt.arrowTexY, this->stickLeftPrompt.texZ, 0, 0, -1.0f, 1.0f); } if (drawStickLeftPrompt) { - EnSob1_DrawTextRec(globalCtx, this->stickRightPrompt.arrowColor.r, this->stickRightPrompt.arrowColor.g, + EnSob1_DrawTextRec(play, this->stickRightPrompt.arrowColor.r, this->stickRightPrompt.arrowColor.g, this->stickRightPrompt.arrowColor.b, this->stickRightPrompt.arrowColor.a, this->stickRightPrompt.arrowTexX, this->stickRightPrompt.arrowTexY, this->stickRightPrompt.texZ, 0, 0, 1.0f, 1.0f); @@ -1556,48 +1559,47 @@ void EnSob1_DrawStickDirectionPrompt(GlobalContext* globalCtx, EnSob1* this) { 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, + EnSob1_DrawTextRec(play, this->stickLeftPrompt.stickColor.r, this->stickLeftPrompt.stickColor.g, this->stickLeftPrompt.stickColor.b, this->stickLeftPrompt.stickColor.a, this->stickLeftPrompt.stickTexX, this->stickLeftPrompt.stickTexY, this->stickLeftPrompt.texZ, 0, 0, -1.0f, 1.0f); } if (drawStickLeftPrompt) { - EnSob1_DrawTextRec(globalCtx, this->stickRightPrompt.stickColor.r, this->stickRightPrompt.stickColor.g, + EnSob1_DrawTextRec(play, this->stickRightPrompt.stickColor.r, this->stickRightPrompt.stickColor.g, this->stickRightPrompt.stickColor.b, this->stickRightPrompt.stickColor.a, this->stickRightPrompt.stickTexX, this->stickRightPrompt.stickTexY, this->stickRightPrompt.texZ, 0, 0, 1.0f, 1.0f); } } - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->state.gfxCtx); } -s32 EnSob1_ZoraShopkeeper_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, +s32 EnSob1_ZoraShopkeeper_OverrideLimbDraw(PlayState* play, 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_BombShopkeeper_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, +s32 EnSob1_BombShopkeeper_OverrideLimbDraw(PlayState* play, 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_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); +void EnSob1_BombShopkeeper_PostLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx) { + OPEN_DISPS(play->state.gfxCtx); + if (limbIndex == BOMB_SHOPKEEPER_LIMB_LEFT_HAND) { + gSPDisplayList(POLY_OPA_DISP++, gBombShopkeeperBombDL); } - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->state.gfxCtx); } Gfx* EnSob1_EndDList(GraphicsContext* gfxCtx) { @@ -1610,77 +1612,76 @@ Gfx* EnSob1_EndDList(GraphicsContext* gfxCtx) { return dList; } -void EnSob1_ZoraShopkeeper_Draw(Actor* thisx, GlobalContext* globalCtx) { +void EnSob1_ZoraShopkeeper_Draw(Actor* thisx, PlayState* play) { static TexturePtr sZoraShopkeeperEyeTextures[] = { gZoraEyeOpenTex, gZoraEyeHalfTex, gZoraEyeClosedTex }; EnSob1* this = THIS; s32 pad; s32 i; - OPEN_DISPS(globalCtx->state.gfxCtx); - func_8012C28C(globalCtx->state.gfxCtx); + OPEN_DISPS(play->state.gfxCtx); + func_8012C28C(play->state.gfxCtx); gDPSetEnvColor(POLY_OPA_DISP++, 0, 0, 0, 255); - gSPSegment(POLY_OPA_DISP++, 0x0C, EnSob1_EndDList(globalCtx->state.gfxCtx)); + gSPSegment(POLY_OPA_DISP++, 0x0C, EnSob1_EndDList(play->state.gfxCtx)); gSPSegment(POLY_OPA_DISP++, 0x08, Lib_SegmentedToVirtual(sZoraShopkeeperEyeTextures[this->eyeTexIndex])); - SkelAnime_DrawFlexOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, + SkelAnime_DrawFlexOpa(play, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, 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; this->items[i]->actor.scale.z = 0.2f; } - EnSob1_DrawCursor(globalCtx, this, this->cursorPos.x, this->cursorPos.y, this->cursorPos.z, this->drawCursor); - EnSob1_DrawStickDirectionPrompt(globalCtx, this); - CLOSE_DISPS(globalCtx->state.gfxCtx); + EnSob1_DrawCursor(play, this, this->cursorPos.x, this->cursorPos.y, this->cursorPos.z, this->drawCursor); + EnSob1_DrawStickDirectionPrompt(play, this); + CLOSE_DISPS(play->state.gfxCtx); } -void EnSob1_GoronShopkeeper_Draw(Actor* thisx, GlobalContext* globalCtx) { - static TexturePtr sGoronShopkeeperEyeTextures[] = { object_oF1d_map_Tex_010438, object_oF1d_map_Tex_010C38, - object_oF1d_map_Tex_011038 }; +void EnSob1_GoronShopkeeper_Draw(Actor* thisx, PlayState* play) { + static TexturePtr sGoronShopkeeperEyeTextures[] = { gGoronEyeOpenTex, gGoronEyeHalfTex, gGoronEyeClosedTex }; EnSob1* this = THIS; s32 pad; s32 i; - OPEN_DISPS(globalCtx->state.gfxCtx); - func_8012C28C(globalCtx->state.gfxCtx); + OPEN_DISPS(play->state.gfxCtx); + func_8012C28C(play->state.gfxCtx); gSPSegment(POLY_OPA_DISP++, 0x08, Lib_SegmentedToVirtual(sGoronShopkeeperEyeTextures[this->eyeTexIndex])); - SkelAnime_DrawFlexOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, - NULL, NULL, &this->actor); + SkelAnime_DrawFlexOpa(play, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, NULL, + 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; this->items[i]->actor.scale.z = 0.2f; } - EnSob1_DrawCursor(globalCtx, this, this->cursorPos.x, this->cursorPos.y, this->cursorPos.z, this->drawCursor); - EnSob1_DrawStickDirectionPrompt(globalCtx, this); - CLOSE_DISPS(globalCtx->state.gfxCtx); + EnSob1_DrawCursor(play, this, this->cursorPos.x, this->cursorPos.y, this->cursorPos.z, this->drawCursor); + EnSob1_DrawStickDirectionPrompt(play, this); + CLOSE_DISPS(play->state.gfxCtx); } -void EnSob1_BombShopkeeper_Draw(Actor* thisx, GlobalContext* globalCtx) { +void EnSob1_BombShopkeeper_Draw(Actor* thisx, PlayState* play) { EnSob1* this = THIS; s32 pad; u32 frames; s32 i; - OPEN_DISPS(globalCtx->state.gfxCtx); - func_8012C28C(globalCtx->state.gfxCtx); - gSPSegment(POLY_OPA_DISP++, 0x08, Lib_SegmentedToVirtual(object_rs_Tex_005458)); - SkelAnime_DrawFlexOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, + OPEN_DISPS(play->state.gfxCtx); + func_8012C28C(play->state.gfxCtx); + gSPSegment(POLY_OPA_DISP++, 0x08, Lib_SegmentedToVirtual(gBombShopkeeperEyeTex)); + SkelAnime_DrawFlexOpa(play, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, 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; this->items[i]->actor.scale.z = 0.2f; } - EnSob1_DrawCursor(globalCtx, this, this->cursorPos.x, this->cursorPos.y, this->cursorPos.z, this->drawCursor); - EnSob1_DrawStickDirectionPrompt(globalCtx, this); - frames = globalCtx->gameplayFrames; - func_8012C2DC(globalCtx->state.gfxCtx); - Matrix_NormalizeXYZ(&globalCtx->billboardMtxF); + EnSob1_DrawCursor(play, this, this->cursorPos.x, this->cursorPos.y, this->cursorPos.z, this->drawCursor); + EnSob1_DrawStickDirectionPrompt(play, this); + frames = play->gameplayFrames; + func_8012C2DC(play->state.gfxCtx); + Matrix_ReplaceRotation(&play->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); + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPSegment(POLY_XLU_DISP++, 0x08, - Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, 0, 0, 32, 64, 1, 0, -frames * 20, 32, 128)); + Gfx_TwoTexScroll(play->state.gfxCtx, 0, 0, 0, 32, 64, 1, 0, -frames * 20, 32, 128)); gDPSetPrimColor(POLY_XLU_DISP++, 128, 128, 255, 255, 0, 255); gDPSetEnvColor(POLY_XLU_DISP++, 255, 0, 0, 0); - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->state.gfxCtx); } 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..6cb615d6f 100644 --- a/src/overlays/actors/ovl_En_Sob1/z_en_sob1.h +++ b/src/overlays/actors/ovl_En_Sob1/z_en_sob1.h @@ -3,10 +3,15 @@ #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; -typedef void (*EnSob1ActionFunc)(struct EnSob1*, GlobalContext*); +typedef void (*EnSob1ActionFunc)(struct EnSob1*, PlayState*); typedef void (*EnSob1BlinkFunc)(struct EnSob1*); #define ENSOB1_GET_SHOPTYPE(thisx) ((thisx)->params & 0x1F) @@ -23,17 +28,19 @@ typedef struct EnSob1 { /* 0x000 */ Actor actor; /* 0x144 */ SkelAnime skelAnime; /* 0x188 */ EnSob1ActionFunc actionFunc; - /* 0x18C */ EnSob1ActionFunc tmpActionFunc; // Used to restore back to correct browsing function + /* 0x18C */ EnSob1ActionFunc prevActionFunc; // Used to restore back to correct browsing function /* 0x190 */ EnSob1ActionFunc changeObjectFunc; /* 0x194 */ ColliderCylinder collider; /* 0x1E0 */ Path* path; - /* 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; @@ -81,8 +88,6 @@ typedef enum { /* 2 */ ENSOB1_CUTSCENESTATE_PLAYING } EnSob1CutsceneState; -//! @TODO: Add enum for objIndices index based on what the object is for - extern const ActorInit En_Sob1_InitVars; #endif // Z_EN_SOB1_H diff --git a/src/overlays/actors/ovl_En_Ssh/z_en_ssh.c b/src/overlays/actors/ovl_En_Ssh/z_en_ssh.c index d880c4873..6e7915539 100644 --- a/src/overlays/actors/ovl_En_Ssh/z_en_ssh.c +++ b/src/overlays/actors/ovl_En_Ssh/z_en_ssh.c @@ -11,17 +11,17 @@ #define THIS ((EnSsh*)thisx) -void EnSsh_Init(Actor* thisx, GlobalContext* globalCtx); -void EnSsh_Destroy(Actor* thisx, GlobalContext* globalCtx); -void EnSsh_Update(Actor* thisx, GlobalContext* globalCtx); -void EnSsh_Draw(Actor* thisx, GlobalContext* globalCtx); +void EnSsh_Init(Actor* thisx, PlayState* play); +void EnSsh_Destroy(Actor* thisx, PlayState* play); +void EnSsh_Update(Actor* thisx, PlayState* play); +void EnSsh_Draw(Actor* thisx, PlayState* play); -void EnSsh_Wait(EnSsh* this, GlobalContext* globalCtx); -void EnSsh_Idle(EnSsh* this, GlobalContext* globalCtx); -void EnSsh_Land(EnSsh* this, GlobalContext* globalCtx); -void EnSsh_Drop(EnSsh* this, GlobalContext* globalCtx); -void EnSsh_Return(EnSsh* this, GlobalContext* globalCtx); -void EnSsh_Start(EnSsh* this, GlobalContext* globalCtx); +void EnSsh_Wait(EnSsh* this, PlayState* play); +void EnSsh_Idle(EnSsh* this, PlayState* play); +void EnSsh_Land(EnSsh* this, PlayState* play); +void EnSsh_Drop(EnSsh* this, PlayState* play); +void EnSsh_Return(EnSsh* this, PlayState* play); +void EnSsh_Start(EnSsh* this, PlayState* play); extern AnimationHeader D_06000304; @@ -102,7 +102,7 @@ static ColliderJntSphInit sJntSphInit = { OC2_TYPE_1, COLSHAPE_JNTSPH, }, - 1, + ARRAY_COUNT(sJntSphElementsInit), sJntSphElementsInit, }; @@ -110,17 +110,17 @@ void EnSsh_SetupAction(EnSsh* this, EnSshActionFunc actionFunc) { this->actionFunc = actionFunc; } -void EnSsh_SpawnShockwave(EnSsh* this, GlobalContext* globalCtx) { +void EnSsh_SpawnShockwave(EnSsh* this, PlayState* play) { Vec3f zeroVec = { 0.0f, 0.0f, 0.0f }; Vec3f pos; pos.x = this->actor.world.pos.x; pos.y = this->actor.floorHeight; pos.z = this->actor.world.pos.z; - EffectSsBlast_SpawnWhiteCustomScale(globalCtx, &pos, &zeroVec, &zeroVec, 100, 220, 8); + EffectSsBlast_SpawnWhiteCustomScale(play, &pos, &zeroVec, &zeroVec, 100, 220, 8); } -s32 EnSsh_CreateBlureEffect(GlobalContext* globalCtx) { +s32 EnSsh_CreateBlureEffect(PlayState* play) { EffectBlureInit1 blureInit; u8 sP1StartColor[4] = { 255, 255, 255, 75 }; u8 sP2StartColor[4] = { 255, 255, 255, 75 }; @@ -139,11 +139,11 @@ s32 EnSsh_CreateBlureEffect(GlobalContext* globalCtx) { blureInit.unkFlag = false; blureInit.calcMode = 3; - Effect_Add(globalCtx, &blureIdx, 1, 0, 0, &blureInit); + Effect_Add(play, &blureIdx, 1, 0, 0, &blureInit); return blureIdx; } -s32 EnSsh_CheckCeilingPos(EnSsh* this, GlobalContext* globalCtx) { +s32 EnSsh_CheckCeilingPos(EnSsh* this, PlayState* play) { CollisionPoly* poly; s32 bgId; Vec3f posB; @@ -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, false, - false, true, true, &bgId)) { + if (!BgCheck_EntityLineTest1(&play->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); } @@ -183,7 +183,7 @@ void EnSsh_AddBlureSpace(EnSsh* this) { EffectBlure_AddSpace(Effect_GetByIndex(this->blureIdx)); } -void EnSsh_InitColliders(EnSsh* this, GlobalContext* globalCtx) { +void EnSsh_InitColliders(EnSsh* this, PlayState* play) { ColliderCylinderInit* cylinders[] = { &sCylinderInit1, &sCylinderInit1, &sCylinderInit1, &sCylinderInit2, &sCylinderInit2, &sCylinderInit2, }; @@ -191,7 +191,7 @@ void EnSsh_InitColliders(EnSsh* this, GlobalContext* globalCtx) { s32 pad; for (i = 0; i < ARRAY_COUNT(this->collider1); i++) { - Collider_InitAndSetCylinder(globalCtx, &this->collider1[i], &this->actor, cylinders[i]); + Collider_InitAndSetCylinder(play, &this->collider1[i], &this->actor, cylinders[i]); } this->collider1[0].info.bumper.dmgFlags = 0x38A9; @@ -202,43 +202,44 @@ void EnSsh_InitColliders(EnSsh* this, GlobalContext* globalCtx) { this->collider1[2].info.bumper.dmgFlags = ~0x83038A9; CollisionCheck_SetInfo2(&this->actor.colChkInfo, DamageTable_Get(2), &sColChkInfoInit); - Collider_InitJntSph(globalCtx, &this->collider2); - Collider_SetJntSph(globalCtx, &this->collider2, &this->actor, &sJntSphInit, this->collider2Elements); + Collider_InitJntSph(play, &this->collider2); + Collider_SetJntSph(play, &this->collider2, &this->actor, &sJntSphInit, this->collider2Elements); } -f32 EnSsh_SetAnimation(EnSsh* this, s32 arg0) { - AnimationHeader* animation[] = { &object_ssh_Anim_006D78, &object_ssh_Anim_001494, &object_ssh_Anim_001494, - &object_ssh_Anim_006788, &object_ssh_Anim_001494, &object_ssh_Anim_001494, - &object_ssh_Anim_006D78 }; - f32 playerbackSpeed[] = { 1.0f, 4.0f, 1.0f, 1.0f, 8.0f, 6.0f, 2.0f }; - u8 mode[] = { +f32 EnSsh_ChangeAnim(EnSsh* this, s32 animIndex) { + AnimationHeader* sAnimations[] = { &object_ssh_Anim_006D78, &object_ssh_Anim_001494, &object_ssh_Anim_001494, + &object_ssh_Anim_006788, &object_ssh_Anim_001494, &object_ssh_Anim_001494, + &object_ssh_Anim_006D78 }; + f32 sPlaySpeeds[] = { 1.0f, 4.0f, 1.0f, 1.0f, 8.0f, 6.0f, 2.0f }; + u8 sAnimationModes[] = { ANIMMODE_ONCE_INTERP, ANIMMODE_ONCE_INTERP, ANIMMODE_LOOP_INTERP, ANIMMODE_ONCE_INTERP, ANIMMODE_LOOP_INTERP, ANIMMODE_LOOP_INTERP, ANIMMODE_LOOP_INTERP, }; - f32 frameCount = Animation_GetLastFrame(animation[arg0]); + f32 frameCount = Animation_GetLastFrame(sAnimations[animIndex]); s32 pad; - Animation_Change(&this->skelAnime, animation[arg0], playerbackSpeed[arg0], 0.0f, frameCount, mode[arg0], -6.0f); + Animation_Change(&this->skelAnime, sAnimations[animIndex], sPlaySpeeds[animIndex], 0.0f, frameCount, + sAnimationModes[animIndex], -6.0f); return frameCount; } void EnSsh_SetWaitAnimation(EnSsh* this) { - EnSsh_SetAnimation(this, SSH_ANIM_WAIT); + EnSsh_ChangeAnim(this, SSH_ANIM_WAIT); } void EnSsh_SetReturnAnimation(EnSsh* this) { Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_STALTU_UP); - EnSsh_SetAnimation(this, SSH_ANIM_UP); + EnSsh_ChangeAnim(this, SSH_ANIM_UP); } void EnSsh_SetLandAnimation(EnSsh* this) { this->actor.world.pos.y = this->floorHeightOffset + this->actor.floorHeight; - this->animTimer = EnSsh_SetAnimation(this, SSH_ANIM_LAND); + this->animTimer = EnSsh_ChangeAnim(this, SSH_ANIM_LAND); } void EnSsh_SetDropAnimation(EnSsh* this) { if (this->unkTimer == 0) { - this->animTimer = EnSsh_SetAnimation(this, SSH_ANIM_DROP); + this->animTimer = EnSsh_ChangeAnim(this, SSH_ANIM_DROP); } this->actor.velocity.y = -10.0f; } @@ -302,7 +303,7 @@ s32 EnSsh_Damaged(EnSsh* this) { return true; } -void EnSsh_Turn(EnSsh* this, GlobalContext* globalCtx) { +void EnSsh_Turn(EnSsh* this, PlayState* play) { if (this->hitTimer != 0) { this->hitTimer--; } @@ -315,7 +316,7 @@ void EnSsh_Turn(EnSsh* this, GlobalContext* globalCtx) { this->actor.shape.rot.y = this->actor.world.rot.y; } -void EnSsh_Stunned(EnSsh* this, GlobalContext* globalCtx) { +void EnSsh_Stunned(EnSsh* this, PlayState* play) { if ((this->swayTimer == 0) && (this->stunTimer == 0)) { Math_SmoothStepToS(&this->actor.world.rot.y, this->actor.yawTowardsPlayer ^ 0x8000, 4, this->maxTurnRate, 1); } @@ -331,25 +332,25 @@ void EnSsh_Stunned(EnSsh* this, GlobalContext* globalCtx) { } } -void EnSsh_UpdateYaw(EnSsh* this, GlobalContext* globalCtx) { +void EnSsh_UpdateYaw(EnSsh* this, PlayState* play) { if (this->stunTimer != 0) { - EnSsh_Stunned(this, globalCtx); + EnSsh_Stunned(this, play); } else { - EnSsh_Turn(this, globalCtx); + EnSsh_Turn(this, play); } } -void EnSsh_Bob(EnSsh* this, GlobalContext* globalCtx) { +void EnSsh_Bob(EnSsh* this, PlayState* play) { f32 bobVel = 0.5f; - if (globalCtx->state.frames & 8) { + if (play->state.frames & 8) { bobVel *= -1.0f; } Math_SmoothStepToF(&this->actor.velocity.y, bobVel, 0.4f, 1000.0f, 0.0f); } -s32 EnSsh_IsCloseToLink(EnSsh* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); +s32 EnSsh_IsCloseToLink(EnSsh* this, PlayState* play) { + Player* player = GET_PLAYER(play); f32 yDist; if (this->stateFlags & SSH_STATE_GROUND_START) { @@ -425,11 +426,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; @@ -437,8 +438,8 @@ void EnSsh_Sway(EnSsh* this) { } } -void EnSsh_CheckBodyStickHit(EnSsh* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); +void EnSsh_CheckBodyStickHit(EnSsh* this, PlayState* play) { + Player* player = GET_PLAYER(play); ColliderInfo* colliderInfo = &this->collider1[0].info; if (player->unk_B28 != 0) { @@ -452,7 +453,7 @@ void EnSsh_CheckBodyStickHit(EnSsh* this, GlobalContext* globalCtx) { } } -s32 EnSsh_CheckHitPlayer(EnSsh* this, GlobalContext* globalCtx) { +s32 EnSsh_CheckHitPlayer(EnSsh* this, PlayState* play) { s32 i; s32 hit = false; @@ -479,9 +480,9 @@ s32 EnSsh_CheckHitPlayer(EnSsh* this, GlobalContext* globalCtx) { Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_STALTU_ROLL); Actor_PlaySfxAtPos(&this->actor, NA_SE_VO_ST_ATTACK); - globalCtx->damagePlayer(globalCtx, -8); + play->damagePlayer(play, -8); - func_800B8D98(globalCtx, &this->actor, 4.0f, this->actor.yawTowardsPlayer, 6.0f); + func_800B8D98(play, &this->actor, 4.0f, this->actor.yawTowardsPlayer, 6.0f); this->hitCount--; return true; } @@ -506,7 +507,7 @@ s32 EnSsh_CheckHitFront(EnSsh* this) { return true; } -s32 EnSsh_CheckHitBack(EnSsh* this, GlobalContext* globalCtx) { +s32 EnSsh_CheckHitBack(EnSsh* this, PlayState* play) { ColliderCylinder* collider = &this->collider1[0]; s32 hit = false; @@ -540,16 +541,16 @@ s32 EnSsh_CheckHitBack(EnSsh* this, GlobalContext* globalCtx) { return false; } -s32 EnSsh_CollisionCheck(EnSsh* this, GlobalContext* globalCtx) { +s32 EnSsh_CollisionCheck(EnSsh* this, PlayState* play) { if (this->stunTimer == 0) { - EnSsh_CheckHitPlayer(this, globalCtx); + EnSsh_CheckHitPlayer(this, play); } if (EnSsh_CheckHitFront(this)) { return false; } - if (globalCtx->actorCtx.unk2 != 0) { + if (play->actorCtx.unk2 != 0) { this->invincibilityTimer = 8; if (this->stunTimer == 0) { Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_COMMON_FREEZE); @@ -560,27 +561,27 @@ s32 EnSsh_CollisionCheck(EnSsh* this, GlobalContext* globalCtx) { return false; } - return EnSsh_CheckHitBack(this, globalCtx); + return EnSsh_CheckHitBack(this, play); } -void EnSsh_SetBodyCylinderAC(EnSsh* this, GlobalContext* globalCtx) { +void EnSsh_SetBodyCylinderAC(EnSsh* this, PlayState* play) { Collider_UpdateCylinder(&this->actor, &this->collider1[0]); - CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->collider1[0].base); + CollisionCheck_SetAC(play, &play->colChkCtx, &this->collider1[0].base); } -void EnSsh_SetLegsCylinderAC(EnSsh* this, GlobalContext* globalCtx) { +void EnSsh_SetLegsCylinderAC(EnSsh* this, PlayState* play) { s16 angleTowardsLink = ABS_ALT((s16)(this->actor.yawTowardsPlayer - this->actor.shape.rot.y)); if (angleTowardsLink < (90 * (0x10000 / 360))) { Collider_UpdateCylinder(&this->actor, &this->collider1[2]); - CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->collider1[2].base); + CollisionCheck_SetAC(play, &play->colChkCtx, &this->collider1[2].base); } else { Collider_UpdateCylinder(&this->actor, &this->collider1[1]); - CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->collider1[1].base); + CollisionCheck_SetAC(play, &play->colChkCtx, &this->collider1[1].base); } } -s32 EnSsh_SetCylinderOC(EnSsh* this, GlobalContext* globalCtx) { +s32 EnSsh_SetCylinderOC(EnSsh* this, PlayState* play) { Vec3f colliderOffsets[] = { { 40.0f, 0.0f, 0.0f }, { 0.0f, 0.0f, 0.0f }, { -40.0f, 0.0f, 0.0f } }; Vec3f colliderPos; s32 i; @@ -592,53 +593,53 @@ 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; this->collider1[3 + i].dim.pos.z = colliderPos.z; - CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider1[3 + i].base); + CollisionCheck_SetOC(play, &play->colChkCtx, &this->collider1[3 + i].base); } return true; } -void EnSsh_SetColliders(EnSsh* this, GlobalContext* globalCtx) { +void EnSsh_SetColliders(EnSsh* this, PlayState* play) { if (this->actor.colChkInfo.health == 0) { - CollisionCheck_SetAT(globalCtx, &globalCtx->colChkCtx, &this->collider2.base); - CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider2.base); + CollisionCheck_SetAT(play, &play->colChkCtx, &this->collider2.base); + CollisionCheck_SetOC(play, &play->colChkCtx, &this->collider2.base); return; } if (this->hitTimer == 0) { - EnSsh_SetCylinderOC(this, globalCtx); + EnSsh_SetCylinderOC(this, play); } if (DECR(this->invincibilityTimer) == 0) { - EnSsh_SetBodyCylinderAC(this, globalCtx); - EnSsh_SetLegsCylinderAC(this, globalCtx); + EnSsh_SetBodyCylinderAC(this, play); + EnSsh_SetLegsCylinderAC(this, play); } } -void EnSsh_Init(Actor* thisx, GlobalContext* globalCtx) { +void EnSsh_Init(Actor* thisx, PlayState* play) { // @bug - this symbol no longer exists, reads from a random place in object_ssh_Tex_000190 instead f32 frameCount = Animation_GetLastFrame(&D_06000304); s32 pad; EnSsh* this = THIS; ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 30.0f); - SkelAnime_Init(globalCtx, &this->skelAnime, &object_ssh_Skel_006470, NULL, this->jointTable, this->morphtable, 30); + SkelAnime_Init(play, &this->skelAnime, &object_ssh_Skel_006470, NULL, this->jointTable, this->morphtable, 30); Animation_Change(&this->skelAnime, &object_ssh_Anim_001494, 1.0f, 0.0f, frameCount, ANIMMODE_LOOP_INTERP, 0.0f); - this->blureIdx = EnSsh_CreateBlureEffect(globalCtx); - EnSsh_InitColliders(this, globalCtx); + this->blureIdx = EnSsh_CreateBlureEffect(play); + EnSsh_InitColliders(this, play); this->stateFlags = 0; this->hitCount = 0; - EnSsh_CheckCeilingPos(this, globalCtx); + EnSsh_CheckCeilingPos(this, play); if (!ENSSH_IS_CHILD(&this->actor)) { this->stateFlags |= SSH_STATE_FATHER; @@ -653,38 +654,38 @@ void EnSsh_Init(Actor* thisx, GlobalContext* globalCtx) { this->actor.gravity = 0.0f; this->initialYaw = this->actor.world.rot.y; EnSsh_SetupAction(this, EnSsh_Start); - if (Inventory_GetSkullTokenCount(globalCtx->sceneNum) >= 30) { + if (Inventory_GetSkullTokenCount(play->sceneNum) >= 30) { Actor_MarkForDeath(&this->actor); } } -void EnSsh_Destroy(Actor* thisx, GlobalContext* globalCtx) { +void EnSsh_Destroy(Actor* thisx, PlayState* play) { EnSsh* this = THIS; s32 i; - Effect_Destroy(globalCtx, this->blureIdx); + Effect_Destroy(play, this->blureIdx); for (i = 0; i < ARRAY_COUNT(this->collider1); i++) { - Collider_DestroyCylinder(globalCtx, &this->collider1[i]); + Collider_DestroyCylinder(play, &this->collider1[i]); } - Collider_DestroyJntSph(globalCtx, &this->collider2); + Collider_DestroyJntSph(play, &this->collider2); } -void EnSsh_Wait(EnSsh* this, GlobalContext* globalCtx) { - if (EnSsh_IsCloseToLink(this, globalCtx)) { +void EnSsh_Wait(EnSsh* this, PlayState* play) { + if (EnSsh_IsCloseToLink(this, play)) { EnSsh_SetDropAnimation(this); EnSsh_SetupAction(this, EnSsh_Drop); } else { - EnSsh_Bob(this, globalCtx); + EnSsh_Bob(this, play); } } -void EnSsh_Talk(EnSsh* this, GlobalContext* globalCtx) { - EnSsh_Bob(this, globalCtx); +void EnSsh_Talk(EnSsh* this, PlayState* play) { + EnSsh_Bob(this, play); - if ((Message_GetState(&globalCtx->msgCtx) == 5) && Message_ShouldAdvance(globalCtx)) { - switch (globalCtx->msgCtx.currentTextId) { + if ((Message_GetState(&play->msgCtx) == TEXT_STATE_5) && Message_ShouldAdvance(play)) { + switch (play->msgCtx.currentTextId) { case 0x904: case 0x905: case 0x906: @@ -693,18 +694,18 @@ void EnSsh_Talk(EnSsh* this, GlobalContext* globalCtx) { case 0x911: case 0x912: case 0x914: - func_80151938(globalCtx, globalCtx->msgCtx.currentTextId + 1); + func_80151938(play, play->msgCtx.currentTextId + 1); break; default: - func_801477B4(globalCtx); + func_801477B4(play); this->actionFunc = EnSsh_Idle; break; } } } -void func_809756D0(EnSsh* this, GlobalContext* globalCtx) { +void func_809756D0(EnSsh* this, PlayState* play) { u16 phi_a1; if (gSaveContext.save.weekEventReg[34] & 8) { @@ -713,25 +714,25 @@ void func_809756D0(EnSsh* this, GlobalContext* globalCtx) { phi_a1 = 0x910; gSaveContext.save.weekEventReg[34] |= 8; } - Message_StartTextbox(globalCtx, phi_a1, &this->actor); + Message_StartTextbox(play, phi_a1, &this->actor); } -void EnSsh_Idle(EnSsh* this, GlobalContext* globalCtx) { - if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { +void EnSsh_Idle(EnSsh* this, PlayState* play) { + if (Actor_ProcessTalkRequest(&this->actor, &play->state)) { this->actionFunc = EnSsh_Talk; - func_809756D0(this, globalCtx); + func_809756D0(this, play); return; } if ((this->unkTimer != 0) && (DECR(this->unkTimer) == 0)) { - EnSsh_SetAnimation(this, SSH_ANIM_WAIT); + EnSsh_ChangeAnim(this, SSH_ANIM_WAIT); } if ((this->animTimer != 0) && (DECR(this->animTimer) == 0)) { - EnSsh_SetAnimation(this, SSH_ANIM_WAIT); + EnSsh_ChangeAnim(this, SSH_ANIM_WAIT); } - if (!EnSsh_IsCloseToLink(this, globalCtx)) { + if (!EnSsh_IsCloseToLink(this, play)) { EnSsh_SetReturnAnimation(this); EnSsh_SetupAction(this, EnSsh_Return); return; @@ -742,21 +743,21 @@ void EnSsh_Idle(EnSsh* this, GlobalContext* globalCtx) { this->sfxTimer = 64; } - EnSsh_Bob(this, globalCtx); + EnSsh_Bob(this, play); if ((this->unkTimer == 0) && (this->animTimer == 0) && (this->actor.xzDistToPlayer < 100.0f) && - Player_IsFacingActor(&this->actor, 0x3000, globalCtx)) { - func_800B8614(&this->actor, globalCtx, 100.0f); + Player_IsFacingActor(&this->actor, 0x3000, play)) { + func_800B8614(&this->actor, play, 100.0f); } } -void EnSsh_Land(EnSsh* this, GlobalContext* globalCtx) { +void EnSsh_Land(EnSsh* this, PlayState* play) { if ((this->unkTimer != 0) && (DECR(this->unkTimer) == 0)) { - EnSsh_SetAnimation(this, SSH_ANIM_WAIT); + EnSsh_ChangeAnim(this, SSH_ANIM_WAIT); } if ((this->animTimer != 0) && (DECR(this->animTimer) == 0)) { - EnSsh_SetAnimation(this, SSH_ANIM_WAIT); + EnSsh_ChangeAnim(this, SSH_ANIM_WAIT); } if ((this->actor.floorHeight + this->floorHeightOffset) <= this->actor.world.pos.y) { @@ -766,16 +767,16 @@ void EnSsh_Land(EnSsh* this, GlobalContext* globalCtx) { } } -void EnSsh_Drop(EnSsh* this, GlobalContext* globalCtx) { +void EnSsh_Drop(EnSsh* this, PlayState* play) { if ((this->unkTimer != 0) && (DECR(this->unkTimer) == 0)) { - EnSsh_SetAnimation(this, SSH_ANIM_DROP); + EnSsh_ChangeAnim(this, SSH_ANIM_DROP); } - if (!EnSsh_IsCloseToLink(this, globalCtx)) { + if (!EnSsh_IsCloseToLink(this, play)) { EnSsh_SetReturnAnimation(this); EnSsh_SetupAction(this, EnSsh_Return); } else if (EnSsh_IsCloseToGround(this)) { - EnSsh_SpawnShockwave(this, globalCtx); + EnSsh_SpawnShockwave(this, play); EnSsh_SetLandAnimation(this); EnSsh_SetupAction(this, EnSsh_Land); } else if (DECR(this->sfxTimer) == 0) { @@ -784,14 +785,14 @@ void EnSsh_Drop(EnSsh* this, GlobalContext* globalCtx) { } } -void EnSsh_Return(EnSsh* this, GlobalContext* globalCtx) { +void EnSsh_Return(EnSsh* this, PlayState* play) { f32 frameRatio = this->skelAnime.curFrame / (this->skelAnime.animLength - 1.0f); if (frameRatio == 1.0f) { EnSsh_SetReturnAnimation(this); } - if (EnSsh_IsCloseToLink(this, globalCtx)) { + if (EnSsh_IsCloseToLink(this, play)) { EnSsh_SetDropAnimation(this); EnSsh_SetupAction(this, EnSsh_Drop); } else if (EnSsh_IsCloseToHome(this)) { @@ -822,24 +823,24 @@ void EnSsh_UpdateColliderScale(EnSsh* this) { } } -void EnSsh_Start(EnSsh* this, GlobalContext* globalCtx) { +void EnSsh_Start(EnSsh* this, PlayState* play) { if (!EnSsh_IsCloseToGround(this)) { EnSsh_SetupAction(this, EnSsh_Wait); - EnSsh_Wait(this, globalCtx); + EnSsh_Wait(this, play); } else { EnSsh_SetLandAnimation(this); this->stateFlags |= SSH_STATE_GROUND_START; EnSsh_SetupAction(this, EnSsh_Land); - EnSsh_Land(this, globalCtx); + EnSsh_Land(this, play); } } -void EnSsh_Update(Actor* thisx, GlobalContext* globalCtx) { +void EnSsh_Update(Actor* thisx, PlayState* play) { EnSsh* this = THIS; EnSsh_UpdateColliderScale(this); - if (EnSsh_CollisionCheck(this, globalCtx)) { + if (EnSsh_CollisionCheck(this, play)) { return; } @@ -848,11 +849,11 @@ void EnSsh_Update(Actor* thisx, GlobalContext* globalCtx) { } else { SkelAnime_Update(&this->skelAnime); Actor_UpdatePos(&this->actor); - Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 0.0f, 0.0f, 0.0f, 4); - this->actionFunc(this, globalCtx); + Actor_UpdateBgCheckInfo(play, &this->actor, 0.0f, 0.0f, 0.0f, 4); + this->actionFunc(this, play); } - EnSsh_UpdateYaw(this, globalCtx); + EnSsh_UpdateYaw(this, play); if (DECR(this->blinkTimer) == 0) { this->blinkTimer = Rand_S16Offset(60, 60); @@ -863,11 +864,11 @@ void EnSsh_Update(Actor* thisx, GlobalContext* globalCtx) { this->blinkState = 0; } - EnSsh_SetColliders(this, globalCtx); + EnSsh_SetColliders(this, play); Actor_SetFocus(&this->actor, 0.0f); } -s32 EnSsh_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, Actor* thisx) { +s32 EnSsh_OverrideLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, Actor* thisx) { EnSsh* this = THIS; switch (limbIndex) { @@ -902,35 +903,35 @@ s32 EnSsh_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, return false; } -void EnSsh_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx) { +void EnSsh_PostLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx) { EnSsh* this = THIS; if ((limbIndex == 5) && (this->stateFlags & SSH_STATE_FATHER)) { - OPEN_DISPS(globalCtx->state.gfxCtx); + OPEN_DISPS(play->state.gfxCtx); gSPDisplayList(POLY_OPA_DISP++, object_ssh_DL_0000D8); - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->state.gfxCtx); } Collider_UpdateSpheres(limbIndex, &this->collider2); } -void EnSsh_Draw(Actor* thisx, GlobalContext* globalCtx) { +void EnSsh_Draw(Actor* thisx, PlayState* play) { static TexturePtr D_80976178[] = { object_ssh_Tex_001970, object_ssh_Tex_001DF0, object_ssh_Tex_0021F0 }; s32 pad; EnSsh* this = THIS; - EnSsh_CheckBodyStickHit(this, globalCtx); + EnSsh_CheckBodyStickHit(this, play); EnSsh_Sway(this); - OPEN_DISPS(globalCtx->state.gfxCtx); + OPEN_DISPS(play->state.gfxCtx); - func_8012C28C(globalCtx->state.gfxCtx); + func_8012C28C(play->state.gfxCtx); gSPSegment(POLY_OPA_DISP++, 0x08, SEGMENTED_TO_VIRTUAL(D_80976178[this->blinkState])); - SkelAnime_DrawOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, EnSsh_OverrideLimbDraw, + SkelAnime_DrawOpa(play, this->skelAnime.skeleton, this->skelAnime.jointTable, EnSsh_OverrideLimbDraw, EnSsh_PostLimbDraw, &this->actor); - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->state.gfxCtx); } diff --git a/src/overlays/actors/ovl_En_Ssh/z_en_ssh.h b/src/overlays/actors/ovl_En_Ssh/z_en_ssh.h index 172ecf0a5..72a82e692 100644 --- a/src/overlays/actors/ovl_En_Ssh/z_en_ssh.h +++ b/src/overlays/actors/ovl_En_Ssh/z_en_ssh.h @@ -5,7 +5,7 @@ struct EnSsh; -typedef void (*EnSshActionFunc)(struct EnSsh*, GlobalContext*); +typedef void (*EnSshActionFunc)(struct EnSsh*, PlayState*); #define SSH_STATE_STUNNED (1 << 0) #define SSH_STATE_GROUND_START (1 << 2) @@ -14,46 +14,46 @@ typedef void (*EnSshActionFunc)(struct EnSsh*, GlobalContext*); #define SSH_STATE_FATHER (1 << 5) typedef enum { - SSH_ANIM_UNK0, // Unused animation. Possibly being knocked back? - SSH_ANIM_UP, - SSH_ANIM_WAIT, - SSH_ANIM_LAND, - SSH_ANIM_DROP, - SSH_ANIM_UNK5, // Slower version of ANIM_DROP - SSH_ANIM_UNK6 // Faster repeating version of ANIM_UNK0 + /* 0x0 */ SSH_ANIM_UNK0, // Unused animation. Possibly being knocked back? + /* 0x1 */ SSH_ANIM_UP, + /* 0x2 */ SSH_ANIM_WAIT, + /* 0x3 */ SSH_ANIM_LAND, + /* 0x4 */ SSH_ANIM_DROP, + /* 0x5 */ SSH_ANIM_UNK5, // Slower version of ANIM_DROP + /* 0x6 */ SSH_ANIM_UNK6 // Faster repeating version of ANIM_UNK0 } EnSshAnimation; #define ENSSH_IS_CHILD(thisx) ((thisx)->params & 0xF) typedef struct EnSsh { - /* 0x0000 */ Actor actor; - /* 0x0144 */ SkelAnime skelAnime; - /* 0x0188 */ Vec3s jointTable[30]; - /* 0x023C */ Vec3s morphtable[30]; - /* 0x02F0 */ EnSshActionFunc actionFunc; - /* 0x02F4 */ ColliderCylinder collider1[6]; - /* 0x04BC */ ColliderJntSph collider2; - /* 0x04DC */ ColliderJntSphElement collider2Elements[1]; - /* 0x051C */ s16 initialYaw; - /* 0x051E */ s16 maxTurnRate; - /* 0x0520 */ s16 unkTimer; - /* 0x0522 */ s16 spinTimer; - /* 0x0524 */ s16 hitTimer; - /* 0x0526 */ s16 invincibilityTimer; - /* 0x0528 */ s16 sfxTimer; - /* 0x052A */ s16 stunTimer; - /* 0x052C */ s16 animTimer; - /* 0x052E */ s16 swayTimer; - /* 0x0530 */ s32 blureIdx; - /* 0x0534 */ f32 colliderScale; - /* 0x0538 */ f32 floorHeightOffset; - /* 0x053C */ Vec3f ceilingPos; - /* 0x0548 */ UNK_TYPE1 unk_548[0x78]; - /* 0x05C0 */ s16 swayAngle; - /* 0x05C2 */ u16 stateFlags; - /* 0x05C4 */ u8 hitCount; - /* 0x05C6 */ s16 blinkState; - /* 0x05C8 */ s16 blinkTimer; + /* 0x000 */ Actor actor; + /* 0x144 */ SkelAnime skelAnime; + /* 0x188 */ Vec3s jointTable[30]; + /* 0x23C */ Vec3s morphtable[30]; + /* 0x2F0 */ EnSshActionFunc actionFunc; + /* 0x2F4 */ ColliderCylinder collider1[6]; + /* 0x4BC */ ColliderJntSph collider2; + /* 0x4DC */ ColliderJntSphElement collider2Elements[1]; + /* 0x51C */ s16 initialYaw; + /* 0x51E */ s16 maxTurnRate; + /* 0x520 */ s16 unkTimer; + /* 0x522 */ s16 spinTimer; + /* 0x524 */ s16 hitTimer; + /* 0x526 */ s16 invincibilityTimer; + /* 0x528 */ s16 sfxTimer; + /* 0x52A */ s16 stunTimer; + /* 0x52C */ s16 animTimer; + /* 0x52E */ s16 swayTimer; + /* 0x530 */ s32 blureIdx; + /* 0x534 */ f32 colliderScale; + /* 0x538 */ f32 floorHeightOffset; + /* 0x53C */ Vec3f ceilingPos; + /* 0x548 */ UNK_TYPE1 unk_548[0x78]; + /* 0x5C0 */ s16 swayAngle; + /* 0x5C2 */ u16 stateFlags; + /* 0x5C4 */ u8 hitCount; + /* 0x5C6 */ s16 blinkState; + /* 0x5C8 */ s16 blinkTimer; } EnSsh; // size = 0x5CC extern const ActorInit En_Ssh_InitVars; diff --git a/src/overlays/actors/ovl_En_St/z_en_st.c b/src/overlays/actors/ovl_En_St/z_en_st.c index a50bf92b4..b3c353f1f 100644 --- a/src/overlays/actors/ovl_En_St/z_en_st.c +++ b/src/overlays/actors/ovl_En_St/z_en_st.c @@ -12,16 +12,16 @@ #define THIS ((EnSt*)thisx) -void EnSt_Init(Actor* thisx, GlobalContext* globalCtx); -void EnSt_Destroy(Actor* thisx, GlobalContext* globalCtx); -void EnSt_Update(Actor* thisx, GlobalContext* globalCtx); +void EnSt_Init(Actor* thisx, PlayState* play); +void EnSt_Destroy(Actor* thisx, PlayState* play); +void EnSt_Update(Actor* thisx, PlayState* play); -void func_808A6A78(EnSt* this, GlobalContext* globalCtx); -void func_808A6C04(EnSt* this, GlobalContext* globalCtx); -void func_808A6D84(EnSt* this, GlobalContext* globalCtx); -void func_808A6E24(EnSt* this, GlobalContext* globalCtx); -void func_808A701C(EnSt* this, GlobalContext* globalCtx); -void func_808A7478(Actor* thisx, GlobalContext* globalCtx); +void func_808A6A78(EnSt* this, PlayState* play); +void func_808A6C04(EnSt* this, PlayState* play); +void func_808A6D84(EnSt* this, PlayState* play); +void func_808A6E24(EnSt* this, PlayState* play); +void func_808A701C(EnSt* this, PlayState* play); +void func_808A7478(Actor* thisx, PlayState* play); const ActorInit En_St_InitVars = { ACTOR_EN_ST, @@ -152,7 +152,7 @@ static DamageTable sDamageTable = { /* Powder Keg */ DMG_ENTRY(1, 0x0), }; -static AnimationInfoS sAnimations[] = { +static AnimationInfoS sAnimationInfo[] = { { &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 }, @@ -163,7 +163,7 @@ static AnimationInfoS sAnimations[] = { { &object_st_Anim_005B98, 2.0f, 0, -1, ANIMMODE_LOOP, -4 }, }; -void func_808A5050(EnSt* this, GlobalContext* globalCtx) { +void func_808A5050(EnSt* this, PlayState* play) { static Color_RGBA8 D_808A770C = { 170, 130, 90, 255 }; static Color_RGBA8 D_808A7710 = { 100, 60, 20, 0 }; s32 i; @@ -191,16 +191,16 @@ void func_808A5050(EnSt* this, GlobalContext* globalCtx) { spA0.x = this->actor.world.pos.x + (2.0f * spB8.x); spA0.z = this->actor.world.pos.z + (2.0f * spB8.z); - func_800B0EB0(globalCtx, &spA0, &spB8, &spAC, &D_808A770C, &D_808A7710, 100, 40, rand); + func_800B0EB0(play, &spA0, &spB8, &spAC, &D_808A770C, &D_808A7710, 100, 40, rand); } spA0.x = this->actor.world.pos.x; spA0.z = this->actor.world.pos.z; spA0.y = this->actor.floorHeight; - EffectSsBlast_SpawnWhiteCustomScale(globalCtx, &spA0, &gZeroVec3f, &gZeroVec3f, 100, 220, 8); + EffectSsBlast_SpawnWhiteCustomScale(play, &spA0, &gZeroVec3f, &gZeroVec3f, 100, 220, 8); } -void func_808A52A8(EnSt* this, GlobalContext* globalCtx) { +void func_808A52A8(EnSt* this, PlayState* play) { static Color_RGBA8 D_808A7714 = { 170, 130, 90, 255 }; static Color_RGBA8 D_808A7718 = { 100, 60, 20, 0 }; s32 pad; @@ -231,30 +231,28 @@ void func_808A52A8(EnSt* this, GlobalContext* globalCtx) { spA0.x = this->actor.world.pos.x + (2.0f * spB8.x); spA0.z = this->actor.world.pos.z + (2.0f * spB8.z); - func_800B0EB0(globalCtx, &spA0, &spB8, &spAC, &D_808A7714, &D_808A7718, 100, 40, rand); + func_800B0EB0(play, &spA0, &spB8, &spAC, &D_808A7714, &D_808A7718, 100, 40, rand); } } -void func_808A54B0(EnSt* this, GlobalContext* globalCtx) { +void func_808A54B0(EnSt* this, PlayState* play) { s32 pad; f32 temp_f0; if ((this->unk_18C & 1) && (this->actor.colChkInfo.health != 0)) { - OPEN_DISPS(globalCtx->state.gfxCtx); + OPEN_DISPS(play->state.gfxCtx); - gSegments[6] = PHYSICAL_TO_VIRTUAL2(globalCtx->objectCtx.status[this->unk_2C0].segment); + gSegments[6] = VIRTUAL_TO_PHYSICAL(play->objectCtx.status[this->unk_2C0].segment); - gSPSegment(POLY_XLU_DISP++, 0x06, globalCtx->objectCtx.status[this->unk_2C0].segment); + gSPSegment(POLY_XLU_DISP++, 0x06, play->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); + func_8012C2DC(play->state.gfxCtx); + 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); - gSPSegment(POLY_XLU_DISP++, 0x08, - Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, 195, 0, 0x40, 0x20, 1, 215, 0, 8, 8)); + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPSegment(POLY_XLU_DISP++, 0x08, Gfx_TwoTexScroll(play->state.gfxCtx, 0, 195, 0, 0x40, 0x20, 1, 215, 0, 8, 8)); temp_f0 = (f32)this->unk_310 / 8; if (temp_f0 > 1.0f) { @@ -265,7 +263,7 @@ void func_808A54B0(EnSt* this, GlobalContext* globalCtx) { gSPDisplayList(POLY_XLU_DISP++, gameplay_keep_DL_025850); gSPDisplayList(POLY_XLU_DISP++, gameplay_keep_DL_025970); - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->state.gfxCtx); } } @@ -296,7 +294,7 @@ s32 func_808A576C(EnSt* this) { return false; } -s32 func_808A5988(EnSt* this, GlobalContext* globalCtx, s32 arg2) { +s32 func_808A5988(EnSt* this, PlayState* play, s32 arg2) { s32 ret = false; u8 drawDmgEffType; Vec3f limbPos[1]; @@ -320,7 +318,7 @@ s32 func_808A5988(EnSt* this, GlobalContext* globalCtx, s32 arg2) { } drawDmgEffAlpha = 1.0f; } - Actor_DrawDamageEffects(globalCtx, &this->actor, limbPos, ARRAY_COUNT(limbPos), 0.6f, + Actor_DrawDamageEffects(play, &this->actor, limbPos, ARRAY_COUNT(limbPos), 0.6f, this->drawDmgEffFrozenSteamScales[arg2], drawDmgEffAlpha, drawDmgEffType); ret = true; } @@ -328,7 +326,7 @@ s32 func_808A5988(EnSt* this, GlobalContext* globalCtx, s32 arg2) { return ret; } -void func_808A5AF8(EnSt* this, GlobalContext* globalCtx) { +void func_808A5AF8(EnSt* this, PlayState* play) { Vec3f sp54; s32 i; @@ -339,7 +337,7 @@ void func_808A5AF8(EnSt* this, GlobalContext* globalCtx) { sp54.z += this->unk_358[i].z; Math_Vec3f_Copy(&this->unk_358[i], &sp54); } - Actor_SpawnIceEffects(globalCtx, &this->actor, this->unk_358, 12, 3, 0.1f, 0.3f); + Actor_SpawnIceEffects(play, &this->actor, this->unk_358, 12, 3, 0.1f, 0.3f); } s16 func_808A5BEC(EnSt* this) { @@ -413,11 +411,11 @@ void func_808A5DCC(EnSt* this, Color_RGB8* colour) { colour->b = 0; } -s32 func_808A5F28(EnSt* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); +s32 func_808A5F28(EnSt* this, PlayState* play) { + Player* player = GET_PLAYER(play); s32 ret = false; - if (Player_GetMask(globalCtx) == PLAYER_MASK_STONE) { + if (Player_GetMask(play) == PLAYER_MASK_STONE) { if (this->unk_2C8 <= 0.0f) { return false; } @@ -449,7 +447,7 @@ s32 func_808A6064(EnSt* this) { } void func_808A60E0(EnSt* this) { - s32 idx = (this->unk_2C8 > 0.0f) ? 2 : 6; + s32 animIndex = (this->unk_2C8 > 0.0f) ? 2 : 6; f32 sp20 = (this->unk_2C8 > 0.0f) ? 4.0f : 9.0f; f32 sp1C; u16 sfxId = (this->unk_2C8 < 0.0f) ? NA_SE_EN_STALTU_DOWN : NA_SE_EN_STALTU_UP; @@ -457,7 +455,7 @@ void func_808A60E0(EnSt* this) { sp1C = this->skelAnime.curFrame / (this->skelAnime.animLength - 1.0f); if (sp1C == 1.0f) { - SubS_ChangeAnimationByInfoS(&this->skelAnime, sAnimations, idx); + SubS_ChangeAnimationByInfoS(&this->skelAnime, sAnimationInfo, animIndex); Actor_PlaySfxAtPos(&this->actor, sfxId); } @@ -477,7 +475,7 @@ s32 func_808A61F4(EnSt* this) { return this->actor.colChkInfo.health; } -void func_808A6220(EnSt* this, GlobalContext* globalCtx) { +void func_808A6220(EnSt* this, PlayState* play) { s32 pad; if ((DECR(this->unk_314) == 0) && (this->actor.colChkInfo.health != 0)) { @@ -485,11 +483,11 @@ void func_808A6220(EnSt* this, GlobalContext* globalCtx) { Collider_UpdateCylinder(&this->actor, &this->collider3); Collider_UpdateCylinder(&this->actor, &this->collider4); if ((s16)ABS_ALT(BINANG_SUB(this->actor.yawTowardsPlayer, this->actor.shape.rot.y)) < 0x4E00) { - CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->collider3.base); + CollisionCheck_SetAC(play, &play->colChkCtx, &this->collider3.base); } else { - CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->collider2.base); + CollisionCheck_SetAC(play, &play->colChkCtx, &this->collider2.base); } - CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->collider4.base); + CollisionCheck_SetAC(play, &play->colChkCtx, &this->collider4.base); } if (this->actor.colChkInfo.health != 0) { @@ -503,13 +501,13 @@ void func_808A6220(EnSt* this, GlobalContext* globalCtx) { this->collider1.dim.radius = 18; this->collider1.dim.height = 48; } - CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider1.base); - CollisionCheck_SetAT(globalCtx, &globalCtx->colChkCtx, &this->collider1.base); + CollisionCheck_SetOC(play, &play->colChkCtx, &this->collider1.base); + CollisionCheck_SetAT(play, &play->colChkCtx, &this->collider1.base); } } void func_808A63E8(EnSt* this) { - SubS_ChangeAnimationByInfoS(&this->skelAnime, sAnimations, 3); + SubS_ChangeAnimationByInfoS(&this->skelAnime, sAnimationInfo, 3); this->unk_2C8 = 1.0f; func_808A5D7C(this); this->unk_30C = 0; @@ -520,9 +518,9 @@ void func_808A63E8(EnSt* this) { this->unk_2C4 = 1.0f; } -void func_808A6468(EnSt* this, GlobalContext* globalCtx) { - func_808A5050(this, globalCtx); - SubS_ChangeAnimationByInfoS(&this->skelAnime, sAnimations, 4); +void func_808A6468(EnSt* this, PlayState* play) { + func_808A5050(this, play); + SubS_ChangeAnimationByInfoS(&this->skelAnime, sAnimationInfo, 4); this->unk_18C |= (0x8 | 0x4); this->unk_18C &= ~(0x10 | 0x2); this->unk_2C8 = -1.0f; @@ -537,9 +535,9 @@ void func_808A6468(EnSt* this, GlobalContext* globalCtx) { } void func_808A650C(EnSt* this) { - s32 idx = (this->unk_2C8 > 0.0f) ? 2 : 6; + s32 animIndex = (this->unk_2C8 > 0.0f) ? 2 : 6; - SubS_ChangeAnimationByInfoS(&this->skelAnime, sAnimations, idx); + SubS_ChangeAnimationByInfoS(&this->skelAnime, sAnimationInfo, animIndex); this->unk_2CC = 0.0f; this->unk_2D4 = 0.0f; this->unk_2D8 = 0.0f; @@ -547,8 +545,8 @@ void func_808A650C(EnSt* this) { this->unk_18C |= 0x10; } -s32 func_808A6580(EnSt* this, GlobalContext* globalCtx) { - Player* sp3C = GET_PLAYER(globalCtx); +s32 func_808A6580(EnSt* this, PlayState* play) { + Player* sp3C = GET_PLAYER(play); s32 ret = false; s32 i; @@ -566,8 +564,8 @@ s32 func_808A6580(EnSt* this, GlobalContext* globalCtx) { } if (this->actor.colChkInfo.damageEffect == 4) { - Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_CLEAR_TAG, this->actor.world.pos.x, - this->actor.world.pos.y, this->actor.world.pos.z, 0, 0, 0, CLEAR_TAG_LARGE_LIGHT_RAYS); + Actor_Spawn(&play->actorCtx, play, ACTOR_EN_CLEAR_TAG, this->actor.world.pos.x, this->actor.world.pos.y, + this->actor.world.pos.z, 0, 0, 0, CLEAR_TAG_LARGE_LIGHT_RAYS); } this->collider3.base.acFlags &= ~AC_HIT; } @@ -576,8 +574,8 @@ s32 func_808A6580(EnSt* this, GlobalContext* globalCtx) { this->collider2.base.acFlags &= ~AC_HIT; this->collider4.base.acFlags &= ~AC_HIT; if (this->actor.colChkInfo.damageEffect == 4) { - Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_CLEAR_TAG, this->actor.world.pos.x, - this->actor.world.pos.y, this->actor.world.pos.z, 0, 0, 0, CLEAR_TAG_LARGE_LIGHT_RAYS); + Actor_Spawn(&play->actorCtx, play, ACTOR_EN_CLEAR_TAG, this->actor.world.pos.x, this->actor.world.pos.y, + this->actor.world.pos.z, 0, 0, 0, CLEAR_TAG_LARGE_LIGHT_RAYS); } if (this->drawDmgEffType == ACTOR_DRAW_DMGEFF_FROZEN_NO_SFX) { @@ -606,7 +604,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); - SubS_ChangeAnimationByInfoS(&this->skelAnime, sAnimations, 1); + SubS_ChangeAnimationByInfoS(&this->skelAnime, sAnimationInfo, 1); this->unk_18C |= 8; this->actionFunc = func_808A6D84; this->unk_2C8 = -1.0f; @@ -614,10 +612,10 @@ s32 func_808A6580(EnSt* this, GlobalContext* globalCtx) { } } else { if (ENST_GET_3F(&this->actor) != ENST_3F_63) { - Flags_SetSwitch(globalCtx, ENST_GET_3F(&this->actor)); + Flags_SetSwitch(play, ENST_GET_3F(&this->actor)); } - SoundSource_PlaySfxAtFixedWorldPos(globalCtx, &this->actor.world.pos, 40, NA_SE_EN_STALTU_DEAD); - Enemy_StartFinishingBlow(globalCtx, &this->actor); + SoundSource_PlaySfxAtFixedWorldPos(play, &this->actor.world.pos, 40, NA_SE_EN_STALTU_DEAD); + Enemy_StartFinishingBlow(play, &this->actor); this->actor.flags &= ~ACTOR_FLAG_1; @@ -647,7 +645,7 @@ s32 func_808A6580(EnSt* this, GlobalContext* globalCtx) { } if (this->drawDmgEffType != ACTOR_DRAW_DMGEFF_FROZEN_NO_SFX) { - SubS_ChangeAnimationByInfoS(&this->skelAnime, sAnimations, 7); + SubS_ChangeAnimationByInfoS(&this->skelAnime, sAnimationInfo, 7); this->unk_2CC = 0.0f; this->unk_2D4 = 0.0f; this->actor.gravity = -1.0f; @@ -664,9 +662,9 @@ s32 func_808A6580(EnSt* this, GlobalContext* globalCtx) { if ((this->collider1.base.ocFlags2 & OC2_HIT_PLAYER) || (this->collider1.base.atFlags & AT_HIT)) { if ((this->unk_316 == 0) && (this->unk_314 == 0) && (this->unk_312 == 0) && !(this->collider1.base.atFlags & AT_BOUNCED) && (this->actor.colChkInfo.health != 0)) { - globalCtx->damagePlayer(globalCtx, -8); + play->damagePlayer(play, -8); Actor_PlaySfxAtPos(&sp3C->actor, NA_SE_PL_BODY_HIT); - func_800B8D98(globalCtx, &this->actor, 4.0f, this->actor.yawTowardsPlayer, 6.0f); + func_800B8D98(play, &this->actor, 4.0f, this->actor.yawTowardsPlayer, 6.0f); this->unk_316 = 10; this->unk_18C |= 1; this->unk_30E = 0; @@ -686,19 +684,18 @@ s32 func_808A6A3C(EnSt* this) { return ret; } -void func_808A6A78(EnSt* this, GlobalContext* globalCtx) { +void func_808A6A78(EnSt* this, PlayState* play) { s32 pad[2]; - if (Object_IsLoaded(&globalCtx->objectCtx, this->unk_2C0)) { + if (Object_IsLoaded(&play->objectCtx, this->unk_2C0)) { ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 8.0f); - SkelAnime_Init(globalCtx, &this->skelAnime, &object_st_Skel_005298, NULL, this->jointTable, this->morphTable, - 30); - SubS_ChangeAnimationByInfoS(&this->skelAnime, sAnimations, 0); + SkelAnime_Init(play, &this->skelAnime, &object_st_Skel_005298, NULL, this->jointTable, this->morphTable, 30); + SubS_ChangeAnimationByInfoS(&this->skelAnime, sAnimationInfo, 0); - Collider_InitAndSetCylinder(globalCtx, &this->collider1, &this->actor, &sCylinderInit1); - Collider_InitAndSetCylinder(globalCtx, &this->collider2, &this->actor, &sCylinderInit2); - Collider_InitAndSetCylinder(globalCtx, &this->collider3, &this->actor, &sCylinderInit3); - Collider_InitAndSetCylinder(globalCtx, &this->collider4, &this->actor, &sCylinderInit4); + Collider_InitAndSetCylinder(play, &this->collider1, &this->actor, &sCylinderInit1); + Collider_InitAndSetCylinder(play, &this->collider2, &this->actor, &sCylinderInit2); + Collider_InitAndSetCylinder(play, &this->collider3, &this->actor, &sCylinderInit3); + Collider_InitAndSetCylinder(play, &this->collider4, &this->actor, &sCylinderInit4); CollisionCheck_SetInfo2(&this->actor.colChkInfo, &sDamageTable, &sColChkInfoInit); if (ENST_GET_1C0(&this->actor) == ENST_1C0_1) { @@ -716,7 +713,7 @@ void func_808A6A78(EnSt* this, GlobalContext* globalCtx) { } } -void func_808A6C04(EnSt* this, GlobalContext* globalCtx) { +void func_808A6C04(EnSt* this, PlayState* play) { this->unk_2CC = Math_SinS(this->unk_30C) * this->unk_2C4; this->unk_30C += 0xE00; Math_ApproachF(&this->unk_2C4, 1.0f, 0.1f, 0.3f); @@ -724,9 +721,9 @@ void func_808A6C04(EnSt* this, GlobalContext* globalCtx) { Actor_MoveWithGravity(&this->actor); if ((this->unk_18C & 8) && Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) { - SubS_ChangeAnimationByInfoS(&this->skelAnime, sAnimations, 3); + SubS_ChangeAnimationByInfoS(&this->skelAnime, sAnimationInfo, 3); this->unk_18C &= ~8; - } else if ((this->unk_310 == 0) && func_808A5F28(this, globalCtx) && !func_808A6064(this)) { + } else if ((this->unk_310 == 0) && func_808A5F28(this, play) && !func_808A6064(this)) { func_808A650C(this); this->actionFunc = func_808A6D84; } else { @@ -739,13 +736,13 @@ void func_808A6C04(EnSt* this, GlobalContext* globalCtx) { } } -void func_808A6D84(EnSt* this, GlobalContext* globalCtx) { +void func_808A6D84(EnSt* this, PlayState* play) { func_808A60E0(this); this->actor.velocity.y = this->unk_2D4 + this->unk_2CC; Actor_MoveWithGravity(&this->actor); if (func_808A6064(this)) { if (this->unk_2C8 < 0.0f) { - func_808A6468(this, globalCtx); + func_808A6468(this, play); } else { func_808A63E8(this); } @@ -754,7 +751,7 @@ void func_808A6D84(EnSt* this, GlobalContext* globalCtx) { func_808A5CCC(this); } -void func_808A6E24(EnSt* this, GlobalContext* globalCtx) { +void func_808A6E24(EnSt* this, PlayState* play) { s32 i; s32 count = 0; @@ -766,12 +763,12 @@ void func_808A6E24(EnSt* this, GlobalContext* globalCtx) { } if (count == ARRAY_COUNT(this->unk_31C)) { - SubS_ChangeAnimationByInfoS(&this->skelAnime, sAnimations, 7); + SubS_ChangeAnimationByInfoS(&this->skelAnime, sAnimationInfo, 7); this->drawDmgEffType = ACTOR_DRAW_DMGEFF_BLUE_FIRE; this->unk_2CC = 0.0f; this->unk_2D4 = 0.0f; this->actor.gravity = -1.0f; - func_808A5AF8(this, globalCtx); + func_808A5AF8(this, play); } } else if (this->unk_18C & 0x80) { this->actionFunc = func_808A701C; @@ -794,7 +791,7 @@ void func_808A6E24(EnSt* this, GlobalContext* globalCtx) { } if ((s32)this->actor.velocity.y >= 2) { - func_808A52A8(this, globalCtx); + func_808A52A8(this, play); } } else { Math_ApproachF(&this->actor.shape.yOffset, 400.0f, 0.3f, 1000.0f); @@ -808,7 +805,7 @@ void func_808A6E24(EnSt* this, GlobalContext* globalCtx) { } } -void func_808A701C(EnSt* this, GlobalContext* globalCtx) { +void func_808A701C(EnSt* this, PlayState* play) { s32 i; s32 count = 0; @@ -824,7 +821,7 @@ void func_808A701C(EnSt* this, GlobalContext* globalCtx) { } if (count == ARRAY_COUNT(this->unk_31C)) { - Item_DropCollectibleRandom(globalCtx, NULL, &this->actor.world.pos, 0); + Item_DropCollectibleRandom(play, NULL, &this->actor.world.pos, 0); Actor_MarkForDeath(&this->actor); } } else if (DECR(this->unk_318) == 0) { @@ -836,11 +833,11 @@ void func_808A701C(EnSt* this, GlobalContext* globalCtx) { } } -void EnSt_Init(Actor* thisx, GlobalContext* globalCtx) { +void EnSt_Init(Actor* thisx, PlayState* play) { EnSt* this = THIS; - this->unk_2C0 = Object_GetIndex(&globalCtx->objectCtx, GAMEPLAY_KEEP); - if (((ENST_GET_3F(&this->actor) != ENST_3F_63) && Flags_GetSwitch(globalCtx, ENST_GET_3F(&this->actor))) || + this->unk_2C0 = Object_GetIndex(&play->objectCtx, GAMEPLAY_KEEP); + if (((ENST_GET_3F(&this->actor) != ENST_3F_63) && Flags_GetSwitch(play, ENST_GET_3F(&this->actor))) || (this->unk_2C0 < 0)) { Actor_MarkForDeath(&this->actor); } else { @@ -848,16 +845,16 @@ void EnSt_Init(Actor* thisx, GlobalContext* globalCtx) { } } -void EnSt_Destroy(Actor* thisx, GlobalContext* globalCtx) { +void EnSt_Destroy(Actor* thisx, PlayState* play) { EnSt* this = THIS; - Collider_DestroyCylinder(globalCtx, &this->collider1); - Collider_DestroyCylinder(globalCtx, &this->collider2); - Collider_DestroyCylinder(globalCtx, &this->collider3); - Collider_DestroyCylinder(globalCtx, &this->collider4); + Collider_DestroyCylinder(play, &this->collider1); + Collider_DestroyCylinder(play, &this->collider2); + Collider_DestroyCylinder(play, &this->collider3); + Collider_DestroyCylinder(play, &this->collider4); } -void EnSt_Update(Actor* thisx, GlobalContext* globalCtx) { +void EnSt_Update(Actor* thisx, PlayState* play) { EnSt* this = THIS; if (this->actor.flags & ACTOR_FLAG_8000) { @@ -870,14 +867,14 @@ void EnSt_Update(Actor* thisx, GlobalContext* globalCtx) { this->actor.flags |= ACTOR_FLAG_80; } - if (func_808A6580(this, globalCtx)) { + if (func_808A6580(this, play)) { this->actionFunc = func_808A6E24; } else if (DECR(this->unk_312) == 0) { - this->actionFunc(this, globalCtx); + this->actionFunc(this, play); 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); + Actor_UpdateBgCheckInfo(play, &this->actor, 30.0f, 12.0f, 0.0f, 5); } else if (this->unk_312 < 20) { s16 idx = (this->unk_312 % 2) ? -1 : 1; @@ -897,10 +894,10 @@ void EnSt_Update(Actor* thisx, GlobalContext* globalCtx) { } Actor_SetFocus(&this->actor, 0.0f); - func_808A6220(this, globalCtx); + func_808A6220(this, play); } -s32 EnSt_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, Actor* thisx, +s32 EnSt_OverrideLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, Actor* thisx, Gfx** gfx) { EnSt* this = THIS; Color_RGB8 sp20; @@ -914,34 +911,34 @@ s32 EnSt_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, return false; } -void func_808A7478(Actor* thisx, GlobalContext* globalCtx) { +void func_808A7478(Actor* thisx, PlayState* play) { EnSt* this = THIS; s32 i; s32 count; if (!(this->unk_18C & 0x20)) { - OPEN_DISPS(globalCtx->state.gfxCtx); + OPEN_DISPS(play->state.gfxCtx); if (func_808A6A3C(this)) { - func_8012C2DC(globalCtx->state.gfxCtx); - POLY_XLU_DISP = SkelAnime_Draw(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, + func_8012C2DC(play->state.gfxCtx); + POLY_XLU_DISP = SkelAnime_Draw(play, this->skelAnime.skeleton, this->skelAnime.jointTable, EnSt_OverrideLimbDraw, NULL, &this->actor, POLY_XLU_DISP); } else { - func_8012C28C(globalCtx->state.gfxCtx); - POLY_OPA_DISP = SkelAnime_Draw(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, + func_8012C28C(play->state.gfxCtx); + POLY_OPA_DISP = SkelAnime_Draw(play, this->skelAnime.skeleton, this->skelAnime.jointTable, EnSt_OverrideLimbDraw, NULL, &this->actor, POLY_OPA_DISP); } - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->state.gfxCtx); } for (i = 0, count = 0; i < ARRAY_COUNT(this->unk_31C); i++) { - count += func_808A5988(this, globalCtx, i); + count += func_808A5988(this, play, i); } if (count != 0) { this->unk_31A += 2; } - func_808A54B0(this, globalCtx); + func_808A54B0(this, play); } 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 f3a827515..d5ca31f2c 100644 --- a/src/overlays/actors/ovl_En_St/z_en_st.h +++ b/src/overlays/actors/ovl_En_St/z_en_st.h @@ -5,7 +5,7 @@ struct EnSt; -typedef void (*EnStActionFunc)(struct EnSt*, GlobalContext*); +typedef void (*EnStActionFunc)(struct EnSt*, PlayState*); #define ENST_GET_3F(thisx) (((thisx)->params & 0x3F) & 0xFF) #define ENST_GET_1C0(thisx) ((((thisx)->params & 0x1C0) >> 6) & 0xFF) 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 82e314d60..77c40d173 100644 --- a/src/overlays/actors/ovl_En_Sth/z_en_sth.c +++ b/src/overlays/actors/ovl_En_Sth/z_en_sth.c @@ -13,19 +13,19 @@ #define THIS ((EnSth*)thisx) -void EnSth_Init(Actor* thisx, GlobalContext* globalCtx); -void EnSth_Destroy(Actor* thisx, GlobalContext* globalCtx); -void EnSth_Update(Actor* thisx, GlobalContext* globalCtx); +void EnSth_Init(Actor* thisx, PlayState* play); +void EnSth_Destroy(Actor* thisx, PlayState* play); +void EnSth_Update(Actor* thisx, PlayState* play); -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); +void func_80B67208(EnSth* this, PlayState* play); +void func_80B67540(EnSth* this, PlayState* play); +void func_80B677BC(EnSth* this, PlayState* play); +void func_80B678A8(EnSth* this, PlayState* play); +void func_80B67958(EnSth* this, PlayState* play); +void func_80B67C1C(EnSth* this, PlayState* play); +void func_80B67DA0(EnSth* this, PlayState* play); +void func_80B680A8(Actor* thisx, PlayState* play); +void func_80B6849C(Actor* thisx, PlayState* play); const ActorInit En_Sth_InitVars = { ACTOR_EN_STH, @@ -78,21 +78,21 @@ Color_RGB8 D_80B6D20C[] = { { 190, 110, 0 }, { 0, 180, 110 }, { 0, 255, 0x50 }, { 255, 160, 60 }, { 190, 230, 250 }, { 240, 230, 120 }, }; -void EnSth_Init(Actor* thisx, GlobalContext* globalCtx) { +void EnSth_Init(Actor* thisx, PlayState* play) { s32 pad; EnSth* this = THIS; s32 objectId; if (ENSTH_GET_100(&this->actor)) { - objectId = Object_GetIndex(&globalCtx->objectCtx, OBJECT_AHG); + objectId = Object_GetIndex(&play->objectCtx, OBJECT_AHG); } else { - objectId = Object_GetIndex(&globalCtx->objectCtx, OBJECT_STH); + objectId = Object_GetIndex(&play->objectCtx, OBJECT_STH); } this->unk_29E = objectId; - this->unk_29F = Object_GetIndex(&globalCtx->objectCtx, OBJECT_MASK_TRUTH); + this->unk_29F = Object_GetIndex(&play->objectCtx, OBJECT_MASK_TRUTH); Actor_SetScale(&this->actor, 0.01f); - Collider_InitAndSetCylinder(globalCtx, &this->collider, &this->actor, &sCylinderInit); + Collider_InitAndSetCylinder(play, &this->collider, &this->actor, &sCylinderInit); this->actor.colChkInfo.mass = MASS_IMMOVABLE; ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 36.0f); @@ -103,7 +103,7 @@ void EnSth_Init(Actor* thisx, GlobalContext* globalCtx) { switch (ENSTH_GET_F(&this->actor)) { case ENSTH_F_1: - if (globalCtx->actorCtx.unk5 & 2) { + if (play->actorCtx.unk5 & 2) { this->actor.flags |= (ACTOR_FLAG_10 | ACTOR_FLAG_20); this->actionFunc = func_80B67958; } else { @@ -113,7 +113,7 @@ void EnSth_Init(Actor* thisx, GlobalContext* globalCtx) { break; case ENSTH_F_2: - if (Inventory_GetSkullTokenCount(globalCtx->sceneNum) >= 30) { + if (Inventory_GetSkullTokenCount(play->sceneNum) >= 30) { this->actionFunc = func_80B67DA0; } else { Actor_MarkForDeath(&this->actor); @@ -148,8 +148,7 @@ void EnSth_Init(Actor* thisx, GlobalContext* globalCtx) { break; case ENSTH_F_5: - if (!(gSaveContext.save.weekEventReg[13] & 0x20) || - (Inventory_GetSkullTokenCount(globalCtx->sceneNum) < 30)) { + if (!(gSaveContext.save.weekEventReg[13] & 0x20) || (Inventory_GetSkullTokenCount(play->sceneNum) < 30)) { Actor_MarkForDeath(&this->actor); return; } @@ -164,14 +163,14 @@ void EnSth_Init(Actor* thisx, GlobalContext* globalCtx) { } } -void EnSth_Destroy(Actor* thisx, GlobalContext* globalCtx) { +void EnSth_Destroy(Actor* thisx, PlayState* play) { EnSth* this = THIS; - Collider_DestroyCylinder(globalCtx, &this->collider); + Collider_DestroyCylinder(play, &this->collider); } -s32 func_80B6703C(EnSth* this, GlobalContext* globalCtx) { - if ((this->actor.xzDistToPlayer < 100.0f) && Player_IsFacingActor(&this->actor, 0x3000, globalCtx) && +s32 func_80B6703C(EnSth* this, PlayState* play) { + if ((this->actor.xzDistToPlayer < 100.0f) && Player_IsFacingActor(&this->actor, 0x3000, play) && Actor_IsFacingPlayer(&this->actor, 0x2000)) { return true; } @@ -180,13 +179,13 @@ s32 func_80B6703C(EnSth* this, GlobalContext* globalCtx) { void func_80B670A4(EnSth* this, s16 arg1) { if ((arg1 >= 0) && (arg1 < ARRAY_COUNT(D_80B6D1C8)) && (arg1 != this->unk_29A)) { - Animation_Change(&this->skelAnime, D_80B6D1C8[arg1], 1.0f, 0.0f, Animation_GetLastFrame(D_80B6D1C8[arg1]), 0, - -5.0f); + Animation_Change(&this->skelAnime, D_80B6D1C8[arg1], 1.0f, 0.0f, Animation_GetLastFrame(D_80B6D1C8[arg1]), + ANIMMODE_LOOP, -5.0f); this->unk_29A = arg1; } } -void func_80B67148(EnSth* this, GlobalContext* globalCtx) { +void func_80B67148(EnSth* this, PlayState* play) { s32 day = CURRENT_DAY - 1; u16 val; @@ -195,30 +194,30 @@ void func_80B67148(EnSth* this, GlobalContext* globalCtx) { } val = D_80B6D1E8[day]; - Message_StartTextbox(globalCtx, val, &this->actor); + Message_StartTextbox(play, val, &this->actor); } -void func_80B671A0(EnSth* this, GlobalContext* globalCtx) { +void func_80B671A0(EnSth* this, PlayState* play) { SkelAnime_Update(&this->skelAnime); - if ((Message_GetState(&globalCtx->msgCtx) == 5) && Message_ShouldAdvance(globalCtx)) { + if ((Message_GetState(&play->msgCtx) == TEXT_STATE_5) && Message_ShouldAdvance(play)) { this->actionFunc = func_80B67208; - func_801477B4(globalCtx); + func_801477B4(play); } } -void func_80B67208(EnSth* this, GlobalContext* globalCtx) { +void func_80B67208(EnSth* this, PlayState* play) { SkelAnime_Update(&this->skelAnime); - if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { - func_80B67148(this, globalCtx); + if (Actor_ProcessTalkRequest(&this->actor, &play->state)) { + func_80B67148(this, play); this->actionFunc = func_80B671A0; - } else if ((this->actor.xzDistToPlayer < 100.0f) && Player_IsFacingActor(&this->actor, 0x3000, globalCtx)) { - func_800B8614(&this->actor, globalCtx, 110.0f); + } else if ((this->actor.xzDistToPlayer < 100.0f) && Player_IsFacingActor(&this->actor, 0x3000, play)) { + func_800B8614(&this->actor, play, 110.0f); } } -void func_80B672A4(EnSth* this, GlobalContext* globalCtx) { +void func_80B672A4(EnSth* this, PlayState* play) { u16 sp1E; s32 day = CURRENT_DAY - 1; @@ -236,15 +235,15 @@ void func_80B672A4(EnSth* this, GlobalContext* globalCtx) { } else { sp1E = D_80B6D1F8[day]; } - Message_StartTextbox(globalCtx, sp1E, &this->actor); + Message_StartTextbox(play, sp1E, &this->actor); } -void func_80B67348(EnSth* this, GlobalContext* globalCtx) { +void func_80B67348(EnSth* this, PlayState* play) { u16 phi_a1; SkelAnime_Update(&this->skelAnime); - if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { + if (Actor_ProcessTalkRequest(&this->actor, &play->state)) { this->actor.flags &= ~ACTOR_FLAG_10000; this->actionFunc = func_80B67540; @@ -274,31 +273,31 @@ void func_80B67348(EnSth* this, GlobalContext* globalCtx) { } break; } - Message_StartTextbox(globalCtx, phi_a1, &this->actor); + Message_StartTextbox(play, phi_a1, &this->actor); } else { - func_800B8500(&this->actor, globalCtx, 1000.0f, 1000.0f, -1); + func_800B8500(&this->actor, play, 1000.0f, 1000.0f, PLAYER_AP_MINUS1); } } -void func_80B67458(EnSth* this, GlobalContext* globalCtx) { +void func_80B67458(EnSth* this, PlayState* play) { SkelAnime_Update(&this->skelAnime); - if (Actor_HasParent(&this->actor, globalCtx)) { + if (Actor_HasParent(&this->actor, play)) { this->actor.parent = NULL; this->actionFunc = func_80B67348; this->actor.flags |= ACTOR_FLAG_10000; - func_800B8500(&this->actor, globalCtx, 1000.0f, 1000.0f, -1); + func_800B8500(&this->actor, play, 1000.0f, 1000.0f, PLAYER_AP_MINUS1); 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); + Actor_PickUp(&this->actor, play, this->actor.home.rot.z, 10000.0f, 500.0f); } } -void func_80B67540(EnSth* this, GlobalContext* globalCtx) { +void func_80B67540(EnSth* this, PlayState* play) { s32 sp2C = CURRENT_DAY - 1; if (sp2C < 0) { @@ -312,22 +311,22 @@ void func_80B67540(EnSth* this, GlobalContext* globalCtx) { SkelAnime_Update(&this->skelAnime); - switch (Message_GetState(&globalCtx->msgCtx)) { - case 5: - if (Message_ShouldAdvance(globalCtx)) { - switch (globalCtx->msgCtx.currentTextId) { + switch (Message_GetState(&play->msgCtx)) { + case TEXT_STATE_5: + if (Message_ShouldAdvance(play)) { + switch (play->msgCtx.currentTextId) { case 0x1134: - func_80151938(globalCtx, globalCtx->msgCtx.currentTextId + 1); + func_80151938(play, play->msgCtx.currentTextId + 1); break; case 0x1132: case 0x113A: case 0x113F: - func_80151938(globalCtx, 0x1133); + func_80151938(play, 0x1133); break; case 0x1133: - func_80151938(globalCtx, 0x1136); + func_80151938(play, 0x1136); func_80B670A4(this, 6); break; @@ -360,78 +359,78 @@ void func_80B67540(EnSth* this, GlobalContext* globalCtx) { this->actor.home.rot.z = 4; break; } - func_801477B4(globalCtx); + func_801477B4(play); this->actionFunc = func_80B67458; - func_80B67458(this, globalCtx); + func_80B67458(this, play); break; case 0x113C: - func_80151938(globalCtx, 0x113B); + func_80151938(play, 0x113B); break; case 0x1141: - func_80151938(globalCtx, 0x1140); + func_80151938(play, 0x1140); func_80B670A4(this, 3); break; default: this->actionFunc = func_80B677BC; - func_801477B4(globalCtx); + func_801477B4(play); this->unk_29C |= 2; break; } } break; - case 2: + case TEXT_STATE_CLOSING: this->actionFunc = func_80B677BC; this->unk_29C |= 2; break; } } -void func_80B677BC(EnSth* this, GlobalContext* globalCtx) { +void func_80B677BC(EnSth* this, PlayState* play) { SkelAnime_Update(&this->skelAnime); - if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { - func_80B672A4(this, globalCtx); + if (Actor_ProcessTalkRequest(&this->actor, &play->state)) { + func_80B672A4(this, play); this->actionFunc = func_80B67540; - } else if (func_80B6703C(this, globalCtx)) { - func_800B8614(&this->actor, globalCtx, 110.0f); + } else if (func_80B6703C(this, play)) { + func_800B8614(&this->actor, play, 110.0f); } } -void func_80B67838(EnSth* this, GlobalContext* globalCtx) { +void func_80B67838(EnSth* this, PlayState* play) { SkelAnime_Update(&this->skelAnime); - if ((Message_GetState(&globalCtx->msgCtx) == 5) && Message_ShouldAdvance(globalCtx)) { + if ((Message_GetState(&play->msgCtx) == TEXT_STATE_5) && Message_ShouldAdvance(play)) { this->actionFunc = func_80B678A8; - func_801477B4(globalCtx); + func_801477B4(play); } this->unk_294.x = -0x1388; } -void func_80B678A8(EnSth* this, GlobalContext* globalCtx) { +void func_80B678A8(EnSth* this, PlayState* play) { SkelAnime_Update(&this->skelAnime); - if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { + if (Actor_ProcessTalkRequest(&this->actor, &play->state)) { this->actionFunc = func_80B67838; - } else if (func_80B6703C(this, globalCtx) || this->actor.isTargeted) { + } else if (func_80B6703C(this, play) || 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); + func_800B8614(&this->actor, play, 110.0f); } this->unk_294.x = -0x1388; } -void func_80B67958(EnSth* this, GlobalContext* globalCtx) { +void func_80B67958(EnSth* this, PlayState* play) { SkelAnime_Update(&this->skelAnime); } -void func_80B67984(EnSth* this, GlobalContext* globalCtx) { +void func_80B67984(EnSth* this, PlayState* play) { u16 sp1E; if (gSaveContext.save.weekEventReg[34] & 0x10) { @@ -447,7 +446,7 @@ void func_80B67984(EnSth* this, GlobalContext* globalCtx) { sp1E = 0x918; } func_80B670A4(this, 2); - } else if (Inventory_GetSkullTokenCount(globalCtx->sceneNum) >= 30) { + } else if (Inventory_GetSkullTokenCount(play->sceneNum) >= 30) { if (INV_CONTENT(ITEM_MASK_TRUTH) == ITEM_MASK_TRUTH) { this->unk_29C |= 4; sp1E = 0x919; @@ -460,52 +459,52 @@ void func_80B67984(EnSth* this, GlobalContext* globalCtx) { sp1E = 0x8FC; gSaveContext.save.weekEventReg[34] |= 2; } - Message_StartTextbox(globalCtx, sp1E, &this->actor); + Message_StartTextbox(play, sp1E, &this->actor); } -void func_80B67AB4(EnSth* this, GlobalContext* globalCtx) { +void func_80B67AB4(EnSth* this, PlayState* play) { SkelAnime_Update(&this->skelAnime); - if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { + if (Actor_ProcessTalkRequest(&this->actor, &play->state)) { this->actionFunc = func_80B67C1C; gSaveContext.save.weekEventReg[34] |= 0x40; - Message_StartTextbox(globalCtx, 0x918, &this->actor); + Message_StartTextbox(play, 0x918, &this->actor); } else { - func_800B8500(&this->actor, globalCtx, 1000.0f, 1000.0f, -1); + func_800B8500(&this->actor, play, 1000.0f, 1000.0f, PLAYER_AP_MINUS1); } } -void func_80B67B50(EnSth* this, GlobalContext* globalCtx) { +void func_80B67B50(EnSth* this, PlayState* play) { SkelAnime_Update(&this->skelAnime); - if (Actor_HasParent(&this->actor, globalCtx)) { + if (Actor_HasParent(&this->actor, play)) { this->actor.parent = NULL; this->actionFunc = func_80B67AB4; this->actor.flags |= ACTOR_FLAG_10000; - func_800B8500(&this->actor, globalCtx, 1000.0f, 1000.0f, -1); + func_800B8500(&this->actor, play, 1000.0f, 1000.0f, PLAYER_AP_MINUS1); } else { this->unk_29C &= ~1; gSaveContext.save.weekEventReg[34] |= 8; - Actor_PickUp(&this->actor, globalCtx, GI_MASK_CAPTAIN, 10000.0f, 50.0f); + Actor_PickUp(&this->actor, play, GI_MASK_TRUTH, 10000.0f, 50.0f); } } -void func_80B67C1C(EnSth* this, GlobalContext* globalCtx) { +void func_80B67C1C(EnSth* this, PlayState* play) { s32 pad; SkelAnime_Update(&this->skelAnime); - if ((Message_GetState(&globalCtx->msgCtx) == 5) && Message_ShouldAdvance(globalCtx)) { - switch (globalCtx->msgCtx.currentTextId) { + if ((Message_GetState(&play->msgCtx) == TEXT_STATE_5) && Message_ShouldAdvance(play)) { + switch (play->msgCtx.currentTextId) { case 0x90C: func_80B670A4(this, 2); - func_80151938(globalCtx, globalCtx->msgCtx.currentTextId + 1); + func_80151938(play, play->msgCtx.currentTextId + 1); break; case 0x916: case 0x919: func_80B670A4(this, 3); - func_80151938(globalCtx, globalCtx->msgCtx.currentTextId + 1); + func_80151938(play, play->msgCtx.currentTextId + 1); break; case 0x8FC: @@ -513,15 +512,15 @@ void func_80B67C1C(EnSth* this, GlobalContext* globalCtx) { case 0x900: case 0x90A: case 0x90D: - func_80151938(globalCtx, globalCtx->msgCtx.currentTextId + 1); + func_80151938(play, play->msgCtx.currentTextId + 1); break; case 0x901: case 0x90B: case 0x917: - func_801477B4(globalCtx); + func_801477B4(play); this->actionFunc = func_80B67B50; - func_80B67B50(this, globalCtx); + func_80B67B50(this, play); break; case 0x91A: @@ -538,55 +537,54 @@ void func_80B67C1C(EnSth* this, GlobalContext* globalCtx) { default: this->actor.flags &= ~ACTOR_FLAG_10000; - func_801477B4(globalCtx); + func_801477B4(play); this->actionFunc = func_80B67DA0; break; } } } -void func_80B67DA0(EnSth* this, GlobalContext* globalCtx) { +void func_80B67DA0(EnSth* this, PlayState* play) { SkelAnime_Update(&this->skelAnime); - if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { - func_80B67984(this, globalCtx); + if (Actor_ProcessTalkRequest(&this->actor, &play->state)) { + func_80B67984(this, play); this->actionFunc = func_80B67C1C; - } else if (func_80B6703C(this, globalCtx)) { + } else if (func_80B6703C(this, play)) { this->actor.textId = 0; - func_800B8614(&this->actor, globalCtx, 110.0f); + func_800B8614(&this->actor, play, 110.0f); } } -void func_80B67E20(Actor* thisx, GlobalContext* globalCtx) { +void func_80B67E20(Actor* thisx, PlayState* play) { EnSth* this = THIS; - if (Inventory_GetSkullTokenCount(globalCtx->sceneNum) >= 30) { + if (Inventory_GetSkullTokenCount(play->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) { +void EnSth_Update(Actor* thisx, PlayState* play) { s32 pad; EnSth* this = THIS; - if (Object_IsLoaded(&globalCtx->objectCtx, this->unk_29E)) { + if (Object_IsLoaded(&play->objectCtx, this->unk_29E)) { this->actor.objBankIndex = this->unk_29E; - Actor_SetObjectDependency(globalCtx, &this->actor); + Actor_SetObjectDependency(play, &this->actor); if (ENSTH_GET_100(&this->actor)) { - SkelAnime_InitFlex(globalCtx, &this->skelAnime, &object_ahg_Skel_005998, &ovl_En_Sth_Anim_0045B4, + SkelAnime_InitFlex(play, &this->skelAnime, &object_ahg_Skel_005998, &ovl_En_Sth_Anim_0045B4, this->jointTable, this->morphTable, 16); Animation_PlayLoop(&this->skelAnime, &ovl_En_Sth_Anim_0045B4); this->unk_29A = 1; if ((gSaveContext.save.weekEventReg[34] & 0x10) || (gSaveContext.save.weekEventReg[34] & 0x20) || - (gSaveContext.save.weekEventReg[34] & 0x40) || - (Inventory_GetSkullTokenCount(globalCtx->sceneNum) >= 30)) { + (gSaveContext.save.weekEventReg[34] & 0x40) || (Inventory_GetSkullTokenCount(play->sceneNum) >= 30)) { func_80B670A4(this, 3); } } else { - SkelAnime_InitFlex(globalCtx, &this->skelAnime, &object_sth_Skel_0031F8, &ovl_En_Sth_Anim_003F50, + SkelAnime_InitFlex(play, &this->skelAnime, &object_sth_Skel_0031F8, &ovl_En_Sth_Anim_003F50, this->jointTable, this->morphTable, 16); Animation_PlayLoop(&this->skelAnime, &ovl_En_Sth_Anim_003F50); } @@ -612,7 +610,7 @@ void EnSth_Update(Actor* thisx, GlobalContext* globalCtx) { break; } - if ((ENSTH_GET_F(&this->actor) == ENSTH_F_4) && (Inventory_GetSkullTokenCount(globalCtx->sceneNum) < 30)) { + if ((ENSTH_GET_F(&this->actor) == ENSTH_F_4) && (Inventory_GetSkullTokenCount(play->sceneNum) < 30)) { this->actor.update = func_80B67E20; this->actor.draw = NULL; this->actor.flags &= ~ACTOR_FLAG_1; @@ -620,29 +618,29 @@ void EnSth_Update(Actor* thisx, GlobalContext* globalCtx) { } } -void func_80B680A8(Actor* thisx, GlobalContext* globalCtx) { +void func_80B680A8(Actor* thisx, PlayState* play) { s32 pad; EnSth* this = THIS; Vec3s sp38; Actor_MoveWithGravity(&this->actor); Collider_UpdateCylinder(&this->actor, &this->collider); - CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); - Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 0.0f, 0.0f, 0.0f, 4); + CollisionCheck_SetOC(play, &play->colChkCtx, &this->collider.base); + Actor_UpdateBgCheckInfo(play, &this->actor, 0.0f, 0.0f, 0.0f, 4); - this->actionFunc(this, globalCtx); + this->actionFunc(this, play); - if (func_80B6703C(this, globalCtx) && !(this->unk_29C & 8) && (this->unk_29A != 5)) { + if (func_80B6703C(this, play) && !(this->unk_29C & 8) && (this->unk_29A != 5)) { sp38.x = sp38.y = sp38.z = 0; - func_800E9250(globalCtx, &this->actor, &this->unk_294, &sp38, this->actor.focus.pos); + Actor_TrackPlayer(play, &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 func_80B681E8(PlayState* play, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, Actor* thisx) { s32 pad; EnSth* this = THIS; @@ -653,63 +651,63 @@ s32 func_80B681E8(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* p } 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); + rot->y += (s16)(Math_SinS(play->state.frames * ((limbIndex * 50) + 0x814)) * 200.0f); + rot->z += (s16)(Math_CosS(play->state.frames * ((limbIndex * 50) + 0x940)) * 200.0f); } return false; } -void func_80B68310(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx) { +void func_80B68310(PlayState* play, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx) { EnSth* this = THIS; if (limbIndex == 15) { s32 pad; - Matrix_MultiplyVector3fByState(&D_80B6D200, &this->actor.focus.pos); + Matrix_MultVec3f(&D_80B6D200, &this->actor.focus.pos); if (!ENSTH_GET_100(&this->actor)) { - OPEN_DISPS(globalCtx->state.gfxCtx); + OPEN_DISPS(play->state.gfxCtx); gSPDisplayList(POLY_OPA_DISP++, ovl_En_Sth_DL_0037C0); - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->state.gfxCtx); } else { - OPEN_DISPS(globalCtx->state.gfxCtx); + OPEN_DISPS(play->state.gfxCtx); if (this->unk_29C & 1) { - if (Object_IsLoaded(&globalCtx->objectCtx, this->unk_29F)) { - Matrix_StatePush(); - Matrix_InsertZRotation_s(0x3A98, MTXMODE_APPLY); - Matrix_InsertTranslation(0.0f, 190.0f, 0.0f, MTXMODE_APPLY); + if (Object_IsLoaded(&play->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), + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - gSPSegment(POLY_OPA_DISP++, 0x0A, globalCtx->objectCtx.status[this->unk_29F].segment); + gSPSegment(POLY_OPA_DISP++, 0x0A, play->objectCtx.status[this->unk_29F].segment); gSPDisplayList(POLY_OPA_DISP++, object_mask_truth_DL_0001A0); - Matrix_StatePop(); + Matrix_Pop(); } } - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->state.gfxCtx); } } } -void func_80B6849C(Actor* thisx, GlobalContext* globalCtx) { +void func_80B6849C(Actor* thisx, PlayState* play) { s32 pad; EnSth* this = THIS; - OPEN_DISPS(globalCtx->state.gfxCtx); + OPEN_DISPS(play->state.gfxCtx); - func_8012C28C(globalCtx->state.gfxCtx); + func_8012C28C(play->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)); + Gfx_EnvColor(play->state.gfxCtx, D_80B6D20C[1].r, D_80B6D20C[1].g, D_80B6D20C[1].b, 255)); + gSPSegment(POLY_OPA_DISP++, 0x09, Gfx_EnvColor(play->state.gfxCtx, 90, 110, 130, 255)); - SkelAnime_DrawFlexOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, + SkelAnime_DrawFlexOpa(play, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, func_80B681E8, func_80B68310, &this->actor); - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->state.gfxCtx); } diff --git a/src/overlays/actors/ovl_En_Sth/z_en_sth.h b/src/overlays/actors/ovl_En_Sth/z_en_sth.h index 422a92c34..38d5fcc7f 100644 --- a/src/overlays/actors/ovl_En_Sth/z_en_sth.h +++ b/src/overlays/actors/ovl_En_Sth/z_en_sth.h @@ -5,7 +5,7 @@ struct EnSth; -typedef void (*EnSthActionFunc)(struct EnSth*, GlobalContext*); +typedef void (*EnSthActionFunc)(struct EnSth*, PlayState*); #define ENSTH_GET_F(thisx) ((thisx)->params & 0xF) #define ENSTH_GET_100(thisx) ((thisx)->params & 0x100) 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 0bf0ae73c..3ce5ba447 100644 --- a/src/overlays/actors/ovl_En_Sth2/z_en_sth2.c +++ b/src/overlays/actors/ovl_En_Sth2/z_en_sth2.c @@ -10,11 +10,14 @@ #define THIS ((EnSth2*)thisx) -void EnSth2_Init(Actor* thisx, GlobalContext* globalCtx); -void EnSth2_Destroy(Actor* thisx, GlobalContext* globalCtx); -void EnSth2_Update(Actor* thisx, GlobalContext* globalCtx); +void EnSth2_Init(Actor* thisx, PlayState* play); +void EnSth2_Destroy(Actor* thisx, PlayState* play); +void EnSth2_Update(Actor* thisx, PlayState* play); +void EnSth2_Draw(Actor* thisx, PlayState* play2); + +void EnSth2_UpdateSkelAnime(EnSth2* this, PlayState* play); +void EnSth2_UpdateActionFunc(Actor* thisx, PlayState* play); -#if 0 const ActorInit En_Sth2_InitVars = { ACTOR_EN_STH2, ACTORCAT_NPC, @@ -27,22 +30,95 @@ const ActorInit En_Sth2_InitVars = { (ActorFunc)NULL, }; -#endif +#include "overlays/ovl_En_Sth2/ovl_En_Sth2.c" -extern UNK_TYPE D_060031F8; +void EnSth2_Init(Actor* thisx, PlayState* play) { + EnSth2* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Sth2/EnSth2_Init.s") + this->objIndex = Object_GetIndex(&play->objectCtx, OBJECT_STH); + Actor_SetScale(&this->actor, 0.01f); + ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 36.0f); + this->unused = 0; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Sth2/EnSth2_Destroy.s") + if (play->actorCtx.unk5 & 2) { + this->actor.flags |= (ACTOR_FLAG_10 | ACTOR_FLAG_20); + } else { + Actor_MarkForDeath(&this->actor); + return; + } + this->actionFunc = EnSth2_UpdateSkelAnime; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Sth2/func_80BF75A0.s") +void EnSth2_Destroy(Actor* thisx, PlayState* play) { +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Sth2/EnSth2_Update.s") +void EnSth2_UpdateSkelAnime(EnSth2* this, PlayState* play) { + SkelAnime_Update(&this->skelAnime); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Sth2/func_80BF7688.s") +void EnSth2_Update(Actor* thisx, PlayState* play) { + s32 pad; + EnSth2* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Sth2/func_80BF76AC.s") + if (Object_IsLoaded(&play->objectCtx, this->objIndex)) { + this->actor.objBankIndex = this->objIndex; + Actor_SetObjectDependency(play, &this->actor); + SkelAnime_InitFlex(play, &this->skelAnime, &object_sth_Skel_0031F8, &gEnSth2WavingHandAnim, this->jointTable, + this->morphTable, OBJECT_STH_LIMB_MAX); + Animation_PlayLoop(&this->skelAnime, &gEnSth2WavingHandAnim); + this->actor.update = EnSth2_UpdateActionFunc; + this->actor.draw = EnSth2_Draw; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Sth2/func_80BF77AC.s") +void EnSth2_UpdateActionFunc(Actor* thisx, PlayState* play) { + EnSth2* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Sth2/func_80BF7814.s") + this->actionFunc(this, play); +} + +s32 EnSth2_OverrideLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, Actor* thisx) { + s32 pad; + + if (limbIndex == OBJECT_STH_LIMB_0F) { + *dList = gEnSth2HeadDL; + } + if ((limbIndex == OBJECT_STH_LIMB_08) || (limbIndex == OBJECT_STH_LIMB_0A) || (limbIndex == OBJECT_STH_LIMB_0D)) { + rot->y += (s16)(Math_SinS((play->state.frames * ((limbIndex * 50) + 0x814))) * 200.0f); + rot->z += (s16)(Math_CosS((play->state.frames * ((limbIndex * 50) + 0x940))) * 200.0f); + } + return false; +} + +void EnSth2_PostLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx) { + static Vec3f focusOffset = { 700.0f, 400.0f, 0.0f }; + + if (limbIndex == OBJECT_STH_LIMB_0F) { + Matrix_MultVec3f(&focusOffset, &thisx->focus.pos); + + OPEN_DISPS(play->state.gfxCtx); + + gSPDisplayList(POLY_OPA_DISP++, gEnSth2HairDL); + + CLOSE_DISPS(play->state.gfxCtx); + } +} + +void EnSth2_Draw(Actor* thisx, PlayState* play2) { + static Color_RGB8 sEnvColors[] = { + { 190, 110, 0 }, { 0, 180, 110 }, { 0, 255, 80 }, { 255, 160, 60 }, { 190, 230, 250 }, { 240, 230, 120 }, + }; + PlayState* play = play2; + EnSth2* this = THIS; + + OPEN_DISPS(play->state.gfxCtx); + + func_8012C28C(play->state.gfxCtx); + gSPSegment(POLY_OPA_DISP++, 0x08, + Gfx_EnvColor(play->state.gfxCtx, sEnvColors[1].r, sEnvColors[1].g, sEnvColors[1].b, 255)); + gSPSegment(POLY_OPA_DISP++, 0x09, Gfx_EnvColor(play->state.gfxCtx, 90, 110, 130, 255)); + SkelAnime_DrawFlexOpa(play, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, + EnSth2_OverrideLimbDraw, EnSth2_PostLimbDraw, &this->actor); + + CLOSE_DISPS(play->state.gfxCtx); +} diff --git a/src/overlays/actors/ovl_En_Sth2/z_en_sth2.h b/src/overlays/actors/ovl_En_Sth2/z_en_sth2.h index 1788c486c..1166c9d29 100644 --- a/src/overlays/actors/ovl_En_Sth2/z_en_sth2.h +++ b/src/overlays/actors/ovl_En_Sth2/z_en_sth2.h @@ -2,12 +2,20 @@ #define Z_EN_STH2_H #include "global.h" +#include "objects/object_sth/object_sth.h" struct EnSth2; +typedef void (*EnSth2ActionFunc)(struct EnSth2*, PlayState*); + typedef struct EnSth2 { /* 0x000 */ Actor actor; - /* 0x144 */ char unk_144[0x10C]; + /* 0x144 */ SkelAnime skelAnime; + /* 0x188 */ Vec3s jointTable[OBJECT_STH_LIMB_MAX]; + /* 0x1E8 */ Vec3s morphTable[OBJECT_STH_LIMB_MAX]; + /* 0x248 */ s16 unused; + /* 0x24A */ u8 objIndex; + /* 0x24C */ EnSth2ActionFunc actionFunc; } EnSth2; // size = 0x250 extern const ActorInit En_Sth2_InitVars; diff --git a/src/overlays/actors/ovl_En_Stone_heishi/z_en_stone_heishi.c b/src/overlays/actors/ovl_En_Stone_heishi/z_en_stone_heishi.c index 54a1f84a8..fe4882947 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 @@ -10,17 +10,17 @@ #define THIS ((EnStoneheishi*)thisx) -void EnStoneheishi_Init(Actor* thisx, GlobalContext* globalCtx); -void EnStoneheishi_Destroy(Actor* thisx, GlobalContext* globalCtx); -void EnStoneheishi_Update(Actor* thisx, GlobalContext* globalCtx); -void EnStoneheishi_Draw(Actor* thisx, GlobalContext* globalCtx); +void EnStoneheishi_Init(Actor* thisx, PlayState* play); +void EnStoneheishi_Destroy(Actor* thisx, PlayState* play); +void EnStoneheishi_Update(Actor* thisx, PlayState* play); +void EnStoneheishi_Draw(Actor* thisx, PlayState* play); -void func_80BC9560(EnStoneheishi* this, GlobalContext* globalCtx); -void func_80BC9680(EnStoneheishi* this, GlobalContext* globalCtx); -void func_80BC9908(EnStoneheishi* this, GlobalContext* globalCtx); -void func_80BC9A2C(EnStoneheishi* this, GlobalContext* globalCtx); -void func_80BC9D28(EnStoneheishi* this, GlobalContext* globalCtx); -void func_80BC9E50(EnStoneheishi* this, GlobalContext* globalCtx); +void func_80BC9560(EnStoneheishi* this, PlayState* play); +void func_80BC9680(EnStoneheishi* this, PlayState* play); +void func_80BC9908(EnStoneheishi* this, PlayState* play); +void func_80BC9A2C(EnStoneheishi* this, PlayState* play); +void func_80BC9D28(EnStoneheishi* this, PlayState* play); +void func_80BC9E50(EnStoneheishi* this, PlayState* play); #if 0 const ActorInit En_Stone_heishi_InitVars = { diff --git a/src/overlays/actors/ovl_En_Stone_heishi/z_en_stone_heishi.h b/src/overlays/actors/ovl_En_Stone_heishi/z_en_stone_heishi.h index 32604cca5..f4eb8e5f2 100644 --- a/src/overlays/actors/ovl_En_Stone_heishi/z_en_stone_heishi.h +++ b/src/overlays/actors/ovl_En_Stone_heishi/z_en_stone_heishi.h @@ -5,13 +5,13 @@ struct EnStoneheishi; -typedef void (*EnStoneheishiActionFunc)(struct EnStoneheishi*, GlobalContext*); +typedef void (*EnStoneheishiActionFunc)(struct EnStoneheishi*, PlayState*); typedef struct EnStoneheishi { - /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x110]; - /* 0x0254 */ EnStoneheishiActionFunc actionFunc; - /* 0x0258 */ char unk_258[0x6C]; + /* 0x000 */ Actor actor; + /* 0x144 */ char unk_144[0x110]; + /* 0x254 */ EnStoneheishiActionFunc actionFunc; + /* 0x258 */ char unk_258[0x6C]; } EnStoneheishi; // size = 0x2C4 extern const ActorInit En_Stone_heishi_InitVars; diff --git a/src/overlays/actors/ovl_En_Stop_heishi/z_en_stop_heishi.c b/src/overlays/actors/ovl_En_Stop_heishi/z_en_stop_heishi.c index 3ca829630..ec412ce79 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 @@ -10,13 +10,13 @@ #define THIS ((EnStopheishi*)thisx) -void EnStopheishi_Init(Actor* thisx, GlobalContext* globalCtx); -void EnStopheishi_Destroy(Actor* thisx, GlobalContext* globalCtx); -void EnStopheishi_Update(Actor* thisx, GlobalContext* globalCtx); -void EnStopheishi_Draw(Actor* thisx, GlobalContext* globalCtx); +void EnStopheishi_Init(Actor* thisx, PlayState* play); +void EnStopheishi_Destroy(Actor* thisx, PlayState* play); +void EnStopheishi_Update(Actor* thisx, PlayState* play); +void EnStopheishi_Draw(Actor* thisx, PlayState* play); -void func_80AE7F34(EnStopheishi* this, GlobalContext* globalCtx); -void func_80AE85C4(EnStopheishi* this, GlobalContext* globalCtx); +void func_80AE7F34(EnStopheishi* this, PlayState* play); +void func_80AE85C4(EnStopheishi* this, PlayState* play); #if 0 const ActorInit En_Stop_heishi_InitVars = { diff --git a/src/overlays/actors/ovl_En_Stop_heishi/z_en_stop_heishi.h b/src/overlays/actors/ovl_En_Stop_heishi/z_en_stop_heishi.h index c85e00f06..5c2b639ef 100644 --- a/src/overlays/actors/ovl_En_Stop_heishi/z_en_stop_heishi.h +++ b/src/overlays/actors/ovl_En_Stop_heishi/z_en_stop_heishi.h @@ -5,13 +5,13 @@ struct EnStopheishi; -typedef void (*EnStopheishiActionFunc)(struct EnStopheishi*, GlobalContext*); +typedef void (*EnStopheishiActionFunc)(struct EnStopheishi*, PlayState*); typedef struct EnStopheishi { - /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x110]; - /* 0x0254 */ EnStopheishiActionFunc actionFunc; - /* 0x0258 */ char unk_258[0x90]; + /* 0x000 */ Actor actor; + /* 0x144 */ char unk_144[0x110]; + /* 0x254 */ EnStopheishiActionFunc actionFunc; + /* 0x258 */ char unk_258[0x90]; } EnStopheishi; // size = 0x2E8 extern const ActorInit En_Stop_heishi_InitVars; diff --git a/src/overlays/actors/ovl_En_Stream/z_en_stream.c b/src/overlays/actors/ovl_En_Stream/z_en_stream.c index abf58da86..782f32c0d 100644 --- a/src/overlays/actors/ovl_En_Stream/z_en_stream.c +++ b/src/overlays/actors/ovl_En_Stream/z_en_stream.c @@ -11,12 +11,12 @@ #define THIS ((EnStream*)thisx) -void EnStream_Init(Actor* thisx, GlobalContext* globalCtx); -void EnStream_Destroy(Actor* thisx, GlobalContext* globalCtx); -void EnStream_Update(Actor* thisx, GlobalContext* globalCtx); -void EnStream_Draw(Actor* thisx, GlobalContext* globalCtx); +void EnStream_Init(Actor* thisx, PlayState* play); +void EnStream_Destroy(Actor* thisx, PlayState* play); +void EnStream_Update(Actor* thisx, PlayState* play); +void EnStream_Draw(Actor* thisx, PlayState* play); -void EnStream_WaitForPlayer(EnStream* this, GlobalContext* globalCtx); +void EnStream_WaitForPlayer(EnStream* this, PlayState* play); const ActorInit En_Stream_InitVars = { ACTOR_EN_STREAM, @@ -38,7 +38,7 @@ void EnStream_SetupAction(EnStream* this, EnStreamActionFunc actionFunc) { this->actionFunc = actionFunc; } -void EnStream_Init(Actor* thisx, GlobalContext* globalCtx) { +void EnStream_Init(Actor* thisx, PlayState* play) { EnStream* this = THIS; this->size = EN_STREAM_SIZE(&this->actor); @@ -49,7 +49,7 @@ void EnStream_Init(Actor* thisx, GlobalContext* globalCtx) { EnStream_SetupAction(this, EnStream_WaitForPlayer); } -void EnStream_Destroy(Actor* thisx, GlobalContext* globalCtx) { +void EnStream_Destroy(Actor* thisx, PlayState* play) { } s32 EnStream_PlayerIsInRange(Vec3f* vortexWorldPos, Vec3f* playerWorldPos, Vec3f* posDifference, f32 vortexYScale) { @@ -81,8 +81,8 @@ s32 EnStream_PlayerIsInRange(Vec3f* vortexWorldPos, Vec3f* playerWorldPos, Vec3f return ret; } -void EnStream_SuckPlayer(EnStream* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); +void EnStream_SuckPlayer(EnStream* this, PlayState* play) { + Player* player = GET_PLAYER(play); s32 pad48; Vec3f posDifference; f32 xzDist; @@ -112,8 +112,8 @@ void EnStream_SuckPlayer(EnStream* this, GlobalContext* globalCtx) { } } -void EnStream_WaitForPlayer(EnStream* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); +void EnStream_WaitForPlayer(EnStream* this, PlayState* play) { + Player* player = GET_PLAYER(play); s32 pad; Vec3f temp; @@ -123,27 +123,27 @@ void EnStream_WaitForPlayer(EnStream* this, GlobalContext* globalCtx) { } } -void EnStream_Update(Actor* thisx, GlobalContext* globalCtx) { +void EnStream_Update(Actor* thisx, PlayState* play) { EnStream* this = THIS; - this->actionFunc(this, globalCtx); + this->actionFunc(this, play); func_800B8FE8(&this->actor, NA_SE_EV_WHIRLPOOL - SFX_FLAG); } -void EnStream_Draw(Actor* thisx, GlobalContext* globalCtx) { +void EnStream_Draw(Actor* thisx, PlayState* play) { u32 multipliedFrames; - u32 frames = globalCtx->gameplayFrames; + u32 frames = play->gameplayFrames; Gfx* gfx; - OPEN_DISPS(globalCtx->state.gfxCtx); - func_8012C2DC(globalCtx->state.gfxCtx); + OPEN_DISPS(play->state.gfxCtx); + func_8012C2DC(play->state.gfxCtx); gfx = POLY_XLU_DISP; - gSPMatrix(&gfx[0], Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPMatrix(&gfx[0], Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); multipliedFrames = frames * 20; gSPSegment(&gfx[1], 0x08, - Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, frames * 30, -multipliedFrames, 64, 64, 1, multipliedFrames, + Gfx_TwoTexScroll(play->state.gfxCtx, 0, frames * 30, -multipliedFrames, 64, 64, 1, multipliedFrames, -multipliedFrames, 64, 64)); gSPDisplayList(&gfx[2], gWaterVortexDL); POLY_XLU_DISP = &gfx[3]; - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->state.gfxCtx); } diff --git a/src/overlays/actors/ovl_En_Stream/z_en_stream.h b/src/overlays/actors/ovl_En_Stream/z_en_stream.h index 3948b70c9..c544be02f 100644 --- a/src/overlays/actors/ovl_En_Stream/z_en_stream.h +++ b/src/overlays/actors/ovl_En_Stream/z_en_stream.h @@ -23,7 +23,7 @@ typedef enum { struct EnStream; -typedef void (*EnStreamActionFunc)(struct EnStream*, GlobalContext*); +typedef void (*EnStreamActionFunc)(struct EnStream*, PlayState*); typedef struct EnStream { /* 0x000 */ Actor actor; 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 dafed18c5..10cdec079 100644 --- a/src/overlays/actors/ovl_En_Suttari/z_en_suttari.c +++ b/src/overlays/actors/ovl_En_Suttari/z_en_suttari.c @@ -13,29 +13,29 @@ #define THIS ((EnSuttari*)thisx) -void EnSuttari_Init(Actor* thisx, GlobalContext* globalCtx); -void EnSuttari_Destroy(Actor* thisx, GlobalContext* globalCtx); -void EnSuttari_Update(Actor* thisx, GlobalContext* globalCtx); -void EnSuttari_Draw(Actor* thisx, GlobalContext* globalCtx); +void EnSuttari_Init(Actor* thisx, PlayState* play); +void EnSuttari_Destroy(Actor* thisx, PlayState* play); +void EnSuttari_Update(Actor* thisx, PlayState* play); +void EnSuttari_Draw(Actor* thisx, PlayState* play); -void func_80BACA14(EnSuttari* this, GlobalContext* globalCtx); -void func_80BACEE0(EnSuttari* this, GlobalContext* globalCtx); -void func_80BAD004(EnSuttari* this, GlobalContext* globalCtx); -void func_80BAD5F8(EnSuttari* this, GlobalContext* globalCtx); -void func_80BAD7F8(EnSuttari* this, GlobalContext* globalCtx); -void func_80BAD380(EnSuttari* this, GlobalContext* globalCtx); -void func_80BACBB0(EnSuttari* this, GlobalContext* globalCtx); -void func_80BADA9C(EnSuttari* this, GlobalContext* globalCtx); -void func_80BADDB4(EnSuttari* this, GlobalContext* globalCtx); -void func_80BAD130(EnSuttari* this, GlobalContext* globalCtx); -void func_80BACD2C(EnSuttari* this, GlobalContext* globalCtx); -void func_80BACE4C(EnSuttari* this, GlobalContext* globalCtx); -void func_80BADD0C(EnSuttari* this, GlobalContext* globalCtx); -void func_80BADA08(EnSuttari* this, GlobalContext* globalCtx); -void func_80BAD2B4(EnSuttari* this, GlobalContext* globalCtx); -void func_80BADE14(EnSuttari* this, GlobalContext* globalCtx); -void func_80BADE8C(EnSuttari* this, GlobalContext* globalCtx); -void func_80BADF3C(EnSuttari* this, GlobalContext* globalCtx); +void func_80BACA14(EnSuttari* this, PlayState* play); +void func_80BACEE0(EnSuttari* this, PlayState* play); +void func_80BAD004(EnSuttari* this, PlayState* play); +void func_80BAD5F8(EnSuttari* this, PlayState* play); +void func_80BAD7F8(EnSuttari* this, PlayState* play); +void func_80BAD380(EnSuttari* this, PlayState* play); +void func_80BACBB0(EnSuttari* this, PlayState* play); +void func_80BADA9C(EnSuttari* this, PlayState* play); +void func_80BADDB4(EnSuttari* this, PlayState* play); +void func_80BAD130(EnSuttari* this, PlayState* play); +void func_80BACD2C(EnSuttari* this, PlayState* play); +void func_80BACE4C(EnSuttari* this, PlayState* play); +void func_80BADD0C(EnSuttari* this, PlayState* play); +void func_80BADA08(EnSuttari* this, PlayState* play); +void func_80BAD2B4(EnSuttari* this, PlayState* play); +void func_80BADE14(EnSuttari* this, PlayState* play); +void func_80BADE8C(EnSuttari* this, PlayState* play); +void func_80BADF3C(EnSuttari* this, PlayState* play); const ActorInit En_Suttari_InitVars = { ACTOR_EN_SUTTARI, @@ -49,7 +49,7 @@ const ActorInit En_Suttari_InitVars = { (ActorFunc)EnSuttari_Draw, }; -static AnimationInfo sAnimations[] = { +static AnimationInfo sAnimationInfo[] = { { &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 }, @@ -120,24 +120,68 @@ 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[] = { -1, -1, -1, -1, -1, -1, 1, 2, 0, 3, 1, 2, 0, 0, 3, 0, }; -void EnSuttari_UpdateCollider(EnSuttari* this, GlobalContext* globalCtx) { +void EnSuttari_UpdateCollider(EnSuttari* this, PlayState* play) { this->collider.dim.pos.x = this->actor.world.pos.x; this->collider.dim.pos.y = this->actor.world.pos.y; this->collider.dim.pos.z = this->actor.world.pos.z; @@ -148,7 +192,7 @@ void EnSuttari_UpdateCollider(EnSuttari* this, GlobalContext* globalCtx) { if (this->actor.colChkInfo.damageEffect == 0xF) { this->flags1 |= 0x100; this->flags1 &= ~0x40; - Enemy_StartFinishingBlow(globalCtx, &this->actor); + Enemy_StartFinishingBlow(play, &this->actor); } else if (this->actor.colChkInfo.damageEffect == 0xE) { this->flags1 |= 0x200; this->flags1 &= ~0x40; @@ -156,18 +200,18 @@ void EnSuttari_UpdateCollider(EnSuttari* this, GlobalContext* globalCtx) { } } - CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); - CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + CollisionCheck_SetAC(play, &play->colChkCtx, &this->collider.base); + CollisionCheck_SetOC(play, &play->colChkCtx, &this->collider.base); if ((this->flags1 & 1) && (this->actionFunc != func_80BADE14)) { - Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 35.0f, 30.0f, 30.0f, 5); + Actor_UpdateBgCheckInfo(play, &this->actor, 35.0f, 30.0f, 30.0f, 5); } else { - Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 35.0f, 30.0f, 30.0f, 4); + Actor_UpdateBgCheckInfo(play, &this->actor, 35.0f, 30.0f, 30.0f, 4); } } -Actor* EnSuttari_GetActorById(GlobalContext* globalCtx, s16 actorId) { - Actor* actor = globalCtx->actorCtx.actorLists[ACTORCAT_NPC].first; +Actor* EnSuttari_GetActorById(PlayState* play, s16 actorId) { + Actor* actor = play->actorCtx.actorLists[ACTORCAT_NPC].first; while (actor != NULL) { if (actor->id == actorId) { @@ -178,23 +222,19 @@ Actor* EnSuttari_GetActorById(GlobalContext* globalCtx, s16 actorId) { return NULL; } -void EnSuttari_SetNextEntrance(GlobalContext* globalCtx, u16 nextEntranceIndex) { - globalCtx->nextEntranceIndex = nextEntranceIndex; - globalCtx->unk_1887F = 0x40; - gSaveContext.nextTransition = 0x40; - globalCtx->sceneLoadFlag = 0x14; +void EnSuttari_TriggerTransition(PlayState* play, u16 entrance) { + play->nextEntrance = entrance; + play->transitionType = TRANS_TYPE_64; + gSaveContext.nextTransitionType = TRANS_TYPE_64; + play->transitionTrigger = TRANS_TRIGGER_START; } void EnSuttari_UpdateTime(void) { - u32* unk_14 = &gSaveContext.save.daySpeed; - u16 time = gSaveContext.save.time; - - gSaveContext.save.time = (u16)REG(15) + time; - time = gSaveContext.save.time; - gSaveContext.save.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) { +s32 func_80BAA904(EnSuttari* this, PlayState* play) { Vec3f pos; s32 pad; CollisionPoly* poly; @@ -202,7 +242,7 @@ s32 func_80BAA904(EnSuttari* this, GlobalContext* globalCtx) { pos.x = (Math_SinS(this->actor.world.rot.y) * 50.0f) + this->actor.world.pos.x; pos.y = this->actor.world.pos.y + 100.0f; pos.z = (Math_CosS(this->actor.world.rot.y) * 50.0f) + this->actor.world.pos.z; - if (BgCheck_EntityRaycastFloor2(globalCtx, &globalCtx->colCtx, &poly, &pos) > -500.0f) { + if (BgCheck_EntityRaycastFloor2(play, &play->colCtx, &poly, &pos) > -500.0f) { return false; } return true; @@ -210,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->animationIndex].animation); + s16 frameCount = Animation_GetLastFrame(sAnimationInfo[this->animIndex].animation); switch (this->textId) { case 0x1454: @@ -221,15 +261,15 @@ void func_80BAA9B4(EnSuttari* this) { case 0x1459: case 0x145A: case 0x145B: - if ((this->animationIndex != 8) && (curFrame == frameCount)) { - this->animationIndex = 8; - Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, this->animationIndex); + if ((this->animIndex != 8) && (curFrame == frameCount)) { + this->animIndex = 8; + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, this->animIndex); } break; default: - if ((this->animationIndex != 1) && (curFrame == frameCount)) { - this->animationIndex = 1; - Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, this->animationIndex); + if ((this->animIndex != 1) && (curFrame == frameCount)) { + this->animIndex = 1; + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, this->animIndex); } } } @@ -237,8 +277,8 @@ void func_80BAA9B4(EnSuttari* this) { void func_80BAAA94(EnSuttari* this) { switch (this->textId) { case 0x29E5: - this->animationIndex = 1; - Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, this->animationIndex); + this->animIndex = 1; + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, this->animIndex); break; case 0x29E9: this->enFsn->flags |= ENFSN_ANGRY; @@ -250,17 +290,17 @@ void func_80BAAA94(EnSuttari* this) { this->enFsn->flags |= ENFSN_OFFER_FINAL_PRICE; break; case 0x29EC: - this->animationIndex = 7; - Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, this->animationIndex); + this->animIndex = 7; + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, this->animIndex); break; case 0x29ED: - this->animationIndex = 1; - Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, this->animationIndex); + this->animIndex = 1; + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, this->animIndex); break; } } -void func_80BAAB78(EnSuttari* this, GlobalContext* globalCtx) { +void func_80BAAB78(EnSuttari* this, PlayState* play) { if (this->flags1 & 4) { switch (this->textId) { case 0: @@ -325,7 +365,7 @@ void func_80BAAB78(EnSuttari* this, GlobalContext* globalCtx) { case 0: if (gSaveContext.save.weekEventReg[81] & 1) { this->textId = 0x1455; - ((EnElf*)GET_PLAYER(globalCtx)->tatlActor)->unk_264 |= 8; + ((EnElf*)GET_PLAYER(play)->tatlActor)->unk_264 |= 8; this->flags2 |= 1; } else { this->textId = 0x1450; @@ -347,7 +387,7 @@ void func_80BAAB78(EnSuttari* this, GlobalContext* globalCtx) { case 0x1453: this->flags1 |= 0x400; gSaveContext.save.weekEventReg[81] |= 1; - ((EnElf*)GET_PLAYER(globalCtx)->tatlActor)->unk_264 |= 8; + ((EnElf*)GET_PLAYER(play)->tatlActor)->unk_264 |= 8; this->flags2 |= 1; this->textId = 0x1454; break; @@ -372,24 +412,24 @@ void func_80BAAB78(EnSuttari* this, GlobalContext* globalCtx) { break; } } - Message_StartTextbox(globalCtx, this->textId, &this->actor); + Message_StartTextbox(play, this->textId, &this->actor); } void func_80BAAF1C(EnSuttari* this) { s16 curFrame = this->skelAnime.curFrame; - s16 frameCount = Animation_GetLastFrame(sAnimations[this->animationIndex].animation); + s16 frameCount = Animation_GetLastFrame(sAnimationInfo[this->animIndex].animation); - 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); + if (this->animIndex == 5) { + this->animIndex = 3; + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, this->animIndex); + } else if ((this->animIndex == 3) && (curFrame == frameCount)) { + this->animIndex = 6; + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, this->animIndex); this->flags1 &= ~0x100; } } -void func_80BAAFDC(EnSuttari* this, GlobalContext* globalCtx) { +void func_80BAAFDC(EnSuttari* this, PlayState* play) { if ((this->actor.xzDistToPlayer < 500.0f) && (this->actor.playerHeightRel < 100.0f)) { Vec3f effectVelOffset = { 0.0f, 0.0f, 0.0f }; Vec3f effectPos; @@ -399,13 +439,13 @@ 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); + EffectSsSolderSrchBall_Spawn(play, &effectPos, &effectVel, &gZeroVec3f, 50, &this->unk3F0, 1); } if (this->unk3F0 == 1) { play_sound(NA_SE_SY_FOUND); @@ -421,7 +461,7 @@ void func_80BAAFDC(EnSuttari* this, GlobalContext* globalCtx) { } } -void func_80BAB1A0(EnSuttari* this, GlobalContext* globalCtx) { +void func_80BAB1A0(EnSuttari* this, PlayState* play) { if ((this->actor.xzDistToPlayer < 500.0f) && (this->actor.playerHeightRel < 100.0f)) { Vec3f effectVelOffset = { 0.0f, 0.0f, 0.0f }; Vec3f effectPos; @@ -431,13 +471,13 @@ 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); + EffectSsSolderSrchBall_Spawn(play, &effectPos, &effectVel, &gZeroVec3f, 50, &this->unk3F0, 1); } if (this->unk3F0 == 1) { play_sound(NA_SE_SY_FOUND); @@ -450,12 +490,12 @@ void func_80BAB1A0(EnSuttari* this, GlobalContext* globalCtx) { this->unk3F6 = 20; this->actionFunc = func_80BADE8C; } else { - func_80BAAFDC(this, globalCtx); + func_80BAAFDC(this, play); } } } -void func_80BAB374(EnSuttari* this, GlobalContext* globalCtx) { +void func_80BAB374(EnSuttari* this, PlayState* play) { s16 curFrame = this->skelAnime.curFrame; Vec3f sp38; @@ -463,7 +503,7 @@ void func_80BAB374(EnSuttari* this, GlobalContext* globalCtx) { sp38.x = randPlusMinusPoint5Scaled(15.0f) + this->actor.world.pos.x; sp38.y = this->actor.world.pos.y; sp38.z = randPlusMinusPoint5Scaled(15.0f) + this->actor.world.pos.z; - Actor_SpawnFloorDustRing(globalCtx, &this->actor, &sp38, 10.0f, 0, 2.0f, 0, 0, 0); + Actor_SpawnFloorDustRing(play, &this->actor, &sp38, 10.0f, 0, 2.0f, 0, 0, 0); } } @@ -472,36 +512,36 @@ void func_80BAB434(EnSuttari* this) { this->unk3F4 += 0x400; } -void EnSuttari_GetPaths(EnSuttari* this, GlobalContext* globalCtx) { - this->paths[0] = SubS_GetPathByIndex(globalCtx, ENSUTTARI_GET_PATH(&this->actor), 0x3F); - this->paths[1] = SubS_GetPathByIndex(globalCtx, this->paths[0]->unk1, 0x3F); +void EnSuttari_GetPaths(EnSuttari* this, PlayState* play) { + this->paths[0] = SubS_GetPathByIndex(play, ENSUTTARI_GET_PATH(&this->actor), 0x3F); + this->paths[1] = SubS_GetPathByIndex(play, this->paths[0]->unk1, 0x3F); } -void func_80BAB4F0(EnSuttari* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); - Vec3f sp30; +void func_80BAB4F0(EnSuttari* this, PlayState* play) { + Player* player = GET_PLAYER(play); + Vec3f point; if (this->flags1 & 0x80) { - EnSuttari_UpdateCollider(this, globalCtx); + EnSuttari_UpdateCollider(this, play); } SkelAnime_Update(&this->skelAnime); - if (!(this->flags1 & 4) && (Player_GetMask(globalCtx) != PLAYER_MASK_STONE)) { + if (!(this->flags1 & 4) && (Player_GetMask(play) != PLAYER_MASK_STONE)) { if (SubS_AngleDiffLessEqual(this->actor.shape.rot.y, 0x36B0, this->actor.yawTowardsPlayer)) { - sp30.x = player->actor.world.pos.x; - sp30.y = player->bodyPartsPos[7].y + 3.0f; - sp30.z = player->actor.world.pos.z; - func_8013D2E0(&sp30, &this->actor.focus.pos, &this->actor.shape.rot, &this->unk2D6, &this->unk2DC, - &this->unk2E2, D_80BAE800); + 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); } } - SubS_FillLimbRotTables(globalCtx, this->unk2FA, this->unk31A, ARRAY_COUNT(this->unk2FA)); + SubS_FillLimbRotTables(play, this->unk2FA, this->unk31A, ARRAY_COUNT(this->unk2FA)); } s16 EnSuttari_GetDistSqAndOrient(Path* path, s32 index, Vec3f* pos, f32* distSq) { @@ -633,68 +673,64 @@ void func_80BABB90(EnSuttari* this, s32 arg1) { } } -s32 func_80BABC48(EnSuttari* this, GlobalContext* globalCtx, struct_80133038_arg2* unkStruct) { - u16 sp26 = gSaveContext.save.time - 0x3FFC; - u16 pad1; - u8 sp23 = ENSUTTARI_GET_PATH(&this->actor); - u16 pad2; - UNK_TYPE sp1C = D_80BAE8F8[unkStruct->unk0]; +s32 func_80BABC48(EnSuttari* this, PlayState* play, ScheduleOutput* scheduleOutput) { + u16 sp26 = SCHEDULE_TIME_NOW; u16 phi_a0; + u8 sp23 = ENSUTTARI_GET_PATH(&this->actor); + u16 tmp; - if (sp1C >= 0) { - this->unk404 = SubS_GetAdditionalPath(globalCtx, sp23, sp1C); + if (D_80BAE8F8[scheduleOutput->result] >= 0) { + this->timePath = SubS_GetAdditionalPath(play, sp23, D_80BAE8F8[scheduleOutput->result]); } - 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 = scheduleOutput->time0; } - if (unkStruct->unk8 < phi_a0) { - this->unk418 = (phi_a0 - unkStruct->unk8) + 0xFFFF; + if (scheduleOutput->time1 < phi_a0) { + this->timePathTotalTime = (phi_a0 - scheduleOutput->time1) + 0xFFFF; } else { - this->unk418 = unkStruct->unk8 - phi_a0; + this->timePathTotalTime = scheduleOutput->time1 - phi_a0; } - this->unk424 = sp26 - phi_a0; - phi_a0 = this->unk404->count - 2; + this->timePathElapsedTime = sp26 - phi_a0; + tmp = 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 / tmp; + 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, PlayState* play, ScheduleOutput* scheduleOutput) { 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.save.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]; + sp48 = (EnDoor*)SubS_FindNearestActor(&this->actor, play, ACTORCAT_DOOR, ACTOR_EN_DOOR); + sp24 = D_80BAE8F8[scheduleOutput->result]; if ((sp48 != NULL) && (sp24 >= 0)) { - this->unk404 = SubS_GetAdditionalPath(globalCtx, sp47, sp24); + this->timePath = SubS_GetAdditionalPath(play, sp47, sp24); } - if ((sp48 == NULL) || (this->unk404 == NULL)) { + if ((sp48 == NULL) || (this->timePath == NULL)) { return 0; } - sp28 = 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 - scheduleOutput->time0; + this->unk436 = scheduleOutput->time1 - scheduleOutput->time0; + if (scheduleOutput->result != 10 && scheduleOutput->result != 11) { sp48->unk_1A7 = 0x4B; } Math_Vec3f_Copy(&this->unk438, &sp38); @@ -704,15 +740,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, PlayState* play, ScheduleOutput* scheduleOutput) { s32 ret; - switch (unkStruct->unk0) { + switch (scheduleOutput->result) { case 15: case 14: case 13: case 12: - ret = func_80BABC48(this, globalCtx, unkStruct); + ret = func_80BABC48(this, play, scheduleOutput); break; case 11: case 10: @@ -720,7 +756,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, play, scheduleOutput); break; case 5: case 4: @@ -736,51 +772,53 @@ s32 func_80BABF64(EnSuttari* this, GlobalContext* globalCtx, struct_80133038_arg return ret; } -s32 func_80BABFD4(EnSuttari* this, GlobalContext* globalCtx) { - f32 sp7C[265]; +s32 func_80BABFD4(EnSuttari* this, PlayState* play) { + 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(play, 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(play)) { + 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(play)) { + this->timePathElapsedTime = sp54; + this->timePathWaypoint = sp50; + this->timePathTargetPos = timePathTargetPos; } return 0; } -s32 func_80BAC220(EnSuttari* this, GlobalContext* globalCtx) { +s32 func_80BAC220(EnSuttari* this, PlayState* play) { Vec3f sp3C; Vec3f sp30; s32 tmp2; @@ -797,25 +835,25 @@ 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); +void func_80BAC2FC(EnSuttari* this, PlayState* play) { + Player* player = GET_PLAYER(play); s16 curFrame = this->skelAnime.curFrame; - s16 frameCount = Animation_GetLastFrame(sAnimations[this->animationIndex].animation); + s16 frameCount = Animation_GetLastFrame(sAnimationInfo[this->animIndex].animation); switch (this->unk428) { case 12: case 13: this->flags1 |= 0x80; - func_80BABFD4(this, globalCtx); + func_80BABFD4(this, play); break; case 15: - if ((this->animationIndex == 1) && (curFrame == frameCount)) { - this->animationIndex = 2; - Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, this->animationIndex); + if ((this->animIndex == 1) && (curFrame == frameCount)) { + this->animIndex = 2; + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, this->animIndex); } if (!(gSaveContext.save.weekEventReg[83] & 4) && !(this->flags1 & 0x1000)) { if (ActorCutscene_GetCanPlayNext(this->cutscenes[0])) { @@ -830,37 +868,37 @@ void func_80BAC2FC(EnSuttari* this, GlobalContext* globalCtx) { ActorCutscene_SetIntentToPlay(this->cutscenes[0]); } } - func_80BABFD4(this, globalCtx); + func_80BABFD4(this, play); break; case 6: case 8: this->flags1 |= 0x80; - func_80BAC220(this, globalCtx); + func_80BAC220(this, play); break; case 10: this->flags1 |= 0x80; - func_80BAC220(this, globalCtx); + func_80BAC220(this, play); break; case 9: case 11: this->flags1 |= 0x80; this->flags1 |= 0x20; this->enFsn->flags &= ~ENFSN_HAGGLE; - if (this->animationIndex != 2) { - this->animationIndex = 2; - Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, this->animationIndex); + if (this->animIndex != 2) { + this->animIndex = 2; + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, this->animIndex); } - func_80BAC220(this, globalCtx); + func_80BAC220(this, play); break; case 7: this->flags1 |= 0x20; this->flags1 |= 0x80; - func_80BAC220(this, globalCtx); + func_80BAC220(this, play); break; case 14: this->flags1 |= 0x20; this->flags1 |= 0x80; - func_80BABFD4(this, globalCtx); + func_80BABFD4(this, play); break; case 1: Actor_MarkForDeath(&this->actor); @@ -877,9 +915,9 @@ void func_80BAC2FC(EnSuttari* this, GlobalContext* globalCtx) { break; case 4: if (!(gSaveContext.save.weekEventReg[33] & 8)) { - if (this->animationIndex == 2 || this->animationIndex == 1) { - this->animationIndex = 5; - Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, this->animationIndex); + if (this->animIndex == 2 || this->animIndex == 1) { + this->animIndex = 5; + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, this->animIndex); } this->flags1 |= 0x10; if (this->flags2 & 2) { @@ -890,7 +928,7 @@ void func_80BAC2FC(EnSuttari* this, GlobalContext* globalCtx) { player->stateFlags1 |= 0x10000000; } this->textId = 0x2A30; - Message_StartTextbox(globalCtx, this->textId, &this->actor); + Message_StartTextbox(play, this->textId, &this->actor); this->actionFunc = func_80BAD2B4; } break; @@ -898,60 +936,61 @@ void func_80BAC2FC(EnSuttari* this, GlobalContext* globalCtx) { Math_ApproachS(&this->actor.shape.rot.y, this->actor.world.rot.y, 4, 0x1554); } -void func_80BAC6E8(EnSuttari* this, GlobalContext* globalCtx) { +void func_80BAC6E8(EnSuttari* this, PlayState* play) { ActorShape_Init(&this->actor.shape, 0.0f, NULL, 0.0f); - SkelAnime_InitFlex(globalCtx, &this->skelAnime, &object_boj_Skel_00C240, &object_boj_Anim_00071C, this->jointTable, + SkelAnime_InitFlex(play, &this->skelAnime, &object_boj_Skel_00C240, &object_boj_Anim_00071C, this->jointTable, this->morphTable, 16); this->actor.draw = EnSuttari_Draw; this->actor.flags |= ACTOR_FLAG_1; - if (globalCtx->sceneNum == SCENE_IKANA) { + if (play->sceneNum == SCENE_IKANA) { this->flags1 |= 1; if (gSaveContext.save.day == 1 || gSaveContext.save.day == 2) { - this->animationIndex = 2; - Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, this->animationIndex); + this->animIndex = 2; + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, this->animIndex); this->flags1 |= 0x80; this->actionFunc = func_80BACA14; return; } 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->animIndex = 2; + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, this->animIndex); this->actionFunc = func_80BACEE0; return; } - } else if (globalCtx->sceneNum == SCENE_BACKTOWN) { + } else if (play->sceneNum == SCENE_BACKTOWN) { if (gSaveContext.save.time >= CLOCK_TIME(0, 20) && gSaveContext.save.time < CLOCK_TIME(6, 00)) { Actor_MarkForDeath(&this->actor); } - if ((gSaveContext.save.entranceIndex == 0xD670) || (gSaveContext.save.weekEventReg[58] & 0x40)) { + if ((gSaveContext.save.entrance == ENTRANCE(NORTH_CLOCK_TOWN, 7)) || + (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->animationIndex = 1; - Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, this->animationIndex); + this->animIndex = 1; + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, this->animIndex); this->actionFunc = func_80BAD004; return; - } else if (globalCtx->sceneNum == SCENE_ICHIBA) { + } else if (play->sceneNum == SCENE_ICHIBA) { if (gSaveContext.save.weekEventReg[33] & 8) { Actor_MarkForDeath(&this->actor); return; } - this->animationIndex = 0; - Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, this->animationIndex); + this->animIndex = 0; + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, this->animIndex); this->flags1 |= 2; this->actionFunc = func_80BAD5F8; return; - } else if (globalCtx->sceneNum == SCENE_AYASHIISHOP) { + } else if (play->sceneNum == SCENE_AYASHIISHOP) { if (gSaveContext.save.weekEventReg[33] & 8) { Actor_MarkForDeath(&this->actor); return; } - this->animationIndex = 0; - Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, this->animationIndex); + this->animIndex = 0; + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, this->animIndex); this->cutscenes[0] = this->actor.cutscene; this->cutscenes[1] = ActorCutscene_GetAdditionalCutscene(this->cutscenes[0]); this->flags1 |= 4; @@ -966,45 +1005,46 @@ void func_80BAC6E8(EnSuttari* this, GlobalContext* globalCtx) { Actor_MarkForDeath(&this->actor); } -void func_80BACA14(EnSuttari* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); +void func_80BACA14(EnSuttari* this, PlayState* play) { + Player* player = GET_PLAYER(play); - if (this->animationIndex == 1 || this->animationIndex == 8) { - this->animationIndex = 2; - Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, this->animationIndex); + if (this->animIndex == 1 || this->animIndex == 8) { + this->animIndex = 2; + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, this->animIndex); } 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) && GET_CUR_EQUIP_VALUE(EQUIP_SWORD) != 0) { - if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { - this->unk3F2 = this->unk2DC.y; - func_80BAAB78(this, globalCtx); + } else if ((player->transformation == PLAYER_FORM_HUMAN) && + (GET_CUR_EQUIP_VALUE(EQUIP_TYPE_SWORD) != EQUIP_VALUE_SWORD_NONE)) { + if (Actor_ProcessTalkRequest(&this->actor, &play->state)) { + this->unk3F2 = this->headRot.y; + func_80BAAB78(this, play); this->actionFunc = func_80BADA9C; } else if (this->actor.xzDistToPlayer < 200.0f) { - func_800B8614(&this->actor, globalCtx, 200.0f); + func_800B8614(&this->actor, play, 200.0f); } } Math_ApproachF(&this->actor.speedXZ, 5.0f, 0.2f, 0.1f); Actor_MoveWithGravity(&this->actor); } -void func_80BACBB0(EnSuttari* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); +void func_80BACBB0(EnSuttari* this, PlayState* play) { + Player* player = GET_PLAYER(play); 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; } if ((this->actor.playerHeightRel < 60.0f) && (this->actor.xzDistToPlayer < 500.0f)) { if (this->actor.bgCheckFlags & 8) { target = this->actor.wallYaw; - } else if (func_80BAA904(this, globalCtx)) { + } else if (func_80BAA904(this, play)) { target = -this->actor.world.rot.y; } else { target = -this->actor.yawTowardsPlayer; @@ -1024,10 +1064,10 @@ void func_80BACBB0(EnSuttari* this, GlobalContext* globalCtx) { } } -void func_80BACD2C(EnSuttari* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); +void func_80BACD2C(EnSuttari* this, PlayState* play) { + Player* player = GET_PLAYER(play); - 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; } @@ -1046,7 +1086,7 @@ void func_80BACD2C(EnSuttari* this, GlobalContext* globalCtx) { } } -void func_80BACE4C(EnSuttari* this, GlobalContext* globalCtx) { +void func_80BACE4C(EnSuttari* this, PlayState* play) { if (this->actor.xzDistToPlayer > 100.0f) { this->actionFunc = func_80BACBB0; } @@ -1058,60 +1098,58 @@ void func_80BACE4C(EnSuttari* this, GlobalContext* globalCtx) { } } -void func_80BACEE0(EnSuttari* this, GlobalContext* globalCtx) { - u32* unk_14 = &gSaveContext.save.daySpeed; - struct_80133038_arg2 unkStruct; +void func_80BACEE0(EnSuttari* this, PlayState* play) { + ScheduleOutput scheduleOutput; - this->unk42A = REG(15) + *unk_14; - if (!func_80133038(globalCtx, D_80BAE820, &unkStruct) || - ((this->unk428 != unkStruct.unk0) && !func_80BABF64(this, globalCtx, &unkStruct))) { + this->timePathTimeSpeed = REG(15) + ((void)0, gSaveContext.save.daySpeed); + if (!Schedule_RunScript(play, D_80BAE820, &scheduleOutput) || + ((this->unk428 != scheduleOutput.result) && !func_80BABF64(this, play, &scheduleOutput))) { this->actor.flags &= ~ACTOR_FLAG_1; - unkStruct.unk0 = 0; + scheduleOutput.result = 0; } else { this->actor.flags |= ACTOR_FLAG_1; } - this->unk428 = unkStruct.unk0; - func_80BAC2FC(this, globalCtx); + this->unk428 = scheduleOutput.result; + func_80BAC2FC(this, play); func_80BAB434(this); if (this->unk428 == 5) { gSaveContext.save.weekEventReg[58] |= 0x80; this->actionFunc = func_80BADDB4; this->actor.speedXZ = 0.0f; - } else if (Player_GetMask(globalCtx) != PLAYER_MASK_STONE) { - func_80BAB1A0(this, globalCtx); + } else if (Player_GetMask(play) != PLAYER_MASK_STONE) { + func_80BAB1A0(this, play); } Actor_MoveWithGravity(&this->actor); } -void func_80BAD004(EnSuttari* this, GlobalContext* globalCtx) { - u32* unk_14 = &gSaveContext.save.daySpeed; - struct_80133038_arg2 unkStruct; +void func_80BAD004(EnSuttari* this, PlayState* play) { + ScheduleOutput scheduleOutput; - this->unk42A = REG(15) + *unk_14; - if (!func_80133038(globalCtx, D_80BAE820, &unkStruct) || - ((this->unk428 != unkStruct.unk0) && !func_80BABF64(this, globalCtx, &unkStruct))) { + this->timePathTimeSpeed = REG(15) + ((void)0, gSaveContext.save.daySpeed); + if (!Schedule_RunScript(play, D_80BAE820, &scheduleOutput) || + ((this->unk428 != scheduleOutput.result) && !func_80BABF64(this, play, &scheduleOutput))) { this->actor.flags &= ~ACTOR_FLAG_1; - unkStruct.unk0 = 0; + scheduleOutput.result = 0; } else { this->actor.flags |= ACTOR_FLAG_1; } - this->unk428 = unkStruct.unk0; - func_80BAC2FC(this, globalCtx); - if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { - Message_StartTextbox(globalCtx, 0x2A3A, &this->actor); + this->unk428 = scheduleOutput.result; + func_80BAC2FC(this, play); + if (Actor_ProcessTalkRequest(&this->actor, &play->state)) { + Message_StartTextbox(play, 0x2A3A, &this->actor); this->actionFunc = func_80BAD130; } else if ((this->actor.xzDistToPlayer < 200.0f) || this->actor.isTargeted) { - func_800B863C(&this->actor, globalCtx); + func_800B863C(&this->actor, play); } Actor_MoveWithGravity(&this->actor); } -void func_80BAD130(EnSuttari* this, GlobalContext* globalCtx) { - u8 talkState = Message_GetState(&globalCtx->msgCtx); +void func_80BAD130(EnSuttari* this, PlayState* play) { + u8 talkState = Message_GetState(&play->msgCtx); - if ((talkState == 5 || talkState == 6) && Message_ShouldAdvance(globalCtx)) { - globalCtx->msgCtx.msgMode = 0x43; - globalCtx->msgCtx.unk12023 = 4; + if (((talkState == TEXT_STATE_5) || (talkState == TEXT_STATE_DONE)) && Message_ShouldAdvance(play)) { + play->msgCtx.msgMode = 0x43; + play->msgCtx.stateTimer = 4; if (this->flags1 & 8) { this->actionFunc = func_80BAD004; } else if (this->flags1 & 4) { @@ -1126,11 +1164,11 @@ void func_80BAD130(EnSuttari* this, GlobalContext* globalCtx) { Math_SmoothStepToS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer, 5, 0x1000, 0x100); } -void func_80BAD230(EnSuttari* this, GlobalContext* globalCtx) { +void func_80BAD230(EnSuttari* this, PlayState* play) { if (ActorCutscene_GetCanPlayNext(this->cutscenes[1])) { ActorCutscene_Start(this->cutscenes[1], &this->actor); this->textId = 0x2A31; - Message_StartTextbox(globalCtx, this->textId, &this->actor); + Message_StartTextbox(play, this->textId, &this->actor); this->flags1 |= 0x4000; Audio_QueueSeqCmd(NA_BGM_CHASE | 0x8000); this->actionFunc = func_80BAD380; @@ -1139,40 +1177,40 @@ void func_80BAD230(EnSuttari* this, GlobalContext* globalCtx) { } } -void func_80BAD2B4(EnSuttari* this, GlobalContext* globalCtx) { - if (Message_GetState(&globalCtx->msgCtx) == 5 && Message_ShouldAdvance(globalCtx)) { +void func_80BAD2B4(EnSuttari* this, PlayState* play) { + if ((Message_GetState(&play->msgCtx) == TEXT_STATE_5) && Message_ShouldAdvance(play)) { if (this->textId == 0x2A30) { ActorCutscene_Stop(this->cutscenes[0]); ActorCutscene_SetIntentToPlay(this->cutscenes[1]); this->actionFunc = func_80BAD230; } else { ActorCutscene_Stop(this->cutscenes[1]); - globalCtx->msgCtx.msgMode = 0x43; - globalCtx->msgCtx.unk12023 = 4; + play->msgCtx.msgMode = 0x43; + play->msgCtx.stateTimer = 4; this->flags1 |= 0x40; this->actionFunc = func_80BAD380; } } - func_80BAB374(this, globalCtx); + func_80BAB374(this, play); } -void func_80BAD380(EnSuttari* this, GlobalContext* globalCtx) { - u8 talkState = Message_GetState(&globalCtx->msgCtx); - Player* player = GET_PLAYER(globalCtx); +void func_80BAD380(EnSuttari* this, PlayState* play) { + u8 talkState = Message_GetState(&play->msgCtx); + Player* player = GET_PLAYER(play); - if ((player->stateFlags1 & 0x40) && (globalCtx->msgCtx.currentTextId != 0x2A31)) { + if ((player->stateFlags1 & 0x40) && (play->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) && Message_ShouldAdvance(globalCtx)) { + if ((this->flags1 & 0x4000) && (talkState == TEXT_STATE_5) && Message_ShouldAdvance(play)) { this->flags2 &= ~0x10; player->stateFlags1 &= ~0x10000000; this->flags1 &= ~0x4000; ActorCutscene_Stop(this->cutscenes[1]); - globalCtx->msgCtx.msgMode = 0x43; - globalCtx->msgCtx.unk12023 = 4; + play->msgCtx.msgMode = 0x43; + play->msgCtx.stateTimer = 4; this->flags1 |= 0x40; } if (this->flags1 & 0x100) { @@ -1182,9 +1220,9 @@ void func_80BAD380(EnSuttari* this, GlobalContext* globalCtx) { 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, - this->actor.world.pos.y, this->actor.world.pos.z, 0, 0, 0, CLEAR_TAG_SMALL_EXPLOSION); - SoundSource_PlaySfxAtFixedWorldPos(globalCtx, &this->actor.world.pos, 30, NA_SE_IT_BOMB_EXPLOSION); + Actor_Spawn(&play->actorCtx, play, ACTOR_EN_CLEAR_TAG, this->actor.world.pos.x, this->actor.world.pos.y, + this->actor.world.pos.z, 0, 0, 0, CLEAR_TAG_SMALL_EXPLOSION); + SoundSource_PlaySfxAtFixedWorldPos(play, &this->actor.world.pos, 30, NA_SE_IT_BOMB_EXPLOSION); Actor_MarkForDeath(&this->actor); return; } @@ -1195,127 +1233,125 @@ void func_80BAD380(EnSuttari* this, GlobalContext* globalCtx) { this->actor.speedXZ = 0.0f; Audio_QueueSeqCmd(0x101400FF); this->flags2 |= 4; - EnSuttari_SetNextEntrance(globalCtx, 0xD670); + EnSuttari_TriggerTransition(play, ENTRANCE(NORTH_CLOCK_TOWN, 7)); } 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); + func_80BAB374(this, play); } } } -void func_80BAD5F8(EnSuttari* this, GlobalContext* globalCtx) { - u32* unk_14 = &gSaveContext.save.daySpeed; - struct_80133038_arg2 unkStruct; +void func_80BAD5F8(EnSuttari* this, PlayState* play) { + ScheduleOutput scheduleOutput; s16 curFrame = this->skelAnime.curFrame; - s16 frameCount = Animation_GetLastFrame(sAnimations[this->animationIndex].animation); + s16 frameCount = Animation_GetLastFrame(sAnimationInfo[this->animIndex].animation); - if ((curFrame == frameCount) && (this->animationIndex == 0) && (this->flags1 & 0x20)) { - this->animationIndex = 2; - Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, this->animationIndex); + if ((curFrame == frameCount) && (this->animIndex == 0) && (this->flags1 & 0x20)) { + this->animIndex = 2; + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, this->animIndex); } - this->unk42A = REG(15) + *unk_14; - if (!func_80133038(globalCtx, D_80BAE820, &unkStruct) || - ((this->unk428 != unkStruct.unk0) && !func_80BABF64(this, globalCtx, &unkStruct))) { + this->timePathTimeSpeed = REG(15) + ((void)0, gSaveContext.save.daySpeed); + if (!Schedule_RunScript(play, D_80BAE820, &scheduleOutput) || + ((this->unk428 != scheduleOutput.result) && !func_80BABF64(this, play, &scheduleOutput))) { this->actor.flags &= ~ACTOR_FLAG_1; - unkStruct.unk0 = 0; + scheduleOutput.result = 0; } else { this->actor.flags |= ACTOR_FLAG_1; } - this->unk428 = unkStruct.unk0; - func_80BAC2FC(this, globalCtx); - if ((this->unk430 == 1) && (this->unk404->unk1 == 0xFF)) { + this->unk428 = scheduleOutput.result; + func_80BAC2FC(this, play); + if ((this->unk430 == 1) && (this->timePath->unk1 == 0xFF)) { Actor_MarkForDeath(&this->actor); return; } func_80BAB434(this); - if ((this->flags1 & 0x20) && (this->unk430 == 0) && (unkStruct.unk0 != 7)) { - if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { - Message_StartTextbox(globalCtx, 0x2A02, &this->actor); + if ((this->flags1 & 0x20) && (this->unk430 == 0) && (scheduleOutput.result != 7)) { + if (Actor_ProcessTalkRequest(&this->actor, &play->state)) { + Message_StartTextbox(play, 0x2A02, &this->actor); this->actionFunc = func_80BAD130; } else if ((this->actor.xzDistToPlayer < 100.0f) || this->actor.isTargeted) { - func_800B863C(&this->actor, globalCtx); + func_800B863C(&this->actor, play); } } Actor_MoveWithGravity(&this->actor); } -void func_80BAD7F8(EnSuttari* this, GlobalContext* globalCtx) { - u32* unk_14 = &gSaveContext.save.daySpeed; - struct_80133038_arg2 unkStruct; +void func_80BAD7F8(EnSuttari* this, PlayState* play) { + ScheduleOutput scheduleOutput; s16 curFrame = this->skelAnime.curFrame; - s16 frameCount = Animation_GetLastFrame(sAnimations[this->animationIndex].animation); + s16 frameCount = Animation_GetLastFrame(sAnimationInfo[this->animIndex].animation); if (this->enFsn == NULL) { - this->enFsn = (EnFsn*)EnSuttari_GetActorById(globalCtx, ACTOR_EN_FSN); + this->enFsn = (EnFsn*)EnSuttari_GetActorById(play, ACTOR_EN_FSN); } else { - if ((this->flags1 & 0x2000) && (this->animationIndex == 1) && (curFrame == frameCount)) { - this->animationIndex = 2; - Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, this->animationIndex); + if ((this->flags1 & 0x2000) && (this->animIndex == 1) && (curFrame == frameCount)) { + this->animIndex = 2; + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, this->animIndex); } - this->unk42A = REG(15) + *unk_14; - if (!func_80133038(globalCtx, D_80BAE820, &unkStruct) || - ((this->unk428 != unkStruct.unk0) && !func_80BABF64(this, globalCtx, &unkStruct))) { + this->timePathTimeSpeed = REG(15) + ((void)0, gSaveContext.save.daySpeed); + if (!Schedule_RunScript(play, D_80BAE820, &scheduleOutput) || + ((this->unk428 != scheduleOutput.result) && !func_80BABF64(this, play, &scheduleOutput))) { this->actor.flags &= ~ACTOR_FLAG_1; - unkStruct.unk0 = 0; + scheduleOutput.result = 0; } else { this->actor.flags |= ACTOR_FLAG_1; } - this->unk428 = unkStruct.unk0; - func_80BAC2FC(this, globalCtx); - if ((this->unk430 == 1) && (this->unk404->unk1 == 0xFF)) { + this->unk428 = scheduleOutput.result; + func_80BAC2FC(this, play); + if ((this->unk430 == 1) && (this->timePath->unk1 == 0xFF)) { Actor_MarkForDeath(&this->actor); return; } - if ((this->flags1 & 0x20) && (unkStruct.unk0 != 9)) { - if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { - Message_StartTextbox(globalCtx, 0x2A02, &this->actor); + if ((this->flags1 & 0x20) && (scheduleOutput.result != 9)) { + if (Actor_ProcessTalkRequest(&this->actor, &play->state)) { + Message_StartTextbox(play, 0x2A02, &this->actor); this->actionFunc = func_80BAD130; } else if ((this->actor.xzDistToPlayer < 100.0f) || this->actor.isTargeted) { - func_800B863C(&this->actor, globalCtx); + func_800B863C(&this->actor, play); } } Actor_MoveWithGravity(&this->actor); } } -void func_80BADA08(EnSuttari* this, GlobalContext* globalCtx) { - if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { +void func_80BADA08(EnSuttari* this, PlayState* play) { + if (Actor_ProcessTalkRequest(&this->actor, &play->state)) { this->actor.flags &= ~ACTOR_FLAG_10000; - func_80BAAB78(this, globalCtx); + func_80BAAB78(this, play); gSaveContext.save.weekEventReg[81] |= 4; } else if (this->actor.xzDistToPlayer < 500.0f) { this->actor.flags |= ACTOR_FLAG_10000; - func_800B8614(&this->actor, globalCtx, 500.0f); + func_800B8614(&this->actor, play, 500.0f); } } -void func_80BADA9C(EnSuttari* this, GlobalContext* globalCtx) { - u8 talkstate = Message_GetState(&globalCtx->msgCtx); +void func_80BADA9C(EnSuttari* this, PlayState* play) { + u8 talkstate = Message_GetState(&play->msgCtx); s16 curFrame = this->skelAnime.curFrame; - s16 frameCount = Animation_GetLastFrame(sAnimations[this->animationIndex].animation); + s16 frameCount = Animation_GetLastFrame(sAnimationInfo[this->animIndex].animation); if (this->flags1 & 1) { - this->unk3F2 = this->unk2DC.y; + this->unk3F2 = this->headRot.y; func_80BAA9B4(this); - } else if ((this->animationIndex == 7) && (curFrame == frameCount)) { - this->animationIndex = 1; - Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, this->animationIndex); + } else if ((this->animIndex == 7) && (curFrame == frameCount)) { + this->animIndex = 1; + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, this->animIndex); } - if (talkstate == 5) { - if (Message_ShouldAdvance(globalCtx)) { + if (talkstate == TEXT_STATE_5) { + if (Message_ShouldAdvance(play)) { if (this->flags1 & 0x400) { if (this->textId == 0x29EE) { ActorCutscene_Stop(this->cutscenes[this->cutsceneIdx]); } this->flags1 &= ~0x400; if (this->flags2 & 1) { - ((EnElf*)GET_PLAYER(globalCtx)->tatlActor)->unk_264 |= 0x10; + ((EnElf*)GET_PLAYER(play)->tatlActor)->unk_264 |= 0x10; this->flags2 &= ~1; } - globalCtx->msgCtx.msgMode = 0x43; - globalCtx->msgCtx.unk12023 = 4; + play->msgCtx.msgMode = 0x43; + play->msgCtx.stateTimer = 4; this->textId = 0; if (this->flags1 & 1) { this->actionFunc = func_80BACA14; @@ -1324,18 +1360,18 @@ void func_80BADA9C(EnSuttari* this, GlobalContext* globalCtx) { } return; } - func_80BAAB78(this, globalCtx); + func_80BAAB78(this, play); } - } else if ((talkstate == 4) && Message_ShouldAdvance(globalCtx)) { - switch (globalCtx->msgCtx.choiceIndex) { + } else if ((talkstate == TEXT_STATE_CHOICE) && Message_ShouldAdvance(play)) { + switch (play->msgCtx.choiceIndex) { case 0: func_8019F208(); this->flags1 |= 0x800; - func_80BAAB78(this, globalCtx); + func_80BAAB78(this, play); break; case 1: func_8019F230(); - func_80BAAB78(this, globalCtx); + func_80BAAB78(this, play); break; } } @@ -1345,7 +1381,7 @@ void func_80BADA9C(EnSuttari* this, GlobalContext* globalCtx) { } } -void func_80BADD0C(EnSuttari* this, GlobalContext* globalCtx) { +void func_80BADD0C(EnSuttari* this, PlayState* play) { if (ActorCutscene_GetCanPlayNext(this->cutscenes[this->cutsceneIdx])) { if (this->cutsceneIdx == 0) { ActorCutscene_Start(this->cutscenes[this->cutsceneIdx], &this->enFsn->actor); @@ -1359,7 +1395,7 @@ void func_80BADD0C(EnSuttari* this, GlobalContext* globalCtx) { } } -void func_80BADDB4(EnSuttari* this, GlobalContext* globalCtx) { +void func_80BADDB4(EnSuttari* this, PlayState* play) { func_80BABA90(this, 1, 1); func_80BAB434(this); if (gSaveContext.save.weekEventReg[51] & 0x10) { @@ -1368,43 +1404,43 @@ void func_80BADDB4(EnSuttari* this, GlobalContext* globalCtx) { Actor_MoveWithGravity(&this->actor); } -void func_80BADE14(EnSuttari* this, GlobalContext* globalCtx) { +void func_80BADE14(EnSuttari* this, PlayState* play) { func_80BABA90(this, 1, 2); 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; +void func_80BADE8C(EnSuttari* this, PlayState* play) { + 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)) { + if (Actor_ProcessTalkRequest(&this->actor, &play->state)) { this->actor.flags &= ~ACTOR_FLAG_10000; - Message_StartTextbox(globalCtx, 0x2A3A, &this->actor); + Message_StartTextbox(play, 0x2A3A, &this->actor); this->actionFunc = func_80BAD130; } else { this->actor.flags |= ACTOR_FLAG_10000; - func_800B8614(&this->actor, globalCtx, 500.0f); + func_800B8614(&this->actor, play, 500.0f); } } -void func_80BADF3C(EnSuttari* this, GlobalContext* globalCtx) { +void func_80BADF3C(EnSuttari* this, PlayState* play) { func_80BABB90(this, 0); 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); } Actor_MoveWithGravity(&this->actor); } -void EnSuttari_Init(Actor* thisx, GlobalContext* globalCtx) { +void EnSuttari_Init(Actor* thisx, PlayState* play) { EnSuttari* this = THIS; s32 pad; @@ -1412,46 +1448,46 @@ void EnSuttari_Init(Actor* thisx, GlobalContext* globalCtx) { Actor_MarkForDeath(&this->actor); return; } - Collider_InitCylinder(globalCtx, &this->collider); - Collider_InitAndSetCylinder(globalCtx, &this->collider, &this->actor, &sCylinderInit); + Collider_InitCylinder(play, &this->collider); + Collider_InitAndSetCylinder(play, &this->collider, &this->actor, &sCylinderInit); CollisionCheck_SetInfo2(&this->actor.colChkInfo, &sDamageTable, &sColChkInfoInit2); this->actor.flags &= ~ACTOR_FLAG_1; - EnSuttari_GetPaths(this, globalCtx); + EnSuttari_GetPaths(this, play); Actor_SetScale(&this->actor, 0.01f); this->actionFunc = func_80BAC6E8; this->actor.gravity = -4.0f; } -void EnSuttari_Destroy(Actor* thisx, GlobalContext* globalCtx) { +void EnSuttari_Destroy(Actor* thisx, PlayState* play) { EnSuttari* this = THIS; - if ((globalCtx->sceneNum == SCENE_BACKTOWN) && !(this->flags2 & 4)) { + if ((play->sceneNum == SCENE_BACKTOWN) && !(this->flags2 & 4)) { Audio_QueueSeqCmd(0x101400FF); } - Collider_DestroyCylinder(globalCtx, &this->collider); + Collider_DestroyCylinder(play, &this->collider); } -void EnSuttari_Update(Actor* thisx, GlobalContext* globalCtx) { +void EnSuttari_Update(Actor* thisx, PlayState* play) { EnSuttari* this = THIS; s32 pad; - Player* player = GET_PLAYER(globalCtx); + Player* player = GET_PLAYER(play); - this->actionFunc(this, globalCtx); + this->actionFunc(this, play); if ((this->flags1 & 8) && (this->flags2 & 0x10) && (player->stateFlags1 & 0x10000000)) { player->actor.freezeTimer = 3; } if (!(this->flags1 & 0x8000)) { - func_80BAB4F0(this, globalCtx); + func_80BAB4F0(this, play); } if (this->flags2 & 2) { EnSuttari_UpdateTime(); } if (this->unk428 != 0) { - if (this->animationIndex == 2 || this->animationIndex == 6) { + if (this->animIndex == 2 || this->animIndex == 6) { if (Animation_OnFrame(&this->skelAnime, 8.0f) || Animation_OnFrame(&this->skelAnime, 16.0f)) { Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_PAMERA_WALK); } - } else if (this->animationIndex == 0 || this->animationIndex == 5) { + } else if (this->animIndex == 0 || this->animIndex == 5) { if (Animation_OnFrame(&this->skelAnime, 8.0f) || Animation_OnFrame(&this->skelAnime, 17.0f)) { Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_PAMERA_WALK); } @@ -1459,22 +1495,21 @@ void EnSuttari_Update(Actor* thisx, GlobalContext* globalCtx) { } } -s32 EnSuttari_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, - Actor* thisx) { +s32 EnSuttari_OverrideLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, Actor* thisx) { EnSuttari* this = THIS; 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); @@ -1483,7 +1518,7 @@ s32 EnSuttari_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dL return false; } -void EnSuttari_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx) { +void EnSuttari_PostLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx) { static Vec3f D_80BAE950 = { 0.0f, 0.0f, 0.0f }; static Vec3f D_80BAE95C = { 2000.0f, -1000.0f, 0.0f }; EnSuttari* this = THIS; @@ -1494,56 +1529,56 @@ 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); + Actor_SpawnAsChild(&play->actorCtx, &this->actor, play, 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); - OPEN_DISPS(globalCtx->state.gfxCtx); + func_8012C28C(play->state.gfxCtx); + OPEN_DISPS(play->state.gfxCtx); gSPDisplayList(POLY_OPA_DISP++, object_boj_DL_013380); - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->state.gfxCtx); } } } } if (limbIndex == 15) { - Matrix_MultiplyVector3fByState(&D_80BAE950, &this->actor.focus.pos); + Matrix_MultVec3f(&D_80BAE950, &this->actor.focus.pos); } } -void EnSuttari_TransformLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Actor* thisx) { +void EnSuttari_TransformLimbDraw(PlayState* play, s32 limbIndex, Actor* thisx) { } -void EnSuttari_Draw(Actor* thisx, GlobalContext* globalCtx) { +void EnSuttari_Draw(Actor* thisx, PlayState* play) { EnSuttari* this = THIS; s32 pad; Vec3f sp5C; Vec3f sp50; if (this->flags1 & 0x80) { - 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)); + OPEN_DISPS(play->state.gfxCtx); + func_8012C28C(play->state.gfxCtx); + gSPSegment(POLY_OPA_DISP++, 0x08, Gfx_EnvColor(play->state.gfxCtx, 255, 255, 255, 0)); + gSPSegment(POLY_OPA_DISP++, 0x09, Gfx_EnvColor(play->state.gfxCtx, 55, 55, 255, 0)); gDPPipeSync(POLY_OPA_DISP++); - SkelAnime_DrawTransformFlexOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, + SkelAnime_DrawTransformFlexOpa(play, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, EnSuttari_OverrideLimbDraw, EnSuttari_PostLimbDraw, EnSuttari_TransformLimbDraw, &this->actor); if (this->flags1 & 0x80) { - func_8012C2DC(globalCtx->state.gfxCtx); + func_8012C2DC(play->state.gfxCtx); sp5C = this->actor.world.pos; sp50.x = 0.2f; sp50.y = 0.2f; sp50.z = 0.2f; - func_800BC620(&sp5C, &sp50, 0xFF, globalCtx); + func_800BC620(&sp5C, &sp50, 0xFF, play); } - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->state.gfxCtx); } } diff --git a/src/overlays/actors/ovl_En_Suttari/z_en_suttari.h b/src/overlays/actors/ovl_En_Suttari/z_en_suttari.h index c6f8cc153..35a9b6e2e 100644 --- a/src/overlays/actors/ovl_En_Suttari/z_en_suttari.h +++ b/src/overlays/actors/ovl_En_Suttari/z_en_suttari.h @@ -6,7 +6,7 @@ struct EnSuttari; -typedef void (*EnSuttariActionFunc)(struct EnSuttari*, GlobalContext*); +typedef void (*EnSuttariActionFunc)(struct EnSuttari*, PlayState*); #define ENSUTTARI_GET_PATH(thisx) (((thisx)->params & 0x7E00) >> 9) @@ -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 animationIndex; + /* 0x450 */ s32 animIndex; /* 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 f0d1a3aa7..a69cbe213 100644 --- a/src/overlays/actors/ovl_En_Sw/z_en_sw.c +++ b/src/overlays/actors/ovl_En_Sw/z_en_sw.c @@ -11,22 +11,22 @@ #define THIS ((EnSw*)thisx) -void EnSw_Init(Actor* thisx, GlobalContext* globalCtx); -void EnSw_Destroy(Actor* thisx, GlobalContext* globalCtx); -void EnSw_Update(Actor* thisx, GlobalContext* globalCtx); -void EnSw_Draw(Actor* thisx, GlobalContext* globalCtx); +void EnSw_Init(Actor* thisx, PlayState* play); +void EnSw_Destroy(Actor* thisx, PlayState* play); +void EnSw_Update(Actor* thisx, PlayState* play); +void EnSw_Draw(Actor* thisx, PlayState* play); -void func_808DA350(EnSw* this, GlobalContext* globalCtx); -void func_808DA3F4(EnSw* this, GlobalContext* globalCtx); -void func_808DA578(EnSw* this, GlobalContext* globalCtx); -void func_808DA6FC(EnSw* this, GlobalContext* globalCtx); -void func_808DA89C(EnSw* this, GlobalContext* globalCtx); -void func_808DAA60(EnSw* this, GlobalContext* globalCtx); -void func_808DACF4(EnSw* this, GlobalContext* globalCtx); -void func_808DAEB4(EnSw* this, GlobalContext* globalCtx); -void func_808DB100(EnSw* this, GlobalContext* globalCtx); -void func_808DB25C(EnSw* this, GlobalContext* globalCtx); -void func_808DB2E0(EnSw* this, GlobalContext* globalCtx); +void func_808DA350(EnSw* this, PlayState* play); +void func_808DA3F4(EnSw* this, PlayState* play); +void func_808DA578(EnSw* this, PlayState* play); +void func_808DA6FC(EnSw* this, PlayState* play); +void func_808DA89C(EnSw* this, PlayState* play); +void func_808DAA60(EnSw* this, PlayState* play); +void func_808DACF4(EnSw* this, PlayState* play); +void func_808DAEB4(EnSw* this, PlayState* play); +void func_808DB100(EnSw* this, PlayState* play); +void func_808DB25C(EnSw* this, PlayState* play); +void func_808DB2E0(EnSw* this, PlayState* play); const ActorInit En_Sw_InitVars = { ACTOR_EN_SW, @@ -134,14 +134,14 @@ static DamageTable sDamageTable2 = { /* Powder Keg */ DMG_ENTRY(1, 0x0), }; -static AnimationInfoS sAnimations[] = { +static AnimationInfoS sAnimationInfo[] = { { &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) { +void func_808D8940(EnSw* this, PlayState* play) { static Color_RGBA8 D_808DBAA4 = { 170, 130, 90, 255 }; static Color_RGBA8 D_808DBAA8 = { 100, 60, 20, 0 }; s32 i; @@ -167,7 +167,7 @@ void func_808D8940(EnSw* this, GlobalContext* globalCtx) { Lib_Vec3f_TranslateAndRotateY(&gZeroVec3f, temp_s0, &sp94, &spB8); spA0.x = this->actor.world.pos.x + (2.0f * spB8.x); spA0.z = this->actor.world.pos.z + (2.0f * spB8.z); - func_800B0EB0(globalCtx, &spA0, &spB8, &spAC, &D_808DBAA4, &D_808DBAA8, 60, 30, temp_f4); + func_800B0EB0(play, &spA0, &spB8, &spAC, &D_808DBAA4, &D_808DBAA8, 60, 30, temp_f4); } } @@ -196,7 +196,7 @@ s32 func_808D8B58(EnSw* this) { return 0; } -s32 func_808D8D60(EnSw* this, GlobalContext* globalCtx, s32 arg2) { +s32 func_808D8D60(EnSw* this, PlayState* play, s32 arg2) { s32 ret = false; u8 drawDmgEffType; Vec3f limbPos[1]; @@ -217,7 +217,7 @@ s32 func_808D8D60(EnSw* this, GlobalContext* globalCtx, s32 arg2) { } drawDmgEffAlpha = 1.0f; } - Actor_DrawDamageEffects(globalCtx, &this->actor, limbPos, ARRAY_COUNT(limbPos), 0.3f, + Actor_DrawDamageEffects(play, &this->actor, limbPos, ARRAY_COUNT(limbPos), 0.3f, this->drawDmgEffFrozenSteamScales[arg2], drawDmgEffAlpha, drawDmgEffType); ret = true; } @@ -225,7 +225,7 @@ s32 func_808D8D60(EnSw* this, GlobalContext* globalCtx, s32 arg2) { return ret; } -void func_808D8ED0(EnSw* this, GlobalContext* globalCtx) { +void func_808D8ED0(EnSw* this, PlayState* play) { Vec3f sp54; s32 i; @@ -236,22 +236,22 @@ void func_808D8ED0(EnSw* this, GlobalContext* globalCtx) { sp54.z += this->unk_380[i].z; Math_Vec3f_Copy(&this->unk_380[i], &sp54); } - Actor_SpawnIceEffects(globalCtx, &this->actor, this->unk_380, ARRAY_COUNT(this->unk_380), 3, 0.1f, 0.3f); + Actor_SpawnIceEffects(play, &this->actor, this->unk_380, ARRAY_COUNT(this->unk_380), 3, 0.1f, 0.3f); } -void func_808D8FC4(EnSw* this, GlobalContext* globalCtx) { +void func_808D8FC4(EnSw* this, PlayState* play) { Math_Vec3f_ToVec3s(&this->collider.dim.worldSphere.center, &this->actor.world.pos); this->collider.dim.worldSphere.radius = this->collider.dim.modelSphere.radius * this->collider.dim.scale; if (!(this->unk_410 & 0x10) && (this->actor.colChkInfo.health != 0) && (DECR(this->unk_458) <= 10)) { - CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + CollisionCheck_SetAC(play, &play->colChkCtx, &this->collider.base); } if (!(this->unk_410 & 0x10) && (this->actor.colChkInfo.health != 0)) { - CollisionCheck_SetAT(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + CollisionCheck_SetAT(play, &play->colChkCtx, &this->collider.base); } if (this->unk_410 & 4) { - CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + CollisionCheck_SetOC(play, &play->colChkCtx, &this->collider.base); } } @@ -277,8 +277,8 @@ void func_808D90F0(EnSw* this, s32 arg1, s16 arg2) { temp = arg2; } - Matrix_InsertRotationAroundUnitVector_f(BINANG_TO_RAD(temp), &this->unk_368, MTXMODE_NEW); - 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); } @@ -316,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); @@ -336,31 +336,30 @@ 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; } -s32 func_808D9440(GlobalContext* globalCtx, Vec3f* posA, Vec3f* posB, Vec3f* posResult, CollisionPoly** outPoly, - s32* bgId) { +s32 func_808D9440(PlayState* play, Vec3f* posA, Vec3f* posB, Vec3f* posResult, CollisionPoly** outPoly, s32* bgId) { s32 ret = false; - if (BgCheck_EntityLineTest1(&globalCtx->colCtx, posA, posB, posResult, outPoly, true, true, true, true, bgId) && - !(func_800C9A4C(&globalCtx->colCtx, *outPoly, *bgId) & 0x30)) { + if (BgCheck_EntityLineTest1(&play->colCtx, posA, posB, posResult, outPoly, true, true, true, true, bgId) && + !(func_800C9A4C(&play->colCtx, *outPoly, *bgId) & 0x30)) { ret = true; } return ret; } #ifdef NON_MATCHING -void func_808D94D0(EnSw* this, GlobalContext* globalCtx, s32 arg2, s32 arg3, s16 arg4) { +void func_808D94D0(EnSw* this, PlayState* play, s32 arg2, s32 arg3, s16 arg4) { CollisionPoly* spA4; CollisionPoly* spA0; s32 pad; @@ -390,11 +389,11 @@ void func_808D94D0(EnSw* this, GlobalContext* globalCtx, s32 arg2, s32 arg3, s16 sp84.y = this->actor.world.pos.y - (this->unk_368.y * 4.0f); sp84.z = this->actor.world.pos.z - (this->unk_368.z * 4.0f); - if (func_808D9440(globalCtx, &sp90, &sp84, &sp6C, &spA0, &sp68)) { + if (func_808D9440(play, &sp90, &sp84, &sp6C, &spA0, &sp68)) { sp84.x = (this->unk_350.x * temp_f20) + sp90.x; sp84.y = (this->unk_350.y * temp_f20) + sp90.y; sp84.z = (this->unk_350.z * temp_f20) + sp90.z; - if (func_808D9440(globalCtx, &sp90, &sp84, &sp78, &spA4, &sp64)) { + if (func_808D9440(play, &sp90, &sp84, &sp78, &spA4, &sp64)) { func_808D91C4(this, spA4); Math_Vec3f_Copy(&this->actor.world.pos, &sp78); this->actor.floorBgId = sp64; @@ -427,7 +426,7 @@ void func_808D94D0(EnSw* this, GlobalContext* globalCtx, s32 arg2, s32 arg3, s16 sp84.z = sp90.z - (this->unk_35C.z * temp_f20); } - if (func_808D9440(globalCtx, &sp90, &sp84, &sp78, &spA4, &sp64)) { + if (func_808D9440(play, &sp90, &sp84, &sp78, &spA4, &sp64)) { func_808D91C4(this, spA4); Math_Vec3f_Copy(&this->actor.world.pos, &sp78); this->actor.floorBgId = sp64; @@ -450,6 +449,7 @@ void func_808D94D0(EnSw* this, GlobalContext* globalCtx, s32 arg2, s32 arg3, s16 } } #else +void func_808D94D0(EnSw* this, PlayState* play, s32 arg2, s32 arg3, s16 arg4); #pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Sw/func_808D94D0.s") #endif @@ -458,38 +458,38 @@ 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) { +s32 func_808D9968(EnSw* this, PlayState* play) { s32 ret = false; - s32 param = ENSW_GET_3FC(&this->actor) & 0xFF; + s32 param = ENSW_GET_3FC(&this->actor); if (ENSW_GET_3(&this->actor)) { - if ((param != 0x3F) && Flags_GetTreasure(globalCtx, param)) { + if ((param != 0x3F) && Flags_GetTreasure(play, param)) { ret = true; } } @@ -497,15 +497,15 @@ s32 func_808D9968(EnSw* this, GlobalContext* globalCtx) { return ret; } -s32 func_808D99C8(EnSw* this, GlobalContext* globalCtx) { +s32 func_808D99C8(EnSw* this, PlayState* play) { s32 phi_v1 = 0; if (ENSW_GET_3(&this->actor) || (this->unk_458 > 10) || (this->actor.colChkInfo.health == 0)) { return false; } - if ((this->actor.xyzDistToPlayerSq < ((sREG(16) * 10) + 60000)) && (globalCtx->actorCtx.unk1F5 != 0) && - (globalCtx->actorCtx.unk1F4 == 0)) { + if ((this->actor.xyzDistToPlayerSq < ((sREG(16) * 10) + 60000)) && (play->actorCtx.unk1F5 != 0) && + (play->actorCtx.unk1F4 == 0)) { this->actor.colChkInfo.damage = 4; phi_v1 = true; } @@ -513,7 +513,7 @@ s32 func_808D99C8(EnSw* this, GlobalContext* globalCtx) { return phi_v1; } -s32 func_808D9A70(EnSw* this, GlobalContext* globalCtx) { +s32 func_808D9A70(EnSw* this, PlayState* play) { s16 sp2E = 0; f32 frame; @@ -543,7 +543,7 @@ s32 func_808D9A70(EnSw* this, GlobalContext* globalCtx) { } } } - func_808D94D0(this, globalCtx, 0, 0, sp2E); + func_808D94D0(this, play, 0, 0, sp2E); } return false; @@ -629,15 +629,15 @@ void func_808D9F08(EnSw* this) { this->unk_45E = this->unk_460; } -void func_808D9F78(EnSw* this, GlobalContext* globalCtx, s32 arg2) { +void func_808D9F78(EnSw* this, PlayState* play, s32 arg2) { if (arg2 != 0) { - func_800BC154(globalCtx, &globalCtx->actorCtx, &this->actor, 5); + func_800BC154(play, &play->actorCtx, &this->actor, 5); } Actor_SetScale(&this->actor, 0.02f); func_808D9DA0(this); this->actor.speedXZ = 10.0f; this->unk_44C = 10.0f; - func_808D94D0(this, globalCtx, 0, 0, 0); + func_808D94D0(this, play, 0, 0, 0); this->actor.speedXZ = 0.0f; this->unk_44C = 0.0f; this->unk_450 = 1.0f; @@ -645,26 +645,26 @@ void func_808D9F78(EnSw* this, GlobalContext* globalCtx, s32 arg2) { this->unk_410 |= 4; } -void func_808DA024(EnSw* this, GlobalContext* globalCtx) { +void func_808DA024(EnSw* this, PlayState* play) { func_808D9DA0(this); this->actor.speedXZ = 10.0f; this->unk_44C = 10.0f; - func_808D94D0(this, globalCtx, 0, 0, 0); + func_808D94D0(this, play, 0, 0, 0); this->actor.speedXZ = 0.0f; this->unk_44C = 0.0f; this->unk_450 = 1.0f; } -s32 func_808DA08C(EnSw* this, GlobalContext* globalCtx) { +s32 func_808DA08C(EnSw* this, PlayState* play) { s32 ret = 0; s32 i; - if (func_808D99C8(this, globalCtx) || (this->collider.base.acFlags & AC_HIT)) { + if (func_808D99C8(this, play) || (this->collider.base.acFlags & AC_HIT)) { this->collider.base.acFlags &= ~AC_HIT; if (this->actor.colChkInfo.damageEffect == 4) { - Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_CLEAR_TAG, this->actor.world.pos.x, - this->actor.world.pos.y, this->actor.world.pos.z, 0, 0, 0, CLEAR_TAG_LARGE_LIGHT_RAYS); + Actor_Spawn(&play->actorCtx, play, ACTOR_EN_CLEAR_TAG, this->actor.world.pos.x, this->actor.world.pos.y, + this->actor.world.pos.z, 0, 0, 0, CLEAR_TAG_LARGE_LIGHT_RAYS); } if (this->drawDmgEffType == ACTOR_DRAW_DMGEFF_FROZEN_NO_SFX) { @@ -674,11 +674,11 @@ s32 func_808DA08C(EnSw* this, GlobalContext* globalCtx) { this->unk_45C = 0; } else if (!func_808D90C4(this)) { - SoundSource_PlaySfxAtFixedWorldPos(globalCtx, &this->actor.world.pos, 40, NA_SE_EN_STALTU_DEAD); - Enemy_StartFinishingBlow(globalCtx, &this->actor); + SoundSource_PlaySfxAtFixedWorldPos(play, &this->actor.world.pos, 40, NA_SE_EN_STALTU_DEAD); + Enemy_StartFinishingBlow(play, &this->actor); this->actor.flags &= ~ACTOR_FLAG_1; if (!ENSW_GET_3(&this->actor)) { - SubS_ChangeAnimationByInfoS(&this->skelAnime, sAnimations, 3); + SubS_ChangeAnimationByInfoS(&this->skelAnime, sAnimationInfo, 3); } switch (this->actor.colChkInfo.damageEffect) { @@ -735,8 +735,8 @@ s32 func_808DA08C(EnSw* this, GlobalContext* globalCtx) { return ret; } -void func_808DA350(EnSw* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); +void func_808DA350(EnSw* this, PlayState* play) { + Player* player = GET_PLAYER(play); if ((player->stateFlags1 & 0x200000) && (this->actor.xyzDistToPlayerSq < 8000.0f)) { Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_STALWALL_LAUGH); @@ -745,11 +745,11 @@ void func_808DA350(EnSw* this, GlobalContext* globalCtx) { this->unk_414 = 0.0f; this->actionFunc = func_808DA3F4; } else { - func_808D9A70(this, globalCtx); + func_808D9A70(this, play); } } -void func_808DA3F4(EnSw* this, GlobalContext* globalCtx) { +void func_808DA3F4(EnSw* this, PlayState* play) { s16 temp_v0; s16 temp_s1 = 0; Vec3f sp38; @@ -778,24 +778,24 @@ void func_808DA3F4(EnSw* this, GlobalContext* globalCtx) { Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_STALWALL_ROLL); this->skelAnime.curFrame = 0.0f; } - func_808D94D0(this, globalCtx, 0, 0, temp_s1); + func_808D94D0(this, play, 0, 0, temp_s1); } -#ifdef NON_MATCHING -void func_808DA578(EnSw* this, GlobalContext* globalCtx) { +void func_808DA578(EnSw* this, PlayState* play) { f32 temp_f0; - s32 test; - s32 test2; + f32 temp; + s16 temp2; Vec3f sp30; if (!Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) { temp_f0 = this->skelAnime.endFrame - this->skelAnime.curFrame; this->unk_44C = 0.3f * temp_f0; - func_808D94D0(this, globalCtx, 1, 0, 0); + func_808D94D0(this, play, 1, 0, 0); if ((this->actor.speedXZ == 0.0f) && (this->unk_44C != 0.0f)) { Math_Vec3f_Copy(&sp30, &this->unk_374); func_808D9894(this, &sp30); - func_808D94D0(this, globalCtx, 0, 0, Math_FAtan2F(sp30.z, sp30.x)); + temp2 = Math_FAtan2F(sp30.z, sp30.x); + func_808D94D0(this, play, 0, 0, temp2); } } else if (this->unk_410 & 0x20) { Math_Vec3f_Copy(&this->unk_374, &this->actor.home.pos); @@ -805,36 +805,28 @@ void func_808DA578(EnSw* this, GlobalContext* globalCtx) { this->skelAnime.curFrame = 0.0f; } - temp_f0 = Math_Vec3f_DistXYZ(&this->actor.world.pos, &this->unk_374); - if (!(this->unk_410 & 0x20)) { - test = this->unk_414; - test2 = temp_f0; - if ((test != 0) && (test < test2)) { - this->unk_410 |= 0x20; - } + temp = Math_Vec3f_DistXYZ(&this->actor.world.pos, &this->unk_374); + if (!(this->unk_410 & 0x20) && ((s32)this->unk_414 != 0) && ((s32)this->unk_414 < (s32)temp)) { + this->unk_410 |= 0x20; } - this->unk_414 = temp_f0; + this->unk_414 = temp; } -#else -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Sw/func_808DA578.s") -#endif -#ifdef NON_MATCHING -void func_808DA6FC(EnSw* this, GlobalContext* globalCtx) { +void func_808DA6FC(EnSw* this, PlayState* play) { f32 sp4C; - s32 temp; - s32 temp2; - Vec3f sp38; f32 temp_f0; + s16 temp2; + Vec3f sp38; if (!Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) { temp_f0 = this->skelAnime.endFrame - this->skelAnime.curFrame; this->unk_44C = 0.14f * temp_f0; - func_808D94D0(this, globalCtx, 1, 0, 0); + func_808D94D0(this, play, 1, 0, 0); if ((this->actor.speedXZ == 0.0f) && (this->unk_44C != 0.0f)) { Math_Vec3f_Copy(&sp38, &this->unk_374); func_808D9894(this, &sp38); - func_808D94D0(this, globalCtx, 0, 0, Math_FAtan2F(sp38.z, sp38.x)); + temp2 = Math_FAtan2F(sp38.z, sp38.x); + func_808D94D0(this, play, 0, 0, temp2); } } else { Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_STALWALL_DASH); @@ -842,9 +834,8 @@ void func_808DA6FC(EnSw* this, GlobalContext* globalCtx) { } sp4C = Math_Vec3f_DistXYZ(&this->actor.world.pos, &this->unk_374); - temp = this->unk_414; - temp2 = sp4C; - if ((temp != 0) && (temp < temp2)) { + + if (((s32)this->unk_414 != 0) && ((s32)this->unk_414 < (s32)sp4C)) { Math_Vec3f_Copy(&this->actor.world.pos, &this->unk_374); this->unk_454 = Rand_S16Offset(20, 20); this->unk_456 = (Rand_ZeroOne() * 10.0f) + 3.0f; @@ -853,11 +844,8 @@ void func_808DA6FC(EnSw* this, GlobalContext* globalCtx) { } this->unk_414 = sp4C; } -#else -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Sw/func_808DA6FC.s") -#endif -void func_808DA89C(EnSw* this, GlobalContext* globalCtx) { +void func_808DA89C(EnSw* this, PlayState* play) { if (this->drawDmgEffType == ACTOR_DRAW_DMGEFF_FROZEN_NO_SFX) { s32 i; s32 count; @@ -880,43 +868,38 @@ void func_808DA89C(EnSw* this, GlobalContext* globalCtx) { func_808D9E44(this); } this->drawDmgEffType = ACTOR_DRAW_DMGEFF_BLUE_FIRE; - func_808D8ED0(this, globalCtx); + func_808D8ED0(this, play); } - 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, play); + } + } else { + Math_ApproachF(&this->actor.shape.yOffset, 400.0f, 0.3f, 1000.0f); + } + + Actor_MoveWithGravity(&this->actor); + Actor_UpdateBgCheckInfo(play, &this->actor, 30.0f, 12.0f, 0.0f, 4); + } } -void func_808DAA60(EnSw* this, GlobalContext* globalCtx) { +void func_808DAA60(EnSw* this, PlayState* play) { Vec3s* sp44; s16 temp_v0; s16 sp40; @@ -966,27 +949,26 @@ void func_808DAA60(EnSw* this, GlobalContext* globalCtx) { } } } - func_808D94D0(this, globalCtx, 0, 0, sp40); + func_808D94D0(this, play, 0, 0, sp40); } -#ifdef NON_MATCHING -void func_808DACF4(EnSw* this, GlobalContext* globalCtx) { +void func_808DACF4(EnSw* this, PlayState* play) { f32 sp4C; - f32 temp_f0; - s32 temp_f6; + f32 temp; + s16 temp_f6; if (Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame) == 0) { Vec3f sp38; - f32 temp; temp = this->skelAnime.endFrame - this->skelAnime.curFrame; this->unk_44C = 0.1f * temp; - func_808D94D0(this, globalCtx, 1, 0, 0); + func_808D94D0(this, play, 1, 0, 0); if ((this->actor.speedXZ == 0.0f) && (this->unk_44C != 0.0f)) { Math_Vec3f_Copy(&sp38, &this->unk_374); func_808D9894(this, &sp38); - func_808D94D0(this, globalCtx, 0, 0, Math_FAtan2F(sp38.z, sp38.x)); + temp_f6 = Math_FAtan2F(sp38.z, sp38.x); + func_808D94D0(this, play, 0, 0, temp_f6); } } else { Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_STALWALL_DASH); @@ -994,8 +976,8 @@ void func_808DACF4(EnSw* this, GlobalContext* globalCtx) { } sp4C = Math_Vec3f_DistXYZ(&this->actor.world.pos, &this->unk_374); - temp_f6 = this->unk_414; - if ((temp_f6 != 0) && (temp_f6 < (s32)sp4C)) { + + if (((s32)this->unk_414 != 0) && ((s32)this->unk_414 < (s32)sp4C)) { Math_Vec3f_Copy(&this->actor.world.pos, &this->unk_374); this->unk_4A0 += this->unk_49C; if ((this->unk_4A0 >= this->unk_1E4->count) || (this->unk_4A0 < 0)) { @@ -1012,11 +994,8 @@ void func_808DACF4(EnSw* this, GlobalContext* globalCtx) { } this->unk_414 = sp4C; } -#else -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Sw/func_808DACF4.s") -#endif -void func_808DAEB4(EnSw* this, GlobalContext* globalCtx) { +void func_808DAEB4(EnSw* this, PlayState* play) { Vec3f sp5C; s32 i; s32 count; @@ -1055,13 +1034,13 @@ void func_808DAEB4(EnSw* this, GlobalContext* globalCtx) { sp5C.x += this->unk_368.x * 10.0f; sp5C.y += this->unk_368.y * 10.0f; sp5C.z += this->unk_368.z * 10.0f; - if (Actor_SpawnAsChild(&globalCtx->actorCtx, &this->actor, globalCtx, ACTOR_EN_SI, sp5C.x, sp5C.y, - sp5C.z, 0, 0, 0, this->actor.params) != NULL) { + if (Actor_SpawnAsChild(&play->actorCtx, &this->actor, play, ACTOR_EN_SI, sp5C.x, sp5C.y, sp5C.z, 0, 0, + 0, this->actor.params) != NULL) { play_sound(NA_SE_SY_KINSTA_MARK_APPEAR); } Actor_MarkForDeath(&this->actor); } - func_808D94D0(this, globalCtx, 0, 0, 0x1554); + func_808D94D0(this, play, 0, 0, 0x1554); } } else { phi_a0 = DECR(this->unk_45C); @@ -1077,19 +1056,19 @@ void func_808DAEB4(EnSw* this, GlobalContext* globalCtx) { } } -void func_808DB100(EnSw* this, GlobalContext* globalCtx) { +void func_808DB100(EnSw* this, PlayState* play) { if (this->actor.parent != NULL) { this->unk_498 = this->actor.parent->id; this->unk_456 = 0; this->unk_454 = 0; this->skelAnime.curFrame = 0.0f; - func_800BC154(globalCtx, &globalCtx->actorCtx, &this->actor, 4); + func_800BC154(play, &play->actorCtx, &this->actor, 4); this->actionFunc = func_808DB25C; return; } if (!(this->unk_410 & 1)) { - func_808D9A70(this, globalCtx); + func_808D9A70(this, play); return; } @@ -1109,7 +1088,7 @@ void func_808DB100(EnSw* this, GlobalContext* globalCtx) { } } -void func_808DB25C(EnSw* this, GlobalContext* globalCtx) { +void func_808DB25C(EnSw* this, PlayState* play) { if (ActorCutscene_GetCurrentIndex() == 0x7C) { ActorCutscene_Stop(0x7C); } else if (ActorCutscene_GetCanPlayNext(this->actor.cutscene)) { @@ -1121,11 +1100,11 @@ void func_808DB25C(EnSw* this, GlobalContext* globalCtx) { } } -void func_808DB2E0(EnSw* this, GlobalContext* globalCtx) { +void func_808DB2E0(EnSw* this, PlayState* play) { f32 temp_f2; if (this->actor.bgCheckFlags & 1) { - func_808D9F78(this, globalCtx, 0); + func_808D9F78(this, play, 0); temp_f2 = fabsf(this->actor.velocity.y) * 0.6f; this->actor.velocity.x *= 0.5f; this->actor.velocity.y = temp_f2; @@ -1135,14 +1114,14 @@ void func_808DB2E0(EnSw* this, GlobalContext* globalCtx) { if ((s32)temp_f2 != 0) { Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_STALTURA_BOUND); } else { - func_800BC154(globalCtx, &globalCtx->actorCtx, &this->actor, 5); + func_800BC154(play, &play->actorCtx, &this->actor, 5); Math_Vec3f_Copy(&this->actor.velocity, &gZeroVec3f); this->unk_410 &= ~(0x10 | 0x1); this->actionFunc = func_808DB100; } if ((s32)this->actor.velocity.y >= 2) { - func_808D8940(this, globalCtx); + func_808D8940(this, play); } } @@ -1150,21 +1129,20 @@ void func_808DB2E0(EnSw* this, GlobalContext* globalCtx) { Actor_SetScale(&this->actor, this->actor.scale.x); this->actor.velocity.y += this->actor.gravity; Actor_UpdatePos(&this->actor); - Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 30.0f, 12.0f, 0.0f, 4); + Actor_UpdateBgCheckInfo(play, &this->actor, 30.0f, 12.0f, 0.0f, 4); } -void EnSw_Init(Actor* thisx, GlobalContext* globalCtx) { +void EnSw_Init(Actor* thisx, PlayState* play) { EnSw* this = THIS; s32 pad; - if (!func_808D9968(this, globalCtx)) { + if (!func_808D9968(this, play)) { 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); - SubS_ChangeAnimationByInfoS(&this->skelAnime, sAnimations, 0); + SkelAnime_Init(play, &this->skelAnime, &object_st_Skel_005298, NULL, this->jointTable, this->morphTable, 30); + SubS_ChangeAnimationByInfoS(&this->skelAnime, sAnimationInfo, 0); this->skelAnime.playSpeed = 4.0f; - Collider_InitAndSetSphere(globalCtx, &this->collider, &this->actor, &sSphereInit); + Collider_InitAndSetSphere(play, &this->collider, &this->actor, &sSphereInit); if (!ENSW_GET_3(&this->actor)) { this->actor.hintId = 0x1F; CollisionCheck_SetInfo2(&this->actor.colChkInfo, &sDamageTable, &sColChkInfoInit); @@ -1175,14 +1153,14 @@ void EnSw_Init(Actor* thisx, GlobalContext* globalCtx) { this->collider.info.toucher.damage = 16; } - this->unk_1E4 = SubS_GetDayDependentPath(globalCtx, ENSW_GET_FF00(&this->actor), 255, &this->unk_4A0); + this->unk_1E4 = SubS_GetDayDependentPath(play, ENSW_GET_FF00(&this->actor), 255, &this->unk_4A0); if (this->unk_1E4 != NULL) { this->unk_4A0 = 1; } switch (ENSW_GET_3(&this->actor)) { case 0: - func_808D9F78(this, globalCtx, 1); + func_808D9F78(this, play, 1); this->actionFunc = func_808DA350; break; @@ -1200,7 +1178,7 @@ void EnSw_Init(Actor* thisx, GlobalContext* globalCtx) { this->unk_410 |= 8; } - func_808DA024(this, globalCtx); + func_808DA024(this, play); this->unk_410 |= (0x10 | 0x1); this->unk_410 &= ~4; this->actionFunc = func_808DB100; @@ -1221,7 +1199,7 @@ void EnSw_Init(Actor* thisx, GlobalContext* globalCtx) { this->unk_410 |= 8; } - func_808D9F78(this, globalCtx, 1); + func_808D9F78(this, play, 1); if (this->unk_1E4 != NULL) { this->unk_49C = 1; func_808D9F08(this); @@ -1236,19 +1214,19 @@ void EnSw_Init(Actor* thisx, GlobalContext* globalCtx) { } } -void EnSw_Destroy(Actor* thisx, GlobalContext* globalCtx) { +void EnSw_Destroy(Actor* thisx, PlayState* play) { EnSw* this = THIS; - Collider_DestroySphere(globalCtx, &this->collider); + Collider_DestroySphere(play, &this->collider); } -void EnSw_Update(Actor* thisx, GlobalContext* globalCtx) { +void EnSw_Update(Actor* thisx, PlayState* play) { EnSw* this = THIS; - if (func_808DA08C(this, globalCtx)) { + if (func_808DA08C(this, play)) { this->actionFunc = func_808DA89C; } else if (DECR(this->unk_45A) == 0) { - this->actionFunc(this, globalCtx); + this->actionFunc(this, play); } if ((this->drawDmgEffType != ACTOR_DRAW_DMGEFF_FROZEN_NO_SFX) || (this->unk_45A != 0)) { @@ -1256,10 +1234,10 @@ void EnSw_Update(Actor* thisx, GlobalContext* globalCtx) { } Actor_SetFocus(&this->actor, 0.0f); - func_808D8FC4(this, globalCtx); + func_808D8FC4(this, play); } -s32 EnSw_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, Actor* thisx) { +s32 EnSw_OverrideLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, Actor* thisx) { EnSw* this = THIS; if (ENSW_GET_3(&this->actor)) { @@ -1308,23 +1286,23 @@ s32 EnSw_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, return false; } -void EnSw_Draw(Actor* thisx, GlobalContext* globalCtx) { +void EnSw_Draw(Actor* thisx, PlayState* play) { EnSw* this = THIS; s32 i; s32 count; if (this->unk_410 & 4) { if (ENSW_GET_3(&this->actor)) { - func_800B8050(&this->actor, globalCtx, MTXMODE_NEW); + func_800B8050(&this->actor, play, MTXMODE_NEW); } - func_8012C28C(globalCtx->state.gfxCtx); - Matrix_InsertXRotation_s(-0x3C72, MTXMODE_APPLY); - SkelAnime_DrawOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, EnSw_OverrideLimbDraw, NULL, + func_8012C28C(play->state.gfxCtx); + Matrix_RotateXS(-0x3C72, MTXMODE_APPLY); + SkelAnime_DrawOpa(play, this->skelAnime.skeleton, this->skelAnime.jointTable, EnSw_OverrideLimbDraw, NULL, &this->actor); } for (i = 0, count = 0; i < ARRAY_COUNT(this->unk_464); i++) { - count += func_808D8D60(this, globalCtx, i); + count += func_808D8D60(this, play, i); } if (count != 0) { 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 b74062705..7bf39b6c2 100644 --- a/src/overlays/actors/ovl_En_Sw/z_en_sw.h +++ b/src/overlays/actors/ovl_En_Sw/z_en_sw.h @@ -5,47 +5,49 @@ struct EnSw; -typedef void (*EnSwActionFunc)(struct EnSw*, GlobalContext*); +typedef void (*EnSwActionFunc)(struct EnSw*, PlayState*); -#define ENSW_GET_3(thisx) (((thisx)->params & 3) & 0xFF) -#define ENSW_GET_3FC(thisx) (((thisx)->params & 0x3FC) >> 2) +#define ENSW_GETS_3(params) ((params & 3) & 0xFF) +#define ENSW_GET_3(thisx) (ENSW_GETS_3((thisx)->params)) +#define ENSW_GETS_3FC(params) (((params & 0x3FC) >> 2) & 0xFF) +#define ENSW_GET_3FC(thisx) (ENSW_GETS_3FC((thisx)->params)) #define ENSW_GET_FF00(thisx) ((((thisx)->params & 0xFF00) >> 8) & 0xFF) typedef struct EnSw { - /* 0x0000 */ Actor actor; - /* 0x0144 */ SkelAnime skelAnime; - /* 0x0188 */ EnSwActionFunc actionFunc; - /* 0x018C */ ColliderSphere collider; - /* 0x01E4 */ Path* unk_1E4; - /* 0x01E8 */ Vec3s jointTable[30]; - /* 0x029C */ Vec3s morphTable[30]; - /* 0x0350 */ Vec3f unk_350; - /* 0x035C */ Vec3f unk_35C; - /* 0x0368 */ Vec3f unk_368; - /* 0x0374 */ Vec3f unk_374; - /* 0x0380 */ Vec3f unk_380[12]; - /* 0x0410 */ u16 unk_410; - /* 0x0412 */ u8 drawDmgEffType; - /* 0x0414 */ f32 unk_414; - /* 0x0418 */ f32 drawDmgEffFrozenSteamScales[12]; - /* 0x0448 */ f32 unk_448; - /* 0x044C */ f32 unk_44C; - /* 0x0450 */ f32 unk_450; - /* 0x0454 */ s16 unk_454; - /* 0x0456 */ s16 unk_456; - /* 0x0458 */ s16 unk_458; - /* 0x045A */ s16 unk_45A; - /* 0x045C */ s16 unk_45C; - /* 0x045E */ s16 unk_45E; - /* 0x0460 */ s16 unk_460; - /* 0x0462 */ s16 unk_462; - /* 0x0464 */ s16 unk_464[12]; - /* 0x047C */ s16 unk_47C[12]; - /* 0x0494 */ s16 unk_494; - /* 0x0496 */ s16 unk_496; - /* 0x0498 */ s16 unk_498; - /* 0x049C */ s32 unk_49C; - /* 0x04A0 */ s32 unk_4A0; + /* 0x000 */ Actor actor; + /* 0x144 */ SkelAnime skelAnime; + /* 0x188 */ EnSwActionFunc actionFunc; + /* 0x18C */ ColliderSphere collider; + /* 0x1E4 */ Path* unk_1E4; + /* 0x1E8 */ Vec3s jointTable[30]; + /* 0x29C */ Vec3s morphTable[30]; + /* 0x350 */ Vec3f unk_350; + /* 0x35C */ Vec3f unk_35C; + /* 0x368 */ Vec3f unk_368; + /* 0x374 */ Vec3f unk_374; + /* 0x380 */ Vec3f unk_380[12]; + /* 0x410 */ u16 unk_410; + /* 0x412 */ u8 drawDmgEffType; + /* 0x414 */ f32 unk_414; + /* 0x418 */ f32 drawDmgEffFrozenSteamScales[12]; + /* 0x448 */ f32 unk_448; + /* 0x44C */ f32 unk_44C; + /* 0x450 */ f32 unk_450; + /* 0x454 */ s16 unk_454; + /* 0x456 */ s16 unk_456; + /* 0x458 */ s16 unk_458; + /* 0x45A */ s16 unk_45A; + /* 0x45C */ s16 unk_45C; + /* 0x45E */ s16 unk_45E; + /* 0x460 */ s16 unk_460; + /* 0x462 */ s16 unk_462; + /* 0x464 */ s16 unk_464[12]; + /* 0x47C */ s16 unk_47C[12]; + /* 0x494 */ s16 unk_494; + /* 0x496 */ s16 unk_496; + /* 0x498 */ s16 unk_498; + /* 0x49C */ s32 unk_49C; + /* 0x4A0 */ s32 unk_4A0; } EnSw; // size = 0x4A4 extern const ActorInit En_Sw_InitVars; diff --git a/src/overlays/actors/ovl_En_Syateki_Crow/z_en_syateki_crow.c b/src/overlays/actors/ovl_En_Syateki_Crow/z_en_syateki_crow.c index 23a16debc..a8d76a7a8 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 @@ -12,17 +12,17 @@ #define THIS ((EnSyatekiCrow*)thisx) -void EnSyatekiCrow_Init(Actor* thisx, GlobalContext* globalCtx); -void EnSyatekiCrow_Destroy(Actor* thisx, GlobalContext* globalCtx); -void EnSyatekiCrow_Update(Actor* thisx, GlobalContext* globalCtx); -void EnSyatekiCrow_Draw(Actor* thisx, GlobalContext* globalCtx); +void EnSyatekiCrow_Init(Actor* thisx, PlayState* play); +void EnSyatekiCrow_Destroy(Actor* thisx, PlayState* play); +void EnSyatekiCrow_Update(Actor* thisx, PlayState* play); +void EnSyatekiCrow_Draw(Actor* thisx, PlayState* play); void func_809CA5D4(EnSyatekiCrow* this); -void func_809CA67C(EnSyatekiCrow* this, GlobalContext* globalCtx); +void func_809CA67C(EnSyatekiCrow* this, PlayState* play); 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); +void func_809CA840(EnSyatekiCrow* this, PlayState* play); +void func_809CA8E4(EnSyatekiCrow* this, PlayState* play); +void func_809CABC0(EnSyatekiCrow* this, PlayState* play); static Vec3f D_809CB050 = { 0.0f, 0.0f, 0.0f }; @@ -61,7 +61,7 @@ static ColliderJntSphInit sJntSphInit = { OC2_TYPE_1, COLSHAPE_JNTSPH, }, - 1, + ARRAY_COUNT(sJntSphElementsInit), sJntSphElementsInit, }; @@ -78,8 +78,8 @@ static Vec3f D_809CB0CC = { 0.0f, 0.0f, 0.0f }; static Vec3f D_809CB0D8 = { 2500.0f, 0.0f, 0.0f }; -void EnSyatekiCrow_Init(Actor* thisx, GlobalContext* globalCtx2) { - GlobalContext* globalCtx = globalCtx2; +void EnSyatekiCrow_Init(Actor* thisx, PlayState* play2) { + PlayState* play = play2; EnSyatekiCrow* this = THIS; Path* path; EnSyatekiMan* syatekiMan = (EnSyatekiMan*)this->actor.parent; @@ -87,22 +87,22 @@ void EnSyatekiCrow_Init(Actor* thisx, GlobalContext* globalCtx2) { path = syatekiMan->path; while (path->unk2 != 0) { - path = &globalCtx->setupPathList[path->unk1]; + path = &play->setupPathList[path->unk1]; } - for (i = 0; i < EN_SYATEKI_CROW_GET_PARAM_FF00(&this->actor); i++) { - path = &globalCtx->setupPathList[path->unk1]; + for (i = 0; i < EN_SYATEKI_CROW_GET_NUMBER(&this->actor); i++) { + path = &play->setupPathList[path->unk1]; } Actor_ProcessInitChain(&this->actor, sInitChain); - SkelAnime_InitFlex(globalCtx, &this->skelAnime, &gGuaySkel, &gGuayFlyAnim, this->jointTable, this->morphTable, + SkelAnime_InitFlex(play, &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); + Collider_InitJntSph(play, &this->unk_23C); + Collider_SetJntSph(play, &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); - if ((path == NULL) || (EN_SYATEKI_CROW_GET_PARAM_FF00(&this->actor) >= 0x80)) { + if ((path == NULL) || (EN_SYATEKI_CROW_GET_NUMBER(&this->actor) >= 0x80)) { Actor_MarkForDeath(&this->actor); return; } @@ -115,10 +115,10 @@ void EnSyatekiCrow_Init(Actor* thisx, GlobalContext* globalCtx2) { func_809CA5D4(this); } -void EnSyatekiCrow_Destroy(Actor* thisx, GlobalContext* globalCtx) { +void EnSyatekiCrow_Destroy(Actor* thisx, PlayState* play) { EnSyatekiCrow* this = THIS; - Collider_DestroyJntSph(globalCtx, &this->unk_23C); + Collider_DestroyJntSph(play, &this->unk_23C); } void func_809CA5D4(EnSyatekiCrow* this) { @@ -133,17 +133,17 @@ void func_809CA5D4(EnSyatekiCrow* this) { this->actionFunc = func_809CA67C; } -void func_809CA67C(EnSyatekiCrow* this, GlobalContext* globalCtx) { +void func_809CA67C(EnSyatekiCrow* this, PlayState* play) { EnSyatekiMan* syatekiMan = (EnSyatekiMan*)this->actor.parent; - if ((syatekiMan->unk_26A == 1) && (this->unk_1C2 == 1) && - (syatekiMan->unk_274 & (1 << EN_SYATEKI_CROW_GET_PARAM_FF00(&this->actor)))) { + if ((syatekiMan->shootingGameState == SG_GAME_STATE_RUNNING) && (this->unk_1C2 == 1) && + (syatekiMan->guayFlags & (1 << EN_SYATEKI_CROW_GET_NUMBER(&this->actor)))) { func_809CA71C(this); - } else if (syatekiMan->unk_26A != 1) { + } else if (syatekiMan->shootingGameState != SG_GAME_STATE_RUNNING) { this->unk_1C2 = 1; } - if ((syatekiMan->unk_274 == 0) && (syatekiMan->unk_274 == 0)) { + if ((syatekiMan->guayFlags == 0) && (syatekiMan->guayFlags == 0)) { this->unk_1C2 = 1; } } @@ -168,7 +168,7 @@ void func_809CA71C(EnSyatekiCrow* this) { this->actionFunc = func_809CA840; } -void func_809CA840(EnSyatekiCrow* this, GlobalContext* globalCtx) { +void func_809CA840(EnSyatekiCrow* this, PlayState* play) { 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; @@ -180,12 +180,12 @@ void func_809CA840(EnSyatekiCrow* this, GlobalContext* globalCtx) { } } -void func_809CA8E4(EnSyatekiCrow* this, GlobalContext* globalCtx) { +void func_809CA8E4(EnSyatekiCrow* this, PlayState* play) { Vec3f sp34; f32 sp30; EnSyatekiMan* syatekiMan = (EnSyatekiMan*)this->actor.parent; - if (syatekiMan->unk_26A != 1) { + if (syatekiMan->shootingGameState != SG_GAME_STATE_RUNNING) { func_809CA5D4(this); return; } @@ -207,13 +207,13 @@ void func_809CA8E4(EnSyatekiCrow* this, GlobalContext* globalCtx) { this->unk_1CC++; } else { this->unk_1C2 = 0; - syatekiMan->unk_274 &= ~(1 << EN_SYATEKI_CROW_GET_PARAM_FF00(&this->actor)); + syatekiMan->guayFlags &= ~(1 << EN_SYATEKI_CROW_GET_NUMBER(&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) { + if ((syatekiMan->perGameVar1.guaySpawnTimer % 90) == 0) { Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_KAICHO_CRY); } } @@ -221,18 +221,18 @@ void func_809CA8E4(EnSyatekiCrow* this, GlobalContext* globalCtx) { void func_809CAAF8(EnSyatekiCrow* this) { EnSyatekiMan* syatekiMan = (EnSyatekiMan*)this->actor.parent; - syatekiMan->unk_280 += 60; + syatekiMan->score += 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); + Animation_Change(&this->skelAnime, &gGuayFlyAnim, 0.4f, 0.0f, 0.0f, ANIMMODE_LOOP_INTERP, -3.0f); this->actor.bgCheckFlags &= ~1; Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_KAICHO_DEAD); Actor_SetColorFilter(&this->actor, 0x4000, 255, 0, 40); this->actionFunc = func_809CABC0; } -void func_809CABC0(EnSyatekiCrow* this, GlobalContext* globalCtx) { +void func_809CABC0(EnSyatekiCrow* this, PlayState* play) { EnSyatekiMan* syatekiMan = (EnSyatekiMan*)this->actor.parent; Math_StepToF(&this->actor.speedXZ, 0.0f, 0.5f); @@ -244,38 +244,37 @@ void func_809CABC0(EnSyatekiCrow* this, GlobalContext* globalCtx) { } 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_800B3030(play, &this->actor.world.pos, &D_809CB050, &D_809CB050, this->actor.scale.x * 10000.0f, 0, 0); + syatekiMan->guayHitCounter++; + syatekiMan->guayFlags &= ~(1 << EN_SYATEKI_CROW_GET_NUMBER(&this->actor)); func_809CA5D4(this); } this->unk_1C4++; } -void func_809CACD0(EnSyatekiCrow* this, GlobalContext* globalCtx) { +void func_809CACD0(EnSyatekiCrow* this, PlayState* play) { 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); + EffectSsExtra_Spawn(play, &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); + CollisionCheck_SetAC(play, &play->colChkCtx, &this->unk_23C.base); } } } -void EnSyatekiCrow_Update(Actor* thisx, GlobalContext* globalCtx) { +void EnSyatekiCrow_Update(Actor* thisx, PlayState* play) { EnSyatekiCrow* this = THIS; - this->actionFunc(this, globalCtx); + this->actionFunc(this, play); if (this->actionFunc != func_809CABC0) { Actor_MoveWithoutGravity(&this->actor); @@ -283,11 +282,10 @@ void EnSyatekiCrow_Update(Actor* thisx, GlobalContext* globalCtx) { Actor_MoveWithGravity(&this->actor); } - func_809CACD0(this, globalCtx); + func_809CACD0(this, play); } -s32 EnSyatekiCrow_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, - Actor* thisx) { +s32 EnSyatekiCrow_OverrideLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, Actor* thisx) { EnSyatekiCrow* this = THIS; if (limbIndex == OBJECT_CROW_LIMB_UPPER_TAIL) { @@ -299,25 +297,25 @@ s32 EnSyatekiCrow_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx* return false; } -void EnSyatekiCrow_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx) { +void EnSyatekiCrow_PostLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx) { EnSyatekiCrow* this = THIS; Vec3f* sp1C; if (limbIndex == OBJECT_CROW_LIMB_BODY) { - Matrix_MultiplyVector3fByState(&D_809CB0D8, &this->unk_144[0]); + 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_MultiplyVector3fByState(&D_809CB050, sp1C); + Matrix_MultVec3f(&D_809CB050, sp1C); sp1C->y -= 20.0f; } } -void EnSyatekiCrow_Draw(Actor* thisx, GlobalContext* globalCtx) { +void EnSyatekiCrow_Draw(Actor* thisx, PlayState* play) { EnSyatekiCrow* this = THIS; - func_8012C28C(globalCtx->state.gfxCtx); - SkelAnime_DrawFlexOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, + func_8012C28C(play->state.gfxCtx); + SkelAnime_DrawFlexOpa(play, 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 8946e213f..05eec4ad0 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 @@ -5,11 +5,12 @@ #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) +#define EN_SYATEKI_CROW_GET_NUMBER(thisx) (((thisx)->params & 0xFF00) >> 8) +#define EN_SYATEKI_CROW_PARAMS(number, unkF0, unkF) (((number << 8) & 0xFF00) | ((unkF0 << 4) & 0xF0) | (unkF & 0xF)) struct EnSyatekiCrow; -typedef void (*EnSyatekiCrowActionFunc)(struct EnSyatekiCrow*, GlobalContext*); +typedef void (*EnSyatekiCrowActionFunc)(struct EnSyatekiCrow*, PlayState*); typedef struct EnSyatekiCrow { /* 0x000 */ Actor actor; 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 944838b3c..fcb1e8330 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 @@ -7,33 +7,32 @@ #include "z_en_syateki_dekunuts.h" #include "overlays/actors/ovl_En_Syateki_Man/z_en_syateki_man.h" #include "overlays/effects/ovl_Effect_Ss_Hahen/z_eff_ss_hahen.h" -#include "objects/object_dekunuts/object_dekunuts.h" #define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_20 | ACTOR_FLAG_8000000) #define THIS ((EnSyatekiDekunuts*)thisx) -void EnSyatekiDekunuts_Init(Actor* thisx, GlobalContext* globalCtx); -void EnSyatekiDekunuts_Destroy(Actor* thisx, GlobalContext* globalCtx); -void EnSyatekiDekunuts_Update(Actor* thisx, GlobalContext* globalCtx); -void EnSyatekiDekunuts_Draw(Actor* thisx, GlobalContext* globalCtx); +void EnSyatekiDekunuts_Init(Actor* thisx, PlayState* play); +void EnSyatekiDekunuts_Destroy(Actor* thisx, PlayState* play); +void EnSyatekiDekunuts_Update(Actor* thisx, PlayState* play); +void EnSyatekiDekunuts_Draw(Actor* thisx, PlayState* play); void func_80A2BE54(EnSyatekiDekunuts* this); -void func_80A2BF18(EnSyatekiDekunuts* this, GlobalContext* globalCtx); +void func_80A2BF18(EnSyatekiDekunuts* this, PlayState* play); void func_80A2BFC4(EnSyatekiDekunuts* this); -void func_80A2C0F8(EnSyatekiDekunuts* this, GlobalContext* globalCtx); +void func_80A2C0F8(EnSyatekiDekunuts* this, PlayState* play); void func_80A2C150(EnSyatekiDekunuts* this); -void func_80A2C168(EnSyatekiDekunuts* this, GlobalContext* globalCtx); +void func_80A2C168(EnSyatekiDekunuts* this, PlayState* play); void func_80A2C1AC(EnSyatekiDekunuts* this); -void func_80A2C208(EnSyatekiDekunuts* this, GlobalContext* globalCtx); +void func_80A2C208(EnSyatekiDekunuts* this, PlayState* play); void func_80A2C27C(EnSyatekiDekunuts* this); -void func_80A2C2E0(EnSyatekiDekunuts* this, GlobalContext* globalCtx); -void func_80A2C33C(EnSyatekiDekunuts* this, GlobalContext* globalCtx); +void func_80A2C2E0(EnSyatekiDekunuts* this, PlayState* play); +void func_80A2C33C(EnSyatekiDekunuts* this, PlayState* play); void func_80A2C3AC(EnSyatekiDekunuts* this); -void func_80A2C3F0(EnSyatekiDekunuts* this, GlobalContext* globalCtx); +void func_80A2C3F0(EnSyatekiDekunuts* this, PlayState* play); void func_80A2C478(EnSyatekiDekunuts* this); -void func_80A2C48C(EnSyatekiDekunuts* this, GlobalContext* globalCtx); -void func_80A2C5DC(EnSyatekiDekunuts* this, GlobalContext* globalCtx); +void func_80A2C48C(EnSyatekiDekunuts* this, PlayState* play); +void func_80A2C5DC(EnSyatekiDekunuts* this, PlayState* play); const ActorInit En_Syateki_Dekunuts_InitVars = { ACTOR_EN_SYATEKI_DEKUNUTS, @@ -69,14 +68,14 @@ static ColliderCylinderInit sCylinderInit = { static Cylinder16 D_80A2CADC[] = { { 24, 40, 0, { 0, 0, 0 } } }; -static AnimationInfo sAnimations[] = { - { &object_dekunuts_Anim_003180, 1.0f, 0.0f, 0.0f, ANIMMODE_ONCE, -1.0f }, - { &object_dekunuts_Anim_002A5C, 1.0f, 0.0f, 0.0f, ANIMMODE_ONCE, -1.0f }, - { &object_dekunuts_Anim_00326C, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, -1.0f }, - { &object_dekunuts_Anim_002FA4, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, -1.0f }, - { &object_dekunuts_Anim_00259C, 1.0f, 0.0f, 0.0f, ANIMMODE_ONCE, -1.0f }, - { &object_dekunuts_Anim_002BD4, 1.0f, 0.0f, 0.0f, ANIMMODE_ONCE, -1.0f }, - { &object_dekunuts_Anim_002DD4, 1.0f, 0.0f, 0.0f, ANIMMODE_ONCE, -1.0f }, +static AnimationInfo sAnimationInfo[] = { + { &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[] = { @@ -85,18 +84,18 @@ static InitChainEntry sInitChain[] = { ICHAIN_F32(targetArrowOffset, 2600, ICHAIN_STOP), }; -void EnSyatekiDekunuts_Init(Actor* thisx, GlobalContext* globalCtx2) { +void EnSyatekiDekunuts_Init(Actor* thisx, PlayState* play2) { static s32 D_80A2CB9C = 1; EnSyatekiDekunuts* this = THIS; - GlobalContext* globalCtx = globalCtx2; + PlayState* play = play2; s32 phi_v0; Path* path; EnSyatekiMan* syatekiMan = (EnSyatekiMan*)this->actor.parent; s32 i; path = syatekiMan->path; - Collider_InitCylinder(globalCtx, &this->collider); - Collider_SetCylinder(globalCtx, &this->collider, &this->actor, &sCylinderInit); + Collider_InitCylinder(play, &this->collider); + Collider_SetCylinder(play, &this->collider, &this->actor, &sCylinderInit); if (EN_SYATEKI_DEKUNUTS_GET_PARAM_F(&this->actor) == 1) { Actor_SetScale(&this->actor, 0.01f); @@ -108,11 +107,11 @@ void EnSyatekiDekunuts_Init(Actor* thisx, GlobalContext* globalCtx2) { } while (path->unk2 != phi_v0) { - path = &globalCtx->setupPathList[path->unk1]; + path = &play->setupPathList[path->unk1]; } for (i = 0; i < EN_SYATEKI_DEKUNUTS_GET_PARAM_FF00(&this->actor); i++) { - path = &globalCtx->setupPathList[path->unk1]; + path = &play->setupPathList[path->unk1]; } if (D_80A2CB9C == 1) { @@ -124,15 +123,15 @@ void EnSyatekiDekunuts_Init(Actor* thisx, GlobalContext* globalCtx2) { Actor_ProcessInitChain(&this->actor, sInitChain); ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 35.0f); - SkelAnime_Init(globalCtx, &this->skelAnime, &object_dekunuts_Skel_002468, &object_dekunuts_Anim_002A5C, - this->jointTable, this->morphTable, 10); + SkelAnime_Init(play, &this->skelAnime, &gDekuScrubSkel, &gDekuScrubBurrowAnim, this->jointTable, this->morphTable, + DEKU_SCRUB_LIMB_MAX); if (path == NULL) { Actor_MarkForDeath(&this->actor); return; } this->unk_1E4 = Lib_SegmentedToVirtual(path->points); - this->unk_1E8 = EN_SYATEKI_DEKUNUTS_GET_PARAM_F0(&this->actor); + this->unk_1E8 = EN_SYATEKI_DEKUNUTS_GET_NUMBER(&this->actor); this->unk_1EA = path->count; this->unk_1D8 = 0; this->unk_1DC = 0; @@ -140,14 +139,14 @@ void EnSyatekiDekunuts_Init(Actor* thisx, GlobalContext* globalCtx2) { func_80A2BE54(this); } -void EnSyatekiDekunuts_Destroy(Actor* thisx, GlobalContext* globalCtx) { +void EnSyatekiDekunuts_Destroy(Actor* thisx, PlayState* play) { EnSyatekiDekunuts* this = THIS; - Collider_DestroyCylinder(globalCtx, &this->collider); + Collider_DestroyCylinder(play, &this->collider); } void func_80A2BE54(EnSyatekiDekunuts* this) { - Animation_PlayOnceSetSpeed(&this->skelAnime, &object_dekunuts_Anim_003180, 0.0f); + Animation_PlayOnceSetSpeed(&this->skelAnime, &gDekuScrubUpAnim, 0.0f); this->actor.speedXZ = 0.0f; this->actor.world = this->actor.home; @@ -164,16 +163,17 @@ void func_80A2BE54(EnSyatekiDekunuts* this) { this->actionFunc = func_80A2BF18; } -void func_80A2BF18(EnSyatekiDekunuts* this, GlobalContext* globalCtx) { +void func_80A2BF18(EnSyatekiDekunuts* this, PlayState* play) { EnSyatekiMan* syatekiMan = (EnSyatekiMan*)this->actor.parent; - if ((syatekiMan->unk_26A == 1) && (this->unk_1E2 == 1) && ((syatekiMan->unk_272 & (1 << this->unk_1E8)) != 0)) { + if ((syatekiMan->shootingGameState == SG_GAME_STATE_RUNNING) && (this->unk_1E2 == 1) && + ((syatekiMan->dekuScrubFlags & (1 << this->unk_1E8)) != 0)) { func_80A2BFC4(this); - } else if (syatekiMan->unk_26A != 1) { + } else if (syatekiMan->shootingGameState != SG_GAME_STATE_RUNNING) { this->unk_1E2 = 1; } - if ((syatekiMan->unk_272 == 0) && (syatekiMan->unk_274 == 0) && + if ((syatekiMan->dekuScrubFlags == 0) && (syatekiMan->guayFlags == 0) && (EN_SYATEKI_DEKUNUTS_GET_PARAM_F(&this->actor) != 1)) { this->unk_1E2 = 1; } @@ -190,9 +190,9 @@ void func_80A2BFC4(EnSyatekiDekunuts* this) { 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); + this->unk_1EE = 140 - (syatekiMan->currentWave * 20); - if ((syatekiMan->unk_27C & 1) != 0) { + if ((syatekiMan->currentWave & 1) != 0) { this->unk_1F0 = 1; this->unk_1F2 = 0; } else { @@ -202,7 +202,7 @@ void func_80A2BFC4(EnSyatekiDekunuts* this) { this->actionFunc = func_80A2C0F8; } -void func_80A2C0F8(EnSyatekiDekunuts* this, GlobalContext* globalCtx) { +void func_80A2C0F8(EnSyatekiDekunuts* this, PlayState* play) { EnSyatekiMan* syatekiMan; if (this->unk_1DA > 20) { @@ -220,7 +220,7 @@ void func_80A2C150(EnSyatekiDekunuts* this) { this->actionFunc = func_80A2C168; } -void func_80A2C168(EnSyatekiDekunuts* this, GlobalContext* globalCtx) { +void func_80A2C168(EnSyatekiDekunuts* this, PlayState* play) { if (this->unk_1DA > 20) { func_80A2C1AC(this); this->unk_1DA = 0; @@ -231,13 +231,13 @@ void func_80A2C168(EnSyatekiDekunuts* this, GlobalContext* globalCtx) { void func_80A2C1AC(EnSyatekiDekunuts* this) { Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_NUTS_UP); - Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 0); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, 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) { +void func_80A2C208(EnSyatekiDekunuts* this, PlayState* play) { if (Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) { func_80A2C27C(this); } @@ -250,7 +250,7 @@ void func_80A2C208(EnSyatekiDekunuts* this, GlobalContext* globalCtx) { } void func_80A2C27C(EnSyatekiDekunuts* this) { - Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 3); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, 3); if (EN_SYATEKI_DEKUNUTS_GET_PARAM_F(&this->actor) != 1) { this->actionFunc = func_80A2C2E0; } else { @@ -258,20 +258,20 @@ void func_80A2C27C(EnSyatekiDekunuts* this) { } } -void func_80A2C2E0(EnSyatekiDekunuts* this, GlobalContext* globalCtx) { +void func_80A2C2E0(EnSyatekiDekunuts* this, PlayState* play) { EnSyatekiMan* syatekiMan = (EnSyatekiMan*)this->actor.parent; - if ((this->unk_1EE < this->unk_1D8) || (syatekiMan->unk_26A != 1)) { + if ((this->unk_1EE < this->unk_1D8) || (syatekiMan->shootingGameState != SG_GAME_STATE_RUNNING)) { func_80A2C3AC(this); } this->unk_1D8++; } -void func_80A2C33C(EnSyatekiDekunuts* this, GlobalContext* globalCtx) { +void func_80A2C33C(EnSyatekiDekunuts* this, PlayState* play) { EnSyatekiMan* syatekiMan = (EnSyatekiMan*)this->actor.parent; - if ((gSaveContext.unk_3DE0[1] <= 0) || (syatekiMan->unk_26A != 1)) { + if ((gSaveContext.unk_3DE0[1] <= 0) || (syatekiMan->shootingGameState != SG_GAME_STATE_RUNNING)) { func_80A2C3AC(this); } @@ -281,14 +281,14 @@ void func_80A2C33C(EnSyatekiDekunuts* this, GlobalContext* globalCtx) { } void func_80A2C3AC(EnSyatekiDekunuts* this) { - Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 1); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, 1); this->actionFunc = func_80A2C3F0; } -void func_80A2C3F0(EnSyatekiDekunuts* this, GlobalContext* globalCtx) { +void func_80A2C3F0(EnSyatekiDekunuts* this, PlayState* play) { EnSyatekiMan* syatekiMan = (EnSyatekiMan*)this->actor.parent; - if (syatekiMan->unk_26A == 1) { + if (syatekiMan->shootingGameState == SG_GAME_STATE_RUNNING) { if (this->unk_1D8 > 160 && Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) { this->unk_1D8 = 0; func_80A2C150(this); @@ -304,7 +304,7 @@ void func_80A2C478(EnSyatekiDekunuts* this) { this->actionFunc = func_80A2C48C; } -void func_80A2C48C(EnSyatekiDekunuts* this, GlobalContext* globalCtx) { +void func_80A2C48C(EnSyatekiDekunuts* this, PlayState* play) { if (this->unk_1DA > 20) { func_80A2BE54(this); this->unk_1DA = 0; @@ -313,36 +313,36 @@ void func_80A2C48C(EnSyatekiDekunuts* this, GlobalContext* globalCtx) { } } -void func_80A2C4D0(EnSyatekiDekunuts* this, GlobalContext* globalCtx) { +void func_80A2C4D0(EnSyatekiDekunuts* this, PlayState* play) { 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++; + EffectSsExtra_Spawn(play, &this->actor.world.pos, &D_80A2CBA0, &D_80A2CBAC, 5, 2); + syatekiMan->score += 100; + syatekiMan->perGameVar2.bonusDekuScrubHitCounter++; } else { - EffectSsExtra_Spawn(globalCtx, &this->actor.world.pos, &D_80A2CBA0, &D_80A2CBAC, 5, 0); - syatekiMan->unk_280 += 30; - syatekiMan->unk_278++; + EffectSsExtra_Spawn(play, &this->actor.world.pos, &D_80A2CBA0, &D_80A2CBAC, 5, 0); + syatekiMan->score += 30; + syatekiMan->dekuScrubHitCounter++; } Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_NUTS_DAMAGE); this->unk_1E2 = 0; - Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 4); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, 4); this->unk_1D8 = 160; this->actionFunc = func_80A2C5DC; } -void func_80A2C5DC(EnSyatekiDekunuts* this, GlobalContext* globalCtx) { +void func_80A2C5DC(EnSyatekiDekunuts* this, PlayState* play) { 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_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, 5); Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_NUTS_DEAD); this->unk_1D8--; } else if (this->unk_1D8 < 160) { @@ -351,13 +351,13 @@ void func_80A2C5DC(EnSyatekiDekunuts* this, GlobalContext* globalCtx) { sp40.x = this->actor.world.pos.x; sp40.y = this->actor.world.pos.y + 18.0f; sp40.z = this->actor.world.pos.z; - EffectSsDeadDb_Spawn(globalCtx, &sp40, &gZeroVec3f, &gZeroVec3f, &D_80A2CBB8, &D_80A2CBBC, 200, 0, 13); - SoundSource_PlaySfxAtFixedWorldPos(globalCtx, &this->actor.world.pos, 30, NA_SE_EN_EXTINCT); + EffectSsDeadDb_Spawn(play, &sp40, &gZeroVec3f, &gZeroVec3f, &D_80A2CBB8, &D_80A2CBBC, 200, 0, 13); + SoundSource_PlaySfxAtFixedWorldPos(play, &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); + EffectSsHahen_SpawnBurst(play, &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); + syatekiMan->dekuScrubFlags &= ~(1 << this->unk_1E8); } func_80A2BE54(this); @@ -367,11 +367,11 @@ void func_80A2C5DC(EnSyatekiDekunuts* this, GlobalContext* globalCtx) { } } -void EnSyatekiDekunuts_Update(Actor* thisx, GlobalContext* globalCtx) { +void EnSyatekiDekunuts_Update(Actor* thisx, PlayState* play) { s32 pad; EnSyatekiDekunuts* this = THIS; - this->actionFunc(this, globalCtx); + this->actionFunc(this, play); 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)) { @@ -382,11 +382,11 @@ void EnSyatekiDekunuts_Update(Actor* thisx, GlobalContext* globalCtx) { } this->collider.base.acFlags &= ~AC_HIT; - func_80A2C4D0(this, globalCtx); + func_80A2C4D0(this, play); } Collider_UpdateCylinder(&this->actor, &this->collider); - CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + CollisionCheck_SetAC(play, &play->colChkCtx, &this->collider.base); } else { this->collider.base.acFlags &= ~AC_HIT; } @@ -394,24 +394,24 @@ void EnSyatekiDekunuts_Update(Actor* thisx, GlobalContext* globalCtx) { SkelAnime_Update(&this->skelAnime); } -s32 EnSyatekiDekunuts_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, +s32 EnSyatekiDekunuts_OverrideLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, Actor* thisx) { EnSyatekiDekunuts* this = THIS; - if ((limbIndex == OBJECT_DEKUNUTS_LIMB_03) && (this->unk_1F0 == 1)) { + if ((limbIndex == DEKU_SCRUB_LIMB_HEADDRESS) && (this->unk_1F0 == 1)) { rot->z += this->unk_1F2; } return false; } -void EnSyatekiDekunuts_Draw(Actor* thisx, GlobalContext* globalCtx) { +void EnSyatekiDekunuts_Draw(Actor* thisx, PlayState* play) { EnSyatekiDekunuts* this = THIS; Vec3f temp_f20; s32 i; if (this->actionFunc != func_80A2BF18) { - SkelAnime_DrawOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, + SkelAnime_DrawOpa(play, this->skelAnime.skeleton, this->skelAnime.jointTable, EnSyatekiDekunuts_OverrideLimbDraw, NULL, &this->actor); } @@ -421,16 +421,15 @@ void EnSyatekiDekunuts_Draw(Actor* thisx, GlobalContext* globalCtx) { temp_f20.y = this->unk_1E4[i].y; temp_f20.z = this->unk_1E4[i].z; - OPEN_DISPS(globalCtx->state.gfxCtx); + OPEN_DISPS(play->state.gfxCtx); - func_8012C28C(globalCtx->state.gfxCtx); - Matrix_InsertTranslation(temp_f20.x, temp_f20.y, temp_f20.z, MTXMODE_NEW); + func_8012C28C(play->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++, &object_dekunuts_DL_001E50); + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_OPA_DISP++, gDekuScrubFlowerDL); - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->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 4055dd6b8..447dcaee7 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,14 +2,16 @@ #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_NUMBER(thisx) (((thisx)->params & 0xF0) >> 4) #define EN_SYATEKI_DEKUNUTS_GET_PARAM_FF00(thisx) (((thisx)->params & 0xFF00) >> 8) +#define EN_SYATEKI_DEKUNUTS_PARAMS(unkFF00, number, unkF) (((unkFF00 << 8) & 0xFF00) | ((number << 4) & 0xF0) | (unkF & 0xF)) struct EnSyatekiDekunuts; -typedef void (*EnSyatekiDekunutsActionFunc)(struct EnSyatekiDekunuts*, GlobalContext*); +typedef void (*EnSyatekiDekunutsActionFunc)(struct EnSyatekiDekunuts*, PlayState*); typedef struct EnSyatekiDekunuts { /* 0x000 */ Actor actor; @@ -28,8 +30,8 @@ typedef struct EnSyatekiDekunuts { /* 0x1EE */ s16 unk_1EE; /* 0x1F0 */ s16 unk_1F0; /* 0x1F2 */ s16 unk_1F2; - /* 0x1F4 */ Vec3s jointTable[10]; - /* 0x230 */ Vec3s morphTable[10]; + /* 0x1F4 */ Vec3s jointTable[DEKU_SCRUB_LIMB_MAX]; + /* 0x230 */ Vec3s morphTable[DEKU_SCRUB_LIMB_MAX]; /* 0x26C */ UNK_TYPE1 unk_26C[0x4]; } EnSyatekiDekunuts; // size = 0x270 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 e69c7e5ab..7852aa24b 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 @@ -2,38 +2,62 @@ * File: z_en_syateki_man.c * Overlay: ovl_En_Syateki_Man * Description: Shooting Gallery Man + * + * In addition to handling the normal NPC behavior with the Town/Swamp Shooting Gallery Man, this actor is also + * responsible for running their respective shooting games as well. */ #include "z_en_syateki_man.h" -#include "objects/object_shn/object_shn.h" +#include "overlays/actors/ovl_En_Syateki_Crow/z_en_syateki_crow.h" +#include "overlays/actors/ovl_En_Syateki_Dekunuts/z_en_syateki_dekunuts.h" +#include "overlays/actors/ovl_En_Syateki_Wf/z_en_syateki_wf.h" #define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_8 | ACTOR_FLAG_10 | ACTOR_FLAG_8000000) #define THIS ((EnSyatekiMan*)thisx) -void EnSyatekiMan_Init(Actor* thisx, GlobalContext* globalCtx); -void EnSyatekiMan_Destroy(Actor* thisx, GlobalContext* globalCtx); -void EnSyatekiMan_Update(Actor* thisx, GlobalContext* globalCtx); -void EnSyatekiMan_Draw(Actor* thisx, GlobalContext* globalCtx); +void EnSyatekiMan_Init(Actor* thisx, PlayState* play); +void EnSyatekiMan_Destroy(Actor* thisx, PlayState* play); +void EnSyatekiMan_Update(Actor* thisx, PlayState* play); +void EnSyatekiMan_Draw(Actor* thisx, PlayState* play); -void func_809C6810(EnSyatekiMan* this, GlobalContext* globalCtx); -void func_809C6848(EnSyatekiMan* this, GlobalContext* globalCtx); -void func_809C6E30(EnSyatekiMan* this, GlobalContext* globalCtx); -void func_809C72D8(EnSyatekiMan* this, GlobalContext* globalCtx); -void func_809C7990(EnSyatekiMan* this, GlobalContext* globalCtx); -void func_809C7A90(EnSyatekiMan* this, GlobalContext* globalCtx); -void func_809C7C14(EnSyatekiMan* this, GlobalContext* globalCtx); -void func_809C7D14(EnSyatekiMan* this, GlobalContext* globalCtx); -void func_809C7EB4(EnSyatekiMan* this, GlobalContext* globalCtx); -void func_809C7FFC(EnSyatekiMan* this, GlobalContext* globalCtx); -void func_809C80C0(EnSyatekiMan* this, GlobalContext* globalCtx); -void func_809C81D0(EnSyatekiMan* this, GlobalContext* globalCtx); -void func_809C8488(EnSyatekiMan* this, GlobalContext* globalCtx); -void func_809C8610(EnSyatekiMan* this, GlobalContext* globalCtx); -void func_809C8710(EnSyatekiMan* this, GlobalContext* globalCtx); -void func_809C8808(EnSyatekiMan* this, GlobalContext* globalCtx); -void func_809C898C(EnSyatekiMan* this, GlobalContext* globalCtx); -void func_809C8BF0(EnSyatekiMan* this, GlobalContext* globalCtx); +void EnSyatekiMan_SetupIdle(EnSyatekiMan* this, PlayState* play); +void EnSyatekiMan_Swamp_Idle(EnSyatekiMan* this, PlayState* play); +void EnSyatekiMan_Swamp_Talk(EnSyatekiMan* this, PlayState* play); +void EnSyatekiMan_Town_Idle(EnSyatekiMan* this, PlayState* play); +void EnSyatekiMan_Town_Talk(EnSyatekiMan* this, PlayState* play); +void EnSyatekiMan_Swamp_SetupGiveReward(EnSyatekiMan* this, PlayState* play); +void EnSyatekiMan_Swamp_GiveReward(EnSyatekiMan* this, PlayState* play); +void EnSyatekiMan_Town_SetupGiveReward(EnSyatekiMan* this, PlayState* play); +void EnSyatekiMan_Town_GiveReward(EnSyatekiMan* this, PlayState* play); +void EnSyatekiMan_Swamp_MovePlayerAndExplainRules(EnSyatekiMan* this, PlayState* play); +void EnSyatekiMan_Swamp_StartGame(EnSyatekiMan* this, PlayState* play); +void EnSyatekiMan_Swamp_RunGame(EnSyatekiMan* this, PlayState* play); +void EnSyatekiMan_Swamp_EndGame(EnSyatekiMan* this, PlayState* play); +void EnSyatekiMan_Swamp_AddBonusPoints(EnSyatekiMan* this, PlayState* play); +void EnSyatekiMan_Town_MovePlayerAndSayHighScore(EnSyatekiMan* this, PlayState* play); +void EnSyatekiMan_Town_StartGame(EnSyatekiMan* this, PlayState* play); +void EnSyatekiMan_Town_RunGame(EnSyatekiMan* this, PlayState* play); +void EnSyatekiMan_Town_EndGame(EnSyatekiMan* this, PlayState* play); + +#define TALK_FLAG_NONE 0 +#define TALK_FLAG_TOWN_HAS_SPOKEN_WITH_HUMAN (1 << 0) +#define TALK_FLAG_TOWN_HAS_SPOKEN_WITH_DEKU (1 << 1) +#define TALK_FLAG_TOWN_HAS_SPOKEN_WITH_GORON (1 << 2) +#define TALK_FLAG_TOWN_HAS_SPOKEN_WITH_ZORA (1 << 3) +#define TALK_FLAG_TOWN_HAS_EXPLAINED_THE_RULES (1 << 4) +#define TALK_FLAG_SWAMP_HAS_SPOKEN_WITH_HUMAN (1 << 0) +#define TALK_FLAG_SWAMP_HAS_EXPLAINED_THE_RULES (1 << 1) + +#define OCTOROK_FLAG(color, row, column) (1 << ((row * 6) + (column * 2) + color)) +#define COLOR_RED 0 +#define COLOR_BLUE 1 +#define ROW_BACK 0 +#define ROW_CENTER 1 +#define ROW_FRONT 2 +#define COLUMN_LEFT 0 +#define COLUMN_CENTER 1 +#define COLUMN_RIGHT 2 const ActorInit En_Syateki_Man_InitVars = { ACTOR_EN_SYATEKI_MAN, @@ -47,201 +71,235 @@ const ActorInit En_Syateki_Man_InitVars = { (ActorFunc)EnSyatekiMan_Draw, }; -static AnimationInfo sAnimations[] = { - { &object_shn_Anim_00D9D0, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, -8.0f }, - { &object_shn_Anim_00DFEC, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, -8.0f }, - { &object_shn_Anim_00D2F8, 1.0f, 0.0f, 0.0f, ANIMMODE_ONCE, -8.0f }, +typedef enum { + /* 0 */ EN_SYATEKI_MAN_ANIM_HANDS_ON_TABLE, + /* 1 */ EN_SYATEKI_MAN_ANIM_SWAMP_HEAD_SCRATCH_LOOP, + /* 2 */ EN_SYATEKI_MAN_ANIM_SWAMP_HEAD_SCRATCH_END, +} EnSyatekiManAnimation; + +static AnimationInfo sAnimationInfo[] = { + { &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[] = { - 0x00C1, - 0x0302, - 0x0019, - 0x0026, +/** + * In the Swamp Shooting Gallery, there are four waves of Guays. + * For each wave, these flags are used to control which Guays appear. + */ +static s16 sGuayFlagsPerWave[] = { + (1 << 7) | (1 << 6) | (1 << 0), + (1 << 9) | (1 << 8) | (1 << 1), + (1 << 4) | (1 << 3) | (1 << 0), + (1 << 5) | (1 << 2) | (1 << 1), }; -static EnSyatekiManUnkStruct D_809C91D0[] = { - { ACTOR_EN_SYATEKI_WF, -1000.0f, 200.0f, -700.0f, 0x130 }, - { ACTOR_EN_SYATEKI_WF, -1000.0f, 200.0f, -700.0f, 0x20 }, - { ACTOR_EN_SYATEKI_DEKUNUTS, -1000.0f, 200.0f, -700.0f, 0x0 }, - { ACTOR_EN_SYATEKI_DEKUNUTS, -1000.0f, 200.0f, -700.0f, 0x10 }, - { ACTOR_EN_SYATEKI_DEKUNUTS, -1000.0f, 200.0f, -700.0f, 0x20 }, - { ACTOR_EN_SYATEKI_DEKUNUTS, -1000.0f, 200.0f, -700.0f, 0x30 }, - { ACTOR_EN_SYATEKI_DEKUNUTS, -1000.0f, 200.0f, -700.0f, 0x40 }, - { ACTOR_EN_SYATEKI_DEKUNUTS, -1000.0f, 200.0f, -700.0f, 0x1 }, - { ACTOR_EN_SYATEKI_DEKUNUTS, -1000.0f, 200.0f, -700.0f, 0x11 }, - { ACTOR_EN_SYATEKI_CROW, -1000.0f, 200.0f, -700.0f, 0x0 }, - { ACTOR_EN_SYATEKI_CROW, -1000.0f, 200.0f, -700.0f, 0x100 }, - { ACTOR_EN_SYATEKI_CROW, -1000.0f, 200.0f, -700.0f, 0x200 }, - { ACTOR_EN_SYATEKI_CROW, -1000.0f, 200.0f, -700.0f, 0x300 }, - { ACTOR_EN_SYATEKI_CROW, -1000.0f, 200.0f, -700.0f, 0x420 }, - { ACTOR_EN_SYATEKI_CROW, -1000.0f, 200.0f, -700.0f, 0x520 }, - { ACTOR_EN_SYATEKI_CROW, -1000.0f, 200.0f, -700.0f, 0x601 }, - { ACTOR_EN_SYATEKI_CROW, -1000.0f, 200.0f, -700.0f, 0x702 }, - { ACTOR_EN_SYATEKI_CROW, -1000.0f, 200.0f, -700.0f, 0x801 }, - { ACTOR_EN_SYATEKI_CROW, -1000.0f, 200.0f, -700.0f, 0x902 }, +typedef struct { + /* 0x00 */ s16 actorId; + /* 0x04 */ Vec3f pos; + /* 0x10 */ s32 params; +} SwampTargetActorEntry; // size = 0x14 + +static SwampTargetActorEntry sNormalSwampTargetActorList[] = { + { ACTOR_EN_SYATEKI_WF, -1000.0f, 200.0f, -700.0f, EN_SYATEKI_WF_PARAMS(1, 3, 0) }, + { ACTOR_EN_SYATEKI_WF, -1000.0f, 200.0f, -700.0f, EN_SYATEKI_WF_PARAMS(0, 2, 0) }, + { ACTOR_EN_SYATEKI_DEKUNUTS, -1000.0f, 200.0f, -700.0f, EN_SYATEKI_DEKUNUTS_PARAMS(0, 0, 0) }, + { ACTOR_EN_SYATEKI_DEKUNUTS, -1000.0f, 200.0f, -700.0f, EN_SYATEKI_DEKUNUTS_PARAMS(0, 1, 0) }, + { ACTOR_EN_SYATEKI_DEKUNUTS, -1000.0f, 200.0f, -700.0f, EN_SYATEKI_DEKUNUTS_PARAMS(0, 2, 0) }, + { ACTOR_EN_SYATEKI_DEKUNUTS, -1000.0f, 200.0f, -700.0f, EN_SYATEKI_DEKUNUTS_PARAMS(0, 3, 0) }, + { ACTOR_EN_SYATEKI_DEKUNUTS, -1000.0f, 200.0f, -700.0f, EN_SYATEKI_DEKUNUTS_PARAMS(0, 4, 0) }, + { ACTOR_EN_SYATEKI_DEKUNUTS, -1000.0f, 200.0f, -700.0f, EN_SYATEKI_DEKUNUTS_PARAMS(0, 0, 1) }, + { ACTOR_EN_SYATEKI_DEKUNUTS, -1000.0f, 200.0f, -700.0f, EN_SYATEKI_DEKUNUTS_PARAMS(0, 1, 1) }, + { ACTOR_EN_SYATEKI_CROW, -1000.0f, 200.0f, -700.0f, EN_SYATEKI_CROW_PARAMS(0, 0, 0) }, + { ACTOR_EN_SYATEKI_CROW, -1000.0f, 200.0f, -700.0f, EN_SYATEKI_CROW_PARAMS(1, 0, 0) }, + { ACTOR_EN_SYATEKI_CROW, -1000.0f, 200.0f, -700.0f, EN_SYATEKI_CROW_PARAMS(2, 0, 0) }, + { ACTOR_EN_SYATEKI_CROW, -1000.0f, 200.0f, -700.0f, EN_SYATEKI_CROW_PARAMS(3, 0, 0) }, + { ACTOR_EN_SYATEKI_CROW, -1000.0f, 200.0f, -700.0f, EN_SYATEKI_CROW_PARAMS(4, 2, 0) }, + { ACTOR_EN_SYATEKI_CROW, -1000.0f, 200.0f, -700.0f, EN_SYATEKI_CROW_PARAMS(5, 2, 0) }, + { ACTOR_EN_SYATEKI_CROW, -1000.0f, 200.0f, -700.0f, EN_SYATEKI_CROW_PARAMS(6, 0, 1) }, + { ACTOR_EN_SYATEKI_CROW, -1000.0f, 200.0f, -700.0f, EN_SYATEKI_CROW_PARAMS(7, 0, 2) }, + { ACTOR_EN_SYATEKI_CROW, -1000.0f, 200.0f, -700.0f, EN_SYATEKI_CROW_PARAMS(8, 0, 1) }, + { ACTOR_EN_SYATEKI_CROW, -1000.0f, 200.0f, -700.0f, EN_SYATEKI_CROW_PARAMS(9, 0, 2) }, }; -static EnSyatekiManUnkStruct D_809C934C[] = { - { ACTOR_EN_SYATEKI_CROW, -1000.0f, 200.0f, -700.0f, 0x0 }, - { ACTOR_EN_SYATEKI_CROW, -1000.0f, 200.0f, -700.0f, 0x100 }, - { ACTOR_EN_SYATEKI_DEKUNUTS, -1000.0f, 200.0f, -700.0f, 0x1 }, - { ACTOR_EN_SYATEKI_DEKUNUTS, -1000.0f, 200.0f, -700.0f, 0x11 }, - { ACTOR_EN_SYATEKI_CROW, -1000.0f, 200.0f, -700.0f, 0x202 }, - { ACTOR_EN_SYATEKI_CROW, -1000.0f, 200.0f, -700.0f, 0x302 }, - { ACTOR_EN_SYATEKI_CROW, -1000.0f, 200.0f, -700.0f, 0x3 }, - { ACTOR_EN_SYATEKI_CROW, -1000.0f, 200.0f, -700.0f, 0x103 }, - { ACTOR_EN_SYATEKI_CROW, -1000.0f, 200.0f, -700.0f, 0x423 }, - { ACTOR_EN_SYATEKI_CROW, -1000.0f, 200.0f, -700.0f, 0x204 }, - { ACTOR_EN_SYATEKI_CROW, -1000.0f, 200.0f, -700.0f, 0x304 }, - { ACTOR_EN_SYATEKI_CROW, -1000.0f, 200.0f, -700.0f, 0x424 }, - { ACTOR_EN_SYATEKI_WF, -1000.0f, 200.0f, -700.0f, 0x25 }, - { ACTOR_EN_SYATEKI_WF, -1000.0f, 200.0f, -700.0f, 0x136 }, +/** + * This actor list is never used in-game and doesn't work properly if modded in. + * Without any "normal" Deku Scrubs, the game will not progress beyond the first wave. + */ +static SwampTargetActorEntry sUnusedSwampTargetActorList[] = { + { ACTOR_EN_SYATEKI_CROW, -1000.0f, 200.0f, -700.0f, EN_SYATEKI_CROW_PARAMS(0, 0, 0) }, + { ACTOR_EN_SYATEKI_CROW, -1000.0f, 200.0f, -700.0f, EN_SYATEKI_CROW_PARAMS(1, 0, 0) }, + { ACTOR_EN_SYATEKI_DEKUNUTS, -1000.0f, 200.0f, -700.0f, EN_SYATEKI_DEKUNUTS_PARAMS(0, 0, 1) }, + { ACTOR_EN_SYATEKI_DEKUNUTS, -1000.0f, 200.0f, -700.0f, EN_SYATEKI_DEKUNUTS_PARAMS(0, 1, 1) }, + { ACTOR_EN_SYATEKI_CROW, -1000.0f, 200.0f, -700.0f, EN_SYATEKI_CROW_PARAMS(2, 0, 2) }, + { ACTOR_EN_SYATEKI_CROW, -1000.0f, 200.0f, -700.0f, EN_SYATEKI_CROW_PARAMS(3, 0, 2) }, + { ACTOR_EN_SYATEKI_CROW, -1000.0f, 200.0f, -700.0f, EN_SYATEKI_CROW_PARAMS(0, 0, 3) }, + { ACTOR_EN_SYATEKI_CROW, -1000.0f, 200.0f, -700.0f, EN_SYATEKI_CROW_PARAMS(1, 0, 3) }, + { ACTOR_EN_SYATEKI_CROW, -1000.0f, 200.0f, -700.0f, EN_SYATEKI_CROW_PARAMS(4, 2, 3) }, + { ACTOR_EN_SYATEKI_CROW, -1000.0f, 200.0f, -700.0f, EN_SYATEKI_CROW_PARAMS(2, 0, 4) }, + { ACTOR_EN_SYATEKI_CROW, -1000.0f, 200.0f, -700.0f, EN_SYATEKI_CROW_PARAMS(3, 0, 4) }, + { ACTOR_EN_SYATEKI_CROW, -1000.0f, 200.0f, -700.0f, EN_SYATEKI_CROW_PARAMS(4, 2, 4) }, + { ACTOR_EN_SYATEKI_WF, -1000.0f, 200.0f, -700.0f, EN_SYATEKI_WF_PARAMS(0, 2, 5) }, + { ACTOR_EN_SYATEKI_WF, -1000.0f, 200.0f, -700.0f, EN_SYATEKI_WF_PARAMS(1, 3, 6) }, }; -static EnSyatekiManUnkStruct* D_809C9464[] = { - D_809C91D0, - D_809C934C, +static SwampTargetActorEntry* sSwampTargetActorLists[] = { + sNormalSwampTargetActorList, + sUnusedSwampTargetActorList, }; -static s32 D_809C946C[] = { - ARRAY_COUNT(D_809C91D0), - ARRAY_COUNT(D_809C934C), +static s32 sSwampTargetActorListLengths[] = { + ARRAY_COUNT(sNormalSwampTargetActorList), + ARRAY_COUNT(sUnusedSwampTargetActorList), }; -static Vec3f D_809C9474 = { 0.0f, 10.0f, 140.0f }; -static Vec3f D_809C9480 = { -20.0f, 20.0f, 198.0f }; -static Vec3f D_809C948C = { -20.0f, 40.0f, 175.0f }; +static Vec3f sSwampPlayerPos = { 0.0f, 10.0f, 140.0f }; +static Vec3f sTownFierceDietyPlayerPos = { -20.0f, 20.0f, 198.0f }; +static Vec3f sTownPlayerPos = { -20.0f, 40.0f, 175.0f }; -void func_809C64C0(EnSyatekiMan* this, GlobalContext* globalCtx2, EnSyatekiManUnkStruct arg2[], s32 arg3) { - GlobalContext* globalCtx = globalCtx2; +/** + * Spawns all the actors used as targets in the Swamp Shooting Gallery. + */ +void EnSyatekiMan_Swamp_SpawnTargetActors(EnSyatekiMan* this, PlayState* play2, SwampTargetActorEntry actorList[], + s32 actorListLength) { + PlayState* play = play2; s32 i; - for (i = 0; i < arg3; i++) { - Actor_SpawnAsChild(&globalCtx->actorCtx, &this->actor, globalCtx, arg2[i].index, arg2[i].x, arg2[i].y, - arg2[i].z, 0, 0, 0, arg2[i].variable); + for (i = 0; i < actorListLength; i++) { + Actor_SpawnAsChild(&play->actorCtx, &this->actor, play, actorList[i].actorId, actorList[i].pos.x, + actorList[i].pos.y, actorList[i].pos.z, 0, 0, 0, actorList[i].params); } } -void EnSyatekiMan_Init(Actor* thisx, GlobalContext* globalCtx) { +void EnSyatekiMan_Init(Actor* thisx, PlayState* play) { EnSyatekiMan* this = THIS; s32 pad; - Path* sp34 = &globalCtx->setupPathList[ENSYATEKIMAN_GET_FF00(&this->actor)]; - s32 sp30 = D_809C946C[this->unk_194]; + Path* path = &play->setupPathList[EN_SYATEKI_MAN_GET_PATH(&this->actor)]; + s32 actorListLength = sSwampTargetActorListLengths[this->swampTargetActorListIndex]; this->actor.targetMode = 1; Actor_SetScale(&this->actor, 0.01f); - if (globalCtx->sceneNum == SCENE_SYATEKI_MORI) { - SkelAnime_InitFlex(globalCtx, &this->skelAnime, &gObjectShnSkel, &object_shn_Anim_00DFEC, this->jointTable, - this->morphTable, OBJECT_SHN_LIMB_MAX); + if (play->sceneNum == SCENE_SYATEKI_MORI) { + SkelAnime_InitFlex(play, &this->skelAnime, &gBurlyGuySkel, &gSwampShootingGalleryManHeadScratchLoopAnim, + this->jointTable, this->morphTable, BURLY_GUY_LIMB_MAX); } else { - SkelAnime_InitFlex(globalCtx, &this->skelAnime, &gObjectShnSkel, &object_shn_Anim_00D9D0, this->jointTable, - this->morphTable, OBJECT_SHN_LIMB_MAX); + SkelAnime_InitFlex(play, &this->skelAnime, &gBurlyGuySkel, &gBurlyGuyHandsOnTableAnim, this->jointTable, + this->morphTable, BURLY_GUY_LIMB_MAX); } this->actor.colChkInfo.cylRadius = 100; - this->actionFunc = func_809C6810; - this->unk_26A = 0; - this->unk_270 = 15; - this->unk_27E = 0; - this->unk_26E = 0; - this->unk_190 = 0; - this->unk_272 = 0; - this->unk_274 = 0; - this->unk_280 = 0; - this->unk_278 = 0; - this->unk_27A = 0; - this->unk_284 = 0; - this->unk_194 = 0; - this->unk_282 = 0; - this->unk_264 = 0; - this->unk_266 = 0; + this->actionFunc = EnSyatekiMan_SetupIdle; + this->shootingGameState = SG_GAME_STATE_NONE; + this->talkWaitTimer = 15; + this->flagsIndex = 0; + this->perGameVar2.octorokHitType = SG_OCTO_HIT_TYPE_NONE; + this->octorokFlags = 0; + this->dekuScrubFlags = 0; + this->guayFlags = 0; + this->score = 0; + this->dekuScrubHitCounter = 0; + this->guayHitCounter = 0; + this->prevTextId = 0; + this->swampTargetActorListIndex = 0; + this->talkFlags = TALK_FLAG_NONE; + this->eyeIndex = 0; + this->blinkTimer = 0; - if (globalCtx->sceneNum == SCENE_SYATEKI_MORI) { - this->path = sp34; - func_809C64C0(this, globalCtx, D_809C9464[this->unk_194], sp30); + if (play->sceneNum == SCENE_SYATEKI_MORI) { + this->path = path; + EnSyatekiMan_Swamp_SpawnTargetActors(this, play, sSwampTargetActorLists[this->swampTargetActorListIndex], + actorListLength); } } -void EnSyatekiMan_Destroy(Actor* thisx, GlobalContext* globalCtx) { +void EnSyatekiMan_Destroy(Actor* thisx, PlayState* play) { gSaveContext.save.weekEventReg[63] &= (u8)~1; } -s32 func_809C6720(GlobalContext* globalCtx, Vec3f arg1) { - Player* player = GET_PLAYER(globalCtx); - f32 sp28; - f32 phi_f0; - s16 sp22 = Math_Vec3f_Yaw(&player->actor.world.pos, &arg1); +/** + * Moves the player to the destination through automated control stick movements. + * This is used to move the player to the right place to play the shooting game. + */ +s32 EnSyatekiMan_MovePlayerToPos(PlayState* play, Vec3f pos) { + Player* player = GET_PLAYER(play); + f32 distXZ; + f32 magnitude; + s16 yaw = Math_Vec3f_Yaw(&player->actor.world.pos, &pos); - sp28 = Math_Vec3f_DistXZ(&player->actor.world.pos, &arg1); + distXZ = Math_Vec3f_DistXZ(&player->actor.world.pos, &pos); - if (sp28 < 5.0f) { - phi_f0 = 10.0f; - } else if (sp28 < 30.0f) { - phi_f0 = 40.0f; + if (distXZ < 5.0f) { + magnitude = 10.0f; + } else if (distXZ < 30.0f) { + magnitude = 40.0f; } else { - phi_f0 = 80.0f; + magnitude = 80.0f; } - globalCtx->actorCtx.unk268 = 1; - func_800B6F20(globalCtx, &globalCtx->actorCtx.unk_26C, phi_f0, sp22); + play->actorCtx.unk268 = 1; + func_800B6F20(play, &play->actorCtx.unk_26C, magnitude, yaw); - if (sp28 < 5.0f) { + if (distXZ < 5.0f) { return true; } return false; } -void func_809C6810(EnSyatekiMan* this, GlobalContext* globalCtx) { - if (globalCtx->sceneNum == SCENE_SYATEKI_MORI) { - this->actionFunc = func_809C6848; - } else if (globalCtx->sceneNum == SCENE_SYATEKI_MIZU) { - this->actionFunc = func_809C72D8; +void EnSyatekiMan_SetupIdle(EnSyatekiMan* this, PlayState* play) { + if (play->sceneNum == SCENE_SYATEKI_MORI) { + this->actionFunc = EnSyatekiMan_Swamp_Idle; + } else if (play->sceneNum == SCENE_SYATEKI_MIZU) { + this->actionFunc = EnSyatekiMan_Town_Idle; } } -void func_809C6848(EnSyatekiMan* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); +void EnSyatekiMan_Swamp_Idle(EnSyatekiMan* this, PlayState* play) { + Player* player = GET_PLAYER(play); - if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { - u16 sp22; + if (Actor_ProcessTalkRequest(&this->actor, &play->state)) { + u16 faceReactionTextId; - Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 2); - sp22 = Text_GetFaceReaction(globalCtx, 0x31); - if (sp22 != 0) { - Message_StartTextbox(globalCtx, sp22, &this->actor); - this->unk_284 = sp22; + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, EN_SYATEKI_MAN_ANIM_SWAMP_HEAD_SCRATCH_END); + faceReactionTextId = Text_GetFaceReaction(play, 0x31); + if (faceReactionTextId != 0) { + Message_StartTextbox(play, faceReactionTextId, &this->actor); + this->prevTextId = faceReactionTextId; } else if (player->transformation == PLAYER_FORM_HUMAN) { - if (this->unk_282 == 0) { - this->unk_282 = 1; - Message_StartTextbox(globalCtx, 0xA28, &this->actor); - this->unk_284 = 0xA28; + if (this->talkFlags == TALK_FLAG_NONE) { + this->talkFlags = TALK_FLAG_SWAMP_HAS_SPOKEN_WITH_HUMAN; + // How are you? Wanna play? + Message_StartTextbox(play, 0xA28, &this->actor); + this->prevTextId = 0xA28; } else { - Message_StartTextbox(globalCtx, 0xA29, &this->actor); - this->unk_284 = 0xA29; + // Won't you play? + Message_StartTextbox(play, 0xA29, &this->actor); + this->prevTextId = 0xA29; } } else { switch (CURRENT_DAY) { case 1: - Message_StartTextbox(globalCtx, 0xA38, &this->actor); - this->unk_284 = 0xA38; + // You can't play if you don't have a bow! (Day 1) + Message_StartTextbox(play, 0xA38, &this->actor); + this->prevTextId = 0xA38; break; case 2: - Message_StartTextbox(globalCtx, 0xA39, &this->actor); - this->unk_284 = 0xA39; + // You can't play if you don't have a bow! (Day 2) + Message_StartTextbox(play, 0xA39, &this->actor); + this->prevTextId = 0xA39; break; case 3: - Message_StartTextbox(globalCtx, 0xA3A, &this->actor); - this->unk_284 = 0xA3A; + // You can't play if you don't have a bow! (Day 3) + Message_StartTextbox(play, 0xA3A, &this->actor); + this->prevTextId = 0xA3A; break; } } - this->actionFunc = func_809C6E30; + this->actionFunc = EnSyatekiMan_Swamp_Talk; } else { - func_800B8614(&this->actor, globalCtx, 120.0f); + func_800B8614(&this->actor, play, 120.0f); } if (player->actor.world.pos.z < 135.0f) { @@ -249,518 +307,569 @@ void func_809C6848(EnSyatekiMan* this, GlobalContext* globalCtx) { } } -void func_809C6A04(EnSyatekiMan* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); +void EnSyatekiMan_Swamp_HandleChoice(EnSyatekiMan* this, PlayState* play) { + Player* player = GET_PLAYER(play); - if (Message_ShouldAdvance(globalCtx)) { - if (globalCtx->msgCtx.choiceIndex == 0) { - if (!CUR_UPG_VALUE(UPG_QUIVER)) { + if (Message_ShouldAdvance(play)) { + if (play->msgCtx.choiceIndex == 0) { + if (CUR_UPG_VALUE(UPG_QUIVER) == 0) { play_sound(NA_SE_SY_ERROR); - Message_StartTextbox(globalCtx, 0xA30, &this->actor); - this->unk_284 = 0xA30; + + // You don't have a bow! + Message_StartTextbox(play, 0xA30, &this->actor); + this->prevTextId = 0xA30; } else if (gSaveContext.save.playerData.rupees < 20) { play_sound(NA_SE_SY_ERROR); - Message_StartTextbox(globalCtx, 0xA31, &this->actor); - this->unk_284 = 0xA31; - if (this->unk_26A == 4) { + + // You don't have enough rupees! + Message_StartTextbox(play, 0xA31, &this->actor); + this->prevTextId = 0xA31; + if (this->shootingGameState == SG_GAME_STATE_ONE_MORE_GAME) { gSaveContext.minigameState = 3; } - this->unk_26A = 3; + + this->shootingGameState = SG_GAME_STATE_NOT_PLAYING; } else { func_8019F208(); - func_801159EC(-20); + Rupees_ChangeBy(-20); gSaveContext.save.weekEventReg[63] |= 1; gSaveContext.save.weekEventReg[63] &= (u8)~2; - globalCtx->msgCtx.msgMode = 0x43; - globalCtx->msgCtx.unk12023 = 4; - this->unk_26A = 7; + play->msgCtx.msgMode = 0x43; + play->msgCtx.stateTimer = 4; + this->shootingGameState = SG_GAME_STATE_MOVING_PLAYER; player->stateFlags1 |= 0x20; - this->actionFunc = func_809C7FFC; + this->actionFunc = EnSyatekiMan_Swamp_MovePlayerAndExplainRules; } } else { func_8019F230(); switch (CURRENT_DAY) { case 1: - Message_StartTextbox(globalCtx, 0xA2D, &this->actor); - this->unk_284 = 0xA2D; + // You're not playing? Please come again. + Message_StartTextbox(play, 0xA2D, &this->actor); + this->prevTextId = 0xA2D; break; case 2: - Message_StartTextbox(globalCtx, 0xA2E, &this->actor); - this->unk_284 = 0xA2E; + // You're not playing? Day after tomorrow is the carnival. + Message_StartTextbox(play, 0xA2E, &this->actor); + this->prevTextId = 0xA2E; break; case 3: - Message_StartTextbox(globalCtx, 0xA2F, &this->actor); - this->unk_284 = 0xA2F; + // You're not playing? Is something happening outside? + Message_StartTextbox(play, 0xA2F, &this->actor); + this->prevTextId = 0xA2F; break; } - if (this->unk_26A == 4) { + if (this->shootingGameState == SG_GAME_STATE_ONE_MORE_GAME) { gSaveContext.minigameState = 3; } - this->unk_26A = 3; + this->shootingGameState = SG_GAME_STATE_NOT_PLAYING; } } } -void func_809C6C2C(EnSyatekiMan* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); +void EnSyatekiMan_Swamp_HandleNormalMessage(EnSyatekiMan* this, PlayState* play) { + Player* player = GET_PLAYER(play); - if (Message_ShouldAdvance(globalCtx)) { - switch (this->unk_284) { - case 0xA28: - case 0xA29: - Message_StartTextbox(globalCtx, 0xA2A, &this->actor); - this->unk_284 = 0xA2A; + if (Message_ShouldAdvance(play)) { + switch (this->prevTextId) { + case 0xA28: // How are you? Wanna play? + case 0xA29: // Won't you play? + // It costs 20 rupees to play. + Message_StartTextbox(play, 0xA2A, &this->actor); + this->prevTextId = 0xA2A; break; - case 0xA2B: - case 0xA2C: - case 0xA35: - globalCtx->msgCtx.msgMode = 0x43; - globalCtx->msgCtx.unk12023 = 4; + case 0xA2B: // The rules of the game are a piece of cake! + case 0xA2C: // I keep saying - you have to aim with [Control Stick]! + case 0xA35: // You almost had it! Well...just this once...here you go! + play->msgCtx.msgMode = 0x43; + play->msgCtx.stateTimer = 4; player->actor.freezeTimer = 0; - func_80112AFC(globalCtx); - globalCtx->interfaceCtx.hbaAmmo = 80; - func_80123F2C(globalCtx, 80); - this->unk_26A = 1; - this->actionFunc = func_809C80C0; + func_80112AFC(play); + play->interfaceCtx.hbaAmmo = 80; + func_80123F2C(play, 80); + this->shootingGameState = SG_GAME_STATE_RUNNING; + this->actionFunc = EnSyatekiMan_Swamp_StartGame; func_801A2BB8(NA_BGM_MINI_GAME_2); break; - case 0xA32: + case 0xA32: // You have to try harder! if (gSaveContext.save.weekEventReg[63] & 2) { - func_801477B4(globalCtx); + func_801477B4(play); player->stateFlags1 &= ~0x20; gSaveContext.save.weekEventReg[63] &= (u8)~1; gSaveContext.save.weekEventReg[63] &= (u8)~2; - this->actionFunc = func_809C6848; + this->actionFunc = EnSyatekiMan_Swamp_Idle; gSaveContext.minigameState = 3; - this->unk_26A = 0; + this->shootingGameState = SG_GAME_STATE_NONE; } else { - Message_StartTextbox(globalCtx, 0xA33, &this->actor); - this->unk_284 = 0xA33; + // Wanna play again? + Message_StartTextbox(play, 0xA33, &this->actor); + this->prevTextId = 0xA33; } break; - case 0xA33: - Message_StartTextbox(globalCtx, 0xA2A, &this->actor); - this->unk_284 = 0xA2A; - this->unk_26A = 4; + case 0xA33: // Wanna play again? + // It costs 20 rupees to play. + Message_StartTextbox(play, 0xA2A, &this->actor); + this->prevTextId = 0xA2A; + this->shootingGameState = SG_GAME_STATE_ONE_MORE_GAME; break; - case 0xA34: - globalCtx->msgCtx.msgMode = 0x43; - globalCtx->msgCtx.unk12023 = 4; + case 0xA34: // Perfect! Take this! + play->msgCtx.msgMode = 0x43; + play->msgCtx.stateTimer = 4; player->actor.freezeTimer = 0; gSaveContext.minigameState = 3; player->stateFlags1 |= 0x20; - this->actionFunc = func_809C7A90; - func_809C7A90(this, globalCtx); + this->actionFunc = EnSyatekiMan_Swamp_SetupGiveReward; + EnSyatekiMan_Swamp_SetupGiveReward(this, play); break; } } } -void func_809C6E30(EnSyatekiMan* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); +void EnSyatekiMan_Swamp_Talk(EnSyatekiMan* this, PlayState* play) { + Player* player = GET_PLAYER(play); if (player->stateFlags1 & 0x20) { player->stateFlags1 |= 0x20; } - switch (Message_GetState(&globalCtx->msgCtx)) { - case 2: - this->actionFunc = func_809C6848; - this->unk_26A = 0; + switch (Message_GetState(&play->msgCtx)) { + case TEXT_STATE_CLOSING: + this->actionFunc = EnSyatekiMan_Swamp_Idle; + this->shootingGameState = SG_GAME_STATE_NONE; break; - case 4: - func_809C6A04(this, globalCtx); + case TEXT_STATE_CHOICE: + EnSyatekiMan_Swamp_HandleChoice(this, play); break; - case 5: - func_809C6C2C(this, globalCtx); + case TEXT_STATE_5: + EnSyatekiMan_Swamp_HandleNormalMessage(this, play); break; - case 6: - if (Message_ShouldAdvance(globalCtx)) { - globalCtx->msgCtx.msgMode = 0x43; - globalCtx->msgCtx.unk12023 = 4; + case TEXT_STATE_DONE: + if (Message_ShouldAdvance(play)) { + play->msgCtx.msgMode = 0x43; + play->msgCtx.stateTimer = 4; player->stateFlags1 &= ~0x20; gSaveContext.save.weekEventReg[63] &= (u8)~1; gSaveContext.save.weekEventReg[63] &= (u8)~2; - this->actionFunc = func_809C6848; - this->unk_26A = 0; + this->actionFunc = EnSyatekiMan_Swamp_Idle; + this->shootingGameState = SG_GAME_STATE_NONE; } break; - case 0: - case 1: - case 3: - case 7: - case 8: - case 9: - case 10: + case TEXT_STATE_NONE: + case TEXT_STATE_1: + case TEXT_STATE_3: + case TEXT_STATE_7: + case TEXT_STATE_8: + case TEXT_STATE_9: + case TEXT_STATE_10: break; } - if (this->skelAnime.animation == &object_shn_Anim_00D2F8) { + if (this->skelAnime.animation == &gSwampShootingGalleryManHeadScratchEndAnim) { if (Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) { - Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 0); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, EN_SYATEKI_MAN_ANIM_HANDS_ON_TABLE); } } } -void func_809C6F98(EnSyatekiMan* this, GlobalContext* globalCtx) { +void EnSyatekiMan_Town_StartIntroTextbox(EnSyatekiMan* this, PlayState* play) { switch (gSaveContext.save.playerForm) { case PLAYER_FORM_HUMAN: - Flags_SetAllTreasure(globalCtx, Flags_GetAllTreasure(globalCtx) + 1); + Flags_SetAllTreasure(play, Flags_GetAllTreasure(play) + 1); if (CURRENT_DAY != 3) { - if (!(this->unk_282 & 1)) { - this->unk_282 |= 1; - Message_StartTextbox(globalCtx, 0x3E8, &this->actor); - this->unk_284 = 0x3E8; + if (!(this->talkFlags & TALK_FLAG_TOWN_HAS_SPOKEN_WITH_HUMAN)) { + this->talkFlags |= TALK_FLAG_TOWN_HAS_SPOKEN_WITH_HUMAN; + // Why don't you give it a try? + Message_StartTextbox(play, 0x3E8, &this->actor); + this->prevTextId = 0x3E8; } else { - Message_StartTextbox(globalCtx, 0x3E9, &this->actor); - this->unk_284 = 0x3E9; + // Wanna try? + Message_StartTextbox(play, 0x3E9, &this->actor); + this->prevTextId = 0x3E9; } - } else if (!(this->unk_282 & 1)) { - this->unk_282 |= 1; - Message_StartTextbox(globalCtx, 0x3EA, &this->actor); - this->unk_284 = 0x3EA; + } else if (!(this->talkFlags & TALK_FLAG_TOWN_HAS_SPOKEN_WITH_HUMAN)) { + this->talkFlags |= TALK_FLAG_TOWN_HAS_SPOKEN_WITH_HUMAN; + // If you still have time, why don't you try it? + Message_StartTextbox(play, 0x3EA, &this->actor); + this->prevTextId = 0x3EA; } else { - Message_StartTextbox(globalCtx, 0x3EB, &this->actor); - this->unk_284 = 0x3EB; + // How about it? Wanna try? + Message_StartTextbox(play, 0x3EB, &this->actor); + this->prevTextId = 0x3EB; } break; case PLAYER_FORM_DEKU: if (CURRENT_DAY != 3) { - if (!(this->unk_282 & 2)) { - this->unk_282 |= 2; - Message_StartTextbox(globalCtx, 0x3EC, &this->actor); - this->unk_284 = 0x3EC; + if (!(this->talkFlags & TALK_FLAG_TOWN_HAS_SPOKEN_WITH_DEKU)) { + this->talkFlags |= TALK_FLAG_TOWN_HAS_SPOKEN_WITH_DEKU; + // When I saw your fairy, I thought you were that masked troublemaker. + Message_StartTextbox(play, 0x3EC, &this->actor); + this->prevTextId = 0x3EC; } else { - Message_StartTextbox(globalCtx, 0x3ED, &this->actor); - this->unk_284 = 0x3ED; + // You can't play because you don't have a bow. + Message_StartTextbox(play, 0x3ED, &this->actor); + this->prevTextId = 0x3ED; } - } else if (!(this->unk_282 & 2)) { - this->unk_282 |= 2; - Message_StartTextbox(globalCtx, 0x3EE, &this->actor); - this->unk_284 = 0x3EE; + } else if (!(this->talkFlags & TALK_FLAG_TOWN_HAS_SPOKEN_WITH_DEKU)) { + this->talkFlags |= TALK_FLAG_TOWN_HAS_SPOKEN_WITH_DEKU; + // I thought you were a customer, but I guess I can't expect any... + Message_StartTextbox(play, 0x3EE, &this->actor); + this->prevTextId = 0x3EE; } else { - Message_StartTextbox(globalCtx, 0x3EF, &this->actor); - this->unk_284 = 0x3EF; + // Stop hanging around and go home! + Message_StartTextbox(play, 0x3EF, &this->actor); + this->prevTextId = 0x3EF; } break; case PLAYER_FORM_ZORA: if (CURRENT_DAY != 3) { - if (!(this->unk_282 & 8)) { - this->unk_282 |= 8; - Message_StartTextbox(globalCtx, 0x3F0, &this->actor); - this->unk_284 = 0x3F0; + if (!(this->talkFlags & TALK_FLAG_TOWN_HAS_SPOKEN_WITH_ZORA)) { + this->talkFlags |= TALK_FLAG_TOWN_HAS_SPOKEN_WITH_ZORA; + // I swear I've seen you before... + Message_StartTextbox(play, 0x3F0, &this->actor); + this->prevTextId = 0x3F0; } else { - Message_StartTextbox(globalCtx, 0x3F1, &this->actor); - this->unk_284 = 0x3F1; + // If you don't have a bow, you can't play. + Message_StartTextbox(play, 0x3F1, &this->actor); + this->prevTextId = 0x3F1; } - } else if (!(this->unk_282 & 8)) { - this->unk_282 |= 8; - Message_StartTextbox(globalCtx, 0x3F4, &this->actor); - this->unk_284 = 0x3F4; + } else if (!(this->talkFlags & TALK_FLAG_TOWN_HAS_SPOKEN_WITH_ZORA)) { + this->talkFlags |= TALK_FLAG_TOWN_HAS_SPOKEN_WITH_ZORA; + // Huh? You're still here? + Message_StartTextbox(play, 0x3F4, &this->actor); + this->prevTextId = 0x3F4; } else { - Message_StartTextbox(globalCtx, 0x3F5, &this->actor); - this->unk_284 = 0x3F5; + // Haven't you heard the news? + Message_StartTextbox(play, 0x3F5, &this->actor); + this->prevTextId = 0x3F5; } break; case PLAYER_FORM_GORON: if (CURRENT_DAY != 3) { - if (!(this->unk_282 & 4)) { - this->unk_282 |= 4; - Message_StartTextbox(globalCtx, 0x3F2, &this->actor); - this->unk_284 = 0x3F2; + if (!(this->talkFlags & TALK_FLAG_TOWN_HAS_SPOKEN_WITH_GORON)) { + this->talkFlags |= TALK_FLAG_TOWN_HAS_SPOKEN_WITH_GORON; + // You have quite the build! + Message_StartTextbox(play, 0x3F2, &this->actor); + this->prevTextId = 0x3F2; } else { - Message_StartTextbox(globalCtx, 0x3F3, &this->actor); - this->unk_284 = 0x3F3; + // Sorry...you don't have a bow. + Message_StartTextbox(play, 0x3F3, &this->actor); + this->prevTextId = 0x3F3; } - } else if (!(this->unk_282 & 4)) { - this->unk_282 |= 4; - Message_StartTextbox(globalCtx, 0x3F4, &this->actor); - this->unk_284 = 0x3F4; + } else if (!(this->talkFlags & TALK_FLAG_TOWN_HAS_SPOKEN_WITH_GORON)) { + this->talkFlags |= TALK_FLAG_TOWN_HAS_SPOKEN_WITH_GORON; + // Huh? You're still here? + Message_StartTextbox(play, 0x3F4, &this->actor); + this->prevTextId = 0x3F4; } else { - Message_StartTextbox(globalCtx, 0x3F5, &this->actor); - this->unk_284 = 0x3F5; + // Haven't you heard the news? + Message_StartTextbox(play, 0x3F5, &this->actor); + this->prevTextId = 0x3F5; } break; } } -void func_809C72D8(EnSyatekiMan* this, GlobalContext* globalCtx) { - if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { - u16 sp26 = Text_GetFaceReaction(globalCtx, 0x30); +void EnSyatekiMan_Town_Idle(EnSyatekiMan* this, PlayState* play) { + if (Actor_ProcessTalkRequest(&this->actor, &play->state)) { + u16 faceReactionTextId = Text_GetFaceReaction(play, 0x30); - if (sp26 != 0) { - Message_StartTextbox(globalCtx, sp26, &this->actor); - this->unk_284 = sp26; + if (faceReactionTextId != 0) { + Message_StartTextbox(play, faceReactionTextId, &this->actor); + this->prevTextId = faceReactionTextId; } else { - func_809C6F98(this, globalCtx); + EnSyatekiMan_Town_StartIntroTextbox(this, play); } - this->actionFunc = func_809C7990; + + this->actionFunc = EnSyatekiMan_Town_Talk; } else { - func_800B8614(&this->actor, globalCtx, 120.0f); + func_800B8614(&this->actor, play, 120.0f); } } -void func_809C7380(EnSyatekiMan* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); +void EnSyatekiMan_Town_HandleChoice(EnSyatekiMan* this, PlayState* play) { + Player* player = GET_PLAYER(play); - if (Message_ShouldAdvance(globalCtx)) { - if (globalCtx->msgCtx.choiceIndex == 0) { - if (!CUR_UPG_VALUE(UPG_QUIVER)) { + if (Message_ShouldAdvance(play)) { + if (play->msgCtx.choiceIndex == 0) { + if (CUR_UPG_VALUE(UPG_QUIVER) == 0) { play_sound(NA_SE_SY_ERROR); if (CURRENT_DAY != 3) { - Message_StartTextbox(globalCtx, 0x3F9, &this->actor); - this->unk_284 = 0x3F9; + // You don't have a bow? Then you can't play. + Message_StartTextbox(play, 0x3F9, &this->actor); + this->prevTextId = 0x3F9; } else { - Message_StartTextbox(globalCtx, 0x3FA, &this->actor); - this->unk_284 = 0x3FA; + // You don't have a bow? That's too bad. + Message_StartTextbox(play, 0x3FA, &this->actor); + this->prevTextId = 0x3FA; } } else if (gSaveContext.save.playerData.rupees < 20) { play_sound(NA_SE_SY_ERROR); if (CURRENT_DAY != 3) { - Message_StartTextbox(globalCtx, 0x3FB, &this->actor); - this->unk_284 = 0x3FB; + // You don't have a enough rupees! + Message_StartTextbox(play, 0x3FB, &this->actor); + this->prevTextId = 0x3FB; } else { - Message_StartTextbox(globalCtx, 0x3FC, &this->actor); - this->unk_284 = 0x3FC; + // You don't have enough rupees? That's too bad. + Message_StartTextbox(play, 0x3FC, &this->actor); + this->prevTextId = 0x3FC; } - if (this->unk_26A == 4) { + if (this->shootingGameState == SG_GAME_STATE_ONE_MORE_GAME) { player->stateFlags3 &= ~0x400; gSaveContext.minigameState = 3; } - this->unk_26A = 3; + + this->shootingGameState = SG_GAME_STATE_NOT_PLAYING; } else { func_8019F208(); - func_801159EC(-20); - this->unk_26A = 2; - if (!(this->unk_282 & 0x10)) { - this->unk_282 |= 0x10; - Message_StartTextbox(globalCtx, 0x3FD, &this->actor); - this->unk_284 = 0x3FD; + Rupees_ChangeBy(-20); + this->shootingGameState = SG_GAME_STATE_EXPLAINING_RULES; + if (!(this->talkFlags & TALK_FLAG_TOWN_HAS_EXPLAINED_THE_RULES)) { + this->talkFlags |= TALK_FLAG_TOWN_HAS_EXPLAINED_THE_RULES; + // The rules are simple. + Message_StartTextbox(play, 0x3FD, &this->actor); + this->prevTextId = 0x3FD; } else { - Message_StartTextbox(globalCtx, 0x3FF, &this->actor); - this->unk_284 = 0x3FF; + // Aim for the red ones. + Message_StartTextbox(play, 0x3FF, &this->actor); + this->prevTextId = 0x3FF; } + gSaveContext.save.weekEventReg[63] |= 1; gSaveContext.save.weekEventReg[63] &= (u8)~2; } } else { func_8019F230(); if (CURRENT_DAY != 3) { - Message_StartTextbox(globalCtx, 0x3F7, &this->actor); - this->unk_284 = 0x3F7; + // Well, be that way! + Message_StartTextbox(play, 0x3F7, &this->actor); + this->prevTextId = 0x3F7; } else { - Message_StartTextbox(globalCtx, 0x3F8, &this->actor); - this->unk_284 = 0x3F8; + // Usually this place is packed... + Message_StartTextbox(play, 0x3F8, &this->actor); + this->prevTextId = 0x3F8; } - if (this->unk_26A == 4) { + if (this->shootingGameState == SG_GAME_STATE_ONE_MORE_GAME) { player->stateFlags3 &= ~0x400; gSaveContext.minigameState = 3; } - this->unk_26A = 3; + + this->shootingGameState = SG_GAME_STATE_NOT_PLAYING; } } } -void func_809C7620(EnSyatekiMan* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); +void EnSyatekiMan_Town_HandleNormalMessage(EnSyatekiMan* this, PlayState* play) { + Player* player = GET_PLAYER(play); - if (Message_ShouldAdvance(globalCtx)) { - switch (this->unk_284) { - case 0x3E8: - case 0x3E9: - case 0x3EA: - case 0x3EB: - Message_StartTextbox(globalCtx, 0x3F6, &this->actor); - this->unk_284 = 0x3F6; + if (Message_ShouldAdvance(play)) { + switch (this->prevTextId) { + case 0x3E8: // Why don't you give it a try? + case 0x3E9: // Wanna try? + case 0x3EA: // If you still have time, why don't you try it? + case 0x3EB: // How about it? Wanna try? + // One game is 20 rupees. + Message_StartTextbox(play, 0x3F6, &this->actor); + this->prevTextId = 0x3F6; break; - case 0x3EC: - Message_StartTextbox(globalCtx, 0x3ED, &this->actor); - this->unk_284 = 0x3ED; + case 0x3EC: // When I saw your fairy, I thought you were that masked troublemaker. + // You can't play because you don't have a bow. + Message_StartTextbox(play, 0x3ED, &this->actor); + this->prevTextId = 0x3ED; break; - case 0x3EE: - Message_StartTextbox(globalCtx, 0x3EF, &this->actor); - this->unk_284 = 0x3EF; + case 0x3EE: // I thought you were a customer, but I guess I can't expect any... + // Stop hanging around and go home! + Message_StartTextbox(play, 0x3EF, &this->actor); + this->prevTextId = 0x3EF; break; - case 0x3F0: - Message_StartTextbox(globalCtx, 0x3F1, &this->actor); - this->unk_284 = 0x3F1; + case 0x3F0: // I swear I've seen you before... + // If you don't have a bow, you can't play. + Message_StartTextbox(play, 0x3F1, &this->actor); + this->prevTextId = 0x3F1; break; - case 0x3F2: - Message_StartTextbox(globalCtx, 0x3F3, &this->actor); - this->unk_284 = 0x3F3; + case 0x3F2: // You have quite the build! + // Sorry...you don't have a bow. + Message_StartTextbox(play, 0x3F3, &this->actor); + this->prevTextId = 0x3F3; break; - case 0x3F4: - Message_StartTextbox(globalCtx, 0x3F5, &this->actor); - this->unk_284 = 0x3F5; + case 0x3F4: // Huh? You're still here? + // Haven't you heard the news? + Message_StartTextbox(play, 0x3F5, &this->actor); + this->prevTextId = 0x3F5; break; - case 0x3FD: - case 0x3FF: - if (this->unk_26A == 4) { - if (this->unk_284 == 0x3FD) { - Message_StartTextbox(globalCtx, 0x3FE, &this->actor); - this->unk_284 = 0x3FE; + case 0x3FD: // The rules are simple. + case 0x3FF: // Aim for the red ones. + if (this->shootingGameState == SG_GAME_STATE_ONE_MORE_GAME) { + if (this->prevTextId == 0x3FD) { + // Our highest score is [score]. If you break the record, you'll win a prize! + Message_StartTextbox(play, 0x3FE, &this->actor); + this->prevTextId = 0x3FE; } else { - Message_StartTextbox(globalCtx, 0x400, &this->actor); - this->unk_284 = 0x400; + // Our highest score is [score]. Good luck! + Message_StartTextbox(play, 0x400, &this->actor); + this->prevTextId = 0x400; } } else { - globalCtx->msgCtx.msgMode = 0x43; - globalCtx->msgCtx.unk12023 = 4; + play->msgCtx.msgMode = 0x43; + play->msgCtx.stateTimer = 4; player->actor.freezeTimer = 0; - this->unk_26A = 7; + this->shootingGameState = SG_GAME_STATE_MOVING_PLAYER; player->stateFlags1 |= 0x20; gSaveContext.save.weekEventReg[63] |= 1; gSaveContext.save.weekEventReg[63] &= (u8)~2; - this->actionFunc = func_809C8710; + this->actionFunc = EnSyatekiMan_Town_MovePlayerAndSayHighScore; } break; - case 0x3FE: - case 0x400: - globalCtx->msgCtx.msgMode = 0x43; - globalCtx->msgCtx.unk12023 = 4; + case 0x3FE: // Our highest score is [score]. If you break the record, you'll win a prize! + case 0x400: // Our highest score is [score]. Good luck! + play->msgCtx.msgMode = 0x43; + play->msgCtx.stateTimer = 4; player->actor.freezeTimer = 0; - this->unk_27E = 0; - func_80112AFC(globalCtx); - func_80123F2C(globalCtx, 0x63); - this->unk_26A = 1; + this->flagsIndex = 0; + func_80112AFC(play); + func_80123F2C(play, 0x63); + this->shootingGameState = SG_GAME_STATE_RUNNING; func_801A2BB8(NA_BGM_MINI_GAME_2); - this->actionFunc = func_809C8808; + this->actionFunc = EnSyatekiMan_Town_StartGame; break; - case 0x401: + case 0x401: // You got [score]? Oh, that's too bad... if (gSaveContext.save.weekEventReg[63] & 2) { - func_801477B4(globalCtx); + func_801477B4(play); gSaveContext.save.weekEventReg[63] &= (u8)~1; gSaveContext.save.weekEventReg[63] &= (u8)~2; - this->unk_26A = 0; - this->actionFunc = func_809C72D8; + this->shootingGameState = SG_GAME_STATE_NONE; + this->actionFunc = EnSyatekiMan_Town_Idle; } else { - Message_StartTextbox(globalCtx, 0x402, &this->actor); - this->unk_284 = 0x402; + // You can't stop, can you? You can play as long as you have rupees. + Message_StartTextbox(play, 0x402, &this->actor); + this->prevTextId = 0x402; } break; - case 0x403: + case 0x403: // You got [score]? Too bad... if (gSaveContext.save.weekEventReg[63] & 2) { - func_801477B4(globalCtx); + func_801477B4(play); gSaveContext.save.weekEventReg[63] &= (u8)~1; gSaveContext.save.weekEventReg[63] &= (u8)~2; - this->unk_26A = 0; - this->actionFunc = func_809C72D8; + this->shootingGameState = SG_GAME_STATE_NONE; + this->actionFunc = EnSyatekiMan_Town_Idle; } else { - Message_StartTextbox(globalCtx, 0x404, &this->actor); - this->unk_284 = 0x404; + // Frustrating, right? Wanna try again? + Message_StartTextbox(play, 0x404, &this->actor); + this->prevTextId = 0x404; } break; - case 0x402: - case 0x404: - Message_StartTextbox(globalCtx, 0x3F6, &this->actor); - this->unk_284 = 0x3F6; - this->unk_26A = 4; + case 0x402: // You can't stop, can you? You can play as long as you have rupees. + case 0x404: // Frustrating, right? Wanna try again? + // One game is 20 rupees. + Message_StartTextbox(play, 0x3F6, &this->actor); + this->prevTextId = 0x3F6; + this->shootingGameState = SG_GAME_STATE_ONE_MORE_GAME; break; - case 0x405: - case 0x406: - case 0x407: - globalCtx->msgCtx.msgMode = 0x43; - globalCtx->msgCtx.unk12023 = 4; + case 0x405: // No way! That was perfect! + case 0x406: // That was perfect! + case 0x407: // You got a new record! + play->msgCtx.msgMode = 0x43; + play->msgCtx.stateTimer = 4; player->actor.freezeTimer = 0; gSaveContext.minigameState = 3; - this->actionFunc = func_809C7D14; - func_809C7D14(this, globalCtx); + this->actionFunc = EnSyatekiMan_Town_SetupGiveReward; + EnSyatekiMan_Town_SetupGiveReward(this, play); break; } } } -void func_809C7990(EnSyatekiMan* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); +void EnSyatekiMan_Town_Talk(EnSyatekiMan* this, PlayState* play) { + Player* player = GET_PLAYER(play); if (player->stateFlags1 & 0x20) { player->stateFlags1 |= 0x20; } - switch (Message_GetState(&globalCtx->msgCtx)) { - case 2: - this->actionFunc = func_809C72D8; - this->unk_26A = 0; + switch (Message_GetState(&play->msgCtx)) { + case TEXT_STATE_CLOSING: + this->actionFunc = EnSyatekiMan_Town_Idle; + this->shootingGameState = SG_GAME_STATE_NONE; break; - case 4: - func_809C7380(this, globalCtx); + case TEXT_STATE_CHOICE: + EnSyatekiMan_Town_HandleChoice(this, play); break; - case 5: - func_809C7620(this, globalCtx); + case TEXT_STATE_5: + EnSyatekiMan_Town_HandleNormalMessage(this, play); break; - case 6: - if (Message_ShouldAdvance(globalCtx)) { + case TEXT_STATE_DONE: + if (Message_ShouldAdvance(play)) { gSaveContext.save.weekEventReg[63] &= (u8)~1; gSaveContext.save.weekEventReg[63] &= (u8)~2; player->stateFlags1 &= ~0x20; - this->actionFunc = func_809C72D8; - this->unk_26A = 0; + this->actionFunc = EnSyatekiMan_Town_Idle; + this->shootingGameState = SG_GAME_STATE_NONE; } break; - case 0: - case 1: - case 3: - case 7: - case 8: - case 9: - case 10: + case TEXT_STATE_NONE: + case TEXT_STATE_1: + case TEXT_STATE_3: + case TEXT_STATE_7: + case TEXT_STATE_8: + case TEXT_STATE_9: + case TEXT_STATE_10: break; } } -void func_809C7A90(EnSyatekiMan* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); +void EnSyatekiMan_Swamp_SetupGiveReward(EnSyatekiMan* this, PlayState* play) { + Player* player = GET_PLAYER(play); - if (Actor_HasParent(&this->actor, globalCtx)) { + if (Actor_HasParent(&this->actor, play)) { if (!(gSaveContext.save.weekEventReg[59] & 0x10)) { gSaveContext.save.weekEventReg[59] |= 0x10; - } else if (!(gSaveContext.save.weekEventReg[32] & 2) && (this->unk_280 >= 0x884)) { + } else if (!(gSaveContext.save.weekEventReg[32] & 2) && (this->score >= 2180)) { gSaveContext.save.weekEventReg[32] |= 2; } + this->actor.parent = NULL; - this->actionFunc = func_809C7C14; + this->actionFunc = EnSyatekiMan_Swamp_GiveReward; } else { 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); + Actor_PickUp(&this->actor, play, GI_QUIVER_30 + CUR_UPG_VALUE(UPG_QUIVER), 500.0f, 100.0f); + } else if (this->score < 2180) { + Actor_PickUp(&this->actor, play, GI_RUPEE_RED, 500.0f, 100.0f); } else if (!(gSaveContext.save.weekEventReg[32] & 2)) { - Actor_PickUp(&this->actor, globalCtx, GI_HEART_PIECE, 500.0f, 100.0f); + Actor_PickUp(&this->actor, play, GI_HEART_PIECE, 500.0f, 100.0f); } else { - Actor_PickUp(&this->actor, globalCtx, GI_RUPEE_PURPLE, 500.0f, 100.0f); + Actor_PickUp(&this->actor, play, GI_RUPEE_PURPLE, 500.0f, 100.0f); } player->actor.shape.rot.y = -0x8000; @@ -770,55 +879,59 @@ void func_809C7A90(EnSyatekiMan* this, GlobalContext* globalCtx) { } } -void func_809C7C14(EnSyatekiMan* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); +void EnSyatekiMan_Swamp_GiveReward(EnSyatekiMan* this, PlayState* play) { + Player* player = GET_PLAYER(play); - if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { + if (Actor_ProcessTalkRequest(&this->actor, &play->state)) { if ((CURRENT_DAY == 3) && (gSaveContext.save.time > CLOCK_TIME(12, 0))) { - Message_StartTextbox(globalCtx, 0xA36, &this->actor); - this->unk_284 = 0xA36; + // We've been having a lot of earthquakes lately. + Message_StartTextbox(play, 0xA36, &this->actor); + this->prevTextId = 0xA36; } else { - Message_StartTextbox(globalCtx, 0xA37, &this->actor); - this->unk_284 = 0xA37; + // Tell your friends about us. + Message_StartTextbox(play, 0xA37, &this->actor); + this->prevTextId = 0xA37; } + player->stateFlags1 &= ~0x20; this->actor.flags &= ~ACTOR_FLAG_10000; - this->unk_280 = 0; - this->unk_26A = 0; - this->actionFunc = func_809C6E30; + this->score = 0; + this->shootingGameState = SG_GAME_STATE_NONE; + this->actionFunc = EnSyatekiMan_Swamp_Talk; } else { - func_800B85E0(&this->actor, globalCtx, 500.0f, EXCH_ITEM_MINUS1); + func_800B85E0(&this->actor, play, 500.0f, PLAYER_AP_MINUS1); } } -void func_809C7D14(EnSyatekiMan* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); +void EnSyatekiMan_Town_SetupGiveReward(EnSyatekiMan* this, PlayState* play) { + Player* player = GET_PLAYER(play); - if (Actor_HasParent(&this->actor, globalCtx)) { - if (this->unk_284 == 0x407) { + if (Actor_HasParent(&this->actor, play)) { + if (this->prevTextId == 0x407) { if (!(gSaveContext.save.weekEventReg[59] & 0x20)) { gSaveContext.save.weekEventReg[59] |= 0x20; } } - if ((this->unk_284 == 0x405) || (this->unk_284 == 0x406)) { + if ((this->prevTextId == 0x405) || (this->prevTextId == 0x406)) { if (!(gSaveContext.save.weekEventReg[32] & 4)) { gSaveContext.save.weekEventReg[32] |= 4; } } + this->actor.parent = NULL; - this->actionFunc = func_809C7EB4; + this->actionFunc = EnSyatekiMan_Town_GiveReward; } else { - if (this->unk_284 == 0x407) { + if (this->prevTextId == 0x407) { 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); + Actor_PickUp(&this->actor, play, 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); + Actor_PickUp(&this->actor, play, GI_RUPEE_PURPLE, 500.0f, 100.0f); } } else if (!(gSaveContext.save.weekEventReg[32] & 4)) { - Actor_PickUp(&this->actor, globalCtx, GI_HEART_PIECE, 500.0f, 100.0f); + Actor_PickUp(&this->actor, play, GI_HEART_PIECE, 500.0f, 100.0f); } else { - Actor_PickUp(&this->actor, globalCtx, GI_RUPEE_HUGE, 500.0f, 100.0f); + Actor_PickUp(&this->actor, play, GI_RUPEE_HUGE, 500.0f, 100.0f); } player->actor.shape.rot.y = -0x8000; @@ -828,472 +941,563 @@ void func_809C7D14(EnSyatekiMan* this, GlobalContext* globalCtx) { } } -void func_809C7EB4(EnSyatekiMan* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); +void EnSyatekiMan_Town_GiveReward(EnSyatekiMan* this, PlayState* play) { + Player* player = GET_PLAYER(play); if (CURRENT_DAY != 3) { - if ((Message_GetState(&globalCtx->msgCtx) == 6) && Message_ShouldAdvance(globalCtx)) { + if ((Message_GetState(&play->msgCtx) == TEXT_STATE_DONE) && Message_ShouldAdvance(play)) { player->stateFlags1 &= ~0x20; - this->unk_280 = 0; - this->unk_26A = 0; + this->score = 0; + this->shootingGameState = SG_GAME_STATE_NONE; gSaveContext.save.weekEventReg[63] &= (u8)~1; gSaveContext.save.weekEventReg[63] &= (u8)~2; - this->actionFunc = func_809C6810; + this->actionFunc = EnSyatekiMan_SetupIdle; } - } else if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { - Message_StartTextbox(globalCtx, 0x408, &this->actor); - this->unk_284 = 0x408; + } else if (Actor_ProcessTalkRequest(&this->actor, &play->state)) { + // This may be our last day in business... + Message_StartTextbox(play, 0x408, &this->actor); + this->prevTextId = 0x408; player->stateFlags1 &= ~0x20; this->actor.flags &= ~ACTOR_FLAG_10000; - this->unk_280 = 0; - this->unk_26A = 0; - this->actionFunc = func_809C7990; + this->score = 0; + this->shootingGameState = SG_GAME_STATE_NONE; + this->actionFunc = EnSyatekiMan_Town_Talk; } else { - func_800B85E0(&this->actor, globalCtx, 500.0f, EXCH_ITEM_MINUS1); + func_800B85E0(&this->actor, play, 500.0f, PLAYER_AP_MINUS1); } } -void func_809C7FFC(EnSyatekiMan* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); +void EnSyatekiMan_Swamp_MovePlayerAndExplainRules(EnSyatekiMan* this, PlayState* play) { + Player* player = GET_PLAYER(play); - if (func_809C6720(globalCtx, D_809C9474)) { + if (EnSyatekiMan_MovePlayerToPos(play, sSwampPlayerPos)) { player->stateFlags1 |= 0x20; - this->unk_26A = 2; - if (this->unk_282 != 2) { - this->unk_282 = 2; - Message_StartTextbox(globalCtx, 0xA2B, &this->actor); - this->unk_284 = 0xA2B; + this->shootingGameState = SG_GAME_STATE_EXPLAINING_RULES; + if (this->talkFlags != TALK_FLAG_SWAMP_HAS_EXPLAINED_THE_RULES) { + this->talkFlags = TALK_FLAG_SWAMP_HAS_EXPLAINED_THE_RULES; + // The rules of the game are a piece of cake! + Message_StartTextbox(play, 0xA2B, &this->actor); + this->prevTextId = 0xA2B; } else { - Message_StartTextbox(globalCtx, 0xA2C, &this->actor); - this->unk_284 = 0xA2C; + // I keep saying - you have to aim with [Control Stick]! + Message_StartTextbox(play, 0xA2C, &this->actor); + this->prevTextId = 0xA2C; } - this->actionFunc = func_809C6E30; + + this->actionFunc = EnSyatekiMan_Swamp_Talk; } } -void func_809C80C0(EnSyatekiMan* this, GlobalContext* globalCtx) { - static s16 D_809C9498 = 30; - Player* player = GET_PLAYER(globalCtx); +void EnSyatekiMan_Swamp_StartGame(EnSyatekiMan* this, PlayState* play) { + static s16 sGameStartTimer = 30; + Player* player = GET_PLAYER(play); - if (D_809C9498 > 0) { - player->actor.world.pos = D_809C9474; + if (sGameStartTimer > 0) { + player->actor.world.pos = sSwampPlayerPos; player->actor.shape.rot.y = -0x8000; player->actor.world.rot.y = player->actor.shape.rot.y; - globalCtx->unk_18790(globalCtx, -0x8000, &this->actor); - D_809C9498--; + play->unk_18790(play, -0x8000, &this->actor); + sGameStartTimer--; } else { - D_809C9498 = 30; - this->unk_27E = 0; - this->unk_280 = 0; + sGameStartTimer = 30; + this->flagsIndex = 0; + this->score = 0; player->stateFlags1 &= ~0x20; Actor_PlaySfxAtPos(&this->actor, NA_SE_SY_FOUND); - this->unk_272 = 0x1F; - this->unk_274 = 0; - this->unk_276 = 0; - this->unk_26C = 0; - this->unk_278 = 0; - this->unk_27A = 0; - this->unk_27C = 0; - this->unk_26E = 0; + this->dekuScrubFlags = (1 << 4) | (1 << 3) | (1 << 2) | (1 << 1) | (1 << 0); + this->guayFlags = 0; + this->wolfosFlags = 0; + this->perGameVar1.guaySpawnTimer = 0; + this->dekuScrubHitCounter = 0; + this->guayHitCounter = 0; + this->currentWave = 0; + this->perGameVar2.bonusDekuScrubHitCounter = 0; func_8010E9F0(1, 100); this->actor.draw = NULL; - this->actionFunc = func_809C81D0; + this->actionFunc = EnSyatekiMan_Swamp_RunGame; } } -void func_809C81D0(EnSyatekiMan* this, GlobalContext* globalCtx) { - static s16 D_809C949C = 0; - Player* player = GET_PLAYER(globalCtx); +void EnSyatekiMan_Swamp_RunGame(EnSyatekiMan* this, PlayState* play) { + static s16 sHasSpawnedGuaysForThisWave = false; + Player* player = GET_PLAYER(play); - if (((this->unk_272 == 0) || (this->unk_26C > 140)) && (D_809C949C == 0) && (this->unk_27C < 4)) { - D_809C949C = 1; - this->unk_26C = 0; + if (((this->dekuScrubFlags == 0) || (this->perGameVar1.guaySpawnTimer > 140)) && !sHasSpawnedGuaysForThisWave && + (this->currentWave < 4)) { + // Spawn three guays after the player has killed all Deku Scrubs, or after 140 frames. + sHasSpawnedGuaysForThisWave = true; + this->perGameVar1.guaySpawnTimer = 0; Actor_PlaySfxAtPos(&this->actor, NA_SE_SY_FOUND); - this->unk_274 = D_809C91C8[this->unk_27E]; - if (this->unk_27E == 3) { - this->unk_27E = 0; + this->guayFlags = sGuayFlagsPerWave[this->flagsIndex]; + if (this->flagsIndex == 3) { + this->flagsIndex = 0; } else { - this->unk_27E++; + this->flagsIndex++; } - } else if ((this->unk_274 == 0) && (this->unk_272 == 0) && (D_809C949C == 1) && (this->unk_27C < 4)) { - if (this->unk_27A < 3) { - this->unk_27A = 0; + } else if ((this->guayFlags == 0) && (this->dekuScrubFlags == 0) && (sHasSpawnedGuaysForThisWave == true) && + (this->currentWave < 4)) { + // Once all Deku Scrubs and Guays in this wave have either disappeared or died, move on to the next wave. + if (this->guayHitCounter < 3) { + this->guayHitCounter = 0; } - this->unk_26C = 0; - D_809C949C = 0; - this->unk_27C++; - if (this->unk_27C < 4) { - this->unk_272 = 31; + + this->perGameVar1.guaySpawnTimer = 0; + sHasSpawnedGuaysForThisWave = false; + this->currentWave++; + if (this->currentWave < 4) { + this->dekuScrubFlags = (1 << 4) | (1 << 3) | (1 << 2) | (1 << 1) | (1 << 0); } } - if (this->unk_27A == 3) { - this->unk_27A = 0; - this->unk_276 |= 1; + if (this->guayHitCounter == 3) { + this->guayHitCounter = 0; + this->wolfosFlags |= 1; } - if (this->unk_278 == 10) { - this->unk_278 = 0; - this->unk_276 |= 2; + if (this->dekuScrubHitCounter == 10) { + this->dekuScrubHitCounter = 0; + this->wolfosFlags |= 2; } - this->unk_26C++; + this->perGameVar1.guaySpawnTimer++; + if (gSaveContext.unk_3DE0[1] == 0) { gSaveContext.unk_3DE0[1] = 0; gSaveContext.unk_3DD0[1] = 5; this->actor.draw = EnSyatekiMan_Draw; - this->unk_27E = 0; - this->unk_27C = 0; + this->flagsIndex = 0; + this->currentWave = 0; player->stateFlags1 |= 0x20; - D_809C949C = 0; + sHasSpawnedGuaysForThisWave = false; func_801A2C20(); - this->actionFunc = func_809C8488; - } else if ((this->unk_27C == 4) && (this->unk_276 == 0) && (this->unk_26E == 2)) { + this->actionFunc = EnSyatekiMan_Swamp_EndGame; + } else if ((this->currentWave == 4) && (this->wolfosFlags == 0) && + (this->perGameVar2.bonusDekuScrubHitCounter == 2)) { this->actor.draw = EnSyatekiMan_Draw; - this->unk_27E = 0; - this->unk_27C = 0; + this->flagsIndex = 0; + this->currentWave = 0; player->stateFlags1 |= 0x20; - D_809C949C = 0; + sHasSpawnedGuaysForThisWave = false; func_801A2C20(); - this->unk_26A = 5; - if (this->unk_280 == 0x848) { - func_8011B4E0(globalCtx, 2); + this->shootingGameState = SG_GAME_STATE_GIVING_BONUS; + if (this->score == 2120) { + func_8011B4E0(play, 2); gSaveContext.unk_3DD0[1] = 6; - this->actionFunc = func_809C8610; + this->actionFunc = EnSyatekiMan_Swamp_AddBonusPoints; } else { gSaveContext.unk_3DD0[1] = 5; - this->actionFunc = func_809C8488; + this->actionFunc = EnSyatekiMan_Swamp_EndGame; } } } -void func_809C8488(EnSyatekiMan* this, GlobalContext* globalCtx) { - if ((this->unk_26A == 1) || (this->unk_26A == 5)) { - this->unk_190 = 0; - this->unk_272 = 0; - this->unk_274 = 0; - this->unk_276 = 0; - if (this->unk_270 <= 0) { - 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); +void EnSyatekiMan_Swamp_EndGame(EnSyatekiMan* this, PlayState* play) { + if ((this->shootingGameState == SG_GAME_STATE_RUNNING) || (this->shootingGameState == SG_GAME_STATE_GIVING_BONUS)) { + this->octorokFlags = 0; + this->dekuScrubFlags = 0; + this->guayFlags = 0; + this->wolfosFlags = 0; + if (this->talkWaitTimer <= 0) { + if (GET_SWAMP_SHOOTING_GALLERY_HIGH_SCORE() < this->score) { + SET_SWAMP_SHOOTING_GALLERY_HIGH_SCORE(this->score); } - this->unk_270 = 15; - if (this->unk_280 >= 0x848) { - Message_StartTextbox(globalCtx, 0xA34, &this->actor); - this->unk_284 = 0xA34; - this->unk_26A = 6; - } else if (this->unk_280 >= 0x7D0) { + + this->talkWaitTimer = 15; + if (this->score >= 2120) { + // Perfect! Take this! + Message_StartTextbox(play, 0xA34, &this->actor); + this->prevTextId = 0xA34; + this->shootingGameState = SG_GAME_STATE_ENDED; + } else if (this->score >= 2000) { if (gSaveContext.save.weekEventReg[63] & 2) { gSaveContext.save.weekEventReg[63] &= (u8)~1; gSaveContext.save.weekEventReg[63] &= (u8)~2; - this->unk_26A = 0; + this->shootingGameState = SG_GAME_STATE_NONE; gSaveContext.minigameState = 3; - this->actionFunc = func_809C6848; + this->actionFunc = EnSyatekiMan_Swamp_Idle; return; } - Message_StartTextbox(globalCtx, 0xA35, &this->actor); - this->unk_284 = 0xA35; - this->unk_26A = 4; - this->unk_280 = 0; + + // You almost had it! Well...just this once...here you go! + // Setting prevTextId to this is what triggers a free replay in EnSyatekiMan_Swamp_HandleNormalMessage. + Message_StartTextbox(play, 0xA35, &this->actor); + this->prevTextId = 0xA35; + this->shootingGameState = SG_GAME_STATE_ONE_MORE_GAME; + this->score = 0; } else { - Message_StartTextbox(globalCtx, 0xA32, &this->actor); - this->unk_284 = 0xA32; - this->unk_26A = 6; + // You have to try harder! + Message_StartTextbox(play, 0xA32, &this->actor); + this->prevTextId = 0xA32; + this->shootingGameState = SG_GAME_STATE_ENDED; } - this->actionFunc = func_809C6E30; + + this->actionFunc = EnSyatekiMan_Swamp_Talk; } else { - this->unk_270--; + this->talkWaitTimer--; } } - if (this->unk_270 < 5) { - globalCtx->unk_1887C = -10; + if (this->talkWaitTimer < 5) { + play->unk_1887C = -10; } } -void func_809C8610(EnSyatekiMan* this, GlobalContext* globalCtx) { - static s32 D_809C94A0 = 0; - Player* player = GET_PLAYER(globalCtx); +void EnSyatekiMan_Swamp_AddBonusPoints(EnSyatekiMan* this, PlayState* play) { + static s32 sBonusTimer = 0; + Player* player = GET_PLAYER(play); player->stateFlags1 |= 0x20; - if (globalCtx->interfaceCtx.unk_286 == 0) { + if (play->interfaceCtx.unk_286 == 0) { if (gSaveContext.unk_3DE0[1] == 0) { gSaveContext.unk_3DE0[1] = 0; gSaveContext.unk_3DD0[1] = 5; - this->unk_27E = 0; - this->unk_27C = 0; - this->actionFunc = func_809C8488; - D_809C94A0 = 0; - } else if (D_809C94A0 > 10) { + this->flagsIndex = 0; + this->currentWave = 0; + this->actionFunc = EnSyatekiMan_Swamp_EndGame; + sBonusTimer = 0; + } else if (sBonusTimer > 10) { gSaveContext.unk_3E88[1] += 100; - globalCtx->interfaceCtx.unk_25C += 10; - this->unk_280 += 10; + play->interfaceCtx.unk_25C += 10; + this->score += 10; Actor_PlaySfxAtPos(&this->actor, NA_SE_SY_TRE_BOX_APPEAR); - D_809C94A0 = 0; + sBonusTimer = 0; } else { - D_809C94A0++; + sBonusTimer++; } } } -void func_809C8710(EnSyatekiMan* this, GlobalContext* globalCtx) { - Vec3f sp24; +void EnSyatekiMan_Town_MovePlayerAndSayHighScore(EnSyatekiMan* this, PlayState* play) { + Vec3f targetPlayerPos; if (gSaveContext.save.playerForm == PLAYER_FORM_FIERCE_DEITY) { - sp24 = D_809C9480; + targetPlayerPos = sTownFierceDietyPlayerPos; } else { - sp24 = D_809C948C; + targetPlayerPos = sTownPlayerPos; } - if (func_809C6720(globalCtx, sp24)) { - if (this->unk_284 == 0x3FD) { - Message_StartTextbox(globalCtx, 0x3FE, &this->actor); - this->unk_284 = 0x3FE; + if (EnSyatekiMan_MovePlayerToPos(play, targetPlayerPos)) { + if (this->prevTextId == 0x3FD) { + // Our highest score is [score]. If you break the record, you'll win a prize! + Message_StartTextbox(play, 0x3FE, &this->actor); + this->prevTextId = 0x3FE; } else { - Message_StartTextbox(globalCtx, 0x400, &this->actor); - this->unk_284 = 0x400; + // Our highest score is [score]. Good luck! + Message_StartTextbox(play, 0x400, &this->actor); + this->prevTextId = 0x400; } - this->unk_26A = 2; - this->actionFunc = func_809C7990; + + this->shootingGameState = SG_GAME_STATE_EXPLAINING_RULES; + this->actionFunc = EnSyatekiMan_Town_Talk; } } -void func_809C8808(EnSyatekiMan* this, GlobalContext* globalCtx) { - static s16 D_809C94A4 = 30; - Player* player = GET_PLAYER(globalCtx); +void EnSyatekiMan_Town_StartGame(EnSyatekiMan* this, PlayState* play) { + static s16 sGameStartTimer = 30; + Player* player = GET_PLAYER(play); - if (D_809C94A4 == 30) { + if (sGameStartTimer == 30) { if (player->transformation == PLAYER_FORM_FIERCE_DEITY) { - player->actor.world.pos = D_809C9480; + player->actor.world.pos = sTownFierceDietyPlayerPos; } else { - player->actor.world.pos = D_809C948C; + player->actor.world.pos = sTownPlayerPos; } + player->actor.prevPos = player->actor.world.pos; player->actor.shape.rot.y = -0x8000; player->actor.world.rot.y = player->actor.shape.rot.y; - globalCtx->unk_18790(globalCtx, -0x8000, &this->actor); + play->unk_18790(play, -0x8000, &this->actor); player->stateFlags1 |= 0x20; - D_809C94A4--; - } else if (D_809C94A4 > 0) { + sGameStartTimer--; + } else if (sGameStartTimer > 0) { player->actor.shape.rot.y = -0x8000; player->actor.world.rot.y = player->actor.shape.rot.y; - D_809C94A4--; - } else if (D_809C94A4 == 0) { + sGameStartTimer--; + } else if (sGameStartTimer == 0) { player->stateFlags1 &= ~0x20; - this->unk_280 = 0; - this->unk_27E = 0; - this->unk_26C = 70; - this->unk_26E = 0; - D_809C94A4 = 30; + this->score = 0; + this->flagsIndex = 0; + this->perGameVar1.octorokState = SG_OCTO_STATE_INITIAL; + this->perGameVar2.octorokHitType = SG_OCTO_HIT_TYPE_NONE; + sGameStartTimer = 30; func_8010E9F0(1, 75); this->actor.draw = NULL; - this->actionFunc = func_809C898C; + this->actionFunc = EnSyatekiMan_Town_RunGame; } } -void func_809C898C(EnSyatekiMan* this, GlobalContext* globalCtx) { - static const s32 D_809C94D0[] = { - 0x00000111, 0x00000650, 0x00010025, 0x00011011, 0x00000984, 0x00004050, 0x00010211, 0x00022015, - 0x00026984, 0x00012852, 0x00011999, 0x00022895, 0x0000056A, 0x0002A451, 0x00004115, - }; - static s32 D_809C94A8 = 0; - Player* player = GET_PLAYER(globalCtx); - s32 sp30; - s32 pad; - u64 sp20; +/** + * In the Town Shooting Gallery, there are fifteen waves of Octoroks. + * For each wave, these flags are used to control which Octoroks appear. + */ +static const s32 sOctorokFlagsPerWave[] = { + OCTOROK_FLAG(COLOR_RED, ROW_CENTER, COLUMN_CENTER) | OCTOROK_FLAG(COLOR_RED, ROW_BACK, COLUMN_RIGHT) | + OCTOROK_FLAG(COLOR_RED, ROW_BACK, COLUMN_LEFT), - sp20 = gSaveContext.unk_3DE0[1]; - sp30 = (sp20 * 0.1f) + 1.0f; + OCTOROK_FLAG(COLOR_RED, ROW_CENTER, COLUMN_RIGHT) | OCTOROK_FLAG(COLOR_BLUE, ROW_CENTER, COLUMN_CENTER) | + OCTOROK_FLAG(COLOR_RED, ROW_CENTER, COLUMN_LEFT) | OCTOROK_FLAG(COLOR_RED, ROW_BACK, COLUMN_RIGHT), - if (sp30 < 0x2EF) { - s32 temp; + OCTOROK_FLAG(COLOR_RED, ROW_FRONT, COLUMN_RIGHT) | OCTOROK_FLAG(COLOR_BLUE, ROW_BACK, COLUMN_RIGHT) | + OCTOROK_FLAG(COLOR_RED, ROW_BACK, COLUMN_CENTER) | OCTOROK_FLAG(COLOR_RED, ROW_BACK, COLUMN_LEFT), - // clang-format off - if (D_809C94A8 == 0) { - sp20 = gSaveContext.unk_3DE0[1]; temp = sp20 % 0x1F4; + OCTOROK_FLAG(COLOR_RED, ROW_FRONT, COLUMN_RIGHT) | OCTOROK_FLAG(COLOR_RED, ROW_FRONT, COLUMN_LEFT) | + OCTOROK_FLAG(COLOR_RED, ROW_BACK, COLUMN_RIGHT) | OCTOROK_FLAG(COLOR_RED, ROW_BACK, COLUMN_LEFT), + + OCTOROK_FLAG(COLOR_BLUE, ROW_CENTER, COLUMN_RIGHT) | OCTOROK_FLAG(COLOR_RED, ROW_CENTER, COLUMN_CENTER) | + OCTOROK_FLAG(COLOR_BLUE, ROW_CENTER, COLUMN_LEFT) | OCTOROK_FLAG(COLOR_RED, ROW_BACK, COLUMN_CENTER), + + OCTOROK_FLAG(COLOR_RED, ROW_FRONT, COLUMN_CENTER) | OCTOROK_FLAG(COLOR_RED, ROW_CENTER, COLUMN_LEFT) | + OCTOROK_FLAG(COLOR_RED, ROW_BACK, COLUMN_RIGHT), + + OCTOROK_FLAG(COLOR_RED, ROW_FRONT, COLUMN_RIGHT) | OCTOROK_FLAG(COLOR_BLUE, ROW_CENTER, COLUMN_CENTER) | + OCTOROK_FLAG(COLOR_RED, ROW_BACK, COLUMN_RIGHT) | OCTOROK_FLAG(COLOR_RED, ROW_BACK, COLUMN_LEFT), + + OCTOROK_FLAG(COLOR_BLUE, ROW_FRONT, COLUMN_RIGHT) | OCTOROK_FLAG(COLOR_BLUE, ROW_FRONT, COLUMN_LEFT) | + OCTOROK_FLAG(COLOR_RED, ROW_BACK, COLUMN_RIGHT) | OCTOROK_FLAG(COLOR_RED, ROW_BACK, COLUMN_CENTER) | + OCTOROK_FLAG(COLOR_RED, ROW_BACK, COLUMN_LEFT), + + OCTOROK_FLAG(COLOR_BLUE, ROW_FRONT, COLUMN_RIGHT) | OCTOROK_FLAG(COLOR_RED, ROW_FRONT, COLUMN_CENTER) | + OCTOROK_FLAG(COLOR_BLUE, ROW_FRONT, COLUMN_LEFT) | OCTOROK_FLAG(COLOR_BLUE, ROW_CENTER, COLUMN_RIGHT) | + OCTOROK_FLAG(COLOR_RED, ROW_CENTER, COLUMN_CENTER) | OCTOROK_FLAG(COLOR_BLUE, ROW_CENTER, COLUMN_LEFT) | + OCTOROK_FLAG(COLOR_RED, ROW_BACK, COLUMN_CENTER), + + OCTOROK_FLAG(COLOR_RED, ROW_FRONT, COLUMN_RIGHT) | OCTOROK_FLAG(COLOR_BLUE, ROW_FRONT, COLUMN_LEFT) | + OCTOROK_FLAG(COLOR_BLUE, ROW_CENTER, COLUMN_RIGHT) | OCTOROK_FLAG(COLOR_RED, ROW_CENTER, COLUMN_LEFT) | + OCTOROK_FLAG(COLOR_RED, ROW_BACK, COLUMN_RIGHT) | OCTOROK_FLAG(COLOR_BLUE, ROW_BACK, COLUMN_LEFT), + + OCTOROK_FLAG(COLOR_RED, ROW_FRONT, COLUMN_RIGHT) | OCTOROK_FLAG(COLOR_RED, ROW_FRONT, COLUMN_LEFT) | + OCTOROK_FLAG(COLOR_BLUE, ROW_CENTER, COLUMN_RIGHT) | OCTOROK_FLAG(COLOR_RED, ROW_CENTER, COLUMN_CENTER) | + OCTOROK_FLAG(COLOR_BLUE, ROW_CENTER, COLUMN_LEFT) | OCTOROK_FLAG(COLOR_RED, ROW_BACK, COLUMN_RIGHT) | + OCTOROK_FLAG(COLOR_BLUE, ROW_BACK, COLUMN_CENTER) | OCTOROK_FLAG(COLOR_RED, ROW_BACK, COLUMN_LEFT), + + OCTOROK_FLAG(COLOR_BLUE, ROW_FRONT, COLUMN_RIGHT) | OCTOROK_FLAG(COLOR_BLUE, ROW_FRONT, COLUMN_LEFT) | + OCTOROK_FLAG(COLOR_BLUE, ROW_CENTER, COLUMN_RIGHT) | OCTOROK_FLAG(COLOR_BLUE, ROW_CENTER, COLUMN_LEFT) | + OCTOROK_FLAG(COLOR_RED, ROW_BACK, COLUMN_RIGHT) | OCTOROK_FLAG(COLOR_RED, ROW_BACK, COLUMN_CENTER) | + OCTOROK_FLAG(COLOR_RED, ROW_BACK, COLUMN_LEFT), + + OCTOROK_FLAG(COLOR_RED, ROW_CENTER, COLUMN_RIGHT) | OCTOROK_FLAG(COLOR_RED, ROW_CENTER, COLUMN_CENTER) | + OCTOROK_FLAG(COLOR_RED, ROW_CENTER, COLUMN_LEFT) | OCTOROK_FLAG(COLOR_BLUE, ROW_BACK, COLUMN_RIGHT) | + OCTOROK_FLAG(COLOR_BLUE, ROW_BACK, COLUMN_CENTER) | OCTOROK_FLAG(COLOR_BLUE, ROW_BACK, COLUMN_LEFT), + + OCTOROK_FLAG(COLOR_BLUE, ROW_FRONT, COLUMN_RIGHT) | OCTOROK_FLAG(COLOR_BLUE, ROW_FRONT, COLUMN_CENTER) | + OCTOROK_FLAG(COLOR_BLUE, ROW_FRONT, COLUMN_LEFT) | OCTOROK_FLAG(COLOR_RED, ROW_CENTER, COLUMN_RIGHT) | + OCTOROK_FLAG(COLOR_RED, ROW_CENTER, COLUMN_LEFT) | OCTOROK_FLAG(COLOR_RED, ROW_BACK, COLUMN_RIGHT) | + OCTOROK_FLAG(COLOR_RED, ROW_BACK, COLUMN_LEFT), + + OCTOROK_FLAG(COLOR_RED, ROW_FRONT, COLUMN_CENTER) | OCTOROK_FLAG(COLOR_RED, ROW_CENTER, COLUMN_CENTER) | + OCTOROK_FLAG(COLOR_RED, ROW_BACK, COLUMN_RIGHT) | OCTOROK_FLAG(COLOR_RED, ROW_BACK, COLUMN_CENTER) | + OCTOROK_FLAG(COLOR_RED, ROW_BACK, COLUMN_LEFT), +}; + +void EnSyatekiMan_Town_RunGame(EnSyatekiMan* this, PlayState* play) { + static s32 sModFromLosingTime = 0; + Player* player = GET_PLAYER(play); + s32 timer = (((void)0, gSaveContext.unk_3DE0[1]) * 0.1f) + 1.0f; // unit is tenths of a second + + if (timer <= 750) { + s32 waveTimer; // unit is hundredths of a second + + // If you hit a Blue Octorok, you lose 2.5 seconds. If we pretend that the code below was not present, + // then waveTimer would drop by 250, dramatically reducing how much time you have before the Octoroks + // begin hiding. This code will ultimately correct waveTimer such that its value is not affected by + // hitting Blue Octoroks. + if (sModFromLosingTime == 0) { + waveTimer = ((void)0, gSaveContext.unk_3DE0[1]) % 500; } else { - sp20 = gSaveContext.unk_3DE0[1]; temp = (sp20 + 250) % 0x1F4; - } - //clang-format on - - if (temp < 100) { - this->unk_26C = 0x50; + waveTimer = (((void)0, gSaveContext.unk_3DE0[1]) + 250) % 500; } - if (this->unk_26E != 0) { - if (this->unk_26E == 2) { + // Octoroks begin hiding four seconds after a wave begins. + if (waveTimer < 100) { + this->perGameVar1.octorokState = SG_OCTO_STATE_HIDING; + } + + if (this->perGameVar2.octorokHitType != SG_OCTO_HIT_TYPE_NONE) { + if (this->perGameVar2.octorokHitType == SG_OCTO_HIT_TYPE_BLUE) { gSaveContext.unk_3E18[1] -= 250; - D_809C94A8 = (D_809C94A8 + 25) % 50; + sModFromLosingTime = (sModFromLosingTime + 25) % 50; } - this->unk_26E = 0; + + this->perGameVar2.octorokHitType = SG_OCTO_HIT_TYPE_NONE; } - if (this->unk_26C == 0) { - this->unk_26C++; + if (this->perGameVar1.octorokState == SG_OCTO_STATE_SPAWNING) { + this->perGameVar1.octorokState++; } - if ((D_809C94A8 == (sp30 % 50)) && (this->unk_26C >= 70)) { - if (this->unk_27E < 15) { - this->unk_190 = D_809C94D0[this->unk_27E++]; + // A new wave of Octoroks should appear every five seconds. However, we need to take into account + // that the player might have lost time from hitting Blue Octoroks, so we do something similar to + // what was done with waveTimer above. + if ((sModFromLosingTime == (timer % 50)) && (this->perGameVar1.octorokState >= SG_OCTO_STATE_INITIAL)) { + if (this->flagsIndex < 15) { + this->octorokFlags = sOctorokFlagsPerWave[this->flagsIndex++]; Actor_PlaySfxAtPos(&this->actor, NA_SE_SY_FOUND); - this->unk_26C = 0; + this->perGameVar1.octorokState = SG_OCTO_STATE_SPAWNING; } } if (gSaveContext.unk_3DE0[1] == 0) { - this->unk_27E = 0; - this->unk_26C = 80; + this->flagsIndex = 0; + this->perGameVar1.octorokState = SG_OCTO_STATE_HIDING; gSaveContext.unk_3DE0[1] = 0; gSaveContext.unk_3DD0[1] = 5; player->stateFlags1 |= 0x20; - D_809C94A8 = 0; + sModFromLosingTime = 0; this->actor.draw = EnSyatekiMan_Draw; func_801A2C20(); - this->actionFunc = func_809C8BF0; - if (this->unk_280 == 50) { + this->actionFunc = EnSyatekiMan_Town_EndGame; + if (this->score == 50) { func_801A3098(NA_BGM_GET_ITEM | 0x900); - func_8011B4E0(globalCtx, 1); + func_8011B4E0(play, 1); } } } } -void func_809C8BF0(EnSyatekiMan* this, GlobalContext* globalCtx) { - if (this->unk_26A == 1) { - this->unk_190 = 0; - if ((this->unk_270 <= 0) && (globalCtx->interfaceCtx.unk_286 == 0)) { - Flags_SetAllTreasure(globalCtx, this->unk_280); - this->unk_270 = 15; - if (((s32)(gSaveContext.save.unk_EF4 & 0xFFFF) < this->unk_280) || (this->unk_280 == 50)) { - if ((s32)(gSaveContext.save.unk_EF4 & 0xFFFF) < this->unk_280) { +void EnSyatekiMan_Town_EndGame(EnSyatekiMan* this, PlayState* play) { + if (this->shootingGameState == SG_GAME_STATE_RUNNING) { + this->octorokFlags = 0; + if ((this->talkWaitTimer <= 0) && (play->interfaceCtx.unk_286 == 0)) { + Flags_SetAllTreasure(play, this->score); + this->talkWaitTimer = 15; + if ((GET_TOWN_SHOOTING_GALLERY_HIGH_SCORE() < this->score) || (this->score == 50)) { + if (GET_TOWN_SHOOTING_GALLERY_HIGH_SCORE() < this->score) { if (!(gSaveContext.save.weekEventReg[59] & 0x20)) { - Message_StartTextbox(globalCtx, 0x407, &this->actor); - this->unk_284 = 0x407; - } else if (this->unk_280 == 50) { - Message_StartTextbox(globalCtx, 0x405, &this->actor); - this->unk_284 = 0x405; + // You got a new record! + Message_StartTextbox(play, 0x407, &this->actor); + this->prevTextId = 0x407; + } else if (this->score == 50) { + // No way! That was perfect! + Message_StartTextbox(play, 0x405, &this->actor); + this->prevTextId = 0x405; } else { - Message_StartTextbox(globalCtx, 0x407, &this->actor); - this->unk_284 = 0x407; + // You got a new record! + Message_StartTextbox(play, 0x407, &this->actor); + this->prevTextId = 0x407; } - } else if (this->unk_280 == 50) { - Message_StartTextbox(globalCtx, 0x406, &this->actor); - this->unk_284 = 0x406; + } else if (this->score == 50) { + // That was perfect! + Message_StartTextbox(play, 0x406, &this->actor); + this->prevTextId = 0x406; } - gSaveContext.save.unk_EF4 = (gSaveContext.save.unk_EF4 & 0xFFFF0000) | (this->unk_280 & 0xFFFF); - this->unk_26A = 6; + + SET_TOWN_SHOOTING_GALLERY_HIGH_SCORE(this->score); + this->shootingGameState = SG_GAME_STATE_ENDED; } else { if (CURRENT_DAY != 3) { - Message_StartTextbox(globalCtx, 0x401, &this->actor); - this->unk_284 = 0x401; + // You got [score]? Oh, that's too bad... + Message_StartTextbox(play, 0x401, &this->actor); + this->prevTextId = 0x401; } else { - Message_StartTextbox(globalCtx, 0x403, &this->actor); - this->unk_284 = 0x403; + // You got [score]? Too bad... + Message_StartTextbox(play, 0x403, &this->actor); + this->prevTextId = 0x403; } - this->unk_26A = 4; + + this->shootingGameState = SG_GAME_STATE_ONE_MORE_GAME; } - this->actionFunc = func_809C7990; + + this->actionFunc = EnSyatekiMan_Town_Talk; } else { - this->unk_270--; + this->talkWaitTimer--; } } - if (this->unk_270 < 5) { - globalCtx->unk_1887C = -10; + if (this->talkWaitTimer < 5) { + play->unk_1887C = -10; } } -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) { +void EnSyatekiMan_Update(Actor* thisx, PlayState* play) { EnSyatekiMan* this = THIS; - this->actionFunc(this, globalCtx); - func_809C8DE8(this); + this->actionFunc(this, play); + EnSyatekiMan_Blink(this); this->actor.focus.pos.y = 70.0f; Actor_SetFocus(&this->actor, 70.0f); - if (this->unk_26A != 1) { + if (this->shootingGameState != SG_GAME_STATE_RUNNING) { SkelAnime_Update(&this->skelAnime); - func_800E9250(globalCtx, &this->actor, &this->unk_258, &this->unk_25E, this->actor.focus.pos); + Actor_TrackPlayer(play, &this->actor, &this->headRot, &this->torsoRot, this->actor.focus.pos); } } -s32 EnSyatekiMan_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, - Actor* thisx) { +s32 EnSyatekiMan_OverrideLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, Actor* thisx) { EnSyatekiMan* this = THIS; - if ((globalCtx->sceneNum == SCENE_SYATEKI_MIZU) && (limbIndex == 15)) { - *dList = object_shn_DL_00F2D0; + if ((play->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->headRot.x, MTXMODE_APPLY); + Matrix_RotateXS(this->headRot.y, MTXMODE_APPLY); + Matrix_Translate(-3000.0f, 0.0f, 0.0f, MTXMODE_APPLY); + } else if (limbIndex == BURLY_GUY_LIMB_TORSO) { + Matrix_RotateXS(-this->torsoRot.y, MTXMODE_APPLY); } return false; } -void EnSyatekiMan_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx) { +void EnSyatekiMan_PostLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx) { EnSyatekiMan* this = THIS; - Vec3f sp18 = { 1600.0f, 0.0f, 0.0f }; + Vec3f sFocusOffset = { 1600.0f, 0.0f, 0.0f }; - if (limbIndex == 15) { - Matrix_MultiplyVector3fByState(&sp18, &this->actor.focus.pos); + if (limbIndex == BURLY_GUY_LIMB_HEAD) { + Matrix_MultVec3f(&sFocusOffset, &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, +void EnSyatekiMan_Draw(Actor* thisx, PlayState* play) { + 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; + if (play->sceneNum == SCENE_SYATEKI_MIZU) { + 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); + OPEN_DISPS(play->state.gfxCtx); - func_8012C5B0(globalCtx->state.gfxCtx); + func_8012C5B0(play->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); + SkelAnime_DrawFlexOpa(play, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, + EnSyatekiMan_OverrideLimbDraw, EnSyatekiMan_PostLimbDraw, &this->actor); - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->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..30bc1b1ad 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,49 +2,72 @@ #define Z_EN_SYATEKI_MAN_H #include "global.h" +#include "objects/object_shn/object_shn.h" struct EnSyatekiMan; -typedef void (*EnSyatekiManActionFunc)(struct EnSyatekiMan*, GlobalContext*); +typedef void (*EnSyatekiManActionFunc)(struct EnSyatekiMan*, PlayState*); -#define ENSYATEKIMAN_GET_FF00(thisx) (((thisx)->params & 0xFF00) >> 8) +#define EN_SYATEKI_MAN_GET_PATH(thisx) (((thisx)->params & 0xFF00) >> 8) -typedef struct { - /* 0x00 */ s16 index; - /* 0x04 */ f32 x; - /* 0x08 */ f32 y; - /* 0x0C */ f32 z; - /* 0x10 */ s32 variable; -} EnSyatekiManUnkStruct; +typedef enum { + /* 0 */ SG_GAME_STATE_NONE, // None of the states below apply. + /* 1 */ SG_GAME_STATE_RUNNING, // The shooting game is in-progress. + /* 2 */ SG_GAME_STATE_EXPLAINING_RULES, // For the Town Shooting Gallery, this state is also used for explaining the current high score. + /* 3 */ SG_GAME_STATE_NOT_PLAYING, // Either the player said "No" to playing, or they said "Yes" but don't have enough rupees. + /* 4 */ SG_GAME_STATE_ONE_MORE_GAME, // The player failed to get a new high score (Town) and/or perfect score (Swamp and Town). + /* 5 */ SG_GAME_STATE_GIVING_BONUS, // The player gets bonus points at the end of the Swamp game if they get a perfect score. + /* 6 */ SG_GAME_STATE_ENDED, // The player got a new high score and/or perfect score (Town), or the game is over (Swamp). + /* 7 */ SG_GAME_STATE_MOVING_PLAYER, // The player is automatically moving towards the spot to play the game. +} ShootingGalleryGameState; + +typedef enum { + /* 0 */ SG_OCTO_STATE_SPAWNING, + /* 1 */ SG_OCTO_STATE_SPAWNED, + /* 70 */ SG_OCTO_STATE_INITIAL = 70, + /* 80 */ SG_OCTO_STATE_HIDING = 80, +} ShootingGalleryOctorokState; + +typedef enum { + /* 0 */ SG_OCTO_HIT_TYPE_NONE, + /* 1 */ SG_OCTO_HIT_TYPE_RED, + /* 2 */ SG_OCTO_HIT_TYPE_BLUE, +} ShootingGalleryoctorokHitType; typedef struct EnSyatekiMan { - /* 0x0000 */ Actor actor; - /* 0x0144 */ SkelAnime skelAnime; - /* 0x0188 */ EnSyatekiManActionFunc actionFunc; - /* 0x018C */ Path* path; - /* 0x0190 */ s32 unk_190; - /* 0x0194 */ s32 unk_194; - /* 0x0198 */ Vec3s jointTable[16]; - /* 0x01F8 */ Vec3s morphTable[16]; - /* 0x0258 */ Vec3s unk_258; - /* 0x025E */ Vec3s unk_25E; - /* 0x0264 */ s16 unk_264; - /* 0x0266 */ s16 unk_266; - /* 0x0268 */ UNK_TYPE1 unk268[0x2]; - /* 0x026A */ s16 unk_26A; - /* 0x026C */ s16 unk_26C; - /* 0x026E */ s16 unk_26E; - /* 0x0270 */ s16 unk_270; - /* 0x0272 */ s16 unk_272; - /* 0x0274 */ s16 unk_274; - /* 0x0276 */ s16 unk_276; - /* 0x0278 */ s16 unk_278; - /* 0x027A */ s16 unk_27A; - /* 0x027C */ s16 unk_27C; - /* 0x027E */ s16 unk_27E; - /* 0x0280 */ s16 unk_280; - /* 0x0282 */ s16 unk_282; - /* 0x0284 */ s16 unk_284; + /* 0x000 */ Actor actor; + /* 0x144 */ SkelAnime skelAnime; + /* 0x188 */ EnSyatekiManActionFunc actionFunc; + /* 0x18C */ Path* path; + /* 0x190 */ s32 octorokFlags; + /* 0x194 */ s32 swampTargetActorListIndex; // used but never initialized, so the value is implicitly always 0 + /* 0x198 */ Vec3s jointTable[BURLY_GUY_LIMB_MAX]; + /* 0x1F8 */ Vec3s morphTable[BURLY_GUY_LIMB_MAX]; + /* 0x258 */ Vec3s headRot; + /* 0x25E */ Vec3s torsoRot; + /* 0x264 */ s16 eyeIndex; + /* 0x266 */ s16 blinkTimer; + /* 0x268 */ UNK_TYPE1 unk268[0x2]; + /* 0x26A */ s16 shootingGameState; + /* 0x26C */ union { + s16 guaySpawnTimer; + s16 octorokState; + } perGameVar1; + /* 0x26E */ union { + s16 bonusDekuScrubHitCounter; + s16 octorokHitType; + } perGameVar2; + /* 0x270 */ s16 talkWaitTimer; + /* 0x272 */ s16 dekuScrubFlags; + /* 0x274 */ s16 guayFlags; + /* 0x276 */ s16 wolfosFlags; + /* 0x278 */ s16 dekuScrubHitCounter; + /* 0x27A */ s16 guayHitCounter; + /* 0x27C */ s16 currentWave; + /* 0x27E */ s16 flagsIndex; // Used for Octoroks in Town and Guays in Swamp + /* 0x280 */ s16 score; + /* 0x282 */ s16 talkFlags; + /* 0x284 */ s16 prevTextId; } EnSyatekiMan; // size = 0x288 extern const ActorInit En_Syateki_Man_InitVars; 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 94f2f3495..9077b38c4 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 @@ -11,21 +11,21 @@ #define THIS ((EnSyatekiOkuta*)thisx) -void EnSyatekiOkuta_Init(Actor* thisx, GlobalContext* globalCtx); -void EnSyatekiOkuta_Destroy(Actor* thisx, GlobalContext* globalCtx); -void EnSyatekiOkuta_Update(Actor* thisx, GlobalContext* globalCtx); -void EnSyatekiOkuta_Draw(Actor* thisx, GlobalContext* globalCtx); +void EnSyatekiOkuta_Init(Actor* thisx, PlayState* play); +void EnSyatekiOkuta_Destroy(Actor* thisx, PlayState* play); +void EnSyatekiOkuta_Update(Actor* thisx, PlayState* play); +void EnSyatekiOkuta_Draw(Actor* thisx, PlayState* play); void func_80A36260(EnSyatekiOkuta* this); -void func_80A362A8(EnSyatekiOkuta* this, GlobalContext* globalCtx); +void func_80A362A8(EnSyatekiOkuta* this, PlayState* play); void func_80A362F8(EnSyatekiOkuta* this); -void func_80A36350(EnSyatekiOkuta* this, GlobalContext* globalCtx); -void func_80A363B4(EnSyatekiOkuta* this, GlobalContext* globalCtx); +void func_80A36350(EnSyatekiOkuta* this, PlayState* play); +void func_80A363B4(EnSyatekiOkuta* this, PlayState* play); void func_80A36444(EnSyatekiOkuta* this); -void func_80A36488(EnSyatekiOkuta* this, GlobalContext* globalCtx); +void func_80A36488(EnSyatekiOkuta* this, PlayState* play); void func_80A364C0(EnSyatekiOkuta* this); -void func_80A36504(EnSyatekiOkuta* this, GlobalContext* globalCtx); -void func_80A365EC(EnSyatekiOkuta* this, GlobalContext* globalCtx); +void func_80A36504(EnSyatekiOkuta* this, PlayState* play); +void func_80A365EC(EnSyatekiOkuta* this, PlayState* play); void func_80A36CB0(EnSyatekiOkuta* this); const ActorInit En_Syateki_Okuta_InitVars = { @@ -60,13 +60,13 @@ static ColliderCylinderInit sCylinderInit = { { 20, 40, -30, { 0, 0, 0 } }, }; -static AnimationInfo sAnimations[] = { - { &object_okuta_Anim_00044C, 1.0f, 0.0f, 0.0f, ANIMMODE_ONCE, -1.0f }, - { &object_okuta_Anim_003958, 1.0f, 0.0f, 0.0f, ANIMMODE_ONCE, -1.0f }, - { &object_okuta_Anim_003B24, 1.0f, 0.0f, 0.0f, ANIMMODE_ONCE, -1.0f }, - { &object_okuta_Anim_003EE4, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, -1.0f }, - { &object_okuta_Anim_00466C, 1.0f, 0.0f, 0.0f, ANIMMODE_ONCE, -1.0f }, - { &object_okuta_Anim_004204, 1.0f, 0.0f, 0.0f, ANIMMODE_ONCE, -1.0f }, +static AnimationInfo sAnimationInfo[] = { + { &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" @@ -86,7 +86,7 @@ Color_RGBA8 D_80A37BA4 = { 255, 255, 255, 255 }; Color_RGBA8 D_80A37BA8 = { 150, 150, 150, 0 }; -void EnSyatekiOkuta_Init(Actor* thisx, GlobalContext* globalCtx) { +void EnSyatekiOkuta_Init(Actor* thisx, PlayState* play) { s32 pad; EnSyatekiOkuta* this = THIS; WaterBox* waterbox; @@ -94,16 +94,16 @@ void EnSyatekiOkuta_Init(Actor* thisx, GlobalContext* globalCtx) { s32 bgId; Actor_ProcessInitChain(&this->actor, sInitChain); - SkelAnime_Init(globalCtx, &this->skelAnime, &object_okuta_Skel_0033D0, &object_okuta_Anim_00466C, this->jointTable, - this->morphTable, OBJECT_OKUTA_LIMB_MAX); - Collider_InitCylinder(globalCtx, &this->collider); - Collider_SetCylinder(globalCtx, &this->collider, &this->actor, &sCylinderInit); + SkelAnime_Init(play, &this->skelAnime, &gOctorokSkel, &gOctorokAppearAnim, this->jointTable, this->morphTable, + OCTOROK_LIMB_MAX); + Collider_InitCylinder(play, &this->collider); + Collider_SetCylinder(play, &this->collider, &this->actor, &sCylinderInit); - this->actor.floorHeight = BgCheck_EntityRaycastFloor5(&globalCtx->colCtx, &this->actor.floorPoly, &bgId, - &this->actor, &this->actor.world.pos); + this->actor.floorHeight = + BgCheck_EntityRaycastFloor5(&play->colCtx, &this->actor.floorPoly, &bgId, &this->actor, &this->actor.world.pos); - if (!(WaterBox_GetSurface1_2(globalCtx, &globalCtx->colCtx, this->actor.world.pos.x, this->actor.world.pos.z, - &ySurface, &waterbox)) || + if (!(WaterBox_GetSurface1_2(play, &play->colCtx, this->actor.world.pos.x, this->actor.world.pos.z, &ySurface, + &waterbox)) || (ySurface <= this->actor.floorHeight)) { Actor_MarkForDeath(&this->actor); } else { @@ -115,18 +115,18 @@ void EnSyatekiOkuta_Init(Actor* thisx, GlobalContext* globalCtx) { func_80A36260(this); } -void EnSyatekiOkuta_Destroy(Actor* thisx, GlobalContext* globalCtx) { +void EnSyatekiOkuta_Destroy(Actor* thisx, PlayState* play) { EnSyatekiOkuta* this = THIS; - Collider_DestroyCylinder(globalCtx, &this->collider); + Collider_DestroyCylinder(play, &this->collider); } -void func_80A36148(Vec3f* pos, Vec3f* velocity, s16 scaleStep, GlobalContext* globalCtx) { - func_800B0DE0(globalCtx, pos, velocity, &gZeroVec3f, &D_80A37B90, &D_80A37B94, 400, scaleStep); +void func_80A36148(Vec3f* pos, Vec3f* velocity, s16 scaleStep, PlayState* play) { + func_800B0DE0(play, pos, velocity, &gZeroVec3f, &D_80A37B90, &D_80A37B94, 400, scaleStep); } -void func_80A361B0(EnSyatekiOkuta* this, GlobalContext* globalCtx) { - EffectSsGSplash_Spawn(globalCtx, &this->actor.home.pos, NULL, NULL, 0, 800); +void func_80A361B0(EnSyatekiOkuta* this, PlayState* play) { + EffectSsGSplash_Spawn(play, &this->actor.home.pos, NULL, NULL, 0, 800); } s32 func_80A361F4(EnSyatekiOkuta* this) { @@ -137,7 +137,7 @@ s32 func_80A361F4(EnSyatekiOkuta* this) { temp_v1 = EN_SYATEKI_OKUTA_GET_F(&this->actor); if ((temp_v1 == 1) || (temp_v1 == 4)) { - temp_a0 = syatekiMan->unk_190; + temp_a0 = syatekiMan->octorokFlags; temp_a1 = (temp_v1 * 2) + 6; if ((temp_a0 >> temp_a1) & 3) { @@ -153,13 +153,13 @@ s32 func_80A361F4(EnSyatekiOkuta* this) { } void func_80A36260(EnSyatekiOkuta* this) { - Animation_PlayOnceSetSpeed(&this->skelAnime, &object_okuta_Anim_00466C, 0.0f); + Animation_PlayOnceSetSpeed(&this->skelAnime, &gOctorokAppearAnim, 0.0f); this->actor.draw = NULL; this->actionFunc = func_80A362A8; } -void func_80A362A8(EnSyatekiOkuta* this, GlobalContext* globalCtx) { - Actor* actorIt = globalCtx->actorCtx.actorLists[ACTORCAT_NPC].first; +void func_80A362A8(EnSyatekiOkuta* this, PlayState* play) { + Actor* actorIt = play->actorCtx.actorLists[ACTORCAT_NPC].first; while (actorIt != NULL) { if (actorIt->id == ACTOR_EN_SYATEKI_MAN) { @@ -173,28 +173,28 @@ void func_80A362A8(EnSyatekiOkuta* this, GlobalContext* globalCtx) { } void func_80A362F8(EnSyatekiOkuta* this) { - Animation_PlayOnceSetSpeed(&this->skelAnime, &object_okuta_Anim_00466C, 0.0f); + Animation_PlayOnceSetSpeed(&this->skelAnime, &gOctorokAppearAnim, 0.0f); this->actor.draw = NULL; Actor_SetScale(&this->actor, 0.01f); this->actionFunc = func_80A36350; } -void func_80A36350(EnSyatekiOkuta* this, GlobalContext* globalCtx) { +void func_80A36350(EnSyatekiOkuta* this, PlayState* play) { } void func_80A36360(EnSyatekiOkuta* this) { this->actor.draw = EnSyatekiOkuta_Draw; this->unk_2AA = 0; - Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 4); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, 4); this->actionFunc = func_80A363B4; } -void func_80A363B4(EnSyatekiOkuta* this, GlobalContext* globalCtx) { +void func_80A363B4(EnSyatekiOkuta* this, PlayState* play) { if ((Animation_OnFrame(&this->skelAnime, 2.0f)) || (Animation_OnFrame(&this->skelAnime, 15.0f))) { if (func_80A361F4(this)) { return; } else { - func_80A361B0(this, globalCtx); + func_80A361B0(this, play); Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_OCTAROCK_JUMP); } } @@ -205,26 +205,26 @@ void func_80A363B4(EnSyatekiOkuta* this, GlobalContext* globalCtx) { } void func_80A36444(EnSyatekiOkuta* this) { - Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 3); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, 3); this->actionFunc = func_80A36488; } -void func_80A36488(EnSyatekiOkuta* this, GlobalContext* globalCtx) { +void func_80A36488(EnSyatekiOkuta* this, PlayState* play) { EnSyatekiMan* syatekiMan = (EnSyatekiMan*)this->actor.parent; - if (syatekiMan->unk_26C >= 0x46) { + if (syatekiMan->perGameVar1.octorokState >= SG_OCTO_STATE_INITIAL) { func_80A364C0(this); } } void func_80A364C0(EnSyatekiOkuta* this) { - Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 2); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, 2); this->actionFunc = func_80A36504; } -void func_80A36504(EnSyatekiOkuta* this, GlobalContext* globalCtx) { +void func_80A36504(EnSyatekiOkuta* this, PlayState* play) { if (Animation_OnFrame(&this->skelAnime, 4.0f)) { - func_80A361B0(this, globalCtx); + func_80A361B0(this, play); Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_DAIOCTA_LAND); } else if (Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) { func_80A362F8(this); @@ -238,11 +238,11 @@ void func_80A3657C(EnSyatekiOkuta* this) { Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_OCTAROCK_DEAD1); } - Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 1); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, 1); this->actionFunc = func_80A365EC; } -void func_80A365EC(EnSyatekiOkuta* this, GlobalContext* globalCtx) { +void func_80A365EC(EnSyatekiOkuta* this, PlayState* play) { Vec3f sp84; Vec3f sp78; s32 pad; @@ -260,7 +260,7 @@ void func_80A365EC(EnSyatekiOkuta* this, GlobalContext* globalCtx) { sp84.x = 0.0f; sp84.y = -0.5f; sp84.z = 0.0f; - func_80A36148(&sp78, &sp84, -20, globalCtx); + func_80A36148(&sp78, &sp84, -20, play); Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_OCTAROCK_DEAD2); } @@ -268,7 +268,7 @@ void func_80A365EC(EnSyatekiOkuta* this, GlobalContext* globalCtx) { } if (Animation_OnFrame(&this->skelAnime, 15.0f)) { - func_80A361B0(this, globalCtx); + func_80A361B0(this, play); } if (this->unk_2A4 < 3) { @@ -279,12 +279,12 @@ void func_80A365EC(EnSyatekiOkuta* this, GlobalContext* globalCtx) { 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); + SoundSource_PlaySfxAtFixedWorldPos(play, &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, + EffectSsDtBubble_SpawnCustomColor(play, &this->actor.world.pos, &sp84, &D_80A37B98, &D_80A37BA4, &D_80A37BA8, Rand_S16Offset(100, 50), 25, 0); } @@ -296,7 +296,7 @@ void func_80A365EC(EnSyatekiOkuta* this, GlobalContext* globalCtx) { } } -void func_80A368E0(EnSyatekiOkuta* this, GlobalContext* globalCtx) { +void func_80A368E0(EnSyatekiOkuta* this, PlayState* play) { 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; @@ -320,10 +320,10 @@ void func_80A368E0(EnSyatekiOkuta* this, GlobalContext* globalCtx) { // 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); + CollisionCheck_SetAC(play, &play->colChkCtx, &this->collider.base); } -s32 func_80A36A90(EnSyatekiOkuta* this, GlobalContext* globalCtx) { +s32 func_80A36A90(EnSyatekiOkuta* this, PlayState* play) { if ((this->actionFunc == func_80A365EC) || (this->actionFunc == func_80A36350)) { return false; } @@ -333,17 +333,18 @@ s32 func_80A36A90(EnSyatekiOkuta* this, GlobalContext* globalCtx) { return true; } - func_80A368E0(this, globalCtx); + func_80A368E0(this, play); return false; } -void func_80A36AF8(EnSyatekiOkuta* this, GlobalContext* globalCtx) { +void func_80A36AF8(EnSyatekiOkuta* this, PlayState* play) { 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 ((this->actionFunc != func_80A36488) && (this->actionFunc != func_80A363B4) && + (syatekiMan->shootingGameState == SG_GAME_STATE_RUNNING) && + (syatekiMan->perGameVar1.octorokState == SG_OCTO_STATE_SPAWNING)) { + temp_v1_2 = (syatekiMan->octorokFlags >> (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; @@ -352,29 +353,29 @@ void func_80A36AF8(EnSyatekiOkuta* this, GlobalContext* globalCtx) { } } -void EnSyatekiOkuta_Update(Actor* thisx, GlobalContext* globalCtx) { +void EnSyatekiOkuta_Update(Actor* thisx, PlayState* play) { s32 pad; EnSyatekiOkuta* this = THIS; EnSyatekiMan* syatekiMan; - this->actionFunc(this, globalCtx); + this->actionFunc(this, play); if (this->actionFunc != func_80A36350) { SkelAnime_Update(&this->skelAnime); } - func_80A36AF8(this, globalCtx); + func_80A36AF8(this, play); - if (func_80A36A90(this, globalCtx)) { + if (func_80A36A90(this, play)) { syatekiMan = (EnSyatekiMan*)this->actor.parent; if (this->unk_2A6 == 1) { Actor_PlaySfxAtPos(&this->actor, NA_SE_SY_TRE_BOX_APPEAR); - globalCtx->interfaceCtx.unk_25C++; - syatekiMan->unk_280++; - syatekiMan->unk_26E = 1; + play->interfaceCtx.unk_25C++; + syatekiMan->score++; + syatekiMan->perGameVar2.octorokHitType = SG_OCTO_HIT_TYPE_RED; } else { Actor_PlaySfxAtPos(&this->actor, NA_SE_SY_ERROR); - syatekiMan->unk_26E = 2; + syatekiMan->perGameVar2.octorokHitType = SG_OCTO_HIT_TYPE_BLUE; } func_80A3657C(this); @@ -462,8 +463,7 @@ s32 func_80A370EC(EnSyatekiOkuta* this, f32 arg1, Vec3f* arg2) { return true; } -s32 EnSyatekiOkuta_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, - Actor* thisx) { +s32 EnSyatekiOkuta_OverrideLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, Actor* thisx) { s32 pad; Vec3f sp20; f32 curFrame; @@ -474,34 +474,34 @@ s32 EnSyatekiOkuta_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx curFrame += this->unk_2A4; } - if (limbIndex == OBJECT_OKUTA_LIMB_0E) { + if (limbIndex == OCTOROK_LIMB_HEAD) { sp20 = this->unk_1D8; Matrix_Scale(sp20.x, sp20.y, sp20.z, MTXMODE_APPLY); - } else if ((limbIndex == OBJECT_OKUTA_LIMB_0F) && (func_80A370EC(this, curFrame, &sp20))) { + } 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) { +void EnSyatekiOkuta_Draw(Actor* thisx, PlayState* play) { EnSyatekiOkuta* this = THIS; - OPEN_DISPS(globalCtx->state.gfxCtx); + OPEN_DISPS(play->state.gfxCtx); - func_8012C28C(globalCtx->state.gfxCtx); + func_8012C28C(play->state.gfxCtx); if (this->unk_2A6 == 1) { gSPSegment(POLY_OPA_DISP++, 0x08, D_801AEFA0); } else { - gSPSegment(POLY_OPA_DISP++, 0x08, ovl_En_Syateki_Okuta_DL_001640); + 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); + SkelAnime_DrawOpa(play, this->skelAnime.skeleton, this->skelAnime.jointTable, EnSyatekiOkuta_OverrideLimbDraw, NULL, + &this->actor); + func_8012C2DC(play->state.gfxCtx); if (this->actionFunc == func_80A365EC) { - Matrix_InsertTranslation(this->actor.world.pos.x, this->actor.world.pos.y + 30.0f, - this->actor.world.pos.z + 20.0f, 0); + 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); @@ -509,14 +509,14 @@ void EnSyatekiOkuta_Draw(Actor* thisx, GlobalContext* globalCtx) { 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); + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); if (this->unk_2A6 == 2) { - gSPDisplayList(POLY_XLU_DISP++, ovl_En_Syateki_Okuta_DL_001A98); + gSPDisplayList(POLY_XLU_DISP++, gShootingGalleryOctorokCrossDL); } else { - gSPDisplayList(POLY_XLU_DISP++, ovl_En_Syateki_Okuta_DL_001B18); + gSPDisplayList(POLY_XLU_DISP++, gShootingGalleryOctorokCircleDL); } } - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->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 e083f26e1..a455765cd 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 @@ -8,7 +8,7 @@ struct EnSyatekiOkuta; -typedef void (*EnSyatekiOkutaActionFunc)(struct EnSyatekiOkuta*, GlobalContext*); +typedef void (*EnSyatekiOkutaActionFunc)(struct EnSyatekiOkuta*, PlayState*); typedef struct EnSyatekiOkuta { /* 0x000 */ Actor actor; @@ -16,8 +16,8 @@ typedef struct EnSyatekiOkuta { /* 0x188 */ EnSyatekiOkutaActionFunc actionFunc; /* 0x18C */ ColliderCylinder collider; /* 0x1DC */ Vec3f unk_1D8; - /* 0x1E4 */ Vec3s jointTable[OBJECT_OKUTA_LIMB_MAX]; - /* 0x244 */ Vec3s morphTable[OBJECT_OKUTA_LIMB_MAX]; + /* 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]; 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 ff6595044..d15859a74 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 @@ -6,30 +6,29 @@ #include "z_en_syateki_wf.h" #include "overlays/actors/ovl_En_Syateki_Man/z_en_syateki_man.h" -#include "objects/object_wf/object_wf.h" #define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_20 | ACTOR_FLAG_8000000) #define THIS ((EnSyatekiWf*)thisx) -void EnSyatekiWf_Init(Actor* thisx, GlobalContext* globalCtx); -void EnSyatekiWf_Destroy(Actor* thisx, GlobalContext* globalCtx); -void EnSyatekiWf_Update(Actor* thisx, GlobalContext* globalCtx); -void EnSyatekiWf_Draw(Actor* thisx, GlobalContext* globalCtx); +void EnSyatekiWf_Init(Actor* thisx, PlayState* play); +void EnSyatekiWf_Destroy(Actor* thisx, PlayState* play); +void EnSyatekiWf_Update(Actor* thisx, PlayState* play); +void EnSyatekiWf_Draw(Actor* thisx, PlayState* play); void func_80A201CC(EnSyatekiWf* this); -void func_80A20284(EnSyatekiWf* this, GlobalContext* globalCtx); +void func_80A20284(EnSyatekiWf* this, PlayState* play); void func_80A2030C(EnSyatekiWf* this); -void func_80A20320(EnSyatekiWf* this, GlobalContext* globalCtx); +void func_80A20320(EnSyatekiWf* this, PlayState* play); void func_80A20378(EnSyatekiWf* this); -void func_80A203DC(EnSyatekiWf* this, GlobalContext* globalCtx); +void func_80A203DC(EnSyatekiWf* this, PlayState* play); void func_80A20670(EnSyatekiWf* this); -void func_80A206DC(EnSyatekiWf* this, GlobalContext* globalCtx); +void func_80A206DC(EnSyatekiWf* this, PlayState* play); void func_80A20710(EnSyatekiWf* this); -void func_80A2075C(EnSyatekiWf* this, GlobalContext* globalCtx); +void func_80A2075C(EnSyatekiWf* this, PlayState* play); void func_80A2079C(EnSyatekiWf* this); -void func_80A20800(EnSyatekiWf* this, GlobalContext* globalCtx); -void func_80A208F8(EnSyatekiWf* this, GlobalContext* globalCtx); +void func_80A20800(EnSyatekiWf* this, PlayState* play); +void func_80A208F8(EnSyatekiWf* this, PlayState* play); static ColliderJntSphElementInit sJntSphElementsInit[1] = { { @@ -74,7 +73,7 @@ static ColliderJntSphInit sJntSphInit = { OC2_TYPE_1, COLSHAPE_JNTSPH, }, - 1, + ARRAY_COUNT(sJntSphElementsInit), sJntSphElementsInit, }; @@ -114,14 +113,14 @@ const ActorInit En_Syateki_Wf_InitVars = { (ActorFunc)EnSyatekiWf_Draw, }; -static AnimationInfo sAnimations[] = { - { &object_wf_Anim_00A3CC, 2.0f, 0.0f, 0.0f, ANIMMODE_LOOP, -1.0f }, - { &object_wf_Anim_005700, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, -8.0f }, - { &object_wf_Anim_005700, 1.0f, 0.0f, 4.0f, ANIMMODE_ONCE, 1.0f }, - { &object_wf_Anim_005700, 1.0f, 4.0f, 8.0f, ANIMMODE_ONCE, 1.0f }, - { &object_wf_Anim_004A90, 1.0f, 0.0f, 0.0f, ANIMMODE_ONCE, -1.0f }, - { &object_wf_Anim_009A50, 1.0f, 0.0f, 0.0f, ANIMMODE_ONCE, 8.0f }, - { &object_wf_Anim_0053D0, 1.0f, 0.0f, 0.0f, ANIMMODE_ONCE, -1.0f }, +static AnimationInfo sAnimationInfo[] = { + { &gWolfosWaitingAnim, 2.0f, 0.0f, 0.0f, ANIMMODE_LOOP, -1.0f }, + { &gWolfosRunningAnim, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, -8.0f }, + { &gWolfosRunningAnim, 1.0f, 0.0f, 4.0f, ANIMMODE_ONCE, 1.0f }, + { &gWolfosRunningAnim, 1.0f, 4.0f, 8.0f, ANIMMODE_ONCE, 1.0f }, + { &gWolfosBackflippingAnim, 1.0f, 0.0f, 0.0f, ANIMMODE_ONCE, -1.0f }, + { &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[] = { @@ -134,13 +133,13 @@ static Vec3f D_80A20FC4 = { 0.0f, 0.5f, 0.0f }; static Vec3f D_80A20FD0 = { 1200.0f, 0.0f, 0.0f }; static TexturePtr sEyeTextures[] = { - object_wf_Tex_007AA8, - object_wf_Tex_0082A8, - object_wf_Tex_0084A8, - object_wf_Tex_0082A8, + gWolfosNormalEyeOpenTex, + gWolfosNormalEyeHalfTex, + gWolfosNormalEyeNarrowTex, + gWolfosNormalEyeHalfTex, }; -void EnSyatekiWf_Init(Actor* thisx, GlobalContext* globalCtx) { +void EnSyatekiWf_Init(Actor* thisx, PlayState* play) { s32 pad; EnSyatekiWf* this = THIS; Path* path; @@ -149,11 +148,11 @@ void EnSyatekiWf_Init(Actor* thisx, GlobalContext* globalCtx) { path = syatekiMan->path; while (path->unk2 != 2) { - path = &globalCtx->setupPathList[path->unk1]; + path = &play->setupPathList[path->unk1]; } - for (i = 0; i < EN_SYATEKI_WF_GET_PARAM_FF00(&this->actor); i++) { - path = &globalCtx->setupPathList[path->unk1]; + for (i = 0; i < EN_SYATEKI_WF_GET_NUMBER(&this->actor); i++) { + path = &play->setupPathList[path->unk1]; } if (path == NULL) { @@ -176,27 +175,27 @@ void EnSyatekiWf_Init(Actor* thisx, GlobalContext* globalCtx) { this->eyeIndex = 0; this->unk_2AC = 10.0f; - 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); + Collider_InitCylinder(play, &this->unk_2B4); + Collider_SetCylinder(play, &this->unk_2B4, &this->actor, &sCylinderInit1); + Collider_InitCylinder(play, &this->unk_300); + Collider_SetCylinder(play, &this->unk_300, &this->actor, &sCylinderInit2); + Collider_InitJntSph(play, &this->unk_34C); + Collider_SetJntSph(play, &this->unk_34C, &this->actor, &sJntSphInit, this->unk_36C); this->unk_34C.elements->dim.worldSphere.radius = sJntSphInit.elements[0].dim.modelSphere.radius; - SkelAnime_InitFlex(globalCtx, &this->skelAnime, &object_wf_Skel_0095D0, &object_wf_Anim_00A3CC, this->jointTable, - this->morphTable, 22); + SkelAnime_InitFlex(play, &this->skelAnime, &gWolfosNormalSkel, &gWolfosWaitingAnim, this->jointTable, + this->morphTable, WOLFOS_NORMAL_LIMB_MAX); Actor_SetScale(&this->actor, 0.01f); this->actor.hintId = 0x4C; func_80A201CC(this); } -void EnSyatekiWf_Destroy(Actor* thisx, GlobalContext* globalCtx) { +void EnSyatekiWf_Destroy(Actor* thisx, PlayState* play) { EnSyatekiWf* this = THIS; - Collider_DestroyCylinder(globalCtx, &this->unk_2B4); - Collider_DestroyCylinder(globalCtx, &this->unk_300); + Collider_DestroyCylinder(play, &this->unk_2B4); + Collider_DestroyCylinder(play, &this->unk_300); } void func_80A200E0(EnSyatekiWf* this) { @@ -225,19 +224,19 @@ void func_80A201CC(EnSyatekiWf* this) { this->actor.draw = NULL; this->unk_2A4 = 1; this->unk_298 = 0; - syatekiMan->unk_276 &= ~(1 << EN_SYATEKI_WF_GET_PARAM_FF00(&this->actor)); + syatekiMan->wolfosFlags &= ~(1 << EN_SYATEKI_WF_GET_NUMBER(&this->actor)); this->actionFunc = func_80A20284; } -void func_80A20284(EnSyatekiWf* this, GlobalContext* globalCtx) { +void func_80A20284(EnSyatekiWf* this, PlayState* play) { EnSyatekiMan* syatekiMan; if (this->actor.parent != NULL) { syatekiMan = (EnSyatekiMan*)this->actor.parent; - if ((syatekiMan->unk_26A == 1) && (this->unk_298 == 1)) { + if ((syatekiMan->shootingGameState == SG_GAME_STATE_RUNNING) && (this->unk_298 == 1)) { func_80A200E0(this); func_80A2030C(this); - } else if (syatekiMan->unk_276 & (1 << EN_SYATEKI_WF_GET_PARAM_FF00(&this->actor))) { + } else if (syatekiMan->wolfosFlags & (1 << EN_SYATEKI_WF_GET_NUMBER(&this->actor))) { this->unk_298 = 1; } } @@ -247,7 +246,7 @@ void func_80A2030C(EnSyatekiWf* this) { this->actionFunc = func_80A20320; } -void func_80A20320(EnSyatekiWf* this, GlobalContext* globalCtx) { +void func_80A20320(EnSyatekiWf* this, PlayState* play) { if (this->unk_29C >= 11) { Actor_PlaySfxAtPos(this->actor.parent, NA_SE_EN_WOLFOS_APPEAR); this->unk_29C = 0; @@ -258,20 +257,20 @@ void func_80A20320(EnSyatekiWf* this, GlobalContext* globalCtx) { } void func_80A20378(EnSyatekiWf* this) { - Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 1); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, 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; } -void func_80A203DC(EnSyatekiWf* this, GlobalContext* globalCtx) { +void func_80A203DC(EnSyatekiWf* this, PlayState* play) { Vec3f sp54; f32 sp50; s16 temp_v0; EnSyatekiMan* syatekiMan = (EnSyatekiMan*)this->actor.parent; - if (syatekiMan->unk_26A != 1) { + if (syatekiMan->shootingGameState != SG_GAME_STATE_RUNNING) { func_80A201CC(this); } @@ -320,7 +319,7 @@ void func_80A203DC(EnSyatekiWf* this, GlobalContext* globalCtx) { } 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); + Actor_SpawnFloorDustRing(play, &this->actor, &this->actor.world.pos, 10.0f, 3, 2.0f, 0, 0, 0); } } } @@ -329,11 +328,11 @@ 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); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, 2); this->actionFunc = func_80A206DC; } -void func_80A206DC(EnSyatekiWf* this, GlobalContext* globalCtx) { +void func_80A206DC(EnSyatekiWf* this, PlayState* play) { if (this->actor.bgCheckFlags & 2) { func_80A20710(this); } @@ -341,11 +340,11 @@ void func_80A206DC(EnSyatekiWf* this, GlobalContext* globalCtx) { void func_80A20710(EnSyatekiWf* this) { this->actor.speedXZ = 0.0f; - Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 3); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, 3); this->actionFunc = func_80A2075C; } -void func_80A2075C(EnSyatekiWf* this, GlobalContext* globalCtx) { +void func_80A2075C(EnSyatekiWf* this, PlayState* play) { if (Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) { func_80A20378(this); } @@ -355,11 +354,11 @@ 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); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, 5); this->actionFunc = func_80A20800; } -void func_80A20800(EnSyatekiWf* this, GlobalContext* globalCtx) { +void func_80A20800(EnSyatekiWf* this, PlayState* play) { if (Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) { this->unk_29A--; if (this->unk_29A == 0) { @@ -368,19 +367,19 @@ void func_80A20800(EnSyatekiWf* this, GlobalContext* globalCtx) { } } -void func_80A20858(EnSyatekiWf* this, GlobalContext* globalCtx) { +void func_80A20858(EnSyatekiWf* this, PlayState* play) { 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); + EffectSsExtra_Spawn(play, &this->actor.world.pos, &D_80A20EDC, &D_80A20EE8, 5, 2); Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_WOLFOS_DEAD); - Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 6); - syatekiMan->unk_280 += 100; + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, 6); + syatekiMan->score += 100; this->actionFunc = func_80A208F8; } -void func_80A208F8(EnSyatekiWf* this, GlobalContext* globalCtx) { +void func_80A208F8(EnSyatekiWf* this, PlayState* play) { s32 pad; if (Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) { @@ -394,13 +393,13 @@ void func_80A208F8(EnSyatekiWf* this, GlobalContext* globalCtx) { 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); + func_800B3030(play, &sp68, &sp5C, &sp5C, 0x64, 0, 2); } } } -void EnSyatekiWf_Update(Actor* thisx, GlobalContext* globalCtx2) { - GlobalContext* globalCtx = globalCtx2; +void EnSyatekiWf_Update(Actor* thisx, PlayState* play2) { + PlayState* play = play2; EnSyatekiWf* this = THIS; if (this->actionFunc != func_80A20284) { @@ -408,8 +407,8 @@ void EnSyatekiWf_Update(Actor* thisx, GlobalContext* globalCtx2) { } Actor_MoveWithGravity(&this->actor); - Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 32.0f, 30.0f, 60.0f, 5); - this->actionFunc(this, globalCtx); + Actor_UpdateBgCheckInfo(play, &this->actor, 32.0f, 30.0f, 60.0f, 5); + this->actionFunc(this, play); if (this->actor.bgCheckFlags & 3) { func_800BE3D0(&this->actor, this->actor.shape.rot.y, &this->actor.shape.rot); @@ -426,24 +425,24 @@ void EnSyatekiWf_Update(Actor* thisx, GlobalContext* globalCtx2) { this->actor.colChkInfo.health -= 2; if (this->actor.colChkInfo.health == 0) { func_801A3098(NA_BGM_GET_ITEM | 0x900); - func_80A20858(this, globalCtx); + func_80A20858(this, play); } else { play_sound(NA_SE_SY_TRE_BOX_APPEAR); - EffectSsExtra_Spawn(globalCtx, &this->actor.world.pos, &D_80A20EDC, &D_80A20EE8, 3, 0); + EffectSsExtra_Spawn(play, &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); + CollisionCheck_SetAC(play, &play->colChkCtx, &this->unk_300.base); + CollisionCheck_SetAC(play, &play->colChkCtx, &this->unk_2B4.base); + CollisionCheck_SetAC(play, &play->colChkCtx, &this->unk_34C.base); 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)) { + if ((Rand_ZeroOne() < 0.2f) && ((play->gameplayFrames & 3) == 0) && (this->actor.colorFilterTimer == 0)) { this->eyeIndex++; } } else { @@ -451,33 +450,32 @@ void EnSyatekiWf_Update(Actor* thisx, GlobalContext* globalCtx2) { } } -s32 EnSyatekiWf_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, - Actor* thisx) { +s32 EnSyatekiWf_OverrideLimbDraw(PlayState* play, 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) { +void EnSyatekiWf_PostLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx) { EnSyatekiWf* this = THIS; Vec3f sp18; Collider_UpdateSpheres(limbIndex, &this->unk_34C); - if (limbIndex == OBJECT_WF_2_LIMB_06) { - Matrix_MultiplyVector3fByState(&D_80A20FD0, &sp18); + 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) { +void EnSyatekiWf_Draw(Actor* thisx, PlayState* play) { EnSyatekiWf* this = THIS; - OPEN_DISPS(globalCtx->state.gfxCtx); + OPEN_DISPS(play->state.gfxCtx); - func_8012C28C(globalCtx->state.gfxCtx); + func_8012C28C(play->state.gfxCtx); gSPSegment(POLY_OPA_DISP++, 0x08, Lib_SegmentedToVirtual(sEyeTextures[this->eyeIndex])); - SkelAnime_DrawFlexOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, + SkelAnime_DrawFlexOpa(play, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, EnSyatekiWf_OverrideLimbDraw, EnSyatekiWf_PostLimbDraw, &this->actor); - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->state.gfxCtx); } diff --git a/src/overlays/actors/ovl_En_Syateki_Wf/z_en_syateki_wf.h b/src/overlays/actors/ovl_En_Syateki_Wf/z_en_syateki_wf.h index 23977fa02..4de182a10 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,19 +2,21 @@ #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) +#define EN_SYATEKI_WF_GET_NUMBER(thisx) (((thisx)->params & 0xFF00) >> 8) +#define EN_SYATEKI_WF_PARAMS(number, unkF0, unused) (((number << 8) & 0xFF00) | ((unkF0 << 4) & 0xF0) | (unused & 0xF)) struct EnSyatekiWf; -typedef void (*EnSyatekiWfActionFunc)(struct EnSyatekiWf*, GlobalContext*); +typedef void (*EnSyatekiWfActionFunc)(struct EnSyatekiWf*, PlayState*); typedef struct EnSyatekiWf { /* 0x000 */ Actor actor; /* 0x144 */ SkelAnime skelAnime; - /* 0x188 */ Vec3s jointTable[22]; - /* 0x20C */ Vec3s morphTable[22]; + /* 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; @@ -29,7 +31,7 @@ typedef struct EnSyatekiWf { /* 0x2B4 */ ColliderCylinder unk_2B4; /* 0x300 */ ColliderCylinder unk_300; /* 0x34C */ ColliderJntSph unk_34C; - /* 0x36C */ ColliderJntSphElement unk_36C; + /* 0x36C */ ColliderJntSphElement unk_36C[1]; /* 0x3AC */ UNK_TYPE1 unk_3AC[0x20]; } EnSyatekiWf; // size = 0x3CC diff --git a/src/overlays/actors/ovl_En_Tab/z_en_tab.c b/src/overlays/actors/ovl_En_Tab/z_en_tab.c index 48a1bc064..860ad9d0c 100644 --- a/src/overlays/actors/ovl_En_Tab/z_en_tab.c +++ b/src/overlays/actors/ovl_En_Tab/z_en_tab.c @@ -12,17 +12,30 @@ #define THIS ((EnTab*)thisx) -void EnTab_Init(Actor* thisx, GlobalContext* globalCtx); -void EnTab_Destroy(Actor* thisx, GlobalContext* globalCtx); -void EnTab_Update(Actor* thisx, GlobalContext* globalCtx); -void EnTab_Draw(Actor* thisx, GlobalContext* globalCtx); +void EnTab_Init(Actor* thisx, PlayState* play); +void EnTab_Destroy(Actor* thisx, PlayState* play); +void EnTab_Update(Actor* thisx, PlayState* play); +void EnTab_Draw(Actor* thisx, PlayState* play); -void func_80BE127C(EnTab* this, GlobalContext* globalCtx); -void func_80BE1348(EnTab* this, GlobalContext* globalCtx); +void func_80BE127C(EnTab* this, PlayState* play); +void func_80BE1348(EnTab* this, PlayState* play); -s32 D_80BE18D0[] = { - 0x0C000320, 0x0A00151B, 0x02093212, 0x010F0212, 0x00060003, 0x0400000E, 0x12000600, 0x020E0932, 0x12010105, - 0x0A001519, 0x02093215, 0x050D0215, 0x37050501, 0x050E1537, 0x0505020E, 0x09321505, 0x01050000, +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[] = { @@ -109,12 +122,12 @@ TexturePtr D_80BE1B24[] = { object_tab_Tex_006928, }; -EnGm* func_80BE04E0(EnTab* this, GlobalContext* globalCtx, u8 actorCat, s16 actorId) { +EnGm* func_80BE04E0(EnTab* this, PlayState* play, u8 actorCat, s16 actorId) { Actor* foundActor = NULL; Actor* tempActor; while (true) { - foundActor = SubS_FindActor(globalCtx, foundActor, actorCat, actorId); + foundActor = SubS_FindActor(play, foundActor, actorCat, actorId); if ((foundActor == NULL) || (((EnTab*)foundActor != this) && (foundActor->update != NULL))) { break; } @@ -151,11 +164,11 @@ s32 func_80BE05BC(EnTab* this, s32 arg1) { return ret; } -void func_80BE0620(EnTab* this, GlobalContext* globalCtx) { +void func_80BE0620(EnTab* this, PlayState* play) { s32 pad; Collider_UpdateCylinder(&this->actor, &this->collider); - CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + CollisionCheck_SetOC(play, &play->colChkCtx, &this->collider.base); } void func_80BE0664(EnTab* this) { @@ -168,16 +181,16 @@ void func_80BE0664(EnTab* this) { } } -s32 func_80BE06DC(EnTab* this, GlobalContext* globalCtx) { +s32 func_80BE06DC(EnTab* this, PlayState* play) { s32 ret = false; if (this->unk_2FC & 7) { - if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { + if (Actor_ProcessTalkRequest(&this->actor, &play->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->actor.child = &GET_PLAYER(play)->actor; this->unk_2FC |= 8; this->actionFunc = func_80BE1348; } @@ -185,13 +198,13 @@ s32 func_80BE06DC(EnTab* this, GlobalContext* globalCtx) { return ret; } -Actor* func_80BE0778(EnTab* this, GlobalContext* globalCtx) { +Actor* func_80BE0778(EnTab* this, PlayState* play) { Actor* actor; if (this->unk_1D8 == 1) { actor = this->actor.child; } else { - actor = &GET_PLAYER(globalCtx)->actor; + actor = &GET_PLAYER(play)->actor; } return actor; } @@ -226,8 +239,8 @@ void func_80BE07A0(EnTab* this) { this->unk_316 = CLAMP(this->unk_316, -0xE38, 0xE38); } -void func_80BE09A8(EnTab* this, GlobalContext* globalCtx) { - this->unk_1E0 = func_80BE0778(this, globalCtx); +void func_80BE09A8(EnTab* this, PlayState* play) { + this->unk_1E0 = func_80BE0778(this, play); if ((this->unk_2FC & 8) && (this->unk_1E0 != 0) && (DECR(this->unk_324) == 0)) { func_80BE07A0(this); this->unk_316 = 0; @@ -246,19 +259,19 @@ void func_80BE09A8(EnTab* this, GlobalContext* globalCtx) { } } -void func_80BE0A98(EnTab* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); - s32 sp20 = Message_GetState(&globalCtx->msgCtx); +void func_80BE0A98(EnTab* this, PlayState* play) { + Player* player = GET_PLAYER(play); + s32 talkState = Message_GetState(&play->msgCtx); this->unk_308 += (this->unk_304 != 0.0f) ? 40.0f : -40.0f; this->unk_308 = CLAMP(this->unk_308, 0.0f, 80.0f); - Matrix_InsertTranslation(this->unk_308, 0.0f, 0.0f, MTXMODE_APPLY); + 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) { + ((play->msgCtx.currentTextId < 0xFF) || (play->msgCtx.currentTextId > 0x200)) && (talkState == TEXT_STATE_3) && + (this->prevTalkState == TEXT_STATE_3)) { + if ((play->state.frames % 2) == 0) { if (this->unk_304 != 0.0f) { this->unk_304 = 0.0f; } else { @@ -268,7 +281,7 @@ void func_80BE0A98(EnTab* this, GlobalContext* globalCtx) { } else { this->unk_304 = 0.0f; } - this->unk_334 = sp20; + this->prevTalkState = talkState; } s32 func_80BE0C04(EnTab* this, Actor* actor, f32 arg2) { @@ -300,27 +313,27 @@ s32 func_80BE0C04(EnTab* this, Actor* actor, f32 arg2) { return ret; } -s32 func_80BE0D38(EnTab* this, GlobalContext* globalCtx) { - return Interface_HasEmptyBottle(); +s32 func_80BE0D38(EnTab* this, PlayState* play) { + return Inventory_HasEmptyBottle(); } -s32 func_80BE0D60(EnTab* this, GlobalContext* globalCtx) { +s32 func_80BE0D60(EnTab* this, PlayState* play) { s32 pad; s32 ret = false; this->unk_320++; if (this->unk_320 == 1) { - globalCtx->setPlayerTalkAnim(globalCtx, &gameplay_keep_Linkanim_00D568, 2); + play->setPlayerTalkAnim(play, &gameplay_keep_Linkanim_00D568, 2); } else if (this->unk_320 > 20) { - globalCtx->setPlayerTalkAnim(globalCtx, NULL, 0); + play->setPlayerTalkAnim(play, NULL, 0); this->unk_320 = 0; ret = true; } return ret; } -s32* func_80BE0E04(EnTab* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); +s32* func_80BE0E04(EnTab* this, PlayState* play) { + Player* player = GET_PLAYER(play); if (player->transformation == PLAYER_FORM_DEKU) { return D_80BE1984; @@ -329,7 +342,7 @@ s32* func_80BE0E04(EnTab* this, GlobalContext* globalCtx) { switch (this->unk_1D8) { case 2: this->unk_328 = func_80BE0D38; - if (Player_GetMask(globalCtx) != PLAYER_MASK_ROMANI) { + if (Player_GetMask(play) != PLAYER_MASK_ROMANI) { return D_80BE1998; } @@ -340,11 +353,11 @@ s32* func_80BE0E04(EnTab* this, GlobalContext* globalCtx) { case 1: this->unk_328 = func_80BE0D60; - if (Player_GetMask(globalCtx) == PLAYER_MASK_ROMANI) { + if (Player_GetMask(play) == PLAYER_MASK_ROMANI) { return D_80BE1940; } - if (Player_GetMask(globalCtx) == PLAYER_MASK_KAFEIS_MASK) { + if (Player_GetMask(play) == PLAYER_MASK_KAFEIS_MASK) { return D_80BE1970; } return D_80BE1914; @@ -353,9 +366,9 @@ s32* func_80BE0E04(EnTab* this, GlobalContext* globalCtx) { return NULL; } -s32 func_80BE0F04(EnTab* this, GlobalContext* globalCtx, struct_80133038_arg2* arg2) { +s32 func_80BE0F04(EnTab* this, PlayState* play, ScheduleOutput* scheduleOutput) { s32 ret = false; - EnGm* sp28 = func_80BE04E0(this, globalCtx, ACTORCAT_NPC, ACTOR_EN_GM); + EnGm* sp28 = func_80BE04E0(this, play, ACTORCAT_NPC, ACTOR_EN_GM); if (sp28) { Math_Vec3f_Copy(&this->actor.world.pos, &D_80BE1AF0); @@ -372,7 +385,7 @@ s32 func_80BE0F04(EnTab* this, GlobalContext* globalCtx, struct_80133038_arg2* a return ret; } -s32 func_80BE0FC4(EnTab* this, GlobalContext* globalCtx, struct_80133038_arg2* arg2) { +s32 func_80BE0FC4(EnTab* this, PlayState* play, ScheduleOutput* scheduleOutput) { s32 pad; Math_Vec3f_Copy(&this->actor.world.pos, &D_80BE1B04); @@ -386,18 +399,18 @@ s32 func_80BE0FC4(EnTab* this, GlobalContext* globalCtx, struct_80133038_arg2* a return true; } -s32 func_80BE1060(EnTab* this, GlobalContext* globalCtx, struct_80133038_arg2* arg2) { +s32 func_80BE1060(EnTab* this, PlayState* play, ScheduleOutput* scheduleOutput) { s32 ret; this->unk_2FC = 0; - switch (arg2->unk0) { + switch (scheduleOutput->result) { case 1: - ret = func_80BE0F04(this, globalCtx, arg2); + ret = func_80BE0F04(this, play, scheduleOutput); break; case 2: - ret = func_80BE0FC4(this, globalCtx, arg2); + ret = func_80BE0FC4(this, play, scheduleOutput); break; default: @@ -407,16 +420,16 @@ s32 func_80BE1060(EnTab* this, GlobalContext* globalCtx, struct_80133038_arg2* a return ret; } -s32 func_80BE10BC(EnTab* this, GlobalContext* globalCtx) { +s32 func_80BE10BC(EnTab* this, PlayState* play) { s32 pad; - Player* player = GET_PLAYER(globalCtx); + Player* player = GET_PLAYER(play); f32 dist; Actor* tempActor; switch (this->unk_1D8) { case 1: - if ((player->stateFlags1 & 0x40) && !(globalCtx->msgCtx.currentTextId <= 0x2B00) && - (globalCtx->msgCtx.currentTextId < 0x2B08)) { + if ((player->stateFlags1 & 0x40) && !(play->msgCtx.currentTextId <= 0x2B00) && + (play->msgCtx.currentTextId < 0x2B08)) { this->actor.child = &this->unk_1E4->actor; this->unk_2FC |= 8; } else { @@ -424,7 +437,7 @@ s32 func_80BE10BC(EnTab* this, GlobalContext* globalCtx) { if ((gSaveContext.save.weekEventReg[75] & 1) || (this->unk_1E4->actor.draw == NULL) || !(dist < 160.0f)) { - tempActor = &GET_PLAYER(globalCtx)->actor; + tempActor = &GET_PLAYER(play)->actor; this->actor.child = tempActor; } else { tempActor = &this->unk_1E4->actor; @@ -440,7 +453,7 @@ s32 func_80BE10BC(EnTab* this, GlobalContext* globalCtx) { break; case 2: - if (func_80BE0C04(this, &GET_PLAYER(globalCtx)->actor, 200.0f)) { + if (func_80BE0C04(this, &GET_PLAYER(play)->actor, 200.0f)) { this->unk_2FC |= 8; } else { this->unk_2FC &= ~8; @@ -451,38 +464,37 @@ s32 func_80BE10BC(EnTab* this, GlobalContext* globalCtx) { return false; } -void func_80BE1224(EnTab* this, GlobalContext* globalCtx) { +void func_80BE1224(EnTab* this, PlayState* play) { if ((this->unk_1D8 == 1) || (this->unk_1D8 == 2)) { - func_80BE10BC(this, globalCtx); + func_80BE10BC(this, play); } Math_ApproachS(&this->actor.shape.rot.y, this->actor.world.rot.y, 3, 0x2AA8); } -void func_80BE127C(EnTab* this, GlobalContext* globalCtx) { - u32* unk_14 = &gSaveContext.save.daySpeed; - struct_80133038_arg2 sp18; +void func_80BE127C(EnTab* this, PlayState* play) { + ScheduleOutput sp18; - this->unk_31A = REG(15) + *unk_14; + this->unk_31A = REG(15) + ((void)0, gSaveContext.save.daySpeed); - if (!func_80133038(globalCtx, D_80BE18D0, &sp18) || - ((this->unk_1D8 != sp18.unk0) && !func_80BE1060(this, globalCtx, &sp18))) { + if (!Schedule_RunScript(play, D_80BE18D0, &sp18) || + ((this->unk_1D8 != sp18.result) && !func_80BE1060(this, play, &sp18))) { this->actor.shape.shadowDraw = NULL; this->actor.flags &= ~ACTOR_FLAG_1; - sp18.unk0 = 0; + sp18.result = 0; } else { this->actor.shape.shadowDraw = ActorShadow_DrawCircle; this->actor.flags |= ACTOR_FLAG_1; } - this->unk_1D8 = sp18.unk0; - func_80BE1224(this, globalCtx); + this->unk_1D8 = sp18.result; + func_80BE1224(this, play); } -void func_80BE1348(EnTab* this, GlobalContext* globalCtx) { +void func_80BE1348(EnTab* this, PlayState* play) { s32 pad; Vec3f sp40; Vec3f sp34; - if (func_8010BF58(&this->actor, globalCtx, func_80BE0E04(this, globalCtx), this->unk_328, &this->unk_1DC)) { + if (func_8010BF58(&this->actor, play, func_80BE0E04(this, play), this->unk_328, &this->unk_1DC)) { SubS_UpdateFlags(&this->unk_2FC, 3, 7); this->unk_2FC &= ~8; this->unk_2FC |= 0x40; @@ -496,15 +508,14 @@ void func_80BE1348(EnTab* this, GlobalContext* globalCtx) { } } -void EnTab_Init(Actor* thisx, GlobalContext* globalCtx) { +void EnTab_Init(Actor* thisx, PlayState* play) { 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); + SkelAnime_InitFlex(play, &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); + Collider_InitAndSetCylinder(play, &this->collider, &this->actor, &sCylinderInit); CollisionCheck_SetInfo2(&this->actor.colChkInfo, DamageTable_Get(0x16), &sColChkInfoInit); Actor_SetScale(&this->actor, 0.01f); @@ -515,44 +526,44 @@ void EnTab_Init(Actor* thisx, GlobalContext* globalCtx) { this->actor.gravity = -1.0f; this->actionFunc = func_80BE127C; - this->actionFunc(this, globalCtx); + this->actionFunc(this, play); } -void EnTab_Destroy(Actor* thisx, GlobalContext* globalCtx) { +void EnTab_Destroy(Actor* thisx, PlayState* play) { EnTab* this = THIS; - Collider_DestroyCylinder(globalCtx, &this->collider); + Collider_DestroyCylinder(play, &this->collider); } -void EnTab_Update(Actor* thisx, GlobalContext* globalCtx) { +void EnTab_Update(Actor* thisx, PlayState* play) { EnTab* this = THIS; f32 radius; f32 height; - func_80BE06DC(this, globalCtx); + func_80BE06DC(this, play); - this->actionFunc(this, globalCtx); + this->actionFunc(this, play); if (this->unk_1D8 != 0) { func_80BE0590(this); func_80BE0664(this); - func_80BE09A8(this, globalCtx); + func_80BE09A8(this, play); radius = this->collider.dim.radius + this->unk_30C; height = this->collider.dim.height + 10; - func_8013C964(&this->actor, globalCtx, radius, height, 0, this->unk_2FC & 7); + func_8013C964(&this->actor, play, radius, height, PLAYER_AP_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); + Actor_UpdateBgCheckInfo(play, &this->actor, 30.0f, 12.0f, 0.0f, 4); + func_80BE0620(this, play); } } -s32 EnTab_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, Actor* thisx) { +s32 EnTab_OverrideLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, Actor* thisx) { EnTab* this = THIS; if (limbIndex == 9) { - func_80BE0A98(this, globalCtx); + func_80BE0A98(this, play); } if ((this->unk_32C == 1) && (limbIndex == 18)) { @@ -561,60 +572,60 @@ s32 EnTab_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, return false; } -void EnTab_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx) { +void EnTab_PostLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx) { EnTab* this = THIS; if (limbIndex == 9) { - Matrix_MultiplyVector3fByState(&D_80BE1B18, &this->actor.focus.pos); + 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) { +void EnTab_TransformLimbDraw(PlayState* play, s32 limbIndex, Actor* thisx) { EnTab* this = THIS; - s32 phi_v0; - s32 phi_v1; + s32 rotStep; + s32 overrideStep; if (!(this->unk_2FC & 0x40)) { if (this->unk_2FC & 0x10) { - phi_v1 = 1; + overrideStep = true; } else { - phi_v1 = 0; + overrideStep = false; } - phi_v0 = 1; + rotStep = true; } else { - phi_v1 = 0; - phi_v0 = 0; + overrideStep = false; + rotStep = false; } if (limbIndex == 9) { - func_8013AD9C(BINANG_ADD(this->unk_312 + this->unk_316, 0x4000), - BINANG_ADD(this->unk_314 + this->unk_318 + this->actor.shape.rot.y, 0x4000), this->unk_1E8, - this->unk_200, phi_v0, phi_v1); - Matrix_StatePop(); - Matrix_InsertTranslation(this->unk_1E8[0].x, this->unk_1E8[0].y, this->unk_1E8[0].z, MTXMODE_NEW); + 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_RotateY(this->unk_200[0].y, MTXMODE_APPLY); - Matrix_InsertXRotation_s(this->unk_200[0].x, MTXMODE_APPLY); - Matrix_InsertZRotation_s(this->unk_200[0].z, MTXMODE_APPLY); - Matrix_StatePush(); + 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) { +void EnTab_Draw(Actor* thisx, PlayState* play) { EnTab* this = THIS; if (this->unk_1D8 != 0) { - OPEN_DISPS(globalCtx->state.gfxCtx); + OPEN_DISPS(play->state.gfxCtx); - func_8012C28C(globalCtx->state.gfxCtx); + func_8012C28C(play->state.gfxCtx); gSPSegment(POLY_OPA_DISP++, 0x08, Lib_SegmentedToVirtual(D_80BE1B24[this->unk_31E])); - SkelAnime_DrawTransformFlexOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, + SkelAnime_DrawTransformFlexOpa(play, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, EnTab_OverrideLimbDraw, EnTab_PostLimbDraw, - EnTab_TransformDraw, &this->actor); + EnTab_TransformLimbDraw, &this->actor); - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->state.gfxCtx); } } diff --git a/src/overlays/actors/ovl_En_Tab/z_en_tab.h b/src/overlays/actors/ovl_En_Tab/z_en_tab.h index 266949fe8..81ce92006 100644 --- a/src/overlays/actors/ovl_En_Tab/z_en_tab.h +++ b/src/overlays/actors/ovl_En_Tab/z_en_tab.h @@ -6,43 +6,43 @@ struct EnTab; -typedef void (*EnTabActionFunc)(struct EnTab*, GlobalContext*); -typedef s32 (*EnTabUnkFunc)(struct EnTab*, GlobalContext*); +typedef void (*EnTabActionFunc)(struct EnTab*, PlayState*); +typedef s32 (*EnTabUnkFunc)(struct EnTab*, PlayState*); typedef struct EnTab { - /* 0x0000 */ Actor actor; - /* 0x0144 */ SkelAnime skelAnime; - /* 0x0188 */ EnTabActionFunc actionFunc; - /* 0x018C */ ColliderCylinder collider; - /* 0x01D8 */ u8 unk_1D8; - /* 0x01DC */ s32 unk_1DC; - /* 0x01E0 */ Actor* unk_1E0; - /* 0x01E4 */ EnGm* unk_1E4; - /* 0x01E8 */ Vec3f unk_1E8[2]; - /* 0x0200 */ Vec3s unk_200[2]; - /* 0x020C */ Vec3s jointTable[20]; - /* 0x0284 */ Vec3s morphTable[20]; - /* 0x02FC */ u16 unk_2FC; - /* 0x0300 */ f32 unk_300; - /* 0x0304 */ f32 unk_304; - /* 0x0308 */ f32 unk_308; - /* 0x030C */ s16 unk_30C; - /* 0x030E */ UNK_TYPE1 unk30E[4]; - /* 0x0312 */ s16 unk_312; - /* 0x0314 */ s16 unk_314; - /* 0x0316 */ s16 unk_316; - /* 0x0318 */ s16 unk_318; - /* 0x031A */ s16 unk_31A; - /* 0x031C */ s16 unk_31C; - /* 0x031E */ s16 unk_31E; - /* 0x0320 */ s16 unk_320; - /* 0x0322 */ s16 unk_322; - /* 0x0324 */ s16 unk_324; - /* 0x0328 */ EnTabUnkFunc unk_328; - /* 0x032C */ s32 unk_32C; - /* 0x0330 */ UNK_TYPE1 unk330[4]; - /* 0x0334 */ s32 unk_334; - /* 0x0338 */ s32 unk_338; + /* 0x000 */ Actor actor; + /* 0x144 */ SkelAnime skelAnime; + /* 0x188 */ EnTabActionFunc actionFunc; + /* 0x18C */ ColliderCylinder collider; + /* 0x1D8 */ u8 unk_1D8; + /* 0x1DC */ s32 unk_1DC; + /* 0x1E0 */ Actor* unk_1E0; + /* 0x1E4 */ EnGm* unk_1E4; + /* 0x1E8 */ Vec3f unk_1E8[2]; + /* 0x200 */ Vec3s unk_200[2]; + /* 0x20C */ Vec3s jointTable[20]; + /* 0x284 */ Vec3s morphTable[20]; + /* 0x2FC */ u16 unk_2FC; + /* 0x300 */ f32 unk_300; + /* 0x304 */ f32 unk_304; + /* 0x308 */ f32 unk_308; + /* 0x30C */ s16 unk_30C; + /* 0x30E */ UNK_TYPE1 unk30E[4]; + /* 0x312 */ s16 unk_312; + /* 0x314 */ s16 unk_314; + /* 0x316 */ s16 unk_316; + /* 0x318 */ s16 unk_318; + /* 0x31A */ s16 unk_31A; + /* 0x31C */ s16 unk_31C; + /* 0x31E */ s16 unk_31E; + /* 0x320 */ s16 unk_320; + /* 0x322 */ s16 unk_322; + /* 0x324 */ s16 unk_324; + /* 0x328 */ EnTabUnkFunc unk_328; + /* 0x32C */ s32 unk_32C; + /* 0x330 */ UNK_TYPE1 unk330[4]; + /* 0x334 */ s32 prevTalkState; + /* 0x338 */ s32 unk_338; } EnTab; // size = 0x33C extern const ActorInit En_Tab_InitVars; diff --git a/src/overlays/actors/ovl_En_Tag_Obj/z_en_tag_obj.c b/src/overlays/actors/ovl_En_Tag_Obj/z_en_tag_obj.c index 5504dabdb..db6a9d172 100644 --- a/src/overlays/actors/ovl_En_Tag_Obj/z_en_tag_obj.c +++ b/src/overlays/actors/ovl_En_Tag_Obj/z_en_tag_obj.c @@ -10,9 +10,9 @@ #define THIS ((EnTagObj*)thisx) -void EnTagObj_Init(Actor* thisx, GlobalContext* globalCtx); -void EnTagObj_Destroy(Actor* thisx, GlobalContext* globalCtx); -void EnTagObj_Update(Actor* thisx, GlobalContext* globalCtx); +void EnTagObj_Init(Actor* thisx, PlayState* play); +void EnTagObj_Destroy(Actor* thisx, PlayState* play); +void EnTagObj_Update(Actor* thisx, PlayState* play); static ColliderCylinderInit sUnusedColliderInit = { { @@ -46,21 +46,21 @@ const ActorInit En_Tag_Obj_InitVars = { (ActorFunc)NULL, }; -void EnTagObj_Init(Actor* thisx, GlobalContext* globalCtx) { +void EnTagObj_Init(Actor* thisx, PlayState* play) { EnTagObj* this = THIS; - this->hasSpawnedSeahorse = 0; + this->hasSpawnedSeahorse = false; } -void EnTagObj_Destroy(Actor* thisx, GlobalContext* globalCtx) { +void EnTagObj_Destroy(Actor* thisx, PlayState* play) { } -void EnTagObj_Update(Actor* thisx, GlobalContext* globalCtx) { +void EnTagObj_Update(Actor* thisx, PlayState* play) { EnTagObj* this = THIS; if (!this->hasSpawnedSeahorse) { - Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_OT, this->actor.world.pos.x, this->actor.world.pos.y, + Actor_Spawn(&play->actorCtx, play, ACTOR_EN_OT, this->actor.world.pos.x, this->actor.world.pos.y, this->actor.world.pos.z, 0, 0, 0, 0); - this->hasSpawnedSeahorse = 1; + this->hasSpawnedSeahorse = true; } } diff --git a/src/overlays/actors/ovl_En_Tag_Obj/z_en_tag_obj.h b/src/overlays/actors/ovl_En_Tag_Obj/z_en_tag_obj.h index 7a9fe909a..a58b2b1d3 100644 --- a/src/overlays/actors/ovl_En_Tag_Obj/z_en_tag_obj.h +++ b/src/overlays/actors/ovl_En_Tag_Obj/z_en_tag_obj.h @@ -7,7 +7,7 @@ struct EnTagObj; typedef struct EnTagObj { /* 0x000 */ Actor actor; - /* 0x144 */ char unk_144[0x50]; + /* 0x144 */ UNK_TYPE1 unk_144[0x50]; /* 0x194 */ s32 hasSpawnedSeahorse; } EnTagObj; // size = 0x198 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 35dc1ba30..726d97227 100644 --- a/src/overlays/actors/ovl_En_Takaraya/z_en_takaraya.c +++ b/src/overlays/actors/ovl_En_Takaraya/z_en_takaraya.c @@ -10,10 +10,10 @@ #define THIS ((EnTakaraya*)thisx) -void EnTakaraya_Init(Actor* thisx, GlobalContext* globalCtx); -void EnTakaraya_Destroy(Actor* thisx, GlobalContext* globalCtx); -void EnTakaraya_Update(Actor* thisx, GlobalContext* globalCtx); -void EnTakaraya_Draw(Actor* thisx, GlobalContext* globalCtx); +void EnTakaraya_Init(Actor* thisx, PlayState* play); +void EnTakaraya_Destroy(Actor* thisx, PlayState* play); +void EnTakaraya_Update(Actor* thisx, PlayState* play); +void EnTakaraya_Draw(Actor* thisx, PlayState* play); #if 0 const ActorInit En_Takaraya_InitVars = { diff --git a/src/overlays/actors/ovl_En_Takaraya/z_en_takaraya.h b/src/overlays/actors/ovl_En_Takaraya/z_en_takaraya.h index f1da0e6c6..cc707f027 100644 --- a/src/overlays/actors/ovl_En_Takaraya/z_en_takaraya.h +++ b/src/overlays/actors/ovl_En_Takaraya/z_en_takaraya.h @@ -5,13 +5,13 @@ struct EnTakaraya; -typedef void (*EnTakarayaActionFunc)(struct EnTakaraya*, GlobalContext*); +typedef void (*EnTakarayaActionFunc)(struct EnTakaraya*, PlayState*); typedef struct EnTakaraya { - /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x164]; - /* 0x02A8 */ EnTakarayaActionFunc actionFunc; - /* 0x02AC */ char unk_2AC[0x10]; + /* 0x000 */ Actor actor; + /* 0x144 */ char unk_144[0x164]; + /* 0x2A8 */ EnTakarayaActionFunc actionFunc; + /* 0x2AC */ char unk_2AC[0x10]; } EnTakaraya; // size = 0x2BC extern const ActorInit En_Takaraya_InitVars; diff --git a/src/overlays/actors/ovl_En_Talk/z_en_talk.c b/src/overlays/actors/ovl_En_Talk/z_en_talk.c index 4cf4ca407..c5b25233d 100644 --- a/src/overlays/actors/ovl_En_Talk/z_en_talk.c +++ b/src/overlays/actors/ovl_En_Talk/z_en_talk.c @@ -10,11 +10,11 @@ #define THIS ((EnTalk*)thisx) -void EnTalk_Init(Actor* thisx, GlobalContext* globalCtx); -void EnTalk_Destroy(Actor* thisx, GlobalContext* globalCtx); -void EnTalk_Update(Actor* thisx, GlobalContext* globalCtx); -void func_80BDE058(EnTalk* this, GlobalContext* globalCtx); -void func_80BDE090(EnTalk* this, GlobalContext* globalCtx); +void EnTalk_Init(Actor* thisx, PlayState* play); +void EnTalk_Destroy(Actor* thisx, PlayState* play); +void EnTalk_Update(Actor* thisx, PlayState* play); +void func_80BDE058(EnTalk* this, PlayState* play); +void func_80BDE090(EnTalk* this, PlayState* play); const ActorInit En_Talk_InitVars = { ACTOR_EN_TALK, @@ -28,7 +28,7 @@ const ActorInit En_Talk_InitVars = { (ActorFunc)NULL, }; -void EnTalk_Init(Actor* thisx, GlobalContext* globalCtx) { +void EnTalk_Init(Actor* thisx, PlayState* play) { EnTalk* this = THIS; s8 targetMode = this->actor.home.rot.x - 0x1; @@ -41,29 +41,29 @@ void EnTalk_Init(Actor* thisx, GlobalContext* globalCtx) { this->actor.textId = ENTALK_GET_TEXT_ID(&this->actor); } -void EnTalk_Destroy(Actor* thisx, GlobalContext* globalCtx) { +void EnTalk_Destroy(Actor* thisx, PlayState* play) { } -void func_80BDE058(EnTalk* this, GlobalContext* globalCtx) { - if (Actor_TextboxIsClosing(&this->actor, globalCtx)) { +void func_80BDE058(EnTalk* this, PlayState* play) { + if (Actor_TextboxIsClosing(&this->actor, play)) { this->actionFunc = func_80BDE090; } } -void func_80BDE090(EnTalk* this, GlobalContext* globalCtx) { - if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { +void func_80BDE090(EnTalk* this, PlayState* play) { + if (Actor_ProcessTalkRequest(&this->actor, &play->state)) { this->actionFunc = func_80BDE058; return; } - if ((this->actor.xzDistToPlayer < 40.0f && Player_IsFacingActor(&this->actor, 0x3000, globalCtx)) || + if ((this->actor.xzDistToPlayer < 40.0f && Player_IsFacingActor(&this->actor, 0x3000, play)) || this->actor.isTargeted) { - func_800B8614(&this->actor, globalCtx, 120.0f); + func_800B8614(&this->actor, play, 120.0f); } } -void EnTalk_Update(Actor* thisx, GlobalContext* globalCtx) { +void EnTalk_Update(Actor* thisx, PlayState* play) { EnTalk* this = THIS; - this->actionFunc(this, globalCtx); + this->actionFunc(this, play); } diff --git a/src/overlays/actors/ovl_En_Talk/z_en_talk.h b/src/overlays/actors/ovl_En_Talk/z_en_talk.h index 629a5c0e2..393a457b5 100644 --- a/src/overlays/actors/ovl_En_Talk/z_en_talk.h +++ b/src/overlays/actors/ovl_En_Talk/z_en_talk.h @@ -7,11 +7,11 @@ struct EnTalk; -typedef void (*EnTalkActionFunc)(struct EnTalk*, GlobalContext*); +typedef void (*EnTalkActionFunc)(struct EnTalk*, PlayState*); typedef struct EnTalk { - /* 0x0000 */ Actor actor; - /* 0x0144 */ EnTalkActionFunc actionFunc; + /* 0x000 */ Actor actor; + /* 0x144 */ EnTalkActionFunc actionFunc; } EnTalk; // size = 0x148 extern const ActorInit En_Talk_InitVars; diff --git a/src/overlays/actors/ovl_En_Talk_Gibud/z_en_talk_gibud.c b/src/overlays/actors/ovl_En_Talk_Gibud/z_en_talk_gibud.c index a2324aaf6..f1268e1e0 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,47 +5,48 @@ */ #include "z_en_talk_gibud.h" +#include "z64rumble.h" #define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_4 | ACTOR_FLAG_10 | ACTOR_FLAG_400) #define THIS ((EnTalkGibud*)thisx) -void EnTalkGibud_Init(Actor* thisx, GlobalContext* globalCtx); -void EnTalkGibud_Destroy(Actor* thisx, GlobalContext* globalCtx); -void EnTalkGibud_Update(Actor* thisx, GlobalContext* globalCtx); -void EnTalkGibud_Draw(Actor* thisx, GlobalContext* globalCtx); +void EnTalkGibud_Init(Actor* thisx, PlayState* play); +void EnTalkGibud_Destroy(Actor* thisx, PlayState* play); +void EnTalkGibud_Update(Actor* thisx, PlayState* play); +void EnTalkGibud_Draw(Actor* thisx, PlayState* play); void EnTalkGibud_SetupIdle(EnTalkGibud* this); -void EnTalkGibud_Idle(EnTalkGibud* this, GlobalContext* globalCtx); +void EnTalkGibud_Idle(EnTalkGibud* this, PlayState* play); void EnTalkGibud_SetupAttemptPlayerFreeze(EnTalkGibud* this); -void EnTalkGibud_AttemptPlayerFreeze(EnTalkGibud* this, GlobalContext* globalCtx); +void EnTalkGibud_AttemptPlayerFreeze(EnTalkGibud* this, PlayState* play); void EnTalkGibud_SetupWalkToPlayer(EnTalkGibud* this); -void EnTalkGibud_WalkToPlayer(EnTalkGibud* this, GlobalContext* globalCtx); +void EnTalkGibud_WalkToPlayer(EnTalkGibud* this, PlayState* play); void EnTalkGibud_SetupGrab(EnTalkGibud* this); -void EnTalkGibud_Grab(EnTalkGibud* this, GlobalContext* globalCtx); +void EnTalkGibud_Grab(EnTalkGibud* this, PlayState* play); void EnTalkGibud_SetupGrabFail(EnTalkGibud* this); -void EnTalkGibud_GrabFail(EnTalkGibud* this, GlobalContext* globalCtx); +void EnTalkGibud_GrabFail(EnTalkGibud* this, PlayState* play); void EnTalkGibud_SetupTurnAwayAndShakeHead(EnTalkGibud* this); -void EnTalkGibud_TurnAwayAndShakeHead(EnTalkGibud* this, GlobalContext* globalCtx); +void EnTalkGibud_TurnAwayAndShakeHead(EnTalkGibud* this, PlayState* play); void EnTalkGibud_SetupWalkToHome(EnTalkGibud* this); -void EnTalkGibud_WalkToHome(EnTalkGibud* this, GlobalContext* globalCtx); -void EnTalkGibud_Stunned(EnTalkGibud* this, GlobalContext* globalCtx); +void EnTalkGibud_WalkToHome(EnTalkGibud* this, PlayState* play); +void EnTalkGibud_Stunned(EnTalkGibud* this, PlayState* play); void EnTalkGibud_SetupDamage(EnTalkGibud* this); -void EnTalkGibud_Damage(EnTalkGibud* this, GlobalContext* globalCtx); +void EnTalkGibud_Damage(EnTalkGibud* this, PlayState* play); void EnTalkGibud_SetupDead(EnTalkGibud* this); -void EnTalkGibud_Dead(EnTalkGibud* this, GlobalContext* globalCtx); +void EnTalkGibud_Dead(EnTalkGibud* this, PlayState* play); void EnTalkGibud_SetupRevive(EnTalkGibud* this); -void EnTalkGibud_Revive(EnTalkGibud* this, GlobalContext* globalCtx); -void EnTalkGibud_PassiveIdle(EnTalkGibud* this, GlobalContext* globalCtx); +void EnTalkGibud_Revive(EnTalkGibud* this, PlayState* play); +void EnTalkGibud_PassiveIdle(EnTalkGibud* this, PlayState* play); void EnTalkGibud_SetupTalk(EnTalkGibud* this); -void EnTalkGibud_Talk(EnTalkGibud* this, GlobalContext* globalCtx); +void EnTalkGibud_Talk(EnTalkGibud* this, PlayState* play); void EnTalkGibud_SetupDisappear(EnTalkGibud* this); -void EnTalkGibud_Disappear(EnTalkGibud* this, GlobalContext* globalCtx); -void EnTalkGibud_FacePlayerWhenTalking(EnTalkGibud* this, GlobalContext* globalCtx); -s32 EnTalkGibud_PlayerInRangeWithCorrectState(EnTalkGibud* this, GlobalContext* globalCtx); -s32 EnTalkGibud_PlayerOutOfRange(EnTalkGibud* this, GlobalContext* globalCtx); -void EnTalkGibud_TurnTowardsPlayer(EnTalkGibud* this, GlobalContext* globalCtx); -s32 EnTalkGibud_MoveToIdealGrabPositionAndRotation(EnTalkGibud* this, GlobalContext* globalCtx); +void EnTalkGibud_Disappear(EnTalkGibud* this, PlayState* play); +void EnTalkGibud_FacePlayerWhenTalking(EnTalkGibud* this, PlayState* play); +s32 EnTalkGibud_PlayerInRangeWithCorrectState(EnTalkGibud* this, PlayState* play); +s32 EnTalkGibud_PlayerOutOfRange(EnTalkGibud* this, PlayState* play); +void EnTalkGibud_TurnTowardsPlayer(EnTalkGibud* this, PlayState* play); +s32 EnTalkGibud_MoveToIdealGrabPositionAndRotation(EnTalkGibud* this, PlayState* play); typedef struct { /* 0x0 */ s32 itemActionParam; @@ -74,21 +75,21 @@ typedef enum { } 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; + /* 0 */ EN_TALK_GIBUD_ANIM_GRAB_ATTACK, + /* 1 */ EN_TALK_GIBUD_ANIM_GRAB_END, + /* 2 */ EN_TALK_GIBUD_ANIM_GRAB_START, + /* 3 */ EN_TALK_GIBUD_ANIM_LOOK_BACK, + /* 4 */ EN_TALK_GIBUD_ANIM_CROUCH_WIPING_TEARS, + /* 5 */ EN_TALK_GIBUD_ANIM_CROUCH_CRYING, + /* 6 */ EN_TALK_GIBUD_ANIM_DEATH, + /* 7 */ EN_TALK_GIBUD_ANIM_DAMAGE, + /* 8 */ EN_TALK_GIBUD_ANIM_CROUCH_END, + /* 9 */ EN_TALK_GIBUD_ANIM_IDLE, + /* 10 */ EN_TALK_GIBUD_ANIM_WALK, + /* 11 */ EN_TALK_GIBUD_ANIM_DANCE_SQUAT, + /* 12 */ EN_TALK_GIBUD_ANIM_DANCE_PIROUETTE, + /* 13 */ EN_TALK_GIBUD_ANIM_DANCE_CLAP, +} EnTalkGibudAnimation; typedef enum { /* 0 */ EN_TALK_GIBUD_TYPE_GIBDO, @@ -113,7 +114,7 @@ const ActorInit En_Talk_Gibud_InitVars = { (ActorFunc)EnTalkGibud_Draw, }; -static AnimationInfo sAnimations[] = { +static AnimationInfo sAnimationInfo[] = { { &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 }, @@ -221,7 +222,7 @@ static Vec3f sVelocity = { 0.0f, 0.0f, 0.0f }; static Vec3f sAccel = { 0.0f, 0.600000023842f, 0.0f }; -void EnTalkGibud_Init(Actor* thisx, GlobalContext* globalCtx) { +void EnTalkGibud_Init(Actor* thisx, PlayState* play) { s32 pad; EnTalkGibud* this = THIS; s32 i; @@ -232,10 +233,10 @@ void EnTalkGibud_Init(Actor* thisx, GlobalContext* globalCtx) { this->actor.textId = 0; ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 28.0f); - 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); + SkelAnime_InitFlex(play, &this->skelAnime, &gGibdoSkel, &gGibdoRedeadIdleAnim, this->jointTable, this->morphTable, + GIBDO_LIMB_MAX); + Collider_InitCylinder(play, &this->collider); + Collider_SetCylinder(play, &this->collider, &this->actor, &sCylinderInit); CollisionCheck_SetInfo2(&this->actor.colChkInfo, &sDamageTable, &sColChkInfoInit); this->playerStunWaitTimer = 0; @@ -267,21 +268,21 @@ void EnTalkGibud_Init(Actor* thisx, GlobalContext* globalCtx) { this->switchFlag = -1; } - if (this->switchFlag != -1 && Flags_GetSwitch(globalCtx, this->switchFlag)) { + if (this->switchFlag != -1 && Flags_GetSwitch(play, this->switchFlag)) { Actor_MarkForDeath(&this->actor); } EnTalkGibud_SetupIdle(this); } -void EnTalkGibud_Destroy(Actor* thisx, GlobalContext* globalCtx) { +void EnTalkGibud_Destroy(Actor* thisx, PlayState* play) { EnTalkGibud* this = THIS; - Collider_DestroyCylinder(globalCtx, &this->collider); + Collider_DestroyCylinder(play, &this->collider); } void EnTalkGibud_SetupIdle(EnTalkGibud* this) { - Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, EN_TALK_GIBUD_ANIMATION_IDLE); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, EN_TALK_GIBUD_ANIM_IDLE); this->actionFunc = EnTalkGibud_Idle; } @@ -289,8 +290,8 @@ void EnTalkGibud_SetupIdle(EnTalkGibud* this) { * This is the idle for when the player is not wearing the Gibdo Mask. The * Gibdo will attack the player if they get too close. */ -void EnTalkGibud_Idle(EnTalkGibud* this, GlobalContext* globalCtx) { - if (this->actor.xzDistToPlayer <= 150.0f && func_800B715C(globalCtx)) { +void EnTalkGibud_Idle(EnTalkGibud* this, PlayState* play) { + if (this->actor.xzDistToPlayer <= 150.0f && func_800B715C(play)) { EnTalkGibud_SetupAttemptPlayerFreeze(this); } @@ -299,28 +300,28 @@ void EnTalkGibud_Idle(EnTalkGibud* this, GlobalContext* globalCtx) { } void EnTalkGibud_SetupAttemptPlayerFreeze(EnTalkGibud* this) { - Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, EN_TALK_GIBUD_ANIMATION_IDLE); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, EN_TALK_GIBUD_ANIM_IDLE); this->actionFunc = EnTalkGibud_AttemptPlayerFreeze; } -void EnTalkGibud_AttemptPlayerFreeze(EnTalkGibud* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); +void EnTalkGibud_AttemptPlayerFreeze(EnTalkGibud* this, PlayState* play) { + Player* player = GET_PLAYER(play); 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) { player->actor.freezeTimer = 60; - func_8013ECE0(this->actor.xzDistToPlayer, 255, 20, 150); - func_80123E90(globalCtx, &this->actor); + Rumble_Request(this->actor.xzDistToPlayer, 255, 20, 150); + func_80123E90(play, &this->actor); Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_REDEAD_AIM); EnTalkGibud_SetupWalkToPlayer(this); } - EnTalkGibud_TurnTowardsPlayer(this, globalCtx); + EnTalkGibud_TurnTowardsPlayer(this, play); } void EnTalkGibud_SetupWalkToPlayer(EnTalkGibud* this) { - Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, EN_TALK_GIBUD_ANIMATION_WALK); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, EN_TALK_GIBUD_ANIM_WALK); this->actor.speedXZ = 0.4f; if (this->actionFunc == EnTalkGibud_AttemptPlayerFreeze) { @@ -332,8 +333,8 @@ void EnTalkGibud_SetupWalkToPlayer(EnTalkGibud* this) { this->actionFunc = EnTalkGibud_WalkToPlayer; } -void EnTalkGibud_WalkToPlayer(EnTalkGibud* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); +void EnTalkGibud_WalkToPlayer(EnTalkGibud* this, PlayState* play) { + Player* player = GET_PLAYER(play); s32 pad; Math_ScaledStepToS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer, 0xFA); @@ -341,22 +342,22 @@ void EnTalkGibud_WalkToPlayer(EnTalkGibud* this, GlobalContext* globalCtx) { 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 (EnTalkGibud_PlayerInRangeWithCorrectState(this, play) && Actor_IsFacingPlayer(&this->actor, 0x38E3)) { if ((this->grabWaitTimer == 0) && (this->actor.xzDistToPlayer <= 45.0f)) { player->actor.freezeTimer = 0; if (gSaveContext.save.playerForm == PLAYER_FORM_GORON || gSaveContext.save.playerForm == PLAYER_FORM_DEKU) { // If the Gibdo/Redead tries to grab Goron or Deku Link, it will fail to // do so. It will appear to take damage and shake its head side-to-side. EnTalkGibud_SetupGrabFail(this); - } else if (globalCtx->grabPlayer(globalCtx, player)) { + } else if (play->grabPlayer(play, player)) { EnTalkGibud_SetupGrab(this); } } else { if (this->playerStunWaitTimer == 0) { player->actor.freezeTimer = 40; this->playerStunWaitTimer = 60; - func_8013ECE0(this->actor.xzDistToPlayer, 255, 20, 150); - func_80123E90(globalCtx, &this->actor); + Rumble_Request(this->actor.xzDistToPlayer, 255, 20, 150); + func_80123E90(play, &this->actor); Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_REDEAD_AIM); } else { this->playerStunWaitTimer--; @@ -364,7 +365,7 @@ void EnTalkGibud_WalkToPlayer(EnTalkGibud* this, GlobalContext* globalCtx) { } } else if ((this->grabWaitTimer == 0) && (this->actor.xzDistToPlayer <= 45.0f)) { EnTalkGibud_SetupWalkToHome(this); - } else if (EnTalkGibud_PlayerOutOfRange(this, globalCtx)) { + } else if (EnTalkGibud_PlayerOutOfRange(this, play)) { EnTalkGibud_SetupWalkToHome(this); } @@ -374,31 +375,31 @@ void EnTalkGibud_WalkToPlayer(EnTalkGibud* this, GlobalContext* globalCtx) { 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)) { + } else if (!(play->gameplayFrames & 95)) { Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_REDEAD_CRY); } } void EnTalkGibud_SetupGrab(EnTalkGibud* this) { - Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, EN_TALK_GIBUD_ANIMATION_GRAB_START); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, EN_TALK_GIBUD_ANIM_GRAB_START); this->grabDamageTimer = 0; this->actor.flags &= ~ACTOR_FLAG_1; this->grabState = EN_TALK_GIBUD_GRAB_START; this->actionFunc = EnTalkGibud_Grab; } -void EnTalkGibud_Grab(EnTalkGibud* this, GlobalContext* globalCtx) { - Player* player2 = GET_PLAYER(globalCtx); +void EnTalkGibud_Grab(EnTalkGibud* this, PlayState* play) { + Player* player2 = GET_PLAYER(play); Player* player = player2; s32 inPositionToAttack; u16 damageSfxId; switch (this->grabState) { case EN_TALK_GIBUD_GRAB_START: - inPositionToAttack = EnTalkGibud_MoveToIdealGrabPositionAndRotation(this, globalCtx); + inPositionToAttack = EnTalkGibud_MoveToIdealGrabPositionAndRotation(this, play); if (Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame) && (inPositionToAttack == true)) { this->grabState = EN_TALK_GIBUD_GRAB_ATTACK; - Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, EN_TALK_GIBUD_ANIMATION_GRAB_ATTACK); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, EN_TALK_GIBUD_ANIM_GRAB_ATTACK); } break; @@ -407,9 +408,9 @@ void EnTalkGibud_Grab(EnTalkGibud* this, GlobalContext* globalCtx) { s16 requiredScopeTemp; damageSfxId = player->ageProperties->unk_92 + NA_SE_VO_LI_DAMAGE_S; - globalCtx->damagePlayer(globalCtx, -8); + play->damagePlayer(play, -8); func_800B8E58(player, damageSfxId); - func_8013ECE0(this->actor.xzDistToPlayer, 240, 1, 12); + Rumble_Request(this->actor.xzDistToPlayer, 240, 1, 12); this->grabDamageTimer = 0; } else { this->grabDamageTimer++; @@ -425,7 +426,7 @@ void EnTalkGibud_Grab(EnTalkGibud* this, GlobalContext* globalCtx) { player->unk_AE8 = 100; } - Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, EN_TALK_GIBUD_ANIMATION_GRAB_END); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, EN_TALK_GIBUD_ANIM_GRAB_END); this->actor.flags |= ACTOR_FLAG_1; this->grabState = EN_TALK_GIBUD_GRAB_RELEASE; this->grabDamageTimer = 0; @@ -445,13 +446,13 @@ void EnTalkGibud_Grab(EnTalkGibud* this, GlobalContext* globalCtx) { } void EnTalkGibud_SetupGrabFail(EnTalkGibud* this) { - Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, EN_TALK_GIBUD_ANIMATION_DAMAGE); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, EN_TALK_GIBUD_ANIM_DAMAGE); Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_REDEAD_DAMAGE); this->actor.speedXZ = -2.0f; this->actionFunc = EnTalkGibud_GrabFail; } -void EnTalkGibud_GrabFail(EnTalkGibud* this, GlobalContext* globalCtx) { +void EnTalkGibud_GrabFail(EnTalkGibud* this, PlayState* play) { if (this->actor.speedXZ < 0.0f) { this->actor.speedXZ += 0.15f; } @@ -467,11 +468,11 @@ void EnTalkGibud_GrabFail(EnTalkGibud* this, GlobalContext* globalCtx) { void EnTalkGibud_SetupTurnAwayAndShakeHead(EnTalkGibud* this) { this->headShakeTimer = 0; - Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, EN_TALK_GIBUD_ANIMATION_WALK); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, EN_TALK_GIBUD_ANIM_WALK); this->actionFunc = EnTalkGibud_TurnAwayAndShakeHead; } -void EnTalkGibud_TurnAwayAndShakeHead(EnTalkGibud* this, GlobalContext* globalCtx) { +void EnTalkGibud_TurnAwayAndShakeHead(EnTalkGibud* this, PlayState* play) { Math_SmoothStepToS(&this->actor.world.rot.y, BINANG_ROT180(this->actor.yawTowardsPlayer), 5, 3500, 200); this->actor.shape.rot.y = this->actor.world.rot.y; if (this->headShakeTimer > 60) { @@ -485,12 +486,12 @@ void EnTalkGibud_TurnAwayAndShakeHead(EnTalkGibud* this, GlobalContext* globalCt } void EnTalkGibud_SetupWalkToHome(EnTalkGibud* this) { - Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, EN_TALK_GIBUD_ANIMATION_WALK); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, EN_TALK_GIBUD_ANIM_WALK); this->actor.speedXZ = 0.4f; this->actionFunc = EnTalkGibud_WalkToHome; } -void EnTalkGibud_WalkToHome(EnTalkGibud* this, GlobalContext* globalCtx) { +void EnTalkGibud_WalkToHome(EnTalkGibud* this, PlayState* play) { Math_SmoothStepToS(&this->headRotation.y, 0, 1, 100, 0); Math_SmoothStepToS(&this->upperBodyRotation.y, 0, 1, 100, 0); if (Actor_XZDistanceToPoint(&this->actor, &this->actor.home.pos) < 5.0f) { @@ -509,7 +510,7 @@ void EnTalkGibud_WalkToHome(EnTalkGibud* this, GlobalContext* globalCtx) { Math_ScaledStepToS(&this->actor.shape.rot.y, Actor_YawToPoint(&this->actor, &this->actor.home.pos), 450); this->actor.world.rot = this->actor.shape.rot; } - if (EnTalkGibud_PlayerInRangeWithCorrectState(this, globalCtx)) { + if (EnTalkGibud_PlayerInRangeWithCorrectState(this, play)) { if (gSaveContext.save.playerForm != PLAYER_FORM_GORON && gSaveContext.save.playerForm != PLAYER_FORM_DEKU && Actor_IsFacingPlayer(&this->actor, 0x38E3)) { EnTalkGibud_SetupWalkToPlayer(this); @@ -531,7 +532,7 @@ void EnTalkGibud_SetupStunned(EnTalkGibud* this) { this->actionFunc = EnTalkGibud_Stunned; } -void EnTalkGibud_Stunned(EnTalkGibud* this, GlobalContext* globalCtx) { +void EnTalkGibud_Stunned(EnTalkGibud* this, PlayState* play) { if (this->actor.colorFilterTimer == 0) { if (this->actor.colChkInfo.health == 0) { EnTalkGibud_SetupDead(this); @@ -546,7 +547,7 @@ void EnTalkGibud_Stunned(EnTalkGibud* this, GlobalContext* globalCtx) { } void EnTalkGibud_SetupDamage(EnTalkGibud* this) { - Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, EN_TALK_GIBUD_ANIMATION_DAMAGE); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, EN_TALK_GIBUD_ANIM_DAMAGE); Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_REDEAD_DAMAGE); this->stunTimer = 0; this->grabWaitTimer = 0; @@ -555,7 +556,7 @@ void EnTalkGibud_SetupDamage(EnTalkGibud* this) { this->actionFunc = EnTalkGibud_Damage; } -void EnTalkGibud_Damage(EnTalkGibud* this, GlobalContext* globalCtx) { +void EnTalkGibud_Damage(EnTalkGibud* this, PlayState* play) { if (this->actor.speedXZ < 0.0f) { this->actor.speedXZ += 0.15f; } @@ -568,12 +569,12 @@ void EnTalkGibud_Damage(EnTalkGibud* this, GlobalContext* globalCtx) { this->actor.hintId = 0x2A; 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, + SkelAnime_InitFlex(play, &this->skelAnime, &gRedeadSkel, NULL, this->jointTable, this->morphTable, GIBDO_LIMB_MAX); this->type = EN_TALK_GIBUD_TYPE_REDEAD; } - if (EnTalkGibud_PlayerOutOfRange(this, globalCtx)) { + if (EnTalkGibud_PlayerOutOfRange(this, play)) { EnTalkGibud_SetupWalkToHome(this); } else { EnTalkGibud_SetupWalkToPlayer(this); @@ -582,14 +583,14 @@ void EnTalkGibud_Damage(EnTalkGibud* this, GlobalContext* globalCtx) { } void EnTalkGibud_SetupDead(EnTalkGibud* this) { - Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, EN_TALK_GIBUD_ANIMATION_DEATH); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, EN_TALK_GIBUD_ANIM_DEATH); this->actor.flags &= ~ACTOR_FLAG_1; Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_REDEAD_DEAD); this->deathTimer = 0; this->actionFunc = EnTalkGibud_Dead; } -void EnTalkGibud_Dead(EnTalkGibud* this, GlobalContext* globalCtx) { +void EnTalkGibud_Dead(EnTalkGibud* this, PlayState* play) { if (this->deathTimer > 300) { EnTalkGibud_SetupRevive(this); } else { @@ -600,7 +601,7 @@ void EnTalkGibud_Dead(EnTalkGibud* this, GlobalContext* globalCtx) { 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, + SkelAnime_InitFlex(play, &this->skelAnime, &gRedeadSkel, NULL, this->jointTable, this->morphTable, GIBDO_LIMB_MAX); this->type = EN_TALK_GIBUD_TYPE_REDEAD; } @@ -608,7 +609,7 @@ void EnTalkGibud_Dead(EnTalkGibud* this, GlobalContext* globalCtx) { void EnTalkGibud_SetupRevive(EnTalkGibud* this) { Animation_Change(&this->skelAnime, &gGibdoRedeadDeathAnim, -1.0f, Animation_GetLastFrame(&gGibdoRedeadDeathAnim), - 0.0f, 2, -8.0f); + 0.0f, ANIMMODE_ONCE, -8.0f); this->actor.flags |= ACTOR_FLAG_1; Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_REDEAD_REVERSE); this->deathTimer = 0; @@ -616,72 +617,72 @@ void EnTalkGibud_SetupRevive(EnTalkGibud* this) { this->actionFunc = EnTalkGibud_Revive; } -void EnTalkGibud_Revive(EnTalkGibud* this, GlobalContext* globalCtx) { +void EnTalkGibud_Revive(EnTalkGibud* this, PlayState* play) { if (Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) { this->actor.colChkInfo.health = 8; EnTalkGibud_SetupIdle(this); } } -void EnTalkGibud_GetTextIdForRequestedItem(EnTalkGibud* this, GlobalContext* globalCtx) { +void EnTalkGibud_GetTextIdForRequestedItem(EnTalkGibud* this, PlayState* play) { switch (this->requestedItemIndex) { case EN_TALK_GIBUD_REQUESTED_ITEM_INDEX_BLUE_POTION: - Message_StartTextbox(globalCtx, 0x138C, &this->actor); + Message_StartTextbox(play, 0x138C, &this->actor); this->textId = 0x138C; break; case EN_TALK_GIBUD_REQUESTED_ITEM_INDEX_BEANS: - Message_StartTextbox(globalCtx, 0x138D, &this->actor); + Message_StartTextbox(play, 0x138D, &this->actor); this->textId = 0x138D; break; case EN_TALK_GIBUD_REQUESTED_ITEM_INDEX_SPRING_WATER: - Message_StartTextbox(globalCtx, 0x138E, &this->actor); + Message_StartTextbox(play, 0x138E, &this->actor); this->textId = 0x138E; break; case EN_TALK_GIBUD_REQUESTED_ITEM_INDEX_FISH: - Message_StartTextbox(globalCtx, 0x138F, &this->actor); + Message_StartTextbox(play, 0x138F, &this->actor); this->textId = 0x138F; break; case EN_TALK_GIBUD_REQUESTED_ITEM_INDEX_BUGS: - Message_StartTextbox(globalCtx, 0x1390, &this->actor); + Message_StartTextbox(play, 0x1390, &this->actor); this->textId = 0x1390; break; case EN_TALK_GIBUD_REQUESTED_ITEM_INDEX_DEKU_NUTS: - Message_StartTextbox(globalCtx, 0x1391, &this->actor); + Message_StartTextbox(play, 0x1391, &this->actor); this->textId = 0x1391; break; case EN_TALK_GIBUD_REQUESTED_ITEM_INDEX_BOMBS: - Message_StartTextbox(globalCtx, 0x1392, &this->actor); + Message_StartTextbox(play, 0x1392, &this->actor); this->textId = 0x1392; break; case EN_TALK_GIBUD_REQUESTED_ITEM_INDEX_HOT_SPRING_WATER: - Message_StartTextbox(globalCtx, 0x1393, &this->actor); + Message_StartTextbox(play, 0x1393, &this->actor); this->textId = 0x1393; break; case EN_TALK_GIBUD_REQUESTED_ITEM_INDEX_BIG_POE: - Message_StartTextbox(globalCtx, 0x1394, &this->actor); + Message_StartTextbox(play, 0x1394, &this->actor); this->textId = 0x1394; break; case EN_TALK_GIBUD_REQUESTED_ITEM_INDEX_MILK: - Message_StartTextbox(globalCtx, 0x1395, &this->actor); + Message_StartTextbox(play, 0x1395, &this->actor); this->textId = 0x1395; break; } } -void EnTalkGibud_GetNextTextBoxId(EnTalkGibud* this, GlobalContext* globalCtx) { - if (Message_ShouldAdvance(globalCtx)) { +void EnTalkGibud_GetNextTextBoxId(EnTalkGibud* this, PlayState* play) { + if (Message_ShouldAdvance(play)) { switch (this->textId) { case 0x1388: - EnTalkGibud_GetTextIdForRequestedItem(this, globalCtx); + EnTalkGibud_GetTextIdForRequestedItem(this, play); break; case 0x138C: @@ -695,14 +696,14 @@ void EnTalkGibud_GetNextTextBoxId(EnTalkGibud* this, GlobalContext* globalCtx) { case 0x1394: case 0x1395: // Prompts the player to choose an item - Message_StartTextbox(globalCtx, 0xFF, &this->actor); + Message_StartTextbox(play, 0xFF, &this->actor); this->textId = 0xFF; break; } } } -s32 EnTalkGibud_PresentedItemMatchesRequest(EnTalkGibud* this, GlobalContext* globalCtx, s32 presentedItemActionParam) { +s32 EnTalkGibud_PresentedItemMatchesRequest(EnTalkGibud* this, PlayState* play, s32 presentedItemActionParam) { EnTalkGibudRequestedItem* requestedItem = &sRequestedItemTable[this->requestedItemIndex]; if (requestedItem->itemActionParam == presentedItemActionParam) { @@ -713,24 +714,24 @@ s32 EnTalkGibud_PresentedItemMatchesRequest(EnTalkGibud* this, GlobalContext* gl return EN_TALK_GIBUD_REQUESTED_ITEM_NOT_ENOUGH_AMMO; } } - if (Interface_HasItemInBottle(requestedItem->item)) { + if (Inventory_HasItemInBottle(requestedItem->item)) { return EN_TALK_GIBUD_REQUESTED_ITEM_MET; } } return EN_TALK_GIBUD_REQUESTED_ITEM_NOT_MET; } -void EnTalkGibud_CheckPresentedItem(EnTalkGibud* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); +void EnTalkGibud_CheckPresentedItem(EnTalkGibud* this, PlayState* play) { + Player* player = GET_PLAYER(play); s32 itemActionParam; if (this->itemActionParam == PLAYER_AP_NONE) { - itemActionParam = func_80123810(globalCtx); + itemActionParam = func_80123810(play); if (itemActionParam != PLAYER_AP_NONE) { this->itemActionParam = itemActionParam; } if (this->itemActionParam > PLAYER_AP_NONE) { - switch (EnTalkGibud_PresentedItemMatchesRequest(this, globalCtx, this->itemActionParam)) { + switch (EnTalkGibud_PresentedItemMatchesRequest(this, play, this->itemActionParam)) { case EN_TALK_GIBUD_REQUESTED_ITEM_MET: player->actor.textId = 0x138A; this->textId = 0x138A; @@ -749,9 +750,9 @@ void EnTalkGibud_CheckPresentedItem(EnTalkGibud* this, GlobalContext* globalCtx) default: break; } - func_801477B4(globalCtx); + func_801477B4(play); } else if (this->itemActionParam < PLAYER_AP_NONE) { - Message_StartTextbox(globalCtx, 0x1389, &this->actor); + Message_StartTextbox(play, 0x1389, &this->actor); this->textId = 0x1389; } } @@ -760,7 +761,7 @@ void EnTalkGibud_CheckPresentedItem(EnTalkGibud* this, GlobalContext* globalCtx) void EnTalkGibud_SetupPassiveIdle(EnTalkGibud* this) { this->isTalking = false; if (this->actionFunc != EnTalkGibud_Talk) { - Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, EN_TALK_GIBUD_ANIMATION_IDLE); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, EN_TALK_GIBUD_ANIM_IDLE); } this->actionFunc = EnTalkGibud_PassiveIdle; } @@ -769,16 +770,16 @@ void EnTalkGibud_SetupPassiveIdle(EnTalkGibud* this) { * This is the idle for when the player is wearing the Gibdo Mask. The * Gibdo will not attempt to attack the player and can be spoken to. */ -void EnTalkGibud_PassiveIdle(EnTalkGibud* this, GlobalContext* globalCtx) { - if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { +void EnTalkGibud_PassiveIdle(EnTalkGibud* this, PlayState* play) { + if (Actor_ProcessTalkRequest(&this->actor, &play->state)) { this->isTalking = true; - Message_StartTextbox(globalCtx, 0x1388, &this->actor); + Message_StartTextbox(play, 0x1388, &this->actor); this->textId = 0x1388; Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_REDEAD_AIM); EnTalkGibud_SetupTalk(this); } else if (this->actor.xzDistToPlayer < 100.0f && !(this->collider.base.acFlags & AC_HIT)) { - func_800E9250(globalCtx, &this->actor, &this->headRotation, &this->upperBodyRotation, this->actor.focus.pos); - func_800B8614(&this->actor, globalCtx, 100.0f); + Actor_TrackPlayer(play, &this->actor, &this->headRotation, &this->upperBodyRotation, this->actor.focus.pos); + func_800B8614(&this->actor, play, 100.0f); } else { Math_SmoothStepToS(&this->headRotation.y, 0, 1, 100, 0); Math_SmoothStepToS(&this->upperBodyRotation.y, 0, 1, 100, 0); @@ -790,38 +791,38 @@ void EnTalkGibud_SetupTalk(EnTalkGibud* this) { this->actionFunc = EnTalkGibud_Talk; } -void EnTalkGibud_Talk(EnTalkGibud* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); +void EnTalkGibud_Talk(EnTalkGibud* this, PlayState* play) { + Player* player = GET_PLAYER(play); EnTalkGibudRequestedItem* requestedItem; - switch (Message_GetState(&globalCtx->msgCtx)) { - case 0: - case 1: - case 2: - case 3: - case 4: - case 7: - case 8: - case 9: - case 10: - case 11: - case 12: - case 13: + switch (Message_GetState(&play->msgCtx)) { + case TEXT_STATE_NONE: + case TEXT_STATE_1: + case TEXT_STATE_CLOSING: + case TEXT_STATE_3: + case TEXT_STATE_CHOICE: + case TEXT_STATE_7: + case TEXT_STATE_8: + case TEXT_STATE_9: + case TEXT_STATE_10: + case TEXT_STATE_11: + case TEXT_STATE_12: + case TEXT_STATE_13: break; - case 5: - EnTalkGibud_GetNextTextBoxId(this, globalCtx); + case TEXT_STATE_5: + EnTalkGibud_GetNextTextBoxId(this, play); break; - case 6: - if (Message_ShouldAdvance(globalCtx)) { + case TEXT_STATE_DONE: + if (Message_ShouldAdvance(play)) { if (this->textId == 0x138A) { // Remove the requested item/amount from the player's inventory requestedItem = &sRequestedItemTable[this->requestedItemIndex]; if (!requestedItem->isBottledItem) { - func_80115A14(requestedItem->item, -requestedItem->amount); + Inventory_ChangeAmmo(requestedItem->item, -requestedItem->amount); } else { - func_80123D50(globalCtx, player, ITEM_BOTTLE, PLAYER_AP_BOTTLE); + func_80123D50(play, player, ITEM_BOTTLE, PLAYER_AP_BOTTLE); } player->stateFlags1 |= 0x20; player->stateFlags1 |= 0x20000000; @@ -833,22 +834,22 @@ void EnTalkGibud_Talk(EnTalkGibud* this, GlobalContext* globalCtx) { } break; - case 16: - EnTalkGibud_CheckPresentedItem(this, globalCtx); + case TEXT_STATE_16: + EnTalkGibud_CheckPresentedItem(this, play); break; } - EnTalkGibud_FacePlayerWhenTalking(this, globalCtx); + EnTalkGibud_FacePlayerWhenTalking(this, play); } void EnTalkGibud_SetupDisappear(EnTalkGibud* this) { - Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, EN_TALK_GIBUD_ANIMATION_IDLE); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, EN_TALK_GIBUD_ANIM_IDLE); this->actor.flags &= ~ACTOR_FLAG_1; this->disappearanceTimer = 40; this->actionFunc = EnTalkGibud_Disappear; } -void EnTalkGibud_Disappear(EnTalkGibud* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); +void EnTalkGibud_Disappear(EnTalkGibud* this, PlayState* play) { + Player* player = GET_PLAYER(play); Vec3f velocity = sVelocity; Vec3f accel = sAccel; Vec3f pos; @@ -864,14 +865,14 @@ void EnTalkGibud_Disappear(EnTalkGibud* this, GlobalContext* globalCtx) { pos.z += Rand_Centered() * 20.0f; velocity.x += Rand_Centered() * 1.5f; velocity.z += Rand_Centered() * 1.5f; - func_800B3030(globalCtx, &pos, &velocity, &accel, 100, 0, 1); + func_800B3030(play, &pos, &velocity, &accel, 100, 0, 1); } func_800B9010(&this->actor, NA_SE_EN_COMMON_EXTINCT_LEV - SFX_FLAG); player->stateFlags1 |= 0x20000000; this->disappearanceTimer--; } else { if (this->switchFlag != -1) { - Flags_SetSwitch(globalCtx, this->switchFlag); + Flags_SetSwitch(play, this->switchFlag); } player->stateFlags1 &= ~0x20; player->stateFlags1 &= ~0x20000000; @@ -879,7 +880,7 @@ void EnTalkGibud_Disappear(EnTalkGibud* this, GlobalContext* globalCtx) { } } -void EnTalkGibud_FacePlayerWhenTalking(EnTalkGibud* this, GlobalContext* globalCtx) { +void EnTalkGibud_FacePlayerWhenTalking(EnTalkGibud* this, PlayState* play) { s16 target = this->actor.yawTowardsPlayer; Math_ScaledStepToS(&this->actor.shape.rot.y, target, 0x320); @@ -890,8 +891,8 @@ void EnTalkGibud_FacePlayerWhenTalking(EnTalkGibud* this, GlobalContext* globalC Math_ScaledStepToS(&this->headRotation.y, target, 0x190); } -s32 EnTalkGibud_PlayerInRangeWithCorrectState(EnTalkGibud* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); +s32 EnTalkGibud_PlayerInRangeWithCorrectState(EnTalkGibud* this, PlayState* play) { + Player* player = GET_PLAYER(play); if ((Actor_DistanceToPoint(&player->actor, &this->actor.home.pos) < 150.0f) && !(player->stateFlags1 & (0x200000 | 0x80000 | 0x40000 | 0x4000 | 0x2000 | 0x80)) && @@ -907,8 +908,8 @@ s32 EnTalkGibud_PlayerInRangeWithCorrectState(EnTalkGibud* this, GlobalContext* * engage with the player. If the player is out of this range, they will simply * walk back to their home. */ -s32 EnTalkGibud_PlayerOutOfRange(EnTalkGibud* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); +s32 EnTalkGibud_PlayerOutOfRange(EnTalkGibud* this, PlayState* play) { + Player* player = GET_PLAYER(play); if (Actor_DistanceToPoint(&player->actor, &this->actor.home.pos) >= 150.0f) { return true; @@ -917,19 +918,19 @@ s32 EnTalkGibud_PlayerOutOfRange(EnTalkGibud* this, GlobalContext* globalCtx) { return false; } -void EnTalkGibud_CheckForGibdoMask(EnTalkGibud* this, GlobalContext* globalCtx) { +void EnTalkGibud_CheckForGibdoMask(EnTalkGibud* this, PlayState* play) { 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) { + if (Player_GetMask(play) == PLAYER_MASK_GIBDO) { 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) { + } else if (Player_GetMask(play) != PLAYER_MASK_GIBDO) { 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) { @@ -943,7 +944,7 @@ void EnTalkGibud_CheckForGibdoMask(EnTalkGibud* this, GlobalContext* globalCtx) } } -void EnTalkGibud_TurnTowardsPlayer(EnTalkGibud* this, GlobalContext* globalCtx) { +void EnTalkGibud_TurnTowardsPlayer(EnTalkGibud* this, PlayState* play) { s16 headAngle = (this->actor.yawTowardsPlayer - this->actor.shape.rot.y) - this->upperBodyRotation.y; s16 upperBodyAngle = CLAMP(headAngle, -500, 500); @@ -967,8 +968,8 @@ void EnTalkGibud_TurnTowardsPlayer(EnTalkGibud* this, GlobalContext* globalCtx) * performing its grab attack. Regardless of what this returns, the Gibdo is * moved closer to this ideal position and rotation. */ -s32 EnTalkGibud_MoveToIdealGrabPositionAndRotation(EnTalkGibud* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); +s32 EnTalkGibud_MoveToIdealGrabPositionAndRotation(EnTalkGibud* this, PlayState* play) { + Player* player = GET_PLAYER(play); Vec3f targetPos; f32 distanceFromTargetPos; f32 distanceFromTargetYOffset = 0.0f; @@ -992,21 +993,21 @@ s32 EnTalkGibud_MoveToIdealGrabPositionAndRotation(EnTalkGibud* this, GlobalCont return false; } -void EnTalkGibud_PlayAnimation(EnTalkGibud* this, GlobalContext* globalCtx) { +void EnTalkGibud_PlayAnimation(EnTalkGibud* this, PlayState* play) { if (this->actionFunc != EnTalkGibud_Stunned) { SkelAnime_Update(&this->skelAnime); } } -void EnTalkGibud_MoveWithGravity(EnTalkGibud* this, GlobalContext* globalCtx) { +void EnTalkGibud_MoveWithGravity(EnTalkGibud* this, PlayState* play) { if ((this->actionFunc == EnTalkGibud_WalkToPlayer) || (this->actionFunc == EnTalkGibud_WalkToHome) || (this->actionFunc == EnTalkGibud_Damage)) { Actor_MoveWithGravity(&this->actor); } } -void EnTalkGibud_UpdateDamage(EnTalkGibud* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); +void EnTalkGibud_UpdateDamage(EnTalkGibud* this, PlayState* play) { + Player* player = GET_PLAYER(play); if (this->collider.base.acFlags & AC_HIT) { this->collider.base.acFlags &= ~AC_HIT; @@ -1077,19 +1078,19 @@ void EnTalkGibud_UpdateDamage(EnTalkGibud* this, GlobalContext* globalCtx) { } } -void EnTalkGibud_UpdateCollision(EnTalkGibud* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); +void EnTalkGibud_UpdateCollision(EnTalkGibud* this, PlayState* play) { + Player* player = GET_PLAYER(play); 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); + CollisionCheck_SetOC(play, &play->colChkCtx, &this->collider.base); if (((this->actionFunc != EnTalkGibud_Damage) || ((player->unk_ADC != 0) && (player->unk_ADD != this->unk_3F7))) && ((this->actionFunc != EnTalkGibud_Stunned) || (this->stunTimer == 0))) { - CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + CollisionCheck_SetAC(play, &play->colChkCtx, &this->collider.base); } } } @@ -1103,11 +1104,11 @@ void EnTalkGibud_UpdateCollision(EnTalkGibud* this, GlobalContext* globalCtx) { * the player like this will help prevent the Gibdo from looking like it's * clipping into the wall as it grabs onto the player. */ -void EnTalkGibud_MoveGrabbedPlayerAwayFromWall(EnTalkGibud* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); +void EnTalkGibud_MoveGrabbedPlayerAwayFromWall(EnTalkGibud* this, PlayState* play) { + Player* player = GET_PLAYER(play); Vec3f targetPos; - Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 30.0f, 20.0f, 35.0f, 29); + Actor_UpdateBgCheckInfo(play, &this->actor, 30.0f, 20.0f, 35.0f, 29); if (this->actionFunc == EnTalkGibud_Grab && this->grabState == EN_TALK_GIBUD_GRAB_START && (this->actor.bgCheckFlags & 8)) { targetPos = player->actor.world.pos; @@ -1117,7 +1118,7 @@ void EnTalkGibud_MoveGrabbedPlayerAwayFromWall(EnTalkGibud* this, GlobalContext* } } -void EnTalkGibud_UpdateEffect(EnTalkGibud* this, GlobalContext* globalCtx) { +void EnTalkGibud_UpdateEffect(EnTalkGibud* this, PlayState* play) { if (this->drawDmgEffTimer > 0) { this->drawDmgEffTimer--; } @@ -1130,26 +1131,26 @@ void EnTalkGibud_UpdateEffect(EnTalkGibud* this, GlobalContext* globalCtx) { } } -void EnTalkGibud_Update(Actor* thisx, GlobalContext* globalCtx) { +void EnTalkGibud_Update(Actor* thisx, PlayState* play) { EnTalkGibud* this = THIS; - EnTalkGibud_CheckForGibdoMask(this, globalCtx); - EnTalkGibud_UpdateDamage(this, globalCtx); + EnTalkGibud_CheckForGibdoMask(this, play); + EnTalkGibud_UpdateDamage(this, play); - this->actionFunc(this, globalCtx); + this->actionFunc(this, play); - EnTalkGibud_PlayAnimation(this, globalCtx); - EnTalkGibud_MoveWithGravity(this, globalCtx); - EnTalkGibud_UpdateCollision(this, globalCtx); - EnTalkGibud_MoveGrabbedPlayerAwayFromWall(this, globalCtx); - EnTalkGibud_UpdateEffect(this, globalCtx); + EnTalkGibud_PlayAnimation(this, play); + EnTalkGibud_MoveWithGravity(this, play); + EnTalkGibud_UpdateCollision(this, play); + EnTalkGibud_MoveGrabbedPlayerAwayFromWall(this, play); + EnTalkGibud_UpdateEffect(this, play); this->actor.focus.pos = this->actor.world.pos; this->actor.focus.pos.y += 50.0f; } -s32 EnTalkGibud_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, - Actor* thisx, Gfx** gfx) { +s32 EnTalkGibud_OverrideLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, Actor* thisx, + Gfx** gfx) { EnTalkGibud* this = THIS; if (limbIndex == GIBDO_LIMB_UPPER_BODY_ROOT) { @@ -1161,8 +1162,7 @@ s32 EnTalkGibud_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** return false; } -void EnTalkGibud_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx, - Gfx** gfx) { +void EnTalkGibud_PostLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx, Gfx** gfx) { EnTalkGibud* this = THIS; if ((this->drawDmgEffTimer != 0) && @@ -1173,41 +1173,41 @@ void EnTalkGibud_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dLi (limbIndex == GIBDO_LIMB_LEFT_FOREARM) || (limbIndex == GIBDO_LIMB_LEFT_HAND) || (limbIndex == GIBDO_LIMB_RIGHT_SHOULDER_AND_UPPER_ARM) || (limbIndex == GIBDO_LIMB_RIGHT_FOREARM) || (limbIndex == GIBDO_LIMB_RIGHT_HAND) || (limbIndex == GIBDO_LIMB_HEAD) || (limbIndex == GIBDO_LIMB_PELVIS))) { - Matrix_GetStateTranslation(&this->limbPos[this->limbIndex]); + Matrix_MultZero(&this->limbPos[this->limbIndex]); this->limbIndex++; } } -void EnTalkGibud_Draw(Actor* thisx, GlobalContext* globalCtx) { +void EnTalkGibud_Draw(Actor* thisx, PlayState* play) { EnTalkGibud* this = THIS; - OPEN_DISPS(globalCtx->state.gfxCtx); + OPEN_DISPS(play->state.gfxCtx); this->limbIndex = 0; if (this->actor.shape.shadowAlpha == 255) { - func_8012C28C(globalCtx->state.gfxCtx); + func_8012C28C(play->state.gfxCtx); gDPSetEnvColor(POLY_OPA_DISP++, 0, 0, 0, this->actor.shape.shadowAlpha); gSPSegment(POLY_OPA_DISP++, 0x08, D_801AEFA0); - POLY_OPA_DISP = SkelAnime_DrawFlex(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, - this->skelAnime.dListCount, EnTalkGibud_OverrideLimbDraw, - EnTalkGibud_PostLimbDraw, &this->actor, POLY_OPA_DISP); + POLY_OPA_DISP = + SkelAnime_DrawFlex(play, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, + EnTalkGibud_OverrideLimbDraw, EnTalkGibud_PostLimbDraw, &this->actor, POLY_OPA_DISP); } else { - func_8012C2DC(globalCtx->state.gfxCtx); + func_8012C2DC(play->state.gfxCtx); gDPSetEnvColor(POLY_XLU_DISP++, 0, 0, 0, this->actor.shape.shadowAlpha); gSPSegment(POLY_XLU_DISP++, 0x08, D_801AEF88); - POLY_XLU_DISP = SkelAnime_DrawFlex(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, - this->skelAnime.dListCount, EnTalkGibud_OverrideLimbDraw, - EnTalkGibud_PostLimbDraw, &this->actor, POLY_XLU_DISP); + POLY_XLU_DISP = + SkelAnime_DrawFlex(play, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, + EnTalkGibud_OverrideLimbDraw, EnTalkGibud_PostLimbDraw, &this->actor, POLY_XLU_DISP); } if (this->drawDmgEffTimer > 0) { - Actor_DrawDamageEffects(globalCtx, &this->actor, this->limbPos, ARRAY_COUNT(this->limbPos), - this->drawDmgEffScale, 0.5f, this->drawDmgEffAlpha, this->drawDmgEffType); + Actor_DrawDamageEffects(play, &this->actor, this->limbPos, ARRAY_COUNT(this->limbPos), this->drawDmgEffScale, + 0.5f, this->drawDmgEffAlpha, this->drawDmgEffType); } - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->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 b2d5b06b8..ba55f9fc3 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 @@ -9,7 +9,7 @@ struct EnTalkGibud; -typedef void (*EnTalkGibudActionFunc)(struct EnTalkGibud*, GlobalContext*); +typedef void (*EnTalkGibudActionFunc)(struct EnTalkGibud*, PlayState*); typedef struct EnTalkGibud { /* 0x000 */ Actor actor; 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 b7e5588f7..d45cc854c 100644 --- a/src/overlays/actors/ovl_En_Tanron1/z_en_tanron1.c +++ b/src/overlays/actors/ovl_En_Tanron1/z_en_tanron1.c @@ -10,13 +10,13 @@ #define THIS ((EnTanron1*)thisx) -void EnTanron1_Init(Actor* thisx, GlobalContext* globalCtx); -void EnTanron1_Destroy(Actor* thisx, GlobalContext* globalCtx); -void EnTanron1_Update(Actor* thisx, GlobalContext* globalCtx); -void EnTanron1_Draw(Actor* thisx, GlobalContext* globalCtx); +void EnTanron1_Init(Actor* thisx, PlayState* play); +void EnTanron1_Destroy(Actor* thisx, PlayState* play); +void EnTanron1_Update(Actor* thisx, PlayState* play); +void EnTanron1_Draw(Actor* thisx, PlayState* play); -void func_80BB5318(EnTanron1* this, GlobalContext* globalCtx); -void func_80BB5AAC(EnTanron1* this, GlobalContext* globalCtx); +void func_80BB5318(EnTanron1* this, PlayState* play); +void func_80BB5AAC(EnTanron1* this, PlayState* play); const ActorInit En_Tanron1_InitVars = { ACTOR_EN_TANRON1, @@ -34,7 +34,7 @@ static u64 sPad = { 0 }; #include "overlays/ovl_En_Tanron1/ovl_En_Tanron1.c" -void EnTanron1_Init(Actor* thisx, GlobalContext* globalCtx) { +void EnTanron1_Init(Actor* thisx, PlayState* play) { EnTanron1* this = THIS; this->actor.flags &= ~ACTOR_FLAG_1; @@ -46,7 +46,7 @@ void EnTanron1_Init(Actor* thisx, GlobalContext* globalCtx) { } } -void EnTanron1_Destroy(Actor* thisx, GlobalContext* globalCtx) { +void EnTanron1_Destroy(Actor* thisx, PlayState* play) { } void func_80BB4E50(EnTanron1Struct* arg0, Vec3f* arg1, s16 arg2) { @@ -71,10 +71,10 @@ void func_80BB4E50(EnTanron1Struct* arg0, Vec3f* arg1, s16 arg2) { } } -void EnTanron1_Update(Actor* thisx, GlobalContext* globalCtx) { +void EnTanron1_Update(Actor* thisx, PlayState* play) { EnTanron1* this = THIS; Actor* temp_a0; - Player* player = GET_PLAYER(globalCtx); + Player* player = GET_PLAYER(play); s16 i; EnTanron1Struct* ptr = &this->unk_160[0]; Vec3f temp; @@ -108,7 +108,7 @@ void EnTanron1_Update(Actor* thisx, GlobalContext* globalCtx) { phi_f18 = 10.0f; while (phi_f18 < 1000.0f) { - temp_a0 = globalCtx->actorCtx.actorLists[ACTORCAT_PROP].first; + temp_a0 = play->actorCtx.actorLists[ACTORCAT_PROP].first; while (temp_a0 != NULL) { if (temp_a0->id != ACTOR_OBJ_SYOKUDAI) { temp_a0 = temp_a0->next; @@ -150,9 +150,9 @@ void EnTanron1_Update(Actor* thisx, GlobalContext* globalCtx) { } if ((player->itemActionParam == 7) && (player->unk_B28 != 0)) { - this->unk_14C.x = player->swordInfo[0].tip.x; - this->unk_14C.y = player->swordInfo[0].tip.y; - this->unk_14C.z = player->swordInfo[0].tip.z; + this->unk_14C.x = player->meleeWeaponInfo[0].tip.x; + this->unk_14C.y = player->meleeWeaponInfo[0].tip.y; + this->unk_14C.z = player->meleeWeaponInfo[0].tip.z; this->unk_158 = 0x5000; this->unk_15C = 50.0f; @@ -160,7 +160,7 @@ void EnTanron1_Update(Actor* thisx, GlobalContext* globalCtx) { this->unk_144 = 100; } } else { - temp_a0 = globalCtx->actorCtx.actorLists[ACTORCAT_EXPLOSIVES].first; + temp_a0 = play->actorCtx.actorLists[ACTORCAT_EXPLOSIVES].first; while (temp_a0 != NULL) { if (temp_a0->params == 1) { temp_a0 = temp_a0->next; @@ -179,17 +179,17 @@ void EnTanron1_Update(Actor* thisx, GlobalContext* globalCtx) { break; } } - func_80BB5318(this, globalCtx); + func_80BB5318(this, play); } -void EnTanron1_Draw(Actor* thisx, GlobalContext* globalCtx) { +void EnTanron1_Draw(Actor* thisx, PlayState* play) { EnTanron1* this = THIS; - func_80BB5AAC(this, globalCtx); + func_80BB5AAC(this, play); } -void func_80BB5318(EnTanron1* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); +void func_80BB5318(EnTanron1* this, PlayState* play) { + Player* player = GET_PLAYER(play); EnTanron1Struct* ptr = NULL; f32 phi_f28 = 0.0f; Vec3f* phi_s2 = NULL; @@ -207,15 +207,15 @@ void func_80BB5318(EnTanron1* this, GlobalContext* globalCtx) { f32 temp_f30 = this->unk_15C; if (player->unk_ADC != 0) { - phi_s2 = &player->swordInfo[0].tip; - if (player->swordAnimation >= 30) { + phi_s2 = &player->meleeWeaponInfo[0].tip; + if (player->meleeWeaponAnimation >= PLAYER_MWA_SPIN_ATTACK_1H) { phi_f28 = 2500.0f; } else { phi_f28 = 400.0f; } } - temp_v0 = globalCtx->actorCtx.actorLists[ACTORCAT_EXPLOSIVES].first; + temp_v0 = play->actorCtx.actorLists[ACTORCAT_EXPLOSIVES].first; while (temp_v0 != NULL) { if (temp_v0->params != 1) { temp_v0 = temp_v0->next; @@ -258,15 +258,15 @@ void func_80BB5318(EnTanron1* this, GlobalContext* globalCtx) { 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); + func_800B8D10(play, &this->actor, 0.0f, 0, 0.0f, 1, 1); } } Math_ApproachS(&ptr->unk_1A, ptr->unk_20, 2, this->unk_158); Math_ApproachS(&ptr->unk_18, ptr->unk_1E, 2, this->unk_158); - Matrix_RotateY(ptr->unk_1A, MTXMODE_NEW); - Matrix_InsertXRotation_s(-ptr->unk_18, MTXMODE_APPLY); - Matrix_GetStateTranslationAndScaledZ(6.0f, &ptr->unk_0C); + 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; @@ -277,9 +277,9 @@ void func_80BB5318(EnTanron1* this, GlobalContext* globalCtx) { ptr->unk_20 = Math_Atan2S(temp.x, temp.z); ptr->unk_1E = Math_Atan2S(temp.y, sqrtf(SQXZ(temp))); - Matrix_RotateY(ptr->unk_20, MTXMODE_NEW); - Matrix_InsertXRotation_s(-ptr->unk_1E, MTXMODE_APPLY); - Matrix_GetStateTranslationAndScaledZ(-20.0f, &ptr->unk_0C); + 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; @@ -299,8 +299,8 @@ void func_80BB5318(EnTanron1* this, GlobalContext* globalCtx) { } else { ptr->unk_1A += ptr->unk_2A; Math_ApproachS(&ptr->unk_18, 0, 0xA, 0x1000); - Matrix_RotateY(ptr->unk_1A, MTXMODE_NEW); - Matrix_GetStateTranslationAndScaledZ(ptr->unk_30, &spA4); + 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; @@ -315,9 +315,9 @@ void func_80BB5318(EnTanron1* this, GlobalContext* globalCtx) { ptr->unk_20 = Math_Atan2S(temp.x, temp.z); ptr->unk_1E = Math_Atan2S(temp.y, sqrtf(SQXZ(temp))); - Matrix_RotateY(ptr->unk_20, MTXMODE_NEW); - Matrix_InsertXRotation_s(-ptr->unk_1E, MTXMODE_APPLY); - Matrix_GetStateTranslationAndScaledZ(-20.0f, &ptr->unk_0C); + 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; @@ -338,10 +338,9 @@ void func_80BB5318(EnTanron1* this, GlobalContext* globalCtx) { if (Rand_ZeroOne() < 0.5f) { ptr->unk_34 = randPlusMinusPoint5Scaled(12.0f); } - ptr->unk_3C = BgCheck_EntityRaycastFloor1(&globalCtx->colCtx, &sp98, &ptr->unk_00); + ptr->unk_3C = BgCheck_EntityRaycastFloor1(&play->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); + WaterBox_GetSurface1(play, &play->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; } @@ -353,7 +352,7 @@ void func_80BB5318(EnTanron1* this, GlobalContext* globalCtx) { } if (spB4 != NULL) { - SkinMatrix_Vec3fMtxFMultXYZW(&globalCtx->viewProjectionMtxF, spB4, &this->unk_3360, &spB0); + SkinMatrix_Vec3fMtxFMultXYZW(&play->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) { @@ -362,15 +361,15 @@ void func_80BB5318(EnTanron1* this, GlobalContext* globalCtx) { } } -void func_80BB5AAC(EnTanron1* this, GlobalContext* globalCtx) { +void func_80BB5AAC(EnTanron1* this, PlayState* play) { EnTanron1Struct* ptrBase = &this->unk_160[0]; s16 i; u8 flag = 0; EnTanron1Struct* ptr = ptrBase; - OPEN_DISPS(globalCtx->state.gfxCtx); + OPEN_DISPS(play->state.gfxCtx); - func_8012C28C(globalCtx->state.gfxCtx); + func_8012C28C(play->state.gfxCtx); for (i = 0; i < this->actor.params; i++, ptr++) { if (ptr->unk_24 == 1) { @@ -378,13 +377,12 @@ void func_80BB5AAC(EnTanron1* this, GlobalContext* globalCtx) { gSPDisplayList(POLY_OPA_DISP++, ovl_En_Tanron1_DL_001888); flag++; } - Matrix_InsertTranslation(ptr->unk_00.x, ptr->unk_00.y, ptr->unk_00.z, MTXMODE_NEW); - Matrix_RotateY(ptr->unk_1A, MTXMODE_APPLY); - Matrix_InsertXRotation_s(ptr->unk_18 * -1, MTXMODE_APPLY); + Matrix_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); + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_OPA_DISP++, ovl_En_Tanron1_DL_001900); } } @@ -403,14 +401,14 @@ void func_80BB5AAC(EnTanron1* this, GlobalContext* globalCtx) { flag++; } - Matrix_InsertTranslation(ptr->unk_00.x, ptr->unk_00.y, ptr->unk_00.z, MTXMODE_NEW); - Matrix_RotateY(ptr->unk_1A, MTXMODE_APPLY); - Matrix_InsertXRotation_s(ptr->unk_18 * -1, MTXMODE_APPLY); + Matrix_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); + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(play->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); + CLOSE_DISPS(play->state.gfxCtx); } 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 e391669e5..4f19b73a8 100644 --- a/src/overlays/actors/ovl_En_Tanron2/z_en_tanron2.c +++ b/src/overlays/actors/ovl_En_Tanron2/z_en_tanron2.c @@ -13,18 +13,18 @@ #define THIS ((EnTanron2*)thisx) -void EnTanron2_Init(Actor* thisx, GlobalContext* globalCtx); -void EnTanron2_Destroy(Actor* thisx, GlobalContext* globalCtx); -void EnTanron2_Update(Actor* thisx, GlobalContext* globalCtx); -void EnTanron2_Draw(Actor* thisx, GlobalContext* globalCtx); +void EnTanron2_Init(Actor* thisx, PlayState* play); +void EnTanron2_Destroy(Actor* thisx, PlayState* play); +void EnTanron2_Update(Actor* thisx, PlayState* play); +void EnTanron2_Draw(Actor* thisx, PlayState* play); void func_80BB69C0(EnTanron2* this); -void func_80BB69FC(EnTanron2* this, GlobalContext* globalCtx); -void func_80BB6BD8(EnTanron2* this, GlobalContext* globalCtx); +void func_80BB69FC(EnTanron2* this, PlayState* play); +void func_80BB6BD8(EnTanron2* this, PlayState* play); 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); +void func_80BB6F78(EnTanron2* this, PlayState* play); +void func_80BB7408(EnTanron2* this, PlayState* play); +void func_80BB7B90(Actor* thisx, PlayState* play); Boss04* D_80BB8450; f32 D_80BB8454; @@ -120,7 +120,7 @@ static ColliderCylinderInit sCylinderInit2 = { Color_RGBA8 D_80BB81E8 = { 255, 255, 255, 255 }; Color_RGBA8 D_80BB81EC = { 255, 100, 100, 255 }; -void EnTanron2_Init(Actor* thisx, GlobalContext* globalCtx) { +void EnTanron2_Init(Actor* thisx, PlayState* play) { EnTanron2* this = THIS; D_80BB8450 = (Boss04*)this->actor.parent; @@ -128,7 +128,7 @@ void EnTanron2_Init(Actor* thisx, GlobalContext* globalCtx) { if (this->actor.params == 100) { this->actor.update = func_80BB7B90; - func_800BC154(globalCtx, &globalCtx->actorCtx, &this->actor, 5); + func_800BC154(play, &play->actorCtx, &this->actor, 5); return; } @@ -140,8 +140,8 @@ void EnTanron2_Init(Actor* thisx, GlobalContext* globalCtx) { this->actor.colChkInfo.damageTable = &sDamageTable; this->actor.targetMode = 5; - Collider_InitAndSetCylinder(globalCtx, &this->collider1, &this->actor, &sCylinderInit1); - Collider_InitAndSetCylinder(globalCtx, &this->collider2, &this->actor, &sCylinderInit2); + Collider_InitAndSetCylinder(play, &this->collider1, &this->actor, &sCylinderInit1); + Collider_InitAndSetCylinder(play, &this->collider2, &this->actor, &sCylinderInit2); if ((KREG(64) != 0) || (gSaveContext.eventInf[6] & 1)) { func_80BB69C0(this); @@ -155,12 +155,12 @@ void EnTanron2_Init(Actor* thisx, GlobalContext* globalCtx) { this->unk_14C = -this->unk_14C; } - Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 35.0f, 60.0f, 60.0f, 4); + Actor_UpdateBgCheckInfo(play, &this->actor, 35.0f, 60.0f, 60.0f, 4); this->actor.floorHeight += 20.0f; this->unk_148 = Rand_ZeroFloat(32.0f); } -void EnTanron2_Destroy(Actor* thisx, GlobalContext* globalCtx) { +void EnTanron2_Destroy(Actor* thisx, PlayState* play) { } void func_80BB69C0(EnTanron2* this) { @@ -173,7 +173,7 @@ void func_80BB69C0(EnTanron2* this) { this->unk_158 = 0; } -void func_80BB69FC(EnTanron2* this, GlobalContext* globalCtx) { +void func_80BB69FC(EnTanron2* this, PlayState* play) { f32 sp34; f32 sp30; f32 sp2C; @@ -213,8 +213,8 @@ void func_80BB6B80(EnTanron2* this) { this->collider1.dim.yShift = -25; } -void func_80BB6BD8(EnTanron2* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); +void func_80BB6BD8(EnTanron2* this, PlayState* play) { + Player* player = GET_PLAYER(play); s16 sp32; f32 sp2C; f32 sp28; @@ -261,8 +261,8 @@ void func_80BB6BD8(EnTanron2* this, GlobalContext* globalCtx) { } break; } - Matrix_RotateY(sp32, MTXMODE_NEW); - Matrix_GetStateTranslationAndScaledZ(this->actor.speedXZ, &this->actor.velocity); + 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; } @@ -295,7 +295,7 @@ void func_80BB6F64(EnTanron2* this) { this->actionFunc = func_80BB6F78; } -void func_80BB6F78(EnTanron2* this, GlobalContext* globalCtx) { +void func_80BB6F78(EnTanron2* this, PlayState* play) { switch (this->unk_158) { case 0: if (D_80BB8450->unk_708 == 13) { @@ -352,16 +352,16 @@ void func_80BB6F78(EnTanron2* this, GlobalContext* globalCtx) { } } -void func_80BB71C8(EnTanron2* this, GlobalContext* globalCtx) { +void func_80BB71C8(EnTanron2* this, PlayState* play) { s32 i; Vec3f spA8; Vec3f sp9C; Vec3f sp90; for (i = 0; i < 15; i++) { - Matrix_InsertYRotation_f(Rand_ZeroFloat(6.2831855f), MTXMODE_NEW); - Matrix_RotateStateAroundXAxis(Rand_ZeroFloat(6.2831855f)); - Matrix_GetStateTranslationAndScaledZ(Rand_ZeroFloat(10.0f) + 5.0f, &spA8); + 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; @@ -370,22 +370,22 @@ void func_80BB71C8(EnTanron2* this, GlobalContext* globalCtx) { sp9C.y = spA8.y * -0.03f; sp9C.z = spA8.z * -0.03f; - EffectSsDtBubble_SpawnCustomColor(globalCtx, &sp90, &spA8, &sp9C, &D_80BB81E8, &D_80BB81EC, + EffectSsDtBubble_SpawnCustomColor(play, &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) { +void func_80BB7398(EnTanron2* this, PlayState* play) { 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); + Enemy_StartFinishingBlow(play, &this->actor); + SoundSource_PlaySfxAtFixedWorldPos(play, &this->actor.world.pos, 30, NA_SE_EN_IKURA_DEAD); } else { Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_IKURA_DAMAGE); } } -void func_80BB7408(EnTanron2* this, GlobalContext* globalCtx) { +void func_80BB7408(EnTanron2* this, PlayState* play) { 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; @@ -395,7 +395,7 @@ void func_80BB7408(EnTanron2* this, GlobalContext* globalCtx) { this->actor.world.pos.y = this->actor.floorHeight; if ((s8)this->actor.colChkInfo.health <= 0) { Actor_MarkForDeath(&this->actor); - func_80BB71C8(this, globalCtx); + func_80BB71C8(this, play); D_80BB8450->unk_6F6--; D_80BB8450->unk_2E2 += 4; D_80BB8450->unk_2E0 += 4; @@ -412,10 +412,10 @@ void func_80BB7408(EnTanron2* this, GlobalContext* globalCtx) { } } -void func_80BB7578(EnTanron2* this, GlobalContext* globalCtx) { +void func_80BB7578(EnTanron2* this, PlayState* play) { ColliderInfo* acHitInfo; s32 pad; - Player* player = GET_PLAYER(globalCtx); + Player* player = GET_PLAYER(play); s32 pad2; s32 pad3; u8 damage; @@ -430,22 +430,22 @@ void func_80BB7578(EnTanron2* this, GlobalContext* globalCtx) { 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; + play->actorCtx.targetContext.arrowPointedActor = &this->actor; + play->actorCtx.targetContext.targetedActor = &this->actor; } } else { this->unk_154 = 15; if (this->actionFunc != func_80BB69FC) { - Matrix_RotateY(this->actor.yawTowardsPlayer, MTXMODE_NEW); + Matrix_RotateYS(this->actor.yawTowardsPlayer, MTXMODE_NEW); if ((acHitInfo->toucher.dmgFlags & 0x300000) != 0) { this->unk_154 = 10; - Matrix_GetStateTranslationAndScaledZ(-10.0f, &this->actor.velocity); + Matrix_MultVecZ(-10.0f, &this->actor.velocity); } else { this->unk_156 = 15; - Matrix_GetStateTranslationAndScaledZ(-20.0f, &this->actor.velocity); + Matrix_MultVecZ(-20.0f, &this->actor.velocity); damage = this->actor.colChkInfo.damage; this->actor.colChkInfo.health -= damage; - func_80BB7398(this, globalCtx); + func_80BB7398(this, play); } } else { Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_IKURA_DAMAGE); @@ -464,18 +464,18 @@ void func_80BB7578(EnTanron2* this, GlobalContext* globalCtx) { block_18: func_80BB6B80(this); this->unk_158 = 2; - Matrix_RotateY(Math_Atan2S(this->actor.world.pos.x - D_80BB8450->unk_6BC.x, - this->actor.world.pos.z - D_80BB8450->unk_6BC.z), - MTXMODE_NEW); - Matrix_GetStateTranslationAndScaledZ(10.0f, &this->actor.velocity); + 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); + func_80BB71C8(this, play); } } -void EnTanron2_Update(Actor* thisx, GlobalContext* globalCtx) { +void EnTanron2_Update(Actor* thisx, PlayState* play) { s32 pad; EnTanron2* this = THIS; s32 pad2[2]; @@ -504,7 +504,7 @@ void EnTanron2_Update(Actor* thisx, GlobalContext* globalCtx) { this->unk_156--; } - this->actionFunc(this, globalCtx); + this->actionFunc(this, play); if (this->actionFunc != func_80BB69FC) { if ((this->actor.world.pos.x < (D_80BB8450->unk_6D8 + 20.0f)) || @@ -521,20 +521,20 @@ void EnTanron2_Update(Actor* thisx, GlobalContext* globalCtx) { } this->unk_14A += this->unk_14C; - func_80BB7578(this, globalCtx); + func_80BB7578(this, play); 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); + CollisionCheck_SetAT(play, &play->colChkCtx, &this->collider2.base); } else { this->unk_15A--; } } Collider_UpdateCylinder(&this->actor, &this->collider1); - CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->collider1.base); + CollisionCheck_SetAC(play, &play->colChkCtx, &this->collider1.base); } if (!(this->unk_148 & 0x1F)) { @@ -564,7 +564,7 @@ void EnTanron2_Update(Actor* thisx, GlobalContext* globalCtx) { this->unk_159 = 1; } - input = CONTROLLER3(globalCtx); + input = CONTROLLER3(&play->state); if (CHECK_BTN_ALL(input->press.button, BTN_L)) { this->unk_158 = 1; } @@ -574,30 +574,30 @@ void EnTanron2_Update(Actor* thisx, GlobalContext* globalCtx) { } } -void func_80BB7B90(Actor* thisx, GlobalContext* globalCtx) { +void func_80BB7B90(Actor* thisx, PlayState* play) { EnTanron2* this = THIS; - D_80BB8454 = (Math_SinS(globalCtx->gameplayFrames * 0x3000) * 0.1f) + 1.0f; + D_80BB8454 = (Math_SinS(play->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; +void EnTanron2_Draw(Actor* thisx, PlayState* play2) { + PlayState* play = play2; s32 i; s32 j; s32 found; Actor* tanron2; - OPEN_DISPS(globalCtx->state.gfxCtx); + OPEN_DISPS(play->state.gfxCtx); - func_8012C2DC(globalCtx->state.gfxCtx); + func_8012C2DC(play->state.gfxCtx); - gSPDisplayList(POLY_XLU_DISP++, object_boss04_DL_003450); + gSPDisplayList(POLY_XLU_DISP++, gWartBubbleMaterialDL); gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 255, 255, 255, 150); - tanron2 = globalCtx->actorCtx.actorLists[ACTORCAT_BOSS].first; + tanron2 = play->actorCtx.actorLists[ACTORCAT_BOSS].first; for (i = 0; i < ARRAY_COUNT(D_80BB8458); i++) { D_80BB8458[i] = NULL; @@ -624,60 +624,56 @@ void EnTanron2_Draw(Actor* thisx, GlobalContext* globalCtx2) { for (i = 0; i < ARRAY_COUNT(D_80BB8458); i++) { if (D_80BB8458[i] != NULL) { - Matrix_InsertTranslation(D_80BB8458[i]->actor.world.pos.x, D_80BB8458[i]->actor.world.pos.y, - D_80BB8458[i]->actor.world.pos.z, MTXMODE_NEW); - Matrix_NormalizeXYZ(&globalCtx->billboardMtxF); + Matrix_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(&play->billboardMtxF); Matrix_Scale(D_80BB8458[i]->actor.scale.x, D_80BB8458[i]->actor.scale.y, 0.0f, MTXMODE_APPLY); - Matrix_InsertZRotation_s(D_80BB8458[i]->unk_14A, MTXMODE_APPLY); + Matrix_RotateZS(D_80BB8458[i]->unk_14A, MTXMODE_APPLY); Matrix_Scale(0.13f, 0.14299999f, 0.13f, MTXMODE_APPLY); - Matrix_InsertZRotation_s(-D_80BB8458[i]->unk_14A, MTXMODE_APPLY); + 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); + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_XLU_DISP++, gWartBubbleModelDL); } } - func_8012C448(globalCtx->state.gfxCtx); + func_8012C448(play->state.gfxCtx); gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 0, 0, 0, 150); - gSPDisplayList(POLY_XLU_DISP++, object_boss04_DL_004510); + gSPDisplayList(POLY_XLU_DISP++, gWartShadowMaterialDL); - tanron2 = globalCtx->actorCtx.actorLists[ACTORCAT_BOSS].first; + tanron2 = play->actorCtx.actorLists[ACTORCAT_BOSS].first; while (tanron2 != NULL) { if ((tanron2->params < 100) && (((EnTanron2*)tanron2)->unk_15B != 0)) { - Matrix_InsertTranslation(tanron2->world.pos.x, D_80BB8450->actor.floorHeight, tanron2->world.pos.z, - MTXMODE_NEW); + Matrix_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); + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_XLU_DISP++, gWartShadowModelDL); } tanron2 = tanron2->next; } - func_8012C974(globalCtx->state.gfxCtx); + func_8012C974(play->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; + tanron2 = play->actorCtx.actorLists[ACTORCAT_BOSS].first; while (tanron2 != NULL) { if ((tanron2->params < 100) && (((EnTanron2*)tanron2)->unk_15B != 0) && (tanron2->world.pos.y <= tanron2->floorHeight)) { - Matrix_InsertTranslation(tanron2->world.pos.x, D_80BB8450->actor.floorHeight + 2.0f, tanron2->world.pos.z, - MTXMODE_NEW); + Matrix_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); + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_XLU_DISP++, gEffWaterRippleDL); } tanron2 = tanron2->next; } - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->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 755bb4ff4..efbcc3108 100644 --- a/src/overlays/actors/ovl_En_Tanron2/z_en_tanron2.h +++ b/src/overlays/actors/ovl_En_Tanron2/z_en_tanron2.h @@ -5,27 +5,27 @@ struct EnTanron2; -typedef void (*EnTanron2ActionFunc)(struct EnTanron2*, GlobalContext*); +typedef void (*EnTanron2ActionFunc)(struct EnTanron2*, PlayState*); typedef struct EnTanron2 { - /* 0x0000 */ Actor actor; - /* 0x0144 */ EnTanron2ActionFunc actionFunc; - /* 0x0148 */ s16 unk_148; - /* 0x014A */ s16 unk_14A; - /* 0x014C */ s16 unk_14C; - /* 0x014E */ s16 unk_14E; - /* 0x0150 */ s16 unk_150; - /* 0x0152 */ s16 unk_152; - /* 0x0154 */ s16 unk_154; - /* 0x0156 */ s16 unk_156; - /* 0x0158 */ u8 unk_158; - /* 0x0159 */ u8 unk_159; - /* 0x015A */ u8 unk_15A; - /* 0x015B */ u8 unk_15B; - /* 0x015C */ f32 unk_15C; - /* 0x0160 */ f32 unk_160; - /* 0x0164 */ ColliderCylinder collider1; - /* 0x01B0 */ ColliderCylinder collider2; + /* 0x000 */ Actor actor; + /* 0x144 */ EnTanron2ActionFunc actionFunc; + /* 0x148 */ s16 unk_148; + /* 0x14A */ s16 unk_14A; + /* 0x14C */ s16 unk_14C; + /* 0x14E */ s16 unk_14E; + /* 0x150 */ s16 unk_150; + /* 0x152 */ s16 unk_152; + /* 0x154 */ s16 unk_154; + /* 0x156 */ s16 unk_156; + /* 0x158 */ u8 unk_158; + /* 0x159 */ u8 unk_159; + /* 0x15A */ u8 unk_15A; + /* 0x15B */ u8 unk_15B; + /* 0x15C */ f32 unk_15C; + /* 0x160 */ f32 unk_160; + /* 0x164 */ ColliderCylinder collider1; + /* 0x1B0 */ ColliderCylinder collider2; } EnTanron2; // size = 0x1FC extern const ActorInit En_Tanron2_InitVars; diff --git a/src/overlays/actors/ovl_En_Tanron3/z_en_tanron3.c b/src/overlays/actors/ovl_En_Tanron3/z_en_tanron3.c index 15d307326..64d8b2dd7 100644 --- a/src/overlays/actors/ovl_En_Tanron3/z_en_tanron3.c +++ b/src/overlays/actors/ovl_En_Tanron3/z_en_tanron3.c @@ -18,14 +18,14 @@ #define WORK_TIMER_ATTACK 2 #define WORK_TIMER_WAIT 2 -void EnTanron3_Init(Actor* thisx, GlobalContext* globalCtx); -void EnTanron3_Destroy(Actor* thisx, GlobalContext* globalCtx); -void EnTanron3_Update(Actor* thisx, GlobalContext* globalCtx); -void EnTanron3_Draw(Actor* thisx, GlobalContext* globalCtx); +void EnTanron3_Init(Actor* thisx, PlayState* play); +void EnTanron3_Destroy(Actor* thisx, PlayState* play); +void EnTanron3_Update(Actor* thisx, PlayState* play); +void EnTanron3_Draw(Actor* thisx, PlayState* play); -void EnTanron3_SetupLive(EnTanron3* this, GlobalContext* globalCtx); -void EnTanron3_Live(EnTanron3* this, GlobalContext* globalCtx); -void EnTanron3_Die(EnTanron3* this, GlobalContext* globalCtx); +void EnTanron3_SetupLive(EnTanron3* this, PlayState* play); +void EnTanron3_Live(EnTanron3* this, PlayState* play); +void EnTanron3_Die(EnTanron3* this, PlayState* play); static Vec3f sZeroVec[] = { 0.0f, 0.0f, 0.0f }; @@ -85,8 +85,8 @@ static ColliderCylinderInit sUnusedCylinderInit = { { 20, 20, -10, { 0, 0, 0 } }, }; -void EnTanron3_CreateEffect(GlobalContext* globalCtx, Vec3f* effectPos) { - GyorgEffect* effectPtr = globalCtx->specialEffects; +void EnTanron3_CreateEffect(PlayState* play, Vec3f* effectPos) { + GyorgEffect* effectPtr = play->specialEffects; s16 i; for (i = 0; i < GYORG_EFFECT_COUNT; i++, effectPtr++) { @@ -107,27 +107,27 @@ void EnTanron3_CreateEffect(GlobalContext* globalCtx, Vec3f* effectPos) { } } -void EnTanron3_Init(Actor* thisx, GlobalContext* globalCtx) { +void EnTanron3_Init(Actor* thisx, PlayState* play) { EnTanron3* this = THIS; this->actor.gravity = -1.0f; - Collider_InitAndSetCylinder(globalCtx, &this->atCollider, &this->actor, &sCylinderInit); - Collider_InitAndSetCylinder(globalCtx, &this->acCollider, &this->actor, &sCylinderInit); - SkelAnime_InitFlex(globalCtx, &this->skelAnime, &gGyorgSmallFishSkel, &gGyorgSmallFishSwimAnim, this->jointTable, + Collider_InitAndSetCylinder(play, &this->atCollider, &this->actor, &sCylinderInit); + Collider_InitAndSetCylinder(play, &this->acCollider, &this->actor, &sCylinderInit); + SkelAnime_InitFlex(play, &this->skelAnime, &gGyorgSmallFishSkel, &gGyorgSmallFishSwimAnim, this->jointTable, this->morphTable, GYORG_SMALL_FISH_LIMB_MAX); Actor_SetScale(&this->actor, 0.02f); - EnTanron3_SetupLive(this, globalCtx); + EnTanron3_SetupLive(this, play); 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) { +void EnTanron3_Destroy(Actor* thisx, PlayState* play) { sGyorg->numSpawnedSmallFish--; } -void EnTanron3_SpawnBubbles(EnTanron3* this, GlobalContext* globalCtx) { +void EnTanron3_SpawnBubbles(EnTanron3* this, PlayState* play) { static Color_RGBA8 sPrimColor = { 100, 55, 55, 255 }; static Color_RGBA8 sEnvColor = { 50, 10, 10, 255 }; s32 i; @@ -135,18 +135,18 @@ 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; - EffectSsDtBubble_SpawnCustomColor(globalCtx, &this->actor.world.pos, &velocity, &acceleration, &sPrimColor, + EffectSsDtBubble_SpawnCustomColor(play, &this->actor.world.pos, &velocity, &acceleration, &sPrimColor, &sEnvColor, Rand_ZeroFloat(30.0f) + 70.0f, Rand_ZeroFloat(5.0f) + 15.0f, 0); } } -void EnTanron3_SetupLive(EnTanron3* this, GlobalContext* globalCtx) { +void EnTanron3_SetupLive(EnTanron3* this, PlayState* play) { this->actionFunc = EnTanron3_Live; Animation_MorphToLoop(&this->skelAnime, &gGyorgSmallFishSwimAnim, -10.0f); this->rotationStep = 0; @@ -169,14 +169,14 @@ void EnTanron3_SetupLive(EnTanron3* this, GlobalContext* globalCtx) { * - swimming around idly if the player is out of range * - flopping around on land if it beaches itself */ -void EnTanron3_Live(EnTanron3* this, GlobalContext* globalCtx) { +void EnTanron3_Live(EnTanron3* this, PlayState* play) { s32 atanTemp; f32 xDistance; f32 yDistance; f32 zDistance; f32 xzDistance; f32 extraScaleY = 0.0f; - Player* player = GET_PLAYER(globalCtx); + Player* player = GET_PLAYER(play); this->skelAnime.curFrame = 4.0f; if ((player->actor.bgCheckFlags & 1) && player->actor.shape.feetPos[0].y >= 438.0f) { @@ -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; @@ -316,7 +316,7 @@ void EnTanron3_Live(EnTanron3* this, GlobalContext* globalCtx) { effectPos.x = randPlusMinusPoint5Scaled(30.0f) + this->actor.world.pos.x; effectPos.y = this->actor.world.pos.y; effectPos.z = randPlusMinusPoint5Scaled(30.0f) + this->actor.world.pos.z; - EnTanron3_CreateEffect(globalCtx, &effectPos); + EnTanron3_CreateEffect(play, &effectPos); } break; } @@ -332,11 +332,11 @@ void EnTanron3_Live(EnTanron3* this, GlobalContext* globalCtx) { } } -void EnTanron3_SetupDie(EnTanron3* this, GlobalContext* globalCtx) { +void EnTanron3_SetupDie(EnTanron3* this, PlayState* play) { f32 xDistance; f32 yDistance; f32 zDistance; - Player* player = GET_PLAYER(globalCtx); + Player* player = GET_PLAYER(play); this->actionFunc = EnTanron3_Die; xDistance = this->actor.world.pos.x - player->actor.world.pos.x; @@ -349,25 +349,25 @@ void EnTanron3_SetupDie(EnTanron3* this, GlobalContext* globalCtx) { Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_KONB_MINI_DEAD); } -void EnTanron3_Die(EnTanron3* this, GlobalContext* globalCtx) { +void EnTanron3_Die(EnTanron3* this, PlayState* play) { Actor_MoveWithoutGravityReverse(&this->actor); if (this->workTimer[WORK_TIMER_DIE] == 0) { - EnTanron3_SpawnBubbles(this, globalCtx); + EnTanron3_SpawnBubbles(this, play); Actor_MarkForDeath(&this->actor); if (Rand_ZeroOne() < 0.3f) { - Item_DropCollectibleRandom(globalCtx, NULL, &this->actor.world.pos, 0x60); + Item_DropCollectibleRandom(play, NULL, &this->actor.world.pos, 0x60); } } } -void EnTanron3_CheckCollisions(EnTanron3* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); +void EnTanron3_CheckCollisions(EnTanron3* this, PlayState* play) { + Player* player = GET_PLAYER(play); if (player->actor.world.pos.y > 350.0f) { if (this->atCollider.base.atFlags & AT_HIT) { this->atCollider.base.atFlags &= ~AT_HIT; - func_800B8D50(globalCtx, NULL, 3.0f, Math_FAtan2F(-player->actor.world.pos.z, -player->actor.world.pos.x), - 5.0f, 0); + func_800B8D50(play, NULL, 3.0f, Math_FAtan2F(-player->actor.world.pos.z, -player->actor.world.pos.x), 5.0f, + 0); } } if (this->acCollider.base.acFlags & AC_HIT) { @@ -375,13 +375,13 @@ void EnTanron3_CheckCollisions(EnTanron3* this, GlobalContext* globalCtx) { if (this->deathTimer == 0) { this->deathTimer = 15; this->fogTimer = 15; - EnTanron3_SetupDie(this, globalCtx); + EnTanron3_SetupDie(this, play); sGyorg->unk_324 = 20; } } } -void EnTanron3_Update(Actor* thisx, GlobalContext* globalCtx) { +void EnTanron3_Update(Actor* thisx, PlayState* play) { s32 pad; EnTanron3* this = THIS; s16 i; @@ -402,8 +402,8 @@ void EnTanron3_Update(Actor* thisx, GlobalContext* globalCtx) { this->fogTimer--; } - this->actionFunc(this, globalCtx); - Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 10.0f, 10.0f, 20.0f, 5); + this->actionFunc(this, play); + Actor_UpdateBgCheckInfo(play, &this->actor, 10.0f, 10.0f, 20.0f, 5); // The fish has either just entered or just exited the water, so create a splash effect if (((this->actor.prevPos.y < this->waterSurfaceYPos) && (this->waterSurfaceYPos <= this->actor.world.pos.y)) || @@ -411,25 +411,24 @@ void EnTanron3_Update(Actor* thisx, GlobalContext* globalCtx) { splashPos.x = this->actor.world.pos.x; splashPos.y = this->waterSurfaceYPos + 10.0f; splashPos.z = this->actor.world.pos.z; - EffectSsGSplash_Spawn(globalCtx, &splashPos, NULL, NULL, 1, 500); + EffectSsGSplash_Spawn(play, &splashPos, NULL, NULL, 1, 500); Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_OUT_OF_WATER); } } - EnTanron3_CheckCollisions(this, globalCtx); + EnTanron3_CheckCollisions(this, play); Collider_UpdateCylinder(&this->actor, &this->atCollider); Collider_UpdateCylinder(&this->actor, &this->acCollider); - CollisionCheck_SetAT(globalCtx, &globalCtx->colChkCtx, &this->atCollider.base); - CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->acCollider.base); + CollisionCheck_SetAT(play, &play->colChkCtx, &this->atCollider.base); + CollisionCheck_SetAC(play, &play->colChkCtx, &this->acCollider.base); if ((s8)sGyorg->actor.colChkInfo.health <= 0 && this->actionFunc != EnTanron3_Die) { - EnTanron3_SetupDie(this, globalCtx); + EnTanron3_SetupDie(this, play); this->workTimer[WORK_TIMER_DIE] = 0; } } -s32 EnTanron3_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, - Actor* thisx) { +s32 EnTanron3_OverrideLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, Actor* thisx) { EnTanron3* this = THIS; if (limbIndex == GYORG_SMALL_FISH_LIMB_ROOT) { @@ -447,18 +446,18 @@ s32 EnTanron3_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dL return false; } -void EnTanron3_Draw(Actor* thisx, GlobalContext* globalCtx) { +void EnTanron3_Draw(Actor* thisx, PlayState* play) { EnTanron3* this = THIS; - OPEN_DISPS(globalCtx->state.gfxCtx); + OPEN_DISPS(play->state.gfxCtx); - func_8012C28C(globalCtx->state.gfxCtx); + func_8012C28C(play->state.gfxCtx); if ((this->fogTimer % 2) != 0) { POLY_OPA_DISP = Gfx_SetFog(POLY_OPA_DISP, 255, 0, 0, 255, 900, 1099); } - SkelAnime_DrawFlexOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, + SkelAnime_DrawFlexOpa(play, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, EnTanron3_OverrideLimbDraw, NULL, &this->actor); - POLY_OPA_DISP = func_801660B8(globalCtx, POLY_OPA_DISP); + POLY_OPA_DISP = func_801660B8(play, POLY_OPA_DISP); - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->state.gfxCtx); } 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 5f984e2ef..14971d6e8 100644 --- a/src/overlays/actors/ovl_En_Tanron3/z_en_tanron3.h +++ b/src/overlays/actors/ovl_En_Tanron3/z_en_tanron3.h @@ -6,7 +6,7 @@ struct EnTanron3; -typedef void (*EnTanron3ActionFunc)(struct EnTanron3*, GlobalContext*); +typedef void (*EnTanron3ActionFunc)(struct EnTanron3*, PlayState*); #define TANRON3_WORK_TIMER_MAX 3 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 969a87cf6..e68ca1b3a 100644 --- a/src/overlays/actors/ovl_En_Tanron4/z_en_tanron4.c +++ b/src/overlays/actors/ovl_En_Tanron4/z_en_tanron4.c @@ -10,16 +10,16 @@ #define THIS ((EnTanron4*)thisx) -void EnTanron4_Init(Actor* thisx, GlobalContext* globalCtx); -void EnTanron4_Destroy(Actor* thisx, GlobalContext* globalCtx); -void EnTanron4_Update(Actor* thisx, GlobalContext* globalCtx); -void EnTanron4_Draw(Actor* thisx, GlobalContext* globalCtx); +void EnTanron4_Init(Actor* thisx, PlayState* play); +void EnTanron4_Destroy(Actor* thisx, PlayState* play); +void EnTanron4_Update(Actor* thisx, PlayState* play); +void EnTanron4_Draw(Actor* thisx, PlayState* play); void EnTanron4_SetupFlyNearHome(EnTanron4* this); void EnTanron4_SetupFlyNearActor(EnTanron4* this); -void EnTanron4_FlyNearHome(EnTanron4* this, GlobalContext* globalCtx); -void EnTanron4_FlyNearActor(EnTanron4* this, GlobalContext* globalCtx); +void EnTanron4_FlyNearHome(EnTanron4* this, PlayState* play); +void EnTanron4_FlyNearActor(EnTanron4* this, PlayState* play); typedef enum { /* 0 */ SEAGULL_FLY_FLAP, @@ -43,12 +43,12 @@ const ActorInit En_Tanron4_InitVars = { (ActorFunc)EnTanron4_Draw, }; -void EnTanron4_Init(Actor* thisx, GlobalContext* globalCtx2) { - GlobalContext* globalCtx = globalCtx2; +void EnTanron4_Init(Actor* thisx, PlayState* play2) { + PlayState* play = play2; EnTanron4* this = THIS; - SkelAnime_InitFlex(globalCtx, &this->skelAnime, &gSeagullSkel, &gSeagullFlapAnim, this->jointTable, - this->morphTable, OBJECT_TANRON4_LIMB_MAX); + SkelAnime_InitFlex(play, &this->skelAnime, &gSeagullSkel, &gSeagullFlapAnim, this->jointTable, this->morphTable, + OBJECT_TANRON4_LIMB_MAX); thisx->flags &= ~ACTOR_FLAG_1; thisx->speedXZ = 3.0f + KREG(48); @@ -65,7 +65,7 @@ void EnTanron4_Init(Actor* thisx, GlobalContext* globalCtx2) { s32 i; for (i = 0; i < thisx->params; i++) { - Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_TANRON4, + Actor_Spawn(&play->actorCtx, play, 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, @@ -80,7 +80,7 @@ void EnTanron4_Init(Actor* thisx, GlobalContext* globalCtx2) { } } -void EnTanron4_Destroy(Actor* thisx, GlobalContext* globalCtx) { +void EnTanron4_Destroy(Actor* thisx, PlayState* play) { } void EnTanron4_SetupFlyNearHome(EnTanron4* this) { @@ -88,7 +88,7 @@ void EnTanron4_SetupFlyNearHome(EnTanron4* this) { Animation_MorphToLoop(&this->skelAnime, &gSeagullFlapAnim, 0.0f); } -void EnTanron4_FlyNearHome(EnTanron4* this, GlobalContext* globalCtx) { +void EnTanron4_FlyNearHome(EnTanron4* this, PlayState* play) { f32 xDiff; f32 yDiff; f32 zDiff; @@ -175,7 +175,7 @@ void EnTanron4_SetupFlyNearActor(EnTanron4* this) { Animation_MorphToLoop(&this->skelAnime, &gSeagullFlapAnim, 0.0f); } -void EnTanron4_FlyNearActor(EnTanron4* this, GlobalContext* globalCtx) { +void EnTanron4_FlyNearActor(EnTanron4* this, PlayState* play) { f32 xDiff; f32 yDiff; f32 zDiff; @@ -249,7 +249,7 @@ void EnTanron4_FlyNearActor(EnTanron4* this, GlobalContext* globalCtx) { Math_ApproachS(&this->roll, this->rollTarget, 3, 0x3E8 + KREG(45)); } -void EnTanron4_Update(Actor* thisx, GlobalContext* globalCtx) { +void EnTanron4_Update(Actor* thisx, PlayState* play) { EnTanron4* this = THIS; Actor_SetScale(&this->actor, 0.001f * KREG(16) + 0.01f); @@ -265,19 +265,19 @@ void EnTanron4_Update(Actor* thisx, GlobalContext* globalCtx) { } } - this->actionFunc(this, globalCtx); + this->actionFunc(this, play); Actor_UpdateVelocityWithoutGravity(&this->actor); Actor_UpdatePos(&this->actor); } } -void EnTanron4_Draw(Actor* thisx, GlobalContext* globalCtx) { +void EnTanron4_Draw(Actor* thisx, PlayState* play) { EnTanron4* this = THIS; if (this->timeInfluence < 1400.0f) { - Matrix_InsertZRotation_s(this->roll, MTXMODE_APPLY); - SkelAnime_DrawFlexOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, - this->skelAnime.dListCount, NULL, NULL, &this->actor); + Matrix_RotateZS(this->roll, MTXMODE_APPLY); + SkelAnime_DrawFlexOpa(play, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, + NULL, NULL, &this->actor); } } diff --git a/src/overlays/actors/ovl_En_Tanron4/z_en_tanron4.h b/src/overlays/actors/ovl_En_Tanron4/z_en_tanron4.h index 250a62cf1..de4874cfc 100644 --- a/src/overlays/actors/ovl_En_Tanron4/z_en_tanron4.h +++ b/src/overlays/actors/ovl_En_Tanron4/z_en_tanron4.h @@ -6,7 +6,7 @@ struct EnTanron4; -typedef void (*EnTanron4ActionFunc)(struct EnTanron4*, GlobalContext*); +typedef void (*EnTanron4ActionFunc)(struct EnTanron4*, PlayState*); typedef struct EnTanron4 { /* 0x000 */ Actor actor; 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 ada39da61..dc74fa461 100644 --- a/src/overlays/actors/ovl_En_Tanron5/z_en_tanron5.c +++ b/src/overlays/actors/ovl_En_Tanron5/z_en_tanron5.c @@ -13,13 +13,13 @@ #define THIS ((EnTanron5*)thisx) -void EnTanron5_Init(Actor* thisx, GlobalContext* globalCtx); -void EnTanron5_Destroy(Actor* thisx, GlobalContext* globalCtx); -void EnTanron5_Update(Actor* thisx, GlobalContext* globalCtx); -void EnTanron5_Draw(Actor* thisx, GlobalContext* globalCtx); +void EnTanron5_Init(Actor* thisx, PlayState* play); +void EnTanron5_Destroy(Actor* thisx, PlayState* play); +void EnTanron5_Update(Actor* thisx, PlayState* play); +void EnTanron5_Draw(Actor* thisx, PlayState* play); -void func_80BE5818(Actor* thisx, GlobalContext* globalCtx); -void func_80BE5C10(Actor* thisx, GlobalContext* globalCtx); +void func_80BE5818(Actor* thisx, PlayState* play); +void func_80BE5C10(Actor* thisx, PlayState* play); s32 D_80BE5D80 = 0; @@ -65,11 +65,11 @@ Vec2s D_80BE5DD4[] = { }; Gfx* D_80BE5E24[] = { - object_boss02_DL_007D18, object_boss02_DL_007D18, object_boss02_DL_007D18, object_boss02_DL_007D18, - object_boss02_DL_007D18, object_boss02_DL_007D18, object_boss02_DL_007D18, object_boss02_DL_007D18, - object_boss02_DL_007D18, object_boss02_DL_007D18, object_boss02_DL_007D18, object_boss02_DL_007D18, - object_boss02_DL_006FD0, object_boss02_DL_006FD0, object_boss02_DL_006FD0, object_boss02_DL_006FD0, - object_boss02_DL_006FD0, object_boss02_DL_006FD0, object_boss02_DL_006FD0, object_boss02_DL_006FD0, + gTwinmoldMajoraPillarDL, gTwinmoldMajoraPillarDL, gTwinmoldMajoraPillarDL, gTwinmoldMajoraPillarDL, + gTwinmoldMajoraPillarDL, gTwinmoldMajoraPillarDL, gTwinmoldMajoraPillarDL, gTwinmoldMajoraPillarDL, + gTwinmoldMajoraPillarDL, gTwinmoldMajoraPillarDL, gTwinmoldMajoraPillarDL, gTwinmoldMajoraPillarDL, + gTwinmoldPyramidRuinDL, gTwinmoldPyramidRuinDL, gTwinmoldPyramidRuinDL, gTwinmoldPyramidRuinDL, + gTwinmoldPyramidRuinDL, gTwinmoldPyramidRuinDL, gTwinmoldPyramidRuinDL, gTwinmoldPyramidRuinDL, }; f32 D_80BE5E74[] = { @@ -144,7 +144,7 @@ void func_80BE4A2C(EnTanron5Effect* effect, Vec3f* arg1, f32 arg2) { } } -void EnTanron5_Init(Actor* thisx, GlobalContext* globalCtx) { +void EnTanron5_Init(Actor* thisx, PlayState* play) { EnTanron5* this = THIS; if (ENTANRON5_GET(&this->actor) >= ENTANRON5_100) { @@ -176,7 +176,7 @@ void EnTanron5_Init(Actor* thisx, GlobalContext* globalCtx) { this->unk_144 = 250; this->actor.shape.rot.x = this->actor.shape.rot.y = this->actor.shape.rot.z = 0; } else { - this->unk_148 = object_boss02_DL_007A88; + this->unk_148 = gRuinFragmentDL; this->unk_144 = 150; } } else if (ENTANRON5_GET(&this->actor) == ENTANRON5_0) { @@ -185,7 +185,7 @@ void EnTanron5_Init(Actor* thisx, GlobalContext* globalCtx) { for (i = 0; i < ARRAY_COUNT(D_80BE5E74); i++) { child = - (EnTanron5*)Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_TANRON5, D_80BE5DD4[i].x, + (EnTanron5*)Actor_Spawn(&play->actorCtx, play, 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; @@ -194,21 +194,21 @@ void EnTanron5_Init(Actor* thisx, GlobalContext* globalCtx) { Actor_SetScale(&child->actor, child->unk_19C); child->unk_148 = D_80BE5E24[i]; - if (child->unk_148 == object_boss02_DL_006FD0) { + if (child->unk_148 == gTwinmoldPyramidRuinDL) { child->actor.shape.rot.y = 0; } - Collider_InitAndSetCylinder(globalCtx, &child->collider, &child->actor, &sCylinderInit); + Collider_InitAndSetCylinder(play, &child->collider, &child->actor, &sCylinderInit); } Actor_MarkForDeath(&this->actor); } else { - Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 50.0f, 150.0f, 100.0f, 4); + Actor_UpdateBgCheckInfo(play, &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) { +void EnTanron5_Destroy(Actor* thisx, PlayState* play) { EnTanron5* this = THIS; if (ENTANRON5_GET(&this->actor) >= ENTANRON5_100) { @@ -216,11 +216,11 @@ void EnTanron5_Destroy(Actor* thisx, GlobalContext* globalCtx) { } } -void EnTanron5_Update(Actor* thisx, GlobalContext* globalCtx2) { - GlobalContext* globalCtx = globalCtx2; +void EnTanron5_Update(Actor* thisx, PlayState* play2) { + PlayState* play = play2; EnTanron5* this = THIS; Boss02* boss02 = (Boss02*)this->actor.parent; - Player* player = GET_PLAYER(globalCtx2); + Player* player = GET_PLAYER(play2); s32 i; s32 phi_v0; s32 spC4; @@ -249,7 +249,7 @@ void EnTanron5_Update(Actor* thisx, GlobalContext* globalCtx2) { Actor_SetScale(&this->actor, this->unk_19C * D_80BE5DD0); - if (this->unk_148 == object_boss02_DL_007D18) { + 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) { @@ -271,7 +271,7 @@ void EnTanron5_Update(Actor* thisx, GlobalContext* globalCtx2) { this->collider.base.acFlags &= ~AC_HIT; spC4 = 10; - if (Play_InCsMode(globalCtx)) { + if (Play_InCsMode(play)) { this->unk_144 = 1; } else { this->unk_144 = 5; @@ -280,17 +280,17 @@ void EnTanron5_Update(Actor* thisx, GlobalContext* globalCtx2) { if ((KREG(19) != 0) || ((acHitInfo->toucher.dmgFlags & 0x05000202) && (D_80BE5DD0 < 0.5f)) || (ac->id == ACTOR_BOSS_02)) { - if (this->unk_148 == object_boss02_DL_007D18) { + 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, + Actor_Spawn(&play->actorCtx, play, 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); + func_80BE4A2C(play->specialEffects, &spB8, Rand_ZeroFloat(3.0f) + 6.0f); } this->actor.world.pos.y -= D_80BE5DD0 * 130.0f; @@ -309,7 +309,8 @@ void EnTanron5_Update(Actor* thisx, GlobalContext* globalCtx2) { 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); @@ -330,11 +331,11 @@ void EnTanron5_Update(Actor* thisx, GlobalContext* globalCtx2) { 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, + Actor_Spawn(&play->actorCtx, play, 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); + func_80BE4A2C(play->specialEffects, &sp9C, Rand_ZeroFloat(3.0f) + 6.0f); } } } @@ -349,7 +350,7 @@ void EnTanron5_Update(Actor* thisx, GlobalContext* globalCtx2) { this->actor.shape.rot.y += phi_v0; Actor_PlaySfxAtPos(&this->actor, NA_SE_IT_BIG_BOMB_EXPLOSION); - func_800BC848(&this->actor, globalCtx, 4, 4); + func_800BC848(&this->actor, play, 4, 4); this->unk_1A0++; } else { Vec3f sp90; @@ -360,18 +361,18 @@ void EnTanron5_Update(Actor* thisx, GlobalContext* globalCtx2) { sp90.z = info->bumper.hitPos.z; Actor_PlaySfxAtPos(&this->actor, NA_SE_IT_SHIELD_REFLECT_SW); - CollisionCheck_SpawnShieldParticlesMetal(globalCtx, &sp90); + CollisionCheck_SpawnShieldParticlesMetal(play, &sp90); } } } Collider_UpdateCylinder(&this->actor, &this->collider); - if (this->unk_148 == object_boss02_DL_006FD0) { + if (this->unk_148 == gTwinmoldPyramidRuinDL) { this->collider.dim.pos.y = this->actor.floorHeight; } - if ((this->unk_148 == object_boss02_DL_007D18) || (D_80BE5DD0 < 0.5f)) { - CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + if ((this->unk_148 == gTwinmoldMajoraPillarDL) || (D_80BE5DD0 < 0.5f)) { + CollisionCheck_SetOC(play, &play->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; @@ -391,15 +392,15 @@ void EnTanron5_Update(Actor* thisx, GlobalContext* globalCtx2) { } } - CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + CollisionCheck_SetAC(play, &play->colChkCtx, &this->collider.base); } -void func_80BE5818(Actor* thisx, GlobalContext* globalCtx2) { +void func_80BE5818(Actor* thisx, PlayState* play2) { f32 sp6C; s32 i; Vec3f sp5C; EnTanron5* this = THIS; - GlobalContext* globalCtx = globalCtx2; + PlayState* play = play2; if ((ENTANRON5_GET(&this->actor) < ENTANRON5_110) && (this->unk_1A0 != 0)) { this->unk_1A0++; @@ -416,7 +417,7 @@ void func_80BE5818(Actor* thisx, GlobalContext* globalCtx2) { if (this->actor.speedXZ > 0.02f) { Actor_MoveWithGravity(&this->actor); - Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 50.0f, 150.0f, 100.0f, 4); + Actor_UpdateBgCheckInfo(play, &this->actor, 50.0f, 150.0f, 100.0f, 4); } if (ENTANRON5_GET(&this->actor) < ENTANRON5_110) { @@ -430,7 +431,7 @@ void func_80BE5818(Actor* thisx, GlobalContext* globalCtx2) { sp5C.y = this->actor.floorHeight; for (i = 0; i < 4; i++) { - func_80BE4930(globalCtx->specialEffects, &sp5C, Rand_ZeroFloat(1.0f) + 2.0f); + func_80BE4930(play->specialEffects, &sp5C, Rand_ZeroFloat(1.0f) + 2.0f); } this->unk_1A0++; } else { @@ -449,7 +450,7 @@ void func_80BE5818(Actor* thisx, GlobalContext* globalCtx2) { 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); + Player* player = GET_PLAYER(play); Vec3f temp; temp.x = player->actor.world.pos.x - this->actor.world.pos.x; @@ -459,15 +460,15 @@ void func_80BE5818(Actor* thisx, GlobalContext* globalCtx2) { if (SQXYZ(temp) < sp6C) { if (ENTANRON5_GET(&this->actor) >= ENTANRON5_110) { if (this->unk_1A0 == 0) { - Item_Give(globalCtx, ITEM_ARROWS_10); + Item_Give(play, ITEM_ARROWS_10); } else { - Item_Give(globalCtx, ITEM_MAGIC_LARGE); + Item_Give(play, 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); + func_800B8D50(play, NULL, 5.0f, this->actor.world.rot.y, 0.0f, 8); } } } @@ -476,22 +477,22 @@ void func_80BE5818(Actor* thisx, GlobalContext* globalCtx2) { } } -void EnTanron5_Draw(Actor* thisx, GlobalContext* globalCtx) { +void EnTanron5_Draw(Actor* thisx, PlayState* play) { EnTanron5* this = THIS; if ((-500.0f * D_80BE5DD0) < this->actor.projectedPos.z) { - OPEN_DISPS(globalCtx->state.gfxCtx); + OPEN_DISPS(play->state.gfxCtx); - func_8012C28C(globalCtx->state.gfxCtx); + func_8012C28C(play->state.gfxCtx); - gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_OPA_DISP++, this->unk_148); - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->state.gfxCtx); } } -void func_80BE5C10(Actor* thisx, GlobalContext* globalCtx) { +void func_80BE5C10(Actor* thisx, PlayState* play) { EnTanron5* this = THIS; TexturePtr texture; s32 phi_v0; @@ -503,9 +504,9 @@ void func_80BE5C10(Actor* thisx, GlobalContext* globalCtx) { } if (((-500.0f * D_80BE5DD0) < this->actor.projectedPos.z) && phi_v0) { - OPEN_DISPS(globalCtx->state.gfxCtx); + OPEN_DISPS(play->state.gfxCtx); - func_8012C28C(globalCtx->state.gfxCtx); + func_8012C28C(play->state.gfxCtx); if (this->unk_1A0 == 0) { texture = gameplay_keep_Tex_05BEF0; } else { @@ -516,12 +517,12 @@ void func_80BE5C10(Actor* thisx, GlobalContext* globalCtx) { gSPSegment(POLY_OPA_DISP++, 0x08, Lib_SegmentedToVirtual(texture)); - Matrix_InsertTranslation(0.0f, 200.0f, 0.0f, MTXMODE_APPLY); - Matrix_InsertZRotation_s(this->unk_198, MTXMODE_APPLY); + 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); + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_OPA_DISP++, gameplay_keep_DL_05F6F0); - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->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 576309694..9f9e47021 100644 --- a/src/overlays/actors/ovl_En_Tanron5/z_en_tanron5.h +++ b/src/overlays/actors/ovl_En_Tanron5/z_en_tanron5.h @@ -15,14 +15,14 @@ struct EnTanron5; typedef struct EnTanron5 { /* 0x000 */ Actor actor; - /* 0x0144 */ s16 unk_144; - /* 0x0148 */ Gfx* unk_148; - /* 0x014C */ ColliderCylinder collider; - /* 0x0198 */ s16 unk_198; - /* 0x019A */ s16 unk_19A; - /* 0x019C */ f32 unk_19C; - /* 0x01A0 */ u8 unk_1A0; - /* 0x01A1 */ u8 unk_1A1; + /* 0x144 */ s16 unk_144; + /* 0x148 */ Gfx* unk_148; + /* 0x14C */ ColliderCylinder collider; + /* 0x198 */ s16 unk_198; + /* 0x19A */ s16 unk_19A; + /* 0x19C */ f32 unk_19C; + /* 0x1A0 */ u8 unk_1A0; + /* 0x1A1 */ u8 unk_1A1; } EnTanron5; // size = 0x1A4 extern const ActorInit En_Tanron5_InitVars; diff --git a/src/overlays/actors/ovl_En_Tanron6/z_en_tanron6.c b/src/overlays/actors/ovl_En_Tanron6/z_en_tanron6.c index bb57ff92f..45459e8b3 100644 --- a/src/overlays/actors/ovl_En_Tanron6/z_en_tanron6.c +++ b/src/overlays/actors/ovl_En_Tanron6/z_en_tanron6.c @@ -10,13 +10,13 @@ #define THIS ((EnTanron6*)thisx) -void EnTanron6_Init(Actor* thisx, GlobalContext* globalCtx); -void EnTanron6_Destroy(Actor* thisx, GlobalContext* globalCtx); -void EnTanron6_Update(Actor* thisx, GlobalContext* globalCtx); -void EnTanron6_Draw(Actor* thisx, GlobalContext* globalCtx); +void EnTanron6_Init(Actor* thisx, PlayState* play); +void EnTanron6_Destroy(Actor* thisx, PlayState* play); +void EnTanron6_Update(Actor* thisx, PlayState* play); +void EnTanron6_Draw(Actor* thisx, PlayState* play); void EnTanron6_DoNothing(EnTanron6* this); -void func_80BE60D0(EnTanron6* this, GlobalContext* globalCtx); +void func_80BE60D0(EnTanron6* this, PlayState* play); const ActorInit En_Tanron6_InitVars = { ACTOR_EN_TANRON6, @@ -65,7 +65,7 @@ static DamageTable sDamageTable = { /* Powder Keg */ DMG_ENTRY(0, 0xF), }; -void EnTanron6_Init(Actor* thisx, GlobalContext* globalCtx) { +void EnTanron6_Init(Actor* thisx, PlayState* play) { EnTanron6* this = THIS; this->actor.colChkInfo.mass = 10; @@ -76,23 +76,23 @@ void EnTanron6_Init(Actor* thisx, GlobalContext* globalCtx) { EnTanron6_DoNothing(this); } -void EnTanron6_Destroy(Actor* thisx, GlobalContext* globalCtx) { +void EnTanron6_Destroy(Actor* thisx, PlayState* play) { } void EnTanron6_DoNothing(EnTanron6* this) { this->actionFunc = func_80BE60D0; } -void func_80BE60D0(EnTanron6* this, GlobalContext* globalCtx) { +void func_80BE60D0(EnTanron6* this, PlayState* play) { } -void EnTanron6_Update(Actor* thisx, GlobalContext* globalCtx) { +void EnTanron6_Update(Actor* thisx, PlayState* play) { EnTanron6* this = THIS; - this->actionFunc(this, globalCtx); + this->actionFunc(this, play); Actor_MoveWithGravity(&this->actor); - Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 10.0f, 40.0f, 40.0f, 0x1D); + Actor_UpdateBgCheckInfo(play, &this->actor, 10.0f, 40.0f, 40.0f, 0x1D); } -void EnTanron6_Draw(Actor* thisx, GlobalContext* globalCtx) { +void EnTanron6_Draw(Actor* thisx, PlayState* play) { } diff --git a/src/overlays/actors/ovl_En_Tanron6/z_en_tanron6.h b/src/overlays/actors/ovl_En_Tanron6/z_en_tanron6.h index 7a1c60e25..fb565a5c8 100644 --- a/src/overlays/actors/ovl_En_Tanron6/z_en_tanron6.h +++ b/src/overlays/actors/ovl_En_Tanron6/z_en_tanron6.h @@ -5,11 +5,11 @@ struct EnTanron6; -typedef void (*EnTanron6ActionFunc)(struct EnTanron6*, GlobalContext*); +typedef void (*EnTanron6ActionFunc)(struct EnTanron6*, PlayState*); typedef struct EnTanron6 { /* 0x000 */ Actor actor; - /* 0x144 */ char unk_144[0xBC]; + /* 0x144 */ UNK_TYPE1 unk_144[0xBC]; /* 0x200 */ EnTanron6ActionFunc actionFunc; } EnTanron6; // size = 0x204 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 7f99833b4..af2824c69 100644 --- a/src/overlays/actors/ovl_En_Test/z_en_test.c +++ b/src/overlays/actors/ovl_En_Test/z_en_test.c @@ -11,10 +11,10 @@ #define THIS ((EnTest*)thisx) -void EnTest_Init(Actor* thisx, GlobalContext* globalCtx); -void EnTest_Destroy(Actor* thisx, GlobalContext* globalCtx); -void EnTest_Update(Actor* thisx, GlobalContext* globalCtx); -void EnTest_Draw(Actor* thisx, GlobalContext* globalCtx); +void EnTest_Init(Actor* thisx, PlayState* play); +void EnTest_Destroy(Actor* thisx, PlayState* play); +void EnTest_Update(Actor* thisx, PlayState* play); +void EnTest_Draw(Actor* thisx, PlayState* play); const ActorInit En_Test_InitVars = { ACTOR_EN_TEST, @@ -126,14 +126,14 @@ void func_80862EDC(EnTestStruct* arg0) { } } -void func_80863048(GlobalContext* globalCtx, EnTestStruct* arg1) { +void func_80863048(PlayState* play, EnTestStruct* arg1) { EnTestStruct* ptr; s32 i; Mtx* mtx; - OPEN_DISPS(globalCtx->state.gfxCtx); + OPEN_DISPS(play->state.gfxCtx); - func_8012C28C(globalCtx->state.gfxCtx); + func_8012C28C(play->state.gfxCtx); gDPSetPrimColor(POLY_OPA_DISP++, 0, 0x80, 255, 255, 255, 255); gDPSetEnvColor(POLY_OPA_DISP++, 255, 255, 255, 255); @@ -145,20 +145,20 @@ void func_80863048(GlobalContext* globalCtx, EnTestStruct* arg1) { continue; } - Matrix_InsertTranslation(ptr->unk_08.x, ptr->unk_08.y, ptr->unk_08.z, MTXMODE_NEW); - Matrix_InsertRotation(ptr->unk_30.x, ptr->unk_30.y, ptr->unk_30.z, MTXMODE_APPLY); + Matrix_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); + mtx = Matrix_NewMtx(play->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); + CLOSE_DISPS(play->state.gfxCtx); } -void EnTest_Init(Actor* thisx, GlobalContext* globalCtx2) { - GlobalContext* globalCtx = globalCtx2; +void EnTest_Init(Actor* thisx, PlayState* play2) { + PlayState* play = play2; EnTest* this = THIS; MtxF sp38; s32 sp34; @@ -172,8 +172,7 @@ void EnTest_Init(Actor* thisx, GlobalContext* globalCtx2) { } else { thisx->floorPoly = NULL; thisx->world.pos.y += 10.0f; - thisx->floorHeight = - BgCheck_EntityRaycastFloor3(&globalCtx->colCtx, &thisx->floorPoly, &sp34, &thisx->world.pos); + thisx->floorHeight = BgCheck_EntityRaycastFloor3(&play->colCtx, &thisx->floorPoly, &sp34, &thisx->world.pos); if ((thisx->floorPoly == NULL) || (thisx->floorHeight == BGCHECK_Y_MIN)) { Actor_MarkForDeath(thisx); @@ -182,9 +181,9 @@ void EnTest_Init(Actor* thisx, GlobalContext* globalCtx2) { thisx->world.pos.y = thisx->floorHeight; func_800C0094(thisx->floorPoly, thisx->world.pos.x, thisx->floorHeight, thisx->world.pos.z, &sp38); - func_8018219C(&sp38, &thisx->shape.rot, 1); + Matrix_MtxFToYXZRot(&sp38, &thisx->shape.rot, true); thisx->world.rot = thisx->shape.rot; - this->unk_20A = func_800C9BB8(&globalCtx->colCtx, thisx->floorPoly, sp34); + this->unk_20A = func_800C9BB8(&play->colCtx, thisx->floorPoly, sp34); } func_80183430(&this->skeletonInfo, &gameplay_keep_Blob_06EB70, &gameplay_keep_Blob_06BB0C, this->unk_178, @@ -194,13 +193,13 @@ void EnTest_Init(Actor* thisx, GlobalContext* globalCtx2) { func_80862B70(this->unk_20C); } -void EnTest_Destroy(Actor* thisx, GlobalContext* globalCtx) { +void EnTest_Destroy(Actor* thisx, PlayState* play) { EnTest* this = THIS; func_8018349C(&this->skeletonInfo); } -void EnTest_Update(Actor* thisx, GlobalContext* globalCtx) { +void EnTest_Update(Actor* thisx, PlayState* play) { EnTest* this = THIS; s32 i; @@ -225,11 +224,11 @@ void EnTest_Update(Actor* thisx, GlobalContext* globalCtx) { 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) { +s32 EnTest_OverrideKeyframeDraw(PlayState* play, SkeletonInfo* skeletonInfo, s32 limbIndex, Gfx** dList, u8* flags, + Actor* thisx, Vec3f* scale, Vec3s* rot, Vec3f* pos) { EnTest* this = THIS; - OPEN_DISPS(globalCtx->state.gfxCtx); + OPEN_DISPS(play->state.gfxCtx); if ((this->actor.params == -1) && ((limbIndex == 1) || (limbIndex == 2))) { *dList = NULL; @@ -244,12 +243,12 @@ s32 EnTest_OverrideKeyframeDraw(GlobalContext* globalCtx, SkeletonInfo* skeleton gDPSetEnvColor(POLY_XLU_DISP++, 0, 0, 0, ((20 - this->unk_209) * 255.0f) / 20.0f); } - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->state.gfxCtx); return true; } -void EnTest_Draw(Actor* thisx, GlobalContext* globalCtx) { +void EnTest_Draw(Actor* thisx, PlayState* play) { EnTest* this = THIS; Mtx* sp28; s32 sp2C = this->unk_208 - 1; @@ -259,16 +258,16 @@ void EnTest_Draw(Actor* thisx, GlobalContext* globalCtx) { } if ((this->unk_20A == 15) || (this->unk_20A == 14)) { - AnimatedMat_DrawStep(globalCtx, Lib_SegmentedToVirtual(gameplay_keep_Matanimheader_06B730), sp2C); + AnimatedMat_DrawStep(play, Lib_SegmentedToVirtual(gameplay_keep_Matanimheader_06B730), sp2C); } else { - AnimatedMat_DrawStep(globalCtx, Lib_SegmentedToVirtual(gameplay_keep_Matanimheader_06B6A0), sp2C); + AnimatedMat_DrawStep(play, Lib_SegmentedToVirtual(gameplay_keep_Matanimheader_06B6A0), sp2C); } - sp28 = GRAPH_ALLOC(globalCtx->state.gfxCtx, ALIGN16(this->skeletonInfo.unk_18->unk_1 * sizeof(Mtx))); + sp28 = GRAPH_ALLOC(play->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); + func_8012C2DC(play->state.gfxCtx); + func_8018450C(play, &this->skeletonInfo, sp28, EnTest_OverrideKeyframeDraw, NULL, thisx); + func_80863048(play, 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 bcb0c4a1e..e01c44c6a 100644 --- a/src/overlays/actors/ovl_En_Test/z_en_test.h +++ b/src/overlays/actors/ovl_En_Test/z_en_test.h @@ -21,7 +21,7 @@ typedef struct EnTest { /* 0x144 */ SkeletonInfo skeletonInfo; /* 0x174 */ s32 unk_174; /* 0x178 */ Vec3s unk_178[12]; - /* 0x1C0 */ s16 unk_1C0[36]; + /* 0x1C0 */ Vec3s unk_1C0[12]; /* 0x208 */ u8 unk_208; /* 0x209 */ u8 unk_209; /* 0x20A */ u8 unk_20A; diff --git a/src/overlays/actors/ovl_En_Test2/z_en_test2.c b/src/overlays/actors/ovl_En_Test2/z_en_test2.c index c16a4133d..4a051fc23 100644 --- a/src/overlays/actors/ovl_En_Test2/z_en_test2.c +++ b/src/overlays/actors/ovl_En_Test2/z_en_test2.c @@ -5,15 +5,28 @@ */ #include "z_en_test2.h" +#include "objects/object_dekucity_ana_obj/object_dekucity_ana_obj.h" +#include "objects/object_sichitai_obj/object_sichitai_obj.h" +#include "objects/object_yukimura_obj/object_yukimura_obj.h" +#include "objects/object_hakugin_obj/object_hakugin_obj.h" +#include "objects/object_meganeana_obj/object_meganeana_obj.h" +#include "objects/object_haka_obj/object_haka_obj.h" #define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_80) #define THIS ((EnTest2*)thisx) -void EnTest2_Init(Actor* thisx, GlobalContext* globalCtx); -void EnTest2_Update(Actor* thisx, GlobalContext* globalCtx); +void EnTest2_Init(Actor* thisx, PlayState* play); +void EnTest2_Update(Actor* thisx, PlayState* play); +void EnTest2_UpdateForLens(Actor* thisx, PlayState* play); +void EnTest2_Draw(Actor* thisx, PlayState* play); + +typedef struct EnTest2ModelInfo { + /* 0x0 */ Gfx* dList1; + /* 0x4 */ Gfx* dList2; + /* 0x8 */ AnimatedMaterial* animMat; +} EnTest2ModelInfo; // size = 0xC -#if 0 const ActorInit En_Test2_InitVars = { ACTOR_EN_TEST2, ACTORCAT_BG, @@ -26,22 +39,105 @@ const ActorInit En_Test2_InitVars = { (ActorFunc)NULL, }; -// static InitChainEntry sInitChain[] = { -static InitChainEntry D_80A3E74C[] = { +static EnTest2ModelInfo sModelInfo[] = { + { object_dekucity_ana_obj_DL_000040, NULL, NULL }, + { object_sichitai_obj_DL_001820, NULL, NULL }, + { object_yukimura_obj_DL_0008C0, NULL, NULL }, + { object_hakugin_obj_DL_0016D8, NULL, object_hakugin_obj_Matanimheader_0017A8 }, + { object_hakugin_obj_DL_002018, NULL, object_hakugin_obj_Matanimheader_0020E8 }, + { object_hakugin_obj_DL_005268, NULL, object_hakugin_obj_Matanimheader_005338 }, + { object_meganeana_obj_DL_000110, object_meganeana_obj_DL_000080, NULL }, + { object_haka_obj_DL_000F70, NULL, NULL }, + { object_haka_obj_DL_001200, NULL, NULL }, + { object_hakugin_obj_DL_004928, NULL, object_hakugin_obj_Matanimheader_0049F8 }, + { object_hakugin_obj_DL_002978, NULL, object_hakugin_obj_Matanimheader_002A58 }, + { object_hakugin_obj_DL_000D38, NULL, object_hakugin_obj_Matanimheader_000E48 }, + { object_hakugin_obj_DL_0035A8, NULL, object_hakugin_obj_Matanimheader_003888 }, +}; + +static InitChainEntry sInitChain[] = { ICHAIN_VEC3F(scale, 1, ICHAIN_CONTINUE), ICHAIN_F32(uncullZoneForward, 8000, ICHAIN_CONTINUE), ICHAIN_F32(uncullZoneScale, 800, ICHAIN_CONTINUE), ICHAIN_F32(uncullZoneDownward, 2500, ICHAIN_STOP), }; -#endif +static s16 sObjectIds[] = { + OBJECT_DEKUCITY_ANA_OBJ, OBJECT_SICHITAI_OBJ, OBJECT_YUKIMURA_OBJ, OBJECT_HAKUGIN_OBJ, OBJECT_HAKUGIN_OBJ, + OBJECT_HAKUGIN_OBJ, OBJECT_MEGANEANA_OBJ, OBJECT_HAKA_OBJ, OBJECT_HAKA_OBJ, OBJECT_HAKUGIN_OBJ, + OBJECT_HAKUGIN_OBJ, OBJECT_HAKUGIN_OBJ, OBJECT_HAKUGIN_OBJ, +}; -extern InitChainEntry D_80A3E74C[]; +void EnTest2_Init(Actor* thisx, PlayState* play) { + EnTest2* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Test2/EnTest2_Init.s") + Actor_ProcessInitChain(&this->actor, sInitChain); + if ((this->actor.params == EN_TEST2_PARAMS_B) || (this->actor.params == EN_TEST2_PARAMS_C)) { + this->actor.flags |= ACTOR_FLAG_20; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Test2/EnTest2_Update.s") +void EnTest2_Update(Actor* thisx, PlayState* play) { + s32 pad; + s32 objectIndex; + EnTest2ModelInfo* modelInfo; + EnTest2* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Test2/func_80A3E4EC.s") + objectIndex = Object_GetIndex(&play->objectCtx, sObjectIds[this->actor.params]); + if (objectIndex < 0) { + Actor_MarkForDeath(&this->actor); + return; + } + if (Object_IsLoaded(&play->objectCtx, objectIndex)) { + modelInfo = &sModelInfo[this->actor.params]; + this->actor.objBankIndex = objectIndex; + this->actor.draw = EnTest2_Draw; + if (modelInfo->animMat != NULL) { + Actor_SetObjectDependency(play, &this->actor); + this->animMat = Lib_SegmentedToVirtual(modelInfo->animMat); + } + if (play->roomCtx.currRoom.unk5) { + this->actor.update = EnTest2_UpdateForLens; + } else { + this->actor.update = Actor_Noop; + } + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Test2/func_80A3E524.s") +void EnTest2_UpdateForLens(Actor* thisx, PlayState* play) { + EnTest2* this = THIS; + + if (play->actorCtx.unk4 == 100) { + this->actor.flags |= ACTOR_FLAG_80; + } else { + this->actor.flags &= ~ACTOR_FLAG_80; + } +} + +void EnTest2_Draw(Actor* thisx, PlayState* play) { + s32 pad; + EnTest2* this = THIS; + Gfx* dList = sModelInfo[this->actor.params].dList2; + + if (this->animMat != NULL) { + AnimatedMat_Draw(play, this->animMat); + } + if (CHECK_FLAG_ALL(this->actor.flags, ACTOR_FLAG_80)) { + OPEN_DISPS(play->state.gfxCtx); + + func_8012C2DC(play->state.gfxCtx); + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + + if (dList != NULL) { + gSPDisplayList(POLY_XLU_DISP++, dList); + } + gSPDisplayList(POLY_XLU_DISP++, sModelInfo[this->actor.params].dList1); + + CLOSE_DISPS(play->state.gfxCtx); + } else { + if (dList != NULL) { + Gfx_DrawDListXlu(play, dList); + } + Gfx_DrawDListOpa(play, sModelInfo[this->actor.params].dList1); + } +} diff --git a/src/overlays/actors/ovl_En_Test2/z_en_test2.h b/src/overlays/actors/ovl_En_Test2/z_en_test2.h index b8eabec2c..ccbba11e7 100644 --- a/src/overlays/actors/ovl_En_Test2/z_en_test2.h +++ b/src/overlays/actors/ovl_En_Test2/z_en_test2.h @@ -7,9 +7,14 @@ struct EnTest2; typedef struct EnTest2 { /* 0x000 */ Actor actor; - /* 0x144 */ char unk_144[0x4]; + /* 0x144 */ AnimatedMaterial* animMat; } EnTest2; // size = 0x148 +typedef enum { + /* 0xB */ EN_TEST2_PARAMS_B = 0xB, + /* 0xC */ EN_TEST2_PARAMS_C +} EnTest2_Params; + extern const ActorInit En_Test2_InitVars; #endif // Z_EN_TEST2_H 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 ce9a8f3c9..f50fca2e7 100644 --- a/src/overlays/actors/ovl_En_Test3/z_en_test3.c +++ b/src/overlays/actors/ovl_En_Test3/z_en_test3.c @@ -10,9 +10,9 @@ #define THIS ((EnTest3*)thisx) -void EnTest3_Init(Actor* thisx, GlobalContext* globalCtx); -void EnTest3_Destroy(Actor* thisx, GlobalContext* globalCtx); -void EnTest3_Update(Actor* thisx, GlobalContext* globalCtx); +void EnTest3_Init(Actor* thisx, PlayState* play); +void EnTest3_Destroy(Actor* thisx, PlayState* play); +void EnTest3_Update(Actor* thisx, PlayState* play); #if 0 const ActorInit En_Test3_InitVars = { diff --git a/src/overlays/actors/ovl_En_Test3/z_en_test3.h b/src/overlays/actors/ovl_En_Test3/z_en_test3.h index 10f1105f5..9d902bad1 100644 --- a/src/overlays/actors/ovl_En_Test3/z_en_test3.h +++ b/src/overlays/actors/ovl_En_Test3/z_en_test3.h @@ -5,13 +5,13 @@ struct EnTest3; -typedef void (*EnTest3ActionFunc)(struct EnTest3*, GlobalContext*); +typedef void (*EnTest3ActionFunc)(struct EnTest3*, PlayState*); typedef struct EnTest3 { - /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x628]; - /* 0x076C */ EnTest3ActionFunc actionFunc; - /* 0x0770 */ char unk_770[0x648]; + /* 0x000 */ Actor actor; + /* 0x144 */ char unk_144[0x628]; + /* 0x76C */ EnTest3ActionFunc actionFunc; + /* 0x770 */ char unk_770[0x648]; } EnTest3; // size = 0xDB8 extern const ActorInit En_Test3_InitVars; diff --git a/src/overlays/actors/ovl_En_Test4/z_en_test4.c b/src/overlays/actors/ovl_En_Test4/z_en_test4.c index 729a82a70..73309f615 100644 --- a/src/overlays/actors/ovl_En_Test4/z_en_test4.c +++ b/src/overlays/actors/ovl_En_Test4/z_en_test4.c @@ -12,12 +12,12 @@ #define THIS ((EnTest4*)thisx) -void EnTest4_Init(Actor* thisx, GlobalContext* globalCtx); -void EnTest4_Destroy(Actor* thisx, GlobalContext* globalCtx); -void EnTest4_Update(Actor* thisx, GlobalContext* globalCtx); +void EnTest4_Init(Actor* thisx, PlayState* play); +void EnTest4_Destroy(Actor* thisx, PlayState* play); +void EnTest4_Update(Actor* thisx, PlayState* play); -void func_80A42AB8(EnTest4* this, GlobalContext* globalCtx); -void func_80A42F20(EnTest4* this, GlobalContext* globalCtx); +void func_80A42AB8(EnTest4* this, PlayState* play); +void func_80A42F20(EnTest4* this, PlayState* play); const ActorInit En_Test4_InitVars = { ACTOR_EN_TEST4, @@ -45,28 +45,28 @@ static u16 D_80A43364[] = { CLOCK_TIME(6, 0), CLOCK_TIME(18, 0) }; static s16 sCutscenes[2]; static s16 sCurrentCs; -void func_80A41D70(EnTest4* this, GlobalContext* globalCtx) { +void func_80A41D70(EnTest4* this, PlayState* play) { if (this->unk_144 != 0) { - func_80151A68(globalCtx, sNightMessages1[CURRENT_DAY - 1]); - } else if ((sCutscenes[this->unk_144] < 0) || ((globalCtx->actorCtx.unk5 & 2) != 0)) { - if (globalCtx->actorCtx.unk5 & 2) { + func_80151A68(play, sNightMessages1[CURRENT_DAY - 1]); + } else if ((sCutscenes[this->unk_144] < 0) || ((play->actorCtx.unk5 & 2) != 0)) { + if (play->actorCtx.unk5 & 2) { Sram_IncrementDay(); gSaveContext.save.time = CLOCK_TIME(6, 0); - func_80151A68(globalCtx, sDayMessages1[CURRENT_DAY - 1]); + func_80151A68(play, sDayMessages1[CURRENT_DAY - 1]); } else { this->unk_144 = 0; this->unk_146 = gSaveContext.save.time += CLOCK_TIME_MINUTE; } - func_8010EE74(globalCtx, CURRENT_DAY); + func_8010EE74(play, CURRENT_DAY); D_801BDBC8 = 0xFE; - func_800FB758(globalCtx); - func_800FEAF4(&globalCtx->envCtx); + func_800FB758(play); + func_800FEAF4(&play->envCtx); this->actionFunc = func_80A42AB8; } if (gSaveContext.cutsceneTrigger == 0) { - if ((sCutscenes[this->unk_144] >= 0) && !(globalCtx->actorCtx.unk5 & 2)) { + if ((sCutscenes[this->unk_144] >= 0) && !(play->actorCtx.unk5 & 2)) { this->actionFunc = func_80A42F20; sCurrentCs = sCutscenes[this->unk_144]; this->transitionCsTimer = 0; @@ -88,22 +88,22 @@ void func_80A41D70(EnTest4* this, GlobalContext* globalCtx) { } } -void func_80A41FA4(EnTest4* this, GlobalContext* globalCtx) { +void func_80A41FA4(EnTest4* this, PlayState* play) { if (this->unk_144 != 0) { - func_80151A68(globalCtx, sNightMessages2[CURRENT_DAY - 1]); - } else if ((sCutscenes[this->unk_144] < 0) || ((globalCtx->actorCtx.unk5 & 2) != 0)) { + func_80151A68(play, sNightMessages2[CURRENT_DAY - 1]); + } else if ((sCutscenes[this->unk_144] < 0) || ((play->actorCtx.unk5 & 2) != 0)) { Sram_IncrementDay(); gSaveContext.save.time = CLOCK_TIME(6, 0); - func_8010EE74(globalCtx, CURRENT_DAY); - func_80151A68(globalCtx, sDayMessages2[CURRENT_DAY - 1]); + func_8010EE74(play, CURRENT_DAY); + func_80151A68(play, sDayMessages2[CURRENT_DAY - 1]); D_801BDBC8 = 0xFE; - func_800FB758(globalCtx); - func_800FEAF4(&globalCtx->envCtx); + func_800FB758(play); + func_800FEAF4(&play->envCtx); this->actionFunc = func_80A42AB8; } if (gSaveContext.cutsceneTrigger == 0) { - if ((sCutscenes[this->unk_144] >= 0) && ((globalCtx->actorCtx.unk5 & 2) == 0)) { + if ((sCutscenes[this->unk_144] >= 0) && ((play->actorCtx.unk5 & 2) == 0)) { this->actionFunc = func_80A42F20; sCurrentCs = sCutscenes[this->unk_144]; this->transitionCsTimer = 0; @@ -239,7 +239,7 @@ void func_80A42198(EnTest4* this) { } // Bells on first and second day -void func_80A425E4(EnTest4* this, GlobalContext* globalCtx) { +void func_80A425E4(EnTest4* this, PlayState* play) { gSaveContext.screenScale = 1000.0f; if ((gSaveContext.save.time >= CLOCK_TIME(6, 0)) && (gSaveContext.save.time < CLOCK_TIME(18, 0))) { @@ -277,7 +277,7 @@ void func_80A425E4(EnTest4* this, GlobalContext* globalCtx) { this->nextBellTime = CLOCK_TIME(17, 30); } - if ((sCutscenes[this->unk_144] < 0) || ((globalCtx->actorCtx.unk5 & 2) != 0) || (CURRENT_DAY == 3) || + if ((sCutscenes[this->unk_144] < 0) || ((play->actorCtx.unk5 & 2) != 0) || (CURRENT_DAY == 3) || (gSaveContext.save.time >= CLOCK_TIME(17, 0))) { gSaveContext.screenScale = 1000.0f; } @@ -287,10 +287,10 @@ void func_80A425E4(EnTest4* this, GlobalContext* globalCtx) { } } -void EnTest4_Init(Actor* thisx, GlobalContext* globalCtx) { +void EnTest4_Init(Actor* thisx, PlayState* play) { s32 dayTemp; EnTest4* this = THIS; - Player* player = GET_PLAYER(globalCtx); + Player* player = GET_PLAYER(play); s8 temp_v0 = this->actor.cutscene; sCutscenes[0] = temp_v0; @@ -316,10 +316,10 @@ void EnTest4_Init(Actor* thisx, GlobalContext* globalCtx) { gSaveContext.save.time = CLOCK_TIME(6, 0); gSaveContext.gameMode = 0; { - GameState* state = &globalCtx->state; + GameState* state = &play->state; state->running = false; } - SET_NEXT_GAMESTATE(&globalCtx->state, Daytelop_Init, DaytelopContext); + SET_NEXT_GAMESTATE(&play->state, Daytelop_Init, DaytelopContext); if (this && this && this) {} this->unk_144 = 1; gSaveContext.save.time = CLOCK_TIME(6, 0); @@ -334,9 +334,8 @@ void EnTest4_Init(Actor* thisx, GlobalContext* globalCtx) { } } 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) && - !(globalCtx->actorCtx.unk5 & 2)) { + func_80A41D70(this, play); + if ((gSaveContext.cutsceneTrigger == 0) && (sCutscenes[this->unk_144] >= 0) && !(play->actorCtx.unk5 & 2)) { player->stateFlags1 |= 0x200; } } else { @@ -353,24 +352,24 @@ void EnTest4_Init(Actor* thisx, GlobalContext* globalCtx) { if (CURRENT_DAY == 3) { func_80A42198(this); } else { - func_80A425E4(this, globalCtx); + func_80A425E4(this, play); } this->lastBellTime = gSaveContext.save.time; - if ((sCutscenes[this->unk_144] < 0) || (globalCtx->actorCtx.unk5 & 2)) { + if ((sCutscenes[this->unk_144] < 0) || (play->actorCtx.unk5 & 2)) { gSaveContext.screenScaleFlag = 0; gSaveContext.screenScale = 1000.0f; } } -void EnTest4_Destroy(Actor* thisx, GlobalContext* globalCtx) { +void EnTest4_Destroy(Actor* thisx, PlayState* play) { } -void func_80A42AB8(EnTest4* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); +void func_80A42AB8(EnTest4* this, PlayState* play) { + Player* player = GET_PLAYER(play); - if ((globalCtx->unk_18B4A == 0) && !Play_InCsMode(globalCtx) && (globalCtx->numSetupActors <= 0) && - (globalCtx->roomCtx.unk31 == 0) && (func_8016A168() == 0)) { + if ((play->transitionMode == TRANS_MODE_OFF) && !Play_InCsMode(play) && (play->numSetupActors <= 0) && + (play->roomCtx.unk31 == 0) && !Play_IsDebugCamEnabled()) { s16 temp_a2; u16 temp_a0 = D_80A43364[this->unk_144]; s16 temp_a3; @@ -384,28 +383,28 @@ void func_80A42AB8(EnTest4* this, GlobalContext* globalCtx) { if ((temp_a3 * temp_a2) <= 0) { gSaveContext.unk_3CA7 = 1; - if (globalCtx->actorCtx.unk5 & 0x4) { - globalCtx->actorCtx.unk5 &= ~0x4; + if (play->actorCtx.unk5 & 0x4) { + play->actorCtx.unk5 &= ~0x4; } if (temp_a0 != CLOCK_TIME(6, 0)) { - func_80A41FA4(this, globalCtx); + func_80A41FA4(this, play); } else if (temp_a0 == CLOCK_TIME(6, 0)) { if (CURRENT_DAY == 3) { - func_8011C808(globalCtx); + func_8011C808(play); Actor_MarkForDeath(&this->actor); gSaveContext.eventInf[1] |= 0x80; - } else if (((sCutscenes[this->unk_144] < 0) || (globalCtx->actorCtx.unk5 & 2)) && CURRENT_DAY != 3) { - func_80A41FA4(this, globalCtx); + } else if (((sCutscenes[this->unk_144] < 0) || (play->actorCtx.unk5 & 2)) && CURRENT_DAY != 3) { + func_80A41FA4(this, play); } else { 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); + Play_SetRespawnData(&play->state, RESPAWN_MODE_DOWN, Entrance_CreateFromSpawn(0), player->unk_3CE, + 0xBFF, &player->unk_3C0, player->unk_3CC); + func_80169EFC(&play->state); if (player->stateFlags1 & 0x800000) { EnHorse* rideActor = (EnHorse*)player->rideActor; - if ((rideActor->type == HORSE_EPONA) || (rideActor->type == HORSE_2)) { + if ((rideActor->type == HORSE_TYPE_EPONA) || (rideActor->type == HORSE_TYPE_2)) { if (CURRENT_DAY < 3) { D_801BDA9C = 1; } else { @@ -420,7 +419,7 @@ void func_80A42AB8(EnTest4* this, GlobalContext* globalCtx) { } } - if ((sCutscenes[this->unk_144] >= 0) && ((globalCtx->actorCtx.unk5 & 2) == 0)) { + if ((sCutscenes[this->unk_144] >= 0) && ((play->actorCtx.unk5 & 2) == 0)) { player->stateFlags1 |= 0x200; this->unk_146 = gSaveContext.save.time; } else { @@ -439,38 +438,38 @@ void func_80A42AB8(EnTest4* this, GlobalContext* globalCtx) { if (CURRENT_DAY == 3) { if ((this->nextBellTime == CLOCK_TIME(0, 0)) && ((gSaveContext.save.inventory.items[SLOT_OCARINA] == ITEM_NONE) || - (globalCtx->sceneNum == SCENE_CLOCKTOWER))) { + (play->sceneNum == SCENE_CLOCKTOWER))) { s32 playerParams; - u32 entranceIndex = gSaveContext.save.entranceIndex; + u32 entrance = gSaveContext.save.entrance; - if ((globalCtx->actorCtx.unk5 & 2)) { + if ((play->actorCtx.unk5 & 2)) { playerParams = 0xCFF; } else { playerParams = 0xBFF; } - Play_SetRespawnData(&globalCtx->state, RESTART_MODE_RETURN, entranceIndex, player->unk_3CE, - playerParams, &player->unk_3C0, player->unk_3CC); + Play_SetRespawnData(&play->state, RESPAWN_MODE_RETURN, entrance, player->unk_3CE, playerParams, + &player->unk_3C0, player->unk_3CC); - if ((globalCtx->sceneNum == SCENE_TENMON_DAI) || (globalCtx->sceneNum == SCENE_00KEIKOKU)) { - globalCtx->nextEntranceIndex = 0x5400; + if ((play->sceneNum == SCENE_TENMON_DAI) || (play->sceneNum == SCENE_00KEIKOKU)) { + play->nextEntrance = ENTRANCE(TERMINA_FIELD, 0); } else { - globalCtx->nextEntranceIndex = 0xD800; + play->nextEntrance = ENTRANCE(SOUTH_CLOCK_TOWN, 0); } gSaveContext.nextCutsceneIndex = 0xFFF1; - globalCtx->sceneLoadFlag = 0x14; - globalCtx->unk_1887F = 2; + play->transitionTrigger = TRANS_TRIGGER_START; + play->transitionType = TRANS_TYPE_02; player->stateFlags1 |= 0x200; Actor_MarkForDeath(&this->actor); } func_80A42198(this); } else { - func_80A425E4(this, globalCtx); + func_80A425E4(this, play); } } } } -void func_80A42F20(EnTest4* this, GlobalContext* globalCtx) { +void func_80A42F20(EnTest4* this, PlayState* play) { if (!this->transitionCsTimer) { if (sCurrentCs >= 0) { if (ActorCutscene_GetCanPlayNext(sCurrentCs) == 0) { @@ -492,11 +491,11 @@ void func_80A42F20(EnTest4* this, GlobalContext* globalCtx) { } } if (this->transitionCsTimer == 60) { - Player* player = GET_PLAYER(globalCtx); + Player* player = GET_PLAYER(play); gSaveContext.save.time += CLOCK_TIME_MINUTE; this->unk_146 = gSaveContext.save.time; - globalCtx->numSetupActors = -globalCtx->numSetupActors; + play->numSetupActors = -play->numSetupActors; player->stateFlags1 &= ~0x200; } } else { @@ -516,45 +515,45 @@ void func_80A42F20(EnTest4* this, GlobalContext* globalCtx) { } } -void func_80A430C8(EnTest4* this, GlobalContext* globalCtx) { +void func_80A430C8(EnTest4* this, PlayState* play) { if ((CURRENT_DAY == 2) && (gSaveContext.save.time >= CLOCK_TIME(7, 0)) && - (gSaveContext.save.time < CLOCK_TIME(17, 30)) && (globalCtx->envCtx.unk_F2[2] == 0)) { + (gSaveContext.save.time < CLOCK_TIME(17, 30)) && (play->envCtx.unk_F2[2] == 0)) { // rain? - D_801BDBB0 = 1; - func_800FD78C(globalCtx); - globalCtx->envCtx.unk_E3 = 1; - globalCtx->envCtx.unk_F2[0] = 0x3C; + gWeatherMode = 1; + func_800FD78C(play); + play->envCtx.unk_E3 = 1; + play->envCtx.unk_F2[0] = 0x3C; } else { - if (globalCtx->envCtx.unk_F2[0] != 0) { - if ((globalCtx->state.frames % 4) == 0) { - globalCtx->envCtx.unk_F2[0]--; - if ((globalCtx->envCtx.unk_F2[0]) == 8) { - func_800FD858(globalCtx); + if (play->envCtx.unk_F2[0] != 0) { + if ((play->state.frames % 4) == 0) { + play->envCtx.unk_F2[0]--; + if ((play->envCtx.unk_F2[0]) == 8) { + func_800FD858(play); } } } } - if (D_801BDBB0 == 1) { + if (gWeatherMode == 1) { this->state = TEST4_STATE_1; } } -void func_80A431C8(EnTest4* this, GlobalContext* globalCtx) { +void func_80A431C8(EnTest4* this, PlayState* play) { 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; - globalCtx->envCtx.unk_E3 = 2; + (play->envCtx.unk_F2[0] != 0)) || + (play->envCtx.unk_F2[2] != 0)) { + gWeatherMode = 0; + play->envCtx.unk_E3 = 2; } - if (D_801BDBB0 == 0) { + if (gWeatherMode == 0) { this->state = TEST4_STATE_0; } } -void func_80A4323C(EnTest4* this, GlobalContext* globalCtx) { +void func_80A4323C(EnTest4* this, PlayState* play) { s32 temp_v0 = (this->actor.params >> 0xA) * 0x64; if (temp_v0 > 0) { @@ -562,23 +561,23 @@ void func_80A4323C(EnTest4* this, GlobalContext* globalCtx) { } } -void EnTest4_Update(Actor* thisx, GlobalContext* globalCtx) { +void EnTest4_Update(Actor* thisx, PlayState* play) { EnTest4* this = THIS; - Player* player = GET_PLAYER(globalCtx); + Player* player = GET_PLAYER(play); if (!(player->stateFlags1 & 2)) { - this->actionFunc(this, globalCtx); + this->actionFunc(this, play); - if (func_800FE4B8(globalCtx) != 0) { + if (func_800FE4B8(play) != 0) { switch (this->state) { case TEST4_STATE_0: - func_80A430C8(this, globalCtx); + func_80A430C8(this, play); break; case TEST4_STATE_1: - func_80A431C8(this, globalCtx); + func_80A431C8(this, play); break; } } - func_80A4323C(this, globalCtx); + func_80A4323C(this, play); } } diff --git a/src/overlays/actors/ovl_En_Test4/z_en_test4.h b/src/overlays/actors/ovl_En_Test4/z_en_test4.h index 4927c337e..5f39f9f56 100644 --- a/src/overlays/actors/ovl_En_Test4/z_en_test4.h +++ b/src/overlays/actors/ovl_En_Test4/z_en_test4.h @@ -5,17 +5,17 @@ struct EnTest4; -typedef void (*EnTest4ActionFunc)(struct EnTest4*, GlobalContext*); +typedef void (*EnTest4ActionFunc)(struct EnTest4*, PlayState*); typedef struct EnTest4 { - /* 0x0000 */ Actor actor; - /* 0x0144 */ s8 unk_144; // 0 on night, 1 on day - /* 0x0145 */ u8 transitionCsTimer; - /* 0x0146 */ u16 unk_146; - /* 0x0148 */ u16 nextBellTime; // Next time the bell will sound - /* 0x014A */ u16 lastBellTime; // Last time the bell sounded - /* 0x014C */ u8 state; - /* 0x0150 */ EnTest4ActionFunc actionFunc; + /* 0x000 */ Actor actor; + /* 0x144 */ s8 unk_144; // 0 on night, 1 on day + /* 0x145 */ u8 transitionCsTimer; + /* 0x146 */ u16 unk_146; + /* 0x148 */ u16 nextBellTime; // Next time the bell will sound + /* 0x14A */ u16 lastBellTime; // Last time the bell sounded + /* 0x14C */ u8 state; + /* 0x150 */ EnTest4ActionFunc actionFunc; } EnTest4; // size = 0x154 typedef enum { diff --git a/src/overlays/actors/ovl_En_Test5/z_en_test5.c b/src/overlays/actors/ovl_En_Test5/z_en_test5.c index 4a93cf5e8..57db36ea6 100644 --- a/src/overlays/actors/ovl_En_Test5/z_en_test5.c +++ b/src/overlays/actors/ovl_En_Test5/z_en_test5.c @@ -10,10 +10,10 @@ #define THIS ((EnTest5*)thisx) -void EnTest5_Init(Actor* thisx, GlobalContext* globalCtx); -void EnTest5_Destroy(Actor* thisx, GlobalContext* globalCtx); -void EnTest5_Update(Actor* thisx, GlobalContext* globalCtx); -void EnTest5_HandleBottleAction(EnTest5* this, GlobalContext* globalCtx); +void EnTest5_Init(Actor* thisx, PlayState* play); +void EnTest5_Destroy(Actor* thisx, PlayState* play); +void EnTest5_Update(Actor* thisx, PlayState* play); +void EnTest5_HandleBottleAction(EnTest5* this, PlayState* play); void EnTest5_SetupAction(EnTest5* this, EnTest5ActionFunc actionFunc); const ActorInit En_Test5_InitVars = { @@ -32,15 +32,15 @@ void EnTest5_SetupAction(EnTest5* this, EnTest5ActionFunc actionFunc) { this->actionFunc = actionFunc; } -void EnTest5_Init(Actor* thisx, GlobalContext* globalCtx2) { - GlobalContext* globalCtx = globalCtx2; +void EnTest5_Init(Actor* thisx, PlayState* play2) { + PlayState* play = play2; EnTest5* this = THIS; WaterBox* water; f32 ySurface; // If not spawned above a water source, immediately despawn - if (!WaterBox_GetSurface1(globalCtx, &globalCtx->colCtx, this->actor.world.pos.x, this->actor.world.pos.z, - &ySurface, &water)) { + if (!WaterBox_GetSurface1(play, &play->colCtx, this->actor.world.pos.x, this->actor.world.pos.z, &ySurface, + &water)) { Actor_MarkForDeath(&this->actor); return; } @@ -52,19 +52,19 @@ void EnTest5_Init(Actor* thisx, GlobalContext* globalCtx2) { EnTest5_SetupAction(this, EnTest5_HandleBottleAction); } -void EnTest5_Destroy(Actor* thisx, GlobalContext* globalCtx) { +void EnTest5_Destroy(Actor* thisx, PlayState* play) { } -void EnTest5_HandleBottleAction(EnTest5* this, GlobalContext* globalCtx) { +void EnTest5_HandleBottleAction(EnTest5* this, PlayState* play) { Player* player; Vec3f playerPosRelativeToWater; - if (Actor_HasParent(&this->actor, globalCtx)) { + if (Actor_HasParent(&this->actor, play)) { this->actor.parent = NULL; return; } - player = GET_PLAYER(globalCtx); + player = GET_PLAYER(play); if (player->interactRangeActor == NULL || player->getItemId != GI_MAX) { Math_Vec3f_DistXYZAndStoreDiff(&this->minPos, &player->actor.world.pos, &playerPosRelativeToWater); @@ -73,28 +73,27 @@ void EnTest5_HandleBottleAction(EnTest5* this, GlobalContext* globalCtx) { if (playerPosRelativeToWater.x >= 0.0f && playerPosRelativeToWater.x <= this->xLength && playerPosRelativeToWater.z >= 0.0f && playerPosRelativeToWater.z <= this->zLength && fabsf(playerPosRelativeToWater.y) < 100.0f && player->actor.depthInWater > 12.0f) { - Actor_PickUp(&this->actor, globalCtx, GI_MAX, this->actor.xzDistToPlayer, - fabsf(this->actor.playerHeightRel)); + Actor_PickUp(&this->actor, play, GI_MAX, this->actor.xzDistToPlayer, fabsf(this->actor.playerHeightRel)); } } } -void EnTest5_Update(Actor* thisx, GlobalContext* globalCtx2) { - GlobalContext* globalCtx = globalCtx2; +void EnTest5_Update(Actor* thisx, PlayState* play2) { + PlayState* play = play2; EnTest5* this = THIS; Vec3f steamPos; CollisionPoly* poly; s32 pad; - this->actionFunc(this, globalCtx); + this->actionFunc(this, play); // If it's the hot spring variant, generate steam clouds - if (ENTEST5_IS_HOT_SPRING(&this->actor) && (globalCtx->state.frames % 4) == 0) { + if (ENTEST5_IS_HOT_SPRING(&this->actor) && (play->state.frames % 4) == 0) { steamPos.x = (Rand_ZeroOne() * this->xLength) + this->minPos.x; steamPos.y = this->minPos.y + 100.0f; steamPos.z = (Rand_ZeroOne() * this->zLength) + this->minPos.z; - if ((BgCheck_EntityRaycastFloor2(globalCtx, &globalCtx->colCtx, &poly, &steamPos) + 10.0f) < this->minPos.y) { + if ((BgCheck_EntityRaycastFloor2(play, &play->colCtx, &poly, &steamPos) + 10.0f) < this->minPos.y) { Vec3f steamVel; steamPos.y = this->minPos.y + 10.0f; @@ -102,7 +101,7 @@ void EnTest5_Update(Actor* thisx, GlobalContext* globalCtx2) { steamVel.x = 0.0f; steamVel.z = 0.0f; - EffectSsIceSmoke_Spawn(globalCtx, &steamPos, &steamVel, &gZeroVec3f, + EffectSsIceSmoke_Spawn(play, &steamPos, &steamVel, &gZeroVec3f, (s16)((-200) - (s32)(Rand_ZeroOne() * 50.0f))); } } diff --git a/src/overlays/actors/ovl_En_Test5/z_en_test5.h b/src/overlays/actors/ovl_En_Test5/z_en_test5.h index 539f5b3c2..bcfcd98e3 100644 --- a/src/overlays/actors/ovl_En_Test5/z_en_test5.h +++ b/src/overlays/actors/ovl_En_Test5/z_en_test5.h @@ -7,14 +7,14 @@ struct EnTest5; // SpringWaterModifier -typedef void (*EnTest5ActionFunc)(struct EnTest5*, GlobalContext*); +typedef void (*EnTest5ActionFunc)(struct EnTest5*, PlayState*); typedef struct EnTest5 { - /* 0x0000 */ Actor actor; - /* 0x0144 */ Vec3f minPos; - /* 0x0150 */ f32 xLength; - /* 0x0154 */ f32 zLength; - /* 0x0158 */ EnTest5ActionFunc actionFunc; + /* 0x000 */ Actor actor; + /* 0x144 */ Vec3f minPos; + /* 0x150 */ f32 xLength; + /* 0x154 */ f32 zLength; + /* 0x158 */ EnTest5ActionFunc actionFunc; } EnTest5; // size = 0x15C extern const ActorInit En_Test5_InitVars; diff --git a/src/overlays/actors/ovl_En_Test6/z_en_test6.c b/src/overlays/actors/ovl_En_Test6/z_en_test6.c index de1a18241..82af65e3c 100644 --- a/src/overlays/actors/ovl_En_Test6/z_en_test6.c +++ b/src/overlays/actors/ovl_En_Test6/z_en_test6.c @@ -11,14 +11,14 @@ #define THIS ((EnTest6*)thisx) -void EnTest6_Init(Actor* thisx, GlobalContext* globalCtx); -void EnTest6_Destroy(Actor* thisx, GlobalContext* globalCtx); -void EnTest6_Update(Actor* thisx, GlobalContext* globalCtx); -void EnTest6_Draw(Actor* thisx, GlobalContext* globalCtx); +void EnTest6_Init(Actor* thisx, PlayState* play); +void EnTest6_Destroy(Actor* thisx, PlayState* play); +void EnTest6_Update(Actor* thisx, PlayState* play); +void EnTest6_Draw(Actor* thisx, PlayState* play); struct EnTest6Struct; -typedef void (*EnTest6StructFunc)(EnTest6*, GlobalContext*, struct EnTest6Struct*); +typedef void (*EnTest6StructFunc)(EnTest6*, PlayState*, struct EnTest6Struct*); typedef struct EnTest6Struct { /* 0x00 */ s32 unk_00; @@ -29,15 +29,15 @@ typedef struct EnTest6Struct { /* 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 func_80A90D34(EnTest6* this, PlayState* play, EnTest6Struct* ptr); +void func_80A90FC0(EnTest6* this, PlayState* play, 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 func_80A9156C(EnTest6* this, PlayState* play); +void func_80A91690(EnTest6* this, PlayState* play); +void func_80A91760(EnTest6* this, PlayState* play); +void func_80A920C8(EnTest6* this, PlayState* play); +void func_80A92188(EnTest6* this, PlayState* play); +void func_80A92950(EnTest6* this, PlayState* play); EnTest6Struct D_80A94910[12]; @@ -96,7 +96,7 @@ Color_RGB8 D_80A94050 = { 0, 0, 0 }; s16 D_80A94054 = 500; s16 D_80A94058 = 1500; -Vec3f D_80A9405C = { 0.0f, 1.0f, 0.0f }; +static Vec3f sSubCamUp = { 0.0f, 1.0f, 0.0f }; Color_RGB8 D_80A94068 = { 225, 230, 225 }; Color_RGB8 D_80A9406C = { 120, 120, 100 }; @@ -105,9 +105,9 @@ Color_RGB8 D_80A94070 = { 0, 0, 0 }; s16 D_80A94074 = 940; s16 D_80A94078 = 2000; -void func_80A90730(EnTest6* this, GlobalContext* globalCtx) { +void func_80A90730(EnTest6* this, PlayState* play) { s32 i; - Player* player = GET_PLAYER(globalCtx); + Player* player = GET_PLAYER(play); s32 phi_s0; f32 phi_f24; @@ -117,13 +117,13 @@ void func_80A90730(EnTest6* this, GlobalContext* globalCtx) { switch (ENTEST6_GET(&this->actor)) { case ENTEST6_24: case ENTEST6_25: - func_80A91690(this, globalCtx); - ActorCutscene_SetIntentToPlay(globalCtx->playerActorCsIds[8]); + func_80A91690(this, play); + ActorCutscene_SetIntentToPlay(play->playerActorCsIds[8]); return; case ENTEST6_26: - func_80A920C8(this, globalCtx); - ActorCutscene_SetIntentToPlay(globalCtx->playerActorCsIds[8]); + func_80A920C8(this, play); + ActorCutscene_SetIntentToPlay(play->playerActorCsIds[8]); return; } @@ -196,56 +196,56 @@ void func_80A90C34(void) { func_80165690(); } -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; +void func_80A90C54(PlayState* play, f32 arg1) { + play->envCtx.fillScreen = 1; + play->envCtx.screenFillColor[0] = 250; + play->envCtx.screenFillColor[1] = 250; + play->envCtx.screenFillColor[2] = 250; + play->envCtx.screenFillColor[3] = 255.0f * arg1; } -void func_80A90D20(GlobalContext* globalCtx) { - globalCtx->envCtx.fillScreen = 0; +void func_80A90D20(PlayState* play) { + play->envCtx.fillScreen = 0; } -void func_80A90D34(EnTest6* this, GlobalContext* globalCtx, EnTest6Struct* ptr) { +void func_80A90D34(EnTest6* this, PlayState* play, EnTest6Struct* ptr) { s32 pad; - OPEN_DISPS(globalCtx->state.gfxCtx); + OPEN_DISPS(play->state.gfxCtx); if (ptr->unk_00 != 0) { - Matrix_InsertTranslation(ptr->unk_08 * ptr->unk_04, ptr->unk_0C, ptr->unk_10 * ptr->unk_04, MTXMODE_NEW); + Matrix_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_801660B8(play, 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); + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_OPA_DISP++, gameplay_keep_DL_05F6F0); } - Matrix_InsertTranslation(ptr->unk_08 * ptr->unk_04, ptr->unk_0C, ptr->unk_10 * ptr->unk_04, MTXMODE_NEW); + 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_InsertMatrix(&globalCtx->billboardMtxF, MTXMODE_APPLY); - Matrix_InsertZRotation_s(globalCtx->state.frames * 512, MTXMODE_APPLY); - Matrix_InsertTranslation(0.0f, 0.0f, 2.0f, MTXMODE_APPLY); + Matrix_Mult(&play->billboardMtxF, MTXMODE_APPLY); + Matrix_RotateZS(play->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); + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - func_8012C2DC(globalCtx->state.gfxCtx); + func_8012C2DC(play->state.gfxCtx); gDPSetPrimColor(POLY_XLU_DISP++, 0x80, 0x80, 210, 210, 230, 128); gDPSetEnvColor(POLY_XLU_DISP++, 255, 255, 255, 0); gSPClearGeometryMode(POLY_XLU_DISP++, G_FOG | G_LIGHTING); - gSPDisplayList(POLY_XLU_DISP++, gameplay_keep_DL_054A90); + gSPDisplayList(POLY_XLU_DISP++, gEffSparklesDL); gSPSetGeometryMode(POLY_XLU_DISP++, G_FOG | G_LIGHTING); - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->state.gfxCtx); } -void func_80A90FC0(EnTest6* this, GlobalContext* globalCtx, EnTest6Struct* ptr) { +void func_80A90FC0(EnTest6* this, PlayState* play, EnTest6Struct* ptr) { s32 pad; - Gfx* gfx = GRAPH_ALLOC(globalCtx->state.gfxCtx, sizeof(Gfx) * 2); + Gfx* gfx = GRAPH_ALLOC(play->state.gfxCtx, sizeof(Gfx) * 2); Gfx* gfx2 = gfx; Hilite* sp70; Vec3f sp64; @@ -254,12 +254,12 @@ void func_80A90FC0(EnTest6* this, GlobalContext* globalCtx, EnTest6Struct* ptr) sp64.y = ptr->unk_0C; sp64.z = ptr->unk_10 * ptr->unk_04; - sp70 = func_800BCBF4(&sp64, globalCtx); + sp70 = func_800BCBF4(&sp64, play); - OPEN_DISPS(globalCtx->state.gfxCtx); + OPEN_DISPS(play->state.gfxCtx); if (gfx != NULL) { - func_8012C28C(globalCtx->state.gfxCtx); + func_8012C28C(play->state.gfxCtx); gDPSetTileSize(gfx++, 1, sp70->h.x1 & 0xFFFF, sp70->h.y1 & 0xFFFF, (sp70->h.x1 + 60) & 0xFFFF, (sp70->h.y1 + 60) & 0xFFFF); @@ -267,46 +267,46 @@ void func_80A90FC0(EnTest6* this, GlobalContext* globalCtx, EnTest6Struct* ptr) gSPSegment(POLY_OPA_DISP++, 0x07, gfx2); - Matrix_InsertTranslation(sp64.x, sp64.y, sp64.z, MTXMODE_NEW); + 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_InsertMatrix(&globalCtx->billboardMtxF, MTXMODE_APPLY); + Matrix_Mult(&play->billboardMtxF, MTXMODE_APPLY); - gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPSegment(POLY_OPA_DISP++, 0x08, Lib_SegmentedToVirtual(D_80A9402C[ptr->unk_00])); gSPDisplayList(POLY_OPA_DISP++, gameplay_keep_DL_0622C0); } - Matrix_InsertTranslation(ptr->unk_08 * ptr->unk_04, ptr->unk_0C, ptr->unk_10 * ptr->unk_04, MTXMODE_NEW); + Matrix_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_InsertMatrix(&globalCtx->billboardMtxF, MTXMODE_APPLY); - Matrix_InsertZRotation_s(globalCtx->state.frames * 256, MTXMODE_APPLY); - Matrix_InsertTranslation(0.0f, 0.0f, 4.0f, MTXMODE_APPLY); + Matrix_Mult(&play->billboardMtxF, MTXMODE_APPLY); + Matrix_RotateZS(play->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); + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - func_8012C2DC(globalCtx->state.gfxCtx); + func_8012C2DC(play->state.gfxCtx); gDPSetPrimColor(POLY_XLU_DISP++, 0x80, 0x80, 220, 220, 230, 192); gDPSetEnvColor(POLY_XLU_DISP++, 128, 128, 128, 0); gSPClearGeometryMode(POLY_XLU_DISP++, G_FOG | G_LIGHTING); - gSPDisplayList(POLY_XLU_DISP++, gameplay_keep_DL_054A90); + gSPDisplayList(POLY_XLU_DISP++, gEffSparklesDL); gSPSetGeometryMode(POLY_XLU_DISP++, G_FOG | G_LIGHTING); - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->state.gfxCtx); } void EnTest6_SetupAction(EnTest6* this, EnTest6ActionFunc actionFunc) { this->actionFunc = actionFunc; } -void EnTest6_Init(Actor* thisx, GlobalContext* globalCtx2) { - GlobalContext* globalCtx = globalCtx2; +void EnTest6_Init(Actor* thisx, PlayState* play2) { + PlayState* play = play2; 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)) { + (play->playerActorCsIds[8] == -1)) { Actor_MarkForDeath(&this->actor); return; } @@ -314,62 +314,62 @@ void EnTest6_Init(Actor* thisx, GlobalContext* globalCtx2) { 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->lights[i].node = LightContext_InsertLight(play, &play->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); + func_80A90730(this, play); EnTest6_SetupAction(this, func_80A9156C); } -void EnTest6_Destroy(Actor* thisx, GlobalContext* globalCtx2) { - GlobalContext* globalCtx = globalCtx2; +void EnTest6_Destroy(Actor* thisx, PlayState* play2) { + PlayState* play = play2; 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; + play->envCtx.lightSettings.ambientColor[0] = 0; + play->envCtx.lightSettings.ambientColor[1] = 0; + play->envCtx.lightSettings.ambientColor[2] = 0; + play->envCtx.lightSettings.diffuseColor1[0] = 0; + play->envCtx.lightSettings.diffuseColor1[1] = 0; + play->envCtx.lightSettings.diffuseColor1[2] = 0; + play->envCtx.lightSettings.diffuseColor2[0] = 0; + play->envCtx.lightSettings.diffuseColor2[1] = 0; + play->envCtx.lightSettings.diffuseColor2[2] = 0; + play->envCtx.lightSettings.fogColor[0] = 0; + play->envCtx.lightSettings.fogColor[1] = 0; + play->envCtx.lightSettings.fogColor[2] = 0; + play->envCtx.lightSettings.fogNear = 0; + play->envCtx.lightSettings.fogFar = 0; + play->envCtx.fillScreen = 0; for (i = 0; i < ARRAY_COUNT(this->lights); i++) { - LightContext_RemoveLight(globalCtx, &globalCtx->lightCtx, this->lights[i].node); + LightContext_RemoveLight(play, &play->lightCtx, this->lights[i].node); } } -void func_80A9156C(EnTest6* this, GlobalContext* globalCtx) { +void func_80A9156C(EnTest6* this, PlayState* play) { switch (ENTEST6_GET(&this->actor)) { case ENTEST6_24: case ENTEST6_25: - if (!ActorCutscene_GetCanPlayNext(globalCtx->playerActorCsIds[8])) { - ActorCutscene_SetIntentToPlay(globalCtx->playerActorCsIds[8]); + if (!ActorCutscene_GetCanPlayNext(play->playerActorCsIds[8])) { + ActorCutscene_SetIntentToPlay(play->playerActorCsIds[8]); } else { - ActorCutscene_Start(globalCtx->playerActorCsIds[8], NULL); - this->unk_284 = ActorCutscene_GetCurrentCamera(globalCtx->playerActorCsIds[8]); + ActorCutscene_Start(play->playerActorCsIds[8], NULL); + this->subCamId = ActorCutscene_GetCurrentSubCamId(play->playerActorCsIds[8]); EnTest6_SetupAction(this, func_80A91760); } break; case ENTEST6_26: - if (!ActorCutscene_GetCanPlayNext(globalCtx->playerActorCsIds[8])) { - ActorCutscene_SetIntentToPlay(globalCtx->playerActorCsIds[8]); + if (!ActorCutscene_GetCanPlayNext(play->playerActorCsIds[8])) { + ActorCutscene_SetIntentToPlay(play->playerActorCsIds[8]); } else { - ActorCutscene_Start(globalCtx->playerActorCsIds[8], NULL); - this->unk_284 = ActorCutscene_GetCurrentCamera(globalCtx->playerActorCsIds[8]); + ActorCutscene_Start(play->playerActorCsIds[8], NULL); + this->subCamId = ActorCutscene_GetCurrentSubCamId(play->playerActorCsIds[8]); EnTest6_SetupAction(this, func_80A92188); } break; @@ -383,7 +383,7 @@ void func_80A9156C(EnTest6* this, GlobalContext* globalCtx) { } } -void func_80A91690(EnTest6* this, GlobalContext* globalCtx) { +void func_80A91690(EnTest6* this, PlayState* play) { this->unk_274 = 90; this->unk_27A = 100; this->unk_286 = 0; @@ -394,31 +394,31 @@ void func_80A91690(EnTest6* this, GlobalContext* globalCtx) { } } -void func_80A916F0(EnTest6* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); +void func_80A916F0(EnTest6* this, PlayState* play) { + Player* player = GET_PLAYER(play); player->actor.freezeTimer = 0; - globalCtx->unk_18844 = 0; - ActorCutscene_Stop(globalCtx->playerActorCsIds[8]); - func_800B7298(globalCtx, NULL, 6); + play->unk_18844 = 0; + ActorCutscene_Stop(play->playerActorCsIds[8]); + func_800B7298(play, NULL, 6); func_80A90C34(); Distortion_ClearType(0x20); Actor_MarkForDeath(&this->actor); } -void func_80A91760(EnTest6* this, GlobalContext* globalCtx) { - Input* input = CONTROLLER1(globalCtx); +void func_80A91760(EnTest6* this, PlayState* play) { + Input* input = CONTROLLER1(&play->state); s16 temp_s0; - Player* player = GET_PLAYER(globalCtx); - Camera* sp78; - Vec3f sp6C; - Vec3f sp60; + Player* player = GET_PLAYER(play); + Camera* mainCam; + Vec3f subCamAt; + Vec3f subCamEye; Vec3f sp54; s32 i; f32 sp4C; - Camera* temp_s3 = Play_GetCamera(globalCtx, this->unk_284); + Camera* subCam = Play_GetCamera(play, this->subCamId); - sp78 = Play_GetCamera(globalCtx, CAM_ID_MAIN); + mainCam = Play_GetCamera(play, CAM_ID_MAIN); switch (this->unk_274) { case 90: @@ -432,10 +432,10 @@ void func_80A91760(EnTest6* this, GlobalContext* globalCtx) { 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); + func_800FD59C(play, &D_80A9404C, this->unk_15C); + func_800FD5E0(play, &D_80A94050, this->unk_15C); + func_800FD654(play, &D_80A94048, this->unk_15C); + func_800FD698(play, D_80A94054, D_80A94058, this->unk_15C); if (this->unk_27A == 90) { this->unk_282 = 0; @@ -459,18 +459,18 @@ void func_80A91760(EnTest6* this, GlobalContext* globalCtx) { this->unk_254 = ZeldaArena_Malloc(sizeof(Vec3f) * 64); if (this->unk_254 != NULL) { for (i = 0; i < ARRAY_COUNT(this->unk_254[0]); i++) { - (*this->unk_254)[i].x = (((2.0f * Rand_ZeroOne()) - 1.0f) * 40.0f) + temp_s3->eye.x + - ((temp_s3->at.x - temp_s3->eye.x) * 0.2f); - (*this->unk_254)[i].y = (((2.0f * Rand_ZeroOne()) - 1.0f) * 120.0f) + temp_s3->eye.y + - ((temp_s3->at.y - temp_s3->eye.y) * 0.2f) + sp4C; - (*this->unk_254)[i].z = (((2.0f * Rand_ZeroOne()) - 1.0f) * 40.0f) + temp_s3->eye.z + - ((temp_s3->at.z - temp_s3->eye.z) * 0.2f); + (*this->unk_254)[i].x = (((2.0f * Rand_ZeroOne()) - 1.0f) * 40.0f) + subCam->eye.x + + ((subCam->at.x - subCam->eye.x) * 0.2f); + (*this->unk_254)[i].y = (((2.0f * Rand_ZeroOne()) - 1.0f) * 120.0f) + subCam->eye.y + + ((subCam->at.y - subCam->eye.y) * 0.2f) + sp4C; + (*this->unk_254)[i].z = (((2.0f * Rand_ZeroOne()) - 1.0f) * 40.0f) + subCam->eye.z + + ((subCam->at.z - subCam->eye.z) * 0.2f); } } func_80A90C08(0x78); Distortion_SetType(0x20); Distortion_SetCountdown(80); - globalCtx->unk_18844 = 1; + play->unk_18844 = 1; this->unk_274 = 95; } break; @@ -484,10 +484,10 @@ void func_80A91760(EnTest6* this, GlobalContext* globalCtx) { 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); + func_800FD59C(play, &D_80A9404C, this->unk_15C); + func_800FD5E0(play, &D_80A94050, this->unk_15C); + func_800FD654(play, &D_80A94048, this->unk_15C); + func_800FD698(play, D_80A94054 + this->unk_282, D_80A94058 + this->unk_282, this->unk_15C); this->unk_278 -= this->unk_27C; temp_s0 = this->unk_278; @@ -524,7 +524,7 @@ void func_80A91760(EnTest6* this, GlobalContext* globalCtx) { this->unk_14C = 0.1f; func_80A90C34(); Distortion_ClearType(0x20); - globalCtx->unk_18844 = 0; + play->unk_18844 = 0; if (this->unk_254 != NULL) { ZeldaArena_Free(this->unk_254); } @@ -534,57 +534,57 @@ void func_80A91760(EnTest6* this, GlobalContext* globalCtx) { 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); + func_800FD59C(play, &D_80A9404C, this->unk_15C); + func_800FD5E0(play, &D_80A94050, this->unk_15C); + func_800FD654(play, &D_80A94048, this->unk_15C); + func_800FD698(play, D_80A94054, D_80A94058, this->unk_15C); break; } if (this->unk_286 != 0) { - func_800B7298(globalCtx, NULL, 7); + func_800B7298(play, NULL, 7); } else { if (this->unk_27A == 90) { - func_800B7298(globalCtx, NULL, 0x42); + func_800B7298(play, NULL, 0x42); } if (this->unk_27A == 70) { - func_800B7298(globalCtx, NULL, 0x52); + func_800B7298(play, NULL, 0x52); } if (this->unk_27A == 30) { - func_800B7298(globalCtx, NULL, 0x51); + func_800B7298(play, NULL, 0x51); } if (this->unk_27A == 5) { - func_800B7298(globalCtx, NULL, 0x4A); + func_800B7298(play, NULL, 0x4A); } } if (this->unk_27A > 80) { - temp_s3->fov += (90.0f - temp_s3->fov) / (this->unk_27A - 80); + subCam->fov += (90.0f - subCam->fov) / (this->unk_27A - 80); } else if (this->unk_27A > 60) { sp4C = 1.0f / (this->unk_27A - 60); - sp6C.x = temp_s3->at.x + ((player->actor.world.pos.x - temp_s3->at.x) * sp4C); - sp6C.y = temp_s3->at.y + (((player->actor.focus.pos.y - temp_s3->at.y) - 20.0f) * sp4C); - sp6C.z = temp_s3->at.z + ((player->actor.world.pos.z - temp_s3->at.z) * sp4C); + subCamAt.x = subCam->at.x + ((player->actor.world.pos.x - subCam->at.x) * sp4C); + subCamAt.y = subCam->at.y + (((player->actor.focus.pos.y - subCam->at.y) - 20.0f) * sp4C); + subCamAt.z = subCam->at.z + ((player->actor.world.pos.z - subCam->at.z) * sp4C); - sp54.x = (Math_SinS(player->actor.world.rot.y) * 80.0f) + sp6C.x; - sp54.y = sp6C.y + 20.0f; - sp54.z = (Math_CosS(player->actor.world.rot.y) * 80.0f) + sp6C.z; + sp54.x = (Math_SinS(player->actor.world.rot.y) * 80.0f) + subCamAt.x; + sp54.y = subCamAt.y + 20.0f; + sp54.z = (Math_CosS(player->actor.world.rot.y) * 80.0f) + subCamAt.z; sp4C *= 0.75f; - VEC3F_LERPIMPDST(&sp60, &temp_s3->eye, &sp54, sp4C); + VEC3F_LERPIMPDST(&subCamEye, &subCam->eye, &sp54, sp4C); - Play_CameraSetAtEye(globalCtx, this->unk_284, &sp6C, &sp60); + Play_SetCameraAtEye(play, this->subCamId, &subCamAt, &subCamEye); } else if ((this->unk_27A < 11) && (this->unk_27A > 0)) { - temp_s3->fov += (sp78->fov - temp_s3->fov) / this->unk_27A; + subCam->fov += (mainCam->fov - subCam->fov) / this->unk_27A; } if (this->unk_286 != 0) { - func_80A90C54(globalCtx, this->unk_286 * 0.05f); - temp_s3->fov += (sp78->fov - temp_s3->fov) * 0.05f; + func_80A90C54(play, this->unk_286 * 0.05f); + subCam->fov += (mainCam->fov - subCam->fov) * 0.05f; this->unk_286++; if (this->unk_286 >= 20) { this->unk_27A = 1; @@ -593,20 +593,20 @@ void func_80A91760(EnTest6* this, GlobalContext* globalCtx) { (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); + AudioSfx_StopById(NA_SE_SY_TIME_CONTROL_SLOW); } else if (ENTEST6_GET(&this->actor) == ENTEST6_24) { - func_801A75E8(NA_SE_SY_TIME_CONTROL_NORMAL); + AudioSfx_StopById(NA_SE_SY_TIME_CONTROL_NORMAL); } } if (DECR(this->unk_27A) == 0) { - func_80A916F0(this, globalCtx); - globalCtx->msgCtx.ocarinaMode = 4; + func_80A916F0(this, play); + play->msgCtx.ocarinaMode = 4; } } -void func_80A920C8(EnTest6* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); +void func_80A920C8(EnTest6* this, PlayState* play) { + Player* player = GET_PLAYER(play); this->unk_27A = 120; this->unk_286 = 0; @@ -615,70 +615,70 @@ void func_80A920C8(EnTest6* this, GlobalContext* globalCtx) { this->actor.home.rot = player->actor.shape.rot; } -void func_80A92118(EnTest6* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); +void func_80A92118(EnTest6* this, PlayState* play) { + Player* player = GET_PLAYER(play); player->actor.freezeTimer = 0; - globalCtx->unk_18844 = 0; - ActorCutscene_Stop(globalCtx->playerActorCsIds[8]); - func_800B7298(globalCtx, NULL, 6); + play->unk_18844 = 0; + ActorCutscene_Stop(play->playerActorCsIds[8]); + func_800B7298(play, NULL, 6); func_80A90C34(); Distortion_ClearType(0x20); Actor_MarkForDeath(&this->actor); } -void func_80A92188(EnTest6* this, GlobalContext* globalCtx) { - Input* input = CONTROLLER1(globalCtx); - Player* player = GET_PLAYER(globalCtx); - Camera* camera; +void func_80A92188(EnTest6* this, PlayState* play) { + Input* input = CONTROLLER1(&play->state); + Player* player = GET_PLAYER(play); + Camera* subCam; s32 pad; - s16 sp46; - s16 sp44; + s16 subCamId; + s16 pad2; if (this->unk_27A > 115) { this->unk_160 += 0.2f; - func_80A90C54(globalCtx, this->unk_160); + func_80A90C54(play, this->unk_160); } else if (this->unk_27A > 90) { this->unk_160 -= 0.05f; - func_80A90C54(globalCtx, this->unk_160); + func_80A90C54(play, this->unk_160); } else if (this->unk_27A == 90) { this->unk_160 = 0.0f; - func_80A90D20(globalCtx); + func_80A90D20(play); } if (this->unk_27A == 1) { this->unk_160 = 0.0f; - func_80A90D20(globalCtx); + func_80A90D20(play); } else if (this->unk_27A < 17) { this->unk_160 -= 0.06666666f; - func_80A90C54(globalCtx, this->unk_160); + func_80A90C54(play, this->unk_160); } else if (this->unk_27A < 22) { this->unk_160 += 0.2f; - func_80A90C54(globalCtx, this->unk_160); + func_80A90C54(play, 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; + func_800FD59C(play, &D_80A9406C, 1.0f); + func_800FD5E0(play, &D_80A94070, 1.0f); + func_800FD654(play, &D_80A94068, 1.0f); + func_800FD698(play, D_80A94074, D_80A94078, 1.0f); + play->unk_18844 = 1; } 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; + func_800FD59C(play, &D_80A9406C, 0.0f); + func_800FD5E0(play, &D_80A94070, 0.0f); + func_800FD654(play, &D_80A94068, 0.0f); + func_800FD698(play, D_80A94074, D_80A94078, 0.0f); + play->unk_18844 = 0; } 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_800FD59C(play, &D_80A9406C, this->unk_160); + func_800FD5E0(play, &D_80A94070, this->unk_160); + func_800FD654(play, &D_80A94068, this->unk_160); + func_800FD698(play, D_80A94074, D_80A94078, this->unk_160); + play->unk_18844 = 0; } func_800B8F98(&player->actor, NA_SE_PL_FLYING_AIR - SFX_FLAG); @@ -733,26 +733,26 @@ void func_80A92188(EnTest6* this, GlobalContext* globalCtx) { break; } - func_80A92950(this, globalCtx); + func_80A92950(this, play); if (this->unk_27A == 115) { - sp44 = ActorCutscene_GetCurrentCamera(globalCtx->playerActorCsIds[8]); - camera = Play_GetCamera(globalCtx, sp44); + subCamId = ActorCutscene_GetCurrentSubCamId(play->playerActorCsIds[8]); + subCam = Play_GetCamera(play, subCamId); - this->unk_258 = camera->at; - this->unk_264 = camera->eye; - this->unk_270 = camera->fov; - func_8016119C(camera, &this->unk_18C); + this->subCamAt = subCam->at; + this->subCamEye = subCam->eye; + this->subCamFov = subCam->fov; + func_8016119C(subCam, &this->unk_18C); } if ((this->unk_27A <= 115) && (this->unk_27A >= 16)) { func_80161998(D_80A93E80, &this->unk_18C); } else if (this->unk_27A < 16) { - sp46 = ActorCutscene_GetCurrentCamera(globalCtx->playerActorCsIds[8]); + subCamId = ActorCutscene_GetCurrentSubCamId(play->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); + Play_SetCameraAtEyeUp(play, subCamId, &this->subCamAt, &this->subCamEye, &sSubCamUp); + Play_SetCameraFov(play, subCamId, this->subCamFov); + Play_SetCameraRoll(play, subCamId, 0); } switch (this->unk_27A) { @@ -769,23 +769,23 @@ void func_80A92188(EnTest6* this, GlobalContext* globalCtx) { break; case 98: - func_800B7298(globalCtx, NULL, 0x40); + func_800B7298(play, NULL, 0x40); break; case 68: - func_800B7298(globalCtx, NULL, 0x41); + func_800B7298(play, NULL, 0x41); break; case 52: - func_800B7298(globalCtx, NULL, 0x58); + func_800B7298(play, NULL, 0x58); break; case 43: - func_800B7298(globalCtx, NULL, 0x72); + func_800B7298(play, NULL, 0x72); break; case 38: - func_800B7298(globalCtx, NULL, 7); + func_800B7298(play, NULL, 7); break; case 14: @@ -801,7 +801,7 @@ void func_80A92188(EnTest6* this, GlobalContext* globalCtx) { } if ((this->unk_286 > 0) && (this->unk_286 < 20)) { - func_80A90C54(globalCtx, this->unk_286 * 0.05f); + func_80A90C54(play, this->unk_286 * 0.05f); this->unk_286++; if (this->unk_286 >= 20) { this->unk_27A = 15; @@ -815,26 +815,26 @@ void func_80A92188(EnTest6* this, GlobalContext* globalCtx) { } if (DECR(this->unk_27A) == 0) { - func_80A92118(this, globalCtx); + func_80A92118(this, play); } } -void EnTest6_Update(Actor* thisx, GlobalContext* globalCtx) { +void EnTest6_Update(Actor* thisx, PlayState* play) { EnTest6* this = THIS; - this->actionFunc(this, globalCtx); + this->actionFunc(this, play); } -void func_80A92950(EnTest6* this, GlobalContext* globalCtx) { +void func_80A92950(EnTest6* this, PlayState* play) { s32 pad[2]; - Player* player = GET_PLAYER(globalCtx); + Player* player = GET_PLAYER(play); 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; + if (Cutscene_CheckActorAction(play, 0x1F9)) { + temp_v0 = Cutscene_GetActorActionIndex(play, 0x1F9); + this->unk_274 = play->csCtx.actorActions[temp_v0]->action; switch (this->unk_274) { case 1: @@ -846,39 +846,39 @@ void func_80A92950(EnTest6* this, GlobalContext* globalCtx) { 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; + if (play->csCtx.actorActions[temp_v0]->startPos.x != 0) { + this->unk_154 = (u32)play->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; + if (play->csCtx.actorActions[temp_v0]->startPos.y != 0) { + this->unk_280 = play->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; + if (play->csCtx.actorActions[temp_v0]->startPos.z != 0) { + this->unk_150 = (u32)play->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 (play->csCtx.actorActions[temp_v0]->startPos.x != 0) { + this->unk_154 += (u32)play->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; + if (play->csCtx.actorActions[temp_v0]->startPos.y != 0) { + this->unk_280 += (s16)play->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; + if (play->csCtx.actorActions[temp_v0]->startPos.z != 0) { + this->unk_158 = (u32)play->csCtx.actorActions[temp_v0]->startPos.z; } else { this->unk_158 = -32.0f; } @@ -886,30 +886,30 @@ void func_80A92950(EnTest6* this, GlobalContext* globalCtx) { break; case 4: - if (globalCtx->csCtx.actorActions[temp_v0]->startPos.x != 0) { - this->unk_154 += (u32)globalCtx->csCtx.actorActions[temp_v0]->startPos.x; + if (play->csCtx.actorActions[temp_v0]->startPos.x != 0) { + this->unk_154 += (u32)play->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; + if (play->csCtx.actorActions[temp_v0]->startPos.y != 0) { + this->unk_280 += (s16)play->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 (play->csCtx.actorActions[temp_v0]->startPos.x != 0) { + this->unk_154 += (u32)play->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; + if (play->csCtx.actorActions[temp_v0]->startPos.y != 0) { + this->unk_280 += (s16)play->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; + if (play->csCtx.actorActions[temp_v0]->startPos.z != 0) { + this->unk_158 += (u32)play->csCtx.actorActions[temp_v0]->startPos.z; } else { this->unk_158 += 20.0f; } @@ -927,20 +927,20 @@ void func_80A92950(EnTest6* this, GlobalContext* globalCtx) { 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; + if (play->csCtx.actorActions[temp_v0]->startPos.x != 0) { + this->unk_154 = (u32)play->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; + if (play->csCtx.actorActions[temp_v0]->startPos.y != 0) { + this->unk_14C = (u32)play->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; + if (play->csCtx.actorActions[temp_v0]->startPos.z != 0) { + this->unk_150 = (u32)play->csCtx.actorActions[temp_v0]->startPos.z; } else { this->unk_150 = 300.0f; } @@ -948,8 +948,8 @@ void func_80A92950(EnTest6* this, GlobalContext* globalCtx) { break; case 7: - if (globalCtx->csCtx.actorActions[temp_v0]->startPos.x != 0) { - this->unk_158 = (u32)globalCtx->csCtx.actorActions[temp_v0]->startPos.x; + if (play->csCtx.actorActions[temp_v0]->startPos.x != 0) { + this->unk_158 = (u32)play->csCtx.actorActions[temp_v0]->startPos.x; } else { this->unk_158 = -5.0f; } @@ -957,8 +957,8 @@ void func_80A92950(EnTest6* this, GlobalContext* globalCtx) { break; case 8: - if (globalCtx->csCtx.actorActions[temp_v0]->startPos.x != 0) { - this->unk_158 += (u32)globalCtx->csCtx.actorActions[temp_v0]->startPos.x; + if (play->csCtx.actorActions[temp_v0]->startPos.x != 0) { + this->unk_158 += (u32)play->csCtx.actorActions[temp_v0]->startPos.x; } else { this->unk_158 += 2.0f; } @@ -976,19 +976,19 @@ void func_80A92950(EnTest6* this, GlobalContext* globalCtx) { return; case 9: - Play_SetRespawnData(&globalCtx->state, 1, ((void)0, gSaveContext.save.entranceIndex & 0xFFFF), - player->unk_3CE, 0xBFF, &player->unk_3C0, player->unk_3CC); + Play_SetRespawnData(&play->state, 1, ((void)0, gSaveContext.save.entrance & 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; + play->transitionTrigger = TRANS_TRIGGER_START; + play->nextEntrance = gSaveContext.respawn[RESPAWN_MODE_RETURN].entrance; + play->transitionType = TRANS_TYPE_02; if ((gSaveContext.save.time > CLOCK_TIME(18, 0)) || (gSaveContext.save.time < CLOCK_TIME(6, 0))) { gSaveContext.respawnFlag = -0x63; gSaveContext.eventInf[2] |= 0x80; } else { gSaveContext.respawnFlag = 2; } - globalCtx->msgCtx.ocarinaMode = 4; + play->msgCtx.ocarinaMode = 4; return; } } else { @@ -1057,14 +1057,14 @@ void func_80A92950(EnTest6* this, GlobalContext* globalCtx) { case 9: if (gSaveContext.save.time > CLOCK_TIME(12, 0)) { - Play_SetRespawnData(&globalCtx->state, 1, ((void)0, gSaveContext.save.entranceIndex & 0xFFFF), + Play_SetRespawnData(&play->state, 1, ((void)0, gSaveContext.save.entrance & 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; + play->transitionTrigger = TRANS_TRIGGER_START; + play->nextEntrance = gSaveContext.respawn[RESPAWN_MODE_RETURN].entrance; + play->transitionType = TRANS_TYPE_02; gSaveContext.respawnFlag = 2; - globalCtx->msgCtx.ocarinaMode = 4; + play->msgCtx.ocarinaMode = 4; } return; } @@ -1092,7 +1092,7 @@ void func_80A92950(EnTest6* this, GlobalContext* globalCtx) { this->unk_278++; } -void func_80A93298(EnTest6* this, GlobalContext* globalCtx) { +void func_80A93298(EnTest6* this, PlayState* play) { s16 temp_s3; s16 temp_s4; f32 phi_f24; @@ -1101,14 +1101,14 @@ void func_80A93298(EnTest6* this, GlobalContext* globalCtx) { f32 cos; f32 sin; - OPEN_DISPS(globalCtx->state.gfxCtx); + OPEN_DISPS(play->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; + temp_s4 = (s32)(Math_SinS(play->state.frames) * 12000.0f) + temp_s3 + 0x4E20; + phi_s2 = (play->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); @@ -1117,12 +1117,12 @@ void func_80A93298(EnTest6* this, GlobalContext* globalCtx) { temp_s3 += 0x1000; cos = Math_CosS(temp_s3) * this->unk_150; sin = Math_SinS(temp_s3) * this->unk_150; - Matrix_InsertTranslation(cos, phi_f24, sin, MTXMODE_NEW); - Matrix_InsertXRotation_s(0x4000, MTXMODE_APPLY); + Matrix_Translate(cos, phi_f24, sin, MTXMODE_NEW); + Matrix_RotateXS(0x4000, MTXMODE_APPLY); Matrix_Scale(0.8f, 0.8f, 0.8f, MTXMODE_APPLY); - Matrix_InsertZRotation_s(phi_s2, 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); + gSPMatrix(this->unk_148++, Matrix_NewMtx(play->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); @@ -1131,12 +1131,12 @@ void func_80A93298(EnTest6* this, GlobalContext* globalCtx) { temp_s4 += 0x1000; cos = Math_CosS(temp_s4) * this->unk_150; sin = Math_SinS(temp_s4) * this->unk_150; - Matrix_InsertTranslation(cos, phi_f24, sin, MTXMODE_NEW); - Matrix_InsertXRotation_s(0x4000, MTXMODE_APPLY); + Matrix_Translate(cos, phi_f24, sin, MTXMODE_NEW); + Matrix_RotateXS(0x4000, MTXMODE_APPLY); Matrix_Scale(0.8f, 0.8f, 0.8f, MTXMODE_APPLY); - Matrix_InsertZRotation_s(-phi_s2, 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); + gSPMatrix(this->unk_148++, Matrix_NewMtx(play->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); @@ -1150,32 +1150,32 @@ void func_80A93298(EnTest6* this, GlobalContext* globalCtx) { 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]); + D_80A94910[i].unk_14(this, play, &D_80A94910[i]); } } - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->state.gfxCtx); } -void func_80A9369C(Actor* thisx, GlobalContext* globalCtx2) { +void func_80A9369C(Actor* thisx, PlayState* play2) { EnTest6* this = THIS; - GlobalContext* globalCtx = globalCtx2; + PlayState* play = play2; f32 temp_f20; f32 temp_f22; f32 phi_f26; s16 phi_s2; s16 sp78; s32 i; - Player* player = GET_PLAYER(globalCtx); + Player* player = GET_PLAYER(play); s32 pad; if (this) {} - OPEN_DISPS(globalCtx->state.gfxCtx); + OPEN_DISPS(play->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; + sp78 = (play->state.frames & 0x3C) * 1024; phi_s2 = this->unk_27C + 0x4000; switch (player->transformation) { @@ -1203,13 +1203,13 @@ void func_80A9369C(Actor* thisx, GlobalContext* globalCtx2) { for (i = 0; i < 51; i++) { temp_f20 = Math_CosS(phi_s2) * this->unk_150; temp_f22 = Math_SinS(phi_s2) * this->unk_150; - Matrix_InsertZRotation_s(this->unk_27E, MTXMODE_NEW); - Matrix_InsertTranslation(phi_f26, temp_f20, temp_f22, MTXMODE_APPLY); + Matrix_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_InsertXRotation_s(phi_s2, MTXMODE_APPLY); - Matrix_InsertZRotation_s(sp78, 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); + gSPMatrix(this->unk_148++, Matrix_NewMtx(play->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); @@ -1224,16 +1224,16 @@ void func_80A9369C(Actor* thisx, GlobalContext* globalCtx2) { POLY_OPA_DISP = this->unk_148; - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->state.gfxCtx); } -void func_80A939E8(EnTest6* this, GlobalContext* globalCtx2) { - GlobalContext* globalCtx = globalCtx2; - Player* player = GET_PLAYER(globalCtx); +void func_80A939E8(EnTest6* this, PlayState* play2) { + PlayState* play = play2; + Player* player = GET_PLAYER(play); f32 temp_f20; s32 i; - OPEN_DISPS(globalCtx->state.gfxCtx); + OPEN_DISPS(play->state.gfxCtx); switch (this->unk_274) { case 91: @@ -1247,12 +1247,12 @@ void func_80A939E8(EnTest6* this, GlobalContext* globalCtx2) { this->unk_148 = POLY_XLU_DISP; for (i = 0; i < ARRAY_COUNT(this->unk_20C); i++) { - Matrix_InsertTranslation(this->unk_20C[i].x, this->unk_20C[i].y, this->unk_20C[i].z, MTXMODE_NEW); + Matrix_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_InsertXRotation_s(-0x4000, MTXMODE_APPLY); - Matrix_InsertZRotation_s(this->unk_278, MTXMODE_APPLY); + Matrix_RotateXS(-0x4000, MTXMODE_APPLY); + Matrix_RotateZS(this->unk_278, MTXMODE_APPLY); - gSPMatrix(this->unk_148++, Matrix_NewMtx(globalCtx->state.gfxCtx), + gSPMatrix(this->unk_148++, Matrix_NewMtx(play->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); @@ -1265,18 +1265,17 @@ void func_80A939E8(EnTest6* this, GlobalContext* globalCtx2) { if (this->unk_254 != NULL) { for (i = 0; i < ARRAY_COUNT(this->unk_254[0]); i++) { temp_f20 = Rand_ZeroOne() * 0.0025f; - Matrix_InsertTranslation((*this->unk_254)[i].x, (*this->unk_254)[i].y, (*this->unk_254)[i].z, - MTXMODE_NEW); + Matrix_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_InsertMatrix(&globalCtx->billboardMtxF, MTXMODE_APPLY); - Matrix_InsertZRotation_s(this->unk_278 + (i << 2), MTXMODE_APPLY); + func_8012C2DC(play->state.gfxCtx); + Matrix_Mult(&play->billboardMtxF, MTXMODE_APPLY); + Matrix_RotateZS(this->unk_278 + (i << 2), MTXMODE_APPLY); - gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_XLU_DISP++, gOwlStatueWhiteFlashDL); } @@ -1296,24 +1295,24 @@ void func_80A939E8(EnTest6* this, GlobalContext* globalCtx2) { break; } - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->state.gfxCtx); } -void EnTest6_Draw(Actor* thisx, GlobalContext* globalCtx) { +void EnTest6_Draw(Actor* thisx, PlayState* play) { EnTest6* this = THIS; if (this->unk_274 != 0) { switch (this->unk_276) { case 1: - func_80A93298(this, globalCtx); + func_80A93298(this, play); break; case 0: - func_80A9369C(thisx, globalCtx); + func_80A9369C(thisx, play); break; case 2: - func_80A939E8(this, globalCtx); + func_80A939E8(this, play); 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 0c1aab3b0..ad596960e 100644 --- a/src/overlays/actors/ovl_En_Test6/z_en_test6.h +++ b/src/overlays/actors/ovl_En_Test6/z_en_test6.h @@ -5,7 +5,7 @@ struct EnTest6; -typedef void (*EnTest6ActionFunc)(struct EnTest6*, GlobalContext*); +typedef void (*EnTest6ActionFunc)(struct EnTest6*, PlayState*); #define ENTEST6_GET(thisx) ((thisx)->params) @@ -18,35 +18,35 @@ enum { typedef struct { /* 0x00 */ LightNode* node; /* 0x04 */ LightInfo info; -} EnTest6Light; +} EnTest6Light; // size = 0x14 typedef struct EnTest6 { - /* 0x0000 */ Actor actor; - /* 0x0144 */ EnTest6ActionFunc actionFunc; - /* 0x0148 */ Gfx* unk_148; - /* 0x014C */ f32 unk_14C; - /* 0x0150 */ f32 unk_150; - /* 0x0154 */ f32 unk_154; - /* 0x0158 */ f32 unk_158; - /* 0x015C */ f32 unk_15C; - /* 0x0160 */ f32 unk_160; - /* 0x0164 */ EnTest6Light lights[2]; - /* 0x018C */ DbCameraUnkStruct unk_18C; - /* 0x020C */ Vec3f unk_20C[6]; - /* 0x0254 */ Vec3f (*unk_254)[64]; - /* 0x0258 */ Vec3f unk_258; - /* 0x0264 */ Vec3f unk_264; - /* 0x0270 */ f32 unk_270; - /* 0x0274 */ s16 unk_274; - /* 0x0276 */ s16 unk_276; - /* 0x0278 */ s16 unk_278; - /* 0x027A */ s16 unk_27A; - /* 0x027C */ s16 unk_27C; - /* 0x027E */ s16 unk_27E; - /* 0x0280 */ s16 unk_280; - /* 0x0282 */ s16 unk_282; - /* 0x0284 */ s16 unk_284; - /* 0x0286 */ s16 unk_286; + /* 0x000 */ Actor actor; + /* 0x144 */ EnTest6ActionFunc actionFunc; + /* 0x148 */ Gfx* unk_148; + /* 0x14C */ f32 unk_14C; + /* 0x150 */ f32 unk_150; + /* 0x154 */ f32 unk_154; + /* 0x158 */ f32 unk_158; + /* 0x15C */ f32 unk_15C; + /* 0x160 */ f32 unk_160; + /* 0x164 */ EnTest6Light lights[2]; + /* 0x18C */ DbCameraUnkStruct unk_18C; + /* 0x20C */ Vec3f unk_20C[6]; + /* 0x254 */ Vec3f (*unk_254)[64]; + /* 0x258 */ Vec3f subCamAt; + /* 0x264 */ Vec3f subCamEye; + /* 0x270 */ f32 subCamFov; + /* 0x274 */ s16 unk_274; + /* 0x276 */ s16 unk_276; + /* 0x278 */ s16 unk_278; + /* 0x27A */ s16 unk_27A; + /* 0x27C */ s16 unk_27C; + /* 0x27E */ s16 unk_27E; + /* 0x280 */ s16 unk_280; + /* 0x282 */ s16 unk_282; + /* 0x284 */ s16 subCamId; + /* 0x286 */ s16 unk_286; } EnTest6; // size = 0x288 extern const ActorInit En_Test6_InitVars; diff --git a/src/overlays/actors/ovl_En_Test7/z_en_test7.c b/src/overlays/actors/ovl_En_Test7/z_en_test7.c index c5fda21f0..ed9d2870c 100644 --- a/src/overlays/actors/ovl_En_Test7/z_en_test7.c +++ b/src/overlays/actors/ovl_En_Test7/z_en_test7.c @@ -11,28 +11,28 @@ #define THIS ((EnTest7*)thisx) -void EnTest7_Init(Actor* thisx, GlobalContext* globalCtx); -void EnTest7_Destroy(Actor* thisx, GlobalContext* globalCtx); -void EnTest7_Update(Actor* thisx, GlobalContext* globalCtx); -void EnTest7_Draw(Actor* thisx, GlobalContext* globalCtx); +void EnTest7_Init(Actor* thisx, PlayState* play); +void EnTest7_Destroy(Actor* thisx, PlayState* play); +void EnTest7_Update(Actor* thisx, PlayState* play); +void EnTest7_Draw(Actor* thisx, PlayState* play); 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); +void func_80AF19A8(EnTest7* this, PlayState* play); +void func_80AF1A2C(EnTest7* this, PlayState* play); +void func_80AF1CA0(EnTest7* this, PlayState* play); +void func_80AF1E44(EnTest7* this, PlayState* play); +void func_80AF1F48(EnTest7* this, PlayState* play); +void func_80AF2030(EnTest7* this, PlayState* play); +void func_80AF21E8(EnTest7* this, PlayState* play); +void func_80AF2318(EnTest7* this, PlayState* play); +void func_80AF2350(EnTest7* this, PlayState* play); +void func_80AF2854(EnTest7* this, PlayState* play); +void func_80AF2938(EnTest7* this, PlayState* play); +void func_80AF2AE8(EnTest7* this, PlayState* play); +void func_80AF2C48(EnTest7* this, PlayState* play); +void func_80AF2EC8(EnTest7* this, PlayState* play); +void func_80AF2F98(EnTest7* this, PlayState* play); +void func_80AF30F4(EnTest7* this, PlayState* play); const ActorInit En_Test7_InitVars = { ACTOR_EN_TEST7, @@ -167,7 +167,7 @@ Vec3f D_80AF3414 = { 0.0f, 1.0f, 0.0f }; Vec3f D_80AF3420 = { 0.0f, 0.0f, 1.0f }; -void func_80AF0CDC(GlobalContext* globalCtx, EnTest7Struct2* arg1) { +void func_80AF0CDC(PlayState* play, EnTest7Struct2* arg1) { static MtxF D_80AF38B0; static Vec3f D_80AF38F0; static f32 D_80AF38FC; @@ -230,7 +230,7 @@ void func_80AF0CDC(GlobalContext* globalCtx, EnTest7Struct2* arg1) { arg1->unk_08.z += arg1->unk_1C; } -void func_80AF10D8(GlobalContext* globalCtx, EnTest7Struct2* arg1) { +void func_80AF10D8(PlayState* play, EnTest7Struct2* arg1) { arg1->unk_30.y += arg1->unk_38; arg1->unk_20 = Rand_Centered(); @@ -246,7 +246,7 @@ void func_80AF10D8(GlobalContext* globalCtx, EnTest7Struct2* arg1) { arg1->unk_08.z += arg1->unk_1C; } -void func_80AF118C(GlobalContext* globalCtx, EnTest7Struct2* arg1, EnTest7* this, s32 arg3, s32 arg4) { +void func_80AF118C(PlayState* play, EnTest7Struct2* arg1, EnTest7* this, s32 arg3, s32 arg4) { s32 pad[4]; EnTest7Struct2* ptr; s16 phi_s1; @@ -268,9 +268,9 @@ void func_80AF118C(GlobalContext* globalCtx, EnTest7Struct2* arg1, EnTest7* this } if (arg1->unk_00 == 1) { - func_80AF0CDC(globalCtx, arg1); + func_80AF0CDC(play, arg1); } else { - func_80AF10D8(globalCtx, arg1); + func_80AF10D8(play, arg1); } if (arg3) { @@ -320,19 +320,19 @@ void func_80AF118C(GlobalContext* globalCtx, EnTest7Struct2* arg1, EnTest7* this } } -void func_80AF14FC(GlobalContext* globalCtx2, EnTest7Struct2* arg1) { +void func_80AF14FC(PlayState* play2, EnTest7Struct2* arg1) { s32 pad[3]; - GlobalContext* globalCtx = globalCtx2; + PlayState* play = play2; Mtx* temp_v0; EnTest7Struct2* ptr; s32 i; MtxF sp6C; - OPEN_DISPS(globalCtx->state.gfxCtx); + OPEN_DISPS(play->state.gfxCtx); - func_8012C1C0(globalCtx->state.gfxCtx); + func_8012C1C0(play->state.gfxCtx); - Matrix_StatePush(); + Matrix_Push(); gDPSetPrimColor(POLY_OPA_DISP++, 0, 0x80, 255, 255, 255, 255); gDPSetEnvColor(POLY_OPA_DISP++, 255, 255, 255, 255); @@ -348,21 +348,21 @@ void func_80AF14FC(GlobalContext* globalCtx2, EnTest7Struct2* arg1) { continue; } - Matrix_InsertTranslation(ptr->unk_08.x, ptr->unk_08.y, ptr->unk_08.z, MTXMODE_NEW); + Matrix_Translate(ptr->unk_08.x, ptr->unk_08.y, ptr->unk_08.z, MTXMODE_NEW); if (ptr->unk_00 == 1) { - Matrix_InsertRotation(ptr->unk_30.x, ptr->unk_30.y, ptr->unk_30.z, MTXMODE_APPLY); + 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_InsertMatrix(&sp6C, MTXMODE_APPLY); + Matrix_Mult(&sp6C, MTXMODE_APPLY); } Matrix_Scale(ptr->unk_2C, ptr->unk_2C, ptr->unk_2C, MTXMODE_APPLY); if (ptr->unk_00 == 2) { - Matrix_InsertTranslation(0.0f, 30.0f, 0.0f, MTXMODE_APPLY); + Matrix_Translate(0.0f, 30.0f, 0.0f, MTXMODE_APPLY); } - temp_v0 = Matrix_NewMtx(globalCtx->state.gfxCtx); + temp_v0 = Matrix_NewMtx(play->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); @@ -371,9 +371,9 @@ void func_80AF14FC(GlobalContext* globalCtx2, EnTest7Struct2* arg1) { if (ptr) {} - Matrix_StatePop(); + Matrix_Pop(); - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->state.gfxCtx); } void func_80AF1730(EnTest7Struct* arg0) { @@ -384,11 +384,11 @@ void func_80AF1730(EnTest7Struct* arg0) { arg0->unk_10 = 0; } -void EnTest7_Init(Actor* thisx, GlobalContext* globalCtx2) { - GlobalContext* globalCtx = globalCtx2; +void EnTest7_Init(Actor* thisx, PlayState* play2) { + PlayState* play = play2; EnTest7* this = THIS; - Player* player = GET_PLAYER(globalCtx); - Player* player2 = GET_PLAYER(globalCtx); + Player* player = GET_PLAYER(play); + Player* player2 = GET_PLAYER(play); this->actor.world.rot.y = this->actor.shape.rot.y = player->actor.shape.rot.y; this->unk_144 = 0; @@ -398,7 +398,7 @@ void EnTest7_Init(Actor* thisx, GlobalContext* globalCtx2) { 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); + this->unk_1BA8, NULL); func_801834A8(&this->unk_18CC, &gameplay_keep_Blob_083534); func_80AF0838(this->unk_15C); func_80AF1730(&this->unk_148); @@ -412,51 +412,51 @@ void EnTest7_Init(Actor* thisx, GlobalContext* globalCtx2) { func_801A2E54(NA_BGM_SONG_OF_SOARING); } - if (globalCtx->playerActorCsIds[8] == -1) { + if (play->playerActorCsIds[8] == -1) { Actor_MarkForDeath(&this->actor); return; } - ActorCutscene_SetIntentToPlay(globalCtx->playerActorCsIds[8]); + ActorCutscene_SetIntentToPlay(play->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); + this->lightNode = LightContext_InsertLight(play, &play->lightCtx, &this->lightInfo); } -void EnTest7_Destroy(Actor* thisx, GlobalContext* globalCtx) { +void EnTest7_Destroy(Actor* thisx, PlayState* play) { EnTest7* this = THIS; - ActorCutscene_Stop(globalCtx->playerActorCsIds[8]); - LightContext_RemoveLight(globalCtx, &globalCtx->lightCtx, this->lightNode); + ActorCutscene_Stop(play->playerActorCsIds[8]); + LightContext_RemoveLight(play, &play->lightCtx, this->lightNode); } -void func_80AF19A8(EnTest7* this, GlobalContext* globalCtx) { - if (!ActorCutscene_GetCanPlayNext(globalCtx->playerActorCsIds[8])) { - ActorCutscene_SetIntentToPlay(globalCtx->playerActorCsIds[8]); +void func_80AF19A8(EnTest7* this, PlayState* play) { + if (!ActorCutscene_GetCanPlayNext(play->playerActorCsIds[8])) { + ActorCutscene_SetIntentToPlay(play->playerActorCsIds[8]); } else { - ActorCutscene_Start(globalCtx->playerActorCsIds[8], NULL); + ActorCutscene_Start(play->playerActorCsIds[8], NULL); func_80AF082C(this, func_80AF1A2C); - globalCtx->unk_18844 = 1; + play->unk_18844 = 1; } } -void func_80AF1A2C(EnTest7* this, GlobalContext* globalCtx) { +void func_80AF1A2C(EnTest7* this, PlayState* play) { 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); + func_800FD59C(play, &sp30, sp2C); + func_800FD654(play, &sp34, sp2C); + func_800FD698(play, 2000, 4000, sp2C); if (this->unk_1E54 >= 10) { - Camera* camera = Play_GetCamera(globalCtx, ActorCutscene_GetCurrentCamera(globalCtx->playerActorCsIds[8])); + Camera* subCam = Play_GetCamera(play, ActorCutscene_GetCurrentSubCamId(play->playerActorCsIds[8])); - this->unk_1E60 = camera->eye; - this->unk_1E6C = camera->at; - this->unk_1E78 = camera->fov; + this->subCamEye = subCam->eye; + this->subCamAt = subCam->at; + this->subCamFov = subCam->fov; func_80AF082C(this, func_80AF1CA0); this->unk_144 |= 0x20; @@ -465,7 +465,7 @@ void func_80AF1A2C(EnTest7* this, GlobalContext* globalCtx) { } } -void func_80AF1B68(EnTest7* this, GlobalContext* globalCtx) { +void func_80AF1B68(EnTest7* this, PlayState* play) { this->unk_144 |= 2; if (this->unk_148.unk_04 < 11.0f) { @@ -477,7 +477,7 @@ void func_80AF1B68(EnTest7* this, GlobalContext* globalCtx) { 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); + Player* player = GET_PLAYER(play); this->unk_144 &= ~1; player->actor.draw = NULL; @@ -491,7 +491,7 @@ void func_80AF1B68(EnTest7* this, GlobalContext* globalCtx) { } } -void func_80AF1CA0(EnTest7* this, GlobalContext* globalCtx) { +void func_80AF1CA0(EnTest7* this, PlayState* play) { Vec3f sp34; if (func_80183DE0(&this->unk_18CC)) { @@ -499,7 +499,7 @@ void func_80AF1CA0(EnTest7* this, GlobalContext* globalCtx) { } if (this->unk_18CC.frameCtrl.unk_10 > 60.0f) { - func_80AF1B68(this, globalCtx); + func_80AF1B68(this, play); } if ((this->unk_18CC.frameCtrl.unk_10 > 20.0f) && !(this->unk_144 & 0x40)) { @@ -514,12 +514,12 @@ void func_80AF1CA0(EnTest7* this, GlobalContext* globalCtx) { } if (Rand_ZeroOne() < 0.3f) { - Camera* camera = Play_GetCamera(globalCtx, ActorCutscene_GetCurrentCamera(globalCtx->playerActorCsIds[8])); + Camera* subCam = Play_GetCamera(play, ActorCutscene_GetCurrentSubCamId(play->playerActorCsIds[8])); f32 rand = Rand_ZeroOne(); - sp34.x = ((camera->eye.x - this->actor.world.pos.x) * rand) + this->actor.world.pos.x; - sp34.y = ((camera->eye.y - this->actor.world.pos.y) * rand) + this->actor.world.pos.y; - sp34.z = ((camera->eye.z - this->actor.world.pos.z) * rand) + this->actor.world.pos.z; + sp34.x = ((subCam->eye.x - this->actor.world.pos.x) * rand) + this->actor.world.pos.x; + sp34.y = ((subCam->eye.y - this->actor.world.pos.y) * rand) + this->actor.world.pos.y; + sp34.z = ((subCam->eye.z - this->actor.world.pos.z) * rand) + this->actor.world.pos.z; func_80AF0C30(this->unk_15C, &sp34, 1); this->unk_144 |= 8; @@ -529,19 +529,19 @@ void func_80AF1CA0(EnTest7* this, GlobalContext* globalCtx) { } } -void func_80AF1E44(EnTest7* this, GlobalContext* globalCtx) { +void func_80AF1E44(EnTest7* this, PlayState* play) { Vec3f sp34; - Camera* camera; + Camera* subCam; f32 rand; - func_80AF1B68(this, globalCtx); + func_80AF1B68(this, play); if (Rand_ZeroOne() < 0.3f) { - camera = Play_GetCamera(globalCtx, ActorCutscene_GetCurrentCamera(globalCtx->playerActorCsIds[8])); + subCam = Play_GetCamera(play, ActorCutscene_GetCurrentSubCamId(play->playerActorCsIds[8])); rand = Rand_ZeroOne(); - sp34.x = ((camera->eye.x - this->actor.world.pos.x) * rand) + this->actor.world.pos.x; - sp34.y = ((camera->eye.y - this->actor.world.pos.y) * rand) + this->actor.world.pos.y; - sp34.z = ((camera->eye.z - this->actor.world.pos.z) * rand) + this->actor.world.pos.z; + sp34.x = ((subCam->eye.x - this->actor.world.pos.x) * rand) + this->actor.world.pos.x; + sp34.y = ((subCam->eye.y - this->actor.world.pos.y) * rand) + this->actor.world.pos.y; + sp34.z = ((subCam->eye.z - this->actor.world.pos.z) * rand) + this->actor.world.pos.z; func_80AF0C30(this->unk_15C, &sp34, 1); } @@ -550,7 +550,7 @@ void func_80AF1E44(EnTest7* this, GlobalContext* globalCtx) { this->unk_18FC[1].y += 0x2EE0; } -void func_80AF1F48(EnTest7* this, GlobalContext* globalCtx) { +void func_80AF1F48(EnTest7* this, PlayState* play) { s32 pad; s32 temp = this->unk_1E54 - 86; f32 temp_f0 = temp / 10.0f; @@ -572,11 +572,11 @@ void func_80AF1F48(EnTest7* this, GlobalContext* globalCtx) { func_80AF0C30(this->unk_15C, &sp20, 1); } -void func_80AF2030(EnTest7* this, GlobalContext* globalCtx) { +void func_80AF2030(EnTest7* this, PlayState* play) { s32 temp = this->unk_1E54 - 96; f32 four = 4; f32 sp1C = 1.0f - (temp / four); - Camera* camera; + Camera* subCam; f32 temp_f2; f32 temp_f4; @@ -585,13 +585,13 @@ void func_80AF2030(EnTest7* this, GlobalContext* globalCtx) { 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; + subCam = Play_GetCamera(play, ActorCutscene_GetCurrentSubCamId(play->playerActorCsIds[8])); + subCam->focalActor = NULL; - camera->eye.x = ((camera->eye.x - this->unk_1E60.x) * sp1C) + this->unk_1E60.x; - camera->eye.y = ((camera->eye.y - this->unk_1E60.y) * sp1C) + this->unk_1E60.y; - camera->eye.z = ((camera->eye.z - this->unk_1E60.z) * sp1C) + this->unk_1E60.z; - camera->fov = ((camera->fov - this->unk_1E78) * sp1C) + this->unk_1E78; + subCam->eye.x = ((subCam->eye.x - this->subCamEye.x) * sp1C) + this->subCamEye.x; + subCam->eye.y = ((subCam->eye.y - this->subCamEye.y) * sp1C) + this->subCamEye.y; + subCam->eye.z = ((subCam->eye.z - this->subCamEye.z) * sp1C) + this->subCamEye.z; + subCam->fov = ((subCam->fov - this->subCamFov) * sp1C) + this->subCamFov; if (this->unk_1E54 >= 100) { MREG(64) = 1; @@ -599,14 +599,14 @@ void func_80AF2030(EnTest7* this, GlobalContext* globalCtx) { MREG(66) = 255; MREG(67) = 255; MREG(68) = 255; - globalCtx->unk_18844 = 0; + play->unk_18844 = 0; this->unk_144 &= ~4; func_80AF082C(this, func_80AF21E8); func_80165690(); } } -void func_80AF21E8(EnTest7* this, GlobalContext* globalCtx) { +void func_80AF21E8(EnTest7* this, PlayState* play) { s32 sp2C = this->unk_1E54 - 100; f32 sp1C; Color_RGB8 sp24 = { 64, 0, 0 }; @@ -622,26 +622,30 @@ void func_80AF21E8(EnTest7* this, GlobalContext* globalCtx) { } sp1C = 1.0f - (sp2C / 10.0f); - func_800FD59C(globalCtx, &sp20, sp1C); - func_800FD654(globalCtx, &sp24, sp1C); - func_800FD698(globalCtx, 2000, 4000, sp1C); + func_800FD59C(play, &sp20, sp1C); + func_800FD654(play, &sp24, sp1C); + func_800FD698(play, 2000, 4000, sp1C); if (this->unk_1E54 >= 110) { func_80AF082C(this, func_80AF2318); } } -void func_80AF2318(EnTest7* this, GlobalContext* globalCtx) { +void func_80AF2318(EnTest7* this, PlayState* play) { if (this->unk_1E54 >= 130) { func_80AF082C(this, func_80AF2350); } } u16 D_80AF343C[] = { - 0x68B0, 0x6A60, 0xB230, 0x9A80, 0xD890, 0x3E40, 0x8640, 0x84A0, 0x2040, 0xAA30, + ENTRANCE(GREAT_BAY_COAST, 11), ENTRANCE(ZORA_CAPE, 6), + ENTRANCE(SNOWHEAD, 3), ENTRANCE(MOUNTAIN_VILLAGE_WINTER, 8), + ENTRANCE(SOUTH_CLOCK_TOWN, 9), ENTRANCE(MILK_ROAD, 4), + ENTRANCE(WOODFALL, 4), ENTRANCE(SOUTHERN_SWAMP_POISONED, 10), + ENTRANCE(IKANA_CANYON, 4), ENTRANCE(STONE_TOWER, 3), }; -void func_80AF2350(EnTest7* this, GlobalContext* globalCtx) { +void func_80AF2350(EnTest7* this, PlayState* play) { Vec3f sp2C; if (this) {} @@ -654,56 +658,58 @@ void func_80AF2350(EnTest7* this, GlobalContext* globalCtx) { this->unk_148.unk_10 -= 0x2EE0; - if (globalCtx->sceneNum == SCENE_SECOM) { - globalCtx->nextEntranceIndex = 0x2060; + if (play->sceneNum == SCENE_SECOM) { + play->nextEntrance = ENTRANCE(IKANA_CANYON, 6); } else if (ENTEST7_GET(&this->actor) == ENTEST7_26) { - func_80169F78(&globalCtx->state); - gSaveContext.respawn[2].playerParams = (gSaveContext.respawn[2].playerParams & 0xFF) | 0x600; + func_80169F78(&play->state); + gSaveContext.respawn[RESPAWN_MODE_TOP].playerParams = + (gSaveContext.respawn[RESPAWN_MODE_TOP].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; + play->nextEntrance = D_80AF343C[ENTEST7_GET(&this->actor) - ENTEST7_1C]; + if ((play->nextEntrance == ENTRANCE(SOUTHERN_SWAMP_POISONED, 10)) && (gSaveContext.save.weekEventReg[20] & 2)) { + play->nextEntrance = ENTRANCE(SOUTHERN_SWAMP_CLEARED, 10); + } else if ((play->nextEntrance == ENTRANCE(MOUNTAIN_VILLAGE_WINTER, 8)) && + (gSaveContext.save.weekEventReg[33] & 0x80)) { + play->nextEntrance = ENTRANCE(MOUNTAIN_VILLAGE_SPRING, 8); } } - globalCtx->sceneLoadFlag = 0x14; - globalCtx->unk_1887F = 2; + play->transitionTrigger = TRANS_TRIGGER_START; + play->transitionType = TRANS_TYPE_02; gSaveContext.seqIndex = 0xFF; gSaveContext.nightSeqIndex = 0xFF; } -void func_80AF24D8(EnTest7* this, GlobalContext* globalCtx, f32 arg2) { +void func_80AF24D8(EnTest7* this, PlayState* play, f32 arg2) { Vec3f sp3C; Vec3f* pos; - Player* player = GET_PLAYER(globalCtx); - Camera* camera = Play_GetCamera(globalCtx, ActorCutscene_GetCurrentCamera(globalCtx->playerActorCsIds[8])); + Player* player = GET_PLAYER(play); + Camera* subCam = Play_GetCamera(play, ActorCutscene_GetCurrentSubCamId(play->playerActorCsIds[8])); pos = &player->actor.world.pos; - camera->player = NULL; + subCam->focalActor = NULL; sp3C.x = ((180.0f * Math_SinS(this->unk_1E8E)) * Math_CosS(0xFA0)) + pos->x; sp3C.y = (Math_SinS(0xFA0) * 180.0f) + pos->y; sp3C.z = ((180.0f * Math_CosS(this->unk_1E8E)) * Math_CosS(0xFA0)) + pos->z; - camera->eye.x = ((sp3C.x - camera->eye.x) * arg2) + camera->eye.x; - camera->eye.y = ((sp3C.y - camera->eye.y) * arg2) + camera->eye.y; - camera->eye.z = ((sp3C.z - camera->eye.z) * arg2) + camera->eye.z; + subCam->eye.x = ((sp3C.x - subCam->eye.x) * arg2) + subCam->eye.x; + subCam->eye.y = ((sp3C.y - subCam->eye.y) * arg2) + subCam->eye.y; + subCam->eye.z = ((sp3C.z - subCam->eye.z) * arg2) + subCam->eye.z; - camera->fov = ((this->unk_1E78 - camera->fov) * arg2) + camera->fov; - camera->at.y += 1.4444444f; + subCam->fov = ((this->subCamFov - subCam->fov) * arg2) + subCam->fov; + subCam->at.y += 1.4444444f; } -void func_80AF2654(EnTest7* this, GlobalContext* globalCtx, f32 arg2) { +void func_80AF2654(EnTest7* this, PlayState* play, f32 arg2) { Vec3f* pos; - Player* player = GET_PLAYER(globalCtx); - Camera* camera; + Player* player = GET_PLAYER(play); + Camera* subCam; Vec3f sp30; - camera = Play_GetCamera(globalCtx, ActorCutscene_GetCurrentCamera(globalCtx->playerActorCsIds[8])); - camera->player = NULL; + subCam = Play_GetCamera(play, ActorCutscene_GetCurrentSubCamId(play->playerActorCsIds[8])); + subCam->focalActor = NULL; pos = &player->actor.world.pos; @@ -711,52 +717,52 @@ void func_80AF2654(EnTest7* this, GlobalContext* globalCtx, f32 arg2) { sp30.y = (Math_SinS(0xBB8) * 80.0f) + pos->y; sp30.z = ((80.0f * Math_CosS(this->unk_1E8E)) * Math_CosS(0xBB8)) + pos->z; - camera->eye.x = ((sp30.x - camera->eye.x) * arg2) + camera->eye.x; - camera->eye.y = ((sp30.y - camera->eye.y) * arg2) + camera->eye.y; - camera->eye.z = ((sp30.z - camera->eye.z) * arg2) + camera->eye.z; + subCam->eye.x = ((sp30.x - subCam->eye.x) * arg2) + subCam->eye.x; + subCam->eye.y = ((sp30.y - subCam->eye.y) * arg2) + subCam->eye.y; + subCam->eye.z = ((sp30.z - subCam->eye.z) * arg2) + subCam->eye.z; - camera->at.x = ((pos->x - camera->at.x) * arg2) + camera->at.x; - camera->at.y = (((pos->y + 40.0f) - camera->at.y) * arg2) + camera->at.y; - camera->at.z = ((pos->z - camera->at.z) * arg2) + camera->at.z; + subCam->at.x = ((pos->x - subCam->at.x) * arg2) + subCam->at.x; + subCam->at.y = (((pos->y + 40.0f) - subCam->at.y) * arg2) + subCam->at.y; + subCam->at.z = ((pos->z - subCam->at.z) * arg2) + subCam->at.z; - camera->fov = ((this->unk_1E78 - camera->fov) * arg2) + camera->fov; + subCam->fov = ((this->subCamFov - subCam->fov) * arg2) + subCam->fov; } -void func_80AF2808(EnTest7* this, GlobalContext* globalCtx, f32 arg2) { - Player* player = GET_PLAYER(globalCtx); +void func_80AF2808(EnTest7* this, PlayState* play, f32 arg2) { + Player* player = GET_PLAYER(play); 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) { +void func_80AF2854(EnTest7* this, PlayState* play) { 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); + func_80AF24D8(this, play, temp); } else if ((this->unk_1E54 >= 79) && (this->unk_1E54 < 96)) { temp = (this->unk_1E54 - 79) / sixteen; - func_80AF2654(this, globalCtx, temp); + func_80AF2654(this, play, temp); } if ((this->unk_1E54 >= 42) && (this->unk_1E54 < 69)) { temp = (this->unk_1E54 - 42) / 26.0f; - func_80AF2808(this, globalCtx, temp); + func_80AF2808(this, play, temp); } } -void func_80AF2938(EnTest7* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); +void func_80AF2938(EnTest7* this, PlayState* play) { + Player* player = GET_PLAYER(play); 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) { + if (play->roomCtx.currRoom.unk3 != 1) { func_80AF082C(this, func_80AF2AE8); } else { func_80AF082C(this, func_80AF2EC8); @@ -767,58 +773,58 @@ s16 D_80AF3450[] = { 0, 0x31C7 }; f32 D_80AF3454 = 3500.0f; -void func_80AF29C0(EnTest7* this, GlobalContext* globalCtx) { +void func_80AF29C0(EnTest7* this, PlayState* play) { s32 pad; - Player* player = GET_PLAYER(globalCtx); + Player* player = GET_PLAYER(play); Vec3f* pos = &player->actor.world.pos; - Camera* temp_s0 = Play_GetCamera(globalCtx, ActorCutscene_GetCurrentCamera(globalCtx->playerActorCsIds[8])); + Camera* subCam = Play_GetCamera(play, ActorCutscene_GetCurrentSubCamId(play->playerActorCsIds[8])); - temp_s0->at.x = ((D_80AF3454 * Math_SinS(D_80AF3450[0]) * Math_CosS(D_80AF3450[1]))) + pos->x; - temp_s0->at.y = (Math_SinS(D_80AF3450[1]) * D_80AF3454) + pos->y; - temp_s0->at.z = ((D_80AF3454 * Math_CosS(D_80AF3450[0])) * Math_CosS(D_80AF3450[1])) + pos->z; + subCam->at.x = ((D_80AF3454 * Math_SinS(D_80AF3450[0]) * Math_CosS(D_80AF3450[1]))) + pos->x; + subCam->at.y = (Math_SinS(D_80AF3450[1]) * D_80AF3454) + pos->y; + subCam->at.z = ((D_80AF3454 * Math_CosS(D_80AF3450[0])) * Math_CosS(D_80AF3450[1])) + pos->z; - this->actor.world.pos.x = temp_s0->at.x; - this->actor.world.pos.y = temp_s0->at.y - 40.0f; - this->actor.world.pos.z = temp_s0->at.z; + this->actor.world.pos.x = subCam->at.x; + this->actor.world.pos.y = subCam->at.y - 40.0f; + this->actor.world.pos.z = subCam->at.z; } -void func_80AF2AE8(EnTest7* this, GlobalContext* globalCtx) { - Camera* camera; +void func_80AF2AE8(EnTest7* this, PlayState* play) { + Camera* subCam; - if (!ActorCutscene_GetCanPlayNext(globalCtx->playerActorCsIds[8])) { - ActorCutscene_SetIntentToPlay(globalCtx->playerActorCsIds[8]); + if (!ActorCutscene_GetCanPlayNext(play->playerActorCsIds[8])) { + ActorCutscene_SetIntentToPlay(play->playerActorCsIds[8]); return; } - ActorCutscene_Start(globalCtx->playerActorCsIds[8], NULL); + ActorCutscene_Start(play->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; + subCam = Play_GetCamera(play, ActorCutscene_GetCurrentSubCamId(play->playerActorCsIds[8])); + this->subCamEye = subCam->eye; + this->subCamAt = subCam->at; - func_80AF29C0(this, globalCtx); + func_80AF29C0(this, play); } -void func_80AF2BAC(EnTest7* this, GlobalContext* globalCtx, Vec3f* arg2, f32 arg3) { +void func_80AF2BAC(EnTest7* this, PlayState* play, Vec3f* arg2, f32 arg3) { f32 x; f32 y; f32 z; - Camera* camera = Play_GetCamera(globalCtx, ActorCutscene_GetCurrentCamera(globalCtx->playerActorCsIds[8])); + Camera* subCam = Play_GetCamera(play, ActorCutscene_GetCurrentSubCamId(play->playerActorCsIds[8])); - camera->player = NULL; - x = ((camera->at.x - arg2->x) * arg3) + arg2->x; - y = ((camera->at.y - arg2->y) * arg3) + arg2->y; - z = ((camera->at.z - arg2->z) * arg3) + arg2->z; + subCam->focalActor = NULL; + x = ((subCam->at.x - arg2->x) * arg3) + arg2->x; + y = ((subCam->at.y - arg2->y) * arg3) + arg2->y; + z = ((subCam->at.z - arg2->z) * arg3) + arg2->z; - camera->at.x = x; - camera->at.y = y; - camera->at.z = z; + subCam->at.x = x; + subCam->at.y = y; + subCam->at.z = z; } -void func_80AF2C48(EnTest7* this, GlobalContext* globalCtx) { +void func_80AF2C48(EnTest7* this, PlayState* play) { f32 sp24 = (40 - this->unk_1E54) / 40.0f; - Camera* camera; + Camera* subCam; this->unk_148.unk_00 = 11.0f; this->unk_144 |= 4; @@ -830,12 +836,12 @@ void func_80AF2C48(EnTest7* this, GlobalContext* globalCtx) { 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); + subCam = Play_GetCamera(play, ActorCutscene_GetCurrentSubCamId(play->playerActorCsIds[8])); + func_80AF2BAC(this, play, &this->actor.home.pos, sp24); - camera->at.x = this->actor.world.pos.x; - camera->at.y = this->actor.world.pos.y + 40.0f; - camera->at.z = this->actor.world.pos.z; + subCam->at.x = this->actor.world.pos.x; + subCam->at.y = this->actor.world.pos.y + 40.0f; + subCam->at.z = this->actor.world.pos.z; func_800B9010(&this->actor, NA_SE_PL_WARP_WING_ROLL_2 - SFX_FLAG); if (this->unk_1E54 >= 40) { @@ -844,43 +850,43 @@ void func_80AF2C48(EnTest7* this, GlobalContext* globalCtx) { } } -void func_80AF2DB4(EnTest7* this, GlobalContext* globalCtx) { - Camera* camera; - Player* player = GET_PLAYER(globalCtx); +void func_80AF2DB4(EnTest7* this, PlayState* play) { + Camera* subCam; + Player* player = GET_PLAYER(play); Vec3f* pos = &player->actor.world.pos; - camera = Play_GetCamera(globalCtx, ActorCutscene_GetCurrentCamera(globalCtx->playerActorCsIds[8])); + subCam = Play_GetCamera(play, ActorCutscene_GetCurrentSubCamId(play->playerActorCsIds[8])); - camera->eye.x = (Math_SinS(-player->actor.shape.rot.y) * 200.0f * -0.83907f) + pos->x; - camera->eye.y = pos->y + 108.8042f; - camera->eye.z = (Math_CosS(-player->actor.shape.rot.y) * 200.0f * -0.83907f) + pos->z; + subCam->eye.x = (Math_SinS(-player->actor.shape.rot.y) * 200.0f * -0.83907f) + pos->x; + subCam->eye.y = pos->y + 108.8042f; + subCam->eye.z = (Math_CosS(-player->actor.shape.rot.y) * 200.0f * -0.83907f) + pos->z; - camera->at.x = pos->x; - camera->at.y = pos->y + 40.0f; - camera->at.z = pos->z; + subCam->at.x = pos->x; + subCam->at.y = pos->y + 40.0f; + subCam->at.z = pos->z; } -void func_80AF2EC8(EnTest7* this, GlobalContext* globalCtx) { - Camera* camera; +void func_80AF2EC8(EnTest7* this, PlayState* play) { + Camera* subCam; - if (!ActorCutscene_GetCanPlayNext(globalCtx->playerActorCsIds[8])) { - ActorCutscene_SetIntentToPlay(globalCtx->playerActorCsIds[8]); + if (!ActorCutscene_GetCanPlayNext(play->playerActorCsIds[8])) { + ActorCutscene_SetIntentToPlay(play->playerActorCsIds[8]); } else { - ActorCutscene_Start(globalCtx->playerActorCsIds[8], NULL); + ActorCutscene_Start(play->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; + subCam = Play_GetCamera(play, ActorCutscene_GetCurrentSubCamId(play->playerActorCsIds[8])); + this->subCamEye = subCam->eye; + this->subCamAt = subCam->at; this->unk_1E54 = 40; - func_80AF2DB4(this, globalCtx); + func_80AF2DB4(this, play); } } -void func_80AF2F98(EnTest7* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); - Player* player2 = GET_PLAYER(globalCtx); +void func_80AF2F98(EnTest7* this, PlayState* play) { + Player* player = GET_PLAYER(play); + Player* player2 = GET_PLAYER(play); Vec3f sp2C; func_800B9010(&this->actor, NA_SE_PL_WARP_WING_ROLL_2 - SFX_FLAG); @@ -909,8 +915,8 @@ void func_80AF2F98(EnTest7* this, GlobalContext* globalCtx) { } } -void func_80AF30F4(EnTest7* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); +void func_80AF30F4(EnTest7* this, PlayState* play) { + Player* player = GET_PLAYER(play); if (this->unk_1E54 > 90) { player->stateFlags1 &= ~0x20; @@ -919,63 +925,62 @@ void func_80AF30F4(EnTest7* this, GlobalContext* globalCtx) { } } -void EnTest7_Update(Actor* thisx, GlobalContext* globalCtx) { +void EnTest7_Update(Actor* thisx, PlayState* play) { EnTest7* this = THIS; - this->unk_1E58(this, globalCtx); + this->unk_1E58(this, play); if (this->actionFunc != NULL) { - this->actionFunc(this, globalCtx); + this->actionFunc(this, play); } this->unk_1E54++; - func_80AF118C(globalCtx, this->unk_15C, this, (this->unk_144 & 8) != 0, (this->unk_144 & 0x10) != 0); + func_80AF118C(play, 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) { +s32 func_80AF31D0(PlayState* play, SkeletonInfo* skeletonInfo, s32 limbIndex, Gfx** dList, u8* flags, Actor* thisx, + Vec3f* scale, Vec3s* rot, Vec3f* pos) { EnTest7* this = THIS; Vec3f sp18; if ((*dList != NULL) && (Rand_ZeroOne() < 0.03f)) { - Matrix_MultiplyVector3fByState(&gZeroVec3f, &sp18); + Matrix_MultVec3f(&gZeroVec3f, &sp18); func_80AF0C30(this->unk_15C, &sp18, 0); } return true; } -void EnTest7_Draw(Actor* thisx, GlobalContext* globalCtx) { +void EnTest7_Draw(Actor* thisx, PlayState* play) { 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)); + Mtx* mtx = GRAPH_ALLOC(play->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); + func_8018450C(play, &this->unk_18CC, mtx, func_80AF31D0, NULL, &this->actor); } else { return; } } if (this->unk_144 & 2) { - Matrix_StatePush(); - Matrix_InsertTranslation(0.0f, 4000.0f, 0.0f, MTXMODE_APPLY); - Matrix_InsertRotation(0, this->unk_148.unk_10, 0, MTXMODE_APPLY); + Matrix_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_StatePop(); + AnimatedMat_DrawStep(play, Lib_SegmentedToVirtual(&gameplay_keep_Matanimheader_0815D0), sp40); + Gfx_DrawDListXlu(play, gameplay_keep_DL_080FC8); + Matrix_Pop(); } - func_80AF14FC(globalCtx, this->unk_15C); + func_80AF14FC(play, 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); + func_800F9824(play, &play->envCtx, &play->view, play->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 a074c7875..da6dec94b 100644 --- a/src/overlays/actors/ovl_En_Test7/z_en_test7.h +++ b/src/overlays/actors/ovl_En_Test7/z_en_test7.h @@ -5,9 +5,9 @@ struct EnTest7; -typedef void (*EnTest7ActionFunc)(struct EnTest7*, GlobalContext*); -typedef void (*EnTest7UnkFunc)(struct EnTest7*, GlobalContext*); -typedef void (*EnTest7UnkDrawFunc)(Actor*, GlobalContext*); +typedef void (*EnTest7ActionFunc)(struct EnTest7*, PlayState*); +typedef void (*EnTest7UnkFunc)(struct EnTest7*, PlayState*); +typedef void (*EnTest7UnkDrawFunc)(Actor*, PlayState*); #define ENTEST7_GET(thisx) ((thisx)->params) @@ -47,13 +47,13 @@ typedef struct EnTest7 { /* 0x015C */ EnTest7Struct2 unk_15C[100]; /* 0x18CC */ SkeletonInfo unk_18CC; /* 0x18FC */ Vec3s unk_18FC[114]; - /* 0x1BA8 */ s16 unk_1BA8[342]; + /* 0x1BA8 */ Vec3s unk_1BA8[114]; /* 0x1E54 */ s32 unk_1E54; /* 0x1E58 */ EnTest7UnkFunc unk_1E58; /* 0x1E5C */ EnTest7ActionFunc actionFunc; - /* 0x1E60 */ Vec3f unk_1E60; - /* 0x1E6C */ Vec3f unk_1E6C; - /* 0x1E78 */ f32 unk_1E78; + /* 0x1E60 */ Vec3f subCamEye; + /* 0x1E6C */ Vec3f subCamAt; + /* 0x1E78 */ f32 subCamFov; /* 0x1E7C */ LightNode* lightNode; /* 0x1E80 */ LightInfo lightInfo; /* 0x1E8E */ s16 unk_1E8E; diff --git a/src/overlays/actors/ovl_En_Tg/z_en_tg.c b/src/overlays/actors/ovl_En_Tg/z_en_tg.c index fe3aadc7b..c090a050d 100644 --- a/src/overlays/actors/ovl_En_Tg/z_en_tg.c +++ b/src/overlays/actors/ovl_En_Tg/z_en_tg.c @@ -10,12 +10,12 @@ #define THIS ((EnTg*)thisx) -void EnTg_Init(Actor* thisx, GlobalContext* globalCtx); -void EnTg_Destroy(Actor* thisx, GlobalContext* globalCtx); -void EnTg_Update(Actor* thisx, GlobalContext* globalCtx); -void EnTg_Draw(Actor* thisx, GlobalContext* globalCtx); +void EnTg_Init(Actor* thisx, PlayState* play); +void EnTg_Destroy(Actor* thisx, PlayState* play); +void EnTg_Update(Actor* thisx, PlayState* play); +void EnTg_Draw(Actor* thisx, PlayState* play); -void func_8098FA70(EnTg* this, GlobalContext* globalCtx); +void func_8098FA70(EnTg* this, PlayState* play); #if 0 const ActorInit En_Tg_InitVars = { diff --git a/src/overlays/actors/ovl_En_Tg/z_en_tg.h b/src/overlays/actors/ovl_En_Tg/z_en_tg.h index de0c6fd2e..2798b99b3 100644 --- a/src/overlays/actors/ovl_En_Tg/z_en_tg.h +++ b/src/overlays/actors/ovl_En_Tg/z_en_tg.h @@ -5,12 +5,12 @@ struct EnTg; -typedef void (*EnTgActionFunc)(struct EnTg*, GlobalContext*); +typedef void (*EnTgActionFunc)(struct EnTg*, PlayState*); typedef struct EnTg { - /* 0x0000 */ Actor actor; - /* 0x0144 */ EnTgActionFunc actionFunc; - /* 0x0148 */ char unk_148[0x400]; + /* 0x000 */ Actor actor; + /* 0x144 */ EnTgActionFunc actionFunc; + /* 0x148 */ char unk_148[0x400]; } EnTg; // size = 0x548 extern const ActorInit En_Tg_InitVars; diff --git a/src/overlays/actors/ovl_En_Thiefbird/z_en_thiefbird.c b/src/overlays/actors/ovl_En_Thiefbird/z_en_thiefbird.c index 5a89347e7..03c7d0e1d 100644 --- a/src/overlays/actors/ovl_En_Thiefbird/z_en_thiefbird.c +++ b/src/overlays/actors/ovl_En_Thiefbird/z_en_thiefbird.c @@ -5,33 +5,32 @@ */ #include "z_en_thiefbird.h" -#include "objects/object_thiefbird/object_thiefbird.h" #define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_4 | ACTOR_FLAG_200 | ACTOR_FLAG_1000 | ACTOR_FLAG_80000000) #define THIS ((EnThiefbird*)thisx) -void EnThiefbird_Init(Actor* thisx, GlobalContext* globalCtx); -void EnThiefbird_Destroy(Actor* thisx, GlobalContext* globalCtx); -void EnThiefbird_Update(Actor* thisx, GlobalContext* globalCtx); -void EnThiefbird_Draw(Actor* thisx, GlobalContext* globalCtx); +void EnThiefbird_Init(Actor* thisx, PlayState* play); +void EnThiefbird_Destroy(Actor* thisx, PlayState* play); +void EnThiefbird_Update(Actor* thisx, PlayState* play); +void EnThiefbird_Draw(Actor* thisx, PlayState* play); void func_80C11538(EnThiefbird* this); -void func_80C11590(EnThiefbird* this, GlobalContext* globalCtx); +void func_80C11590(EnThiefbird* this, PlayState* play); void func_80C118E4(EnThiefbird* this); -void func_80C1193C(EnThiefbird* this, GlobalContext* globalCtx); -void func_80C11D14(EnThiefbird* this, GlobalContext* globalCtx); +void func_80C1193C(EnThiefbird* this, PlayState* play); +void func_80C11D14(EnThiefbird* this, PlayState* play); void func_80C11DC0(EnThiefbird* this); -void func_80C11DF0(EnThiefbird* this, GlobalContext* globalCtx); -void func_80C1215C(EnThiefbird* this, GlobalContext* globalCtx); +void func_80C11DF0(EnThiefbird* this, PlayState* play); +void func_80C1215C(EnThiefbird* this, PlayState* play); void func_80C12308(EnThiefbird* this); -void func_80C12378(EnThiefbird* this, GlobalContext* globalCtx); +void func_80C12378(EnThiefbird* this, PlayState* play); void func_80C1242C(EnThiefbird* this); -void func_80C124B0(EnThiefbird* this, GlobalContext* globalCtx); +void func_80C124B0(EnThiefbird* this, PlayState* play); void func_80C126A8(EnThiefbird* this); -void func_80C126D8(EnThiefbird* this, GlobalContext* globalCtx); +void func_80C126D8(EnThiefbird* this, PlayState* play); void func_80C12744(EnThiefbird* this); -void func_80C127F4(EnThiefbird* this, GlobalContext* globalCtx); +void func_80C127F4(EnThiefbird* this, PlayState* play); const ActorInit En_Thiefbird_InitVars = { ACTOR_EN_THIEFBIRD, @@ -90,7 +89,7 @@ static ColliderJntSphInit sJntSphInit = { OC2_TYPE_1, COLSHAPE_JNTSPH, }, - 3, + ARRAY_COUNT(sJntSphElementsInit), sJntSphElementsInit, }; @@ -144,15 +143,15 @@ static InitChainEntry sInitChain[] = { static Vec3f D_80C13920; static s32 D_80C1392C; -void EnThiefbird_Init(Actor* thisx, GlobalContext* globalCtx) { +void EnThiefbird_Init(Actor* thisx, PlayState* play) { EnThiefbird* this = THIS; s32 i; ColliderJntSphElementDim* dim; Actor_ProcessInitChain(&this->actor, sInitChain); - SkelAnime_InitFlex(globalCtx, &this->skelAnime, &object_thiefbird_Skel_0061A0, &object_thiefbird_Anim_000604, - this->jointTable, this->morphTable, 17); - Collider_InitAndSetJntSph(globalCtx, &this->collider, &this->actor, &sJntSphInit, this->colliderElements); + SkelAnime_InitFlex(play, &this->skelAnime, &gTakkuriSkel, &gTakkuriFlyAnim, this->jointTable, this->morphTable, + TAKKURI_LIMB_MAX); + Collider_InitAndSetJntSph(play, &this->collider, &this->actor, &sJntSphInit, this->colliderElements); for (i = 0; i < ARRAY_COUNT(this->colliderElements); i++) { dim = &this->collider.elements[i].dim; @@ -175,10 +174,10 @@ void EnThiefbird_Init(Actor* thisx, GlobalContext* globalCtx) { } } -void EnThiefbird_Destroy(Actor* thisx, GlobalContext* globalCtx) { +void EnThiefbird_Destroy(Actor* thisx, PlayState* play) { EnThiefbird* this = THIS; - Collider_DestroyJntSph(globalCtx, &this->collider); + Collider_DestroyJntSph(play, &this->collider); } void func_80C10984(EnThiefbird* this, s32 arg1) { @@ -196,7 +195,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; @@ -205,8 +204,8 @@ void func_80C10984(EnThiefbird* this, s32 arg1) { } } -s32 func_80C10B0C(EnThiefbird* this, GlobalContext* globalCtx) { - static Gfx* D_80C13680[] = { object_thiefbird_DL_004348, object_thiefbird_DL_004B88, object_thiefbird_DL_0055E0 }; +s32 func_80C10B0C(EnThiefbird* this, PlayState* play) { + static Gfx* D_80C13680[] = { gTakkuriStolenKokiriSwordDL, gTakkuriStolenRazorSwordDL, gTakkuriStolenGildedSwordDL }; s32 isItemFound = false; s32 phi_a3 = 0; s32 slotId = SLOT_BOTTLE_1; @@ -223,7 +222,7 @@ s32 func_80C10B0C(EnThiefbird* this, GlobalContext* globalCtx) { } if (gSaveContext.save.playerForm == PLAYER_FORM_HUMAN) { - phi_a3 = GET_CUR_EQUIP_VALUE(EQUIP_SWORD); + phi_a3 = GET_CUR_EQUIP_VALUE(EQUIP_TYPE_SWORD); if (INV_CONTENT(ITEM_SWORD_GREAT_FAIRY) == ITEM_SWORD_GREAT_FAIRY) { phi_a3 += 4; } @@ -238,10 +237,10 @@ 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) == 0) { - Message_StartTextbox(globalCtx, 0xF4, NULL); + Inventory_DeleteItem(itemId2, slotId); + this->unk_3E8 = gTakkuriStolenBottleDL; + if (Message_GetState(&play->msgCtx) == TEXT_STATE_NONE) { + Message_StartTextbox(play, 0xF4, NULL); } itemId1 = ITEM_BOTTLE; } else if (phi_a3 != 0) { @@ -255,17 +254,17 @@ s32 func_80C10B0C(EnThiefbird* this, GlobalContext* globalCtx) { itemId1 = phi_a3 + (ITEM_SWORD_KOKIRI - 1); if (phi_a3 == 4) { - func_801149A0(ITEM_SWORD_GREAT_FAIRY, SLOT_SWORD_GREAT_FAIRY); - this->unk_3E8 = object_thiefbird_DL_003D58; + Inventory_DeleteItem(ITEM_SWORD_GREAT_FAIRY, SLOT_SWORD_GREAT_FAIRY); + this->unk_3E8 = gTakkuriStolenGreatFairySwordDL; itemId1 = ITEM_SWORD_GREAT_FAIRY; } else { CUR_FORM_EQUIP(EQUIP_SLOT_B) = ITEM_NONE; - SET_EQUIP_VALUE(EQUIP_SWORD, 0); + SET_EQUIP_VALUE(EQUIP_TYPE_SWORD, EQUIP_VALUE_SWORD_NONE); this->unk_3E8 = D_80C13680[phi_a3 - 1]; } - if (Message_GetState(&globalCtx->msgCtx) == 0) { - Message_StartTextbox(globalCtx, 0xF5, NULL); + if (Message_GetState(&play->msgCtx) == TEXT_STATE_NONE) { + Message_StartTextbox(play, 0xF5, NULL); } } else { return false; @@ -300,8 +299,8 @@ void func_80C10DE8(s32 items[], s32 count, s32 item) { } } -s32 func_80C10E98(GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); +s32 func_80C10E98(PlayState* play) { + Player* player = GET_PLAYER(play); s32 phi_s0_2; s32 phi_s2; s32 spB0; @@ -390,7 +389,7 @@ s32 func_80C10E98(GlobalContext* globalCtx) { sp64.y = player->actor.world.pos.y + 20.0f; sp64.z = (Math_CosS(phi_s3) * 40.0f) + player->actor.world.pos.z; if (dropItem00Ids[i] != ITEM00_NO_DROP) { - Actor* temp_s1_5 = Item_DropCollectible(globalCtx, &sp64, dropItem00Ids[i]); + Actor* temp_s1_5 = Item_DropCollectible(play, &sp64, dropItem00Ids[i]); if (temp_s1_5 != NULL) { temp_s1_5->velocity.y = Rand_ZeroFloat(3.0f) + 6.0f; @@ -404,12 +403,12 @@ s32 func_80C10E98(GlobalContext* globalCtx) { AMMO(ITEM_BOMB) -= spB0 * 5; AMMO(ITEM_BOW) -= spAC * 10; - func_801159EC(-((phi_s0_2 * 50) + (spA0 * 20) + (phi_s2 * 5) + spA8)); + Rupees_ChangeBy(-((phi_s0_2 * 50) + (spA0 * 20) + (phi_s2 * 5) + spA8)); return true; } -void func_80C11338(EnThiefbird* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); +void func_80C11338(EnThiefbird* this, PlayState* play) { + Player* player = GET_PLAYER(play); EnItem00* item = NULL; f32 phi_f20 = 5000.0f; s32 i; @@ -418,7 +417,7 @@ void func_80C11338(EnThiefbird* this, GlobalContext* globalCtx) { this->unk_3EC = NULL; do { - item = (EnItem00*)SubS_FindActor(globalCtx, &item->actor, ACTORCAT_MISC, ACTOR_EN_ITEM00); + item = (EnItem00*)SubS_FindActor(play, &item->actor, ACTORCAT_MISC, ACTOR_EN_ITEM00); if (item != NULL) { if (item->unk152 > 0) { if (Actor_XZDistanceBetweenActors(&player->actor, &item->actor) > 10.0f) { @@ -451,24 +450,24 @@ void func_80C11454(EnThiefbird* this) { Actor_SetColorFilter(&this->actor, 0x4000, 255, 0, 80); } -void func_80C114C0(EnThiefbird* this, GlobalContext* globalCtx) { +void func_80C114C0(EnThiefbird* this, PlayState* play) { 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); + Actor_SpawnIceEffects(play, &this->actor, this->limbPos, 11, 2, 0.2f, 0.2f); this->actor.flags |= ACTOR_FLAG_200; } } void func_80C11538(EnThiefbird* this) { - Animation_MorphToLoop(&this->skelAnime, &object_thiefbird_Anim_000604, -4.0f); + Animation_MorphToLoop(&this->skelAnime, &gTakkuriFlyAnim, -4.0f); this->unk_18E = 60; this->collider.base.acFlags |= AC_ON; this->actionFunc = func_80C11590; } -void func_80C11590(EnThiefbird* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); +void func_80C11590(EnThiefbird* this, PlayState* play) { + Player* player = GET_PLAYER(play); s32 sp38; SkelAnime_Update(&this->skelAnime); @@ -519,20 +518,20 @@ void func_80C11590(EnThiefbird* this, GlobalContext* globalCtx) { } if ((this->unk_18E == 0) && (this->actor.xzDistToPlayer < 300.0f) && !(player->stateFlags1 & 0x800000) && - (Player_GetMask(globalCtx) != PLAYER_MASK_STONE) && (this->actor.depthInWater < -40.0f)) { + (Player_GetMask(play) != PLAYER_MASK_STONE) && (this->actor.depthInWater < -40.0f)) { func_80C118E4(this); } } void func_80C118E4(EnThiefbird* this) { - Animation_MorphToLoop(&this->skelAnime, &object_thiefbird_Anim_0063C4, -10.0f); + Animation_MorphToLoop(&this->skelAnime, &gTakkuriAttackAnim, -10.0f); this->unk_18E = 300; this->actionFunc = func_80C1193C; this->actor.speedXZ = 5.0f; } -void func_80C1193C(EnThiefbird* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); +void func_80C1193C(EnThiefbird* this, PlayState* play) { + Player* player = GET_PLAYER(play); s16 pitch; SkelAnime_Update(&this->skelAnime); @@ -562,7 +561,7 @@ void func_80C1193C(EnThiefbird* this, GlobalContext* globalCtx) { Math_SmoothStepToS(&this->actor.shape.rot.y, rot, 4, 0x1000, 0x100); } - if ((this->unk_18E == 0) || (player->stateFlags1 & 0x800000) || (Player_GetMask(globalCtx) == PLAYER_MASK_STONE) || + if ((this->unk_18E == 0) || (player->stateFlags1 & 0x800000) || (Player_GetMask(play) == PLAYER_MASK_STONE) || (this->collider.base.atFlags & AT_HIT) || (this->actor.bgCheckFlags & 1) || (this->actor.depthInWater > -40.0f)) { if (this->collider.base.atFlags & AT_HIT) { @@ -571,10 +570,10 @@ void func_80C1193C(EnThiefbird* this, GlobalContext* globalCtx) { if (!(this->collider.base.atFlags & AT_BOUNCED)) { if ((D_80C1392C != 0) && CUR_UPG_VALUE(UPG_QUIVER) && ((STOLEN_ITEM_1 == STOLEN_ITEM_NONE) || (STOLEN_ITEM_2 == STOLEN_ITEM_NONE)) && - (Rand_ZeroOne() < 0.5f) && func_80C10B0C(this, globalCtx)) { + (Rand_ZeroOne() < 0.5f) && func_80C10B0C(this, play)) { func_80C1242C(this); - } else if (func_80C10E98(globalCtx)) { - func_80C11338(this, globalCtx); + } else if (func_80C10E98(play)) { + func_80C11338(this, play); func_80C12744(this); } else { func_80C11538(this); @@ -591,7 +590,7 @@ void func_80C1193C(EnThiefbird* this, GlobalContext* globalCtx) { void func_80C11C60(EnThiefbird* this) { this->actor.speedXZ = 0.0f; this->actor.velocity.y = 0.0f; - Animation_PlayOnce(&this->skelAnime, &object_thiefbird_Anim_000088); + Animation_PlayOnce(&this->skelAnime, &gTakkuriDeathAnim); this->actor.bgCheckFlags &= ~1; this->actor.shape.rot.x = 0; this->unk_18E = 40; @@ -604,7 +603,7 @@ void func_80C11C60(EnThiefbird* this) { this->actionFunc = func_80C11D14; } -void func_80C11D14(EnThiefbird* this, GlobalContext* globalCtx) { +void func_80C11D14(EnThiefbird* this, PlayState* play) { this->actor.colorFilterTimer = 40; if (this->unk_18E != 0) { this->unk_18E--; @@ -612,7 +611,7 @@ void func_80C11D14(EnThiefbird* this, GlobalContext* globalCtx) { if (this->drawDmgEffType == ACTOR_DRAW_DMGEFF_FROZEN_NO_SFX) { if (this->unk_18E < 38) { - func_80C114C0(this, globalCtx); + func_80C114C0(this, play); this->actor.speedXZ = 4.0f; } else { return; @@ -635,7 +634,7 @@ void func_80C11DC0(EnThiefbird* this) { this->actor.gravity = -0.5f; } -void func_80C11DF0(EnThiefbird* this, GlobalContext* globalCtx) { +void func_80C11DF0(EnThiefbird* this, PlayState* play) { s32 i; s32 j; @@ -646,15 +645,15 @@ 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->limbPos); i++) { - func_800B3030(globalCtx, &this->limbPos[i], &gZeroVec3f, &gZeroVec3f, 0x8C, 0, 0); + func_800B3030(play, &this->limbPos[i], &gZeroVec3f, &gZeroVec3f, 0x8C, 0, 0); } - SoundSource_PlaySfxAtFixedWorldPos(globalCtx, &this->actor.world.pos, 11, NA_SE_EN_EXTINCT); - Item_DropCollectible(globalCtx, &this->actor.world.pos, ITEM00_RUPEE_HUGE); + SoundSource_PlaySfxAtFixedWorldPos(play, &this->actor.world.pos, 11, NA_SE_EN_EXTINCT); + Item_DropCollectible(play, &this->actor.world.pos, ITEM00_RUPEE_HUGE); for (i = 0; i < ARRAY_COUNT(D_80C13664); i++) { for (j = 0; j < this->unk_196[i]; j++) { - Item_DropCollectible(globalCtx, &this->actor.world.pos, D_80C13664[i]); + Item_DropCollectible(play, &this->actor.world.pos, D_80C13664[i]); } } @@ -662,8 +661,8 @@ void func_80C11DF0(EnThiefbird* this, GlobalContext* globalCtx) { } } -void func_80C11F6C(EnThiefbird* this, GlobalContext* globalCtx) { - Animation_MorphToLoop(&this->skelAnime, &object_thiefbird_Anim_000278, -4.0f); +void func_80C11F6C(EnThiefbird* this, PlayState* play) { + Animation_MorphToLoop(&this->skelAnime, &gTakkuriFlyWithItemAnim, -4.0f); func_80C10984(this, 15); if (this->actor.colChkInfo.damageEffect != 3) { this->actor.speedXZ = 4.0f; @@ -692,20 +691,20 @@ void func_80C11F6C(EnThiefbird* this, GlobalContext* globalCtx) { this->unk_18E = 40; if (Rand_ZeroOne() < 0.9f) { - Item_DropCollectible(globalCtx, &this->actor.focus.pos, ITEM00_RUPEE_GREEN); + Item_DropCollectible(play, &this->actor.focus.pos, ITEM00_RUPEE_GREEN); } if (Rand_ZeroOne() < 0.6f) { - Item_DropCollectible(globalCtx, &this->actor.focus.pos, ITEM00_RUPEE_GREEN); + Item_DropCollectible(play, &this->actor.focus.pos, ITEM00_RUPEE_GREEN); } if (Rand_ZeroOne() < 0.3f) { - Item_DropCollectible(globalCtx, &this->actor.focus.pos, ITEM00_RUPEE_GREEN); + Item_DropCollectible(play, &this->actor.focus.pos, ITEM00_RUPEE_GREEN); } this->actionFunc = func_80C1215C; } -void func_80C1215C(EnThiefbird* this, GlobalContext* globalCtx) { +void func_80C1215C(EnThiefbird* this, PlayState* play) { f32 sp2C; if (this->unk_18E != 0) { @@ -714,7 +713,7 @@ void func_80C1215C(EnThiefbird* this, GlobalContext* globalCtx) { if (this->drawDmgEffType == ACTOR_DRAW_DMGEFF_FROZEN_NO_SFX) { if (this->unk_18E < 38) { - func_80C114C0(this, globalCtx); + func_80C114C0(this, play); this->actor.speedXZ = 4.0f; } else { return; @@ -747,7 +746,7 @@ void func_80C1215C(EnThiefbird* this, GlobalContext* globalCtx) { } void func_80C12308(EnThiefbird* this) { - Animation_MorphToLoop(&this->skelAnime, &object_thiefbird_Anim_000278, -4.0f); + Animation_MorphToLoop(&this->skelAnime, &gTakkuriFlyWithItemAnim, -4.0f); func_80C10984(this, 15); this->unk_190 = -0x1000; this->unk_192 = BINANG_ROT180(this->actor.yawTowardsPlayer); @@ -755,7 +754,7 @@ void func_80C12308(EnThiefbird* this) { this->actionFunc = func_80C12378; } -void func_80C12378(EnThiefbird* this, GlobalContext* globalCtx) { +void func_80C12378(EnThiefbird* this, PlayState* play) { if (this->unk_18E != 0) { this->unk_18E--; } @@ -776,14 +775,14 @@ 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); + Animation_Change(&this->skelAnime, &gTakkuriFlyWithItemAnim, 2.0f, 0.0f, 0.0f, ANIMMODE_LOOP, -4.0f); this->actor.flags |= ACTOR_FLAG_10; this->collider.base.acFlags |= AC_ON; this->actionFunc = func_80C124B0; this->actor.speedXZ = 12.0f; } -void func_80C124B0(EnThiefbird* this, GlobalContext* globalCtx) { +void func_80C124B0(EnThiefbird* this, PlayState* play) { Actor* temp_v0; s16 temp_v1; @@ -796,7 +795,7 @@ void func_80C124B0(EnThiefbird* this, GlobalContext* globalCtx) { Math_SmoothStepToS(&this->actor.shape.rot.y, this->unk_192, 6, 0x1000, 0x100); Math_SmoothStepToS(&this->actor.shape.rot.x, Actor_PitchToPoint(&this->actor, &D_80C13920), 6, 0x1000, 0x100); - temp_v0 = func_800BC270(globalCtx, &this->actor, 80.0f, 0x138B0); + temp_v0 = func_800BC270(play, &this->actor, 80.0f, 0x138B0); if (temp_v0 != NULL) { temp_v1 = temp_v0->world.rot.x - Actor_PitchToPoint(temp_v0, &this->actor.focus.pos); if (ABS_ALT(temp_v1) < 0x1800) { @@ -827,7 +826,7 @@ void func_80C126A8(EnThiefbird* this) { this->actionFunc = func_80C126D8; } -void func_80C126D8(EnThiefbird* this, GlobalContext* globalCtx) { +void func_80C126D8(EnThiefbird* this, PlayState* play) { SkelAnime_Update(&this->skelAnime); Math_ApproachS(&this->actor.shape.rot.x, 0x3000, 6, 0x1000); if (this->actor.playerHeightRel > 100.0f) { @@ -836,8 +835,8 @@ void func_80C126D8(EnThiefbird* this, GlobalContext* globalCtx) { } void func_80C12744(EnThiefbird* this) { - Animation_MorphToLoop(&this->skelAnime, &object_thiefbird_Anim_000604, -4.0f); - Animation_Change(&this->skelAnime, &object_thiefbird_Anim_000604, 1.0f, 0.0f, 0.0f, 1, -4.0f); + Animation_MorphToLoop(&this->skelAnime, &gTakkuriFlyAnim, -4.0f); + Animation_Change(&this->skelAnime, &gTakkuriFlyAnim, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP_INTERP, -4.0f); this->unk_190 = 0; this->collider.base.acFlags |= AC_ON; this->actor.flags |= ACTOR_FLAG_10; @@ -846,8 +845,8 @@ void func_80C12744(EnThiefbird* this) { this->skelAnime.playSpeed = 3.0f; } -void func_80C127F4(EnThiefbird* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); +void func_80C127F4(EnThiefbird* this, PlayState* play) { + Player* player = GET_PLAYER(play); s16 temp_v0; f32 temp_f0; @@ -866,7 +865,7 @@ void func_80C127F4(EnThiefbird* this, GlobalContext* globalCtx) { } if (this->unk_3EC == NULL) { - func_80C11338(this, globalCtx); + func_80C11338(this, play); } if (this->unk_3EC != NULL) { @@ -912,7 +911,7 @@ void func_80C127F4(EnThiefbird* this, GlobalContext* globalCtx) { } } -void func_80C12B1C(EnThiefbird* this, GlobalContext* globalCtx) { +void func_80C12B1C(EnThiefbird* this, PlayState* play) { ColliderJntSphElement* sph; s32 i; @@ -920,7 +919,7 @@ void func_80C12B1C(EnThiefbird* this, GlobalContext* globalCtx) { this->collider.base.acFlags &= ~AC_HIT; this->collider.base.atFlags &= ~AT_HIT; Actor_SetDropFlag(&this->actor, &this->collider.elements->info); - func_80C114C0(this, globalCtx); + func_80C114C0(this, play); this->unk_194 = 0; for (i = 0; i < ARRAY_COUNT(this->colliderElements); i++) { @@ -937,7 +936,7 @@ void func_80C12B1C(EnThiefbird* this, GlobalContext* globalCtx) { 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, + Actor_Spawn(&play->actorCtx, play, 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) { @@ -956,11 +955,11 @@ void func_80C12B1C(EnThiefbird* this, GlobalContext* globalCtx) { if (!Actor_ApplyDamage(&this->actor)) { this->actor.colChkInfo.health = 0; - Enemy_StartFinishingBlow(globalCtx, &this->actor); + Enemy_StartFinishingBlow(play, &this->actor); func_80C10984(this, 40); func_80C11C60(this); } else { - func_80C11F6C(this, globalCtx); + func_80C11F6C(this, play); } } } @@ -995,12 +994,12 @@ void func_80C12D00(EnThiefbird* this) { } } -void EnThiefbird_Update(Actor* thisx, GlobalContext* globalCtx2) { - GlobalContext* globalCtx = globalCtx2; +void EnThiefbird_Update(Actor* thisx, PlayState* play2) { + PlayState* play = play2; EnThiefbird* this = THIS; - func_80C12B1C(this, globalCtx); - this->actionFunc(this, globalCtx); + func_80C12B1C(this, play); + this->actionFunc(this, play); this->actor.world.rot.y = this->actor.shape.rot.y; this->actor.world.rot.x = -this->actor.shape.rot.x; if (this->actor.colChkInfo.health != 0) { @@ -1009,16 +1008,16 @@ void EnThiefbird_Update(Actor* thisx, GlobalContext* globalCtx2) { Actor_MoveWithGravity(&this->actor); } - Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 25.0f, 25.0f, 50.0f, 7); + Actor_UpdateBgCheckInfo(play, &this->actor, 25.0f, 25.0f, 50.0f, 7); if (this->actionFunc == func_80C1193C) { - CollisionCheck_SetAT(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + CollisionCheck_SetAT(play, &play->colChkCtx, &this->collider.base); } if (this->collider.base.acFlags & AC_ON) { - CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + CollisionCheck_SetAC(play, &play->colChkCtx, &this->collider.base); } - CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + CollisionCheck_SetOC(play, &play->colChkCtx, &this->collider.base); if (this->drawDmgEffAlpha > 0.0f) { if (this->drawDmgEffType != ACTOR_DRAW_DMGEFF_FROZEN_NO_SFX) { Math_StepToF(&this->drawDmgEffAlpha, 0.0f, 0.05f); @@ -1030,29 +1029,28 @@ void EnThiefbird_Update(Actor* thisx, GlobalContext* globalCtx2) { } func_80C12D00(this); - if (((this->skelAnime.animation == &object_thiefbird_Anim_000604) && Animation_OnFrame(&this->skelAnime, 13.0f)) || - ((this->skelAnime.animation == &object_thiefbird_Anim_000278) && Animation_OnFrame(&this->skelAnime, 1.0f))) { + if (((this->skelAnime.animation == &gTakkuriFlyAnim) && Animation_OnFrame(&this->skelAnime, 13.0f)) || + ((this->skelAnime.animation == &gTakkuriFlyWithItemAnim) && Animation_OnFrame(&this->skelAnime, 1.0f))) { Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_KAICHO_FLUTTER); } } -s32 EnThiefbird_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, - Actor* thisx) { +s32 EnThiefbird_OverrideLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, Actor* thisx) { EnThiefbird* this = THIS; - if ((limbIndex == 10) || (limbIndex == 11)) { + if ((limbIndex == TAKKURI_LIMB_RIGHT_EAR) || (limbIndex == TAKKURI_LIMB_LEFT_EAR)) { this->unk_3E4 = *dList; *dList = NULL; - } else if (limbIndex == 16) { + } else if (limbIndex == TAKKURI_LIMB_STOLEN_ITEM) { *dList = NULL; - } else if (limbIndex == 8) { + } else if (limbIndex == TAKKURI_LIMB_NECK) { rot->z += this->unk_194; } return false; } -void EnThiefbird_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx) { +void EnThiefbird_PostLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx) { static s8 D_80C13698[] = { -1, 0, -1, 1, 3, -1, 2, 5, -1, -1, 7, 8, 9, -1, -1, 10, -1, }; @@ -1062,95 +1060,95 @@ void EnThiefbird_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dLi s8 idx; Collider_UpdateSpheres(limbIndex, &this->collider); - if ((limbIndex == 10) || (limbIndex == 11)) { - OPEN_DISPS(globalCtx->state.gfxCtx); + if ((limbIndex == TAKKURI_LIMB_RIGHT_EAR) || (limbIndex == TAKKURI_LIMB_LEFT_EAR)) { + OPEN_DISPS(play->state.gfxCtx); gfx = POLY_OPA_DISP; - Matrix_NormalizeXYZ(&globalCtx->billboardMtxF); - gSPMatrix(&gfx[0], Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + Matrix_ReplaceRotation(&play->billboardMtxF); + gSPMatrix(&gfx[0], Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(&gfx[1], this->unk_3E4); POLY_OPA_DISP = &gfx[2]; - CLOSE_DISPS(globalCtx->state.gfxCtx); - } else if (limbIndex == 16) { + CLOSE_DISPS(play->state.gfxCtx); + } else if (limbIndex == TAKKURI_LIMB_STOLEN_ITEM) { if (this->unk_3E8 != NULL) { - OPEN_DISPS(globalCtx->state.gfxCtx); + OPEN_DISPS(play->state.gfxCtx); - if (this->unk_3E8 == object_thiefbird_DL_0033B0) { + if (this->unk_3E8 == gTakkuriStolenBottleDL) { gfx = POLY_XLU_DISP; } else { gfx = POLY_OPA_DISP; } - gSPMatrix(&gfx[0], Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPMatrix(&gfx[0], Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(&gfx[1], this->unk_3E8); - if (this->unk_3E8 == object_thiefbird_DL_0033B0) { + if (this->unk_3E8 == gTakkuriStolenBottleDL) { POLY_XLU_DISP = &gfx[2]; } else { POLY_OPA_DISP = &gfx[2]; } - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->state.gfxCtx); } } idx = D_80C13698[limbIndex]; if (idx != -1) { if (idx == 9) { - Matrix_GetStateTranslationAndScaledX(1000.0f, &this->limbPos[idx]); + Matrix_MultVecX(1000.0f, &this->limbPos[idx]); } else { - Matrix_GetStateTranslation(&this->limbPos[idx]); + Matrix_MultZero(&this->limbPos[idx]); if ((idx == 3) || (idx == 5)) { - Matrix_GetStateTranslationAndScaledX(2000.0f, &this->limbPos[idx + 1]); + Matrix_MultVecX(2000.0f, &this->limbPos[idx + 1]); } } } } -void func_80C13354(EnThiefbird* this, GlobalContext* globalCtx2) { - GlobalContext* globalCtx = globalCtx2; +void func_80C13354(EnThiefbird* this, PlayState* play2) { + PlayState* play = play2; s32 i; Gfx* gfx; EnThiefbirdUnkStruct* ptr = &this->unk_3F0[0]; - OPEN_DISPS(globalCtx->state.gfxCtx); + OPEN_DISPS(play->state.gfxCtx); gfx = POLY_OPA_DISP; gSPDisplayList(&gfx[0], &sSetupDL[6 * 25]); - gSPDisplayList(&gfx[1], object_thiefbird_DL_003060); + gSPDisplayList(&gfx[1], gTakkuriFeatherMaterialDL); gfx = &gfx[2]; 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(&play->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); - gSPDisplayList(&gfx[1], object_thiefbird_DL_0030D8); + gSPMatrix(&gfx[0], Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(&gfx[1], gTakkuriFeatherModelDL); gfx = &gfx[2]; } } POLY_OPA_DISP = gfx; - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->state.gfxCtx); } -void EnThiefbird_Draw(Actor* thisx, GlobalContext* globalCtx) { +void EnThiefbird_Draw(Actor* thisx, PlayState* play) { EnThiefbird* this = THIS; - func_8012C28C(globalCtx->state.gfxCtx); - SkelAnime_DrawFlexOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, + func_8012C28C(play->state.gfxCtx); + SkelAnime_DrawFlexOpa(play, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, EnThiefbird_OverrideLimbDraw, EnThiefbird_PostLimbDraw, &this->actor); if (this->actor.colorFilterTimer > 0) { - func_800AE5A0(globalCtx); + func_800AE5A0(play); } - func_80C13354(this, globalCtx); - Actor_DrawDamageEffects(globalCtx, &this->actor, this->limbPos, ARRAY_COUNT(this->limbPos), this->drawDmgEffScale, + func_80C13354(this, play); + Actor_DrawDamageEffects(play, &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 990b4b2c5..1bbee73e0 100644 --- a/src/overlays/actors/ovl_En_Thiefbird/z_en_thiefbird.h +++ b/src/overlays/actors/ovl_En_Thiefbird/z_en_thiefbird.h @@ -2,10 +2,11 @@ #define Z_EN_THIEFBIRD_H #include "global.h" +#include "objects/object_thiefbird/object_thiefbird.h" struct EnThiefbird; -typedef void (*EnThiefbirdActionFunc)(struct EnThiefbird*, GlobalContext*); +typedef void (*EnThiefbirdActionFunc)(struct EnThiefbird*, PlayState*); typedef struct { /* 0x00 */ Vec3f unk_00; @@ -18,28 +19,28 @@ typedef struct { } EnThiefbirdUnkStruct; // size = 0x24 typedef struct EnThiefbird { - /* 0x0000 */ Actor actor; - /* 0x0144 */ SkelAnime skelAnime; - /* 0x0188 */ EnThiefbirdActionFunc actionFunc; - /* 0x018C */ u8 drawDmgEffType; - /* 0x018E */ s16 unk_18E; - /* 0x0190 */ s16 unk_190; - /* 0x0192 */ s16 unk_192; - /* 0x0194 */ s16 unk_194; - /* 0x0196 */ s16 unk_196[6]; - /* 0x01A2 */ Vec3s jointTable[17]; - /* 0x0208 */ Vec3s morphTable[17]; - /* 0x0270 */ ColliderJntSph collider; - /* 0x0290 */ ColliderJntSphElement colliderElements[3]; - /* 0x0350 */ Vec3f limbPos[11]; - /* 0x03D4 */ f32 drawDmgEffAlpha; - /* 0x03D8 */ f32 drawDmgEffScale; - /* 0x03DC */ f32 drawDmgEffFrozenSteamScale; - /* 0x03E0 */ f32 unk_3E0; - /* 0x03E4 */ Gfx* unk_3E4; - /* 0x03E8 */ Gfx* unk_3E8; - /* 0x03EC */ EnItem00* unk_3EC; - /* 0x03F0 */ EnThiefbirdUnkStruct unk_3F0[40]; + /* 0x000 */ Actor actor; + /* 0x144 */ SkelAnime skelAnime; + /* 0x188 */ EnThiefbirdActionFunc actionFunc; + /* 0x18C */ u8 drawDmgEffType; + /* 0x18E */ s16 unk_18E; + /* 0x190 */ s16 unk_190; + /* 0x192 */ s16 unk_192; + /* 0x194 */ s16 unk_194; + /* 0x196 */ s16 unk_196[6]; + /* 0x1A2 */ Vec3s jointTable[TAKKURI_LIMB_MAX]; + /* 0x208 */ Vec3s morphTable[TAKKURI_LIMB_MAX]; + /* 0x270 */ ColliderJntSph collider; + /* 0x290 */ ColliderJntSphElement colliderElements[3]; + /* 0x350 */ Vec3f limbPos[11]; + /* 0x3D4 */ f32 drawDmgEffAlpha; + /* 0x3D8 */ f32 drawDmgEffScale; + /* 0x3DC */ f32 drawDmgEffFrozenSteamScale; + /* 0x3E0 */ f32 unk_3E0; + /* 0x3E4 */ Gfx* unk_3E4; + /* 0x3E8 */ Gfx* unk_3E8; + /* 0x3EC */ EnItem00* unk_3EC; + /* 0x3F0 */ EnThiefbirdUnkStruct unk_3F0[40]; } EnThiefbird; // size = 0x990 extern const ActorInit En_Thiefbird_InitVars; diff --git a/src/overlays/actors/ovl_En_Time_Tag/z_en_time_tag.c b/src/overlays/actors/ovl_En_Time_Tag/z_en_time_tag.c index cd0403c71..b6dea09f3 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,31 +5,31 @@ */ #include "z_en_time_tag.h" +#include "overlays/actors/ovl_En_Elf/z_en_elf.h" #define FLAGS (ACTOR_FLAG_10) #define THIS ((EnTimeTag*)thisx) -void EnTimeTag_Init(Actor* thisx, GlobalContext* globalCtx); -void EnTimeTag_Destroy(Actor* thisx, GlobalContext* globalCtx); -void EnTimeTag_Update(Actor* thisx, GlobalContext* globalCtx); +void EnTimeTag_Init(Actor* thisx, PlayState* play); +void EnTimeTag_Destroy(Actor* thisx, PlayState* play); +void EnTimeTag_Update(Actor* thisx, PlayState* play); -void func_80AC9FD4(EnTimeTag* this, GlobalContext* globalCtx); -void func_80AC9FE4(EnTimeTag* this, GlobalContext* globalCtx); -void func_80ACA0A8(EnTimeTag* this, GlobalContext* globalCtx); -void func_80ACA12C(EnTimeTag* this, GlobalContext* globalCtx); -void func_80ACA184(EnTimeTag* this, GlobalContext* globalCtx); -void func_80ACA268(EnTimeTag* this, GlobalContext* globalCtx); -void func_80ACA348(EnTimeTag* this, GlobalContext* globalCtx); -void func_80ACA3C0(EnTimeTag* this, GlobalContext* globalCtx); -void func_80ACA418(EnTimeTag* this, GlobalContext* globalCtx); -void func_80ACA5F8(EnTimeTag* this, GlobalContext* globalCtx); -void func_80ACA714(EnTimeTag* this, GlobalContext* globalCtx); -void func_80ACA724(EnTimeTag* this, GlobalContext* globalCtx); -void func_80ACA7C4(EnTimeTag* this, GlobalContext* globalCtx); -void func_80ACA840(EnTimeTag* this, GlobalContext* globalCtx); +void func_80AC9FD4(EnTimeTag* this, PlayState* play); +void func_80AC9FE4(EnTimeTag* this, PlayState* play); +void func_80ACA0A8(EnTimeTag* this, PlayState* play); +void func_80ACA12C(EnTimeTag* this, PlayState* play); +void func_80ACA184(EnTimeTag* this, PlayState* play); +void func_80ACA268(EnTimeTag* this, PlayState* play); +void func_80ACA348(EnTimeTag* this, PlayState* play); +void func_80ACA3C0(EnTimeTag* this, PlayState* play); +void func_80ACA418(EnTimeTag* this, PlayState* play); +void func_80ACA5F8(EnTimeTag* this, PlayState* play); +void func_80ACA714(EnTimeTag* this, PlayState* play); +void func_80ACA724(EnTimeTag* this, PlayState* play); +void func_80ACA7C4(EnTimeTag* this, PlayState* play); +void func_80ACA840(EnTimeTag* this, PlayState* play); -#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, PlayState* play) { + 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, PlayState* play) { +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Time_Tag/func_80ACA184.s") +void func_80AC9FD4(EnTimeTag* this, PlayState* play) { +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Time_Tag/func_80ACA208.s") +void func_80AC9FE4(EnTimeTag* this, PlayState* play) { + 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, PlayState* play) { + EnTimeTag* this2 = this; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Time_Tag/func_80ACA348.s") + if ((play->msgCtx.ocarinaMode == 3) && (play->msgCtx.lastPlayedSong == OCARINA_SONG_OATH)) { + if (this->actor.cutscene != -1) { + this->actionFunc = func_80AC9FE4; + ActorCutscene_SetIntentToPlay(this2->actor.cutscene); + gSaveContext.unk_3DD0[3] = 0; + } + play->msgCtx.ocarinaMode = 4; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Time_Tag/func_80ACA3C0.s") +void func_80ACA12C(EnTimeTag* this, PlayState* play) { + if (ActorCutscene_GetCurrentIndex() != this->actor.cutscene) { + this->actionFunc = func_80ACA268; + this->actor.textId = 0xC02; + Item_Give(play, ITEM_SONG_SOARING); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Time_Tag/func_80ACA418.s") +void func_80ACA184(EnTimeTag* this, PlayState* play) { + if (ActorCutscene_GetCurrentIndex() == 0x7C) { + ActorCutscene_Stop(0x7C); + ActorCutscene_SetIntentToPlay(this->actor.cutscene); + } else if (ActorCutscene_GetCanPlayNext(this->actor.cutscene)) { + ActorCutscene_Start(this->actor.cutscene, &this->actor); + this->actionFunc = func_80ACA12C; + } 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, PlayState* play) { + if ((Message_GetState(&play->msgCtx) == TEXT_STATE_5) && Message_ShouldAdvance(play)) { + func_801477B4(play); + this->actionFunc = func_80ACA268; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Time_Tag/func_80ACA714.s") +void func_80ACA268(EnTimeTag* this, PlayState* play) { + if (Actor_ProcessTalkRequest(&this->actor, &play->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, play) && + (Flags_GetSwitch(play, ENTIMETAG_GET_SWITCHFLAG(&this->actor)) || + CHECK_QUEST_ITEM(QUEST_SONG_SOARING))) { + this->actor.flags |= ACTOR_FLAG_1; + func_800B8614(&this->actor, play, 110.0f); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Time_Tag/func_80ACA724.s") +void func_80ACA348(EnTimeTag* this, PlayState* play) { + 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(play, 0x1230); + } else { + func_80151938(play, 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, PlayState* play) { + if ((play->msgCtx.unk11F00->state == 0) && (play->msgCtx.msgMode == 0x1B)) { + this->actor.home.rot.x = 5; + this->actionFunc = func_80ACA348; + play->msgCtx.msgLength = 0; + play->msgCtx.msgMode = 0; + } +} + +void func_80ACA418(EnTimeTag* this, PlayState* play) { + switch (Message_GetState(&play->msgCtx)) { + case TEXT_STATE_5: + if (Message_ShouldAdvance(play)) { + switch (play->msgCtx.currentTextId) { + case 0x101C: + case 0x101D: + case 0x101E: + case 0x122D: + func_80151938(play, play->msgCtx.currentTextId + 1); + break; + + case 0x101F: + case 0x122A: + case 0x1230: + func_801477B4(play); + this->actionFunc = func_80ACA5F8; + if (ActorCutscene_GetCurrentIndex() == this->actor.cutscene) { + ActorCutscene_Stop(this->actor.cutscene); + } + break; + + case 0x122B: + func_80152434(play, 0x3F); + this->actionFunc = func_80ACA3C0; + this->actor.home.rot.z = 0; + break; + + case 0x122E: + func_80152434(play, 0x40); + this->actionFunc = func_80ACA3C0; + this->actor.home.rot.z = 1; + break; + } + } + break; + + case TEXT_STATE_CLOSING: + 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, PlayState* play) { + if (Actor_ProcessTalkRequest(&this->actor, &play->state)) { + if (gSaveContext.save.playerForm == PLAYER_FORM_ZORA) { + if (ENTIMETAG_GET_SWITCHFLAG(&this->actor) == 1) { + Message_StartTextbox(play, 0x101C, &this->actor); + } else { + Message_StartTextbox(play, 0x122B, &this->actor); + } + this->actor.home.rot.x = 1; + } else { + Message_StartTextbox(play, 0x122A, &this->actor); + if (0) {} + ((EnElf*)GET_PLAYER(play)->tatlActor)->unk_264 |= 4; + Actor_ChangeFocus(&this->actor, play, GET_PLAYER(play)->tatlActor); + this->actor.home.rot.x = 0; + } + this->actionFunc = func_80ACA418; + } else if ((this->actor.xzDistToPlayer < 100.0f) && Player_IsFacingActor(&this->actor, 0x3000, play)) { + func_800B8614(&this->actor, play, 110.0f); + } +} + +void func_80ACA714(EnTimeTag* this, PlayState* play) { +} + +void func_80ACA724(EnTimeTag* this, PlayState* play) { + if (Message_GetState(&play->msgCtx) == TEXT_STATE_5) { + play->nextEntrance = play->setupExitList[ENTIMETAG_GET_1F(&this->actor)]; + play->transitionTrigger = TRANS_TRIGGER_START; + if (!ENTIMETAG_GET_E000(&this->actor)) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_OC_DOOR_OPEN); + } + this->actionFunc = func_80ACA714; + } +} + +void func_80ACA7C4(EnTimeTag* this, PlayState* play) { + if (!(gSaveContext.save.weekEventReg[63] & 1) && !(gSaveContext.save.weekEventReg[63] & 2)) { + func_800B7298(play, &this->actor, 7); + Message_StartTextbox(play, ENTIMETAG_GET_1FE0(&this->actor) + 0x1883, NULL); + this->actionFunc = func_80ACA724; + } +} + +void func_80ACA840(EnTimeTag* this, PlayState* play) { + s16 temp_ft4; + s16 temp_hi; + + if ((play->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(play)) { + func_800B7298(play, &this->actor, 7); + Message_StartTextbox(play, ENTIMETAG_GET_1FE0(&this->actor) + 0x1883, NULL); + this->actionFunc = func_80ACA724; + } + } +} + +void EnTimeTag_Update(Actor* thisx, PlayState* play) { + EnTimeTag* this = THIS; + + this->actionFunc(this, play); +} 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..6ee46c1d3 100644 --- a/src/overlays/actors/ovl_En_Time_Tag/z_en_time_tag.h +++ b/src/overlays/actors/ovl_En_Time_Tag/z_en_time_tag.h @@ -5,11 +5,16 @@ struct EnTimeTag; -typedef void (*EnTimeTagActionFunc)(struct EnTimeTag*, GlobalContext*); +typedef void (*EnTimeTagActionFunc)(struct EnTimeTag*, PlayState*); + +#define ENTIMETAG_GET_1F(thisx) ((thisx)->params & 0x1F) +#define ENTIMETAG_GET_SWITCHFLAG(thisx) ((thisx)->params & 0x7F) +#define ENTIMETAG_GET_1FE0(thisx) (((thisx)->params & 0x1FE0) >> 0x5) +#define ENTIMETAG_GET_E000(thisx) (((thisx)->params & 0xE000) >> 0xD) typedef struct EnTimeTag { - /* 0x0000 */ Actor actor; - /* 0x0144 */ EnTimeTagActionFunc actionFunc; + /* 0x000 */ Actor actor; + /* 0x144 */ EnTimeTagActionFunc actionFunc; } EnTimeTag; // size = 0x148 extern const ActorInit En_Time_Tag_InitVars; diff --git a/src/overlays/actors/ovl_En_Tite/z_en_tite.c b/src/overlays/actors/ovl_En_Tite/z_en_tite.c index 7839e4585..2b1385965 100644 --- a/src/overlays/actors/ovl_En_Tite/z_en_tite.c +++ b/src/overlays/actors/ovl_En_Tite/z_en_tite.c @@ -11,40 +11,40 @@ #define THIS ((EnTite*)thisx) -void EnTite_Init(Actor* thisx, GlobalContext* globalCtx); -void EnTite_Destroy(Actor* thisx, GlobalContext* globalCtx); -void EnTite_Update(Actor* thisx, GlobalContext* globalCtx); -void EnTite_Draw(Actor* thisx, GlobalContext* globalCtx); +void EnTite_Init(Actor* thisx, PlayState* play); +void EnTite_Destroy(Actor* thisx, PlayState* play); +void EnTite_Update(Actor* thisx, PlayState* play); +void EnTite_Draw(Actor* thisx, PlayState* play); void func_80893ED4(EnTite* this); -void func_80893F30(EnTite* this, GlobalContext* globalCtx); +void func_80893F30(EnTite* this, PlayState* play); void func_80893FD0(EnTite* this); -void func_80894024(EnTite* this, GlobalContext* globalCtx); -void func_8089408C(EnTite* this, GlobalContext* globalCtx); -void func_808942B4(EnTite* this, GlobalContext* globalCtx); +void func_80894024(EnTite* this, PlayState* play); +void func_8089408C(EnTite* this, PlayState* play); +void func_808942B4(EnTite* this, PlayState* play); void func_80894414(EnTite* this); -void func_80894454(EnTite* this, GlobalContext* globalCtx); -void func_8089452C(EnTite* this, GlobalContext* globalCtx); -void func_808945B4(EnTite* this, GlobalContext* globalCtx); +void func_80894454(EnTite* this, PlayState* play); +void func_8089452C(EnTite* this, PlayState* play); +void func_808945B4(EnTite* this, PlayState* play); void func_808945EC(EnTite* this); -void func_80894638(EnTite* this, GlobalContext* globalCtx); +void func_80894638(EnTite* this, PlayState* play); void func_8089484C(EnTite* this); -void func_80894910(EnTite* this, GlobalContext* globalCtx); +void func_80894910(EnTite* this, PlayState* play); void func_80894B2C(EnTite* this); -void func_80894BC8(EnTite* this, GlobalContext* globalCtx); -void func_80894E0C(EnTite* this, GlobalContext* globalCtx); -void func_80895020(EnTite* this, GlobalContext* globalCtx); -void func_808951B8(EnTite* this, GlobalContext* globalCtx); -void func_80895424(EnTite* this, GlobalContext* globalCtx); +void func_80894BC8(EnTite* this, PlayState* play); +void func_80894E0C(EnTite* this, PlayState* play); +void func_80895020(EnTite* this, PlayState* play); +void func_808951B8(EnTite* this, PlayState* play); +void func_80895424(EnTite* this, PlayState* play); void func_808955E4(EnTite* this); -void func_80895640(EnTite* this, GlobalContext* globalCtx); +void func_80895640(EnTite* this, PlayState* play); void func_808956B8(EnTite* this); -void func_80895738(EnTite* this, GlobalContext* globalCtx); +void func_80895738(EnTite* this, PlayState* play); void func_80895A10(EnTite* this); -void func_80895AC0(EnTite* this, GlobalContext* globalCtx); +void func_80895AC0(EnTite* this, PlayState* play); void func_80895CB0(EnTite* this); -void func_80895D08(EnTite* this, GlobalContext* globalCtx); -void func_80895E28(EnTite* this, GlobalContext* globalCtx); +void func_80895D08(EnTite* this, PlayState* play); +void func_80895E28(EnTite* this, PlayState* play); const ActorInit En_Tite_InitVars = { ACTOR_EN_TITE, @@ -134,18 +134,18 @@ static InitChainEntry sInitChain[] = { static s32 D_80896B60 = 0; static Vec3f D_80896B64 = { 0.0f, 0.3f, 0.0f }; -void EnTite_Init(Actor* thisx, GlobalContext* globalCtx) { +void EnTite_Init(Actor* thisx, PlayState* play) { EnTite* this = THIS; s32 i; s32 j; Actor_ProcessInitChain(&this->actor, sInitChain); - SkelAnime_Init(globalCtx, &this->skelAnime, &object_tite_Skel_003A20, &object_tite_Anim_0012E4, this->jointTable, + SkelAnime_Init(play, &this->skelAnime, &object_tite_Skel_003A20, &object_tite_Anim_0012E4, this->jointTable, this->morphTable, 25); ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 60.0f); Actor_SetFocus(&this->actor, 20.0f); CollisionCheck_SetInfo(&this->actor.colChkInfo, &sDamageTable, &sColChkInfoInit); - Collider_InitAndSetSphere(globalCtx, &this->collider, &this->actor, &sSphereInit); + Collider_InitAndSetSphere(play, &this->collider, &this->actor, &sSphereInit); this->collider.dim.worldSphere.radius = sSphereInit.dim.modelSphere.radius; this->unk_2C0 = 0x1D; @@ -183,10 +183,10 @@ void EnTite_Init(Actor* thisx, GlobalContext* globalCtx) { } } -void EnTite_Destroy(Actor* thisx, GlobalContext* globalCtx) { +void EnTite_Destroy(Actor* thisx, PlayState* play) { EnTite* this = THIS; - Collider_DestroySphere(globalCtx, &this->collider); + Collider_DestroySphere(play, &this->collider); } void func_80893A18(EnTite* this) { @@ -194,16 +194,16 @@ void func_80893A18(EnTite* this) { this->collider.base.acFlags &= ~AC_HARD; } -s32 func_80893A34(EnTite* this, GlobalContext* globalCtx) { +s32 func_80893A34(EnTite* this, PlayState* play) { if ((this->actor.params == ENTITE_MINUS_2) && (this->actor.bgCheckFlags & 1) && - (func_800C99D4(&globalCtx->colCtx, this->actor.floorPoly, this->actor.floorBgId) == 5)) { + (func_800C99D4(&play->colCtx, this->actor.floorPoly, this->actor.floorBgId) == 5)) { return true; } return false; } -void func_80893A9C(EnTite* this, GlobalContext* globalCtx) { - if (func_80893A34(this, globalCtx)) { +void func_80893A9C(EnTite* this, PlayState* play) { + if (func_80893A34(this, play)) { func_808956B8(this); } else { func_80893FD0(this); @@ -233,17 +233,17 @@ void func_80893B70(EnTite* this) { } } -void func_80893BCC(EnTite* this, GlobalContext* globalCtx) { +void func_80893BCC(EnTite* this, PlayState* play) { Vec3f sp7C; s32 i; s32 j; if (this->actor.bgCheckFlags & 2) { - u32 surface = func_800C9BB8(&globalCtx->colCtx, this->actor.floorPoly, this->actor.floorBgId); + u32 surface = func_800C9BB8(&play->colCtx, this->actor.floorPoly, this->actor.floorBgId); if ((surface == COLPOLY_SURFACE_GROUND) || (surface == COLPOLY_SURFACE_SAND)) { for (i = 5; i < ARRAY_COUNT(this->limbPos); i++) { - func_800BBFB0(globalCtx, &this->limbPos[i], 1.0f, 2, 80, 15, 1); + func_800BBFB0(play, &this->limbPos[i], 1.0f, 2, 80, 15, 1); } } else if (surface == COLPOLY_SURFACE_SNOW) { Vec3f* ptr; @@ -254,7 +254,7 @@ void func_80893BCC(EnTite* this, GlobalContext* globalCtx) { sp7C.x = ptr->x + randPlusMinusPoint5Scaled(1.0f); sp7C.y = ptr->y + randPlusMinusPoint5Scaled(1.0f); sp7C.z = ptr->z + randPlusMinusPoint5Scaled(1.0f); - func_800B0DE0(globalCtx, &sp7C, &gZeroVec3f, &D_80896B64, &D_80896B3C, &D_80896B40, + func_800B0DE0(play, &sp7C, &gZeroVec3f, &D_80896B64, &D_80896B3C, &D_80896B40, (s32)Rand_ZeroFloat(16.0f) + 80, 15); } } @@ -274,12 +274,12 @@ void func_80893DD4(EnTite* this) { this->actor.flags &= ~ACTOR_FLAG_200; } -void func_80893E54(EnTite* this, GlobalContext* globalCtx) { +void func_80893E54(EnTite* this, PlayState* play) { if (this->drawDmgEffType == ACTOR_DRAW_DMGEFF_FROZEN_NO_SFX) { this->drawDmgEffType = ACTOR_DRAW_DMGEFF_FIRE; this->collider.base.colType = COLTYPE_HIT6; this->drawDmgEffAlpha = 0.0f; - Actor_SpawnIceEffects(globalCtx, &this->actor, this->limbPos, 9, 2, 0.2f, 0.2f); + Actor_SpawnIceEffects(play, &this->actor, this->limbPos, 9, 2, 0.2f, 0.2f); this->actor.flags |= ACTOR_FLAG_200; } } @@ -291,12 +291,12 @@ void func_80893ED4(EnTite* this) { this->actionFunc = func_80893F30; } -void func_80893F30(EnTite* this, GlobalContext* globalCtx) { +void func_80893F30(EnTite* this, PlayState* play) { SkelAnime_Update(&this->skelAnime); func_80893B70(this); if (this->unk_2BC > 0) { this->unk_2BC--; - } else if ((Player_GetMask(globalCtx) != PLAYER_MASK_STONE) && (this->actor.xzDistToPlayer < 300.0f) && + } else if ((Player_GetMask(play) != PLAYER_MASK_STONE) && (this->actor.xzDistToPlayer < 300.0f) && (this->actor.playerHeightRel < 80.0f)) { func_808945EC(this); } @@ -310,9 +310,9 @@ void func_80893FD0(EnTite* this) { this->actionFunc = func_80894024; } -void func_80894024(EnTite* this, GlobalContext* globalCtx) { +void func_80894024(EnTite* this, PlayState* play) { if (SkelAnime_Update(&this->skelAnime)) { - func_8089408C(this, globalCtx); + func_8089408C(this, play); } else { func_80893B70(this); Math_ScaledStepToS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer, 1000); @@ -320,7 +320,7 @@ void func_80894024(EnTite* this, GlobalContext* globalCtx) { } } -void func_8089408C(EnTite* this, GlobalContext* globalCtx) { +void func_8089408C(EnTite* this, PlayState* play) { Animation_PlayOnce(&this->skelAnime, &object_tite_Anim_0004F8); if (!func_80893ADC(this)) { Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_TEKU_JUMP); @@ -343,7 +343,7 @@ void func_8089408C(EnTite* this, GlobalContext* globalCtx) { sp70.x = this->actor.world.pos.x + (12.5f * sp64.x); sp70.y = this->actor.world.pos.y + 15.0f; sp70.z = this->actor.world.pos.z + (12.5f * sp64.z); - func_800B0DE0(globalCtx, &sp70, &sp64, &D_80896B44, &D_80896B3C, &D_80896B40, 500, 50); + func_800B0DE0(play, &sp70, &sp64, &D_80896B44, &D_80896B3C, &D_80896B40, 500, 50); this->actor.shape.rot.y += 0x4000; } @@ -362,19 +362,19 @@ void func_8089408C(EnTite* this, GlobalContext* globalCtx) { this->actionFunc = func_808942B4; } -void func_808942B4(EnTite* this, GlobalContext* globalCtx) { +void func_808942B4(EnTite* this, PlayState* play) { SkelAnime_Update(&this->skelAnime); if (((this->actor.bgCheckFlags & 1) || (func_80893ADC(this) && (this->actor.depthInWater > 0.0f))) && (this->actor.velocity.y <= 0.0f)) { this->actor.speedXZ = 0.0f; this->collider.base.atFlags &= ~AT_HIT; if (!func_80893ADC(this)) { - func_80893BCC(this, globalCtx); + func_80893BCC(this, play); func_80894414(this); } else { this->actor.gravity = 0.0f; if (this->actor.velocity.y < -8.0f) { - func_8089452C(this, globalCtx); + func_8089452C(this, play); } else { this->actor.velocity.y = 0.0f; Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_TEKU_LAND_WATER2); @@ -383,7 +383,7 @@ void func_808942B4(EnTite* this, GlobalContext* globalCtx) { } } else if (!(this->collider.base.atFlags & AT_HIT)) { this->actor.flags |= ACTOR_FLAG_1000000; - CollisionCheck_SetAT(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + CollisionCheck_SetAT(play, &play->colChkCtx, &this->collider.base); } else { this->collider.base.atFlags &= ~AT_HIT; func_80894B2C(this); @@ -395,15 +395,15 @@ void func_80894414(EnTite* this) { this->actionFunc = func_80894454; } -void func_80894454(EnTite* this, GlobalContext* globalCtx) { +void func_80894454(EnTite* this, PlayState* play) { if (SkelAnime_Update(&this->skelAnime)) { - if ((Player_GetMask(globalCtx) == PLAYER_MASK_STONE) || (this->actor.xzDistToPlayer > 450.0f) || + if ((Player_GetMask(play) == PLAYER_MASK_STONE) || (this->actor.xzDistToPlayer > 450.0f) || (this->actor.playerHeightRel > 80.0f)) { func_80893ED4(this); } else if (!Actor_IsFacingPlayer(&this->actor, 0x2328)) { func_808945EC(this); } else { - func_80893A9C(this, globalCtx); + func_80893A9C(this, play); } } else { Math_ScaledStepToS(&this->actor.world.rot.y, this->actor.yawTowardsPlayer, 1500); @@ -411,18 +411,18 @@ void func_80894454(EnTite* this, GlobalContext* globalCtx) { } } -void func_8089452C(EnTite* this, GlobalContext* globalCtx) { +void func_8089452C(EnTite* this, PlayState* play) { Vec3f sp2C; Math_Vec3f_Copy(&sp2C, &this->actor.world.pos); sp2C.y += this->actor.depthInWater; this->actor.velocity.y *= 0.75f; - EffectSsGRipple_Spawn(globalCtx, &sp2C, 0, 500, 0); + EffectSsGRipple_Spawn(play, &sp2C, 0, 500, 0); Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_TEKU_LAND_WATER); this->actionFunc = func_808945B4; } -void func_808945B4(EnTite* this, GlobalContext* globalCtx) { +void func_808945B4(EnTite* this, PlayState* play) { if (func_80893B10(this)) { func_80894414(this); } @@ -435,7 +435,7 @@ void func_808945EC(EnTite* this) { this->actionFunc = func_80894638; } -void func_80894638(EnTite* this, GlobalContext* globalCtx) { +void func_80894638(EnTite* this, PlayState* play) { s16 temp_v0; s16 temp_v1; @@ -460,13 +460,13 @@ void func_80894638(EnTite* this, GlobalContext* globalCtx) { } } - if ((Player_GetMask(globalCtx) == PLAYER_MASK_STONE) || (this->actor.xzDistToPlayer > 450.0f) || + if ((Player_GetMask(play) == PLAYER_MASK_STONE) || (this->actor.xzDistToPlayer > 450.0f) || (this->actor.playerHeightRel > 80.0f)) { func_80893ED4(this); } else if (((this->actor.bgCheckFlags & 1) || (func_80893ADC(this) && (this->actor.depthInWater < 10.0f))) && Actor_IsFacingPlayer(&this->actor, 0xE38)) { if ((this->actor.xzDistToPlayer <= 180.0f) && (this->actor.playerHeightRel <= 80.0f)) { - func_80893A9C(this, globalCtx); + func_80893A9C(this, play); } else { func_8089484C(this); } @@ -490,7 +490,7 @@ void func_8089484C(EnTite* this) { this->actionFunc = func_80894910; } -void func_80894910(EnTite* this, GlobalContext* globalCtx) { +void func_80894910(EnTite* this, PlayState* play) { Vec3f sp34; Math_SmoothStepToF(&this->actor.speedXZ, 0.0f, 0.1f, 1.0f, 0.0f); @@ -502,10 +502,10 @@ void func_80894910(EnTite* this, GlobalContext* globalCtx) { Math_Vec3f_Copy(&sp34, &this->actor.world.pos); sp34.y += this->actor.depthInWater; this->actor.velocity.y *= 0.75f; - EffectSsGRipple_Spawn(globalCtx, &sp34, 0, 500, 0); + EffectSsGRipple_Spawn(play, &sp34, 0, 500, 0); } } else { - func_80893BCC(this, globalCtx); + func_80893BCC(this, play); } if (((this->actor.bgCheckFlags & 1) || (func_80893ADC(this) && (this->actor.depthInWater > 0.0f))) && @@ -521,7 +521,7 @@ void func_80894910(EnTite* this, GlobalContext* globalCtx) { } } - if ((Player_GetMask(globalCtx) == PLAYER_MASK_STONE) || (this->actor.xzDistToPlayer > 450.0f) || + if ((Player_GetMask(play) == PLAYER_MASK_STONE) || (this->actor.xzDistToPlayer > 450.0f) || (this->actor.playerHeightRel > 80.0f)) { func_80893ED4(this); } else if ((this->actor.xzDistToPlayer <= 180.0f) && (this->actor.playerHeightRel <= 80.0f)) { @@ -547,7 +547,7 @@ void func_80894B2C(EnTite* this) { this->actionFunc = func_80894BC8; } -void func_80894BC8(EnTite* this, GlobalContext* globalCtx) { +void func_80894BC8(EnTite* this, PlayState* play) { Math_SmoothStepToF(&this->actor.speedXZ, 0.0f, 1.0f, 0.5f, 0.0f); SkelAnime_Update(&this->skelAnime); if (func_80893ADC(this) && (this->actor.velocity.y <= 0.0f)) { @@ -559,19 +559,19 @@ void func_80894BC8(EnTite* this, GlobalContext* globalCtx) { if (this->actor.bgCheckFlags & 0x40) { Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_TEKU_LAND_WATER2); } else { - func_80893BCC(this, globalCtx); + func_80893BCC(this, play); } if ((this->actor.speedXZ == 0.0f) && ((this->actor.bgCheckFlags & 1) || func_80893ADC(this))) { this->actor.world.rot.y = this->actor.shape.rot.y; this->collider.base.acFlags |= AC_ON; - if ((Player_GetMask(globalCtx) == PLAYER_MASK_STONE) || + if ((Player_GetMask(play) == PLAYER_MASK_STONE) || (((this->actor.xzDistToPlayer > 450.0f) || (this->actor.playerHeightRel > 80.0f)) && (ABS_ALT(this->actor.shape.rot.x) < 4000) && (ABS_ALT(this->actor.shape.rot.z) < 4000))) { func_80893ED4(this); } else if ((this->actor.xzDistToPlayer < 180.0f) && (this->actor.playerHeightRel <= 80.0f) && Actor_IsFacingPlayer(&this->actor, 0x1770)) { - func_80893A9C(this, globalCtx); + func_80893A9C(this, play); } else { func_8089484C(this); } @@ -587,7 +587,7 @@ void func_80894DD0(EnTite* this) { this->actionFunc = func_80894E0C; } -void func_80894E0C(EnTite* this, GlobalContext* globalCtx) { +void func_80894E0C(EnTite* this, PlayState* play) { if (this->unk_2BC != 0) { this->unk_2BC--; } @@ -601,29 +601,29 @@ void func_80894E0C(EnTite* this, GlobalContext* globalCtx) { if (this->actor.bgCheckFlags & 0x40) { Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_TEKU_LAND_WATER2); } else { - func_80893BCC(this, globalCtx); + func_80893BCC(this, play); } if (this->unk_2BC == 0) { - func_80893E54(this, globalCtx); + func_80893E54(this, play); if (this->actor.colChkInfo.health == 0) { - func_80895020(this, globalCtx); + func_80895020(this, play); } else if (this->unk_2B9 != 0) { func_808955E4(this); - } else if ((Player_GetMask(globalCtx) == PLAYER_MASK_STONE) || + } else if ((Player_GetMask(play) == PLAYER_MASK_STONE) || (((this->actor.xzDistToPlayer > 450.0f) || (this->actor.playerHeightRel > 80.0f)) && (ABS_ALT(this->actor.shape.rot.x) < 4000) && (ABS_ALT(this->actor.shape.rot.z) < 4000))) { func_80893ED4(this); } else if ((this->actor.xzDistToPlayer < 180.0f) && (this->actor.playerHeightRel <= 80.0f) && Actor_IsFacingPlayer(&this->actor, 0x1770)) { - func_80893A9C(this, globalCtx); + func_80893A9C(this, play); } else { func_8089484C(this); } } } -void func_80895020(EnTite* this, GlobalContext* globalCtx) { +void func_80895020(EnTite* this, PlayState* play) { Vec3f sp74; s32 i; f32 temp_f0; @@ -632,11 +632,11 @@ void func_80895020(EnTite* this, GlobalContext* globalCtx) { this->actor.speedXZ = 0.0f; this->collider.base.acFlags &= ~AC_ON; this->actor.colorFilterTimer = 0; - SoundSource_PlaySfxAtFixedWorldPos(globalCtx, &this->actor.world.pos, 40, NA_SE_EN_TEKU_DEAD); + SoundSource_PlaySfxAtFixedWorldPos(play, &this->actor.world.pos, 40, NA_SE_EN_TEKU_DEAD); 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); + Item_DropCollectibleRandom(play, &this->actor, &this->actor.world.pos, this->unk_2BE); this->unk_2BC = 25; this->actor.gravity = -0.58f; this->actor.velocity.y = 0.0f; @@ -657,7 +657,7 @@ void func_80895020(EnTite* this, GlobalContext* globalCtx) { this->actionFunc = func_808951B8; } -void func_808951B8(EnTite* this, GlobalContext* globalCtx) { +void func_808951B8(EnTite* this, PlayState* play) { s32 i; this->unk_2BC--; @@ -665,8 +665,8 @@ void func_808951B8(EnTite* this, GlobalContext* globalCtx) { if (this->unk_2BC == 0) { 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); + func_800B3030(play, &this->limbPos[i], &gZeroVec3f, &gZeroVec3f, 40, 7, 1); + SoundSource_PlaySfxAtFixedWorldPos(play, &this->limbPos[i], 11, NA_SE_EN_EXTINCT); } Actor_MarkForDeath(&this->actor); } else { @@ -692,7 +692,7 @@ void func_808952EC(EnTite* this) { this->actionFunc = func_80895424; } -void func_80895424(EnTite* this, GlobalContext* globalCtx) { +void func_80895424(EnTite* this, PlayState* play) { Math_ScaledStepToS(&this->actor.shape.rot.z, -0x8000, 4000); if (this->unk_2B8 != 0) { this->unk_2B8--; @@ -706,7 +706,7 @@ void func_80895424(EnTite* this, GlobalContext* globalCtx) { if (this->actor.bgCheckFlags & 1) { this->collider.base.acFlags |= AC_ON; if (this->actor.bgCheckFlags & 2) { - Actor_SpawnFloorDustRing(globalCtx, &this->actor, &this->actor.world.pos, 20.0f, 11, 4.0f, 0, 0, 0); + Actor_SpawnFloorDustRing(play, &this->actor, &this->actor.world.pos, 20.0f, 11, 4.0f, 0, 0, 0); Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_EYEGOLE_ATTACK); } @@ -729,13 +729,13 @@ void func_808955E4(EnTite* this) { this->actionFunc = func_80895640; } -void func_80895640(EnTite* this, GlobalContext* globalCtx) { +void func_80895640(EnTite* this, PlayState* play) { Math_ScaledStepToS(&this->actor.shape.rot.z, 0, 4000); SkelAnime_Update(&this->skelAnime); if (this->actor.bgCheckFlags & 1) { this->collider.base.acFlags |= AC_ON; this->actor.shape.yOffset = 0.0f; - func_80893BCC(this, globalCtx); + func_80893BCC(this, play); func_80893ED4(this); } } @@ -756,8 +756,8 @@ void func_808956FC(EnTite* this) { func_80893A18(this); } -void func_80895738(EnTite* this, GlobalContext* globalCtx) { - func_80893BCC(this, globalCtx); +void func_80895738(EnTite* this, PlayState* play) { + func_80893BCC(this, play); if (this->collider.base.atFlags & AT_HIT) { this->collider.base.atFlags &= ~AT_HIT; this->actor.world.rot.y = BINANG_ROT180(this->actor.yawTowardsPlayer); @@ -779,53 +779,53 @@ void func_80895738(EnTite* this, GlobalContext* globalCtx) { this->unk_2BC--; Math_StepToF(&this->actor.speedXZ, 10.0f, 0.3f); this->actor.flags |= ACTOR_FLAG_1000000; - CollisionCheck_SetAT(globalCtx, &globalCtx->colChkCtx, &this->collider.base); - if (!func_80893A34(this, globalCtx)) { + CollisionCheck_SetAT(play, &play->colChkCtx, &this->collider.base); + if (!func_80893A34(this, play)) { this->unk_2BC = 0; } } else if ((this->unk_2BC == 0) && Math_StepToF(&this->actor.speedXZ, 0.0f, 0.3f)) { this->actor.world.rot.y = this->actor.shape.rot.y; func_80893A18(this); - if ((Player_GetMask(globalCtx) == PLAYER_MASK_STONE) || (this->actor.xzDistToPlayer > 450.0f) || + if ((Player_GetMask(play) == PLAYER_MASK_STONE) || (this->actor.xzDistToPlayer > 450.0f) || (this->actor.playerHeightRel > 80.0f)) { func_80893ED4(this); } else if (!Actor_IsFacingPlayer(&this->actor, 0x2328)) { func_808945EC(this); } else { - func_80893A9C(this, globalCtx); + func_80893A9C(this, play); } } this->actor.shape.rot.y += (s16)(this->actor.speedXZ * 768.0f); } -void func_8089595C(EnTite* this, GlobalContext* globalCtx) { +void func_8089595C(EnTite* this, PlayState* play) { Vec3f sp2C; sp2C.x = randPlusMinusPoint5Scaled(20.0f) + this->actor.world.pos.x; sp2C.y = this->actor.world.pos.y + 15.0f; sp2C.z = randPlusMinusPoint5Scaled(20.0f) + this->actor.world.pos.z; - func_800B0DE0(globalCtx, &sp2C, &gZeroVec3f, &D_80896B44, &D_80896B3C, &D_80896B40, 500, 50); + func_800B0DE0(play, &sp2C, &gZeroVec3f, &D_80896B44, &D_80896B3C, &D_80896B40, 500, 50); } void func_80895A10(EnTite* this) { s32 pad; s16 rand; - Animation_Change(&this->skelAnime, &object_tite_Anim_000A14, 2.0f, 0.0f, 0.0f, 0, 4.0f); + Animation_Change(&this->skelAnime, &object_tite_Anim_000A14, 2.0f, 0.0f, 0.0f, ANIMMODE_LOOP, 4.0f); this->actor.speedXZ = 0.0f; rand = Rand_S16Offset(20, 20); this->unk_2BC = ((Rand_ZeroOne() < 0.5f) ? -1 : 1) * rand; this->actionFunc = func_80895AC0; } -void func_80895AC0(EnTite* this, GlobalContext* globalCtx) { +void func_80895AC0(EnTite* this, PlayState* play) { s16 temp_v1; s32 temp_v0; SkelAnime_Update(&this->skelAnime); if (Animation_OnFrame(&this->skelAnime, 7.0f)) { if (Rand_ZeroOne() < 0.25f) { - func_8089595C(this, globalCtx); + func_8089595C(this, play); } Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_TEKU_WALK); } @@ -846,8 +846,8 @@ void func_80895AC0(EnTite* this, GlobalContext* globalCtx) { } } - if ((this->actor.xzDistToPlayer < 240.0f) && (Player_GetMask(globalCtx) != PLAYER_MASK_STONE)) { - func_8089408C(this, globalCtx); + if ((this->actor.xzDistToPlayer < 240.0f) && (Player_GetMask(play) != PLAYER_MASK_STONE)) { + func_8089408C(this, play); } else if (this->unk_2BC > 0) { this->unk_2BC--; this->actor.shape.rot.y += 0x100; @@ -867,16 +867,16 @@ void func_80895CB0(EnTite* this) { this->actionFunc = func_80895D08; } -void func_80895D08(EnTite* this, GlobalContext* globalCtx) { +void func_80895D08(EnTite* this, PlayState* play) { SkelAnime_Update(&this->skelAnime); if (Animation_OnFrame(&this->skelAnime, 7.0f)) { if (Rand_ZeroOne() < 0.5f) { - func_8089595C(this, globalCtx); + func_8089595C(this, play); } Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_TEKU_WALK); } - if ((this->actor.xzDistToPlayer < 240.0f) && (Player_GetMask(globalCtx) != PLAYER_MASK_STONE)) { - func_8089408C(this, globalCtx); + if ((this->actor.xzDistToPlayer < 240.0f) && (Player_GetMask(play) != PLAYER_MASK_STONE)) { + func_8089408C(this, play); } else { this->unk_2BC--; if (this->unk_2BC == 0) { @@ -893,7 +893,7 @@ void func_80895DE8(EnTite* this) { this->actionFunc = func_80895E28; } -void func_80895E28(EnTite* this, GlobalContext* globalCtx) { +void func_80895E28(EnTite* this, PlayState* play) { Vec3f sp44; Vec3f sp38; s16 sp36; @@ -911,14 +911,14 @@ void func_80895E28(EnTite* this, GlobalContext* globalCtx) { sp38.y = 3.0f; sp38.z = 2.0f * Math_CosS(sp36); - func_800B0DE0(globalCtx, &sp44, &sp38, &D_80896B44, &D_80896B3C, &D_80896B40, 500, 50); + func_800B0DE0(play, &sp44, &sp38, &D_80896B44, &D_80896B3C, &D_80896B40, 500, 50); sp44.x = (2.0f * this->actor.world.pos.x) - sp44.x; sp44.z = (2.0f * this->actor.world.pos.z) - sp44.z; sp38.x *= -1.0f; sp38.z *= -1.0f; - func_800B0DE0(globalCtx, &sp44, &sp38, &D_80896B44, &D_80896B3C, &D_80896B40, 500, 50); + func_800B0DE0(play, &sp44, &sp38, &D_80896B44, &D_80896B3C, &D_80896B40, 500, 50); if (Math_StepToF(&this->actor.shape.yOffset, 0.0f, 200.0f)) { this->actor.flags |= ACTOR_FLAG_1; @@ -928,7 +928,7 @@ void func_80895E28(EnTite* this, GlobalContext* globalCtx) { } } -void func_80895FF8(EnTite* this, GlobalContext* globalCtx) { +void func_80895FF8(EnTite* this, PlayState* play) { if (this->collider.base.acFlags & AC_HIT) { this->collider.base.acFlags &= ~AC_HIT; this->collider.base.atFlags &= ~AT_HIT; @@ -942,14 +942,14 @@ void func_80895FF8(EnTite* this, GlobalContext* globalCtx) { if ((this->drawDmgEffType != ACTOR_DRAW_DMGEFF_FROZEN_NO_SFX) || !(this->collider.info.acHitInfo->toucher.dmgFlags & 0xDB0B3)) { - func_80893E54(this, globalCtx); + func_80893E54(this, play); if (this->actor.shape.yOffset < 0.0f) { func_80895DE8(this); return; } if (!Actor_ApplyDamage(&this->actor)) { - Enemy_StartFinishingBlow(globalCtx, &this->actor); + Enemy_StartFinishingBlow(play, &this->actor); } if (this->actor.colChkInfo.damageEffect != 0xF) { @@ -990,15 +990,15 @@ void func_80895FF8(EnTite* this, GlobalContext* globalCtx) { 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); + Actor_Spawn(&play->actorCtx, play, ACTOR_EN_CLEAR_TAG, this->collider.info.bumper.hitPos.x, + this->collider.info.bumper.hitPos.y, this->collider.info.bumper.hitPos.z, 0, 0, 0, + CLEAR_TAG_LARGE_LIGHT_RAYS); } Actor_SetColorFilter(&this->actor, 0x4000, 255, 0, 8); if (this->actor.colChkInfo.health == 0) { - func_80895020(this, globalCtx); + func_80895020(this, play); } else { Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_TEKU_DAMAGE); @@ -1012,7 +1012,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.colChkInfo.health != 0) && (play->actorCtx.unk2 != 0) && (this->actor.xyzDistToPlayerSq < SQ(200.0f))) { this->actor.flags |= ACTOR_FLAG_1; if (this->actor.shape.yOffset < 0.0f) { @@ -1027,7 +1027,7 @@ void func_80895FF8(EnTite* this, GlobalContext* globalCtx) { } } -void func_808963B4(EnTite* this, GlobalContext* globalCtx) { +void func_808963B4(EnTite* this, PlayState* play) { s32 i; Vec3f sp48; @@ -1035,30 +1035,30 @@ void func_808963B4(EnTite* this, GlobalContext* globalCtx) { 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); + EffectSsGRipple_Spawn(play, &sp48, 0, 220, 0); } } else if (this->actor.bgCheckFlags & 0x20) { - s32 temp = globalCtx->gameplayFrames & 7; + s32 temp = play->gameplayFrames & 7; if (!(temp & 1) && (this->actor.depthInWater < 10.0f)) { 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); + EffectSsGRipple_Spawn(play, &sp48, 0, 220, 0); } } } -void EnTite_Update(Actor* thisx, GlobalContext* globalCtx) { +void EnTite_Update(Actor* thisx, PlayState* play) { EnTite* this = THIS; - func_80895FF8(this, globalCtx); + func_80895FF8(this, play); - this->actionFunc(this, globalCtx); + this->actionFunc(this, play); if (this->actionFunc != func_808951B8) { Actor_MoveWithGravity(&this->actor); - Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 25.0f, 40.0f, 20.0f, this->unk_2C0); - func_808963B4(this, globalCtx); + Actor_UpdateBgCheckInfo(play, &this->actor, 25.0f, 40.0f, 20.0f, this->unk_2C0); + func_808963B4(this, play); if (this->actor.bgCheckFlags & 1) { func_800BE3D0(&this->actor, this->actor.shape.rot.y, &this->actor.shape.rot); if (this->unk_2B9 != 0) { @@ -1080,9 +1080,9 @@ void EnTite_Update(Actor* thisx, GlobalContext* globalCtx) { this->collider.dim.worldSphere.center.z = this->actor.world.pos.z; if (this->collider.base.acFlags & AC_ON) { - CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + CollisionCheck_SetAC(play, &play->colChkCtx, &this->collider.base); } - CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + CollisionCheck_SetOC(play, &play->colChkCtx, &this->collider.base); if (this->drawDmgEffAlpha > 0.0f) { if (this->drawDmgEffType != ACTOR_DRAW_DMGEFF_FROZEN_NO_SFX) { @@ -1096,8 +1096,7 @@ void EnTite_Update(Actor* thisx, GlobalContext* globalCtx) { } } -s32 EnTite_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, - Actor* thisx) { +s32 EnTite_OverrideLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, Actor* thisx) { EnTite* this = THIS; if (this->unk_2BA == -1) { @@ -1107,7 +1106,7 @@ s32 EnTite_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList return false; } -void EnTite_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx) { +void EnTite_PostLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx) { static s8 D_80896B70[] = { -1, -1, -1, -1, 0, -1, -1, -1, 1, -1, -1, -1, -1, 2, -1, -1, -1, -1, 3, -1, -1, -1, -1, 4, -1, }; @@ -1121,40 +1120,40 @@ 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->limbPos[idx]); + Matrix_MultZero(&this->limbPos[idx]); if (idx >= 1) { - Matrix_GetStateTranslationAndScaledX(2500.0f, &this->limbPos[idx + 4]); + Matrix_MultVecX(2500.0f, &this->limbPos[idx + 4]); } } } else if (this->unk_2BA > 0) { if (D_80896B8C[limbIndex] != -1) { - Matrix_GetStateTranslation(&this->limbPos[D_80896B8C[limbIndex]]); + Matrix_MultZero(&this->limbPos[D_80896B8C[limbIndex]]); } if (limbIndex == 24) { this->unk_2BA = -1; } } else if (D_80896B8C[limbIndex] != -1) { - OPEN_DISPS(globalCtx->state.gfxCtx); + OPEN_DISPS(play->state.gfxCtx); - matrix = Matrix_GetCurrentState(); - matrix->wx = this->limbPos[D_80896B8C[limbIndex]].x; - matrix->wy = this->limbPos[D_80896B8C[limbIndex]].y; - matrix->wz = this->limbPos[D_80896B8C[limbIndex]].z; - Matrix_InsertZRotation_s(this->actor.world.rot.z, MTXMODE_APPLY); + 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); + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_OPA_DISP++, this->unk_3A8); - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->state.gfxCtx); } } -void EnTite_Draw(Actor* thisx, GlobalContext* globalCtx) { +void EnTite_Draw(Actor* thisx, PlayState* play) { EnTite* this = THIS; Gfx* gfx; - OPEN_DISPS(globalCtx->state.gfxCtx); + OPEN_DISPS(play->state.gfxCtx); gfx = POLY_OPA_DISP; gSPDisplayList(&gfx[0], &sSetupDL[6 * 25]); @@ -1171,10 +1170,10 @@ void EnTite_Draw(Actor* thisx, GlobalContext* globalCtx) { POLY_OPA_DISP = &gfx[4]; - SkelAnime_DrawOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, EnTite_OverrideLimbDraw, + SkelAnime_DrawOpa(play, this->skelAnime.skeleton, this->skelAnime.jointTable, EnTite_OverrideLimbDraw, EnTite_PostLimbDraw, &this->actor); - Actor_DrawDamageEffects(globalCtx, &this->actor, this->limbPos, ARRAY_COUNT(this->limbPos), this->drawDmgEffScale, + Actor_DrawDamageEffects(play, &this->actor, this->limbPos, ARRAY_COUNT(this->limbPos), this->drawDmgEffScale, this->drawDmgEffFrozenSteamScale, this->drawDmgEffAlpha, this->drawDmgEffType); - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->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 24f3bd630..2d3a13a37 100644 --- a/src/overlays/actors/ovl_En_Tite/z_en_tite.h +++ b/src/overlays/actors/ovl_En_Tite/z_en_tite.h @@ -5,7 +5,7 @@ struct EnTite; -typedef void (*EnTiteActionFunc)(struct EnTite*, GlobalContext*); +typedef void (*EnTiteActionFunc)(struct EnTite*, PlayState*); enum { /* -4 */ ENTITE_MINUS_4 = -4, @@ -16,25 +16,25 @@ enum { }; typedef struct EnTite { - /* 0x0000 */ Actor actor; - /* 0x0144 */ SkelAnime skelAnime; - /* 0x0188 */ Vec3s jointTable[25]; - /* 0x021E */ Vec3s morphTable[25]; - /* 0x02B4 */ EnTiteActionFunc actionFunc; - /* 0x02B8 */ u8 unk_2B8; - /* 0x02B9 */ u8 unk_2B9; - /* 0x02BA */ s8 unk_2BA; - /* 0x02BB */ u8 drawDmgEffType; - /* 0x02BC */ s16 unk_2BC; - /* 0x02BE */ s16 unk_2BE; - /* 0x02C0 */ s32 unk_2C0; - /* 0x02C4 */ f32 drawDmgEffAlpha; - /* 0x02C8 */ f32 drawDmgEffScale; - /* 0x02CC */ f32 drawDmgEffFrozenSteamScale; - /* 0x02D0 */ Vec3f limbPos[9]; - /* 0x033C */ Vec3f unk_33C[9]; - /* 0x03A8 */ Gfx* unk_3A8; - /* 0x03AC */ ColliderSphere collider; + /* 0x000 */ Actor actor; + /* 0x144 */ SkelAnime skelAnime; + /* 0x188 */ Vec3s jointTable[25]; + /* 0x21E */ Vec3s morphTable[25]; + /* 0x2B4 */ EnTiteActionFunc actionFunc; + /* 0x2B8 */ u8 unk_2B8; + /* 0x2B9 */ u8 unk_2B9; + /* 0x2BA */ s8 unk_2BA; + /* 0x2BB */ u8 drawDmgEffType; + /* 0x2BC */ s16 unk_2BC; + /* 0x2BE */ s16 unk_2BE; + /* 0x2C0 */ s32 unk_2C0; + /* 0x2C4 */ f32 drawDmgEffAlpha; + /* 0x2C8 */ f32 drawDmgEffScale; + /* 0x2CC */ f32 drawDmgEffFrozenSteamScale; + /* 0x2D0 */ Vec3f limbPos[9]; + /* 0x33C */ Vec3f unk_33C[9]; + /* 0x3A8 */ Gfx* unk_3A8; + /* 0x3AC */ ColliderSphere collider; } EnTite; // size = 0x404 extern const ActorInit En_Tite_InitVars; diff --git a/src/overlays/actors/ovl_En_Tk/z_en_tk.c b/src/overlays/actors/ovl_En_Tk/z_en_tk.c index 976a5ac31..60c4b4dd0 100644 --- a/src/overlays/actors/ovl_En_Tk/z_en_tk.c +++ b/src/overlays/actors/ovl_En_Tk/z_en_tk.c @@ -13,60 +13,60 @@ #define THIS ((EnTk*)thisx) -void EnTk_Init(Actor* thisx, GlobalContext* globalCtx); -void EnTk_Destroy(Actor* thisx, GlobalContext* globalCtx); -void EnTk_Update(Actor* thisx, GlobalContext* globalCtx); -void EnTk_Draw(Actor* thisx, GlobalContext* globalCtx); +void EnTk_Init(Actor* thisx, PlayState* play); +void EnTk_Destroy(Actor* thisx, PlayState* play); +void EnTk_Update(Actor* thisx, PlayState* play); +void EnTk_Draw(Actor* thisx, PlayState* play); -void func_80AECA3C(EnTk* this, GlobalContext* globalCtx); -void func_80AECA90(EnTk* this, GlobalContext* globalCtx); -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); -void func_80AED4F8(EnTk* this, GlobalContext* globalCtx); -void func_80AED610(EnTk* this, GlobalContext* globalCtx); -void func_80AED898(EnTk* this, GlobalContext* globalCtx); -void func_80AED940(EnTk* this, GlobalContext* globalCtx); -void func_80AEDC4C(EnTk* this, GlobalContext* globalCtx); -void func_80AEDCBC(EnTk* this, GlobalContext* globalCtx); -void func_80AEDD4C(EnTk* this, GlobalContext* globalCtx); -void func_80AEDE10(EnTk* this, GlobalContext* globalCtx); -void func_80AEDF5C(EnTk* this, GlobalContext* globalCtx); -void func_80AEE2A8(EnTk* this, GlobalContext* globalCtx); -void func_80AEE2C0(EnTk* this, GlobalContext* globalCtx); -void func_80AEE374(EnTk* this, GlobalContext* globalCtx); -void func_80AEE414(EnTk* this, GlobalContext* globalCtx); -void func_80AEE478(EnTk* this, GlobalContext* globalCtx); -void func_80AEE4D0(EnTk* this, GlobalContext* globalCtx); -void func_80AEE650(EnTk* this, GlobalContext* globalCtx); -void func_80AEE6B8(EnTk* this, GlobalContext* globalCtx); -void func_80AEE784(EnTk* this, GlobalContext* globalCtx); -void func_80AEE9B0(EnTk* this, GlobalContext* globalCtx); -void func_80AEEAD4(EnTk* this, GlobalContext* globalCtx); -void func_80AEEB88(EnTk* this, GlobalContext* globalCtx); -void func_80AEED38(EnTk* this, GlobalContext* globalCtx); -void func_80AEF048(EnTk* this, GlobalContext* globalCtx); -void func_80AEF094(EnTk* this, GlobalContext* globalCtx); -void func_80AEF15C(EnTk* this, GlobalContext* globalCtx); -void func_80AEF1B4(EnTk* this, GlobalContext* globalCtx); -void func_80AEF1C4(EnTk* this, GlobalContext* globalCtx); -void func_80AEF210(EnTk* this, GlobalContext* globalCtx); -void func_80AEF220(EnTk* this, GlobalContext* globalCtx); -void func_80AEF278(EnTk* this, GlobalContext* globalCtx); -void func_80AEF2C8(Actor* thisx, GlobalContext* globalCtx); -void func_80AEF2D8(Actor* thisx, GlobalContext* globalCtx); -void func_80AEF5F4(Actor* thisx, GlobalContext* globalCtx); +void func_80AECA3C(EnTk* this, PlayState* play); +void func_80AECA90(EnTk* this, PlayState* play); +void func_80AECB0C(EnTk* this, PlayState* play); +void func_80AECB6C(EnTk* this, PlayState* play); +void func_80AECE0C(EnTk* this, PlayState* play); +s32 func_80AECE60(EnTk* this, PlayState* play); +s32 func_80AED354(EnTk* this, PlayState* play, ScheduleOutput* scheduleOutput); +s32 func_80AED38C(EnTk* this, PlayState* play, ScheduleOutput* scheduleOutput); +void func_80AED4F8(EnTk* this, PlayState* play); +void func_80AED610(EnTk* this, PlayState* play); +void func_80AED898(EnTk* this, PlayState* play); +void func_80AED940(EnTk* this, PlayState* play); +void func_80AEDC4C(EnTk* this, PlayState* play); +void func_80AEDCBC(EnTk* this, PlayState* play); +void func_80AEDD4C(EnTk* this, PlayState* play); +void func_80AEDE10(EnTk* this, PlayState* play); +void func_80AEDF5C(EnTk* this, PlayState* play); +void func_80AEE2A8(EnTk* this, PlayState* play); +void func_80AEE2C0(EnTk* this, PlayState* play); +void func_80AEE374(EnTk* this, PlayState* play); +void func_80AEE414(EnTk* this, PlayState* play); +void func_80AEE478(EnTk* this, PlayState* play); +void func_80AEE4D0(EnTk* this, PlayState* play); +void func_80AEE650(EnTk* this, PlayState* play); +void func_80AEE6B8(EnTk* this, PlayState* play); +void func_80AEE784(EnTk* this, PlayState* play); +void func_80AEE9B0(EnTk* this, PlayState* play); +void func_80AEEAD4(EnTk* this, PlayState* play); +void func_80AEEB88(EnTk* this, PlayState* play); +void func_80AEED38(EnTk* this, PlayState* play); +void func_80AEF048(EnTk* this, PlayState* play); +void func_80AEF094(EnTk* this, PlayState* play); +void func_80AEF15C(EnTk* this, PlayState* play); +void func_80AEF1B4(EnTk* this, PlayState* play); +void func_80AEF1C4(EnTk* this, PlayState* play); +void func_80AEF210(EnTk* this, PlayState* play); +void func_80AEF220(EnTk* this, PlayState* play); +void func_80AEF278(EnTk* this, PlayState* play); +void func_80AEF2C8(Actor* thisx, PlayState* play); +void func_80AEF2D8(Actor* thisx, PlayState* play); +void func_80AEF5F4(Actor* thisx, PlayState* play); 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 = { @@ -199,15 +199,15 @@ void func_80AEC658(SkelAnime* skelAnime, f32 arg1, f32 arg2, f32* arg3, f32* arg } } -void EnTk_Init(Actor* thisx, GlobalContext* globalCtx) { +void EnTk_Init(Actor* thisx, PlayState* play) { s32 pad; EnTk* this = THIS; this->unk_2B0 = ENTK_GET_F(&this->actor); this->unk_2B1 = ENTK_GET_7F0(&this->actor); - Collider_InitCylinder(globalCtx, &this->collider); + Collider_InitCylinder(play, &this->collider); - if (Flags_GetSwitch(globalCtx, this->unk_2B1)) { + if (Flags_GetSwitch(play, this->unk_2B1)) { if (this->unk_2B0 == 0) { Actor_MarkForDeath(&this->actor); return; @@ -225,10 +225,9 @@ void EnTk_Init(Actor* thisx, GlobalContext* globalCtx) { } ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 24.0f); - SkelAnime_InitFlex(globalCtx, &this->skelAnime, &object_tk_Skel_00B9E8, NULL, this->jointTable, this->morphTable, - 18); + SkelAnime_InitFlex(play, &this->skelAnime, &object_tk_Skel_00B9E8, NULL, this->jointTable, this->morphTable, 18); Animation_Change(&this->skelAnime, &object_tk_Anim_0030A4, 1.0f, 0.0f, - Animation_GetLastFrame(&object_tk_Anim_0030A4.common), 0, 0.0f); + Animation_GetLastFrame(&object_tk_Anim_0030A4.common), ANIMMODE_LOOP, 0.0f); this->unk_318 = 0; this->unk_2D4 = -1; Actor_SetScale(&this->actor, 0.01f); @@ -238,11 +237,11 @@ void EnTk_Init(Actor* thisx, GlobalContext* globalCtx) { if (this->unk_2B0 == 2) { this->unk_316 = 0; this->actor.update = func_80AEF5F4; - func_80AECA3C(this, globalCtx); + func_80AECA3C(this, play); return; } - Collider_SetCylinder(globalCtx, &this->collider, &this->actor, &sCylinderInit); + Collider_SetCylinder(play, &this->collider, &this->actor, &sCylinderInit); this->actor.world.rot.y = this->actor.yawTowardsPlayer; this->actor.gravity = -1.0f; this->actor.shape.rot.y = this->actor.world.rot.y; @@ -260,15 +259,15 @@ void EnTk_Init(Actor* thisx, GlobalContext* globalCtx) { this->actor.room = -1; this->actor.update = func_80AEF2D8; this->unk_2D8 = 0.0f; - func_80AECB0C(this, globalCtx); - func_80AEF2D8(&this->actor, globalCtx); + func_80AECB0C(this, play); + func_80AEF2D8(&this->actor, play); break; case 0: this->unk_2D0 = -1; this->unk_310 = 0; this->unk_2E4 = 0; - func_80AED898(this, globalCtx); + func_80AED898(this, play); break; default: @@ -277,29 +276,29 @@ void EnTk_Init(Actor* thisx, GlobalContext* globalCtx) { } } -void EnTk_Destroy(Actor* thisx, GlobalContext* globalCtx) { +void EnTk_Destroy(Actor* thisx, PlayState* play) { EnTk* this = THIS; - Collider_DestroyCylinder(globalCtx, &this->collider); + Collider_DestroyCylinder(play, &this->collider); } -void func_80AECA3C(EnTk* this, GlobalContext* globalCtx) { +void func_80AECA3C(EnTk* this, PlayState* play) { this->unk_316 = 0; SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, D_80AEF868, 2, &this->unk_2D4); this->actionFunc = func_80AECA90; } -void func_80AECA90(EnTk* this, GlobalContext* globalCtx) { - if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { - globalCtx->msgCtx.msgMode = 0; - globalCtx->msgCtx.unk11F10 = 0; - func_80AEDE10(this, globalCtx); +void func_80AECA90(EnTk* this, PlayState* play) { + if (Actor_ProcessTalkRequest(&this->actor, &play->state)) { + play->msgCtx.msgMode = 0; + play->msgCtx.msgLength = 0; + func_80AEDE10(this, play); } else if (this->actor.xzDistToPlayer < 100.0f) { - func_800B8614(&this->actor, globalCtx, 100.0f); + func_800B8614(&this->actor, play, 100.0f); } } -void func_80AECB0C(EnTk* this, GlobalContext* globalCtx) { +void func_80AECB0C(EnTk* this, PlayState* play) { this->actor.speedXZ = 0.0f; this->unk_3CC = 0xFF; this->unk_2DC = 0.0f; @@ -307,25 +306,25 @@ void func_80AECB0C(EnTk* this, GlobalContext* globalCtx) { this->actionFunc = func_80AECB6C; } -void func_80AECB6C(EnTk* this, GlobalContext* globalCtx) { +void func_80AECB6C(EnTk* this, PlayState* play) { f32 temp_f0; s32 temp2; s32 temp3; f32 sp48; f32 sp44; + ScheduleOutput sp34; u8 temp4; - struct_80133038_arg2 sp34; this->actor.textId = 0; - if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { - globalCtx->msgCtx.msgMode = 0; - globalCtx->msgCtx.unk11F10 = 0; - func_80AED4F8(this, globalCtx); + if (Actor_ProcessTalkRequest(&this->actor, &play->state)) { + play->msgCtx.msgMode = 0; + play->msgCtx.msgLength = 0; + func_80AED4F8(this, play); return; } if (REG(15) != 0.0f) { - this->skelAnime.playSpeed = (f32)func_800FE620(globalCtx) / REG(15); + this->skelAnime.playSpeed = (f32)func_800FE620(play) / REG(15); } else { this->skelAnime.playSpeed = 0.0f; } @@ -343,18 +342,18 @@ 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(play, D_80AEF800, &sp34)) { + if ((this->unk_3CC != sp34.result) && !func_80AED354(this, play, &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)) { @@ -365,8 +364,8 @@ void func_80AECB6C(EnTk* this, GlobalContext* globalCtx) { this->actor.draw = EnTk_Draw; } - this->unk_3CC = sp34.unk0; - func_80AECE0C(this, globalCtx); + this->unk_3CC = sp34.result; + func_80AECE0C(this, play); if (this->unk_3CE & 8) { this->actor.flags &= ~ACTOR_FLAG_1; @@ -374,98 +373,99 @@ void func_80AECB6C(EnTk* this, GlobalContext* globalCtx) { } } -void func_80AECE0C(EnTk* this, GlobalContext* globalCtx) { +void func_80AECE0C(EnTk* this, PlayState* play) { if (this->unk_3CC != 0) { if (1) {} - func_80AECE60(this, globalCtx); + func_80AECE60(this, play); } Math_SmoothStepToS(&this->actor.shape.rot.y, this->actor.world.rot.y, 4, 0x1555, 0xB6); } -s32 func_80AECE60(EnTk* this, GlobalContext* globalCtx) { +s32 func_80AECE60(EnTk* this, PlayState* play) { EnDoor* door; - f32 spA0[265]; + 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(play, 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 ((play->transitionMode != TRANS_MODE_OFF) || (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 ((play->transitionMode != TRANS_MODE_OFF) || (this->timePathTimeSpeed == 0)) { + this->timePathElapsedTime = sp78; + this->timePathWaypoint = sp74; + this->timePathTargetPos = timePathTargetPos; } 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(play, doorIter, ACTORCAT_DOOR, ACTOR_EN_DOOR); + if (doorIter != NULL) { + if (Actor_XZDistanceBetweenActors(&this->actor, doorIter) <= 120.0f) { + if (ABS(BINANG_SUB(Actor_YawToPoint(&this->actor, &doorIter->world.pos), + this->actor.shape.rot.y)) <= 0x2000) { this->unk_2CA |= 0x400; - door = (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) { - door = (EnDoor*)door2; + doorIter = SubS_FindActor(play, 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 ((door != NULL) && (this->unk_2CA & 0x400)) { @@ -486,101 +486,102 @@ s32 func_80AECE60(EnTk* this, GlobalContext* globalCtx) { } 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, play, 100.0f, 100.0f, PLAYER_AP_NONE, 0x4000, 0x4000); } return false; } -s32 func_80AED354(EnTk* this, GlobalContext* globalCtx, struct_80133038_arg2* arg2) { +s32 func_80AED354(EnTk* this, PlayState* play, ScheduleOutput* scheduleOutput) { s32 phi_v1 = false; - if (arg2->unk0 != 0) { - phi_v1 = func_80AED38C(this, globalCtx, arg2); + if (scheduleOutput->result != 0) { + phi_v1 = func_80AED38C(this, play, scheduleOutput); } return phi_v1; } -s32 func_80AED38C(EnTk* this, GlobalContext* globalCtx, struct_80133038_arg2* arg2) { - u16 sp1E = gSaveContext.save.time - 0x3FFC; +s32 func_80AED38C(EnTk* this, PlayState* play, ScheduleOutput* scheduleOutput) { + u16 sp1E = SCHEDULE_TIME_NOW; u8 params = ENTK_GET_F800(&this->actor); u16 phi_a1; - s32 idx = arg2->unk0 - 1; + s32 index = scheduleOutput->result - 1; + u16 tmp; - this->unk_3C8 = SubS_GetAdditionalPath(globalCtx, params, D_80AEF8E8[idx + 1]); - if (this->unk_3C8 == 0) { + this->timePath = SubS_GetAdditionalPath(play, params, D_80AEF8E8[index + 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 = scheduleOutput->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 = scheduleOutput->time1 - phi_a1; + this->timePathElapsedTime = sp1E - phi_a1; + tmp = phi_a1 = this->timePath->count - (SUBS_TIME_PATHING_ORDER - 1); + this->timePathWaypointTime = this->timePathTotalTime / tmp; + this->timePathWaypoint = (this->timePathElapsedTime / this->timePathWaypointTime) + (SUBS_TIME_PATHING_ORDER - 1); this->unk_3CE &= ~4; this->unk_3CE &= ~8; return true; } -void func_80AED4F8(EnTk* this, GlobalContext* globalCtx) { +void func_80AED4F8(EnTk* this, PlayState* play) { SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, D_80AEF868, 2, &this->unk_2D4); this->actionFunc = func_80AED610; } -void func_80AED544(EnTk* this, GlobalContext* globalCtx) { +void func_80AED544(EnTk* this, PlayState* play) { if (!(gSaveContext.save.weekEventReg[31] & 0x10)) { - Message_StartTextbox(globalCtx, 0x13FE, &this->actor); + Message_StartTextbox(play, 0x13FE, &this->actor); gSaveContext.save.weekEventReg[31] |= 0x10; } else if (gSaveContext.save.time < CLOCK_TIME(9, 0)) { - Message_StartTextbox(globalCtx, 0x13FF, &this->actor); + Message_StartTextbox(play, 0x13FF, &this->actor); } else if (gSaveContext.save.time < CLOCK_TIME(12, 0)) { - Message_StartTextbox(globalCtx, 0x1400, &this->actor); + Message_StartTextbox(play, 0x1400, &this->actor); } else if (gSaveContext.save.time < CLOCK_TIME(15, 0)) { - Message_StartTextbox(globalCtx, 0x1401, &this->actor); + Message_StartTextbox(play, 0x1401, &this->actor); } else { - Message_StartTextbox(globalCtx, 0x1402, &this->actor); + Message_StartTextbox(play, 0x1402, &this->actor); } } -void func_80AED610(EnTk* this, GlobalContext* globalCtx) { +void func_80AED610(EnTk* this, PlayState* play) { if ((this->unk_2D4 == 4) && Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) { SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, D_80AEF868, 7, &this->unk_2D4); } - switch (Message_GetState(&globalCtx->msgCtx)) { - case 0: + switch (Message_GetState(&play->msgCtx)) { + case TEXT_STATE_NONE: if (Math_ScaledStepToS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer - 0x1555, 0x71C)) { - if (Player_GetMask(globalCtx) == PLAYER_MASK_CAPTAIN) { + if (Player_GetMask(play) == PLAYER_MASK_CAPTAIN) { SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, D_80AEF868, 4, &this->unk_2D4); - Message_StartTextbox(globalCtx, 0x13FD, &this->actor); + Message_StartTextbox(play, 0x13FD, &this->actor); } else if (CURRENT_DAY != 2) { - func_80AED544(this, globalCtx); - } else if (!Flags_GetSwitch(globalCtx, ENTK_GET_7F0(&this->actor))) { - Message_StartTextbox(globalCtx, 0x1403, &this->actor); + func_80AED544(this, play); + } else if (!Flags_GetSwitch(play, ENTK_GET_7F0(&this->actor))) { + Message_StartTextbox(play, 0x1403, &this->actor); } else if (gSaveContext.save.weekEventReg[60] & 2) { - func_80AED544(this, globalCtx); + func_80AED544(this, play); } else { - Message_StartTextbox(globalCtx, 0x1413, &this->actor); + Message_StartTextbox(play, 0x1413, &this->actor); } break; } - case 1: - case 2: - case 3: + case TEXT_STATE_1: + case TEXT_STATE_CLOSING: + case TEXT_STATE_3: break; - case 4: - case 5: - case 6: - if (Message_ShouldAdvance(globalCtx)) { - switch (globalCtx->msgCtx.currentTextId) { + case TEXT_STATE_CHOICE: + case TEXT_STATE_5: + case TEXT_STATE_DONE: + if (Message_ShouldAdvance(play)) { + switch (play->msgCtx.currentTextId) { case 0x13FD: this->unk_2CA |= 0x10; SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, D_80AEF868, 0, &this->unk_2D4); @@ -589,13 +590,13 @@ void func_80AED610(EnTk* this, GlobalContext* globalCtx) { break; case 0x13FE: - func_80151938(globalCtx, 0x13FF); + func_80151938(play, 0x13FF); break; case 0x1413: - func_801159EC(30); + Rupees_ChangeBy(30); gSaveContext.save.weekEventReg[60] |= 2; - func_80151938(globalCtx, 0x13FF); + func_80151938(play, 0x13FF); break; case 0x13FF: @@ -628,7 +629,7 @@ void func_80AED610(EnTk* this, GlobalContext* globalCtx) { } } -void func_80AED898(EnTk* this, GlobalContext* globalCtx) { +void func_80AED898(EnTk* this, PlayState* play) { this->unk_316 = 0; this->actor.speedXZ = 0.0f; if (this->unk_2CA & 0x1000) { @@ -641,8 +642,8 @@ void func_80AED898(EnTk* this, GlobalContext* globalCtx) { this->actionFunc = func_80AED940; } -void func_80AED940(EnTk* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); +void func_80AED940(EnTk* this, PlayState* play) { + Player* player = GET_PLAYER(play); Actor* actor; Vec3f sp44; @@ -673,7 +674,7 @@ void func_80AED940(EnTk* this, GlobalContext* globalCtx) { actor = NULL; do { - actor = SubS_FindActor(globalCtx, actor, ACTORCAT_NPC, ACTOR_EN_TK); + actor = SubS_FindActor(play, actor, ACTORCAT_NPC, ACTOR_EN_TK); if (actor != NULL) { if (ENTK_GET_F(actor) == 1) { Math_Vec3f_Copy(&this->unk_2EC, &actor->world.pos); @@ -687,22 +688,22 @@ void func_80AED940(EnTk* this, GlobalContext* globalCtx) { } while (actor != NULL); } - if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { + if (Actor_ProcessTalkRequest(&this->actor, &play->state)) { this->unk_2CA &= ~0x80; this->actor.flags &= ~ACTOR_FLAG_10000; - globalCtx->msgCtx.msgMode = 0; - globalCtx->msgCtx.unk11F10 = 0; - func_80AEDE10(this, globalCtx); + play->msgCtx.msgMode = 0; + play->msgCtx.msgLength = 0; + func_80AEDE10(this, play); } 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, play, 100.0f, 100.0f, PLAYER_AP_NONE, 0x4000, 0x4000); } } else { - func_800B8500(&this->actor, globalCtx, this->actor.xzDistToPlayer, this->actor.playerHeightRel, 0); + func_800B8500(&this->actor, play, this->actor.xzDistToPlayer, this->actor.playerHeightRel, PLAYER_AP_NONE); } } -void func_80AEDBEC(EnTk* this, GlobalContext* globalCtx) { +void func_80AEDBEC(EnTk* this, PlayState* play) { this->actor.params = -1; this->unk_2E8 = 0; this->actor.speedXZ = 0.0f; @@ -710,16 +711,16 @@ void func_80AEDBEC(EnTk* this, GlobalContext* globalCtx) { this->actionFunc = func_80AEDC4C; } -void func_80AEDC4C(EnTk* this, GlobalContext* globalCtx) { +void func_80AEDC4C(EnTk* this, PlayState* play) { if ((this->actor.params >= 0) && SubS_StartActorCutscene(&this->actor, this->cutscenes[1], this->actor.params, SUBS_CUTSCENE_SET_UNK_LINK_FIELDS)) { this->unk_2E8 = ActorCutscene_GetLength(this->cutscenes[1]); - func_80151938(globalCtx, 0x1411); - func_80AEDCBC(this, globalCtx); + func_80151938(play, 0x1411); + func_80AEDCBC(this, play); } } -void func_80AEDCBC(EnTk* this, GlobalContext* globalCtx) { +void func_80AEDCBC(EnTk* this, PlayState* play) { this->actor.speedXZ = 10.0f; SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, D_80AEF868, 5, &this->unk_2D4); Math_Vec3f_Copy(&this->actor.world.pos, &this->unk_2EC); @@ -729,16 +730,16 @@ void func_80AEDCBC(EnTk* this, GlobalContext* globalCtx) { this->actionFunc = func_80AEDD4C; } -void func_80AEDD4C(EnTk* this, GlobalContext* globalCtx) { +void func_80AEDD4C(EnTk* this, PlayState* play) { this->unk_2E8--; if (this->unk_2E8 <= 0) { ActorCutscene_Stop(this->cutscenes[1]); - func_801477B4(globalCtx); + func_801477B4(play); Actor_MarkForDeath(&this->actor); } } -void func_80AEDDA0(EnTk* this, GlobalContext* globalCtx) { +void func_80AEDDA0(EnTk* this, PlayState* play) { this->actor.speedXZ = 0.0f; SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, D_80AEF868, 2, &this->unk_2D4); this->actor.flags |= ACTOR_FLAG_10000; @@ -746,10 +747,10 @@ void func_80AEDDA0(EnTk* this, GlobalContext* globalCtx) { this->actionFunc = func_80AED940; } -void func_80AEDE10(EnTk* this, GlobalContext* globalCtx) { +void func_80AEDE10(EnTk* this, PlayState* play) { switch (this->unk_2B0) { case 0: - if (Player_GetMask(globalCtx) == PLAYER_MASK_CAPTAIN) { + if (Player_GetMask(play) == PLAYER_MASK_CAPTAIN) { this->unk_2E6 = 0x1404; break; } @@ -769,12 +770,12 @@ void func_80AEDE10(EnTk* this, GlobalContext* globalCtx) { break; case 4: - Message_StartTextbox(globalCtx, 0x140F, &this->actor); + Message_StartTextbox(play, 0x140F, &this->actor); SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, D_80AEF868, 2, &this->unk_2D4); break; case 3: - Message_StartTextbox(globalCtx, 0x1410, &this->actor); + Message_StartTextbox(play, 0x1410, &this->actor); SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, D_80AEF868, 2, &this->unk_2D4); break; } @@ -788,13 +789,13 @@ void func_80AEDE10(EnTk* this, GlobalContext* globalCtx) { this->actionFunc = func_80AEDF5C; } -void func_80AEDF5C(EnTk* this, GlobalContext* globalCtx) { +void func_80AEDF5C(EnTk* this, PlayState* play) { if ((this->unk_2D4 == 4) && Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) { SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, D_80AEF868, 7, &this->unk_2D4); } - switch (Message_GetState(&globalCtx->msgCtx)) { - case 0: + switch (Message_GetState(&play->msgCtx)) { + case TEXT_STATE_NONE: switch (this->unk_2E6) { case 0x1404: case 0x1405: @@ -810,84 +811,84 @@ void func_80AEDF5C(EnTk* this, GlobalContext* globalCtx) { } else { SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, D_80AEF868, 2, &this->unk_2D4); } - Message_StartTextbox(globalCtx, this->unk_2E6, &this->actor); + Message_StartTextbox(play, this->unk_2E6, &this->actor); } break; case 0x1414: - Message_StartTextbox(globalCtx, this->unk_2E6, &this->actor); + Message_StartTextbox(play, this->unk_2E6, &this->actor); break; } break; - case 1: - case 2: - case 3: + case TEXT_STATE_1: + case TEXT_STATE_CLOSING: + case TEXT_STATE_3: break; - case 4: - case 5: - case 6: - if (Message_ShouldAdvance(globalCtx)) { - switch (globalCtx->msgCtx.currentTextId) { + case TEXT_STATE_CHOICE: + case TEXT_STATE_5: + case TEXT_STATE_DONE: + if (Message_ShouldAdvance(play)) { + switch (play->msgCtx.currentTextId) { case 0x1404: this->unk_2CA |= 0x1000; - func_80AED898(this, globalCtx); + func_80AED898(this, play); break; case 0x1405: - func_80151938(globalCtx, 0x1406); + func_80151938(play, 0x1406); break; case 0x1406: - func_80151938(globalCtx, 0x1407); + func_80151938(play, 0x1407); break; case 0x1407: - if (globalCtx->msgCtx.choiceIndex == 0) { + if (play->msgCtx.choiceIndex == 0) { func_8019F208(); - func_80151938(globalCtx, 0x1409); + func_80151938(play, 0x1409); } else { func_8019F230(); - func_80151938(globalCtx, 0x1408); + func_80151938(play, 0x1408); } break; case 0x1408: - func_80151938(globalCtx, 0x1407); + func_80151938(play, 0x1407); break; case 0x1409: - func_80151938(globalCtx, 0x140A); + func_80151938(play, 0x140A); break; case 0x140A: gSaveContext.save.weekEventReg[52] |= 0x80; case 0x140B: - func_80AEE784(this, globalCtx); + func_80AEE784(this, play); break; case 0x140D: this->unk_2CA |= 2; - if (globalCtx->msgCtx.choiceIndex == 0) { + if (play->msgCtx.choiceIndex == 0) { func_8019F208(); - globalCtx->msgCtx.msgMode = 0x44; - func_80AEE2A8(this, globalCtx); + play->msgCtx.msgMode = 0x44; + func_80AEE2A8(this, play); } else { func_8019F230(); - func_80151938(globalCtx, 0x140E); + func_80151938(play, 0x140E); } break; case 0x140E: case 0x140F: case 0x1410: - func_80AEE784(this, globalCtx); + func_80AEE784(this, play); break; case 0x1414: - func_80AECA3C(this, globalCtx); + func_80AECA3C(this, play); break; } } @@ -895,17 +896,17 @@ void func_80AEDF5C(EnTk* this, GlobalContext* globalCtx) { } } -void func_80AEE2A8(EnTk* this, GlobalContext* globalCtx) { +void func_80AEE2A8(EnTk* this, PlayState* play) { this->actionFunc = func_80AEE2C0; } -void func_80AEE2C0(EnTk* this, GlobalContext* globalCtx) { +void func_80AEE2C0(EnTk* this, PlayState* play) { if (SubS_StartActorCutscene(&this->actor, this->cutscenes[0], 0x7C, SUBS_CUTSCENE_SET_UNK_LINK_FIELDS)) { - func_80AEE374(this, globalCtx); + func_80AEE374(this, play); } } -s32 func_80AEE300(GlobalContext* globalCtx, Actor* arg1, Actor* arg2, void* _arg3) { +s32 func_80AEE300(PlayState* play, Actor* arg1, Actor* arg2, void* _arg3) { EnTkStruct* arg3 = (EnTkStruct*)_arg3; f32 temp_f0; @@ -919,13 +920,13 @@ s32 func_80AEE300(GlobalContext* globalCtx, Actor* arg1, Actor* arg2, void* _arg return false; } -void func_80AEE374(EnTk* this, GlobalContext* globalCtx) { +void func_80AEE374(EnTk* this, PlayState* play) { EnTkStruct sp30; sp30.unk_00 = NULL; sp30.unk_04 = FLT_MAX; - SubS_FindActorCustom(globalCtx, &this->actor, NULL, ACTORCAT_NPC, ACTOR_EN_TK, &sp30, func_80AEE300); + SubS_FindActorCustom(play, &this->actor, NULL, ACTORCAT_NPC, ACTOR_EN_TK, &sp30, func_80AEE300); if (sp30.unk_00 == 0) { Actor_MarkForDeath(&this->actor); } else { @@ -934,25 +935,25 @@ void func_80AEE374(EnTk* this, GlobalContext* globalCtx) { } } -void func_80AEE414(EnTk* this, GlobalContext* globalCtx) { +void func_80AEE414(EnTk* this, PlayState* play) { Math_SmoothStepToS(&this->actor.shape.rot.y, this->unk_2CC, 2, 0xE38, 0x5B); this->actor.world.rot.y = this->actor.shape.rot.y; if (this->actor.shape.rot.y == this->unk_2CC) { - func_80AEE478(this, globalCtx); + func_80AEE478(this, play); } } -void func_80AEE478(EnTk* this, GlobalContext* globalCtx) { +void func_80AEE478(EnTk* this, PlayState* play) { this->unk_310 = 2; SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, D_80AEF868, 3, &this->unk_2D4); this->actionFunc = func_80AEE4D0; } -void func_80AEE4D0(EnTk* this, GlobalContext* globalCtx) { +void func_80AEE4D0(EnTk* this, PlayState* play) { Actor* bigPoe; if ((this->skelAnime.curFrame > 33.0f) && (this->skelAnime.curFrame < 41.0f)) { - func_800BBFB0(globalCtx, &this->unk_2B4, 10.0f, 2, 50, 30, 1); + func_800BBFB0(play, &this->unk_2B4, 10.0f, 2, 50, 30, 1); } if (Animation_OnFrame(&this->skelAnime, 33.0f)) { @@ -963,7 +964,7 @@ void func_80AEE4D0(EnTk* this, GlobalContext* globalCtx) { if (Animation_OnFrame(&this->skelAnime, 37.0f)) { bigPoe = NULL; do { - bigPoe = SubS_FindActor(globalCtx, bigPoe, ACTORCAT_PROP, ACTOR_EN_BIGPO); + bigPoe = SubS_FindActor(play, bigPoe, ACTORCAT_PROP, ACTOR_EN_BIGPO); if (bigPoe != NULL) { if ((bigPoe->params == 3) && (Actor_DistanceBetweenActors(&this->actor, bigPoe) < 80.0f)) { @@ -978,11 +979,11 @@ void func_80AEE4D0(EnTk* this, GlobalContext* globalCtx) { } if (Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) { - func_80AEE650(this, globalCtx); + func_80AEE650(this, play); } } -void func_80AEE650(EnTk* this, GlobalContext* globalCtx) { +void func_80AEE650(EnTk* this, PlayState* play) { if (this->unk_36C < ARRAY_COUNT(this->unk_324)) { Math_Vec3f_Copy(&this->unk_324[this->unk_36C], &this->actor.world.pos); this->unk_36C++; @@ -990,28 +991,28 @@ void func_80AEE650(EnTk* this, GlobalContext* globalCtx) { this->actionFunc = func_80AEE6B8; } -void func_80AEE6B8(EnTk* this, GlobalContext* globalCtx) { +void func_80AEE6B8(EnTk* this, PlayState* play) { if (this->unk_2CA & 0x20) { if (this->unk_2E4 >= 3) { ActorCutscene_Stop(this->cutscenes[0]); - func_801477B4(globalCtx); - func_80AEDBEC(this, globalCtx); + func_801477B4(play); + func_80AEDBEC(this, play); } else if (SubS_StartActorCutscene(&this->actor, 0x7C, this->cutscenes[0], SUBS_CUTSCENE_SET_UNK_LINK_FIELDS)) { this->unk_310 = 3; - func_80AEDE10(this, globalCtx); + func_80AEDE10(this, play); this->unk_2CA &= ~0x20; } } else if (SubS_StartActorCutscene(&this->actor, 0x7C, this->cutscenes[0], SUBS_CUTSCENE_SET_UNK_LINK_FIELDS)) { this->unk_310 = 4; - func_80AEDE10(this, globalCtx); + func_80AEDE10(this, play); } } -void func_80AEE784(EnTk* this, GlobalContext* globalCtx) { +void func_80AEE784(EnTk* this, PlayState* play) { this->unk_2D0 = -1; this->unk_310 = 1; Math_Vec3s_Copy(&this->actor.world.rot, &this->actor.shape.rot); - func_80AEEAD4(this, globalCtx); + func_80AEEAD4(this, play); this->actionFunc = func_80AEE9B0; } @@ -1028,7 +1029,7 @@ s32 func_80AEE7E0(Vec3f* arg0, f32 arg1, Vec3f* arg2, s32 arg3) { return ret; } -s32 func_80AEE86C(EnTk* this, GlobalContext* globalCtx) { +s32 func_80AEE86C(EnTk* this, PlayState* play) { static Vec3f D_80AEFA78 = { 0.0f, 20.0f, 32.0f }; s32 pad; s32 ret = false; @@ -1038,40 +1039,40 @@ s32 func_80AEE86C(EnTk* this, GlobalContext* globalCtx) { Vec3f sp28; Lib_Vec3f_TranslateAndRotateY(&this->actor.world.pos, this->actor.shape.rot.y, &D_80AEFA78, &sp28); - if ((BgCheck_EntityRaycastFloor3(&globalCtx->colCtx, &sp38, &sp34, &sp28) != BGCHECK_Y_MIN) && - (func_800C9BB8(&globalCtx->colCtx, sp38, sp34) == 1) && (this->unk_2D0 == (u32)1) && + if ((BgCheck_EntityRaycastFloor3(&play->colCtx, &sp38, &sp34, &sp28) != BGCHECK_Y_MIN) && + (func_800C9BB8(&play->colCtx, sp38, sp34) == 1) && (this->unk_2D0 == (u32)1) && (this->actor.xyzDistToPlayerSq <= SQ(115.0f)) && func_80AEE7E0(&this->actor.world.pos, 100.0f, this->unk_324, this->unk_36C) && (((this->unk_2CA & 2) && (Math_Vec3f_DistXZ(&this->unk_300, &sp28) >= 100.0f)) || !(this->unk_2CA & 2)) && - !Play_InCsMode(globalCtx)) { + !Play_InCsMode(play)) { Math_Vec3f_Copy(&this->unk_300, &sp28); ret = true; } return ret; } -void func_80AEE9B0(EnTk* this, GlobalContext* globalCtx) { - this->unk_30C(this, globalCtx); +void func_80AEE9B0(EnTk* this, PlayState* play) { + this->unk_30C(this, play); - func_80AEEAD4(this, globalCtx); + func_80AEEAD4(this, play); if (Math_Vec3f_DistXZ(&this->actor.world.pos, &this->unk_300) >= 100.0f) { this->unk_2CA &= ~2; } - if (func_80AEE86C(this, globalCtx)) { + if (func_80AEE86C(this, play)) { this->unk_310 = 2; - func_80AEDDA0(this, globalCtx); + func_80AEDDA0(this, play); } } -s32 func_80AEEA4C(EnTk* this, GlobalContext* globalCtx) { +s32 func_80AEEA4C(EnTk* this, PlayState* play) { s32 ret; if (this->unk_2CA & 1) { ret = 3; } else if (this->actor.xyzDistToPlayerSq < SQ(60.0f)) { ret = 0; - } else if (this->actor.isTargeted || (globalCtx->actorCtx.targetContext.unk_94 == &this->actor) || + } else if (this->actor.isTargeted || (play->actorCtx.targetContext.unk_94 == &this->actor) || (this->actor.xyzDistToPlayerSq < SQ(80.0f))) { ret = 1; } else { @@ -1080,36 +1081,36 @@ s32 func_80AEEA4C(EnTk* this, GlobalContext* globalCtx) { return ret; } -void func_80AEEAD4(EnTk* this, GlobalContext* globalCtx) { - s32 sp24 = func_80AEEA4C(this, globalCtx); +void func_80AEEAD4(EnTk* this, PlayState* play) { + s32 sp24 = func_80AEEA4C(this, play); if (sp24 != this->unk_2D0) { switch (sp24) { case 0: - func_80AEF220(this, globalCtx); + func_80AEF220(this, play); break; case 1: - func_80AEF048(this, globalCtx); + func_80AEF048(this, play); break; case 2: - func_80AEEB88(this, globalCtx); + func_80AEEB88(this, play); break; case 3: - func_80AEF15C(this, globalCtx); + func_80AEF15C(this, play); break; case 4: - func_80AEF1C4(this, globalCtx); + func_80AEF1C4(this, play); break; } this->unk_2D0 = sp24; } } -void func_80AEEB88(EnTk* this, GlobalContext* globalCtx) { +void func_80AEEB88(EnTk* this, PlayState* play) { s32 sp74; Vec3f sp68; s32 i; @@ -1123,8 +1124,8 @@ void func_80AEEB88(EnTk* this, GlobalContext* globalCtx) { sp68.y = this->actor.world.pos.y + 50.0f; sp68.z += this->actor.world.pos.z; - temp = BgCheck_EntityRaycastFloor3(&globalCtx->colCtx, &this->actor.floorPoly, &sp74, &sp68) - - this->actor.world.pos.y; + temp = + BgCheck_EntityRaycastFloor3(&play->colCtx, &this->actor.floorPoly, &sp74, &sp68) - this->actor.world.pos.y; if (temp <= -80.0f) { break; } @@ -1141,7 +1142,7 @@ void func_80AEEB88(EnTk* this, GlobalContext* globalCtx) { this->unk_30C = func_80AEED38; } -void func_80AEED38(EnTk* this, GlobalContext* globalCtx) { +void func_80AEED38(EnTk* this, PlayState* play) { f32 sp64; Vec3f sp58; s16 sp56 = this->actor.shape.rot.y; @@ -1153,7 +1154,7 @@ void func_80AEED38(EnTk* this, GlobalContext* globalCtx) { sp58.y += 30.0f; sp58.z += Math_CosS(sp56) * 20.0f; - if (BgCheck_SphVsFirstWall(&globalCtx->colCtx, &sp58, 20.0f)) { + if (BgCheck_SphVsFirstWall(&play->colCtx, &sp58, 20.0f)) { Math_Vec3f_Copy(&sp48, &this->actor.world.pos); sp56 = BINANG_ADD(this->actor.shape.rot.y, 0x4000); sp48.x += (Math_SinS(sp56) * 20.0f); @@ -1166,8 +1167,8 @@ void func_80AEED38(EnTk* this, GlobalContext* globalCtx) { sp3C.y += 30.0f; sp3C.z += Math_CosS(sp56) * 20.0f; - if (BgCheck_SphVsFirstWall(&globalCtx->colCtx, &sp48, 20.0f)) { - if (BgCheck_SphVsFirstWall(&globalCtx->colCtx, &sp3C, 20.0f)) { + if (BgCheck_SphVsFirstWall(&play->colCtx, &sp48, 20.0f)) { + if (BgCheck_SphVsFirstWall(&play->colCtx, &sp3C, 20.0f)) { this->unk_2CC = this->actor.shape.rot.y - 0x4000; } else { this->unk_2CC = this->actor.shape.rot.y - 0x4000; @@ -1189,19 +1190,19 @@ void func_80AEED38(EnTk* this, GlobalContext* globalCtx) { this->actor.shape.rot.y = this->actor.world.rot.y; } - if (Message_GetState(&globalCtx->msgCtx) == 0 && !Play_InCsMode(globalCtx) && (this->unk_2C6-- <= 0)) { - Message_StartTextbox(globalCtx, 0x140C, NULL); + if ((Message_GetState(&play->msgCtx) == TEXT_STATE_NONE) && !Play_InCsMode(play) && (this->unk_2C6-- <= 0)) { + Message_StartTextbox(play, 0x140C, NULL); this->unk_2CA |= 0x4000; this->unk_2C6 = 200; } } -void func_80AEF048(EnTk* this, GlobalContext* globalCtx) { +void func_80AEF048(EnTk* this, PlayState* play) { SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, D_80AEF868, 1, &this->unk_2D4); this->unk_30C = func_80AEF094; } -void func_80AEF094(EnTk* this, GlobalContext* globalCtx) { +void func_80AEF094(EnTk* this, PlayState* play) { f32 sp2C; if (this->unk_2CA & 0x200) { @@ -1217,44 +1218,44 @@ void func_80AEF094(EnTk* this, GlobalContext* globalCtx) { } } -void func_80AEF15C(EnTk* this, GlobalContext* globalCtx) { +void func_80AEF15C(EnTk* this, PlayState* play) { this->actor.speedXZ = 0.0f; SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, D_80AEF868, 2, &this->unk_2D4); this->unk_30C = func_80AEF1B4; } -void func_80AEF1B4(EnTk* this, GlobalContext* globalCtx) { +void func_80AEF1B4(EnTk* this, PlayState* play) { } -void func_80AEF1C4(EnTk* this, GlobalContext* globalCtx) { +void func_80AEF1C4(EnTk* this, PlayState* play) { SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, D_80AEF868, 2, &this->unk_2D4); this->unk_30C = func_80AEF210; } -void func_80AEF210(EnTk* this, GlobalContext* globalCtx) { +void func_80AEF210(EnTk* this, PlayState* play) { } -void func_80AEF220(EnTk* this, GlobalContext* globalCtx) { +void func_80AEF220(EnTk* this, PlayState* play) { this->actor.speedXZ = 0.0f; SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, D_80AEF868, 2, &this->unk_2D4); this->unk_30C = func_80AEF278; } -void func_80AEF278(EnTk* this, GlobalContext* globalCtx) { +void func_80AEF278(EnTk* this, PlayState* play) { Math_SmoothStepToS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer - 0x1555, 3, 0x1C7, 0); this->actor.world.rot.y = this->actor.shape.rot.y; } -void func_80AEF2C8(Actor* thisx, GlobalContext* globalCtx) { +void func_80AEF2C8(Actor* thisx, PlayState* play) { } -void func_80AEF2D8(Actor* thisx, GlobalContext* globalCtx) { +void func_80AEF2D8(Actor* thisx, PlayState* play) { s32 pad; EnTk* this = THIS; if (this->actor.draw != NULL) { Collider_UpdateCylinder(&this->actor, &this->collider); - CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + CollisionCheck_SetOC(play, &play->colChkCtx, &this->collider.base); } this->unk_320 = this->skelAnime.curFrame; @@ -1265,19 +1266,19 @@ void func_80AEF2D8(Actor* thisx, GlobalContext* globalCtx) { Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_GOLON_WALK); } - this->actionFunc(this, globalCtx); + this->actionFunc(this, play); Actor_MoveWithGravity(&this->actor); - Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 10.0f, 10.0f, 0.0f, 4); + Actor_UpdateBgCheckInfo(play, &this->actor, 10.0f, 10.0f, 0.0f, 4); func_80AEC460(this); } -void EnTk_Update(Actor* thisx, GlobalContext* globalCtx) { +void EnTk_Update(Actor* thisx, PlayState* play) { s32 pad; EnTk* this = THIS; Collider_UpdateCylinder(&this->actor, &this->collider); - CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + CollisionCheck_SetOC(play, &play->colChkCtx, &this->collider.base); this->unk_320 = this->skelAnime.curFrame; SkelAnime_Update(&this->skelAnime); func_80AEC460(this); @@ -1290,7 +1291,7 @@ void EnTk_Update(Actor* thisx, GlobalContext* globalCtx) { this->unk_2CA &= ~1; if (this->actor.floorBgId != BGCHECK_SCENE) { - BgDanpeiMovebg* platform = (BgDanpeiMovebg*)DynaPoly_GetActor(&globalCtx->colCtx, this->actor.floorBgId); + BgDanpeiMovebg* platform = (BgDanpeiMovebg*)DynaPoly_GetActor(&play->colCtx, this->actor.floorBgId); if (platform != NULL) { if (platform->dyna.actor.id == ACTOR_BG_DANPEI_MOVEBG) { @@ -1305,13 +1306,12 @@ void EnTk_Update(Actor* thisx, GlobalContext* globalCtx) { } } - this->actionFunc(this, globalCtx); + this->actionFunc(this, play); Actor_MoveWithGravity(&this->actor); - Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 10.0f, 10.0f, 0.0f, 5); + Actor_UpdateBgCheckInfo(play, &this->actor, 10.0f, 10.0f, 0.0f, 5); - if ((this->unk_2B0 == 0) && - (func_800C9B40(&globalCtx->colCtx, this->actor.floorPoly, this->actor.floorBgId) == 12)) { + if ((this->unk_2B0 == 0) && (func_800C9B40(&play->colCtx, this->actor.floorPoly, this->actor.floorBgId) == 12)) { Math_Vec3f_Copy(&this->actor.world.pos, &this->actor.prevPos); this->unk_2CA |= 0x200; this->actor.velocity.y = 0.0f; @@ -1328,15 +1328,15 @@ void EnTk_Update(Actor* thisx, GlobalContext* globalCtx) { } } -void func_80AEF5F4(Actor* thisx, GlobalContext* globalCtx) { +void func_80AEF5F4(Actor* thisx, PlayState* play) { EnTk* this = THIS; this->unk_316 += 0x46C8; this->unk_318 = Math_SinS(this->unk_316) * 900.0f; - this->actionFunc(this, globalCtx); + this->actionFunc(this, play); } -s32 EnTk_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, Actor* thisx) { +s32 EnTk_OverrideLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, Actor* thisx) { EnTk* this = THIS; if (limbIndex == 16) { @@ -1346,30 +1346,30 @@ s32 EnTk_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, return false; } -void EnTk_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx) { +void EnTk_PostLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx) { static Vec3f D_80AEFA84 = { 0.0f, 0.0f, 4600.0f }; EnTk* this = THIS; 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); + OPEN_DISPS(play->state.gfxCtx); gSPDisplayList(POLY_OPA_DISP++, object_tk_DL_00B530); - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->state.gfxCtx); break; } } } -void EnTk_Draw(Actor* thisx, GlobalContext* globalCtx) { +void EnTk_Draw(Actor* thisx, PlayState* play) { static TexturePtr D_80AEFA90[] = { object_tk_Tex_004390, object_tk_Tex_004B90, @@ -1378,15 +1378,15 @@ void EnTk_Draw(Actor* thisx, GlobalContext* globalCtx) { s32 pad; EnTk* this = THIS; - OPEN_DISPS(globalCtx->state.gfxCtx); + OPEN_DISPS(play->state.gfxCtx); POLY_OPA_DISP = Gfx_CallSetupDL(POLY_OPA_DISP, 25); gSPSegment(POLY_OPA_DISP++, 0x08, Lib_SegmentedToVirtual(D_80AEFA90[this->unk_2C2])); - Matrix_RotateY(this->unk_318, MTXMODE_APPLY); - SkelAnime_DrawFlexOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, + Matrix_RotateYS(this->unk_318, MTXMODE_APPLY); + SkelAnime_DrawFlexOpa(play, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, EnTk_OverrideLimbDraw, EnTk_PostLimbDraw, &this->actor); - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->state.gfxCtx); } 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..279cd0810 100644 --- a/src/overlays/actors/ovl_En_Tk/z_en_tk.h +++ b/src/overlays/actors/ovl_En_Tk/z_en_tk.h @@ -5,62 +5,62 @@ struct EnTk; -typedef void (*EnTkActionFunc)(struct EnTk*, GlobalContext*); -typedef void (*EnTkUnkFunc)(struct EnTk*, GlobalContext*); +typedef void (*EnTkActionFunc)(struct EnTk*, PlayState*); +typedef void (*EnTkUnkFunc)(struct EnTk*, PlayState*); #define ENTK_GET_F(thisx) ((thisx)->params & 0xF) #define ENTK_GET_7F0(thisx) (((thisx)->params >> 4) & 0x7F) #define ENTK_GET_F800(thisx) ((((thisx)->params >> 0xB) & 0x1F) & 0xFF) typedef struct EnTk { - /* 0x0000 */ Actor actor; - /* 0x0144 */ SkelAnime skelAnime; - /* 0x0188 */ EnTkActionFunc actionFunc; - /* 0x018C */ ColliderCylinder collider; - /* 0x01D8 */ Vec3s jointTable[18]; - /* 0x0244 */ Vec3s morphTable[18]; - /* 0x02B0 */ s8 unk_2B0; - /* 0x02B1 */ s8 unk_2B1; - /* 0x02B4 */ Vec3f unk_2B4; - /* 0x02C0 */ s16 unk_2C0; - /* 0x02C2 */ s16 unk_2C2; - /* 0x02C4 */ s16 unk_2C4; - /* 0x02C6 */ s16 unk_2C6; - /* 0x02C8 */ UNK_TYPE1 unk2C8[0x2]; - /* 0x02CA */ u16 unk_2CA; - /* 0x02CC */ s16 unk_2CC; - /* 0x02D0 */ s32 unk_2D0; - /* 0x02D4 */ s32 unk_2D4; - /* 0x02D8 */ f32 unk_2D8; - /* 0x02DC */ f32 unk_2DC; - /* 0x02E0 */ s32 unk_2E0; - /* 0x02E4 */ s16 unk_2E4; - /* 0x02E6 */ u16 unk_2E6; - /* 0x02E8 */ s16 unk_2E8; - /* 0x02EC */ Vec3f unk_2EC; - /* 0x02F8 */ Vec3s unk_2F8; - /* 0x0300 */ Vec3f unk_300; - /* 0x030C */ EnTkUnkFunc unk_30C; - /* 0x0310 */ s16 unk_310; - /* 0x0312 */ s16 cutscenes[2]; - /* 0x0316 */ s16 unk_316; - /* 0x0318 */ s16 unk_318; - /* 0x031A */ s16 unk_31A; - /* 0x031C */ s16 unk_31C; - /* 0x0320 */ f32 unk_320; - /* 0x0324 */ Vec3f unk_324[6]; - /* 0x036C */ s32 unk_36C; - /* 0x0370 */ UNK_TYPE1 unk370[0x58]; - /* 0x03C8 */ Path* unk_3C8; - /* 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; + /* 0x000 */ Actor actor; + /* 0x144 */ SkelAnime skelAnime; + /* 0x188 */ EnTkActionFunc actionFunc; + /* 0x18C */ ColliderCylinder collider; + /* 0x1D8 */ Vec3s jointTable[18]; + /* 0x244 */ Vec3s morphTable[18]; + /* 0x2B0 */ s8 unk_2B0; + /* 0x2B1 */ s8 unk_2B1; + /* 0x2B4 */ Vec3f unk_2B4; + /* 0x2C0 */ s16 unk_2C0; + /* 0x2C2 */ s16 unk_2C2; + /* 0x2C4 */ s16 unk_2C4; + /* 0x2C6 */ s16 unk_2C6; + /* 0x2C8 */ UNK_TYPE1 unk2C8[0x2]; + /* 0x2CA */ u16 unk_2CA; + /* 0x2CC */ s16 unk_2CC; + /* 0x2D0 */ s32 unk_2D0; + /* 0x2D4 */ s32 unk_2D4; + /* 0x2D8 */ f32 unk_2D8; + /* 0x2DC */ f32 unk_2DC; + /* 0x2E0 */ s32 unk_2E0; + /* 0x2E4 */ s16 unk_2E4; + /* 0x2E6 */ u16 unk_2E6; + /* 0x2E8 */ s16 unk_2E8; + /* 0x2EC */ Vec3f unk_2EC; + /* 0x2F8 */ Vec3s unk_2F8; + /* 0x300 */ Vec3f unk_300; + /* 0x30C */ EnTkUnkFunc unk_30C; + /* 0x310 */ s16 unk_310; + /* 0x312 */ s16 cutscenes[2]; + /* 0x316 */ s16 unk_316; + /* 0x318 */ s16 unk_318; + /* 0x31A */ s16 unk_31A; + /* 0x31C */ s16 unk_31C; + /* 0x320 */ f32 unk_320; + /* 0x324 */ Vec3f unk_324[6]; + /* 0x36C */ s32 unk_36C; + /* 0x370 */ UNK_TYPE1 unk370[0x58]; + /* 0x3C8 */ Path* timePath; + /* 0x3CC */ u8 unk_3CC; + /* 0x3CE */ u16 unk_3CE; + /* 0x3D0 */ s32 timePathTimeSpeed; + /* 0x3D4 */ Vec3f timePathTargetPos; + /* 0x3E0 */ f32 timePathProgress; + /* 0x3E4 */ s32 timePathTotalTime; + /* 0x3E8 */ s32 timePathWaypointTime; + /* 0x3EC */ s32 timePathWaypoint; + /* 0x3F0 */ s32 timePathElapsedTime; } EnTk; // size = 0x3F4 extern const ActorInit En_Tk_InitVars; diff --git a/src/overlays/actors/ovl_En_Torch/z_en_torch.c b/src/overlays/actors/ovl_En_Torch/z_en_torch.c index fc06cff18..9a09e27eb 100644 --- a/src/overlays/actors/ovl_En_Torch/z_en_torch.c +++ b/src/overlays/actors/ovl_En_Torch/z_en_torch.c @@ -5,26 +5,29 @@ */ #include "z_en_torch.h" +#include "overlays/actors/ovl_En_Box/z_en_box.h" #define FLAGS 0x00000000 #define THIS ((EnTorch*)thisx) -void EnTorch_Init(Actor* thisx, GlobalContext* globalCtx); +void EnTorch_Init(Actor* thisx, PlayState* play); const ActorInit En_Torch_InitVars = { ACTOR_EN_TORCH, ACTORCAT_ITEMACTION, FLAGS, GAMEPLAY_KEEP, sizeof(EnTorch), (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) { +void EnTorch_Init(Actor* thisx, PlayState* play) { EnTorch* this = THIS; 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, + Actor_Spawn(&play->actorCtx, play, 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 c6931fac5..2cb3cb193 100644 --- a/src/overlays/actors/ovl_En_Torch2/z_en_torch2.c +++ b/src/overlays/actors/ovl_En_Torch2/z_en_torch2.c @@ -11,13 +11,13 @@ #define THIS ((EnTorch2*)thisx) -void EnTorch2_Init(Actor* thisx, GlobalContext* globalCtx); -void EnTorch2_Destroy(Actor* thisx, GlobalContext* globalCtx); -void EnTorch2_Update(Actor* thisx, GlobalContext* globalCtx); -void EnTorch2_Draw(Actor* thisx, GlobalContext* globalCtx); +void EnTorch2_Init(Actor* thisx, PlayState* play); +void EnTorch2_Destroy(Actor* thisx, PlayState* play); +void EnTorch2_Update(Actor* thisx, PlayState* play); +void EnTorch2_Draw(Actor* thisx, PlayState* play); -void EnTorch2_UpdateIdle(Actor* thisx, GlobalContext* globalCtx); -void EnTorch2_UpdateDeath(Actor* thisx, GlobalContext* globalCtx); +void EnTorch2_UpdateIdle(Actor* thisx, PlayState* play); +void EnTorch2_UpdateDeath(Actor* thisx, PlayState* play); const ActorInit En_Torch2_InitVars = { ACTOR_EN_TORCH2, @@ -65,12 +65,12 @@ static Gfx* sShellDLists[] = { gameplay_keep_DL_01C430, // Human }; -void EnTorch2_Init(Actor* thisx, GlobalContext* globalCtx) { +void EnTorch2_Init(Actor* thisx, PlayState* play) { EnTorch2* this = THIS; s16 params; Actor_ProcessInitChain(&this->actor, sInitChain); - Collider_InitAndSetCylinder(globalCtx, &this->collider, &this->actor, &sCylinderInit); + Collider_InitAndSetCylinder(play, &this->collider, &this->actor, &sCylinderInit); // params: which form Link is in (e.g. human, deku, etc.) params = this->actor.params; @@ -83,16 +83,16 @@ void EnTorch2_Init(Actor* thisx, GlobalContext* globalCtx) { this->framesUntilNextState = 20; } -void EnTorch2_Destroy(Actor* thisx, GlobalContext* globalCtx) { +void EnTorch2_Destroy(Actor* thisx, PlayState* play) { EnTorch2* this = THIS; - Collider_DestroyCylinder(globalCtx, &this->collider); - Play_SetRespawnData(&globalCtx->state, this->actor.params + RESPAWN_MODE_GORON - 1, 0xFF, 0, 0xBFF, + Collider_DestroyCylinder(play, &this->collider); + Play_SetRespawnData(&play->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; + play->actorCtx.unk254[this->actor.params] = 0; } -void EnTorch2_Update(Actor* thisx, GlobalContext* globalCtx) { +void EnTorch2_Update(Actor* thisx, PlayState* play) { EnTorch2* this = THIS; u16 targetAlpha; u16 remainingFrames; @@ -105,7 +105,7 @@ void EnTorch2_Update(Actor* thisx, GlobalContext* globalCtx) { this->actor.gravity = -1.0f; Actor_MoveWithGravity(&this->actor); - Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 30.0f, 20.0f, 70.0f, 0x05); + Actor_UpdateBgCheckInfo(play, &this->actor, 30.0f, 20.0f, 70.0f, 0x05); if (this->framesUntilNextState == 0) { remainingFrames = 0; @@ -131,14 +131,14 @@ void EnTorch2_Update(Actor* thisx, GlobalContext* globalCtx) { } else { // Once the player has moved away, update collision and become opaque Collider_UpdateCylinder(&this->actor, &this->collider); - CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + CollisionCheck_SetOC(play, &play->colChkCtx, &this->collider.base); targetAlpha = 255; } Math_StepToS(&this->alpha, targetAlpha, 8); } } -void EnTorch2_UpdateIdle(Actor* thisx, GlobalContext* globalCtx) { +void EnTorch2_UpdateIdle(Actor* thisx, PlayState* play) { EnTorch2* this = THIS; if (this->state == TORCH2_STATE_DYING) { @@ -148,7 +148,7 @@ void EnTorch2_UpdateIdle(Actor* thisx, GlobalContext* globalCtx) { } } -void EnTorch2_UpdateDeath(Actor* thisx, GlobalContext* globalCtx) { +void EnTorch2_UpdateDeath(Actor* thisx, PlayState* play) { EnTorch2* this = THIS; // Fall down and become transparent, then delete once invisible @@ -160,20 +160,20 @@ void EnTorch2_UpdateDeath(Actor* thisx, GlobalContext* globalCtx) { } } -void EnTorch2_Draw(Actor* thisx, GlobalContext* globalCtx2) { - GlobalContext* globalCtx = globalCtx2; +void EnTorch2_Draw(Actor* thisx, PlayState* play2) { + PlayState* play = play2; EnTorch2* this = THIS; Gfx* gfx = sShellDLists[thisx->params]; - OPEN_DISPS(globalCtx->state.gfxCtx); + OPEN_DISPS(play->state.gfxCtx); if (this->alpha == 0xFF) { - Scene_SetRenderModeXlu(globalCtx, 0, 0x01); + Scene_SetRenderModeXlu(play, 0, 0x01); gDPSetEnvColor(POLY_OPA_DISP++, 255, 255, 255, 255); - Gfx_DrawDListOpa(globalCtx, gfx); + Gfx_DrawDListOpa(play, gfx); } else { - Scene_SetRenderModeXlu(globalCtx, 1, 0x02); + Scene_SetRenderModeXlu(play, 1, 0x02); gDPSetEnvColor(POLY_XLU_DISP++, 255, 255, 255, this->alpha); - Gfx_DrawDListXlu(globalCtx, gfx); + Gfx_DrawDListXlu(play, gfx); } - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->state.gfxCtx); } diff --git a/src/overlays/actors/ovl_En_Toto/z_en_toto.c b/src/overlays/actors/ovl_En_Toto/z_en_toto.c index f12baac71..473ff1edd 100644 --- a/src/overlays/actors/ovl_En_Toto/z_en_toto.c +++ b/src/overlays/actors/ovl_En_Toto/z_en_toto.c @@ -13,42 +13,42 @@ #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); -void EnToto_Update(Actor* thisx, GlobalContext* globalCtx); -void EnToto_Draw(Actor* thisx, GlobalContext* globalCtx); +void EnToto_Init(Actor* thisx, PlayState* play); +void EnToto_Destroy(Actor* thisx, PlayState* play); +void EnToto_Update(Actor* thisx, PlayState* play); +void EnToto_Draw(Actor* thisx, PlayState* play); -void func_80BA3930(EnToto* this, GlobalContext* globalCtx); -void func_80BA39C8(EnToto* this, GlobalContext* globalCtx); -void func_80BA3DBC(EnToto* this, GlobalContext* globalCtx); -void func_80BA3BFC(EnToto* this, GlobalContext* globalCtx); -void func_80BA3CC4(EnToto* this, GlobalContext* globalCtx); -void func_80BA3D38(EnToto* this, GlobalContext* globalCtx); -s32 func_80BA3EC0(EnToto* this, GlobalContext* globalCtx); -s32 func_80BA3ED4(EnToto* this, GlobalContext* globalCtx); -s32 func_80BA3EE8(EnToto* this, GlobalContext* globalCtx); -s32 func_80BA3F2C(EnToto* this, GlobalContext* globalCtx); -s32 func_80BA3FB0(EnToto* this, GlobalContext* globalCtx); -s32 func_80BA3FCC(EnToto* this, GlobalContext* globalCtx); -s32 func_80BA402C(EnToto* this, GlobalContext* globalCtx); -s32 func_80BA407C(EnToto* this, GlobalContext* globalCtx); -s32 func_80BA40D4(EnToto* this, GlobalContext* globalCtx); -s32 func_80BA4128(EnToto* this, GlobalContext* globalCtx); -s32 func_80BA415C(EnToto* this, GlobalContext* globalCtx); -s32 func_80BA4204(EnToto* this, GlobalContext* globalCtx); -s32 func_80BA42BC(EnToto* this, GlobalContext* globalCtx); -s32 func_80BA43F4(EnToto* this, GlobalContext* globalCtx); -s32 func_80BA445C(EnToto* this, GlobalContext* globalCtx); -s32 func_80BA44A0(EnToto* this, GlobalContext* globalCtx); -s32 func_80BA4530(EnToto* this, GlobalContext* globalCtx); -s32 func_80BA46D8(EnToto* this, GlobalContext* globalCtx); -s32 func_80BA4740(EnToto* this, GlobalContext* globalCtx); -s32 func_80BA47E0(EnToto* this, GlobalContext* globalCtx); -s32 func_80BA49A4(EnToto* this, GlobalContext* globalCtx); -s32 func_80BA4A00(EnToto* this, GlobalContext* globalCtx); -s32 func_80BA4B24(EnToto* this, GlobalContext* globalCtx); -s32 func_80BA4C0C(EnToto* this, GlobalContext* globalCtx); -s32 func_80BA4C44(EnToto* this, GlobalContext* globalCtx); +void func_80BA3930(EnToto* this, PlayState* play); +void func_80BA39C8(EnToto* this, PlayState* play); +void func_80BA3DBC(EnToto* this, PlayState* play); +void func_80BA3BFC(EnToto* this, PlayState* play); +void func_80BA3CC4(EnToto* this, PlayState* play); +void func_80BA3D38(EnToto* this, PlayState* play); +s32 func_80BA3EC0(EnToto* this, PlayState* play); +s32 func_80BA3ED4(EnToto* this, PlayState* play); +s32 func_80BA3EE8(EnToto* this, PlayState* play); +s32 func_80BA3F2C(EnToto* this, PlayState* play); +s32 func_80BA3FB0(EnToto* this, PlayState* play); +s32 func_80BA3FCC(EnToto* this, PlayState* play); +s32 func_80BA402C(EnToto* this, PlayState* play); +s32 func_80BA407C(EnToto* this, PlayState* play); +s32 func_80BA40D4(EnToto* this, PlayState* play); +s32 func_80BA4128(EnToto* this, PlayState* play); +s32 func_80BA415C(EnToto* this, PlayState* play); +s32 func_80BA4204(EnToto* this, PlayState* play); +s32 func_80BA42BC(EnToto* this, PlayState* play); +s32 func_80BA43F4(EnToto* this, PlayState* play); +s32 func_80BA445C(EnToto* this, PlayState* play); +s32 func_80BA44A0(EnToto* this, PlayState* play); +s32 func_80BA4530(EnToto* this, PlayState* play); +s32 func_80BA46D8(EnToto* this, PlayState* play); +s32 func_80BA4740(EnToto* this, PlayState* play); +s32 func_80BA47E0(EnToto* this, PlayState* play); +s32 func_80BA49A4(EnToto* this, PlayState* play); +s32 func_80BA4A00(EnToto* this, PlayState* play); +s32 func_80BA4B24(EnToto* this, PlayState* play); +s32 func_80BA4C0C(EnToto* this, PlayState* play); +s32 func_80BA4C44(EnToto* this, PlayState* play); const ActorInit En_Toto_InitVars = { ACTOR_EN_TOTO, @@ -139,7 +139,7 @@ static EnTotoText D_80BA50BC[] = { }; static EnTotoUnkStruct2 D_80BA50DC[] = { - { 0x2B2F, 0x2B30, 0X2B31, { 0xFF96, 0x0016, 0xFE16 } }, + { 0x2B2F, 0x2B30, 0x2B31, { 0xFF96, 0x0016, 0xFE16 } }, { 0x2B26, 0x2B27, 0x2B28, { 0x0072, 0x0016, 0xFE3C } }, { 0x2B29, 0x2B2A, 0x2B2B, { 0xFF67, 0x0016, 0xFE6E } }, { 0x2B2C, 0x2B2D, 0x2B2E, { 0xFFF1, 0x0016, 0xFE74 } }, @@ -173,41 +173,41 @@ static EnTotoActionFunc D_80BA51B8[] = { func_80BA3DBC, }; -void func_80BA36C0(EnToto* this, GlobalContext* globalCtx, s32 index) { +void func_80BA36C0(EnToto* this, PlayState* play, s32 index) { this->unk2B7 = 0; this->actionFuncIndex = index; - D_80BA501C[this->actionFuncIndex](this, globalCtx); + D_80BA501C[this->actionFuncIndex](this, play); } -void EnToto_Init(Actor* thisx, GlobalContext* globalCtx) { +void EnToto_Init(Actor* thisx, PlayState* play) { EnToto* this = THIS; Actor_ProcessInitChain(&this->actor, sInitChain); - Collider_InitAndSetCylinder(globalCtx, &this->collider, &this->actor, &sCylinderInit); - if (globalCtx->sceneNum == SCENE_MILK_BAR && + Collider_InitAndSetCylinder(play, &this->collider, &this->actor, &sCylinderInit); + if (play->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 == SCENE_SONCHONOIE) ? &object_zm_Anim_003AA8 : &object_zm_Anim_00C880), + SkelAnime_InitFlex(play, &this->skelAnime, &object_zm_Skel_00A978, + ((play->sceneNum == SCENE_SONCHONOIE) ? &object_zm_Anim_003AA8 : &object_zm_Anim_00C880), this->jointTable, this->morphTable, 18); - func_80BA36C0(this, globalCtx, 0); + func_80BA36C0(this, play, 0); this->actor.shape.rot.x = 0; } -void EnToto_Destroy(Actor* thisx, GlobalContext* globalCtx) { +void EnToto_Destroy(Actor* thisx, PlayState* play) { EnToto* this = THIS; - Collider_DestroyCylinder(globalCtx, &this->collider); + Collider_DestroyCylinder(play, &this->collider); } -void func_80BA383C(EnToto* this, GlobalContext* globalCtx) { +void func_80BA383C(EnToto* this, PlayState* play) { if (SkelAnime_Update(&this->skelAnime) && this->actionFuncIndex == 1 && this->skelAnime.animation != &object_zm_Anim_000C80) { - if (globalCtx->msgCtx.currentTextId != 0x2A98 && globalCtx->msgCtx.currentTextId != 0x2A99) { + if (play->msgCtx.currentTextId != 0x2A98 && play->msgCtx.currentTextId != 0x2A99) { if (this->unk2B4 & 1 || Rand_ZeroOne() > 0.5f) { this->unk2B4 = (this->unk2B4 + 1) & 3; } @@ -217,10 +217,10 @@ void func_80BA383C(EnToto* this, GlobalContext* globalCtx) { func_800BBB74(this->unk260, 0x14, 0x50, 3); } -void func_80BA3930(EnToto* this, GlobalContext* globalCtx) { +void func_80BA3930(EnToto* this, PlayState* play) { AnimationHeader* animationHeader = &object_zm_Anim_00C880; - if (globalCtx->sceneNum == SCENE_SONCHONOIE) { + if (play->sceneNum == SCENE_SONCHONOIE) { animationHeader = &object_zm_Anim_003AA8; } Animation_MorphToLoop(&this->skelAnime, animationHeader, -4.0f); @@ -236,35 +236,35 @@ s32 func_80BA397C(EnToto* this, s16 arg1) { return 0; } -void func_80BA39C8(EnToto* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); +void func_80BA39C8(EnToto* this, PlayState* play) { + Player* player = GET_PLAYER(play); - func_80BA383C(this, globalCtx); - if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { - func_80BA36C0(this, globalCtx, 1); - if (globalCtx->sceneNum != SCENE_SONCHONOIE) { - Flags_SetSwitch(globalCtx, this->actor.params & 0x7F); + func_80BA383C(this, play); + if (Actor_ProcessTalkRequest(&this->actor, &play->state)) { + func_80BA36C0(this, play, 1); + if (play->sceneNum != SCENE_SONCHONOIE) { + Flags_SetSwitch(play, this->actor.params & 0x7F); } else if (player->transformation == PLAYER_FORM_DEKU) { - Flags_SetSwitch(globalCtx, this->actor.home.rot.x); + Flags_SetSwitch(play, this->actor.home.rot.x); } this->unk2B6 = 0; return; } //! @TODO: 0xED02 nor 0xED01 match CLOCK_TIME macro - if ((globalCtx->sceneNum == SCENE_MILK_BAR && + if ((play->sceneNum == SCENE_MILK_BAR && !(gSaveContext.save.time >= CLOCK_TIME(6, 0) && gSaveContext.save.time < 0xED02)) || - (globalCtx->sceneNum != SCENE_MILK_BAR && func_80BA397C(this, 0x2000))) { + (play->sceneNum != SCENE_MILK_BAR && func_80BA397C(this, 0x2000))) { if (this->unk2B6 != 0) { this->text = D_80BA5044; this->actor.flags |= ACTOR_FLAG_10000; - func_800B8500(&this->actor, globalCtx, 9999.9f, 9999.9f, EXCH_ITEM_NONE); + func_800B8500(&this->actor, play, 9999.9f, 9999.9f, PLAYER_AP_NONE); } else { this->actor.flags &= ~ACTOR_FLAG_10000; - func_800B8614(&this->actor, globalCtx, 50.0f); - if (globalCtx->sceneNum == SCENE_SONCHONOIE) { + func_800B8614(&this->actor, play, 50.0f); + if (play->sceneNum == SCENE_SONCHONOIE) { if (player->transformation == PLAYER_FORM_DEKU) { - if (!Flags_GetSwitch(globalCtx, this->actor.home.rot.x)) { + if (!Flags_GetSwitch(play, this->actor.home.rot.x)) { this->text = D_80BA5068; } else { this->text = D_80BA5074; @@ -274,7 +274,7 @@ void func_80BA39C8(EnToto* this, GlobalContext* globalCtx) { } } else if (ENTOTO_WEEK_EVENT_FLAGS) { this->text = D_80BA502C; - } else if (!Flags_GetSwitch(globalCtx, this->actor.params & 0x7F)) { + } else if (!Flags_GetSwitch(play, this->actor.params & 0x7F)) { this->text = D_80BA5034; } else { this->text = D_80BA5038; @@ -285,13 +285,13 @@ void func_80BA39C8(EnToto* this, GlobalContext* globalCtx) { } } -void func_80BA3BFC(EnToto* this, GlobalContext* globalCtx) { - if (globalCtx->sceneNum == SCENE_SONCHONOIE) { +void func_80BA3BFC(EnToto* this, PlayState* play) { + if (play->sceneNum == SCENE_SONCHONOIE) { Animation_MorphToPlayOnce(&this->skelAnime, &object_zm_Anim_000C80, -4.0f); this->unk2B4 = 0; } else { if (this->text->unk0 == 4) { - func_80151BB4(globalCtx, 9); + func_80151BB4(play, 9); } Animation_MorphToLoop(&this->skelAnime, &object_zm_Anim_00B3E0, -4.0f); } @@ -301,30 +301,30 @@ void func_80BA3C88(EnToto* this) { Math_SmoothStepToS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer, 4, 4000, 800); } -void func_80BA3CC4(EnToto* this, GlobalContext* globalCtx) { - func_80BA383C(this, globalCtx); +void func_80BA3CC4(EnToto* this, PlayState* play) { + func_80BA383C(this, play); func_80BA3C88(this); - if (Actor_TextboxIsClosing(&this->actor, globalCtx)) { - func_80BA36C0(this, globalCtx, this->text->unk1); + if (Actor_TextboxIsClosing(&this->actor, play)) { + func_80BA36C0(this, play, this->text->unk1); } else { - func_80BA4C44(this, globalCtx); + func_80BA4C44(this, play); } } -void func_80BA3D38(EnToto* this, GlobalContext* globalCtx) { +void func_80BA3D38(EnToto* this, PlayState* play) { this->cutscene = this->actor.cutscene; this->text = ENTOTO_WEEK_EVENT_FLAGS ? D_80BA50BC : D_80BA5088; - func_80BA4C0C(this, globalCtx); - globalCtx->actorCtx.unk5 |= 0x20; + func_80BA4C0C(this, play); + play->actorCtx.unk5 |= 0x20; this->unk260[0] = 0; } -void func_80BA3DBC(EnToto* this, GlobalContext* globalCtx) { +void func_80BA3DBC(EnToto* this, PlayState* play) { Player* player; - func_80BA383C(this, globalCtx); + func_80BA383C(this, play); if (this->unk2B7 == 0) { - if (!func_80BA4C44(this, globalCtx)) { + if (!func_80BA4C44(this, play)) { return; } if (this->text->unk1 != 0 && ENTOTO_WEEK_EVENT_FLAGS) { @@ -332,63 +332,63 @@ void func_80BA3DBC(EnToto* this, GlobalContext* globalCtx) { return; } } else { - player = GET_PLAYER(globalCtx); + player = GET_PLAYER(play); if (player->stateFlags1 & 0x400 && player->unk_AE7 != 0) { - func_80151BB4(globalCtx, 48); - func_80151BB4(globalCtx, 9); - func_80151BB4(globalCtx, 10); + func_80151BB4(play, 48); + func_80151BB4(play, 9); + func_80151BB4(play, 10); } else { return; } } - func_80BA36C0(this, globalCtx, 0); + func_80BA36C0(this, play, 0); ActorCutscene_Stop(this->cutscene); - globalCtx->actorCtx.unk5 &= ~0x20; + play->actorCtx.unk5 &= ~0x20; } -s32 func_80BA3EC0(EnToto* this, GlobalContext* globalCtx) { +s32 func_80BA3EC0(EnToto* this, PlayState* play) { return 1; } -s32 func_80BA3ED4(EnToto* this, GlobalContext* globalCtx) { +s32 func_80BA3ED4(EnToto* this, PlayState* play) { return 0; } -s32 func_80BA3EE8(EnToto* this, GlobalContext* globalCtx) { +s32 func_80BA3EE8(EnToto* this, PlayState* play) { if (this->text->unk1 == 2) { - func_800B7298(globalCtx, NULL, 7); + func_800B7298(play, NULL, 7); } return 0; } -s32 func_80BA3F2C(EnToto* this, GlobalContext* globalCtx) { +s32 func_80BA3F2C(EnToto* this, PlayState* play) { if (this->text->textId != 0) { - func_80151938(globalCtx, this->text->textId); + func_80151938(play, this->text->textId); } else { - func_801477B4(globalCtx); - func_80BA3EE8(this, globalCtx); + func_801477B4(play); + func_80BA3EE8(this, play); } if (this->text->unk0 == 4) { - func_80151BB4(globalCtx, 9); + func_80151BB4(play, 9); } return 0; } -s32 func_80BA3FB0(EnToto* this, GlobalContext* globalCtx) { +s32 func_80BA3FB0(EnToto* this, PlayState* play) { this->unk2B1 = this->text->unk1; return 0; } -s32 func_80BA3FCC(EnToto* this, GlobalContext* globalCtx) { +s32 func_80BA3FCC(EnToto* this, PlayState* play) { if (DECR(this->unk2B1) == 0) { - Message_StartTextbox(globalCtx, this->text->textId, NULL); + Message_StartTextbox(play, this->text->textId, NULL); return 1; } return 0; } -s32 func_80BA402C(EnToto* this, GlobalContext* globalCtx) { +s32 func_80BA402C(EnToto* this, PlayState* play) { s16 prevCutscene = this->cutscene; this->cutscene = ActorCutscene_GetAdditionalCutscene(this->cutscene); @@ -397,9 +397,9 @@ s32 func_80BA402C(EnToto* this, GlobalContext* globalCtx) { return 0; } -s32 func_80BA407C(EnToto* this, GlobalContext* globalCtx) { +s32 func_80BA407C(EnToto* this, PlayState* play) { if (ActorCutscene_GetCanPlayNext(this->cutscene)) { - ActorCutscene_StartAndSetUnkLinkFields(this->cutscene, &GET_PLAYER(globalCtx)->actor); + ActorCutscene_StartAndSetUnkLinkFields(this->cutscene, &GET_PLAYER(play)->actor); return 1; } @@ -407,52 +407,52 @@ s32 func_80BA407C(EnToto* this, GlobalContext* globalCtx) { return 0; } -s32 func_80BA40D4(EnToto* this, GlobalContext* globalCtx) { - if (Message_GetState(&globalCtx->msgCtx) == 5 && Message_ShouldAdvance(globalCtx)) { +s32 func_80BA40D4(EnToto* this, PlayState* play) { + if ((Message_GetState(&play->msgCtx) == TEXT_STATE_5) && Message_ShouldAdvance(play)) { return 1; } return 0; } -s32 func_80BA4128(EnToto* this, GlobalContext* globalCtx) { - if (Message_GetState(&globalCtx->msgCtx) == 2) { +s32 func_80BA4128(EnToto* this, PlayState* play) { + if (Message_GetState(&play->msgCtx) == TEXT_STATE_CLOSING) { return 1; } return 0; } -s32 func_80BA415C(EnToto* this, GlobalContext* globalCtx) { - if (Message_GetState(&globalCtx->msgCtx) == 4 && Message_ShouldAdvance(globalCtx)) { - if (globalCtx->msgCtx.choiceIndex != 0) { +s32 func_80BA415C(EnToto* this, PlayState* play) { + if ((Message_GetState(&play->msgCtx) == TEXT_STATE_CHOICE) && Message_ShouldAdvance(play)) { + if (play->msgCtx.choiceIndex != 0) { func_8019F230(); } else { func_8019F208(); } - return (globalCtx->msgCtx.choiceIndex != 0 ? 0 : this->text->unk1) + 1; // Possible msg MACRO + return (play->msgCtx.choiceIndex != 0 ? 0 : this->text->unk1) + 1; // Possible msg MACRO } return 0; } -s32 func_80BA4204(EnToto* this, GlobalContext* globalCtx) { +s32 func_80BA4204(EnToto* this, PlayState* play) { EnTotoUnkStruct2* temp_v1_2; if (DECR(this->unk2B1) == 0) { if (!ENTOTO_WEEK_EVENT_FLAGS) { 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); + Message_StartTextbox(play, (this->text->unk0 == 6) ? temp_v1_2->unk0 : temp_v1_2->unk4, NULL); } return 1; } return 0; } -s32 func_80BA42BC(EnToto* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); +s32 func_80BA42BC(EnToto* this, PlayState* play) { + Player* player = GET_PLAYER(play); u32 phi_s0 = 0; Vec3s* end = &D_80BA510C[3]; - func_80BA3FB0(this, globalCtx); - func_800B7298(globalCtx, NULL, 6); + func_80BA3FB0(this, play); + func_800B7298(play, NULL, 6); if (player->actor.world.pos.z > -310.0f) { if ((player->actor.world.pos.x > -150.0f) || (player->actor.world.pos.z > -172.0f)) { phi_s0 = 3; @@ -464,29 +464,29 @@ s32 func_80BA42BC(EnToto* this, GlobalContext* globalCtx) { } } } - func_80122744(globalCtx, this->unk2BC, phi_s0, end - phi_s0); - this->spotlights = Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_DM_CHAR07, 0.0f, 0.0f, 0.0f, 0, 0, 0, 0xF02); + func_80122744(play, &this->unk_2BC, phi_s0, end - phi_s0); + this->spotlights = Actor_Spawn(&play->actorCtx, play, ACTOR_DM_CHAR07, 0.0f, 0.0f, 0.0f, 0, 0, 0, 0xF02); return 0; } -s32 func_80BA43F4(EnToto* this, GlobalContext* globalCtx) { +s32 func_80BA43F4(EnToto* this, PlayState* play) { func_80BA3C88(this); - if (func_80122760(globalCtx, this->unk2BC, 60.0f)) { - func_800B7298(globalCtx, NULL, 0x13); - return func_80BA4204(this, globalCtx); + if (func_80122760(play, &this->unk_2BC, 60.0f)) { + func_800B7298(play, NULL, 0x13); + return func_80BA4204(this, play); } return 0; } -s32 func_80BA445C(EnToto* this, GlobalContext* globalCtx) { - if (func_80BA4128(this, globalCtx)) { - func_800B7298(globalCtx, NULL, 6); +s32 func_80BA445C(EnToto* this, PlayState* play) { + if (func_80BA4128(this, play)) { + func_800B7298(play, NULL, 6); return 1; } return 0; } -s32 func_80BA44A0(EnToto* this, GlobalContext* globalCtx) { +s32 func_80BA44A0(EnToto* this, PlayState* play) { ActorCutscene_Stop(this->cutscene); this->unk2B1 = 0; return 0; @@ -502,8 +502,8 @@ s32 func_80BA44D4(EnTotoUnkStruct2* arg0, Player* player) { return 0; } -s32 func_80BA4530(EnToto* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); +s32 func_80BA4530(EnToto* this, PlayState* play) { + Player* player = GET_PLAYER(play); EnTotoUnkStruct2* temp_s0; s32 i; @@ -521,7 +521,7 @@ s32 func_80BA4530(EnToto* this, GlobalContext* globalCtx) { Math_Vec3s_ToVec3f(&player->actor.world.pos, &temp_s0->unk6); player->actor.shape.rot.y = 0; player->currentYaw = 0; - return func_80BA407C(this, globalCtx); + return func_80BA407C(this, play); } if (!ENTOTO_WEEK_EVENT_FLAGS) { for (i = 0; i < 4; i++) { @@ -529,8 +529,8 @@ s32 func_80BA4530(EnToto* this, GlobalContext* globalCtx) { if (this->unk2B1 < 10) { this->unk2B1++; if (this->unk2B1 >= 10) { - Message_StartTextbox(globalCtx, - D_80BA50DC[((void)0, gSaveContext.save.playerForm) - 1].unk2, NULL); + Message_StartTextbox(play, D_80BA50DC[((void)0, gSaveContext.save.playerForm) - 1].unk2, + NULL); } } return 0; @@ -542,14 +542,14 @@ s32 func_80BA4530(EnToto* this, GlobalContext* globalCtx) { return 0; } -s32 func_80BA46D8(EnToto* this, GlobalContext* globalCtx) { - func_800B7298(globalCtx, NULL, 0x44); - func_80152434(globalCtx, D_80BA5120[CUR_FORM]); +s32 func_80BA46D8(EnToto* this, PlayState* play) { + func_800B7298(play, NULL, 0x44); + func_80152434(play, D_80BA5120[CUR_FORM]); return 0; } -s32 func_80BA4740(EnToto* this, GlobalContext* globalCtx) { - if (globalCtx->msgCtx.ocarinaMode == 4) { +s32 func_80BA4740(EnToto* this, PlayState* play) { + if (play->msgCtx.ocarinaMode == 4) { if (gSaveContext.save.playerForm == PLAYER_FORM_HUMAN) { gSaveContext.save.weekEventReg[56] |= 0x10; } @@ -567,7 +567,7 @@ s32 func_80BA4740(EnToto* this, GlobalContext* globalCtx) { return 0; } -s32 func_80BA47E0(EnToto* this, GlobalContext* globalCtx) { +s32 func_80BA47E0(EnToto* this, PlayState* play) { Vec3f spawnPos; s32 i; @@ -587,30 +587,29 @@ s32 func_80BA47E0(EnToto* this, GlobalContext* globalCtx) { for (i = 0; i < 4; i++) { 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); + Actor_Spawn(&play->actorCtx, play, ACTOR_PLAYER, spawnPos.x, spawnPos.y, spawnPos.z, i + 2, 0, 0, -1); } } - func_80BA402C(this, globalCtx); + func_80BA402C(this, play); if (ENTOTO_WEEK_EVENT_FLAGS) { - func_80BA402C(this, globalCtx); + func_80BA402C(this, play); } return 0; } -s32 func_80BA49A4(EnToto* this, GlobalContext* globalCtx) { - func_800B7298(globalCtx, NULL, 0x44); +s32 func_80BA49A4(EnToto* this, PlayState* play) { + func_800B7298(play, NULL, 0x44); func_801A31EC(NA_BGM_BALLAD_OF_THE_WIND_FISH, 4, this->unk2B3 ^ 0xF); this->unk2B1 = 4; return 0; } -s32 func_80BA4A00(EnToto* this, GlobalContext* globalCtx) { +s32 func_80BA4A00(EnToto* this, PlayState* play) { Actor* actor; if (DECR(this->unk2B1) == 0) { if (!Audio_IsSequencePlaying(NA_BGM_BALLAD_OF_THE_WIND_FISH)) { - actor = &GET_PLAYER(globalCtx)->actor; + actor = &GET_PLAYER(play)->actor; actor = actor->next; while (actor != NULL) { Actor_MarkForDeath(actor); @@ -619,7 +618,7 @@ s32 func_80BA4A00(EnToto* this, GlobalContext* globalCtx) { if (this->spotlights != NULL) { Actor_MarkForDeath(this->spotlights); } - func_800B7298(globalCtx, NULL, 0x45); + func_800B7298(play, NULL, 0x45); if (this->unk2B3 == 0xF) { if (CURRENT_DAY == 1) { gSaveContext.save.weekEventReg[50] |= 1; @@ -627,7 +626,7 @@ s32 func_80BA4A00(EnToto* this, GlobalContext* globalCtx) { gSaveContext.save.weekEventReg[51] |= 0x80; } } else { - func_80BA402C(this, globalCtx); + func_80BA402C(this, play); } return 1; } @@ -635,22 +634,22 @@ s32 func_80BA4A00(EnToto* this, GlobalContext* globalCtx) { return 0; } -s32 func_80BA4B24(EnToto* this, GlobalContext* globalCtx) { +s32 func_80BA4B24(EnToto* this, PlayState* play) { Player* player; - if (func_80BA40D4(this, globalCtx)) { - player = GET_PLAYER(globalCtx); + if (func_80BA40D4(this, play)) { + player = GET_PLAYER(play); Animation_MorphToPlayOnce(&this->skelAnime, &object_zm_Anim_0028B8, -4.0f); if (player->transformation == PLAYER_FORM_ZORA) { - if (!Flags_GetSwitch(globalCtx, this->actor.params & 0x7F)) { - Flags_SetSwitch(globalCtx, this->actor.params & 0x7F); + if (!Flags_GetSwitch(play, this->actor.params & 0x7F)) { + Flags_SetSwitch(play, this->actor.params & 0x7F); return 1; } else { return 3; } } else { - if (!Flags_GetSwitch(globalCtx, (this->actor.params >> 7) & 0x7F)) { - Flags_SetSwitch(globalCtx, (this->actor.params >> 7) & 0x7F); + if (!Flags_GetSwitch(play, (this->actor.params >> 7) & 0x7F)) { + Flags_SetSwitch(play, (this->actor.params >> 7) & 0x7F); return 4; } else { return 7; @@ -660,23 +659,23 @@ s32 func_80BA4B24(EnToto* this, GlobalContext* globalCtx) { return 0; } -s32 func_80BA4C0C(EnToto* this, GlobalContext* globalCtx) { - return D_80BA512C[this->text->unk0](this, globalCtx); +s32 func_80BA4C0C(EnToto* this, PlayState* play) { + return D_80BA512C[this->text->unk0](this, play); } -s32 func_80BA4C44(EnToto* this, GlobalContext* globalCtx) { +s32 func_80BA4C44(EnToto* this, PlayState* play) { s32 ret; - ret = D_80BA5174[this->text->unk0](this, globalCtx); + ret = D_80BA5174[this->text->unk0](this, play); if (ret != 0) { this->text += ret; - return func_80BA4C0C(this, globalCtx); + return func_80BA4C0C(this, play); } return 0; } -void func_80BA4CB4(EnToto* this, GlobalContext* globalCtx) { - CsCmdActorAction* action = globalCtx->csCtx.actorActions[Cutscene_GetActorActionIndex(globalCtx, 525)]; +void func_80BA4CB4(EnToto* this, PlayState* play) { + CsCmdActorAction* action = play->csCtx.actorActions[Cutscene_GetActorActionIndex(play, 525)]; if (this->unk2B5 != action->action) { this->unk2B5 = action->action; @@ -687,8 +686,8 @@ void func_80BA4CB4(EnToto* this, GlobalContext* globalCtx) { Animation_PlayOnce(&this->skelAnime, this->unk2B5 == 1 ? &object_zm_Anim_0016A4 : &object_zm_Anim_0022C8); if (this->unk2B5 == 2 && this->unk2B3 != 0xF) { - func_80151BB4(globalCtx, 9); - func_80151BB4(globalCtx, 10); + func_80151BB4(play, 9); + func_80151BB4(play, 10); } } } @@ -699,40 +698,40 @@ void func_80BA4CB4(EnToto* this, GlobalContext* globalCtx) { Animation_PlayLoop(&this->skelAnime, this->unk2B5 == 1 ? &object_zm_Anim_00C880 : &object_zm_Anim_001324); } } - if (this->unk2B5 == 4 && !Actor_HasParent(&this->actor, globalCtx)) { - Actor_PickUp(&this->actor, globalCtx, GI_MASK_CIRCUS_LEADER, 9999.9f, 9999.9f); + if (this->unk2B5 == 4 && !Actor_HasParent(&this->actor, play)) { + Actor_PickUp(&this->actor, play, GI_MASK_CIRCUS_LEADER, 9999.9f, 9999.9f); } } -void EnToto_Update(Actor* thisx, GlobalContext* globalCtx) { +void EnToto_Update(Actor* thisx, PlayState* play) { EnToto* this = THIS; s32 pad; - if (Cutscene_CheckActorAction(globalCtx, 0x20D)) { - func_80BA4CB4(this, globalCtx); + if (Cutscene_CheckActorAction(play, 0x20D)) { + func_80BA4CB4(this, play); } else { - D_80BA51B8[this->actionFuncIndex](this, globalCtx); + D_80BA51B8[this->actionFuncIndex](this, play); } - Collider_ResetCylinderAC(globalCtx, &this->collider.base); + Collider_ResetCylinderAC(play, &this->collider.base); Collider_UpdateCylinder(&this->actor, &this->collider); - CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); - CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + CollisionCheck_SetOC(play, &play->colChkCtx, &this->collider.base); + CollisionCheck_SetAC(play, &play->colChkCtx, &this->collider.base); Actor_SetFocus(&this->actor, 40.0f); } -void EnToto_Draw(Actor* thisx, GlobalContext* globalCtx) { +void EnToto_Draw(Actor* thisx, PlayState* play) { TexturePtr sp4C[] = { object_zm_Tex_008AE8, object_zm_Tex_00A068, object_zm_Tex_00A468 }; EnToto* this = THIS; s32 pad; - OPEN_DISPS(globalCtx->state.gfxCtx); + OPEN_DISPS(play->state.gfxCtx); - func_8012C28C(globalCtx->state.gfxCtx); + func_8012C28C(play->state.gfxCtx); gSPSegment(POLY_OPA_DISP++, 0x08, Lib_SegmentedToVirtual(sp4C[this->unk260[0]])); - Scene_SetRenderModeXlu(globalCtx, 0, 1); - SkelAnime_DrawFlexOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, - NULL, NULL, &this->actor); + Scene_SetRenderModeXlu(play, 0, 1); + SkelAnime_DrawFlexOpa(play, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, NULL, + NULL, &this->actor); - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->state.gfxCtx); } diff --git a/src/overlays/actors/ovl_En_Toto/z_en_toto.h b/src/overlays/actors/ovl_En_Toto/z_en_toto.h index cdfe3294e..94c80ef4a 100644 --- a/src/overlays/actors/ovl_En_Toto/z_en_toto.h +++ b/src/overlays/actors/ovl_En_Toto/z_en_toto.h @@ -5,8 +5,8 @@ struct EnToto; -typedef void (*EnTotoActionFunc)(struct EnToto*, GlobalContext*); -typedef s32 (*EnTotoUnkFunc)(struct EnToto*, GlobalContext*); +typedef void (*EnTotoActionFunc)(struct EnToto*, PlayState*); +typedef s32 (*EnTotoUnkFunc)(struct EnToto*, PlayState*); typedef struct EnTotoText { /* 0x0 */ u8 unk0; @@ -37,7 +37,7 @@ typedef struct EnToto { /* 0x2B6 */ u8 unk2B6; /* 0x2B7 */ u8 unk2B7; /* 0x2B8 */ EnTotoText* text; - /* 0x2BC */ char unk2BC[0x8]; // Some z_player_lib struct size 0x8 more info from func_80122744 and func_80122760 + /* 0x2BC */ struct_80122744_arg1 unk_2BC; /* 0x2C4 */ Actor* spotlights; /* 0x2C8 */ s32 pad2C8; } EnToto; // size = 0x2CC diff --git a/src/overlays/actors/ovl_En_Trt/z_en_trt.c b/src/overlays/actors/ovl_En_Trt/z_en_trt.c index dde803708..6402e5920 100644 --- a/src/overlays/actors/ovl_En_Trt/z_en_trt.c +++ b/src/overlays/actors/ovl_En_Trt/z_en_trt.c @@ -16,44 +16,44 @@ #define ENTRT_GIVEN_MUSHROOM (1 << 1) #define ENTRT_MET (1 << 2) -void EnTrt_Init(Actor* thisx, GlobalContext* globalCtx); -void EnTrt_Destroy(Actor* thisx, GlobalContext* globalCtx); -void EnTrt_Update(Actor* thisx, GlobalContext* globalCtx); -void EnTrt_Draw(Actor* thisx, GlobalContext* globalCtx); +void EnTrt_Init(Actor* thisx, PlayState* play); +void EnTrt_Destroy(Actor* thisx, PlayState* play); +void EnTrt_Update(Actor* thisx, PlayState* play); +void EnTrt_Draw(Actor* thisx, PlayState* play); -void EnTrt_GetCutscenes(EnTrt* this, GlobalContext* globalCtx); +void EnTrt_GetCutscenes(EnTrt* this, PlayState* play); void EnTrt_ResetItemPosition(EnTrt* this); -void EnTrt_UpdateHeadYawAndPitch(EnTrt* this, GlobalContext* globalCtx); +void EnTrt_UpdateHeadYawAndPitch(EnTrt* this, PlayState* play); s32 EnTrt_ReturnItemToShelf(EnTrt* this); -s32 EnTrt_FacingShopkeeperDialogResult(EnTrt* this, GlobalContext* globalCtx); +s32 EnTrt_FacingShopkeeperDialogResult(EnTrt* this, PlayState* play); s32 EnTrt_TakeItemOffShelf(EnTrt* this); -void EnTrt_BeginInteraction(EnTrt* this, GlobalContext* globalCtx); -void EnTrt_IdleSleeping(EnTrt* this, GlobalContext* globalCtx); -void EnTrt_IdleAwake(EnTrt* this, GlobalContext* globalCtx); -void EnTrt_Hello(EnTrt* this, GlobalContext* globalCtx); -void EnTrt_FaceShopkeeper(EnTrt* this, GlobalContext* globalCtx); -void EnTrt_SetupEndInteraction(EnTrt* this, GlobalContext* globalCtx); -void EnTrt_StartShopping(GlobalContext* globalCtx, EnTrt* this); -void EnTrt_GiveRedPotionForKoume(EnTrt* this, GlobalContext* globalCtx); -void EnTrt_EndConversation(EnTrt* this, GlobalContext* globalCtx); -void EnTrt_TryToGiveRedPotion(EnTrt* this, GlobalContext* globalCtx); -void EnTrt_Surprised(EnTrt* this, GlobalContext* globalCtx); -void EnTrt_LookToShelf(EnTrt* this, GlobalContext* globalCtx); -void EnTrt_GivenRedPotionForKoume(EnTrt* this, GlobalContext* globalCtx); -void EnTrt_TryToGiveRedPotionAfterSurprised(EnTrt* this, GlobalContext* globalCtx); -void EnTrt_BrowseShelf(EnTrt* this, GlobalContext* globalCtx); -void EnTrt_SetupTalkToShopkeeper(GlobalContext* globalCtx, EnTrt* this); -void EnTrt_ContinueShopping(EnTrt* this, GlobalContext* globalCtx); -void EnTrt_ItemGiven(EnTrt* this, GlobalContext* globalCtx); -void EnTrt_SelectItem(EnTrt* this, GlobalContext* globalCtx); -void EnTrt_SetupLookToShopkeeperFromShelf(GlobalContext* globalCtx, EnTrt* this); -void EnTrt_LookToShopkeeperFromShelf(EnTrt* this, GlobalContext* globalCtx); -void EnTrt_PayForMushroom(EnTrt* this, GlobalContext* globalCtx); -void EnTrt_CanBuy(EnTrt* this, GlobalContext* globalCtx); -void EnTrt_CannotBuy(EnTrt* this, GlobalContext* globalCtx); -void EnTrt_BuyItemWithFanfare(EnTrt* this, GlobalContext* globalCtx); -void EnTrt_SetupItemGiven(EnTrt* this, GlobalContext* globalCtx); +void EnTrt_BeginInteraction(EnTrt* this, PlayState* play); +void EnTrt_IdleSleeping(EnTrt* this, PlayState* play); +void EnTrt_IdleAwake(EnTrt* this, PlayState* play); +void EnTrt_Hello(EnTrt* this, PlayState* play); +void EnTrt_FaceShopkeeper(EnTrt* this, PlayState* play); +void EnTrt_SetupEndInteraction(EnTrt* this, PlayState* play); +void EnTrt_StartShopping(PlayState* play, EnTrt* this); +void EnTrt_GiveRedPotionForKoume(EnTrt* this, PlayState* play); +void EnTrt_EndConversation(EnTrt* this, PlayState* play); +void EnTrt_TryToGiveRedPotion(EnTrt* this, PlayState* play); +void EnTrt_Surprised(EnTrt* this, PlayState* play); +void EnTrt_LookToShelf(EnTrt* this, PlayState* play); +void EnTrt_GivenRedPotionForKoume(EnTrt* this, PlayState* play); +void EnTrt_TryToGiveRedPotionAfterSurprised(EnTrt* this, PlayState* play); +void EnTrt_BrowseShelf(EnTrt* this, PlayState* play); +void EnTrt_SetupTalkToShopkeeper(PlayState* play, EnTrt* this); +void EnTrt_ContinueShopping(EnTrt* this, PlayState* play); +void EnTrt_ItemGiven(EnTrt* this, PlayState* play); +void EnTrt_SelectItem(EnTrt* this, PlayState* play); +void EnTrt_SetupLookToShopkeeperFromShelf(PlayState* play, EnTrt* this); +void EnTrt_LookToShopkeeperFromShelf(EnTrt* this, PlayState* play); +void EnTrt_PayForMushroom(EnTrt* this, PlayState* play); +void EnTrt_CanBuy(EnTrt* this, PlayState* play); +void EnTrt_CannotBuy(EnTrt* this, PlayState* play); +void EnTrt_BuyItemWithFanfare(EnTrt* this, PlayState* play); +void EnTrt_SetupItemGiven(EnTrt* this, PlayState* play); void EnTrt_EyesClosed(EnTrt* this); void EnTrt_OpenThenCloseEyes(EnTrt* this); @@ -64,7 +64,7 @@ void EnTrt_Blink(EnTrt* this); void EnTrt_OpenEyes2(EnTrt* this); void EnTrt_NodOff(EnTrt* this); -static AnimationInfoS sAnimations[] = { +static AnimationInfoS sAnimationInfo[] = { { &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 }, @@ -97,31 +97,31 @@ static ShopItem sShop[] = { { SI_POTION_BLUE, { -12, 32, -36 } }, }; -void EnTrt_ChangeAnim(SkelAnime* skelAnime, AnimationInfoS* animations, s32 idx) { +void EnTrt_ChangeAnim(SkelAnime* skelAnime, AnimationInfoS* animationInfo, s32 animIndex) { f32 frameCount; - animations += idx; - if (animations->frameCount < 0) { - frameCount = Animation_GetLastFrame(animations->animation); + animationInfo += animIndex; + if (animationInfo->frameCount < 0) { + frameCount = Animation_GetLastFrame(animationInfo->animation); } else { - frameCount = animations->frameCount; + frameCount = animationInfo->frameCount; } - Animation_Change(skelAnime, animations->animation, animations->playSpeed, animations->startFrame, frameCount, - animations->mode, animations->morphFrames); + Animation_Change(skelAnime, animationInfo->animation, animationInfo->playSpeed, animationInfo->startFrame, + frameCount, animationInfo->mode, animationInfo->morphFrames); } -s32 EnTrt_TestItemSelected(GlobalContext* globalCtx) { - MessageContext* msgCtx = &globalCtx->msgCtx; +s32 EnTrt_TestItemSelected(PlayState* play) { + MessageContext* msgCtx = &play->msgCtx; if (msgCtx->unk12020 == 0x10 || msgCtx->unk12020 == 0x11) { - return CHECK_BTN_ALL(CONTROLLER1(globalCtx)->press.button, BTN_A); + return CHECK_BTN_ALL(CONTROLLER1(&play->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(&play->state)->press.button, BTN_A) || + CHECK_BTN_ALL(CONTROLLER1(&play->state)->press.button, BTN_B) || + CHECK_BTN_ALL(CONTROLLER1(&play->state)->press.button, BTN_CUP); } -void EnTrt_SpawnShopItems(EnTrt* this, GlobalContext* globalCtx, ShopItem* shopItem) { +void EnTrt_SpawnShopItems(EnTrt* this, PlayState* play, ShopItem* shopItem) { s32 i; for (i = 0; i < ARRAY_COUNT(this->items); i++, shopItem++) { @@ -131,25 +131,25 @@ void EnTrt_SpawnShopItems(EnTrt* this, GlobalContext* globalCtx, ShopItem* shopI this->items[i] = NULL; } else { this->items[i] = - (EnGirlA*)Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_GIRLA, shopItem->spawnPos.x, - shopItem->spawnPos.y, shopItem->spawnPos.z, 0, 0, 0, shopItem->shopItemId); + (EnGirlA*)Actor_Spawn(&play->actorCtx, play, ACTOR_EN_GIRLA, shopItem->spawnPos.x, shopItem->spawnPos.y, + shopItem->spawnPos.z, 0, 0, 0, shopItem->shopItemId); } } } -void EnTrt_UpdateCollider(EnTrt* this, GlobalContext* globalCtx) { +void EnTrt_UpdateCollider(EnTrt* this, PlayState* play) { Collider_UpdateCylinder(&this->actor, &this->collider); - CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); - CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + CollisionCheck_SetAC(play, &play->colChkCtx, &this->collider.base); + CollisionCheck_SetOC(play, &play->colChkCtx, &this->collider.base); } -void EnTrt_UpdateCursorPos(GlobalContext* globalCtx, EnTrt* this) { +void EnTrt_UpdateCursorPos(PlayState* play, EnTrt* this) { s16 x; s16 y; f32 xOffset = 0.0f; f32 yOffset = 17.0f; - Actor_GetScreenPos(globalCtx, &this->items[this->cursorIdx]->actor, &x, &y); + Actor_GetScreenPos(play, &this->items[this->cursorIdx]->actor, &x, &y); this->cursorPos.x = x + xOffset; this->cursorPos.y = y + yOffset; this->cursorPos.z = 1.2f; @@ -196,23 +196,23 @@ u16 EnTrt_GetItemChoiceTextId(EnTrt* this) { return item->choiceTextId; } -void EnTrt_EndInteraction(GlobalContext* globalCtx, EnTrt* this) { - Player* player = GET_PLAYER(globalCtx); +void EnTrt_EndInteraction(PlayState* play, EnTrt* this) { + Player* player = GET_PLAYER(play); if (this->cutsceneState == ENTRT_CUTSCENESTATE_PLAYING) { ActorCutscene_Stop(this->cutscene); this->cutsceneState = ENTRT_CUTSCENESTATE_STOPPED; } - Actor_ProcessTalkRequest(&this->actor, &globalCtx->state); - globalCtx->msgCtx.msgMode = 0x43; - globalCtx->msgCtx.unk12023 = 4; + Actor_ProcessTalkRequest(&this->actor, &play->state); + play->msgCtx.msgMode = 0x43; + play->msgCtx.stateTimer = 4; Interface_ChangeAlpha(50); this->drawCursor = 0; this->stickLeftPrompt.isEnabled = false; this->stickRightPrompt.isEnabled = false; player->stateFlags2 &= ~0x20000000; - globalCtx->interfaceCtx.unk_222 = 0; - globalCtx->interfaceCtx.unk_224 = 0; + play->interfaceCtx.unk_222 = 0; + play->interfaceCtx.unk_224 = 0; this->textId = 0x834; this->timer = 80; this->flags |= ENTRT_FULLY_AWAKE; @@ -222,43 +222,43 @@ void EnTrt_EndInteraction(GlobalContext* globalCtx, EnTrt* this) { this->blinkFunc = EnTrt_NodOff; } -s32 EnTrt_TestEndInteraction(EnTrt* this, GlobalContext* globalCtx, Input* input) { +s32 EnTrt_TestEndInteraction(EnTrt* this, PlayState* play, Input* input) { if (CHECK_BTN_ALL(input->press.button, BTN_B)) { - EnTrt_EndInteraction(globalCtx, this); + EnTrt_EndInteraction(play, this); return true; } return false; } -s32 EnTrt_TestCancelOption(EnTrt* this, GlobalContext* globalCtx, Input* input) { +s32 EnTrt_TestCancelOption(EnTrt* this, PlayState* play, Input* input) { if (CHECK_BTN_ALL(input->press.button, BTN_B)) { - this->actionFunc = this->tmpActionFunc; - func_80151938(globalCtx, EnTrt_GetItemTextId(this)); + this->actionFunc = this->prevActionFunc; + func_80151938(play, EnTrt_GetItemTextId(this)); return true; } return false; } -void EnTrt_SetupStartShopping(GlobalContext* globalCtx, EnTrt* this, u8 skipHello) { - func_8011552C(globalCtx, 0x10); +void EnTrt_SetupStartShopping(PlayState* play, EnTrt* this, u8 skipHello) { + func_8011552C(play, 0x10); if (!skipHello) { this->actionFunc = EnTrt_Hello; } else { - EnTrt_StartShopping(globalCtx, this); + EnTrt_StartShopping(play, this); } } -void EnTrt_StartShopping(GlobalContext* globalCtx, EnTrt* this) { - func_80151938(globalCtx, 0x83E); - func_8011552C(globalCtx, 6); +void EnTrt_StartShopping(PlayState* play, EnTrt* this) { + func_80151938(play, 0x83E); + func_8011552C(play, 6); this->stickLeftPrompt.isEnabled = false; this->stickRightPrompt.isEnabled = true; this->actionFunc = EnTrt_FaceShopkeeper; } -void EnTrt_UpdateJoystickInputState(GlobalContext* globalCtx, EnTrt* this) { - s8 stickX = CONTROLLER1(globalCtx)->rel.stick_x; - s8 stickY = CONTROLLER1(globalCtx)->rel.stick_y; +void EnTrt_UpdateJoystickInputState(PlayState* play, EnTrt* this) { + s8 stickX = CONTROLLER1(&play->state)->rel.stick_x; + s8 stickY = CONTROLLER1(&play->state)->rel.stick_y; if (this->stickAccumX == 0) { if (stickX > 30 || stickX < -30) { @@ -301,8 +301,8 @@ u8 EnTrt_SetCursorIndexFromNeutral(EnTrt* this, u8 shelfOffset) { return CURSOR_INVALID; } -void EnTrt_Hello(EnTrt* this, GlobalContext* globalCtx) { - u8 talkState = Message_GetState(&globalCtx->msgCtx); +void EnTrt_Hello(EnTrt* this, PlayState* play) { + u8 talkState = Message_GetState(&play->msgCtx); if (this->cutsceneState == ENTRT_CUTSCENESTATE_WAITING) { if (ActorCutscene_GetCanPlayNext(this->cutscene)) { @@ -312,17 +312,17 @@ void EnTrt_Hello(EnTrt* this, GlobalContext* globalCtx) { ActorCutscene_SetIntentToPlay(this->cutscene); } } - if (talkState == 5 && Message_ShouldAdvance(globalCtx)) { + if ((talkState == TEXT_STATE_5) && Message_ShouldAdvance(play)) { play_sound(NA_SE_SY_MESSAGE_PASS); - if (!EnTrt_TestEndInteraction(this, globalCtx, CONTROLLER1(globalCtx))) { - EnTrt_StartShopping(globalCtx, this); + if (!EnTrt_TestEndInteraction(this, play, CONTROLLER1(&play->state))) { + EnTrt_StartShopping(play, this); } } } -void EnTrt_GetMushroom(EnTrt* this, GlobalContext* globalCtx) { - u8 talkState = Message_GetState(&globalCtx->msgCtx); - Player* player = GET_PLAYER(globalCtx); +void EnTrt_GetMushroom(EnTrt* this, PlayState* play) { + u8 talkState = Message_GetState(&play->msgCtx); + Player* player = GET_PLAYER(play); this->tmpGetMushroomCutscene = this->getMushroomCutscene; if (this->cutsceneState != ENTRT_CUTSCENESTATE_PLAYING_SPECIAL) { @@ -330,86 +330,86 @@ void EnTrt_GetMushroom(EnTrt* this, GlobalContext* globalCtx) { if (this->cutsceneState == ENTRT_CUTSCENESTATE_PLAYING_SPECIAL) { player->stateFlags2 &= ~0x20000000; } - } else if (talkState == 5 && Message_ShouldAdvance(globalCtx)) { + } else if ((talkState == TEXT_STATE_5) && Message_ShouldAdvance(play)) { switch (this->textId) { case 0x883: this->textId = 0x884; - Message_StartTextbox(globalCtx, this->textId, &this->actor); + Message_StartTextbox(play, this->textId, &this->actor); gSaveContext.save.weekEventReg[53] |= 8; - func_80123D50(globalCtx, GET_PLAYER(globalCtx), ITEM_BOTTLE, PLAYER_AP_BOTTLE); + func_80123D50(play, GET_PLAYER(play), ITEM_BOTTLE, PLAYER_AP_BOTTLE); break; case 0x888: this->textId = 0x889; - Message_StartTextbox(globalCtx, this->textId, &this->actor); + Message_StartTextbox(play, this->textId, &this->actor); break; case 0x889: if (this->cutsceneState == ENTRT_CUTSCENESTATE_PLAYING_SPECIAL) { ActorCutscene_Stop(this->cutscene); this->cutsceneState = ENTRT_CUTSCENESTATE_STOPPED; } - globalCtx->msgCtx.msgMode = 0x43; - globalCtx->msgCtx.unk12023 = 4; + play->msgCtx.msgMode = 0x43; + play->msgCtx.stateTimer = 4; this->actionFunc = EnTrt_PayForMushroom; break; default: this->cutsceneState = ENTRT_CUTSCENESTATE_PLAYING; - EnTrt_EndInteraction(globalCtx, this); + EnTrt_EndInteraction(play, this); break; } } } -void EnTrt_PayForMushroom(EnTrt* this, GlobalContext* globalCtx) { - if (Actor_HasParent(&this->actor, globalCtx)) { +void EnTrt_PayForMushroom(EnTrt* this, PlayState* play) { + if (Actor_HasParent(&this->actor, play)) { this->actor.parent = NULL; - func_80123D50(globalCtx, GET_PLAYER(globalCtx), ITEM_BOTTLE, PLAYER_AP_BOTTLE); + func_80123D50(play, GET_PLAYER(play), ITEM_BOTTLE, PLAYER_AP_BOTTLE); this->actionFunc = EnTrt_SetupItemGiven; } else { - Actor_PickUp(&this->actor, globalCtx, GI_RUPEE_RED, 300.0f, 300.0f); + Actor_PickUp(&this->actor, play, GI_RUPEE_RED, 300.0f, 300.0f); } } -void EnTrt_Goodbye(EnTrt* this, GlobalContext* globalCtx) { - if (Message_GetState(&globalCtx->msgCtx) == 5 && Message_ShouldAdvance(globalCtx)) { +void EnTrt_Goodbye(EnTrt* this, PlayState* play) { + if ((Message_GetState(&play->msgCtx) == TEXT_STATE_5) && Message_ShouldAdvance(play)) { switch (this->textId) { case 0x886: this->textId = 0x887; - func_80151938(globalCtx, this->textId); + func_80151938(play, this->textId); break; case 0x887: case 0x88B: - EnTrt_EndInteraction(globalCtx, this); + EnTrt_EndInteraction(play, this); break; } } } -void EnTrt_SetupTryToGiveRedPotion(EnTrt* this, GlobalContext* globalCtx) { - if (Message_GetState(&globalCtx->msgCtx) == 5 && Message_ShouldAdvance(globalCtx)) { +void EnTrt_SetupTryToGiveRedPotion(EnTrt* this, PlayState* play) { + if ((Message_GetState(&play->msgCtx) == TEXT_STATE_5) && Message_ShouldAdvance(play)) { if (this->textId == 0x88F) { - if (Interface_HasEmptyBottle() || !(gSaveContext.save.weekEventReg[12] & 0x10)) { + if (Inventory_HasEmptyBottle() || !(gSaveContext.save.weekEventReg[12] & 0x10)) { if (this->cutsceneState == ENTRT_CUTSCENESTATE_PLAYING) { ActorCutscene_Stop(this->cutscene); this->cutsceneState = ENTRT_CUTSCENESTATE_STOPPED; } - globalCtx->msgCtx.msgMode = 0x43; - globalCtx->msgCtx.unk12023 = 4; + play->msgCtx.msgMode = 0x43; + play->msgCtx.stateTimer = 4; this->actionFunc = EnTrt_GiveRedPotionForKoume; } else { - this->tmpTextId = this->textId; + this->prevTextId = this->textId; this->textId = 0x88E; gSaveContext.save.weekEventReg[85] |= 8; - Message_StartTextbox(globalCtx, this->textId, &this->actor); + Message_StartTextbox(play, this->textId, &this->actor); this->actionFunc = EnTrt_EndConversation; } } else { if (gSaveContext.save.weekEventReg[12] & 8) { this->textId = 0x83D; - EnTrt_SetupStartShopping(globalCtx, this, 0); + EnTrt_SetupStartShopping(play, this, 0); } else if (gSaveContext.save.weekEventReg[84] & 0x40) { this->textId = 0x83B; - if (Interface_HasItemInBottle(ITEM_POTION_RED)) { - EnTrt_SetupStartShopping(globalCtx, this, false); + if (Inventory_HasItemInBottle(ITEM_POTION_RED)) { + EnTrt_SetupStartShopping(play, this, false); } else { this->actionFunc = EnTrt_TryToGiveRedPotion; } @@ -421,17 +421,17 @@ void EnTrt_SetupTryToGiveRedPotion(EnTrt* this, GlobalContext* globalCtx) { return; } else if (gSaveContext.save.weekEventReg[17] & 1) { this->textId = 0x835; - EnTrt_SetupStartShopping(globalCtx, this, false); + EnTrt_SetupStartShopping(play, this, false); } - Message_StartTextbox(globalCtx, this->textId, &this->actor); + Message_StartTextbox(play, this->textId, &this->actor); } } } -void EnTrt_GiveRedPotionForKoume(EnTrt* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); +void EnTrt_GiveRedPotionForKoume(EnTrt* this, PlayState* play) { + Player* player = GET_PLAYER(play); - if (Actor_HasParent(&this->actor, globalCtx)) { + if (Actor_HasParent(&this->actor, play)) { this->actor.parent = NULL; if (!(gSaveContext.save.weekEventReg[12] & 0x10)) { gSaveContext.save.weekEventReg[12] |= 0x10; @@ -440,17 +440,17 @@ void EnTrt_GiveRedPotionForKoume(EnTrt* this, GlobalContext* globalCtx) { player->stateFlags2 &= ~0x20000000; this->actionFunc = EnTrt_GivenRedPotionForKoume; } else if (gSaveContext.save.weekEventReg[12] & 0x10) { - Actor_PickUp(&this->actor, globalCtx, GI_POTION_RED, 300.0f, 300.0f); + Actor_PickUp(&this->actor, play, GI_POTION_RED, 300.0f, 300.0f); } else { - Actor_PickUp(&this->actor, globalCtx, GI_BOTTLE_POTION_RED, 300.0f, 300.0f); + Actor_PickUp(&this->actor, play, GI_POTION_RED_BOTTLE, 300.0f, 300.0f); } } -void EnTrt_GivenRedPotionForKoume(EnTrt* this, GlobalContext* globalCtx) { +void EnTrt_GivenRedPotionForKoume(EnTrt* this, PlayState* play) { //! @bug: player is set to NULL not PLAYER Player* player = NULL; - if (Message_GetState(&globalCtx->msgCtx) == 6 && Message_ShouldAdvance(globalCtx)) { + if ((Message_GetState(&play->msgCtx) == TEXT_STATE_DONE) && Message_ShouldAdvance(play)) { if (this->cutsceneState == ENTRT_CUTSCENESTATE_STOPPED) { if (ActorCutscene_GetCanPlayNext(this->cutscene)) { ActorCutscene_StartAndSetFlag(this->cutscene, &this->actor); @@ -466,41 +466,41 @@ void EnTrt_GivenRedPotionForKoume(EnTrt* this, GlobalContext* globalCtx) { ActorCutscene_SetIntentToPlay(this->cutscene); } } - func_800B85E0(&this->actor, globalCtx, 400.0f, EXCH_ITEM_MINUS1); + func_800B85E0(&this->actor, play, 400.0f, PLAYER_AP_MINUS1); this->actionFunc = EnTrt_ItemGiven; } } -void EnTrt_EndConversation(EnTrt* this, GlobalContext* globalCtx) { - u8 talkState = Message_GetState(&globalCtx->msgCtx); +void EnTrt_EndConversation(EnTrt* this, PlayState* play) { + u8 talkState = Message_GetState(&play->msgCtx); - if (talkState == 5) { - if (Message_ShouldAdvance(globalCtx)) { - EnTrt_EndInteraction(globalCtx, this); + if (talkState == TEXT_STATE_5) { + if (Message_ShouldAdvance(play)) { + EnTrt_EndInteraction(play, this); } - } else if (talkState == 6) { - if (Message_ShouldAdvance(globalCtx)) { - EnTrt_EndInteraction(globalCtx, this); + } else if (talkState == TEXT_STATE_DONE) { + if (Message_ShouldAdvance(play)) { + EnTrt_EndInteraction(play, this); } } } -s32 EnTrt_FacingShopkeeperDialogResult(EnTrt* this, GlobalContext* globalCtx) { - switch (globalCtx->msgCtx.choiceIndex) { +s32 EnTrt_FacingShopkeeperDialogResult(EnTrt* this, PlayState* play) { + switch (play->msgCtx.choiceIndex) { case 0: func_8019F208(); - EnTrt_SetupTalkToShopkeeper(globalCtx, this); + EnTrt_SetupTalkToShopkeeper(play, this); return true; case 1: func_8019F230(); - EnTrt_EndInteraction(globalCtx, this); + EnTrt_EndInteraction(play, this); return true; } return false; } -void EnTrt_FaceShopkeeper(EnTrt* this, GlobalContext* globalCtx) { - u8 talkState = Message_GetState(&globalCtx->msgCtx); +void EnTrt_FaceShopkeeper(EnTrt* this, PlayState* play) { + u8 talkState = Message_GetState(&play->msgCtx); u8 cursorIdx; if (this->cutsceneState == ENTRT_CUTSCENESTATE_WAITING) { @@ -518,16 +518,16 @@ void EnTrt_FaceShopkeeper(EnTrt* this, GlobalContext* globalCtx) { this->cutscene = this->lookForwardCutscene; ActorCutscene_SetIntentToPlay(this->cutscene); this->cutsceneState = ENTRT_CUTSCENESTATE_WAITING; - } else if (talkState == 4) { - func_8011552C(globalCtx, 6); - if (!EnTrt_TestEndInteraction(this, globalCtx, CONTROLLER1(globalCtx))) { - if ((!Message_ShouldAdvance(globalCtx) || !EnTrt_FacingShopkeeperDialogResult(this, globalCtx)) && + } else if (talkState == TEXT_STATE_CHOICE) { + func_8011552C(play, 6); + if (!EnTrt_TestEndInteraction(this, play, CONTROLLER1(&play->state))) { + if ((!Message_ShouldAdvance(play) || !EnTrt_FacingShopkeeperDialogResult(this, play)) && (this->stickAccumX > 0)) { cursorIdx = EnTrt_SetCursorIndexFromNeutral(this, 2); if (cursorIdx != CURSOR_INVALID) { this->cursorIdx = cursorIdx; this->actionFunc = EnTrt_LookToShelf; - func_8011552C(globalCtx, 6); + func_8011552C(play, 6); this->stickRightPrompt.isEnabled = false; play_sound(NA_SE_SY_CURSOR); } @@ -536,7 +536,7 @@ void EnTrt_FaceShopkeeper(EnTrt* this, GlobalContext* globalCtx) { } } -void EnTrt_LookToShelf(EnTrt* this, GlobalContext* globalCtx) { +void EnTrt_LookToShelf(EnTrt* this, PlayState* play) { if (this->cutsceneState == ENTRT_CUTSCENESTATE_PLAYING) { ActorCutscene_Stop(this->cutscene); this->cutsceneState = ENTRT_CUTSCENESTATE_STOPPED; @@ -552,23 +552,23 @@ void EnTrt_LookToShelf(EnTrt* this, GlobalContext* globalCtx) { if (ActorCutscene_GetCanPlayNext(this->cutscene)) { ActorCutscene_StartAndSetFlag(this->cutscene, &this->actor); this->cutsceneState = ENTRT_CUTSCENESTATE_PLAYING; - EnTrt_UpdateCursorPos(globalCtx, this); + EnTrt_UpdateCursorPos(play, this); this->actionFunc = EnTrt_BrowseShelf; - func_80151938(globalCtx, EnTrt_GetItemTextId(this)); + func_80151938(play, EnTrt_GetItemTextId(this)); } else { ActorCutscene_SetIntentToPlay(this->cutscene); } } } -void EnTrt_CursorLeftRight(GlobalContext* globalCtx, EnTrt* this) { +void EnTrt_CursorLeftRight(PlayState* play, EnTrt* this) { u8 curTemp = this->cursorIdx; if (this->stickAccumX < 0) { if (curTemp != 2) { curTemp++; } else { - EnTrt_SetupLookToShopkeeperFromShelf(globalCtx, this); + EnTrt_SetupLookToShopkeeperFromShelf(play, this); } if (this->items[curTemp] != NULL) { this->cursorIdx = curTemp; @@ -583,16 +583,16 @@ void EnTrt_CursorLeftRight(GlobalContext* globalCtx, EnTrt* this) { } } -s32 EnTrt_HasPlayerSelectedItem(GlobalContext* globalCtx, EnTrt* this, Input* input) { +s32 EnTrt_HasPlayerSelectedItem(PlayState* play, EnTrt* this, Input* input) { EnGirlA* item = this->items[this->cursorIdx]; - if (EnTrt_TestEndInteraction(this, globalCtx, input)) { + if (EnTrt_TestEndInteraction(this, play, input)) { return true; } - if (EnTrt_TestItemSelected(globalCtx)) { + if (EnTrt_TestItemSelected(play)) { if (item->actor.params != SI_POTION_BLUE || (this->flags & ENTRT_GIVEN_MUSHROOM)) { - this->tmpActionFunc = this->actionFunc; - func_80151938(globalCtx, EnTrt_GetItemChoiceTextId(this)); + this->prevActionFunc = this->actionFunc; + func_80151938(play, EnTrt_GetItemChoiceTextId(this)); play_sound(NA_SE_SY_DECIDE); this->stickLeftPrompt.isEnabled = false; this->stickRightPrompt.isEnabled = false; @@ -606,8 +606,8 @@ s32 EnTrt_HasPlayerSelectedItem(GlobalContext* globalCtx, EnTrt* this, Input* in return false; } -void EnTrt_BrowseShelf(EnTrt* this, GlobalContext* globalCtx) { - u8 talkState = Message_GetState(&globalCtx->msgCtx); +void EnTrt_BrowseShelf(EnTrt* this, PlayState* play) { + u8 talkState = Message_GetState(&play->msgCtx); s32 pad; u8 prevCursorIdx = this->cursorIdx; u8 cursorIdx; @@ -619,13 +619,13 @@ void EnTrt_BrowseShelf(EnTrt* this, GlobalContext* globalCtx) { } else { this->drawCursor = 0xFF; this->stickLeftPrompt.isEnabled = true; - EnTrt_UpdateCursorPos(globalCtx, this); - if (talkState == 5) { - func_8011552C(globalCtx, 6); - if (!EnTrt_HasPlayerSelectedItem(globalCtx, this, CONTROLLER1(globalCtx))) { - EnTrt_CursorLeftRight(globalCtx, this); + EnTrt_UpdateCursorPos(play, this); + if (talkState == TEXT_STATE_5) { + func_8011552C(play, 6); + if (!EnTrt_HasPlayerSelectedItem(play, this, CONTROLLER1(&play->state))) { + EnTrt_CursorLeftRight(play, this); if (this->cursorIdx != prevCursorIdx) { - func_80151938(globalCtx, EnTrt_GetItemTextId(this)); + func_80151938(play, EnTrt_GetItemTextId(this)); play_sound(NA_SE_SY_CURSOR); } } @@ -633,33 +633,33 @@ void EnTrt_BrowseShelf(EnTrt* this, GlobalContext* globalCtx) { } } -void EnTrt_SetupBuyItemWithFanfare(GlobalContext* globalCtx, EnTrt* this) { - Player* player = GET_PLAYER(globalCtx); +void EnTrt_SetupBuyItemWithFanfare(PlayState* play, EnTrt* this) { + Player* player = GET_PLAYER(play); - Actor_PickUp(&this->actor, globalCtx, this->items[this->cursorIdx]->getItemId, 300.0f, 300.0f); - globalCtx->msgCtx.msgMode = 0x43; - globalCtx->msgCtx.unk12023 = 4; + Actor_PickUp(&this->actor, play, this->items[this->cursorIdx]->getItemId, 300.0f, 300.0f); + play->msgCtx.msgMode = 0x43; + play->msgCtx.stateTimer = 4; player->stateFlags2 &= ~0x20000000; Interface_ChangeAlpha(50); this->drawCursor = 0; this->actionFunc = EnTrt_BuyItemWithFanfare; } -void EnTrt_SetupCannotBuy(GlobalContext* globalCtx, EnTrt* this, u16 textId) { - func_80151938(globalCtx, textId); +void EnTrt_SetupCannotBuy(PlayState* play, EnTrt* this, u16 textId) { + func_80151938(play, textId); this->actionFunc = EnTrt_CannotBuy; } -void EnTrt_SetupCanBuy(GlobalContext* globalCtx, EnTrt* this, u16 textId) { - func_80151938(globalCtx, textId); +void EnTrt_SetupCanBuy(PlayState* play, EnTrt* this, u16 textId) { + func_80151938(play, textId); this->actionFunc = EnTrt_CanBuy; } -void EnTrt_HandleCanBuyItem(GlobalContext* globalCtx, EnTrt* this) { +void EnTrt_HandleCanBuyItem(PlayState* play, EnTrt* this) { EnGirlA* item = this->items[this->cursorIdx]; EnGirlA* item2; - switch (item->canBuyFunc(globalCtx, item)) { + switch (item->canBuyFunc(play, item)) { case CANBUY_RESULT_SUCCESS_1: if (this->cutsceneState == ENTRT_CUTSCENESTATE_PLAYING) { ActorCutscene_Stop(this->cutscene); @@ -667,79 +667,79 @@ void EnTrt_HandleCanBuyItem(GlobalContext* globalCtx, EnTrt* this) { } func_8019F208(); item2 = this->items[this->cursorIdx]; - item2->buyFanfareFunc(globalCtx, item2); - EnTrt_SetupBuyItemWithFanfare(globalCtx, this); + item2->buyFanfareFunc(play, item2); + EnTrt_SetupBuyItemWithFanfare(play, this); this->drawCursor = 0; this->shopItemSelectedTween = 0.0f; - item->boughtFunc(globalCtx, item); + item->boughtFunc(play, item); break; case CANBUY_RESULT_SUCCESS_2: func_8019F208(); - item->buyFunc(globalCtx, item); - EnTrt_SetupCanBuy(globalCtx, this, 0x848); + item->buyFunc(play, item); + EnTrt_SetupCanBuy(play, this, 0x848); this->drawCursor = 0; this->shopItemSelectedTween = 0.0f; - item->boughtFunc(globalCtx, item); + item->boughtFunc(play, item); break; case CANBUY_RESULT_NO_ROOM: play_sound(NA_SE_SY_ERROR); - EnTrt_SetupCannotBuy(globalCtx, this, 0x641); + EnTrt_SetupCannotBuy(play, this, 0x641); break; case CANBUY_RESULT_NEED_EMPTY_BOTTLE: play_sound(NA_SE_SY_ERROR); - EnTrt_SetupCannotBuy(globalCtx, this, 0x846); + EnTrt_SetupCannotBuy(play, this, 0x846); break; case CANBUY_RESULT_NEED_RUPEES: play_sound(NA_SE_SY_ERROR); - EnTrt_SetupCannotBuy(globalCtx, this, 0x847); + EnTrt_SetupCannotBuy(play, this, 0x847); break; case CANBUY_RESULT_CANNOT_GET_NOW: play_sound(NA_SE_SY_ERROR); - EnTrt_SetupCannotBuy(globalCtx, this, 0x643); + EnTrt_SetupCannotBuy(play, this, 0x643); break; } } -void EnTrt_SelectItem(EnTrt* this, GlobalContext* globalCtx) { +void EnTrt_SelectItem(EnTrt* this, PlayState* play) { EnGirlA* item = this->items[this->cursorIdx]; - u8 talkState = Message_GetState(&globalCtx->msgCtx); + u8 talkState = Message_GetState(&play->msgCtx); if (EnTrt_TakeItemOffShelf(this)) { - if (talkState == 4) { - func_8011552C(globalCtx, 6); - if (!EnTrt_TestCancelOption(this, globalCtx, CONTROLLER1(globalCtx)) && Message_ShouldAdvance(globalCtx)) { - switch (globalCtx->msgCtx.choiceIndex) { + if (talkState == TEXT_STATE_CHOICE) { + func_8011552C(play, 6); + if (!EnTrt_TestCancelOption(this, play, CONTROLLER1(&play->state)) && Message_ShouldAdvance(play)) { + switch (play->msgCtx.choiceIndex) { case 0: - EnTrt_HandleCanBuyItem(globalCtx, this); + EnTrt_HandleCanBuyItem(play, this); break; case 1: func_8019F230(); - this->actionFunc = this->tmpActionFunc; - func_80151938(globalCtx, EnTrt_GetItemTextId(this)); + this->actionFunc = this->prevActionFunc; + func_80151938(play, EnTrt_GetItemTextId(this)); break; } } - } else if (talkState == 5 && Message_ShouldAdvance(globalCtx)) { - if (!Interface_HasEmptyBottle()) { + } else if ((talkState == TEXT_STATE_5) && Message_ShouldAdvance(play)) { + if (!Inventory_HasEmptyBottle()) { play_sound(NA_SE_SY_ERROR); - EnTrt_SetupCannotBuy(globalCtx, this, 0x846); + EnTrt_SetupCannotBuy(play, this, 0x846); } else { if (this->cutsceneState == ENTRT_CUTSCENESTATE_PLAYING) { ActorCutscene_Stop(this->cutscene); this->cutsceneState = ENTRT_CUTSCENESTATE_STOPPED; } - EnTrt_SetupBuyItemWithFanfare(globalCtx, this); + EnTrt_SetupBuyItemWithFanfare(play, this); this->drawCursor = 0; this->shopItemSelectedTween = 0.0f; - item->boughtFunc(globalCtx, item); + item->boughtFunc(play, item); gSaveContext.save.weekEventReg[53] |= 0x10; } } } } -void EnTrt_IdleSleeping(EnTrt* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); +void EnTrt_IdleSleeping(EnTrt* this, PlayState* play) { + Player* player = GET_PLAYER(play); if ((gSaveContext.save.weekEventReg[85] & 8) && !(gSaveContext.save.weekEventReg[84] & 0x40)) { this->textId = 0x88F; @@ -755,16 +755,16 @@ void EnTrt_IdleSleeping(EnTrt* this, GlobalContext* globalCtx) { } else { this->talkOptionTextId = 0x885; } - this->tmpTextId = this->textId; + this->prevTextId = this->textId; if (player->transformation == PLAYER_FORM_GORON || player->transformation == PLAYER_FORM_ZORA || player->transformation == PLAYER_FORM_DEKU) { this->textId = 0x850; } - if (Player_GetMask(globalCtx) == PLAYER_MASK_SCENTS) { + if (Player_GetMask(play) == PLAYER_MASK_SCENTS) { this->textId = 0x890; } - if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { + if (Actor_ProcessTalkRequest(&this->actor, &play->state)) { if (player->transformation == PLAYER_FORM_HUMAN) { this->flags |= ENTRT_MET; } @@ -781,12 +781,12 @@ void EnTrt_IdleSleeping(EnTrt* this, GlobalContext* globalCtx) { this->actionFunc = EnTrt_BeginInteraction; } else if ((player->actor.world.pos.x >= -50.0f && player->actor.world.pos.x <= -25.0f) && (player->actor.world.pos.z >= -19.0f && player->actor.world.pos.z <= 30.0f)) { - func_800B8614(&this->actor, globalCtx, 200.0f); + func_800B8614(&this->actor, play, 200.0f); } if (DECR(this->timer) == 0) { this->timer = 40; - EnTrt_ChangeAnim(&this->skelAnime, sAnimations, 1); - this->animationIndex = 1; + EnTrt_ChangeAnim(&this->skelAnime, sAnimationInfo, 1); + this->animIndex = 1; this->actionFunc = EnTrt_IdleAwake; this->blinkFunc = EnTrt_OpenThenCloseEyes; } @@ -795,20 +795,20 @@ void EnTrt_IdleSleeping(EnTrt* this, GlobalContext* globalCtx) { } } -void EnTrt_IdleAwake(EnTrt* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); +void EnTrt_IdleAwake(EnTrt* this, PlayState* play) { + Player* player = GET_PLAYER(play); this->flags &= ~ENTRT_FULLY_AWAKE; if (player->transformation == PLAYER_FORM_HUMAN || player->transformation == PLAYER_FORM_FIERCE_DEITY) { - if (Player_GetMask(globalCtx) == PLAYER_MASK_SCENTS) { + if (Player_GetMask(play) == PLAYER_MASK_SCENTS) { this->textId = 0x890; } else { - this->textId = this->tmpTextId; + this->textId = this->prevTextId; } } else { this->textId = 0x850; } - if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { + if (Actor_ProcessTalkRequest(&this->actor, &play->state)) { if (this->cutsceneState == ENTRT_CUTSCENESTATE_STOPPED) { if (ActorCutscene_GetCurrentIndex() == 0x7C) { ActorCutscene_Stop(0x7C); @@ -821,18 +821,18 @@ void EnTrt_IdleAwake(EnTrt* this, GlobalContext* globalCtx) { if (player->transformation == PLAYER_FORM_HUMAN) { this->flags |= ENTRT_MET; } - EnTrt_ChangeAnim(&this->skelAnime, sAnimations, 2); + EnTrt_ChangeAnim(&this->skelAnime, sAnimationInfo, 2); this->blinkFunc = EnTrt_EyesClosed; this->timer = 45; this->actionFunc = EnTrt_BeginInteraction; } else if ((player->actor.world.pos.x >= -50.0f && player->actor.world.pos.x <= -25.0f) && (player->actor.world.pos.z >= -19.0f && player->actor.world.pos.z <= 30.0f)) { - func_800B8614(&this->actor, globalCtx, 200.0f); + func_800B8614(&this->actor, play, 200.0f); } if (DECR(this->timer) == 0) { this->timer = Rand_S16Offset(150, 100); - EnTrt_ChangeAnim(&this->skelAnime, sAnimations, 2); - this->animationIndex = 2; + EnTrt_ChangeAnim(&this->skelAnime, sAnimationInfo, 2); + this->animIndex = 2; this->sleepSoundTimer = 10; this->actor.textId = 0; this->actionFunc = EnTrt_IdleSleeping; @@ -840,7 +840,7 @@ void EnTrt_IdleAwake(EnTrt* this, GlobalContext* globalCtx) { } } -void EnTrt_BeginInteraction(EnTrt* this, GlobalContext* globalCtx) { +void EnTrt_BeginInteraction(EnTrt* this, PlayState* play) { s16 curFrame = this->skelAnime.curFrame / this->skelAnime.playSpeed; s16 animLastFrame = Animation_GetLastFrame(&object_trt_Anim_0030EC) / (s16)this->skelAnime.playSpeed; @@ -852,10 +852,10 @@ void EnTrt_BeginInteraction(EnTrt* this, GlobalContext* globalCtx) { ActorCutscene_SetIntentToPlay(this->cutscene); } } else if (this->cutsceneState == ENTRT_CUTSCENESTATE_PLAYING_SPECIAL) { - if (this->animationIndex != 5) { + if (this->animIndex != 5) { if (curFrame == animLastFrame) { - EnTrt_ChangeAnim(&this->skelAnime, sAnimations, 3); - this->animationIndex = 3; + EnTrt_ChangeAnim(&this->skelAnime, sAnimationInfo, 3); + this->animIndex = 3; this->blinkFunc = EnTrt_OpenEyesThenSetToBlink; this->timer = 10; this->cutsceneState = ENTRT_CUTSCENESTATE_PLAYING; @@ -868,14 +868,14 @@ 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); - Message_StartTextbox(globalCtx, this->textId, &this->actor); - this->animationIndex = 5; + EnTrt_ChangeAnim(&this->skelAnime, sAnimationInfo, 5); + Message_StartTextbox(play, this->textId, &this->actor); + this->animIndex = 5; switch (this->textId) { case 0x834: 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); + func_8011552C(play, 6); this->stickLeftPrompt.isEnabled = false; this->stickRightPrompt.isEnabled = true; this->actionFunc = EnTrt_Hello; @@ -884,7 +884,7 @@ void EnTrt_BeginInteraction(EnTrt* this, GlobalContext* globalCtx) { } break; case 0x83E: - func_8011552C(globalCtx, 6); + func_8011552C(play, 6); this->stickLeftPrompt.isEnabled = false; this->stickRightPrompt.isEnabled = true; this->actionFunc = EnTrt_FaceShopkeeper; @@ -900,7 +900,7 @@ void EnTrt_BeginInteraction(EnTrt* this, GlobalContext* globalCtx) { } } -void EnTrt_Surprised(EnTrt* this, GlobalContext* globalCtx) { +void EnTrt_Surprised(EnTrt* this, PlayState* play) { if (this->cutsceneState == ENTRT_CUTSCENESTATE_WAITING) { if (ActorCutscene_GetCanPlayNext(this->cutscene)) { ActorCutscene_StartAndSetFlag(this->cutscene, &this->actor); @@ -910,8 +910,8 @@ 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->animationIndex = 4; + EnTrt_ChangeAnim(&this->skelAnime, sAnimationInfo, 4); + this->animIndex = 4; this->blinkFunc = EnTrt_OpenEyes2; Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_KOTAKE_SURPRISED); this->timer = 30; @@ -919,61 +919,61 @@ 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); - Message_StartTextbox(globalCtx, this->textId, &this->actor); - this->animationIndex = 5; + EnTrt_ChangeAnim(&this->skelAnime, sAnimationInfo, 5); + Message_StartTextbox(play, this->textId, &this->actor); + this->animIndex = 5; this->actionFunc = EnTrt_TryToGiveRedPotionAfterSurprised; } } -void EnTrt_TryToGiveRedPotionAfterSurprised(EnTrt* this, GlobalContext* globalCtx) { - u8 talkState = Message_GetState(&globalCtx->msgCtx); +void EnTrt_TryToGiveRedPotionAfterSurprised(EnTrt* this, PlayState* play) { + u8 talkState = Message_GetState(&play->msgCtx); this->blinkFunc = EnTrt_Blink; - if (talkState == 6 && Message_ShouldAdvance(globalCtx)) { - if (Interface_HasEmptyBottle() || !(gSaveContext.save.weekEventReg[12] & 0x10)) { + if ((talkState == TEXT_STATE_DONE) && Message_ShouldAdvance(play)) { + if (Inventory_HasEmptyBottle() || !(gSaveContext.save.weekEventReg[12] & 0x10)) { if (this->cutsceneState == ENTRT_CUTSCENESTATE_PLAYING) { ActorCutscene_Stop(this->cutscene); this->cutsceneState = ENTRT_CUTSCENESTATE_STOPPED; } this->actionFunc = EnTrt_GiveRedPotionForKoume; } else { - this->tmpTextId = this->textId; + this->prevTextId = this->textId; this->textId = 0x88E; gSaveContext.save.weekEventReg[85] |= 8; - Message_StartTextbox(globalCtx, this->textId, &this->actor); + Message_StartTextbox(play, this->textId, &this->actor); this->actionFunc = EnTrt_EndConversation; } } } -void EnTrt_TryToGiveRedPotion(EnTrt* this, GlobalContext* globalCtx) { - if (Message_GetState(&globalCtx->msgCtx) == 5 && Message_ShouldAdvance(globalCtx)) { +void EnTrt_TryToGiveRedPotion(EnTrt* this, PlayState* play) { + if ((Message_GetState(&play->msgCtx) == TEXT_STATE_5) && Message_ShouldAdvance(play)) { if (this->textId == 0x83C) { - if (Interface_HasEmptyBottle()) { + if (Inventory_HasEmptyBottle()) { if (this->cutsceneState == ENTRT_CUTSCENESTATE_PLAYING) { ActorCutscene_Stop(this->cutscene); this->cutsceneState = ENTRT_CUTSCENESTATE_STOPPED; } - globalCtx->msgCtx.msgMode = 0x43; - globalCtx->msgCtx.unk12023 = 4; + play->msgCtx.msgMode = 0x43; + play->msgCtx.stateTimer = 4; this->actionFunc = EnTrt_GiveRedPotionForKoume; } else { - this->tmpTextId = this->textId; + this->prevTextId = this->textId; this->textId = 0x88E; gSaveContext.save.weekEventReg[85] |= 8; - Message_StartTextbox(globalCtx, this->textId, &this->actor); + Message_StartTextbox(play, this->textId, &this->actor); this->actionFunc = EnTrt_EndConversation; } } else { this->textId = 0x83C; - Message_StartTextbox(globalCtx, this->textId, &this->actor); + Message_StartTextbox(play, this->textId, &this->actor); } } } -void EnTrt_ItemGiven(EnTrt* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); +void EnTrt_ItemGiven(EnTrt* this, PlayState* play) { + Player* player = GET_PLAYER(play); if (this->cutsceneState == ENTRT_CUTSCENESTATE_STOPPED) { if (ActorCutscene_GetCanPlayNext(this->cutscene)) { @@ -989,7 +989,7 @@ void EnTrt_ItemGiven(EnTrt* this, GlobalContext* globalCtx) { ActorCutscene_SetIntentToPlay(this->cutscene); } } - if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { + if (Actor_ProcessTalkRequest(&this->actor, &play->state)) { switch (this->textId) { case 0x889: this->textId = 0x88A; @@ -1008,73 +1008,73 @@ void EnTrt_ItemGiven(EnTrt* this, GlobalContext* globalCtx) { this->textId = 0x849; break; } - func_80151938(globalCtx, this->textId); + func_80151938(play, this->textId); } else { - func_800B85E0(&this->actor, globalCtx, 400.0f, EXCH_ITEM_MINUS1); + func_800B85E0(&this->actor, play, 400.0f, PLAYER_AP_MINUS1); } } -void EnTrt_SetupEndInteraction(EnTrt* this, GlobalContext* globalCtx) { - if (Message_GetState(&globalCtx->msgCtx) == 5 && Message_ShouldAdvance(globalCtx)) { - EnTrt_EndInteraction(globalCtx, this); +void EnTrt_SetupEndInteraction(EnTrt* this, PlayState* play) { + if ((Message_GetState(&play->msgCtx) == TEXT_STATE_5) && Message_ShouldAdvance(play)) { + EnTrt_EndInteraction(play, this); } } -void EnTrt_ShopkeeperGone(EnTrt* this, GlobalContext* globalCtx) { - u8 talkState = Message_GetState(&globalCtx->msgCtx); - Player* player = GET_PLAYER(globalCtx); +void EnTrt_ShopkeeperGone(EnTrt* this, PlayState* play) { + u8 talkState = Message_GetState(&play->msgCtx); + Player* player = GET_PLAYER(play); - if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { - Message_StartTextbox(globalCtx, this->textId, &this->actor); + if (Actor_ProcessTalkRequest(&this->actor, &play->state)) { + Message_StartTextbox(play, 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); + func_800B8614(&this->actor, play, 200.0f); } } - if (talkState == 6 && Message_ShouldAdvance(globalCtx)) { + if ((talkState == TEXT_STATE_DONE) && Message_ShouldAdvance(play)) { if (gSaveContext.save.weekEventReg[20] & 2) { - globalCtx->nextEntranceIndex = 0xC50; + play->nextEntrance = ENTRANCE(SOUTHERN_SWAMP_CLEARED, 5); } else { - globalCtx->nextEntranceIndex = 0x8450; + play->nextEntrance = ENTRANCE(SOUTHERN_SWAMP_POISONED, 5); } - globalCtx->unk_1887F = 0x40; - gSaveContext.nextTransition = 0x40; - globalCtx->sceneLoadFlag = 0x14; + play->transitionType = TRANS_TYPE_64; + gSaveContext.nextTransitionType = TRANS_TYPE_64; + play->transitionTrigger = TRANS_TRIGGER_START; } } -void EnTrt_CannotBuy(EnTrt* this, GlobalContext* globalCtx) { - if (Message_GetState(&globalCtx->msgCtx) == 5 && Message_ShouldAdvance(globalCtx)) { - this->actionFunc = this->tmpActionFunc; - func_80151938(globalCtx, EnTrt_GetItemTextId(this)); +void EnTrt_CannotBuy(EnTrt* this, PlayState* play) { + if ((Message_GetState(&play->msgCtx) == TEXT_STATE_5) && Message_ShouldAdvance(play)) { + this->actionFunc = this->prevActionFunc; + func_80151938(play, EnTrt_GetItemTextId(this)); } } -void EnTrt_CanBuy(EnTrt* this, GlobalContext* globalCtx) { +void EnTrt_CanBuy(EnTrt* this, PlayState* play) { EnGirlA* item; - if (Message_GetState(&globalCtx->msgCtx) == 5 && Message_ShouldAdvance(globalCtx)) { + if ((Message_GetState(&play->msgCtx) == TEXT_STATE_5) && Message_ShouldAdvance(play)) { this->shopItemSelectedTween = 0.0f; EnTrt_ResetItemPosition(this); item = this->items[this->cursorIdx]; - item->restockFunc(globalCtx, item); - this->actionFunc = this->tmpActionFunc; - func_80151938(globalCtx, EnTrt_GetItemTextId(this)); + item->restockFunc(play, item); + this->actionFunc = this->prevActionFunc; + func_80151938(play, EnTrt_GetItemTextId(this)); } } -void EnTrt_BuyItemWithFanfare(EnTrt* this, GlobalContext* globalCtx) { - if (Actor_HasParent(&this->actor, globalCtx)) { +void EnTrt_BuyItemWithFanfare(EnTrt* this, PlayState* play) { + if (Actor_HasParent(&this->actor, play)) { this->actor.parent = NULL; this->actionFunc = EnTrt_SetupItemGiven; } else { - Actor_PickUp(&this->actor, globalCtx, this->items[this->cursorIdx]->getItemId, 300.0f, 300.0f); + Actor_PickUp(&this->actor, play, this->items[this->cursorIdx]->getItemId, 300.0f, 300.0f); } } -void EnTrt_SetupItemGiven(EnTrt* this, GlobalContext* globalCtx) { - if (Message_GetState(&globalCtx->msgCtx) == 6 && Message_ShouldAdvance(globalCtx)) { +void EnTrt_SetupItemGiven(EnTrt* this, PlayState* play) { + if ((Message_GetState(&play->msgCtx) == TEXT_STATE_DONE) && Message_ShouldAdvance(play)) { this->actionFunc = EnTrt_ItemGiven; if (this->cutsceneState == ENTRT_CUTSCENESTATE_STOPPED) { if (ActorCutscene_GetCurrentIndex() == 0x7C) { @@ -1083,45 +1083,45 @@ void EnTrt_SetupItemGiven(EnTrt* this, GlobalContext* globalCtx) { this->cutscene = this->lookToShopkeeperCutscene; ActorCutscene_SetIntentToPlay(this->cutscene); } - func_800B85E0(&this->actor, globalCtx, 400.0f, EXCH_ITEM_MINUS1); + func_800B85E0(&this->actor, play, 400.0f, PLAYER_AP_MINUS1); } } -void EnTrt_ContinueShopping(EnTrt* this, GlobalContext* globalCtx) { - u8 talkState = Message_GetState(&globalCtx->msgCtx); - Player* player = GET_PLAYER(globalCtx); +void EnTrt_ContinueShopping(EnTrt* this, PlayState* play) { + u8 talkState = Message_GetState(&play->msgCtx); + Player* player = GET_PLAYER(play); EnGirlA* item; - if (talkState == 4) { - func_8011552C(globalCtx, 6); - if (Message_ShouldAdvance(globalCtx)) { + if (talkState == TEXT_STATE_CHOICE) { + func_8011552C(play, 6); + if (Message_ShouldAdvance(play)) { EnTrt_ResetItemPosition(this); item = this->items[this->cursorIdx]; - item->restockFunc(globalCtx, item); - if (!EnTrt_TestEndInteraction(this, globalCtx, CONTROLLER1(globalCtx))) { - switch (globalCtx->msgCtx.choiceIndex) { + item->restockFunc(play, item); + if (!EnTrt_TestEndInteraction(this, play, CONTROLLER1(&play->state))) { + switch (play->msgCtx.choiceIndex) { case 0: func_8019F208(); player->actor.shape.rot.y = BINANG_ROT180(player->actor.shape.rot.y); player->stateFlags2 |= 0x20000000; - Message_StartTextbox(globalCtx, this->textId, &this->actor); - EnTrt_SetupStartShopping(globalCtx, this, true); - func_800B85E0(&this->actor, globalCtx, 400.0f, EXCH_ITEM_MINUS1); + Message_StartTextbox(play, this->textId, &this->actor); + EnTrt_SetupStartShopping(play, this, true); + func_800B85E0(&this->actor, play, 400.0f, PLAYER_AP_MINUS1); break; case 1: default: func_8019F230(); - EnTrt_EndInteraction(globalCtx, this); + EnTrt_EndInteraction(play, this); break; } } } - } else if (talkState == 5) { - if (Message_ShouldAdvance(globalCtx)) { + } else if (talkState == TEXT_STATE_5) { + if (Message_ShouldAdvance(play)) { EnTrt_ResetItemPosition(this); item = this->items[this->cursorIdx]; - item->restockFunc(globalCtx, item); - EnTrt_EndInteraction(globalCtx, this); + item->restockFunc(play, item); + EnTrt_EndInteraction(play, this); } } } @@ -1221,7 +1221,7 @@ void EnTrt_UpdateCursorAnim(EnTrt* this) { void EnTrt_UpdateStickDirectionPromptAnim(EnTrt* this) { f32 arrowAnimTween = this->arrowAnimTween; f32 stickAnimTween = this->stickAnimTween; - s32 maxColor = 255; // POSSIBLY FAKE + s32 maxColor = 255; //! FAKE: if (this->arrowAnimState == 0) { arrowAnimTween += 0.05f; @@ -1356,23 +1356,23 @@ void EnTrt_OpenEyesThenSetToBlink(EnTrt* this) { } } -void EnTrt_TalkToShopkeeper(EnTrt* this, GlobalContext* globalCtx) { - u8 talkState = talkState = Message_GetState(&globalCtx->msgCtx); - Player* player = GET_PLAYER(globalCtx); +void EnTrt_TalkToShopkeeper(EnTrt* this, PlayState* play) { + u8 talkState = talkState = Message_GetState(&play->msgCtx); + Player* player = GET_PLAYER(play); s32 itemGiven; - if (talkState == 5) { - if (Message_ShouldAdvance(globalCtx)) { + if (talkState == TEXT_STATE_5) { + if (Message_ShouldAdvance(play)) { if (this->talkOptionTextId == 0x845 || this->talkOptionTextId == 0x882) { - func_80151938(globalCtx, 0xFF); + func_80151938(play, 0xFF); } else { - EnTrt_StartShopping(globalCtx, this); + EnTrt_StartShopping(play, this); } } - } else if (talkState == 16) { - itemGiven = func_80123810(globalCtx); - if (itemGiven > EXCH_ITEM_NONE) { - if (itemGiven == EXCH_ITEM_1E) { + } else if (talkState == TEXT_STATE_16) { + itemGiven = func_80123810(play); + if (itemGiven > PLAYER_AP_NONE) { + if (itemGiven == PLAYER_AP_BOTTLE_MUSHROOM) { if (gSaveContext.save.weekEventReg[53] & 8) { player->actor.textId = 0x888; } else { @@ -1390,34 +1390,34 @@ void EnTrt_TalkToShopkeeper(EnTrt* this, GlobalContext* globalCtx) { this->textId = player->actor.textId; this->actionFunc = EnTrt_Goodbye; } - func_801477B4(globalCtx); - } else if (itemGiven < EXCH_ITEM_NONE) { + func_801477B4(play); + } else if (itemGiven < PLAYER_AP_NONE) { if (this->flags & ENTRT_GIVEN_MUSHROOM) { this->textId = 0x88B; } else { this->textId = 0x886; } - Message_StartTextbox(globalCtx, this->textId, &this->actor); + Message_StartTextbox(play, this->textId, &this->actor); this->actionFunc = EnTrt_Goodbye; } } } -void EnTrt_SetupTalkToShopkeeper(GlobalContext* globalCtx, EnTrt* this) { +void EnTrt_SetupTalkToShopkeeper(PlayState* play, EnTrt* this) { this->actionFunc = EnTrt_TalkToShopkeeper; - func_80151938(globalCtx, this->talkOptionTextId); - func_8011552C(globalCtx, 6); + func_80151938(play, this->talkOptionTextId); + func_8011552C(play, 6); this->stickLeftPrompt.isEnabled = false; this->stickRightPrompt.isEnabled = false; } -void EnTrt_SetupLookToShopkeeperFromShelf(GlobalContext* globalCtx, EnTrt* this) { +void EnTrt_SetupLookToShopkeeperFromShelf(PlayState* play, EnTrt* this) { play_sound(NA_SE_SY_CURSOR); this->drawCursor = 0; this->actionFunc = EnTrt_LookToShopkeeperFromShelf; } -void EnTrt_LookToShopkeeperFromShelf(EnTrt* this, GlobalContext* globalCtx) { +void EnTrt_LookToShopkeeperFromShelf(EnTrt* this, PlayState* play) { if (this->cutsceneState == ENTRT_CUTSCENESTATE_PLAYING) { ActorCutscene_Stop(this->cutscene); this->cutsceneState = ENTRT_CUTSCENESTATE_STOPPED; @@ -1433,15 +1433,15 @@ void EnTrt_LookToShopkeeperFromShelf(EnTrt* this, GlobalContext* globalCtx) { if (ActorCutscene_GetCanPlayNext(this->cutscene)) { ActorCutscene_StartAndSetFlag(this->cutscene, &this->actor); this->cutsceneState = ENTRT_CUTSCENESTATE_PLAYING; - EnTrt_StartShopping(globalCtx, this); + EnTrt_StartShopping(play, this); } else { ActorCutscene_SetIntentToPlay(this->cutscene); } } } -void EnTrt_InitShopkeeper(EnTrt* this, GlobalContext* globalCtx) { - SkelAnime_InitFlex(globalCtx, &this->skelAnime, &object_trt_Skel_00FEF0, &object_trt_Anim_00FD34, NULL, NULL, 0); +void EnTrt_InitShopkeeper(EnTrt* this, PlayState* play) { + SkelAnime_InitFlex(play, &this->skelAnime, &object_trt_Skel_00FEF0, &object_trt_Anim_00FD34, NULL, NULL, 0); if (!(gSaveContext.save.weekEventReg[12] & 8) && !(gSaveContext.save.weekEventReg[84] & 0x40) && gSaveContext.save.day >= 2) { this->actor.draw = NULL; @@ -1450,11 +1450,11 @@ void EnTrt_InitShopkeeper(EnTrt* this, GlobalContext* globalCtx) { } } -void EnTrt_InitShop(EnTrt* this, GlobalContext* globalCtx) { - EnTrt_GetCutscenes(this, globalCtx); +void EnTrt_InitShop(EnTrt* this, PlayState* play) { + EnTrt_GetCutscenes(this, play); this->cutscene = this->lookForwardCutscene; ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 20.0f); - EnTrt_InitShopkeeper(this, globalCtx); + EnTrt_InitShopkeeper(this, play); this->actor.colChkInfo.mass = MASS_IMMOVABLE; this->actor.colChkInfo.cylRadius = 50; this->timer = Rand_S16Offset(40, 20); @@ -1520,7 +1520,7 @@ void EnTrt_InitShop(EnTrt* this, GlobalContext* globalCtx) { this->actor.gravity = 0.0f; Actor_SetScale(&this->actor, sActorScale); - EnTrt_SpawnShopItems(this, globalCtx, sShop); + EnTrt_SpawnShopItems(this, play, sShop); this->blinkTimer = 20; this->eyeTextureIdx = 0; this->blinkFunc = EnTrt_EyesClosed; @@ -1531,14 +1531,14 @@ void EnTrt_InitShop(EnTrt* this, GlobalContext* globalCtx) { this->actor.flags &= ~ACTOR_FLAG_1; } -void EnTrt_GetCutscenes(EnTrt* this, GlobalContext* globalCtx) { +void EnTrt_GetCutscenes(EnTrt* this, PlayState* play) { this->lookForwardCutscene = this->actor.cutscene; this->lookToShelfCutscene = ActorCutscene_GetAdditionalCutscene(this->lookForwardCutscene); this->lookToShopkeeperCutscene = ActorCutscene_GetAdditionalCutscene(this->lookToShelfCutscene); this->getMushroomCutscene = ActorCutscene_GetAdditionalCutscene(this->lookToShopkeeperCutscene); } -void EnTrt_DrawCursor(GlobalContext* globalCtx, EnTrt* this, f32 x, f32 y, f32 z, u8 drawCursor) { +void EnTrt_DrawCursor(PlayState* play, EnTrt* this, f32 x, f32 y, f32 z, u8 drawCursor) { s32 ulx; s32 uly; s32 lrx; @@ -1547,9 +1547,9 @@ void EnTrt_DrawCursor(GlobalContext* globalCtx, EnTrt* this, f32 x, f32 y, f32 z s32 dsdx; s32 pad; - OPEN_DISPS(globalCtx->state.gfxCtx); + OPEN_DISPS(play->state.gfxCtx); if (drawCursor != 0) { - func_8012C654(globalCtx->state.gfxCtx); + func_8012C654(play->state.gfxCtx); gDPSetPrimColor(OVERLAY_DISP++, 0, 0, this->cursorColor.r, this->cursorColor.g, this->cursorColor.b, this->cursorColor.a); gDPLoadTextureBlock_4b(OVERLAY_DISP++, gSelectionCursorTex, G_IM_FMT_IA, 16, 16, 0, G_TX_MIRROR | G_TX_WRAP, @@ -1562,11 +1562,10 @@ void EnTrt_DrawCursor(GlobalContext* globalCtx, EnTrt* this, f32 x, f32 y, f32 z dsdx = (1.0f / z) * 1024.0f; gSPTextureRectangle(OVERLAY_DISP++, ulx, uly, lrx, lry, G_TX_RENDERTILE, 0, 0, dsdx, dsdx); } - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->state.gfxCtx); } -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) { +void EnTrt_DrawTextRec(PlayState* play, 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; s32 uly; @@ -1579,7 +1578,7 @@ void EnTrt_DrawTextRec(GlobalContext* globalCtx, s32 r, s32 g, s32 b, s32 a, f32 (void)"../z_en_trt.c"; - OPEN_DISPS(globalCtx->state.gfxCtx); + OPEN_DISPS(play->state.gfxCtx); gDPPipeSync(OVERLAY_DISP++); gDPSetPrimColor(OVERLAY_DISP++, 0, 0, r, g, b, a); @@ -1596,30 +1595,30 @@ void EnTrt_DrawTextRec(GlobalContext* globalCtx, s32 r, s32 g, s32 b, s32 a, f32 dtdy = dy * unk; gSPTextureRectangle(OVERLAY_DISP++, ulx, uly, lrx, lry, G_TX_RENDERTILE, s, t, dsdx, dtdy); - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->state.gfxCtx); } -void EnTrt_DrawStickDirectionPrompt(GlobalContext* globalCtx, EnTrt* this) { +void EnTrt_DrawStickDirectionPrompt(PlayState* play, EnTrt* this) { s32 drawStickRightPrompt = this->stickLeftPrompt.isEnabled; s32 drawStickLeftPrompt = this->stickRightPrompt.isEnabled; (void)"../z_en_trt.c"; - OPEN_DISPS(globalCtx->state.gfxCtx); + OPEN_DISPS(play->state.gfxCtx); if (drawStickRightPrompt || drawStickLeftPrompt) { - func_8012C654(globalCtx->state.gfxCtx); + func_8012C654(play->state.gfxCtx); gDPSetCombineMode(OVERLAY_DISP++, G_CC_MODULATEIA_PRIM, G_CC_MODULATEIA_PRIM); 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, + EnTrt_DrawTextRec(play, this->stickLeftPrompt.arrowColor.r, this->stickLeftPrompt.arrowColor.g, this->stickLeftPrompt.arrowColor.b, this->stickLeftPrompt.arrowColor.a, this->stickLeftPrompt.arrowTexX, this->stickLeftPrompt.arrowTexY, this->stickLeftPrompt.texZ, 0, 0, -1.0f, 1.0f); } if (drawStickLeftPrompt) { - EnTrt_DrawTextRec(globalCtx, this->stickRightPrompt.arrowColor.r, this->stickRightPrompt.arrowColor.g, + EnTrt_DrawTextRec(play, this->stickRightPrompt.arrowColor.r, this->stickRightPrompt.arrowColor.g, this->stickRightPrompt.arrowColor.b, this->stickRightPrompt.arrowColor.a, this->stickRightPrompt.arrowTexX, this->stickRightPrompt.arrowTexY, this->stickRightPrompt.texZ, 0, 0, 1.0f, 1.0f); @@ -1628,56 +1627,56 @@ void EnTrt_DrawStickDirectionPrompt(GlobalContext* globalCtx, EnTrt* this) { 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, + EnTrt_DrawTextRec(play, this->stickLeftPrompt.stickColor.r, this->stickLeftPrompt.stickColor.g, this->stickLeftPrompt.stickColor.b, this->stickLeftPrompt.stickColor.a, this->stickLeftPrompt.stickTexX, this->stickLeftPrompt.stickTexY, this->stickLeftPrompt.texZ, 0, 0, -1.0f, 1.0f); } if (drawStickLeftPrompt) { - EnTrt_DrawTextRec(globalCtx, this->stickRightPrompt.stickColor.r, this->stickRightPrompt.stickColor.g, + EnTrt_DrawTextRec(play, this->stickRightPrompt.stickColor.r, this->stickRightPrompt.stickColor.g, this->stickRightPrompt.stickColor.b, this->stickRightPrompt.stickColor.a, this->stickRightPrompt.stickTexX, this->stickRightPrompt.stickTexY, this->stickRightPrompt.texZ, 0, 0, 1.0f, 1.0f); } } - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->state.gfxCtx); } static InitChainEntry sInitChain[] = { ICHAIN_F32(targetArrowOffset, 500, ICHAIN_STOP), }; -void EnTrt_Init(Actor* thisx, GlobalContext* globalCtx) { +void EnTrt_Init(Actor* thisx, PlayState* play) { EnTrt* this = THIS; Actor_ProcessInitChain(&this->actor, sInitChain); - EnTrt_InitShop(this, globalCtx); + EnTrt_InitShop(this, play); } -void EnTrt_Destroy(Actor* thisx, GlobalContext* globalCtx) { +void EnTrt_Destroy(Actor* thisx, PlayState* play) { EnTrt* this = THIS; - SkelAnime_Free(&this->skelAnime, globalCtx); - Collider_DestroyCylinder(globalCtx, &this->collider); + SkelAnime_Free(&this->skelAnime, play); + Collider_DestroyCylinder(play, &this->collider); } -void EnTrt_Update(Actor* thisx, GlobalContext* globalCtx) { +void EnTrt_Update(Actor* thisx, PlayState* play) { EnTrt* this = THIS; this->blinkFunc(this); - EnTrt_UpdateJoystickInputState(globalCtx, this); + EnTrt_UpdateJoystickInputState(play, this); EnTrt_UpdateItemSelectedProperty(this); EnTrt_UpdateStickDirectionPromptAnim(this); EnTrt_UpdateCursorAnim(this); - EnTrt_UpdateHeadYawAndPitch(this, globalCtx); - this->actionFunc(this, globalCtx); + EnTrt_UpdateHeadYawAndPitch(this, play); + this->actionFunc(this, play); Actor_SetFocus(&this->actor, 90.0f); SkelAnime_Update(&this->skelAnime); - EnTrt_UpdateCollider(this, globalCtx); + EnTrt_UpdateCollider(this, play); } -void EnTrt_UpdateHeadYawAndPitch(EnTrt* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); +void EnTrt_UpdateHeadYawAndPitch(EnTrt* this, PlayState* play) { + Player* player = GET_PLAYER(play); Vec3f playerPos; Vec3f pos; @@ -1697,9 +1696,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; @@ -1714,7 +1713,7 @@ void EnTrt_UpdateHeadPosAndRot(s16 pitch, s16 yaw, Vec3f* pos, Vec3s* rot, s32 i } } -s32 EnTrt_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, Actor* thisx) { +s32 EnTrt_OverrideLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, Actor* thisx) { EnTrt* this = THIS; s32 i; @@ -1730,7 +1729,7 @@ s32 EnTrt_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, return false; } -void EnTrt_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx) { +void EnTrt_PostLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx) { EnTrt* this = THIS; s32 isFullyAwake; @@ -1740,41 +1739,41 @@ 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); } } -void EnTrt_TransformLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Actor* thisx) { +void EnTrt_TransformLimbDraw(PlayState* play, s32 limbIndex, Actor* thisx) { 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); } } -void EnTrt_Draw(Actor* thisx, GlobalContext* globalCtx) { +void EnTrt_Draw(Actor* thisx, PlayState* play) { static TexturePtr sEyeTextures[] = { object_trt_Tex_00B0B8, object_trt_Tex_00B8B8, object_trt_Tex_00C0B8 }; EnTrt* this = THIS; s32 pad; - OPEN_DISPS(globalCtx->state.gfxCtx); + OPEN_DISPS(play->state.gfxCtx); - func_8012C28C(globalCtx->state.gfxCtx); + func_8012C28C(play->state.gfxCtx); gSPSegment(POLY_OPA_DISP++, 0x08, Lib_SegmentedToVirtual(sEyeTextures[this->eyeTextureIdx])); gSPSegment(POLY_OPA_DISP++, 0x09, Lib_SegmentedToVirtual(sEyeTextures[this->eyeTextureIdx])); - SkelAnime_DrawTransformFlexOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, + SkelAnime_DrawTransformFlexOpa(play, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, EnTrt_OverrideLimbDraw, EnTrt_PostLimbDraw, EnTrt_TransformLimbDraw, &this->actor); - EnTrt_DrawCursor(globalCtx, this, this->cursorPos.x, this->cursorPos.y, this->cursorPos.z, this->drawCursor); - EnTrt_DrawStickDirectionPrompt(globalCtx, this); + EnTrt_DrawCursor(play, this, this->cursorPos.x, this->cursorPos.y, this->cursorPos.z, this->drawCursor); + EnTrt_DrawStickDirectionPrompt(play, this); - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->state.gfxCtx); } 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 eb243317b..46f070797 100644 --- a/src/overlays/actors/ovl_En_Trt/z_en_trt.h +++ b/src/overlays/actors/ovl_En_Trt/z_en_trt.h @@ -6,13 +6,13 @@ struct EnTrt; -typedef void (*EnTrtActionFunc)(struct EnTrt*, GlobalContext*); +typedef void (*EnTrtActionFunc)(struct EnTrt*, PlayState*); typedef void (*EnTrtBlinkFunc)(struct EnTrt*); typedef struct EnTrt { /* 0x000 */ Actor actor; /* 0x144 */ EnTrtActionFunc actionFunc; - /* 0x148 */ EnTrtActionFunc tmpActionFunc; + /* 0x148 */ EnTrtActionFunc prevActionFunc; /* 0x14C */ SkelAnime skelAnime; /* 0x190 */ ColliderCylinder collider; /* 0x1DC */ UNK_TYPE1 pad1DC[0x154]; @@ -41,9 +41,9 @@ typedef struct EnTrt { /* 0x3F0 */ Color_RGBAu32 cursorColor; /* 0x400 */ u8 drawCursor; /* 0x402 */ s16 timer; - /* 0x404 */ s16 animationIndex; + /* 0x404 */ s16 animIndex; /* 0x406 */ u16 textId; - /* 0x408 */ u16 tmpTextId; + /* 0x408 */ u16 prevTextId; /* 0x40A */ u16 talkOptionTextId; /* 0x40C */ s16 lookForwardCutscene; /* 0x40E */ s16 lookToShelfCutscene; diff --git a/src/overlays/actors/ovl_En_Trt2/z_en_trt2.c b/src/overlays/actors/ovl_En_Trt2/z_en_trt2.c index 0af7ac4bb..9e791dbea 100644 --- a/src/overlays/actors/ovl_En_Trt2/z_en_trt2.c +++ b/src/overlays/actors/ovl_En_Trt2/z_en_trt2.c @@ -11,22 +11,22 @@ #define THIS ((EnTrt2*)thisx) -void EnTrt2_Init(Actor* thisx, GlobalContext* globalCtx); -void EnTrt2_Destroy(Actor* thisx, GlobalContext* globalCtx); -void EnTrt2_Update(Actor* thisx, GlobalContext* globalCtx); +void EnTrt2_Init(Actor* thisx, PlayState* play); +void EnTrt2_Destroy(Actor* thisx, PlayState* play); +void EnTrt2_Update(Actor* thisx, PlayState* play); void func_80AD46F8(EnTrt2* this); s32 func_80AD475C(EnTrt2* this, Path* path, s32 arg2); s16 func_80AD48F8(Path* path, s32 arg1, Vec3f* arg2, f32* arg3); f32 func_80AD49B8(Path* path, s32 arg1, Vec3f* arg2, Vec3s* arg3); -void func_80AD4A78(EnTrt2* this, GlobalContext* globalCtx); -s32 func_80AD4B08(GlobalContext* globalCtx); -void func_80AD4DB4(EnTrt2* this, GlobalContext* globalCtx); -void func_80AD4FE4(EnTrt2* this, GlobalContext* globalCtx); -void func_80AD5234(EnTrt2* this, GlobalContext* globalCtx); -void func_80AD56E8(Actor* thisx, GlobalContext* globalCtx); +void func_80AD4A78(EnTrt2* this, PlayState* play); +s32 func_80AD4B08(PlayState* play); +void func_80AD4DB4(EnTrt2* this, PlayState* play); +void func_80AD4FE4(EnTrt2* this, PlayState* play); +void func_80AD5234(EnTrt2* this, PlayState* play); +void func_80AD56E8(Actor* thisx, PlayState* play); -static AnimationInfoS sAnimations[] = { +static AnimationInfoS sAnimationInfo[] = { { &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 }, @@ -122,12 +122,12 @@ void func_80AD3380(SkelAnime* skelAnime, AnimationInfoS* animation, s32 arg2) { animation->mode, animation->morphFrames); } -void func_80AD341C(EnTrt2* this, GlobalContext* globalCtx) { +void func_80AD341C(EnTrt2* this, PlayState* play) { this->collider.dim.pos.x = this->actor.world.pos.x; this->collider.dim.pos.y = this->actor.world.pos.y; this->collider.dim.pos.z = this->actor.world.pos.z; - CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); - CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + CollisionCheck_SetAC(play, &play->colChkCtx, &this->collider.base); + CollisionCheck_SetOC(play, &play->colChkCtx, &this->collider.base); } void func_80AD349C(EnTrt2* this) { @@ -144,7 +144,7 @@ void func_80AD349C(EnTrt2* this) { } } -void func_80AD3530(EnTrt2* this, GlobalContext* globalCtx) { +void func_80AD3530(EnTrt2* this, PlayState* play) { s16 phi_a1; f32 sp30; @@ -170,12 +170,12 @@ void func_80AD3530(EnTrt2* this, GlobalContext* globalCtx) { if (DECR(this->unk_3AE) == 0) { this->unk_3AE = Rand_S16Offset(20, 20); - func_80AD3380(&this->skelAnime, sAnimations, 7); + func_80AD3380(&this->skelAnime, sAnimationInfo, 7); this->unk_3B2 = 5; } } -void func_80AD3664(EnTrt2* this, GlobalContext* globalCtx) { +void func_80AD3664(EnTrt2* this, PlayState* play) { if (ActorCutscene_GetCanPlayNext(this->unk_3DA)) { ActorCutscene_StartAndSetUnkLinkFields(this->unk_3DA, &this->actor); if (this->unk_3D9 == 0) { @@ -190,7 +190,7 @@ void func_80AD3664(EnTrt2* this, GlobalContext* globalCtx) { func_800B9010(&this->actor, NA_SE_EN_KOTAKE_FLY - SFX_FLAG); } -void func_80AD36EC(EnTrt2* this, GlobalContext* globalCtx) { +void func_80AD36EC(EnTrt2* this, PlayState* play) { Vec3s sp30; f32 sp2C; @@ -203,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 = SubS_GetPathByIndex(globalCtx, this->path->unk1, -1); + this->path = SubS_GetPathByIndex(play, this->path->unk1, -1); ActorCutscene_Stop(this->unk_3DA); this->unk_3DA = ActorCutscene_GetAdditionalCutscene(this->unk_3DA); ActorCutscene_SetIntentToPlay(this->unk_3DA); @@ -220,9 +220,9 @@ void func_80AD36EC(EnTrt2* this, GlobalContext* globalCtx) { } } -void func_80AD381C(EnTrt2* this, GlobalContext* globalCtx) { +void func_80AD381C(EnTrt2* this, PlayState* play) { if ((CURRENT_DAY == 2) || (CURRENT_DAY == 3)) { - if (func_80AD4B08(globalCtx) == 1) { + if (func_80AD4B08(play) == 1) { this->actor.world.pos.y -= 50.0f; this->unk_3D9 = 0; this->unk_3B2 = 0; @@ -234,7 +234,7 @@ void func_80AD381C(EnTrt2* this, GlobalContext* globalCtx) { } } -void func_80AD38B8(EnTrt2* this, GlobalContext* globalCtx) { +void func_80AD38B8(EnTrt2* this, PlayState* play) { Vec3s sp30; if (this->unk_3D9 == 2) { @@ -271,39 +271,39 @@ void func_80AD38B8(EnTrt2* this, GlobalContext* globalCtx) { func_800B9010(&this->actor, NA_SE_EN_KOTAKE_FLY - SFX_FLAG); } -void func_80AD3A24(EnTrt2* this, GlobalContext* globalCtx) { +void func_80AD3A24(EnTrt2* this, PlayState* play) { func_80AD46F8(this); if (this->actor.speedXZ > 0.05f) { Math_ApproachF(&this->actor.speedXZ, 0.0f, 0.2f, 1.0f); } else if (DECR(this->unk_3AE) == 0) { this->unk_3AE = Rand_S16Offset(100, 50); - func_80AD3380(&this->skelAnime, sAnimations, 6); + func_80AD3380(&this->skelAnime, sAnimationInfo, 6); this->unk_3B2 = 4; } Actor_MoveWithGravity(&this->actor); } -void func_80AD3AE4(EnTrt2* this, GlobalContext* globalCtx) { +void func_80AD3AE4(EnTrt2* this, PlayState* play) { if (this->actor.world.pos.y < this->actor.home.pos.y) { Math_ApproachF(&this->actor.velocity.y, 0.5f, 0.2f, 0.1f); } else { this->actor.velocity.y = 0.0f; - func_80AD3380(&this->skelAnime, sAnimations, 6); + func_80AD3380(&this->skelAnime, sAnimationInfo, 6); this->unk_3B2 = 4; } Actor_MoveWithGravity(&this->actor); } -void func_80AD3B6C(EnTrt2* this, GlobalContext* globalCtx) { +void func_80AD3B6C(EnTrt2* this, PlayState* play) { if (DECR(this->unk_3B0) == 0) { this->unk_3B0 = 10; this->actor.velocity.y = -1.0f; - func_80AD3380(&this->skelAnime, sAnimations, 8); + func_80AD3380(&this->skelAnime, sAnimationInfo, 8); this->unk_3B2 = 8; } } -void func_80AD3BE4(EnTrt2* this, GlobalContext* globalCtx) { +void func_80AD3BE4(EnTrt2* this, PlayState* play) { s16 sp2E = this->actor.yawTowardsPlayer - this->actor.shape.rot.y; Math_ScaledStepToS(&this->unk_3C0, sp2E, 400); @@ -311,44 +311,44 @@ void func_80AD3BE4(EnTrt2* this, GlobalContext* globalCtx) { this->actor.world.rot.y += this->unk_3C0; this->actor.shape.rot.y = this->actor.world.rot.y; if (this->actor.world.pos.y < 5.0f) { - func_80AD3380(&this->skelAnime, sAnimations, 9); + func_80AD3380(&this->skelAnime, sAnimationInfo, 9); this->unk_3B2 = 9; } } -void func_80AD3C94(EnTrt2* this, GlobalContext* globalCtx) { +void func_80AD3C94(EnTrt2* this, PlayState* play) { if (this->actor.world.pos.y < 5.0f) { - func_80AD4A78(this, globalCtx); + func_80AD4A78(this, play); if (this->actor.bgCheckFlags & 1) { this->unk_3B2 = 0xF; } } } -void func_80AD3CEC(EnTrt2* this, GlobalContext* globalCtx) { - u8 sp27 = Message_GetState(&globalCtx->msgCtx); +void func_80AD3CEC(EnTrt2* this, PlayState* play) { + u8 talkState = Message_GetState(&play->msgCtx); func_80AD46F8(this); if (this->unk_3D8) { - Message_StartTextbox(globalCtx, this->unk_3A8, &this->actor); + Message_StartTextbox(play, this->unk_3A8, &this->actor); this->unk_3D8 = false; - } else if ((sp27 == 5) && Message_ShouldAdvance(globalCtx)) { - globalCtx->msgCtx.msgMode = 0x43; - globalCtx->msgCtx.unk12023 = 4; - func_80AD3380(&this->skelAnime, sAnimations, 6); + } else if ((talkState == TEXT_STATE_5) && Message_ShouldAdvance(play)) { + play->msgCtx.msgMode = 0x43; + play->msgCtx.stateTimer = 4; + func_80AD3380(&this->skelAnime, sAnimationInfo, 6); this->unk_3B2 = 4; } } -void func_80AD3DA4(EnTrt2* this, GlobalContext* globalCtx) { +void func_80AD3DA4(EnTrt2* this, PlayState* play) { this->actor.velocity.y = 0.0f; - Message_StartTextbox(globalCtx, this->unk_3A8, &this->actor); + Message_StartTextbox(play, this->unk_3A8, &this->actor); if (this->unk_3A8 == 0x838) { this->unk_3B2 = 11; return; } else if (this->unk_3A8 == 0x88F) { - if (Interface_HasEmptyBottle()) { + if (Inventory_HasEmptyBottle()) { this->unk_3B2 = 11; } else { this->unk_3B2 = 10; @@ -358,45 +358,45 @@ void func_80AD3DA4(EnTrt2* this, GlobalContext* globalCtx) { } } -void func_80AD3E34(EnTrt2* this, GlobalContext* globalCtx) { - if ((Message_GetState(&globalCtx->msgCtx) == 5) && Message_ShouldAdvance(globalCtx)) { - if (Interface_HasEmptyBottle()) { - globalCtx->msgCtx.msgMode = 0x43; - globalCtx->msgCtx.unk12023 = 4; +void func_80AD3E34(EnTrt2* this, PlayState* play) { + if ((Message_GetState(&play->msgCtx) == TEXT_STATE_5) && Message_ShouldAdvance(play)) { + if (Inventory_HasEmptyBottle()) { + play->msgCtx.msgMode = 0x43; + play->msgCtx.stateTimer = 4; this->unk_3B2 = 12; } else { gSaveContext.save.weekEventReg[85] |= 0x10; this->unk_3A8 = 0x88E; - Message_StartTextbox(globalCtx, this->unk_3A8, &this->actor); + Message_StartTextbox(play, this->unk_3A8, &this->actor); this->unk_3B2 = 10; } } } -void func_80AD3EF0(EnTrt2* this, GlobalContext* globalCtx) { - u8 temp_v0 = Message_GetState(&globalCtx->msgCtx); +void func_80AD3EF0(EnTrt2* this, PlayState* play) { + u8 talkState = Message_GetState(&play->msgCtx); - if (temp_v0 == 6) { - if (Message_ShouldAdvance(globalCtx)) { - if ((Interface_HasEmptyBottle() && !(gSaveContext.save.weekEventReg[84] & 0x40)) || + if (talkState == TEXT_STATE_DONE) { + if (Message_ShouldAdvance(play)) { + if ((Inventory_HasEmptyBottle() && !(gSaveContext.save.weekEventReg[84] & 0x40)) || !(gSaveContext.save.weekEventReg[12] & 0x10)) { this->unk_3B2 = 12; } else { gSaveContext.save.weekEventReg[85] |= 0x10; this->unk_3A8 = 0x88E; - Message_StartTextbox(globalCtx, this->unk_3A8, &this->actor); + Message_StartTextbox(play, this->unk_3A8, &this->actor); this->unk_3B2 = 10; } } - } else if ((temp_v0 == 5) && Message_ShouldAdvance(globalCtx)) { - globalCtx->msgCtx.msgMode = 0x43; - globalCtx->msgCtx.unk12023 = 4; + } else if ((talkState == TEXT_STATE_5) && Message_ShouldAdvance(play)) { + play->msgCtx.msgMode = 0x43; + play->msgCtx.stateTimer = 4; this->unk_3B2 = 12; } } -void func_80AD3FF4(EnTrt2* this, GlobalContext* globalCtx) { - if (Actor_HasParent(&this->actor, globalCtx)) { +void func_80AD3FF4(EnTrt2* this, PlayState* play) { + if (Actor_HasParent(&this->actor, play)) { if (!(gSaveContext.save.weekEventReg[12] & 0x10)) { gSaveContext.save.weekEventReg[12] |= 0x10; } @@ -404,44 +404,44 @@ void func_80AD3FF4(EnTrt2* this, GlobalContext* globalCtx) { this->actor.parent = NULL; this->unk_3B2 = 14; } else if (gSaveContext.save.weekEventReg[12] & 0x10) { - Actor_PickUp(&this->actor, globalCtx, GI_POTION_RED, 300.0f, 300.0f); + Actor_PickUp(&this->actor, play, GI_POTION_RED, 300.0f, 300.0f); } else { - Actor_PickUp(&this->actor, globalCtx, GI_BOTTLE_POTION_RED, 300.0f, 300.0f); + Actor_PickUp(&this->actor, play, GI_POTION_RED_BOTTLE, 300.0f, 300.0f); } } -void func_80AD40AC(EnTrt2* this, GlobalContext* globalCtx) { - if ((Message_GetState(&globalCtx->msgCtx) == 6) && Message_ShouldAdvance(globalCtx)) { - func_800B85E0(&this->actor, globalCtx, 400.0f, -1); +void func_80AD40AC(EnTrt2* this, PlayState* play) { + if ((Message_GetState(&play->msgCtx) == TEXT_STATE_DONE) && Message_ShouldAdvance(play)) { + func_800B85E0(&this->actor, play, 400.0f, -1); this->unk_3B2 = 13; } } -void func_80AD4110(EnTrt2* this, GlobalContext* globalCtx) { - if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { +void func_80AD4110(EnTrt2* this, PlayState* play) { + if (Actor_ProcessTalkRequest(&this->actor, &play->state)) { this->unk_3A8 = 0x84C; - func_80151938(globalCtx, this->unk_3A8); + func_80151938(play, this->unk_3A8); this->unk_3B2 = 10; } else { - func_800B85E0(&this->actor, globalCtx, 400.0f, -1); + func_800B85E0(&this->actor, play, 400.0f, -1); } } -void func_80AD417C(EnTrt2* this, GlobalContext* globalCtx) { - if ((Message_GetState(&globalCtx->msgCtx) == 5) && Message_ShouldAdvance(globalCtx)) { +void func_80AD417C(EnTrt2* this, PlayState* play) { + if ((Message_GetState(&play->msgCtx) == TEXT_STATE_5) && Message_ShouldAdvance(play)) { if (this->unk_3A8 == 0x84B) { func_80AD349C(this); - func_80AD3DA4(this, globalCtx); + func_80AD3DA4(this, play); } else { - globalCtx->msgCtx.msgMode = 0x43; - globalCtx->msgCtx.unk12023 = 4; + play->msgCtx.msgMode = 0x43; + play->msgCtx.stateTimer = 4; if (this->unk_3A8 == 0x84C) { - func_80AD3380(&this->skelAnime, sAnimations, 6); - this->path = SubS_GetPathByIndex(globalCtx, ENTRT2_GET_FC00(&this->actor), 0x3F); + func_80AD3380(&this->skelAnime, sAnimationInfo, 6); + this->path = SubS_GetPathByIndex(play, ENTRT2_GET_FC00(&this->actor), 0x3F); this->unk_3B2 = 18; } else if (this->unk_3A8 == 0x88F) { this->unk_3A8 = 0x88E; - Message_StartTextbox(globalCtx, this->unk_3A8, &this->actor); + Message_StartTextbox(play, this->unk_3A8, &this->actor); } else { this->actor.textId = 0; this->unk_3B2 = 15; @@ -450,8 +450,8 @@ void func_80AD417C(EnTrt2* this, GlobalContext* globalCtx) { } } -void func_80AD4298(EnTrt2* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); +void func_80AD4298(EnTrt2* this, PlayState* play) { + Player* player = GET_PLAYER(play); if (ActorCutscene_GetCanPlayNext(this->unk_3DA)) { ActorCutscene_StartAndSetUnkLinkFields(this->unk_3DA, &this->actor); @@ -465,14 +465,14 @@ void func_80AD4298(EnTrt2* this, GlobalContext* globalCtx) { } } -void func_80AD431C(EnTrt2* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); +void func_80AD431C(EnTrt2* this, PlayState* play) { + Player* player = GET_PLAYER(play); player->stateFlags1 &= ~0x20; Actor_MarkForDeath(&this->actor); } -void func_80AD434C(EnTrt2* this, GlobalContext* globalCtx) { +void func_80AD434C(EnTrt2* this, PlayState* play) { this->actor.shape.rot.y += 0x1000; Math_ApproachF(&this->actor.velocity.y, 1.5f, 0.2f, 0.1f); @@ -489,13 +489,13 @@ void func_80AD434C(EnTrt2* this, GlobalContext* globalCtx) { 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, 100, 0, 3); + func_800B3030(play, &sp68, &sp5C, &sp5C, 100, 0, 3); } func_800B9010(&this->actor, NA_SE_EN_COMMON_EXTINCT_LEV - SFX_FLAG); } } else if (this->actor.world.pos.y < 5.0f) { - func_80AD4A78(this, globalCtx); + func_80AD4A78(this, play); } Actor_MoveWithGravity(&this->actor); @@ -505,18 +505,18 @@ void func_80AD434C(EnTrt2* this, GlobalContext* globalCtx) { } } -void func_80AD4550(EnTrt2* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); - u8 sp23 = Message_GetState(&globalCtx->msgCtx); +void func_80AD4550(EnTrt2* this, PlayState* play) { + Player* player = GET_PLAYER(play); + u8 talkState = Message_GetState(&play->msgCtx); if ((player->transformation != PLAYER_FORM_HUMAN) && (player->transformation != PLAYER_FORM_FIERCE_DEITY)) { - func_80AD3380(&this->skelAnime, sAnimations, 7); + func_80AD3380(&this->skelAnime, sAnimationInfo, 7); this->unk_3B2 = 17; } - if ((sp23 == 5) && Message_ShouldAdvance(globalCtx)) { - globalCtx->msgCtx.msgMode = 0x43; - globalCtx->msgCtx.unk12023 = 4; + if ((talkState == TEXT_STATE_5) && Message_ShouldAdvance(play)) { + play->msgCtx.msgMode = 0x43; + play->msgCtx.stateTimer = 4; } } @@ -538,8 +538,8 @@ void func_80AD4608(EnTrt2* this) { } } -void func_80AD469C(EnTrt2* this, GlobalContext* globalCtx) { - SkelAnime_InitFlex(globalCtx, &this->skelAnime, &object_trt_Skel_00FEF0, &object_trt_Anim_000A44, NULL, NULL, 0); +void func_80AD469C(EnTrt2* this, PlayState* play) { + SkelAnime_InitFlex(play, &this->skelAnime, &object_trt_Skel_00FEF0, &object_trt_Anim_000A44, NULL, NULL, 0); this->actor.draw = func_80AD56E8; } @@ -623,20 +623,20 @@ f32 func_80AD49B8(Path* path, s32 arg1, Vec3f* arg2, Vec3s* arg3) { return sp20.y - arg2->y; } -void func_80AD4A78(EnTrt2* this, GlobalContext* globalCtx) { +void func_80AD4A78(EnTrt2* this, PlayState* play) { Vec3f sp34; sp34.x = randPlusMinusPoint5Scaled(15.0f) + this->actor.world.pos.x; sp34.y = this->actor.world.pos.y; sp34.z = randPlusMinusPoint5Scaled(15.0f) + this->actor.world.pos.z; - Actor_SpawnFloorDustRing(globalCtx, &this->actor, &sp34, 50.0f, 0, 2.0f, 0, 0, 0); + Actor_SpawnFloorDustRing(play, &this->actor, &sp34, 50.0f, 0, 2.0f, 0, 0, 0); } -s32 func_80AD4B08(GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); +s32 func_80AD4B08(PlayState* play) { + Player* player = GET_PLAYER(play); s32 ret; - if (SurfaceType_GetSceneExitIndex(&globalCtx->colCtx, player->actor.floorPoly, player->actor.floorBgId) == 0x15) { + if (SurfaceType_GetSceneExitIndex(&play->colCtx, player->actor.floorPoly, player->actor.floorBgId) == 0x15) { ret = true; } else { ret = false; @@ -644,11 +644,11 @@ s32 func_80AD4B08(GlobalContext* globalCtx) { return ret; } -s32 func_80AD4B4C(EnTrt2* this, GlobalContext* globalCtx) { +s32 func_80AD4B4C(EnTrt2* this, PlayState* play) { s32 sp24 = false; - Player* player = GET_PLAYER(globalCtx); + Player* player = GET_PLAYER(play); - if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { + if (Actor_ProcessTalkRequest(&this->actor, &play->state)) { sp24 = true; this->actor.speedXZ = 0.0f; func_80AD349C(this); @@ -657,7 +657,7 @@ s32 func_80AD4B4C(EnTrt2* this, GlobalContext* globalCtx) { if ((player->transformation != PLAYER_FORM_HUMAN) && (player->transformation != PLAYER_FORM_FIERCE_DEITY)) { this->unk_3A8 = 0x84F; } - func_80AD3DA4(this, globalCtx); + func_80AD3DA4(this, play); } else if ((player->transformation == PLAYER_FORM_HUMAN) || (player->transformation == PLAYER_FORM_FIERCE_DEITY)) { this->unk_3B2 = 16; @@ -665,7 +665,7 @@ s32 func_80AD4B4C(EnTrt2* this, GlobalContext* globalCtx) { } else { this->unk_3A8 = 0x84F; this->unk_3D8 = true; - func_80AD3380(&this->skelAnime, sAnimations, 7); + func_80AD3380(&this->skelAnime, sAnimationInfo, 7); this->unk_3B2 = 7; } } @@ -683,9 +683,9 @@ s32 func_80AD4C4C(EnTrt2* this) { return false; } -s32 func_80AD4CCC(EnTrt2* this, GlobalContext* globalCtx) { +s32 func_80AD4CCC(EnTrt2* this, PlayState* play) { s16 sp1E = this->actor.yawTowardsPlayer - this->actor.shape.rot.y; - Player* player = GET_PLAYER(globalCtx); + Player* player = GET_PLAYER(play); if (((this->unk_3B2 == 4) || (this->unk_3B2 == 5)) && this->actor.isTargeted && !(this->actor.bgCheckFlags & 1) && ((player->transformation == PLAYER_FORM_HUMAN) || (player->transformation == PLAYER_FORM_FIERCE_DEITY))) { @@ -696,19 +696,19 @@ s32 func_80AD4CCC(EnTrt2* this, GlobalContext* globalCtx) { } if (func_80AD4C4C(this) && this->actor.isTargeted && (sp1E < 0x4000) && (sp1E > -0x4000)) { - func_800B863C(&this->actor, globalCtx); + func_800B863C(&this->actor, play); } return true; } -void func_80AD4DB4(EnTrt2* this, GlobalContext* globalCtx) { +void func_80AD4DB4(EnTrt2* this, PlayState* play) { static Vec3f D_80AD5904 = { 0.0f, 50.0f, 0.0 }; this->actor.flags &= ~ACTOR_FLAG_10; - Actor_SetObjectDependency(globalCtx, &this->actor); + Actor_SetObjectDependency(play, &this->actor); Actor_SetScale(&this->actor, 0.008f); - this->path = SubS_GetPathByIndex(globalCtx, ENTRT2_GET_FC00(&this->actor), 0x3F); + this->path = SubS_GetPathByIndex(play, ENTRT2_GET_FC00(&this->actor), 0x3F); this->unk_3AE = Rand_S16Offset(100, 50); this->unk_3B0 = 10; this->unk_3A8 = 0; @@ -718,7 +718,7 @@ void func_80AD4DB4(EnTrt2* this, GlobalContext* globalCtx) { this->actor.world.pos.z += D_80AD5904.z; ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 20.0f); - func_80AD469C(this, globalCtx); + func_80AD469C(this, play); this->actor.colChkInfo.mass = MASS_IMMOVABLE; this->actor.colChkInfo.cylRadius = 50; @@ -739,7 +739,7 @@ void func_80AD4DB4(EnTrt2* this, GlobalContext* globalCtx) { return; } - if ((globalCtx->sceneNum == SCENE_20SICHITAI) || (globalCtx->sceneNum == SCENE_20SICHITAI2)) { + if ((play->sceneNum == SCENE_20SICHITAI) || (play->sceneNum == SCENE_20SICHITAI2)) { if (gSaveContext.save.day == 2) { if (!(gSaveContext.save.weekEventReg[15] & 0x80)) { gSaveContext.save.weekEventReg[15] |= 0x80; @@ -765,7 +765,7 @@ void func_80AD4DB4(EnTrt2* this, GlobalContext* globalCtx) { this->actionFunc = func_80AD4FE4; } -void func_80AD4FE4(EnTrt2* this, GlobalContext* globalCtx) { +void func_80AD4FE4(EnTrt2* this, PlayState* play) { static EnTrt2UnkFunc2 D_80AD5910[] = { func_80AD3664, func_80AD36EC, func_80AD38B8, func_80AD381C, func_80AD3530, func_80AD3A24, func_80AD434C, func_80AD3CEC, func_80AD3BE4, func_80AD3C94, func_80AD417C, func_80AD3EF0, func_80AD3FF4, func_80AD4110, @@ -774,11 +774,11 @@ void func_80AD4FE4(EnTrt2* this, GlobalContext* globalCtx) { this->unk_3BC(this); - D_80AD5910[this->unk_3B2](this, globalCtx); + D_80AD5910[this->unk_3B2](this, play); Actor_MoveWithGravity(&this->actor); - if (globalCtx->sceneNum != SCENE_20SICHITAI) { - Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 26.0f, 10.0f, 0.0f, 5); + if (play->sceneNum != SCENE_20SICHITAI) { + Actor_UpdateBgCheckInfo(play, &this->actor, 26.0f, 10.0f, 0.0f, 5); } Actor_SetFocus(&this->actor, 90.0f); @@ -790,44 +790,44 @@ static InitChainEntry sInitChain[] = { ICHAIN_F32(targetArrowOffset, 500, ICHAIN_STOP), }; -void EnTrt2_Init(Actor* thisx, GlobalContext* globalCtx) { +void EnTrt2_Init(Actor* thisx, PlayState* play) { EnTrt2* this = THIS; - Collider_InitCylinder(globalCtx, &this->collider); - Collider_SetCylinder(globalCtx, &this->collider, &this->actor, &sCylinderInit); + Collider_InitCylinder(play, &this->collider); + Collider_SetCylinder(play, &this->collider, &this->actor, &sCylinderInit); CollisionCheck_SetInfo2(&this->actor.colChkInfo, &sDamageTable, &sColChkInfoInit); Actor_ProcessInitChain(&this->actor, sInitChain); this->actionFunc = func_80AD4DB4; } -void EnTrt2_Destroy(Actor* thisx, GlobalContext* globalCtx) { +void EnTrt2_Destroy(Actor* thisx, PlayState* play) { EnTrt2* this = THIS; - SkelAnime_Free(&this->skelAnime, globalCtx); - Collider_DestroyCylinder(globalCtx, &this->collider); + SkelAnime_Free(&this->skelAnime, play); + Collider_DestroyCylinder(play, &this->collider); } -void EnTrt2_Update(Actor* thisx, GlobalContext* globalCtx) { +void EnTrt2_Update(Actor* thisx, PlayState* play) { EnTrt2* this = THIS; if ((this->unk_3B2 != 6) && (this->unk_3B2 != 10) && (this->unk_3B2 != 13) && (this->unk_3B2 != 14) && (this->unk_3B2 != 16) && (this->unk_3B2 != 8) && (this->unk_3B2 != 9)) { - func_80AD4B4C(this, globalCtx); + func_80AD4B4C(this, play); } - this->actionFunc(this, globalCtx); + this->actionFunc(this, play); - func_80AD341C(this, globalCtx); - func_80AD5234(this, globalCtx); + func_80AD341C(this, play); + func_80AD5234(this, play); if ((this->unk_3B2 != 6) && (this->unk_3B2 != 10) && (this->unk_3B2 != 13) && (this->unk_3B2 != 14) && (this->unk_3B2 != 16) && (this->unk_3B2 != 8) && (this->unk_3B2 != 9)) { - func_80AD4CCC(this, globalCtx); + func_80AD4CCC(this, play); } } -void func_80AD5234(EnTrt2* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); +void func_80AD5234(EnTrt2* this, PlayState* play) { + Player* player = GET_PLAYER(play); Vec3f sp40; Vec3f sp34; @@ -854,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; @@ -873,8 +873,7 @@ void func_80AD5394(s16 arg0, s16 arg1, Vec3f* arg2, Vec3s* arg3, s32 arg4) { } } -s32 EnTrt2_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, - Actor* thisx) { +s32 EnTrt2_OverrideLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, Actor* thisx) { EnTrt2* this = THIS; if ((limbIndex == 8) || (limbIndex == 13) || (limbIndex == 19)) { @@ -884,7 +883,7 @@ s32 EnTrt2_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList return false; } -void EnTrt2_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx) { +void EnTrt2_PostLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx) { EnTrt2* this = THIS; Vec3f sp30 = { 0.0f, -30.0f, 0.0f }; s32 phi_v0 = false; @@ -895,28 +894,28 @@ 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_TransformLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Actor* thisx) { +void EnTrt2_TransformLimbDraw(PlayState* play, 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); } } -void func_80AD56E8(Actor* thisx, GlobalContext* globalCtx) { +void func_80AD56E8(Actor* thisx, PlayState* play) { static TexturePtr D_80AD5978[] = { object_trt_Tex_00B0B8, object_trt_Tex_00B8B8, @@ -925,16 +924,16 @@ void func_80AD56E8(Actor* thisx, GlobalContext* globalCtx) { s32 pad; EnTrt2* this = THIS; - OPEN_DISPS(globalCtx->state.gfxCtx); + OPEN_DISPS(play->state.gfxCtx); - func_8012C28C(globalCtx->state.gfxCtx); + func_8012C28C(play->state.gfxCtx); gSPSegment(POLY_OPA_DISP++, 0x08, Lib_SegmentedToVirtual(D_80AD5978[this->unk_3B8])); gSPSegment(POLY_OPA_DISP++, 0x09, Lib_SegmentedToVirtual(D_80AD5978[this->unk_3B8])); - SkelAnime_DrawTransformFlexOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, + SkelAnime_DrawTransformFlexOpa(play, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, EnTrt2_OverrideLimbDraw, EnTrt2_PostLimbDraw, EnTrt2_TransformLimbDraw, &this->actor); - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->state.gfxCtx); } diff --git a/src/overlays/actors/ovl_En_Trt2/z_en_trt2.h b/src/overlays/actors/ovl_En_Trt2/z_en_trt2.h index bab274721..da5c6fa9c 100644 --- a/src/overlays/actors/ovl_En_Trt2/z_en_trt2.h +++ b/src/overlays/actors/ovl_En_Trt2/z_en_trt2.h @@ -5,9 +5,9 @@ struct EnTrt2; -typedef void (*EnTrt2ActionFunc)(struct EnTrt2*, GlobalContext*); +typedef void (*EnTrt2ActionFunc)(struct EnTrt2*, PlayState*); typedef void (*EnTrt2UnkFunc)(struct EnTrt2*); -typedef void (*EnTrt2UnkFunc2)(struct EnTrt2*, GlobalContext*); +typedef void (*EnTrt2UnkFunc2)(struct EnTrt2*, PlayState*); #define ENTRT2_GET_FC00(thisx) (((thisx)->params & 0xFC00) >> 0xA) 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 ea0e8ae44..996a32bef 100644 --- a/src/overlays/actors/ovl_En_Tru/z_en_tru.c +++ b/src/overlays/actors/ovl_En_Tru/z_en_tru.c @@ -11,18 +11,18 @@ #define THIS ((EnTru*)thisx) -void EnTru_Init(Actor* thisx, GlobalContext* globalCtx); -void EnTru_Destroy(Actor* thisx, GlobalContext* globalCtx); -void EnTru_Update(Actor* thisx, GlobalContext* globalCtx); -void EnTru_Draw(Actor* thisx, GlobalContext* globalCtx); +void EnTru_Init(Actor* thisx, PlayState* play); +void EnTru_Destroy(Actor* thisx, PlayState* play); +void EnTru_Update(Actor* thisx, PlayState* play); +void EnTru_Draw(Actor* thisx, PlayState* play); -s32 func_80A875AC(Actor* thisx, GlobalContext* globalCtx); -s32 func_80A8777C(Actor* thisx, GlobalContext* globalCtx); -s32 func_80A87880(Actor* thisx, GlobalContext* globalCtx); -s32 func_80A87B48(Actor* thisx, GlobalContext* globalCtx); -s32 func_80A87DC0(Actor* thisx, GlobalContext* globalCtx); -void func_80A87FD0(EnTru* this, GlobalContext* globalCtx); -void func_80A881E0(EnTru* this, GlobalContext* globalCtx); +s32 func_80A875AC(Actor* thisx, PlayState* play); +s32 func_80A8777C(Actor* thisx, PlayState* play); +s32 func_80A87880(Actor* thisx, PlayState* play); +s32 func_80A87B48(Actor* thisx, PlayState* play); +s32 func_80A87DC0(Actor* thisx, PlayState* play); +void func_80A87FD0(EnTru* this, PlayState* play); +void func_80A881E0(EnTru* this, PlayState* play); static UNK_TYPE D_80A88910[] = { 0x0E08520C, @@ -106,7 +106,7 @@ static ColliderSphereInit sSphereInit = { static CollisionCheckInfoInit2 sColChkInfoInit = { 1, 20, 0, 0, MASS_IMMOVABLE }; -static AnimationInfoS D_80A8B2D8[] = { +static AnimationInfoS sAnimationInfo[] = { { &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 }, @@ -148,13 +148,13 @@ void func_80A85620(EnTruUnkStruct* arg0, Vec3f* arg1, f32 arg2, f32 arg3, f32 ar } } -void func_80A85788(EnTruUnkStruct* arg0, GlobalContext* globalCtx) { +void func_80A85788(EnTruUnkStruct* arg0, PlayState* play) { s32 i; s32 flag = false; - OPEN_DISPS(globalCtx->state.gfxCtx); + OPEN_DISPS(play->state.gfxCtx); - func_8012C2DC(globalCtx->state.gfxCtx); + func_8012C2DC(play->state.gfxCtx); for (i = 0; i < 30; i++, arg0++) { if (arg0->unk_00 == 1) { @@ -174,20 +174,19 @@ void func_80A85788(EnTruUnkStruct* arg0, GlobalContext* globalCtx) { gDPSetEnvColor(POLY_XLU_DISP++, 255, 255, 255, 128); gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 255, 255, 255, (u8)alpha); gSPSegment(POLY_XLU_DISP++, 0x08, - Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, 0, -arg0->unk_02 * 5, 32, 64, 1, 0, 0, 32, 32)); + Gfx_TwoTexScroll(play->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(&play->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); + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_XLU_DISP++, D_80A890A8); } } - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->state.gfxCtx); } void func_80A85AA4(EnTruUnkStruct* arg0, Vec3f* arg1, f32 arg2, f32 arg3, f32 arg4) { @@ -208,14 +207,14 @@ void func_80A85AA4(EnTruUnkStruct* arg0, Vec3f* arg1, f32 arg2, f32 arg3, f32 ar } } -void func_80A85BCC(EnTruUnkStruct* arg0, GlobalContext* globalCtx) { +void func_80A85BCC(EnTruUnkStruct* arg0, PlayState* play) { s32 i; s32 flag = false; - OPEN_DISPS(globalCtx->state.gfxCtx); - if (globalCtx) {} + OPEN_DISPS(play->state.gfxCtx); + if (play) {} - func_8012C2DC(globalCtx->state.gfxCtx); + func_8012C2DC(play->state.gfxCtx); for (i = 0; i < 30; i++, arg0++) { if (arg0->unk_00 == 2) { @@ -234,17 +233,16 @@ 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(&play->billboardMtxF); Matrix_Scale(arg0->unk_28, arg0->unk_28, 1.0f, MTXMODE_APPLY); - gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), - G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_XLU_DISP++, D_80A8A108); } } - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->state.gfxCtx); } void func_80A85E2C(EnTruUnkStruct* arg0, Vec3f* arg1, Vec3f* arg2, Vec3f* arg3, f32 arg4, f32 arg5, f32 arg6, u8 arg7) { @@ -267,13 +265,13 @@ void func_80A85E2C(EnTruUnkStruct* arg0, Vec3f* arg1, Vec3f* arg2, Vec3f* arg3, #ifdef NON_MATCHING // s8/s6 flipped, same deal as above functions but the same fixes don't work -void func_80A85F84(EnTruUnkStruct* arg0, GlobalContext* globalCtx) { +void func_80A85F84(EnTruUnkStruct* arg0, PlayState* play) { u8 flag = false; s32 i; - OPEN_DISPS(globalCtx->state.gfxCtx); + OPEN_DISPS(play->state.gfxCtx); - func_8012C2DC(globalCtx->state.gfxCtx); + func_8012C2DC(play->state.gfxCtx); for (i = 0; i < 30; i++, arg0++) { f32 alpha; @@ -286,7 +284,7 @@ void func_80A85F84(EnTruUnkStruct* arg0, GlobalContext* globalCtx) { flag = true; } - Matrix_StatePush(); + Matrix_Push(); do { alpha = (f32)arg0->unk_02 / arg0->unk_01; @@ -303,23 +301,23 @@ 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(&play->billboardMtxF); - gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), - G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); idx = ((f32)arg0->unk_02 / arg0->unk_01) * 8.0f; 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); + CLOSE_DISPS(play->state.gfxCtx); } #else +void func_80A85F84(EnTruUnkStruct* arg0, PlayState* play); #pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tru/func_80A85F84.s") #endif @@ -426,22 +424,22 @@ s32 func_80A86924(EnTru* this, s32 arg1) { if (arg1 != this->unk_37C) { this->unk_37C = arg1; - ret = SubS_ChangeAnimationByInfoS(&this->skelAnime, D_80A8B2D8, arg1); + ret = SubS_ChangeAnimationByInfoS(&this->skelAnime, sAnimationInfo, arg1); this->unk_358 = this->skelAnime.playSpeed; } return ret; } -void func_80A8697C(EnTru* this, GlobalContext* globalCtx) { +void func_80A8697C(EnTru* this, PlayState* play) { this->collider.dim.worldSphere.radius = this->collider.dim.modelSphere.radius * this->collider.dim.scale; if (this->actor.draw != NULL) { - CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + CollisionCheck_SetOC(play, &play->colChkCtx, &this->collider.base); } } -s32 func_80A869DC(EnTru* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); +s32 func_80A869DC(EnTru* this, PlayState* play) { + Player* player = GET_PLAYER(play); Vec3f sp38; Vec3f sp2C; @@ -457,11 +455,11 @@ s32 func_80A869DC(EnTru* this, GlobalContext* globalCtx) { return true; } -s32 func_80A86B0C(EnTru* this, GlobalContext* globalCtx) { +s32 func_80A86B0C(EnTru* this, PlayState* play) { if (this->unk_34E & 8) { this->unk_34E &= ~0x10; this->unk_34E |= 0x20; - func_80A869DC(this, globalCtx); + func_80A869DC(this, play); } else if (this->unk_34E & 0x20) { this->unk_34E &= ~0x20; this->unk_366 = 0; @@ -475,12 +473,12 @@ s32 func_80A86B0C(EnTru* this, GlobalContext* globalCtx) { return true; } -s32 func_80A86BAC(EnTru* this, GlobalContext* globalCtx) { +s32 func_80A86BAC(EnTru* this, PlayState* play) { if (this->unk_34E & 0x400) { - Matrix_StatePush(); - func_8012C28C(globalCtx->state.gfxCtx); + Matrix_Push(); + func_8012C28C(play->state.gfxCtx); - OPEN_DISPS(globalCtx->state.gfxCtx); + OPEN_DISPS(play->state.gfxCtx); switch (this->unk_390) { case 1: @@ -496,32 +494,32 @@ 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); + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(play->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); + CLOSE_DISPS(play->state.gfxCtx); } if (this->unk_34E & 0x800) { - Matrix_StatePush(); - func_8012C2DC(globalCtx->state.gfxCtx); + Matrix_Push(); + func_8012C2DC(play->state.gfxCtx); - OPEN_DISPS(globalCtx->state.gfxCtx); + OPEN_DISPS(play->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); + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(play->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); + CLOSE_DISPS(play->state.gfxCtx); } return false; @@ -580,7 +578,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 { @@ -636,7 +633,7 @@ s32 func_80A86DB8(EnTru* this) { return false; } -UNK_TYPE* func_80A871E0(EnTru* this, GlobalContext* globalCtx) { +UNK_TYPE* func_80A871E0(EnTru* this, PlayState* play) { if (this->unk_34E & 0x2000) { if (this->unk_38C == 35) { this->unk_390 = 1; @@ -665,12 +662,12 @@ UNK_TYPE* func_80A871E0(EnTru* this, GlobalContext* globalCtx) { return D_80A8892C; } -s32 func_80A872AC(EnTru* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); +s32 func_80A872AC(EnTru* this, PlayState* play) { + Player* player = GET_PLAYER(play); s32 ret = false; if (this->unk_34E & 7) { - if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { + if (Actor_ProcessTalkRequest(&this->actor, &play->state)) { if (player->transformation == PLAYER_FORM_HUMAN) { this->unk_34E &= ~0x80; } @@ -686,7 +683,7 @@ s32 func_80A872AC(EnTru* this, GlobalContext* globalCtx) { this->unk_378 = func_80A875AC; this->unk_390 = 0; this->unk_364 = 0; - this->unk_354 = func_80A871E0(this, globalCtx); + this->unk_354 = func_80A871E0(this, play); SubS_UpdateFlags(&this->unk_34E, 0, 7); this->actionFunc = func_80A881E0; ret = true; @@ -708,7 +705,7 @@ s32 func_80A873B8(EnTru* this) { return ret; } -s32 func_80A87400(EnTru* this, GlobalContext* globalCtx) { +s32 func_80A87400(EnTru* this, PlayState* play) { Vec3s* sp4C; Vec3f sp40; Vec3f sp34; @@ -747,7 +744,7 @@ s32 func_80A87400(EnTru* this, GlobalContext* globalCtx) { return ret; } -s32 func_80A875AC(Actor* thisx, GlobalContext* globalCtx) { +s32 func_80A875AC(Actor* thisx, PlayState* play) { EnTru* this = THIS; s32 ret = false; @@ -806,41 +803,43 @@ s32 func_80A875AC(Actor* thisx, GlobalContext* globalCtx) { return ret; } -s32 func_80A8777C(Actor* thisx, GlobalContext* globalCtx) { +s32 func_80A8777C(Actor* thisx, PlayState* play) { EnTru* this = THIS; s32 ret = 0; - s32 temp_v0 = Message_GetState(&globalCtx->msgCtx); + s32 temp_v0; - switch (temp_v0) { - 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; + switch (Message_GetState(&play->msgCtx)) { + case TEXT_STATE_CHOICE: + case TEXT_STATE_5: + if (!Message_ShouldAdvance(play)) { + break; } + // Fallthrough + case TEXT_STATE_16: + temp_v0 = func_80123810(play); + if ((temp_v0 == 35) || (temp_v0 == 36)) { + this->unk_34E |= 8; + if (temp_v0 == 35) { + this->unk_390 = 1; + } else { + this->unk_390 = 2; + } + this->unk_378 = func_80A87880; + this->unk_364 = 0; + ret = 1; + } else if (temp_v0 < 0) { + ret = 3; + } else if (temp_v0 != 0) { + ret = 2; + } + break; } return ret; } -s32 func_80A87880(Actor* thisx, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); +s32 func_80A87880(Actor* thisx, PlayState* play) { + Player* player = GET_PLAYER(play); EnTru* this = THIS; s32 ret = false; @@ -879,7 +878,7 @@ s32 func_80A87880(Actor* thisx, GlobalContext* globalCtx) { } else if (Animation_OnFrame(&this->skelAnime, 12.0f) && !(this->unk_34E & 0x800)) { this->unk_34E |= 0x400; this->unk_34E |= 0x800; - func_80123AA4(player, 3); + Player_SetModels(player, 3); } break; @@ -892,7 +891,7 @@ s32 func_80A87880(Actor* thisx, GlobalContext* globalCtx) { Animation_OnFrame(&this->skelAnime, 52.0f)) { if (Animation_OnFrame(&this->skelAnime, 52.0f)) { this->unk_34E &= ~0x400; - func_80123D50(globalCtx, player, 18, 21); + func_80123D50(play, player, 18, 21); } Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_KOUME_DRINK); } else if (Animation_OnFrame(&this->skelAnime, 90.0f)) { @@ -913,9 +912,9 @@ s32 func_80A87880(Actor* thisx, GlobalContext* globalCtx) { return ret; } -s32 func_80A87B48(Actor* thisx, GlobalContext* globalCtx) { +s32 func_80A87B48(Actor* thisx, PlayState* play) { EnTru* this = THIS; - Player* player = GET_PLAYER(globalCtx); + Player* player = GET_PLAYER(play); Vec3f sp4C; Vec3f sp40; s16 sp3E; @@ -930,12 +929,12 @@ s32 func_80A87B48(Actor* thisx, GlobalContext* globalCtx) { case 1: if (Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) { - sp3E = BINANG_ROT180(Camera_GetCamDirYaw(GET_ACTIVE_CAM(globalCtx))); + sp3E = BINANG_ROT180(Camera_GetCamDirYaw(GET_ACTIVE_CAM(play))); 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->state, 1, 160, 160, 160, 0); + func_8016A268(&play->state, 1, 160, 160, 160, 0); this->unk_370 = 20; this->unk_372 = 10; this->unk_364++; @@ -972,7 +971,7 @@ s32 func_80A87B48(Actor* thisx, GlobalContext* globalCtx) { return ret; } -s32 func_80A87DC0(Actor* thisx, GlobalContext* globalCtx) { +s32 func_80A87DC0(Actor* thisx, PlayState* play) { EnTru* this = THIS; s32 ret = false; @@ -995,7 +994,7 @@ s32 func_80A87DC0(Actor* thisx, GlobalContext* globalCtx) { break; case 2: - func_801A75E8(NA_SE_EN_KOUME_MAGIC); + AudioSfx_StopById(NA_SE_EN_KOUME_MAGIC); Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_KOUME_AWAY); Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_KOUME_LAUGH); func_80A86924(this, 13); @@ -1008,7 +1007,7 @@ s32 func_80A87DC0(Actor* thisx, GlobalContext* globalCtx) { case 3: if (!Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) { - AnimationContext_SetMoveActor(globalCtx, &this->actor, &this->skelAnime, 1.0f); + AnimationContext_SetMoveActor(play, &this->actor, &this->skelAnime, 1.0f); break; } else { func_80A86924(this, 14); @@ -1018,7 +1017,7 @@ s32 func_80A87DC0(Actor* thisx, GlobalContext* globalCtx) { } case 4: - if (func_80A87400(this, globalCtx) || (DECR(this->unk_362) == 0)) { + if (func_80A87400(this, play) || (DECR(this->unk_362) == 0)) { ret = true; gSaveContext.save.weekEventReg[12] |= 8; } @@ -1035,7 +1034,7 @@ s32 func_80A87DC0(Actor* thisx, GlobalContext* globalCtx) { return ret; } -void func_80A87FD0(EnTru* this, GlobalContext* globalCtx) { +void func_80A87FD0(EnTru* this, PlayState* play) { if (this->actor.draw != NULL) { if ((this->unk_34E & 0x80) || (gSaveContext.save.weekEventReg[16] & 0x10)) { if (func_80A873B8(this)) { @@ -1072,10 +1071,10 @@ void func_80A87FD0(EnTru* this, GlobalContext* globalCtx) { } } -void func_80A881E0(EnTru* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); +void func_80A881E0(EnTru* this, PlayState* play) { + Player* player = GET_PLAYER(play); - if (func_8010BF58(&this->actor, globalCtx, this->unk_354, this->unk_378, &this->unk_1E8)) { + if (func_8010BF58(&this->actor, play, this->unk_354, this->unk_378, &this->unk_1E8)) { if (player->transformation != PLAYER_FORM_HUMAN) { this->unk_34E |= 0x80; } @@ -1103,22 +1102,21 @@ void func_80A881E0(EnTru* this, GlobalContext* globalCtx) { } } -void EnTru_Init(Actor* thisx, GlobalContext* globalCtx) { +void EnTru_Init(Actor* thisx, PlayState* play) { EnTru* this = THIS; - if ((gSaveContext.save.entranceIndex != 0xC200) || (gSaveContext.save.weekEventReg[12] & 8)) { + if ((gSaveContext.save.entrance != 0xC200) || (gSaveContext.save.weekEventReg[12] & 8)) { 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, - 27); - Collider_InitAndSetSphere(globalCtx, &this->collider, &this->actor, &sSphereInit); + SkelAnime_InitFlex(play, &this->skelAnime, &object_tru_Skel_01AA60, NULL, this->jointTable, this->morphTable, 27); + Collider_InitAndSetSphere(play, &this->collider, &this->actor, &sSphereInit); CollisionCheck_SetInfo2(&this->actor.colChkInfo, DamageTable_Get(0x16), &sColChkInfoInit); this->unk_37C = -1; func_80A86924(this, 0); - this->path = SubS_GetDayDependentPath(globalCtx, ENTRU_GET_PATH(&this->actor), 255, &this->unk_384); + this->path = SubS_GetDayDependentPath(play, ENTRU_GET_PATH(&this->actor), 255, &this->unk_384); if (this->path != NULL) { this->unk_384 = 1; } @@ -1130,51 +1128,51 @@ void EnTru_Init(Actor* thisx, GlobalContext* globalCtx) { if (gSaveContext.save.weekEventReg[16] & 0x10) { func_80A86924(this, 5); } else { - this->unk_388 = 0; + this->unk_388 = PLAYER_AP_NONE; } this->actionFunc = func_80A87FD0; - Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 0.0f, 0.0f, 0.0f, 4); + Actor_UpdateBgCheckInfo(play, &this->actor, 0.0f, 0.0f, 0.0f, 4); } -void EnTru_Destroy(Actor* thisx, GlobalContext* globalCtx) { +void EnTru_Destroy(Actor* thisx, PlayState* play) { EnTru* this = THIS; - Collider_DestroySphere(globalCtx, &this->collider); + Collider_DestroySphere(play, &this->collider); } -void EnTru_Update(Actor* thisx, GlobalContext* globalCtx) { +void EnTru_Update(Actor* thisx, PlayState* play) { EnTru* this = THIS; f32 radius; - func_80A872AC(this, globalCtx); + func_80A872AC(this, play); - this->actionFunc(this, globalCtx); + this->actionFunc(this, play); func_80A868F8(this); - func_80A86B0C(this, globalCtx); + func_80A86B0C(this, play); 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) ? PLAYER_AP_NONE : PLAYER_AP_NONE; - func_8013C964(&this->actor, globalCtx, radius, 20.0f, this->unk_388, this->unk_34E & 7); - func_80A8697C(this, globalCtx); + func_8013C964(&this->actor, play, radius, 20.0f, this->unk_388, this->unk_34E & 7); + func_80A8697C(this, play); func_80A86384(this->unk_394, &this->unk_1F8); } -s32 EnTru_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, Actor* thisx) { +s32 EnTru_OverrideLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, Actor* thisx) { s32 pad; 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)) { @@ -1184,56 +1182,56 @@ s32 EnTru_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, return false; } -void EnTru_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx) { +void EnTru_PostLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx) { EnTru* this = THIS; if (limbIndex == 19) { - func_80A86BAC(this, globalCtx); + func_80A86BAC(this, play); } } -void EnTru_TransformLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Actor* thisx) { +void EnTru_TransformLimbDraw(PlayState* play, 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(); } } -void EnTru_Draw(Actor* thisx, GlobalContext* globalCtx) { +void EnTru_Draw(Actor* thisx, PlayState* play) { static TexturePtr D_80A8B408[] = { object_tru_Tex_018FA0, object_tru_Tex_0197A0, @@ -1243,19 +1241,19 @@ void EnTru_Draw(Actor* thisx, GlobalContext* globalCtx) { s32 pad; EnTru* this = THIS; - OPEN_DISPS(globalCtx->state.gfxCtx); + OPEN_DISPS(play->state.gfxCtx); - func_8012C28C(globalCtx->state.gfxCtx); + func_8012C28C(play->state.gfxCtx); gSPSegment(POLY_OPA_DISP++, 0x08, Lib_SegmentedToVirtual(D_80A8B408[this->unk_36E])); gSPSegment(POLY_OPA_DISP++, 0x09, Lib_SegmentedToVirtual(D_80A8B408[this->unk_36E])); - SkelAnime_DrawTransformFlexOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, + SkelAnime_DrawTransformFlexOpa(play, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, EnTru_OverrideLimbDraw, EnTru_PostLimbDraw, EnTru_TransformLimbDraw, &this->actor); - func_80A85788(this->unk_394, globalCtx); - func_80A85BCC(this->unk_394, globalCtx); - func_80A85F84(this->unk_394, globalCtx); + func_80A85788(this->unk_394, play); + func_80A85BCC(this->unk_394, play); + func_80A85F84(this->unk_394, play); - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->state.gfxCtx); } 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 d1090cec4..7e1c23380 100644 --- a/src/overlays/actors/ovl_En_Tru/z_en_tru.h +++ b/src/overlays/actors/ovl_En_Tru/z_en_tru.h @@ -5,8 +5,8 @@ struct EnTru; -typedef void (*EnTruActionFunc)(struct EnTru*, GlobalContext*); -typedef s32 (*EnTruUnkFunc)(Actor*, GlobalContext*); +typedef void (*EnTruActionFunc)(struct EnTru*, PlayState*); +typedef s32 (*EnTruUnkFunc)(Actor*, PlayState*); #define ENTRU_GET_PATH(thisx) ((thisx)->params & 0xFF) @@ -22,41 +22,41 @@ typedef struct { } EnTruUnkStruct; // size = 0x30 typedef struct EnTru { - /* 0x0000 */ Actor actor; - /* 0x0144 */ SkelAnime skelAnime; - /* 0x0188 */ EnTruActionFunc actionFunc; - /* 0x018C */ ColliderSphere collider; - /* 0x01E4 */ Path* path; - /* 0x01E8 */ s32 unk_1E8; - /* 0x01EC */ Vec3f unk_1EC; - /* 0x01F8 */ Vec3f unk_1F8; - /* 0x0204 */ Vec3s unk_204; - /* 0x020A */ Vec3s jointTable[27]; - /* 0x02AC */ Vec3s morphTable[27]; - /* 0x034E */ u16 unk_34E; - /* 0x0350 */ UNK_TYPE1 unk350[0x4]; - /* 0x0354 */ s32* unk_354; - /* 0x0358 */ f32 unk_358; - /* 0x035C */ f32 unk_35C; - /* 0x0360 */ s16 unk_360; - /* 0x0362 */ s16 unk_362; - /* 0x0364 */ s16 unk_364; - /* 0x0366 */ s16 unk_366; - /* 0x0368 */ s16 unk_368; - /* 0x036A */ s16 unk_36A; - /* 0x036C */ s16 unk_36C; - /* 0x036E */ s16 unk_36E; - /* 0x0370 */ s16 unk_370; - /* 0x0372 */ s16 unk_372; - /* 0x0374 */ s16 unk_374; - /* 0x0378 */ EnTruUnkFunc unk_378; - /* 0x037C */ s32 unk_37C; - /* 0x0380 */ UNK_TYPE1 unk380[0x4]; - /* 0x0384 */ s32 unk_384; - /* 0x0388 */ s32 unk_388; - /* 0x038C */ s32 unk_38C; - /* 0x0390 */ s32 unk_390; - /* 0x0394 */ EnTruUnkStruct unk_394[30]; + /* 0x000 */ Actor actor; + /* 0x144 */ SkelAnime skelAnime; + /* 0x188 */ EnTruActionFunc actionFunc; + /* 0x18C */ ColliderSphere collider; + /* 0x1E4 */ Path* path; + /* 0x1E8 */ s32 unk_1E8; + /* 0x1EC */ Vec3f unk_1EC; + /* 0x1F8 */ Vec3f unk_1F8; + /* 0x204 */ Vec3s unk_204; + /* 0x20A */ Vec3s jointTable[27]; + /* 0x2AC */ Vec3s morphTable[27]; + /* 0x34E */ u16 unk_34E; + /* 0x350 */ UNK_TYPE1 unk350[0x4]; + /* 0x354 */ s32* unk_354; + /* 0x358 */ f32 unk_358; + /* 0x35C */ f32 unk_35C; + /* 0x360 */ s16 unk_360; + /* 0x362 */ s16 unk_362; + /* 0x364 */ s16 unk_364; + /* 0x366 */ s16 unk_366; + /* 0x368 */ s16 unk_368; + /* 0x36A */ s16 unk_36A; + /* 0x36C */ s16 unk_36C; + /* 0x36E */ s16 unk_36E; + /* 0x370 */ s16 unk_370; + /* 0x372 */ s16 unk_372; + /* 0x374 */ s16 unk_374; + /* 0x378 */ EnTruUnkFunc unk_378; + /* 0x37C */ s32 unk_37C; + /* 0x380 */ UNK_TYPE1 unk380[0x4]; + /* 0x384 */ s32 unk_384; + /* 0x388 */ s32 unk_388; + /* 0x38C */ s32 unk_38C; + /* 0x390 */ s32 unk_390; + /* 0x394 */ EnTruUnkStruct unk_394[30]; } EnTru; // size = 0x934 extern const ActorInit En_Tru_InitVars; diff --git a/src/overlays/actors/ovl_En_Tru_Mt/z_en_tru_mt.c b/src/overlays/actors/ovl_En_Tru_Mt/z_en_tru_mt.c index e191cc3cd..ac772a940 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 @@ -11,14 +11,14 @@ #define THIS ((EnTruMt*)thisx) -void EnTruMt_Init(Actor* thisx, GlobalContext* globalCtx); -void EnTruMt_Destroy(Actor* thisx, GlobalContext* globalCtx); -void EnTruMt_Update(Actor* thisx, GlobalContext* globalCtx); -void EnTruMt_Draw(Actor* thisx, GlobalContext* globalCtx); +void EnTruMt_Init(Actor* thisx, PlayState* play); +void EnTruMt_Destroy(Actor* thisx, PlayState* play); +void EnTruMt_Update(Actor* thisx, PlayState* play); +void EnTruMt_Draw(Actor* thisx, PlayState* play); -void func_80B76A64(EnTruMt* this, GlobalContext* globalCtx); -void func_80B76BB8(EnTruMt* this, GlobalContext* globalCtx); -void func_80B76C38(EnTruMt* this, GlobalContext* globalCtx); +void func_80B76A64(EnTruMt* this, PlayState* play); +void func_80B76BB8(EnTruMt* this, PlayState* play); +void func_80B76C38(EnTruMt* this, PlayState* play); const ActorInit En_Tru_Mt_InitVars = { ACTOR_EN_TRU_MT, @@ -87,7 +87,7 @@ static DamageTable sDamageTable = { /* Powder Keg */ DMG_ENTRY(1, 0x0), }; -static AnimationInfoS D_80B7755C[] = { +static AnimationInfoS sAnimationInfo[] = { { &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 }, @@ -115,19 +115,19 @@ s32 func_80B76030(SkelAnime* skelAnime, s16 arg1) { s16 startFrame; s32 ret = false; - if ((arg1 >= 0) && (arg1 < ARRAY_COUNT(D_80B7755C))) { - endFrame = D_80B7755C[arg1].frameCount; + if ((arg1 >= 0) && (arg1 < ARRAY_COUNT(sAnimationInfo))) { + endFrame = sAnimationInfo[arg1].frameCount; if (endFrame < 0) { - endFrame = Animation_GetLastFrame(D_80B7755C[arg1].animation); + endFrame = Animation_GetLastFrame(sAnimationInfo[arg1].animation); } - startFrame = D_80B7755C[arg1].startFrame; + startFrame = sAnimationInfo[arg1].startFrame; if (startFrame < 0) { - startFrame = Animation_GetLastFrame(D_80B7755C[arg1].animation); + startFrame = Animation_GetLastFrame(sAnimationInfo[arg1].animation); } - Animation_Change(skelAnime, D_80B7755C[arg1].animation, D_80B7755C[arg1].playSpeed, startFrame, endFrame, - D_80B7755C[arg1].mode, D_80B7755C[arg1].morphFrames); + Animation_Change(skelAnime, sAnimationInfo[arg1].animation, sAnimationInfo[arg1].playSpeed, startFrame, + endFrame, sAnimationInfo[arg1].mode, sAnimationInfo[arg1].morphFrames); ret = true; } return ret; @@ -149,7 +149,7 @@ void func_80B76188(EnTruMt* this) { Math_SmoothStepToS(&this->unk_38C, 0, 4, 0x3E8, 1); } -s32 func_80B761FC(EnTruMt* this, GlobalContext* globalCtx) { +s32 func_80B761FC(EnTruMt* this, PlayState* play) { this->collider.dim.worldSphere.center.x = this->actor.world.pos.x; this->collider.dim.worldSphere.center.y = this->actor.world.pos.y + 16.0f; this->collider.dim.worldSphere.center.z = this->actor.world.pos.z; @@ -165,7 +165,7 @@ s32 func_80B761FC(EnTruMt* this, GlobalContext* globalCtx) { this->unk_3A4 = 0; Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_KOUME_DAMAGE2); } - globalCtx->interfaceCtx.unk_25E = 1; + play->interfaceCtx.unk_25E = 1; Actor_SetColorFilter(&this->actor, 0x4000, 255, 0, 25); return true; } @@ -177,13 +177,13 @@ s32 func_80B761FC(EnTruMt* this, GlobalContext* globalCtx) { this->unk_38E.x = 0; } - CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); - CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + CollisionCheck_SetOC(play, &play->colChkCtx, &this->collider.base); + CollisionCheck_SetAC(play, &play->colChkCtx, &this->collider.base); return false; } -s32 func_80B76368(EnTruMt* this, GlobalContext* globalCtx) { - Actor* bgActor = globalCtx->actorCtx.actorLists[ACTORCAT_BG].first; +s32 func_80B76368(EnTruMt* this, PlayState* play) { + Actor* bgActor = play->actorCtx.actorLists[ACTORCAT_BG].first; while (bgActor != NULL) { if (bgActor->id == ACTOR_BG_INGATE) { @@ -197,12 +197,12 @@ s32 func_80B76368(EnTruMt* this, GlobalContext* globalCtx) { return false; } -s32 func_80B763C4(EnTruMt* this, GlobalContext* globalCtx) { +s32 func_80B763C4(EnTruMt* this, PlayState* play) { Actor* foundActor; Actor* actor = NULL; while (true) { - foundActor = SubS_FindActor(globalCtx, actor, ACTORCAT_NPC, ACTOR_EN_TRU_MT); + foundActor = SubS_FindActor(play, actor, ACTORCAT_NPC, ACTOR_EN_TRU_MT); if (foundActor == NULL) { break; @@ -222,8 +222,8 @@ s32 func_80B763C4(EnTruMt* this, GlobalContext* globalCtx) { return false; } -void func_80B76440(EnTruMt* this, GlobalContext* globalCtx) { - if (func_80B76368(this, globalCtx)) { +void func_80B76440(EnTruMt* this, PlayState* play) { + if (func_80B76368(this, play)) { s16 temp_v1 = this->unk_394 - Math_Vec3f_Yaw(&this->unk_398, &this->actor.world.pos); if ((temp_v1 <= -0x2000) || (temp_v1 >= 0x2000)) { @@ -289,8 +289,8 @@ s32 func_80B76600(EnTruMt* this, Path* path, s32 arg2) { return sp50; } -void func_80B7679C(EnTruMt* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); +void func_80B7679C(EnTruMt* this, PlayState* play) { + Player* player = GET_PLAYER(play); Vec3f sp40; Vec3f sp34; @@ -307,9 +307,9 @@ void func_80B7679C(EnTruMt* this, GlobalContext* globalCtx) { this->unk_348 = CLAMP(this->unk_348, -0x1C70, 0x1C70); } -s32 func_80B768F0(EnTruMt* this, GlobalContext* globalCtx) { +s32 func_80B768F0(EnTruMt* this, PlayState* play) { if (this->unk_328 & 0x10) { - func_80B7679C(this, globalCtx); + func_80B7679C(this, play); } return true; } @@ -319,11 +319,11 @@ void func_80B76924(EnTruMt* this) { this->unk_388 += 0x400; } -void func_80B76980(EnTruMt* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); +void func_80B76980(EnTruMt* this, PlayState* play) { + Player* player = GET_PLAYER(play); if (gSaveContext.unk_3F3C >= 10) { - Message_StartTextbox(globalCtx, 0x87F, &this->actor); + Message_StartTextbox(play, 0x87F, &this->actor); gSaveContext.eventInf[3] |= 0x40; gSaveContext.eventInf[4] |= 1; player->stateFlags3 &= ~0x400; @@ -340,12 +340,12 @@ void func_80B76980(EnTruMt* this, GlobalContext* globalCtx) { } } -void func_80B76A64(EnTruMt* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); +void func_80B76A64(EnTruMt* this, PlayState* play) { + Player* player = GET_PLAYER(play); Vec3s sp34; func_80B76924(this); - func_80B76980(this, globalCtx); + func_80B76980(this, play); player->stateFlags3 |= 0x400; if (this->path != NULL) { @@ -366,30 +366,30 @@ void func_80B76A64(EnTruMt* this, GlobalContext* globalCtx) { } this->unk_36C++; } - func_80B76440(this, globalCtx); + func_80B76440(this, play); } } -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_80B76BB8(EnTruMt* this, PlayState* play) { + if (Message_GetState(&play->msgCtx) == TEXT_STATE_5) { + if (Message_ShouldAdvance(play)) { + play->nextEntrance = ENTRANCE(TOURIST_INFORMATION, 1); + play->transitionType = TRANS_TYPE_03; + gSaveContext.nextTransitionType = TRANS_TYPE_03; + play->transitionTrigger = TRANS_TRIGGER_START; } } } -void func_80B76C38(EnTruMt* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); +void func_80B76C38(EnTruMt* this, PlayState* play) { + Player* player = GET_PLAYER(play); func_80B76924(this); - func_80B76980(this, globalCtx); + func_80B76980(this, play); player->stateFlags3 |= 0x400; } -void EnTruMt_Init(Actor* thisx, GlobalContext* globalCtx) { +void EnTruMt_Init(Actor* thisx, PlayState* play) { s32 pad; EnTruMt* this = THIS; @@ -398,52 +398,52 @@ void EnTruMt_Init(Actor* thisx, GlobalContext* globalCtx) { return; } - if (func_80B763C4(this, globalCtx)) { + if (func_80B763C4(this, play)) { 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, + SkelAnime_InitFlex(play, &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); + Collider_InitSphere(play, &this->collider); + Collider_SetSphere(play, &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->path = SubS_GetPathByIndex(play, 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); + Actor_UpdateBgCheckInfo(play, &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); + this->path = SubS_GetPathByIndex(play, ENTRUMT_GET_FC00(&this->actor), 0x3F); func_80B76030(&this->skelAnime, 14); this->actionFunc = func_80B76A64; } -void EnTruMt_Destroy(Actor* thisx, GlobalContext* globalCtx) { +void EnTruMt_Destroy(Actor* thisx, PlayState* play) { EnTruMt* this = THIS; - Collider_DestroySphere(globalCtx, &this->collider); + Collider_DestroySphere(play, &this->collider); } -void EnTruMt_Update(Actor* thisx, GlobalContext* globalCtx) { +void EnTruMt_Update(Actor* thisx, PlayState* play) { EnTruMt* this = THIS; - func_80B768F0(this, globalCtx); + func_80B768F0(this, play); SkelAnime_Update(&this->skelAnime); - this->actionFunc(this, globalCtx); + this->actionFunc(this, play); func_80B76110(this); Actor_SetFocus(&this->actor, 34.0f); if (!(gSaveContext.eventInf[4] & 1)) { - func_80B761FC(this, globalCtx); + func_80B761FC(this, play); } Actor_MoveWithoutGravity(&this->actor); @@ -455,9 +455,9 @@ void func_80B76ED4(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; @@ -474,21 +474,20 @@ void func_80B76ED4(s16 arg0, s16 arg1, Vec3f* arg2, Vec3s* arg3, s32 arg4) { } } -s32 EnTruMt_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, - Actor* thisx) { +s32 EnTruMt_OverrideLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, Actor* thisx) { EnTruMt* this = THIS; if (limbIndex == OBJECT_TRU_LIMB_15) { - Matrix_MultiplyVector3fByState(&gZeroVec3f, &this->unk_35C); + Matrix_MultVec3f(&gZeroVec3f, &this->unk_35C); } if (limbIndex == OBJECT_TRU_LIMB_15) { - Matrix_MultiplyVector3fByState(&D_80B7765C, &this->unk_350); + Matrix_MultVec3f(&D_80B7765C, &this->unk_350); } return false; } -void EnTruMt_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx) { +void EnTruMt_PostLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx) { s32 pad; EnTruMt* this = THIS; MtxF* sp54; @@ -501,61 +500,61 @@ void EnTruMt_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, phi_v0 = 0; } func_80B76ED4(this->unk_348, this->unk_34A, &this->unk_33C, &this->unk_336, phi_v0); - Matrix_InsertTranslation(this->unk_33C.x, this->unk_33C.y, this->unk_33C.z, MTXMODE_NEW); + Matrix_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_RotateY(this->unk_336.y, MTXMODE_APPLY); - Matrix_InsertXRotation_s(this->unk_336.x, MTXMODE_APPLY); - Matrix_InsertZRotation_s(this->unk_336.z, MTXMODE_APPLY); + 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); + func_8012C28C(play->state.gfxCtx); - OPEN_DISPS(globalCtx->state.gfxCtx); + OPEN_DISPS(play->state.gfxCtx); - Matrix_MultiplyVector3fByState(&D_80B77668, &this->unk_370); - Matrix_InsertTranslation(this->unk_370.x, this->unk_370.y, this->unk_370.z, MTXMODE_NEW); - Matrix_RotateY(BINANG_ROT180(Camera_GetCamDirYaw(GET_ACTIVE_CAM(globalCtx))), MTXMODE_APPLY); - Matrix_InsertZRotation_s(this->unk_38E.z, MTXMODE_APPLY); - Matrix_InsertXRotation_s(this->unk_38E.x, MTXMODE_APPLY); + Matrix_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(play))), 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); + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_OPA_DISP++, object_tru_DL_0004C8); - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->state.gfxCtx); - sp54 = Matrix_GetCurrentState(); + 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->wx, sp54->wy, - sp54->wz, this->unk_38E.x, BINANG_ROT180(Camera_GetCamDirYaw(GET_ACTIVE_CAM(globalCtx))), + Actor_SpawnAsChild(&play->actorCtx, &this->actor, play, ACTOR_EN_JC_MATO, sp54->xw, sp54->yw, sp54->zw, + this->unk_38E.x, BINANG_ROT180(Camera_GetCamDirYaw(GET_ACTIVE_CAM(play))), this->unk_38E.z, -1); } else if (!((EnJcMato*)this->actor.child)->hitFlag) { - this->actor.child->world.pos.x = sp54->wx; - this->actor.child->world.pos.y = sp54->wy; - this->actor.child->world.pos.z = sp54->wz; + this->actor.child->world.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->world.rot.y = BINANG_ROT180(Camera_GetCamDirYaw(GET_ACTIVE_CAM(play))); this->actor.child->shape.rot = this->actor.child->world.rot; } } } -void EnTruMt_TransformLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Actor* thisx) { +void EnTruMt_TransformLimbDraw(PlayState* play, s32 limbIndex, Actor* thisx) { EnTruMt* this = THIS; if (limbIndex == OBJECT_TRU_LIMB_15) { - Matrix_InsertTranslation(this->unk_33C.x, this->unk_33C.y, this->unk_33C.z, MTXMODE_NEW); + Matrix_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_RotateY(this->unk_336.y, MTXMODE_APPLY); - Matrix_InsertXRotation_s(this->unk_336.x, MTXMODE_APPLY); - Matrix_InsertZRotation_s(this->unk_336.z, MTXMODE_APPLY); + 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) { +void EnTruMt_Draw(Actor* thisx, PlayState* play) { EnTruMt* this = THIS; TexturePtr sp48[] = { object_tru_Tex_018FA0, @@ -563,16 +562,16 @@ void EnTruMt_Draw(Actor* thisx, GlobalContext* globalCtx) { object_tru_Tex_019FA0, }; - OPEN_DISPS(globalCtx->state.gfxCtx); + OPEN_DISPS(play->state.gfxCtx); - func_8012C28C(globalCtx->state.gfxCtx); + func_8012C28C(play->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, + SkelAnime_DrawTransformFlexOpa(play, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, EnTruMt_OverrideLimbDraw, EnTruMt_PostLimbDraw, EnTruMt_TransformLimbDraw, &this->actor); - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->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 049c11ecd..670d0d728 100644 --- a/src/overlays/actors/ovl_En_Tru_Mt/z_en_tru_mt.h +++ b/src/overlays/actors/ovl_En_Tru_Mt/z_en_tru_mt.h @@ -6,39 +6,39 @@ struct EnTruMt; -typedef void (*EnTruMtActionFunc)(struct EnTruMt*, GlobalContext*); +typedef void (*EnTruMtActionFunc)(struct EnTruMt*, PlayState*); #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 */ SkelAnime skelAnime; - /* 0x018C */ ColliderSphere collider; - /* 0x01E4 */ Vec3s jointTable[OBJECT_TRU_LIMB_MAX]; - /* 0x0286 */ Vec3s morphTable[OBJECT_TRU_LIMB_MAX]; - /* 0x0328 */ u16 unk_328; - /* 0x032A */ UNK_TYPE1 unk32A[0xC]; - /* 0x0336 */ Vec3s unk_336; - /* 0x033C */ Vec3f unk_33C; - /* 0x0348 */ s16 unk_348; - /* 0x034A */ s16 unk_34A; - /* 0x034C */ s16 unk_34C; - /* 0x034E */ s16 unk_34E; - /* 0x0350 */ Vec3f unk_350; - /* 0x035C */ Vec3f unk_35C; - /* 0x0368 */ Path* path; - /* 0x036C */ s32 unk_36C; - /* 0x0370 */ Vec3f unk_370; - /* 0x037C */ UNK_TYPE1 unk37C[0xC]; - /* 0x0388 */ s16 unk_388; - /* 0x038A */ s16 unk_38A; - /* 0x038C */ s16 unk_38C; - /* 0x038E */ Vec3s unk_38E; - /* 0x0394 */ s16 unk_394; - /* 0x0398 */ Vec3f unk_398; - /* 0x03A4 */ u8 unk_3A4; + /* 0x000 */ Actor actor; + /* 0x144 */ EnTruMtActionFunc actionFunc; + /* 0x148 */ SkelAnime skelAnime; + /* 0x18C */ ColliderSphere collider; + /* 0x1E4 */ Vec3s jointTable[OBJECT_TRU_LIMB_MAX]; + /* 0x286 */ Vec3s morphTable[OBJECT_TRU_LIMB_MAX]; + /* 0x328 */ u16 unk_328; + /* 0x32A */ UNK_TYPE1 unk32A[0xC]; + /* 0x336 */ Vec3s unk_336; + /* 0x33C */ Vec3f unk_33C; + /* 0x348 */ s16 unk_348; + /* 0x34A */ s16 unk_34A; + /* 0x34C */ s16 unk_34C; + /* 0x34E */ s16 unk_34E; + /* 0x350 */ Vec3f unk_350; + /* 0x35C */ Vec3f unk_35C; + /* 0x368 */ Path* path; + /* 0x36C */ s32 unk_36C; + /* 0x370 */ Vec3f unk_370; + /* 0x37C */ UNK_TYPE1 unk37C[0xC]; + /* 0x388 */ s16 unk_388; + /* 0x38A */ s16 unk_38A; + /* 0x38C */ s16 unk_38C; + /* 0x38E */ Vec3s unk_38E; + /* 0x394 */ s16 unk_394; + /* 0x398 */ Vec3f unk_398; + /* 0x3A4 */ u8 unk_3A4; } EnTruMt; // size = 0x3A8 extern const ActorInit En_Tru_Mt_InitVars; diff --git a/src/overlays/actors/ovl_En_Tsn/z_en_tsn.c b/src/overlays/actors/ovl_En_Tsn/z_en_tsn.c index e999e5c5c..15d4cf3e5 100644 --- a/src/overlays/actors/ovl_En_Tsn/z_en_tsn.c +++ b/src/overlays/actors/ovl_En_Tsn/z_en_tsn.c @@ -5,28 +5,29 @@ */ #include "z_en_tsn.h" +#include "z64snap.h" #include "objects/object_tsn/object_tsn.h" #define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_8 | ACTOR_FLAG_10 | ACTOR_FLAG_2000000) #define THIS ((EnTsn*)thisx) -void EnTsn_Init(Actor* thisx, GlobalContext* globalCtx); -void EnTsn_Destroy(Actor* thisx, GlobalContext* globalCtx); -void EnTsn_Update(Actor* thisx, GlobalContext* globalCtx); -void EnTsn_Draw(Actor* thisx, GlobalContext* globalCtx); +void EnTsn_Init(Actor* thisx, PlayState* play); +void EnTsn_Destroy(Actor* thisx, PlayState* play); +void EnTsn_Update(Actor* thisx, PlayState* play); +void EnTsn_Draw(Actor* thisx, PlayState* play); -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); +void func_80AE0010(EnTsn* this, PlayState* play); +void func_80AE0304(EnTsn* this, PlayState* play); +void func_80AE0418(EnTsn* this, PlayState* play); +void func_80AE0460(EnTsn* this, PlayState* play); +void func_80AE04C4(EnTsn* this, PlayState* play); +void func_80AE04FC(EnTsn* this, PlayState* play); +void func_80AE0704(EnTsn* this, PlayState* play); +void func_80AE0C88(EnTsn* this, PlayState* play); +void func_80AE0D10(EnTsn* this, PlayState* play); +void func_80AE0D78(EnTsn* this, PlayState* play); +void func_80AE0F84(Actor* thisx, PlayState* play); const ActorInit En_Tsn_InitVars = { ACTOR_EN_TSN, @@ -64,8 +65,8 @@ Vec3f D_80AE11BC = { 0.0f, 0.0f, 0.0f }; TexturePtr D_80AE11C8[] = { object_tsn_Tex_0073B8, object_tsn_Tex_0085B8 }; -EnTsn* func_80ADFCA0(GlobalContext* globalCtx) { - Actor* npc = globalCtx->actorCtx.actorLists[ACTORCAT_NPC].first; +EnTsn* func_80ADFCA0(PlayState* play) { + Actor* npc = play->actorCtx.actorLists[ACTORCAT_NPC].first; while (npc != NULL) { if ((npc->id == ACTOR_EN_TSN) && !ENTSN_GET_100(npc)) { @@ -77,7 +78,7 @@ EnTsn* func_80ADFCA0(GlobalContext* globalCtx) { return NULL; } -void func_80ADFCEC(EnTsn* this, GlobalContext* globalCtx) { +void func_80ADFCEC(EnTsn* this, PlayState* play) { this->actionFunc = func_80AE0C88; this->actor.update = func_80AE0F84; this->actor.destroy = NULL; @@ -111,29 +112,29 @@ void func_80ADFCEC(EnTsn* this, GlobalContext* globalCtx) { return; } - this->unk_1D8 = func_80ADFCA0(globalCtx); + this->unk_1D8 = func_80ADFCA0(play); this->unk_220 = 0; 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); + func_800BC154(play, &play->actorCtx, &this->actor, 6); } } -void EnTsn_Init(Actor* thisx, GlobalContext* globalCtx) { +void EnTsn_Init(Actor* thisx, PlayState* play) { EnTsn* this = THIS; if (ENTSN_GET_100(&this->actor)) { - func_80ADFCEC(this, globalCtx); + func_80ADFCEC(this, play); return; } 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); + SkelAnime_InitFlex(play, &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); + Collider_InitCylinder(play, &this->collider); + Collider_SetCylinder(play, &this->collider, &this->actor, &sCylinderInit); this->actor.colChkInfo.mass = MASS_IMMOVABLE; this->unk_220 = 0; @@ -148,13 +149,13 @@ void EnTsn_Init(Actor* thisx, GlobalContext* globalCtx) { } } -void EnTsn_Destroy(Actor* thisx, GlobalContext* globalCtx) { +void EnTsn_Destroy(Actor* thisx, PlayState* play) { EnTsn* this = THIS; - Collider_DestroyCylinder(globalCtx, &this->collider); + Collider_DestroyCylinder(play, &this->collider); } -void func_80ADFF84(EnTsn* this, GlobalContext* globalCtx) { +void func_80ADFF84(EnTsn* this, PlayState* play) { u16 textId; if (gSaveContext.save.weekEventReg[26] & 8) { @@ -171,11 +172,11 @@ void func_80ADFF84(EnTsn* this, GlobalContext* globalCtx) { textId = 0x1084; } - Message_StartTextbox(globalCtx, textId, &this->actor); + Message_StartTextbox(play, textId, &this->actor); } -void func_80AE0010(EnTsn* this, GlobalContext* globalCtx) { - switch (globalCtx->msgCtx.currentTextId) { +void func_80AE0010(EnTsn* this, PlayState* play) { + switch (play->msgCtx.currentTextId) { case 0x107F: case 0x1080: case 0x1081: @@ -193,47 +194,47 @@ void func_80AE0010(EnTsn* this, GlobalContext* globalCtx) { break; } - if ((Message_GetState(&globalCtx->msgCtx) == 5) && Message_ShouldAdvance(globalCtx)) { - switch (globalCtx->msgCtx.currentTextId) { + if ((Message_GetState(&play->msgCtx) == TEXT_STATE_5) && Message_ShouldAdvance(play)) { + switch (play->msgCtx.currentTextId) { case 0x107F: case 0x1081: - func_80151938(globalCtx, globalCtx->msgCtx.currentTextId + 1); + func_80151938(play, play->msgCtx.currentTextId + 1); break; case 0x1080: - func_80151938(globalCtx, globalCtx->msgCtx.currentTextId + 1); + func_80151938(play, play->msgCtx.currentTextId + 1); Animation_MorphToLoop(&this->skelAnime, &object_tsn_Anim_001198, -10.0f); break; case 0x1082: Animation_MorphToLoop(&this->skelAnime, &object_tsn_Anim_0092FC, -10.0f); gSaveContext.save.weekEventReg[25] |= 0x80; - func_801477B4(globalCtx); + func_801477B4(play); this->actionFunc = func_80AE0304; this->actor.textId = 0; break; case 0x1083: gSaveContext.save.weekEventReg[25] |= 0x80; - func_801477B4(globalCtx); + func_801477B4(play); this->actionFunc = func_80AE0304; this->actor.textId = 0; break; case 0x1084: - func_80151938(globalCtx, globalCtx->msgCtx.currentTextId + 1); + func_80151938(play, play->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); + func_80151938(play, play->msgCtx.currentTextId + 1); break; case 0x1089: case 0x1093: gSaveContext.save.weekEventReg[26] |= 1; - func_801477B4(globalCtx); + func_801477B4(play); Animation_MorphToLoop(&this->skelAnime, &object_tsn_Anim_0092FC, -10.0f); this->actionFunc = func_80AE0304; this->actor.textId = 0; @@ -241,24 +242,24 @@ void func_80AE0010(EnTsn* this, GlobalContext* globalCtx) { case 0x1087: Animation_MorphToLoop(&this->skelAnime, &object_tsn_Anim_001198, -10.0f); - func_80151938(globalCtx, globalCtx->msgCtx.currentTextId + 1); + func_80151938(play, play->msgCtx.currentTextId + 1); break; case 0x1088: gSaveContext.save.weekEventReg[26] |= 1; if (INV_CONTENT(ITEM_MASK_ZORA) == ITEM_MASK_ZORA) { - func_801477B4(globalCtx); + func_801477B4(play); Animation_MorphToLoop(&this->skelAnime, &object_tsn_Anim_0092FC, -10.0f); this->actionFunc = func_80AE0304; this->actor.textId = 0; } else { - func_80151938(globalCtx, 0x1093); + func_80151938(play, 0x1093); Animation_MorphToLoop(&this->skelAnime, &object_tsn_Anim_0092FC, -10.0f); } break; case 0x107E: - func_801477B4(globalCtx); + func_801477B4(play); this->actionFunc = func_80AE0304; this->actor.textId = 0; break; @@ -266,15 +267,15 @@ void func_80AE0010(EnTsn* this, GlobalContext* globalCtx) { } } -void func_80AE0304(EnTsn* this, GlobalContext* globalCtx) { - if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { +void func_80AE0304(EnTsn* this, PlayState* play) { + if (Actor_ProcessTalkRequest(&this->actor, &play->state)) { this->actionFunc = func_80AE0010; this->unk_220 |= 1; if (this->actor.textId == 0) { - func_80ADFF84(this, globalCtx); + func_80ADFF84(this, play); } - } else if ((this->actor.xzDistToPlayer < 150.0f) && Player_IsFacingActor(&this->actor, 0x3000, globalCtx)) { - func_800B8614(&this->actor, globalCtx, 160.0f); + } else if ((this->actor.xzDistToPlayer < 150.0f) && Player_IsFacingActor(&this->actor, 0x3000, play)) { + func_800B8614(&this->actor, play, 160.0f); this->unk_220 |= 1; } else { this->unk_220 &= ~1; @@ -287,49 +288,49 @@ void func_80AE0304(EnTsn* this, GlobalContext* globalCtx) { 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); +void func_80AE0418(EnTsn* this, PlayState* play) { + if (Actor_TextboxIsClosing(&this->actor, play)) { + Message_StartTextbox(play, 0x107D, NULL); Actor_MarkForDeath(&this->actor); } } -void func_80AE0460(EnTsn* this, GlobalContext* globalCtx) { - if (Actor_HasParent(&this->actor, globalCtx)) { +void func_80AE0460(EnTsn* this, PlayState* play) { + if (Actor_HasParent(&this->actor, play)) { ENTSN_SET_Z(&this->unk_1D8->actor, false); this->actionFunc = func_80AE0418; } else { - Actor_PickUp(&this->actor, globalCtx, GI_95, 2000.0f, 1000.0f); + Actor_PickUp(&this->actor, play, GI_SEAHORSE_CAUGHT, 2000.0f, 1000.0f); } } -void func_80AE04C4(EnTsn* this, GlobalContext* globalCtx) { - if (Actor_TextboxIsClosing(&this->actor, globalCtx)) { +void func_80AE04C4(EnTsn* this, PlayState* play) { + if (Actor_TextboxIsClosing(&this->actor, play)) { this->actionFunc = func_80AE0C88; } } -void func_80AE04FC(EnTsn* this, GlobalContext* globalCtx) { +void func_80AE04FC(EnTsn* this, PlayState* play) { s32 sp24; - Player* player = GET_PLAYER(globalCtx); + Player* player = GET_PLAYER(play); - if (Message_GetState(&globalCtx->msgCtx) == 0x10) { - sp24 = func_80123810(globalCtx); + if (Message_GetState(&play->msgCtx) == TEXT_STATE_16) { + sp24 = func_80123810(play); if (sp24 != 0) { gSaveContext.save.weekEventReg[26] |= 2; } if (sp24 > 0) { - func_801477B4(globalCtx); + func_801477B4(play); this->actionFunc = func_80AE0704; if (sp24 == 19) { - if (CHECK_QUEST_ITEM(QUEST_UNK_19)) { - if (func_8013A4C4(1 | 8)) { + if (CHECK_QUEST_ITEM(QUEST_PICTOGRAPH)) { + if (Snap_CheckFlag(PICTOGRAPH_PIRATE_GOOD)) { player->actor.textId = 0x107B; return; } - if (func_8013A4C4(1 | 2 | 8)) { + if (Snap_CheckFlag(PICTOGRAPH_PIRATE_TOO_FAR)) { player->actor.textId = 0x10A9; return; } @@ -355,15 +356,15 @@ void func_80AE04FC(EnTsn* this, GlobalContext* globalCtx) { } if (sp24 < 0) { - func_80151938(globalCtx, 0x1078); + func_80151938(play, 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); +void func_80AE0698(EnTsn* this, PlayState* play) { + func_801477B4(play); this->actionFunc = func_80AE0C88; this->unk_220 &= ~2; this->actor.focus.pos = this->actor.world.pos; @@ -371,27 +372,27 @@ void func_80AE0698(EnTsn* this, GlobalContext* globalCtx) { ENTSN_SET_Z(&this->unk_1D8->actor, false); } -void func_80AE0704(EnTsn* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); +void func_80AE0704(EnTsn* this, PlayState* play) { + Player* player = GET_PLAYER(play); s32 pad[2]; - if ((this->unk_220 & 8) && (globalCtx->msgCtx.currentTextId == 0x1078)) { + if ((this->unk_220 & 8) && (play->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: + switch (Message_GetState(&play->msgCtx)) { + case TEXT_STATE_CLOSING: break; - case 5: - if (Message_ShouldAdvance(globalCtx)) { - switch (globalCtx->msgCtx.currentTextId) { + case TEXT_STATE_5: + if (Message_ShouldAdvance(play)) { + switch (play->msgCtx.currentTextId) { case 0x106E: if (gSaveContext.save.weekEventReg[25] & 0x40) { - func_80151938(globalCtx, 0x1074); + func_80151938(play, 0x1074); } else { - func_80151938(globalCtx, 0x106F); + func_80151938(play, 0x106F); } this->unk_220 |= 2; gSaveContext.save.weekEventReg[25] |= 0x40; @@ -403,51 +404,51 @@ void func_80AE0704(EnTsn* this, GlobalContext* globalCtx) { case 0x1070: case 0x1071: case 0x1072: - func_80151938(globalCtx, globalCtx->msgCtx.currentTextId + 1); + func_80151938(play, play->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); + func_80151938(play, play->msgCtx.currentTextId + 1); break; case 0x107A: - func_80151938(globalCtx, 0x10A6); + func_80151938(play, 0x10A6); break; case 0x1075: case 0x1078: player->exchangeItemId = 0; - func_80151938(globalCtx, globalCtx->msgCtx.currentTextId + 1); + func_80151938(play, play->msgCtx.currentTextId + 1); Animation_MorphToLoop(&this->unk_1D8->skelAnime, &object_tsn_Anim_0092FC, -10.0f); break; case 0x107C: - if (Interface_HasEmptyBottle()) { + if (Inventory_HasEmptyBottle()) { gSaveContext.save.weekEventReg[26] |= 8; - func_801477B4(globalCtx); + func_801477B4(play); this->actionFunc = func_80AE0460; - func_80AE0460(this, globalCtx); + func_80AE0460(this, play); this->unk_220 &= ~2; this->actor.focus.pos = this->actor.world.pos; ActorCutscene_Stop(this->actor.cutscene); this->actor.flags &= ~ACTOR_FLAG_100; - REMOVE_QUEST_ITEM(QUEST_UNK_19); + REMOVE_QUEST_ITEM(QUEST_PICTOGRAPH); } else { - func_80151938(globalCtx, 0x10A8); + func_80151938(play, 0x10A8); } break; case 0x1073: case 0x1074: - func_80151938(globalCtx, 0xFF); + func_80151938(play, 0xFF); this->actionFunc = func_80AE04FC; break; case 0x107B: player->exchangeItemId = 0; - func_80151938(globalCtx, globalCtx->msgCtx.currentTextId + 1); + func_80151938(play, play->msgCtx.currentTextId + 1); Animation_MorphToLoop(&this->unk_1D8->skelAnime, &object_tsn_Anim_0092FC, -10.0f); break; @@ -455,7 +456,7 @@ void func_80AE0704(EnTsn* this, GlobalContext* globalCtx) { case 0x10A6: case 0x10A8: Animation_MorphToLoop(&this->unk_1D8->skelAnime, &object_tsn_Anim_0092FC, -10.0f); - func_80AE0698(this, globalCtx); + func_80AE0698(this, play); this->actor.flags &= ~ACTOR_FLAG_100; this->actionFunc = func_80AE04C4; break; @@ -463,7 +464,7 @@ void func_80AE0704(EnTsn* this, GlobalContext* globalCtx) { case 0x108A: case 0x1091: gSaveContext.save.weekEventReg[26] |= 4; - func_80151938(globalCtx, globalCtx->msgCtx.currentTextId + 1); + func_80151938(play, play->msgCtx.currentTextId + 1); this->unk_220 |= 2; this->actor.textId = 0x1091; break; @@ -473,34 +474,35 @@ void func_80AE0704(EnTsn* this, GlobalContext* globalCtx) { case 0x108D: case 0x108E: case 0x108F: - func_80151938(globalCtx, globalCtx->msgCtx.currentTextId + 1); + func_80151938(play, play->msgCtx.currentTextId + 1); break; case 0x1092: if (gSaveContext.save.weekEventReg[26] & 8) { - func_80AE0698(this, globalCtx); + func_80AE0698(this, play); } else { - func_80151938(globalCtx, 0x10A7); + func_80151938(play, 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); + func_80AE0698(this, play); break; case 0x1090: - func_80AE0698(this, globalCtx); + func_80AE0698(this, play); break; case 0x10A9: - func_80AE0698(this, globalCtx); + func_80AE0698(this, play); this->actor.flags &= ~ACTOR_FLAG_100; this->actionFunc = func_80AE04C4; break; } } + break; } if (this->unk_220 & 2) { @@ -526,49 +528,49 @@ void func_80AE0704(EnTsn* this, GlobalContext* globalCtx) { } } -void func_80AE0C88(EnTsn* this, GlobalContext* globalCtx) { - if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { +void func_80AE0C88(EnTsn* this, PlayState* play) { + if (Actor_ProcessTalkRequest(&this->actor, &play->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); + func_800B8614(&this->actor, play, 1000.0f); } } -void func_80AE0D10(EnTsn* this, GlobalContext* globalCtx) { - if ((Message_GetState(&globalCtx->msgCtx) == 5) && Message_ShouldAdvance(globalCtx)) { - func_801477B4(globalCtx); +void func_80AE0D10(EnTsn* this, PlayState* play) { + if ((Message_GetState(&play->msgCtx) == TEXT_STATE_5) && Message_ShouldAdvance(play)) { + func_801477B4(play); this->actionFunc = func_80AE0D78; ActorCutscene_Stop(this->actor.cutscene); } } -void func_80AE0D78(EnTsn* this, GlobalContext* globalCtx) { - if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { +void func_80AE0D78(EnTsn* this, PlayState* play) { + if (Actor_ProcessTalkRequest(&this->actor, &play->state)) { this->actionFunc = func_80AE0D10; this->unk_220 |= 4; } else if (this->actor.isTargeted) { - func_800B8614(&this->actor, globalCtx, 1000.0f); + func_800B8614(&this->actor, play, 1000.0f); } } -void EnTsn_Update(Actor* thisx, GlobalContext* globalCtx) { +void EnTsn_Update(Actor* thisx, PlayState* play) { s32 pad; EnTsn* this = THIS; - this->actionFunc(this, globalCtx); + this->actionFunc(this, play); Collider_UpdateCylinder(&this->actor, &this->collider); - CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + CollisionCheck_SetOC(play, &play->colChkCtx, &this->collider.base); Actor_MoveWithGravity(&this->actor); - Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 20.0f, 25.0f, 0.0f, 4); + Actor_UpdateBgCheckInfo(play, &this->actor, 20.0f, 25.0f, 0.0f, 4); SkelAnime_Update(&this->skelAnime); if (this->unk_220 & 1) { - func_800E9250(globalCtx, &this->actor, &this->unk_222, &this->unk_228, this->actor.focus.pos); + Actor_TrackPlayer(play, &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); @@ -587,13 +589,13 @@ void EnTsn_Update(Actor* thisx, GlobalContext* globalCtx) { } } -void func_80AE0F84(Actor* thisx, GlobalContext* globalCtx) { +void func_80AE0F84(Actor* thisx, PlayState* play) { EnTsn* this = THIS; - this->actionFunc(this, globalCtx); + this->actionFunc(this, play); } -s32 EnTsn_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, Actor* thisx) { +s32 EnTsn_OverrideLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, Actor* thisx) { EnTsn* this = THIS; s16 shifted = this->unk_222.x >> 1; @@ -609,28 +611,28 @@ s32 EnTsn_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, return false; } -void EnTsn_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx) { +void EnTsn_PostLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx) { EnTsn* this = THIS; Vec3f sp18 = D_80AE11BC; if (limbIndex == 15) { - Matrix_MultiplyVector3fByState(&sp18, &this->actor.focus.pos); + Matrix_MultVec3f(&sp18, &this->actor.focus.pos); } } -void EnTsn_Draw(Actor* thisx, GlobalContext* globalCtx) { +void EnTsn_Draw(Actor* thisx, PlayState* play) { s32 pad; EnTsn* this = THIS; - OPEN_DISPS(globalCtx->state.gfxCtx); + OPEN_DISPS(play->state.gfxCtx); - func_8012C5B0(globalCtx->state.gfxCtx); + func_8012C5B0(play->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, + SkelAnime_DrawFlexOpa(play, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, EnTsn_OverrideLimbDraw, EnTsn_PostLimbDraw, &this->actor); - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->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 64df6ac42..396918fdb 100644 --- a/src/overlays/actors/ovl_En_Tsn/z_en_tsn.h +++ b/src/overlays/actors/ovl_En_Tsn/z_en_tsn.h @@ -5,28 +5,28 @@ struct EnTsn; -typedef void (*EnTsnActionFunc)(struct EnTsn*, GlobalContext*); +typedef void (*EnTsnActionFunc)(struct EnTsn*, PlayState*); #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_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 */ ColliderCylinder collider; - /* 0x0190 */ SkelAnime skelAnime; - /* 0x01D4 */ EnTsnActionFunc actionFunc; - /* 0x01D8 */ struct EnTsn* unk_1D8; - /* 0x01DC */ UNK_TYPE1 unk1DC[0x44]; - /* 0x0220 */ u16 unk_220; - /* 0x0222 */ Vec3s unk_222; - /* 0x0228 */ Vec3s unk_228; - /* 0x022E */ s16 unk_22E; - /* 0x0230 */ s16 unk_230; + /* 0x000 */ Actor actor; + /* 0x144 */ ColliderCylinder collider; + /* 0x190 */ SkelAnime skelAnime; + /* 0x1D4 */ EnTsnActionFunc actionFunc; + /* 0x1D8 */ struct EnTsn* unk_1D8; + /* 0x1DC */ UNK_TYPE1 unk1DC[0x44]; + /* 0x220 */ u16 unk_220; + /* 0x222 */ Vec3s unk_222; + /* 0x228 */ Vec3s unk_228; + /* 0x22E */ s16 unk_22E; + /* 0x230 */ s16 unk_230; } EnTsn; // size = 0x234 extern const ActorInit En_Tsn_InitVars; diff --git a/src/overlays/actors/ovl_En_Tubo_Trap/z_en_tubo_trap.c b/src/overlays/actors/ovl_En_Tubo_Trap/z_en_tubo_trap.c index 18476aa4e..bf1e44e98 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 @@ -11,13 +11,13 @@ #define THIS ((EnTuboTrap*)thisx) -void EnTuboTrap_Init(Actor* thisx, GlobalContext* globalCtx); -void EnTuboTrap_Destroy(Actor* thisx, GlobalContext* globalCtx); -void EnTuboTrap_Update(Actor* thisx, GlobalContext* globalCtx); -void EnTuboTrap_Draw(Actor* thisx, GlobalContext* globalCtx); -void EnTuboTrap_Idle(EnTuboTrap* this, GlobalContext* globalCtx); -void EnTuboTrap_Levitate(EnTuboTrap* this, GlobalContext* globalCtx); -void EnTuboTrap_FlyAtPlayer(EnTuboTrap* this, GlobalContext* globalCtx); +void EnTuboTrap_Init(Actor* thisx, PlayState* play); +void EnTuboTrap_Destroy(Actor* thisx, PlayState* play); +void EnTuboTrap_Update(Actor* thisx, PlayState* play); +void EnTuboTrap_Draw(Actor* thisx, PlayState* play); +void EnTuboTrap_Idle(EnTuboTrap* this, PlayState* play); +void EnTuboTrap_Levitate(EnTuboTrap* this, PlayState* play); +void EnTuboTrap_FlyAtPlayer(EnTuboTrap* this, PlayState* play); static ColliderCylinderInit sCylinderInit = { { @@ -58,34 +58,34 @@ static InitChainEntry sInitChain[] = { ICHAIN_F32(uncullZoneDownward, 100, ICHAIN_STOP), }; -void EnTuboTrap_Init(Actor* thisx, GlobalContext* globalCtx) { +void EnTuboTrap_Init(Actor* thisx, PlayState* play) { EnTuboTrap* this = THIS; Actor_ProcessInitChain(&this->actor, sInitChain); this->actor.shape.rot.z = 0; this->actor.world.rot.z = 0; ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 1.8f); - Collider_InitCylinder(globalCtx, &this->collider); - Collider_SetCylinder(globalCtx, &this->collider, &this->actor, &sCylinderInit); + Collider_InitCylinder(play, &this->collider); + Collider_SetCylinder(play, &this->collider, &this->actor, &sCylinderInit); this->actionFunc = EnTuboTrap_Idle; } -void EnTuboTrap_Destroy(Actor* thisx, GlobalContext* globalCtx) { +void EnTuboTrap_Destroy(Actor* thisx, PlayState* play) { EnTuboTrap* this = THIS; - Collider_DestroyCylinder(globalCtx, &this->collider); + Collider_DestroyCylinder(play, &this->collider); } -void EnTuboTrap_DropCollectible(EnTuboTrap* this, GlobalContext* globalCtx) { +void EnTuboTrap_DropCollectible(EnTuboTrap* this, PlayState* play) { s32 itemParam = ((this->actor.params >> 8) & 0x3F); s32 dropItem00Id = func_800A8150(itemParam); if (dropItem00Id > ITEM00_NO_DROP) { - Item_DropCollectible(globalCtx, &this->actor.world.pos, ((this->actor.params & 0x7F) << 8) | dropItem00Id); + Item_DropCollectible(play, &this->actor.world.pos, ((this->actor.params & 0x7F) << 8) | dropItem00Id); } } -void EnTuboTrap_SpawnEffectsOnLand(EnTuboTrap* this, GlobalContext* globalCtx) { +void EnTuboTrap_SpawnEffectsOnLand(EnTuboTrap* this, PlayState* play) { f32 rand; f32 sin; f32 cos; @@ -119,15 +119,14 @@ void EnTuboTrap_SpawnEffectsOnLand(EnTuboTrap* this, GlobalContext* globalCtx) { } else { arg5 = 0x20; } - EffectSsKakera_Spawn(globalCtx, &pos, &vel, actorPos, -0xF0, arg5, 0x14, 0, 0, - ((Rand_ZeroOne() * 85.0f) + 15.0f), 0, 0, 0x3C, -1, GAMEPLAY_DANGEON_KEEP, - gameplay_dangeon_keep_DL_018090); + EffectSsKakera_Spawn(play, &pos, &vel, actorPos, -0xF0, arg5, 0x14, 0, 0, ((Rand_ZeroOne() * 85.0f) + 15.0f), 0, + 0, 0x3C, -1, GAMEPLAY_DANGEON_KEEP, gameplay_dangeon_keep_DL_018090); } - func_800BBFB0(globalCtx, actorPos, 30.0f, 4, 0x14, 0x32, 0); + func_800BBFB0(play, actorPos, 30.0f, 4, 0x14, 0x32, 0); } -void EnTuboTrap_SpawnEffectsInWater(EnTuboTrap* this, GlobalContext* globalCtx) { +void EnTuboTrap_SpawnEffectsInWater(EnTuboTrap* this, PlayState* play) { f32 rand; f32 sin; f32 cos; @@ -141,7 +140,7 @@ void EnTuboTrap_SpawnEffectsInWater(EnTuboTrap* this, GlobalContext* globalCtx) pos = *actorPos; pos.y += this->actor.depthInWater; - EffectSsGSplash_Spawn(globalCtx, &pos, NULL, NULL, 0, 0x190); + EffectSsGSplash_Spawn(play, &pos, NULL, NULL, 0, 0x190); for (i = 0, var = 0; i < 15; i++, var += 20000) { sin = Math_SinS(var); @@ -165,40 +164,39 @@ void EnTuboTrap_SpawnEffectsInWater(EnTuboTrap* this, GlobalContext* globalCtx) arg5 = 32; } - EffectSsKakera_Spawn(globalCtx, &pos, &vel, actorPos, -0xAA, arg5, 0x32, 5, 0, - ((Rand_ZeroOne() * 85.0f) + 15.0f), 0, 0, 0x46, -1, GAMEPLAY_DANGEON_KEEP, - gameplay_dangeon_keep_DL_018090); + EffectSsKakera_Spawn(play, &pos, &vel, actorPos, -0xAA, arg5, 0x32, 5, 0, ((Rand_ZeroOne() * 85.0f) + 15.0f), 0, + 0, 0x46, -1, GAMEPLAY_DANGEON_KEEP, gameplay_dangeon_keep_DL_018090); } } -void EnTuboTrap_HandleImpact(EnTuboTrap* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); - Player* player2 = GET_PLAYER(globalCtx); +void EnTuboTrap_HandleImpact(EnTuboTrap* this, PlayState* play) { + Player* player = GET_PLAYER(play); + Player* player2 = GET_PLAYER(play); if ((this->actor.bgCheckFlags & 0x20) && (this->actor.depthInWater > 15.0f)) { - EnTuboTrap_SpawnEffectsInWater(this, globalCtx); - SoundSource_PlaySfxAtFixedWorldPos(globalCtx, &this->actor.world.pos, 40, NA_SE_EV_BOMB_DROP_WATER); - EnTuboTrap_DropCollectible(this, globalCtx); + EnTuboTrap_SpawnEffectsInWater(this, play); + SoundSource_PlaySfxAtFixedWorldPos(play, &this->actor.world.pos, 40, NA_SE_EV_BOMB_DROP_WATER); + EnTuboTrap_DropCollectible(this, play); Actor_MarkForDeath(&this->actor); return; } if (this->collider.base.atFlags & AT_BOUNCED) { this->collider.base.atFlags &= ~AT_BOUNCED; - EnTuboTrap_SpawnEffectsOnLand(this, globalCtx); - SoundSource_PlaySfxAtFixedWorldPos(globalCtx, &this->actor.world.pos, 40, NA_SE_IT_SHIELD_REFLECT_SW); - SoundSource_PlaySfxAtFixedWorldPos(globalCtx, &this->actor.world.pos, 40, NA_SE_EV_POT_BROKEN); - EnTuboTrap_DropCollectible(this, globalCtx); + EnTuboTrap_SpawnEffectsOnLand(this, play); + SoundSource_PlaySfxAtFixedWorldPos(play, &this->actor.world.pos, 40, NA_SE_IT_SHIELD_REFLECT_SW); + SoundSource_PlaySfxAtFixedWorldPos(play, &this->actor.world.pos, 40, NA_SE_EV_POT_BROKEN); + EnTuboTrap_DropCollectible(this, play); Actor_MarkForDeath(&this->actor); return; } if (this->collider.base.acFlags & AC_HIT) { this->collider.base.acFlags &= ~AC_HIT; - EnTuboTrap_SpawnEffectsOnLand(this, globalCtx); - SoundSource_PlaySfxAtFixedWorldPos(globalCtx, &this->actor.world.pos, 40, NA_SE_EV_EXPLOSION); - SoundSource_PlaySfxAtFixedWorldPos(globalCtx, &this->actor.world.pos, 40, NA_SE_EV_POT_BROKEN); - EnTuboTrap_DropCollectible(this, globalCtx); + EnTuboTrap_SpawnEffectsOnLand(this, play); + SoundSource_PlaySfxAtFixedWorldPos(play, &this->actor.world.pos, 40, NA_SE_EV_EXPLOSION); + SoundSource_PlaySfxAtFixedWorldPos(play, &this->actor.world.pos, 40, NA_SE_EV_POT_BROKEN); + EnTuboTrap_DropCollectible(this, play); Actor_MarkForDeath(&this->actor); return; } @@ -207,28 +205,28 @@ void EnTuboTrap_HandleImpact(EnTuboTrap* this, GlobalContext* globalCtx) { this->collider.base.atFlags &= ~AT_HIT; if (&player->actor == this->collider.base.at) { - EnTuboTrap_SpawnEffectsOnLand(this, globalCtx); - SoundSource_PlaySfxAtFixedWorldPos(globalCtx, &this->actor.world.pos, 40, NA_SE_EV_POT_BROKEN); - SoundSource_PlaySfxAtFixedWorldPos(globalCtx, &player2->actor.world.pos, 40, NA_SE_PL_BODY_HIT); - EnTuboTrap_DropCollectible(this, globalCtx); + EnTuboTrap_SpawnEffectsOnLand(this, play); + SoundSource_PlaySfxAtFixedWorldPos(play, &this->actor.world.pos, 40, NA_SE_EV_POT_BROKEN); + SoundSource_PlaySfxAtFixedWorldPos(play, &player2->actor.world.pos, 40, NA_SE_PL_BODY_HIT); + EnTuboTrap_DropCollectible(this, play); Actor_MarkForDeath(&this->actor); return; } } if ((this->actor.bgCheckFlags & 8) || (this->actor.bgCheckFlags & 1)) { - EnTuboTrap_SpawnEffectsOnLand(this, globalCtx); - SoundSource_PlaySfxAtFixedWorldPos(globalCtx, &this->actor.world.pos, 40, NA_SE_EV_POT_BROKEN); - EnTuboTrap_DropCollectible(this, globalCtx); + EnTuboTrap_SpawnEffectsOnLand(this, play); + SoundSource_PlaySfxAtFixedWorldPos(play, &this->actor.world.pos, 40, NA_SE_EV_POT_BROKEN); + EnTuboTrap_DropCollectible(this, play); Actor_MarkForDeath(&this->actor); } } -void EnTuboTrap_Idle(EnTuboTrap* this, GlobalContext* globalCtx) { +void EnTuboTrap_Idle(EnTuboTrap* this, PlayState* play) { static s8 sTransformationHeight[] = { 40, 40, 40, 25, 28, }; - Player* player = GET_PLAYER(globalCtx); + Player* player = GET_PLAYER(play); f32 currentHeight; f32 transformationHeight; s16 startingRotation; @@ -236,7 +234,7 @@ void EnTuboTrap_Idle(EnTuboTrap* this, GlobalContext* globalCtx) { if ((this->actor.xzDistToPlayer < 200.0f) && (this->actor.world.pos.y <= player->actor.world.pos.y)) { startingRotation = this->actor.home.rot.z; if ((startingRotation == 0) || (this->actor.playerHeightRel <= (startingRotation * 10.0f))) { - func_800BC154(globalCtx, &globalCtx->actorCtx, &this->actor, ACTORCAT_ENEMY); + func_800BC154(play, &play->actorCtx, &this->actor, ACTORCAT_ENEMY); currentHeight = this->actor.world.pos.y; this->actor.flags |= (ACTOR_FLAG_1 | ACTOR_FLAG_10); // always update and can target @@ -254,7 +252,7 @@ void EnTuboTrap_Idle(EnTuboTrap* this, GlobalContext* globalCtx) { } } -void EnTuboTrap_Levitate(EnTuboTrap* this, GlobalContext* globalCtx) { +void EnTuboTrap_Levitate(EnTuboTrap* this, PlayState* play) { this->actor.shape.rot.y += 5000; Math_ApproachF(&this->actor.world.pos.y, this->targetHeight, 0.8f, 3.0f); @@ -265,7 +263,7 @@ void EnTuboTrap_Levitate(EnTuboTrap* this, GlobalContext* globalCtx) { } } -void EnTuboTrap_FlyAtPlayer(EnTuboTrap* this, GlobalContext* globalCtx) { +void EnTuboTrap_FlyAtPlayer(EnTuboTrap* this, PlayState* play) { f32 dX = this->originPos.x - this->actor.world.pos.x; f32 dY = this->originPos.y - this->actor.world.pos.y; f32 dZ = this->originPos.z - this->actor.world.pos.z; @@ -282,16 +280,16 @@ void EnTuboTrap_FlyAtPlayer(EnTuboTrap* this, GlobalContext* globalCtx) { } this->actor.shape.rot.y += 5000; - EnTuboTrap_HandleImpact(this, globalCtx); + EnTuboTrap_HandleImpact(this, play); } -void EnTuboTrap_Update(Actor* thisx, GlobalContext* globalCtx) { +void EnTuboTrap_Update(Actor* thisx, PlayState* play) { EnTuboTrap* this = THIS; s32 padding; - this->actionFunc(this, globalCtx); + this->actionFunc(this, play); Actor_MoveWithGravity(&this->actor); - Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 12.0f, 10.0f, 20.0f, 0x1F); + Actor_UpdateBgCheckInfo(play, &this->actor, 12.0f, 10.0f, 20.0f, 0x1F); Actor_SetFocus(&this->actor, 0.0f); if (this->actor.projectedPos.z < 811.0f) { @@ -309,10 +307,10 @@ void EnTuboTrap_Update(Actor* thisx, GlobalContext* globalCtx) { } Collider_UpdateCylinder(&this->actor, &this->collider); - CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); - CollisionCheck_SetAT(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + CollisionCheck_SetAC(play, &play->colChkCtx, &this->collider.base); + CollisionCheck_SetAT(play, &play->colChkCtx, &this->collider.base); } -void EnTuboTrap_Draw(Actor* thisx, GlobalContext* globalCtx) { - Gfx_DrawDListOpa(globalCtx, gameplay_dangeon_keep_DL_017EA0); +void EnTuboTrap_Draw(Actor* thisx, PlayState* play) { + Gfx_DrawDListOpa(play, gameplay_dangeon_keep_DL_017EA0); } diff --git a/src/overlays/actors/ovl_En_Tubo_Trap/z_en_tubo_trap.h b/src/overlays/actors/ovl_En_Tubo_Trap/z_en_tubo_trap.h index 673e57ae5..db3b9cbe4 100644 --- a/src/overlays/actors/ovl_En_Tubo_Trap/z_en_tubo_trap.h +++ b/src/overlays/actors/ovl_En_Tubo_Trap/z_en_tubo_trap.h @@ -5,14 +5,14 @@ struct EnTuboTrap; -typedef void (*EnTuboTrapActionFunc)(struct EnTuboTrap*, GlobalContext*); +typedef void (*EnTuboTrapActionFunc)(struct EnTuboTrap*, PlayState*); typedef struct EnTuboTrap { - /* 0x0000 */ Actor actor; - /* 0x0144 */ EnTuboTrapActionFunc actionFunc; - /* 0x0148 */ f32 targetHeight; - /* 0x014C */ Vec3f originPos; - /* 0x0158 */ ColliderCylinder collider; + /* 0x000 */ Actor actor; + /* 0x144 */ EnTuboTrapActionFunc actionFunc; + /* 0x148 */ f32 targetHeight; + /* 0x14C */ Vec3f originPos; + /* 0x158 */ ColliderCylinder collider; } EnTuboTrap; // size = 0x1A4 extern const ActorInit En_Tubo_Trap_InitVars; diff --git a/src/overlays/actors/ovl_En_Twig/z_en_twig.c b/src/overlays/actors/ovl_En_Twig/z_en_twig.c index c2cae36c3..182db5659 100644 --- a/src/overlays/actors/ovl_En_Twig/z_en_twig.c +++ b/src/overlays/actors/ovl_En_Twig/z_en_twig.c @@ -10,10 +10,10 @@ #define THIS ((EnTwig*)thisx) -void EnTwig_Init(Actor* thisx, GlobalContext* globalCtx); -void EnTwig_Destroy(Actor* thisx, GlobalContext* globalCtx); -void EnTwig_Update(Actor* thisx, GlobalContext* globalCtx); -void EnTwig_Draw(Actor* thisx, GlobalContext* globalCtx); +void EnTwig_Init(Actor* thisx, PlayState* play); +void EnTwig_Destroy(Actor* thisx, PlayState* play); +void EnTwig_Update(Actor* thisx, PlayState* play); +void EnTwig_Draw(Actor* thisx, PlayState* play); #if 0 const ActorInit En_Twig_InitVars = { diff --git a/src/overlays/actors/ovl_En_Twig/z_en_twig.h b/src/overlays/actors/ovl_En_Twig/z_en_twig.h index 0711d261c..2caebeb82 100644 --- a/src/overlays/actors/ovl_En_Twig/z_en_twig.h +++ b/src/overlays/actors/ovl_En_Twig/z_en_twig.h @@ -5,13 +5,13 @@ struct EnTwig; -typedef void (*EnTwigActionFunc)(struct EnTwig*, GlobalContext*); +typedef void (*EnTwigActionFunc)(struct EnTwig*, PlayState*); typedef struct EnTwig { - /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x18]; - /* 0x015C */ EnTwigActionFunc actionFunc; - /* 0x0160 */ char unk_160[0x2C]; + /* 0x000 */ Actor actor; + /* 0x144 */ char unk_144[0x18]; + /* 0x15C */ EnTwigActionFunc actionFunc; + /* 0x160 */ char unk_160[0x2C]; } EnTwig; // size = 0x18C extern const ActorInit En_Twig_InitVars; diff --git a/src/overlays/actors/ovl_En_Viewer/z_en_viewer.c b/src/overlays/actors/ovl_En_Viewer/z_en_viewer.c index 170cc6edb..43c2dc1e5 100644 --- a/src/overlays/actors/ovl_En_Viewer/z_en_viewer.c +++ b/src/overlays/actors/ovl_En_Viewer/z_en_viewer.c @@ -10,18 +10,19 @@ #define THIS ((EnViewer*)thisx) -void EnViewer_Init(Actor* thisx, GlobalContext* globalCtx); -void EnViewer_Destroy(Actor* thisx, GlobalContext* globalCtx); -void EnViewer_Update(Actor* thisx, GlobalContext* globalCtx); -void EnViewer_Draw(Actor* thisx, GlobalContext* globalCtx); +void EnViewer_Init(Actor* thisx, PlayState* play); +void EnViewer_Destroy(Actor* thisx, PlayState* play); +void EnViewer_Update(Actor* thisx, PlayState* play2); +void EnViewer_Draw(Actor* thisx, PlayState* play); -void func_8089F17C(EnViewer* this, GlobalContext* globalCtx); -void func_8089F218(EnViewer* this, GlobalContext* globalCtx); -void func_8089F2C4(EnViewer* this, GlobalContext* globalCtx); +void func_8089F17C(EnViewer* this, PlayState* play); +void func_8089F218(EnViewer* this, PlayState* play); +void func_8089F2C4(EnViewer* this, PlayState* play); -void EnViewer_SetupAction(EnViewer* this, EnViewerActionFunc actionFunc); +static u8 D_8089F3E0 = 0; + +static u8 D_8089F3E4 = 0; -#if 0 const ActorInit En_Viewer_InitVars = { ACTOR_EN_VIEWER, ACTORCAT_ITEMACTION, @@ -34,24 +35,124 @@ const ActorInit En_Viewer_InitVars = { (ActorFunc)EnViewer_Draw, }; -#endif +u32 D_8089F4D0; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Viewer/EnViewer_SetupAction.s") +void EnViewer_SetupAction(EnViewer* this, EnViewerActionFunc actionFunc) { + this->actionFunc = actionFunc; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Viewer/EnViewer_Init.s") +void EnViewer_Init(Actor* thisx, PlayState* play) { + EnViewer* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Viewer/EnViewer_Destroy.s") + this->unk_154 = D_8089F3E0; + D_8089F3E0++; + switch (ENVIEWER_GET_3(&this->actor)) { + case ENVIEWER_PARAMS_0: + this->unk_148 = ENVIEWER_GET_8000(&this->actor) * 40.0f; + this->unk_150 = (u8)ENVIEWER_GET_1FC(&this->actor) * 40.0f; + EnViewer_SetupAction(this, func_8089F17C); + break; + case ENVIEWER_PARAMS_1: + this->unk_148 = (u16)ENVIEWER_GET_FE00(&this->actor) * 40.0f; + this->unk_150 = (u8)ENVIEWER_GET_1FC(&this->actor) * 40.0f; + this->unk_14C = (u16)(this->actor.world.rot.y) * 40.0f; + EnViewer_SetupAction(this, func_8089F218); + break; + case ENVIEWER_PARAMS_2: + this->unk_148 = (u16)ENVIEWER_GET_FE00(&this->actor) * 40.0f; + this->unk_14C = (u8)ENVIEWER_GET_1FC(&this->actor) * 40.0f; + EnViewer_SetupAction(this, func_8089F2C4); + break; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Viewer/func_8089F014.s") +void EnViewer_Destroy(Actor* thisx, PlayState* play) { + D_8089F3E0--; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Viewer/func_8089F0A0.s") +void func_8089F014(EnViewer* this, PlayState* play, f32 arg2) { + if (arg2 > 1.0f) { + arg2 = 1.0f; + } else if (arg2 < 0.0f) { + arg2 = 0.0f; + } + play->envCtx.lightSettingOverride = 0; + play->envCtx.unk_E0 = 2; + play->envCtx.unk_C1 = this->actor.world.rot.x; + play->envCtx.unk_C2 = this->actor.world.rot.z; + play->envCtx.lightBlend = arg2; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Viewer/func_8089F17C.s") +void func_8089F0A0(EnViewer* this, PlayState* play) { + Player* player = GET_PLAYER(play); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Viewer/func_8089F218.s") + D_8089F3E4++; + if ((D_8089F3E4 == D_8089F3E0) && (play->envCtx.lightSettingOverride != 255)) { + play->envCtx.lightSettingOverride = 255; + play->envCtx.unk_E0 = 0; + play->envCtx.lightBlend = 1.0f; + func_800FAAB4( + play, SurfaceType_GetLightSettingIndex(&play->colCtx, player->actor.floorPoly, player->actor.floorBgId)); + play->envCtx.lightBlend = 1.0f; + play->envCtx.unk_C2 = play->envCtx.unk_C1; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Viewer/func_8089F2C4.s") +void func_8089F17C(EnViewer* this, PlayState* play) { + Player* player = GET_PLAYER(play); + f32 xzDist = fabsf(this->actor.xzDistToPlayer); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Viewer/EnViewer_Update.s") + if ((((play->roomCtx.currRoom.num == this->actor.room) && (xzDist <= this->unk_148)) && + (this->actor.playerHeightRel <= this->unk_150)) && + (this->actor.world.pos.y <= player->actor.world.pos.y)) { + xzDist = this->actor.playerHeightRel / this->unk_150; + func_8089F014(this, play, xzDist); + } else { + func_8089F0A0(this, play); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Viewer/EnViewer_Draw.s") +void func_8089F218(EnViewer* this, PlayState* play) { + Player* player = GET_PLAYER(play); + f32 xzDist = fabsf(this->actor.xzDistToPlayer); + f32 temp; + + if ((play->roomCtx.currRoom.num == this->actor.room) && (xzDist <= this->unk_148) && + (this->actor.playerHeightRel <= this->unk_150) && (this->actor.world.pos.y <= player->actor.world.pos.y)) { + temp = (xzDist - this->unk_14C) / (this->unk_148 - this->unk_14C); + func_8089F014(this, play, temp); + } else { + func_8089F0A0(this, play); + } +} + +void func_8089F2C4(EnViewer* this, PlayState* play) { + Player* player = GET_PLAYER(play); + Vec3f sp20; + f32 temp; + + Actor_OffsetOfPointInActorCoords(&this->actor, &sp20, &player->actor.world.pos); + if (this->unk_14C == 0.0f) { + this->unk_14C = 0.1f; + } + if ((play->roomCtx.currRoom.num == this->actor.room) && (sp20.x < fabsf(this->unk_148))) { + temp = sp20.z / this->unk_14C; + func_8089F014(this, play, temp); + } else { + func_8089F0A0(this, play); + } +} + +void EnViewer_Update(Actor* thisx, PlayState* play2) { + PlayState* play = play2; + EnViewer* this = THIS; + + if (D_8089F4D0 != play->state.frames) { + D_8089F4D0 = play->state.frames; + D_8089F3E4 = 0; + } + this->actionFunc(this, play); +} + +void EnViewer_Draw(Actor* thisx, PlayState* play) { +} diff --git a/src/overlays/actors/ovl_En_Viewer/z_en_viewer.h b/src/overlays/actors/ovl_En_Viewer/z_en_viewer.h index 566c21f3c..c4819f788 100644 --- a/src/overlays/actors/ovl_En_Viewer/z_en_viewer.h +++ b/src/overlays/actors/ovl_En_Viewer/z_en_viewer.h @@ -3,16 +3,30 @@ #include "global.h" +#define ENVIEWER_GET_3(thisx) ((thisx)->params & 3) +#define ENVIEWER_GET_FE00(thisx) ((thisx)->params >> 9) +#define ENVIEWER_GET_1FC(thisx) (((thisx)->params >> 2) & 0x7F) +#define ENVIEWER_GET_8000(thisx) (((thisx)->params & 0xFFFF) >> 9) + struct EnViewer; -typedef void (*EnViewerActionFunc)(struct EnViewer*, GlobalContext*); +typedef void (*EnViewerActionFunc)(struct EnViewer*, PlayState*); typedef struct EnViewer { - /* 0x0000 */ Actor actor; - /* 0x0144 */ EnViewerActionFunc actionFunc; - /* 0x0148 */ char unk_148[0x10]; + /* 0x000 */ Actor actor; + /* 0x144 */ EnViewerActionFunc actionFunc; + /* 0x148 */ f32 unk_148; + /* 0x14C */ f32 unk_14C; + /* 0x150 */ f32 unk_150; + /* 0x154 */ u8 unk_154; } EnViewer; // size = 0x158 +typedef enum { + /* 0x0 */ ENVIEWER_PARAMS_0, + /* 0x1 */ ENVIEWER_PARAMS_1, + /* 0x2 */ ENVIEWER_PARAMS_2 +} EnViewerParams; + extern const ActorInit En_Viewer_InitVars; #endif // Z_EN_VIEWER_H 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 6103cb577..4e7e85147 100644 --- a/src/overlays/actors/ovl_En_Vm/z_en_vm.c +++ b/src/overlays/actors/ovl_En_Vm/z_en_vm.c @@ -13,21 +13,21 @@ #define THIS ((EnVm*)thisx) -void EnVm_Init(Actor* thisx, GlobalContext* globalCtx); -void EnVm_Destroy(Actor* thisx, GlobalContext* globalCtx); -void EnVm_Update(Actor* thisx, GlobalContext* globalCtx); -void EnVm_Draw(Actor* thisx, GlobalContext* globalCtx); +void EnVm_Init(Actor* thisx, PlayState* play); +void EnVm_Destroy(Actor* thisx, PlayState* play); +void EnVm_Update(Actor* thisx, PlayState* play); +void EnVm_Draw(Actor* thisx, PlayState* play); void func_808CC420(EnVm* this); -void func_808CC490(EnVm* this, GlobalContext* globalCtx); +void func_808CC490(EnVm* this, PlayState* play); void func_808CC5C4(EnVm* this); -void func_808CC610(EnVm* this, GlobalContext* globalCtx); +void func_808CC610(EnVm* this, PlayState* play); void func_808CC788(EnVm* this); -void func_808CC820(EnVm* this, GlobalContext* globalCtx); -void func_808CCAA4(EnVm* this, GlobalContext* globalCtx); +void func_808CC820(EnVm* this, PlayState* play); +void func_808CCAA4(EnVm* this, PlayState* play); void func_808CCB08(EnVm* this); -void func_808CCB50(EnVm* this, GlobalContext* globalCtx); -void func_808CCCF0(EnVm* this, GlobalContext* globalCtx); +void func_808CCB50(EnVm* this, PlayState* play); +void func_808CCCF0(EnVm* this, PlayState* play); const ActorInit En_Vm_InitVars = { ACTOR_EN_VM, @@ -75,7 +75,7 @@ static ColliderJntSphInit sJntSphInit = { OC2_TYPE_1, COLSHAPE_JNTSPH, }, - 2, + ARRAY_COUNT(sJntSphElementsInit), sJntSphElementsInit, }; @@ -102,7 +102,7 @@ static ColliderTrisInit sTrisInit = { OC2_NONE, COLSHAPE_TRIS, }, - 1, + ARRAY_COUNT(sTrisElementsInit), sTrisElementsInit, }; @@ -160,18 +160,17 @@ Color_RGBA8 D_808CD5BC = { 0, 0, 255, 0 }; Color_RGBA8 D_808CD5C0 = { 255, 255, 255, 255 }; -void EnVm_Init(Actor* thisx, GlobalContext* globalCtx) { +void EnVm_Init(Actor* thisx, PlayState* play) { EnVm* this = THIS; s32 i; s32 params; 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, + SkelAnime_Init(play, &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); + Collider_InitAndSetTris(play, &this->colliderTris, &this->actor, &sTrisInit, this->colliderTrisElements); + Collider_InitAndSetJntSph(play, &this->colliderJntSph, &this->actor, &sJntSphInit, this->colliderJntSphElements); CollisionCheck_SetInfo(&this->actor.colChkInfo, &sDamageTable, &sColChkInfoInit); params = ENVM_GET_FF00(thisx); @@ -192,11 +191,11 @@ void EnVm_Init(Actor* thisx, GlobalContext* globalCtx) { func_808CC420(this); } -void EnVm_Destroy(Actor* thisx, GlobalContext* globalCtx) { +void EnVm_Destroy(Actor* thisx, PlayState* play) { EnVm* this = THIS; - Collider_DestroyTris(globalCtx, &this->colliderTris); - Collider_DestroyJntSph(globalCtx, &this->colliderJntSph); + Collider_DestroyTris(play, &this->colliderTris); + Collider_DestroyJntSph(play, &this->colliderJntSph); } void func_808CC420(EnVm* this) { @@ -206,8 +205,8 @@ void func_808CC420(EnVm* this) { this->actionFunc = func_808CC490; } -void func_808CC490(EnVm* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); +void func_808CC490(EnVm* this, PlayState* play) { + Player* player = GET_PLAYER(play); s16 sp22; s16 temp_v0; @@ -224,7 +223,7 @@ void func_808CC490(EnVm* this, GlobalContext* globalCtx) { temp_v0 = 0x1B91; } - if ((ABS_ALT(sp22) <= 0x2710) && (temp_v0 >= 0xE38) && (Player_GetMask(globalCtx) != PLAYER_MASK_STONE)) { + if ((ABS_ALT(sp22) <= 0x2710) && (temp_v0 >= 0xE38) && (Player_GetMask(play) != PLAYER_MASK_STONE)) { func_808CC5C4(this); } } @@ -237,8 +236,8 @@ void func_808CC5C4(EnVm* this) { this->actionFunc = func_808CC610; } -void func_808CC610(EnVm* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); +void func_808CC610(EnVm* this, PlayState* play) { + Player* player = GET_PLAYER(play); s16 sp3A; s16 sp38; @@ -258,8 +257,8 @@ void func_808CC610(EnVm* this, GlobalContext* globalCtx) { 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); + EffectSsDeadDd_Spawn(play, &this->unk_228, &gZeroVec3f, &gZeroVec3f, &D_808CD5BC, &D_808CD5C0, 150, -25, 16, + 20); func_808CC788(this); } } @@ -274,8 +273,8 @@ void func_808CC788(EnVm* this) { this->actionFunc = func_808CC820; } -void func_808CC820(EnVm* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); +void func_808CC820(EnVm* this, PlayState* play) { + Player* player = GET_PLAYER(play); s16 sp32; f32 temp_f2; @@ -294,7 +293,7 @@ void func_808CC820(EnVm* this, GlobalContext* globalCtx) { } } - if ((this->unk_216 < 0xAAA) || (Player_GetMask(globalCtx) == PLAYER_MASK_STONE) || (this->unk_214 == 0)) { + if ((this->unk_216 < 0xAAA) || (Player_GetMask(play) == 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; @@ -313,7 +312,7 @@ void func_808CC820(EnVm* this, GlobalContext* globalCtx) { } Math_StepToF(&this->unk_220, 0.01f, 0.012f); - CollisionCheck_SetAT(globalCtx, &globalCtx->colChkCtx, &this->colliderTris.base); + CollisionCheck_SetAT(play, &play->colChkCtx, &this->colliderTris.base); if (this->unk_210 == 0) { this->unk_210 = 1; @@ -333,7 +332,7 @@ void func_808CCA10(EnVm* this) { this->actionFunc = func_808CCAA4; } -void func_808CCAA4(EnVm* this, GlobalContext* globalCtx) { +void func_808CCAA4(EnVm* this, PlayState* play) { Math_ApproachS(&this->unk_216, 0, 0xA, 0x5DC); SkelAnime_Update(&this->skelAnime); if (this->unk_214 == 0) { @@ -349,7 +348,7 @@ void func_808CCB08(EnVm* this) { this->actionFunc = func_808CCB50; } -void func_808CCB50(EnVm* this, GlobalContext* globalCtx) { +void func_808CCB50(EnVm* this, PlayState* play) { Math_ApproachS(&this->unk_216, 0, 0xA, 0x5DC); if (this->unk_214 > 0) { @@ -365,10 +364,10 @@ void func_808CCB50(EnVm* this, GlobalContext* globalCtx) { } } -void func_808CCBE4(EnVm* this, GlobalContext* globalCtx) { +void func_808CCBE4(EnVm* this, PlayState* play) { Animation_Change(&this->skelAnime, &object_vm_Anim_000068, -1.0f, Animation_GetLastFrame(&object_vm_Anim_000068), 0.0f, ANIMMODE_ONCE, 0.0f); - Enemy_StartFinishingBlow(globalCtx, &this->actor); + Enemy_StartFinishingBlow(play, &this->actor); Actor_SetColorFilter(&this->actor, 0x4000, 255, 0, 33); this->unk_214 = 33; this->unk_220 = 0.0f; @@ -383,27 +382,27 @@ void func_808CCBE4(EnVm* this, GlobalContext* globalCtx) { this->actionFunc = func_808CCCF0; } -void func_808CCCF0(EnVm* this, GlobalContext* globalCtx) { +void func_808CCCF0(EnVm* this, PlayState* play) { this->unk_216 += 0x5DC; this->unk_218 += 0x9C4; Actor_MoveWithGravity(&this->actor); - Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 30.0f, 20.0f, 40.0f, 7); + Actor_UpdateBgCheckInfo(play, &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, + EnBom* bomb = (EnBom*)Actor_Spawn(&play->actorCtx, play, ACTOR_EN_BOM, this->actor.world.pos.x, this->actor.world.pos.y, this->actor.world.pos.z, 0, 0, 0x6FF, 0); if (bomb != NULL) { bomb->timer = 0; } } else if (this->unk_214 == 0) { - Item_DropCollectibleRandom(globalCtx, &this->actor, &this->actor.world.pos, 0xB0); + Item_DropCollectibleRandom(play, &this->actor, &this->actor.world.pos, 0xB0); Actor_MarkForDeath(&this->actor); } } -void func_808CCDE4(EnVm* this, GlobalContext* globalCtx) { +void func_808CCDE4(EnVm* this, PlayState* play) { s32 i; s16 temp_v0; @@ -419,7 +418,7 @@ void func_808CCDE4(EnVm* this, GlobalContext* globalCtx) { if (i != ARRAY_COUNT(this->colliderJntSphElements)) { func_800BE5CC(&this->actor, &this->colliderJntSph, i); if (this->actor.colChkInfo.damageEffect == 0) { - func_808CCBE4(this, globalCtx); + func_808CCBE4(this, play); } 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) { @@ -430,16 +429,16 @@ void func_808CCDE4(EnVm* this, GlobalContext* globalCtx) { } } -void EnVm_Update(Actor* thisx, GlobalContext* globalCtx) { +void EnVm_Update(Actor* thisx, PlayState* play) { s32 pad; EnVm* this = THIS; - func_808CCDE4(this, globalCtx); + func_808CCDE4(this, play); 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); + func_800B31BC(play, &this->unk_234, 20, -1, 155, 10); + if ((play->gameplayFrames % 2) != 0) { + func_800BBFB0(play, &this->unk_234, 6.0f, 1, 120, 20, 1); } Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_BIMOS_LAZER_GND - SFX_FLAG); } @@ -448,17 +447,17 @@ void EnVm_Update(Actor* thisx, GlobalContext* globalCtx) { func_800B9010(&this->actor, NA_SE_EN_BIMOS_LAZER - SFX_FLAG); } - this->actionFunc(this, globalCtx); + this->actionFunc(this, play); this->unk_212 += 12; - CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->colliderJntSph.base); + CollisionCheck_SetOC(play, &play->colChkCtx, &this->colliderJntSph.base); if (this->actionFunc != func_808CCCF0) { - CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->colliderJntSph.base); + CollisionCheck_SetAC(play, &play->colChkCtx, &this->colliderJntSph.base); } } -s32 EnVm_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, Actor* thisx) { +s32 EnVm_OverrideLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, Actor* thisx) { EnVm* this = THIS; if (limbIndex == OBJECT_VM_LIMB_02) { @@ -470,7 +469,7 @@ s32 EnVm_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, return false; } -void EnVm_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx) { +void EnVm_PostLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx) { s32 pad; EnVm* this = THIS; Vec3f sp5C; @@ -483,12 +482,12 @@ void EnVm_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec if (limbIndex == OBJECT_VM_LIMB_02) { sp4C = NULL; - Matrix_GetStateTranslation(&this->actor.focus.pos); - Matrix_GetStateTranslationAndScaledZ(1600.0f, &this->unk_228); - Matrix_GetStateTranslationAndScaledZ(this->unk_224 * 71.428566f, &this->unk_234); + 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)) { + if (BgCheck_EntityLineTest1(&play->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); @@ -504,12 +503,12 @@ void EnVm_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec } } -void EnVm_Draw(Actor* thisx, GlobalContext* globalCtx) { +void EnVm_Draw(Actor* thisx, PlayState* play) { s32 pad; EnVm* this = THIS; Gfx* gfx; - OPEN_DISPS(globalCtx->state.gfxCtx); + OPEN_DISPS(play->state.gfxCtx); gfx = POLY_OPA_DISP; @@ -517,7 +516,7 @@ void EnVm_Draw(Actor* thisx, GlobalContext* globalCtx) { POLY_OPA_DISP = &gfx[1]; - SkelAnime_DrawOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, EnVm_OverrideLimbDraw, + SkelAnime_DrawOpa(play, this->skelAnime.skeleton, this->skelAnime.jointTable, EnVm_OverrideLimbDraw, EnVm_PostLimbDraw, &this->actor); if (this->unk_210 == 2) { @@ -526,13 +525,13 @@ void EnVm_Draw(Actor* thisx, GlobalContext* globalCtx) { gSPDisplayList(&gfx[0], &sSetupDL[6 * 60]); gDPSetColorDither(&gfx[1], G_CD_DISABLE); - Matrix_InsertTranslation(this->unk_234.x, this->unk_234.y + 10.0f, this->unk_234.z, MTXMODE_NEW); + Matrix_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); + gSPMatrix(&gfx[2], Matrix_NewMtx(play->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]); + gSPSegment(&gfx[5], 0x08, D_808CD58C[play->gameplayFrames & 7]); gSPDisplayList(&gfx[6], gameplay_keep_DL_044300); POLY_XLU_DISP = &gfx[7]; @@ -541,18 +540,17 @@ void EnVm_Draw(Actor* thisx, GlobalContext* globalCtx) { if (this->unk_224 > 0.0f) { gfx = POLY_OPA_DISP; - gSPSegment(&gfx[0], 0x08, func_8012CB28(globalCtx->state.gfxCtx, 0, this->unk_212)); + gSPSegment(&gfx[0], 0x08, func_8012CB28(play->state.gfxCtx, 0, this->unk_212)); - Matrix_InsertTranslation(this->actor.focus.pos.x, this->actor.focus.pos.y, this->actor.focus.pos.z, - MTXMODE_NEW); - Matrix_InsertRotation(this->unk_216, this->unk_218 + this->actor.shape.rot.y, 0, MTXMODE_APPLY); + Matrix_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); + gSPMatrix(&gfx[1], Matrix_NewMtx(play->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); + CLOSE_DISPS(play->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 1901ac34a..dd1c36aa2 100644 --- a/src/overlays/actors/ovl_En_Vm/z_en_vm.h +++ b/src/overlays/actors/ovl_En_Vm/z_en_vm.h @@ -5,7 +5,7 @@ struct EnVm; -typedef void (*EnVmActionFunc)(struct EnVm*, GlobalContext*); +typedef void (*EnVmActionFunc)(struct EnVm*, PlayState*); #define ENVM_GET_FF00(thisx) (((thisx)->params >> 8) & 0xFF) @@ -14,25 +14,25 @@ typedef void (*EnVmActionFunc)(struct EnVm*, GlobalContext*); #define ENVM_FF00_FF 0xFF typedef struct EnVm { - /* 0x0000 */ Actor actor; - /* 0x0144 */ SkelAnime skelAnime; - /* 0x0188 */ Vec3s jointTable[11]; - /* 0x01CA */ Vec3s morphTable[11]; - /* 0x020C */ EnVmActionFunc actionFunc; - /* 0x0210 */ u8 unk_210; - /* 0x0212 */ s16 unk_212; - /* 0x0214 */ s16 unk_214; - /* 0x0216 */ s16 unk_216; - /* 0x0218 */ s16 unk_218; - /* 0x021C */ f32 unk_21C; - /* 0x0220 */ f32 unk_220; - /* 0x0224 */ f32 unk_224; - /* 0x0228 */ Vec3f unk_228; - /* 0x0234 */ Vec3f unk_234; - /* 0x0240 */ ColliderJntSph colliderJntSph; - /* 0x0260 */ ColliderJntSphElement colliderJntSphElements[2]; - /* 0x02E0 */ ColliderTris colliderTris; - /* 0x0300 */ ColliderTrisElement colliderTrisElements[1]; + /* 0x000 */ Actor actor; + /* 0x144 */ SkelAnime skelAnime; + /* 0x188 */ Vec3s jointTable[11]; + /* 0x1CA */ Vec3s morphTable[11]; + /* 0x20C */ EnVmActionFunc actionFunc; + /* 0x210 */ u8 unk_210; + /* 0x212 */ s16 unk_212; + /* 0x214 */ s16 unk_214; + /* 0x216 */ s16 unk_216; + /* 0x218 */ s16 unk_218; + /* 0x21C */ f32 unk_21C; + /* 0x220 */ f32 unk_220; + /* 0x224 */ f32 unk_224; + /* 0x228 */ Vec3f unk_228; + /* 0x234 */ Vec3f unk_234; + /* 0x240 */ ColliderJntSph colliderJntSph; + /* 0x260 */ ColliderJntSphElement colliderJntSphElements[2]; + /* 0x2E0 */ ColliderTris colliderTris; + /* 0x300 */ ColliderTrisElement colliderTrisElements[1]; } EnVm; // size = 0x35C extern const ActorInit En_Vm_InitVars; diff --git a/src/overlays/actors/ovl_En_Wallmas/z_en_wallmas.c b/src/overlays/actors/ovl_En_Wallmas/z_en_wallmas.c index 1b88d692b..16cfa6a4b 100644 --- a/src/overlays/actors/ovl_En_Wallmas/z_en_wallmas.c +++ b/src/overlays/actors/ovl_En_Wallmas/z_en_wallmas.c @@ -12,36 +12,36 @@ #define THIS ((EnWallmas*)thisx) -void EnWallmas_Init(Actor* thisx, GlobalContext* globalCtx); -void EnWallmas_Destroy(Actor* thisx, GlobalContext* globalCtx); -void EnWallmas_Update(Actor* thisx, GlobalContext* globalCtx); -void EnWallmas_Draw(Actor* thisx, GlobalContext* globalCtx); +void EnWallmas_Init(Actor* thisx, PlayState* play); +void EnWallmas_Destroy(Actor* thisx, PlayState* play); +void EnWallmas_Update(Actor* thisx, PlayState* play); +void EnWallmas_Draw(Actor* thisx, PlayState* play); -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_TimerInit(EnWallmas* this, PlayState* play); +void EnWallmas_WaitToDrop(EnWallmas* this, PlayState* play); +void EnWallmas_SetupDrop(EnWallmas* this, PlayState* play); +void EnWallmas_Drop(EnWallmas* this, PlayState* play); +void EnWallmas_SetupLand(EnWallmas* this, PlayState* play); +void EnWallmas_Land(EnWallmas* this, PlayState* play); void EnWallmas_SetupStand(EnWallmas* this); -void EnWallmas_Stand(EnWallmas* this, GlobalContext* globalCtx); +void EnWallmas_Stand(EnWallmas* this, PlayState* play); void EnWallmas_SetupWalk(EnWallmas* this); -void EnWallmas_Walk(EnWallmas* this, GlobalContext* globalCtx); +void EnWallmas_Walk(EnWallmas* this, PlayState* play); void EnWallmas_SetupJumpToCeiling(EnWallmas* this); -void EnWallmas_JumpToCeiling(EnWallmas* this, GlobalContext* globalCtx); +void EnWallmas_JumpToCeiling(EnWallmas* this, PlayState* play); void EnWallmas_SetupReturnToCeiling(EnWallmas* this); -void EnWallmas_ReturnToCeiling(EnWallmas* this, GlobalContext* globalCtx); -void EnWallmas_Damage(EnWallmas* this, GlobalContext* globalCtx); +void EnWallmas_ReturnToCeiling(EnWallmas* this, PlayState* play); +void EnWallmas_Damage(EnWallmas* this, PlayState* play); 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_Cooldown(EnWallmas* this, PlayState* play); +void EnWallmas_SetupDie(EnWallmas* this, PlayState* play); +void EnWallmas_Die(EnWallmas* this, PlayState* play); +void EnWallmas_SetupTakePlayer(EnWallmas* this, PlayState* play); +void EnWallmas_TakePlayer(EnWallmas* this, PlayState* play); 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); +void EnWallmas_WaitForProximity(EnWallmas* this, PlayState* play); +void EnWallmas_WaitForSwitchFlag(EnWallmas* this, PlayState* play); +void EnWallmas_Stun(EnWallmas* this, PlayState* play); const ActorInit En_Wallmas_InitVars = { ACTOR_EN_WALLMAS, @@ -139,14 +139,14 @@ 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, }; -void EnWallmas_Init(Actor* thisx, GlobalContext* globalCtx) { +void EnWallmas_Init(Actor* thisx, PlayState* play) { EnWallmas* this = THIS; Actor_ProcessInitChain(&this->actor, sInitChain); ActorShape_Init(&this->actor.shape, 0.0f, NULL, 0.5f); - SkelAnime_InitFlex(globalCtx, &this->skelAnime, &gWallmasterSkel, &gWallmasterIdleAnim, this->jointTable, + SkelAnime_InitFlex(play, &this->skelAnime, &gWallmasterSkel, &gWallmasterIdleAnim, this->jointTable, this->morphTable, WALLMASTER_LIMB_MAX); - Collider_InitAndSetCylinder(globalCtx, &this->collider, &this->actor, &sCylinderInit); + Collider_InitAndSetCylinder(play, &this->collider, &this->actor, &sCylinderInit); CollisionCheck_SetInfo(&this->actor.colChkInfo, &sDamageTable, &sColChkInfoInit); this->switchFlag = WALLMASTER_GET_SWITCH_FLAG(thisx); @@ -161,7 +161,7 @@ void EnWallmas_Init(Actor* thisx, GlobalContext* globalCtx) { Actor_SetFocus(&this->actor, 25.0f); if (WALLMASTER_IS_FROZEN(&this->actor)) { - Actor_SpawnAsChild(&globalCtx->actorCtx, &this->actor, globalCtx, ACTOR_OBJ_ICE_POLY, this->actor.world.pos.x, + Actor_SpawnAsChild(&play->actorCtx, &this->actor, play, 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; @@ -170,7 +170,7 @@ void EnWallmas_Init(Actor* thisx, GlobalContext* globalCtx) { } if (WALLMASTER_GET_TYPE(&this->actor) == WALLMASTER_TYPE_FLAG) { - if (Flags_GetSwitch(globalCtx, this->switchFlag)) { + if (Flags_GetSwitch(play, this->switchFlag)) { Actor_MarkForDeath(&this->actor); return; } @@ -179,14 +179,14 @@ void EnWallmas_Init(Actor* thisx, GlobalContext* globalCtx) { } else if (WALLMASTER_GET_TYPE(&this->actor) == WALLMASTER_TYPE_PROXIMITY) { EnWallmas_ProximityOrSwitchInit(this); } else { - EnWallmas_TimerInit(this, globalCtx); + EnWallmas_TimerInit(this, play); } } -void EnWallmas_Destroy(Actor* thisx, GlobalContext* globalCtx) { +void EnWallmas_Destroy(Actor* thisx, PlayState* play) { EnWallmas* this = THIS; - Collider_DestroyCylinder(globalCtx, &this->collider); + Collider_DestroyCylinder(play, &this->collider); if (this->actor.parent != NULL) { EnEncount1* encount1 = (EnEncount1*)this->actor.parent; @@ -208,18 +208,18 @@ void EnWallmas_Freeze(EnWallmas* this) { Actor_SetColorFilter(&this->actor, 0x4000, 255, 0, 80); } -void EnWallmas_ThawIfFrozen(EnWallmas* this, GlobalContext* globalCtx) { +void EnWallmas_ThawIfFrozen(EnWallmas* this, PlayState* play) { 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); + Actor_SpawnIceEffects(play, &this->actor, this->limbPos, 11, 2, 0.3f, 0.2f); this->actor.flags |= ACTOR_FLAG_400; } } -void EnWallmas_TimerInit(EnWallmas* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); +void EnWallmas_TimerInit(EnWallmas* this, PlayState* play) { + Player* player = GET_PLAYER(play); this->actor.flags &= ~ACTOR_FLAG_1; this->actor.flags |= ACTOR_FLAG_20; @@ -231,8 +231,8 @@ void EnWallmas_TimerInit(EnWallmas* this, GlobalContext* globalCtx) { this->actionFunc = EnWallmas_WaitToDrop; } -void EnWallmas_WaitToDrop(EnWallmas* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); +void EnWallmas_WaitToDrop(EnWallmas* this, PlayState* play) { + Player* player = GET_PLAYER(play); Vec3f* playerPos = &player->actor.world.pos; this->actor.world.pos = *playerPos; @@ -247,7 +247,7 @@ void EnWallmas_WaitToDrop(EnWallmas* this, GlobalContext* globalCtx) { (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); + AudioSfx_StopById(NA_SE_EN_FALL_AIM); this->timer = 130; } @@ -256,12 +256,12 @@ void EnWallmas_WaitToDrop(EnWallmas* this, GlobalContext* globalCtx) { } if (this->timer == 0) { - EnWallmas_SetupDrop(this, globalCtx); + EnWallmas_SetupDrop(this, play); } } -void EnWallmas_SetupDrop(EnWallmas* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); +void EnWallmas_SetupDrop(EnWallmas* this, PlayState* play) { + Player* player = GET_PLAYER(play); Animation_Change(&this->skelAnime, &gWallmasterLungeAnim, 0.0f, 20.0f, Animation_GetLastFrame(&gWallmasterLungeAnim), ANIMMODE_ONCE, 0.0f); @@ -276,32 +276,32 @@ void EnWallmas_SetupDrop(EnWallmas* this, GlobalContext* globalCtx) { this->actionFunc = EnWallmas_Drop; } -void EnWallmas_Drop(EnWallmas* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); +void EnWallmas_Drop(EnWallmas* this, PlayState* play) { + Player* player = GET_PLAYER(play); if ((player->stateFlags2 & 0x80) || (player->actor.freezeTimer > 0)) { EnWallmas_SetupReturnToCeiling(this); - } else if (!Play_InCsMode(globalCtx) && !(player->stateFlags2 & 0x10) && (player->invincibilityTimer >= 0) && + } else if (!Play_InCsMode(play) && !(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); + EnWallmas_SetupTakePlayer(this, play); } 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); + EnWallmas_SetupLand(this, play); } } -void EnWallmas_SetupLand(EnWallmas* this, GlobalContext* globalCtx) { +void EnWallmas_SetupLand(EnWallmas* this, PlayState* play) { Animation_Change(&this->skelAnime, &gWallmasterJumpAnim, 1.0f, 41.0f, Animation_GetLastFrame(&gWallmasterJumpAnim), ANIMMODE_ONCE, -3.0f); - Actor_SpawnFloorDustRing(globalCtx, &this->actor, &this->actor.world.pos, 15.0f, 6, 20.0f, 300, 100, true); + Actor_SpawnFloorDustRing(play, &this->actor, &this->actor.world.pos, 15.0f, 6, 20.0f, 300, 100, true); Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_FALL_LAND); this->actionFunc = EnWallmas_Land; } -void EnWallmas_Land(EnWallmas* this, GlobalContext* globalCtx) { +void EnWallmas_Land(EnWallmas* this, PlayState* play) { if (SkelAnime_Update(&this->skelAnime)) { EnWallmas_SetupStand(this); } @@ -312,7 +312,7 @@ void EnWallmas_SetupStand(EnWallmas* this) { this->actionFunc = EnWallmas_Stand; } -void EnWallmas_Stand(EnWallmas* this, GlobalContext* globalCtx) { +void EnWallmas_Stand(EnWallmas* this, PlayState* play) { if (SkelAnime_Update(&this->skelAnime)) { EnWallmas_SetupWalk(this); } @@ -327,7 +327,7 @@ void EnWallmas_SetupWalk(EnWallmas* this) { this->actionFunc = EnWallmas_Walk; } -void EnWallmas_Walk(EnWallmas* this, GlobalContext* globalCtx) { +void EnWallmas_Walk(EnWallmas* this, PlayState* play) { if (SkelAnime_Update(&this->skelAnime)) { EnWallmas_SetupJumpToCeiling(this); } @@ -346,7 +346,7 @@ void EnWallmas_SetupJumpToCeiling(EnWallmas* this) { this->actionFunc = EnWallmas_JumpToCeiling; } -void EnWallmas_JumpToCeiling(EnWallmas* this, GlobalContext* globalCtx) { +void EnWallmas_JumpToCeiling(EnWallmas* this, PlayState* play) { if (SkelAnime_Update(&this->skelAnime)) { EnWallmas_SetupReturnToCeiling(this); } @@ -360,8 +360,8 @@ void EnWallmas_SetupReturnToCeiling(EnWallmas* this) { this->actionFunc = EnWallmas_ReturnToCeiling; } -void EnWallmas_ReturnToCeiling(EnWallmas* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); +void EnWallmas_ReturnToCeiling(EnWallmas* this, PlayState* play) { + Player* player = GET_PLAYER(play); SkelAnime_Update(&this->skelAnime); if (this->skelAnime.curFrame > 20.0f) { @@ -382,7 +382,7 @@ void EnWallmas_ReturnToCeiling(EnWallmas* this, GlobalContext* globalCtx) { 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); + EnWallmas_TimerInit(this, play); } else { EnWallmas_ProximityOrSwitchInit(this); } @@ -402,10 +402,10 @@ void EnWallmas_SetupDamage(EnWallmas* this, s32 arg1) { this->actionFunc = EnWallmas_Damage; } -void EnWallmas_Damage(EnWallmas* this, GlobalContext* globalCtx) { +void EnWallmas_Damage(EnWallmas* this, PlayState* play) { if (SkelAnime_Update(&this->skelAnime)) { if (this->actor.colChkInfo.health == 0) { - EnWallmas_SetupDie(this, globalCtx); + EnWallmas_SetupDie(this, play); } else { EnWallmas_SetupCooldown(this); } @@ -426,24 +426,24 @@ void EnWallmas_SetupCooldown(EnWallmas* this) { this->actionFunc = EnWallmas_Cooldown; } -void EnWallmas_Cooldown(EnWallmas* this, GlobalContext* globalCtx) { +void EnWallmas_Cooldown(EnWallmas* this, PlayState* play) { if (SkelAnime_Update(&this->skelAnime)) { EnWallmas_SetupReturnToCeiling(this); } } -void EnWallmas_SetupDie(EnWallmas* this, GlobalContext* globalCtx) { +void EnWallmas_SetupDie(EnWallmas* this, PlayState* play) { 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); + func_800B3030(play, &this->actor.world.pos, &gZeroVec3f, &gZeroVec3f, 250, -10, 2); + SoundSource_PlaySfxAtFixedWorldPos(play, &this->actor.world.pos, 11, NA_SE_EN_EXTINCT); this->actionFunc = EnWallmas_Die; } -void EnWallmas_Die(EnWallmas* this, GlobalContext* globalCtx) { +void EnWallmas_Die(EnWallmas* this, PlayState* play) { 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); + Item_DropCollectibleRandom(play, &this->actor, &this->actor.world.pos, 0x90); Actor_MarkForDeath(&this->actor); } @@ -451,18 +451,18 @@ void EnWallmas_Die(EnWallmas* this, GlobalContext* globalCtx) { this->actor.scale.y = this->actor.scale.x; } -void EnWallmas_SetupTakePlayer(EnWallmas* this, GlobalContext* globalCtx) { +void EnWallmas_SetupTakePlayer(EnWallmas* this, PlayState* play) { Animation_MorphToPlayOnce(&this->skelAnime, &gWallmasterHoverAnim, -5.0f); this->timer = -30; this->actionFunc = EnWallmas_TakePlayer; this->actor.speedXZ = 0.0f; this->actor.velocity.y = 0.0f; this->yTarget = this->actor.playerHeightRel; - func_800B724C(globalCtx, &this->actor, 18); + func_800B724C(play, &this->actor, 18); } -void EnWallmas_TakePlayer(EnWallmas* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); +void EnWallmas_TakePlayer(EnWallmas* this, PlayState* play) { + Player* player = GET_PLAYER(play); if (Animation_OnFrame(&this->skelAnime, 1.0f)) { func_800B8E58(player, player->ageProperties->unk_92 + NA_SE_VO_LI_DAMAGE_S); @@ -499,7 +499,7 @@ void EnWallmas_TakePlayer(EnWallmas* this, GlobalContext* globalCtx) { if (this->timer == 30) { play_sound(NA_SE_OC_ABYSS); - func_80169FDC(&globalCtx->state); + func_80169FDC(&play->state); } } @@ -514,17 +514,17 @@ void EnWallmas_ProximityOrSwitchInit(EnWallmas* this) { } } -void EnWallmas_WaitForProximity(EnWallmas* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); +void EnWallmas_WaitForProximity(EnWallmas* this, PlayState* play) { + Player* player = GET_PLAYER(play); if (Math_Vec3f_DistXZ(&this->actor.home.pos, &player->actor.world.pos) < this->detectionRadius) { - EnWallmas_TimerInit(this, globalCtx); + EnWallmas_TimerInit(this, play); } } -void EnWallmas_WaitForSwitchFlag(EnWallmas* this, GlobalContext* globalCtx) { - if (Flags_GetSwitch(globalCtx, this->switchFlag)) { - EnWallmas_TimerInit(this, globalCtx); +void EnWallmas_WaitForSwitchFlag(EnWallmas* this, PlayState* play) { + if (Flags_GetSwitch(play, this->switchFlag)) { + EnWallmas_TimerInit(this, play); this->timer = 81; } } @@ -539,13 +539,13 @@ void EnWallmas_SetupStun(EnWallmas* this) { this->actionFunc = EnWallmas_Stun; } -void EnWallmas_Stun(EnWallmas* this, GlobalContext* globalCtx) { +void EnWallmas_Stun(EnWallmas* this, PlayState* play) { if (this->timer != 0) { this->timer--; } if (this->timer == 0) { - EnWallmas_ThawIfFrozen(this, globalCtx); + EnWallmas_ThawIfFrozen(this, play); if (this->actor.colChkInfo.health == 0) { EnWallmas_SetupDamage(this, false); } else { @@ -555,7 +555,7 @@ void EnWallmas_Stun(EnWallmas* this, GlobalContext* globalCtx) { } } -void EnWallmas_UpdateDamage(EnWallmas* this, GlobalContext* globalCtx) { +void EnWallmas_UpdateDamage(EnWallmas* this, PlayState* play) { if (this->collider.base.acFlags & AC_HIT) { this->collider.base.acFlags &= ~AC_HIT; Actor_SetDropFlag(&this->actor, &this->collider.info); @@ -563,14 +563,14 @@ void EnWallmas_UpdateDamage(EnWallmas* this, GlobalContext* globalCtx) { 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); + Enemy_StartFinishingBlow(play, &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); + EnWallmas_ThawIfFrozen(this, play); if (this->actor.colChkInfo.damageEffect != WALLMASTER_DMGEFF_HOOKSHOT) { if (this->actor.colChkInfo.damageEffect == WALLMASTER_DMGEFF_ICE_ARROW) { @@ -603,9 +603,9 @@ void EnWallmas_UpdateDamage(EnWallmas* this, GlobalContext* globalCtx) { 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); + Actor_Spawn(&play->actorCtx, play, ACTOR_EN_CLEAR_TAG, this->collider.info.bumper.hitPos.x, + this->collider.info.bumper.hitPos.y, this->collider.info.bumper.hitPos.z, 0, 0, 0, + CLEAR_TAG_LARGE_LIGHT_RAYS); } EnWallmas_SetupDamage(this, true); @@ -615,12 +615,12 @@ void EnWallmas_UpdateDamage(EnWallmas* this, GlobalContext* globalCtx) { } } -void EnWallmas_Update(Actor* thisx, GlobalContext* globalCtx) { +void EnWallmas_Update(Actor* thisx, PlayState* play) { s32 pad; EnWallmas* this = THIS; - EnWallmas_UpdateDamage(this, globalCtx); - this->actionFunc(this, globalCtx); + EnWallmas_UpdateDamage(this, play); + this->actionFunc(this, play); if ((this->actionFunc != EnWallmas_WaitToDrop) && (this->actionFunc != EnWallmas_WaitForProximity) && (this->actionFunc != EnWallmas_TakePlayer) && (this->actionFunc != EnWallmas_WaitForSwitchFlag)) { @@ -629,15 +629,15 @@ void EnWallmas_Update(Actor* thisx, GlobalContext* globalCtx) { } if (this->actionFunc != EnWallmas_Drop) { - Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 20.0f, 25.0f, 0.0f, 0x1DU); + Actor_UpdateBgCheckInfo(play, &this->actor, 20.0f, 25.0f, 0.0f, 0x1D); } if ((this->actionFunc != EnWallmas_Die) && (this->actionFunc != EnWallmas_Drop)) { Collider_UpdateCylinder(&this->actor, &this->collider); - CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + CollisionCheck_SetOC(play, &play->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); + CollisionCheck_SetAC(play, &play->colChkCtx, &this->collider.base); } } @@ -655,14 +655,14 @@ void EnWallmas_Update(Actor* thisx, GlobalContext* globalCtx) { } } -void EnWallmas_DrawShadow(EnWallmas* this, GlobalContext* globalCtx) { +void EnWallmas_DrawShadow(EnWallmas* this, PlayState* play) { 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); + OPEN_DISPS(play->state.gfxCtx); gfx = POLY_OPA_DISP; @@ -670,7 +670,7 @@ void EnWallmas_DrawShadow(EnWallmas* this, GlobalContext* globalCtx) { gDPSetPrimColor(&gfx[1], 0, 0, 0, 0, 0, 255); func_800C0094(this->actor.floorPoly, this->actor.world.pos.x, this->actor.floorHeight, this->actor.world.pos.z, &mf); - Matrix_InsertMatrix(&mf, MTXMODE_NEW); + Matrix_Mult(&mf, MTXMODE_NEW); if ((this->actionFunc != EnWallmas_WaitToDrop) && (this->actionFunc != EnWallmas_ReturnToCeiling) && (this->actionFunc != EnWallmas_TakePlayer) && (this->actionFunc != EnWallmas_WaitForSwitchFlag)) { @@ -680,17 +680,16 @@ void EnWallmas_DrawShadow(EnWallmas* this, GlobalContext* globalCtx) { } 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); + gSPMatrix(&gfx[2], Matrix_NewMtx(play->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); + CLOSE_DISPS(play->state.gfxCtx); } } -s32 EnWallmas_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, - Actor* thisx) { +s32 EnWallmas_OverrideLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, Actor* thisx) { EnWallmas* this = THIS; if (limbIndex == WALLMASTER_LIMB_ROOT) { @@ -704,55 +703,53 @@ s32 EnWallmas_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dL return false; } -void EnWallmas_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx) { +void EnWallmas_PostLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx) { EnWallmas* this = THIS; Gfx* gfx; if (sLimbIndexToLimbPosIndex[limbIndex] != -1) { - Matrix_GetStateTranslation(&this->limbPos[sLimbIndexToLimbPosIndex[limbIndex]]); + Matrix_MultZero(&this->limbPos[sLimbIndexToLimbPosIndex[limbIndex]]); } if (limbIndex == WALLMASTER_LIMB_WRIST) { - Matrix_GetStateTranslationAndScaledX(1000.0f, &this->limbPos[9]); - Matrix_GetStateTranslationAndScaledX(-1000.0f, &this->limbPos[10]); + 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); + OPEN_DISPS(play->state.gfxCtx); gfx = POLY_OPA_DISP; - Matrix_StatePush(); - Matrix_InsertTranslation(1600.0f, -700.0f, -1700.0f, MTXMODE_APPLY); - Matrix_RotateY(0x2AAA, MTXMODE_APPLY); - Matrix_InsertZRotation_s(0xAAA, MTXMODE_APPLY); + Matrix_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); + gSPMatrix(&gfx[0], Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(&gfx[1], gWallmasterLittleFingerDL); POLY_OPA_DISP = &gfx[2]; - Matrix_StatePop(); + Matrix_Pop(); - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->state.gfxCtx); } } -void EnWallmas_Draw(Actor* thisx, GlobalContext* globalCtx) { +void EnWallmas_Draw(Actor* thisx, PlayState* play) { 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); + func_8012C28C(play->state.gfxCtx); + SkelAnime_DrawFlexOpa(play, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, + EnWallmas_OverrideLimbDraw, EnWallmas_PostLimbDraw, &this->actor); + Actor_DrawDamageEffects(play, &this->actor, this->limbPos, ARRAY_COUNT(this->limbPos), this->drawDmgEffScale, + this->drawDmgEffFrozenSteamScale, this->drawDmgEffAlpha, this->drawDmgEffType); } if (this->actor.colorFilterTimer != 0) { - func_800AE5A0(globalCtx); + func_800AE5A0(play); } - EnWallmas_DrawShadow(this, globalCtx); + EnWallmas_DrawShadow(this, play); } 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 06d4d24d1..af7c6f18c 100644 --- a/src/overlays/actors/ovl_En_Wallmas/z_en_wallmas.h +++ b/src/overlays/actors/ovl_En_Wallmas/z_en_wallmas.h @@ -25,14 +25,14 @@ * the timer to 130 frames if the player strays too far from the Wallmaster's current position. */ typedef enum { - /* 0x00 */ WALLMASTER_TYPE_TIMER_ONLY, - /* 0x01 */ WALLMASTER_TYPE_PROXIMITY, - /* 0x02 */ WALLMASTER_TYPE_FLAG + /* 0x0 */ WALLMASTER_TYPE_TIMER_ONLY, + /* 0x1 */ WALLMASTER_TYPE_PROXIMITY, + /* 0x2 */ WALLMASTER_TYPE_FLAG } WallmasterType; struct EnWallmas; -typedef void (*EnWallmasActionFunc)(struct EnWallmas*, GlobalContext*); +typedef void (*EnWallmasActionFunc)(struct EnWallmas*, PlayState*); typedef struct EnWallmas { /* 0x000 */ Actor actor; 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 51ef3ef38..34c8db4bb 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 @@ -11,15 +11,15 @@ #define THIS ((EnWarpUzu*)thisx) -void EnWarpUzu_Init(Actor* thisx, GlobalContext* globalCtx); -void EnWarpUzu_Destroy(Actor* thisx, GlobalContext* globalCtx); -void EnWarpUzu_Update(Actor* thisx, GlobalContext* globalCtx); -void EnWarpUzu_Draw(Actor* thisx, GlobalContext* globalCtx); +void EnWarpUzu_Init(Actor* thisx, PlayState* play); +void EnWarpUzu_Destroy(Actor* thisx, PlayState* play); +void EnWarpUzu_Update(Actor* thisx, PlayState* play); +void EnWarpUzu_Draw(Actor* thisx, PlayState* play); -void func_80A66208(EnWarpUzu* this, GlobalContext* globalCtx); -void func_80A66278(EnWarpUzu* this, GlobalContext* globalCtx); -void func_80A66384(EnWarpUzu* this, GlobalContext* globalCtx); -void EnWarpUzu_DoNothing(EnWarpUzu* this, GlobalContext* globalCtx); +void func_80A66208(EnWarpUzu* this, PlayState* play); +void func_80A66278(EnWarpUzu* this, PlayState* play); +void func_80A66384(EnWarpUzu* this, PlayState* play); +void EnWarpUzu_DoNothing(EnWarpUzu* this, PlayState* play); const ActorInit En_Warp_Uzu_InitVars = { ACTOR_EN_WARP_UZU, @@ -60,77 +60,77 @@ static InitChainEntry sInitChain[] = { ICHAIN_VEC3F_DIV1000(scale, 100, ICHAIN_STOP), }; -void EnWarpUzu_Init(Actor* thisx, GlobalContext* globalCtx) { +void EnWarpUzu_Init(Actor* thisx, PlayState* play) { EnWarpUzu* this = THIS; Actor_ProcessInitChain(&this->actor, sInitChain); - Collider_InitAndSetCylinder(globalCtx, &this->collider, thisx, &sCylinderInit); + Collider_InitAndSetCylinder(play, &this->collider, thisx, &sCylinderInit); thisx->targetMode = 0; - func_80A66208(this, globalCtx); + func_80A66208(this, play); } -void EnWarpUzu_Destroy(Actor* thisx, GlobalContext* globalCtx) { +void EnWarpUzu_Destroy(Actor* thisx, PlayState* play) { EnWarpUzu* this = THIS; - Collider_DestroyCylinder(globalCtx, &this->collider); + Collider_DestroyCylinder(play, &this->collider); } static Vec3f D_80A664FC = { 0.0f, 53.0f, -29.0f }; -void func_80A66208(EnWarpUzu* this, GlobalContext* globalCtx) { +void func_80A66208(EnWarpUzu* this, PlayState* play) { 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; } -void func_80A66278(EnWarpUzu* this, GlobalContext* globalCtx) { +void func_80A66278(EnWarpUzu* this, PlayState* play) { Player* player; s16 temp_v0; s16 phi_a0; s16 phi_v1; do { - player = GET_PLAYER(globalCtx); - if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { - func_80A66384(this, globalCtx); + player = GET_PLAYER(play); + if (Actor_ProcessTalkRequest(&this->actor, &play->state)) { + func_80A66384(this, play); } else { phi_a0 = ABS((s16)(Actor_YawBetweenActors(&this->actor, &player->actor) - this->actor.shape.rot.y)); temp_v0 = player->actor.shape.rot.y - this->actor.shape.rot.y; phi_v1 = ABS(temp_v0); if (phi_a0 >= 0x2AAB) { if (phi_v1 < 0x238E) { - func_800B8614(&this->actor, globalCtx, 70.0f); + func_800B8614(&this->actor, play, 70.0f); } } } } while (0); } -void func_80A66384(EnWarpUzu* this, GlobalContext* globalCtx) { - globalCtx->nextEntranceIndex = 0x22A0; - gSaveContext.respawn[RESTART_MODE_DOWN].entranceIndex = globalCtx->nextEntranceIndex; - func_80169EFC(&globalCtx->state); +void func_80A66384(EnWarpUzu* this, PlayState* play) { + play->nextEntrance = ENTRANCE(PIRATES_FORTRESS, 10); + gSaveContext.respawn[RESPAWN_MODE_DOWN].entrance = play->nextEntrance; + func_80169EFC(&play->state); gSaveContext.respawnFlag = -2; this->actionFunc = EnWarpUzu_DoNothing; } -void EnWarpUzu_DoNothing(EnWarpUzu* this, GlobalContext* globalCtx) { +void EnWarpUzu_DoNothing(EnWarpUzu* this, PlayState* play) { } -void EnWarpUzu_Update(Actor* thisx, GlobalContext* globalCtx) { +void EnWarpUzu_Update(Actor* thisx, PlayState* play) { EnWarpUzu* this = THIS; s32 pad; this->actor.uncullZoneForward = 1000.0f; - this->actionFunc(this, globalCtx); + this->actionFunc(this, play); Collider_UpdateCylinder(&this->actor, &this->collider); - CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + CollisionCheck_SetOC(play, &play->colChkCtx, &this->collider.base); } -void EnWarpUzu_Draw(Actor* thisx, GlobalContext* globalCtx) { - Gfx_DrawDListOpa(globalCtx, object_warp_uzu_DL_000EC0); +void EnWarpUzu_Draw(Actor* thisx, PlayState* play) { + Gfx_DrawDListOpa(play, object_warp_uzu_DL_000EC0); } diff --git a/src/overlays/actors/ovl_En_Warp_Uzu/z_en_warp_uzu.h b/src/overlays/actors/ovl_En_Warp_Uzu/z_en_warp_uzu.h index 7cc148b97..a1a7766e6 100644 --- a/src/overlays/actors/ovl_En_Warp_Uzu/z_en_warp_uzu.h +++ b/src/overlays/actors/ovl_En_Warp_Uzu/z_en_warp_uzu.h @@ -5,7 +5,7 @@ struct EnWarpUzu; -typedef void (*EnWarpUzuActionFunc)(struct EnWarpUzu*, GlobalContext*); +typedef void (*EnWarpUzuActionFunc)(struct EnWarpUzu*, PlayState*); typedef struct EnWarpUzu { /* 0x000 */ Actor actor; 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 5759b0a9b..4f302e268 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 @@ -12,17 +12,17 @@ #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 EnWarptag_Init(Actor* thisx, PlayState* play); +void EnWarptag_Destroy(Actor* thisx, PlayState* play); +void EnWarptag_Update(Actor* thisx, PlayState* play); +void EnWarpTag_Draw(Actor* thisx, PlayState* play); -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); +void EnWarpTag_CheckDungeonKeepObject(EnWarptag* this, PlayState* play); +void EnWarpTag_WaitForPlayer(EnWarptag* this, PlayState* play); +void EnWarpTag_Unused809C09A0(EnWarptag* this, PlayState* play); +void EnWarpTag_Unused809C0A20(EnWarptag* this, PlayState* play); +void EnWarpTag_RespawnPlayer(EnWarptag* this, PlayState* play); +void EnWarpTag_GrottoReturn(EnWarptag* this, PlayState* play); const ActorInit En_Warp_tag_InitVars = { ACTOR_EN_WARP_TAG, @@ -45,20 +45,20 @@ static InitChainEntry sInitChain[] = { ICHAIN_VEC3S(shape.rot, 0, ICHAIN_STOP), }; -void EnWarptag_Init(Actor* thisx, GlobalContext* globalCtx) { +void EnWarptag_Init(Actor* thisx, PlayState* play) { EnWarptag* this = THIS; Actor_ProcessInitChain(&this->dyna.actor, sInitChain); Actor_SetFocus(&this->dyna.actor, 0.0f); - if (GET_WARPTAG_3C0_MAX(thisx) == WARPTAG_3C0_MAX) { + if (WARPTAG_GET_3C0_MAX(thisx) == WARPTAG_3C0_MAX) { this->dyna.actor.flags &= ~ACTOR_FLAG_1; - if (GET_WARPTAG_INVISIBLE(&this->dyna.actor)) { + if (WARPTAG_GET_INVISIBLE(&this->dyna.actor)) { this->actionFunc = EnWarpTag_WaitForPlayer; } else { - if ((this->dangeonKeepObject = Object_GetIndex(&globalCtx->objectCtx, GAMEPLAY_DANGEON_KEEP)) < 0) { + if ((this->dangeonKeepObject = Object_GetIndex(&play->objectCtx, GAMEPLAY_DANGEON_KEEP)) < 0) { Actor_MarkForDeath(&this->dyna.actor); } @@ -70,34 +70,34 @@ void EnWarptag_Init(Actor* thisx, GlobalContext* globalCtx) { } } -void EnWarptag_Destroy(Actor* thisx, GlobalContext* globalCtx) { +void EnWarptag_Destroy(Actor* thisx, PlayState* play) { EnWarptag* this = THIS; if (this->dyna.actor.draw != NULL) { - DynaPoly_DeleteBgActor(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); + DynaPoly_DeleteBgActor(play, &play->colCtx.dyna, this->dyna.bgId); } } /** * Loads DynaPoly from GAMEPLAY_DANGEON_KEEP. */ -void EnWarpTag_CheckDungeonKeepObject(EnWarptag* this, GlobalContext* globalCtx) { - if (Object_IsLoaded(&globalCtx->objectCtx, this->dangeonKeepObject)) { +void EnWarpTag_CheckDungeonKeepObject(EnWarptag* this, PlayState* play) { + if (Object_IsLoaded(&play->objectCtx, this->dangeonKeepObject)) { this->actionFunc = EnWarpTag_WaitForPlayer; DynaPolyActor_Init(&this->dyna, 0x1); - DynaPolyActor_LoadMesh(globalCtx, &this->dyna, &gWarpTagGoronTrialBaseCollider); + DynaPolyActor_LoadMesh(play, &this->dyna, &gWarpTagGoronTrialBaseCollider); this->dyna.actor.objBankIndex = this->dangeonKeepObject; this->dyna.actor.draw = EnWarpTag_Draw; } } -void EnWarpTag_WaitForPlayer(EnWarptag* this, GlobalContext* globalCtx) { - if (!Player_InCsMode(&globalCtx->state) && (this->dyna.actor.xzDistToPlayer <= 30.0f) && +void EnWarpTag_WaitForPlayer(EnWarptag* this, PlayState* play) { + if (!Player_InCsMode(play) && (this->dyna.actor.xzDistToPlayer <= 30.0f) && (this->dyna.actor.playerHeightRel <= 10.0f)) { - if (GET_WARPTAG_INVISIBLE(&this->dyna.actor)) { - func_800B7298(globalCtx, NULL, 0x51); + if (WARPTAG_GET_INVISIBLE(&this->dyna.actor)) { + func_800B7298(play, NULL, 0x51); this->actionFunc = EnWarpTag_GrottoReturn; } else { - func_800B7298(globalCtx, NULL, 0xF); + func_800B7298(play, NULL, 0xF); this->actionFunc = EnWarpTag_RespawnPlayer; } } @@ -106,32 +106,32 @@ void EnWarpTag_WaitForPlayer(EnWarptag* this, GlobalContext* globalCtx) { /** * 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)) { +void EnWarpTag_Unused809C09A0(EnWarptag* this, PlayState* play) { + if (func_800B8718(&this->dyna.actor, &play->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 + // also WARPTAG_GET_3C0 should always return 2C0 -> 0xF for all known in-game uses, which is OOB + func_80152434(play, D_809C1000[WARPTAG_GET_3C0(&this->dyna.actor)]); // unk message function this->actionFunc = EnWarpTag_Unused809C0A20; } else { - func_800B8804(&this->dyna.actor, globalCtx, 50.0f); // updates player->unk_A90 + func_800B8804(&this->dyna.actor, play, 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); +void EnWarpTag_Unused809C0A20(EnWarptag* this, PlayState* play) { + if (play->msgCtx.ocarinaMode == 9) { + func_800B7298(play, NULL, 7); this->actionFunc = EnWarpTag_RespawnPlayer; ActorCutscene_Stop(ActorCutscene_GetCurrentIndex()); - } else if (globalCtx->msgCtx.ocarinaMode >= 2) { - globalCtx->msgCtx.ocarinaMode = 4; + } else if (play->msgCtx.ocarinaMode >= 2) { + play->msgCtx.ocarinaMode = 4; this->actionFunc = EnWarpTag_Unused809C09A0; } } @@ -139,23 +139,23 @@ void EnWarpTag_Unused809C0A20(EnWarptag* this, GlobalContext* globalCtx) { /** * ActionFunc: Goron Trial (Moon), respawn at the beginning of goron rolling track, try again. */ -void EnWarpTag_RespawnPlayer(EnWarptag* this, GlobalContext* globalCtx) { +void EnWarpTag_RespawnPlayer(EnWarptag* this, PlayState* play) { ActorEntry* playerActorEntry; Player* player; s32 playerSpawnIndex; s32 new15E; - s32 entranceIndex; + s32 entrance; 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]); + player = GET_PLAYER(play); + if (play->playerActorCsIds[4] >= 0 && ActorCutscene_GetCurrentIndex() != play->playerActorCsIds[4]) { + if (ActorCutscene_GetCanPlayNext(play->playerActorCsIds[4]) == 0) { + ActorCutscene_SetIntentToPlay(play->playerActorCsIds[4]); } else { - ActorCutscene_StartAndSetUnkLinkFields(globalCtx->playerActorCsIds[4], &this->dyna.actor); + ActorCutscene_StartAndSetUnkLinkFields(play->playerActorCsIds[4], &this->dyna.actor); func_800B8E58(player, NA_SE_PL_WARP_PLATE); func_8016566C(0); } @@ -180,7 +180,7 @@ void EnWarpTag_RespawnPlayer(EnWarptag* this, GlobalContext* globalCtx) { 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_FIERCE_DEITY] = WARPTAG_GET_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; @@ -192,15 +192,15 @@ void EnWarpTag_RespawnPlayer(EnWarptag* this, GlobalContext* globalCtx) { playerForm = player->transformation; } - entranceIndex = gSaveContext.save.entranceIndex; + entrance = gSaveContext.save.entrance; playerSpawnIndex = playerSpawnIndexPerForm[playerForm]; - playerActorEntry = &globalCtx->linkActorEntry[playerSpawnIndex]; + playerActorEntry = &play->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) { + if (WARPTAG_GET_3C0_MAX(&this->dyna.actor) == WARPTAG_3C0_MAX) { playerParams = 0x9FF; } else { // not used by any known variant playerParams = 0x8FF; @@ -209,11 +209,11 @@ void EnWarpTag_RespawnPlayer(EnWarptag* this, GlobalContext* globalCtx) { // 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, + &play->state, 0, entrance, // parameter 3 is called "sceneSetup" + play->setupEntranceList[playerSpawnIndex].room, playerParams, &newRespawnPos, ((((playerActorEntry->rot.y >> 7) & 0x1FF) / 180.0f) * 32768.0f)); // DEG_TO_BINANG ? - func_80169EFC(&globalCtx->state); + func_80169EFC(&play->state); gSaveContext.respawnFlag = ~0x4; func_80165690(); } @@ -231,7 +231,7 @@ void EnWarpTag_RespawnPlayer(EnWarptag* this, GlobalContext* globalCtx) { /** * ActionFunc: Deku Playground, return to North Clock Town. */ -void EnWarpTag_GrottoReturn(EnWarptag* this, GlobalContext* globalCtx) { +void EnWarpTag_GrottoReturn(EnWarptag* this, PlayState* play) { if (ActorCutscene_GetCurrentIndex() != this->dyna.actor.cutscene) { if (ActorCutscene_GetCanPlayNext(this->dyna.actor.cutscene)) { ActorCutscene_StartAndSetUnkLinkFields(this->dyna.actor.cutscene, &this->dyna.actor); @@ -241,9 +241,9 @@ void EnWarpTag_GrottoReturn(EnWarptag* this, GlobalContext* globalCtx) { } if (this->grottoExitDelay++ == 10) { - globalCtx->nextEntranceIndex = globalCtx->setupExitList[GET_WARPTAG_EXIT_INDEX(&this->dyna.actor)]; - Scene_SetExitFade(globalCtx); - globalCtx->sceneLoadFlag = 0x14; + play->nextEntrance = play->setupExitList[WARPTAG_GET_EXIT_INDEX(&this->dyna.actor)]; + Scene_SetExitFade(play); + play->transitionTrigger = TRANS_TRIGGER_START; func_8019F128(NA_SE_OC_SECRET_HOLE_OUT); func_801A4058(5); if (1) {} @@ -252,22 +252,22 @@ void EnWarpTag_GrottoReturn(EnWarptag* this, GlobalContext* globalCtx) { } } -void EnWarptag_Update(Actor* thisx, GlobalContext* globalCtx) { +void EnWarptag_Update(Actor* thisx, PlayState* play) { EnWarptag* this = THIS; - this->actionFunc(this, globalCtx); + this->actionFunc(this, play); } /** * Only draws for Goron Trial (a rainblow animated target). */ -void EnWarpTag_Draw(Actor* thisx, GlobalContext* globalCtx) { - OPEN_DISPS(globalCtx->state.gfxCtx); +void EnWarpTag_Draw(Actor* thisx, PlayState* play) { + OPEN_DISPS(play->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); + func_8012C28C(play->state.gfxCtx); + AnimatedMat_Draw(play, Lib_SegmentedToVirtual(&gWarpTagRainbowTexAnim)); + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_OPA_DISP++, gWarpTagGoronTrialBaseDL); - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->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 925fda930..ea7eff8ab 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 @@ -5,7 +5,7 @@ struct EnWarptag; -typedef void (*EnWarptagActionFunc)(struct EnWarptag*, GlobalContext*); +typedef void (*EnWarptagActionFunc)(struct EnWarptag*, PlayState*); typedef struct EnWarptag { /* 0x000 */ DynaPolyActor dyna; @@ -24,10 +24,10 @@ extern const ActorInit En_Warp_tag_InitVars; // 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_GET_3C0_MAX(thisx) ((thisx)->params & 0x3C0) +#define WARPTAG_GET_3C0(thisx) (((thisx)->params >> 6) & 0xF) +#define WARPTAG_GET_EXIT_INDEX(thisx) ((thisx)->params & 0x3F) +#define WARPTAG_GET_INVISIBLE(thisx) ((thisx)->params < 0) // 0x8000 flag #define WARPTAG_3C0_MAX 0x3C0 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 127bcc1c2..499ca365f 100644 --- a/src/overlays/actors/ovl_En_Water_Effect/z_en_water_effect.c +++ b/src/overlays/actors/ovl_En_Water_Effect/z_en_water_effect.c @@ -12,15 +12,15 @@ #define THIS ((EnWaterEffect*)thisx) -void EnWaterEffect_Init(Actor* thisx, GlobalContext* globalCtx); -void EnWaterEffect_Destroy(Actor* thisx, GlobalContext* globalCtx); -void EnWaterEffect_Update(Actor* thisx, GlobalContext* globalCtx); -void EnWaterEffect_Draw(Actor* thisx, GlobalContext* globalCtx); +void EnWaterEffect_Init(Actor* thisx, PlayState* play); +void EnWaterEffect_Destroy(Actor* thisx, PlayState* play); +void EnWaterEffect_Update(Actor* thisx, PlayState* play); +void EnWaterEffect_Draw(Actor* thisx, PlayState* play); -void func_80A59C04(Actor* thisx, GlobalContext* globalCtx2); -void func_80A5A184(Actor* thisx, GlobalContext* globalCtx2); -void func_80A5A534(Actor* thisx, GlobalContext* globalCtx); -void func_80A5A6B8(Actor* thisx, GlobalContext* globalCtx2); +void func_80A59C04(Actor* thisx, PlayState* play2); +void func_80A5A184(Actor* thisx, PlayState* play2); +void func_80A5A534(Actor* thisx, PlayState* play); +void func_80A5A6B8(Actor* thisx, PlayState* play2); const ActorInit En_Water_Effect_InitVars = { ACTOR_EN_WATER_EFFECT, @@ -78,7 +78,7 @@ void func_80A58908(EnWaterEffect* this, Vec3f* arg1, Vec3f* arg2, u8 arg3) { } } -void EnWaterEffect_Init(Actor* thisx, GlobalContext* globalCtx) { +void EnWaterEffect_Init(Actor* thisx, PlayState* play) { s32 pad; EnWaterEffect* this = THIS; @@ -89,23 +89,23 @@ void EnWaterEffect_Init(Actor* thisx, GlobalContext* globalCtx) { this->actor.update = func_80A59C04; this->actor.draw = func_80A5A184; this->unk_DC6 = Rand_ZeroFloat(100.0f) + 60.0f; - } else if ((this->actor.params == ENWATEREFFECT_777) || (this->actor.params == ENWATEREFFECT_778) || - (this->actor.params == ENWATEREFFECT_779) || (this->actor.params == ENWATEREFFECT_780)) { + } else if ((this->actor.params == ENWATEREFFECT_309) || (this->actor.params == ENWATEREFFECT_30A) || + (this->actor.params == ENWATEREFFECT_30B) || (this->actor.params == ENWATEREFFECT_30C)) { this->actor.update = func_80A5A534; this->actor.draw = func_80A5A6B8; this->actor.shape.rot.y = Rand_ZeroFloat(0x10000); Actor_SetScale(&this->actor, this->actor.shape.rot.z * 0.0002f); - if (this->actor.params == ENWATEREFFECT_777) { - Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_WATER_EFFECT, this->actor.world.pos.x, - this->actor.world.pos.y, this->actor.world.pos.z, 0, 0, this->actor.shape.rot.z, 0x30A); - Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_WATER_EFFECT, this->actor.world.pos.x, - this->actor.world.pos.y, this->actor.world.pos.z, 0, 0, this->actor.shape.rot.z, 0x30B); - } else if (this->actor.params == ENWATEREFFECT_778) { + if (this->actor.params == ENWATEREFFECT_309) { + Actor_Spawn(&play->actorCtx, play, ACTOR_EN_WATER_EFFECT, this->actor.world.pos.x, this->actor.world.pos.y, + this->actor.world.pos.z, 0, 0, this->actor.shape.rot.z, 0x30A); + Actor_Spawn(&play->actorCtx, play, ACTOR_EN_WATER_EFFECT, this->actor.world.pos.x, this->actor.world.pos.y, + this->actor.world.pos.z, 0, 0, this->actor.shape.rot.z, 0x30B); + } else if (this->actor.params == ENWATEREFFECT_30A) { this->unk_DC4 = -3; - } else if (this->actor.params == ENWATEREFFECT_779) { + } else if (this->actor.params == ENWATEREFFECT_30B) { this->unk_DC4 = -6; - } else if (this->actor.params == ENWATEREFFECT_780) { + } else if (this->actor.params == ENWATEREFFECT_30C) { this->unk_DC4 = 23; } @@ -127,13 +127,13 @@ void EnWaterEffect_Init(Actor* thisx, GlobalContext* globalCtx) { } } -void EnWaterEffect_Destroy(Actor* thisx, GlobalContext* globalCtx) { +void EnWaterEffect_Destroy(Actor* thisx, PlayState* play) { } -void EnWaterEffect_Update(Actor* thisx, GlobalContext* globalCtx2) { - GlobalContext* globalCtx = globalCtx2; +void EnWaterEffect_Update(Actor* thisx, PlayState* play2) { + PlayState* play = play2; EnWaterEffect* this = THIS; - Player* player = GET_PLAYER(globalCtx); + Player* player = GET_PLAYER(play); EnWaterEffectStruct* ptr = &this->unk_144[0]; s16 i; s16 j; @@ -143,11 +143,11 @@ void EnWaterEffect_Update(Actor* thisx, GlobalContext* globalCtx2) { u8 phi_v1; Vec3f sp88; - if (!Flags_GetSwitch(globalCtx, this->actor.params)) { + if (!Flags_GetSwitch(play, this->actor.params)) { this->unk_DC4++; if ((this->unk_DC4 % 32) == 0) { if (Rand_ZeroOne() < 0.5f) { - Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 20.0f, 10.0f, 40.0f, 4); + Actor_UpdateBgCheckInfo(play, &this->actor, 20.0f, 10.0f, 40.0f, 4); sp88.x = randPlusMinusPoint5Scaled(50.0f) + this->actor.world.pos.x; sp88.y = this->actor.world.pos.y; sp88.z = randPlusMinusPoint5Scaled(50.0f) + this->actor.world.pos.z; @@ -198,11 +198,11 @@ void EnWaterEffect_Update(Actor* thisx, GlobalContext* globalCtx2) { if (phi_v0) { ptr->unk_00 = 0; - SoundSource_PlaySfxAtFixedWorldPos(globalCtx, &ptr->unk_04, 30, NA_SE_EV_BOMB_DROP_WATER); + SoundSource_PlaySfxAtFixedWorldPos(play, &ptr->unk_04, 30, NA_SE_EV_BOMB_DROP_WATER); } else { ptr->unk_04.y = this->actor.floorHeight; if (ptr->unk_2A == 0) { - SoundSource_PlaySfxAtFixedWorldPos(globalCtx, &ptr->unk_04, 30, NA_SE_EV_WATERDROP_GRD); + SoundSource_PlaySfxAtFixedWorldPos(play, &ptr->unk_04, 30, NA_SE_EV_WATERDROP_GRD); ptr->unk_00 = 3; ptr->unk_2C.x = 0.1f; ptr->unk_2C.y = 0.6f; @@ -212,21 +212,21 @@ void EnWaterEffect_Update(Actor* thisx, GlobalContext* globalCtx2) { ptr->unk_28 = 9; Math_Vec3f_Copy(&sp98, &ptr->unk_04); sp98.y += 3.0f; - EffectSsGSplash_Spawn(globalCtx, &sp98, NULL, NULL, 1, 100); + EffectSsGSplash_Spawn(play, &sp98, NULL, NULL, 1, 100); } else { ptr->unk_00 = 0; - SoundSource_PlaySfxAtFixedWorldPos(globalCtx, &ptr->unk_04, 30, NA_SE_EV_WATERDROP); - EffectSsGRipple_Spawn(globalCtx, &ptr->unk_04, 70, 500, 0); - EffectSsGRipple_Spawn(globalCtx, &ptr->unk_04, 70, 500, 10); + SoundSource_PlaySfxAtFixedWorldPos(play, &ptr->unk_04, 30, NA_SE_EV_WATERDROP); + EffectSsGRipple_Spawn(play, &ptr->unk_04, 70, 500, 0); + EffectSsGRipple_Spawn(play, &ptr->unk_04, 70, 500, 10); Math_Vec3f_Copy(&sp98, &ptr->unk_04); sp98.y += 10.0f; - EffectSsGSplash_Spawn(globalCtx, &sp98, NULL, NULL, 1, 300); + EffectSsGSplash_Spawn(play, &sp98, NULL, NULL, 1, 300); } } for (j = 0; j < 12; j++) { - Matrix_InsertYRotation_f((2.0f * (j * M_PI)) / 5.5f, MTXMODE_NEW); - Matrix_GetStateTranslationAndScaledZ(Rand_ZeroFloat(1.5f) + 1.5f, &spA4); + 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); } @@ -249,7 +249,7 @@ void EnWaterEffect_Update(Actor* thisx, GlobalContext* globalCtx2) { ptr->unk_3C = 150; ptr->unk_28 = Rand_ZeroFloat(5.0f) + 7.0f; } else { - EffectSsGRipple_Spawn(globalCtx, &ptr->unk_04, 0, 200, 0); + EffectSsGRipple_Spawn(play, &ptr->unk_04, 0, 200, 0); ptr->unk_00 = 0; } } @@ -266,9 +266,9 @@ void EnWaterEffect_Update(Actor* thisx, GlobalContext* globalCtx2) { } } -void EnWaterEffect_Draw(Actor* thisx, GlobalContext* globalCtx2) { - GlobalContext* globalCtx = globalCtx2; - GraphicsContext* gfxCtx = globalCtx->state.gfxCtx; +void EnWaterEffect_Draw(Actor* thisx, PlayState* play2) { + PlayState* play = play2; + GraphicsContext* gfxCtx = play->state.gfxCtx; EnWaterEffect* this = THIS; s32 pad; EnWaterEffectStruct* backupPtr = &this->unk_144[0]; @@ -278,7 +278,7 @@ void EnWaterEffect_Draw(Actor* thisx, GlobalContext* globalCtx2) { OPEN_DISPS(gfxCtx); - func_8012C2DC(globalCtx->state.gfxCtx); + func_8012C2DC(play->state.gfxCtx); for (i = 0; i < ARRAY_COUNT(this->unk_144) / 2; i++, ptr++) { if ((ptr->unk_00 == 1) || (ptr->unk_00 == 2)) { @@ -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(Camera_GetInputDirYaw(GET_ACTIVE_CAM(globalCtx)), MTXMODE_APPLY); + Matrix_RotateYS(Camera_GetInputDirYaw(GET_ACTIVE_CAM(play)), MTXMODE_APPLY); } else { - Matrix_NormalizeXYZ(&globalCtx->billboardMtxF); + Matrix_ReplaceRotation(&play->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); @@ -378,15 +378,15 @@ void func_80A599E8(EnWaterEffect* this, Vec3f* arg1, u8 arg2) { } } -void func_80A59C04(Actor* thisx, GlobalContext* globalCtx2) { - GlobalContext* globalCtx = globalCtx2; +void func_80A59C04(Actor* thisx, PlayState* play2) { + PlayState* play = play2; EnWaterEffect* this = THIS; s16 i; s16 j; f32 temp_f0_2; - Player* player = GET_PLAYER(globalCtx); + Player* player = GET_PLAYER(play); Vec3f sp90; - Actor* rotaryRoom = globalCtx->actorCtx.actorLists[ACTORCAT_BG].first; + Actor* rotaryRoom = play->actorCtx.actorLists[ACTORCAT_BG].first; CollisionPoly* sp88; EnWaterEffectStruct* ptr = &this->unk_144[0]; u8 phi_s5; @@ -403,13 +403,13 @@ void func_80A59C04(Actor* thisx, GlobalContext* globalCtx2) { this->unk_DC6--; } - if ((rotaryRoom != NULL) && Flags_GetSwitch(globalCtx, (rotaryRoom->params >> 1) & 0x7F)) { + if ((rotaryRoom != NULL) && Flags_GetSwitch(play, (rotaryRoom->params >> 1) & 0x7F)) { this->unk_DC6 = Rand_ZeroFloat(150.0f) + 100.0f; - } else if (!Play_InCsMode(globalCtx)) { + } else if (!Play_InCsMode(play)) { this->unk_DC4++; if (this->unk_DC6 == 0) { this->unk_DC6 = Rand_ZeroFloat(150.0f) + 100.0f; - Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 20.0f, 10.0f, 40.0f, 4); + Actor_UpdateBgCheckInfo(play, &this->actor, 20.0f, 10.0f, 40.0f, 4); sp74.x = randPlusMinusPoint5Scaled(50.0f) + this->actor.world.pos.x; sp74.y = this->actor.world.pos.y; sp74.z = randPlusMinusPoint5Scaled(50.0f) + this->actor.world.pos.z; @@ -466,7 +466,7 @@ void func_80A59C04(Actor* thisx, GlobalContext* globalCtx2) { (fabsf(ptr->unk_04.y - (player->actor.world.pos.y + 25.0f)) < 30.0f)) { phi_s5 = true; if ((player->transformation != PLAYER_FORM_GORON) && !player->isBurning) { - func_800B8D50(globalCtx, &this->actor, 2.0f, Rand_ZeroFloat(0x10000), 0.0f, 0x10); + func_800B8D50(play, &this->actor, 2.0f, Rand_ZeroFloat(0x10000), 0.0f, 0x10); for (j = 0; j < ARRAY_COUNT(player->flameTimers); j++) { player->flameTimers[j] = Rand_S16Offset(0, 200); } @@ -478,7 +478,7 @@ void func_80A59C04(Actor* thisx, GlobalContext* globalCtx2) { Math_Vec3f_Copy(&sp90, &ptr->unk_04); sp90.y += 30.0f; - temp_f0_2 = BgCheck_EntityRaycastFloor1(&globalCtx->colCtx, &sp88, &sp90); + temp_f0_2 = BgCheck_EntityRaycastFloor1(&play->colCtx, &sp88, &sp90); if (fabsf(temp_f0_2 - this->actor.floorHeight) > 200.0f) { phi_s5 = true; } @@ -493,7 +493,7 @@ void func_80A59C04(Actor* thisx, GlobalContext* globalCtx2) { for (j = 0; j < 5; j++) { func_80A599E8(this, &ptr->unk_04, 2); } - SoundSource_PlaySfxAtFixedWorldPos(globalCtx, &ptr->unk_04, 30, NA_SE_EV_PLANT_BROKEN); + SoundSource_PlaySfxAtFixedWorldPos(play, &ptr->unk_04, 30, NA_SE_EV_PLANT_BROKEN); } ptr->unk_2A++; } @@ -503,18 +503,18 @@ void func_80A59C04(Actor* thisx, GlobalContext* globalCtx2) { } } -void func_80A5A184(Actor* thisx, GlobalContext* globalCtx2) { - GlobalContext* globalCtx = globalCtx2; +void func_80A5A184(Actor* thisx, PlayState* play2) { + PlayState* play = play2; EnWaterEffect* this = THIS; - GraphicsContext* gfxCtx = globalCtx->state.gfxCtx; + GraphicsContext* gfxCtx = play->state.gfxCtx; EnWaterEffectStruct* ptr = &this->unk_144[0]; u8 flag = false; s16 i; OPEN_DISPS(gfxCtx); - func_8012C28C(globalCtx->state.gfxCtx); - func_8012C2DC(globalCtx->state.gfxCtx); + func_8012C28C(play->state.gfxCtx); + func_8012C2DC(play->state.gfxCtx); for (i = 0; i < ARRAY_COUNT(this->unk_144); i++, ptr++) { if (ptr->unk_00 == 4) { @@ -527,45 +527,44 @@ void func_80A5A184(Actor* thisx, GlobalContext* globalCtx2) { gDPSetPrimColor(POLY_XLU_DISP++, 0x80, 0x80, (u8)ptr->unk_38, 0, 0, (u8)ptr->unk_3C); gSPSegment(POLY_XLU_DISP++, 0x08, - Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, 0, 0, 0x20, 0x40, 1, 0, (ptr->unk_01 * -20) & 0x1FF, + Gfx_TwoTexScroll(play->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(&play->billboardMtxF); } else { - Matrix_RotateY(Camera_GetInputDirYaw(GET_ACTIVE_CAM(globalCtx)), MTXMODE_APPLY); + Matrix_RotateYS(Camera_GetInputDirYaw(GET_ACTIVE_CAM(play)), 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), - G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); 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), + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_OPA_DISP++, gameplay_keep_DL_06AB30); } } } - POLY_OPA_DISP = func_801660B8(globalCtx, POLY_OPA_DISP); + POLY_OPA_DISP = func_801660B8(play, POLY_OPA_DISP); CLOSE_DISPS(gfxCtx); } -void func_80A5A534(Actor* thisx, GlobalContext* globalCtx) { +void func_80A5A534(Actor* thisx, PlayState* play) { EnWaterEffect* this = THIS; s32 i; @@ -601,85 +600,83 @@ void func_80A5A534(Actor* thisx, GlobalContext* globalCtx) { } } -void func_80A5A6B8(Actor* thisx, GlobalContext* globalCtx2) { - GlobalContext* globalCtx = globalCtx2; +void func_80A5A6B8(Actor* thisx, PlayState* play2) { + PlayState* play = play2; EnWaterEffect* this = THIS; EnWaterEffectStruct* ptr = &this->unk_144[0]; u8 phi_s4 = false; s16 i; - OPEN_DISPS(globalCtx->state.gfxCtx); + OPEN_DISPS(play->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); + func_8012C2DC(play->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->actor.params == ENWATEREFFECT_309) || (this->actor.params == ENWATEREFFECT_30A)) { if (this->unk_E2C > 1.0f) { - func_8012C2DC(globalCtx->state.gfxCtx); - AnimatedMat_Draw(globalCtx, Lib_SegmentedToVirtual(object_water_effect_Matanimheader_000DE0)); + func_8012C2DC(play->state.gfxCtx); + AnimatedMat_Draw(play, Lib_SegmentedToVirtual(object_water_effect_Matanimheader_000DE0)); Matrix_Scale(this->unk_DC8[1].y, this->unk_DC8[1].z, this->unk_DC8[1].y, MTXMODE_APPLY); - gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), - G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 255, 255, 255, (u8)this->unk_E2C); gSPDisplayList(POLY_XLU_DISP++, object_water_effect_DL_000420); } - Matrix_StatePop(); + Matrix_Pop(); if (this->unk_E30 > 1.0f) { - func_8012C2DC(globalCtx->state.gfxCtx); - AnimatedMat_Draw(globalCtx, Lib_SegmentedToVirtual(object_water_effect_Matanimheader_000E0C)); + func_8012C2DC(play->state.gfxCtx); + AnimatedMat_Draw(play, Lib_SegmentedToVirtual(object_water_effect_Matanimheader_000E0C)); Matrix_Scale(this->unk_DC8[2].y, this->unk_DC8[2].z, this->unk_DC8[2].y, MTXMODE_APPLY); - gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), - G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 255, 255, 255, (u8)this->unk_E30); gSPDisplayList(POLY_XLU_DISP++, object_water_effect_DL_000730); } - Matrix_StatePop(); + Matrix_Pop(); } else { - Matrix_StatePop(); - Matrix_StatePop(); + Matrix_Pop(); + Matrix_Pop(); } - if ((this->unk_E34 > 1.0f) && (this->actor.params != ENWATEREFFECT_780)) { - func_8012C2DC(globalCtx->state.gfxCtx); - AnimatedMat_Draw(globalCtx, Lib_SegmentedToVirtual(object_water_effect_Matanimheader_000E40)); + if ((this->unk_E34 > 1.0f) && (this->actor.params != ENWATEREFFECT_30C)) { + func_8012C2DC(play->state.gfxCtx); + AnimatedMat_Draw(play, Lib_SegmentedToVirtual(object_water_effect_Matanimheader_000E40)); Matrix_Scale(this->unk_DC8[3].y, this->unk_DC8[3].z, this->unk_DC8[3].y, MTXMODE_APPLY); - gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 255, 255, 255, (u8)this->unk_E34); 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); - AnimatedMat_Draw(globalCtx, Lib_SegmentedToVirtual(object_water_effect_Matanimheader_000E58)); + if ((this->actor.params == ENWATEREFFECT_309) || (this->actor.params == ENWATEREFFECT_30C)) { + func_8012C2DC(play->state.gfxCtx); + AnimatedMat_Draw(play, Lib_SegmentedToVirtual(object_water_effect_Matanimheader_000E58)); Matrix_Scale(this->unk_DC8[4].y, this->unk_DC8[4].z, this->unk_DC8[4].y, MTXMODE_APPLY); - gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 255, 255, 255, (u8)this->unk_E38); gSPDisplayList(POLY_XLU_DISP++, object_water_effect_DL_000CD8); } - if (this->actor.params == ENWATEREFFECT_777) { - func_8012C2DC(globalCtx->state.gfxCtx); + if (this->actor.params == ENWATEREFFECT_309) { + func_8012C2DC(play->state.gfxCtx); for (i = 0; i < ARRAY_COUNT(this->unk_144) / 2; i++, ptr++) { if (ptr->unk_00 == 3) { if (!phi_s4) { - func_8012C448(globalCtx->state.gfxCtx); + func_8012C448(play->state.gfxCtx); gSPSegment(POLY_XLU_DISP++, 0x08, Lib_SegmentedToVirtual(gDust1Tex)); gDPSetEnvColor(POLY_XLU_DISP++, 250, 250, 255, 0); @@ -690,16 +687,16 @@ 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), + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_XLU_DISP++, object_water_effect_DL_0042F8); } } } - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->state.gfxCtx); } diff --git a/src/overlays/actors/ovl_En_Water_Effect/z_en_water_effect.h b/src/overlays/actors/ovl_En_Water_Effect/z_en_water_effect.h index 774b858cd..35aebd83e 100644 --- a/src/overlays/actors/ovl_En_Water_Effect/z_en_water_effect.h +++ b/src/overlays/actors/ovl_En_Water_Effect/z_en_water_effect.h @@ -19,11 +19,11 @@ typedef struct { } EnWaterEffectStruct; // size = 0x40 enum { - /* 0x 1 */ ENWATEREFFECT_1 = 1, - /* 0x309 */ ENWATEREFFECT_777 = 777, - /* 0x30A */ ENWATEREFFECT_778, - /* 0x30B */ ENWATEREFFECT_779, - /* 0x30C */ ENWATEREFFECT_780, + /* 0x001 */ ENWATEREFFECT_1 = 1, + /* 0x309 */ ENWATEREFFECT_309 = 0x309, + /* 0x30A */ ENWATEREFFECT_30A, + /* 0x30B */ ENWATEREFFECT_30B, + /* 0x30C */ ENWATEREFFECT_30C, }; typedef struct EnWaterEffect { diff --git a/src/overlays/actors/ovl_En_Wdhand/z_en_wdhand.c b/src/overlays/actors/ovl_En_Wdhand/z_en_wdhand.c index b21e2f0b8..a4cf5379a 100644 --- a/src/overlays/actors/ovl_En_Wdhand/z_en_wdhand.c +++ b/src/overlays/actors/ovl_En_Wdhand/z_en_wdhand.c @@ -10,10 +10,10 @@ #define THIS ((EnWdhand*)thisx) -void EnWdhand_Init(Actor* thisx, GlobalContext* globalCtx); -void EnWdhand_Destroy(Actor* thisx, GlobalContext* globalCtx); -void EnWdhand_Update(Actor* thisx, GlobalContext* globalCtx); -void EnWdhand_Draw(Actor* thisx, GlobalContext* globalCtx); +void EnWdhand_Init(Actor* thisx, PlayState* play); +void EnWdhand_Destroy(Actor* thisx, PlayState* play); +void EnWdhand_Update(Actor* thisx, PlayState* play); +void EnWdhand_Draw(Actor* thisx, PlayState* play); #if 0 const ActorInit En_Wdhand_InitVars = { @@ -63,7 +63,7 @@ static ColliderJntSphElementInit D_80AF63E0[7] = { // static ColliderJntSphInit sJntSphInit = { static ColliderJntSphInit D_80AF64DC = { { COLTYPE_HIT0, AT_NONE | AT_TYPE_ENEMY, AC_ON | AC_TYPE_PLAYER, OC1_ON | OC1_TYPE_ALL, OC2_TYPE_1, COLSHAPE_JNTSPH, }, - 7, D_80AF63E0, // sJntSphElementsInit, + ARRAY_COUNT(sJntSphElementsInit), D_80AF63E0, // sJntSphElementsInit, }; // sColChkInfoInit diff --git a/src/overlays/actors/ovl_En_Wdhand/z_en_wdhand.h b/src/overlays/actors/ovl_En_Wdhand/z_en_wdhand.h index 28e0d07da..adf19ce8c 100644 --- a/src/overlays/actors/ovl_En_Wdhand/z_en_wdhand.h +++ b/src/overlays/actors/ovl_En_Wdhand/z_en_wdhand.h @@ -5,13 +5,13 @@ struct EnWdhand; -typedef void (*EnWdhandActionFunc)(struct EnWdhand*, GlobalContext*); +typedef void (*EnWdhandActionFunc)(struct EnWdhand*, PlayState*); typedef struct EnWdhand { - /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0xA4]; - /* 0x01E8 */ EnWdhandActionFunc actionFunc; - /* 0x01EC */ char unk_1EC[0x268]; + /* 0x000 */ Actor actor; + /* 0x144 */ char unk_144[0xA4]; + /* 0x1E8 */ EnWdhandActionFunc actionFunc; + /* 0x1EC */ char unk_1EC[0x268]; } EnWdhand; // size = 0x454 extern const ActorInit En_Wdhand_InitVars; diff --git a/src/overlays/actors/ovl_En_Weather_Tag/z_en_weather_tag.c b/src/overlays/actors/ovl_En_Weather_Tag/z_en_weather_tag.c index f4d999fae..752447a5d 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 @@ -10,30 +10,30 @@ #define THIS ((EnWeatherTag*)thisx) -void EnWeatherTag_Init(Actor* thisx, GlobalContext* globalCtx); -void EnWeatherTag_Destroy(Actor* thisx, GlobalContext* globalCtx); -void EnWeatherTag_Update(Actor* thisx, GlobalContext* globalCtx); -void EnWeatherTag_Draw(Actor* thisx, GlobalContext* globalCtx); +void EnWeatherTag_Init(Actor* thisx, PlayState* play); +void EnWeatherTag_Destroy(Actor* thisx, PlayState* play); +void EnWeatherTag_Update(Actor* thisx, PlayState* play); +void EnWeatherTag_Draw(Actor* thisx, PlayState* play); -void func_80966A08(EnWeatherTag* this, GlobalContext* globalCtx); -void func_80966A68(EnWeatherTag* this, GlobalContext* globalCtx); -void EnWeatherTag_Die(EnWeatherTag* this, GlobalContext* globalCtx); -void func_80966B08(EnWeatherTag* this, GlobalContext* globalCtx); -void func_80966BF4(EnWeatherTag* this, GlobalContext* globalCtx); -void func_80966D20(EnWeatherTag* this, GlobalContext* globalCtx); -void func_80966E0C(EnWeatherTag* this, GlobalContext* globalCtx); -void func_80966E84(EnWeatherTag* this, GlobalContext* globalCtx); -void func_80966EF0(EnWeatherTag* this, GlobalContext* globalCtx); -void func_80966F74(EnWeatherTag* this, GlobalContext* globalCtx); -void func_80966FEC(EnWeatherTag* this, GlobalContext* globalCtx); -void func_80967060(EnWeatherTag* this, GlobalContext* globalCtx); -void func_80967148(EnWeatherTag* this, GlobalContext* globalCtx); -void EnWeatherTag_DoNothing(EnWeatherTag* this, GlobalContext* globalCtx); -void EnWeatherTag_Unused_80967250(EnWeatherTag* this, GlobalContext* globalCtx); -void EnWeatherTag_Unused_809671B8(EnWeatherTag* this, GlobalContext* globalCtx); -void func_809672DC(EnWeatherTag* this, GlobalContext* globalCtx); -void func_809674C8(EnWeatherTag* this, GlobalContext* globalCtx); -void func_80967608(EnWeatherTag* this, GlobalContext* globalCtx); +void func_80966A08(EnWeatherTag* this, PlayState* play); +void func_80966A68(EnWeatherTag* this, PlayState* play); +void EnWeatherTag_Die(EnWeatherTag* this, PlayState* play); +void func_80966B08(EnWeatherTag* this, PlayState* play); +void func_80966BF4(EnWeatherTag* this, PlayState* play); +void func_80966D20(EnWeatherTag* this, PlayState* play); +void func_80966E0C(EnWeatherTag* this, PlayState* play); +void func_80966E84(EnWeatherTag* this, PlayState* play); +void func_80966EF0(EnWeatherTag* this, PlayState* play); +void func_80966F74(EnWeatherTag* this, PlayState* play); +void func_80966FEC(EnWeatherTag* this, PlayState* play); +void func_80967060(EnWeatherTag* this, PlayState* play); +void func_80967148(EnWeatherTag* this, PlayState* play); +void EnWeatherTag_DoNothing(EnWeatherTag* this, PlayState* play); +void EnWeatherTag_Unused_80967250(EnWeatherTag* this, PlayState* play); +void EnWeatherTag_Unused_809671B8(EnWeatherTag* this, PlayState* play); +void func_809672DC(EnWeatherTag* this, PlayState* play); +void func_809674C8(EnWeatherTag* this, PlayState* play); +void func_80967608(EnWeatherTag* this, PlayState* play); const ActorInit En_Weather_Tag_InitVars = { ACTOR_EN_WEATHER_TAG, @@ -57,10 +57,10 @@ void EnWeatherTag_SetupAction(EnWeatherTag* this, EnWeatherTagActionFunc func) { this->actionFunc = func; } -void EnWeatherTag_Destroy(Actor* thisx, GlobalContext* globalCtx) { +void EnWeatherTag_Destroy(Actor* thisx, PlayState* play) { } -void EnWeatherTag_Init(Actor* thisx, GlobalContext* globalCtx) { +void EnWeatherTag_Init(Actor* thisx, PlayState* play) { EnWeatherTag* this = THIS; s32 pad; Path* path; @@ -69,7 +69,7 @@ void EnWeatherTag_Init(Actor* thisx, GlobalContext* globalCtx) { // flag: is targetable. Should do nothing as not set by default above this->actor.flags &= ~ACTOR_FLAG_1; - switch (WEATHER_TAG_TYPE(this)) { + switch (WEATHER_TAG_TYPE(&this->actor)) { case WEATHERTAG_TYPE_UNK0: this->unk154 = 0; this->fadeDistance = this->actor.world.rot.x; @@ -93,16 +93,16 @@ void EnWeatherTag_Init(Actor* thisx, GlobalContext* globalCtx) { EnWeatherTag_SetupAction(this, func_80966FEC); break; case WEATHERTAG_TYPE_UNK5: - func_800BC154(globalCtx, &globalCtx->actorCtx, &this->actor, 7); - globalCtx->skyboxId = 3; - globalCtx->envCtx.unk_1F = 5; - globalCtx->envCtx.unk_20 = 5; + func_800BC154(play, &play->actorCtx, &this->actor, 7); + play->skyboxId = 3; + play->envCtx.unk_1F = 5; + play->envCtx.unk_20 = 5; D_801F4E74 = 1.0f; EnWeatherTag_SetupAction(this, func_80966BF4); break; case WEATHERTAG_TYPE_WATERMURK: - pathID = WEATHER_TAG_PATHID(this); - path = &globalCtx->setupPathList[pathID]; + pathID = WEATHER_TAG_PATHID(&this->actor); + path = &play->setupPathList[pathID]; this->pathPoints = Lib_SegmentedToVirtual(path->points); this->pathCount = path->count; EnWeatherTag_SetupAction(this, func_809672DC); @@ -114,26 +114,25 @@ void EnWeatherTag_Init(Actor* thisx, GlobalContext* globalCtx) { // matches but unused params is suspicious // called WeatherTag_CheckEnableWeatherEffect in OOT, that's where "weatherMode" came from -u8 func_80966608(EnWeatherTag* this, GlobalContext* globalCtx, UNK_TYPE a3, UNK_TYPE a4, u8 new1F, u8 new20, u16 new24, +u8 func_80966608(EnWeatherTag* this, PlayState* play, UNK_TYPE a3, UNK_TYPE a4, u8 new1F, u8 new20, u16 new24, u8 weatherMode) { - Player* player = GET_PLAYER(globalCtx); + Player* player = GET_PLAYER(play); u8 returnVal = 0; - if (WEATHER_TAG_RANGE100(this) > Actor_XZDistanceBetweenActors(&player->actor, &this->actor)) { - if (globalCtx->envCtx.unk_1F == globalCtx->envCtx.unk_20) { + if (WEATHER_TAG_RANGE100(&this->actor) > Actor_XZDistanceBetweenActors(&player->actor, &this->actor)) { + if (play->envCtx.unk_1F == play->envCtx.unk_20) { D_801BDBB8 = 1; - if (!(globalCtx->envCtx.unk_1E == 0) || - ((globalCtx->envCtx.unk_1F != 1) && (globalCtx->envCtx.unk_21 == 0))) { + if (!(play->envCtx.unk_1E == 0) || ((play->envCtx.unk_1F != 1) && (play->envCtx.unk_21 == 0))) { D_801BDBB8 = 0; - if (D_801BDBB0 != weatherMode) { - D_801BDBB0 = weatherMode; - globalCtx->envCtx.unk_21 = 1; - globalCtx->envCtx.unk_1F = new1F; - globalCtx->envCtx.unk_20 = new20; + if (gWeatherMode != weatherMode) { + gWeatherMode = weatherMode; + play->envCtx.unk_21 = 1; + play->envCtx.unk_1F = new1F; + play->envCtx.unk_20 = new20; D_801BDBB4 = new20; - globalCtx->envCtx.unk_24 = new24; - globalCtx->envCtx.unk_22 = globalCtx->envCtx.unk_24; + play->envCtx.unk_24 = new24; + play->envCtx.unk_22 = play->envCtx.unk_24; } returnVal = 1; } @@ -144,25 +143,23 @@ u8 func_80966608(EnWeatherTag* this, GlobalContext* globalCtx, UNK_TYPE a3, UNK_ // again with the unused parameters // called WeatherTag_CheckRestoreWeather in OOT -u8 func_80966758(EnWeatherTag* this, GlobalContext* globalCtx, UNK_TYPE a3, UNK_TYPE a4, u8 new1F, u8 new20, - u16 new24) { - Player* player = GET_PLAYER(globalCtx); +u8 func_80966758(EnWeatherTag* this, PlayState* play, UNK_TYPE a3, UNK_TYPE a4, u8 new1F, u8 new20, u16 new24) { + Player* player = GET_PLAYER(play); u8 returnVal = 0; - if (WEATHER_TAG_RANGE100(this) < Actor_XZDistanceBetweenActors(&player->actor, &this->actor)) { - if (globalCtx->envCtx.unk_1F == globalCtx->envCtx.unk_20) { + if (WEATHER_TAG_RANGE100(&this->actor) < Actor_XZDistanceBetweenActors(&player->actor, &this->actor)) { + if (play->envCtx.unk_1F == play->envCtx.unk_20) { D_801BDBB8 = 1; - if (!(globalCtx->envCtx.unk_1E == 0) || - ((globalCtx->envCtx.unk_1F != 1) && (globalCtx->envCtx.unk_21 == 0))) { + if (!(play->envCtx.unk_1E == 0) || ((play->envCtx.unk_1F != 1) && (play->envCtx.unk_21 == 0))) { D_801BDBB8 = 0; - D_801BDBB0 = 0; - globalCtx->envCtx.unk_21 = 1; - globalCtx->envCtx.unk_1F = new1F; - globalCtx->envCtx.unk_20 = new20; + gWeatherMode = 0; + play->envCtx.unk_21 = 1; + play->envCtx.unk_1F = new1F; + play->envCtx.unk_20 = new20; D_801BDBB4 = new20; - globalCtx->envCtx.unk_24 = new24; - globalCtx->envCtx.unk_22 = globalCtx->envCtx.unk_24; + play->envCtx.unk_24 = new24; + play->envCtx.unk_22 = play->envCtx.unk_24; returnVal = 1; } } @@ -171,8 +168,8 @@ u8 func_80966758(EnWeatherTag* this, GlobalContext* globalCtx, UNK_TYPE a3, UNK_ } // modify wind? -void func_8096689C(EnWeatherTag* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); +void func_8096689C(EnWeatherTag* this, PlayState* play) { + Player* player = GET_PLAYER(play); f32 distance; f32 partialResult; @@ -189,28 +186,28 @@ void func_8096689C(EnWeatherTag* this, GlobalContext* globalCtx) { partialResult = (1.0f - (distance / this->fadeDistance)); // strength based on distance? partialResult = (this->unk154 / 32768.0f) * partialResult; // another scale applied - globalCtx->envCtx.windSpeed = (this->actor.world.rot.z * partialResult) + 30.0f; + play->envCtx.windSpeed = (this->actor.world.rot.z * partialResult) + 30.0f; if (partialResult > 0.01f) { - globalCtx->envCtx.sandstormState = 8; + play->envCtx.sandstormState = 8; D_801F4E30 = 0x9B; - } else if (globalCtx->envCtx.sandstormState == 8) { + } else if (play->envCtx.sandstormState == 8) { D_801F4E30 = 0; - globalCtx->envCtx.sandstormState = 9; + play->envCtx.sandstormState = 9; } } // WEATHERTAG_TYPE_UNK0 -void func_80966A08(EnWeatherTag* this, GlobalContext* globalCtx) { +void func_80966A08(EnWeatherTag* this, PlayState* play) { this->unk154 += this->unk158; - if (this->unk154 >= 0x8001) { + if (this->unk154 > 0x8000) { this->unk154 = 0x8000; EnWeatherTag_SetupAction(this, func_80966A68); } - func_8096689C(this, globalCtx); + func_8096689C(this, play); } // WEATHERTAG_TYPE_UNK0 2 -void func_80966A68(EnWeatherTag* this, GlobalContext* globalCtx) { +void func_80966A68(EnWeatherTag* this, PlayState* play) { this->unk154 -= (this->unk158 >> 1); if (this->unk154 == 0) { this->unk154 = 1; @@ -221,10 +218,10 @@ void func_80966A68(EnWeatherTag* this, GlobalContext* globalCtx) { Actor_MarkForDeath(&this->actor); EnWeatherTag_SetupAction(this, EnWeatherTag_Die); } - func_8096689C(this, globalCtx); + func_8096689C(this, play); } -void EnWeatherTag_Die(EnWeatherTag* this, GlobalContext* globalCtx) { +void EnWeatherTag_Die(EnWeatherTag* this, PlayState* play) { Actor_MarkForDeath(&this->actor); } @@ -232,12 +229,12 @@ void EnWeatherTag_Die(EnWeatherTag* this, GlobalContext* globalCtx) { // areas that use: all of ikana, swamp, termina field,stonetower temple, // poisoned swamp: placed behind the water fall from ikana // this tag stops spawning after STT cleared? -void func_80966B08(EnWeatherTag* this, GlobalContext* globalCtx) { - if (func_80966608(this, globalCtx, 0, 0, globalCtx->envCtx.unk_1F, 5, 100, 2) || D_801BDBB0 == 2) { - globalCtx->skyboxId = 3; +void func_80966B08(EnWeatherTag* this, PlayState* play) { + if (func_80966608(this, play, 0, 0, play->envCtx.unk_1F, 5, 100, 2) || (gWeatherMode == 2)) { + play->skyboxId = 3; EnWeatherTag_SetupAction(this, func_80966D20); } else if (D_801F4E74 <= 0.01f) { - globalCtx->skyboxId = 1; + play->skyboxId = 1; } else { Math_SmoothStepToF(&D_801F4E74, 0.0f, 0.2f, 0.02f, 0.001f); } @@ -245,13 +242,13 @@ void func_80966B08(EnWeatherTag* this, GlobalContext* globalCtx) { // WEATHERTAG_TYPE_UNK5: only one in ikana canyon, corner of cliff right outside of stone tower entrance // because it uses cutsecnes.. is this the clear ikana cutcsene? -void func_80966BF4(EnWeatherTag* this, GlobalContext* globalCtx) { +void func_80966BF4(EnWeatherTag* this, PlayState* play) { u8 newUnk20; CsCmdActorAction* tmpAction; - if (Cutscene_CheckActorAction(globalCtx, 567)) { - tmpAction = globalCtx->csCtx.actorActions[Cutscene_GetActorActionIndex(globalCtx, 567)]; - if ((globalCtx->csCtx.frames >= tmpAction->startFrame) && (tmpAction->action >= 2)) { + if (Cutscene_CheckActorAction(play, 567)) { + tmpAction = play->csCtx.actorActions[Cutscene_GetActorActionIndex(play, 567)]; + if ((play->csCtx.frames >= tmpAction->startFrame) && (tmpAction->action >= 2)) { switch (gSaveContext.save.day) { case 0: case 1: @@ -268,18 +265,18 @@ void func_80966BF4(EnWeatherTag* this, GlobalContext* globalCtx) { Math_SmoothStepToF(&D_801F4E74, 0.0f, 0.2f, 0.02f, 0.001f); - if (globalCtx->envCtx.unk_20 != newUnk20) { - globalCtx->envCtx.unk_21 = 1; - globalCtx->envCtx.unk_20 = newUnk20; - globalCtx->envCtx.unk_24 = 100; - globalCtx->envCtx.unk_22 = globalCtx->envCtx.unk_24; + if (play->envCtx.unk_20 != newUnk20) { + play->envCtx.unk_21 = 1; + play->envCtx.unk_20 = newUnk20; + play->envCtx.unk_24 = 100; + play->envCtx.unk_22 = play->envCtx.unk_24; } } } } // WEATHERTAG_TYPE_UNK1 2 -void func_80966D20(EnWeatherTag* this, GlobalContext* globalCtx) { +void func_80966D20(EnWeatherTag* this, PlayState* play) { u8 newUnk20; switch (gSaveContext.save.day) { @@ -297,11 +294,11 @@ void func_80966D20(EnWeatherTag* this, GlobalContext* globalCtx) { } Math_SmoothStepToF(&D_801F4E74, 1.0f, 0.2f, 0.02f, 0.001f); - if (func_80966758(this, globalCtx, 1, 0, 5, newUnk20, 100)) { + if (func_80966758(this, play, 1, 0, 5, newUnk20, 100)) { EnWeatherTag_SetupAction(this, func_80966B08); } - if (D_801BDBB0 != 2) { + if (gWeatherMode != 2) { EnWeatherTag_SetupAction(this, func_80966B08); } } @@ -309,17 +306,17 @@ void func_80966D20(EnWeatherTag* this, GlobalContext* globalCtx) { // WEATHERTAG_TYPE_WINTERFOG: // areas affected: winter goron village, path to mountain village, // path to goron village winter, winter mountain village -void func_80966E0C(EnWeatherTag* this, GlobalContext* globalCtx) { - if (func_80966608(this, globalCtx, 0, 1, 0, 2, 60, 3)) { - globalCtx->envCtx.unk_F2[3] = 0x80; +void func_80966E0C(EnWeatherTag* this, PlayState* play) { + if (func_80966608(this, play, 0, 1, 0, 2, 60, 3)) { + play->envCtx.unk_F2[3] = 0x80; EnWeatherTag_SetupAction(this, func_80966E84); } } // WEATHERTAG_TYPE_WINTERFOG 2 -void func_80966E84(EnWeatherTag* this, GlobalContext* globalCtx) { - if (func_80966758(this, globalCtx, 1, 0, 2, 0, 60)) { - globalCtx->envCtx.unk_F2[3] = 0; +void func_80966E84(EnWeatherTag* this, PlayState* play) { + if (func_80966758(this, play, 1, 0, 2, 0, 60)) { + play->envCtx.unk_F2[3] = 0; EnWeatherTag_SetupAction(this, func_80966E0C); } } @@ -327,19 +324,19 @@ void func_80966E84(EnWeatherTag* this, GlobalContext* globalCtx) { // WEATHERTAG_TYPE_UNK3: unused in vanilla? // just a heavy fog like the winter fog, but unused? // wait if you enter the scene through a room instead of fog you get a flash rain shower -void func_80966EF0(EnWeatherTag* this, GlobalContext* globalCtx) { - if (func_80966608(this, globalCtx, 0, 1, 0, 2, 100, 4)) { - func_800FD78C(globalCtx); - globalCtx->envCtx.unk_F2[0] = 60; +void func_80966EF0(EnWeatherTag* this, PlayState* play) { + if (func_80966608(this, play, 0, 1, 0, 2, 100, 4)) { + func_800FD78C(play); + play->envCtx.unk_F2[0] = 60; EnWeatherTag_SetupAction(this, func_80966F74); } } // WEATHERTAG_TYPE_UNK3 2 -void func_80966F74(EnWeatherTag* this, GlobalContext* globalCtx) { - if (func_80966758(this, globalCtx, 1, 0, 2, 0, 100)) { - func_800FD858(globalCtx); - globalCtx->envCtx.unk_F2[0] = 0; +void func_80966F74(EnWeatherTag* this, PlayState* play) { + if (func_80966758(this, play, 1, 0, 2, 0, 100)) { + func_800FD858(play); + play->envCtx.unk_F2[0] = 0; EnWeatherTag_SetupAction(this, func_80966EF0); } } @@ -347,39 +344,40 @@ void func_80966F74(EnWeatherTag* this, GlobalContext* globalCtx) { // WEATHERTAG_TYPE_UNK4: no visible effect, what does it doooo?? // used in south clock town??? romani ranch, clock tower rooftop woodfall..? stt // all of them have shorter distances though, like 0xA and 0x6, so their locations are important -void func_80966FEC(EnWeatherTag* this, GlobalContext* globalCtx) { +void func_80966FEC(EnWeatherTag* this, PlayState* play) { // weirdly, not the same as the other param lookup used in the rest of the file, which is float - s32 distance = WEATHER_TAG_RANGE100INT(this); + s32 distance = WEATHER_TAG_RANGE100INT(&this->actor); if (distance > 0) { D_801F4E7A = distance; } // unique pirates fortress behavior? - if ((globalCtx->sceneNum == SCENE_KAIZOKU) && (globalCtx->actorCtx.unk5 & 2)) { + if ((play->sceneNum == SCENE_KAIZOKU) && (play->actorCtx.unk5 & 2)) { EnWeatherTag_SetupAction(this, func_80967060); } } // type 4_2 pirates fortres only? -void func_80967060(EnWeatherTag* this, GlobalContext* globalCtx) { - Vec3f vec1; - Vec3f vec2; +void func_80967060(EnWeatherTag* this, PlayState* play) { + Vec3f worldPos; + Vec3f screenPos; - vec1.x = 1055.0f; - vec1.y = -145.0f; - vec1.z = 181.0f; + worldPos.x = 1055.0f; + worldPos.y = -145.0f; + worldPos.z = 181.0f; - func_80169474(globalCtx, &vec1, &vec2); + Play_GetScreenPos(play, &worldPos, &screenPos); - if (globalCtx->view.fovy < 25.0f) { - if ((vec2.x >= 70.0f) && (vec2.x < 250.0f) && (vec2.y >= 30.0f) && (vec2.y < 210.0f)) { + if (play->view.fovy < 25.0f) { + if ((screenPos.x >= 70.0f) && (screenPos.x < (SCREEN_WIDTH - 70.0f)) && (screenPos.y >= 30.0f) && + (screenPos.y < (SCREEN_HEIGHT - 30.0f))) { EnWeatherTag_SetupAction(this, func_80967148); } } } // type 4_3, start cutscene then die? -void func_80967148(EnWeatherTag* this, GlobalContext* globalCtx) { +void func_80967148(EnWeatherTag* this, PlayState* play) { s16 tempCutscene; tempCutscene = this->actor.cutscene; @@ -391,112 +389,109 @@ void func_80967148(EnWeatherTag* this, GlobalContext* globalCtx) { } } -void EnWeatherTag_DoNothing(EnWeatherTag* this, GlobalContext* globalCtx) { +void EnWeatherTag_DoNothing(EnWeatherTag* this, PlayState* play) { } // these two are isolated, they call themselves but nothing calls them? -void EnWeatherTag_Unused_809671B8(EnWeatherTag* this, GlobalContext* globalCtx) { - if (func_80966608(this, globalCtx, 0, 1, 0, 4, 100, 5)) { - func_800FD78C(globalCtx); - globalCtx->envCtx.unk_E3 = 1; - globalCtx->envCtx.unk_F2[0] = 60; +void EnWeatherTag_Unused_809671B8(EnWeatherTag* this, PlayState* play) { + if (func_80966608(this, play, 0, 1, 0, 4, 100, 5)) { + func_800FD78C(play); + play->envCtx.unk_E3 = 1; + play->envCtx.unk_F2[0] = 60; EnWeatherTag_SetupAction(this, EnWeatherTag_Unused_80967250); } } // these two are isolated, they call themselves but nothing calls them -void EnWeatherTag_Unused_80967250(EnWeatherTag* this, GlobalContext* globalCtx) { - if (func_80966758(this, globalCtx, 1, 0, 4, 0, 100)) { - func_800FD858(globalCtx); - globalCtx->envCtx.unk_E3 = 2; - globalCtx->envCtx.unk_F2[0] = 0; +void EnWeatherTag_Unused_80967250(EnWeatherTag* this, PlayState* play) { + if (func_80966758(this, play, 1, 0, 4, 0, 100)) { + func_800FD858(play); + play->envCtx.unk_E3 = 2; + play->envCtx.unk_F2[0] = 0; EnWeatherTag_SetupAction(this, EnWeatherTag_Unused_809671B8); } } // WEATHERTAG_TYPE_WATERMURK: (pinnacle rock, zora cape, zora coast) -void func_809672DC(EnWeatherTag* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); +void func_809672DC(EnWeatherTag* this, PlayState* play) { + Player* player = GET_PLAYER(play); s32 pad; f32 distance; f32 range; f32 strength = 0.0f; - Actor_GetClosestPosOnPath(this->pathPoints, this->pathCount, &GET_PLAYER(globalCtx)->actor.world.pos, + Actor_GetClosestPosOnPath(this->pathPoints, this->pathCount, &GET_PLAYER(play)->actor.world.pos, &this->actor.world.pos, false); distance = Actor_XZDistanceBetweenActors(&player->actor, &this->actor); - range = WEATHER_TAG_RANGE100(this); + range = WEATHER_TAG_RANGE100(&this->actor); if (distance < range) { - globalCtx->envCtx.sandstormState = 6; + play->envCtx.sandstormState = 6; strength = 1.0f - (distance / range); if (0.8f < strength) { strength = 1.0f; } D_801F4E30 = (200.0f * strength); } else { - if (globalCtx->envCtx.sandstormState == 6) { + if (play->envCtx.sandstormState == 6) { D_801F4E30 = 0; - globalCtx->envCtx.sandstormState = 7; + play->envCtx.sandstormState = 7; } } - Math_SmoothStepToS(&globalCtx->envCtx.lightSettings.fogNear, (s16)(-40.0f * strength), 1, 1, 1); + Math_SmoothStepToS(&play->envCtx.lightSettings.fogNear, (s16)(-40.0f * strength), 1, 1, 1); } // WEATHERTAG_TYPE_LOCALDAY2RAIN: rain proximity as approaching rainy scene // (milk road day 2 approaching ranch it rains, walking away towards termfield no rain) -void func_809674C8(EnWeatherTag* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); +void func_809674C8(EnWeatherTag* this, PlayState* play) { + Player* player = GET_PLAYER(play); - if (Actor_XZDistanceBetweenActors(&player->actor, &this->actor) < WEATHER_TAG_RANGE100(this)) { + if (Actor_XZDistanceBetweenActors(&player->actor, &this->actor) < WEATHER_TAG_RANGE100(&this->actor)) { if (CURRENT_DAY == 2) { if ((gSaveContext.save.time >= CLOCK_TIME(7, 0)) && (gSaveContext.save.time < CLOCK_TIME(17, 30)) && - (globalCtx->envCtx.unk_F2[2] == 0)) { + (play->envCtx.unk_F2[2] == 0)) { - D_801BDBB0 = 1; - func_800FD78C(globalCtx); - globalCtx->envCtx.unk_F2[4] = 0x20; + gWeatherMode = 1; + func_800FD78C(play); + play->envCtx.unk_F2[4] = 0x20; EnWeatherTag_SetupAction(this, func_80967608); } } } else { - if ((globalCtx->envCtx.unk_F2[4] != 0) && !(globalCtx->state.frames & 3)) { - globalCtx->envCtx.unk_F2[4]--; - if ((globalCtx->envCtx.unk_F2[4]) == 8) { - func_800FD858(globalCtx); + if ((play->envCtx.unk_F2[4] != 0) && !(play->state.frames & 3)) { + play->envCtx.unk_F2[4]--; + if ((play->envCtx.unk_F2[4]) == 8) { + func_800FD858(play); } } } } // WEATHERTAG_TYPE_LOCALDAY2RAIN 2 -void func_80967608(EnWeatherTag* this, GlobalContext* globalCtx) { - if ((WEATHER_TAG_RANGE100(this) + 10.0f) < - Actor_XZDistanceBetweenActors(&GET_PLAYER(globalCtx)->actor, &this->actor)) { - D_801BDBB0 = 0; +void func_80967608(EnWeatherTag* this, PlayState* play) { + if ((WEATHER_TAG_RANGE100(&this->actor) + 10.0f) < + Actor_XZDistanceBetweenActors(&GET_PLAYER(play)->actor, &this->actor)) { + gWeatherMode = 0; EnWeatherTag_SetupAction(this, func_809674C8); } } -void EnWeatherTag_Update(Actor* thisx, GlobalContext* globalCtx) { +void EnWeatherTag_Update(Actor* thisx, PlayState* play) { EnWeatherTag* this = THIS; - u16 oldTime; - this->actionFunc(this, globalCtx); - 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)) { + this->actionFunc(this, play); + if ((play->actorCtx.unk5 & 2) && (play->msgCtx.msgMode != 0) && (play->msgCtx.currentTextId == 0x5E6) && + (!FrameAdvance_IsEnabled(&play->state)) && (play->transitionTrigger == TRANS_TRIGGER_OFF) && + (ActorCutscene_GetCurrentIndex() == -1) && (play->csCtx.state == 0)) { - oldTime = gSaveContext.save.time; - gSaveContext.save.time = (u16)REG(0xF) + oldTime; // cast req - if (REG(0xF) != 0) { - oldTime = gSaveContext.save.time; - gSaveContext.save.time = (u16)gSaveContext.save.daySpeed + 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); } } } -void EnWeatherTag_Draw(Actor* thisx, GlobalContext* globalCtx) { +void EnWeatherTag_Draw(Actor* thisx, PlayState* play) { } diff --git a/src/overlays/actors/ovl_En_Weather_Tag/z_en_weather_tag.h b/src/overlays/actors/ovl_En_Weather_Tag/z_en_weather_tag.h index f1a876718..84aa36b03 100644 --- a/src/overlays/actors/ovl_En_Weather_Tag/z_en_weather_tag.h +++ b/src/overlays/actors/ovl_En_Weather_Tag/z_en_weather_tag.h @@ -5,12 +5,12 @@ struct EnWeatherTag; -typedef void (*EnWeatherTagActionFunc)(struct EnWeatherTag*, GlobalContext*); +typedef void (*EnWeatherTagActionFunc)(struct EnWeatherTag*, PlayState*); typedef struct EnWeatherTag { /* 0x000 */ Actor actor; /* 0x144 */ EnWeatherTagActionFunc actionFunc; - /* 0x148 */ u8 pad148[0x4]; // todo attempt remove + /* 0x148 */ UNK_TYPE1 pad148[0x4]; /* 0x14C */ u8 pathCount; /* 0x150 */ Vec3s* pathPoints; // 154: the code avoids what would be a negative value if signed, but signed wont match @@ -21,10 +21,10 @@ typedef struct EnWeatherTag { extern const ActorInit En_Weather_Tag_InitVars; -#define WEATHER_TAG_TYPE(x) (x->actor.params & 0xF) -#define WEATHER_TAG_PATHID(x) (x->actor.params >> 4 & 0xF) -#define WEATHER_TAG_RANGE100(x) ((u8)(((x->actor.params >> 8) & 0xFF)) * 100.0f) -#define WEATHER_TAG_RANGE100INT(x) ((u8)(((x->actor.params >> 8))) * 100) +#define WEATHER_TAG_TYPE(thisx) ((thisx)->params & 0xF) +#define WEATHER_TAG_PATHID(thisx) (((thisx)->params >> 4) & 0xF) +#define WEATHER_TAG_RANGE100(thisx) ((u8)(((thisx)->params >> 8) & 0xFF) * 100.0f) +#define WEATHER_TAG_RANGE100INT(thisx) ((u8)(((thisx)->params >> 8) & 0xFF) * 100) typedef enum { /* 0 */ WEATHERTAG_TYPE_UNK0, 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 3b92a8eab..8a5da16c5 100644 --- a/src/overlays/actors/ovl_En_Wf/z_en_wf.c +++ b/src/overlays/actors/ovl_En_Wf/z_en_wf.c @@ -7,54 +7,53 @@ #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 (ACTOR_FLAG_1 | ACTOR_FLAG_4 | ACTOR_FLAG_10 | ACTOR_FLAG_400) #define THIS ((EnWf*)thisx) -void EnWf_Init(Actor* thisx, GlobalContext* globalCtx); -void EnWf_Destroy(Actor* thisx, GlobalContext* globalCtx); -void EnWf_Update(Actor* thisx, GlobalContext* globalCtx); -void EnWf_Draw(Actor* thisx, GlobalContext* globalCtx); +void EnWf_Init(Actor* thisx, PlayState* play); +void EnWf_Destroy(Actor* thisx, PlayState* play); +void EnWf_Update(Actor* thisx, PlayState* play); +void EnWf_Draw(Actor* thisx, PlayState* play); void func_80990F0C(EnWf* this); -void func_80990F50(EnWf* this, GlobalContext* globalCtx); +void func_80990F50(EnWf* this, PlayState* play); void func_80990FC8(EnWf* this); -void func_80991040(EnWf* this, GlobalContext* globalCtx); -void func_80991174(EnWf* this, GlobalContext* globalCtx); +void func_80991040(EnWf* this, PlayState* play); +void func_80991174(EnWf* this, PlayState* play); void func_80991200(EnWf* this); -void func_80991280(EnWf* this, GlobalContext* globalCtx); +void func_80991280(EnWf* this, PlayState* play); void func_80991438(EnWf* this); -void func_8099149C(EnWf* this, GlobalContext* globalCtx); +void func_8099149C(EnWf* this, PlayState* play); void func_80991738(EnWf* this); -void func_8099177C(EnWf* this, GlobalContext* globalCtx); +void func_8099177C(EnWf* this, PlayState* play); void func_80991948(EnWf* this); -void func_809919F4(EnWf* this, GlobalContext* globalCtx); +void func_809919F4(EnWf* this, PlayState* play); void func_80991C04(EnWf* this); -void func_80991C80(EnWf* this, GlobalContext* globalCtx); -void func_80992068(EnWf* this, GlobalContext* globalCtx); +void func_80991C80(EnWf* this, PlayState* play); +void func_80992068(EnWf* this, PlayState* play); void func_8099223C(EnWf* this); -void func_809922B4(EnWf* this, GlobalContext* globalCtx); -void func_809923E4(EnWf* this, GlobalContext* globalCtx); -void func_809924EC(EnWf* this, GlobalContext* globalCtx); +void func_809922B4(EnWf* this, PlayState* play); +void func_809923E4(EnWf* this, PlayState* play); +void func_809924EC(EnWf* this, PlayState* play); void func_809926D0(EnWf* this); -void func_80992784(EnWf* this, GlobalContext* globalCtx); +void func_80992784(EnWf* this, PlayState* play); void func_8099282C(EnWf* this); -void func_809928CC(EnWf* this, GlobalContext* globalCtx); -void func_80992A74(EnWf* this, GlobalContext* globalCtx); -void func_80992B8C(EnWf* this, GlobalContext* globalCtx); +void func_809928CC(EnWf* this, PlayState* play); +void func_80992A74(EnWf* this, PlayState* play); +void func_80992B8C(EnWf* this, PlayState* play); void func_80992D6C(EnWf* this); -void func_80992E0C(EnWf* this, GlobalContext* globalCtx); +void func_80992E0C(EnWf* this, PlayState* play); void func_80992FD4(EnWf* this); -void func_80993018(EnWf* this, GlobalContext* globalCtx); +void func_80993018(EnWf* this, PlayState* play); void func_80993148(EnWf* this); -void func_80993194(EnWf* this, GlobalContext* globalCtx); +void func_80993194(EnWf* this, PlayState* play); void func_80993350(EnWf* this); -void func_809933A0(EnWf* this, GlobalContext* globalCtx); +void func_809933A0(EnWf* this, PlayState* play); void func_80993524(EnWf* this); -void func_8099357C(EnWf* this, GlobalContext* globalCtx); -s32 func_8099408C(GlobalContext* globalCtx, EnWf* this); +void func_8099357C(EnWf* this, PlayState* play); +s32 func_8099408C(PlayState* play, EnWf* this); const ActorInit En_Wf_InitVars = { ACTOR_EN_WF, @@ -124,7 +123,7 @@ static ColliderJntSphInit sJntSphInit = { OC2_TYPE_1, COLSHAPE_JNTSPH, }, - 4, + ARRAY_COUNT(sJntSphElementsInit), sJntSphElementsInit, }; @@ -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[] = { @@ -261,7 +260,7 @@ static InitChainEntry sInitChain[] = { static s32 D_809942D8 = 0; -void EnWf_Init(Actor* thisx, GlobalContext* globalCtx) { +void EnWf_Init(Actor* thisx, PlayState* play) { EnWf* this = THIS; s32 i; s32 temp_s0; @@ -269,9 +268,9 @@ void EnWf_Init(Actor* thisx, GlobalContext* globalCtx) { Actor_ProcessInitChain(&this->actor, sInitChain); ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 70.0f); this->actor.shape.shadowAlpha = 150; - Collider_InitAndSetJntSph(globalCtx, &this->collider1, &this->actor, &sJntSphInit, this->collider1Elements); - Collider_InitAndSetCylinder(globalCtx, &this->collider2, &this->actor, &sCylinderInit1); - Collider_InitAndSetCylinder(globalCtx, &this->collider3, &this->actor, &sCylinderInit2); + Collider_InitAndSetJntSph(play, &this->collider1, &this->actor, &sJntSphInit, this->collider1Elements); + Collider_InitAndSetCylinder(play, &this->collider2, &this->actor, &sCylinderInit1); + Collider_InitAndSetCylinder(play, &this->collider3, &this->actor, &sCylinderInit2); Math_Vec3f_Copy(&this->actor.focus.pos, &this->actor.world.pos); if (this->actor.shape.rot.x <= 0) { @@ -294,11 +293,11 @@ void EnWf_Init(Actor* thisx, GlobalContext* globalCtx) { temp_s0 = CLAMP(temp_s0, 1, 255); this->actor.shape.rot.z = 0; this->actor.world.rot.z = 0; - this->actor.child = Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_OBJ_ICE_POLY, this->actor.world.pos.x, - this->actor.world.pos.y, this->actor.world.pos.z, 0, this->actor.shape.rot.y, 0, - temp_s0 | 0xFF00); + this->actor.child = + Actor_Spawn(&play->actorCtx, play, ACTOR_OBJ_ICE_POLY, this->actor.world.pos.x, this->actor.world.pos.y, + this->actor.world.pos.z, 0, this->actor.shape.rot.y, 0, temp_s0 | 0xFF00); if (this->actor.child != NULL) { - Player* player = GET_PLAYER(globalCtx); + Player* player = GET_PLAYER(play); this->actor.child->xzDistToPlayer = Actor_XZDistanceBetweenActors(&this->actor, &player->actor); this->unk_2A4 = (temp_s0 * 0.5f) + 45.0f; @@ -309,7 +308,7 @@ void EnWf_Init(Actor* thisx, GlobalContext* globalCtx) { } } - if (Flags_GetClear(globalCtx, this->actor.room)) { + if (Flags_GetClear(play, this->actor.room)) { Actor_MarkForDeath(&this->actor); return; } @@ -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(play, &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(play, &this->skelAnime, &gWolfosWhiteSkel, &gWolfosWaitingAnim, this->jointTable, + this->morphTable, WOLFOS_WHITE_LIMB_MAX); this->actor.hintId = 0x57; CollisionCheck_SetInfo(&this->actor.colChkInfo, &sDamageTable1, &sColChkInfoInit); } @@ -339,24 +338,24 @@ void EnWf_Init(Actor* thisx, GlobalContext* globalCtx) { func_80992FD4(this); } - func_800BC154(globalCtx, &globalCtx->actorCtx, &this->actor, 5); + func_800BC154(play, &play->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; } this->unk_2A2 = Rand_ZeroFloat(96.0f); } -void EnWf_Destroy(Actor* thisx, GlobalContext* globalCtx) { +void EnWf_Destroy(Actor* thisx, PlayState* play) { EnWf* this = THIS; - Collider_DestroyJntSph(globalCtx, &this->collider1); - Collider_DestroyCylinder(globalCtx, &this->collider2); - Collider_DestroyCylinder(globalCtx, &this->collider3); + Collider_DestroyJntSph(play, &this->collider1); + Collider_DestroyCylinder(play, &this->collider2); + Collider_DestroyCylinder(play, &this->collider3); } void func_809907D4(EnWf* this) { @@ -371,30 +370,30 @@ void func_809907D4(EnWf* this) { Actor_SetColorFilter(&this->actor, 0x4000, 0xFF, 0, 80); } -void func_80990854(EnWf* this, GlobalContext* globalCtx) { +void func_80990854(EnWf* this, PlayState* play) { 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->drawDmgEffAlpha = 0.0f; - Actor_SpawnIceEffects(globalCtx, &this->actor, this->limbPos, 10, 2, 0.3f, 0.2f); + Actor_SpawnIceEffects(play, &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; } } -s32 func_80990948(GlobalContext* globalCtx, EnWf* this, s16 arg2) { - Player* player = GET_PLAYER(globalCtx); +s32 func_80990948(PlayState* play, EnWf* this, s16 arg2) { + Player* player = GET_PLAYER(play); s32 sp38; s32 pad; s32 pad2; @@ -411,13 +410,13 @@ s32 func_80990948(GlobalContext* globalCtx, EnWf* this, s16 arg2) { return true; } - if (func_800BE184(globalCtx, &this->actor, 100.0f, 10000, 12000, this->actor.shape.rot.y) && - ((player->swordAnimation == 0x11) || ((globalCtx->gameplayFrames % 2) != 0))) { + if (func_800BE184(play, &this->actor, 100.0f, 10000, 12000, this->actor.shape.rot.y) && + ((player->meleeWeaponAnimation == PLAYER_MWA_JUMPSLASH_START) || ((play->gameplayFrames % 2) != 0))) { func_8099282C(this); return true; } - if (func_800BE184(globalCtx, &this->actor, 100.0f, 24000, 0x2AA8, this->actor.shape.rot.y)) { + if (func_800BE184(play, &this->actor, 100.0f, 24000, 0x2AA8, this->actor.shape.rot.y)) { this->actor.shape.rot.y = this->actor.yawTowardsPlayer; this->actor.world.rot.y = this->actor.yawTowardsPlayer; if ((this->actor.bgCheckFlags & 8) && (sp38 < 12000)) { @@ -425,7 +424,7 @@ s32 func_80990948(GlobalContext* globalCtx, EnWf* this, s16 arg2) { return true; } - if ((player->swordAnimation == 0x11) || ((globalCtx->gameplayFrames % 2) != 0)) { + if ((player->meleeWeaponAnimation == PLAYER_MWA_JUMPSLASH_START) || ((play->gameplayFrames % 2) != 0)) { func_8099282C(this); return true; } @@ -434,7 +433,7 @@ s32 func_80990948(GlobalContext* globalCtx, EnWf* this, s16 arg2) { return true; } - actor = func_800BC444(globalCtx, &this->actor, 80.0f); + actor = func_800BC444(play, &this->actor, 80.0f); if ((actor != NULL) && (actor->id == ACTOR_EN_BOM_CHU)) { EnBomChu* bomchu = (EnBomChu*)actor; @@ -448,13 +447,13 @@ s32 func_80990948(GlobalContext* globalCtx, EnWf* this, s16 arg2) { if (arg2 != 0) { if (!Actor_IsFacingPlayer(&this->actor, 7000)) { - func_80992A74(this, globalCtx); + func_80992A74(this, play); return true; } sp2E = player->actor.shape.rot.y - this->actor.shape.rot.y; - if ((this->actor.xzDistToPlayer <= 80.0f) && !Actor_OtherIsTargeted(globalCtx, &this->actor)) { - if (((globalCtx->gameplayFrames % 8) != 0) || (ABS_ALT(sp2E) < 0x38E0)) { + if ((this->actor.xzDistToPlayer <= 80.0f) && !Actor_OtherIsTargeted(play, &this->actor)) { + if (((play->gameplayFrames % 8) != 0) || (ABS_ALT(sp2E) < 0x38E0)) { func_80991C04(this); return true; } @@ -466,7 +465,7 @@ s32 func_80990948(GlobalContext* globalCtx, EnWf* this, s16 arg2) { return false; } -void func_80990C6C(EnWf* this, GlobalContext* globalCtx, s32 arg2) { +void func_80990C6C(EnWf* this, PlayState* play, s32 arg2) { static Vec3f D_809942DC = { 0.0f, 0.1f, 0.0f }; static Color_RGBA8 D_809942E8 = { 185, 140, 70, 255 }; static Color_RGBA8 D_809942EC = { 255, 255, 255, 255 }; @@ -477,7 +476,7 @@ void func_80990C6C(EnWf* this, GlobalContext* globalCtx, s32 arg2) { s16 phi_s6; if (this->actor.floorPoly != NULL) { - temp_v0 = func_800C99D4(&globalCtx->colCtx, this->actor.floorPoly, this->actor.floorBgId); + temp_v0 = func_800C99D4(&play->colCtx, this->actor.floorPoly, this->actor.floorBgId); if (temp_v0 != 5) { if ((temp_v0 == 15) || (temp_v0 == 14)) { phi_s1 = &D_809942EC; @@ -492,16 +491,16 @@ void func_80990C6C(EnWf* this, GlobalContext* globalCtx, s32 arg2) { sp88.x = randPlusMinusPoint5Scaled(50.0f) + this->actor.world.pos.x; sp88.y = Rand_ZeroFloat(5.0f) + this->actor.world.pos.y; sp88.z = randPlusMinusPoint5Scaled(50.0f) + this->actor.world.pos.z; - func_800B0F18(globalCtx, &sp88, &gZeroVec3f, &D_809942DC, phi_s1, phi_s1, phi_s6, 5, + func_800B0F18(play, &sp88, &gZeroVec3f, &D_809942DC, phi_s1, phi_s1, phi_s6, 5, Rand_ZeroFloat(5.0f) + 14.0f); } } } } -void func_80990E4C(EnWf* this, GlobalContext* globalCtx) { +void func_80990E4C(EnWf* this, PlayState* play) { if (Animation_OnFrame(&this->skelAnime, 1.0f) && (this->actor.bgCheckFlags & 1)) { - func_80990C6C(this, globalCtx, 2); + func_80990C6C(this, play, 2); Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_WOLFOS_WALK); } } @@ -531,7 +530,7 @@ void func_80990F0C(EnWf* this) { this->actionFunc = func_80990F50; } -void func_80990F50(EnWf* this, GlobalContext* globalCtx) { +void func_80990F50(EnWf* this, PlayState* play) { f32 phi_f2 = 240.0f; if (this->unk_2A0 != 0) { @@ -550,13 +549,13 @@ 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, ANIMMODE_ONCE_INTERP, 0.0f); this->unk_2A0 = 5; this->actor.flags |= ACTOR_FLAG_1; this->actionFunc = func_80991040; } -void func_80991040(EnWf* this, GlobalContext* globalCtx) { +void func_80991040(EnWf* this, PlayState* play) { if (this->unk_2A0 != 0) { this->actor.scale.y += this->actor.scale.x * 0.2f; Math_StepToF(&this->actor.shape.shadowScale, 70.0f, 14.0f); @@ -573,12 +572,12 @@ 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, ANIMMODE_ONCE_INTERP, -5.0f); this->unk_2A0 = 5; this->actionFunc = func_80991174; } -void func_80991174(EnWf* this, GlobalContext* globalCtx) { +void func_80991174(EnWf* this, PlayState* play) { if (SkelAnime_Update(&this->skelAnime)) { if (this->unk_2A0 > 0) { this->actor.scale.y -= this->actor.scale.x * 0.2f; @@ -592,15 +591,15 @@ 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; this->actor.speedXZ = 0.0f; } -void func_80991280(EnWf* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); +void func_80991280(EnWf* this, PlayState* play) { + Player* player = GET_PLAYER(play); s16 temp_v0; s32 phi_v1; @@ -614,9 +613,9 @@ void func_80991280(EnWf* this, GlobalContext* globalCtx) { this->unk_298 = 0; } - if (!func_8099408C(globalCtx, this) && !func_80990948(globalCtx, this, 0)) { + if (!func_8099408C(play, this) && !func_80990948(play, this, 0)) { phi_v1 = ABS_ALT(BINANG_SUB(player->actor.shape.rot.y, this->actor.shape.rot.y)); - if ((this->actor.xzDistToPlayer < 80.0f) && (player->swordState != 0) && (phi_v1 >= 0x1F40)) { + if ((this->actor.xzDistToPlayer < 80.0f) && (player->meleeWeaponState != 0) && (phi_v1 >= 0x1F40)) { this->actor.shape.rot.y = this->actor.yawTowardsPlayer; this->actor.world.rot.y = this->actor.yawTowardsPlayer; func_80991948(this); @@ -643,22 +642,22 @@ 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; } -void func_8099149C(EnWf* this, GlobalContext* globalCtx) { +void func_8099149C(EnWf* this, PlayState* play) { f32 sp2C; s32 sp28; s32 pad; - Player* player = GET_PLAYER(globalCtx); + Player* player = GET_PLAYER(play); - if (!func_8099408C(globalCtx, this)) { + if (!func_8099408C(play, this)) { Math_ScaledStepToS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer, 500); this->actor.world.rot.y = this->actor.shape.rot.y; - if (Actor_OtherIsTargeted(globalCtx, &this->actor)) { + if (Actor_OtherIsTargeted(play, &this->actor)) { sp2C = 150.0f; } else { sp2C = 0.0f; @@ -666,7 +665,7 @@ void func_8099149C(EnWf* this, GlobalContext* globalCtx) { sp28 = ABS_ALT(BINANG_SUB(player->actor.shape.rot.y, this->actor.shape.rot.y)); - if ((this->actor.xzDistToPlayer < (150.0f + sp2C)) && (player->swordState != 0) && (sp28 >= 0x1F40)) { + if ((this->actor.xzDistToPlayer < (150.0f + sp2C)) && (player->meleeWeaponState != 0) && (sp28 >= 0x1F40)) { this->actor.shape.rot.y = this->actor.yawTowardsPlayer; this->actor.world.rot.y = this->actor.yawTowardsPlayer; if (Rand_ZeroOne() > 0.7f) { @@ -676,7 +675,7 @@ void func_8099149C(EnWf* this, GlobalContext* globalCtx) { } SkelAnime_Update(&this->skelAnime); - if (!func_80990948(globalCtx, this, 0)) { + if (!func_80990948(play, this, 0)) { if (!Actor_IsFacingPlayer(&this->actor, 0x11C7)) { if (Rand_ZeroOne() > 0.5f) { func_80991948(this); @@ -684,10 +683,10 @@ void func_8099149C(EnWf* this, GlobalContext* globalCtx) { func_80991200(this); } } else if (this->actor.xzDistToPlayer < (90.0f + sp2C)) { - if (!Actor_OtherIsTargeted(globalCtx, &this->actor) && + if (!Actor_OtherIsTargeted(play, &this->actor) && ((Rand_ZeroOne() > 0.03f) || ((this->actor.xzDistToPlayer <= 80.0f) && (sp28 < 0x38E0)))) { func_80991C04(this); - } else if (Actor_OtherIsTargeted(globalCtx, &this->actor) && (Rand_ZeroOne() > 0.5f)) { + } else if (Actor_OtherIsTargeted(play, &this->actor) && (Rand_ZeroOne() > 0.5f)) { func_8099223C(this); } else { func_80991948(this); @@ -698,23 +697,23 @@ void func_8099149C(EnWf* this, GlobalContext* globalCtx) { Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_WOLFOS_CRY); } - func_80990E4C(this, globalCtx); + func_80990E4C(this, play); } } } 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; } -void func_8099177C(EnWf* this, GlobalContext* globalCtx) { +void func_8099177C(EnWf* this, PlayState* play) { s16 temp_v0; s16 phi_v1; f32 phi_f2; f32 phi_f12; - if (!func_8099408C(globalCtx, this) && !func_80990948(globalCtx, this, 0)) { + if (!func_8099408C(play, this) && !func_80990948(play, this, 0)) { temp_v0 = this->actor.yawTowardsPlayer - this->actor.shape.rot.y; if (temp_v0 > 0) { phi_v1 = (temp_v0 * 0.25f) + 2000.0f; @@ -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 { @@ -768,13 +767,13 @@ void func_80991948(EnWf* this) { this->actionFunc = func_809919F4; } -void func_809919F4(EnWf* this, GlobalContext* globalCtx) { +void func_809919F4(EnWf* this, PlayState* play) { s16 sp26; - Player* player = GET_PLAYER(globalCtx); + Player* player = GET_PLAYER(play); s16 temp_v0; Math_ScaledStepToS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer + this->unk_29A, 2500); - if (!func_8099408C(globalCtx, this) && !func_80990948(globalCtx, this, 0)) { + if (!func_8099408C(play, this) && !func_80990948(play, this, 0)) { this->actor.world.rot.y = this->actor.shape.rot.y; sp26 = BINANG_ROT180(player->actor.shape.rot.y + this->unk_29A); if (this->actor.bgCheckFlags & 8) { @@ -785,19 +784,19 @@ void func_809919F4(EnWf* this, GlobalContext* globalCtx) { } SkelAnime_Update(&this->skelAnime); - func_80990E4C(this, globalCtx); + func_80990E4C(this, play); if (this->unk_2A2 == 0) { Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_WOLFOS_CRY); } - if ((Math_CosS(sp26 - this->actor.shape.rot.y) < -0.85f) && !Actor_OtherIsTargeted(globalCtx, &this->actor) && + if ((Math_CosS(sp26 - this->actor.shape.rot.y) < -0.85f) && !Actor_OtherIsTargeted(play, &this->actor) && (this->actor.xzDistToPlayer <= 80.0f)) { func_80991C04(this); } else { this->unk_2A0--; if (this->unk_2A0 == 0) { - if (Actor_OtherIsTargeted(globalCtx, &this->actor) && (Rand_ZeroOne() > 0.5f)) { + if (Actor_OtherIsTargeted(play, &this->actor) && (Rand_ZeroOne() > 0.5f)) { func_8099223C(this); } else { func_80991200(this); @@ -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; @@ -819,8 +818,8 @@ void func_80991C04(EnWf* this) { this->actionFunc = func_80991C80; } -void func_80991C80(EnWf* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); +void func_80991C80(EnWf* this, PlayState* play) { + Player* player = GET_PLAYER(play); s32 sp30; s32 sp2C; s16 sp2A; @@ -840,12 +839,12 @@ void func_80991C80(EnWf* this, GlobalContext* globalCtx) { } sp2C = Animation_OnFrame(&this->skelAnime, 15.0f); - if (((sp2C != 0) && !Actor_IsTargeted(globalCtx, &this->actor) && + if (((sp2C != 0) && !Actor_IsTargeted(play, &this->actor) && (!Actor_IsFacingPlayer(&this->actor, 0x2000) || (this->actor.xzDistToPlayer >= 100.0f))) || SkelAnime_Update(&this->skelAnime)) { if ((sp2C == 0) && (this->unk_2A0 != 0)) { this->actor.shape.rot.y += (s16)(0xCCC * (1.5f + ((this->unk_2A0 - 4) * 0.4f))); - func_80990C6C(this, globalCtx, 1); + func_80990C6C(this, play, 1); this->unk_2A0--; } else if (!Actor_IsFacingPlayer(&this->actor, 0x1554) && (sp2C == 0)) { func_80991200(this); @@ -859,13 +858,13 @@ void func_80991C80(EnWf* this, GlobalContext* globalCtx) { } else { this->actor.world.rot.y = this->actor.yawTowardsPlayer; if (Rand_ZeroOne() > 0.7f) { - func_80992A74(this, globalCtx); + func_80992A74(this, play); } else if (ABS_ALT(sp2A) < 0x2711) { if (sp30 >= 0x3E81) { this->actor.world.rot.y = this->actor.yawTowardsPlayer; func_80991948(this); } else { - func_80990948(globalCtx, this, 1); + func_80990948(play, this, 1); } } else { func_80991948(this); @@ -880,13 +879,14 @@ 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, + ANIMMODE_ONCE_INTERP, 0.0f); this->collider1.base.atFlags &= ~AT_ON; this->actionFunc = func_80992068; } -void func_80992068(EnWf* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); +void func_80992068(EnWf* this, PlayState* play) { + Player* player = GET_PLAYER(play); s32 sp28; s16 sp26; @@ -906,13 +906,13 @@ void func_80992068(EnWf* this, GlobalContext* globalCtx) { } else { this->actor.world.rot.y = this->actor.yawTowardsPlayer; if (Rand_ZeroOne() > 0.7f) { - func_80992A74(this, globalCtx); + func_80992A74(this, play); } else if (ABS_ALT(sp26) < 0x2711) { if (sp28 > 0x3E80) { this->actor.world.rot.y = this->actor.yawTowardsPlayer; func_80991948(this); } else { - func_80990948(globalCtx, this, 1); + func_80990948(play, this, 1); } } else { func_80991948(this); @@ -923,7 +923,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; @@ -932,13 +932,13 @@ void func_8099223C(EnWf* this) { this->actionFunc = func_809922B4; } -void func_809922B4(EnWf* this, GlobalContext* globalCtx) { +void func_809922B4(EnWf* this, PlayState* play) { if (SkelAnime_Update(&this->skelAnime)) { - if (!Actor_OtherIsTargeted(globalCtx, &this->actor) && (this->actor.xzDistToPlayer < 170.0f) && + if (!Actor_OtherIsTargeted(play, &this->actor) && (this->actor.xzDistToPlayer < 170.0f) && (this->actor.xzDistToPlayer > 140.0f) && (Rand_ZeroOne() < 0.2f)) { func_80991438(this); - } else if ((globalCtx->gameplayFrames % 2) != 0) { - func_80992A74(this, globalCtx); + } else if ((play->gameplayFrames % 2) != 0) { + func_80992A74(this, play); } else { func_80991200(this); } @@ -956,24 +956,24 @@ void func_809923B0(EnWf* this) { this->actionFunc = func_809923E4; } -void func_809923E4(EnWf* this, GlobalContext* globalCtx) { +void func_809923E4(EnWf* this, PlayState* play) { if (this->unk_2A0 != 0) { this->unk_2A0--; } if (this->unk_2A0 == 0) { - func_80990854(this, globalCtx); + func_80990854(this, play); if (this->actor.colChkInfo.health == 0) { func_80992D6C(this); } else { - func_80990948(globalCtx, this, 1); + func_80990948(play, this, 1); } } } 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; } @@ -983,7 +983,7 @@ void func_8099245C(EnWf* this) { this->actionFunc = func_809924EC; } -void func_809924EC(EnWf* this, GlobalContext* globalCtx) { +void func_809924EC(EnWf* this, PlayState* play) { s16 sp26; if (this->actor.bgCheckFlags & 2) { @@ -998,15 +998,15 @@ void func_809924EC(EnWf* this, GlobalContext* globalCtx) { if (SkelAnime_Update(&this->skelAnime)) { sp26 = this->actor.wallYaw - this->actor.shape.rot.y; - if (func_80990948(globalCtx, this, 0)) { + if (func_80990948(play, this, 0)) { return; } if ((this->actor.bgCheckFlags & 8) && (ABS_ALT(sp26) < 0x2EE0) && (this->actor.xzDistToPlayer < 120.0f)) { func_809926D0(this); - } else if (!func_8099408C(globalCtx, this)) { - if ((this->actor.xzDistToPlayer <= 80.0f) && !Actor_OtherIsTargeted(globalCtx, &this->actor) && - ((globalCtx->gameplayFrames % 8) != 0)) { + } else if (!func_8099408C(play, this)) { + if ((this->actor.xzDistToPlayer <= 80.0f) && !Actor_OtherIsTargeted(play, &this->actor) && + ((play->gameplayFrames % 8) != 0)) { func_80991C04(this); } else if (Rand_ZeroOne() > 0.5f) { func_80991200(this); @@ -1021,8 +1021,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, ANIMMODE_ONCE, -3.0f); this->unk_2A0 = 0; this->actor.speedXZ = 6.5f; this->actor.velocity.y = 15.0f; @@ -1031,7 +1031,7 @@ void func_809926D0(EnWf* this) { this->actionFunc = func_80992784; } -void func_80992784(EnWf* this, GlobalContext* globalCtx) { +void func_80992784(EnWf* this, PlayState* play) { Math_ScaledStepToS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer, 2500); if (SkelAnime_Update(&this->skelAnime) && (this->actor.bgCheckFlags & (2 | 1))) { this->actor.shape.rot.x = 0; @@ -1040,7 +1040,7 @@ void func_80992784(EnWf* this, GlobalContext* globalCtx) { this->actor.velocity.y = 0.0f; this->actor.speedXZ = 0.0f; this->actor.world.pos.y = this->actor.floorHeight; - if (!Actor_OtherIsTargeted(globalCtx, &this->actor)) { + if (!Actor_OtherIsTargeted(play, &this->actor)) { func_80991C04(this); } else { func_80991200(this); @@ -1053,20 +1053,20 @@ 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, ANIMMODE_ONCE, -2.0f); this->actionFunc = func_809928CC; } -void func_809928CC(EnWf* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); +void func_809928CC(EnWf* this, PlayState* play) { + Player* player = GET_PLAYER(play); s16 sp2A; if (SkelAnime_Update(&this->skelAnime)) { if (this->unk_2A0 != 0) { this->unk_2A0--; - } else if (func_800BE184(globalCtx, &this->actor, 100.0f, 10000, 0x4000, this->actor.shape.rot.y)) { - if ((player->swordAnimation != 0x11) || ((globalCtx->gameplayFrames % 2) != 0)) { + } else if (func_800BE184(play, &this->actor, 100.0f, 10000, 0x4000, this->actor.shape.rot.y)) { + if ((player->meleeWeaponAnimation != PLAYER_MWA_JUMPSLASH_START) || ((play->gameplayFrames % 2) != 0)) { this->unk_2A0 = 10; } else { func_8099223C(this); @@ -1074,8 +1074,8 @@ void func_809928CC(EnWf* this, GlobalContext* globalCtx) { } else if (Actor_IsFacingPlayer(&this->actor, 0x4000) && (this->actor.xzDistToPlayer < 60.0f) && (fabsf(this->actor.playerHeightRel) < 50.0f)) { sp2A = player->actor.shape.rot.y - this->actor.shape.rot.y; - if (!Actor_OtherIsTargeted(globalCtx, &this->actor) && - (((globalCtx->gameplayFrames % 2) != 0) || (ABS_ALT(sp2A) < 0x38E0))) { + if (!Actor_OtherIsTargeted(play, &this->actor) && + (((play->gameplayFrames % 2) != 0) || (ABS_ALT(sp2A) < 0x38E0))) { func_80991C04(this); } else { func_80991948(this); @@ -1086,13 +1086,13 @@ void func_809928CC(EnWf* this, GlobalContext* globalCtx) { } } -void func_80992A74(EnWf* this, GlobalContext* globalCtx) { +void func_80992A74(EnWf* this, PlayState* play) { Player* player; f32 temp_f0; this->collider2.base.acFlags |= AC_ON; - Animation_MorphToLoop(&this->skelAnime, &object_wf_Anim_005700, -4.0f); - player = GET_PLAYER(globalCtx); + Animation_MorphToLoop(&this->skelAnime, &gWolfosRunningAnim, -4.0f); + player = GET_PLAYER(play); temp_f0 = Math_SinS((player->actor.shape.rot.y + this->unk_29A) - this->actor.yawTowardsPlayer); if (temp_f0 > 0.0f) { this->unk_29A = 16000; @@ -1109,10 +1109,10 @@ void func_80992A74(EnWf* this, GlobalContext* globalCtx) { this->actionFunc = func_80992B8C; } -void func_80992B8C(EnWf* this, GlobalContext* globalCtx) { +void func_80992B8C(EnWf* this, PlayState* play) { s32 sp28; s32 sp2C; - Player* player = GET_PLAYER(globalCtx); + Player* player = GET_PLAYER(play); Math_ScaledStepToS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer + this->unk_29A, 2000); if (this->actor.bgCheckFlags & 8) { @@ -1125,7 +1125,7 @@ void func_80992B8C(EnWf* this, GlobalContext* globalCtx) { this->actor.world.rot.y = this->actor.shape.rot.y; SkelAnime_Update(&this->skelAnime); - if (!func_80990948(globalCtx, this, 0)) { + if (!func_80990948(play, this, 0)) { this->unk_2A0--; if (this->unk_2A0 == 0) { sp28 = ABS_ALT(BINANG_SUB(player->actor.shape.rot.y, this->actor.yawTowardsPlayer)); @@ -1134,8 +1134,8 @@ void func_80992B8C(EnWf* this, GlobalContext* globalCtx) { this->unk_2A0 = (s32)Rand_ZeroFloat(3.0f) + 1; } else { this->actor.world.rot.y = this->actor.shape.rot.y; - if ((this->actor.xzDistToPlayer <= 80.0f) && !Actor_OtherIsTargeted(globalCtx, &this->actor) && - (((globalCtx->gameplayFrames % 4) == 0) || (sp28 < 0x38E0))) { + if ((this->actor.xzDistToPlayer <= 80.0f) && !Actor_OtherIsTargeted(play, &this->actor) && + (((play->gameplayFrames % 4) == 0) || (sp28 < 0x38E0))) { func_80991C04(this); } else { func_80991438(this); @@ -1143,7 +1143,7 @@ void func_80992B8C(EnWf* this, GlobalContext* globalCtx) { } } - func_80990E4C(this, globalCtx); + func_80990E4C(this, play); if (this->unk_2A2 == 0) { Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_WOLFOS_CRY); @@ -1153,7 +1153,7 @@ 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; @@ -1164,7 +1164,7 @@ void func_80992D6C(EnWf* this) { this->actionFunc = func_80992E0C; } -void func_80992E0C(EnWf* this, GlobalContext* globalCtx) { +void func_80992E0C(EnWf* this, PlayState* play) { static Vec3f D_809942F0 = { 0.0f, 0.5f, 0.0f }; if (this->actor.bgCheckFlags & 2) { @@ -1177,9 +1177,9 @@ void func_80992E0C(EnWf* this, GlobalContext* globalCtx) { if (SkelAnime_Update(&this->skelAnime)) { if (this->unk_295 != 0) { - Item_DropCollectibleRandom(globalCtx, &this->actor, &this->actor.world.pos, 0x70); + Item_DropCollectibleRandom(play, &this->actor, &this->actor.world.pos, 0x70); } else { - Item_DropCollectibleRandom(globalCtx, &this->actor, &this->actor.world.pos, 0x60); + Item_DropCollectibleRandom(play, &this->actor, &this->actor.world.pos, 0x60); } Actor_MarkForDeath(&this->actor); } else { @@ -1187,7 +1187,7 @@ void func_80992E0C(EnWf* this, GlobalContext* globalCtx) { Vec3f sp60; if (this->unk_2A0 == 25) { - SoundSource_PlaySfxEachFrameAtFixedWorldPos(globalCtx, &this->actor.world.pos, 36, + SoundSource_PlaySfxEachFrameAtFixedWorldPos(play, &this->actor.world.pos, 36, NA_SE_EN_COMMON_EXTINCT_LEV - SFX_FLAG); } @@ -1197,7 +1197,7 @@ void func_80992E0C(EnWf* this, GlobalContext* globalCtx) { 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_809942F0, &D_809942F0, 100, 0, 2); + func_800B3030(play, &sp60, &D_809942F0, &D_809942F0, 100, 0, 2); } func_800B9010(&this->actor, NA_SE_EN_COMMON_EXTINCT_LEV - SFX_FLAG); @@ -1205,11 +1205,11 @@ 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; } -void func_80993018(EnWf* this, GlobalContext* globalCtx) { +void func_80993018(EnWf* this, PlayState* play) { SkelAnime_Update(&this->skelAnime); if ((this->actor.child != NULL) && (this->actor.child->update != NULL)) { if (func_80990EAC(this)) { @@ -1232,18 +1232,18 @@ 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; } -void func_80993194(EnWf* this, GlobalContext* globalCtx) { +void func_80993194(EnWf* this, PlayState* play) { s16 sp36; s16 sp34; s16 sp32; SkelAnime_Update(&this->skelAnime); - func_80990E4C(this, globalCtx); + func_80990E4C(this, play); if ((this->actor.child != NULL) && (this->actor.child->update != NULL)) { if (func_80990EAC(this)) { func_80990ED4(this); @@ -1277,18 +1277,18 @@ 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; } -void func_809933A0(EnWf* this, GlobalContext* globalCtx) { +void func_809933A0(EnWf* this, PlayState* play) { s16 sp2E; s16 sp2C; s16 phi_a1; SkelAnime_Update(&this->skelAnime); - func_80990E4C(this, globalCtx); + func_80990E4C(this, play); if ((this->actor.child != NULL) && (this->actor.child->update != NULL)) { if (func_80990EAC(this)) { func_80990ED4(this); @@ -1317,17 +1317,17 @@ 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; } -void func_8099357C(EnWf* this, GlobalContext* globalCtx) { +void func_8099357C(EnWf* this, PlayState* play) { s16 sp2E; SkelAnime_Update(&this->skelAnime); - func_80990E4C(this, globalCtx); + func_80990E4C(this, play); if (this->unk_295 != 0) { if ((this->actor.child != NULL) && (this->actor.child->update != NULL)) { sp2E = Actor_YawBetweenActors(&this->actor, this->actor.child); @@ -1369,7 +1369,7 @@ void func_8099357C(EnWf* this, GlobalContext* globalCtx) { } } -void func_80993738(EnWf* this, GlobalContext* globalCtx) { +void func_80993738(EnWf* this, PlayState* play) { if ((this->actionFunc == func_80991280) && (this->unk_298 != 0)) { this->unk_29E = Math_SinS(this->unk_298 * 4200) * 8920.0f; } else if ((this->actionFunc == func_80991C80) || (this->actionFunc == func_8099357C) || @@ -1381,7 +1381,7 @@ void func_80993738(EnWf* this, GlobalContext* globalCtx) { } } -void func_8099386C(EnWf* this, GlobalContext* globalCtx) { +void func_8099386C(EnWf* this, PlayState* play) { s32 pad; ColliderCylinder* collider; @@ -1415,10 +1415,10 @@ void func_8099386C(EnWf* this, GlobalContext* globalCtx) { (0x80000 | 0x40000 | 0x10000 | 0x8000 | 0x2000 | 0x1000 | 0x80 | 0x20 | 0x10 | 0x2 | 0x1))) && (this->actor.colChkInfo.damageEffect != 0xF)) { if (!Actor_ApplyDamage(&this->actor)) { - Enemy_StartFinishingBlow(globalCtx, &this->actor); + Enemy_StartFinishingBlow(play, &this->actor); } - func_80990854(this, globalCtx); + func_80990854(this, play); if (this->actor.colChkInfo.damageEffect == 1) { this->unk_2A0 = 40; @@ -1449,7 +1449,7 @@ void func_8099386C(EnWf* this, GlobalContext* globalCtx) { 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, + Actor_Spawn(&play->actorCtx, play, 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); } @@ -1465,7 +1465,7 @@ void func_8099386C(EnWf* this, GlobalContext* globalCtx) { } } -void EnWf_Update(Actor* thisx, GlobalContext* globalCtx) { +void EnWf_Update(Actor* thisx, PlayState* play) { s32 pad; EnWf* this = THIS; @@ -1475,16 +1475,16 @@ void EnWf_Update(Actor* thisx, GlobalContext* globalCtx) { this->unk_2A2--; } - func_8099386C(this, globalCtx); + func_8099386C(this, play); if (this->actionFunc != func_809923E4) { - func_809908E0(this); + EnWf_Blink(this); } - this->actionFunc(this, globalCtx); + this->actionFunc(this, play); Actor_MoveWithGravity(&this->actor); - Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 32.0f, 30.0f, 60.0f, 0x1D); - func_80993738(this, globalCtx); + Actor_UpdateBgCheckInfo(play, &this->actor, 32.0f, 30.0f, 60.0f, 0x1D); + func_80993738(this, play); if (this->actor.bgCheckFlags & (2 | 1)) { func_800BE3D0(&this->actor, this->actor.shape.rot.y, &this->actor.shape.rot); @@ -1494,22 +1494,22 @@ void EnWf_Update(Actor* thisx, GlobalContext* globalCtx) { } if (this->actionFunc != func_80990F50) { - CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider1.base); + CollisionCheck_SetOC(play, &play->colChkCtx, &this->collider1.base); } if (this->collider2.base.acFlags & AC_ON) { Collider_UpdateCylinder(&this->actor, &this->collider2); - CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->collider3.base); - CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->collider2.base); + CollisionCheck_SetAC(play, &play->colChkCtx, &this->collider3.base); + CollisionCheck_SetAC(play, &play->colChkCtx, &this->collider2.base); } if (this->actionFunc == func_809928CC) { - CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->collider1.base); + CollisionCheck_SetAC(play, &play->colChkCtx, &this->collider1.base); } if (this->collider1.base.atFlags & AT_ON) { if (!(this->collider1.base.atFlags & AT_BOUNCED)) { - CollisionCheck_SetAT(globalCtx, &globalCtx->colChkCtx, &this->collider1.base); + CollisionCheck_SetAT(play, &play->colChkCtx, &this->collider1.base); } else { func_80991FD8(this); } @@ -1532,16 +1532,16 @@ void EnWf_Update(Actor* thisx, GlobalContext* globalCtx) { } } -s32 EnWf_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, Actor* thisx) { +s32 EnWf_OverrideLimbDraw(PlayState* play, 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; } -void EnWf_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx) { +void EnWf_PostLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx) { static s8 D_809942FC[] = { -1, -1, -1, -1, -1, 0, 1, -1, -1, -1, -1, 2, -1, 3, 4, 5, 6, -1, -1, 7, 8, 9, }; @@ -1551,43 +1551,42 @@ void EnWf_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec Collider_UpdateSpheres(limbIndex, &this->collider1); if (D_809942FC[limbIndex] != -1) { - Matrix_GetStateTranslation(&this->limbPos[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; } } -void EnWf_Draw(Actor* thisx, GlobalContext* globalCtx) { +void EnWf_Draw(Actor* thisx, PlayState* play) { EnWf* this = THIS; if (this->actionFunc != func_80990F50) { - OPEN_DISPS(globalCtx->state.gfxCtx); + OPEN_DISPS(play->state.gfxCtx); - func_8012C28C(globalCtx->state.gfxCtx); + func_8012C28C(play->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); + CLOSE_DISPS(play->state.gfxCtx); - SkelAnime_DrawFlexOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, - this->skelAnime.dListCount, EnWf_OverrideLimbDraw, EnWf_PostLimbDraw, &this->actor); - Actor_DrawDamageEffects(globalCtx, &this->actor, this->limbPos, ARRAY_COUNT(this->limbPos), - this->drawDmgEffScale, this->drawDmgEffFrozenSteamScale, this->drawDmgEffAlpha, - this->drawDmgEffType); + SkelAnime_DrawFlexOpa(play, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, + EnWf_OverrideLimbDraw, EnWf_PostLimbDraw, &this->actor); + Actor_DrawDamageEffects(play, &this->actor, this->limbPos, ARRAY_COUNT(this->limbPos), this->drawDmgEffScale, + this->drawDmgEffFrozenSteamScale, this->drawDmgEffAlpha, this->drawDmgEffType); } } -s32 func_8099408C(GlobalContext* globalCtx, EnWf* this) { - Actor* temp_v0 = func_800BC270(globalCtx, &this->actor, 80.0f, 0x138B0); +s32 func_8099408C(PlayState* play, EnWf* this) { + Actor* temp_v0 = func_800BC270(play, &this->actor, 80.0f, 0x138B0); s16 temp_v1; if (temp_v0 != NULL) { 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 e697ef072..38570dd9e 100644 --- a/src/overlays/actors/ovl_En_Wf/z_en_wf.h +++ b/src/overlays/actors/ovl_En_Wf/z_en_wf.h @@ -2,38 +2,39 @@ #define Z_EN_WF_H #include "global.h" +#include "objects/object_wf/object_wf.h" struct EnWf; -typedef void (*EnWfActionFunc)(struct EnWf*, GlobalContext*); +typedef void (*EnWfActionFunc)(struct EnWf*, PlayState*); #define ENWF_GET_80(thisx) ((thisx)->params & 0x80) typedef struct EnWf { - /* 0x0000 */ Actor actor; - /* 0x0144 */ SkelAnime skelAnime; - /* 0x0188 */ Vec3s jointTable[22]; - /* 0x020C */ Vec3s morphTable[22]; - /* 0x0290 */ EnWfActionFunc actionFunc; - /* 0x0294 */ u8 unk_294; - /* 0x0295 */ u8 unk_295; - /* 0x0296 */ u8 drawDmgEffType; - /* 0x0298 */ s16 unk_298; - /* 0x029A */ s16 unk_29A; - /* 0x029C */ s16 unk_29C; - /* 0x029E */ s16 unk_29E; - /* 0x02A0 */ s16 unk_2A0; - /* 0x02A2 */ u16 unk_2A2; - /* 0x02A4 */ f32 unk_2A4; - /* 0x02A8 */ f32 unk_2A8; - /* 0x02AC */ f32 drawDmgEffAlpha; - /* 0x02B0 */ f32 drawDmgEffScale; - /* 0x02B4 */ f32 drawDmgEffFrozenSteamScale; - /* 0x02B8 */ Vec3f limbPos[10]; - /* 0x0330 */ ColliderJntSph collider1; - /* 0x0350 */ ColliderJntSphElement collider1Elements[4]; - /* 0x0450 */ ColliderCylinder collider2; - /* 0x049C */ ColliderCylinder collider3; + /* 0x000 */ Actor actor; + /* 0x144 */ SkelAnime skelAnime; + /* 0x188 */ Vec3s jointTable[WOLFOS_NORMAL_LIMB_MAX]; + /* 0x20C */ Vec3s morphTable[WOLFOS_NORMAL_LIMB_MAX]; + /* 0x290 */ EnWfActionFunc actionFunc; + /* 0x294 */ u8 eyeIndex; + /* 0x295 */ u8 unk_295; + /* 0x296 */ u8 drawDmgEffType; + /* 0x298 */ s16 unk_298; + /* 0x29A */ s16 unk_29A; + /* 0x29C */ s16 unk_29C; + /* 0x29E */ s16 unk_29E; + /* 0x2A0 */ s16 unk_2A0; + /* 0x2A2 */ u16 unk_2A2; + /* 0x2A4 */ f32 unk_2A4; + /* 0x2A8 */ f32 unk_2A8; + /* 0x2AC */ f32 drawDmgEffAlpha; + /* 0x2B0 */ f32 drawDmgEffScale; + /* 0x2B4 */ f32 drawDmgEffFrozenSteamScale; + /* 0x2B8 */ Vec3f limbPos[10]; + /* 0x330 */ ColliderJntSph collider1; + /* 0x350 */ ColliderJntSphElement collider1Elements[4]; + /* 0x450 */ ColliderCylinder collider2; + /* 0x49C */ ColliderCylinder collider3; } EnWf; // size = 0x4E8 extern const ActorInit En_Wf_InitVars; diff --git a/src/overlays/actors/ovl_En_Wiz/z_en_wiz.c b/src/overlays/actors/ovl_En_Wiz/z_en_wiz.c index 7279650e7..82cc5f2e2 100644 --- a/src/overlays/actors/ovl_En_Wiz/z_en_wiz.c +++ b/src/overlays/actors/ovl_En_Wiz/z_en_wiz.c @@ -12,10 +12,10 @@ #define THIS ((EnWiz*)thisx) -void EnWiz_Init(Actor* thisx, GlobalContext* globalCtx); -void EnWiz_Destroy(Actor* thisx, GlobalContext* globalCtx); -void EnWiz_Update(Actor* thisx, GlobalContext* globalCtx); -void EnWiz_Draw(Actor* thisx, GlobalContext* globalCtx); +void EnWiz_Init(Actor* thisx, PlayState* play); +void EnWiz_Destroy(Actor* thisx, PlayState* play); +void EnWiz_Update(Actor* thisx, PlayState* play); +void EnWiz_Draw(Actor* thisx, PlayState* play); #if 0 const ActorInit En_Wiz_InitVars = { @@ -77,7 +77,7 @@ static ColliderJntSphElementInit D_80A48B50[10] = { // static ColliderJntSphInit sJntSphInit = { static ColliderJntSphInit D_80A48CB8 = { { COLTYPE_HIT2, AT_NONE, AC_ON | AC_TYPE_PLAYER, OC1_NONE, OC2_TYPE_1, COLSHAPE_JNTSPH, }, - 10, D_80A48B50, // sJntSphElementsInit, + ARRAY_COUNT(sJntSphElementsInit), D_80A48B50, // sJntSphElementsInit, }; // static ColliderCylinderInit sCylinderInit = { diff --git a/src/overlays/actors/ovl_En_Wiz/z_en_wiz.h b/src/overlays/actors/ovl_En_Wiz/z_en_wiz.h index 1388260cf..a1ae32032 100644 --- a/src/overlays/actors/ovl_En_Wiz/z_en_wiz.h +++ b/src/overlays/actors/ovl_En_Wiz/z_en_wiz.h @@ -5,19 +5,19 @@ struct EnWiz; -typedef void (*EnWizActionFunc)(struct EnWiz*, GlobalContext*); +typedef void (*EnWizActionFunc)(struct EnWiz*, PlayState*); typedef struct EnWiz { - /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x268]; - /* 0x03AC */ EnWizActionFunc actionFunc; - /* 0x03B0 */ char unk_3B0[0xA]; - /* 0x03BA */ s16 unk_3BA; - /* 0x03BC */ char unk_3BC[0x8C]; - /* 0x0448 */ s32 unk_448; - /* 0x044C */ char unk_44C[0x2FE]; - /* 0x074A */ s16 unk_74A; - /* 0x074C */ char unk_74C[0x634]; + /* 0x000 */ Actor actor; + /* 0x144 */ char unk_144[0x268]; + /* 0x3AC */ EnWizActionFunc actionFunc; + /* 0x3B0 */ char unk_3B0[0xA]; + /* 0x3BA */ s16 unk_3BA; + /* 0x3BC */ char unk_3BC[0x8C]; + /* 0x448 */ s32 unk_448; + /* 0x44C */ char unk_44C[0x2FE]; + /* 0x74A */ s16 unk_74A; + /* 0x74C */ char unk_74C[0x634]; } EnWiz; // size = 0xD80 extern const ActorInit En_Wiz_InitVars; diff --git a/src/overlays/actors/ovl_En_Wiz_Brock/z_en_wiz_brock.c b/src/overlays/actors/ovl_En_Wiz_Brock/z_en_wiz_brock.c index d6ae08331..d49e71c08 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 (ACTOR_FLAG_10 | ACTOR_FLAG_8000000) #define THIS ((EnWizBrock*)thisx) -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); +typedef enum { + PLATFORM_TYPE_INACTIVE, + PLATFORM_TYPE_FIRE, + PLATFORM_TYPE_ICE, + PLATFORM_TYPE_MAX, +} PlatformType; + +void EnWizBrock_Init(Actor* thisx, PlayState* play); +void EnWizBrock_Destroy(Actor* thisx, PlayState* play); +void EnWizBrock_Update(Actor* thisx, PlayState* play); +void EnWizBrock_Draw(Actor* thisx, PlayState* play); + +void EnWizBrock_SetupUpdateStatus(EnWizBrock* this, PlayState* play); +void EnWizBrock_UpdateStatus(EnWizBrock* this, PlayState* play); + +s16 platformCount = 0; -#if 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, PlayState* play) { + 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(play, &play->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, PlayState* play) { + EnWizBrock* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Wiz_Brock/EnWizBrock_Destroy.s") + DynaPoly_DeleteBgActor(play, &play->colCtx.dyna, this->dyna.bgId); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Wiz_Brock/func_80A490E4.s") +void EnWizBrock_SetupUpdateStatus(EnWizBrock* this, PlayState* play) { + 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, PlayState* play) { + 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, PlayState* play) { + EnWizBrock* this = THIS; + + this->actionFunc(this, play); +} + +void EnWizBrock_Draw(Actor* thisx, PlayState* play) { + s32 pad; + EnWizBrock* this = THIS; + + func_8012C28C(play->state.gfxCtx); + func_8012C2DC(play->state.gfxCtx); + + OPEN_DISPS(play->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(play, 0, 1); + gDPPipeSync(POLY_OPA_DISP++); + gDPSetEnvColor(POLY_OPA_DISP++, 255, 255, 255, 255); + Gfx_DrawDListOpa(play, gWizzrobePlatform); + + } else { + Scene_SetRenderModeXlu(play, 1, 2); + gDPPipeSync(POLY_XLU_DISP++); + gDPSetEnvColor(POLY_XLU_DISP++, 255, 255, 255, (s16)this->alpha); + Gfx_DrawDListXlu(play, gWizzrobePlatform); + } + + CLOSE_DISPS(play->state.gfxCtx); + + if (this->platformType != PLATFORM_TYPE_INACTIVE) { + OPEN_DISPS(play->state.gfxCtx); + AnimatedMat_Draw(play, 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(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_XLU_DISP++, &gWizzrobePlatformCenter); + + CLOSE_DISPS(play->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..0f0150697 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 @@ -5,13 +5,17 @@ struct EnWizBrock; -typedef void (*EnWizBrockActionFunc)(struct EnWizBrock*, GlobalContext*); +typedef void (*EnWizBrockActionFunc)(struct EnWizBrock*, PlayState*); 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 80dd47feb..666a5156b 100644 --- a/src/overlays/actors/ovl_En_Wiz_Fire/z_en_wiz_fire.c +++ b/src/overlays/actors/ovl_En_Wiz_Fire/z_en_wiz_fire.c @@ -12,21 +12,21 @@ #define THIS ((EnWizFire*)thisx) -void EnWizFire_Init(Actor* thisx, GlobalContext* globalCtx); -void EnWizFire_Destroy(Actor* thisx, GlobalContext* globalCtx); -void EnWizFire_Update(Actor* thisx, GlobalContext* globalCtx); -void EnWizFire_Draw(Actor* thisx, GlobalContext* globalCtx); +void EnWizFire_Init(Actor* thisx, PlayState* play); +void EnWizFire_Destroy(Actor* thisx, PlayState* play); +void EnWizFire_Update(Actor* thisx, PlayState* play); +void EnWizFire_Draw(Actor* thisx, PlayState* play); -void func_80A4984C(EnWizFire* this, GlobalContext* globalCtx); -void func_80A49A44(EnWizFire* this, GlobalContext* globalCtx); -void func_80A49F38(EnWizFire* this, GlobalContext* globalCtx); -void func_80A49FD8(EnWizFire* this, GlobalContext* globalCtx); -void func_80A4A11C(EnWizFire* this, GlobalContext* globalCtx); -void func_80A4A608(EnWizFire* this, GlobalContext* globalCtx); -void func_80A4BAB4(Actor* thisx, GlobalContext* globalCtx); +void func_80A4984C(EnWizFire* this, PlayState* play); +void func_80A49A44(EnWizFire* this, PlayState* play); +void func_80A49F38(EnWizFire* this, PlayState* play); +void func_80A49FD8(EnWizFire* this, PlayState* play); +void func_80A4A11C(EnWizFire* this, PlayState* play); +void func_80A4A608(EnWizFire* this, PlayState* play); +void func_80A4BAB4(Actor* thisx, PlayState* play); void func_80A4BC74(EnWizFire* this, Vec3f* arg1, Vec3f* arg2); -void func_80A4BDDC(EnWizFire* this, GlobalContext* globalCtx); -void func_80A4BF78(EnWizFire* this, GlobalContext* globalCtx); +void func_80A4BDDC(EnWizFire* this, PlayState* play); +void func_80A4BF78(EnWizFire* this, PlayState* play); static s32 D_80A4C1C0 = 0; @@ -62,17 +62,17 @@ static ColliderCylinderInit sCylinderInit = { { 0, 0, 0, { 0, 0, 0 } }, }; -void EnWizFire_Init(Actor* thisx, GlobalContext* globalCtx) { +void EnWizFire_Init(Actor* thisx, PlayState* play) { EnWizFire* this = THIS; - Collider_InitAndSetCylinder(globalCtx, &this->collider, &this->actor, &sCylinderInit); + Collider_InitAndSetCylinder(play, &this->collider, &this->actor, &sCylinderInit); this->unk_162 = this->actor.params; this->actor.targetMode = 3; this->unk_172 = 10; this->unk_1FC = 255.0f; this->actor.flags &= ~ACTOR_FLAG_1; - if (!func_8012405C(globalCtx)) { + if (!Player_HasMirrorShieldEquipped(play)) { this->collider.info.toucher.dmgFlags = 0x20000000; } @@ -104,28 +104,28 @@ void EnWizFire_Init(Actor* thisx, GlobalContext* globalCtx) { } } -void EnWizFire_Destroy(Actor* thisx, GlobalContext* globalCtx) { +void EnWizFire_Destroy(Actor* thisx, PlayState* play) { EnWizFire* this = THIS; if (this->unk_162 == 0) { - 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]; + play->envCtx.lightSettings.fogColor[2] = 0; + play->envCtx.lightSettings.fogColor[1] = play->envCtx.lightSettings.fogColor[2]; + play->envCtx.lightSettings.fogColor[0] = play->envCtx.lightSettings.fogColor[2]; + play->envCtx.lightSettings.diffuseColor2[2] = play->envCtx.lightSettings.fogColor[2]; + play->envCtx.lightSettings.diffuseColor2[1] = play->envCtx.lightSettings.fogColor[2]; + play->envCtx.lightSettings.diffuseColor2[0] = play->envCtx.lightSettings.fogColor[2]; + play->envCtx.lightSettings.diffuseColor1[2] = play->envCtx.lightSettings.fogColor[2]; + play->envCtx.lightSettings.diffuseColor1[1] = play->envCtx.lightSettings.fogColor[2]; + play->envCtx.lightSettings.diffuseColor1[0] = play->envCtx.lightSettings.fogColor[2]; + play->envCtx.lightSettings.ambientColor[2] = play->envCtx.lightSettings.fogColor[2]; + play->envCtx.lightSettings.ambientColor[1] = play->envCtx.lightSettings.fogColor[2]; + play->envCtx.lightSettings.ambientColor[0] = play->envCtx.lightSettings.fogColor[2]; + play->envCtx.lightSettings.fogNear = play->envCtx.lightSettings.fogColor[2]; } - Collider_DestroyCylinder(globalCtx, &this->collider); + Collider_DestroyCylinder(play, &this->collider); } -void func_80A4984C(EnWizFire* this, GlobalContext* globalCtx) { +void func_80A4984C(EnWizFire* this, PlayState* play) { Vec3f sp44 = { 0.0f, 0.0f, 0.0f }; s32 i; @@ -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) { @@ -160,7 +160,7 @@ void func_80A4984C(EnWizFire* this, GlobalContext* globalCtx) { this->actionFunc = func_80A49A44; } -void func_80A49A44(EnWizFire* this, GlobalContext* globalCtx) { +void func_80A49A44(EnWizFire* this, PlayState* play) { Vec3f sp54 = { 0.0f, 0.0f, 0.0f }; this->actor.world.rot.z += 5000; @@ -202,17 +202,17 @@ 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; if (this->unk_164 == 0) { - Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_WIZ_FIRE, this->actor.world.pos.x, + Actor_Spawn(&play->actorCtx, play, ACTOR_EN_WIZ_FIRE, this->actor.world.pos.x, this->actor.world.pos.y - 10.0f, this->actor.world.pos.z, 0, 0, 0, 2); this->unk_164 = 1; } @@ -233,7 +233,7 @@ void func_80A49A44(EnWizFire* this, GlobalContext* globalCtx) { phi_s0 = 0; for (i = 0; i < 5; i++) { - Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_WIZ_FIRE, this->actor.world.pos.x, + Actor_Spawn(&play->actorCtx, play, ACTOR_EN_WIZ_FIRE, this->actor.world.pos.x, this->actor.world.pos.y, this->actor.world.pos.z, 0, phi_s0, 0, 1); phi_s0 += BINANG_ADD((s32)randPlusMinusPoint5Scaled(0x1000), 0x3333); } @@ -262,11 +262,11 @@ void func_80A49A44(EnWizFire* this, GlobalContext* globalCtx) { if (this->collider.info.acHitInfo->toucher.dmgFlags == 0x1000) { this->unk_168 = 0; this->unk_148 = 1; - SoundSource_PlaySfxAtFixedWorldPos(globalCtx, &this->actor.world.pos, 50, NA_SE_EV_ICE_MELT); + SoundSource_PlaySfxAtFixedWorldPos(play, &this->actor.world.pos, 50, NA_SE_EV_ICE_MELT); } } - if (func_8012405C(globalCtx) && (this->collider.base.atFlags & AT_BOUNCED)) { + if (Player_HasMirrorShieldEquipped(play) && (this->collider.base.atFlags & AT_BOUNCED)) { Actor_PlaySfxAtPos(&this->actor, NA_SE_IT_SHIELD_REFLECT_MG); this->collider.base.atFlags &= ~(AT_TYPE_ENEMY | AT_BOUNCED | AT_HIT); this->collider.base.atFlags |= AT_TYPE_PLAYER; @@ -286,7 +286,7 @@ void func_80A49A44(EnWizFire* this, GlobalContext* globalCtx) { } } -void func_80A49F38(EnWizFire* this, GlobalContext* globalCtx) { +void func_80A49F38(EnWizFire* this, PlayState* play) { this->unk_150 = 0.02f; this->unk_168 = Rand_S16Offset(50, 50); this->unk_154 = randPlusMinusPoint5Scaled(1.0f) * 0.007f; @@ -295,7 +295,7 @@ void func_80A49F38(EnWizFire* this, GlobalContext* globalCtx) { this->actionFunc = func_80A49FD8; } -void func_80A49FD8(EnWizFire* this, GlobalContext* globalCtx) { +void func_80A49FD8(EnWizFire* this, PlayState* play) { if (this->unk_168 > 10) { Math_ApproachF(&this->unk_14C, this->unk_150, 0.3f, 0.01f); } else { @@ -317,7 +317,7 @@ void func_80A49FD8(EnWizFire* this, GlobalContext* globalCtx) { if (this->collider.info.acHitInfo->toucher.dmgFlags == 0x1000) { this->unk_168 = 0; this->unk_148 = 1; - SoundSource_PlaySfxAtFixedWorldPos(globalCtx, &this->actor.world.pos, 50, NA_SE_EV_ICE_MELT); + SoundSource_PlaySfxAtFixedWorldPos(play, &this->actor.world.pos, 50, NA_SE_EV_ICE_MELT); } } } @@ -327,7 +327,7 @@ void func_80A49FD8(EnWizFire* this, GlobalContext* globalCtx) { } } -void func_80A4A11C(EnWizFire* this, GlobalContext* globalCtx) { +void func_80A4A11C(EnWizFire* this, PlayState* play) { s32 pad; if ((this->actor.parent != NULL) && (this->actor.parent->id == ACTOR_EN_WIZ) && @@ -382,7 +382,7 @@ void func_80A4A11C(EnWizFire* this, GlobalContext* globalCtx) { D_80A4C1C0 = 1; this->unk_148 = 1; this->unk_16A = 0; - SoundSource_PlaySfxAtFixedWorldPos(globalCtx, &this->actor.world.pos, 50, NA_SE_EV_ICE_MELT); + SoundSource_PlaySfxAtFixedWorldPos(play, &this->actor.world.pos, 50, NA_SE_EV_ICE_MELT); } } this->actor.world.pos.y = this->actor.floorHeight + 10.0f; @@ -434,7 +434,7 @@ void func_80A4A11C(EnWizFire* this, GlobalContext* globalCtx) { } } -void func_80A4A608(EnWizFire* this, GlobalContext* globalCtx) { +void func_80A4A608(EnWizFire* this, PlayState* play) { if (this->unk_16A == 0) { this->unk_16A = 2; this->unk_16E++; @@ -452,22 +452,22 @@ void func_80A4A608(EnWizFire* this, GlobalContext* globalCtx) { } } -void EnWizFire_Update(Actor* thisx, GlobalContext* globalCtx2) { +void EnWizFire_Update(Actor* thisx, PlayState* play2) { static Color_RGB8 D_80A4C234[] = { { 100, 40, 40 }, { 180, 0x78, 80 }, { 155, 80, 80 }, { 125, 20, 0 }, { 0, 0, 0 }, { 200, 250, 250 }, { 100, 250, 250 }, { 225, 255, 235 }, }; static Color_RGBA8 D_80A4C24C = { 250, 250, 250, 255 }; static Color_RGBA8 D_80A4C250 = { 180, 180, 180, 255 }; - GlobalContext* globalCtx = globalCtx2; + PlayState* play = play2; EnWizFire* this = THIS; - Player* player = GET_PLAYER(globalCtx); + Player* player = GET_PLAYER(play); s32 j; s16 temp_s0; s16 idx; Actor_SetScale(&this->actor, this->unk_14C); - func_80A4BDDC(this, globalCtx); + func_80A4BDDC(this, play); this->unk_204 = this->unk_200 / 60.0f; if (this->unk_162 == 0) { @@ -483,44 +483,44 @@ void EnWizFire_Update(Actor* thisx, GlobalContext* globalCtx2) { phi_f0 = 968.0f; } - globalCtx->envCtx.lightSettings.fogNear = (phi_f0 - (s16)globalCtx->envCtx.unk_C4.fogNear) * this->unk_204; + play->envCtx.lightSettings.fogNear = (phi_f0 - (s16)play->envCtx.unk_C4.fogNear) * this->unk_204; - globalCtx->envCtx.lightSettings.ambientColor[0] = - ((f32)D_80A4C234[idx].r - globalCtx->envCtx.unk_C4.ambientColor[0]) * this->unk_204; - globalCtx->envCtx.lightSettings.ambientColor[1] = - ((f32)D_80A4C234[idx].g - globalCtx->envCtx.unk_C4.ambientColor[1]) * this->unk_204; - globalCtx->envCtx.lightSettings.ambientColor[2] = - ((f32)D_80A4C234[idx].b - globalCtx->envCtx.unk_C4.ambientColor[2]) * this->unk_204; + play->envCtx.lightSettings.ambientColor[0] = + ((f32)D_80A4C234[idx].r - play->envCtx.unk_C4.ambientColor[0]) * this->unk_204; + play->envCtx.lightSettings.ambientColor[1] = + ((f32)D_80A4C234[idx].g - play->envCtx.unk_C4.ambientColor[1]) * this->unk_204; + play->envCtx.lightSettings.ambientColor[2] = + ((f32)D_80A4C234[idx].b - play->envCtx.unk_C4.ambientColor[2]) * this->unk_204; idx++; - globalCtx->envCtx.lightSettings.diffuseColor1[0] = - ((f32)D_80A4C234[idx].r - globalCtx->envCtx.unk_C4.diffuseColor1[0]) * this->unk_204; - globalCtx->envCtx.lightSettings.diffuseColor1[1] = - ((f32)D_80A4C234[idx].g - globalCtx->envCtx.unk_C4.diffuseColor1[1]) * this->unk_204; - globalCtx->envCtx.lightSettings.diffuseColor1[2] = - ((f32)D_80A4C234[idx].b - globalCtx->envCtx.unk_C4.diffuseColor1[2]) * this->unk_204; + play->envCtx.lightSettings.diffuseColor1[0] = + ((f32)D_80A4C234[idx].r - play->envCtx.unk_C4.diffuseColor1[0]) * this->unk_204; + play->envCtx.lightSettings.diffuseColor1[1] = + ((f32)D_80A4C234[idx].g - play->envCtx.unk_C4.diffuseColor1[1]) * this->unk_204; + play->envCtx.lightSettings.diffuseColor1[2] = + ((f32)D_80A4C234[idx].b - play->envCtx.unk_C4.diffuseColor1[2]) * this->unk_204; idx++; - globalCtx->envCtx.lightSettings.diffuseColor2[0] = - ((f32)D_80A4C234[idx].r - globalCtx->envCtx.unk_C4.diffuseColor[0]) * this->unk_204; - globalCtx->envCtx.lightSettings.diffuseColor2[1] = - ((f32)D_80A4C234[idx].g - globalCtx->envCtx.unk_C4.diffuseColor[1]) * this->unk_204; - globalCtx->envCtx.lightSettings.diffuseColor2[2] = - ((f32)D_80A4C234[idx].b - globalCtx->envCtx.unk_C4.diffuseColor[2]) * this->unk_204; + play->envCtx.lightSettings.diffuseColor2[0] = + ((f32)D_80A4C234[idx].r - play->envCtx.unk_C4.diffuseColor[0]) * this->unk_204; + play->envCtx.lightSettings.diffuseColor2[1] = + ((f32)D_80A4C234[idx].g - play->envCtx.unk_C4.diffuseColor[1]) * this->unk_204; + play->envCtx.lightSettings.diffuseColor2[2] = + ((f32)D_80A4C234[idx].b - play->envCtx.unk_C4.diffuseColor[2]) * this->unk_204; idx++; - globalCtx->envCtx.lightSettings.fogColor[0] = - ((f32)D_80A4C234[idx].r - globalCtx->envCtx.unk_C4.fogColor[0]) * this->unk_204; - globalCtx->envCtx.lightSettings.fogColor[1] = - ((f32)D_80A4C234[idx].g - globalCtx->envCtx.unk_C4.fogColor[1]) * this->unk_204; - globalCtx->envCtx.lightSettings.fogColor[2] = - ((f32)D_80A4C234[idx].b - globalCtx->envCtx.unk_C4.fogColor[2]) * this->unk_204; + play->envCtx.lightSettings.fogColor[0] = + ((f32)D_80A4C234[idx].r - play->envCtx.unk_C4.fogColor[0]) * this->unk_204; + play->envCtx.lightSettings.fogColor[1] = + ((f32)D_80A4C234[idx].g - play->envCtx.unk_C4.fogColor[1]) * this->unk_204; + play->envCtx.lightSettings.fogColor[2] = + ((f32)D_80A4C234[idx].b - play->envCtx.unk_C4.fogColor[2]) * this->unk_204; } } this->unk_170++; - this->actionFunc(this, globalCtx); + this->actionFunc(this, play); this->actor.shape.yOffset = 10.0f; Actor_UpdatePos(&this->actor); @@ -549,7 +549,7 @@ void EnWizFire_Update(Actor* thisx, GlobalContext* globalCtx2) { this->unk_16A--; } - Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 20.0f, 5.0f, 10, 0x1D); + Actor_UpdateBgCheckInfo(play, &this->actor, 20.0f, 5.0f, 10, 0x1D); if (((this->unk_148 != 0) || (D_80A4C1C0 != 0)) && (this->unk_16C == 0)) { Vec3f sp70; @@ -578,7 +578,7 @@ void EnWizFire_Update(Actor* thisx, GlobalContext* globalCtx2) { sp58.y = (Rand_ZeroOne() * 20.0f) + this->actor.floorHeight; temp_s0 = Rand_S16Offset(20, 20); sp58.z = ((f32)((Rand_ZeroOne() < .5f) ? -1 : 1) * temp_s0) + this->actor.world.pos.z; - func_800B0DE0(globalCtx, &sp58, &sp64, &sp70, &D_80A4C24C, &D_80A4C250, Rand_S16Offset(350, 100), sp54); + func_800B0DE0(play, &sp58, &sp64, &sp70, &D_80A4C24C, &D_80A4C250, Rand_S16Offset(350, 100), sp54); } } @@ -614,26 +614,25 @@ void EnWizFire_Update(Actor* thisx, GlobalContext* globalCtx2) { if ((this->unk_148 == 0) && (D_80A4C1C0 == 0) && ((this->unk_162 != 0) || (this->unk_1FC > 200.0f))) { Collider_UpdateCylinder(&this->actor, &this->collider); - CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + CollisionCheck_SetAC(play, &play->colChkCtx, &this->collider.base); if (player->invincibilityTimer == 0) { - CollisionCheck_SetAT(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + CollisionCheck_SetAT(play, &play->colChkCtx, &this->collider.base); } } } -void func_80A4B0C8(EnWizFire* this, GlobalContext* globalCtx) { +void func_80A4B0C8(EnWizFire* this, PlayState* play) { s32 pad; - OPEN_DISPS(globalCtx->state.gfxCtx); + OPEN_DISPS(play->state.gfxCtx); if ((this->unk_162 == 0) && (this->unk_160 == 2)) { - func_8012C28C(globalCtx->state.gfxCtx); - func_8012C2DC(globalCtx->state.gfxCtx); - Matrix_InsertTranslation(this->actor.world.pos.x, this->actor.floorHeight, this->actor.world.pos.z, - MTXMODE_NEW); + func_8012C28C(play->state.gfxCtx); + func_8012C2DC(play->state.gfxCtx); + 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); + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gDPPipeSync(POLY_XLU_DISP++); gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 255, 255, 255, (s8)this->unk_1FC); gDPSetEnvColor(POLY_XLU_DISP++, 0, 40, 30, 80); @@ -641,94 +640,89 @@ void func_80A4B0C8(EnWizFire* this, GlobalContext* globalCtx) { gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 215, 215, 215, (s8)this->unk_1FC); gDPSetEnvColor(POLY_XLU_DISP++, 255, 255, 255, 128); gSPSegment(POLY_XLU_DISP++, 0x08, - Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, -globalCtx->state.frames & 0x7F, - -globalCtx->state.frames & 0x7F, 0x20, 0x40, 1, globalCtx->state.frames & 0xFF, - globalCtx->state.frames & 0xFF, 0x10, 0x10)); + Gfx_TwoTexScroll(play->state.gfxCtx, 0, -play->state.frames & 0x7F, -play->state.frames & 0x7F, 0x20, + 0x40, 1, play->state.frames & 0xFF, play->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); + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_XLU_DISP++, object_wiz_DL_005750); } - func_80A4BF78(this, globalCtx); + func_80A4BF78(this, play); - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->state.gfxCtx); } -void func_80A4B33C(EnWizFire* this, GlobalContext* globalCtx2) { - GlobalContext* globalCtx = globalCtx2; +void func_80A4B33C(EnWizFire* this, PlayState* play2) { + PlayState* play = play2; - OPEN_DISPS(globalCtx->state.gfxCtx); + OPEN_DISPS(play->state.gfxCtx); if ((this->unk_162 == 0) && (this->unk_160 == 2)) { - func_8012C28C(globalCtx->state.gfxCtx); - func_8012C2DC(globalCtx->state.gfxCtx); - Matrix_StatePush(); - Matrix_InsertTranslation(this->actor.world.pos.x, this->actor.floorHeight, this->actor.world.pos.z, - MTXMODE_NEW); + func_8012C28C(play->state.gfxCtx); + func_8012C2DC(play->state.gfxCtx); + 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, - Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, -globalCtx->state.frames % 128, 0, 0x20, 0x20, 1, - (globalCtx->state.frames * 2) % 128, 0, 0x20, 0x20)); - gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + Gfx_TwoTexScroll(play->state.gfxCtx, 0, -play->state.frames % 128, 0, 0x20, 0x20, 1, + (play->state.frames * 2) % 128, 0, 0x20, 0x20)); + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gDPPipeSync(POLY_XLU_DISP++); gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 100, 40, 0, (s8)this->unk_1FC); gDPSetEnvColor(POLY_XLU_DISP++, 255, 245, 255, 128); gSPDisplayList(POLY_XLU_DISP++, object_wiz_DL_003120); - Matrix_StatePop(); - Matrix_StatePush(); - Matrix_InsertTranslation(this->actor.world.pos.x, this->actor.floorHeight, this->actor.world.pos.z, - MTXMODE_NEW); - Matrix_NormalizeXYZ(&globalCtx->billboardMtxF); + Matrix_Pop(); + Matrix_Push(); + Matrix_Translate(this->actor.world.pos.x, this->actor.floorHeight, this->actor.world.pos.z, MTXMODE_NEW); + Matrix_ReplaceRotation(&play->billboardMtxF); gSPSegment(POLY_XLU_DISP++, 0x08, - Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, globalCtx->state.frames % 128, - (-globalCtx->state.frames * 6) % 256, 0x20, 0x40, 1, - (globalCtx->state.frames * 2) % 128, (-globalCtx->state.frames * 6) % 256, 0x20, - 0x40)); + Gfx_TwoTexScroll(play->state.gfxCtx, 0, play->state.frames % 128, (-play->state.frames * 6) % 256, + 0x20, 0x40, 1, (play->state.frames * 2) % 128, (-play->state.frames * 6) % 256, + 0x20, 0x40)); gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 80, 0, 0, (s8)this->unk_1FC); gDPPipeSync(POLY_XLU_DISP++); gDPSetEnvColor(POLY_XLU_DISP++, 0, 0, 0, 100); Matrix_Scale(this->unk_1F8, this->unk_1F8, this->unk_1F8, MTXMODE_APPLY); - gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(play->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, - MTXMODE_NEW); - 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(&play->billboardMtxF); gSPSegment(POLY_XLU_DISP++, 0x08, - Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, (-globalCtx->state.frames * 3) % 128, 0, 0x20, 0x20, 1, - 0, (-globalCtx->state.frames * 10) % 256, 0x20, 0x40)); + Gfx_TwoTexScroll(play->state.gfxCtx, 0, (-play->state.frames * 3) % 128, 0, 0x20, 0x20, 1, 0, + (-play->state.frames * 10) % 256, 0x20, 0x40)); gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 100, 50, 0, 255); gDPPipeSync(POLY_XLU_DISP++); gDPSetEnvColor(POLY_XLU_DISP++, 200, 235, 240, 128); Matrix_Scale(this->unk_1F4, this->unk_1F4, this->unk_1F4, MTXMODE_APPLY); - gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_XLU_DISP++, object_wiz_DL_003FC0); } - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->state.gfxCtx); } -void EnWizFire_Draw(Actor* thisx, GlobalContext* globalCtx2) { - GlobalContext* globalCtx = globalCtx2; +void EnWizFire_Draw(Actor* thisx, PlayState* play2) { + PlayState* play = play2; EnWizFire* this = THIS; s32 i; - OPEN_DISPS(globalCtx->state.gfxCtx); + OPEN_DISPS(play->state.gfxCtx); - func_8012C28C(globalCtx->state.gfxCtx); - func_8012C2DC(globalCtx->state.gfxCtx); - Matrix_StatePush(); + func_8012C28C(play->state.gfxCtx); + func_8012C2DC(play->state.gfxCtx); + Matrix_Push(); for (i = 9; i >= this->unk_16E; i--) { f32 temp_f20 = this->actor.scale.x - (i * -0.0019f); @@ -742,52 +736,50 @@ 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(&play->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); + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_XLU_DISP++, object_wiz_DL_002B40); } } - Matrix_StatePop(); + Matrix_Pop(); - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->state.gfxCtx); if (this->unk_166 == 0) { - func_80A4B33C(this, globalCtx); + func_80A4B33C(this, play); } else { - func_80A4B0C8(this, globalCtx); + func_80A4B0C8(this, play); } } -void func_80A4BAB4(Actor* thisx, GlobalContext* globalCtx) { +void func_80A4BAB4(Actor* thisx, PlayState* play) { s32 pad; EnWizFire* this = THIS; - OPEN_DISPS(globalCtx->state.gfxCtx); + OPEN_DISPS(play->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); gSPSegment(POLY_XLU_DISP++, 0x08, - Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, 0, 0, 0x20, 0x20, 1, this->unk_170 & 0x7F, + Gfx_TwoTexScroll(play->state.gfxCtx, 0, 0, 0, 0x20, 0x20, 1, this->unk_170 & 0x7F, (-this->unk_170 * 10) & 0x7F, 0x20, 0x20)); gDPSetPrimColor(POLY_XLU_DISP++, 0, 0x80, 100, 50, 0, (s8)this->unk_1FC); gDPSetEnvColor(POLY_XLU_DISP++, 200, 235, 245, 255); - Matrix_InsertMatrix(&globalCtx->billboardMtxF, MTXMODE_APPLY); + Matrix_Mult(&play->billboardMtxF, MTXMODE_APPLY); - gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_XLU_DISP++, object_wiz_DL_002630); - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->state.gfxCtx); } void func_80A4BC74(EnWizFire* this, Vec3f* arg1, Vec3f* arg2) { @@ -809,7 +801,7 @@ void func_80A4BC74(EnWizFire* this, Vec3f* arg1, Vec3f* arg2) { } } -void func_80A4BDDC(EnWizFire* this, GlobalContext* globalCtx) { +void func_80A4BDDC(EnWizFire* this, PlayState* play) { s32 i; EnWizFireStruct* ptr = &this->unk_254[0]; @@ -841,16 +833,16 @@ void func_80A4BDDC(EnWizFire* this, GlobalContext* globalCtx) { } } -void func_80A4BF78(EnWizFire* this, GlobalContext* globalCtx) { +void func_80A4BF78(EnWizFire* this, PlayState* play) { s16 i; u8 flag; EnWizFireStruct* ptr = &this->unk_254[0]; - GraphicsContext* gfxCtx = globalCtx->state.gfxCtx; + GraphicsContext* gfxCtx = play->state.gfxCtx; OPEN_DISPS(gfxCtx); - func_8012C28C(globalCtx->state.gfxCtx); - func_8012C2DC(globalCtx->state.gfxCtx); + func_8012C28C(play->state.gfxCtx); + func_8012C2DC(play->state.gfxCtx); flag = false; for (i = 0; i < ARRAY_COUNT(this->unk_254); i++, ptr++) { @@ -862,11 +854,11 @@ void func_80A4BF78(EnWizFire* this, GlobalContext* globalCtx) { gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 195, 225, 235, ptr->unk_06); gSPSegment(POLY_XLU_DISP++, 0x08, - Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, (ptr->unk_01 * 3) & 0x7F, - (ptr->unk_01 * 0xF) & 0xFF, 0x20, 0x40, 1, 0, 0, 0x20, 0x20)); + Gfx_TwoTexScroll(play->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(&play->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_Wiz_Fire/z_en_wiz_fire.h b/src/overlays/actors/ovl_En_Wiz_Fire/z_en_wiz_fire.h index df396da97..b628404bb 100644 --- a/src/overlays/actors/ovl_En_Wiz_Fire/z_en_wiz_fire.h +++ b/src/overlays/actors/ovl_En_Wiz_Fire/z_en_wiz_fire.h @@ -5,7 +5,7 @@ struct EnWizFire; -typedef void (*EnWizFireActionFunc)(struct EnWizFire*, GlobalContext*); +typedef void (*EnWizFireActionFunc)(struct EnWizFire*, PlayState*); typedef struct { /* 0x00 */ u8 unk_00; 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 446d92cbd..3098b9a6a 100644 --- a/src/overlays/actors/ovl_En_Wood02/z_en_wood02.c +++ b/src/overlays/actors/ovl_En_Wood02/z_en_wood02.c @@ -11,10 +11,10 @@ #define THIS ((EnWood02*)thisx) -void EnWood02_Init(Actor* thisx, GlobalContext* globalCtx); -void EnWood02_Destroy(Actor* thisx, GlobalContext* globalCtx); -void EnWood02_Update(Actor* thisx, GlobalContext* globalCtx); -void EnWood02_Draw(Actor* thisx, GlobalContext* globalCtx); +void EnWood02_Init(Actor* thisx, PlayState* play); +void EnWood02_Destroy(Actor* thisx, PlayState* play); +void EnWood02_Update(Actor* thisx, PlayState* play); +void EnWood02_Draw(Actor* thisx, PlayState* play); /** * WOOD_SPAWN_SPAWNER is also used by some individual trees: EnWood02_Update also checks for parent before running any @@ -98,11 +98,10 @@ Gfx* D_808C4D70[] = { object_wood02_DL_000700, }; -s32 EnWood02_SpawnZoneCheck(EnWood02* this, GlobalContext* globalCtx, Vec3f* arg2) { +s32 EnWood02_SpawnZoneCheck(EnWood02* this, PlayState* play, Vec3f* arg2) { f32 phi_f12; - SkinMatrix_Vec3fMtxFMultXYZW(&globalCtx->viewProjectionMtxF, arg2, &this->actor.projectedPos, - &this->actor.projectedW); + SkinMatrix_Vec3fMtxFMultXYZW(&play->viewProjectionMtxF, arg2, &this->actor.projectedPos, &this->actor.projectedW); if (this->actor.projectedW == 0.0f) { phi_f12 = 1000.0f; @@ -122,7 +121,7 @@ s32 EnWood02_SpawnZoneCheck(EnWood02* this, GlobalContext* globalCtx, Vec3f* arg /** 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) { +void EnWood02_SpawnOffspring(EnWood02* this, PlayState* play) { EnWood02* child; s32 extraRot; Vec3f childPos; @@ -144,7 +143,7 @@ void EnWood02_SpawnOffspring(EnWood02* this, GlobalContext* globalCtx) { childPos.y = this->actor.home.pos.y; childPos.z = (sSpawnDistance[i] * sSpawnCos) + this->actor.home.pos.z; - if (EnWood02_SpawnZoneCheck(this, globalCtx, &childPos)) { + if (EnWood02_SpawnZoneCheck(this, play, &childPos)) { if (this->unk_14A[i] & 0x80) { unk = 0; } else { @@ -152,9 +151,9 @@ void EnWood02_SpawnOffspring(EnWood02* this, GlobalContext* globalCtx) { } 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); + child = (EnWood02*)Actor_SpawnAsChild(&play->actorCtx, &this->actor, play, ACTOR_EN_WOOD02, childPos.x, + childPos.y, childPos.z, this->actor.world.rot.x, sSpawnAngle[i], + unk, childParams); if (child != NULL) { child->unk_14A[0] = i; this->unk_14A[i] |= 1; @@ -167,7 +166,7 @@ void EnWood02_SpawnOffspring(EnWood02* this, GlobalContext* globalCtx) { } } -void EnWood02_Init(Actor* thisx, GlobalContext* globalCtx) { +void EnWood02_Init(Actor* thisx, PlayState* play) { s16 spawnType = 0; f32 actorScale = 1.0f; EnWood02* this = THIS; @@ -192,14 +191,14 @@ void EnWood02_Init(Actor* thisx, GlobalContext* globalCtx) { 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); + Collider_InitCylinder(play, &this->collider); + Collider_SetCylinder(play, &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)) { + !Flags_GetCollectible(play, this->unk_144)) { this->actor.child = - Actor_SpawnAsChild(&globalCtx->actorCtx, &this->actor, globalCtx, ACTOR_EN_ANI, this->actor.world.pos.x, + Actor_SpawnAsChild(&play->actorCtx, &this->actor, play, ACTOR_EN_ANI, this->actor.world.pos.x, this->actor.world.pos.y + 120.0f, this->actor.world.pos.z - 15.0f, 0, 0, 0, 1); if (this->actor.child != NULL) { this->actor.child->cutscene = this->actor.cutscene; @@ -296,7 +295,7 @@ void EnWood02_Init(Actor* thisx, GlobalContext* globalCtx) { } if (spawnType == WOOD_SPAWN_SPAWNER) { - EnWood02_SpawnOffspring(this, globalCtx); + EnWood02_SpawnOffspring(this, play); sSpawnCos = Math_CosS(sSpawnAngle[5] + this->actor.world.rot.y + extraRot); sSpawnSin = Math_SinS(sSpawnAngle[5] + this->actor.world.rot.y + extraRot); this->actor.world.pos.x += sSpawnSin * sSpawnDistance[5]; @@ -308,7 +307,7 @@ void EnWood02_Init(Actor* thisx, GlobalContext* globalCtx) { // 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); + floorY = BgCheck_EntityRaycastFloor5(&play->colCtx, &outPoly, &bgId, &this->actor, &this->actor.world.pos); if (floorY > BGCHECK_Y_MIN) { this->actor.world.pos.y = floorY; @@ -323,33 +322,33 @@ void EnWood02_Init(Actor* thisx, GlobalContext* globalCtx) { this->actor.colChkInfo.mass = MASS_IMMOVABLE; } -void EnWood02_Destroy(Actor* thisx, GlobalContext* globalCtx) { +void EnWood02_Destroy(Actor* thisx, PlayState* play) { EnWood02* this = THIS; if ((this->actor.params < WOOD_BUSH_GREEN_SMALL) || (this->actor.params == WOOD_TREE_SPECIAL)) { - Collider_DestroyCylinder(globalCtx, &this->collider); + Collider_DestroyCylinder(play, &this->collider); } } -void func_808C4458(EnWood02* this, GlobalContext* globalCtx, Vec3f* arg2, u16 arg3) { +void func_808C4458(EnWood02* this, PlayState* play, 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_144 == -1) || !Flags_GetCollectible(play, 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); + Item_DropCollectibleRandom(play, &this->actor, arg2, ((-1 - this->unk_148) * 0x10) | 0x8000); } else { - Item_DropCollectibleRandom(globalCtx, &this->actor, arg2, (-1 - this->unk_148) * 0x10); + Item_DropCollectibleRandom(play, &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); + Item_DropCollectible(play, arg2, sp24); } else { - Item_DropCollectible(globalCtx, arg2, ((this->unk_144 & 0x7F) << 8) | sp24); + Item_DropCollectible(play, arg2, ((this->unk_144 & 0x7F) << 8) | sp24); } } } @@ -358,8 +357,8 @@ void func_808C4458(EnWood02* this, GlobalContext* globalCtx, Vec3f* arg2, u16 ar } } -void EnWood02_Update(Actor* thisx, GlobalContext* globalCtx2) { - GlobalContext* globalCtx = globalCtx2; +void EnWood02_Update(Actor* thisx, PlayState* play2) { + PlayState* play = play2; EnWood02* this = THIS; f32 wobbleAmplitude; @@ -380,7 +379,7 @@ void EnWood02_Update(Actor* thisx, GlobalContext* globalCtx2) { } this->unk_151 = 0; } else if (this->spawnType == WOOD_SPAWN_SPAWNER) { - EnWood02_SpawnOffspring(this, globalCtx); + EnWood02_SpawnOffspring(this, play); } if ((thisx->params < WOOD_BUSH_GREEN_SMALL) || (thisx->params == WOOD_TREE_SPECIAL)) { @@ -394,7 +393,7 @@ void EnWood02_Update(Actor* thisx, GlobalContext* globalCtx2) { dropsSpawnPt.y += 200.0f; - func_808C4458(this, globalCtx, &dropsSpawnPt, 0); + func_808C4458(this, play, &dropsSpawnPt, 0); // Spawn falling leaves if (this->unk_146 >= -1) { @@ -408,8 +407,8 @@ void EnWood02_Update(Actor* thisx, GlobalContext* globalCtx2) { 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); + Actor_Spawn(&play->actorCtx, play, ACTOR_EN_WOOD02, dropsSpawnPt.x, dropsSpawnPt.y, dropsSpawnPt.z, + 0, randPlusMinusPoint5Scaled(0xFFFF), 0, leavesParams); } } @@ -419,7 +418,7 @@ void EnWood02_Update(Actor* thisx, GlobalContext* globalCtx2) { } if ((thisx->params == WOOD_TREE_SPECIAL) && (this->unk_144 != -1)) { - Flags_SetCollectible(globalCtx, this->unk_144); + Flags_SetCollectible(play, this->unk_144); this->unk_144 = -1; } this->unk_146 = -0x15; @@ -428,17 +427,17 @@ void EnWood02_Update(Actor* thisx, GlobalContext* globalCtx2) { 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); + CollisionCheck_SetAC(play, &play->colChkCtx, &this->collider.base); + CollisionCheck_SetOC(play, &play->colChkCtx, &this->collider.base); } } else if ((thisx->params < WOOD_LEAF_GREEN) || (thisx->params == WOOD_TREE_SPECIAL)) { // not leaves - Player* player = GET_PLAYER(globalCtx); + Player* player = GET_PLAYER(play); 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); + func_808C4458(this, play, &thisx->world.pos, 1); this->unk_146 = -0x15; Actor_PlaySfxAtPos(thisx, NA_SE_EV_TREE_SWING); } @@ -463,24 +462,22 @@ void EnWood02_Update(Actor* thisx, GlobalContext* globalCtx2) { } } -void EnWood02_Draw(Actor* thisx, GlobalContext* globalCtx) { - GraphicsContext* gfxCtx = globalCtx->state.gfxCtx; - s16 type; - s16 pad; +void EnWood02_Draw(Actor* thisx, PlayState* play) { + EnWood02* this = THIS; + GraphicsContext* gfxCtx = play->state.gfxCtx; u8 red; u8 green; u8 blue; OPEN_DISPS(gfxCtx); - type = thisx->params; - if ((type == WOOD_TREE_OVAL_GREEN_SPAWNER) || (type == WOOD_TREE_OVAL_GREEN_SPAWNED) || - (type == WOOD_TREE_OVAL_GREEN) || (type == WOOD_LEAF_GREEN)) { + if ((thisx->params == WOOD_TREE_OVAL_GREEN_SPAWNER) || (thisx->params == WOOD_TREE_OVAL_GREEN_SPAWNED) || + (thisx->params == WOOD_TREE_OVAL_GREEN) || (thisx->params == WOOD_LEAF_GREEN)) { red = 50; green = 170; blue = 70; - } else if ((type == WOOD_TREE_OVAL_YELLOW_SPAWNER) || (type == WOOD_TREE_OVAL_YELLOW_SPAWNED) || - (type == WOOD_LEAF_YELLOW)) { + } else if ((thisx->params == WOOD_TREE_OVAL_YELLOW_SPAWNER) || (thisx->params == WOOD_TREE_OVAL_YELLOW_SPAWNED) || + (thisx->params == WOOD_LEAF_YELLOW)) { red = 180; green = 155; blue = 0; @@ -495,18 +492,18 @@ void EnWood02_Draw(Actor* thisx, GlobalContext* globalCtx) { 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]); + Gfx_DrawDListOpa(play, object_wood02_DL_000700); + } else if (D_808C4D70[this->drawType & 0xF] != NULL) { + Gfx_DrawDListOpa(play, D_808C4D54[this->drawType & 0xF]); gDPSetEnvColor(POLY_XLU_DISP++, red, green, blue, 0); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - gSPDisplayList(POLY_XLU_DISP++, D_808C4D70[THIS->drawType & 0xF]); + gSPDisplayList(POLY_XLU_DISP++, D_808C4D70[this->drawType & 0xF]); } else { func_8012C2DC(gfxCtx); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - gSPDisplayList(POLY_XLU_DISP++, D_808C4D54[THIS->drawType & 0xF]); + gSPDisplayList(POLY_XLU_DISP++, D_808C4D54[this->drawType & 0xF]); } CLOSE_DISPS(gfxCtx); diff --git a/src/overlays/actors/ovl_En_Yb/z_en_yb.c b/src/overlays/actors/ovl_En_Yb/z_en_yb.c index 25cf4c473..d28a06fa0 100644 --- a/src/overlays/actors/ovl_En_Yb/z_en_yb.c +++ b/src/overlays/actors/ovl_En_Yb/z_en_yb.c @@ -11,26 +11,26 @@ #define THIS ((EnYb*)thisx) -void EnYb_Init(Actor* thisx, GlobalContext* globalCtx); -void EnYb_Destroy(Actor* thisx, GlobalContext* globalCtx); -void EnYb_Update(Actor* thisx, GlobalContext* globalCtx); -void EnYb_Draw(Actor* thisx, GlobalContext* globalCtx); +void EnYb_Init(Actor* thisx, PlayState* play); +void EnYb_Destroy(Actor* thisx, PlayState* play); +void EnYb_Update(Actor* thisx, PlayState* play); +void EnYb_Draw(Actor* thisx, PlayState* play); -void EnYb_Idle(EnYb* this, GlobalContext* globalCtx); -void EnYb_TeachingDanceFinish(EnYb* this, GlobalContext* globalCtx); -void EnYb_SetupLeaving(EnYb* this, GlobalContext* globalCtx); +void EnYb_Idle(EnYb* this, PlayState* play); +void EnYb_TeachingDanceFinish(EnYb* this, PlayState* play); +void EnYb_SetupLeaving(EnYb* this, PlayState* play); -void EnYb_UpdateAnimation(EnYb* this, GlobalContext* globalCtx); +void EnYb_UpdateAnimation(EnYb* this, PlayState* play); 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_Disappear(EnYb* this, PlayState* play); +void EnYb_ReceiveMask(EnYb* this, PlayState* play); +void EnYb_Talk(EnYb* this, PlayState* play); +void EnYb_TeachingDance(EnYb* this, PlayState* play); +void EnYb_WaitForMidnight(EnYb* this, PlayState* play); -void EnYb_ActorShadowFunc(Actor* thisx, Lights* mapper, GlobalContext* globalCtx); -void EnYb_SetAnimation(GlobalContext*, EnYb*, s16, u8, f32); -s32 EnYb_CanTalk(EnYb* this, GlobalContext* globalCtx); +void EnYb_ActorShadowFunc(Actor* thisx, Lights* mapper, PlayState* play); +void EnYb_ChangeAnim(PlayState* play, EnYb* this, s16 animIndex, u8 animMode, f32 morphFrames); +s32 EnYb_CanTalk(EnYb* this, PlayState* play); const ActorInit En_Yb_InitVars = { ACTOR_EN_YB, @@ -76,7 +76,7 @@ static Vec3f D_80BFB2F4 = { 500.0f, -500.0, 0.0f }; static Vec3f D_80BFB300 = { 500.0f, -500.0f, 0.0f }; -void EnYb_Init(Actor* thisx, GlobalContext* globalCtx) { +void EnYb_Init(Actor* thisx, PlayState* play) { EnYb* this = THIS; s16 tempCutscene; s32 i; @@ -85,19 +85,19 @@ void EnYb_Init(Actor* thisx, GlobalContext* globalCtx) { ActorShape_Init(&this->actor.shape, 0.0f, EnYb_ActorShadowFunc, 20.0f); // @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); + SkelAnime_InitFlex(play, &this->skelAnime, &gYbSkeleton, &object_yb_Anim_000200, (uintptr_t)this->jointTable & ~0xF, + (uintptr_t)this->morphTable & ~0xF, YB_LIMB_MAX); Animation_PlayLoop(&this->skelAnime, &object_yb_Anim_000200); - Collider_InitAndSetCylinder(globalCtx, &this->collider, &this->actor, &sCylinderInit); + Collider_InitAndSetCylinder(play, &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->animIndex = 3; // gets overwritten to 2 in EnYb_ChangeAnim later this->actor.terminalVelocity = -9.0f; this->actor.gravity = -1.0f; - EnYb_SetAnimation(globalCtx, this, 2, ANIMMODE_LOOP, 0.0f); + EnYb_ChangeAnim(play, this, 2, ANIMMODE_LOOP, 0.0f); tempCutscene = this->actor.cutscene; for (i = 0; i < ARRAY_COUNT(this->cutscenes); i++) { @@ -126,34 +126,34 @@ void EnYb_Init(Actor* thisx, GlobalContext* globalCtx) { } } -void EnYb_Destroy(Actor* thisx, GlobalContext* globalCtx) { +void EnYb_Destroy(Actor* thisx, PlayState* play) { EnYb* this = THIS; - Collider_DestroyCylinder(globalCtx, &this->collider); + Collider_DestroyCylinder(play, &this->collider); } -void func_80BFA2FC(GlobalContext* globalCtx) { +void func_80BFA2FC(PlayState* play) { if (INV_CONTENT(ITEM_MASK_KAMARO) == ITEM_MASK_KAMARO) { - func_80151BB4(globalCtx, 0x34); + func_80151BB4(play, 0x34); } - func_80151BB4(globalCtx, 0xF); + func_80151BB4(play, 0xF); } /** * Custom shadow draw function of type ActorShadowFunc. */ -void EnYb_ActorShadowFunc(Actor* thisx, Lights* mapper, GlobalContext* globalCtx) { +void EnYb_ActorShadowFunc(Actor* thisx, Lights* mapper, PlayState* play) { Vec3f oldPos; EnYb* this = THIS; if (this->alpha > 0) { - if (this->currentAnimIndex == 2) { + if (this->animIndex == 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); + func_800B4AEC(play, &this->actor, 50.0f); if (oldPos.y < this->actor.floorHeight) { this->actor.world.pos.y = this->actor.floorHeight; @@ -161,25 +161,25 @@ void EnYb_ActorShadowFunc(Actor* thisx, Lights* mapper, GlobalContext* globalCtx this->actor.world.pos.y = oldPos.y; } - ActorShadow_DrawCircle(&this->actor, mapper, globalCtx); + ActorShadow_DrawCircle(&this->actor, mapper, play); Math_Vec3f_Copy(&this->actor.world.pos, &oldPos); this->actor.scale.x = 0.01f; } } -void EnYb_SetAnimation(GlobalContext* globalCtx, EnYb* this, s16 animIndex, u8 animMode, f32 transitionRate) { +void EnYb_ChangeAnim(PlayState* play, EnYb* this, s16 animIndex, u8 animMode, f32 morphFrames) { if (animIndex >= 0 && animIndex < 3) { - if (animIndex != this->currentAnimIndex || animMode != ANIMMODE_LOOP) { + if (animIndex != this->animIndex || animMode != ANIMMODE_LOOP) { if (animIndex > 0) { if (animMode == ANIMMODE_LOOP) { - LinkAnimation_Change(globalCtx, &this->skelAnime, gLinkAnimations[animIndex - 1], 1.0f, 0.0f, + LinkAnimation_Change(play, &this->skelAnime, gLinkAnimations[animIndex - 1], 1.0f, 0.0f, Animation_GetLastFrame(gLinkAnimations[animIndex - 1]), ANIMMODE_LOOP, - transitionRate); + morphFrames); } else { // unused case, (only called once with animMode = ANIMMODE_LOOP) - LinkAnimation_Change(globalCtx, &this->skelAnime, gLinkAnimations[animIndex - 1], 1.0f, 0.0f, + LinkAnimation_Change(play, &this->skelAnime, gLinkAnimations[animIndex - 1], 1.0f, 0.0f, Animation_GetLastFrame(gLinkAnimations[animIndex - 1]), ANIMMODE_LOOP, - transitionRate); + morphFrames); } } else { // unused case, (only called once with animIndex = 2) @@ -188,15 +188,15 @@ void EnYb_SetAnimation(GlobalContext* globalCtx, EnYb* this, s16 animIndex, u8 a if (1) {} Animation_Change(&this->skelAnime, gYbUnusedAnimations[animIndex], 1.0f, 0.0f, - Animation_GetLastFrame(animationPtr), animMode, transitionRate); + Animation_GetLastFrame(animationPtr), animMode, morphFrames); } - this->currentAnimIndex = animIndex; + this->animIndex = animIndex; } } } -s32 EnYb_CanTalk(EnYb* this, GlobalContext* globalCtx) { - if (this->actor.xzDistToPlayer < 100.0f && Player_IsFacingActor(&this->actor, 0x3000, globalCtx) && +s32 EnYb_CanTalk(EnYb* this, PlayState* play) { + if (this->actor.xzDistToPlayer < 100.0f && Player_IsFacingActor(&this->actor, 0x3000, play) && Actor_IsFacingPlayer(&this->actor, 0x3000)) { return true; } else { @@ -204,11 +204,11 @@ s32 EnYb_CanTalk(EnYb* this, GlobalContext* globalCtx) { } } -void EnYb_UpdateAnimation(EnYb* this, GlobalContext* globalCtx) { - if (this->currentAnimIndex <= 0) { +void EnYb_UpdateAnimation(EnYb* this, PlayState* play) { + if (this->animIndex <= 0) { SkelAnime_Update(&this->skelAnime); } else { - LinkAnimation_Update(globalCtx, &this->skelAnime); + LinkAnimation_Update(play, &this->skelAnime); } } @@ -233,20 +233,20 @@ void EnYb_EnableProximityMusic(EnYb* this) { func_800B9084(&this->actor); } -void EnYb_Disappear(EnYb* this, GlobalContext* globalCtx) { +void EnYb_Disappear(EnYb* this, PlayState* play) { s32 pad; Vec3f sp60; s32 i; - EnYb_UpdateAnimation(this, globalCtx); + EnYb_UpdateAnimation(this, play); 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); + func_800B3030(play, &sp60, &D_80BFB2E8, &D_80BFB2E8, 100, 0, 2); } - SoundSource_PlaySfxAtFixedWorldPos(globalCtx, &this->actor.world.pos, 20, NA_SE_EN_EXTINCT); + SoundSource_PlaySfxAtFixedWorldPos(play, &this->actor.world.pos, 20, NA_SE_EN_EXTINCT); if (this->alpha > 10) { this->alpha -= 10; } else { @@ -254,63 +254,63 @@ void EnYb_Disappear(EnYb* this, GlobalContext* globalCtx) { } } -void EnYb_SetupLeaving(EnYb* this, GlobalContext* globalCtx) { - EnYb_UpdateAnimation(this, globalCtx); - if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { +void EnYb_SetupLeaving(EnYb* this, PlayState* play) { + EnYb_UpdateAnimation(this, play); + if (Actor_ProcessTalkRequest(&this->actor, &play->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); + Message_StartTextbox(play, 0x147D, &this->actor); + func_80BFA2FC(play); } else { - func_800B8500(&this->actor, globalCtx, 1000.0f, 1000.0f, -1); + func_800B8500(&this->actor, play, 1000.0f, 1000.0f, PLAYER_AP_MINUS1); } EnYb_EnableProximityMusic(this); } -void EnYb_ReceiveMask(EnYb* this, GlobalContext* globalCtx) { - EnYb_UpdateAnimation(this, globalCtx); +void EnYb_ReceiveMask(EnYb* this, PlayState* play) { + EnYb_UpdateAnimation(this, play); // Player is parent: receiving the Kamaro mask - if (Actor_HasParent(&this->actor, globalCtx)) { + if (Actor_HasParent(&this->actor, play)) { this->actor.parent = NULL; this->actionFunc = EnYb_SetupLeaving; this->actor.flags |= ACTOR_FLAG_10000; - func_800B8500(&this->actor, globalCtx, 1000.0f, 1000.0f, -1); + func_800B8500(&this->actor, play, 1000.0f, 1000.0f, PLAYER_AP_MINUS1); } else { - Actor_PickUp(&this->actor, globalCtx, GI_MASK_KAMARO, 10000.0f, 100.0f); + Actor_PickUp(&this->actor, play, GI_MASK_KAMARO, 10000.0f, 100.0f); } EnYb_EnableProximityMusic(this); } -void EnYb_Talk(EnYb* this, GlobalContext* globalCtx) { +void EnYb_Talk(EnYb* this, PlayState* play) { Math_SmoothStepToS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer, 2, 0x1000, 0x200); this->actor.world.rot.y = this->actor.shape.rot.y; - EnYb_UpdateAnimation(this, globalCtx); + EnYb_UpdateAnimation(this, play); - if (Message_GetState(&globalCtx->msgCtx) == 5 && Message_ShouldAdvance(globalCtx) != 0) { - switch (globalCtx->msgCtx.currentTextId) { + if ((Message_GetState(&play->msgCtx) == TEXT_STATE_5) && Message_ShouldAdvance(play)) { + switch (play->msgCtx.currentTextId) { case 0x147D: // I am counting on you - func_801477B4(globalCtx); + func_801477B4(play); 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); + if (Player_GetMask(play) == PLAYER_MASK_KAMARO) { + func_801477B4(play); 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); + func_80151938(play, 0x147D); // I am counting on you + func_80BFA2FC(play); } else { - func_801477B4(globalCtx); + func_801477B4(play); this->actionFunc = EnYb_ReceiveMask; - EnYb_ReceiveMask(this, globalCtx); + EnYb_ReceiveMask(this, play); } break; default: - func_801477B4(globalCtx); + func_801477B4(play); this->actionFunc = EnYb_Idle; break; } @@ -318,22 +318,22 @@ void EnYb_Talk(EnYb* this, GlobalContext* globalCtx) { EnYb_EnableProximityMusic(this); } -void EnYb_TeachingDanceFinish(EnYb* this, GlobalContext* globalCtx) { - EnYb_UpdateAnimation(this, globalCtx); - if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { +void EnYb_TeachingDanceFinish(EnYb* this, PlayState* play) { + EnYb_UpdateAnimation(this, play); + if (Actor_ProcessTalkRequest(&this->actor, &play->state)) { this->actionFunc = EnYb_Talk; // Spread my dance across the world - Message_StartTextbox(globalCtx, 0x147C, &this->actor); + Message_StartTextbox(play, 0x147C, &this->actor); this->actor.flags &= ~ACTOR_FLAG_10000; } else { - func_800B8500(&this->actor, globalCtx, 1000.0f, 1000.0f, -1); + func_800B8500(&this->actor, play, 1000.0f, 1000.0f, PLAYER_AP_MINUS1); } EnYb_EnableProximityMusic(this); } // dancing countdown -void EnYb_TeachingDance(EnYb* this, GlobalContext* globalCtx) { - EnYb_UpdateAnimation(this, globalCtx); +void EnYb_TeachingDance(EnYb* this, PlayState* play) { + EnYb_UpdateAnimation(this, play); if (this->teachingCutsceneTimer > 0) { this->teachingCutsceneTimer--; @@ -341,34 +341,34 @@ void EnYb_TeachingDance(EnYb* this, GlobalContext* globalCtx) { EnYb_FinishTeachingCutscene(this); this->actionFunc = EnYb_TeachingDanceFinish; this->actor.flags |= ACTOR_FLAG_10000; - func_800B8500(&this->actor, globalCtx, 1000.0f, 1000.0f, -1); + func_800B8500(&this->actor, play, 1000.0f, 1000.0f, PLAYER_AP_MINUS1); } EnYb_EnableProximityMusic(this); } -void EnYb_Idle(EnYb* this, GlobalContext* globalCtx) { +void EnYb_Idle(EnYb* this, PlayState* play) { s32 pad; - Player* player = GET_PLAYER(globalCtx); + Player* player = GET_PLAYER(play); - EnYb_UpdateAnimation(this, globalCtx); + EnYb_UpdateAnimation(this, play); if (this->actor.xzDistToPlayer < 180.0f && fabsf(this->actor.playerHeightRel) < 50.0f && - globalCtx->msgCtx.ocarinaMode == 3 && globalCtx->msgCtx.unk1202E == 7 && + play->msgCtx.ocarinaMode == 3 && play->msgCtx.lastPlayedSong == OCARINA_SONG_HEALING && 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); + } else if (Actor_ProcessTalkRequest(&this->actor, &play->state)) { + func_80BFA2FC(play); this->actionFunc = EnYb_Talk; - if (Player_GetMask(globalCtx) == PLAYER_MASK_KAMARO) { + if (Player_GetMask(play) == PLAYER_MASK_KAMARO) { // I have taught you, go use it - Message_StartTextbox(globalCtx, 0x147C, &this->actor); + Message_StartTextbox(play, 0x147C, &this->actor); } else { // regular talk to him first dialogue - Message_StartTextbox(globalCtx, 0x147B, &this->actor); + Message_StartTextbox(play, 0x147B, &this->actor); } - } else if (EnYb_CanTalk(this, globalCtx)) { - func_800B8614(&this->actor, globalCtx, 120.0f); + } else if (EnYb_CanTalk(this, play)) { + func_800B8614(&this->actor, play, 120.0f); } if (this->playerOcarinaOut & 1) { @@ -384,9 +384,9 @@ void EnYb_Idle(EnYb* this, GlobalContext* globalCtx) { EnYb_EnableProximityMusic(this); } -void EnYb_WaitForMidnight(EnYb* this, GlobalContext* globalCtx) { +void EnYb_WaitForMidnight(EnYb* this, PlayState* play) { if (gSaveContext.save.time < CLOCK_TIME(6, 0)) { - EnYb_UpdateAnimation(this, globalCtx); + EnYb_UpdateAnimation(this, play); this->alpha += 5; if (this->alpha > 250) { this->alpha = 255; @@ -397,20 +397,20 @@ void EnYb_WaitForMidnight(EnYb* this, GlobalContext* globalCtx) { } } -void EnYb_Update(Actor* thisx, GlobalContext* globalCtx) { +void EnYb_Update(Actor* thisx, PlayState* play) { 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); + CollisionCheck_SetOC(play, &play->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); + Actor_UpdateBgCheckInfo(play, &this->actor, 40.0f, 25.0f, 40.0f, 5); } - this->actionFunc(this, globalCtx); + this->actionFunc(this, play); if (this->cutsceneIndex != -1 && ActorCutscene_GetCurrentIndex() != this->cutscenes[this->cutsceneIndex]) { if (ActorCutscene_GetCurrentIndex() == 0x7C) { @@ -426,57 +426,57 @@ void EnYb_Update(Actor* thisx, GlobalContext* globalCtx) { } } -void EnYb_PostLimbDrawOpa(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx) { +void EnYb_PostLimbDrawOpa(PlayState* play, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx) { EnYb* this = THIS; if (limbIndex == YB_LIMB_HEAD) { - Matrix_MultiplyVector3fByState(&D_80BFB2F4, &this->actor.focus.pos); + Matrix_MultVec3f(&D_80BFB2F4, &this->actor.focus.pos); } if (limbIndex == YB_LIMB_LEGS_ROOT) { - Matrix_MultiplyVector3fByState(&gZeroVec3f, &this->shadowPos); + Matrix_MultVec3f(&gZeroVec3f, &this->shadowPos); } } -void EnYb_PostLimbDrawXlu(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx, Gfx** gfx) { +void EnYb_PostLimbDrawXlu(PlayState* play, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx, Gfx** gfx) { EnYb* this = THIS; if (limbIndex == YB_LIMB_HEAD) { - Matrix_MultiplyVector3fByState(&D_80BFB300, &this->actor.focus.pos); + Matrix_MultVec3f(&D_80BFB300, &this->actor.focus.pos); } if (limbIndex == YB_LIMB_LEGS_ROOT) { - Matrix_MultiplyVector3fByState(&gZeroVec3f, &this->shadowPos); + Matrix_MultVec3f(&gZeroVec3f, &this->shadowPos); } } -void EnYb_Draw(Actor* thisx, GlobalContext* globalCtx) { +void EnYb_Draw(Actor* thisx, PlayState* play) { EnYb* this = THIS; - OPEN_DISPS(globalCtx->state.gfxCtx); + OPEN_DISPS(play->state.gfxCtx); if (this->alpha != 0) { if (this->alpha < 255) { if (this->alpha > 128) { func_8012C2B4(POLY_XLU_DISP++); - Scene_SetRenderModeXlu(globalCtx, 2, 2); + Scene_SetRenderModeXlu(play, 2, 2); } else { func_8012C304(POLY_XLU_DISP++); - Scene_SetRenderModeXlu(globalCtx, 1, 2); + Scene_SetRenderModeXlu(play, 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, + SkelAnime_DrawFlex(play, 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, + func_8012C28C(play->state.gfxCtx); + Scene_SetRenderModeXlu(play, 0, 1); + SkelAnime_DrawFlexOpa(play, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, NULL, EnYb_PostLimbDrawOpa, &this->actor); } } - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->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 1b4c898a2..c7b977653 100644 --- a/src/overlays/actors/ovl_En_Yb/z_en_yb.h +++ b/src/overlays/actors/ovl_En_Yb/z_en_yb.h @@ -6,7 +6,7 @@ struct EnYb; -typedef void (*EnYbActionFunc)(struct EnYb*, GlobalContext*); +typedef void (*EnYbActionFunc)(struct EnYb*, PlayState*); typedef struct EnYb { /* 0x000 */ Actor actor; @@ -18,7 +18,7 @@ typedef struct EnYb { /* 0x3B8 */ ColliderCylinder collider; /* 0x404 */ Vec3f shadowPos; /* 0x410 */ u16 playerOcarinaOut; - /* 0x412 */ s16 currentAnimIndex; + /* 0x412 */ s16 animIndex; /* 0x414 */ s16 alpha; /* 0x416 */ s16 cutscenes[2]; /* 0x41A */ s16 cutsceneIndex; 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 004907003..d5e6f2e00 100644 --- a/src/overlays/actors/ovl_En_Zl1/z_en_zl1.c +++ b/src/overlays/actors/ovl_En_Zl1/z_en_zl1.c @@ -10,10 +10,10 @@ #define THIS ((EnZl1*)thisx) -void EnZl1_Init(Actor* thisx, GlobalContext* globalCtx); -void EnZl1_Destroy(Actor* thisx, GlobalContext* globalCtx); -void EnZl1_Update(Actor* thisx, GlobalContext* globalCtx); -void EnZl1_Draw(Actor* thisx, GlobalContext* globalCtx); +void EnZl1_Init(Actor* thisx, PlayState* play); +void EnZl1_Destroy(Actor* thisx, PlayState* play); +void EnZl1_Update(Actor* thisx, PlayState* play); +void EnZl1_Draw(Actor* thisx, PlayState* play); const ActorInit En_Zl1_InitVars = { ACTOR_EN_ZL1, @@ -27,11 +27,11 @@ const ActorInit En_Zl1_InitVars = { (ActorFunc)EnZl1_Draw, }; -void EnZl1_Init(Actor* thisx, GlobalContext* globalCtx) { +void EnZl1_Init(Actor* thisx, PlayState* play) { } -void EnZl1_Destroy(Actor* thisx, GlobalContext* globalCtx) { +void EnZl1_Destroy(Actor* thisx, PlayState* play) { } -void EnZl1_Update(Actor* thisx, GlobalContext* globalCtx) { +void EnZl1_Update(Actor* thisx, PlayState* play) { } -void EnZl1_Draw(Actor* thisx, GlobalContext* globalCtx) { +void EnZl1_Draw(Actor* thisx, PlayState* play) { } 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 731af3772..92e0b2925 100644 --- a/src/overlays/actors/ovl_En_Zl4/z_en_zl4.c +++ b/src/overlays/actors/ovl_En_Zl4/z_en_zl4.c @@ -10,12 +10,12 @@ #define THIS ((EnZl4*)thisx) -void EnZl4_Init(Actor* thisx, GlobalContext* globalCtx); -void EnZl4_Destroy(Actor* thisx, GlobalContext* globalCtx); -void EnZl4_Update(Actor* thisx, GlobalContext* globalCtx); -void EnZl4_Draw(Actor* thisx, GlobalContext* globalCtx); +void EnZl4_Init(Actor* thisx, PlayState* play); +void EnZl4_Destroy(Actor* thisx, PlayState* play); +void EnZl4_Update(Actor* thisx, PlayState* play); +void EnZl4_Draw(Actor* thisx, PlayState* play); -void func_809A1D0C(EnZl4* this, GlobalContext* globalCtx); +void func_809A1D0C(EnZl4* this, PlayState* play); #if 0 const ActorInit En_Zl4_InitVars = { diff --git a/src/overlays/actors/ovl_En_Zl4/z_en_zl4.h b/src/overlays/actors/ovl_En_Zl4/z_en_zl4.h index 17c2c6d04..eeb272579 100644 --- a/src/overlays/actors/ovl_En_Zl4/z_en_zl4.h +++ b/src/overlays/actors/ovl_En_Zl4/z_en_zl4.h @@ -5,13 +5,13 @@ struct EnZl4; -typedef void (*EnZl4ActionFunc)(struct EnZl4*, GlobalContext*); +typedef void (*EnZl4ActionFunc)(struct EnZl4*, PlayState*); typedef struct EnZl4 { - /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x14C]; - /* 0x0290 */ EnZl4ActionFunc actionFunc; - /* 0x0294 */ char unk_294[0x60]; + /* 0x000 */ Actor actor; + /* 0x144 */ char unk_144[0x14C]; + /* 0x290 */ EnZl4ActionFunc actionFunc; + /* 0x294 */ char unk_294[0x60]; } EnZl4; // size = 0x2F4 extern const ActorInit En_Zl4_InitVars; diff --git a/src/overlays/actors/ovl_En_Zo/z_en_zo.c b/src/overlays/actors/ovl_En_Zo/z_en_zo.c index 0f91171fb..c4bf8f56d 100644 --- a/src/overlays/actors/ovl_En_Zo/z_en_zo.c +++ b/src/overlays/actors/ovl_En_Zo/z_en_zo.c @@ -5,20 +5,19 @@ */ #include "z_en_zo.h" -#include "objects/object_zo/object_zo.h" #define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_8 | ACTOR_FLAG_10) #define THIS ((EnZo*)thisx) -void EnZo_Init(Actor* thisx, GlobalContext* globalCtx); -void EnZo_Destroy(Actor* thisx, GlobalContext* globalCtx); -void EnZo_Update(Actor* thisx, GlobalContext* globalCtx); -void EnZo_Draw(Actor* thisx, GlobalContext* globalCtx); +void EnZo_Init(Actor* thisx, PlayState* play); +void EnZo_Destroy(Actor* thisx, PlayState* play); +void EnZo_Update(Actor* thisx, PlayState* play); +void EnZo_Draw(Actor* thisx, PlayState* play); -void EnZo_FollowPath(EnZo* this, GlobalContext* globalCtx); -void EnZo_TreadWater(EnZo* this, GlobalContext* globalCtx); -void EnZo_DoNothing(EnZo* this, GlobalContext* globalCtx); +void EnZo_FollowPath(EnZo* this, PlayState* play); +void EnZo_TreadWater(EnZo* this, PlayState* play); +void EnZo_DoNothing(EnZo* this, PlayState* play); const ActorInit En_Zo_InitVars = { ACTOR_EN_ZO, @@ -89,7 +88,7 @@ static DamageTable sDamageTable = { /* Powder Keg */ DMG_ENTRY(0, 0), }; -static AnimationInfoS sAnimations[] = { +static AnimationInfoS sAnimationInfo[] = { { &gZoraIdleAnim, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, { &gZoraIdleAnim, 1.0f, 0, -1, ANIMMODE_LOOP, -4 }, { &gZoraSurfacingAnim, 1.0f, 0, -1, ANIMMODE_LOOP, -4 }, @@ -99,28 +98,28 @@ static AnimationInfoS sAnimations[] = { { &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) { +s32 EnZo_ChangeAnim(SkelAnime* skelAnime, s16 animIndex) { s16 frameCount; s32 didChange = false; - if ((index >= 0) && (index < ARRAY_COUNT(sAnimations))) { + if ((animIndex >= 0) && (animIndex < ARRAY_COUNT(sAnimationInfo))) { didChange = true; - frameCount = sAnimations[index].frameCount; + frameCount = sAnimationInfo[animIndex].frameCount; if (frameCount < 0) { - frameCount = Animation_GetLastFrame(sAnimations[index].animation); + frameCount = Animation_GetLastFrame(sAnimationInfo[animIndex].animation); } - Animation_Change(skelAnime, sAnimations[index].animation, sAnimations[index].playSpeed, - sAnimations[index].startFrame, frameCount, sAnimations[index].mode, - sAnimations[index].morphFrames); + Animation_Change(skelAnime, sAnimationInfo[animIndex].animation, sAnimationInfo[animIndex].playSpeed, + sAnimationInfo[animIndex].startFrame, frameCount, sAnimationInfo[animIndex].mode, + sAnimationInfo[animIndex].morphFrames); } return didChange; } -s32 EnZo_PlayWalkingSound(EnZo* this, GlobalContext* globalCtx) { +s32 EnZo_PlayWalkingSound(EnZo* this, PlayState* play) { u8 leftWasGrounded; u8 rightWasGrounded; s32 waterSfxId; @@ -138,15 +137,15 @@ s32 EnZo_PlayWalkingSound(EnZo* this, GlobalContext* globalCtx) { } sfxId = waterSfxId + SFX_FLAG; } else { - sfxId = SurfaceType_GetSfx(&globalCtx->colCtx, this->actor.floorPoly, this->actor.floorBgId) + SFX_FLAG; + sfxId = SurfaceType_GetSfx(&play->colCtx, this->actor.floorPoly, this->actor.floorBgId) + SFX_FLAG; } - this->isLeftFootGrounded = isFootGrounded = SubS_IsFloorAbove(globalCtx, &this->leftFootPos, -6.0f); + this->isLeftFootGrounded = isFootGrounded = SubS_IsFloorAbove(play, &this->leftFootPos, -6.0f); if ((this->isLeftFootGrounded) && (!leftWasGrounded) && (isFootGrounded)) { Actor_PlaySfxAtPos(&this->actor, sfxId); } - this->isRightFootGrounded = isFootGrounded = SubS_IsFloorAbove(globalCtx, &this->rightFootPos, -6.0f); + this->isRightFootGrounded = isFootGrounded = SubS_IsFloorAbove(play, &this->rightFootPos, -6.0f); if ((this->isRightFootGrounded) && (!rightWasGrounded) && (isFootGrounded)) { Actor_PlaySfxAtPos(&this->actor, sfxId); } @@ -164,30 +163,35 @@ void EnZo_Blink(EnZo* this, s32 maxEyeIndex) { } } -void EnZo_UpdateCollider(EnZo* this, GlobalContext* globalCtx) { +void EnZo_UpdateCollider(EnZo* this, PlayState* play) { this->collider.dim.pos.x = this->actor.world.pos.x; this->collider.dim.pos.y = this->actor.world.pos.y; this->collider.dim.pos.z = this->actor.world.pos.z; - CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); - CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + CollisionCheck_SetAC(play, &play->colChkCtx, &this->collider.base); + CollisionCheck_SetOC(play, &play->colChkCtx, &this->collider.base); } -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 }; - Player* player = GET_PLAYER(globalCtx); - Vec3f focus; +void EnZo_LookAtPlayer(EnZo* this, PlayState* play) { + static TrackOptionsSet sTrackOptions = { + { 0xFA0, 4, 1, 3 }, + { 0x1770, 4, 1, 6 }, + { 0xFA0, 4, 1, 3 }, + { 0x1770, 4, 1, 6 }, + }; + Player* player = GET_PLAYER(play); + Vec3f point; SkelAnime_Update(&this->skelAnime); if (SubS_AngleDiffLessEqual(this->actor.shape.rot.y, 0x2710, this->actor.yawTowardsPlayer)) { - focus.x = player->actor.world.pos.x; - focus.y = player->bodyPartsPos[7].y + 3.0f; - focus.z = player->actor.world.pos.z; - func_8013D2E0(&focus, &this->actor.focus.pos, &this->actor.shape.rot, &this->headRotTarget, &this->headRot, - &this->upperBodyRot, D_8099F5AC); + 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); @@ -197,22 +201,22 @@ void EnZo_LookAtPlayer(EnZo* this, GlobalContext* globalCtx) { } EnZo_Blink(this, 3); - SubS_FillLimbRotTables(globalCtx, this->limbRotY, this->limbRotZ, 20); + SubS_FillLimbRotTables(play, this->limbRotY, this->limbRotZ, 20); } -void EnZo_Walk(EnZo* this, GlobalContext* globalCtx) { - if (ENZO_GET_PATH(&this->actor) != ENZO_NO_PATH) { - EnZo_SetAnimation(&this->skelAnime, 6); +void EnZo_Walk(EnZo* this, PlayState* play) { + if (ENZO_GET_PATH(&this->actor) != 0x3F) { + EnZo_ChangeAnim(&this->skelAnime, 6); } - if (ENZO_GET_PATH(&this->actor) != ENZO_NO_PATH) { + if (ENZO_GET_PATH(&this->actor) != 0x3F) { this->actionFunc = EnZo_FollowPath; } else { this->actionFunc = EnZo_DoNothing; } } -void EnZo_FollowPath(EnZo* this, GlobalContext* globalCtx) { +void EnZo_FollowPath(EnZo* this, PlayState* play) { s16 speed; Vec3f pos; @@ -226,14 +230,14 @@ void EnZo_FollowPath(EnZo* this, GlobalContext* globalCtx) { } if (this->actor.depthInWater > 60.0f) { - EnZo_SetAnimation(&this->skelAnime, 1); + EnZo_ChangeAnim(&this->skelAnime, 1); this->actionFunc = EnZo_TreadWater; this->actor.gravity = 0.0f; this->actor.speedXZ = 0.0f; } } -void EnZo_TreadWater(EnZo* this, GlobalContext* globalCtx) { +void EnZo_TreadWater(EnZo* this, PlayState* play) { f32 targetYVel; if (this->actor.depthInWater < (sREG(0) + 50.0f)) { @@ -244,83 +248,84 @@ void EnZo_TreadWater(EnZo* this, GlobalContext* globalCtx) { Math_ApproachF(&this->actor.velocity.y, targetYVel, (sREG(1) + 18.0f) * 0.01f, (sREG(2) + 12.0f) * 0.01f); } -void EnZo_DoNothing(EnZo* this, GlobalContext* globalCtx) { +void EnZo_DoNothing(EnZo* this, PlayState* play) { } -void EnZo_Init(Actor* thisx, GlobalContext* globalCtx) { +void EnZo_Init(Actor* thisx, PlayState* play) { EnZo* this = THIS; s32 pad; ActorShape_Init(&this->actor.shape, 0.0f, NULL, 0.0f); - SkelAnime_InitFlex(globalCtx, &this->skelAnime, &gZoraSkel, NULL, this->jointTable, this->morphTable, 20); - EnZo_SetAnimation(&this->skelAnime, 0); + SkelAnime_InitFlex(play, &this->skelAnime, &gZoraSkel, NULL, this->jointTable, this->morphTable, ZORA_LIMB_MAX); + EnZo_ChangeAnim(&this->skelAnime, 0); - Collider_InitCylinder(globalCtx, &this->collider); - Collider_SetCylinder(globalCtx, &this->collider, &this->actor, &sCylinderInit); + Collider_InitCylinder(play, &this->collider); + Collider_SetCylinder(play, &this->collider, &this->actor, &sCylinderInit); CollisionCheck_SetInfo2(&this->actor.colChkInfo, &sDamageTable, &sColChkInfoInit); - this->path = SubS_GetPathByIndex(globalCtx, ENZO_GET_PATH(&this->actor), ENZO_NO_PATH); + this->path = SubS_GetPathByIndex(play, ENZO_GET_PATH(&this->actor), 0x3F); Actor_SetScale(&this->actor, 0.01f); this->actionFunc = EnZo_Walk; this->actor.gravity = -4.0f; } -void EnZo_Destroy(Actor* thisx, GlobalContext* globalCtx) { +void EnZo_Destroy(Actor* thisx, PlayState* play) { EnZo* this = THIS; - Collider_DestroyCylinder(globalCtx, &this->collider); + Collider_DestroyCylinder(play, &this->collider); } -void EnZo_Update(Actor* thisx, GlobalContext* globalCtx) { +void EnZo_Update(Actor* thisx, PlayState* play) { EnZo* this = THIS; - this->actionFunc(this, globalCtx); - Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 0.0f, 0.0f, 0.0f, 4); - EnZo_LookAtPlayer(this, globalCtx); - EnZo_PlayWalkingSound(this, globalCtx); - EnZo_UpdateCollider(this, globalCtx); + this->actionFunc(this, play); + Actor_UpdateBgCheckInfo(play, &this->actor, 0.0f, 0.0f, 0.0f, 4); + EnZo_LookAtPlayer(this, play); + EnZo_PlayWalkingSound(this, play); + EnZo_UpdateCollider(this, play); } -s32 EnZo_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, Actor* thisx, +s32 EnZo_OverrideLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, Actor* thisx, 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); } return false; } -void EnZo_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx, Gfx** gfx) { +void EnZo_PostLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx, Gfx** gfx) { EnZo* this = THIS; 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); } } @@ -333,15 +338,15 @@ static Gfx sTransparencyDlist[] = { gsSPEndDisplayList(), }; -void EnZo_Draw(Actor* thisx, GlobalContext* globalCtx) { +void EnZo_Draw(Actor* thisx, PlayState* play) { EnZo* this = THIS; s32 i; - u8* shadowTex = GRAPH_ALLOC(globalCtx->state.gfxCtx, sizeof(u8) * SQ(64)); + u8* shadowTex = GRAPH_ALLOC(play->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); + OPEN_DISPS(play->state.gfxCtx); + func_8012C28C(play->state.gfxCtx); gDPPipeSync(POLY_OPA_DISP++); gDPSetEnvColor(POLY_OPA_DISP++, 0, 0, 0, 255); @@ -350,18 +355,19 @@ void EnZo_Draw(Actor* thisx, GlobalContext* globalCtx) { gSPSegment(POLY_OPA_DISP++, 0x0C, &sTransparencyDlist[2]); POLY_OPA_DISP = - SkelAnime_DrawFlex(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, + SkelAnime_DrawFlex(play, 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); - CLOSE_DISPS(globalCtx->state.gfxCtx); + SubS_DrawShadowTex(&this->actor, &play->state, shadowTex); + CLOSE_DISPS(play->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..bfd0c79dd 100644 --- a/src/overlays/actors/ovl_En_Zo/z_en_zo.h +++ b/src/overlays/actors/ovl_En_Zo/z_en_zo.h @@ -2,38 +2,38 @@ #define Z_EN_ZO_H #include "global.h" +#include "objects/object_zo/object_zo.h" struct EnZo; -typedef void (*EnZoActionFunc)(struct EnZo*, GlobalContext*); +typedef void (*EnZoActionFunc)(struct EnZo*, PlayState*); #define ENZO_GET_PATH(thisx) (((thisx)->params & 0x7E00) >> 9) -#define ENZO_NO_PATH 0x3F typedef struct EnZo { - /* 0x0000 */ Actor actor; - /* 0x0144 */ EnZoActionFunc actionFunc; - /* 0x0148 */ SkelAnime skelAnime; - /* 0x0194 */ ColliderCylinder collider; - /* 0x01D8 */ UNK_TYPE1 unk_1D8[0x4]; - /* 0x01DC */ Path* path; - /* 0x01E0 */ s16 waypoint; - /* 0x01E4 */ Vec3f leftFootPos; - /* 0x01F0 */ Vec3f rightFootPos; - /* 0x01FC */ u8 isLeftFootGrounded; - /* 0x01FD */ u8 isRightFootGrounded; - /* 0x01FE */ Vec3s jointTable[20]; - /* 0x0276 */ Vec3s morphTable[20]; - /* 0x02EE */ Vec3s headRotTarget; - /* 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]; - /* 0x041A */ UNK_TYPE1 unk_41A[0x6]; - /* 0x041E */ s16 eyeIndex; - /* 0x0420 */ s16 blinkTimer; + /* 0x000 */ Actor actor; + /* 0x144 */ EnZoActionFunc actionFunc; + /* 0x148 */ SkelAnime skelAnime; + /* 0x194 */ ColliderCylinder collider; + /* 0x1D8 */ UNK_TYPE1 unk_1D8[0x4]; + /* 0x1DC */ Path* path; + /* 0x1E0 */ s16 waypoint; + /* 0x1E4 */ Vec3f leftFootPos; + /* 0x1F0 */ Vec3f rightFootPos; + /* 0x1FC */ u8 isLeftFootGrounded; + /* 0x1FD */ u8 isRightFootGrounded; + /* 0x1FE */ Vec3s jointTable[ZORA_LIMB_MAX]; + /* 0x276 */ Vec3s morphTable[ZORA_LIMB_MAX]; + /* 0x2EE */ Vec3s trackTarget; + /* 0x2F4 */ Vec3s headRot; + /* 0x2FA */ Vec3s upperBodyRot; + /* 0x300 */ UNK_TYPE1 unk_300[0x12]; + /* 0x312 */ s16 limbRotY[20]; + /* 0x33A */ s16 limbRotZ[20]; + /* 0x364 */ Vec3f bodyPartsPos[15]; + /* 0x41A */ UNK_TYPE1 unk_41A[0x6]; + /* 0x41E */ s16 eyeIndex; + /* 0x420 */ s16 blinkTimer; } EnZo; // size = 0x424 #endif // Z_EN_ZO_H diff --git a/src/overlays/actors/ovl_En_Zob/z_en_zob.c b/src/overlays/actors/ovl_En_Zob/z_en_zob.c index 6e9ddb5c0..1970e53df 100644 --- a/src/overlays/actors/ovl_En_Zob/z_en_zob.c +++ b/src/overlays/actors/ovl_En_Zob/z_en_zob.c @@ -11,31 +11,31 @@ #define THIS ((EnZob*)thisx) -void EnZob_Init(Actor* thisx, GlobalContext* globalCtx); -void EnZob_Destroy(Actor* thisx, GlobalContext* globalCtx); -void EnZob_Update(Actor* thisx, GlobalContext* globalCtx); -void EnZob_Draw(Actor* thisx, GlobalContext* globalCtx); +void EnZob_Init(Actor* thisx, PlayState* play); +void EnZob_Destroy(Actor* thisx, PlayState* play); +void EnZob_Update(Actor* thisx, PlayState* play); +void EnZob_Draw(Actor* thisx, PlayState* play); 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); -void func_80BA0374(EnZob* this, GlobalContext* globalCtx); -void func_80BA0610(EnZob* this, GlobalContext* globalCtx); -void func_80BA06BC(EnZob* this, GlobalContext* globalCtx); -void func_80BA0728(EnZob* this, GlobalContext* globalCtx); -void func_80BA09E0(EnZob* this, GlobalContext* globalCtx); -void func_80BA0A04(EnZob* this, GlobalContext* globalCtx); -void func_80BA0AD8(EnZob* this, GlobalContext* globalCtx); -void func_80BA0BB4(EnZob* this, GlobalContext* globalCtx); -void func_80BA0C14(EnZob* this, GlobalContext* globalCtx); -void func_80BA0CF4(EnZob* this, GlobalContext* globalCtx); +void func_80B9FD24(EnZob* this, PlayState* play); +void func_80B9FDDC(EnZob* this, PlayState* play); +void func_80B9FE1C(EnZob* this, PlayState* play); +void func_80B9FE5C(EnZob* this, PlayState* play); +void func_80B9FF20(EnZob* this, PlayState* play); +void func_80B9FF80(EnZob* this, PlayState* play); +void func_80BA005C(EnZob* this, PlayState* play); +void func_80BA00BC(EnZob* this, PlayState* play); +void func_80BA0318(EnZob* this, PlayState* play); +void func_80BA0374(EnZob* this, PlayState* play); +void func_80BA0610(EnZob* this, PlayState* play); +void func_80BA06BC(EnZob* this, PlayState* play); +void func_80BA0728(EnZob* this, PlayState* play); +void func_80BA09E0(EnZob* this, PlayState* play); +void func_80BA0A04(EnZob* this, PlayState* play); +void func_80BA0AD8(EnZob* this, PlayState* play); +void func_80BA0BB4(EnZob* this, PlayState* play); +void func_80BA0C14(EnZob* this, PlayState* play); +void func_80BA0CF4(EnZob* this, PlayState* play); const ActorInit En_Zob_InitVars = { ACTOR_EN_ZOB, @@ -77,7 +77,7 @@ static AnimationHeader* sAnimations[] = { Vec3f D_80BA1120 = { 300.0f, 900.0f, 0.0f }; -void EnZob_Init(Actor* thisx, GlobalContext* globalCtx) { +void EnZob_Init(Actor* thisx, PlayState* play) { EnZob* this = THIS; s32 i; s16 cs; @@ -85,10 +85,10 @@ void EnZob_Init(Actor* thisx, GlobalContext* globalCtx) { 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, + SkelAnime_InitFlex(play, &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); + Collider_InitAndSetCylinder(play, &this->collider, &this->actor, &sCylinderInit); this->unk_2F4 = 0; this->unk_30E = -1; this->unk_310 = 0; @@ -96,7 +96,7 @@ void EnZob_Init(Actor* thisx, GlobalContext* globalCtx) { this->unk_304 = 0; this->actor.terminalVelocity = -4.0f; this->actor.gravity = -4.0f; - func_80B9F7E4(this, 6, 2); + func_80B9F7E4(this, 6, ANIMMODE_ONCE); this->actionFunc = func_80BA0728; this->actor.textId = 0; @@ -130,7 +130,7 @@ void EnZob_Init(Actor* thisx, GlobalContext* globalCtx) { this->actionFunc = func_80BA0CF4; this->unk_2F4 |= 0x20; this->unk_312 = -1; - func_80B9F7E4(this, 0, 2); + func_80B9F7E4(this, 0, ANIMMODE_ONCE); this->unk_304 = 5; break; @@ -143,10 +143,10 @@ void EnZob_Init(Actor* thisx, GlobalContext* globalCtx) { } } -void EnZob_Destroy(Actor* thisx, GlobalContext* globalCtx) { +void EnZob_Destroy(Actor* thisx, PlayState* play) { EnZob* this = THIS; - Collider_DestroyCylinder(globalCtx, &this->collider); + Collider_DestroyCylinder(play, &this->collider); } void func_80B9F7E4(EnZob* this, s16 arg1, u8 arg2) { @@ -161,9 +161,9 @@ void func_80B9F86C(EnZob* this) { case 0: if (Rand_ZeroFloat(1.0f) > 0.7f) { if (this->unk_302 == 6) { - func_80B9F7E4(this, 7, 2); + func_80B9F7E4(this, 7, ANIMMODE_ONCE); } else { - func_80B9F7E4(this, 6, 2); + func_80B9F7E4(this, 6, ANIMMODE_ONCE); } } else { func_80B9F7E4(this, this->unk_302, 2); @@ -171,32 +171,32 @@ void func_80B9F86C(EnZob* this) { break; case 1: - func_80B9F7E4(this, 3, 0); + func_80B9F7E4(this, 3, ANIMMODE_LOOP); break; case 2: - func_80B9F7E4(this, 4, 0); + func_80B9F7E4(this, 4, ANIMMODE_LOOP); break; case 3: - func_80B9F7E4(this, 5, 0); + func_80B9F7E4(this, 5, ANIMMODE_LOOP); break; case 4: if (this->unk_302 == 3) { - func_80B9F7E4(this, 0, 0); + func_80B9F7E4(this, 0, ANIMMODE_LOOP); } else { - func_80B9F7E4(this, 3, 2); + func_80B9F7E4(this, 3, ANIMMODE_ONCE); } break; case 5: if (Rand_ZeroFloat(1.0f) < 0.8f) { - func_80B9F7E4(this, this->unk_302, 2); + func_80B9F7E4(this, this->unk_302, ANIMMODE_ONCE); } else if (this->unk_302 == 0) { - func_80B9F7E4(this, 1, 2); + func_80B9F7E4(this, 1, ANIMMODE_ONCE); } else { - func_80B9F7E4(this, 0, 2); + func_80B9F7E4(this, 0, ANIMMODE_ONCE); } break; } @@ -205,7 +205,7 @@ void func_80B9F86C(EnZob* this) { } } -void func_80B9FA3C(EnZob* this, GlobalContext* globalCtx) { +void func_80B9FA3C(EnZob* this, PlayState* play) { u16 textId; this->unk_2F4 |= 1; @@ -217,39 +217,39 @@ void func_80B9FA3C(EnZob* this, GlobalContext* globalCtx) { textId = 0x11F8; } this->unk_304 = 3; - func_80B9F7E4(this, 5, 0); + func_80B9F7E4(this, 5, ANIMMODE_LOOP); } else if (this->unk_2F4 & 0x10) { textId = 0x1210; this->unk_304 = 3; - func_80B9F7E4(this, 5, 2); + func_80B9F7E4(this, 5, ANIMMODE_ONCE); } else if (gSaveContext.save.weekEventReg[31] & 8) { textId = 0x1205; this->unk_304 = 1; - func_80B9F7E4(this, 3, 0); + func_80B9F7E4(this, 3, ANIMMODE_LOOP); } else if (this->unk_2F4 & 8) { textId = 0x1215; this->unk_304 = 3; - func_80B9F7E4(this, 5, 2); + func_80B9F7E4(this, 5, ANIMMODE_ONCE); } else if (this->unk_2F4 & 2) { textId = 0x1203; this->unk_304 = 1; - func_80B9F7E4(this, 2, 2); + func_80B9F7E4(this, 2, ANIMMODE_ONCE); } else if (gSaveContext.save.weekEventReg[30] & 8) { textId = 0x11FA; this->unk_304 = 1; - func_80B9F7E4(this, 2, 2); + func_80B9F7E4(this, 2, ANIMMODE_ONCE); } else if (!(gSaveContext.save.weekEventReg[30] & 4)) { gSaveContext.save.weekEventReg[30] |= 4; textId = 0x11FB; this->unk_304 = 1; - func_80B9F7E4(this, 2, 2); + func_80B9F7E4(this, 2, ANIMMODE_ONCE); } else { textId = 0x1201; this->unk_304 = 3; - func_80B9F7E4(this, 4, 2); + func_80B9F7E4(this, 4, ANIMMODE_ONCE); } - Message_StartTextbox(globalCtx, textId, &this->actor); + Message_StartTextbox(play, textId, &this->actor); } void func_80B9FC0C(EnZob* this) { @@ -266,138 +266,138 @@ void func_80B9FC70(EnZob* this, s16 arg1) { this->unk_30E = arg1; } -void func_80B9FCA0(EnZob* this, GlobalContext* globalCtx) { - func_801477B4(globalCtx); - globalCtx->msgCtx.ocarinaMode = 4; +void func_80B9FCA0(EnZob* this, PlayState* play) { + func_801477B4(play); + play->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); + func_80B9F7E4(this, 6, ANIMMODE_ONCE); + func_800B8718(&this->actor, &play->state); } -void func_80B9FD24(EnZob* this, GlobalContext* globalCtx) { +void func_80B9FD24(EnZob* this, PlayState* play) { s32 actionIndex; s16 action; func_80B9F86C(this); - if (Cutscene_CheckActorAction(globalCtx, 500)) { + if (Cutscene_CheckActorAction(play, 500)) { this->unk_30E = -1; - actionIndex = Cutscene_GetActorActionIndex(globalCtx, 500); - action = globalCtx->csCtx.actorActions[actionIndex]->action; + actionIndex = Cutscene_GetActorActionIndex(play, 500); + action = play->csCtx.actorActions[actionIndex]->action; if (action != this->unk_310) { this->unk_310 = action; switch (action) { case 1: - func_80B9F7E4(this, 8, 0); + func_80B9F7E4(this, 8, ANIMMODE_LOOP); break; case 2: - func_80B9F7E4(this, 7, 0); + func_80B9F7E4(this, 7, ANIMMODE_LOOP); break; } } } } -void func_80B9FDDC(EnZob* this, GlobalContext* globalCtx) { - Message_StartTextbox(globalCtx, 0x120C, &this->actor); +void func_80B9FDDC(EnZob* this, PlayState* play) { + Message_StartTextbox(play, 0x120C, &this->actor); this->actionFunc = func_80BA00BC; } -void func_80B9FE1C(EnZob* this, GlobalContext* globalCtx) { - Message_StartTextbox(globalCtx, 0x1211, &this->actor); +void func_80B9FE1C(EnZob* this, PlayState* play) { + Message_StartTextbox(play, 0x1211, &this->actor); this->actionFunc = func_80BA00BC; } -void func_80B9FE5C(EnZob* this, GlobalContext* globalCtx) { +void func_80B9FE5C(EnZob* this, PlayState* play) { func_80B9F86C(this); - if (globalCtx->msgCtx.ocarinaMode == 3) { - globalCtx->msgCtx.unk11F10 = 0; + if (play->msgCtx.ocarinaMode == 3) { + play->msgCtx.msgLength = 0; this->actionFunc = func_80B9FDDC; func_80B9FC70(this, 0); - } else if (Message_GetState(&globalCtx->msgCtx) == 11) { - globalCtx->msgCtx.unk11F10 = 0; + } else if (Message_GetState(&play->msgCtx) == TEXT_STATE_11) { + play->msgCtx.msgLength = 0; this->actionFunc = func_80B9FE1C; this->unk_304 = 3; - func_80B9F7E4(this, 5, 2); + func_80B9F7E4(this, 5, ANIMMODE_ONCE); func_80B9FC70(this, 0); } } -void func_80B9FF20(EnZob* this, GlobalContext* globalCtx) { +void func_80B9FF20(EnZob* this, PlayState* play) { func_80B9F86C(this); - if (Message_GetState(&globalCtx->msgCtx) == 7) { - func_80152434(globalCtx, 0x42); + if (Message_GetState(&play->msgCtx) == TEXT_STATE_7) { + func_80152434(play, 0x42); this->actionFunc = func_80B9FE5C; func_80B9FC70(this, 2); } } -void func_80B9FF80(EnZob* this, GlobalContext* globalCtx) { +void func_80B9FF80(EnZob* this, PlayState* play) { func_80B9F86C(this); - if (globalCtx->msgCtx.ocarinaMode == 3) { + if (play->msgCtx.ocarinaMode == 3) { this->actionFunc = func_80B9FF20; this->unk_304 = 6; - func_80B9F7E4(this, 1, 0); - func_80152434(globalCtx, 0x3E); + func_80B9F7E4(this, 1, ANIMMODE_LOOP); + func_80152434(play, 0x3E); func_80B9FC70(this, 1); - } else if (Message_GetState(&globalCtx->msgCtx) == 11) { - globalCtx->msgCtx.unk11F10 = 0; + } else if (Message_GetState(&play->msgCtx) == TEXT_STATE_11) { + play->msgCtx.msgLength = 0; this->actionFunc = func_80B9FE1C; this->unk_304 = 3; - func_80B9F7E4(this, 5, 2); + func_80B9F7E4(this, 5, ANIMMODE_ONCE); func_80B9FC70(this, 0); } } -void func_80BA005C(EnZob* this, GlobalContext* globalCtx) { +void func_80BA005C(EnZob* this, PlayState* play) { func_80B9F86C(this); - if (Message_GetState(&globalCtx->msgCtx) == 7) { - func_80152434(globalCtx, 0x41); + if (Message_GetState(&play->msgCtx) == TEXT_STATE_7) { + func_80152434(play, 0x41); this->actionFunc = func_80B9FF80; func_80B9FC70(this, 2); } } -void func_80BA00BC(EnZob* this, GlobalContext* globalCtx) { +void func_80BA00BC(EnZob* this, PlayState* play) { func_80B9F86C(this); - switch (Message_GetState(&globalCtx->msgCtx)) { - case 4: - if (Message_ShouldAdvance(globalCtx) && (globalCtx->msgCtx.currentTextId == 0x1212)) { - switch (globalCtx->msgCtx.choiceIndex) { + switch (Message_GetState(&play->msgCtx)) { + case TEXT_STATE_CHOICE: + if (Message_ShouldAdvance(play) && (play->msgCtx.currentTextId == 0x1212)) { + switch (play->msgCtx.choiceIndex) { case 1: func_8019F208(); - func_80151938(globalCtx, 0x1209); + func_80151938(play, 0x1209); this->unk_304 = 1; - func_80B9F7E4(this, 2, 2); + func_80B9F7E4(this, 2, ANIMMODE_ONCE); break; case 0: func_8019F230(); - func_80151938(globalCtx, 0x1213); + func_80151938(play, 0x1213); break; } } break; - case 5: - if (Message_ShouldAdvance(globalCtx)) { - switch (globalCtx->msgCtx.currentTextId) { + case TEXT_STATE_5: + if (Message_ShouldAdvance(play)) { + switch (play->msgCtx.currentTextId) { case 0x1208: case 0x120E: case 0x1216: - func_80151938(globalCtx, globalCtx->msgCtx.currentTextId + 1); + func_80151938(play, play->msgCtx.currentTextId + 1); break; case 0x120C: - globalCtx->msgCtx.unk11F10 = 0; + play->msgCtx.msgLength = 0; this->actionFunc = func_80B9FD24; - func_80B9F7E4(this, 8, 0); + func_80B9F7E4(this, 8, ANIMMODE_LOOP); func_80B9FC70(this, 3); break; @@ -405,30 +405,30 @@ void func_80BA00BC(EnZob* this, GlobalContext* globalCtx) { case 0x1211: case 0x1213: case 0x1217: - func_80151938(globalCtx, globalCtx->msgCtx.currentTextId + 1); + func_80151938(play, play->msgCtx.currentTextId + 1); this->unk_304 = 3; - func_80B9F7E4(this, 4, 2); + func_80B9F7E4(this, 4, ANIMMODE_ONCE); break; case 0x1218: - func_80B9FCA0(this, globalCtx); + func_80B9FCA0(this, play); break; case 0x1214: this->unk_2F4 |= 8; - func_80B9FCA0(this, globalCtx); + func_80B9FCA0(this, play); break; case 0x120F: gSaveContext.save.weekEventReg[31] |= 8; this->unk_2F4 |= 0x10; - func_80B9FCA0(this, globalCtx); + func_80B9FCA0(this, play); break; case 0x1209: - func_80152434(globalCtx, 0x3D); + func_80152434(play, 0x3D); this->unk_304 = 4; - func_80B9F7E4(this, 0, 0); + func_80B9F7E4(this, 0, ANIMMODE_LOOP); this->actionFunc = func_80BA005C; func_80B9FC70(this, 1); break; @@ -438,50 +438,50 @@ void func_80BA00BC(EnZob* this, GlobalContext* globalCtx) { } } -void func_80BA0318(EnZob* this, GlobalContext* globalCtx) { - func_80152434(globalCtx, 0x3D); +void func_80BA0318(EnZob* this, PlayState* play) { + func_80152434(play, 0x3D); this->unk_304 = 4; - func_80B9F7E4(this, 0, 0); + func_80B9F7E4(this, 0, ANIMMODE_LOOP); this->actionFunc = func_80BA005C; func_80B9FC70(this, 1); } -void func_80BA0374(EnZob* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); +void func_80BA0374(EnZob* this, PlayState* play) { + Player* player = GET_PLAYER(play); func_80B9F86C(this); - switch (Message_GetState(&globalCtx->msgCtx)) { - case 4: - if (Message_ShouldAdvance(globalCtx) && (globalCtx->msgCtx.currentTextId == 0x1205)) { - switch (globalCtx->msgCtx.choiceIndex) { + switch (Message_GetState(&play->msgCtx)) { + case TEXT_STATE_CHOICE: + if (Message_ShouldAdvance(play) && (play->msgCtx.currentTextId == 0x1205)) { + switch (play->msgCtx.choiceIndex) { case 0: func_8019F208(); - func_80151938(globalCtx, 0x1207); - func_80B9F7E4(this, 2, 2); + func_80151938(play, 0x1207); + func_80B9F7E4(this, 2, ANIMMODE_ONCE); break; case 1: func_8019F230(); - func_80151938(globalCtx, 0x1206); + func_80151938(play, 0x1206); break; } } break; - case 5: - if (Message_ShouldAdvance(globalCtx)) { - switch (globalCtx->msgCtx.currentTextId) { + case TEXT_STATE_5: + if (Message_ShouldAdvance(play)) { + switch (play->msgCtx.currentTextId) { case 0x11F8: gSaveContext.save.weekEventReg[30] |= 2; - func_80151938(globalCtx, 0x11F9); + func_80151938(play, 0x11F9); break; case 0x11F9: - func_801477B4(globalCtx); + func_801477B4(play); this->actionFunc = func_80BA0728; this->unk_304 = 0; - func_80B9F7E4(this, 6, 2); + func_80B9F7E4(this, 6, ANIMMODE_ONCE); this->unk_2F4 &= ~1; break; @@ -490,19 +490,19 @@ void func_80BA0374(EnZob* this, GlobalContext* globalCtx) { case 0x11FF: case 0x1201: case 0x1203: - func_80151938(globalCtx, globalCtx->msgCtx.currentTextId + 1); + func_80151938(play, play->msgCtx.currentTextId + 1); break; case 0x11FD: this->unk_304 = 3; - func_80B9F7E4(this, 4, 2); - func_80151938(globalCtx, globalCtx->msgCtx.currentTextId + 1); + func_80B9F7E4(this, 4, ANIMMODE_ONCE); + func_80151938(play, play->msgCtx.currentTextId + 1); break; case 0x11FE: this->unk_304 = 1; - func_80B9F7E4(this, 3, 0); - func_80151938(globalCtx, globalCtx->msgCtx.currentTextId + 1); + func_80B9F7E4(this, 3, ANIMMODE_LOOP); + func_80151938(play, play->msgCtx.currentTextId + 1); break; case 0x11FA: @@ -513,16 +513,16 @@ void func_80BA0374(EnZob* this, GlobalContext* globalCtx) { case 0x120F: case 0x1210: case 0x1215: - func_801477B4(globalCtx); + func_801477B4(play); this->actionFunc = func_80BA0728; this->unk_304 = 0; - func_80B9F7E4(this, 6, 2); + func_80B9F7E4(this, 6, ANIMMODE_ONCE); this->unk_2F4 &= ~1; this->unk_2F4 |= 2; break; case 0x1207: - func_801477B4(globalCtx); + func_801477B4(play); this->actionFunc = func_80BA0318; player->unk_A90 = &this->actor; player->stateFlags3 |= 0x20; @@ -533,56 +533,56 @@ void func_80BA0374(EnZob* this, GlobalContext* globalCtx) { } } -void func_80BA0610(EnZob* this, GlobalContext* globalCtx) { +void func_80BA0610(EnZob* this, PlayState* play) { func_80B9F86C(this); - if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { + if (Actor_ProcessTalkRequest(&this->actor, &play->state)) { this->actor.flags &= ~ACTOR_FLAG_10000; - Message_StartTextbox(globalCtx, 0x120D, &this->actor); + Message_StartTextbox(play, 0x120D, &this->actor); this->unk_304 = 3; - func_80B9F7E4(this, 5, 2); + func_80B9F7E4(this, 5, ANIMMODE_ONCE); func_80B9FC70(this, 0); this->actionFunc = func_80BA00BC; } else { - func_800B8614(&this->actor, globalCtx, 500.0f); + func_800B8614(&this->actor, play, 500.0f); } } -void func_80BA06BC(EnZob* this, GlobalContext* globalCtx) { - func_80B9FD24(this, globalCtx); - if (!Cutscene_CheckActorAction(globalCtx, 500)) { +void func_80BA06BC(EnZob* this, PlayState* play) { + func_80B9FD24(this, play); + if (!Cutscene_CheckActorAction(play, 500)) { this->actionFunc = func_80BA0610; this->actor.flags |= ACTOR_FLAG_10000; - func_80BA0610(this, globalCtx); + func_80BA0610(this, play); } } -void func_80BA0728(EnZob* this, GlobalContext* globalCtx) { +void func_80BA0728(EnZob* this, PlayState* play) { s32 pad; Vec3f sp28; func_80B9F86C(this); - if (func_800B8718(&this->actor, &globalCtx->state)) { + if (func_800B8718(&this->actor, &play->state)) { if (gSaveContext.save.playerForm == PLAYER_FORM_ZORA) { - Message_StartTextbox(globalCtx, 0x1208, NULL); + Message_StartTextbox(play, 0x1208, NULL); gSaveContext.save.weekEventReg[30] |= 8; } else { - Message_StartTextbox(globalCtx, 0x1216, NULL); + Message_StartTextbox(play, 0x1216, NULL); } this->actionFunc = func_80BA00BC; this->unk_304 = 1; - func_80B9F7E4(this, 2, 2); + func_80B9F7E4(this, 2, ANIMMODE_ONCE); this->unk_30E = 0; this->unk_2F4 |= 1; - } else if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { + } else if (Actor_ProcessTalkRequest(&this->actor, &play->state)) { this->actionFunc = func_80BA0374; - func_80B9FA3C(this, globalCtx); - } else if (Cutscene_CheckActorAction(globalCtx, 500)) { + func_80B9FA3C(this, play); + } else if (Cutscene_CheckActorAction(play, 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); + Player_IsFacingActor(&this->actor, 0x3000, play) && Actor_IsFacingPlayer(&this->actor, 0x3000)) { + func_800B8614(&this->actor, play, 150.0f); + func_800B874C(&this->actor, play, 200.0f, 150.0f); } sp28.x = this->actor.projectedPos.x; @@ -591,60 +591,61 @@ void func_80BA0728(EnZob* this, GlobalContext* globalCtx) { func_801A1FB4(3, &sp28, 0x6C, 1000.0f); } -void func_80BA08E8(EnZob* this, GlobalContext* globalCtx) { +void func_80BA08E8(EnZob* this, PlayState* play) { 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); + func_80B9F7E4(this, 4, ANIMMODE_ONCE); } else if (gSaveContext.save.weekEventReg[78] & 0x40) { textId = 0x1256; this->unk_304 = 1; - func_80B9F7E4(this, 2, 2); + func_80B9F7E4(this, 2, ANIMMODE_ONCE); } else { textId = 0x1255; gSaveContext.save.weekEventReg[78] |= 0x40; this->unk_304 = 1; - func_80B9F7E4(this, 2, 2); + func_80B9F7E4(this, 2, ANIMMODE_ONCE); } } else { textId = 0x1254; this->unk_304 = 3; - func_80B9F7E4(this, 5, 2); + func_80B9F7E4(this, 5, ANIMMODE_ONCE); } - Message_StartTextbox(globalCtx, textId, &this->actor); + Message_StartTextbox(play, textId, &this->actor); } -void func_80BA09E0(EnZob* this, GlobalContext* globalCtx) { +void func_80BA09E0(EnZob* this, PlayState* play) { func_80B9F86C(this); } -void func_80BA0A04(EnZob* this, GlobalContext* globalCtx) { - u8 temp_v0; - +void func_80BA0A04(EnZob* this, PlayState* play) { 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); + switch (Message_GetState(&play->msgCtx)) { + case TEXT_STATE_5: + if (Message_ShouldAdvance(play)) { + func_801477B4(play); + this->actionFunc = func_80BA0AD8; + this->unk_304 = 0; + func_80B9F7E4(this, 6, ANIMMODE_ONCE); + } + break; + + case TEXT_STATE_CLOSING: this->actionFunc = func_80BA0AD8; this->unk_304 = 0; - func_80B9F7E4(this, 6, 2); - } - } else { - this->actionFunc = func_80BA0AD8; - this->unk_304 = 0; - func_80B9F7E4(this, 6, 2); + func_80B9F7E4(this, 6, ANIMMODE_ONCE); + break; } } -void func_80BA0AD8(EnZob* this, GlobalContext* globalCtx) { +void func_80BA0AD8(EnZob* this, PlayState* play) { func_80B9F86C(this); if (this->actor.home.rot.y != this->actor.shape.rot.y) { @@ -652,25 +653,25 @@ void func_80BA0AD8(EnZob* this, GlobalContext* globalCtx) { this->actor.world.rot.y = this->actor.shape.rot.y; } - if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { + if (Actor_ProcessTalkRequest(&this->actor, &play->state)) { this->actionFunc = func_80BA0A04; - func_80BA08E8(this, globalCtx); - } else if ((this->actor.xzDistToPlayer < 120.0f) && Player_IsFacingActor(&this->actor, 0x3000, globalCtx) && + func_80BA08E8(this, play); + } else if ((this->actor.xzDistToPlayer < 120.0f) && Player_IsFacingActor(&this->actor, 0x3000, play) && Actor_IsFacingPlayer(&this->actor, 0x3000)) { - func_800B8614(&this->actor, globalCtx, 120.0f); + func_800B8614(&this->actor, play, 120.0f); } } -void func_80BA0BB4(EnZob* this, GlobalContext* globalCtx) { +void func_80BA0BB4(EnZob* this, PlayState* play) { func_80B9F86C(this); if (gSaveContext.save.weekEventReg[79] & 1) { this->actionFunc = func_80BA09E0; - func_80B9F7E4(this, 0, 2); + func_80B9F7E4(this, 0, ANIMMODE_ONCE); this->unk_304 = 5; } } -void func_80BA0C14(EnZob* this, GlobalContext* globalCtx) { +void func_80BA0C14(EnZob* this, PlayState* play) { func_80B9F86C(this); if (this->unk_312 < 799) { @@ -683,8 +684,8 @@ void func_80BA0C14(EnZob* this, GlobalContext* globalCtx) { this->unk_312 = 999; } - if (Cutscene_CheckActorAction(globalCtx, 515)) { - if (globalCtx->csCtx.actorActions[Cutscene_GetActorActionIndex(globalCtx, 515)]->action == 1) { + if (Cutscene_CheckActorAction(play, 515)) { + if (play->csCtx.actorActions[Cutscene_GetActorActionIndex(play, 515)]->action == 1) { this->actionFunc = func_80BA0CF4; this->unk_312 = -1; } @@ -694,25 +695,25 @@ void func_80BA0C14(EnZob* this, GlobalContext* globalCtx) { } } -void func_80BA0CF4(EnZob* this, GlobalContext* globalCtx) { +void func_80BA0CF4(EnZob* this, PlayState* play) { func_80B9F86C(this); - if (Cutscene_CheckActorAction(globalCtx, 515) && - (globalCtx->csCtx.actorActions[Cutscene_GetActorActionIndex(globalCtx, 515)]->action == 2)) { + if (Cutscene_CheckActorAction(play, 515) && + (play->csCtx.actorActions[Cutscene_GetActorActionIndex(play, 515)]->action == 2)) { this->actionFunc = func_80BA0C14; } } -void EnZob_Update(Actor* thisx, GlobalContext* globalCtx) { +void EnZob_Update(Actor* thisx, PlayState* play) { 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); + CollisionCheck_SetOC(play, &play->colChkCtx, &this->collider.base); + Actor_UpdateBgCheckInfo(play, &this->actor, 10.0f, 10.0f, 10.0f, 4); - this->actionFunc(this, globalCtx); + this->actionFunc(this, play); if ((this->unk_30E != -1) && (ActorCutscene_GetCurrentIndex() != this->unk_306[this->unk_30E])) { if (ActorCutscene_GetCurrentIndex() == 0x7C) { @@ -726,7 +727,7 @@ void EnZob_Update(Actor* thisx, GlobalContext* globalCtx) { } if (this->unk_2F4 & 1) { - func_800E9250(globalCtx, &this->actor, &this->unk_2F6, &this->unk_2FC, this->actor.focus.pos); + Actor_TrackPlayer(play, &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); @@ -735,7 +736,7 @@ void EnZob_Update(Actor* thisx, GlobalContext* globalCtx) { } } -s32 func_80BA0F64(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, Actor* thisx) { +s32 func_80BA0F64(PlayState* play, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, Actor* thisx) { EnZob* this = THIS; if (limbIndex == 9) { @@ -745,31 +746,31 @@ s32 func_80BA0F64(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* p return false; } -void func_80BA0FAC(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx) { +void func_80BA0FAC(PlayState* play, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx) { EnZob* this = THIS; if (limbIndex == 9) { - Matrix_MultiplyVector3fByState(&D_80BA1120, &this->actor.focus.pos); + Matrix_MultVec3f(&D_80BA1120, &this->actor.focus.pos); } } -void EnZob_Draw(Actor* thisx, GlobalContext* globalCtx) { +void EnZob_Draw(Actor* thisx, PlayState* play) { EnZob* this = THIS; - OPEN_DISPS(globalCtx->state.gfxCtx); + OPEN_DISPS(play->state.gfxCtx); - func_8012C28C(globalCtx->state.gfxCtx); + func_8012C28C(play->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, + SkelAnime_DrawFlexOpa(play, 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); + POLY_OPA_DISP = func_801660B8(play, POLY_OPA_DISP); } - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->state.gfxCtx); } diff --git a/src/overlays/actors/ovl_En_Zob/z_en_zob.h b/src/overlays/actors/ovl_En_Zob/z_en_zob.h index 18834f17e..cd9ccc908 100644 --- a/src/overlays/actors/ovl_En_Zob/z_en_zob.h +++ b/src/overlays/actors/ovl_En_Zob/z_en_zob.h @@ -5,7 +5,7 @@ struct EnZob; -typedef void (*EnZobActionFunc)(struct EnZob*, GlobalContext*); +typedef void (*EnZobActionFunc)(struct EnZob*, PlayState*); #define ENZOB_GET_F(thisx) ((thisx)->params & 0xF) @@ -15,21 +15,21 @@ enum { }; typedef struct EnZob { - /* 0x0000 */ Actor actor; - /* 0x0144 */ SkelAnime skelAnime; - /* 0x0188 */ Vec3s jointTable[24]; - /* 0x0218 */ Vec3s morphTable[24]; - /* 0x02A8 */ ColliderCylinder collider; - /* 0x02F4 */ u16 unk_2F4; - /* 0x02F6 */ Vec3s unk_2F6; - /* 0x02FC */ Vec3s unk_2FC; - /* 0x0302 */ s16 unk_302; - /* 0x0304 */ u16 unk_304; - /* 0x0306 */ s16 unk_306[4]; - /* 0x030E */ s16 unk_30E; - /* 0x0310 */ s16 unk_310; - /* 0x0312 */ s16 unk_312; - /* 0x0314 */ EnZobActionFunc actionFunc; + /* 0x000 */ Actor actor; + /* 0x144 */ SkelAnime skelAnime; + /* 0x188 */ Vec3s jointTable[24]; + /* 0x218 */ Vec3s morphTable[24]; + /* 0x2A8 */ ColliderCylinder collider; + /* 0x2F4 */ u16 unk_2F4; + /* 0x2F6 */ Vec3s unk_2F6; + /* 0x2FC */ Vec3s unk_2FC; + /* 0x302 */ s16 unk_302; + /* 0x304 */ u16 unk_304; + /* 0x306 */ s16 unk_306[4]; + /* 0x30E */ s16 unk_30E; + /* 0x310 */ s16 unk_310; + /* 0x312 */ s16 unk_312; + /* 0x314 */ EnZobActionFunc actionFunc; } EnZob; // size = 0x318 extern const ActorInit En_Zob_InitVars; diff --git a/src/overlays/actors/ovl_En_Zod/z_en_zod.c b/src/overlays/actors/ovl_En_Zod/z_en_zod.c index f908ceafa..d2645b67b 100644 --- a/src/overlays/actors/ovl_En_Zod/z_en_zod.c +++ b/src/overlays/actors/ovl_En_Zod/z_en_zod.c @@ -10,10 +10,10 @@ #define THIS ((EnZod*)thisx) -void EnZod_Init(Actor* thisx, GlobalContext* globalCtx); -void EnZod_Destroy(Actor* thisx, GlobalContext* globalCtx); -void EnZod_Update(Actor* thisx, GlobalContext* globalCtx); -void EnZod_Draw(Actor* thisx, GlobalContext* globalCtx); +void EnZod_Init(Actor* thisx, PlayState* play); +void EnZod_Destroy(Actor* thisx, PlayState* play); +void EnZod_Update(Actor* thisx, PlayState* play); +void EnZod_Draw(Actor* thisx, PlayState* play); #if 0 const ActorInit En_Zod_InitVars = { diff --git a/src/overlays/actors/ovl_En_Zod/z_en_zod.h b/src/overlays/actors/ovl_En_Zod/z_en_zod.h index 7e360a59a..2fd9b7400 100644 --- a/src/overlays/actors/ovl_En_Zod/z_en_zod.h +++ b/src/overlays/actors/ovl_En_Zod/z_en_zod.h @@ -5,12 +5,12 @@ struct EnZod; -typedef void (*EnZodActionFunc)(struct EnZod*, GlobalContext*); +typedef void (*EnZodActionFunc)(struct EnZod*, PlayState*); typedef struct EnZod { - /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x158]; - /* 0x029C */ EnZodActionFunc actionFunc; + /* 0x000 */ Actor actor; + /* 0x144 */ char unk_144[0x158]; + /* 0x29C */ EnZodActionFunc actionFunc; } EnZod; // size = 0x2A0 extern const ActorInit En_Zod_InitVars; diff --git a/src/overlays/actors/ovl_En_Zog/z_en_zog.c b/src/overlays/actors/ovl_En_Zog/z_en_zog.c index f4514a9aa..508734a9b 100644 --- a/src/overlays/actors/ovl_En_Zog/z_en_zog.c +++ b/src/overlays/actors/ovl_En_Zog/z_en_zog.c @@ -11,25 +11,25 @@ #define THIS ((EnZog*)thisx) -void EnZog_Init(Actor* thisx, GlobalContext* globalCtx); -void EnZog_Destroy(Actor* thisx, GlobalContext* globalCtx); -void EnZog_Update(Actor* thisx, GlobalContext* globalCtx); -void EnZog_Draw(Actor* thisx, GlobalContext* globalCtx); +void EnZog_Init(Actor* thisx, PlayState* play); +void EnZog_Destroy(Actor* thisx, PlayState* play); +void EnZog_Update(Actor* thisx, PlayState* play); +void EnZog_Draw(Actor* thisx, PlayState* play); -void func_80B943A0(EnZog* this, GlobalContext* globalCtx); -void func_80B943C0(EnZog* this, GlobalContext* globalCtx); -void func_80B94470(EnZog* this, GlobalContext* globalCtx); -void func_80B9451C(EnZog* this, GlobalContext* globalCtx); -void func_80B9461C(EnZog* this, GlobalContext* globalCtx); -void func_80B946B4(EnZog* this, GlobalContext* globalCtx); -void func_80B946FC(EnZog* this, GlobalContext* globalCtx); -void func_80B948A8(EnZog* this, GlobalContext* globalCtx); -void func_80B94A00(EnZog* this, GlobalContext* globalCtx); -void func_80B94C5C(EnZog* this, GlobalContext* globalCtx); -void func_80B94D0C(EnZog* this, GlobalContext* globalCtx); -void func_80B94E34(EnZog* this, GlobalContext* globalCtx); -void func_80B95128(EnZog* this, GlobalContext* globalCtx); -void func_80B95240(EnZog* this, GlobalContext* globalCtx); +void func_80B943A0(EnZog* this, PlayState* play); +void func_80B943C0(EnZog* this, PlayState* play); +void func_80B94470(EnZog* this, PlayState* play); +void func_80B9451C(EnZog* this, PlayState* play); +void func_80B9461C(EnZog* this, PlayState* play); +void func_80B946B4(EnZog* this, PlayState* play); +void func_80B946FC(EnZog* this, PlayState* play); +void func_80B948A8(EnZog* this, PlayState* play); +void func_80B94A00(EnZog* this, PlayState* play); +void func_80B94C5C(EnZog* this, PlayState* play); +void func_80B94D0C(EnZog* this, PlayState* play); +void func_80B94E34(EnZog* this, PlayState* play); +void func_80B95128(EnZog* this, PlayState* play); +void func_80B95240(EnZog* this, PlayState* play); static u8 D_80B95E10; @@ -127,7 +127,7 @@ static Color_RGBA8 D_80B959A8 = { 80, 80, 220, 255 }; static Vec3f D_80B959AC = { 0.0f, 0.0f, 15.0f }; -void func_80B93310(Actor* thisx, Lights* mapper, GlobalContext* globalCtx) { +void func_80B93310(Actor* thisx, Lights* mapper, PlayState* play) { Vec3f sp34; EnZog* this = THIS; f32 sp2C; @@ -149,23 +149,23 @@ void func_80B93310(Actor* thisx, Lights* mapper, GlobalContext* globalCtx) { } Math_Vec3f_Copy(&this->actor.world.pos, &this->unk_2F0); - func_800B4AEC(globalCtx, &this->actor, 50.0f); + func_800B4AEC(play, &this->actor, 50.0f); if (sp34.y < this->actor.floorHeight) { this->actor.world.pos.y = this->actor.floorHeight; } else { this->actor.world.pos.y = sp34.y; } this->actor.scale.z *= sp2C * (1 / 12.0f); - ActorShadow_DrawCircle(&this->actor, mapper, globalCtx); + ActorShadow_DrawCircle(&this->actor, mapper, play); this->actor.scale.z = this->actor.scale.x; Math_Vec3f_Copy(&this->actor.world.pos, &sp34); } } -void func_80B93468(EnZog* this, GlobalContext* globalCtx) { +void func_80B93468(EnZog* this, PlayState* play) { Vec3s* points; - this->unk_2E8 = &globalCtx->setupPathList[ENZOG_GET_FC00(&this->actor)]; + this->unk_2E8 = &play->setupPathList[ENZOG_GET_FC00(&this->actor)]; if (this->unk_2E8 != NULL) { points = &((Vec3s*)Lib_SegmentedToVirtual(this->unk_2E8->points))[this->unk_2EC]; points++; @@ -177,7 +177,7 @@ void func_80B93468(EnZog* this, GlobalContext* globalCtx) { } } -void EnZog_Init(Actor* thisx, GlobalContext* globalCtx) { +void EnZog_Init(Actor* thisx, PlayState* play) { s32 pad; EnZog* this = THIS; s32 i; @@ -199,15 +199,15 @@ void EnZog_Init(Actor* thisx, GlobalContext* globalCtx) { Actor_SetScale(&this->actor, 0.01f); this->actionFunc = func_80B95128; this->actor.textId = 0x1004; - SkelAnime_InitFlex(globalCtx, &this->skelAnime, &object_zog_Skel_029170, &object_zog_Anim_00FC0C, this->jointTable, + SkelAnime_InitFlex(play, &this->skelAnime, &object_zog_Skel_029170, &object_zog_Anim_00FC0C, this->jointTable, this->morphTable, 23); Animation_PlayOnce(&this->skelAnime, &object_zog_Anim_00FC0C); - Collider_InitAndSetCylinder(globalCtx, &this->collider, &this->actor, &sCylinderInit); + Collider_InitAndSetCylinder(play, &this->collider, &this->actor, &sCylinderInit); this->actor.colChkInfo.mass = MASS_IMMOVABLE; if ((ENZOG_GET_F(&this->actor) != ENZOG_F_2) && (INV_CONTENT(ITEM_MASK_ZORA) == ITEM_MASK_ZORA) && - ((globalCtx->csCtx.currentCsIndex != 2) || (gSaveContext.sceneSetupIndex != 0) || - (globalCtx->sceneNum != SCENE_30GYOSON))) { + ((play->csCtx.currentCsIndex != 2) || (gSaveContext.sceneSetupIndex != 0) || + (play->sceneNum != SCENE_30GYOSON))) { Actor_MarkForDeath(&this->actor); return; } @@ -235,7 +235,7 @@ void EnZog_Init(Actor* thisx, GlobalContext* globalCtx) { this->unk_2EC = 0; if (ENZOG_GET_FC00(&this->actor) != ENZOG_FC00_63) { - func_80B93468(this, globalCtx); + func_80B93468(this, play); } else { this->unk_2E8 = NULL; } @@ -260,7 +260,7 @@ void EnZog_Init(Actor* thisx, GlobalContext* globalCtx) { this->actor.home.rot.z = 0; if (ENZOG_GET_F(&this->actor) != ENZOG_F_2) { for (i = 0; i < 5; i++) { - Actor_SpawnAsChild(&globalCtx->actorCtx, &this->actor, globalCtx, ACTOR_EN_TANRON4, this->actor.world.pos.x, + Actor_SpawnAsChild(&play->actorCtx, &this->actor, play, ACTOR_EN_TANRON4, this->actor.world.pos.x, this->actor.world.pos.y + 500.0f, this->actor.world.pos.z, 0, 0, 0, 100); } } @@ -290,10 +290,10 @@ void EnZog_Init(Actor* thisx, GlobalContext* globalCtx) { } } -void EnZog_Destroy(Actor* thisx, GlobalContext* globalCtx) { +void EnZog_Destroy(Actor* thisx, PlayState* play) { EnZog* this = THIS; - Collider_DestroyCylinder(globalCtx, &this->collider); + Collider_DestroyCylinder(play, &this->collider); } void func_80B939C0(EnZog* this, s16 arg1, u8 arg2) { @@ -302,7 +302,7 @@ void func_80B939C0(EnZog* this, s16 arg1, u8 arg2) { this->unk_304 = arg1; } -void func_80B93A48(EnZog* this, GlobalContext* globalCtx) { +void func_80B93A48(EnZog* this, PlayState* play) { s16* table; if (SkelAnime_Update(&this->skelAnime)) { @@ -346,7 +346,7 @@ void func_80B93BA8(EnZog* this, s16 arg1) { this->unk_30A |= 4; } -s32 func_80B93BE0(EnZog* this, GlobalContext* globalCtx) { +s32 func_80B93BE0(EnZog* this, PlayState* play) { Path* path = this->unk_2E8; s16 temp_v0; Vec3s* points; @@ -368,7 +368,7 @@ s32 func_80B93BE0(EnZog* this, GlobalContext* globalCtx) { if (ABS_ALT(temp_v0 - this->actor.world.rot.y) > 0x4000) { this->unk_2EC++; - func_80B93468(this, globalCtx); + func_80B93468(this, play); if ((this->unk_2EC + 1) >= this->unk_2E8->count) { this->unk_30A |= 1; return true; @@ -380,28 +380,28 @@ s32 func_80B93BE0(EnZog* this, GlobalContext* globalCtx) { return false; } -void func_80B93D2C(EnZog* this, GlobalContext* globalCtx) { +void func_80B93D2C(EnZog* this, PlayState* play) { s32 pad; Vec3f sp28 = this->actor.world.pos; sp28.y += this->actor.depthInWater; this->actor.world.pos.y += (this->actor.depthInWater - 10.0f) + (2.0f * Math_SinS(this->unk_308)); this->unk_308 += 0x200; - if ((globalCtx->gameplayFrames % 16) == 0) { - EffectSsGRipple_Spawn(globalCtx, &sp28, 150, 500, 0); + if ((play->gameplayFrames % 16) == 0) { + EffectSsGRipple_Spawn(play, &sp28, 150, 500, 0); } } -void func_80B93DE8(Vec3f* arg0, GlobalContext* globalCtx, s32 arg2) { +void func_80B93DE8(Vec3f* arg0, PlayState* play, s32 arg2) { Vec3f sp2C; sp2C.x = randPlusMinusPoint5Scaled(30.0f) + arg0->x; sp2C.y = arg0->y + 3.0f; sp2C.z = randPlusMinusPoint5Scaled(30.0f) + arg0->z; - EffectSsKiraKira_SpawnDispersed(globalCtx, &sp2C, &D_80B9598C, &D_80B95998, &D_80B959A4, &D_80B959A8, 1000, arg2); + EffectSsKirakira_SpawnDispersed(play, &sp2C, &D_80B9598C, &D_80B95998, &D_80B959A4, &D_80B959A8, 1000, arg2); } -s32 func_80B93EA0(EnZog* this, GlobalContext* globalCtx) { +s32 func_80B93EA0(EnZog* this, PlayState* play) { s16 sp3E; if (SkelAnime_Update(&this->skelAnime)) { @@ -429,7 +429,7 @@ s32 func_80B93EA0(EnZog* this, GlobalContext* globalCtx) { break; case 17: - Animation_Change(&this->skelAnime, *D_80B958DC, 0.0f, 0.0f, 0.0f, 0, 0.0f); + Animation_Change(&this->skelAnime, *D_80B958DC, 0.0f, 0.0f, 0.0f, ANIMMODE_LOOP, 0.0f); break; } break; @@ -459,13 +459,13 @@ s32 func_80B93EA0(EnZog* this, GlobalContext* globalCtx) { SkelAnime_Update(&this->skelAnime); } - if (Cutscene_CheckActorAction(globalCtx, 471)) { - sp3E = globalCtx->csCtx.actorActions[Cutscene_GetActorActionIndex(globalCtx, 471)]->action; - Cutscene_ActorTranslateAndYaw(&this->actor, globalCtx, Cutscene_GetActorActionIndex(globalCtx, 471)); + if (Cutscene_CheckActorAction(play, 471)) { + sp3E = play->csCtx.actorActions[Cutscene_GetActorActionIndex(play, 471)]->action; + Cutscene_ActorTranslateAndYaw(&this->actor, play, Cutscene_GetActorActionIndex(play, 471)); switch (this->unk_306) { case 2: - if (globalCtx->csCtx.frames == 60) { + if (play->csCtx.frames == 60) { Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_JUMP_SAND); } break; @@ -478,9 +478,9 @@ s32 func_80B93EA0(EnZog* this, GlobalContext* globalCtx) { } if (this->unk_322 > 0) { - func_80B93DE8(&this->unk_2F0, globalCtx, 20); - func_80B93DE8(&this->actor.world.pos, globalCtx, 20); - func_80B93DE8(&this->actor.focus.pos, globalCtx, 20); + func_80B93DE8(&this->unk_2F0, play, 20); + func_80B93DE8(&this->actor.world.pos, play, 20); + func_80B93DE8(&this->actor.focus.pos, play, 20); } break; @@ -503,37 +503,37 @@ s32 func_80B93EA0(EnZog* this, GlobalContext* globalCtx) { switch (this->unk_306) { case 1: - func_80B939C0(this, 7, 0); + func_80B939C0(this, 7, ANIMMODE_LOOP); this->unk_31C = 2; this->unk_31E = 0; break; case 2: - func_80B939C0(this, 11, 2); + func_80B939C0(this, 11, ANIMMODE_ONCE); this->unk_31C = 1; this->unk_31E = 0; break; case 3: - func_80B939C0(this, 15, 2); + func_80B939C0(this, 15, ANIMMODE_ONCE); this->unk_31C = 0; this->unk_31E = 1; break; case 4: - func_80B939C0(this, 13, 2); + func_80B939C0(this, 13, ANIMMODE_ONCE); this->unk_31C = 2; this->unk_31E = 1; break; case 5: - func_80B939C0(this, 16, 2); + func_80B939C0(this, 16, ANIMMODE_ONCE); this->unk_31C = 2; this->unk_31E = 1; break; case 6: - func_80B939C0(this, 8, 2); + func_80B939C0(this, 8, ANIMMODE_ONCE); this->unk_31C = 1; this->unk_31E = 0; break; @@ -546,14 +546,14 @@ s32 func_80B93EA0(EnZog* this, GlobalContext* globalCtx) { case 9: this->unk_322 = 0; this->unk_30A |= 8; - func_80B939C0(this, 18, 0); + func_80B939C0(this, 18, ANIMMODE_LOOP); this->unk_31C = 0; this->unk_31E = 0; this->unk_30A &= ~2; break; case 10: - func_80B939C0(this, 14, 0); + func_80B939C0(this, 14, ANIMMODE_LOOP); this->unk_31C = 0; this->unk_30A |= 2; this->unk_31E = 1; @@ -587,19 +587,19 @@ s32 func_80B93EA0(EnZog* this, GlobalContext* globalCtx) { return false; } -void func_80B943A0(EnZog* this, GlobalContext* globalCtx) { - func_80B93EA0(this, globalCtx); +void func_80B943A0(EnZog* this, PlayState* play) { + func_80B93EA0(this, play); } -void func_80B943C0(EnZog* this, GlobalContext* globalCtx) { +void func_80B943C0(EnZog* this, PlayState* play) { if (!(this->unk_30A & 4)) { this->actionFunc = func_80B943A0; this->unk_306 = -1; } } -void func_80B943EC(EnZog* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); +void func_80B943EC(EnZog* this, PlayState* play) { + Player* player = GET_PLAYER(play); if (this->unk_30A & 0x10) { if (!(player->stateFlags2 & 0x8000000)) { @@ -611,37 +611,38 @@ void func_80B943EC(EnZog* this, GlobalContext* globalCtx) { } } -void func_80B94470(EnZog* this, GlobalContext* globalCtx) { - if (Message_GetState(&globalCtx->msgCtx) == 5) { - if (Message_ShouldAdvance(globalCtx) && (globalCtx->msgCtx.currentTextId == 0x103C)) { - func_801477B4(globalCtx); +void func_80B94470(EnZog* this, PlayState* play) { + if (Message_GetState(&play->msgCtx) == TEXT_STATE_5) { + if (Message_ShouldAdvance(play) && (play->msgCtx.currentTextId == 0x103C)) { + func_801477B4(play); this->actionFunc = func_80B9451C; this->unk_300 = this->unk_302 = 0; this->unk_31C = 2; this->unk_31E = 0; } } - func_80B93A48(this, globalCtx); + func_80B93A48(this, play); } -void func_80B9451C(EnZog* this, GlobalContext* globalCtx) { - if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { +void func_80B9451C(EnZog* this, PlayState* play) { + if (Actor_ProcessTalkRequest(&this->actor, &play->state)) { 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.save.playerForm == PLAYER_FORM_HUMAN)) { + } else if ((play->msgCtx.ocarinaMode == 3) && (this->actor.xzDistToPlayer < 120.0f)) { + if ((play->msgCtx.lastPlayedSong == OCARINA_SONG_HEALING) && + (gSaveContext.save.playerForm == PLAYER_FORM_HUMAN)) { func_80B93BA8(this, 2); this->actionFunc = func_80B943C0; this->actor.shape.shadowDraw = NULL; } } else if (this->actor.xzDistToPlayer < 120.0f) { - func_800B8614(&this->actor, globalCtx, 150.0f); + func_800B8614(&this->actor, play, 150.0f); } - func_80B943EC(this, globalCtx); + func_80B943EC(this, play); } -void func_80B9461C(EnZog* this, GlobalContext* globalCtx) { - if (!func_80B93EA0(this, globalCtx)) { +void func_80B9461C(EnZog* this, PlayState* play) { + if (!func_80B93EA0(this, play)) { this->actor.textId = 0x103C; this->actionFunc = func_80B9451C; this->actor.flags |= ACTOR_FLAG_2000000; @@ -653,52 +654,52 @@ void func_80B9461C(EnZog* this, GlobalContext* globalCtx) { } } -void func_80B946B4(EnZog* this, GlobalContext* globalCtx) { - func_80B93A48(this, globalCtx); +void func_80B946B4(EnZog* this, PlayState* play) { + func_80B93A48(this, play); if (!(this->unk_30A & 4)) { this->actionFunc = func_80B9461C; this->unk_306 = -1; } } -void func_80B946FC(EnZog* this, GlobalContext* globalCtx) { - switch (Message_GetState(&globalCtx->msgCtx)) { - case 4: - if (Message_ShouldAdvance(globalCtx)) { - switch (globalCtx->msgCtx.choiceIndex) { +void func_80B946FC(EnZog* this, PlayState* play) { + switch (Message_GetState(&play->msgCtx)) { + case TEXT_STATE_CHOICE: + if (Message_ShouldAdvance(play)) { + switch (play->msgCtx.choiceIndex) { case 0: func_8019F208(); - globalCtx->msgCtx.unk11F10 = 0; + play->msgCtx.msgLength = 0; this->actionFunc = func_80B946B4; func_80B93BA8(this, 1); break; case 1: func_8019F230(); - func_80151938(globalCtx, 0x1014); + func_80151938(play, 0x1014); break; } } break; - case 5: - if (Message_ShouldAdvance(globalCtx)) { - switch (globalCtx->msgCtx.currentTextId) { + case TEXT_STATE_5: + if (Message_ShouldAdvance(play)) { + switch (play->msgCtx.currentTextId) { case 0x1008: - func_80151938(globalCtx, globalCtx->msgCtx.currentTextId + 1); + func_80151938(play, play->msgCtx.currentTextId + 1); break; case 0x1009: this->unk_300 = 4; - func_80151938(globalCtx, globalCtx->msgCtx.currentTextId + 1); + func_80151938(play, play->msgCtx.currentTextId + 1); break; case 0x1014: - func_80151938(globalCtx, globalCtx->msgCtx.currentTextId + 1); + func_80151938(play, play->msgCtx.currentTextId + 1); break; case 0x1015: - func_801477B4(globalCtx); + func_801477B4(play); this->actionFunc = func_80B948A8; this->unk_300 = this->unk_302 = 0; this->unk_31C = 2; @@ -709,15 +710,16 @@ void func_80B946FC(EnZog* this, GlobalContext* globalCtx) { break; } - func_80B93A48(this, globalCtx); + func_80B93A48(this, play); } -void func_80B948A8(EnZog* this, GlobalContext* globalCtx) { - if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { +void func_80B948A8(EnZog* this, PlayState* play) { + if (Actor_ProcessTalkRequest(&this->actor, &play->state)) { 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.save.playerForm == PLAYER_FORM_HUMAN)) { + } else if ((play->msgCtx.ocarinaMode == 3) && (this->actor.xzDistToPlayer < 120.0f)) { + if ((play->msgCtx.lastPlayedSong == OCARINA_SONG_HEALING) && + (gSaveContext.save.playerForm == PLAYER_FORM_HUMAN)) { func_80B93BA8(this, 2); this->actionFunc = func_80B943C0; this->actor.shape.shadowDraw = NULL; @@ -733,18 +735,18 @@ void func_80B948A8(EnZog* this, GlobalContext* globalCtx) { } if ((this->unk_302 == 0) && (this->actor.xzDistToPlayer < 120.0f)) { - func_800B8614(&this->actor, globalCtx, 150.0f); + func_800B8614(&this->actor, play, 150.0f); } } - func_80B93A48(this, globalCtx); - func_80B943EC(this, globalCtx); + func_80B93A48(this, play); + func_80B943EC(this, play); } -void func_80B94A00(EnZog* this, GlobalContext* globalCtx) { +void func_80B94A00(EnZog* this, PlayState* play) { s32 pad; Vec3f sp30; - if (func_80B93BE0(this, globalCtx)) { + if (func_80B93BE0(this, play)) { this->actionFunc = func_80B948A8; this->actor.flags |= ACTOR_FLAG_2000000; if (gSaveContext.save.weekEventReg[29] & 0x20) { @@ -766,17 +768,17 @@ void func_80B94A00(EnZog* this, GlobalContext* globalCtx) { this->actor.speedXZ = 1.5f; } - if ((this->actor.depthInWater > 0.0f) && ((globalCtx->gameplayFrames % 8) == 0)) { + if ((this->actor.depthInWater > 0.0f) && ((play->gameplayFrames % 8) == 0)) { sp30 = this->actor.world.pos; sp30.y += this->actor.depthInWater; - EffectSsGRipple_Spawn(globalCtx, &sp30, 150, 500, 0); + EffectSsGRipple_Spawn(play, &sp30, 150, 500, 0); } if (this->actor.shape.yOffset > 0.0f) { this->actor.shape.yOffset -= 20.0f; } - func_80B93A48(this, globalCtx); + func_80B93A48(this, play); if ((this->unk_304 == 4) && (Animation_OnFrame(&this->skelAnime, 136.0f) || Animation_OnFrame(&this->skelAnime, 155.0f))) { @@ -793,7 +795,7 @@ void func_80B94A00(EnZog* this, GlobalContext* globalCtx) { } } -void func_80B94C5C(EnZog* this, GlobalContext* globalCtx) { +void func_80B94C5C(EnZog* this, PlayState* play) { this->actor.speedXZ = 0.0f; if (this->unk_304 != 0) { if (this->actor.shape.yOffset > 0.0f) { @@ -812,11 +814,11 @@ void func_80B94C5C(EnZog* this, GlobalContext* globalCtx) { this->actionFunc = func_80B94A00; } - func_80B93A48(this, globalCtx); + func_80B93A48(this, play); } -void func_80B94D0C(EnZog* this, GlobalContext* globalCtx) { - func_80B93D2C(this, globalCtx); +void func_80B94D0C(EnZog* this, PlayState* play) { + func_80B93D2C(this, play); this->actor.speedXZ = 0.0f; if (this->unk_320 > 0) { this->unk_320--; @@ -827,17 +829,17 @@ void func_80B94D0C(EnZog* this, GlobalContext* globalCtx) { this->unk_31E = 0; } - if ((Message_GetState(&globalCtx->msgCtx) == 5) && Message_ShouldAdvance(globalCtx)) { + if ((Message_GetState(&play->msgCtx) == TEXT_STATE_5) && Message_ShouldAdvance(play)) { this->unk_320 = 5; - switch (globalCtx->msgCtx.currentTextId) { + switch (play->msgCtx.currentTextId) { case 0x1004: case 0x1005: case 0x1006: - func_80151938(globalCtx, globalCtx->msgCtx.currentTextId + 1); + func_80151938(play, play->msgCtx.currentTextId + 1); break; case 0x1007: - func_801477B4(globalCtx); + func_801477B4(play); this->actionFunc = func_80B94E34; this->unk_300 = 5; this->unk_320 = 0; @@ -847,15 +849,15 @@ void func_80B94D0C(EnZog* this, GlobalContext* globalCtx) { break; } } - func_80B93A48(this, globalCtx); + func_80B93A48(this, play); } -void func_80B94E34(EnZog* this, GlobalContext* globalCtx) { +void func_80B94E34(EnZog* this, PlayState* play) { s32 pad; - Player* player = GET_PLAYER(globalCtx); + Player* player = GET_PLAYER(play); - func_80B93D2C(this, globalCtx); - func_80B93BE0(this, globalCtx); + func_80B93D2C(this, play); + func_80B93BE0(this, play); if (this->actor.speedXZ < 0.1f) { this->actor.speedXZ = 0.0f; } else { @@ -867,9 +869,9 @@ void func_80B94E34(EnZog* this, GlobalContext* globalCtx) { sp38.x += randPlusMinusPoint5Scaled(30.0f); sp38.y += 20.0f; sp38.z += randPlusMinusPoint5Scaled(30.0f); - if (WaterBox_GetSurface1(globalCtx, &globalCtx->colCtx, sp38.x, sp38.z, &sp38.y, &sp44) && + if (WaterBox_GetSurface1(play, &play->colCtx, sp38.x, sp38.z, &sp38.y, &sp44) && (this->actor.world.pos.y < sp38.y)) { - EffectSsGSplash_Spawn(globalCtx, &sp38, NULL, NULL, 1, + EffectSsGSplash_Spawn(play, &sp38, NULL, NULL, 1, Rand_ZeroFloat(this->actor.speedXZ * 40.0f) + (this->actor.speedXZ * 60.0f)); } @@ -882,14 +884,14 @@ void func_80B94E34(EnZog* this, GlobalContext* globalCtx) { } if (ABS_ALT(this->actor.yawTowardsPlayer - this->actor.world.rot.y) > 0x5000) { - Actor_PickUp(&this->actor, globalCtx, GI_NONE, 60.0f, 40.0f); + Actor_PickUp(&this->actor, play, GI_NONE, 60.0f, 40.0f); } if (this->unk_324 > 0) { this->unk_324--; } - if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { + if (Actor_ProcessTalkRequest(&this->actor, &play->state)) { this->actionFunc = func_80B94D0C; this->actor.speedXZ = 0.0f; this->unk_300 = 2; @@ -907,18 +909,18 @@ void func_80B94E34(EnZog* this, GlobalContext* globalCtx) { 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); + func_800B8614(&this->actor, play, 150.0f); } this->actor.shape.rot.y = this->actor.world.rot.y; - func_80B93A48(this, globalCtx); + func_80B93A48(this, play); } -void func_80B95128(EnZog* this, GlobalContext* globalCtx) { - func_80B93D2C(this, globalCtx); - func_80B93BE0(this, globalCtx); +void func_80B95128(EnZog* this, PlayState* play) { + func_80B93D2C(this, play); + func_80B93BE0(this, play); - if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { + if (Actor_ProcessTalkRequest(&this->actor, &play->state)) { this->actionFunc = func_80B94D0C; this->unk_300 = 2; this->actor.speedXZ = 0.0f; @@ -940,28 +942,28 @@ void func_80B95128(EnZog* this, GlobalContext* globalCtx) { this->actor.flags &= ~ACTOR_FLAG_10000; gSaveContext.save.weekEventReg[91] |= 1; } else { - func_800B8614(&this->actor, globalCtx, 150.0f); + func_800B8614(&this->actor, play, 150.0f); } this->actor.shape.rot.y = this->actor.world.rot.y; - func_80B93A48(this, globalCtx); + func_80B93A48(this, play); } -void func_80B95240(EnZog* this, GlobalContext* globalCtx) { - func_80B93EA0(this, globalCtx); +void func_80B95240(EnZog* this, PlayState* play) { + func_80B93EA0(this, play); } -void EnZog_Update(Actor* thisx, GlobalContext* globalCtx) { +void EnZog_Update(Actor* thisx, PlayState* play) { s32 pad; EnZog* this = THIS; Actor_MoveWithGravity(&this->actor); - Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 10.0f, 10.0f, 10.0f, 5); - if (Cutscene_CheckActorAction(globalCtx, 0x1D7) && (ENZOG_GET_F(&this->actor) != ENZOG_F_2)) { + Actor_UpdateBgCheckInfo(play, &this->actor, 10.0f, 10.0f, 10.0f, 5); + if (Cutscene_CheckActorAction(play, 0x1D7) && (ENZOG_GET_F(&this->actor) != ENZOG_F_2)) { this->actionFunc = func_80B9461C; this->actor.shape.yOffset = 0.0f; } - this->actionFunc(this, globalCtx); + this->actionFunc(this, play); if (((this->unk_304 == 6) && Animation_OnFrame(&this->skelAnime, 43.0f)) || ((this->unk_304 == 17) && Animation_OnFrame(&this->skelAnime, 14.0f))) { @@ -975,7 +977,7 @@ void EnZog_Update(Actor* thisx, GlobalContext* globalCtx) { } else { Collider_UpdateCylinder(&this->actor, &this->collider); } - CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + CollisionCheck_SetOC(play, &play->colChkCtx, &this->collider.base); this->actor.focus.pos = this->actor.world.pos; this->actor.focus.pos.y += 30.0f; @@ -997,41 +999,41 @@ void EnZog_Update(Actor* thisx, GlobalContext* globalCtx) { } } -void EnZog_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx) { +void EnZog_PostLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx) { static Vec3f D_80B959B8 = { 0.0f, 0.0f, 0.0f }; EnZog* this = THIS; D_80B959B8.y = 1000.0f; if (limbIndex == 9) { - Matrix_MultiplyVector3fByState(&D_80B959B8, &this->actor.focus.pos); + 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)) { - OPEN_DISPS(globalCtx->state.gfxCtx); + OPEN_DISPS(play->state.gfxCtx); gSPDisplayList(POLY_OPA_DISP++, object_zog_DL_0280A8); - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->state.gfxCtx); } } -void func_80B95598(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx, Gfx** gfx) { +void func_80B95598(PlayState* play, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx, Gfx** gfx) { static Vec3f D_80B959C4 = { 0.0f, 0.0f, 0.0f }; EnZog* this = THIS; D_80B959C4.y = 1000.0f; if (limbIndex == 9) { - Matrix_MultiplyVector3fByState(&D_80B959C4, &this->actor.focus.pos); + 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)) { @@ -1039,21 +1041,21 @@ void func_80B95598(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* } } -void EnZog_Draw(Actor* thisx, GlobalContext* globalCtx) { +void EnZog_Draw(Actor* thisx, PlayState* play) { EnZog* this = THIS; Gfx* gfx; - OPEN_DISPS(globalCtx->state.gfxCtx); + OPEN_DISPS(play->state.gfxCtx); if (this->unk_30A & 8) { if (this->unk_322 > 128) { gfx = POLY_XLU_DISP++; func_8012C2B4(gfx); - Scene_SetRenderModeXlu(globalCtx, 2, 2); + Scene_SetRenderModeXlu(play, 2, 2); } else { gfx = POLY_XLU_DISP++; func_8012C304(gfx); - Scene_SetRenderModeXlu(globalCtx, 1, 2); + Scene_SetRenderModeXlu(play, 1, 2); } gfx = POLY_XLU_DISP; @@ -1064,11 +1066,11 @@ void EnZog_Draw(Actor* thisx, GlobalContext* globalCtx) { POLY_XLU_DISP = &gfx[3]; POLY_XLU_DISP = - SkelAnime_DrawFlex(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, - this->skelAnime.dListCount, NULL, func_80B95598, &this->actor, POLY_XLU_DISP); + SkelAnime_DrawFlex(play, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, + NULL, func_80B95598, &this->actor, POLY_XLU_DISP); } else { - func_8012C28C(globalCtx->state.gfxCtx); - Scene_SetRenderModeXlu(globalCtx, 0, 1); + func_8012C28C(play->state.gfxCtx); + Scene_SetRenderModeXlu(play, 0, 1); gfx = POLY_OPA_DISP; @@ -1077,9 +1079,9 @@ void EnZog_Draw(Actor* thisx, GlobalContext* globalCtx) { gDPSetEnvColor(&gfx[2], 0, 0, 0, 255); POLY_OPA_DISP = &gfx[3]; - SkelAnime_DrawFlexOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, - this->skelAnime.dListCount, NULL, EnZog_PostLimbDraw, &this->actor); + SkelAnime_DrawFlexOpa(play, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, + NULL, EnZog_PostLimbDraw, &this->actor); } - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->state.gfxCtx); } diff --git a/src/overlays/actors/ovl_En_Zog/z_en_zog.h b/src/overlays/actors/ovl_En_Zog/z_en_zog.h index 7dba946d5..e649c52ab 100644 --- a/src/overlays/actors/ovl_En_Zog/z_en_zog.h +++ b/src/overlays/actors/ovl_En_Zog/z_en_zog.h @@ -5,7 +5,7 @@ struct EnZog; -typedef void (*EnZogActionFunc)(struct EnZog*, GlobalContext*); +typedef void (*EnZogActionFunc)(struct EnZog*, PlayState*); #define ENZOG_GET_F(thisx) ((thisx)->params & 0xF) #define ENZOG_GET_FC00(thisx) (((thisx)->params & 0xFC00) >> 0xA) 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 61be7c8e7..f20b953ba 100644 --- a/src/overlays/actors/ovl_En_Zoraegg/z_en_zoraegg.c +++ b/src/overlays/actors/ovl_En_Zoraegg/z_en_zoraegg.c @@ -12,31 +12,31 @@ #define THIS ((EnZoraegg*)thisx) -void EnZoraegg_Init(Actor* thisx, GlobalContext* globalCtx); -void EnZoraegg_Destroy(Actor* thisx, GlobalContext* globalCtx); -void EnZoraegg_Update(Actor* thisx, GlobalContext* globalCtx); -void EnZoraegg_Draw(Actor* thisx, GlobalContext* globalCtx); +void EnZoraegg_Init(Actor* thisx, PlayState* play); +void EnZoraegg_Destroy(Actor* thisx, PlayState* play); +void EnZoraegg_Update(Actor* thisx, PlayState* play); +void EnZoraegg_Draw(Actor* thisx, PlayState* play); -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); +s32 func_80B319A8(PlayState* play); +void func_80B32084(EnZoraegg* this, PlayState* play); +void func_80B32094(EnZoraegg* this, PlayState* play); +void func_80B320E0(EnZoraegg* this, PlayState* play); +void func_80B321D0(EnZoraegg* this, PlayState* play); +void func_80B32228(EnZoraegg* this, PlayState* play); +void func_80B322BC(EnZoraegg* this, PlayState* play); +void func_80B32390(EnZoraegg* this, PlayState* play); +void func_80B324B0(EnZoraegg* this, PlayState* play); +void func_80B32644(EnZoraegg* this, PlayState* play); +void func_80B326F4(EnZoraegg* this, PlayState* play); +void func_80B32820(EnZoraegg* this, PlayState* play); +void func_80B32928(EnZoraegg* this, PlayState* play); +void func_80B32A88(EnZoraegg* this, PlayState* play); +void func_80B32B10(EnZoraegg* this, PlayState* play); +void func_80B32B3C(EnZoraegg* this, PlayState* play); +void func_80B32B70(EnZoraegg* this, PlayState* play); +void func_80B32BB8(EnZoraegg* this, PlayState* play); +void func_80B32C34(EnZoraegg* this, PlayState* play); +void func_80B32D08(EnZoraegg* this, PlayState* play); const ActorInit En_Zoraegg_InitVars = { ACTOR_EN_ZORAEGG, @@ -72,13 +72,13 @@ void func_80B31590(EnZoraegg* this) { this->actor.shape.rot.x = this->actor.shape.rot.z; } -void EnZoraegg_Init(Actor* thisx, GlobalContext* globalCtx) { +void EnZoraegg_Init(Actor* thisx, PlayState* play) { s32 pad; EnZoraegg* this = THIS; u16 sp40[] = { 457, 458, 459, 460, 461, 462, 464 }; Actor_SetScale(&this->actor, 0.006f); - SkelAnime_InitFlex(globalCtx, &this->skelAnime, &object_zoraegg_Skel_004C90, &object_zoraegg_Anim_005098, + SkelAnime_InitFlex(play, &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); @@ -96,41 +96,41 @@ void EnZoraegg_Init(Actor* thisx, GlobalContext* globalCtx) { this->actor.gravity = -5.0f; switch (ENZORAEGG_GET_1F(&this->actor)) { - case ENZORAEGG_1F_0: - if (Flags_GetSwitch(globalCtx, ENZORAEGG_GET_FE00(&this->actor))) { + case ENZORAEGG_1F_00: + if (Flags_GetSwitch(play, ENZORAEGG_GET_FE00(&this->actor))) { Actor_MarkForDeath(&this->actor); return; } break; - case ENZORAEGG_1F_17: - if (func_80B319A8(globalCtx) >= 7) { + case ENZORAEGG_1F_11: + if (func_80B319A8(play) >= 7) { Actor_MarkForDeath(&this->actor); this->actor.home.rot.z = 1; return; } break; - case ENZORAEGG_1F_3: - case ENZORAEGG_1F_4: - case ENZORAEGG_1F_5: - case ENZORAEGG_1F_6: - case ENZORAEGG_1F_7: - case ENZORAEGG_1F_8: - case ENZORAEGG_1F_9: + case ENZORAEGG_1F_03: + case ENZORAEGG_1F_04: + case ENZORAEGG_1F_05: + case ENZORAEGG_1F_06: + case ENZORAEGG_1F_07: + case ENZORAEGG_1F_08: + case ENZORAEGG_1F_09: if (gSaveContext.save.weekEventReg[19] & 0x40) { Actor_MarkForDeath(&this->actor); return; } break; + case ENZORAEGG_1F_0A: + case ENZORAEGG_1F_0B: + case ENZORAEGG_1F_0C: + case ENZORAEGG_1F_0D: + case ENZORAEGG_1F_0E: + case ENZORAEGG_1F_0F: case ENZORAEGG_1F_10: - case ENZORAEGG_1F_11: - case ENZORAEGG_1F_12: - case ENZORAEGG_1F_13: - case ENZORAEGG_1F_14: - case ENZORAEGG_1F_15: - case ENZORAEGG_1F_16: if (!(gSaveContext.save.weekEventReg[19] & 0x40)) { Actor_MarkForDeath(&this->actor); return; @@ -139,49 +139,49 @@ void EnZoraegg_Init(Actor* thisx, GlobalContext* globalCtx) { } switch (ENZORAEGG_GET_1F(&this->actor)) { - case ENZORAEGG_1F_0: + case ENZORAEGG_1F_00: this->actionFunc = func_80B320E0; this->actor.flags |= (ACTOR_FLAG_1 | ACTOR_FLAG_8); this->actor.targetMode = 3; break; - case ENZORAEGG_1F_1: + case ENZORAEGG_1F_01: this->actionFunc = func_80B322BC; func_80B31590(this); break; - case ENZORAEGG_1F_2: + case ENZORAEGG_1F_02: this->actionFunc = func_80B32390; func_80B31590(this); break; - case ENZORAEGG_1F_3: - case ENZORAEGG_1F_4: - case ENZORAEGG_1F_5: - case ENZORAEGG_1F_6: - case ENZORAEGG_1F_7: - case ENZORAEGG_1F_8: - case ENZORAEGG_1F_9: - this->actorActionCmd = sp40[(ENZORAEGG_GET_1F(&this->actor)) - ENZORAEGG_1F_3]; + case ENZORAEGG_1F_03: + case ENZORAEGG_1F_04: + case ENZORAEGG_1F_05: + case ENZORAEGG_1F_06: + case ENZORAEGG_1F_07: + case ENZORAEGG_1F_08: + case ENZORAEGG_1F_09: + this->actorActionCmd = sp40[(ENZORAEGG_GET_1F(&this->actor)) - ENZORAEGG_1F_03]; Animation_PlayOnce(&this->skelAnime, &object_zoraegg_Anim_001E08); this->unk_1EC = 1; this->unk_1EE = 0; this->unk_1EF = 0; this->actionFunc = func_80B32B10; - if (((ENZORAEGG_GET_1F(&this->actor)) - ENZORAEGG_1F_3) >= func_80B319A8(globalCtx)) { + if (((ENZORAEGG_GET_1F(&this->actor)) - ENZORAEGG_1F_03) >= func_80B319A8(play)) { this->actionFunc = func_80B32B3C; this->actor.draw = NULL; } break; + case ENZORAEGG_1F_0A: + case ENZORAEGG_1F_0B: + case ENZORAEGG_1F_0C: + case ENZORAEGG_1F_0D: + case ENZORAEGG_1F_0E: + case ENZORAEGG_1F_0F: case ENZORAEGG_1F_10: - case ENZORAEGG_1F_11: - case ENZORAEGG_1F_12: - case ENZORAEGG_1F_13: - case ENZORAEGG_1F_14: - case ENZORAEGG_1F_15: - case ENZORAEGG_1F_16: - this->actorActionCmd = sp40[(ENZORAEGG_GET_1F(&this->actor)) - ENZORAEGG_1F_10]; + this->actorActionCmd = sp40[(ENZORAEGG_GET_1F(&this->actor)) - ENZORAEGG_1F_0A]; this->unk_1EC = 2; this->actionFunc = func_80B324B0; Animation_PlayLoop(&this->skelAnime, &object_zoraegg_Anim_004FE4); @@ -190,7 +190,7 @@ void EnZoraegg_Init(Actor* thisx, GlobalContext* globalCtx) { this->unk_1EA |= 3; break; - case ENZORAEGG_1F_17: + case ENZORAEGG_1F_11: Actor_SetScale(&this->actor, 0.0006f); this->actionFunc = func_80B32D08; this->actor.world.pos.y -= this->actor.shape.yOffset * this->actor.scale.y; @@ -202,17 +202,17 @@ void EnZoraegg_Init(Actor* thisx, GlobalContext* globalCtx) { } } -void EnZoraegg_Destroy(Actor* thisx, GlobalContext* globalCtx) { +void EnZoraegg_Destroy(Actor* thisx, PlayState* play) { } -s32 func_80B319A8(GlobalContext* globalCtx) { - return gSaveContext.save.permanentSceneFlags[globalCtx->sceneNum].unk_14 & 7; +s32 func_80B319A8(PlayState* play) { + return gSaveContext.save.permanentSceneFlags[play->sceneNum].unk_14 & 7; } -void func_80B319D0(GlobalContext* globalCtx, s32 arg1) { +void func_80B319D0(PlayState* play, s32 arg1) { if ((arg1 < 8) && (arg1 >= 0)) { - gSaveContext.save.permanentSceneFlags[globalCtx->sceneNum].unk_14 &= ~7; - gSaveContext.save.permanentSceneFlags[globalCtx->sceneNum].unk_14 |= arg1; + gSaveContext.save.permanentSceneFlags[play->sceneNum].unk_14 &= ~7; + gSaveContext.save.permanentSceneFlags[play->sceneNum].unk_14 |= arg1; } } @@ -240,18 +240,18 @@ void func_80B31A34(EnZoraegg* this) { } } -void func_80B31C40(EnZoraegg* this, GlobalContext* globalCtx) { +void func_80B31C40(EnZoraegg* this, PlayState* play) { Actor_MoveWithGravity(&this->actor); Math_Vec3f_Copy(&this->actor.focus.pos, &this->actor.world.pos); this->actor.focus.pos.y += 10.0f; - Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 0.0f, 0.0f, 0.0f, 4); + Actor_UpdateBgCheckInfo(play, &this->actor, 0.0f, 0.0f, 0.0f, 4); } -Actor* func_80B31CB4(GlobalContext* globalCtx) { - Actor* actor = globalCtx->actorCtx.actorLists[ACTORCAT_ITEMACTION].first; +Actor* func_80B31CB4(PlayState* play) { + Actor* actor = play->actorCtx.actorLists[ACTORCAT_ITEMACTION].first; while (actor != NULL) { - if ((actor->id == ACTOR_EN_ZORAEGG) && (ENZORAEGG_GET_1F(actor) == ENZORAEGG_1F_17) && + if ((actor->id == ACTOR_EN_ZORAEGG) && (ENZORAEGG_GET_1F(actor) == ENZORAEGG_1F_11) && (actor->home.rot.z == 0)) { actor->home.rot.z = 1; return actor; @@ -261,11 +261,11 @@ Actor* func_80B31CB4(GlobalContext* globalCtx) { return NULL; } -Actor* func_80B31D14(GlobalContext* globalCtx) { - Actor* actor = globalCtx->actorCtx.actorLists[ACTORCAT_ITEMACTION].first; +Actor* func_80B31D14(PlayState* play) { + Actor* actor = play->actorCtx.actorLists[ACTORCAT_ITEMACTION].first; while (actor != NULL) { - if ((actor->id == ACTOR_EN_ZORAEGG) && (ENZORAEGG_GET_1F(actor) == ENZORAEGG_1F_3)) { + if ((actor->id == ACTOR_EN_ZORAEGG) && (ENZORAEGG_GET_1F(actor) == ENZORAEGG_1F_03)) { return actor; } actor = actor->next; @@ -273,13 +273,13 @@ Actor* func_80B31D14(GlobalContext* globalCtx) { return NULL; } -void func_80B31D64(EnZoraegg* this, GlobalContext* globalCtx, s32 arg2, f32 arg3) { +void func_80B31D64(EnZoraegg* this, PlayState* play, s32 arg2, f32 arg3) { Vec3f sp24 = this->actor.world.pos; sp24.y += arg3; - if ((globalCtx->gameplayFrames & arg2) == 0) { - EffectSsBubble_Spawn(globalCtx, &this->actor.world.pos, 0.0f, 0.0f, 10.0f, 0.13f); + if ((play->gameplayFrames & arg2) == 0) { + EffectSsBubble_Spawn(play, &this->actor.world.pos, 0.0f, 0.0f, 10.0f, 0.13f); } } @@ -322,45 +322,45 @@ void func_80B31E00(EnZoraegg* this) { } } -void func_80B32084(EnZoraegg* this, GlobalContext* globalCtx) { +void func_80B32084(EnZoraegg* this, PlayState* play) { } -void func_80B32094(EnZoraegg* this, GlobalContext* globalCtx) { - if (Message_GetState(&globalCtx->msgCtx) == 2) { +void func_80B32094(EnZoraegg* this, PlayState* play) { + if (Message_GetState(&play->msgCtx) == TEXT_STATE_CLOSING) { this->actionFunc = func_80B320E0; } - func_80B31C40(this, globalCtx); + func_80B31C40(this, play); } -void func_80B320E0(EnZoraegg* this, GlobalContext* globalCtx) { - if (Actor_HasParent(&this->actor, globalCtx)) { - Flags_SetSwitch(globalCtx, ENZORAEGG_GET_FE00(&this->actor)); +void func_80B320E0(EnZoraegg* this, PlayState* play) { + if (Actor_HasParent(&this->actor, play)) { + Flags_SetSwitch(play, ENZORAEGG_GET_FE00(&this->actor)); Actor_MarkForDeath(&this->actor); - } else if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { + } else if (Actor_ProcessTalkRequest(&this->actor, &play->state)) { this->actionFunc = func_80B32094; - Message_StartTextbox(globalCtx, 0x24B, &this->actor); + Message_StartTextbox(play, 0x24B, &this->actor); } else { - Actor_PickUp(&this->actor, globalCtx, GI_MAX, 80.0f, 60.0f); + Actor_PickUp(&this->actor, play, GI_MAX, 80.0f, 60.0f); if (this->actor.isTargeted) { - func_800B8614(&this->actor, globalCtx, 110.0f); + func_800B8614(&this->actor, play, 110.0f); } } this->actor.flags |= (ACTOR_FLAG_1 | ACTOR_FLAG_8); this->actor.targetMode = 3; - func_80B31C40(this, globalCtx); + func_80B31C40(this, play); } -void func_80B321D0(EnZoraegg* this, GlobalContext* globalCtx) { +void func_80B321D0(EnZoraegg* this, PlayState* play) { if (ActorCutscene_GetCurrentIndex() != this->actor.cutscene) { this->actionFunc = func_80B322BC; - func_80B319D0(globalCtx, func_80B319A8(globalCtx) + 1); + func_80B319D0(play, func_80B319A8(play) + 1); } } -void func_80B32228(EnZoraegg* this, GlobalContext* globalCtx) { +void func_80B32228(EnZoraegg* this, PlayState* play) { s32 pad; - Player* player = GET_PLAYER(globalCtx); + Player* player = GET_PLAYER(play); if (ActorCutscene_GetCanPlayNext(this->actor.cutscene)) { ActorCutscene_StartAndSetUnkLinkFields(this->actor.cutscene, this->unk_1DC); @@ -378,11 +378,11 @@ void func_80B32228(EnZoraegg* this, GlobalContext* globalCtx) { } } -void func_80B322BC(EnZoraegg* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); +void func_80B322BC(EnZoraegg* this, PlayState* play) { + Player* player = GET_PLAYER(play); if (this->actor.cutscene != -1) { - this->unk_1DC = func_80B31CB4(globalCtx); + this->unk_1DC = func_80B31CB4(play); if (this->unk_1DC != NULL) { this->unk_1E8 = 3; this->actionFunc = func_80B32228; @@ -392,23 +392,23 @@ void func_80B322BC(EnZoraegg* this, GlobalContext* globalCtx) { 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); + func_8012300C(play, 25); } } -void func_80B32390(EnZoraegg* this, GlobalContext* globalCtx) { +void func_80B32390(EnZoraegg* this, PlayState* play) { s32 pad; - Player* player = GET_PLAYER(globalCtx); + Player* player = GET_PLAYER(play); if (ActorCutscene_GetCanPlayNext(this->actor.cutscene)) { - Actor* temp_v0 = func_80B31D14(globalCtx); + Actor* temp_v0 = func_80B31D14(play); 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) && + } else if ((func_80B319A8(play) >= 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)) { @@ -416,28 +416,25 @@ void func_80B32390(EnZoraegg* this, GlobalContext* globalCtx) { } } -void func_80B324B0(EnZoraegg* this, GlobalContext* globalCtx) { +void func_80B324B0(EnZoraegg* this, PlayState* play) { SkelAnime_Update(&this->skelAnime); - if (Cutscene_CheckActorAction(globalCtx, this->actorActionCmd)) { + if (Cutscene_CheckActorAction(play, this->actorActionCmd)) { if (this->unk_1EA & 4) { - if (Cutscene_CheckActorAction(globalCtx, this->actorActionCmd) && - (globalCtx->csCtx.actorActions[Cutscene_GetActorActionIndex(globalCtx, this->actorActionCmd)]->action == - 3)) { + if (Cutscene_CheckActorAction(play, this->actorActionCmd) && + (play->csCtx.actorActions[Cutscene_GetActorActionIndex(play, 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)) { + if (Cutscene_CheckActorAction(play, this->actorActionCmd) && + (play->csCtx.actorActions[Cutscene_GetActorActionIndex(play, 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)); + Cutscene_ActorTranslateAndYaw(&this->actor, play, Cutscene_GetActorActionIndex(play, 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); @@ -449,18 +446,17 @@ void func_80B324B0(EnZoraegg* this, GlobalContext* globalCtx) { } } -void func_80B32644(EnZoraegg* this, GlobalContext* globalCtx) { +void func_80B32644(EnZoraegg* this, PlayState* play) { 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)) { + if (!Cutscene_CheckActorAction(play, this->actorActionCmd)) { this->actionFunc = func_80B324B0; } else { - Cutscene_ActorTranslateAndYaw(&this->actor, globalCtx, - Cutscene_GetActorActionIndex(globalCtx, this->actorActionCmd)); + Cutscene_ActorTranslateAndYaw(&this->actor, play, Cutscene_GetActorActionIndex(play, this->actorActionCmd)); if (this->unk_1EE > 25) { this->unk_1EE -= 25; @@ -470,13 +466,13 @@ void func_80B32644(EnZoraegg* this, GlobalContext* globalCtx) { } } -void func_80B326F4(EnZoraegg* this, GlobalContext* globalCtx) { +void func_80B326F4(EnZoraegg* this, PlayState* play) { SkelAnime_Update(&this->skelAnime); - if (Cutscene_CheckActorAction(globalCtx, this->actorActionCmd) && - (globalCtx->csCtx.actorActions[Cutscene_GetActorActionIndex(globalCtx, this->actorActionCmd)]->action == 3)) { + if (Cutscene_CheckActorAction(play, this->actorActionCmd) && + (play->csCtx.actorActions[Cutscene_GetActorActionIndex(play, this->actorActionCmd)]->action == 3)) { Animation_Change(&this->skelAnime, &object_zoraegg_Anim_004D20, 1.0f, 0.0f, - Animation_GetLastFrame(&object_zoraegg_Anim_004D20), 2, 5.0f); + Animation_GetLastFrame(&object_zoraegg_Anim_004D20), ANIMMODE_ONCE, 5.0f); this->unk_1E8 = 0; this->actionFunc = func_80B32644; gSaveContext.save.weekEventReg[19] |= 0x40; @@ -485,20 +481,19 @@ void func_80B326F4(EnZoraegg* this, GlobalContext* globalCtx) { Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_ZORA_KIDS_SWIM_2); } - Cutscene_ActorTranslateAndYaw(&this->actor, globalCtx, - Cutscene_GetActorActionIndex(globalCtx, this->actorActionCmd)); + Cutscene_ActorTranslateAndYaw(&this->actor, play, Cutscene_GetActorActionIndex(play, 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) { +void func_80B32820(EnZoraegg* this, PlayState* play) { 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); + Animation_GetLastFrame(&object_zoraegg_Anim_005098), ANIMMODE_LOOP, 10.0f); this->unk_1E8 = 0; SkelAnime_Update(&this->skelAnime); return; @@ -509,15 +504,14 @@ void func_80B32820(EnZoraegg* this, GlobalContext* globalCtx) { SkelAnime_Update(&this->skelAnime); } - Cutscene_ActorTranslateAndYaw(&this->actor, globalCtx, - Cutscene_GetActorActionIndex(globalCtx, this->actorActionCmd)); + Cutscene_ActorTranslateAndYaw(&this->actor, play, Cutscene_GetActorActionIndex(play, 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) { +void func_80B32928(EnZoraegg* this, PlayState* play) { if (this->unk_1E8 < 112) { this->unk_1E8++; } @@ -536,16 +530,15 @@ void func_80B32928(EnZoraegg* this, GlobalContext* globalCtx) { 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); + func_80B31D64(this, play, 0, 0.0f); + func_80B31D64(this, play, 0, 0.0f); + func_80B31D64(this, play, 0, 0.0f); } else { - func_80B31D64(this, globalCtx, 0xD, 0.0f); + func_80B31D64(this, play, 0xD, 0.0f); } } - Cutscene_ActorTranslateAndYaw(&this->actor, globalCtx, - Cutscene_GetActorActionIndex(globalCtx, this->actorActionCmd)); + Cutscene_ActorTranslateAndYaw(&this->actor, play, Cutscene_GetActorActionIndex(play, this->actorActionCmd)); if (Animation_OnFrame(&this->skelAnime, 97.0f) || Animation_OnFrame(&this->skelAnime, 101.0f) || Animation_OnFrame(&this->skelAnime, 105.0f)) { @@ -553,49 +546,49 @@ void func_80B32928(EnZoraegg* this, GlobalContext* globalCtx) { } } -void func_80B32A88(EnZoraegg* this, GlobalContext* globalCtx) { - if (Cutscene_CheckActorAction(globalCtx, this->actorActionCmd) && - (globalCtx->csCtx.actorActions[Cutscene_GetActorActionIndex(globalCtx, this->actorActionCmd)]->action == 2)) { +void func_80B32A88(EnZoraegg* this, PlayState* play) { + if (Cutscene_CheckActorAction(play, this->actorActionCmd) && + (play->csCtx.actorActions[Cutscene_GetActorActionIndex(play, this->actorActionCmd)]->action == 2)) { this->unk_1E8 = 0; this->actionFunc = func_80B32928; } - func_80B31D64(this, globalCtx, 13, 0.0f); + func_80B31D64(this, play, 13, 0.0f); } -void func_80B32B10(EnZoraegg* this, GlobalContext* globalCtx) { +void func_80B32B10(EnZoraegg* this, PlayState* play) { if (gSaveContext.eventInf[3] & 8) { this->actionFunc = func_80B32A88; } } -void func_80B32B3C(EnZoraegg* this, GlobalContext* globalCtx) { +void func_80B32B3C(EnZoraegg* this, PlayState* play) { 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)) { +void func_80B32B70(EnZoraegg* this, PlayState* play) { + func_80B31C40(this, play); + if (Cutscene_CheckActorAction(play, 0x1C9)) { Actor_MarkForDeath(&this->actor); } } -void func_80B32BB8(EnZoraegg* this, GlobalContext* globalCtx) { - func_80B31C40(this, globalCtx); - func_80B31D64(this, globalCtx, 13, 0.0f); +void func_80B32BB8(EnZoraegg* this, PlayState* play) { + func_80B31C40(this, play); + func_80B31D64(this, play, 13, 0.0f); if (this->actor.bgCheckFlags & 0x1) { this->actionFunc = func_80B32B70; } - if (Cutscene_CheckActorAction(globalCtx, 0x1C9)) { + if (Cutscene_CheckActorAction(play, 0x1C9)) { Actor_MarkForDeath(&this->actor); } } -void func_80B32C34(EnZoraegg* this, GlobalContext* globalCtx) { +void func_80B32C34(EnZoraegg* this, PlayState* play) { WaterBox* sp34; f32 sp30; s32 pad; @@ -605,18 +598,17 @@ void func_80B32C34(EnZoraegg* this, GlobalContext* globalCtx) { 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 (WaterBox_GetSurface1(play, &play->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); + func_80B31D64(this, play, 0, -20.0f); + func_80B31D64(this, play, 0, -20.0f); } } -void func_80B32D08(EnZoraegg* this, GlobalContext* globalCtx) { +void func_80B32D08(EnZoraegg* this, PlayState* play) { WaterBox* sp44; f32 sp40; Vec3f sp34; @@ -627,15 +619,14 @@ void func_80B32D08(EnZoraegg* this, GlobalContext* globalCtx) { 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 (WaterBox_GetSurface1(play, &play->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); + EffectSsGRipple_Spawn(play, &sp34, 150, 500, 0); + EffectSsGSplash_Spawn(play, &sp34, NULL, NULL, 0, 200); Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_DIVE_INTO_WATER_L); this->actionFunc = func_80B32C34; @@ -654,10 +645,10 @@ void func_80B32D08(EnZoraegg* this, GlobalContext* globalCtx) { } } -void EnZoraegg_Update(Actor* thisx, GlobalContext* globalCtx) { +void EnZoraegg_Update(Actor* thisx, PlayState* play) { EnZoraegg* this = THIS; - this->actionFunc(this, globalCtx); + this->actionFunc(this, play); if (DECR(this->unk_1F4) == 0) { this->unk_1F4 = Rand_S16Offset(60, 60); @@ -669,7 +660,7 @@ void EnZoraegg_Update(Actor* thisx, GlobalContext* globalCtx) { } } -void func_80B32F04(Actor* thisx, GlobalContext* globalCtx) { +void func_80B32F04(Actor* thisx, PlayState* play) { f32 sp7C; f32 sp78; f32 sp74; @@ -682,9 +673,9 @@ void func_80B32F04(Actor* thisx, GlobalContext* globalCtx) { Vec3f sp4C; s32 pad2; - Matrix_StatePush(); + Matrix_Push(); - sp4C = GET_ACTIVE_CAM(globalCtx)->eye; + sp4C = GET_ACTIVE_CAM(play)->eye; sp62 = Math_Vec3f_Yaw(&sp4C, &this->actor.focus.pos); sp60 = -Math_Vec3f_Pitch(&sp4C, &this->actor.focus.pos); @@ -693,16 +684,16 @@ void func_80B32F04(Actor* thisx, GlobalContext* globalCtx) { sp78 = -(15.0f * Math_SinS(sp60)); sp7C = -((15.0f * Math_CosS(sp62)) * Math_CosS(sp60)); - Matrix_InsertTranslation(this->actor.world.pos.x + sp74, this->actor.world.pos.y + sp78 + 6.0f, - temp_f2 = this->actor.world.pos.z + sp7C, 0); + 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); + sp7C = Math_SinS(play->gameplayFrames * 0x4000); Matrix_Scale(this->actor.scale.x * (((sp7C + 1.0f) * 0.1f) + 9.0f), this->actor.scale.y * (((sp7C + 1.0f) * 0.1f) + 9.0f), - this->actor.scale.z * (((sp7C + 1.0f) * 0.1f) + 9.0f), 1); + this->actor.scale.z * (((sp7C + 1.0f) * 0.1f) + 9.0f), MTXMODE_APPLY); - OPEN_DISPS(globalCtx->state.gfxCtx); + OPEN_DISPS(play->state.gfxCtx); gfx = POLY_XLU_DISP; gfx = func_8012C868(gfx); @@ -711,49 +702,48 @@ void func_80B32F04(Actor* thisx, GlobalContext* globalCtx) { 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); + gSPMatrix(gfx++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(gfx++, gameplay_keep_DL_029CF0); POLY_XLU_DISP = gfx; - Matrix_StatePop(); + Matrix_Pop(); - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->state.gfxCtx); } -void func_80B331C8(Actor* thisx, GlobalContext* globalCtx) { +void func_80B331C8(Actor* thisx, PlayState* play) { EnZoraegg* this = THIS; - OPEN_DISPS(globalCtx->state.gfxCtx); + OPEN_DISPS(play->state.gfxCtx); - Matrix_StatePush(); + 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); + func_8012C28C(play->state.gfxCtx); - gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(play->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); + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gDPSetRenderMode(POLY_XLU_DISP++, G_RM_FOG_SHADE_A, G_RM_AA_ZB_XLU_SURF2); gDPSetEnvColor(POLY_XLU_DISP++, 0, 0, 0, this->unk_1ED); gSPDisplayList(POLY_XLU_DISP++, object_zoraegg_DL_005250); } - Matrix_StatePop(); + Matrix_Pop(); - func_80B32F04(thisx, globalCtx); + func_80B32F04(thisx, play); - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->state.gfxCtx); } -s32 EnZoraegg_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, - Actor* thisx) { +s32 EnZoraegg_OverrideLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, Actor* thisx) { EnZoraegg* this = THIS; switch (this->unk_1EC) { @@ -772,21 +762,21 @@ s32 EnZoraegg_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dL return false; } -void func_80B333DC(GlobalContext* globalCtx, Gfx** dList, f32 arg2) { - Matrix_StatePush(); +void func_80B333DC(PlayState* play, Gfx** dList, f32 arg2) { + Matrix_Push(); Matrix_Scale(arg2, arg2, arg2, MTXMODE_APPLY); - OPEN_DISPS(globalCtx->state.gfxCtx); + OPEN_DISPS(play->state.gfxCtx); - gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(play->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); + CLOSE_DISPS(play->state.gfxCtx); } -void EnZoraegg_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx) { +void EnZoraegg_PostLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx) { EnZoraegg* this = THIS; f32 temp_f20; f32 temp_f2; @@ -796,26 +786,26 @@ void EnZoraegg_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList switch (limbIndex) { case 2: temp_f20 = this->unk_1EE * 0.01f; - Matrix_StatePush(); + Matrix_Push(); Matrix_Scale(temp_f20, temp_f20, temp_f20, MTXMODE_APPLY); - OPEN_DISPS(globalCtx->state.gfxCtx); + OPEN_DISPS(play->state.gfxCtx); - gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_OPA_DISP++, *dList); - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->state.gfxCtx); break; case 4: - Matrix_StatePop(); + Matrix_Pop(); break; case 5: case 6: temp_f20 = this->unk_1EF * 0.01f; - func_80B333DC(globalCtx, dList, temp_f20); + func_80B333DC(play, dList, temp_f20); break; } break; @@ -824,16 +814,16 @@ void EnZoraegg_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList switch (limbIndex) { case 2: temp_f20 = (this->unk_1EE * 0.005f) + 0.5f; - Matrix_StatePush(); + Matrix_Push(); Matrix_Scale(1.0f, temp_f20, temp_f20, MTXMODE_APPLY); - OPEN_DISPS(globalCtx->state.gfxCtx); + OPEN_DISPS(play->state.gfxCtx); - gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_OPA_DISP++, *dList); - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->state.gfxCtx); break; case 4: @@ -841,21 +831,21 @@ void EnZoraegg_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList 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); + OPEN_DISPS(play->state.gfxCtx); - gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_OPA_DISP++, *dList); - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->state.gfxCtx); - Matrix_StatePop(); + Matrix_Pop(); break; case 5: case 6: temp_f20 = this->unk_1EE * 0.01f; - func_80B333DC(globalCtx, dList, temp_f20); + func_80B333DC(play, dList, temp_f20); break; } break; @@ -864,29 +854,29 @@ void EnZoraegg_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList TexturePtr D_80B33950[] = { object_zoraegg_Tex_003430, object_zoraegg_Tex_004430, object_zoraegg_Tex_004830 }; -void func_80B33818(Actor* thisx, GlobalContext* globalCtx) { +void func_80B33818(Actor* thisx, PlayState* play) { EnZoraegg* this = THIS; - OPEN_DISPS(globalCtx->state.gfxCtx); + OPEN_DISPS(play->state.gfxCtx); - func_8012C28C(globalCtx->state.gfxCtx); + func_8012C28C(play->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, + SkelAnime_DrawFlexOpa(play, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, EnZoraegg_OverrideLimbDraw, EnZoraegg_PostLimbDraw, &this->actor); - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->state.gfxCtx); } -void EnZoraegg_Draw(Actor* thisx, GlobalContext* globalCtx) { +void EnZoraegg_Draw(Actor* thisx, PlayState* play) { EnZoraegg* this = THIS; if (this->unk_1ED > 0) { - func_80B331C8(thisx, globalCtx); + func_80B331C8(thisx, play); } if (this->unk_1ED != 255) { - func_80B33818(thisx, globalCtx); + func_80B33818(thisx, play); } } 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 fb65579fa..b5b19afde 100644 --- a/src/overlays/actors/ovl_En_Zoraegg/z_en_zoraegg.h +++ b/src/overlays/actors/ovl_En_Zoraegg/z_en_zoraegg.h @@ -5,58 +5,58 @@ struct EnZoraegg; -typedef void (*EnZoraeggActionFunc)(struct EnZoraegg*, GlobalContext*); +typedef void (*EnZoraeggActionFunc)(struct EnZoraegg*, PlayState*); #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, + /* 0x00 */ ENZORAEGG_1F_00, + /* 0x01 */ ENZORAEGG_1F_01, + /* 0x02 */ ENZORAEGG_1F_02, + /* 0x03 */ ENZORAEGG_1F_03, + /* 0x04 */ ENZORAEGG_1F_04, + /* 0x05 */ ENZORAEGG_1F_05, + /* 0x06 */ ENZORAEGG_1F_06, + /* 0x07 */ ENZORAEGG_1F_07, + /* 0x08 */ ENZORAEGG_1F_08, + /* 0x09 */ ENZORAEGG_1F_09, + /* 0x0A */ ENZORAEGG_1F_0A, + /* 0x0B */ ENZORAEGG_1F_0B, + /* 0x0C */ ENZORAEGG_1F_0C, + /* 0x0D */ ENZORAEGG_1F_0D, + /* 0x0E */ ENZORAEGG_1F_0E, + /* 0x0F */ ENZORAEGG_1F_0F, + /* 0x10 */ ENZORAEGG_1F_10, + /* 0x11 */ ENZORAEGG_1F_11, + /* 0x12 */ ENZORAEGG_1F_12, + /* 0x13 */ ENZORAEGG_1F_13, + /* 0x14 */ ENZORAEGG_1F_14, + /* 0x15 */ ENZORAEGG_1F_15, + /* 0x16 */ ENZORAEGG_1F_16, + /* 0x17 */ ENZORAEGG_1F_17, + /* 0x18 */ ENZORAEGG_1F_18, + /* 0x19 */ ENZORAEGG_1F_19, }; typedef struct EnZoraegg { - /* 0x0000 */ Actor actor; - /* 0x0144 */ SkelAnime skelAnime; - /* 0x0188 */ Vec3s jointTable[7]; - /* 0x01B2 */ Vec3s morphTable[7]; - /* 0x01DC */ Actor* unk_1DC; - /* 0x01E0 */ f32 unk_1E0; - /* 0x01E4 */ f32 unk_1E4; - /* 0x01E8 */ s16 unk_1E8; - /* 0x01EA */ u16 unk_1EA; - /* 0x01EC */ u8 unk_1EC; - /* 0x01ED */ u8 unk_1ED; - /* 0x01EE */ u8 unk_1EE; - /* 0x01EF */ u8 unk_1EF; - /* 0x01F0 */ u16 actorActionCmd; - /* 0x01F2 */ s16 unk_1F2; - /* 0x01F4 */ s16 unk_1F4; - /* 0x01F8 */ EnZoraeggActionFunc actionFunc; + /* 0x000 */ Actor actor; + /* 0x144 */ SkelAnime skelAnime; + /* 0x188 */ Vec3s jointTable[7]; + /* 0x1B2 */ Vec3s morphTable[7]; + /* 0x1DC */ Actor* unk_1DC; + /* 0x1E0 */ f32 unk_1E0; + /* 0x1E4 */ f32 unk_1E4; + /* 0x1E8 */ s16 unk_1E8; + /* 0x1EA */ u16 unk_1EA; + /* 0x1EC */ u8 unk_1EC; + /* 0x1ED */ u8 unk_1ED; + /* 0x1EE */ u8 unk_1EE; + /* 0x1EF */ u8 unk_1EF; + /* 0x1F0 */ u16 actorActionCmd; + /* 0x1F2 */ s16 unk_1F2; + /* 0x1F4 */ s16 unk_1F4; + /* 0x1F8 */ EnZoraeggActionFunc actionFunc; } EnZoraegg; // size = 0x1FC extern const ActorInit En_Zoraegg_InitVars; diff --git a/src/overlays/actors/ovl_En_Zos/z_en_zos.c b/src/overlays/actors/ovl_En_Zos/z_en_zos.c index 419d3325e..1419a7ecd 100644 --- a/src/overlays/actors/ovl_En_Zos/z_en_zos.c +++ b/src/overlays/actors/ovl_En_Zos/z_en_zos.c @@ -11,28 +11,28 @@ #define THIS ((EnZos*)thisx) -void EnZos_Init(Actor* thisx, GlobalContext* globalCtx); -void EnZos_Destroy(Actor* thisx, GlobalContext* globalCtx); -void EnZos_Update(Actor* thisx, GlobalContext* globalCtx); -void EnZos_Draw(Actor* thisx, GlobalContext* globalCtx); +void EnZos_Init(Actor* thisx, PlayState* play); +void EnZos_Destroy(Actor* thisx, PlayState* play); +void EnZos_Update(Actor* thisx, PlayState* play); +void EnZos_Draw(Actor* thisx, PlayState* play); void func_80BBAE84(EnZos* this, s16 arg1, u8 arg2); -void func_80BBB2C4(EnZos* this, GlobalContext* globalCtx); -void func_80BBB354(EnZos* this, GlobalContext* globalCtx); -void func_80BBB4CC(EnZos* this, GlobalContext* globalCtx); -void func_80BBB574(EnZos* this, GlobalContext* globalCtx); -void func_80BBB718(EnZos* this, GlobalContext* globalCtx); -void func_80BBB8AC(EnZos* this, GlobalContext* globalCtx); -void func_80BBBB84(EnZos* this, GlobalContext* globalCtx); -void func_80BBBCBC(EnZos* this, GlobalContext* globalCtx); -void func_80BBBD5C(EnZos* this, GlobalContext* globalCtx); -void func_80BBBDE0(EnZos* this, GlobalContext* globalCtx); -void func_80BBC070(EnZos* this, GlobalContext* globalCtx); -void func_80BBC14C(EnZos* this, GlobalContext* globalCtx); -void func_80BBC22C(EnZos* this, GlobalContext* globalCtx); -void func_80BBC24C(EnZos* this, GlobalContext* globalCtx); -void func_80BBC298(EnZos* this, GlobalContext* globalCtx); -void func_80BBC37C(EnZos* this, GlobalContext* globalCtx); +void func_80BBB2C4(EnZos* this, PlayState* play); +void func_80BBB354(EnZos* this, PlayState* play); +void func_80BBB4CC(EnZos* this, PlayState* play); +void func_80BBB574(EnZos* this, PlayState* play); +void func_80BBB718(EnZos* this, PlayState* play); +void func_80BBB8AC(EnZos* this, PlayState* play); +void func_80BBBB84(EnZos* this, PlayState* play); +void func_80BBBCBC(EnZos* this, PlayState* play); +void func_80BBBD5C(EnZos* this, PlayState* play); +void func_80BBBDE0(EnZos* this, PlayState* play); +void func_80BBC070(EnZos* this, PlayState* play); +void func_80BBC14C(EnZos* this, PlayState* play); +void func_80BBC22C(EnZos* this, PlayState* play); +void func_80BBC24C(EnZos* this, PlayState* play); +void func_80BBC298(EnZos* this, PlayState* play); +void func_80BBC37C(EnZos* this, PlayState* play); const ActorInit En_Zos_InitVars = { ACTOR_EN_ZOS, @@ -66,21 +66,21 @@ static ColliderCylinderInit sCylinderInit = { { 60, 40, 0, { 0, 0, 0 } }, }; -void EnZos_Init(Actor* thisx, GlobalContext* globalCtx) { +void EnZos_Init(Actor* thisx, PlayState* play) { EnZos* this = THIS; Actor_SetScale(&this->actor, 0.0115f); this->actionFunc = func_80BBBDE0; ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 30.0f); this->actor.colChkInfo.mass = MASS_IMMOVABLE; - SkelAnime_InitFlex(globalCtx, &this->skelAnime, &object_zos_Skel_015238, &object_zos_Anim_00A164, this->jointTable, + SkelAnime_InitFlex(play, &this->skelAnime, &object_zos_Skel_015238, &object_zos_Anim_00A164, this->jointTable, this->morphTable, 18); Animation_PlayLoop(&this->skelAnime, &object_zos_Anim_00A164); - Collider_InitAndSetCylinder(globalCtx, &this->collider, &this->actor, &sCylinderInit); + Collider_InitAndSetCylinder(play, &this->collider, &this->actor, &sCylinderInit); this->unk_2B6 = 0; this->actor.terminalVelocity = -4.0f; this->actor.gravity = -4.0f; - func_80BBAE84(this, 0, 2); + func_80BBAE84(this, 0, ANIMMODE_ONCE); switch (ENZOS_GET_F(&this->actor)) { case ENZOS_F_1: @@ -93,12 +93,12 @@ void EnZos_Init(Actor* thisx, GlobalContext* globalCtx) { } else { this->actionFunc = func_80BBC14C; } - func_80BBAE84(this, 0, 2); + func_80BBAE84(this, 0, ANIMMODE_ONCE); break; case ENZOS_F_2: this->actionFunc = func_80BBC37C; - func_80BBAE84(this, 7, 2); + func_80BBAE84(this, 7, ANIMMODE_ONCE); this->unk_2BC = -1; this->unk_2B6 |= 0x40; break; @@ -112,7 +112,7 @@ void EnZos_Init(Actor* thisx, GlobalContext* globalCtx) { } } -void EnZos_Destroy(Actor* thisx, GlobalContext* globalCtx) { +void EnZos_Destroy(Actor* thisx, PlayState* play) { EnZos* this = THIS; gSaveContext.save.weekEventReg[52] &= (u8)~0x10; @@ -139,8 +139,8 @@ void func_80BBAE84(EnZos* this, s16 arg1, u8 arg2) { } } -s32 func_80BBAF5C(EnZos* this, GlobalContext* globalCtx) { - if (Player_IsFacingActor(&this->actor, 0x3000, globalCtx) && +s32 func_80BBAF5C(EnZos* this, PlayState* play) { + if (Player_IsFacingActor(&this->actor, 0x3000, play) && ((!Actor_IsFacingPlayer(&this->actor, 0x4000) && (this->actor.home.rot.y == this->actor.shape.rot.y)) || (Actor_IsFacingPlayer(&this->actor, 0x3000) && (this->actor.home.rot.y != this->actor.shape.rot.y))) && (this->actor.xzDistToPlayer < 100.0f)) { @@ -149,23 +149,23 @@ s32 func_80BBAF5C(EnZos* this, GlobalContext* globalCtx) { return false; } -s32 func_80BBAFFC(EnZos* this, GlobalContext* globalCtx) { +s32 func_80BBAFFC(EnZos* this, PlayState* play) { if (SkelAnime_Update(&this->skelAnime)) { switch ((s16)Rand_ZeroFloat(4.0f)) { case 0: - func_80BBAE84(this, 7, 2); + func_80BBAE84(this, 7, ANIMMODE_ONCE); break; case 1: - func_80BBAE84(this, 8, 2); + func_80BBAE84(this, 8, ANIMMODE_ONCE); break; case 2: - func_80BBAE84(this, 11, 2); + func_80BBAE84(this, 11, ANIMMODE_ONCE); break; default: - func_80BBAE84(this, 12, 2); + func_80BBAE84(this, 12, ANIMMODE_ONCE); break; } return true; @@ -173,107 +173,107 @@ s32 func_80BBAFFC(EnZos* this, GlobalContext* globalCtx) { return false; } -void func_80BBB0D4(EnZos* this, GlobalContext* globalCtx) { +void func_80BBB0D4(EnZos* this, PlayState* play) { if (SkelAnime_Update(&this->skelAnime)) { if (Rand_ZeroFloat(1.0f) < 0.9f) { - func_80BBAE84(this, 0, 2); + func_80BBAE84(this, 0, ANIMMODE_ONCE); } else { - func_80BBAE84(this, 1, 2); + func_80BBAE84(this, 1, ANIMMODE_ONCE); } SkelAnime_Update(&this->skelAnime); } } -void func_80BBB15C(EnZos* this, GlobalContext* globalCtx) { +void func_80BBB15C(EnZos* this, PlayState* play) { s32 textId; if (gSaveContext.save.playerForm == PLAYER_FORM_ZORA) { if (this->unk_2B6 & 8) { textId = 0x1235; - func_80BBAE84(this, 6, 0); + func_80BBAE84(this, 6, ANIMMODE_LOOP); this->unk_2B6 |= 2; } else if (this->unk_2B6 & 4) { textId = 0x123E; - func_80BBAE84(this, 6, 0); + func_80BBAE84(this, 6, ANIMMODE_LOOP); this->unk_2B6 |= 2; } else if (gSaveContext.save.weekEventReg[40] & 0x20) { textId = 0x1236; - func_80BBAE84(this, 6, 0); + func_80BBAE84(this, 6, ANIMMODE_LOOP); this->unk_2B6 |= 0x80; } else { textId = 0x1231; - func_80BBAE84(this, 6, 0); + func_80BBAE84(this, 6, ANIMMODE_LOOP); this->unk_2B6 |= 0x80; } } else { this->unk_2B6 &= ~2; if (gSaveContext.save.weekEventReg[39] & 0x10) { textId = 0x1243; - func_80BBAE84(this, 6, 0); + func_80BBAE84(this, 6, ANIMMODE_LOOP); this->unk_2B6 |= 0x80; } else { textId = 0x1244; gSaveContext.save.weekEventReg[39] |= 0x10; - func_80BBAE84(this, 4, 0); + func_80BBAE84(this, 4, ANIMMODE_LOOP); this->unk_2B6 |= 0x10; } } - Message_StartTextbox(globalCtx, textId, &this->actor); + Message_StartTextbox(play, textId, &this->actor); } -void func_80BBB2C4(EnZos* this, GlobalContext* globalCtx) { - if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { - Message_StartTextbox(globalCtx, 0x124F, &this->actor); +void func_80BBB2C4(EnZos* this, PlayState* play) { + if (Actor_ProcessTalkRequest(&this->actor, &play->state)) { + Message_StartTextbox(play, 0x124F, &this->actor); this->actionFunc = func_80BBB8AC; this->actor.flags &= ~ACTOR_FLAG_10000; } else { - func_800B8500(&this->actor, globalCtx, 1000.0f, 1000.0f, -1); + func_800B8500(&this->actor, play, 1000.0f, 1000.0f, PLAYER_AP_MINUS1); } } -void func_80BBB354(EnZos* this, GlobalContext* globalCtx) { - s32 item; +void func_80BBB354(EnZos* this, PlayState* play) { + s32 getItemId; - if (Actor_HasParent(&this->actor, globalCtx)) { + if (Actor_HasParent(&this->actor, play)) { this->actor.parent = NULL; this->actionFunc = func_80BBB2C4; gSaveContext.save.weekEventReg[39] |= 0x20; this->actor.flags |= ACTOR_FLAG_10000; - func_800B8500(&this->actor, globalCtx, 1000.0f, 1000.0f, -1); + func_800B8500(&this->actor, play, 1000.0f, 1000.0f, PLAYER_AP_MINUS1); } else { if (gSaveContext.save.weekEventReg[39] & 0x20) { - item = GI_RUPEE_PURPLE; + getItemId = GI_RUPEE_PURPLE; } else { - item = GI_HEART_PIECE; + getItemId = GI_HEART_PIECE; } - Actor_PickUp(&this->actor, globalCtx, item, 10000.0f, 50.0f); + Actor_PickUp(&this->actor, play, getItemId, 10000.0f, 50.0f); } } -void func_80BBB414(EnZos* this, GlobalContext* globalCtx) { +void func_80BBB414(EnZos* this, PlayState* play) { SkelAnime_Update(&this->skelAnime); - if (Cutscene_CheckActorAction(globalCtx, 501)) { - s16 action = globalCtx->csCtx.actorActions[Cutscene_GetActorActionIndex(globalCtx, 501)]->action; + if (Cutscene_CheckActorAction(play, 501)) { + s16 action = play->csCtx.actorActions[Cutscene_GetActorActionIndex(play, 501)]->action; if (action != this->unk_2BA) { this->unk_2BA = action; switch (action) { case 1: - func_80BBAE84(this, 1, 0); + func_80BBAE84(this, 1, ANIMMODE_LOOP); break; case 2: - func_80BBAE84(this, 10, 0); + func_80BBAE84(this, 10, ANIMMODE_LOOP); break; } } } } -void func_80BBB4CC(EnZos* this, GlobalContext* globalCtx) { - func_80BBB414(this, globalCtx); +void func_80BBB4CC(EnZos* this, PlayState* play) { + func_80BBB414(this, play); if ((this->actor.cutscene != -1) && (ActorCutscene_GetCurrentIndex() != this->actor.cutscene)) { if (ActorCutscene_GetCurrentIndex() == 0x7C) { @@ -288,65 +288,65 @@ void func_80BBB4CC(EnZos* this, GlobalContext* globalCtx) { } } -void func_80BBB574(EnZos* this, GlobalContext* globalCtx) { +void func_80BBB574(EnZos* this, PlayState* play) { if (!(this->unk_2B6 & 0x10)) { Math_SmoothStepToS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer, 2, 0x1000, 0x200); this->actor.world.rot.y = this->actor.shape.rot.y; } - if (func_80BBAFFC(this, globalCtx)) { + if (func_80BBAFFC(this, play)) { if (this->unk_2B6 & 0x20) { this->unk_2B6 &= ~0x20; - func_80151938(globalCtx, 0x124C); + func_80151938(play, 0x124C); } } - if ((Message_GetState(&globalCtx->msgCtx) == 5) && Message_ShouldAdvance(globalCtx)) { - switch (globalCtx->msgCtx.currentTextId) { + if ((Message_GetState(&play->msgCtx) == TEXT_STATE_5) && Message_ShouldAdvance(play)) { + switch (play->msgCtx.currentTextId) { case 0x124B: if (this->unk_2B8 == 9) { - globalCtx->msgCtx.unk11F10 = 0; + play->msgCtx.msgLength = 0; this->unk_2B6 |= 0x20; } else { - func_80151938(globalCtx, 0x124C); + func_80151938(play, 0x124C); } break; case 0x124C: - globalCtx->msgCtx.unk11F10 = 0; + play->msgCtx.msgLength = 0; this->actionFunc = func_80BBB4CC; - func_80BBAE84(this, 10, 0); + func_80BBAE84(this, 10, ANIMMODE_LOOP); break; case 0x124D: this->unk_2B6 &= ~0x10; - func_80BBAE84(this, 6, 0); - func_80151938(globalCtx, 0x124E); + func_80BBAE84(this, 6, ANIMMODE_LOOP); + func_80151938(play, 0x124E); break; case 0x124E: - func_801477B4(globalCtx); + func_801477B4(play); this->actionFunc = func_80BBB354; - func_80BBB354(this, globalCtx); + func_80BBB354(this, play); break; } } } -void func_80BBB718(EnZos* this, GlobalContext* globalCtx) { +void func_80BBB718(EnZos* this, PlayState* play) { s32 sp24; - Player* player = GET_PLAYER(globalCtx); + Player* player = GET_PLAYER(play); SkelAnime_Update(&this->skelAnime); - if (Message_GetState(&globalCtx->msgCtx) == 0x10) { - sp24 = func_80123810(globalCtx); + if (Message_GetState(&play->msgCtx) == TEXT_STATE_16) { + sp24 = func_80123810(play); if (sp24 > 0) { - func_801477B4(globalCtx); + func_801477B4(play); if (sp24 == 25) { player->actor.textId = 0x1232; - func_80BBAE84(this, 5, 0); + func_80BBAE84(this, 5, ANIMMODE_LOOP); this->unk_2B6 |= 8; gSaveContext.save.weekEventReg[40] |= 0x20; } else if (gSaveContext.save.weekEventReg[39] & 8) { @@ -354,17 +354,17 @@ void func_80BBB718(EnZos* this, GlobalContext* globalCtx) { } else { player->actor.textId = 0x1237; gSaveContext.save.weekEventReg[39] |= 8; - func_80BBAE84(this, 4, 0); + func_80BBAE84(this, 4, ANIMMODE_LOOP); this->unk_2B6 |= 4; } this->actionFunc = func_80BBB8AC; } else if (sp24 < 0) { if (gSaveContext.save.weekEventReg[39] & 8) { - func_80151938(globalCtx, 0x1241); + func_80151938(play, 0x1241); } else { - func_80151938(globalCtx, 0x1237); + func_80151938(play, 0x1237); gSaveContext.save.weekEventReg[39] |= 8; - func_80BBAE84(this, 4, 0); + func_80BBAE84(this, 4, ANIMMODE_LOOP); this->unk_2B6 |= 4; } this->actionFunc = func_80BBB8AC; @@ -372,9 +372,9 @@ void func_80BBB718(EnZos* this, GlobalContext* globalCtx) { } } -void func_80BBB8AC(EnZos* this, GlobalContext* globalCtx) { +void func_80BBB8AC(EnZos* this, PlayState* play) { s32 pad; - Player* player = GET_PLAYER(globalCtx); + Player* player = GET_PLAYER(play); SkelAnime_Update(&this->skelAnime); @@ -382,12 +382,12 @@ void func_80BBB8AC(EnZos* 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; if ((this->unk_2B6 & 0x80) && (this->actor.yawTowardsPlayer == this->actor.shape.rot.y)) { - func_80BBAE84(this, 3, 0); + func_80BBAE84(this, 3, ANIMMODE_LOOP); } } - if ((Message_GetState(&globalCtx->msgCtx) == 5) && Message_ShouldAdvance(globalCtx)) { - switch (globalCtx->msgCtx.currentTextId) { + if ((Message_GetState(&play->msgCtx) == TEXT_STATE_5) && Message_ShouldAdvance(play)) { + switch (play->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.currentTextId + 1); + func_80151938(play, play->msgCtx.currentTextId + 1); break; case 0x1244: this->unk_2B6 &= ~0x10; - func_80BBAE84(this, 6, 0); - func_80151938(globalCtx, globalCtx->msgCtx.currentTextId + 1); + func_80BBAE84(this, 6, ANIMMODE_LOOP); + func_80151938(play, play->msgCtx.currentTextId + 1); break; case 0x1232: @@ -412,30 +412,30 @@ void func_80BBB8AC(EnZos* this, GlobalContext* globalCtx) { case 0x1239: case 0x1246: - func_80BBAE84(this, 6, 0); - func_80151938(globalCtx, globalCtx->msgCtx.currentTextId + 1); + func_80BBAE84(this, 6, ANIMMODE_LOOP); + func_80151938(play, play->msgCtx.currentTextId + 1); break; case 0x1233: - func_80BBAE84(this, 5, 0); - func_80151938(globalCtx, globalCtx->msgCtx.currentTextId + 1); + func_80BBAE84(this, 5, ANIMMODE_LOOP); + func_80151938(play, play->msgCtx.currentTextId + 1); break; case 0x1245: case 0x1248: - func_80BBAE84(this, 3, 0); - func_80151938(globalCtx, globalCtx->msgCtx.currentTextId + 1); + func_80BBAE84(this, 3, ANIMMODE_LOOP); + func_80151938(play, play->msgCtx.currentTextId + 1); break; case 0x1231: - func_80151938(globalCtx, 0xFF); + func_80151938(play, 0xFF); this->actionFunc = func_80BBB718; break; case 0x1243: case 0x1249: - func_80BBAE84(this, 2, 0); - func_801477B4(globalCtx); + func_80BBAE84(this, 2, ANIMMODE_LOOP); + func_801477B4(play); this->actionFunc = func_80BBBDE0; this->unk_2B6 |= 1; break; @@ -443,23 +443,23 @@ void func_80BBB8AC(EnZos* this, GlobalContext* globalCtx) { case 0x1234: case 0x123D: case 0x1242: - func_80BBAE84(this, 2, 0); - Actor_ProcessTalkRequest(&this->actor, &globalCtx->state); - func_801477B4(globalCtx); + func_80BBAE84(this, 2, ANIMMODE_LOOP); + Actor_ProcessTalkRequest(&this->actor, &play->state); + func_801477B4(play); this->actionFunc = func_80BBBDE0; this->unk_2B6 |= 1; break; case 0x1236: - func_80BBAE84(this, 2, 0); - func_801477B4(globalCtx); + func_80BBAE84(this, 2, ANIMMODE_LOOP); + func_801477B4(play); this->actionFunc = func_80BBBDE0; this->unk_2B6 |= 1; break; default: if (0) {} - func_801477B4(globalCtx); + func_801477B4(play); this->actionFunc = func_80BBBDE0; this->unk_2B6 |= 1; break; @@ -467,51 +467,51 @@ void func_80BBB8AC(EnZos* this, GlobalContext* globalCtx) { } } -void func_80BBBB84(EnZos* this, GlobalContext* globalCtx) { - if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { +void func_80BBBB84(EnZos* this, PlayState* play) { + if (Actor_ProcessTalkRequest(&this->actor, &play->state)) { this->actor.flags &= ~ACTOR_FLAG_10000; if (gSaveContext.save.playerForm == PLAYER_FORM_ZORA) { - Message_StartTextbox(globalCtx, 0x1248, &this->actor); + Message_StartTextbox(play, 0x1248, &this->actor); this->actionFunc = func_80BBB8AC; - func_80BBAE84(this, 6, 0); + func_80BBAE84(this, 6, ANIMMODE_LOOP); this->unk_2B6 |= 2; } else if (gSaveContext.save.weekEventReg[41] & 0x10) { - Message_StartTextbox(globalCtx, 0x124A, &this->actor); + Message_StartTextbox(play, 0x124A, &this->actor); this->actionFunc = func_80BBB8AC; - func_80BBAE84(this, 6, 0); + func_80BBAE84(this, 6, ANIMMODE_LOOP); } else { gSaveContext.save.weekEventReg[41] |= 0x10; - Message_StartTextbox(globalCtx, 0x124B, &this->actor); + Message_StartTextbox(play, 0x124B, &this->actor); this->actionFunc = func_80BBB574; - func_80BBAE84(this, 9, 2); + func_80BBAE84(this, 9, ANIMMODE_ONCE); this->unk_2B6 |= 0x10; } } else { - func_800B8614(&this->actor, globalCtx, 300.0f); + func_800B8614(&this->actor, play, 300.0f); } } -void func_80BBBCBC(EnZos* this, GlobalContext* globalCtx) { - if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { +void func_80BBBCBC(EnZos* this, PlayState* play) { + if (Actor_ProcessTalkRequest(&this->actor, &play->state)) { this->actor.flags &= ~ACTOR_FLAG_10000; - func_80BBAE84(this, 5, 0); - Message_StartTextbox(globalCtx, 0x124D, &this->actor); + func_80BBAE84(this, 5, ANIMMODE_LOOP); + Message_StartTextbox(play, 0x124D, &this->actor); this->actionFunc = func_80BBB574; } else { - func_800B8500(&this->actor, globalCtx, 1000.0f, 1000.0f, -1); + func_800B8500(&this->actor, play, 1000.0f, 1000.0f, PLAYER_AP_MINUS1); } } -void func_80BBBD5C(EnZos* this, GlobalContext* globalCtx) { - func_80BBB414(this, globalCtx); - if (!Cutscene_CheckActorAction(globalCtx, 0x1F5)) { +void func_80BBBD5C(EnZos* this, PlayState* play) { + func_80BBB414(this, play); + if (!Cutscene_CheckActorAction(play, 0x1F5)) { this->actionFunc = func_80BBBCBC; this->actor.flags |= ACTOR_FLAG_10000; - func_800B8500(&this->actor, globalCtx, 1000.0f, 1000.0f, -1); + func_800B8500(&this->actor, play, 1000.0f, 1000.0f, PLAYER_AP_MINUS1); } } -void func_80BBBDE0(EnZos* this, GlobalContext* globalCtx) { +void func_80BBBDE0(EnZos* this, PlayState* play) { Actor* thisx = &this->actor; Vec3f sp28; @@ -519,28 +519,28 @@ void func_80BBBDE0(EnZos* this, GlobalContext* globalCtx) { Math_SmoothStepToS(&this->actor.shape.rot.y, this->actor.home.rot.y, 2, 0x1000, 0x200); this->actor.world.rot.y = thisx->shape.rot.y; if (this->actor.home.rot.y == thisx->shape.rot.y) { - func_80BBAE84(this, 0, 2); + func_80BBAE84(this, 0, ANIMMODE_ONCE); this->unk_2B6 &= ~1; } } - func_80BBB0D4(this, globalCtx); + func_80BBB0D4(this, play); - if (globalCtx->msgCtx.ocarinaMode == 0x2A) { - globalCtx->msgCtx.ocarinaMode = 4; + if (play->msgCtx.ocarinaMode == 0x2A) { + play->msgCtx.ocarinaMode = 4; this->actionFunc = func_80BBBB84; this->actor.flags |= ACTOR_FLAG_10000; - func_800B8614(&this->actor, globalCtx, 120.0f); + func_800B8614(&this->actor, play, 120.0f); return; } - if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { + if (Actor_ProcessTalkRequest(&this->actor, &play->state)) { this->actionFunc = func_80BBB8AC; - func_80BBB15C(this, globalCtx); - } else if (Cutscene_CheckActorAction(globalCtx, 0x1F5)) { + func_80BBB15C(this, play); + } else if (Cutscene_CheckActorAction(play, 0x1F5)) { this->actionFunc = func_80BBBD5C; - } else if (func_80BBAF5C(this, globalCtx)) { - func_800B8614(&this->actor, globalCtx, 120.0f); + } else if (func_80BBAF5C(this, play)) { + func_800B8614(&this->actor, play, 120.0f); } if (!Actor_IsFacingPlayer(&this->actor, 0x4000) && (this->actor.xzDistToPlayer < 100.0f)) { @@ -555,7 +555,7 @@ void func_80BBBDE0(EnZos* this, GlobalContext* globalCtx) { func_801A1FB4(3, &sp28, 110, 1000.0f); } -void func_80BBBFBC(EnZos* this, GlobalContext* globalCtx) { +void func_80BBBFBC(EnZos* this, PlayState* play) { u16 textId; if (gSaveContext.save.playerForm == PLAYER_FORM_ZORA) { @@ -567,73 +567,73 @@ void func_80BBBFBC(EnZos* this, GlobalContext* globalCtx) { textId = 0x1259; gSaveContext.save.weekEventReg[78] |= 0x80; } - func_80BBAE84(this, 5, 0); + func_80BBAE84(this, 5, ANIMMODE_LOOP); } else { textId = 0x1258; - func_80BBAE84(this, 6, 0); + func_80BBAE84(this, 6, ANIMMODE_LOOP); } - Message_StartTextbox(globalCtx, textId, &this->actor); + Message_StartTextbox(play, textId, &this->actor); } -void func_80BBC070(EnZos* this, GlobalContext* globalCtx) { +void func_80BBC070(EnZos* this, PlayState* play) { SkelAnime_Update(&this->skelAnime); Math_SmoothStepToS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer, 2, 0x1000, 0x200); this->actor.world.rot.y = this->actor.shape.rot.y; - switch (Message_GetState(&globalCtx->msgCtx)) { - case 5: - if (Message_ShouldAdvance(globalCtx)) { - func_80BBAE84(this, 2, 0); - func_801477B4(globalCtx); + switch (Message_GetState(&play->msgCtx)) { + case TEXT_STATE_5: + if (Message_ShouldAdvance(play)) { + func_80BBAE84(this, 2, ANIMMODE_LOOP); + func_801477B4(play); this->actionFunc = func_80BBC14C; this->unk_2B6 |= 1; } break; - case 2: - func_80BBAE84(this, 2, 0); + case TEXT_STATE_CLOSING: + func_80BBAE84(this, 2, ANIMMODE_LOOP); this->actionFunc = func_80BBC14C; this->unk_2B6 |= 1; break; } } -void func_80BBC14C(EnZos* this, GlobalContext* globalCtx) { +void func_80BBC14C(EnZos* this, PlayState* play) { Actor* thisx = &this->actor; if (this->unk_2B6 & 1) { Math_SmoothStepToS(&this->actor.shape.rot.y, this->actor.home.rot.y, 2, 0x1000, 0x200); this->actor.world.rot.y = thisx->shape.rot.y; if (this->actor.home.rot.y == this->actor.shape.rot.y) { - func_80BBAE84(this, 0, 2); + func_80BBAE84(this, 0, ANIMMODE_ONCE); this->unk_2B6 &= ~1; } } - func_80BBB0D4(this, globalCtx); + func_80BBB0D4(this, play); - if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { + if (Actor_ProcessTalkRequest(&this->actor, &play->state)) { this->actionFunc = func_80BBC070; - func_80BBBFBC(this, globalCtx); - } else if (func_80BBAF5C(this, globalCtx)) { - func_800B8614(&this->actor, globalCtx, 120.0f); + func_80BBBFBC(this, play); + } else if (func_80BBAF5C(this, play)) { + func_800B8614(&this->actor, play, 120.0f); } } -void func_80BBC22C(EnZos* this, GlobalContext* globalCtx) { - func_80BBAFFC(this, globalCtx); +void func_80BBC22C(EnZos* this, PlayState* play) { + func_80BBAFFC(this, play); } -void func_80BBC24C(EnZos* this, GlobalContext* globalCtx) { - func_80BBB0D4(this, globalCtx); +void func_80BBC24C(EnZos* this, PlayState* play) { + func_80BBB0D4(this, play); if (gSaveContext.save.weekEventReg[79] & 1) { this->actionFunc = func_80BBC22C; - func_80BBAE84(this, 7, 2); + func_80BBAE84(this, 7, ANIMMODE_ONCE); } } -void func_80BBC298(EnZos* this, GlobalContext* globalCtx) { - func_80BBAFFC(this, globalCtx); +void func_80BBC298(EnZos* this, PlayState* play) { + func_80BBAFFC(this, play); if (this->unk_2BC < 799) { this->unk_2BC += 200; @@ -645,8 +645,8 @@ void func_80BBC298(EnZos* this, GlobalContext* globalCtx) { this->unk_2BC = 999; } - if (Cutscene_CheckActorAction(globalCtx, 515)) { - if (globalCtx->csCtx.actorActions[Cutscene_GetActorActionIndex(globalCtx, 515)]->action == 1) { + if (Cutscene_CheckActorAction(play, 515)) { + if (play->csCtx.actorActions[Cutscene_GetActorActionIndex(play, 515)]->action == 1) { this->actionFunc = func_80BBC37C; this->unk_2BC = -1; } @@ -656,24 +656,24 @@ void func_80BBC298(EnZos* this, GlobalContext* globalCtx) { } } -void func_80BBC37C(EnZos* this, GlobalContext* globalCtx) { - func_80BBAFFC(this, globalCtx); - if (Cutscene_CheckActorAction(globalCtx, 515) && - (globalCtx->csCtx.actorActions[Cutscene_GetActorActionIndex(globalCtx, 515)]->action == 3)) { +void func_80BBC37C(EnZos* this, PlayState* play) { + func_80BBAFFC(this, play); + if (Cutscene_CheckActorAction(play, 515) && + (play->csCtx.actorActions[Cutscene_GetActorActionIndex(play, 515)]->action == 3)) { this->actionFunc = func_80BBC298; } } -void EnZos_Update(Actor* thisx, GlobalContext* globalCtx) { +void EnZos_Update(Actor* thisx, PlayState* play) { s32 pad; EnZos* 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, 30.0f, 4); + CollisionCheck_SetOC(play, &play->colChkCtx, &this->collider.base); + Actor_UpdateBgCheckInfo(play, &this->actor, 10.0f, 10.0f, 30.0f, 4); - this->actionFunc(this, globalCtx); + this->actionFunc(this, play); if (DECR(this->unk_2AE) == 0) { this->unk_2AE = Rand_S16Offset(60, 60); @@ -685,19 +685,19 @@ void EnZos_Update(Actor* thisx, GlobalContext* globalCtx) { } } -s32 func_80BBC4E4(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, Actor* thisx) { +s32 func_80BBC4E4(PlayState* play, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, Actor* thisx) { return false; } -void func_80BBC500(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx) { +void func_80BBC500(PlayState* play, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx) { 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); } } -void EnZos_Draw(Actor* thisx, GlobalContext* globalCtx) { +void EnZos_Draw(Actor* thisx, PlayState* play) { static TexturePtr D_80BBC75C[] = { object_zos_Tex_010918, object_zos_Tex_011118, @@ -706,9 +706,9 @@ void EnZos_Draw(Actor* thisx, GlobalContext* globalCtx) { EnZos* this = THIS; Gfx* gfx; - OPEN_DISPS(globalCtx->state.gfxCtx); + OPEN_DISPS(play->state.gfxCtx); - func_8012C28C(globalCtx->state.gfxCtx); + func_8012C28C(play->state.gfxCtx); if (this->unk_2B6 & 0x40) { POLY_OPA_DISP = Gfx_SetFog(POLY_OPA_DISP, 0, 0, 0, 0, this->unk_2BC, 1000); @@ -718,24 +718,24 @@ 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); + gSPMatrix(&gfx[1], Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(&gfx[2], object_zos_DL_0136E0); gSPDisplayList(&gfx[3], object_zos_DL_013088); POLY_OPA_DISP = &gfx[4]; - Matrix_StatePop(); + Matrix_Pop(); - SkelAnime_DrawFlexOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, + SkelAnime_DrawFlexOpa(play, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, func_80BBC4E4, func_80BBC500, &this->actor); if (this->unk_2B6 & 0x40) { - POLY_OPA_DISP = func_801660B8(globalCtx, POLY_OPA_DISP); + POLY_OPA_DISP = func_801660B8(play, POLY_OPA_DISP); } - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->state.gfxCtx); } diff --git a/src/overlays/actors/ovl_En_Zos/z_en_zos.h b/src/overlays/actors/ovl_En_Zos/z_en_zos.h index 991f08d57..99125aad3 100644 --- a/src/overlays/actors/ovl_En_Zos/z_en_zos.h +++ b/src/overlays/actors/ovl_En_Zos/z_en_zos.h @@ -5,7 +5,7 @@ struct EnZos; -typedef void (*EnZosActionFunc)(struct EnZos*, GlobalContext*); +typedef void (*EnZosActionFunc)(struct EnZos*, PlayState*); #define ENZOS_GET_F(thisx) ((thisx)->params & 0xF) @@ -15,19 +15,19 @@ enum { }; typedef struct EnZos { - /* 0x0000 */ Actor actor; - /* 0x0144 */ Vec3s jointTable[18]; - /* 0x01B0 */ Vec3s morphTable[18]; - /* 0x021C */ SkelAnime skelAnime; - /* 0x0260 */ ColliderCylinder collider; - /* 0x02AC */ s16 unk_2AC; - /* 0x02AE */ s16 unk_2AE; - /* 0x02B0 */ UNK_TYPE1 unk2B0[6]; - /* 0x02B6 */ u16 unk_2B6; - /* 0x02B8 */ s16 unk_2B8; - /* 0x02BA */ s16 unk_2BA; - /* 0x02BC */ s16 unk_2BC; - /* 0x02C0 */ EnZosActionFunc actionFunc; + /* 0x000 */ Actor actor; + /* 0x144 */ Vec3s jointTable[18]; + /* 0x1B0 */ Vec3s morphTable[18]; + /* 0x21C */ SkelAnime skelAnime; + /* 0x260 */ ColliderCylinder collider; + /* 0x2AC */ s16 unk_2AC; + /* 0x2AE */ s16 unk_2AE; + /* 0x2B0 */ UNK_TYPE1 unk2B0[6]; + /* 0x2B6 */ u16 unk_2B6; + /* 0x2B8 */ s16 unk_2B8; + /* 0x2BA */ s16 unk_2BA; + /* 0x2BC */ s16 unk_2BC; + /* 0x2C0 */ EnZosActionFunc actionFunc; } EnZos; // size = 0x2C4 extern const ActorInit En_Zos_InitVars; diff --git a/src/overlays/actors/ovl_En_Zot/z_en_zot.c b/src/overlays/actors/ovl_En_Zot/z_en_zot.c index bfab9fcf6..bced0c6f3 100644 --- a/src/overlays/actors/ovl_En_Zot/z_en_zot.c +++ b/src/overlays/actors/ovl_En_Zot/z_en_zot.c @@ -5,31 +5,32 @@ */ #include "z_en_zot.h" +#include "z64snap.h" #include "objects/object_zo/object_zo.h" #define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_8 | ACTOR_FLAG_10) #define THIS ((EnZot*)thisx) -void EnZot_Init(Actor* thisx, GlobalContext* globalCtx); -void EnZot_Destroy(Actor* thisx, GlobalContext* globalCtx); -void EnZot_Update(Actor* thisx, GlobalContext* globalCtx); -void EnZot_Draw(Actor* thisx, GlobalContext* globalCtx); +void EnZot_Init(Actor* thisx, PlayState* play); +void EnZot_Destroy(Actor* thisx, PlayState* play); +void EnZot_Update(Actor* thisx, PlayState* play); +void EnZot_Draw(Actor* thisx, PlayState* play); void func_80B96BEC(EnZot* this, s16 arg1, u8 arg2); -void func_80B97100(EnZot* this, GlobalContext* globalCtx); -void func_80B97240(EnZot* this, GlobalContext* globalCtx); -void func_80B97708(EnZot* this, GlobalContext* globalCtx); -void func_80B97B5C(EnZot* this, GlobalContext* globalCtx); -void func_80B97CC8(EnZot* this, GlobalContext* globalCtx); -void func_80B97FD0(EnZot* this, GlobalContext* globalCtx); -void func_80B980FC(EnZot* this, GlobalContext* globalCtx); -void func_80B98728(EnZot* this, GlobalContext* globalCtx); -void func_80B98998(EnZot* this, GlobalContext* globalCtx); -void func_80B98CA8(EnZot* this, GlobalContext* globalCtx); -void func_80B990A4(EnZot* this, GlobalContext* globalCtx); -void func_80B992C0(EnZot* this, GlobalContext* globalCtx); -void func_80B99384(EnZot* this, GlobalContext* globalCtx); +void func_80B97100(EnZot* this, PlayState* play); +void func_80B97240(EnZot* this, PlayState* play); +void func_80B97708(EnZot* this, PlayState* play); +void func_80B97B5C(EnZot* this, PlayState* play); +void func_80B97CC8(EnZot* this, PlayState* play); +void func_80B97FD0(EnZot* this, PlayState* play); +void func_80B980FC(EnZot* this, PlayState* play); +void func_80B98728(EnZot* this, PlayState* play); +void func_80B98998(EnZot* this, PlayState* play); +void func_80B98CA8(EnZot* this, PlayState* play); +void func_80B990A4(EnZot* this, PlayState* play); +void func_80B992C0(EnZot* this, PlayState* play); +void func_80B99384(EnZot* this, PlayState* play); const ActorInit En_Zot_InitVars = { ACTOR_EN_ZOT, @@ -63,7 +64,7 @@ static ColliderCylinderInit sCylinderInit = { { 30, 40, 0, { 0, 0, 0 } }, }; -void func_80B965D0(EnZot* this, GlobalContext* globalCtx) { +void func_80B965D0(EnZot* this, PlayState* play) { s32 i; if ((this->path != NULL) && (this->path->count >= 5)) { @@ -71,25 +72,25 @@ void func_80B965D0(EnZot* this, GlobalContext* globalCtx) { for (i = 0; i < ARRAY_COUNT(this->unk_2D8); i++, points++) { if (this->unk_2D8[i] == NULL) { - this->unk_2D8[i] = Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_OBJ_TSUBO, points->x, points->y, - points->z, 0, 0, 0, 0x13F); + this->unk_2D8[i] = Actor_Spawn(&play->actorCtx, play, ACTOR_OBJ_TSUBO, points->x, points->y, points->z, + 0, 0, 0, 0x13F); } } } } -void EnZot_Init(Actor* thisx, GlobalContext* globalCtx2) { - GlobalContext* globalCtx = globalCtx2; +void EnZot_Init(Actor* thisx, PlayState* play2) { + PlayState* play = play2; EnZot* this = THIS; s32 i; ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 20.0f); Actor_SetScale(&this->actor, 0.01f); this->actionFunc = func_80B97100; - SkelAnime_InitFlex(globalCtx, &this->skelAnime, &gZoraSkel, &gZoraIdleAnim, this->jointTable, this->morphTable, 20); - Animation_PlayLoop(&this->skelAnime, &object_zo_Anim_00DE20); + SkelAnime_InitFlex(play, &this->skelAnime, &gZoraSkel, &gZoraIdleAnim, this->jointTable, this->morphTable, 20); + Animation_PlayLoop(&this->skelAnime, &gZoraStandAnim); this->unk_2F0 = 0; - Collider_InitAndSetCylinder(globalCtx, &this->collider, &this->actor, &sCylinderInit); + Collider_InitAndSetCylinder(play, &this->collider, &this->actor, &sCylinderInit); this->unk_2F2 = 0; this->unk_2F4 = 0; @@ -111,9 +112,9 @@ void EnZot_Init(Actor* thisx, GlobalContext* globalCtx2) { this->unk_2D8[i] = NULL; } if (ENZOT_GET_FC00(&this->actor) != 0x3F) { - this->path = &globalCtx->setupPathList[ENZOT_GET_FC00(&this->actor)]; + this->path = &play->setupPathList[ENZOT_GET_FC00(&this->actor)]; this->unk_2D4 = 0; - func_80B965D0(this, globalCtx); + func_80B965D0(this, play); } else { this->path = NULL; } @@ -124,7 +125,7 @@ void EnZot_Init(Actor* thisx, GlobalContext* globalCtx2) { case 4: this->actionFunc = func_80B97B5C; if (ENZOT_GET_FC00(&this->actor) != 0x3F) { - this->path = &globalCtx->setupPathList[ENZOT_GET_FC00(&this->actor)]; + this->path = &play->setupPathList[ENZOT_GET_FC00(&this->actor)]; } else { this->path = NULL; } @@ -134,29 +135,29 @@ void EnZot_Init(Actor* thisx, GlobalContext* globalCtx2) { this->unk_2F2 |= 4; this->actionFunc = func_80B97FD0; if (ENZOT_GET_FC00(&this->actor) != 0x3F) { - this->path = &globalCtx->setupPathList[ENZOT_GET_FC00(&this->actor)]; + this->path = &play->setupPathList[ENZOT_GET_FC00(&this->actor)]; } else { this->path = NULL; } - func_80B96BEC(this, 5, 0); + func_80B96BEC(this, 5, ANIMMODE_LOOP); break; case 6: this->actionFunc = func_80B98998; - func_80B96BEC(this, 2, 0); + func_80B96BEC(this, 2, ANIMMODE_LOOP); this->actor.colChkInfo.cylRadius = 0; this->actor.shape.yOffset = -1400.0f; break; case 7: this->actionFunc = func_80B98998; - func_80B96BEC(this, 0, 0); + func_80B96BEC(this, 0, ANIMMODE_LOOP); break; case 8: this->actor.flags |= ACTOR_FLAG_2000000; this->actionFunc = func_80B98CA8; - func_80B96BEC(this, 5, 0); + func_80B96BEC(this, 5, ANIMMODE_LOOP); break; case 9: @@ -165,9 +166,9 @@ void EnZot_Init(Actor* thisx, GlobalContext* globalCtx2) { case 10: this->actionFunc = func_80B992C0; - func_80B96BEC(this, 1, 0); + func_80B96BEC(this, 1, ANIMMODE_LOOP); if (ENZOT_GET_FC00(&this->actor) != 0x3F) { - this->path = &globalCtx->setupPathList[ENZOT_GET_FC00(&this->actor)]; + this->path = &play->setupPathList[ENZOT_GET_FC00(&this->actor)]; } else { this->path = NULL; } @@ -181,7 +182,7 @@ void EnZot_Init(Actor* thisx, GlobalContext* globalCtx2) { case 16: case 17: this->actionFunc = func_80B98998; - func_80B96BEC(this, 2, 0); + func_80B96BEC(this, 2, ANIMMODE_LOOP); this->actor.colChkInfo.cylRadius = 0; this->actor.shape.yOffset = -1400.0f; if (!(gSaveContext.save.weekEventReg[55] & 0x80)) { @@ -197,21 +198,21 @@ void EnZot_Init(Actor* thisx, GlobalContext* globalCtx2) { break; case 19: - func_80B96BEC(this, 7, 0); + func_80B96BEC(this, 7, ANIMMODE_LOOP); break; case 20: - func_80B96BEC(this, 8, 2); + func_80B96BEC(this, 8, ANIMMODE_ONCE); break; case 21: - func_80B96BEC(this, 9, 2); + func_80B96BEC(this, 9, ANIMMODE_ONCE); break; case 22: this->actionFunc = func_80B980FC; if (ENZOT_GET_FC00(&this->actor) != 0x3F) { - this->path = &globalCtx->setupPathList[ENZOT_GET_FC00(&this->actor)]; + this->path = &play->setupPathList[ENZOT_GET_FC00(&this->actor)]; } else { this->path = NULL; } @@ -224,10 +225,10 @@ void EnZot_Init(Actor* thisx, GlobalContext* globalCtx2) { } } -void EnZot_Destroy(Actor* thisx, GlobalContext* globalCtx) { +void EnZot_Destroy(Actor* thisx, PlayState* play) { EnZot* this = THIS; - Collider_DestroyCylinder(globalCtx, &this->collider); + Collider_DestroyCylinder(play, &this->collider); if (ENZOT_GET_1F(&this->actor) == 8) { gSaveContext.save.weekEventReg[41] &= (u8)~0x20; } @@ -235,9 +236,9 @@ void EnZot_Destroy(Actor* thisx, GlobalContext* globalCtx) { 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)) { @@ -274,8 +275,8 @@ void func_80B96D4C(EnZot* this) { } } -s32 func_80B96DF0(EnZot* this, GlobalContext* globalCtx) { - if (Player_IsFacingActor(&this->actor, 0x3000, globalCtx) && Actor_IsFacingPlayer(&this->actor, 0x3000) && +s32 func_80B96DF0(EnZot* this, PlayState* play) { + if (Player_IsFacingActor(&this->actor, 0x3000, play) && Actor_IsFacingPlayer(&this->actor, 0x3000) && (this->actor.xzDistToPlayer < 100.0f)) { return true; } @@ -353,10 +354,10 @@ s32 func_80B96FB0(EnZot* this) { return false; } -void func_80B97100(EnZot* this, GlobalContext* globalCtx) { +void func_80B97100(EnZot* this, PlayState* play) { } -void func_80B97110(EnZot* this, GlobalContext* globalCtx) { +void func_80B97110(EnZot* this, PlayState* play) { u16 textId; if (gSaveContext.save.playerForm == PLAYER_FORM_ZORA) { @@ -374,39 +375,39 @@ void func_80B97110(EnZot* this, GlobalContext* globalCtx) { gSaveContext.save.weekEventReg[28] |= 0x40; } } - Message_StartTextbox(globalCtx, textId, &this->actor); + Message_StartTextbox(play, textId, &this->actor); } -void func_80B97194(EnZot* this, GlobalContext* globalCtx) { - if ((Message_GetState(&globalCtx->msgCtx) == 5) && Message_ShouldAdvance(globalCtx)) { - switch (globalCtx->msgCtx.currentTextId) { +void func_80B97194(EnZot* this, PlayState* play) { + if ((Message_GetState(&play->msgCtx) == TEXT_STATE_5) && Message_ShouldAdvance(play)) { + switch (play->msgCtx.currentTextId) { case 0x125C: case 0x125F: - func_80151938(globalCtx, globalCtx->msgCtx.currentTextId + 1); + func_80151938(play, play->msgCtx.currentTextId + 1); break; case 0x125D: case 0x125E: case 0x1260: case 0x1261: - func_801477B4(globalCtx); + func_801477B4(play); this->actionFunc = func_80B97240; break; } } } -void func_80B97240(EnZot* this, GlobalContext* globalCtx) { - if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { +void func_80B97240(EnZot* this, PlayState* play) { + if (Actor_ProcessTalkRequest(&this->actor, &play->state)) { this->actionFunc = func_80B97194; - func_80B97110(this, globalCtx); - } else if ((this->actor.xzDistToPlayer < 100.0f) && Player_IsFacingActor(&this->actor, 0x3000, globalCtx) && + func_80B97110(this, play); + } else if ((this->actor.xzDistToPlayer < 100.0f) && Player_IsFacingActor(&this->actor, 0x3000, play) && Actor_IsFacingPlayer(&this->actor, 0x3000)) { - func_800B8614(&this->actor, globalCtx, 120.0f); + func_800B8614(&this->actor, play, 120.0f); } } -void func_80B972E8(EnZot* this, GlobalContext* globalCtx) { +void func_80B972E8(EnZot* this, PlayState* play) { u16 textId; if (gSaveContext.save.weekEventReg[29] & 0x10) { @@ -440,50 +441,50 @@ void func_80B972E8(EnZot* this, GlobalContext* globalCtx) { gSaveContext.save.weekEventReg[29] |= 8; } } - Message_StartTextbox(globalCtx, textId, &this->actor); + Message_StartTextbox(play, textId, &this->actor); } -void func_80B973BC(EnZot* this, GlobalContext* globalCtx) { +void func_80B973BC(EnZot* this, PlayState* play) { func_80B96D4C(this); Math_SmoothStepToS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer, 2, 0x800, 0x100); this->actor.world.rot.y = this->actor.shape.rot.y; - if ((Message_GetState(&globalCtx->msgCtx) == 5) && Message_ShouldAdvance(globalCtx)) { - switch (globalCtx->msgCtx.currentTextId) { + if ((Message_GetState(&play->msgCtx) == TEXT_STATE_5) && Message_ShouldAdvance(play)) { + switch (play->msgCtx.currentTextId) { case 0x126E: case 0x1270: case 0x1273: case 0x1274: - func_80151938(globalCtx, globalCtx->msgCtx.currentTextId + 1); + func_80151938(play, play->msgCtx.currentTextId + 1); break; case 0x1272: - func_80151938(globalCtx, 0x126F); + func_80151938(play, 0x126F); break; case 0x126F: - func_801159EC(90); - func_80151938(globalCtx, 0x1270); + Rupees_ChangeBy(90); + func_80151938(play, 0x1270); break; case 0x1275: if (gSaveContext.save.playerData.rupees < 10) { - func_80151938(globalCtx, 0x1277); + func_80151938(play, 0x1277); } else { - func_80151938(globalCtx, 0x1278); - func_801159EC(-10); + func_80151938(play, 0x1278); + Rupees_ChangeBy(-10); } break; case 0x1276: - func_80151938(globalCtx, 0x1275); + func_80151938(play, 0x1275); break; case 0x1271: case 0x1277: case 0x1278: case 0x1279: - func_801477B4(globalCtx); - func_80B965D0(this, globalCtx); + func_801477B4(play); + func_80B965D0(this, play); this->actor.flags &= ~ACTOR_FLAG_10000; this->actor.textId = 0; this->actionFunc = func_80B97708; @@ -510,45 +511,45 @@ void func_80B973BC(EnZot* this, GlobalContext* globalCtx) { } } -void func_80B975F8(EnZot* this, GlobalContext* globalCtx) { +void func_80B975F8(EnZot* this, PlayState* play) { func_80B96D4C(this); - if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { + if (Actor_ProcessTalkRequest(&this->actor, &play->state)) { this->actionFunc = func_80B973BC; } else { - func_800B8500(&this->actor, globalCtx, 10000.0f, 1000.0f, EXCH_ITEM_NONE); + func_800B8500(&this->actor, play, 10000.0f, 1000.0f, PLAYER_AP_NONE); } } -void func_80B9765C(EnZot* this, GlobalContext* globalCtx) { +void func_80B9765C(EnZot* this, PlayState* play) { func_80B96D4C(this); - if ((Message_GetState(&globalCtx->msgCtx) == 5) && Message_ShouldAdvance(globalCtx)) { + if ((Message_GetState(&play->msgCtx) == TEXT_STATE_5) && Message_ShouldAdvance(play)) { s32 requiredScopeTemp; - switch (globalCtx->msgCtx.currentTextId) { + switch (play->msgCtx.currentTextId) { case 0x1262: case 0x1267: case 0x126A: case 0x126B: - func_80151938(globalCtx, globalCtx->msgCtx.currentTextId + 1); + func_80151938(play, play->msgCtx.currentTextId + 1); break; default: - func_801477B4(globalCtx); + func_801477B4(play); this->actionFunc = func_80B97708; break; } } } -void func_80B97708(EnZot* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); +void func_80B97708(EnZot* this, PlayState* play) { + Player* player = GET_PLAYER(play); s32 phi_v1; func_80B96D4C(this); Math_SmoothStepToS(&this->actor.shape.rot.y, this->actor.home.rot.y, 2, 0x400, 0x100); this->actor.world.rot.y = this->actor.shape.rot.y; - if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { + if (Actor_ProcessTalkRequest(&this->actor, &play->state)) { this->actionFunc = func_80B9765C; - func_80B972E8(this, globalCtx); + func_80B972E8(this, play); return; } @@ -573,14 +574,14 @@ void func_80B97708(EnZot* this, GlobalContext* globalCtx) { this->actor.textId = 0x1276; } this->unk_2F2 |= 1; - func_80B975F8(this, globalCtx); + func_80B975F8(this, play); this->actionFunc = func_80B975F8; - } else if (func_80B96DF0(this, globalCtx)) { - func_800B8614(&this->actor, globalCtx, 120.0f); + } else if (func_80B96DF0(this, play)) { + func_800B8614(&this->actor, play, 120.0f); } } -void func_80B9787C(EnZot* this, GlobalContext* globalCtx) { +void func_80B9787C(EnZot* this, PlayState* play) { u16 textId; if (this->actor.textId == 0) { @@ -643,30 +644,30 @@ void func_80B9787C(EnZot* this, GlobalContext* globalCtx) { break; } } - Message_StartTextbox(globalCtx, textId, &this->actor); + Message_StartTextbox(play, textId, &this->actor); } } -void func_80B979DC(EnZot* this, GlobalContext* globalCtx) { +void func_80B979DC(EnZot* this, PlayState* play) { if (func_80B96E5C(this)) { this->actionFunc = func_80B97B5C; - func_80B96BEC(this, 0, 0); + func_80B96BEC(this, 0, ANIMMODE_LOOP); this->actor.speedXZ = 0.0f; } else { this->actor.speedXZ = 1.5f; } } -void func_80B97A44(EnZot* this, GlobalContext* globalCtx) { - if ((Message_GetState(&globalCtx->msgCtx) == 5) && Message_ShouldAdvance(globalCtx)) { - switch (globalCtx->msgCtx.currentTextId) { +void func_80B97A44(EnZot* this, PlayState* play) { + if ((Message_GetState(&play->msgCtx) == TEXT_STATE_5) && Message_ShouldAdvance(play)) { + switch (play->msgCtx.currentTextId) { case 0x1279: case 0x127C: case 0x127F: case 0x1282: case 0x1285: case 0x1288: - func_80151938(globalCtx, globalCtx->msgCtx.currentTextId + 1); + func_80151938(play, play->msgCtx.currentTextId + 1); break; case 0x127D: @@ -675,36 +676,36 @@ void func_80B97A44(EnZot* this, GlobalContext* globalCtx) { case 0x1284: case 0x1289: case 0x128A: - func_801477B4(globalCtx); + func_801477B4(play); if (!(this->unk_2F2 & 2)) { this->unk_2F2 |= 2; this->actionFunc = func_80B979DC; - func_80B96BEC(this, 1, 0); + func_80B96BEC(this, 1, ANIMMODE_LOOP); } else { this->actionFunc = func_80B97B5C; } break; default: - func_801477B4(globalCtx); + func_801477B4(play); this->actionFunc = func_80B97B5C; break; } } } -void func_80B97B5C(EnZot* this, GlobalContext* globalCtx) { +void func_80B97B5C(EnZot* this, PlayState* play) { Math_SmoothStepToS(&this->actor.shape.rot.y, this->actor.home.rot.y, 2, 0x400, 0x100); this->actor.world.rot.y = this->actor.shape.rot.y; - if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { + if (Actor_ProcessTalkRequest(&this->actor, &play->state)) { this->actionFunc = func_80B97A44; - func_80B9787C(this, globalCtx); - } else if (func_80B96DF0(this, globalCtx)) { - func_800B8614(&this->actor, globalCtx, 120.0f); + func_80B9787C(this, play); + } else if (func_80B96DF0(this, play)) { + func_800B8614(&this->actor, play, 120.0f); } } -void func_80B97BF8(EnZot* this, GlobalContext* globalCtx) { +void func_80B97BF8(EnZot* this, PlayState* play) { u16 textId; if (gSaveContext.save.playerForm == PLAYER_FORM_ZORA) { @@ -712,32 +713,32 @@ void func_80B97BF8(EnZot* this, GlobalContext* globalCtx) { } else { textId = 0x128B; } - Message_StartTextbox(globalCtx, textId, &this->actor); + Message_StartTextbox(play, textId, &this->actor); } -void func_80B97C40(EnZot* this, GlobalContext* globalCtx) { +void func_80B97C40(EnZot* this, PlayState* play) { Math_SmoothStepToS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer, 2, 0x800, 0x100); this->actor.world.rot.y = this->actor.shape.rot.y; - if ((Message_GetState(&globalCtx->msgCtx) == 5) && Message_ShouldAdvance(globalCtx)) { - func_801477B4(globalCtx); + if ((Message_GetState(&play->msgCtx) == TEXT_STATE_5) && Message_ShouldAdvance(play)) { + func_801477B4(play); this->actionFunc = func_80B97CC8; } } -void func_80B97CC8(EnZot* this, GlobalContext* globalCtx) { - if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { +void func_80B97CC8(EnZot* this, PlayState* play) { + if (Actor_ProcessTalkRequest(&this->actor, &play->state)) { this->actionFunc = func_80B97C40; - 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); + Message_StartTextbox(play, 0x128B, &this->actor); + } else if (Player_IsFacingActor(&this->actor, 0x3000, play) && (this->actor.xzDistToPlayer < 100.0f)) { + func_800B8614(&this->actor, play, 120.0f); } } -void func_80B97D6C(EnZot* this, GlobalContext* globalCtx) { +void func_80B97D6C(EnZot* this, PlayState* play) { if (func_80B96E5C(this)) { this->actionFunc = func_80B97CC8; this->actor.speedXZ = 0.0f; - func_80B96BEC(this, 0, 0); + func_80B96BEC(this, 0, ANIMMODE_LOOP); } else { this->actor.speedXZ = 8.0f; } @@ -747,19 +748,18 @@ void func_80B97D6C(EnZot* this, GlobalContext* globalCtx) { } } -void func_80B97E0C(EnZot* this, GlobalContext* globalCtx) { +void func_80B97E0C(EnZot* this, PlayState* play) { if (this->unk_2F2 & 0x40) { this->actionFunc = func_80B97D6C; - func_80B96BEC(this, 3, 0); + func_80B96BEC(this, 3, ANIMMODE_LOOP); } } -void func_80B97E4C(EnZot* this, GlobalContext* globalCtx) { - if (1) { - do { } while (0); } +void func_80B97E4C(EnZot* this, PlayState* play) { + if (1) {} if (this->unk_2F2 & 0x40) { - func_80B96BEC(this, 0, 0); + func_80B96BEC(this, 0, ANIMMODE_LOOP); } if (!(this->unk_2F2 & 4)) { @@ -767,54 +767,54 @@ void func_80B97E4C(EnZot* this, GlobalContext* globalCtx) { this->actor.world.rot.y = this->actor.shape.rot.y; } - if ((Message_GetState(&globalCtx->msgCtx) == 5) && Message_ShouldAdvance(globalCtx)) { - switch (globalCtx->msgCtx.currentTextId) { + if ((Message_GetState(&play->msgCtx) == TEXT_STATE_5) && Message_ShouldAdvance(play)) { + switch (play->msgCtx.currentTextId) { case 0x128C: this->unk_2F2 &= ~4; - func_80B96BEC(this, 6, 2); - func_80151938(globalCtx, globalCtx->msgCtx.currentTextId + 1); + func_80B96BEC(this, 6, ANIMMODE_ONCE); + func_80151938(play, play->msgCtx.currentTextId + 1); break; case 0x128D: case 0x128E: case 0x128F: - func_80151938(globalCtx, globalCtx->msgCtx.currentTextId + 1); + func_80151938(play, play->msgCtx.currentTextId + 1); break; case 0x1290: - func_801477B4(globalCtx); + func_801477B4(play); this->actionFunc = func_80B97D6C; this->unk_2F2 |= 4; - func_80B96BEC(this, 3, 0); + func_80B96BEC(this, 3, ANIMMODE_LOOP); gSaveContext.save.weekEventReg[38] |= 8; break; case 0x128B: - func_801477B4(globalCtx); + func_801477B4(play); this->actionFunc = func_80B97FD0; break; } } } -void func_80B97FD0(EnZot* this, GlobalContext* globalCtx) { +void func_80B97FD0(EnZot* this, PlayState* play) { Math_SmoothStepToS(&this->actor.shape.rot.y, this->actor.home.rot.y, 2, 0x800, 0x100); this->actor.world.rot.y = this->actor.shape.rot.y; - if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { + if (Actor_ProcessTalkRequest(&this->actor, &play->state)) { this->actionFunc = func_80B97E4C; - func_80B97BF8(this, globalCtx); + func_80B97BF8(this, play); } 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); + func_80B96BEC(this, 6, ANIMMODE_ONCE); } - } else if (Player_IsFacingActor(&this->actor, 0x3000, globalCtx) && (this->actor.xzDistToPlayer < 100.0f)) { - func_800B8614(&this->actor, globalCtx, 120.0f); + } else if (Player_IsFacingActor(&this->actor, 0x3000, play) && (this->actor.xzDistToPlayer < 100.0f)) { + func_800B8614(&this->actor, play, 120.0f); } } -void func_80B980FC(EnZot* this, GlobalContext* globalCtx) { +void func_80B980FC(EnZot* this, PlayState* play) { if (this->actor.home.rot.x > 0) { this->actor.home.rot.x--; } else if (func_80B96E5C(this)) { @@ -823,12 +823,12 @@ void func_80B980FC(EnZot* this, GlobalContext* globalCtx) { } else { this->actor.speedXZ = 8.0f; if (this->unk_2F0 != 3) { - func_80B96BEC(this, 3, 0); + func_80B96BEC(this, 3, ANIMMODE_LOOP); } } } -void func_80B98178(EnZot* this, GlobalContext* globalCtx) { +void func_80B98178(EnZot* this, PlayState* play) { u16 textId; s32 phi_v0; @@ -859,7 +859,7 @@ void func_80B98178(EnZot* this, GlobalContext* globalCtx) { textId = 0x12A6; gSaveContext.save.weekEventReg[39] |= 4; } - } else if (Flags_GetSwitch(globalCtx, this->actor.home.rot.z & 0x7F)) { + } else if (Flags_GetSwitch(play, this->actor.home.rot.z & 0x7F)) { textId = 0x12A0; } else if (gSaveContext.save.weekEventReg[39] & 2) { textId = 0x12A5; @@ -895,10 +895,10 @@ void func_80B98178(EnZot* this, GlobalContext* globalCtx) { } break; } - Message_StartTextbox(globalCtx, textId, &this->actor); + Message_StartTextbox(play, textId, &this->actor); } -void func_80B98348(EnZot* this, GlobalContext* globalCtx) { +void func_80B98348(EnZot* this, PlayState* play) { s16 y; if (ENZOT_GET_1F(&this->actor) == 7) { @@ -921,82 +921,83 @@ void func_80B98348(EnZot* this, GlobalContext* globalCtx) { } } -void func_80B9849C(EnZot* this, GlobalContext* globalCtx) { - func_80B98348(this, globalCtx); - if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { +void func_80B9849C(EnZot* this, PlayState* play) { + func_80B98348(this, play); + if (Actor_ProcessTalkRequest(&this->actor, &play->state)) { if (this->unk_2D4 == 2) { - Message_StartTextbox(globalCtx, 0x12AD, &this->actor); + Message_StartTextbox(play, 0x12AD, &this->actor); } else { - Message_StartTextbox(globalCtx, 0x12B0, &this->actor); + Message_StartTextbox(play, 0x12B0, &this->actor); } this->actionFunc = func_80B98728; } else { - func_800B8500(&this->actor, globalCtx, 1000.0f, 1000.0f, EXCH_ITEM_MINUS1); + func_800B8500(&this->actor, play, 1000.0f, 1000.0f, PLAYER_AP_MINUS1); } } -void func_80B9854C(EnZot* this, GlobalContext* globalCtx) { - func_80B98348(this, globalCtx); - if (Actor_HasParent(&this->actor, globalCtx)) { +void func_80B9854C(EnZot* this, PlayState* play) { + func_80B98348(this, play); + if (Actor_HasParent(&this->actor, play)) { this->actor.parent = NULL; this->actionFunc = func_80B9849C; this->actor.flags |= ACTOR_FLAG_10000; - func_800B8500(&this->actor, globalCtx, 1000.0f, 1000.0f, EXCH_ITEM_MINUS1); + func_800B8500(&this->actor, play, 1000.0f, 1000.0f, PLAYER_AP_MINUS1); } else { - Actor_PickUp(&this->actor, globalCtx, this->unk_2D4, 10000.0f, 50.0f); + Actor_PickUp(&this->actor, play, this->unk_2D4, 10000.0f, 50.0f); } } -void func_80B985EC(EnZot* this, GlobalContext* globalCtx) { +void func_80B985EC(EnZot* this, PlayState* play) { s32 itemActionParam; - Player* player = GET_PLAYER(globalCtx); + Player* player = GET_PLAYER(play); - func_80B98348(this, globalCtx); - if (Message_GetState(&globalCtx->msgCtx) == 0x10) { - itemActionParam = func_80123810(globalCtx); + func_80B98348(this, play); + if (Message_GetState(&play->msgCtx) == TEXT_STATE_16) { + itemActionParam = func_80123810(play); if (itemActionParam > PLAYER_AP_NONE) { - func_801477B4(globalCtx); - if ((itemActionParam == PLAYER_AP_PICTO_BOX) && CHECK_QUEST_ITEM(QUEST_UNK_19) && func_8013A4C4(4)) { - if (func_8013A4C4(5) && func_8013A4C4(6)) { + func_801477B4(play); + if ((itemActionParam == PLAYER_AP_PICTO_BOX) && CHECK_QUEST_ITEM(QUEST_PICTOGRAPH) && + Snap_CheckFlag(PICTOGRAPH_LULU_HEAD)) { + if (Snap_CheckFlag(PICTOGRAPH_LULU_RIGHT_ARM) && Snap_CheckFlag(PICTOGRAPH_LULU_LEFT_ARM)) { player->actor.textId = 0x12AE; } else { player->actor.textId = 0x12AC; } - REMOVE_QUEST_ITEM(QUEST_UNK_19); + REMOVE_QUEST_ITEM(QUEST_PICTOGRAPH); } else { player->actor.textId = 0x12AB; } this->actionFunc = func_80B98728; } else if (itemActionParam < PLAYER_AP_NONE) { - func_80151938(globalCtx, 0x12AB); + func_80151938(play, 0x12AB); this->actionFunc = func_80B98728; } } } -void func_80B98728(EnZot* this, GlobalContext* globalCtx) { - func_80B98348(this, globalCtx); +void func_80B98728(EnZot* this, PlayState* play) { + func_80B98348(this, play); - switch (Message_GetState(&globalCtx->msgCtx)) { - case 4: - if (Message_ShouldAdvance(globalCtx) && (globalCtx->msgCtx.currentTextId == 0x1293)) { - switch (globalCtx->msgCtx.choiceIndex) { + switch (Message_GetState(&play->msgCtx)) { + case TEXT_STATE_CHOICE: + if (Message_ShouldAdvance(play) && (play->msgCtx.currentTextId == 0x1293)) { + switch (play->msgCtx.choiceIndex) { case 0: func_8019F208(); - func_80151938(globalCtx, 0x1294); + func_80151938(play, 0x1294); break; case 1: func_8019F230(); - func_80151938(globalCtx, 0x1298); + func_80151938(play, 0x1298); break; } } break; - case 5: - if (Message_ShouldAdvance(globalCtx)) { - switch (globalCtx->msgCtx.currentTextId) { + case TEXT_STATE_5: + if (Message_ShouldAdvance(play)) { + switch (play->msgCtx.currentTextId) { case 0x1291: case 0x1292: case 0x1296: @@ -1013,44 +1014,44 @@ void func_80B98728(EnZot* this, GlobalContext* globalCtx) { case 0x12A7: case 0x12A8: case 0x12AE: - func_80151938(globalCtx, globalCtx->msgCtx.currentTextId + 1); + func_80151938(play, play->msgCtx.currentTextId + 1); break; case 0x12A9: case 0x12AA: - func_80151938(globalCtx, 0xFF); + func_80151938(play, 0xFF); this->actionFunc = func_80B985EC; break; case 0x1294: if (CURRENT_DAY == 3) { - func_80151938(globalCtx, 0x1296); + func_80151938(play, 0x1296); } else { - func_80151938(globalCtx, 0x1295); + func_80151938(play, 0x1295); } break; case 0x12AB: - func_801477B4(globalCtx); + func_801477B4(play); this->actionFunc = func_80B98998; break; case 0x12AC: - func_801477B4(globalCtx); + func_801477B4(play); this->unk_2D4 = 2; this->actionFunc = func_80B9854C; - func_80B9854C(this, globalCtx); + func_80B9854C(this, play); break; case 0x12AF: - func_801477B4(globalCtx); + func_801477B4(play); this->unk_2D4 = 4; this->actionFunc = func_80B9854C; - func_80B9854C(this, globalCtx); + func_80B9854C(this, play); break; default: - func_801477B4(globalCtx); + func_801477B4(play); this->actionFunc = func_80B98998; this->actor.flags &= ~ACTOR_FLAG_10000; break; @@ -1060,18 +1061,18 @@ void func_80B98728(EnZot* this, GlobalContext* globalCtx) { } } -void func_80B98998(EnZot* this, GlobalContext* globalCtx) { +void func_80B98998(EnZot* this, PlayState* play) { this->unk_2F2 &= ~8; - if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { + if (Actor_ProcessTalkRequest(&this->actor, &play->state)) { this->actionFunc = func_80B98728; - func_80B98178(this, globalCtx); - } else if ((this->actor.xzDistToPlayer < 100.0f) && Player_IsFacingActor(&this->actor, 0x3000, globalCtx) && + func_80B98178(this, play); + } else if ((this->actor.xzDistToPlayer < 100.0f) && Player_IsFacingActor(&this->actor, 0x3000, play) && Actor_IsFacingPlayer(&this->actor, 0x7000)) { - func_800B8614(&this->actor, globalCtx, 120.0f); + func_800B8614(&this->actor, play, 120.0f); } } -void func_80B98A4C(EnZot* this, GlobalContext* globalCtx) { +void func_80B98A4C(EnZot* this, PlayState* play) { u16 textId; if (gSaveContext.save.playerForm == PLAYER_FORM_ZORA) { @@ -1087,73 +1088,73 @@ void func_80B98A4C(EnZot* this, GlobalContext* globalCtx) { textId = 0x12B1; gSaveContext.save.weekEventReg[39] |= 0x40; } - Message_StartTextbox(globalCtx, textId, &this->actor); + Message_StartTextbox(play, textId, &this->actor); } -void func_80B98AD0(EnZot* this, GlobalContext* globalCtx) { - if ((Message_GetState(&globalCtx->msgCtx) == 5) && Message_ShouldAdvance(globalCtx)) { - switch (globalCtx->msgCtx.currentTextId) { +void func_80B98AD0(EnZot* this, PlayState* play) { + if ((Message_GetState(&play->msgCtx) == TEXT_STATE_5) && Message_ShouldAdvance(play)) { + switch (play->msgCtx.currentTextId) { case 0x12B1: case 0x12B4: case 0x12B7: case 0x12B9: - func_80151938(globalCtx, globalCtx->msgCtx.currentTextId + 1); + func_80151938(play, play->msgCtx.currentTextId + 1); break; case 0x12B8: - func_801477B4(globalCtx); + func_801477B4(play); this->actionFunc = func_80B98CA8; gSaveContext.save.weekEventReg[41] &= (u8)~0x20; - AudioOcarina_SetInstrumentId(OCARINA_INSTRUMENT_OFF); + AudioOcarina_SetInstrument(OCARINA_INSTRUMENT_OFF); break; case 0x12BA: - func_801477B4(globalCtx); + func_801477B4(play); this->actionFunc = func_80B98CA8; gSaveContext.save.weekEventReg[41] |= 0x20; - AudioOcarina_SetInstrumentId(OCARINA_INSTRUMENT_OFF); + AudioOcarina_SetInstrument(OCARINA_INSTRUMENT_OFF); break; default: - func_801477B4(globalCtx); + func_801477B4(play); this->actionFunc = func_80B98CA8; break; } } } -void func_80B98BF4(EnZot* this, GlobalContext* globalCtx) { - if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { +void func_80B98BF4(EnZot* this, PlayState* play) { + if (Actor_ProcessTalkRequest(&this->actor, &play->state)) { this->actor.flags &= ~ACTOR_FLAG_10000; if (gSaveContext.save.weekEventReg[41] & 0x20) { - Message_StartTextbox(globalCtx, 0x12B7, &this->actor); + Message_StartTextbox(play, 0x12B7, &this->actor); this->actionFunc = func_80B98AD0; } else { - Message_StartTextbox(globalCtx, 0x12B9, &this->actor); + Message_StartTextbox(play, 0x12B9, &this->actor); this->actionFunc = func_80B98AD0; } } else { - func_800B8614(&this->actor, globalCtx, 120.0f); + func_800B8614(&this->actor, play, 120.0f); } } -void func_80B98CA8(EnZot* this, GlobalContext* globalCtx) { - if (func_800B8718(&this->actor, &globalCtx->state)) { - globalCtx->msgCtx.ocarinaMode = 4; +void func_80B98CA8(EnZot* this, PlayState* play) { + if (func_800B8718(&this->actor, &play->state)) { + play->msgCtx.ocarinaMode = 4; AudioOcarina_StartDefault(0xFFFF); this->actionFunc = func_80B98BF4; this->actor.flags |= ACTOR_FLAG_10000; - func_800B8614(&this->actor, globalCtx, 120.0f); - } else if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { + func_800B8614(&this->actor, play, 120.0f); + } else if (Actor_ProcessTalkRequest(&this->actor, &play->state)) { this->actionFunc = func_80B98AD0; - func_80B98A4C(this, globalCtx); + func_80B98A4C(this, play); } else { - if ((this->actor.xzDistToPlayer < 100.0f) && Player_IsFacingActor(&this->actor, 0x3000, globalCtx)) { - func_800B8614(&this->actor, globalCtx, 120.0f); + if ((this->actor.xzDistToPlayer < 100.0f) && Player_IsFacingActor(&this->actor, 0x3000, play)) { + func_800B8614(&this->actor, play, 120.0f); } if ((gSaveContext.save.playerForm == PLAYER_FORM_ZORA) || (this->actor.xzDistToPlayer < 100.0f)) { - func_800B874C(&this->actor, globalCtx, 120.0, 100.0f); + func_800B874C(&this->actor, play, 120.0, 100.0f); } } @@ -1162,11 +1163,11 @@ void func_80B98CA8(EnZot* this, GlobalContext* globalCtx) { } } -void func_80B98E10(EnZot* this, GlobalContext* globalCtx) { +void func_80B98E10(EnZot* this, PlayState* play) { u16 textId; if (gSaveContext.save.playerForm == PLAYER_FORM_ZORA) { - if (Flags_GetSwitch(globalCtx, this->actor.home.rot.z & 0x7F)) { + if (Flags_GetSwitch(play, this->actor.home.rot.z & 0x7F)) { if (gSaveContext.save.weekEventReg[40] & 4) { textId = 0x12C5; } else { @@ -1180,7 +1181,7 @@ void func_80B98E10(EnZot* this, GlobalContext* globalCtx) { gSaveContext.save.weekEventReg[40] |= 2; } } else { - if (Flags_GetSwitch(globalCtx, this->actor.home.rot.z & 0x7F)) { + if (Flags_GetSwitch(play, this->actor.home.rot.z & 0x7F)) { if (this->unk_2F2 & 0x10) { textId = 0x12BF; } else { @@ -1195,61 +1196,61 @@ void func_80B98E10(EnZot* this, GlobalContext* globalCtx) { textId = 0x12BB; } } - Message_StartTextbox(globalCtx, textId, &this->actor); + Message_StartTextbox(play, textId, &this->actor); } -void func_80B98F30(EnZot* this, GlobalContext* globalCtx) { - if (Actor_HasParent(&this->actor, globalCtx)) { +void func_80B98F30(EnZot* this, PlayState* play) { + if (Actor_HasParent(&this->actor, play)) { this->actor.parent = NULL; this->actionFunc = func_80B990A4; } else { - Actor_PickUp(&this->actor, globalCtx, GI_RUPEE_BLUE, 10000.0f, 50.0f); + Actor_PickUp(&this->actor, play, GI_RUPEE_BLUE, 10000.0f, 50.0f); } } -void func_80B98F94(EnZot* this, GlobalContext* globalCtx) { +void func_80B98F94(EnZot* this, PlayState* play) { if (!(this->unk_2F2 & 4)) { 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) && Message_ShouldAdvance(globalCtx)) { - switch (globalCtx->msgCtx.currentTextId) { + if ((Message_GetState(&play->msgCtx) == TEXT_STATE_5) && Message_ShouldAdvance(play)) { + switch (play->msgCtx.currentTextId) { case 0x12BB: this->unk_2F2 &= ~4; case 0x12BC: case 0x12C0: case 0x12C3: - func_80151938(globalCtx, globalCtx->msgCtx.currentTextId + 1); + func_80151938(play, play->msgCtx.currentTextId + 1); break; case 0x12BE: - func_801477B4(globalCtx); + func_801477B4(play); this->actionFunc = func_80B98F30; - func_80B98F30(this, globalCtx); + func_80B98F30(this, play); break; default: - func_801477B4(globalCtx); + func_801477B4(play); this->actionFunc = func_80B990A4; break; } } } -void func_80B990A4(EnZot* this, GlobalContext* globalCtx) { +void func_80B990A4(EnZot* this, PlayState* play) { Math_SmoothStepToS(&this->actor.shape.rot.y, this->actor.home.rot.y, 2, 0x400, 0x100); this->actor.world.rot.y = this->actor.shape.rot.y; - if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { + if (Actor_ProcessTalkRequest(&this->actor, &play->state)) { this->actionFunc = func_80B98F94; - func_80B98E10(this, globalCtx); - } else if (Player_IsFacingActor(&this->actor, 0x3000, globalCtx) && (this->actor.xzDistToPlayer < 100.0f)) { - func_800B8614(&this->actor, globalCtx, 120.0f); + func_80B98E10(this, play); + } else if (Player_IsFacingActor(&this->actor, 0x3000, play) && (this->actor.xzDistToPlayer < 100.0f)) { + func_800B8614(&this->actor, play, 120.0f); } } -void func_80B99160(EnZot* this, GlobalContext* globalCtx) { +void func_80B99160(EnZot* this, PlayState* play) { u16 textId; if (gSaveContext.save.playerForm == PLAYER_FORM_ZORA) { @@ -1265,66 +1266,66 @@ void func_80B99160(EnZot* this, GlobalContext* globalCtx) { textId = 0x12C6; gSaveContext.save.weekEventReg[40] |= 8; } - Message_StartTextbox(globalCtx, textId, &this->actor); + Message_StartTextbox(play, textId, &this->actor); } -void func_80B991E4(EnZot* this, GlobalContext* globalCtx) { +void func_80B991E4(EnZot* this, PlayState* play) { if (1) { do { } while (0); } 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) && Message_ShouldAdvance(globalCtx)) { - u16 temp = globalCtx->msgCtx.currentTextId; + if ((Message_GetState(&play->msgCtx) == TEXT_STATE_5) && Message_ShouldAdvance(play)) { + u16 temp = play->msgCtx.currentTextId; u32 temp2; if ((temp == 0x12C6) || (temp == 0x12C7) || (temp == 0x12CA) || (temp == 0x12CB)) { temp2 = temp; - func_80151938(globalCtx, temp2 + 1); + func_80151938(play, temp2 + 1); } else { - func_801477B4(globalCtx); + func_801477B4(play); this->actionFunc = func_80B992C0; - func_80B96BEC(this, 1, 0); + func_80B96BEC(this, 1, ANIMMODE_LOOP); } } } -void func_80B992C0(EnZot* this, GlobalContext* globalCtx) { - if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { +void func_80B992C0(EnZot* this, PlayState* play) { + if (Actor_ProcessTalkRequest(&this->actor, &play->state)) { this->actionFunc = func_80B991E4; - func_80B99160(this, globalCtx); + func_80B99160(this, play); this->actor.speedXZ = 0.0f; - func_80B96BEC(this, 0, 0); + func_80B96BEC(this, 0, ANIMMODE_LOOP); } else { - if (Player_IsFacingActor(&this->actor, 0x3000, globalCtx) && (this->actor.xzDistToPlayer < 100.0f)) { - func_800B8614(&this->actor, globalCtx, 120.0f); + if (Player_IsFacingActor(&this->actor, 0x3000, play) && (this->actor.xzDistToPlayer < 100.0f)) { + func_800B8614(&this->actor, play, 120.0f); } this->actor.speedXZ = 1.5f; func_80B96FB0(this); } } -void func_80B99384(EnZot* this, GlobalContext* globalCtx) { +void func_80B99384(EnZot* this, PlayState* play) { } -void EnZot_Update(Actor* thisx, GlobalContext* globalCtx) { +void EnZot_Update(Actor* thisx, PlayState* play) { s32 pad; EnZot* 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, 30.0f, 15.0f, 30.0f, 5); + CollisionCheck_SetOC(play, &play->colChkCtx, &this->collider.base); + Actor_UpdateBgCheckInfo(play, &this->actor, 30.0f, 15.0f, 30.0f, 5); this->unk_2F2 &= ~0x40; if (SkelAnime_Update(&this->skelAnime) && (this->unk_2F0 != 0)) { this->unk_2F2 |= 0x40; } - this->actionFunc(this, globalCtx); + this->actionFunc(this, play); 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); + if (!(this->unk_2F2 & 4) && func_80B96DF0(this, play)) { + Actor_TrackPlayer(play, &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); @@ -1351,40 +1352,40 @@ Gfx* func_80B99580(GraphicsContext* gfxCtx) { return dList; } -s32 EnZot_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, Actor* thisx) { +s32 EnZot_OverrideLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, Actor* thisx) { EnZot* this = THIS; 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)) && ((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); + rot->y += (s16)(Math_SinS(play->state.frames * ((limbIndex * 50) + 0x814)) * 200.0f); + rot->z += (s16)(Math_CosS(play->state.frames * ((limbIndex * 50) + 0x940)) * 200.0f); } return false; } -void EnZot_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx) { +void EnZot_PostLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx) { static Vec3f D_80B99934 = { 400.0f, 0.0f, 0.0f }; EnZot* this = THIS; if (limbIndex == 15) { - Matrix_MultiplyVector3fByState(&D_80B99934, &this->actor.focus.pos); + Matrix_MultVec3f(&D_80B99934, &this->actor.focus.pos); } } -void EnZot_Draw(Actor* thisx, GlobalContext* globalCtx) { +void EnZot_Draw(Actor* thisx, PlayState* play) { TexturePtr sp4C[] = { gZoraEyeOpenTex, gZoraEyeHalfTex, @@ -1392,16 +1393,16 @@ void EnZot_Draw(Actor* thisx, GlobalContext* globalCtx) { }; EnZot* this = THIS; - OPEN_DISPS(globalCtx->state.gfxCtx); + OPEN_DISPS(play->state.gfxCtx); - func_8012C28C(globalCtx->state.gfxCtx); + func_8012C28C(play->state.gfxCtx); gDPSetEnvColor(POLY_OPA_DISP++, 0, 0, 0, 255); gSPSegment(POLY_OPA_DISP++, 0x08, Lib_SegmentedToVirtual(sp4C[this->unk_2EC])); - gSPSegment(POLY_OPA_DISP++, 0x0C, func_80B99580(globalCtx->state.gfxCtx)); + gSPSegment(POLY_OPA_DISP++, 0x0C, func_80B99580(play->state.gfxCtx)); - SkelAnime_DrawFlexOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, + SkelAnime_DrawFlexOpa(play, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, EnZot_OverrideLimbDraw, EnZot_PostLimbDraw, &this->actor); - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->state.gfxCtx); } diff --git a/src/overlays/actors/ovl_En_Zot/z_en_zot.h b/src/overlays/actors/ovl_En_Zot/z_en_zot.h index 06fb724ae..b72328b20 100644 --- a/src/overlays/actors/ovl_En_Zot/z_en_zot.h +++ b/src/overlays/actors/ovl_En_Zot/z_en_zot.h @@ -5,28 +5,28 @@ struct EnZot; -typedef void (*EnZotActionFunc)(struct EnZot*, GlobalContext*); +typedef void (*EnZotActionFunc)(struct EnZot*, PlayState*); #define ENZOT_GET_1F(thisx) ((thisx)->params & 0x1F) #define ENZOT_GET_FC00(thisx) (((thisx)->params & 0xFC00) >> 0xA) typedef struct EnZot { - /* 0x0000 */ Actor actor; - /* 0x0144 */ SkelAnime skelAnime; - /* 0x0188 */ ColliderCylinder collider; - /* 0x01D4 */ Vec3s jointTable[20]; - /* 0x024C */ Vec3s morphTable[20]; - /* 0x02C4 */ Vec3s unk_2C4; - /* 0x02CA */ Vec3s unk_2CA; - /* 0x02D0 */ Path* path; - /* 0x02D4 */ s32 unk_2D4; - /* 0x02D8 */ Actor* unk_2D8[5]; - /* 0x02EC */ s16 unk_2EC; - /* 0x02EE */ s16 unk_2EE; - /* 0x02F0 */ s16 unk_2F0; - /* 0x02F2 */ u16 unk_2F2; - /* 0x02F4 */ s16 unk_2F4; - /* 0x02F8 */ EnZotActionFunc actionFunc; + /* 0x000 */ Actor actor; + /* 0x144 */ SkelAnime skelAnime; + /* 0x188 */ ColliderCylinder collider; + /* 0x1D4 */ Vec3s jointTable[20]; + /* 0x24C */ Vec3s morphTable[20]; + /* 0x2C4 */ Vec3s unk_2C4; + /* 0x2CA */ Vec3s unk_2CA; + /* 0x2D0 */ Path* path; + /* 0x2D4 */ s32 unk_2D4; + /* 0x2D8 */ Actor* unk_2D8[5]; + /* 0x2EC */ s16 unk_2EC; + /* 0x2EE */ s16 unk_2EE; + /* 0x2F0 */ s16 unk_2F0; + /* 0x2F2 */ u16 unk_2F2; + /* 0x2F4 */ s16 unk_2F4; + /* 0x2F8 */ EnZotActionFunc actionFunc; } EnZot; // size = 0x2FC extern const ActorInit En_Zot_InitVars; diff --git a/src/overlays/actors/ovl_En_Zov/z_en_zov.c b/src/overlays/actors/ovl_En_Zov/z_en_zov.c index f593709cf..05726ddce 100644 --- a/src/overlays/actors/ovl_En_Zov/z_en_zov.c +++ b/src/overlays/actors/ovl_En_Zov/z_en_zov.c @@ -12,21 +12,21 @@ #define THIS ((EnZov*)thisx) -void EnZov_Init(Actor* thisx, GlobalContext* globalCtx); -void EnZov_Destroy(Actor* thisx, GlobalContext* globalCtx); -void EnZov_Update(Actor* thisx, GlobalContext* globalCtx); -void EnZov_Draw(Actor* thisx, GlobalContext* globalCtx); +void EnZov_Init(Actor* thisx, PlayState* play); +void EnZov_Destroy(Actor* thisx, PlayState* play); +void EnZov_Update(Actor* thisx, PlayState* play); +void EnZov_Draw(Actor* thisx, PlayState* play); 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); -void func_80BD1C38(EnZov* this, GlobalContext* globalCtx); -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); +void func_80BD187C(EnZov* this, PlayState* play); +void func_80BD19FC(EnZov* this, PlayState* play); +void func_80BD1BF0(EnZov* this, PlayState* play); +void func_80BD1C38(EnZov* this, PlayState* play); +void func_80BD1C84(EnZov* this, PlayState* play); +void func_80BD1D94(EnZov* this, PlayState* play); +void func_80BD1DB8(EnZov* this, PlayState* play); +void func_80BD1F1C(EnZov* this, PlayState* play); +s32 EnZov_ValidatePictograph(PlayState* play, Actor* thisx); const ActorInit En_Zov_InitVars = { ACTOR_EN_ZOV, @@ -79,58 +79,58 @@ static s8 D_80BD2770[] = { 1, 2, 1, 0, 0, 1, 2, 1, }; -void EnZov_Init(Actor* thisx, GlobalContext* globalCtx) { +void EnZov_Init(Actor* thisx, PlayState* play) { EnZov* this = THIS; - 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, + ActorShape_Init(&this->picto.actor.shape, 0.0f, ActorShadow_DrawCircle, 20.0f); + this->picto.actor.colChkInfo.mass = MASS_IMMOVABLE; + Actor_SetScale(&this->picto.actor, 0.01f); + Collider_InitAndSetCylinder(play, &this->collider, &this->picto.actor, &sCylinderInit); + SkelAnime_InitFlex(play, &this->skelAnime, &object_zov_Skel_016258, &object_zov_Anim_00D3EC, this->jontTable, this->morphTable, 23); Animation_PlayLoop(&this->skelAnime, &object_zov_Anim_00D3EC); this->unk_320 = 0; this->unk_32C = -1; this->unk_326 = -1; - this->unk_328[0] = this->actor.cutscene; + this->unk_328[0] = this->picto.actor.cutscene; this->unk_328[1] = 0x7C; this->unk_322 = 0; this->actionFunc = func_80BD1C84; - this->unk_144 = func_80BD1FC8; + this->picto.validationFunc = EnZov_ValidatePictograph; - 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); + Math_Vec3f_Copy(&this->unk_2FC, &this->picto.actor.world.pos); + Math_Vec3f_Copy(&this->unk_308, &this->picto.actor.world.pos); + Math_Vec3f_Copy(&this->unk_314, &this->picto.actor.world.pos); - switch (ENZOV_GET_F(&this->actor)) { + switch (ENZOV_GET_F(&this->picto.actor)) { case ENZOV_F_1: this->actionFunc = func_80BD1F1C; - func_80BD1570(this, 9, 0); + func_80BD1570(this, 9, ANIMMODE_LOOP); if (!(gSaveContext.save.weekEventReg[55] & 0x80)) { - Actor_MarkForDeath(&this->actor); + Actor_MarkForDeath(&this->picto.actor); return; } break; case ENZOV_F_2: this->actionFunc = func_80BD1C38; - this->actor.shape.shadowDraw = NULL; + this->picto.actor.shape.shadowDraw = NULL; break; default: this->unk_320 |= 2; if ((gSaveContext.save.weekEventReg[55] & 0x80) || (gSaveContext.save.weekEventReg[53] & 0x20)) { - Actor_MarkForDeath(&this->actor); + Actor_MarkForDeath(&this->picto.actor); } break; } } -void EnZov_Destroy(Actor* thisx, GlobalContext* globalCtx) { +void EnZov_Destroy(Actor* thisx, PlayState* play) { EnZov* this = THIS; - Collider_DestroyCylinder(globalCtx, &this->collider); + Collider_DestroyCylinder(play, &this->collider); } void func_80BD13DC(EnZov* this) { @@ -150,7 +150,7 @@ void func_80BD1440(EnZov* this, s16 arg1) { void func_80BD1470(EnZov* this, s16 index, u8 mode, f32 transitionRate) { f32 frame; - if (((index != this->unk_322) || mode) && (index >= 0) && (index < ARRAY_COUNT(D_80BD270C))) { + if (((index != this->unk_322) || (mode != ANIMMODE_LOOP)) && (index >= 0) && (index < ARRAY_COUNT(D_80BD270C))) { switch (index) { case 6: frame = 30.0f; @@ -174,15 +174,15 @@ void func_80BD1570(EnZov* this, s16 index, u8 mode) { func_80BD1470(this, index, mode, 5.0f); } -s32 func_80BD15A4(EnZov* this, GlobalContext* globalCtx) { - if ((this->actor.xzDistToPlayer < 100.0f) && Player_IsFacingActor(&this->actor, 0x3000, globalCtx) && - Actor_IsFacingPlayer(&this->actor, 0x3000)) { +s32 func_80BD15A4(EnZov* this, PlayState* play) { + if ((this->picto.actor.xzDistToPlayer < 100.0f) && Player_IsFacingActor(&this->picto.actor, 0x3000, play) && + Actor_IsFacingPlayer(&this->picto.actor, 0x3000)) { return true; } return false; } -void func_80BD160C(EnZov* this, GlobalContext* globalCtx) { +void func_80BD160C(EnZov* this, PlayState* play) { s32 textId = 0; if (gSaveContext.save.weekEventReg[53] & 0x20) { @@ -190,30 +190,30 @@ void func_80BD160C(EnZov* this, GlobalContext* globalCtx) { if (gSaveContext.save.playerForm != PLAYER_FORM_ZORA) { textId = 0x1024; if ((this->unk_322 == 0) || (this->unk_322 == 4)) { - func_80BD1570(this, 4, 2); + func_80BD1570(this, 4, ANIMMODE_ONCE); } else { - func_80BD1570(this, 6, 2); + func_80BD1570(this, 6, ANIMMODE_ONCE); } } else if (this->unk_320 & 4) { textId = 0x1023; } else { textId = 0x1022; this->unk_320 |= 4; - func_80BD1570(this, 3, 2); + func_80BD1570(this, 3, ANIMMODE_ONCE); } } else if (gSaveContext.save.playerForm == PLAYER_FORM_ZORA) { - func_80BD1570(this, 2, 2); + func_80BD1570(this, 2, ANIMMODE_ONCE); this->actionFunc = func_80BD19FC; this->unk_324 = 10; func_80BD1440(this, 0); } else { textId = 0x1020; - func_80BD1570(this, 5, 2); + func_80BD1570(this, 5, ANIMMODE_ONCE); } this->unk_320 |= 1; if (textId != 0) { - Message_StartTextbox(globalCtx, textId, &this->actor); + Message_StartTextbox(play, textId, &this->picto.actor); } } @@ -222,32 +222,32 @@ void func_80BD1764(EnZov* this) { switch (this->unk_322) { case 1: case 6: - func_80BD1570(this, 6, 2); + func_80BD1570(this, 6, ANIMMODE_ONCE); break; case 3: case 7: - func_80BD1570(this, 7, 2); + func_80BD1570(this, 7, ANIMMODE_ONCE); break; case 4: - func_80BD1570(this, 0, 0); + func_80BD1570(this, 0, ANIMMODE_LOOP); break; case 8: - func_80BD1570(this, 9, 0); + func_80BD1570(this, 9, ANIMMODE_LOOP); break; case 10: - func_80BD1570(this, 11, 0); + func_80BD1570(this, 11, ANIMMODE_LOOP); break; case 12: - func_80BD1570(this, 13, 0); + func_80BD1570(this, 13, ANIMMODE_LOOP); break; default: - func_80BD1570(this, 0, 0); + func_80BD1570(this, 0, ANIMMODE_LOOP); this->unk_320 &= ~1; break; } @@ -256,53 +256,53 @@ void func_80BD1764(EnZov* this) { } } -void func_80BD187C(EnZov* this, GlobalContext* globalCtx) { +void func_80BD187C(EnZov* this, PlayState* play) { func_80BD1764(this); - switch (Message_GetState(&globalCtx->msgCtx)) { - case 5: - if (Message_ShouldAdvance(globalCtx)) { - switch (globalCtx->msgCtx.currentTextId) { + switch (Message_GetState(&play->msgCtx)) { + case TEXT_STATE_5: + if (Message_ShouldAdvance(play)) { + switch (play->msgCtx.currentTextId) { case 0x1022: - func_80151938(globalCtx, 0x1023); + func_80151938(play, 0x1023); break; case 0x1023: if ((this->unk_322 != 6) && (this->unk_322 != 1)) { - func_80BD1570(this, 1, 2); + func_80BD1570(this, 1, ANIMMODE_ONCE); } - func_801477B4(globalCtx); + func_801477B4(play); this->actionFunc = func_80BD1C84; break; case 0x1024: if (this->unk_322 != 6) { - func_80BD1570(this, 0, 0); + func_80BD1570(this, 0, ANIMMODE_LOOP); } - func_801477B4(globalCtx); + func_801477B4(play); this->actionFunc = func_80BD1C84; break; default: this->unk_320 &= ~1; - func_80BD1570(this, 0, 0); - func_801477B4(globalCtx); + func_80BD1570(this, 0, ANIMMODE_LOOP); + func_801477B4(play); this->actionFunc = func_80BD1C84; break; } } break; - case 2: - func_801477B4(globalCtx); + case TEXT_STATE_CLOSING: + func_801477B4(play); this->actionFunc = func_80BD1C84; this->unk_320 &= ~1; - func_80BD1570(this, 0, 0); + func_80BD1570(this, 0, ANIMMODE_LOOP); break; } } -void func_80BD19FC(EnZov* this, GlobalContext* globalCtx) { +void func_80BD19FC(EnZov* this, PlayState* play) { func_80BD1764(this); if (this->unk_322 == 0) { if (!(this->unk_320 & 2)) { @@ -314,9 +314,9 @@ void func_80BD19FC(EnZov* this, GlobalContext* globalCtx) { 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); + Message_StartTextbox(play, 0x1021, &this->picto.actor); + ((EnElf*)(GET_PLAYER(play)->tatlActor))->unk_264 |= 4; + Actor_ChangeFocus(&this->picto.actor, play, GET_PLAYER(play)->tatlActor); this->actionFunc = func_80BD187C; } } else if (Animation_OnFrame(&this->skelAnime, 10.0f)) { @@ -325,30 +325,30 @@ void func_80BD19FC(EnZov* this, GlobalContext* globalCtx) { } } -s32 func_80BD1AE0(EnZov* this, GlobalContext* globalCtx) { +s32 func_80BD1AE0(EnZov* this, PlayState* play) { func_80BD1764(this); - if (Cutscene_CheckActorAction(globalCtx, 504)) { - s16 action = globalCtx->csCtx.actorActions[Cutscene_GetActorActionIndex(globalCtx, 504)]->action; + if (Cutscene_CheckActorAction(play, 504)) { + s16 action = play->csCtx.actorActions[Cutscene_GetActorActionIndex(play, 504)]->action; if (action != this->unk_326) { this->unk_326 = action; switch (this->unk_326) { case 1: - func_80BD1570(this, 0, 0); + func_80BD1570(this, 0, ANIMMODE_LOOP); break; case 2: - func_80BD1570(this, 8, 2); + func_80BD1570(this, 8, ANIMMODE_ONCE); this->unk_320 |= 0x10; break; case 3: - func_80BD1470(this, 10, 2, 0.0f); + func_80BD1470(this, 10, ANIMMODE_ONCE, 0.0f); break; case 4: - func_80BD1570(this, 12, 2); + func_80BD1570(this, 12, ANIMMODE_ONCE); break; } } @@ -358,36 +358,36 @@ s32 func_80BD1AE0(EnZov* this, GlobalContext* globalCtx) { return false; } -void func_80BD1BF0(EnZov* this, GlobalContext* globalCtx) { - if (!func_80BD1AE0(this, globalCtx)) { - func_80BD1570(this, 0, 0); +void func_80BD1BF0(EnZov* this, PlayState* play) { + if (!func_80BD1AE0(this, play)) { + func_80BD1570(this, 0, ANIMMODE_LOOP); 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_80BD1C38(EnZov* this, PlayState* play) { + if (func_80BD1AE0(this, play)) { + Cutscene_ActorTranslateAndYaw(&this->picto.actor, play, Cutscene_GetActorActionIndex(play, 504)); } } -void func_80BD1C84(EnZov* this, GlobalContext* globalCtx) { +void func_80BD1C84(EnZov* this, PlayState* play) { func_80BD1764(this); - if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { + if (Actor_ProcessTalkRequest(&this->picto.actor, &play->state)) { this->actionFunc = func_80BD187C; - func_80BD160C(this, globalCtx); - } else if (func_80BD15A4(this, globalCtx)) { - func_800B8614(&this->actor, globalCtx, 120.0f); + func_80BD160C(this, play); + } else if (func_80BD15A4(this, play)) { + func_800B8614(&this->picto.actor, play, 120.0f); } - if (Cutscene_CheckActorAction(globalCtx, 0x1F8)) { + if (Cutscene_CheckActorAction(play, 0x1F8)) { this->actionFunc = func_80BD1BF0; - func_80BD1BF0(this, globalCtx); + func_80BD1BF0(this, play); } } -void func_80BD1D30(EnZov* this, GlobalContext* globalCtx) { +void func_80BD1D30(EnZov* this, PlayState* play) { u16 textId; if (gSaveContext.save.playerForm == PLAYER_FORM_ZORA) { @@ -399,90 +399,93 @@ void func_80BD1D30(EnZov* this, GlobalContext* globalCtx) { } else { textId = 0x1031; } - Message_StartTextbox(globalCtx, textId, &this->actor); + Message_StartTextbox(play, textId, &this->picto.actor); } -void func_80BD1D94(EnZov* this, GlobalContext* globalCtx) { +void func_80BD1D94(EnZov* this, PlayState* play) { func_80BD1764(this); } -void func_80BD1DB8(EnZov* this, GlobalContext* globalCtx) { +void func_80BD1DB8(EnZov* this, PlayState* play) { 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; + Math_SmoothStepToS(&this->picto.actor.shape.rot.y, this->picto.actor.yawTowardsPlayer, 2, 0x1000, 0x200); + this->picto.actor.world.rot.y = this->picto.actor.shape.rot.y; - if ((Message_GetState(&globalCtx->msgCtx) == 5) && Message_ShouldAdvance(globalCtx)) { - switch (globalCtx->msgCtx.currentTextId) { + if ((Message_GetState(&play->msgCtx) == TEXT_STATE_5) && Message_ShouldAdvance(play)) { + switch (play->msgCtx.currentTextId) { case 0x1033: case 0x1034: case 0x1035: case 0x1036: case 0x1037: case 0x1038: - func_80151938(globalCtx, globalCtx->msgCtx.currentTextId + 1); + func_80151938(play, play->msgCtx.currentTextId + 1); break; case 0x1039: - globalCtx->nextEntranceIndex = globalCtx->setupExitList[ENZOV_GET_FE00(&this->actor)]; - globalCtx->unk_1887F = 5; - globalCtx->sceneLoadFlag = 0x14; + play->nextEntrance = play->setupExitList[ENZOV_GET_FE00(&this->picto.actor)]; + play->transitionType = TRANS_TYPE_05; + play->transitionTrigger = TRANS_TRIGGER_START; gSaveContext.save.weekEventReg[78] |= 1; this->actionFunc = func_80BD1D94; - globalCtx->msgCtx.unk11F10 = 0; + play->msgCtx.msgLength = 0; Audio_QueueSeqCmd(0x101400FF); break; default: - func_801477B4(globalCtx); + func_801477B4(play); this->actionFunc = func_80BD1F1C; break; } } } -void func_80BD1F1C(EnZov* this, GlobalContext* globalCtx) { +void func_80BD1F1C(EnZov* this, PlayState* play) { 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 (this->picto.actor.home.rot.y != this->picto.actor.shape.rot.y) { + Math_SmoothStepToS(&this->picto.actor.shape.rot.y, this->picto.actor.home.rot.y, 2, 0x1000, 0x200); + this->picto.actor.world.rot.y = this->picto.actor.shape.rot.y; } - if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { + if (Actor_ProcessTalkRequest(&this->picto.actor, &play->state)) { this->actionFunc = func_80BD1DB8; - func_80BD1D30(this, globalCtx); - } else if (func_80BD15A4(this, globalCtx)) { - func_800B8614(&this->actor, globalCtx, 120.0f); + func_80BD1D30(this, play); + } else if (func_80BD15A4(this, play)) { + func_800B8614(&this->picto.actor, play, 120.0f); } } -s32 func_80BD1FC8(GlobalContext* globalCtx, EnZov* this) { +s32 EnZov_ValidatePictograph(PlayState* play, Actor* thisx) { s32 ret; - s32 pad; + EnZov* this = THIS; - 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); + ret = Snap_ValidatePictograph(play, &this->picto.actor, PICTOGRAPH_LULU_HEAD, &this->picto.actor.focus.pos, + &this->picto.actor.shape.rot, 10.0f, 300.0f, -1); + ret |= Snap_ValidatePictograph(play, &this->picto.actor, PICTOGRAPH_LULU_RIGHT_ARM, &this->unk_308, + &this->picto.actor.shape.rot, 50.0f, 160.0f, 0x3000); + ret |= Snap_ValidatePictograph(play, &this->picto.actor, PICTOGRAPH_LULU_LEFT_ARM, &this->unk_314, + &this->picto.actor.shape.rot, 50.0f, 160.0f, 0x3000); return ret; } -void EnZov_Update(Actor* thisx, GlobalContext* globalCtx) { +void EnZov_Update(Actor* thisx, PlayState* play) { 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); + Actor_MoveWithGravity(&this->picto.actor); + Collider_UpdateCylinder(&this->picto.actor, &this->collider); + CollisionCheck_SetOC(play, &play->colChkCtx, &this->collider.base); + Actor_UpdateBgCheckInfo(play, &this->picto.actor, 10.0f, 10.0f, 10.0f, 4); - this->actionFunc(this, globalCtx); + this->actionFunc(this, play); - if (!Cutscene_CheckActorAction(globalCtx, 0x1F8)) { + if (!Cutscene_CheckActorAction(play, 0x1F8)) { this->unk_320 &= ~0x10; } - if ((this->unk_320 & 1) && func_80BD15A4(this, globalCtx)) { - func_800E9250(globalCtx, &this->actor, &this->unk_2F0, &this->unk_2F6, this->actor.focus.pos); + if ((this->unk_320 & 1) && func_80BD15A4(this, play)) { + Actor_TrackPlayer(play, &this->picto.actor, &this->unk_2F0, &this->unk_2F6, this->picto.actor.focus.pos); } else { if ((this->unk_320 & 0x10) && (this->unk_322 == 0)) { Math_SmoothStepToS(&this->unk_2F0.x, -0x1B58, 6, 0x1838, 0x64); @@ -508,14 +511,14 @@ void EnZov_Update(Actor* thisx, GlobalContext* globalCtx) { 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); + ActorCutscene_Start(this->unk_328[this->unk_32C], &this->picto.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) { +s32 EnZov_OverrideLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, Actor* thisx) { EnZov* this = THIS; if (limbIndex == 12) { @@ -531,25 +534,25 @@ s32 EnZov_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, return false; } -void EnZov_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx) { +void EnZov_PostLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx) { EnZov* this = THIS; if (limbIndex == 12) { - Matrix_MultiplyVector3fByState(&D_80BD2744, &this->actor.focus.pos); - Math_Vec3f_Copy(&this->unk_2FC, &this->actor.focus.pos); + Matrix_MultVec3f(&D_80BD2744, &this->picto.actor.focus.pos); + Math_Vec3f_Copy(&this->unk_2FC, &this->picto.actor.focus.pos); this->unk_2FC.y += 10.0f; } if (limbIndex == 18) { - Matrix_MultiplyVector3fByState(&D_80BD2750, &this->unk_308); + Matrix_MultVec3f(&D_80BD2750, &this->unk_308); } if (limbIndex == 13) { - Matrix_MultiplyVector3fByState(&D_80BD2750, &this->unk_314); + Matrix_MultVec3f(&D_80BD2750, &this->unk_314); } } -void EnZov_Draw(Actor* thisx, GlobalContext* globalCtx) { +void EnZov_Draw(Actor* thisx, PlayState* play) { EnZov* this = THIS; Gfx* gfx; s32 curFrame; @@ -558,9 +561,9 @@ void EnZov_Draw(Actor* thisx, GlobalContext* globalCtx) { if (1) {} - OPEN_DISPS(globalCtx->state.gfxCtx); + OPEN_DISPS(play->state.gfxCtx); - func_8012C28C(globalCtx->state.gfxCtx); + func_8012C28C(play->state.gfxCtx); phi_a1 = 0; curFrame = this->skelAnime.curFrame; phi_v1 = this->unk_2EC; @@ -626,8 +629,8 @@ void EnZov_Draw(Actor* thisx, GlobalContext* globalCtx) { gSPSegment(&gfx[1], 0x08, Lib_SegmentedToVirtual(D_80BD2768[phi_a1])); POLY_OPA_DISP = &gfx[2]; - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->state.gfxCtx); - SkelAnime_DrawFlexOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, - EnZov_OverrideLimbDraw, EnZov_PostLimbDraw, &this->actor); + SkelAnime_DrawFlexOpa(play, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, + EnZov_OverrideLimbDraw, EnZov_PostLimbDraw, &this->picto.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 ce1cc9d0f..25966f994 100644 --- a/src/overlays/actors/ovl_En_Zov/z_en_zov.h +++ b/src/overlays/actors/ovl_En_Zov/z_en_zov.h @@ -2,11 +2,11 @@ #define Z_EN_ZOV_H #include "global.h" +#include "z64snap.h" struct EnZov; -typedef void (*EnZovActionFunc)(struct EnZov*, GlobalContext*); -typedef s32 (*EnZovUnkFunc)(GlobalContext*, struct EnZov*); +typedef void (*EnZovActionFunc)(struct EnZov*, PlayState*); #define ENZOV_GET_F(thisx) ((thisx)->params & 0xF) #define ENZOV_GET_FE00(thisx) (((thisx)->params & 0xFE00) >> 9) @@ -15,26 +15,25 @@ typedef s32 (*EnZovUnkFunc)(GlobalContext*, struct EnZov*); #define ENZOV_F_2 2 typedef struct EnZov { - /* 0x0000 */ Actor actor; - /* 0x0144 */ EnZovUnkFunc unk_144; - /* 0x0148 */ Vec3s jontTable[23]; - /* 0x01D2 */ Vec3s morphTable[23]; - /* 0x025C */ SkelAnime skelAnime; - /* 0x02A0 */ ColliderCylinder collider; - /* 0x02EC */ s16 unk_2EC; - /* 0x02EE */ s16 unk_2EE; - /* 0x02F0 */ Vec3s unk_2F0; - /* 0x02F6 */ Vec3s unk_2F6; - /* 0x02FC */ Vec3f unk_2FC; - /* 0x0308 */ Vec3f unk_308; - /* 0x0314 */ Vec3f unk_314; - /* 0x0320 */ u16 unk_320; - /* 0x0322 */ s16 unk_322; - /* 0x0324 */ s16 unk_324; - /* 0x0326 */ s16 unk_326; - /* 0x0328 */ s16 unk_328[2]; - /* 0x032C */ s16 unk_32C; - /* 0x0330 */ EnZovActionFunc actionFunc; + /* 0x000 */ PictoActor picto; + /* 0x148 */ Vec3s jontTable[23]; + /* 0x1D2 */ Vec3s morphTable[23]; + /* 0x25C */ SkelAnime skelAnime; + /* 0x2A0 */ ColliderCylinder collider; + /* 0x2EC */ s16 unk_2EC; + /* 0x2EE */ s16 unk_2EE; + /* 0x2F0 */ Vec3s unk_2F0; + /* 0x2F6 */ Vec3s unk_2F6; + /* 0x2FC */ Vec3f unk_2FC; + /* 0x308 */ Vec3f unk_308; + /* 0x314 */ Vec3f unk_314; + /* 0x320 */ u16 unk_320; + /* 0x322 */ s16 unk_322; + /* 0x324 */ s16 unk_324; + /* 0x326 */ s16 unk_326; + /* 0x328 */ s16 unk_328[2]; + /* 0x32C */ s16 unk_32C; + /* 0x330 */ EnZovActionFunc actionFunc; } EnZov; // size = 0x334 extern const ActorInit En_Zov_InitVars; diff --git a/src/overlays/actors/ovl_En_Zow/z_en_zow.c b/src/overlays/actors/ovl_En_Zow/z_en_zow.c index ff258fc20..4779fdedd 100644 --- a/src/overlays/actors/ovl_En_Zow/z_en_zow.c +++ b/src/overlays/actors/ovl_En_Zow/z_en_zow.c @@ -11,16 +11,16 @@ #define THIS ((EnZow*)thisx) -void EnZow_Init(Actor* thisx, GlobalContext* globalCtx); -void EnZow_Destroy(Actor* thisx, GlobalContext* globalCtx); -void EnZow_Update(Actor* thisx, GlobalContext* globalCtx); -void EnZow_Draw(Actor* thisx, GlobalContext* globalCtx); +void EnZow_Init(Actor* thisx, PlayState* play); +void EnZow_Destroy(Actor* thisx, PlayState* play); +void EnZow_Update(Actor* thisx, PlayState* play); +void EnZow_Draw(Actor* thisx, PlayState* play); -void func_80BDD350(EnZow* this, GlobalContext* globalCtx); -void func_80BDD570(EnZow* this, GlobalContext* globalCtx); -void func_80BDD634(EnZow* this, GlobalContext* globalCtx); -void func_80BDD6BC(EnZow* this, GlobalContext* globalCtx); -void func_80BDD79C(EnZow* this, GlobalContext* globalCtx); +void func_80BDD350(EnZow* this, PlayState* play); +void func_80BDD570(EnZow* this, PlayState* play); +void func_80BDD634(EnZow* this, PlayState* play); +void func_80BDD6BC(EnZow* this, PlayState* play); +void func_80BDD79C(EnZow* this, PlayState* play); const ActorInit En_Zow_InitVars = { ACTOR_EN_ZOW, @@ -176,19 +176,19 @@ void func_80BDC6F8(EnZow* this, EnZowStruct* ptr) { } } -void func_80BDC830(EnZowStruct* ptr, GlobalContext* globalCtx) { +void func_80BDC830(EnZowStruct* ptr, PlayState* play) { s16 i; - OPEN_DISPS(globalCtx->state.gfxCtx); + OPEN_DISPS(play->state.gfxCtx); u8 flag = false; - func_8012C2DC(globalCtx->state.gfxCtx); + func_8012C2DC(play->state.gfxCtx); for (i = 0; i < 15; i++, ptr++) { if (ptr->unk_00 == 1) { if (!flag) { gDPPipeSync(POLY_XLU_DISP++); - gSPDisplayList(POLY_XLU_DISP++, object_zo_DL_00D220); + gSPDisplayList(POLY_XLU_DISP++, gZoraRippleMaterialDL); gDPSetEnvColor(POLY_XLU_DISP++, 155, 155, 155, 0); if (1) {} flag = true; @@ -196,30 +196,29 @@ void func_80BDC830(EnZowStruct* ptr, GlobalContext* globalCtx) { gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 255, 255, 255, ptr->unk_0F); - Matrix_InsertTranslation(ptr->unk_14.x, ptr->unk_14.y, ptr->unk_14.z, MTXMODE_NEW); + 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); - gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), - G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - gSPDisplayList(POLY_XLU_DISP++, object_zo_DL_00D288); + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_XLU_DISP++, gZoraRippleModelDL); } } - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->state.gfxCtx); } -void func_80BDC9DC(EnZowStruct* ptr, GlobalContext* globalCtx) { +void func_80BDC9DC(EnZowStruct* ptr, PlayState* play) { s16 i; - OPEN_DISPS(globalCtx->state.gfxCtx); + OPEN_DISPS(play->state.gfxCtx); u8 flag = false; - func_8012C2DC(globalCtx->state.gfxCtx); + func_8012C2DC(play->state.gfxCtx); for (i = 0; i < 15; i++, ptr++) { if (ptr->unk_00 == 3) { if (!flag) { - gSPDisplayList(POLY_XLU_DISP++, object_zo_DL_0029F0); + 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); @@ -227,31 +226,30 @@ void func_80BDC9DC(EnZowStruct* ptr, GlobalContext* globalCtx) { flag = true; } - Matrix_InsertTranslation(ptr->unk_14.x, ptr->unk_14.y, ptr->unk_14.z, MTXMODE_NEW); - Matrix_NormalizeXYZ(&globalCtx->billboardMtxF); + Matrix_Translate(ptr->unk_14.x, ptr->unk_14.y, ptr->unk_14.z, MTXMODE_NEW); + Matrix_ReplaceRotation(&play->billboardMtxF); Matrix_Scale(ptr->unk_04, ptr->unk_04, 1.0f, MTXMODE_APPLY); - gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), - G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - gSPDisplayList(POLY_XLU_DISP++, object_zo_DL_002A50); + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_XLU_DISP++, gZoraBubbleModelDL); } } - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->state.gfxCtx); } -void func_80BDCB84(EnZowStruct* ptr, GlobalContext* globalCtx) { +void func_80BDCB84(EnZowStruct* ptr, PlayState* play) { s16 i; - OPEN_DISPS(globalCtx->state.gfxCtx); + OPEN_DISPS(play->state.gfxCtx); u8 flag = false; - func_8012C2DC(globalCtx->state.gfxCtx); + func_8012C2DC(play->state.gfxCtx); for (i = 0; i < 15; i++, ptr++) { if (ptr->unk_00 == 2) { if (!flag) { - gSPDisplayList(POLY_XLU_DISP++, object_zo_DL_002BA0); + gSPDisplayList(POLY_XLU_DISP++, gZoraSplashMaterialDL); gDPPipeSync(POLY_XLU_DISP++); gDPSetEnvColor(POLY_XLU_DISP++, 200, 200, 200, 0); if (1) {} @@ -260,17 +258,16 @@ void func_80BDCB84(EnZowStruct* ptr, GlobalContext* globalCtx) { gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 180, 180, 180, ptr->unk_0F); - Matrix_InsertTranslation(ptr->unk_14.x, ptr->unk_14.y, ptr->unk_14.z, MTXMODE_NEW); - Matrix_NormalizeXYZ(&globalCtx->billboardMtxF); + Matrix_Translate(ptr->unk_14.x, ptr->unk_14.y, ptr->unk_14.z, MTXMODE_NEW); + Matrix_ReplaceRotation(&play->billboardMtxF); Matrix_Scale(ptr->unk_04, ptr->unk_04, 1.0f, MTXMODE_APPLY); - gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), - G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - gSPDisplayList(POLY_XLU_DISP++, object_zo_DL_002C10); + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_XLU_DISP++, gZoraSplashModelDL); } } - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->state.gfxCtx); } void func_80BDCD38(EnZow* this, EnZowStruct* ptr, f32 arg2, f32 arg3, u8 arg4) { @@ -294,8 +291,8 @@ void func_80BDCDA8(EnZow* this, EnZowStruct* ptr) { 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; + 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; @@ -306,17 +303,17 @@ void func_80BDCDA8(EnZow* this, EnZowStruct* ptr) { } } -void EnZow_Init(Actor* thisx, GlobalContext* globalCtx) { +void EnZow_Init(Actor* thisx, PlayState* play) { 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); + SkelAnime_InitFlex(play, &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); + Collider_InitAndSetCylinder(play, &this->collider, &this->actor, &sCylinderInit); this->actor.shape.rot.z = 0; this->unk_2CA = 0; this->unk_2CC = 0; @@ -327,13 +324,13 @@ void EnZow_Init(Actor* thisx, GlobalContext* globalCtx) { this->actor.flags &= ~ACTOR_FLAG_1; } -void EnZow_Destroy(Actor* thisx, GlobalContext* globalCtx) { +void EnZow_Destroy(Actor* thisx, PlayState* play) { EnZow* this = THIS; - Collider_DestroyCylinder(globalCtx, &this->collider); + Collider_DestroyCylinder(play, &this->collider); } -AnimationHeader* sAnimations[] = { &object_zo_Anim_004168, &gZoraSurfacingAnim, &gZoraSurfacingAnim }; +static AnimationHeader* sAnimations[] = { &gZoraTreadingWaterAnim, &gZoraSurfacingAnim, &gZoraSurfacingAnim }; void func_80BDD04C(EnZow* this, s16 arg1, u8 arg2) { if ((arg1 >= 0) && (arg1 < 3)) { @@ -348,15 +345,15 @@ void func_80BDD04C(EnZow* this, s16 arg1, u8 arg2) { } } -s32 func_80BDD154(EnZow* this, GlobalContext* globalCtx) { - if (Player_IsFacingActor(&this->actor, 0x3000, globalCtx) && Actor_IsFacingPlayer(&this->actor, 0x3000) && +s32 func_80BDD154(EnZow* this, PlayState* play) { + if (Player_IsFacingActor(&this->actor, 0x3000, play) && 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) { +void func_80BDD1E0(EnZow* this, PlayState* play) { u16 phi_a1; if (ENZOW_GET_F(&this->actor) == ENZOW_F_1) { @@ -403,10 +400,10 @@ void func_80BDD1E0(EnZow* this, GlobalContext* globalCtx) { } else { phi_a1 = 0x12EF; } - Message_StartTextbox(globalCtx, phi_a1, &this->actor); + Message_StartTextbox(play, phi_a1, &this->actor); } -void func_80BDD350(EnZow* this, GlobalContext* globalCtx) { +void func_80BDD350(EnZow* this, PlayState* play) { if (this->unk_2CA & 2) { Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_DIVE_WATER); func_80BDCDA8(this, this->unk_2D0); @@ -438,16 +435,16 @@ void func_80BDD350(EnZow* this, GlobalContext* globalCtx) { } } -void func_80BDD490(EnZow* this, GlobalContext* globalCtx) { +void func_80BDD490(EnZow* this, PlayState* play) { this->actor.velocity.y = 0.0f; if (this->actor.xzDistToPlayer > 440.0f) { this->actionFunc = func_80BDD350; - func_80BDD04C(this, 2, 2); + func_80BDD04C(this, 2, ANIMMODE_ONCE); } else if (this->unk_2CA & 2) { - func_80BDD04C(this, 0, 0); + func_80BDD04C(this, 0, ANIMMODE_LOOP); } - if ((globalCtx->gameplayFrames & 7) == 0) { + if ((play->gameplayFrames & 7) == 0) { func_80BDCD38(this, this->unk_2D0, 0.2f, 1.0f, 200); } @@ -458,13 +455,13 @@ void func_80BDD490(EnZow* this, GlobalContext* globalCtx) { } } -void func_80BDD570(EnZow* this, GlobalContext* globalCtx) { - func_80BDD490(this, globalCtx); +void func_80BDD570(EnZow* this, PlayState* play) { + func_80BDD490(this, play); - switch (Message_GetState(&globalCtx->msgCtx)) { - case 5: - if (Message_ShouldAdvance(globalCtx)) { - switch (globalCtx->msgCtx.currentTextId) { + switch (Message_GetState(&play->msgCtx)) { + case TEXT_STATE_5: + if (Message_ShouldAdvance(play)) { + switch (play->msgCtx.currentTextId) { case 0x12E8: case 0x12E9: case 0x12EC: @@ -480,33 +477,33 @@ void func_80BDD570(EnZow* this, GlobalContext* globalCtx) { case 0x12FB: case 0x12FD: case 0x12FF: - func_80151938(globalCtx, globalCtx->msgCtx.currentTextId + 1); + func_80151938(play, play->msgCtx.currentTextId + 1); break; default: - func_801477B4(globalCtx); + func_801477B4(play); break; } } break; - case 2: + case TEXT_STATE_CLOSING: this->actionFunc = func_80BDD634; break; } } -void func_80BDD634(EnZow* this, GlobalContext* globalCtx) { - func_80BDD490(this, globalCtx); - if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { +void func_80BDD634(EnZow* this, PlayState* play) { + func_80BDD490(this, play); + if (Actor_ProcessTalkRequest(&this->actor, &play->state)) { this->actionFunc = func_80BDD570; - func_80BDD1E0(this, globalCtx); - } else if (func_80BDD154(this, globalCtx)) { - func_800B8614(&this->actor, globalCtx, 180.0f); + func_80BDD1E0(this, play); + } else if (func_80BDD154(this, play)) { + func_800B8614(&this->actor, play, 180.0f); } } -void func_80BDD6BC(EnZow* this, GlobalContext* globalCtx) { +void func_80BDD6BC(EnZow* this, PlayState* play) { if (this->unk_2CE < 245) { this->unk_2CE += 10; } else { @@ -516,7 +513,7 @@ void func_80BDD6BC(EnZow* this, GlobalContext* globalCtx) { if (this->actor.depthInWater < 54.0f) { Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_OUT_OF_WATER); func_80BDCDA8(this, this->unk_2D0); - func_80BDD04C(this, 1, 2); + func_80BDD04C(this, 1, ANIMMODE_ONCE); this->actor.flags |= ACTOR_FLAG_1; this->actor.velocity.y = 0.0f; this->actionFunc = func_80BDD634; @@ -525,7 +522,7 @@ void func_80BDD6BC(EnZow* this, GlobalContext* globalCtx) { } } -void func_80BDD79C(EnZow* this, GlobalContext* globalCtx) { +void func_80BDD79C(EnZow* this, PlayState* play) { if (this->actor.xzDistToPlayer < 400.0f) { this->actor.velocity.y = 4.0f; this->actionFunc = func_80BDD6BC; @@ -542,15 +539,15 @@ void func_80BDD79C(EnZow* this, GlobalContext* globalCtx) { } } -void EnZow_Update(Actor* thisx, GlobalContext* globalCtx) { +void EnZow_Update(Actor* thisx, PlayState* play) { 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); + CollisionCheck_SetOC(play, &play->colChkCtx, &this->collider.base); + Actor_UpdateBgCheckInfo(play, &this->actor, 30.0f, 15.0f, 30.0f, 5); if (this->unk_2CE != 0) { this->unk_2CA &= ~2; @@ -564,10 +561,10 @@ void EnZow_Update(Actor* thisx, 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; - this->actionFunc(this, globalCtx); + this->actionFunc(this, play); if (this->unk_2CE != 0) { - if ((globalCtx->state.frames & 8) != 0) { + if ((play->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; @@ -601,17 +598,17 @@ Gfx* func_80BDDA7C(GraphicsContext* gfxCtx) { Vec3f D_80BDDD4C = { 400.0f, 0.0f, 0.0f }; -void func_80BDDAA0(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx) { +void func_80BDDAA0(PlayState* play, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx) { if (limbIndex == 15) { - Matrix_MultiplyVector3fByState(&D_80BDDD4C, &thisx->focus.pos); + 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 func_80BDDAE0(PlayState* play, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx, Gfx** gfx) { + func_80BDDAA0(play, limbIndex, dList, rot, thisx); } -void EnZow_Draw(Actor* thisx, GlobalContext* globalCtx) { +void EnZow_Draw(Actor* thisx, PlayState* play) { TexturePtr sp54[] = { gZoraEyeOpenTex, gZoraEyeHalfTex, @@ -619,32 +616,32 @@ void EnZow_Draw(Actor* thisx, GlobalContext* globalCtx) { }; EnZow* this = THIS; - Matrix_StatePush(); + Matrix_Push(); - func_80BDC830(this->unk_2D0, globalCtx); - func_80BDC9DC(this->unk_2D0, globalCtx); - func_80BDCB84(this->unk_2D0, globalCtx); + func_80BDC830(this->unk_2D0, play); + func_80BDC9DC(this->unk_2D0, play); + func_80BDCB84(this->unk_2D0, play); - Matrix_StatePop(); + Matrix_Pop(); if (this->unk_2CE != 0) { - OPEN_DISPS(globalCtx->state.gfxCtx); + OPEN_DISPS(play->state.gfxCtx); if (this->unk_2CE >= 255) { - func_8012C28C(globalCtx->state.gfxCtx); + func_8012C28C(play->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)); + gSPSegment(POLY_OPA_DISP++, 0x0C, func_80BDDA7C(play->state.gfxCtx)); - SkelAnime_DrawFlexOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, + SkelAnime_DrawFlexOpa(play, 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); + func_800BDAA0(play, &this->skelAnime, NULL, func_80BDDAE0, &this->actor, this->unk_2CE); } - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->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 e169e2816..777a0aa9d 100644 --- a/src/overlays/actors/ovl_En_Zow/z_en_zow.h +++ b/src/overlays/actors/ovl_En_Zow/z_en_zow.h @@ -5,7 +5,7 @@ struct EnZow; -typedef void (*EnZowActionFunc)(struct EnZow*, GlobalContext*); +typedef void (*EnZowActionFunc)(struct EnZow*, PlayState*); #define ENZOW_GET_F(thisx) ((thisx)->params & 0xF) @@ -24,19 +24,19 @@ typedef struct { } EnZowStruct; // size = 0x38 typedef struct EnZow { - /* 0x0000 */ Actor actor; - /* 0x0144 */ SkelAnime skelAnime; - /* 0x0188 */ ColliderCylinder collider; - /* 0x01D4 */ Vec3s jointTable[20]; - /* 0x024C */ Vec3s morphTable[20]; - /* 0x02C4 */ s16 unk_2C4; - /* 0x02C6 */ s16 unk_2C6; - /* 0x02C8 */ s16 unk_2C8; - /* 0x02CA */ u16 unk_2CA; - /* 0x02CC */ s16 unk_2CC; - /* 0x02CE */ s16 unk_2CE; - /* 0x02D0 */ EnZowStruct unk_2D0[15]; - /* 0x0618 */ EnZowActionFunc actionFunc; + /* 0x000 */ Actor actor; + /* 0x144 */ SkelAnime skelAnime; + /* 0x188 */ ColliderCylinder collider; + /* 0x1D4 */ Vec3s jointTable[20]; + /* 0x24C */ Vec3s morphTable[20]; + /* 0x2C4 */ s16 unk_2C4; + /* 0x2C6 */ s16 unk_2C6; + /* 0x2C8 */ s16 unk_2C8; + /* 0x2CA */ u16 unk_2CA; + /* 0x2CC */ s16 unk_2CC; + /* 0x2CE */ s16 unk_2CE; + /* 0x2D0 */ EnZowStruct unk_2D0[15]; + /* 0x618 */ EnZowActionFunc actionFunc; } EnZow; // size = 0x61C extern const ActorInit En_Zow_InitVars; diff --git a/src/overlays/actors/ovl_Item_B_Heart/z_item_b_heart.c b/src/overlays/actors/ovl_Item_B_Heart/z_item_b_heart.c index d02bb91da..ac8592615 100644 --- a/src/overlays/actors/ovl_Item_B_Heart/z_item_b_heart.c +++ b/src/overlays/actors/ovl_Item_B_Heart/z_item_b_heart.c @@ -11,12 +11,12 @@ #define THIS ((ItemBHeart*)thisx) -void ItemBHeart_Init(Actor* thisx, GlobalContext* globalCtx); -void ItemBHeart_Destroy(Actor* thisx, GlobalContext* globalCtx); -void ItemBHeart_Update(Actor* thisx, GlobalContext* globalCtx); -void ItemBHeart_Draw(Actor* thisx, GlobalContext* globalCtx); +void ItemBHeart_Init(Actor* thisx, PlayState* play); +void ItemBHeart_Destroy(Actor* thisx, PlayState* play); +void ItemBHeart_Update(Actor* thisx, PlayState* play); +void ItemBHeart_Draw(Actor* thisx, PlayState* play); -void func_808BCF54(ItemBHeart* this, GlobalContext* globalCtx); +void func_808BCF54(ItemBHeart* this, PlayState* play); const ActorInit Item_B_Heart_InitVars = { ACTOR_ITEM_B_HEART, @@ -37,10 +37,10 @@ static InitChainEntry sInitChain[] = { ICHAIN_F32(uncullZoneDownward, 800, ICHAIN_STOP), }; -void ItemBHeart_Init(Actor* thisx, GlobalContext* globalCtx) { +void ItemBHeart_Init(Actor* thisx, PlayState* play) { ItemBHeart* this = THIS; - if (Flags_GetCollectible(globalCtx, 0x1F)) { + if (Flags_GetCollectible(play, 0x1F)) { Actor_MarkForDeath(&this->actor); return; } @@ -57,38 +57,38 @@ void ItemBHeart_Init(Actor* thisx, GlobalContext* globalCtx) { this->actor.world.pos.y += (20.0f * this->unk_168); } -void ItemBHeart_Destroy(Actor* thisx, GlobalContext* globalCtx) { +void ItemBHeart_Destroy(Actor* thisx, PlayState* play) { } -void ItemBHeart_Update(Actor* thisx, GlobalContext* globalCtx) { +void ItemBHeart_Update(Actor* thisx, PlayState* play) { ItemBHeart* this = THIS; - func_808BCF54(this, globalCtx); + func_808BCF54(this, play); if (!(this->unk_168 < 0.5f)) { - if (Actor_HasParent(&this->actor, globalCtx)) { - Flags_SetCollectible(globalCtx, 0x1F); + if (Actor_HasParent(&this->actor, play)) { + Flags_SetCollectible(play, 0x1F); Actor_MarkForDeath(&this->actor); } else { - Actor_PickUp(&this->actor, globalCtx, GI_HEART_CONTAINER, 30.0f, 80.0f); + Actor_PickUp(&this->actor, play, GI_HEART_CONTAINER, 30.0f, 80.0f); } } } -void func_808BCF54(ItemBHeart* this, GlobalContext* globalCtx) { +void func_808BCF54(ItemBHeart* this, PlayState* play) { this->actor.shape.rot.y += 0x400; Math_ApproachF(&this->unk_164, 0.4f, 0.1f, 0.01f); Actor_SetScale(&this->actor, this->unk_164 * this->unk_168); } -void ItemBHeart_Draw(Actor* thisx, GlobalContext* globalCtx) { +void ItemBHeart_Draw(Actor* thisx, PlayState* play) { ItemBHeart* this = THIS; Actor* blueWarpActor; u8 flag = false; - OPEN_DISPS(globalCtx->state.gfxCtx); + OPEN_DISPS(play->state.gfxCtx); - blueWarpActor = globalCtx->actorCtx.actorLists[ACTORCAT_ITEMACTION].first; + blueWarpActor = play->actorCtx.actorLists[ACTORCAT_ITEMACTION].first; while (blueWarpActor != NULL) { if ((blueWarpActor->id == ACTOR_DOOR_WARP1) && (blueWarpActor->projectedPos.z > this->actor.projectedPos.z)) { @@ -99,16 +99,16 @@ void ItemBHeart_Draw(Actor* thisx, GlobalContext* globalCtx) { } if (flag || thisx->world.rot.y != 0) { - 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_gi_hearts_DL_001290); - gSPDisplayList(POLY_XLU_DISP++, object_gi_hearts_DL_001470); + func_8012C2DC(play->state.gfxCtx); + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_XLU_DISP++, gGiHeartBorderDL); + gSPDisplayList(POLY_XLU_DISP++, gGiHeartContainerDL); } else { - func_8012C28C(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_gi_hearts_DL_001290); - gSPDisplayList(POLY_OPA_DISP++, object_gi_hearts_DL_001470); + func_8012C28C(play->state.gfxCtx); + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_OPA_DISP++, gGiHeartBorderDL); + gSPDisplayList(POLY_OPA_DISP++, gGiHeartContainerDL); } - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->state.gfxCtx); } diff --git a/src/overlays/actors/ovl_Item_B_Heart/z_item_b_heart.h b/src/overlays/actors/ovl_Item_B_Heart/z_item_b_heart.h index ccf7b43bd..b89e10edd 100644 --- a/src/overlays/actors/ovl_Item_B_Heart/z_item_b_heart.h +++ b/src/overlays/actors/ovl_Item_B_Heart/z_item_b_heart.h @@ -7,7 +7,7 @@ struct ItemBHeart; typedef struct ItemBHeart { /* 0x000 */ Actor actor; - /* 0x144 */ char unk_144[0x20]; + /* 0x144 */ UNK_TYPE1 unk_144[0x20]; /* 0x164 */ f32 unk_164; /* 0x168 */ f32 unk_168; } ItemBHeart; // size = 0x16C diff --git a/src/overlays/actors/ovl_Item_Etcetera/z_item_etcetera.c b/src/overlays/actors/ovl_Item_Etcetera/z_item_etcetera.c index 82b29e716..d2fa8e3a0 100644 --- a/src/overlays/actors/ovl_Item_Etcetera/z_item_etcetera.c +++ b/src/overlays/actors/ovl_Item_Etcetera/z_item_etcetera.c @@ -10,15 +10,16 @@ #define THIS ((ItemEtcetera*)thisx) -void ItemEtcetera_Init(Actor* thisx, GlobalContext* globalCtx); -void ItemEtcetera_Destroy(Actor* thisx, GlobalContext* globalCtx); -void ItemEtcetera_Update(Actor* thisx, GlobalContext* globalCtx); +void ItemEtcetera_Init(Actor* thisx, PlayState* play); +void ItemEtcetera_Destroy(Actor* thisx, PlayState* play); +void ItemEtcetera_Update(Actor* thisx, PlayState* play); -void func_80920044(ItemEtcetera* this, GlobalContext* globalCtx); +void ItemEtcetera_WaitForObject(ItemEtcetera* this, PlayState* play); +void func_8092009C(ItemEtcetera* this, PlayState* play); +void func_809200F8(ItemEtcetera* this, PlayState* play); +void ItemEtcetera_DrawThroughLens(Actor* thisx, PlayState* play); +void ItemEtcetera_Draw(Actor* thisx, PlayState* play); -void ItemEtcetera_SetupAction(ItemEtcetera* this, ItemEtceteraActionFunc actionFunc); - -#if 0 const ActorInit Item_Etcetera_InitVars = { ACTOR_ITEM_ETCETERA, ACTORCAT_PROP, @@ -31,22 +32,108 @@ const ActorInit Item_Etcetera_InitVars = { (ActorFunc)NULL, }; -#endif +static s16 sObjectIds[] = { + OBJECT_GI_BOTTLE, OBJECT_GI_BOTTLE, OBJECT_GI_BOTTLE, OBJECT_GI_BOTTLE, OBJECT_GI_BOTTLE, + OBJECT_GI_BOTTLE, OBJECT_GI_KEY, OBJECT_GI_M_ARROW, OBJECT_GI_RUPY, OBJECT_GI_RUPY, + OBJECT_GI_RUPY, OBJECT_GI_RUPY, OBJECT_GI_HEARTS, OBJECT_GI_KEY, +}; +static s16 sGetItemDrawIds[] = { + GID_BOTTLE, GID_BOTTLE, GID_BOTTLE, GID_BOTTLE, GID_BOTTLE, GID_BOTTLE, GID_KEY_SMALL, + GID_ARROW_FIRE, GID_RUPEE_GREEN, GID_RUPEE_BLUE, GID_RUPEE_RED, GID_RUPEE_PURPLE, GID_HEART_PIECE, GID_KEY_SMALL, +}; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Item_Etcetera/ItemEtcetera_SetupAction.s") +static s16 sGetItemIds[] = { + GI_BOTTLE, GI_BOTTLE, GI_BOTTLE, GI_BOTTLE, GI_BOTTLE, GI_BOTTLE, GI_KEY_SMALL, + GI_ARROW_FIRE, GI_NONE, GI_NONE, GI_NONE, GI_NONE, GI_NONE, GI_NONE, +}; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Item_Etcetera/ItemEtcetera_Init.s") +void ItemEtcetera_SetupAction(ItemEtcetera* this, ItemEtceteraActionFunc actionFunc) { + this->actionFunc = actionFunc; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Item_Etcetera/ItemEtcetera_Destroy.s") +void ItemEtcetera_Init(Actor* thisx, PlayState* play) { + s32 pad; + ItemEtcetera* this = THIS; + s32 type = ITEMETCETERA_GET_FF(&this->actor); + s32 objBankIndex = Object_GetIndex(&play->objectCtx, sObjectIds[type]); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Item_Etcetera/func_80920044.s") + if (objBankIndex < 0) { + // assert on debug + } else { + this->objIndex = objBankIndex; + } + this->getItemDrawId = sGetItemDrawIds[type]; + this->getItemId = sGetItemIds[type]; + this->futureActionFunc = func_8092009C; + this->drawFunc = ItemEtcetera_Draw; + Actor_SetScale(&this->actor, 0.25f); + ItemEtcetera_SetupAction(this, ItemEtcetera_WaitForObject); + switch (type) { + case ITEM_ETC_ARROW_FIRE: + Actor_SetScale(&this->actor, 0.5f); + this->actor.draw = NULL; + this->actor.shape.yOffset = 50.0f; + break; + case ITEM_ETC_RUPEE_GREEN_CHEST_GAME: + case ITEM_ETC_RUPEE_BLUE_CHEST_GAME: + case ITEM_ETC_RUPEE_RED_CHEST_GAME: + case ITEM_ETC_RUPEE_PURPLE_CHEST_GAME: + case ITEM_ETC_HEART_PIECE_CHEST_GAME: + case ITEM_ETC_KEY_SMALL_CHEST_GAME: + Actor_SetScale(&this->actor, 0.5f); + this->futureActionFunc = func_809200F8; + this->drawFunc = ItemEtcetera_DrawThroughLens; + this->actor.world.pos.y += 15.0f; + default: + break; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Item_Etcetera/func_8092009C.s") +void ItemEtcetera_Destroy(Actor* thisx, PlayState* play) { +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Item_Etcetera/func_809200F8.s") +void ItemEtcetera_WaitForObject(ItemEtcetera* this, PlayState* play) { + if (Object_IsLoaded(&play->objectCtx, this->objIndex)) { + this->actor.objBankIndex = this->objIndex; + this->actor.draw = this->drawFunc; + this->actionFunc = this->futureActionFunc; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Item_Etcetera/ItemEtcetera_Update.s") +void func_8092009C(ItemEtcetera* this, PlayState* play) { + if (Actor_HasParent(&this->actor, play)) { + Actor_MarkForDeath(&this->actor); + } else { + Actor_PickUp(&this->actor, play, this->getItemId, 30.0f, 50.0f); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Item_Etcetera/func_80920164.s") +void func_809200F8(ItemEtcetera* this, PlayState* play) { + if (Flags_GetTreasure(play, ITEMETCETERA_GET_TREASUREFLAG(&this->actor))) { + Actor_MarkForDeath(&this->actor); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Item_Etcetera/func_809201BC.s") +void ItemEtcetera_Update(Actor* thisx, PlayState* play) { + ItemEtcetera* this = THIS; + + this->actionFunc(this, play); +} + +void ItemEtcetera_DrawThroughLens(Actor* thisx, PlayState* play) { + ItemEtcetera* this = THIS; + + if (play->actorCtx.unk4 == 100) { + func_800B8050(&this->actor, play, 0); + func_800B8118(&this->actor, play, 0); + GetItem_Draw(play, this->getItemDrawId); + } +} + +void ItemEtcetera_Draw(Actor* thisx, PlayState* play) { + ItemEtcetera* this = THIS; + + func_800B8050(&this->actor, play, 0); + func_800B8118(&this->actor, play, 0); + GetItem_Draw(play, this->getItemDrawId); +} diff --git a/src/overlays/actors/ovl_Item_Etcetera/z_item_etcetera.h b/src/overlays/actors/ovl_Item_Etcetera/z_item_etcetera.h index 88d08a54d..e33f1e1fb 100644 --- a/src/overlays/actors/ovl_Item_Etcetera/z_item_etcetera.h +++ b/src/overlays/actors/ovl_Item_Etcetera/z_item_etcetera.h @@ -5,12 +5,36 @@ struct ItemEtcetera; -typedef void (*ItemEtceteraActionFunc)(struct ItemEtcetera*, GlobalContext*); +#define ITEMETCETERA_GET_FF(thisx) ((thisx)->params & 0xFF) +#define ITEMETCETERA_GET_TREASUREFLAG(thisx) (((thisx)->params >> 8) & 0x1F) + +typedef void (*ItemEtceteraActionFunc)(struct ItemEtcetera*, PlayState*); + +typedef enum { + /* 0x0 */ ITEM_ETC_BOTTLE_1, + /* 0x1 */ ITEM_ETC_BOTTLE_2, + /* 0x2 */ ITEM_ETC_BOTTLE_3, + /* 0x3 */ ITEM_ETC_BOTTLE_4, + /* 0x4 */ ITEM_ETC_BOTTLE_5, + /* 0x5 */ ITEM_ETC_BOTTLE_6, + /* 0x6 */ ITEM_ETC_KEY_SMALL, + /* 0x7 */ ITEM_ETC_ARROW_FIRE, + /* 0x8 */ ITEM_ETC_RUPEE_GREEN_CHEST_GAME, + /* 0x9 */ ITEM_ETC_RUPEE_BLUE_CHEST_GAME, + /* 0xA */ ITEM_ETC_RUPEE_RED_CHEST_GAME, + /* 0xB */ ITEM_ETC_RUPEE_PURPLE_CHEST_GAME, + /* 0xC */ ITEM_ETC_HEART_PIECE_CHEST_GAME, + /* 0xD */ ITEM_ETC_KEY_SMALL_CHEST_GAME +} ItemEtceteraType; typedef struct ItemEtcetera { - /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x10]; - /* 0x0154 */ ItemEtceteraActionFunc actionFunc; + /* 0x000 */ Actor actor; + /* 0x144 */ ItemEtceteraActionFunc futureActionFunc; + /* 0x148 */ s16 getItemDrawId; + /* 0x14A */ s16 getItemId; + /* 0x14C */ u8 objIndex; + /* 0x150 */ ActorFunc drawFunc; + /* 0x154 */ ItemEtceteraActionFunc actionFunc; } ItemEtcetera; // size = 0x158 extern const ActorInit Item_Etcetera_InitVars; 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 7017dfcec..cdf0447e6 100644 --- a/src/overlays/actors/ovl_Item_Inbox/z_item_inbox.c +++ b/src/overlays/actors/ovl_Item_Inbox/z_item_inbox.c @@ -10,12 +10,12 @@ #define THIS ((ItemInbox*)thisx) -void ItemInbox_Init(Actor* thisx, GlobalContext* globalCtx); -void ItemInbox_Destroy(Actor* thisx, GlobalContext* globalCtx); -void ItemInbox_Update(Actor* thisx, GlobalContext* globalCtx); -void ItemInbox_Draw(Actor* thisx, GlobalContext* globalCtx); +void ItemInbox_Init(Actor* thisx, PlayState* play); +void ItemInbox_Destroy(Actor* thisx, PlayState* play); +void ItemInbox_Update(Actor* thisx, PlayState* play); +void ItemInbox_Draw(Actor* thisx, PlayState* play); -void ItemInbox_Idle(ItemInbox* this, GlobalContext* globalCtx); +void ItemInbox_Idle(ItemInbox* this, PlayState* play); const ActorInit Item_Inbox_InitVars = { ACTOR_ITEM_INBOX, @@ -29,32 +29,32 @@ const ActorInit Item_Inbox_InitVars = { (ActorFunc)ItemInbox_Draw, }; -void ItemInbox_Init(Actor* thisx, GlobalContext* globalCtx) { +void ItemInbox_Init(Actor* thisx, PlayState* play) { ItemInbox* this = THIS; this->actionFunc = ItemInbox_Idle; Actor_SetScale(&this->actor, 0.2f); } -void ItemInbox_Destroy(Actor* thisx, GlobalContext* globalCtx) { +void ItemInbox_Destroy(Actor* thisx, PlayState* play) { } -void ItemInbox_Idle(ItemInbox* this, GlobalContext* globalCtx) { - if (Flags_GetTreasure(globalCtx, (this->actor.params >> 8) & 0x1F)) { +void ItemInbox_Idle(ItemInbox* this, PlayState* play) { + if (Flags_GetTreasure(play, (this->actor.params >> 8) & 0x1F)) { Actor_MarkForDeath(&this->actor); } } -void ItemInbox_Update(Actor* thisx, GlobalContext* globalCtx) { +void ItemInbox_Update(Actor* thisx, PlayState* play) { ItemInbox* this = THIS; - this->actionFunc(this, globalCtx); + this->actionFunc(this, play); } -void ItemInbox_Draw(Actor* thisx, GlobalContext* globalCtx) { +void ItemInbox_Draw(Actor* thisx, PlayState* play) { ItemInbox* this = THIS; - func_800B8050(&this->actor, globalCtx, 0); - func_800B8118(&this->actor, globalCtx, 0); - GetItem_Draw(globalCtx, this->actor.params & 0xFF); + func_800B8050(&this->actor, play, 0); + func_800B8118(&this->actor, play, 0); + GetItem_Draw(play, this->actor.params & 0xFF); } diff --git a/src/overlays/actors/ovl_Item_Inbox/z_item_inbox.h b/src/overlays/actors/ovl_Item_Inbox/z_item_inbox.h index b2e1abf60..0b3247ee7 100644 --- a/src/overlays/actors/ovl_Item_Inbox/z_item_inbox.h +++ b/src/overlays/actors/ovl_Item_Inbox/z_item_inbox.h @@ -5,7 +5,7 @@ struct ItemInbox; -typedef void (*ItemInboxActionFunc)(struct ItemInbox*, GlobalContext*); +typedef void (*ItemInboxActionFunc)(struct ItemInbox*, PlayState*); typedef struct ItemInbox { /* 0x000 */ Actor actor; 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 c6de60ce2..5160dc074 100644 --- a/src/overlays/actors/ovl_Mir_Ray/z_mir_ray.c +++ b/src/overlays/actors/ovl_Mir_Ray/z_mir_ray.c @@ -12,10 +12,10 @@ #define THIS ((MirRay*)thisx) -void MirRay_Init(Actor* thisx, GlobalContext* globalCtx); -void MirRay_Destroy(Actor* thisx, GlobalContext* globalCtx); -void MirRay_Update(Actor* thisx, GlobalContext* globalCtx); -void MirRay_Draw(Actor* thisx, GlobalContext* globalCtx); +void MirRay_Init(Actor* thisx, PlayState* play); +void MirRay_Destroy(Actor* thisx, PlayState* play); +void MirRay_Update(Actor* thisx, PlayState* play); +void MirRay_Draw(Actor* thisx, PlayState* play); s32 MirRay_CheckInFrustum(Vec3f* vecA, Vec3f* vecB, f32 pointx, f32 pointy, f32 pointz, s16 radiusA, s16 radiusB); @@ -98,7 +98,7 @@ static ColliderJntSphInit sJntSphInit = { OC2_NONE, COLSHAPE_JNTSPH, }, - 1, + ARRAY_COUNT(sJntSphElementsInit), sJntSphElementsInit, }; @@ -256,8 +256,8 @@ void MirRay_SetupCollider(MirRay* this) { // 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); +void MirRay_MakeShieldLight(MirRay* this, PlayState* play) { + Player* player = GET_PLAYER(play); MirRayDataEntry* dataEntry = &sMirRayData[MIRRAY_LOCATION(&this->actor)]; Vec3f reflectionPt; Vec3s lightPt; @@ -287,7 +287,7 @@ void MirRay_MakeShieldLight(MirRay* this, GlobalContext* globalCtx) { } } -void MirRay_Init(Actor* thisx, GlobalContext* globalCtx) { +void MirRay_Init(Actor* thisx, PlayState* play) { s32 pad; MirRay* this = THIS; MirRayDataEntry* dataEntry = &sMirRayData[MIRRAY_LOCATION(&this->actor)]; @@ -311,7 +311,7 @@ void MirRay_Init(Actor* thisx, GlobalContext* globalCtx) { 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->lightNode = LightContext_InsertLight(play, &play->lightCtx, &this->lightInfo); this->shieldCorners[0].x = -536.0f; this->shieldCorners[0].y = -939.0f; @@ -332,15 +332,15 @@ void MirRay_Init(Actor* thisx, GlobalContext* globalCtx) { 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); + Collider_InitJntSph(play, &this->collider1); + Collider_SetJntSph(play, &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); + Collider_InitQuad(play, &this->collider2); + Collider_SetQuad(play, &this->collider2, &this->actor, &sQuadInit); if ((MIRRAY_LOCATION(&this->actor) == MIRRAY_SPIRIT_TOPROOM_CEILINGMIRROR) || (MIRRAY_LOCATION(&this->actor) == MIRRAY_SPIRIT_TOPROOM_COBRA1) || @@ -349,22 +349,22 @@ void MirRay_Init(Actor* thisx, GlobalContext* globalCtx) { } } -void MirRay_Destroy(Actor* thisx, GlobalContext* globalCtx) { +void MirRay_Destroy(Actor* thisx, PlayState* play) { MirRay* this = THIS; - LightContext_RemoveLight(globalCtx, &globalCtx->lightCtx, this->lightNode); + LightContext_RemoveLight(play, &play->lightCtx, this->lightNode); if (sMirRayData[MIRRAY_LOCATION(&this->actor)].params & 2) { - Collider_DestroyJntSph(globalCtx, &this->collider1); + Collider_DestroyJntSph(play, &this->collider1); } - Collider_DestroyQuad(globalCtx, &this->collider2); + Collider_DestroyQuad(play, &this->collider2); } -void MirRay_Update(Actor* thisx, GlobalContext* globalCtx) { +void MirRay_Update(Actor* thisx, PlayState* play) { s32 pad; MirRay* this = THIS; - Player* player = GET_PLAYER(globalCtx); + Player* player = GET_PLAYER(play); D_808E3BF0 = false; @@ -373,14 +373,14 @@ void MirRay_Update(Actor* thisx, GlobalContext* globalCtx) { if (sMirRayData[MIRRAY_LOCATION(&this->actor)].params & 4) { MirRay_SetupCollider(this); } - CollisionCheck_SetAT(globalCtx, &globalCtx->colChkCtx, &this->collider1.base); + CollisionCheck_SetAT(play, &play->colChkCtx, &this->collider1.base); } if (this->reflectIntensity > 0.0f) { - CollisionCheck_SetAT(globalCtx, &globalCtx->colChkCtx, &this->collider2.base); + CollisionCheck_SetAT(play, &play->colChkCtx, &this->collider2.base); } - MirRay_MakeShieldLight(this, globalCtx); + MirRay_MakeShieldLight(this, play); if (this->reflectIntensity > 0.0f) { func_800B8F98(&player->actor, NA_SE_IT_SHIELD_BEAM - SFX_FLAG); @@ -388,10 +388,10 @@ void MirRay_Update(Actor* thisx, GlobalContext* globalCtx) { } } -void MirRay_SetIntensity(MirRay* this, GlobalContext* globalCtx) { +void MirRay_SetIntensity(MirRay* this, PlayState* play) { f32 sp4C[3]; s32 pad[4]; - Player* player = GET_PLAYER(globalCtx); + Player* player = GET_PLAYER(play); MtxF* shieldMtx = &player->shieldMf; f32 temp_f0; f32 temp_f0_2; @@ -399,9 +399,9 @@ void MirRay_SetIntensity(MirRay* this, GlobalContext* globalCtx) { this->reflectIntensity = 0.0f; - if (MirRay_CheckInFrustum(&this->sourcePt, &this->poolPt, shieldMtx->wx, shieldMtx->wy, shieldMtx->wz, + 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->zx) + SQ(shieldMtx->zy))); + temp_f0 = sqrtf(SQ(shieldMtx->zz) + (SQ(shieldMtx->xz) + SQ(shieldMtx->yz))); if (temp_f0 == 0.0f) { this->reflectRange = 1.0f; } else { @@ -415,7 +415,7 @@ void MirRay_SetIntensity(MirRay* this, GlobalContext* globalCtx) { sp4C[1] = this->poolPt.y - this->sourcePt.y; sp4C[2] = this->poolPt.z - this->sourcePt.z; - temp_f2 = (-shieldMtx->zx * sp4C[0]) - (shieldMtx->zy * sp4C[1]) - (shieldMtx->zz * sp4C[2]); + 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])); @@ -429,9 +429,9 @@ void MirRay_SetIntensity(MirRay* this, GlobalContext* globalCtx) { // 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) { +void MirRay_SetupReflectionPolys(MirRay* this, PlayState* play, MirRayShieldReflection* reflection) { s32 i; - Player* player = GET_PLAYER(globalCtx); + Player* player = GET_PLAYER(play); MtxF* shieldMtx = &player->shieldMf; Vec3f posA; Vec3f posB; @@ -439,23 +439,23 @@ void MirRay_SetupReflectionPolys(MirRay* this, GlobalContext* globalCtx, MirRayS CollisionPoly* outPoly; f32 sp60[3]; - sp60[0] = -(shieldMtx->zx * this->reflectRange) * this->reflectIntensity * 400.0f; - sp60[1] = -(shieldMtx->zy * this->reflectRange) * this->reflectIntensity * 400.0f; + sp60[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->wx + (this->shieldCorners[i].x * shieldMtx->xx)) + (this->shieldCorners[i].y * (*shieldMtx).yx); + (shieldMtx->xw + (this->shieldCorners[i].x * shieldMtx->xx)) + (this->shieldCorners[i].y * (*shieldMtx).xy); posA.y = - (shieldMtx->wy + (this->shieldCorners[i].x * shieldMtx->xy)) + (this->shieldCorners[i].y * (*shieldMtx).yy); + (shieldMtx->yw + (this->shieldCorners[i].x * shieldMtx->yx)) + (this->shieldCorners[i].y * (*shieldMtx).yy); posA.z = - (shieldMtx->wz + (this->shieldCorners[i].x * shieldMtx->xz)) + (this->shieldCorners[i].y * (*shieldMtx).yz); + (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)) { + if (BgCheck_AnyLineTest1(&play->colCtx, &posA, &posB, &sp70, &outPoly, 1)) { reflection[i].reflectionPoly = outPoly; } else { reflection[i].reflectionPoly = NULL; @@ -485,8 +485,8 @@ void MirRay_RemoveSimilarReflections(MirRayShieldReflection* reflection) { // 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); +void MirRay_ReflectedBeam(MirRay* this, PlayState* play, MirRayShieldReflection* reflection) { + Player* player = GET_PLAYER(play); s32 i; f32 temp_f0; Vec3f vecB; @@ -501,25 +501,25 @@ void MirRay_ReflectedBeam(MirRay* this, GlobalContext* globalCtx, MirRayShieldRe Vec3f vecA; Vec3f vecC; - spE8[0] = -(shieldMtx->zx * this->reflectRange) * this->reflectIntensity * 400.0f; - spE8[1] = -(shieldMtx->zy * this->reflectRange) * this->reflectIntensity * 400.0f; + spE8[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->wx; - vecB.y = shieldMtx->wy; - vecB.z = shieldMtx->wz; + 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->xy * 300.0f); - vecA.z = vecB.z + (shieldMtx->xz * 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->xy * 300.0f); - vecC.z = vecD.z + (shieldMtx->xz * 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); @@ -547,8 +547,8 @@ void MirRay_ReflectedBeam(MirRay* this, GlobalContext* globalCtx, MirRayShieldRe reflection[i].opacity = (s32)(reflection[i].opacity * 1.275f); sp10C.x = (shieldMtx->xx * 100.0f) + vecB.x; - sp10C.y = (shieldMtx->xy * 100.0f) + vecB.y; - sp10C.z = (shieldMtx->xz * 100.0f) + vecB.z; + 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; @@ -556,21 +556,21 @@ void MirRay_ReflectedBeam(MirRay* this, GlobalContext* globalCtx, MirRayShieldRe reflection[i].mtx.xx = reflection[i].mtx.yy = reflection[i].mtx.zz = reflection[i].mtx.ww = 1.0f; - reflection[i].mtx.xy = reflection[i].mtx.xz = reflection[i].mtx.xw = reflection[i].mtx.yx = - reflection[i].mtx.yz = reflection[i].mtx.yw = reflection[i].mtx.zx = reflection[i].mtx.zy = - reflection[i].mtx.zw = reflection[i].mtx.wx = reflection[i].mtx.wy = reflection[i].mtx.wz = + 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.xy = intersection.y - sp118.y; - reflection[i].mtx.xz = intersection.z - sp118.z; + reflection[i].mtx.yx = intersection.y - sp118.y; + reflection[i].mtx.zx = intersection.z - sp118.z; } - sp10C.x = (shieldMtx->yx * 100.0f) + vecB.x; + sp10C.x = (shieldMtx->xy * 100.0f) + vecB.x; sp10C.y = (shieldMtx->yy * 100.0f) + vecB.y; - sp10C.z = (shieldMtx->yz * 100.0f) + vecB.z; + sp10C.z = (shieldMtx->zy * 100.0f) + vecB.z; sp100.x = (spE8[0] * 4.0f) + sp10C.x; sp100.y = (spE8[1] * 4.0f) + sp10C.y; @@ -578,9 +578,9 @@ void MirRay_ReflectedBeam(MirRay* this, GlobalContext* globalCtx, MirRayShieldRe if (Math3D_LineSegVsPlane(normalVec[0], normalVec[1], normalVec[2], reflection[i].reflectionPoly->dist, &sp10C, &sp100, &intersection, 1)) { - reflection[i].mtx.yx = intersection.x - sp118.x; + reflection[i].mtx.xy = intersection.x - sp118.x; reflection[i].mtx.yy = intersection.y - sp118.y; - reflection[i].mtx.yz = intersection.z - sp118.z; + reflection[i].mtx.zy = intersection.z - sp118.z; } } else { reflection[i].reflectionPoly = NULL; @@ -589,42 +589,42 @@ void MirRay_ReflectedBeam(MirRay* this, GlobalContext* globalCtx, MirRayShieldRe } } #else -void MirRay_ReflectedBeam(MirRay* this, GlobalContext* globalCtx, MirRayShieldReflection* reflection); +void MirRay_ReflectedBeam(MirRay* this, PlayState* play, MirRayShieldReflection* reflection); #pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Mir_Ray/MirRay_ReflectedBeam.s") #endif -void MirRay_Draw(Actor* thisx, GlobalContext* globalCtx) { +void MirRay_Draw(Actor* thisx, PlayState* play) { s32 pad; MirRay* this = THIS; - Player* player = GET_PLAYER(globalCtx); + Player* player = GET_PLAYER(play); MirRayShieldReflection reflection[6]; s32 i; this->reflectIntensity = 0.0f; - if (!D_808E3BF0 && !this->unLit && func_80124088(globalCtx)) { - Matrix_InsertMatrix(&player->shieldMf, MTXMODE_NEW); - MirRay_SetIntensity(this, globalCtx); + if (!D_808E3BF0 && !this->unLit && Player_IsHoldingMirrorShield(play)) { + Matrix_Mult(&player->shieldMf, MTXMODE_NEW); + MirRay_SetIntensity(this, play); if (this->reflectIntensity <= 0.0f) { return; } - OPEN_DISPS(globalCtx->state.gfxCtx); + OPEN_DISPS(play->state.gfxCtx); - func_8012C2DC(globalCtx->state.gfxCtx); + func_8012C2DC(play->state.gfxCtx); Matrix_Scale(1.0f, 1.0f, this->reflectIntensity, MTXMODE_APPLY); - gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 255, 255, 255, (u8)(s8)(this->reflectIntensity * 100.0f)); - AnimatedMat_Draw(globalCtx, Lib_SegmentedToVirtual(object_mir_ray_Matanimheader_0003F8)); + AnimatedMat_Draw(play, Lib_SegmentedToVirtual(object_mir_ray_Matanimheader_0003F8)); gSPDisplayList(POLY_XLU_DISP++, object_mir_ray_DL_000168); - MirRay_SetupReflectionPolys(this, globalCtx, reflection); + MirRay_SetupReflectionPolys(this, play, reflection); MirRay_RemoveSimilarReflections(reflection); - MirRay_ReflectedBeam(this, globalCtx, reflection); + MirRay_ReflectedBeam(this, play, reflection); if (reflection[0].reflectionPoly == NULL) { reflection[0].opacity = 0; @@ -640,11 +640,11 @@ void MirRay_Draw(Actor* thisx, GlobalContext* globalCtx) { for (i = 0; i < ARRAY_COUNT(reflection); i++) { if (reflection[i].reflectionPoly != NULL) { - Matrix_InsertTranslation(reflection[i].pos.x, reflection[i].pos.y, reflection[i].pos.z, MTXMODE_NEW); + Matrix_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_InsertMatrix(&reflection[i].mtx, MTXMODE_APPLY); + Matrix_Mult(&reflection[i].mtx, MTXMODE_APPLY); - gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(play->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); @@ -654,7 +654,7 @@ void MirRay_Draw(Actor* thisx, GlobalContext* globalCtx) { D_808E3BF0 = true; - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->state.gfxCtx); } } diff --git a/src/overlays/actors/ovl_Mir_Ray/z_mir_ray.h b/src/overlays/actors/ovl_Mir_Ray/z_mir_ray.h index 4d748e3b5..3ba21c444 100644 --- a/src/overlays/actors/ovl_Mir_Ray/z_mir_ray.h +++ b/src/overlays/actors/ovl_Mir_Ray/z_mir_ray.h @@ -9,35 +9,35 @@ struct MirRay; // Locations of light beams in sMirRayData typedef enum { - /* 0 */ MIRRAY_SPIRIT_BOMBCHUIWAROOM_DOWNLIGHT, - /* 1 */ MIRRAY_SPIRIT_SUNBLOCKROOM_DOWNLIGHT, - /* 2 */ MIRRAY_SPIRIT_SINGLECOBRAROOM_DOWNLIGHT, - /* 3 */ MIRRAY_SPIRIT_ARMOSROOM_DOWNLIGHT, - /* 4 */ MIRRAY_SPIRIT_TOPROOM_DOWNLIGHT, - /* 5 */ MIRRAY_SPIRIT_TOPROOM_CEILINGMIRROR, - /* 6 */ MIRRAY_SPIRIT_SINGLECOBRAROOM_COBRA, - /* 7 */ MIRRAY_SPIRIT_TOPROOM_COBRA1, - /* 8 */ MIRRAY_SPIRIT_TOPROOM_COBRA2, - /* 9 */ MIRRAY_GANONSCASTLE_SPIRITTRIAL_DOWNLIGHT, - /* 10 */ MIRRAY_MAX, + /* 0x0 */ MIRRAY_SPIRIT_BOMBCHUIWAROOM_DOWNLIGHT, + /* 0x1 */ MIRRAY_SPIRIT_SUNBLOCKROOM_DOWNLIGHT, + /* 0x2 */ MIRRAY_SPIRIT_SINGLECOBRAROOM_DOWNLIGHT, + /* 0x3 */ MIRRAY_SPIRIT_ARMOSROOM_DOWNLIGHT, + /* 0x4 */ MIRRAY_SPIRIT_TOPROOM_DOWNLIGHT, + /* 0x5 */ MIRRAY_SPIRIT_TOPROOM_CEILINGMIRROR, + /* 0x6 */ MIRRAY_SPIRIT_SINGLECOBRAROOM_COBRA, + /* 0x7 */ MIRRAY_SPIRIT_TOPROOM_COBRA1, + /* 0x8 */ MIRRAY_SPIRIT_TOPROOM_COBRA2, + /* 0x9 */ MIRRAY_GANONSCASTLE_SPIRITTRIAL_DOWNLIGHT, + /* 0xA */ MIRRAY_MAX, } MirRayBeamLocations; typedef struct MirRay { - /* 0x0000 */ Actor actor; - /* 0x0144 */ ColliderJntSph collider1; - /* 0x0164 */ ColliderJntSphElement collider1Elements[1]; - /* 0x01A4 */ ColliderQuad collider2; - /* 0x0224 */ f32 reflectIntensity; // Reflection occurs if it is positive, brightness depends on it - /* 0x0228 */ Vec3f shieldCorners[6]; - /* 0x0270 */ f32 reflectRange; - /* 0x0274 */ Vec3f sourcePt; - /* 0x0280 */ Vec3f poolPt; - /* 0x028C */ s16 sourceEndRad; - /* 0x028E */ s16 poolEndRad; - /* 0x0290 */ s16 lightPointRad; - /* 0x0294 */ LightNode* lightNode; - /* 0x0298 */ LightInfo lightInfo; - /* 0x02A6 */ u8 unLit; // Conditioned on. set in Cobra? + /* 0x000 */ Actor actor; + /* 0x144 */ ColliderJntSph collider1; + /* 0x164 */ ColliderJntSphElement collider1Elements[1]; + /* 0x1A4 */ ColliderQuad collider2; + /* 0x224 */ f32 reflectIntensity; // Reflection occurs if it is positive, brightness depends on it + /* 0x228 */ Vec3f shieldCorners[6]; + /* 0x270 */ f32 reflectRange; + /* 0x274 */ Vec3f sourcePt; + /* 0x280 */ Vec3f poolPt; + /* 0x28C */ s16 sourceEndRad; + /* 0x28E */ s16 poolEndRad; + /* 0x290 */ s16 lightPointRad; + /* 0x294 */ LightNode* lightNode; + /* 0x298 */ LightInfo lightInfo; + /* 0x2A6 */ u8 unLit; // Conditioned on. set in Cobra? } MirRay; // size = 0x2A8 extern const ActorInit Mir_Ray_InitVars; diff --git a/src/overlays/actors/ovl_Mir_Ray2/z_mir_ray2.c b/src/overlays/actors/ovl_Mir_Ray2/z_mir_ray2.c index f6e8750cb..215b63776 100644 --- a/src/overlays/actors/ovl_Mir_Ray2/z_mir_ray2.c +++ b/src/overlays/actors/ovl_Mir_Ray2/z_mir_ray2.c @@ -10,12 +10,11 @@ #define THIS ((MirRay2*)thisx) -void MirRay2_Init(Actor* thisx, GlobalContext* globalCtx); -void MirRay2_Destroy(Actor* thisx, GlobalContext* globalCtx); -void MirRay2_Update(Actor* thisx, GlobalContext* globalCtx); -void MirRay2_Draw(Actor* thisx, GlobalContext* globalCtx); +void MirRay2_Init(Actor* thisx, PlayState* play); +void MirRay2_Destroy(Actor* thisx, PlayState* play); +void MirRay2_Update(Actor* thisx, PlayState* play); +void MirRay2_Draw(Actor* thisx, PlayState* play); -#if 0 const ActorInit Mir_Ray2_InitVars = { ACTOR_MIR_RAY2, ACTORCAT_ITEMACTION, @@ -28,33 +27,102 @@ const ActorInit Mir_Ray2_InitVars = { (ActorFunc)MirRay2_Draw, }; -// static ColliderJntSphElementInit sJntSphElementsInit[1] = { -static ColliderJntSphElementInit D_80AF4350[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_80AF4374 = { - { COLTYPE_NONE, AT_ON | AT_TYPE_OTHER, AC_NONE, OC1_NONE, OC2_NONE, COLSHAPE_JNTSPH, }, - 1, D_80AF4350, // sJntSphElementsInit, +static ColliderJntSphInit sJntSphInit = { + { + COLTYPE_NONE, + AT_ON | AT_TYPE_OTHER, + AC_NONE, + OC1_NONE, + OC2_NONE, + COLSHAPE_JNTSPH, + }, + ARRAY_COUNT(sJntSphElementsInit), + sJntSphElementsInit, }; -#endif +void func_80AF3F70(MirRay2* this) { + this->collider.elements->dim.worldSphere.center.x = this->actor.world.pos.x; + this->collider.elements->dim.worldSphere.center.y = this->actor.world.pos.y; + this->collider.elements->dim.worldSphere.center.z = this->actor.world.pos.z; + this->collider.elements->dim.worldSphere.radius = this->range * this->collider.elements->dim.scale; +} -extern ColliderJntSphElementInit D_80AF4350[1]; -extern ColliderJntSphInit D_80AF4374; +void func_80AF3FE0(MirRay2* this, PlayState* play) { + if (this->actor.xzDistToPlayer < this->range) { + Math_StepToS(&this->radius, 150, 50); + } else { + Math_StepToS(&this->radius, 0, 50); + } + Lights_PointNoGlowSetInfo(&this->lightInfo, this->actor.world.pos.x, this->actor.world.pos.y + 100.0f, + this->actor.world.pos.z, 255, 255, 255, this->radius); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Mir_Ray2/func_80AF3F70.s") +void MirRay2_Init(Actor* thisx, PlayState* play) { + s32 pad; + MirRay2* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Mir_Ray2/func_80AF3FE0.s") + if (this->actor.home.rot.x <= 0) { + this->range = 100.0f; + } else { + this->range = this->actor.home.rot.x * 4.0f; + } + Actor_SetScale(&this->actor, 1.0f); + if (MIRRAY2_GET_F(&this->actor) != 1) { + ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawWhiteCircle, this->range * 0.02f); + } + func_80AF3FE0(this, play); + this->light = LightContext_InsertLight(play, &play->lightCtx, &this->lightInfo); + Collider_InitJntSph(play, &this->collider); + Collider_SetJntSph(play, &this->collider, &this->actor, &sJntSphInit, &this->elements); + func_80AF3F70(this); + this->actor.shape.rot.x = 0; + this->actor.world.rot.x = this->actor.shape.rot.x; + if (MIRRAY2_GET_F(thisx) != 1) { + if ((MIRRAY2_GET_SWITCH_FLAGS(thisx) != 0x7F) && !Flags_GetSwitch(play, MIRRAY2_GET_SWITCH_FLAGS(thisx))) { + this->unk1A4 |= 1; + } + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Mir_Ray2/MirRay2_Init.s") +void MirRay2_Destroy(Actor* thisx, PlayState* play) { + MirRay2* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Mir_Ray2/MirRay2_Destroy.s") + LightContext_RemoveLight(play, &play->lightCtx, this->light); + Collider_DestroyJntSph(play, &this->collider); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Mir_Ray2/MirRay2_Update.s") +void MirRay2_Update(Actor* thisx, PlayState* play) { + MirRay2* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Mir_Ray2/MirRay2_Draw.s") + if (this->unk1A4 & 1) { + if (Flags_GetSwitch(play, MIRRAY2_GET_SWITCH_FLAGS(thisx))) { + this->unk1A4 &= ~1; + } + } else { + func_80AF3FE0(this, play); + if (MIRRAY2_GET_F(thisx) != 1) { + Actor_UpdateBgCheckInfo(play, &this->actor, 10.0f, 10.0f, 10.0f, 4); + this->actor.shape.shadowAlpha = 0x50; + } else { + func_80AF3F70(this); + } + CollisionCheck_SetAT(play, &play->colChkCtx, &this->collider.base); + } +} + +void MirRay2_Draw(Actor* thisx, PlayState* play) { +} diff --git a/src/overlays/actors/ovl_Mir_Ray2/z_mir_ray2.h b/src/overlays/actors/ovl_Mir_Ray2/z_mir_ray2.h index 26f478ea3..ac5202bdb 100644 --- a/src/overlays/actors/ovl_Mir_Ray2/z_mir_ray2.h +++ b/src/overlays/actors/ovl_Mir_Ray2/z_mir_ray2.h @@ -5,9 +5,18 @@ struct MirRay2; +#define MIRRAY2_GET_F(thisx) ((thisx)->params & 0xF) +#define MIRRAY2_GET_SWITCH_FLAGS(thisx) (((thisx)->params & 0xFE00) >> 9) + typedef struct MirRay2 { /* 0x000 */ Actor actor; - /* 0x144 */ char unk_144[0x7C]; + /* 0x144 */ ColliderJntSph collider; + /* 0x164 */ ColliderJntSphElement elements; + /* 0x1A4 */ u16 unk1A4; + /* 0x1A6 */ s16 radius; + /* 0x1A8 */ f32 range; + /* 0x1AC */ LightNode* light; + /* 0x1B0 */ LightInfo lightInfo; } MirRay2; // size = 0x1C0 extern const ActorInit Mir_Ray2_InitVars; 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 15bef2ca5..66a14a2a6 100644 --- a/src/overlays/actors/ovl_Mir_Ray3/z_mir_ray3.c +++ b/src/overlays/actors/ovl_Mir_Ray3/z_mir_ray3.c @@ -11,10 +11,10 @@ #define THIS ((MirRay3*)thisx) -void MirRay3_Init(Actor* thisx, GlobalContext* globalCtx); -void MirRay3_Destroy(Actor* thisx, GlobalContext* globalCtx); -void MirRay3_Update(Actor* thisx, GlobalContext* globalCtx); -void MirRay3_Draw(Actor* thisx, GlobalContext* globalCtx); +void MirRay3_Init(Actor* thisx, PlayState* play); +void MirRay3_Destroy(Actor* thisx, PlayState* play); +void MirRay3_Update(Actor* thisx, PlayState* play); +void MirRay3_Draw(Actor* thisx, PlayState* play); const ActorInit Mir_Ray3_InitVars = { ACTOR_MIR_RAY3, @@ -75,7 +75,7 @@ typedef struct { /* 0x50 */ u8 unk_50; } MirRay3Struct; // size = 0x54 -void MirRay3_Init(Actor* thisx, GlobalContext* globalCtx) { +void MirRay3_Init(Actor* thisx, PlayState* play) { s32 pad; MirRay3* this = THIS; @@ -100,34 +100,34 @@ void MirRay3_Init(Actor* thisx, GlobalContext* globalCtx) { 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); + Collider_InitQuad(play, &this->colliderQuad); + Collider_SetQuad(play, &this->colliderQuad, &this->actor, &sQuadInit); + Collider_InitCylinder(play, &this->colliderCylinder); + Collider_SetCylinder(play, &this->colliderCylinder, &this->actor, &sCylinderInit); this->actor.world.rot.x = this->actor.shape.rot.x = 0; } -void MirRay3_Destroy(Actor* thisx, GlobalContext* globalCtx) { +void MirRay3_Destroy(Actor* thisx, PlayState* play) { MirRay3* this = THIS; - Collider_DestroyQuad(globalCtx, &this->colliderQuad); - Collider_DestroyCylinder(globalCtx, &this->colliderCylinder); + Collider_DestroyQuad(play, &this->colliderQuad); + Collider_DestroyCylinder(play, &this->colliderCylinder); } -void MirRay3_Update(Actor* thisx, GlobalContext* globalCtx) { +void MirRay3_Update(Actor* thisx, PlayState* play) { s32 pad[2]; MirRay3* this = THIS; - Player* player = GET_PLAYER(globalCtx); + Player* player = GET_PLAYER(play); this->unk_210 &= ~1; if (this->unk_214 > 0.5f) { - CollisionCheck_SetAT(globalCtx, &globalCtx->colChkCtx, &this->colliderQuad.base); + CollisionCheck_SetAT(play, &play->colChkCtx, &this->colliderQuad.base); } this->unk_210 &= ~2; - if (func_8012405C(globalCtx)) { + if (Player_HasMirrorShieldEquipped(play)) { if (this->colliderCylinder.base.acFlags & AC_HIT) { this->unk_210 |= 2; } @@ -135,7 +135,7 @@ void MirRay3_Update(Actor* thisx, GlobalContext* globalCtx) { 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); + CollisionCheck_SetAC(play, &play->colChkCtx, &this->colliderCylinder.base); } if (this->unk_214 > 0.1f) { @@ -145,8 +145,8 @@ void MirRay3_Update(Actor* thisx, GlobalContext* globalCtx) { Math_ApproachZeroF(&this->unk_214, 1.0f, 0.1f); } -void func_80B9E544(MirRay3* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); +void func_80B9E544(MirRay3* this, PlayState* play) { + Player* player = GET_PLAYER(play); MtxF* shieldMtx = &player->shieldMf; f32 temp_f0; @@ -161,8 +161,8 @@ void func_80B9E544(MirRay3* this, GlobalContext* globalCtx) { } } -void func_80B9E5F4(MirRay3* this, GlobalContext* globalCtx, MirRay3Struct* ptr) { - Player* player = GET_PLAYER(globalCtx); +void func_80B9E5F4(MirRay3* this, PlayState* play, MirRay3Struct* ptr) { + Player* player = GET_PLAYER(play); MtxF* shieldMtx = &player->shieldMf; s32 i; Vec3f sp88; @@ -187,7 +187,7 @@ void func_80B9E5F4(MirRay3* this, GlobalContext* globalCtx, MirRay3Struct* ptr) sp7C.y = sp60[1] + sp88.y; sp7C.z = sp60[2] + sp88.z; - if (BgCheck_AnyLineTest1(&globalCtx->colCtx, &sp88, &sp7C, &sp70, &sp6C, true)) { + if (BgCheck_AnyLineTest1(&play->colCtx, &sp88, &sp7C, &sp70, &sp6C, true)) { ptr[i].unk_4C = sp6C; } else { ptr[i].unk_4C = NULL; @@ -214,8 +214,8 @@ void func_80B9E7D0(MirRay3Struct* ptr) { } #ifdef NON_MATCHING -void func_80B9E8D4(MirRay3* this, GlobalContext* globalCtx, MirRay3Struct* ptr) { - Player* player = GET_PLAYER(globalCtx); +void func_80B9E8D4(MirRay3* this, PlayState* play, MirRay3Struct* ptr) { + Player* player = GET_PLAYER(play); s32 i; MtxF* shieldMf = &player->shieldMf; Vec3f sp140; @@ -321,7 +321,7 @@ void func_80B9E8D4(MirRay3* this, GlobalContext* globalCtx, MirRay3Struct* ptr) 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)) { + if (!BgCheck_AnyLineTest1(&play->colCtx, &sp140, &sp134, &sp128, &spC4, 1)) { Math_Vec3f_Copy(&sp128, &sp134); } @@ -340,42 +340,42 @@ void func_80B9E8D4(MirRay3* this, GlobalContext* globalCtx, MirRay3Struct* ptr) Collider_SetQuadVertices(&this->colliderQuad, &spD4, &sp140, &spC8, &sp128); } #else -void func_80B9E8D4(MirRay3* this, GlobalContext* globalCtx, MirRay3Struct* ptr); +void func_80B9E8D4(MirRay3* this, PlayState* play, MirRay3Struct* ptr); #pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Mir_Ray3/func_80B9E8D4.s") #endif -void MirRay3_Draw(Actor* thisx, GlobalContext* globalCtx) { +void MirRay3_Draw(Actor* thisx, PlayState* play) { s32 pad[2]; MirRay3* this = THIS; MirRay3Struct sp8C[6]; - Player* player = GET_PLAYER(globalCtx); + Player* player = GET_PLAYER(play); s32 i; f32 temp; - u16 phi_a0; + u16 time; - if (!(this->unk_210 & 1) && func_8012405C(globalCtx)) { - Matrix_InsertMatrix(&player->shieldMf, MTXMODE_NEW); - func_80B9E544(this, globalCtx); + if (!(this->unk_210 & 1) && Player_HasMirrorShieldEquipped(play)) { + Matrix_Mult(&player->shieldMf, MTXMODE_NEW); + func_80B9E544(this, play); if (this->unk_214 <= 0.1f) { return; } - OPEN_DISPS(globalCtx->state.gfxCtx); + OPEN_DISPS(play->state.gfxCtx); - func_8012C2DC(globalCtx->state.gfxCtx); + func_8012C2DC(play->state.gfxCtx); Matrix_Scale(1.0f, 1.0f, this->unk_214, MTXMODE_APPLY); - gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); if (MIRRAY3_GET_F(&this->actor) == MIRRAY3_F_1) { - phi_a0 = gSaveContext.save.time; + time = gSaveContext.save.time; - if (phi_a0 > CLOCK_TIME(12, 0)) { - phi_a0 = 0xFFFF - phi_a0; + if (time > CLOCK_TIME(12, 0)) { + time = (DAY_LENGTH - 1) - time; } - temp = (phi_a0 * (1.0f / 0x8000)); + temp = (time * (1.0f / 0x8000)); gDPSetPrimColor(POLY_XLU_DISP++, 0, 0x78, 255, 255, 255, (u8)(s8)(100 * this->unk_214)); gDPSetEnvColor(POLY_XLU_DISP++, 218, 225, (u8)((100.0f * temp) + 105.0f), 255); @@ -384,13 +384,13 @@ void MirRay3_Draw(Actor* thisx, GlobalContext* globalCtx) { gDPSetEnvColor(POLY_XLU_DISP++, 218, 225, 205, 255); } - AnimatedMat_Draw(globalCtx, Lib_SegmentedToVirtual(object_mir_ray_Matanimheader_0003F8)); + AnimatedMat_Draw(play, Lib_SegmentedToVirtual(object_mir_ray_Matanimheader_0003F8)); gSPDisplayList(POLY_XLU_DISP++, object_mir_ray_DL_000168); - func_80B9E5F4(this, globalCtx, sp8C); + func_80B9E5F4(this, play, sp8C); func_80B9E7D0(sp8C); - func_80B9E8D4(this, globalCtx, sp8C); + func_80B9E8D4(this, play, sp8C); if (sp8C[0].unk_4C == NULL) { sp8C[0].unk_50 = 0; @@ -406,11 +406,11 @@ void MirRay3_Draw(Actor* thisx, GlobalContext* globalCtx) { for (i = 0; i < ARRAY_COUNT(sp8C); i++) { if (sp8C[i].unk_4C != NULL) { - Matrix_InsertTranslation(sp8C[i].unk_00.x, sp8C[i].unk_00.y, sp8C[i].unk_00.z, MTXMODE_NEW); + Matrix_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_InsertMatrix(&sp8C[i].unk_0C, MTXMODE_APPLY); + Matrix_Mult(&sp8C[i].unk_0C, MTXMODE_APPLY); - gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(play->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); @@ -420,6 +420,6 @@ void MirRay3_Draw(Actor* thisx, GlobalContext* globalCtx) { this->unk_210 |= 1; - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->state.gfxCtx); } } 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 5237d9021..f0049800d 100644 --- a/src/overlays/actors/ovl_Obj_Aqua/z_obj_aqua.c +++ b/src/overlays/actors/ovl_Obj_Aqua/z_obj_aqua.c @@ -11,16 +11,16 @@ #define THIS ((ObjAqua*)thisx) -void ObjAqua_Init(Actor* thisx, GlobalContext* globalCtx); -void ObjAqua_Destroy(Actor* thisx, GlobalContext* globalCtx); -void ObjAqua_Update(Actor* thisx, GlobalContext* globalCtx); -void ObjAqua_Draw(Actor* thisx, GlobalContext* globalCtx); +void ObjAqua_Init(Actor* thisx, PlayState* play); +void ObjAqua_Destroy(Actor* thisx, PlayState* play); +void ObjAqua_Update(Actor* thisx, PlayState* play); +void ObjAqua_Draw(Actor* thisx, PlayState* play); void func_80ACBC70(ObjAqua* this); void func_80ACBDCC(ObjAqua* this); -void func_80ACBC8C(ObjAqua* this, GlobalContext* globalCtx); -void func_80ACBD48(ObjAqua* this, GlobalContext* globalCtx); -void func_80ACBDFC(ObjAqua* this, GlobalContext* globalCtx); +void func_80ACBC8C(ObjAqua* this, PlayState* play); +void func_80ACBD48(ObjAqua* this, PlayState* play); +void func_80ACBDFC(ObjAqua* this, PlayState* play); void func_80ACBD34(ObjAqua* this); @@ -67,7 +67,7 @@ Vec3f D_80ACC308 = { 1.0f / 1000.0f, 7.0f / 10000.0f, 1.0f / 1000.0f }; Vec3f D_80ACC314 = { 8.6f / 1000.0f, 8.0f / 10000.0f, 8.6f / 1000.0f }; Vec3f D_80ACC320 = { 1.0f / 100.0f, 2.6f / 1000.0f, 1.0f / 100.0f }; -void func_80ACB6A0(ObjAqua* this, GlobalContext* globalCtx) { +void func_80ACB6A0(ObjAqua* this, PlayState* play) { s32 pad; Vec3f sp58; s32 angleOffset = 0; @@ -77,15 +77,15 @@ void func_80ACB6A0(ObjAqua* this, GlobalContext* globalCtx) { for (i = 0; i < 4; i++) { sp58.x = this->actor.world.pos.x + Math_SinS((s32)(Rand_ZeroOne() * 7200.0f) + angleOffset) * 8.0f; sp58.z = this->actor.world.pos.z + Math_CosS((s32)(Rand_ZeroOne() * 7200.0f) + angleOffset) * 8.0f; - EffectSsGSplash_Spawn(globalCtx, &sp58, NULL, NULL, 0, 120); + EffectSsGSplash_Spawn(play, &sp58, NULL, NULL, 0, 120); angleOffset += 0x4000; } sp58.x = this->actor.world.pos.x; sp58.z = this->actor.world.pos.z; - EffectSsGSplash_Spawn(globalCtx, &sp58, NULL, NULL, 0, 300); + EffectSsGSplash_Spawn(play, &sp58, NULL, NULL, 0, 300); } -void func_80ACB7F4(ObjAqua* this, GlobalContext* globalCtx) { +void func_80ACB7F4(ObjAqua* this, PlayState* play) { s32 pad; Vec3f effectPos; s32 angleOffset = 0; @@ -95,15 +95,15 @@ void func_80ACB7F4(ObjAqua* this, GlobalContext* globalCtx) { for (i = 0; i < 4; i++) { effectPos.x = (this->actor.world.pos.x + Math_SinS((s32)(Rand_ZeroOne() * 7200.0f) + angleOffset) * 8.0f); effectPos.z = (this->actor.world.pos.z + Math_CosS((s32)(Rand_ZeroOne() * 7200.0f) + angleOffset) * 8.0f); - EffectSsGSplash_Spawn(globalCtx, &effectPos, NULL, NULL, 0, 120); + EffectSsGSplash_Spawn(play, &effectPos, NULL, NULL, 0, 120); angleOffset += 0x4000; } effectPos.x = this->actor.world.pos.x; effectPos.z = this->actor.world.pos.z; - EffectSsGSplash_Spawn(globalCtx, &effectPos, NULL, NULL, 0, 300); + EffectSsGSplash_Spawn(play, &effectPos, NULL, NULL, 0, 300); } -void func_80ACB940(ObjAqua* this, GlobalContext* globalCtx) { +void func_80ACB940(ObjAqua* this, PlayState* play) { s32 pad; Vec3f effectPos; Vec3f effectVel; @@ -114,7 +114,7 @@ void func_80ACB940(ObjAqua* this, GlobalContext* globalCtx) { effectPos.x = this->actor.world.pos.x + (effectVel.x * 40.0f); effectPos.y = this->actor.world.pos.y; effectPos.z = this->actor.world.pos.z + (effectVel.z * 40.0f); - EffectSsIceSmoke_Spawn(globalCtx, &effectPos, &effectVel, &gZeroVec3f, (s32)(Rand_ZeroOne() * 24.0f) + 70); + EffectSsIceSmoke_Spawn(play, &effectPos, &effectVel, &gZeroVec3f, (s32)(Rand_ZeroOne() * 24.0f) + 70); } void func_80ACBA10(ObjAqua* this) { @@ -123,24 +123,24 @@ 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) { +s32 func_80ACBA60(ObjAqua* this, PlayState* play) { s32 pad; WaterBox* waterBox; f32 ySurface; s32 bgId; - if (WaterBox_GetSurfaceImpl(globalCtx, &globalCtx->colCtx, this->actor.world.pos.x, this->actor.world.pos.z, - &ySurface, &waterBox, &bgId) && + if (WaterBox_GetSurfaceImpl(play, &play->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 ObjAqua_Init(Actor* thisx, GlobalContext* globalCtx) { +void ObjAqua_Init(Actor* thisx, PlayState* play) { ObjAqua* this = THIS; s32 i; @@ -148,16 +148,15 @@ void ObjAqua_Init(Actor* thisx, GlobalContext* globalCtx) { this->actor.scale.x = 0.0009f; this->actor.scale.y = 0.0005f; this->actor.scale.z = 0.0009f; - Collider_InitCylinder(globalCtx, &this->collider); - Collider_SetCylinder(globalCtx, &this->collider, &this->actor, &sCylinderInit); + Collider_InitCylinder(play, &this->collider); + Collider_SetCylinder(play, &this->collider, &this->actor, &sCylinderInit); ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 60.0f); if (1) {}; this->actor.shape.shadowAlpha = 140; this->alpha = 255; - if (func_80ACBA60(this, globalCtx)) { + if (func_80ACBA60(this, play)) { for (i = 0; i < 8; i++) { - EffectSsBubble_Spawn(globalCtx, &this->actor.world.pos, -4.0f, 4.0f, 4.0f, - (Rand_ZeroOne() * 0.09f) + 0.03f); + EffectSsBubble_Spawn(play, &this->actor.world.pos, -4.0f, 4.0f, 4.0f, (Rand_ZeroOne() * 0.09f) + 0.03f); } func_80ACBDCC(this); } else { @@ -165,9 +164,9 @@ void ObjAqua_Init(Actor* thisx, GlobalContext* globalCtx) { } } -void ObjAqua_Destroy(Actor* thisx, GlobalContext* globalCtx) { +void ObjAqua_Destroy(Actor* thisx, PlayState* play) { ObjAqua* this = THIS; - Collider_DestroyCylinder(globalCtx, &this->collider); + Collider_DestroyCylinder(play, &this->collider); } void func_80ACBC70(ObjAqua* this) { @@ -175,16 +174,16 @@ void func_80ACBC70(ObjAqua* this) { this->actionFunc = func_80ACBC8C; } -void func_80ACBC8C(ObjAqua* this, GlobalContext* globalCtx) { +void func_80ACBC8C(ObjAqua* this, PlayState* play) { if (this->actor.bgCheckFlags & 0x21) { if (this->actor.bgCheckFlags & 1) { - func_80ACB7F4(this, globalCtx); + func_80ACB7F4(this, play); func_80ACBA10(this); Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_BOTTLE_WATERING); func_80ACBD34(this); } else { - func_80ACB6A0(this, globalCtx); - SoundSource_PlaySfxAtFixedWorldPos(globalCtx, &this->actor.world.pos, 0x28, NA_SE_EV_BOMB_DROP_WATER); + func_80ACB6A0(this, play); + SoundSource_PlaySfxAtFixedWorldPos(play, &this->actor.world.pos, 0x28, NA_SE_EV_BOMB_DROP_WATER); Actor_MarkForDeath(&this->actor); } } else if (this->counter <= 0) { @@ -196,9 +195,9 @@ void func_80ACBD34(ObjAqua* this) { this->actionFunc = func_80ACBD48; } -void func_80ACBD48(ObjAqua* this, GlobalContext* globalCtx) { +void func_80ACBD48(ObjAqua* this, PlayState* play) { if ((AQUA_HOT(&this->actor) == 1) && (this->alpha > 90)) { - func_80ACB940(this, globalCtx); + func_80ACB940(this, play); } if (this->alpha > 5) { this->alpha -= 5; @@ -219,7 +218,7 @@ void func_80ACBDCC(ObjAqua* this) { this->actionFunc = func_80ACBDFC; } -void func_80ACBDFC(ObjAqua* this, GlobalContext* globalCtx) { +void func_80ACBDFC(ObjAqua* this, PlayState* play) { s32 pad; f32 temp = this->counter; @@ -229,7 +228,7 @@ void func_80ACBDFC(ObjAqua* this, GlobalContext* globalCtx) { if (AQUA_HOT(&this->actor) == 1) { f32 temp_f2 = this->actor.scale.x * 10000.0f; - EffectSsBubble_Spawn(globalCtx, &this->actor.world.pos, temp_f2 * -0.5f, temp_f2, temp_f2, + EffectSsBubble_Spawn(play, &this->actor.world.pos, temp_f2 * -0.5f, temp_f2, temp_f2, (Rand_ZeroOne() * 0.1f) + 0.03f); } if (this->counter <= 0) { @@ -237,14 +236,14 @@ void func_80ACBDFC(ObjAqua* this, GlobalContext* globalCtx) { } } -void ObjAqua_Update(Actor* thisx, GlobalContext* globalCtx) { +void ObjAqua_Update(Actor* thisx, PlayState* play) { ObjAqua* this = THIS; s32 pad; if (this->counter > 0) { this->counter--; } - this->actionFunc(this, globalCtx); + this->actionFunc(this, play); if (this->actor.update) { if (this->actionFunc == func_80ACBC8C) { Math_Vec3f_StepTo(&this->actor.scale, &D_80ACC308, 0.00006f); @@ -255,42 +254,44 @@ void ObjAqua_Update(Actor* thisx, GlobalContext* globalCtx) { } this->actor.velocity.y *= 0.9f; Actor_MoveWithGravity(&this->actor); - Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 12.0f, 4.0f, 0.0f, 5); + Actor_UpdateBgCheckInfo(play, &this->actor, 12.0f, 4.0f, 0.0f, 5); if (this->actionFunc != func_80ACBDFC) { Collider_UpdateCylinder(&this->actor, &this->collider); this->collider.dim.radius = this->actor.scale.x * 3000.0f; - CollisionCheck_SetAT(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + CollisionCheck_SetAT(play, &play->colChkCtx, &this->collider.base); } } } -void ObjAqua_Draw(Actor* thisx, GlobalContext* globalCtx) { +void ObjAqua_Draw(Actor* thisx, PlayState* play) { ObjAqua* this = THIS; s32 framesTemp; s32 pad; - s16 yaw = Camera_GetCamDirYaw(globalCtx->cameraPtrs[globalCtx->activeCamera]) + 0x8000; + s16 yaw = Camera_GetCamDirYaw(GET_ACTIVE_CAM(play)) + 0x8000; s32 actionFuncTemp = this->actionFunc == func_80ACBDFC; - OPEN_DISPS(globalCtx->state.gfxCtx); - func_8012C2DC(globalCtx->state.gfxCtx); - framesTemp = ((globalCtx->gameplayFrames & 0x7FFFFFFF) * -0xA) & 0x1FF; + OPEN_DISPS(play->state.gfxCtx); + func_8012C2DC(play->state.gfxCtx); + framesTemp = ((play->gameplayFrames & 0x7FFFFFFF) * -0xA) & 0x1FF; if (actionFuncTemp) { framesTemp >>= 1; } gSPSegment(POLY_XLU_DISP++, 0x08, - Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, 0, 0, 0x20, 0x40, 1, 0, framesTemp, 0x20, 0x80)); + Gfx_TwoTexScroll(play->state.gfxCtx, 0, 0, 0, 0x20, 0x40, 1, 0, framesTemp, 0x20, 0x80)); gDPSetPrimColor(POLY_XLU_DISP++, 0x80, 0x80, 170, 255, 255, this->alpha); gDPSetEnvColor(POLY_XLU_DISP++, 0, 150, 255, 0); 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); - 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); + + Matrix_RotateYS(yaw, MTXMODE_APPLY); + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_XLU_DISP++, gEffFire1DL); + + CLOSE_DISPS(play->state.gfxCtx); } diff --git a/src/overlays/actors/ovl_Obj_Aqua/z_obj_aqua.h b/src/overlays/actors/ovl_Obj_Aqua/z_obj_aqua.h index 8360ae1e2..fa2b1c636 100644 --- a/src/overlays/actors/ovl_Obj_Aqua/z_obj_aqua.h +++ b/src/overlays/actors/ovl_Obj_Aqua/z_obj_aqua.h @@ -8,15 +8,15 @@ struct ObjAqua; -typedef void (*ObjAquaActionFunc)(struct ObjAqua*, GlobalContext*); +typedef void (*ObjAquaActionFunc)(struct ObjAqua*, PlayState*); typedef struct ObjAqua { - /* 0x0000 */ Actor actor; - /* 0x0144 */ ColliderCylinder collider; - /* 0x0190 */ ObjAquaActionFunc actionFunc; - /* 0x0194 */ s16 counter; - /* 0x0196 */ u8 alpha; - /* 0x0198 */ s16 unk_198; + /* 0x000 */ Actor actor; + /* 0x144 */ ColliderCylinder collider; + /* 0x190 */ ObjAquaActionFunc actionFunc; + /* 0x194 */ s16 counter; + /* 0x196 */ u8 alpha; + /* 0x198 */ s16 unk_198; } ObjAqua; // size = 0x19C extern const ActorInit Obj_Aqua_InitVars; diff --git a/src/overlays/actors/ovl_Obj_Armos/z_obj_armos.c b/src/overlays/actors/ovl_Obj_Armos/z_obj_armos.c index 998e85d68..9b31c22ca 100644 --- a/src/overlays/actors/ovl_Obj_Armos/z_obj_armos.c +++ b/src/overlays/actors/ovl_Obj_Armos/z_obj_armos.c @@ -11,17 +11,17 @@ #define THIS ((ObjArmos*)thisx) -void ObjArmos_Init(Actor* thisx, GlobalContext* globalCtx); -void ObjArmos_Destroy(Actor* thisx, GlobalContext* globalCtx); -void ObjArmos_Update(Actor* thisx, GlobalContext* globalCtx); -void ObjArmos_Draw(Actor* thisx, GlobalContext* globalCtx); +void ObjArmos_Init(Actor* thisx, PlayState* play); +void ObjArmos_Destroy(Actor* thisx, PlayState* play); +void ObjArmos_Update(Actor* thisx, PlayState* play); +void ObjArmos_Draw(Actor* thisx, PlayState* play); void func_809A54B4(ObjArmos* this); -void func_809A54E0(ObjArmos* this, GlobalContext* globalCtx); +void func_809A54E0(ObjArmos* this, PlayState* play); void func_809A5610(ObjArmos* this); -void func_809A562C(ObjArmos* this, GlobalContext* globalCtx); +void func_809A562C(ObjArmos* this, PlayState* play); void func_809A57D8(ObjArmos* this); -void func_809A57F4(ObjArmos* this, GlobalContext* globalCtx); +void func_809A57F4(ObjArmos* this, PlayState* play); const ActorInit Obj_Armos_InitVars = { ACTOR_OBJ_ARMOS, @@ -44,9 +44,9 @@ static InitChainEntry sInitChain[] = { ICHAIN_VEC3F_DIV1000(scale, 10, ICHAIN_STOP), }; -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); +s32 func_809A4E00(ObjArmos* this, PlayState* play, s16 arg2) { + return !DynaPolyActor_ValidateMove(play, &this->dyna, 30, arg2, 1) || + !DynaPolyActor_ValidateMove(play, &this->dyna, 30, arg2, 28); } s32 func_809A4E68(ObjArmos* this) { @@ -176,7 +176,7 @@ void func_809A518C(ObjArmos* this, s32 arg1) { this->unk_264 = arg1; } -void ObjArmos_Init(Actor* thisx, GlobalContext* globalCtx) { +void ObjArmos_Init(Actor* thisx, PlayState* play) { s32 pad; ObjArmos* this = THIS; s32 sp44 = OBJARMOS_GET_ROTZ_7(&this->dyna.actor); @@ -189,16 +189,16 @@ void ObjArmos_Init(Actor* thisx, GlobalContext* globalCtx) { 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); + DynaPolyActor_LoadMesh(play, &this->dyna, &object_am_Colheader_005CF8); - SkelAnime_Init(globalCtx, &this->skelAnime, &object_am_Skel_005948, &gArmosPushedBackAnim, this->jointTable, + SkelAnime_Init(play, &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))) { + } else if (Flags_GetSwitch(play, 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); @@ -219,10 +219,10 @@ void ObjArmos_Init(Actor* thisx, GlobalContext* globalCtx) { } } -void ObjArmos_Destroy(Actor* thisx, GlobalContext* globalCtx) { +void ObjArmos_Destroy(Actor* thisx, PlayState* play) { ObjArmos* this = THIS; - DynaPoly_DeleteBgActor(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); + DynaPoly_DeleteBgActor(play, &play->colCtx.dyna, this->dyna.bgId); } void func_809A54B4(ObjArmos* this) { @@ -234,7 +234,7 @@ void func_809A54B4(ObjArmos* this) { this->unk_266[0] = 0; } -void func_809A54E0(ObjArmos* this, GlobalContext* globalCtx) { +void func_809A54E0(ObjArmos* this, PlayState* play) { s32 i; s32 sp20 = func_809A4E68(this); @@ -248,11 +248,11 @@ void func_809A54E0(ObjArmos* this, GlobalContext* globalCtx) { 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_809A4E00(this, play, (this->dyna.pushForce > 0.0f) ? 90 : 120)) { func_809A518C(this, sp20); func_809A5610(this); } else { - GET_PLAYER(globalCtx)->stateFlags2 &= ~0x10; + GET_PLAYER(play)->stateFlags2 &= ~0x10; this->dyna.pushForce = 0.0f; } } @@ -263,7 +263,7 @@ void func_809A5610(ObjArmos* this) { this->unk_24C = 5; } -void func_809A562C(ObjArmos* this, GlobalContext* globalCtx) { +void func_809A562C(ObjArmos* this, PlayState* play) { s32 pad[2]; Player* player; f32 temp2 = this->unk_260 - *this->unk_25C; @@ -271,21 +271,21 @@ void func_809A562C(ObjArmos* this, GlobalContext* globalCtx) { 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); + player = GET_PLAYER(play); 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)) { + if (!func_809A500C(this, this->unk_264) || func_809A4E00(this, play, 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)) { + if (func_809A4E00(this, play, 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)); + Flags_SetSwitch(play, OBJARMOS_GET_7F(&this->dyna.actor)); sp20 = true; } @@ -307,26 +307,26 @@ void func_809A57D8(ObjArmos* this) { this->unk_24C = 4; } -void func_809A57F4(ObjArmos* this, GlobalContext* globalCtx) { +void func_809A57F4(ObjArmos* this, PlayState* play) { if (fabsf(this->dyna.pushForce) > 0.1f) { - GET_PLAYER(globalCtx)->stateFlags2 &= ~0x10; + GET_PLAYER(play)->stateFlags2 &= ~0x10; this->dyna.pushForce = 0.0f; } } -void ObjArmos_Update(Actor* thisx, GlobalContext* globalCtx2) { - GlobalContext* globalCtx = globalCtx2; +void ObjArmos_Update(Actor* thisx, PlayState* play2) { + PlayState* play = play2; ObjArmos* this = THIS; s32 sp2C; - this->actionFunc(this, globalCtx); + this->actionFunc(this, play); 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); + Actor_UpdateBgCheckInfo(play, &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)) { + (DynaPoly_GetActor(&play->colCtx, this->dyna.actor.floorBgId) == NULL)) { this->unk_24C = 0; } @@ -334,39 +334,39 @@ void ObjArmos_Update(Actor* thisx, GlobalContext* globalCtx2) { 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); + this->dyna.actor.floorHeight = BgCheck_EntityRaycastFloor5(&play->colCtx, &this->dyna.actor.floorPoly, &sp2C, + &this->dyna.actor, &this->unk_250); } } -void func_809A5960(ObjArmos* this, GlobalContext* globalCtx) { +void func_809A5960(ObjArmos* this, PlayState* play) { s32 pad; - OPEN_DISPS(globalCtx->state.gfxCtx); + OPEN_DISPS(play->state.gfxCtx); Vec3f sp28; sp28.x = Math_SinS(this->dyna.actor.shape.rot.y); - Matrix_SetStateRotationAndTranslation( - (sp28.x * -9.0f) + this->dyna.actor.world.pos.x, this->dyna.actor.world.pos.y, - (Math_CosS(this->dyna.actor.shape.rot.y) * -9.0f) + this->dyna.actor.world.pos.z, &this->dyna.actor.shape.rot); + Matrix_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); + func_8012C28C(play->state.gfxCtx); gDPSetEnvColor(POLY_OPA_DISP++, 0, 0, 0, 0); - SkelAnime_DrawOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, NULL, NULL, &this->dyna.actor); + SkelAnime_DrawOpa(play, this->skelAnime.skeleton, this->skelAnime.jointTable, NULL, NULL, &this->dyna.actor); - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->state.gfxCtx); } -void func_809A5A3C(ObjArmos* this, GlobalContext* globalCtx) { +void func_809A5A3C(ObjArmos* this, PlayState* play) { s32 pad[2]; MtxF sp48; if (this->dyna.actor.floorPoly != NULL) { - OPEN_DISPS(globalCtx->state.gfxCtx); + OPEN_DISPS(play->state.gfxCtx); - func_8012C448(globalCtx->state.gfxCtx); + func_8012C448(play->state.gfxCtx); gDPSetCombineLERP(POLY_XLU_DISP++, 0, 0, 0, PRIMITIVE, TEXEL0, 0, PRIMITIVE, 0, 0, 0, 0, COMBINED, 0, 0, 0, COMBINED); @@ -374,19 +374,19 @@ void func_809A5A3C(ObjArmos* this, GlobalContext* globalCtx) { func_800C0094(this->dyna.actor.floorPoly, this->unk_250.x, this->dyna.actor.floorHeight, this->unk_250.z, &sp48); - Matrix_SetCurrentState(&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); + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_XLU_DISP++, gCircleShadowDL); - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->state.gfxCtx); } } -void ObjArmos_Draw(Actor* thisx, GlobalContext* globalCtx) { +void ObjArmos_Draw(Actor* thisx, PlayState* play) { ObjArmos* this = THIS; - func_809A5960(this, globalCtx); - func_809A5A3C(this, globalCtx); + func_809A5960(this, play); + func_809A5A3C(this, play); } 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 0a03d4915..a0c91f214 100644 --- a/src/overlays/actors/ovl_Obj_Armos/z_obj_armos.h +++ b/src/overlays/actors/ovl_Obj_Armos/z_obj_armos.h @@ -6,7 +6,7 @@ struct ObjArmos; -typedef void (*ObjArmosActionFunc)(struct ObjArmos*, GlobalContext*); +typedef void (*ObjArmosActionFunc)(struct ObjArmos*, PlayState*); #define OBJARMOS_GET_7F(thisx) ((thisx)->params & 0x7F) #define OBJARMOS_GET_ROTZ_7(thisx) ((thisx)->home.rot.z & 7) @@ -23,19 +23,19 @@ enum { }; typedef struct ObjArmos { - /* 0x0000 */ DynaPolyActor dyna; - /* 0x015C */ SkelAnime skelAnime; - /* 0x01A0 */ Vec3s jointTable[OBJECT_AM_LIMB_MAX]; - /* 0x01F4 */ Vec3s morphTable[OBJECT_AM_LIMB_MAX]; - /* 0x0248 */ ObjArmosActionFunc actionFunc; - /* 0x024C */ u32 unk_24C; - /* 0x0250 */ Vec3f unk_250; - /* 0x025C */ f32* unk_25C; - /* 0x0260 */ f32 unk_260; - /* 0x0264 */ s16 unk_264; - /* 0x0266 */ s16 unk_266[4]; - /* 0x026E */ s16 unk_26E; - /* 0x0270 */ s16 unk_270; + /* 0x000 */ DynaPolyActor dyna; + /* 0x15C */ SkelAnime skelAnime; + /* 0x1A0 */ Vec3s jointTable[OBJECT_AM_LIMB_MAX]; + /* 0x1F4 */ Vec3s morphTable[OBJECT_AM_LIMB_MAX]; + /* 0x248 */ ObjArmosActionFunc actionFunc; + /* 0x24C */ u32 unk_24C; + /* 0x250 */ Vec3f unk_250; + /* 0x25C */ f32* unk_25C; + /* 0x260 */ f32 unk_260; + /* 0x264 */ s16 unk_264; + /* 0x266 */ s16 unk_266[4]; + /* 0x26E */ s16 unk_26E; + /* 0x270 */ s16 unk_270; } ObjArmos; // size = 0x274 extern const ActorInit Obj_Armos_InitVars; diff --git a/src/overlays/actors/ovl_Obj_Bean/z_obj_bean.c b/src/overlays/actors/ovl_Obj_Bean/z_obj_bean.c index a02f7f604..c13fde9b0 100644 --- a/src/overlays/actors/ovl_Obj_Bean/z_obj_bean.c +++ b/src/overlays/actors/ovl_Obj_Bean/z_obj_bean.c @@ -12,9 +12,9 @@ #define THIS ((ObjBean*)thisx) -void ObjBean_Init(Actor* thisx, GlobalContext* globalCtx); -void ObjBean_Destroy(Actor* thisx, GlobalContext* globalCtx); -void ObjBean_Update(Actor* thisx, GlobalContext* globalCtx); +void ObjBean_Init(Actor* thisx, PlayState* play); +void ObjBean_Destroy(Actor* thisx, PlayState* play); +void ObjBean_Update(Actor* thisx, PlayState* play); void func_80937C10(ObjBean* this); void func_80937C24(ObjBean* this); @@ -22,43 +22,43 @@ void func_80937CA0(ObjBean* this); void func_80937CE4(ObjBean* this); void func_80937D54(ObjBean* this); void func_80937DD8(ObjBean* this); -void func_80937DEC(ObjBean* this, GlobalContext* globalCtx); +void func_80937DEC(ObjBean* this, PlayState* play); void func_80937FB0(ObjBean* this); -void func_80937FC8(ObjBean* this, GlobalContext* globalCtx); +void func_80937FC8(ObjBean* this, PlayState* play); void func_809381B0(ObjBean* this); -void func_809381C4(ObjBean* this, GlobalContext* globalCtx); +void func_809381C4(ObjBean* this, PlayState* play); void func_80938284(ObjBean* this); -void func_80938298(ObjBean* this, GlobalContext* globalCtx); +void func_80938298(ObjBean* this, PlayState* play); void func_8093833C(ObjBean* this); -void func_80938358(ObjBean* this, GlobalContext* globalCtx); +void func_80938358(ObjBean* this, PlayState* play); void func_809383B4(ObjBean* this); -void func_809383D0(ObjBean* this, GlobalContext* globalCtx); +void func_809383D0(ObjBean* this, PlayState* play); void func_80938408(ObjBean* this); -void func_80938444(ObjBean* this, GlobalContext* globalCtx); +void func_80938444(ObjBean* this, PlayState* play); void func_809384E8(ObjBean* this); -void func_80938504(ObjBean* this, GlobalContext* globalCtx); +void func_80938504(ObjBean* this, PlayState* play); void func_80938588(ObjBean* this); -void func_809385A8(ObjBean* this, GlobalContext* globalCtx); +void func_809385A8(ObjBean* this, PlayState* play); void func_80938670(ObjBean* this); -void func_8093868C(ObjBean* this, GlobalContext* globalCtx); +void func_8093868C(ObjBean* this, PlayState* play); void func_80938704(ObjBean* this); -void func_80938728(ObjBean* this, GlobalContext* globalCtx); +void func_80938728(ObjBean* this, PlayState* play); void func_8093876C(ObjBean* this); -void func_80938780(ObjBean* this, GlobalContext* globalCtx); +void func_80938780(ObjBean* this, PlayState* play); void func_80938804(ObjBean* this); -void func_80938834(ObjBean* this, GlobalContext* globalCtx); +void func_80938834(ObjBean* this, PlayState* play); void func_80938874(ObjBean* this); -void func_809388A8(ObjBean* this, GlobalContext* globalCtx); +void func_809388A8(ObjBean* this, PlayState* play); void func_8093892C(ObjBean* this); -void func_80938958(ObjBean* this, GlobalContext* globalCtx); -void func_809389BC(ObjBean* this, GlobalContext* globalCtx); +void func_80938958(ObjBean* this, PlayState* play); +void func_809389BC(ObjBean* this, PlayState* play); void func_80938A14(ObjBean* this); -void func_80938A5C(ObjBean* this, GlobalContext* globalCtx); +void func_80938A5C(ObjBean* this, PlayState* play); void func_80938AA4(ObjBean* this); -void func_80938AD8(ObjBean* this, GlobalContext* globalCtx); -void func_80938C1C(Actor* thisx, GlobalContext* globalCtx); -void func_80938E00(Actor* thisx, GlobalContext* globalCtx); -void func_80938F50(Actor* thisx, GlobalContext* globalCtx); +void func_80938AD8(ObjBean* this, PlayState* play); +void func_80938C1C(Actor* thisx, PlayState* play); +void func_80938E00(Actor* thisx, PlayState* play); +void func_80938F50(Actor* thisx, PlayState* play); const ActorInit Obj_Bean_InitVars = { ACTOR_OBJ_BEAN, @@ -119,7 +119,7 @@ static Vec2f D_80938FF8[4] = { { 3.0f, 0.3f }, }; -void func_80936CF0(ObjBean* this, GlobalContext* globalCtx) { +void func_80936CF0(ObjBean* this, PlayState* play) { Vec3f sp24; s32 sp20; @@ -127,10 +127,10 @@ void func_80936CF0(ObjBean* this, GlobalContext* globalCtx) { sp24.y = this->dyna.actor.world.pos.y + 29.999998f; sp24.z = this->dyna.actor.world.pos.z; this->dyna.actor.floorHeight = - BgCheck_EntityRaycastFloor5(&globalCtx->colCtx, &this->dyna.actor.floorPoly, &sp20, &this->dyna.actor, &sp24); + BgCheck_EntityRaycastFloor5(&play->colCtx, &this->dyna.actor.floorPoly, &sp20, &this->dyna.actor, &sp24); } -s32 func_80936D58(ObjBean* this, GlobalContext* globalCtx) { +s32 func_80936D58(ObjBean* this, PlayState* play) { static Vec3f D_80939018 = { 0.0f, 30.0f, 0.0f }; s32 pad; s32 spB8; @@ -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, true, true, true, - true, &spB8, &this->dyna.actor)) { + if (BgCheck_EntityLineTest2(&play->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; @@ -212,8 +212,8 @@ void func_80937238(ObjBean* this) { this->dyna.actor.world.pos.z = this->unk_1BC.z + this->unk_1D0; } -void func_80937268(ObjBean* this, GlobalContext* globalCtx) { - this->unk_1D8 = globalCtx->setupPathList[OBJBEAN_GET_3F00(&this->dyna.actor)].count - 1; +void func_80937268(ObjBean* this, PlayState* play) { + this->unk_1D8 = play->setupPathList[OBJBEAN_GET_3F00(&this->dyna.actor)].count - 1; this->unk_1DA = 0; this->unk_1DC = 1; } @@ -259,8 +259,8 @@ void func_809372D0(ObjBean* this) { } } -s32 func_80937468(ObjBean* this, GlobalContext* globalCtx) { - Actor* bgActor = globalCtx->actorCtx.actorLists[ACTORCAT_BG].first; +s32 func_80937468(ObjBean* this, PlayState* play) { + Actor* bgActor = play->actorCtx.actorLists[ACTORCAT_BG].first; while (bgActor != NULL) { if ((bgActor->id == ACTOR_EN_HORSE) && @@ -273,8 +273,8 @@ s32 func_80937468(ObjBean* this, GlobalContext* globalCtx) { return false; } -ObjBean* func_809374F8(ObjBean* this, GlobalContext* globalCtx) { - Actor* bgActor = globalCtx->actorCtx.actorLists[ACTORCAT_BG].first; +ObjBean* func_809374F8(ObjBean* this, PlayState* play) { + Actor* bgActor = play->actorCtx.actorLists[ACTORCAT_BG].first; s32 params = OBJBEAN_GET_3F80(&this->dyna.actor, 0); while (bgActor != NULL) { @@ -293,15 +293,15 @@ ObjBean* func_809374F8(ObjBean* this, GlobalContext* globalCtx) { return (ObjBean*)bgActor; } -void func_809375C8(ObjBean* this, GlobalContext* globalCtx) { - ObjBean* bean = func_809374F8(this, globalCtx); +void func_809375C8(ObjBean* this, PlayState* play) { + ObjBean* bean = func_809374F8(this, play); if (bean != NULL) { bean->unk_200 = 1; } } -void func_809375F4(ObjBean* this, GlobalContext* globalCtx) { +void func_809375F4(ObjBean* this, PlayState* play) { static Gfx* D_80939024[] = { gKakeraLeafMiddle, gKakeraLeafTip, @@ -345,8 +345,8 @@ void func_809375F4(ObjBean* this, GlobalContext* globalCtx) { phi_s3 = -100; 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, GAMEPLAY_KEEP, D_80939024[i & 1]); + EffectSsKakera_Spawn(play, &spC4, &spB8, &spC4, phi_s3, phi_v0, 40, 3, 0, temp_s2, 0, 0, (temp_s2 >> 3) + 40, + -1, GAMEPLAY_KEEP, D_80939024[i & 1]); } } @@ -357,7 +357,7 @@ static InitChainEntry sInitChain[] = { ICHAIN_F32(uncullZoneDownward, 200, ICHAIN_STOP), }; -void ObjBean_Init(Actor* thisx, GlobalContext* globalCtx) { +void ObjBean_Init(Actor* thisx, PlayState* play) { s32 pad; ObjBean* this = THIS; s32 sp2C = OBJBEAN_GET_C000(&this->dyna.actor); @@ -366,26 +366,26 @@ void ObjBean_Init(Actor* thisx, GlobalContext* globalCtx) { this->unk_1FE = 0; this->unk_1B8 = 0.1f; DynaPolyActor_Init(&this->dyna, 3); - Collider_InitCylinder(globalCtx, &this->collider); + Collider_InitCylinder(play, &this->collider); if ((sp2C == ENOBJBEAN_GET_C000_1) || (sp2C == ENOBJBEAN_GET_C000_2)) { this->dyna.actor.update = func_80938C1C; this->dyna.actor.textId = 0xFD; if (sp2C == ENOBJBEAN_GET_C000_1) { - Collider_SetCylinder(globalCtx, &this->collider, &this->dyna.actor, &sCylinderInit2); + Collider_SetCylinder(play, &this->collider, &this->dyna.actor, &sCylinderInit2); Collider_UpdateCylinder(&this->dyna.actor, &this->collider); } this->dyna.actor.flags |= ACTOR_FLAG_10; func_80937C10(this); - if (!func_80936D58(this, globalCtx)) { + if (!func_80936D58(this, play)) { Actor_MarkForDeath(&this->dyna.actor); } else { - func_800BC154(globalCtx, &globalCtx->actorCtx, &this->dyna.actor, 7); + func_800BC154(play, &play->actorCtx, &this->dyna.actor, 7); func_80937DD8(this); } } else { s32 params2 = OBJBEAN_GET_3F00(&this->dyna.actor); - Path* path = &globalCtx->setupPathList[params2]; + Path* path = &play->setupPathList[params2]; this->unk_1DE = OBJBEAN_GET_3(&this->dyna.actor); this->dyna.actor.world.rot.z = 0; @@ -393,37 +393,37 @@ void ObjBean_Init(Actor* thisx, GlobalContext* globalCtx) { this->dyna.actor.shape.rot.z = 0; this->unk_1FE |= 2; - DynaPolyActor_LoadMesh(globalCtx, &this->dyna, &object_mamenoki_Colheader_0004BC); - Collider_SetCylinder(globalCtx, &this->collider, &this->dyna.actor, &sCylinderInit1); + DynaPolyActor_LoadMesh(play, &this->dyna, &object_mamenoki_Colheader_0004BC); + Collider_SetCylinder(play, &this->collider, &this->dyna.actor, &sCylinderInit1); Collider_UpdateCylinder(&this->dyna.actor, &this->collider); this->unk_1D4 = Lib_SegmentedToVirtual(path->points); - func_80937268(this, globalCtx); + func_80937268(this, play); func_809372A8(this); func_80937238(this); ActorShape_Init(&this->dyna.actor.shape, 0.0f, ActorShadow_DrawCircle, 8.8f); - func_80936CF0(this, globalCtx); + func_80936CF0(this, play); - if (!OBJBEAN_GET_80(&this->dyna.actor) && Flags_GetSwitch(globalCtx, OBJBEAN_GET_7F(&this->dyna.actor, 0)) && - !Flags_GetSwitch(globalCtx, OBJBEAN_GET_7F(&this->dyna.actor, 1)) && func_800FE9B4(globalCtx)) { - Flags_SetSwitch(globalCtx, OBJBEAN_GET_7F(&this->dyna.actor, 1)); + if (!OBJBEAN_GET_80(&this->dyna.actor) && Flags_GetSwitch(play, OBJBEAN_GET_7F(&this->dyna.actor, 0)) && + !Flags_GetSwitch(play, OBJBEAN_GET_7F(&this->dyna.actor, 1)) && func_800FE9B4(play)) { + Flags_SetSwitch(play, OBJBEAN_GET_7F(&this->dyna.actor, 1)); } - if (OBJBEAN_GET_80(&this->dyna.actor) || Flags_GetSwitch(globalCtx, OBJBEAN_GET_7F(&this->dyna.actor, 1))) { + if (OBJBEAN_GET_80(&this->dyna.actor) || Flags_GetSwitch(play, OBJBEAN_GET_7F(&this->dyna.actor, 1))) { func_80938804(this); } else { - func_800C62BC(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); + func_800C62BC(play, &play->colCtx.dyna, this->dyna.bgId); func_80938704(this); } } } -void ObjBean_Destroy(Actor* thisx, GlobalContext* globalCtx) { +void ObjBean_Destroy(Actor* thisx, PlayState* play) { ObjBean* this = THIS; - DynaPoly_DeleteBgActor(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); - Collider_DestroyCylinder(globalCtx, &this->collider); + DynaPoly_DeleteBgActor(play, &play->colCtx.dyna, this->dyna.bgId); + Collider_DestroyCylinder(play, &this->collider); } void func_80937B54(ObjBean* this) { @@ -487,14 +487,14 @@ void func_80937DD8(ObjBean* this) { this->actionFunc = func_80937DEC; } -void func_80937DEC(ObjBean* this, GlobalContext* globalCtx) { +void func_80937DEC(ObjBean* this, PlayState* play) { s32 pad; s32 sp20 = OBJBEAN_GET_C000(&this->dyna.actor); if (sp20 == ENOBJBEAN_GET_C000_1) { s32 pad2; - if (func_809374F8(this, globalCtx) == NULL) { + if (func_809374F8(this, play) == NULL) { this->unk_1FF = false; } else { this->unk_1FF = true; @@ -503,12 +503,12 @@ void func_80937DEC(ObjBean* this, GlobalContext* globalCtx) { this->unk_1FF = false; } - if (this->unk_1FF && !Flags_GetSwitch(globalCtx, OBJBEAN_GET_3F80(&this->dyna.actor, 1)) && - Flags_GetSwitch(globalCtx, OBJBEAN_GET_3F80(&this->dyna.actor, 0)) && func_800FE9B4(globalCtx)) { - Flags_SetSwitch(globalCtx, OBJBEAN_GET_3F80(&this->dyna.actor, 1)); + if (this->unk_1FF && !Flags_GetSwitch(play, OBJBEAN_GET_3F80(&this->dyna.actor, 1)) && + Flags_GetSwitch(play, OBJBEAN_GET_3F80(&this->dyna.actor, 0)) && func_800FE9B4(play)) { + Flags_SetSwitch(play, OBJBEAN_GET_3F80(&this->dyna.actor, 1)); } - if (this->unk_1FF && Flags_GetSwitch(globalCtx, OBJBEAN_GET_3F80(&this->dyna.actor, 1))) { + if (this->unk_1FF && Flags_GetSwitch(play, OBJBEAN_GET_3F80(&this->dyna.actor, 1))) { Actor_MarkForDeath(&this->dyna.actor); return; } @@ -519,7 +519,7 @@ void func_80937DEC(ObjBean* this, GlobalContext* globalCtx) { this->dyna.actor.draw = func_80938E00; } - if (this->unk_1FF && Flags_GetSwitch(globalCtx, OBJBEAN_GET_3F80(&this->dyna.actor, 0))) { + if (this->unk_1FF && Flags_GetSwitch(play, OBJBEAN_GET_3F80(&this->dyna.actor, 0))) { this->unk_1FE |= 5; func_80937C30(this); } else { @@ -527,7 +527,7 @@ void func_80937DEC(ObjBean* this, GlobalContext* globalCtx) { func_80937C10(this); } - if (Flags_GetSwitch(globalCtx, OBJBEAN_GET_7F(&this->dyna.actor, 0))) { + if (Flags_GetSwitch(play, OBJBEAN_GET_7F(&this->dyna.actor, 0))) { this->unk_1E4 = 5; } else { this->unk_1E4 = 0; @@ -541,16 +541,16 @@ void func_80937FB0(ObjBean* this) { this->actionFunc = func_80937FC8; } -void func_80937FC8(ObjBean* this, GlobalContext* globalCtx) { +void func_80937FC8(ObjBean* this, PlayState* play) { this->unk_1E8(this); - if (Actor_ProcessTalkRequest(&this->dyna.actor, &globalCtx->state)) { - if (Player_GetExchangeItemId(globalCtx) == EXCH_ITEM_2E) { + if (Actor_ProcessTalkRequest(&this->dyna.actor, &play->state)) { + if (Player_GetExchangeItemId(play) == PLAYER_AP_MAGIC_BEANS) { func_809383B4(this); - Flags_SetSwitch(globalCtx, OBJBEAN_GET_3F80(&this->dyna.actor, 0)); + Flags_SetSwitch(play, OBJBEAN_GET_3F80(&this->dyna.actor, 0)); } - if (Flags_GetSwitch(globalCtx, OBJBEAN_GET_7F(&this->dyna.actor, 0))) { + if (Flags_GetSwitch(play, OBJBEAN_GET_7F(&this->dyna.actor, 0))) { this->unk_1E4 = 5; } else { s32 pad; @@ -563,19 +563,19 @@ void func_80937FC8(ObjBean* this, GlobalContext* globalCtx) { } else if (((this->collider.base.acFlags & AC_HIT) && (this->collider.base.ac != NULL) && (this->collider.base.ac->id == ACTOR_OBJ_AQUA)) || ((this->unk_1FF != 0) && (this->unk_1FE & 4) && (this->dyna.actor.xzDistToPlayer < 300.0f) && - func_800FE9B4(globalCtx))) { - func_809375C8(this, globalCtx); - Flags_SetSwitch(globalCtx, OBJBEAN_GET_3F80(&this->dyna.actor, 1)); + func_800FE9B4(play))) { + func_809375C8(this, play); + Flags_SetSwitch(play, OBJBEAN_GET_3F80(&this->dyna.actor, 1)); this->unk_1E4 = 6; func_80938670(this); } else if (this->unk_1FF != 0) { if (this->unk_1FE & 4) { this->collider.base.acFlags &= ~AC_HIT; if (this->dyna.actor.xzDistToPlayer < 150.0f) { - CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + CollisionCheck_SetAC(play, &play->colChkCtx, &this->collider.base); } } else { - func_800B85E0(&this->dyna.actor, globalCtx, 28.0f, 0x2E); + func_800B85E0(&this->dyna.actor, play, 28.0f, 0x2E); } } } @@ -584,13 +584,13 @@ void func_809381B0(ObjBean* this) { this->actionFunc = func_809381C4; } -void func_809381C4(ObjBean* this, GlobalContext* globalCtx) { +void func_809381C4(ObjBean* this, PlayState* play) { this->unk_1E8(this); if (ActorCutscene_GetCanPlayNext(this->dyna.actor.cutscene)) { ActorCutscene_StartAndSetUnkLinkFields(this->dyna.actor.cutscene, &this->dyna.actor); if (this->dyna.actor.cutscene >= 0) { - func_800B7298(globalCtx, &this->dyna.actor, 1); + func_800B7298(play, &this->dyna.actor, 1); } this->unk_1E4 = 2; func_80938284(this); @@ -608,12 +608,12 @@ void func_80938284(ObjBean* this) { this->actionFunc = func_80938298; } -void func_80938298(ObjBean* this, GlobalContext* globalCtx) { +void func_80938298(ObjBean* this, PlayState* play) { this->unk_1E8(this); if (this->unk_1E0 >= 3) { this->unk_1E4 = 3; - Flags_SetSwitch(globalCtx, OBJBEAN_GET_7F(&this->dyna.actor, 0)); + Flags_SetSwitch(play, OBJBEAN_GET_7F(&this->dyna.actor, 0)); this->unk_1E4 = 5; func_8093833C(this); } else if (this->unk_1E4 == 4) { @@ -629,7 +629,7 @@ void func_8093833C(ObjBean* this) { this->unk_1B2 = 4; } -void func_80938358(ObjBean* this, GlobalContext* globalCtx) { +void func_80938358(ObjBean* this, PlayState* play) { this->unk_1E8(this); if (this->unk_1B2 <= 0) { @@ -643,7 +643,7 @@ void func_809383B4(ObjBean* this) { this->actionFunc = func_809383D0; } -void func_809383D0(ObjBean* this, GlobalContext* globalCtx) { +void func_809383D0(ObjBean* this, PlayState* play) { if (this->unk_1B2 <= 0) { this->unk_1FE |= 4; func_80938408(this); @@ -655,7 +655,7 @@ void func_80938408(ObjBean* this) { this->actionFunc = func_80938444; } -void func_80938444(ObjBean* this, GlobalContext* globalCtx) { +void func_80938444(ObjBean* this, PlayState* play) { s32 pad; s32 sp20 = Math_StepToF(&this->dyna.actor.scale.y, 0.16672663f, 0.01f) & 1; @@ -677,7 +677,7 @@ void func_809384E8(ObjBean* this) { this->actionFunc = func_80938504; } -void func_80938504(ObjBean* this, GlobalContext* globalCtx) { +void func_80938504(ObjBean* this, PlayState* play) { this->unk_1AC -= 2400; this->dyna.actor.scale.y = Math_SinS(this->unk_1AC) * 0.17434467f; this->dyna.actor.scale.x = this->dyna.actor.scale.z = Math_CosS(this->unk_1AC) * 0.12207746f; @@ -692,7 +692,7 @@ void func_80938588(ObjBean* this) { this->actionFunc = func_809385A8; } -void func_809385A8(ObjBean* this, GlobalContext* globalCtx) { +void func_809385A8(ObjBean* this, PlayState* play) { s32 pad; s16 sp22; @@ -712,7 +712,7 @@ void func_80938670(ObjBean* this) { this->unk_1B2 = 73; } -void func_8093868C(ObjBean* this, GlobalContext* globalCtx) { +void func_8093868C(ObjBean* this, PlayState* play) { if (this->unk_1B2 <= 0) { Actor_MarkForDeath(&this->dyna.actor); } else if (this->unk_1B2 <= 20) { @@ -729,7 +729,7 @@ void func_80938704(ObjBean* this) { this->actionFunc = func_80938728; } -void func_80938728(ObjBean* this, GlobalContext* globalCtx) { +void func_80938728(ObjBean* this, PlayState* play) { if (this->unk_200 != 0) { ActorCutscene_SetIntentToPlay(this->dyna.actor.cutscene); func_8093876C(this); @@ -740,11 +740,11 @@ void func_8093876C(ObjBean* this) { this->actionFunc = func_80938780; } -void func_80938780(ObjBean* this, GlobalContext* globalCtx) { +void func_80938780(ObjBean* this, PlayState* play) { if (ActorCutscene_GetCanPlayNext(this->dyna.actor.cutscene)) { ActorCutscene_StartAndSetUnkLinkFields(this->dyna.actor.cutscene, &this->dyna.actor); if (this->dyna.actor.cutscene >= 0) { - func_800B7298(globalCtx, &this->dyna.actor, 1); + func_800B7298(play, &this->dyna.actor, 1); } this->unk_1B4 = 36; func_80937130(this); @@ -760,7 +760,7 @@ void func_80938804(ObjBean* this) { this->actionFunc = func_80938834; } -void func_80938834(ObjBean* this, GlobalContext* globalCtx) { +void func_80938834(ObjBean* this, PlayState* play) { if (DynaPolyActor_IsInRidingMovingState(&this->dyna)) { func_80938874(this); } @@ -774,10 +774,10 @@ void func_80938874(ObjBean* this) { this->dyna.actor.speedXZ = 0.0f; } -void func_809388A8(ObjBean* this, GlobalContext* globalCtx) { +void func_809388A8(ObjBean* this, PlayState* play) { func_809372D0(this); if (this->unk_1DA == this->unk_1D8) { - func_80937268(this, globalCtx); + func_80937268(this, play); func_809372A8(this); func_8093892C(this); } else if (DynaPolyActor_IsInRidingMovingState(&this->dyna)) { @@ -792,7 +792,7 @@ void func_8093892C(ObjBean* this) { this->actionFunc = func_80938958; } -void func_80938958(ObjBean* this, GlobalContext* globalCtx) { +void func_80938958(ObjBean* this, PlayState* play) { if (!DynaPolyActor_IsInRidingRotatingState(&this->dyna)) { func_80938804(this); } @@ -805,9 +805,9 @@ void func_80938998(ObjBean* this) { this->actionFunc = func_809389BC; } -void func_809389BC(ObjBean* this, GlobalContext* globalCtx) { +void func_809389BC(ObjBean* this, PlayState* play) { if (!DynaPolyActor_IsInRidingMovingState(&this->dyna)) { - func_80937268(this, globalCtx); + func_80937268(this, play); func_809372A8(this); func_80937238(this); func_80938A14(this); @@ -822,8 +822,8 @@ void func_80938A14(ObjBean* this) { this->actionFunc = func_80938A5C; } -void func_80938A5C(ObjBean* this, GlobalContext* globalCtx) { - if (func_80937468(this, globalCtx)) { +void func_80938A5C(ObjBean* this, PlayState* play) { + if (func_80937468(this, play)) { this->unk_1B2 = 100; } else if (this->unk_1B2 <= 0) { func_80938AA4(this); @@ -837,9 +837,9 @@ void func_80938AA4(ObjBean* this) { this->actionFunc = func_80938AD8; } -void func_80938AD8(ObjBean* this, GlobalContext* globalCtx) { +void func_80938AD8(ObjBean* this, PlayState* play) { s32 pad; - s32 sp30 = func_80937468(this, globalCtx); + s32 sp30 = func_80937468(this, play); func_80937160(this); if (this->unk_1B2 == 25) { @@ -847,13 +847,13 @@ void func_80938AD8(ObjBean* this, GlobalContext* globalCtx) { } if (sp30 != 0) { - func_800C6314(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); + func_800C6314(play, &play->colCtx.dyna, this->dyna.bgId); } else { - func_800C6314(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); + func_800C6314(play, &play->colCtx.dyna, this->dyna.bgId); } if (this->dyna.actor.xzDistToPlayer < 74.0f) { - Player* player = GET_PLAYER(globalCtx); + Player* player = GET_PLAYER(play); f32 sp28 = 74.0f - this->dyna.actor.xzDistToPlayer; f32 sin; f32 cos; @@ -875,7 +875,7 @@ void func_80938AD8(ObjBean* this, GlobalContext* globalCtx) { } } -void func_80938C1C(Actor* thisx, GlobalContext* globalCtx) { +void func_80938C1C(Actor* thisx, PlayState* play) { ObjBean* this = THIS; if (this->unk_1B2 > 0) { @@ -889,10 +889,10 @@ void func_80938C1C(Actor* thisx, GlobalContext* globalCtx) { } } - this->actionFunc(this, globalCtx); + this->actionFunc(this, play); } -void ObjBean_Update(Actor* thisx, GlobalContext* globalCtx) { +void ObjBean_Update(Actor* thisx, PlayState* play) { s32 pad; ObjBean* this = THIS; @@ -900,7 +900,7 @@ void ObjBean_Update(Actor* thisx, GlobalContext* globalCtx) { this->unk_1B2--; } - this->actionFunc(this, globalCtx); + this->actionFunc(this, play); if (this->unk_1B4 > 0) { this->unk_1B4--; @@ -914,14 +914,14 @@ void ObjBean_Update(Actor* thisx, GlobalContext* globalCtx) { if (this->dyna.actor.xzDistToPlayer < 150.0f) { this->collider.dim.radius = (this->dyna.actor.scale.x * 640.0f) + 0.5f; Collider_UpdateCylinder(&this->dyna.actor, &this->collider); - CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + CollisionCheck_SetOC(play, &play->colChkCtx, &this->collider.base); } - func_80936CF0(this, globalCtx); + func_80936CF0(this, play); this->dyna.actor.shape.shadowDraw = ActorShadow_DrawCircle; this->dyna.actor.shape.shadowScale = this->dyna.actor.scale.x * 88.0f; - if (func_80937468(this, globalCtx)) { - func_809375F4(this, globalCtx); - func_800C62BC(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); + if (func_80937468(this, play)) { + func_809375F4(this, play); + func_800C62BC(play, &play->colCtx.dyna, this->dyna.bgId); func_80938998(this); } } else { @@ -930,14 +930,14 @@ void ObjBean_Update(Actor* thisx, GlobalContext* globalCtx) { Actor_SetFocus(&this->dyna.actor, 6.0f); } -void func_80938E00(Actor* thisx, GlobalContext* globalCtx) { +void func_80938E00(Actor* thisx, PlayState* play) { ObjBean* this = THIS; - OPEN_DISPS(globalCtx->state.gfxCtx); + OPEN_DISPS(play->state.gfxCtx); - func_8012C28C(globalCtx->state.gfxCtx); + func_8012C28C(play->state.gfxCtx); - gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); if (this->unk_1FE & 4) { gSPDisplayList(POLY_OPA_DISP++, object_mamenoki_DL_000090); @@ -948,19 +948,19 @@ 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); + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_OPA_DISP++, object_mamenoki_DL_000530); } - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->state.gfxCtx); } -void func_80938F50(Actor* thisx, GlobalContext* globalCtx) { +void func_80938F50(Actor* thisx, PlayState* play) { ObjBean* this = THIS; - Gfx_DrawDListXlu(globalCtx, object_mamenoki_DL_002208); + Gfx_DrawDListXlu(play, object_mamenoki_DL_002208); } diff --git a/src/overlays/actors/ovl_Obj_Bean/z_obj_bean.h b/src/overlays/actors/ovl_Obj_Bean/z_obj_bean.h index da6e4a22c..5af772007 100644 --- a/src/overlays/actors/ovl_Obj_Bean/z_obj_bean.h +++ b/src/overlays/actors/ovl_Obj_Bean/z_obj_bean.h @@ -5,7 +5,7 @@ struct ObjBean; -typedef void (*ObjBeanActionFunc)(struct ObjBean*, GlobalContext*); +typedef void (*ObjBeanActionFunc)(struct ObjBean*, PlayState*); typedef void (*ObjBeanUnkFunc)(struct ObjBean*); #define OBJBEAN_GET_7F(thisx, x) (((thisx)->params + (x)) & 0x7F) @@ -17,9 +17,9 @@ typedef void (*ObjBeanUnkFunc)(struct ObjBean*); #define OBJBEAN_GET_3(thisx) ((thisx)->home.rot.z & 3) enum { - /* 0x00 */ ENOBJBEAN_GET_C000_0, - /* 0x01 */ ENOBJBEAN_GET_C000_1, - /* 0x02 */ ENOBJBEAN_GET_C000_2, + /* 0x0 */ ENOBJBEAN_GET_C000_0, + /* 0x1 */ ENOBJBEAN_GET_C000_1, + /* 0x2 */ ENOBJBEAN_GET_C000_2, }; typedef struct ObjBean { diff --git a/src/overlays/actors/ovl_Obj_Bell/z_obj_bell.c b/src/overlays/actors/ovl_Obj_Bell/z_obj_bell.c index dd57b99e4..d57c9937d 100644 --- a/src/overlays/actors/ovl_Obj_Bell/z_obj_bell.c +++ b/src/overlays/actors/ovl_Obj_Bell/z_obj_bell.c @@ -11,13 +11,13 @@ #define THIS ((ObjBell*)thisx) -void ObjBell_Init(Actor* thisx, GlobalContext* globalCtx); -void ObjBell_Destroy(Actor* thisx, GlobalContext* globalCtx); -void ObjBell_Update(Actor* thisx, GlobalContext* globalCtx); -void ObjBell_Draw(Actor* thisx, GlobalContext* globalCtx); +void ObjBell_Init(Actor* thisx, PlayState* play); +void ObjBell_Destroy(Actor* thisx, PlayState* play); +void ObjBell_Update(Actor* thisx, PlayState* play); +void ObjBell_Draw(Actor* thisx, PlayState* play); s32 func_80A356D8(ObjBell* this); -s32 func_80A357A8(ObjBell* this, GlobalContext* globalCtx); +s32 func_80A357A8(ObjBell* this, PlayState* play); const ActorInit Obj_Bell_InitVars = { ACTOR_OBJ_BELL, @@ -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; } @@ -168,7 +165,7 @@ s32 func_80A356D8(ObjBell* this) { return false; } -s32 func_80A357A8(ObjBell* this, GlobalContext* globalCtx) { +s32 func_80A357A8(ObjBell* this, PlayState* play) { f32 temp_f0; s16 temp_v1; @@ -179,7 +176,7 @@ s32 func_80A357A8(ObjBell* this, GlobalContext* globalCtx) { if (ABS_ALT(temp_v1) < 0x3FFC) { if (this->unk_214 == 0) { if (temp_f0 > 0.18f) { - func_800B8D98(globalCtx, &this->dyna.actor, 8.0f * temp_f0, this->dyna.actor.yawTowardsPlayer, + func_800B8D98(play, &this->dyna.actor, 8.0f * temp_f0, this->dyna.actor.yawTowardsPlayer, 11.0f * temp_f0); this->unk_214 = 30; } @@ -206,96 +203,96 @@ s32 func_80A357A8(ObjBell* this, GlobalContext* globalCtx) { return false; } -void func_80A358FC(ObjBell* this, GlobalContext* globalCtx) { +void func_80A358FC(ObjBell* this, PlayState* play) { this->collider1.dim.worldSphere.radius = (this->collider1.dim.modelSphere.radius * this->collider1.dim.scale); this->collider2.dim.worldSphere.radius = (this->collider2.dim.modelSphere.radius * this->collider2.dim.scale); if (DECR(this->unk_20E) == 0) { - CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->collider2.base); + CollisionCheck_SetAC(play, &play->colChkCtx, &this->collider2.base); } - CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider1.base); + CollisionCheck_SetOC(play, &play->colChkCtx, &this->collider1.base); } -void func_80A359B4(Actor* thisx, GlobalContext* globalCtx) { - Matrix_InsertTranslation(thisx->world.pos.x, thisx->world.pos.y, thisx->world.pos.z, MTXMODE_NEW); +void func_80A359B4(Actor* thisx, PlayState* play) { + 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); - OPEN_DISPS(globalCtx->state.gfxCtx); - func_8012C28C(globalCtx->state.gfxCtx); - gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + Matrix_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(play->state.gfxCtx); + func_8012C28C(play->state.gfxCtx); + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_OPA_DISP++, object_f52_obj_DL_000698); gSPDisplayList(POLY_OPA_DISP++, object_f52_obj_DL_0008D0); gSPDisplayList(POLY_OPA_DISP++, object_f52_obj_DL_000960); gSPDisplayList(POLY_OPA_DISP++, object_f52_obj_DL_0007A8); - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->state.gfxCtx); } -void func_80A35B18(Actor* thisx, GlobalContext* globalCtx) { - Matrix_InsertTranslation(thisx->world.pos.x, thisx->world.pos.y, thisx->world.pos.z, MTXMODE_NEW); +void func_80A35B18(Actor* thisx, PlayState* play) { + 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); - OPEN_DISPS(globalCtx->state.gfxCtx); - func_8012C28C(globalCtx->state.gfxCtx); - gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + Matrix_RotateYS(thisx->shape.rot.y, MTXMODE_APPLY); + OPEN_DISPS(play->state.gfxCtx); + func_8012C28C(play->state.gfxCtx); + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_OPA_DISP++, object_f52_obj_DL_000570); - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->state.gfxCtx); } -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); +void func_80A35BD4(Actor* thisx, PlayState* play) { + 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); - gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + OPEN_DISPS(play->state.gfxCtx); + func_8012C2DC(play->state.gfxCtx); + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_XLU_DISP++, object_f52_obj_DL_000840); - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->state.gfxCtx); } -void ObjBell_Init(Actor* thisx, GlobalContext* globalCtx) { +void ObjBell_Init(Actor* thisx, PlayState* play) { ObjBell* this = THIS; DynaPolyActor_Init(&this->dyna, 0); - DynaPolyActor_LoadMesh(globalCtx, &this->dyna, &object_f52_obj_Colheader_001BA8); + DynaPolyActor_LoadMesh(play, &this->dyna, &object_f52_obj_Colheader_001BA8); Actor_SetScale(&this->dyna.actor, 0.08f); - Collider_InitAndSetSphere(globalCtx, &this->collider1, &this->dyna.actor, &sCylinderInit1); - Collider_InitAndSetSphere(globalCtx, &this->collider2, &this->dyna.actor, &sCylinderInit2); + Collider_InitAndSetSphere(play, &this->collider1, &this->dyna.actor, &sCylinderInit1); + Collider_InitAndSetSphere(play, &this->collider2, &this->dyna.actor, &sCylinderInit2); CollisionCheck_SetInfo2(&this->dyna.actor.colChkInfo, &sDamageTable, &sColChkInfoInit2); } -void ObjBell_Destroy(Actor* thisx, GlobalContext* globalCtx) { +void ObjBell_Destroy(Actor* thisx, PlayState* play) { ObjBell* this = THIS; - DynaPoly_DeleteBgActor(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); - Collider_DestroySphere(globalCtx, &this->collider1); - Collider_DestroySphere(globalCtx, &this->collider2); + DynaPoly_DeleteBgActor(play, &play->colCtx.dyna, this->dyna.bgId); + Collider_DestroySphere(play, &this->collider1); + Collider_DestroySphere(play, &this->collider2); } -void ObjBell_Update(Actor* thisx, GlobalContext* globalCtx) { +void ObjBell_Update(Actor* thisx, PlayState* play) { ObjBell* this = THIS; if (this->unk_214 != 0) { this->unk_214--; } - func_80A357A8(this, globalCtx); + func_80A357A8(this, play); func_80A356D8(this); - func_80A358FC(this, globalCtx); + func_80A358FC(this, play); } -void ObjBell_Draw(Actor* thisx, GlobalContext* globalCtx) { +void ObjBell_Draw(Actor* thisx, PlayState* play) { ObjBell* this = THIS; Vec3f sp30; Vec3f sp24; - func_80A35B18(thisx, globalCtx); - func_80A35BD4(thisx, globalCtx); - func_80A359B4(thisx, globalCtx); + func_80A35B18(thisx, play); + func_80A35BD4(thisx, play); + func_80A359B4(thisx, play); 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_Bell/z_obj_bell.h b/src/overlays/actors/ovl_Obj_Bell/z_obj_bell.h index 76265bcec..c55381ad3 100644 --- a/src/overlays/actors/ovl_Obj_Bell/z_obj_bell.h +++ b/src/overlays/actors/ovl_Obj_Bell/z_obj_bell.h @@ -14,10 +14,10 @@ typedef struct ObjBell { /* 0x210 */ s16 unk_210; /* 0x212 */ s16 unk_212; /* 0x214 */ s16 unk_214; - /* 0x216 */ char unk_216[0x06]; + /* 0x216 */ UNK_TYPE1 unk_216[0x06]; /* 0x21C */ f32 unk_21C; // bell speed? /* 0x220 */ f32 unk_220; - /* 0x224 */ char unk_224[0x04]; + /* 0x224 */ UNK_TYPE1 unk_224[0x04]; } ObjBell; // size = 0x228 extern const ActorInit Obj_Bell_InitVars; 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 b4a85a3a0..7f59fe579 100644 --- a/src/overlays/actors/ovl_Obj_Bigicicle/z_obj_bigicicle.c +++ b/src/overlays/actors/ovl_Obj_Bigicicle/z_obj_bigicicle.c @@ -6,22 +6,23 @@ #include "z_obj_bigicicle.h" #include "overlays/actors/ovl_Obj_Ice_Poly/z_obj_ice_poly.h" +#include "overlays/effects/ovl_Effect_Ss_Hahen/z_eff_ss_hahen.h" #include "objects/object_bigicicle/object_bigicicle.h" #define FLAGS 0x00000000 #define THIS ((ObjBigicicle*)thisx) -void ObjBigicicle_Init(Actor* thisx, GlobalContext* globalCtx); -void ObjBigicicle_Destroy(Actor* thisx, GlobalContext* globalCtx); -void ObjBigicicle_Update(Actor* thisx, GlobalContext* globalCtx); -void ObjBigicicle_Draw(Actor* thisx, GlobalContext* globalCtx); +void ObjBigicicle_Init(Actor* thisx, PlayState* play); +void ObjBigicicle_Destroy(Actor* thisx, PlayState* play); +void ObjBigicicle_Update(Actor* thisx, PlayState* play); +void ObjBigicicle_Draw(Actor* thisx, PlayState* play); -void func_80AE8FD4(ObjBigicicle* this, GlobalContext* globalCtx); -void func_80AE9090(ObjBigicicle* this, GlobalContext* globalCtx); -void func_80AE9180(ObjBigicicle* this, GlobalContext* globalCtx); -void func_80AE9258(ObjBigicicle* this, GlobalContext* globalCtx); -void func_80AE939C(ObjBigicicle* this, GlobalContext* globalCtx); +void func_80AE8FD4(ObjBigicicle* this, PlayState* play); +void func_80AE9090(ObjBigicicle* this, PlayState* play); +void func_80AE9180(ObjBigicicle* this, PlayState* play); +void func_80AE9258(ObjBigicicle* this, PlayState* play); +void func_80AE939C(ObjBigicicle* this, PlayState* play); const ActorInit Obj_Bigicicle_InitVars = { ACTOR_OBJ_BIGICICLE, @@ -97,7 +98,7 @@ Gfx* D_80AE98A8[] = { object_bigicicle_DL_000F40, }; -void ObjBigicicle_Init(Actor* thisx, GlobalContext* globalCtx) { +void ObjBigicicle_Init(Actor* thisx, PlayState* play) { ObjBigicicle* this = THIS; f32 sp30; s32 sp28; @@ -114,17 +115,17 @@ void ObjBigicicle_Init(Actor* thisx, GlobalContext* globalCtx) { this->actor.colChkInfo.mass = MASS_IMMOVABLE; sp30 = sp28 * (1.0f / 60.0f); - Collider_InitAndSetCylinder(globalCtx, &this->collider1, &this->actor, &sCylinderInit1); + Collider_InitAndSetCylinder(play, &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; - Collider_InitAndSetCylinder(globalCtx, &this->collider2, &this->actor, &sCylinderInit2); + Collider_InitAndSetCylinder(play, &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; - if (Flags_GetSwitch(globalCtx, this->actor.params)) { + if (Flags_GetSwitch(play, this->actor.params)) { Actor_MarkForDeath(&this->actor); return; } @@ -144,14 +145,14 @@ void ObjBigicicle_Init(Actor* thisx, GlobalContext* globalCtx) { this->actionFunc = func_80AE8FD4; } -void ObjBigicicle_Destroy(Actor* thisx, GlobalContext* globalCtx) { +void ObjBigicicle_Destroy(Actor* thisx, PlayState* play) { ObjBigicicle* this = THIS; - Collider_DestroyCylinder(globalCtx, &this->collider1); - Collider_DestroyCylinder(globalCtx, &this->collider2); + Collider_DestroyCylinder(play, &this->collider1); + Collider_DestroyCylinder(play, &this->collider2); } -void func_80AE8DE4(ObjBigicicle* this, GlobalContext* globalCtx) { +void func_80AE8DE4(ObjBigicicle* this, PlayState* play) { s32 i; Vec3f sp98; Vec3f sp8C; @@ -166,18 +167,18 @@ void func_80AE8DE4(ObjBigicicle* this, GlobalContext* globalCtx) { 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); + EffectSsHahen_Spawn(play, &sp98, &sp8C, &D_80AE987C, HAHEN_XLU, (Rand_ZeroFloat(20.0f) + 30.0f) * temp_f20, + OBJECT_BIGICICLE, 40, object_bigicicle_DL_0009B0); } sp98.x = this->actor.world.pos.x; 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); + SoundSource_PlaySfxAtFixedWorldPos(play, &sp98, 40, NA_SE_EV_ICE_PIECE); } -void func_80AE8FD4(ObjBigicicle* this, GlobalContext* globalCtx) { +void func_80AE8FD4(ObjBigicicle* this, PlayState* play) { if ((this->collider1.base.acFlags & AC_HIT) || ((this->collider2.base.acFlags & AC_HIT) && (this->collider2.info.acHitInfo->toucher.dmgFlags & 0x3820))) { if ((this->unk_148 == 0) || (this->unk_149 == 1)) { @@ -186,18 +187,18 @@ void func_80AE8FD4(ObjBigicicle* this, GlobalContext* globalCtx) { return; } - func_80AE8DE4(this, globalCtx); + func_80AE8DE4(this, play); this->unk_149++; this->unk_14A = 50; this->actionFunc = func_80AE9180; } } -void func_80AE9090(ObjBigicicle* this, GlobalContext* globalCtx) { +void func_80AE9090(ObjBigicicle* this, PlayState* play) { if (ActorCutscene_GetCanPlayNext(this->actor.cutscene)) { ActorCutscene_StartAndSetUnkLinkFields(this->actor.cutscene, &this->actor); this->unk_149++; - func_80AE8DE4(this, globalCtx); + func_80AE8DE4(this, play); if (this->unk_149 == 2) { f32 temp_f0 = this->actor.scale.y * 2100.0f; @@ -216,7 +217,7 @@ void func_80AE9090(ObjBigicicle* this, GlobalContext* globalCtx) { } } -void func_80AE9180(ObjBigicicle* this, GlobalContext* globalCtx) { +void func_80AE9180(ObjBigicicle* this, PlayState* play) { this->unk_14A--; if (this->unk_14A > 0) { @@ -231,15 +232,15 @@ void func_80AE9180(ObjBigicicle* this, GlobalContext* globalCtx) { } } -void func_80AE9258(ObjBigicicle* this, GlobalContext* globalCtx) { +void func_80AE9258(ObjBigicicle* this, PlayState* play) { Actor* itemAction; f32 temp_f0; ObjIcePoly* icePoly; Actor_MoveWithGravity(&this->actor); - Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 0.0f, 0.0f, 0.0f, 4); + Actor_UpdateBgCheckInfo(play, &this->actor, 0.0f, 0.0f, 0.0f, 4); - itemAction = globalCtx->actorCtx.actorLists[ACTORCAT_ITEMACTION].first; + itemAction = play->actorCtx.actorLists[ACTORCAT_ITEMACTION].first; while (itemAction != NULL) { if (itemAction->id == ACTOR_OBJ_ICE_POLY) { @@ -247,7 +248,7 @@ void func_80AE9258(ObjBigicicle* this, GlobalContext* globalCtx) { 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); + Flags_SetSwitch(play, this->actor.params); this->actionFunc = func_80AE939C; return; } @@ -263,7 +264,7 @@ void func_80AE9258(ObjBigicicle* this, GlobalContext* globalCtx) { } } -void func_80AE939C(ObjBigicicle* this, GlobalContext* globalCtx) { +void func_80AE939C(ObjBigicicle* this, PlayState* play) { s32 i; Vec3f sp98; Vec3f sp8C; @@ -278,21 +279,21 @@ void func_80AE939C(ObjBigicicle* this, GlobalContext* globalCtx) { 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, + EffectSsHahen_Spawn(play, &sp98, &sp8C, &D_80AE987C, HAHEN_XLU, (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); + SoundSource_PlaySfxAtFixedWorldPos(play, &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) { +void ObjBigicicle_Update(Actor* thisx, PlayState* play) { s32 pad; ObjBigicicle* this = THIS; Vec3f sp44; - this->actionFunc(this, globalCtx); + this->actionFunc(this, play); if (Rand_ZeroOne() < 0.05f) { sp44.x = (((215.0f + Rand_ZeroFloat(65.0f)) * ((Rand_ZeroOne() < 0.5f) ? -1 : 1)) * this->actor.scale.x) + @@ -302,20 +303,20 @@ void ObjBigicicle_Update(Actor* thisx, GlobalContext* globalCtx) { 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); + EffectSsKirakira_SpawnDispersed(play, &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); + CollisionCheck_SetAC(play, &play->colChkCtx, &this->collider1.base); + CollisionCheck_SetAC(play, &play->colChkCtx, &this->collider2.base); + CollisionCheck_SetOC(play, &play->colChkCtx, &this->collider1.base); + CollisionCheck_SetOC(play, &play->colChkCtx, &this->collider2.base); } -void ObjBigicicle_Draw(Actor* thisx, GlobalContext* globalCtx) { +void ObjBigicicle_Draw(Actor* thisx, PlayState* play) { 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); + Gfx_DrawDListXlu(play, D_80AE989C[this->unk_149]); + Gfx_DrawDListXlu(play, D_80AE98A8[this->unk_149]); + AnimatedMat_Draw(play, D_80AE9878); + Gfx_DrawDListXlu(play, 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 1744a81b4..7e28abd45 100644 --- a/src/overlays/actors/ovl_Obj_Bigicicle/z_obj_bigicicle.h +++ b/src/overlays/actors/ovl_Obj_Bigicicle/z_obj_bigicicle.h @@ -5,18 +5,18 @@ struct ObjBigicicle; -typedef void (*ObjBigicicleActionFunc)(struct ObjBigicicle*, GlobalContext*); +typedef void (*ObjBigicicleActionFunc)(struct ObjBigicicle*, PlayState*); #define OBJBIGICLE_GET_FF00(thisx) (((thisx)->params >> 8) & 0xFF) typedef struct ObjBigicicle { - /* 0x0000 */ Actor actor; - /* 0x0144 */ ObjBigicicleActionFunc actionFunc; - /* 0x0148 */ u8 unk_148; - /* 0x0149 */ u8 unk_149; - /* 0x014A */ s16 unk_14A; - /* 0x014C */ ColliderCylinder collider1; - /* 0x0198 */ ColliderCylinder collider2; + /* 0x000 */ Actor actor; + /* 0x144 */ ObjBigicicleActionFunc actionFunc; + /* 0x148 */ u8 unk_148; + /* 0x149 */ u8 unk_149; + /* 0x14A */ s16 unk_14A; + /* 0x14C */ ColliderCylinder collider1; + /* 0x198 */ ColliderCylinder collider2; } ObjBigicicle; // size = 0x1E4 extern const ActorInit Obj_Bigicicle_InitVars; diff --git a/src/overlays/actors/ovl_Obj_Blockstop/z_obj_blockstop.c b/src/overlays/actors/ovl_Obj_Blockstop/z_obj_blockstop.c index 0d937d1c0..9c35b0298 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 (ACTOR_FLAG_10) #define THIS ((ObjBlockstop*)thisx) -void ObjBlockstop_Init(Actor* thisx, GlobalContext* globalCtx); -void ObjBlockstop_Update(Actor* thisx, GlobalContext* globalCtx); +void ObjBlockstop_Init(Actor* thisx, PlayState* play); +void ObjBlockstop_Update(Actor* thisx, PlayState* play); -void func_809466F0(ObjBlockstop* this, GlobalContext* globalCtx); +void ObjBlockstop_CheckForBlock(ObjBlockstop* this, PlayState* play); +void ObjBlockstop_TryPlayCutscene(ObjBlockstop* this, PlayState* play); -#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, PlayState* play) { + ObjBlockstop* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Blockstop/ObjBlockstop_Init.s") + if (Flags_GetSwitch(play, 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, PlayState* play) { + Actor* prop = play->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, PlayState* play) { + if (ActorCutscene_GetCanPlayNext(this->actor.cutscene)) { + Flags_SetSwitch(play, 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, PlayState* play) { + ObjBlockstop* this = THIS; + + this->actionFunc(this, play); +} diff --git a/src/overlays/actors/ovl_Obj_Blockstop/z_obj_blockstop.h b/src/overlays/actors/ovl_Obj_Blockstop/z_obj_blockstop.h index 6f9f6439e..95af6757c 100644 --- a/src/overlays/actors/ovl_Obj_Blockstop/z_obj_blockstop.h +++ b/src/overlays/actors/ovl_Obj_Blockstop/z_obj_blockstop.h @@ -5,11 +5,11 @@ struct ObjBlockstop; -typedef void (*ObjBlockstopActionFunc)(struct ObjBlockstop*, GlobalContext*); +typedef void (*ObjBlockstopActionFunc)(struct ObjBlockstop*, PlayState*); typedef struct ObjBlockstop { - /* 0x0000 */ Actor actor; - /* 0x0144 */ ObjBlockstopActionFunc actionFunc; + /* 0x000 */ Actor actor; + /* 0x144 */ ObjBlockstopActionFunc actionFunc; } ObjBlockstop; // size = 0x148 extern const ActorInit Obj_Blockstop_InitVars; diff --git a/src/overlays/actors/ovl_Obj_Boat/z_obj_boat.c b/src/overlays/actors/ovl_Obj_Boat/z_obj_boat.c index 880d72b3f..0380b338d 100644 --- a/src/overlays/actors/ovl_Obj_Boat/z_obj_boat.c +++ b/src/overlays/actors/ovl_Obj_Boat/z_obj_boat.c @@ -5,17 +5,19 @@ */ #include "z_obj_boat.h" +#include "objects/object_kaizoku_obj/object_kaizoku_obj.h" #define FLAGS (ACTOR_FLAG_10) #define THIS ((ObjBoat*)thisx) -void ObjBoat_Init(Actor* thisx, GlobalContext* globalCtx); -void ObjBoat_Destroy(Actor* thisx, GlobalContext* globalCtx); -void ObjBoat_Update(Actor* thisx, GlobalContext* globalCtx); -void ObjBoat_Draw(Actor* thisx, GlobalContext* globalCtx); +void ObjBoat_Init(Actor* thisx, PlayState* play); +void ObjBoat_Destroy(Actor* thisx, PlayState* play); +void ObjBoat_Update(Actor* thisx, PlayState* play); +void ObjBoat_Draw(Actor* thisx, PlayState* play); + +void func_80B9B428(Actor* thisx, PlayState* play); -#if 0 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, PlayState* play) { + 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(play, &this->dyna, &object_kaizoku_obj_Colheader_009A88); + if (thisx->params < 0) { + this->dyna.actor.update = func_80B9B428; + } else { + path = &play->setupPathList[OBJBOAT_GET_PATH(thisx)]; + this->unk_163 = path->count - 1; + this->unk_164 = Lib_SegmentedToVirtual(path->points); + this->unk_15D = 1; + this->dyna.actor.world.pos.x = this->unk_164[this->unk_15C].x; + this->dyna.actor.world.pos.z = this->unk_164[this->unk_15C].z; + this->dyna.actor.shape.rot.y = func_80B9AF50(this, &sp24); + this->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, PlayState* play) { + ObjBoat* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Boat/func_80B9B124.s") + DynaPoly_DeleteBgActor(play, &play->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, PlayState* play) { + s32 pad; + ObjBoat* this = THIS; + Player* player = GET_PLAYER(play); + s32 temp = DynaPolyActor_IsInRidingMovingState(&this->dyna); + f32 sp3C = 0.0f; + s16 sp3A = this->dyna.actor.shape.rot.y; + Vec3f sp2C; -#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, PlayState* play2) { + PlayState* play = play2; + ObjBoat* this = THIS; + + if (Cutscene_CheckActorAction(play, 511)) { + CsCmdActorAction* actionIndex = play->csCtx.actorActions[Cutscene_GetActorActionIndex(play, 511)]; + if (this->unk_15F != actionIndex->action) { + this->dyna.actor.shape.rot.x = actionIndex->urot.x; + if (actionIndex->action != 1) { + Path* path = &play->setupPathList[OBJBOAT_GET_PATH(&this->dyna.actor)]; + + if (actionIndex->action == 3) { + path = &play->setupPathList[path->unk1]; + } + this->unk_163 = path->count; + this->unk_164 = Lib_SegmentedToVirtual(path->points); + Math_Vec3s_ToVec3f(&this->dyna.actor.world.pos, this->unk_164); + this->dyna.actor.speedXZ = actionIndex->urot.z * (45.0f / 0x2000); + this->unk_164++; + this->unk_15C = 1; + } + this->unk_15F = actionIndex->action; + } else { + if (actionIndex->action != 1) { + Vec3f vec; + f32 step; + + Math_Vec3s_ToVec3f(&vec, this->unk_164); + step = Math_Vec3f_StepTo(&this->dyna.actor.world.pos, &vec, this->dyna.actor.speedXZ); + if ((this->unk_15C < this->unk_163) && (step < this->dyna.actor.speedXZ)) { + this->unk_164++; + this->unk_15C++; + } + } + 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, PlayState* play) { + ObjBoat* this = THIS; + + Gfx_DrawDListOpa(play, 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..a3ed2b147 100644 --- a/src/overlays/actors/ovl_Obj_Boat/z_obj_boat.h +++ b/src/overlays/actors/ovl_Obj_Boat/z_obj_boat.h @@ -3,11 +3,21 @@ #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]; + /* 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; // size = 0x168 extern const ActorInit Obj_Boat_InitVars; diff --git a/src/overlays/actors/ovl_Obj_Bombiwa/z_obj_bombiwa.c b/src/overlays/actors/ovl_Obj_Bombiwa/z_obj_bombiwa.c index 8a09c6f01..27f3e13aa 100644 --- a/src/overlays/actors/ovl_Obj_Bombiwa/z_obj_bombiwa.c +++ b/src/overlays/actors/ovl_Obj_Bombiwa/z_obj_bombiwa.c @@ -11,18 +11,18 @@ #define THIS ((ObjBombiwa*)thisx) -void ObjBombiwa_Init(Actor* thisx, GlobalContext* globalCtx); -void ObjBombiwa_Destroy(Actor* thisx, GlobalContext* globalCtx); -void ObjBombiwa_Update(Actor* thisx, GlobalContext* globalCtx); +void ObjBombiwa_Init(Actor* thisx, PlayState* play); +void ObjBombiwa_Destroy(Actor* thisx, PlayState* play2); +void ObjBombiwa_Update(Actor* thisx, PlayState* play); s32 func_809393B0(Actor* thisx); s32 func_80939470(Actor* thisx); void func_80939EE0(ObjBombiwa* this); -void func_80939EF4(ObjBombiwa* this, GlobalContext* globalCtx); +void func_80939EF4(ObjBombiwa* this, PlayState* play); 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); +void func_8093A1F0(ObjBombiwa* this, PlayState* play); +void func_8093A418(Actor* thisx, PlayState* play); +void func_8093A608(Actor* thisx, PlayState* play); const ActorInit Obj_Bombiwa_InitVars = { ACTOR_OBJ_BOMBIWA, @@ -146,21 +146,21 @@ s32 func_80939470(Actor* thisx) { return false; } -s32 func_8093951C(ObjBombiwa* this, GlobalContext* globalCtx) { +s32 func_8093951C(ObjBombiwa* this, PlayState* play) { 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) && + if (WaterBox_GetSurfaceImpl(play, &play->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 func_80939594(ObjBombiwa* this, GlobalContext* globalCtx) { +void func_80939594(ObjBombiwa* this, PlayState* play) { s32 pad; Vec3f sp28; s32 sp24; @@ -170,47 +170,50 @@ void func_80939594(ObjBombiwa* this, GlobalContext* globalCtx) { sp28.z = this->actor.world.pos.z; this->actor.floorHeight = - BgCheck_EntityRaycastFloor5(&globalCtx->colCtx, &this->actor.floorPoly, &sp24, &this->actor, &sp28); + BgCheck_EntityRaycastFloor5(&play->colCtx, &this->actor.floorPoly, &sp24, &this->actor, &sp28); } -void ObjBombiwa_Init(Actor* thisx, GlobalContext* globalCtx) { +void ObjBombiwa_Init(Actor* thisx, PlayState* play) { s32 pad; ObjBombiwa* this = THIS; s32 sp34 = OBJBOMBIWA_GET_100(&this->actor); s32 pad2; Actor_ProcessInitChain(&this->actor, sInitChain); - Collider_InitCylinder(globalCtx, &this->collider); + Collider_InitCylinder(play, &this->collider); - if (Flags_GetSwitch(globalCtx, OBJBOMBIWA_GET_7F(&this->actor))) { + if (Flags_GetSwitch(play, OBJBOMBIWA_GET_7F(&this->actor))) { Actor_MarkForDeath(&this->actor); return; } - Collider_SetCylinder(globalCtx, &this->collider, &this->actor, D_8093A998[sp34].collider); + Collider_SetCylinder(play, &this->collider, &this->actor, D_8093A998[sp34].collider); Collider_UpdateCylinder(&this->actor, &this->collider); CollisionCheck_SetInfo(&this->actor.colChkInfo, NULL, &sColChkInfoInit); if (sp34 == OBJBOMBIWA_100_0) { if (this->actor.shape.rot.y == 0) { - this->actor.shape.rot.y = this->actor.world.rot.y = (u32)Rand_Next() >> 0x10; + this->actor.shape.rot.y = this->actor.world.rot.y = Rand_Next() >> 0x10; } - func_80939594(this, globalCtx); + func_80939594(this, play); } 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)) { + if (func_8093951C(this, play)) { this->unk_203 |= 1; } func_80939EE0(this); } -void ObjBombiwa_Destroy(Actor* thisx, GlobalContext* globalCtx) { - Collider_DestroyCylinder(globalCtx, &THIS->collider); +void ObjBombiwa_Destroy(Actor* thisx, PlayState* play2) { + PlayState* play = play2; + ObjBombiwa* this = THIS; + + Collider_DestroyCylinder(play, &this->collider); } -void func_80939794(ObjBombiwa* this, GlobalContext* globalCtx) { +void func_80939794(ObjBombiwa* this, PlayState* play) { Vec3f spB4; Vec3f spA8; s32 phi_v1; @@ -230,14 +233,14 @@ void func_80939794(ObjBombiwa* this, GlobalContext* globalCtx) { } else { phi_v1 = 0x21; } - EffectSsKakera_Spawn(globalCtx, &spB4, &spA8, &spB4, -400, phi_v1, 10, 2, 0, D_8093A9D0[i], 1, 0, 60, -1, + EffectSsKakera_Spawn(play, &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); + func_800BBFB0(play, &this->actor.world.pos, 60.0f, 8, 80, 140, 1); } -void func_80939994(GlobalContext* globalCtx, Vec3f* arg1) { +void func_80939994(PlayState* play, Vec3f* arg1) { Vec3f spAC; Vec3f spA0; s16 phi_v0; @@ -271,20 +274,20 @@ void func_80939994(GlobalContext* globalCtx, Vec3f* arg1) { phi_v0 = 32; } } - EffectSsKakera_Spawn(globalCtx, &spAC, &spA0, &spAC, -450, phi_v0, 15, 0, 0, i, 1, 0, life, -1, OBJECT_BOMBIWA, + EffectSsKakera_Spawn(play, &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); + func_800BBFB0(play, 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); + func_800BBFB0(play, &spAC, 120.0f, 3, 80, 140, 1); } -void func_80939C50(GlobalContext* globalCtx, Vec3f* arg1) { +void func_80939C50(PlayState* play, Vec3f* arg1) { Vec3f spBC; Vec3f spB0; s32 phi_v0; @@ -318,18 +321,18 @@ void func_80939C50(GlobalContext* globalCtx, Vec3f* arg1) { phi_v0 = 32; } } - EffectSsKakera_Spawn(globalCtx, &spBC, &spB0, &spBC, -450, phi_v0, 15, 0, 0, D_8093A9E0[i], 1, 0, phi_s0, -1, + EffectSsKakera_Spawn(play, &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); + func_800BBFB0(play, arg1, 60.0f, 4, 80, 140, 1); } void func_80939EE0(ObjBombiwa* this) { this->actionFunc = func_80939EF4; } -void func_80939EF4(ObjBombiwa* this, GlobalContext* globalCtx) { +void func_80939EF4(ObjBombiwa* this, PlayState* play) { s32 pad; s32 params = OBJBOMBIWA_GET_100(&this->actor); ObjBombiwaStruct2* sp28 = &D_8093A998[params]; @@ -339,17 +342,17 @@ void func_80939EF4(ObjBombiwa* this, GlobalContext* globalCtx) { } 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); + Flags_SetSwitch(play, OBJBOMBIWA_GET_7F(&this->actor)); + SoundSource_PlaySfxAtFixedWorldPos(play, &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); + func_80939794(this, play); Actor_MarkForDeath(&this->actor); } else { - func_80939994(globalCtx, &this->actor.world.pos); + func_80939994(play, &this->actor.world.pos); this->actor.flags |= ACTOR_FLAG_10; func_8093A080(this); } @@ -365,8 +368,8 @@ void func_80939EF4(ObjBombiwa* this, GlobalContext* globalCtx) { this->collider.base.colType = COLTYPE_NONE; } } - CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); - CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + CollisionCheck_SetAC(play, &play->colChkCtx, &this->collider.base); + CollisionCheck_SetOC(play, &play->colChkCtx, &this->collider.base); } } } @@ -387,7 +390,7 @@ void func_8093A080(ObjBombiwa* this) { ptr->unk_10 = i + 3.0f; ptr->unk_14.x = phi_s2; - ptr->unk_14.y = (u32)Rand_Next() >> 0x10; + ptr->unk_14.y = Rand_Next() >> 0x10; ptr->unk_14.z = 0; ptr->unk_1A = 0; } @@ -397,7 +400,7 @@ void func_8093A080(ObjBombiwa* this) { this->actionFunc = func_8093A1F0; } -void func_8093A1F0(ObjBombiwa* this, GlobalContext* globalCtx) { +void func_8093A1F0(ObjBombiwa* this, PlayState* play) { s32 pad; s32 i; Vec3f sp9C; @@ -426,11 +429,11 @@ void func_8093A1F0(ObjBombiwa* this, GlobalContext* globalCtx) { 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); + temp_f0 = BgCheck_EntityRaycastFloor5(&play->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); + func_80939C50(play, &ptr->unk_04); } } @@ -440,91 +443,88 @@ void func_8093A1F0(ObjBombiwa* this, GlobalContext* globalCtx) { } } -void ObjBombiwa_Update(Actor* thisx, GlobalContext* globalCtx) { +void ObjBombiwa_Update(Actor* thisx, PlayState* play) { ObjBombiwa* this = THIS; - this->actionFunc(this, globalCtx); + this->actionFunc(this, play); } -void func_8093A418(Actor* thisx, GlobalContext* globalCtx) { +void func_8093A418(Actor* thisx, PlayState* play) { 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); + Gfx_DrawDListOpa(play, object_bombiwa_DL_0009E0); return; } if (this->actor.projectedPos.z < 2300.0f) { - OPEN_DISPS(globalCtx->state.gfxCtx); + OPEN_DISPS(play->state.gfxCtx); sp28 = (2300.0f - this->actor.projectedPos.z) * 2.55f; this->actor.shape.shadowAlpha = sp28 * (32.0f / 51); - func_8012C2DC(globalCtx->state.gfxCtx); + func_8012C2DC(play->state.gfxCtx); - gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 255, 255, 255, (s32)sp28); gSPDisplayList(POLY_XLU_DISP++, object_bombiwa_DL_000AF0); - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->state.gfxCtx); } else { this->actor.shape.shadowAlpha = 0; } } -void func_8093A608(Actor* thisx, GlobalContext* globalCtx) { +void func_8093A608(Actor* thisx, PlayState* play) { s32 pad[8]; ObjBombiwa* this = THIS; f32 sp38; s32 i; ObjBombiwaStruct* ptr; - OPEN_DISPS(globalCtx->state.gfxCtx); + OPEN_DISPS(play->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); + func_8012C28C(play->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); + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(play->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); + func_8012C2DC(play->state.gfxCtx); - gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), - G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); 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); + func_8012C2DC(play->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); + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(play->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); + func_8012C28C(play->state.gfxCtx); for (i = 0; i < ARRAY_COUNT(this->unk_190); i++) { ptr = &this->unk_190[i]; if (ptr->unk_1A == 0) { - Matrix_SetStateRotationAndTranslation(ptr->unk_04.x, ptr->unk_04.y, ptr->unk_04.z, &ptr->unk_14); + Matrix_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), + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_OPA_DISP++, object_bombiwa_DL_005990); } } } - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->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 54d4024e9..50e0bbf92 100644 --- a/src/overlays/actors/ovl_Obj_Bombiwa/z_obj_bombiwa.h +++ b/src/overlays/actors/ovl_Obj_Bombiwa/z_obj_bombiwa.h @@ -5,7 +5,7 @@ struct ObjBombiwa; -typedef void (*ObjBombiwaActionFunc)(struct ObjBombiwa*, GlobalContext*); +typedef void (*ObjBombiwaActionFunc)(struct ObjBombiwa*, PlayState*); #define OBJBOMBIWA_GET_7F(thisx) ((thisx)->params & 0x7F) #define OBJBOMBIWA_GET_100(thisx) (((thisx)->params >> 8) & 1) @@ -22,14 +22,14 @@ typedef struct { } ObjBombiwaStruct; // size = 0x1C typedef struct ObjBombiwa { - /* 0x0000 */ Actor actor; - /* 0x0144 */ ColliderCylinder collider; - /* 0x0190 */ ObjBombiwaStruct unk_190[4]; - /* 0x0200 */ s8 unk_200; - /* 0x0201 */ s8 unk_201; - /* 0x0202 */ s8 unk_202; - /* 0x0203 */ u8 unk_203; - /* 0x0204 */ ObjBombiwaActionFunc actionFunc; + /* 0x000 */ Actor actor; + /* 0x144 */ ColliderCylinder collider; + /* 0x190 */ ObjBombiwaStruct unk_190[4]; + /* 0x200 */ s8 unk_200; + /* 0x201 */ s8 unk_201; + /* 0x202 */ s8 unk_202; + /* 0x203 */ u8 unk_203; + /* 0x204 */ ObjBombiwaActionFunc actionFunc; } ObjBombiwa; // size = 0x208 extern const ActorInit Obj_Bombiwa_InitVars; diff --git a/src/overlays/actors/ovl_Obj_Boyo/z_obj_boyo.c b/src/overlays/actors/ovl_Obj_Boyo/z_obj_boyo.c index b8da1a9f6..79da4f332 100644 --- a/src/overlays/actors/ovl_Obj_Boyo/z_obj_boyo.c +++ b/src/overlays/actors/ovl_Obj_Boyo/z_obj_boyo.c @@ -13,10 +13,10 @@ #define THIS ((ObjBoyo*)thisx) -void ObjBoyo_Init(Actor* thisx, GlobalContext* globalCtx); -void ObjBoyo_Destroy(Actor* thisx, GlobalContext* globalCtx2); -void ObjBoyo_Update(Actor* thisx, GlobalContext* globalCtx2); -void ObjBoyo_Draw(Actor* thisx, GlobalContext* globalCtx); +void ObjBoyo_Init(Actor* thisx, PlayState* play); +void ObjBoyo_Destroy(Actor* thisx, PlayState* play2); +void ObjBoyo_Update(Actor* thisx, PlayState* play2); +void ObjBoyo_Draw(Actor* thisx, PlayState* play); const ActorInit Obj_Boyo_InitVars = { ACTOR_OBJ_BOYO, @@ -57,22 +57,22 @@ static InitChainEntry sInitChain[] = { ICHAIN_VEC3F_DIV1000(scale, 100, ICHAIN_STOP), }; -void ObjBoyo_Init(Actor* thisx, GlobalContext* globalCtx) { +void ObjBoyo_Init(Actor* thisx, PlayState* play) { ObjBoyo* this = THIS; Actor_ProcessInitChain(&this->actor, sInitChain); - Collider_InitCylinder(globalCtx, &this->collider); - Collider_SetCylinder(globalCtx, &this->collider, &this->actor, &sCylinderInit); + Collider_InitCylinder(play, &this->collider); + Collider_SetCylinder(play, &this->collider, &this->actor, &sCylinderInit); Collider_UpdateCylinder(&this->actor, &this->collider); this->actor.colChkInfo.mass = MASS_IMMOVABLE; this->unk_190 = Lib_SegmentedToVirtual(object_boyo_Matanimheader_000E88); } -void ObjBoyo_Destroy(Actor* thisx, GlobalContext* globalCtx2) { - GlobalContext* globalCtx = globalCtx2; +void ObjBoyo_Destroy(Actor* thisx, PlayState* play2) { + PlayState* play = play2; ObjBoyo* this = THIS; - Collider_DestroyCylinder(globalCtx, &this->collider); + Collider_DestroyCylinder(play, &this->collider); } void ObjBoyo_UpdatePlayerBumpValues(ObjBoyo* this, Player* target) { @@ -95,14 +95,14 @@ BumperCollideInfo sBumperCollideInfo[] = { { ACTOR_EN_BOM, (BumperCollideActorFunc)ObjBoyo_UpdateBombBumpValues }, }; -Actor* ObjBoyo_GetCollidedActor(ObjBoyo* this, GlobalContext* globalCtx, s32* num) { +Actor* ObjBoyo_GetCollidedActor(ObjBoyo* this, PlayState* play, s32* num) { Actor* collideActor; BumperCollideInfo* collideInfo; s32 i; if (this->collider.base.ocFlags2 & OC2_HIT_PLAYER) { *num = 0; - return &GET_PLAYER(globalCtx)->actor; + return &GET_PLAYER(play)->actor; } if (this->collider.base.ocFlags1 & OC2_UNK1) { @@ -118,13 +118,13 @@ Actor* ObjBoyo_GetCollidedActor(ObjBoyo* this, GlobalContext* globalCtx, s32* nu return NULL; } -void ObjBoyo_Update(Actor* thisx, GlobalContext* globalCtx2) { - GlobalContext* globalCtx = globalCtx2; +void ObjBoyo_Update(Actor* thisx, PlayState* play2) { + PlayState* play = play2; ObjBoyo* this = THIS; Actor* target; s32 num; - target = ObjBoyo_GetCollidedActor(this, globalCtx, &num); + target = ObjBoyo_GetCollidedActor(this, play, &num); if (target != NULL) { sBumperCollideInfo[num].actorCollideFunc(this, (void*)target); @@ -169,16 +169,16 @@ void ObjBoyo_Update(Actor* thisx, GlobalContext* globalCtx2) { this->collider.base.ocFlags1 &= ~OC1_HIT; this->collider.base.ocFlags2 &= ~OC2_HIT_PLAYER; - CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + CollisionCheck_SetOC(play, &play->colChkCtx, &this->collider.base); if (thisx->xzDistToPlayer < 2000.0f) { - CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + CollisionCheck_SetAC(play, &play->colChkCtx, &this->collider.base); } } -void ObjBoyo_Draw(Actor* thisx, GlobalContext* globalCtx) { +void ObjBoyo_Draw(Actor* thisx, PlayState* play) { ObjBoyo* this = THIS; - AnimatedMat_Draw(globalCtx, this->unk_190); - Gfx_DrawDListOpa(globalCtx, object_boyo_DL_000300); + AnimatedMat_Draw(play, this->unk_190); + Gfx_DrawDListOpa(play, object_boyo_DL_000300); } diff --git a/src/overlays/actors/ovl_Obj_Boyo/z_obj_boyo.h b/src/overlays/actors/ovl_Obj_Boyo/z_obj_boyo.h index e3104d723..69e188530 100644 --- a/src/overlays/actors/ovl_Obj_Boyo/z_obj_boyo.h +++ b/src/overlays/actors/ovl_Obj_Boyo/z_obj_boyo.h @@ -10,7 +10,7 @@ typedef void (*BumperCollideActorFunc)(struct ObjBoyo*, void*); typedef struct { /* 0x0 */ s16 id; /* 0x4 */ BumperCollideActorFunc actorCollideFunc; -} BumperCollideInfo; +} BumperCollideInfo; // size = 0x8 typedef struct ObjBoyo { /* 0x000 */ Actor actor; diff --git a/src/overlays/actors/ovl_Obj_Chan/z_obj_chan.c b/src/overlays/actors/ovl_Obj_Chan/z_obj_chan.c index 8a822bea4..8e555a19f 100644 --- a/src/overlays/actors/ovl_Obj_Chan/z_obj_chan.c +++ b/src/overlays/actors/ovl_Obj_Chan/z_obj_chan.c @@ -20,13 +20,13 @@ #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 ObjChan_Init(Actor* thisx, PlayState* play); +void ObjChan_Destroy(Actor* thisx, PlayState* play); +void ObjChan_Update(Actor* thisx, PlayState* play); +void ObjChan_Draw(Actor* thisx, PlayState* play); -void ObjChan_ChandelierAction(ObjChan* this, GlobalContext* globalCtx); -void ObjChan_PotAction(ObjChan* this, GlobalContext* globalCtx); +void ObjChan_ChandelierAction(ObjChan* this, PlayState* play); +void ObjChan_PotAction(ObjChan* this, PlayState* play); const ActorInit Obj_Chan_InitVars = { ACTOR_OBJ_CHAN, @@ -64,11 +64,11 @@ static InitChainEntry sInitChain[] = { ICHAIN_VEC3F_DIV1000(scale, 100, ICHAIN_STOP), }; -void ObjChan_InitChandelier(ObjChan* this2, GlobalContext* globalCtx); -void ObjChan_InitPot(ObjChan* this, GlobalContext* globalCtx); -void ObjChan_CreateSmashParticles(ObjChan* this, GlobalContext* globalCtx); -void ObjChan_DrawPot(Actor* thisx, GlobalContext* globalCtx); -void ObjChan_DrawFire(ObjChan* this, GlobalContext* globalCtx); +void ObjChan_InitChandelier(ObjChan* this2, PlayState* play); +void ObjChan_InitPot(ObjChan* this, PlayState* play); +void ObjChan_CreateSmashEffects(ObjChan* this, PlayState* play); +void ObjChan_DrawPot(Actor* thisx, PlayState* play); +void ObjChan_DrawFire(ObjChan* this, PlayState* play); static Vec3f sObjChanFlameSize[2] = { { 0.16f, 0.11f, 1.0f }, @@ -77,7 +77,7 @@ static Vec3f sObjChanFlameSize[2] = { static f32 sObjChanFlameYOffset[2] = { 1800, 1800 }; static s32 sObjChanLoaded; -void ObjChan_Init(Actor* thisx, GlobalContext* globalCtx) { +void ObjChan_Init(Actor* thisx, PlayState* play) { s32 pad; ObjChan* this = THIS; @@ -90,26 +90,26 @@ void ObjChan_Init(Actor* thisx, GlobalContext* globalCtx) { sObjChanLoaded = true; } Actor_ProcessInitChain(&this->actor, sInitChain); - Collider_InitCylinder(globalCtx, &this->collider); - Collider_SetCylinder(globalCtx, &this->collider, &this->actor, &sObjChanCylinderInit); + Collider_InitCylinder(play, &this->collider); + Collider_SetCylinder(play, &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); + ObjChan_InitChandelier(this, play); break; case OBJCHAN_SUBTYPE_POT: this->actor.draw = ObjChan_DrawPot; - ObjChan_InitPot(this, globalCtx); + ObjChan_InitPot(this, play); break; } } -void ObjChan_Destroy(Actor* thisx, GlobalContext* globalCtx) { +void ObjChan_Destroy(Actor* thisx, PlayState* play) { ObjChan* this = THIS; - Collider_DestroyCylinder(globalCtx, &this->collider); + Collider_DestroyCylinder(play, &this->collider); } u32 func_80BB9A1C(ObjChan* this, f32 arg1) { @@ -137,11 +137,11 @@ void ObjChan_CalculatePotPosition(Vec3f* childPosOut, Vec3s* childRotOut, Vec3f* s16 childAngle) { Vec3f offset; - Matrix_RotateY(parentRot->y, MTXMODE_NEW); - Matrix_InsertXRotation_s(parentRot->x, MTXMODE_APPLY); - Matrix_InsertZRotation_s(parentRot->z, MTXMODE_APPLY); - Matrix_RotateY(childAngle, MTXMODE_APPLY); - Matrix_GetStateTranslationAndScaledX(-280.0f, &offset); + 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); childPosOut->x = parentPos->x + offset.x; childPosOut->y = parentPos->y + offset.y; @@ -151,7 +151,7 @@ void ObjChan_CalculatePotPosition(Vec3f* childPosOut, Vec3s* childRotOut, Vec3f* } //! @TODO: Possibly takes actor and recasts -void ObjChan_InitChandelier(ObjChan* this2, GlobalContext* globalCtx) { +void ObjChan_InitChandelier(ObjChan* this2, PlayState* play) { ObjChan* this = this2; s32 i; ObjChan* temp_v0; @@ -165,8 +165,8 @@ void ObjChan_InitChandelier(ObjChan* this2, GlobalContext* globalCtx) { 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)) { + if (BgCheck_EntityLineTest1(&play->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); @@ -177,7 +177,7 @@ void ObjChan_InitChandelier(ObjChan* this2, GlobalContext* globalCtx) { 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, + &play->actorCtx, play, ACTOR_OBJ_CHAN, childPos.x, childPos.y, childPos.z, childRot.x, childRot.y, childRot.z, (this->actor.params & 0xFFF) | 0x1000, this->actor.cutscene, this->actor.unk20, &this->actor); if (temp_v0 != NULL) { this->pots[i] = temp_v0; @@ -188,7 +188,7 @@ void ObjChan_InitChandelier(ObjChan* this2, GlobalContext* globalCtx) { } } - if (Flags_GetSwitch(globalCtx, this->actor.params & 0x7F)) { + if (Flags_GetSwitch(play, this->actor.params & 0x7F)) { this->stateFlags |= OBJCHAN_STATE_FIRE_DELAY; this->stateFlags |= OBJCHAN_STATE_ON_FIRE; @@ -210,7 +210,7 @@ void ObjChan_InitChandelier(ObjChan* this2, GlobalContext* globalCtx) { } //! @TODO: More descriptive name than Action? -void ObjChan_ChandelierAction(ObjChan* this2, GlobalContext* globalCtx) { +void ObjChan_ChandelierAction(ObjChan* this2, PlayState* play) { ObjChan* this = this2; ObjChan* temp; s32 i; @@ -231,7 +231,7 @@ void ObjChan_ChandelierAction(ObjChan* this2, GlobalContext* globalCtx) { } 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)) { + SubS_StartActorCutscene(&this->actor, this->cutscenes[0], -1, SUBS_CUTSCENE_SET_UNK_LINK_FIELDS)) { this->stateFlags |= OBJCHAN_STATE_CUTSCENE; this->stateFlags &= ~OBJCHAN_STATE_START_CUTSCENE; } @@ -239,11 +239,11 @@ void ObjChan_ChandelierAction(ObjChan* this2, GlobalContext* globalCtx) { this->stateFlags &= ~OBJCHAN_STATE_CUTSCENE; ActorCutscene_Stop(this->cutscenes[0]); } - Matrix_RotateY(this->actor.shape.rot.y, MTXMODE_NEW); - Matrix_InsertXRotation_s(this->actor.shape.rot.x, MTXMODE_APPLY); - Matrix_InsertZRotation_s(this->actor.shape.rot.z, MTXMODE_APPLY); - Matrix_RotateY(this->rotation, MTXMODE_APPLY); - Matrix_GetStateTranslationAndScaledY(this->unk1CC, &this->actor.world.pos); + 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++) { @@ -258,9 +258,9 @@ void ObjChan_ChandelierAction(ObjChan* this2, GlobalContext* globalCtx) { } } if ((this->collider.base.acFlags & AC_HIT) && (this->collider.info.acHitInfo->toucher.dmgFlags & 0x800)) { - Flags_SetSwitch(globalCtx, this->actor.params & 0x7F); + Flags_SetSwitch(play, this->actor.params & 0x7F); } - if (Flags_GetSwitch(globalCtx, this->actor.params & 0x7F)) { + if (Flags_GetSwitch(play, this->actor.params & 0x7F)) { if (!(this->stateFlags & OBJCHAN_STATE_FIRE_DELAY)) { this->rotationSpeed = 0; this->flameSize = 0.0f; @@ -284,13 +284,12 @@ void ObjChan_ChandelierAction(ObjChan* this2, GlobalContext* globalCtx) { } } -void ObjChan_InitPot(ObjChan* this, GlobalContext* globalCtx) { +void ObjChan_InitPot(ObjChan* this, PlayState* play) { this->actionFunc = ObjChan_PotAction; } -void ObjChan_PotAction(ObjChan* this, GlobalContext* globalCtx) { +void ObjChan_PotAction(ObjChan* this, PlayState* play) { s32 potBreaks; - s16 temp_v0_2; s32 phi_v1; potBreaks = false; @@ -306,15 +305,14 @@ void ObjChan_PotAction(ObjChan* this, GlobalContext* globalCtx) { } } if (potBreaks) { - ObjChan_CreateSmashParticles(this, globalCtx); + ObjChan_CreateSmashEffects(this, play); ((ObjChan*)this->actor.parent)->pots[this->myPotIndex] = NULL; - SoundSource_PlaySfxAtFixedWorldPos(globalCtx, &this->actor.world.pos, 20, NA_SE_EV_CHANDELIER_BROKEN); + SoundSource_PlaySfxAtFixedWorldPos(play, &this->actor.world.pos, 20, NA_SE_EV_CHANDELIER_BROKEN); func_80BB9A1C((ObjChan*)this->actor.parent, 40.0f); if (this->myPotIndex == 4) { - temp_v0_2 = gSaveContext.save.weekEventReg[0x25]; - if (!(temp_v0_2 & 0x10)) { - gSaveContext.save.weekEventReg[0x25] = temp_v0_2 | 0x10; - Actor_SpawnAsChildAndCutscene(&globalCtx->actorCtx, globalCtx, ACTOR_EN_MM, this->actor.world.pos.x, + if (!(((void)0, gSaveContext.save.weekEventReg[0x25]) & 0x10)) { + gSaveContext.save.weekEventReg[0x25] = ((void)0, gSaveContext.save.weekEventReg[0x25]) | 0x10; + Actor_SpawnAsChildAndCutscene(&play->actorCtx, play, ACTOR_EN_MM, this->actor.world.pos.x, this->actor.world.pos.y, this->actor.world.pos.z, 0, 0, 0, 0x8000, this->actor.cutscene, this->actor.unk20, NULL); } @@ -323,7 +321,7 @@ void ObjChan_PotAction(ObjChan* this, GlobalContext* globalCtx) { } } -void ObjChan_CreateSmashParticles(ObjChan* this, GlobalContext* globalCtx) { +void ObjChan_CreateSmashEffects(ObjChan* this, PlayState* play) { s16 new_var = 0; s32 phi_s0; Vec3f spDC; @@ -354,85 +352,85 @@ void ObjChan_CreateSmashParticles(ObjChan* this, GlobalContext* globalCtx) { 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); + EffectSsKakera_Spawn(play, &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); + func_800BBFB0(play, &this->actor.world.pos, 30.0f, 2, 20, 50, true); + func_800BBFB0(play, &this->actor.world.pos, 30.0f, 2, 10, 80, true); } -void ObjChan_Update(Actor* thisx, GlobalContext* globalCtx) { +void ObjChan_Update(Actor* thisx, PlayState* play) { ObjChan* this = THIS; - this->actionFunc(this, globalCtx); - CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + this->actionFunc(this, play); + CollisionCheck_SetAC(play, &play->colChkCtx, &this->collider.base); } -void ObjChan_Draw(Actor* thisx, GlobalContext* globalCtx) { +void ObjChan_Draw(Actor* thisx, PlayState* play) { s32 pad; ObjChan* this = THIS; Gfx* opa; Gfx* xlu; - OPEN_DISPS(globalCtx->state.gfxCtx); - Matrix_RotateY(this->rotation, MTXMODE_APPLY); + OPEN_DISPS(play->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); + gSPMatrix(&opa[0], Matrix_NewMtx(play->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); + gSPMatrix(&xlu[0], Matrix_NewMtx(play->state.gfxCtx), G_MTX_LOAD); gSPDisplayList(&xlu[1], object_obj_chan_DL_000A10); POLY_XLU_DISP = &xlu[2]; - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->state.gfxCtx); - Matrix_StatePush(); + Matrix_Push(); if (this->stateFlags & OBJCHAN_STATE_ON_FIRE) { - ObjChan_DrawFire(this, globalCtx); + ObjChan_DrawFire(this, play); } - Matrix_StatePop(); + Matrix_Pop(); } -void ObjChan_DrawPot(Actor* thisx, GlobalContext* globalCtx) { +void ObjChan_DrawPot(Actor* thisx, PlayState* play) { ObjChan* this = THIS; s32 pad; Gfx* dl; - OPEN_DISPS(globalCtx->state.gfxCtx); + OPEN_DISPS(play->state.gfxCtx); dl = Gfx_CallSetupDL(POLY_OPA_DISP, 0x19); - gSPMatrix(&dl[0], Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_LOAD); + gSPMatrix(&dl[0], Matrix_NewMtx(play->state.gfxCtx), G_MTX_LOAD); gSPDisplayList(&dl[1], object_obj_chan_DL_002358); POLY_OPA_DISP = &dl[2]; - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->state.gfxCtx); if (this->stateFlags & OBJCHAN_STATE_ON_FIRE) { - ObjChan_DrawFire(this, globalCtx); + ObjChan_DrawFire(this, play); } } -void ObjChan_DrawFire(ObjChan* this, GlobalContext* globalCtx) { +void ObjChan_DrawFire(ObjChan* this, PlayState* play) { u32 sp4C; Gfx* dl; - OPEN_DISPS(globalCtx->state.gfxCtx); + OPEN_DISPS(play->state.gfxCtx); - sp4C = globalCtx->gameplayFrames; + sp4C = play->gameplayFrames; - Matrix_RotateY(Camera_GetCamDirYaw(GET_ACTIVE_CAM(globalCtx)) - this->actor.shape.rot.y - this->rotation + 0x8000, - MTXMODE_APPLY); + Matrix_RotateYS(Camera_GetCamDirYaw(GET_ACTIVE_CAM(play)) - this->actor.shape.rot.y - this->rotation + 0x8000, + MTXMODE_APPLY); Matrix_Scale(sObjChanFlameSize[OBJCHAN_SUBTYPE(&this->actor)].x * this->flameSize, sObjChanFlameSize[OBJCHAN_SUBTYPE(&this->actor)].y * this->flameSize, 1.0f, MTXMODE_APPLY); - Matrix_InsertTranslation(0.0f, sObjChanFlameYOffset[OBJCHAN_SUBTYPE(&this->actor)], 0.0f, MTXMODE_APPLY); + 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)); + gSPMatrix(&dl[0], Matrix_NewMtx(play->state.gfxCtx), G_MTX_LOAD); + gSPSegment(&dl[1], 0x08, Gfx_TwoTexScroll(play->state.gfxCtx, 0, 0, 0, 32, 64, 1, 0, -sp4C * 20, 32, 128)); gDPSetPrimColor(&dl[2], 128, 128, 255, 255, 0, 255); gDPSetEnvColor(&dl[3], 255, 0, 0, 0); - gSPDisplayList(&dl[4], &gGameplayKeepDrawFlameDL); + gSPDisplayList(&dl[4], gEffFire1DL); POLY_XLU_DISP = &dl[5]; - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->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 2b11335b3..a3a4e6d93 100644 --- a/src/overlays/actors/ovl_Obj_Chan/z_obj_chan.h +++ b/src/overlays/actors/ovl_Obj_Chan/z_obj_chan.h @@ -36,25 +36,25 @@ struct ObjChan; -typedef void (*ObjChanActionFunc)(struct ObjChan*, GlobalContext*); +typedef void (*ObjChanActionFunc)(struct ObjChan*, PlayState*); typedef struct ObjChan { - /* 0x0000 */ Actor actor; - /* 0x0144 */ ObjChanActionFunc actionFunc; - /* 0x0148 */ ColliderCylinder collider; - /* 0x0194 */ u8 myPotIndex; // For OBJCHAN_SUBTYPE_POT: which pot is this? - /* 0x0196 */ s16 fireDelayFrames; - /* 0x0198 */ UNK_TYPE1 unk198[0x12]; - /* 0x01AA */ u8 stateFlags; - /* 0x01AC */ struct ObjChan* pots[5]; // For OBJCHAN_SUBTYPE_BODY: pointers to pot actors - /* 0x01C0 */ Vec3f unk1C0; - /* 0x01CC */ f32 unk1CC; - /* 0x01D0 */ f32 unk1D0; - /* 0x01D4 */ s16 unk1D4; - /* 0x01D8 */ f32 flameSize; - /* 0x01DC */ s16 rotationSpeed; // Main object only. Slowly ramps up under some circumstances. In other circumstances it's immediately set to maximum speed. - /* 0x01DE */ s16 rotation; // Increases as the chandelier spins. Don't know why they didn't use the actor's rotation variable. - /* 0x01E0 */ s16 cutscenes[2]; + /* 0x000 */ Actor actor; + /* 0x144 */ ObjChanActionFunc actionFunc; + /* 0x148 */ ColliderCylinder collider; + /* 0x194 */ u8 myPotIndex; // For OBJCHAN_SUBTYPE_POT: which pot is this? + /* 0x196 */ s16 fireDelayFrames; + /* 0x198 */ UNK_TYPE1 unk198[0x12]; + /* 0x1AA */ u8 stateFlags; + /* 0x1AC */ struct ObjChan* pots[5]; // For OBJCHAN_SUBTYPE_BODY: pointers to pot actors + /* 0x1C0 */ Vec3f unk1C0; + /* 0x1CC */ f32 unk1CC; + /* 0x1D0 */ f32 unk1D0; + /* 0x1D4 */ s16 unk1D4; + /* 0x1D8 */ f32 flameSize; + /* 0x1DC */ s16 rotationSpeed; // Main object only. Slowly ramps up under some circumstances. In other circumstances it's immediately set to maximum speed. + /* 0x1DE */ s16 rotation; // Increases as the chandelier spins. Don't know why they didn't use the actor's rotation variable. + /* 0x1E0 */ s16 cutscenes[2]; } ObjChan; // size = 0x1E4 extern const ActorInit Obj_Chan_InitVars; diff --git a/src/overlays/actors/ovl_Obj_Chikuwa/z_obj_chikuwa.c b/src/overlays/actors/ovl_Obj_Chikuwa/z_obj_chikuwa.c index 7de79a2be..769266e97 100644 --- a/src/overlays/actors/ovl_Obj_Chikuwa/z_obj_chikuwa.c +++ b/src/overlays/actors/ovl_Obj_Chikuwa/z_obj_chikuwa.c @@ -5,17 +5,17 @@ */ #include "z_obj_chikuwa.h" +#include "objects/object_d_lift/object_d_lift.h" #define FLAGS (ACTOR_FLAG_10) #define THIS ((ObjChikuwa*)thisx) -void ObjChikuwa_Init(Actor* thisx, GlobalContext* globalCtx); -void ObjChikuwa_Destroy(Actor* thisx, GlobalContext* globalCtx); -void ObjChikuwa_Update(Actor* thisx, GlobalContext* globalCtx); -void ObjChikuwa_Draw(Actor* thisx, GlobalContext* globalCtx); +void ObjChikuwa_Init(Actor* thisx, PlayState* play); +void ObjChikuwa_Destroy(Actor* thisx, PlayState* play); +void ObjChikuwa_Update(Actor* thisx, PlayState* play); +void ObjChikuwa_Draw(Actor* thisx, PlayState* play); -#if 0 const ActorInit Obj_Chikuwa_InitVars = { ACTOR_OBJ_CHIKUWA, ACTORCAT_BG, @@ -28,31 +28,206 @@ const ActorInit Obj_Chikuwa_InitVars = { (ActorFunc)ObjChikuwa_Draw, }; -// static InitChainEntry sInitChain[] = { -static InitChainEntry D_809B1FC0[] = { +static InitChainEntry sInitChain[] = { ICHAIN_F32(uncullZoneForward, 4000, ICHAIN_CONTINUE), ICHAIN_F32(uncullZoneScale, 1500, ICHAIN_CONTINUE), ICHAIN_F32(uncullZoneDownward, 1500, ICHAIN_CONTINUE), ICHAIN_VEC3F_DIV1000(scale, 100, ICHAIN_STOP), }; -#endif +Vec3f D_809B1FD0 = { 0.0f, -0.3f, 0.0f }; +Vec3f D_809B1FDC = { 0.0f, 0.7f, 0.0f }; -extern InitChainEntry D_809B1FC0[]; +void func_809B1550(Actor* thisx, PlayState* play) { + ObjChikuwa* this = THIS; + f32 sp18; -extern UNK_TYPE D_06000D10; -extern UNK_TYPE D_06000F00; + if (this->unk_2A0 < this->unk_29C) { + thisx->scale.z = (this->unk_29C - this->unk_2A0) * 0.05f; + sp18 = (((this->unk_29C + this->unk_2A0) * 60) - 60) * 0.5f; + thisx->world.pos.x = (Math_SinS(thisx->shape.rot.y) * sp18) + thisx->home.pos.x; + thisx->world.pos.z = (Math_CosS(thisx->shape.rot.y) * sp18) + thisx->home.pos.z; + } else { + func_800C62BC(play, &play->colCtx.dyna, this->dyna.bgId); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Chikuwa/func_809B1550.s") +void ObjChikuwa_Init(Actor* thisx, PlayState* play) { + ObjChikuwa* this = THIS; + s32 i; + s32 val; + ObjChikuwaStruct* temp; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Chikuwa/ObjChikuwa_Init.s") + Actor_ProcessInitChain(&this->dyna.actor, sInitChain); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Chikuwa/ObjChikuwa_Destroy.s") + this->dyna.actor.scale.x = 0.15f; + this->dyna.actor.scale.y = 0.2f; + this->dyna.actor.scale.z = 0.05f; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Chikuwa/func_809B17D0.s") + DynaPolyActor_Init(&this->dyna, 0); + DynaPolyActor_LoadMesh(play, &this->dyna, &gDampeGraveBrownElevatorCol); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Chikuwa/func_809B1AA0.s") + this->dyna.actor.home.rot.y += 0x2000; + this->dyna.actor.home.rot.y &= 0xC000; + this->unk_29C = 20; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Chikuwa/ObjChikuwa_Update.s") + this->dyna.actor.shape.rot.y = this->dyna.actor.home.rot.y; + this->dyna.actor.world.rot.y = this->dyna.actor.home.rot.y; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Chikuwa/ObjChikuwa_Draw.s") + for (val = 0, i = 0; i < this->unk_29C; i++, val += 7) { + temp = &this->unk_15C[i]; + + temp->unk_00.x = thisx->home.pos.x + (Math_SinS(thisx->shape.rot.y) * (i * 60)); + temp->unk_00.y = thisx->home.pos.y; + temp->unk_00.z = thisx->home.pos.z + (Math_CosS(thisx->shape.rot.y) * (i * 60)); + temp->unk_0C = val + 100; + } + + func_809B1550(thisx, play); +} + +void ObjChikuwa_Destroy(Actor* thisx, PlayState* play) { + ObjChikuwa* this = THIS; + + DynaPoly_DeleteBgActor(play, &play->colCtx.dyna, this->dyna.bgId); +} + +void func_809B17D0(PlayState* play, ObjChikuwa* this, Vec3f* arg2) { + ObjChikuwaStruct2* temp_s0; + f32 var_fs2; + f32 temp; + s32 i; + + for (i = 0, var_fs2 = -78.75f; i < 8; var_fs2 += 22.5f) { + temp_s0 = &this->unk_2A4[this->unk_9A4]; + + temp_s0->unk_00.x = (Rand_ZeroOne() * 0.05f) + 0.01f; + temp_s0->unk_00.y = (Rand_ZeroOne() * 0.16f) + 0.04f; + temp_s0->unk_00.z = (Rand_ZeroOne() * 0.05f) + 0.01f; + + temp_s0->unk_0C.x = (Math_CosS(this->dyna.actor.shape.rot.y) * var_fs2) + arg2->x; + temp_s0->unk_0C.y = arg2->y; + temp_s0->unk_0C.z = (Math_SinS(this->dyna.actor.shape.rot.y) * var_fs2) + arg2->z; + + temp_s0->unk_18 = (2.0f * Rand_ZeroOne()) - 1.0f; + temp_s0->unk_1C = (Rand_ZeroOne() * 4.0f) - 1.0f; + temp_s0->unk_20 = (2.0f * Rand_ZeroOne()) - 1.0f; + + temp = Math3D_Vec3fMagnitude(&temp_s0->unk_00); + temp_s0->unk_24 = (-Rand_ZeroOne() * 0.5f) - temp * 25.0f; + + temp_s0->unk_28.x = this->dyna.actor.shape.rot.x; + temp_s0->unk_28.y = this->dyna.actor.shape.rot.y; + temp_s0->unk_28.z = this->dyna.actor.shape.rot.z; + + temp_s0->unk_2E.x = (Rand_ZeroOne() - 0.5f) * 5000.0f; + temp_s0->unk_2E.y = (Rand_ZeroOne() - 0.5f) * 5000.0f; + temp_s0->unk_2E.z = (Rand_ZeroOne() - 0.5f) * 5000.0f; + + temp_s0->unk_34 = 80; + func_800B1210(play, &temp_s0->unk_0C, &D_809B1FDC, &D_809B1FD0, (Rand_ZeroOne() * 60.0f) + 80.0f, + (Rand_ZeroOne() * 30.0f) + 60.0f); + this->unk_9A4 = (this->unk_9A4 + 1) & 0x1F; + i++; + } +} + +void func_809B1AA0(ObjChikuwa* this) { + ObjChikuwaStruct2* temp_v0; + s32 i; + + this->unk_9A6 = 0; + + for (i = 0; i < ARRAY_COUNT(this->unk_2A4); i++) { + temp_v0 = &this->unk_2A4[i]; + if (temp_v0->unk_34 > 0) { + temp_v0->unk_34--; + this->unk_9A6 = 1; + temp_v0->unk_1C += temp_v0->unk_24; + temp_v0->unk_0C.x += temp_v0->unk_18; + temp_v0->unk_0C.y += temp_v0->unk_1C; + temp_v0->unk_0C.z += temp_v0->unk_20; + temp_v0->unk_28.x += temp_v0->unk_2E.x; + temp_v0->unk_28.y += temp_v0->unk_2E.y; + temp_v0->unk_28.z += temp_v0->unk_2E.z; + } + } +} + +void ObjChikuwa_Update(Actor* thisx, PlayState* play) { + ObjChikuwa* this = THIS; + ObjChikuwaStruct* temp; + f32 temp_fs0; + s16 var_s2; + s32 i; + s32 quake; + + this->unk_29E++; + + for (i = 0; i < this->unk_29C; i++) { + temp = &this->unk_15C[i]; + if ((this->unk_29E >= temp->unk_0C) && !(temp->unk_0E & 1)) { + temp->unk_0E |= 1; + this->unk_2A0++; + func_809B1550(&this->dyna.actor, play); + func_809B17D0(play, this, &temp->unk_00); + temp_fs0 = Math3D_Vec3fDistSq(&temp->unk_00, &GET_PLAYER(play)->actor.world.pos); + if (temp_fs0 < SQ(240.0f)) { + quake = Quake_Add(GET_ACTIVE_CAM(play), 3); + if (temp_fs0 < SQ(120.0f)) { + var_s2 = 4; + } else { + var_s2 = 3; + } + + Quake_SetSpeed(quake, 0x4350); + Quake_SetQuakeValues(quake, var_s2, 0, 0, 0); + Quake_SetCountdown(quake, 7); + } + } + } + + func_809B1AA0(this); +} + +void ObjChikuwa_Draw(Actor* thisx, PlayState* play) { + ObjChikuwa* this = THIS; + ObjChikuwaStruct* temp; + ObjChikuwaStruct2* temp2; + s32 i; + + OPEN_DISPS(play->state.gfxCtx); + + func_8012C28C(play->state.gfxCtx); + + if (this->unk_2A0 < this->unk_29C) { + for (i = 0; i < this->unk_29C; i++) { + temp = &this->unk_15C[i]; + if (!(temp->unk_0E & 1)) { + Matrix_SetTranslateRotateYXZ(temp->unk_00.x, temp->unk_00.y, temp->unk_00.z, + &this->dyna.actor.shape.rot); + Matrix_Scale(0.15f, 0.2f, 0.05f, MTXMODE_APPLY); + + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(play->state.gfxCtx), + G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_OPA_DISP++, gDampeGraveBrownElevatorDL); + } + } + } + + if (this->unk_9A6 != 0) { + for (i = 0; i < ARRAY_COUNT(this->unk_2A4); i++) { + temp2 = &this->unk_2A4[i]; + if (temp2->unk_34 > 0) { + Matrix_SetTranslateRotateYXZ(temp2->unk_0C.x, temp2->unk_0C.y, temp2->unk_0C.z, &temp2->unk_28); + Matrix_Scale(temp2->unk_00.x, temp2->unk_00.y, temp2->unk_00.z, MTXMODE_APPLY); + + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(play->state.gfxCtx), + G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_OPA_DISP++, gDampeGraveBrownElevatorDL); + } + } + } + + CLOSE_DISPS(play->state.gfxCtx); +} diff --git a/src/overlays/actors/ovl_Obj_Chikuwa/z_obj_chikuwa.h b/src/overlays/actors/ovl_Obj_Chikuwa/z_obj_chikuwa.h index 1e869a220..7ebba3021 100644 --- a/src/overlays/actors/ovl_Obj_Chikuwa/z_obj_chikuwa.h +++ b/src/overlays/actors/ovl_Obj_Chikuwa/z_obj_chikuwa.h @@ -5,9 +5,33 @@ struct ObjChikuwa; +typedef struct { + /* 0x00 */ Vec3f unk_00; + /* 0x0C */ s16 unk_0C; + /* 0x0E */ u8 unk_0E; +} ObjChikuwaStruct; // size = 0x10 + +typedef struct { + /* 0x00 */ Vec3f unk_00; + /* 0x0C */ Vec3f unk_0C; + /* 0x18 */ f32 unk_18; + /* 0x1C */ f32 unk_1C; + /* 0x20 */ f32 unk_20; + /* 0x24 */ f32 unk_24; + /* 0x28 */ Vec3s unk_28; + /* 0x2E */ Vec3s unk_2E; + /* 0x34 */ s16 unk_34; +} ObjChikuwaStruct2; // size = 0x38 + typedef struct ObjChikuwa { - /* 0x000 */ Actor actor; - /* 0x144 */ char unk_144[0x864]; + /* 0x000 */ DynaPolyActor dyna; + /* 0x15C */ ObjChikuwaStruct unk_15C[20]; + /* 0x29C */ s16 unk_29C; + /* 0x29E */ s16 unk_29E; + /* 0x2A0 */ s16 unk_2A0; + /* 0x2A4 */ ObjChikuwaStruct2 unk_2A4[32]; + /* 0x9A4 */ s16 unk_9A4; + /* 0x9A6 */ u8 unk_9A6; } ObjChikuwa; // size = 0x9A8 extern const ActorInit Obj_Chikuwa_InitVars; diff --git a/src/overlays/actors/ovl_Obj_Comb/z_obj_comb.c b/src/overlays/actors/ovl_Obj_Comb/z_obj_comb.c index 573b34fdc..2ce8f6ef3 100644 --- a/src/overlays/actors/ovl_Obj_Comb/z_obj_comb.c +++ b/src/overlays/actors/ovl_Obj_Comb/z_obj_comb.c @@ -11,16 +11,16 @@ #define THIS ((ObjComb*)thisx) -void ObjComb_Init(Actor* thisx, GlobalContext* globalCtx); -void ObjComb_Destroy(Actor* thisx, GlobalContext* globalCtx); -void ObjComb_Update(Actor* thisx, GlobalContext* globalCtx); -void ObjComb_Draw(Actor* thisx, GlobalContext* globalCtx); +void ObjComb_Init(Actor* thisx, PlayState* play); +void ObjComb_Destroy(Actor* thisx, PlayState* play2); +void ObjComb_Update(Actor* thisx, PlayState* play); +void ObjComb_Draw(Actor* thisx, PlayState* play); void func_8098DC44(ObjComb* this); -void func_8098DC60(ObjComb* this, GlobalContext* globalCtx); -void func_8098DEA0(ObjComb* this, GlobalContext* globalCtx); +void func_8098DC60(ObjComb* this, PlayState* play); +void func_8098DEA0(ObjComb* this, PlayState* play); void func_8098E098(ObjComb* this); -void func_8098E0B8(ObjComb* this, GlobalContext* globalCtx); +void func_8098E0B8(ObjComb* this, PlayState* play); const ActorInit Obj_Comb_InitVars = { ACTOR_OBJ_COMB, @@ -57,7 +57,7 @@ static ColliderJntSphInit sJntSphInit = { OC2_TYPE_2, COLSHAPE_JNTSPH, }, - 1, + ARRAY_COUNT(sJntSphElementsInit), sJntSphElementsInit, }; @@ -68,7 +68,7 @@ static InitChainEntry sInitChain[] = { ICHAIN_F32(uncullZoneDownward, 100, ICHAIN_STOP), }; -s32 func_8098CE40(ObjComb* this, GlobalContext* globalCtx) { +s32 func_8098CE40(ObjComb* this, PlayState* play) { s32 phi_a2 = -1; s32 temp_v0 = (OBJCOMB_GET_1F(&this->actor) << 2) | 0xFF01; @@ -76,10 +76,10 @@ s32 func_8098CE40(ObjComb* this, GlobalContext* globalCtx) { phi_a2 = ((temp_v0 & 0x3FC) >> 2) & 0xFF; } - return ((phi_a2 < 0) == 1) || !Flags_GetTreasure(globalCtx, phi_a2); + return ((phi_a2 < 0) == 1) || !Flags_GetTreasure(play, phi_a2); } -void func_8098CEAC(ObjComb* this, GlobalContext* globalCtx) { +void func_8098CEAC(ObjComb* this, PlayState* play) { Vec3f spDC; Vec3f spD0; Vec3f spC4; @@ -126,7 +126,7 @@ void func_8098CEAC(ObjComb* this, GlobalContext* globalCtx) { } else { phi_v0 = 0x20; } - EffectSsKakera_Spawn(globalCtx, &spD0, &spC4, &spD0, phi_s0, phi_v0, phi_s1, 4, 0, temp_f10, 0, 0, 60, -1, + EffectSsKakera_Spawn(play, &spD0, &spC4, &spD0, phi_s0, phi_v0, phi_s1, 4, 0, temp_f10, 0, 0, 60, -1, OBJECT_COMB, object_comb_DL_001040); } @@ -134,10 +134,10 @@ void func_8098CEAC(ObjComb* this, GlobalContext* globalCtx) { spD0.y = this->actor.world.pos.y - 10.0f; spD0.z = this->actor.world.pos.z; - func_800BBFB0(globalCtx, &spD0, 40.0f, 6, 70, 60, 1); + func_800BBFB0(play, &spD0, 40.0f, 6, 70, 60, 1); } -void func_8098D19C(ObjComb* this, GlobalContext* globalCtx) { +void func_8098D19C(ObjComb* this, PlayState* play) { Vec3f spDC; Vec3f spD0; Vec3f spC4; @@ -184,7 +184,7 @@ void func_8098D19C(ObjComb* this, GlobalContext* globalCtx) { phi_v0 = 0x20; } - EffectSsKakera_Spawn(globalCtx, &spD0, &spC4, &spD0, phi_s0, phi_v0, phi_s1, 4, 0, temp_f8, 0, 0, 60, -1, + EffectSsKakera_Spawn(play, &spD0, &spC4, &spD0, phi_s0, phi_v0, phi_s1, 4, 0, temp_f8, 0, 0, 60, -1, OBJECT_COMB, object_comb_DL_001040); } @@ -192,10 +192,10 @@ void func_8098D19C(ObjComb* this, GlobalContext* globalCtx) { 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); + func_800BBFB0(play, &spD0, 40.0f, 6, 70, 60, 1); } -void func_8098D47C(ObjComb* this, GlobalContext* globalCtx) { +void func_8098D47C(ObjComb* this, PlayState* play) { Vec3f spD4; Vec3f spC8; Vec3f spBC; @@ -235,12 +235,12 @@ void func_8098D47C(ObjComb* this, GlobalContext* globalCtx) { 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); + EffectSsKakera_Spawn(play, &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) { +void func_8098D6E0(ObjComb* this, PlayState* play) { s32 i; Vec3f sp70; f32 temp_f0; @@ -254,23 +254,23 @@ void func_8098D6E0(ObjComb* this, GlobalContext* globalCtx) { 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); + EffectSsGSplash_Spawn(play, &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); + EffectSsGSplash_Spawn(play, &sp70, NULL, NULL, 0, 300); } -void func_8098D870(ObjComb* this, GlobalContext* globalCtx) { +void func_8098D870(ObjComb* this, PlayState* play) { 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); + Item_DropCollectible(play, &this->actor.world.pos, ((OBJCOMB_GET_7F00(&this->actor)) << 8) | temp_v0); } } -void func_8098D8C8(ObjComb* this, GlobalContext* globalCtx) { +void func_8098D8C8(ObjComb* this, PlayState* play) { s32 params = OBJCOMB_GET_F(&this->actor); s32 i; s32 phi_s5; @@ -283,21 +283,21 @@ void func_8098D8C8(ObjComb* this, GlobalContext* globalCtx) { 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, + if (Actor_Spawn(&play->actorCtx, play, 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) { +void func_8098D99C(ObjComb* this, PlayState* play) { s32 params; Actor* temp_v0; - if (func_8098CE40(this, globalCtx)) { + if (func_8098CE40(this, play)) { 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); + temp_v0 = Actor_Spawn(&play->actorCtx, play, 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; @@ -314,46 +314,49 @@ void func_8098D99C(ObjComb* this, GlobalContext* globalCtx) { } } -void func_8098DA74(ObjComb* this, GlobalContext* globalCtx) { +void func_8098DA74(ObjComb* this, PlayState* play) { s32 temp_v0 = OBJCOMB_GET_8000(&this->actor) | OBJCOMB_GET_80(&this->actor); if (temp_v0 == 0) { - func_8098D870(this, globalCtx); + func_8098D870(this, play); } else if (temp_v0 == 1) { - func_8098D8C8(this, globalCtx); + func_8098D8C8(this, play); } else { - func_8098D99C(this, globalCtx); + func_8098D99C(this, play); } } -void ObjComb_Init(Actor* thisx, GlobalContext* globalCtx) { +void ObjComb_Init(Actor* thisx, PlayState* play) { 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); + Collider_InitJntSph(play, &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); + Collider_SetJntSph(play, &this->collider, &this->actor, &sJntSphInit, &this->colliderElement); - if ((sp2C == 0) && func_800A81A4(globalCtx, OBJCOMB_GET_3F(&this->actor), OBJCOMB_GET_7F00(&this->actor))) { + if ((sp2C == 0) && Item_CanDropBigFairy(play, 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)) { + if ((sp2C != 2) || !func_8098CE40(this, play)) { this->unk_1B8 = -1; } func_8098DC44(this); } -void ObjComb_Destroy(Actor* thisx, GlobalContext* globalCtx) { - Collider_DestroyJntSph(globalCtx, &THIS->collider); +void ObjComb_Destroy(Actor* thisx, PlayState* play2) { + PlayState* play = play2; + ObjComb* this = THIS; + + Collider_DestroyJntSph(play, &this->collider); } void func_8098DC44(ObjComb* this) { @@ -361,7 +364,7 @@ void func_8098DC44(ObjComb* this) { this->actionFunc = func_8098DC60; } -void func_8098DC60(ObjComb* this, GlobalContext* globalCtx) { +void func_8098DC60(ObjComb* this, PlayState* play) { s32 temp_a0; s8 temp_v0; u32 temp_v1; @@ -378,8 +381,8 @@ void func_8098DC60(ObjComb* this, GlobalContext* globalCtx) { if (this->unk_1B3) { if (this->collider.elements->info.acHitInfo->toucher.dmgFlags & 0x0182C29C) { - func_8098CEAC(this, globalCtx); - func_8098DA74(this, globalCtx); + func_8098CEAC(this, play); + func_8098DA74(this, play); Actor_MarkForDeath(&this->actor); } else { s32 dmgFlags = this->collider.elements->info.acHitInfo->toucher.dmgFlags; @@ -413,11 +416,11 @@ void func_8098DC60(ObjComb* this, GlobalContext* globalCtx) { this->unk_1B8--; } } - CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + CollisionCheck_SetAC(play, &play->colChkCtx, &this->collider.base); } if (this->actor.update != NULL) { - CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + CollisionCheck_SetOC(play, &play->colChkCtx, &this->collider.base); } this->actor.shape.rot.x = (s32)(Math_SinS(this->unk_1AA) * this->unk_1A8) + this->actor.home.rot.x; @@ -432,20 +435,20 @@ void func_8098DE58(ObjComb* this) { this->actionFunc = func_8098DEA0; } -void func_8098DEA0(ObjComb* this, GlobalContext* globalCtx) { +void func_8098DEA0(ObjComb* this, PlayState* play) { this->unk_1B4--; if ((this->actor.bgCheckFlags & 1) || (this->unk_1B4 <= 0)) { - func_8098DA74(this, globalCtx); + func_8098DA74(this, play); if ((this->actor.bgCheckFlags & 0x20) && (this->actor.depthInWater > 30.0f)) { - func_8098D47C(this, globalCtx); + func_8098D47C(this, play); } else { - func_8098D19C(this, globalCtx); + func_8098D19C(this, play); } - SoundSource_PlaySfxAtFixedWorldPos(globalCtx, &this->actor.world.pos, 40, NA_SE_EV_HONEYCOMB_BROKEN); + SoundSource_PlaySfxAtFixedWorldPos(play, &this->actor.world.pos, 40, NA_SE_EV_HONEYCOMB_BROKEN); func_8098E098(this); } else { if (this->actor.bgCheckFlags & 0x40) { - func_8098D6E0(this, globalCtx); + func_8098D6E0(this, play); } if (this->actor.bgCheckFlags & 0x20) { @@ -472,8 +475,8 @@ void func_8098DEA0(ObjComb* this, GlobalContext* globalCtx) { 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); + Actor_UpdateBgCheckInfo(play, &this->actor, 20.0f, 12.0f, 0.0f, 5); + CollisionCheck_SetOC(play, &play->colChkCtx, &this->collider.base); } } @@ -483,7 +486,7 @@ void func_8098E098(ObjComb* this) { this->actionFunc = func_8098E0B8; } -void func_8098E0B8(ObjComb* this, GlobalContext* globalCtx) { +void func_8098E0B8(ObjComb* this, PlayState* play) { this->unk_1B4--; if (this->unk_1B4 <= 0) { Actor_MarkForDeath(&this->actor); @@ -492,12 +495,12 @@ void func_8098E0B8(ObjComb* this, GlobalContext* globalCtx) { 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); + func_800B7298(play, &this->actor, 4); } } } -void ObjComb_Update(Actor* thisx, GlobalContext* globalCtx) { +void ObjComb_Update(Actor* thisx, PlayState* play) { ObjComb* this = THIS; this->unk_1B3 = (this->collider.base.acFlags & AC_HIT) != 0; @@ -512,7 +515,7 @@ void ObjComb_Update(Actor* thisx, GlobalContext* globalCtx) { } } - this->actionFunc(this, globalCtx); + this->actionFunc(this, play); if (this->actor.update == NULL) { if ((this->unk_1B5 == 2) && (func_800F2138(this->actor.cutscene) == -1)) { @@ -526,7 +529,7 @@ void ObjComb_Update(Actor* thisx, GlobalContext* globalCtx) { if (ActorCutscene_GetCanPlayNext(this->actor.cutscene)) { ActorCutscene_StartAndSetUnkLinkFields(this->actor.cutscene, &this->actor); if (this->actor.cutscene >= 0) { - func_800B7298(globalCtx, &this->actor, 1); + func_800B7298(play, &this->actor, 1); } if (((OBJCOMB_GET_8000(&this->actor) | OBJCOMB_GET_80(&this->actor)) == 1) && @@ -542,30 +545,30 @@ void ObjComb_Update(Actor* thisx, GlobalContext* globalCtx) { } if (this->unk_1B7 != 0) { - globalCtx->actorCtx.unk5 |= 8; + play->actorCtx.unk5 |= 8; this->actor.flags |= ACTOR_FLAG_10; } } } -void ObjComb_Draw(Actor* thisx, GlobalContext* globalCtx) { +void ObjComb_Draw(Actor* thisx, PlayState* play) { ObjComb* this = THIS; - OPEN_DISPS(globalCtx->state.gfxCtx); + OPEN_DISPS(play->state.gfxCtx); - func_8012C28C(globalCtx->state.gfxCtx); - Matrix_InsertTranslation(this->actor.world.pos.x, this->actor.world.pos.y + (118.0f * this->actor.scale.y), - this->actor.world.pos.z, MTXMODE_NEW); - Matrix_RotateY(this->actor.shape.rot.y, MTXMODE_APPLY); - Matrix_InsertXRotation_s(this->actor.shape.rot.x, MTXMODE_APPLY); - Matrix_InsertZRotation_s(this->actor.shape.rot.z, MTXMODE_APPLY); - Matrix_InsertTranslation(0.0f, -(this->actor.scale.y * 118.0f), 0.0f, MTXMODE_APPLY); + func_8012C28C(play->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); + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(play->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); + CLOSE_DISPS(play->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 fc47df429..ed5188576 100644 --- a/src/overlays/actors/ovl_Obj_Comb/z_obj_comb.h +++ b/src/overlays/actors/ovl_Obj_Comb/z_obj_comb.h @@ -5,7 +5,7 @@ struct ObjComb; -typedef void (*ObjCombActionFunc)(struct ObjComb*, GlobalContext*); +typedef void (*ObjCombActionFunc)(struct ObjComb*, PlayState*); #define OBJCOMB_GET_F(thisx) ((thisx)->params & 0xF) #define OBJCOMB_GET_10(thisx) (((thisx)->params >> 4) & 0x1) @@ -16,22 +16,22 @@ typedef void (*ObjCombActionFunc)(struct ObjComb*, GlobalContext*); #define OBJCOMB_GET_8000(thisx) (((thisx)->params >> 0xE) & 2) typedef struct ObjComb { - /* 0x0000 */ Actor actor; - /* 0x0144 */ ObjCombActionFunc actionFunc; - /* 0x0148 */ ColliderJntSph collider; - /* 0x0168 */ ColliderJntSphElement colliderElement; - /* 0x01A8 */ s16 unk_1A8; - /* 0x01AA */ s16 unk_1AA; - /* 0x01AC */ s16 unk_1AC; - /* 0x01AE */ s16 unk_1AE; - /* 0x01B0 */ s16 unk_1B0; - /* 0x01B2 */ s8 unk_1B2; - /* 0x01B3 */ s8 unk_1B3; - /* 0x01B4 */ s8 unk_1B4; - /* 0x01B5 */ s8 unk_1B5; - /* 0x01B6 */ s8 unk_1B6; - /* 0x01B7 */ s8 unk_1B7; - /* 0x01B8 */ s8 unk_1B8; + /* 0x000 */ Actor actor; + /* 0x144 */ ObjCombActionFunc actionFunc; + /* 0x148 */ ColliderJntSph collider; + /* 0x168 */ ColliderJntSphElement colliderElement; + /* 0x1A8 */ s16 unk_1A8; + /* 0x1AA */ s16 unk_1AA; + /* 0x1AC */ s16 unk_1AC; + /* 0x1AE */ s16 unk_1AE; + /* 0x1B0 */ s16 unk_1B0; + /* 0x1B2 */ s8 unk_1B2; + /* 0x1B3 */ s8 unk_1B3; + /* 0x1B4 */ s8 unk_1B4; + /* 0x1B5 */ s8 unk_1B5; + /* 0x1B6 */ s8 unk_1B6; + /* 0x1B7 */ s8 unk_1B7; + /* 0x1B8 */ s8 unk_1B8; } ObjComb; // size = 0x1BC extern const ActorInit Obj_Comb_InitVars; diff --git a/src/overlays/actors/ovl_Obj_Danpeilift/z_obj_danpeilift.c b/src/overlays/actors/ovl_Obj_Danpeilift/z_obj_danpeilift.c index aa72f3052..be3f365e3 100644 --- a/src/overlays/actors/ovl_Obj_Danpeilift/z_obj_danpeilift.c +++ b/src/overlays/actors/ovl_Obj_Danpeilift/z_obj_danpeilift.c @@ -10,12 +10,17 @@ #define THIS ((ObjDanpeilift*)thisx) -void ObjDanpeilift_Init(Actor* thisx, GlobalContext* globalCtx); -void ObjDanpeilift_Destroy(Actor* thisx, GlobalContext* globalCtx); -void ObjDanpeilift_Update(Actor* thisx, GlobalContext* globalCtx); -void ObjDanpeilift_Draw(Actor* thisx, GlobalContext* globalCtx); +void ObjDanpeilift_Init(Actor* thisx, PlayState* play); +void ObjDanpeilift_Destroy(Actor* thisx, PlayState* play); +void ObjDanpeilift_Update(Actor* thisx, PlayState* play); +void ObjDanpeilift_Draw(Actor* thisx, PlayState* play); + +void ObjDanpeilift_UpdatePosition(ObjDanpeilift* this, s32 index); +void ObjDanpeilift_DoNothing(ObjDanpeilift* this, PlayState* play); +void ObjDanpeilift_Move(ObjDanpeilift* this, PlayState* play); +void ObjDanpeilift_Teleport(ObjDanpeilift* this, PlayState* play); +void ObjDanpeilift_Wait(ObjDanpeilift* this, PlayState* play); -#if 0 const ActorInit Obj_Danpeilift_InitVars = { ACTOR_OBJ_DANPEILIFT, ACTORCAT_BG, @@ -28,35 +33,171 @@ const ActorInit Obj_Danpeilift_InitVars = { (ActorFunc)ObjDanpeilift_Draw, }; -// static InitChainEntry sInitChain[] = { -static InitChainEntry D_80C1B540[] = { +static InitChainEntry sInitChain[] = { ICHAIN_F32(uncullZoneForward, 4000, ICHAIN_CONTINUE), ICHAIN_F32(uncullZoneScale, 200, ICHAIN_CONTINUE), ICHAIN_F32(uncullZoneDownward, 400, ICHAIN_CONTINUE), ICHAIN_VEC3F_DIV1000(scale, 100, ICHAIN_STOP), }; -#endif +void ObjDanpeilift_UpdatePosition(ObjDanpeilift* this, s32 index) { + Math_Vec3s_ToVec3f(&this->dyna.actor.world.pos, &this->points[index]); +} -extern InitChainEntry D_80C1B540[]; +void ObjDanpeilift_Init(Actor* thisx, PlayState* play) { + Path* path; + ObjDanpeiliftActionFunc tempActionFunc; + ObjDanpeilift* this = THIS; -extern UNK_TYPE D_06000180; -extern UNK_TYPE D_06000BA0; + 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; + DynaPolyActor_Init(&this->dyna, 1); + DynaPolyActor_LoadMesh(play, &this->dyna, &object_obj_danpeilift_Colheader_000BA0); + if (this->dyna.bgId == BG_ACTOR_MAX) { + Actor_MarkForDeath(&this->dyna.actor); + } else { + this->speed = OBJDANPEILIFT_GET_SPEED(thisx); + if (this->speed < 0.0f) { + this->speed = -this->speed; + } + if (this->speed < 0.01f) { + this->actionFunc = ObjDanpeilift_DoNothing; + } else { + path = &play->setupPathList[OBJDANPEILIFT_GET_PATH(thisx)]; + this->curPoint = OBJDANPEILIFT_GET_STARTING_POINT(thisx); + this->endPoint = path->count - 1; + this->direction = 1; + this->points = Lib_SegmentedToVirtual(path->points); + ObjDanpeilift_UpdatePosition(this, this->curPoint); + this->actionFunc = ObjDanpeilift_Move; + } + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Danpeilift/func_80C1ADC0.s") +void ObjDanpeilift_Destroy(Actor* thisx, PlayState* play) { + ObjDanpeilift* this = THIS; + DynaPoly_DeleteBgActor(play, &play->colCtx.dyna, this->dyna.bgId); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Danpeilift/ObjDanpeilift_Init.s") +void ObjDanpeilift_DoNothing(ObjDanpeilift* this, PlayState* play) { +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Danpeilift/ObjDanpeilift_Destroy.s") +void ObjDanpeilift_Move(ObjDanpeilift* this, PlayState* play) { + Actor* thisx = &this->dyna.actor; + Vec3f nextPoint; + f32 speed; + f32 target; + f32 step; + s32 isTeleporting; + s32 isPosUpdated; + Vec3s* endPoint; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Danpeilift/func_80C1AF84.s") + Math_Vec3s_ToVec3f(&nextPoint, this->points + this->curPoint + this->direction); + Math_Vec3f_Diff(&nextPoint, &thisx->world.pos, &thisx->velocity); + speed = Math3D_Vec3fMagnitude(&thisx->velocity); + if ((speed < (this->speed * 8.0f)) && (this->speed > 2.0f)) { + target = ((this->speed - 2.0f) * 0.1f) + 2.0f; + step = this->speed * 0.03f; + } else { + target = this->speed; + step = this->speed * 0.16f; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Danpeilift/func_80C1AF94.s") + Math_StepToF(&thisx->speedXZ, target, step); + if ((thisx->speedXZ + 0.05f) < speed) { + Math_Vec3f_Scale(&thisx->velocity, thisx->speedXZ / speed); + thisx->world.pos.x += thisx->velocity.x; + thisx->world.pos.y += thisx->velocity.y; + thisx->world.pos.z += thisx->velocity.z; + } else { + this->curPoint += this->direction; + thisx->speedXZ *= 0.4f; + isTeleporting = OBJDANPEILIFT_SHOULD_TELEPORT(thisx); + isPosUpdated = true; + if (((this->curPoint >= this->endPoint) && (this->direction > 0)) || + ((this->curPoint <= 0) && (this->direction < 0))) { + if (!isTeleporting) { + this->direction = -this->direction; + this->waitTimer = 10; + this->actionFunc = ObjDanpeilift_Wait; + } else { + endPoint = &this->points[this->endPoint]; + this->curPoint = this->direction > 0 ? 0 : this->endPoint; + if ((this->points[0].x != endPoint->x) || (this->points[0].y != endPoint->y) || + (this->points[0].z != endPoint->z)) { + this->actionFunc = ObjDanpeilift_Teleport; + func_800C62BC(play, &play->colCtx.dyna, this->dyna.bgId); + isPosUpdated = false; + } + } + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Danpeilift/func_80C1B210.s") + if (isPosUpdated) { + ObjDanpeilift_UpdatePosition(this, this->curPoint); + } + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Danpeilift/func_80C1B26C.s") +void ObjDanpeilift_Teleport(ObjDanpeilift* this, PlayState* play) { + if (!DynaPolyActor_IsInRidingMovingState(&this->dyna)) { + ObjDanpeilift_UpdatePosition(this, this->curPoint); + func_800C6314(play, &play->colCtx.dyna, this->dyna.bgId); + this->actionFunc = ObjDanpeilift_Move; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Danpeilift/ObjDanpeilift_Update.s") +void ObjDanpeilift_Wait(ObjDanpeilift* this, PlayState* play) { + this->waitTimer--; + if (this->waitTimer <= 0) { + this->actionFunc = ObjDanpeilift_Move; + this->dyna.actor.speedXZ = 0.0f; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Danpeilift/ObjDanpeilift_Draw.s") +void ObjDanpeilift_Update(Actor* thisx, PlayState* play) { + f32 step; + ObjDanpeilift* this = THIS; + + this->actionFunc(this, play); + Actor_SetFocus(&this->dyna.actor, 10.0f); + if (this->cutsceneTimer > 0) { + this->cutsceneTimer--; + if (this->cutsceneTimer == 0) { + ActorCutscene_Stop(this->dyna.actor.cutscene); + } + } + if (OBJDANPEILIFT_SHOULD_REACT_TO_WEIGHT(thisx)) { + f32 target; + + this->isWeightOnPrev = this->isWeightOn; + this->isWeightOn = DynaPolyActor_IsInRidingMovingState(&this->dyna) ? 1 : 0; + if ((this->isWeightOn != this->isWeightOnPrev) && (this->maxHeight < 1.0f)) { + this->cycle = -0x8000; + this->maxHeight = 6.0f; + } + this->cycle += 0xCE4; + Math_StepToF(&this->maxHeight, 0.0f, 0.12f); + step = this->isWeightOn ? Math_CosS(fabsf(this->cycleSpeed) * 2048.0f) + 0.02f + : Math_SinS(fabsf(this->cycleSpeed) * 2048.0f) + 0.02f; + target = this->isWeightOn ? -8.0f : 0.0f; + Math_StepToF(&this->cycleSpeed, target, step); + this->dyna.actor.shape.yOffset = ((Math_SinS(this->cycle) * this->maxHeight) + this->cycleSpeed) * 10.0f; + } + if ((OBJDANPEILIFT_GET_TYPE(thisx) == 1) && (this->dyna.actor.child != NULL)) { + if (this->dyna.actor.child->update == NULL) { + this->dyna.actor.child = NULL; + } else { + this->dyna.actor.child->world.pos.x = this->dyna.actor.world.pos.x; + this->dyna.actor.child->world.pos.y = + this->dyna.actor.world.pos.y + (this->dyna.actor.shape.yOffset * this->dyna.actor.scale.y); + this->dyna.actor.child->world.pos.z = this->dyna.actor.world.pos.z; + } + } +} + +void ObjDanpeilift_Draw(Actor* thisx, PlayState* play) { + Gfx_DrawDListOpa(play, object_obj_danpeilift_DL_000180); +} diff --git a/src/overlays/actors/ovl_Obj_Danpeilift/z_obj_danpeilift.h b/src/overlays/actors/ovl_Obj_Danpeilift/z_obj_danpeilift.h index 3cf7af320..31f6b90c4 100644 --- a/src/overlays/actors/ovl_Obj_Danpeilift/z_obj_danpeilift.h +++ b/src/overlays/actors/ovl_Obj_Danpeilift/z_obj_danpeilift.h @@ -2,16 +2,34 @@ #define Z_OBJ_DANPEILIFT_H #include "global.h" +#include "objects/object_obj_danpeilift/object_obj_danpeilift.h" struct ObjDanpeilift; -typedef void (*ObjDanpeiliftActionFunc)(struct ObjDanpeilift*, GlobalContext*); +typedef void (*ObjDanpeiliftActionFunc)(struct ObjDanpeilift*, PlayState*); + +#define OBJDANPEILIFT_GET_TYPE(thisx) (((thisx)->params >> 0xF) & 1) +#define OBJDANPEILIFT_GET_STARTING_POINT(thisx) (((thisx)->params >> 7) & 0x1F) +#define OBJDANPEILIFT_GET_PATH(thisx) ((thisx)->params & 0x7F) +#define OBJDANPEILIFT_SHOULD_TELEPORT(thisx) (((thisx)->params >> 0xC) & 1) +#define OBJDANPEILIFT_GET_SPEED(thisx) ((thisx)->home.rot.z * 0.1f) +#define OBJDANPEILIFT_SHOULD_REACT_TO_WEIGHT(thisx) (((thisx)->params >> 0xE) & 1) typedef struct ObjDanpeilift { - /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x18]; - /* 0x015C */ ObjDanpeiliftActionFunc actionFunc; - /* 0x0160 */ char unk_160[0x2C]; + /* 0x000 */ DynaPolyActor dyna; + /* 0x15C */ ObjDanpeiliftActionFunc actionFunc; + /* 0x160 */ f32 speed; + /* 0x164 */ s32 endPoint; + /* 0x168 */ s32 curPoint; + /* 0x16C */ s32 direction; + /* 0x170 */ Vec3s* points; + /* 0x174 */ s32 isWeightOn; + /* 0x178 */ s32 isWeightOnPrev; + /* 0x17C */ f32 cycleSpeed; + /* 0x180 */ f32 maxHeight; + /* 0x184 */ s16 cycle; + /* 0x186 */ s16 waitTimer; + /* 0x188 */ s16 cutsceneTimer; } ObjDanpeilift; // size = 0x18C extern const ActorInit Obj_Danpeilift_InitVars; diff --git a/src/overlays/actors/ovl_Obj_Demo/z_obj_demo.c b/src/overlays/actors/ovl_Obj_Demo/z_obj_demo.c index 2fba4b96a..5783118de 100644 --- a/src/overlays/actors/ovl_Obj_Demo/z_obj_demo.c +++ b/src/overlays/actors/ovl_Obj_Demo/z_obj_demo.c @@ -10,13 +10,13 @@ #define THIS ((ObjDemo*)thisx) -void ObjDemo_Init(Actor* thisx, GlobalContext* globalCtx); -void ObjDemo_Update(Actor* thisx, GlobalContext* globalCtx); +void ObjDemo_Init(Actor* thisx, PlayState* play); +void ObjDemo_Update(Actor* thisx, PlayState* play); -void func_80983678(ObjDemo* this, GlobalContext* globalCtx); -void func_80983704(ObjDemo* this, GlobalContext* globalCtx); +void func_80983678(ObjDemo* this, PlayState* play); +void func_80983704(ObjDemo* this, PlayState* play); +void func_80983634(PlayState* play); -#if 0 const ActorInit Obj_Demo_InitVars = { ACTOR_OBJ_DEMO, ACTORCAT_PROP, @@ -29,14 +29,88 @@ const ActorInit Obj_Demo_InitVars = { (ActorFunc)NULL, }; -#endif +void ObjDemo_Init(Actor* thisx, PlayState* play) { + ObjDemo* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Demo/ObjDemo_Init.s") + thisx->params = OBJDEMO_GET_FF(thisx); + if ((thisx->params != OBJDEMO_FF_FF) && (Flags_GetSwitch(play, thisx->params))) { + Actor_MarkForDeath(&this->actor); + return; + } + if (thisx->shape.rot.x < 0) { + this->unk_148 = 1; + thisx->shape.rot.x = -thisx->shape.rot.x; + } + if (thisx->shape.rot.x == 0) { + this->xzRange = 80.0f; + } else { + this->xzRange = thisx->shape.rot.x * 4.0f; + thisx->shape.rot.x = 0; + thisx->world.rot.x = 0; + } + if (thisx->shape.rot.z == 0) { + this->yRange = 60.0f; + } else { + this->yRange = thisx->shape.rot.z * 4.0f; + thisx->shape.rot.z = 0; + thisx->world.rot.z = 0; + } + func_80983634(play); + this->actionFunc = func_80983678; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Demo/func_80983634.s") +void func_80983634(PlayState* play) { + if ((play->sceneNum == SCENE_CASTLE) && (func_801A8A50(0) == NA_BGM_IKANA_CASTLE)) { + Audio_QueueSeqCmd(0x100100FF); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Demo/func_80983678.s") +void func_80983678(ObjDemo* this, PlayState* play) { + func_80983634(play); + if ((this->actor.xzDistToPlayer < this->xzRange) && (fabsf(this->actor.playerHeightRel) < this->yRange)) { + if (this->unk_148 == 1) { + ActorCutscene_Stop(0x7D); + } + ActorCutscene_SetIntentToPlay(this->actor.cutscene); + this->actionFunc = func_80983704; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Demo/func_80983704.s") +void func_80983704(ObjDemo* this, PlayState* play) { + if ((this->unk_148 == 1) && (ActorCutscene_GetCurrentIndex() == 0x7D)) { + ActorCutscene_Stop(0x7D); + ActorCutscene_SetIntentToPlay(this->actor.cutscene); + } else { + if (ActorCutscene_GetCanPlayNext(this->actor.cutscene)) { + if (this->unk_148 == 1) { + ActorCutscene_Start(this->actor.cutscene, &this->actor); + func_800E0348(play->cameraPtrs[CAM_ID_MAIN]); + } else { + ActorCutscene_StartAndSetUnkLinkFields(this->actor.cutscene, &this->actor); + } + if (play->sceneNum == SCENE_CASTLE) { + Audio_QueueSeqCmd(NA_BGM_IKANA_CASTLE | 0x8000); + } + this->actor.cutscene = ActorCutscene_GetAdditionalCutscene(this->actor.cutscene); + if (this->actor.cutscene == -1) { + if (this->actor.params != 0xFF) { + Flags_SetSwitch(play, this->actor.params); + } + Actor_MarkForDeath(&this->actor); + } + } else { + ActorCutscene_SetIntentToPlay(this->actor.cutscene); + func_80983634(play); + } + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Demo/ObjDemo_Update.s") +void ObjDemo_Update(Actor* thisx, PlayState* play) { + ObjDemo* this = THIS; + + if ((this->actor.params != 0xFF) && Flags_GetSwitch(play, this->actor.params)) { + Actor_MarkForDeath(&this->actor); + return; + } + this->actionFunc(this, play); +} diff --git a/src/overlays/actors/ovl_Obj_Demo/z_obj_demo.h b/src/overlays/actors/ovl_Obj_Demo/z_obj_demo.h index 2631e91be..be774bf07 100644 --- a/src/overlays/actors/ovl_Obj_Demo/z_obj_demo.h +++ b/src/overlays/actors/ovl_Obj_Demo/z_obj_demo.h @@ -3,14 +3,18 @@ #include "global.h" +#define OBJDEMO_GET_FF(thisx) ((thisx)->params & 0xFF) +#define OBJDEMO_FF_FF 0xFF struct ObjDemo; -typedef void (*ObjDemoActionFunc)(struct ObjDemo*, GlobalContext*); +typedef void (*ObjDemoActionFunc)(struct ObjDemo*, PlayState*); typedef struct ObjDemo { - /* 0x0000 */ Actor actor; - /* 0x0144 */ ObjDemoActionFunc actionFunc; - /* 0x0148 */ char unk_148[0xC]; + /* 0x000 */ Actor actor; + /* 0x144 */ ObjDemoActionFunc actionFunc; + /* 0x148 */ s32 unk_148; + /* 0x14C */ f32 xzRange; + /* 0x150 */ f32 yRange; } ObjDemo; // size = 0x154 extern const ActorInit Obj_Demo_InitVars; diff --git a/src/overlays/actors/ovl_Obj_Dhouse/z_obj_dhouse.c b/src/overlays/actors/ovl_Obj_Dhouse/z_obj_dhouse.c index bec773c2f..050207492 100644 --- a/src/overlays/actors/ovl_Obj_Dhouse/z_obj_dhouse.c +++ b/src/overlays/actors/ovl_Obj_Dhouse/z_obj_dhouse.c @@ -11,21 +11,21 @@ #define THIS ((ObjDhouse*)thisx) -void ObjDhouse_Init(Actor* thisx, GlobalContext* globalCtx); -void ObjDhouse_Destroy(Actor* thisx, GlobalContext* globalCtx); -void ObjDhouse_Update(Actor* thisx, GlobalContext* globalCtx); -void ObjDhouse_Draw(Actor* thisx, GlobalContext* globalCtx); +void ObjDhouse_Init(Actor* thisx, PlayState* play); +void ObjDhouse_Destroy(Actor* thisx, PlayState* play); +void ObjDhouse_Update(Actor* thisx, PlayState* play); +void ObjDhouse_Draw(Actor* thisx, PlayState* play); -void func_80B12E7C(ObjDhouse* this, GlobalContext* globalCtx, ObjDhouseStruct1* ptr, ObjDhouseStruct3* ptr3); -void func_80B13170(ObjDhouse* this, GlobalContext* globalCtx, ObjDhouseStruct1* ptr, ObjDhouseStruct3* ptr3); +void func_80B12E7C(ObjDhouse* this, PlayState* play, ObjDhouseStruct1* ptr, ObjDhouseStruct3* ptr3); +void func_80B13170(ObjDhouse* this, PlayState* play, ObjDhouseStruct1* ptr, ObjDhouseStruct3* ptr3); void func_80B13908(ObjDhouse* this); -void func_80B1391C(ObjDhouse* this, GlobalContext* globalCtx); +void func_80B1391C(ObjDhouse* this, PlayState* play); void func_80B1392C(ObjDhouse* this); -void func_80B13940(ObjDhouse* this, GlobalContext* globalCtx); +void func_80B13940(ObjDhouse* this, PlayState* play); 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); +void func_80B139F4(ObjDhouse* this, PlayState* play); +void func_80B13C08(Actor* thisx, PlayState* play); +void func_80B13E40(Actor* thisx, PlayState* play); const ActorInit Obj_Dhouse_InitVars = { ACTOR_OBJ_DHOUSE, @@ -123,27 +123,27 @@ static InitChainEntry sInitChain[] = { Vec3f D_80B13FC4 = { 160.0f, 0.0f, 240.0f }; -void ObjDhouse_Init(Actor* thisx, GlobalContext* globalCtx) { +void ObjDhouse_Init(Actor* thisx, PlayState* play) { ObjDhouse* this = THIS; Actor_ProcessInitChain(&this->dyna.actor, sInitChain); DynaPolyActor_Init(&this->dyna, 0); - if (Flags_GetSwitch(globalCtx, OBJDHOUSE_GET_7F(&this->dyna.actor))) { + if (Flags_GetSwitch(play, 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); + DynaPolyActor_LoadMesh(play, &this->dyna, &object_dhouse_Colheader_008040); this->dyna.actor.flags |= ACTOR_FLAG_10; func_80B1392C(this); } } -void ObjDhouse_Destroy(Actor* thisx, GlobalContext* globalCtx) { +void ObjDhouse_Destroy(Actor* thisx, PlayState* play) { ObjDhouse* this = THIS; - DynaPoly_DeleteBgActor(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); + DynaPoly_DeleteBgActor(play, &play->colCtx.dyna, this->dyna.bgId); } void func_80B12A50(ObjDhouseStruct1* this, ObjDhouseStruct3* ptr3, Vec3f* arg2) { @@ -166,7 +166,7 @@ void func_80B12A88(Actor* thisx) { } } -void func_80B12B38(ObjDhouse* this2, GlobalContext* globalCtx) { +void func_80B12B38(ObjDhouse* this2, PlayState* play) { ObjDhouse* this = this2; s32 i; f32 temp_f0; @@ -193,14 +193,14 @@ void func_80B12B38(ObjDhouse* this2, GlobalContext* globalCtx) { ptr->unk_18.z += ptr3->unk_20.z; if (ptr->unk_1E == ptr3->unk_26) { - func_80B12E7C(this, globalCtx, ptr, ptr3); + func_80B12E7C(this, play, ptr, ptr3); } } 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); + temp_f0 = BgCheck_EntityRaycastFloor5(&play->colCtx, &sp90, &sp7C, &this->dyna.actor, &sp80); if (((sp80.y - 35.0f) < temp_f0) && (temp_f0 > (BGCHECK_Y_MIN + 1.0f))) { phi_s3 = true; } @@ -208,7 +208,7 @@ void func_80B12B38(ObjDhouse* this2, GlobalContext* globalCtx) { if (phi_s3) { ptr->unk_1E = -1; - func_80B13170(this, globalCtx, ptr, ptr3); + func_80B13170(this, play, ptr, ptr3); } else if (ptr->unk_1E > 60) { ptr->unk_1E = -1; } else { @@ -234,15 +234,15 @@ s32 func_80B12D78(ObjDhouse* this) { return count; } -void func_80B12E7C(ObjDhouse* this, GlobalContext* globalCtx, ObjDhouseStruct1* ptr, ObjDhouseStruct3* ptr3) { +void func_80B12E7C(ObjDhouse* this, PlayState* play, ObjDhouseStruct1* ptr, ObjDhouseStruct3* ptr3) { s32 i; Vec3f spA0; Vec3f sp94; Vec3f sp88; ObjDhouseStruct2* ptr2; - Matrix_RotateY(this->dyna.actor.shape.rot.y, MTXMODE_NEW); - Matrix_MultiplyVector3fXZByCurrentState(&D_80B13FC4, &sp94); + Matrix_RotateYS(this->dyna.actor.shape.rot.y, MTXMODE_NEW); + Matrix_MultVec3fXZ(&D_80B13FC4, &sp94); sp94.y = 100.0f; func_80B12A50(ptr, ptr3, &spA0); @@ -263,13 +263,13 @@ void func_80B12E7C(ObjDhouse* this, GlobalContext* globalCtx, ObjDhouseStruct1* ptr2->unk_18 = (Rand_ZeroOne() * 0.057f) + 0.003f; - ptr2->unk_1C.x = (u32)Rand_Next() >> 0x10; - ptr2->unk_1C.y = (u32)Rand_Next() >> 0x10; - ptr2->unk_1C.z = (u32)Rand_Next() >> 0x10; + ptr2->unk_1C.x = Rand_Next() >> 0x10; + ptr2->unk_1C.y = Rand_Next() >> 0x10; + ptr2->unk_1C.z = Rand_Next() >> 0x10; - ptr2->unk_22 = ((u32)Rand_Next() >> 0x11) - 0x3FFF; - ptr2->unk_24 = ((u32)Rand_Next() >> 0x13) - 0xFFF; - ptr2->unk_26 = ((u32)Rand_Next() >> 0x12) - 0x1FFF; + ptr2->unk_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; @@ -278,13 +278,13 @@ void func_80B12E7C(ObjDhouse* this, GlobalContext* globalCtx, ObjDhouseStruct1* 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, + func_800B1210(play, &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) { +void func_80B13170(ObjDhouse* this, PlayState* play, ObjDhouseStruct1* ptr, ObjDhouseStruct3* ptr3) { s32 i; Vec3f sp98; Vec3f sp8C; @@ -307,13 +307,13 @@ void func_80B13170(ObjDhouse* this, GlobalContext* globalCtx, ObjDhouseStruct1* ptr2->unk_00.y = (ptr2->unk_00.y * 23.0f) + sp98.y + 15.0f; ptr2->unk_00.z = (ptr2->unk_00.z * 80.0f) + sp98.z; - ptr2->unk_1C.x = (u32)Rand_Next() >> 0x10; - ptr2->unk_1C.y = (u32)Rand_Next() >> 0x10; - ptr2->unk_1C.z = (u32)Rand_Next() >> 0x10; + ptr2->unk_1C.x = Rand_Next() >> 0x10; + ptr2->unk_1C.y = Rand_Next() >> 0x10; + ptr2->unk_1C.z = Rand_Next() >> 0x10; - ptr2->unk_22 = ((u32)Rand_Next() >> 0x12) - 0x1FFF; - ptr2->unk_24 = ((u32)Rand_Next() >> 0x13) - 0xFFF; - ptr2->unk_26 = ((u32)Rand_Next() >> 0x12) - 0x1FFF; + ptr2->unk_22 = (Rand_Next() >> 0x12) - 0x1FFF; + ptr2->unk_24 = (Rand_Next() >> 0x13) - 0xFFF; + ptr2->unk_26 = (Rand_Next() >> 0x12) - 0x1FFF; ptr2->unk_28 = 40; @@ -330,13 +330,13 @@ void func_80B13170(ObjDhouse* this, GlobalContext* globalCtx, ObjDhouseStruct1* 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, + func_800B1210(play, &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) { +void func_80B13474(ObjDhouse* this, PlayState* play, Vec3f* arg2) { s32 i; Vec3f sp88; ObjDhouseStruct2* ptr2; @@ -356,13 +356,13 @@ void func_80B13474(ObjDhouse* this, GlobalContext* globalCtx, Vec3f* arg2) { ptr2->unk_00.y = ((ptr2->unk_00.y - 0.4f) * 20.0f) + arg2->y; ptr2->unk_00.z = (ptr2->unk_00.z * 40.0f) + arg2->z; - ptr2->unk_1C.x = (u32)Rand_Next() >> 0x10; - ptr2->unk_1C.y = (u32)Rand_Next() >> 0x10; - ptr2->unk_1C.z = (u32)Rand_Next() >> 0x10; + ptr2->unk_1C.x = Rand_Next() >> 0x10; + ptr2->unk_1C.y = Rand_Next() >> 0x10; + ptr2->unk_1C.z = Rand_Next() >> 0x10; - ptr2->unk_22 = ((u32)Rand_Next() >> 0x12) - 0x1FFF; - ptr2->unk_24 = ((u32)Rand_Next() >> 0x13) - 0xFFF; - ptr2->unk_26 = ((u32)Rand_Next() >> 0x12) - 0x1FFF; + ptr2->unk_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; @@ -372,12 +372,12 @@ void func_80B13474(ObjDhouse* this, GlobalContext* globalCtx, Vec3f* arg2) { 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, + func_800B1210(play, &sp88, &gZeroVec3f, &D_80B13FA8, (s32)(Rand_ZeroOne() * 80.0f) + 20, (s32)(Rand_ZeroOne() * 90.0f) + 40); } } -void func_80B13724(ObjDhouse* this, GlobalContext* globalCtx) { +void func_80B13724(ObjDhouse* this, PlayState* play) { f32 temp_f0; f32 temp_f20 = this->dyna.actor.home.pos.y - 300.0f; s32 i; @@ -406,11 +406,11 @@ void func_80B13724(ObjDhouse* this, GlobalContext* globalCtx) { if (ptr2->unk_29 & 1) { temp_f0 = - BgCheck_EntityRaycastFloor5(&globalCtx->colCtx, &sp80, &sp6C, &this->dyna.actor, &ptr2->unk_00); + BgCheck_EntityRaycastFloor5(&play->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); + func_80B13474(this, play, &sp70); } } } @@ -422,25 +422,25 @@ void func_80B13908(ObjDhouse* this) { this->actionFunc = func_80B1391C; } -void func_80B1391C(ObjDhouse* this, GlobalContext* globalCtx) { +void func_80B1391C(ObjDhouse* this, PlayState* play) { } void func_80B1392C(ObjDhouse* this) { this->actionFunc = func_80B13940; } -void func_80B13940(ObjDhouse* this, GlobalContext* globalCtx2) { - GlobalContext* globalCtx = globalCtx2; +void func_80B13940(ObjDhouse* this, PlayState* play2) { + PlayState* play = play2; s32 sp20 = false; - if (Flags_GetSwitch(globalCtx, OBJDHOUSE_GET_7F(&this->dyna.actor))) { + if (Flags_GetSwitch(play, 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); + func_800C62BC(play, &play->colCtx.dyna, this->dyna.bgId); this->dyna.actor.draw = func_80B13C08; this->dyna.actor.flags |= ACTOR_FLAG_20; func_80B139D8(this); @@ -452,8 +452,8 @@ void func_80B139D8(ObjDhouse* this) { this->actionFunc = func_80B139F4; } -void func_80B139F4(ObjDhouse* this, GlobalContext* globalCtx) { - Camera* camera = GET_ACTIVE_CAM(globalCtx); +void func_80B139F4(ObjDhouse* this, PlayState* play) { + Camera* camera = GET_ACTIVE_CAM(play); s16 quake; if (this->unk_1370 == 117) { @@ -480,44 +480,43 @@ void func_80B139F4(ObjDhouse* this, GlobalContext* globalCtx) { this->dyna.actor.flags &= ~ACTOR_FLAG_10; func_80B13908(this); } else { - func_80B12B38(this, globalCtx); - func_80B13724(this, globalCtx); + func_80B12B38(this, play); + func_80B13724(this, play); } } -void ObjDhouse_Update(Actor* thisx, GlobalContext* globalCtx) { +void ObjDhouse_Update(Actor* thisx, PlayState* play) { ObjDhouse* this = THIS; - this->actionFunc(this, globalCtx); + this->actionFunc(this, play); } -void ObjDhouse_Draw(Actor* thisx, GlobalContext* globalCtx) { - Gfx_DrawDListOpa(globalCtx, object_dhouse_DL_005A78); +void ObjDhouse_Draw(Actor* thisx, PlayState* play) { + Gfx_DrawDListOpa(play, object_dhouse_DL_005A78); } -void func_80B13C08(Actor* thisx, GlobalContext* globalCtx) { +void func_80B13C08(Actor* thisx, PlayState* play) { ObjDhouse* this = THIS; ObjDhouseStruct1* ptr; ObjDhouseStruct2* ptr2; ObjDhouseStruct3* ptr3; s32 i; - OPEN_DISPS(globalCtx->state.gfxCtx); + OPEN_DISPS(play->state.gfxCtx); - func_8012C28C(globalCtx->state.gfxCtx); + func_8012C28C(play->state.gfxCtx); - gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_OPA_DISP++, object_dhouse_DL_004928); for (i = 0, ptr = &this->unk_160[0], ptr3 = &D_80B13E90[0]; i < ARRAY_COUNT(this->unk_160); i++, ptr3++, ptr++) { if (ptr->unk_1E >= 0) { - Matrix_SetStateRotationAndTranslation(ptr->unk_00.x + ptr3->unk_08.x, ptr->unk_00.y + ptr3->unk_08.y, - ptr->unk_00.z + ptr3->unk_08.z, &ptr->unk_18); - Matrix_InsertTranslation(-ptr3->unk_08.x, -ptr3->unk_08.y, -ptr3->unk_08.z, MTXMODE_APPLY); + Matrix_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); + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(play->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); } @@ -525,18 +524,17 @@ void func_80B13C08(Actor* thisx, GlobalContext* globalCtx) { for (i = 0, ptr2 = &this->unk_240[0]; i < ARRAY_COUNT(this->unk_240); i++, ptr2++) { if (ptr2->unk_28 > 0) { - Matrix_SetStateRotationAndTranslation(ptr2->unk_00.x, ptr2->unk_00.y, ptr2->unk_00.z, &ptr2->unk_1C); + Matrix_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); + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_OPA_DISP++, object_dhouse_DL_0081D8); } } - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->state.gfxCtx); } -void func_80B13E40(Actor* thisx, GlobalContext* globalCtx) { - Gfx_DrawDListOpa(globalCtx, object_dhouse_DL_004928); +void func_80B13E40(Actor* thisx, PlayState* play) { + Gfx_DrawDListOpa(play, 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 053928c1c..807af52f9 100644 --- a/src/overlays/actors/ovl_Obj_Dhouse/z_obj_dhouse.h +++ b/src/overlays/actors/ovl_Obj_Dhouse/z_obj_dhouse.h @@ -5,7 +5,7 @@ struct ObjDhouse; -typedef void (*ObjDhouseActionFunc)(struct ObjDhouse*, GlobalContext*); +typedef void (*ObjDhouseActionFunc)(struct ObjDhouse*, PlayState*); #define OBJDHOUSE_GET_7F(thisx) ((thisx)->params & 0x7F) 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 57f9d7550..4c8f38350 100644 --- a/src/overlays/actors/ovl_Obj_Dinner/z_obj_dinner.c +++ b/src/overlays/actors/ovl_Obj_Dinner/z_obj_dinner.c @@ -11,10 +11,10 @@ #define THIS ((ObjDinner*)thisx) -void ObjDinner_Init(Actor* thisx, GlobalContext* globalCtx); -void ObjDinner_Destroy(Actor* thisx, GlobalContext* globalCtx); -void ObjDinner_Update(Actor* thisx, GlobalContext* globalCtx); -void ObjDinner_Draw(Actor* thisx, GlobalContext* globalCtx); +void ObjDinner_Init(Actor* thisx, PlayState* play); +void ObjDinner_Destroy(Actor* thisx, PlayState* play); +void ObjDinner_Update(Actor* thisx, PlayState* play); +void ObjDinner_Draw(Actor* thisx, PlayState* play); const ActorInit Obj_Dinner_InitVars = { ACTOR_OBJ_DINNER, @@ -28,7 +28,7 @@ const ActorInit Obj_Dinner_InitVars = { (ActorFunc)ObjDinner_Draw, }; -void ObjDinner_Init(Actor* thisx, GlobalContext* globalCtx) { +void ObjDinner_Init(Actor* thisx, PlayState* play) { ObjDinner* this = THIS; if (gSaveContext.save.isNight != true || (CURRENT_DAY == 3 && gSaveContext.save.weekEventReg[22] & 1)) { @@ -37,18 +37,18 @@ void ObjDinner_Init(Actor* thisx, GlobalContext* globalCtx) { Actor_SetScale(&this->actor, 0.1f); } -void ObjDinner_Destroy(Actor* thisx, GlobalContext* globalCtx) { +void ObjDinner_Destroy(Actor* thisx, PlayState* play) { } -void ObjDinner_Update(Actor* thisx, GlobalContext* globalCtx) { +void ObjDinner_Update(Actor* thisx, PlayState* play) { } -void ObjDinner_Draw(Actor* thisx, GlobalContext* globalCtx) { - OPEN_DISPS(globalCtx->state.gfxCtx); - func_8012C28C(globalCtx->state.gfxCtx); +void ObjDinner_Draw(Actor* thisx, PlayState* play) { + OPEN_DISPS(play->state.gfxCtx); + func_8012C28C(play->state.gfxCtx); - gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_OPA_DISP++, object_obj_dinner_DL_0011E0); - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->state.gfxCtx); } 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 1d77cc257..c8b9926c5 100644 --- a/src/overlays/actors/ovl_Obj_Dora/z_obj_dora.c +++ b/src/overlays/actors/ovl_Obj_Dora/z_obj_dora.c @@ -5,17 +5,36 @@ */ #include "z_obj_dora.h" +#include "assets/objects/object_dora/object_dora.h" #define FLAGS (ACTOR_FLAG_10) #define THIS ((ObjDora*)thisx) -void ObjDora_Init(Actor* thisx, GlobalContext* globalCtx); -void ObjDora_Destroy(Actor* thisx, GlobalContext* globalCtx); -void ObjDora_Update(Actor* thisx, GlobalContext* globalCtx); -void ObjDora_Draw(Actor* thisx, GlobalContext* globalCtx); +void ObjDora_Init(Actor* thisx, PlayState* play); +void ObjDora_Destroy(Actor* thisx, PlayState* play); +void ObjDora_Update(Actor* thisx, PlayState* play); +void ObjDora_Draw(Actor* thisx, PlayState* play); + +void ObjDora_SetupWait(ObjDora* this); +void ObjDora_Wait(ObjDora* this, PlayState* play); +void ObjDora_SetupMoveGong(ObjDora* this); +void ObjDora_MoveGong(ObjDora* this, PlayState* play); +s32 ObjDora_IsHalfHour(u16 time); +void ObjDora_UpdateCollision(ObjDora* this, PlayState* play); + +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; -#if 0 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, + }, + ARRAY_COUNT(sTrisElementsInit), + 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, PlayState* play) { + 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(play, &this->colliderTris); + Collider_SetTris(play, &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, PlayState* play) { + ObjDora* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Dora/func_80B60CC0.s") + Collider_DestroyTris(play, &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, PlayState* play) { +} -#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, PlayState* play) { -#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, PlayState* play) { + 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, play, 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(play, &this->actor.world.pos, ITEM00_RUPEE_BLUE); + itemDrop->world.rot.y = this->actor.world.rot.y; + itemDrop->world.rot.y += (s32)(Rand_Centered() * 90.0f * (0x10000 / 360.0f)); + itemDrop->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(play, &play->colChkCtx, &this->colliderTris.base); + } +} + +void ObjDora_Update(Actor* thisx, PlayState* play) { + ObjDora* this = THIS; + + this->actionFunc(this, play); + ObjDora_UpdateCollision(this, play); +} + +void ObjDora_Draw(Actor* thisx, PlayState* play) { + static Vec3f position = { 0.0f, -61.5f, 0.0f }; + ObjDora* this = THIS; + f32 gongForceX; + + OPEN_DISPS(play->state.gfxCtx); + func_8012C28C(play->state.gfxCtx); + + if (this->actionFunc == ObjDora_MoveGong) { + gongForceX = this->gongForce.x; + if ((play->state.frames % 2) != 0) { + gongForceX *= -1.0f; + } + + Matrix_Push(); + Matrix_RotateXS(this->gongRotation.x, MTXMODE_APPLY); + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_OPA_DISP++, &gDoraGongDL); + + Matrix_Translate(position.x, position.y + gongForceX, position.z + gongForceX, MTXMODE_APPLY); + Matrix_RotateXS(this->gongRotation.z - this->gongRotation.x, MTXMODE_APPLY); + Matrix_Translate(-position.x, -position.y, -position.z, MTXMODE_APPLY); + + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_OPA_DISP++, &gDoraChainDL); + + Matrix_Pop(); + } else { + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_OPA_DISP++, &gDoraChainDL); + gSPDisplayList(POLY_OPA_DISP++, &gDoraGongDL); + } + + CLOSE_DISPS(play->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..ece93f627 100644 --- a/src/overlays/actors/ovl_Obj_Dora/z_obj_dora.h +++ b/src/overlays/actors/ovl_Obj_Dora/z_obj_dora.h @@ -5,13 +5,20 @@ struct ObjDora; -typedef void (*ObjDoraActionFunc)(struct ObjDora*, GlobalContext*); +typedef void (*ObjDoraActionFunc)(struct ObjDora*, PlayState*); typedef struct ObjDora { - /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x248]; - /* 0x038C */ ObjDoraActionFunc actionFunc; - /* 0x0390 */ char unk_390[0x1C]; + /* 0x000 */ Actor actor; + /* 0x144 */ ColliderTris colliderTris; + /* 0x164 */ ColliderTrisElement colliderTrisElements[6]; + /* 0x38C */ ObjDoraActionFunc actionFunc; + /* 0x390 */ Vec3f gongForce; + /* 0x39C */ Vec2s gongAngle; + /* 0x3A0 */ s16 lastGongHitType; + /* 0x3A2 */ Vec2s gongRotation; // gongAngle * gongForce. Used in ObjDora_Draw. + /* 0x3A6 */ s16 rupeeDropTimer; + /* 0x3A8 */ s16 collisionCooldownTimer; + /* 0x3AA */ s16 unk3AA; // Set but not used } ObjDora; // size = 0x3AC extern const ActorInit Obj_Dora_InitVars; diff --git a/src/overlays/actors/ovl_Obj_Dowsing/z_obj_dowsing.c b/src/overlays/actors/ovl_Obj_Dowsing/z_obj_dowsing.c index dbc945109..cbbdf82ed 100644 --- a/src/overlays/actors/ovl_Obj_Dowsing/z_obj_dowsing.c +++ b/src/overlays/actors/ovl_Obj_Dowsing/z_obj_dowsing.c @@ -10,12 +10,12 @@ #define THIS ((ObjDowsing*)thisx) -void ObjDowsing_Init(Actor* thisx, GlobalContext* globalCtx); -void ObjDowsing_Destroy(Actor* thisx, GlobalContext* globalCtx); -void ObjDowsing_Update(Actor* thisx, GlobalContext* globalCtx); +void ObjDowsing_Init(Actor* thisx, PlayState* play); +void ObjDowsing_Destroy(Actor* thisx, PlayState* play); +void ObjDowsing_Update(Actor* thisx, PlayState* play); -s32 ObjDowsing_GetFlag(ObjDowsing* this, GlobalContext* globalCtx); -s32 ObjDowsing_CheckValidSpawn(ObjDowsing* this, GlobalContext* globalCtx); +s32 ObjDowsing_GetFlag(ObjDowsing* this, PlayState* play); +s32 ObjDowsing_CheckValidSpawn(ObjDowsing* this, PlayState* play); const ActorInit Obj_Dowsing_InitVars = { ACTOR_OBJ_DOWSING, @@ -29,42 +29,42 @@ const ActorInit Obj_Dowsing_InitVars = { (ActorFunc)NULL, }; -s32 ObjDowsing_GetFlag(ObjDowsing* this, GlobalContext* globalCtx) { +s32 ObjDowsing_GetFlag(ObjDowsing* this, PlayState* play) { s32 type = DOWSING_GET_TYPE(&this->actor); s32 flag = DOWSING_GET_FLAG(&this->actor); if (type == DOWSING_COLLECTIBLE) { - return Flags_GetCollectible(globalCtx, flag); + return Flags_GetCollectible(play, flag); } else if (type == DOWSING_CHEST) { - return Flags_GetTreasure(globalCtx, flag); + return Flags_GetTreasure(play, flag); } else if (type == DOWSING_SWITCH) { - return Flags_GetSwitch(globalCtx, flag); + return Flags_GetSwitch(play, flag); } else { return 0; } } -s32 ObjDowsing_CheckValidSpawn(ObjDowsing* this, GlobalContext* globalCtx) { - if (ObjDowsing_GetFlag(this, globalCtx)) { +s32 ObjDowsing_CheckValidSpawn(ObjDowsing* this, PlayState* play) { + if (ObjDowsing_GetFlag(this, play)) { Actor_MarkForDeath(&this->actor); return true; } return false; } -void ObjDowsing_Init(Actor* thisx, GlobalContext* globalCtx) { +void ObjDowsing_Init(Actor* thisx, PlayState* play) { ObjDowsing* this = THIS; - ObjDowsing_CheckValidSpawn(this, globalCtx); + ObjDowsing_CheckValidSpawn(this, play); } -void ObjDowsing_Destroy(Actor* thisx, GlobalContext* globalCtx) { +void ObjDowsing_Destroy(Actor* thisx, PlayState* play) { } -void ObjDowsing_Update(Actor* thisx, GlobalContext* globalCtx) { +void ObjDowsing_Update(Actor* thisx, PlayState* play) { ObjDowsing* this = THIS; - if (!ObjDowsing_CheckValidSpawn(this, globalCtx)) { - func_800B8C50(thisx, globalCtx); + if (!ObjDowsing_CheckValidSpawn(this, play)) { + func_800B8C50(thisx, play); } } diff --git a/src/overlays/actors/ovl_Obj_Driftice/z_obj_driftice.c b/src/overlays/actors/ovl_Obj_Driftice/z_obj_driftice.c index abd30b256..5db059252 100644 --- a/src/overlays/actors/ovl_Obj_Driftice/z_obj_driftice.c +++ b/src/overlays/actors/ovl_Obj_Driftice/z_obj_driftice.c @@ -11,19 +11,19 @@ #define THIS ((ObjDriftice*)thisx) -void ObjDriftice_Init(Actor* thisx, GlobalContext* globalCtx); -void ObjDriftice_Destroy(Actor* thisx, GlobalContext* globalCtx); -void ObjDriftice_Update(Actor* thisx, GlobalContext* globalCtx); -void ObjDriftice_Draw(Actor* thisx, GlobalContext* globalCtx); +void ObjDriftice_Init(Actor* thisx, PlayState* play); +void ObjDriftice_Destroy(Actor* thisx, PlayState* play); +void ObjDriftice_Update(Actor* thisx, PlayState* play); +void ObjDriftice_Draw(Actor* thisx, PlayState* play); void func_80A671A8(ObjDriftice* this); -void func_80A671BC(ObjDriftice* this, GlobalContext* globalCtx); +void func_80A671BC(ObjDriftice* this, PlayState* play); void func_80A671CC(ObjDriftice* this); -void func_80A671E0(ObjDriftice* this, GlobalContext* globalCtx); +void func_80A671E0(ObjDriftice* this, PlayState* play); void func_80A6743C(ObjDriftice* this); -void func_80A67450(ObjDriftice* this, GlobalContext* globalCtx); +void func_80A67450(ObjDriftice* this, PlayState* play); void func_80A674A8(ObjDriftice* this); -void func_80A674C4(ObjDriftice* this, GlobalContext* globalCtx); +void func_80A674C4(ObjDriftice* this, PlayState* play); const ActorInit Obj_Driftice_InitVars = { ACTOR_OBJ_DRIFTICE, @@ -148,7 +148,6 @@ f32 func_80A667F0(ObjDrifticeStruct3* arg0, ObjDriftice* this) { return temp_f20; } -#ifdef NON_MATCHING void func_80A66930(ObjDrifticeStruct2* arg0, ObjDriftice* this, s16* arg2, s16* arg3) { ObjDrifticeStruct3* temp_s0; f32 temp_f22 = 0.0f; @@ -157,6 +156,7 @@ void func_80A66930(ObjDrifticeStruct2* arg0, ObjDriftice* this, s16* arg2, s16* if (this->unk_248 > 0) { f32 temp_f20 = this->dyna.actor.xzDistToPlayer * this->unk_240 * 0.0007075472f; + if (temp_f20 > 1.0f) { temp_f20 = 1.0f; } else if (temp_f20 < 0.01f) { @@ -195,11 +195,9 @@ void func_80A66930(ObjDrifticeStruct2* arg0, ObjDriftice* this, s16* arg2, s16* temp_f22 *= arg0->unk_08; - *arg2 = (s32)temp_f22 + arg0->unk_00[2]; + //! FAKE: + *arg2 = arg0->unk_00[2] + (s32)((void)0, temp_f22); } -#else -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Driftice/func_80A66930.s") -#endif void func_80A66C4C(ObjDrifticeStruct4* arg0, ObjDriftice* this, s16* arg2, s16* arg3) { ObjDrifticeStruct3* temp_s0; @@ -266,7 +264,7 @@ void func_80A66E30(ObjDrifticeStruct* arg0, ObjDriftice* this) { func_80A665AC(&this->dyna.actor.shape.rot.z, 0xA28); } -void ObjDriftice_Init(Actor* thisx, GlobalContext* globalCtx) { +void ObjDriftice_Init(Actor* thisx, PlayState* play) { s32 pad; ObjDriftice* this = THIS; f32* sp2C = D_80A67620[OBJDRIFTICE_GET_3(&this->dyna.actor)]; @@ -304,14 +302,14 @@ void ObjDriftice_Init(Actor* thisx, GlobalContext* globalCtx) { } DynaPolyActor_Init(&this->dyna, phi_a1); - DynaPolyActor_LoadMesh(globalCtx, &this->dyna, &object_driftice_Colheader_001AA8); + DynaPolyActor_LoadMesh(play, &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)]; + path = &play->setupPathList[OBJDRIFTICE_GET_1FC(&this->dyna.actor)]; this->unk_164 = 0; this->unk_160 = path->count - 1; this->unk_168 = 1; @@ -322,38 +320,36 @@ void ObjDriftice_Init(Actor* thisx, GlobalContext* globalCtx) { } } -void ObjDriftice_Destroy(Actor* thisx, GlobalContext* globalCtx) { +void ObjDriftice_Destroy(Actor* thisx, PlayState* play) { ObjDriftice* this = THIS; - DynaPoly_DeleteBgActor(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); + DynaPoly_DeleteBgActor(play, &play->colCtx.dyna, this->dyna.bgId); } void func_80A671A8(ObjDriftice* this) { this->actionFunc = func_80A671BC; } -void func_80A671BC(ObjDriftice* this, GlobalContext* globalCtx) { +void func_80A671BC(ObjDriftice* this, PlayState* play) { } void func_80A671CC(ObjDriftice* this) { this->actionFunc = func_80A671E0; } -#ifdef NON_MATCHING -// stack -void func_80A671E0(ObjDriftice* this, GlobalContext* globalCtx) { +void func_80A671E0(ObjDriftice* this, PlayState* play) { f32 phi_f0; Vec3f sp40; f32 sp3C; f32 phi_f12; Vec3s* points; s32 sp30; - Vec3s* points2; + 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, &this->dyna.actor.velocity); + Math_Vec3f_Diff(&sp40, &this->dyna.actor.world.pos, &thisx->velocity); - sp3C = Math3D_Vec3fMagnitude(&this->dyna.actor.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; @@ -390,10 +386,10 @@ void func_80A671E0(ObjDriftice* this, GlobalContext* globalCtx) { this->unk_164 = this->unk_160; } - points2 = &this->unk_16C[0]; - if ((points2->x != points->x) || (points2->y != points->y) || (points2->z != points->z)) { + 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); + func_800C62BC(play, &play->colCtx.dyna, this->dyna.bgId); sp30 = false; } } @@ -404,18 +400,15 @@ void func_80A671E0(ObjDriftice* this, GlobalContext* globalCtx) { } } } -#else -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Driftice/func_80A671E0.s") -#endif void func_80A6743C(ObjDriftice* this) { this->actionFunc = func_80A67450; } -void func_80A67450(ObjDriftice* this, GlobalContext* globalCtx) { +void func_80A67450(ObjDriftice* this, PlayState* play) { if (this->unk_248 < 0) { func_80A66570(this, this->unk_164); - func_800C6314(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); + func_800C6314(play, &play->colCtx.dyna, this->dyna.bgId); func_80A671CC(this); } } @@ -425,7 +418,7 @@ void func_80A674A8(ObjDriftice* this) { this->actionFunc = func_80A674C4; } -void func_80A674C4(ObjDriftice* this, GlobalContext* globalCtx) { +void func_80A674C4(ObjDriftice* this, PlayState* play) { this->unk_24C--; if (this->unk_24C <= 0) { this->dyna.actor.speedXZ = 0.0f; @@ -433,7 +426,7 @@ void func_80A674C4(ObjDriftice* this, GlobalContext* globalCtx) { } } -void ObjDriftice_Update(Actor* thisx, GlobalContext* globalCtx) { +void ObjDriftice_Update(Actor* thisx, PlayState* play) { ObjDriftice* this = THIS; if (DynaPolyActor_IsInRidingMovingState(&this->dyna)) { @@ -452,15 +445,15 @@ void ObjDriftice_Update(Actor* thisx, GlobalContext* globalCtx) { this->dyna.actor.shape.rot.y += this->unk_244; - this->actionFunc(this, globalCtx); + this->actionFunc(this, play); 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) { +void ObjDriftice_Draw(Actor* thisx, PlayState* play) { ObjDriftice* this = THIS; - Gfx_DrawDListOpa(globalCtx, object_driftice_DL_0016A0); + Gfx_DrawDListOpa(play, 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 190fbdcb6..e2f37350a 100644 --- a/src/overlays/actors/ovl_Obj_Driftice/z_obj_driftice.h +++ b/src/overlays/actors/ovl_Obj_Driftice/z_obj_driftice.h @@ -5,7 +5,7 @@ struct ObjDriftice; -typedef void (*ObjDrifticeActionFunc)(struct ObjDriftice*, GlobalContext*); +typedef void (*ObjDrifticeActionFunc)(struct ObjDriftice*, PlayState*); #define OBJDRIFTICE_GET_3(thisx) ((thisx)->params & 3) #define OBJDRIFTICE_GET_1FC(thisx) (((thisx)->params >> 2) & 0x7F) @@ -42,18 +42,18 @@ typedef struct { } ObjDrifticeStruct; // size = 0xCC typedef struct ObjDriftice { - /* 0x0000 */ DynaPolyActor dyna; - /* 0x015C */ ObjDrifticeActionFunc actionFunc; - /* 0x0160 */ s32 unk_160; - /* 0x0164 */ s32 unk_164; - /* 0x0168 */ s32 unk_168; - /* 0x016C */ Vec3s* unk_16C; - /* 0x0170 */ ObjDrifticeStruct unk_170; - /* 0x023C */ f32 unk_23C; - /* 0x0240 */ f32 unk_240; - /* 0x0244 */ s16 unk_244; - /* 0x0248 */ s32 unk_248; - /* 0x024C */ s32 unk_24C; + /* 0x000 */ DynaPolyActor dyna; + /* 0x15C */ ObjDrifticeActionFunc actionFunc; + /* 0x160 */ s32 unk_160; + /* 0x164 */ s32 unk_164; + /* 0x168 */ s32 unk_168; + /* 0x16C */ Vec3s* unk_16C; + /* 0x170 */ ObjDrifticeStruct unk_170; + /* 0x23C */ f32 unk_23C; + /* 0x240 */ f32 unk_240; + /* 0x244 */ s16 unk_244; + /* 0x248 */ s32 unk_248; + /* 0x24C */ s32 unk_24C; } ObjDriftice; // size = 0x250 extern const ActorInit Obj_Driftice_InitVars; diff --git a/src/overlays/actors/ovl_Obj_Ending/z_obj_ending.c b/src/overlays/actors/ovl_Obj_Ending/z_obj_ending.c index 5109cf284..d2da273b5 100644 --- a/src/overlays/actors/ovl_Obj_Ending/z_obj_ending.c +++ b/src/overlays/actors/ovl_Obj_Ending/z_obj_ending.c @@ -11,9 +11,9 @@ #define THIS ((ObjEnding*)thisx) -void ObjEnding_Init(Actor* thisx, GlobalContext* globalCtx); -void ObjEnding_Update(Actor* thisx, GlobalContext* globalCtx); -void ObjEnding_Draw(Actor* thisx, GlobalContext* globalCtx); +void ObjEnding_Init(Actor* thisx, PlayState* play); +void ObjEnding_Update(Actor* thisx, PlayState* play); +void ObjEnding_Draw(Actor* thisx, PlayState* play); const ActorInit Obj_Ending_InitVars = { ACTOR_OBJ_ENDING, @@ -36,7 +36,7 @@ static InitChainEntry sInitChain[] = { ICHAIN_VEC3F_DIV1000(scale, 100, ICHAIN_STOP), }; -void ObjEnding_Init(Actor* thisx, GlobalContext* globalCtx) { +void ObjEnding_Init(Actor* thisx, PlayState* play) { ObjEnding* this = THIS; AnimatedMaterial* animMat; @@ -48,23 +48,23 @@ void ObjEnding_Init(Actor* thisx, GlobalContext* globalCtx) { } } -void ObjEnding_Update(Actor* thisx, GlobalContext* globalCtx) { +void ObjEnding_Update(Actor* thisx, PlayState* play) { } -void ObjEnding_Draw(Actor* thisx, GlobalContext* globalCtx) { +void ObjEnding_Draw(Actor* thisx, PlayState* play) { ObjEnding* this = THIS; Gfx* dl1; Gfx* dl2; if (this->animMat != NULL) { - AnimatedMat_Draw(globalCtx, this->animMat); + AnimatedMat_Draw(play, this->animMat); } dl1 = this->modelInfo->dLists[0]; if (dl1 != NULL) { - Gfx_DrawDListOpa(globalCtx, dl1); + Gfx_DrawDListOpa(play, dl1); } dl2 = this->modelInfo->dLists[1]; if (dl2 != NULL) { - Gfx_DrawDListXlu(globalCtx, dl2); + Gfx_DrawDListXlu(play, dl2); } } 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 8ed237927..cd7106240 100644 --- a/src/overlays/actors/ovl_Obj_Entotu/z_obj_entotu.c +++ b/src/overlays/actors/ovl_Obj_Entotu/z_obj_entotu.c @@ -11,10 +11,10 @@ #define THIS ((ObjEntotu*)thisx) -void ObjEntotu_Init(Actor* thisx, GlobalContext* globalCtx); -void ObjEntotu_Destroy(Actor* thisx, GlobalContext* globalCtx); -void ObjEntotu_Update(Actor* thisx, GlobalContext* globalCtx); -void ObjEntotu_Draw(Actor* thisx, GlobalContext* globalCtx); +void ObjEntotu_Init(Actor* thisx, PlayState* play); +void ObjEntotu_Destroy(Actor* thisx, PlayState* play); +void ObjEntotu_Update(Actor* thisx, PlayState* play); +void ObjEntotu_Draw(Actor* thisx, PlayState* play); const ActorInit Obj_Entotu_InitVars = { ACTOR_OBJ_ENTOTU, @@ -96,23 +96,23 @@ void func_80A349C0(ObjEntotu* this) { Math_ApproachF(&this->unk_1B8.x, (temp2 == 0) ? 0.0f : 1.0f, 0.02f, 1000.0f); } -void func_80A34A44(ObjEntotu* this, GlobalContext* globalCtx) { - Matrix_InsertTranslation(this->actor.world.pos.x, this->actor.world.pos.y, this->actor.world.pos.z, MTXMODE_NEW); - this->actor.shape.rot.y = BINANG_ROT180(Camera_GetCamDirYaw(GET_ACTIVE_CAM(globalCtx))); - Matrix_RotateY(this->actor.shape.rot.y, MTXMODE_APPLY); +void func_80A34A44(ObjEntotu* this, PlayState* play) { + 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(play))); + Matrix_RotateYS(this->actor.shape.rot.y, MTXMODE_APPLY); Matrix_Scale(0.1f, 0.1f, 0.0f, MTXMODE_APPLY); - OPEN_DISPS(globalCtx->state.gfxCtx); + OPEN_DISPS(play->state.gfxCtx); - func_8012C28C(globalCtx->state.gfxCtx); + func_8012C28C(play->state.gfxCtx); - gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_OPA_DISP++, object_f53_obj_DL_000158); - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->state.gfxCtx); } -void func_80A34B28(ObjEntotu* this, GlobalContext* globalCtx) { +void func_80A34B28(ObjEntotu* this, PlayState* play) { u8 sp57; u8 sp56; s32 i; @@ -129,27 +129,26 @@ void func_80A34B28(ObjEntotu* this, GlobalContext* globalCtx) { } if (this->unk_1B8.x > 0.0f) { - Matrix_InsertTranslation(this->actor.world.pos.x, this->actor.world.pos.y, this->actor.world.pos.z, - MTXMODE_NEW); - this->actor.shape.rot.y = BINANG_ROT180(Camera_GetCamDirYaw(GET_ACTIVE_CAM(globalCtx))); - Matrix_RotateY(this->actor.shape.rot.y, MTXMODE_APPLY); + Matrix_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(play))); + Matrix_RotateYS(this->actor.shape.rot.y, MTXMODE_APPLY); Matrix_Scale(0.1f, 0.1f, 0.0f, MTXMODE_APPLY); - OPEN_DISPS(globalCtx->state.gfxCtx); + OPEN_DISPS(play->state.gfxCtx); - func_8012C28C(globalCtx->state.gfxCtx); + func_8012C28C(play->state.gfxCtx); gSPSegment(POLY_XLU_DISP++, 0x08, - Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, 0, sp57, 0x20, 0x20, 1, 0, sp56, 0x20, 0x20)); + Gfx_TwoTexScroll(play->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); + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_XLU_DISP++, object_f53_obj_DL_001C00); - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->state.gfxCtx); } } -void ObjEntotu_Init(Actor* thisx, GlobalContext* globalCtx) { +void ObjEntotu_Init(Actor* thisx, PlayState* play) { ObjEntotu* this = THIS; Lib_MemCpy(this->unk_148, ovl_Obj_Entotu_Vtx_000D10, sizeof(ovl_Obj_Entotu_Vtx_000D10)); @@ -157,18 +156,18 @@ void ObjEntotu_Init(Actor* thisx, GlobalContext* globalCtx) { this->unk_1C4 = 0; } -void ObjEntotu_Destroy(Actor* thisx, GlobalContext* globalCtx) { +void ObjEntotu_Destroy(Actor* thisx, PlayState* play) { } -void ObjEntotu_Update(Actor* thisx, GlobalContext* globalCtx) { +void ObjEntotu_Update(Actor* thisx, PlayState* play) { ObjEntotu* this = THIS; func_80A349C0(this); } -void ObjEntotu_Draw(Actor* thisx, GlobalContext* globalCtx) { +void ObjEntotu_Draw(Actor* thisx, PlayState* play) { ObjEntotu* this = THIS; - func_80A34B28(this, globalCtx); - func_80A34A44(this, globalCtx); + func_80A34B28(this, play); + func_80A34A44(this, play); } 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 eb91a93d4..f8a7d38d7 100644 --- a/src/overlays/actors/ovl_Obj_Etcetera/z_obj_etcetera.c +++ b/src/overlays/actors/ovl_Obj_Etcetera/z_obj_etcetera.c @@ -5,21 +5,20 @@ */ #include "z_obj_etcetera.h" -#include "objects/gameplay_keep/gameplay_keep.h" #define FLAGS (ACTOR_FLAG_10) #define THIS ((ObjEtcetera*)thisx) -void ObjEtcetera_Init(Actor* thisx, GlobalContext* globalCtx); -void ObjEtcetera_Destroy(Actor* thisx, GlobalContext* globalCtx); -void ObjEtcetera_Update(Actor* thisx, GlobalContext* globalCtx); +void ObjEtcetera_Init(Actor* thisx, PlayState* play); +void ObjEtcetera_Destroy(Actor* thisx, PlayState* play); +void ObjEtcetera_Update(Actor* thisx, PlayState* play); -void ObjEtcetera_PlayRustleAnimation(ObjEtcetera* this, GlobalContext* globalCtx); -void ObjEtcetera_DoBounceOscillation(ObjEtcetera* this, GlobalContext* globalCtx); -void ObjEtcetera_Setup(ObjEtcetera* this, GlobalContext* globalCtx); -void ObjEtcetera_DrawIdle(Actor* thisx, GlobalContext* globalCtx); -void ObjEtcetera_DrawAnimated(Actor* thisx, GlobalContext* globalCtx); +void ObjEtcetera_PlayRustleAnimation(ObjEtcetera* this, PlayState* play); +void ObjEtcetera_DoBounceOscillation(ObjEtcetera* this, PlayState* play); +void ObjEtcetera_Setup(ObjEtcetera* this, PlayState* play); +void ObjEtcetera_DrawIdle(Actor* thisx, PlayState* play); +void ObjEtcetera_DrawAnimated(Actor* thisx, PlayState* play); const ActorInit Obj_Etcetera_InitVars = { ACTOR_OBJ_ETCETERA, @@ -69,7 +68,7 @@ static f32 oscillationTable[] = { -1.0, -1.0, -1.0, -0.7, 0.0, 0.7, 1.0, 0.7, 0.0, -0.7, -1.0, -0.7, 0.0, 0.7, 1.0, 0.7, 0.0, -0.7, }; -void ObjEtcetera_Init(Actor* thisx, GlobalContext* globalCtx) { +void ObjEtcetera_Init(Actor* thisx, PlayState* play) { s32 pad; ObjEtcetera* this = THIS; s32 objectIndex; @@ -80,16 +79,18 @@ void ObjEtcetera_Init(Actor* thisx, GlobalContext* globalCtx) { if ((type < DEKU_FLOWER_TYPE_PINK) || (type >= DEKU_FLOWER_TYPE_MAX)) { type = DEKU_FLOWER_TYPE_PINK; } - objectIndex = Object_GetIndex(&globalCtx->objectCtx, objectIds[type]); + + objectIndex = Object_GetIndex(&play->objectCtx, objectIds[type]); if (objectIndex >= 0) { this->objIndex = objectIndex; } + pos.x = this->dyna.actor.world.pos.x; pos.y = this->dyna.actor.world.pos.y + 10.0f; pos.z = this->dyna.actor.world.pos.z; - BgCheck_EntityRaycastFloor5(&globalCtx->colCtx, &this->dyna.actor.floorPoly, &floorBgId, &this->dyna.actor, &pos); + BgCheck_EntityRaycastFloor5(&play->colCtx, &this->dyna.actor.floorPoly, &floorBgId, &this->dyna.actor, &pos); this->dyna.actor.floorBgId = floorBgId; - Collider_InitAndSetCylinder(globalCtx, &this->collider, &this->dyna.actor, &sCylinderInit); + Collider_InitAndSetCylinder(play, &this->collider, &this->dyna.actor, &sCylinderInit); Collider_UpdateCylinder(&this->dyna.actor, &this->collider); this->actionFunc = ObjEtcetera_Setup; Actor_SetScale(&this->dyna.actor, 0.01f); @@ -97,11 +98,11 @@ void ObjEtcetera_Init(Actor* thisx, GlobalContext* globalCtx) { this->burrowFlag = 0; } -void ObjEtcetera_Destroy(Actor* thisx, GlobalContext* globalCtx) { +void ObjEtcetera_Destroy(Actor* thisx, PlayState* play) { ObjEtcetera* this = THIS; - DynaPoly_DeleteBgActor(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); - Collider_DestroyCylinder(globalCtx, &this->collider); + DynaPoly_DeleteBgActor(play, &play->colCtx.dyna, this->dyna.bgId); + Collider_DestroyCylinder(play, &this->collider); } /** @@ -109,12 +110,12 @@ void ObjEtcetera_Destroy(Actor* thisx, GlobalContext* globalCtx) { * where something interacts with it. When the player launches out of the flower, the * oscillation is handled by ObjEtcetera_DoBounceOscillation instead. */ -void ObjEtcetera_DoNormalOscillation(ObjEtcetera* this, GlobalContext* globalCtx) { +void ObjEtcetera_DoNormalOscillation(ObjEtcetera* this, PlayState* play) { if (this->oscillationTimer > 0) { s32 requiredScopeTemp; Actor_SetScale(&this->dyna.actor, - (oscillationTable[globalCtx->gameplayFrames % 18] * (0.0001f * this->oscillationTimer)) + 0.01f); + (oscillationTable[play->gameplayFrames % 18] * (0.0001f * this->oscillationTimer)) + 0.01f); this->dyna.actor.scale.y = 0.02f; this->oscillationTimer--; } else { @@ -125,19 +126,19 @@ void ObjEtcetera_DoNormalOscillation(ObjEtcetera* this, GlobalContext* globalCtx void ObjEtcetera_StartRustleAnimation(ObjEtcetera* this) { Animation_Change(&this->skelAnime, &gDekuFlowerRustleAnim, 1.0f, 0.0f, - Animation_GetLastFrame(&gDekuFlowerRustleAnim), 2, 0.0f); + Animation_GetLastFrame(&gDekuFlowerRustleAnim), ANIMMODE_ONCE, 0.0f); this->dyna.actor.draw = ObjEtcetera_DrawAnimated; this->actionFunc = ObjEtcetera_PlayRustleAnimation; } -void ObjEtcetera_Idle(ObjEtcetera* this, GlobalContext* globalCtx) { +void ObjEtcetera_Idle(ObjEtcetera* this, PlayState* play) { s16 minOscillationTimer; - Player* player = GET_PLAYER(globalCtx); + Player* player = GET_PLAYER(play); if ((player->stateFlags3 & 0x200) && (this->dyna.actor.xzDistToPlayer < 20.0f)) { // Player is launching out of the Deku Flower Animation_Change(&this->skelAnime, &gDekuFlowerBounceAnim, 1.0f, 0.0f, - Animation_GetLastFrame(&gDekuFlowerBounceAnim), 2, 0.0f); + Animation_GetLastFrame(&gDekuFlowerBounceAnim), ANIMMODE_ONCE, 0.0f); this->dyna.actor.draw = ObjEtcetera_DrawAnimated; this->actionFunc = ObjEtcetera_DoBounceOscillation; Actor_SetScale(&this->dyna.actor, 0.01f); @@ -163,6 +164,7 @@ void ObjEtcetera_Idle(ObjEtcetera* this, GlobalContext* globalCtx) { // start of launching this->oscillationTimer = 10; } + this->burrowFlag |= 1; } else { if (this->burrowFlag & 1) { @@ -170,27 +172,32 @@ void ObjEtcetera_Idle(ObjEtcetera* this, GlobalContext* globalCtx) { this->oscillationTimer = 10; ObjEtcetera_StartRustleAnimation(this); } + this->burrowFlag &= ~1; } } + if ((this->collider.base.acFlags & AC_HIT)) { this->oscillationTimer = 10; ObjEtcetera_StartRustleAnimation(this); } - ObjEtcetera_DoNormalOscillation(this, globalCtx); + + ObjEtcetera_DoNormalOscillation(this, play); } -void ObjEtcetera_PlayRustleAnimation(ObjEtcetera* this, GlobalContext* globalCtx) { +void ObjEtcetera_PlayRustleAnimation(ObjEtcetera* this, PlayState* play) { if (DynaPolyActor_IsInRidingMovingState(&this->dyna)) { this->burrowFlag |= 1; } else { this->burrowFlag &= ~1; } + if (SkelAnime_Update(&this->skelAnime)) { this->dyna.actor.draw = ObjEtcetera_DrawIdle; this->actionFunc = ObjEtcetera_Idle; } - ObjEtcetera_DoNormalOscillation(this, globalCtx); + + ObjEtcetera_DoNormalOscillation(this, play); } /** @@ -198,7 +205,7 @@ void ObjEtcetera_PlayRustleAnimation(ObjEtcetera* this, GlobalContext* globalCtx * or because the flower spawned after killing a Mad Scrub), this function makes the * flower oscillate stronger than it normally does, including an oscillation on the Y-axis. */ -void ObjEtcetera_DoBounceOscillation(ObjEtcetera* this, GlobalContext* globalCtx) { +void ObjEtcetera_DoBounceOscillation(ObjEtcetera* this, PlayState* play) { // In order to match, we are seemingly required to access scale.x at one point // without using this. We can create a thisx or dyna pointer to achieve that, but // it's more likely they used dyna given that DynaPolyActor_IsInRidingMovingState takes a DynaPolyActor. @@ -210,7 +217,9 @@ void ObjEtcetera_DoBounceOscillation(ObjEtcetera* this, GlobalContext* globalCtx } else { this->burrowFlag &= ~1; } + SkelAnime_Update(&this->skelAnime); + if (this->oscillationTimer > 0) { this->oscillationTimer--; } else { @@ -222,6 +231,7 @@ void ObjEtcetera_DoBounceOscillation(ObjEtcetera* this, GlobalContext* globalCtx this->bounceOscillationScale = 0.0f; return; } + this->bounceOscillationScale *= 0.8f; this->bounceOscillationScale -= (this->dyna.actor.scale.x - 0.01f) * 0.4f; scaleTemp = dyna->actor.scale.x + this->bounceOscillationScale; @@ -229,7 +239,7 @@ void ObjEtcetera_DoBounceOscillation(ObjEtcetera* this, GlobalContext* globalCtx this->dyna.actor.scale.y = 2.0f * scaleTemp; } -void ObjEtcetera_Setup(ObjEtcetera* this, GlobalContext* globalCtx) { +void ObjEtcetera_Setup(ObjEtcetera* this, PlayState* play) { CollisionHeader* colHeader = NULL; s32 type; CollisionHeader* collisionHeaders[] = { @@ -246,29 +256,31 @@ void ObjEtcetera_Setup(ObjEtcetera* this, GlobalContext* globalCtx) { type = DEKU_FLOWER_TYPE_PINK; } - if (Object_IsLoaded(&globalCtx->objectCtx, this->objIndex)) { + if (Object_IsLoaded(&play->objectCtx, this->objIndex)) { this->dyna.actor.objBankIndex = this->objIndex; - Actor_SetObjectDependency(globalCtx, &this->dyna.actor); + Actor_SetObjectDependency(play, &this->dyna.actor); DynaPolyActor_Init(&this->dyna, 1); thisCollisionHeader = collisionHeaders[type]; - if (thisCollisionHeader != 0) { + if (thisCollisionHeader != NULL) { CollisionHeader_GetVirtual(thisCollisionHeader, &colHeader); } - this->dyna.bgId = DynaPoly_SetBgActor(globalCtx, &globalCtx->colCtx.dyna, &this->dyna.actor, colHeader); + + this->dyna.bgId = DynaPoly_SetBgActor(play, &play->colCtx.dyna, &this->dyna.actor, colHeader); type = DEKU_FLOWER_TYPE(&this->dyna.actor); switch (type) { case DEKU_FLOWER_TYPE_PINK: - case DEKU_FLOWER_TYPE_PINK_SPAWNED_FROM_MAD_SCRUB: - SkelAnime_Init(globalCtx, &this->skelAnime, &gPinkDekuFlowerSkel, &gDekuFlowerBounceAnim, - this->jointTable, this->morphTable, DEKU_FLOWER_LIMB_MAX); + case DEKU_FLOWER_TYPE_PINK_WITH_INITIAL_BOUNCE: + SkelAnime_Init(play, &this->skelAnime, &gPinkDekuFlowerSkel, &gDekuFlowerBounceAnim, this->jointTable, + this->morphTable, PINK_DEKU_FLOWER_LIMB_MAX); this->dList = gPinkDekuFlowerIdleDL; break; + case DEKU_FLOWER_TYPE_GOLD: - case DEKU_FLOWER_TYPE_GOLD_SPAWNED_FROM_MAD_SCRUB: + case DEKU_FLOWER_TYPE_GOLD_WITH_INITIAL_BOUNCE: this->dList = gGoldDekuFlowerIdleDL; - SkelAnime_Init(globalCtx, &this->skelAnime, &gGoldDekuFlowerSkel.sh, &gDekuFlowerBounceAnim, - this->jointTable, this->morphTable, DEKU_FLOWER_LIMB_MAX); + SkelAnime_Init(play, &this->skelAnime, &gGoldDekuFlowerSkel.sh, &gDekuFlowerBounceAnim, + this->jointTable, this->morphTable, GOLD_DEKU_FLOWER_LIMB_MAX); this->collider.dim.height = 20; break; } @@ -284,10 +296,11 @@ void ObjEtcetera_Setup(ObjEtcetera* this, GlobalContext* globalCtx) { this->dyna.actor.focus.pos.y = this->dyna.actor.home.pos.y + 10.0f; this->dyna.actor.targetMode = 3; break; - case DEKU_FLOWER_TYPE_PINK_SPAWNED_FROM_MAD_SCRUB: - case DEKU_FLOWER_TYPE_GOLD_SPAWNED_FROM_MAD_SCRUB: + + case DEKU_FLOWER_TYPE_PINK_WITH_INITIAL_BOUNCE: + case DEKU_FLOWER_TYPE_GOLD_WITH_INITIAL_BOUNCE: Animation_Change(&this->skelAnime, &gDekuFlowerBounceAnim, 1.0f, 0.0f, - Animation_GetLastFrame(&gDekuFlowerBounceAnim), 2, 0.0f); + Animation_GetLastFrame(&gDekuFlowerBounceAnim), ANIMMODE_ONCE, 0.0f); this->dyna.actor.draw = ObjEtcetera_DrawAnimated; this->actionFunc = ObjEtcetera_DoBounceOscillation; Actor_SetScale(&this->dyna.actor, 0.0f); @@ -300,7 +313,7 @@ void ObjEtcetera_Setup(ObjEtcetera* this, GlobalContext* globalCtx) { } } -void ObjEtcetera_Update(Actor* thisx, GlobalContext* globalCtx) { +void ObjEtcetera_Update(Actor* thisx, PlayState* play) { ObjEtcetera* this = THIS; CollisionPoly* floorPoly; u8 floorBgId = this->dyna.actor.floorBgId; @@ -308,11 +321,12 @@ void ObjEtcetera_Update(Actor* thisx, GlobalContext* globalCtx) { if (floorBgId == BGCHECK_SCENE) { floorPoly = this->dyna.actor.floorPoly; if (floorPoly != NULL && this->burrowFlag & 1) { - func_800FAAB4(globalCtx, SurfaceType_GetLightSettingIndex(&globalCtx->colCtx, floorPoly, floorBgId)); + func_800FAAB4(play, SurfaceType_GetLightSettingIndex(&play->colCtx, floorPoly, floorBgId)); } } - this->actionFunc(this, globalCtx); - CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + + this->actionFunc(this, play); + CollisionCheck_SetAC(play, &play->colChkCtx, &this->collider.base); } /** @@ -320,16 +334,16 @@ void ObjEtcetera_Update(Actor* thisx, GlobalContext* globalCtx) { * It draws the flower as a single, non-moving display list that encompasses the whole flower. * When an animation is finished, functions are expected to set the actor's draw function to this. */ -void ObjEtcetera_DrawIdle(Actor* thisx, GlobalContext* globalCtx) { +void ObjEtcetera_DrawIdle(Actor* thisx, PlayState* play) { ObjEtcetera* this = THIS; - OPEN_DISPS(globalCtx->state.gfxCtx); + OPEN_DISPS(play->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); + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + func_8012C28C(play->state.gfxCtx); gSPDisplayList(POLY_OPA_DISP++, this->dList); - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->state.gfxCtx); } /** @@ -337,9 +351,9 @@ void ObjEtcetera_DrawIdle(Actor* thisx, GlobalContext* globalCtx) { * It draws the flower as an animated bunch of limbs using the SkelAnime system. * When a function wants to play an animation, it is expected to set the actor's draw function to this. */ -void ObjEtcetera_DrawAnimated(Actor* thisx, GlobalContext* globalCtx) { +void ObjEtcetera_DrawAnimated(Actor* thisx, PlayState* play) { ObjEtcetera* this = THIS; - func_8012C5B0(globalCtx->state.gfxCtx); - SkelAnime_DrawOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, NULL, NULL, &this->dyna.actor); + func_8012C5B0(play->state.gfxCtx); + SkelAnime_DrawOpa(play, this->skelAnime.skeleton, this->skelAnime.jointTable, NULL, NULL, &this->dyna.actor); } diff --git a/src/overlays/actors/ovl_Obj_Etcetera/z_obj_etcetera.h b/src/overlays/actors/ovl_Obj_Etcetera/z_obj_etcetera.h index a52f5ae2e..33810ae06 100644 --- a/src/overlays/actors/ovl_Obj_Etcetera/z_obj_etcetera.h +++ b/src/overlays/actors/ovl_Obj_Etcetera/z_obj_etcetera.h @@ -2,47 +2,29 @@ #define Z_OBJ_ETCETERA_H #include "global.h" +#include "objects/gameplay_keep/gameplay_keep.h" #define DEKU_FLOWER_TYPE(thisx) (((thisx)->params & 0xFF80) >> 7) +#define DEKU_FLOWER_PARAMS(type) (((type) << 7) & 0xFF80) typedef enum { /* 0 */ DEKU_FLOWER_TYPE_PINK, - /* 1 */ DEKU_FLOWER_TYPE_PINK_SPAWNED_FROM_MAD_SCRUB, + /* 1 */ DEKU_FLOWER_TYPE_PINK_WITH_INITIAL_BOUNCE, /* 2 */ DEKU_FLOWER_TYPE_GOLD, - /* 3 */ DEKU_FLOWER_TYPE_GOLD_SPAWNED_FROM_MAD_SCRUB, + /* 3 */ DEKU_FLOWER_TYPE_GOLD_WITH_INITIAL_BOUNCE, /* 4 */ DEKU_FLOWER_TYPE_MAX, } DekuFlowerType; -/** - * For the petal/leaf directions, "back" is negative and "front" is positive - * on the flower's local Z-axis. "Left" and "right" are relative to the front - * and back. - */ -typedef enum { - /* 0 */ DEKU_FLOWER_LIMB_NONE, - /* 1 */ DEKU_FLOWER_LIMB_BASE, - /* 2 */ DEKU_FLOWER_LIMB_CENTER, - /* 3 */ DEKU_FLOWER_LIMB_BACK_PETAL_OR_LEAF, - /* 4 */ DEKU_FLOWER_LIMB_FRONT_PETAL_OR_LEAF, - /* 5 */ DEKU_FLOWER_LIMB_FRONT_RIGHT_PETAL, - /* 6 */ DEKU_FLOWER_LIMB_BACK_RIGHT_PETAL, - /* 7 */ DEKU_FLOWER_LIMB_RIGHT_PETAL_OR_LEAF, - /* 8 */ DEKU_FLOWER_LIMB_FRONT_LEFT_PETAL, - /* 9 */ DEKU_FLOWER_LIMB_LEFT_PETAL_OR_LEAF, - /* 10 */ DEKU_FLOWER_LIMB_BACK_LEFT_PETAL, - /* 11 */ DEKU_FLOWER_LIMB_MAX, -} DekuFlowerLimbs; - struct ObjEtcetera; -typedef void (*ObjEtceteraActionFunc)(struct ObjEtcetera*, GlobalContext*); +typedef void (*ObjEtceteraActionFunc)(struct ObjEtcetera*, PlayState*); typedef struct ObjEtcetera { /* 0x000 */ DynaPolyActor dyna; /* 0x15C */ SkelAnime skelAnime; /* 0x1A0 */ ColliderCylinder collider; - /* 0x1EC */ Vec3s jointTable[DEKU_FLOWER_LIMB_MAX]; - /* 0x22E */ Vec3s morphTable[DEKU_FLOWER_LIMB_MAX]; + /* 0x1EC */ Vec3s jointTable[PINK_DEKU_FLOWER_LIMB_MAX]; + /* 0x22E */ Vec3s morphTable[PINK_DEKU_FLOWER_LIMB_MAX]; /* 0x270 */ f32 bounceOscillationScale; /* 0x274 */ s16 oscillationTimer; /* 0x276 */ u16 burrowFlag; diff --git a/src/overlays/actors/ovl_Obj_Fireshield/z_obj_fireshield.c b/src/overlays/actors/ovl_Obj_Fireshield/z_obj_fireshield.c index 705dc93bf..54bd7966c 100644 --- a/src/overlays/actors/ovl_Obj_Fireshield/z_obj_fireshield.c +++ b/src/overlays/actors/ovl_Obj_Fireshield/z_obj_fireshield.c @@ -11,10 +11,10 @@ #define THIS ((ObjFireshield*)thisx) -void ObjFireshield_Init(Actor* thisx, GlobalContext* globalCtx); -void ObjFireshield_Destroy(Actor* thisx, GlobalContext* globalCtx); -void ObjFireshield_Update(Actor* thisx, GlobalContext* globalCtx); -void ObjFireshield_Draw(Actor* thisx, GlobalContext* globalCtx); +void ObjFireshield_Init(Actor* thisx, PlayState* play); +void ObjFireshield_Destroy(Actor* thisx, PlayState* play); +void ObjFireshield_Update(Actor* thisx, PlayState* play); +void ObjFireshield_Draw(Actor* thisx, PlayState* play); void func_80A4CABC(ObjFireshield* this); void func_80A4CB7C(ObjFireshield* this); @@ -138,10 +138,10 @@ void func_80A4CCBC(ObjFireshield* this) { void func_80A4CD28(ObjFireshield* this) { } -void func_80A4CD34(Actor* thisx, GlobalContext* globalCtx) { +void func_80A4CD34(Actor* thisx, PlayState* play) { s32 pad; ObjFireshield* this = THIS; - s32 sp24 = Flags_GetSwitch(globalCtx, OBJFIRESHIELD_GET_7F(&this->actor)); + s32 sp24 = Flags_GetSwitch(play, OBJFIRESHIELD_GET_7F(&this->actor)); s32 phi_v1; s32 phi_a0; @@ -150,11 +150,11 @@ void func_80A4CD34(Actor* thisx, GlobalContext* globalCtx) { phi_v1 = false; phi_a0 = false; } else { - phi_v1 = Flags_GetTreasure(globalCtx, OBJFIRESHIELD_GET_1F00(&this->actor)); + phi_v1 = Flags_GetTreasure(play, OBJFIRESHIELD_GET_1F00(&this->actor)); phi_a0 = false; } } else { - phi_a0 = Flags_GetSwitch(globalCtx, OBJFIRESHIELD_GET_3F80(&this->actor)); + phi_a0 = Flags_GetSwitch(play, OBJFIRESHIELD_GET_3F80(&this->actor)); phi_v1 = false; } @@ -173,7 +173,7 @@ void func_80A4CD34(Actor* thisx, GlobalContext* globalCtx) { } } -void func_80A4CE28(ObjFireshield* this, GlobalContext* globalCtx) { +void func_80A4CE28(ObjFireshield* this, PlayState* play) { s32 pad; s32 sp30 = OBJFIRESHIELD_GET_7F(&this->actor); s32 pad2[2]; @@ -185,23 +185,23 @@ void func_80A4CE28(ObjFireshield* this, GlobalContext* globalCtx) { sp24 = false; sp20 = false; } else { - sp24 = Flags_GetTreasure(globalCtx, OBJFIRESHIELD_GET_1F00(&this->actor)); + sp24 = Flags_GetTreasure(play, OBJFIRESHIELD_GET_1F00(&this->actor)); sp20 = false; } } else { - sp20 = Flags_GetSwitch(globalCtx, OBJFIRESHIELD_GET_3F80(&this->actor)); + sp20 = Flags_GetSwitch(play, OBJFIRESHIELD_GET_3F80(&this->actor)); sp24 = false; } if (!sp24 || !sp20 || (this->unk_19C != 0)) { - s32 sp1C = Flags_GetSwitch(globalCtx, sp30); + s32 sp1C = Flags_GetSwitch(play, 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); + Flags_UnsetSwitch(play, sp30); sp1C = false; } } @@ -267,7 +267,7 @@ void func_80A4D1CC(void) { D_80A4D864[3] = 0; } -void ObjFireshield_Init(Actor* thisx, GlobalContext* globalCtx) { +void ObjFireshield_Init(Actor* thisx, PlayState* play) { ObjFireshield* this = THIS; s32 temp = 0x8000; ObjFireshieldStruct* sp2C = &D_80A4D84C[OBJFIRESHIELD_GET_C000(&this->actor)]; @@ -297,24 +297,24 @@ void ObjFireshield_Init(Actor* thisx, GlobalContext* globalCtx) { this->actor.home.rot.z = -thisx->home.rot.z; } - Collider_InitCylinder(globalCtx, &this->collider); - Collider_SetCylinder(globalCtx, &this->collider, &this->actor, &sCylinderInit); + Collider_InitCylinder(play, &this->collider); + Collider_SetCylinder(play, &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); + func_80A4CD34(&this->actor, play); this->actionFunc = func_80A4CD28; } -void ObjFireshield_Destroy(Actor* thisx, GlobalContext* globalCtx) { +void ObjFireshield_Destroy(Actor* thisx, PlayState* play) { ObjFireshield* this = THIS; - Collider_DestroyCylinder(globalCtx, &this->collider); + Collider_DestroyCylinder(play, &this->collider); } -void ObjFireshield_Update(Actor* thisx, GlobalContext* globalCtx) { +void ObjFireshield_Update(Actor* thisx, PlayState* play) { ObjFireshield* this = THIS; ObjFireshield* this2 = THIS; s32 sp44 = OBJFIRESHIELD_GET_ROTX(&this->actor); @@ -342,17 +342,17 @@ void ObjFireshield_Update(Actor* thisx, GlobalContext* globalCtx) { 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_800B8D98(play, &this->actor, 5.0f, this->actor.yawTowardsPlayer, 1.0f); } - func_80A4CE28(this, globalCtx); + func_80A4CE28(this, play); 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); + Player* player = GET_PLAYER(play); this->collider.dim.height = this->unk_198 * 80.0f; @@ -374,25 +374,25 @@ void ObjFireshield_Update(Actor* thisx, GlobalContext* globalCtx) { } Collider_UpdateCylinder(&this->actor, &this->collider); - CollisionCheck_SetAT(globalCtx, &globalCtx->colChkCtx, &this->collider.base); - CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + CollisionCheck_SetAT(play, &play->colChkCtx, &this->collider.base); + CollisionCheck_SetOC(play, &play->colChkCtx, &this->collider.base); } } -void ObjFireshield_Draw(Actor* thisx, GlobalContext* globalCtx) { +void ObjFireshield_Draw(Actor* thisx, PlayState* play) { ObjFireshield* this = THIS; - OPEN_DISPS(globalCtx->state.gfxCtx); + OPEN_DISPS(play->state.gfxCtx); - func_8012C2DC(globalCtx->state.gfxCtx); + func_8012C2DC(play->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, + Gfx_TwoTexScroll(play->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); + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_XLU_DISP++, gameplay_keep_DL_02E510); - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->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 4d6a971eb..bc01ceac4 100644 --- a/src/overlays/actors/ovl_Obj_Fireshield/z_obj_fireshield.h +++ b/src/overlays/actors/ovl_Obj_Fireshield/z_obj_fireshield.h @@ -15,17 +15,17 @@ typedef void (*ObjFireshieldActionFunc)(struct ObjFireshield*); #define OBJFIRESHIELD_GET_ROTX(thisx) ((thisx)->home.rot.x & 1) typedef struct ObjFireshield { - /* 0x0000 */ Actor actor; - /* 0x0144 */ ColliderCylinder collider; - /* 0x0190 */ ObjFireshieldActionFunc actionFunc; - /* 0x0194 */ s32 unk_194; - /* 0x0198 */ f32 unk_198; - /* 0x019C */ s32 unk_19C; - /* 0x01A0 */ s32 unk_1A0; - /* 0x01A4 */ s16 unk_1A4; - /* 0x01A6 */ u8 unk_1A6; - /* 0x01A7 */ s8 unk_1A7; - /* 0x01A8 */ s8 unk_1A8; + /* 0x000 */ Actor actor; + /* 0x144 */ ColliderCylinder collider; + /* 0x190 */ ObjFireshieldActionFunc actionFunc; + /* 0x194 */ s32 unk_194; + /* 0x198 */ f32 unk_198; + /* 0x19C */ s32 unk_19C; + /* 0x1A0 */ s32 unk_1A0; + /* 0x1A4 */ s16 unk_1A4; + /* 0x1A6 */ u8 unk_1A6; + /* 0x1A7 */ s8 unk_1A7; + /* 0x1A8 */ s8 unk_1A8; } ObjFireshield; // size = 0x1AC extern const ActorInit Obj_Fireshield_InitVars; diff --git a/src/overlays/actors/ovl_Obj_Flowerpot/z_obj_flowerpot.c b/src/overlays/actors/ovl_Obj_Flowerpot/z_obj_flowerpot.c index 16ac7e8e9..73c5e32c6 100644 --- a/src/overlays/actors/ovl_Obj_Flowerpot/z_obj_flowerpot.c +++ b/src/overlays/actors/ovl_Obj_Flowerpot/z_obj_flowerpot.c @@ -4,6 +4,7 @@ * Description: Breakable Pot With Grass */ +#include "prevent_bss_reordering.h" #include "z_obj_flowerpot.h" #include "objects/object_flowerpot/object_flowerpot.h" @@ -11,25 +12,25 @@ #define THIS ((ObjFlowerpot*)thisx) -void ObjFlowerpot_Init(Actor* thisx, GlobalContext* globalCtx); -void ObjFlowerpot_Destroy(Actor* thisx, GlobalContext* globalCtx); -void ObjFlowerpot_Update(Actor* thisx, GlobalContext* globalCtx); -void ObjFlowerpot_Draw(Actor* thisx, GlobalContext* globalCtx); +void ObjFlowerpot_Init(Actor* thisx, PlayState* play); +void ObjFlowerpot_Destroy(Actor* thisx, PlayState* play); +void ObjFlowerpot_Update(Actor* thisx, PlayState* play); +void ObjFlowerpot_Draw(Actor* thisx, PlayState* play); void func_80A1C818(ObjFlowerpot* this); -void func_80A1C838(ObjFlowerpot* this, GlobalContext* globalCtx); +void func_80A1C838(ObjFlowerpot* this, PlayState* play); void func_80A1CBF8(ObjFlowerpot* this); -void func_80A1CC0C(ObjFlowerpot* this, GlobalContext* globalCtx); +void func_80A1CC0C(ObjFlowerpot* this, PlayState* play); void func_80A1CD10(ObjFlowerpot* this); -void func_80A1CEF4(ObjFlowerpot* this2, GlobalContext* globalCtx); +void func_80A1CEF4(ObjFlowerpot* this2, PlayState* play); -static u32 D_80A1D830; -static MtxF D_80A1D838[8]; -static s16 D_80A1DA38; -static s16 D_80A1DA3A; -static s16 D_80A1DA3C; -static s16 D_80A1DA3E; -static s16 D_80A1DA40; +u32 D_80A1D830; +MtxF D_80A1D838[8]; +s16 D_80A1DA38; +s16 D_80A1DA3A; +s16 D_80A1DA3C; +s16 D_80A1DA3E; +s16 D_80A1DA40; const ActorInit Obj_Flowerpot_InitVars = { ACTOR_OBJ_FLOWERPOT, @@ -77,19 +78,19 @@ static ColliderJntSphInit sJntSphInit = { OC2_TYPE_2, COLSHAPE_JNTSPH, }, - 2, + ARRAY_COUNT(sJntSphElementsInit), sJntSphElementsInit, }; -static s16 D_80A1D3F8 = 0; +s16 D_80A1D3F8 = 0; -static s16 D_80A1D3FC = 0; +s16 D_80A1D3FC = 0; -static s16 D_80A1D400 = 0; +s16 D_80A1D400 = 0; -static u8 D_80A1D404 = true; +u8 D_80A1D404 = true; -static Vec3f D_80A1D408 = { 0.0f, 20.0f, 0.0f }; +Vec3f D_80A1D408 = { 0.0f, 20.0f, 0.0f }; static InitChainEntry sInitChain[] = { ICHAIN_F32_DIV1000(gravity, -2000, ICHAIN_CONTINUE), ICHAIN_F32_DIV1000(terminalVelocity, -20000, ICHAIN_CONTINUE), @@ -145,7 +146,7 @@ void func_80A1B3D0(void) { sp74[7] = (spAC - temp_f20) * temp_f22 * temp_f24 * temp_f0 * 0.0013f; for (i = 0; i < ARRAY_COUNT(D_80A1D838); i++) { - ptr = (f32*)&D_80A1D838[i].mf[0]; + ptr = &D_80A1D838[i].xx; tempf1 = sp74[(i + 0) & 7]; tempf2 = sp74[(i + 1) & 7]; @@ -176,9 +177,9 @@ void func_80A1B3D0(void) { } void func_80A1B840(MtxF* matrix) { - MtxF* temp = Matrix_GetCurrentState(); - f32* tmp = (f32*)&temp->mf[0]; - f32* tmp2 = (f32*)&matrix->mf[0]; + MtxF* temp = Matrix_GetCurrent(); + f32* tmp = &temp->xx; + f32* tmp2 = &matrix->xx; s32 i; for (i = 0; i < 16; i++) { @@ -186,34 +187,34 @@ void func_80A1B840(MtxF* matrix) { } } -void func_80A1B914(ObjFlowerpot* this, GlobalContext* globalCtx) { +void func_80A1B914(ObjFlowerpot* this, PlayState* play) { if (!(this->unk_1EA & 4)) { s32 temp_v0 = func_800A8150(ENOBJFLOWERPOT_GET_3F(&this->actor)); if (temp_v0 >= 0) { s32 params = ENOBJFLOWERPOT_GET_7F00(&this->actor); - Item_DropCollectible(globalCtx, &this->actor.world.pos, temp_v0 | (params << 8)); + Item_DropCollectible(play, &this->actor.world.pos, temp_v0 | (params << 8)); this->unk_1EA |= 4; } } } -void func_80A1B994(ObjFlowerpot* this, GlobalContext* globalCtx) { - SoundSource_PlaySfxAtFixedWorldPos(globalCtx, &this->actor.world.pos, 20, NA_SE_EV_POT_BROKEN); +void func_80A1B994(ObjFlowerpot* this, PlayState* play) { + SoundSource_PlaySfxAtFixedWorldPos(play, &this->actor.world.pos, 20, NA_SE_EV_POT_BROKEN); } -void func_80A1B9CC(ObjFlowerpot* this, GlobalContext* globalCtx) { - SoundSource_PlaySfxAtFixedWorldPos(globalCtx, &this->actor.world.pos, 20, NA_SE_EV_PLANT_BROKEN); +void func_80A1B9CC(ObjFlowerpot* this, PlayState* play) { + SoundSource_PlaySfxAtFixedWorldPos(play, &this->actor.world.pos, 20, NA_SE_EV_PLANT_BROKEN); } 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) { +void func_80A1BA44(ObjFlowerpot* this, PlayState* play) { s32 i; Vec3f spD0; Vec3f spC4; @@ -253,18 +254,18 @@ void func_80A1BA44(ObjFlowerpot* this, GlobalContext* globalCtx) { phi_s1 = 0; } - EffectSsKakera_Spawn(globalCtx, &spC4, &spB8, &spC4, -600, phi_s0, 30, 0, 0, (Rand_ZeroOne() * 12.0f) + 16.6f, + EffectSsKakera_Spawn(play, &spC4, &spB8, &spC4, -600, phi_s0, 30, 0, 0, (Rand_ZeroOne() * 12.0f) + 16.6f, phi_s1, 0, 35, -1, ACTOR_DEMO_GETITEM, object_flowerpot_DL_0015B0); } spD0.y += 20.0f; - func_800BBFB0(globalCtx, &spD0, 30.0f, 2, 20, 50, 1); - func_800BBFB0(globalCtx, &spD0, 30.0f, 2, 10, 80, 1); - func_800BBFB0(globalCtx, &spD0, 30.0f, 1, 10, 40, 1); + func_800BBFB0(play, &spD0, 30.0f, 2, 20, 50, 1); + func_800BBFB0(play, &spD0, 30.0f, 2, 10, 80, 1); + func_800BBFB0(play, &spD0, 30.0f, 1, 10, 40, 1); } -void func_80A1BD80(ObjFlowerpot* this, GlobalContext* globalCtx) { +void func_80A1BD80(ObjFlowerpot* this, PlayState* play) { s32 i; Vec3f spC8; Vec3f spBC; @@ -296,8 +297,8 @@ void func_80A1BD80(ObjFlowerpot* this, GlobalContext* globalCtx) { phi_s0 = 32; } - EffectSsKakera_Spawn(globalCtx, &spBC, &spB0, &spBC, -240, phi_s0, 40, 0, 0, (Rand_ZeroOne() * 20.0f) + 10.6f, - 0, 0, 42, -1, ACTOR_DEMO_GETITEM, object_flowerpot_DL_0015B0); + EffectSsKakera_Spawn(play, &spBC, &spB0, &spBC, -240, phi_s0, 40, 0, 0, (Rand_ZeroOne() * 20.0f) + 10.6f, 0, 0, + 42, -1, ACTOR_DEMO_GETITEM, object_flowerpot_DL_0015B0); } spBC.y = this->actor.world.pos.y + this->actor.depthInWater; @@ -305,16 +306,16 @@ void func_80A1BD80(ObjFlowerpot* this, GlobalContext* globalCtx) { for (phi_s1 = 0, i = 0; i < 4; i++, phi_s1 += 0x4000) { spBC.x = (Math_SinS((s32)(Rand_ZeroOne() * 7200.0f) + phi_s1) * 15.0f) + this->actor.world.pos.x; spBC.z = (Math_CosS((s32)(Rand_ZeroOne() * 7200.0f) + phi_s1) * 15.0f) + this->actor.world.pos.z; - EffectSsGSplash_Spawn(globalCtx, &spBC, NULL, NULL, 0, 200); + EffectSsGSplash_Spawn(play, &spBC, NULL, NULL, 0, 200); } spBC.x = this->actor.world.pos.x; spBC.z = this->actor.world.pos.z; - EffectSsGSplash_Spawn(globalCtx, &spBC, NULL, NULL, 0, 350); - EffectSsGRipple_Spawn(globalCtx, &spBC, 150, 650, 0); + EffectSsGSplash_Spawn(play, &spBC, NULL, NULL, 0, 350); + EffectSsGRipple_Spawn(play, &spBC, 150, 650, 0); } -void func_80A1C0FC(ObjFlowerpot* this, GlobalContext* globalCtx) { +void func_80A1C0FC(ObjFlowerpot* this, PlayState* play) { Vec3f spC4; Vec3f spB8; Vec3f spAC; @@ -336,12 +337,12 @@ void func_80A1C0FC(ObjFlowerpot* this, GlobalContext* globalCtx) { spAC.z = spB8.z * 0.23f; Math_Vec3f_Sum(&spB8, &spC4, &spB8); - EffectSsKakera_Spawn(globalCtx, &spB8, &spAC, &spB8, -100, 64, 40, 0, 0, (Rand_ZeroOne() * 16.0f) + 14.0f, 0, 0, - 80, -1, ACTOR_DEMO_GETITEM, object_flowerpot_DL_0014F0); + EffectSsKakera_Spawn(play, &spB8, &spAC, &spB8, -100, 64, 40, 0, 0, (Rand_ZeroOne() * 16.0f) + 14.0f, 0, 0, 80, + -1, ACTOR_DEMO_GETITEM, object_flowerpot_DL_0014F0); } } -void func_80A1C328(ObjFlowerpot* this, GlobalContext* globalCtx) { +void func_80A1C328(ObjFlowerpot* this, PlayState* play) { Vec3f spC4; Vec3f spB8; Vec3f spAC; @@ -363,8 +364,8 @@ void func_80A1C328(ObjFlowerpot* this, GlobalContext* globalCtx) { spAC.z = spB8.z * 0.18f; Math_Vec3f_Sum(&spB8, &spC4, &spB8); - EffectSsKakera_Spawn(globalCtx, &spB8, &spAC, &spB8, -80, 64, 44, 0, 0, (Rand_ZeroOne() * 16.0f) + 14.0f, 0, 0, - 80, -1, ACTOR_DEMO_GETITEM, object_flowerpot_DL_0014F0); + EffectSsKakera_Spawn(play, &spB8, &spAC, &spB8, -80, 64, 44, 0, 0, (Rand_ZeroOne() * 16.0f) + 14.0f, 0, 0, 80, + -1, ACTOR_DEMO_GETITEM, object_flowerpot_DL_0014F0); } } @@ -382,30 +383,30 @@ void func_80A1C554(ObjFlowerpot* this) { } } -void func_80A1C5E8(ObjFlowerpot* this, GlobalContext* globalCtx) { - Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 18.0f, 15.0f, 0.0f, 0x45); +void func_80A1C5E8(ObjFlowerpot* this, PlayState* play) { + Actor_UpdateBgCheckInfo(play, &this->actor, 18.0f, 15.0f, 0.0f, 0x45); } -void func_80A1C62C(ObjFlowerpot* this, GlobalContext* globalCtx) { - if (!(this->unk_1EA & 4) && (globalCtx->roomCtx.currRoom.num != this->unk_1EC)) { +void func_80A1C62C(ObjFlowerpot* this, PlayState* play) { + if (!(this->unk_1EA & 4) && (play->roomCtx.currRoom.num != this->unk_1EC)) { this->unk_1EA |= 4; } } -void ObjFlowerpot_Init(Actor* thisx, GlobalContext* globalCtx) { +void ObjFlowerpot_Init(Actor* thisx, PlayState* play) { s32 pad; ObjFlowerpot* this = THIS; Actor_ProcessInitChain(&this->actor, sInitChain); if (this->actor.shape.rot.y == 0) { - this->actor.shape.rot.y = this->actor.world.rot.y = (u32)Rand_Next() >> 0x10; + 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); + Collider_InitJntSph(play, &this->collider); + Collider_SetJntSph(play, &this->collider, &this->actor, &sJntSphInit, this->colliderElements); + 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,24 +416,24 @@ 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; + D_80A1D830 = play->gameplayFrames; } this->unk_1EB = D_80A1D400 & 7; D_80A1D400++; } -void ObjFlowerpot_Destroy(Actor* thisx, GlobalContext* globalCtx2) { - GlobalContext* globalCtx = globalCtx2; +void ObjFlowerpot_Destroy(Actor* thisx, PlayState* play2) { + PlayState* play = play2; ObjFlowerpot* this = THIS; - Collider_DestroyJntSph(globalCtx, &this->collider); + Collider_DestroyJntSph(play, &this->collider); } void func_80A1C818(ObjFlowerpot* this) { @@ -440,16 +441,16 @@ void func_80A1C818(ObjFlowerpot* this) { this->unk_1EA |= 1; } -void func_80A1C838(ObjFlowerpot* this, GlobalContext* globalCtx) { +void func_80A1C838(ObjFlowerpot* this, PlayState* play) { s32 pad; - if (Actor_HasParent(&this->actor, globalCtx)) { + if (Actor_HasParent(&this->actor, play)) { func_80A1CBF8(this); this->actor.room = -1; this->actor.colChkInfo.mass = 180; this->actor.flags |= ACTOR_FLAG_10; if (func_800A817C(ENOBJFLOWERPOT_GET_3F(&this->actor))) { - func_80A1B914(this, globalCtx); + func_80A1B914(this, play); } //! @bug: This function should only pass Player*: it uses *(this + 0x153), which is meant to be @@ -457,42 +458,42 @@ void func_80A1C838(ObjFlowerpot* this, GlobalContext* globalCtx) { func_800B8E58((Player*)this, NA_SE_PL_PULL_UP_POT); } else if ((this->actor.bgCheckFlags & 0x20) && (this->actor.depthInWater > 19.0f)) { if (!(this->unk_1EA & 2)) { - func_80A1B914(this, globalCtx); - func_80A1C328(this, globalCtx); - func_80A1B9CC(this, globalCtx); + func_80A1B914(this, play); + func_80A1C328(this, play); + func_80A1B9CC(this, play); this->unk_1EA |= 2; } - func_80A1BD80(this, globalCtx); - func_80A1B994(this, globalCtx); + func_80A1BD80(this, play); + func_80A1B994(this, play); Actor_MarkForDeath(&this->actor); } 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); - func_80A1C0FC(this, globalCtx); - func_80A1B9CC(this, globalCtx); + func_80A1B914(this, play); + func_80A1C0FC(this, play); + func_80A1B9CC(this, play); this->unk_1EA |= 2; } - func_80A1BA44(this, globalCtx); - func_80A1B994(this, globalCtx); + func_80A1BA44(this, play); + func_80A1B994(this, play); Actor_MarkForDeath(&this->actor); } else { if (this->collider.elements[1].info.bumperFlags & BUMP_HIT) { if (!(this->unk_1EA & 2)) { this->unk_1EA |= 2; this->collider.elements[1].info.bumperFlags &= ~BUMP_ON; - func_80A1C0FC(this, globalCtx); - func_80A1B914(this, globalCtx); - func_80A1B9CC(this, globalCtx); + func_80A1C0FC(this, play); + func_80A1B914(this, play); + func_80A1B9CC(this, play); } } if (this->unk_1EA & 1) { Actor_MoveWithGravity(&this->actor); - func_80A1C5E8(this, globalCtx); + func_80A1C5E8(this, play); if (this->actor.bgCheckFlags & 1) { if (this->actor.colChkInfo.mass == MASS_IMMOVABLE) { - if (DynaPoly_GetActor(&globalCtx->colCtx, this->actor.floorBgId) == NULL) { + if (DynaPoly_GetActor(&play->colCtx, this->actor.floorBgId) == NULL) { this->actor.flags &= ~ACTOR_FLAG_10; this->unk_1EA &= ~0x1; } @@ -509,16 +510,16 @@ void func_80A1C838(ObjFlowerpot* this, GlobalContext* globalCtx) { this->collider.base.acFlags &= ~AC_HIT; if (this->actor.xzDistToPlayer < 600.0f) { - CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + CollisionCheck_SetAC(play, &play->colChkCtx, &this->collider.base); if (this->actor.xzDistToPlayer < 180.0f) { - CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + CollisionCheck_SetOC(play, &play->colChkCtx, &this->collider.base); if (this->actor.xzDistToPlayer < 100.0f) { - s16 temp_v0_3 = this->actor.yawTowardsPlayer - GET_PLAYER(globalCtx)->actor.world.rot.y; + s16 temp_v0_3 = this->actor.yawTowardsPlayer - GET_PLAYER(play)->actor.world.rot.y; if (ABS_ALT(temp_v0_3) >= 0x5556) { - Actor_PickUp(&this->actor, globalCtx, GI_NONE, 36.0f, 30.0f); + Actor_PickUp(&this->actor, play, GI_NONE, 36.0f, 30.0f); } } } @@ -530,22 +531,22 @@ void func_80A1CBF8(ObjFlowerpot* this) { this->actionFunc = func_80A1CC0C; } -void func_80A1CC0C(ObjFlowerpot* this, GlobalContext* globalCtx) { +void func_80A1CC0C(ObjFlowerpot* this, PlayState* play) { s32 pad; - func_80A1C62C(this, globalCtx); + func_80A1C62C(this, play); - if (Actor_HasNoParent(&this->actor, globalCtx)) { - this->actor.room = globalCtx->roomCtx.currRoom.num; + if (Actor_HasNoParent(&this->actor, play)) { + this->actor.room = play->roomCtx.currRoom.num; if (fabsf(this->actor.speedXZ) < 0.1f) { func_80A1C818(this); - func_800B8E58(GET_PLAYER(globalCtx), NA_SE_PL_PUT_DOWN_POT); + func_800B8E58(GET_PLAYER(play), NA_SE_PL_PUT_DOWN_POT); this->collider.base.ocFlags1 &= ~OC1_TYPE_PLAYER; } else { Actor_MoveWithGravity(&this->actor); func_80A1CD10(this); } - func_80A1C5E8(this, globalCtx); + func_80A1C5E8(this, play); } else { Vec3f sp30; s32 sp2C; @@ -554,7 +555,7 @@ void func_80A1CC0C(ObjFlowerpot* this, GlobalContext* globalCtx) { 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); + BgCheck_EntityRaycastFloor5(&play->colCtx, &this->actor.floorPoly, &sp2C, &this->actor, &sp30); } } @@ -587,7 +588,7 @@ void func_80A1CD10(ObjFlowerpot* this) { } } -void func_80A1CEF4(ObjFlowerpot* this2, GlobalContext* globalCtx) { +void func_80A1CEF4(ObjFlowerpot* this2, PlayState* play) { ObjFlowerpot* this = this2; s32 sp28 = this->collider.elements[0].info.toucherFlags & TOUCH_HIT; @@ -599,31 +600,31 @@ void func_80A1CEF4(ObjFlowerpot* this2, GlobalContext* globalCtx) { this->unk_1E8--; } - func_80A1C62C(this, globalCtx); + func_80A1C62C(this, play); if ((this->actor.bgCheckFlags & (0x8 | 0x2 | 0x1)) || sp28 || (this->unk_1E8 <= 0)) { if (!(this->unk_1EA & 2)) { - func_80A1B914(this, globalCtx); - func_80A1C0FC(this, globalCtx); - func_80A1B9CC(this, globalCtx); + func_80A1B914(this, play); + func_80A1C0FC(this, play); + func_80A1B9CC(this, play); this->unk_1EA |= 2; } - func_80A1BA44(this, globalCtx); - func_80A1B994(this, globalCtx); + func_80A1BA44(this, play); + func_80A1B994(this, play); Actor_MarkForDeath(&this->actor); return; } if (this->actor.bgCheckFlags & 0x40) { if (!(this->unk_1EA & 2)) { - func_80A1B914(this, globalCtx); - func_80A1C328(this, globalCtx); - func_80A1B9CC(this, globalCtx); + func_80A1B914(this, play); + func_80A1C328(this, play); + func_80A1B9CC(this, play); this->unk_1EA |= 2; } - func_80A1BD80(this, globalCtx); - func_80A1B994(this, globalCtx); - SoundSource_PlaySfxAtFixedWorldPos(globalCtx, &this->actor.world.pos, 40, NA_SE_EV_DIVE_INTO_WATER_L); + func_80A1BD80(this, play); + func_80A1B994(this, play); + SoundSource_PlaySfxAtFixedWorldPos(play, &this->actor.world.pos, 40, NA_SE_EV_DIVE_INTO_WATER_L); Actor_MarkForDeath(&this->actor); return; } @@ -640,34 +641,34 @@ void func_80A1CEF4(ObjFlowerpot* this2, GlobalContext* globalCtx) { this->actor.shape.rot.x += D_80A1D3F8; this->actor.shape.rot.y += D_80A1D3FC; - func_80A1C5E8(this, globalCtx); - CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); - CollisionCheck_SetAT(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + func_80A1C5E8(this, play); + CollisionCheck_SetOC(play, &play->colChkCtx, &this->collider.base); + CollisionCheck_SetAT(play, &play->colChkCtx, &this->collider.base); } -void ObjFlowerpot_Update(Actor* thisx, GlobalContext* globalCtx2) { - GlobalContext* globalCtx = globalCtx2; +void ObjFlowerpot_Update(Actor* thisx, PlayState* play2) { + PlayState* play = play2; ObjFlowerpot* this = THIS; - this->actionFunc(this, globalCtx); + this->actionFunc(this, play); func_80A1C554(this); - if ((D_80A1D830 != globalCtx->gameplayFrames) && (globalCtx->roomCtx.currRoom.unk3 == 0)) { + if ((D_80A1D830 != play->gameplayFrames) && (play->roomCtx.currRoom.unk3 == 0)) { func_80A1B3D0(); - D_80A1D830 = globalCtx->gameplayFrames; + D_80A1D830 = play->gameplayFrames; } } -void ObjFlowerpot_Draw(Actor* thisx, GlobalContext* globalCtx) { +void ObjFlowerpot_Draw(Actor* thisx, PlayState* play) { s32 pad; ObjFlowerpot* this = THIS; - OPEN_DISPS(globalCtx->state.gfxCtx); + OPEN_DISPS(play->state.gfxCtx); - func_8012C28C(globalCtx->state.gfxCtx); + func_8012C28C(play->state.gfxCtx); - gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_OPA_DISP++, object_flowerpot_DL_0012E0); if ((this->actionFunc != func_80A1C838) || (this->unk_1EA & 1)) { @@ -678,11 +679,11 @@ void ObjFlowerpot_Draw(Actor* thisx, GlobalContext* globalCtx) { } if (!(this->unk_1EA & 2)) { - if ((globalCtx->roomCtx.currRoom.unk3 == 0) && (this->actionFunc == func_80A1C838)) { + if ((play->roomCtx.currRoom.unk3 == 0) && (this->actionFunc == func_80A1C838)) { if ((this->actor.projectedPos.z > -150.0f) && (this->actor.projectedPos.z < 400.0f)) { func_80A1B840(&D_80A1D838[this->unk_1EB]); - gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); } } @@ -690,5 +691,5 @@ void ObjFlowerpot_Draw(Actor* thisx, GlobalContext* globalCtx) { gSPDisplayList(POLY_OPA_DISP++, object_flowerpot_DL_001408); } - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->state.gfxCtx); } diff --git a/src/overlays/actors/ovl_Obj_Flowerpot/z_obj_flowerpot.h b/src/overlays/actors/ovl_Obj_Flowerpot/z_obj_flowerpot.h index 01557bc2b..3e803672c 100644 --- a/src/overlays/actors/ovl_Obj_Flowerpot/z_obj_flowerpot.h +++ b/src/overlays/actors/ovl_Obj_Flowerpot/z_obj_flowerpot.h @@ -5,20 +5,20 @@ struct ObjFlowerpot; -typedef void (*ObjFlowerpotActionFunc)(struct ObjFlowerpot*, GlobalContext*); +typedef void (*ObjFlowerpotActionFunc)(struct ObjFlowerpot*, PlayState*); #define ENOBJFLOWERPOT_GET_3F(thisx) ((thisx)->params & 0x3F) #define ENOBJFLOWERPOT_GET_7F00(thisx) (((thisx)->params >> 8) & 0x7F) typedef struct ObjFlowerpot { - /* 0x0000 */ Actor actor; - /* 0x0144 */ ColliderJntSph collider; - /* 0x0164 */ ColliderJntSphElement colliderElements[2]; - /* 0x01E4 */ ObjFlowerpotActionFunc actionFunc; - /* 0x01E8 */ s16 unk_1E8; - /* 0x01EA */ u8 unk_1EA; - /* 0x01EB */ s8 unk_1EB; - /* 0x01EC */ s8 unk_1EC; + /* 0x000 */ Actor actor; + /* 0x144 */ ColliderJntSph collider; + /* 0x164 */ ColliderJntSphElement colliderElements[2]; + /* 0x1E4 */ ObjFlowerpotActionFunc actionFunc; + /* 0x1E8 */ s16 unk_1E8; + /* 0x1EA */ u8 unk_1EA; + /* 0x1EB */ s8 unk_1EB; + /* 0x1EC */ s8 unk_1EC; } ObjFlowerpot; // size = 0x1F0 extern const ActorInit Obj_Flowerpot_InitVars; diff --git a/src/overlays/actors/ovl_Obj_Funen/z_obj_funen.c b/src/overlays/actors/ovl_Obj_Funen/z_obj_funen.c index 2ec24e73e..99a481577 100644 --- a/src/overlays/actors/ovl_Obj_Funen/z_obj_funen.c +++ b/src/overlays/actors/ovl_Obj_Funen/z_obj_funen.c @@ -11,8 +11,8 @@ #define THIS ((ObjFunen*)thisx) -void ObjFunen_Init(Actor* thisx, GlobalContext* globalCtx); -void ObjFunen_Draw(Actor* thisx, GlobalContext* globalCtx); +void ObjFunen_Init(Actor* thisx, PlayState* play); +void ObjFunen_Draw(Actor* thisx, PlayState* play); const ActorInit Obj_Funen_InitVars = { ACTOR_OBJ_FUNEN, ACTORCAT_PROP, FLAGS, @@ -22,27 +22,27 @@ const ActorInit Obj_Funen_InitVars = { f32 D_80A198D0[] = { 0.1f, 0.024390244f }; -void ObjFunen_Init(Actor* thisx, GlobalContext* globalCtx) { +void ObjFunen_Init(Actor* thisx, PlayState* play) { ObjFunen* this = THIS; Actor_SetScale(&this->actor, D_80A198D0[this->actor.params & 1]); } -void ObjFunen_Draw(Actor* thisx, GlobalContext* globalCtx) { +void ObjFunen_Draw(Actor* thisx, PlayState* play) { s32 temp; s32 pad[2]; - OPEN_DISPS(globalCtx->state.gfxCtx); + OPEN_DISPS(play->state.gfxCtx); - func_8012C2DC(globalCtx->state.gfxCtx); - Matrix_RotateY((s16)(Camera_GetCamDirYaw(GET_ACTIVE_CAM(globalCtx)) - 0x8000), MTXMODE_APPLY); + func_8012C2DC(play->state.gfxCtx); + Matrix_RotateYS((s16)(Camera_GetCamDirYaw(GET_ACTIVE_CAM(play)) - 0x8000), MTXMODE_APPLY); - gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_MODELVIEW | G_MTX_LOAD | G_MTX_NOPUSH); + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_MODELVIEW | G_MTX_LOAD | G_MTX_NOPUSH); - temp = -(globalCtx->gameplayFrames & 0x7FFFFFFF) & 0x7F; + temp = -(play->gameplayFrames & 0x7FFFFFFF) & 0x7F; gSPSegment(POLY_XLU_DISP++, 0x08, - Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, 0, temp, 0x20, 0x20, 1, 0, temp, 0x20, 0x20)); + Gfx_TwoTexScroll(play->state.gfxCtx, 0, 0, temp, 0x20, 0x20, 1, 0, temp, 0x20, 0x20)); gSPDisplayList(POLY_XLU_DISP++, object_funen_DL_0000D0); - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->state.gfxCtx); } 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 bedb0a38f..343a8f61e 100644 --- a/src/overlays/actors/ovl_Obj_Ghaka/z_obj_ghaka.c +++ b/src/overlays/actors/ovl_Obj_Ghaka/z_obj_ghaka.c @@ -11,18 +11,18 @@ #define THIS ((ObjGhaka*)thisx) -void ObjGhaka_Init(Actor* thisx, GlobalContext* globalCtx); -void ObjGhaka_Destroy(Actor* thisx, GlobalContext* globalCtx); -void ObjGhaka_Update(Actor* thisx, GlobalContext* globalCtx); -void ObjGhaka_Draw(Actor* thisx, GlobalContext* globalCtx); +void ObjGhaka_Init(Actor* thisx, PlayState* play); +void ObjGhaka_Destroy(Actor* thisx, PlayState* play); +void ObjGhaka_Update(Actor* thisx, PlayState* play); +void ObjGhaka_Draw(Actor* thisx, PlayState* play); void func_80B3C260(ObjGhaka* this); void func_80B3C29C(ObjGhaka* this); void func_80B3C2B0(ObjGhaka* this); -void func_80B3C2C4(ObjGhaka* this, GlobalContext* globalCtx); -void func_80B3C39C(ObjGhaka* this, GlobalContext* globalCtx); -void func_80B3C4E0(ObjGhaka* this, GlobalContext* globalCtx); -void func_80B3C624(ObjGhaka* this, GlobalContext* globalCtx); +void func_80B3C2C4(ObjGhaka* this, PlayState* play); +void func_80B3C39C(ObjGhaka* this, PlayState* play); +void func_80B3C4E0(ObjGhaka* this, PlayState* play); +void func_80B3C624(ObjGhaka* this, PlayState* play); const ActorInit Obj_Ghaka_InitVars = { ACTOR_OBJ_GHAKA, @@ -58,25 +58,25 @@ void func_80B3C2B0(ObjGhaka* this) { this->actionFunc = func_80B3C624; } -void func_80B3C2C4(ObjGhaka* this, GlobalContext* globalCtx) { +void func_80B3C2C4(ObjGhaka* this, PlayState* play) { 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); + Actor_SpawnAsChildAndCutscene(&play->actorCtx, play, ACTOR_BG_GORON_OYU, 0.0f, 25.0f, 261.0f, 0, 0, 0, 0, + this->dyna.actor.cutscene, this->dyna.actor.unk20, 0); } else { - Actor_SpawnAsChildAndCutscene(&globalCtx->actorCtx, globalCtx, ACTOR_BG_GORON_OYU, 0.0f, 25.0f, 261.0f, 0, 0, 0, - 1, -1, this->dyna.actor.unk20, 0); + Actor_SpawnAsChildAndCutscene(&play->actorCtx, play, ACTOR_BG_GORON_OYU, 0.0f, 25.0f, 261.0f, 0, 0, 0, 1, -1, + this->dyna.actor.unk20, 0); } } -void func_80B3C39C(ObjGhaka* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); +void func_80B3C39C(ObjGhaka* this, PlayState* play) { + Player* player = GET_PLAYER(play); s16 distDiff = this->dyna.actor.yawTowardsPlayer - this->dyna.actor.shape.rot.y; - if (Actor_ProcessTalkRequest(&this->dyna.actor, &globalCtx->state)) { + if (Actor_ProcessTalkRequest(&this->dyna.actor, &play->state)) { func_80B3C29C(this); } else if (this->dyna.actor.xzDistToPlayer < 100.0f || this->dyna.actor.isTargeted) { if (distDiff <= -0x5556 || distDiff >= 0x5556) { - func_800B863C(&this->dyna.actor, globalCtx); + func_800B863C(&this->dyna.actor, play); if (player->transformation == PLAYER_FORM_GORON) { this->dyna.actor.textId = 0xCF3; } else { @@ -94,40 +94,43 @@ void func_80B3C39C(ObjGhaka* this, GlobalContext* globalCtx) { } } -void func_80B3C4E0(ObjGhaka* this, GlobalContext* globalCtx) { - u8 talkState = Message_GetState(&globalCtx->msgCtx); +void func_80B3C4E0(ObjGhaka* this, PlayState* play) { + u8 talkState = Message_GetState(&play->msgCtx); - if (talkState == 5) { - if (Message_ShouldAdvance(globalCtx)) { - globalCtx->msgCtx.msgMode = 0x43; - globalCtx->msgCtx.unk12023 = 4; + if (talkState == TEXT_STATE_5) { + if (Message_ShouldAdvance(play)) { + play->msgCtx.msgMode = 0x43; + play->msgCtx.stateTimer = 4; func_80B3C260(this); } - } else if (talkState == 4) { - if (Message_ShouldAdvance(globalCtx)) { - switch (globalCtx->msgCtx.choiceIndex) { + } else if (talkState == TEXT_STATE_CHOICE) { + if (Message_ShouldAdvance(play)) { + switch (play->msgCtx.choiceIndex) { case 0: func_8019F208(); this->dyna.actor.textId = 0xCF5; - Message_StartTextbox(globalCtx, this->dyna.actor.textId, &this->dyna.actor); + Message_StartTextbox(play, this->dyna.actor.textId, &this->dyna.actor); break; + case 1: func_8019F208(); this->dyna.actor.textId = 0xCF7; - Message_StartTextbox(globalCtx, this->dyna.actor.textId, &this->dyna.actor); + Message_StartTextbox(play, this->dyna.actor.textId, &this->dyna.actor); break; + case 2: func_8019F230(); - globalCtx->msgCtx.msgMode = 0x43; - globalCtx->msgCtx.unk12023 = 4; + play->msgCtx.msgMode = 0x43; + play->msgCtx.stateTimer = 4; func_80B3C260(this); + break; } } } } -void func_80B3C624(ObjGhaka* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); +void func_80B3C624(ObjGhaka* this, PlayState* play) { + Player* player = GET_PLAYER(play); u8 stepTemp = Math_StepToS(&this->unk_168, 0x64, 1); this->dyna.actor.world.pos.z = this->dyna.actor.home.pos.z + this->unk_168; @@ -135,7 +138,7 @@ void func_80B3C624(ObjGhaka* this, GlobalContext* globalCtx) { if (stepTemp) { player->stateFlags2 &= ~0x10; this->dyna.pushForce = 0.0f; - func_80B3C2C4(this, globalCtx); + func_80B3C2C4(this, play); gSaveContext.save.weekEventReg[20] |= 0x20; func_80B3C260(this); Audio_PlaySfxAtPos(&D_80B3C960, NA_SE_EV_BLOCK_BOUND); @@ -144,7 +147,7 @@ void func_80B3C624(ObjGhaka* this, GlobalContext* globalCtx) { } } -void ObjGhaka_Init(Actor* thisx, GlobalContext* globalCtx) { +void ObjGhaka_Init(Actor* thisx, PlayState* play) { ObjGhaka* this = THIS; s32 pad; CollisionHeader* colHeader = NULL; @@ -153,39 +156,39 @@ void ObjGhaka_Init(Actor* thisx, GlobalContext* globalCtx) { Actor_SetScale(&this->dyna.actor, 0.1f); DynaPolyActor_Init(&this->dyna, 1); CollisionHeader_GetVirtual(&object_ghaka_Colheader_003CD0, &colHeader); - this->dyna.bgId = DynaPoly_SetBgActor(globalCtx, &globalCtx->colCtx.dyna, &this->dyna.actor, colHeader); - Actor_UpdateBgCheckInfo(globalCtx, &this->dyna.actor, 0.0f, 0.0f, 0.0f, 0x4); + this->dyna.bgId = DynaPoly_SetBgActor(play, &play->colCtx.dyna, &this->dyna.actor, colHeader); + Actor_UpdateBgCheckInfo(play, &this->dyna.actor, 0.0f, 0.0f, 0.0f, 0x4); if (this->dyna.actor.floorPoly == 0) { Actor_MarkForDeath(&this->dyna.actor); } if (gSaveContext.save.weekEventReg[20] & 0x20) { - func_80B3C2C4(this, globalCtx); + func_80B3C2C4(this, play); } func_80B3C260(this); } -void ObjGhaka_Destroy(Actor* thisx, GlobalContext* globalCtx) { +void ObjGhaka_Destroy(Actor* thisx, PlayState* play) { ObjGhaka* this = THIS; - DynaPoly_DeleteBgActor(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); + DynaPoly_DeleteBgActor(play, &play->colCtx.dyna, this->dyna.bgId); } -void ObjGhaka_Update(Actor* thisx, GlobalContext* globalCtx) { +void ObjGhaka_Update(Actor* thisx, PlayState* play) { ObjGhaka* this = THIS; - this->actionFunc(this, globalCtx); + this->actionFunc(this, play); thisx->focus.pos.x = thisx->world.pos.x; thisx->focus.pos.y = thisx->world.pos.y + 60.0f; thisx->focus.pos.z = thisx->world.pos.z; } -void ObjGhaka_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); +void ObjGhaka_Draw(Actor* thisx, PlayState* play) { + OPEN_DISPS(play->state.gfxCtx); + func_8012C28C(play->state.gfxCtx); + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_OPA_DISP++, object_ghaka_DL_001A20); - func_8012C2DC(globalCtx->state.gfxCtx); - gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + func_8012C2DC(play->state.gfxCtx); + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_XLU_DISP++, object_ghaka_DL_001980); - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->state.gfxCtx); } diff --git a/src/overlays/actors/ovl_Obj_Ghaka/z_obj_ghaka.h b/src/overlays/actors/ovl_Obj_Ghaka/z_obj_ghaka.h index d375d6374..34c71f6b8 100644 --- a/src/overlays/actors/ovl_Obj_Ghaka/z_obj_ghaka.h +++ b/src/overlays/actors/ovl_Obj_Ghaka/z_obj_ghaka.h @@ -5,12 +5,12 @@ struct ObjGhaka; -typedef void (*ObjGhakaActionFunc)(struct ObjGhaka*, GlobalContext*); +typedef void (*ObjGhakaActionFunc)(struct ObjGhaka*, PlayState*); typedef struct ObjGhaka { /* 0x000 */ DynaPolyActor dyna; /* 0x15C */ ObjGhakaActionFunc actionFunc; - /* 0x160 */ char unk160[0x8]; + /* 0x160 */ UNK_TYPE1 unk160[0x8]; /* 0x168 */ s16 unk_168; } ObjGhaka; // size = 0x16C 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 d95cc0631..df880906e 100644 --- a/src/overlays/actors/ovl_Obj_Grass/z_obj_grass.c +++ b/src/overlays/actors/ovl_Obj_Grass/z_obj_grass.c @@ -4,18 +4,20 @@ * Description: "Master" instance of grass for unit spawned by Obj_Grass_Unit */ +#include "prevent_bss_reordering.h" #include "z_obj_grass.h" #include "overlays/actors/ovl_Obj_Grass_Carry/z_obj_grass_carry.h" #include "objects/gameplay_keep/gameplay_keep.h" +#include "prevent_bss_reordering.h" #define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_20) #define THIS ((ObjGrass*)thisx) -void ObjGrass_Init(Actor* thisx, GlobalContext* globalCtx); -void ObjGrass_Destroy(Actor* thisx, GlobalContext* globalCtx); -void ObjGrass_Update(Actor* thisx, GlobalContext* globalCtx); -void ObjGrass_Draw(Actor* thisx, GlobalContext* globalCtx); +void ObjGrass_Init(Actor* thisx, PlayState* play); +void ObjGrass_Destroy(Actor* thisx, PlayState* play); +void ObjGrass_Update(Actor* thisx, PlayState* play); +void ObjGrass_Draw(Actor* thisx, PlayState* play); ObjGrassStruct1* D_809AADA0[4]; f32 D_809AADB0[4]; @@ -65,19 +67,19 @@ Vec3f D_809AAB4C[] = { s16 D_809AAB7C[] = { 0x6C, 0x66, 0x60, 0x54, 0x42, 0x37, 0x2A, 0x26 }; -s32 func_809A9110(GlobalContext* globalCtx, Vec3f* arg1) { +s32 func_809A9110(PlayState* play, Vec3f* arg1) { f32 sp2C; Vec3f sp20; - SkinMatrix_Vec3fMtxFMultXYZW(&globalCtx->viewProjectionMtxF, arg1, &sp20, &sp2C); + SkinMatrix_Vec3fMtxFMultXYZW(&play->viewProjectionMtxF, arg1, &sp20, &sp2C); - if ((globalCtx->unk_187F0.z * -130.13191f) < sp20.z) { + if ((play->unk_187F0.z * -130.13191f) < sp20.z) { if (sp2C < 1.0f) { sp2C = 1.0f; } - if (((fabsf(sp20.x) - (130.13191f * globalCtx->unk_187F0.x)) < sp2C) && - ((fabsf(sp20.y) - (130.13191f * globalCtx->unk_187F0.y)) < sp2C)) { + if (((fabsf(sp20.x) - (130.13191f * play->unk_187F0.x)) < sp2C) && + ((fabsf(sp20.y) - (130.13191f * play->unk_187F0.y)) < sp2C)) { return true; } } @@ -86,7 +88,7 @@ s32 func_809A9110(GlobalContext* globalCtx, Vec3f* arg1) { void func_809A91FC(MtxF* matrix) { s32 i; - MtxF* temp = Matrix_GetCurrentState(); + MtxF* temp = Matrix_GetCurrent(); f32* tmp = &temp->xx; f32* tmp2 = &matrix->xx; @@ -95,13 +97,13 @@ void func_809A91FC(MtxF* matrix) { } } -void func_809A92D0(ObjGrassStruct1_1* ptr, GlobalContext* globalCtx) { +void func_809A92D0(ObjGrassStruct1_1* ptr, PlayState* play) { if (!(ptr->unk_0E & 0x10)) { - Item_DropCollectibleRandom(globalCtx, NULL, &ptr->unk_00, ptr->unk_0E * 0x10); + Item_DropCollectibleRandom(play, NULL, &ptr->unk_00, ptr->unk_0E * 0x10); } } -void func_809A9314(ObjGrassStruct1_1* ptr, GlobalContext* globalCtx) { +void func_809A9314(ObjGrassStruct1_1* ptr, PlayState* play) { Vec3f spBC; Vec3f spB0; s32 i; @@ -118,7 +120,7 @@ void func_809A9314(ObjGrassStruct1_1* ptr, GlobalContext* globalCtx) { spBC.y = Rand_ZeroOne() * 10.0f; spBC.z = (Rand_ZeroOne() - 0.5f) * 8.0f; - EffectSsKakera_Spawn(globalCtx, &spB0, &spBC, &spB0, -100, 64, 40, 3, 0, + EffectSsKakera_Spawn(play, &spB0, &spBC, &spB0, -100, 64, 40, 3, 0, D_809AAB7C[(s32)(Rand_ZeroOne() * 111.1f) & 7], 0, 0, 80, -1, 1, gKakeraLeafMiddle); spB0.x = ptr->unk_00.x + (ptr2->x * 16.0f); @@ -129,36 +131,36 @@ void func_809A9314(ObjGrassStruct1_1* ptr, GlobalContext* globalCtx) { 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, + EffectSsKakera_Spawn(play, &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) { +void ObjGrass_Init(Actor* thisx, PlayState* play) { 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); + Collider_InitCylinder(play, &this->unk_2948[i].collider); + Collider_SetCylinder(play, &this->unk_2948[i].collider, &this->actor, &sCylinderInit); } this->actor.colChkInfo.mass = MASS_IMMOVABLE; - this->unk_3288 = (u32)Rand_Next() >> 0x10; - this->unk_328A = (u32)Rand_Next() >> 0x10; - this->unk_328C = (u32)Rand_Next() >> 0x10; - this->unk_328E = (u32)Rand_Next() >> 0x10; - this->unk_3290 = (u32)Rand_Next() >> 0x10; + 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) { +void ObjGrass_Destroy(Actor* thisx, PlayState* play) { ObjGrass* this = THIS; s32 i; for (i = 0; i < ARRAY_COUNT(this->unk_2948); i++) { - Collider_DestroyCylinder(globalCtx, &this->unk_2948[i].collider); + Collider_DestroyCylinder(play, &this->unk_2948[i].collider); } for (i = 0; i < ARRAY_COUNT(this->unk_3298); i++) { @@ -171,23 +173,23 @@ void ObjGrass_Destroy(Actor* thisx, GlobalContext* globalCtx) { } } -void func_809A9790(ObjGrass* this, GlobalContext* globalCtx) { +void func_809A9790(ObjGrass* this, PlayState* play) { 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); + func_809A9314(ptr, play); + func_809A92D0(ptr, play); ptr->unk_0F |= 4; - SoundSource_PlaySfxAtFixedWorldPos(globalCtx, &ptr->unk_00, 20, NA_SE_EV_PLANT_BROKEN); + SoundSource_PlaySfxAtFixedWorldPos(play, &ptr->unk_00, 20, NA_SE_EV_PLANT_BROKEN); } } } -void func_809A983C(ObjGrass* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); +void func_809A983C(ObjGrass* this, PlayState* play) { + Player* player = GET_PLAYER(play); s32 i; s32 j; s32 x; @@ -287,8 +289,8 @@ void func_809A983C(ObjGrass* this, GlobalContext* globalCtx) { 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); + CollisionCheck_SetAC(play, &play->colChkCtx, &ptr3->collider.base); + CollisionCheck_SetOC(play, &play->colChkCtx, &ptr3->collider.base); ptr2->unk_0F |= 2; ptr3->unk_4C = ptr2; } else { @@ -375,15 +377,15 @@ void func_809A9DB8(ObjGrass* this) { } } -void ObjGrass_Update(Actor* thisx, GlobalContext* globalCtx) { +void ObjGrass_Update(Actor* thisx, PlayState* play) { ObjGrass* this = THIS; - func_809A9790(this, globalCtx); - func_809A983C(this, globalCtx); + func_809A9790(this, play); + func_809A983C(this, play); func_809A9DB8(this); } -void func_809AA278(ObjGrass* this, GlobalContext* globalCtx) { +void func_809AA278(ObjGrass* this, PlayState* play) { ObjGrassStruct1* ptr; ObjGrassStruct1_1* ptr2; s32 i; @@ -394,9 +396,9 @@ void func_809AA278(ObjGrass* this, GlobalContext* globalCtx) { 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); + temp_f22 = Math3D_Vec3fDistSq(&ptr->unk_00, &GET_ACTIVE_CAM(play)->eye); - if ((temp_f22 < SQ(1280.0f)) && func_809A9110(globalCtx, &ptr->unk_00)) { + if ((temp_f22 < SQ(1280.0f)) && func_809A9110(play, &ptr->unk_00)) { ptr->unk_FE |= 1; for (j = 0; j < ptr->unk_FC; j++) { @@ -410,7 +412,7 @@ void func_809AA278(ObjGrass* this, GlobalContext* globalCtx) { if (temp_f22 < SQ(980.0f)) { ptr2->unk_10 = 255; } else { - distSq = Math3D_Vec3fDistSq(&ptr2->unk_00, &GET_ACTIVE_CAM(globalCtx)->eye); + distSq = Math3D_Vec3fDistSq(&ptr2->unk_00, &GET_ACTIVE_CAM(play)->eye); if ((distSq <= SQ(1080.0f)) || ((ptr2->unk_0F & 8) && (distSq < SQ(1180.0f)))) { ptr2->unk_10 = 255; } else if (distSq >= SQ(1180.0f)) { @@ -427,9 +429,9 @@ void func_809AA278(ObjGrass* this, GlobalContext* globalCtx) { } } -void func_809AA54C(Actor* thisx, GlobalContext* globalCtx2) { +void func_809AA54C(Actor* thisx, PlayState* play2) { ObjGrass* this = THIS; - GlobalContext* globalCtx = globalCtx2; + PlayState* play = play2; Lights* temp_s0; ObjGrassStruct1* ptr; s32 i; @@ -437,9 +439,9 @@ void func_809AA54C(Actor* thisx, GlobalContext* globalCtx2) { Vec3s sp70 = { 0, 0, 0 }; ObjGrassStruct1_1* ptr2; - OPEN_DISPS(globalCtx->state.gfxCtx); + OPEN_DISPS(play->state.gfxCtx); - func_8012C28C(globalCtx->state.gfxCtx); + func_8012C28C(play->state.gfxCtx); gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, 255, 255, 255, 255); gSPDisplayList(POLY_OPA_DISP++, gObjGrass_D_809AA9F0); @@ -448,22 +450,22 @@ void func_809AA54C(Actor* thisx, GlobalContext* globalCtx2) { 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); + temp_s0 = LightContext_NewLights(&play->lightCtx, play->state.gfxCtx); + Lights_BindAll(temp_s0, play->lightCtx.listHead, &ptr->unk_00, play); + Lights_Draw(temp_s0, play->state.gfxCtx); for (j = 0; j < ptr->unk_FC; j++) { ptr2 = &ptr->unk_0C[j]; if ((ptr2->unk_0F & 1) && (ptr2->unk_10 == 255)) { sp70.y = ptr2->unk_0C; - Matrix_SetStateRotationAndTranslation(ptr2->unk_00.x, ptr2->unk_00.y, ptr2->unk_00.z, &sp70); + Matrix_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), + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_OPA_DISP++, gObjGrass_D_809AAAE0); } @@ -471,10 +473,10 @@ void func_809AA54C(Actor* thisx, GlobalContext* globalCtx2) { } } - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->state.gfxCtx); } -void func_809AA798(Actor* thisx, GlobalContext* globalCtx) { +void func_809AA798(Actor* thisx, PlayState* play) { ObjGrass* this = THIS; ObjGrassStruct1* ptr; ObjGrassStruct1_1* ptr2; @@ -482,9 +484,9 @@ void func_809AA798(Actor* thisx, GlobalContext* globalCtx) { s32 j; Vec3s sp6C = { 0, 0, 0 }; - OPEN_DISPS(globalCtx->state.gfxCtx); + OPEN_DISPS(play->state.gfxCtx); - func_8012C2DC(globalCtx->state.gfxCtx); + func_8012C2DC(play->state.gfxCtx); gSPDisplayList(POLY_XLU_DISP++, gObjGrass_D_809AAA68); @@ -497,10 +499,10 @@ void func_809AA798(Actor* thisx, GlobalContext* globalCtx) { if ((ptr2->unk_0F & 1) && (ptr2->unk_10 > 0) && (ptr2->unk_10 < 255)) { sp6C.y = ptr2->unk_0C; - Matrix_SetStateRotationAndTranslation(ptr2->unk_00.x, ptr2->unk_00.y, ptr2->unk_00.z, &sp6C); + Matrix_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), + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(play->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); @@ -509,13 +511,13 @@ void func_809AA798(Actor* thisx, GlobalContext* globalCtx) { } } - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->state.gfxCtx); } -void ObjGrass_Draw(Actor* thisx, GlobalContext* globalCtx) { +void ObjGrass_Draw(Actor* thisx, PlayState* play) { ObjGrass* this = THIS; - func_809AA278(this, globalCtx); - func_809AA54C(thisx, globalCtx); - func_809AA798(thisx, globalCtx); + func_809AA278(this, play); + func_809AA54C(thisx, play); + func_809AA798(thisx, play); } diff --git a/src/overlays/actors/ovl_Obj_Grass/z_obj_grass.h b/src/overlays/actors/ovl_Obj_Grass/z_obj_grass.h index 1c87108df..be73c70b5 100644 --- a/src/overlays/actors/ovl_Obj_Grass/z_obj_grass.h +++ b/src/overlays/actors/ovl_Obj_Grass/z_obj_grass.h @@ -13,7 +13,6 @@ typedef struct ObjGrassStruct1_1 { /* 0x0E */ s8 unk_0E; /* 0x0F */ u8 unk_0F; /* 0x10 */ u8 unk_10; - /* 0x11 */ UNK_TYPE1 unk_11[0x3]; } ObjGrassStruct1_1; // size = 0x14 typedef struct { diff --git a/src/overlays/actors/ovl_Obj_Grass_Carry/z_obj_grass_carry.c b/src/overlays/actors/ovl_Obj_Grass_Carry/z_obj_grass_carry.c index 2e9df3323..11c8619ce 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 @@ -13,21 +13,21 @@ #define THIS ((ObjGrassCarry*)thisx) -void ObjGrassCarry_Init(Actor* thisx, GlobalContext* globalCtx); -void ObjGrassCarry_Destroy(Actor* thisx, GlobalContext* globalCtx); -void ObjGrassCarry_Update(Actor* thisx, GlobalContext* globalCtx); +void ObjGrassCarry_Init(Actor* thisx, PlayState* play); +void ObjGrassCarry_Destroy(Actor* thisx, PlayState* play); +void ObjGrassCarry_Update(Actor* thisx, PlayState* play); void func_809AB3C4(ObjGrassCarry* this); -void func_809AB3D8(ObjGrassCarry* this, GlobalContext* globalCtx); +void func_809AB3D8(ObjGrassCarry* this, PlayState* play); void func_809AB428(ObjGrassCarry* this); -void func_809AB43C(ObjGrassCarry* this, GlobalContext* globalCtx); +void func_809AB43C(ObjGrassCarry* this, PlayState* play); void func_809AB474(ObjGrassCarry* this); -void func_809AB4A8(ObjGrassCarry* this, GlobalContext* globalCtx); +void func_809AB4A8(ObjGrassCarry* this, PlayState* play); void func_809AB5FC(ObjGrassCarry* this); -void func_809AB610(ObjGrassCarry* this, GlobalContext* globalCtx); +void func_809AB610(ObjGrassCarry* this, PlayState* play); void func_809AB6FC(ObjGrassCarry* this); -void func_809AB77C(ObjGrassCarry* this, GlobalContext* globalCtx); -void func_809ABB7C(Actor* this, GlobalContext* globalCtx); +void func_809AB77C(ObjGrassCarry* this, PlayState* play); +void func_809ABB7C(Actor* this, PlayState* play); const ActorInit Obj_Grass_Carry_InitVars = { ACTOR_OBJ_GRASS_CARRY, @@ -102,17 +102,17 @@ void func_809AAF18(ObjGrassCarry* this) { Actor_UpdatePos(&this->actor); } -void func_809AAF58(ObjGrassCarry* this, GlobalContext* globalCtx) { - Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 7.5f, 35.0f, 0.0f, 0xC5); +void func_809AAF58(ObjGrassCarry* this, PlayState* play) { + Actor_UpdateBgCheckInfo(play, &this->actor, 7.5f, 35.0f, 0.0f, 0xC5); } -void func_809AAF9C(Vec3f* arg0, s16 arg1, GlobalContext* globalCtx) { +void func_809AAF9C(Vec3f* arg0, s16 arg1, PlayState* play) { if (!(arg1 & 0x10)) { - Item_DropCollectibleRandom(globalCtx, NULL, arg0, arg1 * 0x10); + Item_DropCollectibleRandom(play, NULL, arg0, arg1 * 0x10); } } -void func_809AAFE8(Vec3f* arg0, GlobalContext* globalCtx) { +void func_809AAFE8(Vec3f* arg0, PlayState* play) { Vec3f spBC; Vec3f spB0; s32 i; @@ -129,7 +129,7 @@ void func_809AAFE8(Vec3f* arg0, GlobalContext* globalCtx) { spBC.y = Rand_ZeroOne() * 10.0f; spBC.z = (Rand_ZeroOne() - 0.5f) * 8.0f; - EffectSsKakera_Spawn(globalCtx, &spB0, &spBC, &spB0, -100, 64, 40, 3, 0, + EffectSsKakera_Spawn(play, &spB0, &spBC, &spB0, -100, 64, 40, 3, 0, D_809ABC3C[(s32)(Rand_ZeroOne() * 111.1f) & 7], 0, 0, 80, -1, 1, gKakeraLeafMiddle); spB0.x = arg0->x + (ptr->x * 16.0f); @@ -140,25 +140,25 @@ void func_809AAFE8(Vec3f* arg0, GlobalContext* globalCtx) { 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, + EffectSsKakera_Spawn(play, &spB0, &spBC, &spB0, -100, 64, 40, 3, 0, D_809ABC3C[(s32)(Rand_ZeroOne() * 111.1f) % 7], 0, 0, 80, -1, 1, gKakeraLeafTip); } } -void ObjGrassCarry_Init(Actor* thisx, GlobalContext* globalCtx) { +void ObjGrassCarry_Init(Actor* thisx, PlayState* play) { ObjGrassCarry* this = THIS; Actor_ProcessInitChain(&this->actor, sInitChain); - Collider_InitCylinder(globalCtx, &this->collider); - Collider_SetCylinder(globalCtx, &this->collider, &this->actor, &sCylinderInit); + Collider_InitCylinder(play, &this->collider); + Collider_SetCylinder(play, &this->collider, &this->actor, &sCylinderInit); this->actor.colChkInfo.mass = 80; func_809AB3C4(this); } -void ObjGrassCarry_Destroy(Actor* thisx, GlobalContext* globalCtx) { +void ObjGrassCarry_Destroy(Actor* thisx, PlayState* play) { ObjGrassCarry* this = THIS; - Collider_DestroyCylinder(globalCtx, &this->collider); + Collider_DestroyCylinder(play, &this->collider); if (this->unk_190 != NULL) { ObjGrassCarry** carry = &this->unk_190->unk_3298[this->actor.params]; @@ -174,7 +174,7 @@ void func_809AB3C4(ObjGrassCarry* this) { this->actionFunc = func_809AB3D8; } -void func_809AB3D8(ObjGrassCarry* this, GlobalContext* globalCtx) { +void func_809AB3D8(ObjGrassCarry* this, PlayState* play) { if (this->unk_190 != NULL) { if (this->actor.params != this->unk_190->unk_3292) { func_809AB474(this); @@ -188,7 +188,7 @@ void func_809AB428(ObjGrassCarry* this) { this->actionFunc = func_809AB43C; } -void func_809AB43C(ObjGrassCarry* this, GlobalContext* globalCtx) { +void func_809AB43C(ObjGrassCarry* this, PlayState* play) { if (this->actor.params != this->unk_190->unk_3292) { func_809AB474(this); } @@ -205,10 +205,10 @@ void func_809AB474(ObjGrassCarry* this) { this->actor.world.rot.x = this->actor.shape.rot.z; } -void func_809AB4A8(ObjGrassCarry* this, GlobalContext* globalCtx) { +void func_809AB4A8(ObjGrassCarry* this, PlayState* play) { ObjGrassCarry* this2 = this; - if (Actor_HasParent(&this->actor, globalCtx)) { + if (Actor_HasParent(&this->actor, play)) { func_809AB5FC(this); if (this->unk_194 != NULL) { this->unk_194->unk_0F |= 4; @@ -219,9 +219,9 @@ void func_809AB4A8(ObjGrassCarry* this, GlobalContext* globalCtx) { 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); + SoundSource_PlaySfxAtFixedWorldPos(play, &this->actor.world.pos, 20, NA_SE_PL_PULL_UP_PLANT); } else if (this->unk_190->unk_3294 != NULL) { - Player* player = GET_PLAYER(globalCtx); + Player* player = GET_PLAYER(play); this->unk_194 = this->unk_190->unk_3294; Math_Vec3f_Copy(&this->actor.world.pos, &this->unk_194->unk_00); @@ -231,7 +231,7 @@ void func_809AB4A8(ObjGrassCarry* this, GlobalContext* globalCtx) { 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); + Actor_LiftActor(&this->actor, play); } } @@ -239,26 +239,26 @@ void func_809AB5FC(ObjGrassCarry* this) { this->actionFunc = func_809AB610; } -void func_809AB610(ObjGrassCarry* this, GlobalContext* globalCtx) { +void func_809AB610(ObjGrassCarry* this, PlayState* play) { s32 pad; Vec3f sp30; s32 sp2C; - if (Actor_HasNoParent(&this->actor, globalCtx)) { + if (Actor_HasNoParent(&this->actor, play)) { func_809AB6FC(this); this->actor.velocity.x = Math_SinS(this->actor.world.rot.y) * this->actor.speedXZ; this->actor.velocity.z = Math_CosS(this->actor.world.rot.y) * this->actor.speedXZ; this->actor.gravity = -0.1f; this->actor.terminalVelocity = -17.0f; func_809AAF18(this); - func_809AAF58(this, globalCtx); + func_809AAF58(this, play); 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); + BgCheck_EntityRaycastFloor5(&play->colCtx, &this->actor.floorPoly, &sp2C, &this->actor, &sp30); } } @@ -271,7 +271,7 @@ void func_809AB6FC(ObjGrassCarry* this) { this->unk_19A = 60; } -void func_809AB77C(ObjGrassCarry* this, GlobalContext* globalCtx) { +void func_809AB77C(ObjGrassCarry* this, PlayState* play) { s16 phi_s0; s32 temp_v0 = (this->collider.base.atFlags & AT_HIT) != 0; Vec3f sp5C; @@ -284,8 +284,8 @@ void func_809AB77C(ObjGrassCarry* this, GlobalContext* globalCtx) { 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); + func_809AAFE8(&this->actor.world.pos, play); + func_809AAF9C(&this->actor.world.pos, this->unk_198, play); this->actor.draw = NULL; this->actor.shape.shadowDraw = NULL; @@ -295,7 +295,7 @@ void func_809AB77C(ObjGrassCarry* this, GlobalContext* globalCtx) { } if (!(this->actor.bgCheckFlags & 0x20)) { - SoundSource_PlaySfxAtFixedWorldPos(globalCtx, &this->actor.world.pos, 20, NA_SE_EV_PLANT_BROKEN); + SoundSource_PlaySfxAtFixedWorldPos(play, &this->actor.world.pos, 20, NA_SE_EV_PLANT_BROKEN); } func_809AB428(this); return; @@ -307,14 +307,14 @@ void func_809AB77C(ObjGrassCarry* this, GlobalContext* globalCtx) { 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); + EffectSsGSplash_Spawn(play, &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); + EffectSsGSplash_Spawn(play, &sp5C, NULL, NULL, 0, 280); + EffectSsGRipple_Spawn(play, &sp5C, 300, 700, 0); this->actor.terminalVelocity = -3.0f; this->actor.velocity.x *= 0.1f; @@ -327,7 +327,7 @@ void func_809AB77C(ObjGrassCarry* this, GlobalContext* globalCtx) { 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); + SoundSource_PlaySfxAtFixedWorldPos(play, &this->actor.world.pos, 40, NA_SE_EV_DIVE_INTO_WATER_L); } Math_StepToS(&D_809ABC00, D_809ABBFC, 0x1F4); @@ -335,14 +335,14 @@ void func_809AB77C(ObjGrassCarry* this, GlobalContext* globalCtx) { this->actor.shape.rot.x += D_809ABC00; this->actor.shape.rot.y += D_809ABC08; func_809AAF18(this); - func_809AAF58(this, globalCtx); + func_809AAF58(this, play); Collider_UpdateCylinder(&this->actor, &this->collider); - CollisionCheck_SetAT(globalCtx, &globalCtx->colChkCtx, &this->collider.base); - CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + CollisionCheck_SetAT(play, &play->colChkCtx, &this->collider.base); + CollisionCheck_SetOC(play, &play->colChkCtx, &this->collider.base); } -void ObjGrassCarry_Update(Actor* thisx, GlobalContext* globalCtx) { +void ObjGrassCarry_Update(Actor* thisx, PlayState* play) { ObjGrassCarry* this = THIS; if (this->unk_190 == NULL) { @@ -352,9 +352,9 @@ void ObjGrassCarry_Update(Actor* thisx, GlobalContext* globalCtx) { } } - this->actionFunc(this, globalCtx); + this->actionFunc(this, play); } -void func_809ABB7C(Actor* this, GlobalContext* globalCtx) { - Gfx_DrawDListOpa(globalCtx, gKusaBushType1); +void func_809ABB7C(Actor* this, PlayState* play) { + Gfx_DrawDListOpa(play, 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 50d2f61f7..0e59033fc 100644 --- a/src/overlays/actors/ovl_Obj_Grass_Carry/z_obj_grass_carry.h +++ b/src/overlays/actors/ovl_Obj_Grass_Carry/z_obj_grass_carry.h @@ -7,16 +7,16 @@ struct ObjGrassCarry; struct ObjGrass; struct ObjGrassStruct1_1; -typedef void (*ObjGrassCarryActionFunc)(struct ObjGrassCarry*, GlobalContext*); +typedef void (*ObjGrassCarryActionFunc)(struct ObjGrassCarry*, PlayState*); typedef struct ObjGrassCarry { - /* 0x0000 */ Actor actor; - /* 0x0144 */ ColliderCylinder collider; - /* 0x0190 */ struct ObjGrass* unk_190; - /* 0x0194 */ struct ObjGrassStruct1_1* unk_194; - /* 0x0198 */ s16 unk_198; - /* 0x019A */ s16 unk_19A; - /* 0x019C */ ObjGrassCarryActionFunc actionFunc; + /* 0x000 */ Actor actor; + /* 0x144 */ ColliderCylinder collider; + /* 0x190 */ struct ObjGrass* unk_190; + /* 0x194 */ struct ObjGrassStruct1_1* unk_194; + /* 0x198 */ s16 unk_198; + /* 0x19A */ s16 unk_19A; + /* 0x19C */ ObjGrassCarryActionFunc actionFunc; } ObjGrassCarry; // size = 0x1A0 extern const ActorInit Obj_Grass_Carry_InitVars; diff --git a/src/overlays/actors/ovl_Obj_Grass_Unit/z_obj_grass_unit.c b/src/overlays/actors/ovl_Obj_Grass_Unit/z_obj_grass_unit.c index 88beb7a6b..125c78850 100644 --- a/src/overlays/actors/ovl_Obj_Grass_Unit/z_obj_grass_unit.c +++ b/src/overlays/actors/ovl_Obj_Grass_Unit/z_obj_grass_unit.c @@ -10,7 +10,7 @@ #define THIS ((ObjGrassUnit*)thisx) -void ObjGrassUnit_Init(Actor* thisx, GlobalContext* globalCtx); +void ObjGrassUnit_Init(Actor* thisx, PlayState* play); #if 0 const ActorInit Obj_Grass_Unit_InitVars = { 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 4b96d3a77..8e5a6d4a0 100644 --- a/src/overlays/actors/ovl_Obj_Hakaisi/z_obj_hakaisi.c +++ b/src/overlays/actors/ovl_Obj_Hakaisi/z_obj_hakaisi.c @@ -11,31 +11,31 @@ #define THIS ((ObjHakaisi*)thisx) -void ObjHakaisi_Init(Actor* thisx, GlobalContext* globalCtx); -void ObjHakaisi_Destroy(Actor* thisx, GlobalContext* globalCtx); -void ObjHakaisi_Update(Actor* thisx, GlobalContext* globalCtx); -void ObjHakaisi_Draw(Actor* thisx, GlobalContext* globalCtx); +void ObjHakaisi_Init(Actor* thisx, PlayState* play); +void ObjHakaisi_Destroy(Actor* thisx, PlayState* play); +void ObjHakaisi_Update(Actor* thisx, PlayState* play); +void ObjHakaisi_Draw(Actor* thisx, PlayState* play); void func_80B1444C(ObjHakaisi* this); -void func_80B14460(ObjHakaisi* this, GlobalContext* globalCtx); +void func_80B14460(ObjHakaisi* this, PlayState* play); void func_80B14510(ObjHakaisi* this); -void func_80B14524(ObjHakaisi* this, GlobalContext* globalCtx); +void func_80B14524(ObjHakaisi* this, PlayState* play); void func_80B14558(ObjHakaisi* this); -void func_80B1456C(ObjHakaisi* this, GlobalContext* globalCtx); +void func_80B1456C(ObjHakaisi* this, PlayState* play); void func_80B145F4(ObjHakaisi* this); -void func_80B14648(ObjHakaisi* this, GlobalContext* globalCtx); +void func_80B14648(ObjHakaisi* this, PlayState* play); 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_80B149C0(ObjHakaisi* this, PlayState* play); +void func_80B14A24(ObjHakaisi* this, PlayState* play, Vec3f vec); +void func_80B14B6C(ObjHakaisi* this, PlayState* play, Vec3f vec, s16 arg3); +void func_80B14CF8(PlayState* play, Vec3f vec, s16 arg2, s16 arg3, s32 arg4); +void func_80B14F4C(ObjHakaisi* this, PlayState* play, s32 arg2); +void func_80B151E0(ObjHakaisi* this, PlayState* play); +void func_80B15254(Actor* thisx, PlayState* play); 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); +void func_80B15330(ObjHakaisi* this, PlayState* play); +void func_80B1544C(Actor* thisx, PlayState* play); +void func_80B154A0(Actor* thisx, PlayState* play); const ActorInit Obj_Hakaisi_InitVars = { ACTOR_OBJ_HAKAISI, @@ -63,7 +63,7 @@ Color_RGBA8 D_80B155FC = { 100, 60, 20, 0 }; Vec3f D_80B15600 = { 1.0f, 0.0f, 0.0f }; -void ObjHakaisi_Init(Actor* thisx, GlobalContext* globalCtx) { +void ObjHakaisi_Init(Actor* thisx, PlayState* play) { s32 pad; ObjHakaisi* this = THIS; CollisionHeader* sp7C = NULL; @@ -89,7 +89,7 @@ void ObjHakaisi_Init(Actor* thisx, GlobalContext* globalCtx) { case 4: case 5: - func_80B151E0(this, globalCtx); + func_80B151E0(this, play); return; default: @@ -109,7 +109,7 @@ void ObjHakaisi_Init(Actor* thisx, GlobalContext* globalCtx) { DynaPolyActor_Init(&this->dyna, 1); CollisionHeader_GetVirtual(&object_hakaisi_Colheader_002FC4, &sp7C); - this->dyna.bgId = DynaPoly_SetBgActor(globalCtx, &globalCtx->colCtx.dyna, &this->dyna.actor, sp7C); + this->dyna.bgId = DynaPoly_SetBgActor(play, &play->colCtx.dyna, &this->dyna.actor, sp7C); this->unk_19A = 0; this->unk_198 = 0; this->switchFlag = OBJHAKAISI_GET_SWITCHFLAG(thisx); @@ -119,11 +119,11 @@ void ObjHakaisi_Init(Actor* thisx, GlobalContext* globalCtx) { this->switchFlag = -1; } - if ((this->switchFlag != -1) && Flags_GetSwitch(globalCtx, this->switchFlag)) { + if ((this->switchFlag != -1) && Flags_GetSwitch(play, this->switchFlag)) { Actor_MarkForDeath(&this->dyna.actor); } - Actor_UpdateBgCheckInfo(globalCtx, &this->dyna.actor, 0.0f, 0.0f, 0.0f, 4); + Actor_UpdateBgCheckInfo(play, &this->dyna.actor, 0.0f, 0.0f, 0.0f, 4); if (this->dyna.actor.floorPoly == NULL) { Actor_MarkForDeath(&this->dyna.actor); @@ -131,29 +131,29 @@ void ObjHakaisi_Init(Actor* thisx, GlobalContext* globalCtx) { func_800C0094(this->dyna.actor.floorPoly, this->dyna.actor.world.pos.x, this->dyna.actor.floorHeight, this->dyna.actor.world.pos.z, &sp3C); - Matrix_SetCurrentState(&sp3C); - Matrix_RotateY(this->dyna.actor.shape.rot.y, MTXMODE_APPLY); + Matrix_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_CopyCurrentState(&sp3C); - func_8018219C(&sp3C, &this->dyna.actor.shape.rot, 1); + Matrix_Get(&sp3C); + Matrix_MtxFToYXZRot(&sp3C, &this->dyna.actor.shape.rot, true); this->dyna.actor.world.rot = this->dyna.actor.shape.rot; - Matrix_SetStateRotationAndTranslation(this->dyna.actor.world.pos.x, this->dyna.actor.world.pos.y, - this->dyna.actor.world.pos.z, &this->dyna.actor.shape.rot); + Matrix_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_MultiplyVector3fByState(&D_80B155B0, &this->dyna.actor.focus.pos); + Matrix_MultVec3f(&D_80B155B0, &this->dyna.actor.focus.pos); for (i = 0; i < ARRAY_COUNT(D_80B155BC); i++) { - Matrix_MultiplyVector3fByState(&D_80B155BC[i], &this->unk_160[i]); + Matrix_MultVec3f(&D_80B155BC[i], &this->unk_160[i]); } func_80B1444C(this); } -void ObjHakaisi_Destroy(Actor* thisx, GlobalContext* globalCtx) { +void ObjHakaisi_Destroy(Actor* thisx, PlayState* play) { ObjHakaisi* this = THIS; if (OBJHAKAISI_GET_FF(&this->dyna.actor) != 3) { - DynaPoly_DeleteBgActor(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); + DynaPoly_DeleteBgActor(play, &play->colCtx.dyna, this->dyna.bgId); } } @@ -161,14 +161,14 @@ void func_80B1444C(ObjHakaisi* this) { this->actionFunc = func_80B14460; } -void func_80B14460(ObjHakaisi* this, GlobalContext* globalCtx) { +void func_80B14460(ObjHakaisi* this, PlayState* play) { s16 sp26 = BINANG_SUB(this->dyna.actor.shape.rot.y, this->dyna.actor.yawTowardsPlayer); - if (Actor_ProcessTalkRequest(&this->dyna.actor, &globalCtx->state)) { + if (Actor_ProcessTalkRequest(&this->dyna.actor, &play->state)) { func_80B14510(this); } else if (this->dyna.actor.textId != 0) { if (ABS_ALT(sp26) < 0x2000) { - func_800B8614(&this->dyna.actor, globalCtx, 100.0f); + func_800B8614(&this->dyna.actor, play, 100.0f); } } @@ -181,8 +181,8 @@ void func_80B14510(ObjHakaisi* this) { this->actionFunc = func_80B14524; } -void func_80B14524(ObjHakaisi* this, GlobalContext* globalCtx) { - if (Actor_TextboxIsClosing(&this->dyna.actor, globalCtx)) { +void func_80B14524(ObjHakaisi* this, PlayState* play) { + if (Actor_TextboxIsClosing(&this->dyna.actor, play)) { func_80B1444C(this); } } @@ -191,7 +191,7 @@ void func_80B14558(ObjHakaisi* this) { this->actionFunc = func_80B1456C; } -void func_80B1456C(ObjHakaisi* this, GlobalContext* globalCtx) { +void func_80B1456C(ObjHakaisi* this, PlayState* play) { if (this->unk_196 != -1) { if (ActorCutscene_GetCanPlayNext(this->unk_196)) { ActorCutscene_StartAndSetUnkLinkFields(this->unk_196, &this->dyna.actor); @@ -201,7 +201,7 @@ void func_80B1456C(ObjHakaisi* this, GlobalContext* globalCtx) { } if (this->dyna.actor.colChkInfo.health < 30) { func_80B145F4(this); - func_800C62BC(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); + func_800C62BC(play, &play->colCtx.dyna, this->dyna.bgId); } } @@ -213,33 +213,33 @@ void func_80B145F4(ObjHakaisi* this) { this->actionFunc = func_80B14648; } -void func_80B14648(ObjHakaisi* this, GlobalContext* globalCtx) { +void func_80B14648(ObjHakaisi* this, PlayState* play) { if (this->unk_19A < 2) { - func_80B14CF8(globalCtx, this->unk_160[this->unk_194], 100, 30, 5); + func_80B14CF8(play, 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); + func_80B14A24(this, play, this->unk_160[this->unk_194]); + func_80B14A24(this, play, this->unk_160[this->unk_194]); + func_80B14B6C(this, play, this->unk_160[this->unk_194], 70); + Flags_SetSwitch(play, 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); + func_80B14A24(this, play, this->unk_160[this->unk_194]); + func_80B14A24(this, play, this->unk_160[this->unk_194]); + func_80B14F4C(this, play, 0); + func_80B14B6C(this, play, 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); + func_80B14A24(this, play, this->unk_160[this->unk_194]); + func_80B14A24(this, play, this->unk_160[this->unk_194]); + func_80B14B6C(this, play, this->unk_160[this->unk_194], 60); this->unk_194 = 2; } this->unk_19A = 0; @@ -255,7 +255,7 @@ void func_80B149A8(ObjHakaisi* this) { this->actionFunc = func_80B149C0; } -void func_80B149C0(ObjHakaisi* this, GlobalContext* globalCtx) { +void func_80B149C0(ObjHakaisi* this, PlayState* play) { if (this->unk_19A < 60) { this->unk_19A++; } else if ((this->unk_196 != -1) && !ActorCutscene_GetCanPlayNext(this->unk_196)) { @@ -263,20 +263,20 @@ void func_80B149C0(ObjHakaisi* this, GlobalContext* globalCtx) { } } -void func_80B14A24(ObjHakaisi* this, GlobalContext* globalCtx, Vec3f vec) { +void func_80B14A24(ObjHakaisi* this, PlayState* play, Vec3f vec) { s32 i; - func_80B14CF8(globalCtx, vec, 100, 30, 5); + func_80B14CF8(play, 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); + EffectSsHahen_SpawnBurst(play, &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) { +void func_80B14B6C(ObjHakaisi* this, PlayState* play, Vec3f vec, s16 arg3) { s32 i; s16 temp_s1; Vec3f sp6C; @@ -290,13 +290,13 @@ void func_80B14B6C(ObjHakaisi* this, GlobalContext* globalCtx, Vec3f vec, s16 ar 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); + EffectSsHahen_SpawnBurst(play, &sp6C, 10.0f, 0, arg3, 30, 2, OBJECT_HAKAISI, 15, object_hakaisi_DL_0021B0); } - func_80B14CF8(globalCtx, vec, 100, 50, 20); + func_80B14CF8(play, vec, 100, 50, 20); } -void func_80B14CF8(GlobalContext* globalCtx, Vec3f vec, s16 arg2, s16 arg3, s32 arg4) { +void func_80B14CF8(PlayState* play, Vec3f vec, s16 arg2, s16 arg3, s32 arg4) { s32 i; s16 temp_s0; Vec3f spAC; @@ -322,54 +322,54 @@ void func_80B14CF8(GlobalContext* globalCtx, Vec3f vec, s16 arg2, s16 arg3, s32 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); + func_800B0EB0(play, &spAC, &spA0, &sp94, &D_80B155F8, &D_80B155FC, arg2, arg3, 10); } } -void func_80B14F4C(ObjHakaisi* this, GlobalContext* globalCtx, s32 arg2) { +void func_80B14F4C(ObjHakaisi* this, PlayState* play, s32 arg2) { if (arg2 == 0) { - Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_OBJ_HAKAISI, this->dyna.actor.world.pos.x, + Actor_Spawn(&play->actorCtx, play, 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, + Actor_Spawn(&play->actorCtx, play, 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) { +void ObjHakaisi_Update(Actor* thisx, PlayState* play) { ObjHakaisi* this = THIS; - this->actionFunc(this, globalCtx); + this->actionFunc(this, play); } -void ObjHakaisi_Draw(Actor* thisx, GlobalContext* globalCtx) { +void ObjHakaisi_Draw(Actor* thisx, PlayState* play) { ObjHakaisi* this = THIS; - OPEN_DISPS(globalCtx->state.gfxCtx); + OPEN_DISPS(play->state.gfxCtx); - func_8012C28C(globalCtx->state.gfxCtx); + func_8012C28C(play->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); + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(play->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); + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(play->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); + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_OPA_DISP++, object_hakaisi_DL_002CC0); } - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->state.gfxCtx); } -void func_80B151E0(ObjHakaisi* this, GlobalContext* globalCtx) { +void func_80B151E0(ObjHakaisi* this, PlayState* play) { this->dyna.actor.update = func_80B1544C; this->dyna.actor.draw = func_80B154A0; this->dyna.actor.destroy = func_80B15254; @@ -379,24 +379,24 @@ void func_80B151E0(ObjHakaisi* this, GlobalContext* globalCtx) { func_80B15264(this); } -void func_80B15254(Actor* thisx, GlobalContext* globalCtx) { +void func_80B15254(Actor* thisx, PlayState* play) { } void func_80B15264(ObjHakaisi* this) { s32 pad; s16 sp32 = Rand_Next(); - Matrix_InsertRotation(Rand_Next(), Rand_Next(), Rand_Next(), MTXMODE_NEW); - Matrix_MultiplyVector3fByState(&D_80B15600, &this->unk_184); + 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 = Rand_Next() >> 0x12; + 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) { +void func_80B15330(ObjHakaisi* this, PlayState* play) { s32 pad; MtxF sp34; @@ -404,40 +404,40 @@ void func_80B15330(ObjHakaisi* this, GlobalContext* globalCtx) { 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); + func_80B14B6C(this, play, this->dyna.actor.world.pos, 40); + func_80B14CF8(play, this->dyna.actor.world.pos, 100, 30, 10); Actor_MarkForDeath(&this->dyna.actor); } - Matrix_InsertRotationAroundUnitVector_s(this->unk_19C, &this->unk_184, MTXMODE_NEW); - Matrix_RotateY(this->dyna.actor.shape.rot.y, MTXMODE_APPLY); - Matrix_InsertXRotation_s(this->dyna.actor.shape.rot.x, MTXMODE_APPLY); - Matrix_InsertZRotation_s(this->dyna.actor.shape.rot.z, MTXMODE_APPLY); - Matrix_CopyCurrentState(&sp34); + 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); - func_8018219C(&sp34, &this->dyna.actor.shape.rot, 0); + Matrix_MtxFToYXZRot(&sp34, &this->dyna.actor.shape.rot, false); } -void func_80B1544C(Actor* thisx, GlobalContext* globalCtx) { +void func_80B1544C(Actor* thisx, PlayState* play) { ObjHakaisi* this = THIS; - this->actionFunc(this, globalCtx); + this->actionFunc(this, play); - Actor_UpdateBgCheckInfo(globalCtx, &this->dyna.actor, 0.0f, 0.0f, 0.0f, 4); + Actor_UpdateBgCheckInfo(play, &this->dyna.actor, 0.0f, 0.0f, 0.0f, 4); } -void func_80B154A0(Actor* thisx, GlobalContext* globalCtx) { - OPEN_DISPS(globalCtx->state.gfxCtx); +void func_80B154A0(Actor* thisx, PlayState* play) { + OPEN_DISPS(play->state.gfxCtx); - func_8012C28C(globalCtx->state.gfxCtx); + func_8012C28C(play->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); + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(play->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); + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_OPA_DISP++, object_hakaisi_DL_0021B0); } - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->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 4f1d1ada9..a4e5d233c 100644 --- a/src/overlays/actors/ovl_Obj_Hakaisi/z_obj_hakaisi.h +++ b/src/overlays/actors/ovl_Obj_Hakaisi/z_obj_hakaisi.h @@ -5,23 +5,23 @@ struct ObjHakaisi; -typedef void (*ObjHakaisiActionFunc)(struct ObjHakaisi*, GlobalContext*); +typedef void (*ObjHakaisiActionFunc)(struct ObjHakaisi*, PlayState*); #define OBJHAKAISI_GET_FF(thisx) ((thisx)->params & 0xFF) #define OBJHAKAISI_GET_SWITCHFLAG(thisx) (((thisx)->params & 0xFF00) >> 8) typedef struct ObjHakaisi { - /* 0x0000 */ DynaPolyActor dyna; - /* 0x015C */ ObjHakaisiActionFunc actionFunc; - /* 0x0160 */ Vec3f unk_160[3]; - /* 0x0184 */ Vec3f unk_184; - /* 0x0190 */ s32 switchFlag; - /* 0x0194 */ s16 unk_194; - /* 0x0196 */ s16 unk_196; - /* 0x0198 */ s16 unk_198; - /* 0x019A */ s16 unk_19A; - /* 0x019C */ s16 unk_19C; - /* 0x019E */ u8 unk_19E; + /* 0x000 */ DynaPolyActor dyna; + /* 0x15C */ ObjHakaisiActionFunc actionFunc; + /* 0x160 */ Vec3f unk_160[3]; + /* 0x184 */ Vec3f unk_184; + /* 0x190 */ s32 switchFlag; + /* 0x194 */ s16 unk_194; + /* 0x196 */ s16 unk_196; + /* 0x198 */ s16 unk_198; + /* 0x19A */ s16 unk_19A; + /* 0x19C */ s16 unk_19C; + /* 0x19E */ u8 unk_19E; } ObjHakaisi; // size = 0x1A0 extern const ActorInit Obj_Hakaisi_InitVars; diff --git a/src/overlays/actors/ovl_Obj_Hamishi/z_obj_hamishi.c b/src/overlays/actors/ovl_Obj_Hamishi/z_obj_hamishi.c index 10d8891ef..11baddb38 100644 --- a/src/overlays/actors/ovl_Obj_Hamishi/z_obj_hamishi.c +++ b/src/overlays/actors/ovl_Obj_Hamishi/z_obj_hamishi.c @@ -11,10 +11,10 @@ #define THIS ((ObjHamishi*)thisx) -void ObjHamishi_Init(Actor* thisx, GlobalContext* globalCtx); -void ObjHamishi_Destroy(Actor* thisx, GlobalContext* globalCtx); -void ObjHamishi_Update(Actor* thisx, GlobalContext* globalCtx); -void ObjHamishi_Draw(Actor* thisx, GlobalContext* globalCtx); +void ObjHamishi_Init(Actor* thisx, PlayState* play); +void ObjHamishi_Destroy(Actor* thisx, PlayState* play2); +void ObjHamishi_Update(Actor* thisx, PlayState* play); +void ObjHamishi_Draw(Actor* thisx, PlayState* play); const ActorInit Obj_Hamishi_InitVars = { ACTOR_OBJ_HAMISHI, @@ -61,11 +61,11 @@ static InitChainEntry sInitChain[] = { ICHAIN_F32(uncullZoneDownward, 500, ICHAIN_STOP), }; -void func_809A0F20(Actor* thisx, GlobalContext* globalCtx) { +void func_809A0F20(Actor* thisx, PlayState* play) { ObjHamishi* this = THIS; - Collider_InitCylinder(globalCtx, &this->collider); - Collider_SetCylinder(globalCtx, &this->collider, &this->actor, &sCylinderInit); + Collider_InitCylinder(play, &this->collider); + Collider_SetCylinder(play, &this->collider, &this->actor, &sCylinderInit); Collider_UpdateCylinder(&this->actor, &this->collider); } @@ -91,7 +91,7 @@ void func_809A0F78(ObjHamishi* this) { } } -void func_809A10F4(ObjHamishi* this, GlobalContext* globalCtx) { +void func_809A10F4(ObjHamishi* this, PlayState* play) { s32 i; Vec3f spC8; Vec3f spBC; @@ -125,15 +125,15 @@ void func_809A10F4(ObjHamishi* this, GlobalContext* globalCtx) { 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); + EffectSsKakera_Spawn(play, &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); + func_800BBFB0(play, &this->actor.world.pos, 140.0f, 6, 180, 90, 1); + func_800BBFB0(play, &this->actor.world.pos, 140.0f, 12, 80, 90, 1); } -void func_809A13A0(ObjHamishi* this, GlobalContext* globalCtx) { +void func_809A13A0(ObjHamishi* this, PlayState* play) { s32 pad; Vec3f sp28; s32 sp24; @@ -143,60 +143,63 @@ void func_809A13A0(ObjHamishi* this, GlobalContext* globalCtx) { sp28.z = this->actor.world.pos.z; this->actor.floorHeight = - BgCheck_EntityRaycastFloor5(&globalCtx->colCtx, &this->actor.floorPoly, &sp24, &this->actor, &sp28); + BgCheck_EntityRaycastFloor5(&play->colCtx, &this->actor.floorPoly, &sp24, &this->actor, &sp28); } -s32 func_809A1408(ObjHamishi* this, GlobalContext* globalCtx) { +s32 func_809A1408(ObjHamishi* this, PlayState* play) { 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) && + if (WaterBox_GetSurfaceImpl(play, &play->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) { +void ObjHamishi_Init(Actor* thisx, PlayState* play) { ObjHamishi* this = THIS; Actor_ProcessInitChain(&this->actor, sInitChain); - if (globalCtx->csCtx.state != 0) { + if (play->csCtx.state != 0) { this->actor.uncullZoneForward += 1000.0f; } if (this->actor.shape.rot.y == 0) { - this->actor.shape.rot.y = (u32)Rand_Next() >> 0x10; + this->actor.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); + func_809A0F20(&this->actor, play); CollisionCheck_SetInfo(&this->actor.colChkInfo, NULL, &sColChkInfoInit); - func_809A13A0(this, globalCtx); + func_809A13A0(this, play); ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 2.3f); - if (Flags_GetSwitch(globalCtx, OBJHAMISHI_GET_SWITCHFLAG(&this->actor))) { + if (Flags_GetSwitch(play, OBJHAMISHI_GET_SWITCHFLAG(&this->actor))) { Actor_MarkForDeath(&this->actor); return; } this->actor.shape.yOffset = 80.0f; - if (func_809A1408(this, globalCtx)) { + if (func_809A1408(this, play)) { this->unk_1A2 |= 1; } } -void ObjHamishi_Destroy(Actor* thisx, GlobalContext* globalCtx) { - Collider_DestroyCylinder(globalCtx, &THIS->collider); +void ObjHamishi_Destroy(Actor* thisx, PlayState* play2) { + PlayState* play = play2; + ObjHamishi* this = THIS; + + Collider_DestroyCylinder(play, &this->collider); } -void ObjHamishi_Update(Actor* thisx, GlobalContext* globalCtx) { +void ObjHamishi_Update(Actor* thisx, PlayState* play) { s32 pad; ObjHamishi* this = THIS; s32 sp24 = (this->collider.base.acFlags & AC_HIT) != 0; @@ -227,9 +230,9 @@ void ObjHamishi_Update(Actor* thisx, GlobalContext* globalCtx) { 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)); + func_809A10F4(this, play); + SoundSource_PlaySfxAtFixedWorldPos(play, &this->actor.world.pos, 40, NA_SE_EV_WALL_BROKEN); + Flags_SetSwitch(play, OBJHAMISHI_GET_SWITCHFLAG(&this->actor)); Actor_MarkForDeath(&this->actor); } } @@ -248,41 +251,41 @@ void ObjHamishi_Update(Actor* thisx, GlobalContext* globalCtx) { 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); + CollisionCheck_SetAC(play, &play->colChkCtx, &this->collider.base); } if (this->actor.xzDistToPlayer < 600.0f) { - CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + CollisionCheck_SetOC(play, &play->colChkCtx, &this->collider.base); } } } -void ObjHamishi_Draw(Actor* thisx, GlobalContext* globalCtx) { +void ObjHamishi_Draw(Actor* thisx, PlayState* play) { ObjHamishi* this = THIS; - OPEN_DISPS(globalCtx->state.gfxCtx); + OPEN_DISPS(play->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); + func_8012C28C(play->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); + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(play->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); + func_8012C2DC(play->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); + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(play->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); + CLOSE_DISPS(play->state.gfxCtx); } diff --git a/src/overlays/actors/ovl_Obj_Hana/z_obj_hana.c b/src/overlays/actors/ovl_Obj_Hana/z_obj_hana.c index 93578ac40..6eb0b0adc 100644 --- a/src/overlays/actors/ovl_Obj_Hana/z_obj_hana.c +++ b/src/overlays/actors/ovl_Obj_Hana/z_obj_hana.c @@ -11,10 +11,10 @@ #define THIS ((ObjHana*)thisx) -void ObjHana_Init(Actor* thisx, GlobalContext* globalCtx); -void ObjHana_Destroy(Actor* thisx, GlobalContext* globalCtx); -void ObjHana_Update(Actor* thisx, GlobalContext* globalCtx); -void ObjHana_Draw(Actor* thisx, GlobalContext* globalCtx); +void ObjHana_Init(Actor* thisx, PlayState* play); +void ObjHana_Destroy(Actor* thisx, PlayState* play); +void ObjHana_Update(Actor* thisx, PlayState* play); +void ObjHana_Draw(Actor* thisx, PlayState* play); const ActorInit Obj_Hana_InitVars = { ACTOR_OBJ_HANA, @@ -35,18 +35,18 @@ static InitChainEntry sInitChain[] = { ICHAIN_F32(uncullZoneDownward, 40, ICHAIN_STOP), }; -void ObjHana_Init(Actor* thisx, GlobalContext* globalCtx) { +void ObjHana_Init(Actor* thisx, PlayState* play) { ObjHana* this = THIS; Actor_ProcessInitChain(&this->actor, sInitChain); } -void ObjHana_Destroy(Actor* thisx, GlobalContext* globalCtx) { +void ObjHana_Destroy(Actor* thisx, PlayState* play) { } -void ObjHana_Update(Actor* thisx, GlobalContext* globalCtx) { +void ObjHana_Update(Actor* thisx, PlayState* play) { } -void ObjHana_Draw(Actor* thisx, GlobalContext* globalCtx) { - Gfx_DrawDListOpa(globalCtx, object_hana_DL_000500); +void ObjHana_Draw(Actor* thisx, PlayState* play) { + Gfx_DrawDListOpa(play, object_hana_DL_000500); } 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 f07b9c6d4..c0537940c 100644 --- a/src/overlays/actors/ovl_Obj_Hariko/z_obj_hariko.c +++ b/src/overlays/actors/ovl_Obj_Hariko/z_obj_hariko.c @@ -11,15 +11,15 @@ #define THIS ((ObjHariko*)thisx) -void ObjHariko_Init(Actor* thisx, GlobalContext* globalCtx); -void ObjHariko_Destroy(Actor* thisx, GlobalContext* globalCtx); -void ObjHariko_Update(Actor* thisx, GlobalContext* globalCtx); -void ObjHariko_Draw(Actor* thisx, GlobalContext* globalCtx); +void ObjHariko_Init(Actor* thisx, PlayState* play); +void ObjHariko_Destroy(Actor* thisx, PlayState* play); +void ObjHariko_Update(Actor* thisx, PlayState* play); +void ObjHariko_Draw(Actor* thisx, PlayState* play); void ObjHariko_SetupWait(ObjHariko* this); -void ObjHariko_Wait(ObjHariko* this, GlobalContext* globalCtx); +void ObjHariko_Wait(ObjHariko* this, PlayState* play); void ObjHariko_SetupBobHead(ObjHariko* this); -void ObjHariko_BobHead(ObjHariko* this, GlobalContext* globalCtx); +void ObjHariko_BobHead(ObjHariko* this, PlayState* play); void ObjHariko_CheckForQuakes(ObjHariko* this); const ActorInit Obj_Hariko_InitVars = { @@ -34,7 +34,7 @@ const ActorInit Obj_Hariko_InitVars = { (ActorFunc)ObjHariko_Draw, }; -void ObjHariko_Init(Actor* thisx, GlobalContext* globalCtx) { +void ObjHariko_Init(Actor* thisx, PlayState* play) { ObjHariko* this = THIS; Actor_SetScale(&this->actor, 0.1f); @@ -46,14 +46,14 @@ void ObjHariko_Init(Actor* thisx, GlobalContext* globalCtx) { ObjHariko_SetupWait(this); } -void ObjHariko_Destroy(Actor* thisx, GlobalContext* globalCtx) { +void ObjHariko_Destroy(Actor* thisx, PlayState* play) { } void ObjHariko_SetupWait(ObjHariko* this) { this->actionFunc = ObjHariko_Wait; } -void ObjHariko_Wait(ObjHariko* this, GlobalContext* globalCtx) { +void ObjHariko_Wait(ObjHariko* this, PlayState* play) { } void ObjHariko_SetupBobHead(ObjHariko* this) { @@ -62,7 +62,7 @@ void ObjHariko_SetupBobHead(ObjHariko* this) { this->actionFunc = ObjHariko_BobHead; } -void ObjHariko_BobHead(ObjHariko* this, GlobalContext* globalCtx) { +void ObjHariko_BobHead(ObjHariko* this, PlayState* play) { this->headOffset += 0x1555; this->headRotation.x = Math_SinS(this->headOffset) * this->bobbleStep; this->headRotation.y = Math_CosS(this->headOffset) * this->bobbleStep; @@ -78,27 +78,27 @@ void ObjHariko_CheckForQuakes(ObjHariko* this) { } } -void ObjHariko_Update(Actor* thisx, GlobalContext* globalCtx) { +void ObjHariko_Update(Actor* thisx, PlayState* play) { ObjHariko* this = THIS; - this->actionFunc(this, globalCtx); + this->actionFunc(this, play); ObjHariko_CheckForQuakes(this); } -void ObjHariko_Draw(Actor* thisx, GlobalContext* globalCtx) { +void ObjHariko_Draw(Actor* thisx, PlayState* play) { ObjHariko* this = THIS; - OPEN_DISPS(globalCtx->state.gfxCtx); - func_8012C28C(globalCtx->state.gfxCtx); + OPEN_DISPS(play->state.gfxCtx); + func_8012C28C(play->state.gfxCtx); - Matrix_StatePush(); - Matrix_InsertXRotation_s(this->headRotation.x, MTXMODE_APPLY); - Matrix_RotateY(this->headRotation.y, MTXMODE_APPLY); + 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); + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_OPA_DISP++, gHarikoBodyDL); gSPDisplayList(POLY_OPA_DISP++, gHarikoFaceDL); - Matrix_StatePop(); - CLOSE_DISPS(globalCtx->state.gfxCtx); + Matrix_Pop(); + CLOSE_DISPS(play->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 12d4fe505..5d9a8e39b 100644 --- a/src/overlays/actors/ovl_Obj_Hariko/z_obj_hariko.h +++ b/src/overlays/actors/ovl_Obj_Hariko/z_obj_hariko.h @@ -5,15 +5,15 @@ struct ObjHariko; -typedef void (*ObjHarikoActionFunc)(struct ObjHariko*, GlobalContext*); +typedef void (*ObjHarikoActionFunc)(struct ObjHariko*, PlayState*); typedef struct ObjHariko { - /* 0x0000 */ Actor actor; - /* 0x0144 */ ObjHarikoActionFunc actionFunc; - /* 0x0148 */ f32 bobbleStep; - /* 0x014C */ Vec3s headRotation; - /* 0x0152 */ s16 headOffset; - /* 0x0154 */ s16 unk154; // Set but not used + /* 0x000 */ Actor actor; + /* 0x144 */ ObjHarikoActionFunc actionFunc; + /* 0x148 */ f32 bobbleStep; + /* 0x14C */ Vec3s headRotation; + /* 0x152 */ s16 headOffset; + /* 0x154 */ s16 unk154; // Set but not used } ObjHariko; // size = 0x158 extern const ActorInit Obj_Hariko_InitVars; diff --git a/src/overlays/actors/ovl_Obj_Hgdoor/z_obj_hgdoor.c b/src/overlays/actors/ovl_Obj_Hgdoor/z_obj_hgdoor.c index 4e6b3791d..72aaa3e12 100644 --- a/src/overlays/actors/ovl_Obj_Hgdoor/z_obj_hgdoor.c +++ b/src/overlays/actors/ovl_Obj_Hgdoor/z_obj_hgdoor.c @@ -11,20 +11,20 @@ #define THIS ((ObjHgdoor*)thisx) -void ObjHgdoor_Init(Actor* thisx, GlobalContext* globalCtx); -void ObjHgdoor_Destroy(Actor* thisx, GlobalContext* globalCtx); -void ObjHgdoor_Update(Actor* thisx, GlobalContext* globalCtx); -void ObjHgdoor_Draw(Actor* thisx, GlobalContext* globalCtx); +void ObjHgdoor_Init(Actor* thisx, PlayState* play); +void ObjHgdoor_Destroy(Actor* thisx, PlayState* play); +void ObjHgdoor_Update(Actor* thisx, PlayState* play); +void ObjHgdoor_Draw(Actor* thisx, PlayState* play); void ObjHgdoor_SetupCheckShouldOpen(ObjHgdoor* this); -void ObjHgdoor_CheckShouldOpen(ObjHgdoor* this, GlobalContext* globalCtx); +void ObjHgdoor_CheckShouldOpen(ObjHgdoor* this, PlayState* play); void func_80BD42AC(ObjHgdoor* this); -void func_80BD42C0(ObjHgdoor* this, GlobalContext* globalCtx); +void func_80BD42C0(ObjHgdoor* this, PlayState* play); void func_80BD433C(ObjHgdoor* this); -void func_80BD4358(ObjHgdoor* this, GlobalContext* globalCtx); +void func_80BD4358(ObjHgdoor* this, PlayState* play); void func_80BD4460(ObjHgdoor* this); -void func_80BD4478(ObjHgdoor* this, GlobalContext* globalCtx); -s32 func_80BD44D0(ObjHgdoor* this, GlobalContext* globalCtx); +void func_80BD4478(ObjHgdoor* this, PlayState* play); +s32 func_80BD44D0(ObjHgdoor* this, PlayState* play); const ActorInit Obj_Hgdoor_InitVars = { ACTOR_OBJ_HGDOOR, @@ -42,8 +42,8 @@ static s16 D_80BD4690 = 0; static s32 unused = 0; static s32 unused2 = 0; -void ObjHgdoor_SetChild(ObjHgdoor* this, GlobalContext* globalCtx) { - Actor* actorIterator = globalCtx->actorCtx.actorLists[ACTORCAT_PROP].first; +void ObjHgdoor_SetChild(ObjHgdoor* this, PlayState* play) { + Actor* actorIterator = play->actorCtx.actorLists[ACTORCAT_PROP].first; while (actorIterator) { if ((actorIterator->id == ACTOR_OBJ_HGDOOR) && (&this->dyna.actor != actorIterator)) { @@ -54,8 +54,8 @@ void ObjHgdoor_SetChild(ObjHgdoor* this, GlobalContext* globalCtx) { } } -void ObjHgdoor_SetParent(ObjHgdoor* this, GlobalContext* globalCtx) { - Actor* actorIterator = globalCtx->actorCtx.actorLists[ACTORCAT_PROP].first; +void ObjHgdoor_SetParent(ObjHgdoor* this, PlayState* play) { + Actor* actorIterator = play->actorCtx.actorLists[ACTORCAT_PROP].first; while (actorIterator) { if (actorIterator->id == ACTOR_EN_HG) { @@ -66,7 +66,7 @@ void ObjHgdoor_SetParent(ObjHgdoor* this, GlobalContext* globalCtx) { } } -void ObjHgdoor_Init(Actor* thisx, GlobalContext* globalCtx) { +void ObjHgdoor_Init(Actor* thisx, PlayState* play) { ObjHgdoor* this = THIS; s32 pad; CollisionHeader* header = NULL; @@ -78,29 +78,29 @@ void ObjHgdoor_Init(Actor* thisx, GlobalContext* globalCtx) { } else { CollisionHeader_GetVirtual(&object_hgdoor_Colheader_0018C0, &header); } - this->dyna.bgId = DynaPoly_SetBgActor(globalCtx, &globalCtx->colCtx.dyna, &this->dyna.actor, header); + this->dyna.bgId = DynaPoly_SetBgActor(play, &play->colCtx.dyna, &this->dyna.actor, header); this->rotation = 0; this->timer = 0; this->cutscene = this->dyna.actor.cutscene; ObjHgdoor_SetupCheckShouldOpen(this); } -void ObjHgdoor_Destroy(Actor* thisx, GlobalContext* globalCtx) { +void ObjHgdoor_Destroy(Actor* thisx, PlayState* play) { ObjHgdoor* this = THIS; - DynaPoly_DeleteBgActor(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); + DynaPoly_DeleteBgActor(play, &play->colCtx.dyna, this->dyna.bgId); } void ObjHgdoor_SetupCheckShouldOpen(ObjHgdoor* this) { this->actionFunc = ObjHgdoor_CheckShouldOpen; } -void ObjHgdoor_CheckShouldOpen(ObjHgdoor* this, GlobalContext* globalCtx) { +void ObjHgdoor_CheckShouldOpen(ObjHgdoor* this, PlayState* play) { 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); - ObjHgdoor_SetParent(this, globalCtx); + ObjHgdoor_SetChild(this, play); + ObjHgdoor_SetParent(this, play); func_80BD42AC(this); } } @@ -109,7 +109,7 @@ void func_80BD42AC(ObjHgdoor* this) { this->actionFunc = func_80BD42C0; } -void func_80BD42C0(ObjHgdoor* this, GlobalContext* globalCtx) { +void func_80BD42C0(ObjHgdoor* this, PlayState* play) { if (ActorCutscene_GetCanPlayNext(this->cutscene)) { ActorCutscene_Start(this->cutscene, &this->dyna.actor); func_80BD433C(this); @@ -127,14 +127,14 @@ void func_80BD433C(ObjHgdoor* this) { this->actionFunc = func_80BD4358; } -void func_80BD4358(ObjHgdoor* this, GlobalContext* globalCtx) { +void func_80BD4358(ObjHgdoor* this, PlayState* play) { s32 actionIndex; - 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) { + if (Cutscene_CheckActorAction(play, 483)) { + actionIndex = Cutscene_GetActorActionIndex(play, 483); + if (this->unk166 != play->csCtx.actorActions[actionIndex]->action) { + this->unk166 = play->csCtx.actorActions[actionIndex]->action; + switch (play->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)) { @@ -146,7 +146,7 @@ void func_80BD4358(ObjHgdoor* this, GlobalContext* globalCtx) { break; } } - if ((D_80BD4690 == 1) && (func_80BD44D0(this, globalCtx))) { + if ((D_80BD4690 == 1) && (func_80BD44D0(this, play))) { func_80BD4460(this); } } else { @@ -159,13 +159,13 @@ void func_80BD4460(ObjHgdoor* this) { this->actionFunc = func_80BD4478; } -void func_80BD4478(ObjHgdoor* this, GlobalContext* globalCtx) { +void func_80BD4478(ObjHgdoor* this, PlayState* play) { if (this->timer++ > 80 && !ActorCutscene_GetCanPlayNext(this->cutscene)) { ActorCutscene_Stop(this->cutscene); } } -s32 func_80BD44D0(ObjHgdoor* this, GlobalContext* globalCtx) { +s32 func_80BD44D0(ObjHgdoor* this, PlayState* play) { if (this->rotation < 0x5555) { this->rotation += 0x1388; } else { @@ -184,18 +184,18 @@ void func_80BD4500(ObjHgdoor* this) { } } -void ObjHgdoor_Update(Actor* thisx, GlobalContext* globalCtx) { +void ObjHgdoor_Update(Actor* thisx, PlayState* play) { ObjHgdoor* this = THIS; - this->actionFunc(this, globalCtx); + this->actionFunc(this, play); func_80BD4500(this); } -void ObjHgdoor_Draw(Actor* thisx, GlobalContext* globalCtx) { - OPEN_DISPS(globalCtx->state.gfxCtx); - func_8012C28C(globalCtx->state.gfxCtx); +void ObjHgdoor_Draw(Actor* thisx, PlayState* play) { + OPEN_DISPS(play->state.gfxCtx); + func_8012C28C(play->state.gfxCtx); - gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); if (OBJHGDOOR_IS_RIGHT_DOOR(thisx)) { gSPDisplayList(POLY_OPA_DISP++, object_hgdoor_DL_001AB0); gSPDisplayList(POLY_OPA_DISP++, object_hgdoor_DL_001BA8); @@ -204,5 +204,5 @@ void ObjHgdoor_Draw(Actor* thisx, GlobalContext* globalCtx) { gSPDisplayList(POLY_OPA_DISP++, object_hgdoor_DL_001768); } - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->state.gfxCtx); } diff --git a/src/overlays/actors/ovl_Obj_Hgdoor/z_obj_hgdoor.h b/src/overlays/actors/ovl_Obj_Hgdoor/z_obj_hgdoor.h index a3590f424..803236ac1 100644 --- a/src/overlays/actors/ovl_Obj_Hgdoor/z_obj_hgdoor.h +++ b/src/overlays/actors/ovl_Obj_Hgdoor/z_obj_hgdoor.h @@ -5,7 +5,7 @@ struct ObjHgdoor; -typedef void (*ObjHgdoorActionFunc)(struct ObjHgdoor*, GlobalContext*); +typedef void (*ObjHgdoorActionFunc)(struct ObjHgdoor*, PlayState*); #define OBJHGDOOR_IS_RIGHT_DOOR(thisx) \ ((thisx)->params & 0x8000) // door on the right when looking at the cabinet 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 1ce6faa7d..9f19241ac 100644 --- a/src/overlays/actors/ovl_Obj_HsStump/z_obj_hsstump.c +++ b/src/overlays/actors/ovl_Obj_HsStump/z_obj_hsstump.c @@ -11,15 +11,15 @@ #define THIS ((ObjHsStump*)thisx) -void ObjHsStump_Init(Actor* thisx, GlobalContext* globalCtx); -void ObjHsStump_Destroy(Actor* thisx, GlobalContext* globalCtx); -void ObjHsStump_Update(Actor* thisx, GlobalContext* globalCtx); -void ObjHsStump_Draw(Actor* thisx, GlobalContext* globalCtx); +void ObjHsStump_Init(Actor* thisx, PlayState* play); +void ObjHsStump_Destroy(Actor* thisx, PlayState* play); +void ObjHsStump_Update(Actor* thisx, PlayState* play); +void ObjHsStump_Draw(Actor* thisx, PlayState* play); -void ObjHsStump_SetupIdle(ObjHsStump* this, GlobalContext* globalCtx); -void ObjHsStump_Idle(ObjHsStump* this, GlobalContext* globalCtx); -void ObjHsStump_SetupAppear(ObjHsStump* this, GlobalContext* globalCtx); -void ObjHsStump_Appear(ObjHsStump* this, GlobalContext* globalCtx); +void ObjHsStump_SetupIdle(ObjHsStump* this, PlayState* play); +void ObjHsStump_Idle(ObjHsStump* this, PlayState* play); +void ObjHsStump_SetupAppear(ObjHsStump* this, PlayState* play); +void ObjHsStump_Appear(ObjHsStump* this, PlayState* play); const ActorInit Obj_HsStump_InitVars = { ACTOR_OBJ_HSSTUMP, @@ -39,39 +39,39 @@ static InitChainEntry sInitChain[] = { static Vec3f sIceSmokeAccel = { 0.0f, 0.0f, 0.0f }; -void ObjHsStump_Init(Actor* thisx, GlobalContext* globalCtx) { +void ObjHsStump_Init(Actor* thisx, PlayState* play) { ObjHsStump* this = THIS; Actor_ProcessInitChain(&this->dyna.actor, sInitChain); this->isHidden = OBJHSSTUMP_GET_ISHIDDEN(thisx); this->switchFlag = OBJHSSTUMP_GET_SWITCHFLAG(thisx); DynaPolyActor_Init(&this->dyna, 1); - DynaPolyActor_LoadMesh(globalCtx, &this->dyna, &object_hsstump_Colheader_0011B0); + DynaPolyActor_LoadMesh(play, &this->dyna, &object_hsstump_Colheader_0011B0); switch (this->isHidden) { case true: - if (Flags_GetSwitch(globalCtx, this->switchFlag)) { + if (Flags_GetSwitch(play, this->switchFlag)) { this->isHidden = false; } else { this->dyna.actor.draw = NULL; Actor_SetScale(&this->dyna.actor, 0.0f); - func_800C62BC(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); + func_800C62BC(play, &play->colCtx.dyna, this->dyna.bgId); } case false: - ObjHsStump_SetupIdle(this, globalCtx); + ObjHsStump_SetupIdle(this, play); } } -void ObjHsStump_SetupIdle(ObjHsStump* this, GlobalContext* globalCtx) { +void ObjHsStump_SetupIdle(ObjHsStump* this, PlayState* play) { this->actionFunc = ObjHsStump_Idle; } -void ObjHsStump_Idle(ObjHsStump* this, GlobalContext* globalCtx) { - if (this->isHidden == true && Flags_GetSwitch(globalCtx, this->switchFlag)) { - ObjHsStump_SetupAppear(this, globalCtx); +void ObjHsStump_Idle(ObjHsStump* this, PlayState* play) { + if (this->isHidden == true && Flags_GetSwitch(play, this->switchFlag)) { + ObjHsStump_SetupAppear(this, play); } } -void ObjHsStump_SetupAppear(ObjHsStump* this, GlobalContext* globalCtx) { +void ObjHsStump_SetupAppear(ObjHsStump* this, PlayState* play) { this->dyna.actor.draw = ObjHsStump_Draw; this->framesAppeared = 0; this->rotAngle = 0; @@ -80,7 +80,7 @@ void ObjHsStump_SetupAppear(ObjHsStump* this, GlobalContext* globalCtx) { this->actionFunc = ObjHsStump_Appear; } -void ObjHsStump_Appear(ObjHsStump* this, GlobalContext* globalCtx) { +void ObjHsStump_Appear(ObjHsStump* this, PlayState* play) { if (this->framesAppeared >= 0) { Math_SmoothStepToF(&this->rotFactor, 0.0f, 1.0f, this->framesAppeared + 18.0f, 0.01f); this->dyna.actor.shape.rot.x = (Math_SinS(this->rotAngle) * this->rotFactor) + this->dyna.actor.home.rot.x; @@ -115,7 +115,7 @@ void ObjHsStump_Appear(ObjHsStump* this, GlobalContext* globalCtx) { Lib_Vec3f_TranslateAndRotateY(&this->dyna.actor.world.pos, offsetAngle, &iceSmokePosOffset, &iceSmokePos); Lib_Vec3f_TranslateAndRotateY(&gZeroVec3f, offsetAngle, &iceSmokeVelOffset, &iceSmokeVel); - EffectSsIceSmoke_Spawn(globalCtx, &iceSmokePos, &iceSmokeVel, &sIceSmokeAccel, 100); + EffectSsIceSmoke_Spawn(play, &iceSmokePos, &iceSmokeVel, &sIceSmokeAccel, 100); } } } @@ -125,24 +125,24 @@ void ObjHsStump_Appear(ObjHsStump* this, GlobalContext* globalCtx) { } 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); + func_800C6314(play, &play->colCtx.dyna, this->dyna.bgId); + ObjHsStump_SetupIdle(this, play); } this->framesAppeared++; } -void ObjHsStump_Destroy(Actor* thisx, GlobalContext* globalCtx) { +void ObjHsStump_Destroy(Actor* thisx, PlayState* play) { ObjHsStump* this = THIS; - DynaPoly_DeleteBgActor(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); + DynaPoly_DeleteBgActor(play, &play->colCtx.dyna, this->dyna.bgId); } -void ObjHsStump_Update(Actor* thisx, GlobalContext* globalCtx) { +void ObjHsStump_Update(Actor* thisx, PlayState* play) { ObjHsStump* this = THIS; - this->actionFunc(this, globalCtx); + this->actionFunc(this, play); } -void ObjHsStump_Draw(Actor* thisx, GlobalContext* globalCtx) { - Gfx_DrawDListOpa(globalCtx, object_hsstump_DL_0003B8); +void ObjHsStump_Draw(Actor* thisx, PlayState* play) { + Gfx_DrawDListOpa(play, object_hsstump_DL_0003B8); } diff --git a/src/overlays/actors/ovl_Obj_HsStump/z_obj_hsstump.h b/src/overlays/actors/ovl_Obj_HsStump/z_obj_hsstump.h index 899688b27..1f82a15b1 100644 --- a/src/overlays/actors/ovl_Obj_HsStump/z_obj_hsstump.h +++ b/src/overlays/actors/ovl_Obj_HsStump/z_obj_hsstump.h @@ -8,7 +8,7 @@ struct ObjHsStump; -typedef void (*ObjHsStumpActionFunc)(struct ObjHsStump*, GlobalContext*); +typedef void (*ObjHsStumpActionFunc)(struct ObjHsStump*, PlayState*); typedef struct ObjHsStump { /* 0x000 */ DynaPolyActor dyna; diff --git a/src/overlays/actors/ovl_Obj_Hsblock/z_obj_hsblock.c b/src/overlays/actors/ovl_Obj_Hsblock/z_obj_hsblock.c index 373815365..3339d1440 100644 --- a/src/overlays/actors/ovl_Obj_Hsblock/z_obj_hsblock.c +++ b/src/overlays/actors/ovl_Obj_Hsblock/z_obj_hsblock.c @@ -5,21 +5,24 @@ */ #include "z_obj_hsblock.h" +#include "objects/object_d_hsblock/object_d_hsblock.h" #define FLAGS 0x00000000 #define THIS ((ObjHsblock*)thisx) -void ObjHsblock_Init(Actor* thisx, GlobalContext* globalCtx); -void ObjHsblock_Destroy(Actor* thisx, GlobalContext* globalCtx); -void ObjHsblock_Update(Actor* thisx, GlobalContext* globalCtx); -void ObjHsblock_Draw(Actor* thisx, GlobalContext* globalCtx); +void ObjHsblock_Init(Actor* thisx, PlayState* play); +void ObjHsblock_Destroy(Actor* thisx, PlayState* play); +void ObjHsblock_Update(Actor* thisx, PlayState* play); +void ObjHsblock_Draw(Actor* thisx, PlayState* play); -void func_8093E0A0(ObjHsblock* this, GlobalContext* globalCtx); +void func_8093E0A0(ObjHsblock* this, PlayState* play); -void ObjHsblock_SetupAction(ObjHsblock* this, ObjHsblockActionFunc actionFunc); +void func_8093E03C(ObjHsblock* this); +void func_8093E05C(ObjHsblock* this); +void func_8093E0E8(ObjHsblock* this); +void func_8093E10C(ObjHsblock* this, PlayState* play); -#if 0 const ActorInit Obj_Hsblock_InitVars = { ACTOR_OBJ_HSBLOCK, ACTORCAT_BG, @@ -32,36 +35,120 @@ const ActorInit Obj_Hsblock_InitVars = { (ActorFunc)ObjHsblock_Draw, }; -// static InitChainEntry sInitChain[] = { -static InitChainEntry D_8093E33C[] = { +static f32 sFocusHeights[] = { 85.0f, 85.0f, 0.0f }; + +static InitChainEntry sInitChain[] = { ICHAIN_VEC3F_DIV1000(scale, 100, ICHAIN_CONTINUE), ICHAIN_F32(uncullZoneForward, 4000, ICHAIN_CONTINUE), ICHAIN_F32(uncullZoneScale, 100, ICHAIN_CONTINUE), ICHAIN_F32(uncullZoneDownward, 200, ICHAIN_STOP), }; -#endif +static CollisionHeader* sColHeaders[] = { + &gHookshotPostCol, + &gHookshotPostCol, + &gHookshotTargetCol, +}; -extern InitChainEntry D_8093E33C[]; +static Gfx* sDisplayLists[] = { gHookshotPostDL, gHookshotPostDL, gHookshotTargetDL }; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Hsblock/ObjHsblock_SetupAction.s") +void ObjHsblock_SetupAction(ObjHsblock* this, ObjHsblockActionFunc actionFunc) { + this->actionFunc = actionFunc; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Hsblock/func_8093DEAC.s") +void func_8093DEAC(ObjHsblock* this, PlayState* play) { + if (OBJHSBLOCK_GET_5(&this->dyna.actor) != 0) { + Actor_SpawnAsChild(&play->actorCtx, &this->dyna.actor, play, ACTOR_OBJ_ICE_POLY, this->dyna.actor.world.pos.x, + this->dyna.actor.world.pos.y, this->dyna.actor.world.pos.z, this->dyna.actor.world.rot.x, + this->dyna.actor.world.rot.y, this->dyna.actor.world.rot.z, 0xFF64); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Hsblock/ObjHsblock_Init.s") +void ObjHsblock_Init(Actor* thisx, PlayState* play) { + ObjHsblock* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Hsblock/ObjHsblock_Destroy.s") + DynaPolyActor_Init(&this->dyna, 0); + DynaPolyActor_LoadMesh(play, &this->dyna, sColHeaders[OBJHSBLOCK_GET_3(thisx)]); + Actor_ProcessInitChain(&this->dyna.actor, sInitChain); + func_8093DEAC(this, play); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Hsblock/func_8093E03C.s") + switch (OBJHSBLOCK_GET_3(&this->dyna.actor)) { + case 0: + case 2: + func_8093E03C(this); + break; + case 1: + if (Flags_GetSwitch(play, OBJHSBLOCK_GET_SWITCH(thisx))) { + func_8093E03C(this); + } else { + func_8093E05C(this); + } + break; + default: + break; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Hsblock/func_8093E05C.s") +void ObjHsblock_Destroy(Actor* thisx, PlayState* play) { + ObjHsblock* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Hsblock/func_8093E0A0.s") + DynaPoly_DeleteBgActor(play, &play->colCtx.dyna, this->dyna.bgId); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Hsblock/func_8093E0E8.s") +void func_8093E03C(ObjHsblock* this) { + ObjHsblock_SetupAction(this, NULL); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Hsblock/func_8093E10C.s") +void func_8093E05C(ObjHsblock* this) { + this->dyna.actor.flags |= ACTOR_FLAG_10; + this->dyna.actor.world.pos.y = this->dyna.actor.home.pos.y - 105.0f; + ObjHsblock_SetupAction(this, func_8093E0A0); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Hsblock/ObjHsblock_Update.s") +void func_8093E0A0(ObjHsblock* this, PlayState* play) { + if (Flags_GetSwitch(play, OBJHSBLOCK_GET_SWITCH(&this->dyna.actor))) { + func_8093E0E8(this); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Hsblock/ObjHsblock_Draw.s") +void func_8093E0E8(ObjHsblock* this) { + ObjHsblock_SetupAction(this, func_8093E10C); +} + +void func_8093E10C(ObjHsblock* this, PlayState* play) { + Math_SmoothStepToF(&this->dyna.actor.velocity.y, 16.0f, 0.1f, 0.8f, 0.0f); + if (fabsf(Math_SmoothStepToF(&this->dyna.actor.world.pos.y, this->dyna.actor.home.pos.y, 0.3f, + this->dyna.actor.velocity.y, 0.3f)) < 0.001f) { + this->dyna.actor.world.pos.y = this->dyna.actor.home.pos.y; + func_8093E03C(this); + this->dyna.actor.flags &= ~ACTOR_FLAG_10; + } +} + +void ObjHsblock_Update(Actor* thisx, PlayState* play) { + ObjHsblock* this = THIS; + + if (this->actionFunc != NULL) { + this->actionFunc(this, play); + } + Actor_SetFocus(&this->dyna.actor, sFocusHeights[OBJHSBLOCK_GET_3(thisx)]); +} + +void ObjHsblock_Draw(Actor* thisx, PlayState* play) { + static Color_RGB8 sEnvColors[] = { + { 60, 60, 120 }, + { 120, 100, 70 }, + { 100, 150, 120 }, + { 255, 255, 255 }, + }; + Color_RGB8* envColor = &sEnvColors[OBJHSBLOCK_GET_6(thisx)]; + + OPEN_DISPS(play->state.gfxCtx); + + func_8012C28C(play->state.gfxCtx); + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gDPSetEnvColor(POLY_OPA_DISP++, envColor->r, envColor->g, envColor->b, 255); + gSPDisplayList(POLY_OPA_DISP++, sDisplayLists[OBJHSBLOCK_GET_3(thisx)]); + + CLOSE_DISPS(play->state.gfxCtx); +} diff --git a/src/overlays/actors/ovl_Obj_Hsblock/z_obj_hsblock.h b/src/overlays/actors/ovl_Obj_Hsblock/z_obj_hsblock.h index 230313cb6..0411cc9e4 100644 --- a/src/overlays/actors/ovl_Obj_Hsblock/z_obj_hsblock.h +++ b/src/overlays/actors/ovl_Obj_Hsblock/z_obj_hsblock.h @@ -3,14 +3,18 @@ #include "global.h" +#define OBJHSBLOCK_GET_SWITCH(thisx) (((thisx)->params >> 8) & 0x7F) +#define OBJHSBLOCK_GET_3(thisx) ((thisx)->params & 3) +#define OBJHSBLOCK_GET_5(thisx) (((thisx)->params >> 5) & 1) +#define OBJHSBLOCK_GET_6(thisx) (((thisx)->params >> 6) & 3) + struct ObjHsblock; -typedef void (*ObjHsblockActionFunc)(struct ObjHsblock*, GlobalContext*); +typedef void (*ObjHsblockActionFunc)(struct ObjHsblock*, PlayState*); typedef struct ObjHsblock { - /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x18]; - /* 0x015C */ ObjHsblockActionFunc actionFunc; + /* 0x000 */ DynaPolyActor dyna; + /* 0x15C */ ObjHsblockActionFunc actionFunc; } ObjHsblock; // size = 0x160 extern const ActorInit Obj_Hsblock_InitVars; diff --git a/src/overlays/actors/ovl_Obj_Hugebombiwa/z_obj_hugebombiwa.c b/src/overlays/actors/ovl_Obj_Hugebombiwa/z_obj_hugebombiwa.c index 06293bf40..249e7ffde 100644 --- a/src/overlays/actors/ovl_Obj_Hugebombiwa/z_obj_hugebombiwa.c +++ b/src/overlays/actors/ovl_Obj_Hugebombiwa/z_obj_hugebombiwa.c @@ -5,26 +5,27 @@ */ #include "z_obj_hugebombiwa.h" +#include "z64rumble.h" #include "objects/object_bombiwa/object_bombiwa.h" #define FLAGS (ACTOR_FLAG_10) #define THIS ((ObjHugebombiwa*)thisx) -void ObjHugebombiwa_Init(Actor* thisx, GlobalContext* globalCtx); -void ObjHugebombiwa_Destroy(Actor* thisx, GlobalContext* globalCtx); -void ObjHugebombiwa_Update(Actor* thisx, GlobalContext* globalCtx); -void ObjHugebombiwa_Draw(Actor* thisx, GlobalContext* globalCtx); +void ObjHugebombiwa_Init(Actor* thisx, PlayState* play); +void ObjHugebombiwa_Destroy(Actor* thisx, PlayState* play); +void ObjHugebombiwa_Update(Actor* thisx, PlayState* play); +void ObjHugebombiwa_Draw(Actor* thisx, PlayState* play); void func_80A54BF0(ObjHugebombiwa* this); -void func_80A54C04(ObjHugebombiwa* this, GlobalContext* globalCtx); +void func_80A54C04(ObjHugebombiwa* this, PlayState* play); void func_80A54CD8(ObjHugebombiwa* this); -void func_80A54CEC(ObjHugebombiwa* this, GlobalContext* globalCtx); +void func_80A54CEC(ObjHugebombiwa* this, PlayState* play); void func_80A54E10(ObjHugebombiwa* this); -void func_80A55064(ObjHugebombiwa* this, GlobalContext* globalCtx); +void func_80A55064(ObjHugebombiwa* this, PlayState* play); void func_80A55310(ObjHugebombiwa* this); -void func_80A55564(ObjHugebombiwa* this, GlobalContext* globalCtx); -void func_80A55B34(Actor* thisx, GlobalContext* globalCtx); +void func_80A55564(ObjHugebombiwa* this, PlayState* play); +void func_80A55B34(Actor* thisx, PlayState* play); const ActorInit Obj_Hugebombiwa_InitVars = { ACTOR_OBJ_HUGEBOMBIWA, @@ -60,7 +61,7 @@ static ColliderCylinderInit sCylinderInit = { static Vec3f D_80A55D2C = { 0.0f, 0.3f, 0.0f }; -void func_80A53BE0(GlobalContext* globalCtx, Vec3f* arg1) { +void func_80A53BE0(PlayState* play, Vec3f* arg1) { Vec3f spBC; Vec3f spB0; s32 i; @@ -105,12 +106,12 @@ void func_80A53BE0(GlobalContext* globalCtx, Vec3f* arg1) { if (1) {} } - EffectSsKakera_Spawn(globalCtx, &spBC, &spB0, &spBC, gravity, phi_v0, 15, 0, 0, phi_v1, 1, 0, life, -1, + EffectSsKakera_Spawn(play, &spBC, &spB0, &spBC, gravity, phi_v0, 15, 0, 0, phi_v1, 1, 0, life, -1, OBJECT_BOMBIWA, object_bombiwa_DL_001990); } } -void func_80A53E60(GlobalContext* globalCtx, Vec3f* arg1, f32 arg2, f32 arg3) { +void func_80A53E60(PlayState* play, Vec3f* arg1, f32 arg2, f32 arg3) { static Color_RGBA8 D_80A55D38 = { 210, 210, 210, 255 }; static Color_RGBA8 D_80A55D3C = { 140, 140, 140, 255 }; static f32 D_80A55D40[] = { 3.0f, 5.0f, 9.0f, 18.0f }; @@ -163,7 +164,7 @@ void func_80A53E60(GlobalContext* globalCtx, Vec3f* arg1, f32 arg2, f32 arg3) { phi_v1 = temp_f0; } - EffectSsKakera_Spawn(globalCtx, &spDC, &spD0, &spDC, phi_s2, phi_v0, 15, 0, 0, phi_v1, 1, 0, phi_s0, -1, + EffectSsKakera_Spawn(play, &spDC, &spD0, &spDC, phi_s2, phi_v0, 15, 0, 0, phi_v1, 1, 0, phi_s0, -1, OBJECT_BOMBIWA, object_bombiwa_DL_001990); spDC.x += (Rand_ZeroOne() - 0.5f) * 270.0f; @@ -172,11 +173,11 @@ void func_80A53E60(GlobalContext* globalCtx, Vec3f* arg1, f32 arg2, f32 arg3) { phi_s0 = (Rand_ZeroOne() * 160.0f) + 140.0f; phi_s1 = (Rand_ZeroOne() * 180.0f) + 120.0f; - func_800B0E48(globalCtx, &spDC, &gZeroVec3f, &D_80A55D2C, &D_80A55D38, &D_80A55D3C, phi_s0, phi_s1); + func_800B0E48(play, &spDC, &gZeroVec3f, &D_80A55D2C, &D_80A55D38, &D_80A55D3C, phi_s0, phi_s1); } } -void func_80A541F4(ObjHugebombiwa* this, GlobalContext* globalCtx) { +void func_80A541F4(ObjHugebombiwa* this, PlayState* play) { static s16 D_80A55D50[] = { 24, 17, 13, 7, 6, 5, 3, 2 }; s32 i; s32 pad[2]; @@ -207,7 +208,7 @@ void func_80A541F4(ObjHugebombiwa* this, GlobalContext* globalCtx) { spE8.y = (Rand_ZeroOne() * 18.0f) + 10.0f; spE8.z = temp_f24 * 10.0f; - EffectSsKakera_Spawn(globalCtx, &spF4, &spE8, &spF4, -650, 37, 15, 0, 0, D_80A55D50[i & 7], 1, 0, 60, -1, + EffectSsKakera_Spawn(play, &spF4, &spE8, &spF4, -650, 37, 15, 0, 0, D_80A55D50[i & 7], 1, 0, 60, -1, OBJECT_BOMBIWA, object_bombiwa_DL_0009E0); spDC.x = ((Rand_ZeroOne() - 0.5f) * 230.0f) + spF4.x; @@ -222,7 +223,7 @@ void func_80A541F4(ObjHugebombiwa* this, GlobalContext* globalCtx) { spC4.y = 0.24f; spC4.z = temp_f24 * -0.07f; - func_800B12F0(globalCtx, &spDC, &spD0, &spC4, (s32)(Rand_ZeroOne() * 800.0f) + 1000, -49, 20); + func_800B12F0(play, &spDC, &spD0, &spC4, (s32)(Rand_ZeroOne() * 800.0f) + 1000, -49, 20); spDC.x = ((Rand_ZeroOne() - 0.5f) * 160.0f) + spF4.x; spDC.y = ((Rand_ZeroOne() - 0.2f) * 140.0f) + spF4.y; @@ -236,12 +237,12 @@ void func_80A541F4(ObjHugebombiwa* this, GlobalContext* globalCtx) { spC4.y = 0.3f; spC4.z = temp_f24 * -0.09f; - func_800B12F0(globalCtx, &spDC, &spD0, &spC4, (s32)(Rand_ZeroOne() * 100.0f) + 40, + func_800B12F0(play, &spDC, &spD0, &spC4, (s32)(Rand_ZeroOne() * 100.0f) + 40, (s32)(Rand_ZeroOne() * 200.0f) + 20, 10); } } -void func_80A54600(GlobalContext* globalCtx, Vec3f* arg1, f32 arg2, f32 arg3) { +void func_80A54600(PlayState* play, Vec3f* arg1, f32 arg2, f32 arg3) { static f32 D_80A55D60[] = { 3.0f, 5.0f, 9.0f, 18.0f }; static s8 D_80A55D70 = 0; Vec3f spCC; @@ -278,7 +279,7 @@ void func_80A54600(GlobalContext* globalCtx, Vec3f* arg1, f32 arg2, f32 arg3) { phi_v0 = temp; } - EffectSsKakera_Spawn(globalCtx, &spCC, &spC0, &spCC, phi_v1, 33, 15, 0, 0, phi_v0, 1, 0, 70, -1, OBJECT_BOMBIWA, + EffectSsKakera_Spawn(play, &spCC, &spC0, &spCC, phi_v1, 33, 15, 0, 0, phi_v0, 1, 0, 70, -1, OBJECT_BOMBIWA, object_bombiwa_DL_0009E0); spCC.x += (Rand_ZeroOne() - 0.5f) * 270.0f; @@ -287,18 +288,18 @@ void func_80A54600(GlobalContext* globalCtx, Vec3f* arg1, f32 arg2, f32 arg3) { temp_s0 = (Rand_ZeroOne() * 160.0f) + 140.0f; temp_s1 = (Rand_ZeroOne() * 180.0f) + 120.0f; - func_800B1210(globalCtx, &spCC, &gZeroVec3f, &D_80A55D2C, temp_s0, temp_s1); + func_800B1210(play, &spCC, &gZeroVec3f, &D_80A55D2C, temp_s0, temp_s1); } } -void func_80A54980(ObjHugebombiwa* this, GlobalContext* globalCtx, s32 arg2) { +void func_80A54980(ObjHugebombiwa* this, PlayState* play, s32 arg2) { s32 pad[2]; - s16 quake = Quake_Add(GET_ACTIVE_CAM(globalCtx), 3); + s16 quake = Quake_Add(GET_ACTIVE_CAM(play), 3); Quake_SetSpeed(quake, 0x4E20); Quake_SetQuakeValues(quake, arg2, 0, 0, 0); Quake_SetCountdown(quake, 7); - func_8013ECE0(this->actor.xyzDistToPlayerSq, 255, 20, 150); + Rumble_Request(this->actor.xyzDistToPlayerSq, 255, 20, 150); } s32 func_80A54A0C(ObjHugebombiwa* this) { @@ -330,19 +331,19 @@ static InitChainEntry sInitChain[] = { ICHAIN_F32(uncullZoneDownward, 900, ICHAIN_STOP), }; -void ObjHugebombiwa_Init(Actor* thisx, GlobalContext* globalCtx) { +void ObjHugebombiwa_Init(Actor* thisx, PlayState* play) { s32 pad; ObjHugebombiwa* this = THIS; Actor_ProcessInitChain(&this->actor, sInitChain); - Collider_InitCylinder(globalCtx, &this->collider); + Collider_InitCylinder(play, &this->collider); - if (Flags_GetSwitch(globalCtx, ENHUGEBOMBIWA_GET_7F(&this->actor))) { + if (Flags_GetSwitch(play, ENHUGEBOMBIWA_GET_7F(&this->actor))) { Actor_MarkForDeath(&this->actor); return; } - Collider_SetCylinder(globalCtx, &this->collider, &this->actor, &sCylinderInit); + Collider_SetCylinder(play, &this->collider, &this->actor, &sCylinderInit); Collider_UpdateCylinder(&this->actor, &this->collider); this->actor.colChkInfo.mass = MASS_IMMOVABLE; if ((ENHUGEBOMBIWA_GET_100(&this->actor)) == 1) { @@ -358,18 +359,18 @@ void ObjHugebombiwa_Init(Actor* thisx, GlobalContext* globalCtx) { func_80A54BF0(this); } -void ObjHugebombiwa_Destroy(Actor* thisx, GlobalContext* globalCtx2) { - GlobalContext* globalCtx = globalCtx2; +void ObjHugebombiwa_Destroy(Actor* thisx, PlayState* play2) { + PlayState* play = play2; ObjHugebombiwa* this = THIS; - Collider_DestroyCylinder(globalCtx, &this->collider); + Collider_DestroyCylinder(play, &this->collider); } void func_80A54BF0(ObjHugebombiwa* this) { this->actionFunc = func_80A54C04; } -void func_80A54C04(ObjHugebombiwa* this, GlobalContext* globalCtx) { +void func_80A54C04(ObjHugebombiwa* this, PlayState* play) { s32 pad; if (this->collider.base.acFlags & AC_HIT) { @@ -393,36 +394,36 @@ void func_80A54C04(ObjHugebombiwa* this, GlobalContext* globalCtx) { } } - CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); - CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + CollisionCheck_SetAC(play, &play->colChkCtx, &this->collider.base); + CollisionCheck_SetOC(play, &play->colChkCtx, &this->collider.base); } void func_80A54CD8(ObjHugebombiwa* this) { this->actionFunc = func_80A54CEC; } -void func_80A54CEC(ObjHugebombiwa* this, GlobalContext* globalCtx) { +void func_80A54CEC(ObjHugebombiwa* this, PlayState* play) { s32 pad; if (ActorCutscene_GetCanPlayNext(this->actor.cutscene)) { ActorCutscene_StartAndSetUnkLinkFields(this->actor.cutscene, &this->actor); - Flags_SetSwitch(globalCtx, ENHUGEBOMBIWA_GET_7F(&this->actor)); + Flags_SetSwitch(play, ENHUGEBOMBIWA_GET_7F(&this->actor)); if (!(ENHUGEBOMBIWA_GET_100(&this->actor)) && - ((globalCtx->sceneNum == SCENE_17SETUGEN) || (globalCtx->sceneNum == SCENE_17SETUGEN2))) { + ((play->sceneNum == SCENE_17SETUGEN) || (play->sceneNum == SCENE_17SETUGEN2))) { gSaveContext.save.weekEventReg[19] |= 2; } if (!(ENHUGEBOMBIWA_GET_100(&this->actor))) { - SoundSource_PlaySfxAtFixedWorldPos(globalCtx, &this->actor.world.pos, 80, NA_SE_EV_WALL_BROKEN); + SoundSource_PlaySfxAtFixedWorldPos(play, &this->actor.world.pos, 80, NA_SE_EV_WALL_BROKEN); } else { - SoundSource_PlaySfxAtFixedWorldPos(globalCtx, &this->actor.world.pos, 80, NA_SE_EV_SNOWBALL_BROKEN); + SoundSource_PlaySfxAtFixedWorldPos(play, &this->actor.world.pos, 80, NA_SE_EV_SNOWBALL_BROKEN); } if (!(ENHUGEBOMBIWA_GET_100(&this->actor))) { - func_80A53BE0(globalCtx, &this->actor.world.pos); + func_80A53BE0(play, &this->actor.world.pos); func_80A54E10(this); } else { - func_80A541F4(this, globalCtx); + func_80A541F4(this, play); func_80A55310(this); } } else { @@ -439,8 +440,8 @@ void func_80A54E10(ObjHugebombiwa* this) { s32 pad; Vec3f sp84; - Matrix_StatePush(); - Matrix_RotateY(this->actor.shape.rot.y, MTXMODE_NEW); + 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 +456,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 +464,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,11 +472,11 @@ void func_80A54E10(ObjHugebombiwa* this) { this->unk_4B0 = 0; this->unk_4B2 = 100; - Matrix_StatePop(); + Matrix_Pop(); this->actionFunc = func_80A55064; } -void func_80A55064(ObjHugebombiwa* this, GlobalContext* globalCtx) { +void func_80A55064(ObjHugebombiwa* this, PlayState* play) { s32 i; s32 pad; Vec3f spA4; @@ -507,13 +508,13 @@ void func_80A55064(ObjHugebombiwa* this, GlobalContext* globalCtx) { spA4.y = ptr->unk_0C.y + 60.0f; spA4.z = ptr->unk_0C.z; - temp_f0 = BgCheck_EntityRaycastFloor5(&globalCtx->colCtx, &sp9C, &sp98, &this->actor, &spA4); + temp_f0 = BgCheck_EntityRaycastFloor5(&play->colCtx, &sp9C, &sp98, &this->actor, &spA4); if ((temp_f0 <= BGCHECK_Y_MIN + 10.0f) || ((ptr->unk_0C.y - (350.0f * ptr->unk_00.y)) < temp_f0)) { this->unk_4B0++; ptr->unk_24 = 1; - func_80A53E60(globalCtx, &ptr->unk_0C, ptr->unk_18, ptr->unk_00.y * 9.8f); - if ((globalCtx->gameplayFrames % 4) == 0) { - func_80A54980(this, globalCtx, (s32)(Rand_ZeroOne() * 5.5f) + 1); + func_80A53E60(play, &ptr->unk_0C, ptr->unk_18, ptr->unk_00.y * 9.8f); + if ((play->gameplayFrames % 4) == 0) { + func_80A54980(this, play, (s32)(Rand_ZeroOne() * 5.5f) + 1); } } } @@ -534,8 +535,8 @@ void func_80A55310(ObjHugebombiwa* this) { s16 phi_s2; Vec3f sp84; - Matrix_StatePush(); - Matrix_RotateY(this->actor.shape.rot.y, MTXMODE_NEW); + 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 +550,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 +559,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,11 +568,11 @@ void func_80A55310(ObjHugebombiwa* this) { this->unk_4B0 = 0; this->unk_4B2 = 100; - Matrix_StatePop(); + Matrix_Pop(); this->actionFunc = func_80A55564; } -void func_80A55564(ObjHugebombiwa* this, GlobalContext* globalCtx) { +void func_80A55564(ObjHugebombiwa* this, PlayState* play) { s32 i; EnHugebombiwaStruct* ptr; Vec3f spA4; @@ -603,13 +604,13 @@ void func_80A55564(ObjHugebombiwa* this, GlobalContext* globalCtx) { spA4.y = ptr->unk_0C.y + 60.0f; spA4.z = ptr->unk_0C.z; - temp_f0 = BgCheck_EntityRaycastFloor5(&globalCtx->colCtx, &sp9C, &sp98, &this->actor, &spA4); + temp_f0 = BgCheck_EntityRaycastFloor5(&play->colCtx, &sp9C, &sp98, &this->actor, &spA4); if ((temp_f0 <= BGCHECK_Y_MIN + 10.0f) || (ptr->unk_0C.y < temp_f0)) { this->unk_4B0++; ptr->unk_24 = 1; - func_80A54600(globalCtx, &ptr->unk_0C, ptr->unk_18, ptr->unk_00.y * 10.1f); - if ((globalCtx->gameplayFrames % 4) == 0) { - func_80A54980(this, globalCtx, (s32)(Rand_ZeroOne() * 5.5f) + 1); + func_80A54600(play, &ptr->unk_0C, ptr->unk_18, ptr->unk_00.y * 10.1f); + if ((play->gameplayFrames % 4) == 0) { + func_80A54980(this, play, (s32)(Rand_ZeroOne() * 5.5f) + 1); } } } @@ -621,42 +622,39 @@ void func_80A55564(ObjHugebombiwa* this, GlobalContext* globalCtx) { } } -void ObjHugebombiwa_Update(Actor* thisx, GlobalContext* globalCtx) { +void ObjHugebombiwa_Update(Actor* thisx, PlayState* play) { ObjHugebombiwa* this = THIS; - this->actionFunc(this, globalCtx); + this->actionFunc(this, play); } -void ObjHugebombiwa_Draw(Actor* thisx, GlobalContext* globalCtx) { +void ObjHugebombiwa_Draw(Actor* thisx, PlayState* play) { ObjHugebombiwa* this = THIS; s32 pad[8]; f32 sp38; - OPEN_DISPS(globalCtx->state.gfxCtx); + OPEN_DISPS(play->state.gfxCtx); if ((this->actionFunc == func_80A54C04) || (this->actionFunc == func_80A54CEC)) { if (this->actor.projectedPos.z <= 4300.0f) { - func_8012C28C(globalCtx->state.gfxCtx); + func_8012C28C(play->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); + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gDPSetPrimColor(POLY_OPA_DISP++, 0, 0xFF, 255, 255, 255, 255); gSPDisplayList(POLY_OPA_DISP++, object_bombiwa_DL_002F60); - func_8012C2DC(globalCtx->state.gfxCtx); + func_8012C2DC(play->state.gfxCtx); - gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), - G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_XLU_DISP++, object_bombiwa_DL_003110); } else if (this->actor.projectedPos.z < 4500.0f) { sp38 = (4500.0f - this->actor.projectedPos.z) * 1.275f; - func_8012C2DC(globalCtx->state.gfxCtx); + func_8012C2DC(play->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); + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gDPSetPrimColor(POLY_XLU_DISP++, 0, 0xFF, 255, 255, 255, (s32)sp38); gSPDisplayList(POLY_XLU_DISP++, object_bombiwa_DL_002F60); } @@ -671,10 +669,10 @@ 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); + gSPMatrix(gfx++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(gfx++, object_bombiwa_DL_001990); } } @@ -682,21 +680,21 @@ void ObjHugebombiwa_Draw(Actor* thisx, GlobalContext* globalCtx) { POLY_OPA_DISP = gfx; } - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->state.gfxCtx); } -void func_80A55B34(Actor* thisx, GlobalContext* globalCtx) { +void func_80A55B34(Actor* thisx, PlayState* play) { ObjHugebombiwa* this = THIS; s32 i; Gfx* gfx; EnHugebombiwaStruct* ptr; if ((this->actionFunc == func_80A54C04) || (this->actionFunc == func_80A54CEC)) { - Gfx_DrawDListOpa(globalCtx, object_bombiwa_DL_001820); + Gfx_DrawDListOpa(play, object_bombiwa_DL_001820); return; } - OPEN_DISPS(globalCtx->state.gfxCtx); + OPEN_DISPS(play->state.gfxCtx); gfx = POLY_OPA_DISP; gSPDisplayList(gfx++, &sSetupDL[6 * 25]); @@ -708,16 +706,16 @@ 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); + gSPMatrix(gfx++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(gfx++, object_bombiwa_DL_0009E0); } POLY_OPA_DISP = gfx; - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->state.gfxCtx); } diff --git a/src/overlays/actors/ovl_Obj_Hugebombiwa/z_obj_hugebombiwa.h b/src/overlays/actors/ovl_Obj_Hugebombiwa/z_obj_hugebombiwa.h index f1d26aaf4..67b428182 100644 --- a/src/overlays/actors/ovl_Obj_Hugebombiwa/z_obj_hugebombiwa.h +++ b/src/overlays/actors/ovl_Obj_Hugebombiwa/z_obj_hugebombiwa.h @@ -5,7 +5,7 @@ struct ObjHugebombiwa; -typedef void (*ObjHugebombiwaActionFunc)(struct ObjHugebombiwa*, GlobalContext*); +typedef void (*ObjHugebombiwaActionFunc)(struct ObjHugebombiwa*, PlayState*); #define ENHUGEBOMBIWA_GET_7F(thisx) ((thisx)->params & 0x7F) #define ENHUGEBOMBIWA_GET_100(thisx) (((thisx)->params >> 8) & 1) @@ -20,13 +20,13 @@ typedef struct { } EnHugebombiwaStruct; // size = 0x28 typedef struct ObjHugebombiwa { - /* 0x0000 */ Actor actor; - /* 0x0144 */ ColliderCylinder collider; - /* 0x0190 */ EnHugebombiwaStruct unk_190[20]; - /* 0x04B0 */ s16 unk_4B0; - /* 0x04B2 */ s8 unk_4B2; - /* 0x04B3 */ s8 unk_4B3; - /* 0x04B4 */ ObjHugebombiwaActionFunc actionFunc; + /* 0x000 */ Actor actor; + /* 0x144 */ ColliderCylinder collider; + /* 0x190 */ EnHugebombiwaStruct unk_190[20]; + /* 0x4B0 */ s16 unk_4B0; + /* 0x4B2 */ s8 unk_4B2; + /* 0x4B3 */ s8 unk_4B3; + /* 0x4B4 */ ObjHugebombiwaActionFunc actionFunc; } ObjHugebombiwa; // size = 0x4B8 extern const ActorInit Obj_Hugebombiwa_InitVars; diff --git a/src/overlays/actors/ovl_Obj_Hunsui/z_obj_hunsui.c b/src/overlays/actors/ovl_Obj_Hunsui/z_obj_hunsui.c index 4e09bb655..3289699b0 100644 --- a/src/overlays/actors/ovl_Obj_Hunsui/z_obj_hunsui.c +++ b/src/overlays/actors/ovl_Obj_Hunsui/z_obj_hunsui.c @@ -4,7 +4,6 @@ * Description: Switch-Activated Geyser */ -#include "prevent_bss_reordering.h" #include "z_obj_hunsui.h" #include "objects/object_hunsui/object_hunsui.h" @@ -12,19 +11,19 @@ #define THIS ((ObjHunsui*)thisx) -void ObjHunsui_Init(Actor* thisx, GlobalContext* globalCtx); -void ObjHunsui_Destroy(Actor* thisx, GlobalContext* globalCtx); -void ObjHunsui_Update(Actor* thisx, GlobalContext* globalCtx); -void ObjHunsui_Draw(Actor* thisx, GlobalContext* globalCtx); +void ObjHunsui_Init(Actor* thisx, PlayState* play); +void ObjHunsui_Destroy(Actor* thisx, PlayState* play); +void ObjHunsui_Update(Actor* thisx, PlayState* play); +void ObjHunsui_Draw(Actor* thisx, PlayState* play); -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); +void func_80B9CE64(ObjHunsui* this, PlayState* play); +void func_80B9D0FC(ObjHunsui* this, PlayState* play); +void func_80B9D120(ObjHunsui* this, PlayState* play); +void func_80B9D2BC(ObjHunsui* this, PlayState* play); +void func_80B9D4D0(ObjHunsui* this, PlayState* play); +void func_80B9D508(ObjHunsui* this, PlayState* play); +void func_80B9D714(ObjHunsui* this, PlayState* play); +void func_80B9DA60(Actor* thisx, PlayState* play); AnimatedMaterial* D_80B9DED0; AnimatedMaterial* D_80B9DED4; @@ -66,7 +65,7 @@ static InitChainEntry sInitChain[] = { ICHAIN_F32(uncullZoneDownward, 400, ICHAIN_STOP), }; -s32 func_80B9C450(GlobalContext* globalCtx, s32 arg1, s32 arg2) { +s32 func_80B9C450(PlayState* play, s32 arg1, s32 arg2) { s32 sp2C = 1; if (arg2 < ARRAY_COUNT(D_80B9DC70)) { @@ -75,11 +74,11 @@ s32 func_80B9C450(GlobalContext* globalCtx, s32 arg1, s32 arg2) { while (val--) { if ((1 << val) & val3) { - if (!Flags_GetSwitch(globalCtx, arg1 + val)) { + if (!Flags_GetSwitch(play, arg1 + val)) { sp2C = 0; break; } - } else if (Flags_GetSwitch(globalCtx, arg1 + val)) { + } else if (Flags_GetSwitch(play, arg1 + val)) { sp2C = 0; break; } @@ -88,20 +87,20 @@ s32 func_80B9C450(GlobalContext* globalCtx, s32 arg1, s32 arg2) { sp2C = 0; switch (arg2) { case 14: - if (!Flags_GetSwitch(globalCtx, arg1)) { + if (!Flags_GetSwitch(play, arg1)) { sp2C = 1; } - if (Flags_GetSwitch(globalCtx, arg1 + 1) && Flags_GetSwitch(globalCtx, arg1 + 2) && - Flags_GetSwitch(globalCtx, arg1 + 3)) { + if (Flags_GetSwitch(play, arg1 + 1) && Flags_GetSwitch(play, arg1 + 2) && + Flags_GetSwitch(play, arg1 + 3)) { sp2C += 2; } break; case 15: - if (!Flags_GetSwitch(globalCtx, arg1) || - (Flags_GetSwitch(globalCtx, arg1 + 1) && Flags_GetSwitch(globalCtx, arg1 + 2) && - Flags_GetSwitch(globalCtx, arg1 + 3))) { + if (!Flags_GetSwitch(play, arg1) || + (Flags_GetSwitch(play, arg1 + 1) && Flags_GetSwitch(play, arg1 + 2) && + Flags_GetSwitch(play, arg1 + 3))) { sp2C = 1; } break; @@ -110,8 +109,8 @@ s32 func_80B9C450(GlobalContext* globalCtx, s32 arg1, s32 arg2) { return sp2C; } -void func_80B9C5E8(ObjHunsui* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); +void func_80B9C5E8(ObjHunsui* this, PlayState* play) { + Player* player = GET_PLAYER(play); f32 temp_f10; f32 temp_f16; Vec3f sp40; @@ -135,7 +134,7 @@ void func_80B9C5E8(ObjHunsui* this, GlobalContext* globalCtx) { sp40.z += randPlusMinusPoint5Scaled(10.0f); sp40.y += Rand_ZeroFloat(2.0f); - EffectSsGSplash_Spawn(globalCtx, &sp40, NULL, NULL, 2.0f * Rand_ZeroOne(), 1); + EffectSsGSplash_Spawn(play, &sp40, NULL, NULL, 2.0f * Rand_ZeroOne(), 1); } } else { this->unk_172 |= 8; @@ -149,7 +148,7 @@ void func_80B9C5E8(ObjHunsui* this, GlobalContext* globalCtx) { sp40.z += randPlusMinusPoint5Scaled(10.0f); sp40.y += Rand_ZeroFloat(45.0f); - EffectSsGSplash_Spawn(globalCtx, &sp40, NULL, NULL, 1, 1); + EffectSsGSplash_Spawn(play, &sp40, NULL, NULL, 1, 1); } sp3E = BINANG_ROT180(player->actor.world.rot.y - this->dyna.actor.yawTowardsPlayer); @@ -199,7 +198,7 @@ void func_80B9C5E8(ObjHunsui* this, GlobalContext* globalCtx) { } } -void ObjHunsui_Init(Actor* thisx, GlobalContext* globalCtx) { +void ObjHunsui_Init(Actor* thisx, PlayState* play) { ObjHunsui* this = THIS; Actor_ProcessInitChain(&this->dyna.actor, sInitChain); @@ -209,12 +208,12 @@ void ObjHunsui_Init(Actor* thisx, GlobalContext* globalCtx) { 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); + DynaPolyActor_LoadMesh(play, &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); + SubS_FillCutscenesList(&this->dyna.actor, this->unk_170, ARRAY_COUNT(this->unk_170)); this->unk_18C = 0; switch (this->unk_160) { @@ -280,7 +279,7 @@ void ObjHunsui_Init(Actor* thisx, GlobalContext* globalCtx) { case OBJHUNSUI_F000_1: this->dyna.actor.draw = func_80B9DA60; - if ((this->unk_172 & 1) && func_80B9C450(globalCtx, this->unk_168, this->unk_164)) { + if ((this->unk_172 & 1) && func_80B9C450(play, this->unk_168, this->unk_164)) { this->unk_174 = 240.0f; this->unk_172 |= 4; this->unk_184 = 0xFF0; @@ -290,7 +289,7 @@ void ObjHunsui_Init(Actor* thisx, GlobalContext* globalCtx) { this->unk_184 = 0; } this->unk_178 = this->unk_174; - this->unk_180 = func_80B9C450(globalCtx, this->unk_168, this->unk_164); + this->unk_180 = func_80B9C450(play, this->unk_168, this->unk_164); this->actionFunc = func_80B9CE64; break; @@ -302,13 +301,13 @@ void ObjHunsui_Init(Actor* thisx, GlobalContext* globalCtx) { 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); + func_80B9D2BC(this, play); 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); + if ((this->unk_172 & 1) || func_80B9C450(play, this->unk_168, this->unk_164)) { + func_80B9D4D0(this, play); } else { - func_80B9D0FC(this, globalCtx); + func_80B9D0FC(this, play); } this->unk_178 = this->unk_174; } @@ -316,18 +315,19 @@ void ObjHunsui_Init(Actor* thisx, GlobalContext* globalCtx) { } } -void ObjHunsui_Destroy(Actor* thisx, GlobalContext* globalCtx) { +void ObjHunsui_Destroy(Actor* thisx, PlayState* play) { ObjHunsui* this = THIS; - DynaPoly_DeleteBgActor(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); + DynaPoly_DeleteBgActor(play, &play->colCtx.dyna, this->dyna.bgId); } -void ObjHunsui_Update(Actor* thisx, GlobalContext* globalCtx) { +void ObjHunsui_Update(Actor* thisx, PlayState* play) { ObjHunsui* this = THIS; - this->actionFunc(this, globalCtx); + this->actionFunc(this, play); - if ((this->unk_172 & 0x40) && SubS_StartActorCutscene(&this->dyna.actor, this->unk_17C, -1, 0)) { + if ((this->unk_172 & 0x40) && + SubS_StartActorCutscene(&this->dyna.actor, this->unk_17C, -1, SUBS_CUTSCENE_SET_UNK_LINK_FIELDS)) { this->unk_172 &= ~0x40; } @@ -340,22 +340,22 @@ void ObjHunsui_Update(Actor* thisx, GlobalContext* globalCtx) { } } -void func_80B9CE64(ObjHunsui* this, GlobalContext* globalCtx) { +void func_80B9CE64(ObjHunsui* this, PlayState* play) { s32 sp2C; f32 sins; if (!(this->unk_172 & 2)) { - func_80B9C5E8(this, globalCtx); + func_80B9C5E8(this, play); } 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); + sp2C = func_80B9C450(play, this->unk_168, this->unk_164); if (!(this->unk_172 & 1)) { if (sp2C != this->unk_180) { - this->unk_17C = this->unk_170; + this->unk_17C = this->unk_170[0]; this->unk_172 |= 0x40; } } @@ -404,7 +404,7 @@ void func_80B9CE64(ObjHunsui* this, GlobalContext* globalCtx) { this->unk_180 = sp2C; } -void func_80B9D094(ObjHunsui* this, GlobalContext* globalCtx) { +void func_80B9D094(ObjHunsui* this, PlayState* play) { f32 sins; this->unk_18A += 0x71C; @@ -413,15 +413,15 @@ void func_80B9D094(ObjHunsui* this, GlobalContext* globalCtx) { this->unk_198 = sins * this->unk_190; } -void func_80B9D0FC(ObjHunsui* this, GlobalContext* globalCtx) { +void func_80B9D0FC(ObjHunsui* this, PlayState* play) { this->unk_174 = -30.0f; this->actionFunc = func_80B9D120; } -void func_80B9D120(ObjHunsui* this, GlobalContext* globalCtx) { +void func_80B9D120(ObjHunsui* this, PlayState* play) { 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))) { + (this->unk_16C != play->roomCtx.currRoom.num) && (this->unk_16C != play->roomCtx.prevRoom.num) && + ((this->unk_16D != play->roomCtx.currRoom.num) && (this->unk_16D != play->roomCtx.prevRoom.num))) { switch (this->unk_160) { case OBJHUNSUI_F000_5: D_80B9DED8.unk_01 = 0; @@ -435,7 +435,7 @@ void func_80B9D120(ObjHunsui* this, GlobalContext* globalCtx) { return; } - func_80B9D094(this, globalCtx); + func_80B9D094(this, play); if (!(this->unk_172 & 0x40)) { Math_SmoothStepToF(&this->unk_178, this->unk_174, 0.6f, 10.5f, 0.05f); } @@ -446,14 +446,14 @@ void func_80B9D120(ObjHunsui* this, GlobalContext* globalCtx) { this->unk_172 |= 2; } - if (func_80B9C450(globalCtx, this->unk_168, this->unk_164)) { - this->unk_17C = this->unk_170; + if (func_80B9C450(play, this->unk_168, this->unk_164)) { + this->unk_17C = this->unk_170[0]; this->unk_172 |= 0x40; - func_80B9D4D0(this, globalCtx); + func_80B9D4D0(this, play); } } -s32 func_80B9D288(GlobalContext* globalCtx, Actor* thisx, Actor* iter, void* verifyData) { +s32 func_80B9D288(PlayState* play, Actor* thisx, Actor* iter, void* verifyData) { s32 ret = false; if (BGDBLUEMOVEBG_GET_F(iter) == BGDBLUEMOVEBG_F_8) { @@ -462,16 +462,16 @@ s32 func_80B9D288(GlobalContext* globalCtx, Actor* thisx, Actor* iter, void* ver 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); +void func_80B9D2BC(ObjHunsui* this, PlayState* play) { + if ((this->unk_172 & 1) || func_80B9C450(play, this->unk_168, this->unk_164)) { + func_80B9D4D0(this, play); } else { this->unk_172 |= 2; - func_80B9D0FC(this, globalCtx); + func_80B9D0FC(this, play); } } -void func_80B9D334(ObjHunsui* this, GlobalContext* globalCtx) { +void func_80B9D334(ObjHunsui* this, PlayState* play) { Vec3f sp74; s32 i; s32 phi_s2 = 0; @@ -506,27 +506,27 @@ void func_80B9D334(ObjHunsui* this, GlobalContext* globalCtx) { this->unk_174 = 240; } } else { - Actor* dblueMovebg = SubS_FindActorCustom(globalCtx, &this->dyna.actor, NULL, ACTORCAT_BG, - ACTOR_BG_DBLUE_MOVEBG, NULL, func_80B9D288); + Actor* dblueMovebg = SubS_FindActorCustom(play, &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); + func_80B9D2BC(this, play); } } } -void func_80B9D4D0(ObjHunsui* this, GlobalContext* globalCtx) { +void func_80B9D4D0(ObjHunsui* this, PlayState* play) { this->unk_172 &= ~2; this->unk_172 |= 0x10; this->unk_174 = 240.0f; this->actionFunc = func_80B9D508; } -void func_80B9D508(ObjHunsui* this, GlobalContext* globalCtx) { +void func_80B9D508(ObjHunsui* this, PlayState* play) { 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)) { + (this->unk_16C != play->roomCtx.currRoom.num) && (this->unk_16C != play->roomCtx.prevRoom.num) && + (this->unk_16D != play->roomCtx.currRoom.num) && (this->unk_16D != play->roomCtx.prevRoom.num)) { switch (this->unk_160) { case OBJHUNSUI_F000_5: D_80B9DED8.unk_01 = 0; @@ -540,12 +540,12 @@ void func_80B9D508(ObjHunsui* this, GlobalContext* globalCtx) { return; } - func_80B9C5E8(this, globalCtx); - func_80B9D094(this, globalCtx); + func_80B9C5E8(this, play); + func_80B9D094(this, play); if (((this->unk_160 == OBJHUNSUI_F000_5) || (this->unk_160 == OBJHUNSUI_F000_6)) && - (globalCtx->roomCtx.currRoom.num == 8)) { - func_80B9D334(this, globalCtx); + (play->roomCtx.currRoom.num == 8)) { + func_80B9D334(this, play); } if (!(this->unk_172 & 0x40)) { @@ -559,24 +559,24 @@ void func_80B9D508(ObjHunsui* this, GlobalContext* globalCtx) { 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; + if (!(this->unk_172 & 1) && !func_80B9C450(play, this->unk_168, this->unk_164)) { + this->unk_17C = this->unk_170[0]; this->unk_172 |= 0x40; - func_80B9D0FC(this, globalCtx); + func_80B9D0FC(this, play); } } -void func_80B9D714(ObjHunsui* this, GlobalContext* globalCtx) { +void func_80B9D714(ObjHunsui* this, PlayState* play) { s32 pad; - Player* player = GET_PLAYER(globalCtx); + Player* player = GET_PLAYER(play); 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)) { + if ((this->unk_16C != play->roomCtx.currRoom.num) && (this->unk_16C != play->roomCtx.prevRoom.num) && + (this->unk_16D != play->roomCtx.currRoom.num) && (this->unk_16D != play->roomCtx.prevRoom.num)) { Actor_MarkForDeath(&this->dyna.actor); } else { - if (Flags_GetSwitch(globalCtx, this->unk_168)) { + if (Flags_GetSwitch(play, this->unk_168)) { this->unk_172 &= ~2; this->unk_172 |= 0x10; cs = this->dyna.actor.cutscene; @@ -600,7 +600,7 @@ void func_80B9D714(ObjHunsui* this, GlobalContext* globalCtx) { 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); + Flags_UnsetSwitch(play, this->unk_168); } } this->dyna.actor.velocity.y = this->dyna.actor.world.pos.y - this->dyna.actor.prevPos.y; @@ -628,7 +628,7 @@ void func_80B9D714(ObjHunsui* this, GlobalContext* globalCtx) { } } -void ObjHunsui_Draw(Actor* thisx, GlobalContext* globalCtx) { +void ObjHunsui_Draw(Actor* thisx, PlayState* play) { ObjHunsui* this = THIS; if (this->unk_172 & 0x10) { @@ -638,12 +638,12 @@ void ObjHunsui_Draw(Actor* thisx, GlobalContext* globalCtx) { } if (!(this->unk_172 & 2)) { - AnimatedMat_Draw(globalCtx, D_80B9DED0); - Gfx_DrawDListXlu(globalCtx, object_hunsui_DL_000220); + AnimatedMat_Draw(play, D_80B9DED0); + Gfx_DrawDListXlu(play, object_hunsui_DL_000220); } } -void func_80B9DA60(Actor* thisx, GlobalContext* globalCtx) { +void func_80B9DA60(Actor* thisx, PlayState* play) { s32 pad; ObjHunsui* this = THIS; f32 temp; @@ -655,26 +655,26 @@ void func_80B9DA60(Actor* thisx, GlobalContext* globalCtx) { 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); + OPEN_DISPS(play->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)); + Gfx_TwoTexScroll(play->state.gfxCtx, 0, 0, (play->gameplayFrames % 128) * -9, 0x20, 0x20, 1, 0, + (play->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, + Gfx_TwoTexScroll(play->state.gfxCtx, 0, 0, (s32)this->unk_1AC, 0x20, 0x20, 1, 0, (s32)this->unk_1B0, 0x20, 0x20)); - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->state.gfxCtx); } else { - AnimatedMat_DrawXlu(globalCtx, D_80B9DED4); + AnimatedMat_DrawXlu(play, D_80B9DED4); } - OPEN_DISPS(globalCtx->state.gfxCtx); + OPEN_DISPS(play->state.gfxCtx); gDPSetPrimColor(POLY_XLU_DISP++, 0, 0x7F, 255, 255, 255, 127); - Gfx_DrawDListXlu(globalCtx, object_hunsui_DL_000EC0); + Gfx_DrawDListXlu(play, object_hunsui_DL_000EC0); - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->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 cbf1e4f13..2f3d968a6 100644 --- a/src/overlays/actors/ovl_Obj_Hunsui/z_obj_hunsui.h +++ b/src/overlays/actors/ovl_Obj_Hunsui/z_obj_hunsui.h @@ -6,7 +6,7 @@ struct ObjHunsui; -typedef void (*ObjHunsuiActionFunc)(struct ObjHunsui*, GlobalContext*); +typedef void (*ObjHunsuiActionFunc)(struct ObjHunsui*, PlayState*); #define OBJHUNSUI_GET_7F(thisx) ((thisx)->params & 0x7F) #define OBJHUNSUI_GET_F80(thisx) (((thisx)->params >> 7) & 0x1F) @@ -23,35 +23,35 @@ enum { }; typedef struct ObjHunsui { - /* 0x0000 */ DynaPolyActor dyna; - /* 0x015C */ ObjHunsuiActionFunc actionFunc; - /* 0x0160 */ s16 unk_160; - /* 0x0164 */ s32 unk_164; - /* 0x0168 */ s32 unk_168; - /* 0x016C */ s8 unk_16C; - /* 0x016D */ s8 unk_16D; - /* 0x016E */ s8 unk_16E; - /* 0x0170 */ s16 unk_170; - /* 0x0172 */ u16 unk_172; - /* 0x0174 */ f32 unk_174; - /* 0x0178 */ f32 unk_178; - /* 0x017C */ s16 unk_17C; - /* 0x0180 */ s32 unk_180; - /* 0x0184 */ s16 unk_184; - /* 0x0186 */ s16 unk_186; - /* 0x0188 */ s16 unk_188; - /* 0x018A */ s16 unk_18A; - /* 0x018C */ s16 unk_18C; - /* 0x0190 */ f32 unk_190; - /* 0x0194 */ f32 unk_194; - /* 0x0198 */ f32 unk_198; - /* 0x019C */ f32 unk_19C; - /* 0x01A0 */ f32 unk_1A0; - /* 0x01A4 */ s16 unk_1A4; - /* 0x0196 */ UNK_TYPE1 unk1A6[0x6]; - /* 0x01AC */ f32 unk_1AC; - /* 0x01B0 */ f32 unk_1B0; - /* 0x01B4 */ BgDblueMovebg* unk_1B4; + /* 0x000 */ DynaPolyActor dyna; + /* 0x15C */ ObjHunsuiActionFunc actionFunc; + /* 0x160 */ s16 unk_160; + /* 0x164 */ s32 unk_164; + /* 0x168 */ s32 unk_168; + /* 0x16C */ s8 unk_16C; + /* 0x16D */ s8 unk_16D; + /* 0x16E */ s8 unk_16E; + /* 0x170 */ s16 unk_170[1]; + /* 0x172 */ u16 unk_172; + /* 0x174 */ f32 unk_174; + /* 0x178 */ f32 unk_178; + /* 0x17C */ s16 unk_17C; + /* 0x180 */ s32 unk_180; + /* 0x184 */ s16 unk_184; + /* 0x186 */ s16 unk_186; + /* 0x188 */ s16 unk_188; + /* 0x18A */ s16 unk_18A; + /* 0x18C */ s16 unk_18C; + /* 0x190 */ f32 unk_190; + /* 0x194 */ f32 unk_194; + /* 0x198 */ f32 unk_198; + /* 0x19C */ f32 unk_19C; + /* 0x1A0 */ f32 unk_1A0; + /* 0x1A4 */ s16 unk_1A4; + /* 0x196 */ UNK_TYPE1 unk1A6[0x6]; + /* 0x1AC */ f32 unk_1AC; + /* 0x1B0 */ f32 unk_1B0; + /* 0x1B4 */ BgDblueMovebg* unk_1B4; } ObjHunsui; // size = 0x1B8 extern const ActorInit Obj_Hunsui_InitVars; diff --git a/src/overlays/actors/ovl_Obj_Ice_Poly/z_obj_ice_poly.c b/src/overlays/actors/ovl_Obj_Ice_Poly/z_obj_ice_poly.c index d6ac6f342..0210b5ba7 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 @@ -12,15 +12,15 @@ #define THIS ((ObjIcePoly*)thisx) -void ObjIcePoly_Init(Actor* thisx, GlobalContext* globalCtx); -void ObjIcePoly_Destroy(Actor* thisx, GlobalContext* globalCtx); -void ObjIcePoly_Update(Actor* thisx, GlobalContext* globalCtx); -void ObjIcePoly_Draw(Actor* thisx, GlobalContext* globalCtx); +void ObjIcePoly_Init(Actor* thisx, PlayState* play); +void ObjIcePoly_Destroy(Actor* thisx, PlayState* play); +void ObjIcePoly_Update(Actor* thisx, PlayState* play); +void ObjIcePoly_Draw(Actor* thisx, PlayState* play); -void func_80931828(ObjIcePoly* this, GlobalContext* globalCtx); -void func_80931A38(ObjIcePoly* this, GlobalContext* globalCtx); -void func_80931E58(ObjIcePoly* this, GlobalContext* globalCtx); -void func_80931EEC(ObjIcePoly* this, GlobalContext* globalCtx); +void func_80931828(ObjIcePoly* this, PlayState* play); +void func_80931A38(ObjIcePoly* this, PlayState* play); +void func_80931E58(ObjIcePoly* this, PlayState* play); +void func_80931EEC(ObjIcePoly* this, PlayState* play); const ActorInit Obj_Ice_Poly_InitVars = { ACTOR_OBJ_ICE_POLY, @@ -77,7 +77,7 @@ static ColliderCylinderInit sCylinderInit2 = { static Color_RGBA8 D_80932378 = { 250, 250, 250, 255 }; static Color_RGBA8 D_8093237C = { 180, 180, 180, 255 }; -void ObjIcePoly_Init(Actor* thisx, GlobalContext* globalCtx) { +void ObjIcePoly_Init(Actor* thisx, PlayState* play) { ObjIcePoly* this = THIS; s32 i; @@ -88,8 +88,8 @@ void ObjIcePoly_Init(Actor* thisx, GlobalContext* globalCtx) { Actor_SetScale(thisx, thisx->params * 0.01f); for (i = 0; i < ARRAY_COUNT(this->colliders1); i++) { - Collider_InitAndSetCylinder(globalCtx, &this->colliders1[i], thisx, &sCylinderInit1); - Collider_InitAndSetCylinder(globalCtx, &this->colliders2[i], thisx, &sCylinderInit2); + Collider_InitAndSetCylinder(play, &this->colliders1[i], thisx, &sCylinderInit1); + Collider_InitAndSetCylinder(play, &this->colliders2[i], thisx, &sCylinderInit2); Collider_UpdateCylinder(thisx, &this->colliders1[i]); Collider_UpdateCylinder(thisx, &this->colliders2[i]); } @@ -115,8 +115,8 @@ void ObjIcePoly_Init(Actor* thisx, GlobalContext* globalCtx) { thisx->shape.rot.x = 0x500; thisx->shape.rot.z = -0x500; - if (((this->unk_149 != OBJICEPOLY_FF_FF) && Flags_GetSwitch(globalCtx, this->unk_149)) || - ((globalCtx->sceneNum == SCENE_KAJIYA) && (gSaveContext.save.weekEventReg[33] & 0x80))) { + if (((this->unk_149 != OBJICEPOLY_FF_FF) && Flags_GetSwitch(play, this->unk_149)) || + ((play->sceneNum == SCENE_KAJIYA) && (gSaveContext.save.weekEventReg[33] & 0x80))) { Actor_MarkForDeath(thisx); return; } @@ -124,17 +124,17 @@ void ObjIcePoly_Init(Actor* thisx, GlobalContext* globalCtx) { this->actionFunc = func_80931A38; } -void ObjIcePoly_Destroy(Actor* thisx, GlobalContext* globalCtx) { +void ObjIcePoly_Destroy(Actor* thisx, PlayState* play) { ObjIcePoly* this = THIS; s32 i; for (i = 0; i < ARRAY_COUNT(this->colliders1); i++) { - Collider_DestroyCylinder(globalCtx, &this->colliders1[i]); - Collider_DestroyCylinder(globalCtx, &this->colliders2[i]); + Collider_DestroyCylinder(play, &this->colliders1[i]); + Collider_DestroyCylinder(play, &this->colliders2[i]); } } -void func_80931828(ObjIcePoly* this, GlobalContext* globalCtx) { +void func_80931828(ObjIcePoly* this, PlayState* play) { static Color_RGBA8 D_80932380 = { 170, 255, 255, 255 }; static Color_RGBA8 D_80932384 = { 0, 50, 100, 255 }; static Vec3f D_80932388 = { 0.0f, -1.0f, 0.0f }; @@ -149,7 +149,7 @@ void func_80931828(ObjIcePoly* this, GlobalContext* globalCtx) { spA0.y = (this->colliders1[0].dim.height * 2) + this->actor.world.pos.y; spA0.z = this->actor.world.pos.z; - sp90 = BgCheck_EntityRaycastFloor1(&globalCtx->colCtx, &sp88, &spA0); + sp90 = BgCheck_EntityRaycastFloor1(&play->colCtx, &sp88, &spA0); if (sp90 < this->actor.world.pos.y) { sp90 = this->actor.world.pos.y; } @@ -163,14 +163,14 @@ void func_80931828(ObjIcePoly* this, GlobalContext* globalCtx) { spA0.x = (this->colliders1[0].dim.radius * (sp94.x * (1.0f / 12))) + this->actor.world.pos.x; spA0.z = (this->colliders1[0].dim.radius * (sp94.z * (1.0f / 12))) + this->actor.world.pos.z; spA0.y = Rand_ZeroFloat(temp) + sp90; - EffectSsEnIce_Spawn(globalCtx, &spA0, (Rand_ZeroFloat(0.4f) + 0.3f) * this->actor.scale.x, &sp94, &D_80932388, + EffectSsEnIce_Spawn(play, &spA0, (Rand_ZeroFloat(0.4f) + 0.3f) * this->actor.scale.x, &sp94, &D_80932388, &D_80932380, &D_80932384, 40); } } -void func_80931A38(ObjIcePoly* this, GlobalContext* globalCtx) { +void func_80931A38(ObjIcePoly* this, PlayState* play) { s32 pad; - Player* player = GET_PLAYER(globalCtx); + Player* player = GET_PLAYER(play); Vec3f sp6C; s32 i; s32 pad2; @@ -205,11 +205,11 @@ void func_80931A38(ObjIcePoly* this, GlobalContext* globalCtx) { this->actionFunc = func_80931E58; this->actor.focus.rot.y = this->actor.yawTowardsPlayer; - if (globalCtx->sceneNum == SCENE_00KEIKOKU) { + if (play->sceneNum == SCENE_00KEIKOKU) { Actor* actor = NULL; do { - actor = SubS_FindActor(globalCtx, actor, ACTORCAT_ITEMACTION, ACTOR_OBJ_ICE_POLY); + actor = SubS_FindActor(play, actor, ACTORCAT_ITEMACTION, ACTOR_OBJ_ICE_POLY); if (actor != NULL) { if ((&this->actor != actor) && (&this->actor != actor)) { ((ObjIcePoly*)actor)->unk_14A = 0; @@ -219,7 +219,7 @@ void func_80931A38(ObjIcePoly* this, GlobalContext* globalCtx) { } } while (actor != NULL); } - } else if ((this->unk_149 != OBJICEPOLY_FF_FF) && Flags_GetSwitch(globalCtx, this->unk_149)) { + } else if ((this->unk_149 != OBJICEPOLY_FF_FF) && Flags_GetSwitch(play, this->unk_149)) { ActorCutscene_SetIntentToPlay(this->actor.cutscene); this->unk_14A = 1; this->actionFunc = func_80931E58; @@ -231,14 +231,14 @@ void func_80931A38(ObjIcePoly* this, GlobalContext* globalCtx) { } if (this->unk_14A == 0) { - CollisionCheck_SetAT(globalCtx, &globalCtx->colChkCtx, &this->colliders1[0].base); - CollisionCheck_SetAT(globalCtx, &globalCtx->colChkCtx, &this->colliders1[1].base); + CollisionCheck_SetAT(play, &play->colChkCtx, &this->colliders1[0].base); + CollisionCheck_SetAT(play, &play->colChkCtx, &this->colliders1[1].base); } for (i = 0; i < ARRAY_COUNT(this->colliders1); i++) { - CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->colliders1[i].base); - CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->colliders1[i].base); - CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->colliders2[i].base); + CollisionCheck_SetAC(play, &play->colChkCtx, &this->colliders1[i].base); + CollisionCheck_SetOC(play, &play->colChkCtx, &this->colliders1[i].base); + CollisionCheck_SetAC(play, &play->colChkCtx, &this->colliders2[i].base); } } @@ -260,15 +260,15 @@ 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(play, &sp6C, &gZeroVec3f, &gZeroVec3f, &D_80932378, &D_8093237C, 2000, 5); } } -void func_80931E58(ObjIcePoly* this, GlobalContext* globalCtx) { +void func_80931E58(ObjIcePoly* this, PlayState* play) { if (ActorCutscene_GetCanPlayNext(this->actor.cutscene)) { ActorCutscene_StartAndSetUnkLinkFields(this->actor.cutscene, &this->actor); if (this->unk_14A == 1) { - func_80931828(this, globalCtx); + func_80931828(this, play); Actor_MarkForDeath(&this->actor); } else { this->unk_14A = 40; @@ -280,7 +280,7 @@ void func_80931E58(ObjIcePoly* this, GlobalContext* globalCtx) { } } -void func_80931EEC(ObjIcePoly* this, GlobalContext* globalCtx) { +void func_80931EEC(ObjIcePoly* this, PlayState* play) { Vec3f spAC; Vec3f spA0; Vec3f sp94; @@ -314,7 +314,7 @@ void func_80931EEC(ObjIcePoly* this, GlobalContext* globalCtx) { } sp94.z = (phi_v0 * (20.0f + (20.0f * temp_f20)) * this->actor.scale.x) + this->actor.world.pos.z; - func_800B0DE0(globalCtx, &sp94, &spA0, &spAC, &D_80932378, &D_8093237C, + func_800B0DE0(play, &sp94, &spA0, &spAC, &D_80932378, &D_8093237C, ((Rand_ZeroOne() * 100.0f) + 350.0f) * this->actor.scale.x, this->actor.scale.x * 20.0f); } @@ -328,33 +328,33 @@ void func_80931EEC(ObjIcePoly* this, GlobalContext* globalCtx) { if (this->unk_14A == 0) { ActorCutscene_Stop(this->actor.cutscene); if (this->unk_149 != OBJICEPOLY_FF_FF) { - Flags_SetSwitch(globalCtx, this->unk_149); + Flags_SetSwitch(play, this->unk_149); } Actor_MarkForDeath(&this->actor); } } -void ObjIcePoly_Update(Actor* thisx, GlobalContext* globalCtx) { +void ObjIcePoly_Update(Actor* thisx, PlayState* play) { ObjIcePoly* this = THIS; - this->actionFunc(this, globalCtx); + this->actionFunc(this, play); } -void ObjIcePoly_Draw(Actor* thisx, GlobalContext* globalCtx) { +void ObjIcePoly_Draw(Actor* thisx, PlayState* play) { s32 pad; ObjIcePoly* this = THIS; - OPEN_DISPS(globalCtx->state.gfxCtx); + OPEN_DISPS(play->state.gfxCtx); - func_8012C2DC(globalCtx->state.gfxCtx); - func_800B8118(&this->actor, globalCtx, 0); + func_8012C2DC(play->state.gfxCtx); + func_800B8118(&this->actor, play, 0); - gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPSegment(POLY_XLU_DISP++, 0x08, - Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, 0, globalCtx->gameplayFrames % 256, 0x20, 0x10, 1, 0, - (globalCtx->gameplayFrames * 2) % 256, 0x40, 0x20)); + Gfx_TwoTexScroll(play->state.gfxCtx, 0, 0, play->gameplayFrames % 256, 0x20, 0x10, 1, 0, + (play->gameplayFrames * 2) % 256, 0x40, 0x20)); gDPSetEnvColor(POLY_XLU_DISP++, 0, 50, 100, this->unk_148); - gSPDisplayList(POLY_XLU_DISP++, gameplay_keep_DL_050D10); + gSPDisplayList(POLY_XLU_DISP++, gEffIceFragment3DL); - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->state.gfxCtx); } diff --git a/src/overlays/actors/ovl_Obj_Ice_Poly/z_obj_ice_poly.h b/src/overlays/actors/ovl_Obj_Ice_Poly/z_obj_ice_poly.h index b34866e3c..601c5c9e7 100644 --- a/src/overlays/actors/ovl_Obj_Ice_Poly/z_obj_ice_poly.h +++ b/src/overlays/actors/ovl_Obj_Ice_Poly/z_obj_ice_poly.h @@ -5,20 +5,20 @@ struct ObjIcePoly; -typedef void (*ObjIcePolyActionFunc)(struct ObjIcePoly*, GlobalContext*); +typedef void (*ObjIcePolyActionFunc)(struct ObjIcePoly*, PlayState*); #define OBJICEPOLY_GET_FF00(thisx) (((thisx)->params >> 8) & 0xFF) #define OBJICEPOLY_FF_FF 0xFF typedef struct ObjIcePoly { - /* 0x0000 */ Actor actor; - /* 0x0144 */ ObjIcePolyActionFunc actionFunc; - /* 0x0148 */ u8 unk_148; - /* 0x0149 */ u8 unk_149; - /* 0x014A */ s16 unk_14A; - /* 0x014C */ ColliderCylinder colliders1[2]; - /* 0x01E4 */ ColliderCylinder colliders2[2]; + /* 0x000 */ Actor actor; + /* 0x144 */ ObjIcePolyActionFunc actionFunc; + /* 0x148 */ u8 unk_148; + /* 0x149 */ u8 unk_149; + /* 0x14A */ s16 unk_14A; + /* 0x14C */ ColliderCylinder colliders1[2]; + /* 0x1E4 */ ColliderCylinder colliders2[2]; } ObjIcePoly; // size = 0x27C extern const ActorInit Obj_Ice_Poly_InitVars; diff --git a/src/overlays/actors/ovl_Obj_Iceblock/z_obj_iceblock.c b/src/overlays/actors/ovl_Obj_Iceblock/z_obj_iceblock.c index 582c3a299..b01f22ae6 100644 --- a/src/overlays/actors/ovl_Obj_Iceblock/z_obj_iceblock.c +++ b/src/overlays/actors/ovl_Obj_Iceblock/z_obj_iceblock.c @@ -11,39 +11,39 @@ #define THIS ((ObjIceblock*)thisx) -void ObjIceblock_Init(Actor* thisx, GlobalContext* globalCtx); -void ObjIceblock_Destroy(Actor* thisx, GlobalContext* globalCtx); -void ObjIceblock_Update(Actor* thisx, GlobalContext* globalCtx); -void ObjIceblock_Draw(Actor* thisx, GlobalContext* globalCtx); +void ObjIceblock_Init(Actor* thisx, PlayState* play); +void ObjIceblock_Destroy(Actor* thisx, PlayState* play); +void ObjIceblock_Update(Actor* thisx, PlayState* play); +void ObjIceblock_Draw(Actor* thisx, PlayState* play); void ObjIceBlock_SetupAttemptSpawnCutscene(ObjIceblock* this); -void ObjIceBlock_AttemptSpawnCutscene(ObjIceblock* this, GlobalContext* globalCtx); +void ObjIceBlock_AttemptSpawnCutscene(ObjIceblock* this, PlayState* play); void func_80A25824(ObjIceblock* this); -void func_80A2586C(ObjIceblock* this, GlobalContext* globalCtx); +void func_80A2586C(ObjIceblock* this, PlayState* play); void func_80A25978(ObjIceblock* this); -void func_80A25994(ObjIceblock* this, GlobalContext* globalCtx); +void func_80A25994(ObjIceblock* this, PlayState* play); void func_80A25A8C(ObjIceblock* this); -void func_80A25AA8(ObjIceblock* this, GlobalContext* globalCtx); +void func_80A25AA8(ObjIceblock* this, PlayState* play); void func_80A25BA0(ObjIceblock* this); -void func_80A25BBC(ObjIceblock* this, GlobalContext* globalCtx); +void func_80A25BBC(ObjIceblock* this, PlayState* play); void func_80A25C5C(ObjIceblock* this); -void func_80A25C70(ObjIceblock* this, GlobalContext* globalCtx); +void func_80A25C70(ObjIceblock* this, PlayState* play); void func_80A25CF4(ObjIceblock* this); -void func_80A25D28(ObjIceblock* this, GlobalContext* globalCtx); +void func_80A25D28(ObjIceblock* this, PlayState* play); void func_80A25E3C(ObjIceblock* this); -void func_80A25E50(ObjIceblock* this, GlobalContext* globalCtx); +void func_80A25E50(ObjIceblock* this, PlayState* play); void func_80A25FA0(ObjIceblock* this); -void func_80A25FD4(ObjIceblock* this, GlobalContext* globalCtx); +void func_80A25FD4(ObjIceblock* this, PlayState* play); void func_80A260E8(ObjIceblock* this); -void func_80A26144(ObjIceblock* this, GlobalContext* globalCtx); +void func_80A26144(ObjIceblock* this, PlayState* play); void func_80A262BC(ObjIceblock* this); -void func_80A262EC(ObjIceblock* this, GlobalContext* globalCtx); +void func_80A262EC(ObjIceblock* this, PlayState* play); void func_80A26574(ObjIceblock* this); -void func_80A265C0(ObjIceblock* this, GlobalContext* globalCtx); -void func_80A266E0(ObjIceblock* this, GlobalContext* globalCtx); -void func_80A26B64(ObjIceblock* this, GlobalContext* globalCtx); -void func_80A26B74(ObjIceblock* this, GlobalContext* globalCtx); -void func_80A26BF8(ObjIceblock* this, GlobalContext* globalCtx); +void func_80A265C0(ObjIceblock* this, PlayState* play); +void func_80A266E0(ObjIceblock* this, PlayState* play); +void func_80A26B64(ObjIceblock* this, PlayState* play); +void func_80A26B74(ObjIceblock* this, PlayState* play); +void func_80A26BF8(ObjIceblock* this, PlayState* play); const ActorInit Obj_Iceblock_InitVars = { ACTOR_OBJ_ICEBLOCK, @@ -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++) { @@ -148,7 +148,7 @@ void func_80A23370(ObjIceblock* this, s32 arg1) { this->unk_26C = arg1; } -void func_80A2339C(GlobalContext* globalCtx, Vec3f* arg1, f32 arg2, f32 arg3, s32 arg4) { +void func_80A2339C(PlayState* play, Vec3f* arg1, f32 arg2, f32 arg3, s32 arg4) { Vec3f spBC; Vec3f spB0; Vec3f spA4; @@ -187,7 +187,7 @@ void func_80A2339C(GlobalContext* globalCtx, Vec3f* arg1, f32 arg2, f32 arg3, s3 spA4.y = -0.8f - (temp_f20 * 18.0f); - EffectSsIceBlock_Spawn(globalCtx, &spBC, &spB0, &spA4, temp_s4); + EffectSsIceBlock_Spawn(play, &spBC, &spB0, &spA4, temp_s4); } } @@ -301,7 +301,7 @@ void func_80A23B88(ObjIceblock* this) { } } -s32 func_80A23D08(ObjIceblock* this, GlobalContext* globalCtx) { +s32 func_80A23D08(ObjIceblock* this, PlayState* play) { static ObjIceBlockUnkStruct3 D_80A26E90[] = { { -300.0f, 300.0f }, { 300.0f, 300.0f }, { -300.0f, -300.0f }, { 300.0f, -300.0f }, { 0.0f, 0.0f }, }; @@ -341,7 +341,7 @@ s32 func_80A23D08(ObjIceblock* this, GlobalContext* globalCtx) { spA4.z += this->dyna.actor.world.pos.z; ptr->unk_04 = - BgCheck_EntityRaycastFloor6(&globalCtx->colCtx, &ptr->unk_00, &ptr->unk_08, &this->dyna.actor, &spA4, 0.0f); + BgCheck_EntityRaycastFloor6(&play->colCtx, &ptr->unk_00, &ptr->unk_08, &this->dyna.actor, &spA4, 0.0f); if (ptr->unk_04 > BGCHECK_Y_MIN + 1) { sp94 = 1; if (phi_f22 < ptr->unk_04) { @@ -350,7 +350,7 @@ s32 func_80A23D08(ObjIceblock* this, GlobalContext* globalCtx) { } } - if (WaterBox_GetSurface1_2(globalCtx, &globalCtx->colCtx, spA4.x, spA4.z, &ptr->unk_0C, &spC4)) { + if (WaterBox_GetSurface1_2(play, &play->colCtx, spA4.x, spA4.z, &ptr->unk_0C, &spC4)) { if (phi_f20 < ptr->unk_0C) { spB8 = i; phi_f20 = ptr->unk_0C; @@ -379,10 +379,10 @@ s32 func_80A23D08(ObjIceblock* this, GlobalContext* globalCtx) { return sp94; } -s32 func_80A23F90(ObjIceblock* this, GlobalContext* globalCtx) { +s32 func_80A23F90(ObjIceblock* this, PlayState* play) { this->unk_1B0 &= ~4; - if (func_80A23D08(this, globalCtx)) { + if (func_80A23D08(this, play)) { f32 phi_f2 = BGCHECK_Y_MIN; s32 ret = false; s32 i; @@ -406,7 +406,7 @@ s32 func_80A23F90(ObjIceblock* this, GlobalContext* globalCtx) { return false; } -s32 func_80A24118(ObjIceblock* this, GlobalContext* globalCtx, f32 arg2, Vec3f* arg3) { +s32 func_80A24118(ObjIceblock* this, PlayState* play, f32 arg2, Vec3f* arg3) { static ObjIceBlockUnkStruct3 D_80A26EE0[] = { { -300.0f, -300.0f }, { 300.0f, -300.0f }, { -300.0f, 600.0f }, { 300.0f, 600.0f }, { 0.0f, 0.0f }, }; @@ -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, true, false, false, true, &spAC, + if (BgCheck_EntityLineTest3(&play->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) { @@ -473,10 +473,10 @@ s32 func_80A24118(ObjIceblock* this, GlobalContext* globalCtx, f32 arg2, Vec3f* return ret; } -s32 func_80A24384(ObjIceblock* this, GlobalContext* globalCtx) { +s32 func_80A24384(ObjIceblock* this, PlayState* play) { Vec3f sp1C; - if (func_80A24118(this, globalCtx, 0.0f, &sp1C)) { + if (func_80A24118(this, play, 0.0f, &sp1C)) { this->dyna.actor.world.pos.x += sp1C.x; this->dyna.actor.world.pos.z += sp1C.z; return true; @@ -484,7 +484,7 @@ s32 func_80A24384(ObjIceblock* this, GlobalContext* globalCtx) { return false; } -s32 func_80A243E0(ObjIceblock* this, GlobalContext* globalCtx, Vec3f* arg0) { +s32 func_80A243E0(ObjIceblock* this, PlayState* play, Vec3f* arg0) { static f32 D_80A26F30[] = { -300.0f, 300.0f }; static f32 D_80A26F38[] = { 1.0f, -1.0f }; s32 i; @@ -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, true, false, false, true, &spBC, + if (BgCheck_EntityLineTest3(&play->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) { @@ -551,10 +551,10 @@ s32 func_80A243E0(ObjIceblock* this, GlobalContext* globalCtx, Vec3f* arg0) { return ret; } -s32 func_80A24680(ObjIceblock* this, GlobalContext* globalCtx) { +s32 func_80A24680(ObjIceblock* this, PlayState* play) { Vec3f sp1C; - if (func_80A243E0(this, globalCtx, &sp1C)) { + if (func_80A243E0(this, play, &sp1C)) { this->dyna.actor.world.pos.x += sp1C.x; this->dyna.actor.world.pos.z += sp1C.z; return true; @@ -562,7 +562,7 @@ s32 func_80A24680(ObjIceblock* this, GlobalContext* globalCtx) { return false; } -s32 func_80A246D8(ObjIceblock* this, GlobalContext* globalCtx, Vec3f* arg2) { +s32 func_80A246D8(ObjIceblock* this, PlayState* play, Vec3f* arg2) { static ObjIceBlockUnkStruct3 D_80A26F40[] = { { -300.0f, -300.0f }, { 300.0f, -300.0f }, { -300.0f, 600.0f }, { 300.0f, 600.0f }, { 0.0f, 0.0f }, }; @@ -600,10 +600,10 @@ 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, true, false, false, true, &sp98, + if (BgCheck_EntityLineTest3(&play->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); + temp_v0 = (ObjIceblock*)DynaPoly_GetActor(&play->colCtx, sp98); if ((temp_v0 != NULL) && (temp_v0->dyna.actor.id == ACTOR_OBJ_ICEBLOCK) && (temp_v0->unk_2B0 == 3)) { temp_v0->unk_1B0 |= 0x80; } @@ -620,7 +620,7 @@ void func_80A2491C(ObjIceblock* this) { this->unk_276 = this->unk_278; } -s32 func_80A24954(ObjIceblock* this, GlobalContext* globalCtx) { +s32 func_80A24954(ObjIceblock* this, PlayState* play) { s32 pad[2]; s8 sp27 = this->unk_2B0; f32 temp = (this->dyna.actor.scale.y * 600.0f) - 90.0f; @@ -629,7 +629,7 @@ s32 func_80A24954(ObjIceblock* this, GlobalContext* globalCtx) { func_80A262BC(this); this->unk_2B0 = 3; } else if (this->unk_1B0 & 4) { - if (func_800C99D4(&globalCtx->colCtx, this->dyna.actor.floorPoly, this->dyna.actor.floorBgId) == 5) { + if (func_800C99D4(&play->colCtx, this->dyna.actor.floorPoly, this->dyna.actor.floorBgId) == 5) { func_80A25FA0(this); this->unk_2B0 = 2; } else { @@ -640,21 +640,21 @@ s32 func_80A24954(ObjIceblock* this, GlobalContext* globalCtx) { return sp27 != this->unk_2B0; } -void func_80A24A48(ObjIceblock* this, GlobalContext* globalCtx) { +void func_80A24A48(ObjIceblock* this, PlayState* play) { if (!(this->unk_1B0 & 0x10) && !(this->collider.base.ocFlags1 & OC1_HIT)) { - func_800C6314(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); + func_800C6314(play, &play->colCtx.dyna, this->dyna.bgId); this->unk_1B0 |= 0x10; } } -void func_80A24AA8(ObjIceblock* this, GlobalContext* globalCtx) { +void func_80A24AA8(ObjIceblock* this, PlayState* play) { s32 i; f32 x; ObjIceblock* temp_v0; if (this->unk_1B0 & 4) { for (i = 0; i < ARRAY_COUNT(this->unk_1F4); i++) { - temp_v0 = (ObjIceblock*)DynaPoly_GetActor(&globalCtx->colCtx, ((void)0, this->unk_1F4[i]).unk_08); + temp_v0 = (ObjIceblock*)DynaPoly_GetActor(&play->colCtx, ((void)0, this->unk_1F4[i]).unk_08); if ((temp_v0 != NULL) && (temp_v0->dyna.actor.id == ACTOR_OBJ_ICEBLOCK)) { x = this->dyna.actor.world.pos.y - this->unk_1F4[i].unk_04; @@ -666,7 +666,7 @@ void func_80A24AA8(ObjIceblock* this, GlobalContext* globalCtx) { } } -void func_80A24B74(ObjIceblock* this, GlobalContext* globalCtx) { +void func_80A24B74(ObjIceblock* this, PlayState* play) { s32 pad; Vec3f sp20; @@ -675,11 +675,11 @@ void func_80A24B74(ObjIceblock* this, GlobalContext* globalCtx) { sp20.x = this->dyna.actor.world.pos.x; sp20.y = this->unk_244; sp20.z = this->dyna.actor.world.pos.z; - EffectSsGRipple_Spawn(globalCtx, &sp20, 480, 880, 0); + EffectSsGRipple_Spawn(play, &sp20, 480, 880, 0); } } -void func_80A24BDC(ObjIceblock* this, GlobalContext* globalCtx, f32 arg2, f32 arg3, s32 arg4) { +void func_80A24BDC(ObjIceblock* this, PlayState* play, f32 arg2, f32 arg3, s32 arg4) { s32 i; Vec3f sp88; f32 temp_f20; @@ -695,7 +695,7 @@ void func_80A24BDC(ObjIceblock* this, GlobalContext* globalCtx, f32 arg2, f32 ar temp_f20 = ((Rand_ZeroOne() * 5.0f) + 40.0f) * arg2; sp88.x = (Math_SinS((s32)(Rand_ZeroOne() * temp_f22) + phi_s0) * temp_f20) + this->dyna.actor.world.pos.x; sp88.z = (Math_CosS((s32)(Rand_ZeroOne() * temp_f22) + phi_s0) * temp_f20) + this->dyna.actor.world.pos.z; - EffectSsGSplash_Spawn(globalCtx, &sp88, NULL, NULL, 0, ((Rand_ZeroOne() * 60.0f) + 320.0f) * arg3); + EffectSsGSplash_Spawn(play, &sp88, NULL, NULL, 0, ((Rand_ZeroOne() * 60.0f) + 320.0f) * arg3); } } } @@ -704,7 +704,7 @@ void func_80A24DC4(ObjIceblock* this) { this->unk_2A2 = 0; } -void func_80A24DD0(ObjIceblock* this, GlobalContext* globalCtx) { +void func_80A24DD0(ObjIceblock* this, PlayState* play) { static Vec3f D_80A26F90 = { 0.0f, 0.3f, 0.0f }; static Color_RGBA8 D_80A26F9C = { 250, 250, 250, 255 }; static Color_RGBA8 D_80A26FA0 = { 180, 180, 180, 255 }; @@ -751,13 +751,13 @@ void func_80A24DD0(ObjIceblock* this, GlobalContext* globalCtx) { spA8.z += this->dyna.actor.world.pos.z; temp_f20 = ((Rand_ZeroOne() * 800.0f) + (1600.0f * this->dyna.actor.scale.x)) * phi_f22; - func_800B0E48(globalCtx, &spA8, &gZeroVec3f, &D_80A26F90, &D_80A26F9C, &D_80A26FA0, temp_f20, + func_800B0E48(play, &spA8, &gZeroVec3f, &D_80A26F90, &D_80A26F9C, &D_80A26FA0, temp_f20, (Rand_ZeroOne() * 20.0f) + 30.0f); } } } -void func_80A2508C(ObjIceblock* this, GlobalContext* globalCtx) { +void func_80A2508C(ObjIceblock* this, PlayState* play) { s32 pad; Vec3f sp40; Vec3f sp34; @@ -786,8 +786,7 @@ void func_80A2508C(ObjIceblock* this, GlobalContext* globalCtx) { sp34.z = (this->dyna.actor.scale.z * sp34.z) + this->dyna.actor.world.pos.z; if ((this->unk_244 - 3.0f) < sp34.y) { - EffectSsIceSmoke_Spawn(globalCtx, &sp34, &sp40, &gZeroVec3f, - (s32)(this->dyna.actor.scale.y * 1300.0f) + 60); + EffectSsIceSmoke_Spawn(play, &sp34, &sp40, &gZeroVec3f, (s32)(this->dyna.actor.scale.y * 1300.0f) + 60); } } } @@ -847,8 +846,8 @@ void func_80A25404(ObjIceblock* this) { this->unk_26E[0] = 0; } -void func_80A2541C(ObjIceblock* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); +void func_80A2541C(ObjIceblock* this, PlayState* play) { + Player* player = GET_PLAYER(play); player->stateFlags2 &= ~0x10; this->dyna.pushForce = 0.0f; @@ -866,26 +865,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); } @@ -902,7 +901,7 @@ static InitChainEntry sInitChain[] = { ICHAIN_F32(uncullZoneDownward, 200, ICHAIN_STOP), }; -void ObjIceblock_Init(Actor* thisx, GlobalContext* globalCtx) { +void ObjIceblock_Init(Actor* thisx, PlayState* play) { s32 pad; ObjIceblock* this = THIS; Actor* parent; @@ -915,19 +914,19 @@ 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 (!GET_ICEBLOCK_SNAP_ROT(&this->dyna.actor)) { + if (!ICEBLOCK_GET_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, &gIceBlockDynaColHeader); - func_800C62BC(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); - Collider_InitCylinder(globalCtx, &this->collider); - Collider_SetCylinder(globalCtx, &this->collider, &this->dyna.actor, &sCylinderInit); + DynaPolyActor_LoadMesh(play, &this->dyna, &gIceBlockDynaColHeader); + func_800C62BC(play, &play->colCtx.dyna, this->dyna.bgId); + Collider_InitCylinder(play, &this->collider); + Collider_SetCylinder(play, &this->collider, &this->dyna.actor, &sCylinderInit); - if (GET_ICEBLOCK_ICEBERG(&this->dyna.actor)) { + if (ICEBLOCK_GET_ICEBERG(&this->dyna.actor)) { this->collider.dim.yShift = -100; this->collider.dim.height = 126; this->collider.dim.radius = 29; @@ -949,7 +948,7 @@ void ObjIceblock_Init(Actor* thisx, GlobalContext* globalCtx) { } } - if (GET_ICEBLOCK_ICEBERG(&this->dyna.actor)) { + if (ICEBLOCK_GET_ICEBERG(&this->dyna.actor)) { this->unk_2B4 = -1.0f; } @@ -959,18 +958,18 @@ void ObjIceblock_Init(Actor* thisx, GlobalContext* globalCtx) { this->meltTimer = 450; // (450/20) = 22 seconds } -void ObjIceblock_Destroy(Actor* thisx, GlobalContext* globalCtx) { +void ObjIceblock_Destroy(Actor* thisx, PlayState* play) { ObjIceblock* this = THIS; - DynaPoly_DeleteBgActor(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); - Collider_DestroyCylinder(globalCtx, &this->collider); + DynaPoly_DeleteBgActor(play, &play->colCtx.dyna, this->dyna.bgId); + Collider_DestroyCylinder(play, &this->collider); } void ObjIceBlock_SetupAttemptSpawnCutscene(ObjIceblock* this) { this->actionFunc = ObjIceBlock_AttemptSpawnCutscene; } -void ObjIceBlock_AttemptSpawnCutscene(ObjIceblock* this, GlobalContext* globalCtx) { +void ObjIceBlock_AttemptSpawnCutscene(ObjIceblock* this, PlayState* play) { if (ActorCutscene_GetCanPlayNext(this->dyna.actor.cutscene)) { ActorCutscene_StartAndSetUnkLinkFields(this->dyna.actor.cutscene, &this->dyna.actor); this->extendedDrawFunc = func_80A26BF8; @@ -988,7 +987,7 @@ void func_80A25824(ObjIceblock* this) { func_80A2319C(this, this->dyna.actor.scale.x); } -void func_80A2586C(ObjIceblock* this, GlobalContext* globalCtx) { +void func_80A2586C(ObjIceblock* this, PlayState* play) { func_80A236D4(this, &this->dyna.actor.home.pos); if (this->stateTimer > 0) { @@ -998,7 +997,7 @@ void func_80A2586C(ObjIceblock* this, GlobalContext* globalCtx) { if (Math_StepToF(&this->dyna.actor.scale.x, 0.1f, 0.02f)) { Actor_SetScale(&this->dyna.actor, 0.1f); - if (GET_ICEBLOCK_ICEBERG(&this->dyna.actor)) { + if (ICEBLOCK_GET_ICEBERG(&this->dyna.actor)) { this->unk_2B4 = 0.05f; } func_80A25978(this); @@ -1010,7 +1009,7 @@ void func_80A2586C(ObjIceblock* this, GlobalContext* globalCtx) { func_80A2319C(this, this->dyna.actor.scale.x); 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); + func_80A2339C(play, &this->dyna.actor.world.pos, (this->dyna.actor.scale.x + 0.05f) * 0.6666666f, 1.0f, 3); } } @@ -1019,7 +1018,7 @@ void func_80A25978(ObjIceblock* this) { this->stateTimer = 4; } -void func_80A25994(ObjIceblock* this, GlobalContext* globalCtx) { +void func_80A25994(ObjIceblock* this, PlayState* play) { s32 pad; Vec3f sp30; @@ -1030,16 +1029,16 @@ void func_80A25994(ObjIceblock* this, GlobalContext* globalCtx) { } 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 (GET_ICEBLOCK_ICEBERG(&this->dyna.actor)) { + func_80A2339C(play, &this->dyna.actor.world.pos, this->dyna.actor.scale.x, 1.2f, 15); + if (ICEBLOCK_GET_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; - func_80A2339C(globalCtx, &sp30, this->dyna.actor.scale.x, 1.2f, 10); + func_80A2339C(play, &sp30, this->dyna.actor.scale.x, 1.2f, 10); } } - if (GET_ICEBLOCK_ICEBERG(&this->dyna.actor)) { + if (ICEBLOCK_GET_ICEBERG(&this->dyna.actor)) { this->unk_2B4 = 0.1f; } @@ -1052,7 +1051,7 @@ void func_80A25A8C(ObjIceblock* this) { this->stateTimer = 2; } -void func_80A25AA8(ObjIceblock* this, GlobalContext* globalCtx) { +void func_80A25AA8(ObjIceblock* this, PlayState* play) { s32 pad[2]; f32 sp24; s32 temp = func_80A236D4(this, &this->dyna.actor.home.pos); @@ -1064,7 +1063,7 @@ void func_80A25AA8(ObjIceblock* this, GlobalContext* globalCtx) { if (temp) { sp24 = this->dyna.actor.scale.y * 300.0f; - func_80A23D08(this, globalCtx); + func_80A23D08(this, play); if (sp24 < (this->dyna.actor.world.pos.y - this->dyna.actor.floorHeight)) { func_80A25BA0(this); } else { @@ -1075,7 +1074,7 @@ void func_80A25AA8(ObjIceblock* this, GlobalContext* globalCtx) { this->dyna.actor.shape.yOffset = 300.0f; this->unk_248.y += sp24; - if (GET_ICEBLOCK_ICEBERG(&this->dyna.actor)) { + if (ICEBLOCK_GET_ICEBERG(&this->dyna.actor)) { this->collider.dim.yShift = -69; } else { this->collider.dim.yShift = 0; @@ -1089,18 +1088,18 @@ void func_80A25BA0(ObjIceblock* this) { this->dyna.actor.velocity.y = 0.0f; } -void func_80A25BBC(ObjIceblock* this, GlobalContext* globalCtx) { +void func_80A25BBC(ObjIceblock* this, PlayState* play) { if (func_80A25238(this) != -1) { - func_80A2541C(this, globalCtx); + func_80A2541C(this, play); } func_80A23690(this); - if (func_80A23F90(this, globalCtx)) { + if (func_80A23F90(this, play)) { Actor_PlaySfxAtPos(&this->dyna.actor, NA_SE_EV_BLOCK_BOUND); } - if (func_80A24954(this, globalCtx)) { + if (func_80A24954(this, play)) { func_80A2491C(this); if (this->unk_2B0 == 3) { Actor_PlaySfxAtPos(&this->dyna.actor, NA_SE_EV_DIVE_INTO_WATER_L); @@ -1112,14 +1111,14 @@ void func_80A25C5C(ObjIceblock* this) { this->actionFunc = func_80A25C70; } -void func_80A25C70(ObjIceblock* this, GlobalContext* globalCtx) { +void func_80A25C70(ObjIceblock* this, PlayState* play) { if (func_80A25238(this) != -1) { - func_80A2541C(this, globalCtx); + func_80A2541C(this, play); } if (Math_StepToF(&this->dyna.actor.world.pos.y, this->dyna.actor.floorHeight - 0.1f, 14.0f)) { - func_80A23F90(this, globalCtx); - func_80A24954(this, globalCtx); + func_80A23F90(this, play); + func_80A24954(this, play); } } @@ -1128,13 +1127,13 @@ void func_80A25CF4(ObjIceblock* this) { this->actionFunc = func_80A25D28; } -void func_80A25D28(ObjIceblock* this, GlobalContext* globalCtx) { +void func_80A25D28(ObjIceblock* this, PlayState* play) { s32 sp34; s32 sp30; Vec3f sp24; func_80A23690(this); - func_80A23F90(this, globalCtx); + func_80A23F90(this, play); sp30 = func_80A25238(this); func_80A252DC(this, sp30); sp34 = true; @@ -1142,7 +1141,7 @@ void func_80A25D28(ObjIceblock* this, GlobalContext* globalCtx) { sp34 = false; } else if (!(this->unk_1B0 & 2) && (this->unk_26E[sp30] >= 11)) { sp34 = true; - if (!func_80A24118(this, globalCtx, (this->dyna.pushForce > 0.0f) ? 59.9f : 89.9f, &sp24)) { + if (!func_80A24118(this, play, (this->dyna.pushForce > 0.0f) ? 59.9f : 89.9f, &sp24)) { func_80A232C4(this, sp30); func_80A25E3C(this); sp34 = false; @@ -1150,17 +1149,17 @@ void func_80A25D28(ObjIceblock* this, GlobalContext* globalCtx) { } if (sp34) { - func_80A2541C(this, globalCtx); + func_80A2541C(this, play); } - func_80A24A48(this, globalCtx); + func_80A24A48(this, play); } void func_80A25E3C(ObjIceblock* this) { this->actionFunc = func_80A25E50; } -void func_80A25E50(ObjIceblock* this, GlobalContext* globalCtx) { +void func_80A25E50(ObjIceblock* this, PlayState* play) { s32 pad; f32 temp_f0 = this->unk_268 - *this->unk_264; f32 temp_f2 = (Math_SinS(fabsf(temp_f0) * 546.13336f) * 2.8f) + 1.2f; @@ -1169,16 +1168,16 @@ void func_80A25E50(ObjIceblock* this, GlobalContext* globalCtx) { Vec3f sp28; func_80A23690(this); - if (!func_80A23F90(this, globalCtx)) { - func_80A24680(this, globalCtx); + if (!func_80A23F90(this, play)) { + func_80A24680(this, play); func_80A23B88(this); - func_80A2541C(this, globalCtx); + func_80A2541C(this, play); func_80A25BA0(this); } else if (sp38) { - if (func_80A24118(this, globalCtx, 59.9f, &sp28)) { + if (func_80A24118(this, play, 59.9f, &sp28)) { Actor_PlaySfxAtPos(&this->dyna.actor, NA_SE_EV_BLOCK_BOUND); } - func_80A2541C(this, globalCtx); + func_80A2541C(this, play); func_80A25CF4(this); } else { func_800B9010(&this->dyna.actor, NA_SE_PL_SLIP_ICE_LEVEL - SFX_FLAG); @@ -1190,35 +1189,35 @@ void func_80A25FA0(ObjIceblock* this) { this->actionFunc = func_80A25FD4; } -void func_80A25FD4(ObjIceblock* this, GlobalContext* globalCtx) { +void func_80A25FD4(ObjIceblock* this, PlayState* play) { s32 pad; s32 sp30; s32 sp2C; Vec3f sp20; func_80A23690(this); - func_80A23F90(this, globalCtx); + func_80A23F90(this, play); sp2C = func_80A25238(this); func_80A252DC(this, sp2C); sp30 = true; if (sp2C == -1) { sp30 = false; - } else if (!(this->unk_1B0 & 2) && (this->unk_26E[sp2C] >= 11) && !func_80A24118(this, globalCtx, 2.0f, &sp20) && - !Player_InCsMode(&globalCtx->state)) { + } else if (!(this->unk_1B0 & 2) && (this->unk_26E[sp2C] >= 11) && !func_80A24118(this, play, 2.0f, &sp20) && + !Player_InCsMode(play)) { func_80A23370(this, sp2C); func_80A260E8(this); sp30 = false; - func_800B7298(globalCtx, &this->dyna.actor, 7); + func_800B7298(play, &this->dyna.actor, 7); this->unk_1B0 |= 1; } if (this) {} if (sp30) { - func_80A2541C(this, globalCtx); + func_80A2541C(this, play); } - func_80A24A48(this, globalCtx); + func_80A24A48(this, play); } void func_80A260E8(ObjIceblock* this) { @@ -1232,7 +1231,7 @@ void func_80A260E8(ObjIceblock* this) { this->actionFunc = func_80A26144; } -void func_80A26144(ObjIceblock* this, GlobalContext* globalCtx) { +void func_80A26144(ObjIceblock* this, PlayState* play) { s32 pad2; s32 sp28; s32 isBool; @@ -1244,22 +1243,22 @@ void func_80A26144(ObjIceblock* this, GlobalContext* globalCtx) { Math_StepToF(&this->unk_25C, this->unk_260, 0.75f); *this->unk_264 += this->unk_25C; - sp28 = func_80A24384(this, globalCtx); + sp28 = func_80A24384(this, play); func_80A23690(this); - sp24 = func_80A23F90(this, globalCtx); + sp24 = func_80A23F90(this, play); isBool = sp24 == 0; if (isBool || sp28 || (this->stateTimer == 1)) { - func_80A2541C(this, globalCtx); + func_80A2541C(this, play); } if ((this->unk_1B0 & 1) && (isBool || sp28 || (this->dyna.actor.xzDistToPlayer > 400.0f))) { this->unk_1B0 &= ~1; - func_800B7298(globalCtx, &this->dyna.actor, 6); + func_800B7298(play, &this->dyna.actor, 6); } if (isBool) { - func_80A24680(this, globalCtx); + func_80A24680(this, play); func_80A23B88(this); func_80A25BA0(this); } else if (sp28) { @@ -1270,7 +1269,7 @@ void func_80A26144(ObjIceblock* this, GlobalContext* globalCtx) { func_800B9010(&this->dyna.actor, NA_SE_PL_SLIP_ICE_LEVEL - SFX_FLAG); } - func_80A24DD0(this, globalCtx); + func_80A24DD0(this, play); } void func_80A262BC(ObjIceblock* this) { @@ -1279,7 +1278,7 @@ void func_80A262BC(ObjIceblock* this) { this->stateTimer = -1; } -void func_80A262EC(ObjIceblock* this, GlobalContext* globalCtx) { +void func_80A262EC(ObjIceblock* this, PlayState* play) { s32 pad; f32 temp_f14; f32 temp_f18; @@ -1287,7 +1286,7 @@ void func_80A262EC(ObjIceblock* this, GlobalContext* globalCtx) { f32 temp; if (func_80A25238(this) != -1) { - func_80A2541C(this, globalCtx); + func_80A2541C(this, play); } if (this->stateTimer > 0) { @@ -1297,15 +1296,15 @@ void func_80A262EC(ObjIceblock* this, GlobalContext* globalCtx) { 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); + func_80A24BDC(this, play, 1.0f, 0.9f, 11); + func_80A24B74(this, play); this->stateTimer = 3; } else { this->stateTimer = 0; } } else if (this->stateTimer == 1) { - func_80A24BDC(this, globalCtx, 0.7f, 1.3f, 6); - func_80A24B74(this, globalCtx); + func_80A24BDC(this, play, 0.7f, 1.3f, 6); + func_80A24B74(this, play); } this->dyna.actor.velocity.y += 5.0f; @@ -1317,20 +1316,20 @@ void func_80A262EC(ObjIceblock* this, GlobalContext* globalCtx) { this->dyna.actor.world.pos.y += temp; temp_f14 = this->dyna.actor.world.pos.y + (600.0f * this->dyna.actor.scale.y); if (this->unk_244 < (temp_f14 - 90.0f)) { - func_80A24B74(this, globalCtx); + func_80A24B74(this, play); func_80A26574(this); } else { if ((this->dyna.actor.velocity.y > 0.0f) && (temp_f14 < (this->unk_244 + 3.0f)) && (this->unk_244 <= temp_f14)) { - func_80A24BDC(this, globalCtx, 0.8f, 1.0f, 11); - func_80A24B74(this, globalCtx); + func_80A24BDC(this, play, 0.8f, 1.0f, 11); + func_80A24B74(this, play); } sp38.x = this->dyna.actor.world.pos.x; sp38.y = (this->unk_244 - (600.0f * this->dyna.actor.scale.y)) + 90.0f; sp38.z = this->dyna.actor.world.pos.z; - if (func_80A246D8(this, globalCtx, &sp38)) { + if (func_80A246D8(this, play, &sp38)) { this->unk_1B0 |= 0x80; } } @@ -1348,12 +1347,12 @@ void func_80A26574(ObjIceblock* this) { this->stateTimer = 40; } -void func_80A265C0(ObjIceblock* this, GlobalContext* globalCtx) { +void func_80A265C0(ObjIceblock* this, PlayState* play) { s32 pad; ObjIceBlockUnkStruct4* ptr; if (func_80A25238(this) != -1) { - func_80A2541C(this, globalCtx); + func_80A2541C(this, play); } if (this->stateTimer > 0) { @@ -1364,18 +1363,18 @@ void func_80A265C0(ObjIceblock* this, GlobalContext* globalCtx) { ptr->unk_0C = Rand_S16Offset(300, 300); ptr->unk_0E = Rand_S16Offset(900, 600); ptr->unk_04 = (2.0f * Rand_ZeroOne()) + 1.0f; - ptr->unk_14 = (u32)Rand_Next() >> 0x10; - func_80A24B74(this, globalCtx); + ptr->unk_14 = Rand_Next() >> 0x10; + func_80A24B74(this, play); } func_80A237A4(this); func_80A23938(this); if (this->unk_1B0 & 0x40) { - func_80A24B74(this, globalCtx); + func_80A24B74(this, play); } - func_80A24A48(this, globalCtx); + func_80A24A48(this, play); } void func_80A266C4(ObjIceblock* this) { @@ -1383,7 +1382,7 @@ void func_80A266C4(ObjIceblock* this) { this->unk_2A8 = 0.0f; } -void func_80A266E0(ObjIceblock* this, GlobalContext* globalCtx) { +void func_80A266E0(ObjIceblock* this, PlayState* play) { f32 temp; s32 sp20; Actor* actor = &this->dyna.actor; @@ -1401,21 +1400,21 @@ void func_80A266E0(ObjIceblock* this, GlobalContext* globalCtx) { actor->scale.z = actor->scale.x; } - if (GET_ICEBLOCK_ICEBERG(&this->dyna.actor)) { + if (ICEBLOCK_GET_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; this->collider.dim.radius = actor->scale.x * 290.0f; } - func_80A2508C(this, globalCtx); + func_80A2508C(this, play); if (sp20) { Actor_MarkForDeath(&this->dyna.actor); } } -void ObjIceblock_Update(Actor* thisx, GlobalContext* globalCtx) { +void ObjIceblock_Update(Actor* thisx, PlayState* play) { s32 pad; ObjIceblock* this = THIS; Actor* parent = this->dyna.actor.parent; @@ -1454,7 +1453,7 @@ void ObjIceblock_Update(Actor* thisx, GlobalContext* globalCtx) { this->unk_1B0 &= ~0x100; if (this->unk_1B0 & 1) { this->unk_1B0 &= ~1; - func_800B7298(globalCtx, &this->dyna.actor, 6); + func_800B7298(play, &this->dyna.actor, 6); } func_80A266C4(this); } @@ -1467,7 +1466,7 @@ void ObjIceblock_Update(Actor* thisx, GlobalContext* globalCtx) { } } - this->actionFunc(this, globalCtx); + this->actionFunc(this, play); if (this->dyna.actor.update == NULL) { if (parent != NULL) { parent->child = NULL; @@ -1484,19 +1483,19 @@ void ObjIceblock_Update(Actor* thisx, GlobalContext* globalCtx) { Collider_UpdateCylinder(&this->dyna.actor, &this->collider); if (this->unk_1B0 & 0x10) { - if (GET_ICEBLOCK_ICEBERG(&this->dyna.actor) && (this->unk_2B4 > 0.0f)) { + if (ICEBLOCK_GET_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 |= (0x800000 | 0x400000 | 0x10000 | 0x2000 | 0x1000 | 0x800 | 0x200 | 0x100 | 0x80 | 0x20 | 0x10 | 0x2); - CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + CollisionCheck_SetOC(play, &play->colChkCtx, &this->collider.base); } } else { - CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + CollisionCheck_SetOC(play, &play->colChkCtx, &this->collider.base); } if (this->unk_1B0 & 0x100) { - CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + CollisionCheck_SetAC(play, &play->colChkCtx, &this->collider.base); } func_80A25440(this); @@ -1506,59 +1505,59 @@ void ObjIceblock_Update(Actor* thisx, GlobalContext* globalCtx) { if (parent) {} } -void func_80A26B64(ObjIceblock* this, GlobalContext* globalCtx) { +void func_80A26B64(ObjIceblock* this, PlayState* play) { } // draw func -void func_80A26B74(ObjIceblock* this, GlobalContext* globalCtx) { - 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); +void func_80A26B74(ObjIceblock* this, PlayState* play) { + Gfx_DrawDListXlu(play, gIceBlockCubeDL); + if (ICEBLOCK_GET_ICEBERG(&this->dyna.actor) && (this->unk_2B4 > 0.0f)) { + AnimatedMat_Draw(play, Lib_SegmentedToVirtual(gIceBlockIceBergSublimatingAirTexAnim)); + Gfx_DrawDListXlu(play, gIceBlockIceBergDL); } } // draw func -void func_80A26BF8(ObjIceblock* this, GlobalContext* globalCtx) { +void func_80A26BF8(ObjIceblock* this, PlayState* play) { s32 pad[2]; ObjIceBlockUnkStruct* ptr; s32 i; Vec3s sp70; - OPEN_DISPS(globalCtx->state.gfxCtx); + OPEN_DISPS(play->state.gfxCtx); - func_8012C2DC(globalCtx->state.gfxCtx); + func_8012C2DC(play->state.gfxCtx); sp70.z = 0; for (i = 0; i < ARRAY_COUNT(this->unk_1B4); i++) { ptr = &this->unk_1B4[i]; sp70.x = ptr->unk_00; sp70.y = ptr->unk_02; - Matrix_SetStateRotationAndTranslation(this->dyna.actor.world.pos.x, this->dyna.actor.world.pos.y, - this->dyna.actor.world.pos.z, &sp70); + Matrix_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); + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_XLU_DISP++, gIceBlockCubeDL); } - if (GET_ICEBLOCK_ICEBERG(&this->dyna.actor) && (this->unk_2B4 > 0.0f)) { - AnimatedMat_Draw(globalCtx, Lib_SegmentedToVirtual(gIceBlockIceBergSublimatingAirTexAnim)); - Matrix_SetStateRotationAndTranslation(this->dyna.actor.world.pos.x, this->dyna.actor.world.pos.y - 20.0f, - this->dyna.actor.world.pos.z, &this->dyna.actor.shape.rot); + if (ICEBLOCK_GET_ICEBERG(&this->dyna.actor) && (this->unk_2B4 > 0.0f)) { + AnimatedMat_Draw(play, 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); + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_XLU_DISP++, gIceBlockIceBergDL); } - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->state.gfxCtx); } -void ObjIceblock_Draw(Actor* thisx, GlobalContext* globalCtx) { +void ObjIceblock_Draw(Actor* thisx, PlayState* play) { ObjIceblock* this = THIS; - AnimatedMat_Draw(globalCtx, sCubeSublimatingAirTexMat); - this->extendedDrawFunc(this, globalCtx); - func_80A24AA8(this, globalCtx); + AnimatedMat_Draw(play, sCubeSublimatingAirTexMat); + this->extendedDrawFunc(this, play); + func_80A24AA8(this, play); } 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 52460b87d..46ebc0c40 100644 --- a/src/overlays/actors/ovl_Obj_Iceblock/z_obj_iceblock.h +++ b/src/overlays/actors/ovl_Obj_Iceblock/z_obj_iceblock.h @@ -5,11 +5,11 @@ struct ObjIceblock; -typedef void (*ObjIceblockActionFunc)(struct ObjIceblock*, GlobalContext*); -typedef void (*ObjIceblockExtendedDrawFunc)(struct ObjIceblock*, GlobalContext*); +typedef void (*ObjIceblockActionFunc)(struct ObjIceblock*, PlayState*); +typedef void (*ObjIceblockExtendedDrawFunc)(struct ObjIceblock*, PlayState*); -#define GET_ICEBLOCK_SNAP_ROT(thisx) (((thisx)->params >> 1) & 1) -#define GET_ICEBLOCK_ICEBERG(thisx) ((thisx)->params & 1) +#define ICEBLOCK_GET_SNAP_ROT(thisx) (((thisx)->params >> 1) & 1) +#define ICEBLOCK_GET_ICEBERG(thisx) ((thisx)->params & 1) typedef struct { /* 0x00 */ s16 unk_00; @@ -27,8 +27,8 @@ typedef struct { } ObjIceBlockUnkStruct2; // size = 0x10 typedef struct { - f32 unk_00; - f32 unk_04; + /* 0x0 */ f32 unk_00; + /* 0x4 */ f32 unk_04; } ObjIceBlockUnkStruct3; // size = 0x8 typedef struct { @@ -48,34 +48,34 @@ typedef struct { } ObjIceBlockUnkStruct4; // size = 0x24 typedef struct ObjIceblock { - /* 0x0000 */ DynaPolyActor dyna; - /* 0x015C */ ColliderCylinder collider; - /* 0x01A8 */ ObjIceblockActionFunc actionFunc; - /* 0x01AC */ ObjIceblockExtendedDrawFunc extendedDrawFunc; - /* 0x01B0 */ s32 unk_1B0; - /* 0x01B4 */ ObjIceBlockUnkStruct unk_1B4[4]; - /* 0x01F4 */ ObjIceBlockUnkStruct2 unk_1F4[5]; - /* 0x0244 */ f32 unk_244; - /* 0x0248 */ Vec3f unk_248; - /* 0x0254 */ Vec3s unk_254; - /* 0x025C */ f32 unk_25C; - /* 0x0260 */ f32 unk_260; - /* 0x0264 */ f32* unk_264; - /* 0x0268 */ f32 unk_268; - /* 0x026C */ s16 unk_26C; - /* 0x026E */ s16 unk_26E[4]; - /* 0x0276 */ s16 unk_276; - /* 0x0278 */ s16 unk_278; - /* 0x027C */ ObjIceBlockUnkStruct4 unk_27C; - /* 0x02A0 */ s16 stateTimer; // re-used per-actionFunc - /* 0x02A2 */ s16 unk_2A2; - /* 0x02A4 */ f32 unk_2A4; - /* 0x02A8 */ f32 unk_2A8; - /* 0x02AC */ s16 unk_2AC; - /* 0x02AE */ s16 meltTimer; // starts at 450 frames = 22 seconds - /* 0x02B0 */ s8 unk_2B0; - /* 0x02B1 */ s8 spawnCutsceneTimer; - /* 0x02B4 */ f32 unk_2B4; + /* 0x000 */ DynaPolyActor dyna; + /* 0x15C */ ColliderCylinder collider; + /* 0x1A8 */ ObjIceblockActionFunc actionFunc; + /* 0x1AC */ ObjIceblockExtendedDrawFunc extendedDrawFunc; + /* 0x1B0 */ s32 unk_1B0; + /* 0x1B4 */ ObjIceBlockUnkStruct unk_1B4[4]; + /* 0x1F4 */ ObjIceBlockUnkStruct2 unk_1F4[5]; + /* 0x244 */ f32 unk_244; + /* 0x248 */ Vec3f unk_248; + /* 0x254 */ Vec3s unk_254; + /* 0x25C */ f32 unk_25C; + /* 0x260 */ f32 unk_260; + /* 0x264 */ f32* unk_264; + /* 0x268 */ f32 unk_268; + /* 0x26C */ s16 unk_26C; + /* 0x26E */ s16 unk_26E[4]; + /* 0x276 */ s16 unk_276; + /* 0x278 */ s16 unk_278; + /* 0x27C */ ObjIceBlockUnkStruct4 unk_27C; + /* 0x2A0 */ s16 stateTimer; // re-used per-actionFunc + /* 0x2A2 */ s16 unk_2A2; + /* 0x2A4 */ f32 unk_2A4; + /* 0x2A8 */ f32 unk_2A8; + /* 0x2AC */ s16 unk_2AC; + /* 0x2AE */ s16 meltTimer; // starts at 450 frames = 22 seconds + /* 0x2B0 */ s8 unk_2B0; + /* 0x2B1 */ s8 spawnCutsceneTimer; + /* 0x2B4 */ f32 unk_2B4; } ObjIceblock; // size = 0x2B8 extern const ActorInit Obj_Iceblock_InitVars; diff --git a/src/overlays/actors/ovl_Obj_Jg_Gakki/z_obj_jg_gakki.c b/src/overlays/actors/ovl_Obj_Jg_Gakki/z_obj_jg_gakki.c index 53d1d7669..497d9a219 100644 --- a/src/overlays/actors/ovl_Obj_Jg_Gakki/z_obj_jg_gakki.c +++ b/src/overlays/actors/ovl_Obj_Jg_Gakki/z_obj_jg_gakki.c @@ -11,10 +11,10 @@ #define THIS ((ObjJgGakki*)thisx) -void ObjJgGakki_Init(Actor* thisx, GlobalContext* globalCtx); -void ObjJgGakki_Destroy(Actor* thisx, GlobalContext* globalCtx); -void ObjJgGakki_Update(Actor* thisx, GlobalContext* globalCtx); -void ObjJgGakki_Draw(Actor* thisx, GlobalContext* globalCtx); +void ObjJgGakki_Init(Actor* thisx, PlayState* play); +void ObjJgGakki_Destroy(Actor* thisx, PlayState* play); +void ObjJgGakki_Update(Actor* thisx, PlayState* play); +void ObjJgGakki_Draw(Actor* thisx, PlayState* play); const ActorInit Obj_Jg_Gakki_InitVars = { ACTOR_OBJ_JG_GAKKI, @@ -28,39 +28,40 @@ const ActorInit Obj_Jg_Gakki_InitVars = { (ActorFunc)ObjJgGakki_Draw, }; -void ObjJgGakki_Init(Actor* thisx, GlobalContext* globalCtx2) { - GlobalContext* globalCtx = globalCtx2; +void ObjJgGakki_Init(Actor* thisx, PlayState* play2) { + PlayState* play = play2; ObjJgGakki* this = THIS; 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); + SkelAnime_Init(play, &this->skelAnime, &gGoronElderDrumSkel, NULL, NULL, NULL, 0); - if (((globalCtx->sceneNum == SCENE_SPOT00) && (gSaveContext.sceneSetupIndex == 7)) && - (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, &gGoronElderDrumTakeOutAnim, 1.0f, 0.0f, frameCount, 2, 0.0f); + if (((play->sceneNum == SCENE_SPOT00) && (gSaveContext.sceneSetupIndex == 7)) && + (play->csCtx.currentCsIndex == 0)) { + Animation_Change(&this->skelAnime, &gGoronElderDrumTakeOutAnim, 1.0f, frameCount, frameCount, ANIMMODE_ONCE, + 0.0f); + } else if ((play->sceneNum == SCENE_17SETUGEN) || (play->sceneNum == SCENE_10YUKIYAMANOMURA)) { + Animation_Change(&this->skelAnime, &gGoronElderDrumTakeOutAnim, 1.0f, 0.0f, frameCount, ANIMMODE_ONCE, 0.0f); } else { Actor_MarkForDeath(&this->actor); } Actor_SetScale(&this->actor, 0.01f); } -void ObjJgGakki_Destroy(Actor* thisx, GlobalContext* globalCtx) { +void ObjJgGakki_Destroy(Actor* thisx, PlayState* play) { ObjJgGakki* this = THIS; - Collider_DestroyCylinder(globalCtx, &this->collider); + Collider_DestroyCylinder(play, &this->collider); } -void ObjJgGakki_Update(Actor* thisx, GlobalContext* globalCtx) { +void ObjJgGakki_Update(Actor* thisx, PlayState* play) { ObjJgGakki* this = THIS; SkelAnime_Update(&this->skelAnime); } -void ObjJgGakki_Draw(Actor* thisx, GlobalContext* globalCtx) { +void ObjJgGakki_Draw(Actor* thisx, PlayState* play) { ObjJgGakki* this = THIS; - SkelAnime_DrawOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, NULL, NULL, &this->actor); + SkelAnime_DrawOpa(play, this->skelAnime.skeleton, this->skelAnime.jointTable, NULL, NULL, &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 68e7717c1..21b764593 100644 --- a/src/overlays/actors/ovl_Obj_Jgame_Light/z_obj_jgame_light.c +++ b/src/overlays/actors/ovl_Obj_Jgame_Light/z_obj_jgame_light.c @@ -5,17 +5,28 @@ */ #include "z_obj_jgame_light.h" +#include "objects/gameplay_keep/gameplay_keep.h" +#include "objects/object_syokudai/object_syokudai.h" #define FLAGS (ACTOR_FLAG_10) #define THIS ((ObjJgameLight*)thisx) -void ObjJgameLight_Init(Actor* thisx, GlobalContext* globalCtx); -void ObjJgameLight_Destroy(Actor* thisx, GlobalContext* globalCtx); -void ObjJgameLight_Update(Actor* thisx, GlobalContext* globalCtx); -void ObjJgameLight_Draw(Actor* thisx, GlobalContext* globalCtx); +typedef enum { + /* 0x0 */ OBJJGAMELIGHT_NONE, + /* 0x1 */ OBJJGAMELIGHT_CORRECT, + /* 0x2 */ OBJJGAMELIGHT_INCORRECT, +} ObjJgameLightSignal; + +void ObjJgameLight_Init(Actor* thisx, PlayState* play); +void ObjJgameLight_Destroy(Actor* thisx, PlayState* play); +void ObjJgameLight_Update(Actor* thisx, PlayState* play); +void ObjJgameLight_Draw(Actor* thisx, PlayState* play); + +void func_80C15474(ObjJgameLight* this, PlayState* play); +void ObjJgameLight_UpdateCollision(ObjJgameLight* this, PlayState* play); +void func_80C15718(ObjJgameLight* this, PlayState* play); -#if 0 const ActorInit Obj_Jgame_Light_InitVars = { ACTOR_OBJ_JGAME_LIGHT, ACTORCAT_PROP, @@ -28,29 +39,172 @@ const ActorInit Obj_Jgame_Light_InitVars = { (ActorFunc)ObjJgameLight_Draw, }; -// static ColliderCylinderInit sCylinderInit = { -static ColliderCylinderInit D_80C15BC0 = { - { COLTYPE_METAL, AT_NONE, AC_ON | AC_HARD | AC_TYPE_PLAYER, OC1_ON | OC1_TYPE_ALL, OC2_TYPE_2, COLSHAPE_CYLINDER, }, - { ELEMTYPE_UNK2, { 0x00100000, 0x00, 0x00 }, { 0xF6CFFFFF, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_ON | BUMP_HOOKABLE, OCELEM_ON, }, +static ColliderCylinderInit sCylinderInit = { + { + COLTYPE_METAL, + AT_NONE, + AC_ON | AC_HARD | AC_TYPE_PLAYER, + OC1_ON | OC1_TYPE_ALL, + OC2_TYPE_2, + COLSHAPE_CYLINDER, + }, + { + ELEMTYPE_UNK2, + { 0x00100000, 0x00, 0x00 }, + { 0xF6CFFFFF, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_ON | BUMP_HOOKABLE, + OCELEM_ON, + }, { 12, 45, 0, { 0, 0, 0 } }, }; -#endif +#include "assets/overlays/ovl_Obj_Jgame_Light/ovl_Obj_Jgame_Light.c" -extern ColliderCylinderInit D_80C15BC0; +void ObjJgameLight_Init(Actor* thisx, PlayState* play) { + ObjJgameLight* this = THIS; + LightInfo* lights = &this->lightInfo; -extern UNK_TYPE D_060003A0; + Actor_SetScale(&this->actor, 1.0f); + func_800B4AEC(play, &this->actor, 50.0f); + ActorShape_Init(&this->actor.shape, 0.0f, func_800B4B50, 1.0f); + Collider_InitCylinder(play, &this->collider); + Collider_SetCylinder(play, &this->collider, &this->actor, &sCylinderInit); + Lights_PointGlowSetInfo(lights, this->actor.world.pos.x, (this->actor.world.pos.y + 70.0f), this->actor.world.pos.z, + 255, 255, 180, -1); + this->lightNode = LightContext_InsertLight(play, &play->lightCtx, &this->lightInfo); + Actor_SetFocus(&this->actor, 60.0f); + this->actor.colChkInfo.health = 0; + this->prevHealth = 0; + this->isOn = false; + this->lightRadius = 0; + this->alpha = 0; + this->signal = OBJJGAMELIGHT_NONE; + this->flameScaleProportion = 0.0f; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Jgame_Light/ObjJgameLight_Init.s") +void ObjJgameLight_Destroy(Actor* thisx, PlayState* play) { + ObjJgameLight* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Jgame_Light/ObjJgameLight_Destroy.s") + Collider_DestroyCylinder(play, &this->collider); + LightContext_RemoveLight(play, &play->lightCtx, this->lightNode); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Jgame_Light/func_80C15474.s") +void func_80C15474(ObjJgameLight* this, PlayState* play) { + u8 temp_a1; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Jgame_Light/func_80C156C4.s") + if ((this->actor.colChkInfo.health & OBJLUPYGAMELIFT_IGNITE_FIRE) && (this->isOn == false)) { + if (this->lightRadius < 160) { + this->lightRadius += 40; + } else { + this->lightRadius = 200; + this->isOn = true; + } + if (this->flameScaleProportion < 0.7f) { + this->flameScaleProportion += 0.3f; + } else { + this->flameScaleProportion = 1.0f; + } + } else if (this->actor.colChkInfo.health & OBJLUPYGAMELIFT_SNUFF_FIRE) { + if (this->lightRadius > 40) { + this->lightRadius -= 40; + } else { + this->lightRadius = -1; + if (this->flameScaleProportion == 0.0f) { + this->isOn = false; + this->actor.colChkInfo.health &= ~OBJLUPYGAMELIFT_IGNITE_FIRE; + this->actor.colChkInfo.health &= ~OBJLUPYGAMELIFT_SNUFF_FIRE; + } + } + if (this->flameScaleProportion > 0.3f) { + this->flameScaleProportion -= 0.3f; + } else { + this->flameScaleProportion = 0.0f; + } + } + if (this->flameScaleProportion > 0.1f) { + func_800B9010(&this->actor, NA_SE_EV_TORCH - SFX_FLAG); + } + temp_a1 = (s32)(Rand_ZeroOne() * 127.0f) + 128; + Lights_PointSetColorAndRadius(&this->lightInfo, temp_a1, temp_a1 * 0.7f, 0, this->lightRadius); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Jgame_Light/func_80C15718.s") +void ObjJgameLight_UpdateCollision(ObjJgameLight* this, PlayState* play) { + Collider_UpdateCylinder(&this->actor, &this->collider); + CollisionCheck_SetOC(play, &play->colChkCtx, &this->collider.base); + CollisionCheck_SetAC(play, &play->colChkCtx, &this->collider.base); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Jgame_Light/ObjJgameLight_Update.s") +void func_80C15718(ObjJgameLight* this, PlayState* play) { + if ((this->actor.colChkInfo.health & OBJLUPYGAMELIFT_IGNITE_FIRE) && + !(this->prevHealth & OBJLUPYGAMELIFT_IGNITE_FIRE)) { + Audio_PlaySfxAtPos(&this->actor.projectedPos, NA_SE_EV_FLAME_IGNITION); + this->prevHealth = this->actor.colChkInfo.health; + } + if (this->actor.colChkInfo.health & OBJLUPYGAMELIFT_DISPLAY_CORRECT) { + this->actor.colChkInfo.health &= ~OBJLUPYGAMELIFT_DISPLAY_CORRECT; + this->alpha = 300; + this->signal = OBJJGAMELIGHT_CORRECT; + } else if (this->actor.colChkInfo.health & OBJLUPYGAMELIFT_DISPLAY_INCORRECT) { + this->actor.colChkInfo.health &= ~OBJLUPYGAMELIFT_DISPLAY_INCORRECT; + this->alpha = 300; + this->signal = OBJJGAMELIGHT_INCORRECT; + } + if (this->alpha > 15) { + this->alpha -= 15; + } else { + this->alpha = 0; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Jgame_Light/ObjJgameLight_Draw.s") +void ObjJgameLight_Update(Actor* thisx, PlayState* play) { + ObjJgameLight* this = THIS; + + func_80C15718(this, play); + func_80C15474(this, play); + ObjJgameLight_UpdateCollision(this, play); + this->flameScroll++; +} + +void ObjJgameLight_Draw(Actor* thisx, PlayState* play) { + s32 pad; + ObjJgameLight* this = THIS; + + OPEN_DISPS(play->state.gfxCtx); + + func_8012C28C(play->state.gfxCtx); + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_OPA_DISP++, &gObjectSyokudaiTypeSwitchCausesFlameDL); + if (this->alpha > 0) { + func_8012C2DC(play->state.gfxCtx); + if (this->alpha > 255) { + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 210, 64, 32, 255); + } else { + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 210, 64, 32, this->alpha); + } + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + if (this->signal == OBJJGAMELIGHT_CORRECT) { + gSPDisplayList(POLY_XLU_DISP++, gObjJgameLightCorrectDL); + } else if (this->signal == OBJJGAMELIGHT_INCORRECT) { + gSPDisplayList(POLY_XLU_DISP++, gObjJgameLightIncorrectDL); + } + } + if (this->flameScaleProportion != 0.0f) { + f32 scale; + + func_8012C2DC(play->state.gfxCtx); + scale = (this->flameScaleProportion * 27.0f) / 10000.0f; + gSPSegment(POLY_XLU_DISP++, 0x08, + Gfx_TwoTexScroll(play->state.gfxCtx, 0, 0, 0, 0x20, 0x40, 1, 0, (this->flameScroll * -20) & 0x1FF, + 0x20, 0x80)); + gDPSetPrimColor(POLY_XLU_DISP++, 0x80, 0x80, 255, 255, 0, 255); + gDPSetEnvColor(POLY_XLU_DISP++, 255, 0, 0, 0); + Matrix_Translate(0.0f, 52.0f, 0.0f, MTXMODE_APPLY); + Matrix_RotateYS(((Camera_GetCamDirYaw(GET_ACTIVE_CAM(play)) - this->actor.shape.rot.y) + 0x8000), + MTXMODE_APPLY); + Matrix_Scale(scale, scale, scale, MTXMODE_APPLY); + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_XLU_DISP++, gEffFire1DL); + } + CLOSE_DISPS(play->state.gfxCtx); +} diff --git a/src/overlays/actors/ovl_Obj_Jgame_Light/z_obj_jgame_light.h b/src/overlays/actors/ovl_Obj_Jgame_Light/z_obj_jgame_light.h index 50023c252..a81bbf3cc 100644 --- a/src/overlays/actors/ovl_Obj_Jgame_Light/z_obj_jgame_light.h +++ b/src/overlays/actors/ovl_Obj_Jgame_Light/z_obj_jgame_light.h @@ -6,10 +6,25 @@ struct ObjJgameLight; #define OBJJGAMELIGHT_GET_7F(thisx) ((thisx)->params & 0x7F) +#define OBJLUPYGAMELIFT_IGNITE_FIRE (1 << 0) +#define OBJLUPYGAMELIFT_DISPLAY_CORRECT (1 << 1) +#define OBJLUPYGAMELIFT_DISPLAY_INCORRECT (1 << 2) +#define OBJLUPYGAMELIFT_SNUFF_FIRE (1 << 3) typedef struct ObjJgameLight { /* 0x000 */ Actor actor; - /* 0x144 */ char unk_144[0x78]; + /* 0x144 */ ColliderCylinder collider; + /* 0x190 */ UNK_TYPE1 pad_190[4]; + /* 0x194 */ LightNode* lightNode; + /* 0x198 */ LightInfo lightInfo; + /* 0x1A8 */ f32 flameScaleProportion; + /* 0x1AC */ s16 lightRadius; + /* 0x1AE */ s16 flameScroll; + /* 0x1B0 */ UNK_TYPE1 pad_1B0[2]; + /* 0x1B2 */ s16 alpha; + /* 0x1B4 */ s16 signal; + /* 0x1B6 */ s16 isOn; + /* 0x1B8 */ u8 prevHealth; } ObjJgameLight; // size = 0x1BC extern const ActorInit Obj_Jgame_Light_InitVars; diff --git a/src/overlays/actors/ovl_Obj_Kendo_Kanban/z_obj_kendo_kanban.c b/src/overlays/actors/ovl_Obj_Kendo_Kanban/z_obj_kendo_kanban.c index 6cf8e0751..bc1d353fd 100644 --- a/src/overlays/actors/ovl_Obj_Kendo_Kanban/z_obj_kendo_kanban.c +++ b/src/overlays/actors/ovl_Obj_Kendo_Kanban/z_obj_kendo_kanban.c @@ -11,18 +11,18 @@ #define THIS ((ObjKendoKanban*)thisx) -void ObjKendoKanban_Init(Actor* thisx, GlobalContext* globalCtx); -void ObjKendoKanban_Destroy(Actor* thisx, GlobalContext* globalCtx); -void ObjKendoKanban_Update(Actor* thisx, GlobalContext* globalCtx); -void ObjKendoKanban_Draw(Actor* thisx, GlobalContext* globalCtx); +void ObjKendoKanban_Init(Actor* thisx, PlayState* play); +void ObjKendoKanban_Destroy(Actor* thisx, PlayState* play); +void ObjKendoKanban_Update(Actor* thisx, PlayState* play); +void ObjKendoKanban_Draw(Actor* thisx, PlayState* play); 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); +void func_80B65894(ObjKendoKanban* this, PlayState* play); +void func_80B658A4(ObjKendoKanban* this, PlayState* play); +void func_80B65CE0(ObjKendoKanban* this, PlayState* play); +void func_80B65D68(ObjKendoKanban* this, PlayState* play); +void func_80B65DA8(ObjKendoKanban* this, PlayState* play); +s32 func_80B6618C(ObjKendoKanban* this, PlayState* play); const ActorInit Obj_Kendo_Kanban_InitVars = { ACTOR_OBJ_KENDO_KANBAN, @@ -45,10 +45,10 @@ Vec3f D_80B6669C = { 150.0f, 425.0f, 40.0f }; Vec3f D_80B666A8 = { 0.0f, 140.0f, 40.0f }; Vec3f D_80B666B4 = { 0.0f, 565.0f, 40.0f }; -Gfx* D_80B666C0 = object_dora_DL_002080; -Gfx* D_80B666C4 = object_dora_DL_002180; -Gfx* D_80B666C8 = object_dora_DL_002380; -Gfx* D_80B666CC = object_dora_DL_002280; +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 }; @@ -94,7 +94,7 @@ static ColliderTrisInit sTrisInit = { OC2_TYPE_1, COLSHAPE_TRIS, }, - 2, + ARRAY_COUNT(sTrisElementsInit), sTrisElementsInit, }; @@ -158,7 +158,7 @@ static CollisionCheckInfoInit2 sColChkInfoInit = { 8, 0, 0, 0, MASS_HEAVY }; Vec3f D_80B6681C = { 0.0f, 0.0f, 0.0f }; Vec3f D_80B66828 = { 1.0f, 0.0f, 0.0f }; -void ObjKendoKanban_Init(Actor* thisx, GlobalContext* globalCtx) { +void ObjKendoKanban_Init(Actor* thisx, PlayState* play) { s32 pad[2]; ObjKendoKanban* this = THIS; Vec3f sp70[3]; @@ -167,24 +167,24 @@ void ObjKendoKanban_Init(Actor* thisx, GlobalContext* globalCtx) { Actor_SetScale(&this->actor, 0.1f); - Collider_InitCylinder(globalCtx, &this->colliderCylinder); - Collider_SetCylinder(globalCtx, &this->colliderCylinder, &this->actor, &sCylinderInit); + Collider_InitCylinder(play, &this->colliderCylinder); + Collider_SetCylinder(play, &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); + Collider_InitTris(play, &this->colliderTris); + Collider_SetTris(play, &this->colliderTris, &this->actor, &sTrisInit, this->colliderTrisElements); - 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); for (i = 0; i < ARRAY_COUNT(this->colliderTrisElements); i++) { for (j = 0; j < ARRAY_COUNT(sp70); j++) { - Matrix_MultiplyVector3fByState(&sTrisElementsInit[i].dim.vtx[j], &sp70[j]); + Matrix_MultVec3f(&sTrisElementsInit[i].dim.vtx[j], &sp70[j]); } Collider_SetTrisVertices(&this->colliderTris, i, &sp70[0], &sp70[1], &sp70[2]); } - Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 0.0f, 0.0f, 0.0f, 4); + Actor_UpdateBgCheckInfo(play, &this->actor, 0.0f, 0.0f, 0.0f, 4); this->unk_30C = OBJKENDOKANBAN_GET_F(&this->actor); this->actor.gravity = -2.0f; @@ -206,35 +206,37 @@ void ObjKendoKanban_Init(Actor* thisx, GlobalContext* globalCtx) { if (this->unk_30C == OBJKENDOKANBAN_F_0) { func_80B65880(this); } else { - func_80B658A4(this, globalCtx); + func_80B658A4(this, play); } } -void ObjKendoKanban_Destroy(Actor* thisx, GlobalContext* globalCtx) { +void ObjKendoKanban_Destroy(Actor* thisx, PlayState* play) { ObjKendoKanban* this = THIS; - Collider_DestroyCylinder(globalCtx, &this->colliderCylinder); - Collider_DestroyTris(globalCtx, &this->colliderTris); + Collider_DestroyCylinder(play, &this->colliderCylinder); + Collider_DestroyTris(play, &this->colliderTris); } void func_80B65880(ObjKendoKanban* this) { this->actionFunc = func_80B65894; } -void func_80B65894(ObjKendoKanban* this, GlobalContext* globalCtx) { +void func_80B65894(ObjKendoKanban* this, PlayState* play) { } -void func_80B658A4(ObjKendoKanban* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); +void func_80B658A4(ObjKendoKanban* this, PlayState* play) { + Player* player = GET_PLAYER(play); if (this->unk_30C == OBJKENDOKANBAN_F_0) { - if ((player->swordAnimation == 0) || (player->swordAnimation == 1) || (player->swordAnimation == 0x14)) { + if ((player->meleeWeaponAnimation == PLAYER_MWA_FORWARD_SLASH_1H) || + (player->meleeWeaponAnimation == PLAYER_MWA_FORWARD_SLASH_2H) || + (player->meleeWeaponAnimation == PLAYER_MWA_JUMPSLASH_FINISH)) { this->unk_30C = (OBJKENDOKANBAN_F_4 | OBJKENDOKANBAN_F_1); this->unk_304 = 0x71C; this->actor.velocity = D_80B6666C; this->unk_2CC = D_80B6669C; - Actor_SpawnAsChild(&globalCtx->actorCtx, &this->actor, globalCtx, ACTOR_OBJ_KENDO_KANBAN, + Actor_SpawnAsChild(&play->actorCtx, &this->actor, play, 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); @@ -248,9 +250,8 @@ void func_80B658A4(ObjKendoKanban* this, GlobalContext* globalCtx) { 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); + Actor_SpawnAsChild(&play->actorCtx, &this->actor, play, 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; @@ -281,11 +282,11 @@ void func_80B658A4(ObjKendoKanban* this, GlobalContext* globalCtx) { this->actionFunc = func_80B65CE0; } -void func_80B65CE0(ObjKendoKanban* this, GlobalContext* globalCtx) { +void func_80B65CE0(ObjKendoKanban* this, PlayState* play) { this->actor.velocity.y += this->actor.gravity; Actor_UpdatePos(&this->actor); this->unk_302 += this->unk_304; - func_80B65DA8(this, globalCtx); + func_80B65DA8(this, play); if (this->actor.world.pos.y < -200.0f) { this->actor.world.pos.y = -200.0f; } @@ -295,15 +296,15 @@ void func_80B65D54(ObjKendoKanban* this) { this->actionFunc = func_80B65D68; } -void func_80B65D68(ObjKendoKanban* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); +void func_80B65D68(ObjKendoKanban* this, PlayState* play) { + Player* player = GET_PLAYER(play); - if (func_80B6618C(this, globalCtx) == 1) { + if (func_80B6618C(this, play) == 1) { player->unk_AC0 = 700.0f; } } -void func_80B65DA8(ObjKendoKanban* this, GlobalContext* globalCtx) { +void func_80B65DA8(ObjKendoKanban* this, PlayState* play) { Vec3f sp5C; s32 pad[2]; Vec3f sp48; @@ -339,17 +340,17 @@ void func_80B65DA8(ObjKendoKanban* this, GlobalContext* globalCtx) { this->unk_2FC = index; this->unk_2E4 = this->unk_29C[index]; - Matrix_StatePush(); - Matrix_SetStateRotationAndTranslation(this->actor.world.pos.x, this->actor.world.pos.y, this->actor.world.pos.z, - &this->actor.shape.rot); + Matrix_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_MultiplyVector3fByState(&this->unk_2E4, &this->actor.world.pos); + Matrix_MultVec3f(&this->unk_2E4, &this->actor.world.pos); this->actor.world.pos = sp5C; this->actor.prevPos = this->actor.world.pos; - Matrix_StatePop(); + Matrix_Pop(); } - Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 0.0f, 0.0f, 0.0f, 4); + Actor_UpdateBgCheckInfo(play, &this->actor, 0.0f, 0.0f, 0.0f, 4); if (this->actor.bgCheckFlags & 1) { this->actor.velocity.x *= 0.8f; @@ -395,8 +396,8 @@ void func_80B65DA8(ObjKendoKanban* this, GlobalContext* globalCtx) { } } -s32 func_80B6618C(ObjKendoKanban* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); +s32 func_80B6618C(ObjKendoKanban* this, PlayState* play) { + Player* player = GET_PLAYER(play); s32 phi_v0; s32 phi_v1 = 0; s32 i; @@ -433,11 +434,11 @@ s32 func_80B6618C(ObjKendoKanban* this, GlobalContext* globalCtx) { return true; } -void func_80B66304(ObjKendoKanban* this, GlobalContext* globalCtx) { +void func_80B66304(ObjKendoKanban* this, PlayState* play) { 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); + func_80B658A4(this, play); } Collider_UpdateCylinder(&this->actor, &this->colliderCylinder); @@ -445,39 +446,39 @@ void func_80B66304(ObjKendoKanban* this, GlobalContext* globalCtx) { 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_SetAC(play, &play->colChkCtx, &this->colliderTris.base); } - CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->colliderCylinder.base); + CollisionCheck_SetOC(play, &play->colChkCtx, &this->colliderCylinder.base); } } -void ObjKendoKanban_Update(Actor* thisx, GlobalContext* globalCtx) { +void ObjKendoKanban_Update(Actor* thisx, PlayState* play) { ObjKendoKanban* this = THIS; - this->actionFunc(this, globalCtx); + this->actionFunc(this, play); - func_80B66304(this, globalCtx); + func_80B66304(this, play); } #ifdef NON_MATCHING -void ObjKendoKanban_Draw(Actor* thisx, GlobalContext* globalCtx) { +void ObjKendoKanban_Draw(Actor* thisx, PlayState* play) { ObjKendoKanban* this = THIS; s32 i; Gfx* poly; - OPEN_DISPS(globalCtx->state.gfxCtx); + OPEN_DISPS(play->state.gfxCtx); - func_8012C28C(globalCtx->state.gfxCtx); + func_8012C28C(play->state.gfxCtx); if (this->unk_30C == OBJKENDOKANBAN_F_0) { - gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - gSPDisplayList(POLY_OPA_DISP++, object_dora_DL_000180); + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_OPA_DISP++, gKendoKanbanDL); } else { - Matrix_InsertRotationAroundUnitVector_s(this->unk_302, &this->unk_2F0, MTXMODE_APPLY); - Matrix_InsertTranslation(-this->unk_2E4.x, -this->unk_2E4.y, -this->unk_2E4.z, MTXMODE_APPLY); + 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); + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); if (this->unk_30C & OBJKENDOKANBAN_F_1) { gSPDisplayList(POLY_OPA_DISP++, D_80B666C0); @@ -496,13 +497,13 @@ void ObjKendoKanban_Draw(Actor* thisx, GlobalContext* globalCtx) { } } - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->state.gfxCtx); for (i = 0; i < ARRAY_COUNT(this->unk_26C); i++) { - Matrix_MultiplyVector3fByState(&this->unk_29C[i], &this->unk_26C[i]); + Matrix_MultVec3f(&this->unk_29C[i], &this->unk_26C[i]); } - Matrix_MultiplyVector3fByState(&this->unk_2CC, &this->unk_2D8); + Matrix_MultVec3f(&this->unk_2CC, &this->unk_2D8); } #else #pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Kendo_Kanban/ObjKendoKanban_Draw.s") 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 a8c4f8d7c..8526f4976 100644 --- a/src/overlays/actors/ovl_Obj_Kendo_Kanban/z_obj_kendo_kanban.h +++ b/src/overlays/actors/ovl_Obj_Kendo_Kanban/z_obj_kendo_kanban.h @@ -5,7 +5,7 @@ struct ObjKendoKanban; -typedef void (*ObjKendoKanbanActionFunc)(struct ObjKendoKanban*, GlobalContext*); +typedef void (*ObjKendoKanbanActionFunc)(struct ObjKendoKanban*, PlayState*); #define OBJKENDOKANBAN_GET_F(thisx) ((thisx)->params & 0xF) @@ -16,25 +16,25 @@ typedef void (*ObjKendoKanbanActionFunc)(struct ObjKendoKanban*, GlobalContext*) #define OBJKENDOKANBAN_F_8 (1 << 3) typedef struct ObjKendoKanban { - /* 0x0000 */ Actor actor; - /* 0x0144 */ ColliderCylinder colliderCylinder; - /* 0x0190 */ ColliderTris colliderTris; - /* 0x01B0 */ ColliderTrisElement colliderTrisElements[2]; - /* 0x0268 */ ObjKendoKanbanActionFunc actionFunc; - /* 0x026C */ Vec3f unk_26C[4]; - /* 0x029C */ Vec3f unk_29C[4]; - /* 0x02CC */ Vec3f unk_2CC; - /* 0x02D8 */ Vec3f unk_2D8; - /* 0x02E4 */ Vec3f unk_2E4; - /* 0x02F0 */ Vec3f unk_2F0; - /* 0x02FC */ s32 unk_2FC; - /* 0x0300 */ s16 unk_300; - /* 0x0302 */ s16 unk_302; - /* 0x0304 */ s16 unk_304; - /* 0x0306 */ UNK_TYPE1 pad306[2]; - /* 0x0308 */ s16 unk_308; - /* 0x030A */ s16 unk_30A; - /* 0x030C */ u8 unk_30C; + /* 0x000 */ Actor actor; + /* 0x144 */ ColliderCylinder colliderCylinder; + /* 0x190 */ ColliderTris colliderTris; + /* 0x1B0 */ ColliderTrisElement colliderTrisElements[2]; + /* 0x268 */ ObjKendoKanbanActionFunc actionFunc; + /* 0x26C */ Vec3f unk_26C[4]; + /* 0x29C */ Vec3f unk_29C[4]; + /* 0x2CC */ Vec3f unk_2CC; + /* 0x2D8 */ Vec3f unk_2D8; + /* 0x2E4 */ Vec3f unk_2E4; + /* 0x2F0 */ Vec3f unk_2F0; + /* 0x2FC */ s32 unk_2FC; + /* 0x300 */ s16 unk_300; + /* 0x302 */ s16 unk_302; + /* 0x304 */ s16 unk_304; + /* 0x306 */ UNK_TYPE1 pad306[2]; + /* 0x308 */ s16 unk_308; + /* 0x30A */ s16 unk_30A; + /* 0x30C */ u8 unk_30C; } ObjKendoKanban; // size = 0x310 extern const ActorInit Obj_Kendo_Kanban_InitVars; diff --git a/src/overlays/actors/ovl_Obj_Kepn_Koya/z_obj_kepn_koya.c b/src/overlays/actors/ovl_Obj_Kepn_Koya/z_obj_kepn_koya.c index 4f8bc1d3a..28c10781d 100644 --- a/src/overlays/actors/ovl_Obj_Kepn_Koya/z_obj_kepn_koya.c +++ b/src/overlays/actors/ovl_Obj_Kepn_Koya/z_obj_kepn_koya.c @@ -11,10 +11,10 @@ #define THIS ((ObjKepnKoya*)thisx) -void ObjKepnKoya_Init(Actor* thisx, GlobalContext* globalCtx); -void ObjKepnKoya_Destroy(Actor* thisx, GlobalContext* globalCtx); -void ObjKepnKoya_Update(Actor* thisx, GlobalContext* globalCtx); -void ObjKepnKoya_Draw(Actor* thisx, GlobalContext* globalCtx); +void ObjKepnKoya_Init(Actor* thisx, PlayState* play); +void ObjKepnKoya_Destroy(Actor* thisx, PlayState* play); +void ObjKepnKoya_Update(Actor* thisx, PlayState* play); +void ObjKepnKoya_Draw(Actor* thisx, PlayState* play); const ActorInit Obj_Kepn_Koya_InitVars = { ACTOR_OBJ_KEPN_KOYA, @@ -33,27 +33,27 @@ static InitChainEntry sInitChain[] = { ICHAIN_F32(uncullZoneDownward, 900, ICHAIN_STOP), }; -void ObjKepnKoya_Init(Actor* thisx, GlobalContext* globalCtx) { +void ObjKepnKoya_Init(Actor* thisx, PlayState* play) { ObjKepnKoya* this = THIS; Actor_ProcessInitChain(&this->dyna.actor, sInitChain); Actor_SetScale(&this->dyna.actor, 0.1f); DynaPolyActor_Init(&this->dyna, 0); - DynaPolyActor_LoadMesh(globalCtx, &this->dyna, &object_kepn_koya_Colheader_00805C); + DynaPolyActor_LoadMesh(play, &this->dyna, &object_kepn_koya_Colheader_00805C); if (this->dyna.bgId == BG_ACTOR_MAX) { Actor_MarkForDeath(&this->dyna.actor); } } -void ObjKepnKoya_Destroy(Actor* thisx, GlobalContext* globalCtx) { +void ObjKepnKoya_Destroy(Actor* thisx, PlayState* play) { ObjKepnKoya* this = THIS; - DynaPoly_DeleteBgActor(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); + DynaPoly_DeleteBgActor(play, &play->colCtx.dyna, this->dyna.bgId); } -void ObjKepnKoya_Update(Actor* thisx, GlobalContext* globalCtx) { +void ObjKepnKoya_Update(Actor* thisx, PlayState* play) { } -void ObjKepnKoya_Draw(Actor* thisx, GlobalContext* globalCtx) { - Gfx_DrawDListOpa(globalCtx, object_kepn_koya_DL_003478); +void ObjKepnKoya_Draw(Actor* thisx, PlayState* play) { + Gfx_DrawDListOpa(play, object_kepn_koya_DL_003478); } 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 979848c3b..6f98958b1 100644 --- a/src/overlays/actors/ovl_Obj_Kibako/z_obj_kibako.c +++ b/src/overlays/actors/ovl_Obj_Kibako/z_obj_kibako.c @@ -12,24 +12,24 @@ #define THIS ((ObjKibako*)thisx) -void ObjKibako_Init(Actor* thisx, GlobalContext* globalCtx); -void ObjKibako_Destroy(Actor* thisx, GlobalContext* globalCtx); -void ObjKibako_Update(Actor* thisx, GlobalContext* globalCtx); +void ObjKibako_Init(Actor* thisx, PlayState* play); +void ObjKibako_Destroy(Actor* thisx, PlayState* play); +void ObjKibako_Update(Actor* thisx, PlayState* play); -void ObjKibako_Draw(Actor* thisx, GlobalContext* globalCtx); -void ObjKibako_SpawnCollectible(ObjKibako* this, GlobalContext* globalCtx); +void ObjKibako_Draw(Actor* thisx, PlayState* play); +void ObjKibako_SpawnCollectible(ObjKibako* this, PlayState* play); void func_809262BC(ObjKibako* this); -void func_80926318(ObjKibako* this, GlobalContext* globalCtx); -void ObjKibako_AirBreak(ObjKibako* this, GlobalContext* globalCtx); -void ObjKibako_WaterBreak(ObjKibako* this, GlobalContext* globalCtx); +void func_80926318(ObjKibako* this, PlayState* play); +void ObjKibako_AirBreak(ObjKibako* this, PlayState* play); +void ObjKibako_WaterBreak(ObjKibako* this, PlayState* play); void func_80926B40(ObjKibako* this); -void func_80926B54(ObjKibako* this, GlobalContext* globalCtx); +void func_80926B54(ObjKibako* this, PlayState* play); void ObjKibako_SetupIdle(ObjKibako* this); -void ObjKibako_Idle(ObjKibako* this, GlobalContext* globalCtx); +void ObjKibako_Idle(ObjKibako* this, PlayState* play); void ObjKibako_SetupHeld(ObjKibako* this); -void ObjKibako_Held(ObjKibako* this, GlobalContext* globalCtx); +void ObjKibako_Held(ObjKibako* this, PlayState* play); void ObjKibako_SetupThrown(ObjKibako* this); -void ObjKibako_Thrown(ObjKibako* this, GlobalContext* globalCtx); +void ObjKibako_Thrown(ObjKibako* this, PlayState* play); static s16 D_80927380 = 0; static s16 D_80927384 = 0; @@ -81,13 +81,13 @@ static InitChainEntry sInitChain[] = { ICHAIN_F32(uncullZoneDownward, 60, ICHAIN_STOP), }; -void ObjKibako_SpawnCollectible(ObjKibako* this, GlobalContext* globalCtx) { +void ObjKibako_SpawnCollectible(ObjKibako* this, PlayState* play) { s32 dropItem00Id; if (this->isDropCollected == 0) { dropItem00Id = func_800A8150(KIBAKO_COLLECTIBLE_ID(&this->actor)); if (dropItem00Id > ITEM00_NO_DROP) { - Item_DropCollectible(globalCtx, &this->actor.world.pos, + Item_DropCollectible(play, &this->actor.world.pos, dropItem00Id | KIBAKO_COLLECTIBLE_FLAG(&this->actor) << 8); this->isDropCollected = 1; } @@ -114,26 +114,26 @@ void func_809262BC(ObjKibako* this) { } } -void func_80926318(ObjKibako* this, GlobalContext* globalCtx) { +void func_80926318(ObjKibako* this, PlayState* play) { s16 angle; s32 pad; if (this->actor.xzDistToPlayer < 100.0f) { - angle = this->actor.yawTowardsPlayer - GET_PLAYER(globalCtx)->actor.world.rot.y; + angle = this->actor.yawTowardsPlayer - GET_PLAYER(play)->actor.world.rot.y; if (ABS_ALT(angle) > 0x5555) { - Actor_PickUp(&this->actor, globalCtx, GI_NONE, 36.0f, 30.0f); + Actor_PickUp(&this->actor, play, GI_NONE, 36.0f, 30.0f); } } } -void func_80926394(ObjKibako* this, GlobalContext* globalCtx) { - if ((this->isDropCollected == 0) && (globalCtx->roomCtx.currRoom.num != this->unk199)) { +void func_80926394(ObjKibako* this, PlayState* play) { + if ((this->isDropCollected == 0) && (play->roomCtx.currRoom.num != this->unk199)) { this->isDropCollected = 1; } } -void ObjKibako_Init(Actor* thisx, GlobalContext* globalCtx2) { - GlobalContext* globalCtx = globalCtx2; +void ObjKibako_Init(Actor* thisx, PlayState* play2) { + PlayState* play = play2; ObjKibako* this = THIS; s32 whichBankIndex; @@ -145,11 +145,11 @@ void ObjKibako_Init(Actor* thisx, GlobalContext* globalCtx2) { } else { this->actor.uncullZoneForward = 800.0f; } - Collider_InitCylinder(globalCtx, &this->collider); - Collider_SetCylinder(globalCtx, &this->collider, &this->actor, &sCylinderInit); + Collider_InitCylinder(play, &this->collider); + Collider_SetCylinder(play, &this->collider, &this->actor, &sCylinderInit); Collider_UpdateCylinder(&this->actor, &this->collider); this->actor.colChkInfo.mass = MASS_IMMOVABLE; - this->bankIndex = Object_GetIndex(&globalCtx->objectCtx, sObjectIdList[whichBankIndex]); + this->bankIndex = Object_GetIndex(&play->objectCtx, sObjectIdList[whichBankIndex]); if (this->bankIndex < 0) { Actor_MarkForDeath(&this->actor); return; @@ -158,14 +158,14 @@ void ObjKibako_Init(Actor* thisx, GlobalContext* globalCtx2) { func_80926B40(this); } -void ObjKibako_Destroy(Actor* thisx, GlobalContext* globalCtx2) { - GlobalContext* globalCtx = globalCtx2; +void ObjKibako_Destroy(Actor* thisx, PlayState* play2) { + PlayState* play = play2; ObjKibako* this = THIS; - Collider_DestroyCylinder(globalCtx, &this->collider); + Collider_DestroyCylinder(play, &this->collider); } -void ObjKibako_AirBreak(ObjKibako* this, GlobalContext* globalCtx) { +void ObjKibako_AirBreak(ObjKibako* this, PlayState* play) { s16 angle; s32 i; Vec3f* worldPos = &this->actor.world.pos; @@ -196,16 +196,16 @@ void ObjKibako_AirBreak(ObjKibako* this, GlobalContext* globalCtx) { phi_s0 = 0x20; } - EffectSsKakera_Spawn( - globalCtx, &pos, &velocity, worldPos, -200, phi_s0, 20, 0, 0, (Rand_ZeroOne() * 38.0f) + 10.0f, 0, 0, 60, - -1, sObjectIdList[KIBAKO_BANK_INDEX(&this->actor)], sKakeraDisplayLists[KIBAKO_BANK_INDEX(&this->actor)]); + EffectSsKakera_Spawn(play, &pos, &velocity, worldPos, -200, phi_s0, 20, 0, 0, (Rand_ZeroOne() * 38.0f) + 10.0f, + 0, 0, 60, -1, sObjectIdList[KIBAKO_BANK_INDEX(&this->actor)], + sKakeraDisplayLists[KIBAKO_BANK_INDEX(&this->actor)]); } - func_800BBFB0(globalCtx, worldPos, 40.0f, 3, 0x32, 0x8C, 1); - func_800BBFB0(globalCtx, worldPos, 40.0f, 2, 0x14, 0x50, 1); + func_800BBFB0(play, worldPos, 40.0f, 3, 0x32, 0x8C, 1); + func_800BBFB0(play, worldPos, 40.0f, 2, 0x14, 0x50, 1); } -void ObjKibako_WaterBreak(ObjKibako* this, GlobalContext* globalCtx) { +void ObjKibako_WaterBreak(ObjKibako* this, PlayState* play) { s16 angle; s32 i; Vec3f* worldPos = &this->actor.world.pos; @@ -216,11 +216,11 @@ void ObjKibako_WaterBreak(ObjKibako* this, GlobalContext* globalCtx) { for (angle = 0, i = 0; i < 5; i++, angle += 0x3333) { pos.x = (Math_SinS(((s32)(Rand_ZeroOne() * 6000.0f)) + angle) * 15.0f) + worldPos->x; pos.z = (Math_CosS(((s32)(Rand_ZeroOne() * 6000.0f)) + angle) * 15.0f) + worldPos->z; - EffectSsGSplash_Spawn(globalCtx, &pos, NULL, NULL, 0, 350); + EffectSsGSplash_Spawn(play, &pos, NULL, NULL, 0, 350); } pos.x = worldPos->x; pos.z = worldPos->z; - EffectSsGRipple_Spawn(globalCtx, &pos, 200, 600, 0); + EffectSsGRipple_Spawn(play, &pos, 200, 600, 0); for (i = 0, angle = 0; i < 12; i++, angle += 0x4E20) { f32 sn = Math_SinS(angle); @@ -240,9 +240,9 @@ void ObjKibako_WaterBreak(ObjKibako* this, GlobalContext* globalCtx) { temp_rand = Rand_ZeroOne(); phi_s0 = (temp_rand < 0.2f) ? 0x40 : 0x20; - EffectSsKakera_Spawn( - globalCtx, &pos, &velocity, worldPos, -180, phi_s0, 50, 5, 0, (Rand_ZeroOne() * 35.0f) + 10.0f, 0, 0, 70, - -1, sObjectIdList[KIBAKO_BANK_INDEX(&this->actor)], sKakeraDisplayLists[KIBAKO_BANK_INDEX(&this->actor)]); + EffectSsKakera_Spawn(play, &pos, &velocity, worldPos, -180, phi_s0, 50, 5, 0, (Rand_ZeroOne() * 35.0f) + 10.0f, + 0, 0, 70, -1, sObjectIdList[KIBAKO_BANK_INDEX(&this->actor)], + sKakeraDisplayLists[KIBAKO_BANK_INDEX(&this->actor)]); } } @@ -250,10 +250,10 @@ void func_80926B40(ObjKibako* this) { this->actionFunc = func_80926B54; } -void func_80926B54(ObjKibako* this, GlobalContext* globalCtx) { +void func_80926B54(ObjKibako* this, PlayState* play) { Actor_MoveWithGravity(&this->actor); - Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 18.0f, 15.0f, 0.0f, 0x45); - if (Object_IsLoaded(&globalCtx->objectCtx, this->bankIndex)) { + Actor_UpdateBgCheckInfo(play, &this->actor, 18.0f, 15.0f, 0.0f, 0x45); + if (Object_IsLoaded(&play->objectCtx, this->bankIndex)) { this->actor.draw = ObjKibako_Draw; this->actor.objBankIndex = this->bankIndex; ObjKibako_SetupIdle(this); @@ -264,36 +264,36 @@ void ObjKibako_SetupIdle(ObjKibako* this) { this->actionFunc = ObjKibako_Idle; } -void ObjKibako_Idle(ObjKibako* this, GlobalContext* globalCtx) { +void ObjKibako_Idle(ObjKibako* this, PlayState* play) { s32 pad; s32 pad1; - if (Actor_HasParent(&this->actor, globalCtx)) { + if (Actor_HasParent(&this->actor, play)) { ObjKibako_SetupHeld(this); this->actor.room = -1; this->actor.colChkInfo.mass = 120; if (func_800A817C(KIBAKO_COLLECTIBLE_ID(&this->actor))) { - ObjKibako_SpawnCollectible(this, globalCtx); + ObjKibako_SpawnCollectible(this, play); } //! @bug: This function should only pass Player*: it uses *(this + 0x153), which is meant to be //! player->currentMask, but in this case is garbage in the collider func_800B8E58((Player*)this, NA_SE_PL_PULL_UP_WOODBOX); } else if ((this->actor.bgCheckFlags & 0x20) && (this->actor.depthInWater > 19.0f)) { - ObjKibako_WaterBreak(this, globalCtx); - ObjKibako_SpawnCollectible(this, globalCtx); - SoundSource_PlaySfxAtFixedWorldPos(globalCtx, &this->actor.world.pos, 20, NA_SE_EV_WOODBOX_BREAK); - SoundSource_PlaySfxAtFixedWorldPos(globalCtx, &this->actor.world.pos, 40, NA_SE_EV_DIVE_INTO_WATER_L); + ObjKibako_WaterBreak(this, play); + ObjKibako_SpawnCollectible(this, play); + SoundSource_PlaySfxAtFixedWorldPos(play, &this->actor.world.pos, 20, NA_SE_EV_WOODBOX_BREAK); + SoundSource_PlaySfxAtFixedWorldPos(play, &this->actor.world.pos, 40, NA_SE_EV_DIVE_INTO_WATER_L); Actor_MarkForDeath(&this->actor); } else if (this->collider.base.acFlags & AC_HIT) { - ObjKibako_AirBreak(this, globalCtx); - ObjKibako_SpawnCollectible(this, globalCtx); - SoundSource_PlaySfxAtFixedWorldPos(globalCtx, &this->actor.world.pos, 20, NA_SE_EV_WOODBOX_BREAK); + ObjKibako_AirBreak(this, play); + ObjKibako_SpawnCollectible(this, play); + SoundSource_PlaySfxAtFixedWorldPos(play, &this->actor.world.pos, 20, NA_SE_EV_WOODBOX_BREAK); Actor_MarkForDeath(&this->actor); } else { Actor_MoveWithGravity(&this->actor); func_809262BC(this); - Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 18.0f, 15.0f, 0.0f, 0x45); + Actor_UpdateBgCheckInfo(play, &this->actor, 18.0f, 15.0f, 0.0f, 0x45); if (!(this->collider.base.ocFlags1 & OC1_TYPE_PLAYER) && (this->actor.xzDistToPlayer > 28.0f)) { this->collider.base.ocFlags1 |= OC1_TYPE_PLAYER; @@ -308,20 +308,20 @@ void ObjKibako_Idle(ObjKibako* this, GlobalContext* globalCtx) { if (KIBAKO_BOMBER_CAN_HIDE_IN_BOX(&this->actor)) { Collider_UpdateCylinder(&this->actor, &this->collider); - CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + CollisionCheck_SetOC(play, &play->colChkCtx, &this->collider.base); if (this->actor.xzDistToPlayer < 800.0f) { - CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); - func_80926318(this, globalCtx); + CollisionCheck_SetAC(play, &play->colChkCtx, &this->collider.base); + func_80926318(this, play); } } else { if (this->actor.xzDistToPlayer < 800.0f) { Collider_UpdateCylinder(&this->actor, &this->collider); - CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + CollisionCheck_SetAC(play, &play->colChkCtx, &this->collider.base); if (this->actor.xzDistToPlayer < 180.0f) { - CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); - func_80926318(this, globalCtx); + CollisionCheck_SetOC(play, &play->colChkCtx, &this->collider.base); + func_80926318(this, play); } } } @@ -332,14 +332,14 @@ void ObjKibako_SetupHeld(ObjKibako* this) { this->actionFunc = ObjKibako_Held; } -void ObjKibako_Held(ObjKibako* this, GlobalContext* globalCtx) { +void ObjKibako_Held(ObjKibako* this, PlayState* play) { s32 pad; Vec3f pos; s32 bgId; - func_80926394(this, globalCtx); - if (Actor_HasNoParent(&this->actor, globalCtx)) { - this->actor.room = globalCtx->roomCtx.currRoom.num; + func_80926394(this, play); + if (Actor_HasNoParent(&this->actor, play)) { + this->actor.room = play->roomCtx.currRoom.num; if (fabsf(this->actor.speedXZ) < 0.1f) { ObjKibako_SetupIdle(this); this->collider.base.ocFlags1 &= ~OC1_TYPE_PLAYER; @@ -349,13 +349,13 @@ void ObjKibako_Held(ObjKibako* this, GlobalContext* globalCtx) { ObjKibako_SetupThrown(this); this->actor.flags &= ~ACTOR_FLAG_4000000; } - Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 18.0f, 15.0f, 0.0f, 0x45); + Actor_UpdateBgCheckInfo(play, &this->actor, 18.0f, 15.0f, 0.0f, 0x45); } 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); + BgCheck_EntityRaycastFloor5(&play->colCtx, &this->actor.floorPoly, &bgId, &this->actor, &pos); } } @@ -371,7 +371,7 @@ void ObjKibako_SetupThrown(ObjKibako* this) { this->actionFunc = ObjKibako_Thrown; } -void ObjKibako_Thrown(ObjKibako* this, GlobalContext* globalCtx) { +void ObjKibako_Thrown(ObjKibako* this, PlayState* play) { void* pad; void* pad2; s32 atHit; @@ -380,21 +380,21 @@ void ObjKibako_Thrown(ObjKibako* this, GlobalContext* globalCtx) { if (atHit) { this->collider.base.atFlags &= ~AT_HIT; } - func_80926394(this, globalCtx); + func_80926394(this, play); if (this->timer > 0) { this->timer--; } if ((this->actor.bgCheckFlags & 0xB) || (atHit) || (this->timer <= 0)) { - ObjKibako_AirBreak(this, globalCtx); - ObjKibako_SpawnCollectible(this, globalCtx); - SoundSource_PlaySfxAtFixedWorldPos(globalCtx, &this->actor.world.pos, 20, NA_SE_EV_WOODBOX_BREAK); + ObjKibako_AirBreak(this, play); + ObjKibako_SpawnCollectible(this, play); + SoundSource_PlaySfxAtFixedWorldPos(play, &this->actor.world.pos, 20, NA_SE_EV_WOODBOX_BREAK); Actor_MarkForDeath(&this->actor); } else { if (this->actor.bgCheckFlags & 0x40) { - ObjKibako_WaterBreak(this, globalCtx); - ObjKibako_SpawnCollectible(this, globalCtx); - SoundSource_PlaySfxAtFixedWorldPos(globalCtx, &this->actor.world.pos, 20, NA_SE_EV_WOODBOX_BREAK); - SoundSource_PlaySfxAtFixedWorldPos(globalCtx, &this->actor.world.pos, 40, NA_SE_EV_DIVE_INTO_WATER_L); + ObjKibako_WaterBreak(this, play); + ObjKibako_SpawnCollectible(this, play); + SoundSource_PlaySfxAtFixedWorldPos(play, &this->actor.world.pos, 20, NA_SE_EV_WOODBOX_BREAK); + SoundSource_PlaySfxAtFixedWorldPos(play, &this->actor.world.pos, 40, NA_SE_EV_DIVE_INTO_WATER_L); Actor_MarkForDeath(&this->actor); } else { if (this->actor.velocity.y < -0.05f) { @@ -405,21 +405,21 @@ void ObjKibako_Thrown(ObjKibako* this, GlobalContext* globalCtx) { Math_StepToS(&D_8092738C, D_80927388, 0xA0); this->actor.shape.rot.x = (s16)(this->actor.shape.rot.x + D_80927384); this->actor.shape.rot.y = (s16)(this->actor.shape.rot.y + D_8092738C); - Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 18.0f, 15.0f, 0.0f, 0x45); + Actor_UpdateBgCheckInfo(play, &this->actor, 18.0f, 15.0f, 0.0f, 0x45); Collider_UpdateCylinder(&this->actor, &this->collider); - CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); - CollisionCheck_SetAT(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + CollisionCheck_SetOC(play, &play->colChkCtx, &this->collider.base); + CollisionCheck_SetAT(play, &play->colChkCtx, &this->collider.base); } } } -void ObjKibako_Update(Actor* thisx, GlobalContext* globalCtx) { +void ObjKibako_Update(Actor* thisx, PlayState* play) { ObjKibako* this = THIS; - this->actionFunc(this, globalCtx); + this->actionFunc(this, play); ObjKibako_SetShadow(this); } -void ObjKibako_Draw(Actor* thisx, GlobalContext* globalCtx) { - Gfx_DrawDListOpa(globalCtx, sDisplayLists[KIBAKO_BANK_INDEX(thisx)]); +void ObjKibako_Draw(Actor* thisx, PlayState* play) { + Gfx_DrawDListOpa(play, sDisplayLists[KIBAKO_BANK_INDEX(thisx)]); } diff --git a/src/overlays/actors/ovl_Obj_Kibako/z_obj_kibako.h b/src/overlays/actors/ovl_Obj_Kibako/z_obj_kibako.h index 6df8b48ee..b3ef71cca 100644 --- a/src/overlays/actors/ovl_Obj_Kibako/z_obj_kibako.h +++ b/src/overlays/actors/ovl_Obj_Kibako/z_obj_kibako.h @@ -10,7 +10,7 @@ struct ObjKibako; -typedef void (*ObjKibakoActionFunc)(struct ObjKibako*, GlobalContext*); +typedef void (*ObjKibakoActionFunc)(struct ObjKibako*, PlayState*); typedef struct ObjKibako { /* 0x000 */ Actor actor; 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 c0e5d8b4b..fcbdfbad4 100644 --- a/src/overlays/actors/ovl_Obj_Kibako2/z_obj_kibako2.c +++ b/src/overlays/actors/ovl_Obj_Kibako2/z_obj_kibako2.c @@ -12,12 +12,12 @@ #define THIS ((ObjKibako2*)thisx) -void ObjKibako2_Init(Actor* thisx, GlobalContext* globalCtx); -void ObjKibako2_Destroy(Actor* thisx, GlobalContext* globalCtx); -void ObjKibako2_Update(Actor* thisx, GlobalContext* globalCtx); -void ObjKibako2_Draw(Actor* thisx, GlobalContext* globalCtx); -void ObjKibako2_Idle(ObjKibako2* this, GlobalContext* globalCtx); -void ObjKibako2_Kill(ObjKibako2* this, GlobalContext* globalCtx); +void ObjKibako2_Init(Actor* thisx, PlayState* play); +void ObjKibako2_Destroy(Actor* thisx, PlayState* play); +void ObjKibako2_Update(Actor* thisx, PlayState* play); +void ObjKibako2_Draw(Actor* thisx, PlayState* play); +void ObjKibako2_Idle(ObjKibako2* this, PlayState* play); +void ObjKibako2_Kill(ObjKibako2* this, PlayState* play); const ActorInit Obj_Kibako2_InitVars = { ACTOR_OBJ_KIBAKO2, @@ -58,17 +58,17 @@ static InitChainEntry sInitChain[] = { ICHAIN_F32(uncullZoneDownward, 200, ICHAIN_STOP), }; -s32 ObjKibako2_ContainsSkulltula(ObjKibako2* this, GlobalContext* globalCtx) { +s32 ObjKibako2_ContainsSkulltula(ObjKibako2* this, PlayState* play) { s32 actorSpawnParam = KIBAKO2_SKULLTULA_SPAWN_PARAM(&this->dyna.actor); s32 flag = -1; if ((u16)actorSpawnParam & 3) { flag = ((actorSpawnParam & 0x3FC) >> 2) & 0xFF; } - return !(flag >= 0 && Flags_GetTreasure(globalCtx, flag)); + return !(flag >= 0 && Flags_GetTreasure(play, flag)); } -void ObjKibako2_Break(ObjKibako2* this, GlobalContext* globalCtx) { +void ObjKibako2_Break(ObjKibako2* this, PlayState* play) { s32 pad[2]; Vec3f* thisPos = &this->dyna.actor.world.pos; Vec3f pos; @@ -99,32 +99,32 @@ void ObjKibako2_Break(ObjKibako2* this, GlobalContext* globalCtx) { } else { phi_s0 = 0x20; } - EffectSsKakera_Spawn(globalCtx, &pos, &velocity, &pos, -200, phi_s0, 28, 2, 0, (Rand_ZeroOne() * 30.0f) + 5.0f, - 0, 0, 70, KAKERA_COLOR_NONE, OBJECT_KIBAKO2, gLargeCrateFragment1DL); + EffectSsKakera_Spawn(play, &pos, &velocity, &pos, -200, phi_s0, 28, 2, 0, (Rand_ZeroOne() * 30.0f) + 5.0f, 0, 0, + 70, KAKERA_COLOR_NONE, OBJECT_KIBAKO2, gLargeCrateFragment1DL); } - func_800BBFB0(globalCtx, thisPos, 90.0f, 6, 100, 160, 1); + func_800BBFB0(play, thisPos, 90.0f, 6, 100, 160, 1); } -void ObjKibako2_SpawnCollectible(ObjKibako2* this, GlobalContext* globalCtx) { +void ObjKibako2_SpawnCollectible(ObjKibako2* this, PlayState* play) { s32 dropItem00Id = func_800A8150(KIBAKO2_COLLECTIBLE_ID(&this->dyna.actor)); if (dropItem00Id > ITEM00_NO_DROP) { - Item_DropCollectible(globalCtx, &this->dyna.actor.world.pos, + Item_DropCollectible(play, &this->dyna.actor.world.pos, dropItem00Id | KIBAKO2_COLLECTIBLE_FLAG(&this->dyna.actor) << 8); } } -void ObjKibako2_SpawnSkulltula(ObjKibako2* this, GlobalContext* globalCtx) { +void ObjKibako2_SpawnSkulltula(ObjKibako2* this, PlayState* play) { s16 yRotation; s32 actorSpawnParam; Actor* skulltula; - if (ObjKibako2_ContainsSkulltula(this, globalCtx)) { + if (ObjKibako2_ContainsSkulltula(this, play)) { 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); + Actor_Spawn(&play->actorCtx, play, 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); if (skulltula != NULL) { skulltula->parent = &this->dyna.actor; skulltula->velocity.y = 13.0f; @@ -133,48 +133,48 @@ void ObjKibako2_SpawnSkulltula(ObjKibako2* this, GlobalContext* globalCtx) { } } -void ObjKibako2_SpawnContents(ObjKibako2* this, GlobalContext* globalCtx) { - if (KIBAKO2_CONTENTS(&this->dyna.actor) == CONTENTS_COLLECTIBLE) { - ObjKibako2_SpawnCollectible(this, globalCtx); +void ObjKibako2_SpawnContents(ObjKibako2* this, PlayState* play) { + if (KIBAKO2_CONTENTS(&this->dyna.actor) == OBJKIBAKO2_CONTENTS_COLLECTIBLE) { + ObjKibako2_SpawnCollectible(this, play); } else { - ObjKibako2_SpawnSkulltula(this, globalCtx); + ObjKibako2_SpawnSkulltula(this, play); } } -void ObjKibako2_Init(Actor* thisx, GlobalContext* globalCtx) { +void ObjKibako2_Init(Actor* thisx, PlayState* play) { ObjKibako2* this = THIS; s32 pad; s32 contents = KIBAKO2_CONTENTS(&this->dyna.actor); DynaPolyActor_Init(&this->dyna, 0); - Collider_InitCylinder(globalCtx, &this->collider); + Collider_InitCylinder(play, &this->collider); Actor_ProcessInitChain(&this->dyna.actor, sInitChain); - DynaPolyActor_LoadMesh(globalCtx, &this->dyna, &gLargeCrateCol); - Collider_SetCylinder(globalCtx, &this->collider, &this->dyna.actor, &sCylinderInit); + DynaPolyActor_LoadMesh(play, &this->dyna, &gLargeCrateCol); + Collider_SetCylinder(play, &this->collider, &this->dyna.actor, &sCylinderInit); Collider_UpdateCylinder(&this->dyna.actor, &this->collider); this->dyna.actor.home.rot.z = 0; this->dyna.actor.world.rot.z = 0; this->dyna.actor.shape.rot.z = 0; this->dyna.actor.world.rot.x = 0; this->dyna.actor.shape.rot.x = 0; - if (contents == CONTENTS_COLLECTIBLE) { - if (func_800A81A4(globalCtx, KIBAKO2_COLLECTIBLE_ID(&this->dyna.actor), - KIBAKO2_COLLECTIBLE_FLAG(&this->dyna.actor))) { + if (contents == OBJKIBAKO2_CONTENTS_COLLECTIBLE) { + if (Item_CanDropBigFairy(play, KIBAKO2_COLLECTIBLE_ID(&this->dyna.actor), + KIBAKO2_COLLECTIBLE_FLAG(&this->dyna.actor))) { this->unk_1AC = 1; this->dyna.actor.flags |= ACTOR_FLAG_10; } } - if ((contents != CONTENTS_SKULLTULA) || !ObjKibako2_ContainsSkulltula(this, globalCtx)) { + if ((contents != OBJKIBAKO2_CONTENTS_SKULLTULA) || !ObjKibako2_ContainsSkulltula(this, play)) { this->skulltulaNoiseTimer = -1; } this->actionFunc = ObjKibako2_Idle; } -void ObjKibako2_Destroy(Actor* thisx, GlobalContext* globalCtx) { +void ObjKibako2_Destroy(Actor* thisx, PlayState* play) { ObjKibako2* this = THIS; - Collider_DestroyCylinder(globalCtx, &this->collider); - DynaPoly_DeleteBgActor(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); + Collider_DestroyCylinder(play, &this->collider); + DynaPoly_DeleteBgActor(play, &play->colCtx.dyna, this->dyna.bgId); } s32 ObjKibako2_ShouldBreak(ObjKibako2* this) { @@ -206,29 +206,29 @@ s32 ObjKibako2_ShouldBreak(ObjKibako2* this) { return shouldBreak; } -void ObjKibako2_Idle(ObjKibako2* this, GlobalContext* globalCtx) { +void ObjKibako2_Idle(ObjKibako2* this, PlayState* play) { if (ObjKibako2_ShouldBreak(this)) { - ObjKibako2_Break(this, globalCtx); - SoundSource_PlaySfxAtFixedWorldPos(globalCtx, &this->dyna.actor.world.pos, 20, NA_SE_EV_WOODBOX_BREAK); + ObjKibako2_Break(this, play); + SoundSource_PlaySfxAtFixedWorldPos(play, &this->dyna.actor.world.pos, 20, NA_SE_EV_WOODBOX_BREAK); this->dyna.actor.flags |= ACTOR_FLAG_10; - func_800C62BC(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); + func_800C62BC(play, &play->colCtx.dyna, this->dyna.bgId); this->dyna.actor.draw = NULL; this->actionFunc = ObjKibako2_Kill; } else if (this->dyna.actor.xzDistToPlayer < 600.0f) { - CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + CollisionCheck_SetAC(play, &play->colChkCtx, &this->collider.base); } } -void ObjKibako2_Kill(ObjKibako2* this, GlobalContext* globalCtx) { - ObjKibako2_SpawnContents(this, globalCtx); +void ObjKibako2_Kill(ObjKibako2* this, PlayState* play) { + ObjKibako2_SpawnContents(this, play); Actor_MarkForDeath(&this->dyna.actor); } -void ObjKibako2_Update(Actor* thisx, GlobalContext* globalCtx) { +void ObjKibako2_Update(Actor* thisx, PlayState* play) { ObjKibako2* this = THIS; if (this->unk_1AC != 0) { - globalCtx->actorCtx.unk5 |= 8; + play->actorCtx.unk5 |= 8; } if (this->skulltulaNoiseTimer >= 0) { @@ -243,9 +243,9 @@ void ObjKibako2_Update(Actor* thisx, GlobalContext* globalCtx) { this->skulltulaNoiseTimer--; } } - this->actionFunc(this, globalCtx); + this->actionFunc(this, play); } -void ObjKibako2_Draw(Actor* thisx, GlobalContext* globalCtx) { - Gfx_DrawDListOpa(globalCtx, gLargeCrateDL); +void ObjKibako2_Draw(Actor* thisx, PlayState* play) { + Gfx_DrawDListOpa(play, gLargeCrateDL); } diff --git a/src/overlays/actors/ovl_Obj_Kibako2/z_obj_kibako2.h b/src/overlays/actors/ovl_Obj_Kibako2/z_obj_kibako2.h index dd4687ab2..f1816ab4d 100644 --- a/src/overlays/actors/ovl_Obj_Kibako2/z_obj_kibako2.h +++ b/src/overlays/actors/ovl_Obj_Kibako2/z_obj_kibako2.h @@ -9,13 +9,13 @@ #define KIBAKO2_CONTENTS(thisx) (((thisx)->params >> 0xF) & 1) typedef enum { - /* 0 */ CONTENTS_COLLECTIBLE, - /* 1 */ CONTENTS_SKULLTULA + /* 0 */ OBJKIBAKO2_CONTENTS_COLLECTIBLE, + /* 1 */ OBJKIBAKO2_CONTENTS_SKULLTULA } ObjKibako2Contents; struct ObjKibako2; -typedef void (*ObjKibako2ActionFunc)(struct ObjKibako2*, GlobalContext*); +typedef void (*ObjKibako2ActionFunc)(struct ObjKibako2*, PlayState*); typedef struct ObjKibako2 { /* 0x000 */ DynaPolyActor dyna; 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 740439ead..deb315bc4 100644 --- a/src/overlays/actors/ovl_Obj_Kinoko/z_obj_kinoko.c +++ b/src/overlays/actors/ovl_Obj_Kinoko/z_obj_kinoko.c @@ -11,10 +11,10 @@ #define THIS ((ObjKinoko*)thisx) -void ObjKinoko_Init(Actor* thisx, GlobalContext* globalCtx); -void ObjKinoko_Destroy(Actor* thisx, GlobalContext* globalCtx); -void ObjKinoko_Update(Actor* thisx, GlobalContext* globalCtx); -void ObjKinoko_Draw(Actor* thisx, GlobalContext* globalCtx); +void ObjKinoko_Init(Actor* thisx, PlayState* play); +void ObjKinoko_Destroy(Actor* thisx, PlayState* play); +void ObjKinoko_Update(Actor* thisx, PlayState* play); +void ObjKinoko_Draw(Actor* thisx, PlayState* play); const ActorInit Obj_Kinoko_InitVars = { ACTOR_OBJ_KINOKO, @@ -28,15 +28,15 @@ const ActorInit Obj_Kinoko_InitVars = { (ActorFunc)ObjKinoko_Draw, }; -void ObjKinoko_Init(Actor* thisx, GlobalContext* globalCtx) { +void ObjKinoko_Init(Actor* thisx, PlayState* play) { thisx->world.pos.y += 4.0f; } -void ObjKinoko_Destroy(Actor* thisx, GlobalContext* globalCtx) { +void ObjKinoko_Destroy(Actor* thisx, PlayState* play) { } -void ObjKinoko_Update(Actor* thisx, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); +void ObjKinoko_Update(Actor* thisx, PlayState* play) { + Player* player = GET_PLAYER(play); s32 pad; if (player->currentMask != PLAYER_MASK_SCENTS) { @@ -47,12 +47,12 @@ void ObjKinoko_Update(Actor* thisx, GlobalContext* globalCtx) { 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)); + if (Actor_HasParent(thisx, play)) { + Flags_SetCollectible(play, OBJ_KINOKO_GET_FLAG(thisx)); Actor_MarkForDeath(thisx); return; } - Actor_PickUp(thisx, globalCtx, GI_MAX, 20.0f, 10.0f); + Actor_PickUp(thisx, play, GI_MAX, 20.0f, 10.0f); if (Math_SmoothStepToF(&thisx->speedXZ, 0.0f, 0.04f, 2.0f, 0.5f) < 0.5f) { thisx->scale.x = 0.0f; thisx->speedXZ = 110.0f; @@ -64,27 +64,27 @@ void ObjKinoko_Update(Actor* thisx, GlobalContext* globalCtx) { } thisx->scale.y = thisx->scale.x; thisx->scale.z = thisx->scale.x; - thisx->shape.rot.y = Camera_GetCamDirYaw(globalCtx->cameraPtrs[globalCtx->activeCamera]) + 0x8000; + thisx->shape.rot.y = Camera_GetCamDirYaw(GET_ACTIVE_CAM(play)) + 0x8000; } } -void ObjKinoko_Draw(Actor* thisx, GlobalContext* globalCtx) { +void ObjKinoko_Draw(Actor* thisx, PlayState* play) { Gfx* gfx; - OPEN_DISPS(globalCtx->state.gfxCtx); + OPEN_DISPS(play->state.gfxCtx); - func_8012C2DC(globalCtx->state.gfxCtx); + func_8012C2DC(play->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); + gSPMatrix(&gfx[3], Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(&gfx[4], &gameplay_keep_DL_029D10[2]); - Matrix_InsertXRotation_s(-0x4000, 1); - gSPMatrix(&gfx[5], Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + Matrix_RotateXS(-0x4000, MTXMODE_APPLY); + gSPMatrix(&gfx[5], Matrix_NewMtx(play->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); + CLOSE_DISPS(play->state.gfxCtx); } 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 5080c19e6..810525a58 100644 --- a/src/overlays/actors/ovl_Obj_Kzsaku/z_obj_kzsaku.c +++ b/src/overlays/actors/ovl_Obj_Kzsaku/z_obj_kzsaku.c @@ -11,17 +11,17 @@ #define THIS ((ObjKzsaku*)thisx) -void ObjKzsaku_Init(Actor* thisx, GlobalContext* globalCtx); -void ObjKzsaku_Destroy(Actor* thisx, GlobalContext* globalCtx); -void ObjKzsaku_Update(Actor* thisx, GlobalContext* globalCtx); -void ObjKzsaku_Draw(Actor* thisx, GlobalContext* globalCtx); +void ObjKzsaku_Init(Actor* thisx, PlayState* play); +void ObjKzsaku_Destroy(Actor* thisx, PlayState* play); +void ObjKzsaku_Update(Actor* thisx, PlayState* play); +void ObjKzsaku_Draw(Actor* thisx, PlayState* play); void ObjKzsaku_SetupIdle(ObjKzsaku* this); void func_80C08BBC(ObjKzsaku* this); void func_80C08C84(ObjKzsaku* this); -void ObjKzsaku_Idle(ObjKzsaku* this, GlobalContext* globalCtx); -void ObjKzsaku_Rise(ObjKzsaku* this, GlobalContext* globalCtx); -void func_80C08CB0(ObjKzsaku* this, GlobalContext* globalCtx); +void ObjKzsaku_Idle(ObjKzsaku* this, PlayState* play); +void ObjKzsaku_Rise(ObjKzsaku* this, PlayState* play); +void func_80C08CB0(ObjKzsaku* this, PlayState* play); const ActorInit Obj_Kzsaku_InitVars = { ACTOR_OBJ_KZSAKU, @@ -35,7 +35,7 @@ const ActorInit Obj_Kzsaku_InitVars = { (ActorFunc)ObjKzsaku_Draw, }; -void ObjKzsaku_Init(Actor* thisx, GlobalContext* globalCtx) { +void ObjKzsaku_Init(Actor* thisx, PlayState* play) { s32 pad; ObjKzsaku* this = THIS; CollisionHeader* col = NULL; @@ -44,22 +44,22 @@ void ObjKzsaku_Init(Actor* thisx, GlobalContext* globalCtx) { DynaPolyActor_Init(&this->dyna, 1); CollisionHeader_GetVirtual(&object_kzsaku_Colheader_001118, &col); - this->dyna.bgId = DynaPoly_SetBgActor(globalCtx, &globalCtx->colCtx.dyna, thisx, col); + this->dyna.bgId = DynaPoly_SetBgActor(play, &play->colCtx.dyna, thisx, col); this->switchFlag = KZSAKU_GET_SWITCHFLAG(thisx); this->raisedAmount = 0.0f; - if (Flags_GetSwitch(globalCtx, this->switchFlag)) { + if (Flags_GetSwitch(play, this->switchFlag)) { func_80C08C84(this); } else { ObjKzsaku_SetupIdle(this); } } -void ObjKzsaku_Destroy(Actor* thisx, GlobalContext* globalCtx) { +void ObjKzsaku_Destroy(Actor* thisx, PlayState* play) { ObjKzsaku* this = THIS; - DynaPoly_DeleteBgActor(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); + DynaPoly_DeleteBgActor(play, &play->colCtx.dyna, this->dyna.bgId); } void ObjKzsaku_SetupIdle(ObjKzsaku* this) { @@ -67,8 +67,8 @@ void ObjKzsaku_SetupIdle(ObjKzsaku* this) { this->actionFunc = ObjKzsaku_Idle; } -void ObjKzsaku_Idle(ObjKzsaku* this, GlobalContext* globalCtx) { - if (Flags_GetSwitch(globalCtx, this->switchFlag)) { +void ObjKzsaku_Idle(ObjKzsaku* this, PlayState* play) { + if (Flags_GetSwitch(play, this->switchFlag)) { func_80C08BBC(this); } } @@ -77,7 +77,7 @@ void func_80C08BBC(ObjKzsaku* this) { this->actionFunc = ObjKzsaku_Rise; } -void ObjKzsaku_Rise(ObjKzsaku* this, GlobalContext* globalCtx) { +void ObjKzsaku_Rise(ObjKzsaku* this, PlayState* play) { if (this->dyna.actor.cutscene != -1) { if (ActorCutscene_GetCanPlayNext(this->dyna.actor.cutscene)) { ActorCutscene_StartAndSetUnkLinkFields(this->dyna.actor.cutscene, &this->dyna.actor); @@ -100,7 +100,7 @@ void func_80C08C84(ObjKzsaku* this) { this->actionFunc = func_80C08CB0; } -void func_80C08CB0(ObjKzsaku* this, GlobalContext* globalCtx) { +void func_80C08CB0(ObjKzsaku* this, PlayState* play) { if (this->timer <= 20) { if (this->timer == 20) { if (ActorCutscene_GetCurrentIndex() == this->dyna.actor.cutscene) { @@ -113,18 +113,18 @@ void func_80C08CB0(ObjKzsaku* this, GlobalContext* globalCtx) { } } -void ObjKzsaku_Update(Actor* thisx, GlobalContext* globalCtx) { +void ObjKzsaku_Update(Actor* thisx, PlayState* play) { ObjKzsaku* this = THIS; - this->actionFunc(this, globalCtx); + this->actionFunc(this, play); } -void ObjKzsaku_Draw(Actor* thisx, GlobalContext* globalCtx) { - OPEN_DISPS(globalCtx->state.gfxCtx); +void ObjKzsaku_Draw(Actor* thisx, PlayState* play) { + OPEN_DISPS(play->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); + func_8012C28C(play->state.gfxCtx); + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_OPA_DISP++, object_kzsaku_DL_000040); - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->state.gfxCtx); } diff --git a/src/overlays/actors/ovl_Obj_Kzsaku/z_obj_kzsaku.h b/src/overlays/actors/ovl_Obj_Kzsaku/z_obj_kzsaku.h index 8c126412d..c4a9298fa 100644 --- a/src/overlays/actors/ovl_Obj_Kzsaku/z_obj_kzsaku.h +++ b/src/overlays/actors/ovl_Obj_Kzsaku/z_obj_kzsaku.h @@ -7,14 +7,14 @@ struct ObjKzsaku; -typedef void (*ObjKzsakuActionFunc)(struct ObjKzsaku*, GlobalContext*); +typedef void (*ObjKzsakuActionFunc)(struct ObjKzsaku*, PlayState*); typedef struct ObjKzsaku { - /* 0x0000 */ DynaPolyActor dyna; - /* 0x015C */ ObjKzsakuActionFunc actionFunc; - /* 0x0160 */ f32 raisedAmount; - /* 0x0164 */ s32 switchFlag; - /* 0x0168 */ s16 timer; + /* 0x000 */ DynaPolyActor dyna; + /* 0x15C */ ObjKzsakuActionFunc actionFunc; + /* 0x160 */ f32 raisedAmount; + /* 0x164 */ s32 switchFlag; + /* 0x168 */ s16 timer; } ObjKzsaku; // size = 0x16C extern const ActorInit Obj_Kzsaku_InitVars; diff --git a/src/overlays/actors/ovl_Obj_Lift/z_obj_lift.c b/src/overlays/actors/ovl_Obj_Lift/z_obj_lift.c index 300e299aa..f7056b147 100644 --- a/src/overlays/actors/ovl_Obj_Lift/z_obj_lift.c +++ b/src/overlays/actors/ovl_Obj_Lift/z_obj_lift.c @@ -5,17 +5,27 @@ */ #include "z_obj_lift.h" +#include "objects/object_d_lift/object_d_lift.h" #define FLAGS (ACTOR_FLAG_10) #define THIS ((ObjLift*)thisx) -void ObjLift_Init(Actor* thisx, GlobalContext* globalCtx); -void ObjLift_Destroy(Actor* thisx, GlobalContext* globalCtx); -void ObjLift_Update(Actor* thisx, GlobalContext* globalCtx); -void ObjLift_Draw(Actor* thisx, GlobalContext* globalCtx); +void ObjLift_Init(Actor* thisx, PlayState* play); +void ObjLift_Destroy(Actor* thisx, PlayState* play); +void ObjLift_Update(Actor* thisx, PlayState* play); +void ObjLift_Draw(Actor* thisx, PlayState* play); + +void func_8093D760(ObjLift* this); +void func_8093D7A0(ObjLift* this, PlayState* play); +void func_8093D9C0(ObjLift* this); +void func_8093D8B4(ObjLift* this, PlayState* play); +void func_8093D88C(ObjLift* this); +void func_8093DA48(ObjLift* this, PlayState* play); +void func_8093DB70(ObjLift* this); +void func_8093DB90(ObjLift* this, PlayState* play); +void func_8093DC90(Actor* thisx, PlayState* play); -#if 0 const ActorInit Obj_Lift_InitVars = { ACTOR_OBJ_LIFT, ACTORCAT_BG, @@ -28,46 +38,207 @@ const ActorInit Obj_Lift_InitVars = { (ActorFunc)ObjLift_Draw, }; -// static InitChainEntry sInitChain[] = { -static InitChainEntry D_8093DD84[] = { - ICHAIN_F32_DIV1000(gravity, -600, ICHAIN_CONTINUE), - ICHAIN_F32_DIV1000(terminalVelocity, -15000, ICHAIN_CONTINUE), - ICHAIN_F32(uncullZoneForward, 4000, ICHAIN_CONTINUE), - ICHAIN_F32(uncullZoneScale, 350, ICHAIN_CONTINUE), +static s16 D_8093DD50[] = { 0, 10, 20, 30, 40, 50, 60 }; + +Vec2s D_8093DD60[] = { + { 120, -120 }, { 120, 0 }, { 120, 120 }, { 0, -120 }, { 0, 0 }, + { 0, 120 }, { -120, -120 }, { -120, 0 }, { -120, 120 }, +}; + +static InitChainEntry sInitChain[] = { + ICHAIN_F32_DIV1000(gravity, -600, ICHAIN_CONTINUE), ICHAIN_F32_DIV1000(terminalVelocity, -15000, ICHAIN_CONTINUE), + ICHAIN_F32(uncullZoneForward, 4000, ICHAIN_CONTINUE), ICHAIN_F32(uncullZoneScale, 350, ICHAIN_CONTINUE), ICHAIN_F32(uncullZoneDownward, 350, ICHAIN_STOP), }; -#endif +static f32 D_8093DD98[] = { 0.1f, 0.05f }; -extern InitChainEntry D_8093DD84[]; +static f32 yOffsets[] = { -18.0f, -9.0f }; -extern UNK_TYPE D_06000D10; -extern UNK_TYPE D_06000F00; +void func_8093D3C0(ObjLift* this, PlayState* play) { + Vec3f pos; + Vec3f vel; + Vec3f* actorPos = &this->dyna.actor.world.pos; + s32 i; + s32 rand; + s32 pad; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Lift/func_8093D3C0.s") + for (i = 0; i < ARRAY_COUNT(D_8093DD60); i++) { + pos.x = (D_8093DD60[i].x * this->dyna.actor.scale.x) + actorPos->x; + pos.y = actorPos->y; + pos.z = (D_8093DD60[i].z * this->dyna.actor.scale.z) + actorPos->z; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Lift/ObjLift_Init.s") + vel.x = D_8093DD60[i].x * this->dyna.actor.scale.x * 0.8f; + vel.y = (Rand_ZeroOne() * 10.0f) + 6.0f; + vel.z = D_8093DD60[i].z * this->dyna.actor.scale.z * 0.8f; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Lift/ObjLift_Destroy.s") + if ((s32)Rand_Next() > 0) { + rand = 0x40; + } else { + rand = 0x20; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Lift/func_8093D760.s") + EffectSsKakera_Spawn(play, &pos, &vel, actorPos, -0x100, rand, 15, 15, 0, + ((Rand_ZeroOne() * 50.0f) + 50.0f) * this->dyna.actor.scale.x, 0, 32, 50, -1, + OBJECT_D_LIFT, gDampeGraveBrownElevatorDL); + } + if (OBJLIFT_GET_1(&this->dyna.actor) == 0) { + func_800BBFB0(play, &this->dyna.actor.world.pos, 120.0f, 12, 120, 100, 1); + } else if (OBJLIFT_GET_1(&this->dyna.actor) == 1) { + func_800BBFB0(play, &this->dyna.actor.world.pos, 60.0f, 8, 60, 100, 1); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Lift/func_8093D7A0.s") +void ObjLift_Init(Actor* thisx, PlayState* play) { + f32 temp_fv0; + ObjLift* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Lift/func_8093D88C.s") + Actor_ProcessInitChain(&this->dyna.actor, sInitChain); + this->dyna.actor.scale.x = this->dyna.actor.scale.z = D_8093DD98[OBJLIFT_GET_1(&this->dyna.actor)]; + this->dyna.actor.scale.y = 5.0f / 90.0f; + this->dyna.actor.shape.rot.z = 0; + this->unk_178 = this->dyna.actor.home.rot.z; + this->dyna.actor.home.rot.z = this->dyna.actor.world.rot.z = this->dyna.actor.shape.rot.z; + DynaPolyActor_Init(&this->dyna, 1); + if ((this->unk_178 <= 0) && (Flags_GetSwitch(play, OBJLIFT_GET_7F(&this->dyna.actor)))) { + Actor_MarkForDeath(&this->dyna.actor); + } else { + DynaPolyActor_LoadMesh(play, &this->dyna, &gDampeGraveBrownElevatorCol); + this->unk_160 = Rand_Next() >> 0x10; + this->unk_162 = Rand_Next() >> 0x10; + this->unk_164 = Rand_Next() >> 0x10; + func_8093D760(this); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Lift/func_8093D8B4.s") +void ObjLift_Destroy(Actor* thisx, PlayState* play) { + ObjLift* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Lift/func_8093D9C0.s") + DynaPoly_DeleteBgActor(play, &play->colCtx.dyna, this->dyna.bgId); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Lift/func_8093DA48.s") +void func_8093D760(ObjLift* this) { + this->timer = D_8093DD50[OBJLIFT_GET_7(&this->dyna.actor)]; + this->actionFunc = func_8093D7A0; + this->dyna.actor.draw = ObjLift_Draw; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Lift/func_8093DB70.s") +void func_8093D7A0(ObjLift* this, PlayState* play) { + s32 pad; + s16 quake; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Lift/func_8093DB90.s") + if (DynaPolyActor_IsInRidingMovingState(&this->dyna)) { + if (this->timer <= 0) { + if (OBJLIFT_GET_7(&this->dyna.actor) == 7) { + func_8093D9C0(this); + } else { + quake = Quake_Add(GET_ACTIVE_CAM(play), 1); + Quake_SetSpeed(quake, 10000); + Quake_SetQuakeValues(quake, 2, 0, 0, 0); + Quake_SetCountdown(quake, 20); + func_8093D88C(this); + } + } + } else { + this->timer = D_8093DD50[OBJLIFT_GET_7(&this->dyna.actor)]; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Lift/ObjLift_Update.s") +void func_8093D88C(ObjLift* this) { + this->timer = 20; + this->actionFunc = func_8093D8B4; + this->dyna.actor.draw = func_8093DC90; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Lift/ObjLift_Draw.s") +void func_8093D8B4(ObjLift* this, PlayState* play) { + if (this->timer <= 0) { + func_8093D9C0(this); + } else { + this->unk_160 += 0x2710; + this->unk_174 = Math_SinS(this->unk_160) * 300.0f; + this->unk_176 = Math_CosS(this->unk_160) * 300.0f; + this->unk_162 += 0x4650; + this->unk_168.y = Math_SinS(this->unk_162); + this->unk_164 += 0x4650; + this->unk_168.x = Math_SinS(this->unk_164) * 3.0f; + this->unk_168.z = Math_CosS(this->unk_164) * 3.0f; + } + if ((this->timer & 3) == 3) { + SoundSource_PlaySfxAtFixedWorldPos(play, &this->dyna.actor.world.pos, 16, NA_SE_EV_BLOCK_SHAKE); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Lift/func_8093DC90.s") +void func_8093D9C0(ObjLift* this) { + this->actionFunc = func_8093DA48; + Math_Vec3f_Copy(&this->dyna.actor.world.pos, &this->dyna.actor.home.pos); + this->dyna.actor.shape.rot = this->dyna.actor.world.rot = this->dyna.actor.home.rot; + this->dyna.actor.draw = ObjLift_Draw; +} + +void func_8093DA48(ObjLift* this, PlayState* play) { + s32 pad; + s32 sp38; + Vec3f pos; + + Actor_MoveWithGravity(&this->dyna.actor); + Math_Vec3f_Copy(&pos, &this->dyna.actor.prevPos); + pos.y += yOffsets[OBJLIFT_GET_1(&this->dyna.actor)]; + this->dyna.actor.floorHeight = + BgCheck_EntityRaycastFloor5(&play->colCtx, &this->dyna.actor.floorPoly, &sp38, &this->dyna.actor, &pos); + if ((yOffsets[OBJLIFT_GET_1(&this->dyna.actor)] - 0.001f) <= + (this->dyna.actor.floorHeight - this->dyna.actor.world.pos.y)) { + func_8093D3C0(this, play); + SoundSource_PlaySfxAtFixedWorldPos(play, &this->dyna.actor.world.pos, 20, NA_SE_EV_BOX_BREAK); + if (this->unk_178 > 0) { + func_8093DB70(this); + func_800C62BC(play, &play->colCtx.dyna, this->dyna.bgId); + } else { + Flags_SetSwitch(play, OBJLIFT_GET_7F(&this->dyna.actor)); + Actor_MarkForDeath(&this->dyna.actor); + } + } +} + +void func_8093DB70(ObjLift* this) { + this->timer = this->unk_178; + this->actionFunc = func_8093DB90; + this->dyna.actor.draw = NULL; +} + +void func_8093DB90(ObjLift* this, PlayState* play) { + if (this->timer <= 0) { + Math_Vec3f_Copy(&this->dyna.actor.world.pos, &this->dyna.actor.home.pos); + this->dyna.actor.world.rot = this->dyna.actor.shape.rot = this->dyna.actor.home.rot; + func_800C6314(play, &play->colCtx.dyna, this->dyna.bgId); + func_8093D760(this); + } +} + +void ObjLift_Update(Actor* thisx, PlayState* play) { + ObjLift* this = THIS; + + if (this->timer > 0) { + this->timer--; + } + this->actionFunc(this, play); +} + +void ObjLift_Draw(Actor* thisx, PlayState* play) { + ObjLift* this = THIS; + + Gfx_DrawDListOpa(play, gDampeGraveBrownElevatorDL); +} + +void func_8093DC90(Actor* thisx, PlayState* play) { + ObjLift* this = THIS; + Vec3f pos; + Vec3s rot; + + Math_Vec3f_Sum(&this->dyna.actor.world.pos, &this->unk_168, &pos); + rot.x = this->unk_174 + this->dyna.actor.home.rot.x; + rot.y = this->dyna.actor.home.rot.y; + rot.z = this->unk_176 + this->dyna.actor.home.rot.z; + Matrix_SetTranslateRotateYXZ(pos.x, pos.y, pos.z, &rot); + Matrix_Scale(this->dyna.actor.scale.x, this->dyna.actor.scale.y, this->dyna.actor.scale.z, MTXMODE_APPLY); + Gfx_DrawDListOpa(play, gDampeGraveBrownElevatorDL); +} diff --git a/src/overlays/actors/ovl_Obj_Lift/z_obj_lift.h b/src/overlays/actors/ovl_Obj_Lift/z_obj_lift.h index 3a3bbb497..ea29a9cb9 100644 --- a/src/overlays/actors/ovl_Obj_Lift/z_obj_lift.h +++ b/src/overlays/actors/ovl_Obj_Lift/z_obj_lift.h @@ -3,15 +3,25 @@ #include "global.h" +#define OBJLIFT_GET_1(thisx) ((thisx)->params & 1) +#define OBJLIFT_GET_7(thisx) (((thisx)->params >> 8) & 7) +#define OBJLIFT_GET_7F(thisx) (((thisx)->params >> 1) & 0x7F) + struct ObjLift; -typedef void (*ObjLiftActionFunc)(struct ObjLift*, GlobalContext*); +typedef void (*ObjLiftActionFunc)(struct ObjLift*, PlayState*); typedef struct ObjLift { - /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x18]; - /* 0x015C */ ObjLiftActionFunc actionFunc; - /* 0x0160 */ char unk_160[0x1C]; + /* 0x000 */ DynaPolyActor dyna; + /* 0x15C */ ObjLiftActionFunc actionFunc; + /* 0x160 */ s16 unk_160; + /* 0x162 */ s16 unk_162; + /* 0x164 */ s16 unk_164; + /* 0x166 */ s16 timer; + /* 0x168 */ Vec3f unk_168; + /* 0x174 */ s16 unk_174; + /* 0x176 */ s16 unk_176; + /* 0x178 */ s16 unk_178; } ObjLift; // size = 0x17C extern const ActorInit Obj_Lift_InitVars; diff --git a/src/overlays/actors/ovl_Obj_Lightblock/z_obj_lightblock.c b/src/overlays/actors/ovl_Obj_Lightblock/z_obj_lightblock.c index bd86f2dea..6884526ee 100644 --- a/src/overlays/actors/ovl_Obj_Lightblock/z_obj_lightblock.c +++ b/src/overlays/actors/ovl_Obj_Lightblock/z_obj_lightblock.c @@ -11,16 +11,16 @@ #define THIS ((ObjLightblock*)thisx) -void ObjLightblock_Init(Actor* thisx, GlobalContext* globalCtx); -void ObjLightblock_Destroy(Actor* thisx, GlobalContext* globalCtx); -void ObjLightblock_Update(Actor* thisx, GlobalContext* globalCtx); -void ObjLightblock_Draw(Actor* thisx, GlobalContext* globalCtx); +void ObjLightblock_Init(Actor* thisx, PlayState* play); +void ObjLightblock_Destroy(Actor* thisx, PlayState* play); +void ObjLightblock_Update(Actor* thisx, PlayState* play); +void ObjLightblock_Draw(Actor* thisx, PlayState* play); void func_80AF3AC8(ObjLightblock* this); -void func_80AF3ADC(ObjLightblock* this, GlobalContext* globalCtx); +void func_80AF3ADC(ObjLightblock* this, PlayState* play); void func_80AF3B8C(ObjLightblock* this); -void func_80AF3BA0(ObjLightblock* this, GlobalContext* globalCtx); +void func_80AF3BA0(ObjLightblock* this, PlayState* play); void func_80AF3C18(ObjLightblock* this); -void func_80AF3C34(ObjLightblock* this, GlobalContext* globalCtx); +void func_80AF3C34(ObjLightblock* this, PlayState* play); const ActorInit Obj_Lightblock_InitVars = { ACTOR_OBJ_LIGHTBLOCK, @@ -76,14 +76,14 @@ static InitChainEntry sInitChain[] = { extern Gfx D_801AEF88[]; extern Gfx D_801AEFA0[]; -void func_80AF3910(ObjLightblock* this, GlobalContext* globalCtx) { +void func_80AF3910(ObjLightblock* this, PlayState* play) { LightblockTypeVars* typeVars = &sLightblockTypeVars[LIGHTBLOCK_TYPE(&this->dyna.actor)]; - Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_DEMO_EFFECT, this->dyna.actor.world.pos.x, - this->dyna.actor.world.pos.y, this->dyna.actor.world.pos.z, 0, 0, 0, typeVars->params); + Actor_Spawn(&play->actorCtx, play, ACTOR_DEMO_EFFECT, this->dyna.actor.world.pos.x, this->dyna.actor.world.pos.y, + this->dyna.actor.world.pos.z, 0, 0, 0, typeVars->params); } -void ObjLightblock_Init(Actor* thisx, GlobalContext* globalCtx) { +void ObjLightblock_Init(Actor* thisx, PlayState* play) { s32 pad; ObjLightblock* this = THIS; LightblockTypeVars* typeVars = &sLightblockTypeVars[LIGHTBLOCK_TYPE(&this->dyna.actor)]; @@ -91,12 +91,12 @@ void ObjLightblock_Init(Actor* thisx, GlobalContext* globalCtx) { Actor_ProcessInitChain(&this->dyna.actor, sInitChain); Actor_SetScale(&this->dyna.actor, typeVars->scale); DynaPolyActor_Init(&this->dyna, 0); - Collider_InitCylinder(globalCtx, &this->collider); - if (Flags_GetSwitch(globalCtx, LIGHTBLOCK_DESTROYED(&this->dyna.actor))) { + Collider_InitCylinder(play, &this->collider); + if (Flags_GetSwitch(play, LIGHTBLOCK_DESTROYED(&this->dyna.actor))) { Actor_MarkForDeath(&this->dyna.actor); } else { - DynaPolyActor_LoadMesh(globalCtx, &this->dyna, &object_lightblock_Colheader_000B80); - Collider_SetCylinder(globalCtx, &this->collider, &this->dyna.actor, &sCylinderInit); + DynaPolyActor_LoadMesh(play, &this->dyna, &object_lightblock_Colheader_000B80); + Collider_SetCylinder(play, &this->collider, &this->dyna.actor, &sCylinderInit); Collider_UpdateCylinder(&this->dyna.actor, &this->collider); this->collider.dim.radius = typeVars->radius; this->collider.dim.height = typeVars->height; @@ -106,18 +106,18 @@ void ObjLightblock_Init(Actor* thisx, GlobalContext* globalCtx) { } } -void ObjLightblock_Destroy(Actor* thisx, GlobalContext* globalCtx) { +void ObjLightblock_Destroy(Actor* thisx, PlayState* play) { ObjLightblock* this = THIS; - DynaPoly_DeleteBgActor(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); - Collider_DestroyCylinder(globalCtx, &this->collider); + DynaPoly_DeleteBgActor(play, &play->colCtx.dyna, this->dyna.bgId); + Collider_DestroyCylinder(play, &this->collider); } void func_80AF3AC8(ObjLightblock* this) { this->actionFunc = func_80AF3ADC; } -void func_80AF3ADC(ObjLightblock* this, GlobalContext* globalCtx) { +void func_80AF3ADC(ObjLightblock* this, PlayState* play) { if (this->collider.base.acFlags & AC_HIT) { this->collider.base.acFlags &= ~AC_HIT; // light arrows @@ -136,7 +136,7 @@ void func_80AF3ADC(ObjLightblock* this, GlobalContext* globalCtx) { ActorCutscene_SetIntentToPlay(this->dyna.actor.cutscene); func_80AF3B8C(this); } else { - CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + CollisionCheck_SetAC(play, &play->colChkCtx, &this->collider.base); } } @@ -144,11 +144,11 @@ void func_80AF3B8C(ObjLightblock* this) { this->actionFunc = func_80AF3BA0; } -void func_80AF3BA0(ObjLightblock* this, GlobalContext* globalCtx) { +void func_80AF3BA0(ObjLightblock* this, PlayState* play) { if (ActorCutscene_GetCanPlayNext(this->dyna.actor.cutscene)) { ActorCutscene_StartAndSetUnkLinkFields(this->dyna.actor.cutscene, &this->dyna.actor); - Flags_SetSwitch(globalCtx, LIGHTBLOCK_DESTROYED(&this->dyna.actor)); - func_80AF3910(this, globalCtx); + Flags_SetSwitch(play, LIGHTBLOCK_DESTROYED(&this->dyna.actor)); + func_80AF3910(this, play); func_80AF3C18(this); } else { ActorCutscene_SetIntentToPlay(this->dyna.actor.cutscene); @@ -160,7 +160,7 @@ void func_80AF3C18(ObjLightblock* this) { this->actionFunc = func_80AF3C34; } -void func_80AF3C34(ObjLightblock* this, GlobalContext* globalCtx) { +void func_80AF3C34(ObjLightblock* this, PlayState* play) { s8 temp_a0; this->timer--; @@ -174,33 +174,33 @@ void func_80AF3C34(ObjLightblock* this, GlobalContext* globalCtx) { } else { this->alpha = 0; this->dyna.actor.draw = NULL; - func_800C62BC(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); + func_800C62BC(play, &play->colCtx.dyna, this->dyna.bgId); } } } -void ObjLightblock_Update(Actor* thisx, GlobalContext* globalCtx) { +void ObjLightblock_Update(Actor* thisx, PlayState* play) { ObjLightblock* this = THIS; - this->actionFunc(this, globalCtx); + this->actionFunc(this, play); } -void ObjLightblock_Draw(Actor* thisx, GlobalContext* globalCtx) { +void ObjLightblock_Draw(Actor* thisx, PlayState* play) { ObjLightblock* this = THIS; - OPEN_DISPS(globalCtx->state.gfxCtx); + OPEN_DISPS(play->state.gfxCtx); if (this->alpha < 255) { - func_8012C2DC(globalCtx->state.gfxCtx); + func_8012C2DC(play->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); + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gDPSetPrimColor(POLY_XLU_DISP++, 0, 0x80, 255, 255, 255, this->alpha); gSPDisplayList(POLY_XLU_DISP++, object_lightblock_DL_000178); } else { - func_8012C28C(globalCtx->state.gfxCtx); + func_8012C28C(play->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); + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gDPSetPrimColor(POLY_OPA_DISP++, 0, 0x80, 255, 255, 255, 255); gSPDisplayList(POLY_OPA_DISP++, object_lightblock_DL_000178); } - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->state.gfxCtx); } diff --git a/src/overlays/actors/ovl_Obj_Lightblock/z_obj_lightblock.h b/src/overlays/actors/ovl_Obj_Lightblock/z_obj_lightblock.h index 028d63754..eb16a7a92 100644 --- a/src/overlays/actors/ovl_Obj_Lightblock/z_obj_lightblock.h +++ b/src/overlays/actors/ovl_Obj_Lightblock/z_obj_lightblock.h @@ -8,15 +8,15 @@ struct ObjLightblock; -typedef void (*ObjLightblockActionFunc)(struct ObjLightblock*, GlobalContext*); +typedef void (*ObjLightblockActionFunc)(struct ObjLightblock*, PlayState*); typedef struct ObjLightblock { - /* 0x0000 */ DynaPolyActor dyna; - /* 0x015C */ ColliderCylinder collider; - /* 0x01A8 */ ObjLightblockActionFunc actionFunc; - /* 0x01AC */ s8 timer; - /* 0x01AD */ u8 alpha; - /* 0x01AE */ s8 collisionCounter; + /* 0x000 */ DynaPolyActor dyna; + /* 0x15C */ ColliderCylinder collider; + /* 0x1A8 */ ObjLightblockActionFunc actionFunc; + /* 0x1AC */ s8 timer; + /* 0x1AD */ u8 alpha; + /* 0x1AE */ s8 collisionCounter; } ObjLightblock; // size = 0x1B0 extern const ActorInit Obj_Lightblock_InitVars; diff --git a/src/overlays/actors/ovl_Obj_Lightswitch/z_obj_lightswitch.c b/src/overlays/actors/ovl_Obj_Lightswitch/z_obj_lightswitch.c index e9456bac1..dafd9bc2c 100644 --- a/src/overlays/actors/ovl_Obj_Lightswitch/z_obj_lightswitch.c +++ b/src/overlays/actors/ovl_Obj_Lightswitch/z_obj_lightswitch.c @@ -11,21 +11,21 @@ #define THIS ((ObjLightswitch*)thisx) -void ObjLightswitch_Init(Actor* thisx, GlobalContext* globalCtx); -void ObjLightswitch_Destroy(Actor* thisx, GlobalContext* globalCtx); -void ObjLightswitch_Update(Actor* thisx, GlobalContext* globalCtx); -void ObjLightswitch_Draw(Actor* thisx, GlobalContext* globalCtx); -void ObjLightswitch_PlayCinema(ObjLightswitch* this, GlobalContext* globalCtx); +void ObjLightswitch_Init(Actor* thisx, PlayState* play); +void ObjLightswitch_Destroy(Actor* thisx, PlayState* play); +void ObjLightswitch_Update(Actor* thisx, PlayState* play); +void ObjLightswitch_Draw(Actor* thisx, PlayState* play); +void ObjLightswitch_PlayCinema(ObjLightswitch* this, PlayState* play); void ObjLightSwitch_SetupEnabled(ObjLightswitch* this); -void ObjLightSwitch_Enabled(ObjLightswitch* this, GlobalContext* globalCtx); +void ObjLightSwitch_Enabled(ObjLightswitch* this, PlayState* play); void ObjLightswitch_SetupIdle(ObjLightswitch* this); void ObjLightSwitch_SetupFade(ObjLightswitch* this); -void ObjLightSwitch_Fade(ObjLightswitch* this, GlobalContext* globalCtx); +void ObjLightSwitch_Fade(ObjLightswitch* this, PlayState* play); void ObjLightSwitch_SetupAsleep(ObjLightswitch* this); -void ObjLightSwitch_Asleep(ObjLightswitch* this, GlobalContext* globalCtx); +void ObjLightSwitch_Asleep(ObjLightswitch* this, PlayState* play); void ObjLightSwitch_SetupDisabled(ObjLightswitch* this); -void ObjLightSwitch_Disabled(ObjLightswitch* this, GlobalContext* globalCtx); -void ObjLightswitch_Idle(ObjLightswitch* this, GlobalContext* globalCtx); +void ObjLightSwitch_Disabled(ObjLightswitch* this, PlayState* play); +void ObjLightswitch_Idle(ObjLightswitch* this, PlayState* play); const ActorInit Obj_Lightswitch_InitVars = { ACTOR_OBJ_LIGHTSWITCH, @@ -62,7 +62,7 @@ static ColliderJntSphInit sJntSphInit = { OC2_TYPE_2, COLSHAPE_JNTSPH, }, - 1, + ARRAY_COUNT(sJntSphElementsInit), sJntSphElementsInit, }; @@ -83,30 +83,30 @@ static InitChainEntry sInitChain[] = { ICHAIN_F32(uncullZoneDownward, 200, ICHAIN_STOP), }; -void ObjLightswitch_InitCollider(ObjLightswitch* this, GlobalContext* globalCtx) { +void ObjLightswitch_InitCollider(ObjLightswitch* this, PlayState* play) { s32 pad; - Collider_InitJntSph(globalCtx, &this->collider); - Collider_SetJntSph(globalCtx, &this->collider, &this->actor, &sJntSphInit, &this->elements); + Collider_InitJntSph(play, &this->collider); + Collider_SetJntSph(play, &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); } -void ObjLightswitch_UpdateSwitchFlags(ObjLightswitch* this, GlobalContext* globalCtx, s32 set) { +void ObjLightswitch_UpdateSwitchFlags(ObjLightswitch* this, PlayState* play, s32 set) { if (this) {} if (set) { - Flags_SetSwitch(globalCtx, GET_LIGHTSWITCH_SWITCHFLAG(this)); + Flags_SetSwitch(play, LIGHTSWITCH_GET_SWITCHFLAG(&this->actor)); } else { - Flags_UnsetSwitch(globalCtx, GET_LIGHTSWITCH_SWITCHFLAG(this)); + Flags_UnsetSwitch(play, LIGHTSWITCH_GET_SWITCHFLAG(&this->actor)); } } -void ObjLightswitch_SpawnEffects(ObjLightswitch* this, GlobalContext* globalCtx) { +void ObjLightswitch_SpawnEffects(ObjLightswitch* this, PlayState* play) { Vec3f effectPos; f32 sinResult; f32 cosResult; @@ -139,24 +139,24 @@ void ObjLightswitch_SpawnEffects(ObjLightswitch* this, GlobalContext* globalCtx) effectPos.y = this->actor.world.pos.y + tempResultDiff + 10.0f; effectPos.z = this->actor.world.pos.z + ((rand * cosResult) - (tempResult * sinResult)); - EffectSsDeadDb_Spawn(globalCtx, &effectPos, &gZeroVec3f, &gZeroVec3f, &sLightswitchEffectPrimColor, + EffectSsDeadDb_Spawn(play, &effectPos, &gZeroVec3f, &gZeroVec3f, &sLightswitchEffectPrimColor, &sLightswitchEffectEnvColor, 100, 0, 9); } } -void ObjLightswitch_Init(Actor* thisx, GlobalContext* globalCtx) { +void ObjLightswitch_Init(Actor* thisx, PlayState* play) { ObjLightswitch* this = THIS; s32 pad; u32 isSwitchActivated; s32 isTriggered; - isSwitchActivated = Flags_GetSwitch(globalCtx, GET_LIGHTSWITCH_SWITCHFLAG(this)); + isSwitchActivated = Flags_GetSwitch(play, LIGHTSWITCH_GET_SWITCHFLAG(&this->actor)); isTriggered = false; Actor_ProcessInitChain(&this->actor, sInitChain); Actor_SetFocus(&this->actor, 0.0f); if (isSwitchActivated) { - if (GET_LIGHTSWITCH_TYPE(this) == LIGHTSWITCH_TYPE_FAKE) { + if (LIGHTSWITCH_GET_TYPE(&this->actor) == LIGHTSWITCH_TYPE_FAKE) { isTriggered = true; } else { ObjLightSwitch_SetupEnabled(this); @@ -165,9 +165,9 @@ void ObjLightswitch_Init(Actor* thisx, GlobalContext* globalCtx) { ObjLightswitch_SetupIdle(this); } - ObjLightswitch_InitCollider(this, globalCtx); + ObjLightswitch_InitCollider(this, play); - if (GET_LIGHTSWITCH_INVISIBLE(this)) { + if (LIGHTSWITCH_GET_INVISIBLE(&this->actor)) { // the stone tower exterior switch is part of the scene mesh, the actor is invisble on top this->actor.draw = NULL; } @@ -177,9 +177,9 @@ void ObjLightswitch_Init(Actor* thisx, GlobalContext* globalCtx) { } } -void ObjLightswitch_Destroy(Actor* thisx, GlobalContext* globalCtx) { +void ObjLightswitch_Destroy(Actor* thisx, PlayState* play) { ObjLightswitch* this = THIS; - Collider_DestroyJntSph(globalCtx, &this->collider); + Collider_DestroyJntSph(play, &this->collider); } void ObjLightswitch_SetAction(ObjLightswitch* this, ObjLightswitchSetupFunc setupFunc, u32 setState) { @@ -188,10 +188,10 @@ void ObjLightswitch_SetAction(ObjLightswitch* this, ObjLightswitchSetupFunc setu this->actionFunc = ObjLightswitch_PlayCinema; } -void ObjLightswitch_PlayCinema(ObjLightswitch* this, GlobalContext* globalCtx) { +void ObjLightswitch_PlayCinema(ObjLightswitch* this, PlayState* play) { if (ActorCutscene_GetCanPlayNext(this->actor.cutscene)) { ActorCutscene_StartAndSetUnkLinkFields(this->actor.cutscene, &this->actor); - ObjLightswitch_UpdateSwitchFlags(this, globalCtx, this->switchFlagSetType); + ObjLightswitch_UpdateSwitchFlags(this, play, this->switchFlagSetType); this->cutsceneTimer = 50; this->setupFunc(this); } else { @@ -208,8 +208,8 @@ void ObjLightswitch_SetupIdle(ObjLightswitch* this) { this->actionFunc = ObjLightswitch_Idle; } -void ObjLightswitch_Idle(ObjLightswitch* this, GlobalContext* globalCtx) { - s32 actorType = GET_LIGHTSWITCH_TYPE(this); +void ObjLightswitch_Idle(ObjLightswitch* this, PlayState* play) { + s32 actorType = LIGHTSWITCH_GET_TYPE(&this->actor); if (this->hitState >= 10) { if (actorType == LIGHTSWITCH_TYPE_FAKE) { @@ -229,7 +229,7 @@ void ObjLightSwitch_SetupAsleep(ObjLightswitch* this) { this->actionFunc = ObjLightSwitch_Asleep; } -void ObjLightSwitch_Asleep(ObjLightswitch* this, GlobalContext* globalCtx) { +void ObjLightSwitch_Asleep(ObjLightswitch* this, PlayState* play) { if (this->colorShiftTimer == 0) { Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_SUN_MARK_FLASH); } @@ -259,12 +259,12 @@ void ObjLightSwitch_SetupEnabled(ObjLightswitch* this) { this->actionFunc = ObjLightSwitch_Enabled; } -void ObjLightSwitch_Enabled(ObjLightswitch* this, GlobalContext* globalCtx) { - s32 actorType = GET_LIGHTSWITCH_TYPE(this); +void ObjLightSwitch_Enabled(ObjLightswitch* this, PlayState* play) { + s32 actorType = LIGHTSWITCH_GET_TYPE(&this->actor); if (actorType == LIGHTSWITCH_TYPE_REGULAR) { // switch can be disabled outside of this actor by flag - if (!Flags_GetSwitch(globalCtx, GET_LIGHTSWITCH_SWITCHFLAG(this))) { + if (!Flags_GetSwitch(play, LIGHTSWITCH_GET_SWITCHFLAG(&this->actor))) { ObjLightSwitch_SetupDisabled(this); } } else if (actorType == LIGHTSWITCH_TYPE_FLIP) { @@ -274,7 +274,7 @@ void ObjLightSwitch_Enabled(ObjLightswitch* this, GlobalContext* globalCtx) { } } else if (this->hitState == 0) { if (this->colorShiftTimer >= 13) { - ObjLightswitch_UpdateSwitchFlags(this, globalCtx, 0); + ObjLightswitch_UpdateSwitchFlags(this, play, 0); ObjLightSwitch_SetupDisabled(this); } else { this->colorShiftTimer++; @@ -291,7 +291,7 @@ void ObjLightSwitch_SetupDisabled(ObjLightswitch* this) { this->actionFunc = ObjLightSwitch_Disabled; } -void ObjLightSwitch_Disabled(ObjLightswitch* this, GlobalContext* globalCtx) { +void ObjLightSwitch_Disabled(ObjLightswitch* this, PlayState* play) { this->colorShiftTimer--; Math_StepToS(&this->edgeRotSpeed, 0, 0xA); this->edgeRot += this->edgeRotSpeed; @@ -311,9 +311,9 @@ void ObjLightSwitch_SetupFade(ObjLightswitch* this) { this->actionFunc = ObjLightSwitch_Fade; } -void ObjLightSwitch_Fade(ObjLightswitch* this, GlobalContext* globalCtx) { +void ObjLightSwitch_Fade(ObjLightswitch* this, PlayState* play) { this->colorAlpha -= 200; - ObjLightswitch_SpawnEffects(this, globalCtx); // spawn burning fire effect + ObjLightswitch_SpawnEffects(this, play); // spawn burning fire effect if (this->colorAlpha < 0) { Actor_MarkForDeath(&this->actor); } else { @@ -321,7 +321,7 @@ void ObjLightSwitch_Fade(ObjLightswitch* this, GlobalContext* globalCtx) { } } -void ObjLightswitch_Update(Actor* thisx, GlobalContext* globalCtx) { +void ObjLightswitch_Update(Actor* thisx, PlayState* play) { ObjLightswitch* this = THIS; s32 pad; @@ -329,7 +329,7 @@ void ObjLightswitch_Update(Actor* thisx, GlobalContext* globalCtx) { // dmgFlags enum doesn't exist yet, 0x2000 is light arrows if ((this->collider.elements->info.acHitInfo->toucher.dmgFlags & 0x2000) != 0) { this->hitState = 10; - } else if (GET_LIGHTSWITCH_TYPE(this) == LIGHTSWITCH_TYPE_FLIP) { + } else if (LIGHTSWITCH_GET_TYPE(&this->actor) == LIGHTSWITCH_TYPE_FLIP) { if (this->hitState == 0) { if ((this->previousACFlags & AC_HIT) == 0) { this->hitState = 1; @@ -354,22 +354,22 @@ void ObjLightswitch_Update(Actor* thisx, GlobalContext* globalCtx) { } } - this->actionFunc(this, globalCtx); + this->actionFunc(this, play); if (this->actor.update != NULL) { this->previousACFlags = this->collider.base.acFlags; - CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); - CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + CollisionCheck_SetOC(play, &play->colChkCtx, &this->collider.base); + CollisionCheck_SetAC(play, &play->colChkCtx, &this->collider.base); } } -void ObjLightSwitch_DrawOpa(ObjLightswitch* this, GlobalContext* globalCtx) { +void ObjLightSwitch_DrawOpa(ObjLightswitch* this, PlayState* play) { s32 pad; Vec3f tempPos; Vec3s tempRot; - OPEN_DISPS(globalCtx->state.gfxCtx); + OPEN_DISPS(play->state.gfxCtx); - func_8012C28C(globalCtx->state.gfxCtx); + func_8012C28C(play->state.gfxCtx); gDPSetEnvColor(POLY_OPA_DISP++, (u8)(this->colorR >> 6), (u8)(this->colorG >> 6), ((void)0, (u8)(this->colorB >> 6)), (u8)(this->colorAlpha >> 6)); gSPSegment(POLY_OPA_DISP++, 0x09, D_801AEFA0); @@ -377,35 +377,35 @@ void ObjLightSwitch_DrawOpa(ObjLightswitch* this, GlobalContext* globalCtx) { tempPos.x = this->actor.world.pos.x; tempPos.y = this->actor.world.pos.y + (this->actor.shape.yOffset * this->actor.scale.y); tempPos.z = this->actor.world.pos.z; - gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPSegment(POLY_OPA_DISP++, 0x08, Lib_SegmentedToVirtual(sLightswitchFaceGfx[this->faceState])); gSPDisplayList(POLY_OPA_DISP++, object_lightswitch_DL_000260); 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); + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(play->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); + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_OPA_DISP++, object_lightswitch_DL_000408); - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->state.gfxCtx); } -void ObjLightSwitch_DrawXlu(ObjLightswitch* this, GlobalContext* globalCtx) { +void ObjLightSwitch_DrawXlu(ObjLightswitch* this, PlayState* play) { s32 pad; Vec3f tempPos; Vec3s tempRot; - OPEN_DISPS(globalCtx->state.gfxCtx); + OPEN_DISPS(play->state.gfxCtx); - func_8012C2DC(globalCtx->state.gfxCtx); + func_8012C2DC(play->state.gfxCtx); gDPSetEnvColor(POLY_XLU_DISP++, (u8)(this->colorR >> 6), (u8)(this->colorG >> 6), ((void)0, (u8)(this->colorB >> 6)), (u8)(this->colorAlpha >> 6)); gSPSegment(POLY_XLU_DISP++, 0x09, D_801AEF88); @@ -413,34 +413,34 @@ void ObjLightSwitch_DrawXlu(ObjLightswitch* this, GlobalContext* globalCtx) { tempPos.x = this->actor.world.pos.x; tempPos.y = this->actor.world.pos.y + (this->actor.shape.yOffset * this->actor.scale.y); tempPos.z = this->actor.world.pos.z; - gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPSegment(POLY_XLU_DISP++, 0x08, Lib_SegmentedToVirtual(sLightswitchFaceGfx[this->faceState])); gSPDisplayList(POLY_XLU_DISP++, object_lightswitch_DL_000260); 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); + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(play->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); + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_XLU_DISP++, object_lightswitch_DL_000408); - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->state.gfxCtx); } -void ObjLightswitch_Draw(Actor* thisx, GlobalContext* globalCtx) { +void ObjLightswitch_Draw(Actor* thisx, PlayState* play) { ObjLightswitch* this = THIS; s32 alpha = (u8)(this->colorAlpha >> 6); - if ((GET_LIGHTSWITCH_TYPE(this) == LIGHTSWITCH_TYPE_FAKE) && (alpha > 0) && (alpha < 255)) { - ObjLightSwitch_DrawXlu(this, globalCtx); + if ((LIGHTSWITCH_GET_TYPE(&this->actor) == LIGHTSWITCH_TYPE_FAKE) && (alpha > 0) && (alpha < 255)) { + ObjLightSwitch_DrawXlu(this, play); } else { - ObjLightSwitch_DrawOpa(this, globalCtx); + ObjLightSwitch_DrawOpa(this, play); } } diff --git a/src/overlays/actors/ovl_Obj_Lightswitch/z_obj_lightswitch.h b/src/overlays/actors/ovl_Obj_Lightswitch/z_obj_lightswitch.h index 6bd9dde17..a07900138 100644 --- a/src/overlays/actors/ovl_Obj_Lightswitch/z_obj_lightswitch.h +++ b/src/overlays/actors/ovl_Obj_Lightswitch/z_obj_lightswitch.h @@ -5,7 +5,7 @@ struct ObjLightswitch; -typedef void (*ObjLightswitchActionFunc)(struct ObjLightswitch*, GlobalContext*); +typedef void (*ObjLightswitchActionFunc)(struct ObjLightswitch*, PlayState*); typedef void (*ObjLightswitchSetupFunc)(struct ObjLightswitch*); typedef struct ObjLightswitch { @@ -40,8 +40,8 @@ extern const ActorInit Obj_Lightswitch_InitVars; #define LIGHTSWITCH_TYPE_UNK2 2 #define LIGHTSWITCH_TYPE_FAKE 3 -#define GET_LIGHTSWITCH_TYPE(this) (((this)->actor.params >> 4) & 0x3) -#define GET_LIGHTSWITCH_INVISIBLE(this) (((this)->actor.params >> 3) & 1) -#define GET_LIGHTSWITCH_SWITCHFLAG(this) (((this)->actor.params >> 8) & 0x7F) +#define LIGHTSWITCH_GET_TYPE(thisx) (((thisx)->params >> 4) & 0x3) +#define LIGHTSWITCH_GET_INVISIBLE(thisx) (((thisx)->params >> 3) & 1) +#define LIGHTSWITCH_GET_SWITCHFLAG(thisx) (((thisx)->params >> 8) & 0x7F) #endif // Z_OBJ_LIGHTSWITCH_H diff --git a/src/overlays/actors/ovl_Obj_Lupygamelift/z_obj_lupygamelift.c b/src/overlays/actors/ovl_Obj_Lupygamelift/z_obj_lupygamelift.c index d804f6b63..697c73f6a 100644 --- a/src/overlays/actors/ovl_Obj_Lupygamelift/z_obj_lupygamelift.c +++ b/src/overlays/actors/ovl_Obj_Lupygamelift/z_obj_lupygamelift.c @@ -5,17 +5,22 @@ */ #include "z_obj_lupygamelift.h" +#include "objects/object_raillift/object_raillift.h" #define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_20) #define THIS ((ObjLupygamelift*)thisx) -void ObjLupygamelift_Init(Actor* thisx, GlobalContext* globalCtx); -void ObjLupygamelift_Destroy(Actor* thisx, GlobalContext* globalCtx); -void ObjLupygamelift_Update(Actor* thisx, GlobalContext* globalCtx); -void ObjLupygamelift_Draw(Actor* thisx, GlobalContext* globalCtx); +void ObjLupygamelift_Init(Actor* thisx, PlayState* play); +void ObjLupygamelift_Destroy(Actor* thisx, PlayState* play); +void ObjLupygamelift_Update(Actor* thisx, PlayState* play); +void ObjLupygamelift_Draw(Actor* thisx, PlayState* play); + +void func_80AF04BC(ObjLupygamelift* this); +void func_80AF04D8(ObjLupygamelift* this, PlayState* play); +void func_80AF0514(ObjLupygamelift* this); +void func_80AF0530(ObjLupygamelift* this, PlayState* play); -#if 0 const ActorInit Obj_Lupygamelift_InitVars = { ACTOR_OBJ_LUPYGAMELIFT, ACTORCAT_BG, @@ -28,35 +33,142 @@ const ActorInit Obj_Lupygamelift_InitVars = { (ActorFunc)ObjLupygamelift_Draw, }; -// static InitChainEntry sInitChain[] = { -static InitChainEntry D_80AF0740[] = { +static InitChainEntry sInitChain[] = { ICHAIN_F32(uncullZoneForward, 4000, ICHAIN_CONTINUE), ICHAIN_F32(uncullZoneScale, 200, ICHAIN_CONTINUE), ICHAIN_F32(uncullZoneDownward, 400, ICHAIN_CONTINUE), ICHAIN_VEC3F_DIV1000(scale, 100, ICHAIN_STOP), }; -#endif +void ObjLupygamelift_Init(Actor* thisx, PlayState* play) { + s32 pad; + ObjLupygamelift* this = THIS; + Path* path; + s32 params; -extern InitChainEntry D_80AF0740[]; + Actor_ProcessInitChain(thisx, sInitChain); + this->dyna.actor.scale.y = 0.15f; + this->dyna.actor.shape.rot.x = 0; + this->dyna.actor.world.rot.x = 0; + this->dyna.actor.shape.rot.z = 0; + this->dyna.actor.world.rot.z = 0; + this->timer = 0; + Actor_UpdateBgCheckInfo(play, thisx, 0.0f, 0.0f, 0.0f, 4); + ActorShape_Init(&thisx->shape, 0.0f, ActorShadow_DrawSquare, 0.0f); + DynaPolyActor_Init(&this->dyna, 1); + DynaPolyActor_LoadMesh(play, &this->dyna, &object_raillift_Colheader_0048D0); + this->targetSpeedXZ = thisx->home.rot.z * 0.1f; + if (this->targetSpeedXZ < 0.0f) { + this->targetSpeedXZ = -this->targetSpeedXZ; + } + this->dyna.actor.home.rot.x = 0; + this->dyna.actor.home.rot.y = 0; + this->dyna.actor.home.rot.z = 0; -extern UNK_TYPE D_060048D0; -extern UNK_TYPE D_060071B8; + path = &play->setupPathList[OBJLUPYGAMELIFT_GET_PATH(thisx)]; + this->pointIndex = OBJLUPYGAMELIFT_GET_7(thisx); + this->count = path->count; + if (this->pointIndex >= this->count) { + this->pointIndex = 0; + } + this->points = Lib_SegmentedToVirtual(path->points); + Actor_SpawnAsChild(&play->actorCtx, &this->dyna.actor, play, ACTOR_OBJ_ETCETERA, this->dyna.actor.world.pos.x, + this->dyna.actor.world.pos.y, this->dyna.actor.world.pos.z, this->dyna.actor.shape.rot.x, + this->dyna.actor.shape.rot.y, this->dyna.actor.shape.rot.z, 0); + if (OBJLUPYGAMELIFT_GET_C(thisx) != 0) { + params = 1; + } else { + params = 0; + } + Actor_Spawn(&play->actorCtx, play, ACTOR_EN_GAMELUPY, this->dyna.actor.home.pos.x, this->dyna.actor.home.pos.y, + this->dyna.actor.home.pos.z, 0, 0, 0, params); + func_80AF04BC(this); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Lupygamelift/ObjLupygamelift_Init.s") +void ObjLupygamelift_Destroy(Actor* thisx, PlayState* play) { + ObjLupygamelift* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Lupygamelift/ObjLupygamelift_Destroy.s") + DynaPoly_DeleteBgActor(play, &play->colCtx.dyna, this->dyna.bgId); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Lupygamelift/func_80AF0394.s") +void func_80AF0394(ObjLupygamelift* this) { + static f32 D_80AF0750 = 100.0f; + static f32 D_80AF0754 = 255.0f; + static f32 D_80AF0758 = 5.0f; + static f32 D_80AF075C = 10.0f; + static f32 D_80AF0760 = -240.0f; + static f32 D_80AF0764 = 30.0f; + f32 new_var = D_80AF0754 - D_80AF0750; + f32 new_var2 = D_80AF0764 - D_80AF0760; + f32 new_var3 = D_80AF075C - D_80AF0758; + f32 temp_fa0; + f32 phi_fa1; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Lupygamelift/func_80AF04BC.s") + temp_fa0 = this->dyna.actor.world.pos.y - D_80AF0760; + if (temp_fa0 < 0.0f) { + phi_fa1 = 0.0f; + } else if (new_var2 < temp_fa0) { + phi_fa1 = 1.0f; + } else { + phi_fa1 = temp_fa0 / new_var2; + } + this->dyna.actor.shape.shadowAlpha = D_80AF0754 - (phi_fa1 * new_var); + this->dyna.actor.shape.shadowScale = D_80AF075C - (phi_fa1 * new_var3); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Lupygamelift/func_80AF04D8.s") +void func_80AF04BC(ObjLupygamelift* this) { + this->timer = 5; + this->actionFunc = func_80AF04D8; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Lupygamelift/func_80AF0514.s") +void func_80AF04D8(ObjLupygamelift* this, PlayState* play) { + if (this->timer == 0) { + func_80AF0514(this); + } else { + this->timer--; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Lupygamelift/func_80AF0530.s") +void func_80AF0514(ObjLupygamelift* this) { + this->actionFunc = func_80AF0530; + this->dyna.actor.speedXZ = this->targetSpeedXZ; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Lupygamelift/ObjLupygamelift_Update.s") +void func_80AF0530(ObjLupygamelift* this, PlayState* play) { + f32 step; + Vec3f target; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Lupygamelift/ObjLupygamelift_Draw.s") + target.x = this->points[this->pointIndex].x; + target.y = this->points[this->pointIndex].y; + target.z = this->points[this->pointIndex].z; + step = Math_Vec3f_StepTo(&this->dyna.actor.world.pos, &target, this->dyna.actor.speedXZ); + if (step > 30.0f) { + Math_SmoothStepToF(&this->dyna.actor.speedXZ, this->targetSpeedXZ, 0.5f, 5.0f, 0.1f); + } else if (step > 0.0f) { + Math_SmoothStepToF(&this->dyna.actor.speedXZ, 5.0f, 0.5f, 5.0f, 1.0f); + } else { + if (this->pointIndex < (this->count - 1)) { + this->pointIndex++; + } else { + this->pointIndex = 0; + } + } + if (this->dyna.actor.child->update == NULL) { + this->dyna.actor.child = NULL; + } else { + this->dyna.actor.child->world.pos.x = this->dyna.actor.world.pos.x; + this->dyna.actor.child->world.pos.y = this->dyna.actor.world.pos.y; + this->dyna.actor.child->world.pos.z = this->dyna.actor.world.pos.z; + } + func_80AF0394(this); +} + +void ObjLupygamelift_Update(Actor* thisx, PlayState* play) { + ObjLupygamelift* this = THIS; + + this->actionFunc(this, play); +} + +void ObjLupygamelift_Draw(Actor* thisx, PlayState* play) { + Gfx_DrawDListOpa(play, object_raillift_DL_0071B8); +} diff --git a/src/overlays/actors/ovl_Obj_Lupygamelift/z_obj_lupygamelift.h b/src/overlays/actors/ovl_Obj_Lupygamelift/z_obj_lupygamelift.h index a1bd6d62e..e2abd8be5 100644 --- a/src/overlays/actors/ovl_Obj_Lupygamelift/z_obj_lupygamelift.h +++ b/src/overlays/actors/ovl_Obj_Lupygamelift/z_obj_lupygamelift.h @@ -3,16 +3,23 @@ #include "global.h" +#define OBJLUPYGAMELIFT_GET_PATH(thisx) ((thisx)->params & 0x7F) +#define OBJLUPYGAMELIFT_GET_7(thisx) (((thisx)->params >> 7) & 0x1F) +#define OBJLUPYGAMELIFT_GET_C(thisx) (((thisx)->params >> 0xC) & 1) + struct ObjLupygamelift; -typedef void (*ObjLupygameliftActionFunc)(struct ObjLupygamelift*, GlobalContext*); +typedef void (*ObjLupygameliftActionFunc)(struct ObjLupygamelift*, PlayState*); typedef struct ObjLupygamelift { - /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x18]; - /* 0x015C */ ObjLupygameliftActionFunc actionFunc; - /* 0x0160 */ char unk_160[0x14]; -} ObjLupygamelift; // size = 0x174 + /* 0x000 */ DynaPolyActor dyna; + /* 0x15C */ ObjLupygameliftActionFunc actionFunc; + /* 0x160 */ f32 targetSpeedXZ; + /* 0x164 */ s32 count; + /* 0x168 */ s32 pointIndex; + /* 0x16C */ Vec3s* points; + /* 0x170 */ s16 timer; +} ObjLupygamelift; /* size = 0x174 */ extern const ActorInit Obj_Lupygamelift_InitVars; diff --git a/src/overlays/actors/ovl_Obj_Makekinsuta/z_obj_makekinsuta.c b/src/overlays/actors/ovl_Obj_Makekinsuta/z_obj_makekinsuta.c index a5aaefd4f..90aa5fa40 100644 --- a/src/overlays/actors/ovl_Obj_Makekinsuta/z_obj_makekinsuta.c +++ b/src/overlays/actors/ovl_Obj_Makekinsuta/z_obj_makekinsuta.c @@ -10,11 +10,14 @@ #define THIS ((ObjMakekinsuta*)thisx) -void ObjMakekinsuta_Init(Actor* thisx, GlobalContext* globalCtx); -void ObjMakekinsuta_Destroy(Actor* thisx, GlobalContext* globalCtx); -void ObjMakekinsuta_Update(Actor* thisx, GlobalContext* globalCtx); +void ObjMakekinsuta_Init(Actor* thisx, PlayState* play); +void ObjMakekinsuta_Destroy(Actor* thisx, PlayState* play); +void ObjMakekinsuta_Update(Actor* thisx, PlayState* play); + +s32 func_8099FA40(ObjMakekinsuta* this, PlayState* play); +void func_8099FB64(Actor* thisx, PlayState* play); +void func_8099FD7C(Actor* thisx, PlayState* play); -#if 0 const ActorInit Obj_Makekinsuta_InitVars = { ACTOR_OBJ_MAKEKINSUTA, ACTORCAT_ITEMACTION, @@ -27,25 +30,112 @@ const ActorInit Obj_Makekinsuta_InitVars = { (ActorFunc)NULL, }; -// static InitChainEntry sInitChain[] = { -static InitChainEntry D_8099FE30[] = { +static InitChainEntry sInitChain[] = { ICHAIN_F32(uncullZoneForward, 1, ICHAIN_CONTINUE), ICHAIN_F32(uncullZoneScale, 1, ICHAIN_CONTINUE), ICHAIN_F32(uncullZoneDownward, 1, ICHAIN_STOP), }; -#endif +s32 func_8099FA40(ObjMakekinsuta* this, PlayState* play) { + s32 chestFlag = -1; + s32 skulltulaParams = (OBJMAKEKINSUTA_GET_1F(&this->actor) << 2) | 0xFF01; -extern InitChainEntry D_8099FE30[]; + if (OBJMAKEKINSUTA_GETS_3(skulltulaParams)) { + chestFlag = OBJMAKEKINSUTA_GETS_3FC(skulltulaParams); + } + return (chestFlag < 0) == true || !Flags_GetTreasure(play, chestFlag); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Makekinsuta/func_8099FA40.s") +void ObjMakekinsuta_Init(Actor* thisx, PlayState* play) { + ObjMakekinsuta* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Makekinsuta/ObjMakekinsuta_Init.s") + Actor_ProcessInitChain(&this->actor, sInitChain); + if (!func_8099FA40(this, play)) { + this->unk144 = -1; + } + if (Flags_GetSwitch(play, OBJMAKEKINSUTA_GET_SWITCH_FLAGS(thisx))) { + Actor_MarkForDeath(&this->actor); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Makekinsuta/ObjMakekinsuta_Destroy.s") +void ObjMakekinsuta_Destroy(Actor* thisx, PlayState* play) { + ObjMakekinsuta* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Makekinsuta/func_8099FB64.s") + if (func_8099FA40(this, play)) { + Flags_UnsetSwitch(play, OBJMAKEKINSUTA_GET_SWITCH_FLAGS(thisx)); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Makekinsuta/ObjMakekinsuta_Update.s") +void func_8099FB64(Actor* thisx, PlayState* play) { + s32 pad[0x2]; + Actor* actor; + Vec3f destVec; + s16 rotY; + f32 speedXZ; + s32 rotCheck; + static Vec3f D_8099FE3C = { 0.0f, 1.0f, 0.0f }; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Makekinsuta/func_8099FD7C.s") + rotCheck = thisx->shape.rot.x == 0; + if (rotCheck) { + rotCheck = thisx->shape.rot.z == 0; + } + + if (rotCheck) { + rotY = thisx->shape.rot.y; + } else { + Matrix_RotateYS(thisx->shape.rot.y, MTXMODE_NEW); + Matrix_RotateXS(thisx->shape.rot.x, MTXMODE_APPLY); + Matrix_RotateZS(thisx->shape.rot.z, MTXMODE_APPLY); + Matrix_MultVec3f(&D_8099FE3C, &destVec); + rotY = Math_FAtan2F(destVec.z, destVec.x); + } + actor = Actor_Spawn(&play->actorCtx, play, ACTOR_EN_SW, thisx->world.pos.x, thisx->world.pos.y, thisx->world.pos.z, + 0, rotY, 0, (OBJMAKEKINSUTA_GET_1F(thisx) << 2) | 0xFF01); + if (actor != NULL) { + actor->parent = thisx; + if (rotCheck) { + actor->velocity.y = 10.0f; + actor->speedXZ = 3.0f; + } else { + speedXZ = sqrtf((destVec.x * destVec.x) + (destVec.z * destVec.z)); + actor->velocity.y = (4 * destVec.y) + 4.0f; + actor->speedXZ = (2 * speedXZ) + 2.0f; + } + } +} + +void ObjMakekinsuta_Update(Actor* thisx, PlayState* play) { + ObjMakekinsuta* this = THIS; + + if (Flags_GetSwitch(play, OBJMAKEKINSUTA_GET_SWITCH_FLAGS(thisx))) { + this->actor.update = func_8099FD7C; + ActorCutscene_SetIntentToPlay(this->actor.cutscene); + } else { + if (this->unk144 >= 0) { + if (this->unk144 == 0) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_STALGOLD_ROLL); + if (Rand_ZeroOne() < 0.1f) { + this->unk144 = Rand_S16Offset(0x28, 0x50); + } else { + this->unk144 = 8; + } + } else { + this->unk144--; + } + } + } +} + +void func_8099FD7C(Actor* thisx, PlayState* play) { + if (ActorCutscene_GetCanPlayNext(thisx->cutscene)) { + ActorCutscene_StartAndSetUnkLinkFields(thisx->cutscene, thisx); + if (thisx->cutscene >= 0) { + func_800B7298(play, thisx, 4); + } + func_8099FB64(thisx, play); + thisx->update = Actor_Noop; + thisx->flags &= ~ACTOR_FLAG_10; + } else { + ActorCutscene_SetIntentToPlay(thisx->cutscene); + } +} diff --git a/src/overlays/actors/ovl_Obj_Makekinsuta/z_obj_makekinsuta.h b/src/overlays/actors/ovl_Obj_Makekinsuta/z_obj_makekinsuta.h index 57c855179..d5bc998f0 100644 --- a/src/overlays/actors/ovl_Obj_Makekinsuta/z_obj_makekinsuta.h +++ b/src/overlays/actors/ovl_Obj_Makekinsuta/z_obj_makekinsuta.h @@ -5,9 +5,14 @@ struct ObjMakekinsuta; +#define OBJMAKEKINSUTA_GET_1F(thisx) (((thisx)->params >> 8) & 0x1F) +#define OBJMAKEKINSUTA_GETS_3(params) ((params & 3) & 0xFF) +#define OBJMAKEKINSUTA_GETS_3FC(params) (((params & 0x3FC) >> 2) & 0xFF) +#define OBJMAKEKINSUTA_GET_SWITCH_FLAGS(thisx) ((thisx)->params & 0x7F) + typedef struct ObjMakekinsuta { /* 0x000 */ Actor actor; - /* 0x144 */ char unk_144[0x4]; + /* 0x144 */ s8 unk144; } ObjMakekinsuta; // size = 0x148 extern const ActorInit Obj_Makekinsuta_InitVars; 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 1645f8469..b5f9d67b2 100644 --- a/src/overlays/actors/ovl_Obj_Makeoshihiki/z_obj_makeoshihiki.c +++ b/src/overlays/actors/ovl_Obj_Makeoshihiki/z_obj_makeoshihiki.c @@ -10,8 +10,8 @@ #define THIS ((ObjMakeoshihiki*)thisx) -void ObjMakeoshihiki_Init(Actor* thisx, GlobalContext* globalCtx); -void ObjMakeoshihiki_Update(Actor* thisx, GlobalContext* globalCtx); +void ObjMakeoshihiki_Init(Actor* thisx, PlayState* play); +void ObjMakeoshihiki_Update(Actor* thisx, PlayState* play); const ActorInit Obj_Makeoshihiki_InitVars = { ACTOR_OBJ_MAKEOSHIHIKI, @@ -25,54 +25,54 @@ const ActorInit Obj_Makeoshihiki_InitVars = { (ActorFunc)NULL, }; -s32 ObjMakeoshihiki_GetChildSpawnPointIndex(ObjMakeoshihiki* this, GlobalContext* globalCtx) { +s32 ObjMakeoshihiki_GetChildSpawnPointIndex(ObjMakeoshihiki* this, PlayState* play) { s32 pad; - s32 pathIndexOffset1 = Flags_GetSwitch(globalCtx, OBJMAKEOSHIHIKI_GET_SWITCHFLAG_1(this)) ? 1 : 0; - s32 pathIndexOffset2 = Flags_GetSwitch(globalCtx, OBJMAKEOSHIHIKI_GET_SWITCHFLAG_2(this)) ? 2 : 0; + s32 pathIndexOffset1 = Flags_GetSwitch(play, OBJMAKEOSHIHIKI_GET_SWITCHFLAG_1(&this->actor)) ? 1 : 0; + s32 pathIndexOffset2 = Flags_GetSwitch(play, OBJMAKEOSHIHIKI_GET_SWITCHFLAG_2(&this->actor)) ? 2 : 0; return pathIndexOffset1 + pathIndexOffset2; } -void ObjMakeoshihiki_SetSwitchFlags(ObjMakeoshihiki* this, GlobalContext* globalCtx, s32 pathIndex) { +void ObjMakeoshihiki_SetSwitchFlags(ObjMakeoshihiki* this, PlayState* play, s32 pathIndex) { s32 pad; s32 pad2; s32 switchFlag1; s32 switchFlag2; - switchFlag2 = OBJMAKEOSHIHIKI_GET_SWITCHFLAG_2(this); - switchFlag1 = OBJMAKEOSHIHIKI_GET_SWITCHFLAG_1(this); + switchFlag2 = OBJMAKEOSHIHIKI_GET_SWITCHFLAG_2(&this->actor); + switchFlag1 = OBJMAKEOSHIHIKI_GET_SWITCHFLAG_1(&this->actor); if (pathIndex & 2) { - Flags_SetSwitch(globalCtx, switchFlag2); + Flags_SetSwitch(play, switchFlag2); } else { - Flags_UnsetSwitch(globalCtx, switchFlag2); + Flags_UnsetSwitch(play, switchFlag2); } if (pathIndex & 1) { - Flags_SetSwitch(globalCtx, switchFlag1); + Flags_SetSwitch(play, switchFlag1); } else { - Flags_UnsetSwitch(globalCtx, switchFlag1); + Flags_UnsetSwitch(play, switchFlag1); } } -void ObjMakeoshihiki_Init(Actor* thisx, GlobalContext* globalCtx) { +void ObjMakeoshihiki_Init(Actor* thisx, PlayState* play) { ObjMakeoshihiki* this = THIS; Vec3s* childPoint; Path* path; s32 childPointIndex; - path = &globalCtx->setupPathList[OBJMAKEOSHIHIKI_GET_PATHLISTINDEX(this)]; + path = &play->setupPathList[OBJMAKEOSHIHIKI_GET_PATHLISTINDEX(&this->actor)]; this->pathPoints = Lib_SegmentedToVirtual(path->points); this->pathCount = path->count; - childPointIndex = ObjMakeoshihiki_GetChildSpawnPointIndex(this, globalCtx); + childPointIndex = ObjMakeoshihiki_GetChildSpawnPointIndex(this, play); childPoint = &this->pathPoints[childPointIndex]; - if (Actor_SpawnAsChild(&globalCtx->actorCtx, &this->actor, globalCtx, ACTOR_OBJ_OSHIHIKI, childPoint->x, - childPoint->y, childPoint->z, 0, 0, 0, 0xFFF1) == NULL) { + if (Actor_SpawnAsChild(&play->actorCtx, &this->actor, play, ACTOR_OBJ_OSHIHIKI, childPoint->x, childPoint->y, + childPoint->z, 0, 0, 0, 0xFFF1) == NULL) { Actor_MarkForDeath(&this->actor); } } -void ObjMakeoshihiki_Update(Actor* thisx, GlobalContext* globalCtx) { +void ObjMakeoshihiki_Update(Actor* thisx, PlayState* play) { ObjMakeoshihiki* this = THIS; Actor* child; s32 loopPathIndex; @@ -86,7 +86,7 @@ void ObjMakeoshihiki_Update(Actor* thisx, GlobalContext* globalCtx) { for (loopPathIndex = 0; loopPathIndex < this->pathCount; loopPathIndex++) { Math_Vec3s_ToVec3f(&pathPointF, &this->pathPoints[loopPathIndex]); if (Math3D_Vec3fDistSq(&this->actor.child->world.pos, &pathPointF) < SQ(0.5f)) { - ObjMakeoshihiki_SetSwitchFlags(this, globalCtx, loopPathIndex); + ObjMakeoshihiki_SetSwitchFlags(this, play, loopPathIndex); return; } } diff --git a/src/overlays/actors/ovl_Obj_Makeoshihiki/z_obj_makeoshihiki.h b/src/overlays/actors/ovl_Obj_Makeoshihiki/z_obj_makeoshihiki.h index 708da99d6..8a419c550 100644 --- a/src/overlays/actors/ovl_Obj_Makeoshihiki/z_obj_makeoshihiki.h +++ b/src/overlays/actors/ovl_Obj_Makeoshihiki/z_obj_makeoshihiki.h @@ -5,9 +5,9 @@ struct ObjMakeoshihiki; -#define OBJMAKEOSHIHIKI_GET_PATHLISTINDEX(this) (((this)->actor.params >> 7) & 0x7F) -#define OBJMAKEOSHIHIKI_GET_SWITCHFLAG_1(this) ((this)->actor.home.rot.z & 0x7F) -#define OBJMAKEOSHIHIKI_GET_SWITCHFLAG_2(this) ((this)->actor.params & 0x7F) +#define OBJMAKEOSHIHIKI_GET_PATHLISTINDEX(thisx) (((thisx)->params >> 7) & 0x7F) +#define OBJMAKEOSHIHIKI_GET_SWITCHFLAG_1(thisx) ((thisx)->home.rot.z & 0x7F) +#define OBJMAKEOSHIHIKI_GET_SWITCHFLAG_2(thisx) ((thisx)->params & 0x7F) typedef struct ObjMakeoshihiki { /* 0x000 */ Actor actor; 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 a32f791bc..99745be7c 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 @@ -11,10 +11,10 @@ #define THIS ((ObjMilkBin*)thisx) -void ObjMilkBin_Init(Actor* thisx, GlobalContext* globalCtx); -void ObjMilkBin_Destroy(Actor* thisx, GlobalContext* globalCtx); -void ObjMilkBin_Update(Actor* thisx, GlobalContext* globalCtx); -void ObjMilkBin_Draw(Actor* thisx, GlobalContext* globalCtx); +void ObjMilkBin_Init(Actor* thisx, PlayState* play); +void ObjMilkBin_Destroy(Actor* thisx, PlayState* play); +void ObjMilkBin_Update(Actor* thisx, PlayState* play); +void ObjMilkBin_Draw(Actor* thisx, PlayState* play); const ActorInit Obj_Milk_Bin_InitVars = { ACTOR_OBJ_MILK_BIN, @@ -48,10 +48,10 @@ static ColliderCylinderInit sCylinderInit = { { 12, 30, 0, { 0, 0, 0 } }, }; -void ObjMilkBin_Init(Actor* thisx, GlobalContext* globalCtx) { +void ObjMilkBin_Init(Actor* thisx, PlayState* play) { ObjMilkBin* this = THIS; - Collider_InitAndSetCylinder(globalCtx, &this->collider, &this->actor, &sCylinderInit); + Collider_InitAndSetCylinder(play, &this->collider, &this->actor, &sCylinderInit); Collider_UpdateCylinder(&this->actor, &this->collider); this->actor.shape.yOffset = 1100.0f; @@ -63,14 +63,14 @@ void ObjMilkBin_Init(Actor* thisx, GlobalContext* globalCtx) { } } -void ObjMilkBin_Destroy(Actor* thisx, GlobalContext* globalCtx) { +void ObjMilkBin_Destroy(Actor* thisx, PlayState* play) { ObjMilkBin* this = THIS; - Collider_DestroyCylinder(globalCtx, &this->collider); + Collider_DestroyCylinder(play, &this->collider); } -void ObjMilkBin_Update(Actor* thisx, GlobalContext* globalCtx2) { - GlobalContext* globalCtx = globalCtx2; +void ObjMilkBin_Update(Actor* thisx, PlayState* play2) { + PlayState* play = play2; ObjMilkBin* this = THIS; if (this->type == OBJ_MILK_BIN_TYPE_1) { @@ -89,15 +89,15 @@ void ObjMilkBin_Update(Actor* thisx, GlobalContext* globalCtx2) { } if (!(this->disableDraw & 1)) { - CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); - CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + CollisionCheck_SetAC(play, &play->colChkCtx, &this->collider.base); + CollisionCheck_SetOC(play, &play->colChkCtx, &this->collider.base); } } -void ObjMilkBin_Draw(Actor* thisx, GlobalContext* globalCtx) { +void ObjMilkBin_Draw(Actor* thisx, PlayState* play) { ObjMilkBin* this = THIS; if (!(this->disableDraw & 1)) { - Gfx_DrawDListOpa(globalCtx, gMilkBinMilkJarDL); + Gfx_DrawDListOpa(play, gMilkBinMilkJarDL); } } diff --git a/src/overlays/actors/ovl_Obj_Milk_Bin/z_obj_milk_bin.h b/src/overlays/actors/ovl_Obj_Milk_Bin/z_obj_milk_bin.h index 6bba9c014..c5f313661 100644 --- a/src/overlays/actors/ovl_Obj_Milk_Bin/z_obj_milk_bin.h +++ b/src/overlays/actors/ovl_Obj_Milk_Bin/z_obj_milk_bin.h @@ -7,7 +7,7 @@ struct ObjMilkBin; typedef struct ObjMilkBin { /* 0x000 */ Actor actor; - /* 0x144 */ char unk_144[0x4]; + /* 0x144 */ UNK_TYPE1 unk_144[0x4]; /* 0x148 */ ColliderCylinder collider; /* 0x194 */ s32 disableDraw; /* 0x198 */ s32 type; diff --git a/src/overlays/actors/ovl_Obj_Mine/z_obj_mine.c b/src/overlays/actors/ovl_Obj_Mine/z_obj_mine.c index c2b644cef..1d4403c14 100644 --- a/src/overlays/actors/ovl_Obj_Mine/z_obj_mine.c +++ b/src/overlays/actors/ovl_Obj_Mine/z_obj_mine.c @@ -11,28 +11,28 @@ #define THIS ((ObjMine*)thisx) -void ObjMine_Init(Actor* thisx, GlobalContext* globalCtx); -void ObjMine_Destroy(Actor* thisx, GlobalContext* globalCtx); -void ObjMine_Update(Actor* thisx, GlobalContext* globalCtx); -void ObjMine_Draw(Actor* thisx, GlobalContext* globalCtx); +void ObjMine_Init(Actor* thisx, PlayState* play); +void ObjMine_Destroy(Actor* thisx, PlayState* play); +void ObjMine_Update(Actor* thisx, PlayState* play); +void ObjMine_Draw(Actor* thisx, PlayState* play); void func_80A82F84(ObjMine* this); -void func_80A82F98(ObjMine* this, GlobalContext* globalCtx); +void func_80A82F98(ObjMine* this, PlayState* play); void func_80A82FA8(ObjMine* this); -void func_80A82FC8(ObjMine* this, GlobalContext* globalCtx); -void func_80A83258(ObjMine* this, GlobalContext* globalCtx); +void func_80A82FC8(ObjMine* this, PlayState* play); +void func_80A83258(ObjMine* this, PlayState* play); void func_80A832BC(ObjMine* this); -void func_80A832D0(ObjMine* this, GlobalContext* globalCtx); +void func_80A832D0(ObjMine* this, PlayState* play); void func_80A83A74(ObjMine* this); -void func_80A83A88(ObjMine* this, GlobalContext* globalCtx); +void func_80A83A88(ObjMine* this, PlayState* play); void func_80A83B14(ObjMine* this); -void func_80A83B28(ObjMine* this, GlobalContext* globalCtx); +void func_80A83B28(ObjMine* this, PlayState* play); void func_80A83CEC(ObjMine* this); -void func_80A83D00(ObjMine* this, GlobalContext* globalCtx); -void func_80A83E7C(Actor* thisx, GlobalContext* globalCtx); -void func_80A83FBC(Actor* thisx, GlobalContext* globalCtx); -void func_80A84088(Actor* thisx, GlobalContext* globalCtx); -void func_80A84338(Actor* thisx, GlobalContext* globalCtx); +void func_80A83D00(ObjMine* this, PlayState* play); +void func_80A83E7C(Actor* thisx, PlayState* play); +void func_80A83FBC(Actor* thisx, PlayState* play); +void func_80A84088(Actor* thisx, PlayState* play); +void func_80A84338(Actor* thisx, PlayState* play); extern Gfx D_06000030[]; extern Gfx D_06002068[]; @@ -75,7 +75,7 @@ static ColliderJntSphInit sJntSphInit = { OC2_TYPE_1, COLSHAPE_JNTSPH, }, - 1, + ARRAY_COUNT(sJntSphElementsInit), sJntSphElementsInit, }; @@ -130,8 +130,8 @@ s32 func_80A81288(Vec3f* arg0, Vec3f* arg1, f32* arg2, f32* arg3) { return true; } -void func_80A8131C(ObjMine* this, GlobalContext* globalCtx) { - EnBom* bomb = (EnBom*)Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_BOM, this->actor.world.pos.x, +void func_80A8131C(ObjMine* this, PlayState* play) { + EnBom* bomb = (EnBom*)Actor_Spawn(&play->actorCtx, play, ACTOR_EN_BOM, this->actor.world.pos.x, this->actor.world.pos.y - 15.0f, this->actor.world.pos.z, 0, 0, 0, 0); if (bomb != NULL) { @@ -139,12 +139,12 @@ void func_80A8131C(ObjMine* this, GlobalContext* globalCtx) { } } -void func_80A81384(ObjMine* this, GlobalContext* globalCtx) { +void func_80A81384(ObjMine* this, PlayState* play) { f32 x = this->collider.elements[0].dim.worldSphere.center.x; f32 y = this->collider.elements[0].dim.worldSphere.center.y - 15.0f; f32 z = this->collider.elements[0].dim.worldSphere.center.z; - EnBom* bom = (EnBom*)Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_BOM, x, y, z, 0, 0, 0, 0); + EnBom* bom = (EnBom*)Actor_Spawn(&play->actorCtx, play, ACTOR_EN_BOM, x, y, z, 0, 0, 0, 0); if (bom != NULL) { bom->timer = 0; @@ -198,11 +198,11 @@ void func_80A81544(ObjMine* this, Vec3f* arg1) { Actor* temp_v1 = this->collider.base.ac; if ((element->info.acHitInfo->toucher.dmgFlags & 0x13820)) { - Matrix_StatePush(); - Matrix_RotateY(temp_v1->shape.rot.y, MTXMODE_NEW); - Matrix_InsertXRotation_s(temp_v1->shape.rot.x, MTXMODE_APPLY); - Matrix_GetStateTranslationAndScaledZ(1.0f, arg1); - Matrix_StatePop(); + Matrix_Push(); + Matrix_RotateYS(temp_v1->shape.rot.y, MTXMODE_NEW); + Matrix_RotateXS(temp_v1->shape.rot.x, MTXMODE_APPLY); + Matrix_MultVecZ(1.0f, arg1); + Matrix_Pop(); } else { Vec3f sp20; @@ -215,6 +215,7 @@ void func_80A81544(ObjMine* this, Vec3f* arg1) { } } #else +void func_80A81544(ObjMine* this, Vec3f* arg1); #pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Mine/func_80A81544.s") #endif @@ -222,7 +223,7 @@ void func_80A81640(ObjMine* this) { } void func_80A8164C(Vec3f* arg0) { - MtxF* matrix = Matrix_GetCurrentState(); + MtxF* matrix = Matrix_GetCurrent(); matrix->mf[3][0] = arg0->x; matrix->mf[3][1] = arg0->y; @@ -230,7 +231,7 @@ void func_80A8164C(Vec3f* arg0) { } void func_80A81684(ObjMineUnkStruct* arg0) { - MtxF* matrix = Matrix_GetCurrentState(); + MtxF* matrix = Matrix_GetCurrent(); matrix->mf[0][0] = arg0->unk_00.x; matrix->mf[0][1] = arg0->unk_00.y; @@ -264,18 +265,18 @@ s32 func_80A81714(Vec3f* arg0, Vec3f* arg1, f32 arg2) { return true; } - Matrix_StatePush(); + Matrix_Push(); Math_Vec3f_Copy(&sp30, arg0); Math3D_CrossProduct(arg0, arg1, &sp3C); if (func_80A8120C(&sp3C, &sp24)) { - Matrix_InsertRotationAroundUnitVector_s(arg2 * 10430.378f, &sp24, MTXMODE_NEW); - Matrix_MultiplyVector3fByState(&sp30, arg0); + Matrix_RotateAxisS(arg2 * 10430.378f, &sp24, MTXMODE_NEW); + Matrix_MultVec3f(&sp30, arg0); } else { - Matrix_SetStateXRotation(arg2); - Matrix_MultiplyVector3fByState(&sp30, arg0); + Matrix_RotateXFNew(arg2); + Matrix_MultVec3f(&sp30, arg0); } - Matrix_StatePop(); + Matrix_Pop(); return false; } @@ -318,7 +319,7 @@ void func_80A81868(ObjMine* this, s32 arg1) { } void func_80A819A4(ObjMine* this, s32 arg1) { - 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); Collider_UpdateSpheres(0, &this->collider); } @@ -407,7 +408,7 @@ void func_80A81B7C(ObjMine* this, s32 arg1) { } void func_80A81D70(ObjMine* this, s32 arg1) { - Matrix_InsertTranslation(this->actor.home.pos.x, this->actor.home.pos.y + (arg1 * 12.0f) + 10.0f, + Matrix_Translate(this->actor.home.pos.x, this->actor.home.pos.y + (arg1 * 12.0f) + 10.0f, this->actor.home.pos.z, MTXMODE_NEW); Matrix_Scale(this->actor.scale.x, this->actor.scale.y, this->actor.scale.z, MTXMODE_APPLY); Collider_UpdateSpheres(0, &this->collider); @@ -428,7 +429,7 @@ void func_80A81DEC(ObjMine* this) { } } -void func_80A81E7C(ObjMine* this, GlobalContext* globalCtx) { +void func_80A81E7C(ObjMine* this, PlayState* play) { ObjMineUnkStruct* temp_v1 = &this->unk_1B8; s32 pad; Vec3f sp7C; @@ -455,7 +456,7 @@ void func_80A81E7C(ObjMine* this, GlobalContext* globalCtx) { sp7C.x = this->actor.home.pos.x; sp7C.y = this->actor.world.pos.y; sp7C.z = this->actor.home.pos.z; - if (BgCheck_EntityLineTest1(&globalCtx->colCtx, &sp7C, &sp70, &sp64, &sp48, 1, 0, 0, 1, &sp44)) { + if (BgCheck_EntityLineTest1(&play->colCtx, &sp7C, &sp70, &sp64, &sp48, 1, 0, 0, 1, &sp44)) { *(s8*)(&temp_v1->unk_40) = 1; temp_v1->unk_38 = sp4C.x * -0.2f; temp_v1->unk_3C = sp4C.z * -0.2f; @@ -548,13 +549,13 @@ void func_80A828A8(ObjMine* this) { void func_80A81FFC(ObjMine* this); -void func_80A82C28(ObjMine* this, GlobalContext* globalCtx) { - func_80A81E7C(this, globalCtx); +void func_80A82C28(ObjMine* this, PlayState* play) { + func_80A81E7C(this, play); func_80A81FFC(this); func_80A828A8(this); } -void ObjMine_Init(Actor* thisx, GlobalContext* globalCtx) { +void ObjMine_Init(Actor* thisx, PlayState* play) { ObjMine* this = THIS; s32 pad; s32 sp44 = this->actor.params & 0xFF; @@ -566,8 +567,8 @@ void ObjMine_Init(Actor* thisx, GlobalContext* globalCtx) { Actor_ProcessInitChain(&this->actor, sInitChain); this->actor.shape.rot.z = 0; this->actor.world.rot.z = 0; - Collider_InitJntSph(globalCtx, &this->collider); - Collider_SetJntSph(globalCtx, &this->collider, &this->actor, &sJntSphInit, this->colliderElements); + Collider_InitJntSph(play, &this->collider); + Collider_SetJntSph(play, &this->collider, &this->actor, &sJntSphInit, this->colliderElements); if (sp38 == 0) { ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 45.0f); @@ -576,18 +577,18 @@ void ObjMine_Init(Actor* thisx, GlobalContext* globalCtx) { if (sp44 == 0xFF) { func_80A82F84(this); } else { - path = &globalCtx->setupPathList[sp44]; + path = &play->setupPathList[sp44]; this->unk_1B0 = 0; this->unk_1AC = path->count - 1; this->unk_1B4 = (Vec3s*)Lib_SegmentedToVirtual(path->points); func_80A811D0(this, this->unk_1B0); func_80A82FA8(this); } - Matrix_SetStateRotationAndTranslation(this->actor.world.pos.x, this->actor.world.pos.y, this->actor.world.pos.z, + 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); - this->actor.floorHeight = BgCheck_EntityRaycastFloor5(&globalCtx->colCtx, &this->actor.floorPoly, &sp3C, + this->actor.floorHeight = BgCheck_EntityRaycastFloor5(&play->colCtx, &this->actor.floorPoly, &sp3C, &this->actor, &this->actor.world.pos); } else { sp34 = this->actor.params & 0x3F; @@ -602,7 +603,7 @@ void ObjMine_Init(Actor* thisx, GlobalContext* globalCtx) { func_80A81868(this, sp34); this->actor.world.pos.y = (-10.0f - (sp34 * 12.0f)) + this->actor.home.pos.y; func_80A819A4(this, sp34); - func_800B4AEC(globalCtx, &this->actor, 0.0f); + func_800B4AEC(play, &this->actor, 0.0f); if (sp34 == 0) { func_80A83A74(this); } else { @@ -622,17 +623,17 @@ void ObjMine_Init(Actor* thisx, GlobalContext* globalCtx) { } } -void ObjMine_Destroy(Actor* thisx, GlobalContext* globalCtx) { +void ObjMine_Destroy(Actor* thisx, PlayState* play) { ObjMine* this = THIS; - Collider_DestroyJntSph(globalCtx, &this->collider); + Collider_DestroyJntSph(play, &this->collider); } void func_80A82F84(ObjMine* this) { this->actionFunc = func_80A82F98; } -void func_80A82F98(ObjMine* this, GlobalContext* globalCtx) { +void func_80A82F98(ObjMine* this, PlayState* play) { } void func_80A82FA8(ObjMine* this) { @@ -642,7 +643,7 @@ void func_80A82FA8(ObjMine* this) { #ifdef NON_MATCHING // stack -void func_80A82FC8(ObjMine* this, GlobalContext* globalCtx) { +void func_80A82FC8(ObjMine* this, PlayState* play) { f32 phi_f0; Vec3f spA0; f32 sp9C; @@ -681,18 +682,18 @@ void func_80A82FC8(ObjMine* this, GlobalContext* globalCtx) { func_80A811D0(this, this->unk_1B0); } - this->actor.floorHeight = BgCheck_EntityRaycastFloor5(&globalCtx->colCtx, &this->actor.floorPoly, &sp90, + this->actor.floorHeight = BgCheck_EntityRaycastFloor5(&play->colCtx, &this->actor.floorPoly, &sp90, &this->actor, &this->actor.world.pos); if (this->actor.flags & 0x40) { Math3D_CrossProduct(&D_80A845D0[0], &this->actor.velocity, &sp78); if (func_80A8120C(&sp78, &sp84)) { - Matrix_InsertRotationAroundUnitVector_f(this->actor.speedXZ * 0.03125f, &sp84, 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(&sp38); - func_8018219C(&sp38, &this->actor.shape.rot, 0); + Matrix_RotateAxisF(this->actor.speedXZ * 0.03125f, &sp84, 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(&sp38); + Matrix_MtxFToYXZRot(&sp38, &this->actor.shape.rot, 0); } } } @@ -710,7 +711,7 @@ void func_80A83214(ObjMine* this) { this->actionFunc = func_80A83258; } -void func_80A83258(ObjMine* this, GlobalContext* globalCtx) { +void func_80A83258(ObjMine* this, PlayState* play) { this->actor.scale.x *= 1.8f; if (this->actor.scale.x > 0.17495999f) { Actor_MarkForDeath(&this->actor); @@ -724,14 +725,14 @@ void func_80A832BC(ObjMine* this) { this->actionFunc = func_80A832D0; } -void func_80A832D0(ObjMine* this, GlobalContext* globalCtx) { +void func_80A832D0(ObjMine* this, PlayState* play) { s32 pad; s32 spA0 = this->actor.params & 0x3F; ObjMineUnkStruct* unkStruct = &this->unk_1B8; Math_Vec3f_Copy(&unkStruct->unk_24, &unkStruct->unk_0C); if (func_80A8140C(this)) { - func_80A81384(this, globalCtx); + func_80A81384(this, play); func_80A81640(this); func_80A83214(this); } else { @@ -796,7 +797,7 @@ void func_80A832D0(ObjMine* this, GlobalContext* globalCtx) { if ((unkStruct->unk_5C > -0.000001f) && (unkStruct->unk_5C <= Math3D_XZDistanceSquared(this->actor.world.pos.x, this->actor.world.pos.z, this->actor.home.pos.x, this->actor.home.pos.z))) { - Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 0.0f, 20.0f, 0.0f, 1); + Actor_UpdateBgCheckInfo(play, &this->actor, 0.0f, 20.0f, 0.0f, 1); if (this->actor.bgCheckFlags & 8) { if (this->actor.wallPoly != NULL) { @@ -837,10 +838,10 @@ void func_80A832D0(ObjMine* this, GlobalContext* globalCtx) { temp->unk_00 += temp->unk_02; } - func_800B4AEC(globalCtx, &this->actor, 0.0f); + func_800B4AEC(play, &this->actor, 0.0f); func_80A81818(this); - CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); - CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + CollisionCheck_SetOC(play, &play->colChkCtx, &this->collider.base); + CollisionCheck_SetAC(play, &play->colChkCtx, &this->collider.base); } } @@ -848,14 +849,14 @@ void func_80A83A74(ObjMine* this) { this->actionFunc = func_80A83A88; } -void func_80A83A88(ObjMine* this, GlobalContext* globalCtx) { +void func_80A83A88(ObjMine* this, PlayState* play) { if (func_80A8140C(this)) { - func_80A81384(this, globalCtx); + func_80A81384(this, play); func_80A81640(this); func_80A83214(this); } else { - CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); - CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + CollisionCheck_SetOC(play, &play->colChkCtx, &this->collider.base); + CollisionCheck_SetAC(play, &play->colChkCtx, &this->collider.base); } } @@ -863,12 +864,12 @@ void func_80A83B14(ObjMine* this) { this->actionFunc = func_80A83B28; } -void func_80A83B28(ObjMine* this, GlobalContext* globalCtx) { +void func_80A83B28(ObjMine* this, PlayState* play) { ObjMineUnkStruct* ptr; s16 rand; if (func_80A8140C(this)) { - func_80A81384(this, globalCtx); + func_80A81384(this, play); func_80A81640(this); func_80A83214(this); return; @@ -897,95 +898,95 @@ void func_80A83B28(ObjMine* this, GlobalContext* globalCtx) { *(s16*)((u8*)ptr + 0x20) = (u32)Rand_Next() >> 0x13; } - func_80A82C28(this, globalCtx); + func_80A82C28(this, play); func_80A81DEC(this); func_80A81818(this); - CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); - CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + CollisionCheck_SetOC(play, &play->colChkCtx, &this->collider.base); + CollisionCheck_SetAC(play, &play->colChkCtx, &this->collider.base); } void func_80A83CEC(ObjMine* this) { this->actionFunc = func_80A83D00; } -void func_80A83D00(ObjMine* this, GlobalContext* globalCtx) { +void func_80A83D00(ObjMine* this, PlayState* play) { if (func_80A8140C(this)) { - func_80A81384(this, globalCtx); + func_80A81384(this, play); func_80A81640(this); func_80A83214(this); } else { - CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); - CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + CollisionCheck_SetOC(play, &play->colChkCtx, &this->collider.base); + CollisionCheck_SetAC(play, &play->colChkCtx, &this->collider.base); } } -void ObjMine_Update(Actor* thisx, GlobalContext* globalCtx) { +void ObjMine_Update(Actor* thisx, PlayState* play) { s32 pad; ObjMine* this = THIS; if ((this->collider.base.ocFlags2 & OC2_HIT_PLAYER) || (this->collider.base.acFlags & AC_HIT)) { - func_80A8131C(this, globalCtx); + func_80A8131C(this, play); func_80A83214(this); } - this->actionFunc(this, globalCtx); + this->actionFunc(this, play); if (this->actor.update != NULL) { this->collider.base.ocFlags1 &= ~OC1_HIT; this->collider.base.acFlags &= ~AC_HIT; this->collider.base.ocFlags2 &= ~OC2_HIT_PLAYER; if ((this->actor.flags & 0x40) && (this->actionFunc != func_80A83258)) { - CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); - CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + CollisionCheck_SetOC(play, &play->colChkCtx, &this->collider.base); + CollisionCheck_SetAC(play, &play->colChkCtx, &this->collider.base); } } } -void func_80A83E7C(Actor* thisx, GlobalContext* globalCtx) { +void func_80A83E7C(Actor* thisx, PlayState* play) { ObjMine* this = THIS; - this->actionFunc(this, globalCtx); + this->actionFunc(this, play); } -void ObjMine_Draw(Actor* thisx, GlobalContext* globalCtx) { +void ObjMine_Draw(Actor* thisx, PlayState* play) { s32 pad; ObjMine* this = THIS; - OPEN_DISPS(globalCtx->state.gfxCtx); + OPEN_DISPS(play->state.gfxCtx); if (this->actionFunc == func_80A82FC8) { Collider_UpdateSpheres(0, &this->collider); } - func_800B8050(&this->actor, globalCtx, 1); - func_8012C28C(globalCtx->state.gfxCtx); + func_800B8050(&this->actor, play, 1); + func_8012C28C(play->state.gfxCtx); - gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gDPSetRenderMode(POLY_OPA_DISP++, G_RM_PASS, G_RM_AA_ZB_OPA_SURF2); gDPSetEnvColor(POLY_OPA_DISP++, 0, 0, 0, 255); gSPDisplayList(POLY_OPA_DISP++, D_06002068); gSPDisplayList(POLY_OPA_DISP++, D_06002188); - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->state.gfxCtx); } -void func_80A83FBC(Actor* thisx, GlobalContext* globalCtx) { +void func_80A83FBC(Actor* thisx, PlayState* play) { ObjMine* this = THIS; - OPEN_DISPS(globalCtx->state.gfxCtx); + OPEN_DISPS(play->state.gfxCtx); - func_800B8118(&this->actor, globalCtx, 1); - func_8012C2DC(globalCtx->state.gfxCtx); + func_800B8118(&this->actor, play, 1); + func_8012C2DC(play->state.gfxCtx); gDPSetRenderMode(POLY_XLU_DISP++, G_RM_PASS, G_RM_AA_ZB_XLU_SURF2); gDPSetEnvColor(POLY_XLU_DISP++, 0, 0, 0, 75); - gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_XLU_DISP++, D_06002068); - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->state.gfxCtx); } -void func_80A84088(Actor* thisx, GlobalContext* globalCtx) { +void func_80A84088(Actor* thisx, PlayState* play) { ObjMine* this = THIS; s32 temp_s5 = this->actor.params & 0x3F; ObjMineUnkStruct3* temp; @@ -996,13 +997,13 @@ void func_80A84088(Actor* thisx, GlobalContext* globalCtx) { Vec3f sp88; Gfx* gfx; - func_800B8050(&this->actor, globalCtx, 1); + func_800B8050(&this->actor, play, 1); - OPEN_DISPS(globalCtx->state.gfxCtx); + OPEN_DISPS(play->state.gfxCtx); gfx = POLY_OPA_DISP; gSPDisplayList(gfx++, &sSetupDL[6 * 25]); - gSPMatrix(gfx++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPMatrix(gfx++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(gfx++, D_06000030); func_80A81684(ptr); @@ -1015,21 +1016,21 @@ void func_80A84088(Actor* thisx, GlobalContext* globalCtx) { Math_Vec3f_ScaleAndStore(&ptr->unk_0C, -12.0f, &sp88); for (i = 0, temp = &ptr->unk_60[0]; i < temp_s5; i++, temp++) { - Matrix_RotateY(temp->unk_00, MTXMODE_APPLY); + Matrix_RotateYS(temp->unk_00, MTXMODE_APPLY); sp94.x += sp88.x; sp94.y += sp88.y; sp94.z += sp88.z; func_80A8164C(&sp94); - gSPMatrix(gfx++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPMatrix(gfx++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(gfx++, D_06000030); } } - Matrix_InsertXRotation_s(0x2000, MTXMODE_APPLY); + Matrix_RotateXS(0x2000, MTXMODE_APPLY); func_80A8164C(&this->actor.world.pos); - gSPMatrix(gfx++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPMatrix(gfx++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gDPPipeSync(gfx++); gDPSetRenderMode(gfx++, G_RM_PASS, G_RM_AA_ZB_OPA_SURF2); gDPSetEnvColor(gfx++, 0, 0, 0, 255); @@ -1038,10 +1039,10 @@ void func_80A84088(Actor* thisx, GlobalContext* globalCtx) { POLY_OPA_DISP = gfx; - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->state.gfxCtx); } -void func_80A84338(Actor* thisx, GlobalContext* globalCtx) { +void func_80A84338(Actor* thisx, PlayState* play) { ObjMine* this = THIS; s32 temp_s7 = this->actor.params & 0x3F; s32 i; @@ -1049,31 +1050,31 @@ void func_80A84338(Actor* thisx, GlobalContext* globalCtx) { ObjMineUnkStruct2* temp; s32 pad[2]; - func_800B8050(&this->actor, globalCtx, 1); + func_800B8050(&this->actor, play, 1); - OPEN_DISPS(globalCtx->state.gfxCtx); + OPEN_DISPS(play->state.gfxCtx); gfx = POLY_OPA_DISP; gSPDisplayList(gfx++, &sSetupDL[6 * 25]); - gSPMatrix(gfx++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPMatrix(gfx++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(gfx++, D_06000030); for (i = 0, temp = (ObjMineUnkStruct2*)((u8*)this + 0x1FC); i < temp_s7; i++, temp++) { func_80A81684((ObjMineUnkStruct*)temp); Matrix_Scale(this->actor.scale.x, this->actor.scale.y, this->actor.scale.z, 1); if ((i & 1) == 0) { - Matrix_RotateY(0x4000, 1); + Matrix_RotateYS(0x4000, MTXMODE_APPLY); } func_80A8164C(&temp->unk_24); - gSPMatrix(gfx++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPMatrix(gfx++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(gfx++, D_06000030); } - Matrix_InsertXRotation_s(0x2000, 1); + Matrix_RotateXS(0x2000, 1); func_80A8164C(&this->actor.world.pos); - gSPMatrix(gfx++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPMatrix(gfx++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gDPPipeSync(gfx++); gDPSetRenderMode(gfx++, G_RM_PASS, G_RM_AA_ZB_OPA_SURF2); gDPSetEnvColor(gfx++, 0, 0, 0, 255); @@ -1082,5 +1083,5 @@ void func_80A84338(Actor* thisx, GlobalContext* globalCtx) { POLY_OPA_DISP = gfx; - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->state.gfxCtx); } diff --git a/src/overlays/actors/ovl_Obj_Mine/z_obj_mine.h b/src/overlays/actors/ovl_Obj_Mine/z_obj_mine.h index af2772fda..be5f1bb58 100644 --- a/src/overlays/actors/ovl_Obj_Mine/z_obj_mine.h +++ b/src/overlays/actors/ovl_Obj_Mine/z_obj_mine.h @@ -5,7 +5,7 @@ struct ObjMine; -typedef void (*ObjMineActionFunc)(struct ObjMine*, GlobalContext*); +typedef void (*ObjMineActionFunc)(struct ObjMine*, PlayState*); // definitely fake typedef struct { 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 546f0db16..31ba1fa63 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 @@ -11,19 +11,19 @@ #define THIS ((ObjMoonStone*)thisx) -void ObjMoonStone_Init(Actor* thisx, GlobalContext* globalCtx); -void ObjMoonStone_Destroy(Actor* thisx, GlobalContext* globalCtx); -void ObjMoonStone_Update(Actor* thisx, GlobalContext* globalCtx); -void ObjMoonStone_Draw(Actor* thisx, GlobalContext* globalCtx); +void ObjMoonStone_Init(Actor* thisx, PlayState* play); +void ObjMoonStone_Destroy(Actor* thisx, PlayState* play); +void ObjMoonStone_Update(Actor* thisx, PlayState* play); +void ObjMoonStone_Draw(Actor* thisx, PlayState* play); void func_80C0662C(ObjMoonStone* this); -void func_80C06640(ObjMoonStone* this, GlobalContext* globalCtx); +void func_80C06640(ObjMoonStone* this, PlayState* play); void func_80C066F8(ObjMoonStone* this); -void func_80C0670C(ObjMoonStone* this, GlobalContext* globalCtx); +void func_80C0670C(ObjMoonStone* this, PlayState* play); void func_80C0673C(ObjMoonStone* this); -void func_80C06768(ObjMoonStone* this, GlobalContext* globalCtx); +void func_80C06768(ObjMoonStone* this, PlayState* play); void func_80C0685C(ObjMoonStone* this); -void func_80C06870(ObjMoonStone* this, GlobalContext* globalCtx); +void func_80C06870(ObjMoonStone* this, PlayState* play); const ActorInit Obj_Moon_Stone_InitVars = { ACTOR_OBJ_MOON_STONE, @@ -37,7 +37,7 @@ const ActorInit Obj_Moon_Stone_InitVars = { (ActorFunc)ObjMoonStone_Draw, }; -void ObjMoonStone_Init(Actor* thisx, GlobalContext* globalCtx) { +void ObjMoonStone_Init(Actor* thisx, PlayState* play) { ObjMoonStone* this = THIS; Actor_SetScale(&this->actor, 0.3f); @@ -51,7 +51,7 @@ void ObjMoonStone_Init(Actor* thisx, GlobalContext* globalCtx) { func_80C0662C(this); } 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, + Actor_Spawn(&play->actorCtx, play, 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; @@ -61,26 +61,26 @@ void ObjMoonStone_Init(Actor* thisx, GlobalContext* globalCtx) { } } -void ObjMoonStone_Destroy(Actor* thisx, GlobalContext* globalCtx) { +void ObjMoonStone_Destroy(Actor* thisx, PlayState* play) { } void func_80C0662C(ObjMoonStone* this) { this->actionFunc = func_80C06640; } -void func_80C06640(ObjMoonStone* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); +void func_80C06640(ObjMoonStone* this, PlayState* play) { + Player* player = GET_PLAYER(play); s16 sp1A = this->actor.yawTowardsPlayer - 0x8000; sp1A -= player->actor.shape.rot.y; - if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { + if (Actor_ProcessTalkRequest(&this->actor, &play->state)) { this->actor.colChkInfo.health = 1; - Message_StartTextbox(globalCtx, 0x5E3U, &this->actor); + Message_StartTextbox(play, 0x5E3, &this->actor); func_80C066F8(this); } else { s32 phi_v0 = ABS_ALT(sp1A); if (phi_v0 < 0x1555) { - func_800B8614(&this->actor, globalCtx, 80.0f); + func_800B8614(&this->actor, play, 80.0f); } } } @@ -89,8 +89,8 @@ void func_80C066F8(ObjMoonStone* this) { this->actionFunc = func_80C0670C; } -void func_80C0670C(ObjMoonStone* this, GlobalContext* globalCtx) { - if (Actor_TextboxIsClosing(&this->actor, globalCtx)) { +void func_80C0670C(ObjMoonStone* this, PlayState* play) { + if (Actor_TextboxIsClosing(&this->actor, play)) { this->actor.colChkInfo.health = 0; func_80C0662C(this); } @@ -103,21 +103,21 @@ void func_80C0673C(ObjMoonStone* this) { this->actionFunc = func_80C06768; } -void func_80C06768(ObjMoonStone* this, GlobalContext* globalCtx) { +void func_80C06768(ObjMoonStone* this, PlayState* play) { 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, + Actor_Spawn(&play->actorCtx, play, 1, this->actor.world.pos.x, this->actor.world.pos.y, this->actor.world.pos.z, 0, 0, 0, -1); } } if (this->actor.draw) { - if (Actor_HasParent(&this->actor, globalCtx)) { + if (Actor_HasParent(&this->actor, play)) { this->actor.parent = NULL; this->actor.draw = NULL; func_80C0685C(this); } else if (this->actor.xzDistToPlayer < 25.0f) { - Actor_PickUp(&this->actor, globalCtx, GI_MOON_TEAR, 100.0f, 30.0f); + Actor_PickUp(&this->actor, play, GI_MOON_TEAR, 100.0f, 30.0f); } } } @@ -126,33 +126,33 @@ void func_80C0685C(ObjMoonStone* this) { this->actionFunc = func_80C06870; } -void func_80C06870(ObjMoonStone* this, GlobalContext* globalCtx) { - if (Message_GetState(&globalCtx->msgCtx) == 6 && Message_ShouldAdvance(globalCtx)) { +void func_80C06870(ObjMoonStone* this, PlayState* play) { + if ((Message_GetState(&play->msgCtx) == TEXT_STATE_DONE) && Message_ShouldAdvance(play)) { gSaveContext.save.weekEventReg[74] |= 0x40; Actor_MarkForDeath(&this->actor); } } -void ObjMoonStone_Update(Actor* thisx, GlobalContext* globalCtx) { +void ObjMoonStone_Update(Actor* thisx, PlayState* play) { ObjMoonStone* this = THIS; - Player* player = GET_PLAYER(globalCtx); + Player* player = GET_PLAYER(play); if (!(player->stateFlags1 & 0x10000282)) { - this->actionFunc(this, globalCtx); + this->actionFunc(this, play); } } -void ObjMoonStone_Draw(Actor* thisx, GlobalContext* globalCtx) { - GraphicsContext* gfxCtx = globalCtx->state.gfxCtx; +void ObjMoonStone_Draw(Actor* thisx, PlayState* play) { + GraphicsContext* gfxCtx = play->state.gfxCtx; - OPEN_DISPS(globalCtx->state.gfxCtx); - func_8012C28C(globalCtx->state.gfxCtx); - func_8012C2DC(globalCtx->state.gfxCtx); - 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); - 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); + OPEN_DISPS(play->state.gfxCtx); + func_8012C28C(play->state.gfxCtx); + func_8012C2DC(play->state.gfxCtx); + AnimatedMat_Draw(play, Lib_SegmentedToVirtual(gGiMoonsTearTexAnim)); + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_OPA_DISP++, gGiMoonsTearItemDL); + Matrix_ReplaceRotation(&play->billboardMtxF); + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_XLU_DISP++, gGiMoonsTearGlowDL); + CLOSE_DISPS(play->state.gfxCtx); } diff --git a/src/overlays/actors/ovl_Obj_Moon_Stone/z_obj_moon_stone.h b/src/overlays/actors/ovl_Obj_Moon_Stone/z_obj_moon_stone.h index 079038497..375d40fad 100644 --- a/src/overlays/actors/ovl_Obj_Moon_Stone/z_obj_moon_stone.h +++ b/src/overlays/actors/ovl_Obj_Moon_Stone/z_obj_moon_stone.h @@ -5,11 +5,11 @@ struct ObjMoonStone; -typedef void (*ObjMoonStoneActionFunc)(struct ObjMoonStone*, GlobalContext*); +typedef void (*ObjMoonStoneActionFunc)(struct ObjMoonStone*, PlayState*); typedef struct ObjMoonStone { /* 0x000 */ Actor actor; - /* 0x144 */ char unk_144[0x4C]; + /* 0x144 */ UNK_TYPE1 unk_144[0x4C]; /* 0x190 */ ObjMoonStoneActionFunc actionFunc; /* 0x194 */ s16 unk194; } ObjMoonStone; // size = 0x198 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 f81b4fe47..3b1b72f2f 100644 --- a/src/overlays/actors/ovl_Obj_Mu_Pict/z_obj_mu_pict.c +++ b/src/overlays/actors/ovl_Obj_Mu_Pict/z_obj_mu_pict.c @@ -10,20 +10,20 @@ #define THIS ((ObjMuPict*)thisx) -void ObjMuPict_Init(Actor* thisx, GlobalContext* globalCtx); -void ObjMuPict_Destroy(Actor* thisx, GlobalContext* globalCtx); -void ObjMuPict_Update(Actor* thisx, GlobalContext* globalCtx); -void ObjMuPict_Draw(Actor* thisx, GlobalContext* globalCtx); +void ObjMuPict_Init(Actor* thisx, PlayState* play); +void ObjMuPict_Destroy(Actor* thisx, PlayState* play); +void ObjMuPict_Update(Actor* thisx, PlayState* play); +void ObjMuPict_Draw(Actor* thisx, PlayState* play); void func_80C06B5C(ObjMuPict* this); -void func_80C06B70(ObjMuPict* this, GlobalContext* globalCtx); +void func_80C06B70(ObjMuPict* this, PlayState* play); void func_80C06C54(ObjMuPict* this); -void func_80C06C68(ObjMuPict* this, GlobalContext* globalCtx); +void func_80C06C68(ObjMuPict* this, PlayState* play); void func_80C06CC4(ObjMuPict* this); -void func_80C06CD8(ObjMuPict* this, GlobalContext* globalCtx); -void func_80C06D90(ObjMuPict* this, GlobalContext* globalCtx); -void func_80C06DC8(ObjMuPict* this, GlobalContext* globalCtx); -void func_80C06E88(ObjMuPict* this, GlobalContext* globalCtx); +void func_80C06CD8(ObjMuPict* this, PlayState* play); +void func_80C06D90(ObjMuPict* this, PlayState* play); +void func_80C06DC8(ObjMuPict* this, PlayState* play); +void func_80C06E88(ObjMuPict* this, PlayState* play); const ActorInit Obj_Mu_Pict_InitVars = { ACTOR_OBJ_MU_PICT, @@ -37,15 +37,15 @@ const ActorInit Obj_Mu_Pict_InitVars = { (ActorFunc)ObjMuPict_Draw, }; -void ObjMuPict_Init(Actor* thisx, GlobalContext* globalCtx) { +void ObjMuPict_Init(Actor* thisx, PlayState* play) { ObjMuPict* this = THIS; if (!(gSaveContext.save.weekEventReg[75] & 0x20) && !(gSaveContext.save.weekEventReg[52] & 0x20)) { Actor_MarkForDeath(&this->actor); } - func_80C06D90(this, globalCtx); - this->unk14A = UNK_ACTOR_PARAM; + func_80C06D90(this, play); + this->unk14A = OBJMUPICT_GET_F000(&this->actor); this->actor.targetMode = 6; this->actor.focus.pos = this->actor.world.pos; this->actor.focus.pos.y += 30.0f; @@ -53,30 +53,30 @@ void ObjMuPict_Init(Actor* thisx, GlobalContext* globalCtx) { func_80C06B5C(this); } -void ObjMuPict_Destroy(Actor* thisx, GlobalContext* globalCtx) { +void ObjMuPict_Destroy(Actor* thisx, PlayState* play) { } void func_80C06B5C(ObjMuPict* this) { this->actionFunc = func_80C06B70; } -void func_80C06B70(ObjMuPict* this, GlobalContext* globalCtx) { +void func_80C06B70(ObjMuPict* this, PlayState* play) { s16 yawDiff = this->actor.yawTowardsPlayer - this->actor.world.rot.y; - if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { + if (Actor_ProcessTalkRequest(&this->actor, &play->state)) { if (this->actor.cutscene < 0) { - func_80C06DC8(this, globalCtx); + func_80C06DC8(this, play); func_80C06CC4(this); } else { if (ActorCutscene_GetCurrentIndex() == 0x7C) { ActorCutscene_Stop(0x7C); } ActorCutscene_SetIntentToPlay(this->actor.cutscene); - func_80C06DC8(this, globalCtx); + func_80C06DC8(this, play); func_80C06C54(this); } } else if (ABS_ALT(yawDiff) < 0x2AAA) { - func_800B8614(&this->actor, globalCtx, 80.0f); + func_800B8614(&this->actor, play, 80.0f); } } @@ -84,7 +84,7 @@ void func_80C06C54(ObjMuPict* this) { this->actionFunc = func_80C06C68; } -void func_80C06C68(ObjMuPict* this, GlobalContext* globalCtx) { +void func_80C06C68(ObjMuPict* this, PlayState* play) { if (ActorCutscene_GetCanPlayNext(this->actor.cutscene)) { ActorCutscene_Start(this->actor.cutscene, &this->actor); func_80C06CC4(this); @@ -97,19 +97,21 @@ void func_80C06CC4(ObjMuPict* this) { this->actionFunc = func_80C06CD8; } -void func_80C06CD8(ObjMuPict* this, GlobalContext* globalCtx) { - switch (Message_GetState(&globalCtx->msgCtx)) { - case 0: - case 1: - case 2: - case 3: - case 4: +void func_80C06CD8(ObjMuPict* this, PlayState* play) { + switch (Message_GetState(&play->msgCtx)) { + case TEXT_STATE_NONE: + case TEXT_STATE_1: + case TEXT_STATE_CLOSING: + case TEXT_STATE_3: + case TEXT_STATE_CHOICE: break; - case 5: - func_80C06E88(this, globalCtx); + + case TEXT_STATE_5: + func_80C06E88(this, play); break; - case 6: - if (Message_ShouldAdvance(globalCtx)) { + + case TEXT_STATE_DONE: + if (Message_ShouldAdvance(play)) { func_80C06B5C(this); if (this->actor.cutscene >= 0) { ActorCutscene_Stop(this->actor.cutscene); @@ -121,8 +123,8 @@ void func_80C06CD8(ObjMuPict* this, GlobalContext* globalCtx) { this->actor.parent->shape.rot.y = this->actor.parent->world.rot.y; } -void func_80C06D90(ObjMuPict* this, GlobalContext* globalCtx) { - Actor* actorPtr = globalCtx->actorCtx.actorLists[ACTORCAT_NPC].first; +void func_80C06D90(ObjMuPict* this, PlayState* play) { + Actor* actorPtr = play->actorCtx.actorLists[ACTORCAT_NPC].first; while (actorPtr != NULL) { if (actorPtr->id == ACTOR_EN_HGO) { @@ -133,65 +135,65 @@ void func_80C06D90(ObjMuPict* this, GlobalContext* globalCtx) { } } -void func_80C06DC8(ObjMuPict* this, GlobalContext* globalCtx) { +void func_80C06DC8(ObjMuPict* this, PlayState* play) { if (this->unk14A == 0) { if (this->unk148 == 0) { this->unk148 = 1; - Message_StartTextbox(globalCtx, 0x159A, &this->actor); + Message_StartTextbox(play, 0x159A, &this->actor); this->textId = 0x159A; } else { - Message_StartTextbox(globalCtx, 0x159D, &this->actor); + Message_StartTextbox(play, 0x159D, &this->actor); this->textId = 0x159D; } } else if (this->unk148 == 0) { this->unk148 = 1; - Message_StartTextbox(globalCtx, 0x15A0, &this->actor); + Message_StartTextbox(play, 0x15A0, &this->actor); this->textId = 0x15A0; } else { - Message_StartTextbox(globalCtx, 0x15A3, &this->actor); + Message_StartTextbox(play, 0x15A3, &this->actor); this->textId = 0x15A3; } } -void func_80C06E88(ObjMuPict* this, GlobalContext* globalCtx) { - if (Message_ShouldAdvance(globalCtx)) { +void func_80C06E88(ObjMuPict* this, PlayState* play) { + if (Message_ShouldAdvance(play)) { switch (this->textId) { case 0x159A: - Message_StartTextbox(globalCtx, 0x159B, &this->actor); + Message_StartTextbox(play, 0x159B, &this->actor); this->textId = 0x159B; break; case 0x159B: - Message_StartTextbox(globalCtx, 0x159C, &this->actor); + Message_StartTextbox(play, 0x159C, &this->actor); this->textId = 0x159C; break; case 0x159D: - Message_StartTextbox(globalCtx, 0x159E, &this->actor); + Message_StartTextbox(play, 0x159E, &this->actor); this->textId = 0x159E; break; case 0x159E: - Message_StartTextbox(globalCtx, 0x159F, &this->actor); + Message_StartTextbox(play, 0x159F, &this->actor); this->textId = 0x159F; break; case 0x15A0: - Message_StartTextbox(globalCtx, 0x15A1, &this->actor); + Message_StartTextbox(play, 0x15A1, &this->actor); this->textId = 0x15A1; break; case 0x15A1: - Message_StartTextbox(globalCtx, 0x15A2, &this->actor); + Message_StartTextbox(play, 0x15A2, &this->actor); this->textId = 0x15A2; break; case 0x15A3: - Message_StartTextbox(globalCtx, 0x15A4, &this->actor); + Message_StartTextbox(play, 0x15A4, &this->actor); this->textId = 0x15A4; break; } } } -void ObjMuPict_Update(Actor* thisx, GlobalContext* globalCtx) { +void ObjMuPict_Update(Actor* thisx, PlayState* play) { ObjMuPict* this = THIS; - this->actionFunc(this, globalCtx); + this->actionFunc(this, play); } -void ObjMuPict_Draw(Actor* thisx, GlobalContext* globalCtx) { +void ObjMuPict_Draw(Actor* thisx, PlayState* play) { } diff --git a/src/overlays/actors/ovl_Obj_Mu_Pict/z_obj_mu_pict.h b/src/overlays/actors/ovl_Obj_Mu_Pict/z_obj_mu_pict.h index eceebab1c..f5417d9db 100644 --- a/src/overlays/actors/ovl_Obj_Mu_Pict/z_obj_mu_pict.h +++ b/src/overlays/actors/ovl_Obj_Mu_Pict/z_obj_mu_pict.h @@ -5,9 +5,9 @@ struct ObjMuPict; -#define UNK_ACTOR_PARAM ((this->actor.params & 0xF000) >> 0xC) +#define OBJMUPICT_GET_F000(thisx) (((thisx)->params & 0xF000) >> 0xC) -typedef void (*ObjMuPictActionFunc)(struct ObjMuPict*, GlobalContext*); +typedef void (*ObjMuPictActionFunc)(struct ObjMuPict*, PlayState*); typedef struct ObjMuPict { /* 0x000 */ Actor actor; 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 b24354482..9a8072edd 100644 --- a/src/overlays/actors/ovl_Obj_Mure/z_obj_mure.c +++ b/src/overlays/actors/ovl_Obj_Mure/z_obj_mure.c @@ -10,15 +10,15 @@ #define THIS ((ObjMure*)thisx) -void ObjMure_Init(Actor* thisx, GlobalContext* globalCtx); -void ObjMure_Destroy(Actor* thisx, GlobalContext* globalCtx); -void ObjMure_Update(Actor* thisx, GlobalContext* globalCtx); +void ObjMure_Init(Actor* thisx, PlayState* play); +void ObjMure_Destroy(Actor* thisx, PlayState* play); +void ObjMure_Update(Actor* thisx, PlayState* play); -void ObjMure_InitialAction(ObjMure* this, GlobalContext* globalCtx); -void ObjMure_CulledState(ObjMure* this, GlobalContext* globalCtx); -void ObjMure_ActiveState(ObjMure* this, GlobalContext* globalCtx); -void ObjMure_KillActors(ObjMure* this, GlobalContext* globalCtx); -void ObjMure_CheckChildren(ObjMure* this, GlobalContext* globalCtx); +void ObjMure_InitialAction(ObjMure* this, PlayState* play); +void ObjMure_CulledState(ObjMure* this, PlayState* play); +void ObjMure_ActiveState(ObjMure* this, PlayState* play); +void ObjMure_KillActors(ObjMure* this, PlayState* play); +void ObjMure_CheckChildren(ObjMure* this, PlayState* play); const ActorInit Obj_Mure_InitVars = { ACTOR_OBJ_MURE, @@ -72,7 +72,7 @@ typedef enum { /* 2 */ OBJMURE_CHILD_STATE_2 } ObjMureChildState; -s32 func_808D78D0(ObjMure* this, GlobalContext* globalCtx) { +s32 func_808D78D0(ObjMure* this, PlayState* play) { if (this->type == OBJMURE_TYPE_FISH || this->type == OBJMURE_TYPE_BUGS || this->type == OBJMURE_TYPE_BUTTERFLY) { Actor_ProcessInitChain(&this->actor, sInitChain); } else { @@ -81,20 +81,20 @@ s32 func_808D78D0(ObjMure* this, GlobalContext* globalCtx) { return true; } -s32 func_808D7928(ObjMure* this, GlobalContext* globalCtx) { - if (!func_808D78D0(this, globalCtx)) { +s32 func_808D7928(ObjMure* this, PlayState* play) { + if (!func_808D78D0(this, play)) { return false; } return true; } -void ObjMure_Init(Actor* thisx, GlobalContext* globalCtx) { +void ObjMure_Init(Actor* thisx, PlayState* play) { ObjMure* this = THIS; - this->chNum = OBJ_MURE_GET_CHNUM(this->actor.params); - this->ptn = OBJ_MURE_GET_PTN(this->actor.params); - this->svNum = OBJ_MURE_GET_SVNUM(this->actor.params); - this->type = OBJ_MURE_GET_TYPE(this->actor.params); + this->chNum = OBJ_MURE_GET_CHNUM(&this->actor); + this->ptn = OBJ_MURE_GET_PTN(&this->actor); + this->svNum = OBJ_MURE_GET_SVNUM(&this->actor); + this->type = OBJ_MURE_GET_TYPE(&this->actor); if (this->ptn >= 4) { Actor_MarkForDeath(&this->actor); return; @@ -103,14 +103,14 @@ void ObjMure_Init(Actor* thisx, GlobalContext* globalCtx) { Actor_MarkForDeath(&this->actor); return; } - if (!func_808D7928(this, globalCtx)) { + if (!func_808D7928(this, play)) { Actor_MarkForDeath(&this->actor); return; } this->actionFunc = ObjMure_InitialAction; } -void ObjMure_Destroy(Actor* thisx, GlobalContext* globalCtx) { +void ObjMure_Destroy(Actor* thisx, PlayState* play) { } s32 ObjMure_GetMaxChildSpawns(ObjMure* this) { @@ -124,7 +124,7 @@ void ObjMure_GetSpawnPos(Vec3f* outPos, Vec3f* inPos, s32 ptn, s32 idx) { *outPos = *inPos; } -void ObjMure_SpawnActors0(Actor* thisx, GlobalContext* globalCtx) { +void ObjMure_SpawnActors0(Actor* thisx, PlayState* play) { ObjMure* this = THIS; s32 i; Vec3f pos; @@ -138,9 +138,9 @@ void ObjMure_SpawnActors0(Actor* thisx, GlobalContext* globalCtx) { case OBJMURE_CHILD_STATE_2: ObjMure_GetSpawnPos(&pos, &this->actor.world.pos, this->ptn, i); this->children[i] = Actor_SpawnAsChildAndCutscene( - &globalCtx->actorCtx, globalCtx, sSpawnActorIds[this->type], pos.x, pos.y, pos.z, - this->actor.world.rot.x, this->actor.world.rot.y, this->actor.world.rot.z, sSpawnParams[this->type], - this->actor.cutscene, this->actor.unk20, NULL); + &play->actorCtx, play, sSpawnActorIds[this->type], pos.x, pos.y, pos.z, this->actor.world.rot.x, + this->actor.world.rot.y, this->actor.world.rot.z, sSpawnParams[this->type], this->actor.cutscene, + this->actor.unk20, NULL); if (this->children[i] != NULL) { if (this->type == 0x90) { ((ObjMureChild*)this->children[i])->unk_197 = 1; @@ -151,9 +151,9 @@ void ObjMure_SpawnActors0(Actor* thisx, GlobalContext* globalCtx) { default: ObjMure_GetSpawnPos(&pos, &this->actor.world.pos, this->ptn, i); this->children[i] = Actor_SpawnAsChildAndCutscene( - &globalCtx->actorCtx, globalCtx, sSpawnActorIds[this->type], pos.x, pos.y, pos.z, - this->actor.world.rot.x, this->actor.world.rot.y, this->actor.world.rot.z, sSpawnParams[this->type], - this->actor.cutscene, this->actor.unk20, NULL); + &play->actorCtx, play, sSpawnActorIds[this->type], pos.x, pos.y, pos.z, this->actor.world.rot.x, + this->actor.world.rot.y, this->actor.world.rot.z, sSpawnParams[this->type], this->actor.cutscene, + this->actor.unk20, NULL); if (this->children[i] != NULL) { this->children[i]->room = this->actor.room; } @@ -162,8 +162,8 @@ void ObjMure_SpawnActors0(Actor* thisx, GlobalContext* globalCtx) { } } -void ObjMure_SpawnActors1(ObjMure* this, GlobalContext* globalCtx2) { - GlobalContext* globalCtx = globalCtx2; +void ObjMure_SpawnActors1(ObjMure* this, PlayState* play2) { + PlayState* play = play2; Actor* actor = &this->actor; Vec3f spawnPos; s32 maxChildren = ObjMure_GetMaxChildSpawns(this); @@ -172,8 +172,8 @@ void ObjMure_SpawnActors1(ObjMure* this, GlobalContext* globalCtx2) { for (i = 0; i < maxChildren; i++) { ObjMure_GetSpawnPos(&spawnPos, &actor->world.pos, this->ptn, i); this->children[i] = Actor_SpawnAsChildAndCutscene( - &globalCtx2->actorCtx, globalCtx, sSpawnActorIds[this->type], spawnPos.x, spawnPos.y, spawnPos.z, - actor->world.rot.x, actor->world.rot.y, actor->world.rot.z, + &play2->actorCtx, play, sSpawnActorIds[this->type], spawnPos.x, spawnPos.y, spawnPos.z, actor->world.rot.x, + actor->world.rot.y, actor->world.rot.z, (this->type == OBJMURE_TYPE_BUTTERFLY && i == 0) ? 1 : sSpawnParams[this->type], this->actor.cutscene, this->actor.unk20, NULL); if (this->children[i] != NULL) { @@ -185,18 +185,18 @@ void ObjMure_SpawnActors1(ObjMure* this, GlobalContext* globalCtx2) { } } -void ObjMure_SpawnActors(ObjMure* this, GlobalContext* globalCtx) { +void ObjMure_SpawnActors(ObjMure* this, PlayState* play) { switch (this->svNum) { case 0: - ObjMure_SpawnActors0(&this->actor, globalCtx); + ObjMure_SpawnActors0(&this->actor, play); break; case 1: - ObjMure_SpawnActors1(this, globalCtx); + ObjMure_SpawnActors1(this, play); break; } } -void ObjMure_KillActorsImpl(ObjMure* this, GlobalContext* globalCtx) { +void ObjMure_KillActorsImpl(ObjMure* this, PlayState* play) { s32 maxChildren = ObjMure_GetMaxChildSpawns(this); s32 i; @@ -213,7 +213,7 @@ void ObjMure_KillActorsImpl(ObjMure* this, GlobalContext* globalCtx) { break; default: if (this->children[i] != NULL) { - if (Actor_HasParent(this->children[i], globalCtx)) { + if (Actor_HasParent(this->children[i], play)) { this->children[i] = NULL; } else { Actor_MarkForDeath(this->children[i]); @@ -225,11 +225,11 @@ void ObjMure_KillActorsImpl(ObjMure* this, GlobalContext* globalCtx) { } } -void ObjMure_KillActors(ObjMure* this, GlobalContext* globalCtx) { - ObjMure_KillActorsImpl(this, globalCtx); +void ObjMure_KillActors(ObjMure* this, PlayState* play) { + ObjMure_KillActorsImpl(this, play); } -void ObjMure_CheckChildren(ObjMure* this, GlobalContext* globalCtx) { +void ObjMure_CheckChildren(ObjMure* this, PlayState* play) { s32 maxChildren = ObjMure_GetMaxChildSpawns(this); s32 i; @@ -252,15 +252,15 @@ void ObjMure_CheckChildren(ObjMure* this, GlobalContext* globalCtx) { } } -void ObjMure_InitialAction(ObjMure* this, GlobalContext* globalCtx) { +void ObjMure_InitialAction(ObjMure* this, PlayState* play) { this->actionFunc = ObjMure_CulledState; } -void ObjMure_CulledState(ObjMure* this, GlobalContext* globalCtx) { +void ObjMure_CulledState(ObjMure* this, PlayState* play) { if (fabsf(this->actor.projectedPos.z) < sZClip[this->type]) { this->actionFunc = ObjMure_ActiveState; this->actor.flags |= ACTOR_FLAG_10; - ObjMure_SpawnActors(this, globalCtx); + ObjMure_SpawnActors(this, play); } } @@ -310,7 +310,7 @@ void ObjMure_SetChildToFollowPlayer(ObjMure* this, s32 idx1) { } // Fish, Bugs -void ObjMure_GroupBehavior0(ObjMure* this, GlobalContext* globalCtx) { +void ObjMure_GroupBehavior0(ObjMure* this, PlayState* play) { if (this->unk_19C <= 0) { if (this->unk_19E) { this->unk_19E = false; @@ -344,7 +344,7 @@ void ObjMure_GroupBehavior0(ObjMure* this, GlobalContext* globalCtx) { } // Butterflies -void ObjMure_GroupBehavior1(ObjMure* this, GlobalContext* globalCtx) { +void ObjMure_GroupBehavior1(ObjMure* this, PlayState* play) { s32 maxChildren; s32 i; @@ -378,22 +378,22 @@ static ObjMureActionFunc sTypeGroupBehaviorFunc[] = { NULL, NULL, ObjMure_GroupBehavior0, ObjMure_GroupBehavior0, ObjMure_GroupBehavior1, }; -void ObjMure_ActiveState(ObjMure* this, GlobalContext* globalCtx) { - ObjMure_CheckChildren(this, globalCtx); +void ObjMure_ActiveState(ObjMure* this, PlayState* play) { + ObjMure_CheckChildren(this, play); if (sZClip[this->type] + 40.0f <= fabsf(this->actor.projectedPos.z)) { this->actionFunc = ObjMure_CulledState; this->actor.flags &= ~ACTOR_FLAG_10; - ObjMure_KillActors(this, globalCtx); + ObjMure_KillActors(this, play); } else if (sTypeGroupBehaviorFunc[this->type] != NULL) { - sTypeGroupBehaviorFunc[this->type](this, globalCtx); + sTypeGroupBehaviorFunc[this->type](this, play); } } -void ObjMure_Update(Actor* thisx, GlobalContext* globalCtx) { +void ObjMure_Update(Actor* thisx, PlayState* play) { ObjMure* this = THIS; if (this->unk_19C > 0) { this->unk_19C--; } - this->actionFunc(this, globalCtx); + this->actionFunc(this, play); } diff --git a/src/overlays/actors/ovl_Obj_Mure/z_obj_mure.h b/src/overlays/actors/ovl_Obj_Mure/z_obj_mure.h index 1cb9a653a..bc3669697 100644 --- a/src/overlays/actors/ovl_Obj_Mure/z_obj_mure.h +++ b/src/overlays/actors/ovl_Obj_Mure/z_obj_mure.h @@ -5,35 +5,35 @@ struct ObjMure; -typedef void (*ObjMureActionFunc)(struct ObjMure*, GlobalContext*); +typedef void (*ObjMureActionFunc)(struct ObjMure*, PlayState*); #define OBJMURE_MAX_SPAWNS 15 typedef struct { - Actor actor; - /* 0x144 */ char unk_144[0x53]; + /* 0x000 */ Actor actor; + /* 0x144 */ UNK_TYPE1 unk_144[0x53]; /* 0x197 */ u8 unk_197; -} ObjMureChild; +} ObjMureChild; // size = 0x198 typedef struct ObjMure { - /* 0x0000 */ Actor actor; - /* 0x0144 */ ObjMureActionFunc actionFunc; - /* 0x0148 */ s16 chNum; - /* 0x014A */ s16 ptn; - /* 0x014C */ s16 svNum; - /* 0x014E */ s16 type; - /* 0x0150 */ Actor* children[OBJMURE_MAX_SPAWNS]; - /* 0x018C */ u8 childrenStates[OBJMURE_MAX_SPAWNS]; - /* 0x019C */ s16 unk_19C; - /* 0x019E */ s16 unk_19E; - /* 0x01A0 */ s16 unk_1A0; + /* 0x000 */ Actor actor; + /* 0x144 */ ObjMureActionFunc actionFunc; + /* 0x148 */ s16 chNum; + /* 0x14A */ s16 ptn; + /* 0x14C */ s16 svNum; + /* 0x14E */ s16 type; + /* 0x150 */ Actor* children[OBJMURE_MAX_SPAWNS]; + /* 0x18C */ u8 childrenStates[OBJMURE_MAX_SPAWNS]; + /* 0x19C */ s16 unk_19C; + /* 0x19E */ s16 unk_19E; + /* 0x1A0 */ s16 unk_1A0; } ObjMure; // size = 0x1A4 extern const ActorInit Obj_Mure_InitVars; -#define OBJ_MURE_GET_CHNUM(params) ((params >> 12) & 0xF) -#define OBJ_MURE_GET_PTN(params) ((params >> 8) & 0x7) -#define OBJ_MURE_GET_SVNUM(params) ((params >> 5) & 0x3) -#define OBJ_MURE_GET_TYPE(params) (params & 0x1F) +#define OBJ_MURE_GET_CHNUM(thisx) (((thisx)->params >> 12) & 0xF) +#define OBJ_MURE_GET_PTN(thisx) (((thisx)->params >> 8) & 0x7) +#define OBJ_MURE_GET_SVNUM(thisx) (((thisx)->params >> 5) & 0x3) +#define OBJ_MURE_GET_TYPE(thisx) ((thisx)->params & 0x1F) #endif // Z_OBJ_MURE_H diff --git a/src/overlays/actors/ovl_Obj_Mure2/z_obj_mure2.c b/src/overlays/actors/ovl_Obj_Mure2/z_obj_mure2.c index 49101b746..31c5b50aa 100644 --- a/src/overlays/actors/ovl_Obj_Mure2/z_obj_mure2.c +++ b/src/overlays/actors/ovl_Obj_Mure2/z_obj_mure2.c @@ -10,12 +10,12 @@ #define THIS ((ObjMure2*)thisx) -void ObjMure2_Init(Actor* thisx, GlobalContext* globalCtx); -void ObjMure2_Update(Actor* thisx, GlobalContext* globalCtx); +void ObjMure2_Init(Actor* thisx, PlayState* play); +void ObjMure2_Update(Actor* thisx, PlayState* play); -void func_809613C4(ObjMure2* this, GlobalContext* globalCtx); -void func_809613FC(ObjMure2* this, GlobalContext* globalCtx); -void func_80961490(ObjMure2* this, GlobalContext* globalCtx); +void func_809613C4(ObjMure2* this, PlayState* play); +void func_809613FC(ObjMure2* this, PlayState* play); +void func_80961490(ObjMure2* this, PlayState* play); #if 0 const ActorInit Obj_Mure2_InitVars = { diff --git a/src/overlays/actors/ovl_Obj_Mure2/z_obj_mure2.h b/src/overlays/actors/ovl_Obj_Mure2/z_obj_mure2.h index b306e2552..bf13c3fbc 100644 --- a/src/overlays/actors/ovl_Obj_Mure2/z_obj_mure2.h +++ b/src/overlays/actors/ovl_Obj_Mure2/z_obj_mure2.h @@ -5,12 +5,12 @@ struct ObjMure2; -typedef void (*ObjMure2ActionFunc)(struct ObjMure2*, GlobalContext*); +typedef void (*ObjMure2ActionFunc)(struct ObjMure2*, PlayState*); typedef struct ObjMure2 { - /* 0x0000 */ Actor actor; - /* 0x0144 */ ObjMure2ActionFunc actionFunc; - /* 0x0148 */ char unk_148[0x38]; + /* 0x000 */ Actor actor; + /* 0x144 */ ObjMure2ActionFunc actionFunc; + /* 0x148 */ char unk_148[0x38]; } ObjMure2; // size = 0x180 extern const ActorInit Obj_Mure2_InitVars; diff --git a/src/overlays/actors/ovl_Obj_Mure3/z_obj_mure3.c b/src/overlays/actors/ovl_Obj_Mure3/z_obj_mure3.c index bdeb9c702..edefba93a 100644 --- a/src/overlays/actors/ovl_Obj_Mure3/z_obj_mure3.c +++ b/src/overlays/actors/ovl_Obj_Mure3/z_obj_mure3.c @@ -10,15 +10,17 @@ #define THIS ((ObjMure3*)thisx) -void ObjMure3_Init(Actor* thisx, GlobalContext* globalCtx); -void ObjMure3_Destroy(Actor* thisx, GlobalContext* globalCtx); -void ObjMure3_Update(Actor* thisx, GlobalContext* globalCtx); +void ObjMure3_Init(Actor* thisx, PlayState* play); +void ObjMure3_Destroy(Actor* thisx, PlayState* play); +void ObjMure3_Update(Actor* thisx, PlayState* play); -void func_8098F5AC(ObjMure3* this, GlobalContext* globalCtx); -void func_8098F5E4(ObjMure3* this, GlobalContext* globalCtx); -void func_8098F680(ObjMure3* this, GlobalContext* globalCtx); +void func_8098F598(ObjMure3* this); +void func_8098F5AC(ObjMure3* this, PlayState* play); +void func_8098F5D0(ObjMure3* this); +void func_8098F5E4(ObjMure3* this, PlayState* play); +void func_8098F66C(ObjMure3* this); +void func_8098F680(ObjMure3* this, PlayState* play); -#if 0 const ActorInit Obj_Mure3_InitVars = { ACTOR_OBJ_MURE3, ACTORCAT_BG, @@ -31,41 +33,168 @@ const ActorInit Obj_Mure3_InitVars = { (ActorFunc)NULL, }; -// static InitChainEntry sInitChain[] = { -static InitChainEntry D_8098F748[] = { +static s16 sRupeeCounts[] = { 5, 5, 7, 0 }; + +static InitChainEntry sInitChain[] = { ICHAIN_F32(uncullZoneForward, 100, ICHAIN_CONTINUE), ICHAIN_F32(uncullZoneScale, 1800, ICHAIN_CONTINUE), ICHAIN_F32(uncullZoneDownward, 100, ICHAIN_STOP), }; -#endif +void func_8098F040(ObjMure3* this, PlayState* play) { + s32 i; + Vec3f spawnPos; -extern InitChainEntry D_8098F748[]; + Math_Vec3f_Copy(&spawnPos, &this->actor.world.pos); + for (i = 0; i < 5; i++, spawnPos.y += 20.0f) { + if (!((this->unk164 >> i) & 1)) { + this->unk148[i] = (EnItem00*)Item_DropCollectible2(play, &spawnPos, 0x10001); + if (this->unk148[i] != NULL) { + this->unk148[i]->actor.room = this->actor.room; + } + } + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Mure3/func_8098F040.s") +void func_8098F110(ObjMure3* this, PlayState* play) { + s32 i; + Vec3f spawnPos; + f32 sin = Math_SinS(this->actor.world.rot.y); + f32 cos = Math_CosS(this->actor.world.rot.y); + f32 dist; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Mure3/func_8098F110.s") + spawnPos.y = this->actor.world.pos.y; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Mure3/func_8098F220.s") + for (i = 0, dist = -40.0f; i < 5; i++, dist += 20.0f) { + if (!((this->unk164 >> i) & 1)) { + spawnPos.x = this->actor.world.pos.x + (sin * dist); + spawnPos.z = this->actor.world.pos.z + (cos * dist); + this->unk148[i] = (EnItem00*)Item_DropCollectible2(play, &spawnPos, 0x4000); + if (this->unk148[i] != NULL) { + this->unk148[i]->actor.room = this->actor.room; + } + } + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Mure3/func_8098F364.s") +void func_8098F220(ObjMure3* this, PlayState* play) { + s16 yRot; + Vec3f spawnPos; + s32 i; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Mure3/func_8098F438.s") + spawnPos.y = this->actor.world.pos.y; + yRot = this->actor.world.rot.y; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Mure3/ObjMure3_Init.s") + for (i = 0; i < 6; i++) { + if (!((this->unk164 >> i) & 1)) { + spawnPos.x = (Math_SinS(yRot) * 40.0f) + this->actor.world.pos.x; + spawnPos.z = (Math_CosS(yRot) * 40.0f) + this->actor.world.pos.z; + this->unk148[i] = (EnItem00*)Item_DropCollectible2(play, &spawnPos, 0x4000); + if (this->unk148[i] != NULL) { + this->unk148[i]->actor.room = this->actor.room; + } + } + yRot += 0x2AAA; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Mure3/ObjMure3_Destroy.s") + if (!((this->unk164 >> 6) & 1)) { + spawnPos.x = this->actor.world.pos.x; + spawnPos.z = this->actor.world.pos.z; + this->unk160 = Item_DropCollectible2(play, &spawnPos, 0x4002); + if (this->unk160 != NULL) { + this->unk160->room = this->actor.room; + } + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Mure3/func_8098F598.s") +void func_8098F364(ObjMure3* this, s32 play) { + s16 count = sRupeeCounts[OBJMURE3_PARAMS_RUPEEINDEX(&this->actor)]; + s32 i; + EnItem00** collectible; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Mure3/func_8098F5AC.s") + for (i = 0; i < count; i++) { + collectible = &this->unk148[i]; + if ((!((this->unk164 >> i) & 1)) && (*collectible != NULL)) { + if (((*collectible)->unk1A4 != 0) || ((*collectible)->actor.update == NULL)) { + this->unk164 |= (1 << i); + } else { + Actor_MarkForDeath(&(*collectible)->actor); + } + } + *collectible = NULL; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Mure3/func_8098F5D0.s") +void func_8098F438(ObjMure3* this, PlayState* play) { + s16 count = sRupeeCounts[OBJMURE3_PARAMS_RUPEEINDEX(&this->actor)]; + s32 i; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Mure3/func_8098F5E4.s") + for (i = 0; i < count; i++) { + EnItem00** collectible = &this->unk148[i]; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Mure3/func_8098F66C.s") + if ((*collectible != NULL) && !((this->unk164 >> i) & 1)) { + if ((*collectible)->unk1A4 != 0) { + Flags_SetSwitch(play, OBJMURE3_PARAMS_7F(&this->actor)); + } + if ((*collectible)->actor.update == NULL) { + this->unk164 |= (1 << i); + this->unk148[i] = NULL; + } + } + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Mure3/func_8098F680.s") +void ObjMure3_Init(Actor* thisx, PlayState* play) { + ObjMure3* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Mure3/ObjMure3_Update.s") + if (Flags_GetSwitch(play, OBJMURE3_PARAMS_7F(&this->actor))) { + Actor_MarkForDeath(&this->actor); + return; + } + Actor_ProcessInitChain(&this->actor, sInitChain); + func_8098F598(this); +} + +void ObjMure3_Destroy(Actor* thisx, PlayState* play) { +} + +void func_8098F598(ObjMure3* this) { + this->actionFunc = func_8098F5AC; +} + +void func_8098F5AC(ObjMure3* this, PlayState* play) { + func_8098F5D0(this); +} + +void func_8098F5D0(ObjMure3* this) { + this->actionFunc = func_8098F5E4; +} + +void func_8098F5E4(ObjMure3* this, PlayState* play) { + static ObjMure3SpawnFunc sSpawnFuncs[] = { func_8098F040, func_8098F110, func_8098F220 }; + + if (Math3D_XZLengthSquared(this->actor.projectedPos.x, this->actor.projectedPos.z) < SQ(1150.0f)) { + this->actor.flags |= ACTOR_FLAG_10; + sSpawnFuncs[OBJMURE3_PARAMS_RUPEEINDEX(&this->actor)](this, play); + func_8098F66C(this); + } +} + +void func_8098F66C(ObjMure3* this) { + this->actionFunc = func_8098F680; +} + +void func_8098F680(ObjMure3* this, PlayState* play) { + func_8098F438(this, play); + if (Math3D_XZLengthSquared(this->actor.projectedPos.x, this->actor.projectedPos.z) >= SQ(1450.0f)) { + this->actor.flags &= ~ACTOR_FLAG_10; + func_8098F364(this, play); + func_8098F5D0(this); + } +} + +void ObjMure3_Update(Actor* thisx, PlayState* play) { + ObjMure3* this = THIS; + + this->actionFunc(this, play); +} diff --git a/src/overlays/actors/ovl_Obj_Mure3/z_obj_mure3.h b/src/overlays/actors/ovl_Obj_Mure3/z_obj_mure3.h index 67252a147..2b6c4f891 100644 --- a/src/overlays/actors/ovl_Obj_Mure3/z_obj_mure3.h +++ b/src/overlays/actors/ovl_Obj_Mure3/z_obj_mure3.h @@ -3,14 +3,20 @@ #include "global.h" +#define OBJMURE3_PARAMS_7F(thisx) ((thisx)->params & 0x7F) +#define OBJMURE3_PARAMS_RUPEEINDEX(thisx) (((thisx)->params >> 13) & 7) + struct ObjMure3; -typedef void (*ObjMure3ActionFunc)(struct ObjMure3*, GlobalContext*); +typedef void (*ObjMure3ActionFunc)(struct ObjMure3*, PlayState*); +typedef void (*ObjMure3SpawnFunc)(struct ObjMure3*, PlayState*); typedef struct ObjMure3 { - /* 0x0000 */ Actor actor; - /* 0x0144 */ ObjMure3ActionFunc actionFunc; - /* 0x0148 */ char unk_148[0x20]; + /* 0x000 */ Actor actor; + /* 0x144 */ ObjMure3ActionFunc actionFunc; + /* 0x148 */ EnItem00* unk148[6]; + /* 0x160 */ Actor* unk160; + /* 0x164 */ u16 unk164; } ObjMure3; // size = 0x168 extern const ActorInit Obj_Mure3_InitVars; diff --git a/src/overlays/actors/ovl_Obj_Nozoki/z_obj_nozoki.c b/src/overlays/actors/ovl_Obj_Nozoki/z_obj_nozoki.c index ba5b62151..681faf3c1 100644 --- a/src/overlays/actors/ovl_Obj_Nozoki/z_obj_nozoki.c +++ b/src/overlays/actors/ovl_Obj_Nozoki/z_obj_nozoki.c @@ -5,26 +5,33 @@ */ #include "z_obj_nozoki.h" +#include "objects/object_secom_obj/object_secom_obj.h" #define FLAGS (ACTOR_FLAG_10) #define THIS ((ObjNozoki*)thisx) -void ObjNozoki_Init(Actor* thisx, GlobalContext* globalCtx); -void ObjNozoki_Destroy(Actor* thisx, GlobalContext* globalCtx); -void ObjNozoki_Update(Actor* thisx, GlobalContext* globalCtx); - -void func_80BA2514(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_80BA3044(ObjNozoki* this, GlobalContext* globalCtx); -void func_80BA3230(ObjNozoki* this, GlobalContext* globalCtx); -void func_80BA3344(ObjNozoki* this, GlobalContext* globalCtx); +void ObjNozoki_Init(Actor* thisx, PlayState* play); +void ObjNozoki_Destroy(Actor* thisx, PlayState* play); +void ObjNozoki_Update(Actor* thisx, PlayState* play); void ObjNozoki_SetupAction(ObjNozoki* this, ObjNozokiActionFunc actionFunc); +void func_80BA2514(ObjNozoki* this, PlayState* play); +void func_80BA27C4(ObjNozoki* this, PlayState* play); +void func_80BA28DC(ObjNozoki* this, PlayState* play); +void func_80BA2AB4(ObjNozoki* this, PlayState* play); +void func_80BA2BA4(ObjNozoki* this, PlayState* play); +void func_80BA2C94(ObjNozoki* this, PlayState* play); +void func_80BA3044(ObjNozoki* this, PlayState* play); +void func_80BA311C(ObjNozoki* this, PlayState* play); +void func_80BA3230(ObjNozoki* this, PlayState* play); +void func_80BA3344(ObjNozoki* this, PlayState* play); +void ObjNozoki_Draw(Actor* thisx, PlayState* play); + +s32 D_80BA36B0; +s32 D_80BA36B4; +f32 D_80BA36B8; -#if 0 const ActorInit Obj_Nozoki_InitVars = { ACTOR_OBJ_NOZOKI, ACTORCAT_ITEMACTION, @@ -37,54 +44,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, PlayState* play) { + 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 (play->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, PlayState* play) { + ObjNozoki* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Nozoki/func_80BA27C4.s") + if (this->unk_15C == 0) { + DynaPoly_DeleteBgActor(play, &play->colCtx.dyna, this->dyna.bgId); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Nozoki/func_80BA28DC.s") +void func_80BA2514(ObjNozoki* this, PlayState* play) { + s32 sp24 = Object_GetIndex(&play->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(&play->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(play, &this->dyna.actor); + DynaPolyActor_LoadMesh(play, &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, PlayState* play) { + Actor* enemy = play->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, PlayState* play) { + if (!(play->actorCtx.unk5 & 0x20)) { + if (OBJNOZOKI_GET_200(&this->dyna.actor)) { + if (!func_80BA2708(this, play)) { + return; + } + } else { + if (D_80BA36B0 != 0) { + play->actorCtx.unk5 |= 0x80; + } + + if (!Flags_GetSwitch(play, 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; + } + play->actorCtx.unk5 |= 0x10; + } + } + GET_PLAYER(play)->linearVelocity = 0.0f; + } +} + +void func_80BA28DC(ObjNozoki* this, PlayState* play) { + if (this->unk_15E != 0) { + if (DECR(this->unk_15E) == 0) { + Actor_PlaySfxAtPos(&this->dyna.actor, NA_SE_EV_SLIDE_DOOR_OPEN); + } + return; + } + + if (!(play->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(play, OBJNOZOKI_GET_SWITCHFLAG1(&this->dyna.actor))) { + return; + } + } else if (Flags_GetSwitch(play, 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(play)->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, PlayState* play) { + 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 (!(play->actorCtx.unk5 & 0x20)) { + if (!(OBJNOZOKI_GET_200(&this->dyna.actor)) && + Flags_GetSwitch(play, OBJNOZOKI_GET_SWITCHFLAG1(&this->dyna.actor))) { + func_80BA2790(this); + } + } +} + +void func_80BA2B64(ObjNozoki* this, PlayState* play, s32 arg2, s32 arg3) { + this->unk_15D = arg2; + this->unk_15E = 80; + Flags_UnsetSwitch(play, arg3); +} + +void func_80BA2BA4(ObjNozoki* this, PlayState* play) { + if (!Flags_GetSwitch(play, 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, PlayState* play) { + 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(play)) { + 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(play, this->dyna.actor.world.rot.z)) { + func_80BA2B64(this, play, 1, this->dyna.actor.world.rot.x); + } else if ((this->unk_15D != 2) && Flags_GetSwitch(play, this->dyna.actor.world.rot.x)) { + func_80BA2B64(this, play, 2, this->dyna.actor.world.rot.z); + } else if (DECR(this->unk_15E) == 0) { + this->unk_15D = 0; + Flags_UnsetSwitch(play, this->dyna.actor.world.rot.z); + Flags_UnsetSwitch(play, this->dyna.actor.world.rot.x); + } + + Math_StepToF(&this->dyna.actor.speedXZ, D_80BA34E4[this->unk_15D], 0.1f); + + if ((play->actorCtx.unk5 & 0x40) || (play->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 (play->actorCtx.unk5 & 0x40) { + if (sp34 <= 5.0f) { + Actor_MarkForDeath(&this->dyna.actor); + } + } else if (!(play->actorCtx.unk5 & 0x20) && (GET_PLAYER(play)->actor.id == ACTOR_PLAYER) && + Flags_GetSwitch(play, OBJNOZOKI_GET_SWITCHFLAG2(&this->dyna.actor)) && (sp38 < 20.0f)) { + static Vec3f D_80BA34F0 = { 0.0f, 0.0f, 50.0f }; + + play->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) { + play->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; + } + + play->roomCtx.unk7A[0] = this->dyna.actor.velocity.x; + + func_8019FAD8(&gSfxDefaultPos, NA_SE_EV_SECOM_CONVEYOR - SFX_FLAG, this->dyna.actor.speedXZ); +} + +void func_80BA3044(ObjNozoki* this, PlayState* play) { + Vec3f* sp1C = &this->dyna.actor.focus.pos; + + if (this->unk_15D == 0) { + if (play->actorCtx.unk5 & 0x40) { + this->unk_15D = 1; + this->unk_15E = 20; + Math_Vec3f_Copy(&this->dyna.actor.world.pos, sp1C); + } else if (!(play->actorCtx.unk5 & 0x20) && + Flags_GetSwitch(play, 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, PlayState* play) { + if (this->unk_15D == 0) { + if (Flags_GetSwitch(play, 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, PlayState* play) { + if (gSaveContext.save.weekEventReg[64] & 0x20) { + Actor* npc = play->actorCtx.actorLists[ACTORCAT_NPC].first; + Actor* test3 = SubS_FindActor(play, npc, ACTORCAT_NPC, ACTOR_EN_TEST3); + + if ((test3 != NULL) && (test3->draw != NULL)) { + if ((play->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, &play->state)) { + ObjNozoki_SetupAction(this, func_80BA3344); + } else { + func_800B8614(&this->dyna.actor, play, 50.0f); + } + } + } +} + +void func_80BA3344(ObjNozoki* this, PlayState* play) { + if ((play->curSpawn == 3) && !(gSaveContext.save.weekEventReg[64] & 0x40)) { + if (Actor_TextboxIsClosing(&this->dyna.actor, play)) { + 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, play)) { + play->nextEntrance = ENTRANCE(CURIOSITY_SHOP, 2); + play->transitionTrigger = TRANS_TRIGGER_START; + } +} + +void ObjNozoki_Update(Actor* thisx, PlayState* play) { + ObjNozoki* this = THIS; + + this->actionFunc(this, play); +} + +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, PlayState* play) { + ObjNozoki* this = THIS; + + if (this->unk_15C == 1) { + GetItem_Draw(play, GID_MASK_SUN); + } else { + Gfx_DrawDListOpa(play, 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..7b4c3a5b8 100644 --- a/src/overlays/actors/ovl_Obj_Nozoki/z_obj_nozoki.h +++ b/src/overlays/actors/ovl_Obj_Nozoki/z_obj_nozoki.h @@ -5,12 +5,23 @@ struct ObjNozoki; -typedef void (*ObjNozokiActionFunc)(struct ObjNozoki*, GlobalContext*); +typedef void (*ObjNozokiActionFunc)(struct ObjNozoki*, PlayState*); + +#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]; - /* 0x0160 */ ObjNozokiActionFunc actionFunc; + /* 0x000 */ DynaPolyActor dyna; + /* 0x15C */ u8 unk_15C; + /* 0x15D */ u8 unk_15D; + /* 0x15E */ s8 unk_15E; + /* 0x15F */ s8 unk_15F; + /* 0x160 */ ObjNozokiActionFunc actionFunc; } ObjNozoki; // size = 0x164 extern const ActorInit Obj_Nozoki_InitVars; diff --git a/src/overlays/actors/ovl_Obj_Ocarinalift/z_obj_ocarinalift.c b/src/overlays/actors/ovl_Obj_Ocarinalift/z_obj_ocarinalift.c index 731bc4328..b7a098b46 100644 --- a/src/overlays/actors/ovl_Obj_Ocarinalift/z_obj_ocarinalift.c +++ b/src/overlays/actors/ovl_Obj_Ocarinalift/z_obj_ocarinalift.c @@ -5,17 +5,32 @@ */ #include "z_obj_ocarinalift.h" +#include "objects/object_raillift/object_raillift.h" #define FLAGS (ACTOR_FLAG_10) #define THIS ((ObjOcarinalift*)thisx) -void ObjOcarinalift_Init(Actor* thisx, GlobalContext* globalCtx); -void ObjOcarinalift_Destroy(Actor* thisx, GlobalContext* globalCtx); -void ObjOcarinalift_Update(Actor* thisx, GlobalContext* globalCtx); -void ObjOcarinalift_Draw(Actor* thisx, GlobalContext* globalCtx); +void ObjOcarinalift_Init(Actor* thisx, PlayState* play); +void ObjOcarinalift_Destroy(Actor* thisx, PlayState* play); +void ObjOcarinalift_Update(Actor* thisx, PlayState* play); +void ObjOcarinalift_Draw(Actor* thisx, PlayState* play); + +void func_80AC9680(ObjOcarinalift* this); +void func_80AC96A4(ObjOcarinalift* this, PlayState* play); +void func_80AC96B4(ObjOcarinalift* this); +void func_80AC96D0(ObjOcarinalift* this, PlayState* play); +void func_80AC99D4(ObjOcarinalift* this, PlayState* play); +void func_80AC99C0(ObjOcarinalift* this); +void func_80AC9A68(ObjOcarinalift* this); +void func_80AC9A7C(ObjOcarinalift* this, PlayState* play); +void func_80AC9AB8(ObjOcarinalift* this); +void func_80AC9AE0(ObjOcarinalift* this, PlayState* play); +void func_80AC9B48(ObjOcarinalift* this); +void func_80AC9B5C(ObjOcarinalift* this, PlayState* play); +void func_80AC9C20(ObjOcarinalift* this); +void func_80AC9C48(ObjOcarinalift* this, PlayState* play); -#if 0 const ActorInit Obj_Ocarinalift_InitVars = { ACTOR_OBJ_OCARINALIFT, ACTORCAT_BG, @@ -28,56 +43,227 @@ const ActorInit Obj_Ocarinalift_InitVars = { (ActorFunc)ObjOcarinalift_Draw, }; -// static InitChainEntry sInitChain[] = { -static InitChainEntry D_80AC9D70[] = { - ICHAIN_U8(targetMode, 2, ICHAIN_CONTINUE), - ICHAIN_F32(uncullZoneForward, 4000, ICHAIN_CONTINUE), - ICHAIN_F32(uncullZoneScale, 200, ICHAIN_CONTINUE), - ICHAIN_F32(uncullZoneDownward, 300, ICHAIN_CONTINUE), +static InitChainEntry sInitChain[] = { + ICHAIN_U8(targetMode, 2, ICHAIN_CONTINUE), ICHAIN_F32(uncullZoneForward, 4000, ICHAIN_CONTINUE), + ICHAIN_F32(uncullZoneScale, 200, ICHAIN_CONTINUE), ICHAIN_F32(uncullZoneDownward, 300, ICHAIN_CONTINUE), ICHAIN_VEC3F_DIV1000(scale, 100, ICHAIN_STOP), }; -#endif +void func_80AC94C0(ObjOcarinalift* this, s32 arg1) { + Math_Vec3s_ToVec3f(&this->dyna.actor.world.pos, &this->unk170[arg1]); +} -extern InitChainEntry D_80AC9D70[]; +void ObjOcarinalift_Init(Actor* thisx, PlayState* play) { + Path* path; + ObjOcarinalift* this = THIS; -extern UNK_TYPE D_06001E40; -extern UNK_TYPE D_060048D0; + Actor_ProcessInitChain(thisx, sInitChain); + this->dyna.actor.shape.rot.x = 0; + this->dyna.actor.world.rot.x = 0; + this->dyna.actor.shape.rot.z = 0; + this->dyna.actor.world.rot.z = 0; + DynaPolyActor_Init(&this->dyna, 1); + DynaPolyActor_LoadMesh(play, &this->dyna, &object_raillift_Colheader_0048D0); + this->unk160 = thisx->home.rot.z * 0.1f; + if (this->unk160 < 0.01f) { + func_80AC9680(this); + } else { + path = &play->setupPathList[OBJOCARINALIFT_GET_7F(&this->dyna.actor)]; + this->unk168 = OBJOCARINALIFT_GET_1F(&this->dyna.actor); + this->unk164 = path->count - 1; + this->unk16C = 1; + this->unk170 = Lib_SegmentedToVirtual(path->points); + func_80AC94C0(this, this->unk168); + if ((OBJOCARINALIFT_GET_C(&this->dyna.actor) != OBJOCARINALIFT_PARAMSC_1) && + (Flags_GetSwitch(play, OBJOCARINALIFT_GET_SWITCH_FLAG(&this->dyna.actor)))) { + func_80AC96B4(this); + } else { + func_80AC9AB8(this); + } + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Ocarinalift/func_80AC94C0.s") +void ObjOcarinalift_Destroy(Actor* thisx, PlayState* play) { + ObjOcarinalift* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Ocarinalift/ObjOcarinalift_Init.s") + DynaPoly_DeleteBgActor(play, &play->colCtx.dyna, this->dyna.bgId); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Ocarinalift/ObjOcarinalift_Destroy.s") +void func_80AC9680(ObjOcarinalift* this) { + this->dyna.actor.flags &= ~ACTOR_FLAG_10; + this->actionFunc = func_80AC96A4; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Ocarinalift/func_80AC9680.s") +void func_80AC96A4(ObjOcarinalift* this, PlayState* play) { +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Ocarinalift/func_80AC96A4.s") +void func_80AC96B4(ObjOcarinalift* this) { + this->actionFunc = func_80AC96D0; + this->dyna.actor.speedXZ = 0.0f; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Ocarinalift/func_80AC96B4.s") +void func_80AC96D0(ObjOcarinalift* this, PlayState* play) { + Actor* thisx = &this->dyna.actor; + Vec3f sp48; + f32 magnitude; + f32 phi_fv0; + f32 phi_fa0; + s32 paramsC; + s32 sp34; + Vec3s* temp_v1_2; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Ocarinalift/func_80AC96D0.s") + func_800B9010(thisx, NA_SE_EV_PLATE_LIFT_LEVEL - SFX_FLAG); + Math_Vec3s_ToVec3f(&sp48, this->unk170 + this->unk168 + this->unk16C); + Math_Vec3f_Diff(&sp48, &thisx->world.pos, &thisx->velocity); + magnitude = Math3D_Vec3fMagnitude(&thisx->velocity); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Ocarinalift/func_80AC99C0.s") + if ((magnitude < (this->unk160 * 8.0f)) && (this->unk160 > 2.0f)) { + phi_fv0 = ((this->unk160 - 2.0f) * 0.1f) + 2.0f; + phi_fa0 = this->unk160 * 0.03f; + } else { + phi_fv0 = this->unk160; + phi_fa0 = this->unk160 * 0.16f; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Ocarinalift/func_80AC99D4.s") + Math_StepToF(&thisx->speedXZ, phi_fv0, phi_fa0); + if ((thisx->speedXZ + 0.05f) < magnitude) { + Math_Vec3f_Scale(&thisx->velocity, thisx->speedXZ / magnitude); + thisx->world.pos.x += thisx->velocity.x; + thisx->world.pos.y += thisx->velocity.y; + thisx->world.pos.z += thisx->velocity.z; + } else { + paramsC = OBJOCARINALIFT_GET_C(thisx); + sp34 = true; + this->unk168 += this->unk16C; + thisx->speedXZ *= 0.4f; + if (((this->unk168 >= this->unk164) && (this->unk16C > 0)) || ((this->unk168 <= 0) && (this->unk16C < 0))) { + if (paramsC == OBJOCARINALIFT_PARAMSC_0) { + this->unk16C = -this->unk16C; + this->timer = 10; + func_80AC9A68(this); + } else { + temp_v1_2 = this->unk170 + this->unk164; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Ocarinalift/func_80AC9A68.s") + if (this->unk16C > 0) { + this->unk168 = 0; + } else { + this->unk168 = this->unk164; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Ocarinalift/func_80AC9A7C.s") + if (((this->unk170->x != temp_v1_2->x) || (this->unk170->y != temp_v1_2->y)) || + (this->unk170->z != temp_v1_2->z)) { + func_80AC99C0(this); + func_800C62BC(play, &play->colCtx.dyna, this->dyna.bgId); + sp34 = false; + } else if ((paramsC == OBJOCARINALIFT_PARAMSC_1) && (this->unk168 == OBJOCARINALIFT_GET_1F(thisx))) { + func_80AC9AB8(this); + } + } + } else if ((paramsC == OBJOCARINALIFT_PARAMSC_1) && (this->unk168 == OBJOCARINALIFT_GET_1F(thisx))) { + func_80AC9AB8(this); + } + if (sp34) { + func_80AC94C0(this, this->unk168); + } + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Ocarinalift/func_80AC9AB8.s") +void func_80AC99C0(ObjOcarinalift* this) { + this->actionFunc = func_80AC99D4; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Ocarinalift/func_80AC9AE0.s") +void func_80AC99D4(ObjOcarinalift* this, PlayState* play) { + if (!DynaPolyActor_IsInRidingMovingState(&this->dyna)) { + func_80AC94C0(this, this->unk168); + func_800C6314(play, &play->colCtx.dyna, this->dyna.bgId); + if ((OBJOCARINALIFT_GET_C(&this->dyna.actor) == OBJOCARINALIFT_PARAMSC_1) && + (this->unk168 == OBJOCARINALIFT_GET_1F(&this->dyna.actor))) { + func_80AC9AB8(this); + } else { + func_80AC96B4(this); + } + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Ocarinalift/func_80AC9B48.s") +void func_80AC9A68(ObjOcarinalift* this) { + this->actionFunc = func_80AC9A7C; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Ocarinalift/func_80AC9B5C.s") +void func_80AC9A7C(ObjOcarinalift* this, PlayState* play) { + this->timer--; + if (this->timer <= 0) { + func_80AC96B4(this); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Ocarinalift/func_80AC9C20.s") +void func_80AC9AB8(ObjOcarinalift* this) { + this->dyna.actor.flags |= (ACTOR_FLAG_1 | ACTOR_FLAG_2000000 | ACTOR_FLAG_8000000); + this->actionFunc = func_80AC9AE0; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Ocarinalift/func_80AC9C48.s") +void func_80AC9AE0(ObjOcarinalift* this, PlayState* play) { + if (func_800B8718(&this->dyna.actor, &play->state)) { + func_80152434(play, 1); + func_80AC9B48(this); + } else if (DynaPolyActor_IsInRidingMovingState(&this->dyna)) { + func_800B8804(&this->dyna.actor, play, 40.0f); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Ocarinalift/ObjOcarinalift_Update.s") +void func_80AC9B48(ObjOcarinalift* this) { + this->actionFunc = func_80AC9B5C; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Ocarinalift/ObjOcarinalift_Draw.s") +void func_80AC9B5C(ObjOcarinalift* this, PlayState* play) { + if (func_800B886C(&this->dyna.actor, play)) { + if (play->msgCtx.ocarinaMode == 4) { + if (play->msgCtx.lastPlayedSong == 0) { + if (OBJOCARINALIFT_GET_C(&this->dyna.actor) != OBJOCARINALIFT_PARAMSC_1) { + Flags_SetSwitch(play, OBJOCARINALIFT_GET_SWITCH_FLAG(&this->dyna.actor)); + } + ActorCutscene_SetIntentToPlay(this->dyna.actor.cutscene); + func_80AC9C20(this); + } + } else { + if (play->msgCtx.ocarinaMode >= 2) { + play->msgCtx.ocarinaMode = 4; + } + func_80AC9AB8(this); + } + } +} + +void func_80AC9C20(ObjOcarinalift* this) { + this->dyna.actor.flags &= ~(ACTOR_FLAG_1 | ACTOR_FLAG_2000000 | ACTOR_FLAG_8000000); + this->actionFunc = func_80AC9C48; +} + +void func_80AC9C48(ObjOcarinalift* this, PlayState* play) { + if (ActorCutscene_GetCanPlayNext(this->dyna.actor.cutscene)) { + ActorCutscene_StartAndSetUnkLinkFields(this->dyna.actor.cutscene, &this->dyna.actor); + this->cutsceneTimer = 50; + func_80AC96B4(this); + } else { + ActorCutscene_SetIntentToPlay(this->dyna.actor.cutscene); + } +} + +void ObjOcarinalift_Update(Actor* thisx, PlayState* play) { + ObjOcarinalift* this = THIS; + + this->actionFunc(this, play); + Actor_SetFocus(&this->dyna.actor, 10.0f); + if (this->cutsceneTimer > 0) { + this->cutsceneTimer--; + if (this->cutsceneTimer == 0) { + ActorCutscene_Stop(this->dyna.actor.cutscene); + } + } +} + +void ObjOcarinalift_Draw(Actor* thisx, PlayState* play) { + ObjOcarinalift* this = THIS; + + Gfx_DrawDListOpa(play, object_raillift_DL_001E40); + Gfx_DrawDListXlu(play, object_raillift_DL_001DB0); +} diff --git a/src/overlays/actors/ovl_Obj_Ocarinalift/z_obj_ocarinalift.h b/src/overlays/actors/ovl_Obj_Ocarinalift/z_obj_ocarinalift.h index 33e56c4ab..a542fb840 100644 --- a/src/overlays/actors/ovl_Obj_Ocarinalift/z_obj_ocarinalift.h +++ b/src/overlays/actors/ovl_Obj_Ocarinalift/z_obj_ocarinalift.h @@ -3,17 +3,32 @@ #include "global.h" +#define OBJOCARINALIFT_GET_C(thisx) (((thisx)->params >> 0xC) & 3) +#define OBJOCARINALIFT_GET_7F(thisx) ((thisx)->params & 0x7F) +#define OBJOCARINALIFT_GET_1F(thisx) (((thisx)->params >> 7) & 0x1F) +#define OBJOCARINALIFT_GET_SWITCH_FLAG(thisx) ((thisx)->home.rot.x & 0x7F) + struct ObjOcarinalift; -typedef void (*ObjOcarinaliftActionFunc)(struct ObjOcarinalift*, GlobalContext*); +typedef void (*ObjOcarinaliftActionFunc)(struct ObjOcarinalift*, PlayState*); typedef struct ObjOcarinalift { - /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x18]; - /* 0x015C */ ObjOcarinaliftActionFunc actionFunc; - /* 0x0160 */ char unk_160[0x18]; + /* 0x000 */ DynaPolyActor dyna; + /* 0x15C */ ObjOcarinaliftActionFunc actionFunc; + /* 0x160 */ f32 unk160; + /* 0x164 */ s32 unk164; + /* 0x168 */ s32 unk168; + /* 0x16C */ s32 unk16C; + /* 0x170 */ Vec3s* unk170; + /* 0x174 */ s16 timer; + /* 0x176 */ s16 cutsceneTimer; } ObjOcarinalift; // size = 0x178 +typedef enum ObjOcarinaliftParams { + /* 0x0 */ OBJOCARINALIFT_PARAMSC_0, + /* 0x1 */ OBJOCARINALIFT_PARAMSC_1 +} ObjOcarinaliftParams; + extern const ActorInit Obj_Ocarinalift_InitVars; #endif // Z_OBJ_OCARINALIFT_H diff --git a/src/overlays/actors/ovl_Obj_Oshihiki/z_obj_oshihiki.c b/src/overlays/actors/ovl_Obj_Oshihiki/z_obj_oshihiki.c index fa3b46cf7..4bfb5ba96 100644 --- a/src/overlays/actors/ovl_Obj_Oshihiki/z_obj_oshihiki.c +++ b/src/overlays/actors/ovl_Obj_Oshihiki/z_obj_oshihiki.c @@ -12,18 +12,18 @@ #define THIS ((ObjOshihiki*)thisx) -void ObjOshihiki_Init(Actor* thisx, GlobalContext* globalCtx); -void ObjOshihiki_Destroy(Actor* thisx, GlobalContext* globalCtx); -void ObjOshihiki_Update(Actor* thisx, GlobalContext* globalCtx); -void ObjOshihiki_Draw(Actor* thisx, GlobalContext* globalCtx); +void ObjOshihiki_Init(Actor* thisx, PlayState* play); +void ObjOshihiki_Destroy(Actor* thisx, PlayState* play); +void ObjOshihiki_Update(Actor* thisx, PlayState* play); +void ObjOshihiki_Draw(Actor* thisx, PlayState* play); -void ObjOshihiki_OnScene(ObjOshihiki* this, GlobalContext* globalCtx); -void ObjOshihiki_SetupOnActor(ObjOshihiki* this, GlobalContext* globalCtx); -void ObjOshihiki_OnActor(ObjOshihiki* this, GlobalContext* globalCtx); -void ObjOshihiki_SetupPush(ObjOshihiki* this, GlobalContext* globalCtx); -void ObjOshihiki_Push(ObjOshihiki* this, GlobalContext* globalCtx); -void ObjOshihiki_SetupFall(ObjOshihiki* this, GlobalContext* globalCtx); -void ObjOshihiki_Fall(ObjOshihiki* this, GlobalContext* globalCtx); +void ObjOshihiki_OnScene(ObjOshihiki* this, PlayState* play); +void ObjOshihiki_SetupOnActor(ObjOshihiki* this, PlayState* play); +void ObjOshihiki_OnActor(ObjOshihiki* this, PlayState* play); +void ObjOshihiki_SetupPush(ObjOshihiki* this, PlayState* play); +void ObjOshihiki_Push(ObjOshihiki* this, PlayState* play); +void ObjOshihiki_SetupFall(ObjOshihiki* this, PlayState* play); +void ObjOshihiki_Fall(ObjOshihiki* this, PlayState* play); const ActorInit Obj_Oshihiki_InitVars = { ACTOR_OBJ_OSHIHIKI, @@ -73,7 +73,7 @@ void ObjOshihiki_RotateXZ(Vec3f* out, Vec3f* in, f32 sn, f32 cs) { out->z = (in->z * cs) - (in->x * sn); } -s32 ObjOshihiki_StrongEnough(ObjOshihiki* this, GlobalContext* globalCtx) { +s32 ObjOshihiki_StrongEnough(ObjOshihiki* this, PlayState* play) { s32 strength = OBJOSHIHIKI_GET_F(&this->dyna.actor); if (this->cantMove) { @@ -84,7 +84,7 @@ s32 ObjOshihiki_StrongEnough(ObjOshihiki* this, GlobalContext* globalCtx) { return true; } - if (func_80124020() >= 2) { + if (Player_GetStrength() >= PLAYER_STRENGTH_ZORA) { return true; } return false; @@ -98,12 +98,12 @@ void ObjOshihiki_ResetFloors(ObjOshihiki* this) { } } -ObjOshihiki* ObjOshihiki_GetBlockUnder(ObjOshihiki* this, GlobalContext* globalCtx) { +ObjOshihiki* ObjOshihiki_GetBlockUnder(ObjOshihiki* this, PlayState* play) { DynaPolyActor* dyna; if ((this->floorBgIds[this->highestFloor] != BGCHECK_SCENE) && (fabsf(this->dyna.actor.floorHeight - this->dyna.actor.world.pos.y) < 0.001f)) { - dyna = DynaPoly_GetActor(&globalCtx->colCtx, this->floorBgIds[this->highestFloor]); + dyna = DynaPoly_GetActor(&play->colCtx, this->floorBgIds[this->highestFloor]); if ((dyna != NULL) && (dyna->actor.id == ACTOR_OBJ_OSHIHIKI)) { return (ObjOshihiki*)dyna; } @@ -133,7 +133,7 @@ void ObjOshihiki_UpdateInitPos(ObjOshihiki* this) { } } -s32 ObjOshihiki_NoSwitchPress(ObjOshihiki* this, DynaPolyActor* dyna, GlobalContext* globalCtx) { +s32 ObjOshihiki_NoSwitchPress(ObjOshihiki* this, DynaPolyActor* dyna, PlayState* play) { s16 dynaSwitchFlag; if (dyna == NULL) { @@ -146,14 +146,14 @@ s32 ObjOshihiki_NoSwitchPress(ObjOshihiki* this, DynaPolyActor* dyna, GlobalCont switch (OBJSWITCH_GET_33(&dyna->actor)) { case OBJSWITCH_NORMAL_BLUE: if ((dynaSwitchFlag == OBJOSHIHIKI_GET_7F00(&this->dyna.actor)) && - Flags_GetSwitch(globalCtx, dynaSwitchFlag)) { + Flags_GetSwitch(play, dynaSwitchFlag)) { return false; } break; case OBJSWITCH_INVERSE_BLUE: if ((dynaSwitchFlag == OBJOSHIHIKI_GET_7F00(&this->dyna.actor)) && - !Flags_GetSwitch(globalCtx, dynaSwitchFlag)) { + !Flags_GetSwitch(play, dynaSwitchFlag)) { return false; } break; @@ -162,11 +162,11 @@ s32 ObjOshihiki_NoSwitchPress(ObjOshihiki* this, DynaPolyActor* dyna, GlobalCont return true; } -void ObjOshihiki_SetScale(ObjOshihiki* this, GlobalContext* globalCtx) { +void ObjOshihiki_SetScale(ObjOshihiki* this, PlayState* play) { Actor_SetScale(&this->dyna.actor, sScales[OBJOSHIHIKI_GET_F(&this->dyna.actor)]); } -void ObjOshihiki_SetTextureStep(ObjOshihiki* this, GlobalContext* globalCtx) { +void ObjOshihiki_SetTextureStep(ObjOshihiki* this, PlayState* play) { switch (OBJOSHIHIKI_GET_F(&this->dyna.actor)) { case OBJOSHIHIKI_F_0: case OBJOSHIHIKI_F_3: @@ -185,7 +185,7 @@ void ObjOshihiki_SetTextureStep(ObjOshihiki* this, GlobalContext* globalCtx) { } } -void ObjOshihiki_SetColor(ObjOshihiki* this, GlobalContext* globalCtx) { +void ObjOshihiki_SetColor(ObjOshihiki* this, PlayState* play) { Color_RGB8* src = &sColors[OBJOSHIHIKI_GET_F0(&this->dyna.actor)]; this->color.r = src->r; @@ -193,14 +193,14 @@ void ObjOshihiki_SetColor(ObjOshihiki* this, GlobalContext* globalCtx) { this->color.b = src->b; } -void ObjOshihiki_Init(Actor* thisx, GlobalContext* globalCtx) { +void ObjOshihiki_Init(Actor* thisx, PlayState* play) { ObjOshihiki* this = THIS; DynaPolyActor_Init(&this->dyna, 1); if ((OBJOSHIHIKI_GET_FF00(&this->dyna.actor) >= OBJOSHIHIKI_FF00_0) && (OBJOSHIHIKI_GET_FF00(&this->dyna.actor) < OBJOSHIHIKI_FF00_80)) { - if (Flags_GetSwitch(globalCtx, OBJOSHIHIKI_GET_7F00(&this->dyna.actor))) { + if (Flags_GetSwitch(play, OBJOSHIHIKI_GET_7F00(&this->dyna.actor))) { switch (OBJOSHIHIKI_GET_F(&this->dyna.actor)) { case OBJOSHIHIKI_F_0: case OBJOSHIHIKI_F_1: @@ -219,24 +219,24 @@ void ObjOshihiki_Init(Actor* thisx, GlobalContext* globalCtx) { } } - DynaPolyActor_LoadMesh(globalCtx, &this->dyna, &gameplay_dangeon_keep_Colheader_007498); + DynaPolyActor_LoadMesh(play, &this->dyna, &gameplay_dangeon_keep_Colheader_007498); this->texture = Lib_SegmentedToVirtual(gameplay_dangeon_keep_Matanimheader_01B370); - ObjOshihiki_SetScale(this, globalCtx); - ObjOshihiki_SetTextureStep(this, globalCtx); + ObjOshihiki_SetScale(this, play); + ObjOshihiki_SetTextureStep(this, play); Actor_ProcessInitChain(&this->dyna.actor, sInitChain); this->dyna.actor.colChkInfo.mass = MASS_IMMOVABLE; - ObjOshihiki_SetColor(this, globalCtx); + ObjOshihiki_SetColor(this, play); ObjOshihiki_ResetFloors(this); - ObjOshihiki_SetupOnActor(this, globalCtx); + ObjOshihiki_SetupOnActor(this, play); } -void ObjOshihiki_Destroy(Actor* thisx, GlobalContext* globalCtx) { +void ObjOshihiki_Destroy(Actor* thisx, PlayState* play) { ObjOshihiki* this = THIS; - DynaPoly_DeleteBgActor(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); + DynaPoly_DeleteBgActor(play, &play->colCtx.dyna, this->dyna.bgId); } -void ObjOshihiki_SetFloors(ObjOshihiki* this, GlobalContext* globalCtx) { +void ObjOshihiki_SetFloors(ObjOshihiki* this, PlayState* play) { s32 pad; Vec3f colCheckPoint; Vec3f colCheckOffset; @@ -253,8 +253,8 @@ void ObjOshihiki_SetFloors(ObjOshihiki* this, GlobalContext* globalCtx) { colCheckPoint.y += this->dyna.actor.prevPos.y; colCheckPoint.z += this->dyna.actor.world.pos.z; - this->floorHeights[i] = BgCheck_EntityRaycastFloor6( - &globalCtx->colCtx, &this->floorPolys[i], &this->floorBgIds[i], &this->dyna.actor, &colCheckPoint, 0.0f); + this->floorHeights[i] = BgCheck_EntityRaycastFloor6(&play->colCtx, &this->floorPolys[i], &this->floorBgIds[i], + &this->dyna.actor, &colCheckPoint, 0.0f); } } @@ -274,15 +274,15 @@ s16 ObjOshihiki_GetHighestFloor(ObjOshihiki* this) { return highestFloor; } -void ObjOshihiki_SetGround(ObjOshihiki* this, GlobalContext* globalCtx) { +void ObjOshihiki_SetGround(ObjOshihiki* this, PlayState* play) { ObjOshihiki_ResetFloors(this); - ObjOshihiki_SetFloors(this, globalCtx); + ObjOshihiki_SetFloors(this, play); this->highestFloor = ObjOshihiki_GetHighestFloor(this); this->dyna.actor.floorHeight = this->floorHeights[this->highestFloor]; } -s32 ObjOshihiki_CheckFloor(ObjOshihiki* this, GlobalContext* globalCtx) { - ObjOshihiki_SetGround(this, globalCtx); +s32 ObjOshihiki_CheckFloor(ObjOshihiki* this, PlayState* play) { + ObjOshihiki_SetGround(this, play); if ((this->dyna.actor.floorHeight - this->dyna.actor.world.pos.y) >= -0.001f) { this->dyna.actor.world.pos.y = this->dyna.actor.floorHeight; @@ -291,7 +291,7 @@ s32 ObjOshihiki_CheckFloor(ObjOshihiki* this, GlobalContext* globalCtx) { return false; } -s32 ObjOshihiki_CheckGround(ObjOshihiki* this, GlobalContext* globalCtx) { +s32 ObjOshihiki_CheckGround(ObjOshihiki* this, PlayState* play) { if (this->dyna.actor.world.pos.y <= BGCHECK_Y_MIN + 10.0f) { Actor_MarkForDeath(&this->dyna.actor); return false; @@ -304,7 +304,7 @@ s32 ObjOshihiki_CheckGround(ObjOshihiki* this, GlobalContext* globalCtx) { return false; } -s32 ObjOshihiki_CheckWall(GlobalContext* globalCtx, s16 angle, f32 direction, ObjOshihiki* this) { +s32 ObjOshihiki_CheckWall(PlayState* play, s16 angle, f32 direction, ObjOshihiki* this) { f32 maxDists[2]; f32 maxDist; f32 sn; @@ -345,20 +345,20 @@ 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, true, false, - false, true, &bgId, &this->dyna.actor, 0.0f)) { + if (BgCheck_EntityLineTest3(&play->colCtx, &faceVtx, &faceVtxNext, &posResult, &outPoly, true, false, false, + true, &bgId, &this->dyna.actor, 0.0f)) { return true; } } return false; } -s32 ObjOshihiki_MoveWithBlockUnder(ObjOshihiki* this, GlobalContext* globalCtx) { +s32 ObjOshihiki_MoveWithBlockUnder(ObjOshihiki* this, PlayState* play) { s32 pad; - ObjOshihiki* blockUnder = ObjOshihiki_GetBlockUnder(this, globalCtx); + ObjOshihiki* blockUnder = ObjOshihiki_GetBlockUnder(this, play); if ((blockUnder != NULL) && (blockUnder->stateFlags & PUSHBLOCK_SETUP_PUSH)) { - if (!ObjOshihiki_CheckWall(globalCtx, blockUnder->dyna.yRotation, blockUnder->direction, this)) { + if (!ObjOshihiki_CheckWall(play, blockUnder->dyna.yRotation, blockUnder->direction, this)) { this->blockUnder = blockUnder; } } @@ -382,7 +382,7 @@ s32 ObjOshihiki_MoveWithBlockUnder(ObjOshihiki* this, GlobalContext* globalCtx) return false; } -void ObjOshihiki_SetupOnScene(ObjOshihiki* this, GlobalContext* globalCtx) { +void ObjOshihiki_SetupOnScene(ObjOshihiki* this, PlayState* play) { this->stateFlags |= PUSHBLOCK_SETUP_ON_SCENE; this->dyna.actor.gravity = 0.0f; this->dyna.actor.velocity.z = 0.0f; @@ -391,18 +391,18 @@ void ObjOshihiki_SetupOnScene(ObjOshihiki* this, GlobalContext* globalCtx) { this->actionFunc = ObjOshihiki_OnScene; } -void ObjOshihiki_OnScene(ObjOshihiki* this, GlobalContext* globalCtx) { +void ObjOshihiki_OnScene(ObjOshihiki* this, PlayState* play) { s32 pad; - Player* player = GET_PLAYER(globalCtx); + Player* player = GET_PLAYER(play); this->stateFlags |= PUSHBLOCK_ON_SCENE; if (this->timer <= 0) { if (fabsf(this->dyna.pushForce) > 0.001f) { - if (ObjOshihiki_StrongEnough(this, globalCtx)) { - if (!ObjOshihiki_CheckWall(globalCtx, this->dyna.yRotation, this->dyna.pushForce, this)) { + if (ObjOshihiki_StrongEnough(this, play)) { + if (!ObjOshihiki_CheckWall(play, this->dyna.yRotation, this->dyna.pushForce, this)) { this->direction = this->dyna.pushForce; - ObjOshihiki_SetupPush(this, globalCtx); + ObjOshihiki_SetupPush(this, play); return; } } @@ -415,7 +415,7 @@ void ObjOshihiki_OnScene(ObjOshihiki* this, GlobalContext* globalCtx) { } } -void ObjOshihiki_SetupOnActor(ObjOshihiki* this, GlobalContext* globalCtx) { +void ObjOshihiki_SetupOnActor(ObjOshihiki* this, PlayState* play) { this->stateFlags |= PUSHBLOCK_SETUP_ON_ACTOR; this->dyna.actor.velocity.z = 0.0f; this->dyna.actor.velocity.y = 0.0f; @@ -424,44 +424,44 @@ void ObjOshihiki_SetupOnActor(ObjOshihiki* this, GlobalContext* globalCtx) { this->actionFunc = ObjOshihiki_OnActor; } -void ObjOshihiki_OnActor(ObjOshihiki* this, GlobalContext* globalCtx) { +void ObjOshihiki_OnActor(ObjOshihiki* this, PlayState* play) { s32 pad; - Player* player = GET_PLAYER(globalCtx); + Player* player = GET_PLAYER(play); DynaPolyActor* dyna; s32 sp20 = false; this->stateFlags |= PUSHBLOCK_ON_ACTOR; Actor_MoveWithGravity(&this->dyna.actor); - if (ObjOshihiki_CheckFloor(this, globalCtx)) { + if (ObjOshihiki_CheckFloor(this, play)) { if (this->floorBgIds[this->highestFloor] == BGCHECK_SCENE) { - ObjOshihiki_SetupOnScene(this, globalCtx); + ObjOshihiki_SetupOnScene(this, play); } else { - dyna = DynaPoly_GetActor(&globalCtx->colCtx, this->floorBgIds[this->highestFloor]); + dyna = DynaPoly_GetActor(&play->colCtx, this->floorBgIds[this->highestFloor]); if (dyna != NULL) { DynaPolyActor_SetRidingFallingState(dyna); DynaPolyActor_SetSwitchPressedState(dyna); if ((this->timer <= 0) && (fabsf(this->dyna.pushForce) > 0.001f) && - ObjOshihiki_StrongEnough(this, globalCtx) && ObjOshihiki_NoSwitchPress(this, dyna, globalCtx) && - !ObjOshihiki_CheckWall(globalCtx, this->dyna.yRotation, this->dyna.pushForce, this)) { + ObjOshihiki_StrongEnough(this, play) && ObjOshihiki_NoSwitchPress(this, dyna, play) && + !ObjOshihiki_CheckWall(play, this->dyna.yRotation, this->dyna.pushForce, this)) { this->direction = this->dyna.pushForce; - ObjOshihiki_SetupPush(this, globalCtx); + ObjOshihiki_SetupPush(this, play); sp20 = true; } } else { - ObjOshihiki_SetupOnScene(this, globalCtx); + ObjOshihiki_SetupOnScene(this, play); } } } else if (this->floorBgIds[this->highestFloor] == BGCHECK_SCENE) { - ObjOshihiki_SetupFall(this, globalCtx); + ObjOshihiki_SetupFall(this, play); } else { - dyna = DynaPoly_GetActor(&globalCtx->colCtx, this->floorBgIds[this->highestFloor]); + dyna = DynaPoly_GetActor(&play->colCtx, this->floorBgIds[this->highestFloor]); if ((dyna != NULL) && (dyna->flags & 1)) { DynaPolyActor_SetRidingFallingState(dyna); DynaPolyActor_SetSwitchPressedState(dyna); this->dyna.actor.world.pos.y = this->dyna.actor.floorHeight; } else { - ObjOshihiki_SetupFall(this, globalCtx); + ObjOshihiki_SetupFall(this, play); } } @@ -471,16 +471,16 @@ void ObjOshihiki_OnActor(ObjOshihiki* this, GlobalContext* globalCtx) { } } -void ObjOshihiki_SetupPush(ObjOshihiki* this, GlobalContext* globalCtx) { +void ObjOshihiki_SetupPush(ObjOshihiki* this, PlayState* play) { this->stateFlags |= PUSHBLOCK_SETUP_PUSH; this->dyna.actor.gravity = 0.0f; this->pushSpeed = 2.0f; this->actionFunc = ObjOshihiki_Push; } -void ObjOshihiki_Push(ObjOshihiki* this, GlobalContext* globalCtx) { +void ObjOshihiki_Push(ObjOshihiki* this, PlayState* play) { s32 pad; - Player* player = GET_PLAYER(globalCtx); + Player* player = GET_PLAYER(play); f32 pushDistSigned; s32 stopFlag; @@ -491,18 +491,18 @@ void ObjOshihiki_Push(ObjOshihiki* this, GlobalContext* globalCtx) { this->dyna.actor.world.pos.x = this->dyna.actor.home.pos.x + (pushDistSigned * this->yawSin); this->dyna.actor.world.pos.z = this->dyna.actor.home.pos.z + (pushDistSigned * this->yawCos); - if (!ObjOshihiki_CheckFloor(this, globalCtx)) { + if (!ObjOshihiki_CheckFloor(this, play)) { this->dyna.actor.home.pos.x = this->dyna.actor.world.pos.x; this->dyna.actor.home.pos.z = this->dyna.actor.world.pos.z; player->stateFlags2 &= ~0x10; this->dyna.pushForce = 0.0f; this->pushDist = 0.0f; this->pushSpeed = 0.0f; - ObjOshihiki_SetupFall(this, globalCtx); + ObjOshihiki_SetupFall(this, play); } else if (stopFlag) { - player = GET_PLAYER(globalCtx); + player = GET_PLAYER(play); - if (ObjOshihiki_CheckWall(globalCtx, this->dyna.yRotation, this->dyna.pushForce, this)) { + if (ObjOshihiki_CheckWall(play, this->dyna.yRotation, this->dyna.pushForce, this)) { Actor_PlaySfxAtPos(&this->dyna.actor, NA_SE_EV_BLOCK_BOUND); } @@ -515,27 +515,27 @@ void ObjOshihiki_Push(ObjOshihiki* this, GlobalContext* globalCtx) { this->timer = 10; if (this->floorBgIds[this->highestFloor] == BGCHECK_SCENE) { - ObjOshihiki_SetupOnScene(this, globalCtx); + ObjOshihiki_SetupOnScene(this, play); } else { - ObjOshihiki_SetupOnActor(this, globalCtx); + ObjOshihiki_SetupOnActor(this, play); } } Actor_PlaySfxAtPos(&this->dyna.actor, NA_SE_EV_ROCK_SLIDE - SFX_FLAG); } -void ObjOshihiki_SetupFall(ObjOshihiki* this, GlobalContext* globalCtx) { +void ObjOshihiki_SetupFall(ObjOshihiki* this, PlayState* play) { this->stateFlags |= PUSHBLOCK_SETUP_FALL; this->dyna.actor.velocity.z = 0.0f; this->dyna.actor.velocity.y = 0.0f; this->dyna.actor.velocity.x = 0.0f; this->dyna.actor.gravity = -1.0f; - ObjOshihiki_SetGround(this, globalCtx); + ObjOshihiki_SetGround(this, play); this->actionFunc = ObjOshihiki_Fall; } -void ObjOshihiki_Fall(ObjOshihiki* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); +void ObjOshihiki_Fall(ObjOshihiki* this, PlayState* play) { + Player* player = GET_PLAYER(play); s16 temp_t4; this->stateFlags |= PUSHBLOCK_FALL; @@ -547,21 +547,20 @@ void ObjOshihiki_Fall(ObjOshihiki* this, GlobalContext* globalCtx) { Actor_MoveWithGravity(&this->dyna.actor); - if (ObjOshihiki_CheckGround(this, globalCtx)) { + if (ObjOshihiki_CheckGround(this, play)) { if (this->floorBgIds[this->highestFloor] == BGCHECK_SCENE) { - ObjOshihiki_SetupOnScene(this, globalCtx); + ObjOshihiki_SetupOnScene(this, play); } else { - ObjOshihiki_SetupOnActor(this, globalCtx); + ObjOshihiki_SetupOnActor(this, play); } Actor_PlaySfxAtPos(&this->dyna.actor, NA_SE_EV_BLOCK_BOUND); - Actor_PlaySfxAtPos(&this->dyna.actor, - SurfaceType_GetSfx(&globalCtx->colCtx, this->floorPolys[this->highestFloor], - this->floorBgIds[this->highestFloor]) + - SFX_FLAG); + Actor_PlaySfxAtPos(&this->dyna.actor, SurfaceType_GetSfx(&play->colCtx, this->floorPolys[this->highestFloor], + this->floorBgIds[this->highestFloor]) + + SFX_FLAG); } } -void ObjOshihiki_Update(Actor* thisx, GlobalContext* globalCtx) { +void ObjOshihiki_Update(Actor* thisx, PlayState* play) { ObjOshihiki* this = THIS; this->stateFlags &= @@ -577,27 +576,27 @@ void ObjOshihiki_Update(Actor* thisx, GlobalContext* globalCtx) { this->yawCos = Math_CosS(this->dyna.actor.world.rot.y); if (this->actionFunc != NULL) { - this->actionFunc(this, globalCtx); + this->actionFunc(this, play); } } -void ObjOshihiki_Draw(Actor* thisx, GlobalContext* globalCtx) { +void ObjOshihiki_Draw(Actor* thisx, PlayState* play) { s32 pad; ObjOshihiki* this = THIS; - OPEN_DISPS(globalCtx->state.gfxCtx); + OPEN_DISPS(play->state.gfxCtx); - if (ObjOshihiki_MoveWithBlockUnder(this, globalCtx)) { - Matrix_InsertTranslation(this->underDistX * 10.0f, 0.0f, this->underDistZ * 10.0f, MTXMODE_APPLY); + if (ObjOshihiki_MoveWithBlockUnder(this, play)) { + Matrix_Translate(this->underDistX * 10.0f, 0.0f, this->underDistZ * 10.0f, MTXMODE_APPLY); } this->stateFlags &= ~PUSHBLOCK_MOVE_UNDER; - func_8012C28C(globalCtx->state.gfxCtx); - AnimatedMat_DrawStep(globalCtx, this->texture, this->textureStep); + func_8012C28C(play->state.gfxCtx); + AnimatedMat_DrawStep(play, this->texture, this->textureStep); - gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gDPSetPrimColor(POLY_OPA_DISP++, 0xFF, 0xFF, this->color.r, this->color.g, this->color.b, 255); gSPDisplayList(POLY_OPA_DISP++, gameplay_dangeon_keep_DL_0182A8); - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->state.gfxCtx); } diff --git a/src/overlays/actors/ovl_Obj_Oshihiki/z_obj_oshihiki.h b/src/overlays/actors/ovl_Obj_Oshihiki/z_obj_oshihiki.h index e08630132..ade27ca43 100644 --- a/src/overlays/actors/ovl_Obj_Oshihiki/z_obj_oshihiki.h +++ b/src/overlays/actors/ovl_Obj_Oshihiki/z_obj_oshihiki.h @@ -5,7 +5,7 @@ struct ObjOshihiki; -typedef void (*ObjOshihikiActionFunc)(struct ObjOshihiki*, GlobalContext*); +typedef void (*ObjOshihikiActionFunc)(struct ObjOshihiki*, PlayState*); #define OBJOSHIHIKI_GET_F(thisx) ((thisx)->params & 0xF) #define OBJOSHIHIKI_GET_F0(thisx) (((thisx)->params >> 4) & 0xF) @@ -38,26 +38,26 @@ enum { #define PUSHBLOCK_MOVE_UNDER (1 << 8) typedef struct ObjOshihiki { - /* 0x0000 */ DynaPolyActor dyna; - /* 0x015C */ ObjOshihikiActionFunc actionFunc; - /* 0x0160 */ u16 stateFlags; - /* 0x0162 */ s16 timer; - /* 0x0164 */ f32 yawSin; - /* 0x0168 */ f32 yawCos; - /* 0x016C */ f32 pushSpeed; - /* 0x0170 */ f32 pushDist; - /* 0x0174 */ f32 direction; - /* 0x0178 */ s32 floorBgIds[5]; - /* 0x018C */ CollisionPoly* floorPolys[5]; - /* 0x01A0 */ f32 floorHeights[5]; - /* 0x01B4 */ s16 highestFloor; - /* 0x01B6 */ u8 cantMove; - /* 0x01B8 */ struct ObjOshihiki* blockUnder; - /* 0x01BC */ f32 underDistX; - /* 0x01C0 */ f32 underDistZ; - /* 0x01C4 */ s8 textureStep; - /* 0x01C5 */ Color_RGB8 color; - /* 0x01C8 */ AnimatedMaterial* texture; + /* 0x000 */ DynaPolyActor dyna; + /* 0x15C */ ObjOshihikiActionFunc actionFunc; + /* 0x160 */ u16 stateFlags; + /* 0x162 */ s16 timer; + /* 0x164 */ f32 yawSin; + /* 0x168 */ f32 yawCos; + /* 0x16C */ f32 pushSpeed; + /* 0x170 */ f32 pushDist; + /* 0x174 */ f32 direction; + /* 0x178 */ s32 floorBgIds[5]; + /* 0x18C */ CollisionPoly* floorPolys[5]; + /* 0x1A0 */ f32 floorHeights[5]; + /* 0x1B4 */ s16 highestFloor; + /* 0x1B6 */ u8 cantMove; + /* 0x1B8 */ struct ObjOshihiki* blockUnder; + /* 0x1BC */ f32 underDistX; + /* 0x1C0 */ f32 underDistZ; + /* 0x1C4 */ s8 textureStep; + /* 0x1C5 */ Color_RGB8 color; + /* 0x1C8 */ AnimatedMaterial* texture; } ObjOshihiki; // size = 0x1CC extern const ActorInit Obj_Oshihiki_InitVars; diff --git a/src/overlays/actors/ovl_Obj_Purify/z_obj_purify.c b/src/overlays/actors/ovl_Obj_Purify/z_obj_purify.c index 0f594f1e1..6255b2cbe 100644 --- a/src/overlays/actors/ovl_Obj_Purify/z_obj_purify.c +++ b/src/overlays/actors/ovl_Obj_Purify/z_obj_purify.c @@ -5,16 +5,42 @@ */ #include "z_obj_purify.h" +#include "objects/object_numa_obj/object_numa_obj.h" +#include "objects/object_dekucity_obj/object_dekucity_obj.h" #define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_20) #define THIS ((ObjPurify*)thisx) -void ObjPurify_Init(Actor* thisx, GlobalContext* globalCtx); -void ObjPurify_Destroy(Actor* thisx, GlobalContext* globalCtx); -void ObjPurify_Update(Actor* thisx, GlobalContext* globalCtx); +void ObjPurify_Init(Actor* thisx, PlayState* play); +void ObjPurify_Destroy(Actor* thisx, PlayState* play); +void ObjPurify_Update(Actor* thisx, PlayState* play); + +void func_80A84EC0(ObjPurify* this, PlayState* play); +void func_80A851C8(Actor* thisx, PlayState* play); +void func_80A85074(ObjPurify* this, PlayState* play); +void func_80A850B0(ObjPurify* this); +void func_80A850E8(ObjPurify* this, PlayState* play); +void func_80A85304(Actor* thisx, PlayState* play); +void func_80A84FB4(ObjPurify* this, PlayState* play); +void func_80A85010(ObjPurify* this, PlayState* play); +void ObjPurify_DoNothing(ObjPurify* this, PlayState* play); +void func_80A85048(ObjPurify* this); +void func_80A84FA0(ObjPurify* this); +void func_80A8515C(ObjPurify* this); +void func_80A84FEC(ObjPurify* this); +void func_80A84EAC(ObjPurify* this); + +typedef struct ObjPurifyInfo { + /* 0x00 */ s16 objectId; + /* 0x04 */ f32 scale; + /* 0x08 */ Gfx* opaDLists[2]; + /* 0x10 */ Gfx* xluDLists[2]; + /* 0x18 */ AnimatedMaterial* animMat[2]; + /* 0x20 */ CollisionHeader* colHeader; + /* 0x24 */ s32 isDekuCity; +} ObjPurifyInfo; // size = 0x28 -#if 0 const ActorInit Obj_Purify_InitVars = { ACTOR_OBJ_PURIFY, ACTORCAT_BG, @@ -27,42 +53,248 @@ const ActorInit Obj_Purify_InitVars = { (ActorFunc)NULL, }; -#endif +ObjPurifyInfo sObjPurifyInfo[] = { + { + OBJECT_NUMA_OBJ, + 0.1f, + { NULL, NULL }, + { object_numa_obj_DL_0128E0, object_numa_obj_DL_012D90 }, + { object_numa_obj_Matanimheader_012CF8, object_numa_obj_Matanimheader_0131A8 }, + &object_numa_obj_Colheader_012818, + false, + }, + { + OBJECT_DEKUCITY_OBJ, + 1.0f, + { NULL, NULL }, + { object_dekucity_obj_DL_0004E0, object_dekucity_obj_DL_001030 }, + { object_dekucity_obj_Matanimheader_000E28, object_dekucity_obj_Matanimheader_001978 }, + &object_dekucity_obj_Colheader_0002AC, + true, + }, + { + OBJECT_DEKUCITY_OBJ, + 1.0f, + { object_dekucity_obj_DL_001ED8, object_dekucity_obj_DL_003998 }, + { object_dekucity_obj_DL_001D80, NULL }, + { object_dekucity_obj_Matanimheader_003820, NULL }, + NULL, + true, + }, + { + OBJECT_NUMA_OBJ, + 0.1f, + { NULL, NULL }, + { object_numa_obj_DL_012A60, object_numa_obj_DL_012F10 }, + { object_numa_obj_Matanimheader_012B58, object_numa_obj_Matanimheader_013008 }, + &object_numa_obj_Colheader_012818, + false, + }, + { + OBJECT_NUMA_OBJ, + 0.1f, + { NULL, NULL }, + { object_numa_obj_DL_012BF0, object_numa_obj_DL_0130A0 }, + { object_numa_obj_Matanimheader_012CE8, object_numa_obj_Matanimheader_013198 }, + &object_numa_obj_Colheader_012818, + false, + }, +}; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Purify/func_80A84CD0.s") +void ObjPurify_SetSysMatrix(f32 yPos) { + Matrix_GetCurrent()->yw = yPos; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Purify/func_80A84CF8.s") +s32 ObjPurify_IsPurified(ObjPurify* this) { + ObjPurifyInfo* info = &sObjPurifyInfo[OBJPURIFY_GET_INFO_INDEX(&this->dyna.actor)]; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Purify/ObjPurify_Init.s") + if (!info->isDekuCity) { + // woodfall temple wood flower unraveled + if (gSaveContext.save.weekEventReg[12] & 1) { + return true; + } + } + // woodfall temple purification cutscene watched + else { + if (gSaveContext.save.weekEventReg[20] & 2) { + return true; + } + } + return false; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Purify/ObjPurify_Destroy.s") +void ObjPurify_Init(Actor* thisx, PlayState* play) { + s32 pad; + ObjPurify* this = THIS; + ObjPurifyInfo* info = &sObjPurifyInfo[OBJPURIFY_GET_INFO_INDEX(&this->dyna.actor)]; + s32 sp20 = OBJPURIFY_GET_UNK_FLAG(thisx); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Purify/func_80A84EAC.s") + Actor_SetScale(&this->dyna.actor, info->scale); + if (sp20 == 1) { + DynaPolyActor_Init(&this->dyna, 0); + } + this->objIndex = Object_GetIndex(&play->objectCtx, info->objectId); + if (this->objIndex < 0) { + Actor_MarkForDeath(&this->dyna.actor); + } else if (sp20 == 0) { + func_80A84EAC(this); + } else if (ObjPurify_IsPurified(this)) { + Actor_MarkForDeath(&this->dyna.actor); + } else { + func_80A84EAC(this); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Purify/func_80A84EC0.s") +void ObjPurify_Destroy(Actor* thisx, PlayState* play) { + ObjPurify* this = THIS; + if (OBJPURIFY_GET_UNK_FLAG(&this->dyna.actor) == 1) { + DynaPoly_DeleteBgActor(play, &play->colCtx.dyna, this->dyna.bgId); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Purify/func_80A84FA0.s") +void func_80A84EAC(ObjPurify* this) { + this->actionFunc = func_80A84EC0; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Purify/func_80A84FB4.s") +void func_80A84EC0(ObjPurify* this, PlayState* play) { + s32 pad; + s32 sp28; + s32 index; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Purify/func_80A84FEC.s") + if (Object_IsLoaded(&play->objectCtx, this->objIndex)) { + sp28 = OBJPURIFY_GET_UNK_FLAG(&this->dyna.actor); + index = OBJPURIFY_GET_INFO_INDEX(&this->dyna.actor); + this->dyna.actor.objBankIndex = this->objIndex; + Actor_SetObjectDependency(play, &this->dyna.actor); + if (sp28 == 1) { + DynaPolyActor_LoadMesh(play, &this->dyna, sObjPurifyInfo[index].colHeader); + func_80A84FA0(this); + } else if (ObjPurify_IsPurified(this)) { + func_80A8515C(this); + } else { + func_80A84FEC(this); + } + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Purify/func_80A85010.s") +void func_80A84FA0(ObjPurify* this) { + this->actionFunc = func_80A84FB4; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Purify/func_80A85048.s") +void func_80A84FB4(ObjPurify* this, PlayState* play) { + if (ObjPurify_IsPurified(this)) { + Actor_MarkForDeath(&this->dyna.actor); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Purify/func_80A85074.s") +void func_80A84FEC(ObjPurify* this) { + this->dyna.actor.draw = func_80A851C8; + this->gfxIndex = 0; + this->actionFunc = func_80A85010; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Purify/func_80A850B0.s") +void func_80A85010(ObjPurify* this, PlayState* play) { + if (ObjPurify_IsPurified(this)) { + func_80A85048(this); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Purify/func_80A850E8.s") +void func_80A85048(ObjPurify* this) { + this->dyna.actor.draw = func_80A851C8; + this->gfxIndex = 0; + this->actionFunc = func_80A85074; + this->timer = 30; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Purify/func_80A8515C.s") +void func_80A85074(ObjPurify* this, PlayState* play) { + this->timer--; + if (this->timer <= 0) { + func_80A850B0(this); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Purify/func_80A85194.s") +void func_80A850B0(ObjPurify* this) { + f32 yPos = this->dyna.actor.home.pos.y; + this->dyna.actor.draw = func_80A85304; + this->unk168[1] = yPos - 90.0f; + this->actionFunc = func_80A850E8; + this->unk168[0] = yPos; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Purify/ObjPurify_Update.s") +void func_80A850E8(ObjPurify* this, PlayState* play) { + Math_StepToF(&this->unk168[0], this->dyna.actor.home.pos.y - 90.0f, 0.9f); + if (Math_StepToF(&this->unk168[1], this->dyna.actor.home.pos.y, 0.9f)) { + func_80A8515C(this); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Purify/func_80A851C8.s") +void func_80A8515C(ObjPurify* this) { + this->dyna.actor.flags &= ~ACTOR_FLAG_10; + this->dyna.actor.draw = func_80A851C8; + this->gfxIndex = 1; + this->actionFunc = ObjPurify_DoNothing; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Purify/func_80A85304.s") +void ObjPurify_DoNothing(ObjPurify* this, PlayState* play) { +} + +void ObjPurify_Update(Actor* thisx, PlayState* play) { + ObjPurify* this = THIS; + + this->actionFunc(this, play); +} + +void func_80A851C8(Actor* thisx, PlayState* play) { + s32 pad; + ObjPurify* this = THIS; + ObjPurifyInfo* info = &sObjPurifyInfo[OBJPURIFY_GET_INFO_INDEX(&this->dyna.actor)]; + Gfx* opaDList = info->opaDLists[this->gfxIndex]; + Gfx* xluDList = info->xluDLists[this->gfxIndex]; + AnimatedMaterial* animMat = info->animMat[this->gfxIndex]; + + OPEN_DISPS(play->state.gfxCtx); + + if (animMat != NULL) { + AnimatedMat_Draw(play, Lib_SegmentedToVirtual(animMat)); + } + if (opaDList != NULL) { + func_8012C28C(play->state.gfxCtx); + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_OPA_DISP++, opaDList); + } + if (xluDList != NULL) { + func_8012C2DC(play->state.gfxCtx); + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_XLU_DISP++, xluDList); + } + + CLOSE_DISPS(play->state.gfxCtx); +} + +void func_80A85304(Actor* thisx, PlayState* play) { + s32 pad; + ObjPurify* this = THIS; + ObjPurifyInfo* info = &sObjPurifyInfo[OBJPURIFY_GET_INFO_INDEX(&this->dyna.actor)]; + s32 sp6C[2]; + s32 i; + s32 index; + + if (this->unk168[1] < this->unk168[0]) { + sp6C[0] = 1; + sp6C[1] = 0; + } else { + sp6C[0] = 0; + sp6C[1] = 1; + } + + OPEN_DISPS(play->state.gfxCtx); + func_8012C2DC(play->state.gfxCtx); + for (i = 0; i < ARRAY_COUNT(sp6C); i++) { + index = sp6C[i]; + AnimatedMat_Draw(play, Lib_SegmentedToVirtual(info->animMat[index])); + ObjPurify_SetSysMatrix(this->unk168[index]); + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_XLU_DISP++, info->xluDLists[index]); + }; + CLOSE_DISPS(play->state.gfxCtx); +} diff --git a/src/overlays/actors/ovl_Obj_Purify/z_obj_purify.h b/src/overlays/actors/ovl_Obj_Purify/z_obj_purify.h index 46ee7a879..542938c80 100644 --- a/src/overlays/actors/ovl_Obj_Purify/z_obj_purify.h +++ b/src/overlays/actors/ovl_Obj_Purify/z_obj_purify.h @@ -5,15 +5,20 @@ struct ObjPurify; -typedef void (*ObjPurifyActionFunc)(struct ObjPurify*, GlobalContext*); +typedef void (*ObjPurifyActionFunc)(struct ObjPurify*, PlayState*); typedef struct ObjPurify { - /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x18]; - /* 0x015C */ ObjPurifyActionFunc actionFunc; - /* 0x0160 */ char unk_160[0x10]; + /* 0x000 */ DynaPolyActor dyna; + /* 0x15C */ ObjPurifyActionFunc actionFunc; + /* 0x160 */ s32 gfxIndex; + /* 0x164 */ s16 timer; + /* 0x166 */ s16 objIndex; + /* 0x168 */ f32 unk168[2]; } ObjPurify; // size = 0x170 extern const ActorInit Obj_Purify_InitVars; +#define OBJPURIFY_GET_INFO_INDEX(thisx) ((thisx)->params & 0xF) +#define OBJPURIFY_GET_UNK_FLAG(thisx) (((thisx)->params >> 0xC) & 1) + #endif // Z_OBJ_PURIFY_H diff --git a/src/overlays/actors/ovl_Obj_Pzlblock/z_obj_pzlblock.c b/src/overlays/actors/ovl_Obj_Pzlblock/z_obj_pzlblock.c index 95b9a3a13..9f024b0c0 100644 --- a/src/overlays/actors/ovl_Obj_Pzlblock/z_obj_pzlblock.c +++ b/src/overlays/actors/ovl_Obj_Pzlblock/z_obj_pzlblock.c @@ -12,18 +12,18 @@ #define THIS ((ObjPzlblock*)thisx) -void ObjPzlblock_Init(Actor* thisx, GlobalContext* globalCtx); -void ObjPzlblock_Destroy(Actor* thisx, GlobalContext* globalCtx); -void ObjPzlblock_Update(Actor* thisx, GlobalContext* globalCtx); +void ObjPzlblock_Init(Actor* thisx, PlayState* play); +void ObjPzlblock_Destroy(Actor* thisx, PlayState* play); +void ObjPzlblock_Update(Actor* thisx, PlayState* play); void func_809A3A48(ObjPzlblock* this); -void func_809A3A74(ObjPzlblock* this, GlobalContext* globalCtx); +void func_809A3A74(ObjPzlblock* this, PlayState* play); void func_809A3BA4(ObjPzlblock* this); -void func_809A3BC0(ObjPzlblock* this, GlobalContext* globalCtx); +void func_809A3BC0(ObjPzlblock* this, PlayState* play); 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); +void func_809A3D38(ObjPzlblock* this, PlayState* play); +void func_809A3E58(Actor* thisx, PlayState* play); +void func_809A3F0C(Actor* thisx, PlayState* play); const ActorInit Obj_Pzlblock_InitVars = { ACTOR_OBJ_PZLBLOCK, @@ -63,9 +63,9 @@ Color_RGB8 D_809A4088[] = { { 0, 255, 255 }, { 255, 0, 255 }, { 0, 0, 0 }, { 255, 255, 255 }, }; -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); +s32 func_809A33E0(ObjPzlblock* this, PlayState* play, s16 arg2) { + return !DynaPolyActor_ValidateMove(play, &this->dyna, 30, arg2, 1) || + !DynaPolyActor_ValidateMove(play, &this->dyna, 30, arg2, 28); } s32 func_809A3448(ObjPzlblock* this) { @@ -191,7 +191,7 @@ void func_809A376C(ObjPzlblock* this, s32 arg1) { this->unk_16C = arg1; } -void ObjPzlblock_Init(Actor* thisx, GlobalContext* globalCtx) { +void ObjPzlblock_Init(Actor* thisx, PlayState* play) { s32 pad; ObjPzlblock* this = THIS; s32 sp2C = OBJPZLBLOCK_GET_ROTZ(&this->dyna.actor); @@ -207,11 +207,11 @@ void ObjPzlblock_Init(Actor* thisx, GlobalContext* globalCtx) { DynaPolyActor_Init(&this->dyna, 0); - this->unk_17A = Object_GetIndex(&globalCtx->objectCtx, sp24->unk_00); + this->unk_17A = Object_GetIndex(&play->objectCtx, sp24->unk_00); if (sp28 == 0) { func_809A3D1C(this); - } else if (Flags_GetSwitch(globalCtx, OBJPZLBLOCK_GET_7F(&this->dyna.actor))) { + } else if (Flags_GetSwitch(play, 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); @@ -232,10 +232,10 @@ void ObjPzlblock_Init(Actor* thisx, GlobalContext* globalCtx) { } } -void ObjPzlblock_Destroy(Actor* thisx, GlobalContext* globalCtx) { +void ObjPzlblock_Destroy(Actor* thisx, PlayState* play) { ObjPzlblock* this = THIS; - DynaPoly_DeleteBgActor(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); + DynaPoly_DeleteBgActor(play, &play->colCtx.dyna, this->dyna.bgId); } void func_809A3A48(ObjPzlblock* this) { @@ -247,7 +247,7 @@ void func_809A3A48(ObjPzlblock* this) { this->unk_160 = 4; } -void func_809A3A74(ObjPzlblock* this, GlobalContext* globalCtx) { +void func_809A3A74(ObjPzlblock* this, PlayState* play) { s32 i; s32 sp20 = func_809A3448(this); @@ -261,14 +261,14 @@ void func_809A3A74(ObjPzlblock* this, GlobalContext* globalCtx) { 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)) { + if (!func_809A33E0(this, play, (this->dyna.pushForce > 0.0f) ? 90 : 120)) { func_809A376C(this, sp20); func_809A3BA4(this); return; } } - GET_PLAYER(globalCtx)->stateFlags2 &= ~0x10; + GET_PLAYER(play)->stateFlags2 &= ~0x10; this->dyna.pushForce = 0.0f; } } @@ -278,24 +278,24 @@ void func_809A3BA4(ObjPzlblock* this) { this->unk_160 = 5; } -void func_809A3BC0(ObjPzlblock* this, GlobalContext* globalCtx) { +void func_809A3BC0(ObjPzlblock* this, PlayState* play) { if (Math_StepToF(this->unk_164, this->unk_168, 2.3f)) { - Player* player = GET_PLAYER(globalCtx); + Player* player = GET_PLAYER(play); 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)) { + if (!func_809A35EC(this, this->unk_16C) || func_809A33E0(this, play, 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)) { + if (func_809A33E0(this, play, 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)); + Flags_SetSwitch(play, OBJPZLBLOCK_GET_7F(&this->dyna.actor)); sp20 = 1; } @@ -316,58 +316,58 @@ void func_809A3D1C(ObjPzlblock* this) { this->unk_160 = 4; } -void func_809A3D38(ObjPzlblock* this, GlobalContext* globalCtx) { +void func_809A3D38(ObjPzlblock* this, PlayState* play) { if (fabsf(this->dyna.pushForce) > 0.1f) { - GET_PLAYER(globalCtx)->stateFlags2 &= ~0x10; + GET_PLAYER(play)->stateFlags2 &= ~0x10; this->dyna.pushForce = 0.0f; } } -void ObjPzlblock_Update(Actor* thisx, GlobalContext* globalCtx) { +void ObjPzlblock_Update(Actor* thisx, PlayState* play) { 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); + Actor_UpdateBgCheckInfo(play, &this->dyna.actor, 15.0f, 30.0f, 0.0f, 4); - if (Object_IsLoaded(&globalCtx->objectCtx, this->unk_17A)) { + if (Object_IsLoaded(&play->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); + Actor_SetObjectDependency(play, &this->dyna.actor); + DynaPolyActor_LoadMesh(play, &this->dyna, sp2C->unk_04); this->dyna.actor.update = func_809A3E58; this->dyna.actor.draw = func_809A3F0C; } } -void func_809A3E58(Actor* thisx, GlobalContext* globalCtx) { +void func_809A3E58(Actor* thisx, PlayState* play) { ObjPzlblock* this = THIS; - this->actionFunc(this, globalCtx); + this->actionFunc(this, play); 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); + Actor_UpdateBgCheckInfo(play, &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->dyna.actor.bgCheckFlags & 1) && !DynaPoly_GetActor(&play->colCtx, this->dyna.actor.floorBgId)) { this->unk_160 = 0; } } } -void func_809A3F0C(Actor* thisx, GlobalContext* globalCtx) { +void func_809A3F0C(Actor* thisx, PlayState* play) { ObjPzlblockStruct* sp2C = &D_809A4060[OBJPZLBLOCK_GET_1000(thisx)]; Color_RGB8* sp28 = &D_809A4088[OBJPZLBLOCK_GET_700(thisx)]; - OPEN_DISPS(globalCtx->state.gfxCtx); + OPEN_DISPS(play->state.gfxCtx); - func_8012C28C(globalCtx->state.gfxCtx); + func_8012C28C(play->state.gfxCtx); - gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(play->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); + CLOSE_DISPS(play->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 fa1ca1f59..c40800483 100644 --- a/src/overlays/actors/ovl_Obj_Pzlblock/z_obj_pzlblock.h +++ b/src/overlays/actors/ovl_Obj_Pzlblock/z_obj_pzlblock.h @@ -5,7 +5,7 @@ struct ObjPzlblock; -typedef void (*ObjPzlblockActionFunc)(struct ObjPzlblock*, GlobalContext*); +typedef void (*ObjPzlblockActionFunc)(struct ObjPzlblock*, PlayState*); #define OBJPZLBLOCK_GET_7F(thisx) ((thisx)->params & 0x7F) #define OBJPZLBLOCK_GET_700(thisx) (((thisx)->params >> 8) & 7) 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 24f3fe0d6..23ca0872d 100644 --- a/src/overlays/actors/ovl_Obj_Raillift/z_obj_raillift.c +++ b/src/overlays/actors/ovl_Obj_Raillift/z_obj_raillift.c @@ -6,26 +6,27 @@ #include "z_obj_raillift.h" #include "objects/object_raillift/object_raillift.h" +#include "overlays/actors/ovl_Obj_Etcetera/z_obj_etcetera.h" #define FLAGS (ACTOR_FLAG_10) #define THIS ((ObjRaillift*)thisx) -void ObjRaillift_Init(Actor* thisx, GlobalContext* globalCtx); -void ObjRaillift_Destroy(Actor* thisx, GlobalContext* globalCtx); -void ObjRaillift_Update(Actor* thisx, GlobalContext* globalCtx); -void ObjRaillift_Draw(Actor* thisx, GlobalContext* globalCtx); +void ObjRaillift_Init(Actor* thisx, PlayState* play); +void ObjRaillift_Destroy(Actor* thisx, PlayState* play); +void ObjRaillift_Update(Actor* thisx, PlayState* play); +void ObjRaillift_Draw(Actor* thisx, PlayState* play); -void ObjRaillift_DrawDekuFlowerPlatformColorful(Actor* thisx, GlobalContext* globalCtx); -void ObjRaillift_DrawDekuFlowerPlatform(Actor* thisx, GlobalContext* globalCtx); +void ObjRaillift_DrawDekuFlowerPlatformColorful(Actor* thisx, PlayState* play); +void ObjRaillift_DrawDekuFlowerPlatform(Actor* thisx, PlayState* play); -void ObjRaillift_DoNothing(ObjRaillift* this, GlobalContext* globalCtx); -void ObjRaillift_Idle(ObjRaillift* this, GlobalContext* globalCtx); +void ObjRaillift_DoNothing(ObjRaillift* this, PlayState* play); +void ObjRaillift_Idle(ObjRaillift* this, PlayState* play); void ObjRaillift_UpdatePosition(ObjRaillift* this, s32 arg1); -void ObjRaillift_StartCutscene(ObjRaillift* this, GlobalContext* globalCtx); -void ObjRaillift_Teleport(ObjRaillift* this, GlobalContext* globalCtx); -void ObjRaillift_Wait(ObjRaillift* this, GlobalContext* globalCtx); -void ObjRaillift_Move(ObjRaillift* this, GlobalContext* globalCtx); +void ObjRaillift_StartCutscene(ObjRaillift* this, PlayState* play); +void ObjRaillift_Teleport(ObjRaillift* this, PlayState* play); +void ObjRaillift_Wait(ObjRaillift* this, PlayState* play); +void ObjRaillift_Move(ObjRaillift* this, PlayState* play); const ActorInit Obj_Raillift_InitVars = { ACTOR_OBJ_RAILLIFT, @@ -52,7 +53,7 @@ void ObjRaillift_UpdatePosition(ObjRaillift* this, s32 idx) { Math_Vec3s_ToVec3f(&this->dyna.actor.world.pos, &this->points[idx]); } -void ObjRaillift_Init(Actor* thisx, GlobalContext* globalCtx) { +void ObjRaillift_Init(Actor* thisx, PlayState* play) { ObjRaillift* this = THIS; s32 pad; Path* path; @@ -66,16 +67,16 @@ void ObjRaillift_Init(Actor* thisx, GlobalContext* globalCtx) { thisx->shape.rot.z = 0; thisx->world.rot.z = 0; DynaPolyActor_Init(&this->dyna, 1); - DynaPolyActor_LoadMesh(globalCtx, &this->dyna, sColHeaders[type]); + DynaPolyActor_LoadMesh(play, &this->dyna, sColHeaders[type]); this->speed = OBJRAILLIFT_GET_SPEED(thisx); if (this->speed < 0.0f) { this->speed = -this->speed; isColorful = true; } if (type == DEKU_FLOWER_PLATFORM) { - Actor_SpawnAsChild(&globalCtx->actorCtx, thisx, globalCtx, ACTOR_OBJ_ETCETERA, thisx->world.pos.x, - thisx->world.pos.y, thisx->world.pos.z, thisx->shape.rot.x, thisx->shape.rot.y, - thisx->shape.rot.z, 0); + Actor_SpawnAsChild(&play->actorCtx, thisx, play, ACTOR_OBJ_ETCETERA, thisx->world.pos.x, thisx->world.pos.y, + thisx->world.pos.z, thisx->shape.rot.x, thisx->shape.rot.y, thisx->shape.rot.z, + DEKU_FLOWER_PARAMS(DEKU_FLOWER_TYPE_PINK)); if (isColorful) { thisx->draw = ObjRaillift_DrawDekuFlowerPlatformColorful; } else { @@ -85,13 +86,13 @@ void ObjRaillift_Init(Actor* thisx, GlobalContext* globalCtx) { if (this->speed < 0.01f) { this->actionFunc = ObjRaillift_DoNothing; } else { - path = &globalCtx->setupPathList[OBJRAILLIFT_GET_PATH(thisx)]; + path = &play->setupPathList[OBJRAILLIFT_GET_PATH(thisx)]; this->curPoint = OBJRAILLIFT_GET_STARTING_POINT(thisx); this->endPoint = path->count - 1; this->direction = 1; this->points = Lib_SegmentedToVirtual(path->points); ObjRaillift_UpdatePosition(this, this->curPoint); - if (OBJRAILLIFT_HAS_FLAG(thisx) && !Flags_GetSwitch(globalCtx, OBJRAILLIFT_GET_FLAG(thisx))) { + if (OBJRAILLIFT_HAS_FLAG(thisx) && !Flags_GetSwitch(play, OBJRAILLIFT_GET_FLAG(thisx))) { this->actionFunc = ObjRaillift_Idle; } else { this->actionFunc = ObjRaillift_Move; @@ -99,40 +100,39 @@ void ObjRaillift_Init(Actor* thisx, GlobalContext* globalCtx) { } } -void ObjRaillift_Destroy(Actor* thisx, GlobalContext* globalCtx) { +void ObjRaillift_Destroy(Actor* thisx, PlayState* play) { ObjRaillift* this = THIS; - DynaPoly_DeleteBgActor(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); + DynaPoly_DeleteBgActor(play, &play->colCtx.dyna, this->dyna.bgId); } -void ObjRaillift_DoNothing(ObjRaillift* this, GlobalContext* globalCtx) { +void ObjRaillift_DoNothing(ObjRaillift* this, PlayState* play) { } -void ObjRaillift_Move(ObjRaillift* this, GlobalContext* globalCtx) { - s32 isTeleporting; +void ObjRaillift_Move(ObjRaillift* this, PlayState* play) { + Actor* thisx = &this->dyna.actor; Vec3f nextPoint; f32 speed; f32 target; f32 step; + s32 isTeleporting; s32 isPosUpdated; - Vec3s* initialPoint; Vec3s* endPoint; - s32 pad; - if (OBJRAILLIFT_HAS_FLAG(&this->dyna.actor)) { - if (!Flags_GetSwitch(globalCtx, OBJRAILLIFT_GET_FLAG(&this->dyna.actor))) { + if (OBJRAILLIFT_HAS_FLAG(thisx)) { + if (!Flags_GetSwitch(play, OBJRAILLIFT_GET_FLAG(thisx))) { this->actionFunc = ObjRaillift_Idle; return; } - if (OBJRAILLIFT_GET_TYPE(&this->dyna.actor) == DEKU_FLOWER_PLATFORM) { - func_800B9010(&this->dyna.actor, NA_SE_EV_PLATE_LIFT_LEVEL - SFX_FLAG); + if (OBJRAILLIFT_GET_TYPE(thisx) == DEKU_FLOWER_PLATFORM) { + func_800B9010(thisx, NA_SE_EV_PLATE_LIFT_LEVEL - SFX_FLAG); } } - Math_Vec3s_ToVec3f(&nextPoint, &(&this->points[this->curPoint])[this->direction]); - Math_Vec3f_Diff(&nextPoint, &this->dyna.actor.world.pos, &this->dyna.actor.velocity); - speed = Math3D_Vec3fMagnitude(&this->dyna.actor.velocity); + Math_Vec3s_ToVec3f(&nextPoint, this->points + this->curPoint + this->direction); + Math_Vec3f_Diff(&nextPoint, &thisx->world.pos, &thisx->velocity); + speed = Math3D_Vec3fMagnitude(&thisx->velocity); if ((speed < (this->speed * 8.0f)) && (this->speed > 2.0f)) { target = ((this->speed - 2.0f) * 0.1f) + 2.0f; step = this->speed * 0.03f; @@ -141,17 +141,16 @@ void ObjRaillift_Move(ObjRaillift* this, GlobalContext* globalCtx) { step = this->speed * 0.16f; } - Math_StepToF(&this->dyna.actor.speedXZ, target, step); - if ((this->dyna.actor.speedXZ + 0.05f) < speed) { - Math_Vec3f_Scale(&this->dyna.actor.velocity, this->dyna.actor.speedXZ / speed); - 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; + Math_StepToF(&thisx->speedXZ, target, step); + if ((thisx->speedXZ + 0.05f) < speed) { + Math_Vec3f_Scale(&thisx->velocity, thisx->speedXZ / speed); + thisx->world.pos.x += thisx->velocity.x; + thisx->world.pos.y += thisx->velocity.y; + thisx->world.pos.z += thisx->velocity.z; } else { this->curPoint += this->direction; - if (1) {} - this->dyna.actor.speedXZ *= 0.4f; - isTeleporting = OBJRAILLIFT_SHOULD_TELEPORT(&this->dyna.actor); + thisx->speedXZ *= 0.4f; + isTeleporting = OBJRAILLIFT_SHOULD_TELEPORT(thisx); isPosUpdated = true; if (((this->curPoint >= this->endPoint) && (this->direction > 0)) || ((this->curPoint <= 0) && (this->direction < 0))) { @@ -162,11 +161,10 @@ void ObjRaillift_Move(ObjRaillift* this, GlobalContext* globalCtx) { } else { endPoint = &this->points[this->endPoint]; this->curPoint = this->direction > 0 ? 0 : this->endPoint; - initialPoint = &this->points[0]; - if ((initialPoint->x != endPoint->x) || (initialPoint->y != endPoint->y) || - (initialPoint->z != endPoint->z)) { + if ((this->points[0].x != endPoint->x) || (this->points[0].y != endPoint->y) || + (this->points[0].z != endPoint->z)) { this->actionFunc = ObjRaillift_Teleport; - func_800C62BC(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); + func_800C62BC(play, &play->colCtx.dyna, this->dyna.bgId); isPosUpdated = false; } } @@ -181,15 +179,15 @@ void ObjRaillift_Move(ObjRaillift* this, GlobalContext* globalCtx) { /* Will teleport to what ever curpoint is set to */ -void ObjRaillift_Teleport(ObjRaillift* this, GlobalContext* globalCtx) { +void ObjRaillift_Teleport(ObjRaillift* this, PlayState* play) { if (!DynaPolyActor_IsInRidingMovingState(&this->dyna)) { ObjRaillift_UpdatePosition(this, this->curPoint); - func_800C6314(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); + func_800C6314(play, &play->colCtx.dyna, this->dyna.bgId); this->actionFunc = ObjRaillift_Move; } } -void ObjRaillift_Wait(ObjRaillift* this, GlobalContext* globalCtx) { +void ObjRaillift_Wait(ObjRaillift* this, PlayState* play) { this->waitTimer--; if (this->waitTimer <= 0) { this->actionFunc = ObjRaillift_Move; @@ -197,15 +195,15 @@ void ObjRaillift_Wait(ObjRaillift* this, GlobalContext* globalCtx) { } } -void ObjRaillift_Idle(ObjRaillift* this, GlobalContext* globalCtx) { - if (Flags_GetSwitch(globalCtx, OBJRAILLIFT_GET_FLAG(&this->dyna.actor))) { +void ObjRaillift_Idle(ObjRaillift* this, PlayState* play) { + if (Flags_GetSwitch(play, OBJRAILLIFT_GET_FLAG(&this->dyna.actor))) { this->dyna.actor.speedXZ = 0.0f; ActorCutscene_SetIntentToPlay(this->dyna.actor.cutscene); this->actionFunc = ObjRaillift_StartCutscene; } } -void ObjRaillift_StartCutscene(ObjRaillift* this, GlobalContext* globalCtx) { +void ObjRaillift_StartCutscene(ObjRaillift* this, PlayState* play) { if (ActorCutscene_GetCanPlayNext(this->dyna.actor.cutscene)) { ActorCutscene_StartAndSetUnkLinkFields(this->dyna.actor.cutscene, &this->dyna.actor); this->cutsceneTimer = 50; @@ -215,13 +213,13 @@ void ObjRaillift_StartCutscene(ObjRaillift* this, GlobalContext* globalCtx) { } } -void ObjRaillift_Update(Actor* thisx, GlobalContext* globalCtx) { +void ObjRaillift_Update(Actor* thisx, PlayState* play) { ObjRaillift* this = THIS; f32 target; f32 step; - this->actionFunc(this, globalCtx); - Actor_SetFocus(&this->dyna.actor, 10.0f); + this->actionFunc(this, play); + Actor_SetFocus(thisx, 10.0f); if (this->cutsceneTimer > 0) { this->cutsceneTimer--; if (this->cutsceneTimer == 0) { @@ -261,29 +259,29 @@ void ObjRaillift_Update(Actor* thisx, GlobalContext* globalCtx) { } } -void ObjRaillift_Draw(Actor* thisx, GlobalContext* globalCtx) { +void ObjRaillift_Draw(Actor* thisx, PlayState* play) { s32 pad; - OPEN_DISPS(globalCtx->state.gfxCtx); - func_8012C28C(globalCtx->state.gfxCtx); + OPEN_DISPS(play->state.gfxCtx); + func_8012C28C(play->state.gfxCtx); gSPSegment(POLY_OPA_DISP++, 0x08, - Gfx_TwoTexScrollEnvColor(globalCtx->state.gfxCtx, 0, globalCtx->gameplayFrames, 0, 32, 32, 1, 0, 0, 32, - 32, 0, 0, 0, 160)); - gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + Gfx_TwoTexScrollEnvColor(play->state.gfxCtx, 0, play->gameplayFrames, 0, 32, 32, 1, 0, 0, 32, 32, 0, 0, + 0, 160)); + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_OPA_DISP++, object_raillift_DL_004BF0); - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->state.gfxCtx); } /* The non-colorful platforms are the ones found in Woodfall Temple */ -void ObjRaillift_DrawDekuFlowerPlatform(Actor* thisx, GlobalContext* globalCtx) { - Gfx_DrawDListOpa(globalCtx, object_raillift_DL_000208); +void ObjRaillift_DrawDekuFlowerPlatform(Actor* thisx, PlayState* play) { + Gfx_DrawDListOpa(play, object_raillift_DL_000208); } /* The colorful platforms are the ones found in Deku Palace */ -void ObjRaillift_DrawDekuFlowerPlatformColorful(Actor* thisx, GlobalContext* globalCtx) { - Gfx_DrawDListOpa(globalCtx, object_raillift_DL_0071B8); +void ObjRaillift_DrawDekuFlowerPlatformColorful(Actor* thisx, PlayState* play) { + Gfx_DrawDListOpa(play, object_raillift_DL_0071B8); } diff --git a/src/overlays/actors/ovl_Obj_Raillift/z_obj_raillift.h b/src/overlays/actors/ovl_Obj_Raillift/z_obj_raillift.h index 06ff23d92..cd55d1fa6 100644 --- a/src/overlays/actors/ovl_Obj_Raillift/z_obj_raillift.h +++ b/src/overlays/actors/ovl_Obj_Raillift/z_obj_raillift.h @@ -5,7 +5,7 @@ struct ObjRaillift; -typedef void (*ObjRailliftActionFunc)(struct ObjRaillift*, GlobalContext*); +typedef void (*ObjRailliftActionFunc)(struct ObjRaillift*, PlayState*); #define OBJRAILLIFT_GET_TYPE(thisx) (((thisx)->params >> 0xF) & 1) #define OBJRAILLIFT_HAS_FLAG(thisx) (((thisx)->params >> 0xD) & 1) 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 ff0c8d270..b39187c75 100644 --- a/src/overlays/actors/ovl_Obj_Roomtimer/z_obj_roomtimer.c +++ b/src/overlays/actors/ovl_Obj_Roomtimer/z_obj_roomtimer.c @@ -10,13 +10,13 @@ #define THIS ((ObjRoomtimer*)thisx) -void ObjRoomtimer_Init(Actor* thisx, GlobalContext* globalCtx); -void ObjRoomtimer_Destroy(Actor* thisx, GlobalContext* globalCtx); -void ObjRoomtimer_Update(Actor* thisx, GlobalContext* globalCtx); +void ObjRoomtimer_Init(Actor* thisx, PlayState* play); +void ObjRoomtimer_Destroy(Actor* thisx, PlayState* play); +void ObjRoomtimer_Update(Actor* thisx, PlayState* play); -void func_80973CD8(ObjRoomtimer* this, GlobalContext* globalCtx); -void func_80973D3C(ObjRoomtimer* this, GlobalContext* globalCtx); -void func_80973DE0(ObjRoomtimer* this, GlobalContext* globalCtx); +void func_80973CD8(ObjRoomtimer* this, PlayState* play); +void func_80973D3C(ObjRoomtimer* this, PlayState* play); +void func_80973DE0(ObjRoomtimer* this, PlayState* play); const ActorInit Obj_Roomtimer_InitVars = { ACTOR_OBJ_ROOMTIMER, @@ -30,7 +30,7 @@ const ActorInit Obj_Roomtimer_InitVars = { (ActorFunc)NULL, }; -void ObjRoomtimer_Init(Actor* thisx, GlobalContext* globalCtx) { +void ObjRoomtimer_Init(Actor* thisx, PlayState* play) { ObjRoomtimer* this = THIS; this->switchFlag = ROOMTIMER_GET_SWITCHFLAG(thisx); @@ -42,7 +42,7 @@ void ObjRoomtimer_Init(Actor* thisx, GlobalContext* globalCtx) { this->actionFunc = func_80973CD8; } -void ObjRoomtimer_Destroy(Actor* thisx, GlobalContext* globalCtx) { +void ObjRoomtimer_Destroy(Actor* thisx, PlayState* play) { ObjRoomtimer* this = THIS; if (this->actor.params != 0x1FF && gSaveContext.unk_3DD0[4] > 0) { @@ -50,17 +50,17 @@ void ObjRoomtimer_Destroy(Actor* thisx, GlobalContext* globalCtx) { } } -void func_80973CD8(ObjRoomtimer* this, GlobalContext* globalCtx) { +void func_80973CD8(ObjRoomtimer* this, PlayState* play) { if (this->actor.params != 0x1FF) { func_8010E9F0(4, this->actor.params); } - func_800BC154(globalCtx, &globalCtx->actorCtx, &this->actor, ACTORCAT_PROP); + func_800BC154(play, &play->actorCtx, &this->actor, ACTORCAT_PROP); this->actionFunc = func_80973D3C; } -void func_80973D3C(ObjRoomtimer* this, GlobalContext* globalCtx) { - if (Flags_GetClearTemp(globalCtx, this->actor.room)) { +void func_80973D3C(ObjRoomtimer* this, PlayState* play) { + if (Flags_GetClearTemp(play, this->actor.room)) { if (this->actor.params != 0x1FF) { gSaveContext.unk_3DD0[4] = 5; } @@ -68,15 +68,15 @@ 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->state); + func_80169EFC(&play->state); Actor_MarkForDeath(&this->actor); } } -void func_80973DE0(ObjRoomtimer* this, GlobalContext* globalCtx) { +void func_80973DE0(ObjRoomtimer* this, PlayState* play) { if (ActorCutscene_GetCanPlayNext(this->actor.cutscene)) { - Flags_SetClear(globalCtx, this->actor.room); - Flags_SetSwitch(globalCtx, this->switchFlag); + Flags_SetClear(play, this->actor.room); + Flags_SetSwitch(play, this->switchFlag); if (ActorCutscene_GetLength(this->actor.cutscene) != -1) { ActorCutscene_StartAndSetUnkLinkFields(this->actor.cutscene, &this->actor); } @@ -86,8 +86,8 @@ void func_80973DE0(ObjRoomtimer* this, GlobalContext* globalCtx) { } } -void ObjRoomtimer_Update(Actor* thisx, GlobalContext* globalCtx) { +void ObjRoomtimer_Update(Actor* thisx, PlayState* play) { ObjRoomtimer* this = THIS; - this->actionFunc(this, globalCtx); + this->actionFunc(this, play); } diff --git a/src/overlays/actors/ovl_Obj_Roomtimer/z_obj_roomtimer.h b/src/overlays/actors/ovl_Obj_Roomtimer/z_obj_roomtimer.h index b58d5da49..be15ac11a 100644 --- a/src/overlays/actors/ovl_Obj_Roomtimer/z_obj_roomtimer.h +++ b/src/overlays/actors/ovl_Obj_Roomtimer/z_obj_roomtimer.h @@ -7,12 +7,12 @@ struct ObjRoomtimer; -typedef void (*ObjRoomtimerActionFunc)(struct ObjRoomtimer*, GlobalContext*); +typedef void (*ObjRoomtimerActionFunc)(struct ObjRoomtimer*, PlayState*); typedef struct ObjRoomtimer { - /* 0x0000 */ Actor actor; - /* 0x0144 */ ObjRoomtimerActionFunc actionFunc; - /* 0x0148 */ s32 switchFlag; + /* 0x000 */ Actor actor; + /* 0x144 */ ObjRoomtimerActionFunc actionFunc; + /* 0x148 */ s32 switchFlag; } ObjRoomtimer; // size = 0x14C extern const ActorInit Obj_Roomtimer_InitVars; diff --git a/src/overlays/actors/ovl_Obj_Rotlift/z_obj_rotlift.c b/src/overlays/actors/ovl_Obj_Rotlift/z_obj_rotlift.c index 6163c753c..6a5298728 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,26 @@ */ #include "z_obj_rotlift.h" +#include "objects/object_rotlift/object_rotlift.h" +#include "overlays/actors/ovl_Obj_Etcetera/z_obj_etcetera.h" #define FLAGS 0x00000000 #define THIS ((ObjRotlift*)thisx) -void ObjRotlift_Init(Actor* thisx, GlobalContext* globalCtx); -void ObjRotlift_Destroy(Actor* thisx, GlobalContext* globalCtx); -void ObjRotlift_Update(Actor* thisx, GlobalContext* globalCtx); -void ObjRotlift_Draw(Actor* thisx, GlobalContext* globalCtx); +void ObjRotlift_Init(Actor* thisx, PlayState* play2); +void ObjRotlift_Destroy(Actor* thisx, PlayState* play); +void ObjRotlift_Update(Actor* thisx, PlayState* play); +void ObjRotlift_Draw(Actor* thisx, PlayState* play); + +void ObjRotlift_MoveDekuFlowers(ObjRotlift* this); + +typedef struct ObjRotliftModelInfo { + /* 0x0 */ Gfx* dList; + /* 0x4 */ AnimatedMaterial* animMat; + /* 0x8 */ CollisionHeader* colHeader; +} ObjRotliftModelInfo; // size = 0xC -#if 0 const ActorInit Obj_Rotlift_InitVars = { ACTOR_OBJ_ROTLIFT, ACTORCAT_BG, @@ -28,24 +37,118 @@ const ActorInit Obj_Rotlift_InitVars = { (ActorFunc)ObjRotlift_Draw, }; -// static InitChainEntry sInitChain[] = { -static InitChainEntry D_80B96178[] = { +struct ObjRotliftModelInfo sModelInfo[] = { + { + gDekuMoonDungeonRotatingPlatformsDL, + gDekuMoonDungeonRotatingPlatformsUnusedTexAnim, + &gDekuMoonDungeonRotatingPlatformsCol, + }, + { + gDekuMoonDungeonRotatingSpikesDL, + gDekuMoonDungeonRotatingSpikesUnusedTexAnim, + &gDekuMoonDungeonRotatingSpikesCol, + }, +}; + +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; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Rotlift/func_80B95E20.s") + 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; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Rotlift/ObjRotlift_Init.s") + posOffset -= 600.0f; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Rotlift/ObjRotlift_Destroy.s") +void ObjRotlift_Init(Actor* thisx, PlayState* play2) { + PlayState* play = play2; + ObjRotlift* this = THIS; + s32 type = OBJROTLIFT_GET_TYPE(&this->dyna.actor); + s32 dekuFlowerParams; + s32 i; + ObjRotliftModelInfo* modelInfo; + ObjEtcetera** dekuFlowers; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Rotlift/ObjRotlift_Update.s") + Actor_ProcessInitChain(&this->dyna.actor, sInitChain); + if (type == OBJROTLIFT_TYPE_PLATFORMS) { + for (dekuFlowers = this->dekuFlowers, i = 0; i < ARRAY_COUNT(this->dekuFlowers); i++, dekuFlowers++) { + // Depending on the params, the platforms can be configured in one of two ways: + // 1. Pink Deku Flower, Pink Deku Flower + // 2. Gold Deku Flower, Pink Deku Flower + if (!OBJROTLIFT_FIRST_DEKU_FLOWER_IS_GOLD(thisx) || (i != 0)) { + dekuFlowerParams = DEKU_FLOWER_PARAMS(DEKU_FLOWER_TYPE_PINK); + } else { + dekuFlowerParams = DEKU_FLOWER_PARAMS(DEKU_FLOWER_TYPE_GOLD); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Rotlift/ObjRotlift_Draw.s") + *dekuFlowers = (ObjEtcetera*)Actor_SpawnAsChild( + &play->actorCtx, &this->dyna.actor, play, ACTOR_OBJ_ETCETERA, this->dyna.actor.world.pos.x, + this->dyna.actor.world.pos.y, this->dyna.actor.world.pos.z, this->dyna.actor.shape.rot.x, + this->dyna.actor.shape.rot.y, this->dyna.actor.shape.rot.z, dekuFlowerParams); + } + + ObjRotlift_MoveDekuFlowers(this); + } + + DynaPolyActor_Init(&this->dyna, 3); + + modelInfo = &sModelInfo[type]; + DynaPolyActor_LoadMesh(play, &this->dyna, modelInfo->colHeader); + modelInfo->animMat = Lib_SegmentedToVirtual(modelInfo->animMat); +} + +void ObjRotlift_Destroy(Actor* thisx, PlayState* play) { + ObjRotlift* this = THIS; + + DynaPoly_DeleteBgActor(play, &play->colCtx.dyna, this->dyna.bgId); +} + +void ObjRotlift_Update(Actor* thisx, PlayState* play) { + ObjRotlift* this = THIS; + s16 angShift; + s32 angVelocity; + + if (OBJROTLIFT_GET_TYPE(&this->dyna.actor) == OBJROTLIFT_TYPE_PLATFORMS) { + ObjRotlift_MoveDekuFlowers(this); + } + + if (thisx->params >= 0) { + angVelocity = -0xC8; + } else { + angVelocity = 0xC8; + } + + angShift = angVelocity; + this->dyna.actor.shape.rot.y += angShift; +} + +void ObjRotlift_Draw(Actor* thisx, PlayState* play) { + s32 pad; + ObjRotlift* this = THIS; + ObjRotliftModelInfo* modelInfo = &sModelInfo[OBJROTLIFT_GET_TYPE(&this->dyna.actor)]; + + // Neither of the displaylists reference other segments, so this call is ultimately pointless. + AnimatedMat_Draw(play, modelInfo->animMat); + Gfx_DrawDListOpa(play, modelInfo->dList); +} diff --git a/src/overlays/actors/ovl_Obj_Rotlift/z_obj_rotlift.h b/src/overlays/actors/ovl_Obj_Rotlift/z_obj_rotlift.h index a58a6b621..46cbef0ee 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,21 @@ #include "global.h" +#include "overlays/actors/ovl_Obj_Etcetera/z_obj_etcetera.h" + +#define OBJROTLIFT_GET_TYPE(thisx) ((thisx)->params & 1) +#define OBJROTLIFT_FIRST_DEKU_FLOWER_IS_GOLD(thisx) ((thisx)->params & 0x4000) + +typedef enum { + /* 0 */ OBJROTLIFT_TYPE_PLATFORMS, + /* 1 */ OBJROTLIFT_TYPE_SPIKES, +} ObjRotliftType; + 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 f6f744d15..5246b20d4 100644 --- a/src/overlays/actors/ovl_Obj_Shutter/z_obj_shutter.c +++ b/src/overlays/actors/ovl_Obj_Shutter/z_obj_shutter.c @@ -5,17 +5,17 @@ */ #include "z_obj_shutter.h" +#include "objects/object_f53_obj/object_f53_obj.h" #define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_20) #define THIS ((ObjShutter*)thisx) -void ObjShutter_Init(Actor* thisx, GlobalContext* globalCtx); -void ObjShutter_Destroy(Actor* thisx, GlobalContext* globalCtx); -void ObjShutter_Update(Actor* thisx, GlobalContext* globalCtx); -void ObjShutter_Draw(Actor* thisx, GlobalContext* globalCtx); +void ObjShutter_Init(Actor* thisx, PlayState* play); +void ObjShutter_Destroy(Actor* thisx, PlayState* play); +void ObjShutter_Update(Actor* thisx, PlayState* play2); +void ObjShutter_Draw(Actor* thisx, PlayState* play); -#if 0 const ActorInit Obj_Shutter_InitVars = { ACTOR_OBJ_SHUTTER, ACTORCAT_PROP, @@ -28,14 +28,66 @@ const ActorInit Obj_Shutter_InitVars = { (ActorFunc)ObjShutter_Draw, }; -#endif +void ObjShutter_Init(Actor* thisx, PlayState* play) { +} -extern UNK_TYPE D_060011E0; +void ObjShutter_Destroy(Actor* thisx, PlayState* play) { +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Shutter/ObjShutter_Init.s") +static u8 sScheduleScript[] = { + /* 0x0 */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(10, 0, 20, 0, 0x9 - 0x6), + /* 0x6 */ SCHEDULE_CMD_RET_VAL_L(2), + /* 0x9 */ SCHEDULE_CMD_RET_VAL_L(1), +}; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Shutter/ObjShutter_Destroy.s") +void ObjShutter_Update(Actor* thisx, PlayState* play2) { + ObjShutter* this = THIS; + PlayState* play = play2; + ScheduleOutput scheduleOutput; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Shutter/ObjShutter_Update.s") + Schedule_RunScript(play, sScheduleScript, &scheduleOutput); + if (scheduleOutput.result == 1) { + if (this->scheduleResult != scheduleOutput.result) { + this->actor.velocity.y = 0.0f; + } + if ((this->verticalOffset >= 80.0f) || (this->scheduleResult == 0)) { + this->actor.velocity.y = 0.0f; + this->verticalOffset = 80.0f; + } else { + this->verticalOffset += 10.0f; + } + } else { + if (this->scheduleResult != scheduleOutput.result) { + this->actor.velocity.y = 0.0f; + } + if (this->verticalOffset != 0.0f) { + this->actor.velocity.y -= 3.0f; + this->verticalOffset += this->actor.velocity.y; + if (this->verticalOffset <= 0.0f) { + this->actor.velocity.y = fabsf(this->actor.velocity.y) * 0.8f; + if ((s32)this->actor.velocity.y == 0) { + this->actor.velocity.y = 0.0f; + this->verticalOffset = 0.0f; + } + } + } + } + this->scheduleResult = scheduleOutput.result; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Shutter/ObjShutter_Draw.s") +void ObjShutter_Draw(Actor* thisx, PlayState* play) { + ObjShutter* this = THIS; + + Matrix_Translate(this->actor.world.pos.x, this->actor.world.pos.y + this->verticalOffset, this->actor.world.pos.z, + MTXMODE_NEW); + Matrix_Scale(0.1f, 0.1f, 0.1f, MTXMODE_APPLY); + Matrix_RotateYS(this->actor.world.rot.y, MTXMODE_APPLY); + + OPEN_DISPS(play->state.gfxCtx); + + func_8012C28C(play->state.gfxCtx); + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_OPA_DISP++, gBankShutterDL); + + CLOSE_DISPS(play->state.gfxCtx); +} diff --git a/src/overlays/actors/ovl_Obj_Shutter/z_obj_shutter.h b/src/overlays/actors/ovl_Obj_Shutter/z_obj_shutter.h index 764f5dd2a..b777c64b3 100644 --- a/src/overlays/actors/ovl_Obj_Shutter/z_obj_shutter.h +++ b/src/overlays/actors/ovl_Obj_Shutter/z_obj_shutter.h @@ -7,7 +7,8 @@ struct ObjShutter; typedef struct ObjShutter { /* 0x000 */ Actor actor; - /* 0x144 */ char unk_144[0x8]; + /* 0x144 */ u8 scheduleResult; + /* 0x148 */ f32 verticalOffset; } ObjShutter; // size = 0x14C extern const ActorInit Obj_Shutter_InitVars; diff --git a/src/overlays/actors/ovl_Obj_Skateblock/z_obj_skateblock.c b/src/overlays/actors/ovl_Obj_Skateblock/z_obj_skateblock.c index 1253747e4..3eee8491a 100644 --- a/src/overlays/actors/ovl_Obj_Skateblock/z_obj_skateblock.c +++ b/src/overlays/actors/ovl_Obj_Skateblock/z_obj_skateblock.c @@ -11,21 +11,21 @@ #define THIS ((ObjSkateblock*)thisx) -void ObjSkateblock_Init(Actor* thisx, GlobalContext* globalCtx); -void ObjSkateblock_Destroy(Actor* thisx, GlobalContext* globalCtx); -void ObjSkateblock_Update(Actor* thisx, GlobalContext* globalCtx); -void ObjSkateblock_Draw(Actor* thisx, GlobalContext* globalCtx); +void ObjSkateblock_Init(Actor* thisx, PlayState* play); +void ObjSkateblock_Destroy(Actor* thisx, PlayState* play); +void ObjSkateblock_Update(Actor* thisx, PlayState* play); +void ObjSkateblock_Draw(Actor* thisx, PlayState* play); void func_80A22308(ObjSkateblock* this); -void func_80A22334(ObjSkateblock* this, GlobalContext* globalCtx); +void func_80A22334(ObjSkateblock* this, PlayState* play); void func_80A2244C(ObjSkateblock* this); -void func_80A224A4(ObjSkateblock* this, GlobalContext* globalCtx); +void func_80A224A4(ObjSkateblock* this, PlayState* play); void func_80A22628(ObjSkateblock* this); -void func_80A2264C(ObjSkateblock* this, GlobalContext* globalCtx); +void func_80A2264C(ObjSkateblock* this, PlayState* play); void func_80A22728(ObjSkateblock* this); -void func_80A2273C(ObjSkateblock* this, GlobalContext* globalCtx); +void func_80A2273C(ObjSkateblock* this, PlayState* play); void func_80A227A4(ObjSkateblock* this); -void func_80A227C0(ObjSkateblock* this, GlobalContext* globalCtx); +void func_80A227C0(ObjSkateblock* this, PlayState* play); const ActorInit Obj_Skateblock_InitVars = { ACTOR_OBJ_SKATEBLOCK, @@ -138,7 +138,7 @@ void func_80A212F0(Vec3f* arg0, Vec3f* arg1, s16 arg2) { arg0->z = (arg1->z * temp_f0) - (arg1->x * sp1C); } -s32 func_80A21370(ObjSkateblock* this, GlobalContext* globalCtx) { +s32 func_80A21370(ObjSkateblock* this, PlayState* play) { ObjSkateblockFloor* floor; s32 i; s32 pad; @@ -162,7 +162,7 @@ s32 func_80A21370(ObjSkateblock* this, GlobalContext* globalCtx) { sp8C.z = this->dyna.actor.world.pos.z + ((D_80A22A1C[i].z * this->dyna.actor.scale.z) + D_80A22A44[i].z); floor->height = - BgCheck_EntityRaycastFloor6(&globalCtx->colCtx, &floor->poly, &floor->bgId, &this->dyna.actor, &sp8C, 0.0f); + BgCheck_EntityRaycastFloor6(&play->colCtx, &floor->poly, &floor->bgId, &this->dyna.actor, &sp8C, 0.0f); if (floor->height > BGCHECK_Y_MIN + 1.0f) { sp88 = true; @@ -181,13 +181,13 @@ s32 func_80A21370(ObjSkateblock* this, GlobalContext* globalCtx) { return sp88; } -s32 func_80A21548(ObjSkateblock* this, GlobalContext* globalCtx) { +s32 func_80A21548(ObjSkateblock* this, PlayState* play) { s32 i; ObjSkateblockFloor* floor; this->unk_1C1 &= ~4; - if (func_80A21370(this, globalCtx)) { + if (func_80A21370(this, play)) { f32 maxHeight = BGCHECK_Y_MIN; s32 phi_v1 = false; f32 temp_f12 = this->dyna.actor.world.pos.y - 10.0f; @@ -210,7 +210,7 @@ s32 func_80A21548(ObjSkateblock* this, GlobalContext* globalCtx) { return false; } -s32 func_80A216D4(ObjSkateblock* this, GlobalContext* globalCtx, f32 arg2, Vec3f* arg3) { +s32 func_80A216D4(ObjSkateblock* this, PlayState* play, f32 arg2, Vec3f* arg3) { s32 pad; f32 spE8; f32 spE4; @@ -257,7 +257,7 @@ s32 func_80A216D4(ObjSkateblock* this, GlobalContext* globalCtx, f32 arg2, Vec3f spC8.y = spD4.y; spC8.z = temp_f26 + spD4.z; - if (BgCheck_EntityLineTest3(&globalCtx->colCtx, &spD4, &spC8, &spB0, &spA0, true, false, false, true, &spA4, + if (BgCheck_EntityLineTest3(&play->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) { @@ -270,10 +270,10 @@ s32 func_80A216D4(ObjSkateblock* this, GlobalContext* globalCtx, f32 arg2, Vec3f return ret; } -s32 func_80A21934(ObjSkateblock* this, GlobalContext* globalCtx) { +s32 func_80A21934(ObjSkateblock* this, PlayState* play) { Vec3f sp1C; - if (func_80A216D4(this, globalCtx, 0.0f, &sp1C)) { + if (func_80A216D4(this, play, 0.0f, &sp1C)) { this->dyna.actor.world.pos.x += sp1C.x; this->dyna.actor.world.pos.z += sp1C.z; return true; @@ -281,7 +281,7 @@ s32 func_80A21934(ObjSkateblock* this, GlobalContext* globalCtx) { return false; } -s32 func_80A21990(ObjSkateblock* this, GlobalContext* globalCtx, Vec3f* arg2) { +s32 func_80A21990(ObjSkateblock* this, PlayState* play, Vec3f* arg2) { s32 i; f32 sp100; s16 phi_s6 = this->dyna.yRotation; @@ -330,7 +330,7 @@ s32 func_80A21990(ObjSkateblock* this, GlobalContext* globalCtx, Vec3f* arg2) { spE0.y = spEC.y; spE0.z = temp_f30 + spEC.z; - if (BgCheck_EntityLineTest3(&globalCtx->colCtx, &spEC, &spE0, &spC8, &spB8, true, false, false, true, &spBC, + if (BgCheck_EntityLineTest3(&play->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) { @@ -345,10 +345,10 @@ s32 func_80A21990(ObjSkateblock* this, GlobalContext* globalCtx, Vec3f* arg2) { return ret; } -s32 func_80A21C30(ObjSkateblock* this, GlobalContext* globalCtx) { +s32 func_80A21C30(ObjSkateblock* this, PlayState* play) { Vec3f sp1C; - if (func_80A21990(this, globalCtx, &sp1C)) { + if (func_80A21990(this, play, &sp1C)) { this->dyna.actor.world.pos.x += sp1C.x; this->dyna.actor.world.pos.z += sp1C.z; return true; @@ -366,8 +366,8 @@ void func_80A21C88(ObjSkateblock* this, s32 arg1) { this->unk_170 = arg1; } -void func_80A21CB4(ObjSkateblock* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); +void func_80A21CB4(ObjSkateblock* this, PlayState* play) { + Player* player = GET_PLAYER(play); player->stateFlags2 &= ~0x10; this->dyna.pushForce = 0.0f; @@ -407,7 +407,7 @@ void func_80A21D1C(ObjSkateblock* this) { } } -void func_80A21E9C(ObjSkateblock* this, GlobalContext* globalCtx) { +void func_80A21E9C(ObjSkateblock* this, PlayState* play) { DynaPolyActor* temp_v0; s32 i; ObjSkateblockFloor* ptr; @@ -419,7 +419,7 @@ void func_80A21E9C(ObjSkateblock* this, GlobalContext* globalCtx) { for (i = 0; i < ARRAY_COUNT(this->unk_184); i++) { ptr = &this->unk_184[i]; - temp_v0 = DynaPoly_GetActor(&globalCtx->colCtx, ptr->bgId); + temp_v0 = DynaPoly_GetActor(&play->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; @@ -435,7 +435,7 @@ void func_80A21F68(ObjSkateblock* this) { this->unk_17C = 0; } -void func_80A21F74(ObjSkateblock* this, GlobalContext* globalCtx) { +void func_80A21F74(ObjSkateblock* this, PlayState* play) { s32 pad; Vec3f spA8; Vec3f sp9C; @@ -479,18 +479,18 @@ void func_80A21F74(ObjSkateblock* this, GlobalContext* globalCtx) { 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, + func_800B0E48(play, &spA8, &gZeroVec3f, &D_80A22ACC, &D_80A22AD8, &D_80A22ADC, temp, (Rand_ZeroOne() * 20.0f) + 30.0f); } } } -void ObjSkateblock_Init(Actor* thisx, GlobalContext* globalCtx) { +void ObjSkateblock_Init(Actor* thisx, PlayState* play) { ObjSkateblock* this = THIS; Actor_ProcessInitChain(&this->dyna.actor, sInitChain); DynaPolyActor_Init(&this->dyna, 1); - DynaPolyActor_LoadMesh(globalCtx, &this->dyna, &gameplay_dangeon_keep_Colheader_007498); + DynaPolyActor_LoadMesh(play, &this->dyna, &gameplay_dangeon_keep_Colheader_007498); if (D_80A22A18 == NULL) { D_80A22A18 = Lib_SegmentedToVirtual(gameplay_dangeon_keep_Matanimheader_01B370); } @@ -500,10 +500,10 @@ void ObjSkateblock_Init(Actor* thisx, GlobalContext* globalCtx) { D_80A22A14 &= 0x1F; } -void ObjSkateblock_Destroy(Actor* thisx, GlobalContext* globalCtx) { +void ObjSkateblock_Destroy(Actor* thisx, PlayState* play) { ObjSkateblock* this = THIS; - DynaPoly_DeleteBgActor(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); + DynaPoly_DeleteBgActor(play, &play->colCtx.dyna, this->dyna.bgId); } void func_80A22308(ObjSkateblock* this) { @@ -515,14 +515,14 @@ void func_80A22308(ObjSkateblock* this) { this->dyna.actor.velocity.y = 0.0f; } -void func_80A22334(ObjSkateblock* this, GlobalContext* globalCtx) { +void func_80A22334(ObjSkateblock* this, PlayState* play) { s32 pad; s32 sp30; s32 sp2C; Vec3f sp20; func_80A21CD8(this); - func_80A21548(this, globalCtx); + func_80A21548(this, play); sp2C = func_80A21150(this); func_80A211F4(this, sp2C); @@ -531,16 +531,16 @@ void func_80A22334(ObjSkateblock* this, GlobalContext* globalCtx) { 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_80A216D4(this, play, 2.0f, &sp20) && !Player_InCsMode(play)) { func_80A21C88(this, sp2C); func_80A2244C(this); sp30 = false; - func_800B7298(globalCtx, &this->dyna.actor, 7); + func_800B7298(play, &this->dyna.actor, 7); this->unk_1C1 |= 1; } if (sp30) { - func_80A21CB4(this, globalCtx); + func_80A21CB4(this, play); } } @@ -553,7 +553,7 @@ void func_80A2244C(ObjSkateblock* this) { func_80A21F68(this); } -void func_80A224A4(ObjSkateblock* this, GlobalContext* globalCtx) { +void func_80A224A4(ObjSkateblock* this, PlayState* play) { s32 pad; s32 sp28 = false; s32 sp24 = false; @@ -562,7 +562,7 @@ void func_80A224A4(ObjSkateblock* this, GlobalContext* globalCtx) { *this->unk_16C += this->unk_164; - if (func_80A21934(this, globalCtx)) { + if (func_80A21934(this, play)) { Actor_PlaySfxAtPos(&this->dyna.actor, NA_SE_EV_BLOCK_BOUND); func_80A21D1C(this); sp28 = true; @@ -572,8 +572,8 @@ void func_80A224A4(ObjSkateblock* this, GlobalContext* globalCtx) { func_80A21CD8(this); - if (!func_80A21548(this, globalCtx)) { - func_80A21C30(this, globalCtx); + if (!func_80A21548(this, play)) { + func_80A21C30(this, play); func_80A21D1C(this); func_80A22628(this); sp24 = true; @@ -586,15 +586,15 @@ void func_80A224A4(ObjSkateblock* this, GlobalContext* globalCtx) { } if (sp24 || sp28 || (this->unk_17A == 1)) { - func_80A21CB4(this, globalCtx); + func_80A21CB4(this, play); } 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_800B7298(play, &this->dyna.actor, 6); } - func_80A21F74(this, globalCtx); + func_80A21F74(this, play); } void func_80A22628(ObjSkateblock* this) { @@ -603,19 +603,19 @@ void func_80A22628(ObjSkateblock* this) { this->dyna.actor.velocity.y = this->dyna.actor.gravity; } -void func_80A2264C(ObjSkateblock* this, GlobalContext* globalCtx) { +void func_80A2264C(ObjSkateblock* this, PlayState* play) { s32 pad; s32 sp20; if (func_80A21150(this) != -1) { - func_80A21CB4(this, globalCtx); + func_80A21CB4(this, play); } func_80A21CD8(this); - sp20 = func_80A21548(this, globalCtx); + sp20 = func_80A21548(this, play); 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); + if (func_800C9B40(&play->colCtx, this->dyna.actor.floorPoly, this->dyna.actor.floorBgId) == 12) { + func_800C62BC(play, &play->colCtx.dyna, this->dyna.bgId); this->dyna.actor.draw = NULL; func_80A22728(this); return; @@ -631,7 +631,7 @@ void func_80A22728(ObjSkateblock* this) { this->actionFunc = func_80A2273C; } -void func_80A2273C(ObjSkateblock* this, GlobalContext* globalCtx) { +void func_80A2273C(ObjSkateblock* this, PlayState* play) { 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; @@ -646,9 +646,9 @@ void func_80A227A4(ObjSkateblock* this) { this->unk_17A = 40; } -void func_80A227C0(ObjSkateblock* this, GlobalContext* globalCtx) { +void func_80A227C0(ObjSkateblock* this, PlayState* play) { if (func_80A21150(this) != -1) { - func_80A21CB4(this, globalCtx); + func_80A21CB4(this, play); } if (this->unk_17A > 0) { @@ -656,7 +656,7 @@ void func_80A227C0(ObjSkateblock* this, GlobalContext* globalCtx) { return; } - func_800C6314(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); + func_800C6314(play, &play->colCtx.dyna, this->dyna.bgId); this->dyna.actor.draw = ObjSkateblock_Draw; if (Math_StepToF(&this->dyna.actor.world.pos.y, this->dyna.actor.home.pos.y, 1.0f)) { @@ -668,29 +668,29 @@ void func_80A227C0(ObjSkateblock* this, GlobalContext* globalCtx) { } } -void ObjSkateblock_Update(Actor* thisx, GlobalContext* globalCtx) { +void ObjSkateblock_Update(Actor* thisx, PlayState* play) { ObjSkateblock* this = THIS; D_80A22A10 &= ~(1 << this->unk_1C0); - this->actionFunc(this, globalCtx); + this->actionFunc(this, play); this->unk_1C1 &= ~2; } -void ObjSkateblock_Draw(Actor* thisx, GlobalContext* globalCtx) { +void ObjSkateblock_Draw(Actor* thisx, PlayState* play) { s32 pad; ObjSkateblock* this = THIS; Color_RGB8* sp2C = &D_80A22B08[OBJSKAEBLOCK_GET_F(&this->dyna.actor)]; - OPEN_DISPS(globalCtx->state.gfxCtx); + OPEN_DISPS(play->state.gfxCtx); - func_8012C28C(globalCtx->state.gfxCtx); - AnimatedMat_DrawStep(globalCtx, D_80A22A18, 0); + func_8012C28C(play->state.gfxCtx); + AnimatedMat_DrawStep(play, D_80A22A18, 0); - gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(play->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); + func_80A21E9C(this, play); - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->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 c26a93844..97a2e6ede 100644 --- a/src/overlays/actors/ovl_Obj_Skateblock/z_obj_skateblock.h +++ b/src/overlays/actors/ovl_Obj_Skateblock/z_obj_skateblock.h @@ -5,31 +5,31 @@ struct ObjSkateblock; -typedef void (*ObjSkateblockActionFunc)(struct ObjSkateblock*, GlobalContext*); +typedef void (*ObjSkateblockActionFunc)(struct ObjSkateblock*, PlayState*); #define OBJSKAEBLOCK_GET_F(thisx) ((thisx)->params & 0xF) typedef struct { - /* 0x00 */ CollisionPoly* poly; - /* 0x04 */ f32 height; - /* 0x08 */ s32 bgId; + /* 0x0 */ CollisionPoly* poly; + /* 0x4 */ f32 height; + /* 0x8 */ s32 bgId; } ObjSkateblockFloor; // size = 0xC typedef struct ObjSkateblock { - /* 0x0000 */ DynaPolyActor dyna; - /* 0x015C */ ObjSkateblockActionFunc actionFunc; - /* 0x0160 */ f32 unk_160; - /* 0x0164 */ f32 unk_164; - /* 0x0168 */ f32 unk_168; - /* 0x016C */ f32* unk_16C; - /* 0x0170 */ s16 unk_170; - /* 0x0172 */ s16 unk_172[4]; - /* 0x017A */ s16 unk_17A; - /* 0x017C */ s16 unk_17C; - /* 0x0180 */ f32 unk_180; - /* 0x0184 */ ObjSkateblockFloor unk_184[5]; - /* 0x01C0 */ u8 unk_1C0; - /* 0x01C1 */ u8 unk_1C1; + /* 0x000 */ DynaPolyActor dyna; + /* 0x15C */ ObjSkateblockActionFunc actionFunc; + /* 0x160 */ f32 unk_160; + /* 0x164 */ f32 unk_164; + /* 0x168 */ f32 unk_168; + /* 0x16C */ f32* unk_16C; + /* 0x170 */ s16 unk_170; + /* 0x172 */ s16 unk_172[4]; + /* 0x17A */ s16 unk_17A; + /* 0x17C */ s16 unk_17C; + /* 0x180 */ f32 unk_180; + /* 0x184 */ ObjSkateblockFloor unk_184[5]; + /* 0x1C0 */ u8 unk_1C0; + /* 0x1C1 */ u8 unk_1C1; } ObjSkateblock; // size = 0x1C4 extern const ActorInit Obj_Skateblock_InitVars; diff --git a/src/overlays/actors/ovl_Obj_Smork/z_obj_smork.c b/src/overlays/actors/ovl_Obj_Smork/z_obj_smork.c index ded17da2d..9d3b1265d 100644 --- a/src/overlays/actors/ovl_Obj_Smork/z_obj_smork.c +++ b/src/overlays/actors/ovl_Obj_Smork/z_obj_smork.c @@ -11,10 +11,10 @@ #define THIS ((ObjSmork*)thisx) -void ObjSmork_Init(Actor* thisx, GlobalContext* globalCtx); -void ObjSmork_Destroy(Actor* thisx, GlobalContext* globalCtx); -void ObjSmork_Update(Actor* thisx, GlobalContext* globalCtx); -void ObjSmork_Draw(Actor* thisx, GlobalContext* globalCtx); +void ObjSmork_Init(Actor* thisx, PlayState* play); +void ObjSmork_Destroy(Actor* thisx, PlayState* play); +void ObjSmork_Update(Actor* thisx, PlayState* play); +void ObjSmork_Draw(Actor* thisx, PlayState* play); const ActorInit Obj_Smork_InitVars = { ACTOR_OBJ_SMORK, @@ -90,7 +90,7 @@ void func_80A3D940(ObjSmork* this) { Math_ApproachF(&this->unk_1B8, (this->unk_1C4 == 0) ? 0.0f : 1.0f, 0.02f, 1000.0f); } -void func_80A3D9C4(ObjSmork* this, GlobalContext* globalCtx) { +void func_80A3D9C4(ObjSmork* this, PlayState* play) { u8 sp57; u8 sp56; s32 i; @@ -108,27 +108,26 @@ void func_80A3D9C4(ObjSmork* this, GlobalContext* globalCtx) { } if (this->unk_1B8 > 0.0f) { - Matrix_InsertTranslation(this->actor.world.pos.x, this->actor.world.pos.y, this->actor.world.pos.z, - MTXMODE_NEW); - this->actor.shape.rot.y = BINANG_ROT180(Camera_GetCamDirYaw(GET_ACTIVE_CAM(globalCtx))); - Matrix_RotateY(this->actor.shape.rot.y, MTXMODE_APPLY); + Matrix_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(play))); + Matrix_RotateYS(this->actor.shape.rot.y, MTXMODE_APPLY); Matrix_Scale(0.1f, 0.1f, 0.0f, MTXMODE_APPLY); - OPEN_DISPS(globalCtx->state.gfxCtx); + OPEN_DISPS(play->state.gfxCtx); - func_8012C28C(globalCtx->state.gfxCtx); + func_8012C28C(play->state.gfxCtx); gSPSegment(POLY_XLU_DISP++, 0x08, - Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, 0, sp57, 0x20, 0x20, 1, 0, sp56, 0x20, 0x20)); + Gfx_TwoTexScroll(play->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); + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_XLU_DISP++, object_f53_obj_DL_001C00); - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->state.gfxCtx); } } -void ObjSmork_Init(Actor* thisx, GlobalContext* globalCtx) { +void ObjSmork_Init(Actor* thisx, PlayState* play) { ObjSmork* this = THIS; Lib_MemCpy(this->unk_148, ovl_Obj_Smork_Vtx_000C10, sizeof(Vtx) * ARRAY_COUNT(ovl_Obj_Smork_Vtx_000C10)); @@ -136,17 +135,17 @@ void ObjSmork_Init(Actor* thisx, GlobalContext* globalCtx) { this->unk_1C4 = 0; } -void ObjSmork_Destroy(Actor* thisx, GlobalContext* globalCtx) { +void ObjSmork_Destroy(Actor* thisx, PlayState* play) { } -void ObjSmork_Update(Actor* thisx, GlobalContext* globalCtx) { +void ObjSmork_Update(Actor* thisx, PlayState* play) { ObjSmork* this = THIS; func_80A3D940(this); } -void ObjSmork_Draw(Actor* thisx, GlobalContext* globalCtx) { +void ObjSmork_Draw(Actor* thisx, PlayState* play) { ObjSmork* this = THIS; - func_80A3D9C4(this, globalCtx); + func_80A3D9C4(this, play); } 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 15a63746b..72f452682 100644 --- a/src/overlays/actors/ovl_Obj_Snowball/z_obj_snowball.c +++ b/src/overlays/actors/ovl_Obj_Snowball/z_obj_snowball.c @@ -12,26 +12,26 @@ #define THIS ((ObjSnowball*)thisx) -void ObjSnowball_Init(Actor* thisx, GlobalContext* globalCtx); -void ObjSnowball_Destroy(Actor* thisx, GlobalContext* globalCtx); -void ObjSnowball_Update(Actor* thisx, GlobalContext* globalCtx); -void ObjSnowball_Draw(Actor* thisx, GlobalContext* globalCtx); +void ObjSnowball_Init(Actor* thisx, PlayState* play); +void ObjSnowball_Destroy(Actor* thisx, PlayState* play); +void ObjSnowball_Update(Actor* thisx, PlayState* play); +void ObjSnowball_Draw(Actor* thisx, PlayState* play); -void func_80B02CD0(ObjSnowball* this, GlobalContext* globalCtx); -void func_80B02D58(ObjSnowball* this, GlobalContext* globalCtx); -void func_80B02DB0(ObjSnowball* this, GlobalContext* globalCtx); -void func_80B02E54(ObjSnowball* this, GlobalContext* globalCtx); -void func_80B04338(ObjSnowball* this, GlobalContext* globalCtx); -void func_80B04350(ObjSnowball* this, GlobalContext* globalCtx); -void func_80B04540(ObjSnowball* this, GlobalContext* globalCtx); -void func_80B0457C(ObjSnowball* this, GlobalContext* globalCtx); -void func_80B04608(ObjSnowball* this, GlobalContext* globalCtx); -void func_80B04648(ObjSnowball* this, GlobalContext* globalCtx); -void func_80B046E4(ObjSnowball* this, GlobalContext* globalCtx); -void func_80B047C0(ObjSnowball* this, GlobalContext* globalCtx); -void func_80B04B48(ObjSnowball* this, GlobalContext* globalCtx); -void func_80B04B60(ObjSnowball* this, GlobalContext* globalCtx); -void func_80B04D34(Actor* thisx, GlobalContext* globalCtx); +void func_80B02CD0(ObjSnowball* this, PlayState* play); +void func_80B02D58(ObjSnowball* this, PlayState* play); +void func_80B02DB0(ObjSnowball* this, PlayState* play); +void func_80B02E54(ObjSnowball* this, PlayState* play); +void func_80B04338(ObjSnowball* this, PlayState* play); +void func_80B04350(ObjSnowball* this, PlayState* play); +void func_80B04540(ObjSnowball* this, PlayState* play); +void func_80B0457C(ObjSnowball* this, PlayState* play); +void func_80B04608(ObjSnowball* this, PlayState* play); +void func_80B04648(ObjSnowball* this, PlayState* play); +void func_80B046E4(ObjSnowball* this, PlayState* play); +void func_80B047C0(ObjSnowball* this, PlayState* play); +void func_80B04B48(ObjSnowball* this, PlayState* play); +void func_80B04B60(ObjSnowball* this, PlayState* play); +void func_80B04D34(Actor* thisx, PlayState* play); const ActorInit Obj_Snowball_InitVars = { ACTOR_OBJ_SNOWBALL, @@ -68,7 +68,7 @@ static ColliderJntSphInit sJntSphInit = { OC2_TYPE_2, COLSHAPE_JNTSPH, }, - 1, + ARRAY_COUNT(sJntSphElementsInit), sJntSphElementsInit, }; @@ -101,42 +101,41 @@ static InitChainEntry sInitChain[] = { ICHAIN_F32(uncullZoneForward, 2000, ICHAIN_STOP), }; -void func_80B02CD0(ObjSnowball* this, GlobalContext* globalCtx) { +void func_80B02CD0(ObjSnowball* this, PlayState* play) { ObjSnowballStruct2* ptr = &D_80B04F84[this->actor.home.rot.y]; - Actor_SpawnAsChildAndCutscene(&globalCtx->actorCtx, globalCtx, ptr->unk_00, this->actor.home.pos.x, - this->actor.home.pos.y, this->actor.home.pos.z, this->actor.home.rot.x, 0, - this->actor.home.rot.z, ptr->unk_02, -1, this->actor.unk20, NULL); + Actor_SpawnAsChildAndCutscene(&play->actorCtx, play, ptr->unk_00, this->actor.home.pos.x, this->actor.home.pos.y, + this->actor.home.pos.z, this->actor.home.rot.x, 0, this->actor.home.rot.z, + ptr->unk_02, -1, this->actor.unk20, NULL); } -void func_80B02D58(ObjSnowball* this, GlobalContext* globalCtx) { +void func_80B02D58(ObjSnowball* this, PlayState* play) { s32 temp_v0 = func_800A8150(OBJSNOWBALL_GET_3F(&this->actor)); if (temp_v0 >= 0) { - Item_DropCollectible(globalCtx, &this->actor.home.pos, (OBJSNOWBALL_GET_7F00(&this->actor) << 8) | temp_v0); + Item_DropCollectible(play, &this->actor.home.pos, (OBJSNOWBALL_GET_7F00(&this->actor) << 8) | temp_v0); } } -void func_80B02DB0(ObjSnowball* this, GlobalContext* globalCtx) { +void func_80B02DB0(ObjSnowball* this, PlayState* play) { s32 pad; ObjSnowballStruct2* ptr = &D_80B04F84[this->actor.home.rot.y]; - Actor_SpawnAsChildAndCutscene(&globalCtx->actorCtx, globalCtx, ptr->unk_00, this->actor.home.pos.x, - this->actor.home.pos.y, this->actor.home.pos.z, this->actor.home.rot.x, 0, - this->actor.home.rot.z, this->actor.params | ptr->unk_02, + Actor_SpawnAsChildAndCutscene(&play->actorCtx, play, ptr->unk_00, this->actor.home.pos.x, this->actor.home.pos.y, + this->actor.home.pos.z, this->actor.home.rot.x, 0, this->actor.home.rot.z, + this->actor.params | ptr->unk_02, ActorCutscene_GetAdditionalCutscene(this->actor.cutscene), this->actor.unk20, NULL); } -void func_80B02E54(ObjSnowball* this, GlobalContext* globalCtx) { +void func_80B02E54(ObjSnowball* this, PlayState* play) { ObjSnowballStruct2* ptr = &D_80B04F84[this->actor.home.rot.y]; - Actor_SpawnAsChildAndCutscene(&globalCtx->actorCtx, globalCtx, ptr->unk_00, this->actor.home.pos.x, - this->actor.home.pos.y, this->actor.home.pos.z, this->actor.home.rot.x, 0, - this->actor.home.rot.z, this->actor.params | ptr->unk_02, -1, this->actor.unk20, - NULL); + Actor_SpawnAsChildAndCutscene(&play->actorCtx, play, ptr->unk_00, this->actor.home.pos.x, this->actor.home.pos.y, + this->actor.home.pos.z, this->actor.home.rot.x, 0, this->actor.home.rot.z, + this->actor.params | ptr->unk_02, -1, this->actor.unk20, NULL); } -void func_80B02EE4(ObjSnowball* this, GlobalContext* globalCtx) { +void func_80B02EE4(ObjSnowball* this, PlayState* play) { Vec3f spAC; Vec3f spA0; Vec3f sp94; @@ -156,12 +155,12 @@ void func_80B02EE4(ObjSnowball* this, GlobalContext* globalCtx) { spAC.y = spA0.y * -0.06f; spAC.z = spA0.z * -0.06f; - func_800B0E48(globalCtx, &sp94, &spA0, &spAC, &D_80B04FB4, &D_80B04FB8, (s32)(Rand_ZeroOne() * 30.0f) + 15, + func_800B0E48(play, &sp94, &spA0, &spAC, &D_80B04FB4, &D_80B04FB8, (s32)(Rand_ZeroOne() * 30.0f) + 15, (s32)(Rand_ZeroOne() * 40.0f) + 30); } } -void func_80B030F8(ObjSnowball* this, GlobalContext* globalCtx) { +void func_80B030F8(ObjSnowball* this, PlayState* play) { s32 pad; f32 temp_f28 = sqrtf(this->unk_20C); Vec3f spFC; @@ -205,7 +204,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,7 +227,7 @@ 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, + EffectSsKakera_Spawn(play, &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; @@ -237,7 +236,7 @@ void func_80B030F8(ObjSnowball* this, GlobalContext* globalCtx) { temp_s0 = (s32)(Rand_ZeroOne() * 50.0f * temp_f28) + 40; temp_s1 = (s32)(Rand_ZeroOne() * 60.0f * temp_f28) + 50; - func_800B0E48(globalCtx, &spFC, &gZeroVec3f, &D_80B04FBC, &D_80B04FB4, &D_80B04FB8, temp_s0, temp_s1); + func_800B0E48(play, &spFC, &gZeroVec3f, &D_80B04FBC, &D_80B04FB4, &D_80B04FB8, temp_s0, temp_s1); } } @@ -245,7 +244,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); @@ -268,12 +267,12 @@ void func_80B030F8(ObjSnowball* this, GlobalContext* globalCtx) { spE4.y = spF0.y * -0.05f; spE4.z = spF0.z * -0.02f; - EffectSsIceSmoke_Spawn(globalCtx, &spFC, &spF0, &spE4, ((s32)(Rand_ZeroOne() * 170.0f) + 150) * temp_f28); + EffectSsIceSmoke_Spawn(play, &spFC, &spF0, &spE4, ((s32)(Rand_ZeroOne() * 170.0f) + 150) * temp_f28); } } } -void func_80B03688(ObjSnowball* this, GlobalContext* globalCtx) { +void func_80B03688(ObjSnowball* this, PlayState* play) { s32 i; Vec3f spB8; Vec3f spAC; @@ -306,7 +305,7 @@ void func_80B03688(ObjSnowball* this, GlobalContext* globalCtx) { temp_s3 = (s32)(Rand_ZeroOne() * 60.0f * temp_f22) + 70; - func_800B0E48(globalCtx, &spB8, &spAC, &spA0, &D_80B04FB4, &D_80B04FB8, temp_s3, + func_800B0E48(play, &spB8, &spAC, &spA0, &D_80B04FB4, &D_80B04FB8, temp_s3, (s32)(Rand_ZeroOne() * 70.0f * temp_f22) + 70); } } else { @@ -328,12 +327,12 @@ void func_80B03688(ObjSnowball* this, GlobalContext* globalCtx) { spB8.y = (Rand_ZeroOne() * 20.0f) + this->actor.home.pos.y; spB8.z = (spB8.z * temp_f20) + this->actor.home.pos.z; - EffectSsIceSmoke_Spawn(globalCtx, &spB8, &spAC, &spA0, (s32)(Rand_ZeroOne() * 140.0f * temp_f22) + 100); + EffectSsIceSmoke_Spawn(play, &spB8, &spAC, &spA0, (s32)(Rand_ZeroOne() * 140.0f * temp_f22) + 100); } } } -void func_80B03A80(GlobalContext* globalCtx, f32 arg1, Vec3f* arg2) { +void func_80B03A80(PlayState* play, f32 arg1, Vec3f* arg2) { f32 temp_f30 = sqrtf(arg1); Vec3f spD8; Vec3f spCC; @@ -368,7 +367,7 @@ void func_80B03A80(GlobalContext* globalCtx, f32 arg1, Vec3f* arg2) { 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; @@ -377,7 +376,7 @@ void func_80B03A80(GlobalContext* globalCtx, f32 arg1, Vec3f* arg2) { 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 +388,7 @@ void func_80B03A80(GlobalContext* globalCtx, f32 arg1, Vec3f* arg2) { phi_s0 = 0x40; } - EffectSsKakera_Spawn(globalCtx, &spD8, &spCC, &spD8, phi_s2, phi_s0, 30, 0, 0, + EffectSsKakera_Spawn(play, &spD8, &spCC, &spD8, phi_s2, phi_s0, 30, 0, 0, ((Rand_ZeroOne() * 15.0f) + 25.0f) * arg1, phi_s3, 0, 0x36, -1, OBJECT_GOROIWA, temp_s1); spD8.x += (Rand_ZeroOne() * 80.0f) - 40.0f; @@ -398,12 +397,12 @@ void func_80B03A80(GlobalContext* globalCtx, f32 arg1, Vec3f* arg2) { phi_s0 = (s32)(Rand_ZeroOne() * 60.0f * temp_f30) + 60; - func_800B0E48(globalCtx, &spD8, &gZeroVec3f, &D_80B04FBC, &D_80B04FB4, &D_80B04FB8, phi_s0, + func_800B0E48(play, &spD8, &gZeroVec3f, &D_80B04FBC, &D_80B04FB4, &D_80B04FB8, phi_s0, (s32)(Rand_ZeroOne() * 30.0f * temp_f30) + 60); } } -void func_80B03E2C(ObjSnowball* this, GlobalContext* globalCtx) { +void func_80B03E2C(ObjSnowball* this, PlayState* play) { ObjSnowballStruct* ptr; s32 i; @@ -432,23 +431,23 @@ void func_80B03E2C(ObjSnowball* this, GlobalContext* globalCtx) { } } -void func_80B03FF8(ObjSnowball* this, GlobalContext* globalCtx) { +void func_80B03FF8(ObjSnowball* this, PlayState* play) { s32 pad; s16 rotY = this->actor.home.rot.y; ObjSnowballStruct2* sp18 = &D_80B04F84[rotY]; if (sp18->unk_04 != NULL) { - sp18->unk_04(this, globalCtx); + sp18->unk_04(this, play); } Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_SNOWBALL_BROKEN); if (rotY == 5) { - Flags_SetSwitch(globalCtx, OBJSNOWBALL_GET_3F(&this->actor)); + Flags_SetSwitch(play, OBJSNOWBALL_GET_3F(&this->actor)); } } -void ObjSnowball_Init(Actor* thisx, GlobalContext* globalCtx) { +void ObjSnowball_Init(Actor* thisx, PlayState* play) { ObjSnowball* this = THIS; Sphere16* sphere; ColliderJntSphElementDim* elementDim; @@ -474,7 +473,7 @@ 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) { @@ -485,8 +484,8 @@ void ObjSnowball_Init(Actor* thisx, GlobalContext* globalCtx) { this->actor.targetMode = 3; } - Collider_InitJntSph(globalCtx, &this->collider); - Collider_SetJntSph(globalCtx, &this->collider, &this->actor, &sJntSphInit, this->colliderElements); + Collider_InitJntSph(play, &this->collider); + Collider_SetJntSph(play, &this->collider, &this->actor, &sJntSphInit, this->colliderElements); this->actor.colChkInfo.mass = MASS_HEAVY; sphere = &this->collider.elements[0].dim.worldSphere; @@ -501,31 +500,31 @@ void ObjSnowball_Init(Actor* thisx, GlobalContext* globalCtx) { sp48.z = this->actor.home.pos.z; this->actor.floorHeight = - BgCheck_EntityRaycastFloor5(&globalCtx->colCtx, &this->actor.floorPoly, &sp44, &this->actor, &sp48); + BgCheck_EntityRaycastFloor5(&play->colCtx, &this->actor.floorPoly, &sp44, &this->actor, &sp48); if (this->actor.floorHeight < (this->actor.home.pos.y - 10.0f)) { this->actor.floorPoly = NULL; } else { ActorShape_Init(&this->actor.shape, 0.0f, NULL, 13.0f); } - func_80B04338(this, globalCtx); + func_80B04338(this, play); - if ((sp40 == 5) && Flags_GetSwitch(globalCtx, OBJSNOWBALL_GET_3F(&this->actor))) { + if ((sp40 == 5) && Flags_GetSwitch(play, OBJSNOWBALL_GET_3F(&this->actor))) { Actor_MarkForDeath(&this->actor); } } -void ObjSnowball_Destroy(Actor* thisx, GlobalContext* globalCtx) { +void ObjSnowball_Destroy(Actor* thisx, PlayState* play) { ObjSnowball* this = THIS; - Collider_DestroyJntSph(globalCtx, &this->collider); + Collider_DestroyJntSph(play, &this->collider); } -void func_80B04338(ObjSnowball* this, GlobalContext* globalCtx) { +void func_80B04338(ObjSnowball* this, PlayState* play) { this->actionFunc = func_80B04350; } -void func_80B04350(ObjSnowball* this, GlobalContext* globalCtx) { +void func_80B04350(ObjSnowball* this, PlayState* play) { s32 pad; s32 flag = (this->collider.base.acFlags & AC_HIT) != 0; @@ -551,14 +550,14 @@ void func_80B04350(ObjSnowball* this, GlobalContext* globalCtx) { } if (this->actor.cutscene < 0) { - func_80B03FF8(this, globalCtx); + func_80B03FF8(this, play); if (this->unk_20A == 0) { - func_80B04608(this, globalCtx); + func_80B04608(this, play); } else { - func_80B046E4(this, globalCtx); + func_80B046E4(this, play); } } else { - func_80B04540(this, globalCtx); + func_80B04540(this, play); } return; } @@ -566,7 +565,7 @@ void func_80B04350(ObjSnowball* this, GlobalContext* globalCtx) { if (flag && !(this->collider.elements->info.acHitInfo->toucher.dmgFlags & (0x10000 | 0x2000 | 0x1000 | 0x800 | 0x20))) { if (this->unk_209 <= 0) { - func_80B02EE4(this, globalCtx); + func_80B02EE4(this, play); if (this->collider.elements->info.acHitInfo->toucher.dmgFlags & 0x1000000) { this->unk_209 = 25; } else { @@ -580,39 +579,39 @@ void func_80B04350(ObjSnowball* this, GlobalContext* globalCtx) { this->unk_209--; } - CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); - CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + CollisionCheck_SetAC(play, &play->colChkCtx, &this->collider.base); + CollisionCheck_SetOC(play, &play->colChkCtx, &this->collider.base); } -void func_80B04540(ObjSnowball* this, GlobalContext* globalCtx) { +void func_80B04540(ObjSnowball* this, PlayState* play) { ActorCutscene_SetIntentToPlay(this->actor.cutscene); this->actionFunc = func_80B0457C; } -void func_80B0457C(ObjSnowball* this, GlobalContext* globalCtx) { +void func_80B0457C(ObjSnowball* this, PlayState* play) { if (ActorCutscene_GetCanPlayNext(this->actor.cutscene)) { ActorCutscene_StartAndSetUnkLinkFields(this->actor.cutscene, &this->actor); - func_80B03FF8(this, globalCtx); + func_80B03FF8(this, play); this->unk_20B = 1; if (this->unk_20A == 0) { - func_80B04608(this, globalCtx); + func_80B04608(this, play); } else { - func_80B046E4(this, globalCtx); + func_80B046E4(this, play); } } else { ActorCutscene_SetIntentToPlay(this->actor.cutscene); } } -void func_80B04608(ObjSnowball* this, GlobalContext* globalCtx) { - func_80B030F8(this, globalCtx); +void func_80B04608(ObjSnowball* this, PlayState* play) { + func_80B030F8(this, play); this->actor.draw = NULL; this->unk_208 = 50; this->actor.floorPoly = NULL; this->actionFunc = func_80B04648; } -void func_80B04648(ObjSnowball* this, GlobalContext* globalCtx) { +void func_80B04648(ObjSnowball* this, PlayState* play) { this->unk_208--; if (this->unk_208 <= 0) { if (this->unk_20B != 0) { @@ -620,26 +619,26 @@ void func_80B04648(ObjSnowball* this, GlobalContext* globalCtx) { } if (this->actor.home.rot.y == 1) { - func_80B04B48(this, globalCtx); + func_80B04B48(this, play); } else { Actor_MarkForDeath(&this->actor); } } else if (this->unk_208 == 0x2D) { - func_80B03688(this, globalCtx); + func_80B03688(this, play); } } -void func_80B046E4(ObjSnowball* this, GlobalContext* globalCtx) { +void func_80B046E4(ObjSnowball* this, PlayState* play) { Vec3f sp44; s32 i; - func_80B03E2C(this, globalCtx); + func_80B03E2C(this, play); for (i = 0; i < ARRAY_COUNT(this->unk_1A8); i++) { sp44.x = this->unk_1A8[i].unk_00.x; sp44.y = this->unk_1A8[i].unk_00.y - (60.0f * this->unk_20C); sp44.z = this->unk_1A8[i].unk_00.z; - func_80B03A80(globalCtx, this->unk_20C, &sp44); + func_80B03A80(play, this->unk_20C, &sp44); } this->actor.draw = func_80B04D34; @@ -648,7 +647,7 @@ void func_80B046E4(ObjSnowball* this, GlobalContext* globalCtx) { this->actionFunc = func_80B047C0; } -void func_80B047C0(ObjSnowball* this, GlobalContext* globalCtx) { +void func_80B047C0(ObjSnowball* this, PlayState* play) { static Vec3f D_80B04FD8 = { 0.0f, 1.0f, 0.0f }; static Vec3f D_80B04FE4 = { 0.0f, 0.0f, 1.0f }; s32 pad; @@ -684,11 +683,11 @@ void func_80B047C0(ObjSnowball* this, GlobalContext* globalCtx) { sp9C.y = ptr->unk_00.y + 25.0f; sp9C.z = ptr->unk_00.z; - ptr->unk_18 = BgCheck_EntityRaycastFloor5(&globalCtx->colCtx, &ptr->unk_28, &sp98, &this->actor, &sp9C); + ptr->unk_18 = BgCheck_EntityRaycastFloor5(&play->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) { @@ -710,7 +709,7 @@ void func_80B047C0(ObjSnowball* this, GlobalContext* globalCtx) { sp70.x = ptr->unk_00.x; sp70.y = ptr->unk_00.y - sp84; sp70.z = ptr->unk_00.z; - func_80B03A80(globalCtx, this->unk_20C, &sp70); + func_80B03A80(play, this->unk_20C, &sp70); } } } @@ -724,7 +723,7 @@ void func_80B047C0(ObjSnowball* this, GlobalContext* globalCtx) { } if (this->actor.home.rot.y == 1) { - func_80B04B48(this, globalCtx); + func_80B04B48(this, play); } else { Actor_MarkForDeath(&this->actor); } @@ -743,25 +742,25 @@ void func_80B047C0(ObjSnowball* this, GlobalContext* globalCtx) { } } -void func_80B04B48(ObjSnowball* this, GlobalContext* globalCtx) { +void func_80B04B48(ObjSnowball* this, PlayState* play) { this->actionFunc = func_80B04B60; } -void func_80B04B60(ObjSnowball* this, GlobalContext* globalCtx) { +void func_80B04B60(ObjSnowball* this, PlayState* play) { } -void ObjSnowball_Update(Actor* thisx, GlobalContext* globalCtx) { +void ObjSnowball_Update(Actor* thisx, PlayState* play) { s32 pad; ObjSnowball* this = THIS; s32 sp24 = false; if (this->actor.home.rot.y == 1) { if (this->unk_211 != 0) { - if (Actor_TextboxIsClosing(&this->actor, globalCtx)) { + if (Actor_TextboxIsClosing(&this->actor, play)) { this->actor.flags &= ~ACTOR_FLAG_10; this->unk_211 = 0; } - } else if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { + } else if (Actor_ProcessTalkRequest(&this->actor, &play->state)) { this->actor.flags |= ACTOR_FLAG_10; this->unk_211 = 1; } else if (this->actor.isTargeted) { @@ -769,10 +768,10 @@ void ObjSnowball_Update(Actor* thisx, GlobalContext* globalCtx) { } } - this->actionFunc(this, globalCtx); + this->actionFunc(this, play); if (sp24 && (this->actionFunc == func_80B04350)) { - func_800B8614(&this->actor, globalCtx, 100.0f); + func_800B8614(&this->actor, play, 100.0f); } if ((this->actor.floorPoly != NULL) && (this->actor.projectedPos.z < 920.0f)) { @@ -790,13 +789,13 @@ void ObjSnowball_Update(Actor* thisx, GlobalContext* globalCtx) { } } -void ObjSnowball_Draw(Actor* thisx, GlobalContext* globalCtx) { +void ObjSnowball_Draw(Actor* thisx, PlayState* play) { ObjSnowball* this = THIS; - Gfx_DrawDListOpa(globalCtx, object_goroiwa_DL_008B90); + Gfx_DrawDListOpa(play, object_goroiwa_DL_008B90); } -void func_80B04D34(Actor* thisx, GlobalContext* globalCtx) { +void func_80B04D34(Actor* thisx, PlayState* play) { s32 pad; ObjSnowball* this = THIS; ObjSnowballStruct* ptr; @@ -812,28 +811,28 @@ 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); + Gfx_DrawDListOpa(play, object_goroiwa_DL_0082D0); if ((ptr->unk_28 != NULL) && (ptr->unk_2C > 0)) { - OPEN_DISPS(globalCtx->state.gfxCtx); + OPEN_DISPS(play->state.gfxCtx); - func_8012C448(globalCtx->state.gfxCtx); + func_8012C448(play->state.gfxCtx); gDPSetCombineLERP(POLY_XLU_DISP++, 0, 0, 0, PRIMITIVE, TEXEL0, 0, PRIMITIVE, 0, 0, 0, 0, COMBINED, 0, 0, 0, COMBINED); gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 0, 0, 0, ptr->unk_2C); func_800C0094(ptr->unk_28, ptr->unk_00.x, ptr->unk_18, ptr->unk_00.z, &sp88); - Matrix_SetCurrentState(&sp88); + Matrix_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), + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_XLU_DISP++, gCircleShadowDL); - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->state.gfxCtx); } } } diff --git a/src/overlays/actors/ovl_Obj_Snowball/z_obj_snowball.h b/src/overlays/actors/ovl_Obj_Snowball/z_obj_snowball.h index c6bc03100..0b2974d44 100644 --- a/src/overlays/actors/ovl_Obj_Snowball/z_obj_snowball.h +++ b/src/overlays/actors/ovl_Obj_Snowball/z_obj_snowball.h @@ -5,7 +5,7 @@ struct ObjSnowball; -typedef void (*ObjSnowballActionFunc)(struct ObjSnowball*, GlobalContext*); +typedef void (*ObjSnowballActionFunc)(struct ObjSnowball*, PlayState*); #define OBJSNOWBALL_GET_3F(thisx) ((thisx)->params & 0x3F) #define OBJSNOWBALL_GET_7F00(thisx) (((thisx)->params >> 8) & 0x7F) 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 229cdf516..937a61d79 100644 --- a/src/overlays/actors/ovl_Obj_Snowball2/z_obj_snowball2.c +++ b/src/overlays/actors/ovl_Obj_Snowball2/z_obj_snowball2.c @@ -11,20 +11,20 @@ #define THIS ((ObjSnowball2*)thisx) -void ObjSnowball2_Init(Actor* thisx, GlobalContext* globalCtx); -void ObjSnowball2_Destroy(Actor* thisx, GlobalContext* globalCtx); -void ObjSnowball2_Update(Actor* thisx, GlobalContext* globalCtx); -void ObjSnowball2_Draw(Actor* thisx, GlobalContext* globalCtx); +void ObjSnowball2_Init(Actor* thisx, PlayState* play); +void ObjSnowball2_Destroy(Actor* thisx, PlayState* play); +void ObjSnowball2_Update(Actor* thisx, PlayState* play); +void ObjSnowball2_Draw(Actor* thisx, PlayState* play); void func_80B38E20(ObjSnowball2* this); void func_80B39C78(ObjSnowball2* this); -void func_80B39C9C(ObjSnowball2* this, GlobalContext* globalCtx); +void func_80B39C9C(ObjSnowball2* this, PlayState* play); void func_80B39F60(ObjSnowball2* this); -void func_80B39FA8(ObjSnowball2* this, GlobalContext* globalCtx); +void func_80B39FA8(ObjSnowball2* this, PlayState* play); void func_80B3A0D8(ObjSnowball2* this); -void func_80B3A13C(ObjSnowball2* this, GlobalContext* globalCtx); +void func_80B3A13C(ObjSnowball2* this, PlayState* play); void func_80B3A498(ObjSnowball2* this); -void func_80B3A500(ObjSnowball2* this, GlobalContext* globalCtx); +void func_80B3A500(ObjSnowball2* this, PlayState* play); const ActorInit Obj_Snowball2_InitVars = { ACTOR_OBJ_SNOWBALL2, @@ -61,7 +61,7 @@ static ColliderJntSphInit sJntSphInit = { OC2_TYPE_2, COLSHAPE_JNTSPH, }, - 1, + ARRAY_COUNT(sJntSphElementsInit), sJntSphElementsInit, }; @@ -79,27 +79,26 @@ Gfx* D_80B3A91C[] = { Vec3f D_80B3A92C = { 0.0f, 0.3f, 0.0f }; void func_80B38E20(ObjSnowball2* this) { - Matrix_SetStateRotationAndTranslation(this->actor.world.pos.x, - this->actor.world.pos.y + (this->actor.shape.yOffset * this->actor.scale.y), - this->actor.world.pos.z, &this->actor.shape.rot); + Matrix_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); } -void func_80B38E88(ObjSnowball2* this, GlobalContext* globalCtx) { +void func_80B38E88(ObjSnowball2* this, PlayState* play) { s32 temp_v0; 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); + Item_DropCollectible(play, &this->actor.world.pos, (ENOBJSNOWBALL2_GET_7F00(&this->actor) << 8) | temp_v0); this->unk_1AE = 1; } } } -void func_80B38EFC(ObjSnowball2* this, GlobalContext* globalCtx) { +void func_80B38EFC(ObjSnowball2* this, PlayState* play) { s32 pad; s32 i; Vec3f spA4; @@ -120,12 +119,12 @@ void func_80B38EFC(ObjSnowball2* this, GlobalContext* globalCtx) { spA4.y = sp98.y * -0.06f; spA4.z = sp98.z * -0.06f; - func_800B0E48(globalCtx, &sp8C, &sp98, &spA4, &D_80B3A914, &D_80B3A918, (s32)(Rand_ZeroOne() * 40.0f) + 10, + func_800B0E48(play, &sp8C, &sp98, &spA4, &D_80B3A914, &D_80B3A918, (s32)(Rand_ZeroOne() * 40.0f) + 10, (s32)(Rand_ZeroOne() * 30.0f) + 10); } } -void func_80B39108(ObjSnowball2* this, GlobalContext* globalCtx) { +void func_80B39108(ObjSnowball2* this, PlayState* play) { s32 phi_s5; s16 phi_s1; s32 phi_v0; @@ -145,7 +144,7 @@ void func_80B39108(ObjSnowball2* this, GlobalContext* globalCtx) { for (i = 0, phi_s5 = 0; i < 11; i++, phi_s5 += (0x10000 / 11)) { temp_s3 = (s32)(Rand_ZeroOne() * 5957.0f) + phi_s5; - if (((u32)Rand_Next() >> 0x1E) == 0) { + if ((Rand_Next() >> 0x1E) == 0) { phi_s1 = 0x20; } else { phi_s1 = 0x40; @@ -177,20 +176,20 @@ void func_80B39108(ObjSnowball2* this, GlobalContext* globalCtx) { phi_v0 = 0; } - 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]); + EffectSsKakera_Spawn(play, &spD0, &spDC, &spD0, -300, phi_s1, 30, 0, 0, (temp >> 0x1D) + 8, phi_v0, 0, 50, -1, + OBJECT_GOROIWA, D_80B3A91C[i & 3]); spD0.x += (Rand_ZeroOne() - 0.5f) * 40.0f; spD0.y += (Rand_ZeroOne() - 0.3f) * 45.0f; spD0.z += (Rand_ZeroOne() - 0.5f) * 40.0f; - func_800B0E48(globalCtx, &spD0, &gZeroVec3f, &D_80B3A92C, &D_80B3A914, &D_80B3A918, + func_800B0E48(play, &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; } -void func_80B39470(Actor* thisx, GlobalContext* globalCtx) { +void func_80B39470(Actor* thisx, PlayState* play) { ObjSnowball2* this = THIS; Vec3f sp58; s32 phi_s0; @@ -201,29 +200,29 @@ void func_80B39470(Actor* thisx, GlobalContext* globalCtx) { 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); + EffectSsGSplash_Spawn(play, &sp58, NULL, NULL, 0, 200); } sp58.x = this->actor.world.pos.x; sp58.z = this->actor.world.pos.z; - EffectSsGSplash_Spawn(globalCtx, &sp58, NULL, NULL, 0, 300); + EffectSsGSplash_Spawn(play, &sp58, NULL, NULL, 0, 300); } -void func_80B395C4(GlobalContext* this, Vec3f* arg1) { - EffectSsGRipple_Spawn(this, arg1, 200, 700, 0); +void func_80B395C4(PlayState* play, Vec3f* arg1) { + EffectSsGRipple_Spawn(play, arg1, 200, 700, 0); } -void func_80B395EC(Actor* thisx, GlobalContext* globalCtx) { +void func_80B395EC(Actor* thisx, PlayState* play) { ObjSnowball2* this = THIS; Vec3f sp18; 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); + func_80B395C4(play, &sp18); } -void func_80B39638(GlobalContext* globalCtx, Vec3f* arg1) { +void func_80B39638(PlayState* play, Vec3f* arg1) { static s16 D_80B3A938 = 0; f32 temp_f20; f32 temp_f22; @@ -234,7 +233,7 @@ void func_80B39638(GlobalContext* globalCtx, Vec3f* arg1) { f32 temp_f2; s32 i; - D_80B3A938 += (s16)((u32)Rand_Next() >> 0x11); + D_80B3A938 += (s16)(Rand_Next() >> 0x11); for (i = 0; i < 2; i++) { D_80B3A938 += 0x8000; @@ -255,20 +254,20 @@ void func_80B39638(GlobalContext* globalCtx, Vec3f* arg1) { sp80.y = sp8C.y * -0.025f; sp80.z = sp8C.z * -0.02f; - EffectSsIceSmoke_Spawn(globalCtx, &sp98, &sp8C, &sp80, (s32)(Rand_ZeroOne() * 30.0f) + 68); + EffectSsIceSmoke_Spawn(play, &sp98, &sp8C, &sp80, (s32)(Rand_ZeroOne() * 30.0f) + 68); } } -void func_80B39834(Actor* thisx, GlobalContext* globalCtx) { +void func_80B39834(Actor* thisx, PlayState* play) { 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); + EffectSsBubble_Spawn(play, &this->actor.world.pos, 0.0f, 20.0f, 30.0f, (Rand_ZeroOne() * 0.11f) + 0.03f); } } -void func_80B39908(ObjSnowball2* this, GlobalContext* globalCtx) { +void func_80B39908(ObjSnowball2* this, PlayState* play) { Vec3f spAC; Vec3f spA0; Vec3f sp94; @@ -290,20 +289,20 @@ void func_80B39908(ObjSnowball2* this, GlobalContext* globalCtx) { 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, + func_800B0E48(play, &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)) { +void func_80B39B28(ObjSnowball2* this, PlayState* play) { + if ((this->unk_1AE == 0) && (play->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); +void func_80B39B5C(ObjSnowball2* this, PlayState* play) { + SoundSource_PlaySfxAtFixedWorldPos(play, &this->actor.world.pos, 40, NA_SE_EV_SMALL_SNOWBALL_BROKEN); } static InitChainEntry sInitChain[] = { @@ -312,27 +311,27 @@ static InitChainEntry sInitChain[] = { ICHAIN_F32(uncullZoneDownward, 100, ICHAIN_CONTINUE), ICHAIN_VEC3F_DIV1000(scale, 25, ICHAIN_STOP), }; -void ObjSnowball2_Init(Actor* thisx, GlobalContext* globalCtx) { +void ObjSnowball2_Init(Actor* thisx, PlayState* play) { ObjSnowball2* this = THIS; Actor_ProcessInitChain(&this->actor, sInitChain); - Collider_InitJntSph(globalCtx, &this->collider); + Collider_InitJntSph(play, &this->collider); this->actor.shape.rot.x = 0; this->actor.shape.rot.z = 0; - this->actor.shape.rot.y = (u32)Rand_Next() >> 0x10; + 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); + Collider_SetJntSph(play, &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) { +void ObjSnowball2_Destroy(Actor* thisx, PlayState* play) { ObjSnowball2* this = THIS; - Collider_DestroyJntSph(globalCtx, &this->collider); + Collider_DestroyJntSph(play, &this->collider); } void func_80B39C78(ObjSnowball2* this) { @@ -341,7 +340,7 @@ void func_80B39C78(ObjSnowball2* this) { this->actionFunc = func_80B39C9C; } -void func_80B39C9C(ObjSnowball2* this, GlobalContext* globalCtx) { +void func_80B39C9C(ObjSnowball2* this, PlayState* play) { s32 pad; s32 sp38 = (this->collider.base.acFlags & AC_HIT) != 0; s32 pad2; @@ -350,47 +349,46 @@ void func_80B39C9C(ObjSnowball2* this, GlobalContext* globalCtx) { this->collider.base.acFlags &= ~AC_HIT; } - if (Actor_HasParent(&this->actor, globalCtx)) { + if (Actor_HasParent(&this->actor, play)) { this->actor.room = -1; this->actor.flags |= ACTOR_FLAG_10; if (func_800A817C(ENOBJSNOWBALL2_GET_3F(&this->actor))) { - func_80B38E88(this, globalCtx); + func_80B38E88(this, play); } - func_80B38EFC(this, globalCtx); - func_800B8E58(GET_PLAYER(globalCtx), NA_SE_PL_PULL_UP_SNOWBALL); + func_80B38EFC(this, play); + func_800B8E58(GET_PLAYER(play), 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); + func_80B38E88(this, play); + func_80B39108(this, play); + func_80B39B5C(this, play); Actor_MarkForDeath(&this->actor); return; } else { if (sp38 && (this->collider.elements->info.acHitInfo->toucher.dmgFlags & 2)) { - func_80B39908(this, globalCtx); + func_80B39908(this, play); } 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)) { + Actor_UpdateBgCheckInfo(play, &this->actor, 15.0f, 15.0f, 0.0f, 0x44); + if ((this->actor.bgCheckFlags & 1) && (DynaPoly_GetActor(&play->colCtx, this->actor.floorBgId) == NULL)) { this->unk_1AD = 1; this->actor.flags &= ~ACTOR_FLAG_10; } } if (this->actor.xzDistToPlayer < 800.0f) { - CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + CollisionCheck_SetAC(play, &play->colChkCtx, &this->collider.base); if (this->actor.xzDistToPlayer < 150.0f) { - CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + CollisionCheck_SetOC(play, &play->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)) >= + if (ABS_ALT(BINANG_SUB(this->actor.yawTowardsPlayer, GET_PLAYER(play)->actor.world.rot.y)) >= 0x5556) { - Actor_PickUp(&this->actor, globalCtx, GI_NONE, 36.0f, 30.0f); + Actor_PickUp(&this->actor, play, GI_NONE, 36.0f, 30.0f); } } } @@ -405,32 +403,32 @@ void func_80B39F60(ObjSnowball2* this) { this->actionFunc = func_80B39FA8; } -void func_80B39FA8(ObjSnowball2* this, GlobalContext* globalCtx) { +void func_80B39FA8(ObjSnowball2* this, PlayState* play) { s32 pad; Vec3f sp30; s32 sp2C; - func_80B39B28(this, globalCtx); + func_80B39B28(this, play); if (this->unk_1AC > 0) { this->unk_1AC--; - func_80B38EFC(this, globalCtx); + func_80B38EFC(this, play); } - if (Actor_HasNoParent(&this->actor, globalCtx)) { - this->actor.room = globalCtx->roomCtx.currRoom.num; + if (Actor_HasNoParent(&this->actor, play)) { + this->actor.room = play->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); + Actor_UpdateBgCheckInfo(play, &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); + BgCheck_EntityRaycastFloor5(&play->colCtx, &this->actor.floorPoly, &sp2C, &this->actor, &sp30); } } @@ -442,7 +440,7 @@ void func_80B3A0D8(ObjSnowball2* this) { this->actionFunc = func_80B3A13C; } -void func_80B3A13C(ObjSnowball2* this, GlobalContext* globalCtx) { +void func_80B3A13C(ObjSnowball2* this, PlayState* play) { s32 pad; s32 sp38 = (this->collider.base.atFlags & AT_HIT) != 0; s32 sp34 = (this->collider.base.ocFlags1 & OC1_HIT) != 0; @@ -460,12 +458,12 @@ void func_80B3A13C(ObjSnowball2* this, GlobalContext* globalCtx) { this->unk_1AC--; } - func_80B39B28(this, globalCtx); + func_80B39B28(this, play); 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); + func_80B38E88(this, play); + func_80B39108(this, play); + func_80B39B5C(this, play); Actor_MarkForDeath(&this->actor); return; } @@ -474,18 +472,18 @@ void func_80B3A13C(ObjSnowball2* this, GlobalContext* globalCtx) { 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); + func_80B39470(&this->actor, play); + func_80B395EC(&this->actor, play); } if (this->actor.bgCheckFlags & 0x40) { Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_BOMB_DROP_WATER); } - } else if ((((globalCtx->gameplayFrames % 16) == 0) || (((u32)Rand_Next() >> 0x10) == 0)) && + } else if ((((play->gameplayFrames % 16) == 0) || ((Rand_Next() >> 0x10) == 0)) && (this->actor.depthInWater < (1200.0f * this->actor.scale.y))) { - func_80B395EC(&this->actor, globalCtx); + func_80B395EC(&this->actor, play); } - func_80B39834(&this->actor, globalCtx); + func_80B39834(&this->actor, play); this->unk_1A8 >>= 1; this->unk_1AA >>= 1; @@ -509,15 +507,15 @@ void func_80B3A13C(ObjSnowball2* this, GlobalContext* globalCtx) { } Actor_MoveWithGravity(&this->actor); - Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 15.0f, 15.0f, 0.0f, 0x45); + Actor_UpdateBgCheckInfo(play, &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); + CollisionCheck_SetOC(play, &play->colChkCtx, &this->collider.base); if (sp30) { func_80B3A498(this); } else { - CollisionCheck_SetAT(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + CollisionCheck_SetAT(play, &play->colChkCtx, &this->collider.base); } } @@ -533,7 +531,7 @@ void func_80B3A498(ObjSnowball2* this) { this->actionFunc = func_80B3A500; } -void func_80B3A500(ObjSnowball2* this, GlobalContext* globalCtx) { +void func_80B3A500(ObjSnowball2* this, PlayState* play) { f32 phi_f0; s32 pad; f32 temp_f14 = this->actor.home.pos.y - this->actor.world.pos.y; @@ -567,8 +565,8 @@ void func_80B3A500(ObjSnowball2* this, GlobalContext* globalCtx) { this->actor.velocity.y += this->actor.gravity; this->actor.world.pos.y += this->actor.velocity.y; - if (((globalCtx->gameplayFrames % 16) == 0) || (((u32)Rand_Next() >> 0x10) == 0)) { - func_80B395C4(globalCtx, &this->actor.home.pos); + if (((play->gameplayFrames % 16) == 0) || ((Rand_Next() >> 0x10) == 0)) { + func_80B395C4(play, &this->actor.home.pos); } if (this->unk_1AC <= 0) { @@ -583,24 +581,24 @@ void func_80B3A500(ObjSnowball2* this, GlobalContext* globalCtx) { this->actor.scale.z = this->actor.scale.x; if ((this->unk_1AC >= 6) && (temp_f14 < temp_f12)) { - func_80B39638(globalCtx, &this->actor.home.pos); + func_80B39638(play, &this->actor.home.pos); } if (this->unk_1AC == 10) { - func_80B38E88(this, globalCtx); + func_80B38E88(this, play); } func_800B9010(&this->actor, NA_SE_EV_ICE_MELT_LEVEL - SFX_FLAG); } else { func_80B38E20(this); - CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + CollisionCheck_SetOC(play, &play->colChkCtx, &this->collider.base); } } -void ObjSnowball2_Update(Actor* thisx, GlobalContext* globalCtx) { +void ObjSnowball2_Update(Actor* thisx, PlayState* play) { ObjSnowball2* this = THIS; - this->actionFunc(this, globalCtx); + this->actionFunc(this, play); if (this->actor.projectedPos.z < 460.0f) { if (this->actor.projectedPos.z > 200.0f) { @@ -617,8 +615,8 @@ void ObjSnowball2_Update(Actor* thisx, GlobalContext* globalCtx) { } } -void ObjSnowball2_Draw(Actor* thisx, GlobalContext* globalCtx) { +void ObjSnowball2_Draw(Actor* thisx, PlayState* play) { ObjSnowball2* this = THIS; - Gfx_DrawDListOpa(globalCtx, object_goroiwa_DL_008B90); + Gfx_DrawDListOpa(play, 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 120358a80..b6990fc1c 100644 --- a/src/overlays/actors/ovl_Obj_Snowball2/z_obj_snowball2.h +++ b/src/overlays/actors/ovl_Obj_Snowball2/z_obj_snowball2.h @@ -5,23 +5,23 @@ struct ObjSnowball2; -typedef void (*ObjSnowball2ActionFunc)(struct ObjSnowball2*, GlobalContext*); +typedef void (*ObjSnowball2ActionFunc)(struct ObjSnowball2*, PlayState*); #define ENOBJSNOWBALL2_GET_3F(thisx) ((thisx)->params & 0x3F) #define ENOBJSNOWBALL2_GET_7F00(thisx) (((thisx)->params >> 8) & 0x7F) typedef struct ObjSnowball2 { - /* 0x0000 */ Actor actor; - /* 0x0144 */ ColliderJntSph collider; - /* 0x0164 */ ColliderJntSphElement colliderElements[1]; - /* 0x01A4 */ ObjSnowball2ActionFunc actionFunc; - /* 0x01A8 */ s16 unk_1A8; - /* 0x01AA */ s16 unk_1AA; - /* 0x01AC */ s8 unk_1AC; - /* 0x01AD */ u8 unk_1AD; - /* 0x01AE */ s8 unk_1AE; - /* 0x01AF */ s8 unk_1AF; - /* 0x01B0 */ UNK_TYPE1 unk1B0[4]; + /* 0x000 */ Actor actor; + /* 0x144 */ ColliderJntSph collider; + /* 0x164 */ ColliderJntSphElement colliderElements[1]; + /* 0x1A4 */ ObjSnowball2ActionFunc actionFunc; + /* 0x1A8 */ s16 unk_1A8; + /* 0x1AA */ s16 unk_1AA; + /* 0x1AC */ s8 unk_1AC; + /* 0x1AD */ u8 unk_1AD; + /* 0x1AE */ s8 unk_1AE; + /* 0x1AF */ s8 unk_1AF; + /* 0x1B0 */ UNK_TYPE1 unk1B0[4]; } ObjSnowball2; // size = 0x1B4 extern const ActorInit Obj_Snowball2_InitVars; diff --git a/src/overlays/actors/ovl_Obj_Sound/z_obj_sound.c b/src/overlays/actors/ovl_Obj_Sound/z_obj_sound.c index 231dd99f3..221ae3acc 100644 --- a/src/overlays/actors/ovl_Obj_Sound/z_obj_sound.c +++ b/src/overlays/actors/ovl_Obj_Sound/z_obj_sound.c @@ -10,9 +10,9 @@ #define THIS ((ObjSound*)thisx) -void ObjSound_Init(Actor* thisx, GlobalContext* globalCtx); -void ObjSound_Destroy(Actor* thisx, GlobalContext* globalCtx); -void ObjSound_Update(Actor* thisx, GlobalContext* globalCtx); +void ObjSound_Init(Actor* thisx, PlayState* play); +void ObjSound_Destroy(Actor* thisx, PlayState* play); +void ObjSound_Update(Actor* thisx, PlayState* play); #if 0 const ActorInit Obj_Sound_InitVars = { diff --git a/src/overlays/actors/ovl_Obj_Spidertent/z_obj_spidertent.c b/src/overlays/actors/ovl_Obj_Spidertent/z_obj_spidertent.c index 1bc0f57b2..05fe851a9 100644 --- a/src/overlays/actors/ovl_Obj_Spidertent/z_obj_spidertent.c +++ b/src/overlays/actors/ovl_Obj_Spidertent/z_obj_spidertent.c @@ -11,17 +11,17 @@ #define THIS ((ObjSpidertent*)thisx) -void ObjSpidertent_Init(Actor* thisx, GlobalContext* globalCtx); -void ObjSpidertent_Destroy(Actor* thisx, GlobalContext* globalCtx); -void ObjSpidertent_Update(Actor* thisx, GlobalContext* globalCtx); -void ObjSpidertent_Draw(Actor* thisx, GlobalContext* globalCtx); +void ObjSpidertent_Init(Actor* thisx, PlayState* play); +void ObjSpidertent_Destroy(Actor* thisx, PlayState* play); +void ObjSpidertent_Update(Actor* thisx, PlayState* play); +void ObjSpidertent_Draw(Actor* thisx, PlayState* play); void func_80B307E0(ObjSpidertent* this); -void func_80B30808(ObjSpidertent* this, GlobalContext* globalCtx); +void func_80B30808(ObjSpidertent* this, PlayState* play); void func_80B30A2C(ObjSpidertent* this); -void func_80B30A4C(ObjSpidertent* this, GlobalContext* globalCtx); +void func_80B30A4C(ObjSpidertent* this, PlayState* play); void func_80B30AD4(ObjSpidertent* this); -void func_80B30AF8(ObjSpidertent* this, GlobalContext* globalCtx); +void func_80B30AF8(ObjSpidertent* this, PlayState* play); const ActorInit Obj_Spidertent_InitVars = { ACTOR_OBJ_SPIDERTENT, @@ -125,7 +125,7 @@ static ColliderTrisInit sTrisInit1 = { OC2_NONE, COLSHAPE_TRIS, }, - 6, + ARRAY_COUNT(sTrisElementsInit1), sTrisElementsInit1, }; @@ -219,7 +219,7 @@ static ColliderTrisInit sTrisInit2 = { OC2_NONE, COLSHAPE_TRIS, }, - 6, + ARRAY_COUNT(sTrisElementsInit2), sTrisElementsInit2, }; @@ -446,7 +446,7 @@ s32 func_80B2FC98(TriNorm* triNorm, Vec3f* arg1) { } } -void func_80B300F4(ObjSpidertent* thisx, GlobalContext* globalCtx, TriNorm* triNorm, Vec3f* arg3, f32 arg4, s32 arg5) { +void func_80B300F4(ObjSpidertent* thisx, PlayState* play, TriNorm* triNorm, Vec3f* arg3, f32 arg4, s32 arg5) { ObjSpidertent* this = THIS; ObjSpidertentStruct* spE0 = &D_80B31350[OBJSPIDERTENT_GET_1(&this->dyna.actor)]; f32 temp_f24; @@ -478,8 +478,8 @@ void func_80B300F4(ObjSpidertent* thisx, GlobalContext* globalCtx, TriNorm* triN for (i = 0; i < sp80->unk_0F; i++) { temp_f2 = (Rand_ZeroOne() * temp_f24) + phi_f22; - Matrix_InsertRotationAroundUnitVector_f(temp_f2, &spAC, MTXMODE_NEW); - Matrix_MultiplyVector3fByState(&spA0, &sp94); + Matrix_RotateAxisF(temp_f2, &spAC, MTXMODE_NEW); + Matrix_MultVec3f(&spA0, &sp94); if (arg5 == 0) { spC4.x = (sp94.x * arg4) + arg3->x; @@ -499,8 +499,8 @@ void func_80B300F4(ObjSpidertent* thisx, GlobalContext* globalCtx, TriNorm* triN 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); + EffectSsDeadDb_Spawn(play, &spC4, &spB8, &gZeroVec3f, &sp80->unk_10, &sp80->unk_14, sp80->unk_0C, 0, + sp80->unk_0E); } phi_f22 += temp_f24; @@ -522,8 +522,8 @@ void func_80B30410(ObjSpidertent* this, Vec3f* arg1) { this->unk_3C0 = 0; } -s32 func_80B30480(ObjSpidertent* this, GlobalContext* globalCtx, Vec3f* arg2) { - Player* player = GET_PLAYER(globalCtx); +s32 func_80B30480(ObjSpidertent* this, PlayState* play, Vec3f* arg2) { + Player* player = GET_PLAYER(play); TriNorm* triNorm; s32 i; Vec3f sp58; @@ -534,14 +534,14 @@ s32 func_80B30480(ObjSpidertent* this, GlobalContext* globalCtx, Vec3f* arg2) { for (i = 0; i < ARRAY_COUNT(this->colliderElements); i++) { triNorm = &this->collider.elements[i].dim; - if (func_80B2FB94(&player->swordInfo[0].tip, 6.0f, triNorm, &sp58, &sp54) && + if (func_80B2FB94(&player->meleeWeaponInfo[0].tip, 6.0f, triNorm, &sp58, &sp54) && func_80B2FC98(triNorm, &sp58)) { break; } } if (i < ARRAY_COUNT(this->colliderElements)) { - Math_Vec3f_Copy(arg2, &player->swordInfo[0].tip); + Math_Vec3f_Copy(arg2, &player->meleeWeaponInfo[0].tip); return true; } } @@ -549,7 +549,7 @@ s32 func_80B30480(ObjSpidertent* this, GlobalContext* globalCtx, Vec3f* arg2) { return false; } -void ObjSpidertent_Init(Actor* thisx, GlobalContext* globalCtx) { +void ObjSpidertent_Init(Actor* thisx, PlayState* play) { s32 pad; ObjSpidertent* this = THIS; s32 temp_s1 = OBJSPIDERTENT_GET_1(&this->dyna.actor); @@ -557,36 +557,37 @@ void ObjSpidertent_Init(Actor* thisx, GlobalContext* globalCtx) { ColliderTrisElementInit* element; Vec3f sp70[3]; Vec3f sp64; - s32 i, j; + s32 i; + s32 j; Actor_ProcessInitChain(&this->dyna.actor, sInitChain); DynaPolyActor_Init(&this->dyna, 0); - Collider_InitTris(globalCtx, &this->collider); + Collider_InitTris(play, &this->collider); - if (Flags_GetSwitch(globalCtx, OBJSPIDERTENT_GET_7F00(&this->dyna.actor))) { + if (Flags_GetSwitch(play, OBJSPIDERTENT_GET_7F00(&this->dyna.actor))) { Actor_MarkForDeath(&this->dyna.actor); return; } - DynaPolyActor_LoadMesh(globalCtx, &this->dyna, ptr->unk_04); - Collider_SetTris(globalCtx, &this->collider, &this->dyna.actor, D_80B31350[temp_s1].unk_08, this->colliderElements); - Matrix_SetStateRotationAndTranslation(this->dyna.actor.world.pos.x, this->dyna.actor.world.pos.y, - this->dyna.actor.world.pos.z, &this->dyna.actor.shape.rot); + DynaPolyActor_LoadMesh(play, &this->dyna, ptr->unk_04); + Collider_SetTris(play, &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_MultiplyVector3fByState(&sp64, &this->dyna.actor.focus.pos); - Matrix_InsertTranslation(ptr->unk_10, ptr->unk_14 + 5.0f, ptr->unk_18, MTXMODE_APPLY); + 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_InsertTranslation(-ptr->unk_10, -ptr->unk_14, -ptr->unk_18, 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_MultiplyVector3fByState(&element->dim.vtx[j], &sp70[j]); + Matrix_MultVec3f(&element->dim.vtx[j], &sp70[j]); } Collider_SetTrisVertices(&this->collider, i, &sp70[0], &sp70[1], &sp70[2]); @@ -595,11 +596,11 @@ void ObjSpidertent_Init(Actor* thisx, GlobalContext* globalCtx) { func_80B307E0(this); } -void ObjSpidertent_Destroy(Actor* thisx, GlobalContext* globalCtx) { +void ObjSpidertent_Destroy(Actor* thisx, PlayState* play) { ObjSpidertent* this = THIS; - DynaPoly_DeleteBgActor(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); - Collider_DestroyTris(globalCtx, &this->collider); + DynaPoly_DeleteBgActor(play, &play->colCtx.dyna, this->dyna.bgId); + Collider_DestroyTris(play, &this->collider); } void func_80B307E0(ObjSpidertent* this) { @@ -610,7 +611,7 @@ void func_80B307E0(ObjSpidertent* this) { this->actionFunc = func_80B30808; } -void func_80B30808(ObjSpidertent* this, GlobalContext* globalCtx) { +void func_80B30808(ObjSpidertent* this, PlayState* play) { s32 phi_s4; s32 i; ObjSpidertentStruct* ptr2 = &D_80B31350[OBJSPIDERTENT_GET_1(&this->dyna.actor)]; @@ -624,7 +625,7 @@ void func_80B30808(ObjSpidertent* this, GlobalContext* globalCtx) { s32 phi_s0 = false; if (this->collider.base.acFlags & AC_HIT) { - Player* player = GET_PLAYER(globalCtx); + Player* player = GET_PLAYER(play); this->collider.base.acFlags &= ~AC_HIT; phi_s1 = 0; @@ -657,7 +658,7 @@ void func_80B30808(ObjSpidertent* this, GlobalContext* globalCtx) { 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)) { + } else if ((this->dyna.actor.xzDistToPlayer < ptr2->unk_24) && func_80B30480(this, play, &sp70)) { phi_s0 = true; } @@ -665,7 +666,7 @@ void func_80B30808(ObjSpidertent* this, GlobalContext* globalCtx) { func_80B30410(this, &sp70); func_80B30A2C(this); } else { - CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + CollisionCheck_SetAC(play, &play->colChkCtx, &this->collider.base); } } @@ -674,13 +675,13 @@ void func_80B30A2C(ObjSpidertent* this) { this->actionFunc = func_80B30A4C; } -void func_80B30A4C(ObjSpidertent* this, GlobalContext* globalCtx) { +void func_80B30A4C(ObjSpidertent* this, PlayState* play) { if (ActorCutscene_GetCanPlayNext(this->dyna.actor.cutscene)) { ActorCutscene_StartAndSetUnkLinkFields(this->dyna.actor.cutscene, &this->dyna.actor); if (this->dyna.actor.cutscene >= 0) { - func_800B7298(globalCtx, &this->dyna.actor, 1); + func_800B7298(play, &this->dyna.actor, 1); } - Flags_SetSwitch(globalCtx, OBJSPIDERTENT_GET_7F00(&this->dyna.actor)); + Flags_SetSwitch(play, OBJSPIDERTENT_GET_7F00(&this->dyna.actor)); func_80B30AD4(this); } else { ActorCutscene_SetIntentToPlay(this->dyna.actor.cutscene); @@ -694,14 +695,11 @@ void func_80B30AD4(ObjSpidertent* this) { this->actionFunc = func_80B30AF8; } -#ifdef NON_MATCHING -void func_80B30AF8(ObjSpidertent* this, GlobalContext* globalCtx) { +void func_80B30AF8(ObjSpidertent* this, PlayState* play) { ObjSpidertentStruct* temp_s0 = &D_80B31350[OBJSPIDERTENT_GET_1(&this->dyna.actor)]; - TriNorm* triNorm; - s32 i, j; - ObjSpidertentStruct2* ptr; - Vec3f sp60; - f32 sp5C; + s32 i; + s32 j; + s32 pad; this->unk_3C6++; @@ -757,17 +755,17 @@ void func_80B30AF8(ObjSpidertent* this, GlobalContext* globalCtx) { this->unk_3C1--; if (this->unk_3C1 == 40) { - func_800C62BC(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); + func_800C62BC(play, &play->colCtx.dyna, this->dyna.bgId); } - if (this->unk_3C1 >= 0x20) { + if (this->unk_3C1 >= 32) { if (this->unk_3C7 > 0) { this->unk_3C7--; - } else if (this->unk_3C1 >= 0x33) { + } else if (this->unk_3C1 > 50) { 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); + SoundSource_PlaySfxAtFixedWorldPos(play, &this->dyna.actor.world.pos, 11, NA_SE_EN_EXTINCT); this->unk_3C7 = Rand_S16Offset(2, 4); } @@ -779,12 +777,16 @@ void func_80B30AF8(ObjSpidertent* this, GlobalContext* globalCtx) { } for (i = 0; i < ARRAY_COUNT(this->colliderElements); i++) { - triNorm = &this->collider.elements[i].dim; + TriNorm* triNorm = &this->collider.elements[i].dim; + Vec3f sp60; + f32 sp5C; 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); + if ((this->unk_3B0[j] < 5.0f) || (this->unk_3C0 & (1 << j))) { + continue; + } + if (func_80B2FB94(&this->unk_3A4, this->unk_3B0[j], triNorm, &sp60, &sp5C)) { + func_80B300F4(this, play, triNorm, &sp60, sp5C, j); } } } @@ -793,31 +795,28 @@ void func_80B30AF8(ObjSpidertent* this, GlobalContext* globalCtx) { Actor_MarkForDeath(&this->dyna.actor); } } -#else -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Spidertent/func_80B30AF8.s") -#endif -void ObjSpidertent_Update(Actor* thisx, GlobalContext* globalCtx) { +void ObjSpidertent_Update(Actor* thisx, PlayState* play) { ObjSpidertent* this = THIS; - this->actionFunc(this, globalCtx); + this->actionFunc(this, play); } -void ObjSpidertent_Draw(Actor* thisx, GlobalContext* globalCtx) { +void ObjSpidertent_Draw(Actor* thisx, PlayState* play) { ObjSpidertent* this = THIS; s32 params = OBJSPIDERTENT_GET_1(&this->dyna.actor); s32 temp_f18 = this->unk_3C5 * (29.0f / 51); Gfx* gfx; - OPEN_DISPS(globalCtx->state.gfxCtx); + OPEN_DISPS(play->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); + gSPMatrix(gfx++, Matrix_NewMtx(play->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); POLY_XLU_DISP = gfx; - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->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 9289bd365..3fdb83597 100644 --- a/src/overlays/actors/ovl_Obj_Spidertent/z_obj_spidertent.h +++ b/src/overlays/actors/ovl_Obj_Spidertent/z_obj_spidertent.h @@ -5,26 +5,26 @@ struct ObjSpidertent; -typedef void (*ObjSpidertentActionFunc)(struct ObjSpidertent*, GlobalContext*); +typedef void (*ObjSpidertentActionFunc)(struct ObjSpidertent*, PlayState*); #define OBJSPIDERTENT_GET_1(thisx) ((thisx)->params & 1) #define OBJSPIDERTENT_GET_7F00(thisx) (((thisx)->params >> 8) & 0x7F) typedef struct ObjSpidertent { - /* 0x0000 */ DynaPolyActor dyna; - /* 0x015C */ ColliderTris collider; - /* 0x017C */ ColliderTrisElement colliderElements[6]; - /* 0x03A4 */ Vec3f unk_3A4; - /* 0x03B0 */ f32 unk_3B0[4]; - /* 0x03C0 */ u8 unk_3C0; - /* 0x03C1 */ s8 unk_3C1; - /* 0x03C2 */ u8 unk_3C2; - /* 0x03C3 */ u8 unk_3C3; - /* 0x03C4 */ u8 unk_3C4; - /* 0x03C5 */ u8 unk_3C5; - /* 0x03C6 */ s8 unk_3C6; - /* 0x03C7 */ s8 unk_3C7; - /* 0x03C8 */ ObjSpidertentActionFunc actionFunc; + /* 0x000 */ DynaPolyActor dyna; + /* 0x15C */ ColliderTris collider; + /* 0x17C */ ColliderTrisElement colliderElements[6]; + /* 0x3A4 */ Vec3f unk_3A4; + /* 0x3B0 */ f32 unk_3B0[4]; + /* 0x3C0 */ u8 unk_3C0; + /* 0x3C1 */ s8 unk_3C1; + /* 0x3C2 */ u8 unk_3C2; + /* 0x3C3 */ u8 unk_3C3; + /* 0x3C4 */ u8 unk_3C4; + /* 0x3C5 */ u8 unk_3C5; + /* 0x3C6 */ s8 unk_3C6; + /* 0x3C7 */ s8 unk_3C7; + /* 0x3C8 */ ObjSpidertentActionFunc actionFunc; } ObjSpidertent; // size = 0x3CC extern const ActorInit Obj_Spidertent_InitVars; diff --git a/src/overlays/actors/ovl_Obj_Spinyroll/z_obj_spinyroll.c b/src/overlays/actors/ovl_Obj_Spinyroll/z_obj_spinyroll.c index 20f4a1c50..0db945c96 100644 --- a/src/overlays/actors/ovl_Obj_Spinyroll/z_obj_spinyroll.c +++ b/src/overlays/actors/ovl_Obj_Spinyroll/z_obj_spinyroll.c @@ -11,22 +11,22 @@ #define THIS ((ObjSpinyroll*)thisx) -void ObjSpinyroll_Init(Actor* thisx, GlobalContext* globalCtx); -void ObjSpinyroll_Destroy(Actor* thisx, GlobalContext* globalCtx); -void ObjSpinyroll_Update(Actor* thisx, GlobalContext* globalCtx); -void ObjSpinyroll_Draw(Actor* thisx, GlobalContext* globalCtx); +void ObjSpinyroll_Init(Actor* thisx, PlayState* play); +void ObjSpinyroll_Destroy(Actor* thisx, PlayState* play); +void ObjSpinyroll_Update(Actor* thisx, PlayState* play); +void ObjSpinyroll_Draw(Actor* thisx, PlayState* play); void func_80A1E9C4(ObjSpinyroll* this); -void func_80A1E9E0(ObjSpinyroll* this, GlobalContext* globalCtx); -void func_80A1EA4C(ObjSpinyroll* this, GlobalContext* globalCtx); +void func_80A1E9E0(ObjSpinyroll* this, PlayState* play); +void func_80A1EA4C(ObjSpinyroll* this, PlayState* play); void func_80A1EAAC(ObjSpinyroll* this); -void func_80A1EAE0(ObjSpinyroll* this, GlobalContext* globalCtx); +void func_80A1EAE0(ObjSpinyroll* this, PlayState* play); void func_80A1EB40(ObjSpinyroll* this); -void func_80A1EB54(ObjSpinyroll* this, GlobalContext* globalCtx); +void func_80A1EB54(ObjSpinyroll* this, PlayState* play); void func_80A1EC24(ObjSpinyroll* this); -void func_80A1EC38(ObjSpinyroll* this, GlobalContext* globalCtx); +void func_80A1EC38(ObjSpinyroll* this, PlayState* play); void func_80A1ECC0(ObjSpinyroll* this); -void func_80A1ECD4(ObjSpinyroll* this, GlobalContext* globalCtx); +void func_80A1ECD4(ObjSpinyroll* this, PlayState* play); const ActorInit Obj_Spinyroll_InitVars = { ACTOR_OBJ_SPINYROLL, @@ -118,7 +118,7 @@ static ColliderTrisInit sTrisInit = { OC2_NONE, COLSHAPE_TRIS, }, - 6, + ARRAY_COUNT(sTrisElementsInit), sTrisElementsInit, }; @@ -143,12 +143,12 @@ static InitChainEntry sInitChain[] = { s16 D_80A1F20C[] = { 0xFA0, -0xFA0 }; -void func_80A1DA50(GlobalContext* globalCtx, ObjSpinyroll* this, Vec3f* arg2, Vec3f* arg3) { +void func_80A1DA50(PlayState* play, 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); + EffectSsHitmark_SpawnFixedScale(play, 3, &sp1C); Actor_PlaySfxAtPos(&this->dyna.actor, NA_SE_IT_SHIELD_REFLECT_SW); } @@ -272,26 +272,25 @@ void func_80A1DFA0(ObjSpinyroll* this) { 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; + this->unk_3A4.unk_00[i][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 func_80A1E074(ObjSpinyroll* this, PlayState* play, Vec3f* arg2, s32 arg3) { + f32 temp_f0; + ObjSpinyrollStruct* ptr = &this->unk_3A4; + f32 temp_f20; s32 i; s32 j; - ObjSpinyrollStruct2* ptr = &this->unk_3A4; - f32 temp_f0; - f32 temp_f20; Vec3f spC8; Vec3f spBC; Vec3f spB0; - ObjSpinyrollStruct* temp_s1; + ObjSpinyrollSubStruct* temp_s1; f32 temp_f22; f32 temp_f24; f32 temp; + s32 pad; s32 sp98; spC8.y = this->dyna.actor.world.pos.y + 10.0f; @@ -304,21 +303,19 @@ s32 func_80A1E074(ObjSpinyroll* this, GlobalContext* globalCtx, Vec3f* arg2, s32 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; + temp_s1 = &ptr->unk_00[i][j]; + spC8.x = (temp_s1->unk_00 * Math_CosS(this->dyna.actor.world.rot.y)) + this->dyna.actor.world.pos.x; + spC8.z = (temp_s1->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 (BgCheck_EntityLineTest3(&play->colCtx, &spC8, &spBC, &spB0, &temp_s1->unk_04, 1, 0, 0, 1, + &temp_s1->bgId, &this->dyna.actor, 0.0f)) { if (arg3 && (this->dyna.actor.flags & ACTOR_FLAG_40)) { - func_80A1DA50(globalCtx, this, &spC8, &spB0); + func_80A1DA50(play, this, &spC8, &spB0); } temp_f0 = Math3D_Vec3fDistSq(&spC8, &spB0); @@ -334,15 +331,11 @@ s32 func_80A1E074(ObjSpinyroll* this, GlobalContext* globalCtx, Vec3f* arg2, s32 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 -s32 func_80A1E2D8(ObjSpinyroll* this, GlobalContext* globalCtx, s32 arg2) { +s32 func_80A1E2D8(ObjSpinyroll* this, PlayState* play, s32 arg2) { Vec3f sp1C; - if (func_80A1E074(this, globalCtx, &sp1C, arg2)) { + if (func_80A1E074(this, play, &sp1C, arg2)) { this->dyna.actor.world.pos.x += sp1C.x; this->dyna.actor.world.pos.z += sp1C.z; return true; @@ -363,10 +356,9 @@ s32 func_80A1E394(CollisionContext* colCtx, f32* arg1, CollisionPoly** polyOut, return BgCheck_EntityCheckCeiling(colCtx, arg1, arg4, 24.0f, polyOut, bgId, &this->dyna.actor); } -#ifdef NON_MATCHING -s32 func_80A1E3D8(ObjSpinyroll* this, GlobalContext* globalCtx, f32* arg2, s32 arg3) { - f32 temp_f20; - ObjSpinyrollStruct2* spC8; +s32 func_80A1E3D8(ObjSpinyroll* this, PlayState* play, f32* arg2, s32 arg3) { + f32 phi_f26; + ObjSpinyrollStruct* spC8 = &this->unk_3A4; f32 phi_f22; ObjSpinyrollColFunc spC0; s32 i; @@ -374,11 +366,12 @@ s32 func_80A1E3D8(ObjSpinyroll* this, GlobalContext* globalCtx, f32* arg2, s32 a Vec3f spAC; Vec3f spA0; Vec3f sp94; - ObjSpinyrollStruct* temp_s0; - f32 phi_f26; + ObjSpinyrollSubStruct* temp_s0; + f32 temp_f20; + s32 pad; s32 sp84; - - spC8 = &this->unk_3A4; + s32 pad2; + f32* temp; if (this->unk_4C4.y > 0.0f) { spC0 = func_80A1E394; @@ -393,24 +386,25 @@ s32 func_80A1E3D8(ObjSpinyroll* this, GlobalContext* globalCtx, f32* arg2, s32 a phi_f22 = FLT_MAX; spC8->unk_F0 = NULL; - for (i = 0; i < ARRAY_COUNT(this->unk_3A4.unk_00); i++) { - sp94.z = D_80A1F1FC[i]; - temp_s0 = &spC8->unk_00[i]; + for (i = 0, temp = D_80A1F1FC; i < ARRAY_COUNT(this->unk_3A4.unk_00); i++, temp++) { + sp94.z = *temp; for (j = 0; j < spC8->unk_F4; j++) { - sp94.x = temp_s0->unk_00[j].unk_00; + temp_s0 = &spC8->unk_00[i][j]; + + sp94.x = temp_s0->unk_00; func_80A1DAAC(&spAC, &sp94, this->dyna.actor.world.rot.y); spAC.x += this->dyna.actor.world.pos.x; spAC.z += this->dyna.actor.world.pos.z; - if (spC0(&globalCtx->colCtx, &spA0.y, &temp_s0->unk_00[j].unk_04, &temp_s0->unk_00[j].bgId, &spAC, this)) { + if (spC0(&play->colCtx, &spA0.y, &temp_s0->unk_04, &temp_s0->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); + func_80A1DA50(play, this, &spAC, &spA0); } if (temp_f20 < phi_f22) { @@ -425,30 +419,26 @@ s32 func_80A1E3D8(ObjSpinyroll* this, GlobalContext* globalCtx, f32* arg2, s32 a } 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 -s32 func_80A1E648(ObjSpinyroll* this, GlobalContext* globalCtx, s32 arg2) { +s32 func_80A1E648(ObjSpinyroll* this, PlayState* play, s32 arg2) { f32 sp1C; - if (func_80A1E3D8(this, globalCtx, &sp1C, arg2)) { + if (func_80A1E3D8(this, play, &sp1C, arg2)) { this->dyna.actor.world.pos.y += sp1C; return true; } return false; } -DynaPolyActor* func_80A1E694(ObjSpinyroll* this, GlobalContext* globalCtx) { +DynaPolyActor* func_80A1E694(ObjSpinyroll* this, PlayState* play) { if (this->unk_3A4.unk_F0 != NULL) { - return DynaPoly_GetActor(&globalCtx->colCtx, this->unk_3A4.unk_F0->unk_00[0].bgId); + return DynaPoly_GetActor(&play->colCtx, this->unk_3A4.unk_F0->bgId); } return NULL; } -s32 func_80A1E6D4(ObjSpinyroll* this, GlobalContext* globalCtx) { - DynaPolyActor* temp_v0 = func_80A1E694(this, globalCtx); +s32 func_80A1E6D4(ObjSpinyroll* this, PlayState* play) { + DynaPolyActor* temp_v0 = func_80A1E694(this, play); if ((temp_v0 != NULL) && (Math3D_Vec3fDistSq(&temp_v0->actor.world.pos, &temp_v0->actor.prevPos) > SQ(0.01f))) { return true; @@ -456,7 +446,7 @@ s32 func_80A1E6D4(ObjSpinyroll* this, GlobalContext* globalCtx) { return false; } -void ObjSpinyroll_Init(Actor* thisx, GlobalContext* globalCtx) { +void ObjSpinyroll_Init(Actor* thisx, PlayState* play) { s32 pad; ObjSpinyroll* this = THIS; f32 sp44; @@ -480,10 +470,10 @@ void ObjSpinyroll_Init(Actor* thisx, GlobalContext* globalCtx) { this->dyna.actor.uncullZoneScale = 250.0f * sp44; DynaPolyActor_Init(&this->dyna, 0); - DynaPolyActor_LoadMesh(globalCtx, &this->dyna, &object_spinyroll_Colheader_000E68); + DynaPolyActor_LoadMesh(play, &this->dyna, &object_spinyroll_Colheader_000E68); - Collider_InitTris(globalCtx, &this->collider); - Collider_SetTris(globalCtx, &this->collider, &this->dyna.actor, &sTrisInit, this->colliderElements); + Collider_InitTris(play, &this->collider); + Collider_SetTris(play, &this->collider, &this->dyna.actor, &sTrisInit, this->colliderElements); if (OBJSPINYROLL_GET_7F(&this->dyna.actor) == OBJSPINYROLL_GET_7F_7F) { func_80A1E9C4(this); @@ -494,7 +484,7 @@ void ObjSpinyroll_Init(Actor* thisx, GlobalContext* globalCtx) { func_80A1DFA0(this); this->unk_4A4 = D_80A1F1C4[OBJSPINYROLL_GET_380(thisx)]; - path = &globalCtx->setupPathList[OBJSPINYROLL_GET_7F(&this->dyna.actor)]; + path = &play->setupPathList[OBJSPINYROLL_GET_7F(&this->dyna.actor)]; points = Lib_SegmentedToVirtual(path->points); sp34 = &points[0]; @@ -519,11 +509,11 @@ void ObjSpinyroll_Init(Actor* thisx, GlobalContext* globalCtx) { func_80A1EAAC(this); } -void ObjSpinyroll_Destroy(Actor* thisx, GlobalContext* globalCtx) { +void ObjSpinyroll_Destroy(Actor* thisx, PlayState* play) { ObjSpinyroll* this = THIS; - DynaPoly_DeleteBgActor(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); - Collider_DestroyTris(globalCtx, &this->collider); + DynaPoly_DeleteBgActor(play, &play->colCtx.dyna, this->dyna.bgId); + Collider_DestroyTris(play, &this->collider); } void func_80A1E9C4(ObjSpinyroll* this) { @@ -531,7 +521,7 @@ void func_80A1E9C4(ObjSpinyroll* this) { this->actionFunc = func_80A1E9E0; } -void func_80A1E9E0(ObjSpinyroll* this, GlobalContext* globalCtx) { +void func_80A1E9E0(ObjSpinyroll* this, PlayState* play) { this->unk_4DA += 0x6E; if (this->unk_4DA > 0xFA0) { this->unk_4DA = 0xFA0; @@ -544,7 +534,7 @@ void func_80A1EA10(ObjSpinyroll* this) { this->dyna.actor.speedXZ = 0.0f; } -void func_80A1EA4C(ObjSpinyroll* this, GlobalContext* globalCtx) { +void func_80A1EA4C(ObjSpinyroll* this, PlayState* play) { if (Math_ScaledStepToS(&this->unk_4DA, 0, this->unk_4DE)) { if (this->unk_4E2 > 0) { this->unk_4E2--; @@ -561,7 +551,7 @@ void func_80A1EAAC(ObjSpinyroll* this) { this->dyna.actor.speedXZ = 0.0f; } -void func_80A1EAE0(ObjSpinyroll* this, GlobalContext* globalCtx) { +void func_80A1EAE0(ObjSpinyroll* this, PlayState* play) { if (Math_ScaledStepToS(&this->unk_4DA, this->unk_4DC, 0x6E)) { if (!this->unk_49C) { func_80A1EB40(this); @@ -575,11 +565,11 @@ void func_80A1EB40(ObjSpinyroll* this) { this->actionFunc = func_80A1EB54; } -void func_80A1EB54(ObjSpinyroll* this, GlobalContext* globalCtx) { +void func_80A1EB54(ObjSpinyroll* this, PlayState* play) { s32 sp24 = func_80A1DEB8(this); - if (func_80A1E2D8(this, globalCtx, 1)) { - if (func_80A1E694(this, globalCtx) != NULL) { + if (func_80A1E2D8(this, play, 1)) { + if (func_80A1E694(this, play) != NULL) { func_80A1DCCC(this); this->unk_4DE = 0x7D0; func_80A1EC24(this); @@ -601,12 +591,12 @@ void func_80A1EC24(ObjSpinyroll* this) { this->actionFunc = func_80A1EC38; } -void func_80A1EC38(ObjSpinyroll* this, GlobalContext* globalCtx) { +void func_80A1EC38(ObjSpinyroll* this, PlayState* play) { s32 sp24 = true; Math_ScaledStepToS(&this->unk_4DA, 0, this->unk_4DE); - if (func_80A1E2D8(this, globalCtx, 0) && func_80A1E6D4(this, globalCtx)) { + if (func_80A1E2D8(this, play, 0) && func_80A1E6D4(this, play)) { sp24 = false; } @@ -620,10 +610,10 @@ void func_80A1ECC0(ObjSpinyroll* this) { this->actionFunc = func_80A1ECD4; } -void func_80A1ECD4(ObjSpinyroll* this, GlobalContext* globalCtx) { +void func_80A1ECD4(ObjSpinyroll* this, PlayState* play) { s32 sp24 = func_80A1DEB8(this); - if (func_80A1E648(this, globalCtx, 1)) { + if (func_80A1E648(this, play, 1)) { func_80A1DE84(this); func_80A1DCCC(this); this->unk_4DE = 0x7D0; @@ -636,8 +626,8 @@ void func_80A1ECD4(ObjSpinyroll* this, GlobalContext* globalCtx) { } } -void ObjSpinyroll_Update(Actor* thisx, GlobalContext* globalCtx2) { - GlobalContext* globalCtx = globalCtx2; +void ObjSpinyroll_Update(Actor* thisx, PlayState* play2) { + PlayState* play = play2; ObjSpinyroll* this = THIS; if (this->collider.base.atFlags & AT_HIT) { @@ -645,17 +635,17 @@ void ObjSpinyroll_Update(Actor* thisx, GlobalContext* globalCtx2) { func_80A1DCCC(this); } - this->actionFunc(this, globalCtx); + this->actionFunc(this, play); 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); + CollisionCheck_SetAT(play, &play->colChkCtx, &this->collider.base); + CollisionCheck_SetAC(play, &play->colChkCtx, &this->collider.base); } -void ObjSpinyroll_Draw(Actor* thisx, GlobalContext* globalCtx) { +void ObjSpinyroll_Draw(Actor* thisx, PlayState* play) { ObjSpinyroll* this = THIS; f32 temp_f26; f32 temp_f28; @@ -667,9 +657,9 @@ void ObjSpinyroll_Draw(Actor* thisx, GlobalContext* globalCtx) { f32 temp_f30; Vec3s sp84; - OPEN_DISPS(globalCtx->state.gfxCtx); + OPEN_DISPS(play->state.gfxCtx); - func_8012C28C(globalCtx->state.gfxCtx); + func_8012C28C(play->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; @@ -694,15 +684,15 @@ void ObjSpinyroll_Draw(Actor* thisx, GlobalContext* globalCtx) { sp84.z = this->dyna.actor.shape.rot.z; for (i = 0; i < phi_s4; i++) { - Matrix_SetStateRotationAndTranslation(phi_f22, temp_f30, phi_f24, &sp84); + Matrix_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); + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(play->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); + CLOSE_DISPS(play->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 b35627b13..10322586a 100644 --- a/src/overlays/actors/ovl_Obj_Spinyroll/z_obj_spinyroll.h +++ b/src/overlays/actors/ovl_Obj_Spinyroll/z_obj_spinyroll.h @@ -5,7 +5,7 @@ struct ObjSpinyroll; -typedef void (*ObjSpinyrollActionFunc)(struct ObjSpinyroll*, GlobalContext*); +typedef void (*ObjSpinyrollActionFunc)(struct ObjSpinyroll*, PlayState*); typedef s32 (*ObjSpinyrollColFunc)(CollisionContext*, f32*, CollisionPoly**, s32*, Vec3f*, struct ObjSpinyroll*); #define OBJSPINYROLL_GET_7F(thisx) ((thisx)->params & 0x7F) @@ -18,42 +18,36 @@ typedef s32 (*ObjSpinyrollColFunc)(CollisionContext*, f32*, CollisionPoly**, s32 #define OBJSPINYROLL_GET_C000_1 1 typedef struct { - /* 0x00 */ f32 unk_00; - /* 0x04 */ CollisionPoly* unk_04; - /* 0x08 */ s32 bgId; + /* 0x0 */ f32 unk_00; + /* 0x4 */ CollisionPoly* unk_04; + /* 0x8 */ s32 bgId; } ObjSpinyrollSubStruct; // size = 0xC typedef struct { - /* 0x00 */ ObjSpinyrollSubStruct unk_00[10]; -} ObjSpinyrollStruct; // size = 0x78 - -typedef struct { - /* 0x00 */ ObjSpinyrollStruct unk_00[2]; - /* 0xF0 */ ObjSpinyrollStruct* unk_F0; + /* 0x00 */ ObjSpinyrollSubStruct unk_00[2][10]; + /* 0xF0 */ ObjSpinyrollSubStruct* unk_F0; /* 0xF4 */ s32 unk_F4; -} ObjSpinyrollStruct2; // size = 0xF8? +} ObjSpinyrollStruct; // size = 0xF8? typedef struct ObjSpinyroll { - /* 0x0000 */ DynaPolyActor dyna; - /* 0x015C */ ColliderTris collider; - /* 0x017C */ ColliderTrisElement colliderElements[6]; - /* 0x03A4 */ ObjSpinyrollStruct2 unk_3A4; - ///* 0x0494 */ ObjSpinyrollStruct* unk_494; // alternative testing - ///* 0x0498 */ s32 unk_498; - /* 0x049C */ s32 unk_49C; - /* 0x04A0 */ ObjSpinyrollActionFunc actionFunc; - /* 0x04A4 */ f32 unk_4A4; - /* 0x04A8 */ s32 unk_4A8; - /* 0x04AC */ Vec3f unk_4AC[2]; - /* 0x04C4 */ Vec3f unk_4C4; - /* 0x04D0 */ f32 unk_4D0; - /* 0x04D4 */ f32 unk_4D4; - /* 0x04D8 */ s16 unk_4D8; - /* 0x04DA */ s16 unk_4DA; - /* 0x04DC */ s16 unk_4DC; - /* 0x04DE */ s16 unk_4DE; - /* 0x04E0 */ s16 unk_4E0; - /* 0x04E2 */ s16 unk_4E2; + /* 0x000 */ DynaPolyActor dyna; + /* 0x15C */ ColliderTris collider; + /* 0x17C */ ColliderTrisElement colliderElements[6]; + /* 0x3A4 */ ObjSpinyrollStruct unk_3A4; + /* 0x49C */ s32 unk_49C; + /* 0x4A0 */ ObjSpinyrollActionFunc actionFunc; + /* 0x4A4 */ f32 unk_4A4; + /* 0x4A8 */ s32 unk_4A8; + /* 0x4AC */ Vec3f unk_4AC[2]; + /* 0x4C4 */ Vec3f unk_4C4; + /* 0x4D0 */ f32 unk_4D0; + /* 0x4D4 */ f32 unk_4D4; + /* 0x4D8 */ s16 unk_4D8; + /* 0x4DA */ s16 unk_4DA; + /* 0x4DC */ s16 unk_4DC; + /* 0x4DE */ s16 unk_4DE; + /* 0x4E0 */ s16 unk_4E0; + /* 0x4E2 */ s16 unk_4E2; } ObjSpinyroll; // size = 0x4E4 extern const ActorInit Obj_Spinyroll_InitVars; diff --git a/src/overlays/actors/ovl_Obj_Switch/z_obj_switch.c b/src/overlays/actors/ovl_Obj_Switch/z_obj_switch.c index 7bea97826..801cfc3ce 100644 --- a/src/overlays/actors/ovl_Obj_Switch/z_obj_switch.c +++ b/src/overlays/actors/ovl_Obj_Switch/z_obj_switch.c @@ -5,6 +5,7 @@ */ #include "z_obj_switch.h" +#include "z64rumble.h" #include "objects/gameplay_dangeon_keep/gameplay_dangeon_keep.h" #define FLAGS (ACTOR_FLAG_10) @@ -13,10 +14,10 @@ #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); +void ObjSwitch_Init(Actor* thisx, PlayState* play); +void ObjSwitch_Destroy(Actor* thisx, PlayState* play); +void ObjSwitch_Update(Actor* thisx, PlayState* play); +void ObjSwitch_Draw(Actor* thisx, PlayState* play); void ObjSwitch_FloorSwitchUpInit(ObjSwitch* this); void ObjSwitch_FloorSwitchPushDownInit(ObjSwitch* this); @@ -36,32 +37,32 @@ 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_FloorSwitchSnapPlayerToSwitchEdge(ObjSwitch* this, PlayState* play); +void ObjSwitch_TryPlayCutscene(ObjSwitch* this, PlayState* play); +void ObjSwitch_FloorSwitchUp(ObjSwitch* this, PlayState* play); +void ObjSwitch_FloorSwitchPushDown(ObjSwitch* this, PlayState* play); +void ObjSwitch_FloorSwitchDown(ObjSwitch* this, PlayState* play); +void ObjSwitch_FloorSwitchRiseUp(ObjSwitch* this, PlayState* play); +void ObjSwitch_EyeSwitchUnfrozen(ObjSwitch* this, PlayState* play); +void ObjSwitch_EyeSwitchOpen(ObjSwitch* this, PlayState* play); +void ObjSwitch_EyeSwitchClosing(ObjSwitch* this, PlayState* play); +void ObjSwitch_EyeSwitchClosed(ObjSwitch* this, PlayState* play); +void ObjSwitch_EyeSwitchOpening(ObjSwitch* this, PlayState* play); +void ObjSwitch_CrystalSwitchOff(ObjSwitch* this, PlayState* play); +void ObjSwitch_CrystalSwitchTurnOn(ObjSwitch* this, PlayState* play); +void ObjSwitch_CrystalSwitchOn(ObjSwitch* this, PlayState* play); +void ObjSwitch_CrystalSwitchTurnOff(ObjSwitch* this, PlayState* play); +void ObjSwitch_LargeFloorSwitchUp(ObjSwitch* this, PlayState* play); +void ObjSwitch_LargeFloorSwitchPushDown(ObjSwitch* this, PlayState* play); +void ObjSwitch_LargeFloorSwitchDown(ObjSwitch* this, PlayState* play); +void ObjSwitch_LargeFloorSwitchRiseUp(ObjSwitch* this, PlayState* play); -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); +void ObjSwitch_DrawFloorSwitch(ObjSwitch* this, PlayState* play); +void ObjSwitch_DrawRustyFloorSwitch(ObjSwitch* this, PlayState* play); +void ObjSwitch_DrawVisibleEyeSwitch(ObjSwitch* this, PlayState* play); +void ObjSwitch_DrawInvisibleEyeSwitch(ObjSwitch* this, PlayState* play); +void ObjSwitch_DrawEyeSwitch(ObjSwitch* this, PlayState* play); +void ObjSwitch_DrawCrystalSwitch(ObjSwitch* this, PlayState* play); static TexturePtr sEyeSwitchTextures[][4] = { { gEyeSwitchGoldOpenTex, gEyeSwitchGoldOpeningTex, gEyeSwitchGoldClosingTex, gEyeSwitchGoldClosedTex }, @@ -203,59 +204,59 @@ static Gfx* sEyeSwitchDL[] = { gEyeSwitchGoldDL, gEyeSwitchSilverDL }; static AnimatedMaterial* sCrystalSwitchAnimatedMat; -void ObjSwitch_InitJntSphCollider(ObjSwitch* this, GlobalContext* globalCtx, ColliderJntSphInit* init) { +void ObjSwitch_InitJntSphCollider(ObjSwitch* this, PlayState* play, ColliderJntSphInit* init) { s32 pad; - Collider_InitJntSph(globalCtx, &this->colliderJntSph); - Collider_SetJntSph(globalCtx, &this->colliderJntSph, &this->dyna.actor, init, this->colliderJntSphElements); - Matrix_SetStateRotationAndTranslation(this->dyna.actor.world.pos.x, - this->dyna.actor.world.pos.y + - (this->dyna.actor.shape.yOffset * this->dyna.actor.scale.y), - this->dyna.actor.world.pos.z, &this->dyna.actor.shape.rot); + Collider_InitJntSph(play, &this->colliderJntSph); + Collider_SetJntSph(play, &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); } -void ObjSwitch_InitTrisCollider(ObjSwitch* this, GlobalContext* globalCtx, ColliderTrisInit* init) { +void ObjSwitch_InitTrisCollider(ObjSwitch* this, PlayState* play, ColliderTrisInit* init) { s32 pad; s32 i; s32 j; Vec3f vtx[3]; - Collider_InitTris(globalCtx, &this->colliderTris); - Collider_SetTris(globalCtx, &this->colliderTris, &this->dyna.actor, init, this->colliderTrisElements); - Matrix_StatePush(); - Matrix_SetStateRotationAndTranslation(this->dyna.actor.world.pos.x, - this->dyna.actor.world.pos.y + - this->dyna.actor.shape.yOffset * this->dyna.actor.scale.y, - this->dyna.actor.world.pos.z, &this->dyna.actor.shape.rot); + Collider_InitTris(play, &this->colliderTris); + Collider_SetTris(play, &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); for (i = 0; i < ARRAY_COUNT(this->colliderTrisElements); i++) { if (this) {} for (j = 0; j < ARRAY_COUNT(vtx); j++) { - Matrix_MultiplyVector3fByState(&init->elements[i].dim.vtx[j], &vtx[j]); + Matrix_MultVec3f(&init->elements[i].dim.vtx[j], &vtx[j]); } Collider_SetTrisVertices(&this->colliderTris, i, &vtx[0], &vtx[1], &vtx[2]); } - Matrix_StatePop(); + Matrix_Pop(); } -Actor* ObjSwitch_SpawnIce(ObjSwitch* this, GlobalContext* globalCtx) { - Actor_SpawnAsChild(&globalCtx->actorCtx, &this->dyna.actor, globalCtx, ACTOR_OBJ_ICE_POLY, - this->dyna.actor.world.pos.x, this->dyna.actor.world.pos.y - 25.0f, this->dyna.actor.world.pos.z, - this->dyna.actor.world.rot.x, this->dyna.actor.world.rot.y, this->dyna.actor.world.rot.z, - 0xFF32); +Actor* ObjSwitch_SpawnIce(ObjSwitch* this, PlayState* play) { + return Actor_SpawnAsChild(&play->actorCtx, &this->dyna.actor, play, 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); } -void ObjSwitch_SetSwitchFlagState(ObjSwitch* this, GlobalContext* globalCtx, s32 setFlag) { +void ObjSwitch_SetSwitchFlagState(ObjSwitch* this, PlayState* play, s32 setFlag) { if (setFlag) { s32 flag = OBJ_SWITCH_GET_SWITCH_FLAG(&this->dyna.actor); - Flags_SetSwitch(globalCtx, flag); + Flags_SetSwitch(play, flag); } else { s32 flag = OBJ_SWITCH_GET_SWITCH_FLAG(&this->dyna.actor); - Flags_UnsetSwitch(globalCtx, flag); + Flags_UnsetSwitch(play, flag); } } @@ -288,15 +289,15 @@ void ObjSwitch_SetFloorSwitchSnapPlayerState(ObjSwitch* this, s32 state) { } } -void ObjSwitch_FloorSwitchSnapPlayerToSwitchEdge(ObjSwitch* this, GlobalContext* globalCtx) { +void ObjSwitch_FloorSwitchSnapPlayerToSwitchEdge(ObjSwitch* this, PlayState* play) { s32 pad; Player* player; f32 centerDisplacement; s16 yaw; f32 cos; - if (globalCtx->actorCtx.unk5 & 0x80) { - player = GET_PLAYER(globalCtx); + if (play->actorCtx.unk5 & 0x80) { + player = GET_PLAYER(play); // compute yawTowardsPlayer relative to model space yaw = BINANG_SUB(this->dyna.actor.yawTowardsPlayer, this->dyna.actor.shape.rot.y); @@ -325,14 +326,14 @@ void ObjSwitch_FloorSwitchSnapPlayerToSwitchEdge(ObjSwitch* this, GlobalContext* } } -void ObjSwitch_Init(Actor* thisx, GlobalContext* globalCtx) { +void ObjSwitch_Init(Actor* thisx, PlayState* play) { s32 pad; s32 type; u32 isSwitchFlagSet; ObjSwitch* this = THIS; s32 pad2; - isSwitchFlagSet = Flags_GetSwitch(globalCtx, OBJ_SWITCH_GET_SWITCH_FLAG(&this->dyna.actor)); + isSwitchFlagSet = Flags_GetSwitch(play, 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]); @@ -344,10 +345,10 @@ void ObjSwitch_Init(Actor* thisx, GlobalContext* globalCtx) { 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); + DynaPolyActor_LoadMesh(play, &this->dyna, &gFloorSwitchCol); } if (type == OBJSWITCH_TYPE_FLOOR) { - if (globalCtx->sceneNum == SCENE_SECOM) { + if (play->sceneNum == SCENE_SECOM) { this->floorSwitchUpScale = 33.0f / 200.0f / 3.0f; this->floorSwitchDownScale = 33.0f / 2000.0f / 3.0f; } else { @@ -356,7 +357,7 @@ void ObjSwitch_Init(Actor* thisx, GlobalContext* globalCtx) { } } if (type == OBJSWITCH_TYPE_FLOOR || type == OBJSWITCH_TYPE_FLOOR_LARGE) { - if (globalCtx->sceneNum == SCENE_SECOM) { + if (play->sceneNum == SCENE_SECOM) { Color_RGB8* color = &sSakonHideoutColor[OBJ_SWITCH_GET_COLOR_ID(&this->dyna.actor)]; this->color.r = color->r; @@ -373,11 +374,11 @@ void ObjSwitch_Init(Actor* thisx, GlobalContext* globalCtx) { Actor_SetFocus(&this->dyna.actor, sHeights[type]); if (type == OBJSWITCH_TYPE_FLOOR_RUSTY) { - ObjSwitch_InitTrisCollider(this, globalCtx, &sRustyFloorTrisInit); + ObjSwitch_InitTrisCollider(this, play, &sRustyFloorTrisInit); } else if (type == OBJSWITCH_TYPE_EYE) { - ObjSwitch_InitTrisCollider(this, globalCtx, &sEyeSwitchTrisInit); + ObjSwitch_InitTrisCollider(this, play, &sEyeSwitchTrisInit); } else if (type == OBJSWITCH_TYPE_CRYSTAL || type == OBJSWITCH_TYPE_CRYSTAL_TARGETABLE) { - ObjSwitch_InitJntSphCollider(this, globalCtx, &sJntSphInit); + ObjSwitch_InitJntSphCollider(this, play, &sJntSphInit); } if (type == OBJSWITCH_TYPE_CRYSTAL_TARGETABLE) { this->dyna.actor.targetMode = 4; @@ -385,7 +386,7 @@ void ObjSwitch_Init(Actor* thisx, GlobalContext* globalCtx) { } this->dyna.actor.colChkInfo.mass = MASS_IMMOVABLE; if (OBJ_SWITCH_IS_FROZEN(&this->dyna.actor)) { - if (ObjSwitch_SpawnIce(this, globalCtx) == NULL) { + if (ObjSwitch_SpawnIce(this, play) == NULL) { OBJ_SWITCH_UNSET_FROZEN(&this->dyna.actor); } this->sfxTimer = 0; @@ -397,7 +398,8 @@ void ObjSwitch_Init(Actor* thisx, GlobalContext* globalCtx) { } if (type == OBJSWITCH_TYPE_EYE) { if (sIsSegmentTableInit == false) { - s32 i, j; + s32 i; + s32 j; sIsSegmentTableInit = true; @@ -409,7 +411,7 @@ void ObjSwitch_Init(Actor* thisx, GlobalContext* globalCtx) { } } if (type == OBJSWITCH_TYPE_CRYSTAL) { - sCrystalSwitchAnimatedMat = Lib_SegmentedToVirtual(&gCrystalSwitchAnimatedMat); + sCrystalSwitchAnimatedMat = Lib_SegmentedToVirtual(&gCrystalSwitchTexAnim); } if (OBJ_SWITCH_IS_FROZEN(&this->dyna.actor)) { ObjSwitch_EyeSwitchFrozenInit(this); @@ -456,37 +458,37 @@ void ObjSwitch_Init(Actor* thisx, GlobalContext* globalCtx) { } } -void ObjSwitch_Destroy(Actor* thisx, GlobalContext* globalCtx) { +void ObjSwitch_Destroy(Actor* thisx, PlayState* play) { s32 pad; ObjSwitch* this = THIS; s32 type = OBJ_SWITCH_GET_TYPE(&this->dyna.actor); if (type == OBJSWITCH_TYPE_FLOOR || type == OBJSWITCH_TYPE_FLOOR_RUSTY || type == OBJSWITCH_TYPE_FLOOR_LARGE) { - DynaPoly_DeleteBgActor(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); + DynaPoly_DeleteBgActor(play, &play->colCtx.dyna, this->dyna.bgId); } switch (type) { case OBJSWITCH_TYPE_FLOOR_RUSTY: case OBJSWITCH_TYPE_EYE: - Collider_DestroyTris(globalCtx, &this->colliderTris); + Collider_DestroyTris(play, &this->colliderTris); break; case OBJSWITCH_TYPE_CRYSTAL: case OBJSWITCH_TYPE_CRYSTAL_TARGETABLE: - Collider_DestroyJntSph(globalCtx, &this->colliderJntSph); + Collider_DestroyJntSph(play, &this->colliderJntSph); break; } } -void ObjSwitch_TryPlayCutsceneInit(ObjSwitch* this, GlobalContext* globalCtx, ObjSwitchSetupActionFunc actionFunc, +void ObjSwitch_TryPlayCutsceneInit(ObjSwitch* this, PlayState* play, ObjSwitchSetupActionFunc actionFunc, s32 nextSwitchFlagState) { this->setupFunc = actionFunc; this->nextSwitchFlagState = nextSwitchFlagState; this->actionFunc = ObjSwitch_TryPlayCutscene; } -void ObjSwitch_TryPlayCutscene(ObjSwitch* this, GlobalContext* globalCtx) { +void ObjSwitch_TryPlayCutscene(ObjSwitch* this, PlayState* play) { if (ActorCutscene_GetCanPlayNext(this->dyna.actor.cutscene)) { ActorCutscene_StartAndSetUnkLinkFields(this->dyna.actor.cutscene, &this->dyna.actor); - ObjSwitch_SetSwitchFlagState(this, globalCtx, this->nextSwitchFlagState); + ObjSwitch_SetSwitchFlagState(this, play, this->nextSwitchFlagState); if (this->floorSwitchPlayerSnapState == 1) { this->floorSwitchPlayerSnapState = 2; } @@ -502,52 +504,51 @@ void ObjSwitch_FloorSwitchUpInit(ObjSwitch* this) { this->dyna.actor.scale.y = this->floorSwitchUpScale; } -void ObjSwitch_FloorSwitchUp(ObjSwitch* this, GlobalContext* globalCtx) { +void ObjSwitch_FloorSwitchUp(ObjSwitch* this, PlayState* play) { s32 pad; 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); + ObjSwitch_TryPlayCutsceneInit(this, play, ObjSwitch_FloorSwitchPushDownInit, true); } else { - CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->colliderTris.base); + CollisionCheck_SetAC(play, &play->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); + ObjSwitch_TryPlayCutsceneInit(this, play, 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_TryPlayCutsceneInit(this, play, ObjSwitch_FloorSwitchPushDownInit, true); + } else if (Flags_GetSwitch(play, 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; + Flags_GetSwitch(play, OBJ_SWITCH_GET_SWITCH_FLAG(&this->dyna.actor)) ? false : true; ObjSwitch_SetFloorSwitchSnapPlayerState(this, 1); - ObjSwitch_TryPlayCutsceneInit(this, globalCtx, ObjSwitch_FloorSwitchPushDownInit, - isSwitchFlagNotSet); + ObjSwitch_TryPlayCutsceneInit(this, play, ObjSwitch_FloorSwitchPushDownInit, isSwitchFlagNotSet); } break; case OBJSWITCH_SUBTYPE_RESET: if (DynaPolyActor_IsInSwitchPressedState(&this->dyna)) { ObjSwitch_SetFloorSwitchSnapPlayerState(this, 1); - ObjSwitch_TryPlayCutsceneInit(this, globalCtx, ObjSwitch_FloorSwitchPushDownInit, true); + ObjSwitch_TryPlayCutsceneInit(this, play, ObjSwitch_FloorSwitchPushDownInit, true); } break; case OBJSWITCH_SUBTYPE_RESET_INVERTED: if (DynaPolyActor_IsInSwitchPressedState(&this->dyna)) { ObjSwitch_SetFloorSwitchSnapPlayerState(this, 2); - ObjSwitch_SetSwitchFlagState(this, globalCtx, false); + ObjSwitch_SetSwitchFlagState(this, play, false); ObjSwitch_FloorSwitchPushDownInit(this); } break; @@ -559,11 +560,11 @@ void ObjSwitch_FloorSwitchPushDownInit(ObjSwitch* this) { this->actionFunc = ObjSwitch_FloorSwitchPushDown; } -void ObjSwitch_FloorSwitchPushDown(ObjSwitch* this, GlobalContext* globalCtx) { +void ObjSwitch_FloorSwitchPushDown(ObjSwitch* this, PlayState* play) { 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); + Rumble_Request(this->dyna.actor.xyzDistToPlayerSq, 120, 20, 10); ObjSwitch_StopCutscene(this); ObjSwitch_FloorSwitchDownInit(this); } @@ -575,16 +576,16 @@ void ObjSwitch_FloorSwitchDownInit(ObjSwitch* this) { this->dyna.actor.scale.y = this->floorSwitchDownScale; } -void ObjSwitch_FloorSwitchDown(ObjSwitch* this, GlobalContext* globalCtx) { +void ObjSwitch_FloorSwitchDown(ObjSwitch* this, PlayState* play) { s32 pad; u32 subType = OBJ_SWITCH_GET_SUBTYPE(&this->dyna.actor); 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); + if (!Flags_GetSwitch(play, OBJ_SWITCH_GET_SWITCH_FLAG(&this->dyna.actor))) { + if (play->sceneNum == SCENE_SECOM && DynaPolyActor_IsInSwitchPressedState(&this->dyna)) { + ObjSwitch_SetSwitchFlagState(this, play, true); } else { ObjSwitch_FloorSwitchRiseUpInit(this); } @@ -594,19 +595,19 @@ void ObjSwitch_FloorSwitchDown(ObjSwitch* this, GlobalContext* globalCtx) { case OBJSWITCH_SUBTYPE_RESET: case OBJSWITCH_SUBTYPE_RESET_INVERTED: if (!DynaPolyActor_IsInSwitchPressedState(&this->dyna) && - (Player_InCsMode(&globalCtx->state) == 0 || globalCtx->sceneNum == SCENE_SECOM)) { + (!Player_InCsMode(play) || play->sceneNum == SCENE_SECOM)) { if (this->floorSwitchReleaseTimer <= 0) { if (subType == OBJSWITCH_SUBTYPE_RESET) { - ObjSwitch_SetSwitchFlagState(this, globalCtx, false); + ObjSwitch_SetSwitchFlagState(this, play, false); ObjSwitch_FloorSwitchRiseUpInit(this); } else if (subType == OBJSWITCH_SUBTYPE_RESET_INVERTED) { - ObjSwitch_TryPlayCutsceneInit(this, globalCtx, ObjSwitch_FloorSwitchRiseUpInit, true); + ObjSwitch_TryPlayCutsceneInit(this, play, ObjSwitch_FloorSwitchRiseUpInit, true); } else { ObjSwitch_FloorSwitchRiseUpInit(this); } } } else { - if (globalCtx->sceneNum == SCENE_SECOM) { + if (play->sceneNum == SCENE_SECOM) { this->floorSwitchReleaseTimer = 2; } else { this->floorSwitchReleaseTimer = 6; @@ -620,7 +621,7 @@ void ObjSwitch_FloorSwitchRiseUpInit(ObjSwitch* this) { this->actionFunc = ObjSwitch_FloorSwitchRiseUp; } -void ObjSwitch_FloorSwitchRiseUp(ObjSwitch* this, GlobalContext* globalCtx) { +void ObjSwitch_FloorSwitchRiseUp(ObjSwitch* this, PlayState* play) { this->dyna.actor.scale.y += 0.0495f; if (this->floorSwitchUpScale <= this->dyna.actor.scale.y) { ObjSwitch_PlayFootSwitchSfx(this); @@ -639,15 +640,15 @@ s32 ObjSwitch_IsEyeSwitchHit(ObjSwitch* this) { Vec3f sp2C; Vec3f sp20; - Matrix_StatePush(); - Matrix_RotateY(acActor->world.rot.y, MTXMODE_NEW); - Matrix_InsertXRotation_s(acActor->world.rot.x, MTXMODE_APPLY); - Matrix_GetStateTranslationAndScaledZ(1.0f, &sp2C); - Matrix_RotateY(actor->shape.rot.y, MTXMODE_NEW); - Matrix_InsertXRotation_s(actor->shape.rot.x, MTXMODE_APPLY); - Matrix_InsertZRotation_s(actor->shape.rot.z, MTXMODE_APPLY); - Matrix_GetStateTranslationAndScaledZ(1.0f, &sp20); - Matrix_StatePop(); + 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; } @@ -660,8 +661,8 @@ void ObjSwitch_EyeSwitchFrozenInit(ObjSwitch* this) { this->actionFunc = ObjSwitch_EyeSwitchUnfrozen; } -void ObjSwitch_EyeSwitchUnfrozen(ObjSwitch* this, GlobalContext* globalCtx) { - if (Flags_GetSwitch(globalCtx, OBJ_SWITCH_GET_SWITCH_FLAG(&this->dyna.actor))) { +void ObjSwitch_EyeSwitchUnfrozen(ObjSwitch* this, PlayState* play) { + if (Flags_GetSwitch(play, OBJ_SWITCH_GET_SWITCH_FLAG(&this->dyna.actor))) { ObjSwitch_EyeSwitchClosedInit(this); } else { ObjSwitch_EyeSwitchOpenInit(this); @@ -673,10 +674,10 @@ void ObjSwitch_EyeSwitchOpenInit(ObjSwitch* this) { this->eyeTexIndex = 0; } -void ObjSwitch_EyeSwitchOpen(ObjSwitch* this, GlobalContext* globalCtx) { +void ObjSwitch_EyeSwitchOpen(ObjSwitch* this, PlayState* play) { 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); + ObjSwitch_TryPlayCutsceneInit(this, play, ObjSwitch_EyeSwitchClosingInit, true); } } @@ -684,7 +685,7 @@ void ObjSwitch_EyeSwitchClosingInit(ObjSwitch* this) { this->actionFunc = ObjSwitch_EyeSwitchClosing; } -void ObjSwitch_EyeSwitchClosing(ObjSwitch* this, GlobalContext* globalCtx) { +void ObjSwitch_EyeSwitchClosing(ObjSwitch* this, PlayState* play) { this->eyeTexIndex++; if (this->eyeTexIndex >= 3) { ObjSwitch_StopCutscene(this); @@ -698,10 +699,10 @@ void ObjSwitch_EyeSwitchClosedInit(ObjSwitch* this) { this->eyeTexIndex = 3; } -void ObjSwitch_EyeSwitchClosed(ObjSwitch* this, GlobalContext* globalCtx) { +void ObjSwitch_EyeSwitchClosed(ObjSwitch* this, PlayState* play) { switch (OBJ_SWITCH_GET_SUBTYPE(&this->dyna.actor)) { case OBJSWITCH_SUBTYPE_ONCE: - if (!Flags_GetSwitch(globalCtx, OBJ_SWITCH_GET_SWITCH_FLAG(&this->dyna.actor))) { + if (!Flags_GetSwitch(play, OBJ_SWITCH_GET_SWITCH_FLAG(&this->dyna.actor))) { OBJ_SWITCH_UNSET_FROZEN(&this->dyna.actor); ObjSwitch_EyeSwitchOpeningInit(this); } @@ -709,7 +710,7 @@ void ObjSwitch_EyeSwitchClosed(ObjSwitch* this, GlobalContext* globalCtx) { 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); + ObjSwitch_TryPlayCutsceneInit(this, play, ObjSwitch_EyeSwitchOpeningInit, false); } break; } @@ -719,7 +720,7 @@ void ObjSwitch_EyeSwitchOpeningInit(ObjSwitch* this) { this->actionFunc = ObjSwitch_EyeSwitchOpening; } -void ObjSwitch_EyeSwitchOpening(ObjSwitch* this, GlobalContext* globalCtx) { +void ObjSwitch_EyeSwitchOpening(ObjSwitch* this, PlayState* play) { this->eyeTexIndex--; if (this->eyeTexIndex <= 0) { ObjSwitch_StopCutscene(this); @@ -735,7 +736,7 @@ void ObjSwitch_CrystalSwitchOffInit(ObjSwitch* this) { this->actionFunc = ObjSwitch_CrystalSwitchOff; } -void ObjSwitch_CrystalSwitchOff(ObjSwitch* this, GlobalContext* globalCtx) { +void ObjSwitch_CrystalSwitchOff(ObjSwitch* this, PlayState* play) { s32 switchHit = (this->colliderJntSph.base.acFlags & AC_HIT) != 0; s32 canActivate = switchHit && !(this->collisionFlags & AC_HIT) && (this->disableCrystalSwitchTimer <= 0); @@ -745,21 +746,21 @@ void ObjSwitch_CrystalSwitchOff(ObjSwitch* this, GlobalContext* globalCtx) { switch (OBJ_SWITCH_GET_SUBTYPE(&this->dyna.actor)) { case OBJSWITCH_SUBTYPE_ONCE: if (canActivate) { - ObjSwitch_TryPlayCutsceneInit(this, globalCtx, ObjSwitch_CrystalSwitchTurnOnInit, true); + ObjSwitch_TryPlayCutsceneInit(this, play, ObjSwitch_CrystalSwitchTurnOnInit, true); } break; case OBJSWITCH_SUBTYPE_SYNC: if (canActivate) { - ObjSwitch_TryPlayCutsceneInit(this, globalCtx, ObjSwitch_CrystalSwitchTurnOnInit, true); + ObjSwitch_TryPlayCutsceneInit(this, play, ObjSwitch_CrystalSwitchTurnOnInit, true); - } else if (Flags_GetSwitch(globalCtx, OBJ_SWITCH_GET_SWITCH_FLAG(&this->dyna.actor))) { + } else if (Flags_GetSwitch(play, 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_TryPlayCutsceneInit(this, play, ObjSwitch_CrystalSwitchTurnOnInit, true); } ObjSwitch_CrystalUpdateTimer(this); break; @@ -770,7 +771,7 @@ void ObjSwitch_CrystalSwitchTurnOnInit(ObjSwitch* this) { this->actionFunc = ObjSwitch_CrystalSwitchTurnOn; } -void ObjSwitch_CrystalSwitchTurnOn(ObjSwitch* this, GlobalContext* globalCtx) { +void ObjSwitch_CrystalSwitchTurnOn(ObjSwitch* this, PlayState* play) { s32 switchHit = (this->colliderJntSph.base.acFlags & AC_HIT) != 0; s32 subType = OBJ_SWITCH_GET_SUBTYPE(&this->dyna.actor); @@ -792,7 +793,7 @@ void ObjSwitch_CrystalSwitchOnInit(ObjSwitch* this) { this->actionFunc = ObjSwitch_CrystalSwitchOn; } -void ObjSwitch_CrystalSwitchOn(ObjSwitch* this, GlobalContext* globalCtx) { +void ObjSwitch_CrystalSwitchOn(ObjSwitch* this, PlayState* play) { s32 switchHit = (this->colliderJntSph.base.acFlags & AC_HIT) != 0; s32 canActivate = switchHit && !(this->collisionFlags & AC_HIT) && (this->disableCrystalSwitchTimer <= 0); @@ -802,14 +803,14 @@ void ObjSwitch_CrystalSwitchOn(ObjSwitch* this, GlobalContext* globalCtx) { 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))) { + if (!Flags_GetSwitch(play, 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_TryPlayCutsceneInit(this, play, ObjSwitch_CrystalSwitchTurnOffInit, false); } } ObjSwitch_CrystalUpdateTimer(this); @@ -819,7 +820,7 @@ void ObjSwitch_CrystalSwitchTurnOffInit(ObjSwitch* this) { this->actionFunc = ObjSwitch_CrystalSwitchTurnOff; } -void ObjSwitch_CrystalSwitchTurnOff(ObjSwitch* this, GlobalContext* globalCtx) { +void ObjSwitch_CrystalSwitchTurnOff(ObjSwitch* this, PlayState* play) { s32 switchHit = (this->colliderJntSph.base.acFlags & AC_HIT) != 0; if (switchHit) { @@ -836,22 +837,22 @@ void ObjSwitch_LargeFloorSwitchUpInit(ObjSwitch* this) { this->actionFunc = ObjSwitch_LargeFloorSwitchUp; } -void ObjSwitch_LargeFloorSwitchUp(ObjSwitch* this, GlobalContext* globalCtx) { +void ObjSwitch_LargeFloorSwitchUp(ObjSwitch* this, PlayState* play) { s32 subType = OBJ_SWITCH_GET_SUBTYPE(&this->dyna.actor); if (subType == OBJSWITCH_SUBTYPE_ONCE) { if (DynaPolyActor_IsInHeavySwitchPressedState(&this->dyna)) { ObjSwitch_SetFloorSwitchSnapPlayerState(this, 1); - ObjSwitch_TryPlayCutsceneInit(this, globalCtx, ObjSwitch_LargeFloorSwitchPushDownInit, true); + ObjSwitch_TryPlayCutsceneInit(this, play, 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); + ObjSwitch_TryPlayCutsceneInit(this, play, ObjSwitch_LargeFloorSwitchPushDownInit, true); } } else if (subType == OBJSWITCH_SUBTYPE_RESET_INVERTED && DynaPolyActor_IsInHeavySwitchPressedState(&this->dyna)) { ObjSwitch_SetFloorSwitchSnapPlayerState(this, 2); - ObjSwitch_SetSwitchFlagState(this, globalCtx, false); + ObjSwitch_SetSwitchFlagState(this, play, false); ObjSwitch_LargeFloorSwitchPushDownInit(this); } } @@ -860,11 +861,11 @@ void ObjSwitch_LargeFloorSwitchPushDownInit(ObjSwitch* this) { this->actionFunc = ObjSwitch_LargeFloorSwitchPushDown; } -void ObjSwitch_LargeFloorSwitchPushDown(ObjSwitch* this, GlobalContext* globalCtx) { +void ObjSwitch_LargeFloorSwitchPushDown(ObjSwitch* this, PlayState* play) { 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); + Rumble_Request(this->dyna.actor.xyzDistToPlayerSq, 120, 20, 10); ObjSwitch_StopCutscene(this); ObjSwitch_LargeFloorSwitchDownInit(this); } @@ -876,21 +877,21 @@ void ObjSwitch_LargeFloorSwitchDownInit(ObjSwitch* this) { this->actionFunc = ObjSwitch_LargeFloorSwitchDown; } -void ObjSwitch_LargeFloorSwitchDown(ObjSwitch* this, GlobalContext* globalCtx) { +void ObjSwitch_LargeFloorSwitchDown(ObjSwitch* this, PlayState* play) { 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))) { + if (!Flags_GetSwitch(play, 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 (!DynaPolyActor_IsInHeavySwitchPressedState(&this->dyna) && !Player_InCsMode(play)) { if (this->floorSwitchReleaseTimer <= 0) { if (OBJ_SWITCH_GET_SUBTYPE(&this->dyna.actor) == OBJSWITCH_SUBTYPE_RESET) { - ObjSwitch_SetSwitchFlagState(this, globalCtx, false); + ObjSwitch_SetSwitchFlagState(this, play, false); ObjSwitch_LargeFloorSwitchRiseUpInit(this); } else { - ObjSwitch_TryPlayCutsceneInit(this, globalCtx, ObjSwitch_LargeFloorSwitchRiseUpInit, true); + ObjSwitch_TryPlayCutsceneInit(this, play, ObjSwitch_LargeFloorSwitchRiseUpInit, true); } } } else { @@ -903,7 +904,7 @@ void ObjSwitch_LargeFloorSwitchRiseUpInit(ObjSwitch* this) { this->actionFunc = ObjSwitch_LargeFloorSwitchRiseUp; } -void ObjSwitch_LargeFloorSwitchRiseUp(ObjSwitch* this, GlobalContext* globalCtx) { +void ObjSwitch_LargeFloorSwitchRiseUp(ObjSwitch* this, PlayState* play) { this->dyna.actor.scale.y += 0.074250005f; if (this->dyna.actor.scale.y >= 0.2475f) { ObjSwitch_PlayFootSwitchSfx(this); @@ -912,7 +913,7 @@ void ObjSwitch_LargeFloorSwitchRiseUp(ObjSwitch* this, GlobalContext* globalCtx) } } -void ObjSwitch_Update(Actor* thisx, GlobalContext* globalCtx) { +void ObjSwitch_Update(Actor* thisx, PlayState* play) { ObjSwitch* this = THIS; if (this->floorSwitchReleaseTimer > 0) { @@ -921,12 +922,12 @@ void ObjSwitch_Update(Actor* thisx, GlobalContext* globalCtx) { if (this->sfxTimer > 0) { this->sfxTimer--; } - this->actionFunc(this, globalCtx); + this->actionFunc(this, play); if (this->floorSwitchPlayerSnapState != 0) { s32 pad; dummy: - ObjSwitch_FloorSwitchSnapPlayerToSwitchEdge(this, globalCtx); + ObjSwitch_FloorSwitchSnapPlayerToSwitchEdge(this, play); if (this->floorSwitchPlayerSnapState == 2) { this->floorSwitchPlayerSnapState = 0; } @@ -940,11 +941,11 @@ void ObjSwitch_Update(Actor* thisx, GlobalContext* globalCtx) { case OBJSWITCH_TYPE_EYE: this->collisionFlags = this->colliderTris.base.acFlags; this->colliderTris.base.acFlags &= ~AC_HIT; - CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->colliderTris.base); + CollisionCheck_SetAC(play, &play->colChkCtx, &this->colliderTris.base); break; case OBJSWITCH_TYPE_CRYSTAL: case OBJSWITCH_TYPE_CRYSTAL_TARGETABLE: - if (!Player_InCsMode(&globalCtx->state)) { + if (!Player_InCsMode(play)) { if (this->disableCrystalSwitchTimer > 0) { this->disableCrystalSwitchTimer--; } @@ -955,96 +956,96 @@ void ObjSwitch_Update(Actor* thisx, GlobalContext* globalCtx) { 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); + CollisionCheck_SetAC(play, &play->colChkCtx, &this->colliderJntSph.base); + CollisionCheck_SetOC(play, &play->colChkCtx, &this->colliderJntSph.base); } } -void ObjSwitch_DrawFloorSwitch(ObjSwitch* this, GlobalContext* globalCtx) { +void ObjSwitch_DrawFloorSwitch(ObjSwitch* this, PlayState* play) { s32 pad[2]; if (OBJ_SWITCH_GET_SUBTYPE(&this->dyna.actor) == OBJSWITCH_SUBTYPE_ONCE) { Gfx* opa; - OPEN_DISPS(globalCtx->state.gfxCtx); + OPEN_DISPS(play->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); + gSPMatrix(opa++, Matrix_NewMtx(play->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); + CLOSE_DISPS(play->state.gfxCtx); } else { - Gfx_DrawDListOpa(globalCtx, sFloorSwitchDL[OBJ_SWITCH_GET_SUBTYPE(&this->dyna.actor)]); + Gfx_DrawDListOpa(play, sFloorSwitchDL[OBJ_SWITCH_GET_SUBTYPE(&this->dyna.actor)]); } } -void ObjSwitch_DrawRustyFloorSwitch(ObjSwitch* this, GlobalContext* globalCtx) { - Gfx_DrawDListOpa(globalCtx, gRustyFloorSwitchDL); +void ObjSwitch_DrawRustyFloorSwitch(ObjSwitch* this, PlayState* play) { + Gfx_DrawDListOpa(play, gRustyFloorSwitchDL); } -void ObjSwitch_DrawVisibleEyeSwitch(ObjSwitch* this, GlobalContext* globalCtx) { +void ObjSwitch_DrawVisibleEyeSwitch(ObjSwitch* this, PlayState* play) { s32 pad; s32 subType = OBJ_SWITCH_GET_SUBTYPE(&this->dyna.actor); - OPEN_DISPS(globalCtx->state.gfxCtx); + OPEN_DISPS(play->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); + func_8012C28C(play->state.gfxCtx); + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(play->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); + CLOSE_DISPS(play->state.gfxCtx); } -void ObjSwitch_DrawInvisibleEyeSwitch(ObjSwitch* this, GlobalContext* globalCtx) { +void ObjSwitch_DrawInvisibleEyeSwitch(ObjSwitch* this, PlayState* play) { s32 pad; s32 subType = OBJ_SWITCH_GET_SUBTYPE(&this->dyna.actor); - OPEN_DISPS(globalCtx->state.gfxCtx); + OPEN_DISPS(play->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_8012C2DC(play->state.gfxCtx); + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(play->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); + CLOSE_DISPS(play->state.gfxCtx); } -void ObjSwitch_DrawEyeSwitch(ObjSwitch* this, GlobalContext* globalCtx) { +void ObjSwitch_DrawEyeSwitch(ObjSwitch* this, PlayState* play) { if (OBJ_SWITCH_IS_INVISIBLE(&this->dyna.actor)) { - ObjSwitch_DrawInvisibleEyeSwitch(this, globalCtx); + ObjSwitch_DrawInvisibleEyeSwitch(this, play); } else { - ObjSwitch_DrawVisibleEyeSwitch(this, globalCtx); + ObjSwitch_DrawVisibleEyeSwitch(this, play); } } -void ObjSwitch_DrawCrystalSwitch(ObjSwitch* this, GlobalContext* globalCtx) { +void ObjSwitch_DrawCrystalSwitch(ObjSwitch* this, PlayState* play) { s32 pad[2]; - OPEN_DISPS(globalCtx->state.gfxCtx); + OPEN_DISPS(play->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); + func_800B8118(&this->dyna.actor, play, 0); + AnimatedMat_DrawStep(play, sCrystalSwitchAnimatedMat, this->crystalAnimTimer); + func_8012C28C(play->state.gfxCtx); + func_8012C2DC(play->state.gfxCtx); - gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(play->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); + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_XLU_DISP++, gCrystalSwitchDiamondDL); - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->state.gfxCtx); } -void ObjSwitch_Draw(Actor* thisx, GlobalContext* globalCtx) { +void ObjSwitch_Draw(Actor* thisx, PlayState* play) { 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); + drawFunc[OBJ_SWITCH_GET_TYPE(&this->dyna.actor)](this, play); } 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 42ee4207f..f208a60cf 100644 --- a/src/overlays/actors/ovl_Obj_Switch/z_obj_switch.h +++ b/src/overlays/actors/ovl_Obj_Switch/z_obj_switch.h @@ -5,8 +5,8 @@ struct ObjSwitch; -typedef void (*ObjSwitchActionFunc)(struct ObjSwitch* this, GlobalContext* globalCtx); -typedef void (*ObjSwitchDrawFunc)(struct ObjSwitch* this, GlobalContext* globalCtx); +typedef void (*ObjSwitchActionFunc)(struct ObjSwitch* this, PlayState* play); +typedef void (*ObjSwitchDrawFunc)(struct ObjSwitch* this, PlayState* play); typedef void (*ObjSwitchSetupActionFunc)(struct ObjSwitch* this); typedef enum { @@ -33,31 +33,31 @@ typedef enum { #define OBJSWITCH_INVERSE_BLUE 0x30 typedef struct ObjSwitch { - /* 0x0000 */ DynaPolyActor dyna; - /* 0x015C */ ObjSwitchActionFunc actionFunc; - /* 0x0160 */ s16 floorSwitchReleaseTimer; - /* 0x0162 */ s16 disableCrystalSwitchTimer; - /* 0x0164 */ s8 eyeTexIndex; - /* 0x0165 */ s8 sfxTimer; - /* 0x0168 */ s32 crystalAnimTimer; - /* 0x016C */ Color_RGB8 color; - /* 0x016F */ u8 collisionFlags; - /* 0x0170 */ s8 floorSwitchPlayerSnapState; - /* 0x0171 */ s8 nextSwitchFlagState; - /* 0x0172 */ s8 isPlayingCutscene; - /* 0x0174 */ ObjSwitchSetupActionFunc setupFunc; + /* 0x000 */ DynaPolyActor dyna; + /* 0x15C */ ObjSwitchActionFunc actionFunc; + /* 0x160 */ s16 floorSwitchReleaseTimer; + /* 0x162 */ s16 disableCrystalSwitchTimer; + /* 0x164 */ s8 eyeTexIndex; + /* 0x165 */ s8 sfxTimer; + /* 0x168 */ s32 crystalAnimTimer; + /* 0x16C */ Color_RGB8 color; + /* 0x16F */ u8 collisionFlags; + /* 0x170 */ s8 floorSwitchPlayerSnapState; + /* 0x171 */ s8 nextSwitchFlagState; + /* 0x172 */ s8 isPlayingCutscene; + /* 0x174 */ ObjSwitchSetupActionFunc setupFunc; union { struct { - /* 0x0178 */ ColliderJntSph colliderJntSph; - /* 0x0198 */ ColliderJntSphElement colliderJntSphElements[1]; + /* 0x178 */ ColliderJntSph colliderJntSph; + /* 0x198 */ ColliderJntSphElement colliderJntSphElements[1]; }; struct { - /* 0x0178 */ ColliderTris colliderTris; - /* 0x0198 */ ColliderTrisElement colliderTrisElements[2]; + /* 0x178 */ ColliderTris colliderTris; + /* 0x198 */ ColliderTrisElement colliderTrisElements[2]; }; }; - /* 0x0250 */ f32 floorSwitchUpScale; - /* 0x0254 */ f32 floorSwitchDownScale; + /* 0x250 */ f32 floorSwitchUpScale; + /* 0x254 */ f32 floorSwitchDownScale; } ObjSwitch; // size = 0x258 extern const ActorInit Obj_Switch_InitVars; diff --git a/src/overlays/actors/ovl_Obj_Swprize/z_obj_swprize.c b/src/overlays/actors/ovl_Obj_Swprize/z_obj_swprize.c index cea97efe9..4472c4fc3 100644 --- a/src/overlays/actors/ovl_Obj_Swprize/z_obj_swprize.c +++ b/src/overlays/actors/ovl_Obj_Swprize/z_obj_swprize.c @@ -10,14 +10,14 @@ #define THIS ((ObjSwprize*)thisx) -void ObjSwprize_Init(Actor* thisx, GlobalContext* globalCtx); -void ObjSwprize_Destroy(Actor* thisx, GlobalContext* globalCtx); -void ObjSwprize_Update(Actor* thisx, GlobalContext* globalCtx); +void ObjSwprize_Init(Actor* thisx, PlayState* play); +void ObjSwprize_Destroy(Actor* thisx, PlayState* play); +void ObjSwprize_Update(Actor* thisx, PlayState* play); -void func_80C25654(ObjSwprize* this, GlobalContext* globalCtx); -void func_80C256AC(ObjSwprize* this, GlobalContext* globalCtx); -void func_80C2572C(ObjSwprize* this, GlobalContext* globalCtx); -void func_80C25794(ObjSwprize* this, GlobalContext* globalCtx); +void func_80C25654(ObjSwprize* this, PlayState* play); +void func_80C256AC(ObjSwprize* this, PlayState* play); +void func_80C2572C(ObjSwprize* this, PlayState* play); +void func_80C25794(ObjSwprize* this, PlayState* play); #if 0 const ActorInit Obj_Swprize_InitVars = { diff --git a/src/overlays/actors/ovl_Obj_Swprize/z_obj_swprize.h b/src/overlays/actors/ovl_Obj_Swprize/z_obj_swprize.h index 680417d50..29654f992 100644 --- a/src/overlays/actors/ovl_Obj_Swprize/z_obj_swprize.h +++ b/src/overlays/actors/ovl_Obj_Swprize/z_obj_swprize.h @@ -5,12 +5,12 @@ struct ObjSwprize; -typedef void (*ObjSwprizeActionFunc)(struct ObjSwprize*, GlobalContext*); +typedef void (*ObjSwprizeActionFunc)(struct ObjSwprize*, PlayState*); typedef struct ObjSwprize { - /* 0x0000 */ Actor actor; - /* 0x0144 */ ObjSwprizeActionFunc actionFunc; - /* 0x0148 */ char unk_148[0x4]; + /* 0x000 */ Actor actor; + /* 0x144 */ ObjSwprizeActionFunc actionFunc; + /* 0x148 */ char unk_148[0x4]; } ObjSwprize; // size = 0x14C extern const ActorInit Obj_Swprize_InitVars; diff --git a/src/overlays/actors/ovl_Obj_Syokudai/z_obj_syokudai.c b/src/overlays/actors/ovl_Obj_Syokudai/z_obj_syokudai.c index 2996ce5ae..7625b403f 100644 --- a/src/overlays/actors/ovl_Obj_Syokudai/z_obj_syokudai.c +++ b/src/overlays/actors/ovl_Obj_Syokudai/z_obj_syokudai.c @@ -13,10 +13,10 @@ #define THIS ((ObjSyokudai*)thisx) -void ObjSyokudai_Init(Actor* thisx, GlobalContext* globalCtx); -void ObjSyokudai_Destroy(Actor* thisx, GlobalContext* globalCtx); -void ObjSyokudai_Update(Actor* thisx, GlobalContext* globalCtx); -void ObjSyokudai_Draw(Actor* thisx, GlobalContext* globalCtx); +void ObjSyokudai_Init(Actor* thisx, PlayState* play); +void ObjSyokudai_Destroy(Actor* thisx, PlayState* play); +void ObjSyokudai_Update(Actor* thisx, PlayState* play); +void ObjSyokudai_Draw(Actor* thisx, PlayState* play); const ActorInit Obj_Syokudai_InitVars = { ACTOR_OBJ_SYOKUDAI, @@ -87,25 +87,25 @@ static Gfx* sDLists[] = { static s32 sNumLitTorchesInGroup; -void ObjSyokudai_Init(Actor* thisx, GlobalContext* globalCtx) { +void ObjSyokudai_Init(Actor* thisx, PlayState* play) { ObjSyokudai* this = THIS; s32 pad; s32 type = OBJ_SYOKUDAI_GET_TYPE(thisx); s32 switchFlag = OBJ_SYOKUDAI_GET_SWITCH_FLAG(thisx); Actor_ProcessInitChain(thisx, sInitChain); - func_800B4AEC(globalCtx, thisx, 50.0f); + func_800B4AEC(play, thisx, 50.0f); ActorShape_Init(&thisx->shape, 0.0f, func_800B4B50, 1.0f); - Collider_InitAndSetCylinder(globalCtx, &this->standCollider, thisx, &sStandColliderInit); + Collider_InitAndSetCylinder(play, &this->standCollider, thisx, &sStandColliderInit); this->standCollider.base.colType = sColTypes[OBJ_SYOKUDAI_GET_TYPE(thisx)]; - Collider_InitAndSetCylinder(globalCtx, &this->flameCollider, thisx, &sFlameColliderInit); + Collider_InitAndSetCylinder(play, &this->flameCollider, thisx, &sFlameColliderInit); thisx->colChkInfo.mass = MASS_IMMOVABLE; Lights_PointGlowSetInfo(&this->lightInfo, thisx->world.pos.x, thisx->world.pos.y + OBJ_SYOKUDAI_GLOW_HEIGHT, thisx->world.pos.z, 0xFF, 0xFF, 0xB4, -1); - this->lightNode = LightContext_InsertLight(globalCtx, &globalCtx->lightCtx, &this->lightInfo); + this->lightNode = LightContext_InsertLight(play, &play->lightCtx, &this->lightInfo); if (OBJ_SYOKUDAI_GET_START_LIT(thisx) || - ((type != OBJ_SYOKUDAI_TYPE_NO_SWITCH || switchFlag != 0x7F) && Flags_GetSwitch(globalCtx, switchFlag))) { + ((type != OBJ_SYOKUDAI_TYPE_NO_SWITCH || switchFlag != 0x7F) && Flags_GetSwitch(play, switchFlag))) { s32 groupSize = OBJ_SYOKUDAI_GET_GROUP_SIZE(thisx); @@ -120,16 +120,16 @@ void ObjSyokudai_Init(Actor* thisx, GlobalContext* globalCtx) { Actor_SetFocus(thisx, 60.0f); } -void ObjSyokudai_Destroy(Actor* thisx, GlobalContext* globalCtx) { +void ObjSyokudai_Destroy(Actor* thisx, PlayState* play) { ObjSyokudai* this = THIS; - Collider_DestroyCylinder(globalCtx, &this->standCollider); - Collider_DestroyCylinder(globalCtx, &this->flameCollider); - LightContext_RemoveLight(globalCtx, &globalCtx->lightCtx, this->lightNode); + Collider_DestroyCylinder(play, &this->standCollider); + Collider_DestroyCylinder(play, &this->flameCollider); + LightContext_RemoveLight(play, &play->lightCtx, this->lightNode); } -void ObjSyokudai_Update(Actor* thisx, GlobalContext* globalCtx2) { - GlobalContext* globalCtx = globalCtx2; +void ObjSyokudai_Update(Actor* thisx, PlayState* play2) { + PlayState* play = play2; ObjSyokudai* this = THIS; s32 groupSize = OBJ_SYOKUDAI_GET_GROUP_SIZE(thisx); s32 switchFlag = OBJ_SYOKUDAI_GET_SWITCH_FLAG(thisx); @@ -147,7 +147,7 @@ void ObjSyokudai_Update(Actor* thisx, GlobalContext* globalCtx2) { if (ActorCutscene_GetCanPlayNext(thisx->cutscene) != 0) { ActorCutscene_StartAndSetUnkLinkFields(thisx->cutscene, thisx); if (this->pendingAction >= OBJ_SYOKUDAI_PENDING_ACTION_CUTSCENE_AND_SWITCH) { - Flags_SetSwitch(globalCtx, switchFlag); + Flags_SetSwitch(play, switchFlag); } } else { ActorCutscene_SetIntentToPlay(thisx->cutscene); @@ -157,13 +157,13 @@ void ObjSyokudai_Update(Actor* thisx, GlobalContext* globalCtx2) { this->pendingAction = OBJ_SYOKUDAI_PENDING_ACTION_NONE; } } else { - if (WaterBox_GetSurface1_2(globalCtx, &globalCtx->colCtx, thisx->world.pos.x, thisx->world.pos.z, &waterSurface, + if (WaterBox_GetSurface1_2(play, &play->colCtx, thisx->world.pos.x, thisx->world.pos.z, &waterSurface, &waterBox) && ((waterSurface - thisx->world.pos.y) > OBJ_SYOKUDAI_FLAME_HEIGHT)) { this->snuffTimer = OBJ_SYOKUDAI_SNUFF_OUT; if (type == OBJ_SYOKUDAI_TYPE_FLAME_CAUSES_SWITCH) { - Flags_UnsetSwitch(globalCtx, switchFlag); + Flags_UnsetSwitch(play, switchFlag); if (groupSize != 0) { this->snuffTimer = OBJ_SYOKUDAI_SNUFF_GROUP_BY_WATER; } @@ -171,13 +171,13 @@ void ObjSyokudai_Update(Actor* thisx, GlobalContext* globalCtx2) { } else { s32 interaction = OBJ_SYOKUDAI_INTERACTION_NONE; u32 flameColliderHurtboxDmgFlags = 0; - player = GET_PLAYER(globalCtx); + player = GET_PLAYER(play); if (OBJ_SYOKUDAI_GET_START_LIT(thisx)) { this->snuffTimer = OBJ_SYOKUDAI_SNUFF_NEVER; } if (groupSize != 0) { - if (Flags_GetSwitch(globalCtx, switchFlag)) { + if (Flags_GetSwitch(play, switchFlag)) { if (this->snuffTimer == OBJ_SYOKUDAI_SNUFF_OUT) { if (type != OBJ_SYOKUDAI_TYPE_SWITCH_CAUSES_FLAME) { this->snuffTimer = OBJ_SYOKUDAI_SNUFF_NEVER; @@ -199,7 +199,7 @@ void ObjSyokudai_Update(Actor* thisx, GlobalContext* globalCtx2) { } else if (player->itemActionParam == PLAYER_AP_STICK) { Vec3f stickTipSeparationVec; - Math_Vec3f_Diff(&player->swordInfo[0].tip, &thisx->world.pos, &stickTipSeparationVec); + Math_Vec3f_Diff(&player->meleeWeaponInfo[0].tip, &thisx->world.pos, &stickTipSeparationVec); stickTipSeparationVec.y -= OBJ_SYOKUDAI_STICK_IGNITION_HEIGHT; if (SQXYZ(stickTipSeparationVec) < SQ(OBJ_SYOKUDAI_STICK_IGNITION_RADIUS)) { interaction = OBJ_SYOKUDAI_INTERACTION_STICK; @@ -243,7 +243,7 @@ void ObjSyokudai_Update(Actor* thisx, GlobalContext* globalCtx2) { } else if (thisx->cutscene >= 0) { this->pendingAction = OBJ_SYOKUDAI_PENDING_ACTION_CUTSCENE_AND_SWITCH; } else { - Flags_SetSwitch(globalCtx, switchFlag); + Flags_SetSwitch(play, switchFlag); this->snuffTimer = OBJ_SYOKUDAI_SNUFF_NEVER; } } else { @@ -254,17 +254,17 @@ void ObjSyokudai_Update(Actor* thisx, GlobalContext* globalCtx2) { OBJ_SYOKUDAI_SNUFF_TIMER_INITIAL(groupSize) + OBJ_SYOKUDAI_SNUFF_TIMER_JUST_LIT_BONUS; } } - Audio_PlaySfxGeneral(NA_SE_EV_FLAME_IGNITION, &thisx->projectedPos, 4, &D_801DB4B0, &D_801DB4B0, - &D_801DB4B8); + AudioSfx_PlaySfx(NA_SE_EV_FLAME_IGNITION, &thisx->projectedPos, 4, &gSfxDefaultFreqAndVolScale, + &gSfxDefaultFreqAndVolScale, &gSfxDefaultReverb); } } } } Collider_UpdateCylinder(thisx, &this->standCollider); - CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->standCollider.base); - CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->standCollider.base); + CollisionCheck_SetOC(play, &play->colChkCtx, &this->standCollider.base); + CollisionCheck_SetAC(play, &play->colChkCtx, &this->standCollider.base); Collider_UpdateCylinder(thisx, &this->flameCollider); - CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->flameCollider.base); + CollisionCheck_SetAC(play, &play->colChkCtx, &this->flameCollider.base); if ((this->snuffTimer > OBJ_SYOKUDAI_SNUFF_OUT) && (--this->snuffTimer == OBJ_SYOKUDAI_SNUFF_OUT) && (type != OBJ_SYOKUDAI_TYPE_SWITCH_CAUSES_FLAME)) { sNumLitTorchesInGroup--; @@ -285,15 +285,15 @@ void ObjSyokudai_Update(Actor* thisx, GlobalContext* globalCtx2) { this->flameTexScroll++; } -void ObjSyokudai_Draw(Actor* thisx, GlobalContext* globalCtx) { +void ObjSyokudai_Draw(Actor* thisx, PlayState* play) { ObjSyokudai* this = THIS; s32 pad; s32 groupSize = OBJ_SYOKUDAI_GET_GROUP_SIZE(thisx); f32 flameScale; - 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); + OPEN_DISPS(play->state.gfxCtx); + func_8012C28C(play->state.gfxCtx); + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_OPA_DISP++, sDLists[OBJ_SYOKUDAI_GET_TYPE(thisx)]); if (this->snuffTimer != OBJ_SYOKUDAI_SNUFF_OUT) { s32 snuffTimerInitial = OBJ_SYOKUDAI_SNUFF_TIMER_INITIAL(groupSize); @@ -306,18 +306,18 @@ void ObjSyokudai_Draw(Actor* thisx, GlobalContext* globalCtx) { flameScale = (f32)this->snuffTimer / OBJ_SYOKUDAI_SNUFF_DEFAULT; } flameScale *= 0.0027f; - func_8012C2DC(globalCtx->state.gfxCtx); + func_8012C2DC(play->state.gfxCtx); gSPSegment(POLY_XLU_DISP++, 0x08, - Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, 0, 0, 0x20, 0x40, 1, 0, + Gfx_TwoTexScroll(play->state.gfxCtx, 0, 0, 0, 0x20, 0x40, 1, 0, (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(Camera_GetCamDirYaw(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(play)) - 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); + + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_XLU_DISP++, gEffFire1DL); } - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->state.gfxCtx); } diff --git a/src/overlays/actors/ovl_Obj_Syokudai/z_obj_syokudai.h b/src/overlays/actors/ovl_Obj_Syokudai/z_obj_syokudai.h index 618b86ed5..d1a0be1c8 100644 --- a/src/overlays/actors/ovl_Obj_Syokudai/z_obj_syokudai.h +++ b/src/overlays/actors/ovl_Obj_Syokudai/z_obj_syokudai.h @@ -50,10 +50,10 @@ typedef enum { #define OBJ_SYOKUDAI_SNUFF_TIMER_JUST_LIT_BONUS 10 #define OBJ_SYOKUDAI_LIGHT_RADIUS_MAX 250 -#define OBJ_SYOKUDAI_GET_TYPE(thisx) (thisx->params >> 0xC) -#define OBJ_SYOKUDAI_GET_START_LIT(thisx) (thisx->params & 0x800) -#define OBJ_SYOKUDAI_GET_GROUP_SIZE(thisx) ((thisx->params >> 7) & 0xF) -#define OBJ_SYOKUDAI_GET_SWITCH_FLAG(thisx) (thisx->params & 0x7F) +#define OBJ_SYOKUDAI_GET_TYPE(thisx) ((thisx)->params >> 0xC) +#define OBJ_SYOKUDAI_GET_START_LIT(thisx) ((thisx)->params & 0x800) +#define OBJ_SYOKUDAI_GET_GROUP_SIZE(thisx) (((thisx)->params >> 7) & 0xF) +#define OBJ_SYOKUDAI_GET_SWITCH_FLAG(thisx) ((thisx)->params & 0x7F) #define OBJ_SYOKUDAI_SNUFF_TIMER_INITIAL(groupSize) ((groupSize * 50) + 100) 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 65c984981..e4936f1fb 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 @@ -10,12 +10,12 @@ #define THIS ((ObjTakarayaWall*)thisx) -void ObjTakarayaWall_Init(Actor* thisx, GlobalContext* globalCtx); -void ObjTakarayaWall_Destroy(Actor* thisx, GlobalContext* globalCtx); -void ObjTakarayaWall_Update(Actor* thisx, GlobalContext* globalCtx); -void ObjTakarayaWall_Draw(Actor* thisx, GlobalContext* globalCtx); +void ObjTakarayaWall_Init(Actor* thisx, PlayState* play); +void ObjTakarayaWall_Destroy(Actor* thisx, PlayState* play); +void ObjTakarayaWall_Update(Actor* thisx, PlayState* play); +void ObjTakarayaWall_Draw(Actor* thisx, PlayState* play); -void func_80AD9B04(ObjTakarayaWall* this, GlobalContext* globalCtx); +void func_80AD9B04(ObjTakarayaWall* this, PlayState* play); #if 0 const ActorInit Obj_Takaraya_Wall_InitVars = { diff --git a/src/overlays/actors/ovl_Obj_Takaraya_Wall/z_obj_takaraya_wall.h b/src/overlays/actors/ovl_Obj_Takaraya_Wall/z_obj_takaraya_wall.h index 83f267d37..603041d9f 100644 --- a/src/overlays/actors/ovl_Obj_Takaraya_Wall/z_obj_takaraya_wall.h +++ b/src/overlays/actors/ovl_Obj_Takaraya_Wall/z_obj_takaraya_wall.h @@ -5,12 +5,12 @@ struct ObjTakarayaWall; -typedef void (*ObjTakarayaWallActionFunc)(struct ObjTakarayaWall*, GlobalContext*); +typedef void (*ObjTakarayaWallActionFunc)(struct ObjTakarayaWall*, PlayState*); typedef struct ObjTakarayaWall { - /* 0x0000 */ Actor actor; - /* 0x0144 */ ObjTakarayaWallActionFunc actionFunc; - /* 0x0148 */ char unk_148[0x98]; + /* 0x000 */ Actor actor; + /* 0x144 */ ObjTakarayaWallActionFunc actionFunc; + /* 0x148 */ char unk_148[0x98]; } ObjTakarayaWall; // size = 0x1E0 extern const ActorInit Obj_Takaraya_Wall_InitVars; diff --git a/src/overlays/actors/ovl_Obj_Taru/z_obj_taru.c b/src/overlays/actors/ovl_Obj_Taru/z_obj_taru.c index 6d7fd7552..9aadc668c 100644 --- a/src/overlays/actors/ovl_Obj_Taru/z_obj_taru.c +++ b/src/overlays/actors/ovl_Obj_Taru/z_obj_taru.c @@ -1,21 +1,29 @@ /* * File: z_obj_taru.c * Overlay: ovl_Obj_Taru - * Description: Wooden Barrel + * Description: Wooden Barrel and Breakable Pirate Panel */ #include "z_obj_taru.h" +#include "overlays/actors/ovl_En_Sw/z_en_sw.h" +#include "overlays/effects/ovl_Effect_Ss_Kakera/z_eff_ss_kakera.h" +#include "overlays/actors/ovl_Obj_Tsubo/z_obj_tsubo.h" +#include "objects/object_taru/object_taru.h" +#include "objects/object_kibako2/object_kibako2.h" #define FLAGS 0x00000000 #define THIS ((ObjTaru*)thisx) -void ObjTaru_Init(Actor* thisx, GlobalContext* globalCtx); -void ObjTaru_Destroy(Actor* thisx, GlobalContext* globalCtx); -void ObjTaru_Update(Actor* thisx, GlobalContext* globalCtx); -void ObjTaru_Draw(Actor* thisx, GlobalContext* globalCtx); +void ObjTaru_Init(Actor* thisx, PlayState* play); +void ObjTaru_Destroy(Actor* thisx, PlayState* play); +void ObjTaru_Update(Actor* thisx, PlayState* play); +void ObjTaru_Draw(Actor* thisx, PlayState* play); + +void func_80B9C07C(ObjTaru* this, PlayState* play); +void func_80B9C174(ObjTaru* this, PlayState* play); +void func_80B9C1A0(ObjTaru* this, PlayState* play); -#if 0 const ActorInit Obj_Taru_InitVars = { ACTOR_OBJ_TARU, ACTORCAT_BG, @@ -28,55 +36,309 @@ const ActorInit Obj_Taru_InitVars = { (ActorFunc)ObjTaru_Draw, }; -// static ColliderCylinderInit sCylinderInit = { -static ColliderCylinderInit D_80B9C340 = { - { COLTYPE_NONE, AT_NONE, AC_ON | AC_TYPE_PLAYER, OC1_NONE, OC2_TYPE_2, COLSHAPE_CYLINDER, }, - { ELEMTYPE_UNK0, { 0x00000000, 0x00, 0x00 }, { 0x80000508, 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_TYPE_2, + COLSHAPE_CYLINDER, + }, + { + ELEMTYPE_UNK0, + { 0x00000000, 0x00, 0x00 }, + { 0x80000508, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_NONE, + }, { 30, 50, 0, { 0, 0, 0 } }, }; -// static InitChainEntry sInitChain[] = { -static InitChainEntry D_80B9C36C[] = { +static InitChainEntry sInitChain[] = { ICHAIN_VEC3F_DIV1000(scale, 100, ICHAIN_CONTINUE), ICHAIN_F32(uncullZoneForward, 3300, ICHAIN_CONTINUE), ICHAIN_F32(uncullZoneScale, 200, ICHAIN_CONTINUE), ICHAIN_F32(uncullZoneDownward, 200, ICHAIN_STOP), }; -#endif +s32 func_80B9B6E0(ObjTaru* this, PlayState* play) { + s32 chestFlag = -1; + s32 skulltulaParams = (OBJ_TSUBO_P001F(&this->dyna.actor) * 4) | 0xFF01; -extern ColliderCylinderInit D_80B9C340; -extern InitChainEntry D_80B9C36C[]; + if (ENSW_GETS_3(skulltulaParams)) { + chestFlag = ENSW_GETS_3FC(skulltulaParams); + } -extern UNK_TYPE D_06000420; -extern UNK_TYPE D_06001040; -extern UNK_TYPE D_06001100; -extern UNK_TYPE D_06001CB0; + return (chestFlag < 0) == true || !Flags_GetTreasure(play, chestFlag); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Taru/func_80B9B6E0.s") +void func_80B9B74C(ObjTaru* this, PlayState* play) { + s32 pad[2]; + Vec3f* thisPos = &this->dyna.actor.world.pos; + Vec3f pos; + Vec3f velocity; + s16 angle; + s32 i; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Taru/func_80B9B74C.s") + for (i = 0, angle = 0; i < 0x10; i++, angle += 0x4E20) { + f32 sin = Math_SinS(angle); + f32 cos = Math_CosS(angle); + f32 tempRand = Rand_ZeroOne() * 30.0f; + s32 phi_s0; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Taru/func_80B9B9C8.s") + pos.x = sin * tempRand; + pos.y = (Rand_ZeroOne() * 10.0f) + 2.0f; + pos.z = cos * tempRand; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Taru/func_80B9BC64.s") + velocity.x = pos.x * 0.2f; + velocity.y = (Rand_ZeroOne() * 10.0f) + 2.0f; + velocity.z = pos.z * 0.2f; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Taru/func_80B9BCBC.s") + pos.x += thisPos->x; + pos.y += thisPos->y; + pos.z += thisPos->z; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Taru/func_80B9BD84.s") + tempRand = Rand_ZeroOne(); + if (tempRand < 0.05f) { + phi_s0 = 0x60; + } else if (tempRand < 0.7f) { + phi_s0 = 0x40; + } else { + phi_s0 = 0x20; + } + EffectSsKakera_Spawn(play, &pos, &velocity, &pos, -200, phi_s0, 28, 2, 0, (Rand_ZeroOne() * 30.0f) + 5.0f, 0, 0, + 70, KAKERA_COLOR_NONE, OBJECT_KIBAKO2, gLargeCrateFragment1DL); + } + func_800BBFB0(play, thisPos, 90.0f, 6, 100, 160, 1); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Taru/ObjTaru_Init.s") +void func_80B9B9C8(ObjTaru* this, PlayState* play) { + s32 phi_s5; + s32 i; + s32 j; + Vec3f spD8; + Vec3f spCC; + s32 pad[2]; + f32 sin; + f32 cos; + s32 phi_fp; + Vec3f* thisPos = &this->dyna.actor.world.pos; + f32 temp_fs0; + f32 temp_fs1; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Taru/ObjTaru_Destroy.s") + sin = Math_SinS(this->dyna.actor.shape.rot.y); + cos = Math_CosS(this->dyna.actor.shape.rot.y); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Taru/func_80B9BF7C.s") + if (OBJ_TARU_GET_100(&this->dyna.actor)) { + phi_fp = 0; + phi_s5 = 8; + } else { + phi_fp = 2; + phi_s5 = 6; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Taru/func_80B9C07C.s") + for (i = 0; i < 4; i++) { + for (j = phi_fp; j < phi_s5; j++) { + temp_fs0 = randPlusMinusPoint5Scaled(10.0f) + -105.0f + (j * 30.0f); + temp_fs1 = randPlusMinusPoint5Scaled(4.0f); + spD8.x = temp_fs0 * cos; + spD8.y = randPlusMinusPoint5Scaled(10.0f) + 15.0f + (i * 30.0f); + spD8.z = temp_fs0 * sin; + spCC.x = (spD8.x * 0.05f) + (temp_fs1 * sin); + spCC.y = Rand_ZeroFloat(5.0f) + 2.0f; + spCC.z = (spD8.z * 0.05f) + (temp_fs1 * cos); + spD8.x += thisPos->x; + spD8.y += thisPos->y; + spD8.z += thisPos->z; + EffectSsKakera_Spawn(play, &spD8, &spCC, &spD8, -0x64, 0x20, 0x1C, 4, 0, (Rand_ZeroOne() * 30.0f) + 5.0f, 0, + 0, 0x5A, KAKERA_COLOR_NONE, OBJECT_KIBAKO2, gLargeCrateFragment2DL); + } + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Taru/func_80B9C174.s") +void func_80B9BC64(ObjTaru* this, PlayState* play) { + s32 item; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Taru/func_80B9C1A0.s") + item = func_800A8150(OBJ_TARU_GET_3F(&this->dyna.actor)); + if (item >= 0) { + Item_DropCollectible(play, &this->dyna.actor.world.pos, (OBJ_TARU_GET_7F00(&this->dyna.actor) << 8) | item); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Taru/ObjTaru_Update.s") +void func_80B9BCBC(ObjTaru* this, PlayState* play) { + s32 pad; + s32 params1F; + Actor* spawnedActor; + s16 rotY; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Taru/ObjTaru_Draw.s") + if (func_80B9B6E0(this, play)) { + params1F = (OBJ_TARU_GET_1F(&this->dyna.actor) * 4) | 0xFF01; + rotY = (Rand_Next() >> 0x11) + this->dyna.actor.yawTowardsPlayer + 0xC000; + spawnedActor = Actor_Spawn(&play->actorCtx, play, ACTOR_EN_SW, this->dyna.actor.world.pos.x, + this->dyna.actor.world.pos.y, this->dyna.actor.world.pos.z, 0, rotY, 0, params1F); + if (spawnedActor != NULL) { + spawnedActor->parent = &this->dyna.actor; + spawnedActor->velocity.y = 12.0f; + spawnedActor->speedXZ = 2.0f; + } + } +} + +void func_80B9BD84(ObjTaru* this, PlayState* play) { + if (!OBJ_TARU_GET_8000(&this->dyna.actor)) { + func_80B9BC64(this, play); + } else { + func_80B9BCBC(this, play); + } +} + +void ObjTaru_Init(Actor* thisx, PlayState* play) { + s32 pad; + ObjTaru* this = THIS; + s32 params8000; + + DynaPolyActor_Init(&this->dyna, 0); + Actor_ProcessInitChain(&this->dyna.actor, sInitChain); + + if (OBJ_TARU_GET_80(thisx)) { + if (Flags_GetSwitch(play, OBJ_TARU_GET_7F(thisx))) { + Actor_MarkForDeath(&this->dyna.actor); + } else { + DynaPolyActor_LoadMesh(play, &this->dyna, &object_taru_Colheader_001CB0); + } + if (OBJ_TARU_GET_100(&this->dyna.actor)) { + this->dyna.actor.scale.x = 0.2f; + } + } else { + params8000 = OBJ_TARU_GET_8000(thisx); + DynaPolyActor_LoadMesh(play, &this->dyna, &object_taru_Colheader_000FC8); + Collider_InitAndSetCylinder(play, &this->collider, &this->dyna.actor, &sCylinderInit); + Collider_UpdateCylinder(&this->dyna.actor, &this->collider); + + if (params8000 == 0) { + if (Item_CanDropBigFairy(play, OBJ_TARU_GET_3F(&this->dyna.actor), OBJ_TARU_GET_7F00(&this->dyna.actor))) { + this->unk_1AC = 1; + this->dyna.actor.flags |= ACTOR_FLAG_10; + } + } + if ((params8000 != 1) || (!func_80B9B6E0(this, play))) { + this->unk_1AD = -1; + } + } + this->actionFunc = func_80B9C07C; +} + +void ObjTaru_Destroy(Actor* thisx, PlayState* play) { + ObjTaru* this = THIS; + + if (!OBJ_TARU_GET_80(thisx)) { + Collider_DestroyCylinder(play, &this->collider); + } + DynaPoly_DeleteBgActor(play, &play->colCtx.dyna, this->dyna.bgId); +} + +s32 func_80B9BF7C(ObjTaru* this) { + s32 pad; + s32 phi_a3 = false; + + if ((!OBJ_TARU_GET_80(&this->dyna.actor)) && (this->collider.base.acFlags & AC_HIT)) { + Actor* ac = this->collider.base.ac; + + this->collider.base.acFlags &= ~AC_HIT; + if (ac != NULL) { + if (this->collider.info.acHitInfo->toucher.dmgFlags & 0x80000000) { + phi_a3 = false; + if (Math3D_Vec3fDistSq(&this->dyna.actor.world.pos, &ac->world.pos) < SQ(160.0f)) { + phi_a3 = true; + } + } else if (this->collider.info.acHitInfo->toucher.dmgFlags & 8) { + if (Math3D_Vec3fDistSq(&this->dyna.actor.world.pos, &ac->world.pos) < SQ(100.0f)) { + phi_a3 = true; + } + } else if (this->collider.info.acHitInfo->toucher.dmgFlags & 0x500) { + phi_a3 = true; + } + } + } else if (this->dyna.actor.home.rot.z != 0) { + phi_a3 = true; + } + return phi_a3; +} + +void func_80B9C07C(ObjTaru* this, PlayState* play) { + if (func_80B9BF7C(this)) { + if (!OBJ_TARU_GET_80(&this->dyna.actor)) { + func_80B9B74C(this, play); + } else { + func_80B9B9C8(this, play); + } + SoundSource_PlaySfxAtFixedWorldPos(play, &this->dyna.actor.world.pos, 0x14, NA_SE_EV_WOODBOX_BREAK); + if (OBJ_TARU_GET_80(&this->dyna.actor)) { + this->actionFunc = func_80B9C1A0; + } else { + this->dyna.actor.flags |= ACTOR_FLAG_10; + func_800C62BC(play, &play->colCtx.dyna, this->dyna.bgId); + this->dyna.actor.draw = NULL; + this->actionFunc = func_80B9C174; + } + } else { + if (this->dyna.actor.xzDistToPlayer < 600.0f) { + CollisionCheck_SetAC(play, &play->colChkCtx, &this->collider.base); + } + } +} + +void func_80B9C174(ObjTaru* this, PlayState* play) { + func_80B9BD84(this, play); + Actor_MarkForDeath(&this->dyna.actor); +} + +void func_80B9C1A0(ObjTaru* this, PlayState* play) { + if (ActorCutscene_GetCanPlayNext(this->dyna.actor.cutscene)) { + ActorCutscene_StartAndSetUnkLinkFields(this->dyna.actor.cutscene, &this->dyna.actor); + Flags_SetSwitch(play, OBJ_TARU_GET_7F(&this->dyna.actor)); + Actor_MarkForDeath(&this->dyna.actor); + } else { + ActorCutscene_SetIntentToPlay(this->dyna.actor.cutscene); + } +} + +void ObjTaru_Update(Actor* thisx, PlayState* play) { + ObjTaru* this = THIS; + + if (!OBJ_TARU_GET_80(thisx)) { + if (this->unk_1AC != 0) { + play->actorCtx.unk5 |= 8; + } + if (this->unk_1AD >= 0) { + switch (this->unk_1AD) { + case 0: + Actor_PlaySfxAtPos(&this->dyna.actor, NA_SE_EN_STALGOLD_ROLL); + if (Rand_ZeroOne() < 0.1f) { + this->unk_1AD = Rand_S16Offset(40, 80); + } else { + this->unk_1AD = 8; + } + break; + default: + this->unk_1AD--; + break; + } + } + } + this->actionFunc(this, play); +} + +void ObjTaru_Draw(Actor* thisx, PlayState* play) { + Gfx* dList; + ObjTaru* this = THIS; + + if (OBJ_TARU_GET_80(thisx)) { + dList = gObjTaruBreakablePiratePanelDL; + } else { + dList = gObjTaruBarrelDL; + } + Gfx_DrawDListOpa(play, dList); +} diff --git a/src/overlays/actors/ovl_Obj_Taru/z_obj_taru.h b/src/overlays/actors/ovl_Obj_Taru/z_obj_taru.h index 67cea2ef8..063e90ef4 100644 --- a/src/overlays/actors/ovl_Obj_Taru/z_obj_taru.h +++ b/src/overlays/actors/ovl_Obj_Taru/z_obj_taru.h @@ -3,15 +3,24 @@ #include "global.h" +#define OBJ_TARU_GET_100(thisx) ((thisx)->params & 0x100) +#define OBJ_TARU_GET_1F(thisx) ((thisx)->params & 0x1F) +#define OBJ_TARU_GET_3F(thisx) ((thisx)->params & 0x3F) +#define OBJ_TARU_GET_7F(thisx) ((thisx)->params & 0x7F) +#define OBJ_TARU_GET_7F00(thisx) (((thisx)->params >> 8) & 0x7F) +#define OBJ_TARU_GET_80(thisx) ((thisx)->params & 0x80) +#define OBJ_TARU_GET_8000(thisx) (((thisx)->params >> 0xF) & 1) + struct ObjTaru; -typedef void (*ObjTaruActionFunc)(struct ObjTaru*, GlobalContext*); +typedef void (*ObjTaruActionFunc)(struct ObjTaru*, PlayState*); typedef struct ObjTaru { - /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x64]; - /* 0x01A8 */ ObjTaruActionFunc actionFunc; - /* 0x01AC */ char unk_1AC[0x4]; + /* 0x000 */ DynaPolyActor dyna; + /* 0x15C */ ColliderCylinder collider; + /* 0x1A8 */ ObjTaruActionFunc actionFunc; + /* 0x1AC */ s8 unk_1AC; + /* 0x1AD */ s8 unk_1AD; } ObjTaru; // size = 0x1B0 extern const ActorInit Obj_Taru_InitVars; 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 0471b6bd7..bd5c16413 100644 --- a/src/overlays/actors/ovl_Obj_Toge/z_obj_toge.c +++ b/src/overlays/actors/ovl_Obj_Toge/z_obj_toge.c @@ -5,21 +5,24 @@ */ #include "z_obj_toge.h" +#include "objects/object_trap/object_trap.h" #define FLAGS (ACTOR_FLAG_10) #define THIS ((ObjToge*)thisx) -void ObjToge_Init(Actor* thisx, GlobalContext* globalCtx); -void ObjToge_Destroy(Actor* thisx, GlobalContext* globalCtx); -void ObjToge_Update(Actor* thisx, GlobalContext* globalCtx); -void ObjToge_Draw(Actor* thisx, GlobalContext* globalCtx); +void ObjToge_Init(Actor* thisx, PlayState* play); +void ObjToge_Destroy(Actor* thisx, PlayState* play); +void ObjToge_Update(Actor* thisx, PlayState* play); +void ObjToge_Draw(Actor* thisx, PlayState* play); -void func_809A477C(ObjToge* this, GlobalContext* globalCtx); -void func_809A481C(ObjToge* this, GlobalContext* globalCtx); -void func_809A48AC(ObjToge* this, GlobalContext* globalCtx); +void func_809A4744(ObjToge* this); +void func_809A477C(ObjToge* this, PlayState* play); +void func_809A4804(ObjToge* this); +void func_809A481C(ObjToge* this, PlayState* play); +void func_809A488C(ObjToge* this); +void func_809A48AC(ObjToge* this, PlayState* play); -#if 0 const ActorInit Obj_Toge_InitVars = { ACTOR_OBJ_TOGE, ACTORCAT_PROP, @@ -32,52 +35,279 @@ 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, PlayState* play) { + Vec3f sp1C = this->actor.world.pos; -extern ColliderCylinderInit D_809A4CB0; -extern InitChainEntry D_809A4D14[]; + sp1C.y += 10.0f; + sp1C.z += 10.0f; + func_800B2B44(play, &this->actor, &sp1C, 1.8f); -extern UNK_TYPE D_06001400; + sp1C.x += 10.0f; + sp1C.z -= 20.0f; + func_800B2B44(play, &this->actor, &sp1C, 1.8f); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Toge/func_809A41C0.s") + sp1C.x -= 20.0f; + func_800B2B44(play, &this->actor, &sp1C, 1.8f); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Toge/func_809A42A0.s") +void func_809A42A0(ObjToge* this, PlayState* play) { + 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(play, &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, PlayState* play) { + if (!OBJTOGE_GET_4000(&this->actor)) { + func_809A41C0(this, play); + } else { + func_809A42A0(this, play); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Toge/ObjToge_Destroy.s") +s32 func_809A43EC(ObjToge* this, PlayState* play) { + Player* player = GET_PLAYER(play); + 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, PlayState* play) { + 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(play, &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 = &play->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(play, &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, PlayState* play2) { + PlayState* play = play2; + ObjToge* this = THIS; + + Collider_DestroyCylinder(play, &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, PlayState* play) { + 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, PlayState* play) { + if (this->unk_1B0 >= 0x1770) { + this->unk_1B0 = 0x1770; + func_809A488C(this); + } else if ((this->unk_1B0 > 0) || func_809A43EC(this, play)) { + 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, PlayState* play) { + 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(play, &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, PlayState* play) { + 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, play); + 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(play, &this->actor, 6.0f, this->actor.yawTowardsPlayer, 6.0f, 4); + } + + this->actionFunc(this, play); + + Collider_UpdateCylinder(&this->actor, &this->collider); + if (this->actor.xzDistToPlayer < 1000.0f) { + CollisionCheck_SetAC(play, &play->colChkCtx, &this->collider.base); + } + } + + if ((this->actor.flags & ACTOR_FLAG_40) || (this->actor.xzDistToPlayer < 300.0f)) { + CollisionCheck_SetOC(play, &play->colChkCtx, &collider->base); + } else { + this->collider.base.ocFlags1 &= ~OC1_HIT; + this->collider.base.ocFlags2 &= ~OC2_HIT_PLAYER; + } +} + +void ObjToge_Draw(Actor* thisx, PlayState* play) { + ObjToge* this = THIS; + + func_800B8050(&this->actor, play, 1); + Gfx_DrawDListOpa(play, 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..9a55a4219 100644 --- a/src/overlays/actors/ovl_Obj_Toge/z_obj_toge.h +++ b/src/overlays/actors/ovl_Obj_Toge/z_obj_toge.h @@ -5,13 +5,28 @@ struct ObjToge; -typedef void (*ObjTogeActionFunc)(struct ObjToge*, GlobalContext*); +typedef void (*ObjTogeActionFunc)(struct ObjToge*, PlayState*); + +#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 b46f2626e..780c31c9a 100644 --- a/src/overlays/actors/ovl_Obj_Tokei_Step/z_obj_tokei_step.c +++ b/src/overlays/actors/ovl_Obj_Tokei_Step/z_obj_tokei_step.c @@ -5,26 +5,27 @@ */ #include "z_obj_tokei_step.h" +#include "z64rumble.h" #include "objects/object_tokei_step/object_tokei_step.h" #define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_400000) #define THIS ((ObjTokeiStep*)thisx) -void ObjTokeiStep_Init(Actor* thisx, GlobalContext* globalCtx); -void ObjTokeiStep_Destroy(Actor* thisx, GlobalContext* globalCtx); -void ObjTokeiStep_Update(Actor* thisx, GlobalContext* globalCtx); -void ObjTokeiStep_Draw(Actor* thisx, GlobalContext* globalCtx); +void ObjTokeiStep_Init(Actor* thisx, PlayState* play); +void ObjTokeiStep_Destroy(Actor* thisx, PlayState* play); +void ObjTokeiStep_Update(Actor* thisx, PlayState* play); +void ObjTokeiStep_Draw(Actor* thisx, PlayState* play); void ObjTokeiStep_SetupBeginOpen(ObjTokeiStep* this); -void ObjTokeiStep_BeginOpen(ObjTokeiStep* this, GlobalContext* globalCtx); +void ObjTokeiStep_BeginOpen(ObjTokeiStep* this, PlayState* play); void ObjTokeiStep_SetupDoNothing(ObjTokeiStep* this); -void ObjTokeiStep_DoNothing(ObjTokeiStep* this, GlobalContext* globalCtx); +void ObjTokeiStep_DoNothing(ObjTokeiStep* this, PlayState* play); void ObjTokeiStep_SetupOpen(ObjTokeiStep* this); -void ObjTokeiStep_Open(ObjTokeiStep* this, GlobalContext* globalCtx); +void ObjTokeiStep_Open(ObjTokeiStep* this, PlayState* play); void ObjTokeiStep_SetupDoNothingOpen(ObjTokeiStep* this); -void ObjTokeiStep_DoNothingOpen(ObjTokeiStep* this, GlobalContext* globalCtx); -void ObjTokeiStep_DrawOpen(Actor* thisx, GlobalContext* globalCtx); +void ObjTokeiStep_DoNothingOpen(ObjTokeiStep* this, PlayState* play); +void ObjTokeiStep_DrawOpen(Actor* thisx, PlayState* play); const ActorInit Obj_Tokei_Step_InitVars = { ACTOR_OBJ_TOKEI_STEP, @@ -52,40 +53,40 @@ 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) { +void ObjTokeiStep_AddQuake(ObjTokeiStep* this, PlayState* play) { s32 pad[2]; - s16 quake = Quake_Add(GET_ACTIVE_CAM(globalCtx), 3); + s16 quake = Quake_Add(GET_ACTIVE_CAM(play), 3); Quake_SetSpeed(quake, 20000); Quake_SetQuakeValues(quake, 1, 0, 0, 0); Quake_SetCountdown(quake, 7); - func_8013ECE0(this->dyna.actor.xyzDistToPlayerSq, 120, 20, 10); + Rumble_Request(this->dyna.actor.xyzDistToPlayerSq, 120, 20, 10); } -void ObjTokeiStep_SpawnDust(ObjTokeiStep* this, ObjTokeiStepPanel* panel, GlobalContext* globalCtx) { +void ObjTokeiStep_SpawnDust(ObjTokeiStep* this, ObjTokeiStepPanel* panel, PlayState* play) { s32 i; s32 pad; 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; - func_800B1210(globalCtx, &dustSpawnPos, &gZeroVec3f, &sDustEffectAccel, (s32)((Rand_ZeroOne() * 40.0f) + 80.0f), + func_800B1210(play, &dustSpawnPos, &gZeroVec3f, &sDustEffectAccel, (s32)((Rand_ZeroOne() * 40.0f) + 80.0f), (s32)((Rand_ZeroOne() * 20.0f) + 50.0f)); } } @@ -96,15 +97,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 +116,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); } } @@ -136,7 +137,7 @@ void ObjTokeiStep_InitTimers(ObjTokeiStep* this) { } } -s32 ObjTokeiStep_OpenProcess(ObjTokeiStep* this, GlobalContext* globalCtx) { +s32 ObjTokeiStep_OpenProcess(ObjTokeiStep* this, PlayState* play) { ObjTokeiStep* this2 = this; s32 i; ObjTokeiStepPanel* panel; @@ -176,8 +177,8 @@ s32 ObjTokeiStep_OpenProcess(ObjTokeiStep* this, GlobalContext* globalCtx) { panel->pos.y += finalPosY; } if (panel->numBounces == 1) { - ObjTokeiStep_SpawnDust(this2, panel, globalCtx); - ObjTokeiStep_AddQuake(this2, globalCtx); + ObjTokeiStep_SpawnDust(this2, panel, play); + ObjTokeiStep_AddQuake(this2, play); } } } @@ -187,14 +188,14 @@ s32 ObjTokeiStep_OpenProcess(ObjTokeiStep* this, GlobalContext* globalCtx) { return isOpen; } -void ObjTokeiStep_Init(Actor* thisx, GlobalContext* globalCtx) { +void ObjTokeiStep_Init(Actor* thisx, PlayState* play) { ObjTokeiStep* this = THIS; Actor_ProcessInitChain(&this->dyna.actor, sInitChain); DynaPolyActor_Init(&this->dyna, 0); - if ((globalCtx->sceneNum == SCENE_CLOCKTOWER) && (gSaveContext.sceneSetupIndex == 2) && - (globalCtx->csCtx.currentCsIndex == 0)) { - DynaPolyActor_LoadMesh(globalCtx, &this->dyna, &gClocktowerPanelCol); + if ((play->sceneNum == SCENE_CLOCKTOWER) && (gSaveContext.sceneSetupIndex == 2) && + (play->csCtx.currentCsIndex == 0)) { + DynaPolyActor_LoadMesh(play, &this->dyna, &gClocktowerPanelCol); ObjTokeiStep_InitSteps(this); ObjTokeiStep_SetupBeginOpen(this); } else if (((CURRENT_DAY == 3) && (gSaveContext.save.time < CLOCK_TIME(6, 0))) || (gSaveContext.save.day >= 4)) { @@ -202,29 +203,29 @@ void ObjTokeiStep_Init(Actor* thisx, GlobalContext* globalCtx) { ObjTokeiStep_InitStepsOpen(this); ObjTokeiStep_SetupDoNothingOpen(this); } else { - DynaPolyActor_LoadMesh(globalCtx, &this->dyna, &gClocktowerPanelCol); + DynaPolyActor_LoadMesh(play, &this->dyna, &gClocktowerPanelCol); ObjTokeiStep_InitSteps(this); ObjTokeiStep_SetupDoNothing(this); } } -void ObjTokeiStep_Destroy(Actor* thisx, GlobalContext* globalCtx) { +void ObjTokeiStep_Destroy(Actor* thisx, PlayState* play) { ObjTokeiStep* this = THIS; - DynaPoly_DeleteBgActor(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); + DynaPoly_DeleteBgActor(play, &play->colCtx.dyna, this->dyna.bgId); } void ObjTokeiStep_SetupBeginOpen(ObjTokeiStep* this) { this->actionFunc = ObjTokeiStep_BeginOpen; } -void ObjTokeiStep_BeginOpen(ObjTokeiStep* this, GlobalContext* globalCtx) { +void ObjTokeiStep_BeginOpen(ObjTokeiStep* this, PlayState* play) { CsCmdActorAction* action; - if (Cutscene_CheckActorAction(globalCtx, 134)) { - action = globalCtx->csCtx.actorActions[Cutscene_GetActorActionIndex(globalCtx, 134)]; + if (Cutscene_CheckActorAction(play, 134)) { + action = play->csCtx.actorActions[Cutscene_GetActorActionIndex(play, 134)]; - if ((action->startFrame == globalCtx->csCtx.frames) && (action->action != 0)) { + if ((action->startFrame == play->csCtx.frames) && (action->action != 0)) { this->dyna.actor.draw = ObjTokeiStep_DrawOpen; ObjTokeiStep_SetupOpen(this); } @@ -235,7 +236,7 @@ void ObjTokeiStep_SetupDoNothing(ObjTokeiStep* this) { this->actionFunc = ObjTokeiStep_DoNothing; } -void ObjTokeiStep_DoNothing(ObjTokeiStep* this, GlobalContext* globalCtx) { +void ObjTokeiStep_DoNothing(ObjTokeiStep* this, PlayState* play) { } void ObjTokeiStep_SetupOpen(ObjTokeiStep* this) { @@ -243,9 +244,9 @@ void ObjTokeiStep_SetupOpen(ObjTokeiStep* this) { this->actionFunc = ObjTokeiStep_Open; } -void ObjTokeiStep_Open(ObjTokeiStep* this, GlobalContext* globalCtx) { - if (ObjTokeiStep_OpenProcess(this, globalCtx)) { - func_800C62BC(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); +void ObjTokeiStep_Open(ObjTokeiStep* this, PlayState* play) { + if (ObjTokeiStep_OpenProcess(this, play)) { + func_800C62BC(play, &play->colCtx.dyna, this->dyna.bgId); ObjTokeiStep_SetupDoNothingOpen(this); } } @@ -255,37 +256,37 @@ void ObjTokeiStep_SetupDoNothingOpen(ObjTokeiStep* this) { this->actionFunc = ObjTokeiStep_DoNothingOpen; } -void ObjTokeiStep_DoNothingOpen(ObjTokeiStep* this, GlobalContext* globalCtx) { +void ObjTokeiStep_DoNothingOpen(ObjTokeiStep* this, PlayState* play) { } -void ObjTokeiStep_Update(Actor* thisx, GlobalContext* globalCtx) { +void ObjTokeiStep_Update(Actor* thisx, PlayState* play) { ObjTokeiStep* this = THIS; - this->actionFunc(this, globalCtx); + this->actionFunc(this, play); } -void ObjTokeiStep_Draw(Actor* thisx, GlobalContext* globalCtx) { +void ObjTokeiStep_Draw(Actor* thisx, PlayState* play) { ObjTokeiStep* this = THIS; - Gfx_DrawDListOpa(globalCtx, gClocktowerPanelDL); + Gfx_DrawDListOpa(play, gClocktowerPanelDL); } -void ObjTokeiStep_DrawOpen(Actor* thisx, GlobalContext* globalCtx) { +void ObjTokeiStep_DrawOpen(Actor* thisx, PlayState* play) { ObjTokeiStep* this = THIS; s32 i; ObjTokeiStepPanel* panel; Gfx* gfx; - OPEN_DISPS(globalCtx->state.gfxCtx); + OPEN_DISPS(play->state.gfxCtx); gfx = POLY_OPA_DISP; gSPDisplayList(gfx++, &sSetupDL[6 * 0x19]); for (i = 0; i < ARRAY_COUNT(this->panels); i++) { panel = &this->panels[i]; ObjTokeiStep_SetSysMatrix(panel); - gSPMatrix(gfx++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPMatrix(gfx++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(gfx++, gClocktowerPanelDL); } POLY_OPA_DISP = gfx; - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->state.gfxCtx); } diff --git a/src/overlays/actors/ovl_Obj_Tokei_Step/z_obj_tokei_step.h b/src/overlays/actors/ovl_Obj_Tokei_Step/z_obj_tokei_step.h index 06ec37e3a..537e7ecc7 100644 --- a/src/overlays/actors/ovl_Obj_Tokei_Step/z_obj_tokei_step.h +++ b/src/overlays/actors/ovl_Obj_Tokei_Step/z_obj_tokei_step.h @@ -5,7 +5,7 @@ struct ObjTokeiStep; -typedef void (*ObjTokeiStepFunc)(struct ObjTokeiStep*, struct GlobalContext*); +typedef void (*ObjTokeiStepFunc)(struct ObjTokeiStep*, struct PlayState*); typedef struct ObjTokeiStepPanel { /* 0x00 */ Vec3f pos; @@ -19,7 +19,7 @@ typedef struct ObjTokeiStepPanel { typedef struct ObjTokeiStep { /* 0x000 */ DynaPolyActor dyna; - /* 0x15c */ ObjTokeiStepFunc actionFunc; + /* 0x15C */ ObjTokeiStepFunc actionFunc; /* 0x160 */ ObjTokeiStepPanel panels[7]; } ObjTokeiStep; // size = 0x1EC diff --git a/src/overlays/actors/ovl_Obj_Tokei_Tobira/z_obj_tokei_tobira.c b/src/overlays/actors/ovl_Obj_Tokei_Tobira/z_obj_tokei_tobira.c index 9ffa6d446..15e01b832 100644 --- a/src/overlays/actors/ovl_Obj_Tokei_Tobira/z_obj_tokei_tobira.c +++ b/src/overlays/actors/ovl_Obj_Tokei_Tobira/z_obj_tokei_tobira.c @@ -10,10 +10,10 @@ #define THIS ((ObjTokeiTobira*)thisx) -void ObjTokeiTobira_Init(Actor* thisx, GlobalContext* globalCtx); -void ObjTokeiTobira_Destroy(Actor* thisx, GlobalContext* globalCtx); -void ObjTokeiTobira_Update(Actor* thisx, GlobalContext* globalCtx); -void ObjTokeiTobira_Draw(Actor* thisx, GlobalContext* globalCtx); +void ObjTokeiTobira_Init(Actor* thisx, PlayState* play); +void ObjTokeiTobira_Destroy(Actor* thisx, PlayState* play); +void ObjTokeiTobira_Update(Actor* thisx, PlayState* play); +void ObjTokeiTobira_Draw(Actor* thisx, PlayState* play); #if 0 const ActorInit Obj_Tokei_Tobira_InitVars = { diff --git a/src/overlays/actors/ovl_Obj_Tokei_Tobira/z_obj_tokei_tobira.h b/src/overlays/actors/ovl_Obj_Tokei_Tobira/z_obj_tokei_tobira.h index 610f67780..49e47af19 100644 --- a/src/overlays/actors/ovl_Obj_Tokei_Tobira/z_obj_tokei_tobira.h +++ b/src/overlays/actors/ovl_Obj_Tokei_Tobira/z_obj_tokei_tobira.h @@ -5,13 +5,13 @@ struct ObjTokeiTobira; -typedef void (*ObjTokeiTobiraActionFunc)(struct ObjTokeiTobira*, GlobalContext*); +typedef void (*ObjTokeiTobiraActionFunc)(struct ObjTokeiTobira*, PlayState*); typedef struct ObjTokeiTobira { - /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x18]; - /* 0x015C */ ObjTokeiTobiraActionFunc actionFunc; - /* 0x0160 */ char unk_160[0x10]; + /* 0x000 */ Actor actor; + /* 0x144 */ char unk_144[0x18]; + /* 0x15C */ ObjTokeiTobiraActionFunc actionFunc; + /* 0x160 */ char unk_160[0x10]; } ObjTokeiTobira; // size = 0x170 extern const ActorInit Obj_Tokei_Tobira_InitVars; diff --git a/src/overlays/actors/ovl_Obj_Tokei_Turret/z_obj_tokei_turret.c b/src/overlays/actors/ovl_Obj_Tokei_Turret/z_obj_tokei_turret.c index 327183cfd..a0183266f 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,17 +5,17 @@ */ #include "z_obj_tokei_turret.h" +#include "objects/object_tokei_turret/object_tokei_turret.h" #define FLAGS 0x00000000 #define THIS ((ObjTokeiTurret*)thisx) -void ObjTokeiTurret_Init(Actor* thisx, GlobalContext* globalCtx); -void ObjTokeiTurret_Destroy(Actor* thisx, GlobalContext* globalCtx); -void ObjTokeiTurret_Update(Actor* thisx, GlobalContext* globalCtx); -void ObjTokeiTurret_Draw(Actor* thisx, GlobalContext* globalCtx); +void ObjTokeiTurret_Init(Actor* thisx, PlayState* play); +void ObjTokeiTurret_Destroy(Actor* thisx, PlayState* play); +void ObjTokeiTurret_Update(Actor* thisx, PlayState* play); +void ObjTokeiTurret_Draw(Actor* thisx, PlayState* play); -#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, PlayState* play) { + 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(play, &this->dyna, &gClockTownTurretBaseCol); + } else { + DynaPolyActor_LoadMesh(play, &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, PlayState* play) { + ObjTokeiTurret* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Tokei_Turret/ObjTokeiTurret_Update.s") + DynaPoly_DeleteBgActor(play, &play->colCtx.dyna, this->dyna.bgId); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Tokei_Turret/ObjTokeiTurret_Draw.s") +void ObjTokeiTurret_Update(Actor* thisx, PlayState* play) { +} + +void ObjTokeiTurret_Draw(Actor* thisx, PlayState* play) { + ObjTokeiTurret* this = THIS; + Gfx* gfx; + + if (OBJ_TOKEI_TURRET_TIER_TYPE(thisx) == TURRET_TIER_TOP) { + OPEN_DISPS(play->state.gfxCtx); + + gfx = POLY_OPA_DISP; + gSPDisplayList(gfx++, &sSetupDL[6 * 25]); + gSPMatrix(gfx++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_MODELVIEW | G_MTX_LOAD); + gSPDisplayList(gfx++, gClockTownTurretPlatformTopDL); + POLY_OPA_DISP = gfx; + + CLOSE_DISPS(play->state.gfxCtx); + } else if (OBJ_TOKEI_TURRET_TIER_TYPE(thisx) == TURRET_TIER_BASE) { + Gfx_DrawDListOpa(play, gClockTownTurretPlatformBaseDL); + } else { + Gfx_DrawDListOpa(play, 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 d13a3bb4d..79b2e577e 100644 --- a/src/overlays/actors/ovl_Obj_Tokeidai/z_obj_tokeidai.c +++ b/src/overlays/actors/ovl_Obj_Tokeidai/z_obj_tokeidai.c @@ -42,25 +42,25 @@ #define GET_MINUTE_RING_OR_EXTERIOR_GEAR_ROTATION(currentClockMinute) \ ((s16)(currentClockMinute * (0x10000 * 12.0f / 360))) -void ObjTokeidai_Init(Actor* thisx, GlobalContext* globalCtx); -void ObjTokeidai_Destroy(Actor* thisx, GlobalContext* globalCtx); -void ObjTokeidai_Update(Actor* thisx, GlobalContext* globalCtx); -void ObjTokeidai_Draw(Actor* thisx, GlobalContext* globalCtx); +void ObjTokeidai_Init(Actor* thisx, PlayState* play); +void ObjTokeidai_Destroy(Actor* thisx, PlayState* play); +void ObjTokeidai_Update(Actor* thisx, PlayState* play); +void ObjTokeidai_Draw(Actor* thisx, PlayState* play); -void ObjTokeidai_DoNothing(ObjTokeidai* this, GlobalContext* globalCtx); -void ObjTokeidai_TowerClock_OpenedIdle(ObjTokeidai* this, GlobalContext* globalCtx); -void ObjTokeidai_ExteriorGear_OpenedIdle(ObjTokeidai* this, GlobalContext* globalCtx); -void ObjTokeidai_Counterweight_OpenedIdle(ObjTokeidai* this, GlobalContext* globalCtx); -void ObjTokeidai_TowerClock_Idle(ObjTokeidai* this, GlobalContext* globalCtx); -void ObjTokeidai_WallClock_Idle(ObjTokeidai* this, GlobalContext* globalCtx); -void ObjTokeidai_ExteriorGear_Idle(ObjTokeidai* this, GlobalContext* globalCtx); -void ObjTokeidai_Counterweight_Idle(ObjTokeidai* this, GlobalContext* globalCtx); -void ObjTokeidai_TerminaFieldWalls_Idle(ObjTokeidai* this, GlobalContext* globalCtx); -void ObjTokeidai_StaircaseToRooftop_Idle(ObjTokeidai* this, GlobalContext* globalCtx); +void ObjTokeidai_DoNothing(ObjTokeidai* this, PlayState* play); +void ObjTokeidai_TowerClock_OpenedIdle(ObjTokeidai* this, PlayState* play); +void ObjTokeidai_ExteriorGear_OpenedIdle(ObjTokeidai* this, PlayState* play); +void ObjTokeidai_Counterweight_OpenedIdle(ObjTokeidai* this, PlayState* play); +void ObjTokeidai_TowerClock_Idle(ObjTokeidai* this, PlayState* play); +void ObjTokeidai_WallClock_Idle(ObjTokeidai* this, PlayState* play); +void ObjTokeidai_ExteriorGear_Idle(ObjTokeidai* this, PlayState* play); +void ObjTokeidai_Counterweight_Idle(ObjTokeidai* this, PlayState* play); +void ObjTokeidai_TerminaFieldWalls_Idle(ObjTokeidai* this, PlayState* play); +void ObjTokeidai_StaircaseToRooftop_Idle(ObjTokeidai* this, PlayState* play); void ObjTokeidai_SetupTowerOpening(ObjTokeidai* this); -void ObjTokeidai_Clock_Draw(Actor* thisx, GlobalContext* globalCtx); -void ObjTokeidai_Counterweight_Draw(Actor* thisx, GlobalContext* globalCtx); -void ObjTokeidai_ExteriorGear_Draw(Actor* thisx, GlobalContext* globalCtx); +void ObjTokeidai_Clock_Draw(Actor* thisx, PlayState* play); +void ObjTokeidai_Counterweight_Draw(Actor* thisx, PlayState* play); +void ObjTokeidai_ExteriorGear_Draw(Actor* thisx, PlayState* play); const ActorInit Obj_Tokeidai_InitVars = { ACTOR_OBJ_TOKEIDAI, @@ -87,7 +87,7 @@ static InitChainEntry sInitChain[] = { * angle can differ from the target angle if the panel is in * the middle of rotating. */ -s32 ObjTokeidai_GetTargetSunMoonPanelRotation() { +s32 ObjTokeidai_GetTargetSunMoonPanelRotation(void) { if (gSaveContext.save.isNight) { return 0x8000; } @@ -116,15 +116,15 @@ void ObjTokeidai_Clock_Init(ObjTokeidai* this) { this->sunMoonPanelRotation = ObjTokeidai_GetTargetSunMoonPanelRotation(); } -void ObjTokeidai_ExteriorGear_Init(ObjTokeidai* this, GlobalContext* globalCtx) { +void ObjTokeidai_ExteriorGear_Init(ObjTokeidai* this, PlayState* play) { this->actor.draw = ObjTokeidai_ExteriorGear_Draw; this->opaDList = gClockTowerExteriorGearDL; ObjTokeidai_SetupClockOrExteriorGear(this); - if (((globalCtx->sceneNum == SCENE_CLOCKTOWER) && (gSaveContext.sceneSetupIndex == 2) && - (globalCtx->csCtx.currentCsIndex == 0)) || - ((globalCtx->sceneNum == SCENE_00KEIKOKU) && (gSaveContext.sceneSetupIndex == 2) && - (globalCtx->csCtx.currentCsIndex == 0))) { + if (((play->sceneNum == SCENE_CLOCKTOWER) && (gSaveContext.sceneSetupIndex == 2) && + (play->csCtx.currentCsIndex == 0)) || + ((play->sceneNum == SCENE_00KEIKOKU) && (gSaveContext.sceneSetupIndex == 2) && + (play->csCtx.currentCsIndex == 0))) { ObjTokeidai_SetupTowerOpening(this); } else if ((CURRENT_DAY == 3 && gSaveContext.save.time < CLOCK_TIME(6, 0)) || CURRENT_DAY >= 4) { this->actionFunc = ObjTokeidai_ExteriorGear_OpenedIdle; @@ -136,14 +136,14 @@ void ObjTokeidai_ExteriorGear_Init(ObjTokeidai* this, GlobalContext* globalCtx) } } -void ObjTokeidai_TowerClock_Init(ObjTokeidai* this, GlobalContext* globalCtx) { +void ObjTokeidai_TowerClock_Init(ObjTokeidai* this, PlayState* play) { this->actor.draw = ObjTokeidai_Clock_Draw; ObjTokeidai_Clock_Init(this); - if (((globalCtx->sceneNum == SCENE_CLOCKTOWER) && (gSaveContext.sceneSetupIndex == 2) && - (globalCtx->csCtx.currentCsIndex == 0)) || - ((globalCtx->sceneNum == SCENE_00KEIKOKU) && (gSaveContext.sceneSetupIndex == 2) && - (globalCtx->csCtx.currentCsIndex == 0))) { + if (((play->sceneNum == SCENE_CLOCKTOWER) && (gSaveContext.sceneSetupIndex == 2) && + (play->csCtx.currentCsIndex == 0)) || + ((play->sceneNum == SCENE_00KEIKOKU) && (gSaveContext.sceneSetupIndex == 2) && + (play->csCtx.currentCsIndex == 0))) { ObjTokeidai_SetupTowerOpening(this); } else if ((CURRENT_DAY == 3 && gSaveContext.save.time < CLOCK_TIME(6, 0)) || CURRENT_DAY >= 4) { this->actor.world.pos.y += (this->actor.scale.y * 5191.0f) - 50.0f; @@ -163,7 +163,7 @@ void ObjTokeidai_TowerClock_Init(ObjTokeidai* this, GlobalContext* globalCtx) { } } -void ObjTokeidai_Counterweight_Init(ObjTokeidai* this, GlobalContext* globalCtx) { +void ObjTokeidai_Counterweight_Init(ObjTokeidai* this, PlayState* play) { s32 type; this->actor.draw = ObjTokeidai_Counterweight_Draw; @@ -175,10 +175,10 @@ void ObjTokeidai_Counterweight_Init(ObjTokeidai* this, GlobalContext* globalCtx) this->spotlightIntensity = 0; } - if (((globalCtx->sceneNum == SCENE_CLOCKTOWER) && (gSaveContext.sceneSetupIndex == 2) && - (globalCtx->csCtx.currentCsIndex == 0)) || - ((globalCtx->sceneNum == SCENE_00KEIKOKU) && (gSaveContext.sceneSetupIndex == 2) && - (globalCtx->csCtx.currentCsIndex == 0))) { + if (((play->sceneNum == SCENE_CLOCKTOWER) && (gSaveContext.sceneSetupIndex == 2) && + (play->csCtx.currentCsIndex == 0)) || + ((play->sceneNum == SCENE_00KEIKOKU) && (gSaveContext.sceneSetupIndex == 2) && + (play->csCtx.currentCsIndex == 0))) { this->spotlightIntensity = 0; ObjTokeidai_SetupTowerOpening(this); @@ -186,9 +186,8 @@ void ObjTokeidai_Counterweight_Init(ObjTokeidai* this, GlobalContext* globalCtx) type = OBJ_TOKEIDAI_TYPE(&this->actor); if (type == OBJ_TOKEIDAI_TYPE_COUNTERWEIGHT_CLOCK_TOWN || type == OBJ_TOKEIDAI_TYPE_COUNTERWEIGHT_TERMINA_FIELD) { - this->actor.child = - Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_HANABI, this->actor.world.pos.x, - this->actor.world.pos.y, this->actor.world.pos.z, 0, 0, 0, 0); + this->actor.child = Actor_Spawn(&play->actorCtx, play, ACTOR_EN_HANABI, this->actor.world.pos.x, + this->actor.world.pos.y, this->actor.world.pos.z, 0, 0, 0, 0); } } @@ -211,7 +210,7 @@ void ObjTokeidai_Counterweight_Init(ObjTokeidai* this, GlobalContext* globalCtx) } } -void ObjTokeidai_Init(Actor* thisx, GlobalContext* globalCtx) { +void ObjTokeidai_Init(Actor* thisx, PlayState* play) { ObjTokeidai* this = THIS; Actor_ProcessInitChain(&this->actor, sInitChain); @@ -227,11 +226,11 @@ void ObjTokeidai_Init(Actor* thisx, GlobalContext* globalCtx) { switch (OBJ_TOKEIDAI_TYPE(&this->actor)) { case OBJ_TOKEIDAI_TYPE_EXTERIOR_GEAR_TERMINA_FIELD: Actor_SetScale(&this->actor, 0.15f); - ObjTokeidai_ExteriorGear_Init(this, globalCtx); + ObjTokeidai_ExteriorGear_Init(this, play); break; case OBJ_TOKEIDAI_TYPE_EXTERIOR_GEAR_CLOCK_TOWN: - ObjTokeidai_ExteriorGear_Init(this, globalCtx); + ObjTokeidai_ExteriorGear_Init(this, play); break; case OBJ_TOKEIDAI_TYPE_UNUSED_WALL: @@ -246,11 +245,11 @@ void ObjTokeidai_Init(Actor* thisx, GlobalContext* globalCtx) { case OBJ_TOKEIDAI_TYPE_TOWER_CLOCK_TERMINA_FIELD: Actor_SetScale(&this->actor, 0.15f); - ObjTokeidai_TowerClock_Init(this, globalCtx); + ObjTokeidai_TowerClock_Init(this, play); break; case OBJ_TOKEIDAI_TYPE_TOWER_CLOCK_CLOCK_TOWN: - ObjTokeidai_TowerClock_Init(this, globalCtx); + ObjTokeidai_TowerClock_Init(this, play); break; case OBJ_TOKEIDAI_TYPE_WALL_CLOCK: @@ -269,11 +268,11 @@ void ObjTokeidai_Init(Actor* thisx, GlobalContext* globalCtx) { case OBJ_TOKEIDAI_TYPE_COUNTERWEIGHT_TERMINA_FIELD: Actor_SetScale(&this->actor, 0.15f); - ObjTokeidai_Counterweight_Init(this, globalCtx); + ObjTokeidai_Counterweight_Init(this, play); break; case OBJ_TOKEIDAI_TYPE_COUNTERWEIGHT_CLOCK_TOWN: - ObjTokeidai_Counterweight_Init(this, globalCtx); + ObjTokeidai_Counterweight_Init(this, play); break; case OBJ_TOKEIDAI_TYPE_STAIRCASE_TO_ROOFTOP: @@ -284,7 +283,7 @@ void ObjTokeidai_Init(Actor* thisx, GlobalContext* globalCtx) { } } -void ObjTokeidai_Destroy(Actor* thisx, GlobalContext* globalCtx) { +void ObjTokeidai_Destroy(Actor* thisx, PlayState* play) { } void ObjTokeidai_RotateOnMinuteChange(ObjTokeidai* this, s32 playSfx) { @@ -324,20 +323,20 @@ void ObjTokeidai_RotateOnMinuteChange(ObjTokeidai* this, s32 playSfx) { } } -void ObjTokeidai_ExteriorGear_Collapse(ObjTokeidai* this, GlobalContext* globalCtx) { +void ObjTokeidai_ExteriorGear_Collapse(ObjTokeidai* this, PlayState* play) { if ((this->actor.bgCheckFlags & 1) || this->actor.world.pos.y < 0.0f) { this->actionFunc = ObjTokeidai_DoNothing; } else { this->actor.shape.rot.x += 0x50; this->actor.shape.rot.z += 0x50; Actor_MoveWithGravity(&this->actor); - Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 0.0f, 0.0f, 0.0f, 4); + Actor_UpdateBgCheckInfo(play, &this->actor, 0.0f, 0.0f, 0.0f, 4); } } -void ObjTokeidai_ExteriorGear_OpenedIdle(ObjTokeidai* this, GlobalContext* globalCtx) { - if (Cutscene_CheckActorAction(globalCtx, 132) && - globalCtx->csCtx.actorActions[Cutscene_GetActorActionIndex(globalCtx, 132)]->action == 2) { +void ObjTokeidai_ExteriorGear_OpenedIdle(ObjTokeidai* this, PlayState* play) { + if (Cutscene_CheckActorAction(play, 132) && + play->csCtx.actorActions[Cutscene_GetActorActionIndex(play, 132)]->action == 2) { this->actionFunc = ObjTokeidai_ExteriorGear_Collapse; this->actor.speedXZ = this->actor.scale.y * 5.0f; this->actor.velocity.y = 0.0f; @@ -350,7 +349,7 @@ void ObjTokeidai_ExteriorGear_OpenedIdle(ObjTokeidai* this, GlobalContext* globa * This, used in conjunction with the following function, makes the * tower's clock slide off the tower and spin through the air when the moon crashes. */ -void ObjTokeidai_TowerClock_Fall(ObjTokeidai* this, GlobalContext* globalCtx) { +void ObjTokeidai_TowerClock_Fall(ObjTokeidai* this, PlayState* play) { this->actor.shape.rot.x += this->fallingClockFaceRotationalVelocity; if (this->fallingClockFaceRotationalVelocity > 0xA0) { this->fallingClockFaceRotationalVelocity -= 5; @@ -367,7 +366,7 @@ void ObjTokeidai_TowerClock_Fall(ObjTokeidai* this, GlobalContext* globalCtx) { * This makes the tower's clock slide off as the moon crashes into it. It's * the tower clock's equivalent to other components' Collapse functions. */ -void ObjTokeidai_TowerClock_SlideOff(ObjTokeidai* this, GlobalContext* globalCtx) { +void ObjTokeidai_TowerClock_SlideOff(ObjTokeidai* this, PlayState* play) { f32 cos; f32 sin; Actor* thisx = &this->actor; @@ -403,16 +402,16 @@ void ObjTokeidai_TowerClock_SlideOff(ObjTokeidai* this, GlobalContext* globalCtx thisx->world.pos.z = (1178.0f * sin) + (this->aerialClockFaceSpeed * cos) + thisx->home.pos.z; } -void ObjTokeidai_TowerClock_OpenedIdle(ObjTokeidai* this, GlobalContext* globalCtx) { - if (Cutscene_CheckActorAction(globalCtx, 132) && - globalCtx->csCtx.actorActions[Cutscene_GetActorActionIndex(globalCtx, 132)]->action == 1) { +void ObjTokeidai_TowerClock_OpenedIdle(ObjTokeidai* this, PlayState* play) { + if (Cutscene_CheckActorAction(play, 132) && + play->csCtx.actorActions[Cutscene_GetActorActionIndex(play, 132)]->action == 1) { this->actionFunc = ObjTokeidai_TowerClock_SlideOff; this->slidingClockFaceAngle = 0; this->aerialClockFaceSpeed = -0xD; } } -void ObjTokeidai_Counterweight_Collapse(ObjTokeidai* this, GlobalContext* globalCtx) { +void ObjTokeidai_Counterweight_Collapse(ObjTokeidai* this, PlayState* play) { if (this->actor.world.pos.y < 0.0f) { this->actionFunc = ObjTokeidai_DoNothing; } else { @@ -421,9 +420,9 @@ void ObjTokeidai_Counterweight_Collapse(ObjTokeidai* this, GlobalContext* global } } -void ObjTokeidai_Counterweight_OpenedIdle(ObjTokeidai* this, GlobalContext* globalCtx) { - if (Cutscene_CheckActorAction(globalCtx, 132) && - globalCtx->csCtx.actorActions[Cutscene_GetActorActionIndex(globalCtx, 132)]->action == 3) { +void ObjTokeidai_Counterweight_OpenedIdle(ObjTokeidai* this, PlayState* play) { + if (Cutscene_CheckActorAction(play, 132) && + play->csCtx.actorActions[Cutscene_GetActorActionIndex(play, 132)]->action == 3) { this->actionFunc = ObjTokeidai_Counterweight_Collapse; this->xRotation = 0; this->actor.velocity.y = 0.0f; @@ -432,45 +431,45 @@ void ObjTokeidai_Counterweight_OpenedIdle(ObjTokeidai* this, GlobalContext* glob } } -void ObjTokeidai_TerminaFieldWalls_Collapse(ObjTokeidai* this, GlobalContext* globalCtx) { +void ObjTokeidai_TerminaFieldWalls_Collapse(ObjTokeidai* this, PlayState* play) { if (this->actor.shape.rot.x < 0x4000) { this->actor.shape.rot.x += 0x28; } } -void ObjTokeidai_TerminaFieldWalls_Idle(ObjTokeidai* this, GlobalContext* globalCtx) { - if (Cutscene_CheckActorAction(globalCtx, 132) != 0 && - globalCtx->csCtx.actorActions[Cutscene_GetActorActionIndex(globalCtx, 132)]->action == 1) { +void ObjTokeidai_TerminaFieldWalls_Idle(ObjTokeidai* this, PlayState* play) { + if (Cutscene_CheckActorAction(play, 132) != 0 && + play->csCtx.actorActions[Cutscene_GetActorActionIndex(play, 132)]->action == 1) { this->actionFunc = ObjTokeidai_TerminaFieldWalls_Collapse; } } -void ObjTokeidai_TowerOpening_EndCutscene(ObjTokeidai* this, GlobalContext* globalCtx) { - if (Cutscene_CheckActorAction(globalCtx, 132) != 0 && - globalCtx->csCtx.actorActions[Cutscene_GetActorActionIndex(globalCtx, 132)]->action == 5) { +void ObjTokeidai_TowerOpening_EndCutscene(ObjTokeidai* this, PlayState* play) { + if (Cutscene_CheckActorAction(play, 132) != 0 && + play->csCtx.actorActions[Cutscene_GetActorActionIndex(play, 132)]->action == 5) { gSaveContext.save.weekEventReg[8] |= 0x40; - if (((globalCtx->sceneNum == SCENE_CLOCKTOWER) && (gSaveContext.sceneSetupIndex == 2) && - (globalCtx->csCtx.currentCsIndex == 0)) || - ((globalCtx->sceneNum == SCENE_00KEIKOKU) && (gSaveContext.sceneSetupIndex == 2) && - (globalCtx->csCtx.currentCsIndex == 0))) { + if (((play->sceneNum == SCENE_CLOCKTOWER) && (gSaveContext.sceneSetupIndex == 2) && + (play->csCtx.currentCsIndex == 0)) || + ((play->sceneNum == SCENE_00KEIKOKU) && (gSaveContext.sceneSetupIndex == 2) && + (play->csCtx.currentCsIndex == 0))) { Audio_SetCutsceneFlag(false); gSaveContext.save.cutscene = 0; gSaveContext.nextCutsceneIndex = 0; gSaveContext.respawnFlag = 2; - globalCtx->sceneLoadFlag = 0x14; - globalCtx->nextEntranceIndex = gSaveContext.respawn[RESTART_MODE_RETURN].entranceIndex; - globalCtx->unk_1887F = 2; - if (gSaveContext.respawn[RESTART_MODE_RETURN].playerParams == 0xCFF) { - gSaveContext.nextTransition = 0x15; + play->transitionTrigger = TRANS_TRIGGER_START; + play->nextEntrance = gSaveContext.respawn[RESPAWN_MODE_RETURN].entrance; + play->transitionType = TRANS_TYPE_02; + if (gSaveContext.respawn[RESPAWN_MODE_RETURN].playerParams == 0xCFF) { + gSaveContext.nextTransitionType = TRANS_TYPE_21; } else { - gSaveContext.nextTransition = 2; + gSaveContext.nextTransitionType = TRANS_TYPE_02; } } this->actionFunc = ObjTokeidai_DoNothing; } } -void ObjTokeidai_TowerOpening_FinishOpening(ObjTokeidai* this, GlobalContext* globalCtx) { +void ObjTokeidai_TowerOpening_FinishOpening(ObjTokeidai* this, PlayState* play) { s32 type; if (this->clockFaceZTranslation > -320) { @@ -481,7 +480,7 @@ void ObjTokeidai_TowerOpening_FinishOpening(ObjTokeidai* this, GlobalContext* gl type = OBJ_TOKEIDAI_TYPE(&this->actor); if ((type == OBJ_TOKEIDAI_TYPE_TOWER_CLOCK_CLOCK_TOWN) || (type == OBJ_TOKEIDAI_TYPE_TOWER_CLOCK_TERMINA_FIELD)) { - ObjTokeidai_TowerOpening_EndCutscene(this, globalCtx); + ObjTokeidai_TowerOpening_EndCutscene(this, play); } else { this->actionFunc = ObjTokeidai_DoNothing; if (this->actor.child != NULL) { @@ -491,7 +490,7 @@ void ObjTokeidai_TowerOpening_FinishOpening(ObjTokeidai* this, GlobalContext* gl } } -void ObjTokeidai_TowerOpening_Wait(ObjTokeidai* this, GlobalContext* globalCtx) { +void ObjTokeidai_TowerOpening_Wait(ObjTokeidai* this, PlayState* play) { if (this->openingWaitTimer > 0) { this->openingWaitTimer--; } else { @@ -500,7 +499,7 @@ void ObjTokeidai_TowerOpening_Wait(ObjTokeidai* this, GlobalContext* globalCtx) } } -void ObjTokeidai_TowerOpening_DropCounterweight(ObjTokeidai* this, GlobalContext* globalCtx) { +void ObjTokeidai_TowerOpening_DropCounterweight(ObjTokeidai* this, PlayState* play) { this->xRotation += this->counterweightRotationalVelocity; if (this->xRotation < 0x4000) { this->counterweightRotationalVelocity += this->counterweightRotationalAcceleration; @@ -540,7 +539,7 @@ void ObjTokeidai_TowerOpening_DropCounterweight(ObjTokeidai* this, GlobalContext } } -void ObjTokeidai_TowerOpening_FinishRaise(ObjTokeidai* this, GlobalContext* globalCtx) { +void ObjTokeidai_TowerOpening_FinishRaise(ObjTokeidai* this, PlayState* play) { s32 type; if (this->settleTimer > 0) { @@ -569,7 +568,7 @@ void ObjTokeidai_TowerOpening_FinishRaise(ObjTokeidai* this, GlobalContext* glob } } -void ObjTokeidai_TowerOpening_RaiseTower(ObjTokeidai* this, GlobalContext* globalCtx) { +void ObjTokeidai_TowerOpening_RaiseTower(ObjTokeidai* this, PlayState* play) { s32 type; if (this->yTranslation < 3400) { @@ -592,9 +591,9 @@ void ObjTokeidai_TowerOpening_RaiseTower(ObjTokeidai* this, GlobalContext* globa } } -void ObjTokeidai_TowerOpening_Start(ObjTokeidai* this, GlobalContext* globalCtx) { - if ((Cutscene_CheckActorAction(globalCtx, 132) && - globalCtx->csCtx.actorActions[Cutscene_GetActorActionIndex(globalCtx, 132)]->action == 4) || +void ObjTokeidai_TowerOpening_Start(ObjTokeidai* this, PlayState* play) { + if ((Cutscene_CheckActorAction(play, 132) && + play->csCtx.actorActions[Cutscene_GetActorActionIndex(play, 132)]->action == 4) || (gSaveContext.save.weekEventReg[8] & 0x40)) { this->actionFunc = ObjTokeidai_TowerOpening_RaiseTower; } @@ -613,10 +612,10 @@ void ObjTokeidai_SetupTowerOpening(ObjTokeidai* this) { this->clockFaceZTranslation = 0; } -void ObjTokeidai_DoNothing(ObjTokeidai* this, GlobalContext* globalCtx) { +void ObjTokeidai_DoNothing(ObjTokeidai* this, PlayState* play) { } -void ObjTokeidai_StaircaseToRooftop_Idle(ObjTokeidai* this, GlobalContext* globalCtx) { +void ObjTokeidai_StaircaseToRooftop_Idle(ObjTokeidai* this, PlayState* play) { if (((CURRENT_DAY == 3 && gSaveContext.save.time < CLOCK_TIME(6, 0)) || CURRENT_DAY >= 4) || (gSaveContext.save.weekEventReg[8] & 0x40)) { this->actor.draw = ObjTokeidai_Draw; @@ -625,7 +624,7 @@ void ObjTokeidai_StaircaseToRooftop_Idle(ObjTokeidai* this, GlobalContext* globa } } -s32 ObjTokeidai_IsPostFirstCycleFinalHours(ObjTokeidai* this, GlobalContext* globalCtx) { +s32 ObjTokeidai_IsPostFirstCycleFinalHours(ObjTokeidai* this, PlayState* play) { if (gSaveContext.save.inventory.items[SLOT_OCARINA] == ITEM_NONE) { return false; } @@ -636,7 +635,7 @@ s32 ObjTokeidai_IsPostFirstCycleFinalHours(ObjTokeidai* this, GlobalContext* glo return false; } -void ObjTokeidai_RotateOnHourChange(ObjTokeidai* this, GlobalContext* globalCtx) { +void ObjTokeidai_RotateOnHourChange(ObjTokeidai* this, PlayState* play) { s32 currentClockHour = GET_CURRENT_CLOCK_HOUR(this); if (currentClockHour != this->clockHour) { @@ -689,7 +688,7 @@ void ObjTokeidai_RotateOnHourChange(ObjTokeidai* this, GlobalContext* globalCtx) } } -void ObjTokeidai_TowerClock_Idle(ObjTokeidai* this, GlobalContext* globalCtx) { +void ObjTokeidai_TowerClock_Idle(ObjTokeidai* this, PlayState* play) { if (CURRENT_DAY == 3 && this->clockHour < 6 && gSaveContext.save.time < CLOCK_TIME(6, 0)) { this->actor.draw = ObjTokeidai_Clock_Draw; ObjTokeidai_SetupTowerOpening(this); @@ -697,12 +696,12 @@ void ObjTokeidai_TowerClock_Idle(ObjTokeidai* this, GlobalContext* globalCtx) { return; } - if (globalCtx->csCtx.state != 0) { + if (play->csCtx.state != 0) { this->actor.home.rot.x = 1; this->clockTime += 3; this->actor.draw = ObjTokeidai_Clock_Draw; } else { - if (!(globalCtx->actorCtx.unk5 & 2) && + if (!(play->actorCtx.unk5 & 2) && OBJ_TOKEIDAI_TYPE(&this->actor) == OBJ_TOKEIDAI_TYPE_TOWER_CLOCK_TERMINA_FIELD && ActorCutscene_GetCurrentIndex() == -1) { this->actor.draw = NULL; @@ -717,25 +716,25 @@ void ObjTokeidai_TowerClock_Idle(ObjTokeidai* this, GlobalContext* globalCtx) { if (CURRENT_DAY != 3 || gSaveContext.save.time >= CLOCK_TIME(6, 0)) { ObjTokeidai_RotateOnMinuteChange(this, true); } - ObjTokeidai_RotateOnHourChange(this, globalCtx); + ObjTokeidai_RotateOnHourChange(this, play); } -void ObjTokeidai_WallClock_Idle(ObjTokeidai* this, GlobalContext* globalCtx) { +void ObjTokeidai_WallClock_Idle(ObjTokeidai* this, PlayState* play) { this->clockTime = gSaveContext.save.time; ObjTokeidai_RotateOnMinuteChange(this, true); - ObjTokeidai_RotateOnHourChange(this, globalCtx); + ObjTokeidai_RotateOnHourChange(this, play); } -void ObjTokeidai_ExteriorGear_Idle(ObjTokeidai* this, GlobalContext* globalCtx) { - if (ObjTokeidai_IsPostFirstCycleFinalHours(this, globalCtx)) { +void ObjTokeidai_ExteriorGear_Idle(ObjTokeidai* this, PlayState* play) { + if (ObjTokeidai_IsPostFirstCycleFinalHours(this, play)) { this->actor.draw = ObjTokeidai_ExteriorGear_Draw; } else { - if (globalCtx->csCtx.state != 0) { + if (play->csCtx.state != 0) { this->actor.home.rot.x = 1; this->clockTime += 3; this->actor.draw = ObjTokeidai_ExteriorGear_Draw; } else { - if ((globalCtx->actorCtx.unk5 & 2) == 0 && + if ((play->actorCtx.unk5 & 2) == 0 && OBJ_TOKEIDAI_TYPE(&this->actor) == OBJ_TOKEIDAI_TYPE_EXTERIOR_GEAR_TERMINA_FIELD && ActorCutscene_GetCurrentIndex() == -1) { this->actor.draw = NULL; @@ -750,19 +749,18 @@ void ObjTokeidai_ExteriorGear_Idle(ObjTokeidai* this, GlobalContext* globalCtx) } } -void ObjTokeidai_Counterweight_Idle(ObjTokeidai* this, GlobalContext* globalCtx) { +void ObjTokeidai_Counterweight_Idle(ObjTokeidai* this, PlayState* play) { s32 type; - if (ObjTokeidai_IsPostFirstCycleFinalHours(this, globalCtx)) { + if (ObjTokeidai_IsPostFirstCycleFinalHours(this, play)) { this->spotlightIntensity = 0; if (this->actor.child == NULL) { type = OBJ_TOKEIDAI_TYPE(&this->actor); if (type == OBJ_TOKEIDAI_TYPE_COUNTERWEIGHT_CLOCK_TOWN || type == OBJ_TOKEIDAI_TYPE_COUNTERWEIGHT_TERMINA_FIELD) { - this->actor.child = - Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_HANABI, this->actor.world.pos.x, - this->actor.world.pos.y, this->actor.world.pos.z, 0, 0, 0, 0); + this->actor.child = Actor_Spawn(&play->actorCtx, play, ACTOR_EN_HANABI, this->actor.world.pos.x, + this->actor.world.pos.y, this->actor.world.pos.z, 0, 0, 0, 0); } } @@ -785,57 +783,57 @@ void ObjTokeidai_Counterweight_Idle(ObjTokeidai* this, GlobalContext* globalCtx) } } -void ObjTokeidai_Update(Actor* thisx, GlobalContext* globalCtx) { +void ObjTokeidai_Update(Actor* thisx, PlayState* play) { ObjTokeidai* this = THIS; - this->actionFunc(this, globalCtx); + this->actionFunc(this, play); } /** * Used for TerminaFieldWalls StaircaseToRooftop, and UnusedWall */ -void ObjTokeidai_Draw(Actor* thisx, GlobalContext* globalCtx) { +void ObjTokeidai_Draw(Actor* thisx, PlayState* play) { ObjTokeidai* this = THIS; - OPEN_DISPS(globalCtx->state.gfxCtx); + OPEN_DISPS(play->state.gfxCtx); if (this->opaDList != NULL) { - gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - func_8012C28C(globalCtx->state.gfxCtx); + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + func_8012C28C(play->state.gfxCtx); gSPDisplayList(POLY_OPA_DISP++, this->opaDList); } if (this->xluDList != NULL) { - gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - func_8012C2DC(globalCtx->state.gfxCtx); + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + func_8012C2DC(play->state.gfxCtx); gSPDisplayList(POLY_XLU_DISP++, this->xluDList); } - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->state.gfxCtx); } -void ObjTokeidai_Clock_Draw(Actor* thisx, GlobalContext* globalCtx) { +void ObjTokeidai_Clock_Draw(Actor* thisx, PlayState* play) { ObjTokeidai* this = THIS; - OPEN_DISPS(globalCtx->state.gfxCtx); + OPEN_DISPS(play->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); + func_8012C28C(play->state.gfxCtx); + 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); - gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + Matrix_Push(); + Matrix_RotateZS(-this->minuteRingOrExteriorGearRotation, MTXMODE_APPLY); + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(play->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); - gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + Matrix_Translate(0.0f, 0.0f, this->clockFaceZTranslation, MTXMODE_APPLY); + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_OPA_DISP++, gClockTowerClockCenterAndHandDL); - Matrix_InsertZRotation_s(-this->clockFaceRotation * 2, MTXMODE_APPLY); - gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + Matrix_RotateZS(-this->clockFaceRotation * 2, MTXMODE_APPLY); + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); if (OBJ_TOKEIDAI_TYPE(&this->actor) == OBJ_TOKEIDAI_TYPE_WALL_CLOCK || OBJ_TOKEIDAI_TYPE(&this->actor) == OBJ_TOKEIDAI_TYPE_SMALL_WALL_CLOCK) { gSPDisplayList(POLY_OPA_DISP++, gWallClockClockFace); @@ -843,61 +841,61 @@ 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); - gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + Matrix_Translate(0.0f, -1112.0f, -19.6f, MTXMODE_APPLY); + Matrix_RotateYS(this->sunMoonPanelRotation, MTXMODE_APPLY); + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_OPA_DISP++, gClockTowerSunAndMoonPanelDL); - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->state.gfxCtx); } -void ObjTokeidai_Counterweight_Draw(Actor* thisx, GlobalContext* globalCtx) { +void ObjTokeidai_Counterweight_Draw(Actor* thisx, PlayState* play) { s32 pad; - u32 gameplayFrames = globalCtx->gameplayFrames; + u32 gameplayFrames = play->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); + OPEN_DISPS(play->state.gfxCtx); // For scrolling the spotlight's mask texture down the length of the light beam. gSPSegment(POLY_XLU_DISP++, 0x08, - Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, 0, 0, 0x20, 0x40, 1, -gameplayFrames, 0, 0x20, 0x20)); + Gfx_TwoTexScroll(play->state.gfxCtx, 0, 0, 0, 0x20, 0x40, 1, -gameplayFrames, 0, 0x20, 0x20)); // Draws the counterweight - gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - func_8012C28C(globalCtx->state.gfxCtx); + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + func_8012C28C(play->state.gfxCtx); gSPDisplayList(POLY_OPA_DISP++, this->opaDList); // Draws the spotlight - gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - func_8012C2DC(globalCtx->state.gfxCtx); + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + func_8012C2DC(play->state.gfxCtx); gDPSetPrimColor(POLY_XLU_DISP++, 0, 255, 255, 235, 180, (s32)(this->spotlightIntensity * 2.55f)); gSPDisplayList(POLY_XLU_DISP++, this->xluDList); - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->state.gfxCtx); } -void ObjTokeidai_ExteriorGear_Draw(Actor* thisx, GlobalContext* globalCtx) { +void ObjTokeidai_ExteriorGear_Draw(Actor* thisx, PlayState* play) { ObjTokeidai* this = THIS; - OPEN_DISPS(globalCtx->state.gfxCtx); + OPEN_DISPS(play->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); - gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - func_8012C28C(globalCtx->state.gfxCtx); + 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(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + func_8012C28C(play->state.gfxCtx); gSPDisplayList(POLY_OPA_DISP++, gClockTowerExteriorGearDL); - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->state.gfxCtx); } diff --git a/src/overlays/actors/ovl_Obj_Tokeidai/z_obj_tokeidai.h b/src/overlays/actors/ovl_Obj_Tokeidai/z_obj_tokeidai.h index 48e44614d..70ef31c79 100644 --- a/src/overlays/actors/ovl_Obj_Tokeidai/z_obj_tokeidai.h +++ b/src/overlays/actors/ovl_Obj_Tokeidai/z_obj_tokeidai.h @@ -21,7 +21,7 @@ typedef enum { struct ObjTokeidai; -typedef void (*ObjTokeidaiActionFunc)(struct ObjTokeidai*, GlobalContext*); +typedef void (*ObjTokeidaiActionFunc)(struct ObjTokeidai*, PlayState*); typedef struct ObjTokeidai { /* 0x000 */ Actor actor; 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 b91cbcf7e..4a71acc95 100644 --- a/src/overlays/actors/ovl_Obj_Toudai/z_obj_toudai.c +++ b/src/overlays/actors/ovl_Obj_Toudai/z_obj_toudai.c @@ -5,17 +5,17 @@ */ #include "z_obj_toudai.h" +#include "objects/object_f53_obj/object_f53_obj.h" #define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_20) #define THIS ((ObjToudai*)thisx) -void ObjToudai_Init(Actor* thisx, GlobalContext* globalCtx); -void ObjToudai_Destroy(Actor* thisx, GlobalContext* globalCtx); -void ObjToudai_Update(Actor* thisx, GlobalContext* globalCtx); -void ObjToudai_Draw(Actor* thisx, GlobalContext* globalCtx); +void ObjToudai_Init(Actor* thisx, PlayState* play); +void ObjToudai_Destroy(Actor* thisx, PlayState* play); +void ObjToudai_Update(Actor* thisx, PlayState* play); +void ObjToudai_Draw(Actor* thisx, PlayState* play); -#if 0 const ActorInit Obj_Toudai_InitVars = { ACTOR_OBJ_TOUDAI, ACTORCAT_PROP, @@ -28,21 +28,102 @@ const ActorInit Obj_Toudai_InitVars = { (ActorFunc)ObjToudai_Draw, }; -#endif +#include "assets/overlays/ovl_Obj_Toudai/ovl_Obj_Toudai.c" -extern UNK_TYPE D_060023B0; -extern UNK_TYPE D_060024E8; +void func_80A33B00(ObjToudai* this, PlayState* play) { + Matrix_Translate(this->actor.world.pos.x, this->actor.world.pos.y, this->actor.world.pos.z, MTXMODE_NEW); + Matrix_Scale(0.1f, 0.1f, 0.1f, MTXMODE_APPLY); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Toudai/func_80A33B00.s") + OPEN_DISPS(play->state.gfxCtx); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Toudai/func_80A33BB4.s") + func_8012C28C(play->state.gfxCtx); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Toudai/func_80A342F4.s") + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_OPA_DISP++, object_f53_obj_DL_0024E8); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Toudai/ObjToudai_Init.s") + CLOSE_DISPS(play->state.gfxCtx); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Toudai/ObjToudai_Destroy.s") +void func_80A33BB4(ObjToudai* this, PlayState* play) { + u8 sp57; + u8 sp56; + s32 i; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Toudai/ObjToudai_Update.s") + this->unk_22C += 1.8f; + this->unk_230 += 0.6f; + sp57 = this->unk_22C; + sp56 = this->unk_230; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Toudai/ObjToudai_Draw.s") + this->unk_228 = CLAMP(this->unk_228, 0.0f, 1.0f); + + for (i = 0; i < ARRAY_COUNT(ovl_Obj_Toudai_Vtx_D_80A34590); i++) { + this->unk_148[i].v.cn[3] = ovl_Obj_Toudai_Vtx_D_80A34590[i].v.cn[3] * this->unk_228; + } + + if (this->unk_228 > 0.0f) { + Matrix_Translate(this->actor.world.pos.x, this->actor.world.pos.y, this->actor.world.pos.z, MTXMODE_NEW); + Matrix_RotateYS(this->actor.shape.rot.y, MTXMODE_APPLY); + Matrix_Scale(0.1f, 0.1f, 0.1f, MTXMODE_APPLY); + + OPEN_DISPS(play->state.gfxCtx); + + func_8012C28C(play->state.gfxCtx); + + gSPSegment(POLY_XLU_DISP++, 0x08, + Gfx_TwoTexScroll(play->state.gfxCtx, 0, 0, sp57, 0x20, 0x80, 1, 0, sp56, 0x20, 0x20)); + gSPSegment(POLY_XLU_DISP++, 0x09, Lib_SegmentedToVirtual(this->unk_148)); + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_XLU_DISP++, object_f53_obj_DL_0023B0); + + CLOSE_DISPS(play->state.gfxCtx); + } +} + +u8 func_80A342F4(s16 arg0) { + u8 var_v1 = 0; + s16 minutes = TIME_TO_MINUTES_F(gSaveContext.save.time); + s32 hours = minutes / 60; + + if (hours >= 17) { + if ((hours == 17) && ((minutes % 60) < arg0)) { + return var_v1; + } + var_v1 = 2; + } else if (hours < 6) { + if ((hours == 5) && ((minutes % 60) < arg0)) { + return var_v1; + } + var_v1 = 1; + } + return var_v1; +} + +void ObjToudai_Init(Actor* thisx, PlayState* play) { + ObjToudai* this = THIS; + + Lib_MemCpy(this->unk_148, &ovl_Obj_Toudai_Vtx_D_80A34590, sizeof(ovl_Obj_Toudai_Vtx_D_80A34590)); +} + +void ObjToudai_Destroy(Actor* thisx, PlayState* play) { +} + +void ObjToudai_Update(Actor* thisx, PlayState* play) { + ObjToudai* this = THIS; + u8 temp_v0 = func_80A342F4(this->unk_238); + + if (temp_v0 != this->unk_236) { + this->unk_236 = temp_v0; + this->unk_238 = Rand_S16Offset(0, 50); + } + + Math_ApproachF(&this->unk_228, (this->unk_236 == 0) ? 0.0f : 1.0f, 0.01f, 1000.0f); + this->unk_234 += 100; + thisx->shape.rot.y = (s16)(Math_SinS(this->unk_234) * 16000.0f) + thisx->world.rot.y; +} + +void ObjToudai_Draw(Actor* thisx, PlayState* play) { + ObjToudai* this = THIS; + + func_80A33B00(this, play); + func_80A33BB4(this, play); +} diff --git a/src/overlays/actors/ovl_Obj_Toudai/z_obj_toudai.h b/src/overlays/actors/ovl_Obj_Toudai/z_obj_toudai.h index ca28dc786..c1af4d733 100644 --- a/src/overlays/actors/ovl_Obj_Toudai/z_obj_toudai.h +++ b/src/overlays/actors/ovl_Obj_Toudai/z_obj_toudai.h @@ -7,8 +7,16 @@ struct ObjToudai; typedef struct ObjToudai { /* 0x000 */ Actor actor; - /* 0x144 */ char unk_144[0xFC]; -} ObjToudai; // size = 0x240 + /* 0x144 */ UNK_TYPE1 pad144[4]; + /* 0x148 */ Vtx unk_148[14]; + /* 0x228 */ f32 unk_228; + /* 0x22C */ f32 unk_22C; + /* 0x230 */ f32 unk_230; + /* 0x234 */ s16 unk_234; + /* 0x236 */ u8 unk_236; + /* 0x238 */ s16 unk_238; + /* 0x23A */ UNK_TYPE1 pad23A[6]; +} ObjToudai;// size = 0x240 extern const ActorInit Obj_Toudai_InitVars; diff --git a/src/overlays/actors/ovl_Obj_Tree/z_obj_tree.c b/src/overlays/actors/ovl_Obj_Tree/z_obj_tree.c index e19edead3..ef55e5ab7 100644 --- a/src/overlays/actors/ovl_Obj_Tree/z_obj_tree.c +++ b/src/overlays/actors/ovl_Obj_Tree/z_obj_tree.c @@ -11,14 +11,14 @@ #define THIS ((ObjTree*)thisx) -void ObjTree_Init(Actor* thisx, GlobalContext* globalCtx); -void ObjTree_Destroy(Actor* thisx, GlobalContext* globalCtx); -void ObjTree_Update(Actor* thisx, GlobalContext* globalCtx); -void ObjTree_Draw(Actor* thisx, GlobalContext* globalCtx); +void ObjTree_Init(Actor* thisx, PlayState* play); +void ObjTree_Destroy(Actor* thisx, PlayState* play); +void ObjTree_Update(Actor* thisx, PlayState* play); +void ObjTree_Draw(Actor* thisx, PlayState* play); -void ObTree_DoNothing(ObjTree* this, GlobalContext* globalCtx); -void ObTree_SetupDoNothing(ObjTree* this); -void ObTree_Sway(ObjTree* this, GlobalContext* globalCtx); +void ObjTree_DoNothing(ObjTree* this, PlayState* play); +void ObjTree_SetupDoNothing(ObjTree* this); +void ObjTree_Sway(ObjTree* this, PlayState* play); const ActorInit Obj_Tree_InitVars = { ACTOR_OBJ_TREE, @@ -89,7 +89,7 @@ static DamageTable sDamageTable = { static CollisionCheckInfoInit2 sColchkInfoInit = { 8, 0, 0, 0, MASS_HEAVY }; -void ObjTree_Init(Actor* thisx, GlobalContext* globalCtx) { +void ObjTree_Init(Actor* thisx, PlayState* play) { s32 pad; ObjTree* this = THIS; CollisionHeader* colHeader = NULL; @@ -101,11 +101,11 @@ void ObjTree_Init(Actor* thisx, GlobalContext* globalCtx) { Actor_SetScale(&this->dyna.actor, 0.1f); DynaPolyActor_Init(&this->dyna, 1); CollisionHeader_GetVirtual(&object_tree_Colheader_001B2C, &colHeader); - this->dyna.bgId = DynaPoly_SetBgActor(globalCtx, &globalCtx->colCtx.dyna, &this->dyna.actor, colHeader); + this->dyna.bgId = DynaPoly_SetBgActor(play, &play->colCtx.dyna, &this->dyna.actor, colHeader); } - Collider_InitCylinder(globalCtx, &this->collider); - Collider_SetCylinder(globalCtx, &this->collider, &this->dyna.actor, &sCylinderInit); + Collider_InitCylinder(play, &this->collider); + Collider_SetCylinder(play, &this->collider, &this->dyna.actor, &sCylinderInit); CollisionCheck_SetInfo2(&this->dyna.actor.colChkInfo, &sDamageTable, &sColchkInfoInit); if (OBJTREE_ISLARGE(&this->dyna.actor)) { @@ -115,39 +115,39 @@ void ObjTree_Init(Actor* thisx, GlobalContext* globalCtx) { this->swayAmplitude = 0.0f; this->swayAngle = 0; this->swayVelocity = 0; - ObTree_SetupDoNothing(this); + ObjTree_SetupDoNothing(this); } -void ObjTree_Destroy(Actor* thisx, GlobalContext* globalCtx) { +void ObjTree_Destroy(Actor* thisx, PlayState* play) { ObjTree* this = THIS; s32 bgId; if (!OBJTREE_ISLARGE(&this->dyna.actor)) { bgId = this->dyna.bgId; - DynaPoly_DeleteBgActor(globalCtx, &globalCtx->colCtx.dyna, bgId); + DynaPoly_DeleteBgActor(play, &play->colCtx.dyna, bgId); } - Collider_DestroyCylinder(globalCtx, &this->collider); + Collider_DestroyCylinder(play, &this->collider); } -void ObTree_SetupDoNothing(ObjTree* this) { - this->actionFunc = ObTree_DoNothing; +void ObjTree_SetupDoNothing(ObjTree* this) { + this->actionFunc = ObjTree_DoNothing; } -void ObTree_DoNothing(ObjTree* this, GlobalContext* globalCtx) { +void ObjTree_DoNothing(ObjTree* this, PlayState* play) { } -void ObTree_SetupSway(ObjTree* this) { +void ObjTree_SetupSway(ObjTree* this) { this->timer = 0; this->swayAmplitude = 546.0f; this->swayVelocity = 35 * 0x10000 / 360; Actor_PlaySfxAtPos(&this->dyna.actor, NA_SE_EV_TREE_SWING); - this->actionFunc = ObTree_Sway; + this->actionFunc = ObjTree_Sway; } -void ObTree_Sway(ObjTree* this, GlobalContext* globalCtx) { +void ObjTree_Sway(ObjTree* this, PlayState* play) { if (this->timer > 80) { - ObTree_SetupDoNothing(this); + ObjTree_SetupDoNothing(this); return; } @@ -159,39 +159,39 @@ void ObTree_Sway(ObjTree* this, GlobalContext* globalCtx) { this->timer++; } -void ObTree_UpdateCollision(ObjTree* this, GlobalContext* globalCtx) { +void ObjTree_UpdateCollision(ObjTree* this, PlayState* play) { Collider_UpdateCylinder(&this->dyna.actor, &this->collider); - CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + CollisionCheck_SetOC(play, &play->colChkCtx, &this->collider.base); if (this->dyna.actor.xzDistToPlayer < 600.0f) { - CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + CollisionCheck_SetAC(play, &play->colChkCtx, &this->collider.base); if (this->dyna.actor.home.rot.y == 1) { this->dyna.actor.home.rot.y = 0; - ObTree_SetupSway(this); + ObjTree_SetupSway(this); } } } -void ObjTree_Update(Actor* thisx, GlobalContext* globalCtx) { +void ObjTree_Update(Actor* thisx, PlayState* play) { ObjTree* this = THIS; - this->actionFunc(this, globalCtx); - ObTree_UpdateCollision(this, globalCtx); + this->actionFunc(this, play); + ObjTree_UpdateCollision(this, play); } -void ObjTree_Draw(Actor* thisx, GlobalContext* globalCtx) { +void ObjTree_Draw(Actor* thisx, PlayState* play) { s16 xRot = (f32)thisx->shape.rot.x; s16 zRot = (f32)thisx->shape.rot.z; - OPEN_DISPS(globalCtx->state.gfxCtx); + OPEN_DISPS(play->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); + func_8012C28C(play->state.gfxCtx); + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_OPA_DISP++, object_tree_DL_000680); - Matrix_InsertRotation(xRot, 0, zRot, MTXMODE_APPLY); - gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + Matrix_RotateZYX(xRot, 0, zRot, MTXMODE_APPLY); + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_OPA_DISP++, object_tree_DL_0007C8); - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->state.gfxCtx); } diff --git a/src/overlays/actors/ovl_Obj_Tree/z_obj_tree.h b/src/overlays/actors/ovl_Obj_Tree/z_obj_tree.h index b50e3eb40..828530ab3 100644 --- a/src/overlays/actors/ovl_Obj_Tree/z_obj_tree.h +++ b/src/overlays/actors/ovl_Obj_Tree/z_obj_tree.h @@ -5,7 +5,7 @@ struct ObjTree; -typedef void (*ObjTreeActionFunc)(struct ObjTree*, GlobalContext*); +typedef void (*ObjTreeActionFunc)(struct ObjTree*, PlayState*); #define OBJTREE_ISLARGE(thisx) ((thisx)->params & 0x8000) 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 af00e5c64..c2cc74a82 100644 --- a/src/overlays/actors/ovl_Obj_Tsubo/z_obj_tsubo.c +++ b/src/overlays/actors/ovl_Obj_Tsubo/z_obj_tsubo.c @@ -5,22 +5,42 @@ */ #include "z_obj_tsubo.h" +#include "overlays/actors/ovl_En_Sw/z_en_sw.h" +#include "objects/gameplay_dangeon_keep/gameplay_dangeon_keep.h" +#include "objects/object_tsubo/object_tsubo.h" +#include "objects/object_racetsubo/object_racetsubo.h" #define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_800000 | ACTOR_FLAG_4000000) #define THIS ((ObjTsubo*)thisx) -void ObjTsubo_Init(Actor* thisx, GlobalContext* globalCtx); -void ObjTsubo_Destroy(Actor* thisx, GlobalContext* globalCtx); -void ObjTsubo_Update(Actor* thisx, GlobalContext* globalCtx); +void ObjTsubo_Init(Actor* thisx, PlayState* play); +void ObjTsubo_Destroy(Actor* thisx, PlayState* play); +void ObjTsubo_Update(Actor* thisx, PlayState* play); +void ObjTsubo_Draw(Actor* thisx, PlayState* play); -void func_80928928(ObjTsubo* this, GlobalContext* globalCtx); -void func_809289E4(ObjTsubo* this, GlobalContext* globalCtx); -void func_80928D80(ObjTsubo* this, GlobalContext* globalCtx); -void func_80928F18(ObjTsubo* this, GlobalContext* globalCtx); -void func_8092926C(ObjTsubo* this, GlobalContext* globalCtx); +void ObjTsubo_PotBreak1(ObjTsubo* this, PlayState* play); +void ObjTsubo_RacePotBreak1(ObjTsubo* this, PlayState* play); +void ObjTsubo_PotBreak2(ObjTsubo* this, PlayState* play2); +void ObjTsubo_RacePotBreak2(ObjTsubo* this, PlayState* play2); +void ObjTsubo_PotBreak3(ObjTsubo* this, PlayState* play2); +void ObjTsubo_RacePotBreak3(ObjTsubo* this, PlayState* play2); +void func_80928914(ObjTsubo* this); +void func_80928928(ObjTsubo* this, PlayState* play); +void func_809289B4(ObjTsubo* this); +void func_809289E4(ObjTsubo* this, PlayState* play); +void func_80928D6C(ObjTsubo* this); +void func_80928D80(ObjTsubo* this, PlayState* play); +void func_80928E74(ObjTsubo* this); +void func_80928F18(ObjTsubo* this, PlayState* play); +void func_809291DC(ObjTsubo* this); +void func_8092926C(ObjTsubo* this, PlayState* play); + +s16 D_80929500 = 0; +s16 D_80929504 = 0; +s16 D_80929508 = 0; +s16 D_8092950C = 0; -#if 0 const ActorInit Obj_Tsubo_InitVars = { ACTOR_OBJ_TSUBO, ACTORCAT_PROP, @@ -33,79 +53,638 @@ const ActorInit Obj_Tsubo_InitVars = { (ActorFunc)NULL, }; -// static ColliderCylinderInit sCylinderInit = { -static ColliderCylinderInit D_809295B0 = { - { COLTYPE_HARD, AT_ON | AT_TYPE_PLAYER, AC_ON | AC_TYPE_PLAYER, OC1_ON | OC1_TYPE_ALL, OC2_TYPE_2, COLSHAPE_CYLINDER, }, - { ELEMTYPE_UNK0, { 0x00400000, 0x00, 0x02 }, { 0x05CBFFBE, 0x00, 0x00 }, TOUCH_ON | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_ON, }, +typedef struct { + /* 0x00 */ s16 objId; + /* 0x04 */ f32 scale; + /* 0x08 */ Gfx* modelDL; + /* 0x0C */ Gfx* shardDL; + /* 0x10 */ s16 radius; + /* 0x12 */ s16 height; + /* 0x14 */ ObjTsuboUnkFunc breakPot1; + /* 0x18 */ ObjTsuboUnkFunc breakPot2; + /* 0x1C */ ObjTsuboUnkFunc breakPot3; + +} ObjTsuboData; + +ObjTsuboData sPotTypeData[4] = { + { GAMEPLAY_DANGEON_KEEP, 0.197f, gameplay_dangeon_keep_DL_017EA0, gameplay_dangeon_keep_DL_018090, 12, 32, + ObjTsubo_PotBreak1, ObjTsubo_PotBreak2, ObjTsubo_PotBreak3 }, + { OBJECT_RACETSUBO, 0.29549998f, object_racetsubo_DL_000278, object_racetsubo_DL_001610, 18, 45, + ObjTsubo_RacePotBreak1, ObjTsubo_RacePotBreak2, ObjTsubo_RacePotBreak3 }, + { OBJECT_TSUBO, 0.197f, object_tsubo_DL_0017C0, object_tsubo_DL_001960, 12, 32, ObjTsubo_PotBreak1, + ObjTsubo_PotBreak2, ObjTsubo_PotBreak3 }, + { GAMEPLAY_DANGEON_KEEP, 0.197f, gameplay_dangeon_keep_DL_017EA0, gameplay_dangeon_keep_DL_018090, 12, 32, + ObjTsubo_PotBreak1, ObjTsubo_PotBreak2, ObjTsubo_PotBreak3 }, +}; + +static ColliderCylinderInit sCylinderInit = { + { + COLTYPE_HARD, + AT_ON | AT_TYPE_PLAYER, + AC_ON | AC_TYPE_PLAYER, + OC1_ON | OC1_TYPE_ALL, + OC2_TYPE_2, + COLSHAPE_CYLINDER, + }, + { + ELEMTYPE_UNK0, + { 0x00400000, 0x00, 0x02 }, + { 0x05CBFFBE, 0x00, 0x00 }, + TOUCH_ON | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_ON, + }, { 12, 30, 0, { 0, 0, 0 } }, }; -// static InitChainEntry sInitChain[] = { -static InitChainEntry D_809295DC[] = { - ICHAIN_F32_DIV1000(gravity, -2000, ICHAIN_CONTINUE), - ICHAIN_F32_DIV1000(terminalVelocity, -20000, ICHAIN_CONTINUE), - ICHAIN_F32(uncullZoneForward, 4000, ICHAIN_CONTINUE), - ICHAIN_F32(uncullZoneScale, 100, ICHAIN_CONTINUE), +static InitChainEntry sInitChain[] = { + ICHAIN_F32_DIV1000(gravity, -2000, ICHAIN_CONTINUE), ICHAIN_F32_DIV1000(terminalVelocity, -20000, ICHAIN_CONTINUE), + ICHAIN_F32(uncullZoneForward, 4000, ICHAIN_CONTINUE), ICHAIN_F32(uncullZoneScale, 100, ICHAIN_CONTINUE), ICHAIN_F32(uncullZoneDownward, 100, ICHAIN_STOP), }; -#endif +s32 func_809275C0(ObjTsubo* this, PlayState* play) { + s32 chestFlag = -1; + s32 skulltulaParams = (OBJ_TSUBO_P001F(&this->actor) << 2) | 0xFF01; -extern ColliderCylinderInit D_809295B0; -extern InitChainEntry D_809295DC[]; + if (ENSW_GETS_3(skulltulaParams)) { + chestFlag = ENSW_GETS_3FC(skulltulaParams); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Tsubo/func_809275C0.s") + return (chestFlag < 0) == true || !Flags_GetTreasure(play, chestFlag); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Tsubo/func_8092762C.s") +void func_8092762C(ObjTsubo* this, PlayState* play) { + if (!OBJ_TSUBO_P0010(&this->actor) && (OBJ_TSUBO_ZROT(&this->actor) != 2)) { + Item_DropCollectibleRandom(play, NULL, &this->actor.world.pos, OBJ_TSUBO_P000F(&this->actor) << 4); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Tsubo/func_80927690.s") +void func_80927690(ObjTsubo* this, PlayState* play) { + s32 itemDrop; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Tsubo/func_80927714.s") + if (!this->unk_197 && (OBJ_TSUBO_ZROT(&this->actor) != 2)) { + itemDrop = func_800A8150(OBJ_TSUBO_P003F(&this->actor)); + if (itemDrop > ITEM00_NO_DROP) { + Item_DropCollectible(play, &this->actor.world.pos, (OBJ_TSUBO_PFE00(&this->actor) << 8) | itemDrop); + this->unk_197 = true; + } + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Tsubo/func_8092776C.s") +void ObjTsubo_SpawnBoes(ObjTsubo* this, PlayState* play, s32 arg2) { + Actor_Spawn(&play->actorCtx, play, ACTOR_EN_MKK, this->actor.world.pos.x, this->actor.world.pos.y, + this->actor.world.pos.z, 0, 0, 0, 2); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Tsubo/func_80927818.s") +void ObjTsubo_SpawnGoldSkulltula(ObjTsubo* this, PlayState* play, s32 arg2) { + Actor* child; + s32 params; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Tsubo/func_80927864.s") + if (func_809275C0(this, play)) { + params = (OBJ_TSUBO_P001F(&this->actor) << 2) | 0xFF01; + child = Actor_Spawn(&play->actorCtx, play, ACTOR_EN_SW, this->actor.world.pos.x, this->actor.world.pos.y, + this->actor.world.pos.z, 0, Rand_Next() >> 0x10, 0, params); + if (child != NULL) { + child->parent = &this->actor; + child->velocity.y = 0.0f; + child->speedXZ = 0.0f; + } + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Tsubo/func_8092788C.s") +void func_80927818(ObjTsubo* this, PlayState* play, s32 arg2) { + if (OBJ_TSUBO_ZROT(&this->actor) == 1) { + ObjTsubo_SpawnBoes(this, play, arg2); + } else if (OBJ_TSUBO_ZROT(&this->actor) == 2) { + ObjTsubo_SpawnGoldSkulltula(this, play, arg2); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Tsubo/ObjTsubo_Init.s") +s32 ObjTsubo_IsSceneNotGohtOrTwinmold(ObjTsubo* this, PlayState* play) { + return (play->sceneNum != SCENE_HAKUGIN_BS) && (play->sceneNum != SCENE_INISIE_BS); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Tsubo/ObjTsubo_Destroy.s") +void func_8092788C(ObjTsubo* this, PlayState* play) { + if (!this->unk_197 && (play->roomCtx.currRoom.num != this->homeRoom)) { + this->unk_197 = true; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Tsubo/func_80927A78.s") +void ObjTsubo_Init(Actor* thisx, PlayState* play) { + ObjTsubo* this = (ObjTsubo*)thisx; + s32 pad; + s32 type = OBJ_TSUBO_GET_TYPE(&this->actor); + s32 pad2; + s32 sp2C = OBJ_TSUBO_ZROT(&this->actor); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Tsubo/func_80927D2C.s") + Actor_ProcessInitChain(&this->actor, sInitChain); + Actor_SetScale(&this->actor, sPotTypeData[type].scale); + this->actor.shape.rot.z = 0; + this->actor.world.rot.z = 0; + Collider_InitCylinder(play, &this->cylinderCollider); + Collider_SetCylinder(play, &this->cylinderCollider, &this->actor, &sCylinderInit); + Collider_UpdateCylinder(&this->actor, &this->cylinderCollider); + this->cylinderCollider.dim.radius = sPotTypeData[type].radius; + this->cylinderCollider.dim.height = sPotTypeData[type].height; + this->actor.colChkInfo.mass = MASS_IMMOVABLE; + this->objBankIndex = Object_GetIndex(&play->objectCtx, sPotTypeData[type].objId); + if (this->objBankIndex < 0) { + Actor_MarkForDeath(&this->actor); + } else { + this->actor.shape.shadowScale = 1.8f; + this->homeRoom = this->actor.room; + if ((type != OBJ_TSUBO_TYPE_3) && (sp2C != 2)) { + if (Item_CanDropBigFairy(play, OBJ_TSUBO_P003F(&this->actor), OBJ_TSUBO_PFE00(&this->actor))) { + this->unk_198 = true; + } + } + if ((type == OBJ_TSUBO_TYPE_3) || (sp2C != 2) || !func_809275C0(this, play)) { + this->unk_19A = -1; + } + func_80928914(this); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Tsubo/func_80927FCC.s") +void ObjTsubo_Destroy(Actor* thisx, PlayState* play2) { + PlayState* play = (PlayState*)play2; + ObjTsubo* this = (ObjTsubo*)thisx; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Tsubo/func_809282F0.s") + Collider_DestroyCylinder(play, &this->cylinderCollider); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Tsubo/func_8092860C.s") +void ObjTsubo_PotBreak1(ObjTsubo* this, PlayState* play) { + s16 rot; + s32 i; + s32 phi_s0; + s32 pad; + Vec3f pos; + Vec3f vel; + ObjTsuboData* typeData = &sPotTypeData[OBJ_TSUBO_GET_TYPE(&this->actor)]; + f32 randf; + f32 sin; + f32 cos; + f32 scale; + s32 pad2; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Tsubo/func_80928904.s") + for (i = 0, rot = 0; i < 18; rot += 0x4E20, i++) { + sin = Math_SinS(rot); + cos = Math_CosS(rot); + pos.x = sin * 8.0f; + pos.y = Rand_ZeroOne() * 12.0f + 2.0f; + pos.z = cos * 8.0f; + vel.x = pos.x * 0.23f; + vel.y = Rand_ZeroOne() * 5.0f + 2.5f; + vel.z = pos.z * 0.23f; + Math_Vec3f_Sum(&pos, &this->actor.world.pos, &pos); + randf = Rand_ZeroOne(); + if (randf < 0.2f) { + phi_s0 = 0x60; + } else if (randf < 0.6f) { + phi_s0 = 0x40; + } else { + phi_s0 = 0x20; + } + scale = Rand_ZeroOne() * 110.0f + 15.0f; + EffectSsKakera_Spawn(play, &pos, &vel, &this->actor.world.pos, -260, phi_s0, 20, 0, 0, scale, 0, 0, 50, -1, + typeData->objId, typeData->shardDL); + } + func_800BBFB0(play, &this->actor.world.pos, 30.0f, 2, 20, 50, true); + func_800BBFB0(play, &this->actor.world.pos, 30.0f, 2, 10, 80, true); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Tsubo/func_80928914.s") +void ObjTsubo_RacePotBreak1(ObjTsubo* this, PlayState* play) { + s16 rot; + s32 phi_s0; + s32 i; + ObjTsuboData* typeData = &sPotTypeData[OBJ_TSUBO_GET_TYPE(&this->actor)]; + Vec3f pos; + Vec3f vel; + f32 randf; + f32 sin; + f32 cos; + f32 scale; + s32 pad[2]; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Tsubo/func_80928928.s") + for (i = 0, rot = 0; i < 20; rot += 0x4E20, i++) { + sin = Math_SinS(rot); + cos = Math_CosS(rot); + pos.x = sin * 10.0f; + pos.y = Rand_ZeroOne() * 20.0f + 2.0f; + pos.z = cos * 10.0f; + vel.x = pos.x * 0.3f; + vel.y = Rand_ZeroOne() * 10.0f + 2.0f; + vel.z = pos.z * 0.3f; + Math_Vec3f_Sum(&pos, &this->actor.world.pos, &pos); + randf = Rand_ZeroOne(); + if (randf < 0.2f) { + phi_s0 = 0xE0; + } else if (randf < 0.6f) { + phi_s0 = 0xC0; + } else { + phi_s0 = 0xA0; + } + scale = Rand_ZeroOne() * 160.0f + 15.0f; + EffectSsKakera_Spawn(play, &pos, &vel, &this->actor.world.pos, -340, phi_s0, 20, 0, 0, scale, 0, 0, 50, -1, + typeData->objId, typeData->shardDL); + } + func_800BBFB0(play, &this->actor.world.pos, 50.0f, 2, 40, 50, true); + func_800BBFB0(play, &this->actor.world.pos, 50.0f, 2, 20, 80, true); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Tsubo/func_809289B4.s") +void ObjTsubo_PotBreak2(ObjTsubo* this, PlayState* play2) { + PlayState* play = (PlayState*)play2; + s16 rot; + s32 i; + s32 phi_s0; + Vec3f pos; + Vec3f vel; + Vec3f* worldPos = &this->actor.world.pos; + ObjTsuboData* typeData = &sPotTypeData[OBJ_TSUBO_GET_TYPE(&this->actor)]; + f32 sin; + f32 cos; + f32 scale; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Tsubo/func_809289E4.s") + pos.y = worldPos->y + this->actor.depthInWater; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Tsubo/func_80928D6C.s") + for (rot = 0, i = 0; i < 5; i++, rot += 0x10000 / 5) { + pos.x = Math_SinS((s32)(Rand_ZeroOne() * 6000) + rot) * 15.0f + worldPos->x; + pos.z = Math_CosS((s32)(Rand_ZeroOne() * 6000) + rot) * 15.0f + worldPos->z; + EffectSsGSplash_Spawn(play, &pos, NULL, NULL, 0, 350); + } + pos.x = worldPos->x; + pos.z = worldPos->z; + EffectSsGRipple_Spawn(play, &pos, 200, 600, 0); + for (i = 0, rot = 0; i < 13; rot += 0x4E20, i++) { + sin = Math_SinS(rot); + cos = Math_CosS(rot); + pos.x = sin * 8.0f; + pos.y = (Rand_ZeroOne() * 5.0f) + 2.0f; + pos.z = cos * 8.0f; + vel.x = pos.x * 0.2f; + vel.y = (Rand_ZeroOne() * 4.0f) + 2.0f; + vel.z = pos.z * 0.2f; + Math_Vec3f_Sum(&pos, worldPos, &pos); + if (Rand_ZeroOne() < .2f) { + phi_s0 = 0x40; + } else { + phi_s0 = 0x20; + } + scale = Rand_ZeroOne() * 105.0f + 10.0f; + EffectSsKakera_Spawn(play, &pos, &vel, worldPos, -170, phi_s0, 50, 5, 0, scale, 0, 0, 70, -1, typeData->objId, + typeData->shardDL); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Tsubo/func_80928D80.s") +void ObjTsubo_RacePotBreak2(ObjTsubo* this, PlayState* play2) { + PlayState* play = (PlayState*)play2; + s32 pad; + s16 rot; + s32 i; + Vec3f pos; + Vec3f vel; + ObjTsuboData* typeData = &sPotTypeData[OBJ_TSUBO_GET_TYPE(&this->actor)]; + Vec3f* worldPos = &this->actor.world.pos; + f32 sin; + f32 cos; + s32 phi_s0; + s16 scale; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Tsubo/func_80928E74.s") + pos.y = this->actor.world.pos.y + this->actor.depthInWater; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Tsubo/func_80928F18.s") + for (rot = 0, i = 0; i < 5; i++, rot += 0x10000 / 5) { + pos.x = Math_SinS((s32)(Rand_ZeroOne() * 6000) + rot) * 30.0f + worldPos->x; + pos.z = Math_CosS((s32)(Rand_ZeroOne() * 6000) + rot) * 30.0f + worldPos->z; + EffectSsGSplash_Spawn(play, &pos, NULL, NULL, 0, 350); + } + pos.x = worldPos->x; + pos.z = worldPos->z; + EffectSsGRipple_Spawn(play, &pos, 300, 700, 0); + for (i = 0, rot = 0; i < 15; rot += 0x4E20, i++) { + sin = Math_SinS(rot); + cos = Math_CosS(rot); + pos.x = sin * 10.0f; + pos.y = (Rand_ZeroOne() * 15.0f) + 2.0f; + pos.z = cos * 10.0f; + vel.x = pos.x * 0.3f; + vel.y = (Rand_ZeroOne() * 4.0f) + 2.0f; + vel.z = pos.z * 0.3f; + Math_Vec3f_Sum(&pos, worldPos, &pos); + if (Rand_ZeroOne() < 0.2f) { + phi_s0 = 0xC0; + } else { + phi_s0 = 0xA0; + } + scale = (Rand_ZeroOne() * 150.0f) + 10.0f; + EffectSsKakera_Spawn(play, &pos, &vel, worldPos, -170, phi_s0, 50, 5, 0, scale, 0, 0, 70, -1, typeData->objId, + typeData->shardDL); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Tsubo/func_809291DC.s") +void ObjTsubo_PotBreak3(ObjTsubo* this, PlayState* play2) { + PlayState* play = (PlayState*)play2; + s32 i; + s16 rot; + s32 phi_s0; + Vec3f pos; + Vec3f vel; + ObjTsuboData* typeData = &sPotTypeData[OBJ_TSUBO_GET_TYPE(&this->actor)]; + f32 randf; + f32 temp_f20; + f32 cos; + f32 sin; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Tsubo/func_8092926C.s") + for (i = 0, rot = 0; i < 13; i++, rot += 0x4E20) { + randf = Rand_ZeroOne(); + temp_f20 = (1.0f - SQ(randf)) * 4.8f + 3.2f; + if (this) {} + sin = Math_SinS(rot); + cos = Math_CosS(rot); + pos.x = sin * temp_f20; + pos.y = (Rand_ZeroOne() * 15.0f) + 2.0f; + pos.z = cos * temp_f20; + vel.x = pos.x * 0.4f; + vel.y = (Rand_ZeroOne() * 4.0f) + 4.0f; + vel.z = pos.z * 0.4f; + Math_Vec3f_Sum(&pos, &this->actor.world.pos, &pos); + if (Rand_ZeroOne() < 0.2f) { + phi_s0 = 0x40; + } else { + phi_s0 = 0x20; + } + EffectSsKakera_Spawn(play, &pos, &vel, &this->actor.world.pos, -170, phi_s0, 50, 3, 0, + (Rand_ZeroOne() * 105.0f) + 10.0f, 0, 0, 70, -1, typeData->objId, typeData->shardDL); + } + for (i = 0; i < 7; i++) { + EffectSsBubble_Spawn(play, &this->actor.world.pos, 20.0f, 30.0f, 40.0f, (Rand_ZeroOne() * 0.06f) + 0.09f); + EffectSsBubble_Spawn(play, &this->actor.world.pos, 10.0f, 10.0f, 10.0f, (Rand_ZeroOne() * 0.08f) + 0.09f); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Tsubo/ObjTsubo_Update.s") +void ObjTsubo_RacePotBreak3(ObjTsubo* this, PlayState* play2) { +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Tsubo/func_809294B0.s") +void func_80928914(ObjTsubo* this) { + this->actionFunc = func_80928928; +} + +void func_80928928(ObjTsubo* this, PlayState* play) { + Actor_MoveWithGravity(&this->actor); + Actor_UpdateBgCheckInfo(play, &this->actor, 15.0f, 15.0f, 0.0f, 0x44); + if (Object_IsLoaded(&play->objectCtx, this->objBankIndex)) { + this->actor.objBankIndex = this->objBankIndex; + func_809289B4(this); + } +} + +void func_809289B4(ObjTsubo* this) { + this->actor.draw = ObjTsubo_Draw; + this->actor.flags |= ACTOR_FLAG_10; + this->unk_195 = false; + this->actionFunc = func_809289E4; +} + +void func_809289E4(ObjTsubo* this, PlayState* play) { + ObjTsuboData* typeData; + s32 pad; + s32 type = OBJ_TSUBO_GET_TYPE(&this->actor); + s32 pad2; + s32 acHit = (this->cylinderCollider.base.acFlags & AC_HIT) != 0; + + if (acHit) { + this->cylinderCollider.base.acFlags &= ~AC_HIT; + } + if (this->cylinderCollider.base.ocFlags1 & OC1_HIT) { + this->cylinderCollider.base.ocFlags1 &= ~OC1_HIT; + } + if (Actor_HasParent(&this->actor, play)) { + this->actor.room = -1; + this->actor.flags |= ACTOR_FLAG_10; + if ((type != OBJ_TSUBO_TYPE_3) && func_800A817C(OBJ_TSUBO_P003F(&this->actor))) { + func_80927690(this, play); + } + func_80927818(this, play, 0); + //! @bug: This function should only pass Player*: it uses *(this + 0x153), which is meant to be + //! player->currentMask, but in this case is garbage in the collider + func_800B8E58((Player*)&this->actor, NA_SE_PL_PULL_UP_POT); + func_80928D6C(this); + } else if ((this->unk_19B != 0) || + (acHit && (this->cylinderCollider.info.acHitInfo->toucher.dmgFlags & 0x058BFFBC))) { + typeData = &sPotTypeData[type]; + this->unk_19B = 0; + if ((this->actor.bgCheckFlags & 0x20) && (this->actor.depthInWater > 15.0f)) { + typeData->breakPot3(this, play); + } else { + typeData->breakPot1(this, play); + } + if (type == OBJ_TSUBO_TYPE_3) { + func_8092762C(this, play); + } else { + func_80927690(this, play); + } + func_80927818(this, play, 1); + SoundSource_PlaySfxAtFixedWorldPos(play, &this->actor.world.pos, 20, NA_SE_EV_POT_BROKEN); + if (ObjTsubo_IsSceneNotGohtOrTwinmold(this, play)) { + Actor_MarkForDeath(&this->actor); + } else { + func_809291DC(this); + } + } else { + if (!this->unk_195) { + Actor_MoveWithGravity(&this->actor); + Actor_UpdateBgCheckInfo(play, &this->actor, 15.0f, 15.0f, 0.0f, 0x44); + if ((this->actor.bgCheckFlags & 1) && (DynaPoly_GetActor(&play->colCtx, this->actor.floorBgId) == NULL)) { + this->unk_195 = true; + this->actor.flags &= ~ACTOR_FLAG_10; + } + } + if ((this->actor.xzDistToPlayer < 800.0f) || (gSaveContext.save.entrance == ENTRANCE(GORON_RACETRACK, 1))) { + Collider_UpdateCylinder(&this->actor, &this->cylinderCollider); + CollisionCheck_SetAC(play, &play->colChkCtx, &this->cylinderCollider.base); + if (this->actor.xzDistToPlayer < 150.0f) { + CollisionCheck_SetOC(play, &play->colChkCtx, &this->cylinderCollider.base); + if (this->actor.xzDistToPlayer < 100.0f) { + s16 yawDiff = this->actor.yawTowardsPlayer - GET_PLAYER(play)->actor.world.rot.y; + s32 absYawDiff = ABS_ALT(yawDiff); + + if (absYawDiff > (0x10000 / 3)) { + Actor_PickUp(&this->actor, play, GI_NONE, 36.0f, 30.0f); + } + } + } + } + } +} + +void func_80928D6C(ObjTsubo* this) { + this->actionFunc = func_80928D80; +} + +void func_80928D80(ObjTsubo* this, PlayState* play) { + s32 pad; + Vec3f pos; + s32 bgId; + + func_8092788C(this, play); + if (Actor_HasNoParent(&this->actor, play)) { + this->actor.room = play->roomCtx.currRoom.num; + Actor_MoveWithGravity(&this->actor); + this->actor.flags &= ~ACTOR_FLAG_4000000; + Actor_UpdateBgCheckInfo(play, &this->actor, 15.0f, 15.0f, 0.0f, 0xC5); + func_80928E74(this); + } 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(&play->colCtx, &this->actor.floorPoly, &bgId, &this->actor, &pos); + } +} + +void func_80928E74(ObjTsubo* this) { + this->unk_194 = 80; + this->actor.colChkInfo.mass = 180; + D_80929500 = (Rand_ZeroOne() - 0.78f) * 4500.0f; + D_80929508 = (Rand_ZeroOne() - 0.5f) * 2000.0f; + D_80929504 = 0; + D_8092950C = 0; + this->actionFunc = func_80928F18; +} + +void func_80928F18(ObjTsubo* this, PlayState* play) { + s32 pad; + ObjTsuboData* typeData; + s32 type = OBJ_TSUBO_GET_TYPE(&this->actor); + s32 pad2; + s32 atHit = (this->cylinderCollider.base.atFlags & AT_HIT) != 0; + + if (atHit) { + this->cylinderCollider.base.atFlags &= ~AT_HIT; + } + func_8092788C(this, play); + + if (this->unk_194 > 0) { + this->unk_194--; + } + typeData = &sPotTypeData[type]; + if ((this->actor.bgCheckFlags & 0xB) || atHit || (this->unk_194 <= 0)) { + typeData->breakPot1(this, play); + if (type == OBJ_TSUBO_TYPE_3) { + func_8092762C(this, play); + } else { + func_80927690(this, play); + } + SoundSource_PlaySfxAtFixedWorldPos(play, &this->actor.world.pos, 20, NA_SE_EV_POT_BROKEN); + if (ObjTsubo_IsSceneNotGohtOrTwinmold(this, play)) { + Actor_MarkForDeath(&this->actor); + } else { + func_809291DC(this); + } + } else if (this->actor.bgCheckFlags & 0x40) { + typeData->breakPot2(this, play); + if (type == OBJ_TSUBO_TYPE_3) { + func_8092762C(this, play); + } else { + func_80927690(this, play); + } + SoundSource_PlaySfxAtFixedWorldPos(play, &this->actor.world.pos, 20, NA_SE_EV_POT_BROKEN); + SoundSource_PlaySfxAtFixedWorldPos(play, &this->actor.world.pos, 40, NA_SE_EV_DIVE_INTO_WATER_L); + if (ObjTsubo_IsSceneNotGohtOrTwinmold(this, play)) { + Actor_MarkForDeath(&this->actor); + } else { + func_809291DC(this); + } + } else { + Actor_MoveWithGravity(&this->actor); + Math_StepToS(&D_80929504, D_80929500, 150); + Math_StepToS(&D_8092950C, D_80929508, 150); + this->actor.shape.rot.x += D_80929504; + this->actor.shape.rot.y += D_8092950C; + Actor_UpdateBgCheckInfo(play, &this->actor, 15.0f, 15.0f, 0.0f, 0xC5); + Collider_UpdateCylinder(&this->actor, &this->cylinderCollider); + CollisionCheck_SetOC(play, &play->colChkCtx, &this->cylinderCollider.base); + CollisionCheck_SetAT(play, &play->colChkCtx, &this->cylinderCollider.base); + } +} + +void func_809291DC(ObjTsubo* this) { + this->actor.draw = NULL; + this->actor.flags |= ACTOR_FLAG_10; + + Math_Vec3f_Copy(&this->actor.world.pos, &this->actor.home.pos); + this->actor.shape.rot.z = 0; + this->actor.world.rot.z = 0; + this->unk_197 = false; + this->actor.shape.rot.x = this->actor.home.rot.x; + this->actor.world.rot.x = this->actor.home.rot.x; + this->actor.velocity.y = 0.0f; + this->actor.speedXZ = 0.0f; + this->actor.shape.rot.y = this->actor.home.rot.y; + this->actor.world.rot.y = this->actor.home.rot.y; + Actor_SetScale(&this->actor, 0.0f); + this->unk_194 = 127; + this->actionFunc = func_8092926C; +} + +void func_8092926C(ObjTsubo* this, PlayState* play) { + f32 scale; + + if (this->unk_194 > 0) { + this->unk_194--; + if (this->unk_194 == 0) { + this->actor.draw = ObjTsubo_Draw; + } + } else { + scale = sPotTypeData[OBJ_TSUBO_GET_TYPE(&this->actor)].scale; + if (Math_StepToF(&this->actor.scale.x, scale, scale * 0.1f)) { + this->actor.flags |= ACTOR_FLAG_4000000; + func_809289B4(this); + } + this->actor.scale.z = this->actor.scale.y = this->actor.scale.x; + } +} + +void ObjTsubo_Update(Actor* thisx, PlayState* play) { + ObjTsubo* this = (ObjTsubo*)thisx; + + this->actionFunc(this, play); + if (this->actor.draw == NULL) { + this->actor.shape.shadowDraw = NULL; + } else if (this->actor.projectedPos.z < 811.0f) { + if (this->actor.projectedPos.z > 300.0f) { + this->actor.shape.shadowAlpha = (811 - (s32)this->actor.projectedPos.z) >> 1; + this->actor.shape.shadowDraw = ActorShadow_DrawCircle; + } else if (this->actor.projectedPos.z > -10.0f) { + this->actor.shape.shadowAlpha = 255; + this->actor.shape.shadowDraw = ActorShadow_DrawCircle; + } else { + this->actor.shape.shadowDraw = NULL; + } + } else { + this->actor.shape.shadowDraw = NULL; + } + if (!this->unk_197) { + if (this->unk_198) { + play->actorCtx.unk5 |= 8; + this->actor.flags |= ACTOR_FLAG_10; + } + if (this->unk_19A >= 0) { + if (this->unk_19A == 0) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_STALGOLD_ROLL); + if (Rand_ZeroOne() < 0.1f) { + this->unk_19A = Rand_S16Offset(40, 80); + } else { + this->unk_19A = 8; + } + } else { + this->unk_19A--; + } + } + } +} + +void ObjTsubo_Draw(Actor* thisx, PlayState* play2) { + PlayState* play = (PlayState*)play2; + + Gfx_DrawDListOpa(play, sPotTypeData[OBJ_TSUBO_GET_TYPE(thisx)].modelDL); +} diff --git a/src/overlays/actors/ovl_Obj_Tsubo/z_obj_tsubo.h b/src/overlays/actors/ovl_Obj_Tsubo/z_obj_tsubo.h index d3a188e41..28233c911 100644 --- a/src/overlays/actors/ovl_Obj_Tsubo/z_obj_tsubo.h +++ b/src/overlays/actors/ovl_Obj_Tsubo/z_obj_tsubo.h @@ -5,14 +5,39 @@ struct ObjTsubo; -typedef void (*ObjTsuboActionFunc)(struct ObjTsubo*, GlobalContext*); +typedef void (*ObjTsuboActionFunc)(struct ObjTsubo*, PlayState*); + +typedef void (*ObjTsuboUnkFunc)(struct ObjTsubo*, PlayState*); + +#define OBJ_TSUBO_P000F(thisx) ((thisx)->params & 0x0F) +#define OBJ_TSUBO_P001F(thisx) ((thisx)->params & 0x1F) +#define OBJ_TSUBO_P003F(thisx) ((thisx)->params & 0x3F) +#define OBJ_TSUBO_P0010(thisx) (((thisx)->params >> 4) & 1) +#define OBJ_TSUBO_GET_TYPE(thisx) (((thisx)->params >> 7) & 3) +#define OBJ_TSUBO_PFE00(thisx) (((thisx)->params >> 9) & 0x7F) //item collectable flag? +#define OBJ_TSUBO_ZROT(thisx) ((thisx)->home.rot.z) typedef struct ObjTsubo { - /* 0x0000 */ Actor actor; - /* 0x0144 */ ObjTsuboActionFunc actionFunc; - /* 0x0148 */ char unk_148[0x54]; + /* 0x000 */ Actor actor; + /* 0x144 */ ObjTsuboActionFunc actionFunc; + /* 0x148 */ ColliderCylinder cylinderCollider; + /* 0x194 */ s8 unk_194; + /* 0x195 */ s8 unk_195; + /* 0x196 */ s8 homeRoom; + /* 0x197 */ s8 unk_197; + /* 0x198 */ s8 unk_198; + /* 0x199 */ s8 objBankIndex; + /* 0x19A */ s8 unk_19A; + /* 0x19B */ u8 unk_19B; } ObjTsubo; // size = 0x19C extern const ActorInit Obj_Tsubo_InitVars; +typedef enum { + /* 0 */ OBJ_TSUBO_TYPE_0, + /* 1 */ OBJ_TSUBO_TYPE_1, + /* 2 */ OBJ_TSUBO_TYPE_2, + /* 3 */ OBJ_TSUBO_TYPE_3 +} ObjTsuboType; + #endif // Z_OBJ_TSUBO_H 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 324d13e4b..9bae7169e 100644 --- a/src/overlays/actors/ovl_Obj_Um/z_obj_um.c +++ b/src/overlays/actors/ovl_Obj_Um/z_obj_um.c @@ -1,39 +1,66 @@ /* * File: z_obj_um.c * Overlay: ovl_Obj_Um - * Description: Cremia's cart and milk run quest + * Description: Cremia's Cart and milk run minigame */ #include "z_obj_um.h" +#include "overlays/actors/ovl_En_In/z_en_in.h" +#include "objects/gameplay_keep/gameplay_keep.h" #define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_8 | ACTOR_FLAG_10 | ACTOR_FLAG_20) #define THIS ((ObjUm*)thisx) -void ObjUm_Init(Actor* thisx, GlobalContext* globalCtx); -void ObjUm_Destroy(Actor* thisx, GlobalContext* globalCtx); -void ObjUm_Update(Actor* thisx, GlobalContext* globalCtx); -void ObjUm_Draw(Actor* thisx, GlobalContext* globalCtx); +/** + * weekEventReg flags checked by this actor: + * - gSaveContext.save.weekEventReg[22] & 1: Aliens defeated + * If false: The actor doesn't spawn + * - gSaveContext.save.weekEventReg[31] & 0x40 + * If true: Cremia doesn't explain again she'll deliever milk to town + * - gSaveContext.save.weekEventReg[31] & 0x80 + * If true: Triggers cutscene on Romani's Ranch + * - gSaveContext.save.weekEventReg[34] & 0x80 + * If true: Doesn't spawn on Romani's Ranch + * - gSaveContext.save.weekEventReg[52] & 1 + * If true: Doesn't spawn on Romani's Ranch or Milk Road + * - gSaveContext.save.weekEventReg[52] & 2 + * If true: Doesn't spawn on Romani's Ranch or Milk Road + * - gSaveContext.save.weekEventReg[59] & 2 + * If true: Doesn't spawn again on Milk Road + * + * weekEventReg flags set by this actor: + * - gSaveContext.save.weekEventReg[31] |= 0x40: Cremia offered a ride + * Cremia offered a ride accross the Milk Road to Player + * - gSaveContext.save.weekEventReg[31] |= 0x80: Player is in Milk Run + * Player accepts the ride and is with Cremia during the Milk Run. + * - gSaveContext.save.weekEventReg[34] |= 0x80: Cremia does Milk Run alone + * Player didn't interact or didn't accept the ride + * - gSaveContext.save.weekEventReg[52] |= 1: Won Milk Run minigame + * At least one pot is safe. Turns off the "Lose Milk Run minigame" + * - gSaveContext.save.weekEventReg[52] |= 2: Lose Milk Run minigame + * Every pot was broken by bandits. Turns off the "Win Milk Run minigame" + * - gSaveContext.save.weekEventReg[59] |= 2: ? + * Passed through Milk Road after winning the Milk Run + * + * weekEventReg flags unset by this actor: + * - gSaveContext.save.weekEventReg[31] &= (u8)~0x80 + * Turned off when the Milk Run finishes + * - gSaveContext.save.weekEventReg[52] &= (u8)~1 + * Turned off if Player lose the Milk Run + * - gSaveContext.save.weekEventReg[52] &= (u8)~2 + * Turned off if Player wins the Milk Run + */ -void func_80B79A50(ObjUm* this, GlobalContext* globalCtx); -void func_80B79F10(ObjUm* this, GlobalContext* globalCtx); -void func_80B7A070(ObjUm* this, GlobalContext* globalCtx); -void func_80B7A0E0(ObjUm* this, GlobalContext* globalCtx); -void func_80B7A144(ObjUm* this, GlobalContext* globalCtx); -void func_80B7A2AC(ObjUm* this, GlobalContext* globalCtx); -void func_80B7A394(ObjUm* this, GlobalContext* globalCtx); -void func_80B7A400(ObjUm* this, GlobalContext* globalCtx); -void func_80B7A494(ObjUm* this, GlobalContext* globalCtx); -void func_80B7A614(ObjUm* this, GlobalContext* globalCtx); -void func_80B7A7AC(ObjUm* this, GlobalContext* globalCtx); -void func_80B7ABE4(ObjUm* this, GlobalContext* globalCtx); -void func_80B7AC94(ObjUm* this, GlobalContext* globalCtx); -void func_80B7AD34(ObjUm* this, GlobalContext* globalCtx); -void func_80B7AE58(ObjUm* this, GlobalContext* globalCtx); +void ObjUm_Init(Actor* thisx, PlayState* play); +void ObjUm_Destroy(Actor* thisx, PlayState* play); +void ObjUm_Update(Actor* thisx, PlayState* play); +void ObjUm_Draw(Actor* thisx, PlayState* play); +void ObjUm_DefaultAnim(ObjUm* this, PlayState* play); +void ObjUm_ChangeAnim(ObjUm* this, PlayState* play, ObjUmAnimation index); void ObjUm_SetupAction(ObjUm* this, ObjUmActionFunc actionFunc); -#if 0 const ActorInit Obj_Um_InitVars = { ACTOR_OBJ_UM, ACTORCAT_NPC, @@ -46,131 +73,1949 @@ const ActorInit Obj_Um_InitVars = { (ActorFunc)ObjUm_Draw, }; -// static ColliderCylinderInit sCylinderInit = { -static ColliderCylinderInit D_80B7C138 = { - { COLTYPE_HIT3, AT_NONE, AC_ON | AC_TYPE_PLAYER, OC1_NONE, OC2_TYPE_1, COLSHAPE_CYLINDER, }, - { ELEMTYPE_UNK1, { 0x00000000, 0x00, 0x00 }, { 0x00000020, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_NONE, }, +static TexturePtr sEyeTextures[] = { + gUmCremiaEyeOpenTex, gUmCremiaEyeHalfTex, gUmCremiaEyeClosedTex, + gUmCremiaEyeHappyTex, gUmCremiaEyeAngryTex, gUmCremiaEyeSadTex, +}; + +static TexturePtr sMouthTextures[] = { + gUmMouthNormalTex, + gUmMouthHappyTex, + gUmMouthHangingOpenTex, + gUmMouthFrownTex, +}; + +static ColliderCylinderInit sCylinderInit = { + { + COLTYPE_HIT3, + AT_NONE, + AC_ON | AC_TYPE_PLAYER, + OC1_NONE, + OC2_TYPE_1, + COLSHAPE_CYLINDER, + }, + { + ELEMTYPE_UNK1, + { 0x00000000, 0x00, 0x00 }, + { 0x00000020, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_NONE, + }, { 40, 64, 0, { 0, 0, 0 } }, }; -// static InitChainEntry sInitChain[] = { -static InitChainEntry D_80B7C254[] = { +// actionfuncs +void func_80B7A144(ObjUm* this, PlayState* play); +void ObjUm_RanchWait(ObjUm* this, PlayState* play); +void ObjUm_PreMilkRunStartCs(ObjUm* this, PlayState* play); +void ObjUm_StartCs(ObjUm* this, PlayState* play); +void ObjUm_PostMilkRunStartCs(ObjUm* this, PlayState* play); +void ObjUm_TerminaFieldIdle(ObjUm* this, PlayState* play); +void ObjUm_RanchWaitPathFinished(ObjUm* this, PlayState* play); +void func_80B7A0E0(ObjUm* this, PlayState* play); +void func_80B7A070(ObjUm* this, PlayState* play); +void ObjUm_RanchStartCs(ObjUm* this, PlayState* play); +void func_80B7A2AC(ObjUm* this, PlayState* play); +void func_80B7A240(ObjUm* this, PlayState* play); +void func_80B7A394(ObjUm* this, PlayState* play); +void ObjUm_RunMinigame(ObjUm* this, PlayState* play); +void func_80B7A614(ObjUm* this, PlayState* play); +void func_80B7AB78(ObjUm* this, PlayState* play); +void func_80B7ABE4(ObjUm* this, PlayState* play); +void ObjUm_PostMilkRunWaitPathFinished(ObjUm* this, PlayState* play); + +// Maybe it is updating the bandits positions? +void func_80B77770(ObjUm* this, PlayState* play) { + s16 rotY = this->dyna.actor.shape.rot.y; + Vec3f sp108; + Vec3f spFC; + Vec3f spF0; + Vec3f spE4; + Vec3f spD8; + Vec3f spCC; + Vec3f spC0; + Vec3f spB4; + Vec3f spA8; + Vec3f sp9C; + Vec3f sp90; + Vec3f sp84; + Vec3f sp78; + Vec3f sp6C; + Vec3f sp60 = this->dyna.actor.world.pos; + + // Loop unroll? + this->unk_360[15] = sp60; + sp6C = sp60; + this->unk_360[14] = sp6C; + sp78 = sp6C; + this->unk_360[13] = sp78; + sp84 = sp78; + this->unk_360[12] = sp84; + sp90 = sp84; + this->unk_360[11] = sp90; + sp9C = sp90; + this->unk_360[10] = sp9C; + spA8 = sp9C; + this->unk_360[9] = spA8; + spB4 = spA8; + this->unk_360[8] = spB4; + spC0 = spB4; + this->unk_360[7] = spC0; + spCC = spC0; + this->unk_360[6] = spCC; + spD8 = spCC; + this->unk_360[5] = spD8; + spE4 = spD8; + this->unk_360[4] = spE4; + spF0 = spE4; + this->unk_360[3] = spF0; + spFC = spF0; + this->unk_360[2] = spFC; + sp108 = spFC; + this->unk_360[1] = sp108; + this->unk_360[0] = sp108; + + this->unk_360[0].x += 110.0f * Math_SinS(rotY + 0x4000); + this->unk_360[0].z += 110.0f * Math_CosS(rotY + 0x4000); + this->unk_360[1].x += 110.0f * Math_SinS(rotY - 0x4000); + this->unk_360[1].z += 110.0f * Math_CosS(rotY - 0x4000); + Math_Vec3f_Copy(&this->unk_360[2], &this->unk_360[0]); + this->unk_360[2].x -= 200.0f * Math_SinS(rotY); + this->unk_360[2].z -= 200.0f * Math_CosS(rotY); + Math_Vec3f_Copy(&this->unk_360[4], &this->unk_360[1]); + this->unk_360[4].x -= 200.0f * Math_SinS(rotY); + this->unk_360[4].z -= 200.0f * Math_CosS(rotY); + this->unk_360[3].x -= 220.0f * Math_SinS(rotY); + this->unk_360[3].z -= 220.0f * Math_CosS(rotY); + Math_Vec3f_Copy(&this->unk_360[5], &this->unk_360[0]); + this->unk_360[5].x -= 500.0f * Math_SinS(rotY); + this->unk_360[5].z -= 500.0f * Math_CosS(rotY); + Math_Vec3f_Copy(&this->unk_360[7], &this->unk_360[1]); + this->unk_360[7].x -= 500.0f * Math_SinS(rotY); + this->unk_360[7].z -= 500.0f * Math_CosS(rotY); + this->unk_360[6].x -= 500.0f * Math_SinS(rotY); + this->unk_360[6].z -= 500.0f * Math_CosS(rotY); + Math_Vec3f_Copy(&this->unk_360[8], &this->unk_360[0]); + this->unk_360[8].x -= 700.0f * Math_SinS(rotY); + this->unk_360[8].z -= 700.0f * Math_CosS(rotY); + Math_Vec3f_Copy(&this->unk_360[10], &this->unk_360[1]); + this->unk_360[10].x -= 700.0f * Math_SinS(rotY); + this->unk_360[10].z -= 700.0f * Math_CosS(rotY); + this->unk_360[9].x -= 700.0f * Math_SinS(rotY); + this->unk_360[9].z -= 700.0f * Math_CosS(rotY); + this->unk_360[11] = this->unk_360[3]; + this->unk_360[11].x += 40.0f * Math_SinS(rotY + 0x4000); + this->unk_360[11].z += 40.0f * Math_CosS(rotY + 0x4000); + this->unk_360[12] = this->unk_360[3]; + this->unk_360[12].x += 40.0f * Math_SinS(rotY - 0x4000); + this->unk_360[12].z += 40.0f * Math_CosS(rotY - 0x4000); + this->unk_360[13] = this->unk_360[2]; + this->unk_360[14] = this->unk_360[4]; +} + +s32 ObjUm_InitBandits(ObjUm* this, PlayState* play) { + Path* path = &play->setupPathList[this->pathIndex]; + s16 pad; + Vec3s* spawnPoints; + EnHorse* bandit1; + EnHorse* bandit2; + + spawnPoints = Lib_SegmentedToVirtual(path->points); + Audio_QueueSeqCmd(0x8000 | NA_BGM_CHASE); + + bandit1 = (EnHorse*)Actor_Spawn(&play->actorCtx, play, ACTOR_EN_HORSE, spawnPoints[0].x, spawnPoints[0].y, + spawnPoints[0].z, 0, this->dyna.actor.shape.rot.y, 0, + ENHORSE_PARAMS(ENHORSE_PARAM_BANDIT, ENHORSE_19)); + this->bandit1 = bandit1; + + bandit1->unk_540 = bandit1->actor.world.pos; + + bandit1->unk_54C = 0xF; + bandit1->unk_550 = 10; + + bandit1->unk_554 = this->pathIndex; + bandit1->unk_568 = 0.0f; + bandit1->unk_56C = 0.0f; + bandit1->unk_558 = 0; + bandit1->unk_55C = 40; + bandit1->unk_560 = 40; + + bandit1->banditPosition = gZeroVec3f; + bandit1->unk_57C = gZeroVec3f; + + bandit1->unk_588 = this->dyna.actor.shape.rot.y; + bandit1->curRaceWaypoint = 1; + + bandit2 = (EnHorse*)Actor_Spawn(&play->actorCtx, play, ACTOR_EN_HORSE, spawnPoints[1].x, spawnPoints[1].y, + spawnPoints[1].z, 0, this->dyna.actor.shape.rot.y, 0, + ENHORSE_PARAMS(ENHORSE_PARAM_BANDIT, ENHORSE_20)); + this->bandit2 = bandit2; + + bandit2->unk_540 = bandit2->actor.world.pos; + + bandit2->unk_54C = 0xF; + bandit2->unk_550 = 8; + + bandit2->unk_554 = this->pathIndex; + bandit2->unk_568 = 0.0f; + bandit2->unk_56C = 0.0f; + bandit2->unk_55C = 40; + bandit2->unk_560 = 40; + + bandit2->unk_57C = gZeroVec3f; + + bandit2->unk_588 = this->dyna.actor.shape.rot.y; + bandit2->curRaceWaypoint = 2; + + this->potsLife[0] = 4; + this->potsLife[1] = 4; + this->potsLife[2] = 4; + + return 0; +} + +typedef struct { + /* 0x00 */ s32 unk_00; + /* 0x04 */ s32 unk_04; + /* 0x08 */ s32 unk_08; + /* 0x0C */ f32 unk_0C; + /* 0x10 */ s32 unk_10; +} struct_80B7C254; // size = 0x14 + +struct_80B7C254 D_80B7C164[] = { + { 2, 0, 0, 1.0f, 40 }, { 4, 1, 0, 1.0f, 40 }, { 3, 2, 0, 1.0f, 40 }, { 3, 4, 0, 1.0f, 40 }, + { 5, 3, 1, -1.0f, 30 }, { 7, 3, 1, 1.0f, 30 }, { 0, 13, 1, -1.0f, 60 }, { 1, 14, 1, 1.0f, 60 }, + { 13, 10, 0, 1.0f, 40 }, { 14, 8, 0, 1.0f, 40 }, { 8, 5, 0, 1.0f, 30 }, { 10, 7, 0, 1.0f, 30 }, +}; + +// BanditAttack? +s32 func_80B781DC(ObjUm* this, EnHorse* bandit1, EnHorse* bandit2, PlayState* play) { + s32 temp_v0; + s32 phi_s3 = -1; + s32 phi_s4 = 0; + s32 phi_s2 = 0; + f32 phi_f20 = 0.0f; + s32 i; + s32 mask; + + for (i = 0; i < ARRAY_COUNT(D_80B7C164); i++) { + if (bandit1->unk_550 == D_80B7C164[i].unk_00) { + if (bandit2->unk_550 != D_80B7C164[i].unk_04) { + if (D_80B7C164[i].unk_00 != 3) { + if (D_80B7C164[i].unk_04 != 3 || + ((mask = Player_GetMask(play)), PLAYER_MASK_CIRCUS_LEADER != mask)) { + phi_s3 = D_80B7C164[i].unk_04; + phi_s4 = D_80B7C164[i].unk_08; + phi_f20 = D_80B7C164[i].unk_0C; + phi_s2 = D_80B7C164[i].unk_10; + } + } else if (((bandit1->unk_54C != 5) || (D_80B7C164[i].unk_04 != 2)) && + ((bandit1->unk_54C != 7) || (D_80B7C164[i].unk_04 != 4))) { + phi_s3 = D_80B7C164[i].unk_04; + phi_s4 = D_80B7C164[i].unk_08; + phi_f20 = D_80B7C164[i].unk_0C; + if ((2.0f * Rand_ZeroOne()) < 1.0f) { + phi_f20 *= -1.0f; + } + phi_s2 = D_80B7C164[i].unk_10; + } + //! FAKE: + ; + } + } + } + + if (phi_s3 == -1) { + return 0; + } + + bandit1->unk_540 = bandit1->actor.world.pos; + bandit1->unk_54C = bandit1->unk_550; + bandit1->unk_550 = phi_s3; + bandit1->unk_55C = phi_s2; + bandit1->unk_560 = phi_s2; + bandit1->unk_564 = phi_s4; + bandit1->unk_568 = phi_f20; + + if (phi_s3 == 3) { + f32 rand = Rand_ZeroOne(); + + bandit1->unk_558 = (s32)(rand * 3.0f); + } else { + bandit1->unk_558 = 0; + } + + return 0; +} + +// ObjUm_Bandit_UpdatePosition? +s32 func_80B783E0(ObjUm* this, PlayState* play, s32 banditIndex, EnHorse* bandit) { + Path* sp6C = &play->setupPathList[this->pathIndex]; + s32 sp68; + Vec3s* sp64; + f32 phi_f12; + s32 phi_v1_2; + Vec3f sp50; + f32 sp4C; + f32 sp48; + f32 sp44; + s32 temp_a1; + f32 sp3C; + f32 phi_f14; + + sp68 = sp6C->count; + sp64 = Lib_SegmentedToVirtual(sp6C->points); + + if (sp68 == 0) { + return 0; + } + + if (Math3D_Distance(&bandit->actor.world.pos, &this->dyna.actor.world.pos) < 800.0f) { + if (banditIndex == 0) { + this->flags |= OBJ_UM_FLAG_0200; + } else { + this->flags |= OBJ_UM_FLAG_0400; + } + bandit->unk_540 = bandit->actor.world.pos; + bandit->unk_55C = 50; + bandit->unk_560 = 50; + bandit->unk_564 = 1; + } + + Math_Vec3s_ToVec3f(&sp50, &sp64[bandit->curRaceWaypoint]); + + if (bandit->curRaceWaypoint == 0) { + phi_f12 = sp64[1].x - sp64[0].x; + phi_f14 = sp64[1].z - sp64[0].z; + } else { + if ((bandit->curRaceWaypoint + 1) == sp6C->count) { + phi_f12 = sp64[sp6C->count - 1].x - sp64[sp6C->count - 2].x; + phi_f14 = sp64[sp6C->count - 1].z - sp64[sp6C->count - 2].z; + } else { + phi_f12 = sp64[bandit->curRaceWaypoint + 1].x - sp64[bandit->curRaceWaypoint - 1].x; + phi_f14 = sp64[bandit->curRaceWaypoint + 1].z - sp64[bandit->curRaceWaypoint - 1].z; + } + } + + temp_a1 = Math_Atan2S(phi_f12, phi_f14); + + func_8017B7F8(&sp50, temp_a1, &sp4C, &sp48, &sp44); + if (((bandit->actor.world.pos.x * sp4C) + (sp48 * bandit->actor.world.pos.z) + sp44) > 0.0f) { + bandit->curRaceWaypoint++; + if (bandit->curRaceWaypoint >= sp68) { + bandit->curRaceWaypoint = 0; + } + Math_Vec3s_ToVec3f(&sp50, &sp64[bandit->curRaceWaypoint]); + } + + bandit->actor.world.rot.y = Math_Vec3f_Yaw(&bandit->actor.world.pos, &sp50); + bandit->actor.speedXZ = 45.0f; + + sp3C = Math_CosS(bandit->actor.world.rot.x) * bandit->actor.speedXZ; + bandit->actor.velocity.x = Math_SinS(bandit->actor.world.rot.y) * sp3C; + bandit->actor.velocity.y = Math_SinS(bandit->actor.world.rot.x) * bandit->actor.speedXZ; + bandit->actor.velocity.z = Math_CosS(bandit->actor.world.rot.y) * sp3C; + + bandit->banditPosition.x = + bandit->actor.world.pos.x + (bandit->actor.velocity.x * 0.5f) + bandit->actor.colChkInfo.displacement.x; + bandit->banditPosition.y = + bandit->actor.world.pos.y + (bandit->actor.velocity.y * 0.5f) + bandit->actor.colChkInfo.displacement.y; + bandit->banditPosition.z = + bandit->actor.world.pos.z + (bandit->actor.velocity.z * 0.5f) + bandit->actor.colChkInfo.displacement.z; + + phi_v1_2 = BINANG_SUB(bandit->actor.world.rot.y, bandit->actor.shape.rot.y); + + if (phi_v1_2 > 0x190) { + phi_v1_2 = 0x190; + } else if (phi_v1_2 < -0x190) { + phi_v1_2 = -0x190; + } + + bandit->actor.shape.rot.y = bandit->actor.shape.rot.y + phi_v1_2; + return 0; +} + +// ObjUm_Bandit_GetCloserAndAttack +s32 func_80B78764(ObjUm* this, PlayState* play, EnHorse* bandit1, EnHorse* bandit2) { + s32 pad; + Vec3f sp30; + s16 phi_v1_5; + + bandit1->unk_55C--; + if (bandit1->unk_55C <= 0) { + bandit1->unk_55C = 0; + + if ((bandit1->unk_550 == 3) && !(this->flags & OBJ_UM_FLAG_MINIGAME_FINISHED)) { + s32 potIndex = -1; + + if (this->potsLife[0] != 1) { + potIndex = 0; + } + + if (this->potsLife[1] != 1) { + if ((potIndex == -1) || (potIndex == 0 && Rand_ZeroOne() < 0.3f)) { + potIndex = 1; + } + } + + if (this->potsLife[2] != 1) { + if ((potIndex == -1) || (potIndex != -1 && Rand_ZeroOne() < 0.3f)) { + potIndex = 2; + } + } + + if (this->potsLife[potIndex] != 1) { + this->wasPotHit[potIndex] = true; + if (this->potsLife[potIndex] == 2) { + Audio_PlaySfxAtPos(&this->potPos[potIndex], NA_SE_EV_MILK_POT_BROKEN); + } else { + Audio_PlaySfxAtPos(&this->potPos[potIndex], NA_SE_EV_MILK_POT_DAMAGE); + } + + this->potsLife[potIndex]--; + if (this->potsLife[potIndex] < 1) { + this->potsLife[potIndex] = 1; + } + } + } + + func_80B781DC(this, bandit1, bandit2, play); + } + + Math3D_Lerp(&bandit1->unk_540, &this->unk_360[bandit1->unk_550], 1.0f - ((f32)bandit1->unk_55C / bandit1->unk_560), + &sp30); + bandit1->banditPosition = sp30; + bandit1->unk_588 = this->dyna.actor.shape.rot.y; + + if ((bandit1->unk_550 == 10) || ((bandit1->unk_550 == 8))) { + phi_v1_5 = bandit1->unk_588; + } else if (Math3D_Distance(&bandit1->actor.prevPos, &bandit1->actor.world.pos) < 10.0f) { + phi_v1_5 = bandit1->unk_588; + } else { + phi_v1_5 = Math_Vec3f_Yaw(&bandit1->actor.prevPos, &bandit1->actor.world.pos); + } + + if (1) {} + + phi_v1_5 -= bandit1->actor.shape.rot.y; + if (phi_v1_5 > 0x190) { + bandit1->actor.shape.rot.y += 0x190; + } else if (phi_v1_5 < -0x190) { + bandit1->actor.shape.rot.y -= 0x190; + } else { + bandit1->actor.shape.rot.y += phi_v1_5; + } + + return 0; +} + +// ObjUm_UpdateBanditsDamage? +s32 func_80B78A54(ObjUm* this, PlayState* play, s32 arg2, EnHorse* arg3, EnHorse* arg4) { + if (this->banditsCollisions[arg2].base.acFlags & AC_HIT) { + if (arg3->unk_550 == 3) { + s16 sp36 = + Math_Vec3f_Yaw(&this->dyna.actor.world.pos, &arg3->actor.world.pos) - this->dyna.actor.shape.rot.y; + + this->banditsCollisions[arg2].base.acFlags &= ~AC_HIT; + Audio_PlaySfxAtPos(&arg3->actor.projectedPos, NA_SE_EN_CUTBODY); + arg3->unk_54C = 0xF; + + if (Math_SinS(sp36) > 0.0f) { + arg3->unk_550 = arg4->unk_550 != 10 ? 10 : 8; + arg3->unk_568 = -1.0f; + } else { + arg3->unk_550 = arg4->unk_550 != 8 ? 8 : 10; + arg3->unk_568 = 1.0f; + } + + arg3->unk_540 = arg3->actor.world.pos; + arg3->unk_55C = 40; + arg3->unk_560 = 40; + arg3->unk_564 = 1; + if (arg3->rider != NULL) { + arg3->rider->actor.colorFilterTimer = 20; + Actor_SetColorFilter(&arg3->rider->actor, 0x4000, 0xFF, 0, 40); + } + } else { + if (arg3->rider != NULL) { + arg3->rider->actor.colorFilterTimer = 20; + Actor_SetColorFilter(&arg3->rider->actor, 0x4000, 0xFF, 0, 40); + } + Audio_PlaySfxAtPos(&arg3->actor.projectedPos, NA_SE_EN_CUTBODY); + } + } + + return 0; +} + +// ObjUm_UpdateBanditLogic? +s32 func_80B78C18(ObjUm* this, PlayState* play) { + EnHorse* bandit1 = this->bandit1; + EnHorse* bandit2 = this->bandit2; + + if (!(this->flags & OBJ_UM_FLAG_0200)) { + func_80B783E0(this, play, 0, bandit1); + } else { + func_80B78764(this, play, bandit1, bandit2); + } + + if (!(this->flags & OBJ_UM_FLAG_0400)) { + func_80B783E0(this, play, 1, bandit2); + } else { + func_80B78764(this, play, bandit2, bandit1); + } + + func_80B78A54(this, play, 0, bandit1, bandit2); + func_80B78A54(this, play, 1, bandit2, bandit1); + return 0; +} + +s32 ObjUm_UpdateBanditsCollisions(ObjUm* this, PlayState* play) { + s32 pad[3]; + + this->banditsCollisions[0].dim.pos.x = this->bandit1->actor.world.pos.x; + this->banditsCollisions[0].dim.pos.y = this->bandit1->actor.world.pos.y + 70.0f; + this->banditsCollisions[0].dim.pos.z = this->bandit1->actor.world.pos.z; + + this->banditsCollisions[1].dim.pos.x = this->bandit2->actor.world.pos.x; + this->banditsCollisions[1].dim.pos.y = this->bandit2->actor.world.pos.y + 70.0f; + this->banditsCollisions[1].dim.pos.z = this->bandit2->actor.world.pos.z; + + CollisionCheck_SetAC(play, &play->colChkCtx, &this->banditsCollisions[0].base); + CollisionCheck_SetAC(play, &play->colChkCtx, &this->banditsCollisions[1].base); + return 0; +} + +// ObjUm_UpdateBandits? +s32 func_80B78DF0(ObjUm* this, PlayState* play) { + func_80B78C18(this, play); + ObjUm_UpdateBanditsCollisions(this, play); + return 0; +} + +void ObjUm_SetupAction(ObjUm* this, ObjUmActionFunc actionFunc) { + this->actionFunc = actionFunc; +} + +void ObjUm_SetPlayerPosition(ObjUm* this, PlayState* play) { + Player* player = GET_PLAYER(play); + + if (this->flags & OBJ_UM_FLAG_DRAWN_FLOOR) { + player->actor.world.pos = this->unk_308; + player->actor.prevPos = this->unk_308; + } +} + +void ObjUm_RotatePlayer(ObjUm* this, PlayState* play, s16 angle) { + Player* player = GET_PLAYER(play); + + player->actor.shape.rot.y = player->actor.world.rot.y = player->currentYaw = this->dyna.actor.shape.rot.y + angle; +} + +void func_80B78EBC(ObjUm* this, PlayState* play) { + Player* player = GET_PLAYER(play); + + player->actor.focus.rot.x = 0; + player->actor.focus.rot.z = 0; + player->actor.focus.rot.y = player->actor.shape.rot.y; + + player->unk_AAC.x = 0; + player->unk_AAC.y = 0; + player->unk_AAC.z = 0; + + player->unk_AB2.x = 0; + player->unk_AB2.y = 0; + player->unk_AB2.z = 0; + + player->currentYaw = player->actor.focus.rot.y; +} + +void ObjUm_RotatePlayerView(ObjUm* this, PlayState* play, s16 angle) { + Player* player = GET_PLAYER(play); + + player->actor.focus.rot.y += angle; +} + +static InitChainEntry sInitChain[] = { ICHAIN_F32(uncullZoneScale, 1200, ICHAIN_CONTINUE), ICHAIN_F32(uncullZoneDownward, 300, ICHAIN_STOP), }; -#endif +void ObjUm_Init(Actor* thisx, PlayState* play) { + s32 pad; + ObjUm* this = THIS; + s32 sp54 = true; + s32 i; -extern ColliderCylinderInit D_80B7C138; -extern InitChainEntry D_80B7C254[]; + DynaPolyActor_Init(&this->dyna, 0); + this->unk_350 = 0; -extern UNK_TYPE D_06011DF8; -extern UNK_TYPE D_06012CC0; + this->unk_2C4 = this->dyna.actor.world.pos; + this->unk_2DC = this->dyna.actor.world.pos; + this->unk_308 = this->dyna.actor.world.pos; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Um/func_80B77770.s") + for (i = 0; i < MILK_POTS_COUNT; i++) { + this->potsLife[i] = 5; + this->wasPotHit[i] = false; + this->potPos[i] = gZeroVec3f; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Um/func_80B77FA4.s") + this->donkey = NULL; + this->unk_354 = 0; + this->unk_420 = 0; + this->cartBedPos = this->dyna.actor.world.pos; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Um/func_80B781DC.s") + this->unk_4CC = 0; + this->mouthTexIndex = 0; + this->flags = OBJ_UM_FLAG_NONE; + this->dyna.actor.gravity = -3.5f; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Um/func_80B783E0.s") + Actor_ProcessInitChain(&this->dyna.actor, sInitChain); + ActorShape_Init(&this->dyna.actor.shape, 0.0f, NULL, 50.0f); + SkelAnime_InitFlex(play, &this->skelAnime, &gUmSkel, NULL, this->jointTable, this->morphTable, UM_LIMB_MAX); + Animation_PlayLoop(&this->skelAnime, &gUmTrotAnim); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Um/func_80B78764.s") + this->wheelRot = 0; + ObjUm_DefaultAnim(this, play); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Um/func_80B78A54.s") + this->type = OBJ_UM_GET_TYPE(thisx); + this->initialPathIndex = OBJ_UM_GET_PATH_INDEX(thisx); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Um/func_80B78C18.s") + // if (!AliensDefeated) + if (!(gSaveContext.save.weekEventReg[22] & 1)) { + Actor_MarkForDeath(&this->dyna.actor); + return; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Um/func_80B78D08.s") + if (this->type == OBJ_UM_TYPE_TERMINA_FIELD) { + ObjUm_SetupAction(this, ObjUm_TerminaFieldIdle); + } else if (this->type == OBJ_UM_TYPE_RANCH) { + this->pathIndex = this->initialPathIndex; + if (gSaveContext.save.weekEventReg[31] & 0x80) { + // In cutscene -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Um/func_80B78DF0.s") + sp54 = false; + this->flags |= OBJ_UM_FLAG_0100; + ObjUm_SetupAction(this, func_80B7A144); + func_800FE484(); + } else { + // Waiting for player -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Um/ObjUm_SetupAction.s") + if ((gSaveContext.save.weekEventReg[34] & 0x80) || gSaveContext.save.time >= CLOCK_TIME(19, 0) || + gSaveContext.save.time <= CLOCK_TIME(6, 0) || (gSaveContext.save.weekEventReg[52] & 1) || + (gSaveContext.save.weekEventReg[52] & 2)) { + Actor_MarkForDeath(&this->dyna.actor); + return; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Um/func_80B78E38.s") + this->dyna.actor.targetMode = 6; + this->unk_2B4 = 0; + ObjUm_SetupAction(this, ObjUm_RanchWait); + } + } else if (this->type == OBJ_UM_TYPE_PRE_MILK_RUN) { + if (!(gSaveContext.save.weekEventReg[31] & 0x80) || (gSaveContext.save.weekEventReg[52] & 1)) { + Actor_MarkForDeath(&this->dyna.actor); + return; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Um/func_80B78E88.s") + if (!(gSaveContext.save.weekEventReg[52] & 2)) { + this->pathIndex = this->initialPathIndex; + sp54 = false; + func_800FE484(); + ObjUm_SetupAction(this, ObjUm_PreMilkRunStartCs); + this->unk_354 = 0; + ObjUm_RotatePlayer(this, play, 0); + } + } else if (this->type == OBJ_UM_TYPE_MILK_RUN_MINIGAME) { + if (!(gSaveContext.save.weekEventReg[31] & 0x80)) { + Actor_MarkForDeath(&this->dyna.actor); + return; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Um/func_80B78EBC.s") + this->pathIndex = this->initialPathIndex; + sp54 = false; + func_800FE484(); + ObjUm_SetupAction(this, ObjUm_StartCs); + this->unk_354 = 0; + ObjUm_RotatePlayer(this, play, 0); + } else if (this->type == OBJ_UM_TYPE_POST_MILK_RUN) { + if (!(gSaveContext.save.weekEventReg[52] & 1) || (gSaveContext.save.weekEventReg[59] & 2)) { + Actor_MarkForDeath(&this->dyna.actor); + return; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Um/func_80B78EFC.s") + this->pathIndex = this->initialPathIndex; + sp54 = false; + func_800FE484(); + ObjUm_SetupAction(this, ObjUm_PostMilkRunStartCs); + this->unk_354 = 0; + ObjUm_RotatePlayer(this, play, 0); + func_801A3098(NA_BGM_CLEAR_EVENT); + } else { + this->type = OBJ_UM_TYPE_TERMINA_FIELD; + ObjUm_SetupAction(this, ObjUm_TerminaFieldIdle); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Um/ObjUm_Init.s") + this->unk_2F8 = this->unk_2FE = gZeroVec3s; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Um/ObjUm_Destroy.s") + if (sp54) { + DynaPolyActor_Init(&this->dyna, 0); + DynaPolyActor_LoadMesh(play, &this->dyna, &object_um_Colheader_007E20); + } else { + DynaPolyActor_Init(&this->dyna, 3); + DynaPolyActor_LoadMesh(play, &this->dyna, &object_um_Colheader_007F50); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Um/func_80B79524.s") + if (this->dyna.bgId == BGCHECK_SCENE) { + Actor_MarkForDeath(&this->dyna.actor); + return; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Um/func_80B79560.s") + func_800C636C(play, &play->colCtx.dyna, this->dyna.bgId); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Um/func_80B795A0.s") + this->donkey = + (EnHorse*)Actor_Spawn(&play->actorCtx, play, ACTOR_EN_HORSE, this->dyna.actor.world.pos.x, + this->dyna.actor.world.pos.y, this->dyna.actor.world.pos.z, 0, + this->dyna.actor.shape.rot.y, 0, ENHORSE_PARAMS(ENHORSE_PARAM_DONKEY, ENHORSE_18)); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Um/func_80B79734.s") + if (this->donkey == NULL) { + Actor_MarkForDeath(&this->dyna.actor); + return; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Um/func_80B797EC.s") + Collider_InitAndSetCylinder(play, &this->banditsCollisions[0], &this->dyna.actor, &sCylinderInit); + Collider_InitAndSetCylinder(play, &this->banditsCollisions[1], &this->dyna.actor, &sCylinderInit); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Um/func_80B7984C.s") +void ObjUm_Destroy(Actor* thisx, PlayState* play) { + ObjUm* this = THIS; + s32 i; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Um/func_80B79A24.s") + DynaPoly_DeleteBgActor(play, &play->colCtx.dyna, this->dyna.bgId); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Um/func_80B79A50.s") + for (i = 0; i < ARRAY_COUNT(this->potPos); i++) { + AudioSfx_StopByPos(&this->potPos[i]); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Um/func_80B79BA0.s") + Collider_DestroyCylinder(play, &this->banditsCollisions[0]); + Collider_DestroyCylinder(play, &this->banditsCollisions[1]); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Um/func_80B79F10.s") +// ObjUm_MarkMyDonkeyAndMyselfForDeath, ObjUm_TerminateMe, ObjUmn't, ObjUm_Asinucide +void func_80B79524(ObjUm* this) { + Actor_MarkForDeath(&this->dyna.actor); + if (this->donkey != NULL) { + Actor_MarkForDeath(&this->donkey->actor); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Um/func_80B79FFC.s") +void func_80B79560(PlayState* play, ObjUm* this, s32 arg2, u16 textId) { + // "Thanks, I rely on you" + if (textId == 0x33BF) { + ObjUm_SetupAction(this, ObjUm_StartCs); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Um/func_80B7A070.s") +s32 func_80B795A0(PlayState* play, ObjUm* this, s32 arg2) { + s32 pad[2]; + s32 phi_v1 = true; + u16 textId = this->dyna.actor.textId; + Player* player; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Um/func_80B7A0E0.s") + switch (textId) { + // "I'll go to town" + case 0x33B4: + // "Want a ride?" + case 0x33CF: + gSaveContext.save.weekEventReg[31] |= 0x40; + if (play->msgCtx.choiceIndex == 0) { + player = GET_PLAYER(play); + func_8019F208(); + gSaveContext.save.weekEventReg[31] |= 0x80; + play->nextEntrance = ENTRANCE(ROMANI_RANCH, 11); + if (player->stateFlags1 & PLAYER_STATE1_800000) { + D_801BDAA0 = 1; + } + play->transitionType = TRANS_TYPE_64; + gSaveContext.nextTransitionType = TRANS_TYPE_03; + play->transitionTrigger = TRANS_TRIGGER_START; + phi_v1 = true; + } else { + Actor_ContinueText(play, &this->dyna.actor, 0x33B5); + func_8019F230(); + func_80151BB4(play, 6); + phi_v1 = false; + } + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Um/func_80B7A144.s") + // "I'll go as fast as I can!" + case 0x33BB: + Actor_ContinueText(play, &this->dyna.actor, 0x33BC); + phi_v1 = false; + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Um/func_80B7A1B4.s") + // "Chase pursuers with your arrows." + case 0x33BC: + Actor_ContinueText(play, &this->dyna.actor, 0x33BD); + phi_v1 = false; + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Um/func_80B7A240.s") + // "Understand?" + case 0x33BD: + if (play->msgCtx.choiceIndex == 0) { + Actor_ContinueText(play, &this->dyna.actor, 0x33BE); + func_8019F230(); + } else { + Actor_ContinueText(play, &this->dyna.actor, 0x33BF); + func_8019F208(); + } + phi_v1 = false; + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Um/func_80B7A2AC.s") + // "I'll tell you again!" + case 0x33BE: + Actor_ContinueText(play, &this->dyna.actor, 0x33BC); + phi_v1 = false; + break; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Um/func_80B7A394.s") + return phi_v1; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Um/func_80B7A400.s") +s32 func_80B79734(PlayState* play, ObjUm* this, s32 arg2) { + MessageContext* msgCtx = &play->msgCtx; + s32 ret = false; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Um/func_80B7A494.s") + switch (Message_GetState(msgCtx)) { + case TEXT_STATE_CLOSING: + func_80B79560(play, this, arg2, this->dyna.actor.textId); + return true; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Um/func_80B7A614.s") + case TEXT_STATE_CHOICE: + case TEXT_STATE_5: + if (Message_ShouldAdvance(play) && func_80B795A0(play, this, arg2)) { + msgCtx->msgMode = 0x43; + ret = true; + } + break; + } + return ret; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Um/func_80B7A7AC.s") +u16 ObjUm_RanchGetDialogue(PlayState* play, ObjUm* this, s32 arg2) { + u16 textId = 0; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Um/func_80B7A860.s") + if (gSaveContext.save.playerForm == PLAYER_FORM_HUMAN) { + if (gSaveContext.save.weekEventReg[31] & 0x40) { + // "Want a ride?" + textId = 0x33CF; + } else { + // "I'll deliver milk" + textId = 0x33B4; + } + } else { + textId = 0x33B7; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Um/func_80B7AB78.s") + if (textId == 0) { + textId = 1; + } + return textId; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Um/func_80B7ABE4.s") +s32 func_80B7984C(PlayState* play, ObjUm* this, s32 arg2, s32* arg3) { + s16 temp_v0_2; + s16 phi_v1; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Um/func_80B7AC94.s") + if (*arg3 == 4) { + return 0; + } + if (*arg3 == 2) { + Message_StartTextbox(play, this->dyna.actor.textId, &this->dyna.actor); + *arg3 = 1; + return 0; + } + if (*arg3 == 3) { + func_80151938(play, this->dyna.actor.textId); + *arg3 = 1; + return 0; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Um/func_80B7AD34.s") + if (Actor_ProcessTalkRequest(&this->dyna.actor, &play->state)) { + *arg3 = 1; + return 1; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Um/func_80B7AE58.s") + if (*arg3 == 1) { + if (func_80B79734(play, this, arg2)) { + *arg3 = 0; + } + return 0; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Um/func_80B7AEFC.s") + phi_v1 = this->dyna.actor.yawTowardsPlayer - this->dyna.actor.shape.rot.y; + temp_v0_2 = ABS_ALT(phi_v1); + if (temp_v0_2 >= 0x4E20) { + return 0; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Um/func_80B7AF30.s") + if ((this->dyna.actor.xyzDistToPlayerSq > SQ(100.0f)) && !this->dyna.actor.isTargeted) { + return 0; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Um/func_80B7B154.s") + if (this->dyna.actor.xyzDistToPlayerSq <= SQ(50.0f)) { + if (func_800B8614(&this->dyna.actor, play, 50.0f)) { + this->dyna.actor.textId = ObjUm_RanchGetDialogue(play, this, arg2); + } + } else if (func_800B863C(&this->dyna.actor, play)) { + this->dyna.actor.textId = ObjUm_RanchGetDialogue(play, this, arg2); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Um/func_80B7B18C.s") + return 0; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Um/ObjUm_Update.s") +s32 func_80B79A24(s32 arg0) { + switch (arg0) { + case 1: + case 2: + case 3: + return true; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Um/func_80B7B598.s") + default: + return false; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Um/func_80B7B93C.s") +void ObjUm_RanchWait(ObjUm* this, PlayState* play) { + Player* player = GET_PLAYER(play); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Um/func_80B7BABC.s") + this->dyna.actor.flags |= ACTOR_FLAG_1; + SkelAnime_Update(&this->skelAnime); + ObjUm_ChangeAnim(this, play, OBJ_UM_ANIM_IDLE); + this->flags |= OBJ_UM_FLAG_WAITING; + if ((gSaveContext.save.time > CLOCK_TIME(18, 0)) && (gSaveContext.save.time <= CLOCK_TIME(19, 0))) { + if (!(player->stateFlags1 & PLAYER_STATE1_800000)) { + func_80B7984C(play, this, 0, &this->unk_2B4); + } + } else if (!func_80B79A24(this->unk_2B4) && (gSaveContext.save.time > CLOCK_TIME(19, 0))) { + gSaveContext.save.weekEventReg[34] |= 0x80; + ObjUm_SetupAction(this, ObjUm_RanchWaitPathFinished); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Um/func_80B7BEA4.s") + switch (play->msgCtx.currentTextId) { + default: + this->unk_4CC = 0; + this->mouthTexIndex = 0; + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Um/ObjUm_Draw.s") + // "I'm worried about my sister" + case 0x33B7: + // "I'll deliver milk" + case 0x33B4: + this->unk_4CC = 0; + this->mouthTexIndex = 1; + break; + + // "I'll leave at 7" + case 0x33B5: + this->unk_4CC = 3; + this->mouthTexIndex = 1; + break; + } +} + +typedef enum ObjUmPathState { + /* 0 */ OBJUM_PATH_STATE_0, + /* 1 */ OBJUM_PATH_STATE_1, + /* 2 */ OBJUM_PATH_STATE_FINISH, + /* 3 */ OBJUM_PATH_STATE_3, + /* 4 */ OBJUM_PATH_STATE_4, +} ObjUmPathState; + +ObjUmPathState ObjUm_UpdatePath(ObjUm* this, PlayState* play) { + Path* path = &play->setupPathList[this->pathIndex]; + s32 pathCount; + Vec3s* pathPoints; + f32 xDiff; + f32 zDiff; + Vec3f sp50; + f32 sp4C; + f32 sp48; + f32 sp44; + s32 angle; + ObjUmPathState sp3C; + s16 yawDiff; + + pathCount = path->count; + pathPoints = Lib_SegmentedToVirtual(path->points); + sp3C = OBJUM_PATH_STATE_0; + + if (pathCount == 0) { + return 0; + } + + Math_Vec3s_ToVec3f(&sp50, &pathPoints[this->pointIndex]); + + if (this->pointIndex == 0) { + xDiff = pathPoints[1].x - pathPoints[0].x; + zDiff = pathPoints[1].z - pathPoints[0].z; + } else if ((this->pointIndex + 1) == path->count) { + xDiff = pathPoints[path->count - 1].x - pathPoints[path->count - 2].x; + zDiff = pathPoints[path->count - 1].z - pathPoints[path->count - 2].z; + } else { + xDiff = pathPoints[this->pointIndex + 1].x - pathPoints[this->pointIndex - 1].x; + zDiff = pathPoints[this->pointIndex + 1].z - pathPoints[this->pointIndex - 1].z; + } + + angle = Math_Atan2S(xDiff, zDiff); + + func_8017B7F8(&sp50, angle, &sp4C, &sp48, &sp44); + if (((this->dyna.actor.world.pos.x * sp4C) + (sp48 * this->dyna.actor.world.pos.z) + sp44) > 0.0f) { + this->pointIndex++; + + if (this->pointIndex >= (pathCount - 7)) { + sp3C = OBJUM_PATH_STATE_3; + } + if (this->pointIndex >= (pathCount - 3)) { + sp3C = OBJUM_PATH_STATE_1; + } + if (this->pointIndex >= (pathCount - 2)) { + sp3C = OBJUM_PATH_STATE_4; + } + if (this->pointIndex >= pathCount) { + this->pointIndex = 0; + sp3C = OBJUM_PATH_STATE_FINISH; + } + + Math_Vec3s_ToVec3f(&sp50, &pathPoints[this->pointIndex]); + } + + if (this->donkey != NULL) { + this->dyna.actor.world.rot.y = Math_Vec3f_Yaw(&this->dyna.actor.world.pos, &sp50); + func_800F415C(&this->donkey->actor, &sp50, 0x190); + + if (1) {} + + yawDiff = this->donkey->actor.shape.rot.y - this->dyna.actor.shape.rot.y; + if (fabsf(yawDiff) < 2730.0f) { + if (fabsf(yawDiff) < 100.0f) { + this->dyna.actor.shape.rot.y = this->donkey->actor.shape.rot.y; + } else if (yawDiff > 0) { + this->dyna.actor.shape.rot.y = this->dyna.actor.shape.rot.y + 0x64; + yawDiff = 0x64; + } else if (yawDiff < 0) { + this->dyna.actor.shape.rot.y = this->dyna.actor.shape.rot.y - 0x64; + yawDiff = -0x64; + } + } else if (yawDiff > 0) { + this->dyna.actor.shape.rot.y = this->dyna.actor.shape.rot.y + 0x190; + yawDiff = 0x190; + } else if (yawDiff < 0) { + this->dyna.actor.shape.rot.y = this->dyna.actor.shape.rot.y - 0x190; + yawDiff = -0x190; + } + + if (this->flags & (OBJ_UM_FLAG_0010 | OBJ_UM_FLAG_0004)) { + ObjUm_RotatePlayerView(this, play, yawDiff); + } + } + + if (this->animIndex == OBJ_UM_ANIM_TROT) { + this->dyna.actor.speedXZ = 4.0f; + } else if (this->animIndex == OBJ_UM_ANIM_GALLOP) { + this->dyna.actor.speedXZ = 8.0f; + } + + return sp3C; +} + +void ObjUm_RanchWaitPathFinished(ObjUm* this, PlayState* play) { + this->wheelRot += 0x3E8; + this->flags &= ~OBJ_UM_FLAG_WAITING; + ObjUm_ChangeAnim(this, play, OBJ_UM_ANIM_TROT); + + switch (ObjUm_UpdatePath(this, play)) { + case OBJUM_PATH_STATE_1: + case OBJUM_PATH_STATE_FINISH: + if (gSaveContext.save.weekEventReg[31] & 0x80) { + ActorCutscene_Stop(this->dyna.actor.cutscene); + play->nextEntrance = ENTRANCE(MILK_ROAD, 5); + play->transitionType = TRANS_TYPE_64; + gSaveContext.nextTransitionType = TRANS_TYPE_03; + play->transitionTrigger = TRANS_TRIGGER_START; + } else { + func_80B79524(this); + } + break; + + default: + Actor_MoveWithGravity(&this->dyna.actor); + break; + } +} + +void ObjUm_RanchStartCs(ObjUm* this, PlayState* play) { + ObjUm_ChangeAnim(this, play, OBJ_UM_ANIM_IDLE); + + if (ActorCutscene_GetCanPlayNext(this->dyna.actor.cutscene)) { + ActorCutscene_StartAndSetUnkLinkFields(this->dyna.actor.cutscene, &this->dyna.actor); + this->lastTime = gSaveContext.save.time; + ObjUm_SetupAction(this, func_80B7A0E0); + } else { + ActorCutscene_SetIntentToPlay(this->dyna.actor.cutscene); + } +} + +void func_80B7A070(ObjUm* this, PlayState* play) { + ObjUm_RanchWaitPathFinished(this, play); + ObjUm_RotatePlayer(this, play, 0); + + switch (play->msgCtx.currentTextId) { + case 0x33B6: + this->unk_4CC = 1; + this->mouthTexIndex = 1; + break; + + default: + this->unk_4CC = 0; + this->mouthTexIndex = 0; + break; + } +} + +void func_80B7A0E0(ObjUm* this, PlayState* play) { + ObjUm_ChangeAnim(this, play, OBJ_UM_ANIM_IDLE); + if (gSaveContext.save.time != this->lastTime) { + ObjUm_ChangeAnim(this, play, OBJ_UM_ANIM_TROT); + ObjUm_SetupAction(this, func_80B7A070); + } +} + +void func_80B7A144(ObjUm* this, PlayState* play) { + Player* player = GET_PLAYER(play); + + ObjUm_SetPlayerPosition(this, play); + this->flags |= OBJ_UM_FLAG_0100; + this->flags |= OBJ_UM_FLAG_0004; + player->stateFlags1 |= PLAYER_STATE1_20; + ObjUm_ChangeAnim(this, play, OBJ_UM_ANIM_IDLE); + ObjUm_SetupAction(this, ObjUm_RanchStartCs); +} + +void ObjUm_PreMilkRunDialogueHandler(ObjUm* this, PlayState* play) { + ObjUm_SetPlayerPosition(this, play); + this->flags |= OBJ_UM_FLAG_0004; + + switch (play->msgCtx.currentTextId) { + case 0x33B8: + this->unk_4CC = 0; + this->mouthTexIndex = 3; + break; + + case 0x33B9: + this->unk_4CC = 2; + this->mouthTexIndex = 0; + break; + + default: + this->flags &= ~OBJ_UM_FLAG_LOOK_BACK; + this->unk_4CC = 0; + this->mouthTexIndex = 0; + break; + } +} + +void func_80B7A240(ObjUm* this, PlayState* play) { + ObjUm_ChangeAnim(this, play, OBJ_UM_ANIM_IDLE); + if (gSaveContext.save.time != this->lastTime) { + ObjUm_SetupAction(this, func_80B7A2AC); + } + + this->lastTime = gSaveContext.save.time; + ObjUm_PreMilkRunDialogueHandler(this, play); +} + +void func_80B7A2AC(ObjUm* this, PlayState* play) { + this->wheelRot += 0x3E8; + ObjUm_ChangeAnim(this, play, OBJ_UM_ANIM_TROT); + + switch (ObjUm_UpdatePath(this, play)) { + case OBJUM_PATH_STATE_1: + case OBJUM_PATH_STATE_FINISH: + play->nextEntrance = ENTRANCE(GORMAN_TRACK, 4); + play->transitionType = TRANS_TYPE_64; + gSaveContext.nextTransitionType = TRANS_TYPE_03; + play->transitionTrigger = TRANS_TRIGGER_START; + break; + + default: + if (gSaveContext.save.time == this->lastTime) { + ObjUm_SetupAction(this, func_80B7A240); + } + + this->lastTime = gSaveContext.save.time; + Actor_MoveWithGravity(&this->dyna.actor); + ObjUm_PreMilkRunDialogueHandler(this, play); + break; + } +} + +void func_80B7A394(ObjUm* this, PlayState* play) { + ObjUm_SetPlayerPosition(this, play); + this->flags |= OBJ_UM_FLAG_0004; + if (gSaveContext.save.time != this->lastTime) { + ObjUm_ChangeAnim(this, play, OBJ_UM_ANIM_TROT); + ObjUm_SetupAction(this, func_80B7A2AC); + } +} + +void ObjUm_PreMilkRunStartCs(ObjUm* this, PlayState* play) { + Player* player = GET_PLAYER(play); + + ObjUm_SetPlayerPosition(this, play); + this->flags |= OBJ_UM_FLAG_0004; + player->stateFlags1 |= PLAYER_STATE1_20; + if (ActorCutscene_GetCanPlayNext(this->dyna.actor.cutscene)) { + ActorCutscene_StartAndSetUnkLinkFields(this->dyna.actor.cutscene, &this->dyna.actor); + this->lastTime = gSaveContext.save.time; + ObjUm_SetupAction(this, func_80B7A394); + } else { + ActorCutscene_SetIntentToPlay(this->dyna.actor.cutscene); + } +} + +void ObjUm_RunMinigame(ObjUm* this, PlayState* play) { + ObjUm_SetPlayerPosition(this, play); + ObjUm_RotatePlayer(this, play, 0x7FFF); + this->wheelRot += 0x7D0; + this->flags |= OBJ_UM_FLAG_0010; + ObjUm_ChangeAnim(this, play, OBJ_UM_ANIM_GALLOP); + + switch (ObjUm_UpdatePath(this, play)) { + case OBJUM_PATH_STATE_1: + case OBJUM_PATH_STATE_FINISH: + gSaveContext.seqIndex = 0xFF; + gSaveContext.save.weekEventReg[31] &= (u8)~0x80; + gSaveContext.nightSeqIndex = 0xFF; + + if (!(gSaveContext.save.weekEventReg[52] & 1) && !(gSaveContext.save.weekEventReg[52] & 2)) { + if (!this->areAllPotsBroken) { + play->nextEntrance = ENTRANCE(MILK_ROAD, 6); + play->transitionType = TRANS_TYPE_64; + gSaveContext.nextTransitionType = TRANS_TYPE_03; + play->transitionTrigger = TRANS_TRIGGER_START; + gSaveContext.save.weekEventReg[52] |= 1; + gSaveContext.save.weekEventReg[52] &= (u8)~2; + } else { + play->nextEntrance = ENTRANCE(ROMANI_RANCH, 8); + play->transitionType = TRANS_TYPE_64; + gSaveContext.nextTransitionType = TRANS_TYPE_03; + play->transitionTrigger = TRANS_TRIGGER_START; + gSaveContext.save.weekEventReg[52] |= 2; + gSaveContext.save.weekEventReg[52] &= (u8)~1; + } + } + break; + + default: + Actor_MoveWithGravity(&this->dyna.actor); + func_80B78DF0(this, play); + break; + } +} + +void func_80B7A614(ObjUm* this, PlayState* play) { + s32 pad; + + ObjUm_SetPlayerPosition(this, play); + ObjUm_RotatePlayer(this, play, 0x7FFF); + this->wheelRot += 0x7D0; + this->flags |= OBJ_UM_FLAG_0010; + this->flags |= OBJ_UM_FLAG_PLAYING_MINIGAME; + ObjUm_ChangeAnim(this, play, OBJ_UM_ANIM_GALLOP); + + if (ObjUm_UpdatePath(this, play) == OBJUM_PATH_STATE_3 && this->unk_4DC == 0) { + this->unk_4DC = 1; + } else if (this->unk_4DC > 0) { + if (this->unk_4DC == 1) { + s32 i; + + this->areAllPotsBroken = true; + + for (i = 0; i < ARRAY_COUNT(this->potsLife); i++) { + if (this->potsLife[i] != 1) { + this->areAllPotsBroken = false; + break; + } + } + + this->flags |= OBJ_UM_FLAG_MINIGAME_FINISHED; + } + + this->unk_4DC++; + } + + if (this->flags & OBJ_UM_FLAG_MINIGAME_FINISHED) { + s32 sp20 = ActorCutscene_GetAdditionalCutscene(this->dyna.actor.cutscene); + + if (this->areAllPotsBroken) { + sp20 = ActorCutscene_GetAdditionalCutscene(sp20); + } + if (ActorCutscene_GetCanPlayNext(sp20)) { + ActorCutscene_StartAndSetUnkLinkFields(sp20, &this->dyna.actor); + ObjUm_SetupAction(this, ObjUm_RunMinigame); + this->flags &= ~OBJ_UM_FLAG_PLAYING_MINIGAME; + } else { + ActorCutscene_SetIntentToPlay(sp20); + } + } + + Actor_MoveWithGravity(&this->dyna.actor); + func_80B78DF0(this, play); +} + +void func_80B7A7AC(ObjUm* this, PlayState* play) { + Player* player = GET_PLAYER(play); + + this->unk_4DC = 0; + this->areAllPotsBroken = false; + player->stateFlags1 &= ~PLAYER_STATE1_20; + ObjUm_SetPlayerPosition(this, play); + ObjUm_RotatePlayer(this, play, 0x7FFF); + func_80B78EBC(this, play); + this->flags |= OBJ_UM_FLAG_0010; + func_80B78DF0(this, play); + this->flags |= 4; + ObjUm_ChangeAnim(this, play, OBJ_UM_ANIM_GALLOP); + ObjUm_SetupAction(this, func_80B7A614); +} + +void func_80B7A860(ObjUm* this, PlayState* play) { + ObjUm_SetPlayerPosition(this, play); + ObjUm_RotatePlayer(this, play, 0); + this->flags |= OBJ_UM_FLAG_0004; + + if (play->csCtx.frames == 449) { + ObjUm_InitBandits(this, play); + } else if (play->csCtx.frames >= 450) { + func_80B78DF0(this, play); + } + + if (play->csCtx.state == 0) { + ActorCutscene_Stop(this->dyna.actor.cutscene); + ObjUm_SetupAction(this, func_80B7A7AC); + } + + switch (play->msgCtx.currentTextId) { + case 0x33BA: + this->unk_4CC = 2; + this->mouthTexIndex = 3; + break; + + // "We'll go through here as fast as we can" + case 0x33BB: + if ((fabsf(this->skelAnime.curFrame) < 0.008f) && !(this->flags & OBJ_UM_FLAG_1000)) { + this->flags |= OBJ_UM_FLAG_1000; + this->unk_4CC = 4; + this->mouthTexIndex = 0; + } else if (fabsf(this->skelAnime.morphWeight) < 0.008f) { + this->unk_4CC = 2; + this->mouthTexIndex = 2; + } else { + this->unk_4CC = 5; + this->mouthTexIndex = 0; + } + + this->flags |= OBJ_UM_FLAG_LOOK_BACK; + break; + + // "Chase pursuers with your arrows" + case 0x33BC: + if ((fabsf(this->skelAnime.curFrame) < 0.008f) && !(this->flags & OBJ_UM_FLAG_1000)) { + this->flags |= OBJ_UM_FLAG_1000; + this->unk_4CC = 4; + this->mouthTexIndex = 0; + } else if (fabsf(this->skelAnime.morphWeight) < 0.008f) { + this->unk_4CC = 2; + this->mouthTexIndex = 2; + } else { + this->unk_4CC = 5; + this->mouthTexIndex = 0; + } + this->flags |= OBJ_UM_FLAG_LOOK_BACK; + break; + + // "Understand?" + case 0x33BD: + if ((fabsf(this->skelAnime.curFrame) < 0.008f) && !(this->flags & OBJ_UM_FLAG_1000)) { + this->flags |= OBJ_UM_FLAG_1000; + this->unk_4CC = 4; + this->mouthTexIndex = 0; + } else if (fabsf(this->skelAnime.morphWeight) < 0.008f) { + this->unk_4CC = 2; + } else { + this->unk_4CC = 5; + } + this->mouthTexIndex = 0; + this->unk_4D8 = 0; + this->flags |= OBJ_UM_FLAG_LOOK_BACK; + break; + + case 0x33BE: + this->flags |= OBJ_UM_FLAG_LOOK_BACK; + this->unk_4CC = 2; + this->mouthTexIndex = 3; + break; + + case 0x33BF: + this->unk_4D8++; + if ((fabsf(this->skelAnime.morphWeight) < 0.008f) && this->unk_4D8 >= 6) { + this->unk_4CC = 0; + this->mouthTexIndex = 0; + } else { + this->unk_4CC = 2; + this->mouthTexIndex = 2; + } + this->flags &= ~OBJ_UM_FLAG_LOOK_BACK; + break; + + default: + this->unk_4CC = 0; + this->mouthTexIndex = 0; + break; + } +} + +void func_80B7AB78(ObjUm* this, PlayState* play) { + ObjUm_ChangeAnim(this, play, OBJ_UM_ANIM_IDLE); + if (gSaveContext.save.time != this->lastTime) { + ObjUm_SetupAction(this, func_80B7ABE4); + } + + this->lastTime = gSaveContext.save.time; + func_80B7A860(this, play); +} + +void func_80B7ABE4(ObjUm* this, PlayState* play) { + this->wheelRot += 0x3E8; + + ObjUm_ChangeAnim(this, play, OBJ_UM_ANIM_TROT); + switch (ObjUm_UpdatePath(this, play)) { + case OBJUM_PATH_STATE_FINISH: + func_80B79524(this); + break; + + default: + if (gSaveContext.save.time == this->lastTime) { + ObjUm_SetupAction(this, func_80B7AB78); + } + + this->lastTime = gSaveContext.save.time; + Actor_MoveWithGravity(&this->dyna.actor); + func_80B7A860(this, play); + break; + } +} + +void ObjUm_StartCs(ObjUm* this, PlayState* play) { + Player* player = GET_PLAYER(play); + + player->stateFlags1 |= PLAYER_STATE1_20; + ObjUm_SetPlayerPosition(this, play); + ObjUm_RotatePlayer(this, play, 0); + this->flags |= OBJ_UM_FLAG_0004; + + if (ActorCutscene_GetCanPlayNext(this->dyna.actor.cutscene)) { + ActorCutscene_StartAndSetUnkLinkFields(this->dyna.actor.cutscene, &this->dyna.actor); + this->lastTime = gSaveContext.save.time; + ObjUm_SetupAction(this, func_80B7ABE4); + } else { + ActorCutscene_SetIntentToPlay(this->dyna.actor.cutscene); + } +} + +void ObjUm_PostMilkRunWaitPathFinished(ObjUm* this, PlayState* play) { + Player* player = GET_PLAYER(play); + + player->stateFlags1 |= PLAYER_STATE1_20; + ObjUm_SetPlayerPosition(this, play); + ObjUm_RotatePlayer(this, play, 0); + this->flags |= OBJ_UM_FLAG_0004; + this->wheelRot += 0x3E8; + ObjUm_ChangeAnim(this, play, OBJ_UM_ANIM_TROT); + + if ((ObjUm_UpdatePath(this, play) == OBJUM_PATH_STATE_4) && !(gSaveContext.save.weekEventReg[59] & 2)) { + ActorCutscene_Stop(this->dyna.actor.cutscene); + Audio_SetCutsceneFlag(false); + gSaveContext.save.weekEventReg[59] |= 2; + gSaveContext.nextCutsceneIndex = 0xFFF3; + play->nextEntrance = ENTRANCE(TERMINA_FIELD, 0); + play->transitionType = TRANS_TYPE_64; + gSaveContext.nextTransitionType = TRANS_TYPE_03; + play->transitionTrigger = TRANS_TRIGGER_START; + gSaveContext.save.time += CLOCK_TIME(1, 0) + 2; + } + Actor_MoveWithGravity(&this->dyna.actor); +} + +void ObjUm_PostMilkRunStartCs(ObjUm* this, PlayState* play) { + Player* player = GET_PLAYER(play); + + player->stateFlags1 |= PLAYER_STATE1_20; + ObjUm_SetPlayerPosition(this, play); + ObjUm_RotatePlayer(this, play, 0); + this->flags |= OBJ_UM_FLAG_0004; + ObjUm_ChangeAnim(this, play, OBJ_UM_ANIM_IDLE); + + if (ActorCutscene_GetCanPlayNext(this->dyna.actor.cutscene)) { + ActorCutscene_StartAndSetUnkLinkFields(this->dyna.actor.cutscene, &this->dyna.actor); + ObjUm_SetupAction(this, ObjUm_PostMilkRunWaitPathFinished); + } else { + ActorCutscene_SetIntentToPlay(this->dyna.actor.cutscene); + } +} + +void ObjUm_TerminaFieldIdle(ObjUm* this, PlayState* play) { + ObjUm_ChangeAnim(this, play, OBJ_UM_ANIM_IDLE); + SkelAnime_Update(&this->skelAnime); +} + +void func_80B7AF30(ObjUm* this, PlayState* play) { + if (!(this->flags & OBJ_UM_FLAG_0001)) { + this->dyna.actor.shape.rot.x = 0; + this->dyna.actor.shape.rot.z = 0; + } else { + CollisionPoly* sp44; + s32 pad[2]; + Vec3f sp30; + + this->flags &= ~OBJ_UM_FLAG_0001; + + if (1) {} + + this->unk_2D0 = this->unk_2C4; + this->unk_2E8 = this->unk_2DC; + + this->unk_2D0.y = BgCheck_EntityRaycastFloor1(&play->colCtx, &sp44, &this->unk_2C4); + if (this->unk_2D0.y == BGCHECK_Y_MIN) { + this->unk_2D0.y = this->dyna.actor.floorHeight; + } + + if (1) {} + + this->unk_2E8.y = BgCheck_EntityRaycastFloor1(&play->colCtx, &sp44, &this->unk_2DC); + if (this->unk_2E8.y == BGCHECK_Y_MIN) { + this->unk_2E8.y = this->dyna.actor.floorHeight; + } + + sp30.x = (this->unk_2D0.x + this->unk_2E8.x) * 0.5f; + sp30.y = (this->unk_2D0.y + this->unk_2E8.y) * 0.5f; + sp30.z = (this->unk_2D0.z + this->unk_2E8.z) * 0.5f; + + this->dyna.actor.shape.rot.x = + (s16)Math_Atan2S(sp30.y - this->dyna.actor.world.pos.y, sqrtf(SQ(sp30.x - this->dyna.actor.world.pos.x) + + SQ(sp30.z - this->dyna.actor.world.pos.z))); + this->dyna.actor.shape.rot.z = (s16)-Math_Atan2S( + sp30.y - this->unk_2D0.y, sqrtf(SQ(sp30.x - this->unk_2D0.x) + SQ(sp30.z - this->unk_2D0.z))); + if (this->flags & OBJ_UM_FLAG_MOVING) { + this->dyna.actor.shape.rot.x += BINANG_SUB((Rand_ZeroOne() * 100.0f), 50.0f); + this->dyna.actor.shape.rot.z += BINANG_SUB((Rand_ZeroOne() * 100.0f), 50.0f); + } + } +} + +void ObjUm_DefaultAnim(ObjUm* this, PlayState* play) { + Animation_PlayOnce(&this->skelAnime, &gUmTrotAnim); + this->animIndex = OBJ_UM_ANIM_TROT; +} + +typedef struct { + /* 0x00 */ AnimationHeader* anim; + /* 0x04 */ s32 doesMove; // `true` if the animation is intended to be used while the actor is moving +} struct_80B7C25C; // size = 0x08 + +struct_80B7C25C sUmAnims[] = { + { &gUmTrotAnim, true }, // OBJ_UM_ANIM_TROT + { &gUmGallopAnim, true }, // OBJ_UM_ANIM_GALLOP + { &gUmIdleAnim, false }, // OBJ_UM_ANIM_IDLE + { NULL, false }, // OBJ_UM_ANIM_3 + { &gUmLookBackAnim, false }, // OBJ_UM_ANIM_LOOK_BACK +}; + +void ObjUm_ChangeAnim(ObjUm* this, PlayState* play, ObjUmAnimation animIndex) { + s32 changeAnim; + s32 temp; + s32 indexTemp = animIndex; + f32 animPlaybackSpeed = 0.0f; + + if (sUmAnims[animIndex].doesMove) { + this->flags |= OBJ_UM_FLAG_MOVING; + } else { + this->flags &= ~OBJ_UM_FLAG_MOVING; + } + + if (animIndex == OBJ_UM_ANIM_TROT) { + animPlaybackSpeed = this->dyna.actor.speedXZ * 0.25f; + } else if (animIndex == OBJ_UM_ANIM_GALLOP) { + animPlaybackSpeed = this->dyna.actor.speedXZ * 0.2f; + } else if (animIndex == OBJ_UM_ANIM_IDLE) { + animPlaybackSpeed = 1.0f; + } + this->skelAnime.playSpeed = animPlaybackSpeed; + + if (this->flags & OBJ_UM_FLAG_LOOK_BACK) { + this->skelAnime.playSpeed = 1.0f; + animIndex = OBJ_UM_ANIM_MINUS_1; + } + + changeAnim = (animIndex != this->animIndex); + if (SkelAnime_Update(&this->skelAnime) || changeAnim) { + this->animIndex = animIndex; + + if (animIndex != OBJ_UM_ANIM_MINUS_1) { + if (this->donkey != NULL) { + this->donkey->unk_538 = animIndex; + } + + if (changeAnim) { + Animation_MorphToPlayOnce(&this->skelAnime, sUmAnims[animIndex].anim, -3.0f); + } else { + Animation_PlayOnce(&this->skelAnime, sUmAnims[animIndex].anim); + } + } else { + EnHorse* donkey = this->donkey; + + if (donkey != NULL) { + donkey->unk_538 = indexTemp; + } + + if (changeAnim) { + temp = 3 - animIndex; // OBJ_UM_ANIM_LOOK_BACK + Animation_MorphToPlayOnce(&this->skelAnime, sUmAnims[temp].anim, -10.0f); + } else { + temp = 3 - animIndex; // OBJ_UM_ANIM_LOOK_BACK + Animation_PlayOnce(&this->skelAnime, sUmAnims[temp].anim); + } + } + } + + if (this->wheelRot / 0x199A != this->unk_420) { + this->unk_420 = this->wheelRot / 0x199A; + //! FAKE + if (!&sUmAnims[0]) {} + Actor_PlaySfxAtPos(&this->dyna.actor, NA_SE_EV_CART_WHEEL); + } +} + +void ObjUm_Update(Actor* thisx, PlayState* play) { + ObjUm* this = THIS; + + this->actionFunc(this, play); + this->unk_350++; + Actor_UpdateBgCheckInfo(play, &this->dyna.actor, 0.0f, 0.0f, 0.0f, 0x1C); + + if (this->donkey != NULL) { + this->donkey->actor.world.pos.x = this->dyna.actor.world.pos.x; + this->donkey->actor.world.pos.y = this->dyna.actor.floorHeight; + this->donkey->actor.world.pos.z = this->dyna.actor.world.pos.z; + } + + if (this->flags & OBJ_UM_FLAG_0010) { + func_80123F2C(play, 0x63); + this->flags &= ~OBJ_UM_FLAG_0010; + } else if (this->flags & OBJ_UM_FLAG_0004) { + func_80123F2C(play, -3); + this->flags &= ~OBJ_UM_FLAG_0004; + } + + if (this->flags & OBJ_UM_FLAG_0100) { + this->flags &= ~OBJ_UM_FLAG_0100; + ObjUm_RotatePlayer(this, play, 0); + func_80B78EBC(this, play); + } + + func_80B7AF30(this, play); + switch (this->unk_4CC) { + case 0: + switch (this->eyeTexIndex) { + case 0: + if (Rand_ZeroOne() < 0.025f) { + this->eyeTexIndex = 1; + } + break; + + case 1: + if (Rand_ZeroOne() < 0.6f) { + this->eyeTexIndex = 2; + } + break; + + case 2: + if (Rand_ZeroOne() < 0.6f) { + this->eyeTexIndex = 0; + } + break; + + default: + this->eyeTexIndex = 0; + break; + } + break; + + case 1: + this->eyeTexIndex = 3; + break; + case 2: + this->eyeTexIndex = 4; + break; + case 3: + this->eyeTexIndex = 5; + break; + case 4: + this->eyeTexIndex = 2; + break; + case 5: + this->eyeTexIndex = 0; + break; + default: + this->unk_4CC = 0; + this->eyeTexIndex = 0; + break; + } +} + +s32 ObjUm_OverrideLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, Actor* thisx) { + ObjUm* this = THIS; + Player* player = GET_PLAYER(play); + s32 pad; + s16 temp_v0_3; + Vec3f sp5C = { 4223.0f, -979.0f, 4098.0f }; + Vec3f sp50 = { 4223.0f, -980.0f, -4083.0f }; + + if ((limbIndex >= UM_LIMB_CREMIA_ROOT) && (this->type == OBJ_UM_TYPE_TERMINA_FIELD)) { + *dList = NULL; + return false; + } + + if (limbIndex == UM_LIMB_CREMIA_HEAD) { + OPEN_DISPS(play->state.gfxCtx); + + gSPSegment(POLY_OPA_DISP++, 0x08, Lib_SegmentedToVirtual(sEyeTextures[this->eyeTexIndex])); + gSPSegment(POLY_OPA_DISP++, 0x09, Lib_SegmentedToVirtual(sMouthTextures[this->mouthTexIndex])); + + CLOSE_DISPS(play->state.gfxCtx); + } + + if (limbIndex == UM_LIMB_WAGON_RIGHT_WHEEL) { + if (this->flags & OBJ_UM_FLAG_MOVING) { + rot->x = -this->wheelRot; + } + Matrix_MultVec3f(&sp5C, &this->unk_2C4); + } else if (limbIndex == UM_LIMB_WAGON_LEFT_WHEEL) { + if (this->flags & OBJ_UM_FLAG_MOVING) { + rot->x = this->wheelRot; + } + Matrix_MultVec3f(&sp50, &this->unk_2DC); + } else if ((limbIndex == UM_LIMB_CREMIA_HEAD) && (this->flags & OBJ_UM_FLAG_WAITING)) { + if (SubS_AngleDiffLessEqual(this->dyna.actor.shape.rot.y, 0x4E20, this->dyna.actor.yawTowardsPlayer) && + (this->dyna.actor.xzDistToPlayer < 500.0f)) { + s16 sp3E; + Vec3f sp30 = player->actor.world.pos; + + sp30.y = player->bodyPartsPos[7].y + 3.0f; + sp3E = Math_Vec3f_Yaw(&this->dyna.actor.focus.pos, &sp30) - this->dyna.actor.shape.rot.y; + temp_v0_3 = Math_Atan2S( + this->dyna.actor.focus.pos.y - sp30.y, + Math3D_XZLength(sp30.x - this->dyna.actor.focus.pos.x, sp30.z - this->dyna.actor.focus.pos.z)); + this->unk_2FE.x = rot->x + sp3E; + this->unk_2FE.y = rot->y; + this->unk_2FE.z = rot->z + temp_v0_3; + Math_SmoothStepToS(&this->unk_2F8.x, this->unk_2FE.x, 4, 0x3E8, 1); + Math_SmoothStepToS(&this->unk_2F8.z, this->unk_2FE.z, 4, 0x3E8, 1); + this->unk_2F8.y = rot->y; + rot->x = this->unk_2F8.x; + rot->z = this->unk_2F8.z; + } else { + this->unk_2FE.x = rot->x; + this->unk_2FE.y = rot->y; + this->unk_2FE.z = rot->z; + Math_SmoothStepToS(&this->unk_2F8.x, this->unk_2FE.x, 4, 0x3E8, 1); + Math_SmoothStepToS(&this->unk_2F8.z, this->unk_2FE.z, 4, 0x3E8, 1); + this->unk_2F8.y = rot->y; + rot->x = this->unk_2F8.x; + rot->z = this->unk_2F8.z; + } + } else if ((limbIndex == UM_LIMB_WAGON_CART_COVER) && (this->flags & OBJ_UM_FLAG_PLAYING_MINIGAME)) { + *dList = NULL; + } + + return false; +} + +void ObjUm_SpawnFragments(PlayState* play, Vec3f* potPos) { + Vec3f sp8C = { 0.0f, -1.0f, 0.0f }; + Gfx* potFragments[] = { object_um_DL_000040, object_um_DL_000910, object_um_DL_0011E0 }; + s32 i; + Vec3f sp70; + + EffectSsHitmark_SpawnFixedScale(play, 0, potPos); + + for (i = 0; i < 20; i++) { + sp70.x = (Rand_ZeroOne() * 20.0f) - 10.0f; + sp70.y = -((Rand_ZeroOne() * 20.0f) - 10.0f); + sp70.z = (Rand_ZeroOne() * 20.0f) - 10.0f; + EffectSsHahen_Spawn(play, potPos, &sp70, &sp8C, 1, 100, OBJECT_UM, 10, + potFragments[(s32)(Rand_ZeroOne() * ARRAY_COUNT(potFragments))]); + } +} + +void ObjUm_PostLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx) { + ObjUm* this = THIS; + GraphicsContext* gfxCtx = play->state.gfxCtx; + Mtx* mtx_s3; + Gfx* spFC[] = { + NULL, gUmBrokenMinigamePotDL, gUmMinigamePotDL, gUmMinigamePotDL, gUmMinigamePotDL, object_um_DL_0067C0 + }; + Gfx* spE4[] = { NULL, NULL, object_um_DL_004B60, object_um_DL_0043E0, NULL, NULL }; + f32 spCC[] = { 0.0f, 1070.0f, 1070.0f, 1070.0f, 1070.0f, 2100.0f }; + Vec3f spC0 = gZeroVec3f; + Vec3f calcPotPos; + f32 spB0; + + spC0.y += 1700.0f; + + if (limbIndex == UM_LIMB_WAGON_CART_BED) { + Vec3f spA4 = { 2000.0f, 1070.0f, 0.0f }; + + Matrix_MultVec3f(&spA4, &this->unk_308); + this->flags |= OBJ_UM_FLAG_DRAWN_FLOOR; + } + + if (limbIndex == UM_LIMB_WAGON_CART_BED) { + Vec3f sp98 = { 2500.0f, 200.0f, 0.0f }; + + Matrix_MultVec3f(&sp98, &this->cartBedPos); + } + + if (limbIndex == UM_LIMB_WAGON_CART_BED) { + Vec3f* potPos; + Vec3f sp88; + Vec3s sp80; + s32 i; + f32 sp70[] = { 2000.0f, 0.0f, -2000.0f }; + + //! FAKE + if (!i) {} + + sp80.x = 0; + sp80.z = 0; + sp88.x = 6800.0f; + OPEN_DISPS(gfxCtx); + + for (i = 0; i < ARRAY_COUNT(this->potsLife); i++) { + sp88.z = sp70[i]; + sp88.y = spCC[this->potsLife[i]]; + + if (this->potsLife[i] == 5) { + sp80.y = 0x4000; + } else { + sp80.y = -0x4000; + } + + Matrix_Push(); + Matrix_TranslateRotateZYX(&sp88, &sp80); + mtx_s3 = Matrix_NewMtx(gfxCtx); + potPos = &this->potPos[i]; + Matrix_MultVec3f(&spC0, &calcPotPos); + SkinMatrix_Vec3fMtxFMultXYZW(&play->viewProjectionMtxF, &calcPotPos, potPos, &spB0); + + if (this->wasPotHit[i]) { + this->wasPotHit[i] = false; + if (this->potsLife[i] == 1) { + ObjUm_SpawnFragments(play, &calcPotPos); + } else { + EffectSsHitmark_SpawnFixedScale(play, 0, &calcPotPos); + } + } + Matrix_Pop(); + + if (mtx_s3 != NULL) { + if (play) {} + gSPMatrix(POLY_OPA_DISP++, mtx_s3, G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + + if (spFC[this->potsLife[i]] != NULL) { + s32 pad; + + gSPDisplayList(POLY_OPA_DISP++, spFC[this->potsLife[i]]); + + if (spE4[this->potsLife[i]] != NULL) { + gSPDisplayList(POLY_OPA_DISP++, spE4[this->potsLife[i]]); + } + } + } else { + //! @bug skips CLOSE_DISPS + return; + } + } + + CLOSE_DISPS(gfxCtx); + } + + if (limbIndex == UM_LIMB_CREMIA_HEAD) { + Matrix_MultZero(&this->dyna.actor.focus.pos); + } +} + +void func_80B7BEA4(Vec3f* cartBedPos, s16 arg1, Vec3f* arg2, u8 alpha, PlayState* play) { + f32 temp; + Vec3f sp108; + CollisionPoly* sp104; + Mtx* sp100; + MtxF spC0; + MtxF sp80; + MtxF sp40; + + sp108.x = cartBedPos->x; + sp108.y = cartBedPos->y + 1.0f; + sp108.z = cartBedPos->z; + + temp = BgCheck_EntityRaycastFloor2(play, &play->colCtx, &sp104, &sp108); + if (sp104 != NULL) { + func_800C0094(sp104, cartBedPos->x, temp, cartBedPos->z, &spC0); + } else { + SkinMatrix_SetTranslate(&spC0, cartBedPos->x, cartBedPos->y, cartBedPos->z); + } + + SkinMatrix_MulYRotation(&spC0, arg1); + SkinMatrix_SetScale(&sp80, arg2->x, 1.0f, arg2->z); + SkinMatrix_MtxFMtxFMult(&spC0, &sp80, &sp40); + + sp100 = SkinMatrix_MtxFToNewMtx(play->state.gfxCtx, &sp40); + if (sp100 != NULL) { + OPEN_DISPS(play->state.gfxCtx); + + gSPMatrix(POLY_OPA_DISP++, &gIdentityMtx, G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + POLY_OPA_DISP = Gfx_CallSetupDL(POLY_OPA_DISP, 0x2C); + gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, 0, 0, 0, alpha); + gSPMatrix(POLY_OPA_DISP++, sp100, G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_OPA_DISP++, gSquareShadowDL); + + CLOSE_DISPS(play->state.gfxCtx); + } +} + +void ObjUm_Draw(Actor* thisx, PlayState* play) { + s32 pad; + ObjUm* this = THIS; + Vec3f sp34; + + this->flags |= OBJ_UM_FLAG_0001; + SkelAnime_DrawFlexOpa(play, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, + ObjUm_OverrideLimbDraw, ObjUm_PostLimbDraw, &this->dyna.actor); + sp34.x = 0.45f; + sp34.y = 0.0f; + sp34.z = 0.7f; + func_80B7BEA4(&this->cartBedPos, this->dyna.actor.shape.rot.y, &sp34, 180, play); + func_80B77770(this, play); +} diff --git a/src/overlays/actors/ovl_Obj_Um/z_obj_um.h b/src/overlays/actors/ovl_Obj_Um/z_obj_um.h index 1487c561f..a6644009e 100644 --- a/src/overlays/actors/ovl_Obj_Um/z_obj_um.h +++ b/src/overlays/actors/ovl_Obj_Um/z_obj_um.h @@ -2,18 +2,93 @@ #define Z_OBJ_UM_H #include "global.h" +#include "objects/object_um/object_um.h" +#include "overlays/actors/ovl_En_Horse/z_en_horse.h" struct ObjUm; -typedef void (*ObjUmActionFunc)(struct ObjUm*, GlobalContext*); +typedef void (*ObjUmActionFunc)(struct ObjUm*, PlayState*); + +#define MILK_POTS_COUNT 3 + +typedef enum ObjUmAnimation { + /* -1 */ OBJ_UM_ANIM_MINUS_1 = -1, + /* 0 */ OBJ_UM_ANIM_TROT, + /* 1 */ OBJ_UM_ANIM_GALLOP, + /* 2 */ OBJ_UM_ANIM_IDLE, + /* 3 */ OBJ_UM_ANIM_3, // NULL pointer + /* 4 */ OBJ_UM_ANIM_LOOK_BACK +} ObjUmAnimation; typedef struct ObjUm { - /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x18]; - /* 0x015C */ ObjUmActionFunc actionFunc; - /* 0x0160 */ char unk_160[0x384]; + /* 0x000 */ DynaPolyActor dyna; + /* 0x15C */ ObjUmActionFunc actionFunc; + /* 0x160 */ SkelAnime skelAnime; + /* 0x1A4 */ Vec3s jointTable[UM_LIMB_MAX]; + /* 0x228 */ Vec3s morphTable[UM_LIMB_MAX]; + /* 0x2AC */ s16 wheelRot; + /* 0x2AE */ s16 type; + /* 0x2B0 */ s16 initialPathIndex; + /* 0x2B4 */ s32 unk_2B4; + /* 0x2B8 */ EnHorse* donkey; + /* 0x2BC */ s32 pathIndex; + /* 0x2BE */ s32 pointIndex; + /* 0x2C4 */ Vec3f unk_2C4; + /* 0x2D0 */ Vec3f unk_2D0; + /* 0x2DC */ Vec3f unk_2DC; + /* 0x2E8 */ Vec3f unk_2E8; + /* 0x2F4 */ s32 flags; + /* 0x2BC */ Vec3s unk_2F8; + /* 0x2FE */ Vec3s unk_2FE; + /* 0x304 */ ObjUmAnimation animIndex; + /* 0x308 */ Vec3f unk_308; + /* 0x314 */ s32 potsLife[MILK_POTS_COUNT]; + /* 0x320 */ s32 wasPotHit[MILK_POTS_COUNT]; // resets to false in the same frame + /* 0x32C */ Vec3f potPos[MILK_POTS_COUNT]; + /* 0x350 */ s32 unk_350; // unused counter? + /* 0x354 */ s32 unk_354; // unused? + /* 0x358 */ EnHorse* bandit1; + /* 0x35C */ EnHorse* bandit2; + /* 0x360 */ Vec3f unk_360[16]; + /* 0x420 */ s32 unk_420; // ? + /* 0x424 */ ColliderCylinder banditsCollisions[2]; + /* 0x4BC */ Vec3f cartBedPos; + /* 0x4C8 */ u16 lastTime; + /* 0x4CC */ s32 unk_4CC; + /* 0x4D0 */ s32 eyeTexIndex; + /* 0x4D4 */ s32 mouthTexIndex; + /* 0x4D8 */ s32 unk_4D8; + /* 0x4DC */ s32 unk_4DC; + /* 0x4E0 */ s32 areAllPotsBroken; // true when all of the pots have been broken } ObjUm; // size = 0x4E4 extern const ActorInit Obj_Um_InitVars; +typedef enum { + /* 0 */ OBJ_UM_TYPE_TERMINA_FIELD, + /* 1 */ OBJ_UM_TYPE_RANCH, + /* 2 */ OBJ_UM_TYPE_PRE_MILK_RUN, // milk road, pre-minigame + /* 3 */ OBJ_UM_TYPE_MILK_RUN_MINIGAME, + /* 4 */ OBJ_UM_TYPE_POST_MILK_RUN // milk road, post-minigame +} ObjUmType; + +#define OBJ_UM_GET_TYPE(thisx) (((thisx)->params & 0xFF00) >> 8) +#define OBJ_UM_GET_PATH_INDEX(thisx) ((thisx)->params & 0xFF) + +#define OBJ_UM_FLAG_NONE (0) +#define OBJ_UM_FLAG_0001 (1 << 0) +#define OBJ_UM_FLAG_MOVING (1 << 1) +#define OBJ_UM_FLAG_0004 (1 << 2) +#define OBJ_UM_FLAG_WAITING (1 << 3) // Waiting in the Ranch +#define OBJ_UM_FLAG_0010 (1 << 4) +#define OBJ_UM_FLAG_DRAWN_FLOOR (1 << 5) +#define OBJ_UM_FLAG_0040 (1 << 6) +#define OBJ_UM_FLAG_PLAYING_MINIGAME (1 << 7) +#define OBJ_UM_FLAG_0100 (1 << 8) +#define OBJ_UM_FLAG_0200 (1 << 9) // Something bandit1 +#define OBJ_UM_FLAG_0400 (1 << 10) // Something bandit2 +#define OBJ_UM_FLAG_LOOK_BACK (1 << 11) +#define OBJ_UM_FLAG_1000 (1 << 12) +#define OBJ_UM_FLAG_MINIGAME_FINISHED (1 << 13) + #endif // Z_OBJ_UM_H 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 35371b605..e895eeba9 100644 --- a/src/overlays/actors/ovl_Obj_Usiyane/z_obj_usiyane.c +++ b/src/overlays/actors/ovl_Obj_Usiyane/z_obj_usiyane.c @@ -10,10 +10,10 @@ #define THIS ((ObjUsiyane*)thisx) -void ObjUsiyane_Init(Actor* thisx, GlobalContext* globalCtx); -void ObjUsiyane_Destroy(Actor* thisx, GlobalContext* globalCtx); -void ObjUsiyane_Update(Actor* thisx, GlobalContext* globalCtx); -void ObjUsiyane_Draw(Actor* thisx, GlobalContext* globalCtx); +void ObjUsiyane_Init(Actor* thisx, PlayState* play); +void ObjUsiyane_Destroy(Actor* thisx, PlayState* play); +void ObjUsiyane_Update(Actor* thisx, PlayState* play); +void ObjUsiyane_Draw(Actor* thisx, PlayState* play); #if 0 const ActorInit Obj_Usiyane_InitVars = { diff --git a/src/overlays/actors/ovl_Obj_Usiyane/z_obj_usiyane.h b/src/overlays/actors/ovl_Obj_Usiyane/z_obj_usiyane.h index 664da07e4..7c4cdd8a5 100644 --- a/src/overlays/actors/ovl_Obj_Usiyane/z_obj_usiyane.h +++ b/src/overlays/actors/ovl_Obj_Usiyane/z_obj_usiyane.h @@ -5,13 +5,13 @@ struct ObjUsiyane; -typedef void (*ObjUsiyaneActionFunc)(struct ObjUsiyane*, GlobalContext*); +typedef void (*ObjUsiyaneActionFunc)(struct ObjUsiyane*, PlayState*); typedef struct ObjUsiyane { - /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x18]; - /* 0x015C */ ObjUsiyaneActionFunc actionFunc; - /* 0x0160 */ char unk_160[0x5E8]; + /* 0x000 */ Actor actor; + /* 0x144 */ char unk_144[0x18]; + /* 0x15C */ ObjUsiyaneActionFunc actionFunc; + /* 0x160 */ char unk_160[0x5E8]; } ObjUsiyane; // size = 0x748 extern const ActorInit Obj_Usiyane_InitVars; diff --git a/src/overlays/actors/ovl_Obj_Visiblock/z_obj_visiblock.c b/src/overlays/actors/ovl_Obj_Visiblock/z_obj_visiblock.c index 8741fc01b..e0d07c4fb 100644 --- a/src/overlays/actors/ovl_Obj_Visiblock/z_obj_visiblock.c +++ b/src/overlays/actors/ovl_Obj_Visiblock/z_obj_visiblock.c @@ -11,9 +11,9 @@ #define THIS ((ObjVisiblock*)thisx) -void ObjVisiblock_Init(Actor* thisx, GlobalContext* globalCtx); -void ObjVisiblock_Destroy(Actor* thisx, GlobalContext* globalCtx); -void ObjVisiblock_Draw(Actor* thisx, GlobalContext* globalCtx); +void ObjVisiblock_Init(Actor* thisx, PlayState* play); +void ObjVisiblock_Destroy(Actor* thisx, PlayState* play); +void ObjVisiblock_Draw(Actor* thisx, PlayState* play); const ActorInit Obj_Visiblock_InitVars = { ACTOR_OBJ_VISIBLOCK, @@ -34,20 +34,20 @@ static InitChainEntry sInitChain[] = { ICHAIN_VEC3F_DIV1000(scale, 100, ICHAIN_STOP), }; -void ObjVisiblock_Init(Actor* thisx, GlobalContext* globalCtx) { +void ObjVisiblock_Init(Actor* thisx, PlayState* play) { ObjVisiblock* this = THIS; Actor_ProcessInitChain(&this->dyna.actor, sInitChain); DynaPolyActor_Init(&this->dyna, 0); - DynaPolyActor_LoadMesh(globalCtx, &this->dyna, &object_visiblock_Colheader_000AD0); + DynaPolyActor_LoadMesh(play, &this->dyna, &object_visiblock_Colheader_000AD0); } -void ObjVisiblock_Destroy(Actor* thisx, GlobalContext* globalCtx) { +void ObjVisiblock_Destroy(Actor* thisx, PlayState* play) { ObjVisiblock* this = THIS; - DynaPoly_DeleteBgActor(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); + DynaPoly_DeleteBgActor(play, &play->colCtx.dyna, this->dyna.bgId); } -void ObjVisiblock_Draw(Actor* thisx, GlobalContext* globalCtx) { - Gfx_DrawDListXlu(globalCtx, object_visiblock_DL_000140); +void ObjVisiblock_Draw(Actor* thisx, PlayState* play) { + Gfx_DrawDListXlu(play, object_visiblock_DL_000140); } 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 9c5d22bac..6740cc684 100644 --- a/src/overlays/actors/ovl_Obj_Vspinyroll/z_obj_vspinyroll.c +++ b/src/overlays/actors/ovl_Obj_Vspinyroll/z_obj_vspinyroll.c @@ -11,21 +11,21 @@ #define THIS ((ObjVspinyroll*)thisx) -void ObjVspinyroll_Init(Actor* thisx, GlobalContext* globalCtx); -void ObjVspinyroll_Destroy(Actor* thisx, GlobalContext* globalCtx); -void ObjVspinyroll_Update(Actor* thisx, GlobalContext* globalCtx); -void ObjVspinyroll_Draw(Actor* thisx, GlobalContext* globalCtx); +void ObjVspinyroll_Init(Actor* thisx, PlayState* play); +void ObjVspinyroll_Destroy(Actor* thisx, PlayState* play); +void ObjVspinyroll_Update(Actor* thisx, PlayState* play); +void ObjVspinyroll_Draw(Actor* thisx, PlayState* play); void func_80A3CEC4(ObjVspinyroll* this); -void func_80A3CEE0(ObjVspinyroll* this, GlobalContext* globalCtx); -void func_80A3CF4C(ObjVspinyroll* this, GlobalContext* globalCtx); +void func_80A3CEE0(ObjVspinyroll* this, PlayState* play); +void func_80A3CF4C(ObjVspinyroll* this, PlayState* play); void func_80A3CFAC(ObjVspinyroll* this); -void func_80A3CFE0(ObjVspinyroll* this, GlobalContext* globalCtx); +void func_80A3CFE0(ObjVspinyroll* this, PlayState* play); void func_80A3D024(ObjVspinyroll* this); -void func_80A3D038(ObjVspinyroll* this, GlobalContext* globalCtx); +void func_80A3D038(ObjVspinyroll* this, PlayState* play); void func_80A3D0E8(ObjVspinyroll* this); -void func_80A3D0FC(ObjVspinyroll* this, GlobalContext* globalCtx); -void func_80A3D2C0(Actor* thisx, GlobalContext* globalCtx); +void func_80A3D0FC(ObjVspinyroll* this, PlayState* play); +void func_80A3D2C0(Actor* thisx, PlayState* play); const ActorInit Obj_Vspinyroll_InitVars = { ACTOR_OBJ_VSPINYROLL, @@ -141,15 +141,15 @@ void func_80A3C7E8(ObjVspinyroll* this) { s32 index = D_80A3D450[OBJVSPINYROLL_GET_4000(&this->dyna.actor)] * 120.0f * (1.0f / 58.0f); index += 2; - this->unk_38C = index * 4; + this->unk_1A8.unk_1E4 = index * 4; tempf = ((D_80A3D450[OBJVSPINYROLL_GET_4000(&this->dyna.actor)] * 120.0f) - 2.0f) / (index - 1); phi_f2 = 1.0f; - for (i = 0, j = 0; i < this->unk_38C; i++) { - this->unk_1A8[i].unk_00.x = D_80A3D4C4[j]; - this->unk_1A8[i].unk_00.y = phi_f2; - this->unk_1A8[i].unk_00.z = D_80A3D4B4[j]; + 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]; j++; if (j >= 4) { @@ -159,11 +159,10 @@ void func_80A3C7E8(ObjVspinyroll* this) { } } -#ifdef NON_MATCHING -s32 func_80A3C8D8(ObjVspinyroll* this, GlobalContext* globalCtx, Vec3f* arg2, s32 arg3) { +s32 func_80A3C8D8(ObjVspinyroll* this, PlayState* play, Vec3f* arg2, s32 arg3) { s32 pad; - ObjVspinyrollStruct2* ptr = &this->unk_1A8[0]; - s32 pad2; + ObjVspinyrollStruct3* unk_1A8 = &this->unk_1A8; + ObjVspinyrollStruct2* ptr; s32 i; Vec3f spE4; Vec3f spD8; @@ -177,9 +176,11 @@ s32 func_80A3C8D8(ObjVspinyroll* this, GlobalContext* globalCtx, Vec3f* arg2, s3 spE4.z = 0.0f; sp9C = false; - this->unk_388 = NULL; + unk_1A8->unk_1E0 = NULL; + + for (i = 0; i < unk_1A8->unk_1E4; i++) { + ptr = &unk_1A8->unk_000[i]; - for (i = 0; i < this->unk_38C; i++, ptr++) { spE4.x = ptr->unk_00.x; spE4.y = ptr->unk_00.y; func_80A3C4E0(&spD8, &spE4, this->dyna.actor.world.rot.y); @@ -193,8 +194,8 @@ s32 func_80A3C8D8(ObjVspinyroll* this, GlobalContext* globalCtx, Vec3f* arg2, s3 spCC.x += 30.0f * this->unk_3B4.x; spCC.z += 30.0f * this->unk_3B4.z; - if (BgCheck_EntityLineTest3(&globalCtx->colCtx, &spD8, &spCC, &spC0, &this->unk_1A8[i].collisionPoly, true, - false, false, true, &this->unk_1A8[i].bgId, &this->dyna.actor, 0.0f)) { + if (BgCheck_EntityLineTest3(&play->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; @@ -206,7 +207,7 @@ s32 func_80A3C8D8(ObjVspinyroll* this, GlobalContext* globalCtx, Vec3f* arg2, s3 spB4.y += this->dyna.actor.world.pos.y; spB4.z += this->dyna.actor.world.pos.z; - EffectSsHitMark_SpawnFixedScale(globalCtx, 3, &spB4); + EffectSsHitmark_SpawnFixedScale(play, 3, &spB4); Actor_PlaySfxAtPos(&this->dyna.actor, NA_SE_IT_SHIELD_REFLECT_SW); } @@ -215,21 +216,18 @@ s32 func_80A3C8D8(ObjVspinyroll* this, GlobalContext* globalCtx, Vec3f* arg2, s3 temp_f20 = temp_f0; sp9C = true; Math_Vec3f_Diff(&spC0, &spCC, arg2); - this->unk_388 = ptr; + unk_1A8->unk_1E0 = ptr; } } } return sp9C; } -#else -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Vspinyroll/func_80A3C8D8.s") -#endif -s32 func_80A3CB94(ObjVspinyroll* this, GlobalContext* globalCtx, s32 arg2) { +s32 func_80A3CB94(ObjVspinyroll* this, PlayState* play, s32 arg2) { Vec3f sp1C; - if (func_80A3C8D8(this, globalCtx, &sp1C, arg2)) { + if (func_80A3C8D8(this, play, &sp1C, arg2)) { this->dyna.actor.world.pos.x += sp1C.x; this->dyna.actor.world.pos.z += sp1C.z; return true; @@ -237,15 +235,15 @@ s32 func_80A3CB94(ObjVspinyroll* this, GlobalContext* globalCtx, s32 arg2) { return false; } -DynaPolyActor* func_80A3CBF0(ObjVspinyroll* this, GlobalContext* globalCtx) { - if (this->unk_388 != NULL) { - return DynaPoly_GetActor(&globalCtx->colCtx, this->unk_388->bgId); +DynaPolyActor* func_80A3CBF0(ObjVspinyroll* this, PlayState* play) { + if (this->unk_1A8.unk_1E0 != NULL) { + return DynaPoly_GetActor(&play->colCtx, this->unk_1A8.unk_1E0->bgId); } return NULL; } -s32 func_80A3CC30(ObjVspinyroll* this, GlobalContext* globalCtx) { - DynaPolyActor* actor = func_80A3CBF0(this, globalCtx); +s32 func_80A3CC30(ObjVspinyroll* this, PlayState* play) { + DynaPolyActor* actor = func_80A3CBF0(this, play); if ((actor != NULL) && (Math3D_Vec3fDistSq(&actor->actor.world.pos, &actor->actor.prevPos) > 0.0001f)) { return true; @@ -254,12 +252,12 @@ s32 func_80A3CC30(ObjVspinyroll* this, GlobalContext* globalCtx) { } void func_80A3CC84(f32 arg0) { - MtxF* matrix = Matrix_GetCurrentState(); + MtxF* matrix = Matrix_GetCurrent(); - matrix->wy += arg0; + matrix->yw += arg0; } -void ObjVspinyroll_Init(Actor* thisx, GlobalContext* globalCtx) { +void ObjVspinyroll_Init(Actor* thisx, PlayState* play) { s32 pad; ObjVspinyroll* this = THIS; s32 params = OBJVSPINYROLL_GET_4000(&this->dyna.actor); @@ -282,10 +280,10 @@ void ObjVspinyroll_Init(Actor* thisx, GlobalContext* globalCtx) { this->dyna.actor.scale.x = 0.1f; DynaPolyActor_Init(&this->dyna, 0); - DynaPolyActor_LoadMesh(globalCtx, &this->dyna, &object_spinyroll_Colheader_000F80); + DynaPolyActor_LoadMesh(play, &this->dyna, &object_spinyroll_Colheader_000F80); - Collider_InitCylinder(globalCtx, &this->collider); - Collider_SetCylinder(globalCtx, &this->collider, &this->dyna.actor, &sCylinderInit); + Collider_InitCylinder(play, &this->collider); + Collider_SetCylinder(play, &this->collider, &this->dyna.actor, &sCylinderInit); if (params == OBJVSPINYROLL_4000_1) { this->dyna.actor.draw = func_80A3D2C0; @@ -301,7 +299,7 @@ void ObjVspinyroll_Init(Actor* thisx, GlobalContext* globalCtx) { func_80A3C7E8(this); this->unk_394 = D_80A3D458[OBJVSPINYROLL_GET_380(thisx)]; - path = &globalCtx->setupPathList[OBJVSPINYROLL_GET_7F(&this->dyna.actor)]; + path = &play->setupPathList[OBJVSPINYROLL_GET_7F(&this->dyna.actor)]; points = Lib_SegmentedToVirtual(path->points); point1 = &points[0]; point2 = &points[1]; @@ -316,11 +314,11 @@ void ObjVspinyroll_Init(Actor* thisx, GlobalContext* globalCtx) { func_80A3CFAC(this); } -void ObjVspinyroll_Destroy(Actor* thisx, GlobalContext* globalCtx) { +void ObjVspinyroll_Destroy(Actor* thisx, PlayState* play) { ObjVspinyroll* this = THIS; - DynaPoly_DeleteBgActor(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); - Collider_DestroyCylinder(globalCtx, &this->collider); + DynaPoly_DeleteBgActor(play, &play->colCtx.dyna, this->dyna.bgId); + Collider_DestroyCylinder(play, &this->collider); } void func_80A3CEC4(ObjVspinyroll* this) { @@ -328,7 +326,7 @@ void func_80A3CEC4(ObjVspinyroll* this) { this->actionFunc = func_80A3CEE0; } -void func_80A3CEE0(ObjVspinyroll* this, GlobalContext* globalCtx) { +void func_80A3CEE0(ObjVspinyroll* this, PlayState* play) { this->unk_3C0 += 0x6E; if (this->unk_3C0 > 0xFA0) { this->unk_3C0 = 0xFA0; @@ -341,7 +339,7 @@ void func_80A3CF10(ObjVspinyroll* this) { this->dyna.actor.speedXZ = 0.0f; } -void func_80A3CF4C(ObjVspinyroll* this, GlobalContext* globalCtx) { +void func_80A3CF4C(ObjVspinyroll* this, PlayState* play) { if (Math_ScaledStepToS(&this->unk_3C0, 0, this->unk_3C4) && (this->unk_3C8 > 0)) { this->unk_3C8--; if (this->unk_3C8 <= 0) { @@ -356,7 +354,7 @@ void func_80A3CFAC(ObjVspinyroll* this) { this->dyna.actor.speedXZ = 0.0f; } -void func_80A3CFE0(ObjVspinyroll* this, GlobalContext* globalCtx) { +void func_80A3CFE0(ObjVspinyroll* this, PlayState* play) { if (Math_ScaledStepToS(&this->unk_3C0, this->unk_3C2, 0x6E)) { func_80A3D024(this); } @@ -366,12 +364,12 @@ void func_80A3D024(ObjVspinyroll* this) { this->actionFunc = func_80A3D038; } -void func_80A3D038(ObjVspinyroll* this, GlobalContext* globalCtx) { +void func_80A3D038(ObjVspinyroll* this, PlayState* play) { s32 sp24 = func_80A3C700(this); - if (func_80A3CB94(this, globalCtx, 1)) { + if (func_80A3CB94(this, play, 1)) { this->unk_3C4 = 0x7D0; - if (func_80A3CBF0(this, globalCtx) != NULL) { + if (func_80A3CBF0(this, play) != NULL) { func_80A3D0E8(this); } else { func_80A3C6CC(this); @@ -388,11 +386,11 @@ void func_80A3D0E8(ObjVspinyroll* this) { this->actionFunc = func_80A3D0FC; } -void func_80A3D0FC(ObjVspinyroll* this, GlobalContext* globalCtx) { +void func_80A3D0FC(ObjVspinyroll* this, PlayState* play) { s32 sp24 = true; Math_ScaledStepToS(&this->unk_3C0, 0, this->unk_3C4); - if (func_80A3CB94(this, globalCtx, 0) && func_80A3CC30(this, globalCtx)) { + if (func_80A3CB94(this, play, 0) && func_80A3CC30(this, play)) { sp24 = false; } @@ -402,56 +400,56 @@ void func_80A3D0FC(ObjVspinyroll* this, GlobalContext* globalCtx) { } } -void ObjVspinyroll_Update(Actor* thisx, GlobalContext* globalCtx2) { - GlobalContext* globalCtx = globalCtx2; +void ObjVspinyroll_Update(Actor* thisx, PlayState* play2) { + PlayState* play = play2; ObjVspinyroll* this = THIS; - this->actionFunc(this, globalCtx); + this->actionFunc(this, play); 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); + CollisionCheck_SetAT(play, &play->colChkCtx, &this->collider.base); + CollisionCheck_SetAC(play, &play->colChkCtx, &this->collider.base); } -void ObjVspinyroll_Draw(Actor* thisx, GlobalContext* globalCtx) { +void ObjVspinyroll_Draw(Actor* thisx, PlayState* play) { ObjVspinyroll* this = THIS; - Matrix_InsertTranslation(this->dyna.actor.world.pos.x, this->dyna.actor.world.pos.y + 60.0f, - this->dyna.actor.world.pos.z, MTXMODE_NEW); - Matrix_RotateY(this->dyna.actor.shape.rot.y, MTXMODE_APPLY); - Matrix_InsertZRotation_s(this->dyna.actor.shape.rot.z + 0x4000, MTXMODE_APPLY); - Matrix_InsertXRotation_s(this->dyna.actor.shape.rot.x + this->unk_3C6, MTXMODE_APPLY); + Matrix_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); + Gfx_DrawDListOpa(play, object_spinyroll_DL_000460); } -void func_80A3D2C0(Actor* thisx, GlobalContext* globalCtx) { +void func_80A3D2C0(Actor* thisx, PlayState* play) { ObjVspinyroll* this = THIS; Vec3s sp3C; - OPEN_DISPS(globalCtx->state.gfxCtx); + OPEN_DISPS(play->state.gfxCtx); sp3C.x = this->dyna.actor.shape.rot.x + this->unk_3C6; sp3C.y = this->dyna.actor.shape.rot.y; sp3C.z = this->dyna.actor.shape.rot.z + 0x4000; - func_8012C28C(globalCtx->state.gfxCtx); - Matrix_InsertTranslation(this->dyna.actor.world.pos.x, this->dyna.actor.world.pos.y + 60.0f, - this->dyna.actor.world.pos.z, MTXMODE_NEW); - Matrix_RotateY(sp3C.y, MTXMODE_APPLY); - Matrix_InsertZRotation_s(sp3C.z, MTXMODE_APPLY); - Matrix_InsertXRotation_s(sp3C.x, MTXMODE_APPLY); + func_8012C28C(play->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); + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(play->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); + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_OPA_DISP++, object_spinyroll_DL_000460); - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->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 af1048267..38dee86fb 100644 --- a/src/overlays/actors/ovl_Obj_Vspinyroll/z_obj_vspinyroll.h +++ b/src/overlays/actors/ovl_Obj_Vspinyroll/z_obj_vspinyroll.h @@ -5,7 +5,7 @@ struct ObjVspinyroll; -typedef void (*ObjVspinyrollActionFunc)(struct ObjVspinyroll*, GlobalContext*); +typedef void (*ObjVspinyrollActionFunc)(struct ObjVspinyroll*, PlayState*); #define OBJVSPINYROLL_GET_7F(thisx) ((thisx)->params & 0x7F) #define OBJVSPINYROLL_GET_380(thisx) (((thisx)->params >> 7) & 7) @@ -21,22 +21,26 @@ typedef struct { /* 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 */ DynaPolyActor dyna; - /* 0x015C */ ColliderCylinder collider; - /* 0x01A8 */ ObjVspinyrollStruct2 unk_1A8[24]; - /* 0x0388 */ ObjVspinyrollStruct2* unk_388; - /* 0x038C */ s32 unk_38C; - /* 0x0390 */ ObjVspinyrollActionFunc actionFunc; - /* 0x0394 */ f32 unk_394; - /* 0x0398 */ s32 unk_398; - /* 0x039C */ Vec3f unk_39C[2]; - /* 0x03B4 */ Vec3f unk_3B4; - /* 0x03C0 */ s16 unk_3C0; - /* 0x03C2 */ s16 unk_3C2; - /* 0x03C4 */ s16 unk_3C4; - /* 0x03C6 */ s16 unk_3C6; - /* 0x03C8 */ s16 unk_3C8; + /* 0x000 */ DynaPolyActor dyna; + /* 0x15C */ ColliderCylinder collider; + /* 0x1A8 */ ObjVspinyrollStruct3 unk_1A8; + /* 0x390 */ ObjVspinyrollActionFunc actionFunc; + /* 0x394 */ f32 unk_394; + /* 0x398 */ s32 unk_398; + /* 0x39C */ Vec3f unk_39C[2]; + /* 0x3B4 */ Vec3f unk_3B4; + /* 0x3C0 */ s16 unk_3C0; + /* 0x3C2 */ s16 unk_3C2; + /* 0x3C4 */ s16 unk_3C4; + /* 0x3C6 */ s16 unk_3C6; + /* 0x3C8 */ s16 unk_3C8; } ObjVspinyroll; // size = 0x3CC extern const ActorInit Obj_Vspinyroll_InitVars; diff --git a/src/overlays/actors/ovl_Obj_Warpstone/z_obj_warpstone.c b/src/overlays/actors/ovl_Obj_Warpstone/z_obj_warpstone.c index fde0406f1..ea9b35f5c 100644 --- a/src/overlays/actors/ovl_Obj_Warpstone/z_obj_warpstone.c +++ b/src/overlays/actors/ovl_Obj_Warpstone/z_obj_warpstone.c @@ -12,15 +12,15 @@ #define THIS ((ObjWarpstone*)thisx) -void ObjWarpstone_Init(Actor* thisx, GlobalContext* globalCtx); -void ObjWarpstone_Destroy(Actor* thisx, GlobalContext* globalCtx); -void ObjWarpstone_Update(Actor* thisx, GlobalContext* globalCtx); -void ObjWarpstone_Draw(Actor* thisx, GlobalContext* globalCtx); +void ObjWarpstone_Init(Actor* thisx, PlayState* play); +void ObjWarpstone_Destroy(Actor* thisx, PlayState* play); +void ObjWarpstone_Update(Actor* thisx, PlayState* play); +void ObjWarpstone_Draw(Actor* thisx, PlayState* play); void ObjWarpstone_SetupAction(ObjWarpstone* this, ObjWarpstoneActionFunc actionFunc); -s32 ObjWarpstone_ClosedIdle(ObjWarpstone* this, GlobalContext* globalCtx); -s32 ObjWarpstone_BeginOpeningCutscene(ObjWarpstone* this, GlobalContext* globalCtx); -s32 ObjWarpstone_PlayOpeningCutscene(ObjWarpstone* this, GlobalContext* globalCtx); -s32 ObjWarpstone_OpenedIdle(ObjWarpstone* this, GlobalContext* globalCtx); +s32 ObjWarpstone_ClosedIdle(ObjWarpstone* this, PlayState* play); +s32 ObjWarpstone_BeginOpeningCutscene(ObjWarpstone* this, PlayState* play); +s32 ObjWarpstone_PlayOpeningCutscene(ObjWarpstone* this, PlayState* play); +s32 ObjWarpstone_OpenedIdle(ObjWarpstone* this, PlayState* play); const ActorInit Obj_Warpstone_InitVars = { ACTOR_OBJ_WARPSTONE, @@ -64,14 +64,14 @@ void ObjWarpstone_SetupAction(ObjWarpstone* this, ObjWarpstoneActionFunc actionF this->actionFunc = actionFunc; } -void ObjWarpstone_Init(Actor* thisx, GlobalContext* globalCtx) { +void ObjWarpstone_Init(Actor* thisx, PlayState* play) { ObjWarpstone* this = THIS; Actor_ProcessInitChain(&this->dyna.actor, sInitChain); - Collider_InitAndSetCylinder(globalCtx, &this->collider, &this->dyna.actor, &sCylinderInit); + Collider_InitAndSetCylinder(play, &this->collider, &this->dyna.actor, &sCylinderInit); Actor_SetFocus(&this->dyna.actor, 40.0f); - if (!OBJ_WARPSTONE_IS_ACTIVATED(OBJ_WARPSTONE_GET_ID(this))) { + if (!OBJ_WARPSTONE_IS_ACTIVATED(OBJ_WARPSTONE_GET_ID(&this->dyna.actor))) { ObjWarpstone_SetupAction(this, ObjWarpstone_ClosedIdle); } else { ObjWarpstone_SetupAction(this, ObjWarpstone_OpenedIdle); @@ -79,13 +79,13 @@ void ObjWarpstone_Init(Actor* thisx, GlobalContext* globalCtx) { } } -void ObjWarpstone_Destroy(Actor* thisx, GlobalContext* globalCtx) { +void ObjWarpstone_Destroy(Actor* thisx, PlayState* play) { ObjWarpstone* this = THIS; - Collider_DestroyCylinder(globalCtx, &this->collider); + Collider_DestroyCylinder(play, &this->collider); } -s32 ObjWarpstone_ClosedIdle(ObjWarpstone* this, GlobalContext* globalCtx) { +s32 ObjWarpstone_ClosedIdle(ObjWarpstone* this, PlayState* play) { if (this->collider.base.acFlags & AC_HIT) { ObjWarpstone_SetupAction(this, ObjWarpstone_BeginOpeningCutscene); return true; @@ -96,7 +96,7 @@ s32 ObjWarpstone_ClosedIdle(ObjWarpstone* this, GlobalContext* globalCtx) { } } -s32 ObjWarpstone_BeginOpeningCutscene(ObjWarpstone* this, GlobalContext* globalCtx) { +s32 ObjWarpstone_BeginOpeningCutscene(ObjWarpstone* this, PlayState* play) { if (this->dyna.actor.cutscene < 0 || ActorCutscene_GetCanPlayNext(this->dyna.actor.cutscene)) { ActorCutscene_StartAndSetUnkLinkFields(this->dyna.actor.cutscene, &this->dyna.actor); ObjWarpstone_SetupAction(this, ObjWarpstone_PlayOpeningCutscene); @@ -107,10 +107,10 @@ s32 ObjWarpstone_BeginOpeningCutscene(ObjWarpstone* this, GlobalContext* globalC return true; } -s32 ObjWarpstone_PlayOpeningCutscene(ObjWarpstone* this, GlobalContext* globalCtx) { +s32 ObjWarpstone_PlayOpeningCutscene(ObjWarpstone* this, PlayState* play) { if (this->openingCSTimer++ >= OBJ_WARPSTONE_TIMER_ACTIVATE_THRESHOLD) { ActorCutscene_Stop(this->dyna.actor.cutscene); - Sram_ActivateOwl(OBJ_WARPSTONE_GET_ID(this)); + Sram_ActivateOwl(OBJ_WARPSTONE_GET_ID(&this->dyna.actor)); ObjWarpstone_SetupAction(this, ObjWarpstone_OpenedIdle); } else if (this->openingCSTimer < OBJ_WARPSTONE_TIMER_OPEN_THRESHOLD) { Math_StepToF(&this->dyna.actor.velocity.x, 0.01f, 0.001f); @@ -125,67 +125,67 @@ s32 ObjWarpstone_PlayOpeningCutscene(ObjWarpstone* this, GlobalContext* globalCt return true; } -s32 ObjWarpstone_OpenedIdle(ObjWarpstone* this, GlobalContext* globalCtx) { +s32 ObjWarpstone_OpenedIdle(ObjWarpstone* this, PlayState* play) { /*You can save your progress and quit here.*/ this->dyna.actor.textId = 0xC01; return false; } -void ObjWarpstone_Update(Actor* thisx, GlobalContext* globalCtx) { +void ObjWarpstone_Update(Actor* thisx, PlayState* play) { ObjWarpstone* this = THIS; s32 pad; if (this->isTalking) { - if (Actor_TextboxIsClosing(&this->dyna.actor, globalCtx)) { + if (Actor_TextboxIsClosing(&this->dyna.actor, play)) { this->isTalking = false; - } else if ((Message_GetState(&globalCtx->msgCtx) == 4) && (Message_ShouldAdvance(globalCtx))) { - if (globalCtx->msgCtx.choiceIndex != 0) { + } else if ((Message_GetState(&play->msgCtx) == TEXT_STATE_CHOICE) && Message_ShouldAdvance(play)) { + if (play->msgCtx.choiceIndex != 0) { func_8019F208(); - globalCtx->msgCtx.msgMode = 0x4D; - globalCtx->msgCtx.unk120D6 = 0; - globalCtx->msgCtx.unk120D4 = 0; - gSaveContext.save.owlSaveLocation = OBJ_WARPSTONE_GET_ID(this); + play->msgCtx.msgMode = 0x4D; + play->msgCtx.unk120D6 = 0; + play->msgCtx.unk120D4 = 0; + gSaveContext.save.owlSaveLocation = OBJ_WARPSTONE_GET_ID(&this->dyna.actor); } else { - func_801477B4(globalCtx); + func_801477B4(play); } } - } else if (Actor_ProcessTalkRequest(&this->dyna.actor, &globalCtx->state)) { + } else if (Actor_ProcessTalkRequest(&this->dyna.actor, &play->state)) { this->isTalking = true; - } else if (!this->actionFunc(this, globalCtx)) { - func_800B863C(&this->dyna.actor, globalCtx); + } else if (!this->actionFunc(this, play)) { + func_800B863C(&this->dyna.actor, play); } - Collider_ResetCylinderAC(globalCtx, &this->collider.base); + Collider_ResetCylinderAC(play, &this->collider.base); Collider_UpdateCylinder(&this->dyna.actor, &this->collider); - CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); - CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + CollisionCheck_SetOC(play, &play->colChkCtx, &this->collider.base); + CollisionCheck_SetAC(play, &play->colChkCtx, &this->collider.base); } -void ObjWarpstone_Draw(Actor* thisx, GlobalContext* globalCtx2) { - GlobalContext* globalCtx = globalCtx2; +void ObjWarpstone_Draw(Actor* thisx, PlayState* play2) { + PlayState* play = play2; ObjWarpstone* this = THIS; - Gfx_DrawDListOpa(globalCtx, sOwlStatueDLs[this->modelIndex]); + Gfx_DrawDListOpa(play, sOwlStatueDLs[this->modelIndex]); 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); + OPEN_DISPS(play->state.gfxCtx); + func_8012C2DC(play->state.gfxCtx); + 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(&play->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); - gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + Matrix_RotateZF((((play->gameplayFrames * 1500) & 0xFFFF) * M_PI) / 0x8000, MTXMODE_APPLY); + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_XLU_DISP++, gOwlStatueWhiteFlashDL); - Matrix_StatePop(); - Matrix_InsertZRotation_f((~((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); + Matrix_Pop(); + Matrix_RotateZF((~((play->gameplayFrames * 1200) & 0xFFFF) * M_PI) / 0x8000, MTXMODE_APPLY); + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_XLU_DISP++, gOwlStatueWhiteFlashDL); - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->state.gfxCtx); } } diff --git a/src/overlays/actors/ovl_Obj_Warpstone/z_obj_warpstone.h b/src/overlays/actors/ovl_Obj_Warpstone/z_obj_warpstone.h index 37cfb99ab..8d39deef0 100644 --- a/src/overlays/actors/ovl_Obj_Warpstone/z_obj_warpstone.h +++ b/src/overlays/actors/ovl_Obj_Warpstone/z_obj_warpstone.h @@ -5,7 +5,7 @@ struct ObjWarpstone; -typedef s32 (*ObjWarpstoneActionFunc)(struct ObjWarpstone* this, GlobalContext* globalCtx); +typedef s32 (*ObjWarpstoneActionFunc)(struct ObjWarpstone* this, PlayState* play); typedef enum { /* 0 */ SEK_MODEL_CLOSED, @@ -28,7 +28,7 @@ typedef struct ObjWarpstone { extern const ActorInit Obj_Warpstone_InitVars; -#define OBJ_WARPSTONE_GET_ID(this) ((u16)(this->dyna.actor.params & 0xF)) -#define OBJ_WARPSTONE_IS_ACTIVATED(owlId) (((void)0, gSaveContext.save.playerData.owlActivationFlags) & (u16)gBitFlags[owlId]) +#define OBJ_WARPSTONE_GET_ID(thisx) ((u16)((thisx)->params & 0xF)) +#define OBJ_WARPSTONE_IS_ACTIVATED(owlId) (((void)0, gSaveContext.save.playerData.owlActivationFlags) & (u16)gBitFlags[(owlId)]) #endif // Z_OBJ_WARPSTONE_H diff --git a/src/overlays/actors/ovl_Obj_Wind/z_obj_wind.c b/src/overlays/actors/ovl_Obj_Wind/z_obj_wind.c index f72645e49..567d9a92e 100644 --- a/src/overlays/actors/ovl_Obj_Wind/z_obj_wind.c +++ b/src/overlays/actors/ovl_Obj_Wind/z_obj_wind.c @@ -10,10 +10,10 @@ #define THIS ((ObjWind*)thisx) -void ObjWind_Init(Actor* thisx, GlobalContext* globalCtx); -void ObjWind_Destroy(Actor* thisx, GlobalContext* globalCtx); -void ObjWind_Update(Actor* thisx, GlobalContext* globalCtx); -void ObjWind_Draw(Actor* thisx, GlobalContext* globalCtx); +void ObjWind_Init(Actor* thisx, PlayState* play); +void ObjWind_Destroy(Actor* thisx, PlayState* play); +void ObjWind_Update(Actor* thisx, PlayState* play); +void ObjWind_Draw(Actor* thisx, PlayState* play); #if 0 const ActorInit Obj_Wind_InitVars = { 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 34d82523f..83e06a1a3 100644 --- a/src/overlays/actors/ovl_Obj_Wturn/z_obj_wturn.c +++ b/src/overlays/actors/ovl_Obj_Wturn/z_obj_wturn.c @@ -10,17 +10,17 @@ #define THIS ((ObjWturn*)thisx) -void ObjWturn_Init(Actor* thisx, GlobalContext* globalCtx); -void ObjWturn_Update(Actor* thisx, GlobalContext* globalCtx); +void ObjWturn_Init(Actor* thisx, PlayState* play); +void ObjWturn_Update(Actor* thisx, PlayState* play); void func_808A7954(ObjWturn* this); -void func_808A7968(ObjWturn* this, GlobalContext* globalCtx); +void func_808A7968(ObjWturn* this, PlayState* play); 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); +void func_808A7A5C(ObjWturn* this, PlayState* play); +void func_808A7AAC(ObjWturn* this, PlayState* play); +void func_808A7BA0(ObjWturn* this, PlayState* play); +void func_808A7C04(ObjWturn* this, PlayState* play); +void func_808A7C78(ObjWturn* this, PlayState* play); const ActorInit Obj_Wturn_InitVars = { ACTOR_OBJ_WTURN, ACTORCAT_ITEMACTION, FLAGS, @@ -28,7 +28,7 @@ const ActorInit Obj_Wturn_InitVars = { (ActorFunc)Actor_Noop, (ActorFunc)ObjWturn_Update, (ActorFunc)NULL, }; -void ObjWturn_Init(Actor* thisx, GlobalContext* globalCtx) { +void ObjWturn_Init(Actor* thisx, PlayState* play) { ObjWturn* this = THIS; func_808A7954(this); @@ -38,12 +38,12 @@ void func_808A7954(ObjWturn* this) { this->actionFunc = func_808A7968; } -void func_808A7968(ObjWturn* this, GlobalContext* globalCtx) { - if (globalCtx->msgCtx.ocarinaMode >= 28 && globalCtx->msgCtx.ocarinaMode < 39) { - Flags_UnsetSwitch(globalCtx, this->actor.params); +void func_808A7968(ObjWturn* this, PlayState* play) { + if (play->msgCtx.ocarinaMode >= 28 && play->msgCtx.ocarinaMode < 39) { + Flags_UnsetSwitch(play, 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))) { + } else if ((Flags_GetSwitch(play, this->actor.params) && (play->sceneNum == SCENE_F40)) || + (!Flags_GetSwitch(play, this->actor.params) && (play->sceneNum == SCENE_F41))) { func_808A7A24(this); } } @@ -53,76 +53,76 @@ void func_808A7A24(ObjWturn* this) { this->actionFunc = func_808A7A5C; } -void func_808A7A5C(ObjWturn* this, GlobalContext* globalCtx) { +void func_808A7A5C(ObjWturn* this, PlayState* play) { if (ActorCutscene_GetCanPlayNext(this->actor.cutscene)) { - func_808A7AAC(this, globalCtx); + func_808A7AAC(this, play); } else { ActorCutscene_SetIntentToPlay(this->actor.cutscene); } } -void func_808A7AAC(ObjWturn* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); - Vec3f eye; - Vec3f at; +void func_808A7AAC(ObjWturn* this, PlayState* play) { + Player* player = GET_PLAYER(play); + Vec3f subCamEye; + Vec3f subCamAt; 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->subCamId = ActorCutscene_GetCurrentSubCamId(this->actor.cutscene); + func_800B7298(play, &this->actor, 21); + subCamAt.x = player->actor.focus.pos.x; + subCamAt.z = player->actor.focus.pos.z; + subCamAt.y = player->actor.focus.pos.y; + subCamEye.x = (Math_SinS(this->actor.shape.rot.y) * 150.0f) + subCamAt.x; + subCamEye.z = (Math_CosS(this->actor.shape.rot.y) * 150.0f) + subCamAt.z; + subCamEye.y = subCamAt.y + 4.0f; + Play_SetCameraAtEye(play, this->subCamId, &subCamAt, &subCamEye); this->actionFunc = func_808A7BA0; } -void func_808A7BA0(ObjWturn* this, GlobalContext* globalCtx) { +void func_808A7BA0(ObjWturn* this, PlayState* play) { if (Math_ScaledStepToS(&this->actor.shape.rot.z, -0x8000, 0x0200)) { - func_808A7C04(this, globalCtx); + func_808A7C04(this, play); } func_800B8FE8(&this->actor, NA_SE_EV_EARTHQUAKE - SFX_FLAG); - Play_CameraSetRoll(globalCtx, this->camId, this->actor.shape.rot.z); + Play_SetCameraRoll(play, this->subCamId, this->actor.shape.rot.z); } -void func_808A7C04(ObjWturn* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); +void func_808A7C04(ObjWturn* this, PlayState* play) { + Player* player = GET_PLAYER(play); this->actor.world.pos.y += this->actor.playerHeightRel; player->actor.shape.shadowAlpha = 0; - func_800B7298(globalCtx, &this->actor, 0x54); + func_800B7298(play, &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); +void func_808A7C78(ObjWturn* this, PlayState* play) { + static Vec3f sSubCamUp = { 0.0f, -1.0f, 0.0f }; + Camera* subCam = Play_GetCamera(play, this->subCamId); + Player* player = GET_PLAYER(play); this->unk_14A++; player->actor.world.pos.y = this->actor.world.pos.y + this->unk_14A * 4.0f; - Play_CameraSetAtEyeUp(globalCtx, this->camId, &player->actor.focus.pos, &camera->eye, &D_808A7DC0); + Play_SetCameraAtEyeUp(play, this->subCamId, &player->actor.focus.pos, &subCam->eye, &sSubCamUp); if (this->unk_14A == 1) { - globalCtx->unk_1887F = 0x40; - gSaveContext.nextTransition = 3; + play->transitionType = TRANS_TYPE_64; + gSaveContext.nextTransitionType = TRANS_TYPE_03; gSaveContext.nextCutsceneIndex = 0; - if (globalCtx->sceneNum == 0x58) { - globalCtx->nextEntranceIndex = 0xAC00; + if (play->sceneNum == SCENE_F40) { + play->nextEntrance = ENTRANCE(STONE_TOWER_INVERTED, 0); } else { - globalCtx->nextEntranceIndex = 0xAA10; + play->nextEntrance = ENTRANCE(STONE_TOWER, 1); } - globalCtx->sceneLoadFlag = 0x14; + play->transitionTrigger = TRANS_TRIGGER_START; } } -void ObjWturn_Update(Actor* thisx, GlobalContext* globalCtx) { +void ObjWturn_Update(Actor* thisx, PlayState* play) { ObjWturn* this = THIS; - this->actionFunc(this, globalCtx); + this->actionFunc(this, play); } 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 0390ac7a8..9b8674f59 100644 --- a/src/overlays/actors/ovl_Obj_Wturn/z_obj_wturn.h +++ b/src/overlays/actors/ovl_Obj_Wturn/z_obj_wturn.h @@ -5,13 +5,13 @@ struct ObjWturn; -typedef void (*ObjWturnActionFunc)(struct ObjWturn*, GlobalContext*); +typedef void (*ObjWturnActionFunc)(struct ObjWturn*, PlayState*); typedef struct ObjWturn { - /* 0x0000 */ Actor actor; - /* 0x0144 */ ObjWturnActionFunc actionFunc; - /* 0x0148 */ s16 camId; - /* 0x014A */ s16 unk_14A; + /* 0x000 */ Actor actor; + /* 0x144 */ ObjWturnActionFunc actionFunc; + /* 0x148 */ s16 subCamId; + /* 0x14A */ s16 unk_14A; } ObjWturn; // size = 0x14C extern const ActorInit Obj_Wturn_InitVars; diff --git a/src/overlays/actors/ovl_Obj_Y2lift/z_obj_y2lift.c b/src/overlays/actors/ovl_Obj_Y2lift/z_obj_y2lift.c index 7e9f6cb29..8870295aa 100644 --- a/src/overlays/actors/ovl_Obj_Y2lift/z_obj_y2lift.c +++ b/src/overlays/actors/ovl_Obj_Y2lift/z_obj_y2lift.c @@ -5,17 +5,17 @@ */ #include "z_obj_y2lift.h" +#include "objects/object_kaizoku_obj/object_kaizoku_obj.h" #define FLAGS (ACTOR_FLAG_10) #define THIS ((ObjY2lift*)thisx) -void ObjY2lift_Init(Actor* thisx, GlobalContext* globalCtx); -void ObjY2lift_Destroy(Actor* thisx, GlobalContext* globalCtx); -void ObjY2lift_Update(Actor* thisx, GlobalContext* globalCtx); -void ObjY2lift_Draw(Actor* thisx, GlobalContext* globalCtx); +void ObjY2lift_Init(Actor* thisx, PlayState* play); +void ObjY2lift_Destroy(Actor* thisx, PlayState* play); +void ObjY2lift_Update(Actor* thisx, PlayState* play); +void ObjY2lift_Draw(Actor* thisx, PlayState* play); -#if 0 const ActorInit Obj_Y2lift_InitVars = { ACTOR_OBJ_Y2LIFT, ACTORCAT_BG, @@ -28,25 +28,68 @@ const ActorInit Obj_Y2lift_InitVars = { (ActorFunc)ObjY2lift_Draw, }; -// static InitChainEntry sInitChain[] = { -static InitChainEntry D_80B9A940[] = { +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 ObjY2lift_Init(Actor* thisx, PlayState* play) { + ObjY2lift* this = THIS; -extern InitChainEntry D_80B9A940[]; + Actor_ProcessInitChain(&this->dyna.actor, sInitChain); + DynaPolyActor_Init(&this->dyna, 1); + DynaPolyActor_LoadMesh(play, &this->dyna, &gPirateLiftPlatformCol); +} -extern UNK_TYPE D_06001680; -extern UNK_TYPE D_060019B0; +void ObjY2lift_Destroy(Actor* thisx, PlayState* play) { + ObjY2lift* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Y2lift/ObjY2lift_Init.s") + DynaPoly_DeleteBgActor(play, &play->colCtx.dyna, this->dyna.bgId); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Y2lift/ObjY2lift_Destroy.s") +void ObjY2lift_Update(Actor* thisx, PlayState* play) { + ObjY2lift* this = THIS; + f32 temp_fv0 = this->dyna.actor.world.pos.y; + f32 targetVelocityY = 0.0f; + s32 temp_v0 = DynaPolyActor_IsInRidingMovingState(&this->dyna); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Y2lift/ObjY2lift_Update.s") + if (temp_v0 || DynaPolyActor_IsInRidingFallingState(&this->dyna)) { + if (!this->unk15D) { + this->unk15D = true; + this->unk15F = 12; + } else if (this->unk15F == 0 && temp_v0) { + this->unk15C = 16; + } + } else { + this->unk15D = false; + } + if (DECR(this->unk15C) != 0) { + temp_fv0 = this->dyna.actor.home.pos.y + 180.0f; + targetVelocityY = 2.0f; + } else if (!temp_v0 && this->dyna.actor.velocity.y <= 0.0f) { + temp_fv0 = this->dyna.actor.home.pos.y; + targetVelocityY = -2.0f; + } + Math_StepToF(&this->dyna.actor.velocity.y, targetVelocityY, 0.1f); + this->dyna.actor.world.pos.y += this->dyna.actor.velocity.y; + if (((this->dyna.actor.world.pos.y - temp_fv0) * targetVelocityY) >= 0.0f) { + this->dyna.actor.world.pos.y = temp_fv0; + this->dyna.actor.velocity.y = 0.0f; + if (!this->unk15E) { + this->unk15E = true; + this->unk15F = 12; + } + } else { + this->unk15E = false; + func_800B9010(&this->dyna.actor, NA_SE_EV_PLATE_LIFT_LEVEL - SFX_FLAG); + } + if (DECR(this->unk15F) != 0) { + this->dyna.actor.shape.yOffset = (2.0f * (this->unk15F & 1)) * this->unk15F; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Y2lift/ObjY2lift_Draw.s") +void ObjY2lift_Draw(Actor* thisx, PlayState* play) { + Gfx_DrawDListOpa(play, gPirateLiftPlatformDL); +} diff --git a/src/overlays/actors/ovl_Obj_Y2lift/z_obj_y2lift.h b/src/overlays/actors/ovl_Obj_Y2lift/z_obj_y2lift.h index 27bd6d968..a26d305ae 100644 --- a/src/overlays/actors/ovl_Obj_Y2lift/z_obj_y2lift.h +++ b/src/overlays/actors/ovl_Obj_Y2lift/z_obj_y2lift.h @@ -6,8 +6,11 @@ struct ObjY2lift; typedef struct ObjY2lift { - /* 0x000 */ Actor actor; - /* 0x144 */ char unk_144[0x1C]; + /* 0x000 */ DynaPolyActor dyna; + /* 0x15C */ u8 unk15C; + /* 0x15D */ u8 unk15D; + /* 0x15E */ u8 unk15E; + /* 0x15F */ u8 unk15F; } ObjY2lift; // size = 0x160 extern const ActorInit Obj_Y2lift_InitVars; 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 4bfced35c..6b67bc068 100644 --- a/src/overlays/actors/ovl_Obj_Y2shutter/z_obj_y2shutter.c +++ b/src/overlays/actors/ovl_Obj_Y2shutter/z_obj_y2shutter.c @@ -10,10 +10,10 @@ #define THIS ((ObjY2shutter*)thisx) -void ObjY2shutter_Init(Actor* thisx, GlobalContext* globalCtx); -void ObjY2shutter_Destroy(Actor* thisx, GlobalContext* globalCtx); -void ObjY2shutter_Update(Actor* thisx, GlobalContext* globalCtx); -void ObjY2shutter_Draw(Actor* thisx, GlobalContext* globalCtx); +void ObjY2shutter_Init(Actor* thisx, PlayState* play); +void ObjY2shutter_Destroy(Actor* thisx, PlayState* play); +void ObjY2shutter_Update(Actor* thisx, PlayState* play); +void ObjY2shutter_Draw(Actor* thisx, PlayState* play); #if 0 const ActorInit Obj_Y2shutter_InitVars = { 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 997941057..845e97da4 100644 --- a/src/overlays/actors/ovl_Obj_Yado/z_obj_yado.c +++ b/src/overlays/actors/ovl_Obj_Yado/z_obj_yado.c @@ -11,10 +11,10 @@ #define THIS ((ObjYado*)thisx) -void ObjYado_Init(Actor* thisx, GlobalContext* globalCtx); -void ObjYado_Destroy(Actor* thisx, GlobalContext* globalCtx); -void ObjYado_Update(Actor* thisx, GlobalContext* globalCtx); -void ObjYado_Draw(Actor* thisx, GlobalContext* globalCtx); +void ObjYado_Init(Actor* thisx, PlayState* play); +void ObjYado_Destroy(Actor* thisx, PlayState* play); +void ObjYado_Update(Actor* thisx, PlayState* play); +void ObjYado_Draw(Actor* thisx, PlayState* play); const ActorInit Obj_Yado_InitVars = { ACTOR_OBJ_YADO, @@ -34,7 +34,7 @@ static InitChainEntry sInitChain[] = { AnimatedMaterial* D_80C16470; -void ObjYado_Init(Actor* thisx, GlobalContext* globalCtx) { +void ObjYado_Init(Actor* thisx, PlayState* play) { ObjYado* this = THIS; Actor_ProcessInitChain(&this->actor, sInitChain); @@ -42,32 +42,32 @@ void ObjYado_Init(Actor* thisx, GlobalContext* globalCtx) { this->isNight = gSaveContext.save.isNight; } -void ObjYado_Destroy(Actor* thisx, GlobalContext* globalCtx) { +void ObjYado_Destroy(Actor* thisx, PlayState* play) { } -void ObjYado_Update(Actor* thisx, GlobalContext* globalCtx) { +void ObjYado_Update(Actor* thisx, PlayState* play) { ObjYado* this = THIS; this->isNight = gSaveContext.save.isNight; } -void ObjYado_Draw(Actor* thisx, GlobalContext* globalCtx) { +void ObjYado_Draw(Actor* thisx, PlayState* play) { s32 pad; ObjYado* this = THIS; - OPEN_DISPS(globalCtx->state.gfxCtx); + OPEN_DISPS(play->state.gfxCtx); if (this->isNight) { - gSPSegment(POLY_XLU_DISP++, 0x09, Gfx_PrimColor(globalCtx->state.gfxCtx, 128, 95, 95, 70, 155)); - gSPSegment(POLY_OPA_DISP++, 0x0A, Gfx_PrimColor(globalCtx->state.gfxCtx, 128, 0, 40, 40, 255)); + gSPSegment(POLY_XLU_DISP++, 0x09, Gfx_PrimColor(play->state.gfxCtx, 128, 95, 95, 70, 155)); + gSPSegment(POLY_OPA_DISP++, 0x0A, Gfx_PrimColor(play->state.gfxCtx, 128, 0, 40, 40, 255)); } else { - gSPSegment(POLY_XLU_DISP++, 0x09, Gfx_PrimColor(globalCtx->state.gfxCtx, 128, 255, 255, 215, 110)); - gSPSegment(POLY_OPA_DISP++, 0x0A, Gfx_PrimColor(globalCtx->state.gfxCtx, 128, 255, 255, 215, 255)); + gSPSegment(POLY_XLU_DISP++, 0x09, Gfx_PrimColor(play->state.gfxCtx, 128, 255, 255, 215, 110)); + gSPSegment(POLY_OPA_DISP++, 0x0A, Gfx_PrimColor(play->state.gfxCtx, 128, 255, 255, 215, 255)); } - AnimatedMat_Draw(globalCtx, D_80C16470); - Gfx_DrawDListOpa(globalCtx, object_yado_obj_DL_000430); - Gfx_DrawDListXlu(globalCtx, object_yado_obj_DL_000320); + AnimatedMat_Draw(play, D_80C16470); + Gfx_DrawDListOpa(play, object_yado_obj_DL_000430); + Gfx_DrawDListXlu(play, object_yado_obj_DL_000320); - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->state.gfxCtx); } 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 3ed787918..185638056 100644 --- a/src/overlays/actors/ovl_Obj_Yasi/z_obj_yasi.c +++ b/src/overlays/actors/ovl_Obj_Yasi/z_obj_yasi.c @@ -13,10 +13,10 @@ #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); +void ObjYasi_Init(Actor* thisx, PlayState* play); +void ObjYasi_Destroy(Actor* thisx, PlayState* play); +void ObjYasi_Update(Actor* thisx, PlayState* play); +void ObjYasi_Draw(Actor* thisx, PlayState* play); const ActorInit Obj_Yasi_InitVars = { ACTOR_OBJ_YASI, @@ -37,28 +37,28 @@ static InitChainEntry sInitChain[] = { ICHAIN_F32(uncullZoneDownward, 800, ICHAIN_STOP), }; -void ObjYasi_Init(Actor* thisx, GlobalContext* globalCtx) { +void ObjYasi_Init(Actor* thisx, PlayState* play) { ObjYasi* this = THIS; Actor_ProcessInitChain(&this->dyna.actor, sInitChain); DynaPolyActor_Init(&this->dyna, 0); - DynaPolyActor_LoadMesh(globalCtx, &this->dyna, &object_obj_yasi_Colheader_001428); + DynaPolyActor_LoadMesh(play, &this->dyna, &gPalmTreeCol); this->dyna.actor.home.rot.y = 0; - if (OBJYASI_IS_WIDE(thisx)) { + if (PALM_TREE_IS_WIDE(thisx)) { this->dyna.actor.scale.x = 0.2f; this->dyna.actor.scale.z = 0.2f; } } -void ObjYasi_Destroy(Actor* thisx, GlobalContext* globalCtx) { +void ObjYasi_Destroy(Actor* thisx, PlayState* play) { ObjYasi* this = THIS; - DynaPoly_DeleteBgActor(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); + DynaPoly_DeleteBgActor(play, &play->colCtx.dyna, this->dyna.bgId); } -void ObjYasi_Update(Actor* thisx, GlobalContext* globalCtx) { +void ObjYasi_Update(Actor* thisx, PlayState* play) { ObjYasi* this = THIS; s16 temp; Vec3f dropPos; @@ -69,10 +69,10 @@ void ObjYasi_Update(Actor* thisx, GlobalContext* globalCtx) { 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); + Item_DropCollectible(play, &dropPos, ITEM00_NUTS_1); } } - this->dyna.actor.home.rot.y = GET_PLAYER(globalCtx)->actor.shape.rot.y; + this->dyna.actor.home.rot.y = GET_PLAYER(play)->actor.shape.rot.y; this->dyna.actor.home.rot.x = 400; this->dyna.actor.home.rot.z = 0; } @@ -82,20 +82,20 @@ void ObjYasi_Update(Actor* thisx, GlobalContext* globalCtx) { BINANG_SUB(this->dyna.actor.home.rot.x, (s16)(this->dyna.actor.shape.rot.x * 0.08f)); } -void ObjYasi_Draw(Actor* thisx, GlobalContext* globalCtx) { +void ObjYasi_Draw(Actor* thisx, PlayState* play) { ObjYasi* this = THIS; - Matrix_InsertTranslation(this->dyna.actor.world.pos.x, this->dyna.actor.world.pos.y, this->dyna.actor.world.pos.z, - MTXMODE_NEW); + 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_RotateY(this->dyna.actor.home.rot.y, MTXMODE_APPLY); - Matrix_InsertXRotation_s(this->dyna.actor.shape.rot.x, MTXMODE_APPLY); - Matrix_RotateY(BINANG_SUB(this->dyna.actor.shape.rot.y, this->dyna.actor.home.rot.y), MTXMODE_APPLY); + 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_RotateY(this->dyna.actor.shape.rot.y, MTXMODE_APPLY); + Matrix_RotateYS(this->dyna.actor.shape.rot.y, MTXMODE_APPLY); } Matrix_Scale(0.1f, 0.1f, 0.1f, MTXMODE_APPLY); - Gfx_DrawDListOpa(globalCtx, object_obj_yasi_DL_000360); + Gfx_DrawDListOpa(play, 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 f4ab9ca9c..d1fdc6aed 100644 --- a/src/overlays/actors/ovl_Obj_Yasi/z_obj_yasi.h +++ b/src/overlays/actors/ovl_Obj_Yasi/z_obj_yasi.h @@ -11,6 +11,6 @@ typedef struct ObjYasi { extern const ActorInit Obj_Yasi_InitVars; -#define OBJYASI_IS_WIDE(thisx) ((thisx)->params & 1) +#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 324e53fee..0247cd23a 100644 --- a/src/overlays/actors/ovl_Object_Kankyo/z_object_kankyo.c +++ b/src/overlays/actors/ovl_Object_Kankyo/z_object_kankyo.c @@ -11,19 +11,19 @@ #define THIS ((ObjectKankyo*)thisx) -void ObjectKankyo_Init(Actor* thisx, GlobalContext* globalCtx); -void ObjectKankyo_Destroy(Actor* thisx, GlobalContext* globalCtx); -void ObjectKankyo_Update(Actor* thisx, GlobalContext* globalCtx); -void ObjectKankyo_Draw(Actor* thisx, GlobalContext* globalCtx); +void ObjectKankyo_Init(Actor* thisx, PlayState* play); +void ObjectKankyo_Destroy(Actor* thisx, PlayState* play); +void ObjectKankyo_Update(Actor* thisx, PlayState* play); +void ObjectKankyo_Draw(Actor* thisx, PlayState* play); void ObjectKankyo_SetupAction(ObjectKankyo* this, ObjectKankyoActionFunc actionFunc); -void func_808DC18C(ObjectKankyo* this, GlobalContext* globalCtx); -void func_808DCB7C(ObjectKankyo* this, GlobalContext* globalCtx); -void func_808DCBF8(ObjectKankyo* this, GlobalContext* globalCtx); -void func_808DCDB4(ObjectKankyo* this, GlobalContext* globalCtx); -void func_808DD3C8(Actor* thisx, GlobalContext* globalCtx2); -void func_808DD970(Actor* thisx, GlobalContext* globalCtx2); -void func_808DDE9C(Actor* thisx, GlobalContext* globalCtx2); +void func_808DC18C(ObjectKankyo* this, PlayState* play); +void func_808DCB7C(ObjectKankyo* this, PlayState* play); +void func_808DCBF8(ObjectKankyo* this, PlayState* play); +void func_808DCDB4(ObjectKankyo* this, PlayState* play); +void func_808DD3C8(Actor* thisx, PlayState* play2); +void func_808DD970(Actor* thisx, PlayState* play2); +void func_808DDE9C(Actor* thisx, PlayState* play2); static f32 D_808DE5B0; @@ -49,17 +49,17 @@ void func_808DBE8C(ObjectKankyo* this) { ObjectKankyo_SetupAction(this, func_808DC18C); } -void func_808DBEB0(ObjectKankyo* this, GlobalContext* globalCtx) { +void func_808DBEB0(ObjectKankyo* this, PlayState* play) { s32 i; D_808DE5B0 = 0.0f; this->unk_144 = Rand_ZeroOne() * 360.0f; this->unk_148 = Rand_ZeroOne() * 360.0f; - if (globalCtx->envCtx.unk_F2[2] == 128) { + if (play->envCtx.unk_F2[2] == 128) { D_808DE5B0 = 1.0f; this->unk_114E = 1; - for (i = 0; i < globalCtx->envCtx.unk_F2[2]; i++) { + for (i = 0; i < play->envCtx.unk_F2[2]; i++) { this->unk_14C[i].unk_10 = Rand_ZeroOne() * -200.0f; } } else { @@ -68,7 +68,7 @@ void func_808DBEB0(ObjectKankyo* this, GlobalContext* globalCtx) { ObjectKankyo_SetupAction(this, func_808DCB7C); } -void func_808DBFB0(ObjectKankyo* this, GlobalContext* globalCtx) { +void func_808DBFB0(ObjectKankyo* this, PlayState* play) { D_808DE5B0 = 0.0f; this->unk_114E = 0; this->unk_144 = Rand_ZeroOne() * 360.0f; @@ -78,7 +78,7 @@ void func_808DBFB0(ObjectKankyo* this, GlobalContext* globalCtx) { ObjectKankyo_SetupAction(this, func_808DCBF8); } -void func_808DC038(ObjectKankyo* this, GlobalContext* globalCtx) { +void func_808DC038(ObjectKankyo* this, PlayState* play) { s16 i; this->unk_144 = Rand_ZeroOne() * 360.0f; @@ -92,7 +92,7 @@ void func_808DC038(ObjectKankyo* this, GlobalContext* globalCtx) { ObjectKankyo_SetupAction(this, func_808DCDB4); } -void ObjectKankyo_Init(Actor* thisx, GlobalContext* globalCtx) { +void ObjectKankyo_Init(Actor* thisx, PlayState* play) { ObjectKankyo* this = THIS; s16 i; @@ -107,28 +107,28 @@ void ObjectKankyo_Init(Actor* thisx, GlobalContext* globalCtx) { break; case 2: - globalCtx->envCtx.unk_F2[2] = 0x80; - func_808DBFB0(this, globalCtx); + play->envCtx.unk_F2[2] = 0x80; + func_808DBFB0(this, play); break; case 1: case 3: - func_808DBEB0(this, globalCtx); + func_808DBEB0(this, play); break; case 4: - func_808DC038(this, globalCtx); + func_808DC038(this, play); break; } } -void ObjectKankyo_Destroy(Actor* thisx, GlobalContext* globalCtx) { +void ObjectKankyo_Destroy(Actor* thisx, PlayState* play) { ObjectKankyo* this = THIS; Actor_MarkForDeath(&this->actor); } -void func_808DC18C(ObjectKankyo* this, GlobalContext* globalCtx) { +void func_808DC18C(ObjectKankyo* this, PlayState* play) { s32 pad; s32 pad2; s32 pad3; @@ -140,20 +140,20 @@ void func_808DC18C(ObjectKankyo* this, GlobalContext* globalCtx) { f32 x; f32 sp1C; - x = globalCtx->view.at.x - globalCtx->view.eye.x; - y = globalCtx->view.at.y - globalCtx->view.eye.y; - z = globalCtx->view.at.z - globalCtx->view.eye.z; + x = play->view.at.x - play->view.eye.x; + y = play->view.at.y - play->view.eye.y; + z = play->view.at.z - play->view.eye.z; magnitude = sqrtf(SQ(x) + SQ(y) + SQ(z)); temp_f18 = x / magnitude; x = z / magnitude; sp1C = (y / magnitude) * 120.0f; - this->unk_14C[0].unk_00 = globalCtx->view.eye.x + (temp_f18 * 50.0f); - this->unk_14C[0].unk_04 = globalCtx->view.eye.y + sp1C; - this->unk_14C[0].unk_08 = globalCtx->view.eye.z + (x * 50.0f); - this->unk_14C[1].unk_00 = globalCtx->view.eye.x + (temp_f18 * 220.0f); - this->unk_14C[1].unk_08 = globalCtx->view.eye.z + (x * 220.0f); + this->unk_14C[0].unk_00 = play->view.eye.x + (temp_f18 * 50.0f); + this->unk_14C[0].unk_04 = play->view.eye.y + sp1C; + this->unk_14C[0].unk_08 = play->view.eye.z + (x * 50.0f); + this->unk_14C[1].unk_00 = play->view.eye.x + (temp_f18 * 220.0f); + this->unk_14C[1].unk_08 = play->view.eye.z + (x * 220.0f); this->unk_114C = 0; this->unk_144 = 100.0f; @@ -163,13 +163,13 @@ void func_808DC18C(ObjectKankyo* this, GlobalContext* globalCtx) { this->unk_144 = 400.0f; if (x < 0.0f) { this->unk_14C[0].unk_00 = -350.0f; - this->unk_14C[0].unk_04 = globalCtx->view.eye.y + sp1C; + this->unk_14C[0].unk_04 = play->view.eye.y + sp1C; this->unk_14C[0].unk_08 = 3680.0f; this->unk_14C[1].unk_00 = -350.0f; this->unk_14C[1].unk_08 = 3680.0f; } else { this->unk_14C[0].unk_00 = -350.0f; - this->unk_14C[0].unk_04 = globalCtx->view.eye.y + sp1C; + this->unk_14C[0].unk_04 = play->view.eye.y + sp1C; this->unk_14C[0].unk_08 = 4280.0f; this->unk_14C[1].unk_00 = -350.0f; this->unk_14C[1].unk_08 = 4280.0f; @@ -177,17 +177,17 @@ void func_808DC18C(ObjectKankyo* this, GlobalContext* globalCtx) { } } - magnitude = globalCtx->envCtx.windSpeed / 60.0f; + magnitude = play->envCtx.windSpeed / 60.0f; magnitude = CLAMP(magnitude, 0.0f, 1.0f); - sp30.x = globalCtx->envCtx.windDir.x * magnitude; - sp30.y = globalCtx->envCtx.windDir.y + 100.0f; - sp30.z = globalCtx->envCtx.windDir.z * magnitude; + sp30.x = play->envCtx.windDir.x * magnitude; + sp30.y = play->envCtx.windDir.y + 100.0f; + sp30.z = play->envCtx.windDir.z * magnitude; this->unk_14C[2].unk_00 = 0x4000 - Math_Vec3f_Pitch(&gZeroVec3f, &sp30); this->unk_14C[2].unk_04 = Math_Vec3f_Yaw(&gZeroVec3f, &sp30) + 0x8000; } -void func_808DC454(ObjectKankyo* this, GlobalContext* globalCtx) { +void func_808DC454(ObjectKankyo* this, PlayState* play) { s16 i; u32 tempI; f32 phi_f20; @@ -201,9 +201,9 @@ void func_808DC454(ObjectKankyo* this, GlobalContext* globalCtx) { f32 temp_f22; f32 temp_f24; f32 temp_f28; - f32 x = globalCtx->view.at.x - globalCtx->view.eye.x; - f32 y = globalCtx->view.at.y - globalCtx->view.eye.y; - f32 z = globalCtx->view.at.z - globalCtx->view.eye.z; + f32 x = play->view.at.x - play->view.eye.x; + f32 y = play->view.at.y - play->view.eye.y; + f32 z = play->view.at.z - play->view.eye.z; f32 magnitude = sqrtf(SQ(x) + SQ(y) + SQ(z)); f32 temp_120 = 120.0f; f32 temp_f30; @@ -214,15 +214,15 @@ void func_808DC454(ObjectKankyo* this, GlobalContext* globalCtx) { spCC = y / magnitude; spC8 = z / magnitude; - for (i = 0; i < globalCtx->envCtx.unk_F2[2]; i++) { + for (i = 0; i < play->envCtx.unk_F2[2]; i++) { switch (this->unk_14C[i].unk_1C) { case 0: - this->unk_14C[i].unk_00 = globalCtx->view.eye.x + (spD0 * 120.0f); - this->unk_14C[i].unk_04 = globalCtx->view.eye.y + (spCC * 120.0f); - this->unk_14C[i].unk_08 = globalCtx->view.eye.z + (spC8 * 120.0f); + this->unk_14C[i].unk_00 = play->view.eye.x + (spD0 * 120.0f); + this->unk_14C[i].unk_04 = play->view.eye.y + (spCC * 120.0f); + this->unk_14C[i].unk_08 = play->view.eye.z + (spC8 * 120.0f); this->unk_14C[i].unk_0C = (Rand_ZeroOne() - 0.5f) * (2.0f * temp_120); - temp_f22 = (Camera_GetCamDirPitch(GET_ACTIVE_CAM(globalCtx)) * 0.004f) + 60.0f; + temp_f22 = (Camera_GetCamDirPitch(GET_ACTIVE_CAM(play)) * 0.004f) + 60.0f; if (temp_f22 < 20.0f) { temp_f22 = 20.0f; } @@ -232,13 +232,13 @@ void func_808DC454(ObjectKankyo* this, GlobalContext* globalCtx) { } else { this->unk_14C[i].unk_10 += temp_f22; tempI = i; - if (globalCtx->envCtx.unk_F2[2] == (tempI + 1)) { + if (play->envCtx.unk_F2[2] == (tempI + 1)) { this->unk_114E = 0; } } this->unk_14C[i].unk_14 = (Rand_ZeroOne() - 0.5f) * (2.0f * temp_120); - if (globalCtx->envCtx.unk_F2[4] == 0) { + if (play->envCtx.unk_F2[4] == 0) { this->unk_14C[i].unk_18 = (Rand_ZeroOne() * 3.0f) + 1.0f; } else { this->unk_14C[i].unk_18 = (Rand_ZeroOne() * 3.0f) + 8.0f; @@ -247,33 +247,32 @@ void func_808DC454(ObjectKankyo* this, GlobalContext* globalCtx) { break; case 1: - temp_f24 = globalCtx->view.eye.x + (spD0 * 120.0f); - temp_f28 = globalCtx->view.eye.y + (spCC * 120.0f); - temp_f30 = globalCtx->view.eye.z + (spC8 * 120.0f); + temp_f24 = play->view.eye.x + (spD0 * 120.0f); + temp_f28 = play->view.eye.y + (spCC * 120.0f); + temp_f30 = play->view.eye.z + (spC8 * 120.0f); - magnitude = sqrtf((f32)SQ(globalCtx->envCtx.windDir.x) + SQ(globalCtx->envCtx.windDir.y) + - SQ(globalCtx->envCtx.windDir.z)); + magnitude = + sqrtf((f32)SQ(play->envCtx.windDir.x) + SQ(play->envCtx.windDir.y) + SQ(play->envCtx.windDir.z)); if (magnitude == 0.0f) { magnitude = 0.001f; } - spC4 = -globalCtx->envCtx.windDir.x / magnitude; - spC0 = -globalCtx->envCtx.windDir.y / magnitude; - spBC = -globalCtx->envCtx.windDir.z / magnitude; + spC4 = -play->envCtx.windDir.x / magnitude; + spC0 = -play->envCtx.windDir.y / magnitude; + spBC = -play->envCtx.windDir.z / magnitude; if (i == 0) { this->unk_144 += 0.049999997f * Rand_ZeroOne(); this->unk_148 += 0.049999997f * Rand_ZeroOne(); } - phi_f20 = globalCtx->envCtx.windSpeed / 120.0f; + phi_f20 = play->envCtx.windSpeed / 120.0f; phi_f20 = CLAMP(phi_f20, 0.0f, 1.0f); - this->unk_14C[i].unk_0C += __sinf((this->unk_144 + (i * 100.0f)) * 0.01f) + (spC4 * 10.0f * phi_f20); - this->unk_14C[i].unk_14 += __cosf((this->unk_148 + (i * 100.0f)) * 0.01f) + (spBC * 10.0f * phi_f20); - this->unk_14C[i].unk_10 -= - this->unk_14C[i].unk_18 - (spC0 * 3.0f * (globalCtx->envCtx.windSpeed / 100.0f)); + 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 * (play->envCtx.windSpeed / 100.0f)); - temp_f22 = (-Camera_GetCamDirPitch(GET_ACTIVE_CAM(globalCtx)) * 0.012f) + 40.0f; + temp_f22 = (-Camera_GetCamDirPitch(GET_ACTIVE_CAM(play)) * 0.012f) + 40.0f; if (temp_f22 < -40.0f) { temp_f22 = -40.0f; } @@ -290,7 +289,7 @@ void func_808DC454(ObjectKankyo* this, GlobalContext* globalCtx) { sp88.y = this->unk_14C[i].unk_04 + this->unk_14C[i].unk_10; sp88.z = this->unk_14C[i].unk_08 + this->unk_14C[i].unk_14; - phi_f20 = Math_Vec3f_DistXZ(&sp88, &globalCtx->view.eye) / 200.0f; + phi_f20 = Math_Vec3f_DistXZ(&sp88, &play->view.eye) / 200.0f; phi_f20 = CLAMP(phi_f20, 0.0f, 1.0f); temp_f0_4 = 100.0f + phi_f20 + 60.0f; @@ -310,8 +309,7 @@ void func_808DC454(ObjectKankyo* this, GlobalContext* globalCtx) { this->unk_14C[i].unk_08 = temp_f30 + temp_120; } - if ((this->unk_14C[i].unk_04 + this->unk_14C[i].unk_10) < - ((globalCtx->view.eye.y - temp_f22) - 40.0f)) { + if ((this->unk_14C[i].unk_04 + this->unk_14C[i].unk_10) < ((play->view.eye.y - temp_f22) - 40.0f)) { this->unk_14C[i].unk_1C = 0; } break; @@ -319,45 +317,45 @@ void func_808DC454(ObjectKankyo* this, GlobalContext* globalCtx) { } } -void func_808DCB7C(ObjectKankyo* this, GlobalContext* globalCtx) { - if (globalCtx->envCtx.unk_F2[2] < globalCtx->envCtx.unk_F2[3]) { - if ((globalCtx->state.frames % 16) == 0) { - globalCtx->envCtx.unk_F2[2] += 2; +void func_808DCB7C(ObjectKankyo* this, PlayState* play) { + if (play->envCtx.unk_F2[2] < play->envCtx.unk_F2[3]) { + if ((play->state.frames % 16) == 0) { + play->envCtx.unk_F2[2] += 2; } - } else if (globalCtx->envCtx.unk_F2[3] < globalCtx->envCtx.unk_F2[2]) { - if ((globalCtx->state.frames % 16) == 0) { - globalCtx->envCtx.unk_F2[2] -= 2; + } else if (play->envCtx.unk_F2[3] < play->envCtx.unk_F2[2]) { + if ((play->state.frames % 16) == 0) { + play->envCtx.unk_F2[2] -= 2; } } - func_808DC454(this, globalCtx); + func_808DC454(this, play); } -void func_808DCBF8(ObjectKankyo* this, GlobalContext* globalCtx) { +void func_808DCBF8(ObjectKankyo* this, PlayState* play) { f32 temp_f0; - if ((globalCtx->envCtx.unk_F2[2] > 0) && (this->unk_114C == 0)) { - if ((globalCtx->state.frames % 16) == 0) { - globalCtx->envCtx.unk_F2[2] -= 9; - if ((s8)globalCtx->envCtx.unk_F2[2] < 0) { - globalCtx->envCtx.unk_F2[2] = 0; + if ((play->envCtx.unk_F2[2] > 0) && (this->unk_114C == 0)) { + if ((play->state.frames % 16) == 0) { + play->envCtx.unk_F2[2] -= 9; + if ((s8)play->envCtx.unk_F2[2] < 0) { + play->envCtx.unk_F2[2] = 0; } } } - temp_f0 = (f32)globalCtx->envCtx.unk_F2[2] / 128; + temp_f0 = (f32)play->envCtx.unk_F2[2] / 128; temp_f0 = CLAMP(temp_f0, 0.0f, 1.0f); if (temp_f0 > 0.01f) { D_801F4E30 = 155.0f * temp_f0; - globalCtx->envCtx.sandstormState = 10; + play->envCtx.sandstormState = 10; } else { D_801F4E30 = 0; - globalCtx->envCtx.sandstormState = 10; + play->envCtx.sandstormState = 10; } - func_808DC454(this, globalCtx); + func_808DC454(this, play); } -void func_808DCDB4(ObjectKankyo* this, GlobalContext* globalCtx) { +void func_808DCDB4(ObjectKankyo* this, PlayState* play) { s16 i; f32 magnitude; f32 temp_80; @@ -379,9 +377,9 @@ void func_808DCDB4(ObjectKankyo* this, GlobalContext* globalCtx) { this->unk_114C++; } - x = globalCtx->view.at.x - globalCtx->view.eye.x; - y = globalCtx->view.at.y - globalCtx->view.eye.y; - z = globalCtx->view.at.z - globalCtx->view.eye.z; + x = play->view.at.x - play->view.eye.x; + y = play->view.at.y - play->view.eye.y; + z = play->view.at.z - play->view.eye.z; magnitude = sqrtf(SQ(x) + SQ(y) + SQ(z)); @@ -395,9 +393,9 @@ void func_808DCDB4(ObjectKankyo* this, GlobalContext* globalCtx) { for (i = 0; i < this->unk_114C; i++) { switch (this->unk_14C[i].unk_1C) { case 0: - this->unk_14C[i].unk_00 = globalCtx->view.eye.x + (spAC * 120.0f); - this->unk_14C[i].unk_04 = globalCtx->view.eye.y + (spA8 * 120.0f); - this->unk_14C[i].unk_08 = globalCtx->view.eye.z + (spA4 * 120.0f); + this->unk_14C[i].unk_00 = play->view.eye.x + (spAC * 120.0f); + this->unk_14C[i].unk_04 = play->view.eye.y + (spA8 * 120.0f); + this->unk_14C[i].unk_08 = play->view.eye.z + (spA4 * 120.0f); this->unk_14C[i].unk_0C = (Rand_ZeroOne() - 0.5f) * (temp_120 * 2.0f); if ((i % 2) == 0) { this->unk_14C[i].unk_10 = -100.0f; @@ -411,37 +409,37 @@ void func_808DCDB4(ObjectKankyo* this, GlobalContext* globalCtx) { case 1: - temp_f26 = globalCtx->view.eye.x + (spAC * 120.0f); - temp_f28 = globalCtx->view.eye.y + (spA8 * 120.0f); - temp_f18 = globalCtx->view.eye.z + (spA4 * 120.0f); + temp_f26 = play->view.eye.x + (spAC * 120.0f); + temp_f28 = play->view.eye.y + (spA8 * 120.0f); + temp_f18 = play->view.eye.z + (spA4 * 120.0f); - magnitude = sqrtf((f32)SQ(globalCtx->envCtx.windDir.x) + SQ(globalCtx->envCtx.windDir.y) + - SQ(globalCtx->envCtx.windDir.z)); + magnitude = + sqrtf((f32)SQ(play->envCtx.windDir.x) + SQ(play->envCtx.windDir.y) + SQ(play->envCtx.windDir.z)); if (magnitude == 0.0f) { magnitude = 0.001f; } - spA0 = -globalCtx->envCtx.windDir.x / magnitude; - sp9C = -globalCtx->envCtx.windDir.z / magnitude; + spA0 = -play->envCtx.windDir.x / magnitude; + sp9C = -play->envCtx.windDir.z / magnitude; if (i == 0) { this->unk_144 += 0.049999997f * Rand_ZeroOne(); this->unk_148 += 0.049999997f * Rand_ZeroOne(); } - temp_f20 = globalCtx->envCtx.windSpeed / 120.0f; + temp_f20 = play->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; - if ((this->unk_14C[i].unk_04 + this->unk_14C[i].unk_10) > (globalCtx->view.eye.y + 100.0f)) { + if ((this->unk_14C[i].unk_04 + this->unk_14C[i].unk_10) > (play->view.eye.y + 100.0f)) { this->unk_14C[i].unk_1C = 0; } } else { this->unk_14C[i].unk_10 -= this->unk_14C[i].unk_18; - if ((this->unk_14C[i].unk_04 + this->unk_14C[i].unk_10) < (globalCtx->view.eye.y - 100.0f)) { + if ((this->unk_14C[i].unk_04 + this->unk_14C[i].unk_10) < (play->view.eye.y - 100.0f)) { this->unk_14C[i].unk_1C = 0; } } @@ -474,37 +472,37 @@ void func_808DCDB4(ObjectKankyo* this, GlobalContext* globalCtx) { } } -void ObjectKankyo_Update(Actor* thisx, GlobalContext* globalCtx) { +void ObjectKankyo_Update(Actor* thisx, PlayState* play) { ObjectKankyo* this = THIS; - this->actionFunc(this, globalCtx); + this->actionFunc(this, play); } -void ObjectKankyo_Draw(Actor* thisx, GlobalContext* globalCtx) { +void ObjectKankyo_Draw(Actor* thisx, PlayState* play) { ObjectKankyo* this = THIS; switch (this->actor.params) { case 0: - func_808DDE9C(thisx, globalCtx); + func_808DDE9C(thisx, play); break; case 1: case 2: case 3: - func_808DD3C8(thisx, globalCtx); + func_808DD3C8(thisx, play); break; case 4: - func_808DD970(thisx, globalCtx); + func_808DD970(thisx, play); break; } } -void func_808DD3C8(Actor* thisx, GlobalContext* globalCtx2) { - GlobalContext* globalCtx = globalCtx2; +void func_808DD3C8(Actor* thisx, PlayState* play2) { + PlayState* play = play2; ObjectKankyo* this = THIS; - Vec3f spC4; - Vec3f spB8; + Vec3f worldPos; + Vec3f screenPos; s16 i; u8 pad2; u8 spB4; @@ -514,35 +512,37 @@ void func_808DD3C8(Actor* thisx, GlobalContext* globalCtx2) { f32 temp_f2; f32 tempf; - if ((globalCtx->cameraPtrs[CAM_ID_MAIN]->flags2 & 0x100) || ((u8)globalCtx->envCtx.unk_E2 == 0)) { + if ((play->cameraPtrs[CAM_ID_MAIN]->stateFlags & CAM_STATE_UNDERWATER) || ((u8)play->envCtx.unk_E2 == 0)) { return; } - OPEN_DISPS(globalCtx->state.gfxCtx); + OPEN_DISPS(play->state.gfxCtx); spB4 = false; if (this->actor.params == 3) { - temp_f0 = func_80173B48(&globalCtx->state) / 1.4e7f; + temp_f0 = func_80173B48(&play->state) / 1.4e7f; temp_f0 = CLAMP(temp_f0, 0.0f, 1.0f); Math_SmoothStepToF(&D_808DE5B0, temp_f0, 0.2f, 0.1f, 0.001f); - sp68 = globalCtx->envCtx.unk_F2[2]; + sp68 = play->envCtx.unk_F2[2]; sp68 *= D_808DE5B0; - if ((globalCtx->envCtx.unk_F2[2] >= 32) && (sp68 < 32)) { + if ((play->envCtx.unk_F2[2] >= 32) && (sp68 < 32)) { sp68 = 32; } } else { - sp68 = globalCtx->envCtx.unk_F2[2]; + sp68 = play->envCtx.unk_F2[2]; } for (i = 0; i < sp68; i++) { - spC4.x = this->unk_14C[i].unk_00 + this->unk_14C[i].unk_0C; - spC4.y = this->unk_14C[i].unk_04 + this->unk_14C[i].unk_10; - spC4.z = this->unk_14C[i].unk_08 + this->unk_14C[i].unk_14; - func_80169474(globalCtx, &spC4, &spB8); + worldPos.x = this->unk_14C[i].unk_00 + this->unk_14C[i].unk_0C; + worldPos.y = this->unk_14C[i].unk_04 + this->unk_14C[i].unk_10; + worldPos.z = this->unk_14C[i].unk_08 + this->unk_14C[i].unk_14; - if ((spB8.x >= 0.0f) && (spB8.x < 320.0f) && (spB8.y >= 0.0f) && (spB8.y < 240.0f)) { + Play_GetScreenPos(play, &worldPos, &screenPos); + + if ((screenPos.x >= 0.0f) && (screenPos.x < SCREEN_WIDTH) && (screenPos.y >= 0.0f) && + (screenPos.y < SCREEN_HEIGHT)) { if (!spB4) { spB4 = true; @@ -557,44 +557,43 @@ 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(worldPos.x, worldPos.y, worldPos.z, MTXMODE_NEW); tempf = (i & 7) * 0.008f; Matrix_Scale(0.05f + tempf, 0.05f + tempf, 0.05f + tempf, MTXMODE_APPLY); - temp_f2 = Math_Vec3f_DistXYZ(&spC4, &globalCtx->view.eye) / 300.0f; + temp_f2 = Math_Vec3f_DistXYZ(&worldPos, &play->view.eye) / 300.0f; temp_f2 = ((1.0f < temp_f2) ? 0.0f : (((1.0f - temp_f2) > 1.0f) ? 1.0f : 1.0f - temp_f2)); gDPPipeSync(POLY_XLU_DISP++); gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 255, 255, 255, (u8)(160.0f * temp_f2)); - Matrix_InsertMatrix(&globalCtx->billboardMtxF, MTXMODE_APPLY); + Matrix_Mult(&play->billboardMtxF, MTXMODE_APPLY); - gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), - G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_XLU_DISP++, gameplay_keep_DL_023130); } } - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->state.gfxCtx); } -void func_808DD970(Actor* thisx, GlobalContext* globalCtx2) { +void func_808DD970(Actor* thisx, PlayState* play2) { f32 temp_f0; f32 temp_f20; - Vec3f spBC; - Vec3f spB0; + Vec3f worldPos; + Vec3f screenPos; f32 tempf; s16 i; f32 phi_f26; - GlobalContext* globalCtx = globalCtx2; + PlayState* play = play2; ObjectKankyo* this = THIS; f32 tempA; - if (globalCtx->sceneNum == SCENE_KYOJINNOMA) { + if (play->sceneNum == SCENE_KYOJINNOMA) { phi_f26 = 1.0f; } else { - tempA = Camera_GetWaterYPos(GET_ACTIVE_CAM(globalCtx)); + tempA = Camera_GetWaterYPos(GET_ACTIVE_CAM(play)); if (tempA != BGCHECK_Y_MIN) { - tempA -= globalCtx->view.eye.y; + tempA -= play->view.eye.y; phi_f26 = tempA / 4000.0f; } else { phi_f26 = 0.0f; @@ -602,33 +601,34 @@ void func_808DD970(Actor* thisx, GlobalContext* globalCtx2) { phi_f26 = CLAMP_MAX(phi_f26, 1.0f); - if (!(globalCtx->cameraPtrs[CAM_ID_MAIN]->flags2 & 0x100) || (phi_f26 == 0.0f)) { + if (!(play->cameraPtrs[CAM_ID_MAIN]->stateFlags & CAM_STATE_UNDERWATER) || (phi_f26 == 0.0f)) { return; } } - OPEN_DISPS(globalCtx->state.gfxCtx); + OPEN_DISPS(play->state.gfxCtx); for (i = 0; i < this->unk_114C; i++) { - spBC.x = this->unk_14C[i].unk_00 + this->unk_14C[i].unk_0C; - spBC.y = this->unk_14C[i].unk_04 + this->unk_14C[i].unk_10; - spBC.z = this->unk_14C[i].unk_08 + this->unk_14C[i].unk_14; - func_80169474(globalCtx, &spBC, &spB0); + worldPos.x = this->unk_14C[i].unk_00 + this->unk_14C[i].unk_0C; + worldPos.y = this->unk_14C[i].unk_04 + this->unk_14C[i].unk_10; + worldPos.z = this->unk_14C[i].unk_08 + this->unk_14C[i].unk_14; - 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); + Play_GetScreenPos(play, &worldPos, &screenPos); + + if ((screenPos.x >= 0.0f) && (screenPos.x < SCREEN_WIDTH) && (screenPos.y >= 0.0f) && + (screenPos.y < SCREEN_HEIGHT)) { + Matrix_Translate(worldPos.x, worldPos.y, worldPos.z, MTXMODE_NEW); Matrix_Scale(0.03f, 0.03f, 0.03f, MTXMODE_APPLY); - temp_f0 = Math_Vec3f_DistXYZ(&spBC, &globalCtx->view.eye); + temp_f0 = Math_Vec3f_DistXYZ(&worldPos, &play->view.eye); temp_f0 = (u8)(255.0f * phi_f26) * (1.0f - (temp_f0 / 300.0f)); gDPPipeSync(POLY_XLU_DISP++); gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 255, 255, 55, temp_f0); gDPSetEnvColor(POLY_XLU_DISP++, 55, 50, 255, temp_f0); - Matrix_InsertMatrix(&globalCtx->billboardMtxF, MTXMODE_APPLY); + Matrix_Mult(&play->billboardMtxF, MTXMODE_APPLY); - gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), - G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPSegment(POLY_XLU_DISP++, 0x08, Lib_SegmentedToVirtual(gDust5Tex)); gSPClearGeometryMode(POLY_XLU_DISP++, G_LIGHTING); @@ -640,7 +640,7 @@ void func_808DD970(Actor* thisx, GlobalContext* globalCtx2) { } } - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->state.gfxCtx); } f32 func_808DDE74(void) { @@ -648,23 +648,22 @@ f32 func_808DDE74(void) { } #ifdef NON_MATCHING -// globalCtx->envCtx.unk_F2[1] needs to be laoded into s0 and then copied to s7 -void func_808DDE9C(Actor* thisx, GlobalContext* globalCtx2) { - GlobalContext* globalCtx = globalCtx2; +// s2/s3 swapped +void func_808DDE9C(Actor* thisx, PlayState* play2) { + PlayState* play = play2; ObjectKankyo* this = THIS; - Player* player = GET_PLAYER(globalCtx); + Player* player = GET_PLAYER(play); s32 i; - s16 temp; + u8 phi_s5; + u16 end = play->envCtx.unk_F2[1]; f32 temp_f12; f32 temp_f20; f32 temp_f22; f32 temp_f2; - u8 phi_s5; - s32 end = globalCtx->envCtx.unk_F2[1]; - OPEN_DISPS(globalCtx->state.gfxCtx); + OPEN_DISPS(play->state.gfxCtx); - if (end != 0) { + if (end) { gDPPipeSync(POLY_XLU_DISP++); gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 150, 255, 255, 25); POLY_XLU_DISP = Gfx_CallSetupDL(POLY_XLU_DISP, 20); @@ -679,12 +678,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); @@ -692,15 +691,15 @@ void func_808DDE9C(Actor* thisx, GlobalContext* globalCtx2) { Matrix_Scale(2.0f, 4.0f, 2.0f, MTXMODE_APPLY); } - gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_XLU_DISP++, gameplay_keep_DL_0706E0); } phi_s5 = false; - if (player->actor.floorHeight < globalCtx->view.eye.y) { + if (player->actor.floorHeight < play->view.eye.y) { for (i = 0; i < end; i++) { if (!phi_s5) { - func_8012C2DC(globalCtx->state.gfxCtx); + func_8012C2DC(play->state.gfxCtx); gDPSetEnvColor(POLY_XLU_DISP++, 255, 255, 255, 255); gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 255, 255, 255, 100); @@ -715,17 +714,16 @@ 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); + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_XLU_DISP++, gEffShockwaveDL); } } - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->state.gfxCtx); } #else #pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Object_Kankyo/func_808DDE9C.s") diff --git a/src/overlays/actors/ovl_Object_Kankyo/z_object_kankyo.h b/src/overlays/actors/ovl_Object_Kankyo/z_object_kankyo.h index 646863be0..c6e374da8 100644 --- a/src/overlays/actors/ovl_Object_Kankyo/z_object_kankyo.h +++ b/src/overlays/actors/ovl_Object_Kankyo/z_object_kankyo.h @@ -5,7 +5,7 @@ struct ObjectKankyo; -typedef void (*ObjectKankyoActionFunc)(struct ObjectKankyo*, GlobalContext*); +typedef void (*ObjectKankyoActionFunc)(struct ObjectKankyo*, PlayState*); typedef struct { /* 0x00 */ f32 unk_00; 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 18d28f8c7..91a5d3e66 100644 --- a/src/overlays/actors/ovl_Oceff_Spot/z_oceff_spot.c +++ b/src/overlays/actors/ovl_Oceff_Spot/z_oceff_spot.c @@ -10,13 +10,13 @@ #define THIS ((OceffSpot*)thisx) -void OceffSpot_Init(Actor* thisx, GlobalContext* globalCtx); -void OceffSpot_Destroy(Actor* thisx, GlobalContext* globalCtx); -void OceffSpot_Update(Actor* thisx, GlobalContext* globalCtx); -void OceffSpot_Draw(Actor* thisx, GlobalContext* globalCtx); +void OceffSpot_Init(Actor* thisx, PlayState* play); +void OceffSpot_Destroy(Actor* thisx, PlayState* play); +void OceffSpot_Update(Actor* thisx, PlayState* play); +void OceffSpot_Draw(Actor* thisx, PlayState* play); -void func_809728F8(OceffSpot* this, GlobalContext* globalCtx); -void func_80972934(OceffSpot* this, GlobalContext* globalCtx); +void func_809728F8(OceffSpot* this, PlayState* play); +void func_80972934(OceffSpot* this, PlayState* play); void OceffSpot_SetupAction(OceffSpot* this, OceffSpotActionFunc actionFunc); diff --git a/src/overlays/actors/ovl_Oceff_Spot/z_oceff_spot.h b/src/overlays/actors/ovl_Oceff_Spot/z_oceff_spot.h index fa92acb98..922b1f89b 100644 --- a/src/overlays/actors/ovl_Oceff_Spot/z_oceff_spot.h +++ b/src/overlays/actors/ovl_Oceff_Spot/z_oceff_spot.h @@ -5,12 +5,12 @@ struct OceffSpot; -typedef void (*OceffSpotActionFunc)(struct OceffSpot*, GlobalContext*); +typedef void (*OceffSpotActionFunc)(struct OceffSpot*, PlayState*); typedef struct OceffSpot { - /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x30]; - /* 0x0174 */ OceffSpotActionFunc actionFunc; + /* 0x000 */ Actor actor; + /* 0x144 */ char unk_144[0x30]; + /* 0x174 */ OceffSpotActionFunc actionFunc; } OceffSpot; // size = 0x178 extern const ActorInit Oceff_Spot_InitVars; diff --git a/src/overlays/actors/ovl_Oceff_Storm/z_oceff_storm.c b/src/overlays/actors/ovl_Oceff_Storm/z_oceff_storm.c index 1939b1ef0..68ee9d27f 100644 --- a/src/overlays/actors/ovl_Oceff_Storm/z_oceff_storm.c +++ b/src/overlays/actors/ovl_Oceff_Storm/z_oceff_storm.c @@ -10,13 +10,13 @@ #define THIS ((OceffStorm*)thisx) -void OceffStorm_Init(Actor* thisx, GlobalContext* globalCtx); -void OceffStorm_Destroy(Actor* thisx, GlobalContext* globalCtx); -void OceffStorm_Update(Actor* thisx, GlobalContext* globalCtx); -void OceffStorm_Draw(Actor* thisx, GlobalContext* globalCtx); +void OceffStorm_Init(Actor* thisx, PlayState* play); +void OceffStorm_Destroy(Actor* thisx, PlayState* play); +void OceffStorm_Update(Actor* thisx, PlayState* play); +void OceffStorm_Draw(Actor* thisx, PlayState* play); -void func_80981928(OceffStorm* this, GlobalContext* globalCtx); -void func_80981B48(OceffStorm* this, GlobalContext* globalCtx); +void func_80981928(OceffStorm* this, PlayState* play); +void func_80981B48(OceffStorm* this, PlayState* play); void OceffStorm_SetupAction(OceffStorm* this, OceffStormActionFunc actionFunc); diff --git a/src/overlays/actors/ovl_Oceff_Storm/z_oceff_storm.h b/src/overlays/actors/ovl_Oceff_Storm/z_oceff_storm.h index 892632a4a..460ede844 100644 --- a/src/overlays/actors/ovl_Oceff_Storm/z_oceff_storm.h +++ b/src/overlays/actors/ovl_Oceff_Storm/z_oceff_storm.h @@ -5,12 +5,12 @@ struct OceffStorm; -typedef void (*OceffStormActionFunc)(struct OceffStorm*, GlobalContext*); +typedef void (*OceffStormActionFunc)(struct OceffStorm*, PlayState*); typedef struct OceffStorm { - /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x8]; - /* 0x014C */ OceffStormActionFunc actionFunc; + /* 0x000 */ Actor actor; + /* 0x144 */ char unk_144[0x8]; + /* 0x14C */ OceffStormActionFunc actionFunc; } OceffStorm; // size = 0x150 extern const ActorInit Oceff_Storm_InitVars; diff --git a/src/overlays/actors/ovl_Oceff_Wipe/z_oceff_wipe.c b/src/overlays/actors/ovl_Oceff_Wipe/z_oceff_wipe.c index 1179f5ba2..661c13a1b 100644 --- a/src/overlays/actors/ovl_Oceff_Wipe/z_oceff_wipe.c +++ b/src/overlays/actors/ovl_Oceff_Wipe/z_oceff_wipe.c @@ -10,10 +10,10 @@ #define THIS ((OceffWipe*)thisx) -void OceffWipe_Init(Actor* thisx, GlobalContext* globalCtx); -void OceffWipe_Destroy(Actor* thisx, GlobalContext* globalCtx); -void OceffWipe_Update(Actor* thisx, GlobalContext* globalCtx); -void OceffWipe_Draw(Actor* thisx, GlobalContext* globalCtx); +void OceffWipe_Init(Actor* thisx, PlayState* play); +void OceffWipe_Destroy(Actor* thisx, PlayState* play); +void OceffWipe_Update(Actor* thisx, PlayState* play); +void OceffWipe_Draw(Actor* thisx, PlayState* play); #if 0 const ActorInit Oceff_Wipe_InitVars = { 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 61a1ae549..ca7ff8de2 100644 --- a/src/overlays/actors/ovl_Oceff_Wipe2/z_oceff_wipe2.c +++ b/src/overlays/actors/ovl_Oceff_Wipe2/z_oceff_wipe2.c @@ -10,10 +10,10 @@ #define THIS ((OceffWipe2*)thisx) -void OceffWipe2_Init(Actor* thisx, GlobalContext* globalCtx); -void OceffWipe2_Destroy(Actor* thisx, GlobalContext* globalCtx); -void OceffWipe2_Update(Actor* thisx, GlobalContext* globalCtx); -void OceffWipe2_Draw(Actor* thisx, GlobalContext* globalCtx); +void OceffWipe2_Init(Actor* thisx, PlayState* play); +void OceffWipe2_Destroy(Actor* thisx, PlayState* play); +void OceffWipe2_Update(Actor* thisx, PlayState* play); +void OceffWipe2_Draw(Actor* thisx, PlayState* play); #if 0 const ActorInit Oceff_Wipe2_InitVars = { 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 a8745c015..fb1f2a45d 100644 --- a/src/overlays/actors/ovl_Oceff_Wipe3/z_oceff_wipe3.c +++ b/src/overlays/actors/ovl_Oceff_Wipe3/z_oceff_wipe3.c @@ -4,16 +4,17 @@ * Description: Unused OoT Saria's Song Ocarina Effect */ +#include "prevent_bss_reordering.h" #include "z_oceff_wipe3.h" #define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_2000000) #define THIS ((OceffWipe3*)thisx) -void OceffWipe3_Init(Actor* thisx, GlobalContext* globalCtx); -void OceffWipe3_Destroy(Actor* thisx, GlobalContext* globalCtx); -void OceffWipe3_Update(Actor* thisx, GlobalContext* globalCtx); -void OceffWipe3_Draw(Actor* thisx, GlobalContext* globalCtx); +void OceffWipe3_Init(Actor* thisx, PlayState* play); +void OceffWipe3_Destroy(Actor* thisx, PlayState* play); +void OceffWipe3_Update(Actor* thisx, PlayState* play); +void OceffWipe3_Draw(Actor* thisx, PlayState* play); #if 0 const ActorInit Oceff_Wipe3_InitVars = { 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 b985aadad..56942962d 100644 --- a/src/overlays/actors/ovl_Oceff_Wipe4/z_oceff_wipe4.c +++ b/src/overlays/actors/ovl_Oceff_Wipe4/z_oceff_wipe4.c @@ -10,10 +10,10 @@ #define THIS ((OceffWipe4*)thisx) -void OceffWipe4_Init(Actor* thisx, GlobalContext* globalCtx); -void OceffWipe4_Destroy(Actor* thisx, GlobalContext* globalCtx); -void OceffWipe4_Update(Actor* thisx, GlobalContext* globalCtx); -void OceffWipe4_Draw(Actor* thisx, GlobalContext* globalCtx); +void OceffWipe4_Init(Actor* thisx, PlayState* play); +void OceffWipe4_Destroy(Actor* thisx, PlayState* play); +void OceffWipe4_Update(Actor* thisx, PlayState* play); +void OceffWipe4_Draw(Actor* thisx, PlayState* play); #if 0 const ActorInit Oceff_Wipe4_InitVars = { 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 e39a4aa4c..1bef04db8 100644 --- a/src/overlays/actors/ovl_Oceff_Wipe5/z_oceff_wipe5.c +++ b/src/overlays/actors/ovl_Oceff_Wipe5/z_oceff_wipe5.c @@ -10,10 +10,10 @@ #define THIS ((OceffWipe5*)thisx) -void OceffWipe5_Init(Actor* thisx, GlobalContext* globalCtx); -void OceffWipe5_Destroy(Actor* thisx, GlobalContext* globalCtx); -void OceffWipe5_Update(Actor* thisx, GlobalContext* globalCtx); -void OceffWipe5_Draw(Actor* thisx, GlobalContext* globalCtx); +void OceffWipe5_Init(Actor* thisx, PlayState* play); +void OceffWipe5_Destroy(Actor* thisx, PlayState* play); +void OceffWipe5_Update(Actor* thisx, PlayState* play); +void OceffWipe5_Draw(Actor* thisx, PlayState* play); #if 0 const ActorInit Oceff_Wipe5_InitVars = { 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 a16821f00..3dd701dbf 100644 --- a/src/overlays/actors/ovl_Oceff_Wipe6/z_oceff_wipe6.c +++ b/src/overlays/actors/ovl_Oceff_Wipe6/z_oceff_wipe6.c @@ -10,10 +10,10 @@ #define THIS ((OceffWipe6*)thisx) -void OceffWipe6_Init(Actor* thisx, GlobalContext* globalCtx); -void OceffWipe6_Destroy(Actor* thisx, GlobalContext* globalCtx); -void OceffWipe6_Update(Actor* thisx, GlobalContext* globalCtx); -void OceffWipe6_Draw(Actor* thisx, GlobalContext* globalCtx); +void OceffWipe6_Init(Actor* thisx, PlayState* play); +void OceffWipe6_Destroy(Actor* thisx, PlayState* play); +void OceffWipe6_Update(Actor* thisx, PlayState* play); +void OceffWipe6_Draw(Actor* thisx, PlayState* play); const ActorInit Oceff_Wipe6_InitVars = { ACTOR_OCEFF_WIPE6, @@ -29,23 +29,23 @@ const ActorInit Oceff_Wipe6_InitVars = { #include "overlays/ovl_Oceff_Wipe6/ovl_Oceff_Wipe6.c" -void OceffWipe6_Init(Actor* thisx, GlobalContext* globalCtx) { +void OceffWipe6_Init(Actor* thisx, PlayState* play) { OceffWipe6* this = THIS; Actor_SetScale(&this->actor, 1.0f); this->counter = 0; - this->actor.world.pos = GET_ACTIVE_CAM(globalCtx)->eye; + this->actor.world.pos = GET_ACTIVE_CAM(play)->eye; } -void OceffWipe6_Destroy(Actor* thisx, GlobalContext* globalCtx) { - func_80115D5C(&globalCtx->state); - globalCtx->msgCtx.unk120B0 = 0; +void OceffWipe6_Destroy(Actor* thisx, PlayState* play) { + func_80115D5C(&play->state); + play->msgCtx.unk120B0 = 0; } -void OceffWipe6_Update(Actor* thisx, GlobalContext* globalCtx) { +void OceffWipe6_Update(Actor* thisx, PlayState* play) { OceffWipe6* this = THIS; - this->actor.world.pos = GET_ACTIVE_CAM(globalCtx)->eye; + this->actor.world.pos = GET_ACTIVE_CAM(play)->eye; if (this->counter < 100) { this->counter++; } else { @@ -53,7 +53,7 @@ void OceffWipe6_Update(Actor* thisx, GlobalContext* globalCtx) { } } -void OceffWipe6_Draw(Actor* thisx, GlobalContext* globalCtx) { +void OceffWipe6_Draw(Actor* thisx, PlayState* play) { OceffWipe6* this = THIS; f32 z; u8 alpha; @@ -64,8 +64,8 @@ void OceffWipe6_Draw(Actor* thisx, GlobalContext* globalCtx) { Vec3f quakeOffset; s32 pad2; - activeCamEye = GET_ACTIVE_CAM(globalCtx)->eye; - Camera_GetQuakeOffset(&quakeOffset, GET_ACTIVE_CAM(globalCtx)); + activeCamEye = GET_ACTIVE_CAM(play)->eye; + Camera_GetQuakeOffset(&quakeOffset, GET_ACTIVE_CAM(play)); if (this->counter < 32) { counter = this->counter; @@ -84,18 +84,18 @@ void OceffWipe6_Draw(Actor* thisx, GlobalContext* globalCtx) { gOceff6Vtx[i].v.cn[3] = alpha; } - OPEN_DISPS(globalCtx->state.gfxCtx); + OPEN_DISPS(play->state.gfxCtx); - func_8012C2DC(globalCtx->state.gfxCtx); - Matrix_InsertTranslation(activeCamEye.x + quakeOffset.x, activeCamEye.y + quakeOffset.y, - activeCamEye.z + quakeOffset.z, MTXMODE_NEW); + func_8012C2DC(play->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_NormalizeXYZ(&globalCtx->billboardMtxF); - Matrix_InsertXRotation_s(0x708, MTXMODE_APPLY); - Matrix_InsertTranslation(0.0f, 0.0f, -z, MTXMODE_APPLY); - gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - AnimatedMat_Draw(globalCtx, ovl_Oceff_Wipe6_Matanimheader_000338); + Matrix_ReplaceRotation(&play->billboardMtxF); + Matrix_RotateXS(0x708, MTXMODE_APPLY); + Matrix_Translate(0.0f, 0.0f, -z, MTXMODE_APPLY); + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + AnimatedMat_Draw(play, ovl_Oceff_Wipe6_Matanimheader_000338); gSPDisplayList(POLY_XLU_DISP++, gOceff6DL); - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->state.gfxCtx); } 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 da295b768..5a71ef0d1 100644 --- a/src/overlays/actors/ovl_Oceff_Wipe7/z_oceff_wipe7.c +++ b/src/overlays/actors/ovl_Oceff_Wipe7/z_oceff_wipe7.c @@ -10,12 +10,11 @@ #define THIS ((OceffWipe7*)thisx) -void OceffWipe7_Init(Actor* thisx, GlobalContext* globalCtx); -void OceffWipe7_Destroy(Actor* thisx, GlobalContext* globalCtx); -void OceffWipe7_Update(Actor* thisx, GlobalContext* globalCtx); -void OceffWipe7_Draw(Actor* thisx, GlobalContext* globalCtx); +void OceffWipe7_Init(Actor* thisx, PlayState* play); +void OceffWipe7_Destroy(Actor* thisx, PlayState* play); +void OceffWipe7_Update(Actor* thisx, PlayState* play); +void OceffWipe7_Draw(Actor* thisx, PlayState* play); -#if 0 const ActorInit Oceff_Wipe7_InitVars = { ACTOR_OCEFF_WIPE7, ACTORCAT_ITEMACTION, @@ -28,12 +27,77 @@ const ActorInit Oceff_Wipe7_InitVars = { (ActorFunc)OceffWipe7_Draw, }; -#endif +#include "assets/overlays/ovl_Oceff_Wipe7/ovl_Oceff_Wipe7.c" -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Oceff_Wipe7/OceffWipe7_Init.s") +s32 D_80BCEB10; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Oceff_Wipe7/OceffWipe7_Destroy.s") +void OceffWipe7_Init(Actor* thisx, PlayState* play) { + OceffWipe7* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Oceff_Wipe7/OceffWipe7_Update.s") + Actor_SetScale(&this->actor, 1.0f); + this->counter = 0; + this->actor.world.pos = GET_ACTIVE_CAM(play)->eye; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Oceff_Wipe7/OceffWipe7_Draw.s") +void OceffWipe7_Destroy(Actor* thisx, PlayState* play) { + OceffWipe7* this = THIS; + + func_80115D5C(&play->state); + play->msgCtx.unk120B0 = 0; +} + +void OceffWipe7_Update(Actor* thisx, PlayState* play) { + OceffWipe7* this = THIS; + + this->actor.world.pos = GET_ACTIVE_CAM(play)->eye; + if (this->counter < 100) { + this->counter++; + } else { + Actor_MarkForDeath(&this->actor); + } +} + +void OceffWipe7_Draw(Actor* thisx, PlayState* play) { + OceffWipe7* this = THIS; + f32 z; + u8 alpha; + s32 i; + s32 counter; + Vec3f activeCamEye = GET_ACTIVE_CAM(play)->eye; + s32 pad; + Vec3f quakeOffset; + s32 pad2; + + Camera_GetQuakeOffset(&quakeOffset, GET_ACTIVE_CAM(play)); + + if (this->counter < 32) { + z = Math_SinS(this->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(sSongofHealingEffectFrustrumVtx); i += 2) { + sSongofHealingEffectFrustrumVtx[i].v.cn[3] = alpha; + } + + OPEN_DISPS(play->state.gfxCtx); + + func_8012C2DC(play->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(&play->billboardMtxF); + Matrix_RotateXS(0x708, MTXMODE_APPLY); + Matrix_Translate(0.0f, 0.0f, -z, MTXMODE_APPLY); + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + AnimatedMat_Draw(play, sSongofHealingEffectTexAnim); + gSPDisplayList(POLY_XLU_DISP++, sSongOfHealingEffectFrustumDL); + + CLOSE_DISPS(play->state.gfxCtx); +} diff --git a/src/overlays/actors/ovl_Oceff_Wipe7/z_oceff_wipe7.h b/src/overlays/actors/ovl_Oceff_Wipe7/z_oceff_wipe7.h index df517e1fe..d5d82130c 100644 --- a/src/overlays/actors/ovl_Oceff_Wipe7/z_oceff_wipe7.h +++ b/src/overlays/actors/ovl_Oceff_Wipe7/z_oceff_wipe7.h @@ -7,7 +7,7 @@ struct OceffWipe7; typedef struct OceffWipe7 { /* 0x000 */ Actor actor; - /* 0x144 */ char unk_144[0x4]; + /* 0x144 */ s16 counter; } OceffWipe7; // size = 0x148 extern const ActorInit Oceff_Wipe7_InitVars; 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 38acb813e..093261344 100644 --- a/src/overlays/actors/ovl_Shot_Sun/z_shot_sun.c +++ b/src/overlays/actors/ovl_Shot_Sun/z_shot_sun.c @@ -1,25 +1,24 @@ /* * File: z_shot_sun.c * Overlay: ovl_Shot_Sun - * Description: + * Description: Leftover sun hitbox from OOT and fairy spawner */ #include "z_shot_sun.h" +#include "overlays/actors/ovl_Item_Etcetera/z_item_etcetera.h" +#include "overlays/actors/ovl_En_Elf/z_en_elf.h" #define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_8) #define THIS ((ShotSun*)thisx) -void ShotSun_Init(Actor* thisx, GlobalContext* globalCtx); -void ShotSun_Destroy(Actor* thisx, GlobalContext* globalCtx); -void ShotSun_Update(Actor* thisx, GlobalContext* globalCtx); +void ShotSun_Init(Actor* thisx, PlayState* play); +void ShotSun_Destroy(Actor* thisx, PlayState* play); +void ShotSun_Update(Actor* thisx, PlayState* play); -void func_80973740(ShotSun* this, GlobalContext* globalCtx); -void func_80973804(ShotSun* this, GlobalContext* globalCtx); -void func_809738D0(ShotSun* this, GlobalContext* globalCtx); -void func_80973960(ShotSun* this, GlobalContext* globalCtx); +void ShotSun_UpdateForOcarina(ShotSun* this, PlayState* play); +void ShotSun_UpdateHyliaSun(ShotSun* this, PlayState* play2); -#if 0 const ActorInit Shot_Sun_InitVars = { ACTOR_SHOT_SUN, ACTORCAT_PROP, @@ -32,27 +31,156 @@ const ActorInit Shot_Sun_InitVars = { (ActorFunc)NULL, }; -// static ColliderCylinderInit sCylinderInit = { -static ColliderCylinderInit D_80973BA0 = { - { COLTYPE_NONE, AT_NONE, AC_ON | AC_TYPE_PLAYER, OC1_ON | OC1_TYPE_ALL, OC2_TYPE_1, COLSHAPE_CYLINDER, }, - { ELEMTYPE_UNK0, { 0x00000000, 0x00, 0x00 }, { 0x00000020, 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 }, + { 0x00000020, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_ON, + }, { 30, 60, 0, { 0, 0, 0 } }, }; -#endif +void ShotSun_Init(Actor* thisx, PlayState* play) { + s32 pad; + ShotSun* this = THIS; -extern ColliderCylinderInit D_80973BA0; + if ((SHOTSUN_GET_FF(thisx) == SHOTSUN_FAIRY_SPAWNER_SUNS) || + (SHOTSUN_GET_FF(thisx) == SHOTSUN_FAIRY_SPAWNER_STORMS)) { + this->unk_19C = 0; + this->actor.flags |= ACTOR_FLAG_10; + this->actor.flags |= ACTOR_FLAG_2000000; + this->actionFunc = ShotSun_UpdateForOcarina; + this->actor.flags |= ACTOR_FLAG_8000000; + } else { + Collider_InitCylinder(play, &this->collider); + Collider_SetCylinder(play, &this->collider, &this->actor, &sCylinderInit); + this->actionFunc = ShotSun_UpdateHyliaSun; + this->actor.flags &= ~ACTOR_FLAG_1; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Shot_Sun/ShotSun_Init.s") +void ShotSun_Destroy(Actor* thisx, PlayState* play) { + ShotSun* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Shot_Sun/ShotSun_Destroy.s") + if ((SHOTSUN_GET_FF(thisx) != SHOTSUN_FAIRY_SPAWNER_SUNS) && + (SHOTSUN_GET_FF(thisx) != SHOTSUN_FAIRY_SPAWNER_STORMS)) { + Collider_DestroyCylinder(play, &this->collider); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Shot_Sun/func_80973740.s") +void ShotSun_SpawnFairy(ShotSun* this, PlayState* play2) { + s32 params = SHOTSUN_GET_FF(&this->actor); + s32 fairyType = 0; + PlayState* play = play2; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Shot_Sun/func_80973804.s") + if (this->timer > 0) { + this->timer--; + } else { + ActorCutscene_Stop(this->actor.cutscene); + switch (params) { + case SHOTSUN_FAIRY_SPAWNER_SUNS: + fairyType = ENELF_TYPE_7; + break; + case SHOTSUN_FAIRY_SPAWNER_STORMS: + fairyType = ENELF_TYPE_7; + break; + } + Actor_Spawn(&play->actorCtx, play, ACTOR_EN_ELF, this->actor.home.pos.x, this->actor.home.pos.y, + this->actor.home.pos.z, 0, 0, 0, fairyType); + Actor_MarkForDeath(&this->actor); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Shot_Sun/func_809738D0.s") +void ShotSun_TriggerFairy(ShotSun* this, PlayState* play) { + if ((this->actor.cutscene == -1) || ActorCutscene_GetCanPlayNext(this->actor.cutscene)) { + if (this->actor.cutscene != -1) { + ActorCutscene_Start(this->actor.cutscene, &this->actor); + } + this->actionFunc = ShotSun_SpawnFairy; + this->timer = 50; + Actor_Spawn(&play->actorCtx, play, ACTOR_DEMO_KANKYO, this->actor.home.pos.x, this->actor.home.pos.y, + this->actor.home.pos.z, 0, 0, 0, 0x11); + Audio_PlaySfxAtPos(&this->actor.projectedPos, NA_SE_EV_TRE_BOX_APPEAR); + } else { + ActorCutscene_SetIntentToPlay(this->actor.cutscene); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Shot_Sun/func_80973960.s") +void ShotSun_UpdateForOcarina(ShotSun* this, PlayState* play) { + s32 params = SHOTSUN_GET_FF(&this->actor); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Shot_Sun/ShotSun_Update.s") + if (play->msgCtx.ocarinaMode == 3) { + switch (play->msgCtx.lastPlayedSong) { + case OCARINA_SONG_STORMS: + if (params == SHOTSUN_FAIRY_SPAWNER_STORMS) { + this->actionFunc = ShotSun_TriggerFairy; + play->msgCtx.ocarinaMode = 4; + } + break; + case OCARINA_SONG_SUNS: + if (params == SHOTSUN_FAIRY_SPAWNER_SUNS) { + this->actionFunc = ShotSun_TriggerFairy; + play->msgCtx.ocarinaMode = 4; + } + break; + } + } +} + +void ShotSun_UpdateHyliaSun(ShotSun* this, PlayState* play) { + Vec3s cylinderPos; + Player* player = GET_PLAYER(play); + EnItem00* collectible; + s32 pad; + Vec3f spawnPos; + + if (this->collider.base.acFlags & AC_HIT) { + play_sound(NA_SE_SY_CORRECT_CHIME); + if (1) {} + if (INV_CONTENT(ITEM_ARROW_FIRE) == ITEM_NONE) { + Actor_Spawn(&play->actorCtx, play, ACTOR_ITEM_ETCETERA, 700.0f, -800.0f, 7261.0f, 0, 0, 0, + ITEM_ETC_ARROW_FIRE); + if (1) {} + gSaveContext.cutsceneTrigger = 1; + } else { + spawnPos.x = 700.0f; + spawnPos.y = -800.0f; + spawnPos.z = 7261.0f; + collectible = (EnItem00*)Item_DropCollectible(play, &spawnPos, ITEM00_MAGIC_LARGE); + if (collectible != NULL) { + collectible->unk152 = 0x1770; + collectible->actor.speedXZ = 0.0f; + } + } + + Actor_MarkForDeath(&this->actor); + } else if (!(this->actor.xzDistToPlayer > 120.0f)) { + if ((gSaveContext.save.time >= CLOCK_TIME(6, 30)) && (gSaveContext.save.time < CLOCK_TIME(7, 30))) { + cylinderPos.x = player->bodyPartsPos[7].x + (play->envCtx.unk_4 * (1.0f / 6.0f)); + cylinderPos.y = (player->bodyPartsPos[7].y - 30.0f) + (play->envCtx.unk_8 * (1.0f / 6.0f)); + cylinderPos.z = player->bodyPartsPos[7].z + (play->envCtx.unk_C * (1.0f / 6.0f)); + + this->hitboxPos = cylinderPos; + + Collider_SetCylinderPosition(&this->collider, &cylinderPos); + CollisionCheck_SetAC(play, &play->colChkCtx, &this->collider.base); + } + } +} + +void ShotSun_Update(Actor* thisx, PlayState* play) { + ShotSun* this = THIS; + + this->actionFunc(this, play); +} diff --git a/src/overlays/actors/ovl_Shot_Sun/z_shot_sun.h b/src/overlays/actors/ovl_Shot_Sun/z_shot_sun.h index 53434204f..49fd2ffb7 100644 --- a/src/overlays/actors/ovl_Shot_Sun/z_shot_sun.h +++ b/src/overlays/actors/ovl_Shot_Sun/z_shot_sun.h @@ -3,16 +3,22 @@ #include "global.h" +#define SHOTSUN_GET_FF(thisx) ((thisx)->params & 0xFF) +#define SHOTSUN_FAIRY_SPAWNER_SUNS 0x40 +#define SHOTSUN_FAIRY_SPAWNER_STORMS 0x41 + struct ShotSun; -typedef void (*ShotSunActionFunc)(struct ShotSun*, GlobalContext*); +typedef void (*ShotSunActionFunc)(struct ShotSun*, PlayState*); typedef struct ShotSun { - /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x4C]; - /* 0x0190 */ ShotSunActionFunc actionFunc; - /* 0x0194 */ char unk_194[0xC]; -} ShotSun; // size = 0x1A0 + /* 0x000 */ Actor actor; + /* 0x144 */ ColliderCylinder collider; + /* 0x190 */ ShotSunActionFunc actionFunc; + /* 0x194 */ Vec3s hitboxPos; + /* 0x19A */ s16 timer; + /* 0x19C */ s8 unk_19C; // leftover from OOT secret ocarina occurrence function. +} ShotSun; // size = 0x1A0 extern const ActorInit Shot_Sun_InitVars; diff --git a/src/overlays/actors/ovl_TG_Sw/z_tg_sw.c b/src/overlays/actors/ovl_TG_Sw/z_tg_sw.c index 51a2fa695..c79697e97 100644 --- a/src/overlays/actors/ovl_TG_Sw/z_tg_sw.c +++ b/src/overlays/actors/ovl_TG_Sw/z_tg_sw.c @@ -11,12 +11,12 @@ #define THIS ((TGSw*)thisx) // Prototypes -void TGSw_Init(Actor* thisx, GlobalContext* globalCtx); -void TGSw_Destroy(Actor* thisx, GlobalContext* globalCtx); -void TGSw_Update(Actor* thisx, GlobalContext* globalCtx); -void TGSw_Draw(Actor* thisx, GlobalContext* globalCtx); +void TGSw_Init(Actor* thisx, PlayState* play); +void TGSw_Destroy(Actor* thisx, PlayState* play); +void TGSw_Update(Actor* thisx, PlayState* play); +void TGSw_Draw(Actor* thisx, PlayState* play); -void TGSw_ActionExecuteOneShot(struct TGSw* this, GlobalContext* globalCtx); +void TGSw_ActionExecuteOneShot(struct TGSw* this, PlayState* play); const ActorInit TG_Sw_InitVars = { ACTOR_TG_SW, @@ -30,33 +30,33 @@ const ActorInit TG_Sw_InitVars = { (ActorFunc)TGSw_Draw, }; -void TGSw_ActionDecider(TGSw* this, GlobalContext* globalCtx) { +void TGSw_ActionDecider(TGSw* this, PlayState* play) { f32 scaledAbsoluteRotZ; f32 scaledAbsoluteRotY; u8 unk1F4; // Maybe actorCtx Debug Flag? - if (globalCtx->actorCtx.unk1F5 != 0) { + if (play->actorCtx.unk1F5 != 0) { scaledAbsoluteRotY = ABS_ALT(this->actor.world.rot.y) * 4.0f; scaledAbsoluteRotZ = ABS_ALT(this->actor.world.rot.z) * 4.0f; if ((scaledAbsoluteRotZ < this->actor.xzDistToPlayer) || (scaledAbsoluteRotY < this->actor.playerHeightRel)) { return; } - unk1F4 = globalCtx->actorCtx.unk1F4; + unk1F4 = play->actorCtx.unk1F4; if (unk1F4 == 2 || unk1F4 == 0) { - this->actionFunc = &TGSw_ActionExecuteOneShot; + this->actionFunc = TGSw_ActionExecuteOneShot; } } } -void TGSw_ActionExecuteOneShot(TGSw* this, GlobalContext* globalCtx) { +void TGSw_ActionExecuteOneShot(TGSw* this, PlayState* play) { Actor* actor = NULL; if (1) {} do { - actor = SubS_FindActor(globalCtx, actor, ACTORCAT_ENEMY, ACTOR_EN_SW); + actor = SubS_FindActor(play, actor, ACTORCAT_ENEMY, ACTOR_EN_SW); if (actor == NULL) { break; } @@ -71,7 +71,7 @@ void TGSw_ActionExecuteOneShot(TGSw* this, GlobalContext* globalCtx) { actor = NULL; do { - actor = SubS_FindActor(globalCtx, actor, ACTORCAT_NPC, ACTOR_EN_SW); + actor = SubS_FindActor(play, actor, ACTORCAT_NPC, ACTOR_EN_SW); if (actor == NULL) { break; @@ -87,22 +87,23 @@ void TGSw_ActionExecuteOneShot(TGSw* this, GlobalContext* globalCtx) { Actor_MarkForDeath(&this->actor); } -void TGSw_Init(Actor* thisx, GlobalContext* globalCtx) { +void TGSw_Init(Actor* thisx, PlayState* play) { TGSw* this = THIS; + this->actor.cutscene = this->actor.world.rot.z; - this->actionFunc = &TGSw_ActionDecider; + this->actionFunc = TGSw_ActionDecider; } -void TGSw_Destroy(Actor* thisx, GlobalContext* globalCtx) { - ; +void TGSw_Destroy(Actor* thisx, PlayState* play) { } -void TGSw_Update(Actor* thisx, GlobalContext* globalCtx) { +void TGSw_Update(Actor* thisx, PlayState* play) { TGSw* this = THIS; - this->actionFunc(this, globalCtx); + + this->actionFunc(this, play); } -void TGSw_Draw(Actor* thisx, GlobalContext* globalCtx) { +void TGSw_Draw(Actor* thisx, PlayState* play) { s32 pad; f32 scale; s32 absRot; @@ -113,11 +114,11 @@ void TGSw_Draw(Actor* thisx, GlobalContext* globalCtx) { absRot = ABS_ALT(thisx->world.rot.y); DebugDisplay_AddObject(thisx->world.pos.x, thisx->world.pos.y, thisx->world.pos.z, 0, thisx->shape.rot.y, 0, - 0.1f, 0.1f, scale, 160, 160, 160, 255, 6, globalCtx->state.gfxCtx); + 0.1f, 0.1f, scale, 160, 160, 160, 255, 6, play->state.gfxCtx); scale = absRot * 0.2f; DebugDisplay_AddObject(thisx->world.pos.x, thisx->world.pos.y, thisx->world.pos.z, 0, 0, 0, 0.1f, scale, 0.1f, - 160, 160, 160, 255, 6, globalCtx->state.gfxCtx); + 160, 160, 160, 255, 6, play->state.gfxCtx); thisx->shape.rot.y += 0x1000; } } diff --git a/src/overlays/actors/ovl_TG_Sw/z_tg_sw.h b/src/overlays/actors/ovl_TG_Sw/z_tg_sw.h index bec4c1f05..28bebb5d8 100644 --- a/src/overlays/actors/ovl_TG_Sw/z_tg_sw.h +++ b/src/overlays/actors/ovl_TG_Sw/z_tg_sw.h @@ -4,7 +4,7 @@ #include "global.h" struct TGSw; -typedef void (*TGSwActionFunc)(struct TGSw*, GlobalContext*); +typedef void (*TGSwActionFunc)(struct TGSw*, PlayState*); typedef struct TGSw { /* 0x000 */ Actor actor; diff --git a/src/overlays/actors/ovl_player_actor/z_player.c b/src/overlays/actors/ovl_player_actor/z_player.c index bc3e3c1e8..e8a872802 100644 --- a/src/overlays/actors/ovl_player_actor/z_player.c +++ b/src/overlays/actors/ovl_player_actor/z_player.c @@ -5,6 +5,7 @@ */ #include "global.h" +#include "z64rumble.h" #define THIS ((Player*)thisx) @@ -12,10 +13,10 @@ 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); +void Player_Init(Actor* thisx, PlayState* play); +void Player_Destroy(Actor* thisx, PlayState* play); +void Player_Update(Actor* thisx, PlayState* play); +void Player_Draw(Actor* thisx, PlayState* play); #pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8082DA90.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 29ac6b18b..09c2afb11 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 @@ -10,9 +10,9 @@ #define PARAMS ((EffectEnIceBlockInitParams*)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); +u32 EffectEnIceBlock_Init(PlayState* play, u32 index, EffectSs* this, void* initParamsx); +void EffectEnIceBlock_Update(PlayState* play, u32 index, EffectSs* this); +void EffectEnIceBlock_Draw(PlayState* play, u32 index, EffectSs* this); const EffectSsInit Effect_En_Ice_Block_InitVars = { EFFECT_EN_ICE_BLOCK, @@ -24,9 +24,9 @@ const EffectSsInit Effect_En_Ice_Block_InitVars = { #define rRot regs[2] #define rRotVel regs[3] -u32 EffectEnIceBlock_CheckIceBlockObject(EffectSs* this, GlobalContext* globalCtx) { - if (((this->rObjId = Object_GetIndex(&globalCtx->objectCtx, OBJECT_ICE_BLOCK)) < 0) || - (!Object_IsLoaded(&globalCtx->objectCtx, this->rObjId))) { +u32 EffectEnIceBlock_CheckIceBlockObject(EffectSs* this, PlayState* play) { + if (((this->rObjId = Object_GetIndex(&play->objectCtx, OBJECT_ICE_BLOCK)) < 0) || + (!Object_IsLoaded(&play->objectCtx, this->rObjId))) { this->life = -1; this->draw = NULL; return false; @@ -35,7 +35,7 @@ u32 EffectEnIceBlock_CheckIceBlockObject(EffectSs* this, GlobalContext* globalCt } } -u32 EffectEnIceBlock_Init(GlobalContext* globalCtx, u32 index, EffectSs* this, void* initParamsx) { +u32 EffectEnIceBlock_Init(PlayState* play, u32 index, EffectSs* this, void* initParamsx) { EffectEnIceBlockInitParams* params = PARAMS; Math_Vec3f_Copy(&this->pos, ¶ms->pos); @@ -48,28 +48,28 @@ u32 EffectEnIceBlock_Init(GlobalContext* globalCtx, u32 index, EffectSs* this, v this->draw = EffectEnIceBlock_Draw; this->update = EffectEnIceBlock_Update; - EffectEnIceBlock_CheckIceBlockObject(this, globalCtx); + EffectEnIceBlock_CheckIceBlockObject(this, play); return 1; } -void EffectEnIceBlock_Draw(GlobalContext* globalCtx, u32 index, EffectSs* this) { +void EffectEnIceBlock_Draw(PlayState* play, u32 index, EffectSs* this) { s32 pad; - GraphicsContext* gfxCtx = globalCtx->state.gfxCtx; + GraphicsContext* gfxCtx = play->state.gfxCtx; - if (EffectEnIceBlock_CheckIceBlockObject(this, globalCtx)) { + if (EffectEnIceBlock_CheckIceBlockObject(this, play)) { 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 + play->objectCtx.status[this->rObjId].segment); // object: OBJECT_ICE_BLOCK - func_8012C2DC(globalCtx->state.gfxCtx); - Matrix_InsertTranslation(this->pos.x, this->pos.y, this->pos.z, MTXMODE_NEW); + func_8012C2DC(play->state.gfxCtx); + Matrix_Translate(this->pos.x, this->pos.y, this->pos.z, MTXMODE_NEW); Matrix_Scale(scale, scale, scale, MTXMODE_APPLY); - Matrix_InsertMatrix(&globalCtx->billboardMtxF, MTXMODE_APPLY); - Matrix_InsertZRotation_s(this->rRot, MTXMODE_APPLY); + Matrix_Mult(&play->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); @@ -79,7 +79,7 @@ void EffectEnIceBlock_Draw(GlobalContext* globalCtx, u32 index, EffectSs* this) } } -void EffectEnIceBlock_Update(GlobalContext* globalCtx, u32 index, EffectSs* this) { +void EffectEnIceBlock_Update(PlayState* play, u32 index, EffectSs* this) { this->rRot += this->rRotVel; - EffectEnIceBlock_CheckIceBlockObject(this, globalCtx); + EffectEnIceBlock_CheckIceBlockObject(this, play); } diff --git a/src/overlays/effects/ovl_Effect_Ss_Blast/z_eff_ss_blast.c b/src/overlays/effects/ovl_Effect_Ss_Blast/z_eff_ss_blast.c index ec5433b3c..bb4cada88 100644 --- a/src/overlays/effects/ovl_Effect_Ss_Blast/z_eff_ss_blast.c +++ b/src/overlays/effects/ovl_Effect_Ss_Blast/z_eff_ss_blast.c @@ -8,9 +8,9 @@ #define PARAMS ((EffectSsBlastInitParams*)initParamsx) -s32 EffectSsBlast_Init(GlobalContext* globalCtx, u32 index, EffectSs* this, void* initParamsx); -void EffectSsBlast_Update(GlobalContext* globalCtx, u32 index, EffectSs* this); -void EffectSsBlast_Draw(GlobalContext* globalCtx, u32 index, EffectSs* this); +s32 EffectSsBlast_Init(PlayState* play, u32 index, EffectSs* this, void* initParamsx); +void EffectSsBlast_Update(PlayState* play, u32 index, EffectSs* this); +void EffectSsBlast_Draw(PlayState* play, u32 index, EffectSs* this); #if 0 const EffectSsInit Effect_Ss_Blast_InitVars = { diff --git a/src/overlays/effects/ovl_Effect_Ss_Bomb2/z_eff_ss_bomb2.c b/src/overlays/effects/ovl_Effect_Ss_Bomb2/z_eff_ss_bomb2.c index 3d571f3f7..7903deffa 100644 --- a/src/overlays/effects/ovl_Effect_Ss_Bomb2/z_eff_ss_bomb2.c +++ b/src/overlays/effects/ovl_Effect_Ss_Bomb2/z_eff_ss_bomb2.c @@ -8,10 +8,10 @@ #define PARAMS ((EffectSsBomb2InitParams*)initParamsx) -s32 EffectSsBomb2_Init(GlobalContext* globalCtx, u32 index, EffectSs* this, void* initParamsx); -void EffectSsBomb2_Update(GlobalContext* globalCtx, u32 index, EffectSs* this); -void func_80978138(GlobalContext* globalCtx, u32 index, EffectSs* this); -void func_80978304(GlobalContext* globalCtx, u32 index, EffectSs* this); +s32 EffectSsBomb2_Init(PlayState* play, u32 index, EffectSs* this, void* initParamsx); +void EffectSsBomb2_Update(PlayState* play, u32 index, EffectSs* this); +void func_80978138(PlayState* play, u32 index, EffectSs* this); +void func_80978304(PlayState* play, u32 index, EffectSs* this); #if 0 const EffectSsInit Effect_Ss_Bomb2_InitVars = { 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 41a8f92ff..011d8a101 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 @@ -13,9 +13,9 @@ #define PARAMS ((EffectSsBubbleInitParams*)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); +u32 EffectSsBubble_Init(PlayState* play, u32 index, EffectSs* this, void* initParamsx); +void EffectSsBubble_Update(PlayState* play, u32 index, EffectSs* this); +void EffectSsBubble_Draw(PlayState* play, u32 index, EffectSs* this); const EffectSsInit Effect_Ss_Bubble_InitVars = { EFFECT_SS_BUBBLE, @@ -24,7 +24,7 @@ const EffectSsInit Effect_Ss_Bubble_InitVars = { static f32 sVecAdjMaximums[] = { 291.0f, 582.0f, 1600.0f }; -u32 EffectSsBubble_Init(GlobalContext* globalCtx, u32 index, EffectSs* this, void* initParamsx) { +u32 EffectSsBubble_Init(PlayState* play, u32 index, EffectSs* this, void* initParamsx) { EffectSsBubbleInitParams* initParams = (EffectSsBubbleInitParams*)initParamsx; { @@ -45,13 +45,13 @@ u32 EffectSsBubble_Init(GlobalContext* globalCtx, u32 index, EffectSs* this, voi return 1; } -void EffectSsBubble_Draw(GlobalContext* globalCtx, u32 index, EffectSs* this) { - GraphicsContext* gfxCtx = globalCtx->state.gfxCtx; +void EffectSsBubble_Draw(PlayState* play, u32 index, EffectSs* this) { + GraphicsContext* gfxCtx = play->state.gfxCtx; f32 scale = this->rScale / 100.0f; OPEN_DISPS(gfxCtx); - Matrix_InsertTranslation(this->pos.x, this->pos.y, this->pos.z, MTXMODE_NEW); + Matrix_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); @@ -64,13 +64,13 @@ void EffectSsBubble_Draw(GlobalContext* globalCtx, u32 index, EffectSs* this) { CLOSE_DISPS(gfxCtx); } -void EffectSsBubble_Update(GlobalContext* globalCtx2, u32 index, EffectSs* this) { +void EffectSsBubble_Update(PlayState* play2, u32 index, EffectSs* this) { WaterBox* waterBox; f32 waterSurfaceY = this->pos.y; Vec3f ripplePos; - GlobalContext* globalCtx = globalCtx2; + PlayState* play = play2; - if (!WaterBox_GetSurface1(globalCtx, &globalCtx->colCtx, this->pos.x, this->pos.z, &waterSurfaceY, &waterBox)) { + if (!WaterBox_GetSurface1(play, &play->colCtx, this->pos.x, this->pos.z, &waterSurfaceY, &waterBox)) { this->life = -1; return; } @@ -78,21 +78,21 @@ void EffectSsBubble_Update(GlobalContext* globalCtx2, u32 index, EffectSs* this) ripplePos.x = this->pos.x; ripplePos.y = waterSurfaceY; ripplePos.z = this->pos.z; - EffectSsGRipple_Spawn(globalCtx, &ripplePos, 0, 80, 0); + EffectSsGRipple_Spawn(play, &ripplePos, 0, 80, 0); this->life = -1; label: return; } - if (((globalCtx->gameplayFrames + index) % 8) == 0) { + if (((play->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; + BgCheck_EntityRaycastFloor2_1(play, &play->colCtx, &colPoly, &this->pos); + speed = SurfaceType_GetConveyorSpeed(&play->colCtx, colPoly, BGCHECK_SCENE); + if ((speed != 0) && !SurfaceType_GetConveyorType(&play->colCtx, colPoly, BGCHECK_SCENE)) { + direction = SurfaceType_GetConveyorDirection(&play->colCtx, colPoly, BGCHECK_SCENE) << 0xA; rVecAdjMax = sVecAdjMaximums[speed - 1]; this->rVecAdjX = Math_SinS(direction) * rVecAdjMax; this->rVecAdjZ = Math_CosS(direction) * rVecAdjMax; diff --git a/src/overlays/effects/ovl_Effect_Ss_D_Fire/z_eff_ss_d_fire.c b/src/overlays/effects/ovl_Effect_Ss_D_Fire/z_eff_ss_d_fire.c index cc3531434..ff8c54053 100644 --- a/src/overlays/effects/ovl_Effect_Ss_D_Fire/z_eff_ss_d_fire.c +++ b/src/overlays/effects/ovl_Effect_Ss_D_Fire/z_eff_ss_d_fire.c @@ -8,9 +8,9 @@ #define PARAMS ((EffectSsDFireInitParams*)initParamsx) -s32 EffectSsDFire_Init(GlobalContext* globalCtx, u32 index, EffectSs* this, void* initParamsx); -void EffectSsDFire_Update(GlobalContext* globalCtx, u32 index, EffectSs* this); -void EffectSsDFire_Draw(GlobalContext* globalCtx, u32 index, EffectSs* this); +s32 EffectSsDFire_Init(PlayState* play, u32 index, EffectSs* this, void* initParamsx); +void EffectSsDFire_Update(PlayState* play, u32 index, EffectSs* this); +void EffectSsDFire_Draw(PlayState* play, u32 index, EffectSs* this); #if 0 const EffectSsInit Effect_Ss_D_Fire_InitVars = { diff --git a/src/overlays/effects/ovl_Effect_Ss_Dead_Db/z_eff_ss_dead_db.c b/src/overlays/effects/ovl_Effect_Ss_Dead_Db/z_eff_ss_dead_db.c index 0ed0cf5f8..616d30d03 100644 --- a/src/overlays/effects/ovl_Effect_Ss_Dead_Db/z_eff_ss_dead_db.c +++ b/src/overlays/effects/ovl_Effect_Ss_Dead_Db/z_eff_ss_dead_db.c @@ -8,9 +8,9 @@ #define PARAMS ((EffectSsDeadDbInitParams*)initParamsx) -s32 EffectSsDeadDb_Init(GlobalContext* globalCtx, u32 index, EffectSs* this, void* initParamsx); -void EffectSsDeadDb_Update(GlobalContext* globalCtx, u32 index, EffectSs* this); -void EffectSsDeadDb_Draw(GlobalContext* globalCtx, u32 index, EffectSs* this); +s32 EffectSsDeadDb_Init(PlayState* play, u32 index, EffectSs* this, void* initParamsx); +void EffectSsDeadDb_Update(PlayState* play, u32 index, EffectSs* this); +void EffectSsDeadDb_Draw(PlayState* play, u32 index, EffectSs* this); #if 0 const EffectSsInit Effect_Ss_Dead_Db_InitVars = { diff --git a/src/overlays/effects/ovl_Effect_Ss_Dead_Dd/z_eff_ss_dead_dd.c b/src/overlays/effects/ovl_Effect_Ss_Dead_Dd/z_eff_ss_dead_dd.c index 0d26eec89..6dfbce5a1 100644 --- a/src/overlays/effects/ovl_Effect_Ss_Dead_Dd/z_eff_ss_dead_dd.c +++ b/src/overlays/effects/ovl_Effect_Ss_Dead_Dd/z_eff_ss_dead_dd.c @@ -5,23 +5,141 @@ */ #include "z_eff_ss_dead_dd.h" +#include "objects/gameplay_keep/gameplay_keep.h" + +#define rScale regs[0] +#define rPrimColorR regs[2] +#define rPrimColorG regs[3] +#define rPrimColorB regs[4] +#define rAlpha regs[5] +#define rEnvColorR regs[6] +#define rEnvColorG regs[7] +#define rEnvColorB regs[8] +#define rScaleStep regs[9] +#define rAlphaStep regs[10] +#define rAlphaMode regs[11] #define PARAMS ((EffectSsDeadDdInitParams*)initParamsx) -s32 EffectSsDeadDd_Init(GlobalContext* globalCtx, u32 index, EffectSs* this, void* initParamsx); -void EffectSsDeadDd_Update(GlobalContext* globalCtx, u32 index, EffectSs* this); -void EffectSsDeadDd_Draw(GlobalContext* globalCtx, u32 index, EffectSs* this); +u32 EffectSsDeadDd_Init(PlayState* play, u32 index, EffectSs* this, void* initParamsx); +void EffectSsDeadDd_Update(PlayState* play, u32 index, EffectSs* this); +void EffectSsDeadDd_Draw(PlayState* play, u32 index, EffectSs* this); -#if 0 const EffectSsInit Effect_Ss_Dead_Dd_InitVars = { EFFECT_SS_DEAD_DD, EffectSsDeadDd_Init, }; -#endif +u32 EffectSsDeadDd_Init(PlayState* play, u32 index, EffectSs* this, void* initParamsx) { + EffectSsDeadDdInitParams* initParams = PARAMS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Effect_Ss_Dead_Dd/EffectSsDeadDd_Init.s") + if (initParams->type == DEADDD_TYPE_0) { + this->pos = initParams->pos; + this->velocity = initParams->velocity; + this->accel = initParams->accel; + this->life = initParams->life; + this->rScaleStep = initParams->scaleStep; + this->rAlphaMode = initParams->alphaStep; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Effect_Ss_Dead_Dd/EffectSsDeadDd_Draw.s") + if (initParams->alphaStep != 0) { + this->rAlphaStep = initParams->alphaStep; + } else { + this->rAlphaStep = initParams->primColor.a / initParams->life; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Effect_Ss_Dead_Dd/EffectSsDeadDd_Update.s") + this->draw = EffectSsDeadDd_Draw; + this->update = EffectSsDeadDd_Update; + this->rScale = initParams->scale; + this->rPrimColorR = initParams->primColor.r; + this->rPrimColorG = initParams->primColor.g; + this->rPrimColorB = initParams->primColor.b; + this->rAlpha = initParams->primColor.a; + this->rEnvColorR = initParams->envColor.r; + this->rEnvColorG = initParams->envColor.g; + this->rEnvColorB = initParams->envColor.b; + + } else if (initParams->type == DEADDD_TYPE_1) { + s32 i; + + this->life = initParams->life; + this->rScaleStep = initParams->scaleStep; + this->rAlphaMode = 0; + this->rAlphaStep = 155 / initParams->life; + this->rScale = initParams->scale; + this->rPrimColorR = 255; + this->rPrimColorG = 255; + this->rPrimColorB = 155; + this->rAlpha = 155; + this->rEnvColorR = 250; + this->rEnvColorG = 180; + this->rEnvColorB = 0; + this->draw = EffectSsDeadDd_Draw; + this->update = EffectSsDeadDd_Update; + + for (i = initParams->randIter; i > 0; i--) { + this->pos.x = ((Rand_ZeroOne() - 0.5f) * initParams->randPosScale) + initParams->pos.x; + this->pos.y = ((Rand_ZeroOne() - 0.5f) * initParams->randPosScale) + initParams->pos.y; + this->pos.z = ((Rand_ZeroOne() - 0.5f) * initParams->randPosScale) + initParams->pos.z; + this->accel.x = this->velocity.x = (Rand_ZeroOne() - 0.5f) * 2.0f; + this->accel.y = this->velocity.y = (Rand_ZeroOne() - 0.5f) * 2.0f; + this->accel.z = this->velocity.z = (Rand_ZeroOne() - 0.5f) * 2.0f; + } + } else { + return 0; + } + + return 1; +} + +void EffectSsDeadDd_Draw(PlayState* play, u32 index, EffectSs* this) { + GraphicsContext* gfxCtx = play->state.gfxCtx; + MtxF mfTrans; + MtxF mfScale; + MtxF mfResult; + Mtx* mtx; + f32 scale; + + OPEN_DISPS(gfxCtx); + + scale = this->rScale * 0.01f; + SkinMatrix_SetTranslate(&mfTrans, this->pos.x, this->pos.y, this->pos.z); + SkinMatrix_SetScale(&mfScale, scale, scale, scale); + SkinMatrix_MtxFMtxFMult(&mfTrans, &mfScale, &mfResult); + + mtx = SkinMatrix_MtxFToNewMtx(gfxCtx, &mfResult); + + if (mtx != NULL) { + func_8012C974(gfxCtx); + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, this->rPrimColorR, this->rPrimColorG, this->rPrimColorB, this->rAlpha); + gDPSetEnvColor(POLY_XLU_DISP++, this->rEnvColorR, this->rEnvColorG, this->rEnvColorB, this->rAlpha); + gSPMatrix(POLY_XLU_DISP++, mtx, G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPMatrix(POLY_XLU_DISP++, &D_01000000, G_MTX_NOPUSH | G_MTX_MUL | G_MTX_MODELVIEW); + gDPSetCombineLERP(POLY_XLU_DISP++, 0, 0, 0, PRIMITIVE, TEXEL0, 0, PRIMITIVE, 0, 0, 0, 0, PRIMITIVE, TEXEL0, 0, + PRIMITIVE, 0); + gSPDisplayList(POLY_XLU_DISP++, gameplay_keep_DL_054940); + } + + CLOSE_DISPS(gfxCtx); +} + +void EffectSsDeadDd_Update(PlayState* play, u32 index, EffectSs* this) { + + this->rScale += this->rScaleStep; + + if (this->rScale < 0) { + this->rScale = 0; + } + + if (this->rAlphaMode != 0) { + this->rAlpha += this->rAlphaStep; + if (this->rAlpha > 255) { + this->rAlpha = 255; + } + } else { + if (this->rAlpha < this->rAlphaStep) { + this->rAlpha = 0; + } else { + this->rAlpha -= this->rAlphaStep; + } + } +} diff --git a/src/overlays/effects/ovl_Effect_Ss_Dead_Dd/z_eff_ss_dead_dd.h b/src/overlays/effects/ovl_Effect_Ss_Dead_Dd/z_eff_ss_dead_dd.h index e344df407..9c9dcf28e 100644 --- a/src/overlays/effects/ovl_Effect_Ss_Dead_Dd/z_eff_ss_dead_dd.h +++ b/src/overlays/effects/ovl_Effect_Ss_Dead_Dd/z_eff_ss_dead_dd.h @@ -3,6 +3,11 @@ #include "global.h" +typedef enum { + /* 0 */ DEADDD_TYPE_0, + /* 1 */ DEADDD_TYPE_1 // Unused +} DeadDDType; + typedef struct { /* 0x00 */ Vec3f pos; /* 0x0C */ Vec3f velocity; diff --git a/src/overlays/effects/ovl_Effect_Ss_Dead_Ds/z_eff_ss_dead_ds.c b/src/overlays/effects/ovl_Effect_Ss_Dead_Ds/z_eff_ss_dead_ds.c index 34bb24d28..e5079f55d 100644 --- a/src/overlays/effects/ovl_Effect_Ss_Dead_Ds/z_eff_ss_dead_ds.c +++ b/src/overlays/effects/ovl_Effect_Ss_Dead_Ds/z_eff_ss_dead_ds.c @@ -8,9 +8,9 @@ #define PARAMS ((EffectSsDeadDsInitParams*)initParamsx) -s32 EffectSsDeadDs_Init(GlobalContext* globalCtx, u32 index, EffectSs* this, void* initParamsx); -void EffectSsDeadDs_Update(GlobalContext* globalCtx, u32 index, EffectSs* this); -void EffectSsDeadDs_Draw(GlobalContext* globalCtx, u32 index, EffectSs* this); +s32 EffectSsDeadDs_Init(PlayState* play, u32 index, EffectSs* this, void* initParamsx); +void EffectSsDeadDs_Update(PlayState* play, u32 index, EffectSs* this); +void EffectSsDeadDs_Draw(PlayState* play, u32 index, EffectSs* this); #if 0 const EffectSsInit Effect_Ss_Dead_Ds_InitVars = { diff --git a/src/overlays/effects/ovl_Effect_Ss_Dt_Bubble/z_eff_ss_dt_bubble.c b/src/overlays/effects/ovl_Effect_Ss_Dt_Bubble/z_eff_ss_dt_bubble.c index 0237cfb1e..a4aed4732 100644 --- a/src/overlays/effects/ovl_Effect_Ss_Dt_Bubble/z_eff_ss_dt_bubble.c +++ b/src/overlays/effects/ovl_Effect_Ss_Dt_Bubble/z_eff_ss_dt_bubble.c @@ -8,9 +8,9 @@ #define PARAMS ((EffectSsDtBubbleInitParams*)initParamsx) -s32 EffectSsDtBubble_Init(GlobalContext* globalCtx, u32 index, EffectSs* this, void* initParamsx); -void EffectSsDtBubble_Update(GlobalContext* globalCtx, u32 index, EffectSs* this); -void EffectSsDtBubble_Draw(GlobalContext* globalCtx, u32 index, EffectSs* this); +s32 EffectSsDtBubble_Init(PlayState* play, u32 index, EffectSs* this, void* initParamsx); +void EffectSsDtBubble_Update(PlayState* play, u32 index, EffectSs* this); +void EffectSsDtBubble_Draw(PlayState* play, u32 index, EffectSs* this); #if 0 const EffectSsInit Effect_Ss_Dt_Bubble_InitVars = { diff --git a/src/overlays/effects/ovl_Effect_Ss_Dust/z_eff_ss_dust.c b/src/overlays/effects/ovl_Effect_Ss_Dust/z_eff_ss_dust.c index 4d53619ff..c3a72bb7f 100644 --- a/src/overlays/effects/ovl_Effect_Ss_Dust/z_eff_ss_dust.c +++ b/src/overlays/effects/ovl_Effect_Ss_Dust/z_eff_ss_dust.c @@ -8,10 +8,10 @@ #define PARAMS ((EffectSsDustInitParams*)initParamsx) -s32 EffectSsDust_Init(GlobalContext* globalCtx, u32 index, EffectSs* this, void* initParamsx); -void func_809776BC(GlobalContext* globalCtx, u32 index, EffectSs* this); -void func_809777B4(GlobalContext* globalCtx, u32 index, EffectSs* this); -void EffectSsDust_Draw(GlobalContext* globalCtx, u32 index, EffectSs* this); +s32 EffectSsDust_Init(PlayState* play, u32 index, EffectSs* this, void* initParamsx); +void func_809776BC(PlayState* play, u32 index, EffectSs* this); +void func_809777B4(PlayState* play, u32 index, EffectSs* this); +void EffectSsDust_Draw(PlayState* play, u32 index, EffectSs* this); #if 0 const EffectSsInit Effect_Ss_Dust_InitVars = { diff --git a/src/overlays/effects/ovl_Effect_Ss_En_Fire/z_eff_ss_en_fire.c b/src/overlays/effects/ovl_Effect_Ss_En_Fire/z_eff_ss_en_fire.c index 2953789c9..fab6f8788 100644 --- a/src/overlays/effects/ovl_Effect_Ss_En_Fire/z_eff_ss_en_fire.c +++ b/src/overlays/effects/ovl_Effect_Ss_En_Fire/z_eff_ss_en_fire.c @@ -5,23 +5,144 @@ */ #include "z_eff_ss_en_fire.h" +#include "objects/gameplay_keep/gameplay_keep.h" + +#define rScaleMax regs[0] +#define rScale regs[1] +#define rLifespan regs[2] +#define rUnused regs[3] +#define rPitch regs[4] +#define rYaw regs[5] +#define rReg6 regs[6] +#define rBodyPart regs[7] +#define rFlags regs[8] +#define rScroll regs[9] #define PARAMS ((EffectSsEnFireInitParams*)initParamsx) -s32 EffectSsEnFire_Init(GlobalContext* globalCtx, u32 index, EffectSs* this, void* initParamsx); -void EffectSsEnFire_Update(GlobalContext* globalCtx, u32 index, EffectSs* this); -void EffectSsEnFire_Draw(GlobalContext* globalCtx, u32 index, EffectSs* this); +u32 EffectSsEnFire_Init(PlayState* play, u32 index, EffectSs* this, void* initParamsx); +void EffectSsEnFire_Update(PlayState* play, u32 index, EffectSs* this); +void EffectSsEnFire_Draw(PlayState* play, u32 index, EffectSs* this); -#if 0 const EffectSsInit Effect_Ss_En_Fire_InitVars = { EFFECT_SS_EN_FIRE, EffectSsEnFire_Init, }; -#endif +u32 EffectSsEnFire_Init(PlayState* play, u32 index, EffectSs* this, void* initParamsx) { + EffectSsEnFireInitParams* initParams = PARAMS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Effect_Ss_En_Fire/EffectSsEnFire_Init.s") + Math_Vec3f_Copy(&this->pos, &initParams->pos); + Math_Vec3f_Copy(&this->velocity, &gZeroVec3f); + Math_Vec3f_Copy(&this->accel, &gZeroVec3f); + this->life = 20; + this->rLifespan = this->life; + this->actor = initParams->actor; + this->rScroll = Rand_ZeroOne() * 20.0f; + this->draw = EffectSsEnFire_Draw; + this->update = EffectSsEnFire_Update; + this->rUnused = -15; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Effect_Ss_En_Fire/EffectSsEnFire_Draw.s") + if (initParams->bodyPart < 0) { + this->rYaw = Math_Vec3f_Yaw(&initParams->actor->world.pos, &initParams->pos) - initParams->actor->shape.rot.y; + this->rPitch = + Math_Vec3f_Pitch(&initParams->actor->world.pos, &initParams->pos) - initParams->actor->shape.rot.x; + this->vec.z = Math_Vec3f_DistXYZ(&initParams->pos, &initParams->actor->world.pos); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Effect_Ss_En_Fire/EffectSsEnFire_Update.s") + this->rScaleMax = initParams->scale; + + if (initParams->params & ENFIRE_PARAMS_USE_SCALE) { + this->rScale = initParams->scale; + } else { + this->rScale = 0; + } + + this->rReg6 = initParams->params & 0x7FFF; + this->rBodyPart = initParams->bodyPart; + this->rFlags = initParams->flags; + + return 1; +} + +void EffectSsEnFire_Draw(PlayState* play, u32 index, EffectSs* this) { + GraphicsContext* gfxCtx = play->state.gfxCtx; + f32 scale; + s16 camYaw; + s32 pad[3]; + s16 redGreen; + + OPEN_DISPS(gfxCtx); + + Matrix_Translate(this->pos.x, this->pos.y, this->pos.z, MTXMODE_NEW); + camYaw = (Camera_GetCamDirYaw(GET_ACTIVE_CAM(play)) + 0x8000); + Matrix_RotateYS(camYaw, MTXMODE_APPLY); + + scale = Math_SinS(this->life * 0x333) * (this->rScale * 0.00005f); + Matrix_Scale(scale, scale, scale, MTXMODE_APPLY); + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + + redGreen = this->life - 5; + + if (redGreen < 0) { + redGreen = 0; + } + + func_8012C2DC(play->state.gfxCtx); + gDPSetEnvColor(POLY_XLU_DISP++, redGreen * 12.7f, 0, 0, 0); + gDPSetPrimColor(POLY_XLU_DISP++, 0x0, 0x80, redGreen * 12.7f, redGreen * 12.7f, 0, 255); + gSPSegment( + POLY_XLU_DISP++, 0x08, + Gfx_TwoTexScroll(play->state.gfxCtx, 0, 0, 0, 0x20, 0x40, 1, 0, (this->rScroll * -20) & 0x1FF, 0x20, 0x80)); + + if ((this->rFlags & 0x7FFF) || (this->life < 18)) { + gSPDisplayList(POLY_XLU_DISP++, gEffFire2DL); + } else { + gSPDisplayList(POLY_XLU_DISP++, gEffFire1DL); + } + + CLOSE_DISPS(gfxCtx); +} + +typedef struct { + /* 0x000 */ Actor actor; + /* 0x14C */ Vec3f firePos[10]; +} FireActorF; // size = 0x1BC + +typedef struct { + /* 0x000 */ Actor actor; + /* 0x14C */ Vec3s firePos[10]; +} FireActorS; // size = 0x180 + +void EffectSsEnFire_Update(PlayState* play, u32 index, EffectSs* this) { + this->rScroll++; + + if (this->actor != NULL) { + if (this->actor->colorFilterTimer >= 22) { + this->life++; + } + if (this->actor->update != NULL) { + Math_SmoothStepToS(&this->rScale, this->rScaleMax, 1, this->rScaleMax >> 3, 0); + + if (this->rBodyPart < 0) { + Matrix_Translate(this->actor->world.pos.x, this->actor->world.pos.y, this->actor->world.pos.z, + MTXMODE_NEW); + Matrix_RotateYS(this->rYaw + this->actor->shape.rot.y, MTXMODE_APPLY); + Matrix_RotateXS(this->rPitch + this->actor->shape.rot.x, MTXMODE_APPLY); + Matrix_MultVec3f(&this->vec, &this->pos); + } else if (this->rFlags & ENFIRE_FLAGS_BODYPART_POS_VEC3S) { + this->pos.x = ((FireActorS*)this->actor)->firePos[this->rBodyPart].x; + this->pos.y = ((FireActorS*)this->actor)->firePos[this->rBodyPart].y; + this->pos.z = ((FireActorS*)this->actor)->firePos[this->rBodyPart].z; + } else { + this->pos.x = ((FireActorF*)this->actor)->firePos[this->rBodyPart].x; + this->pos.y = ((FireActorF*)this->actor)->firePos[this->rBodyPart].y; + this->pos.z = ((FireActorF*)this->actor)->firePos[this->rBodyPart].z; + } + } else if (this->rReg6 != 0) { + this->life = 0; + } else { + this->actor = NULL; + } + } +} diff --git a/src/overlays/effects/ovl_Effect_Ss_En_Fire/z_eff_ss_en_fire.h b/src/overlays/effects/ovl_Effect_Ss_En_Fire/z_eff_ss_en_fire.h index 987e426da..9fb959824 100644 --- a/src/overlays/effects/ovl_Effect_Ss_En_Fire/z_eff_ss_en_fire.h +++ b/src/overlays/effects/ovl_Effect_Ss_En_Fire/z_eff_ss_en_fire.h @@ -3,11 +3,14 @@ #include "global.h" +#define ENFIRE_FLAGS_BODYPART_POS_VEC3S (1 << 15) +#define ENFIRE_PARAMS_USE_SCALE (1 << 15) + typedef struct { /* 0x00 */ Actor* actor; /* 0x04 */ Vec3f pos; /* 0x10 */ s16 scale; - /* 0x12 */ s16 unk_12; + /* 0x12 */ s16 params; /* 0x14 */ s16 flags; /* 0x16 */ s16 bodyPart; } EffectSsEnFireInitParams; // size = 0x18 diff --git a/src/overlays/effects/ovl_Effect_Ss_En_Ice/z_eff_ss_en_ice.c b/src/overlays/effects/ovl_Effect_Ss_En_Ice/z_eff_ss_en_ice.c index 963c38bb9..7d6cf277c 100644 --- a/src/overlays/effects/ovl_Effect_Ss_En_Ice/z_eff_ss_en_ice.c +++ b/src/overlays/effects/ovl_Effect_Ss_En_Ice/z_eff_ss_en_ice.c @@ -1,30 +1,157 @@ /* * File: z_eff_ss_en_ice.c * Overlay: ovl_Effect_Ss_En_Ice - * Description: + * Description: Ice clumps */ #include "z_eff_ss_en_ice.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 rPrimColorR regs[4] +#define rPrimColorG regs[5] +#define rPrimColorB regs[6] +#define rPrimColorA regs[7] +#define rEnvColorR regs[8] +#define rEnvColorG regs[9] +#define rEnvColorB regs[10] +#define rAlphaMode regs[11] +#define rScale regs[12] #define PARAMS ((EffectSsEnIceInitParams*)initParamsx) -s32 EffectSsEnIce_Init(GlobalContext* globalCtx, u32 index, EffectSs* this, void* initParamsx); -void func_8097F62C(GlobalContext* globalCtx, u32 index, EffectSs* this); -void func_8097F7EC(GlobalContext* globalCtx, u32 index, EffectSs* this); -void EffectSsEnIce_Draw(GlobalContext* globalCtx, u32 index, EffectSs* this); +u32 EffectSsEnIce_Init(PlayState* play, u32 index, EffectSs* this, void* initParamsx); +void EffectSsEnIce_UpdateFlying(PlayState* play, u32 index, EffectSs* this); +void EffectSsEnIce_Update(PlayState* play, u32 index, EffectSs* this); +void EffectSsEnIce_Draw(PlayState* play, u32 index, EffectSs* this); -#if 0 const EffectSsInit Effect_Ss_En_Ice_InitVars = { EFFECT_SS_EN_ICE, EffectSsEnIce_Init, }; -#endif +u32 EffectSsEnIce_Init(PlayState* play, u32 index, EffectSs* this, void* initParamsx) { + EffectSsEnIceInitParams* initParams = PARAMS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Effect_Ss_En_Ice/EffectSsEnIce_Init.s") + if (initParams->type == ENICE_TYPE_FLYING) { + Math_Vec3f_Copy(&this->pos, &initParams->pos); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Effect_Ss_En_Ice/EffectSsEnIce_Draw.s") + if (initParams->actor != NULL) { + Math_Vec3f_Diff(&this->pos, &initParams->actor->world.pos, &this->vec); + } else { + Math_Vec3f_Copy(&this->vec, &initParams->pos); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Effect_Ss_En_Ice/func_8097F62C.s") + Math_Vec3f_Copy(&this->velocity, &gZeroVec3f); + Math_Vec3f_Copy(&this->accel, &gZeroVec3f); + this->life = 10; + this->actor = initParams->actor; + this->draw = EffectSsEnIce_Draw; + this->update = EffectSsEnIce_UpdateFlying; + this->rScale = initParams->scale * 100.0f; + 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->rAlphaMode = 1; + this->rPitch = randPlusMinusPoint5Scaled(0x10000); + } else if (initParams->type == ENICE_TYPE_NORMAL) { + Math_Vec3f_Copy(&this->pos, &initParams->pos); + Math_Vec3f_Copy(&this->vec, &initParams->pos); + Math_Vec3f_Copy(&this->velocity, &initParams->velocity); + Math_Vec3f_Copy(&this->accel, &initParams->accel); + this->life = initParams->life; + this->draw = EffectSsEnIce_Draw; + this->update = EffectSsEnIce_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->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->rAlphaMode = 0; + } else { + return 0; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Effect_Ss_En_Ice/func_8097F7EC.s") + return 1; +} + +void EffectSsEnIce_Draw(PlayState* play, u32 index, EffectSs* this) { + GraphicsContext* gfxCtx = play->state.gfxCtx; + s32 pad; + f32 scale = this->rScale * 0.01f; + u32 gameplayFrames = play->gameplayFrames; + f32 alpha; + + OPEN_DISPS(gfxCtx); + + if (this->rAlphaMode != 0) { + alpha = this->life * 12.0f; + } else 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(play->state.gfxCtx); + func_800BCC68(&this->pos, play); + gSPSegment(POLY_XLU_DISP++, 0x08, + Gfx_TwoTexScroll(play->state.gfxCtx, 0, 0, gameplayFrames & 0xFF, 0x20, 0x10, 1, 0, + (gameplayFrames * 2) & 0xFF, 0x40, 0x20)); + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0x80, this->rPrimColorR, this->rPrimColorG, this->rPrimColorB, + this->rPrimColorA); + gDPSetEnvColor(POLY_XLU_DISP++, this->rEnvColorR, this->rEnvColorG, this->rEnvColorB, (u32)alpha); + gSPDisplayList(POLY_XLU_DISP++, gEffIceFragment2MaterialDL); + gSPDisplayList(POLY_XLU_DISP++, gEffIceFragment2ModelDL); + + CLOSE_DISPS(gfxCtx); +} + +void EffectSsEnIce_UpdateFlying(PlayState* play, u32 index, EffectSs* this) { + s16 rand; + + if ((this->actor != NULL) && (this->actor->update != NULL)) { + if ((this->life >= 9) && (this->actor->colorFilterTimer != 0) && (!(this->actor->colorFilterParams & 0xC000))) { + Math_Vec3f_Sum(&this->actor->world.pos, &this->vec, &this->pos); + this->life++; + } else if (this->life == 9) { + this->accel.x = Math_SinS(Math_Vec3f_Yaw(&this->actor->world.pos, &this->pos)) * (Rand_ZeroOne() + 1.0f); + this->accel.z = Math_CosS(Math_Vec3f_Yaw(&this->actor->world.pos, &this->pos)) * (Rand_ZeroOne() + 1.0f); + this->accel.y = -1.5f; + this->velocity.y = 5.0f; + } + } else { + this->actor = NULL; + if (this->life >= 9) { + rand = randPlusMinusPoint5Scaled(0xFFFF); + this->accel.x = Math_SinS(rand) * (Rand_ZeroOne() + 1.0f); + this->accel.z = Math_CosS(rand) * (Rand_ZeroOne() + 1.0f); + this->life = 8; + this->accel.y = -1.5f; + this->velocity.y = 5.0f; + } + } +} + +void EffectSsEnIce_Update(PlayState* play, u32 index, EffectSs* this) { + this->rPitch += this->rRotSpeed; // rRotSpeed is not initialized so this does nothing +} diff --git a/src/overlays/effects/ovl_Effect_Ss_En_Ice/z_eff_ss_en_ice.h b/src/overlays/effects/ovl_Effect_Ss_En_Ice/z_eff_ss_en_ice.h index ed0c6d457..46b162cc1 100644 --- a/src/overlays/effects/ovl_Effect_Ss_En_Ice/z_eff_ss_en_ice.h +++ b/src/overlays/effects/ovl_Effect_Ss_En_Ice/z_eff_ss_en_ice.h @@ -3,6 +3,11 @@ #include "global.h" +typedef enum EffectSsEnIceType { + /* 0 */ ENICE_TYPE_FLYING, + /* 1 */ ENICE_TYPE_NORMAL +} EffectSsEnIceType; + typedef struct { /* 0x00 */ Actor* actor; /* 0x04 */ Vec3f pos; 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..e33b486f4 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); -void EffectSsExtra_Update(GlobalContext* globalCtx, u32 index, EffectSs* this); -void EffectSsExtra_Draw(GlobalContext* globalCtx, u32 index, EffectSs* this); +u32 EffectSsExtra_Init(PlayState* play, u32 index, EffectSs* this, void* initParamsx); +void EffectSsExtra_Update(PlayState* play, u32 index, EffectSs* this); +void EffectSsExtra_Draw(PlayState* play, u32 index, EffectSs* this); + +static s16 sScores[] = { 30, 60, 100 }; -#if 0 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(PlayState* play, 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(&play->objectCtx, OBJECT_YABUSAME_POINT); + if ((objIndex >= 0) && (Object_IsLoaded(&play->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(play->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(PlayState* play, u32 index, EffectSs* this) { + s32 pad; + f32 scale; + void* storedSegment; + + scale = this->rScale / 100.0f; + storedSegment = play->objectCtx.status[this->rObjId].segment; + + OPEN_DISPS(play->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(play->state.gfxCtx); + Matrix_ReplaceRotation(&play->billboardMtxF); + + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(play->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(play->state.gfxCtx); +} + +void EffectSsExtra_Update(PlayState* play, u32 index, EffectSs* this) { + if (this->rTimer != 0) { + this->rTimer--; + } else { + this->velocity.y = 0.0f; + } + + if (this->rTimer == 1) { + play->interfaceCtx.unk_25C = sScores[this->rScoreIndex]; + } +} diff --git a/src/overlays/effects/ovl_Effect_Ss_Fhg_Flash/z_eff_ss_fhg_flash.c b/src/overlays/effects/ovl_Effect_Ss_Fhg_Flash/z_eff_ss_fhg_flash.c index 36ba13f9d..764828bf4 100644 --- a/src/overlays/effects/ovl_Effect_Ss_Fhg_Flash/z_eff_ss_fhg_flash.c +++ b/src/overlays/effects/ovl_Effect_Ss_Fhg_Flash/z_eff_ss_fhg_flash.c @@ -1,27 +1,119 @@ /* * File: z_eff_ss_fhg_flash.c * Overlay: ovl_Effect_Ss_Fhg_Flash - * Description: + * Description: Shock and Light Ball Effect */ #include "z_eff_ss_fhg_flash.h" +#include "overlays/actors/ovl_Boss_Hakugin/z_boss_hakugin.h" +#include "assets/overlays/ovl_Effect_Ss_Fhg_Flash/ovl_Effect_Ss_Fhg_Flash.h" + +#define rAlpha regs[0] +#define rXZRot regs[3] +#define rParams regs[4] +#define rScale regs[8] #define PARAMS ((EffectSsFhgFlashInitParams*)initParamsx) -s32 EffectSsFhgFlash_Init(GlobalContext* globalCtx, u32 index, EffectSs* this, void* initParamsx); -void EffectSsFhgFlash_Update(GlobalContext* globalCtx, u32 index, EffectSs* this); -void EffectSsFhgFlash_Draw(GlobalContext* globalCtx, u32 index, EffectSs* this); +u32 EffectSsFhgFlash_Init(PlayState* play, u32 index, EffectSs* this, void* initParamsx); +void EffectSsFhgFlash_Update(PlayState* play, u32 index, EffectSs* this); +void EffectSsFhgFlash_Draw(PlayState* play, u32 index, EffectSs* this); -#if 0 const EffectSsInit Effect_Ss_Fhg_Flash_InitVars = { EFFECT_SS_FHG_FLASH, EffectSsFhgFlash_Init, }; -#endif +u32 EffectSsFhgFlash_Init(PlayState* play, u32 index, EffectSs* this, void* initParamsx) { + static Vec3f sZeroVec = { 0.0f, 0.0f, 0.0f }; + EffectSsFhgFlashInitParams* initParams = PARAMS; + Vec3f noActorPos = { 0.0f, -1000.0f, 0.0f }; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Effect_Ss_Fhg_Flash/EffectSsFhgFlash_Init.s") + this->actor = initParams->actor; + Math_Vec3f_Copy(&this->velocity, &gZeroVec3f); + Math_Vec3f_Copy(&this->accel, &gZeroVec3f); + this->life = (s32)(Rand_ZeroOne() * 10.0f) + 111; + this->rScale = (s32)Rand_ZeroFloat(initParams->scale) + initParams->scale; + this->rAlpha = 255; + this->draw = EffectSsFhgFlash_Draw; + this->update = EffectSsFhgFlash_Update; + this->rParams = initParams->params; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Effect_Ss_Fhg_Flash/EffectSsFhgFlash_Draw.s") + if (initParams->params != FHGFLASH_SHOCK_NO_ACTOR) { + this->pos = noActorPos; + this->gfx = gEffFhgFlashDL; + } else { + this->pos = initParams->pos; + this->gfx = gEffFhgFlashDL; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Effect_Ss_Fhg_Flash/EffectSsFhgFlash_Update.s") + return 1; +} + +#include "overlays/ovl_Effect_Ss_Fhg_Flash/ovl_Effect_Ss_Fhg_Flash.c" + +void EffectSsFhgFlash_Draw(PlayState* play, u32 index, EffectSs* this) { + s32 pad; + GraphicsContext* gfxCtx = play->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); + if (this->rParams != FHGFLASH_SHOCK_NO_ACTOR) { + func_8012C448(play->state.gfxCtx); + Matrix_RotateXS(this->rXZRot, MTXMODE_APPLY); + gDPSetRenderMode(POLY_XLU_DISP++, G_RM_PASS, G_RM_AA_ZB_XLU_DECAL2); + } else { + func_8012C2DC(play->state.gfxCtx); + Matrix_ReplaceRotation(&play->billboardMtxF); + gDPSetRenderMode(POLY_XLU_DISP++, G_RM_PASS, G_RM_AA_ZB_XLU_SURF2); + } + gDPPipeSync(POLY_XLU_DISP++); + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 255, 255, 255, this->rAlpha); + gDPSetEnvColor(POLY_XLU_DISP++, 0, 255, 155, 0); + Matrix_RotateZS(this->rXZRot, MTXMODE_APPLY); + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + + gSPDisplayList(POLY_XLU_DISP++, this->gfx); + + CLOSE_DISPS(gfxCtx); +} + +void EffectSsFhgFlash_Update(PlayState* play, u32 index, EffectSs* this) { + s16 randBodyPart; + s16 rand = Rand_ZeroOne() * 20000.0f; + + this->rXZRot = (this->rXZRot + rand) + 0x4000; + if (this->rParams == FHGFLASH_SHOCK_PLAYER) { + Player* player = GET_PLAYER(play); + + randBodyPart = Rand_ZeroFloat(18 - 0.1f); + this->pos.x = player->bodyPartsPos[randBodyPart].x + randPlusMinusPoint5Scaled(10.0f); + this->pos.y = player->bodyPartsPos[randBodyPart].y + randPlusMinusPoint5Scaled(15.0f); + this->pos.z = player->bodyPartsPos[randBodyPart].z + randPlusMinusPoint5Scaled(10.0f); + } else if ((this->rParams >= FHGFLASH_SHOCK_GOHT_2) && (this->rParams <= FHGFLASH_SHOCK_GOHT_6)) { + s32 pad; + Vec3f* bodyPartPos; + BossHakugin* goht = (BossHakugin*)this->actor; + s32 index = goht->unk_191 - 3; + + if (index < 0) { + bodyPartPos = &goht->unk_2F00[this->rParams][12].unk_00; + } else { + bodyPartPos = &goht->unk_2F00[this->rParams][index].unk_00; + } + + this->pos.x = randPlusMinusPoint5Scaled(70.0f) + bodyPartPos->x; + this->pos.y = randPlusMinusPoint5Scaled(70.0f) + bodyPartPos->y; + this->pos.z = randPlusMinusPoint5Scaled(70.0f) + bodyPartPos->z; + } + if (this->life < 100) { + this->rAlpha -= 50; + if (this->rAlpha < 0) { + this->rAlpha = 0; + this->life = 0; + } + } +} diff --git a/src/overlays/effects/ovl_Effect_Ss_Fhg_Flash/z_eff_ss_fhg_flash.h b/src/overlays/effects/ovl_Effect_Ss_Fhg_Flash/z_eff_ss_fhg_flash.h index 0598377f8..c464047b5 100644 --- a/src/overlays/effects/ovl_Effect_Ss_Fhg_Flash/z_eff_ss_fhg_flash.h +++ b/src/overlays/effects/ovl_Effect_Ss_Fhg_Flash/z_eff_ss_fhg_flash.h @@ -23,7 +23,11 @@ typedef enum { typedef enum { /* 0x00 */ FHGFLASH_SHOCK_NO_ACTOR, /* 0x01 */ FHGFLASH_SHOCK_PLAYER, - /* 0x02 */ FHGFLASH_SHOCK_PG + /* 0x02 */ FHGFLASH_SHOCK_GOHT_2, + /* 0x03 */ FHGFLASH_SHOCK_GOHT_3, + /* 0x04 */ FHGFLASH_SHOCK_GOHT_4, + /* 0x05 */ FHGFLASH_SHOCK_GOHT_5, + /* 0x06 */ FHGFLASH_SHOCK_GOHT_6 } FhgFlashLightningParam; typedef struct { @@ -31,7 +35,7 @@ typedef struct { /* 0x0C */ Vec3f velocity; /* 0x18 */ Vec3f accel; /* 0x24 */ s16 scale; - /* 0x26 */ u8 param; + /* 0x26 */ u8 params; /* 0x28 */ Actor* actor; /* 0x2C */ u8 type; } EffectSsFhgFlashInitParams; // size = 0x30 diff --git a/src/overlays/effects/ovl_Effect_Ss_Fire_Tail/z_eff_ss_fire_tail.c b/src/overlays/effects/ovl_Effect_Ss_Fire_Tail/z_eff_ss_fire_tail.c index 8d900162f..da4de14d6 100644 --- a/src/overlays/effects/ovl_Effect_Ss_Fire_Tail/z_eff_ss_fire_tail.c +++ b/src/overlays/effects/ovl_Effect_Ss_Fire_Tail/z_eff_ss_fire_tail.c @@ -1,27 +1,142 @@ /* * File: z_eff_ss_fire_tail.c * Overlay: ovl_Effect_Ss_Fire_Tail - * Description: + * Description: Fire (burned by something) */ #include "z_eff_ss_fire_tail.h" +#include "objects/gameplay_keep/gameplay_keep.h" + +#define rScale regs[0] +#define rLifespan regs[1] +#define rReg2 regs[2] +#define rReg3 regs[3] +#define rPrimColorR regs[4] +#define rPrimColorG regs[5] +#define rPrimColorB regs[6] +#define rEnvColorR regs[7] +#define rEnvColorG regs[8] +#define rEnvColorB regs[9] +#define rReg10 regs[10] +#define rBodyPart regs[11] +#define rType regs[12] #define PARAMS ((EffectSsFireTailInitParams*)initParamsx) -s32 EffectSsFireTail_Init(GlobalContext* globalCtx, u32 index, EffectSs* this, void* initParamsx); -void EffectSsFireTail_Update(GlobalContext* globalCtx, u32 index, EffectSs* this); -void EffectSsFireTail_Draw(GlobalContext* globalCtx, u32 index, EffectSs* this); +u32 EffectSsFireTail_Init(PlayState* play, u32 index, EffectSs* this, void* initParamsx); +void EffectSsFireTail_Update(PlayState* play, u32 index, EffectSs* this); +void EffectSsFireTail_Draw(PlayState* play, u32 index, EffectSs* this); -#if 0 const EffectSsInit Effect_Ss_Fire_Tail_InitVars = { EFFECT_SS_FIRE_TAIL, EffectSsFireTail_Init, }; -#endif +u32 EffectSsFireTail_Init(PlayState* play, u32 index, EffectSs* this, void* initParamsx) { + EffectSsFireTailInitParams* initParams = PARAMS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Effect_Ss_Fire_Tail/EffectSsFireTail_Init.s") + this->pos = initParams->pos; + this->vec = initParams->unk_14; + this->velocity.x = 0.0f; + this->velocity.y = 0.0f; + this->velocity.z = 0.0f; + this->accel.x = 0.0f; + this->accel.y = 0.0f; + this->accel.z = 0.0f; + this->life = initParams->life; + this->actor = initParams->actor; + this->draw = EffectSsFireTail_Draw; + this->update = EffectSsFireTail_Update; + this->rScale = initParams->scale * 1000.0f; + this->rLifespan = initParams->life; + this->rReg2 = -10; + this->rReg3 = -15; + if (initParams->unk_20 == 0) { + initParams->unk_20 = 1; + } + this->rReg10 = initParams->unk_20; + this->rPrimColorR = initParams->primColor.r; + this->rPrimColorG = initParams->primColor.g; + this->rPrimColorB = initParams->primColor.b; + this->rEnvColorR = initParams->envColor.r; + this->rEnvColorG = initParams->envColor.g; + this->rEnvColorB = initParams->envColor.b; + this->rBodyPart = initParams->bodyPart; + this->rType = initParams->type; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Effect_Ss_Fire_Tail/EffectSsFireTail_Draw.s") + return 1; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Effect_Ss_Fire_Tail/EffectSsFireTail_Update.s") +void EffectSsFireTail_Draw(PlayState* play, u32 index, EffectSs* this) { + GraphicsContext* gfxCtx = play->state.gfxCtx; + s32 pad; + s16 yawDiff; + Vec3f scale; + f32 temp1; + f32 temp2; + f32 dist; + + OPEN_DISPS(gfxCtx); + + scale.x = scale.y = scale.z = 0.0f; + + if (this->actor != NULL) { + this->vec = this->actor->velocity; + + if (this->rBodyPart < 0) { + Matrix_Translate(this->pos.x + this->actor->world.pos.x, this->pos.y + this->actor->world.pos.y, + this->pos.z + this->actor->world.pos.z, MTXMODE_NEW); + } else { + Player* player = GET_PLAYER(play); + s16 bodyPart = this->rBodyPart; + + this->pos.x = + player->bodyPartsPos[bodyPart].x - (Math_SinS(Camera_GetCamDirYaw(GET_ACTIVE_CAM(play))) * 5.0f); + this->pos.y = player->bodyPartsPos[bodyPart].y; + this->pos.z = + player->bodyPartsPos[bodyPart].z - (Math_CosS(Camera_GetCamDirYaw(GET_ACTIVE_CAM(play))) * 5.0f); + + Matrix_Translate(this->pos.x, this->pos.y, this->pos.z, MTXMODE_NEW); + } + } else { + Matrix_Translate(this->pos.x, this->pos.y, this->pos.z, MTXMODE_NEW); + } + + yawDiff = Math_Vec3f_Yaw(&scale, &this->vec) - Camera_GetCamDirYaw(GET_ACTIVE_CAM(play)); + temp1 = fabsf(Math_CosS(yawDiff)); + temp2 = Math_SinS(yawDiff); + dist = Math_Vec3f_DistXZ(&scale, &this->vec) / (this->rReg10 * 0.1f); + Matrix_RotateYS(Camera_GetCamDirYaw(GET_ACTIVE_CAM(play)) + 0x8000, MTXMODE_APPLY); + Matrix_RotateZF(DEGF_TO_RADF(temp2 * this->rReg2 * dist), MTXMODE_APPLY); + temp2 = 1.0f - ((f32)(this->life + 1) / this->rLifespan); + temp2 = 1.0f - SQ(temp2); + scale.x = scale.y = scale.z = temp2 * (this->rScale * (0.001f * 0.01f)); + Matrix_Scale(scale.x, scale.y, scale.z, MTXMODE_APPLY); + temp1 = (this->rReg3 * 0.01f * temp1 * dist) + 1.0f; + + if (temp1 < 0.1f) { + temp1 = 0.1f; + } + + Matrix_Scale(1.0f, temp1, 1.0f / temp1, MTXMODE_APPLY); + + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + func_8012C2DC(play->state.gfxCtx); + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0x80, this->rPrimColorR, this->rPrimColorG, this->rPrimColorB, 255); + gDPSetEnvColor(POLY_XLU_DISP++, this->rEnvColorR, this->rEnvColorG, this->rEnvColorB, 0); + gSPSegment( + POLY_XLU_DISP++, 0x08, + Gfx_TwoTexScroll(play->state.gfxCtx, 0, 0, 0, 32, 64, 1, 0, (play->state.frames * -20) & 0x1FF, 32, 128)); + + if (this->rType != 0) { + gSPDisplayList(POLY_XLU_DISP++, gEffFire2DL); + } else { + gSPDisplayList(POLY_XLU_DISP++, gEffFire1DL); + } + + CLOSE_DISPS(gfxCtx); +} + +void EffectSsFireTail_Update(PlayState* play, u32 index, EffectSs* this) { + this->rScale *= 0.9f; +} diff --git a/src/overlays/effects/ovl_Effect_Ss_G_Fire/z_eff_ss_g_fire.c b/src/overlays/effects/ovl_Effect_Ss_G_Fire/z_eff_ss_g_fire.c index 62c945566..7bc2d6966 100644 --- a/src/overlays/effects/ovl_Effect_Ss_G_Fire/z_eff_ss_g_fire.c +++ b/src/overlays/effects/ovl_Effect_Ss_G_Fire/z_eff_ss_g_fire.c @@ -1,27 +1,59 @@ /* * File: z_eff_ss_g_fire.c * Overlay: ovl_Effect_Ss_G_Fire - * Description: + * Description: Flame Footprints */ #include "z_eff_ss_g_fire.h" +#include "objects/gameplay_keep/gameplay_keep.h" #define PARAMS ((EffectSsGFireInitParams*)initParamsx) -s32 EffectSsGFire_Init(GlobalContext* globalCtx, u32 index, EffectSs* this, void* initParamsx); -void EffectSsGFire_Update(GlobalContext* globalCtx, u32 index, EffectSs* this); -void EffectSsGFire_Draw(GlobalContext* globalCtx, u32 index, EffectSs* this); +u32 EffectSsGFire_Init(PlayState* play, u32 index, EffectSs* this, void* initParamsx); +void EffectSsGFire_Update(PlayState* play, u32 index, EffectSs* this); +void EffectSsGFire_Draw(PlayState* play, u32 index, EffectSs* this); -#if 0 const EffectSsInit Effect_Ss_G_Fire_InitVars = { EFFECT_SS_G_FIRE, EffectSsGFire_Init, }; -#endif +u32 EffectSsGFire_Init(PlayState* play, u32 index, EffectSs* this, void* initParamsx) { + EffectSsGFireInitParams* initParams = PARAMS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Effect_Ss_G_Fire/EffectSsGFire_Init.s") + Math_Vec3f_Copy(&this->velocity, &gZeroVec3f); + Math_Vec3f_Copy(&this->accel, &gZeroVec3f); + Math_Vec3f_Copy(&this->pos, &initParams->pos); + this->draw = EffectSsGFire_Draw; + this->update = EffectSsGFire_Update; + this->gfx = gEffFireFootprintDL; + this->life = 8; + this->flags = 0; + this->rgScale = 200; + this->rgTexIndex = 0; + this->rgTexIndexStep = 50; + this->rgPrimColorR = 255; + this->rgPrimColorG = 220; + this->rgPrimColorB = 80; + this->rgPrimColorA = 255; + this->rgEnvColorR = 130; + this->rgEnvColorG = 30; + this->rgEnvColorB = 0; + this->rgEnvColorA = 0; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Effect_Ss_G_Fire/EffectSsGFire_Draw.s") + return 1; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Effect_Ss_G_Fire/EffectSsGFire_Update.s") +void EffectSsGFire_Draw(PlayState* play, u32 index, EffectSs* this) { + TexturePtr fireFootprintTextures[] = { + gEffFireFootprint1Tex, gEffFireFootprint2Tex, gEffFireFootprint3Tex, gEffFireFootprint4Tex, + gEffFireFootprint5Tex, gEffFireFootprint6Tex, gEffFireFootprint7Tex, gEffFireFootprint8Tex, + }; + s16 texIndex = (this->rgTexIndex / 100) % 7; + + EffectSs_DrawGEffect(play, this, fireFootprintTextures[texIndex]); +} + +void EffectSsGFire_Update(PlayState* play, u32 index, EffectSs* this) { + this->rgTexIndex += this->rgTexIndexStep; +} diff --git a/src/overlays/effects/ovl_Effect_Ss_G_Ripple/z_eff_ss_g_ripple.c b/src/overlays/effects/ovl_Effect_Ss_G_Ripple/z_eff_ss_g_ripple.c index dbe61ca2f..b820d8168 100644 --- a/src/overlays/effects/ovl_Effect_Ss_G_Ripple/z_eff_ss_g_ripple.c +++ b/src/overlays/effects/ovl_Effect_Ss_G_Ripple/z_eff_ss_g_ripple.c @@ -1,29 +1,138 @@ /* * File: z_eff_ss_g_ripple.c * Overlay: ovl_Effect_Ss_G_Ripple - * Description: + * Description: Water Ripple */ #include "z_eff_ss_g_ripple.h" +#include "objects/gameplay_keep/gameplay_keep.h" + +#define rWaterBoxNum regs[0] +#define rRadius regs[1] +#define rRadiusMax regs[2] +#define rPrimColorR regs[3] +#define rPrimColorG regs[4] +#define rPrimColorB regs[5] +#define rPrimColorA regs[6] +#define rEnvColorR regs[7] +#define rEnvColorG regs[8] +#define rEnvColorB regs[9] +#define rEnvColorA regs[10] +#define rLifespan regs[11] +#define rBgId regs[12] #define PARAMS ((EffectSsGRippleInitParams*)initParamsx) -s32 EffectSsGRipple_Init(GlobalContext* globalCtx, u32 index, EffectSs* this, void* initParamsx); -void EffectSsGRipple_Update(GlobalContext* globalCtx, u32 index, EffectSs* this); -void EffectSsGRipple_Draw(GlobalContext* globalCtx, u32 index, EffectSs* this); +u32 EffectSsGRipple_Init(PlayState* play, u32 index, EffectSs* this, void* initParamsx); +void EffectSsGRipple_Update(PlayState* play, u32 index, EffectSs* this); +void EffectSsGRipple_Draw(PlayState* play, u32 index, EffectSs* this); -#if 0 const EffectSsInit Effect_Ss_G_Ripple_InitVars = { EFFECT_SS_G_RIPPLE, EffectSsGRipple_Init, }; -#endif +u32 EffectSsGRipple_Init(PlayState* play, u32 index, EffectSs* this, void* initParamsx) { + EffectSsGRippleInitParams* initParams = PARAMS; + WaterBox* waterBox = NULL; + s32 pad; + s32 bgId; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Effect_Ss_G_Ripple/EffectSsGRipple_Init.s") + Math_Vec3f_Copy(&this->velocity, &gZeroVec3f); + Math_Vec3f_Copy(&this->accel, &gZeroVec3f); + Math_Vec3f_Copy(&this->pos, &initParams->pos); + this->gfx = gEffWaterRippleDL; + this->life = initParams->life + 20; + this->flags = 0; + this->draw = EffectSsGRipple_Draw; + this->update = EffectSsGRipple_Update; + this->rRadius = initParams->radius; + this->rRadiusMax = initParams->radiusMax; + this->rLifespan = initParams->life; + this->rPrimColorR = 255; + this->rPrimColorG = 255; + this->rPrimColorB = 255; + this->rPrimColorA = 255; + this->rEnvColorR = 255; + this->rEnvColorG = 255; + this->rEnvColorB = 255; + this->rEnvColorA = 255; + this->rWaterBoxNum = WaterBox_GetSurface2(play, &play->colCtx, &initParams->pos, 3.0f, &waterBox, &bgId); + this->rBgId = bgId; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Effect_Ss_G_Ripple/func_80979C38.s") + return 1; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Effect_Ss_G_Ripple/EffectSsGRipple_Draw.s") +void EffectSsGRipple_DrawRipple(PlayState* play2, EffectSs* this, TexturePtr tex) { + PlayState* play = play2; + f32 radius; + GraphicsContext* gfxCtx = play->state.gfxCtx; + MtxF mfTrans; + MtxF mfScale; + MtxF mfResult; + Mtx* mtx; + f32 yPos; + CollisionHeader* colHeader; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Effect_Ss_G_Ripple/EffectSsGRipple_Update.s") + OPEN_DISPS(gfxCtx); + + radius = this->rRadius * 0.0025f; + colHeader = BgCheck_GetCollisionHeader(&play->colCtx, this->rBgId); + + if ((this->rWaterBoxNum != -1) && (colHeader != NULL) && (this->rWaterBoxNum < colHeader->numWaterBoxes)) { + yPos = func_800CA568(&play->colCtx, this->rWaterBoxNum, this->rBgId); + } else { + yPos = this->pos.y; + } + + SkinMatrix_SetTranslate(&mfTrans, this->pos.x, yPos, this->pos.z); + SkinMatrix_SetScale(&mfScale, radius, radius, radius); + SkinMatrix_MtxFMtxFMult(&mfTrans, &mfScale, &mfResult); + + mtx = SkinMatrix_MtxFToNewMtx(gfxCtx, &mfResult); + + if (mtx != NULL) { + gSPMatrix(POLY_XLU_DISP++, mtx, G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + func_8012C974(gfxCtx); + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, this->rPrimColorR, this->rPrimColorG, this->rPrimColorB, + this->rPrimColorA); + gDPSetEnvColor(POLY_XLU_DISP++, this->rEnvColorR, this->rEnvColorG, this->rEnvColorB, this->rEnvColorA); + gDPSetAlphaDither(POLY_XLU_DISP++, G_AD_NOISE); + gDPSetColorDither(POLY_XLU_DISP++, G_CD_NOISE); + gSPDisplayList(POLY_XLU_DISP++, this->gfx); + } + + CLOSE_DISPS(gfxCtx); +} + +void EffectSsGRipple_Draw(PlayState* play, u32 index, EffectSs* this) { + if (this->rLifespan == 0) { + EffectSsGRipple_DrawRipple(play, this, gEffWaterRippleTex); + } +} + +void EffectSsGRipple_Update(PlayState* play, u32 index, EffectSs* this) { + f32 radius; + f32 primAlpha; + f32 envAlpha; + WaterBox* waterBox; + s32 bgId; + + this->rWaterBoxNum = WaterBox_GetSurface2(play, &play->colCtx, &this->pos, 3.0f, &waterBox, &bgId); + this->rBgId = bgId; + + if (DECR(this->rLifespan) == 0) { + radius = this->rRadius; + Math_SmoothStepToF(&radius, this->rRadiusMax, 0.2f, 30.0f, 1.0f); + this->rRadius = radius; + + primAlpha = this->rPrimColorA; + envAlpha = this->rEnvColorA; + + Math_SmoothStepToF(&primAlpha, 0.0f, 0.2f, 15.0f, 7.0f); + Math_SmoothStepToF(&envAlpha, 0.0f, 0.2f, 15.0f, 7.0f); + + this->rPrimColorA = primAlpha; + this->rEnvColorA = envAlpha; + } +} diff --git a/src/overlays/effects/ovl_Effect_Ss_G_Spk/z_eff_ss_g_spk.c b/src/overlays/effects/ovl_Effect_Ss_G_Spk/z_eff_ss_g_spk.c index 6cb6f18d8..260541b51 100644 --- a/src/overlays/effects/ovl_Effect_Ss_G_Spk/z_eff_ss_g_spk.c +++ b/src/overlays/effects/ovl_Effect_Ss_G_Spk/z_eff_ss_g_spk.c @@ -1,30 +1,145 @@ /* * File: z_eff_ss_g_spk.c * Overlay: ovl_Effect_Ss_G_Spk - * Description: + * Description: Sparks */ #include "z_eff_ss_g_spk.h" +#include "objects/gameplay_keep/gameplay_keep.h" + +#define rPrimColorR regs[0] +#define rPrimColorG regs[1] +#define rPrimColorB regs[2] +#define rPrimColorA regs[3] +#define rEnvColorR regs[4] +#define rEnvColorG regs[5] +#define rEnvColorB regs[6] +#define rEnvColorA regs[7] +#define rTexIndex regs[8] +#define rScale regs[9] +#define rScaleStep regs[10] #define PARAMS ((EffectSsGSpkInitParams*)initParamsx) -s32 EffectSsGSpk_Init(GlobalContext* globalCtx, u32 index, EffectSs* this, void* initParamsx); -void func_80978F40(GlobalContext* globalCtx, u32 index, EffectSs* this); -void func_80979068(GlobalContext* globalCtx, u32 index, EffectSs* this); -void EffectSsGSpk_Draw(GlobalContext* globalCtx, u32 index, EffectSs* this); +u32 EffectSsGSpk_Init(PlayState* play, u32 index, EffectSs* this, void* initParamsx); +void EffectSsGSpk_Update(PlayState* play, u32 index, EffectSs* this); +void EffectSsGSpk_UpdateNoAccel(PlayState* play, u32 index, EffectSs* this); +void EffectSsGSpk_Draw(PlayState* play, u32 index, EffectSs* this); -#if 0 const EffectSsInit Effect_Ss_G_Spk_InitVars = { EFFECT_SS_G_SPK, EffectSsGSpk_Init, }; -#endif +static TexturePtr sSparkTextures[] = { + gElectricSpark1Tex, + gElectricSpark2Tex, + gElectricSpark3Tex, + gElectricSpark4Tex, +}; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Effect_Ss_G_Spk/EffectSsGSpk_Init.s") +u32 EffectSsGSpk_Init(PlayState* play, u32 index, EffectSs* this, void* initParamsx) { + EffectSsGSpkInitParams* initParams = PARAMS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Effect_Ss_G_Spk/EffectSsGSpk_Draw.s") + Math_Vec3f_Copy(&this->pos, &initParams->pos); + Math_Vec3f_Copy(&this->velocity, &initParams->velocity); + Math_Vec3f_Copy(&this->accel, &initParams->accel); + this->gfx = gEffSparkDL; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Effect_Ss_G_Spk/func_80978F40.s") + if (initParams->updateMode == GSPK_UPDATEMODE_NORMAL) { + this->life = 10; + this->vec.x = initParams->pos.x - initParams->actor->world.pos.x; + this->vec.y = initParams->pos.y - initParams->actor->world.pos.y; + this->vec.z = initParams->pos.z - initParams->actor->world.pos.z; + this->update = EffectSsGSpk_Update; + } else { + this->life = 5; + this->update = EffectSsGSpk_UpdateNoAccel; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Effect_Ss_G_Spk/func_80979068.s") + this->draw = EffectSsGSpk_Draw; + this->rPrimColorR = initParams->primColor.r; + this->rPrimColorG = initParams->primColor.g; + this->rPrimColorB = initParams->primColor.b; + this->rPrimColorA = initParams->primColor.a; + this->rEnvColorR = initParams->envColor.r; + this->rEnvColorG = initParams->envColor.g; + this->rEnvColorB = initParams->envColor.b; + this->rEnvColorA = initParams->envColor.a; + this->rTexIndex = 0; + this->rScale = initParams->scale; + this->rScaleStep = initParams->scaleStep; + this->actor = initParams->actor; + + return 1; +} + +void EffectSsGSpk_Draw(PlayState* play, u32 index, EffectSs* this) { + s32 pad; + MtxF mfTrans; + MtxF mfScale; + MtxF mfResult; + MtxF mfTransBillboard; + Mtx* mtx; + f32 scale; + GraphicsContext* gfxCtx = play->state.gfxCtx; + + OPEN_DISPS(gfxCtx); + + scale = this->rScale * 0.0025f; + SkinMatrix_SetTranslate(&mfTrans, this->pos.x, this->pos.y, this->pos.z); + SkinMatrix_SetScale(&mfScale, scale, scale, 1.0f); + SkinMatrix_MtxFMtxFMult(&mfTrans, &play->billboardMtxF, &mfTransBillboard); + SkinMatrix_MtxFMtxFMult(&mfTransBillboard, &mfScale, &mfResult); + + mtx = SkinMatrix_MtxFToNewMtx(gfxCtx, &mfResult); + + if (mtx != NULL) { + gSPMatrix(POLY_XLU_DISP++, mtx, G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPSegment(POLY_XLU_DISP++, 0x08, Lib_SegmentedToVirtual(sSparkTextures[this->rTexIndex])); + func_8012C974(gfxCtx); + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, this->rPrimColorR, this->rPrimColorG, this->rPrimColorB, 255); + gDPSetEnvColor(POLY_XLU_DISP++, this->rEnvColorR, this->rEnvColorG, this->rEnvColorB, this->rEnvColorA); + gSPDisplayList(POLY_XLU_DISP++, this->gfx); + } + + CLOSE_DISPS(gfxCtx); +} + +void EffectSsGSpk_Update(PlayState* play, u32 index, EffectSs* this) { + this->accel.x = (Rand_ZeroOne() - 0.5f) * 3.0f; + this->accel.z = (Rand_ZeroOne() - 0.5f) * 3.0f; + + if (this->actor != NULL) { + if ((this->actor->category == ACTORCAT_EXPLOSIVES) && (this->actor->update != NULL)) { + this->pos.x = this->actor->world.pos.x + this->vec.x; + this->pos.y = this->actor->world.pos.y + this->vec.y; + this->pos.z = this->actor->world.pos.z + this->vec.z; + if (this->actor->depthInWater >= 20.0f) { + this->life = 0; + } + } + } + + this->vec.x += this->accel.x; + this->vec.z += this->accel.z; + + this->rTexIndex++; + this->rTexIndex &= 3; + this->rScale += this->rScaleStep; +} + +// this update mode is unused in the original game +// with this update mode, the sparks dont move randomly in the xz plane, appearing to be on top of each other +void EffectSsGSpk_UpdateNoAccel(PlayState* play, u32 index, EffectSs* this) { + if (this->actor != NULL) { + if ((this->actor->category == ACTORCAT_EXPLOSIVES) && (this->actor->update != NULL)) { + this->pos.x += (Math_SinS(this->actor->world.rot.y) * this->actor->speedXZ); + this->pos.z += (Math_CosS(this->actor->world.rot.y) * this->actor->speedXZ); + } + } + + this->rTexIndex++; + this->rTexIndex &= 3; + this->rScale += this->rScaleStep; +} diff --git a/src/overlays/effects/ovl_Effect_Ss_G_Spk/z_eff_ss_g_spk.h b/src/overlays/effects/ovl_Effect_Ss_G_Spk/z_eff_ss_g_spk.h index 1d970d3d2..c44bb9168 100644 --- a/src/overlays/effects/ovl_Effect_Ss_G_Spk/z_eff_ss_g_spk.h +++ b/src/overlays/effects/ovl_Effect_Ss_G_Spk/z_eff_ss_g_spk.h @@ -3,6 +3,11 @@ #include "global.h" +typedef enum EffectSsGSpkUpdatemode { + /* 0 */ GSPK_UPDATEMODE_NORMAL, + /* 1 */ GSPK_UPDATEMODE_NO_ACCEL +} EffectSsGSpkUpdatemode; + typedef struct { /* 0x00 */ Actor* actor; /* 0x04 */ Vec3f pos; diff --git a/src/overlays/effects/ovl_Effect_Ss_G_Splash/z_eff_ss_g_splash.c b/src/overlays/effects/ovl_Effect_Ss_G_Splash/z_eff_ss_g_splash.c index 597fce601..78bee9835 100644 --- a/src/overlays/effects/ovl_Effect_Ss_G_Splash/z_eff_ss_g_splash.c +++ b/src/overlays/effects/ovl_Effect_Ss_G_Splash/z_eff_ss_g_splash.c @@ -5,23 +5,135 @@ */ #include "z_eff_ss_g_splash.h" +#include "objects/gameplay_keep/gameplay_keep.h" + +//! @bug the reuse of regs[11] means that EffectSs_DrawGEffect will treat the type as an object bank index +// this ends up having no effect because the texture provided does not use segment 6 +#define rType regs[11] #define PARAMS ((EffectSsGSplashInitParams*)initParamsx) -s32 EffectSsGSplash_Init(GlobalContext* globalCtx, u32 index, EffectSs* this, void* initParamsx); -void EffectSsGSplash_Update(GlobalContext* globalCtx, u32 index, EffectSs* this); -void EffectSsGSplash_Draw(GlobalContext* globalCtx, u32 index, EffectSs* this); +u32 EffectSsGSplash_Init(PlayState* play, u32 index, EffectSs* this, void* initParamsx); +void EffectSsGSplash_Update(PlayState* play, u32 index, EffectSs* this); +void EffectSsGSplash_Draw(PlayState* play, u32 index, EffectSs* this); -#if 0 const EffectSsInit Effect_Ss_G_Splash_InitVars = { EFFECT_SS_G_SPLASH, EffectSsGSplash_Init, }; -#endif +static TexturePtr waterSplashTextures[] = { + gEffWaterSplash1Tex, gEffWaterSplash2Tex, gEffWaterSplash3Tex, gEffWaterSplash4Tex, + gEffWaterSplash5Tex, gEffWaterSplash6Tex, gEffWaterSplash7Tex, gEffWaterSplash8Tex, +}; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Effect_Ss_G_Splash/EffectSsGSplash_Init.s") +u32 EffectSsGSplash_Init(PlayState* play, u32 index, EffectSs* this, void* initParamsx) { + EffectSsGSplashInitParams* initParams = PARAMS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Effect_Ss_G_Splash/EffectSsGSplash_Draw.s") + Math_Vec3f_Copy(&this->velocity, &gZeroVec3f); + Math_Vec3f_Copy(&this->accel, &gZeroVec3f); + Math_Vec3f_Copy(&this->pos, &initParams->pos); + this->draw = EffectSsGSplash_Draw; + this->update = EffectSsGSplash_Update; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Effect_Ss_G_Splash/EffectSsGSplash_Update.s") + if (initParams->scale == 0) { + initParams->scale = 600; + } + + this->gfx = gEffWaterSplashDL; + this->life = 8; + this->rgScale = initParams->scale; + this->rgTexIndex = 0; + this->rgTexIndexStep = 100; + + if (initParams->customColor) { + this->rgPrimColorR = initParams->primColor.r; + this->rgPrimColorG = initParams->primColor.g; + this->rgPrimColorB = initParams->primColor.b; + this->rgPrimColorA = initParams->primColor.a; + this->rgEnvColorR = initParams->envColor.r; + this->rgEnvColorG = initParams->envColor.g; + this->rgEnvColorB = initParams->envColor.b; + this->rgEnvColorA = initParams->envColor.a; + this->rType = initParams->type; + } else { + switch (initParams->type) { + case 0: + this->rgPrimColorR = 255; + this->rgPrimColorG = 255; + this->rgPrimColorB = 255; + this->rgPrimColorA = 200; + this->rgEnvColorR = 255; + this->rgEnvColorG = 255; + this->rgEnvColorB = 255; + this->rgEnvColorA = 200; + this->rType = 0; + break; + case 1: + this->rgPrimColorR = 255; + this->rgPrimColorG = 255; + this->rgPrimColorB = 255; + this->rgPrimColorA = 255; + this->rgEnvColorR = 255; + this->rgEnvColorG = 255; + this->rgEnvColorB = 255; + this->rgEnvColorA = 255; + this->rType = 1; + break; + case 2: + this->rgPrimColorR = 255; + this->rgPrimColorG = 255; + this->rgPrimColorB = 255; + this->rgPrimColorA = 200; + this->rgEnvColorR = 255; + this->rgEnvColorG = 255; + this->rgEnvColorB = 255; + this->rgEnvColorA = 200; + this->rType = 2; + break; + } + } + return 1; +} + +void EffectSsGSplash_Draw(PlayState* play, u32 index, EffectSs* this) { + s16 texIndex; + + switch (this->rType) { + case 0: + texIndex = this->rgTexIndex / 100; + if (texIndex > 7) { + texIndex = 7; + } + EffectSs_DrawGEffect(play, this, waterSplashTextures[texIndex]); + break; + + case 1: + texIndex = this->rgTexIndex / 100; + if (texIndex > 7) { + texIndex = 7; + } + EffectSs_DrawGEffect(play, this, waterSplashTextures[texIndex]); + break; + + case 2: + texIndex = this->rgTexIndex / 100; + if (texIndex > 7) { + texIndex = 7; + } + EffectSs_DrawGEffect(play, this, waterSplashTextures[texIndex]); + break; + } +} + +void EffectSsGSplash_Update(PlayState* play, u32 index, EffectSs* this) { + Vec3f newSplashPos; + + if ((this->rType == 1) && (this->life == 5)) { + newSplashPos = this->pos; + newSplashPos.y += ((this->rgScale * 20) * 0.002f); + EffectSsGSplash_Spawn(play, &newSplashPos, 0, 0, 2, this->rgScale / 2); + } + + this->rgTexIndex += this->rgTexIndexStep; +} diff --git a/src/overlays/effects/ovl_Effect_Ss_Hahen/z_eff_ss_hahen.c b/src/overlays/effects/ovl_Effect_Ss_Hahen/z_eff_ss_hahen.c index b187c8f9c..b4d9ae6fb 100644 --- a/src/overlays/effects/ovl_Effect_Ss_Hahen/z_eff_ss_hahen.c +++ b/src/overlays/effects/ovl_Effect_Ss_Hahen/z_eff_ss_hahen.c @@ -1,33 +1,131 @@ /* * File: z_eff_ss_hahen.c * Overlay: ovl_Effect_Ss_Hahen - * Description: + * Description: Fragments */ #include "z_eff_ss_hahen.h" +#include "objects/gameplay_keep/gameplay_keep.h" + +#define rPitch regs[0] +#define rYaw regs[1] +#define rFlags regs[2] +#define rScale regs[3] +#define rObjId regs[4] +#define rObjBankIndex regs[5] +#define rMinLife regs[6] #define PARAMS ((EffectSsHahenInitParams*)initParamsx) -s32 EffectSsHahen_Init(GlobalContext* globalCtx, u32 index, EffectSs* this, void* initParamsx); -void EffectSsHahen_Update(GlobalContext* globalCtx, u32 index, EffectSs* this); -void EffectSsHahen_Draw(GlobalContext* globalCtx, u32 index, EffectSs* this); +u32 EffectSsHahen_Init(PlayState* play, u32 index, EffectSs* this, void* initParamsx); +void EffectSsHahen_Update(PlayState* play, u32 index, EffectSs* this); +void EffectSsHahen_Draw(PlayState* play, u32 index, EffectSs* this); -#if 0 const EffectSsInit Effect_Ss_Hahen_InitVars = { EFFECT_SS_HAHEN, EffectSsHahen_Init, }; -#endif +void EffectSsHahen_CheckForObject(EffectSs* this, PlayState* play) { + if (((this->rObjBankIndex = Object_GetIndex(&play->objectCtx, this->rObjId)) < 0) || + !Object_IsLoaded(&play->objectCtx, this->rObjBankIndex)) { + this->life = -1; + this->draw = NULL; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Effect_Ss_Hahen/func_8097B270.s") +u32 EffectSsHahen_Init(PlayState* play, u32 index, EffectSs* this, void* initParamsx) { + EffectSsHahenInitParams* initParams = PARAMS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Effect_Ss_Hahen/EffectSsHahen_Init.s") + this->pos = initParams->pos; + this->velocity = initParams->velocity; + this->accel = initParams->accel; + this->life = 200; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Effect_Ss_Hahen/func_8097B424.s") + if (initParams->dList != NULL) { + this->gfx = initParams->dList; + this->rObjId = initParams->objId; + EffectSsHahen_CheckForObject(this, play); + } else { + this->gfx = gEffFragments1DL; + this->rObjId = HAHEN_OBJECT_DEFAULT; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Effect_Ss_Hahen/func_8097B504.s") + this->draw = EffectSsHahen_Draw; + this->update = EffectSsHahen_Update; + this->rFlags = initParams->flags; + this->rScale = initParams->scale; + this->rPitch = Rand_ZeroOne() * 314.0f; + this->rYaw = Rand_ZeroOne() * 314.0f; + this->rMinLife = 200 - initParams->life; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Effect_Ss_Hahen/EffectSsHahen_Draw.s") + return 1; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Effect_Ss_Hahen/EffectSsHahen_Update.s") +void EffectSsHahen_DrawOpa(PlayState* play, EffectSs* this) { + GraphicsContext* gfxCtx = play->state.gfxCtx; + s32 pad; + + OPEN_DISPS(gfxCtx); + + if (this->rObjId != HAHEN_OBJECT_DEFAULT) { + gSPSegment(POLY_OPA_DISP++, 0x06, play->objectCtx.status[this->rObjBankIndex].segment); + } + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + func_8012C28C(play->state.gfxCtx); + gSPDisplayList(POLY_OPA_DISP++, this->gfx); + + CLOSE_DISPS(gfxCtx); +} + +void EffectSsHahen_DrawXlu(PlayState* play, EffectSs* this) { + GraphicsContext* gfxCtx = play->state.gfxCtx; + s32 pad; + + OPEN_DISPS(gfxCtx); + + if (this->rObjId != -1) { + gSPSegment(POLY_XLU_DISP++, 0x06, play->objectCtx.status[this->rObjBankIndex].segment); + } + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + func_8012C2DC(play->state.gfxCtx); + gSPDisplayList(POLY_XLU_DISP++, this->gfx); + + CLOSE_DISPS(gfxCtx); +} + +void EffectSsHahen_Draw(PlayState* play, u32 index, EffectSs* this) { + f32 scale; + + if (this->rFlags & HAHEN_SMALL) { + scale = this->rScale * (0.001f * 0.1f); + } else { + scale = this->rScale * 0.001f; + } + + Matrix_Translate(this->pos.x, this->pos.y, this->pos.z, MTXMODE_NEW); + Matrix_RotateYF(this->rYaw * 0.01f, MTXMODE_APPLY); + Matrix_RotateXFApply(this->rPitch * 0.01f); + Matrix_Scale(scale, scale, scale, MTXMODE_APPLY); + + if (this->rFlags & HAHEN_XLU) { + EffectSsHahen_DrawXlu(play, this); + } else { + EffectSsHahen_DrawOpa(play, this); + } +} + +void EffectSsHahen_Update(PlayState* play, u32 index, EffectSs* this) { + Player* player = GET_PLAYER(play); + + this->rPitch += 0x37; + this->rYaw += 0xA; + + if ((this->pos.y <= player->actor.floorHeight) && (this->life < this->rMinLife)) { + this->life = 0; + } + + if (this->rObjId != HAHEN_OBJECT_DEFAULT) { + EffectSsHahen_CheckForObject(this, play); + } +} diff --git a/src/overlays/effects/ovl_Effect_Ss_Hahen/z_eff_ss_hahen.h b/src/overlays/effects/ovl_Effect_Ss_Hahen/z_eff_ss_hahen.h index d7a160b4f..9a73ac664 100644 --- a/src/overlays/effects/ovl_Effect_Ss_Hahen/z_eff_ss_hahen.h +++ b/src/overlays/effects/ovl_Effect_Ss_Hahen/z_eff_ss_hahen.h @@ -5,12 +5,15 @@ #define HAHEN_OBJECT_DEFAULT -1 +#define HAHEN_SMALL (1 << 0) +#define HAHEN_XLU (1 << 1) + typedef struct { /* 0x00 */ Vec3f pos; /* 0x0C */ Vec3f velocity; /* 0x18 */ Vec3f accel; /* 0x24 */ Gfx* dList; - /* 0x28 */ s16 unused; + /* 0x28 */ s16 flags; /* 0x2A */ s16 scale; /* 0x2C */ s16 objId; /* 0x2C */ s16 life; diff --git a/src/overlays/effects/ovl_Effect_Ss_Hitmark/z_eff_ss_hitmark.c b/src/overlays/effects/ovl_Effect_Ss_Hitmark/z_eff_ss_hitmark.c index 4f221abe4..f65e36c7d 100644 --- a/src/overlays/effects/ovl_Effect_Ss_Hitmark/z_eff_ss_hitmark.c +++ b/src/overlays/effects/ovl_Effect_Ss_Hitmark/z_eff_ss_hitmark.c @@ -1,27 +1,163 @@ /* * File: z_eff_ss_hitmark.c * Overlay: ovl_Effect_Ss_Hitmark - * Description: + * Description: Hit Marks */ #include "z_eff_ss_hitmark.h" +#include "objects/gameplay_keep/gameplay_keep.h" + +#define rTexIndex regs[0] +#define rType regs[1] +#define rPrimColorR regs[2] +#define rPrimColorG regs[3] +#define rPrimColorB regs[4] +#define rEnvColorR regs[5] +#define rEnvColorG regs[6] +#define rEnvColorB regs[7] +#define rScale regs[8] #define PARAMS ((EffectSsHitmarkInitParams*)initParamsx) -s32 EffectSsHitmark_Init(GlobalContext* globalCtx, u32 index, EffectSs* this, void* initParamsx); -void EffectSsHitmark_Update(GlobalContext* globalCtx, u32 index, EffectSs* this); -void EffectSsHitmark_Draw(GlobalContext* globalCtx, u32 index, EffectSs* this); +u32 EffectSsHitmark_Init(PlayState* play, u32 index, EffectSs* this, void* initParamsx); +void EffectSsHitmark_Update(PlayState* play, u32 index, EffectSs* this); +void EffectSsHitmark_Draw(PlayState* play, u32 index, EffectSs* this); + +static Color_RGB8 sColors[] = { + { 255, 255, 255 }, { 255, 255, 0 }, // EFFECT_HITMARK_WHITE Init + { 255, 255, 255 }, { 255, 0, 0 }, // EFFECT_HITMARK_WHITE Update + { 255, 200, 100 }, { 200, 150, 0 }, // EFFECT_HITMARK_DUST Init + { 150, 100, 0 }, { 100, 50, 0 }, // EFFECT_HITMARK_DUST Update + { 255, 255, 255 }, { 255, 0, 0 }, // EFFECT_HITMARK_RED Init + { 255, 255, 0 }, { 255, 0, 0 }, // EFFECT_HITMARK_RED Update + { 255, 255, 255 }, { 0, 255, 200 }, // EFFECT_HITMARK_METAL Init + { 255, 255, 255 }, { 150, 0, 255 }, // EFFECT_HITMARK_METAL Update +}; + +static TexturePtr sTextures[] = { + // EFFECT_HITMARK_WHITE + gEffHitmarkWhiteMetal1Tex, + gEffHitmarkWhiteMetal2Tex, + gEffHitmarkWhiteMetal3Tex, + gEffHitmarkWhiteMetal4Tex, + gEffHitmarkWhiteMetal5Tex, + gEffHitmarkWhiteMetal6Tex, + gEffHitmarkWhiteMetal7Tex, + gEffHitmarkWhiteMetal8Tex, + // EFFECT_HITMARK_DUST + gEffHitmarkDust1Tex, + gEffHitmarkDust2Tex, + gEffHitmarkDust3Tex, + gEffHitmarkDust4Tex, + gEffHitmarkDust5Tex, + gEffHitmarkDust6Tex, + gEffHitmarkDust7Tex, + gEffHitmarkDust8Tex, + // EFFECT_HITMARK_RED + gEffHitmarkRed1Tex, + gEffHitmarkRed2Tex, + gEffHitmarkRed3Tex, + gEffHitmarkRed4Tex, + gEffHitmarkRed5Tex, + gEffHitmarkRed6Tex, + gEffHitmarkRed7Tex, + gEffHitmarkRed8Tex, + // EFFECT_HITMARK_METAL + gEffHitmarkWhiteMetal1Tex, + gEffHitmarkWhiteMetal2Tex, + gEffHitmarkWhiteMetal3Tex, + gEffHitmarkWhiteMetal4Tex, + gEffHitmarkWhiteMetal5Tex, + gEffHitmarkWhiteMetal6Tex, + gEffHitmarkWhiteMetal7Tex, + gEffHitmarkWhiteMetal8Tex, +}; -#if 0 const EffectSsInit Effect_Ss_Hitmark_InitVars = { EFFECT_SS_HITMARK, EffectSsHitmark_Init, }; -#endif +u32 EffectSsHitmark_Init(PlayState* play, u32 index, EffectSs* this, void* initParamsx) { + EffectSsHitmarkInitParams* initParams = PARAMS; + s32 colorIndex; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Effect_Ss_Hitmark/EffectSsHitmark_Init.s") + this->pos = initParams->pos; + this->gfx = gEffHitmarkDL; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Effect_Ss_Hitmark/EffectSsHitmark_Draw.s") + if (initParams->type == EFFECT_HITMARK_DUST) { + this->life = 16; + } else { + this->life = 8; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Effect_Ss_Hitmark/EffectSsHitmark_Update.s") + this->draw = EffectSsHitmark_Draw; + this->update = EffectSsHitmark_Update; + + colorIndex = initParams->type * 4; + this->rTexIndex = 0; + this->rType = initParams->type; + this->rPrimColorR = sColors[colorIndex].r; + this->rPrimColorG = sColors[colorIndex].g; + this->rPrimColorB = sColors[colorIndex].b; + this->rEnvColorR = sColors[colorIndex + 1].r; + this->rEnvColorG = sColors[colorIndex + 1].g; + this->rEnvColorB = sColors[colorIndex + 1].b; + this->rScale = initParams->scale; + + return 1; +} + +void EffectSsHitmark_Draw(PlayState* play, u32 index, EffectSs* this) { + GraphicsContext* gfxCtx = play->state.gfxCtx; + MtxF mfTrans; + MtxF mfScale; + MtxF mfResult; + MtxF mfTransBillboard; + Mtx* mtx; + f32 scale; + TexturePtr tex; + s32 pad; + + OPEN_DISPS(gfxCtx); + + SkinMatrix_SetTranslate(&mfTrans, this->pos.x, this->pos.y, this->pos.z); + scale = this->rScale / 100.0f; + SkinMatrix_SetScale(&mfScale, scale, scale, 1.0f); + SkinMatrix_MtxFMtxFMult(&mfTrans, &play->billboardMtxF, &mfTransBillboard); + SkinMatrix_MtxFMtxFMult(&mfTransBillboard, &mfScale, &mfResult); + gSPMatrix(POLY_XLU_DISP++, &gIdentityMtx, G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + + mtx = SkinMatrix_MtxFToNewMtx(gfxCtx, &mfResult); + + if (mtx != NULL) { + gSPMatrix(POLY_XLU_DISP++, mtx, G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + tex = sTextures[(this->rType * 8) + (this->rTexIndex)]; + gSPSegment(POLY_XLU_DISP++, 0x08, Lib_SegmentedToVirtual(tex)); + func_8012C9BC(gfxCtx); + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, this->rPrimColorR, this->rPrimColorG, this->rPrimColorB, 255); + gDPSetEnvColor(POLY_XLU_DISP++, this->rEnvColorR, this->rEnvColorG, this->rEnvColorB, 0); + gSPDisplayList(POLY_XLU_DISP++, this->gfx); + } + CLOSE_DISPS(gfxCtx); +} + +void EffectSsHitmark_Update(PlayState* play, u32 index, EffectSs* this) { + s32 colorIndex; + + if (this->rType == EFFECT_HITMARK_DUST) { + this->rTexIndex = (15 - this->life) / 2; + } else { + this->rTexIndex = 7 - this->life; + } + + if (this->rTexIndex != 0) { + colorIndex = this->rType * 4 + 2; + this->rPrimColorR = func_800B096C(this->rPrimColorR, sColors[colorIndex].r, this->life + 1); + this->rPrimColorG = func_800B096C(this->rPrimColorG, sColors[colorIndex].g, this->life + 1); + this->rPrimColorB = func_800B096C(this->rPrimColorB, sColors[colorIndex].b, this->life + 1); + this->rEnvColorR = func_800B096C(this->rEnvColorR, sColors[colorIndex + 1].r, this->life + 1); + this->rEnvColorG = func_800B096C(this->rEnvColorG, sColors[colorIndex + 1].g, this->life + 1); + this->rEnvColorB = func_800B096C(this->rEnvColorB, sColors[colorIndex + 1].b, this->life + 1); + } +} diff --git a/src/overlays/effects/ovl_Effect_Ss_Hitmark/z_eff_ss_hitmark.h b/src/overlays/effects/ovl_Effect_Ss_Hitmark/z_eff_ss_hitmark.h index fe6c54eb0..6e38ab8d2 100644 --- a/src/overlays/effects/ovl_Effect_Ss_Hitmark/z_eff_ss_hitmark.h +++ b/src/overlays/effects/ovl_Effect_Ss_Hitmark/z_eff_ss_hitmark.h @@ -14,7 +14,7 @@ typedef struct { /* 0x00 */ s32 type; /* 0x04 */ s16 scale; /* 0x08 */ Vec3f pos; -} EffectSsHitMarkInitParams; // size = 0x14 +} EffectSsHitmarkInitParams; // size = 0x14 extern const EffectSsInit Effect_Ss_Hitmark_InitVars; diff --git a/src/overlays/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..ebc28b469 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); -void EffectSsIcePiece_Update(GlobalContext* globalCtx, u32 index, EffectSs* this); -void EffectSsIcePiece_Draw(GlobalContext* globalCtx, u32 index, EffectSs* this); +u32 EffectSsIcePiece_Init(PlayState* play, u32 index, EffectSs* this, void* initParamsx); +void EffectSsIcePiece_Update(PlayState* play, u32 index, EffectSs* this); +void EffectSsIcePiece_Draw(PlayState* play, u32 index, EffectSs* this); -#if 0 const EffectSsInit Effect_Ss_Ice_Piece_InitVars = { EFFECT_SS_ICE_PIECE, EffectSsIcePiece_Init, }; -#endif +u32 EffectSsIcePiece_Init(PlayState* play, 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(PlayState* play, u32 index, EffectSs* this) { + GraphicsContext* gfxCtx = play->state.gfxCtx; + s32 pad; + f32 scale = this->rScale * 0.01f; + u32 frames = play->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(play->state.gfxCtx); + gDPSetEnvColor(POLY_XLU_DISP++, 0, 50, 100, (u8)(s32)alpha); + func_800BCC68(&this->pos, play); + gSPSegment( + POLY_XLU_DISP++, 0x08, + Gfx_TwoTexScroll(play->state.gfxCtx, 0, 0, frames % 256, 0x20, 0x10, 1, 0, (2 * frames) % 256, 0x40, 0x20)); + gSPDisplayList(POLY_XLU_DISP++, gEffIceFragment1DL); + + CLOSE_DISPS(gfxCtx); +} + +void EffectSsIcePiece_Update(PlayState* play, 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..41c9c818a 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); -void EffectSsIceSmoke_Update(GlobalContext* globalCtx, u32 index, EffectSs* this); -void EffectSsIceSmoke_Draw(GlobalContext* globalCtx, u32 index, EffectSs* this); +u32 EffectSsIceSmoke_Init(PlayState* play, u32 index, EffectSs* this, void* initParamsx); +void EffectSsIceSmoke_Update(PlayState* play, u32 index, EffectSs* this); +void EffectSsIceSmoke_Draw(PlayState* play, u32 index, EffectSs* this); -#if 0 const EffectSsInit Effect_Ss_Ice_Smoke_InitVars = { EFFECT_SS_ICE_SMOKE, EffectSsIceSmoke_Init, }; -#endif +u32 EffectSsIceSmoke_Init(PlayState* play, 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(PlayState* play, u32 index, EffectSs* this) { + s32 pad; + Mtx* mtx; + f32 scale; + + OPEN_DISPS(play->state.gfxCtx); + + func_8012C2DC(play->state.gfxCtx); + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 195, 235, 235, this->rAlpha); + gSPSegment(POLY_XLU_DISP++, 0x08, + Gfx_TwoTexScroll(play->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(&play->billboardMtxF); + scale = this->rScale * 0.0001f; + Matrix_Scale(scale, scale, 1.0f, MTXMODE_APPLY); + mtx = Matrix_NewMtx(play->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(play->state.gfxCtx); +} + +void EffectSsIceSmoke_Update(PlayState* play, 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..4aa209639 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); -void EffectSsKFire_Update(GlobalContext* globalCtx, u32 index, EffectSs* this); -void EffectSsKFire_Draw(GlobalContext* globalCtx, u32 index, EffectSs* this); +u32 EffectSsKFire_Init(PlayState* play, u32 index, EffectSs* this, void* initParamsx); +void EffectSsKFire_Update(PlayState* play, u32 index, EffectSs* this); +void EffectSsKFire_Draw(PlayState* play, u32 index, EffectSs* this); -#if 0 const EffectSsInit Effect_Ss_K_Fire_InitVars = { EFFECT_SS_K_FIRE, EffectSsKFire_Init, }; -#endif +u32 EffectSsKFire_Init(PlayState* play, 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(PlayState* play, u32 index, EffectSs* this) { + s32 pad; + GraphicsContext* gfxCtx = play->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(play->state.gfxCtx); + gSPSegment(POLY_XLU_DISP++, 0x08, + Gfx_TwoTexScroll(play->state.gfxCtx, 0, 0, 0, 0x20, 0x40, 1, 0, play->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(&play->billboardMtxF); + + if ((index % 2) != 0) { + Matrix_RotateYF(M_PI, MTXMODE_APPLY); + } + + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_XLU_DISP++, gEffFire1DL); + + CLOSE_DISPS(gfxCtx); +} + +void EffectSsKFire_Update(PlayState* play, 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 d2ea02f7c..a84b450c1 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 @@ -22,11 +22,11 @@ #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); +u32 EffectSsKakera_Init(PlayState* play, u32 index, EffectSs* this, void* initParamsx); +void EffectSsKakera_Update(PlayState* play, u32 index, EffectSs* this); +void EffectSsKakera_Draw(PlayState* play, u32 index, EffectSs* this); -void EffectSsKakera_CheckForObject(EffectSs* this, GlobalContext* globalCtx); +void EffectSsKakera_CheckForObject(EffectSs* this, PlayState* play); const EffectSsInit Effect_Ss_Kakera_InitVars = { EFFECT_SS_KAKERA, @@ -41,7 +41,7 @@ KakeraColorStruct D_8097EAD8[] = { 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) { +u32 EffectSsKakera_Init(PlayState* play, u32 index, EffectSs* this, void* initParamsx) { EffectSsKakeraInitParams* initParams = PARAMS; this->pos = initParams->pos; @@ -58,7 +58,7 @@ u32 EffectSsKakera_Init(GlobalContext* globalCtx, u32 index, EffectSs* this, voi break; default: this->rObjId = initParams->objId; - EffectSsKakera_CheckForObject(this, globalCtx); + EffectSsKakera_CheckForObject(this, play); break; } } else { @@ -85,8 +85,8 @@ f32 func_8097DE30(f32 center, f32 range) { return (2.0f * (Rand_ZeroOne() * range) - range) + center; } -void EffectSsKakera_Draw(GlobalContext* globalCtx, u32 index, EffectSs* this) { - GraphicsContext* gfxCtx = globalCtx->state.gfxCtx; +void EffectSsKakera_Draw(PlayState* play, u32 index, EffectSs* this) { + GraphicsContext* gfxCtx = play->state.gfxCtx; s16 pad; f32 scale = this->rScale / 256.0f; s32 colorIndex = this->rColorIndex; @@ -94,20 +94,20 @@ void EffectSsKakera_Draw(GlobalContext* globalCtx, u32 index, EffectSs* this) { OPEN_DISPS(gfxCtx); if (this->rObjId != KAKERA_OBJECT_DEFAULT) { if ((((this->rReg4 >> 7) & 1) << 7) == 0x80) { - gSPSegment(POLY_XLU_DISP++, 0x06, globalCtx->objectCtx.status[this->rObjBankIndex].segment); + gSPSegment(POLY_XLU_DISP++, 0x06, play->objectCtx.status[this->rObjBankIndex].segment); } else { - gSPSegment(POLY_OPA_DISP++, 0x06, globalCtx->objectCtx.status[this->rObjBankIndex].segment); + gSPSegment(POLY_OPA_DISP++, 0x06, play->objectCtx.status[this->rObjBankIndex].segment); } } - Matrix_InsertTranslation(this->pos.x, this->pos.y, this->pos.z, MTXMODE_NEW); - Matrix_RotateY(this->rYaw, MTXMODE_APPLY); - Matrix_InsertXRotation_s(this->rPitch, 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->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); + func_8012C2DC(play->state.gfxCtx); if (colorIndex >= 0) { gDPSetPrimColor(POLY_XLU_DISP++, 0, D_8097EAD8[colorIndex].lod, D_8097EAD8[colorIndex].color.r, D_8097EAD8[colorIndex].color.g, D_8097EAD8[colorIndex].color.b, 255); @@ -115,7 +115,7 @@ void EffectSsKakera_Draw(GlobalContext* globalCtx, u32 index, EffectSs* this) { gSPDisplayList(POLY_XLU_DISP++, this->gfx); } else { gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - func_8012C28C(globalCtx->state.gfxCtx); + func_8012C28C(play->state.gfxCtx); if (colorIndex >= 0) { gDPSetPrimColor(POLY_OPA_DISP++, 0, D_8097EAD8[colorIndex].lod, D_8097EAD8[colorIndex].color.r, D_8097EAD8[colorIndex].color.g, D_8097EAD8[colorIndex].color.b, 255); @@ -125,9 +125,9 @@ void EffectSsKakera_Draw(GlobalContext* globalCtx, u32 index, EffectSs* this) { CLOSE_DISPS(gfxCtx); } -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))) { +void EffectSsKakera_CheckForObject(EffectSs* this, PlayState* play) { + this->rObjBankIndex = Object_GetIndex(&play->objectCtx, this->rObjId); + if ((this->rObjBankIndex < 0) || (!Object_IsLoaded(&play->objectCtx, this->rObjBankIndex))) { this->life = 0; this->draw = NULL; } @@ -303,9 +303,9 @@ s32 func_8097E698(EffectSs* this) { } } -void func_8097E7E0(EffectSs* this, GlobalContext* globalCtx) { +void func_8097E7E0(EffectSs* this, PlayState* play) { static f32 D_8097EB64[] = { 10.0f, 20.0f, 40.0f }; - Player* player = GET_PLAYER(globalCtx); + Player* player = GET_PLAYER(play); if (this->rReg8 == 0) { if ((((this->rReg4 >> 4) & 1) << 4) == (1 << 4)) { @@ -330,7 +330,7 @@ void func_8097E7E0(EffectSs* this, GlobalContext* globalCtx) { break; case 1: if ((this->velocity.y < 0.0f) && - (BgCheck_SphVsFirstPoly(&globalCtx->colCtx, &this->pos, D_8097EB64[(this->rReg4 >> 2) & 3]))) { + (BgCheck_SphVsFirstPoly(&play->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); @@ -340,7 +340,7 @@ void func_8097E7E0(EffectSs* this, GlobalContext* globalCtx) { } break; case 2: - if (BgCheck_SphVsFirstPoly(&globalCtx->colCtx, &this->pos, D_8097EB64[(this->rReg4 >> 2) & 3])) { + if (BgCheck_SphVsFirstPoly(&play->colCtx, &this->pos, D_8097EB64[(this->rReg4 >> 2) & 3])) { this->rReg8 = 0; } break; @@ -348,7 +348,7 @@ void func_8097E7E0(EffectSs* this, GlobalContext* globalCtx) { } } -void EffectSsKakera_Update(GlobalContext* globalCtx, u32 index, EffectSs* this) { +void EffectSsKakera_Update(PlayState* play, u32 index, EffectSs* this) { switch (((this->rReg4 >> 5) & 3) << 5) { case 0x20: this->rPitch += 0x47B; @@ -367,8 +367,8 @@ void EffectSsKakera_Update(GlobalContext* globalCtx, u32 index, EffectSs* this) if (!func_8097E698(this)) { this->life = 0; } - func_8097E7E0(this, globalCtx); + func_8097E7E0(this, play); if (this->rObjId != KAKERA_OBJECT_DEFAULT) { - EffectSsKakera_CheckForObject(this, globalCtx); + EffectSsKakera_CheckForObject(this, play); } } 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..97899ae68 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); -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); +u32 EffectSsKirakira_Init(PlayState* play, u32 index, EffectSs* this, void* initParamsx); +void func_80977DB4(PlayState* play, u32 index, EffectSs* this); +void func_80977E6C(PlayState* play, u32 index, EffectSs* this); +void func_80977F28(PlayState* play, u32 index, EffectSs* this); +void EffectSsKirakira_Draw(PlayState* play, u32 index, EffectSs* this); -#if 0 const EffectSsInit Effect_Ss_Kirakira_InitVars = { EFFECT_SS_KIRAKIRA, EffectSsKirakira_Init, }; -#endif +u32 EffectSsKirakira_Init(PlayState* play, 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(PlayState* play, 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 = play->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, &play->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(PlayState* play, 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(PlayState* play, 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(PlayState* play, 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..1f70b8064 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); -void EffectSsLightning_Update(GlobalContext* globalCtx, u32 index, EffectSs* this); -void EffectSsLightning_Draw(GlobalContext* globalCtx, u32 index, EffectSs* this); +u32 EffectSsLightning_Init(PlayState* play, u32 index, EffectSs* this, void* initParamsx); +void EffectSsLightning_Update(PlayState* play, u32 index, EffectSs* this); +void EffectSsLightning_Draw(PlayState* play, u32 index, EffectSs* this); + +TexturePtr sLightningTextures[] = { + gEffLightning1Tex, gEffLightning2Tex, gEffLightning3Tex, gEffLightning4Tex, + gEffLightning5Tex, gEffLightning6Tex, gEffLightning7Tex, gEffLightning8Tex, +}; -#if 0 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(PlayState* play, 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(PlayState* play, 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(play, &newLightning); +} + +void EffectSsLightning_Draw(PlayState* play, u32 index, EffectSs* this) { + GraphicsContext* gfxCtx = play->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, &play->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(PlayState* play, 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(play))) * scale); + pos.z = this->pos.z + (Math_SinS(Camera_GetInputDirYaw(GET_ACTIVE_CAM(play))) * scale); + + EffectSsLightning_NewLightning(play, &pos, yaw, this); + + if (Rand_ZeroOne() < 0.1f) { + EffectSsLightning_NewLightning(play, &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..d1a22473f 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); -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); +u32 EffectSsSbn_Init(PlayState* play, u32 index, EffectSs* this, void* initParamsx); +void EffectSsSbn_Update(PlayState* play, u32 index, EffectSs* this); +void EffectSsSbn_DrawSliding(PlayState* play, u32 index, EffectSs* this); +void EffectSsSbn_Draw(PlayState* play, u32 index, EffectSs* this); -#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(PlayState* play, 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(PlayState* play, u32 index, EffectSs* this) { + GraphicsContext* gfxCtx = play->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) && ((play->state.frames % 2) == 0)) { + this->rScrollStep--; + } + this->rScroll += this->rScrollStep; + } + gSPSegment(POLY_XLU_DISP++, 0x09, + Gfx_TwoTexScroll(play->state.gfxCtx, 0, 0, 0, 0x20, 0x40, 1, 0, this->rScroll, 0x20, 0x20)); + gSPDisplayList(POLY_XLU_DISP++, gEffPoppedDekuBubbleSlidingDL); + + CLOSE_DISPS(gfxCtx); +} + +void EffectSsSbn_Draw(PlayState* play, u32 index, EffectSs* this) { + GraphicsContext* gfxCtx = play->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(PlayState* play, 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 ba2355d23..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,11 +4,10 @@ #include "global.h" typedef struct { - /* 0x00 */ Vec3f unk_00; - /* 0x0C */ CollisionPoly* unk_0C; - /* 0x10 */ f32 unk_10; - /* 0x14 */ char unk_14[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 d4356f90c..4dbdc65a2 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 @@ -21,16 +21,16 @@ #define PARAMS ((EffectSsSibukiInitParams*)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); +u32 EffectSsSibuki_Init(PlayState* play, u32 index, EffectSs* this, void* initParamsx); +void EffectSsSibuki_Update(PlayState* play, u32 index, EffectSs* this); +void EffectSsSibuki_Draw(PlayState* play, u32 index, EffectSs* this); const EffectSsInit Effect_Ss_Sibuki_InitVars = { EFFECT_SS_SIBUKI, EffectSsSibuki_Init, }; -u32 EffectSsSibuki_Init(GlobalContext* globalCtx, u32 index, EffectSs* this, void* initParamsx) { +u32 EffectSsSibuki_Init(PlayState* play, u32 index, EffectSs* this, void* initParamsx) { EffectSsSibukiInitParams* initParams = PARAMS; this->pos = initParams->pos; @@ -61,13 +61,13 @@ u32 EffectSsSibuki_Init(GlobalContext* globalCtx, u32 index, EffectSs* this, voi return 1; } -void EffectSsSibuki_Draw(GlobalContext* globalCtx, u32 index, EffectSs* this) { - GraphicsContext* gfxCtx = globalCtx->state.gfxCtx; +void EffectSsSibuki_Draw(PlayState* play, u32 index, EffectSs* this) { + GraphicsContext* gfxCtx = play->state.gfxCtx; f32 scale = this->rScale / 100.0f; OPEN_DISPS(gfxCtx); - Matrix_InsertTranslation(this->pos.x, this->pos.y, this->pos.z, MTXMODE_NEW); + Matrix_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); @@ -79,8 +79,8 @@ void EffectSsSibuki_Draw(GlobalContext* globalCtx, u32 index, EffectSs* this) { CLOSE_DISPS(gfxCtx); } -void EffectSsSibuki_Update(GlobalContext* globalCtx, u32 index, EffectSs* this) { - Player* player = GET_PLAYER(globalCtx); +void EffectSsSibuki_Update(PlayState* play, u32 index, EffectSs* this) { + Player* player = GET_PLAYER(play); s32 pad[2]; f32 xzVelScale; @@ -92,7 +92,7 @@ void EffectSsSibuki_Update(GlobalContext* globalCtx, u32 index, EffectSs* this) this->rMoveDelay--; if (this->rMoveDelay == 0) { - s16 yaw = Camera_GetInputDirYaw(Play_GetCamera(globalCtx, CAM_ID_MAIN)); + s16 yaw = Camera_GetInputDirYaw(Play_GetCamera(play, CAM_ID_MAIN)); xzVelScale = ((200.0f + KREG(20)) * 0.01f) + ((0.1f * Rand_ZeroOne()) * (KREG(23) + 20.0f)); diff --git a/src/overlays/effects/ovl_Effect_Ss_Solder_Srch_Ball/z_eff_ss_solder_srch_ball.c b/src/overlays/effects/ovl_Effect_Ss_Solder_Srch_Ball/z_eff_ss_solder_srch_ball.c index c96684f0d..04afcba3f 100644 --- a/src/overlays/effects/ovl_Effect_Ss_Solder_Srch_Ball/z_eff_ss_solder_srch_ball.c +++ b/src/overlays/effects/ovl_Effect_Ss_Solder_Srch_Ball/z_eff_ss_solder_srch_ball.c @@ -8,9 +8,9 @@ #define PARAMS ((EffectSsSolderSrchBallInitParams*)initParamsx) -s32 EffectSsSolderSrchBall_Init(GlobalContext* globalCtx, u32 index, EffectSs* this, void* initParamsx); -void EffectSsSolderSrchBall_Update(GlobalContext* globalCtx, u32 index, EffectSs* this); -void EffectSsSolderSrchBall_Draw(GlobalContext* globalCtx, u32 index, EffectSs* this); +s32 EffectSsSolderSrchBall_Init(PlayState* play, u32 index, EffectSs* this, void* initParamsx); +void EffectSsSolderSrchBall_Update(PlayState* play, u32 index, EffectSs* this); +void EffectSsSolderSrchBall_Draw(PlayState* play, u32 index, EffectSs* this); #if 0 const EffectSsInit Effect_Ss_Solder_Srch_Ball_InitVars = { 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 d26135729..5d546a78f 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 @@ -12,20 +12,20 @@ #define PARAMS ((EffectSsStickInitParams*)initParamsx) -u32 EffectSsStick_Init(GlobalContext* globalCtx, u32 index, EffectSs* this, void* initParamsx); -void EffectSsStick_Update(GlobalContext* globalCtx, u32 index, EffectSs* this); -void EffectSsStick_Draw(GlobalContext* globalCtx, u32 index, EffectSs* this); +u32 EffectSsStick_Init(PlayState* play, u32 index, EffectSs* this, void* initParamsx); +void EffectSsStick_Update(PlayState* play, u32 index, EffectSs* this); +void EffectSsStick_Draw(PlayState* play, u32 index, EffectSs* this); const EffectSsInit Effect_Ss_Stick_InitVars = { EFFECT_SS_STICK, EffectSsStick_Init, }; -u32 EffectSsStick_Init(GlobalContext* globalCtx, u32 index, EffectSs* this, void* initParamsx) { +u32 EffectSsStick_Init(PlayState* play, u32 index, EffectSs* this, void* initParamsx) { EffectSsStickInitParams* initParams = PARAMS; Vec3f pos; - this->rObjBankIndex = Object_GetIndex(&globalCtx->objectCtx, GAMEPLAY_KEEP); + this->rObjBankIndex = Object_GetIndex(&play->objectCtx, GAMEPLAY_KEEP); pos = initParams->pos; this->pos = pos; this->vec = pos; @@ -40,23 +40,23 @@ u32 EffectSsStick_Init(GlobalContext* globalCtx, u32 index, EffectSs* this, void return 1; } -void EffectSsStick_Draw(GlobalContext* globalCtx, u32 index, EffectSs* this) { +void EffectSsStick_Draw(PlayState* play, u32 index, EffectSs* this) { s32 pad; - GraphicsContext* gfxCtx = globalCtx->state.gfxCtx; + GraphicsContext* gfxCtx = play->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->rYaw, 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->rObjBankIndex].segment); + gSPSegment(POLY_OPA_DISP++, 0x06, play->objectCtx.status[this->rObjBankIndex].segment); gSPSegment(POLY_OPA_DISP++, 0x0C, D_801C0850); gSPDisplayList(POLY_OPA_DISP++, gDekuStickDL); CLOSE_DISPS(gfxCtx); } -void EffectSsStick_Update(GlobalContext* globalCtx, u32 index, EffectSs* this) { +void EffectSsStick_Update(PlayState* play, u32 index, EffectSs* this) { } 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..ad61166d3 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); -void EffectSsStone1_Update(GlobalContext* globalCtx, u32 index, EffectSs* this); -void EffectSsStone1_Draw(GlobalContext* globalCtx, u32 index, EffectSs* this); +#define rReg0 regs[0] + +u32 EffectSsStone1_Init(PlayState* play, u32 index, EffectSs* this, void* initParamsx); +void EffectSsStone1_Update(PlayState* play, u32 index, EffectSs* this); +void EffectSsStone1_Draw(PlayState* play, 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(PlayState* play, 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(PlayState* play, u32 index, EffectSs* this) { + GraphicsContext* gfxCtx = play->state.gfxCtx; + EffStoneDrawInfo* drawParams = &sDrawInfo[this->life]; + Vec3f mfVec; + f32 mfW; + f32 scale; + + OPEN_DISPS(gfxCtx); + + SkinMatrix_Vec3fMtxFMultXYZW(&play->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(PlayState* play, 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 0ac471162..eac0b8f59 100644 --- a/src/overlays/gamestates/ovl_daytelop/z_daytelop.c +++ b/src/overlays/gamestates/ovl_daytelop/z_daytelop.c @@ -82,7 +82,7 @@ void Daytelop_Update(DaytelopContext* this, GameState* gameState) { state->running = 0; } - SET_NEXT_GAMESTATE(&this->state, Play_Init, GlobalContext); + SET_NEXT_GAMESTATE(&this->state, Play_Init, PlayState); gSaveContext.save.time = CLOCK_TIME(6, 0); D_801BDBC8 = 0xFE; } else if (this->transitionCountdown == 90) { @@ -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; diff --git a/src/overlays/gamestates/ovl_file_choose/z_file_choose.h b/src/overlays/gamestates/ovl_file_choose/z_file_choose.h index 78c4a9a62..4184ca576 100644 --- a/src/overlays/gamestates/ovl_file_choose/z_file_choose.h +++ b/src/overlays/gamestates/ovl_file_choose/z_file_choose.h @@ -17,7 +17,6 @@ typedef struct FileChooseContext { /* 0x00248 */ SkyboxContext skyboxCtx; /* 0x00470 */ MessageContext msgCtx; /* 0x12550 */ Font font; - /* 0x242DC */ UNK_TYPE1 unk_242DC[4]; /* 0x242E0 */ EnvironmentContext envCtx; /* 0x243E0 */ Vtx* unk_243E0; /* 0x243E4 */ Vtx* unk_243E4; @@ -113,13 +112,4 @@ typedef struct FileChooseContext { /* 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_file_choose/z_file_choose_80807940.c b/src/overlays/gamestates/ovl_file_choose/z_file_choose_80807940.c index ea1ed9eed..2e0e9a0d4 100644 --- a/src/overlays/gamestates/ovl_file_choose/z_file_choose_80807940.c +++ b/src/overlays/gamestates/ovl_file_choose/z_file_choose_80807940.c @@ -5,6 +5,7 @@ */ #include "z_file_choose.h" +#include "z64rumble.h" extern UNK_TYPE D_01002800; extern UNK_TYPE D_01007980; diff --git a/src/overlays/gamestates/ovl_file_choose/z_file_choose_NES.c b/src/overlays/gamestates/ovl_file_choose/z_file_choose_NES.c index ad9ca6ccf..62ea8ef7e 100644 --- a/src/overlays/gamestates/ovl_file_choose/z_file_choose_NES.c +++ b/src/overlays/gamestates/ovl_file_choose/z_file_choose_NES.c @@ -5,6 +5,7 @@ */ #include "z_file_choose.h" +#include "z64rumble.h" extern UNK_TYPE D_01002800; extern UNK_TYPE D_01007980; diff --git a/src/overlays/gamestates/ovl_file_choose/z_file_nameset_NES.c b/src/overlays/gamestates/ovl_file_choose/z_file_nameset_NES.c index 6612d9728..c6e3983d8 100644 --- a/src/overlays/gamestates/ovl_file_choose/z_file_nameset_NES.c +++ b/src/overlays/gamestates/ovl_file_choose/z_file_nameset_NES.c @@ -5,6 +5,7 @@ */ #include "z_file_choose.h" +#include "z64rumble.h" extern UNK_TYPE D_01002800; extern UNK_TYPE D_01007980; diff --git a/src/overlays/gamestates/ovl_opening/z_opening.c b/src/overlays/gamestates/ovl_opening/z_opening.c index f0dd8190e..bc5e46940 100644 --- a/src/overlays/gamestates/ovl_opening/z_opening.c +++ b/src/overlays/gamestates/ovl_opening/z_opening.c @@ -7,7 +7,7 @@ #include "z_opening.h" void Opening_SetupForTitleCutscene(OpeningContext* this) { - static s32 openingEntrances[] = { 0x1C00, 0x1C10 }; + static s32 openingEntrances[] = { ENTRANCE(CUTSCENE, 0), ENTRANCE(CUTSCENE, 1) }; static s32 openingCutscenes[] = { 0xFFFA, 0xFFFA }; gSaveContext.eventInf[1] &= (u8)~0x80; @@ -15,7 +15,7 @@ void Opening_SetupForTitleCutscene(OpeningContext* this) { Sram_InitNewSave(); - gSaveContext.save.entranceIndex = openingEntrances[D_801BB12C]; + gSaveContext.save.entrance = openingEntrances[D_801BB12C]; gSaveContext.nextCutsceneIndex = gSaveContext.save.cutscene = openingCutscenes[D_801BB12C]; gSaveContext.sceneSetupIndex = 0; @@ -26,7 +26,7 @@ void Opening_SetupForTitleCutscene(OpeningContext* this) { GameState* thisx = &this->gameState; thisx->running = false; } - SET_NEXT_GAMESTATE(&this->gameState, Play_Init, GlobalContext); + SET_NEXT_GAMESTATE(&this->gameState, Play_Init, PlayState); gSaveContext.save.playerForm = PLAYER_FORM_HUMAN; } @@ -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[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; + gSaveContext.respawn[RESPAWN_MODE_GORON].entrance = 0xFF; + gSaveContext.respawn[RESPAWN_MODE_ZORA].entrance = 0xFF; + gSaveContext.respawn[RESPAWN_MODE_DEKU].entrance = 0xFF; + gSaveContext.respawn[RESPAWN_MODE_HUMAN].entrance = 0xFF; } diff --git a/src/overlays/gamestates/ovl_select/z_select.c b/src/overlays/gamestates/ovl_select/z_select.c index 53dbc266f..0147cca64 100644 --- a/src/overlays/gamestates/ovl_select/z_select.c +++ b/src/overlays/gamestates/ovl_select/z_select.c @@ -1,14 +1,14 @@ /* * File: z_select.c * Overlay: ovl_select - * Description: Debug map select + * Description: Debug Map Select Menu */ #include "z_select.h" #include "libc/alloca.h" #include "overlays/gamestates/ovl_title/z_title.h" -void Select_LoadTitle(SelectContext* this) { +void MapSelect_LoadTitle(MapSelectState* this) { { GameState* gameState = &this->state; gameState->running = false; @@ -17,347 +17,496 @@ void Select_LoadTitle(SelectContext* this) { SET_NEXT_GAMESTATE(&this->state, Title_Init, TitleContext); } -void Select_LoadGame(SelectContext* this, u32 entranceIndex, s32 opt) { +void MapSelect_LoadGame(MapSelectState* this, u32 entrance, s32 spawn) { if (gSaveContext.fileNum == 0xFF) { Sram_InitDebugSave(); } - gSaveContext.buttonStatus[0] = BTN_ENABLED; - gSaveContext.buttonStatus[1] = BTN_ENABLED; - gSaveContext.buttonStatus[2] = BTN_ENABLED; - gSaveContext.buttonStatus[3] = BTN_ENABLED; - gSaveContext.buttonStatus[4] = BTN_ENABLED; + gSaveContext.buttonStatus[EQUIP_SLOT_B] = BTN_ENABLED; + gSaveContext.buttonStatus[EQUIP_SLOT_C_LEFT] = BTN_ENABLED; + gSaveContext.buttonStatus[EQUIP_SLOT_C_DOWN] = BTN_ENABLED; + gSaveContext.buttonStatus[EQUIP_SLOT_C_RIGHT] = BTN_ENABLED; + gSaveContext.buttonStatus[EQUIP_SLOT_A] = BTN_ENABLED; gSaveContext.unk_3F1E = 0; gSaveContext.unk_3F20 = 0; gSaveContext.unk_3F22 = 0; gSaveContext.unk_3F24 = 0; Audio_QueueSeqCmd(NA_BGM_STOP); - gSaveContext.save.entranceIndex = entranceIndex; + gSaveContext.save.entrance = entrance; - if (opt != 0) { - gSaveContext.save.entranceIndex = - Entrance_CreateIndex((s32)gSaveContext.save.entranceIndex >> 9, opt, gSaveContext.save.entranceIndex & 0xF); + if (spawn != 0) { + gSaveContext.save.entrance = + Entrance_Create((s32)gSaveContext.save.entrance >> 9, spawn, gSaveContext.save.entrance & 0xF); } - if (gSaveContext.save.entranceIndex == 0xC000) { + if (gSaveContext.save.entrance == ENTRANCE(CLOCK_TOWER_INTERIOR, 0)) { gSaveContext.save.day = 0; gSaveContext.save.time = CLOCK_TIME(6, 0) - 1; } - gSaveContext.respawn[RESTART_MODE_DOWN].entranceIndex = 0xFFFF; + gSaveContext.respawn[RESPAWN_MODE_DOWN].entrance = 0xFFFF; gSaveContext.seqIndex = (u8)NA_BGM_DISABLED; gSaveContext.nightSeqIndex = 0xFF; gSaveContext.showTitleCard = true; gSaveContext.respawnFlag = 0; - 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; + gSaveContext.respawn[RESPAWN_MODE_GORON].entrance = 0xFF; + gSaveContext.respawn[RESPAWN_MODE_ZORA].entrance = 0xFF; + gSaveContext.respawn[RESPAWN_MODE_DEKU].entrance = 0xFF; + gSaveContext.respawn[RESPAWN_MODE_HUMAN].entrance = 0xFF; + gWeatherMode = 0; do { GameState* gameState = &this->state; gameState->running = false; } while (0); - SET_NEXT_GAMESTATE(&this->state, Play_Init, GlobalContext); + SET_NEXT_GAMESTATE(&this->state, Play_Init, PlayState); } -// "Translation" ("Actual name") +// "Translation" (Actual name) static SceneSelectEntry sScenes[] = { - // " 0: OP Woods for Cutscene Use" (" 0: Forest Opening Scene") - { " 0:OP\x8Cデモ\x8Dヨウ シンリン", Select_LoadGame, 0x1C00 }, - // " 0-0: Lost Woods" (" 0-0: Lost Woods") - { " 0-0:\x8Dマヨイ ノ モリ", Select_LoadGame, 0xC400 }, - // " 1: Town Outskirts" (" 1: Termina Field") - { " 1:\x8Cタウン \x8Dコウガイ", Select_LoadGame, 0x5400 }, - // " 1-0: Astral Observatory" (" 1-0: Astral Observatory") - { " 1-0:\x8Dテンモンカンソクジョ", Select_LoadGame, 0x4C00 }, - // " 1 - 1: Astral Observatory Telescope" (" 1 - 1: Astral Observatory - Telescope") - { " 1-1:\x8Dテンモンカンソクジョ デ ボウエンキョウ", Select_LoadGame, 0x54A0 }, - // " 1 - 2: Ikana Graveyard" (" 1 - 2: Ikana Canyon Graveyard") - { " 1-2:\x8Cイカーナ \x8Dノ ハカバ", Select_LoadGame, 0x8000 }, - // " 2: Romani Ranch" (" 2: Romani Ranch") - { " 2:\x8Cロマニー \x8Dボクジョウ", Select_LoadGame, 0x6400 }, - // " 3: Milk Road" (" 3: Milk Road") - { " 3:\x8Cミルクロード", Select_LoadGame, 0x3E00 }, - // " 4: Main Building" (" 4: Ranch House") - { " 4:\x8Dオモヤ", Select_LoadGame, 0x610 }, - // " 5: Cow Shed" (" 5: Cow Shed") - { " 5:\x8Dウシゴヤ", Select_LoadGame, 0x600 }, - // " 6: Cucco Shed" (" 6: Cucco Shed") - { " 6:\x8Cコッコ \x8Dゴヤ", Select_LoadGame, 0x7E00 }, - // " 7: Dog Racing Area" (" 7: Doggy Racetrack") - { " 7:\x8Cドッグレース\x8Dジョウ", Select_LoadGame, 0x7C00 }, - // " 8: Gorman Track" (" 8: Gorman Track") - { " 8:\x8Cゴーマン トラック", Select_LoadGame, 0xCE00 }, - // " 10: Mountain Village -Winter-" (" 10: Mountain Village - Winter") - { " 10:\x8Dヤマザト -フユ-", Select_LoadGame, 0x9A00 }, - // " 10 - 0: Mountain Village -Spring-" (" 10 - 0: Mountain Village - Spring") - { " 10-0:\x8Dヤマザト -ハル-", Select_LoadGame, 0xAE00 }, - // " 10 - 1: Mountain Village Blacksmith" (" 10 - 1: Mountain Smithy") - { " 10-1:\x8Dヤマザト ノ カジヤ", Select_LoadGame, 0x5200 }, - // " 11: Goron Village -Winter-" (" 11: Goron Village - Winter") - { " 11:\x8Cゴロン\x8D ノ サト -フユ-", Select_LoadGame, 0x9400 }, - // " 11-0: Goron Village -Spring-" (" 11-0: Goron Village - Spring") - { " 11-0:\x8Cゴロン\x8D ノ サト -ハル-", Select_LoadGame, 0x8A00 }, - // " 11-1: Goron Shrine" (" 11-1: Goron Shrine") - { " 11-1:\x8Cゴロン\x8D ノ ホコラ", Select_LoadGame, 0x5E00 }, - // " 11-2: Lone Peak Shrine" (" 11-2: Lone Peak Shrine") - { " 11-2:\x8Dハナレヤマ ノ ホコラ", Select_LoadGame, 0x1500 }, - // " 11-3: Goron Shop" (" 11-3: Goron Shop") - { " 11-3:\x8Cゴロン \x8Dノ ミセ", Select_LoadGame, 0x7400 }, - // " 12: Snowhead" (" 12: Snowhead") - { " 12:\x8Cスノーヘッド", Select_LoadGame, 0xB200 }, - // " 13: Blizzard Path" (" 13: Path to Goron Village - Part 1") - { " 13:\x8Dフブキ ノ ミチ", Select_LoadGame, 0x3200 }, - // " 14: Snowball Path" (" 14: Path to Goron Village - Part 2") - { " 14:\x8Dユキダマ ノ ミチ", Select_LoadGame, 0xB000 }, - // " 15: Goron Racetrack" (" 15: Goron Racetrack") - { " 15:\x8Cゴロンレース \x8Dジョウ", Select_LoadGame, 0xD000 }, - // " 16: Goron Grave" (" 16: Darmani's Grave") - { " 16:\x8Cゴロン \x8Dノ ハカ", Select_LoadGame, 0x9600 }, - // " 17: Snow Field Battle -Winter-" (" 17: Path to Goron Village - Winter") - { " 17:\x8Dセツゲン \x8Cバトル \x8D-フユ-", Select_LoadGame, 0xB400 }, - // " 17-0: Snow Field Battle -Spring-" (" 17-0: Path to Goron Village - Spring") - { " 17-0:\x8Dセツゲン \x8Cバトル \x8D-ハル-", Select_LoadGame, 0xB600 }, - // " 20: Swampland" (" 20: Southern Swamp") - { " 20:\x8Dヌマチ", Select_LoadGame, 0x8400 }, - // " 20-0: Swampland - Afterwards" (" 20-0: Southern Swamp - After Odolwa") - { " 20-0:\x8Dヌマチ ソノゴ", Select_LoadGame, 0xC00 }, - // " 20-1: Swamp Tourist Information" (" 20-1: Tourist Information") - { " 20-1:\x8Dヌマ ノ カンコウアンナイ", Select_LoadGame, 0xA800 }, - // " 20-2: Magic Hags' Potion Shop" (" 20-2: Magic Hags' Potion Shop") - { " 20-2:\x8Dマホウオババ ノ クスリヤ", Select_LoadGame, 0x400 }, - // " 21: Wood Mountain" (" 21: Woodfall") - { " 21:\x8Cウッドマウンテン", Select_LoadGame, 0x8600 }, - // " 21-0: Deku Princess's Prison" (" 21-0: Deku Princess's Prison [Cutscene: Tatl Apologizes]") - { " 21-0:\x8Cデク\x8Dヒメ ノ ロウヤ", Select_LoadGame, 0x3010 }, - // " 22: Deku Castle" (" 22: Deku Palace") - { " 22:\x8Cデクナッツ \x8Dノ シロ", Select_LoadGame, 0x5000 }, - // " 22-0: Boe Hole 0" (" 22-0: Deku Palace Grotto 0 - Deku Baba & Butterflies, Entrance 1") - { " 22-0:\x8Cクロスケ \x8Dノ アナ0", Select_LoadGame, 0x1460 }, - // " 22-1: Boe Hole 1" (" 22-1: Deku Palace Grotto 1 - Deku Baba & Butterflies, Entrance 2") - { " 22-1:\x8Cクロスケ \x8Dノ アナ1", Select_LoadGame, 0x14E0 }, - // " 22-2: Boe Hole 2" (" 22-2: Deku Palace Grotto 2 - Skullwalltula Wall, Lower Entrance") - { " 22-2:\x8Cクロスケ \x8Dノ アナ2", Select_LoadGame, 0x1480 }, - // " 22-3: Boe Hole 3" (" 22-3: Deku Palace Grotto 3 - Skullwalltula Wall, Upper Entrance") - { " 22-3:\x8Cクロスケ \x8Dノ アナ3", Select_LoadGame, 0x14F0 }, - // " 22-4: Boe Hole 4" (" 22-4: Deku Palace Grotto 4 - Bean Seller") - { " 22-4:\x8Cクロスケ \x8Dノ アナ4", Select_LoadGame, 0x14C0 }, - // " 24: Beast Path" (" 24: Road to Swamp") - { " 24:\x8Dケモノミチ", Select_LoadGame, 0x7A00 }, - // " 24-0: Forest Shooting Gallery" (" 24-0: Swamp Shooting Gallery") - { " 24-0:\x8Dモリ ノ シャテキジョウ", Select_LoadGame, 0x4200 }, - // " 25: Deku King's Chamber" (" 25: Deku Palace Throne Room") - { " 25:\x8Cデク\x8Dオウ ノ マ", Select_LoadGame, 0x7600 }, - // " 26: Woods of Mystery" (" 26: Woods of Mystery") - { " 26:\x8Dフシギ ノ モリ", Select_LoadGame, 0xC200 }, - // " 30: Great Bay Coast" (" 30: Great Bay Coast - Entrance Area") - { " 30:\x8Cグレートベイ\x8D ノ カイガン", Select_LoadGame, 0x6800 }, - // " 30-0: Ocean Laboratory" (" 30-0: Marine Research Lab") - { " 30-0:\x8Dカイヨウ ケンキュウジョ", Select_LoadGame, 0x5800 }, - // " 30-1: Fisherman's House" (" 30-1: Fisherman's Hut") - { " 30-1:\x8Dリョウシ ノ イエ", Select_LoadGame, 0x7200 }, - // " 30-2: Pointed Rock" (" 30-2: Twin Pillars") - { " 30-2:\x8Dトンガリ イワ", Select_LoadGame, 0x4400 }, - // " 31: Cape" (" 31: Great Bay Coast - River Area") - { " 31:\x8Dミサキ", Select_LoadGame, 0x6A00 }, - // " 32: Outside of Pirates' Fortress" (" 32: Pirates' Fortress - Exterior") - { " 32:\x8Dカイゾクノトリデマエ", Select_LoadGame, 0x7000 }, - // " 32-0: Pirates' Fortress" (" 32-0: Pirates' Fortress - Courtyard") - { " 32-0:\x8Dカイゾクノトリデ", Select_LoadGame, 0x2200 }, - // " 32-1: Pirates' Fortress - Telescope" (" 32-1: Pirates' Fortress - Secret Entrance (Looking Through - // Telescope)") - { " 32-1:\x8Dカイゾクノトリデ ボウエンキョウ", Select_LoadGame, 0x22A0 }, - // " 32-2: Pirates' Fortress - Interior 0" (" 32-2: Pirates' Fortress - Throne Room") - { " 32-2:\x8Dカイゾクノトリデナイブ0", Select_LoadGame, 0x4000 }, - // " 32-3: Pirates' Fortress - Interior 1" (" 32-3: Pirates' Fortress - View of Throne Room, Wasp Nest") - { " 32-3:\x8Dカイゾクノトリデナイブ1", Select_LoadGame, 0x4010 }, - // " 32-4: Pirates' Fortress - Interior 2" (" 32-4: Pirates' Fortress - Tempting Treasure Chest, Leading to 32-5") - { " 32-4:\x8Dカイゾクノトリデナイブ2", Select_LoadGame, 0x4020 }, - // " 32-5: Pirates' Fortress - Interior 3" (" 32-5: Pirates' Fortress - Zora Egg Room, One Shell Blade") - { " 32-5:\x8Dカイゾクノトリデナイブ3", Select_LoadGame, 0x4030 }, - // " 32-6: Pirates' Fortress - Interior 4" (" 32-6: Pirates' Fortress - Oil Drum Room, Leading to 32-7") - { " 32-6:\x8Dカイゾクノトリデナイブ4", Select_LoadGame, 0x4040 }, - // " 32-7: Pirates' Fortress - Interior 5" (" 32-7: Pirates' Fortress - Zora Egg Room, One Shell Blade") - { " 32-7:\x8Dカイゾクノトリデナイブ5", Select_LoadGame, 0x4050 }, - // " 32-8: Pirates' Fortress - Interior 6" (" 32-8: Pirates' Fortress - Fenced Indoor Walkway, Leading to 32-9") - { " 32-8:\x8Dカイゾクノトリデナイブ6", Select_LoadGame, 0x4060 }, - // " 32-9: Pirates' Fortress - Interior 7" (" 32-9: Pirates' Fortress - Zora Egg Room, One Desbreko & Treasure - // Chest") - { " 32-9:\x8Dカイゾクノトリデナイブ7", Select_LoadGame, 0x4070 }, - // " 32-10: Pirates' Fortress - Interior 8" (" 32-10: Pirates' Fortress - End of Secret Entrance (Telescope - // Room)") - { " 32-10:\x8Dカイゾクノトリデナイブ8", Select_LoadGame, 0x4080 }, - // " 32-11: Pirates' Fortress - Interior 9" (" 32-11: Pirates' Fortress - Start of Secret Entrance") - { " 32-11:\x8Dカイゾクノトリデナイブ9", Select_LoadGame, 0x4090 }, - // " 33: Zora Shrine" (" 33: Zora Hall") - { " 33:\x8Cゾーラ \x8Dノ ホコラ", Select_LoadGame, 0x6000 }, - // " 33-0: Zora Shop" (" 33-0: Zora Shop") - { " 33-0:\x8Cゾーラ \x8Dノ ミセ", Select_LoadGame, 0x9250 }, - // " 33-1: Zora Waiting Room" (" 33-1: Mikau & Tijo's Room") - { " 33-1:\x8Cゾーラ \x8Dノ ヒカエシツ", Select_LoadGame, 0x9200 }, - // " 34: Great Bay" (" 34: Great Bay [Cutscene: Pirates Approach Temple]") - { " 34:\x8Cグレートベイ", Select_LoadGame, 0xBE00 }, - // " 35: Mountain Stream Above Falls" (" 35: Waterfall Rapids") - { " 35:\x8Dタキウエ ノ ケイリュウ", Select_LoadGame, 0x8E00 }, - // " 40: Rock Building Shaft" (" 40: Stone Tower") - { " 40:\x8Cロックビル\x8D ノ タテアナ", Select_LoadGame, 0xAA00 }, - // " 40-0: Heaven & Earth Are Overturned" (" 40-0: Stone Tower [Cutscene: Tower is Flipped]") - { " 40-0:\x8Dテンチ ギャクテン", Select_LoadGame, 0xAC00 }, - // " 41: Road to Ikana" (" 41: Road to Ikana") - { " 41:\x8Cイカーナ \x8Dヘノ ミチ", Select_LoadGame, 0xA000 }, - // " 42: Ancient Castle of Ikana" (" 42: Ancient Castle of Ikana") - { " 42:\x8Cイカーナ\x8D コジョウ", Select_LoadGame, 0x3400 }, - // " 42-0: Ancient Castle of Ikana - Interior" (" 42-0: Ancient Castle of Ikana - Interior") - { " 42-0:\x8Cイカーナ\x8D ノ コジョウ ナイブ", Select_LoadGame, 0x3430 }, - // " 42-B: Ancient Castle of Ikana - Boss Room" (" 42-B: Ikana King's Throne") - { " 42-B:\x8Cイカーナ\x8D ノ コジョウ \x8Cボス\x8Dベヤ", Select_LoadGame, 0xA600 }, - // " 43: Ikana Canyon" (" 43: Ikana Canyon") - { " 43:\x8Cイカーナ \x8Dケイコク", Select_LoadGame, 0x2000 }, - // " 43-0: Ikana Canyon Cave" (" 43-0: Sharp's Cave") - { " 43-0:\x8Cイカーナ \x8Dケイコク ドウクツ", Select_LoadGame, 0x20E0 }, - // " 43-1: Secom's House" (" 43-1: Sakon's Hideout") - { " 43-1:\x8Cセコム \x8Dノ イエ", Select_LoadGame, 0x9800 }, - // " 43-2: Music Box House" (" 43-2: Music Box House") - { " 43-2:\x8Cオルゴール ハウス", Select_LoadGame, 0xA400 }, - // " 50: Clock Town -East-" (" 50: East Clock Town") - { " 50:\x8Cクロックタウン \x8D-ヒガシ-", Select_LoadGame, 0xD200 }, - // " 50-0: Town Target Range" (" 50-0: Shooting Gallery") - { " 50-0:\x8Dマチ ノ シャテキジョウ", Select_LoadGame, 0x3A00 }, - // " 50-1: Honey and Darling's Shop" (" 50-1: Honey & Darling's Shop") - { " 50-1:\x8Cハニー アンド ダーリン \x8Dノ ミセ", Select_LoadGame, 0x800 }, - // " 50-2: Treasure Chest Shop" (" 50-2: Treasure Chest Shop") - { " 50-2:\x8Dタカラバコヤ", Select_LoadGame, 0x2800 }, - // " 50-3: Pots 'n' Pans Inn" (" 50-3: Stockpot Inn") - { " 50-3:\x8Cナベ\x8Dカマ テイ", Select_LoadGame, 0xBC00 }, - // " 50-4: Mayor's House" (" 50-4: The Mayor's Residence") - { " 50-4:\x8Dチョウチョウ ノ イエ", Select_LoadGame, 0 }, - // " 50-5: Milk Bar" (" 50-5: Milk Bar") - { " 50-5:\x8Cミルクバー", Select_LoadGame, 0x2400 }, - // " 51: Clock Town -West-" (" 51: West Clock Town") - { " 51:\x8Cクロックタウン \x8D-ニシ-", Select_LoadGame, 0xD400 }, - // " 51-0: Bomb Shop" (" 51-0: Bomb Shop") - { " 51-0:\x8Dバクダン ヤ", Select_LoadGame, 0xCA00 }, - // " 51-1: Maniac Mart" (" 51-1: Curiosity Shop") - { " 51-1:\x8Cマニ\x8Dヤ", Select_LoadGame, 0xE00 }, - // " 51-2: General Store" (" 51-2: Trading Post") - { " 51-2:\x8Dザッカ ヤ", Select_LoadGame, 0x6200 }, - // " 51-3: Sword Dojo" (" 51-3: Swordsman's School") - { " 51-3:\x8Dケンドウジョウ", Select_LoadGame, 0xA200 }, - // " 51-4: Post House" (" 51-4: Post Office") - { " 51-4:\x8Dポストハウス", Select_LoadGame, 0x5600 }, - // " 51-5: Lottery Shop" (" 51-5: Lottery Shop") - { " 51-5:\x8Dタカラクジヤ", Select_LoadGame, 0x6C00 }, - // " 52: Clock Town -North-" (" 52: North Clock Town") - { " 52:\x8Cクロックタウン \x8D-キタ-", Select_LoadGame, 0xD600 }, - // " 53: Clocktown -South-" (" 53: South Clock Town") - { " 53:\x8Cクロックタウン \x8D-ミナミ-", Select_LoadGame, 0xD800 }, - // " 53-0: Clock Tower Interior" (" 53-0: Clock Tower Interior") - { " 53-0:\x8Dトケイトウナイブ", Select_LoadGame, 0xC000 }, - // " 54: Clock Tower Rooftop" (" 54: Clock Tower Rooftop") - { " 54:\x8Dトケイトウ オクジョウ", Select_LoadGame, 0x2C00 }, - // " 55: Laundry Area" (" 55: Laundry Pool") - { " 55:\x8Dセンタクジョウ", Select_LoadGame, 0xDA00 }, - // " 55-0: Maniac Mart - Rear Entrance" (" 55-0: Curiosity Shop - Back Room") - { " 55-0:\x8Cマニ\x8Dヤ ノ ウラグチ", Select_LoadGame, 0xE10 }, - // " 55-1: Maniac Mart - Peephole" (" 55-1: Curiosity Shop Back Room - Peephole") - { " 55-1:\x8Cマニ\x8Dヤ ノ ノゾキアナ", Select_LoadGame, 0xE20 }, - // "100: Wood Mountain Temple" ("100: Woodfall Temple") - { "100:\x8Cウッドマウンテン \x8Dノ シンデン", Select_LoadGame, 0x3000 }, - // "100-B: Wood Mountain Temple - Boss" ("100-B: Odolwa's Lair") - { "100-B:\x8Cウッドマウンテン \x8Dノ シンデン\x8C-ボス-", Select_LoadGame, 0x3800 }, - // "101: Snowhead Temple" ("101: Snowhead Temple") - { "101:\x8Cスノーヘッド \x8Dノ シンデン", Select_LoadGame, 0x3C00 }, - // "101-B: Snowhead Temple - Boss" ("101-B: Goht's Lair") - { "101-B:\x8Cスノーヘッド \x8Dノ シンデン\x8C-ボス-", Select_LoadGame, 0x8200 }, - // "102: Great Bay Temple" ("102: Great Bay Temple") - { "102:\x8Cグレートベイ \x8Dノ シンデン", Select_LoadGame, 0x8C00 }, - // "102-B: Great Bay Temple - Boss" ("102-B: Gyorg's Lair") - { "102-B:\x8Cグレートベイ \x8Dノ シンデン\x8C-ボス-", Select_LoadGame, 0xB800 }, - // "103: Rock Building Temple -Top Side-" ("103: Stone Tower Temple") - { "103:\x8Cロックビル \x8Dノ シンデン-オモテー", Select_LoadGame, 0x2600 }, - // "103-0: Rock Building Temple -Underside-" ("103-0: Stone Tower Temple - Flipped") - { "103-0:\x8Cロックビル \x8Dノ シンデン-ウラー", Select_LoadGame, 0x2A00 }, - // "103-B: Rock Building Temple - Boss" ("103-B: Twinmold's Lair") - { "103-B:\x8Cロックビル \x8Dノ シンデン\x8C-ボス-", Select_LoadGame, 0x6600 }, - // "104: Steppe" ("104: On the Moon") - { "104:\x8Cソウゲン", Select_LoadGame, 0xC800 }, - // "104-0: Last Deku Dungeon" ("104-0: Deku Trial") - { "104-0:\x8Cラスト デク ダンジョン", Select_LoadGame, 0x4E00 }, - // "104-1: Last Goron Dungeon" ("104-1: Goron Trial") - { "104-1:\x8Cラスト ゴロン ダンジョン", Select_LoadGame, 0x7800 }, - // "104-2: Last Zora Dungeon" ("104-2: Zora Trial") - { "104-2:\x8Cラスト ゾーラ ダンジョン", Select_LoadGame, 0x8800 }, - // "104-3: Last Link Dungeon" ("104-3: Link Trial") - { "104-3:\x8Cラスト リンク ダンジョン", Select_LoadGame, 0xC600 }, - // "104-B: Last Dungeon -Boss-" ("104-B: Majora's Lair") - { "104-B:\x8Cラストダンジョン -ボス-", Select_LoadGame, 0x200 }, - // "119: Deku Shrine" ("119: Deku Shrine") - { "119:\x8Cデクナッツ \x8Dノ ホコラ", Select_LoadGame, 0x9E00 }, - // "121: Secret Shrine" ("121: Secret Shrine") - { "121:\x8Dヒミツ ノ ホコラ", Select_LoadGame, 0xBA00 }, - // "122: Opening Dungeon" ("122: Pond Area [Cutscene: Falling of the Cliff]") - { "122:\x8Cオープニング ダンジョン", Select_LoadGame, 0x2E00 }, - // "123: Giants' Chamber" ("123: Giants' Chamber") - { "123:\x8Dキョジン ノ マ", Select_LoadGame, 0xCC00 }, - // "126: Deku Minigame" ("126: Deku Rupee Minigame") - { "126:\x8Cデクナッツ ミニゲーム", Select_LoadGame, 0x3600 }, - // "127-0: Fairy Fountain 0" ("127-0: Fairy Fountain - Clock Town") - { "127-0:\x8Dヨウセイ ノ イズミ 0", Select_LoadGame, 0x4600 }, - // "127-1: Fairy Fountain 1" ("127-1: Fairy Fountain - Woodfall") - { "127-1:\x8Dヨウセイ ノ イズミ 1", Select_LoadGame, 0x4610 }, - // "127-2: Fairy Fountain 2" ("127-2: Fairy Fountain - Snowhead") - { "127-2:\x8Dヨウセイ ノ イズミ 2", Select_LoadGame, 0x4620 }, - // "127-3: Fairy Fountain 3" ("127-3: Fairy Fountain - Great Bay Coast") - { "127-3:\x8Dヨウセイ ノ イズミ 3", Select_LoadGame, 0x4630 }, - // "127-4: Fairy Fountain 4" ("127-4: Fairy Fountain - Ikana Canyon") - { "127-4:\x8Dヨウセイ ノ イズミ 4", Select_LoadGame, 0x4640 }, - // "128: Swamp Spider Manor" ("128: Swamp Spider House") - { "128:\x8Dヌマ ノ クモヤカタ", Select_LoadGame, 0x4800 }, - // "129: Ocean Spider Manor" ("129: Oceanside Spider House") - { "129:\x8Dウミ ノ クモヤカタ", Select_LoadGame, 0x4A00 }, - // "130: Beneath the Graves - Dampe" ("130: Beneath the Graveyard") - { "130:\x8Dハカ ノ シタ-\x8Cダンペイ-", Select_LoadGame, 0x5A00 }, - // "131: Beneath the Well" ("131: Beneath the Well") - { "131:\x8Dイド ノ シタ", Select_LoadGame, 0x9000 }, - // "132: Ghost Hut" (" 132: Ghost Hut") - { "132:\x8Dユウレイゴヤ", Select_LoadGame, 0x9C00 }, - // "133-0: Beneath the Graves 0" ("133-0: Beneath the Graveyard - Part 1") - { "133-0:\x8Dハカ ノ シタ0", Select_LoadGame, 0xA00 }, - // "133-1: Beneath the Graves 1" ("133-1: Beneath the Graveyard - Part 2") - { "133-1:\x8Dハカ ノ シタ1", Select_LoadGame, 0xA10 }, - // "134-0: Secret Grotto 0" ("134-0: Secret Grotto - Four Gossip Stones") - { "134-0:\x8Dカクシアナ 0", Select_LoadGame, 0x1400 }, - // "134-1: Secret Grotto 1" ("134-1: Secret Grotto - Four Gossip Stones, Skulltula") - { "134-1:\x8Dカクシアナ 1", Select_LoadGame, 0x1410 }, - // "134-2: Secret Grotto 2" ("134-2: Secret Grotto - Four Gossip Stones, Water Puddles") - { "134-2:\x8Dカクシアナ 2", Select_LoadGame, 0x1420 }, - // "134-3: Secret Grotto 3" ("134-3: Secret Grotto - Four Gossip Stones, Water Puddle With Bugs") - { "134-3:\x8Dカクシアナ 3", Select_LoadGame, 0x1430 }, - // "134-4: Secret Grotto 4" ("134-4: Secret Grotto - Chest with Blue Rupee, Deku Babas") - { "134-4:\x8Dカクシアナ 4", Select_LoadGame, 0x1440 }, - // "134-5: Secret Grotto 5" ("134-5: Secret Grotto - Hot Spring, Deku Babas, Large Stones") - { "134-5:\x8Dカクシアナ5", Select_LoadGame, 0x1450 }, - // "134-7: Secret Grotto 7" ("134-7: Secret Grotto - Two Dondogos") - { "134-7:\x8Dカクシアナ 7", Select_LoadGame, 0x1470 }, - // "134-9: Secret Grotto 9" ("134-9: Secret Grotto - Tall Grass With Box, Pot, Bugs") - { "134-9:\x8Dカクシアナ 9", Select_LoadGame, 0x1490 }, - // "134-10: Secret Grotto 10" ("134-10: Secret Grotto - Two Cows Surrounded by Grass") - { "134-10:\x8Dカクシアナ10", Select_LoadGame, 0x14A0 }, - // "134-11: Secret Grotto 11" ("134-11: Secret Grotto - Watery Hole Filled with Underwater Babas, Fish") - { "134-11:\x8Dカクシアナ11", Select_LoadGame, 0x14B0 }, - // "134-13: Secret Grotto 13" ("134-13: Secret Grotto - Peahat in Center") - { "134-13:\x8Dカクシアナ13", Select_LoadGame, 0x14D0 }, - // "X 1: SPOT00" ("X 1: Opening [Cutscene: Opening Cutscene]") - { "X 1:SPOT00", Select_LoadGame, 0x1C00 }, - // "Title" ("Title Screen") - { "title", (void*)Select_LoadTitle, 0x0000 }, + // "0: OP Woods for Cutscene Use" (Forest Opening Scene) + { " 0:OP" GFXP_KATAKANA "デモ" GFXP_HIRAGANA "ヨウ シンリン", MapSelect_LoadGame, ENTRANCE(CUTSCENE, 0) }, + + // "0-0: Lost Woods" (Lost Woods) + { " 0-0:" GFXP_HIRAGANA "マヨイ ノ モリ", MapSelect_LoadGame, ENTRANCE(LOST_WOODS, 0) }, + + // "1: Town Outskirts" (Termina Field) + { " 1:" GFXP_KATAKANA "タウン " GFXP_HIRAGANA "コウガイ", MapSelect_LoadGame, ENTRANCE(TERMINA_FIELD, 0) }, + + // "1-0: Astral Observatory" (Astral Observatory) + { " 1-0:" GFXP_HIRAGANA "テンモンカンソクジョ", MapSelect_LoadGame, ENTRANCE(ASTRAL_OBSERVATORY, 0) }, + + // "1-1: Astral Observatory Telescope" (Astral Observatory - Telescope) + { " 1-1:" GFXP_HIRAGANA "テンモンカンソクジョ デ ボウエンキョウ", MapSelect_LoadGame, ENTRANCE(TERMINA_FIELD, 10) }, + + // "1-2: Ikana Graveyard" (Ikana Canyon Graveyard) + { " 1-2:" GFXP_KATAKANA "イカーナ " GFXP_HIRAGANA "ノ ハカバ", MapSelect_LoadGame, ENTRANCE(IKANA_GRAVEYARD, 0) }, + + // "2: Romani Ranch" (Romani Ranch) + { " 2:" GFXP_KATAKANA "ロマニー " GFXP_HIRAGANA "ボクジョウ", MapSelect_LoadGame, ENTRANCE(ROMANI_RANCH, 0) }, + + // "3: Milk Road" (Milk Road) + { " 3:" GFXP_KATAKANA "ミルクロード", MapSelect_LoadGame, ENTRANCE(MILK_ROAD, 0) }, + + // "4: Main Building" ("Ranch House) + { " 4:" GFXP_HIRAGANA "オモヤ", MapSelect_LoadGame, ENTRANCE(RANCH_HOUSE, 1) }, + + // "5: Cow Shed" (Cow Shed) + { " 5:" GFXP_HIRAGANA "ウシゴヤ", MapSelect_LoadGame, ENTRANCE(RANCH_HOUSE, 0) }, + + // "6: Cucco Shed" (Cucco Shed) + { " 6:" GFXP_KATAKANA "コッコ " GFXP_HIRAGANA "ゴヤ", MapSelect_LoadGame, ENTRANCE(CUCCO_SHACK, 0) }, + + // "7: Dog Racing Area" (Doggy Racetrack) + { " 7:" GFXP_KATAKANA "ドッグレース" GFXP_HIRAGANA "ジョウ", MapSelect_LoadGame, ENTRANCE(DOGGY_RACETRACK, 0) }, + + // "8: Gorman Track" (Gorman Track) + { " 8:" GFXP_KATAKANA "ゴーマン トラック", MapSelect_LoadGame, ENTRANCE(GORMAN_TRACK, 0) }, + + // "10: Mountain Village -Winter-" (Mountain Village - Winter) + { " 10:" GFXP_HIRAGANA "ヤマザト -フユ-", MapSelect_LoadGame, ENTRANCE(MOUNTAIN_VILLAGE_WINTER, 0) }, + + // "10-0: Mountain Village -Spring-" (Mountain Village - Spring) + { " 10-0:" GFXP_HIRAGANA "ヤマザト -ハル-", MapSelect_LoadGame, ENTRANCE(MOUNTAIN_VILLAGE_SPRING, 0) }, + + // "10-1: Mountain Village Blacksmith" (Mountain Smithy) + { " 10-1:" GFXP_HIRAGANA "ヤマザト ノ カジヤ", MapSelect_LoadGame, ENTRANCE(MOUNTAIN_SMITHY, 0) }, + + // "11: Goron Village -Winter-" (Goron Village - Winter) + { " 11:" GFXP_KATAKANA "ゴロン" GFXP_HIRAGANA " ノ サト -フユ-", MapSelect_LoadGame, ENTRANCE(GORON_VILLAGE_WINTER, 0) }, + + // "11-0: Goron Village -Spring-" (Goron Village - Spring) + { " 11-0:" GFXP_KATAKANA "ゴロン" GFXP_HIRAGANA " ノ サト -ハル-", MapSelect_LoadGame, ENTRANCE(GORON_VILLAGE_SPRING, 0) }, + + // "11-1: Goron Shrine" (Goron Shrine) + { " 11-1:" GFXP_KATAKANA "ゴロン" GFXP_HIRAGANA " ノ ホコラ", MapSelect_LoadGame, ENTRANCE(GORON_SHRINE, 0) }, + + // "11-2: Lone Peak Shrine" (Lone Peak Shrine) + { " 11-2:" GFXP_HIRAGANA "ハナレヤマ ノ ホコラ", MapSelect_LoadGame, ENTRANCE(GROTTOS, 16) }, + + // "11-3: Goron Shop" (Goron Shop) + { " 11-3:" GFXP_KATAKANA "ゴロン " GFXP_HIRAGANA "ノ ミセ", MapSelect_LoadGame, ENTRANCE(GORON_SHOP, 0) }, + + // "12: Snowhead" (Snowhead) + { " 12:" GFXP_KATAKANA "スノーヘッド", MapSelect_LoadGame, ENTRANCE(SNOWHEAD, 0) }, + + // "13: Blizzard Path" (Path to Goron Village - Part 1) + { " 13:" GFXP_HIRAGANA "フブキ ノ ミチ", MapSelect_LoadGame, ENTRANCE(PATH_TO_MOUNTAIN_VILLAGE, 0) }, + + // "14: Snowball Path" (Path to Goron Village - Part 2) + { " 14:" GFXP_HIRAGANA "ユキダマ ノ ミチ", MapSelect_LoadGame, ENTRANCE(PATH_TO_SNOWHEAD, 0) }, + + // "15: Goron Racetrack" (Goron Racetrack) + { " 15:" GFXP_KATAKANA "ゴロンレース " GFXP_HIRAGANA "ジョウ", MapSelect_LoadGame, ENTRANCE(GORON_RACETRACK, 0) }, + + // "16: Goron Grave" (Darmani's Grave) + { " 16:" GFXP_KATAKANA "ゴロン " GFXP_HIRAGANA "ノ ハカ", MapSelect_LoadGame, ENTRANCE(GORON_GRAVERYARD, 0) }, + + // "17: Snow Field Battle -Winter-" (Path to Goron Village - Winter) + { " 17:" GFXP_HIRAGANA "セツゲン " GFXP_KATAKANA "バトル " GFXP_HIRAGANA "-フユ-", MapSelect_LoadGame, + ENTRANCE(PATH_TO_GORON_VILLAGE_WINTER, 0) }, + + // "17-0: Snow Field Battle -Spring-" (Path to Goron Village - Spring) + { " 17-0:" GFXP_HIRAGANA "セツゲン " GFXP_KATAKANA "バトル " GFXP_HIRAGANA "-ハル-", MapSelect_LoadGame, + ENTRANCE(PATH_TO_GORON_VILLAGE_SPRING, 0) }, + + // "20: Swampland" (Southern Swamp) + { " 20:" GFXP_HIRAGANA "ヌマチ", MapSelect_LoadGame, ENTRANCE(SOUTHERN_SWAMP_POISONED, 0) }, + + // "20-0: Swampland - Afterwards" (Southern Swamp - After Odolwa) + { " 20-0:" GFXP_HIRAGANA "ヌマチ ソノゴ", MapSelect_LoadGame, ENTRANCE(SOUTHERN_SWAMP_CLEARED, 0) }, + + // "20-1: Swamp Tourist Information" (Tourist Information) + { " 20-1:" GFXP_HIRAGANA "ヌマ ノ カンコウアンナイ", MapSelect_LoadGame, ENTRANCE(TOURIST_INFORMATION, 0) }, + + // "20-2: Magic Hags' Potion Shop" (Magic Hags' Potion Shop) + { " 20-2:" GFXP_HIRAGANA "マホウオババ ノ クスリヤ", MapSelect_LoadGame, ENTRANCE(MAGIC_HAGS_POTION_SHOP, 0) }, + + // "21: Wood Mountain" (Woodfall) + { " 21:" GFXP_KATAKANA "ウッドマウンテン", MapSelect_LoadGame, ENTRANCE(WOODFALL, 0) }, + + // "21-0: Deku Princess's Prison" (Deku Princess's Prison Cutscene: Tatl Apologizes) + { " 21-0:" GFXP_KATAKANA "デク" GFXP_HIRAGANA "ヒメ ノ ロウヤ", MapSelect_LoadGame, ENTRANCE(WOODFALL_TEMPLE, 1) }, + + // "22: Deku Castle" (Deku Palace) + { " 22:" GFXP_KATAKANA "デクナッツ " GFXP_HIRAGANA "ノ シロ", MapSelect_LoadGame, ENTRANCE(DEKU_PALACE, 0) }, + + // "22-0: Boe Hole 0" (Deku Palace Grotto 0 - Deku Baba & Butterflies, Entrance 1) + { " 22-0:" GFXP_KATAKANA "クロスケ " GFXP_HIRAGANA "ノ アナ0", MapSelect_LoadGame, ENTRANCE(GROTTOS, 6) }, + + // "22-1: Boe Hole 1" (Deku Palace Grotto 1 - Deku Baba & Butterflies, Entrance 2) + { " 22-1:" GFXP_KATAKANA "クロスケ " GFXP_HIRAGANA "ノ アナ1", MapSelect_LoadGame, ENTRANCE(GROTTOS, 14) }, + + // "22-2: Boe Hole 2" (Deku Palace Grotto 2 - Skullwalltula Wall, Lower Entrance) + { " 22-2:" GFXP_KATAKANA "クロスケ " GFXP_HIRAGANA "ノ アナ2", MapSelect_LoadGame, ENTRANCE(GROTTOS, 8) }, + + // "22-3: Boe Hole 3" (Deku Palace Grotto 3 - Skullwalltula Wall, Upper Entrance) + { " 22-3:" GFXP_KATAKANA "クロスケ " GFXP_HIRAGANA "ノ アナ3", MapSelect_LoadGame, ENTRANCE(GROTTOS, 15) }, + + // "22-4: Boe Hole 4" (Deku Palace Grotto 4 - Bean Seller) + { " 22-4:" GFXP_KATAKANA "クロスケ " GFXP_HIRAGANA "ノ アナ4", MapSelect_LoadGame, ENTRANCE(GROTTOS, 12) }, + + // "24: Beast Path" (Road to Swamp) + { " 24:" GFXP_HIRAGANA "ケモノミチ", MapSelect_LoadGame, ENTRANCE(ROAD_TO_SOUTHERN_SWAMP, 0) }, + + // "24-0: Forest Shooting Gallery" (Swamp Shooting Gallery) + { " 24-0:" GFXP_HIRAGANA "モリ ノ シャテキジョウ", MapSelect_LoadGame, ENTRANCE(SWAMP_SHOOTING_GALLERY, 0) }, + + // "25: Deku King's Chamber" (Deku Palace Throne Room) + { " 25:" GFXP_KATAKANA "デク" GFXP_HIRAGANA "オウ ノ マ", MapSelect_LoadGame, ENTRANCE(DEKU_KINGS_CHAMBER, 0) }, + + // "26: Woods of Mystery" (Woods of Mystery) + { " 26:" GFXP_HIRAGANA "フシギ ノ モリ", MapSelect_LoadGame, ENTRANCE(WOODS_OF_MYSTERY, 0) }, + + // "30: Great Bay Coast" (Great Bay Coast - Entrance Area) + { " 30:" GFXP_KATAKANA "グレートベイ" GFXP_HIRAGANA " ノ カイガン", MapSelect_LoadGame, ENTRANCE(GREAT_BAY_COAST, 0) }, + + // "30-0: Ocean Laboratory" (Marine Research Lab) + { " 30-0:" GFXP_HIRAGANA "カイヨウ ケンキュウジョ", MapSelect_LoadGame, ENTRANCE(MARINE_RESEARCH_LAB, 0) }, + + // "30-1: Fisherman's House" (Fisherman's Hut) + { " 30-1:" GFXP_HIRAGANA "リョウシ ノ イエ", MapSelect_LoadGame, ENTRANCE(FISHERMANS_HUT, 0) }, + + // "30-2: Pointed Rock" (Twin Pillars) + { " 30-2:" GFXP_HIRAGANA "トンガリ イワ", MapSelect_LoadGame, ENTRANCE(PINNACLE_ROCK, 0) }, + + // "31: Cape" (Great Bay Coast - River Area) + { " 31:" GFXP_HIRAGANA "ミサキ", MapSelect_LoadGame, ENTRANCE(ZORA_CAPE, 0) }, + + // "32: Outside of Pirates' Fortress" (Pirates' Fortress - Exterior) + { " 32:" GFXP_HIRAGANA "カイゾクノトリデマエ", MapSelect_LoadGame, ENTRANCE(PIRATES_FORTRESS_EXTERIOR, 0) }, + + // "32-0: Pirates' Fortress" (Pirates' Fortress - Courtyard) + { " 32-0:" GFXP_HIRAGANA "カイゾクノトリデ", MapSelect_LoadGame, ENTRANCE(PIRATES_FORTRESS, 0) }, + + // "32-1: Pirates' Fortress - Telescope" (Pirates' Fortress - Secret Entrance, Looking Through Telescope) + { " 32-1:" GFXP_HIRAGANA "カイゾクノトリデ ボウエンキョウ", MapSelect_LoadGame, ENTRANCE(PIRATES_FORTRESS, 10) }, + + // "32-2: Pirates' Fortress - Interior 0" (Pirates' Fortress - Throne Room) + { " 32-2:" GFXP_HIRAGANA "カイゾクノトリデナイブ0", MapSelect_LoadGame, ENTRANCE(PIRATES_FORTRESS_INTERIOR, 0) }, + + // "32-3: Pirates' Fortress - Interior 1" (Pirates' Fortress - View of Throne Room, Wasp Nest) + { " 32-3:" GFXP_HIRAGANA "カイゾクノトリデナイブ1", MapSelect_LoadGame, ENTRANCE(PIRATES_FORTRESS_INTERIOR, 1) }, + + // "32-4: Pirates' Fortress - Interior 2" (Pirates' Fortress - Tempting Treasure Chest, Leading to 32-5) + { " 32-4:" GFXP_HIRAGANA "カイゾクノトリデナイブ2", MapSelect_LoadGame, ENTRANCE(PIRATES_FORTRESS_INTERIOR, 2) }, + + // "32-5: Pirates' Fortress - Interior 3" (Pirates' Fortress - Zora Egg Room, One Shell Blade) + { " 32-5:" GFXP_HIRAGANA "カイゾクノトリデナイブ3", MapSelect_LoadGame, ENTRANCE(PIRATES_FORTRESS_INTERIOR, 3) }, + + // "32-6: Pirates' Fortress - Interior 4" (Pirates' Fortress - Oil Drum Room, Leading to 32-7) + { " 32-6:" GFXP_HIRAGANA "カイゾクノトリデナイブ4", MapSelect_LoadGame, ENTRANCE(PIRATES_FORTRESS_INTERIOR, 4) }, + + // "32-7: Pirates' Fortress - Interior 5" (Pirates' Fortress - Zora Egg Room, One Shell Blade) + { " 32-7:" GFXP_HIRAGANA "カイゾクノトリデナイブ5", MapSelect_LoadGame, ENTRANCE(PIRATES_FORTRESS_INTERIOR, 5) }, + + // "32-8: Pirates' Fortress - Interior 6" (Pirates' Fortress - Fenced Indoor Walkway, Leading to 32-9) + { " 32-8:" GFXP_HIRAGANA "カイゾクノトリデナイブ6", MapSelect_LoadGame, ENTRANCE(PIRATES_FORTRESS_INTERIOR, 6) }, + + // "32-9: Pirates' Fortress - Interior 7" (Pirates' Fortress - Zora Egg Room, One Desbreko & Treasure Chest) + { " 32-9:" GFXP_HIRAGANA "カイゾクノトリデナイブ7", MapSelect_LoadGame, ENTRANCE(PIRATES_FORTRESS_INTERIOR, 7) }, + + // "32-10: Pirates' Fortress - Interior 8" (Pirates' Fortress - End of Secret Entrance: Telescope Room) + { " 32-10:" GFXP_HIRAGANA "カイゾクノトリデナイブ8", MapSelect_LoadGame, ENTRANCE(PIRATES_FORTRESS_INTERIOR, 8) }, + + // "32-11: Pirates' Fortress - Interior 9" (Pirates' Fortress - Start of Secret Entrance) + { " 32-11:" GFXP_HIRAGANA "カイゾクノトリデナイブ9", MapSelect_LoadGame, ENTRANCE(PIRATES_FORTRESS_INTERIOR, 9) }, + + // "33: Zora Shrine" (Zora Hall) + { " 33:" GFXP_KATAKANA "ゾーラ " GFXP_HIRAGANA "ノ ホコラ", MapSelect_LoadGame, ENTRANCE(ZORA_HALL, 0) }, + + // "33-0: Zora Shop" (Zora Shop) + { " 33-0:" GFXP_KATAKANA "ゾーラ " GFXP_HIRAGANA "ノ ミセ", MapSelect_LoadGame, ENTRANCE(ZORA_HALL_ROOMS, 5) }, + + // "33-1: Zora Waiting Room" (Mikau & Tijo's Room) + { " 33-1:" GFXP_KATAKANA "ゾーラ " GFXP_HIRAGANA "ノ ヒカエシツ", MapSelect_LoadGame, ENTRANCE(ZORA_HALL_ROOMS, 0) }, + + // "34: Great Bay" (Great Bay Cutscene: Pirates Approach Temple) + { " 34:" GFXP_KATAKANA "グレートベイ", MapSelect_LoadGame, ENTRANCE(GREAT_BAY_CUTSCENE, 0) }, + + // "35: Mountain Stream Above Falls" (Waterfall Rapids) + { " 35:" GFXP_HIRAGANA "タキウエ ノ ケイリュウ", MapSelect_LoadGame, ENTRANCE(WATERFALL_RAPIDS, 0) }, + + // "40: Rock Building Shaft" (Stone Tower) + { " 40:" GFXP_KATAKANA "ロックビル" GFXP_HIRAGANA " ノ タテアナ", MapSelect_LoadGame, ENTRANCE(STONE_TOWER, 0) }, + + // "40-0: Heaven & Earth Are Overturned" (Stone Tower Cutscene: Tower is Flipped) + { " 40-0:" GFXP_HIRAGANA "テンチ ギャクテン", MapSelect_LoadGame, ENTRANCE(STONE_TOWER_INVERTED, 0) }, + + // "41: Road to Ikana" (Road to Ikana) + { " 41:" GFXP_KATAKANA "イカーナ " GFXP_HIRAGANA "ヘノ ミチ", MapSelect_LoadGame, ENTRANCE(ROAD_TO_IKANA, 0) }, + + // "42: Ancient Castle of Ikana" (Ancient Castle of Ikana) + { " 42:" GFXP_KATAKANA "イカーナ" GFXP_HIRAGANA " コジョウ", MapSelect_LoadGame, ENTRANCE(IKANA_CASTLE, 0) }, + + // "42-0: Ancient Castle of Ikana - Interior" (Ancient Castle of Ikana - Interior) + { " 42-0:" GFXP_KATAKANA "イカーナ" GFXP_HIRAGANA " ノ コジョウ ナイブ", MapSelect_LoadGame, ENTRANCE(IKANA_CASTLE, 3) }, + + // "42-B: Ancient Castle of Ikana - Boss Room" (Ikana King's Throne) + { " 42-B:" GFXP_KATAKANA "イカーナ" GFXP_HIRAGANA " ノ コジョウ " GFXP_KATAKANA "ボス" GFXP_HIRAGANA "ベヤ", + MapSelect_LoadGame, ENTRANCE(IGOS_DU_IKANAS_LAIR, 0) }, + + // "43: Ikana Canyon" (Ikana Canyon) + { " 43:" GFXP_KATAKANA "イカーナ " GFXP_HIRAGANA "ケイコク", MapSelect_LoadGame, ENTRANCE(IKANA_CANYON, 0) }, + + // "43-0: Ikana Canyon Cave" (Sharp's Cave) + { " 43-0:" GFXP_KATAKANA "イカーナ " GFXP_HIRAGANA "ケイコク ドウクツ", MapSelect_LoadGame, ENTRANCE(IKANA_CANYON, 14) }, + + // "43-1: Secom's House" (Sakon's Hideout) + { " 43-1:" GFXP_KATAKANA "セコム " GFXP_HIRAGANA "ノ イエ", MapSelect_LoadGame, ENTRANCE(SAKONS_HIDEOUT, 0) }, + + // "43-2: Music Box House" (Music Box House) + { " 43-2:" GFXP_KATAKANA "オルゴール ハウス", MapSelect_LoadGame, ENTRANCE(MUSIC_BOX_HOUSE, 0) }, + + // "50: Clock Town -East-" (East Clock Town) + { " 50:" GFXP_KATAKANA "クロックタウン " GFXP_HIRAGANA "-ヒガシ-", MapSelect_LoadGame, ENTRANCE(EAST_CLOCK_TOWN, 0) }, + + // "50-0: Town Target Range" (Shooting Gallery) + { " 50-0:" GFXP_HIRAGANA "マチ ノ シャテキジョウ", MapSelect_LoadGame, ENTRANCE(TOWN_SHOOTING_GALLERY, 0) }, + + // "50-1: Honey and Darling's Shop" (Honey & Darling's Shop) + { " 50-1:" GFXP_KATAKANA "ハニー アンド ダーリン " GFXP_HIRAGANA "ノ ミセ", MapSelect_LoadGame, + ENTRANCE(HONEY_AND_DARLINGS_SHOP, 0) }, + + // "50-2: Treasure Chest Shop" (Treasure Chest Shop) + { " 50-2:" GFXP_HIRAGANA "タカラバコヤ", MapSelect_LoadGame, ENTRANCE(TREASURE_CHEST_SHOP, 0) }, + + // "50-3: Pots 'n' Pans Inn" (Stockpot Inn) + { " 50-3:" GFXP_KATAKANA "ナベ" GFXP_HIRAGANA "カマ テイ", MapSelect_LoadGame, ENTRANCE(STOCK_POT_INN, 0) }, + + // "50-4: Mayor's House" (The Mayor's Residence) + { " 50-4:" GFXP_HIRAGANA "チョウチョウ ノ イエ", MapSelect_LoadGame, ENTRANCE(MAYORS_RESIDENCE, 0) }, + + // "50-5: Milk Bar" (Milk Bar) + { " 50-5:" GFXP_KATAKANA "ミルクバー", MapSelect_LoadGame, ENTRANCE(MILK_BAR, 0) }, + + // "51: Clock Town -West-" (West Clock Town) + { " 51:" GFXP_KATAKANA "クロックタウン " GFXP_HIRAGANA "-ニシ-", MapSelect_LoadGame, ENTRANCE(WEST_CLOCK_TOWN, 0) }, + + // "51-0: Bomb Shop" (Bomb Shop) + { " 51-0:" GFXP_HIRAGANA "バクダン ヤ", MapSelect_LoadGame, ENTRANCE(BOMB_SHOP, 0) }, + + // "51-1: Maniac Mart" (Curiosity Shop) + { " 51-1:" GFXP_KATAKANA "マニ" GFXP_HIRAGANA "ヤ", MapSelect_LoadGame, ENTRANCE(CURIOSITY_SHOP, 0) }, + + // "51-2: General Store" (Trading Post) + { " 51-2:" GFXP_HIRAGANA "ザッカ ヤ", MapSelect_LoadGame, ENTRANCE(TRADING_POST, 0) }, + + // "51-3: Sword Dojo" (Swordsman's School) + { " 51-3:" GFXP_HIRAGANA "ケンドウジョウ", MapSelect_LoadGame, ENTRANCE(SWORDMANS_SCHOOL, 0) }, + + // "51-4: Post House" (Post Office) + { " 51-4:" GFXP_HIRAGANA "ポストハウス", MapSelect_LoadGame, ENTRANCE(POST_OFFICE, 0) }, + + // "51-5: Lottery Shop" (Lottery Shop) + { " 51-5:" GFXP_HIRAGANA "タカラクジヤ", MapSelect_LoadGame, ENTRANCE(LOTTERY_SHOP, 0) }, + + // "52: Clock Town -North-" (North Clock Town) + { " 52:" GFXP_KATAKANA "クロックタウン " GFXP_HIRAGANA "-キタ-", MapSelect_LoadGame, ENTRANCE(NORTH_CLOCK_TOWN, 0) }, + + // "53: Clocktown -South-" (South Clock Town) + { " 53:" GFXP_KATAKANA "クロックタウン " GFXP_HIRAGANA "-ミナミ-", MapSelect_LoadGame, ENTRANCE(SOUTH_CLOCK_TOWN, 0) }, + + // "53-0: Clock Tower Interior" (Clock Tower Interior) + { " 53-0:" GFXP_HIRAGANA "トケイトウナイブ", MapSelect_LoadGame, ENTRANCE(CLOCK_TOWER_INTERIOR, 0) }, + + // "54: Clock Tower Rooftop" (Clock Tower Rooftop) + { " 54:" GFXP_HIRAGANA "トケイトウ オクジョウ", MapSelect_LoadGame, ENTRANCE(CLOCK_TOWER_ROOFTOP, 0) }, + + // "55: Laundry Area" (Laundry Pool) + { " 55:" GFXP_HIRAGANA "センタクジョウ", MapSelect_LoadGame, ENTRANCE(LAUNDRY_POOL, 0) }, + + // "55-0: Maniac Mart - Rear Entrance" (Curiosity Shop - Back Room) + { " 55-0:" GFXP_KATAKANA "マニ" GFXP_HIRAGANA "ヤ ノ ウラグチ", MapSelect_LoadGame, ENTRANCE(CURIOSITY_SHOP, 1) }, + + // "55-1: Maniac Mart - Peephole" (Curiosity Shop Back Room - Peephole) + { " 55-1:" GFXP_KATAKANA "マニ" GFXP_HIRAGANA "ヤ ノ ノゾキアナ", MapSelect_LoadGame, ENTRANCE(CURIOSITY_SHOP, 2) }, + + // "100: Wood Mountain Temple" (Woodfall Temple) + { "100:" GFXP_KATAKANA "ウッドマウンテン " GFXP_HIRAGANA "ノ シンデン", MapSelect_LoadGame, ENTRANCE(WOODFALL_TEMPLE, 0) }, + + // "100-B: Wood Mountain Temple - Boss" (Odolwa's Lair) + { "100-B:" GFXP_KATAKANA "ウッドマウンテン " GFXP_HIRAGANA "ノ シンデン" GFXP_KATAKANA "-ボス-", MapSelect_LoadGame, + ENTRANCE(ODOLWAS_LAIR, 0) }, + + // "101: Snowhead Temple" (Snowhead Temple) + { "101:" GFXP_KATAKANA "スノーヘッド " GFXP_HIRAGANA "ノ シンデン", MapSelect_LoadGame, ENTRANCE(SNOWHEAD_TEMPLE, 0) }, + + // "101-B: Snowhead Temple - Boss" (Goht's Lair) + { "101-B:" GFXP_KATAKANA "スノーヘッド " GFXP_HIRAGANA "ノ シンデン" GFXP_KATAKANA "-ボス-", MapSelect_LoadGame, + ENTRANCE(GOHTS_LAIR, 0) }, + + // "102: Great Bay Temple" (Great Bay Temple) + { "102:" GFXP_KATAKANA "グレートベイ " GFXP_HIRAGANA "ノ シンデン", MapSelect_LoadGame, ENTRANCE(GREAT_BAY_TEMPLE, 0) }, + + // "102-B: Great Bay Temple - Boss" (Gyorg's Lair) + { "102-B:" GFXP_KATAKANA "グレートベイ " GFXP_HIRAGANA "ノ シンデン" GFXP_KATAKANA "-ボス-", MapSelect_LoadGame, + ENTRANCE(GYORGS_LAIR, 0) }, + + // "103: Rock Building Temple -Top Side-" (Stone Tower Temple) + { "103:" GFXP_KATAKANA "ロックビル " GFXP_HIRAGANA "ノ シンデン-オモテー", MapSelect_LoadGame, + ENTRANCE(STONE_TOWER_TEMPLE, 0) }, + + // "103-0: Rock Building Temple -Underside-" (Stone Tower Temple - Flipped) + { "103-0:" GFXP_KATAKANA "ロックビル " GFXP_HIRAGANA "ノ シンデン-ウラー", MapSelect_LoadGame, + ENTRANCE(STONE_TOWER_TEMPLE_INVERTED, 0) }, + + // "103-B: Rock Building Temple - Boss" (Twinmold's Lair) + { "103-B:" GFXP_KATAKANA "ロックビル " GFXP_HIRAGANA "ノ シンデン" GFXP_KATAKANA "-ボス-", MapSelect_LoadGame, + ENTRANCE(TWINMOLDS_LAIR, 0) }, + + // "104: Steppe" (On the Moon) + { "104:" GFXP_KATAKANA "ソウゲン", MapSelect_LoadGame, ENTRANCE(THE_MOON, 0) }, + + // "104-0: Last Deku Dungeon" (Deku Trial) + { "104-0:" GFXP_KATAKANA "ラスト デク ダンジョン", MapSelect_LoadGame, ENTRANCE(MOON_DEKU_TRIAL, 0) }, + + // "104-1: Last Goron Dungeon" (Goron Trial) + { "104-1:" GFXP_KATAKANA "ラスト ゴロン ダンジョン", MapSelect_LoadGame, ENTRANCE(MOON_GORON_TRIAL, 0) }, + + // "104-2: Last Zora Dungeon" (Zora Trial) + { "104-2:" GFXP_KATAKANA "ラスト ゾーラ ダンジョン", MapSelect_LoadGame, ENTRANCE(MOON_ZORA_TRIAL, 0) }, + + // "104-3: Last Link Dungeon" (Link Trial) + { "104-3:" GFXP_KATAKANA "ラスト リンク ダンジョン", MapSelect_LoadGame, ENTRANCE(MOON_LINK_TRIAL, 0) }, + + // "104-B: Last Dungeon -Boss-" (Majora's Lair) + { "104-B:" GFXP_KATAKANA "ラストダンジョン -ボス-", MapSelect_LoadGame, ENTRANCE(MAJORAS_LAIR, 0) }, + + // "119: Deku Shrine" (Deku Shrine) + { "119:" GFXP_KATAKANA "デクナッツ " GFXP_HIRAGANA "ノ ホコラ", MapSelect_LoadGame, ENTRANCE(DEKU_SHRINE, 0) }, + + // "121: Secret Shrine" (Secret Shrine) + { "121:" GFXP_HIRAGANA "ヒミツ ノ ホコラ", MapSelect_LoadGame, ENTRANCE(SECRET_SHRINE, 0) }, + + // "122: Opening Dungeon" (Pond Area Cutscene: Falling of the Cliff) + { "122:" GFXP_KATAKANA "オープニング ダンジョン", MapSelect_LoadGame, ENTRANCE(OPENING_DUNGEON, 0) }, + + // "123: Giants' Chamber" (Giants' Chamber) + { "123:" GFXP_HIRAGANA "キョジン ノ マ", MapSelect_LoadGame, ENTRANCE(GIANTS_CHAMBER, 0) }, + + // "126: Deku Minigame" (Deku Rupee Minigame) + { "126:" GFXP_KATAKANA "デクナッツ ミニゲーム", MapSelect_LoadGame, ENTRANCE(DEKU_SCRUB_PLAYGROUND, 0) }, + + // "127-0: Fairy Fountain 0" (Fairy Fountain - Clock Town) + { "127-0:" GFXP_HIRAGANA "ヨウセイ ノ イズミ 0", MapSelect_LoadGame, ENTRANCE(FAIRY_FOUNTAIN, 0) }, + + // "127-1: Fairy Fountain 1" (Fairy Fountain - Woodfall) + { "127-1:" GFXP_HIRAGANA "ヨウセイ ノ イズミ 1", MapSelect_LoadGame, ENTRANCE(FAIRY_FOUNTAIN, 1) }, + + // "127-2: Fairy Fountain 2" (Fairy Fountain - Snowhead) + { "127-2:" GFXP_HIRAGANA "ヨウセイ ノ イズミ 2", MapSelect_LoadGame, ENTRANCE(FAIRY_FOUNTAIN, 2) }, + + // "127-3: Fairy Fountain 3" (Fairy Fountain - Great Bay Coast) + { "127-3:" GFXP_HIRAGANA "ヨウセイ ノ イズミ 3", MapSelect_LoadGame, ENTRANCE(FAIRY_FOUNTAIN, 3) }, + + // "127-4: Fairy Fountain 4" (Fairy Fountain - Ikana Canyon) + { "127-4:" GFXP_HIRAGANA "ヨウセイ ノ イズミ 4", MapSelect_LoadGame, ENTRANCE(FAIRY_FOUNTAIN, 4) }, + + // "128: Swamp Spider Manor" (Swamp Spider House) + { "128:" GFXP_HIRAGANA "ヌマ ノ クモヤカタ", MapSelect_LoadGame, ENTRANCE(SWAMP_SPIDER_HOUSE, 0) }, + + // "129: Ocean Spider Manor" (Oceanside Spider House) + { "129:" GFXP_HIRAGANA "ウミ ノ クモヤカタ", MapSelect_LoadGame, ENTRANCE(OCEANSIDE_SPIDER_HOUSE, 0) }, + + // "130: Beneath the Graves - Dampe" (Beneath the Graveyard) + { "130:" GFXP_HIRAGANA "ハカ ノ シタ-" GFXP_KATAKANA "ダンペイ-", MapSelect_LoadGame, ENTRANCE(DAMPES_HOUSE, 0) }, + + // "131: Beneath the Well" (Beneath the Well) + { "131:" GFXP_HIRAGANA "イド ノ シタ", MapSelect_LoadGame, ENTRANCE(BENEATH_THE_WELL, 0) }, + + // "132: Ghost Hut" (Ghost Hut) + { "132:" GFXP_HIRAGANA "ユウレイゴヤ", MapSelect_LoadGame, ENTRANCE(GHOST_HUT, 0) }, + + // "133-0: Beneath the Graves 0" (Beneath the Graveyard - Part 1) + { "133-0:" GFXP_HIRAGANA "ハカ ノ シタ0", MapSelect_LoadGame, ENTRANCE(BENEATH_THE_GRAVERYARD, 0) }, + + // "133-1: Beneath the Graves 1" (Beneath the Graveyard - Part 2) + { "133-1:" GFXP_HIRAGANA "ハカ ノ シタ1", MapSelect_LoadGame, ENTRANCE(BENEATH_THE_GRAVERYARD, 1) }, + + // "134-0: Secret Grotto 0" (Secret Grotto - Four Gossip Stones) + { "134-0:" GFXP_HIRAGANA "カクシアナ 0", MapSelect_LoadGame, ENTRANCE(GROTTOS, 0) }, + + // "134-1: Secret Grotto 1" (Secret Grotto - Four Gossip Stones, Skulltula) + { "134-1:" GFXP_HIRAGANA "カクシアナ 1", MapSelect_LoadGame, ENTRANCE(GROTTOS, 1) }, + + // "134-2: Secret Grotto 2" (Secret Grotto - Four Gossip Stones, Water Puddles) + { "134-2:" GFXP_HIRAGANA "カクシアナ 2", MapSelect_LoadGame, ENTRANCE(GROTTOS, 2) }, + + // "134-3: Secret Grotto 3" (Secret Grotto - Four Gossip Stones, Water Puddle With Bugs) + { "134-3:" GFXP_HIRAGANA "カクシアナ 3", MapSelect_LoadGame, ENTRANCE(GROTTOS, 3) }, + + // "134-4: Secret Grotto 4" (Secret Grotto - Chest with Blue Rupee, Deku Babas) + { "134-4:" GFXP_HIRAGANA "カクシアナ 4", MapSelect_LoadGame, ENTRANCE(GROTTOS, 4) }, + + // "134-5: Secret Grotto 5" (Secret Grotto - Hot Spring, Deku Babas, Large Stones) + { "134-5:" GFXP_HIRAGANA "カクシアナ5", MapSelect_LoadGame, ENTRANCE(GROTTOS, 5) }, + + // "134-7: Secret Grotto 7" (Secret Grotto - Two Dondogos) + { "134-7:" GFXP_HIRAGANA "カクシアナ 7", MapSelect_LoadGame, ENTRANCE(GROTTOS, 7) }, + + // "134-9: Secret Grotto 9" (Secret Grotto - Tall Grass With Box, Pot, Bugs) + { "134-9:" GFXP_HIRAGANA "カクシアナ 9", MapSelect_LoadGame, ENTRANCE(GROTTOS, 9) }, + + // "134-10: Secret Grotto 10" (Secret Grotto - Two Cows Surrounded by Grass) + { "134-10:" GFXP_HIRAGANA "カクシアナ10", MapSelect_LoadGame, ENTRANCE(GROTTOS, 10) }, + + // "134-11: Secret Grotto 11" (Secret Grotto - Watery Hole Filled with Underwater Babas, Fish) + { "134-11:" GFXP_HIRAGANA "カクシアナ11", MapSelect_LoadGame, ENTRANCE(GROTTOS, 11) }, + + // "134-13: Secret Grotto 13" (Secret Grotto - Peahat in Center) + { "134-13:" GFXP_HIRAGANA "カクシアナ13", MapSelect_LoadGame, ENTRANCE(GROTTOS, 13) }, + + // "X 1: SPOT00" (Opening Cutscene) + { "X 1:SPOT00", MapSelect_LoadGame, ENTRANCE(CUTSCENE, 0) }, + + // "Title" (Title Screen) + { "title", (void*)MapSelect_LoadTitle, 0 }, }; -void Select_UpdateMenu(SelectContext* this) { +void MapSelect_UpdateMenu(MapSelectState* this) { s32 playerForm; - Input* controller1 = CONTROLLER1(this); + Input* controller1 = CONTROLLER1(&this->state); s32 stickY; s32 pad[2]; s16 i; @@ -376,8 +525,7 @@ void Select_UpdateMenu(SelectContext* this) { gSaveContext.minigameState = 0; if (this->scenes[this->currentScene].loadFunc != NULL) { - this->scenes[this->currentScene].loadFunc(this, this->scenes[this->currentScene].entranceIndex, - this->opt); + this->scenes[this->currentScene].loadFunc(this, this->scenes[this->currentScene].entrance, this->opt); } } @@ -544,7 +692,7 @@ void Select_UpdateMenu(SelectContext* this) { this->currentScene++; this->currentScene = (this->currentScene + this->count) % this->count; - if (this->currentScene == ((this->topDisplayedScene + 19 + this->count) % this->count)) { + if (this->currentScene == ((this->topDisplayedScene + this->count + 19) % this->count)) { this->topDisplayedScene++; this->topDisplayedScene = (this->topDisplayedScene + this->count) % this->count; } @@ -553,6 +701,7 @@ void Select_UpdateMenu(SelectContext* this) { if (this->verticalInputAccumulator > 7) { this->verticalInput = 0; this->verticalInputAccumulator = 0; + if (this->currentScene == this->topDisplayedScene) { this->topDisplayedScene -= 2; this->topDisplayedScene = (this->topDisplayedScene + this->count) % this->count; @@ -560,6 +709,7 @@ void Select_UpdateMenu(SelectContext* this) { this->currentScene--; this->currentScene = (this->currentScene + this->count) % this->count; + if (this->currentScene == ((this->topDisplayedScene + this->count) % this->count)) { this->topDisplayedScene--; this->topDisplayedScene = (this->topDisplayedScene + this->count) % this->count; @@ -576,6 +726,7 @@ void Select_UpdateMenu(SelectContext* this) { if (this->timerUp != 0) { this->timerUp--; } + if (this->timerUp == 0) { this->lockUp = false; } @@ -583,19 +734,20 @@ void Select_UpdateMenu(SelectContext* this) { if (this->timerDown != 0) { this->timerDown--; } + if (this->timerDown == 0) { this->lockDown = false; } } -void Select_PrintMenu(SelectContext* this, GfxPrint* printer) { +void MapSelect_PrintMenu(MapSelectState* this, GfxPrint* printer) { s32 i; GfxPrint_SetColor(printer, 255, 155, 150, 255); GfxPrint_SetPos(printer, 12, 2); GfxPrint_Printf(printer, "ZELDA MAP SELECT"); - GfxPrint_SetColor(printer, 255, 255, 255, 255); + for (i = 0; i < 20; i++) { s32 sceneIndex; char* sceneName; @@ -620,62 +772,58 @@ void Select_PrintMenu(SelectContext* this, GfxPrint* printer) { GfxPrint_Printf(printer, "OPT=%d", this->opt); } -// clang-format off static const char* sLoadingMessages[] = { - // "Please wait a minute", - "\x8Dシバラクオマチクダサイ", - // "Hold on a sec", - "\x8Dチョット マッテネ", - // "Wait a moment", - "\x8Cウェイト ア モーメント", - // "Loading", - "\x8Cロード\x8Dチュウ", - // "Now working", - "\x8Dナウ ワーキング", - // "Now creating", - "\x8Dイマ ツクッテマス", - // "It's not broken", - "\x8Dコショウジャナイヨ", - // "Coffee Break", - "\x8Cコーヒー ブレイク", - // "Please set B side", - "\x8C" "Bメンヲセットシテクダサイ", - // "Be patient, now", - "\x8Dジット\x8Cガマン\x8Dノ\x8Cコ\x8Dデアッタ", - // "Please wait just a minute", - "\x8Dイマシバラクオマチクダサイ", - // "Don't worry, don't worry. Take a break, take a break", - "\x8Dアワテナイアワテナイ。ヒトヤスミヒトヤスミ。", + // "Please wait a minute" + GFXP_HIRAGANA "シバラクオマチクダサイ", + // "Hold on a sec" + GFXP_HIRAGANA "チョット マッテネ", + // "Wait a moment" + GFXP_KATAKANA "ウェイト ア モーメント", + // "Loading" + GFXP_KATAKANA "ロード" GFXP_HIRAGANA "チュウ", + // "Now working" + GFXP_HIRAGANA "ナウ ワーキング", + // "Now creating" + GFXP_HIRAGANA "イマ ツクッテマス", + // "It's not broken" + GFXP_HIRAGANA "コショウジャナイヨ", + // "Coffee Break" + GFXP_KATAKANA "コーヒー ブレイク", + // "Please set B side" + GFXP_KATAKANA "Bメンヲセットシテクダサイ", + // "Be patient, now" + GFXP_HIRAGANA "ジット" GFXP_KATAKANA "ガマン" GFXP_HIRAGANA "ノ" GFXP_KATAKANA "コ" GFXP_HIRAGANA "デアッタ", + // "Please wait just a minute" + GFXP_HIRAGANA "イマシバラクオマチクダサイ", + // "Don't worry, don't worry. Take a break, take a break." + GFXP_HIRAGANA "アワテナイアワテナイ。ヒトヤスミヒトヤスミ。", }; -// clang-format on -void Select_PrintLoadingMessage(SelectContext* this, GfxPrint* printer) { - s32 index; +void MapSelect_PrintLoadingMessage(MapSelectState* this, GfxPrint* printer) { + s32 randomMsg; GfxPrint_SetPos(printer, 10, 15); GfxPrint_SetColor(printer, 255, 255, 255, 255); - index = Rand_ZeroOne() * ARRAY_COUNT(sLoadingMessages); - GfxPrint_Printf(printer, "%s", sLoadingMessages[index]); + randomMsg = Rand_ZeroOne() * ARRAY_COUNT(sLoadingMessages); + GfxPrint_Printf(printer, "%s", sLoadingMessages[randomMsg]); } -// clang-format off // Second column is unused static const char* sFormLabel[][2] = { // "17 (Adult)" // 17 (Daitetsujin) - {"\x8D""17(オトナ)", "\x8D""17(ダイテツジン)"}, + { GFXP_HIRAGANA "17(オトナ)", GFXP_HIRAGANA "17(ダイテツジン)" }, // "30 (Goron)" // 30 (Ice Cream -1) - {"\x8C""30(ゴロン)", "\x8C""30(アイスクリーム-1)"}, + { GFXP_KATAKANA "30(ゴロン)", GFXP_KATAKANA "30(アイスクリーム-1)" }, // "78 (Zora)" // 78 (Carmen +1) - {"\x8C""78(ゾーラ)", "\x8C""78(カルメン+1)"}, + { GFXP_KATAKANA "78(ゾーラ)", GFXP_KATAKANA "78(カルメン+1)" }, // "12 (Deku)" // 12 (Majestic) - {"\x8C""12(デクナッツ)", "\x8C""12(マジェスティック)"}, + { GFXP_KATAKANA "12(デクナッツ)", GFXP_KATAKANA "12(マジェスティック)" }, // "5 (Child)" // 5 (NTT Kodomo) - {"\x8D""5(コドモ)", "\x8C""5(NTTコドモ)"}, + { GFXP_HIRAGANA "5(コドモ)", GFXP_KATAKANA "5(NTTコドモ)" }, }; -// clang-format on -void Select_PrintAgeSetting(SelectContext* this, GfxPrint* printer, s32 playerForm) { +void MapSelect_PrintAgeSetting(MapSelectState* this, GfxPrint* printer, s32 playerForm) { s32 pad; const char* age; const char*(*ageTemp)[2]; @@ -706,12 +854,12 @@ void Select_PrintAgeSetting(SelectContext* this, GfxPrint* printer, s32 playerFo GfxPrint_Printf(printer, "Age:%s", age); } else { // clang-format off - GfxPrint_Printf(printer, "Age:" "???" "(%d)", playerForm); + GfxPrint_Printf(printer, "Age:???" "(%d)", playerForm); // clang-format on } } -void Select_PrintCutsceneSetting(SelectContext* this, GfxPrint* printer, u16 csIndex) { +void MapSelect_PrintCutsceneSetting(MapSelectState* this, GfxPrint* printer, u16 csIndex) { const char* stage; const char* day; @@ -723,21 +871,21 @@ void Select_PrintCutsceneSetting(SelectContext* this, GfxPrint* printer, u16 csI case 0: // clang-format off // "Afternoon-jara" - gSaveContext.save.time = CLOCK_TIME(12, 0); stage = "\x8Dオヒル\x8Cジャラ"; + gSaveContext.save.time = CLOCK_TIME(12, 0); stage = GFXP_HIRAGANA "オヒル" GFXP_KATAKANA "ジャラ"; // clang-format on break; case 0x8000: // clang-format off // "Morning-jara" - gSaveContext.save.time = CLOCK_TIME(6, 0) + 1; stage = "\x8Dアサ \x8Cジャラ"; + gSaveContext.save.time = CLOCK_TIME(6, 0) + 1; stage = GFXP_HIRAGANA "アサ " GFXP_KATAKANA "ジャラ"; // clang-format on break; case 0x8800: gSaveContext.save.time = CLOCK_TIME(18, 1); // "Night-jara" - stage = "\x8Dヨル \x8Cジャラ"; + stage = GFXP_HIRAGANA "ヨル " GFXP_KATAKANA "ジャラ"; break; case 0xFFF0: @@ -746,42 +894,52 @@ void Select_PrintCutsceneSetting(SelectContext* this, GfxPrint* printer, u16 csI gSaveContext.save.time = CLOCK_TIME(12, 0); stage = "デモ00"; // clang-format on break; + case 0xFFF1: // "Cutscene 01" stage = "デモ01"; break; + case 0xFFF2: // "Cutscene 02" stage = "デモ02"; break; + case 0xFFF3: // "Cutscene 03" stage = "デモ03"; break; + case 0xFFF4: // "Cutscene 04" stage = "デモ04"; break; + case 0xFFF5: // "Cutscene 05" stage = "デモ05"; break; + case 0xFFF6: // "Cutscene 06" stage = "デモ06"; break; + case 0xFFF7: // "Cutscene 07" stage = "デモ07"; break; + case 0xFFF8: // "Cutscene 08" stage = "デモ08"; break; + case 0xFFF9: // "Cutscene 09" stage = "デモ09"; break; + case 0xFFFA: // "Cutscene 0A" stage = "デモ0A"; @@ -791,8 +949,8 @@ void Select_PrintCutsceneSetting(SelectContext* this, GfxPrint* printer, u16 csI stage = "???"; break; } - gSaveContext.environmentTime = gSaveContext.save.time; - GfxPrint_Printf(printer, "Stage:\x8C%s", stage); + gSaveContext.skyboxTime = gSaveContext.save.time; + GfxPrint_Printf(printer, "Stage:" GFXP_KATAKANA "%s", stage); GfxPrint_SetPos(printer, 23, 25); GfxPrint_SetColor(printer, 255, 255, 55, 255); @@ -800,31 +958,35 @@ void Select_PrintCutsceneSetting(SelectContext* this, GfxPrint* printer, u16 csI switch (gSaveContext.save.day) { case 1: // "The First Day" - day = "\x8Dサイショノヒ"; + day = GFXP_HIRAGANA "サイショノヒ"; break; + case 2: // "The Next Day" - day = "\x8Dツギノヒ"; + day = GFXP_HIRAGANA "ツギノヒ"; break; + case 3: // "The Final Day" - day = "\x8Dサイゴノヒ"; + day = GFXP_HIRAGANA "サイゴノヒ"; break; + case 4: // "Clear Day" - day = "\x8Dクリアーノヒ"; + day = GFXP_HIRAGANA "クリアーノヒ"; break; + default: gSaveContext.save.day = 1; // "The First Day" - day = "\x8Dサイショノヒ"; + day = GFXP_HIRAGANA "サイショノヒ"; break; } - GfxPrint_Printf(printer, "Day:\x8D%s", day); + GfxPrint_Printf(printer, "Day:" GFXP_HIRAGANA "%s", day); } -void Select_DrawMenu(SelectContext* this) { +void MapSelect_DrawMenu(MapSelectState* this) { GraphicsContext* gfxCtx = this->state.gfxCtx; GfxPrint* printer; @@ -836,9 +998,9 @@ void Select_DrawMenu(SelectContext* this) { GfxPrint_Init(printer); GfxPrint_Open(printer, POLY_OPA_DISP); - Select_PrintMenu(this, printer); - Select_PrintAgeSetting(this, printer, ((void)0, gSaveContext.save.playerForm)); - Select_PrintCutsceneSetting(this, printer, ((void)0, gSaveContext.save.cutscene)); + MapSelect_PrintMenu(this, printer); + MapSelect_PrintAgeSetting(this, printer, ((void)0, gSaveContext.save.playerForm)); + MapSelect_PrintCutsceneSetting(this, printer, ((void)0, gSaveContext.save.cutscene)); POLY_OPA_DISP = GfxPrint_Close(printer); GfxPrint_Destroy(printer); @@ -846,7 +1008,7 @@ void Select_DrawMenu(SelectContext* this) { CLOSE_DISPS(gfxCtx); } -void Select_DrawLoadingScreen(SelectContext* this) { +void MapSelect_DrawLoadingScreen(MapSelectState* this) { GraphicsContext* gfxCtx = this->state.gfxCtx; GfxPrint printer; @@ -857,7 +1019,7 @@ void Select_DrawLoadingScreen(SelectContext* this) { GfxPrint_Init(&printer); GfxPrint_Open(&printer, POLY_OPA_DISP); - Select_PrintLoadingMessage(this, &printer); + MapSelect_PrintLoadingMessage(this, &printer); POLY_OPA_DISP = GfxPrint_Close(&printer); GfxPrint_Destroy(&printer); @@ -865,7 +1027,7 @@ void Select_DrawLoadingScreen(SelectContext* this) { CLOSE_DISPS(gfxCtx); } -void Select_Draw(SelectContext* this) { +void MapSelect_Draw(MapSelectState* this) { GraphicsContext* gfxCtx = this->state.gfxCtx; func_8012CF0C(gfxCtx, true, true, 0, 0, 0); @@ -873,28 +1035,28 @@ void Select_Draw(SelectContext* this) { SET_FULLSCREEN_VIEWPORT(&this->view); View_RenderView(&this->view, 0xF); if (!this->state.running) { - Select_DrawLoadingScreen(this); + MapSelect_DrawLoadingScreen(this); } else { - Select_DrawMenu(this); + MapSelect_DrawMenu(this); } } -void Select_Main(GameState* thisx) { - SelectContext* this = (SelectContext*)thisx; +void MapSelect_Main(GameState* thisx) { + MapSelectState* this = (MapSelectState*)thisx; - Select_UpdateMenu(this); - Select_Draw(this); + MapSelect_UpdateMenu(this); + MapSelect_Draw(this); } -void Select_Destroy(GameState* thisx) { +void MapSelect_Destroy(GameState* thisx) { ShrinkWindow_Destroy(); } -void Select_Init(GameState* thisx) { - SelectContext* this = (SelectContext*)thisx; +void MapSelect_Init(GameState* thisx) { + MapSelectState* this = (MapSelectState*)thisx; - this->state.main = Select_Main; - this->state.destroy = Select_Destroy; + this->state.main = MapSelect_Main; + this->state.destroy = MapSelect_Destroy; this->scenes = sScenes; this->topDisplayedScene = 0; diff --git a/src/overlays/gamestates/ovl_select/z_select.h b/src/overlays/gamestates/ovl_select/z_select.h index a454a098b..efe5f9945 100644 --- a/src/overlays/gamestates/ovl_select/z_select.h +++ b/src/overlays/gamestates/ovl_select/z_select.h @@ -3,20 +3,17 @@ #include "global.h" -struct SelectContext; +struct MapSelectState; -void Select_Init(GameState* thisx); -void Select_Destroy(GameState* thisx); - -typedef void (*Select_LoadFunc)(struct SelectContext*, u32, s32); +typedef void (*Select_LoadFunc)(struct MapSelectState*, u32, s32); typedef struct { /* 0x00 */ char* name; /* 0x04 */ Select_LoadFunc loadFunc; - /* 0x08 */ s32 entranceIndex; + /* 0x08 */ s32 entrance; } SceneSelectEntry; // size = 0xC -typedef struct SelectContext { +typedef struct MapSelectState { /* 0x000 */ GameState state; /* 0x0A8 */ View view; /* 0x210 */ s32 count; @@ -36,6 +33,9 @@ typedef struct SelectContext { /* 0x270 */ s32 lockDown; /* 0x274 */ s32 unk_274; // unused /* 0x278 */ UNK_TYPE1 unk_278[0x08]; -} SelectContext; // size = 0x280 +} MapSelectState; // size = 0x280 + +void MapSelect_Init(GameState* thisx); +void MapSelect_Destroy(GameState* thisx); #endif diff --git a/src/overlays/gamestates/ovl_title/z_title.c b/src/overlays/gamestates/ovl_title/z_title.c index afeafe09f..68488b336 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); @@ -91,7 +91,7 @@ void Title_Draw(GameState* thisx) { gDPPipeSync(POLY_OPA_DISP++); gDPSetCycleType(POLY_OPA_DISP++, G_CYC_2CYCLE); - gDPSetRenderMode(POLY_OPA_DISP++, G_RM_XLU_SURF2, G_RM_OPA_CI | CVG_DST_WRAP); + gDPSetRenderMode(POLY_OPA_DISP++, G_RM_PASS, G_RM_CLD_SURF2); gDPSetCombineLERP(POLY_OPA_DISP++, TEXEL1, PRIMITIVE, ENV_ALPHA, TEXEL0, 0, 0, 0, TEXEL0, PRIMITIVE, ENVIRONMENT, COMBINED, ENVIRONMENT, COMBINED, 0, PRIMITIVE, 0); gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, 170, 255, 255, 255); @@ -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); diff --git a/src/overlays/kaleido_scope/ovl_kaleido_scope/z_kaleido_collect.c b/src/overlays/kaleido_scope/ovl_kaleido_scope/z_kaleido_collect.c index aaa7c9fc6..316ad3355 100644 --- a/src/overlays/kaleido_scope/ovl_kaleido_scope/z_kaleido_collect.c +++ b/src/overlays/kaleido_scope/ovl_kaleido_scope/z_kaleido_collect.c @@ -16,6 +16,86 @@ extern UNK_TYPE D_0B000000; extern UNK_TYPE D_0C000000; extern UNK_TYPE D_0C006C00; +s16 D_8082AED0[] = { 120, 60, 2, 80 }; + +s16 D_8082AED8[] = { 20, 4, 20, 10 }; + +s32 D_8082AEE0 = 0; + +s32 D_8082AEE4[] = { 0, 0, 0 }; + +s32 D_8082AEF0[] = { 0, 0, 0, 0, 0 }; + +s16 D_8082AF04[] = { + 255, 0, 0, 255, 255, 70, 0, 150, 255, 70, 0, 150, 255, 0, 0, 255, +}; + +s16 D_8082AF24[] = { + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x003C, 0x0000, 0x005A, 0x0000, 0x0000, + 0x0000, 0x0028, 0x006E, 0x0050, 0x0028, 0x0000, 0x0046, 0x0000, 0x005A, 0x005A, 0x005A, 0x0000, +}; + +s16 D_8082AF6C[] = { + 255, 255, 255, 255, 255, 255, +}; + +s16 D_8082AF78[] = { + 255, 255, 255, 255, 255, 255, +}; + +s16 D_8082AF84[] = { + 150, 150, 150, 150, 150, 150, +}; + +s16 D_8082AF90 = 20; + +s32 D_8082AF94 = 0; + +s32 D_8082AF98 = 0; + +s32 D_8082AF9C = 0; + +s32 D_8082AFA0 = 0; + +s32 D_8082AFA4 = 0; + +s16 D_8082AFA8 = 20; + +s32 D_8082AFAC = 0; + +void* D_8082AFB0[] = { + 0x020024A0, 0x020025A0, 0x020026A0, 0x020027A0, 0x020028A0, +}; + +s16 D_8082AFC4[] = { + 150, 255, 100, 255, 255, 255, 255, 255, 255, 255, 255, 255, +}; + +s16 D_8082AFDC[] = { + 255, 80, 150, 160, 100, 240, 255, 255, 255, 255, 255, 255, +}; + +s16 D_8082AFF4[] = { 100, 40, 255, 0, 255, 100, 255, 255, 255, 255, 255, 255 }; + +void* D_8082B00C[] = { + 0x08053000, 0x08054000, 0x08055000, 0x08056000, 0x08057000, 0x08058000, +}; + +s16 D_8082B024 = 1; + +s16 D_8082B028 = 0; + +s16 D_8082B02C[] = { + 0xFFFF, 0x0003, 0x0002, 0x0001, 0x0000, 0x0004, 0x0003, 0xFFFE, 0x0000, 0x0005, 0x0016, 0x0003, 0x0000, 0x0004, + 0x0002, 0x0001, 0x0001, 0x0014, 0x0005, 0xFFFE, 0x0002, 0x0013, 0x0010, 0x0004, 0x000C, 0xFFFF, 0xFFFD, 0x0007, + 0x000D, 0xFFFF, 0x0006, 0x0008, 0x000E, 0xFFFF, 0x0007, 0x0009, 0x000F, 0xFFFF, 0x0008, 0x000A, 0x0010, 0xFFFF, + 0x0009, 0x0013, 0x0011, 0xFFFF, 0x000A, 0x0005, 0x0012, 0x0006, 0xFFFD, 0x000D, 0x0012, 0x0007, 0x000C, 0x000E, + 0x0016, 0x0008, 0x000D, 0x000F, 0x0016, 0x0009, 0x000E, 0x0010, 0x0016, 0x000A, 0x000F, 0x0005, 0x0016, 0x000B, + 0x0010, 0x0005, 0xFFFF, 0x000C, 0xFFFD, 0x0016, 0x0005, 0xFFFF, 0x000A, 0x0014, 0x0004, 0xFFFF, 0x0013, 0xFFFE, + 0x0013, 0x000C, 0xFFFD, 0x0016, 0xFFFF, 0x0010, 0x0012, 0x0002, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, +}; + #pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_kaleido_scope/func_808160A0.s") #pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_kaleido_scope/func_80817B5C.s") diff --git a/src/overlays/kaleido_scope/ovl_kaleido_scope/z_kaleido_debug.c b/src/overlays/kaleido_scope/ovl_kaleido_scope/z_kaleido_debug.c index 99928bb16..2854b02c6 100644 --- a/src/overlays/kaleido_scope/ovl_kaleido_scope/z_kaleido_debug.c +++ b/src/overlays/kaleido_scope/ovl_kaleido_scope/z_kaleido_debug.c @@ -1,25 +1,1098 @@ /* * File: z_kaleido_debug.c * Overlay: ovl_kaleido_scope - * Description: + * Description: Inventory Editor */ #include "z_kaleido_scope.h" +#include "interface/parameter_static/parameter_static.h" -extern UNK_TYPE D_02001360; -extern UNK_TYPE D_020044A0; -extern UNK_TYPE D_02004AA0; -extern UNK_TYPE D_0200B998; -extern UNK_TYPE D_08062000; -extern UNK_TYPE D_08064340; -extern UNK_TYPE D_0B000000; -extern UNK_TYPE D_0C000000; -extern UNK_TYPE D_0C006C00; +s16 sCurSection = 0; +s16 sCurRow = 0; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_kaleido_scope/func_80818920.s") +// These defines must line up with the indices of sSectionPositions +#define INV_EDITOR_SECTION_RUPEE 0 +#define INV_EDITOR_SECTION_HEALTH_CAPACITY 1 +#define INV_EDITOR_SECTION_HEALTH 2 +#define INV_EDITOR_SECTION_ITEMS 3 +#define INV_EDITOR_SECTION_MASKS 27 +#define INV_EDITOR_SECTION_BOSS 51 +#define INV_EDITOR_SECTION_SWORD 55 +#define INV_EDITOR_SECTION_SHIELD 56 +#define INV_EDITOR_SECTION_SONGS 57 +#define INV_EDITOR_SECTION_LULLABY_INTRO 69 +#define INV_EDITOR_SECTION_NOTEBOOK 70 +#define INV_EDITOR_SECTION_QUIVER 71 +#define INV_EDITOR_SECTION_BOMB_BAG 72 +#define INV_EDITOR_SECTION_SWAMP_GOLD_SKULLS 73 +#define INV_EDITOR_SECTION_OCEAN_GOLD_SKULLS 74 +#define INV_EDITOR_SECTION_HEART_PIECE_COUNT 75 +#define INV_EDITOR_SECTION_SMALL_KEYS 76 +#define INV_EDITOR_SECTION_DUNGEON_ITEMS 80 +#define INV_EDITOR_SECTION_STRAY_FAIRIES 84 +#define INV_EDITOR_SECTION_DOUBLE_DEFENSE 88 -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_kaleido_scope/func_808190C4.s") +// Geometry of the highlights for the selected section +typedef struct { + /* 0 */ s16 screenX; + /* 1 */ s16 screenY; + /* 2 */ s16 width; +} SectionPosition; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_kaleido_scope/func_80819238.s") +// clang-format off +SectionPosition sSectionPositions[] = { + // Rupees (0) + { 65, 14, 41 }, + // Health Capacity (1) + { 145, 14, 21 }, + // Health (2) + { 193, 14, 35 }, + // Items (3) + { 42, 37, 22 }, { 65, 37, 22 }, { 88, 37, 22 }, { 111, 37, 22 }, { 134, 37, 22 }, { 157, 37, 22 }, // row 1 + { 42, 51, 22 }, { 65, 51, 22 }, { 88, 51, 22 }, { 111, 51, 22 }, { 134, 51, 22 }, { 157, 51, 22 }, // row 2 + { 42, 65, 22 }, { 65, 65, 22 }, { 88, 65, 22 }, { 111, 65, 22 }, { 134, 65, 22 }, { 157, 65, 22 }, // row 3 + { 42, 80, 22 }, { 65, 80, 22 }, { 88, 80, 22 }, { 111, 80, 22 }, { 134, 80, 22 }, { 157, 80, 22 }, // row 4 + // Masks (27) + { 202, 37, 14 }, { 215, 37, 14 }, { 229, 37, 14 }, { 243, 37, 14 }, { 257, 37, 14 }, { 271, 37, 14 }, // row 1 + { 202, 51, 14 }, { 215, 51, 14 }, { 229, 51, 14 }, { 243, 51, 14 }, { 257, 51, 14 }, { 271, 51, 14 }, // row 2 + { 202, 65, 14 }, { 215, 65, 14 }, { 229, 65, 14 }, { 243, 65, 14 }, { 257, 65, 14 }, { 271, 65, 14 }, // row 3 + { 202, 80, 14 }, { 215, 80, 14 }, { 229, 80, 14 }, { 243, 80, 14 }, { 257, 80, 14 }, { 271, 80, 14 }, // row 4 + // Boss (51) + { 42, 111, 14 }, { 54, 111, 14 }, { 66, 111, 14 }, { 78, 111, 14 }, + // Sword (55) + { 114, 99, 14 }, + // Shield (56) + { 142, 99, 14 }, + // Songs (57) + { 188, 99, 14 }, { 202, 99, 14 }, { 216, 99, 14 }, { 230, 99, 14 }, { 244, 99, 14 }, { 258, 99, 14 }, + { 188, 113, 14 }, { 202, 113, 14 }, { 216, 113, 14 }, { 230, 113, 14 }, { 244, 113, 14 }, { 258, 113, 14 }, + // Goron Lullaby Intro (69) + { 272, 113, 14 }, + // Bombers Notebook (70) + { 54, 141, 14 }, + // Quiver Upgrade (71) + { 112, 134, 14 }, + // Bomb Bag Upgrade (72) + { 155, 134, 14 }, + // Gold Skulltula Count (73) + { 194, 130, 32 }, { 194, 144, 32 }, + // Heart Piece Count (75) + { 262, 134, 14 }, + // Small Keys (76) + { 43, 168, 14 }, { 55, 168, 14 }, { 67, 168, 14 }, { 79, 168, 14 }, + // Dungeon Items (80) + { 127, 168, 14 }, { 139, 168, 14 }, { 151, 168, 14 }, { 163, 168, 14 }, + // Stray Fairies (84) + { 202, 168, 22 }, { 223, 168, 22 }, { 244, 168, 22 }, { 265, 168, 22 }, + // Life (88) + { 42, 202, 14 }, + // Magic + { 73, 202, 14 }, + // Lottery + { 136, 202, 38 }, + // Gold Color/Bombers Code (not highlighted properly) + { 214, 202, 74 }, { 214, 202, 74 }, +}; +// clang-format on -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_kaleido_scope/func_80819F04.s") +s16 sSlotItems[] = { + // Items Row 1 + ITEM_OCARINA, + ITEM_BOW, + ITEM_ARROW_FIRE, + ITEM_ARROW_ICE, + ITEM_ARROW_LIGHT, + ITEM_OCARINA_FAIRY, + // Items Row 2 + ITEM_BOMB, + ITEM_BOMBCHU, + ITEM_STICK, + ITEM_NUT, + ITEM_MAGIC_BEANS, + ITEM_SLINGSHOT, + // Items Row 3 + ITEM_POWDER_KEG, + ITEM_PICTO_BOX, + ITEM_LENS, + ITEM_HOOKSHOT, + ITEM_SWORD_GREAT_FAIRY, + ITEM_LONGSHOT, + // Items Row 4 + ITEM_BOTTLE, + ITEM_POTION_RED, + ITEM_POTION_GREEN, + ITEM_POTION_BLUE, + ITEM_FAIRY, + ITEM_MUSHROOM, + // Masks Row 1 + ITEM_MASK_POSTMAN, + ITEM_MASK_ALL_NIGHT, + ITEM_MASK_BLAST, + ITEM_MASK_STONE, + ITEM_MASK_GREAT_FAIRY, + ITEM_MASK_DEKU, + // Masks Row 2 + ITEM_MASK_KEATON, + ITEM_MASK_BREMEN, + ITEM_MASK_BUNNY, + ITEM_MASK_DON_GERO, + ITEM_MASK_SCENTS, + ITEM_MASK_GORON, + // Masks Row 3 + ITEM_MASK_ROMANI, + ITEM_MASK_CIRCUS_LEADER, + ITEM_MASK_KAFEIS_MASK, + ITEM_MASK_COUPLE, + ITEM_MASK_TRUTH, + ITEM_MASK_ZORA, + // Masks Row 4 + ITEM_MASK_KAMARO, + ITEM_MASK_GIBDO, + ITEM_MASK_GARO, + ITEM_MASK_CAPTAIN, + ITEM_MASK_GIANT, + ITEM_MASK_FIERCE_DEITY, +}; + +s16 sRowFirstSections[] = { + INV_EDITOR_SECTION_RUPEE, + INV_EDITOR_SECTION_HEALTH_CAPACITY, + INV_EDITOR_SECTION_HEALTH, + INV_EDITOR_SECTION_ITEMS, + INV_EDITOR_SECTION_MASKS, + INV_EDITOR_SECTION_BOSS, + INV_EDITOR_SECTION_SWORD, + INV_EDITOR_SECTION_SHIELD, + INV_EDITOR_SECTION_SONGS, + INV_EDITOR_SECTION_NOTEBOOK, + INV_EDITOR_SECTION_QUIVER, + INV_EDITOR_SECTION_BOMB_BAG, + INV_EDITOR_SECTION_SWAMP_GOLD_SKULLS, + INV_EDITOR_SECTION_HEART_PIECE_COUNT, + INV_EDITOR_SECTION_SMALL_KEYS, + INV_EDITOR_SECTION_DUNGEON_ITEMS, + INV_EDITOR_SECTION_STRAY_FAIRIES, + INV_EDITOR_SECTION_DOUBLE_DEFENSE, +}; + +void KaleidoScope_DrawInventoryEditorText(Gfx** gfxp) { + GfxPrint printer; + s32 pad[2]; + + GfxPrint_Init(&printer); + GfxPrint_Open(&printer, *gfxp); + + // Rupees + GfxPrint_SetPos(&printer, 4, 2); + GfxPrint_SetColor(&printer, 255, 60, 0, 255); + GfxPrint_Printf(&printer, "%s", GFXP_KATAKANA "ルピー"); + + // Hearts + GfxPrint_SetPos(&printer, 15, 2); + GfxPrint_Printf(&printer, "%s", GFXP_KATAKANA "ハート"); + GfxPrint_SetPos(&printer, 15, 3); + GfxPrint_Printf(&printer, "%s", "MAX"); + GfxPrint_SetPos(&printer, 21, 3); + GfxPrint_Printf(&printer, "%s", "NOW"); + GfxPrint_SetPos(&printer, 28, 3); + GfxPrint_Printf(&printer, "%s", "/4"); + + // Items + GfxPrint_SetPos(&printer, 4, 5); + GfxPrint_Printf(&printer, "%s", GFXP_KATAKANA "ア"); + GfxPrint_SetPos(&printer, 4, 6); + GfxPrint_Printf(&printer, "%s", GFXP_KATAKANA "イ"); + GfxPrint_SetPos(&printer, 4, 7); + GfxPrint_Printf(&printer, "%s", GFXP_KATAKANA "テ"); + GfxPrint_SetPos(&printer, 4, 8); + GfxPrint_Printf(&printer, "%s", GFXP_KATAKANA "ム"); + + // Masks + GfxPrint_SetPos(&printer, 24, 5); + GfxPrint_Printf(&printer, "%s", GFXP_KATAKANA "マ"); + GfxPrint_SetPos(&printer, 24, 6); + GfxPrint_Printf(&printer, "%s", GFXP_KATAKANA "ス"); + GfxPrint_SetPos(&printer, 24, 7); + GfxPrint_Printf(&printer, "%s", GFXP_KATAKANA "ク"); + + // Boss (Remains) + GfxPrint_SetPos(&printer, 4, 13); + GfxPrint_Printf(&printer, "%s", "BOSS"); + + // Sword + GfxPrint_SetPos(&printer, 13, 13); + GfxPrint_Printf(&printer, "%s", GFXP_KATAKANA "ケ"); + GfxPrint_SetPos(&printer, 13, 14); + GfxPrint_Printf(&printer, "%s", GFXP_KATAKANA "ン"); + + // Shield + GfxPrint_SetPos(&printer, 17, 13); + GfxPrint_Printf(&printer, "%s", GFXP_KATAKANA "タ"); + GfxPrint_SetPos(&printer, 17, 14); + GfxPrint_Printf(&printer, "%s", GFXP_KATAKANA "テ"); + + // Ocarina (Songs) + GfxPrint_SetPos(&printer, 21, 13); + GfxPrint_Printf(&printer, "%s", GFXP_KATAKANA "オカ"); + GfxPrint_SetPos(&printer, 21, 14); + GfxPrint_Printf(&printer, "%s", GFXP_KATAKANA "リナ"); + + // Schedule (Bombers Notebook) + GfxPrint_SetPos(&printer, 4, 17); + GfxPrint_Printf(&printer, "%s", GFXP_KATAKANA "スケジュール"); + + // Quiver + GfxPrint_SetPos(&printer, 12, 17); + GfxPrint_Printf(&printer, "%s", GFXP_KATAKANA "ヤ"); + GfxPrint_SetPos(&printer, 12, 18); + GfxPrint_Printf(&printer, "%s", GFXP_KATAKANA "タテ"); + + // Bomb Bag + GfxPrint_SetPos(&printer, 16, 17); + GfxPrint_Printf(&printer, "%s", GFXP_KATAKANA "ボム"); + GfxPrint_SetPos(&printer, 16, 18); + GfxPrint_Printf(&printer, "%s", GFXP_KATAKANA "フクロ"); + + // Gold Skulls + GfxPrint_SetPos(&printer, 22, 17); + GfxPrint_Printf(&printer, "%s", GFXP_KATAKANA "キン"); + GfxPrint_SetPos(&printer, 22, 18); + GfxPrint_Printf(&printer, "%s", GFXP_KATAKANA "スタ"); + + // Heart Pieces + GfxPrint_SetPos(&printer, 29, 17); + GfxPrint_Printf(&printer, "%s", GFXP_KATAKANA "ハート"); + GfxPrint_SetPos(&printer, 29, 18); + GfxPrint_Printf(&printer, "%s", GFXP_KATAKANA "カケラ"); + GfxPrint_SetPos(&printer, 34, 18); + GfxPrint_Printf(&printer, "%s", "/4"); + + // Keys + GfxPrint_SetPos(&printer, 4, 21); + GfxPrint_Printf(&printer, "%s", GFXP_KATAKANA "カ"); + GfxPrint_SetPos(&printer, 4, 22); + GfxPrint_Printf(&printer, "%s", GFXP_KATAKANA "ギ"); + + // Map/Compass + GfxPrint_SetPos(&printer, 12, 21); + GfxPrint_Printf(&printer, "%s", "MAP"); + GfxPrint_SetPos(&printer, 12, 22); + GfxPrint_Printf(&printer, "%s", "コンパ"); + + // Fairies + GfxPrint_SetPos(&printer, 23, 21); + GfxPrint_Printf(&printer, "%s", "ヨウ"); + GfxPrint_SetPos(&printer, 23, 22); + GfxPrint_Printf(&printer, "%s", "セイ"); + + // Life (double defence) + GfxPrint_SetPos(&printer, 4, 25); + GfxPrint_Printf(&printer, "%s", "イ"); + GfxPrint_SetPos(&printer, 4, 26); + GfxPrint_Printf(&printer, "%s", "ノ"); + GfxPrint_SetPos(&printer, 4, 27); + GfxPrint_Printf(&printer, "%s", "チ"); + + // Magic + GfxPrint_SetPos(&printer, 8, 25); + GfxPrint_Printf(&printer, "%s", "マ"); + GfxPrint_SetPos(&printer, 8, 26); + GfxPrint_Printf(&printer, "%s", "ホ"); + GfxPrint_SetPos(&printer, 8, 27); + GfxPrint_Printf(&printer, "%s", "ウ"); + + // Lottery + GfxPrint_SetPos(&printer, 13, 25); + GfxPrint_Printf(&printer, "%s", "タカラ"); + GfxPrint_SetPos(&printer, 13, 26); + GfxPrint_Printf(&printer, "%s", "クジ"); + + // Gold Color (Oceanside Spider House Mask Order) + GfxPrint_SetPos(&printer, 23, 24); + GfxPrint_Printf(&printer, "%s", "キンイロ"); + + // Bombers (code) + GfxPrint_SetPos(&printer, 23, 26); + GfxPrint_Printf(&printer, "%s", "ボン"); + GfxPrint_SetPos(&printer, 23, 27); + GfxPrint_Printf(&printer, "%s", "バーズ"); + + *gfxp = GfxPrint_Close(&printer); + GfxPrint_Destroy(&printer); +} + +void KaleidoScope_DrawDigit(PlayState* play, s32 digit, s32 rectLeft, s32 rectTop) { + OPEN_DISPS(play->state.gfxCtx); + + gDPLoadTextureBlock(POLY_OPA_DISP++, ((u8*)gCounterDigit0Tex + (8 * 16 * digit)), G_IM_FMT_I, G_IM_SIZ_8b, 8, 16, 0, + G_TX_NOMIRROR | G_TX_CLAMP, G_TX_NOMIRROR | G_TX_CLAMP, G_TX_NOMASK, G_TX_NOMASK, G_TX_NOLOD, + G_TX_NOLOD); + gSPTextureRectangle(POLY_OPA_DISP++, rectLeft << 2, rectTop << 2, (rectLeft + 8) << 2, (rectTop + 16) << 2, + G_TX_RENDERTILE, 0, 0, 1 << 10, 1 << 10); + + CLOSE_DISPS(play->state.gfxCtx); +} + +void KaleidoScope_DrawInventoryEditor(PlayState* play) { + Gfx* gfx; + Gfx* gfxRef; + s32 counterDigits[4]; + s16 slot; + s16 i; + s16 j; + s32 rectLeft; + s32 rectTop; + + OPEN_DISPS(play->state.gfxCtx); + + func_8012C628(play->state.gfxCtx); + + gDPSetRenderMode(POLY_OPA_DISP++, G_RM_XLU_SURF, G_RM_XLU_SURF2); + gDPSetCombineMode(POLY_OPA_DISP++, G_CC_PRIMITIVE, G_CC_PRIMITIVE); + gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, 0, 0, 0, 220); + gDPFillRectangle(POLY_OPA_DISP++, 24, 12, 298, 228); + gDPPipeSync(POLY_OPA_DISP++); + gDPSetCombineLERP(POLY_OPA_DISP++, 0, 0, 0, PRIMITIVE, TEXEL0, 0, PRIMITIVE, 0, 0, 0, 0, PRIMITIVE, TEXEL0, 0, + PRIMITIVE, 0); + + gfxRef = POLY_OPA_DISP; + gfx = Graph_GfxPlusOne(gfxRef); + gSPDisplayList(OVERLAY_DISP++, gfx); + + KaleidoScope_DrawInventoryEditorText(&gfx); + + gSPEndDisplayList(gfx++); + Graph_BranchDlist(gfxRef, gfx); + POLY_OPA_DISP = gfx; + + gDPPipeSync(POLY_OPA_DISP++); + gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, 255, 0, 0, 255); + gDPSetEnvColor(POLY_OPA_DISP++, 0, 0, 0, 0); + + // Current Health Quarter (X / 4) + KaleidoScope_DrawDigit(play, (((void)0, gSaveContext.save.playerData.health) % 0x10) / 4, 217, 15); + + gDPPipeSync(POLY_OPA_DISP++); + gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, 255, 255, 255, 255); + + // Rupees + counterDigits[0] = counterDigits[1] = counterDigits[2] = 0; + counterDigits[3] = gSaveContext.save.playerData.rupees; + while (counterDigits[3] >= 1000) { + counterDigits[0]++; + counterDigits[3] -= 1000; + } + + while (counterDigits[3] >= 100) { + counterDigits[1]++; + counterDigits[3] -= 100; + } + + while (counterDigits[3] >= 10) { + counterDigits[2]++; + counterDigits[3] -= 10; + } + + // Loop over columns (i) + for (i = 0, rectLeft = 68; i < 4; i++, rectLeft += 9) { + KaleidoScope_DrawDigit(play, counterDigits[i], rectLeft, 15); + } + + // Health capacity + counterDigits[2] = 0; + counterDigits[3] = gSaveContext.save.playerData.healthCapacity / 0x10; + while (counterDigits[3] >= 10) { + counterDigits[2]++; + counterDigits[3] -= 10; + } + + KaleidoScope_DrawDigit(play, counterDigits[2], 145, 15); + KaleidoScope_DrawDigit(play, counterDigits[3], 154, 15); + + // Health + counterDigits[2] = 0; + counterDigits[3] = gSaveContext.save.playerData.health / 0x10; + while (counterDigits[3] >= 10) { + counterDigits[2]++; + counterDigits[3] -= 10; + } + + KaleidoScope_DrawDigit(play, counterDigits[2], 195, 15); + KaleidoScope_DrawDigit(play, counterDigits[3], 204, 15); + + // Items + // Loop over rows (i) + for (slot = 0, i = 0, rectTop = 38; i < 4; i++, rectTop += 14) { + // Loop over columns (j) + for (j = 0, rectLeft = 44; j < 6; j++, slot++, rectLeft += 23) { + counterDigits[3] = 0; + counterDigits[2] = 0; + if ((slot == SLOT_BOW) || ((slot >= SLOT_BOMB) && (slot <= SLOT_NUT)) || (slot == SLOT_POWDER_KEG) || + (slot == SLOT_MAGIC_BEANS)) { + counterDigits[3] = AMMO(gAmmoItems[slot]); + } else if ((slot == SLOT_TRADE_DEED) || (slot == SLOT_TRADE_KEY_MAMA) || (slot == SLOT_TRADE_COUPLE)) { + counterDigits[3] = gSaveContext.save.inventory.items[slot]; + } else if (slot >= SLOT_BOTTLE_1) { + counterDigits[3] = gSaveContext.save.inventory.items[slot]; + } else if (gSaveContext.save.inventory.items[slot] != ITEM_NONE) { + counterDigits[3] = 1; + } + + if (counterDigits[3] != ITEM_NONE) { + while (counterDigits[3] >= 10) { + counterDigits[2]++; + counterDigits[3] -= 10; + } + } else { + counterDigits[2] = counterDigits[3] = 0; + } + + if (counterDigits[2] != 0) { + KaleidoScope_DrawDigit(play, counterDigits[2], rectLeft, rectTop); + } + KaleidoScope_DrawDigit(play, counterDigits[3], rectLeft + 9, rectTop); + } + } + + // Masks + // Loop over rows (i) + for (slot = 0, i = 0, rectTop = 38; i < 4; i++, rectTop += 14) { + // Loop over columns (j) + for (j = 0, rectLeft = 204; j < 6; j++, slot++, rectLeft += 14) { + counterDigits[2] = 0; + + if (gSaveContext.save.inventory.items[SLOT_MASK_POSTMAN + slot] != ITEM_NONE) { + counterDigits[2] = 1; + } + KaleidoScope_DrawDigit(play, counterDigits[2], rectLeft, rectTop); + } + } + + // Boss Remains + // Loop over columns (i), (counterDigits[1] stores rectLeft) + for (counterDigits[1] = 44, i = 0; i < 4; i++) { + counterDigits[2] = 0; + if (CHECK_QUEST_ITEM(QUEST_REMAINS_ODOWLA + i)) { + counterDigits[2] = 1; + } + KaleidoScope_DrawDigit(play, counterDigits[2], counterDigits[1], 112); + counterDigits[1] += 14; + } + + // Sword + KaleidoScope_DrawDigit(play, GET_CUR_EQUIP_VALUE(EQUIP_TYPE_SWORD), 116, 100); + + // Shield + KaleidoScope_DrawDigit(play, GET_CUR_EQUIP_VALUE(EQUIP_TYPE_SHIELD), 145, 100); + + // Songs + // Loop over rows (j), (counterDigits[3] stores rectTop) + for (counterDigits[3] = 100, j = 0, slot = 0; j < 2; j++) { + // Loop over columns (i), (counterDigits[1] stores rectLeft) + for (counterDigits[1] = 190, i = 0; i < 6; i++, slot++) { + counterDigits[2] = 0; + if (CHECK_QUEST_ITEM(QUEST_SONG_SONATA + slot)) { + counterDigits[2] = 1; + } + KaleidoScope_DrawDigit(play, counterDigits[2], counterDigits[1], counterDigits[3]); + counterDigits[1] += 14; + } + counterDigits[3] += 14; + } + + // Goron Lullaby Intro + counterDigits[2] = 0; + counterDigits[3] -= 14; + if (CHECK_QUEST_ITEM(QUEST_SONG_LULLABY_INTRO)) { + counterDigits[2] = 1; + } + KaleidoScope_DrawDigit(play, counterDigits[2], counterDigits[1], counterDigits[3]); + + // Bombers Notebook + counterDigits[2] = 0; + if (CHECK_QUEST_ITEM(QUEST_BOMBERS_NOTEBOOK)) { + counterDigits[2] = 1; + } + KaleidoScope_DrawDigit(play, counterDigits[2], 56, 142); + + // Quiver + KaleidoScope_DrawDigit(play, CUR_UPG_VALUE(UPG_QUIVER), 114, 134); + + // Bomb Bag + KaleidoScope_DrawDigit(play, CUR_UPG_VALUE(UPG_BOMB_BAG), 156, 134); + + // Gold Skulls (Swamp Spider House) + counterDigits[2] = 0; + counterDigits[1] = 0; + counterDigits[3] = Inventory_GetSkullTokenCount(SCENE_KINSTA1); + + while (counterDigits[3] >= 100) { + counterDigits[3] -= 100; + counterDigits[1]++; + } + + while (counterDigits[3] >= 10) { + counterDigits[3] -= 10; + counterDigits[2]++; + } + + KaleidoScope_DrawDigit(play, counterDigits[1], 196, 130); + KaleidoScope_DrawDigit(play, counterDigits[2], 205, 130); + KaleidoScope_DrawDigit(play, counterDigits[3], 214, 130); + + // Gold Skulls (Oceans Spider House) + counterDigits[2] = 0; + counterDigits[1] = 0; + counterDigits[3] = Inventory_GetSkullTokenCount(SCENE_KINDAN2); + + while (counterDigits[3] >= 100) { + counterDigits[3] -= 100; + counterDigits[1]++; + } + + while (counterDigits[3] >= 10) { + counterDigits[3] -= 10; + counterDigits[2]++; + } + + KaleidoScope_DrawDigit(play, counterDigits[1], 196, 144); + KaleidoScope_DrawDigit(play, counterDigits[2], 205, 144); + KaleidoScope_DrawDigit(play, counterDigits[3], 214, 144); + + // Heart Pieces + KaleidoScope_DrawDigit(play, GET_QUEST_HEART_PIECE_COUNT, 264, 134); + + // Keys + // Loop over columns (i), (counterDigits[1] stores rectLeft) + for (counterDigits[1] = 45, i = 0; i < 4; i++) { + counterDigits[2] = 0; + + if ((counterDigits[3] = DUNGEON_KEY_COUNT(i)) >= 0) { + while (counterDigits[3] >= 10) { + counterDigits[2]++; + counterDigits[3] -= 10; + } + } else { + counterDigits[2] = counterDigits[3] = 0; + } + + KaleidoScope_DrawDigit(play, counterDigits[3], counterDigits[1], 168); + counterDigits[1] += 12; + } + + // Dungeon Items + // Loop over columns (i), (counterDigits[1] stores rectLeft) + for (counterDigits[1] = 129, i = 0; i < 4; i++) { + counterDigits[2] = gSaveContext.save.inventory.dungeonItems[i] & gEquipMasks[0]; + KaleidoScope_DrawDigit(play, counterDigits[2], counterDigits[1], 168); + counterDigits[1] += 12; + } + + // Stray Fairies + // Loop over columns (i), (counterDigits[1] stores rectLeft) + for (counterDigits[1] = 202, i = 0; i < 4; i++) { + counterDigits[3] = gSaveContext.save.inventory.strayFairies[i]; + counterDigits[2] = counterDigits[3] / 10; + counterDigits[3] -= counterDigits[2] * 10; + if (counterDigits[2] != 0) { + KaleidoScope_DrawDigit(play, counterDigits[2], counterDigits[1], 168); + } + KaleidoScope_DrawDigit(play, counterDigits[3], counterDigits[1] + 9, 168); + counterDigits[1] += 21; + } + + // Double Defence + KaleidoScope_DrawDigit(play, gSaveContext.save.playerData.doubleDefense, 44, 202); + + // Magic + //! @bug should be gSaveContext.save.playerData.doubleMagic + KaleidoScope_DrawDigit(play, gSaveContext.save.playerData.doubleDefense, 75, 202); + + // Lottery + // Loop over columns (i), (counterDigits[1] stores rectLeft) + for (counterDigits[1] = 139, i = 0; i < 3; i++) { + counterDigits[2] = gSaveContext.save.lotteryCodes[0][i]; + + KaleidoScope_DrawDigit(play, counterDigits[2], counterDigits[1], 184); + counterDigits[2] = gSaveContext.save.lotteryCodes[1][i]; + KaleidoScope_DrawDigit(play, counterDigits[2], counterDigits[1], 198); + + counterDigits[2] = gSaveContext.save.lotteryCodes[2][i]; + KaleidoScope_DrawDigit(play, counterDigits[2], counterDigits[1], 212); + + counterDigits[1] += 12; + } + + // Oceanside Spider House Mask Order + // Loop over columns (i), (counterDigits[1] stores rectLeft) + for (counterDigits[1] = 217, i = 0; i < 6; i++) { + counterDigits[2] = gSaveContext.save.spiderHouseMaskOrder[i]; + KaleidoScope_DrawDigit(play, counterDigits[2], counterDigits[1], 186); + + counterDigits[1] += 12; + } + + // Bombers code + // Loop over columns (i), (counterDigits[1] stores rectLeft) + for (counterDigits[1] = 220, i = 0; i < 5; i++) { + counterDigits[2] = gSaveContext.save.bomberCode[i]; + KaleidoScope_DrawDigit(play, counterDigits[2], counterDigits[1], 210); + + counterDigits[1] += 12; + } + + // Draws a highlight on the selected section + gDPPipeSync(POLY_OPA_DISP++); + gDPSetRenderMode(POLY_OPA_DISP++, G_RM_XLU_SURF, G_RM_XLU_SURF2); + gDPSetCombineMode(POLY_OPA_DISP++, G_CC_PRIMITIVE, G_CC_PRIMITIVE); + gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, 0, 0, 200, 120); + + gDPFillRectangle(POLY_OPA_DISP++, sSectionPositions[sCurSection].screenX, sSectionPositions[sCurSection].screenY, + sSectionPositions[sCurSection].screenX + sSectionPositions[sCurSection].width, + sSectionPositions[sCurSection].screenY + 15); + + CLOSE_DISPS(play->state.gfxCtx); +} + +void KaleidoScope_UpdateInventoryEditor(PlayState* play) { + static s32 sPrevDBtnInput = 0; + static s32 sHeldDBtnTimer = 0; + PauseContext* pauseCtx = &play->pauseCtx; + Input* input = CONTROLLER1(&play->state); + s16 slot; + s16 value; + s32 dBtnInput = input->cur.button & (BTN_DUP | BTN_DDOWN | BTN_DLEFT | BTN_DRIGHT); + + pauseCtx->stickRelX = input->rel.stick_x; + pauseCtx->stickRelY = input->rel.stick_y; + + // Handles navigating the menu to different sections with the D-Pad + // When the same direction is held, registers the input periodically based on a timer + if (dBtnInput == sPrevDBtnInput) { + sHeldDBtnTimer--; + if (sHeldDBtnTimer < 0) { + sHeldDBtnTimer = 1; + } else { + dBtnInput ^= sPrevDBtnInput; + } + } else { + sPrevDBtnInput = dBtnInput; + sHeldDBtnTimer = 16; + } + + if (CHECK_BTN_ANY(dBtnInput, BTN_DDOWN)) { + sCurRow++; + if (sCurRow > 17) { + sCurRow = 0; + } + sCurSection = sRowFirstSections[sCurRow]; + } else if (CHECK_BTN_ANY(dBtnInput, BTN_DUP)) { + sCurRow--; + if (sCurRow < 0) { + sCurRow = 17; + } + sCurSection = sRowFirstSections[sCurRow]; + } else if (CHECK_BTN_ANY(dBtnInput, BTN_DLEFT)) { + sCurSection--; + if (sCurSection < 0) { + sCurSection = ARRAY_COUNT(sSectionPositions) - 1; + } + } else if (CHECK_BTN_ANY(dBtnInput, BTN_DRIGHT)) { + sCurSection++; + if (sCurSection > (ARRAY_COUNT(sSectionPositions) - 1)) { + sCurSection = 0; + } + } + + // Handles the logic to change values based on the selected section + switch (sCurSection) { + case INV_EDITOR_SECTION_RUPEE: + // Rupees + if (CHECK_BTN_ALL(input->press.button, BTN_CUP)) { + gSaveContext.save.playerData.rupees -= 100; + if (gSaveContext.save.playerData.rupees < 0) { + gSaveContext.save.playerData.rupees = 0; + } + } else if (CHECK_BTN_ALL(input->press.button, BTN_CDOWN)) { + gSaveContext.save.playerData.rupees += 100; + if (gSaveContext.save.playerData.rupees >= 9999) { + gSaveContext.save.playerData.rupees = 9999; + } + } else if (CHECK_BTN_ALL(input->press.button, BTN_CLEFT)) { + gSaveContext.save.playerData.rupees--; + if (gSaveContext.save.playerData.rupees < 0) { + gSaveContext.save.playerData.rupees = 0; + } + } else if (CHECK_BTN_ALL(input->press.button, BTN_CRIGHT)) { + gSaveContext.save.playerData.rupees++; + if (gSaveContext.save.playerData.rupees >= 9999) { + gSaveContext.save.playerData.rupees = 9999; + } + } + break; + + case INV_EDITOR_SECTION_HEALTH_CAPACITY: + // Health Capacity + if (CHECK_BTN_ALL(input->press.button, BTN_CUP) || CHECK_BTN_ALL(input->press.button, BTN_CLEFT)) { + gSaveContext.save.playerData.healthCapacity -= 0x10; + if (gSaveContext.save.playerData.healthCapacity < 0x30) { + gSaveContext.save.playerData.healthCapacity = 0x30; + } + } else if (CHECK_BTN_ALL(input->press.button, BTN_CDOWN) || + CHECK_BTN_ALL(input->press.button, BTN_CRIGHT)) { + gSaveContext.save.playerData.healthCapacity += 0x10; + if (gSaveContext.save.playerData.healthCapacity >= 0x140) { + gSaveContext.save.playerData.healthCapacity = 0x140; + } + } + break; + + case INV_EDITOR_SECTION_HEALTH: + // Health + if (CHECK_BTN_ALL(input->press.button, BTN_CLEFT)) { + Health_ChangeBy(play, -4); + } else if (CHECK_BTN_ALL(input->press.button, BTN_CRIGHT)) { + Health_ChangeBy(play, 4); + } else if (CHECK_BTN_ALL(input->press.button, BTN_CUP)) { + Health_ChangeBy(play, -0x10); + } else if (CHECK_BTN_ALL(input->press.button, BTN_CDOWN)) { + Health_ChangeBy(play, 0x10); + } + break; + + case INV_EDITOR_SECTION_HEART_PIECE_COUNT: + // Heart Piece Count + if (CHECK_BTN_ALL(input->press.button, BTN_CUP) || CHECK_BTN_ALL(input->press.button, BTN_CLEFT)) { + if (GET_QUEST_HEART_PIECE_COUNT != 0) { + DECREMENT_QUEST_HEART_PIECE_COUNT; + } + } else if (CHECK_BTN_ALL(input->press.button, BTN_CDOWN) || + CHECK_BTN_ALL(input->press.button, BTN_CRIGHT)) { + if (LEQ_MAX_QUEST_HEART_PIECE_COUNT) { + INCREMENT_QUEST_HEART_PIECE_COUNT; + } + } + break; + + default: + if (sCurSection < INV_EDITOR_SECTION_BOSS) { + // Items + slot = sCurSection - INV_EDITOR_SECTION_ITEMS; + if ((slot == SLOT_BOW) || ((slot >= SLOT_BOMB) && (slot <= SLOT_NUT)) || (slot == SLOT_POWDER_KEG) || + (slot == SLOT_MAGIC_BEANS)) { + if (CHECK_BTN_ALL(input->press.button, BTN_CUP)) { + Inventory_DeleteItem(gAmmoItems[slot], SLOT(gAmmoItems[slot])); + AMMO(gAmmoItems[slot]) = 0; + } + + if (CHECK_BTN_ALL(input->press.button, BTN_CRIGHT)) { + if (slot != INV_CONTENT(gAmmoItems[slot])) { + INV_CONTENT(gAmmoItems[slot]) = gAmmoItems[slot]; + } + AMMO(gAmmoItems[slot])++; + if (AMMO(gAmmoItems[slot]) > 99) { + AMMO(gAmmoItems[slot]) = 99; + } + } else if (CHECK_BTN_ALL(input->press.button, BTN_CLEFT)) { + AMMO(gAmmoItems[slot])--; + if (AMMO(gAmmoItems[slot]) < 0) { + AMMO(gAmmoItems[slot]) = 0; + } + } + } else if ((slot == SLOT_TRADE_DEED) || (slot == SLOT_TRADE_KEY_MAMA) || (slot == SLOT_TRADE_COUPLE)) { + if (CHECK_BTN_ALL(input->press.button, BTN_CUP)) { + value = sSlotItems[slot]; + Inventory_DeleteItem(value, slot); + } else if (slot == SLOT_TRADE_DEED) { + if (CHECK_BTN_ALL(input->press.button, BTN_CRIGHT)) { + if (INV_CONTENT(ITEM_MOON_TEAR) == ITEM_NONE) { + gSaveContext.save.inventory.items[slot] = ITEM_MOON_TEAR; + } else if ((INV_CONTENT(ITEM_MOON_TEAR) >= ITEM_MOON_TEAR) && + (INV_CONTENT(ITEM_MOON_TEAR) <= ITEM_DEED_MOUNTAIN)) { + gSaveContext.save.inventory.items[slot] = INV_CONTENT(ITEM_MOON_TEAR) + 1; + } + } else if (CHECK_BTN_ALL(input->press.button, BTN_CLEFT)) { + if (INV_CONTENT(ITEM_MOON_TEAR) == ITEM_NONE) { + gSaveContext.save.inventory.items[slot] = ITEM_DEED_OCEAN; + } else if ((INV_CONTENT(ITEM_MOON_TEAR) >= ITEM_DEED_LAND) && + (INV_CONTENT(ITEM_MOON_TEAR) <= ITEM_DEED_OCEAN)) { + gSaveContext.save.inventory.items[slot] = INV_CONTENT(ITEM_MOON_TEAR) - 1; + } + } + } else if (slot == SLOT_TRADE_KEY_MAMA) { + if (CHECK_BTN_ALL(input->press.button, BTN_CRIGHT)) { + if (INV_CONTENT(ITEM_ROOM_KEY) == ITEM_NONE) { + gSaveContext.save.inventory.items[slot] = ITEM_ROOM_KEY; + } else if ((INV_CONTENT(ITEM_ROOM_KEY) >= ITEM_ROOM_KEY) && + (INV_CONTENT(ITEM_ROOM_KEY) <= ITEM_ROOM_KEY)) { + gSaveContext.save.inventory.items[slot] = INV_CONTENT(ITEM_ROOM_KEY) + 1; + } + } else if (CHECK_BTN_ALL(input->press.button, BTN_CLEFT)) { + if (INV_CONTENT(ITEM_ROOM_KEY) == ITEM_NONE) { + gSaveContext.save.inventory.items[slot] = ITEM_LETTER_MAMA; + } else if ((INV_CONTENT(ITEM_ROOM_KEY) >= ITEM_LETTER_MAMA) && + (INV_CONTENT(ITEM_ROOM_KEY) <= ITEM_LETTER_MAMA)) { + gSaveContext.save.inventory.items[slot] = INV_CONTENT(ITEM_ROOM_KEY) - 1; + } + } + } else if (CHECK_BTN_ALL(input->press.button, BTN_CRIGHT)) { + if (INV_CONTENT(ITEM_LETTER_TO_KAFEI) == ITEM_NONE) { + gSaveContext.save.inventory.items[slot] = ITEM_LETTER_TO_KAFEI; + } else if ((INV_CONTENT(ITEM_LETTER_TO_KAFEI) >= ITEM_LETTER_TO_KAFEI) && + (INV_CONTENT(ITEM_LETTER_TO_KAFEI) <= ITEM_LETTER_TO_KAFEI)) { + gSaveContext.save.inventory.items[slot] = INV_CONTENT(ITEM_LETTER_TO_KAFEI) + 1; + } + } else if (CHECK_BTN_ALL(input->press.button, BTN_CLEFT)) { + if (INV_CONTENT(ITEM_LETTER_TO_KAFEI) == ITEM_NONE) { + gSaveContext.save.inventory.items[slot] = ITEM_PENDANT_OF_MEMORIES; + } else if ((INV_CONTENT(ITEM_LETTER_TO_KAFEI) >= ITEM_PENDANT_OF_MEMORIES) && + (INV_CONTENT(ITEM_LETTER_TO_KAFEI) <= ITEM_PENDANT_OF_MEMORIES)) { + gSaveContext.save.inventory.items[slot] = INV_CONTENT(ITEM_LETTER_TO_KAFEI) - 1; + } + } + } else if ((slot >= SLOT_BOTTLE_1) && (slot <= SLOT_BOTTLE_6)) { + if (CHECK_BTN_ALL(input->press.button, BTN_CUP)) { + value = ITEM_BOTTLE + slot - SLOT_BOTTLE_1; + Inventory_DeleteItem(value, SLOT(ITEM_BOTTLE) + slot - SLOT_BOTTLE_1); + } else if (CHECK_BTN_ALL(input->press.button, BTN_CRIGHT)) { + if (gSaveContext.save.inventory.items[slot] == ITEM_NONE) { + gSaveContext.save.inventory.items[slot] = ITEM_BOTTLE; + } else if ((gSaveContext.save.inventory.items[slot] >= ITEM_BOTTLE) && + (gSaveContext.save.inventory.items[slot] <= ITEM_HYLIAN_LOACH)) { + gSaveContext.save.inventory.items[slot] = gSaveContext.save.inventory.items[slot] + 1; + } + } else if (CHECK_BTN_ALL(input->press.button, BTN_CLEFT)) { + if (gSaveContext.save.inventory.items[slot] == ITEM_NONE) { + gSaveContext.save.inventory.items[slot] = ITEM_OBABA_DRINK; + } else if ((gSaveContext.save.inventory.items[slot] >= ITEM_POTION_RED) && + (gSaveContext.save.inventory.items[slot] <= ITEM_OBABA_DRINK)) { + gSaveContext.save.inventory.items[slot] = gSaveContext.save.inventory.items[slot] - 1; + } + } + } else { + if (CHECK_BTN_ALL(input->press.button, BTN_CUP) || CHECK_BTN_ALL(input->press.button, BTN_CLEFT) || + CHECK_BTN_ALL(input->press.button, BTN_CDOWN) || + CHECK_BTN_ALL(input->press.button, BTN_CRIGHT)) { + value = sSlotItems[slot]; + if (gSaveContext.save.inventory.items[slot] == ITEM_NONE) { + INV_CONTENT(value) = value; + } else { + Inventory_DeleteItem(value, slot); + } + } + } + + } else if (sCurSection == INV_EDITOR_SECTION_SWORD) { + // Sword + value = GET_CUR_EQUIP_VALUE(EQUIP_TYPE_SWORD); + if (CHECK_BTN_ALL(input->press.button, BTN_CUP) || CHECK_BTN_ALL(input->press.button, BTN_CLEFT)) { + value--; + if (value < EQUIP_VALUE_SWORD_NONE) { + value = EQUIP_VALUE_SWORD_NONE; + } + + SET_EQUIP_VALUE(EQUIP_TYPE_SWORD, value); + + if (value != 0) { + BUTTON_ITEM_EQUIP(CUR_FORM, EQUIP_SLOT_B) = value + (ITEM_SWORD_KOKIRI - 1); + gSaveContext.save.playerData.swordHealth = 100; + } else { + BUTTON_ITEM_EQUIP(CUR_FORM, EQUIP_SLOT_B) = ITEM_NONE; + } + + } else if (CHECK_BTN_ALL(input->press.button, BTN_CDOWN) || + CHECK_BTN_ALL(input->press.button, BTN_CRIGHT)) { + value++; + if (value > EQUIP_VALUE_SWORD_DIETY) { + value = EQUIP_VALUE_SWORD_DIETY; + } + + SET_EQUIP_VALUE(EQUIP_TYPE_SWORD, value); + + BUTTON_ITEM_EQUIP(CUR_FORM, EQUIP_SLOT_B) = value + (ITEM_SWORD_KOKIRI - 1); + gSaveContext.save.playerData.swordHealth = 100; + } + + Interface_LoadItemIconImpl(play, EQUIP_SLOT_B); + + } else if (sCurSection == INV_EDITOR_SECTION_SHIELD) { + // Shield + value = GET_CUR_EQUIP_VALUE(EQUIP_TYPE_SHIELD); + if (CHECK_BTN_ALL(input->press.button, BTN_CUP) || CHECK_BTN_ALL(input->press.button, BTN_CLEFT)) { + value--; + if (value < EQUIP_VALUE_SHIELD_NONE) { + value = EQUIP_VALUE_SHIELD_NONE; + } + + SET_EQUIP_VALUE(EQUIP_TYPE_SHIELD, value); + + } else if (CHECK_BTN_ALL(input->press.button, BTN_CDOWN) || + CHECK_BTN_ALL(input->press.button, BTN_CRIGHT)) { + value++; + if (value > EQUIP_VALUE_SHIELD_MAX) { + value = EQUIP_VALUE_SHIELD_MAX; + } + SET_EQUIP_VALUE(EQUIP_TYPE_SHIELD, value); + } + + } else if (sCurSection == INV_EDITOR_SECTION_QUIVER) { + // Quiver + value = GET_CUR_UPG_VALUE(UPG_QUIVER); + if (CHECK_BTN_ALL(input->press.button, BTN_CUP) || CHECK_BTN_ALL(input->press.button, BTN_CLEFT)) { + value--; + if (value < 0) { + value = 0; + } + Inventory_ChangeUpgrade(UPG_QUIVER, value); + } else if (CHECK_BTN_ALL(input->press.button, BTN_CDOWN) || + CHECK_BTN_ALL(input->press.button, BTN_CRIGHT)) { + value++; + if (value > 3) { + value = 3; + } + Inventory_ChangeUpgrade(UPG_QUIVER, value); + } + + } else if (sCurSection == INV_EDITOR_SECTION_BOMB_BAG) { + // Bomb Bag + value = GET_CUR_UPG_VALUE(UPG_BOMB_BAG); + if (CHECK_BTN_ALL(input->press.button, BTN_CUP) || CHECK_BTN_ALL(input->press.button, BTN_CLEFT)) { + value--; + if (value < 0) { + value = 0; + } + Inventory_ChangeUpgrade(UPG_BOMB_BAG, value); + } else if (CHECK_BTN_ALL(input->press.button, BTN_CDOWN) || + CHECK_BTN_ALL(input->press.button, BTN_CRIGHT)) { + value++; + if (value > 3) { + value = 3; + } + Inventory_ChangeUpgrade(UPG_BOMB_BAG, value); + } + + } else if (sCurSection == INV_EDITOR_SECTION_SWAMP_GOLD_SKULLS) { + // Gold Skulls (Swamp Spider House) + if (CHECK_BTN_ALL(input->press.button, BTN_CUP) || CHECK_BTN_ALL(input->press.button, BTN_CLEFT)) { + if (((gSaveContext.save.skullTokenCount & 0xFFFF0000) >> 0x10) != 0) { + gSaveContext.save.skullTokenCount = + ((u16)(((gSaveContext.save.skullTokenCount & 0xFFFF0000) >> 0x10) - 1) << 0x10) | + (gSaveContext.save.skullTokenCount & 0xFFFF); + } + } else if (CHECK_BTN_ALL(input->press.button, BTN_CDOWN) || + CHECK_BTN_ALL(input->press.button, BTN_CRIGHT)) { + gSaveContext.save.skullTokenCount = + ((u16)(((gSaveContext.save.skullTokenCount & 0xFFFF0000) >> 0x10) + 1) << 0x10) | + (gSaveContext.save.skullTokenCount & 0xFFFF); + } + + } else if (sCurSection == INV_EDITOR_SECTION_OCEAN_GOLD_SKULLS) { + // Gold Skulls (Oceans Spider House) + if (CHECK_BTN_ALL(input->press.button, BTN_CUP) || CHECK_BTN_ALL(input->press.button, BTN_CLEFT)) { + if (((u16)gSaveContext.save.skullTokenCount) != 0) { + gSaveContext.save.skullTokenCount = (((u16)gSaveContext.save.skullTokenCount - 1) & 0xFFFF) | + (gSaveContext.save.skullTokenCount & 0xFFFF0000); + } + } else if (CHECK_BTN_ALL(input->press.button, BTN_CDOWN) || + CHECK_BTN_ALL(input->press.button, BTN_CRIGHT)) { + gSaveContext.save.skullTokenCount = (((u16)gSaveContext.save.skullTokenCount + 1) & 0xFFFF) | + (gSaveContext.save.skullTokenCount & 0xFFFF0000); + } + + } else if (sCurSection == INV_EDITOR_SECTION_NOTEBOOK) { + // Bombers Notebook + if (CHECK_BTN_ALL(input->press.button, BTN_CUP) || CHECK_BTN_ALL(input->press.button, BTN_CLEFT)) { + gSaveContext.save.inventory.questItems ^= gBitFlags[QUEST_BOMBERS_NOTEBOOK]; + } + + } else if (sCurSection == INV_EDITOR_SECTION_LULLABY_INTRO) { + // Goron Lullaby Intro + if (CHECK_BTN_ALL(input->press.button, BTN_CUP) || CHECK_BTN_ALL(input->press.button, BTN_CLEFT)) { + gSaveContext.save.inventory.questItems ^= gBitFlags[QUEST_SONG_LULLABY_INTRO]; + } + + } else if (sCurSection < INV_EDITOR_SECTION_LULLABY_INTRO) { + // Boss Remains and Songs + //! Note: quest items must align with section, and all cases below INV_EDITOR_SECTION_LULLABY_INTRO must + //! have also been taken + slot = sCurSection - INV_EDITOR_SECTION_BOSS; + if (CHECK_BTN_ALL(input->press.button, BTN_CUP) || CHECK_BTN_ALL(input->press.button, BTN_CLEFT)) { + gSaveContext.save.inventory.questItems ^= gBitFlags[slot]; + } + + } else if (sCurSection < INV_EDITOR_SECTION_DUNGEON_ITEMS) { + // Dungeon Small Keys + slot = sCurSection - INV_EDITOR_SECTION_SMALL_KEYS; + if (CHECK_BTN_ALL(input->press.button, BTN_CUP) || CHECK_BTN_ALL(input->press.button, BTN_CLEFT)) { + DUNGEON_KEY_COUNT(slot)--; + if (DUNGEON_KEY_COUNT(slot) < 0) { + DUNGEON_KEY_COUNT(slot) = -1; + } + } else if (CHECK_BTN_ALL(input->press.button, BTN_CDOWN) || + CHECK_BTN_ALL(input->press.button, BTN_CRIGHT)) { + if (DUNGEON_KEY_COUNT(slot) < 0) { + DUNGEON_KEY_COUNT(slot) = 1; + } else { + DUNGEON_KEY_COUNT(slot)++; + if (DUNGEON_KEY_COUNT(slot) >= 9) { + DUNGEON_KEY_COUNT(slot) = 9; + } + } + } + + } else if (sCurSection < INV_EDITOR_SECTION_STRAY_FAIRIES) { + // Dungeon Items + slot = sCurSection - INV_EDITOR_SECTION_DUNGEON_ITEMS; + if (CHECK_BTN_ALL(input->press.button, BTN_CLEFT)) { + // Map + gSaveContext.save.inventory.dungeonItems[slot] ^= 4; + } + if (CHECK_BTN_ALL(input->press.button, BTN_CDOWN)) { + // Compass + gSaveContext.save.inventory.dungeonItems[slot] ^= 2; + } + if (CHECK_BTN_ALL(input->press.button, BTN_CRIGHT)) { + // Boss Key + gSaveContext.save.inventory.dungeonItems[slot] ^= 1; + } + + } else if (sCurSection < INV_EDITOR_SECTION_DOUBLE_DEFENSE) { + // Stray Fairies + slot = sCurSection - INV_EDITOR_SECTION_STRAY_FAIRIES; + if (CHECK_BTN_ALL(input->press.button, BTN_CUP) || CHECK_BTN_ALL(input->press.button, BTN_CLEFT)) { + gSaveContext.save.inventory.strayFairies[slot]--; + if (gSaveContext.save.inventory.strayFairies[slot] < 0) { + gSaveContext.save.inventory.strayFairies[slot] = 0; + } + } else if (CHECK_BTN_ALL(input->press.button, BTN_CDOWN) || + CHECK_BTN_ALL(input->press.button, BTN_CRIGHT)) { + gSaveContext.save.inventory.strayFairies[slot]++; + if (gSaveContext.save.inventory.strayFairies[slot] >= 99) { + gSaveContext.save.inventory.strayFairies[slot] = 99; + } + } + + } else { + // Double Defence + if (CHECK_BTN_ALL(input->press.button, BTN_CUP) || CHECK_BTN_ALL(input->press.button, BTN_CLEFT) || + CHECK_BTN_ALL(input->press.button, BTN_CDOWN) || CHECK_BTN_ALL(input->press.button, BTN_CRIGHT)) { + gSaveContext.save.playerData.doubleDefense ^= 1; + if (!gSaveContext.save.playerData.doubleDefense) { + gSaveContext.save.inventory.defenseHearts = 0; + } else { + gSaveContext.save.inventory.defenseHearts = 20; + } + } + } + break; + } + + // Handles exiting the inventory editor with the L button + // The editor is opened with `debugEditor` set to DEBUG_EDITOR_INVENTORY_INIT, + // and becomes closable after a frame once `debugEditor` is set to DEBUG_EDITOR_INVENTORY + if (pauseCtx->debugEditor == DEBUG_EDITOR_INVENTORY_INIT) { + pauseCtx->debugEditor = DEBUG_EDITOR_INVENTORY; + } else if ((pauseCtx->debugEditor == DEBUG_EDITOR_INVENTORY) && CHECK_BTN_ALL(input->press.button, BTN_L)) { + pauseCtx->debugEditor = DEBUG_EDITOR_NONE; + } +} diff --git a/src/overlays/kaleido_scope/ovl_kaleido_scope/z_kaleido_item.c b/src/overlays/kaleido_scope/ovl_kaleido_scope/z_kaleido_item.c index 11d0b1207..ae2140f2c 100644 --- a/src/overlays/kaleido_scope/ovl_kaleido_scope/z_kaleido_item.c +++ b/src/overlays/kaleido_scope/ovl_kaleido_scope/z_kaleido_item.c @@ -16,6 +16,64 @@ extern UNK_TYPE D_0B000000; extern UNK_TYPE D_0C000000; extern UNK_TYPE D_0C006C00; +s32 D_8082B3C0 = 0; + +s32 D_8082B3C4 = 0; + +s16 D_8082B3C8 = 10; + +u8 D_8082B3CC[5][24] = { + { + false, false, false, false, false, false, false, false, false, false, false, false, + false, false, false, false, false, false, true, true, true, true, true, true, + }, + { + true, false, false, false, false, true, false, false, false, false, false, true, + true, true, true, false, false, true, true, true, true, true, true, true, + }, + { + true, false, false, false, false, true, false, false, false, false, false, true, + false, true, true, false, false, true, true, true, true, true, true, true, + }, + { + true, false, false, false, false, true, false, false, false, true, false, true, + false, true, true, false, false, true, true, true, true, true, true, true, + }, + { + true, true, true, true, true, true, true, true, true, true, true, true, + false, true, true, true, true, true, true, true, true, true, true, true, + }, +}; + +s16 D_8082B444[] = { + 0x005F, 0x003E, 0x005F, 0x0080, 0x00A1, 0x00C2, 0x003E, 0x005F, +}; + +s16 D_8082B454[] = { + 0x0055, 0x0075, 0x0075, 0x0075, 0x0075, 0x0075, 0x0096, 0x0096, 0x00FF, 0x0064, + 0x00FF, 0x0000, 0x0000, 0x0064, 0x00FF, 0x0000, 0x0000, 0x00FF, 0x0064, 0x0000, +}; + +u8 D_8082B47C[] = { + 0x35, 0x33, 0x34, 0x32, 0xFF, +}; + +s16 D_8082B484[] = { + 0x0294, + 0x0384, + 0x0474, + 0x0000, +}; + +s16 D_8082B48C[] = { + 0x044C, + 0x0398, + 0x044C, + 0x0000, +}; + +s32 D_8082B494[] = { 0, 0, 0 }; + #pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_kaleido_scope/func_8081B240.s") #pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_kaleido_scope/func_8081B6BC.s") diff --git a/src/overlays/kaleido_scope/ovl_kaleido_scope/z_kaleido_map.c b/src/overlays/kaleido_scope/ovl_kaleido_scope/z_kaleido_map.c index 83869bd10..6e23e8f6f 100644 --- a/src/overlays/kaleido_scope/ovl_kaleido_scope/z_kaleido_map.c +++ b/src/overlays/kaleido_scope/ovl_kaleido_scope/z_kaleido_map.c @@ -16,6 +16,87 @@ extern UNK_TYPE D_0B000000; extern UNK_TYPE D_0C000000; extern UNK_TYPE D_0C006C00; +s32 D_8082B4A0[] = { 0x09003600, 0x09003F00, 0x09004800 }; + +s32 D_8082B4AC[] = { + 0x0D000000, + 0x0D000800, + 0x0D001000, + 0x0D001800, +}; + +s16 D_8082B4BC[] = { + 0x0043, + 0x0051, + 0x005F, + 0x006D, +}; + +s16 D_8082B4C4 = 0x7B; +s16 D_8082B4C8 = 30; +s16 D_8082B4CC = 0; +s16 D_8082B4D0 = 0xF; +s16 D_8082B4D4 = 0; +s16 D_8082B4D8 = 0xFF; +f32 D_8082B4DC = 100.0f; + +s32 D_8082B4E0[] = { + 0x02008998, 0x0C001B80, 0x02008998, 0x0C001B80, 0x02009598, 0x0C002780, 0x02009598, 0x0C002780, + 0x0200A198, 0x0C003380, 0x0200A198, 0x0C003380, 0x0200AD98, 0x0C003F80, 0x0200AD98, 0x0C003F80, +}; + +s32 D_8082B520[] = { + 0xFF6EA05A, + 0xFF6478FF, + 0xFFF5F55A, +}; + +s32 D_8082B52C[] = { + 0xFFFFFFFF, + 0xFFFFFFFF, + 0xFFE1AA00, +}; + +s32 D_8082B538[] = { + 0x00000400, + 0x00000000, + 0x00000000, + 0x00000000, +}; + +s16 D_8082B548[] = { + 0x0C00, 0x8418, 0x0C00, 0x9098, 0x0C01, 0x2898, 0x0C01, 0x35D8, 0x0C01, 0x4318, + 0x0C00, 0xDE58, 0x0C00, 0xEB58, 0x0C00, 0xFAA8, 0x0C00, 0x9858, 0x0C00, 0x9E58, + 0x0C00, 0xAE58, 0x0C00, 0xBE58, 0x0C00, 0xCE58, 0x0C01, 0x09F8, 0x0C01, 0x1958, +}; + +s16 D_8082B584[] = { + 0x0000, 0x0000, 0x00FF, 0x00FF, 0x00FF, 0x0000, +}; + +s16 D_8082B590[] = { + 0x00FF, 0x00FF, 0x0000, 0x0000, 0x0000, 0x00FF, +}; + +s16 D_8082B59C[] = { + 0x0056, 0x0068, 0x0091, 0x0099, 0x00A3, 0x009F, 0x009D, 0x00C7, 0x00D0, 0x00D2, 0x00DA, 0x0000, +}; + +s16 D_8082B5B4[] = { + 0x007F, 0x0099, 0x008A, 0x00AB, 0x0092, 0x0077, 0x004D, 0x006A, 0x0078, 0x0049, 0x0063, 0x0000, +}; + +s16 D_8082B5CC[] = { + 0x0005, 0x0004, 0x0006, 0x0000, 0x0008, 0x0005, 0x0004, 0x0006, 0x0000, 0x0008, +}; + +u16 D_8082B5E0[] = { + 0xAF, 0xB3, 0xAA, 0xB1, 0xA9, 0xB2, 0xA8, 0xB0, 0xAC, 0xAE, +}; +u16 D_8082B5F4 = 0; + +s32 D_8082B5F8[] = { 0, 0 }; + #pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_kaleido_scope/func_8081D240.s") #pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_kaleido_scope/func_8081D6DC.s") diff --git a/src/overlays/kaleido_scope/ovl_kaleido_scope/z_kaleido_mask.c b/src/overlays/kaleido_scope/ovl_kaleido_scope/z_kaleido_mask.c index 04fa566e3..aa24bf2e2 100644 --- a/src/overlays/kaleido_scope/ovl_kaleido_scope/z_kaleido_mask.c +++ b/src/overlays/kaleido_scope/ovl_kaleido_scope/z_kaleido_mask.c @@ -16,6 +16,48 @@ extern UNK_TYPE D_0B000000; extern UNK_TYPE D_0C000000; extern UNK_TYPE D_0C006C00; +s32 D_8082B600 = 0; + +s32 D_8082B604 = 0; + +s16 D_8082B608 = 10; + +s32 D_8082B60C[] = { + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000001, 0x00000000, 0x00010000, + 0x00000001, 0x00000000, 0x00010000, 0x00000001, 0x00000000, 0x00010000, 0x00000001, 0x00000000, + 0x00010000, 0x00000001, 0x00000000, 0x00010000, 0x00000001, 0x00000000, 0x00010000, 0x00000001, + 0x01010101, 0x01010101, 0x01010101, 0x01010101, 0x01010101, 0x01010101, +}; + +s32 D_8082B684[] = { + 0x01010004, 0x02020180, 0x01040210, 0x00100201, 0x00080110, 0x02040220, 0x00400080, 0x00020102, 0x00010240, + 0x01200108, 0x00200140, 0x02080280, 0x00FF0064, 0x00FF0000, 0x00000064, 0x00FF0000, 0x000000FF, 0x00640000, +}; + +u8 D_8082B6CC[] = { 0x35, 0x33, 0x34, 0x32, 0xFF }; + +s16 D_8082B6D4[] = { + 0x0294, + 0x0384, + 0x0474, + 0x0000, +}; + +s16 D_8082B6DC[] = { + 0x044C, + 0x0398, + 0x044C, + 0x0000, +}; + +s32 D_8082B6E4[] = { 0, 0, 0 }; + +s16 D_8082B6F0[] = { 100, 255 }; + +s32 D_8082B6F4 = 0; + +s16 D_8082B6F8[] = { 10, 0, 0, 0 }; + #pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_kaleido_scope/func_8081FF80.s") #pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_kaleido_scope/func_808204AC.s") diff --git a/src/overlays/kaleido_scope/ovl_kaleido_scope/z_kaleido_scope.h b/src/overlays/kaleido_scope/ovl_kaleido_scope/z_kaleido_scope.h index 91c6b044d..f4c91e9e8 100644 --- a/src/overlays/kaleido_scope/ovl_kaleido_scope/z_kaleido_scope.h +++ b/src/overlays/kaleido_scope/ovl_kaleido_scope/z_kaleido_scope.h @@ -1,8 +1,25 @@ -#ifndef _Z64_KALEIDO_SCOPE_H_ -#define _Z64_KALEIDO_SCOPE_H_ +#ifndef Z_KALEIDO_SCOPE_H +#define Z_KALEIDO_SCOPE_H #include "global.h" +typedef enum { + /* 0x00 */ PAUSE_ITEM, + /* 0x01 */ PAUSE_MAP, + /* 0x02 */ PAUSE_QUEST, + /* 0x03 */ PAUSE_MASK, + /* 0x04 */ PAUSE_WORLD_MAP +} PauseMenuPage; +typedef enum { + /* 0 */ DEBUG_EDITOR_NONE, + /* 1 */ DEBUG_EDITOR_INVENTORY_INIT, + /* 2 */ DEBUG_EDITOR_INVENTORY, + /* 3 */ DEBUG_EDITOR_EVENTS +} DebugEditor; + +// Debug +void KaleidoScope_DrawInventoryEditor(PlayState* play); +void KaleidoScope_UpdateInventoryEditor(PlayState* play); #endif diff --git a/src/overlays/kaleido_scope/ovl_kaleido_scope/z_kaleido_scope_NES.c b/src/overlays/kaleido_scope/ovl_kaleido_scope/z_kaleido_scope_NES.c index 5573ecb11..44575f156 100644 --- a/src/overlays/kaleido_scope/ovl_kaleido_scope/z_kaleido_scope_NES.c +++ b/src/overlays/kaleido_scope/ovl_kaleido_scope/z_kaleido_scope_NES.c @@ -16,6 +16,302 @@ extern UNK_TYPE D_0B000000; extern UNK_TYPE D_0C000000; extern UNK_TYPE D_0C006C00; +void* D_8082B700[] = { + 0x08064440, 0x0806E440, 0x08077A40, 0x08081040, 0x0808A640, 0x0D003A00, 0x0806EE40, 0x08078440, + 0x08081A40, 0x0808B040, 0x08065840, 0x0806F840, 0x08078E40, 0x08082440, 0x0808BA40, +}; +void* D_8082B73C[] = { + 0x0D004400, 0x08070240, 0x08079840, 0x08082E40, 0x0808C440, 0x0D004E00, 0x08070C40, 0x0807A240, + 0x08083840, 0x0808CE40, 0x0D005800, 0x08071640, 0x0807AC40, 0x08084240, 0x0808D840, +}; +void* D_8082B778[] = { + 0x08068040, 0x08072040, 0x0807B640, 0x08084C40, 0x0808E240, 0x0D006200, 0x08072A40, 0x0807C040, + 0x08085640, 0x0808EC40, 0x08069440, 0x08073440, 0x0807CA40, 0x08086040, 0x0808F640, +}; +void* D_8082B7B4[] = { + 0x0D006C00, 0x08073E40, 0x0807D440, 0x08086A40, 0x08090040, 0x0D007600, 0x08074840, 0x0807DE40, + 0x08087440, 0x08090A40, 0x0D008000, 0x08075240, 0x0807E840, 0x08087E40, 0x08091440, +}; + +s16 D_8082B7F0[] = { + 0x0050, 0x0040, 0x0040, 0x0040, 0x0010, 0x0040, 0x0070, 0x0070, 0x0030, 0x0040, 0x0040, 0x0040, + 0x0040, 0x0030, 0x0040, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, + 0x0008, 0x0008, 0x0018, 0x0018, 0x0018, 0x0018, 0x0018, 0x0018, 0x0018, 0x0018, 0x0018, 0x0018, +}; +s16 D_8082B838[] = { + 0x0028, 0x001F, 0x0035, 0x0035, 0x0035, 0x0034, 0x0023, 0x0023, 0x0020, 0x0040, 0x0040, 0x0040, + 0x0040, 0x0052, 0x003D, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, + 0x0008, 0x0008, 0x000C, 0x000C, 0x000C, 0x000C, 0x000C, 0x000C, 0x000C, 0x000C, 0x000C, 0x000C, +}; + +s16 D_8082B880 = 0; +s16 D_8082B884 = 0; +s16 D_8082B888 = 0; +s16 D_8082B88C = 255; +s16 D_8082B890 = 0; +s16 D_8082B894 = 0; +s16 D_8082B898 = 0; +s16 D_8082B89C = 0; +s16 D_8082B8A0 = 0; +s16 D_8082B8A4 = 0; +s16 D_8082B8A8 = 255; +s16 D_8082B8AC = 0; +s16 D_8082B8B0 = 0; + +s16 D_8082B8B4 = false; + +f32 D_8082B8B8[] = { + -4.0f, 4.0f, 4.0f, 4.0f, 4.0f, -4.0f, -4.0f, -4.0f, +}; + +f32 D_8082B8D8[] = { + -4.0f, -4.0f, -4.0f, 4.0f, 4.0f, 4.0f, 4.0f, -4.0f, +}; + +s16 D_8082B8F8[] = { + PAUSE_MAP, PAUSE_MASK, PAUSE_QUEST, PAUSE_ITEM, PAUSE_MASK, PAUSE_MAP, PAUSE_ITEM, PAUSE_QUEST, +}; + +f32 D_8082B908 = 0.0f; +f32 D_8082B90C = 0.0f; +f32 D_8082B910 = 40.0f; +f32 D_8082B914 = -40.0f; + +s32 D_8082B918 = 0; + +s32 D_8082B91C = 0; + +s16 D_8082B920 = 10; + +u8 D_8082B924[] = { + 0x00, 0x14, 0x00, 0x04, 0x00, 0x14, 0x00, 0x0A, 0x0F, 0x1F, 0x0F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, + 0x07, 0x07, 0x03, 0x0F, 0x07, 0x0F, 0x0F, 0xFF, 0xFF, 0xFF, 0x1F, 0x0F, 0x03, 0x0F, 0x00, 0x00, +}; + +s16 D_8082B944 = 0x42; + +s16 D_8082B948[][3] = { + { 0x00FF, 0x00FF, 0x00FF }, { 0x00FF, 0x00FF, 0x00FF }, { 0x00FF, 0x00FF, 0x0000 }, + { 0x00FF, 0x00FF, 0x0000 }, { 0x0064, 0x0096, 0x00FF }, { 0x0064, 0x00FF, 0x00FF }, +}; + +s16 D_8082B96C[][3] = { + { 0x0000, 0x0000, 0x0000 }, { 0x00AA, 0x00AA, 0x00AA }, { 0x0000, 0x0000, 0x0000 }, + { 0x00FF, 0x00A0, 0x0000 }, { 0x0000, 0x0000, 0x0064 }, { 0x0000, 0x0096, 0x00FF }, +}; + +s16 D_8082B990 = 10; +s16 D_8082B994 = 0; + +s32 D_8082B998[] = { + 0x0D003300, + 0x0D002700, + 0x0D002B00, + 0x0D002F00, +}; + +s32 D_8082B9A8[] = { + 0x0D002B00, + 0x0D002F00, + 0x0D003300, + 0x0D002700, +}; + +s16 D_8082B9B8[] = { + 0x00B4, 0x00D2, 0x00FF, 0x00DC, 0x0064, 0x0064, 0x0096, 0x00DC, +}; + +s16 D_8082B9C8 = 20; + +s32 D_8082B9CC = 0; + +s16 D_8082B9D0[] = { + 0x00B4, 0x00D2, 0x00FF, 0x00DC, 0x0064, 0x0064, 0x0096, 0x00DC, +}; + +s16 D_8082B9E0 = 20; + +s32 D_8082B9E4 = 0; + +s32 D_8082B9E8 = 0; + +s32 D_8082B9EC = 0; + +s16 D_8082B9F0[] = { + 0xFFEB, 0xFF98, 0xFFB4, 0xFFD0, 0xFF98, 0xFFD8, +}; + +s32 D_8082B9FC = 0; + +s16 D_8082BA00[] = { + 0xFFD7, 0x0009, 0x002B, 0xFFEB, 0xFFDB, 0x002B, 0xFFBB, 0xFFBB, 0xFFE0, 0xFF93, 0xFFD3, 0xFF93, + 0xFFD3, 0x003B, 0xFFFB, 0xFFBA, 0xFFCC, 0xFFF5, 0xFFFE, 0x0008, 0x0002, 0x0001, 0x002B, 0x0034, + 0x0036, 0x003E, 0xFFB0, 0xFFC0, 0xFFF7, 0xFFFD, 0xFFF9, 0xFFF0, 0xFFFF, 0x0017, 0x002C, 0x0036, +}; + +s16 D_8082BA48[] = { + 0xFFB4, 0xFFC6, 0x000A, 0xFFC6, 0x000A, 0x0000, +}; + +s32 D_8082BA54 = 0; + +s32 D_8082BA58 = 0; + +s16 D_8082BA5C[] = { + 0x0080, 0x0018, 0x0018, 0x0018, 0x0020, 0x0018, +}; + +s32 D_8082BA68 = 0; + +s16 D_8082BA6C[] = { + 0x0098, 0x0030, 0x0030, 0x0030, 0x0030, 0x0000, +}; + +s32 D_8082BA78 = 0; + +s32 D_8082BA7C = 0; + +s16 D_8082BA80[] = { + 0x0036, 0xFFD6, 0xFFD6, 0xFFD6, 0xFFE8, 0x0032, +}; + +s32 D_8082BA8C = 0; + +s16 D_8082BA90[] = { + 0x000B, 0x0016, 0xFFF0, 0xFFF0, 0xFFF0, 0x003B, 0x0018, 0x003B, 0xFFF5, 0xFFFB, 0xFFFB, 0x003B, + 0x003B, 0x0027, 0x001F, 0xFFF6, 0xFFDC, 0xFFED, 0xFFCB, 0xFFE5, 0xFFFE, 0x0029, 0x000B, 0xFFFD, + 0x002D, 0x0012, 0xFFF8, 0xFFDA, 0x0027, 0x001A, 0x0001, 0xFFF9, 0xFFE4, 0xFFE5, 0xFFFF, 0x0018, +}; + +s16 D_8082BAD8[] = { + 0x0024, 0x000A, 0x000A, 0xFFFA, 0xFFFA, 0x0000, +}; + +s32 D_8082BAE4 = 0; + +s32 D_8082BAE8 = 0; + +s16 D_8082BAEC[] = { + 0x0010, 0x0018, 0x0018, 0x0018, 0x0018, 0x0018, +}; + +s32 D_8082BAF8 = 0; + +s16 D_8082BAFC[] = { + 0x0010, 0x0030, 0x0030, 0x0010, 0x0010, 0x0000, +}; + +void* D_8082BB08[] = { + &D_8082B9E8, &D_8082B9EC, &D_8082B9F0, &D_8082B9FC, &D_8082BA00, &D_8082BA48, +}; + +void* D_8082BB20[] = { + &D_8082BA54, &D_8082BA58, &D_8082BA5C, &D_8082BA68, &D_8082B7F0, &D_8082BA6C, +}; + +void* D_8082BB38[] = { + &D_8082BA78, &D_8082BA7C, &D_8082BA80, &D_8082BA8C, &D_8082BA90, &D_8082BAD8, +}; + +void* D_8082BB50[] = { + &D_8082BAE4, &D_8082BAE8, &D_8082BAEC, &D_8082BAF8, &D_8082B838, &D_8082BAFC, +}; + +s16 D_8082BB68[] = { + 0x000E, 0xFFFE, 0xFFFE, 0xFFEE, 0xFFEE, 0x0000, +}; + +s16 D_8082BB74[] = { + 0x002D, 0x004E, 0x000A, 0x002D, 0x0050, 0x000B, 0xFF93, 0xFFA9, 0xFFBF, 0xFFD7, 0xFFED, 0xFFEE, 0xFF93, 0xFFA9, + 0xFFBF, 0xFFD7, 0xFFED, 0xFFEE, 0xFF99, 0x0007, 0x0052, 0xFF92, 0xFFCA, 0xFF9E, 0xFFAA, 0xFFB6, 0xFFC2, 0xFFCE, + 0xFFDA, 0xFFE6, 0xFFF2, 0xFF9E, 0xFFAA, 0xFFB6, 0xFFC2, 0xFFCE, 0xFFDA, 0xFFE6, 0xFFF2, 0x0000, +}; + +s16 D_8082BBC4[] = { + 0x003E, 0x002A, 0x002A, 0x0014, 0xFFF7, 0xFFF7, 0xFFEC, 0xFFEC, 0xFFEC, 0xFFEC, 0xFFEC, 0xFFEC, 0x0002, 0x0002, + 0x0002, 0x0002, 0x0002, 0x0002, 0x0036, 0xFFD4, 0xFFD4, 0x0022, 0x003A, 0xFFCC, 0xFFCC, 0xFFCC, 0xFFCC, 0xFFCC, + 0xFFCC, 0xFFCC, 0xFFCC, 0xFFCC, 0xFFCC, 0xFFCC, 0xFFCC, 0xFFCC, 0xFFCC, 0xFFCC, 0xFFCC, 0x0000, +}; + +s16 D_8082BC14[] = { + 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0010, 0x0010, 0x0010, 0x0010, 0x0010, 0x0010, 0x0010, 0x0010, + 0x0010, 0x0010, 0x0010, 0x0010, 0x0020, 0x0020, 0x0020, 0x0018, 0x0030, 0x0010, 0x0010, 0x0010, 0x0010, 0x0010, + 0x0010, 0x0010, 0x0010, 0x0010, 0x0010, 0x0010, 0x0010, 0x0010, 0x0010, 0x0010, 0x0010, 0x0000, +}; + +s16 D_8082BC64[] = { + 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0018, 0x0018, 0x0018, 0x0018, 0x0018, 0x0018, 0x0018, 0x0018, + 0x0018, 0x0018, 0x0018, 0x0018, 0x0020, 0x0020, 0x0020, 0x0018, 0x0030, 0x0010, 0x0010, 0x0010, 0x0010, 0x0010, + 0x0010, 0x0010, 0x0010, 0x0010, 0x0010, 0x0010, 0x0010, 0x0010, 0x0010, 0x0010, 0x0010, 0x0000, +}; + +f32 D_8082BCB4[] = { + -62.0f, -36.0f, -10.0f, 16.0f, 42.0f, 68.0f, +}; + +f32 D_8082BCCC[] = { + 31.0f, + 5.0f, + -21.0f, + -47.0f, +}; + +f32 D_8082BCDC[] = { + -49.0f, -35.0f, -3.0f, 4.0f, 12.0f, 8.0f, 7.0f, 40.0f, 47.0f, 49.0f, 55.0f, +}; + +f32 D_8082BD08[] = { + -15.0f, -36.0f, -23.0f, -49.0f, -29.0f, -8.0f, 25.0f, 2.0f, -9.0f, 28.0f, 7.0f, +}; + +f32 D_8082BD34[] = { + -50.0f, -38.0f, 6.0f, 11.0f, 8.0f, 0.0f, 12.0f, 31.0f, 48.0f, 56.0f, +}; + +f32 D_8082BD5C[] = { + -14.0f, -39.0f, 23.0f, 11.0f, -8.0f, -15.0f, -31.0f, -30.0f, -10.0f, 11.0f, +}; + +f32 D_8082BD84[] = { + -72.0f, -47.0f, -26.0f, -50.0f, -48.0f, -48.0f, -48.0f, -48.0f, -48.0f, +}; + +f32 D_8082BDA8[] = { + -47.0f, -47.0f, -47.0f, -30.0f, 33.0f, 22.0f, 11.0f, -2.0f, -13.0f, +}; + +f32 D_8082BDCC[] = { + 52.0f, 80.0f, 24.0f, 52.0f, 81.0f, 24.0f, -78.0f, -61.0f, -44.0f, -24.0f, -6.0f, -3.0f, + -78.0f, -61.0f, -44.0f, -24.0f, -6.0f, -3.0f, -68.0f, 22.0f, 83.0f, -67.0f, -21.0f, +}; + +f32 D_8082BE28[] = { + 33.0f, 18.0f, 18.0f, 0.0f, -23.0f, -23.0f, -29.0f, -29.0f, -29.0f, -29.0f, -29.0f, -29.0f, + -11.0f, -11.0f, -11.0f, -11.0f, -11.0f, -11.0f, 27.0f, -53.0f, -53.0f, 14.0f, 26.0f, +}; + +s16 D_8082BE84 = 0; + +s16 D_8082BE88[] = { + 0x001C, 0x001D, 0x001E, 0x001F, 0x0020, 0x0021, 0x0022, 0x0023, 0x0024, 0x0025, +}; + +s32 D_8082BE9C = 0; + +s32 D_8082BEA0 = 0; + +s16 D_8082BEA4 = 10; + +s32 D_8082BEA8 = 0; + +s32 D_8082BEAC = 0; + +s32 D_8082BEB0 = 0; + +s32 D_8082BEB4 = 0; + +s32 D_8082BEB8[] = { 0, 0 }; + #pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_kaleido_scope/func_80821900.s") #pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_kaleido_scope/func_8082192C.s") diff --git a/tools/Makefile b/tools/Makefile index a7fc3da90..887f146af 100644 --- a/tools/Makefile +++ b/tools/Makefile @@ -4,12 +4,14 @@ PROGRAMS := vtxdis all: $(PROGRAMS) $(MAKE) -C ZAPD + $(MAKE) -C fado $(MAKE) -C buildtools $(MAKE) -C z64compress clean: $(RM) $(PROGRAMS) $(MAKE) -C ZAPD clean + $(MAKE) -C fado clean $(MAKE) -C buildtools clean $(MAKE) -C z64compress clean diff --git a/tools/ZAPD/.gitrepo b/tools/ZAPD/.gitrepo index 5d67a3762..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 = efae567d3917afa341bd843ba185b3bd66d57429 - parent = 22c6551083172f5c506aecf8c31ad761afbbd658 + 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/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/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/ZAPDUtils/Utils/BitConverter.h b/tools/ZAPD/ZAPDUtils/Utils/BitConverter.h index ac82c24ca..646fa1274 100644 --- a/tools/ZAPD/ZAPDUtils/Utils/BitConverter.h +++ b/tools/ZAPD/ZAPDUtils/Utils/BitConverter.h @@ -11,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/buildtools/.gitignore b/tools/buildtools/.gitignore index 9edb09b20..ecf2dd851 100644 --- a/tools/buildtools/.gitignore +++ b/tools/buildtools/.gitignore @@ -3,4 +3,5 @@ elf2rom makeromfs mkldscript +reloc_prereq yaz0 diff --git a/tools/buildtools/Makefile b/tools/buildtools/Makefile index e6d601324..6f34b5cfa 100644 --- a/tools/buildtools/Makefile +++ b/tools/buildtools/Makefile @@ -1,16 +1,32 @@ CC := gcc CFLAGS := -Wall -Wextra -pedantic -std=c99 -g -O2 -PROGRAMS := yaz0 makeromfs elf2rom mkldscript +PROGRAMS := elf2rom makeromfs mkldscript reloc_prereq yaz0 +ifeq ($(shell command -v clang >/dev/null 2>&1; echo $$?),0) + CC := clang +else + CC := gcc +endif + +LLD ?= 0 + +ifeq ($(shell command -v ld.lld >/dev/null 2>&1; echo $$?),0) + LLD := 1 +endif + +ifneq ($(LLD),0) + CFLAGS += -fuse-ld=lld +endif all: $(PROGRAMS) clean: $(RM) $(PROGRAMS) -mkldscript_SOURCES := mkldscript.c util.c -elf2rom_SOURCES := elf2rom.c elf32.c n64chksum.c util.c -yaz0_SOURCES := yaz0tool.c yaz0.c util.c -makeromfs_SOURCES := makeromfs.c n64chksum.c util.c +elf2rom_SOURCES := elf2rom.c elf32.c n64chksum.c util.c +makeromfs_SOURCES := makeromfs.c n64chksum.c util.c +mkldscript_SOURCES := mkldscript.c spec.c util.c +reloc_prereq_SOURCES := reloc_prereq.c spec.c util.c +yaz0_SOURCES := yaz0tool.c yaz0.c util.c define COMPILE = $(1): $($1_SOURCES) diff --git a/tools/buildtools/mkldscript.c b/tools/buildtools/mkldscript.c index 6446f24d0..76191b86d 100644 --- a/tools/buildtools/mkldscript.c +++ b/tools/buildtools/mkldscript.c @@ -6,360 +6,51 @@ #include #include +#include "spec.h" #include "util.h" -#define ARRAY_COUNT(arr) (sizeof(arr) / sizeof(arr[0])) +// Note: *SECTION ALIGNMENT* Object files built with a compiler such as GCC can, by default, use narrower +// alignment for sections size, compared to IDO padding sections to a 0x10-aligned size. +// To properly generate relocations relative to section starts, sections currently need to be aligned +// explicitly (to 0x10 currently, a narrower alignment might work), otherwise the linker does implicit alignment +// and inserts padding between the address indicated by section start symbols (such as *SegmentRoDataStart) and +// the actual aligned start of the section. +// With IDO, the padding of sections to an aligned size makes the section start at aligned addresses out of the box, +// so the explicit alignment has no further effect. -static FILE *fout; +struct Segment* g_segments; +int g_segmentsCount; -enum -{ - STMT_address, - STMT_after, - STMT_align, - STMT_beginseg, - STMT_compress, - STMT_endseg, - STMT_entry, - STMT_flags, - STMT_include, - STMT_include_readonly, - STMT_name, - STMT_number, - STMT_romalign, - STMT_stack, - STMT_increment, - STMT_pad_text, -}; - -enum -{ - FLAG_BOOT = (1 << 0), - FLAG_OBJECT = (1 << 1), - FLAG_RAW = (1 << 2), - FLAG_NOLOAD = (1 << 3), -}; - -struct Include -{ - char *fpath; - int linkerPadding; - uint8_t dataReadOnly; -}; - -struct Segment -{ - uint32_t fields; - char *name; - char *after; - uint32_t flags; - uint32_t address; - uint32_t stack; - uint32_t align; - uint32_t romalign; - uint32_t increment; - uint32_t entry; - uint32_t number; - struct Include *includes; - int includesCount; - bool compress; -}; - -static struct Segment *g_segments = NULL; -static int g_segmentsCount = 0; - -static struct Segment *add_segment(void) -{ - struct Segment *seg; - - g_segmentsCount++; - g_segments = realloc(g_segments, g_segmentsCount * sizeof(*g_segments)); - - seg = &g_segments[g_segmentsCount - 1]; - memset(seg, 0, sizeof(*seg)); - - seg->align = 16; - - return seg; -} - -static char *skip_whitespace(char *str) -{ - while (isspace(*str)) - str++; - return str; -} - -// null terminates the current token and returns a pointer to the next token -static char *token_split(char *str) -{ - while (!isspace(*str)) - { - if (*str == 0) - return str; // end of string - str++; - } - *str = 0; // terminate token - str++; - - return skip_whitespace(str); -} - -// null terminates the current line and returns a pointer to the next line -static char *line_split(char *str) -{ - while (*str != '\n') - { - if (*str == 0) - return str; // end of string - str++; - } - *str = 0; // terminate line - return str + 1; -} - -static bool parse_number(const char *str, unsigned int *num) -{ - char *endptr; - long int n = strtol(str, &endptr, 0); - *num = n; - return endptr > str; -} - -static bool parse_flags(char *str, unsigned int *flags) -{ - unsigned int f = 0; - - while (str[0] != 0) - { - char *next = token_split(str); - - if (strcmp(str, "BOOT") == 0) - f |= FLAG_BOOT; - else if (strcmp(str, "OBJECT") == 0) - f |= FLAG_OBJECT; - else if (strcmp(str, "RAW") == 0) - f |= FLAG_RAW; - else if (strcmp(str, "NOLOAD") == 0) - f |= FLAG_NOLOAD; - else - return false; - - str = next; - } - *flags = f; - return true; -} - -static bool parse_quoted_string(char *str, char **out) -{ - if (*str != '"') - return false; - - str++; - *out = str; - - while (*str != '"') - { - if (*str == 0) - return false; // unterminated quote - str++; - } - *str = 0; - str++; - - str = skip_whitespace(str); - if (*str != 0) - return false; // garbage after filename - - return true; -} - -static bool is_pow_of_2(unsigned int n) -{ - return (n & (n - 1)) == 0; -} - -static const char *const stmtNames[] = -{ - [STMT_address] = "address", - [STMT_after] = "after", - [STMT_align] = "align", - [STMT_beginseg] = "beginseg", - [STMT_compress] = "compress", - [STMT_endseg] = "endseg", - [STMT_entry] = "entry", - [STMT_flags] = "flags", - [STMT_include] = "include", - [STMT_include_readonly] = "include_readonly", - [STMT_name] = "name", - [STMT_number] = "number", - [STMT_romalign] = "romalign", - [STMT_stack] = "stack", - [STMT_increment] = "increment", - [STMT_pad_text] = "pad_text", -}; - -static void parse_rom_spec(char *spec) -{ - int lineNum = 1; - char *line = spec; - - struct Segment *currSeg = NULL; - - // iterate over lines - while (line[0] != 0) - { - char *nextLine = line_split(line); - - if (line[0] != 0) - { - char *stmtName = skip_whitespace(line); - if (strlen(stmtName) == 0) // skip empty lines - goto no_stmt; - char *args = token_split(stmtName); - unsigned int stmt; - - for (stmt = 0; stmt < ARRAY_COUNT(stmtNames); stmt++) - if (strcmp(stmtName, stmtNames[stmt]) == 0) - goto got_stmt; - util_fatal_error("line %i: unknown statement '%s'", lineNum, stmtName); - got_stmt: - - if (currSeg != NULL) - { - // ensure no duplicates (except for 'include' or 'pad_text') - if (stmt != STMT_include && stmt != STMT_include_readonly && stmt != STMT_pad_text && - (currSeg->fields & (1 << stmt))) - util_fatal_error("line %i: duplicate '%s' statement", lineNum, stmtName); - - currSeg->fields |= 1 << stmt; - currSeg->compress = false; - - // statements valid within a segment definition - switch (stmt) - { - case STMT_beginseg: - util_fatal_error("line %i: '%s' inside of a segment definition", lineNum, stmtName); - break; - case STMT_endseg: - // verify segment data - if (currSeg->name == NULL) - util_fatal_error("line %i: no name specified for segment", lineNum); - if (currSeg->includesCount == 0) - util_fatal_error("line %i: no includes specified for segment", lineNum); - currSeg = NULL; - break; - case STMT_name: - if (!parse_quoted_string(args, &currSeg->name)) - util_fatal_error("line %i: invalid name", lineNum); - break; - case STMT_after: - if (!parse_quoted_string(args, &currSeg->after)) - util_fatal_error("line %i: invalid name for 'after'", lineNum); - break; - case STMT_address: - if (!parse_number(args, &currSeg->address)) - util_fatal_error("line %i: expected number after 'address'", lineNum); - break; - case STMT_number: - if (!parse_number(args, &currSeg->number)) - util_fatal_error("line %i: expected number after 'number'", lineNum); - break; - case STMT_flags: - if (!parse_flags(args, &currSeg->flags)) - util_fatal_error("line %i: invalid flags", lineNum); - break; - case STMT_align: - if (!parse_number(args, &currSeg->align)) - util_fatal_error("line %i: expected number after 'align'", lineNum); - if (!is_pow_of_2(currSeg->align)) - util_fatal_error("line %i: alignment is not a power of two", lineNum); - break; - case STMT_romalign: - if (!parse_number(args, &currSeg->romalign)) - util_fatal_error("line %i: expected number after 'romalign'", lineNum); - if (!is_pow_of_2(currSeg->romalign)) - util_fatal_error("line %i: alignment is not a power of two", lineNum); - break; - case STMT_include: - case STMT_include_readonly: - currSeg->includesCount++; - currSeg->includes = realloc(currSeg->includes, currSeg->includesCount * sizeof(*currSeg->includes)); - - if (!parse_quoted_string(args, &currSeg->includes[currSeg->includesCount - 1].fpath)) - util_fatal_error("line %i: invalid filename", lineNum); - - currSeg->includes[currSeg->includesCount - 1].linkerPadding = 0; - currSeg->includes[currSeg->includesCount - 1].dataReadOnly = (stmt == STMT_include_readonly); - break; - case STMT_increment: - if (!parse_number(args, &currSeg->increment)) - util_fatal_error("line %i: expected number after 'increment'", lineNum); - break; - case STMT_compress: - currSeg->compress = true; - break; - case STMT_pad_text: - currSeg->includes[currSeg->includesCount - 1].linkerPadding += 0x10; - break; - default: - fprintf(stderr, "warning: '%s' is not implemented\n", stmtName); - break; - } - } - else - { - // commands valid outside a segment definition - switch (stmt) - { - case STMT_beginseg: - currSeg = add_segment(); - break; - case STMT_endseg: - util_fatal_error("line %i: '%s' outside of a segment definition", lineNum, stmtName); - break; - default: - fprintf(stderr, "warning: '%s' is not implemented\n", stmtName); - break; - } - } - } - no_stmt: - line = nextLine; - lineNum++; - } -} - -static void write_ld_script(void) -{ +static void write_ld_script(FILE* fout) { int i; int j; - fputs("SECTIONS {\n" + fputs("OUTPUT_ARCH (mips)\n\n" + "SECTIONS {\n" " _RomSize = 0;\n" " _RomStart = _RomSize;\n\n", fout); - for (i = 0; i < g_segmentsCount; i++) - { - const struct Segment *seg = &g_segments[i]; + for (i = 0; i < g_segmentsCount; i++) { + const struct Segment* seg = &g_segments[i]; // align start of ROM segment if (seg->fields & (1 << STMT_romalign)) fprintf(fout, " _RomSize = (_RomSize + %i) & ~ %i;\n", seg->romalign - 1, seg->romalign - 1); - else if (seg->fields & (1 << STMT_increment)) // align only start of ROM segment + else if (seg->fields & (1 << STMT_increment)) // align only start of ROM segment fprintf(fout, " _RomSize = (_RomSize + %i) & ~ %i;\n", seg->increment - 1, seg->increment - 1); // initialized data (.text, .data, .rodata, .sdata) // Increment the start of the section - //if (seg->fields & (1 << STMT_increment)) - //fprintf(fout, " . += 0x%08X;\n", seg->increment); + // if (seg->fields & (1 << STMT_increment)) + // fprintf(fout, " . += 0x%08X;\n", seg->increment); - fprintf(fout, " _%sSegmentRomStartTemp = _RomSize;\n" - " _%sSegmentRomStart = _%sSegmentRomStartTemp;\n" - " ..%s ", seg->name, seg->name, seg->name, seg->name); + fprintf(fout, + " _%sSegmentRomStartTemp = _RomSize;\n" + " _%sSegmentRomStart = _%sSegmentRomStartTemp;\n" + " ..%s ", + seg->name, seg->name, seg->name, seg->name); if (seg->fields & (1 << STMT_after)) fprintf(fout, "_%sSegmentEnd ", seg->after); @@ -369,7 +60,8 @@ static void write_ld_script(void) fprintf(fout, "0x%08X ", seg->address); // (AT(_RomSize) isn't necessary, but adds useful "load address" lines to the map file) - fprintf(fout, ": AT(_RomSize)\n {\n" + fprintf(fout, + ": AT(_RomSize)\n {\n" " _%sSegmentStart = .;\n" " . = ALIGN(0x10);\n" " _%sSegmentTextStart = .;\n", @@ -382,52 +74,85 @@ static void write_ld_script(void) fprintf(fout, " %s (.text)\n", seg->includes[j].fpath); if (seg->includes[j].linkerPadding != 0) fprintf(fout, " . += 0x%X;\n", seg->includes[j].linkerPadding); + fprintf(fout, " . = ALIGN(0x10);\n"); } fprintf(fout, " _%sSegmentTextEnd = .;\n", seg->name); - fprintf(fout, " _%sSegmentTextSize = ABSOLUTE( _%sSegmentTextEnd - _%sSegmentTextStart );\n", seg->name, seg->name, seg->name); + fprintf(fout, " _%sSegmentTextSize = ABSOLUTE( _%sSegmentTextEnd - _%sSegmentTextStart );\n", seg->name, + seg->name, seg->name); fprintf(fout, " _%sSegmentDataStart = .;\n", seg->name); for (j = 0; j < seg->includesCount; j++) { - if (!seg->includes[j].dataReadOnly) - fprintf(fout, " %s (.data)\n", seg->includes[j].fpath); + if (!seg->includes[j].dataWithRodata) + fprintf(fout, + " %s (.data)\n" + " . = ALIGN(0x10);\n", + seg->includes[j].fpath); } /* - for (j = 0; j < seg->includesCount; j++) + for (j = 0; j < seg->includesCount; j++) fprintf(fout, " %s (.rodata)\n", seg->includes[j].fpath); - for (j = 0; j < seg->includesCount; j++) + for (j = 0; j < seg->includesCount; j++) fprintf(fout, " %s (.sdata)\n", seg->includes[j].fpath); */ - //fprintf(fout, " . = ALIGN(0x10);\n"); + // fprintf(fout, " . = ALIGN(0x10);\n"); fprintf(fout, " _%sSegmentDataEnd = .;\n", seg->name); - fprintf(fout, " _%sSegmentDataSize = ABSOLUTE( _%sSegmentDataEnd - _%sSegmentDataStart );\n", seg->name, seg->name, seg->name); - + fprintf(fout, " _%sSegmentDataSize = ABSOLUTE( _%sSegmentDataEnd - _%sSegmentDataStart );\n", seg->name, + seg->name, seg->name); + fprintf(fout, " _%sSegmentRoDataStart = .;\n", seg->name); for (j = 0; j < seg->includesCount; j++) { - if (seg->includes[j].dataReadOnly) - fprintf(fout, " %s (.data)\n", seg->includes[j].fpath); - fprintf(fout, " %s (.rodata)\n", seg->includes[j].fpath); - } + if (seg->includes[j].dataWithRodata) + fprintf(fout, + " %s (.data)\n" + " . = ALIGN(0x10);\n", + seg->includes[j].fpath); - //fprintf(fout, " . = ALIGN(0x10);\n"); + fprintf(fout, + " %s (.rodata)\n" + " . = ALIGN(0x10);\n", + seg->includes[j].fpath); + // Compilers other than IDO, such as GCC, produce different sections such as + // the ones named directly below. These sections do not contain values that + // need relocating, but we need to ensure that the base .rodata section + // always comes first. The reason this is important is due to relocs assuming + // the base of .rodata being the offset for the relocs and thus needs to remain + // the beginning of the entire rodata area in order to remain consistent. + // Inconsistencies will lead to various .rodata reloc crashes as a result of + // either missing relocs or wrong relocs. + fprintf(fout, + " %s (.rodata.str1.4)\n" + " . = ALIGN(0x10);\n", + seg->includes[j].fpath); + fprintf(fout, + " %s (.rodata.cst4)\n" + " . = ALIGN(0x10);\n", + seg->includes[j].fpath); + fprintf(fout, + " %s (.rodata.cst8)\n" + " . = ALIGN(0x10);\n", + seg->includes[j].fpath); + } fprintf(fout, " _%sSegmentRoDataEnd = .;\n", seg->name); - fprintf(fout, " _%sSegmentRoDataSize = ABSOLUTE( _%sSegmentRoDataEnd - _%sSegmentRoDataStart );\n", seg->name, seg->name, seg->name); + fprintf(fout, " _%sSegmentRoDataSize = ABSOLUTE( _%sSegmentRoDataEnd - _%sSegmentRoDataStart );\n", + seg->name, seg->name, seg->name); fprintf(fout, " _%sSegmentSDataStart = .;\n", seg->name); for (j = 0; j < seg->includesCount; j++) - fprintf(fout, " %s (.sdata)\n", seg->includes[j].fpath); - - fprintf(fout, " . = ALIGN(0x10);\n"); + fprintf(fout, + " %s (.sdata)\n" + " . = ALIGN(0x10);\n", + seg->includes[j].fpath); fprintf(fout, " _%sSegmentSDataEnd = .;\n", seg->name); @@ -436,107 +161,193 @@ static void write_ld_script(void) for (j = 0; j < seg->includesCount; j++) fprintf(fout, " %s (.ovl)\n", seg->includes[j].fpath); - fprintf(fout, " . = ALIGN(0x10);\n"); - fprintf(fout, " _%sSegmentOvlEnd = .;\n", seg->name); - //if (seg->fields & (1 << STMT_increment)) - // fprintf(fout, " . += 0x%08X;\n", seg->increment); - + if (seg->fields & (1 << STMT_increment)) + fprintf(fout, " . += 0x%08X;\n", seg->increment); fputs(" }\n", fout); - //fprintf(fout, " _RomSize += ( _%sSegmentDataEnd - _%sSegmentTextStart );\n", seg->name, seg->name); + fprintf(fout, " _RomSize += ( _%sSegmentOvlEnd - _%sSegmentTextStart );\n", seg->name, seg->name); - fprintf(fout, " _%sSegmentRomEndTemp = _RomSize;\n" - "_%sSegmentRomEnd = _%sSegmentRomEndTemp;\n\n", - seg->name, seg->name, seg->name); + fprintf(fout, + " _%sSegmentRomEndTemp = _RomSize;\n" + "_%sSegmentRomEnd = _%sSegmentRomEndTemp;\n\n", + seg->name, seg->name, seg->name); - // algn end of ROM segment + // align end of ROM segment if (seg->fields & (1 << STMT_romalign)) fprintf(fout, " _RomSize = (_RomSize + %i) & ~ %i;\n", seg->romalign - 1, seg->romalign - 1); // uninitialized data (.sbss, .scommon, .bss, COMMON) - fprintf(fout, " ..%s.bss ADDR(..%s) + SIZEOF(..%s) (NOLOAD) :\n" - /*" ..%s.bss :\n"*/ - " {\n" - " . = ALIGN(0x10);\n" - " _%sSegmentBssStart = .;\n", - seg->name, seg->name, seg->name, seg->name); + fprintf(fout, + " ..%s.bss ADDR(..%s) + SIZEOF(..%s) (NOLOAD) :\n" + /*" ..%s.bss :\n"*/ + " {\n" + " . = ALIGN(0x10);\n" + " _%sSegmentBssStart = .;\n", + seg->name, seg->name, seg->name, seg->name); + if (seg->fields & (1 << STMT_align)) fprintf(fout, " . = ALIGN(0x%X);\n", seg->align); + for (j = 0; j < seg->includesCount; j++) - fprintf(fout, " %s (.sbss)\n", seg->includes[j].fpath); + fprintf(fout, + " %s (.sbss)\n" + " . = ALIGN(0x10);\n", + seg->includes[j].fpath); + for (j = 0; j < seg->includesCount; j++) - fprintf(fout, " %s (.scommon)\n", seg->includes[j].fpath); + fprintf(fout, + " %s (.scommon)\n" + " . = ALIGN(0x10);\n", + seg->includes[j].fpath); + for (j = 0; j < seg->includesCount; j++) - fprintf(fout, " %s (.bss)\n", seg->includes[j].fpath); + fprintf(fout, + " %s (.bss)\n" + " . = ALIGN(0x10);\n", + seg->includes[j].fpath); + for (j = 0; j < seg->includesCount; j++) - fprintf(fout, " %s (COMMON)\n", seg->includes[j].fpath); - fprintf(fout, " . = ALIGN(0x10);\n" - " _%sSegmentBssEnd = .;\n" - " _%sSegmentEnd = .;\n" - " }\n" - " _%sSegmentBssSize = ABSOLUTE( _%sSegmentBssEnd - _%sSegmentBssStart );\n\n", - seg->name, seg->name, seg->name, seg->name, seg->name); + fprintf(fout, + " %s (COMMON)\n" + " . = ALIGN(0x10);\n", + seg->includes[j].fpath); + + fprintf(fout, + " . = ALIGN(0x10);\n" + " _%sSegmentBssEnd = .;\n" + " _%sSegmentEnd = .;\n" + " }\n" + " _%sSegmentBssSize = ABSOLUTE( _%sSegmentBssEnd - _%sSegmentBssStart );\n\n", + seg->name, seg->name, seg->name, seg->name, seg->name); // Increment the end of the segment - //if (seg->fields & (1 << STMT_increment)) - // fprintf(fout, " . += 0x%08X;\n", seg->increment); + // if (seg->fields & (1 << STMT_increment)) + // fprintf(fout, " . += 0x%08X;\n", seg->increment); - //fprintf(fout, " ..%s.ovl ADDR(..%s) + SIZEOF(..%s) :\n" - // /*" ..%s.bss :\n"*/ - // " {\n", - // seg->name, seg->name, seg->name); - //fprintf(fout, " _%sSegmentOvlStart = .;\n", seg->name); + // fprintf(fout, " ..%s.ovl ADDR(..%s) + SIZEOF(..%s) :\n" + // /*" ..%s.bss :\n"*/ + // " {\n", + // seg->name, seg->name, seg->name); + // fprintf(fout, " _%sSegmentOvlStart = .;\n", seg->name); - //for (j = 0; j < seg->includesCount; j++) - // fprintf(fout, " %s (.ovl)\n", seg->includes[j].fpath); + // for (j = 0; j < seg->includesCount; j++) + // fprintf(fout, " %s (.ovl)\n", seg->includes[j].fpath); ////fprintf(fout, " . = ALIGN(0x10);\n"); - //fprintf(fout, " _%sSegmentOvlEnd = .;\n", seg->name); + // fprintf(fout, " _%sSegmentOvlEnd = .;\n", seg->name); - //fprintf(fout, "\n }\n"); + // fprintf(fout, "\n }\n"); } - fputs(" _RomEnd = _RomSize;\n}\n", fout); + fputs(" _RomEnd = _RomSize;\n\n", fout); + + // Debugging sections + fputs( + // mdebug debug sections + " .mdebug : { *(.mdebug) }" + "\n" + " .mdebug.abi32 : { *(.mdebug.abi32) }" + "\n" + // DWARF debug sections + // Symbols in the DWARF debugging sections are relative to the beginning of the section so we begin them at 0. + // DWARF 1 + " .debug 0 : { *(.debug) }" + "\n" + " .line 0 : { *(.line) }" + "\n" + // GNU DWARF 1 extensions + " .debug_srcinfo 0 : { *(.debug_srcinfo) }" + "\n" + " .debug_sfnames 0 : { *(.debug_sfnames) }" + "\n" + // DWARF 1.1 and DWARF 2 + " .debug_aranges 0 : { *(.debug_aranges) }" + "\n" + " .debug_pubnames 0 : { *(.debug_pubnames) }" + "\n" + // DWARF 2 + " .debug_info 0 : { *(.debug_info .gnu.linkonce.wi.*) }" + "\n" + " .debug_abbrev 0 : { *(.debug_abbrev) }" + "\n" + " .debug_line 0 : { *(.debug_line .debug_line.* .debug_line_end ) }" + "\n" + " .debug_frame 0 : { *(.debug_frame) }" + "\n" + " .debug_str 0 : { *(.debug_str) }" + "\n" + " .debug_loc 0 : { *(.debug_loc) }" + "\n" + " .debug_macinfo 0 : { *(.debug_macinfo) }" + "\n" + // SGI/MIPS DWARF 2 extensions + " .debug_weaknames 0 : { *(.debug_weaknames) }" + "\n" + " .debug_funcnames 0 : { *(.debug_funcnames) }" + "\n" + " .debug_typenames 0 : { *(.debug_typenames) }" + "\n" + " .debug_varnames 0 : { *(.debug_varnames) }" + "\n" + // DWARF 3 + " .debug_pubtypes 0 : { *(.debug_pubtypes) }" + "\n" + " .debug_ranges 0 : { *(.debug_ranges) }" + "\n" + // DWARF Extension + " .debug_macro 0 : { *(.debug_macro) }" + "\n" + " .gnu.attributes 0 : { KEEP (*(.gnu.attributes)) }" + "\n", + fout); + + // Discard all other sections not mentioned above + fputs(" /DISCARD/ :" + "\n" + " {" + "\n" + " *(*);" + "\n" + " }" + "\n", + fout); + fputs("}\n", fout); } -static void usage(const char *execname) -{ - fprintf(stderr, "Nintendo 64 linker script generation tool v0.02\n" - "usage: %s [-c SEGMENTS] SPEC_FILE LD_SCRIPT\n" - "SPEC_FILE file describing the organization of object files into segments\n" - "LD_SCRIPT filename of output linker script\n" - "-c SEGMENTS (optional) output compression script for compressed segments in SEGMENTS folder\n", - execname); +static void usage(const char* execname) { + fprintf(stderr, + "Nintendo 64 linker script generation tool v0.03\n" + "usage: %s SPEC_FILE LD_SCRIPT\n" + "SPEC_FILE file describing the organization of object files into segments\n" + "LD_SCRIPT filename of output linker script\n", + execname); } -int main(int argc, char **argv) -{ - const char *spec_arg = NULL; - const char *ldscript_arg = NULL; +int main(int argc, char** argv) { + FILE* ldout; + void* spec; + size_t size; - void *spec; - size_t size; - - if (argc == 3) { - spec_arg = argv[1]; - ldscript_arg = argv[2]; - } else { - usage(argv[0]); - return 1; + if (argc != 3) { + usage(argv[0]); + return 1; } - spec = util_read_whole_file(spec_arg, &size); - parse_rom_spec(spec); - fout = fopen(ldscript_arg, "w"); - if (fout == NULL) - util_fatal_error("failed to open file '%s' for writing", ldscript_arg); - write_ld_script(); + spec = util_read_whole_file(argv[1], &size); + parse_rom_spec(spec, &g_segments, &g_segmentsCount); + + ldout = fopen(argv[2], "w"); + if (ldout == NULL) + util_fatal_error("failed to open file '%s' for writing", argv[2]); + write_ld_script(ldout); + fclose(ldout); + + free_rom_spec(g_segments, g_segmentsCount); free(spec); - fclose(fout); - return 0; + return 0; } diff --git a/tools/buildtools/reloc_prereq.c b/tools/buildtools/reloc_prereq.c new file mode 100644 index 000000000..ea117f12e --- /dev/null +++ b/tools/buildtools/reloc_prereq.c @@ -0,0 +1,89 @@ +#include +#include +#include +#include + +#include "spec.h" +#include "util.h" + +void print_usage(char* prog_name) { + printf("USAGE: %s SPEC OVERLAY_SEGMENT_NAME\n" + "Search the preprocessed SPEC for an overlay segment name, \n" + "e.g. \"ovl_En_Firefly\", and return a space-separated list of the files it\n" + "includes. The relocation file must be the last include in the segment\n" + "OVERLAY_SEGMENT_NAME, and have the filename \"OVERLAY_SEGMENT_NAME_reloc.o\",\n" + "but can be in a different directory from the other files.\n", + prog_name); +} + +int main(int argc, char** argv) { + char* spec_path; + char* overlay_name; + char* spec; + size_t size; + Segment segment; + int exit_status = 0; + bool segmentFound = false; + + if (argc != 3) { + print_usage(argv[0]); + return 1; + } + + spec_path = argv[1]; + overlay_name = argv[2]; + + // printf("spec path: %s\n", spec_path); + // printf("overlay name: %s\n", overlay_name); + + spec = util_read_whole_file(spec_path, &size); + segmentFound = get_single_segment_by_name(&segment, spec, overlay_name); + + if (!segmentFound) { + fprintf(stderr, ERRMSG_START "no segment \"%s\" found\n" ERRMSG_END, overlay_name); + goto error_out; + } + + { + size_t overlay_name_length; + const char* reloc_suffix = "_reloc.o"; + char* expected_filename; + + /* Relocation file must be the last `include` (so .ovl section is linked last) */ + if (strstr(segment.includes[segment.includesCount - 1].fpath, reloc_suffix) == NULL) { + fprintf(stderr, ERRMSG_START "last include in overlay segment \"%s\" is not a `%s` file\n" ERRMSG_END, + overlay_name, reloc_suffix); + goto error_out; + } + + overlay_name_length = strlen(overlay_name); + expected_filename = malloc(overlay_name_length + strlen(reloc_suffix) + 1); + strcpy(expected_filename, overlay_name); + strcat(expected_filename, reloc_suffix); + + if (strstr(segment.includes[segment.includesCount - 1].fpath, expected_filename) == NULL) { + fprintf(stderr, ERRMSG_START "Relocation file \"%s\" should have filename \"%s\"\n" ERRMSG_END, + segment.includes[segment.includesCount - 1].fpath, expected_filename); + goto error_out; + } + free(expected_filename); + } + { + int i; + /* Skip `_reloc.o` include */ + for (i = 0; i < segment.includesCount - 1; i++) { + printf("%s ", segment.includes[i].fpath); + } + putchar('\n'); + } + + if (0) { + error_out: + exit_status = 1; + } + + free_single_segment_elements(&segment); + free(spec); + + return exit_status; +} diff --git a/tools/buildtools/spec.c b/tools/buildtools/spec.c new file mode 100644 index 000000000..5a11c47c7 --- /dev/null +++ b/tools/buildtools/spec.c @@ -0,0 +1,365 @@ +#include +#include +#include +#include +#include +#include +#include + +#include "util.h" +#include "spec.h" + +#define ARRAY_COUNT(arr) (sizeof(arr) / sizeof(arr[0])) + +static struct Segment* add_segment(struct Segment** segments, int* segments_count) { + struct Segment* seg; + + (*segments_count)++; + *segments = realloc(*segments, *segments_count * sizeof(**segments)); + + seg = &(*segments)[*segments_count - 1]; + memset(seg, 0, sizeof(*seg)); + + seg->align = 16; + + return seg; +} + +static char* skip_whitespace(char* str) { + while (isspace(*str)) + str++; + return str; +} + +// null terminates the current token and returns a pointer to the next token +static char* token_split(char* str) { + while (!isspace(*str)) { + if (*str == 0) + return str; // end of string + str++; + } + *str = 0; // terminate token + str++; + + return skip_whitespace(str); +} + +// null terminates the current line and returns a pointer to the next line +static char* line_split(char* str) { + while (*str != '\n') { + if (*str == 0) + return str; // end of string + str++; + } + *str = 0; // terminate line + return str + 1; +} + +static bool parse_number(const char* str, unsigned int* num) { + char* endptr; + long int n = strtol(str, &endptr, 0); + *num = n; + return endptr > str; +} + +static bool parse_flags(char* str, unsigned int* flags) { + unsigned int f = 0; + + while (str[0] != 0) { + char* next = token_split(str); + + if (strcmp(str, "BOOT") == 0) + f |= FLAG_BOOT; + else if (strcmp(str, "OBJECT") == 0) + f |= FLAG_OBJECT; + else if (strcmp(str, "RAW") == 0) + f |= FLAG_RAW; + else if (strcmp(str, "NOLOAD") == 0) + f |= FLAG_NOLOAD; + else + return false; + + str = next; + } + *flags = f; + return true; +} + +static bool parse_quoted_string(char* str, char** out) { + if (*str != '"') + return false; + + str++; + *out = str; + + while (*str != '"') { + if (*str == 0) + return false; // unterminated quote + str++; + } + *str = 0; + str++; + + str = skip_whitespace(str); + if (*str != 0) + return false; // garbage after filename + + return true; +} + +static bool is_pow_of_2(unsigned int n) { + return (n & (n - 1)) == 0; +} + +// clang-format off +static const char* const stmtNames[] = { + [STMT_address] = "address", + [STMT_after] = "after", + [STMT_align] = "align", + [STMT_beginseg] = "beginseg", + [STMT_compress] = "compress", + [STMT_endseg] = "endseg", + [STMT_entry] = "entry", + [STMT_flags] = "flags", + [STMT_include] = "include", + [STMT_include_data_with_rodata] = "include_data_with_rodata", + [STMT_name] = "name", + [STMT_number] = "number", + [STMT_romalign] = "romalign", + [STMT_stack] = "stack", + [STMT_increment] = "increment", + [STMT_pad_text] = "pad_text", +}; +// clang-format on + +STMTId get_stmt_id_by_stmt_name(const char* stmtName, int lineNum) { + STMTId stmt; + + for (stmt = 0; stmt < ARRAY_COUNT(stmtNames); stmt++) { + if (strcmp(stmtName, stmtNames[stmt]) == 0) + return stmt; + } + util_fatal_error("line %i: unknown statement '%s'", lineNum, stmtName); + return -1; +} + +bool parse_segment_statement(struct Segment* currSeg, STMTId stmt, char* args, int lineNum) { + // ensure no duplicates (except for 'include' or 'pad_text') + if (stmt != STMT_include && stmt != STMT_include_data_with_rodata && stmt != STMT_pad_text && + (currSeg->fields & (1 << stmt))) + util_fatal_error("line %i: duplicate '%s' statement", lineNum, stmtNames[stmt]); + + currSeg->fields |= 1 << stmt; + currSeg->compress = false; + + // statements valid within a segment definition + switch (stmt) { + case STMT_beginseg: + util_fatal_error("line %i: '%s' inside of a segment definition", lineNum, stmtNames[stmt]); + break; + + case STMT_endseg: + // verify segment data + if (currSeg->name == NULL) + util_fatal_error("line %i: no name specified for segment", lineNum); + if (currSeg->includesCount == 0) + util_fatal_error("line %i: no includes specified for segment", lineNum); + return true; + break; + + case STMT_name: + if (!parse_quoted_string(args, &currSeg->name)) + util_fatal_error("line %i: invalid name", lineNum); + break; + + case STMT_after: + if (!parse_quoted_string(args, &currSeg->after)) + util_fatal_error("line %i: invalid name for 'after'", lineNum); + break; + + case STMT_address: + if (!parse_number(args, &currSeg->address)) + util_fatal_error("line %i: expected number after 'address'", lineNum); + break; + + case STMT_number: + if (!parse_number(args, &currSeg->number)) + util_fatal_error("line %i: expected number after 'number'", lineNum); + break; + + case STMT_flags: + if (!parse_flags(args, &currSeg->flags)) + util_fatal_error("line %i: invalid flags", lineNum); + break; + + case STMT_align: + if (!parse_number(args, &currSeg->align)) + util_fatal_error("line %i: expected number after 'align'", lineNum); + if (!is_pow_of_2(currSeg->align)) + util_fatal_error("line %i: alignment is not a power of two", lineNum); + break; + + case STMT_romalign: + if (!parse_number(args, &currSeg->romalign)) + util_fatal_error("line %i: expected number after 'romalign'", lineNum); + if (!is_pow_of_2(currSeg->romalign)) + util_fatal_error("line %i: alignment is not a power of two", lineNum); + break; + + case STMT_include: + case STMT_include_data_with_rodata: + currSeg->includesCount++; + currSeg->includes = realloc(currSeg->includes, currSeg->includesCount * sizeof(*currSeg->includes)); + + if (!parse_quoted_string(args, &currSeg->includes[currSeg->includesCount - 1].fpath)) + util_fatal_error("line %i: invalid filename", lineNum); + + currSeg->includes[currSeg->includesCount - 1].linkerPadding = 0; + currSeg->includes[currSeg->includesCount - 1].dataWithRodata = (stmt == STMT_include_data_with_rodata); + break; + case STMT_increment: + if (!parse_number(args, &currSeg->increment)) + util_fatal_error("line %i: expected number after 'increment'", lineNum); + break; + + case STMT_compress: + currSeg->compress = true; + break; + + case STMT_pad_text: + currSeg->includes[currSeg->includesCount - 1].linkerPadding += 0x10; + break; + + default: + fprintf(stderr, "warning: '%s' is not implemented\n", stmtNames[stmt]); + break; + } + return false; +} + +/** + * `segments` should be freed with `free_rom_spec` after use. + * Will write to the contents of `spec` to introduce string terminating '\0's. + * `segments` also contains pointers to inside `spec`, so `spec` should not be freed before `segments` + */ +void parse_rom_spec(char* spec, struct Segment** segments, int* segment_count) { + int lineNum = 1; + char* line = spec; + + struct Segment* currSeg = NULL; + + // iterate over lines + while (line[0] != 0) { + char* nextLine = line_split(line); + char* stmtName; + + if (line[0] != 0) { + stmtName = skip_whitespace(line); + } + + if (line[0] != 0 && stmtName[0] != 0) { + char* args = token_split(stmtName); + STMTId stmt = get_stmt_id_by_stmt_name(stmtName, lineNum); + + if (currSeg != NULL) { + bool segmentEnded = parse_segment_statement(currSeg, stmt, args, lineNum); + if (segmentEnded) { + currSeg = NULL; + } + } else { + // commands valid outside a segment definition + switch (stmt) { + case STMT_beginseg: + currSeg = add_segment(segments, segment_count); + currSeg->includes = NULL; + break; + case STMT_endseg: + util_fatal_error("line %i: '%s' outside of a segment definition", lineNum, stmtName); + break; + default: + fprintf(stderr, "warning: '%s' is not implemented\n", stmtName); + break; + } + } + } + + line = nextLine; + lineNum++; + } +} + +/** + * @brief Parses the spec, looking only for the segment with the name `segmentName`. + * Returns true if the segment was found, false otherwise + * + * @param[out] dstSegment The Segment to be filled. Will only contain the data of the searched segment, or garbage if + * the segment was not found. dstSegment must be previously allocated, a stack variable is recommended + * @param[in,out] spec A null-terminated string containing the whole spec file. This string will be modified by this + * function + * @param[in] segmentName The name of the segment being searched + */ +bool get_single_segment_by_name(struct Segment* dstSegment, char* spec, const char* segmentName) { + bool insideSegment = false; + int lineNum = 1; + char* line = spec; + + memset(dstSegment, 0, sizeof(struct Segment)); + + // iterate over lines + while (line[0] != '\0') { + char* nextLine = line_split(line); + char* stmtName = skip_whitespace(line); + + if (stmtName[0] != '\0') { + char* args = token_split(stmtName); + STMTId stmt = get_stmt_id_by_stmt_name(stmtName, lineNum); + + if (insideSegment) { + bool segmentEnded = parse_segment_statement(dstSegment, stmt, args, lineNum); + + if (stmt == STMT_name) { + if (strcmp(segmentName, dstSegment->name) != 0) { + // Not the segment we are looking for + insideSegment = false; + } + } else if (segmentEnded) { + return true; + } + } else { + if (stmt == STMT_beginseg) { + insideSegment = true; + if (dstSegment->includes != NULL) { + free(dstSegment->includes); + } + memset(dstSegment, 0, sizeof(struct Segment)); + } + } + } + + line = nextLine; + lineNum++; + } + + return false; +} + +/** + * @brief Frees the elements of the passed Segment. Will not free the pointer itself + * + * @param segment + */ +void free_single_segment_elements(struct Segment* segment) { + if (segment->includes != NULL) { + free(segment->includes); + } +} + +void free_rom_spec(struct Segment* segments, int segment_count) { + int i; + + for (i = 0; i < segment_count; i++) { + if (segments[i].includes != NULL) + free(segments[i].includes); + } + free(segments); +} diff --git a/tools/buildtools/spec.h b/tools/buildtools/spec.h new file mode 100644 index 000000000..aeabd07d1 --- /dev/null +++ b/tools/buildtools/spec.h @@ -0,0 +1,64 @@ +#ifndef SPEC_H +#define SPEC_H + +#include +#include + +typedef enum { + STMT_address, + STMT_after, + STMT_align, + STMT_beginseg, + STMT_compress, + STMT_endseg, + STMT_entry, + STMT_flags, + STMT_include, + STMT_include_data_with_rodata, + STMT_name, + STMT_number, + STMT_romalign, + STMT_stack, + STMT_increment, + STMT_pad_text, +} STMTId; + +enum { + FLAG_BOOT = (1 << 0), + FLAG_OBJECT = (1 << 1), + FLAG_RAW = (1 << 2), + FLAG_NOLOAD = (1 << 3), +}; + +struct Include { + char* fpath; + int linkerPadding; + uint8_t dataWithRodata; +}; + +typedef struct Segment { + uint32_t fields; + char* name; + char* after; + uint32_t flags; + uint32_t address; + uint32_t stack; + uint32_t align; + uint32_t romalign; + uint32_t increment; + uint32_t entry; + uint32_t number; + struct Include* includes; + int includesCount; + bool compress; +} Segment; + +void parse_rom_spec(char* spec, struct Segment** segments, int* segment_count); + +bool get_single_segment_by_name(struct Segment* dstSegment, char *spec, const char *segmentName); + +void free_single_segment_elements(struct Segment *segment); + +void free_rom_spec(struct Segment* segments, int segment_count); + +#endif diff --git a/tools/buildtools/util.c b/tools/buildtools/util.c index e826906cd..824e089e0 100644 --- a/tools/buildtools/util.c +++ b/tools/buildtools/util.c @@ -12,18 +12,18 @@ void util_fatal_error(const char *msgfmt, ...) { va_list args; - fputs("error: ", stderr); + fputs(ERRMSG_START, stderr); va_start(args, msgfmt); vfprintf(stderr, msgfmt, args); va_end(args); - fputc('\n', stderr); + fputs(ERRMSG_END "\n", stderr); exit(1); } -// reads a whole file into memory, and returns a pointer to the data +// reads a whole file into memory, and returns a malloc'd pointer to the data. void *util_read_whole_file(const char *filename, size_t *pSize) { FILE *file = fopen(filename, "rb"); @@ -59,13 +59,13 @@ void *util_read_whole_file(const char *filename, size_t *pSize) void util_write_whole_file(const char *filename, const void *data, size_t size) { FILE *file = fopen(filename, "wb"); - + if (file == NULL) util_fatal_error("failed to open file '%s' for writing: %s", filename, strerror(errno)); if (fwrite(data, size, 1, file) != 1) util_fatal_error("error writing to file '%s': %s", filename, strerror(errno)); - + fclose(file); } diff --git a/tools/buildtools/util.h b/tools/buildtools/util.h index 8659e6f35..ed692bf53 100644 --- a/tools/buildtools/util.h +++ b/tools/buildtools/util.h @@ -1,8 +1,15 @@ -#ifndef _UTIL_H_ -#define _UTIL_H_ +#ifndef UTIL_H +#define UTIL_H + +#include +#include +#include + +#define ERRMSG_START "\x1b[91merror\x1b[97m: " +#define ERRMSG_END "\x1b[0m" #ifdef __GNUC__ -__attribute__((format(printf, 1, 2))) +__attribute__((format(printf, 1, 2), noreturn)) #endif void util_fatal_error(const char *msgfmt, ...); diff --git a/tools/disasm/disasm.py b/tools/disasm/disasm.py index cb634d138..0f5e16464 100755 --- a/tools/disasm/disasm.py +++ b/tools/disasm/disasm.py @@ -4,12 +4,12 @@ import argparse, ast, math, os, re, struct import bisect import multiprocessing from pathlib import Path -import mips_isa +import rabbitizer # Consider implementing gpr naming too, but already uses abi names by default fpr_name_options = { - "numeric": mips_isa.numeric_fpr_names, - "o32": mips_isa.o32_fpr_names, + "numeric", + "o32", } parser = argparse.ArgumentParser() @@ -32,12 +32,15 @@ parser.add_argument( required=False, help="Optional list of files to diassemble separated by a space. This is a whitelist, all files will be skipped besides the ones listed here if used.", ) -parser.add_argument("--reg-names", choices=fpr_name_options.keys(), help="How to name registers in the output") +parser.add_argument( + "--reg-names", choices=fpr_name_options, help="How to name registers in the output" +) args = parser.parse_args() jobs = args.jobs -mips_isa.mips_fpr_names = fpr_name_options.get(args.reg_names, mips_isa.mips_fpr_names) +rabbitizer.config.regNames_fprAbiNames = rabbitizer.Abi.fromStr(args.reg_names) +rabbitizer.config.regNames_userFpcCsr = False ASM_OUT = "asm/" @@ -131,76 +134,6 @@ def discard_decomped_files(files_spec, include_files): return new_spec -MIPS_BRANCH_LIKELY_INSNS = [ - mips_isa.MIPS_INS_BEQL, - mips_isa.MIPS_INS_BGEZALL, - mips_isa.MIPS_INS_BGEZL, - mips_isa.MIPS_INS_BGTZL, - mips_isa.MIPS_INS_BLEZL, - mips_isa.MIPS_INS_BLTZALL, - mips_isa.MIPS_INS_BLTZL, - mips_isa.MIPS_INS_BNEL, - mips_isa.MIPS_INS_BC1TL, - mips_isa.MIPS_INS_BC1FL, -] - -MIPS_BRANCH_INSNS = [ - *MIPS_BRANCH_LIKELY_INSNS, - mips_isa.MIPS_INS_BEQ, - mips_isa.MIPS_INS_BGEZ, - mips_isa.MIPS_INS_BGEZAL, - mips_isa.MIPS_INS_BGTZ, - mips_isa.MIPS_INS_BNE, - mips_isa.MIPS_INS_BLTZ, - mips_isa.MIPS_INS_BLTZAL, - mips_isa.MIPS_INS_BLEZ, - mips_isa.MIPS_INS_BC1T, - mips_isa.MIPS_INS_BC1F, - mips_isa.MIPS_INS_BEQZ, - mips_isa.MIPS_INS_BNEZ, - mips_isa.MIPS_INS_B, -] - -MIPS_JUMP_INSNS = [mips_isa.MIPS_INS_JAL, mips_isa.MIPS_INS_JALR, mips_isa.MIPS_INS_J, mips_isa.MIPS_INS_JR] - -MIPS_FP_LOAD_INSNS = [mips_isa.MIPS_INS_LWC1, mips_isa.MIPS_INS_LDC1] - -MIPS_FP_STORE_INSNS = [mips_isa.MIPS_INS_SWC1, mips_isa.MIPS_INS_SDC1] - -MIPS_FP_LOAD_STORE_INSNS = [*MIPS_FP_LOAD_INSNS, *MIPS_FP_STORE_INSNS] - -MIPS_STORE_INSNS = [ - mips_isa.MIPS_INS_SB, - mips_isa.MIPS_INS_SH, - mips_isa.MIPS_INS_SW, - mips_isa.MIPS_INS_SWL, - mips_isa.MIPS_INS_SWR, - mips_isa.MIPS_INS_SD, - mips_isa.MIPS_INS_SDL, - mips_isa.MIPS_INS_SDR, - mips_isa.MIPS_INS_SC, - mips_isa.MIPS_INS_SCD, - *MIPS_FP_STORE_INSNS, -] - -MIPS_LOAD_STORE_INSNS = [ - mips_isa.MIPS_INS_LB, - mips_isa.MIPS_INS_LBU, - mips_isa.MIPS_INS_LH, - mips_isa.MIPS_INS_LHU, - mips_isa.MIPS_INS_LW, - mips_isa.MIPS_INS_LWL, - mips_isa.MIPS_INS_LWR, - mips_isa.MIPS_INS_LWU, - mips_isa.MIPS_INS_LD, - mips_isa.MIPS_INS_LDL, - mips_isa.MIPS_INS_LDR, - mips_isa.MIPS_INS_LL, - mips_isa.MIPS_INS_LLD, - *MIPS_STORE_INSNS, - *MIPS_FP_LOAD_STORE_INSNS, -] - VRAM_BASE = { "code": {"data": 0x801AAAB0, "rodata": 0x801DBDF0, "bss": 0x801E3FA0}, "boot": {"data": 0x800969C0, "rodata": 0x80098190, "bss": 0x80099500}, @@ -573,6 +506,18 @@ def update_symbols_from_dict(symbols_dict): put_text(file[0], file[1]) +def validateLuiImm(imm_value: int, insn: rabbitizer.Instruction) -> bool: + if ((imm_value >> 0x8) & 0xF) != 0 and imm_value < 0x1000: + return True + if imm_value >= 0x8000 and imm_value < 0x80D0: + return True + if imm_value >= 0xA400 and imm_value < 0xA480: + return True + if imm_value < 0x0400 and insn.uniqueId == rabbitizer.InstrId.cpu_addiu: + return True + return False + + def find_symbols_in_text(section, rodata_section, data_regions): data, rodata = section[4], rodata_section[4] if rodata_section else None vram, vram_rodata = section[0], rodata_section[0] if rodata_section else None @@ -582,6 +527,7 @@ def find_symbols_in_text(section, rodata_section, data_regions): print(f"Finding symbols from .text in {info['name']}") + rodata_words = [] if rodata is not None: rodata_words = as_word_list(rodata) @@ -623,20 +569,20 @@ def find_symbols_in_text(section, rodata_section, data_regions): # that means no code path produces a valid symbol at he convergent code, unless the convergent code provides all the # new registers. - # assert insn.value_forname(insn.fields[0]) is not None - # print(f"insn: {insn.mnemonic}, rt: {insn.rt}, first: {insn.value_forname(insn.fields[0])}") - # assert insn.id not in [MIPS_INS_ORI, mips_isa.MIPS_INS_ADDIU, *MIPS_LOAD_STORE_INSNS] or insn.rt == insn.value_forname(insn.fields[0]) - - if ( - delay_slot - and delayed_insn is not None - and delayed_insn.id in MIPS_BRANCH_LIKELY_INSNS - ): - clobber_later.update( - {delayed_insn.offset: insn.value_forname(insn.fields[0])} - ) + if delay_slot and delayed_insn is not None and delayed_insn.isBranchLikely(): + if insn.modifiesRd(): + clobber_later.update( + {delayed_insn.getBranchOffset() + delayed_insn.vram: insn.rd} + ) + elif insn.modifiesRt(): + clobber_later.update( + {delayed_insn.getBranchOffset() + delayed_insn.vram: insn.rt} + ) else: - lui_tracker.pop(insn.value_forname(insn.fields[0]), None) + if insn.modifiesRd(): + lui_tracker.pop(insn.rd, None) + elif insn.modifiesRt(): + lui_tracker.pop(insn.rt, None) for region in data_regions: assert region[1] != 0 @@ -646,26 +592,30 @@ def find_symbols_in_text(section, rodata_section, data_regions): insns = [] for i, raw_insn in enumerate(raw_insns, 0): - insn = mips_isa.decode_insn(raw_insn, vram + i * 4) + insn = rabbitizer.Instruction(raw_insn, vram=vram + i * 4) - if insn.id == mips_isa.MIPS_INS_JR and insn.rs != mips_isa.MIPS_REG_RA: - # It's hard to find when two jump tables next to each other end, so do a naive first pass - # to try and find as many jump tables as possible. - # Luckily IDO has a very homogeneous output for jump tables for which it is very unlikely - # that other instructions will break up: - # lui $at, %hi(jtbl) - # addu $at, $at, $reg - # lw $reg, %lo(jtbl)($at) - # jr $reg + if insn.isJrNotRa() and len(insns) > 3: + """ + It's hard to find when two jump tables next to each other end, so do a naive first pass + to try and find as many jump tables as possible. + Luckily IDO has a very homogeneous output for jump tables for which it is very unlikely + that other instructions will break up: + lui $at, %hi(jtbl) + addu $at, $at, $reg + lw $reg, %lo(jtbl)($at) + jr $reg + """ insn_m1 = insns[-1] insn_m2 = insns[-2] insn_m3 = insns[-3] if ( - insn_m1.id == mips_isa.MIPS_INS_LW - and insn_m2.id == mips_isa.MIPS_INS_ADDU - and insn_m3.id == mips_isa.MIPS_INS_LUI + insn_m1.uniqueId == rabbitizer.InstrId.cpu_lw + and insn_m2.uniqueId == rabbitizer.InstrId.cpu_addu + and insn_m3.uniqueId == rabbitizer.InstrId.cpu_lui ): - prospective_jtbls.add((insn_m3.imm << 0x10) + insn_m1.imm) + prospective_jtbls.add( + (insn_m3.getImmediate() << 0x10) + insn_m1.getProcessedImmediate() + ) insns.append(insn) if relocs is not None: @@ -684,26 +634,27 @@ def find_symbols_in_text(section, rodata_section, data_regions): Relocated jump targets give us functions in this section """ assert ( - insn.id == mips_isa.MIPS_INS_JAL - ), f"R_MIPS_26 applied to {insn.mnemonic} when it should be JAL" - put_symbol(symbols_dict, "functions", insn.target) + insn.uniqueId == rabbitizer.InstrId.cpu_jal + ), f"R_MIPS_26 applied to {insn.getOpcodeName()} when it should be JAL" + put_symbol(symbols_dict, "functions", insn.getInstrIndexAsVram()) elif reloc[1] == 5: # R_MIPS_HI16 """ Relocated %hi gives us %hi values to match with associated %lo """ assert ( - insn.id == mips_isa.MIPS_INS_LUI - ), f"R_MIPS_HI16 applied to {insn.mnemonic} when it should be LUI" - prev_hi = insn.imm + insn.canBeHi() + ), f"R_MIPS_HI16 applied to {insn.getOpcodeName()} when it should be LUI" + prev_hi = insn.getImmediate() hi_vram = vram + reloc[2] elif reloc[1] == 6: # R_MIPS_LO16 """ Relocated %lo + a %hi to match with gives us relocated symbols in data sections """ assert ( - insn.id == mips_isa.MIPS_INS_ADDIU or insn.id in MIPS_LOAD_STORE_INSNS - ), f"R_MIPS_HI16 applied to {insn.mnemonic} when it should be ADDIU or a load/store" - symbol_value = (prev_hi << 0x10) + insn.imm + insn.canBeLo() + ), f"R_MIPS_HI16 applied to {insn.getOpcodeName()} when it should be ADDIU or a load/store" + assert prev_hi is not None + symbol_value = (prev_hi << 0x10) + insn.getProcessedImmediate() put_symbols(symbols_dict, "symbols", {hi_vram: symbol_value}) put_symbols(symbols_dict, "symbols", {vram + reloc[2]: symbol_value}) else: @@ -716,8 +667,6 @@ def find_symbols_in_text(section, rodata_section, data_regions): cur_file = "" cur_vaddr = 0 - segment_dirname = ("" if info["type"] != "overlay" else "overlays/") + info["name"] - delayed_insn = None delay_slot = False @@ -730,14 +679,13 @@ def find_symbols_in_text(section, rodata_section, data_regions): if vaddr in range(region[0], region[1], 4): in_data = True break + if not insn.isValid(): + in_data = True if in_data: results.append( { - "vaddr": vaddr, - "insn": {"id": insn.id}, - "addr": f"/* {i*4:06X} {vaddr:08X} {raw_insns[i]:08X} */ ", - "mnem": "", - "op": [f" .word 0x{raw_insns[i]:08X}"], + "insn": insn, + "comment": f"/* {i*4:06X} {vaddr:08X} {raw_insns[i]:08X} */", "data": True, } ) @@ -764,19 +712,21 @@ def find_symbols_in_text(section, rodata_section, data_regions): if cl is not None: lui_tracker.pop(cl, None) - if insn.id in MIPS_BRANCH_INSNS: - func_branch_labels.add(insn.offset) + branch_likely_delay_slot_save = None + + if insn.isBranch(): + func_branch_labels.add(insn.getBranchOffset() + insn.vram) delayed_insn = insn - elif insn.id == mips_isa.MIPS_INS_ERET: + elif insn.uniqueId == rabbitizer.InstrId.cpu_eret: put_symbol(symbols_dict, "functions", vaddr + 4) - elif insn.id in MIPS_JUMP_INSNS: - if insn.id == mips_isa.MIPS_INS_JAL: + elif insn.isJump(): + if insn.uniqueId == rabbitizer.InstrId.cpu_jal: # mark function at target - put_symbol(symbols_dict, "functions", insn.target) - elif insn.id == mips_isa.MIPS_INS_J: + put_symbol(symbols_dict, "functions", insn.getInstrIndexAsVram()) + elif insn.uniqueId == rabbitizer.InstrId.cpu_j: # mark label at target - func_branch_labels.add(insn.target) - elif insn.id == mips_isa.MIPS_INS_JR: + func_branch_labels.add(insn.getInstrIndexAsVram()) + elif insn.uniqueId == rabbitizer.InstrId.cpu_jr: # check if anything branches past it in either branch or jtbl labels if vaddr >= max(func_branch_labels, default=0) and vaddr >= max( func_jtbl_labels, default=0 @@ -802,7 +752,7 @@ def find_symbols_in_text(section, rodata_section, data_regions): symbols_dict, "functions", vaddr + 8 + n_padding * 4 ) delayed_insn = insn - elif insn.id == mips_isa.MIPS_INS_LUI: + elif insn.canBeHi(): """ Process LUI instruction @@ -813,45 +763,47 @@ def find_symbols_in_text(section, rodata_section, data_regions): if ( delay_slot and delayed_insn is not None - and delayed_insn.id in MIPS_BRANCH_LIKELY_INSNS + and delayed_insn.isBranchLikely() ): # for branch likelies, the current tracker does not update but the lui is saved to be tracked at the branch target - save_tracker(delayed_insn.offset, {insn.rt: (vaddr, insn.imm)}) + branch_likely_delay_slot_save = {insn.rt: (vaddr, insn.getProcessedImmediate())} else: - lui_tracker.update({insn.rt: (vaddr, insn.imm)}) - elif insn.id == mips_isa.MIPS_INS_ADDIU or insn.id in MIPS_LOAD_STORE_INSNS: + lui_tracker.update({insn.rt: (vaddr, insn.getProcessedImmediate())}) + elif insn.uniqueId == rabbitizer.InstrId.cpu_ori: + # try match with tracked lui and mark constant + hi_vram, imm_value = lui_tracker.get(insn.rs, (None, None)) + if hi_vram is not None and imm_value is not None: # found match + lo_vram = vaddr + const_value = (imm_value << 0x10) | insn.getProcessedImmediate() + put_symbols(symbols_dict, "constants", {hi_vram: const_value}) + put_symbols(symbols_dict, "constants", {lo_vram: const_value}) + # clear lui tracking state if register is clobbered by the ori instruction itself + # insn.rt == insn.rs or + if insn.rt in lui_tracker.keys(): + clobber_conditionally(insn) + elif insn.canBeLo(): # try match with tracked lui and mark symbol - hi_vram, imm_value = lui_tracker.get( - insn.rs if insn.id == mips_isa.MIPS_INS_ADDIU else insn.base, (None, None) - ) + hi_vram, imm_value = lui_tracker.get(insn.rs, (None, None)) # if a match was found, validate and record the symbol, TODO improve validation - if hi_vram != None and ( - (((imm_value >> 0x8) & 0xF) != 0 and imm_value < 0x1000) - or (imm_value >= 0x8000 and imm_value < 0x80D0) - or (imm_value >= 0xA400 and imm_value < 0xA480) - or (imm_value < 0x0400 and insn.id == mips_isa.MIPS_INS_ADDIU) + if ( + hi_vram is not None + and imm_value is not None + and validateLuiImm(imm_value, insn) ): lo_vram = vaddr - symbol_value = (imm_value << 0x10) + insn.imm + symbol_value = (imm_value << 0x10) + insn.getProcessedImmediate() put_symbols(symbols_dict, "symbols", {hi_vram: symbol_value}) put_symbols(symbols_dict, "symbols", {lo_vram: symbol_value}) - if insn.id == mips_isa.MIPS_INS_LW: + if insn.uniqueId == rabbitizer.InstrId.cpu_lw: # try find jr within the same block cur_idx = i lookahead_insn = insns[cur_idx] # TODO fix vaddr here # still in same block unless one of these instructions are found - while lookahead_insn.id not in [ - *MIPS_BRANCH_INSNS, - mips_isa.MIPS_INS_JAL, - mips_isa.MIPS_INS_JALR, - mips_isa.MIPS_INS_J, - ]: - if lookahead_insn.id == mips_isa.MIPS_INS_JR: - if lookahead_insn.rs == ( - insn.ft - if insn.id in MIPS_FP_LOAD_STORE_INSNS - else insn.rt - ): + while lookahead_insn.isJrNotRa() or not ( + lookahead_insn.isBranch() or lookahead_insn.isJump() + ): + if lookahead_insn.uniqueId == rabbitizer.InstrId.cpu_jr: + if lookahead_insn.rs == insn.rt: # read the jtbl and add targets to func_jtbl_labels assert ( rodata is not None @@ -881,104 +833,52 @@ def find_symbols_in_text(section, rodata_section, data_regions): put_symbol(symbols_dict, "jtbls", symbol_value) # found a jr that matches, no need to keep searching break - elif ( - insn.ft if insn.id in MIPS_FP_LOAD_STORE_INSNS else insn.rt - ) in [ - lookahead_insn.value_forname(field) - for field in lookahead_insn.fields[1:] - ]: - # register clobbered, no need to keep searching - break cur_idx += 1 # found end before finding jr insn, not a jtbl if cur_idx >= len(raw_insns): break lookahead_insn = insns[cur_idx] # TODO fix vaddr here - elif insn.id == mips_isa.MIPS_INS_LD: # doubleword loads + elif insn.uniqueId == rabbitizer.InstrId.cpu_ld: # doubleword loads put_symbol(symbols_dict, "dwords", symbol_value) - elif insn.id in [mips_isa.MIPS_INS_LWC1, mips_isa.MIPS_INS_SWC1]: # float load/stores - # add float - put_symbol(symbols_dict, "floats", symbol_value) - elif insn.id in [mips_isa.MIPS_INS_LDC1, mips_isa.MIPS_INS_SDC1]: # double load/stores - # add double - put_symbol(symbols_dict, "doubles", symbol_value) - elif ( - insn.id == mips_isa.MIPS_INS_ADDIU and vaddr % 4 == 0 - ): # strings seem to only ever be 4-byte aligned - # add possible string - put_symbol(symbols_dict, "prospective_strings", symbol_value) + elif insn.doesDereference() and insn.isFloat(): + if insn.isDouble(): # double load/stores + # add double + put_symbol(symbols_dict, "doubles", symbol_value) + else: # float load/stores + # add float + put_symbol(symbols_dict, "floats", symbol_value) + elif not insn.doesDereference() and not insn.isUnsigned(): + if vaddr % 4 == 0: # strings seem to only ever be 4-byte aligned + # add possible string + put_symbol(symbols_dict, "prospective_strings", symbol_value) # clear lui tracking state if register is clobbered by the addiu/load instruction itself - # insn.rt == (insn.rs if insn.id == mips_isa.MIPS_INS_ADDIU else insn.base) and - if insn.id not in MIPS_STORE_INSNS and insn.id not in MIPS_FP_LOAD_INSNS: - clobber_conditionally(insn) - elif insn.id == mips_isa.MIPS_INS_ORI: - # try match with tracked lui and mark constant - hi_vram, imm_value = lui_tracker.get(insn.rs, (None, None)) - if hi_vram != None: # found match - lo_vram = vaddr - const_value = (imm_value << 0x10) | insn.imm - put_symbols(symbols_dict, "constants", {hi_vram: const_value}) - put_symbols(symbols_dict, "constants", {lo_vram: const_value}) - # clear lui tracking state if register is clobbered by the ori instruction itself - # insn.rt == insn.rs or - if insn.rt in lui_tracker.keys(): + if not insn.doesStore() and not (insn.doesLoad() and insn.isFloat()): clobber_conditionally(insn) else: # clear lui tracking if register is clobbered by something unrelated if ( - insn.id == mips_isa.MIPS_INS_ADDU + insn.uniqueId == rabbitizer.InstrId.cpu_addu and insn.rs in lui_tracker.keys() - and (insn.rd == insn.rs) + and insn.rd == insn.rs ): - # array accesses optimisation: - # lui reg, %hi(symbol) - # addu reg, reg, idx - # lw reg, %lo(symbol)(reg) - # instead of clobbering, keep it if the second operand is also the first - # if the output is not currently tracked it will behave as intended anyway + """ + array accesses optimisation: + lui reg, %hi(symbol) + addu reg, reg, idx + lw reg, %lo(symbol)(reg) + instead of clobbering, keep it if the second operand is also the first + if the output is not currently tracked it will behave as intended anyway + """ pass # insns listed either write to fprs/cop0 or don't write to any - elif insn.id not in [ - mips_isa.MIPS_INS_MTC0, - mips_isa.MIPS_INS_MTC1, - mips_isa.MIPS_INS_DMTC1, - mips_isa.MIPS_INS_MULT, - mips_isa.MIPS_INS_MULTU, - mips_isa.MIPS_INS_DMULT, - mips_isa.MIPS_INS_DMULTU, - mips_isa.MIPS_INS_DIV, - mips_isa.MIPS_INS_DIVU, - mips_isa.MIPS_INS_DDIV, - mips_isa.MIPS_INS_DDIVU, - mips_isa.MIPS_INS_MTHI, - mips_isa.MIPS_INS_MTLO, - mips_isa.MIPS_INS_CTC1, - mips_isa.MIPS_INS_NOP, - mips_isa.MIPS_INS_BREAK, - mips_isa.MIPS_INS_TLBP, - mips_isa.MIPS_INS_TLBR, - mips_isa.MIPS_INS_TLBWI, - mips_isa.MIPS_INS_MOV_S, - mips_isa.MIPS_INS_MOV_D, - mips_isa.MIPS_INS_C_LT_S, - mips_isa.MIPS_INS_C_LT_D, - mips_isa.MIPS_INS_DIV_S, - mips_isa.MIPS_INS_MUL_S, - mips_isa.MIPS_INS_TRUNC_W_S, - mips_isa.MIPS_INS_CVT_S_W, - mips_isa.MIPS_INS_SUB_S, - mips_isa.MIPS_INS_ADD_S, - ]: + else: clobber_conditionally(insn) ############# Start text disassembly ########## # Symbols aren't avaialble here yet, so placeholders are added # in each instruction, to be looked up later - mnemonic = f" {insn.mnemonic}" if delay_slot else insn.mnemonic - op_str = insn.op_str - instr = {"id": insn.id} - if vaddr in full_file_list[info["name"]]: + if info["name"] in full_file_list and vaddr in full_file_list[info["name"]]: if cur_file != "": if cur_vaddr in info["syms"]: result_files.append([cur_file, results]) @@ -988,51 +888,10 @@ def find_symbols_in_text(section, rodata_section, data_regions): if cur_file == "": cur_file = f"{info['name']}_{vaddr:08X}" - if insn.id in MIPS_BRANCH_INSNS: - op_str_parts = [] - for field in insn.fields: - if field == "offset": - op_str_parts.append(f".L{insn.offset:08X}") - else: - op_str_parts.append(insn.format_field(field)) - op_str = [", ".join(op_str_parts)] - - elif insn.id in MIPS_JUMP_INSNS: - op_str = [] - op_str_parts = [] - for field in insn.fields: - if field == "target": - op_str_parts.append([insn.target, False, True]) - else: - op_str_parts.append(insn.format_field(field)) - for x, part in enumerate(op_str_parts): - if x + 1 < len(op_str_parts): - part += ", " - op_str.append(part) - - elif insn.id == mips_isa.MIPS_INS_LUI: - op_str = [op_str] - instr["rt"] = insn.rt - - elif insn.id == mips_isa.MIPS_INS_ADDIU or insn.id in MIPS_LOAD_STORE_INSNS: - op_str = [op_str] - instr["rt"] = insn.rt - instr["rs"] = insn.rs - instr["ft"] = insn.ft - instr["base"] = insn.base - - elif insn.id == mips_isa.MIPS_INS_ORI: - op_str = [op_str] - instr["rt"] = insn.rt - instr["rs"] = insn.rs - results.append( { - "vaddr": vaddr, - "insn": instr, - "addr": f"/* {i*4:06X} {vaddr:08X} {raw_insns[i]:08X} */ ", - "mnem": mnemonic, - "op": op_str, + "insn": insn, + "comment": f"/* {i*4:06X} {vaddr:08X} {raw_insns[i]:08X} */", "data": False, } ) @@ -1041,22 +900,30 @@ def find_symbols_in_text(section, rodata_section, data_regions): if delay_slot and delayed_insn is not None: if ( - delayed_insn.id == mips_isa.MIPS_INS_JAL - or delayed_insn.id == mips_isa.MIPS_INS_JALR - or (delayed_insn.id == mips_isa.MIPS_INS_JR and delayed_insn.rs == mips_isa.MIPS_REG_RA) + delayed_insn.uniqueId == rabbitizer.InstrId.cpu_jal + or delayed_insn.uniqueId == rabbitizer.InstrId.cpu_jalr + or delayed_insn.isJrRa() ): # destroy lui tracking state lui_tracker.clear() - elif delayed_insn.id == mips_isa.MIPS_INS_JR and vaddr == next_jtbl_jr + 4: + elif ( + delayed_insn.uniqueId == rabbitizer.InstrId.cpu_jr + and vaddr == next_jtbl_jr + 4 + ): # save lui tracking state for each jtbl label for label in individual_jtbl_labels[next_jtbl_jr]: save_tracker(label, lui_tracker.copy()) next_jtbl_jr = 0 - else: + elif delayed_insn.isBranch(): # save lui tracking state - save_tracker(delayed_insn.offset, lui_tracker.copy()) + save_tracker( + delayed_insn.getBranchOffset() + delayed_insn.vram, + lui_tracker.copy(), + ) + if branch_likely_delay_slot_save is not None: + save_tracker(delayed_insn.getBranchOffset() + delayed_insn.vram, branch_likely_delay_slot_save) # destroy current lui tracking state for unconditional branches - if delayed_insn.id == mips_isa.MIPS_INS_B: + if delayed_insn.isUnconditionalBranch(): lui_tracker.clear() delayed_insn = None @@ -1221,7 +1088,7 @@ def find_symbols_in_rodata(section): return symbols_dict -def asm_header(section_name): +def asm_header(section_name: str): return f""".include "macro.inc" # assembler directives @@ -1235,6 +1102,43 @@ def asm_header(section_name): """ +def getImmOverride(insn: rabbitizer.Instruction): + if insn.isBranch(): + return f".L{insn.getBranchOffset() + insn.vram:08X}" + elif insn.isJump(): + return proper_name(insn.getInstrIndexAsVram(), in_data=False, is_symbol=True) + + elif insn.uniqueId == rabbitizer.InstrId.cpu_ori: + constant_value = constants.get(insn.vram, None) + if constant_value is not None: + return f"(0x{constant_value:08X} & 0xFFFF)" + + elif insn.canBeHi(): + symbol_value = symbols.get(insn.vram, None) + if symbol_value is not None: + return f"%hi({proper_name(symbol_value)})" + constant_value = constants.get(insn.vram, None) + if constant_value is not None: + return f"(0x{constant_value:08X} >> 16)" + + elif insn.canBeLo(): + symbol_value = symbols.get(insn.vram, None) + if symbol_value is not None: + return f"%lo({proper_name(symbol_value)})" + return None + + +def getLabelForVaddr(vaddr: int, in_data: bool = False) -> str: + label = "" + if vaddr in functions: + label += f"\nglabel {proper_name(vaddr, in_data=in_data)}\n" + if vaddr in jtbl_labels: + label += f"glabel L{vaddr:08X}\n" + if vaddr in branch_labels: + label += f".L{vaddr:08X}:\n" + return label + + def fixup_text_symbols(data, vram, data_regions, info): segment_dirname = "" if info["type"] != "overlay" else "overlays/" if info["type"] in ("boot", "code"): @@ -1251,73 +1155,34 @@ def fixup_text_symbols(data, vram, data_regions, info): # We didn't have full symbols available during initial disassembly, # so here we loop over each instruction, and do symbol lookups, add labels etc - for i, entry in enumerate(file): - vaddr = entry["vaddr"] - - if vaddr in functions: - text.append(f"\nglabel {proper_name(vaddr, in_data=entry['data'])}\n") - if vaddr in jtbl_labels: - text.append(f"glabel L{vaddr:08X}\n") - if vaddr in branch_labels: - text.append(f".L{vaddr:08X}:\n") - - line = entry["addr"] - if not entry["data"]: - line += f"{entry['mnem']:12}" - + delay_slot = False + disasm_as_data = False + for entry in file: insn = entry["insn"] - if insn["id"] in MIPS_JUMP_INSNS: - for op_part in entry["op"]: - if type(op_part) == list: - line += proper_name( - op_part[0], in_data=op_part[1], is_symbol=op_part[2] - ) - else: - line += op_part + in_data = entry["data"] + comment = entry["comment"] - elif insn["id"] == mips_isa.MIPS_INS_LUI: - symbol_value = symbols.get(vaddr, None) - if symbol_value is not None: - line += ( - f"{ mips_isa.mips_gpr_names[insn['rt']]}, %hi({proper_name(symbol_value)})" - ) - else: - constant_value = constants.get(vaddr, None) - if constant_value is not None: - line += ( - f"{ mips_isa.mips_gpr_names[insn['rt']]}, (0x{constant_value:08X} >> 16)" - ) - else: - line += entry["op"][0] + text.append(getLabelForVaddr(insn.vram, in_data)) + if insn.vram in functions: + # new function, needs to check this again + disasm_as_data = False - elif insn["id"] == mips_isa.MIPS_INS_ADDIU or insn["id"] in MIPS_LOAD_STORE_INSNS: - symbol_value = symbols.get(vaddr, None) - if symbol_value is not None: - if insn["id"] == mips_isa.MIPS_INS_ADDIU: - line += f"{ mips_isa.mips_gpr_names[insn['rt']]}, { mips_isa.mips_gpr_names[insn['rs']]}, %lo({proper_name(symbol_value)})" - else: - line += f"{mips_isa.mips_fpr_names[insn['ft']] if insn['id'] in MIPS_FP_LOAD_STORE_INSNS else mips_isa.mips_gpr_names[insn['rt']]}, %lo({proper_name(symbol_value)})({ mips_isa.mips_gpr_names[insn['base']]})" - else: - line += entry["op"][0] + if in_data or disasm_as_data: + disasm_as_data = True + text.append(f"{comment} .word 0x{insn.getRaw():08X}\n") + continue - elif insn["id"] == mips_isa.MIPS_INS_ORI: - constant_value = constants.get(vaddr, None) - if constant_value is not None: - line += f"{ mips_isa.mips_gpr_names[insn['rt']]}, { mips_isa.mips_gpr_names[insn['rs']]}, (0x{constant_value:08X} & 0xFFFF)" - else: - line += entry["op"][0] + extraLJust = 0 + if delay_slot: + extraLJust = -1 + comment += " " - else: - for part in entry["op"]: - if type(part) == list: - line += ( - f"{proper_name(part[0], in_data=part[1], is_symbol=part[2])}" - ) - else: - line += part + disassembled = insn.disassemble( + immOverride=getImmOverride(insn), extraLJust=extraLJust + ) + text.append(f"{comment} {disassembled}\n") - line += "\n" - text.append(line) + delay_slot = insn.hasDelaySlot() with open(f"{ASM_OUT}/{segment_dirname}/{info['name']}.text.s", "w") as outfile: outfile.write("".join(text)) @@ -1333,15 +1198,12 @@ def disassemble_text(data, vram, data_regions, info): segment_dirname = ("" if info["type"] != "overlay" else "overlays/") + info["name"] os.makedirs(f"{ASM_OUT}/{segment_dirname}/", exist_ok=True) - delayed_insn = None delay_slot = False for i, raw_insn in enumerate(raw_insns, 0): i *= 4 vaddr = vram + i - insn = mips_isa.decode_insn(raw_insns[i // 4], vaddr) - mnemonic = insn.mnemonic - op_str = insn.op_str + insn = rabbitizer.Instruction(raw_insns[i // 4], vram=vaddr) if vaddr in full_file_list[info["name"]]: if cur_file != "": @@ -1372,63 +1234,20 @@ def disassemble_text(data, vram, data_regions, info): ) continue - # LABELS - if vaddr in functions: - result += f"\nglabel {proper_name(vaddr)}\n" - if vaddr in jtbl_labels: - result += f"glabel L{vaddr:08X}\n" - if vaddr in branch_labels: - result += f".L{vaddr:08X}:\n" - - # INSTRUCTIONS FORMATTING/CORRECTING - if insn.id in MIPS_BRANCH_INSNS: - op_str_parts = [] - for field in insn.fields: - if field == "offset": - op_str_parts.append(f".L{insn.offset:08X}") - else: - op_str_parts.append(insn.format_field(field)) - op_str = ", ".join(op_str_parts) - delayed_insn = insn - elif insn.id in MIPS_JUMP_INSNS: - op_str_parts = [] - for field in insn.fields: - if field == "target": - op_str_parts.append(proper_name(insn.target, is_symbol=True)) - else: - op_str_parts.append(insn.format_field(field)) - op_str = ", ".join(op_str_parts) - delayed_insn = insn - elif insn.id == mips_isa.MIPS_INS_LUI: - symbol_value = symbols.get(vaddr, None) - if symbol_value is not None: - op_str = f"{ mips_isa.mips_gpr_names[insn.rt]}, %hi({proper_name(symbol_value)})" - else: - constant_value = constants.get(vaddr, None) - if constant_value is not None: - op_str = ( - f"{ mips_isa.mips_gpr_names[insn.rt]}, (0x{constant_value:08X} >> 16)" - ) - elif insn.id == mips_isa.MIPS_INS_ADDIU or insn.id in MIPS_LOAD_STORE_INSNS: - symbol_value = symbols.get(vaddr, None) - if symbol_value is not None: - if insn.id == mips_isa.MIPS_INS_ADDIU: - op_str = f"{ mips_isa.mips_gpr_names[insn.rt]}, { mips_isa.mips_gpr_names[insn.rs]}, %lo({proper_name(symbol_value)})" - else: - op_str = f"{mips_isa.mips_fpr_names[insn.ft] if insn.id in MIPS_FP_LOAD_STORE_INSNS else mips_isa.mips_gpr_names[insn.rt]}, %lo({proper_name(symbol_value)})({ mips_isa.mips_gpr_names[insn.base]})" - elif insn.id == mips_isa.MIPS_INS_ORI: - constant_value = constants.get(vaddr, None) - if constant_value is not None: - op_str = f"{ mips_isa.mips_gpr_names[insn.rt]}, { mips_isa.mips_gpr_names[insn.rs]}, (0x{constant_value:08X} & 0xFFFF)" + result += getLabelForVaddr(vaddr) + comment = f"/* {i:06X} {vaddr:08X} {raw_insn:08X} */" + extraLJust = 0 if delay_slot: - mnemonic = " " + mnemonic - delayed_insn = None - delay_slot = False - if delayed_insn is not None: - delay_slot = True + extraLJust = -1 + comment += " " - result += f"/* {i:06X} {vaddr:08X} {raw_insn:08X} */ {mnemonic:12}{op_str}\n" + disassembled = insn.disassemble( + immOverride=getImmOverride(insn), extraLJust=extraLJust + ) + result += f"{comment} {disassembled}\n" + + delay_slot = insn.hasDelaySlot() with open(f"{ASM_OUT}/{segment_dirname}/{cur_file}.text.s", "w") as outfile: outfile.write(result) @@ -1703,12 +1522,16 @@ def disassemble_rodata(data, vram, end, info): if symbol in strings: string_data = data[data_offset : data_offset + data_size] - string_data = string_data[: string_data.index(0)] - # ensure strings don't have a null char midway through - assert all( - [b != 0 for b in string_data[:-1]] - ), f"{symbol:08X} , {data_size:X} , {string_data}" - r += f"/* {data_base:06X} {symbol:08X} */ {try_decode_string(string_data, force_ascii=force_ascii_str)}\n{STR_INDENT}.balign 4\n" + if 0 in string_data: + string_data = string_data[: string_data.index(0)] + # ensure strings don't have a null char midway through + assert all( + [b != 0 for b in string_data[:-1]] + ), f"{symbol:08X} , {data_size:X} , {string_data}" + r += f"/* {data_base:06X} {symbol:08X} */ {try_decode_string(string_data, force_ascii=force_ascii_str)}\n{STR_INDENT}.balign 4\n" + else: + # Not null-terminanted. Can't be a string + strings.remove(symbol) elif symbol % 8 == 0 and data_size % 8 == 0 and symbol in doubles: r += ( "\n".join( @@ -2392,9 +2215,10 @@ for section in all_sections: rodata_section = None pool.apply_async( find_symbols_in_text, - args=(section, rodata_section if rodata_section else None, data_regions), + args=(section, rodata_section, data_regions), callback=update_symbols_from_dict, ) + elif section[2] == "data": pool.apply_async( find_symbols_in_data, args=(section), callback=update_symbols_from_dict diff --git a/tools/disasm/files.txt b/tools/disasm/files.txt index cd1bbac2f..ffa305cdd 100644 --- a/tools/disasm/files.txt +++ b/tools/disasm/files.txt @@ -418,14 +418,14 @@ 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", 0x80138BA0 : "z_skin_matrix", 0x8013A240 : "z_snap", 0x8013A7C0 : "z_sub_s", - 0x8013EC10 : "code_8013EC10", + 0x8013EC10 : "z_rumble", 0x8013EE60 : "z_view", 0x80140260 : "z_vimode", 0x80140E80 : "code_80140E80", @@ -471,7 +471,7 @@ 0x8017FEB0 : "sys_math_atan", 0x80180160 : "sys_matrix", 0x80182C90 : "sys_ucode", - 0x80182CE0 : "", + 0x80182CE0 : "sys_rumble", 0x80183070 : "code_80183070", 0x801830A0 : "c_keyframe", 0x80185660 : "sys_slowly", @@ -484,7 +484,7 @@ 0x8018EB60 : "audio_load", 0x80192BE0 : "code_80192BE0", 0x80194710 : "audio_dcache", - 0x80194790 : "code_80194790", + 0x80194790 : "aisetnextbuf", 0x80194930 : "audio_playback", 0x80196A00 : "audio_effects", 0x801974D0 : "audio_seqplayer", @@ -526,7 +526,7 @@ 0x801BB090 : "z_debug_mode", 0x801BB120 : "z_demo", 0x801BB170 : "z_draw", - 0x801BC240 : "z_eff_footmark", + 0x801BC210 : "z_eff_footmark", 0x801BC2A0 : "", 0x801BC420 : "z_face_reaction", 0x801BD830 : "", @@ -544,7 +544,7 @@ 0x801BF550 : "z_map_exp", 0x801BF5C0 : "z_msgevent", 0x801BF6C0 : "z_parameter", - 0x801BFDD0 : "z_player_lib", + 0x801BFDA0 : "z_player_lib", 0x801C0EC0 : "z_quake", 0x801C0EF0 : "z_rcp", 0x801C1D10 : "z_room", @@ -554,7 +554,7 @@ 0x801C2730 : "", 0x801C3B60 : "z_scene_proc", 0x801C3CA0 : "z_scene_table", - 0x801C5C50 : "", + 0x801C5C50 : "z_schedule", 0x801C5CB0 : "z_skelanime", 0x801C5CD0 : "z_skin_matrix", 0x801C5D10 : "z_sub_s", @@ -581,12 +581,13 @@ 0x801D15D0 : "sys_math_atan", 0x801D1DE0 : "sys_matrix", 0x801D1E60 : "sys_ucode", - 0x801D1E70 : "", + 0x801D1E70 : "sys_rumble", + 0x801D1E80 : "code_801D1E80", 0x801D2E80 : "audio_data", 0x801D5FB0 : "audio_synthesis", 0x801D5FE0 : "audio_load", 0x801D5FF0 : "code_80192BE0", - 0x801D6010 : "code_80194790", + 0x801D6010 : "aisetnextbuf", 0x801D6190 : "audio_effects", 0x801D61A0 : "audio_seqplayer", 0x801D6200 : "audio_dramStack", @@ -638,7 +639,7 @@ 0x801DE5D0 : "z_skin_matrix", 0x801DE5E0 : "z_sub_s", 0x801DE890 : "", - 0x801DF090 : "code_8013EC10", + 0x801DF090 : "z_rumble", 0x801DF0A0 : "z_view", 0x801DF0B0 : "z_vimode", 0x801DF120 : "code_80140E80", @@ -711,7 +712,7 @@ 0x801F5AA0 : "z_scene_proc", 0x801F5AB0 : "z_skelanime", 0x801F5AC0 : "z_skin", - 0x801F69D0 : "code_8013EC10", + 0x801F69D0 : "z_rumble", 0x801F6AE0 : "z_vr_box_draw", 0x801F6AF0 : "z_sram_NES", 0x801F6B00 : "z_message", diff --git a/tools/disasm/functions.txt b/tools/disasm/functions.txt index bed963c7a..bea647d45 100644 --- a/tools/disasm/functions.txt +++ b/tools/disasm/functions.txt @@ -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",), @@ -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",), @@ -510,7 +510,7 @@ 0x800A7D28:("Item_DropCollectibleRandom",), 0x800A8150:("func_800A8150",), 0x800A817C:("func_800A817C",), - 0x800A81A4:("func_800A81A4",), + 0x800A81A4:("Item_CanDropBigFairy",), 0x800A81F0:("EffectBlure_AddVertex",), 0x800A8514:("EffectBlure_AddSpace",), 0x800A8558:("EffectBlure_InitElements",), @@ -552,7 +552,7 @@ 0x800AF050:("EffectTireMark_Update",), 0x800AF284:("EffectTireMark_SetVertices",), 0x800AF310:("EffectTireMark_Draw",), - 0x800AF710:("Effect_GetGlobalCtx",), + 0x800AF710:("Effect_GetPlayState",), 0x800AF720:("Effect_GetByIndex",), 0x800AF87C:("Effect_InitStatus",), 0x800AF890:("Effect_Init",), @@ -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",), @@ -626,16 +626,16 @@ 0x800B242C:("EffectSsSibuki_Spawn",), 0x800B249C:("EffectSsSibuki_SpawnBurst",), 0x800B25D8:("EffectSsStone1_Spawn",), - 0x800B262C:("EffectSsHitMark_Spawn",), - 0x800B2684:("EffectSsHitMark_SpawnFixedScale",), - 0x800B26A8:("EffectSsHitMark_SpawnCustomScale",), + 0x800B262C:("EffectSsHitmark_Spawn",), + 0x800B2684:("EffectSsHitmark_SpawnFixedScale",), + 0x800B26A8:("EffectSsHitmark_SpawnCustomScale",), 0x800B26D4:("EffectSsFhgFlash_SpawnShock",), 0x800B2738:("EffectSsKFire_Spawn",), 0x800B27A0:("EffectSsSolderSrchBall_Spawn",), 0x800B2810:("EffectSsKakera_Spawn",), 0x800B28C8:("EffectSsIcePiece_Spawn",), 0x800B2930:("EffectSsIcePiece_SpawnBurst",), - 0x800B2AC4:("EffectSsEnIce_SpawnFlyingVec3f",), + 0x800B2AC4:("EffectSsEnIce_SpawnFlying",), 0x800B2B44:("func_800B2B44",), 0x800B2B7C:("func_800B2B7C",), 0x800B2BC0:("EffectSsEnIce_Spawn",), @@ -783,7 +783,7 @@ 0x800B882C:("func_800B882C",), 0x800B886C:("func_800B886C",), 0x800B8898:("Actor_GetScreenPos",), - 0x800B8934:("func_800B8934",), + 0x800B8934:("Actor_OnScreen",), 0x800B89F8:("Actor_HasParent",), 0x800B8A1C:("Actor_PickUp",), 0x800B8B84:("Actor_PickUpNearby",), @@ -892,7 +892,7 @@ 0x800BE504:("func_800BE504",), 0x800BE568:("func_800BE568",), 0x800BE5CC:("func_800BE5CC",), - 0x800BE63C:("func_800BE63C",), + 0x800BE63C:("Actor_IsSmallChest",), 0x800BE680:("Actor_DrawDamageEffects",), 0x800BF7CC:("Actor_SpawnIceEffects",), 0x800BF9A0:("ActorOverlayTable_FaultPrint",), @@ -1047,13 +1047,13 @@ 0x800C9598:("BgCheck_InitCollisionHeaders",), 0x800C9640:("BgCheck_ResetPolyCheckTbl",), 0x800C9694:("SurfaceType_GetData",), - 0x800C9704:("SurfaceType_GetCamDataIndex",), - 0x800C9728:("func_800C9728",), - 0x800C9770:("SurfaceType_GetCameraSetting",), - 0x800C97F8:("func_800C97F8",), - 0x800C9844:("func_800C9844",), - 0x800C98CC:("func_800C98CC",), - 0x800C9924:("SurfaceType_GetCamPosData",), + 0x800C9704:("SurfaceType_GetBgCamIndex",), + 0x800C9728:("BgCheck_GetBgCamSettingImpl",), + 0x800C9770:("BgCheck_GetBgCamSetting",), + 0x800C97F8:("BgCheck_GetBgCamCountImpl",), + 0x800C9844:("BgCheck_GetBgCamCount",), + 0x800C98CC:("BgCheck_GetBgCamFuncDataImpl",), + 0x800C9924:("BgCheck_GetBgCamFuncData",), 0x800C99AC:("SurfaceType_GetSceneExitIndex",), 0x800C99D4:("func_800C99D4",), 0x800C99FC:("func_800C99FC",), @@ -1085,9 +1085,9 @@ 0x800CA1E8:("WaterBox_GetSurface1_2",), 0x800CA22C:("WaterBox_GetSurface2",), 0x800CA568:("func_800CA568",), - 0x800CA634:("WaterBox_GetCamDataIndex",), - 0x800CA648:("WaterBox_GetCameraSetting",), - 0x800CA6B8:("func_800CA6B8",), + 0x800CA634:("WaterBox_GetBgCamIndex",), + 0x800CA648:("WaterBox_GetBgCamSetting",), + 0x800CA6B8:("WaterBox_GetSceneBgCamSetting",), 0x800CA6D8:("WaterBox_GetLightSettingIndex",), 0x800CA6F0:("func_800CA6F0",), 0x800CA9D0:("func_800CA9D0",), @@ -1113,37 +1113,37 @@ 0x800CAFDC:("DynaPolyActor_IsInHeavySwitchPressedState",), 0x800CB000:("DynaPolyActor_ValidateMove",), 0x800CB210:("Camera_fabsf",), - 0x800CB240:("Camera_LengthVec3f",), - 0x800CB270:("func_800CB270",), - 0x800CB330:("Camera_Lerpf",), - 0x800CB398:("Camera_Lerps",), - 0x800CB42C:("func_800CB42C",), - 0x800CB4C0:("Camera_LerpVec3f",), - 0x800CB544:("func_800CB544",), - 0x800CB584:("func_800CB584",), - 0x800CB5DC:("func_800CB5DC",), - 0x800CB60C:("func_800CB60C",), - 0x800CB674:("func_800CB674",), - 0x800CB6C8:("func_800CB6C8",), - 0x800CB700:("func_800CB700",), - 0x800CB780:("func_800CB780",), + 0x800CB240:("Camera_Vec3fMagnitude",), + 0x800CB270:("Camera_QuadraticAttenuation",), + 0x800CB330:("Camera_LerpCeilF",), + 0x800CB398:("Camera_LerpCeilS",), + 0x800CB42C:("Camera_LerpFloorS",), + 0x800CB4C0:("Camera_LerpCeilVec3f",), + 0x800CB544:("Camera_SetUpdateRatesFastPitch",), + 0x800CB584:("Camera_SetUpdateRatesFastYaw",), + 0x800CB5DC:("Camera_SetUpdateRatesSlow",), + 0x800CB60C:("Camera_Vec3sToVec3f",), + 0x800CB674:("Camera_AngleDiffAndScale",), + 0x800CB6C8:("Camera_UpdateAtActorOffset",), + 0x800CB700:("Camera_GetFocalActorHeight",), + 0x800CB780:("Camera_GetRunSpeedLimit",), 0x800CB7CC:("func_800CB7CC",), - 0x800CB7F8:("func_800CB7F8",), - 0x800CB828:("func_800CB828",), + 0x800CB7F8:("Camera_IsMountedOnHorse",), + 0x800CB828:("Camera_IsDekuHovering",), 0x800CB854:("func_800CB854",), - 0x800CB880:("func_800CB880",), - 0x800CB8C8:("func_800CB8C8",), - 0x800CB8F4:("func_800CB8F4",), + 0x800CB880:("Camera_IsSwimming",), + 0x800CB8C8:("Camera_IsDiving",), + 0x800CB8F4:("Camera_IsPlayerFormZora",), 0x800CB924:("func_800CB924",), 0x800CB950:("func_800CB950",), - 0x800CBA08:("func_800CBA08",), - 0x800CBA34:("func_800CBA34",), + 0x800CBA08:("Camera_IsClimbingLedge",), + 0x800CBA34:("Camera_IsChargingSwordOrDekuFlowerDive",), 0x800CBA7C:("func_800CBA7C",), 0x800CBAAC:("func_800CBAAC",), - 0x800CBAD4:("func_800CBAD4",), - 0x800CBB58:("func_800CBB58",), + 0x800CBAD4:("Camera_GetFocalActorPos",), + 0x800CBB58:("Camera_IsUnderwaterAsZora",), 0x800CBB88:("func_800CBB88",), - 0x800CBC00:("func_800CBC00",), + 0x800CBC00:("Camera_IsUsingZoraFins",), 0x800CBC30:("func_800CBC30",), 0x800CBC84:("func_800CBC84",), 0x800CBFA4:("func_800CBFA4",), @@ -1154,10 +1154,10 @@ 0x800CC488:("func_800CC488",), 0x800CC56C:("func_800CC56C",), 0x800CC5C8:("func_800CC5C8",), - 0x800CC740:("func_800CC740",), - 0x800CC7A8:("func_800CC7A8",), - 0x800CC804:("func_800CC804",), - 0x800CC874:("func_800CC874",), + 0x800CC740:("Camera_GetBgCamOrActorCsCamSetting",), + 0x800CC7A8:("Camera_GetBgCamOrActorCsCamFuncData",), + 0x800CC804:("Camera_GetBgCamIndex",), + 0x800CC874:("Camera_GetWaterBoxBgCamSetting",), 0x800CC938:("func_800CC938",), 0x800CC958:("func_800CC958",), 0x800CC9C0:("func_800CC9C0",), @@ -1258,8 +1258,8 @@ 0x800DDDD0:("Camera_Init",), 0x800DDFE0:("func_800DDFE0",), 0x800DE0E0:("func_800DE0E0",), - 0x800DE0EC:("func_800DE0EC",), - 0x800DE308:("func_800DE308",), + 0x800DE0EC:("Camera_InitPlayerSettings",), + 0x800DE308:("Camera_ChangeStatus",), 0x800DE324:("func_800DE324",), 0x800DE62C:("func_800DE62C",), 0x800DE840:("func_800DE840",), @@ -1271,24 +1271,24 @@ 0x800DF840:("Camera_ChangeMode",), 0x800DF86C:("func_800DF86C",), 0x800DF8EC:("func_800DF8EC",), - 0x800DFAC8:("func_800DFAC8",), + 0x800DFAC8:("Camera_ChangeSetting",), 0x800DFB14:("Camera_ChangeDataIdx",), 0x800DFC1C:("func_800DFC1C",), 0x800DFC40:("func_800DFC40",), 0x800DFC68:("Camera_GetInputDirYaw",), - 0x800DFC90:("func_800DFC90",), + 0x800DFC90:("Camera_GetCamDir",), 0x800DFCB4:("Camera_GetCamDirPitch",), 0x800DFCDC:("Camera_GetCamDirYaw",), - 0x800DFD04:("func_800DFD04",), - 0x800DFD78:("func_800DFD78",), + 0x800DFD04:("Camera_AddQuake",), + 0x800DFD78:("Camera_SetViewParam",), 0x800DFEF0:("func_800DFEF0",), 0x800DFF18:("func_800DFF18",), 0x800DFF34:("func_800DFF34",), 0x800DFF44:("func_800DFF44",), 0x800DFF60:("Camera_SetFlags",), 0x800DFF84:("Camera_ClearFlags",), - 0x800DFFAC:("func_800DFFAC",), - 0x800E007C:("func_800E007C",), + 0x800DFFAC:("Camera_ChangeDoorCam",), + 0x800E007C:("Camera_Copy",), 0x800E01AC:("func_800E01AC",), 0x800E01B8:("Camera_GetQuakeOffset",), 0x800E01DC:("func_800E01DC",), @@ -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",), @@ -1583,29 +1583,29 @@ 0x800EE29C:("Cutscene_CheckActorAction",), 0x800EE2F4:("Cutscene_IsPlaying",), 0x800EE320:("GetItem_Draw",), - 0x800EE364:("func_800EE364",), - 0x800EE400:("func_800EE400",), - 0x800EE5FC:("func_800EE5FC",), - 0x800EE7D8:("func_800EE7D8",), - 0x800EE940:("func_800EE940",), - 0x800EEA48:("func_800EEA48",), - 0x800EEC18:("func_800EEC18",), - 0x800EED20:("func_800EED20",), - 0x800EEE34:("func_800EEE34",), - 0x800EEF4C:("func_800EEF4C",), - 0x800EF054:("func_800EF054",), - 0x800EF0F0:("func_800EF0F0",), - 0x800EF1F4:("func_800EF1F4",), - 0x800EF2AC:("func_800EF2AC",), - 0x800EF364:("func_800EF364",), - 0x800EF4D4:("func_800EF4D4",), - 0x800EF65C:("func_800EF65C",), - 0x800EF780:("func_800EF780",), - 0x800EF89C:("func_800EF89C",), - 0x800EF984:("func_800EF984",), - 0x800EFAB8:("func_800EFAB8",), - 0x800EFBFC:("func_800EFBFC",), - 0x800EFD44:("func_800EFD44",), + 0x800EE364:("GetItem_DrawBombchu",), + 0x800EE400:("GetItem_DrawPoes",), + 0x800EE5FC:("GetItem_DrawFairyBottle",), + 0x800EE7D8:("GetItem_DrawSkullToken",), + 0x800EE940:("GetItem_DrawCompass",), + 0x800EEA48:("GetItem_DrawPotion",), + 0x800EEC18:("GetItem_DrawGoronSword",), + 0x800EED20:("GetItem_DrawDekuNuts",), + 0x800EEE34:("GetItem_DrawRecoveryHeart",), + 0x800EEF4C:("GetItem_DrawFish",), + 0x800EF054:("GetItem_DrawOpa0",), + 0x800EF0F0:("GetItem_DrawOpa0Xlu1",), + 0x800EF1F4:("GetItem_DrawOpa01",), + 0x800EF2AC:("GetItem_DrawXlu01",), + 0x800EF364:("GetItem_DrawSeahorse",), + 0x800EF4D4:("GetItem_DrawFairyContainer",), + 0x800EF65C:("GetItem_DrawMoonsTear",), + 0x800EF780:("GetItem_DrawMagicArrow",), + 0x800EF89C:("GetItem_DrawUpgrades",), + 0x800EF984:("GetItem_DrawRupee",), + 0x800EFAB8:("GetItem_DrawSmallRupee",), + 0x800EFBFC:("GetItem_DrawWallet",), + 0x800EFD44:("GetItem_DrawRemains",), 0x800EFE60:("EffFootmark_Init",), 0x800EFF04:("EffFootmark_Add",), 0x800F00BC:("EffFootmark_Update",), @@ -1657,12 +1657,12 @@ 0x800F20F8:("ActorCutscene_GetLength",), 0x800F2138:("func_800F2138",), 0x800F2178:("func_800F2178",), - 0x800F21B8:("ActorCutscene_GetCurrentCamera",), + 0x800F21B8:("ActorCutscene_GetCurrentSubCamId",), 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",), @@ -1994,21 +1994,21 @@ 0x80109E70:("func_80109E70",), 0x80109EF8:("func_80109EF8",), 0x80109F78:("func_80109F78",), - 0x8010A000:("func_8010A000",), - 0x8010A074:("func_8010A074",), + 0x8010A000:("Map_GetDungeonOrBossAreaIndex",), + 0x8010A074:("Map_IsInDungeonOrBossAreaArea",), 0x8010A0A4:("func_8010A0A4",), - 0x8010A0F0:("func_8010A0F0",), - 0x8010A164:("func_8010A164",), - 0x8010A194:("func_8010A194",), - 0x8010A208:("func_8010A208",), + 0x8010A0F0:("Map_GetDungeonAreaIndex",), + 0x8010A164:("Map_IsInDungeonArea",), + 0x8010A194:("Map_GetBossAreaIndex",), + 0x8010A208:("Map_IsInBossArea",), 0x8010A238:("func_8010A238",), 0x8010A2AC:("func_8010A2AC",), - 0x8010A2DC:("func_8010A2DC",), - 0x8010A33C:("func_8010A33C",), - 0x8010A410:("func_8010A410",), - 0x8010A430:("func_8010A430",), - 0x8010A54C:("func_8010A54C",), - 0x8010A580:("func_8010A580",), + 0x8010A2DC:("Minimap_SavePlayerRoomInitInfo",), + 0x8010A33C:("Map_InitRoomData",), + 0x8010A410:("Map_Destroy",), + 0x8010A430:("Map_Init",), + 0x8010A54C:("Minimap_Draw",), + 0x8010A580:("Map_Update",), 0x8010A760:("func_8010A760",), 0x8010A7CC:("func_8010A7CC",), 0x8010A814:("func_8010A814",), @@ -2109,31 +2109,31 @@ 0x801129E4:("func_801129E4",), 0x80112AF4:("func_80112AF4",), 0x80112AFC:("func_80112AFC",), - 0x80112B40:("func_80112B40",), - 0x80112BE4:("func_80112BE4",), + 0x80112B40:("Interface_LoadItemIconImpl",), + 0x80112BE4:("Interface_LoadItemIcon",), 0x80112C0C:("func_80112C0C",), 0x80112E80:("Item_Give",), - 0x801143CC:("func_801143CC",), - 0x80114978:("func_80114978",), - 0x801149A0:("func_801149A0",), - 0x80114A9C:("func_80114A9C",), - 0x80114B84:("func_80114B84",), - 0x80114CA0:("func_80114CA0",), - 0x80114E90:("Interface_HasEmptyBottle",), - 0x80114F2C:("Interface_HasItemInBottle",), - 0x80114FD0:("func_80114FD0",), - 0x80115130:("func_80115130",), - 0x801152B8:("func_801152B8",), + 0x801143CC:("Item_CheckObtainabilityImpl",), + 0x80114978:("Item_CheckObtainability",), + 0x801149A0:("Inventory_DeleteItem",), + 0x80114A9C:("Inventory_UnequipItem",), + 0x80114B84:("Inventory_ReplaceItem",), + 0x80114CA0:("Inventory_UpdateDeitySwordEquip",), + 0x80114E90:("Inventory_HasEmptyBottle",), + 0x80114F2C:("Inventory_HasItemInBottle",), + 0x80114FD0:("Inventory_UpdateBottleItem",), + 0x80115130:("Inventory_ConsumeFairy",), + 0x801152B8:("Inventory_UpdateItem",), 0x801153C8:("func_801153C8",), 0x80115428:("func_80115428",), 0x8011552C:("func_8011552C",), 0x801155B4:("func_801155B4",), 0x80115764:("func_80115764",), 0x80115844:("func_80115844",), - 0x80115908:("func_80115908",), - 0x801159C0:("func_801159c0",), - 0x801159EC:("func_801159EC",), - 0x80115A14:("func_80115A14",), + 0x80115908:("Health_ChangeBy",), + 0x801159C0:("Health_GiveHearts",), + 0x801159EC:("Rupees_ChangeBy",), + 0x80115A14:("Inventory_ChangeAmmo",), 0x80115D14:("Parameter_AddMagic",), 0x80115D5C:("func_80115D5C",), 0x80115DB4:("func_80115DB4",), @@ -2182,29 +2182,29 @@ 0x80122BA4:("func_80122BA4",), 0x80122C20:("func_80122C20",), 0x80122D44:("func_80122D44",), - 0x80122ED8:("func_80122ED8",), - 0x80122EEC:("func_80122EEC",), + 0x80122ED8:("Player_MaskIdToItemId",), + 0x80122EEC:("Player_GetCurMaskItemId",), 0x80122F28:("func_80122F28",), 0x80122F9C:("func_80122F9C",), 0x80122FCC:("func_80122FCC",), 0x8012300C:("func_8012300C",), 0x8012301C:("func_8012301C",), 0x80123140:("func_80123140",), - 0x80123358:("func_80123358",), + 0x80123358:("Player_InBlockingCsMode",), 0x801233E4:("Player_InCsMode",), 0x80123420:("func_80123420",), 0x80123434:("func_80123434",), 0x80123448:("func_80123448",), - 0x801234B0:("func_801234B0",), + 0x801234B0:("Player_IsGoronOrDeku",), 0x801234D4:("func_801234D4",), 0x80123590:("func_80123590",), 0x801235DC:("func_801235DC",), 0x8012364C:("func_8012364C",), 0x80123810:("func_80123810",), - 0x80123960:("func_80123960",), + 0x80123960:("Player_ActionToModelGroup",), 0x801239AC:("func_801239AC",), - 0x80123AA4:("func_80123AA4",), - 0x80123BD4:("func_80123BD4",), + 0x80123AA4:("Player_SetModels",), + 0x80123BD4:("Player_SetModelGroup",), 0x80123C58:("func_80123C58",), 0x80123C90:("Player_SetEquipmentData",), 0x80123D50:("func_80123D50",), @@ -2213,22 +2213,22 @@ 0x80123E90:("func_80123E90",), 0x80123F14:("func_80123F14",), 0x80123F2C:("func_80123F2C",), - 0x80123F48:("func_80123F48",), - 0x80124020:("func_80124020",), + 0x80123F48:("Player_IsBurningStickInRange",), + 0x80124020:("Player_GetStrength",), 0x8012403C:("Player_GetMask",), 0x8012404C:("Player_RemoveMask",), - 0x8012405C:("func_8012405C",), - 0x80124088:("func_80124088",), - 0x801240C8:("func_801240C8",), + 0x8012405C:("Player_HasMirrorShieldEquipped",), + 0x80124088:("Player_IsHoldingMirrorShield",), + 0x801240C8:("Player_IsHoldingHookshot",), 0x801240DC:("func_801240DC",), 0x80124110:("func_80124110",), 0x80124148:("func_80124148",), - 0x80124168:("func_80124168",), - 0x80124190:("func_80124190",), - 0x801241B4:("func_801241B4",), - 0x801241E0:("func_801241E0",), - 0x8012420C:("func_8012420C",), - 0x8012422C:("func_8012422C",), + 0x80124168:("Player_ActionToMeleeWeapon",), + 0x80124190:("Player_GetMeleeWeaponHeld",), + 0x801241B4:("Player_IsHoldingTwoHandedWeapon",), + 0x801241E0:("Player_ActionToBottle",), + 0x8012420C:("Player_GetBottleHeld",), + 0x8012422C:("Player_ActionToExplosive",), 0x80124258:("Player_GetExplosiveHeld",), 0x80124278:("func_80124278",), 0x801242B4:("func_801242B4",), @@ -2244,7 +2244,7 @@ 0x80125318:("func_80125318",), 0x80125340:("func_80125340",), 0x8012536C:("func_8012536C",), - 0x801253A4:("func_801253A4",), + 0x801253A4:("Player_DrawZoraShield",), 0x80125500:("func_80125500",), 0x80125580:("func_80125580",), 0x80125CE0:("func_80125CE0",), @@ -2254,15 +2254,15 @@ 0x80126440:("func_80126440",), 0x801265C8:("func_801265C8",), 0x8012669C:("func_8012669C",), - 0x80126808:("func_80126808",), - 0x8012697C:("func_8012697C",), + 0x80126808:("Player_DrawGetItemImpl",), + 0x8012697C:("Player_DrawGetItem",), 0x80126AB4:("func_80126AB4",), 0x80126B8C:("func_80126B8C",), 0x80126BD0:("func_80126BD0",), 0x801271B0:("func_801271B0",), 0x80127438:("func_80127438",), 0x80127488:("func_80127488",), - 0x8012754C:("func_8012754C",), + 0x8012754C:("Player_DrawCouplesMask",), 0x80127594:("func_80127594",), 0x801278F8:("func_801278F8",), 0x80127A60:("func_80127A60",), @@ -2456,8 +2456,8 @@ 0x80130674:("Scene_HeaderCmdAnimatedMaterials",), 0x801306A4:("Scene_SetExitFade",), 0x801306E8:("Scene_ProcessHeader",), - 0x80130768:("Entrance_CreateIndex",), - 0x80130784:("Entrance_CreateIndexFromSpawn",), + 0x80130768:("Entrance_Create",), + 0x80130784:("Entrance_CreateFromSpawn",), 0x801307C0:("Scene_ExecuteDrawConfig",), 0x801307F4:("Scene_DrawConfigDefault",), 0x80130834:("AnimatedMat_TexScroll",), @@ -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",), @@ -2649,38 +2649,38 @@ 0x80139FA0:("SkinMatrix_SetYRotation",), 0x8013A068:("SkinMatrix_MulYRotation",), 0x8013A174:("SkinMatrix_SetZRotation",), - 0x8013A240:("func_8013A240",), - 0x8013A41C:("func_8013A41C",), - 0x8013A46C:("func_8013A46C",), - 0x8013A4C4:("func_8013A4C4",), - 0x8013A504:("func_8013A504",), - 0x8013A530:("func_8013A530",), + 0x8013A240:("Snap_RecordPictographedActors",), + 0x8013A41C:("Snap_SetFlag",), + 0x8013A46C:("Snap_UnsetFlag",), + 0x8013A4C4:("Snap_CheckFlag",), + 0x8013A504:("Snap_AbsS",), + 0x8013A530:("Snap_ValidatePictograph",), 0x8013A7C0:("SubS_FindDoor",), 0x8013A860:("SubS_DrawTransformFlexLimb",), 0x8013AB00:("SubS_DrawTransformFlex",), - 0x8013AD6C:("func_8013AD6C",), - 0x8013AD9C:("func_8013AD9C",), + 0x8013AD6C:("SubS_InCsMode",), + 0x8013AD9C:("SubS_UpdateLimb",), 0x8013AED4:("SubS_UpdateFlags",), - 0x8013AF00:("func_8013AF00",), - 0x8013B010:("func_8013B010",), - 0x8013B0C8:("func_8013B0C8",), - 0x8013B350:("func_8013B350",), - 0x8013B6B0:("func_8013B6B0",), - 0x8013B878:("func_8013B878",), + 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:("SubS_ChangeAnimationByInfoS",), 0x8013BD40:("SubS_HasReachedPoint",), 0x8013BEDC:("SubS_GetDayDependentPath",), - 0x8013C068:("func_8013C068",), - 0x8013C624:("func_8013C624",), + 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",), + 0x8013CC2C:("SubS_FillShadowTex",), + 0x8013CD64:("SubS_GenShadowTex",), + 0x8013CF04:("SubS_DrawShadowTex",), + 0x8013D0E0:("SubS_ComputeTrackPointRot",), + 0x8013D2E0:("SubS_TrackPoint",), 0x8013D5E8:("SubS_AngleDiffLessEqual",), 0x8013D648:("SubS_GetPathByIndex",), 0x8013D68C:("SubS_CopyPointFromPath",), @@ -2693,7 +2693,7 @@ 0x8013D9C8:("SubS_FillLimbRotTables",), 0x8013DB90:("SubS_IsFloorAbove",), 0x8013DC40:("SubS_CopyPointFromPathList",), - 0x8013DCCC:("SubS_GetPathCount",), + 0x8013DCCC:("SubS_GetPathCountFromPathList",), 0x8013DCE0:("SubS_ActorPathing_Init",), 0x8013DE04:("SubS_ActorPathing_Update",), 0x8013DF3C:("SubS_ActorPathing_ComputePointInfo",), @@ -2703,22 +2703,22 @@ 0x8013E1C8:("SubS_ChangeAnimationBySpeedInfo",), 0x8013E2D4:("SubS_StartActorCutscene",), 0x8013E3B8:("SubS_FillCutscenesList",), - 0x8013E4B0:("func_8013E4B0",), - 0x8013E5CC:("func_8013E5CC",), + 0x8013E4B0:("SubS_ConstructPlane",), + 0x8013E5CC:("SubS_LineSegVsPlane",), 0x8013E640:("SubS_FindActorCustom",), 0x8013E748:("func_8013E748",), - 0x8013E7C0:("func_8013E7C0",), + 0x8013E7C0:("SubS_ActorAndPlayerFaceEachOther",), 0x8013E8F8:("func_8013E8F8",), - 0x8013E950:("func_8013E950",), - 0x8013EC10:("func_8013EC10",), - 0x8013EC44:("func_8013EC44",), - 0x8013ECE0:("func_8013ECE0",), - 0x8013ED9C:("func_8013ED9C",), - 0x8013EDD0:("func_8013EDD0",), - 0x8013EE04:("func_8013EE04",), - 0x8013EE24:("func_8013EE24",), - 0x8013EE38:("func_8013EE38",), - 0x8013EE48:("func_8013EE48",), + 0x8013E950:("SubS_TrackPointStep",), + 0x8013EC10:("Rumble_Update",), + 0x8013EC44:("Rumble_Override",), + 0x8013ECE0:("Rumble_Request",), + 0x8013ED9C:("Rumble_Init",), + 0x8013EDD0:("Rumble_Destroy",), + 0x8013EE04:("Rumble_ControllerOneHasRumblePak",), + 0x8013EE24:("Rumble_StateReset",), + 0x8013EE38:("Rumble_StateWipeRequests",), + 0x8013EE48:("Rumble_SetUpdateEnabled",), 0x8013EE60:("View_ViewportToVp",), 0x8013EEF4:("View_Init",), 0x8013EF9C:("View_SetViewOrientation",), @@ -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",), @@ -2986,18 +2986,18 @@ 0x80165EC0:("func_80165EC0",), 0x80166060:("func_80166060",), 0x801660B8:("func_801660B8",), - 0x8016613C:("Play_Fini",), + 0x8016613C:("Play_Destroy",), 0x801663C4:("func_801663C4",), 0x80166644:("func_80166644",), 0x801668B4:("func_801668B4",), 0x80166968:("func_80166968",), 0x80166B30:("func_80166B30",), - 0x80167814:("func_80167814",), + 0x80167814:("Play_Update",), 0x80167DE4:("func_80167DE4",), 0x80167F0C:("func_80167F0C",), 0x80168090:("Play_Draw",), 0x80168DAC:("func_80168DAC",), - 0x80168F64:("Play_Update",), + 0x80168F64:("Play_Main",), 0x801690CC:("Play_InCsMode",), 0x80169100:("func_80169100",), 0x801691F0:("func_801691F0",), @@ -3005,25 +3005,25 @@ 0x8016927C:("func_8016927C",), 0x801692C4:("func_801692C4",), 0x801693D4:("Play_SceneInit",), - 0x80169474:("func_80169474",), + 0x80169474:("Play_GetScreenPos",), 0x801694DC:("Play_CreateSubCamera",), 0x80169584:("Play_GetActiveCamId",), - 0x80169590:("Play_CameraChangeStatus",), + 0x80169590:("Play_ChangeCameraStatus",), 0x80169600:("Play_ClearCamera",), 0x80169668:("Play_ClearAllSubCameras",), 0x801696D4:("Play_GetCamera",), - 0x8016970C:("Play_CameraSetAtEye",), - 0x8016981C:("Play_CameraSetAtEyeUp",), - 0x80169940:("Play_CameraSetFov",), - 0x80169988:("Play_CameraSetRoll",), + 0x8016970C:("Play_SetCameraAtEye",), + 0x8016981C:("Play_SetCameraAtEyeUp",), + 0x80169940:("Play_SetCameraFov",), + 0x80169988:("Play_SetCameraRoll",), 0x801699D4:("Play_CopyCamera",), 0x80169A50:("func_80169A50",), - 0x80169AC0:("Play_CameraChangeSetting",), + 0x80169AC0:("Play_ChangeCameraSetting",), 0x80169AFC:("func_80169AFC",), - 0x80169BC4:("Play_CameraGetUID",), + 0x80169BC4:("Play_GetCameraUID",), 0x80169BF8:("func_80169BF8",), - 0x80169C64:("Play_GetCsCamDataSetting",), - 0x80169C84:("Play_GetCsCamDataVec3s",), + 0x80169C64:("Play_GetActorCsCamSetting",), + 0x80169C84:("Play_GetActorCsCamFuncData",), 0x80169CBC:("Play_GetOriginalSceneNumber",), 0x80169D40:("Play_SaveCycleSceneFlags",), 0x80169DCC:("Play_SetRespawnData",), @@ -3036,7 +3036,7 @@ 0x8016A01C:("FrameAdvance_IsEnabled",), 0x8016A02C:("func_8016A02C",), 0x8016A0AC:("Play_IsUnderwater",), - 0x8016A168:("func_8016A168",), + 0x8016A168:("Play_IsDebugCamEnabled",), 0x8016A178:("Play_AssignPlayerActorCsIdsFromScene",), 0x8016A268:("func_8016A268",), 0x8016A2C8:("Play_Init",), @@ -3109,7 +3109,7 @@ 0x80172B3C:("THA_Init",), 0x80172B58:("THA_Ct",), 0x80172B9C:("THA_Dt",), - 0x80172BC0:("func_80172BC0",), + 0x80172BC0:("AudioMgr_StopAllSfxExceptSystem",), 0x80172C30:("func_80172C30",), 0x80172C68:("AudioMgr_HandleRetrace",), 0x80172EAC:("AudioMgr_HandlePRENMI",), @@ -3179,8 +3179,8 @@ 0x80175364:("func_80175364",), 0x80175434:("func_80175434",), 0x8017544C:("func_8017544C",), - 0x80175474:("func_80175474",), - 0x801754C0:("func_801754C0",), + 0x80175474:("PadMgr_RumbleSet",), + 0x801754C0:("PadMgr_ControllerHasRumblePak",), 0x801754E0:("Padmgr_CalcStickEdges",), 0x801757A4:("Padmgr_ParseState",), 0x801759BC:("func_801759BC",), @@ -3354,52 +3354,52 @@ 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",), 0x80182CCC:("SysUcode_GetUCodeData",), - 0x80182CE0:("func_80182CE0",), - 0x80183020:("func_80183020",), - 0x80183058:("func_80183058",), + 0x80182CE0:("RumbleManager_Update",), + 0x80183020:("RumbleManager_Init",), + 0x80183058:("RumbleManager_Destroy",), 0x80183070:("func_80183070",), 0x801830A0:("func_801830A0",), 0x801830C8:("func_801830C8",), @@ -3688,10 +3688,10 @@ 0x80193774:("func_80193774",), 0x8019380C:("func_8019380C",), 0x80193858:("func_80193858",), - 0x8019387C:("func_8019387C",), - 0x801938A0:("Audio_QueueCmdS8",), + 0x8019387C:("AudioThread_QueueCmdS32",), + 0x801938A0:("AudioThread_QueueCmdS8",), 0x801938D0:("func_801938D0",), - 0x80193900:("func_80193900",), + 0x80193900:("AudioThread_ScheduleProcessCmds",), 0x80193990:("func_80193990",), 0x801939A8:("func_801939A8",), 0x80193AEC:("func_80193AEC",), @@ -3718,11 +3718,11 @@ 0x80194528:("func_80194528",), 0x80194548:("func_80194548",), 0x80194568:("func_80194568",), - 0x80194668:("Audio_NextRandom",), - 0x801946E4:("Audio_InitMesgQueues",), + 0x80194668:("AudioThread_NextRandom",), + 0x801946E4:("AudioThread_InitMesgQueues",), 0x80194710:("Audio_InvalDCache",), 0x80194750:("Audio_WritebackDCache",), - 0x80194790:("func_80194790",), + 0x80194790:("osAiSetNextBuffer",), 0x80194804:("func_80194804",), 0x80194840:("func_80194840",), 0x801948B0:("func_801948B0",), @@ -3767,90 +3767,90 @@ 0x80197138:("AudioEffects_NotePortamentoInit",), 0x80197164:("AudioEffects_AdsrInit",), 0x80197188:("AudioEffects_AdsrUpdate",), - 0x801974D0:("func_801974D0",), - 0x80197538:("func_80197538",), - 0x80197714:("func_80197714",), - 0x80197880:("func_80197880",), - 0x801979D8:("func_801979D8",), - 0x80197A54:("func_80197A54",), + 0x801974D0:("AudioSeq_GetScriptControlFlowArgument",), + 0x80197538:("AudioSeq_HandleScriptFlowControl",), + 0x80197714:("AudioSeq_InitSequenceChannel",), + 0x80197880:("AudioSeq_SeqChannelSetLayer",), + 0x801979D8:("AudioSeq_SeqLayerDisable",), + 0x80197A54:("AudioSeq_SeqLayerFree",), 0x80197AA4:("AudioSeq_SequenceChannelDisable",), - 0x80197B14:("func_80197B14",), - 0x80197C0C:("func_80197C0C",), - 0x80197C8C:("func_80197C8C",), + 0x80197B14:("AudioSeq_SequencePlayerSetupChannels",), + 0x80197C0C:("AudioSeq_SequencePlayerDisableChannels",), + 0x80197C8C:("AudioSeq_SequenceChannelEnable",), 0x80197D24:("AudioSeq_SequencePlayerDisableAsFinished",), 0x80197D4C:("AudioSeq_SequencePlayerDisable",), 0x80197E08:("AudioSeq_AudioListPushBack",), 0x80197E48:("AudioSeq_AudioListPopBack",), - 0x80197E88:("func_80197E88",), - 0x80197F28:("func_80197F28",), - 0x80197F3C:("func_80197F3C",), - 0x80197F74:("func_80197F74",), - 0x80197FB4:("func_80197FB4",), - 0x801980D0:("func_801980D0",), - 0x8019815C:("func_8019815C",), - 0x8019825C:("func_8019825C",), - 0x80198640:("func_80198640",), - 0x80198CE0:("func_80198CE0",), - 0x801990F4:("func_801990F4",), - 0x80199124:("func_80199124",), - 0x80199198:("func_80199198",), - 0x80199244:("func_80199244",), - 0x80199268:("func_80199268",), - 0x8019A0BC:("func_8019A0BC",), - 0x8019AA3C:("func_8019AA3C",), - 0x8019AAF0:("func_8019AAF0",), + 0x80197E88:("AudioSeq_InitLayerFreelist",), + 0x80197F28:("AudioSeq_ScriptReadU8",), + 0x80197F3C:("AudioSeq_ScriptReadS16",), + 0x80197F74:("AudioSeq_ScriptReadCompressedU16",), + 0x80197FB4:("AudioSeq_SeqLayerProcessScript",), + 0x801980D0:("AudioSeq_SeqLayerProcessScriptStep1",), + 0x8019815C:("AudioSeq_SeqLayerProcessScriptStep5",), + 0x8019825C:("AudioSeq_SeqLayerProcessScriptStep2",), + 0x80198640:("AudioSeq_SeqLayerProcessScriptStep4",), + 0x80198CE0:("AudioSeq_SeqLayerProcessScriptStep3",), + 0x801990F4:("AudioSeq_SetChannelPriorities",), + 0x80199124:("AudioSeq_GetInstrument",), + 0x80199198:("AudioSeq_SetInstrument",), + 0x80199244:("AudioSeq_SequenceChannelSetVolume",), + 0x80199268:("AudioSeq_SequenceChannelProcessScript",), + 0x8019A0BC:("AudioSeq_SequencePlayerProcessSequence",), + 0x8019AA3C:("AudioSeq_ProcessSequences",), + 0x8019AAF0:("AudioSeq_SkipForwardSequence",), 0x8019AB40:("AudioSeq_ResetSequencePlayer",), 0x8019AC10:("AudioSeq_InitSequencePlayerChannels",), - 0x8019ACEC:("func_8019ACEC",), + 0x8019ACEC:("AudioSeq_InitSequencePlayer",), 0x8019ADBC:("AudioSeq_InitSequencePlayers",), 0x8019AE40:("func_8019AE40",), 0x8019AEC0:("func_8019AEC0",), - 0x8019AF00:("func_8019AF00",), - 0x8019AF58:("func_8019AF58",), - 0x8019AFE8:("func_8019AFE8",), - 0x8019B02C:("func_8019B02C",), - 0x8019B074:("AudioOcarina_MapSongFromNotesToButtons",), - 0x8019B144:("func_8019B144",), - 0x8019B378:("func_8019B378",), - 0x8019B38C:("func_8019B38C",), - 0x8019B3D0:("func_8019B3D0",), - 0x8019B4B8:("func_8019B4B8",), + 0x8019AF00:("AudioOcarina_ReadControllerInput",), + 0x8019AF58:("AudioOcarina_BendPitchTwoSemitones",), + 0x8019AFE8:("AudioOcarina_GetPlayingState",), + 0x8019B02C:("AudioOcarina_MapPitchToButton",), + 0x8019B074:("AudioOcarina_MapSongFromPitchToButton",), + 0x8019B144:("AudioOcarina_Start",), + 0x8019B378:("AudioOcarina_SetSongStartingPos",), + 0x8019B38C:("AudioOcarina_StartAtSongStartingPos",), + 0x8019B3D0:("AudioOcarina_StartForSongCheck",), + 0x8019B4B8:("AudioOcarina_StartWithSongNoteLengths",), 0x8019B544:("AudioOcarina_StartDefault",), 0x8019B568:("func_8019B568",), 0x8019B5AC:("func_8019B5AC",), 0x8019B5EC:("func_8019B5EC",), - 0x8019B618:("func_8019B618",), - 0x8019B654:("func_8019B654",), - 0x8019B6B4:("func_8019B6B4",), - 0x8019BC44:("func_8019BC44",), - 0x8019BE98:("func_8019BE98",), - 0x8019C1C0:("func_8019C1C0",), - 0x8019C1D0:("func_8019C1D0",), - 0x8019C268:("func_8019C268",), - 0x8019C2E4:("func_8019C2E4",), - 0x8019C300:("AudioOcarina_SetInstrumentId",), - 0x8019C398:("func_8019C398",), - 0x8019C5A0:("func_8019C5A0",), - 0x8019C8D8:("func_8019C8D8",), - 0x8019CD08:("func_8019CD08",), - 0x8019CE34:("func_8019CE34",), - 0x8019CE6C:("func_8019CE6C",), - 0x8019CEBC:("func_8019CEBC",), - 0x8019CF6C:("func_8019CF6C",), - 0x8019CF78:("func_8019CF78",), + 0x8019B618:("AudioOcarina_CheckIfStartedSong",), + 0x8019B654:("AudioOcarina_UpdateCurOcarinaSong",), + 0x8019B6B4:("AudioOcarina_CheckSongsWithMusicStaff",), + 0x8019BC44:("AudioOcarina_CheckSongsWithoutMusicStaff",), + 0x8019BE98:("AudioOcarina_PlayControllerInput",), + 0x8019C1C0:("AudioOcarina_EnableInput",), + 0x8019C1D0:("AudioOcarina_ResetAndMute",), + 0x8019C268:("AudioOcarina_ResetAndReadInput",), + 0x8019C2E4:("AudioOcarina_SetOcarinaDisableTimer",), + 0x8019C300:("AudioOcarina_SetInstrument",), + 0x8019C398:("AudioOcarina_SetPlaybackSong",), + 0x8019C5A0:("AudioOcarina_PlaybackSong",), + 0x8019C8D8:("AudioOcarina_SetRecordingSong",), + 0x8019CD08:("AudioOcarina_SetRecordingState",), + 0x8019CE34:("AudioOcarina_UpdateRecordingStaff",), + 0x8019CE6C:("AudioOcarina_UpdatePlayingStaff",), + 0x8019CEBC:("AudioOcarina_UpdatePlaybackStaff",), + 0x8019CF6C:("AudioOcarina_GetRecordingStaff",), + 0x8019CF78:("AudioOcarina_GetPlayingStaff",), 0x8019CF9C:("AudioOcarina_GetPlaybackStaff",), - 0x8019CFA8:("func_8019CFA8",), + 0x8019CFA8:("AudioOcarina_RecordSong",), 0x8019D134:("AudioOcarina_TerminaWallValidateNotes",), 0x8019D26C:("AudioOcarina_TerminaWallGenerateNotes",), - 0x8019D488:("AudioOcarina_MemoryGameSetNumNotes",), - 0x8019D4F8:("AudioOcarina_MemoryGameGenerateNotes",), - 0x8019D600:("func_8019D600",), - 0x8019D758:("func_8019D758",), - 0x8019D864:("func_8019D864",), - 0x8019D8B4:("func_8019D8B4",), - 0x8019D8E4:("func_8019D8E4",), - 0x8019DF28:("func_8019DF28",), - 0x8019DF64:("func_8019DF64",), + 0x8019D488:("AudioOcarina_MemoryGameInit",), + 0x8019D4F8:("AudioOcarina_MemoryGameNextNote",), + 0x8019D600:("AudioOcarina_Update",), + 0x8019D758:("AudioOcarina_PlayLongScarecrowAfterCredits",), + 0x8019D864:("AudioOcarina_SetCustomSequence",), + 0x8019D8B4:("AudioOcarina_PlayCustomSequence",), + 0x8019D8E4:("AudioOcarina_CreateCustomSequence",), + 0x8019DF28:("AudioOcarina_ResetInstrument",), + 0x8019DF64:("AudioOcarina_ResetStaffs",), 0x8019DFF8:("func_8019DFF8",), 0x8019E000:("func_8019E000",), 0x8019E00C:("func_8019E00C",), @@ -3858,27 +3858,27 @@ 0x8019E0FC:("func_8019E0FC",), 0x8019E104:("func_8019E104",), 0x8019E110:("func_8019E110",), - 0x8019E14C:("func_8019E14C",), - 0x8019E324:("func_8019E324",), - 0x8019E4B0:("func_8019E4B0",), - 0x8019E634:("func_8019E634",), - 0x8019E864:("func_8019E864",), - 0x8019EA40:("func_8019EA40",), - 0x8019EB2C:("func_8019EB2C",), - 0x8019F024:("func_8019F024",), - 0x8019F05C:("func_8019F05C",), + 0x8019E14C:("AudioSfx_ComputeVolume",), + 0x8019E324:("AudioSfx_ComputeReverb",), + 0x8019E4B0:("AudioSfx_ComputePanSigned",), + 0x8019E634:("AudioSfx_ComputeFreqScale",), + 0x8019E864:("AudioSfx_ComputeSurroundSoundFilter",), + 0x8019EA40:("AudioSfx_ComputeCombFilter",), + 0x8019EB2C:("AudioSfx_SetProperties",), + 0x8019F024:("AudioSfx_SetFreqAndStereoBits",), + 0x8019F05C:("AudioSfx_ResetSfxChannelState",), 0x8019F0C8:("play_sound",), 0x8019F128:("func_8019F128",), 0x8019F170:("func_8019F170",), 0x8019F1C0:("Audio_PlaySfxAtPos",), 0x8019F208:("func_8019F208",), 0x8019F230:("func_8019F230",), - 0x8019F258:("func_8019F258",), - 0x8019F300:("func_8019F300",), + 0x8019F258:("AudioSfx_AddSfxSetting",), + 0x8019F300:("AudioSfx_ProcessSfxSettings",), 0x8019F420:("func_8019F420",), 0x8019F4AC:("func_8019F4AC",), 0x8019F540:("func_8019F540",), - 0x8019F570:("func_8019F570",), + 0x8019F570:("AudioSfx_LowerSfxSettingsReverb",), 0x8019F5AC:("func_8019F5AC",), 0x8019F638:("func_8019F638",), 0x8019F780:("func_8019F780",), @@ -3912,7 +3912,7 @@ 0x801A0554:("func_801A0554",), 0x801A05E4:("func_801A05E4",), 0x801A05F0:("func_801A05F0",), - 0x801A0654:("func_801A0654",), + 0x801A0654:("AudioSfx_SetChannelIO",), 0x801A0810:("func_801A0810",), 0x801A0868:("func_801A0868",), 0x801A09D4:("func_801A09D4",), @@ -3990,7 +3990,7 @@ 0x801A42C8:("func_801A42C8",), 0x801A4324:("func_801A4324",), 0x801A4348:("func_801A4348",), - 0x801A4380:("func_801A4380",), + 0x801A4380:("Audio_SetSfxVolumeExceptSystemAndOcarinaBanks",), 0x801A4428:("func_801A4428",), 0x801A44A4:("Audio_PreNMI",), 0x801A44C4:("func_801A44C4",), @@ -4001,9 +4001,9 @@ 0x801A47DC:("func_801A47DC",), 0x801A48E0:("func_801A48E0",), 0x801A4A28:("func_801A4A28",), - 0x801A4B80:("func_801A4B80",), - 0x801A4C30:("func_801A4C30",), - 0x801A4C54:("func_801A4C54",), + 0x801A4B80:("Audio_SetNatureAmbienceRandomBend",), + 0x801A4C30:("Audio_Init",), + 0x801A4C54:("AudioSfx_Init",), 0x801A4D00:("func_801A4D00",), 0x801A4D50:("func_801A4D50",), 0x801A4DA4:("func_801A4DA4",), @@ -4030,29 +4030,29 @@ 0x801A5808:("func_801A5808",), 0x801A5A10:("func_801A5A10",), 0x801A5A1C:("func_801A5A1C",), - 0x801A5BD0:("func_801A5BD0",), - 0x801A5C28:("func_801A5C28",), - 0x801A5C8C:("func_801A5C8C",), - 0x801A5CFC:("Audio_PlaySfxGeneral",), - 0x801A5DDC:("func_801A5DDC",), - 0x801A5F7C:("func_801A5F7C",), - 0x801A6430:("func_801A6430",), - 0x801A65C8:("func_801A65C8",), - 0x801A6D0C:("func_801A6D0C",), - 0x801A7084:("func_801A7084",), - 0x801A7168:("func_801A7168",), - 0x801A7284:("func_801A7284",), - 0x801A72CC:("Audio_StopSfxByPos",), - 0x801A7328:("func_801A7328",), - 0x801A7484:("func_801A7484",), - 0x801A75E8:("func_801A75E8",), - 0x801A7720:("func_801A7720",), - 0x801A7794:("func_801A7794",), - 0x801A7828:("func_801A7828",), - 0x801A787C:("func_801A787C",), - 0x801A78E4:("Audio_IsSfxPlaying",), - 0x801A794C:("func_801A794C",), - 0x801A7B10:("func_801A7B10",), + 0x801A5BD0:("AudioSfx_MuteBanks",), + 0x801A5C28:("AudioSfx_LowerBgmVolume",), + 0x801A5C8C:("AudioSfx_RestoreBgmVolume",), + 0x801A5CFC:("AudioSfx_PlaySfx",), + 0x801A5DDC:("AudioSfx_RemoveMatchingRequests",), + 0x801A5F7C:("AudioSfx_ProcessRequest",), + 0x801A6430:("AudioSfx_RemoveBankEntry",), + 0x801A65C8:("AudioSfx_ChooseActiveSfx",), + 0x801A6D0C:("AudioSfx_PlayActiveSfx",), + 0x801A7084:("AudioSfx_StopByBank",), + 0x801A7168:("AudioSfx_StopByPosAndBankImpl",), + 0x801A7284:("AudioSfx_StopByPosAndBank",), + 0x801A72CC:("AudioSfx_StopByPos",), + 0x801A7328:("AudioSfx_StopByPosAndId",), + 0x801A7484:("AudioSfx_StopByTokenAndId",), + 0x801A75E8:("AudioSfx_StopById",), + 0x801A7720:("AudioSfx_ProcessRequests",), + 0x801A7794:("AudioSfx_SetBankLerp",), + 0x801A7828:("AudioSfx_StepBankLerp",), + 0x801A787C:("AudioSfx_ProcessActiveSfx",), + 0x801A78E4:("AudioSfx_IsPlaying",), + 0x801A794C:("AudioSfx_Reset",), + 0x801A7B10:("Audio_StartSequence",), 0x801A7D04:("func_801A7D04",), 0x801A7D84:("func_801A7D84",), 0x801A89A8:("Audio_QueueSeqCmd",), @@ -4089,19 +4089,19 @@ 0x8080066C:("Title_Main",), 0x8080071C:("Title_Destroy",), 0x8080074C:("Title_Init",), - 0x80800910:("Select_LoadTitle",), - 0x80800930:("Select_LoadGame",), - 0x80800A44:("Select_UpdateMenu",), - 0x808013B8:("Select_PrintMenu",), - 0x80801594:("Select_PrintLoadingMessage",), - 0x80801620:("Select_PrintAgeSetting",), - 0x808016E8:("Select_PrintCutsceneSetting",), - 0x8080194C:("Select_DrawMenu",), - 0x808019FC:("Select_DrawLoadingScreen",), - 0x80801A64:("Select_Draw",), - 0x80801AFC:("Select_Main",), - 0x80801B28:("Select_Destroy",), - 0x80801B4C:("Select_Init",), + 0x80800910:("MapSelect_LoadTitle",), + 0x80800930:("MapSelect_LoadGame",), + 0x80800A44:("MapSelect_UpdateMenu",), + 0x808013B8:("MapSelect_PrintMenu",), + 0x80801594:("MapSelect_PrintLoadingMessage",), + 0x80801620:("MapSelect_PrintAgeSetting",), + 0x808016E8:("MapSelect_PrintCutsceneSetting",), + 0x8080194C:("MapSelect_DrawMenu",), + 0x808019FC:("MapSelect_DrawLoadingScreen",), + 0x80801A64:("MapSelect_Draw",), + 0x80801AFC:("MapSelect_Main",), + 0x80801B28:("MapSelect_Destroy",), + 0x80801B4C:("MapSelect_Init",), 0x80803DF0:("Opening_SetupForTitleCutscene",), 0x80803EA0:("func_80803EA0",), 0x80803EC0:("Opening_Main",), @@ -4200,10 +4200,10 @@ 0x808160A0:("func_808160A0",), 0x80817B5C:("func_80817B5C",), 0x80818904:("func_80818904",), - 0x80818920:("func_80818920",), - 0x808190C4:("func_808190C4",), - 0x80819238:("func_80819238",), - 0x80819F04:("func_80819F04",), + 0x80818920:("KaleidoScope_DrawInventoryEditorText",), + 0x808190C4:("KaleidoScope_DrawDigit",), + 0x80819238:("KaleidoScope_DrawInventoryEditor",), + 0x80819F04:("KaleidoScope_UpdateInventoryEditor",), 0x8081B240:("func_8081B240",), 0x8081B6BC:("func_8081B6BC",), 0x8081B6EC:("func_8081B6EC",), @@ -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",), @@ -4962,31 +4962,31 @@ 0x8086732C:("EnDoor_Update",), 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",), @@ -5237,7 +5237,7 @@ 0x8087DF64:("EnHorse_MountedIdle",), 0x8087E080:("EnHorse_MountedIdleAnim",), 0x8087E0A4:("EnHorse_MountedIdleWhinney",), - 0x8087E18C:("EnHorse_MountedIdleWhinneying",), + 0x8087E18C:("EnHorse_MountedIdleWhinnying",), 0x8087E2A8:("EnHorse_StartTurning",), 0x8087E350:("EnHorse_MountedTurn",), 0x8087E564:("EnHorse_StartWalkingFromIdle",), @@ -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",), @@ -5803,9 +5803,9 @@ 0x808AACE0:("EnOssan_WaitForBlink",), 0x808AAD14:("EnOssan_Blink",), 0x808AADB4:("EnOssan_CuriosityShopMan_Init",), - 0x808AAE1C:("EnOssan_PartTimeWorker_Init",), + 0x808AAE1C:("EnOssan_PartTimer_Init",), 0x808AAE84:("EnOssan_CuriosityShopMan_GetWelcome",), - 0x808AAFB0:("EnOssan_PartTimerWorker_GetWelcome",), + 0x808AAFB0:("EnOssan_PartTimer_GetWelcome",), 0x808AB0B0:("EnOssan_SetHaveMet",), 0x808AB16C:("EnOssan_InitShop",), 0x808AB404:("EnOssan_GetCutscenes",), @@ -5814,51 +5814,51 @@ 0x808AB78C:("EnOssan_DrawTextRec",), 0x808AB928:("EnOssan_DrawStickDirectionPrompts",), 0x808ABCD0:("EnOssan_CuriosityShopMan_OverrideLimbDraw",), - 0x808ABD10:("EnOssan_PartTimeWorker_OverrideLimbDraw",), + 0x808ABD10:("EnOssan_PartTimer_OverrideLimbDraw",), 0x808ABD60:("EnOssan_CuriosityShopMan_PostLimbDraw",), - 0x808ABE18:("EnOssan_PartTimeWorker_PostLimbDraw",), + 0x808ABE18:("EnOssan_PartTimer_PostLimbDraw",), 0x808ABE58:("EnOssan_CuriosityShopMan_Draw",), - 0x808ABF30:("EnOssan_PartTimeWorker_Draw",), + 0x808ABF30:("EnOssan_PartTimer_Draw",), 0x808AC920:("EnFamos_Init",), 0x808ACB08:("EnFamos_Destroy",), - 0x808ACB58:("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",), @@ -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",), @@ -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",), @@ -6703,7 +6703,7 @@ 0x808F25A4:("EnKarebaba_Update",), 0x808F280C:("func_808F280C",), 0x808F28F8:("EnKarebaba_Draw",), - 0x808F30B0:("func_808F30B0",), + 0x808F30B0:("EnIn_ChangeAnim",), 0x808F3178:("func_808F3178",), 0x808F322C:("func_808F322C",), 0x808F32A0:("func_808F32A0",), @@ -7047,19 +7047,19 @@ 0x809275C0:("func_809275C0",), 0x8092762C:("func_8092762C",), 0x80927690:("func_80927690",), - 0x80927714:("func_80927714",), - 0x8092776C:("func_8092776C",), + 0x80927714:("ObjTsubo_SpawnEnMkk",), + 0x8092776C:("ObjTsubo_SpawnEnSw",), 0x80927818:("func_80927818",), 0x80927864:("func_80927864",), 0x8092788C:("func_8092788C",), 0x809278C0:("ObjTsubo_Init",), 0x80927A4C:("ObjTsubo_Destroy",), - 0x80927A78:("func_80927A78",), - 0x80927D2C:("func_80927D2C",), - 0x80927FCC:("func_80927FCC",), - 0x809282F0:("func_809282F0",), - 0x8092860C:("func_8092860C",), - 0x80928904:("func_80928904",), + 0x80927A78:("func_PotBreak1",), + 0x80927D2C:("func_RacePotBreak1",), + 0x80927FCC:("func_PotBreak2",), + 0x809282F0:("func_RacePotBreak2",), + 0x8092860C:("func_PotBreak3",), + 0x80928904:("func_RacePotBreak3",), 0x80928914:("func_80928914",), 0x80928928:("func_80928928",), 0x809289B4:("func_809289B4",), @@ -7071,47 +7071,47 @@ 0x809291DC:("func_809291DC",), 0x8092926C:("func_8092926C",), 0x8092932C:("ObjTsubo_Update",), - 0x809294B0:("func_809294B0",), + 0x809294B0:("ObjTsubo_Draw",), 0x80929910:("EnIk_Init",), 0x80929A98:("EnIk_Destroy",), - 0x80929AF8:("func_80929AF8",), - 0x80929B6C:("func_80929B6C",), - 0x80929BEC:("func_80929BEC",), - 0x80929C80:("func_80929C80",), - 0x80929D04:("func_80929D04",), - 0x80929E2C:("func_80929E2C",), - 0x80929E88:("func_80929E88",), - 0x80929F20:("func_80929F20",), - 0x80929FC8:("func_80929FC8",), - 0x8092A020:("func_8092A020",), - 0x8092A124:("func_8092A124",), - 0x8092A188:("func_8092A188",), - 0x8092A28C:("func_8092A28C",), - 0x8092A33C:("func_8092A33C",), - 0x8092A570:("func_8092A570",), - 0x8092A5BC:("func_8092A5BC",), - 0x8092A680:("func_8092A680",), - 0x8092A754:("func_8092A754",), - 0x8092A8D8:("func_8092A8D8",), - 0x8092A994:("func_8092A994",), - 0x8092AA6C:("func_8092AA6C",), - 0x8092AB14:("func_8092AB14",), - 0x8092AB50:("func_8092AB50",), - 0x8092ABD8:("func_8092ABD8",), - 0x8092AC4C:("func_8092AC4C",), - 0x8092ACFC:("func_8092ACFC",), - 0x8092ADB4:("func_8092ADB4",), - 0x8092AE14:("func_8092AE14",), - 0x8092AFB4:("func_8092AFB4",), - 0x8092AFD4:("func_8092AFD4",), - 0x8092B03C:("func_8092B03C",), - 0x8092B098:("func_8092B098",), - 0x8092B1B4:("func_8092B1B4",), - 0x8092B46C:("func_8092B46C",), + 0x80929AF8:("EnIk_Freeze",), + 0x80929B6C:("EnIk_Thaw",), + 0x80929BEC:("EnIk_HitArmor",), + 0x80929C80:("EnIk_IsChangingAction",), + 0x80929D04:("EnIk_ChooseAttack",), + 0x80929E2C:("EnIk_CheckActions",), + 0x80929E88:("EnIk_SetupIdle",), + 0x80929F20:("EnIk_Idle",), + 0x80929FC8:("EnIk_SetupWalk",), + 0x8092A020:("EnIk_WalkTowardsPlayer",), + 0x8092A124:("EnIk_SetupRun",), + 0x8092A188:("EnIk_RunTowardsPlayer",), + 0x8092A28C:("EnIk_SetupVerticalAttack",), + 0x8092A33C:("EnIk_VerticalAttack",), + 0x8092A570:("EnIk_SetupTakeOutAxe",), + 0x8092A5BC:("EnIk_TakeOutAxe",), + 0x8092A680:("EnIk_SetupHorizontalDoubleAttack",), + 0x8092A754:("EnIk_HorizontalDoubleAttack",), + 0x8092A8D8:("EnIk_SetupSingleHorizontalAttack",), + 0x8092A994:("EnIk_SingleHorizontalAttack",), + 0x8092AA6C:("EnIk_SetupEndHorizontalAttack",), + 0x8092AB14:("EnIk_EndHorizontalAttack",), + 0x8092AB50:("EnIk_SetupBlock",), + 0x8092ABD8:("EnIk_Block",), + 0x8092AC4C:("EnIk_SetupReactToAttack",), + 0x8092ACFC:("EnIk_ReactToAttack",), + 0x8092ADB4:("EnIk_SetupDie",), + 0x8092AE14:("EnIk_Die",), + 0x8092AFB4:("EnIk_SetupFrozen",), + 0x8092AFD4:("EnIk_Frozen",), + 0x8092B03C:("EnIk_SetupCutscene",), + 0x8092B098:("EnIk_PlayCutscene",), + 0x8092B1B4:("EnIk_UpdateDamage",), + 0x8092B46C:("EnIk_UpdateArmor",), 0x8092B5FC:("EnIk_Update",), - 0x8092B900:("func_8092B900",), - 0x8092B93C:("func_8092B93C",), - 0x8092BC6C:("func_8092BC6C",), + 0x8092B900:("EnIk_OverrideLimbDraw",), + 0x8092B93C:("EnIk_PostLimbDraw",), + 0x8092BC6C:("EnIk_UpdateArmorDraw",), 0x8092BE14:("EnIk_Draw",), 0x8092C530:("DemoShd_Init",), 0x8092C540:("DemoShd_Destroy",), @@ -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",), @@ -7539,22 +7539,22 @@ 0x809455A0:("ItemInbox_Draw",), 0x80945650:("EnGe1_Init",), 0x809457C0:("EnGe1_Destroy",), - 0x809457EC:("func_809457EC",), - 0x80945924:("func_80945924",), - 0x80945A00:("func_80945A00",), - 0x80945A9C:("func_80945A9C",), - 0x80945B60:("func_80945B60",), - 0x80945C50:("func_80945C50",), - 0x80945CAC:("func_80945CAC",), - 0x80945CE4:("func_80945CE4",), + 0x809457EC:("EnGe1_ChangeAnim",), + 0x80945924:("EnGe1_LookAtPlayer",), + 0x80945A00:("EnGe1_ShadowDraw",), + 0x80945A9C:("EnGe1_SetupPath",), + 0x80945B60:("EnGe1_FollowPath",), + 0x80945C50:("EnGe1_Scream",), + 0x80945CAC:("EnGe1_Wait",), + 0x80945CE4:("EnGe1_PerformCutsceneActions",), 0x8094607C:("EnGe1_Update",), - 0x80946190:("func_80946190",), - 0x80946238:("func_80946238",), - 0x80946368:("func_80946368",), + 0x80946190:("EnGe1_ValidatePictograph",), + 0x80946238:("EnGe1_OverrideLimbDraw",), + 0x80946368:("EnGe1_PostLimbDraw",), 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,13 +7641,13 @@ 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",), @@ -7680,11 +7680,11 @@ 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:("EnAttackNiw_OverrideLimbDraw",), 0x8095909C:("EnAttackNiw_Draw",), @@ -8016,8 +8016,8 @@ 0x8096F4DC:("BgF40Swlift_Draw",), 0x8096F5E0:("EnKakasi_Destroy",), 0x8096F60C:("EnKakasi_Init",), - 0x8096F800:("EnKakasi_SetAnimation",), - 0x8096F88C:("EnKakasi_8096F88C",), + 0x8096F800:("EnKakasi_ChangeAnim",), + 0x8096F88C:("EnKakasi_ValidatePictograph",), 0x8096F8D8:("func_8096F8D8",), 0x8096FA18:("func_8096FA18",), 0x8096FAAC:("func_8096FAAC",), @@ -8065,10 +8065,10 @@ 0x80973550:("EnTorch_Init",), 0x80973640:("ShotSun_Init",), 0x809736FC:("ShotSun_Destroy",), - 0x80973740:("func_80973740",), - 0x80973804:("func_80973804",), - 0x809738D0:("func_809738D0",), - 0x80973960:("func_80973960",), + 0x80973740:("ShotSun_SpawnFairy",), + 0x80973804:("ShotSun_TriggerFairy",), + 0x809738D0:("ShotSun_UpdateForOcarina",), + 0x80973960:("ShotSun_UpdateHyliaSun",), 0x80973B5C:("ShotSun_Update",), 0x80973C50:("ObjRoomtimer_Init",), 0x80973CA4:("ObjRoomtimer_Destroy",), @@ -8083,7 +8083,7 @@ 0x80974118:("EnSsh_AddBlureVertex",), 0x80974220:("EnSsh_AddBlureSpace",), 0x8097424C:("EnSsh_InitColliders",), - 0x80974374:("EnSsh_SetAnimation",), + 0x80974374:("EnSsh_ChangeAnim",), 0x809744A8:("EnSsh_SetWaitAnimation",), 0x809744C8:("EnSsh_SetReturnAnimation",), 0x809744FC:("EnSsh_SetLandAnimation",), @@ -8145,8 +8145,8 @@ 0x80978B68:("EffectSsBlast_Update",), 0x80978C30:("EffectSsGSpk_Init",), 0x80978D70:("EffectSsGSpk_Draw",), - 0x80978F40:("func_80978F40",), - 0x80979068:("func_80979068",), + 0x80978F40:("EffectSsGSpk_Update",), + 0x80979068:("EffectSsGSpk_UpdateNoAccel",), 0x809791B0:("func_809791B0",), 0x80979228:("EffectSsDFire_Init",), 0x8097930C:("EffectSsDFire_Draw",), @@ -8155,7 +8155,7 @@ 0x80979738:("EffectSsBubble_Draw",), 0x8097985C:("EffectSsBubble_Update",), 0x80979B30:("EffectSsGRipple_Init",), - 0x80979C38:("func_80979C38",), + 0x80979C38:("EffectSsGRipple_DrawRipple",), 0x80979E48:("EffectSsGRipple_Draw",), 0x80979E80:("EffectSsGRipple_Update",), 0x8097A050:("EffectSsGSplash_Init",), @@ -8165,16 +8165,16 @@ 0x8097A548:("EffectSsGFire_Draw",), 0x8097A5F0:("EffectSsGFire_Update",), 0x8097A680:("EffectSsLightning_Init",), - 0x8097A794:("func_8097A794",), + 0x8097A794:("EffectSsLightning_NewLightning",), 0x8097A838:("EffectSsLightning_Draw",), 0x8097AA98:("EffectSsLightning_Update",), 0x8097AD60:("EffectSsDtBubble_Init",), 0x8097AF50:("EffectSsDtBubble_Draw",), 0x8097B160:("EffectSsDtBubble_Update",), - 0x8097B270:("func_8097B270",), + 0x8097B270:("EffectSsHahen_CheckForObject",), 0x8097B2E4:("EffectSsHahen_Init",), - 0x8097B424:("func_8097B424",), - 0x8097B504:("func_8097B504",), + 0x8097B424:("EffectSsHahen_DrawOpa",), + 0x8097B504:("EffectSsHahen_DrawXlu",), 0x8097B5E4:("EffectSsHahen_Draw",), 0x8097B708:("EffectSsHahen_Update",), 0x8097B810:("EffectSsStick_Init",), @@ -8221,8 +8221,8 @@ 0x8097F020:("EffectSsIcePiece_Update",), 0x8097F0D0:("EffectSsEnIce_Init",), 0x8097F2F0:("EffectSsEnIce_Draw",), - 0x8097F62C:("func_8097F62C",), - 0x8097F7EC:("func_8097F7EC",), + 0x8097F62C:("EffectSsEnIce_UpdateFlying",), + 0x8097F7EC:("EffectSsEnIce_Update",), 0x8097F880:("EffectSsFireTail_Init",), 0x8097F99C:("EffectSsFireTail_Draw",), 0x8097FE8C:("EffectSsFireTail_Update",), @@ -8305,49 +8305,49 @@ 0x80987A3C:("OceffWipe3_Destroy",), 0x80987A70:("OceffWipe3_Update",), 0x80987AD0:("OceffWipe3_Draw",), - 0x80989140:("func_80989140",), - 0x80989204:("func_80989204",), - 0x8098933C:("func_8098933C",), - 0x80989418:("func_80989418",), - 0x809895B4:("func_809895B4",), - 0x80989674:("func_80989674",), - 0x80989864:("func_80989864",), - 0x80989974:("func_80989974",), - 0x809899C8:("func_809899C8",), - 0x80989A08:("func_80989A08",), - 0x80989A48:("func_80989A48",), - 0x80989A9C:("func_80989A9C",), - 0x80989ADC:("func_80989ADC",), - 0x80989BF8:("func_80989BF8",), - 0x80989D38:("func_80989D38",), - 0x80989E18:("func_80989E18",), - 0x80989FC8:("func_80989FC8",), - 0x8098A064:("func_8098A064",), - 0x8098A1B4:("func_8098A1B4",), - 0x8098A234:("func_8098A234",), - 0x8098A468:("func_8098A468",), - 0x8098A55C:("func_8098A55C",), - 0x8098A618:("func_8098A618",), - 0x8098A70C:("func_8098A70C",), - 0x8098A89C:("func_8098A89C",), - 0x8098A938:("func_8098A938",), - 0x8098AAAC:("func_8098AAAC",), - 0x8098AB48:("func_8098AB48",), - 0x8098AC34:("func_8098AC34",), - 0x8098AE58:("func_8098AE58",), - 0x8098AF44:("func_8098AF44",), - 0x8098AF98:("func_8098AF98",), - 0x8098B004:("func_8098B004",), - 0x8098B198:("func_8098B198",), - 0x8098B28C:("func_8098B28C",), - 0x8098B390:("func_8098B390",), - 0x8098B464:("func_8098B464",), - 0x8098B560:("func_8098B560",), - 0x8098B88C:("func_8098B88C",), - 0x8098BA64:("func_8098BA64",), - 0x8098BB10:("func_8098BB10",), - 0x8098BBEC:("func_8098BBEC",), - 0x8098BC54:("func_8098BC54",), + 0x80989140:("EnDg_ChangeAnim",), + 0x80989204:("EnDg_UpdateCollision",), + 0x8098933C:("EnDg_GetFloorRot",), + 0x80989418:("EnDg_HasReachedPoint",), + 0x809895B4:("EnDg_GetYRotation",), + 0x80989674:("EnDg_MoveAlongPath",), + 0x80989864:("EnDg_SpawnFloorDustRing",), + 0x80989974:("EnDg_PlaySfxWalk",), + 0x809899C8:("EnDg_PlaySfxBark",), + 0x80989A08:("EnDg_PlaySfxAngryBark",), + 0x80989A48:("EnDg_PlaySfxWhine",), + 0x80989A9C:("EnDg_PlaySfxGrowl",), + 0x80989ADC:("EnDg_SetupIdleMove",), + 0x80989BF8:("EnDg_UpdateTextId",), + 0x80989D38:("EnDg_StartTextBox",), + 0x80989E18:("EnDg_TryPickUp",), + 0x80989FC8:("EnDg_FindFollowerForBremenMask",), + 0x8098A064:("EnDg_CheckForBremenMaskMarch",), + 0x8098A1B4:("EnDg_ShouldReactToNonHumanPlayer",), + 0x8098A234:("EnDg_ChooseActionForForm",), + 0x8098A468:("EnDg_IdleMove",), + 0x8098A55C:("EnDg_IdleBark",), + 0x8098A618:("EnDg_BackAwayFromGoron",), + 0x8098A70C:("EnDg_RunAwayFromGoron",), + 0x8098A89C:("EnDg_BarkAtGoron",), + 0x8098A938:("EnDg_ApproachPlayerToAttack",), + 0x8098AAAC:("EnDg_RunAfterAttacking",), + 0x8098AB48:("EnDg_SitNextToPlayer",), + 0x8098AC34:("EnDg_JumpAttack",), + 0x8098AE58:("EnDg_WalkToPlayer",), + 0x8098AF44:("EnDg_SetupBremenMaskApproachPlayer",), + 0x8098AF98:("EnDg_Fall",), + 0x8098B004:("EnDg_ApproachPlayer",), + 0x8098B198:("EnDg_SlowlyBackUpBeforeAttacking",), + 0x8098B28C:("EnDg_BackAwayFromPlayer",), + 0x8098B390:("EnDg_BarkAtPlayer",), + 0x8098B464:("EnDg_SetupSwim",), + 0x8098B560:("EnDg_Swim",), + 0x8098B88C:("EnDg_JumpOutOfWater",), + 0x8098BA64:("EnDg_Held",), + 0x8098BB10:("EnDg_Thrown",), + 0x8098BBEC:("EnDg_SetupTalk",), + 0x8098BC54:("EnDg_Talk",), 0x8098BCA8:("EnDg_Init",), 0x8098BE18:("EnDg_Destroy",), 0x8098BE44:("EnDg_Update",), @@ -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",), @@ -8615,7 +8615,7 @@ 0x8099D7DC:("OceffWipe4_Destroy",), 0x8099D810:("OceffWipe4_Update",), 0x8099D870:("OceffWipe4_Draw",), - 0x8099E790:("EnZo_SetAnimation",), + 0x8099E790:("EnZo_ChangeAnim",), 0x8099E858:("EnZo_PlayWalkingSound",), 0x8099E96C:("EnZo_Blink",), 0x8099E9E0:("EnZo_UpdateCollider",), @@ -8830,7 +8830,7 @@ 0x809AC7F8:("func_809AC7F8",), 0x809AC970:("func_809AC970",), 0x809AC9B8:("BgFireWall_Update",), - 0x809ACB28:("func_809ACB28",), + 0x809ACB28:("BgFireWall_Draw",), 0x809ACD90:("EnBu_Init",), 0x809ACDA8:("EnBu_Destroy",), 0x809ACDB8:("EnBu_DoNothing",), @@ -9080,34 +9080,34 @@ 0x809C5E14:("EnBomBowlMan_Update",), 0x809C5F44:("EnBomBowlMan_OverrideLimbDraw",), 0x809C5FC4:("EnBomBowlMan_Draw",), - 0x809C64C0:("func_809C64C0",), + 0x809C64C0:("EnSyatekiMan_Swamp_SpawnTargetActors",), 0x809C6578:("EnSyatekiMan_Init",), 0x809C66FC:("EnSyatekiMan_Destroy",), - 0x809C6720:("func_809C6720",), - 0x809C6810:("func_809C6810",), - 0x809C6848:("func_809C6848",), - 0x809C6A04:("func_809C6A04",), - 0x809C6C2C:("func_809C6C2C",), - 0x809C6E30:("func_809C6E30",), - 0x809C6F98:("func_809C6F98",), - 0x809C72D8:("func_809C72D8",), - 0x809C7380:("func_809C7380",), - 0x809C7620:("func_809C7620",), - 0x809C7990:("func_809C7990",), - 0x809C7A90:("func_809C7A90",), - 0x809C7C14:("func_809C7C14",), - 0x809C7D14:("func_809C7D14",), - 0x809C7EB4:("func_809C7EB4",), - 0x809C7FFC:("func_809C7FFC",), - 0x809C80C0:("func_809C80C0",), - 0x809C81D0:("func_809C81D0",), - 0x809C8488:("func_809C8488",), - 0x809C8610:("func_809C8610",), - 0x809C8710:("func_809C8710",), - 0x809C8808:("func_809C8808",), - 0x809C898C:("func_809C898C",), - 0x809C8BF0:("func_809C8BF0",), - 0x809C8DE8:("func_809C8DE8",), + 0x809C6720:("EnSyatekiMan_MovePlayerToPos",), + 0x809C6810:("EnSyatekiMan_SetupIdle",), + 0x809C6848:("EnSyatekiMan_Swamp_Idle",), + 0x809C6A04:("EnSyatekiMan_Swamp_HandleChoice",), + 0x809C6C2C:("EnSyatekiMan_Swamp_HandleNormalMessage",), + 0x809C6E30:("EnSyatekiMan_Swamp_Talk",), + 0x809C6F98:("EnSyatekiMan_Town_StartIntroTextbox",), + 0x809C72D8:("EnSyatekiMan_Town_Idle",), + 0x809C7380:("EnSyatekiMan_Town_HandleChoice",), + 0x809C7620:("EnSyatekiMan_Town_HandleNormalMessage",), + 0x809C7990:("EnSyatekiMan_Town_Talk",), + 0x809C7A90:("EnSyatekiMan_Swamp_SetupGiveReward",), + 0x809C7C14:("EnSyatekiMan_Swamp_GiveReward",), + 0x809C7D14:("EnSyatekiMan_Town_SetupGiveReward",), + 0x809C7EB4:("EnSyatekiMan_Town_GiveReward",), + 0x809C7FFC:("EnSyatekiMan_Swamp_MovePlayerAndExplainRules",), + 0x809C80C0:("EnSyatekiMan_Swamp_StartGame",), + 0x809C81D0:("EnSyatekiMan_Swamp_RunGame",), + 0x809C8488:("EnSyatekiMan_Swamp_EndGame",), + 0x809C8610:("EnSyatekiMan_Swamp_AddBonusPoints",), + 0x809C8710:("EnSyatekiMan_Town_MovePlayerAndSayHighScore",), + 0x809C8808:("EnSyatekiMan_Town_StartGame",), + 0x809C898C:("EnSyatekiMan_Town_RunGame",), + 0x809C8BF0:("EnSyatekiMan_Town_EndGame",), + 0x809C8DE8:("EnSyatekiMan_Blink",), 0x809C8E44:("EnSyatekiMan_Update",), 0x809C8EE4:("EnSyatekiMan_OverrideLimbDraw",), 0x809C8FAC:("EnSyatekiMan_PostLimbDraw",), @@ -9295,9 +9295,9 @@ 0x809DA1D0:("func_809DA1D0",), 0x809DA22C:("func_809DA22C",), 0x809DA24C:("func_809DA24C",), - 0x809DA264:("func_809DA264",), - 0x809DA344:("func_809DA344",), - 0x809DA460:("func_809DA460",), + 0x809DA264:("Boss02_SpawnEffectSand",), + 0x809DA344:("Boss02_SpawnEffectFragment",), + 0x809DA460:("Boss02_SpawnEffectFlash",), 0x809DA50C:("func_809DA50C",), 0x809DA5AC:("Boss02_Init",), 0x809DAA64:("Boss02_Destroy",), @@ -9306,13 +9306,13 @@ 0x809DAAA8:("func_809DAAA8",), 0x809DAB78:("func_809DAB78",), 0x809DBFB4:("func_809DBFB4",), - 0x809DC218:("func_809DC218",), - 0x809DC320:("Boss02_Update",), - 0x809DC78C:("func_809DC78C",), - 0x809DCA00:("Boss02_Draw",), - 0x809DD0A8:("func_809DD0A8",), - 0x809DD0CC:("func_809DD0CC",), - 0x809DD2F8:("func_809DD2F8",), + 0x809DC218:("Boss02_Tail_Update",), + 0x809DC320:("Boss02_Twinmold_Update",), + 0x809DC78C:("Boss02_Static_Update",), + 0x809DCA00:("Boss02_Twinmold_Draw",), + 0x809DD0A8:("Boss02_Static_Draw",), + 0x809DD0CC:("Boss02_UpdateEffects",), + 0x809DD2F8:("Boss02_DrawEffects",), 0x809DD934:("func_809DD934",), 0x809DEAC4:("func_809DEAC4",), 0x809E2760:("Boss03_PlayUnderwaterSfx",), @@ -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_ChangeAnim",), + 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",), @@ -10036,11 +10036,11 @@ 0x80A29094:("func_80A29094",), 0x80A29150:("EnBigpamet_Update",), 0x80A292A8:("func_80A292A8",), - 0x80A293E4:("func_80A293E4",), - 0x80A29494:("func_80A29494",), + 0x80A293E4:("EnBigpamet_OverrideLimbDraw2",), + 0x80A29494:("EnBigpamet_PostLimbDraw2",), 0x80A294D8:("EnBigpamet_Draw",), - 0x80A29580:("func_80A29580",), - 0x80A29628:("func_80A29628",), + 0x80A29580:("EnBigpamet_OverrideLimbDraw1",), + 0x80A29628:("EnBigpamet_PostLimbDraw1",), 0x80A2966C:("func_80A2966C",), 0x80A29A80:("func_80A29A80",), 0x80A29C18:("BgDblueMovebg_Init",), @@ -10090,7 +10090,7 @@ 0x80A2CF50:("func_80A2CF50",), 0x80A2CF7C:("func_80A2CF7C",), 0x80A2D0FC:("ElfMsg3_Update",), - 0x80A2D280:("EnFg_UpdateAnimation",), + 0x80A2D280:("EnFg_ChangeAnim",), 0x80A2D348:("func_80A2D348",), 0x80A2D3D4:("func_80A2D3D4",), 0x80A2D400:("func_80A2D400",), @@ -10244,15 +10244,15 @@ 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",), @@ -10347,8 +10347,8 @@ 0x80A3E248:("ObjSmork_Draw",), 0x80A3E390:("EnTest2_Init",), 0x80A3E3E4:("EnTest2_Update",), - 0x80A3E4EC:("func_80A3E4EC",), - 0x80A3E524:("func_80A3E524",), + 0x80A3E4EC:("EnTest2_UpdateForLens",), + 0x80A3E524:("EnTest2_Draw",), 0x80A3E7E0:("func_80A3E7E0",), 0x80A3E80C:("func_80A3E80C",), 0x80A3E870:("func_80A3E870",), @@ -10416,19 +10416,19 @@ 0x80A43274:("EnTest4_Update",), 0x80A434E0:("EnBat_Init",), 0x80A437A0:("EnBat_Destroy",), - 0x80A437CC:("func_80A437CC",), - 0x80A43810:("func_80A43810",), - 0x80A43870:("func_80A43870",), - 0x80A438D4:("func_80A438D4",), - 0x80A438F8:("func_80A438F8",), - 0x80A4392C:("func_80A4392C",), - 0x80A43CA0:("func_80A43CA0",), - 0x80A43CE8:("func_80A43CE8",), - 0x80A43F60:("func_80A43F60",), - 0x80A44114:("func_80A44114",), - 0x80A44294:("func_80A44294",), - 0x80A4431C:("func_80A4431C",), - 0x80A443D8:("func_80A443D8",), + 0x80A437CC:("EnBat_IsGraveyardOnSecondDay",), + 0x80A43810:("EnBat_StepAnimation",), + 0x80A43870:("EnBat_SetupPerch",), + 0x80A438D4:("EnBat_Perch",), + 0x80A438F8:("EnBat_SetupFlyIdle",), + 0x80A4392C:("EnBat_FlyIdle",), + 0x80A43CA0:("EnBat_SetupDiveAttack",), + 0x80A43CE8:("EnBat_DiveAttack",), + 0x80A43F60:("EnBat_SetupDie",), + 0x80A44114:("EnBat_Die",), + 0x80A44294:("EnBat_SetupStunned",), + 0x80A4431C:("EnBat_Stunned",), + 0x80A443D8:("EnBat_UpdateDamage",), 0x80A444B8:("EnBat_Update",), 0x80A44818:("EnBat_Draw",), 0x80A44C80:("EnSekihi_Init",), @@ -10436,9 +10436,9 @@ 0x80A44DE8:("func_80A44DE8",), 0x80A44F40:("func_80A44F40",), 0x80A450B0:("func_80A450B0",), - 0x80A45130:("func_80A45130",), + 0x80A45130:("EnSekihi_DoNothing",), 0x80A45140:("EnSekihi_Update",), - 0x80A45164:("func_80A45164",), + 0x80A45164:("EnSekihi_Draw",), 0x80A45360:("EnWiz_Init",), 0x80A45568:("EnWiz_Destroy",), 0x80A455C4:("func_80A455C4",), @@ -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",), @@ -10491,10 +10491,10 @@ 0x80A4BF78:("func_80A4BF78",), 0x80A4C490:("EffChange_Init",), 0x80A4C54C:("EffChange_Destroy",), - 0x80A4C578:("func_80A4C578",), + 0x80A4C578:("EffChange_SetColors",), 0x80A4C5CC:("func_80A4C5CC",), 0x80A4C78C:("EffChange_Update",), - 0x80A4C7B0:("func_80A4C7B0",), + 0x80A4C7B0:("EffChange_Draw",), 0x80A4C9B0:("DmStatue_Init",), 0x80A4C9D4:("DmStatue_Destroy",), 0x80A4C9E4:("DmStatue_Update",), @@ -10515,10 +10515,10 @@ 0x80A4D6A4:("ObjFireshield_Draw",), 0x80A4D9F0:("BgLadder_Init",), 0x80A4DB54:("BgLadder_Destroy",), - 0x80A4DB88:("BgLadder_ActionWait",), - 0x80A4DBD8:("BgLadder_ActionStartCutscene",), - 0x80A4DC48:("BgLadder_ActionFadeIn",), - 0x80A4DCCC:("BgLadder_ActionIdle",), + 0x80A4DB88:("BgLadder_Wait",), + 0x80A4DBD8:("BgLadder_StartCutscene",), + 0x80A4DC48:("BgLadder_FadeIn",), + 0x80A4DCCC:("BgLadder_DoNothing",), 0x80A4DCDC:("BgLadder_Update",), 0x80A4DD00:("BgLadder_Draw",), 0x80A4DED0:("EnMkk_Init",), @@ -10549,7 +10549,7 @@ 0x80A4FB10:("func_80A4FB10",), 0x80A4FB68:("func_80A4FB68",), 0x80A4FCCC:("DemoGetitem_Update",), - 0x80A4FCF0:("func_80A4FCF0",), + 0x80A4FCF0:("DemoGetitem_Draw",), 0x80A4FDD0:("func_80A4FDD0",), 0x80A4FEBC:("func_80A4FEBC",), 0x80A4FFE8:("func_80A4FFE8",), @@ -10591,7 +10591,7 @@ 0x80A52018:("func_80A52018",), 0x80A52074:("func_80A52074",), 0x80A52134:("func_80A52134",), - 0x80A52530:("func_80A52530",), + 0x80A52530:("EnDnq_ValidatePictograph",), 0x80A5257C:("func_80A5257C",), 0x80A52604:("func_80A52604",), 0x80A52648:("func_80A52648",), @@ -10641,32 +10641,32 @@ 0x80A560F0:("EnFirefly2_Draw",), 0x80A56150:("EnRat_Init",), 0x80A56370:("EnRat_Destroy",), - 0x80A563CC:("func_80A563CC",), - 0x80A56444:("func_80A56444",), - 0x80A5665C:("func_80A5665C",), - 0x80A566E0:("func_80A566E0",), - 0x80A56994:("func_80A56994",), - 0x80A56AFC:("func_80A56AFC",), - 0x80A56EB8:("func_80A56EB8",), - 0x80A56F68:("func_80A56F68",), - 0x80A57010:("func_80A57010",), - 0x80A57118:("func_80A57118",), - 0x80A57180:("func_80A57180",), - 0x80A5723C:("func_80A5723C",), - 0x80A57330:("func_80A57330",), - 0x80A57384:("func_80A57384",), - 0x80A57488:("func_80A57488",), - 0x80A574E8:("func_80A574E8",), - 0x80A57570:("func_80A57570",), - 0x80A575F4:("func_80A575F4",), - 0x80A5764C:("func_80A5764C",), - 0x80A57918:("func_80A57918",), - 0x80A57984:("func_80A57984",), - 0x80A57A08:("func_80A57A08",), - 0x80A57A9C:("func_80A57A9C",), + 0x80A563CC:("EnRat_InitializeAxes",), + 0x80A56444:("EnRat_UpdateFloorPoly",), + 0x80A5665C:("EnRat_UpdateRotation",), + 0x80A566E0:("EnRat_ChooseDirection",), + 0x80A56994:("EnRat_IsOnCollisionPoly",), + 0x80A56AFC:("EnRat_IsTouchingSurface",), + 0x80A56EB8:("EnRat_ActorCoordsToWorld",), + 0x80A56F68:("EnRat_SpawnWaterEffects",), + 0x80A57010:("EnRat_HandleNonSceneCollision",), + 0x80A57118:("EnRat_SpawnSmoke",), + 0x80A57180:("EnRat_SetupRevive",), + 0x80A5723C:("EnRat_Revive",), + 0x80A57330:("EnRat_SetupIdle",), + 0x80A57384:("EnRat_Idle",), + 0x80A57488:("EnRat_SetupSpottedPlayer",), + 0x80A574E8:("EnRat_SpottedPlayer",), + 0x80A57570:("EnRat_UpdateSparkOffsets",), + 0x80A575F4:("EnRat_SetupChasePlayer",), + 0x80A5764C:("EnRat_ChasePlayer",), + 0x80A57918:("EnRat_SetupBounced",), + 0x80A57984:("EnRat_Bounced",), + 0x80A57A08:("EnRat_Explode",), + 0x80A57A9C:("EnRat_PostDetonation",), 0x80A57AE0:("EnRat_Update",), - 0x80A57F10:("func_80A57F10",), - 0x80A57F4C:("func_80A57F4C",), + 0x80A57F10:("EnRat_OverrideLimbDraw",), + 0x80A57F4C:("EnRat_PostLimbDraw",), 0x80A58354:("EnRat_Draw",), 0x80A587A0:("func_80A587A0",), 0x80A58908:("func_80A58908",), @@ -10749,7 +10749,7 @@ 0x80A60DA0:("func_80A60DA0",), 0x80A60E08:("func_80A60E08",), 0x80A60F68:("BgSpoutFire_Update",), - 0x80A61040:("func_80A61040",), + 0x80A61040:("BgSpoutFire_Draw",), 0x80A612B0:("EnDyExtra_Destroy",), 0x80A612C0:("EnDyExtra_Init",), 0x80A61334:("func_80A61334",), @@ -10760,7 +10760,7 @@ 0x80A619EC:("EnBal_Destroy",), 0x80A61A18:("func_80A61A18",), 0x80A61A44:("func_80A61A44",), - 0x80A61A6C:("func_80A61A6C",), + 0x80A61A6C:("EnBal_ValidatePictograph",), 0x80A61ADC:("func_80A61ADC",), 0x80A61B5C:("func_80A61B5C",), 0x80A61C9C:("func_80A61C9C",), @@ -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",), @@ -11197,8 +11197,8 @@ 0x80A83FBC:("func_80A83FBC",), 0x80A84088:("func_80A84088",), 0x80A84338:("func_80A84338",), - 0x80A84CD0:("func_80A84CD0",), - 0x80A84CF8:("func_80A84CF8",), + 0x80A84CD0:("ObjPurify_SetSysMatrix",), + 0x80A84CF8:("ObjPurify_IsPurified",), 0x80A84D68:("ObjPurify_Init",), 0x80A84E68:("ObjPurify_Destroy",), 0x80A84EAC:("func_80A84EAC",), @@ -11212,7 +11212,7 @@ 0x80A850B0:("func_80A850B0",), 0x80A850E8:("func_80A850E8",), 0x80A8515C:("func_80A8515C",), - 0x80A85194:("func_80A85194",), + 0x80A85194:("ObjPurify_DoNothing",), 0x80A851A4:("ObjPurify_Update",), 0x80A851C8:("func_80A851C8",), 0x80A85304:("func_80A85304",), @@ -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_ChangeAnim",), + 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",), @@ -11547,37 +11547,37 @@ 0x80AA90F4:("func_80AA90F4",), 0x80AA9140:("DmChar01_Update",), 0x80AA922C:("DmChar01_Draw",), - 0x80AAAE30:("func_80AAAE30",), - 0x80AAAECC:("func_80AAAECC",), - 0x80AAAF2C:("func_80AAAF2C",), + 0x80AAAE30:("DmChar02_ChangeAnim",), + 0x80AAAECC:("DmChar02_PlaySfxForDroppingOcarinaCutscene",), + 0x80AAAF2C:("DmChar02_PlaySfxForCutscenes",), 0x80AAAF78:("DmChar02_Init",), 0x80AAB03C:("DmChar02_Destroy",), - 0x80AAB04C:("func_80AAB04C",), + 0x80AAB04C:("DmChar02_PerformCutsceneActions",), 0x80AAB19C:("DmChar02_Update",), - 0x80AAB23C:("func_80AAB23C",), - 0x80AAB258:("func_80AAB258",), - 0x80AAB270:("func_80AAB270",), + 0x80AAB23C:("DmChar02_OverrideLimbDraw",), + 0x80AAB258:("DmChar02_PostLimbDraw",), + 0x80AAB270:("DmChar02_TransformLimbDraw",), 0x80AAB284:("DmChar02_Draw",), - 0x80AAB4A0:("func_80AAB4A0",), + 0x80AAB4A0:("DmChar03_ChangeAnim",), 0x80AAB53C:("DmChar03_Init",), 0x80AAB5E8:("DmChar03_Destroy",), 0x80AAB5F8:("func_80AAB5F8",), 0x80AAB644:("func_80AAB644",), - 0x80AAB700:("func_80AAB700",), + 0x80AAB700:("DmChar03_DoNothing",), 0x80AAB710:("func_80AAB710",), 0x80AAB838:("func_80AAB838",), 0x80AAB8DC:("DmChar03_Update",), - 0x80AAB974:("func_80AAB974",), - 0x80AAB990:("func_80AAB990",), - 0x80AAB9A8:("func_80AAB9A8",), + 0x80AAB974:("DmChar03_OverrideLimbDraw",), + 0x80AAB990:("DmChar03_PostLimbDraw",), + 0x80AAB9A8:("DmChar03_TransformLimbDraw",), 0x80AAB9BC:("DmChar03_Draw",), 0x80AABA84:("func_80AABA84",), - 0x80AABC40:("func_80AABC40",), + 0x80AABC40:("DmChar04_ChangeAnim",), 0x80AABCDC:("DmChar04_Init",), 0x80AABE24:("DmChar04_Destroy",), 0x80AABE34:("func_80AABE34",), 0x80AABF28:("DmChar04_Update",), - 0x80AABF74:("func_80AABF74",), + 0x80AABF74:("DmChar04_OverrideLimbDraw",), 0x80AAC03C:("DmChar04_Draw",), 0x80AAC5A0:("func_80AAC5A0",), 0x80AAC63C:("func_80AAC63C",), @@ -11656,16 +11656,16 @@ 0x80AB0E7C:("func_80AB0E7C",), 0x80AB0F90:("func_80AB0F90",), 0x80AB1124:("DmChar08_Draw",), - 0x80AB1E10:("func_80AB1E10",), + 0x80AB1E10:("DmChar09_ChangeAnim",), 0x80AB1EAC:("DmChar09_Init",), 0x80AB1F90:("DmChar09_Destroy",), 0x80AB1FA0:("func_80AB1FA0",), 0x80AB1FDC:("func_80AB1FDC",), - 0x80AB2258:("func_80AB2258",), + 0x80AB2258:("DmChar09_DoNothing",), 0x80AB2268:("func_80AB2268",), 0x80AB24BC:("func_80AB24BC",), 0x80AB2544:("DmChar09_Update",), - 0x80AB25D8:("func_80AB25D8",), + 0x80AB25D8:("DmChar09_OverrideLimbDraw",), 0x80AB261C:("DmChar09_Draw",), 0x80AB2790:("ObjTokeidai_GetTargetSunMoonPanelRotation",), 0x80AB27B4:("ObjTokeidai_SetupClockOrExteriorGear",), @@ -11720,7 +11720,7 @@ 0x80AB53DC:("EnMnk_Init",), 0x80AB59E8:("EnMnk_Destroy",), 0x80AB5A64:("func_80AB5A64",), - 0x80AB5B38:("func_80AB5B38",), + 0x80AB5B38:("EnMnk_ValidatePictograph",), 0x80AB5B84:("func_80AB5B84",), 0x80AB5BCC:("func_80AB5BCC",), 0x80AB5C14:("func_80AB5C14",), @@ -11916,7 +11916,7 @@ 0x80AC299C:("EnBigokuta_MoveCamera",), 0x80AC2A1C:("EnBigokuta_ResetCamera",), 0x80AC2A7C:("EnBigokuta_ShootPlayer",), - 0x80AC2B4C:("func_80AC2B4C",), + 0x80AC2B4C:("EnBigokuta_ValidatePictograph",), 0x80AC2B98:("EnBigokuta_IsInWater",), 0x80AC2C30:("EnBigokuta_SpawnRipple",), 0x80AC2C84:("EnBigokuta_SetupIdle",), @@ -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",), @@ -12387,14 +12387,14 @@ 0x80AE0FA8:("EnTsn_OverrideLimbDraw",), 0x80AE1024:("EnTsn_PostLimbDraw",), 0x80AE1080:("EnTsn_Draw",), - 0x80AE1650:("func_80AE1650",), - 0x80AE16A0:("func_80AE16A0",), - 0x80AE16D8:("func_80AE16D8",), + 0x80AE1650:("EnDs2n_SetupIdle",), + 0x80AE16A0:("EnDs2n_Idle",), + 0x80AE16D8:("EnDs2n_UpdateEyes",), 0x80AE1760:("EnDs2n_Init",), 0x80AE17D0:("EnDs2n_Destroy",), 0x80AE17F4:("EnDs2n_Update",), - 0x80AE1874:("func_80AE1874",), - 0x80AE18B4:("func_80AE18B4",), + 0x80AE1874:("EnDs2n_OverrideLimbDraw",), + 0x80AE18B4:("EnDs2n_PostLimbDraw",), 0x80AE19B8:("EnDs2n_Draw",), 0x80AE1B70:("EnFsn_TestItemSelected",), 0x80AE1BF0:("EnFsn_GetWelcome",), @@ -12791,7 +12791,7 @@ 0x80AFD380:("func_80AFD380",), 0x80AFD4B8:("ElfMsg4_Init",), 0x80AFD5A4:("ElfMsg4_Destroy",), - 0x80AFD5B4:("func_80AFD5B4",), + 0x80AFD5B4:("ElfMsg4_GetTextId",), 0x80AFD5E0:("func_80AFD5E0",), 0x80AFD668:("func_80AFD668",), 0x80AFD770:("func_80AFD770",), @@ -12865,12 +12865,12 @@ 0x80B00F08:("EnTalkGibud_OverrideLimbDraw",), 0x80B00F64:("EnTalkGibud_PostLimbDraw",), 0x80B01040:("EnTalkGibud_Draw",), - 0x80B01990:("EnGiant_ChangeAnimation",), + 0x80B01990:("EnGiant_ChangeAnim",), 0x80B01A74:("EnGiant_IsImprisoned",), 0x80B01B30:("EnGiant_Init",), 0x80B01E74:("EnGiant_Destroy",), 0x80B01E84:("EnGiant_ChangeToStartOrLoopAnimation",), - 0x80B01EE8:("EnGiant_ChangeAnimationBasedOnCsAction",), + 0x80B01EE8:("EnGiant_ChangeAnimBasedOnCsAction",), 0x80B020A0:("EnGiant_UpdateAlpha",), 0x80B0211C:("EnGiant_PlayAndUpdateAnimation",), 0x80B02234:("EnGiant_PlaySound",), @@ -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",), @@ -13157,82 +13157,82 @@ 0x80B1A1B0:("TGSw_Draw",), 0x80B1A3B0:("EnPoSisters_Init",), 0x80B1A600:("EnPoSisters_Destroy",), - 0x80B1A648:("func_80B1A648",), - 0x80B1A768:("func_80B1A768",), - 0x80B1A894:("func_80B1A894",), - 0x80B1A9B0:("func_80B1A9B0",), - 0x80B1AA88:("func_80B1AA88",), - 0x80B1AAE8:("func_80B1AAE8",), - 0x80B1AB5C:("func_80B1AB5C",), - 0x80B1ABB8:("func_80B1ABB8",), - 0x80B1AC40:("func_80B1AC40",), - 0x80B1ACB8:("func_80B1ACB8",), - 0x80B1AE28:("func_80B1AE28",), - 0x80B1AE3C:("func_80B1AE3C",), - 0x80B1AF8C:("func_80B1AF8C",), - 0x80B1B020:("func_80B1B020",), - 0x80B1B0E0:("func_80B1B0E0",), - 0x80B1B168:("func_80B1B168",), - 0x80B1B280:("func_80B1B280",), - 0x80B1B2F0:("func_80B1B2F0",), - 0x80B1B3A8:("func_80B1B3A8",), - 0x80B1B444:("func_80B1B444",), - 0x80B1B5B4:("func_80B1B5B4",), - 0x80B1B628:("func_80B1B628",), - 0x80B1B70C:("func_80B1B70C",), - 0x80B1B7BC:("func_80B1B7BC",), - 0x80B1B860:("func_80B1B860",), - 0x80B1B940:("func_80B1B940",), - 0x80B1BA3C:("func_80B1BA3C",), - 0x80B1BA90:("func_80B1BA90",), - 0x80B1BC4C:("func_80B1BC4C",), - 0x80B1BCA0:("func_80B1BCA0",), - 0x80B1BCF0:("func_80B1BCF0",), - 0x80B1BE4C:("func_80B1BE4C",), - 0x80B1BF2C:("func_80B1BF2C",), - 0x80B1C030:("func_80B1C030",), - 0x80B1C0A4:("func_80B1C0A4",), - 0x80B1C2E8:("func_80B1C2E8",), - 0x80B1C340:("func_80B1C340",), - 0x80B1C408:("func_80B1C408",), + 0x80B1A648:("EnPoSisters_UpdateDeathFlameSwirl",), + 0x80B1A768:("EnPoSisters_MatchPlayerXZ",), + 0x80B1A894:("EnPoSisters_MatchPlayerY",), + 0x80B1A9B0:("EnPoSisters_CheckZTarget",), + 0x80B1AA88:("EnPoSisters_SetupObserverIdle",), + 0x80B1AAE8:("EnPoSisters_ObserverIdle",), + 0x80B1AB5C:("EnPoSisters_SetupAimlessIdleFlying2",), + 0x80B1ABB8:("EnPoSisters_AimlessIdleFlying2",), + 0x80B1AC40:("EnPoSisters_SetupAimlessIdleFlying",), + 0x80B1ACB8:("EnPoSisters_AimlessIdleFlying",), + 0x80B1AE28:("EnPoSisters_SetupInvestigating",), + 0x80B1AE3C:("EnPoSisters_Investigating",), + 0x80B1AF8C:("EnPoSisters_SetupSpinUp",), + 0x80B1B020:("EnPoSisters_SpinUp",), + 0x80B1B0E0:("EnPoSisters_SetupSpinAttack",), + 0x80B1B168:("EnPoSisters_SpinAttack",), + 0x80B1B280:("EnPoSisters_SetupAttackConnect",), + 0x80B1B2F0:("EnPoSisters_AttackConnectDrift",), + 0x80B1B3A8:("EnPoSisters_SetupDamageFlinch",), + 0x80B1B444:("EnPoSisters_DamageFlinch",), + 0x80B1B5B4:("EnPoSisters_SetupFlee",), + 0x80B1B628:("EnPoSisters_Flee",), + 0x80B1B70C:("EnPoSisters_SetupSpinToInvis",), + 0x80B1B7BC:("EnPoSisters_SpinToInvis",), + 0x80B1B860:("EnPoSisters_SetupSpinBackToVisible",), + 0x80B1B940:("EnPoSisters_SpinBackToVisible",), + 0x80B1BA3C:("EnPoSisters_SetupDeathStage1",), + 0x80B1BA90:("EnPoSisters_DeathStage1",), + 0x80B1BC4C:("EnPoSisters_SetupDeathStage2",), + 0x80B1BCA0:("EnPoSisters_DeathStage2",), + 0x80B1BCF0:("EnPoSisters_SpawnMegClones",), + 0x80B1BE4C:("EnPoSisters_MegCloneVanish",), + 0x80B1BF2C:("EnPoSisters_MegCloneWaitForSpinBack",), + 0x80B1C030:("EnPoSisters_SetupMegSurroundPlayer",), + 0x80B1C0A4:("EnPoSisters_MegSurroundPlayer",), + 0x80B1C2E8:("EnPoSisters_SetupSpawnPo",), + 0x80B1C340:("EnPoSisters_PoeSpawn",), + 0x80B1C408:("EnPoSisters_CheckCollision",), 0x80B1C61C:("EnPoSisters_Update",), - 0x80B1C974:("func_80B1C974",), + 0x80B1C974:("EnPoSisters_UpdateColors",), 0x80B1CB44:("EnPoSisters_OverrideLimbDraw",), 0x80B1CD34:("EnPoSisters_PostLimbDraw",), 0x80B1D484:("EnPoSisters_Draw",), 0x80B1DEB0:("EnPp_Init",), 0x80B1E234:("EnPp_Destroy",), - 0x80B1E29C:("func_80B1E29C",), - 0x80B1E3D4:("func_80B1E3D4",), - 0x80B1E5A8:("func_80B1E5A8",), - 0x80B1E680:("func_80B1E680",), - 0x80B1E778:("func_80B1E778",), - 0x80B1E958:("func_80B1E958",), - 0x80B1E970:("func_80B1E970",), - 0x80B1EBD8:("func_80B1EBD8",), - 0x80B1EC24:("func_80B1EC24",), - 0x80B1EFFC:("func_80B1EFFC",), - 0x80B1F048:("func_80B1F048",), - 0x80B1F0A4:("func_80B1F0A4",), - 0x80B1F188:("func_80B1F188",), - 0x80B1F244:("func_80B1F244",), - 0x80B1F29C:("func_80B1F29C",), - 0x80B1F4A0:("func_80B1F4A0",), - 0x80B1F560:("func_80B1F560",), - 0x80B1F664:("func_80B1F664",), - 0x80B1F6B4:("func_80B1F6B4",), - 0x80B1F770:("func_80B1F770",), - 0x80B1F940:("func_80B1F940",), - 0x80B1FAD0:("func_80B1FAD0",), - 0x80B1FC7C:("func_80B1FC7C",), - 0x80B1FF20:("func_80B1FF20",), - 0x80B20030:("func_80B20030",), - 0x80B202B8:("func_80B202B8",), - 0x80B203BC:("func_80B203BC",), - 0x80B20668:("func_80B20668",), + 0x80B1E29C:("EnPp_PointlessPosCheck",), + 0x80B1E3D4:("EnPp_SpawnDust",), + 0x80B1E5A8:("EnPp_ChangeAnim",), + 0x80B1E680:("EnPp_PlaySfxForAnimation",), + 0x80B1E778:("EnPp_CheckCollision",), + 0x80B1E958:("EnPp_SetupIdle",), + 0x80B1E970:("EnPp_Idle",), + 0x80B1EBD8:("EnPp_SetupCharge",), + 0x80B1EC24:("EnPp_Charge",), + 0x80B1EFFC:("EnPp_SetupAttack",), + 0x80B1F048:("EnPp_Attack",), + 0x80B1F0A4:("EnPp_SetupBounced",), + 0x80B1F188:("EnPp_Bounced",), + 0x80B1F244:("EnPp_SetupRoar",), + 0x80B1F29C:("EnPp_Roar",), + 0x80B1F4A0:("EnPp_SetupJump",), + 0x80B1F560:("EnPp_Jump",), + 0x80B1F664:("EnPp_SetupStunnedOrFrozen",), + 0x80B1F6B4:("EnPp_StunnedOrFrozen",), + 0x80B1F770:("EnPp_SetupDamaged",), + 0x80B1F940:("EnPp_Damaged",), + 0x80B1FAD0:("EnPp_SetupDead",), + 0x80B1FC7C:("EnPp_Dead",), + 0x80B1FF20:("EnPp_Mask_SetupDetach",), + 0x80B20030:("EnPp_Mask_Detach",), + 0x80B202B8:("EnPp_BodyPart_SetupMove",), + 0x80B203BC:("EnPp_BodyPart_Move",), + 0x80B20668:("EnPp_UpdateDamage",), 0x80B20B40:("EnPp_Update",), - 0x80B20E6C:("func_80B20E6C",), - 0x80B20F70:("func_80B20F70",), + 0x80B20E6C:("EnPp_OverrideLimbDraw",), + 0x80B20F70:("EnPp_PostLimbDraw",), 0x80B21344:("EnPp_Draw",), 0x80B21B00:("EnHakurock_Init",), 0x80B21BB4:("EnHakurock_Destroy",), @@ -13277,26 +13277,26 @@ 0x80B23F50:("ObjWind_Destroy",), 0x80B23F60:("ObjWind_Update",), 0x80B243C0:("ObjWind_Draw",), - 0x80B24630:("func_80B24630",), - 0x80B246F4:("func_80B246F4",), - 0x80B2478C:("func_80B2478C",), - 0x80B248B8:("func_80B248B8",), + 0x80B24630:("EnRacedog_ChangeAnim",), + 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_PlaySfxWalk",), 0x80B25708:("EnRacedog_Update",), - 0x80B2583C:("func_80B2583C",), - 0x80B258D8:("func_80B258D8",), + 0x80B2583C:("EnRacedog_UpdateSelectionArrow",), + 0x80B258D8:("EnRacedog_DrawSelectionArrow",), 0x80B25A74:("EnRacedog_OverrideLimbDraw",), 0x80B25A90:("EnRacedog_PostLimbDraw",), 0x80B25B14:("EnRacedog_Draw",), @@ -13372,21 +13372,21 @@ 0x80B2ADB0:("func_80B2ADB0",), 0x80B2AF80:("func_80B2AF80",), 0x80B2B180:("func_80B2B180",), - 0x80B2B830:("func_80B2B830",), - 0x80B2B874:("func_80B2B874",), - 0x80B2B8F4:("func_80B2B8F4",), - 0x80B2B974:("func_80B2B974",), - 0x80B2BAA4:("func_80B2BAA4",), - 0x80B2BBFC:("func_80B2BBFC",), - 0x80B2BCF8:("func_80B2BCF8",), - 0x80B2BD30:("func_80B2BD30",), - 0x80B2BD88:("func_80B2BD88",), - 0x80B2BD98:("func_80B2BD98",), - 0x80B2BE54:("func_80B2BE54",), + 0x80B2B830:("EnPst_UpdateCollision",), + 0x80B2B874:("EnPst_HandleLetterDay1",), + 0x80B2B8F4:("EnPst_HandleLetterDay2",), + 0x80B2B974:("EnPst_ChooseBehaviour",), + 0x80B2BAA4:("EnPst_GetMsgEventScript",), + 0x80B2BBFC:("EnPst_CheckTalk",), + 0x80B2BCF8:("EnPst_UpdateFlagsSubs",), + 0x80B2BD30:("EnPst_ProcessScheduleOutput",), + 0x80B2BD88:("EnPst_Idle",), + 0x80B2BD98:("EnPst_FollowSchedule",), + 0x80B2BE54:("EnPst_Talk",), 0x80B2BF3C:("EnPst_Init",), 0x80B2C04C:("EnPst_Destroy",), 0x80B2C078:("EnPst_Update",), - 0x80B2C11C:("func_80B2C11C",), + 0x80B2C11C:("EnPst_OverrideLimbDraw",), 0x80B2C18C:("EnPst_Draw",), 0x80B2C6F0:("EnPoh_Init",), 0x80B2C8B8:("EnPoh_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",), @@ -14005,7 +14005,7 @@ 0x80B529E4:("EnGk_Update",), 0x80B52AD4:("EnGk_OverrideLimbDraw",), 0x80B52AF0:("EnGk_PostLimbDraw",), - 0x80B52D8C:("EnGk_TransformDraw",), + 0x80B52D8C:("EnGk_TransformLimbDraw",), 0x80B52F74:("EnGk_Draw",), 0x80B53840:("func_80B53840",), 0x80B539CC:("func_80B539CC",), @@ -14130,14 +14130,14 @@ 0x80B5E1D8:("func_80B5E1D8",), 0x80B5E890:("EnDragon_Init",), 0x80B5EA74:("EnDragon_Destroy",), - 0x80B5EAA0:("EnDragon_ChangeAnimation",), + 0x80B5EAA0:("EnDragon_ChangeAnim",), 0x80B5EB40:("EnDragon_SpawnBubbles",), 0x80B5ED90:("EnDragon_RetreatOnceTimerEnds",), 0x80B5EDF0:("EnDragon_SetupRetreatOrIdle",), 0x80B5EE3C:("EnDragon_RetreatOrIdle",), 0x80B5EF88:("EnDragon_SetupExtend",), 0x80B5EFD0:("EnDragon_Extend",), - 0x80B5F3A4:("EnDragon_CameraSetAtEye",), + 0x80B5F3A4:("EnDragon_SetSubCamEyeAt",), 0x80B5F418:("EnDragon_SetupGrab",), 0x80B5F508:("EnDragon_Grab",), 0x80B5F888:("EnDragon_SetupAttack",), @@ -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",), @@ -14294,16 +14294,16 @@ 0x80B6DEA8:("func_80B6DEA8",), 0x80B6DEB8:("BgHakaCurtain_Update",), 0x80B6DF44:("BgHakaCurtain_Draw",), - 0x80B6E020:("func_80B6E020",), - 0x80B6E090:("func_80B6E090",), + 0x80B6E020:("BgKin2Bombwall_IsHitFromNearby",), + 0x80B6E090:("BgKin2Bombwall_SpawnEffects",), 0x80B6E3AC:("BgKin2Bombwall_Init",), 0x80B6E470:("BgKin2Bombwall_Destroy",), - 0x80B6E4B8:("func_80B6E4B8",), - 0x80B6E4CC:("func_80B6E4CC",), - 0x80B6E544:("func_80B6E544",), - 0x80B6E558:("func_80B6E558",), - 0x80B6E5F8:("func_80B6E5F8",), - 0x80B6E614:("func_80B6E614",), + 0x80B6E4B8:("BgKin2Bombwall_SetupWait",), + 0x80B6E4CC:("BgKin2Bombwall_Wait",), + 0x80B6E544:("BgKin2Bombwall_SetupPlayCutscene",), + 0x80B6E558:("BgKin2Bombwall_PlayCutscene",), + 0x80B6E5F8:("BgKin2Bombwall_SetupEndCutscene",), + 0x80B6E614:("BgKin2Bombwall_EndCutscene",), 0x80B6E664:("BgKin2Bombwall_Update",), 0x80B6E688:("BgKin2Bombwall_Draw",), 0x80B6E820:("BgKin2Fence_CheckHitMask",), @@ -14462,57 +14462,57 @@ 0x80B77354:("EnTruMt_TransformLimbDraw",), 0x80B773D0:("EnTruMt_Draw",), 0x80B77770:("func_80B77770",), - 0x80B77FA4:("func_80B77FA4",), + 0x80B77FA4:("ObjUm_InitBandits",), 0x80B781DC:("func_80B781DC",), 0x80B783E0:("func_80B783E0",), 0x80B78764:("func_80B78764",), 0x80B78A54:("func_80B78A54",), 0x80B78C18:("func_80B78C18",), - 0x80B78D08:("func_80B78D08",), + 0x80B78D08:("ObjUm_UpdateBanditsCollisions",), 0x80B78DF0:("func_80B78DF0",), 0x80B78E2C:("ObjUm_SetupAction",), - 0x80B78E38:("func_80B78E38",), - 0x80B78E88:("func_80B78E88",), + 0x80B78E38:("ObjUm_SetPlayerPosition",), + 0x80B78E88:("ObjUm_RotatePlayer",), 0x80B78EBC:("func_80B78EBC",), - 0x80B78EFC:("func_80B78EFC",), + 0x80B78EFC:("ObjUm_RotatePlayerView",), 0x80B78F24:("ObjUm_Init",), 0x80B7949C:("ObjUm_Destroy",), 0x80B79524:("func_80B79524",), 0x80B79560:("func_80B79560",), 0x80B795A0:("func_80B795A0",), 0x80B79734:("func_80B79734",), - 0x80B797EC:("func_80B797EC",), + 0x80B797EC:("ObjUm_RanchGetDialogue",), 0x80B7984C:("func_80B7984C",), 0x80B79A24:("func_80B79A24",), - 0x80B79A50:("func_80B79A50",), - 0x80B79BA0:("func_80B79BA0",), - 0x80B79F10:("func_80B79F10",), - 0x80B79FFC:("func_80B79FFC",), + 0x80B79A50:("ObjUm_RanchWait",), + 0x80B79BA0:("ObjUm_UpdatePath",), + 0x80B79F10:("ObjUm_RanchWaitPathFinished",), + 0x80B79FFC:("ObjUm_RanchStartCs",), 0x80B7A070:("func_80B7A070",), 0x80B7A0E0:("func_80B7A0E0",), 0x80B7A144:("func_80B7A144",), - 0x80B7A1B4:("func_80B7A1B4",), + 0x80B7A1B4:("ObjUm_PreMilkRunDialogueHandler",), 0x80B7A240:("func_80B7A240",), 0x80B7A2AC:("func_80B7A2AC",), 0x80B7A394:("func_80B7A394",), - 0x80B7A400:("func_80B7A400",), - 0x80B7A494:("func_80B7A494",), + 0x80B7A400:("ObjUm_PreMilkRunStartCs",), + 0x80B7A494:("ObjUm_RunMinigame",), 0x80B7A614:("func_80B7A614",), 0x80B7A7AC:("func_80B7A7AC",), 0x80B7A860:("func_80B7A860",), 0x80B7AB78:("func_80B7AB78",), 0x80B7ABE4:("func_80B7ABE4",), - 0x80B7AC94:("func_80B7AC94",), - 0x80B7AD34:("func_80B7AD34",), - 0x80B7AE58:("func_80B7AE58",), - 0x80B7AEFC:("func_80B7AEFC",), + 0x80B7AC94:("ObjUm_StartCs",), + 0x80B7AD34:("ObjUm_PostMilkRunWaitPathFinished",), + 0x80B7AE58:("ObjUm_PostMilkRunStartCs",), + 0x80B7AEFC:("ObjUm_TerminaFieldIdle",), 0x80B7AF30:("func_80B7AF30",), - 0x80B7B154:("func_80B7B154",), - 0x80B7B18C:("func_80B7B18C",), + 0x80B7B154:("ObjUm_DefaultAnim",), + 0x80B7B18C:("ObjUm_ChangeAnim",), 0x80B7B368:("ObjUm_Update",), - 0x80B7B598:("func_80B7B598",), - 0x80B7B93C:("func_80B7B93C",), - 0x80B7BABC:("func_80B7BABC",), + 0x80B7B598:("ObjUm_OverrideLimbDraw",), + 0x80B7B93C:("ObjUm_SpawnFragments",), + 0x80B7BABC:("ObjUm_PostLimbDraw",), 0x80B7BEA4:("func_80B7BEA4",), 0x80B7C03C:("ObjUm_Draw",), 0x80B7C890:("EnNeoReeba_Init",), @@ -14574,13 +14574,13 @@ 0x80B7F398:("func_80B7F398",), 0x80B7F474:("BgIkanaBlock_Update",), 0x80B7F564:("func_80B7F564",), - 0x80B7F730:("func_80B7F730",), + 0x80B7F730:("BgIkanaMirror_SetQuadVertices",), 0x80B7F850:("BgIkanaMirror_Init",), 0x80B7FA00:("BgIkanaMirror_Destroy",), - 0x80B7FA84:("func_80B7FA84",), - 0x80B7FA9C:("func_80B7FA9C",), - 0x80B7FB84:("func_80B7FB84",), - 0x80B7FBA4:("func_80B7FBA4",), + 0x80B7FA84:("BgIkanaMirror_SetupWait",), + 0x80B7FA9C:("BgIkanaMirror_Wait",), + 0x80B7FB84:("BgIkanaMirror_SetupEmitLight",), + 0x80B7FBA4:("BgIkanaMirror_EmitLight",), 0x80B7FCB8:("BgIkanaMirror_Update",), 0x80B7FCDC:("BgIkanaMirror_Draw",), 0x80B802E0:("func_80B802E0",), @@ -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",), @@ -15168,27 +15168,27 @@ 0x80BA7D30:("EnRailgibud_SinkIntoGround",), 0x80BA7DC8:("EnRailgibud_PerformCutsceneActions",), 0x80BA8050:("EnRailgibud_Cutscene_Update",), - 0x80BA8820:("func_80BA8820",), - 0x80BA886C:("func_80BA886C",), - 0x80BA8C4C:("func_80BA8C4C",), - 0x80BA8C90:("func_80BA8C90",), - 0x80BA8D2C:("func_80BA8D2C",), - 0x80BA8DF4:("func_80BA8DF4",), - 0x80BA8F88:("func_80BA8F88",), - 0x80BA9110:("func_80BA9110",), - 0x80BA9160:("func_80BA9160",), - 0x80BA93AC:("func_80BA93AC",), - 0x80BA9480:("func_80BA9480",), - 0x80BA9758:("func_80BA9758",), - 0x80BA9848:("func_80BA9848",), - 0x80BA98EC:("func_80BA98EC",), - 0x80BA9AB8:("func_80BA9AB8",), - 0x80BA9B24:("func_80BA9B24",), - 0x80BA9B80:("func_80BA9B80",), - 0x80BA9CD4:("func_80BA9CD4",), - 0x80BA9E00:("func_80BA9E00",), - 0x80BA9E10:("func_80BA9E10",), - 0x80BA9E48:("func_80BA9E48",), + 0x80BA8820:("EnBaba_FindBombShopkeeper",), + 0x80BA886C:("EnBaba_HandleConversation",), + 0x80BA8C4C:("EnBaba_TriggerTransition",), + 0x80BA8C90:("EnBaba_UpdateCollider",), + 0x80BA8D2C:("EnBaba_MoveForward",), + 0x80BA8DF4:("EnBaba_UpdateModel",), + 0x80BA8F88:("EnBaba_InitTimePath",), + 0x80BA9110:("EnBaba_ProcessScheduleOutput",), + 0x80BA9160:("EnBaba_FollowTimePath",), + 0x80BA93AC:("EnBaba_HandleSchedule",), + 0x80BA9480:("EnBaba_FinishInit",), + 0x80BA9758:("EnBaba_Idle",), + 0x80BA9848:("EnBaba_FollowSchedule_Talk",), + 0x80BA98EC:("EnBaba_Talk",), + 0x80BA9AB8:("EnBaba_GiveBlastMask",), + 0x80BA9B24:("EnBaba_GaveBlastMask",), + 0x80BA9B80:("EnBaba_FollowSchedule",), + 0x80BA9CD4:("EnBaba_KnockedOver",), + 0x80BA9E00:("EnBaba_DoNothing",), + 0x80BA9E10:("EnBaba_Walk",), + 0x80BA9E48:("EnBaba_FaceForward",), 0x80BA9E6C:("EnBaba_Init",), 0x80BA9F24:("EnBaba_Destroy",), 0x80BA9F50:("EnBaba_Update",), @@ -15198,7 +15198,7 @@ 0x80BAA220:("EnBaba_Draw",), 0x80BAA6D0:("EnSuttari_UpdateCollider",), 0x80BAA848:("EnSuttari_GetActorById",), - 0x80BAA88C:("EnSuttari_SetNextEntrance",), + 0x80BAA88C:("EnSuttari_TriggerTransition",), 0x80BAA8D0:("EnSuttari_UpdateTime",), 0x80BAA904:("func_80BAA904",), 0x80BAA9B4:("func_80BAA9B4",), @@ -15380,7 +15380,7 @@ 0x80BB9F24:("ObjChan_ChandelierAction",), 0x80BBA2FC:("ObjChan_InitPot",), 0x80BBA314:("ObjChan_PotAction",), - 0x80BBA488:("ObjChan_CreateSmashParticles",), + 0x80BBA488:("ObjChan_CreateSmashEffects",), 0x80BBA738:("ObjChan_Update",), 0x80BBA78C:("ObjChan_Draw",), 0x80BBA894:("ObjChan_DrawPot",), @@ -15414,42 +15414,42 @@ 0x80BBC4E4:("func_80BBC4E4",), 0x80BBC500:("func_80BBC500",), 0x80BBC540:("EnZos_Draw",), - 0x80BBCA80:("func_80BBCA80",), - 0x80BBD348:("func_80BBD348",), - 0x80BBD8F0:("func_80BBD8F0",), - 0x80BBD93C:("func_80BBD93C",), - 0x80BBD98C:("func_80BBD98C",), - 0x80BBDACC:("func_80BBDACC",), - 0x80BBDC34:("func_80BBDC34",), - 0x80BBDCFC:("func_80BBDCFC",), - 0x80BBDDF8:("func_80BBDDF8",), - 0x80BBDE78:("func_80BBDE78",), - 0x80BBDF28:("func_80BBDF28",), - 0x80BBDFA8:("func_80BBDFA8",), - 0x80BBE05C:("func_80BBE05C",), - 0x80BBE0E4:("func_80BBE0E4",), - 0x80BBE144:("func_80BBE144",), - 0x80BBE374:("func_80BBE374",), - 0x80BBE498:("func_80BBE498",), - 0x80BBE73C:("func_80BBE73C",), - 0x80BBE844:("func_80BBE844",), - 0x80BBE904:("func_80BBE904",), - 0x80BBE9F8:("func_80BBE9F8",), - 0x80BBEAD8:("func_80BBEAD8",), - 0x80BBEBF8:("func_80BBEBF8",), - 0x80BBECBC:("func_80BBECBC",), - 0x80BBEEB4:("func_80BBEEB4",), - 0x80BBEF34:("func_80BBEF34",), - 0x80BBEFA0:("func_80BBEFA0",), - 0x80BBF01C:("func_80BBF01C",), + 0x80BBCA80:("EnSGoro_ShrineGoron_NextTextId",), + 0x80BBD348:("EnSGoro_BombshopGoron_NextTextId",), + 0x80BBD8F0:("EnSGoro_FindGoronElder",), + 0x80BBD93C:("EnSGoro_FindGoronChild",), + 0x80BBD98C:("EnSGoro_UpdateSleeping",), + 0x80BBDACC:("EnSGoro_UpdateCheerAnimation",), + 0x80BBDC34:("EnSGoro_CheckLullaby",), + 0x80BBDCFC:("EnSGoro_CheckGKBehavior",), + 0x80BBDDF8:("EnSGoro_UpdateToHandtapAnimation",), + 0x80BBDE78:("EnSGoro_UpdateSleepyAnimation",), + 0x80BBDF28:("EnSGoro_UpdateToIdleAnimation",), + 0x80BBDFA8:("EnSGoro_UpdateCollider",), + 0x80BBE05C:("EnSGoro_UpdateEyes",), + 0x80BBE0E4:("EnSGoro_UpdateActorFocus",), + 0x80BBE144:("EnSGoro_UpdateRotationToPlayer",), + 0x80BBE374:("EnSGoro_UpdateAttentionTarget",), + 0x80BBE498:("EnSGoro_SetupAction",), + 0x80BBE73C:("EnSGoro_WinterShrineGoron_Idle",), + 0x80BBE844:("EnSGoro_WinterShrineGoron_Talk",), + 0x80BBE904:("EnSGoro_SpringShrineGoron_Idle",), + 0x80BBE9F8:("EnSGoro_SpringShrineGoron_Talk",), + 0x80BBEAD8:("EnSGoro_ShopGoron_Idle",), + 0x80BBEBF8:("EnSGoro_ShopGoron_FinishUnroll",), + 0x80BBECBC:("EnSGoro_ShopGoron_Talk",), + 0x80BBEEB4:("EnSGoro_ShopGoron_TakePayment",), + 0x80BBEF34:("EnSGoro_ShopGoron_FinishTransaction",), + 0x80BBEFA0:("EnSGoro_Sleep",), + 0x80BBF01C:("EnSGoro_SleepTalk",), 0x80BBF09C:("EnSGoro_Init",), 0x80BBF198:("EnSGoro_Destroy",), 0x80BBF1C4:("EnSGoro_Update",), - 0x80BBF298:("func_80BBF298",), - 0x80BBF3D0:("func_80BBF3D0",), - 0x80BBF3EC:("func_80BBF3EC",), - 0x80BBF5F0:("func_80BBF5F0",), - 0x80BBF6BC:("func_80BBF6BC",), + 0x80BBF298:("EnSGoro_UpdateLimb",), + 0x80BBF3D0:("EnSGoro_OverrideLimbDraw",), + 0x80BBF3EC:("EnSGoro_TransformLimbDraw",), + 0x80BBF5F0:("EnSGoro_DrawUnrolled",), + 0x80BBF6BC:("EnSGoro_DrawRolledUp",), 0x80BBF7BC:("EnSGoro_Draw",), 0x80BBFDB0:("func_80BBFDB0",), 0x80BBFE60:("func_80BBFE60",), @@ -15577,7 +15577,7 @@ 0x80BC61D0:("EnPoComposer_Draw",), 0x80BC6BF0:("EnGuruguru_Init",), 0x80BC6D28:("EnGuruguru_Destroy",), - 0x80BC6D64:("EnGuruguru_ChangeAnimation",), + 0x80BC6D64:("EnGuruguru_ChangeAnim",), 0x80BC6E00:("EnGuruguru_DoNothing",), 0x80BC6E10:("func_80BC6E10",), 0x80BC6F14:("func_80BC6F14",), @@ -15668,8 +15668,8 @@ 0x80BCED34:("func_80BCED34",), 0x80BCEDE0:("func_80BCEDE0",), 0x80BCEE98:("EffKamejimaWave_Update",), - 0x80BCEEBC:("func_80BCEEBC",), - 0x80BCEF0C:("func_80BCEF0C",), + 0x80BCEEBC:("EffKamejimaWave_SetVtxAlpha",), + 0x80BCEF0C:("EffKamejimaWave_Draw",), 0x80BCF1D0:("EnHg_Init",), 0x80BCF328:("EnHg_Destroy",), 0x80BCF354:("func_80BCF354",), @@ -15728,7 +15728,7 @@ 0x80BD1D94:("func_80BD1D94",), 0x80BD1DB8:("func_80BD1DB8",), 0x80BD1F1C:("func_80BD1F1C",), - 0x80BD1FC8:("func_80BD1FC8",), + 0x80BD1FC8:("EnZov_ValidatePictograph",), 0x80BD20B4:("EnZov_Update",), 0x80BD2380:("EnZov_OverrideLimbDraw",), 0x80BD2404:("EnZov_PostLimbDraw",), @@ -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",), @@ -15830,10 +15830,10 @@ 0x80BD6218:("BgHakaBombwall_Destroy",), 0x80BD6260:("func_80BD6260",), 0x80BD6274:("func_80BD6274",), - 0x80BD62D0:("func_80BD62D0",), - 0x80BD6314:("func_80BD6314",), - 0x80BD63B4:("func_80BD63B4",), - 0x80BD63D0:("func_80BD63D0",), + 0x80BD62D0:("BgHakaBombwall_SetupPlayCutscene",), + 0x80BD6314:("BgHakaBombwall_PlayCutscene",), + 0x80BD63B4:("BgHakaBombwall_SetupEndCutscene",), + 0x80BD63D0:("BgHakaBombwall_EndCutscene",), 0x80BD6420:("BgHakaBombwall_Update",), 0x80BD6444:("BgHakaBombwall_Draw",), 0x80BD6580:("BgHakaTomb_Init",), @@ -16059,7 +16059,7 @@ 0x80BE1550:("EnTab_Update",), 0x80BE1648:("EnTab_OverrideLimbDraw",), 0x80BE16B4:("EnTab_PostLimbDraw",), - 0x80BE1704:("EnTab_TransformDraw",), + 0x80BE1704:("EnTab_TransformLimbDraw",), 0x80BE1810:("EnTab_Draw",), 0x80BE1C80:("func_80BE1C80",), 0x80BE1CEC:("EnNimotsu_Init",), @@ -16148,7 +16148,7 @@ 0x80BE8390:("EnMuto_Draw",), 0x80BE84F0:("EnBaisen_Init",), 0x80BE8664:("EnBaisen_Destroy",), - 0x80BE8690:("EnBaisen_ChangeAnimation",), + 0x80BE8690:("EnBaisen_ChangeAnim",), 0x80BE871C:("func_80BE871C",), 0x80BE87B0:("func_80BE87B0",), 0x80BE87FC:("func_80BE87FC",), @@ -16161,7 +16161,7 @@ 0x80BE8D94:("EnBaisen_Draw",), 0x80BE8F20:("EnHeishi_Init",), 0x80BE9090:("EnHeishi_Destroy",), - 0x80BE90BC:("EnHeishi_ChangeAnimation",), + 0x80BE90BC:("EnHeishi_ChangeAnim",), 0x80BE9148:("EnHeishi_SetHeadRotation",), 0x80BE91DC:("EnHeishi_SetupIdle",), 0x80BE9214:("EnHeishi_Idle",), @@ -16170,7 +16170,7 @@ 0x80BE93D8:("EnHeishi_Draw",), 0x80BE9510:("EnDemoheishi_Init",), 0x80BE95C0:("EnDemoheishi_Destroy",), - 0x80BE95EC:("EnDemoheishi_ChangeAnimation",), + 0x80BE95EC:("EnDemoheishi_ChangeAnim",), 0x80BE9678:("EnDemoheishi_SetHeadRotation",), 0x80BE970C:("EnDemoheishi_SetupIdle",), 0x80BE975C:("EnDemoheishi_Idle",), @@ -16218,17 +16218,17 @@ 0x80BEBEB8:("func_80BEBEB8",), 0x80BEBF78:("func_80BEBF78",), 0x80BEC080:("EffLastday_Update",), - 0x80BEC0A4:("func_80BEC0A4",), + 0x80BEC0A4:("EffLastday_SetVtxAlpha",), 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",), @@ -16370,17 +16370,17 @@ 0x80BF6C94:("EnOsk_Draw",), 0x80BF74E0:("EnSth2_Init",), 0x80BF7590:("EnSth2_Destroy",), - 0x80BF75A0:("func_80BF75A0",), + 0x80BF75A0:("EnSth2_UpdateSkelAnime",), 0x80BF75CC:("EnSth2_Update",), - 0x80BF7688:("func_80BF7688",), - 0x80BF76AC:("func_80BF76AC",), - 0x80BF77AC:("func_80BF77AC",), - 0x80BF7814:("func_80BF7814",), + 0x80BF7688:("EnSth2_UpdateActionFunc",), + 0x80BF76AC:("EnSth2_OverrideLimbDraw",), + 0x80BF77AC:("EnSth2_PostLimbDraw",), + 0x80BF7814:("EnSth2_Draw",), 0x80BFA100:("EnYb_Init",), 0x80BFA2D0:("EnYb_Destroy",), 0x80BFA2FC:("func_80BFA2FC",), 0x80BFA350:("EnYb_ActorShadowFunc",), - 0x80BFA444:("EnYb_SetAnimation",), + 0x80BFA444:("EnYb_ChangeAnim",), 0x80BFA5CC:("EnYb_CanTalk",), 0x80BFA634:("EnYb_UpdateAnimation",), 0x80BFA67C:("EnYb_FinishTeachingCutscene",), @@ -16436,17 +16436,17 @@ 0x80BFD148:("EnScopecoin_Destroy",), 0x80BFD158:("EnScopecoin_Update",), 0x80BFD17C:("EnScopecoin_Draw",), - 0x80BFD2E0:("func_80BFD2E0",), - 0x80BFD30C:("func_80BFD30C",), - 0x80BFD3A4:("func_80BFD3A4",), - 0x80BFD434:("func_80BFD434",), - 0x80BFD4FC:("func_80BFD4FC",), - 0x80BFD5E4:("func_80BFD5E4",), - 0x80BFD6BC:("func_80BFD6BC",), - 0x80BFD8F0:("func_80BFD8F0",), - 0x80BFD984:("func_80BFD984",), - 0x80BFDA48:("func_80BFDA48",), - 0x80BFDAE8:("func_80BFDAE8",), + 0x80BFD2E0:("EnBjt_UpdateSkelAnime",), + 0x80BFD30C:("EnBjt_ChangeAnim",), + 0x80BFD3A4:("EnBjt_UpdateCollision",), + 0x80BFD434:("EnBjt_TakeItem",), + 0x80BFD4FC:("EnBjt_Appear",), + 0x80BFD5E4:("EnBjt_Vanish",), + 0x80BFD6BC:("EnBjt_ChooseBehaviour",), + 0x80BFD8F0:("EnBjt_CheckTalk",), + 0x80BFD984:("EnBjt_ChooseAnimation",), + 0x80BFDA48:("EnBjt_Talk",), + 0x80BFDAE8:("EnBjt_FollowSchedule",), 0x80BFDC98:("EnBjt_Init",), 0x80BFDD80:("EnBjt_Destroy",), 0x80BFDD90:("EnBjt_Update",), @@ -16610,10 +16610,10 @@ 0x80C08480:("ObjUsiyane_Draw",), 0x80C08760:("EnNnh_Init",), 0x80C087FC:("EnNnh_Destroy",), - 0x80C08828:("func_80C08828",), - 0x80C0883C:("func_80C0883C",), - 0x80C088A4:("func_80C088A4",), - 0x80C088B8:("func_80C088B8",), + 0x80C08828:("EnNnh_SetupWaitForDialogue",), + 0x80C0883C:("EnNnh_WaitForDialogue",), + 0x80C088A4:("EnNnh_SetupDialogue",), + 0x80C088B8:("EnNnh_Dialogue",), 0x80C088EC:("EnNnh_Update",), 0x80C08950:("EnNnh_Draw",), 0x80C08A80:("ObjKzsaku_Init",), @@ -16817,7 +16817,7 @@ 0x80C152F0:("ObjJgameLight_Init",), 0x80C1542C:("ObjJgameLight_Destroy",), 0x80C15474:("func_80C15474",), - 0x80C156C4:("func_80C156C4",), + 0x80C156C4:("ObjJgameLight_UpdateCollision",), 0x80C15718:("func_80C15718",), 0x80C157D4:("ObjJgameLight_Update",), 0x80C15828:("ObjJgameLight_Draw",), @@ -16856,7 +16856,7 @@ 0x80C18120:("BgLbfshot_Init",), 0x80C1817C:("BgLbfshot_Destroy",), 0x80C181B0:("BgLbfshot_Draw",), - 0x80C18240:("func_80C18240",), + 0x80C18240:("BgLastBwall_InitCollider",), 0x80C1838C:("BgLastBwall_Init",), 0x80C184B8:("BgLastBwall_Destroy",), 0x80C184EC:("func_80C184EC",), @@ -16865,7 +16865,7 @@ 0x80C1886C:("func_80C1886C",), 0x80C18884:("func_80C18884",), 0x80C188C4:("func_80C188C4",), - 0x80C18928:("func_80C18928",), + 0x80C18928:("BgLastBwall_DoNothing",), 0x80C18938:("BgLastBwall_Update",), 0x80C1895C:("BgLastBwall_Draw",), 0x80C18B90:("func_80C18B90",), @@ -16912,13 +16912,13 @@ 0x80C1A98C:("EnInvadepohDemo_Destroy",), 0x80C1A9C0:("EnInvadepohDemo_Update",), 0x80C1A9E4:("EnInvadepohDemo_Draw",), - 0x80C1ADC0:("func_80C1ADC0",), + 0x80C1ADC0:("ObjDanpeilift_UpdatePosition",), 0x80C1ADFC:("ObjDanpeilift_Init",), 0x80C1AF50:("ObjDanpeilift_Destroy",), - 0x80C1AF84:("func_80C1AF84",), - 0x80C1AF94:("func_80C1AF94",), - 0x80C1B210:("func_80C1B210",), - 0x80C1B26C:("func_80C1B26C",), + 0x80C1AF84:("ObjDanpeilift_DoNothing",), + 0x80C1AF94:("ObjDanpeilift_Move",), + 0x80C1B210:("ObjDanpeilift_Teleport",), + 0x80C1B26C:("ObjDanpeilift_Wait",), 0x80C1B2A4:("ObjDanpeilift_Update",), 0x80C1B4E4:("ObjDanpeilift_Draw",), 0x80C1B640:("EnFall2_Init",), @@ -16930,14 +16930,14 @@ 0x80C1B9D4:("func_80C1B9D4",), 0x80C1BAC8:("EnFall2_Update",), 0x80C1BAEC:("EnFall2_Draw",), - 0x80C1BD90:("func_80C1BD90",), + 0x80C1BD90:("DmAl_ChangeAnim",), 0x80C1BDD8:("func_80C1BDD8",), 0x80C1BF08:("DmAl_Init",), 0x80C1BFB8:("DmAl_Destroy",), 0x80C1BFC8:("DmAl_Update",), - 0x80C1C028:("func_80C1C028",), - 0x80C1C064:("func_80C1C064",), - 0x80C1C11C:("func_80C1C11C",), + 0x80C1C028:("DmAl_OverrideLimbDraw",), + 0x80C1C064:("DmAl_PostLimbDraw",), + 0x80C1C11C:("DmAl_TransformLimbDraw",), 0x80C1C130:("DmAl_Draw",), 0x80C1C410:("func_80C1C410",), 0x80C1C4D8:("func_80C1C4D8",), @@ -16964,8 +16964,8 @@ 0x80C1D93C:("DmAh_Init",), 0x80C1DA48:("DmAh_Destroy",), 0x80C1DA58:("DmAh_Update",), - 0x80C1DAD4:("func_80C1DAD4",), - 0x80C1DB24:("func_80C1DB24",), + 0x80C1DAD4:("DmAh_PostLimbDraw",), + 0x80C1DB24:("DmAh_TransformLimbDraw",), 0x80C1DCD8:("DmAh_Draw",), 0x80C1DED0:("func_80C1DED0",), 0x80C1DF18:("func_80C1DF18",), @@ -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",), diff --git a/tools/disasm/mips_isa.py b/tools/disasm/mips_isa.py deleted file mode 100644 index 337bbd021..000000000 --- a/tools/disasm/mips_isa.py +++ /dev/null @@ -1,776 +0,0 @@ -# Register IDs -MIPS_REG_R0 = MIPS_REG_F0 = 0 -MIPS_REG_AT = MIPS_REG_F1 = 1 -MIPS_REG_V0 = MIPS_REG_F2 = 2 -MIPS_REG_V1 = MIPS_REG_F3 = 3 -MIPS_REG_A0 = MIPS_REG_F4 = 4 -MIPS_REG_A1 = MIPS_REG_F5 = 5 -MIPS_REG_A2 = MIPS_REG_F6 = 6 -MIPS_REG_A3 = MIPS_REG_F7 = 7 -MIPS_REG_T0 = MIPS_REG_F8 = 8 -MIPS_REG_T1 = MIPS_REG_F9 = 9 -MIPS_REG_T2 = MIPS_REG_F10 = 10 -MIPS_REG_T3 = MIPS_REG_F11 = 11 -MIPS_REG_T4 = MIPS_REG_F12 = 12 -MIPS_REG_T5 = MIPS_REG_F13 = 13 -MIPS_REG_T6 = MIPS_REG_F14 = 14 -MIPS_REG_T7 = MIPS_REG_F15 = 15 -MIPS_REG_S0 = MIPS_REG_F16 = 16 -MIPS_REG_S1 = MIPS_REG_F17 = 17 -MIPS_REG_S2 = MIPS_REG_F18 = 18 -MIPS_REG_S3 = MIPS_REG_F19 = 19 -MIPS_REG_S4 = MIPS_REG_F20 = 20 -MIPS_REG_S5 = MIPS_REG_F21 = 21 -MIPS_REG_S6 = MIPS_REG_F22 = 22 -MIPS_REG_S7 = MIPS_REG_F23 = 23 -MIPS_REG_T8 = MIPS_REG_F24 = 24 -MIPS_REG_T9 = MIPS_REG_F25 = 25 -MIPS_REG_K0 = MIPS_REG_F26 = 26 -MIPS_REG_K1 = MIPS_REG_F27 = 27 -MIPS_REG_GP = MIPS_REG_F28 = 28 -MIPS_REG_SP = MIPS_REG_F29 = 29 -MIPS_REG_FP = MIPS_REG_F30 = 30 -MIPS_REG_RA = MIPS_REG_F31 = 31 - -# Instruction Unique IDs -MIPS_INS_SLL = 0 -MIPS_INS_SRL = 1 -MIPS_INS_SRA = 2 -MIPS_INS_SLLV = 3 -MIPS_INS_SRLV = 4 -MIPS_INS_SRAV = 5 -MIPS_INS_JR = 6 -MIPS_INS_JALR = 7 -MIPS_INS_SYSCALL = 8 -MIPS_INS_BREAK = 9 -MIPS_INS_SYNC = 10 -MIPS_INS_MFHI = 11 -MIPS_INS_MTHI = 12 -MIPS_INS_MFLO = 13 -MIPS_INS_MTLO = 14 -MIPS_INS_DSLLV = 15 -MIPS_INS_DSRLV = 16 -MIPS_INS_DSRAV = 17 -MIPS_INS_MULT = 18 -MIPS_INS_MULTU = 19 -MIPS_INS_DIV = 20 -MIPS_INS_DIVU = 21 -MIPS_INS_DMULT = 22 -MIPS_INS_DMULTU = 23 -MIPS_INS_DDIV = 24 -MIPS_INS_DDIVU = 25 -MIPS_INS_ADD = 26 -MIPS_INS_ADDU = 27 -MIPS_INS_SUB = 28 -MIPS_INS_SUBU = 29 -MIPS_INS_AND = 30 -MIPS_INS_OR = 31 -MIPS_INS_XOR = 32 -MIPS_INS_NOR = 33 -MIPS_INS_SLT = 34 -MIPS_INS_SLTU = 35 -MIPS_INS_DADD = 36 -MIPS_INS_DADDU = 37 -MIPS_INS_DSUB = 38 -MIPS_INS_DSUBU = 39 -MIPS_INS_TGE = 40 -MIPS_INS_TGEU = 41 -MIPS_INS_TLT = 42 -MIPS_INS_TLTU = 43 -MIPS_INS_TEQ = 44 -MIPS_INS_TNE = 45 -MIPS_INS_DSLL = 46 -MIPS_INS_DSRL = 47 -MIPS_INS_DSRA = 48 -MIPS_INS_DSLL32 = 49 -MIPS_INS_DSRL32 = 50 -MIPS_INS_DSRA32 = 51 -MIPS_INS_BLTZ = 52 -MIPS_INS_BGEZ = 53 -MIPS_INS_BLTZL = 54 -MIPS_INS_BGEZL = 55 -MIPS_INS_TGEI = 56 -MIPS_INS_TGEIU = 57 -MIPS_INS_TLTI = 58 -MIPS_INS_TLTIU = 59 -MIPS_INS_TEQI = 60 -MIPS_INS_TNEI = 61 -MIPS_INS_BLTZAL = 62 -MIPS_INS_BGEZAL = 63 -MIPS_INS_BLTZALL = 64 -MIPS_INS_BGEZALL = 65 -MIPS_INS_J = 66 -MIPS_INS_JAL = 67 -MIPS_INS_BEQ = 68 -MIPS_INS_BNE = 69 -MIPS_INS_BLEZ = 70 -MIPS_INS_BGTZ = 71 -MIPS_INS_ADDI = 72 -MIPS_INS_ADDIU = 73 -MIPS_INS_SLTI = 74 -MIPS_INS_SLTIU = 75 -MIPS_INS_ANDI = 76 -MIPS_INS_ORI = 77 -MIPS_INS_XORI = 78 -MIPS_INS_LUI = 79 -MIPS_INS_MFC0 = 80 -MIPS_INS_MTC0 = 81 -MIPS_INS_TLBR = 82 -MIPS_INS_TLBWI = 83 -MIPS_INS_TLBWR = 84 -MIPS_INS_TLBP = 85 -MIPS_INS_ERET = 86 -MIPS_INS_MFC1 = 87 -MIPS_INS_DMFC1 = 88 -MIPS_INS_CFC1 = 89 -MIPS_INS_MTC1 = 90 -MIPS_INS_DMTC1 = 91 -MIPS_INS_CTC1 = 92 -MIPS_INS_BC1F = 93 -MIPS_INS_BC1T = 94 -MIPS_INS_BC1FL = 95 -MIPS_INS_BC1TL = 96 -MIPS_INS_ADD_S = 97 -MIPS_INS_SUB_S = 98 -MIPS_INS_MUL_S = 99 -MIPS_INS_DIV_S = 100 -MIPS_INS_SQRT_S = 101 -MIPS_INS_ABS_S = 102 -MIPS_INS_MOV_S = 103 -MIPS_INS_NEG_S = 104 -MIPS_INS_ROUND_L_S = 105 -MIPS_INS_TRUNC_L_S = 106 -MIPS_INS_CEIL_L_S = 107 -MIPS_INS_FLOOR_L_S = 108 -MIPS_INS_ROUND_W_S = 109 -MIPS_INS_TRUNC_W_S = 110 -MIPS_INS_CEIL_W_S = 111 -MIPS_INS_FLOOR_W_S = 112 -MIPS_INS_CVT_D_S = 113 -MIPS_INS_CVT_W_S = 114 -MIPS_INS_CVT_L_S = 115 -MIPS_INS_C_F_S = 116 -MIPS_INS_C_UN_S = 117 -MIPS_INS_C_EQ_S = 118 -MIPS_INS_C_UEQ_S = 119 -MIPS_INS_C_OLT_S = 120 -MIPS_INS_C_ULT_S = 121 -MIPS_INS_C_OLE_S = 122 -MIPS_INS_C_ULE_S = 123 -MIPS_INS_C_SF_S = 124 -MIPS_INS_C_NGLE_S = 125 -MIPS_INS_C_SEQ_S = 126 -MIPS_INS_C_NGL_S = 127 -MIPS_INS_C_LT_S = 128 -MIPS_INS_C_NGE_S = 129 -MIPS_INS_C_LE_S = 130 -MIPS_INS_C_NGT_S = 131 -MIPS_INS_ADD_D = 132 -MIPS_INS_SUB_D = 133 -MIPS_INS_MUL_D = 134 -MIPS_INS_DIV_D = 135 -MIPS_INS_SQRT_D = 136 -MIPS_INS_ABS_D = 137 -MIPS_INS_MOV_D = 138 -MIPS_INS_NEG_D = 139 -MIPS_INS_ROUND_L_D = 140 -MIPS_INS_TRUNC_L_D = 141 -MIPS_INS_CEIL_L_D = 142 -MIPS_INS_FLOOR_L_D = 143 -MIPS_INS_ROUND_W_D = 144 -MIPS_INS_TRUNC_W_D = 145 -MIPS_INS_CEIL_W_D = 146 -MIPS_INS_FLOOR_W_D = 147 -MIPS_INS_CVT_S_D = 148 -MIPS_INS_CVT_W_D = 149 -MIPS_INS_CVT_L_D = 150 -MIPS_INS_C_F_D = 151 -MIPS_INS_C_UN_D = 152 -MIPS_INS_C_EQ_D = 153 -MIPS_INS_C_UEQ_D = 154 -MIPS_INS_C_OLT_D = 155 -MIPS_INS_C_ULT_D = 156 -MIPS_INS_C_OLE_D = 157 -MIPS_INS_C_ULE_D = 158 -MIPS_INS_C_SF_D = 159 -MIPS_INS_C_NGLE_D = 160 -MIPS_INS_C_SEQ_D = 161 -MIPS_INS_C_NGL_D = 162 -MIPS_INS_C_LT_D = 163 -MIPS_INS_C_NGE_D = 164 -MIPS_INS_C_LE_D = 165 -MIPS_INS_C_NGT_D = 166 -MIPS_INS_CVT_S_W = 167 -MIPS_INS_CVT_D_W = 168 -MIPS_INS_CVT_S_L = 169 -MIPS_INS_CVT_D_L = 170 -MIPS_INS_BEQL = 171 -MIPS_INS_BNEL = 172 -MIPS_INS_BLEZL = 173 -MIPS_INS_BGTZL = 174 -MIPS_INS_DADDI = 175 -MIPS_INS_DADDIU = 176 -MIPS_INS_LDL = 177 -MIPS_INS_LDR = 178 -MIPS_INS_LB = 179 -MIPS_INS_LH = 180 -MIPS_INS_LWL = 181 -MIPS_INS_LW = 182 -MIPS_INS_LBU = 183 -MIPS_INS_LHU = 184 -MIPS_INS_LWR = 185 -MIPS_INS_LWU = 186 -MIPS_INS_SB = 187 -MIPS_INS_SH = 188 -MIPS_INS_SWL = 189 -MIPS_INS_SW = 190 -MIPS_INS_SDL = 191 -MIPS_INS_SDR = 192 -MIPS_INS_SWR = 193 -MIPS_INS_CACHE = 194 -MIPS_INS_LL = 195 -MIPS_INS_LWC1 = 196 -MIPS_INS_LLD = 197 -MIPS_INS_LDC1 = 198 -#MIPS_INS_INVALID = 199 -MIPS_INS_LD = 200 -MIPS_INS_SC = 201 -MIPS_INS_SWC1 = 202 -MIPS_INS_SCD = 203 -MIPS_INS_SDC1 = 204 -MIPS_INS_SD = 206 - -# Pseudo-Instruction Unique IDs -MIPS_INS_BEQZ = 207 -MIPS_INS_BNEZ = 208 -MIPS_INS_B = 209 -MIPS_INS_NOP = 210 -MIPS_INS_MOVE = 211 -MIPS_INS_NEGU = 212 -MIPS_INS_NOT = 213 - -# Invalid Instruction Unique ID -MIPS_INS_INVALID = -1 - -# Op IDs -# MIPS_OP_RS = 0 -# MIPS_OP_RT = 0 -# MIPS_OP_RD = 0 -# MIPS_OP_IMM = 0 - -# Register Names - -mips_gpr_names = [ - "$zero", - "$at", - "$v0", "$v1", - "$a0", "$a1", "$a2", "$a3", - "$t0", "$t1", "$t2", "$t3", "$t4", "$t5", "$t6", "$t7", - "$s0", "$s1", "$s2", "$s3", "$s4", "$s5", "$s6", "$s7", - "$t8", "$t9", - "$k0", "$k1", - "$gp", - "$sp", - "$fp", - "$ra", -] - -mips_cop0_names = [ - "Index" , "Random" , "EntryLo0" , "EntryLo1" , - "Context" , "PageMask" , "Wired" , "Reserved07", - "BadVaddr" , "Count" , "EntryHi" , "Compare" , - "Status" , "Cause" , "EPC" , "PRevID" , - "Config" , "LLAddr" , "WatchLo" , "WatchHi" , - "XContext" , "Reserved21", "Reserved22", "Reserved23", - "Reserved24", "Reserved25", "PErr" , "CacheErr" , - "TagLo" , "TagHi" , "ErrorEPC" , "Reserved31", -] - -numeric_fpr_names = [ - "$f0", "$f1", "$f2", "$f3", - "$f4", "$f5", "$f6", "$f7", "$f8", "$f9", "$f10", "$f11", - "$f12", "$f13", "$f14", "$f15", - "$f16", "$f17", "$f18", "$f19", - "$f20", "$f21", "$f22", "$f23", "$f24", "$f25", "$f26", "$f27", "$f28", "$f29", "$f30", - "$31", # Floating-point control/status register -] - -o32_fpr_names = [ - "$fv0", "$fv0f", "$fv1", "$fv1f", - "$ft0", "$ft0f", "$ft1", "$ft1f", "$ft2", "$ft2f", "$ft3", "$ft3f", - "$fa0", "$fa0f", "$fa1", "$fa1f", - "$ft4", "$ft4f", "$ft5", "$ft5f", - "$fs0", "$fs0f", "$fs1", "$fs1f", "$fs2", "$fs2f", "$fs3", "$fs3f", "$fs4", "$fs4f", "$fs5", - "$31", # Floating-point control/status register -] - -mips_fpr_names = numeric_fpr_names - -# Instruction field fetching - -def sign_extend_16(value): - return (value & 0x7FFF) - (value & 0x8000) - -def mask_shift(v, s, w): - return (v >> s) & ((1 << w) - 1) - -mips_get_field = lambda raw,vaddr : mask_shift(raw, 26, 6) -mips_get_special = lambda raw,vaddr : mask_shift(raw, 0, 6) -mips_get_cop0 = lambda raw,vaddr : mask_shift(raw, 21, 5) -mips_get_cop1 = lambda raw,vaddr : mask_shift(raw, 21, 5) -mips_get_regimm = lambda raw,vaddr : mask_shift(raw, 16, 5) -mips_get_tlb = lambda raw,vaddr : mask_shift(raw, 0, 5) -mips_get_function = lambda raw,vaddr : mask_shift(raw, 0, 6) - -mips_get_cond = lambda raw,vaddr : mask_shift(raw, 0, 4) -mips_get_fc = lambda raw,vaddr : mask_shift(raw, 2, 2) -mips_get_fd = lambda raw,vaddr : mask_shift(raw, 6, 5) -mips_get_fs = lambda raw,vaddr : mask_shift(raw, 11, 5) -mips_get_ft = lambda raw,vaddr : mask_shift(raw, 16, 5) -mips_get_fmt = lambda raw,vaddr : mask_shift(raw, 21, 5) -mips_get_ndtf = lambda raw,vaddr : mask_shift(raw, 16, 2) - -mips_get_target = lambda raw,vaddr : (0x80000000 | (mask_shift(raw, 0, 26) << 2)) -mips_get_offset = lambda raw,vaddr : vaddr + 4 + sign_extend_16(mask_shift(raw, 0, 16)) * 4 -mips_get_imm = lambda raw,vaddr : mask_shift(raw, 0, 16) - -mips_get_base = lambda raw,vaddr : mask_shift(raw, 21, 5) - -mips_get_cd = lambda raw,vaddr : mask_shift(raw, 11, 5) - -mips_get_code = lambda raw,vaddr : (mask_shift(raw, 6, 20) << 6) >> 16 -mips_get_op = lambda raw,vaddr : mask_shift(raw, 16, 5) - -mips_get_sa = lambda raw,vaddr : mask_shift(raw, 6, 5) - -mips_get_rd = lambda raw,vaddr : mask_shift(raw, 11, 5) -mips_get_rs = lambda raw,vaddr : mask_shift(raw, 21, 5) -mips_get_rt = lambda raw,vaddr : mask_shift(raw, 16, 5) - -# Formatting - -class MipsInsn: - - def __init__(self, raw, vaddr, values): - self.raw = raw - self.vaddr = vaddr - - if values is None: - values = MIPS_INS_INVALID, f"/* Invalid Instruction: 0x{raw:08X} */", () - - self.id, self.mnemonic, self.fields = values - - self.code = self.sa = self.op = self.cd = self.rd = self.rs = self.rt = self.fd = self.fs = self.ft = self.imm = self.offset = self.base = self.target = None - - for field in self.fields: - self.value_forname(field) - - self.op_str = self.format_insn() - - if self.id == MIPS_INS_SLL and self.rd == MIPS_REG_R0 and self.rt == MIPS_REG_R0 and self.sa == 0: - self.id = MIPS_INS_NOP - self.mnemonic = "nop" - self.fields = () - elif self.id == MIPS_INS_BEQ and self.rs == MIPS_REG_R0 and self.rt == MIPS_REG_R0: - self.id = MIPS_INS_B - self.mnemonic = "b" - self.fields = ("offset",) - elif self.id == MIPS_INS_OR and self.rt == MIPS_REG_R0: - self.id = MIPS_INS_MOVE - self.mnemonic = "move" - self.fields = ("rd","rs") - elif self.id == MIPS_INS_BEQ and self.rt == MIPS_REG_R0: - self.id = MIPS_INS_BEQZ - self.mnemonic = "beqz" - self.fields = ("rs","offset") - elif self.id == MIPS_INS_BNE and self.rt == MIPS_REG_R0: - self.id = MIPS_INS_BNEZ - self.mnemonic = "bnez" - self.fields = ("rs","offset") - elif self.id == MIPS_INS_SUBU and self.rs == MIPS_REG_R0: - self.id = MIPS_INS_NEGU - self.mnemonic = "negu" - self.fields = ("rd","rt") - elif self.id == MIPS_INS_NOR and self.rt == MIPS_REG_R0: - self.id = MIPS_INS_NOT - self.mnemonic = "not" - self.fields = ("rd","rs") - - self.op_str = self.format_insn() - - def value_forname(self, name): - field_setters = { - 'code' : self.set_code, - 'sa' : self.set_sa, - 'op' : self.set_op, - 'cd' : self.set_cd, - 'rd' : self.set_rd, - 'rs' : self.set_rs, - 'rt' : self.set_rt, - 'fd' : self.set_fd, - 'fs' : self.set_fs, - 'ft' : self.set_ft, - 'imm' : self.set_imm, - 'offset' : self.set_offset, - 'base' : self.set_base, - 'offset(base)' : self.set_offset_base, - 'target' : self.set_target, - } - - return field_setters[name]() - - def format_field(self, field): - def format_hex(v, signed, zeros, no_zero): - if abs(v) < 10: - if v == 0 and no_zero: - return "" - return f"{v}" - elif not signed: - return f"0x{v:{f'0{zeros}' if zeros > 0 else ''}x}" - else: - return f"{v:#x}" - - format_handlers = { - 'code' : (lambda insn : f'{insn.code}' if insn.code != 0 else ''), - 'cd' : (lambda insn : mips_cop0_names[insn.cd]), - 'rd' : (lambda insn : mips_gpr_names[insn.rd]), - 'rs' : (lambda insn : mips_gpr_names[insn.rs]), - 'rt' : (lambda insn : mips_gpr_names[insn.rt]), - 'fd' : (lambda insn : mips_fpr_names[insn.fd]), - 'fs' : (lambda insn : mips_fpr_names[insn.fs]), - 'ft' : (lambda insn : mips_fpr_names[insn.ft]), - 'sa' : (lambda insn : format_hex(insn.sa, True, 0, False)), - 'op' : (lambda insn : format_hex(insn.op, False, 0, False)), - 'imm' : (lambda insn : format_hex(insn.imm, True, 0, False)), - 'offset(base)' : (lambda insn : f'{format_hex(insn.imm, True, 0, True)}({mips_gpr_names[insn.base]})'), - 'offset' : (lambda insn : f'{format_hex(insn.offset, True, 0, False)}'), - 'target' : (lambda insn : f'{format_hex(insn.target, False, 0, False)}') - } - - return format_handlers[field](self) - - def format_insn(self): - return ", ".join([self.format_field(field) for field in self.fields]) - - def __str__(self): - return f"{self.mnemonic:12}{self.op_str}" - - def set_code(self): - self.code = mips_get_code(self.raw, self.vaddr) - return self.code - - def set_sa(self): - self.sa = mips_get_sa(self.raw, self.vaddr) - return self.sa - - def set_op(self): - self.op = mips_get_op(self.raw, self.vaddr) - return self.op - - def set_cd(self): - self.cd = mips_get_cd(self.raw, self.vaddr) - return self.cd - - def set_rd(self): - self.rd = mips_get_rd(self.raw, self.vaddr) - return self.rd - - def set_rs(self): - self.rs = mips_get_rs(self.raw, self.vaddr) - return self.rs - - def set_rt(self): - self.rt = mips_get_rt(self.raw, self.vaddr) - return self.rt - - def set_fd(self): - self.fd = mips_get_fd(self.raw, self.vaddr) - return self.fd - - def set_fs(self): - self.fs = mips_get_fs(self.raw, self.vaddr) - return self.fs - - def set_ft(self): - self.ft = mips_get_ft(self.raw, self.vaddr) - return self.ft - - def set_imm(self): - do_sign_extend = [ MIPS_INS_ADDIU, MIPS_INS_SLTI, MIPS_INS_ADDI, MIPS_INS_DADDIU, - MIPS_INS_LB, MIPS_INS_LBU, - MIPS_INS_LH, MIPS_INS_LHU, - MIPS_INS_LW, MIPS_INS_LWL, MIPS_INS_LWR, MIPS_INS_LWU, - MIPS_INS_LWC1, - MIPS_INS_LD, MIPS_INS_LDL, MIPS_INS_LDR, - MIPS_INS_LDC1, - MIPS_INS_LL, MIPS_INS_LLD, - MIPS_INS_SB, - MIPS_INS_SH, - MIPS_INS_SW, MIPS_INS_SWL, MIPS_INS_SWR, - MIPS_INS_SWC1, - MIPS_INS_SD, MIPS_INS_SDL, MIPS_INS_SDR, - MIPS_INS_SDC1, - MIPS_INS_SC, MIPS_INS_SCD, - ] - - self.imm = mips_get_imm(self.raw, self.vaddr) - if self.id in do_sign_extend: # sign extended immediates - self.imm = sign_extend_16(self.imm) - return self.imm - - def set_offset(self): - self.offset = mips_get_offset(self.raw, self.vaddr) - return self.offset - - def set_base(self): - self.base = mips_get_base(self.raw, self.vaddr) - return self.base - - def set_offset_base(self): - self.set_imm() - self.set_base() - return self.imm, self.base - - def set_target(self): - self.target = mips_get_target(self.raw, self.vaddr) - return self.target - -def fetch_insn(raw, vaddr, insn_set, func): - insn = insn_set.get(func(raw, vaddr), None) # default none for invalid instruction encoding - - if insn is not None and type(insn[1]) == dict: # extra decoding required - insn = fetch_insn(raw, vaddr, insn[1], insn[0]) - return insn - -def decode_insn(raw, vaddr): - return MipsInsn(raw, vaddr, fetch_insn(raw, vaddr, mips_insns, mips_get_field)) - -mips_insns = { - 0b000000: (mips_get_special, { - 0b000000: (MIPS_INS_SLL, "sll", ("rd","rt","sa")), - 0b000010: (MIPS_INS_SRL, "srl", ("rd","rt","sa")), - 0b000011: (MIPS_INS_SRA, "sra", ("rd","rt","sa")), - 0b000100: (MIPS_INS_SLLV, "sllv", ("rd","rt","rs")), - 0b000110: (MIPS_INS_SRLV, "srlv", ("rd","rt","rs")), - 0b000111: (MIPS_INS_SRAV, "srav", ("rd","rt","rs")), - 0b001000: (MIPS_INS_JR, "jr", ("rs", )), - 0b001001: (MIPS_INS_JALR, "jalr", ("rs", )), # technically also rd but it's always $ra - 0b001100: (MIPS_INS_SYSCALL, "syscall", ( )), - 0b001101: (MIPS_INS_BREAK, "break", ("code", )), - 0b001111: (MIPS_INS_SYNC, "sync", ( )), - 0b010000: (MIPS_INS_MFHI, "mfhi", ("rd", )), - 0b010001: (MIPS_INS_MTHI, "mthi", ("rs", )), - 0b010010: (MIPS_INS_MFLO, "mflo", ("rd", )), - 0b010011: (MIPS_INS_MTLO, "mtlo", ("rs", )), - 0b010100: (MIPS_INS_DSLLV, "dsllv", ("rd","rt","rs")), - 0b010110: (MIPS_INS_DSRLV, "dsrlv", ("rd","rt","rs")), - 0b010111: (MIPS_INS_DSRAV, "dsrav", ("rd","rt","rs")), - 0b011000: (MIPS_INS_MULT, "mult", ("rs","rt" )), - 0b011001: (MIPS_INS_MULTU, "multu", ("rs","rt" )), - 0b011010: (MIPS_INS_DIV, "div", ("rd","rs","rt")), # for some reason gas hates div instructions - 0b011011: (MIPS_INS_DIVU, "divu", ("rd","rs","rt")), # with the correct number of operands - 0b011100: (MIPS_INS_DMULT, "dmult", ("rs","rt" )), - 0b011101: (MIPS_INS_DMULTU, "dmultu", ("rs","rt" )), - 0b011110: (MIPS_INS_DDIV, "ddiv", ("rd","rs","rt")), - 0b011111: (MIPS_INS_DDIVU, "ddivu", ("rd","rs","rt")), - 0b100000: (MIPS_INS_ADD, "add", ("rd","rs","rt")), - 0b100001: (MIPS_INS_ADDU, "addu", ("rd","rs","rt")), - 0b100010: (MIPS_INS_SUB, "sub", ("rd","rs","rt")), - 0b100011: (MIPS_INS_SUBU, "subu", ("rd","rs","rt")), - 0b100100: (MIPS_INS_AND, "and", ("rd","rs","rt")), - 0b100101: (MIPS_INS_OR, "or", ("rd","rs","rt")), - 0b100110: (MIPS_INS_XOR, "xor", ("rd","rs","rt")), - 0b100111: (MIPS_INS_NOR, "nor", ("rd","rs","rt")), - 0b101010: (MIPS_INS_SLT, "slt", ("rd","rs","rt")), - 0b101011: (MIPS_INS_SLTU, "sltu", ("rd","rs","rt")), - 0b101100: (MIPS_INS_DADD, "dadd", ("rd","rs","rt")), - 0b101101: (MIPS_INS_DADDU, "daddu", ("rd","rs","rt")), - 0b101110: (MIPS_INS_DSUB, "dsub", ("rd","rs","rt")), - 0b101111: (MIPS_INS_DSUBU, "dsubu", ("rd","rs","rt")), - 0b110000: (MIPS_INS_TGE, "tge", ("rs","rt" )), - 0b110001: (MIPS_INS_TGEU, "tgeu", ("rs","rt" )), - 0b110010: (MIPS_INS_TLT, "tlt", ("rs","rt" )), - 0b110011: (MIPS_INS_TLTU, "tltu", ("rs","rt" )), - 0b110100: (MIPS_INS_TEQ, "teq", ("rs","rt" )), - 0b110110: (MIPS_INS_TNE, "tne", ("rs","rt" )), - 0b111000: (MIPS_INS_DSLL, "dsll", ("rd","rt","sa")), - 0b111010: (MIPS_INS_DSRL, "dsrl", ("rd","rt","sa")), - 0b111011: (MIPS_INS_DSRA, "dsra", ("rd","rt","sa")), - 0b111100: (MIPS_INS_DSLL32, "dsll32", ("rd","rt","sa")), - 0b111110: (MIPS_INS_DSRL32, "dsrl32", ("rd","rt","sa")), - 0b111111: (MIPS_INS_DSRA32, "dsra32", ("rd","rt","sa")), - }), - 0b000001: (mips_get_regimm, { - 0b00000: (MIPS_INS_BLTZ, "bltz", ("rs","offset")), - 0b00001: (MIPS_INS_BGEZ, "bgez", ("rs","offset")), - 0b00010: (MIPS_INS_BLTZL, "bltzl", ("rs","offset")), - 0b00011: (MIPS_INS_BGEZL, "bgezl", ("rs","offset")), - 0b01000: (MIPS_INS_TGEI, "tgei", ("rs","imm" )), - 0b01001: (MIPS_INS_TGEIU, "tgeiu", ("rs","imm" )), - 0b01010: (MIPS_INS_TLTI, "tlti", ("rs","imm" )), - 0b01011: (MIPS_INS_TLTIU, "tltiu", ("rs","imm" )), - 0b01100: (MIPS_INS_TEQI, "teqi", ("rs","imm" )), - 0b01110: (MIPS_INS_TNEI, "tnei", ("rs","imm" )), - 0b10000: (MIPS_INS_BLTZAL, "bltzal", ("rs","offset")), - 0b10001: (MIPS_INS_BGEZAL, "bgezal", ("rs","offset")), - 0b10010: (MIPS_INS_BLTZALL, "bltzall", ("rs","offset")), - 0b10011: (MIPS_INS_BGEZALL, "bgezall", ("rs","offset")), - }), - 0b000010: (MIPS_INS_J, "j", ("target", )), - 0b000011: (MIPS_INS_JAL, "jal", ("target", )), - 0b000100: (MIPS_INS_BEQ, "beq", ("rs","rt","offset")), - 0b000101: (MIPS_INS_BNE, "bne", ("rs","rt","offset")), - 0b000110: (MIPS_INS_BLEZ, "blez", ("rs","offset" )), - 0b000111: (MIPS_INS_BGTZ, "bgtz", ("rs","offset" )), - 0b001000: (MIPS_INS_ADDI, "addi", ("rt","rs","imm" )), - 0b001001: (MIPS_INS_ADDIU, "addiu", ("rt","rs","imm" )), - 0b001010: (MIPS_INS_SLTI, "slti", ("rt","rs","imm" )), - 0b001011: (MIPS_INS_SLTIU, "sltiu", ("rt","rs","imm" )), - 0b001100: (MIPS_INS_ANDI, "andi", ("rt","rs","imm" )), - 0b001101: (MIPS_INS_ORI, "ori", ("rt","rs","imm" )), - 0b001110: (MIPS_INS_XORI, "xori", ("rt","rs","imm" )), - 0b001111: (MIPS_INS_LUI, "lui", ("rt","imm" )), - 0b010000: (mips_get_cop0, { - 0b00000: (MIPS_INS_MFC0, "mfc0", ("rt","cd")), - 0b00100: (MIPS_INS_MTC0, "mtc0", ("rt","cd")), - 0b10000: (mips_get_tlb, { - 0b000001: (MIPS_INS_TLBR, "tlbr", ()), - 0b000010: (MIPS_INS_TLBWI, "tlbwi", ()), - 0b000110: (MIPS_INS_TLBWR, "tlbwr", ()), - 0b001000: (MIPS_INS_TLBP, "tlbp", ()), - 0b011000: (MIPS_INS_ERET, "eret", ()), - }), - }), - 0b010001: (mips_get_cop1, { - 0b00000: (MIPS_INS_MFC1, "mfc1", ("rt","fs")), - 0b00001: (MIPS_INS_DMFC1, "dmfc1", ("rt","fs")), - 0b00010: (MIPS_INS_CFC1, "cfc1", ("rt","fs")), - 0b00100: (MIPS_INS_MTC1, "mtc1", ("rt","fs")), - 0b00101: (MIPS_INS_DMTC1, "dmtc1", ("rt","fs")), - 0b00110: (MIPS_INS_CTC1, "ctc1", ("rt","fs")), - 0b01000: (mips_get_ndtf, { - 0b00: (MIPS_INS_BC1F, "bc1f", ("offset",)), - 0b01: (MIPS_INS_BC1T, "bc1t", ("offset",)), - 0b10: (MIPS_INS_BC1FL, "bc1fl", ("offset",)), - 0b11: (MIPS_INS_BC1TL, "bc1tl", ("offset",)), - }), - 0b010000: (mips_get_function, { - 0b000000: (MIPS_INS_ADD_S, "add.s", ("fd","fs","ft")), - 0b000001: (MIPS_INS_SUB_S, "sub.s", ("fd","fs","ft")), - 0b000010: (MIPS_INS_MUL_S, "mul.s", ("fd","fs","ft")), - 0b000011: (MIPS_INS_DIV_S, "div.s", ("fd","fs","ft")), - 0b000100: (MIPS_INS_SQRT_S, "sqrt.s", ("fd","fs" )), - 0b000101: (MIPS_INS_ABS_S, "abs.s", ("fd","fs" )), - 0b000110: (MIPS_INS_MOV_S, "mov.s", ("fd","fs" )), - 0b000111: (MIPS_INS_NEG_S, "neg.s", ("fd","fs" )), - 0b001000: (MIPS_INS_ROUND_L_S, "round.l.s", ("fd","fs" )), - 0b001001: (MIPS_INS_TRUNC_L_S, "trunc.l.s", ("fd","fs" )), - 0b001010: (MIPS_INS_CEIL_L_S, "ceil.l.s", ("fd","fs" )), - 0b001011: (MIPS_INS_FLOOR_L_S, "floor.l.s", ("fd","fs" )), - 0b001100: (MIPS_INS_ROUND_W_S, "round.w.s", ("fd","fs" )), - 0b001101: (MIPS_INS_TRUNC_W_S, "trunc.w.s", ("fd","fs" )), - 0b001110: (MIPS_INS_CEIL_W_S, "ceil.w.s", ("fd","fs" )), - 0b001111: (MIPS_INS_FLOOR_W_S, "floor.w.s", ("fd","fs" )), - 0b100001: (MIPS_INS_CVT_D_S, "cvt.d.s", ("fd","fs" )), - 0b100100: (MIPS_INS_CVT_W_S, "cvt.w.s", ("fd","fs" )), - 0b100101: (MIPS_INS_CVT_L_S, "cvt.l.s", ("fd","fs" )), - 0b110000: (MIPS_INS_C_F_S, "c.f.s", ("fs","ft" )), - 0b110001: (MIPS_INS_C_UN_S, "c.un.s", ("fs","ft" )), - 0b110010: (MIPS_INS_C_EQ_S, "c.eq.s", ("fs","ft" )), - 0b110011: (MIPS_INS_C_UEQ_S, "c.ueq.s", ("fs","ft" )), - 0b110100: (MIPS_INS_C_OLT_S, "c.olt.s", ("fs","ft" )), - 0b110101: (MIPS_INS_C_ULT_S, "c.ult.s", ("fs","ft" )), - 0b110110: (MIPS_INS_C_OLE_S, "c.ole.s", ("fs","ft" )), - 0b110111: (MIPS_INS_C_ULE_S, "c.ule.s", ("fs","ft" )), - 0b111000: (MIPS_INS_C_SF_S, "c.sf.s", ("fs","ft" )), - 0b111001: (MIPS_INS_C_NGLE_S, "c.ngle.s", ("fs","ft" )), - 0b111010: (MIPS_INS_C_SEQ_S, "c.seq.s", ("fs","ft" )), - 0b111011: (MIPS_INS_C_NGL_S, "c.ngl.s", ("fs","ft" )), - 0b111100: (MIPS_INS_C_LT_S, "c.lt.s", ("fs","ft" )), - 0b111101: (MIPS_INS_C_NGE_S, "c.nge.s", ("fs","ft" )), - 0b111110: (MIPS_INS_C_LE_S, "c.le.s", ("fs","ft" )), - 0b111111: (MIPS_INS_C_NGT_S, "c.ngt.s", ("fs","ft" )), - }), - 0b010001: (mips_get_function, { - 0b000000: (MIPS_INS_ADD_D, "add.d", ("fd","fs","ft")), - 0b000001: (MIPS_INS_SUB_D, "sub.d", ("fd","fs","ft")), - 0b000010: (MIPS_INS_MUL_D, "mul.d", ("fd","fs","ft")), - 0b000011: (MIPS_INS_DIV_D, "div.d", ("fd","fs","ft")), - 0b000100: (MIPS_INS_SQRT_D, "sqrt.d", ("fd","fs" )), - 0b000101: (MIPS_INS_ABS_D, "abs.d", ("fd","fs" )), - 0b000110: (MIPS_INS_MOV_D, "mov.d", ("fd","fs" )), - 0b000111: (MIPS_INS_NEG_D, "neg.d", ("fd","fs" )), - 0b001000: (MIPS_INS_ROUND_L_D, "round.l.d", ("fd","fs" )), - 0b001001: (MIPS_INS_TRUNC_L_D, "trunc.l.d", ("fd","fs" )), - 0b001010: (MIPS_INS_CEIL_L_D, "ceil.l.d", ("fd","fs" )), - 0b001011: (MIPS_INS_FLOOR_L_D, "floor.l.d", ("fd","fs" )), - 0b001100: (MIPS_INS_ROUND_W_D, "round.w.d", ("fd","fs" )), - 0b001101: (MIPS_INS_TRUNC_W_D, "trunc.w.d", ("fd","fs" )), - 0b001110: (MIPS_INS_CEIL_W_D, "ceil.w.d", ("fd","fs" )), - 0b001111: (MIPS_INS_FLOOR_W_D, "floor.w.d", ("fd","fs" )), - 0b100000: (MIPS_INS_CVT_S_D, "cvt.s.d", ("fd","fs" )), - 0b100100: (MIPS_INS_CVT_W_D, "cvt.w.d", ("fd","fs" )), - 0b100101: (MIPS_INS_CVT_L_D, "cvt.l.d", ("fd","fs" )), - 0b110000: (MIPS_INS_C_F_D, "c.f.d", ("fs","ft" )), - 0b110001: (MIPS_INS_C_UN_D, "c.un.d", ("fs","ft" )), - 0b110010: (MIPS_INS_C_EQ_D, "c.eq.d", ("fs","ft" )), - 0b110011: (MIPS_INS_C_UEQ_D, "c.ueq.d", ("fs","ft" )), - 0b110100: (MIPS_INS_C_OLT_D, "c.olt.d", ("fs","ft" )), - 0b110101: (MIPS_INS_C_ULT_D, "c.ult.d", ("fs","ft" )), - 0b110110: (MIPS_INS_C_OLE_D, "c.ole.d", ("fs","ft" )), - 0b110111: (MIPS_INS_C_ULE_D, "c.ule.d", ("fs","ft" )), - 0b111000: (MIPS_INS_C_SF_D, "c.sf.d", ("fs","ft" )), - 0b111001: (MIPS_INS_C_NGLE_D, "c.ngle.d", ("fs","ft" )), - 0b111010: (MIPS_INS_C_SEQ_D, "c.seq.d", ("fs","ft" )), - 0b111011: (MIPS_INS_C_NGL_D, "c.ngl.d", ("fs","ft" )), - 0b111100: (MIPS_INS_C_LT_D, "c.lt.d", ("fs","ft" )), - 0b111101: (MIPS_INS_C_NGE_D, "c.nge.d", ("fs","ft" )), - 0b111110: (MIPS_INS_C_LE_D, "c.le.d", ("fs","ft" )), - 0b111111: (MIPS_INS_C_NGT_D, "c.ngt.d", ("fs","ft" )), - }), - 0b010100: (mips_get_function, { - 0b100000: (MIPS_INS_CVT_S_W, "cvt.s.w", ("fd","fs")), - 0b100001: (MIPS_INS_CVT_D_W, "cvt.d.w", ("fd","fs")), - }), - 0b010101: (mips_get_function, { - 0b100000: (MIPS_INS_CVT_S_L, "cvt.s.l", ("fd","fs")), - 0b100001: (MIPS_INS_CVT_D_L, "cvt.d.l", ("fd","fs")), - }), - }), - 0b010100: (MIPS_INS_BEQL, "beql", ("rs","rt","offset" )), - 0b010101: (MIPS_INS_BNEL, "bnel", ("rs","rt","offset" )), - 0b010110: (MIPS_INS_BLEZL, "blezl", ("rs","offset" )), - 0b010111: (MIPS_INS_BGTZL, "bgtzl", ("rs","offset" )), - 0b011000: (MIPS_INS_DADDI, "daddi", ("rt","rs","imm" )), - 0b011001: (MIPS_INS_DADDIU, "daddiu", ("rt","rs","imm" )), - 0b011010: (MIPS_INS_LDL, "ldl", ("rt","offset(base)")), - 0b011011: (MIPS_INS_LDR, "ldr", ("rt","offset(base)")), - 0b100000: (MIPS_INS_LB, "lb", ("rt","offset(base)")), - 0b100001: (MIPS_INS_LH, "lh", ("rt","offset(base)")), - 0b100010: (MIPS_INS_LWL, "lwl", ("rt","offset(base)")), - 0b100011: (MIPS_INS_LW, "lw", ("rt","offset(base)")), - 0b100100: (MIPS_INS_LBU, "lbu", ("rt","offset(base)")), - 0b100101: (MIPS_INS_LHU, "lhu", ("rt","offset(base)")), - 0b100110: (MIPS_INS_LWR, "lwr", ("rt","offset(base)")), - 0b100111: (MIPS_INS_LWU, "lwu", ("rt","offset(base)")), - 0b101000: (MIPS_INS_SB, "sb", ("rt","offset(base)")), - 0b101001: (MIPS_INS_SH, "sh", ("rt","offset(base)")), - 0b101010: (MIPS_INS_SWL, "swl", ("rt","offset(base)")), - 0b101011: (MIPS_INS_SW, "sw", ("rt","offset(base)")), - 0b101100: (MIPS_INS_SDL, "sdl", ("rt","offset(base)")), - 0b101101: (MIPS_INS_SDR, "sdr", ("rt","offset(base)")), - 0b101110: (MIPS_INS_SWR, "swr", ("rt","offset(base)")), - 0b101111: (MIPS_INS_CACHE, "cache", ("op","offset(base)")), - 0b110000: (MIPS_INS_LL, "ll", ("rt","offset(base)")), - 0b110001: (MIPS_INS_LWC1, "lwc1", ("ft","offset(base)")), - 0b110100: (MIPS_INS_LLD, "lld", ("rt","offset(base)")), - 0b110101: (MIPS_INS_LDC1, "ldc1", ("ft","offset(base)")), - # ldc2 - 0b110111: (MIPS_INS_LD, "ld", ("rt","offset(base)")), - 0b111000: (MIPS_INS_SC, "sc", ("rt","offset(base)")), - 0b111001: (MIPS_INS_SWC1, "swc1", ("ft","offset(base)")), - 0b111100: (MIPS_INS_SCD, "scd", ("rt","offset(base)")), - 0b111101: (MIPS_INS_SDC1, "sdc1", ("ft","offset(base)")), - # sdc2 - 0b111111: (MIPS_INS_SD, "sd", ("rt","offset(base)")), -} diff --git a/tools/disasm/variables.txt b/tools/disasm/variables.txt index c96b82408..eaca8ea4b 100644 --- a/tools/disasm/variables.txt +++ b/tools/disasm/variables.txt @@ -27,13 +27,13 @@ 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:("sInitFuncs","void*","",0x4), 0x80097504:("sNew","char","[4]",0x4), @@ -914,14 +914,14 @@ 0x801BB148:("sCsStateHandlers2","cutscene_update_func","[5]",0x14), 0x801BB15C:("D_801BB15C","UNK_TYPE2","",0x2), 0x801BB160:("D_801BB160","UNK_TYPE4","",0x4), - 0x801BB170:("D_801BB170","s801BB170","[118]",0x1098), + 0x801BB170:("sDrawItemTable","DrawItemTableEntry","[118]",0x1098), 0x801BC210:("D_801BC210","UNK_TYPE1","",0x1), 0x801BC240:("D_801BC240","Gfx","[9]",0x48), 0x801BC288:("D_801BC288","Gfx","[3]",0x18), 0x801BC2A0:("D_801BC2A0","UNK_TYPE1","",0x1), 0x801BC3F0:("gEnHyBodyParts","UNK_TYPE1","",0x1), - 0x801BC400:("gEnHyBodyPartsIndex","UNK_TYPE1","",0x1), - 0x801BC410:("gEnHyShadowSize","s32",[],0x10), + 0x801BC400:("gEnHyParentBodyParts","UNK_TYPE1","",0x1), + 0x801BC410:("gEnHyShadowSizes","s32",[],0x10), 0x801BC420:("sReactionTextIds","u16","[]",0x140A), 0x801BD830:("actorCutscenesGlobalCutscenes","ActorCutscene","[8]",0x80), 0x801BD8B0:("actorCutsceneCurrent","s16","",0x2), @@ -930,7 +930,7 @@ 0x801BD8B6:("actorCutsceneCurrentCamera","s16","",0x2), 0x801BD8B8:("actorCutsceneCurrentCutsceneActor","Actor*","",0x4), 0x801BD8BC:("actorCutsceneStartMethod","UNK_TYPE4","",0x4), - 0x801BD8C0:("actorCutscenesGlobalCtxt","GlobalContext*","",0x4), + 0x801BD8C0:("actorCutscenesPlayState","PlayState*","",0x4), 0x801BD8C4:("actorCutsceneReturnCamera","s16","",0x2), 0x801BD8C6:("D_801BD8C6","s16","",0x2), 0x801BD8D0:("sFireObjCollisionInit","ColliderCylinderInit","",0x2c), @@ -970,7 +970,7 @@ 0x801BDBA0:("D_801BDBA0","UNK_TYPE1","",0x1), 0x801BDBA4:("D_801BDBA4","UNK_TYPE1","",0x1), 0x801BDBA8:("D_801BDBA8","UNK_TYPE1","",0x1), - 0x801BDBB0:("D_801BDBB0","u8","",0x1), + 0x801BDBB0:("gWeatherMode","u8","",0x1), 0x801BDBB4:("D_801BDBB4","UNK_TYPE1","",0x1), 0x801BDBB8:("D_801BDBB8","UNK_TYPE1","",0x1), 0x801BDBBC:("D_801BDBBC","UNK_TYPE1","",0x1), @@ -1062,65 +1062,51 @@ 0x801BF5B0:("D_801BF5B0","UNK_TYPE2","",0x2), 0x801BF5C0:("D_801BF5C0","UNK_PTR","",0x4), 0x801BF68C:("D_801BF68C","UNK_TYPE1","",0x1), - 0x801BF6C0:("D_801BF6C0","UNK_TYPE1","",0x1), - 0x801BF79E:("D_801BF79E","UNK_TYPE1","",0x1), + 0x801BF6C0:("sRestrictionFlags","RestrictionFlags","[113]",0x1c4), 0x801BF884:("D_801BF884","UNK_TYPE2","",0x2), 0x801BF888:("D_801BF888","UNK_TYPE2","",0x2), - 0x801BF88C:("D_801BF88C","UNK_TYPE2","",0x2), - 0x801BF890:("D_801BF890","UNK_TYPE2","",0x2), - 0x801BF898:("D_801BF898","UNK_TYPE2","",0x2), - 0x801BF89C:("D_801BF89C","UNK_TYPE2","",0x2), - 0x801BF8A0:("D_801BF8A0","UNK_TYPE2","",0x2), - 0x801BF8A4:("D_801BF8A4","UNK_TYPE2","",0x2), - 0x801BF8A8:("D_801BF8A8","UNK_TYPE2","",0x2), + 0x801BF88C:("sHBAScoreTier","UNK_TYPE2","",0x2), + 0x801BF890:("sMinigameScoreDigits","UNK_TYPE2","",0x2), + 0x801BF898:("sCUpInvisible","UNK_TYPE2","",0x2), + 0x801BF89C:("sCUpTimer","UNK_TYPE2","",0x2), + 0x801BF8A0:("sMagicBarOutlinePrimRed","UNK_TYPE2","",0x2), + 0x801BF8A4:("sMagicBarOutlinePrimGreen","UNK_TYPE2","",0x2), + 0x801BF8A8:("sMagicBarOutlinePrimBlue","UNK_TYPE2","",0x2), 0x801BF8AC:("D_801BF8AC","UNK_TYPE2","",0x2), 0x801BF8B0:("D_801BF8B0","UNK_TYPE2","",0x2), 0x801BF8DC:("D_801BF8DC","UNK_TYPE2","",0x2), 0x801BF8E0:("D_801BF8E0","UNK_TYPE2","",0x2), 0x801BF8E4:("D_801BF8E4","UNK_TYPE2","",0x2), 0x801BF8E8:("D_801BF8E8","UNK_TYPE4","",0x4), - 0x801BF8F0:("D_801BF8F0","UNK_TYPE4","",0x4), - 0x801BF8F4:("D_801BF8F4","UNK_TYPE4","",0x4), - 0x801BF8F8:("D_801BF8F8","UNK_TYPE4","",0x4), - 0x801BF8FC:("D_801BF8FC","UNK_TYPE4","",0x4), - 0x801BF930:("D_801BF930","UNK_TYPE4","",0x4), - 0x801BF934:("D_801BF934","UNK_TYPE4","",0x4), - 0x801BF968:("D_801BF968","UNK_TYPE1","",0x1), - 0x801BF96A:("D_801BF96A","UNK_TYPE1","",0x1), - 0x801BF96C:("D_801BF96C","UNK_TYPE1","",0x1), - 0x801BF96E:("D_801BF96E","UNK_TYPE1","",0x1), - 0x801BF970:("D_801BF970","UNK_TYPE2","",0x2), - 0x801BF972:("D_801BF972","UNK_TYPE1","",0x1), - 0x801BF974:("D_801BF974","UNK_TYPE2","",0x2), - 0x801BF978:("D_801BF978","UNK_TYPE2","",0x2), - 0x801BF97C:("D_801BF97C","UNK_TYPE2","",0x2), + 0x801BF8F0:("D_801BF8F0","u64","",0x8), + 0x801BF8F8:("D_801BF8F8","u64","[7]",0x38), + 0x801BF930:("D_801BF930","u64","[7]",0x38), + 0x801BF968:("D_801BF968","UNK_TYPE4","",0x4), + 0x801BF96C:("D_801BF96C","UNK_TYPE4","",0x4), + 0x801BF970:("D_801BF970","UNK_TYPE4","",0x4), + 0x801BF974:("D_801BF974","UNK_TYPE4","",0x4), + 0x801BF978:("D_801BF978","UNK_TYPE4","",0x4), + 0x801BF97C:("D_801BF97C","UNK_TYPE4","",0x4), 0x801BF980:("D_801BF980","UNK_TYPE4","",0x4), - 0x801BF988:("D_801BF988","UNK_TYPE1","",0x1), - 0x801BF998:("D_801BF998","UNK_TYPE1","",0x1), + 0x801BF988:("D_801BF988","Gfx","[5]",0x28), 0x801BF9B0:("D_801BF9B0","UNK_TYPE2","",0x2), 0x801BF9B4:("D_801BF9B4","UNK_TYPE1","",0x1), 0x801BF9BC:("D_801BF9BC","UNK_TYPE1","",0x1), 0x801BF9C4:("D_801BF9C4","UNK_TYPE1","",0x1), 0x801BF9C8:("D_801BF9C8","UNK_TYPE1","",0x1), 0x801BF9CC:("D_801BF9CC","UNK_TYPE1","",0x1), - 0x801BF9D4:("D_801BF9D4","UNK_TYPE2","",0x2), - 0x801BF9D6:("D_801BF9D6","UNK_TYPE2","",0x2), - 0x801BF9D8:("D_801BF9D8","UNK_TYPE2","",0x2), - 0x801BF9DA:("D_801BF9DA","UNK_TYPE2","",0x2), - 0x801BF9DC:("D_801BF9DC","UNK_TYPE2","",0x2), - 0x801BF9DE:("D_801BF9DE","UNK_TYPE2","",0x2), - 0x801BF9E0:("D_801BF9E0","UNK_TYPE2","",0x2), - 0x801BF9E2:("D_801BF9E2","UNK_TYPE2","",0x2), - 0x801BF9E4:("D_801BF9E4","UNK_TYPE2","",0x2), - 0x801BF9E6:("D_801BF9E6","UNK_TYPE2","",0x2), - 0x801BF9E8:("D_801BF9E8","UNK_TYPE2","",0x2), - 0x801BF9EA:("D_801BF9EA","UNK_TYPE2","",0x2), - 0x801BF9EC:("D_801BF9EC","UNK_TYPE2","",0x2), - 0x801BF9F0:("D_801BF9F0","UNK_TYPE2","",0x2), - 0x801BF9F4:("D_801BF9F4","UNK_TYPE2","",0x2), - 0x801BF9F8:("D_801BF9F8","UNK_TYPE2","",0x2), - 0x801BF9FC:("D_801BF9FC","UNK_TYPE2","",0x2), - 0x801BFA00:("D_801BFA00","UNK_TYPE2","",0x2), + 0x801BF9D4:("D_801BF9D4","UNK_TYPE4","",0x4), + 0x801BF9D8:("D_801BF9D8","UNK_TYPE4","",0x4), + 0x801BF9DC:("D_801BF9DC","UNK_TYPE4","",0x4), + 0x801BF9E0:("D_801BF9E0","UNK_TYPE4","",0x4), + 0x801BF9E4:("D_801BF9E4","UNK_TYPE4","",0x4), + 0x801BF9E8:("D_801BF9E8","UNK_TYPE4","",0x4), + 0x801BF9EC:("sFinalHoursClockDigitsRed","UNK_TYPE4","",0x4), + 0x801BF9F0:("sFinalHoursClockFrameEnvRed","UNK_TYPE2","",0x2), + 0x801BF9F4:("sFinalHoursClockFrameEnvGreen","UNK_TYPE2","",0x2), + 0x801BF9F8:("sFinalHoursClockFrameEnvBlue","UNK_TYPE2","",0x2), + 0x801BF9FC:("sFinalHoursClockColorTimer","UNK_TYPE2","",0x2), + 0x801BFA00:("sFinalHoursClockColorTargetIndex","UNK_TYPE2","",0x2), 0x801BFA04:("D_801BFA04","UNK_TYPE2","",0x2), 0x801BFA1C:("D_801BFA1C","UNK_TYPE2","",0x2), 0x801BFA34:("D_801BFA34","UNK_TYPE2","",0x2), @@ -1128,16 +1114,14 @@ 0x801BFA64:("D_801BFA64","UNK_TYPE2","",0x2), 0x801BFA74:("D_801BFA74","UNK_TYPE2","",0x2), 0x801BFA84:("D_801BFA84","UNK_TYPE4","",0x4), - 0x801BFAB0:("D_801BFAB0","UNK_TYPE1","",0x1), - 0x801BFAB8:("D_801BFAB8","UNK_TYPE1","",0x1), - 0x801BFAC4:("D_801BFAC4","UNK_TYPE1","",0x1), - 0x801BFACC:("D_801BFACC","UNK_TYPE1","",0x1), - 0x801BFAD4:("D_801BFAD4","UNK_TYPE1","",0x1), - 0x801BFAF4:("D_801BFAF4","UNK_TYPE2","",0x2), - 0x801BFAF6:("D_801BFAF6","UNK_TYPE2","",0x2), - 0x801BFAF8:("D_801BFAF8","UNK_TYPE2","",0x2), - 0x801BFAFA:("D_801BFAFA","UNK_TYPE2","",0x2), - 0x801BFAFC:("D_801BFAFC","UNK_TYPE1","",0x1), + 0x801BFAB0:("sDoActionTextures","UNK_TYPE1","",0x1), + 0x801BFAB8:("magicBorderColors","UNK_TYPE1","",0x1), + 0x801BFAC4:("magicBorderIndices","UNK_TYPE1","",0x1), + 0x801BFACC:("magicBorderColorTimerIndex","UNK_TYPE1","",0x1), + 0x801BFAD4:("cUpLabelTextures","UNK_TYPE1","",0x1), + 0x801BFAF4:("D_801BFAF4","UNK_TYPE4","",0x4), + 0x801BFAF8:("D_801BFAF8","UNK_TYPE4","",0x4), + 0x801BFAFC:("D_801BFAFC","UNK_TYPE4","",0x4), 0x801BFB04:("D_801BFB04","UNK_TYPE1","",0x1), 0x801BFB0C:("D_801BFB0C","UNK_TYPE1","",0x1), 0x801BFB14:("D_801BFB14","UNK_TYPE1","",0x1), @@ -1169,27 +1153,19 @@ 0x801BFC14:("D_801BFC14","UNK_TYPE1","",0x1), 0x801BFC40:("D_801BFC40","UNK_TYPE1","",0x1), 0x801BFC50:("D_801BFC50","UNK_TYPE2","",0x2), - 0x801BFC60:("D_801BFC60","UNK_TYPE2","",0x2), - 0x801BFC62:("D_801BFC62","UNK_TYPE2","",0x2), - 0x801BFC64:("D_801BFC64","UNK_TYPE2","",0x2), - 0x801BFC6C:("D_801BFC6C","UNK_TYPE2","",0x2), + 0x801BFC60:("D_801BFC60","s16","[6]",0xC), + 0x801BFC6C:("D_801BFC6C","UNK_TYPE4","",0x4), 0x801BFC7C:("D_801BFC7C","UNK_TYPE2","",0x2), 0x801BFC8C:("D_801BFC8C","UNK_TYPE1","",0x1), 0x801BFC98:("D_801BFC98","UNK_TYPE2","",0x2), 0x801BFCA8:("D_801BFCA8","UNK_TYPE2","",0x2), 0x801BFCB8:("D_801BFCB8","UNK_TYPE1","",0x1), 0x801BFCC4:("D_801BFCC4","UNK_TYPE4","",0x4), - 0x801BFCE4:("D_801BFCE4","UNK_TYPE2","",0x2), - 0x801BFCE8:("D_801BFCE8","UNK_TYPE2","",0x2), - 0x801BFCEA:("D_801BFCEA","UNK_TYPE2","",0x2), - 0x801BFCEC:("D_801BFCEC","UNK_TYPE2","",0x2), - 0x801BFCEE:("D_801BFCEE","UNK_TYPE2","",0x2), - 0x801BFCF0:("D_801BFCF0","UNK_TYPE2","",0x2), - 0x801BFCF2:("D_801BFCF2","UNK_TYPE2","",0x2), - 0x801BFCF4:("D_801BFCF4","UNK_TYPE2","",0x2), - 0x801BFCF8:("D_801BFCF8","UNK_TYPE2","",0x2), - 0x801BFCFC:("D_801BFCFC","UNK_TYPE2","",0x2), - 0x801BFD0C:("D_801BFD0C","UNK_TYPE2","",0x2), + 0x801BFCE4:("D_801BFCE4","UNK_TYPE4","",0x4), + 0x801BFCE8:("D_801BFCE8","u16","[8]",0x10), + 0x801BFCF8:("D_801BFCF8","UNK_TYPE4","",0x4), + 0x801BFCFC:("D_801BFCFC","UNK_TYPE4","",0x4), + 0x801BFD0C:("D_801BFD0C","UNK_TYPE4","",0x4), 0x801BFD1C:("D_801BFD1C","UNK_TYPE1","",0x1), 0x801BFD24:("D_801BFD24","UNK_TYPE1","",0x1), 0x801BFD2C:("D_801BFD2C","UNK_TYPE1","",0x1), @@ -1199,33 +1175,24 @@ 0x801BFD6C:("D_801BFD6C","UNK_TYPE2","",0x2), 0x801BFD84:("D_801BFD84","UNK_TYPE1","",0x1), 0x801BFD8C:("D_801BFD8C","UNK_TYPE1","",0x1), - 0x801BFD94:("D_801BFD94","UNK_TYPE1","",0x1), - 0x801BFD98:("D_801BFD98","UNK_TYPE2","",0x2), - 0x801BFD9E:("D_801BFD9E","UNK_TYPE1","",0x1), + 0x801BFD94:("D_801BFD94","UNK_TYPE4","",0x4), + 0x801BFD98:("D_801BFD98","UNK_TYPE4","[2]",0x8), + 0x801BFDA0:("sMaskObjectIds","s16","[24]",0x30), 0x801BFDD0:("D_801BFDD0","UNK_TYPE1","",0x1), - 0x801BFDE8:("D_801BFDE8","UNK_TYPE1","",0x1), + 0x801BFDE8:("sMaskItemIds","UNK_TYPE1","",0x1), 0x801BFE00:("D_801BFE00","UNK_TYPE1","",0x1), 0x801BFE14:("D_801BFE14","UNK_TYPE1","",0x1), 0x801BFF34:("D_801BFF34","UNK_TYPE2","",0x2), - 0x801BFF3C:("D_801BFF3C","UNK_TYPE1","",0x1), + 0x801BFF3C:("sActionModelGroups","UNK_TYPE1","",0x1), 0x801BFF90:("D_801BFF90","UNK_TYPE1","",0x1), - 0x801BFF98:("D_801BFF98","UNK_TYPE1","",0x1), - 0x801BFFA0:("D_801BFFA0","UNK_TYPE1","",0x1), - 0x801BFFB0:("D_801BFFB0","UNK_TYPE1","",0x1), + 0x801BFF98:("sPlayerStrengths","UNK_TYPE1","",0x1), + 0x801BFFA0:("sEnvironmentTextTriggers","UNK_TYPE1","",0x1), + 0x801BFFB0:("gPlayerModelTypes","UNK_TYPE1","",0x1), 0x801BFFFC:("D_801BFFFC","UNK_TYPE1","",0x1), - 0x801C0000:("D_801C0000","UNK_TYPE1","",0x1), - 0x801C0001:("D_801C0001","UNK_TYPE1","",0x1), - 0x801C0002:("D_801C0002","UNK_TYPE1","",0x1), - 0x801C0008:("D_801C0008","UNK_TYPE1","",0x1), - 0x801C0010:("D_801C0010","UNK_TYPE1","",0x1), 0x801C0024:("D_801C0024","UNK_TYPE1","",0x1), 0x801C0034:("D_801C0034","UNK_TYPE1","",0x1), - 0x801C0040:("D_801C0040","UNK_TYPE1","",0x1), 0x801C005C:("D_801C005C","UNK_TYPE1","",0x1), - 0x801C0060:("D_801C0060","UNK_TYPE1","",0x1), - 0x801C0070:("D_801C0070","UNK_TYPE1","",0x1), 0x801C0084:("D_801C0084","UNK_TYPE1","",0x1), - 0x801C00A0:("D_801C00A0","UNK_TYPE1","",0x1), 0x801C00AC:("D_801C00AC","UNK_TYPE1","",0x1), 0x801C00BC:("D_801C00BC","UNK_TYPE1","",0x1), 0x801C00D4:("D_801C00D4","UNK_TYPE1","",0x1), @@ -1245,7 +1212,7 @@ 0x801C02BC:("D_801C02BC","UNK_TYPE1","",0x1), 0x801C02D0:("D_801C02D0","UNK_TYPE1","",0x1), 0x801C02E4:("D_801C02E4","UNK_TYPE1","",0x1), - 0x801C02F8:("D_801C02F8","UNK_PTR","",0x4), + 0x801C02F8:("sPlayerDListGroups","UNK_PTR","",0x4), 0x801C0340:("D_801C0340","UNK_TYPE1","",0x1), 0x801C0368:("D_801C0368","UNK_TYPE1","",0x1), 0x801C03A0:("D_801C03A0","UNK_TYPE1","",0x1), @@ -1262,9 +1229,7 @@ 0x801C05A8:("D_801C05A8","UNK_TYPE1","",0x1), 0x801C05C8:("D_801C05C8","UNK_TYPE1","",0x1), 0x801C05D8:("D_801C05D8","UNK_TYPE1","",0x1), - 0x801C05F0:("D_801C05F0","UNK_TYPE1","",0x1), - 0x801C05F2:("D_801C05F2","UNK_TYPE2","",0x2), - 0x801C05FA:("D_801C05FA","UNK_TYPE1","",0x1), + 0x801C05F0:("D_801C05F0","struct_80124618","[3]",0x18), 0x801C0608:("D_801C0608","UNK_TYPE1","",0x1), 0x801C0628:("D_801C0628","UNK_TYPE1","",0x1), 0x801C0678:("D_801C0678","UNK_TYPE1","",0x1), @@ -1287,15 +1252,13 @@ 0x801C0860:("D_801C0860","UNK_TYPE1","",0x1), 0x801C0870:("D_801C0870","UNK_PTR","",0x4), 0x801C0890:("D_801C0890","UNK_TYPE1","",0x1), - 0x801C08A0:("D_801C08A0","UNK_TYPE1","",0x1), - 0x801C08A1:("D_801C08A1","UNK_TYPE1","",0x1), + 0x801C08A0:("D_801C08A0","UNK_TYPE1","",0x20), 0x801C08C0:("D_801C08C0","UNK_TYPE1","",0x1), 0x801C08FC:("D_801C08FC","UNK_TYPE1","",0x1), 0x801C0910:("D_801C0910","UNK_TYPE1","",0x1), 0x801C0924:("D_801C0924","UNK_TYPE1","",0x1), 0x801C0938:("D_801C0938","UNK_TYPE1","",0x1), - 0x801C094C:("D_801C094C","UNK_TYPE1","",0x1), - 0x801C0954:("D_801C0954","UNK_TYPE4","",0x4), + 0x801C094C:("D_801C094C","Vec3f","",0xC), 0x801C0958:("D_801C0958","UNK_TYPE4","",0x4), 0x801C095C:("D_801C095C","UNK_PTR","",0x4), 0x801C0964:("D_801C0964","UNK_TYPE1","",0x1), @@ -1321,27 +1284,18 @@ 0x801C0B1C:("D_801C0B1C","UNK_TYPE1","",0x1), 0x801C0B20:("D_801C0B20","UNK_TYPE1","",0x1), 0x801C0B90:("D_801C0B90","UNK_TYPE1","",0x1), - 0x801C0BA8:("D_801C0BA8","UNK_TYPE4","",0x4), - 0x801C0BAC:("D_801C0BAC","UNK_TYPE4","",0x4), - 0x801C0BB0:("D_801C0BB0","UNK_TYPE4","",0x4), - 0x801C0BB4:("D_801C0BB4","UNK_TYPE1","",0x1), - 0x801C0BB8:("D_801C0BB8","UNK_TYPE4","",0x4), + 0x801C0BA8:("D_801C0BA8","Vec3f","",0xC), + 0x801C0BB4:("D_801C0BB4","Vec3f","",0xC), 0x801C0BC0:("D_801C0BC0","UNK_TYPE1","",0x1), 0x801C0BD0:("D_801C0BD0","UNK_TYPE1","",0x1), - 0x801C0BE0:("D_801C0BE0","UNK_TYPE4","",0x4), - 0x801C0BE4:("D_801C0BE4","UNK_TYPE4","",0x4), - 0x801C0BE8:("D_801C0BE8","UNK_TYPE4","",0x4), - 0x801C0BEC:("D_801C0BEC","UNK_TYPE4","",0x4), - 0x801C0BF0:("D_801C0BF0","UNK_TYPE4","",0x4), - 0x801C0BF4:("D_801C0BF4","UNK_TYPE4","",0x4), + 0x801C0BE0:("D_801C0BE0","Vec3f","",0xC), + 0x801C0BEC:("D_801C0BEC","Vec3f","",0xC), 0x801C0BF8:("D_801C0BF8","UNK_TYPE1","",0x1), 0x801C0BFC:("D_801C0BFC","UNK_TYPE1","",0x1), 0x801C0C00:("D_801C0C00","UNK_TYPE1","",0x1), 0x801C0C0C:("D_801C0C0C","UNK_TYPE4","",0x4), 0x801C0C30:("D_801C0C30","UNK_TYPE1","",0x1), - 0x801C0C54:("D_801C0C54","UNK_TYPE1","",0x1), - 0x801C0C78:("D_801C0C78","UNK_TYPE1","",0x1), - 0x801C0C94:("D_801C0C94","UNK_TYPE1","",0x1), + 0x801C0C54:("D_801C0C54","struct_80128388_arg1","",0x54), 0x801C0CA8:("D_801C0CA8","UNK_TYPE1","",0x1), 0x801C0CE8:("D_801C0CE8","UNK_TYPE4","",0x4), 0x801C0D24:("D_801C0D24","UNK_TYPE1","",0x1), @@ -1394,8 +1348,8 @@ 0x801C2650:("tatlMessageFiles","RomFile","[2]",0x10), 0x801C2660:("sceneTextureFiles","RomFile","[9]",0x48), 0x801C26A8:("sceneHeaderFuncTable","scene_header_func","[31]",0x7c), - 0x801C2730:("gLinkFormObjectIndexes","s16","[8]",0x10), - 0x801C2740:("objectFileTable","RomFile","[643]",0x1418), + 0x801C2730:("gPlayerFormObjectIndices","s16","[8]",0x10), + 0x801C2740:("gObjectTable","RomFile","[643]",0x1418), 0x801C3B60:("sSceneDrawDefaultDl","Gfx","[11]",0x58), 0x801C3BB8:("gSceneProcSceneDrawFuncs","SceneDrawConfigFunc","[8]",0x20), 0x801C3BD8:("gSceneProcDrawFuncs","scene_proc_draw_func","[6]",0x18), @@ -1971,9 +1925,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), @@ -1988,7 +1942,7 @@ 0x801C5FC0:("D_801C5FC0","u32","[452]",0x710), 0x801C66D0:("D_801C66D0","UNK_TYPE2","",0x2), 0x801C6798:("D_801C6798","UNK_TYPE4","",0x4), - 0x801C67B0:("D_801C67B0","UNK_TYPE1","",0x1), + 0x801C67B0:("gAmmoItems","UNK_TYPE1","",0x1), 0x801C67C8:("D_801C67C8","s32","[8]",0x20), 0x801C67E8:("D_801C67E8","UNK_TYPE4","",0x4), 0x801C67F0:("D_801C67F0","s32","[8]",0x20), @@ -2171,7 +2125,7 @@ 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), @@ -2245,7 +2199,8 @@ 0x801D1E20:("gIdentityMtxF","MtxF","",0x40), 0x801D1E60:("initialgspUcodeText","UNK_PTR","",0x4), 0x801D1E64:("initialgspUcodeData","UNK_PTR","",0x4), - 0x801D1E70:("D_801D1E70","UNK_TYPE1","",0x1), + 0x801D1E70:("D_801D1E70","u8","",0x1), + 0x801D1E80:("D_801D1E80","u8","",0x1), 0x801D2E80:("gLowPassFilterData","UNK_TYPE1","",0x1), 0x801D2F80:("gHighPassFilterData","UNK_TYPE1","",0x1), 0x801D3070:("gBandStopFilterData","UNK_TYPE1","",0x1), @@ -2297,9 +2252,9 @@ 0x801D618C:("D_801D618C","UNK_PTR","",0x4), 0x801D6190:("D_801D6190","f32","",0x4), 0x801D6194:("D_801D6194","UNK_TYPE4","",0x4), - 0x801D61A0:("D_801D61A0","u8","[96]",0x60), + 0x801D61A0:("sSeqInstructionArgsTable","u8","[96]",0x60), 0x801D6200:("D_801D6200","UNK_TYPE1","",0x1), - 0x801D6600:("D_801D6600","UNK_TYPE1","",0x1), + 0x801D6600:("gIsLargeSfxBank","UNK_TYPE1","",0x1), 0x801D6608:("D_801D6608","UNK_TYPE1","",0x1), 0x801D6610:("gChannelsPerBank","UNK_TYPE1","",0x1), 0x801D662C:("gUsedChannelsPerBank","UNK_TYPE1","",0x1), @@ -2318,7 +2273,7 @@ 0x801D6698:("sGanonsTowerLevelsVol","u8","[8]",0x8), 0x801D66A0:("sEnterGanonsTowerTimer","UNK_TYPE1","",0x1), 0x801D66A4:("sSfxVolumeDuration","UNK_TYPE2","",0x2), - 0x801D66A8:("sAudioFileSelectSetting","UNK_TYPE1","",0x1), + 0x801D66A8:("sSoundMode","UNK_TYPE1","",0x1), 0x801D66AC:("sAudioIsWindowOpen","UNK_TYPE1","",0x1), 0x801D66B0:("sAudioCutsceneFlag","UNK_TYPE1","",0x1), 0x801D66B4:("sSpecReverb","UNK_TYPE1","",0x1), @@ -2355,28 +2310,28 @@ 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), + 0x801D6FE4:("sPlaybackStaffStopPos","UNK_TYPE1","",0x1), + 0x801D6FE8:("sPlaybackStaffStartPos","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), + 0x801D6FFC:("sPrevOcarinaWithMusicStaffFlags","UNK_TYPE4","",0x4), + 0x801D7000:("sPlaybackPitch","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), + 0x801D7010:("sRelativeNotePlaybackBend","f32","",0x4), + 0x801D7014:("sRelativeNotePlaybackVolume","f32","",0x4), 0x801D7018:("sOcarinaPlaybackTaskStart","UNK_TYPE4","",0x4), 0x801D701C:("sOcarinaWallCounter","UNK_TYPE4","",0x4), - 0x801D7020:("sCurOcarinaSong","u8","[8]",0x8), - 0x801D7028:("sOcarinaSongAppendPos","UNK_TYPE1","",0x1), + 0x801D7020:("sCurOcarinaSongWithoutMusicStaff","u8","[8]",0x8), + 0x801D7028:("sOcarinaWithoutMusicStaffPos","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), + 0x801D703C:("sOcarinaMemoryGameEndPos","UNK_TYPE1","",0x1), + 0x801D7040:("sOcarinaMemoryGameNumNotes","UNK_TYPE1","",0x1), 0x801D7044:("sOcarinaSongNotes","OcarinaNote","[24][20]",0xF00), 0x801D7F44:("sOoTOcarinaSongNotes","OcarinaNote","[9][20]",0x5A0), 0x801D84E4:("sOoTOcarinaSongsNumNotes","UNK_TYPE1","",0x1), @@ -2395,7 +2350,7 @@ 0x801D852C:("sMusicStaffNumNotesPerTest","UNK_TYPE1","",0x1), 0x801D8530:("D_801D8530","UNK_TYPE1","",0x1), 0x801D8534:("D_801D8534","UNK_TYPE4","",0x4), - 0x801D8538:("sIsOcarinaNoteChanged","UNK_TYPE1","",0x1), + 0x801D8538:("sOcarinaDropInputTimer","UNK_TYPE1","",0x1), 0x801D853C:("sScarecrowsLongSongNotes","OcarinaNote","[108]",0x360), 0x801D889C:("gScarecrowLongSongPtr","UNK_PTR","",0x4), 0x801D88A0:("gScarecrowSpawnSongPtr","UNK_PTR","",0x4), @@ -2426,20 +2381,20 @@ 0x801DADD0:("sOcarinaBankParams","UNK_TYPE1","",0x1), 0x801DAE10:("sVoiceBankParams","UNK_TYPE1","",0x1), 0x801DB450:("gSfxParams","UNK_PTR","",0x4), - 0x801DB470:("D_801DB470","UNK_TYPE1","",0x1), - 0x801DB474:("D_801DB474","UNK_TYPE1","",0x1), - 0x801DB478:("D_801DB478","UNK_PTR","[7]",0x1c), - 0x801DB494:("D_801DB494","UNK_TYPE1","",0x1), - 0x801DB49C:("D_801DB49C","UNK_TYPE1","",0x1), - 0x801DB4A0:("D_801DB4A0","UNK_TYPE2","",0x2), - 0x801DB4A4:("D_801DB4A4","UNK_TYPE4","",0x4), - 0x801DB4B0:("D_801DB4B0","UNK_TYPE1","",0x1), - 0x801DB4B8:("D_801DB4B8","UNK_TYPE1","",0x1), + 0x801DB470:("sSfxRequestWriteIndex","UNK_TYPE1","",0x1), + 0x801DB474:("sSfxRequestReadIndex","UNK_TYPE1","",0x1), + 0x801DB478:("gSfxBanks","UNK_PTR","[7]",0x1c), + 0x801DB494:("sSfxBankSizes","UNK_TYPE1","",0x1), + 0x801DB49C:("gSfxChannelLayout","UNK_TYPE1","",0x1), + 0x801DB4A0:("sSfxChannelLowVolumeFlag","UNK_TYPE2","",0x2), + 0x801DB4A4:("gSfxDefaultPos","UNK_TYPE4","",0x4), + 0x801DB4B0:("gSfxDefaultFreqAndVolScale","UNK_TYPE1","",0x1), + 0x801DB4B8:("gSfxDefaultReverb","UNK_TYPE1","",0x1), 0x801DB4C0:("D_801DB4C0","UNK_TYPE1","",0x1), 0x801DB4C4:("D_801DB4C4","UNK_TYPE1","",0x1), 0x801DB4C8:("D_801DB4C8","UNK_TYPE1","",0x1), 0x801DB4CC:("D_801DB4CC","UNK_TYPE1","",0x1), - 0x801DB4D4:("D_801DB4D4","UNK_TYPE1","",0x1), + 0x801DB4D4:("gAudioSpecId","UNK_TYPE1","",0x1), 0x801DB4D8:("D_801DB4D8","UNK_TYPE1","",0x1), 0x801DB4DC:("D_801DB4DC","UNK_TYPE4","",0x4), 0x801DB4E0:("D_801DB4E0","UNK_TYPE1","",0x1), @@ -4056,9 +4011,7 @@ 0x801F59DC:("D_801F59DC","UNK_TYPE1","",0x1), 0x801F59E0:("D_801F59E0","UNK_TYPE1","",0x1), 0x801F59E4:("D_801F59E4","UNK_TYPE1","",0x1), - 0x801F59E8:("D_801F59E8","UNK_TYPE1","",0x1), - 0x801F59EC:("D_801F59EC","UNK_TYPE1","",0x1), - 0x801F59F0:("D_801F59F0","UNK_TYPE1","",0x1), + 0x801F59E8:("D_801F59E8","Vec3f","",0xC), 0x801F59F4:("D_801F59F4","UNK_TYPE1","",0x1), 0x801F59F8:("D_801F59F8","UNK_TYPE1","",0x1), 0x801F5A00:("sQuakeRequest","QuakeRequest","[4]",0x90), @@ -4070,11 +4023,7 @@ 0x801F5AB4:("sDisableAnimQueueFlags","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), - 0x801F6AD5:("D_801F6AD5","UNK_TYPE1","",0x1), - 0x801F6ADA:("D_801F6ADA","UNK_TYPE1","",0x1), + 0x801F69D0:("gRumbleMgr","RumbleManager","",0x10E), 0x801F6AE0:("sSkyboxDrawMatrix","Mtx*","",0x4), 0x801F6AF0:("D_801F6AF0","UNK_TYPE1","",0x1), 0x801F6AF2:("D_801F6AF2","UNK_TYPE1","",0x1), @@ -4343,18 +4292,18 @@ 0x801FD43A:("sPlayingStaff","OcarinaStaff","",0x3), 0x801FD43E:("sPlaybackStaff","OcarinaStaff","",0x3), 0x801FD442:("sRecordingStaff","OcarinaStaff","",0x3), - 0x801FD448:("sOcarinaUpdateTaskCurrent","UNK_TYPE1","",0x1), + 0x801FD448:("sOcarinaUpdateTaskStart","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), + 0x801FD45C:("sOcarinaInputButtonPress","UNK_TYPE1","",0x1), + 0x801FD460:("sOcarinaDisableTimer","UNK_TYPE1","",0x1), + 0x801FD461:("sOcarinaUnused","UNK_TYPE1","",0x1), 0x801FD462:("sOcarinaHasStartedSong","UNK_TYPE1","",0x1), 0x801FD463:("sFirstOcarinaSongIndex","UNK_TYPE1","",0x1), 0x801FD464:("sLastOcarinaSongIndex","UNK_TYPE1","",0x1), - 0x801FD468:("sOcarinaAvailSongs","UNK_TYPE1","",0x1), + 0x801FD468:("sOcarinaAvailableSongFlags","UNK_TYPE1","",0x1), 0x801FD46C:("sOcarinaStaffPlayingPos","UNK_TYPE1","",0x1), 0x801FD470:("sMusicStaffPos","UNK_TYPE1","",0x1), 0x801FD4A0:("sMusicStaffCurHeldLength","UNK_TYPE1","",0x1), @@ -4362,7 +4311,7 @@ 0x801FD500:("sMusicStaffExpectedPitch","UNK_TYPE1","",0x1), 0x801FD518:("D_801FD518","UNK_TYPE1","",0x1), 0x801FD530:("D_801FD530","u32","[24]",0x60), - 0x801FD590:("sRecordingSongNote","UNK_TYPE1","",0x1), + 0x801FD590:("sScarecrowsLongSongSecondNote","UNK_TYPE1","",0x1), 0x801FD598:("sCustomSequencePc","UNK_TYPE1","",0x1), 0x801FD5A0:("D_801FD5A0","UNK_TYPE1","",0x1), 0x801FD5A4:("D_801FD5A4","UNK_TYPE1","",0x1), @@ -4372,21 +4321,21 @@ 0x801FD5E8:("D_801FD5E8","UNK_TYPE1","",0x1), 0x801FD608:("D_801FD608","UNK_TYPE1","",0x1), 0x801FD610:("D_801FD610","UNK_TYPE1","",0x1), - 0x801FD710:("D_801FD710","UNK_TYPE1","",0x1), - 0x801FD8C0:("D_801FD8C0","UNK_TYPE1","",0x1), - 0x801FDB00:("D_801FDB00","UNK_TYPE1","",0x1), - 0x801FE100:("D_801FE100","UNK_TYPE1","",0x1), - 0x801FE4C0:("D_801FE4C0","UNK_TYPE1","",0x1), - 0x801FE640:("D_801FE640","UNK_TYPE1","",0x1), - 0x801FE6D0:("D_801FE6D0","UNK_TYPE1","",0x1), - 0x801FE7C0:("D_801FE7C0","SoundRequest","[1]",0x14), - 0x801FFBC0:("D_801FFBC0","UNK_TYPE1","",0x1), - 0x801FFBC8:("D_801FFBC8","UNK_TYPE1","",0x1), - 0x801FFBD0:("D_801FFBD0","UNK_TYPE1","",0x1), - 0x801FFBD8:("D_801FFBD8","UNK_TYPE1","",0x1), - 0x801FFC80:("D_801FFC80","UNK_TYPE1","",0x1), - 0x801FFC84:("D_801FFC84","UNK_TYPE1","",0x1), - 0x801FFC90:("D_801FFC90","UNK_TYPE1","",0x1), + 0x801FD710:("sSfxPlayerBank","UNK_TYPE1","",0x1), + 0x801FD8C0:("sSfxItemBank","UNK_TYPE1","",0x1), + 0x801FDB00:("sSfxEnvironmentBank","UNK_TYPE1","",0x1), + 0x801FE100:("sSfxEnemyBank","UNK_TYPE1","",0x1), + 0x801FE4C0:("sSfxSystemBank","UNK_TYPE1","",0x1), + 0x801FE640:("sSfxOcarinaBank","UNK_TYPE1","",0x1), + 0x801FE6D0:("sSfxVoiceBank","UNK_TYPE1","",0x1), + 0x801FE7C0:("sSfxRequests","SfxRequest","[0x100]",0x14), + 0x801FFBC0:("sSfxBankListEnd","UNK_TYPE1","",0x1), + 0x801FFBC8:("sSfxBankFreeListStart","UNK_TYPE1","",0x1), + 0x801FFBD0:("sSfxBankUnused","UNK_TYPE1","",0x1), + 0x801FFBD8:("gActiveSfx","UNK_TYPE1","",0x1), + 0x801FFC80:("sCurSfxPlayerChannelIndex","UNK_TYPE1","",0x1), + 0x801FFC84:("gSfxBankMuted","UNK_TYPE1","",0x1), + 0x801FFC90:("sUnusedBankLerp","UNK_TYPE1","",0x1), 0x801FFD00:("D_801FFD00","UNK_TYPE1","",0x1), 0x801FFD34:("D_801FFD34","UNK_TYPE1","",0x1), 0x801FFD40:("D_801FFD40","UNK_TYPE1","",0x1), @@ -4732,24 +4681,18 @@ 0x8082AFB0:("D_8082AFB0","UNK_TYPE1","",0x1), 0x8082AFC4:("D_8082AFC4","UNK_TYPE2","",0x2), 0x8082AFDC:("D_8082AFDC","UNK_TYPE2","",0x2), - 0x8082AFF4:("D_8082AFF4","UNK_TYPE2","",0x2), - 0x8082B008:("D_8082B008","UNK_TYPE1","",0x1), + 0x8082AFF4:("D_8082AFF4","s16","[12]",0x18), + 0x8082B00C:("D_8082B00C","void*","[6]",0x18), 0x8082B024:("D_8082B024","UNK_TYPE1","",0x1), 0x8082B028:("D_8082B028","UNK_TYPE2","",0x2), - 0x8082B02C:("D_8082B02C","UNK_TYPE1","",0x1), - 0x8082B02E:("D_8082B02E","UNK_TYPE1","",0x1), - 0x8082B030:("D_8082B030","UNK_TYPE1","",0x1), - 0x8082B032:("D_8082B032","UNK_TYPE1","",0x1), - 0x8082B0F0:("D_8082B0F0","UNK_TYPE2","",0x2), - 0x8082B0F4:("D_8082B0F4","UNK_TYPE2","",0x2), - 0x8082B0F8:("D_8082B0F8","UNK_TYPE1","",0x1), - 0x8082B2FA:("D_8082B2FA","UNK_TYPE1","",0x1), - 0x8082B302:("D_8082B302","UNK_TYPE1","",0x1), - 0x8082B30A:("D_8082B30A","UNK_TYPE1","",0x1), - 0x8082B328:("D_8082B328","UNK_TYPE1","",0x1), - 0x8082B388:("D_8082B388","UNK_TYPE2","",0x2), - 0x8082B3AC:("D_8082B3AC","UNK_TYPE4","",0x4), - 0x8082B3B0:("D_8082B3B0","UNK_TYPE4","",0x4), + 0x8082B02C:("D_8082B02C","s16","[98]",0xC4), + 0x8082B0F0:("sCurSection","UNK_TYPE2","",0x2), + 0x8082B0F4:("sCurRow","UNK_TYPE2","",0x2), + 0x8082B0F8:("sSectionPositions","s16","[280]",0x230), + 0x8082B328:("sSlotItems","UNK_TYPE1","",0x1), + 0x8082B388:("sRowFirstSections","UNK_TYPE2","",0x2), + 0x8082B3AC:("sPrevDBtnInput","UNK_TYPE4","",0x4), + 0x8082B3B0:("sHeldDBtnTimer","UNK_TYPE4","",0x4), 0x8082B3C0:("D_8082B3C0","UNK_TYPE2","",0x2), 0x8082B3C4:("D_8082B3C4","UNK_TYPE2","",0x2), 0x8082B3C8:("D_8082B3C8","UNK_TYPE2","",0x2), @@ -4774,10 +4717,7 @@ 0x8082B520:("D_8082B520","UNK_TYPE1","",0x1), 0x8082B52C:("D_8082B52C","UNK_TYPE1","",0x1), 0x8082B538:("D_8082B538","UNK_TYPE1","",0x1), - 0x8082B548:("D_8082B548","UNK_TYPE4","",0x4), - 0x8082B54A:("D_8082B54A","UNK_TYPE1","",0x1), - 0x8082B552:("D_8082B552","UNK_TYPE1","",0x1), - 0x8082B55A:("D_8082B55A","UNK_TYPE1","",0x1), + 0x8082B548:("D_8082B548","s16","[30]",0x3C), 0x8082B584:("D_8082B584","UNK_TYPE2","",0x2), 0x8082B590:("D_8082B590","UNK_TYPE2","",0x2), 0x8082B59C:("D_8082B59C","UNK_TYPE1","",0x1), @@ -5791,7 +5731,7 @@ 0x808743E8:("D_808743E8","f32","",0x4), 0x808743EC:("D_808743EC","f32","",0x4), 0x808743F0:("D_808743F0","f32","",0x4), - 0x80874650:("D_80874650","s80874650","[16]",0x1c0), + 0x80874650:("sPowderKegFuseSegments","PowderKegFuseSegment","[16]",0x1c0), 0x80874668:("D_80874668","UNK_TYPE1","",0x1), 0x8087466A:("D_8087466A","UNK_TYPE1","",0x1), 0x8087466C:("D_8087466C","UNK_TYPE1","",0x1), @@ -6351,24 +6291,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), @@ -6422,7 +6350,7 @@ 0x808A8060:("D_808A8060","UNK_TYPE1","",0x1), 0x808AC010:("En_Ossan_InitVars","UNK_TYPE1","",0x1), 0x808AC030:("sAnimationsCuriosityShopMan","UNK_TYPE1","",0x1), - 0x808AC100:("sAnimationsPartTimeWorker","UNK_TYPE1","",0x1), + 0x808AC100:("sAnimationsPartTimer","UNK_TYPE1","",0x1), 0x808AC1C0:("sObjectIds","UNK_TYPE1","",0x1), 0x808AC1C4:("sAnimations","UNK_TYPE1","",0x1), 0x808AC1CC:("sShops","UNK_TYPE1","",0x1), @@ -6442,9 +6370,9 @@ 0x808AC288:("sInitChain","UNK_TYPE1","",0x1), 0x808AC28C:("sSelectedItemPosition","UNK_TYPE4","",0x4), 0x808AC2A4:("sInitFuncs","UNK_TYPE1","",0x1), - 0x808AC2AC:("sPartTimeWorkerFocusOffset","UNK_TYPE1","",0x1), + 0x808AC2AC:("sPartTimerFocusOffset","UNK_TYPE1","",0x1), 0x808AC2B8:("sCuriosityShopManEyeTextures","UNK_TYPE1","",0x1), - 0x808AC2C4:("sPartTimeWorkerEyeTextures","UNK_TYPE1","",0x1), + 0x808AC2C4:("sPartTimerEyeTextures","UNK_TYPE1","",0x1), 0x808AC2D0:("filename1","char","[]",0x1), 0x808AC2E0:("filename2","char","[]",0x1), 0x808AC2F0:("filename3","char","[]",0x1), @@ -6838,9 +6766,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), @@ -7059,8 +6986,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), @@ -8510,12 +8437,12 @@ 0x809453C4:("D_809453C4","f32","",0x4), 0x80945600:("Item_Inbox_InitVars","UNK_TYPE1","",0x1), 0x809464B0:("En_Ge1_InitVars","UNK_TYPE1","",0x1), - 0x809464D0:("D_809464D0","UNK_TYPE1","",0x1), - 0x809464FC:("D_809464FC","UNK_TYPE1","",0x1), - 0x80946524:("D_80946524","UNK_TYPE1","",0x1), - 0x80946530:("D_80946530","UNK_TYPE1","",0x1), - 0x8094653C:("D_8094653C","UNK_TYPE1","",0x1), - 0x80946548:("D_80946548","UNK_TYPE1","",0x1), + 0x809464D0:("sCylinderInit","ColliderCylinderInit","",0x1), + 0x809464FC:("sAnimations","AnimationHeader","10",0x28), + 0x80946524:("sHairstyleDLs","Gfx*","3",0xC), + 0x80946530:("sInitialFocusPos","Vec3f","",0xC), + 0x8094653C:("sZeroVec","Vec3f","",0xC), + 0x80946548:("sEyeTextures","TexturePtr","3",0xC), 0x80946560:("jtbl_80946560","UNK_PTR","",0x4), 0x80946880:("Obj_Blockstop_InitVars","UNK_TYPE1","",0x1), 0x80947A40:("En_Sda_InitVars","UNK_TYPE1","",0x1), @@ -8602,7 +8529,7 @@ 0x80951C5C:("D_80951C5C","UNK_TYPE1","",0x1), 0x80951C88:("D_80951C88","UNK_TYPE1","",0x1), 0x80951CB4:("D_80951CB4","UNK_TYPE1","",0x1), - 0x80951CC0:("D_80951CC0","UNK_TYPE1","",0x1), + 0x80951CC0:("sAnimationInfo","UNK_TYPE1","",0x1), 0x80951D90:("D_80951D90","UNK_TYPE1","",0x1), 0x80951D9C:("D_80951D9C","UNK_TYPE1","",0x1), 0x80951DA8:("D_80951DA8","UNK_TYPE1","",0x1), @@ -9240,8 +9167,8 @@ 0x80989064:("D_80989064","f32","",0x4), 0x80989068:("D_80989068","f32","",0x4), 0x8098C280:("En_Dg_InitVars","UNK_TYPE1","",0x1), - 0x8098C2A0:("D_8098C2A0","UNK_TYPE1","",0x1), - 0x8098C2A4:("D_8098C2A4","UNK_TYPE2","",0x2), + 0x8098C2A0:("sIsAnyDogHeld","UNK_TYPE1","",0x1), + 0x8098C2A4:("sBremenMaskFollower","UNK_TYPE2","",0x2), 0x8098C2A8:("D_8098C2A8","UNK_TYPE2","",0x2), 0x8098C2AC:("D_8098C2AC","UNK_TYPE2","",0x2), 0x8098C2FC:("D_8098C2FC","UNK_TYPE1","",0x1), @@ -9941,7 +9868,7 @@ 0x809C1008:("D_809C1008","UNK_TYPE1","",0x1), 0x809C1010:("D_809C1010","f32","",0x4), 0x809C3770:("En_Aob_01_InitVars","UNK_TYPE1","",0x1), - 0x809C3790:("D_809C3790","UNK_TYPE4","",0x4), + 0x809C3790:("sAnimationInfo","UNK_TYPE4","",0x4), 0x809C3820:("D_809C3820","UNK_TYPE1","",0x1), 0x809C384C:("D_809C384C","UNK_TYPE4","",0x4), 0x809C392C:("D_809C392C","UNK_TYPE1","",0x1), @@ -9986,23 +9913,23 @@ 0x809C6264:("D_809C6264","f32","",0x4), 0x809C6268:("D_809C6268","f32","",0x4), 0x809C9160:("En_Syateki_Man_InitVars","UNK_TYPE1","",0x1), - 0x809C9180:("D_809C9180","UNK_TYPE1","",0x1), - 0x809C91C8:("D_809C91C8","UNK_TYPE1","",0x1), - 0x809C91D0:("D_809C91D0","UNK_TYPE1","",0x1), - 0x809C934C:("D_809C934C","UNK_TYPE1","",0x1), - 0x809C9464:("D_809C9464","UNK_PTR","",0x4), - 0x809C946C:("D_809C946C","UNK_TYPE1","",0x1), - 0x809C9474:("D_809C9474","UNK_TYPE4","",0x4), - 0x809C9480:("D_809C9480","UNK_TYPE4","",0x4), - 0x809C948C:("D_809C948C","UNK_TYPE4","",0x4), - 0x809C9498:("D_809C9498","UNK_TYPE2","",0x2), - 0x809C949C:("D_809C949C","UNK_TYPE2","",0x2), - 0x809C94A0:("D_809C94A0","UNK_TYPE4","",0x4), - 0x809C94A4:("D_809C94A4","UNK_TYPE2","",0x2), - 0x809C94A8:("D_809C94A8","UNK_TYPE4","",0x4), - 0x809C94AC:("D_809C94AC","UNK_TYPE4","",0x4), - 0x809C94B8:("D_809C94B8","UNK_PTR","",0x4), - 0x809C94D0:("D_809C94D0","UNK_TYPE1","",0x1), + 0x809C9180:("sAnimations","UNK_TYPE1","",0x1), + 0x809C91C8:("sGuayFlagsPerWave","UNK_TYPE1","",0x1), + 0x809C91D0:("sNormalSwampTargetActorList","UNK_TYPE1","",0x1), + 0x809C934C:("sUnusedSwampTargetActorList","UNK_TYPE1","",0x1), + 0x809C9464:("sSwampTargetActorLists","UNK_PTR","",0x4), + 0x809C946C:("sSwampTargetActorListLengths","UNK_TYPE1","",0x1), + 0x809C9474:("sSwampPlayerPos","UNK_TYPE4","",0x4), + 0x809C9480:("sTownFierceDietyPlayerPos","UNK_TYPE4","",0x4), + 0x809C948C:("sTownPlayerPos","UNK_TYPE4","",0x4), + 0x809C9498:("sGameStartTimer","s16","",0x2), + 0x809C949C:("sHasSpawnedGuaysForThisWave","UNK_TYPE2","",0x2), + 0x809C94A0:("sBonusTimer","s32","",0x4), + 0x809C94A4:("sGameStartTimer","s16","",0x2), + 0x809C94A8:("sModFromLosingTime","s32","",0x4), + 0x809C94AC:("sFocusOffset","UNK_TYPE4","",0x4), + 0x809C94B8:("sEyeTextures","UNK_PTR","",0x4), + 0x809C94D0:("sOctorokFlagsPerWave","UNK_TYPE1","",0x1), 0x809C950C:("jtbl_809C950C","UNK_PTR","",0x4), 0x809C9544:("jtbl_809C9544","UNK_PTR","",0x4), 0x809C9570:("jtbl_809C9570","UNK_PTR","",0x4), @@ -10052,7 +9979,7 @@ 0x809CCD14:("D_809CCD14","f32","",0x4), 0x809CDC30:("En_Bji_01_InitVars","ActorInit","",0x20), 0x809CDC50:("D_809CDC50","UNK_TYPE1","",0x1), - 0x809CDC7C:("D_809CDC7C","UNK_TYPE1","",0x1), + 0x809CDC7C:("sAnimationInfo","UNK_TYPE1","",0x1), 0x809CDCBC:("D_809CDCBC","UNK_TYPE1","",0x1), 0x809CDCC8:("D_809CDCC8","UNK_TYPE1","",0x1), 0x809CDCD4:("D_809CDCD4","UNK_TYPE1","",0x1), @@ -10296,12 +10223,12 @@ 0x809E0420:("D_809E0420","UNK_TYPE1","",0x1), 0x809E0421:("D_809E0421","UNK_TYPE1","",0x1), 0x809E0422:("D_809E0422","UNK_TYPE1","",0x1), - 0x809E0424:("D_809E0424","UNK_TYPE4","",0x4), - 0x809E0428:("D_809E0428","UNK_TYPE4","",0x4), - 0x809E042C:("D_809E042C","UNK_TYPE4","",0x4), - 0x809E0430:("D_809E0430","UNK_TYPE1","",0x1), - 0x809E0434:("D_809E0434","UNK_TYPE4","",0x4), - 0x809E0438:("D_809E0438","UNK_TYPE1","",0x1), + 0x809E0424:("sRedTwinmold","UNK_TYPE4","",0x4), + 0x809E0428:("sBlueTwinmold","UNK_TYPE4","",0x4), + 0x809E042C:("sTwinmoldStatic","UNK_TYPE4","",0x4), + 0x809E0430:("sMusicStartTimer","UNK_TYPE1","",0x1), + 0x809E0434:("sBlueWarp","UNK_TYPE4","",0x4), + 0x809E0438:("sEffects","UNK_TYPE1","",0x1), 0x809E8EA0:("D_809E8EA0","UNK_TYPE4","",0x4), 0x809E8EAC:("Boss_03_InitVars","UNK_TYPE1","",0x1), 0x809E8ECC:("D_809E8ECC","UNK_TYPE1","",0x1), @@ -10887,10 +10814,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), @@ -10900,10 +10827,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), @@ -11230,7 +11155,7 @@ 0x80A2E630:("D_80A2E630","f32","",0x4), 0x80A2E910:("Dm_Ravine_InitVars","UNK_TYPE1","",0x1), 0x80A2ECE0:("Dm_Sa_InitVars","UNK_TYPE1","",0x1), - 0x80A2ED00:("D_80A2ED00","UNK_TYPE1","",0x1), + 0x80A2ED00:("sAnimationInfo","UNK_TYPE1","",0x1), 0x80A2ED20:("D_80A2ED20","f32","",0x4), 0x80A31AD0:("En_Slime_InitVars","UNK_TYPE1","",0x1), 0x80A31AF0:("D_80A31AF0","UNK_TYPE1","",0x1), @@ -11561,12 +11486,12 @@ 0x80A43364:("D_80A43364","u16","[2]",0x4), 0x80A434D0:("sCutscenes","s16","[2]",0x4), 0x80A434D4:("sCurrentCs","s16","",0x2), - 0x80A449E0:("En_Bat_InitVars","UNK_TYPE1","",0x1), - 0x80A44A00:("D_80A44A00","UNK_TYPE1","",0x1), - 0x80A44A2C:("D_80A44A2C","UNK_TYPE1","",0x1), - 0x80A44A4C:("D_80A44A4C","UNK_TYPE1","",0x1), - 0x80A44A54:("D_80A44A54","UNK_TYPE1","",0x1), - 0x80A44A64:("D_80A44A64","UNK_TYPE1","",0x1), + 0x80A449E0:("En_Bat_InitVars","ActorInit","",0x1), + 0x80A44A00:("sSphereInit","ColliderSphereInit","",0x1), + 0x80A44A2C:("sDamageTable","DamageTable","4",0x1), + 0x80A44A4C:("sColChkInfoInit","CollisionCheckInfoInit","",0x1), + 0x80A44A54:("sInitChain","InitChainEntry","",0x1), + 0x80A44A64:("sWingsDLs","Gfx*[]","9",0x1), 0x80A44A90:("D_80A44A90","f32","",0x4), 0x80A44A94:("D_80A44A94","f32","",0x4), 0x80A44A98:("D_80A44A98","f32","",0x4), @@ -11583,8 +11508,8 @@ 0x80A44AC4:("D_80A44AC4","f32","",0x4), 0x80A44AC8:("D_80A44AC8","f32","",0x4), 0x80A44ACC:("D_80A44ACC","f32","",0x4), - 0x80A44C70:("D_80A44C70","UNK_TYPE1","",0x1), - 0x80A44C74:("D_80A44C74","UNK_TYPE1","",0x1), + 0x80A44C70:("sNumberAttacking","UNK_TYPE1","",0x1), + 0x80A44C74:("sAlreadySpawned","UNK_TYPE1","",0x1), 0x80A45250:("En_Sekihi_InitVars","UNK_TYPE1","",0x1), 0x80A45270:("D_80A45270","UNK_TYPE1","",0x1), 0x80A4527C:("D_80A4527C","UNK_TYPE1","",0x1), @@ -11746,7 +11671,7 @@ 0x80A53444:("En_Dnq_InitVars","UNK_TYPE1","",0x1), 0x80A53464:("D_80A53464","UNK_TYPE1","",0x1), 0x80A53490:("D_80A53490","UNK_PTR","",0x4), - 0x80A5349C:("D_80A5349C","UNK_TYPE1","",0x1), + 0x80A5349C:("sAnimationInfo","UNK_TYPE1","",0x1), 0x80A535DC:("D_80A535DC","UNK_TYPE1","",0x1), 0x80A535F0:("D_80A535F0","UNK_TYPE4","",0x4), 0x80A535FC:("D_80A535FC","UNK_TYPE1","",0x1), @@ -11814,20 +11739,19 @@ 0x80A55E40:("D_80A55E40","f32","",0x4), 0x80A56100:("En_Firefly2_InitVars","UNK_TYPE1","",0x1), 0x80A583E0:("En_Rat_InitVars","UNK_TYPE1","",0x1), - 0x80A58400:("D_80A58400","UNK_TYPE1","",0x1), - 0x80A58428:("D_80A58428","UNK_TYPE2","",0x2), - 0x80A5842C:("D_80A5842C","UNK_TYPE1","",0x1), - 0x80A5844C:("D_80A5844C","UNK_TYPE1","",0x1), - 0x80A58454:("D_80A58454","UNK_TYPE4","",0x4), - 0x80A58464:("D_80A58464","UNK_TYPE1","",0x1), - 0x80A58470:("D_80A58470","EffectBlureInit2","",0x24), - 0x80A58494:("D_80A58494","UNK_TYPE4","",0x4), - 0x80A58498:("D_80A58498","UNK_TYPE1","",0x1), - 0x80A584A4:("D_80A584A4","UNK_TYPE1","",0x1), - 0x80A584A8:("D_80A584A8","UNK_TYPE1","",0x1), - 0x80A584B4:("D_80A584B4","UNK_TYPE1","",0x1), - 0x80A584C0:("D_80A584C0","UNK_TYPE1","",0x1), - 0x80A584CC:("D_80A584CC","UNK_TYPE1","",0x1), + 0x80A58400:("sSphereInit","UNK_TYPE1","",0x1), + 0x80A5842C:("sDamageTable","UNK_TYPE1","",0x1), + 0x80A5844C:("sColChkInfoInit","UNK_TYPE1","",0x1), + 0x80A58454:("sSparkTextures","UNK_TYPE4","",0x4), + 0x80A58464:("sInitChain","UNK_TYPE1","",0x1), + 0x80A58470:("sBlureInit","EffectBlureInit2","",0x24), + 0x80A58494:("sTexturesDesegmented","UNK_TYPE4","",0x4), + 0x80A58498:("sSmokeAccel","UNK_TYPE1","",0x1), + 0x80A584A4:("sSmokeColor","UNK_TYPE1","",0x1), + 0x80A584A8:("sBlureP1Offset","UNK_TYPE1","",0x1), + 0x80A584B4:("sBlureP2LeftOffset","UNK_TYPE1","",0x1), + 0x80A584C0:("sBlureP2RightOffset","UNK_TYPE1","",0x1), + 0x80A584CC:("sDustVelocity","UNK_TYPE1","",0x1), 0x80A584E0:("D_80A584E0","f32","",0x4), 0x80A584E4:("D_80A584E4","f32","",0x4), 0x80A584E8:("D_80A584E8","f32","",0x4), @@ -12394,7 +12318,7 @@ 0x80A846A0:("D_80A846A0","f32","",0x4), 0x80A849D0:("D_80A849D0","UNK_TYPE4","",0x4), 0x80A85460:("Obj_Purify_InitVars","UNK_TYPE1","",0x1), - 0x80A85480:("D_80A85480","UNK_TYPE1","",0x1), + 0x80A85480:("ObjPurifyInfoList","UNK_TYPE1","",0x1), 0x80A854A0:("D_80A854A0","UNK_TYPE1","",0x1), 0x80A88910:("D_80A88910","UNK_TYPE1","",0x1), 0x80A88918:("D_80A88918","UNK_TYPE1","",0x1), @@ -12418,7 +12342,7 @@ 0x80A8B280:("D_80A8B280","UNK_TYPE1","",0x1), 0x80A8B2A0:("D_80A8B2A0","UNK_TYPE1","",0x1), 0x80A8B2CC:("D_80A8B2CC","UNK_TYPE1","",0x1), - 0x80A8B2D8:("D_80A8B2D8","UNK_TYPE1","",0x1), + 0x80A8B2D8:("sAnimationInfo","UNK_TYPE1","",0x1), 0x80A8B3D8:("D_80A8B3D8","UNK_TYPE1","",0x1), 0x80A8B3E4:("D_80A8B3E4","UNK_TYPE1","",0x1), 0x80A8B3F0:("D_80A8B3F0","UNK_TYPE1","",0x1), @@ -13249,7 +13173,7 @@ 0x80ADD940:("D_80ADD940","UNK_TYPE1","",0x1), 0x80ADD944:("En_Sellnuts_InitVars","UNK_TYPE1","",0x1), 0x80ADD964:("D_80ADD964","UNK_TYPE1","",0x1), - 0x80ADD990:("D_80ADD990","UNK_TYPE1","",0x1), + 0x80ADD990:("sAnimationInfo","UNK_TYPE1","",0x1), 0x80ADDB00:("D_80ADDB00","UNK_TYPE1","",0x1), 0x80ADDB10:("jtbl_80ADDB10","UNK_PTR","",0x4), 0x80ADDB4C:("D_80ADDB4C","f32","",0x4), @@ -13910,10 +13834,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), @@ -13950,7 +13872,7 @@ 0x80B1A348:("D_80B1A348","f32","",0x4), 0x80B1A34C:("D_80B1A34C","f32","",0x4), 0x80B1DA30:("D_80B1DA30","UNK_TYPE1","",0x1), - 0x80B1DA40:("D_80B1DA40","UNK_TYPE1","",0x1), + 0x80B1DA40:("sPoSisterEnvColors","UNK_TYPE1","",0x1), 0x80B1DA50:("En_Po_Sisters_InitVars","UNK_TYPE1","",0x1), 0x80B1DA70:("D_80B1DA70","UNK_TYPE1","",0x1), 0x80B1DA9C:("D_80B1DA9C","UNK_TYPE1","",0x1), @@ -13981,27 +13903,22 @@ 0x80B1DB54:("D_80B1DB54","f32","",0x4), 0x80B1DB58:("D_80B1DB58","f32","",0x4), 0x80B1DB5C:("D_80B1DB5C","f32","",0x4), - 0x80B21620:("D_80B21620","UNK_TYPE4","",0x4), - 0x80B21624:("D_80B21624","UNK_TYPE1","",0x1), + 0x80B21620:("sCurrentDeadBodyPartIndex","UNK_TYPE4","",0x4), + 0x80B21624:("sDamageTable","UNK_TYPE1","",0x1), 0x80B21644:("En_Pp_InitVars","UNK_TYPE1","",0x1), - 0x80B21664:("D_80B21664","UNK_TYPE1","",0x1), - 0x80B21688:("D_80B21688","UNK_TYPE1","",0x1), - 0x80B21698:("D_80B21698","UNK_TYPE1","",0x1), - 0x80B216BC:("D_80B216BC","UNK_TYPE1","",0x1), - 0x80B216CC:("D_80B216CC","UNK_TYPE1","",0x1), - 0x80B2171C:("D_80B2171C","UNK_TYPE1","",0x1), - 0x80B21720:("D_80B21720","UNK_TYPE1","",0x1), - 0x80B21724:("D_80B21724","UNK_TYPE1","",0x1), - 0x80B2174C:("D_80B2174C","UNK_TYPE1","",0x1), - 0x80B21758:("D_80B21758","UNK_TYPE2","",0x2), - 0x80B2175E:("D_80B2175E","UNK_TYPE1","",0x1), - 0x80B21760:("D_80B21760","UNK_TYPE4","",0x4), - 0x80B217CC:("D_80B217CC","f32","",0x4), - 0x80B217D0:("D_80B217D0","f32","",0x4), - 0x80B217D4:("D_80B217D4","f32","",0x4), - 0x80B217D8:("D_80B217D8","f32","",0x4), - 0x80B217DC:("D_80B217DC","f32","",0x4), - 0x80B217E0:("D_80B217E0","f32","",0x4), + 0x80B21664:("sMaskColliderJntSphElementsInit","UNK_TYPE1","",0x1), + 0x80B21688:("sMaskColliderJntSphInit","UNK_TYPE1","",0x1), + 0x80B21698:("sBodyColliderJntSphElementsInit","UNK_TYPE1","",0x1), + 0x80B216BC:("sBodyColliderJntSphInit","UNK_TYPE1","",0x1), + 0x80B216CC:("sQuadInit","UNK_TYPE1","",0x1), + 0x80B2171C:("sDustPrimColor","UNK_TYPE1","",0x1), + 0x80B21720:("sDustEnvColor","UNK_TYPE1","",0x1), + 0x80B21724:("sAnimations","UNK_TYPE1","",0x1), + 0x80B2174C:("sAnimationModes","UNK_TYPE1","",0x1), + 0x80B21758:("sLedgeCheckAngles","UNK_TYPE2","",0x2), + 0x80B21760:("sMaskFireVelocityAndAccel","UNK_TYPE4","",0x4), + 0x80B217CC:("sVertexOffset1","f32","",0x4), + 0x80B217D8:("sVertexOffset2","f32","",0x4), 0x80B217F0:("D_80B217F0","f32","",0x4), 0x80B217F4:("jtbl_80B217F4","UNK_PTR","",0x4), 0x80B21810:("D_80B21810","f32","",0x4), @@ -14370,7 +14287,7 @@ 0x80B3DED0:("D_80B3DED0","f32","",0x4), 0x80B3FBD0:("En_Dai_InitVars","UNK_TYPE1","",0x1), 0x80B3FBF0:("D_80B3FBF0","UNK_TYPE4","",0x4), - 0x80B3FBFC:("D_80B3FBFC","UNK_TYPE1","",0x1), + 0x80B3FBFC:("sAnimationInfo","UNK_TYPE1","",0x1), 0x80B3FC8C:("D_80B3FC8C","UNK_TYPE1","",0x1), 0x80B3FCB4:("D_80B3FCB4","UNK_TYPE4","",0x4), 0x80B3FCE4:("D_80B3FCE4","UNK_TYPE4","",0x4), @@ -14416,11 +14333,11 @@ 0x80B4E934:("D_80B4E934","UNK_TYPE4","",0x4), 0x80B4E938:("D_80B4E938","f32","",0x4), 0x80B4E940:("D_80B4E940","UNK_TYPE4","",0x4), - 0x80B4E944:("D_80B4E944","UNK_TYPE4","",0x4), - 0x80B4E958:("D_80B4E958","UNK_TYPE4","",0x4), + 0x80B4E944:("sRomaniEyeTextures","UNK_TYPE4","",0x4), + 0x80B4E958:("sRomaniMouthTextures","UNK_TYPE4","",0x4), 0x80B4E968:("D_80B4E968","UNK_TYPE1","",0x1), - 0x80B4E96C:("D_80B4E96C","UNK_TYPE4","",0x4), - 0x80B4E984:("D_80B4E984","UNK_TYPE4","",0x4), + 0x80B4E96C:("sCremiaEyeTextures","UNK_TYPE4","",0x4), + 0x80B4E984:("sCremiaMouthTextures","UNK_TYPE4","",0x4), 0x80B4E994:("D_80B4E994","UNK_TYPE1","",0x1), 0x80B4E998:("D_80B4E998","UNK_TYPE1","",0x1), 0x80B4E99C:("D_80B4E99C","UNK_TYPE1","",0x1), @@ -14646,8 +14563,8 @@ 0x80B503F0:("D_80B503F0","UNK_TYPE4","",0x4), 0x80B503F4:("D_80B503F4","UNK_TYPE4","",0x4), 0x80B503F8:("D_80B503F8","UNK_TYPE4","",0x4), - 0x80B503FC:("D_80B503FC","UNK_TYPE4","",0x4), - 0x80B50400:("D_80B50400","UNK_TYPE4","",0x4), + 0x80B503FC:("sAlienEyeBeamTexAnim","UNK_TYPE4","",0x4), + 0x80B50400:("sAlienEmptyTexAnim","UNK_TYPE4","",0x4), 0x80B50404:("D_80B50404","UNK_TYPE2","",0x2), 0x80B50406:("D_80B50406","UNK_TYPE2","",0x2), 0x80B5040A:("D_80B5040A","UNK_TYPE1","",0x1), @@ -15063,7 +14980,7 @@ 0x80B774F0:("En_Tru_Mt_InitVars","UNK_TYPE1","",0x1), 0x80B77510:("D_80B77510","UNK_TYPE1","",0x1), 0x80B7753C:("D_80B7753C","UNK_TYPE1","",0x1), - 0x80B7755C:("D_80B7755C","UNK_TYPE1","",0x1), + 0x80B7755C:("sAnimationInfo","UNK_TYPE1","",0x1), 0x80B7765C:("D_80B7765C","UNK_TYPE1","",0x1), 0x80B77668:("D_80B77668","UNK_TYPE1","",0x1), 0x80B77674:("D_80B77674","UNK_TYPE4","",0x4), @@ -15071,14 +14988,12 @@ 0x80B77684:("D_80B77684","f32","",0x4), 0x80B77688:("D_80B77688","f32","",0x4), 0x80B7C0F0:("Obj_Um_InitVars","UNK_TYPE1","",0x1), - 0x80B7C110:("D_80B7C110","UNK_TYPE1","",0x1), - 0x80B7C128:("D_80B7C128","UNK_TYPE1","",0x1), - 0x80B7C138:("D_80B7C138","UNK_TYPE1","",0x1), + 0x80B7C110:("sEyeTextures","UNK_TYPE1","",0x1), + 0x80B7C128:("sMouthTextures","UNK_TYPE1","",0x1), + 0x80B7C138:("sCylinderInit","UNK_TYPE1","",0x1), 0x80B7C164:("D_80B7C164","UNK_TYPE4","",0x4), - 0x80B7C254:("D_80B7C254","UNK_TYPE4","",0x4), - 0x80B7C25C:("D_80B7C25C","UNK_TYPE1","",0x1), - 0x80B7C260:("D_80B7C260","UNK_TYPE1","",0x1), - 0x80B7C274:("D_80B7C274","UNK_TYPE1","",0x1), + 0x80B7C254:("sInitChain","UNK_TYPE4","",0x4), + 0x80B7C25C:("sUmAnims","UNK_TYPE1","[5]",0x28), 0x80B7C284:("D_80B7C284","UNK_TYPE4","",0x4), 0x80B7C290:("D_80B7C290","UNK_TYPE4","",0x4), 0x80B7C29C:("D_80B7C29C","UNK_TYPE4","",0x4), @@ -15694,12 +15609,12 @@ 0x80BBC75C:("D_80BBC75C","UNK_TYPE1","",0x1), 0x80BBC770:("D_80BBC770","f32","",0x4), 0x80BBC774:("jtbl_80BBC774","UNK_PTR","",0x4), - 0x80BBF800:("En_S_Goro_InitVars","UNK_TYPE1","",0x1), - 0x80BBF820:("D_80BBF820","UNK_TYPE1","",0x1), - 0x80BBF84C:("D_80BBF84C","UNK_TYPE1","",0x1), - 0x80BBF858:("D_80BBF858","UNK_TYPE1","",0x1), - 0x80BBF878:("D_80BBF878","UNK_TYPE1","",0x1), - 0x80BBF978:("D_80BBF978","UNK_TYPE1","",0x1), + 0x80BBF800:("En_S_Goro_InitVars","ActorInit","",0x20), + 0x80BBF820:("sCylinderInit","ColliderCylinderInit","",0x2C), + 0x80BBF84C:("sColChkInfoInit","CollisionCheckInfoInit2","",0xC), + 0x80BBF858:("sDamageTable","DamageTable","",0x20), + 0x80BBF878:("sAnimationInfo","AnimationInfoS","[16]",0x100), + 0x80BBF978:("sEyeTextures","TexturePtr","[4]",0x18), 0x80BBF990:("jtbl_80BBF990","UNK_PTR","",0x4), 0x80BBF9B4:("jtbl_80BBF9B4","UNK_PTR","",0x4), 0x80BBFA34:("D_80BBFA34","f32","",0x4), @@ -15785,9 +15700,9 @@ 0x80BC7960:("En_Guruguru_InitVars","UNK_TYPE1","",0x1), 0x80BC7980:("D_80BC7980","UNK_TYPE1","",0x1), 0x80BC79A0:("D_80BC79A0","UNK_TYPE1","",0x1), - 0x80BC79CC:("D_80BC79CC","UNK_TYPE1","",0x1), - 0x80BC79D4:("D_80BC79D4","UNK_TYPE1","",0x1), - 0x80BC79D8:("D_80BC79D8","UNK_TYPE1","",0x1), + 0x80BC79CC:("sAnimations","UNK_TYPE1","",0x1), + 0x80BC79D4:("sAnimationModes","UNK_TYPE1","",0x1), + 0x80BC79D8:("sPlaySpeeds","UNK_TYPE1","",0x1), 0x80BC79E0:("D_80BC79E0","UNK_TYPE1","",0x1), 0x80BC79E8:("D_80BC79E8","UNK_TYPE1","",0x1), 0x80BC7EF0:("Oceff_Wipe5_InitVars","UNK_TYPE1","",0x1), @@ -15892,7 +15807,7 @@ 0x80BCF0C0:("D_80BCF0C0","f32","",0x4), 0x80BCF0C4:("D_80BCF0C4","f32","",0x4), 0x80BCF0C8:("D_80BCF0C8","f32","",0x4), - 0x80BCF1C0:("D_80BCF1C0","UNK_TYPE1","",0x1), + 0x80BCF1C0:("sVtxAlpha","UNK_TYPE1","",0x1), 0x80BCF1C1:("D_80BCF1C1","UNK_TYPE1","",0x1), 0x80BCF1C4:("D_80BCF1C4","UNK_TYPE1","",0x1), 0x80BCFF90:("En_Hg_InitVars","UNK_TYPE1","",0x1), @@ -15971,8 +15886,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), @@ -16145,17 +16059,17 @@ 0x80BE8DF0:("En_Baisen_InitVars","UNK_TYPE1","",0x1), 0x80BE8E10:("D_80BE8E10","UNK_TYPE1","",0x1), 0x80BE8E3C:("D_80BE8E3C","UNK_TYPE1","",0x1), - 0x80BE8E4C:("D_80BE8E4C","UNK_TYPE1","",0x1), + 0x80BE8E4C:("sAnimations","UNK_TYPE1","",0x1), 0x80BE8E58:("D_80BE8E58","UNK_TYPE1","",0x1), 0x80BE9430:("En_Heishi_InitVars","UNK_TYPE1","",0x1), 0x80BE9450:("sCylinderInit","UNK_TYPE1","",0x1), 0x80BE947C:("sAnimations","UNK_TYPE1","",0x1), - 0x80BE9490:("sAnimModes","UNK_TYPE1","",0x1), + 0x80BE9490:("sAnimationModes","UNK_TYPE1","",0x1), 0x80BE9A30:("En_Demo_heishi_InitVars","UNK_TYPE1","",0x1), 0x80BE9A50:("sCylinderInit","UNK_TYPE1","",0x1), 0x80BE9A7C:("sTextIds","UNK_TYPE1","",0x1), 0x80BE9A80:("sAnimations","UNK_TYPE1","",0x1), - 0x80BE9A94:("sAnimModes","UNK_TYPE1","",0x1), + 0x80BE9A94:("sAnimationModes","UNK_TYPE1","",0x1), 0x80BEB1B0:("En_Dt_InitVars","UNK_TYPE1","",0x1), 0x80BEB1D0:("D_80BEB1D0","UNK_TYPE1","",0x1), 0x80BEB208:("D_80BEB208","UNK_TYPE1","",0x1), @@ -16400,7 +16314,7 @@ 0x80C058A0:("sTextIds","u16","",0x1), 0x80C058B0:("sCylinderInit","UNK_TYPE1","",0x1), 0x80C058DC:("sAnimations","AnimationHeader*","",0x1), - 0x80C058F8:("sAnimModes","u8","",0x1), + 0x80C058F8:("sAnimationModes","u8","",0x1), 0x80C05900:("sSetPrimColorDL","UNK_TYPE1","",0x1), 0x80C05910:("sSetPrimColorDlPtr","Gfx*","",0x4), 0x80C05914:("sEyeTextures","void*","",0x1), @@ -16651,7 +16565,7 @@ 0x80C1C250:("Dm_Al_InitVars","UNK_TYPE1","",0x1), 0x80C1C270:("D_80C1C270","UNK_TYPE1","",0x1), 0x80C1C280:("D_80C1C280","UNK_TYPE4","",0x4), - 0x80C1C294:("D_80C1C294","UNK_TYPE4","",0x4), + 0x80C1C294:("sDlists","UNK_TYPE4","",0x4), 0x80C1C2AC:("D_80C1C2AC","UNK_TYPE1","",0x1), 0x80C1C2B0:("jtbl_80C1C2B0","UNK_PTR","",0x4), 0x80C1C2E4:("jtbl_80C1C2E4","UNK_PTR","",0x4), @@ -16671,7 +16585,7 @@ 0x80C1DE20:("D_80C1DE20","UNK_TYPE4","",0x4), 0x80C1DE28:("D_80C1DE28","UNK_TYPE1","",0x1), 0x80C1E1E0:("Dm_Nb_InitVars","UNK_TYPE1","",0x1), - 0x80C1E200:("D_80C1E200","UNK_TYPE1","",0x1), + 0x80C1E200:("sAnimationInfo","UNK_TYPE1","",0x1), 0x80C1E210:("D_80C1E210","UNK_TYPE4","",0x4), 0x80C1E5C0:("En_Drs_InitVars","UNK_TYPE1","",0x1), 0x80C1E5E0:("D_80C1E5E0","UNK_TYPE1","",0x1), @@ -16681,7 +16595,7 @@ 0x80C1E970:("D_80C1E970","UNK_TYPE1","",0x1), 0x80C1E984:("D_80C1E984","UNK_TYPE1","",0x1), 0x80C1F150:("Dm_Bal_InitVars","UNK_TYPE1","",0x1), - 0x80C1F170:("D_80C1F170","UNK_PTR","",0x4), + 0x80C1F170:("sAnimationInfo","UNK_PTR","",0x4), 0x80C1F2C0:("D_80C1F2C0","UNK_TYPE2","",0x2), 0x80C1F2C4:("D_80C1F2C4","UNK_TYPE4","",0x4), 0x80C1F2D0:("D_80C1F2D0","UNK_TYPE1","",0x1), diff --git a/tools/entr.py b/tools/entr.py new file mode 100755 index 000000000..9b16556c5 --- /dev/null +++ b/tools/entr.py @@ -0,0 +1,132 @@ +#!/usr/bin/env python3 + +enumPrfix = "ENTR_SCENE_" +entranceScenes = [ + "ENTR_SCENE_MAYORS_RESIDENCE", + "ENTR_SCENE_MAJORAS_LAIR", + "ENTR_SCENE_MAGIC_HAGS_POTION_SHOP", + "ENTR_SCENE_RANCH_HOUSE", + "ENTR_SCENE_HONEY_AND_DARLINGS_SHOP", + "ENTR_SCENE_BENEATH_THE_GRAVERYARD", + "ENTR_SCENE_SOUTHERN_SWAMP_CLEARED", + "ENTR_SCENE_CURIOSITY_SHOP", + "ENTR_SCENE_UNSET_08", + "ENTR_SCENE_UNSET_09", + "ENTR_SCENE_GROTTOS", + "ENTR_SCENE_UNSET_0B", + "ENTR_SCENE_UNSET_0C", + "ENTR_SCENE_UNSET_0D", + "ENTR_SCENE_CUTSCENE", + "ENTR_SCENE_UNSET_0F", + "ENTR_SCENE_IKANA_CANYON", + "ENTR_SCENE_PIRATES_FORTRESS", + "ENTR_SCENE_MILK_BAR", + "ENTR_SCENE_STONE_TOWER_TEMPLE", + "ENTR_SCENE_TREASURE_CHEST_SHOP", + "ENTR_SCENE_STONE_TOWER_TEMPLE_REVERSED", + "ENTR_SCENE_CLOCK_TOWER_ROOFTOP", + "ENTR_SCENE_OPENING_DUNGEON", + "ENTR_SCENE_WOODFALL_TEMPLE", + "ENTR_SCENE_PATH_TO_MOUNTAIN_VILLAGE", + "ENTR_SCENE_IKANA_CASTLE", + "ENTR_SCENE_DEKU_SCRUB_PLAYGROUND", + "ENTR_SCENE_ODOLWAS_LAIR", + "ENTR_SCENE_TOWN_SHOOTING_GALLERY", + "ENTR_SCENE_SNOWHEAD_TEMPLE", + "ENTR_SCENE_MILK_ROAD", + "ENTR_SCENE_PIRATES_FORTRESS_INTERIOR", + "ENTR_SCENE_SWAMP_SHOOTING_GALLERY", + "ENTR_SCENE_PINNACLE_ROCK", + "ENTR_SCENE_FAIRY_FOUNTAIN", + "ENTR_SCENE_SWAMP_SPIDER_HOUSE", + "ENTR_SCENE_OCEANSIDE_SPIDER_HOUSE", + "ENTR_SCENE_ASTRAL_OBSERVATORY", + "ENTR_SCENE_MOON_DEKU_TRIAL", + "ENTR_SCENE_DEKU_PALACE", + "ENTR_SCENE_MOUNTAIN_SMITHY", + "ENTR_SCENE_TERMINA_FIELD", + "ENTR_SCENE_POST_OFFICE", + "ENTR_SCENE_MARINE_RESEARCH_LAB", + "ENTR_SCENE_DAMPES_HOUSE", + "ENTR_SCENE_UNSET_2E", + "ENTR_SCENE_GORON_SHRINE", + "ENTR_SCENE_ZORA_HALL", + "ENTR_SCENE_TRADING_POST", + "ENTR_SCENE_ROMANI_RANCH", + "ENTR_SCENE_TWINMOLDS_LAIR", + "ENTR_SCENE_GREAT_BAY_COAST", + "ENTR_SCENE_ZORA_CAPE", + "ENTR_SCENE_LOTTERY_SHOP", + "ENTR_SCENE_UNSET_37", + "ENTR_SCENE_PIRATES_FORTRESS_EXTERIOR", + "ENTR_SCENE_FISHERMANS_HUT", + "ENTR_SCENE_GORON_SHOP", + "ENTR_SCENE_DEKU_KINGS_CHAMBER", + "ENTR_SCENE_MOON_GORON_TRIAL", + "ENTR_SCENE_ROAD_TO_SOUTHERN_SWAMP", + "ENTR_SCENE_DOGGY_RACETRACK", + "ENTR_SCENE_CUCCO_SHACK", + "ENTR_SCENE_IKANA_GRAVEYARD", + "ENTR_SCENE_GOHTS_LAIR", + "ENTR_SCENE_SOUTHERN_SWAMP_POISONED", + "ENTR_SCENE_WOODFALL", + "ENTR_SCENE_MOON_ZORA_TRIAL", + "ENTR_SCENE_GORON_VILLAGE_SPRING", + "ENTR_SCENE_GREAT_BAY_TEMPLE", + "ENTR_SCENE_WATERFALL_RAPIDS", + "ENTR_SCENE_BENEATH_THE_WELL", + "ENTR_SCENE_ZORA_HALL_ROOMS", + "ENTR_SCENE_GORON_VILLAGE_WINTER", + "ENTR_SCENE_GORON_GRAVERYARD", + "ENTR_SCENE_SAKONS_HIDEOUT", + "ENTR_SCENE_MOUNTAIN_VILLAGE_WINTER", + "ENTR_SCENE_GHOST_HUT", + "ENTR_SCENE_DEKU_SHRINE", + "ENTR_SCENE_ROAD_TO_IKANA", + "ENTR_SCENE_SWORDMANS_SCHOOL", + "ENTR_SCENE_MUSIC_BOX_HOUSE", + "ENTR_SCENE_IGOS_DU_IKANAS_LAIR", + "ENTR_SCENE_TOURIST_INFORMATION", + "ENTR_SCENE_STONE_TOWER", + "ENTR_SCENE_STONE_TOWER_INVERTED", + "ENTR_SCENE_MOUNTAIN_VILLAGE_SPRING", + "ENTR_SCENE_PATH_TO_SNOWHEAD", + "ENTR_SCENE_SNOWHEAD", + "ENTR_SCENE_PATH_TO_GORON_VILLAGE_WINTER", + "ENTR_SCENE_PATH_TO_GORON_VILLAGE_SPRING", + "ENTR_SCENE_GYORGS_LAIR", + "ENTR_SCENE_SECRET_SHRINE", + "ENTR_SCENE_STOCK_POT_INN", + "ENTR_SCENE_GREAT_BAY_CUTSCENE", + "ENTR_SCENE_CLOCK_TOWER_INTERIOR", + "ENTR_SCENE_WOODS_OF_MYSTERY", + "ENTR_SCENE_LOST_WOODS", + "ENTR_SCENE_MOON_LINK_TRIAL", + "ENTR_SCENE_THE_MOON", + "ENTR_SCENE_BOMB_SHOP", + "ENTR_SCENE_GIANTS_CHAMBER", + "ENTR_SCENE_GORMAN_TRACK", + "ENTR_SCENE_GORON_RACETRACK", + "ENTR_SCENE_EAST_CLOCK_TOWN", + "ENTR_SCENE_WEST_CLOCK_TOWN", + "ENTR_SCENE_NORTH_CLOCK_TOWN", + "ENTR_SCENE_SOUTH_CLOCK_TOWN", + "ENTR_SCENE_LAUNDRY_POOL", + "ENTR_SCENE_MAX" +] + +def macro(num): + sceneIndex = (num >> 9) & 0x7F + spawnIndex = (num >> 4) & 0x1F + return f'ENTRANCE({entranceScenes[sceneIndex][len(enumPrfix):]}, {spawnIndex})' + +if __name__ == "__main__": + import sys + + if len(sys.argv) < 2: + print(f'{sys.argv[0]} nextEntrance', file=sys.stderr) + exit(1) + + nextEntrance = sys.argv[1] + nextEntrance = int(nextEntrance, 16 if nextEntrance.startswith("0x") else 10) + print(macro(nextEntrance)) diff --git a/tools/fado/.clang-format b/tools/fado/.clang-format new file mode 100644 index 000000000..c7b900f06 --- /dev/null +++ b/tools/fado/.clang-format @@ -0,0 +1,23 @@ +IndentWidth: 4 +Language: Cpp +UseTab: Never +ColumnLimit: 120 +PointerAlignment: Left +BreakBeforeBraces: Attach +SpaceAfterCStyleCast: false +Cpp11BracedListStyle: false +IndentCaseLabels: true +BinPackArguments: true +BinPackParameters: true +AlignAfterOpenBracket: Align +AlignOperands: true +BreakBeforeTernaryOperators: true +BreakBeforeBinaryOperators: None +AllowShortBlocksOnASingleLine: true +AllowShortIfStatementsOnASingleLine: false +AllowShortLoopsOnASingleLine: false +AllowShortCaseLabelsOnASingleLine: false +AllowShortFunctionsOnASingleLine: false +AlignEscapedNewlines: Left +AlignTrailingComments: true +SortIncludes: false diff --git a/tools/fado/.gitignore b/tools/fado/.gitignore new file mode 100644 index 000000000..83b94860c --- /dev/null +++ b/tools/fado/.gitignore @@ -0,0 +1,56 @@ +# Prerequisites +*.d + +# Object files +*.o +*.ko +*.obj +*.elf + +# Linker output +*.ilk +*.map +*.exp + +# Precompiled Headers +*.gch +*.pch + +# Libraries +*.lib +*.a +*.la +*.lo + +# Shared objects (inc. Windows DLLs) +*.dll +*.so +*.so.* +*.dylib + +# Executables +*.exe +*.out +*.app +*.i*86 +*.x86_64 +*.hex + +# Debug files +*.dSYM/ +*.su +*.idb +*.pdb + +# Kernel Module Compile Results +*.mod* +*.cmd +.tmp_versions/ +modules.order +Module.symvers +Mkfile.old +dkms.conf + +# Custom +build/ +.vscode diff --git a/tools/fado/.gitrepo b/tools/fado/.gitrepo new file mode 100644 index 000000000..cedec4930 --- /dev/null +++ b/tools/fado/.gitrepo @@ -0,0 +1,12 @@ +; DO NOT EDIT (unless you know what you are doing) +; +; This subdirectory is a git "subrepo", and this file is maintained by the +; git-subrepo command. See https://github.com/git-commands/git-subrepo#readme +; +[subrepo] + remote = git@github.com:EllipticEllipsis/fado.git + branch = master + commit = f7efb10a9a65f27e9ccad7ce270234f20d386ac9 + parent = 90cfafec47fe4b73ad9009e9501e147e86025aa6 + method = merge + cmdver = 0.4.3 diff --git a/tools/fado/LICENSE b/tools/fado/LICENSE new file mode 100644 index 000000000..0ad25db4b --- /dev/null +++ b/tools/fado/LICENSE @@ -0,0 +1,661 @@ + GNU AFFERO GENERAL PUBLIC LICENSE + Version 3, 19 November 2007 + + Copyright (C) 2007 Free Software Foundation, Inc. + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + Preamble + + The GNU Affero General Public License is a free, copyleft license for +software and other kinds of works, specifically designed to ensure +cooperation with the community in the case of network server software. + + The licenses for most software and other practical works are designed +to take away your freedom to share and change the works. By contrast, +our General Public Licenses are intended to guarantee your freedom to +share and change all versions of a program--to make sure it remains free +software for all its users. + + When we speak of free software, we are referring to freedom, not +price. Our General Public Licenses are designed to make sure that you +have the freedom to distribute copies of free software (and charge for +them if you wish), that you receive source code or can get it if you +want it, that you can change the software or use pieces of it in new +free programs, and that you know you can do these things. + + Developers that use our General Public Licenses protect your rights +with two steps: (1) assert copyright on the software, and (2) offer +you this License which gives you legal permission to copy, distribute +and/or modify the software. + + A secondary benefit of defending all users' freedom is that +improvements made in alternate versions of the program, if they +receive widespread use, become available for other developers to +incorporate. Many developers of free software are heartened and +encouraged by the resulting cooperation. However, in the case of +software used on network servers, this result may fail to come about. +The GNU General Public License permits making a modified version and +letting the public access it on a server without ever releasing its +source code to the public. + + The GNU Affero General Public License is designed specifically to +ensure that, in such cases, the modified source code becomes available +to the community. It requires the operator of a network server to +provide the source code of the modified version running there to the +users of that server. Therefore, public use of a modified version, on +a publicly accessible server, gives the public access to the source +code of the modified version. + + An older license, called the Affero General Public License and +published by Affero, was designed to accomplish similar goals. This is +a different license, not a version of the Affero GPL, but Affero has +released a new version of the Affero GPL which permits relicensing under +this license. + + The precise terms and conditions for copying, distribution and +modification follow. + + TERMS AND CONDITIONS + + 0. Definitions. + + "This License" refers to version 3 of the GNU Affero General Public License. + + "Copyright" also means copyright-like laws that apply to other kinds of +works, such as semiconductor masks. + + "The Program" refers to any copyrightable work licensed under this +License. Each licensee is addressed as "you". "Licensees" and +"recipients" may be individuals or organizations. + + To "modify" a work means to copy from or adapt all or part of the work +in a fashion requiring copyright permission, other than the making of an +exact copy. The resulting work is called a "modified version" of the +earlier work or a work "based on" the earlier work. + + A "covered work" means either the unmodified Program or a work based +on the Program. + + To "propagate" a work means to do anything with it that, without +permission, would make you directly or secondarily liable for +infringement under applicable copyright law, except executing it on a +computer or modifying a private copy. Propagation includes copying, +distribution (with or without modification), making available to the +public, and in some countries other activities as well. + + To "convey" a work means any kind of propagation that enables other +parties to make or receive copies. Mere interaction with a user through +a computer network, with no transfer of a copy, is not conveying. + + An interactive user interface displays "Appropriate Legal Notices" +to the extent that it includes a convenient and prominently visible +feature that (1) displays an appropriate copyright notice, and (2) +tells the user that there is no warranty for the work (except to the +extent that warranties are provided), that licensees may convey the +work under this License, and how to view a copy of this License. If +the interface presents a list of user commands or options, such as a +menu, a prominent item in the list meets this criterion. + + 1. Source Code. + + The "source code" for a work means the preferred form of the work +for making modifications to it. "Object code" means any non-source +form of a work. + + A "Standard Interface" means an interface that either is an official +standard defined by a recognized standards body, or, in the case of +interfaces specified for a particular programming language, one that +is widely used among developers working in that language. + + The "System Libraries" of an executable work include anything, other +than the work as a whole, that (a) is included in the normal form of +packaging a Major Component, but which is not part of that Major +Component, and (b) serves only to enable use of the work with that +Major Component, or to implement a Standard Interface for which an +implementation is available to the public in source code form. A +"Major Component", in this context, means a major essential component +(kernel, window system, and so on) of the specific operating system +(if any) on which the executable work runs, or a compiler used to +produce the work, or an object code interpreter used to run it. + + The "Corresponding Source" for a work in object code form means all +the source code needed to generate, install, and (for an executable +work) run the object code and to modify the work, including scripts to +control those activities. However, it does not include the work's +System Libraries, or general-purpose tools or generally available free +programs which are used unmodified in performing those activities but +which are not part of the work. For example, Corresponding Source +includes interface definition files associated with source files for +the work, and the source code for shared libraries and dynamically +linked subprograms that the work is specifically designed to require, +such as by intimate data communication or control flow between those +subprograms and other parts of the work. + + The Corresponding Source need not include anything that users +can regenerate automatically from other parts of the Corresponding +Source. + + The Corresponding Source for a work in source code form is that +same work. + + 2. Basic Permissions. + + All rights granted under this License are granted for the term of +copyright on the Program, and are irrevocable provided the stated +conditions are met. This License explicitly affirms your unlimited +permission to run the unmodified Program. The output from running a +covered work is covered by this License only if the output, given its +content, constitutes a covered work. This License acknowledges your +rights of fair use or other equivalent, as provided by copyright law. + + You may make, run and propagate covered works that you do not +convey, without conditions so long as your license otherwise remains +in force. You may convey covered works to others for the sole purpose +of having them make modifications exclusively for you, or provide you +with facilities for running those works, provided that you comply with +the terms of this License in conveying all material for which you do +not control copyright. Those thus making or running the covered works +for you must do so exclusively on your behalf, under your direction +and control, on terms that prohibit them from making any copies of +your copyrighted material outside their relationship with you. + + Conveying under any other circumstances is permitted solely under +the conditions stated below. Sublicensing is not allowed; section 10 +makes it unnecessary. + + 3. Protecting Users' Legal Rights From Anti-Circumvention Law. + + No covered work shall be deemed part of an effective technological +measure under any applicable law fulfilling obligations under article +11 of the WIPO copyright treaty adopted on 20 December 1996, or +similar laws prohibiting or restricting circumvention of such +measures. + + When you convey a covered work, you waive any legal power to forbid +circumvention of technological measures to the extent such circumvention +is effected by exercising rights under this License with respect to +the covered work, and you disclaim any intention to limit operation or +modification of the work as a means of enforcing, against the work's +users, your or third parties' legal rights to forbid circumvention of +technological measures. + + 4. Conveying Verbatim Copies. + + You may convey verbatim copies of the Program's source code as you +receive it, in any medium, provided that you conspicuously and +appropriately publish on each copy an appropriate copyright notice; +keep intact all notices stating that this License and any +non-permissive terms added in accord with section 7 apply to the code; +keep intact all notices of the absence of any warranty; and give all +recipients a copy of this License along with the Program. + + You may charge any price or no price for each copy that you convey, +and you may offer support or warranty protection for a fee. + + 5. Conveying Modified Source Versions. + + You may convey a work based on the Program, or the modifications to +produce it from the Program, in the form of source code under the +terms of section 4, provided that you also meet all of these conditions: + + a) The work must carry prominent notices stating that you modified + it, and giving a relevant date. + + b) The work must carry prominent notices stating that it is + released under this License and any conditions added under section + 7. This requirement modifies the requirement in section 4 to + "keep intact all notices". + + c) You must license the entire work, as a whole, under this + License to anyone who comes into possession of a copy. This + License will therefore apply, along with any applicable section 7 + additional terms, to the whole of the work, and all its parts, + regardless of how they are packaged. This License gives no + permission to license the work in any other way, but it does not + invalidate such permission if you have separately received it. + + d) If the work has interactive user interfaces, each must display + Appropriate Legal Notices; however, if the Program has interactive + interfaces that do not display Appropriate Legal Notices, your + work need not make them do so. + + A compilation of a covered work with other separate and independent +works, which are not by their nature extensions of the covered work, +and which are not combined with it such as to form a larger program, +in or on a volume of a storage or distribution medium, is called an +"aggregate" if the compilation and its resulting copyright are not +used to limit the access or legal rights of the compilation's users +beyond what the individual works permit. Inclusion of a covered work +in an aggregate does not cause this License to apply to the other +parts of the aggregate. + + 6. Conveying Non-Source Forms. + + You may convey a covered work in object code form under the terms +of sections 4 and 5, provided that you also convey the +machine-readable Corresponding Source under the terms of this License, +in one of these ways: + + a) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by the + Corresponding Source fixed on a durable physical medium + customarily used for software interchange. + + b) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by a + written offer, valid for at least three years and valid for as + long as you offer spare parts or customer support for that product + model, to give anyone who possesses the object code either (1) a + copy of the Corresponding Source for all the software in the + product that is covered by this License, on a durable physical + medium customarily used for software interchange, for a price no + more than your reasonable cost of physically performing this + conveying of source, or (2) access to copy the + Corresponding Source from a network server at no charge. + + c) Convey individual copies of the object code with a copy of the + written offer to provide the Corresponding Source. This + alternative is allowed only occasionally and noncommercially, and + only if you received the object code with such an offer, in accord + with subsection 6b. + + d) Convey the object code by offering access from a designated + place (gratis or for a charge), and offer equivalent access to the + Corresponding Source in the same way through the same place at no + further charge. You need not require recipients to copy the + Corresponding Source along with the object code. If the place to + copy the object code is a network server, the Corresponding Source + may be on a different server (operated by you or a third party) + that supports equivalent copying facilities, provided you maintain + clear directions next to the object code saying where to find the + Corresponding Source. Regardless of what server hosts the + Corresponding Source, you remain obligated to ensure that it is + available for as long as needed to satisfy these requirements. + + e) Convey the object code using peer-to-peer transmission, provided + you inform other peers where the object code and Corresponding + Source of the work are being offered to the general public at no + charge under subsection 6d. + + A separable portion of the object code, whose source code is excluded +from the Corresponding Source as a System Library, need not be +included in conveying the object code work. + + A "User Product" is either (1) a "consumer product", which means any +tangible personal property which is normally used for personal, family, +or household purposes, or (2) anything designed or sold for incorporation +into a dwelling. In determining whether a product is a consumer product, +doubtful cases shall be resolved in favor of coverage. For a particular +product received by a particular user, "normally used" refers to a +typical or common use of that class of product, regardless of the status +of the particular user or of the way in which the particular user +actually uses, or expects or is expected to use, the product. A product +is a consumer product regardless of whether the product has substantial +commercial, industrial or non-consumer uses, unless such uses represent +the only significant mode of use of the product. + + "Installation Information" for a User Product means any methods, +procedures, authorization keys, or other information required to install +and execute modified versions of a covered work in that User Product from +a modified version of its Corresponding Source. The information must +suffice to ensure that the continued functioning of the modified object +code is in no case prevented or interfered with solely because +modification has been made. + + If you convey an object code work under this section in, or with, or +specifically for use in, a User Product, and the conveying occurs as +part of a transaction in which the right of possession and use of the +User Product is transferred to the recipient in perpetuity or for a +fixed term (regardless of how the transaction is characterized), the +Corresponding Source conveyed under this section must be accompanied +by the Installation Information. But this requirement does not apply +if neither you nor any third party retains the ability to install +modified object code on the User Product (for example, the work has +been installed in ROM). + + The requirement to provide Installation Information does not include a +requirement to continue to provide support service, warranty, or updates +for a work that has been modified or installed by the recipient, or for +the User Product in which it has been modified or installed. Access to a +network may be denied when the modification itself materially and +adversely affects the operation of the network or violates the rules and +protocols for communication across the network. + + Corresponding Source conveyed, and Installation Information provided, +in accord with this section must be in a format that is publicly +documented (and with an implementation available to the public in +source code form), and must require no special password or key for +unpacking, reading or copying. + + 7. Additional Terms. + + "Additional permissions" are terms that supplement the terms of this +License by making exceptions from one or more of its conditions. +Additional permissions that are applicable to the entire Program shall +be treated as though they were included in this License, to the extent +that they are valid under applicable law. If additional permissions +apply only to part of the Program, that part may be used separately +under those permissions, but the entire Program remains governed by +this License without regard to the additional permissions. + + When you convey a copy of a covered work, you may at your option +remove any additional permissions from that copy, or from any part of +it. (Additional permissions may be written to require their own +removal in certain cases when you modify the work.) You may place +additional permissions on material, added by you to a covered work, +for which you have or can give appropriate copyright permission. + + Notwithstanding any other provision of this License, for material you +add to a covered work, you may (if authorized by the copyright holders of +that material) supplement the terms of this License with terms: + + a) Disclaiming warranty or limiting liability differently from the + terms of sections 15 and 16 of this License; or + + b) Requiring preservation of specified reasonable legal notices or + author attributions in that material or in the Appropriate Legal + Notices displayed by works containing it; or + + c) Prohibiting misrepresentation of the origin of that material, or + requiring that modified versions of such material be marked in + reasonable ways as different from the original version; or + + d) Limiting the use for publicity purposes of names of licensors or + authors of the material; or + + e) Declining to grant rights under trademark law for use of some + trade names, trademarks, or service marks; or + + f) Requiring indemnification of licensors and authors of that + material by anyone who conveys the material (or modified versions of + it) with contractual assumptions of liability to the recipient, for + any liability that these contractual assumptions directly impose on + those licensors and authors. + + All other non-permissive additional terms are considered "further +restrictions" within the meaning of section 10. If the Program as you +received it, or any part of it, contains a notice stating that it is +governed by this License along with a term that is a further +restriction, you may remove that term. If a license document contains +a further restriction but permits relicensing or conveying under this +License, you may add to a covered work material governed by the terms +of that license document, provided that the further restriction does +not survive such relicensing or conveying. + + If you add terms to a covered work in accord with this section, you +must place, in the relevant source files, a statement of the +additional terms that apply to those files, or a notice indicating +where to find the applicable terms. + + Additional terms, permissive or non-permissive, may be stated in the +form of a separately written license, or stated as exceptions; +the above requirements apply either way. + + 8. Termination. + + You may not propagate or modify a covered work except as expressly +provided under this License. Any attempt otherwise to propagate or +modify it is void, and will automatically terminate your rights under +this License (including any patent licenses granted under the third +paragraph of section 11). + + However, if you cease all violation of this License, then your +license from a particular copyright holder is reinstated (a) +provisionally, unless and until the copyright holder explicitly and +finally terminates your license, and (b) permanently, if the copyright +holder fails to notify you of the violation by some reasonable means +prior to 60 days after the cessation. + + Moreover, your license from a particular copyright holder is +reinstated permanently if the copyright holder notifies you of the +violation by some reasonable means, this is the first time you have +received notice of violation of this License (for any work) from that +copyright holder, and you cure the violation prior to 30 days after +your receipt of the notice. + + Termination of your rights under this section does not terminate the +licenses of parties who have received copies or rights from you under +this License. If your rights have been terminated and not permanently +reinstated, you do not qualify to receive new licenses for the same +material under section 10. + + 9. Acceptance Not Required for Having Copies. + + You are not required to accept this License in order to receive or +run a copy of the Program. Ancillary propagation of a covered work +occurring solely as a consequence of using peer-to-peer transmission +to receive a copy likewise does not require acceptance. However, +nothing other than this License grants you permission to propagate or +modify any covered work. These actions infringe copyright if you do +not accept this License. Therefore, by modifying or propagating a +covered work, you indicate your acceptance of this License to do so. + + 10. Automatic Licensing of Downstream Recipients. + + Each time you convey a covered work, the recipient automatically +receives a license from the original licensors, to run, modify and +propagate that work, subject to this License. You are not responsible +for enforcing compliance by third parties with this License. + + An "entity transaction" is a transaction transferring control of an +organization, or substantially all assets of one, or subdividing an +organization, or merging organizations. If propagation of a covered +work results from an entity transaction, each party to that +transaction who receives a copy of the work also receives whatever +licenses to the work the party's predecessor in interest had or could +give under the previous paragraph, plus a right to possession of the +Corresponding Source of the work from the predecessor in interest, if +the predecessor has it or can get it with reasonable efforts. + + You may not impose any further restrictions on the exercise of the +rights granted or affirmed under this License. For example, you may +not impose a license fee, royalty, or other charge for exercise of +rights granted under this License, and you may not initiate litigation +(including a cross-claim or counterclaim in a lawsuit) alleging that +any patent claim is infringed by making, using, selling, offering for +sale, or importing the Program or any portion of it. + + 11. Patents. + + A "contributor" is a copyright holder who authorizes use under this +License of the Program or a work on which the Program is based. The +work thus licensed is called the contributor's "contributor version". + + A contributor's "essential patent claims" are all patent claims +owned or controlled by the contributor, whether already acquired or +hereafter acquired, that would be infringed by some manner, permitted +by this License, of making, using, or selling its contributor version, +but do not include claims that would be infringed only as a +consequence of further modification of the contributor version. For +purposes of this definition, "control" includes the right to grant +patent sublicenses in a manner consistent with the requirements of +this License. + + Each contributor grants you a non-exclusive, worldwide, royalty-free +patent license under the contributor's essential patent claims, to +make, use, sell, offer for sale, import and otherwise run, modify and +propagate the contents of its contributor version. + + In the following three paragraphs, a "patent license" is any express +agreement or commitment, however denominated, not to enforce a patent +(such as an express permission to practice a patent or covenant not to +sue for patent infringement). To "grant" such a patent license to a +party means to make such an agreement or commitment not to enforce a +patent against the party. + + If you convey a covered work, knowingly relying on a patent license, +and the Corresponding Source of the work is not available for anyone +to copy, free of charge and under the terms of this License, through a +publicly available network server or other readily accessible means, +then you must either (1) cause the Corresponding Source to be so +available, or (2) arrange to deprive yourself of the benefit of the +patent license for this particular work, or (3) arrange, in a manner +consistent with the requirements of this License, to extend the patent +license to downstream recipients. "Knowingly relying" means you have +actual knowledge that, but for the patent license, your conveying the +covered work in a country, or your recipient's use of the covered work +in a country, would infringe one or more identifiable patents in that +country that you have reason to believe are valid. + + If, pursuant to or in connection with a single transaction or +arrangement, you convey, or propagate by procuring conveyance of, a +covered work, and grant a patent license to some of the parties +receiving the covered work authorizing them to use, propagate, modify +or convey a specific copy of the covered work, then the patent license +you grant is automatically extended to all recipients of the covered +work and works based on it. + + A patent license is "discriminatory" if it does not include within +the scope of its coverage, prohibits the exercise of, or is +conditioned on the non-exercise of one or more of the rights that are +specifically granted under this License. You may not convey a covered +work if you are a party to an arrangement with a third party that is +in the business of distributing software, under which you make payment +to the third party based on the extent of your activity of conveying +the work, and under which the third party grants, to any of the +parties who would receive the covered work from you, a discriminatory +patent license (a) in connection with copies of the covered work +conveyed by you (or copies made from those copies), or (b) primarily +for and in connection with specific products or compilations that +contain the covered work, unless you entered into that arrangement, +or that patent license was granted, prior to 28 March 2007. + + Nothing in this License shall be construed as excluding or limiting +any implied license or other defenses to infringement that may +otherwise be available to you under applicable patent law. + + 12. No Surrender of Others' Freedom. + + If conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot convey a +covered work so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you may +not convey it at all. For example, if you agree to terms that obligate you +to collect a royalty for further conveying from those to whom you convey +the Program, the only way you could satisfy both those terms and this +License would be to refrain entirely from conveying the Program. + + 13. Remote Network Interaction; Use with the GNU General Public License. + + Notwithstanding any other provision of this License, if you modify the +Program, your modified version must prominently offer all users +interacting with it remotely through a computer network (if your version +supports such interaction) an opportunity to receive the Corresponding +Source of your version by providing access to the Corresponding Source +from a network server at no charge, through some standard or customary +means of facilitating copying of software. This Corresponding Source +shall include the Corresponding Source for any work covered by version 3 +of the GNU General Public License that is incorporated pursuant to the +following paragraph. + + Notwithstanding any other provision of this License, you have +permission to link or combine any covered work with a work licensed +under version 3 of the GNU General Public License into a single +combined work, and to convey the resulting work. The terms of this +License will continue to apply to the part which is the covered work, +but the work with which it is combined will remain governed by version +3 of the GNU General Public License. + + 14. Revised Versions of this License. + + The Free Software Foundation may publish revised and/or new versions of +the GNU Affero General Public License from time to time. Such new versions +will be similar in spirit to the present version, but may differ in detail to +address new problems or concerns. + + Each version is given a distinguishing version number. If the +Program specifies that a certain numbered version of the GNU Affero General +Public License "or any later version" applies to it, you have the +option of following the terms and conditions either of that numbered +version or of any later version published by the Free Software +Foundation. If the Program does not specify a version number of the +GNU Affero General Public License, you may choose any version ever published +by the Free Software Foundation. + + If the Program specifies that a proxy can decide which future +versions of the GNU Affero General Public License can be used, that proxy's +public statement of acceptance of a version permanently authorizes you +to choose that version for the Program. + + Later license versions may give you additional or different +permissions. However, no additional obligations are imposed on any +author or copyright holder as a result of your choosing to follow a +later version. + + 15. Disclaimer of Warranty. + + THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY +APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT +HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY +OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, +THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM +IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF +ALL NECESSARY SERVICING, REPAIR OR CORRECTION. + + 16. Limitation of Liability. + + IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS +THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY +GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE +USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF +DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD +PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), +EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF +SUCH DAMAGES. + + 17. Interpretation of Sections 15 and 16. + + If the disclaimer of warranty and limitation of liability provided +above cannot be given local legal effect according to their terms, +reviewing courts shall apply local law that most closely approximates +an absolute waiver of all civil liability in connection with the +Program, unless a warranty or assumption of liability accompanies a +copy of the Program in return for a fee. + + END OF TERMS AND CONDITIONS + + How to Apply These Terms to Your New Programs + + If you develop a new program, and you want it to be of the greatest +possible use to the public, the best way to achieve this is to make it +free software which everyone can redistribute and change under these terms. + + To do so, attach the following notices to the program. It is safest +to attach them to the start of each source file to most effectively +state the exclusion of warranty; and each file should have at least +the "copyright" line and a pointer to where the full notice is found. + + + Copyright (C) + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU Affero General Public License as published + by the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Affero General Public License for more details. + + You should have received a copy of the GNU Affero General Public License + along with this program. If not, see . + +Also add information on how to contact you by electronic and paper mail. + + If your software can interact with users remotely through a computer +network, you should also make sure that it provides a way for users to +get its source. For example, if your program is a web application, its +interface could display a "Source" link that leads users to an archive +of the code. There are many ways you could offer source, and different +solutions will be better for different programs; see section 13 for the +specific requirements. + + You should also get your employer (if you work as a programmer) or school, +if any, to sign a "copyright disclaimer" for the program, if necessary. +For more information on this, and how to apply and follow the GNU AGPL, see +. diff --git a/tools/fado/Makefile b/tools/fado/Makefile new file mode 100644 index 000000000..135f51251 --- /dev/null +++ b/tools/fado/Makefile @@ -0,0 +1,74 @@ +DEBUG ?= 0 +LLD ?= 0 +ASAN ?= 0 +EXPERIMENTAL?= 0 + +ELF := fado.elf + +CC := $(shell ./find_program.sh gcc clang clang-[0-9][0-9] clang-[0-9]) +LD := $(shell ./find_program.sh ld ld.lld ld.lld-*) +INC := -I include -I lib +WARNINGS := -Wall -Wextra -Wpedantic -Wshadow -Werror=implicit-function-declaration -Wvla -Wno-unused-function +CFLAGS := -std=c11 +LDFLAGS := + +ifeq ($(DEBUG),0) + OPTFLAGS := -O2 + CFLAGS += -Werror +else + OPTFLAGS := -O0 -g3 -DDEBUG_ON +endif + +ifneq ($(ASAN),0) + CFLAGS += -fsanitize=address -fsanitize=pointer-compare -fsanitize=pointer-subtract -fsanitize=undefined +endif + +ifneq ($(LLD),0) + LDFLAGS += -fuse-ld=lld +else +ifneq ($(LD),ld) + LDFLAGS += -fuse-ld=lld +endif +endif + +ifneq ($(EXPERIMENTAL),0) + CFLAGS += -DEXPERIMENTAL +endif + +# GCC is too stupid to be trusted with these warnings +ifeq ($(CC),gcc) + WARNINGS += -Wno-implicit-fallthrough -Wno-maybe-uninitialized +endif + +SRC_DIRS := $(shell find src -type d) +C_FILES := $(foreach dir,$(SRC_DIRS),$(wildcard $(dir)/*.c)) +H_FILES := $(foreach dir,$(INC),$(wildcard $(dir)/*.h)) +O_FILES := $(foreach f,$(C_FILES:.c=.o),build/$f) + +LIB_DIRS := $(shell find lib -type d) +# exclude test file since we don't want it +C_LIB_FILES := $(filter-out lib/vc_vector/vc_vector_test.c, $(foreach dir,$(LIB_DIRS),$(wildcard $(dir)/*.c))) +O_LIB_FILES := $(foreach f,$(C_LIB_FILES:.c=.o),build/$f) + +# Main targets +all: $(ELF) + +clean: + $(RM) -r build $(ELF) + +format: + clang-format-11 -i $(C_FILES) $(H_FILES) lib/fairy/* + +.PHONY: all clean format + +# create build directories +$(shell mkdir -p $(foreach dir,$(SRC_DIRS),build/$(dir)) $(foreach dir,$(LIB_DIRS),build/$(dir))) + +$(ELF): $(O_FILES) $(O_LIB_FILES) + $(CC) $(INC) $(WARNINGS) $(CFLAGS) $(OPTFLAGS) $(LDFLAGS) -o $@ $^ + +build/%.o: %.c $(H_FILES) + $(CC) -c $(INC) $(WARNINGS) $(CFLAGS) $(OPTFLAGS) -o $@ $< + +build/lib/%.o: lib/%.c + $(CC) -c $(INC) $(WARNINGS) $(CFLAGS) $(OPTFLAGS) -o $@ $< diff --git a/tools/fado/README.md b/tools/fado/README.md new file mode 100644 index 000000000..61b32d603 --- /dev/null +++ b/tools/fado/README.md @@ -0,0 +1,77 @@ +# fado +*Fairy-Assisted (relocations for) Decomplied Overlays* + + +Contains +- **Fairy** a library for reading relocatable MIPS ELF object files (big-endian, suitable for Nintendo 64 games) +- **Fado** a program for generating the `.ovl`/relocation section for Zelda64 overlay files +- **Mido** an automatic dependency file generator + +Compatible with both IDO and GCC (although [see below](N_B)). Both ordinary MIPS REL sections and RELA sections are now supported. + +Output format is the standard "Zelda64" .ovl section, with the relocs divided by section, as used by +- *The Legend of Zelda: Ocarina of Time* (all Nintendo 64/Gamecube/iQue releases) +- *The Legend of Zelda: Majora's Mask* (all Nintendo 64/Gamecube releases) + +In theory it will also work for other Nintendo 64 games that use this system, such as *Yoshi's Story*, but has yet to be tested with these. + + +## Explanation + +The overlay relocation sections used by Zelda64 is described [here](z64_relocation_section_format.md). Fado will produce a `.ovl` section compatible with this format, although as noted there, some compilers need persuasion to produce compatible objects. + + +## How to use + +Compile by running `make`. + +A standalone invocation of Fado would look something like + +```sh +./fado.elf z_en_hs2.o -n ovl_En_Hs2 -o ovl_En_Hs2_reloc.s +``` +This takes as input the compiled object file from the C file (e.g. [this one](https://github.com/zeldaret/oot/blob/eadc477187888e1ae078d021b4a00b1366f0c9a4/src/overlays/actors/ovl_En_Hs2/z_en_hs2.c)), the name of the overlay (`ovl_En_Hs2`) and will output an assembly file `ovl_En_Hs2_reloc.s` containing the relocation section. An example output is included in the repo [here](ovl_En_Hs_reloc.s). Fado will print information from the object file to assist with debugging, by splitting relocs by section, and for each, printing the type, offset, and associated symbol (or section if static): + +```mips +# TEXT RELOCS +.word 0x45000084 # R_MIPS_HI16 0x000084 .data +.word 0x4600008C # R_MIPS_LO16 0x00008C .data +.word 0x450000B4 # R_MIPS_HI16 0x0000B4 .rodata +.word 0x460000BC # R_MIPS_LO16 0x0000BC .rodata +.word 0x450000C0 # R_MIPS_HI16 0x0000C0 func_80A6F1A4 +.word 0x460000C4 # R_MIPS_LO16 0x0000C4 func_80A6F1A4 +``` + +If invoking in a makefile, you will probably want to generate these from a predefined filelist, and with the appropriate dependencies. [The Ocarina of Time decomp repository](http://github.com/zeldaret/oot) contains an example of how to do this using a supplementary program to parse the `spec` format. + +More information can be obtained by running + +```sh +./fado.elf --help +``` + +which contains information on the various options, such as automatic dependency file generation, etc. + + +## N.B. + +- Fado expects the linker script to output symbols for the section sizes, and for them to be declared separately, in the format + +``` +_SEGMENTNAMESegmentSECTIONSize +``` + +e.g. + +``` +_ovl_En_Hs2SegmentTextSize +``` + +etc. + +- By default Fado expects sections to be 0x10-aligned, as is usual for IDO. Some versions of GCC like to align sections to smaller widths, which Fado will handle appropriately, but the linker script must also address this, and at least the default settings seem unable to size the sections correctly due ot placing `fill`s in the wrong places. For now it is recommended to manually align sections to 0x10 if the compiler does not automatically. + - The experimental flag `--alignment`/`-a` can be passed to Fado, and it will use the alignment declared by each section in the elf file instead of padding them to 0x10 bytes, It should be noted this option has not been fully tested because currently we don't have any linker script tool that can properly address the incorrect placing of `fill`s. Fado must be rebuilt passing `EXPERIMENTAL=1` to be able to use this flag. + +- To prevent GCC producing non-compliant HI/LOs, you must pass *both* of the following compiler flags: `-mno-explicit-relocs -mno-split-addresses`. See [here](z64_relocation_section_format.md#hilo) for more details. + +- It is recommended, though not strictly required, that `-fno-merge-constants` is used for GCC, to avoid unpredictable section sizes, and comply with the Zelda64 relocation format's expectation of at most one rodata section. See [here](z64_relocation_section_format.md#rodata) for more details. diff --git a/tools/fado/find_program.sh b/tools/fado/find_program.sh new file mode 100755 index 000000000..77eb53cbe --- /dev/null +++ b/tools/fado/find_program.sh @@ -0,0 +1,16 @@ +#!/usr/bin/env bash + +for i in "${@:2}" + do + RESULT=$(IFS=:;find $PATH -maxdepth 1 -name "$i" -print -quit 2> /dev/null | grep -o '[^/]*$') + COUNT=$(echo "$RESULT" | wc -c) + + if [ $COUNT -gt 1 ] + then + echo $RESULT + exit 0 + fi + done + +echo $1 +exit 0 diff --git a/tools/fado/include/fado.h b/tools/fado/include/fado.h new file mode 100644 index 000000000..6044d0a24 --- /dev/null +++ b/tools/fado/include/fado.h @@ -0,0 +1,8 @@ +/* Copyright (C) 2021 Elliptic Ellipsis */ +/* SPDX-License-Identifier: AGPL-3.0-only */ +#pragma once + +#include + +void Fado_Relocs(FILE* outputFile, int inputFilesCount, FILE** inputFiles, const char* ovlName); +// void Fado_WriteRelocFile(FILE* outputFile, FILE** inputFiles, int inputFilesCount); diff --git a/tools/fado/include/help.h b/tools/fado/include/help.h new file mode 100644 index 000000000..35e8f595d --- /dev/null +++ b/tools/fado/include/help.h @@ -0,0 +1,25 @@ +/* Copyright (C) 2021 Elliptic Ellipsis */ +/* SPDX-License-Identifier: AGPL-3.0-only */ +#pragma once + +#include +#include + +typedef struct { + struct option longOpt; + char* helpArg; + char* helpMsg; +} OptInfo; + +typedef struct { + char* helpArg; + char* helpMsg; +} PosArgInfo; + +/* Formatting sizes used by Help_PrintHelp. Change them before calling Help_PrintHelp to use custom values */ +extern size_t helpTextWidth; +extern size_t helpDtIndent; +extern size_t helpDdIndent; + +void Help_PrintHelp(const char* prologue, size_t posArgCount, const PosArgInfo* posArgInfo, size_t optCount, + const OptInfo* optInfo, const char* epilogue); diff --git a/tools/fado/include/macros.h b/tools/fado/include/macros.h new file mode 100644 index 000000000..e201f8d36 --- /dev/null +++ b/tools/fado/include/macros.h @@ -0,0 +1,23 @@ +/* Copyright (C) 2021 Elliptic Ellipsis */ +/* SPDX-License-Identifier: AGPL-3.0-only */ +#pragma once + +#include "vc_vector/vc_vector.h" + +/* C macros */ +#define ARRAY_COUNT(arr) (signed long long)(sizeof(arr) / sizeof(arr[0])) +#define ARRAY_COUNTU(arr) (unsigned long long)(sizeof(arr) / sizeof(arr[0])) + +#define ALIGN(val, align) (((val) + (align - 1)) / (align) * (align)) + +/* Mathematical macros */ +#define ABS(x) ((x) < 0 ? -(x) : (x)) + +#define CLAMP(x, min, max) ((x) < (min) ? (min) : (x) > (max) ? (max) : (x)) +#define CLAMP_MAX(x, max) ((x) > (max) ? (max) : (x)) +#define CLAMP_MIN(x, min) ((x) < (min) ? (min) : (x)) +#define MEDIAN3(a1, a2, a3) \ + ((a2 >= a1) ? ((a3 >= a2) ? a2 : ((a1 >= a3) ? a1 : a3)) : ((a2 >= a3) ? a2 : ((a3 >= a1) ? a1 : a3))) + +/* vc_vector macros - really these should go in vc_vector.h, but not much choice without touching the library files */ +#define VC_FOREACH(i, v) for (i = vc_vector_begin(v); i != vc_vector_end(v); i = vc_vector_next(v, i)) diff --git a/tools/fado/include/mido.h b/tools/fado/include/mido.h new file mode 100644 index 000000000..b40d8a4c3 --- /dev/null +++ b/tools/fado/include/mido.h @@ -0,0 +1,6 @@ +#pragma once + +#include +#include "vc_vector/vc_vector.h" + +int Mido_WriteDependencyFile(FILE* dependencyFile, const char* relocFile, vc_vector* inputFilesVector); diff --git a/tools/fado/include/mips_elf.h b/tools/fado/include/mips_elf.h new file mode 100644 index 000000000..122e98d25 --- /dev/null +++ b/tools/fado/include/mips_elf.h @@ -0,0 +1,659 @@ +/* This file contains enough of the ELF format definitions for MIPS to enable Fairy and Fado to work. More may need to + * be added later. The content is excerpted directly from elf.h from the GNU C Library, and therefore: */ +/* Copyright (C) 1995-2020 Free Software Foundation, Inc. */ +/* SPDX-License-Identifier: LGPL-2.1-or-later */ + +#ifndef MIPS_ELF_H +#define MIPS_ELF_H + +#include + +/* Type for a 16-bit quantity. */ +typedef uint16_t Elf32_Half; + +/* Types for signed and unsigned 32-bit quantities. */ +typedef uint32_t Elf32_Word; +typedef int32_t Elf32_Sword; + +/* Types for signed and unsigned 64-bit quantities. */ +typedef uint64_t Elf32_Xword; +typedef int64_t Elf32_Sxword; + +/* Type of addresses. */ +typedef uint32_t Elf32_Addr; + +/* Type of file offsets. */ +typedef uint32_t Elf32_Off; + +/* Type for section indices, which are 16-bit quantities. */ +typedef uint16_t Elf32_Section; + +/* The ELF file header. This appears at the start of every ELF file. */ + +#define EI_NIDENT (16) + +typedef struct { + unsigned char e_ident[EI_NIDENT]; /* Magic number and other info */ + Elf32_Half e_type; /* Object file type */ + Elf32_Half e_machine; /* Architecture */ + Elf32_Word e_version; /* Object file version */ + Elf32_Addr e_entry; /* Entry point virtual address */ + Elf32_Off e_phoff; /* Program header table file offset */ + Elf32_Off e_shoff; /* Section header table file offset */ + Elf32_Word e_flags; /* Processor-specific flags */ + Elf32_Half e_ehsize; /* ELF header size in bytes */ + Elf32_Half e_phentsize; /* Program header table entry size */ + Elf32_Half e_phnum; /* Program header table entry count */ + Elf32_Half e_shentsize; /* Section header table entry size */ + Elf32_Half e_shnum; /* Section header table entry count */ + Elf32_Half e_shstrndx; /* Section header string table index */ +} Elf32_Ehdr; + +/* Fields in the e_ident array. The EI_* macros are indices into the + array. The macros under each EI_* macro are the values the byte + may have. */ + +#define EI_MAG0 0 /* File identification byte 0 index */ +#define ELFMAG0 0x7f /* Magic number byte 0 */ + +#define EI_MAG1 1 /* File identification byte 1 index */ +#define ELFMAG1 'E' /* Magic number byte 1 */ + +#define EI_MAG2 2 /* File identification byte 2 index */ +#define ELFMAG2 'L' /* Magic number byte 2 */ + +#define EI_MAG3 3 /* File identification byte 3 index */ +#define ELFMAG3 'F' /* Magic number byte 3 */ + +/* Conglomeration of the identification bytes, for easy testing as a word. */ +#define ELFMAG "\177ELF" +#define SELFMAG 4 + +#define EI_CLASS 4 /* File class byte index */ +#define ELFCLASSNONE 0 /* Invalid class */ +#define ELFCLASS32 1 /* 32-bit objects */ +#define ELFCLASS64 2 /* 64-bit objects */ +#define ELFCLASSNUM 3 + +#define EI_DATA 5 /* Data encoding byte index */ +#define ELFDATANONE 0 /* Invalid data encoding */ +#define ELFDATA2LSB 1 /* 2's complement, little endian */ +#define ELFDATA2MSB 2 /* 2's complement, big endian */ +#define ELFDATANUM 3 + +#define EI_VERSION 6 /* File version byte index */ + /* Value must be EV_CURRENT */ + +#define EI_OSABI 7 /* OS ABI identification */ +#define ELFOSABI_NONE 0 /* UNIX System V ABI */ +#define ELFOSABI_SYSV 0 /* Alias. */ +#define ELFOSABI_HPUX 1 /* HP-UX */ +#define ELFOSABI_NETBSD 2 /* NetBSD. */ +#define ELFOSABI_GNU 3 /* Object uses GNU ELF extensions. */ +#define ELFOSABI_LINUX ELFOSABI_GNU /* Compatibility alias. */ +#define ELFOSABI_SOLARIS 6 /* Sun Solaris. */ +#define ELFOSABI_AIX 7 /* IBM AIX. */ +#define ELFOSABI_IRIX 8 /* SGI Irix. */ +#define ELFOSABI_FREEBSD 9 /* FreeBSD. */ +#define ELFOSABI_TRU64 10 /* Compaq TRU64 UNIX. */ +#define ELFOSABI_MODESTO 11 /* Novell Modesto. */ +#define ELFOSABI_OPENBSD 12 /* OpenBSD. */ +#define ELFOSABI_ARM_AEABI 64 /* ARM EABI */ +#define ELFOSABI_ARM 97 /* ARM */ +#define ELFOSABI_STANDALONE 255 /* Standalone (embedded) application */ + +#define EI_ABIVERSION 8 /* ABI version */ + +#define EI_PAD 9 /* Byte index of padding bytes */ + +/* Legal values for e_type (object file type). */ + +#define ET_NONE 0 /* No file type */ +#define ET_REL 1 /* Relocatable file */ +#define ET_EXEC 2 /* Executable file */ +#define ET_DYN 3 /* Shared object file */ +#define ET_CORE 4 /* Core file */ +#define ET_NUM 5 /* Number of defined types */ +#define ET_LOOS 0xfe00 /* OS-specific range start */ +#define ET_HIOS 0xfeff /* OS-specific range end */ +#define ET_LOPROC 0xff00 /* Processor-specific range start */ +#define ET_HIPROC 0xffff /* Processor-specific range end */ + +/* Legal values for e_machine (architecture). */ + +#define EM_NONE 0 /* No machine */ +#define EM_M32 1 /* AT&T WE 32100 */ +#define EM_SPARC 2 /* SUN SPARC */ +#define EM_386 3 /* Intel 80386 */ +#define EM_68K 4 /* Motorola m68k family */ +#define EM_88K 5 /* Motorola m88k family */ +#define EM_IAMCU 6 /* Intel MCU */ +#define EM_860 7 /* Intel 80860 */ +#define EM_MIPS 8 /* MIPS R3000 big-endian */ +#define EM_S370 9 /* IBM System/370 */ +#define EM_MIPS_RS3_LE 10 /* MIPS R3000 little-endian */ +/* reserved 11-14 */ +#define EM_PARISC 15 /* HPPA */ +/* reserved 16 */ +#define EM_VPP500 17 /* Fujitsu VPP500 */ +#define EM_SPARC32PLUS 18 /* Sun's "v8plus" */ +#define EM_960 19 /* Intel 80960 */ +#define EM_PPC 20 /* PowerPC */ +#define EM_PPC64 21 /* PowerPC 64-bit */ +#define EM_S390 22 /* IBM S390 */ +#define EM_SPU 23 /* IBM SPU/SPC */ +/* reserved 24-35 */ +#define EM_V800 36 /* NEC V800 series */ +#define EM_FR20 37 /* Fujitsu FR20 */ +#define EM_RH32 38 /* TRW RH-32 */ +#define EM_RCE 39 /* Motorola RCE */ +#define EM_ARM 40 /* ARM */ +#define EM_FAKE_ALPHA 41 /* Digital Alpha */ +#define EM_SH 42 /* Hitachi SH */ +#define EM_SPARCV9 43 /* SPARC v9 64-bit */ +#define EM_TRICORE 44 /* Siemens Tricore */ +#define EM_ARC 45 /* Argonaut RISC Core */ +#define EM_H8_300 46 /* Hitachi H8/300 */ +#define EM_H8_300H 47 /* Hitachi H8/300H */ +#define EM_H8S 48 /* Hitachi H8S */ +#define EM_H8_500 49 /* Hitachi H8/500 */ +#define EM_IA_64 50 /* Intel Merced */ +#define EM_MIPS_X 51 /* Stanford MIPS-X */ +#define EM_COLDFIRE 52 /* Motorola Coldfire */ +#define EM_68HC12 53 /* Motorola M68HC12 */ +#define EM_MMA 54 /* Fujitsu MMA Multimedia Accelerator */ +#define EM_PCP 55 /* Siemens PCP */ +#define EM_NCPU 56 /* Sony nCPU embeeded RISC */ +#define EM_NDR1 57 /* Denso NDR1 microprocessor */ +#define EM_STARCORE 58 /* Motorola Start*Core processor */ +#define EM_ME16 59 /* Toyota ME16 processor */ +#define EM_ST100 60 /* STMicroelectronic ST100 processor */ +#define EM_TINYJ 61 /* Advanced Logic Corp. Tinyj emb.fam */ +#define EM_X86_64 62 /* AMD x86-64 architecture */ +#define EM_PDSP 63 /* Sony DSP Processor */ +#define EM_PDP10 64 /* Digital PDP-10 */ +#define EM_PDP11 65 /* Digital PDP-11 */ +#define EM_FX66 66 /* Siemens FX66 microcontroller */ +#define EM_ST9PLUS 67 /* STMicroelectronics ST9+ 8/16 mc */ +#define EM_ST7 68 /* STmicroelectronics ST7 8 bit mc */ +#define EM_68HC16 69 /* Motorola MC68HC16 microcontroller */ +#define EM_68HC11 70 /* Motorola MC68HC11 microcontroller */ +#define EM_68HC08 71 /* Motorola MC68HC08 microcontroller */ +#define EM_68HC05 72 /* Motorola MC68HC05 microcontroller */ +#define EM_SVX 73 /* Silicon Graphics SVx */ +#define EM_ST19 74 /* STMicroelectronics ST19 8 bit mc */ +#define EM_VAX 75 /* Digital VAX */ +#define EM_CRIS 76 /* Axis Communications 32-bit emb.proc */ +#define EM_JAVELIN 77 /* Infineon Technologies 32-bit emb.proc */ +#define EM_FIREPATH 78 /* Element 14 64-bit DSP Processor */ +#define EM_ZSP 79 /* LSI Logic 16-bit DSP Processor */ +#define EM_MMIX 80 /* Donald Knuth's educational 64-bit proc */ +#define EM_HUANY 81 /* Harvard University machine-independent object files */ +#define EM_PRISM 82 /* SiTera Prism */ +#define EM_AVR 83 /* Atmel AVR 8-bit microcontroller */ +#define EM_FR30 84 /* Fujitsu FR30 */ +#define EM_D10V 85 /* Mitsubishi D10V */ +#define EM_D30V 86 /* Mitsubishi D30V */ +#define EM_V850 87 /* NEC v850 */ +#define EM_M32R 88 /* Mitsubishi M32R */ +#define EM_MN10300 89 /* Matsushita MN10300 */ +#define EM_MN10200 90 /* Matsushita MN10200 */ +#define EM_PJ 91 /* picoJava */ +#define EM_OPENRISC 92 /* OpenRISC 32-bit embedded processor */ +#define EM_ARC_COMPACT 93 /* ARC International ARCompact */ +#define EM_XTENSA 94 /* Tensilica Xtensa Architecture */ +#define EM_VIDEOCORE 95 /* Alphamosaic VideoCore */ +#define EM_TMM_GPP 96 /* Thompson Multimedia General Purpose Proc */ +#define EM_NS32K 97 /* National Semi. 32000 */ +#define EM_TPC 98 /* Tenor Network TPC */ +#define EM_SNP1K 99 /* Trebia SNP 1000 */ +#define EM_ST200 100 /* STMicroelectronics ST200 */ +#define EM_IP2K 101 /* Ubicom IP2xxx */ +#define EM_MAX 102 /* MAX processor */ +#define EM_CR 103 /* National Semi. CompactRISC */ +#define EM_F2MC16 104 /* Fujitsu F2MC16 */ +#define EM_MSP430 105 /* Texas Instruments msp430 */ +#define EM_BLACKFIN 106 /* Analog Devices Blackfin DSP */ +#define EM_SE_C33 107 /* Seiko Epson S1C33 family */ +#define EM_SEP 108 /* Sharp embedded microprocessor */ +#define EM_ARCA 109 /* Arca RISC */ +#define EM_UNICORE 110 /* PKU-Unity & MPRC Peking Uni. mc series */ +#define EM_EXCESS 111 /* eXcess configurable cpu */ +#define EM_DXP 112 /* Icera Semi. Deep Execution Processor */ +#define EM_ALTERA_NIOS2 113 /* Altera Nios II */ +#define EM_CRX 114 /* National Semi. CompactRISC CRX */ +#define EM_XGATE 115 /* Motorola XGATE */ +#define EM_C166 116 /* Infineon C16x/XC16x */ +#define EM_M16C 117 /* Renesas M16C */ +#define EM_DSPIC30F 118 /* Microchip Technology dsPIC30F */ +#define EM_CE 119 /* Freescale Communication Engine RISC */ +#define EM_M32C 120 /* Renesas M32C */ +/* reserved 121-130 */ +#define EM_TSK3000 131 /* Altium TSK3000 */ +#define EM_RS08 132 /* Freescale RS08 */ +#define EM_SHARC 133 /* Analog Devices SHARC family */ +#define EM_ECOG2 134 /* Cyan Technology eCOG2 */ +#define EM_SCORE7 135 /* Sunplus S+core7 RISC */ +#define EM_DSP24 136 /* New Japan Radio (NJR) 24-bit DSP */ +#define EM_VIDEOCORE3 137 /* Broadcom VideoCore III */ +#define EM_LATTICEMICO32 138 /* RISC for Lattice FPGA */ +#define EM_SE_C17 139 /* Seiko Epson C17 */ +#define EM_TI_C6000 140 /* Texas Instruments TMS320C6000 DSP */ +#define EM_TI_C2000 141 /* Texas Instruments TMS320C2000 DSP */ +#define EM_TI_C5500 142 /* Texas Instruments TMS320C55x DSP */ +#define EM_TI_ARP32 143 /* Texas Instruments App. Specific RISC */ +#define EM_TI_PRU 144 /* Texas Instruments Prog. Realtime Unit */ +/* reserved 145-159 */ +#define EM_MMDSP_PLUS 160 /* STMicroelectronics 64bit VLIW DSP */ +#define EM_CYPRESS_M8C 161 /* Cypress M8C */ +#define EM_R32C 162 /* Renesas R32C */ +#define EM_TRIMEDIA 163 /* NXP Semi. TriMedia */ +#define EM_QDSP6 164 /* QUALCOMM DSP6 */ +#define EM_8051 165 /* Intel 8051 and variants */ +#define EM_STXP7X 166 /* STMicroelectronics STxP7x */ +#define EM_NDS32 167 /* Andes Tech. compact code emb. RISC */ +#define EM_ECOG1X 168 /* Cyan Technology eCOG1X */ +#define EM_MAXQ30 169 /* Dallas Semi. MAXQ30 mc */ +#define EM_XIMO16 170 /* New Japan Radio (NJR) 16-bit DSP */ +#define EM_MANIK 171 /* M2000 Reconfigurable RISC */ +#define EM_CRAYNV2 172 /* Cray NV2 vector architecture */ +#define EM_RX 173 /* Renesas RX */ +#define EM_METAG 174 /* Imagination Tech. META */ +#define EM_MCST_ELBRUS 175 /* MCST Elbrus */ +#define EM_ECOG16 176 /* Cyan Technology eCOG16 */ +#define EM_CR16 177 /* National Semi. CompactRISC CR16 */ +#define EM_ETPU 178 /* Freescale Extended Time Processing Unit */ +#define EM_SLE9X 179 /* Infineon Tech. SLE9X */ +#define EM_L10M 180 /* Intel L10M */ +#define EM_K10M 181 /* Intel K10M */ +/* reserved 182 */ +#define EM_AARCH64 183 /* ARM AARCH64 */ +/* reserved 184 */ +#define EM_AVR32 185 /* Amtel 32-bit microprocessor */ +#define EM_STM8 186 /* STMicroelectronics STM8 */ +#define EM_TILE64 187 /* Tileta TILE64 */ +#define EM_TILEPRO 188 /* Tilera TILEPro */ +#define EM_MICROBLAZE 189 /* Xilinx MicroBlaze */ +#define EM_CUDA 190 /* NVIDIA CUDA */ +#define EM_TILEGX 191 /* Tilera TILE-Gx */ +#define EM_CLOUDSHIELD 192 /* CloudShield */ +#define EM_COREA_1ST 193 /* KIPO-KAIST Core-A 1st gen. */ +#define EM_COREA_2ND 194 /* KIPO-KAIST Core-A 2nd gen. */ +#define EM_ARC_COMPACT2 195 /* Synopsys ARCompact V2 */ +#define EM_OPEN8 196 /* Open8 RISC */ +#define EM_RL78 197 /* Renesas RL78 */ +#define EM_VIDEOCORE5 198 /* Broadcom VideoCore V */ +#define EM_78KOR 199 /* Renesas 78KOR */ +#define EM_56800EX 200 /* Freescale 56800EX DSC */ +#define EM_BA1 201 /* Beyond BA1 */ +#define EM_BA2 202 /* Beyond BA2 */ +#define EM_XCORE 203 /* XMOS xCORE */ +#define EM_MCHP_PIC 204 /* Microchip 8-bit PIC(r) */ +/* reserved 205-209 */ +#define EM_KM32 210 /* KM211 KM32 */ +#define EM_KMX32 211 /* KM211 KMX32 */ +#define EM_EMX16 212 /* KM211 KMX16 */ +#define EM_EMX8 213 /* KM211 KMX8 */ +#define EM_KVARC 214 /* KM211 KVARC */ +#define EM_CDP 215 /* Paneve CDP */ +#define EM_COGE 216 /* Cognitive Smart Memory Processor */ +#define EM_COOL 217 /* Bluechip CoolEngine */ +#define EM_NORC 218 /* Nanoradio Optimized RISC */ +#define EM_CSR_KALIMBA 219 /* CSR Kalimba */ +#define EM_Z80 220 /* Zilog Z80 */ +#define EM_VISIUM 221 /* Controls and Data Services VISIUMcore */ +#define EM_FT32 222 /* FTDI Chip FT32 */ +#define EM_MOXIE 223 /* Moxie processor */ +#define EM_AMDGPU 224 /* AMD GPU */ +/* reserved 225-242 */ +#define EM_RISCV 243 /* RISC-V */ + +#define EM_BPF 247 /* Linux BPF -- in-kernel virtual machine */ +#define EM_CSKY 252 /* C-SKY */ + +#define EM_NUM 253 + +/* Old spellings/synonyms. */ + +#define EM_ARC_A5 EM_ARC_COMPACT + +/* If it is necessary to assign new unofficial EM_* values, please + pick large random numbers (0x8523, 0xa7f2, etc.) to minimize the + chances of collision with official or non-GNU unofficial values. */ + +#define EM_ALPHA 0x9026 + +/* Legal values for e_version (version). */ + +#define EV_NONE 0 /* Invalid ELF version */ +#define EV_CURRENT 1 /* Current version */ +#define EV_NUM 2 + +/* Section header. */ + +typedef struct { + Elf32_Word sh_name; /* Section name (string tbl index) */ + Elf32_Word sh_type; /* Section type */ + Elf32_Word sh_flags; /* Section flags */ + Elf32_Addr sh_addr; /* Section virtual addr at execution */ + Elf32_Off sh_offset; /* Section file offset */ + Elf32_Word sh_size; /* Section size in bytes */ + Elf32_Word sh_link; /* Link to another section */ + Elf32_Word sh_info; /* Additional section information */ + Elf32_Word sh_addralign; /* Section alignment */ + Elf32_Word sh_entsize; /* Entry size if section holds table */ +} Elf32_Shdr; + +/* Special section indices. */ + +#define SHN_UNDEF 0 /* Undefined section */ +#define SHN_LORESERVE 0xff00 /* Start of reserved indices */ +#define SHN_LOPROC 0xff00 /* Start of processor-specific */ +#define SHN_BEFORE 0xff00 /* Order section before all others (Solaris). */ +#define SHN_AFTER 0xff01 /* Order section after all others (Solaris). */ +#define SHN_HIPROC 0xff1f /* End of processor-specific */ +#define SHN_LOOS 0xff20 /* Start of OS-specific */ +#define SHN_HIOS 0xff3f /* End of OS-specific */ +#define SHN_ABS 0xfff1 /* Associated symbol is absolute */ +#define SHN_COMMON 0xfff2 /* Associated symbol is common */ +#define SHN_XINDEX 0xffff /* Index is in extra table. */ +#define SHN_HIRESERVE 0xffff /* End of reserved indices */ +/* Legal values for sh_type (section type). */ + +#define SHT_NULL 0 /* Section header table entry unused */ +#define SHT_PROGBITS 1 /* Program data */ +#define SHT_SYMTAB 2 /* Symbol table */ +#define SHT_STRTAB 3 /* String table */ +#define SHT_RELA 4 /* Relocation entries with addends */ +#define SHT_HASH 5 /* Symbol hash table */ +#define SHT_DYNAMIC 6 /* Dynamic linking information */ +#define SHT_NOTE 7 /* Notes */ +#define SHT_NOBITS 8 /* Program space with no data (bss) */ +#define SHT_REL 9 /* Relocation entries, no addends */ +#define SHT_SHLIB 10 /* Reserved */ +#define SHT_DYNSYM 11 /* Dynamic linker symbol table */ +#define SHT_INIT_ARRAY 14 /* Array of constructors */ +#define SHT_FINI_ARRAY 15 /* Array of destructors */ +#define SHT_PREINIT_ARRAY 16 /* Array of pre-constructors */ +#define SHT_GROUP 17 /* Section group */ +#define SHT_SYMTAB_SHNDX 18 /* Extended section indeces */ +#define SHT_NUM 19 /* Number of defined types. */ +#define SHT_LOOS 0x60000000 /* Start OS-specific. */ +#define SHT_GNU_ATTRIBUTES 0x6ffffff5 /* Object attributes. */ +#define SHT_GNU_HASH 0x6ffffff6 /* GNU-style hash table. */ +#define SHT_GNU_LIBLIST 0x6ffffff7 /* Prelink library list */ +#define SHT_CHECKSUM 0x6ffffff8 /* Checksum for DSO content. */ +#define SHT_LOSUNW 0x6ffffffa /* Sun-specific low bound. */ +#define SHT_SUNW_move 0x6ffffffa +#define SHT_SUNW_COMDAT 0x6ffffffb +#define SHT_SUNW_syminfo 0x6ffffffc +#define SHT_GNU_verdef 0x6ffffffd /* Version definition section. */ +#define SHT_GNU_verneed 0x6ffffffe /* Version needs section. */ +#define SHT_GNU_versym 0x6fffffff /* Version symbol table. */ +#define SHT_HISUNW 0x6fffffff /* Sun-specific high bound. */ +#define SHT_HIOS 0x6fffffff /* End OS-specific type */ +#define SHT_LOPROC 0x70000000 /* Start of processor-specific */ +#define SHT_HIPROC 0x7fffffff /* End of processor-specific */ +#define SHT_LOUSER 0x80000000 /* Start of application-specific */ +#define SHT_HIUSER 0x8fffffff /* End of application-specific */ + +/* Symbol table entry. */ + +typedef struct { + Elf32_Word st_name; /* Symbol name (string tbl index) */ + Elf32_Addr st_value; /* Symbol value */ + Elf32_Word st_size; /* Symbol size */ + unsigned char st_info; /* Symbol type and binding */ + unsigned char st_other; /* Symbol visibility */ + Elf32_Section st_shndx; /* Section index */ +} Elf32_Sym; + +/* How to extract and insert information held in the st_info field. */ + +#define ELF32_ST_BIND(val) (((unsigned char)(val)) >> 4) +#define ELF32_ST_TYPE(val) ((val)&0xf) +#define ELF32_ST_INFO(bind, type) (((bind) << 4) + ((type)&0xf)) + +/* Both Elf32_Sym and Elf64_Sym use the same one-byte st_info field. */ +#define ELF64_ST_BIND(val) ELF32_ST_BIND(val) +#define ELF64_ST_TYPE(val) ELF32_ST_TYPE(val) +#define ELF64_ST_INFO(bind, type) ELF32_ST_INFO((bind), (type)) + +/* Legal values for ST_BIND subfield of st_info (symbol binding). */ + +#define STB_LOCAL 0 /* Local symbol */ +#define STB_GLOBAL 1 /* Global symbol */ +#define STB_WEAK 2 /* Weak symbol */ +#define STB_NUM 3 /* Number of defined types. */ +#define STB_LOOS 10 /* Start of OS-specific */ +#define STB_GNU_UNIQUE 10 /* Unique symbol. */ +#define STB_HIOS 12 /* End of OS-specific */ +#define STB_LOPROC 13 /* Start of processor-specific */ +#define STB_HIPROC 15 /* End of processor-specific */ + +/* Legal values for ST_TYPE subfield of st_info (symbol type). */ + +#define STT_NOTYPE 0 /* Symbol type is unspecified */ +#define STT_OBJECT 1 /* Symbol is a data object */ +#define STT_FUNC 2 /* Symbol is a code object */ +#define STT_SECTION 3 /* Symbol associated with a section */ +#define STT_FILE 4 /* Symbol's name is file name */ +#define STT_COMMON 5 /* Symbol is a common data object */ +#define STT_TLS 6 /* Symbol is thread-local data object*/ +#define STT_NUM 7 /* Number of defined types. */ +#define STT_LOOS 10 /* Start of OS-specific */ +#define STT_GNU_IFUNC 10 /* Symbol is indirect code object */ +#define STT_HIOS 12 /* End of OS-specific */ +#define STT_LOPROC 13 /* Start of processor-specific */ +#define STT_HIPROC 15 /* End of processor-specific */ + +/* Symbol table indices are found in the hash buckets and chain table + of a symbol hash table section. This special index value indicates + the end of a chain, meaning no further symbols are found in that bucket. */ + +#define STN_UNDEF 0 /* End of a chain. */ + +/* How to extract and insert information held in the st_other field. */ + +#define ELF32_ST_VISIBILITY(o) ((o)&0x03) + +/* For ELF64 the definitions are the same. */ +#define ELF64_ST_VISIBILITY(o) ELF32_ST_VISIBILITY(o) + +/* Symbol visibility specification encoded in the st_other field. */ +#define STV_DEFAULT 0 /* Default symbol visibility rules */ +#define STV_INTERNAL 1 /* Processor specific hidden class */ +#define STV_HIDDEN 2 /* Sym unavailable in other modules */ +#define STV_PROTECTED 3 /* Not preemptible, not exported */ + +/* Relocation table entry without addend (in section of type SHT_REL). */ + +typedef struct { + Elf32_Addr r_offset; /* Address */ + Elf32_Word r_info; /* Relocation type and symbol index */ +} Elf32_Rel; + +/* Relocation table entry with addend (in section of type SHT_RELA). */ + +typedef struct { + Elf32_Addr r_offset; /* Address */ + Elf32_Word r_info; /* Relocation type and symbol index */ + Elf32_Sword r_addend; /* Addend */ +} Elf32_Rela; + +/* How to extract and insert information held in the r_info field. */ + +#define ELF32_R_SYM(val) ((val) >> 8) +#define ELF32_R_TYPE(val) ((val)&0xff) +#define ELF32_R_INFO(sym, type) (((sym) << 8) + ((type)&0xff)) + +/* MIPS R3000 specific definitions. */ + +/* Legal values for e_flags field of Elf32_Ehdr. */ + +#define EF_MIPS_NOREORDER 1 /* A .noreorder directive was used. */ +#define EF_MIPS_PIC 2 /* Contains PIC code. */ +#define EF_MIPS_CPIC 4 /* Uses PIC calling sequence. */ +#define EF_MIPS_XGOT 8 +#define EF_MIPS_64BIT_WHIRL 16 +#define EF_MIPS_ABI2 32 +#define EF_MIPS_ABI_ON32 64 +#define EF_MIPS_FP64 512 /* Uses FP64 (12 callee-saved). */ +#define EF_MIPS_NAN2008 1024 /* Uses IEEE 754-2008 NaN encoding. */ +#define EF_MIPS_ARCH 0xf0000000 /* MIPS architecture level. */ + +/* Legal values for MIPS architecture level. */ + +#define EF_MIPS_ARCH_1 0x00000000 /* -mips1 code. */ +#define EF_MIPS_ARCH_2 0x10000000 /* -mips2 code. */ +#define EF_MIPS_ARCH_3 0x20000000 /* -mips3 code. */ +#define EF_MIPS_ARCH_4 0x30000000 /* -mips4 code. */ +#define EF_MIPS_ARCH_5 0x40000000 /* -mips5 code. */ +#define EF_MIPS_ARCH_32 0x50000000 /* MIPS32 code. */ +#define EF_MIPS_ARCH_64 0x60000000 /* MIPS64 code. */ +#define EF_MIPS_ARCH_32R2 0x70000000 /* MIPS32r2 code. */ +#define EF_MIPS_ARCH_64R2 0x80000000 /* MIPS64r2 code. */ + +/* The following are unofficial names and should not be used. */ + +#define E_MIPS_ARCH_1 EF_MIPS_ARCH_1 +#define E_MIPS_ARCH_2 EF_MIPS_ARCH_2 +#define E_MIPS_ARCH_3 EF_MIPS_ARCH_3 +#define E_MIPS_ARCH_4 EF_MIPS_ARCH_4 +#define E_MIPS_ARCH_5 EF_MIPS_ARCH_5 +#define E_MIPS_ARCH_32 EF_MIPS_ARCH_32 +#define E_MIPS_ARCH_64 EF_MIPS_ARCH_64 + +/* Special section indices. */ + +#define SHN_MIPS_ACOMMON 0xff00 /* Allocated common symbols. */ +#define SHN_MIPS_TEXT 0xff01 /* Allocated test symbols. */ +#define SHN_MIPS_DATA 0xff02 /* Allocated data symbols. */ +#define SHN_MIPS_SCOMMON 0xff03 /* Small common symbols. */ +#define SHN_MIPS_SUNDEFINED 0xff04 /* Small undefined symbols. */ + +/* Legal values for sh_type field of Elf32_Shdr. */ + +#define SHT_MIPS_LIBLIST 0x70000000 /* Shared objects used in link. */ +#define SHT_MIPS_MSYM 0x70000001 +#define SHT_MIPS_CONFLICT 0x70000002 /* Conflicting symbols. */ +#define SHT_MIPS_GPTAB 0x70000003 /* Global data area sizes. */ +#define SHT_MIPS_UCODE 0x70000004 /* Reserved for SGI/MIPS compilers */ +#define SHT_MIPS_DEBUG 0x70000005 /* MIPS ECOFF debugging info. */ +#define SHT_MIPS_REGINFO 0x70000006 /* Register usage information. */ +#define SHT_MIPS_PACKAGE 0x70000007 +#define SHT_MIPS_PACKSYM 0x70000008 +#define SHT_MIPS_RELD 0x70000009 +#define SHT_MIPS_IFACE 0x7000000b +#define SHT_MIPS_CONTENT 0x7000000c +#define SHT_MIPS_OPTIONS 0x7000000d /* Miscellaneous options. */ +#define SHT_MIPS_SHDR 0x70000010 +#define SHT_MIPS_FDESC 0x70000011 +#define SHT_MIPS_EXTSYM 0x70000012 +#define SHT_MIPS_DENSE 0x70000013 +#define SHT_MIPS_PDESC 0x70000014 +#define SHT_MIPS_LOCSYM 0x70000015 +#define SHT_MIPS_AUXSYM 0x70000016 +#define SHT_MIPS_OPTSYM 0x70000017 +#define SHT_MIPS_LOCSTR 0x70000018 +#define SHT_MIPS_LINE 0x70000019 +#define SHT_MIPS_RFDESC 0x7000001a +#define SHT_MIPS_DELTASYM 0x7000001b +#define SHT_MIPS_DELTAINST 0x7000001c +#define SHT_MIPS_DELTACLASS 0x7000001d +#define SHT_MIPS_DWARF 0x7000001e /* DWARF debugging information. */ +#define SHT_MIPS_DELTADECL 0x7000001f +#define SHT_MIPS_SYMBOL_LIB 0x70000020 +#define SHT_MIPS_EVENTS 0x70000021 /* Event section. */ +#define SHT_MIPS_TRANSLATE 0x70000022 +#define SHT_MIPS_PIXIE 0x70000023 +#define SHT_MIPS_XLATE 0x70000024 +#define SHT_MIPS_XLATE_DEBUG 0x70000025 +#define SHT_MIPS_WHIRL 0x70000026 +#define SHT_MIPS_EH_REGION 0x70000027 +#define SHT_MIPS_XLATE_OLD 0x70000028 +#define SHT_MIPS_PDR_EXCEPTION 0x70000029 +#define SHT_MIPS_XHASH 0x7000002b + +/* Legal values for sh_flags field of Elf32_Shdr. */ + +#define SHF_MIPS_GPREL 0x10000000 /* Must be in global data area. */ +#define SHF_MIPS_MERGE 0x20000000 +#define SHF_MIPS_ADDR 0x40000000 +#define SHF_MIPS_STRINGS 0x80000000 +#define SHF_MIPS_NOSTRIP 0x08000000 +#define SHF_MIPS_LOCAL 0x04000000 +#define SHF_MIPS_NAMES 0x02000000 +#define SHF_MIPS_NODUPE 0x01000000 + +/* Symbol tables. */ + +/* MIPS specific values for `st_other'. */ +#define STO_MIPS_DEFAULT 0x0 +#define STO_MIPS_INTERNAL 0x1 +#define STO_MIPS_HIDDEN 0x2 +#define STO_MIPS_PROTECTED 0x3 +#define STO_MIPS_PLT 0x8 +#define STO_MIPS_SC_ALIGN_UNUSED 0xff + +/* MIPS specific values for `st_info'. */ +#define STB_MIPS_SPLIT_COMMON 13 + +/* MIPS relocs. */ + +#define R_MIPS_NONE 0 /* No reloc */ +#define R_MIPS_16 1 /* Direct 16 bit */ +#define R_MIPS_32 2 /* Direct 32 bit */ +#define R_MIPS_REL32 3 /* PC relative 32 bit */ +#define R_MIPS_26 4 /* Direct 26 bit shifted */ +#define R_MIPS_HI16 5 /* High 16 bit */ +#define R_MIPS_LO16 6 /* Low 16 bit */ +#define R_MIPS_GPREL16 7 /* GP relative 16 bit */ +#define R_MIPS_LITERAL 8 /* 16 bit literal entry */ +#define R_MIPS_GOT16 9 /* 16 bit GOT entry */ +#define R_MIPS_PC16 10 /* PC relative 16 bit */ +#define R_MIPS_CALL16 11 /* 16 bit GOT entry for function */ +#define R_MIPS_GPREL32 12 /* GP relative 32 bit */ + +#define R_MIPS_SHIFT5 16 +#define R_MIPS_SHIFT6 17 +#define R_MIPS_64 18 +#define R_MIPS_GOT_DISP 19 +#define R_MIPS_GOT_PAGE 20 +#define R_MIPS_GOT_OFST 21 +#define R_MIPS_GOT_HI16 22 +#define R_MIPS_GOT_LO16 23 +#define R_MIPS_SUB 24 +#define R_MIPS_INSERT_A 25 +#define R_MIPS_INSERT_B 26 +#define R_MIPS_DELETE 27 +#define R_MIPS_HIGHER 28 +#define R_MIPS_HIGHEST 29 +#define R_MIPS_CALL_HI16 30 +#define R_MIPS_CALL_LO16 31 +#define R_MIPS_SCN_DISP 32 +#define R_MIPS_REL16 33 +#define R_MIPS_ADD_IMMEDIATE 34 +#define R_MIPS_PJUMP 35 +#define R_MIPS_RELGOT 36 +#define R_MIPS_JALR 37 +#define R_MIPS_TLS_DTPMOD32 38 /* Module number 32 bit */ +#define R_MIPS_TLS_DTPREL32 39 /* Module-relative offset 32 bit */ +#define R_MIPS_TLS_DTPMOD64 40 /* Module number 64 bit */ +#define R_MIPS_TLS_DTPREL64 41 /* Module-relative offset 64 bit */ +#define R_MIPS_TLS_GD 42 /* 16 bit GOT offset for GD */ +#define R_MIPS_TLS_LDM 43 /* 16 bit GOT offset for LDM */ +#define R_MIPS_TLS_DTPREL_HI16 44 /* Module-relative offset, high 16 bits */ +#define R_MIPS_TLS_DTPREL_LO16 45 /* Module-relative offset, low 16 bits */ +#define R_MIPS_TLS_GOTTPREL 46 /* 16 bit GOT offset for IE */ +#define R_MIPS_TLS_TPREL32 47 /* TP-relative offset, 32 bit */ +#define R_MIPS_TLS_TPREL64 48 /* TP-relative offset, 64 bit */ +#define R_MIPS_TLS_TPREL_HI16 49 /* TP-relative offset, high 16 bits */ +#define R_MIPS_TLS_TPREL_LO16 50 /* TP-relative offset, low 16 bits */ +#define R_MIPS_GLOB_DAT 51 +#define R_MIPS_COPY 126 +#define R_MIPS_JUMP_SLOT 127 +/* Keep this the last entry. */ +#define R_MIPS_NUM 128 + +#endif /* MIPS_ELF_H */ diff --git a/tools/fado/lib/fairy/fairy.c b/tools/fado/lib/fairy/fairy.c new file mode 100644 index 000000000..8fc090300 --- /dev/null +++ b/tools/fado/lib/fairy/fairy.c @@ -0,0 +1,418 @@ +/** + * Functions for working with N64 ELF files. + */ +/* Copyright (C) 2021 Elliptic Ellipsis */ +/* SPDX-License-Identifier: AGPL-3.0-only */ +#include "fairy.h" + +#include +#include +#include +#include +#include +#include +#include + +#include "vc_vector/vc_vector.h" +#include "macros.h" + +VerbosityLevel gVerbosity = VERBOSITY_NONE; +bool gUseElfAlignment = false; + +int Fairy_DebugPrintf(const char* file, int line, const char* func, VerbosityLevel level, const char* fmt, ...) { + if (gVerbosity >= level) { + int ret = 0; + va_list args; + va_start(args, fmt); + + if (gVerbosity >= VERBOSITY_DEBUG) { + ret += fprintf(stderr, "%s:%d:%s: ", file, line, func); + } + + ret += vfprintf(stderr, fmt, args); + va_end(args); + return ret; + } + return 0; +} + +/* Endian readers. MIPS is BE, so only need these */ +static Elf32_Half Fairy_ReadHalf(const uint8_t* data) { + return data[0] << 8 | data[1] << 0; +} + +static Elf32_Word Fairy_ReadWord(const uint8_t* data) { + return data[0] << 24 | data[1] << 16 | data[2] << 8 | data[3] << 0; +} + +static bool Fairy_VerifyMagic(const uint8_t* data) { + return (data[0] == 0x7F && data[1] == 'E' && data[2] == 'L' && data[3] == 'F'); +} + +static uint16_t Fairy_Swap16(uint16_t x) { + return ((x & 0xFF) << 0x8) | ((x & 0xFF00) >> 0x8); +} + +static uint32_t Fairy_Swap32(uint32_t x) { + return ((x & 0xFF) << 0x18) | ((x & 0xFF00) << 0x8) | ((x & 0xFF0000) >> 0x8) | ((x & 0xFF000000) >> 0x18); +} + +/* Both GCC and Clang define these, so we can avoid an endian header altogether */ +#if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__ +#define REEND16(x) Fairy_Swap16(x) +#define REEND32(x) Fairy_Swap32(x) +#else +#define REEND16(x) (x) +#define REEND32(x) (x) +#endif + +const char* Fairy_StringFromDefine(const FairyDefineString* dict, int define) { + size_t i; + for (i = 0; dict[i].string != NULL; i++) { + if (dict[i].define == define) { + return dict[i].string; + } + } + return NULL; +} + +/** + * Returns true if the string 'initial' is contained in the string 'string' + * 'initial' must be null-terminated, 'string' ideally is. + */ +bool Fairy_StartsWith(const char* string, const char* initial) { + char s; + char i; + do { + s = *string++; + i = *initial++; + if (i == '\0') { + return true; + } + } while (s == i); + return false; +} + +/* Reading functions */ + +/** + * Every reading function: + * - Returns the pointer to the struct + * - Takes the ouput struct or array as its first argument. This must be pre-allocated + * - Takes the input file as the second argument (At least until I am persuaded to read the whole file into RAM...) + * - The rest of the arguments are important information about the struct it is reading (offset and size, usually) + */ + +FairyFileHeader* Fairy_ReadFileHeader(FairyFileHeader* header, FILE* file) { + fseek(file, 0, SEEK_SET); + assert(fread(header, sizeof(char), 0x34, file) == 0x34); + + if (!Fairy_VerifyMagic(header->e_ident)) { + fprintf(stderr, "Not a valid ELF file.\n"); + return NULL; + } + + if (header->e_ident[EI_CLASS] != ELFCLASS32) { + fprintf(stderr, "Not a 32-bit ELF file.\n"); + return NULL; + } + + header->e_type = REEND16(header->e_type); + if (header->e_type != ET_REL) { + fprintf(stderr, "Not a relocatable object file.\n"); + return NULL; + } + + header->e_machine = REEND16(header->e_machine); + if (header->e_machine != EM_MIPS) { + fprintf(stderr, "Not a MIPS object file.\n"); + return NULL; + } + + header->e_version = REEND32(header->e_version); + header->e_entry = REEND32(header->e_entry); + header->e_phoff = REEND32(header->e_phoff); + header->e_shoff = REEND32(header->e_shoff); + header->e_flags = REEND32(header->e_flags); + header->e_ehsize = REEND16(header->e_ehsize); + header->e_phentsize = REEND16(header->e_phentsize); + header->e_phnum = REEND16(header->e_phnum); + header->e_shentsize = REEND16(header->e_shentsize); + header->e_shnum = REEND16(header->e_shnum); + header->e_shstrndx = REEND16(header->e_shstrndx); + + return header; +} + +/* tableOffset and number should be obtained from the file header */ +FairySecHeader* Fairy_ReadSectionTable(FairySecHeader* sectionTable, FILE* file, size_t tableOffset, size_t number) { + size_t entrySize = sizeof(FairySecHeader); + size_t tableSize = number * entrySize; + + fseek(file, tableOffset, SEEK_SET); + assert(fread(sectionTable, sizeof(char), tableSize, file) == tableSize); + + /* Since the section table happens to only have entries of width 4, we can byteswap it by pretending it is a raw + * uint32_t array */ + { + size_t i; + uint32_t* data = (uint32_t*)sectionTable; + for (i = 0; i < tableSize / sizeof(uint32_t); i++) { + data[i] = REEND32(data[i]); + } + } + + return sectionTable; +} + +size_t Fairy_ReadSymbolTable(FairySym** symbolTableOut, FILE* file, size_t tableOffset, size_t tableSize) { + size_t number = tableSize / sizeof(FairySym); + FairySym* symbolTable = malloc(tableSize); + + *symbolTableOut = NULL; + + if (symbolTable == NULL) { + return 0; + } + if (fseek(file, tableOffset, SEEK_SET) != 0 || fread(symbolTable, sizeof(char), tableSize, file) != tableSize) { + free(symbolTable); + return 0; + } + + /* Reend the variables that are wider than bytes */ + { + size_t i; + for (i = 0; i < number; i++) { + symbolTable[i].st_name = REEND32(symbolTable[i].st_name); + symbolTable[i].st_value = REEND32(symbolTable[i].st_value); + symbolTable[i].st_size = REEND32(symbolTable[i].st_size); + symbolTable[i].st_shndx = REEND16(symbolTable[i].st_shndx); + } + } + + *symbolTableOut = symbolTable; + return number; +} + +/* Can be used for both the section header string table and the strtab */ +char* Fairy_ReadStringTable(char* stringTable, FILE* file, size_t tableOffset, size_t tableSize) { + fseek(file, tableOffset, SEEK_SET); + assert(fread(stringTable, sizeof(char), tableSize, file) == tableSize); + return stringTable; +} + +/* offset and number are attained from the section table, the returned pointer must be freed */ +size_t Fairy_ReadRelocs(FairyRela** relocsOut, FILE* file, int type, size_t offset, size_t size) { + /* Final size of the relocation table, relocations of type SHT_REL need more space for extra addend of 0 */ + size_t finalSize = (type == SHT_REL) ? ((size * sizeof(FairyRela)) / sizeof(FairyRel)) : size; + void* readBuf = malloc(size); + FairyRela* relocTable = malloc(finalSize); + + *relocsOut = NULL; + + if (readBuf == NULL) { + return 0; + } + if (relocTable == NULL) { + free(readBuf); + return 0; + } + if (fseek(file, offset, SEEK_SET) != 0 || fread(readBuf, sizeof(char), size, file) != size) { + free(readBuf); + free(relocTable); + return 0; + } + + /* Reend the variables that are wider than bytes */ + { + size_t i; + uint32_t* data = (uint32_t*)readBuf; + for (i = 0; i < size / sizeof(uint32_t); i++) { + data[i] = REEND32(data[i]); + } + } + + /* Make the relocation table, for SHT_REL sections add an addend of 0 */ + if (type == SHT_REL) { + size_t i; + FairyRel* rel = (FairyRel*)readBuf; + + for (i = 0; i < size / sizeof(FairyRel); i++) { + relocTable[i].r_info = rel[i].r_info; + relocTable[i].r_offset = rel[i].r_offset; + relocTable[i].r_addend = 0; + } + } else { + memcpy(relocTable, readBuf, size); + } + free(readBuf); + + *relocsOut = relocTable; + return finalSize / sizeof(FairyRela); +} + +char* Fairy_GetSectionName(FairySecHeader* sectionTable, char* shstrtab, size_t index) { + return &shstrtab[sectionTable[index].sh_name]; +} + +/* Look up the index in the symbol table and return a pointer to the beginning of its string */ +char* Fairy_GetSymbolName(FairySym* symtab, char* strtab, size_t index) { + return &strtab[symtab[index].st_name]; +} + +/* FairyFileInfo functions */ + +void Fairy_InitFile(FairyFileInfo* fileInfo, FILE* file) { + FairyFileHeader fileHeader; + FairySecHeader* sectionTable; + char* shstrtab; + int i; + + assert(fileInfo != NULL); + assert(file != NULL); + + fileInfo->progBitsSections = vc_vector_create(3, sizeof(Elf32_Section), NULL); + for (i = 0; i < 3; i++) { + fileInfo->progBitsSizes[i] = 0; + } + Fairy_ReadFileHeader(&fileHeader, file); + + sectionTable = malloc(fileHeader.e_shnum * fileHeader.e_shentsize); + Fairy_ReadSectionTable(sectionTable, file, fileHeader.e_shoff, fileHeader.e_shnum); + + shstrtab = malloc(sectionTable[fileHeader.e_shstrndx].sh_size * sizeof(char)); + fseek(file, sectionTable[fileHeader.e_shstrndx].sh_offset, SEEK_SET); + assert(fread(shstrtab, sizeof(char), sectionTable[fileHeader.e_shstrndx].sh_size, file) == + sectionTable[fileHeader.e_shstrndx].sh_size); + + /* Search for the sections we need */ + { + size_t currentIndex; + FairySecHeader currentSection; + for (currentIndex = 0; currentIndex < 3; currentIndex++) { + fileInfo->relocTablesInfo[currentIndex].sectionData = NULL; + } + + for (currentIndex = 0; currentIndex < fileHeader.e_shnum; currentIndex++) { + size_t off = 0; + + currentSection = sectionTable[currentIndex]; + + switch (currentSection.sh_type) { + case SHT_PROGBITS: + assert(vc_vector_push_back(fileInfo->progBitsSections, ¤tIndex)); + + { + FairySection sectionType = FAIRY_SECTION_OTHER; + const char* sectionName = &shstrtab[currentSection.sh_name + 1]; + size_t alignedSize; + + /* Ignore the leading "." */ + if (strcmp(sectionName, "text") == 0) { + sectionType = FAIRY_SECTION_TEXT; + } else if (strcmp(sectionName, "data") == 0) { + sectionType = FAIRY_SECTION_DATA; + } else if (Fairy_StartsWith(sectionName, "rodata")) { /* May be several */ + sectionType = FAIRY_SECTION_RODATA; + } + + if (sectionType != FAIRY_SECTION_OTHER) { + if (gUseElfAlignment) { + /* Ensure the next file will start at its correct alignment */ + fileInfo->progBitsSizes[sectionType] = + ALIGN(fileInfo->progBitsSizes[sectionType], currentSection.sh_addralign); + + alignedSize = ALIGN(currentSection.sh_size, currentSection.sh_addralign); + + FAIRY_DEBUG_PRINTF("%s section alignment: 0x%X\n", sectionName, + currentSection.sh_addralign); + FAIRY_DEBUG_PRINTF("%s section size before align: 0x%X\n", sectionName, + currentSection.sh_size); + FAIRY_DEBUG_PRINTF("%s section size after align: 0x%X\n", sectionName, alignedSize); + + fileInfo->progBitsSizes[sectionType] += alignedSize; + } else { + fileInfo->progBitsSizes[sectionType] += ALIGN(currentSection.sh_size, 0x10); + } + + FAIRY_DEBUG_PRINTF("%s section size: 0x%X\n", sectionName, + fileInfo->progBitsSizes[sectionType]); + } + } + + break; + + case SHT_SYMTAB: + if (strcmp(&shstrtab[currentSection.sh_name + 1], "symtab") == 0) { + fileInfo->symtabInfo.sectionType = SHT_SYMTAB; + fileInfo->symtabInfo.sectionEntrySize = sizeof(FairySym); + fileInfo->symtabInfo.sectionEntryCount = + Fairy_ReadSymbolTable((FairySym**)&fileInfo->symtabInfo.sectionData, file, + currentSection.sh_offset, currentSection.sh_size); + } + break; + + case SHT_STRTAB: + if (strcmp(&shstrtab[currentSection.sh_name + 1], "strtab") == 0) { + FAIRY_DEBUG_PRINTF("%s", "strtab found\n"); + fileInfo->strtab = malloc(currentSection.sh_size); + Fairy_ReadStringTable(fileInfo->strtab, file, currentSection.sh_offset, currentSection.sh_size); + } + break; + + case SHT_RELA: + off += 1; + case SHT_REL: + off += 5; + /* This assumes only one reloc section of each name */ + // TODO: is this a problem? + { + FairySection relocSection = FAIRY_SECTION_OTHER; + + /* Ignore the first 5/6 chars, which will always be ".rel."/".rela." */ + if (strcmp(&shstrtab[currentSection.sh_name + off], "text") == 0) { + relocSection = FAIRY_SECTION_TEXT; + } else if (strcmp(&shstrtab[currentSection.sh_name + off], "data") == 0) { + relocSection = FAIRY_SECTION_DATA; + } else if (strcmp(&shstrtab[currentSection.sh_name + off], "rodata") == 0) { + relocSection = FAIRY_SECTION_RODATA; + } else { + break; + } + FAIRY_DEBUG_PRINTF("Found %s section\n", &shstrtab[currentSection.sh_name]); + + fileInfo->relocTablesInfo[relocSection].sectionType = SHT_RELA; + fileInfo->relocTablesInfo[relocSection].sectionEntrySize = sizeof(FairyRela); + fileInfo->relocTablesInfo[relocSection].sectionEntryCount = + Fairy_ReadRelocs((FairyRela**)&fileInfo->relocTablesInfo[relocSection].sectionData, file, + currentSection.sh_type, currentSection.sh_offset, currentSection.sh_size); + } + break; + + default: + break; + } + } + } + + free(sectionTable); + free(shstrtab); +} + +void Fairy_DestroyFile(FairyFileInfo* fileInfo) { + size_t i; + for (i = 0; i < ARRAY_COUNTU(fileInfo->relocTablesInfo); i++) { + if (fileInfo->relocTablesInfo[i].sectionData != NULL) { + FAIRY_DEBUG_PRINTF("Freeing reloc section %zd data\n", i); + free(fileInfo->relocTablesInfo[i].sectionData); + } + } + + vc_vector_release(fileInfo->progBitsSections); + + FAIRY_DEBUG_PRINTF("%s", "Freeing symtab data\n"); + free(fileInfo->symtabInfo.sectionData); + + FAIRY_DEBUG_PRINTF("%s", "Freeing strtab data\n"); + free(fileInfo->strtab); +} diff --git a/tools/fado/lib/fairy/fairy.h b/tools/fado/lib/fairy/fairy.h new file mode 100644 index 000000000..5a3cb3d97 --- /dev/null +++ b/tools/fado/lib/fairy/fairy.h @@ -0,0 +1,74 @@ +/* Copyright (C) 2021 Elliptic Ellipsis */ +/* SPDX-License-Identifier: AGPL-3.0-only */ +#pragma once + +#include +#include +#include "mips_elf.h" + +#include "vc_vector/vc_vector.h" + +#define FAIRY_DEF_STRING(prefix, x) \ + { prefix##x, #x } + +typedef enum { + VERBOSITY_NONE, + VERBOSITY_INFO, + VERBOSITY_DEBUG //, +} VerbosityLevel; + +extern VerbosityLevel gVerbosity; +extern bool gUseElfAlignment; + +typedef Elf32_Ehdr FairyFileHeader; +typedef Elf32_Shdr FairySecHeader; +typedef Elf32_Sym FairySym; +typedef Elf32_Rel FairyRel; +typedef Elf32_Rela FairyRela; + +typedef struct { + int define; + const char* string; +} FairyDefineString; + +typedef struct { + void* sectionData; + int sectionType; + size_t sectionEntryCount; + size_t sectionEntrySize; +} FairySectionInfo; + +typedef struct { + FairySectionInfo symtabInfo; + char* strtab; + Elf32_Word progBitsSizes[3]; + vc_vector* progBitsSections; + FairySectionInfo relocTablesInfo[3]; +} FairyFileInfo; + +typedef enum { + FAIRY_SECTION_TEXT, + FAIRY_SECTION_DATA, + FAIRY_SECTION_RODATA, + FAIRY_SECTION_OTHER //, +} FairySection; + +/* Prints debugging information to stderr. To be used via the macros. */ +int Fairy_DebugPrintf(const char* file, int line, const char* func, VerbosityLevel level, const char* fmt, ...); +#define FAIRY_INFO_PRINTF(fmt, ...) Fairy_DebugPrintf(__FILE__, __LINE__, __func__, VERBOSITY_INFO, fmt, __VA_ARGS__) +#define FAIRY_DEBUG_PRINTF(fmt, ...) Fairy_DebugPrintf(__FILE__, __LINE__, __func__, VERBOSITY_DEBUG, fmt, __VA_ARGS__) + +const char* Fairy_StringFromDefine(const FairyDefineString* dict, int define); +bool Fairy_StartsWith(const char* string, const char* initial); + +FairyFileHeader* Fairy_ReadFileHeader(FairyFileHeader* header, FILE* file); +FairySecHeader* Fairy_ReadSectionTable(FairySecHeader* sectionTable, FILE* file, size_t tableOffset, size_t number); +char* Fairy_ReadStringTable(char* stringTable, FILE* file, size_t tableOffset, size_t tableSize); +size_t Fairy_ReadSymbolTable(FairySym** symbolTableOut, FILE* file, size_t tableOffset, size_t tableSize); +size_t Fairy_ReadRelocs(FairyRela** relocsOut, FILE* file, int type, size_t offset, size_t size); + +char* Fairy_GetSectionName(FairySecHeader* sectionTable, char* shstrtab, size_t index); +char* Fairy_GetSymbolName(FairySym* symtab, char* strtab, size_t index); + +void Fairy_InitFile(FairyFileInfo* fileInfo, FILE* file); +void Fairy_DestroyFile(FairyFileInfo* fileInfo); diff --git a/tools/fado/lib/fairy/fairy_data.inc b/tools/fado/lib/fairy/fairy_data.inc new file mode 100644 index 000000000..5dfecfc20 --- /dev/null +++ b/tools/fado/lib/fairy/fairy_data.inc @@ -0,0 +1,126 @@ +/* Copyright (C) 2021 Elliptic Ellipsis */ +/* SPDX-License-Identifier: AGPL-3.0-only */ +#include "fairy.h" +#include "mips_elf.h" + +// clang-format off +static const FairyDefineString stTypes[] = { + FAIRY_DEF_STRING(STT_, NOTYPE), + FAIRY_DEF_STRING(STT_, OBJECT), + FAIRY_DEF_STRING(STT_, FUNC), + FAIRY_DEF_STRING(STT_, SECTION), + FAIRY_DEF_STRING(STT_, FILE), + FAIRY_DEF_STRING(STT_, COMMON), + FAIRY_DEF_STRING(STT_, TLS), + FAIRY_DEF_STRING(STT_, NUM), + FAIRY_DEF_STRING(STT_, LOOS), + FAIRY_DEF_STRING(STT_, GNU_IFUNC), + FAIRY_DEF_STRING(STT_, HIOS), + FAIRY_DEF_STRING(STT_, LOPROC), + FAIRY_DEF_STRING(STT_, HIPROC), + { 0 }, +}; + +static const FairyDefineString stBinds[] = { + FAIRY_DEF_STRING(STB_, LOCAL), + FAIRY_DEF_STRING(STB_, GLOBAL), + FAIRY_DEF_STRING(STB_, WEAK), + FAIRY_DEF_STRING(STB_, NUM), + FAIRY_DEF_STRING(STB_, LOOS), + FAIRY_DEF_STRING(STB_, GNU_UNIQUE), + FAIRY_DEF_STRING(STB_, HIOS), + FAIRY_DEF_STRING(STB_, LOPROC), + FAIRY_DEF_STRING(STB_, HIPROC), + { 0 }, +}; + +static const FairyDefineString stVisibilities[] = { + FAIRY_DEF_STRING(STV_, DEFAULT), + FAIRY_DEF_STRING(STV_, INTERNAL), + FAIRY_DEF_STRING(STV_, HIDDEN), + FAIRY_DEF_STRING(STV_, PROTECTED), + { 0 }, +}; + +/* TODO: understand this data better: there are several cases with the same number */ +static const FairyDefineString shTypes[] = { + FAIRY_DEF_STRING(SHT_, NULL), + FAIRY_DEF_STRING(SHT_, PROGBITS), + FAIRY_DEF_STRING(SHT_, SYMTAB), + FAIRY_DEF_STRING(SHT_, STRTAB), + FAIRY_DEF_STRING(SHT_, RELA), + FAIRY_DEF_STRING(SHT_, HASH), + FAIRY_DEF_STRING(SHT_, DYNAMIC), + FAIRY_DEF_STRING(SHT_, NOTE), + FAIRY_DEF_STRING(SHT_, NOBITS), + FAIRY_DEF_STRING(SHT_, REL), + FAIRY_DEF_STRING(SHT_, SHLIB), + FAIRY_DEF_STRING(SHT_, DYNSYM), + FAIRY_DEF_STRING(SHT_, INIT_ARRAY), + FAIRY_DEF_STRING(SHT_, FINI_ARRAY), + FAIRY_DEF_STRING(SHT_, PREINIT_ARRAY), + FAIRY_DEF_STRING(SHT_, GROUP), + FAIRY_DEF_STRING(SHT_, SYMTAB_SHNDX), + FAIRY_DEF_STRING(SHT_, NUM), + FAIRY_DEF_STRING(SHT_, LOOS), + FAIRY_DEF_STRING(SHT_, GNU_ATTRIBUTES), + FAIRY_DEF_STRING(SHT_, GNU_HASH), + FAIRY_DEF_STRING(SHT_, GNU_LIBLIST), + FAIRY_DEF_STRING(SHT_, CHECKSUM), + FAIRY_DEF_STRING(SHT_, LOSUNW), + FAIRY_DEF_STRING(SHT_, SUNW_move), + FAIRY_DEF_STRING(SHT_, SUNW_COMDAT), + FAIRY_DEF_STRING(SHT_, SUNW_syminfo), + FAIRY_DEF_STRING(SHT_, GNU_verdef), + FAIRY_DEF_STRING(SHT_, GNU_verneed), + FAIRY_DEF_STRING(SHT_, GNU_versym), + FAIRY_DEF_STRING(SHT_, HISUNW), + FAIRY_DEF_STRING(SHT_, HIOS), + FAIRY_DEF_STRING(SHT_, LOPROC), + FAIRY_DEF_STRING(SHT_, HIPROC), + FAIRY_DEF_STRING(SHT_, LOUSER), + FAIRY_DEF_STRING(SHT_, HIUSER), + FAIRY_DEF_STRING(SHT_, MIPS_LIBLIST), + FAIRY_DEF_STRING(SHT_, MIPS_MSYM), + FAIRY_DEF_STRING(SHT_, MIPS_CONFLICT), + FAIRY_DEF_STRING(SHT_, MIPS_GPTAB), + FAIRY_DEF_STRING(SHT_, MIPS_UCODE), + FAIRY_DEF_STRING(SHT_, MIPS_DEBUG), + FAIRY_DEF_STRING(SHT_, MIPS_REGINFO), + FAIRY_DEF_STRING(SHT_, MIPS_PACKAGE), + FAIRY_DEF_STRING(SHT_, MIPS_PACKSYM), + FAIRY_DEF_STRING(SHT_, MIPS_RELD), + FAIRY_DEF_STRING(SHT_, MIPS_IFACE), + FAIRY_DEF_STRING(SHT_, MIPS_CONTENT), + FAIRY_DEF_STRING(SHT_, MIPS_OPTIONS), + FAIRY_DEF_STRING(SHT_, MIPS_SHDR), + FAIRY_DEF_STRING(SHT_, MIPS_FDESC), + FAIRY_DEF_STRING(SHT_, MIPS_EXTSYM), + FAIRY_DEF_STRING(SHT_, MIPS_DENSE), + FAIRY_DEF_STRING(SHT_, MIPS_PDESC), + FAIRY_DEF_STRING(SHT_, MIPS_LOCSYM), + FAIRY_DEF_STRING(SHT_, MIPS_AUXSYM), + FAIRY_DEF_STRING(SHT_, MIPS_OPTSYM), + FAIRY_DEF_STRING(SHT_, MIPS_LOCSTR), + FAIRY_DEF_STRING(SHT_, MIPS_LINE), + FAIRY_DEF_STRING(SHT_, MIPS_RFDESC), + FAIRY_DEF_STRING(SHT_, MIPS_DELTASYM), + FAIRY_DEF_STRING(SHT_, MIPS_DELTAINST), + FAIRY_DEF_STRING(SHT_, MIPS_DELTACLASS), + FAIRY_DEF_STRING(SHT_, MIPS_DWARF), + FAIRY_DEF_STRING(SHT_, MIPS_DELTADECL), + FAIRY_DEF_STRING(SHT_, MIPS_SYMBOL_LIB), + FAIRY_DEF_STRING(SHT_, MIPS_EVENTS), + FAIRY_DEF_STRING(SHT_, MIPS_TRANSLATE), + FAIRY_DEF_STRING(SHT_, MIPS_PIXIE), + FAIRY_DEF_STRING(SHT_, MIPS_XLATE), + FAIRY_DEF_STRING(SHT_, MIPS_XLATE_DEBUG), + FAIRY_DEF_STRING(SHT_, MIPS_WHIRL), + FAIRY_DEF_STRING(SHT_, MIPS_EH_REGION), + FAIRY_DEF_STRING(SHT_, MIPS_XLATE_OLD), + FAIRY_DEF_STRING(SHT_, MIPS_PDR_EXCEPTION), + // FAIRY_DEF_STRING(SHT_, MIPS_XHASH), /* New in 2019 */ + { 0 }, +}; + +// clang-format on diff --git a/tools/fado/lib/fairy/fairy_print.c b/tools/fado/lib/fairy/fairy_print.c new file mode 100644 index 000000000..80b8fcd9e --- /dev/null +++ b/tools/fado/lib/fairy/fairy_print.c @@ -0,0 +1,463 @@ +/** + * Functions for printing various sections of an N64 ELF file using the functions in Fairy, similarly to readelf + */ +/* Copyright (C) 2021 Elliptic Ellipsis */ +/* SPDX-License-Identifier: AGPL-3.0-only */ +#include "fairy.h" + +#include +#include +#include +#include +#include +#include + +#include "fairy_data.inc" + +void Fairy_PrintSymbolTable(FILE* inputFile) { + FairyFileHeader fileHeader; + FairySecHeader* sectionTable; + size_t shstrndx; + char* shstrtab; + FairySym* symbolTable = NULL; + size_t symbolTableNum = 0; + char* strtab = NULL; + + Fairy_ReadFileHeader(&fileHeader, inputFile); + sectionTable = malloc(fileHeader.e_shentsize * fileHeader.e_shnum); + shstrndx = fileHeader.e_shstrndx; + + Fairy_ReadSectionTable(sectionTable, inputFile, fileHeader.e_shoff, fileHeader.e_shnum); + + shstrtab = malloc(sectionTable[shstrndx].sh_size * sizeof(char)); + + fseek(inputFile, sectionTable[shstrndx].sh_offset, SEEK_SET); + assert(fread(shstrtab, sizeof(char), sectionTable[shstrndx].sh_size, inputFile) == sectionTable[shstrndx].sh_size); + + { + size_t currentIndex; + size_t strtabndx = 0; + for (currentIndex = 0; currentIndex < fileHeader.e_shnum; currentIndex++) { + FairySecHeader currentHeader = sectionTable[currentIndex]; + + switch (currentHeader.sh_type) { + case SHT_SYMTAB: + if (strcmp(&shstrtab[currentHeader.sh_name], ".symtab") == 0) { + printf("symtab found\n"); + symbolTableNum = Fairy_ReadSymbolTable(&symbolTable, inputFile, currentHeader.sh_offset, + currentHeader.sh_size); + } + break; + + case SHT_STRTAB: + if (strcmp(&shstrtab[currentHeader.sh_name], ".strtab") == 0) { + strtabndx = currentIndex; + } + break; + + default: + break; + } + } + + if (symbolTable == NULL) { + puts("No symtab found."); + free(sectionTable); + return; + } + + if (strtabndx != 0) { + printf("strtab found\n"); + printf("Size: %X bytes\n", sectionTable[strtabndx].sh_size); + strtab = malloc(sectionTable[strtabndx].sh_size); + printf("and mallocked\n"); + fseek(inputFile, sectionTable[strtabndx].sh_offset, SEEK_SET); + printf("file offset sought: %X\n", sectionTable[strtabndx].sh_offset); + assert(fread(strtab, sizeof(char), sectionTable[strtabndx].sh_size, inputFile) == + sectionTable[strtabndx].sh_size); + printf("file read\n"); + } + } + + { + size_t currentIndex; + printf("Symbol table\n"); + printf(" Num: Value Size Type Bind Vis Ndx Name\n"); + for (currentIndex = 0; currentIndex < symbolTableNum; currentIndex++) { + FairySym currentSymbol = symbolTable[currentIndex]; + printf("%4zd: ", currentIndex); + printf("%08X ", currentSymbol.st_value); + printf("%4X ", currentSymbol.st_size); + printf("%-11s ", Fairy_StringFromDefine(stTypes, ELF32_ST_TYPE(currentSymbol.st_info))); + printf("%-10s ", Fairy_StringFromDefine(stBinds, ELF32_ST_BIND(currentSymbol.st_info))); + printf("%-11s ", Fairy_StringFromDefine(stVisibilities, ELF32_ST_VISIBILITY(currentSymbol.st_other))); + + if (currentSymbol.st_shndx != 0) { + printf("%3X ", currentSymbol.st_shndx); + } else { + printf("UND "); + } + + if (strtab != NULL) { + printf("%s", &strtab[currentSymbol.st_name]); + } else { + printf("%4X ", currentSymbol.st_name); + } + putchar('\n'); + } + } + + free(sectionTable); + free(symbolTable); + if (strtab != NULL) { + free(strtab); + } +} + +void Fairy_PrintRelocs(FILE* inputFile) { + FairyFileHeader fileHeader; + FairySecHeader* sectionTable; + FairyRela* relocs; + size_t shstrndx; + char* shstrtab; + size_t currentSection; + + Fairy_ReadFileHeader(&fileHeader, inputFile); + sectionTable = malloc(fileHeader.e_shentsize * fileHeader.e_shnum); + shstrndx = fileHeader.e_shstrndx; + + Fairy_ReadSectionTable(sectionTable, inputFile, fileHeader.e_shoff, fileHeader.e_shnum); + + shstrtab = malloc(sectionTable[shstrndx].sh_size * sizeof(char)); + + fseek(inputFile, sectionTable[shstrndx].sh_offset, SEEK_SET); + assert(fread(shstrtab, sizeof(char), sectionTable[shstrndx].sh_size, inputFile) == sectionTable[shstrndx].sh_size); + + for (currentSection = 0; currentSection < fileHeader.e_shnum; currentSection++) { + size_t nRelocs; + + if (sectionTable[currentSection].sh_type != SHT_REL || sectionTable[currentSection].sh_type != SHT_RELA) { + continue; + } + printf("Section size: %d\n", sectionTable[currentSection].sh_size); + + nRelocs = Fairy_ReadRelocs(&relocs, inputFile, sectionTable[currentSection].sh_type, + sectionTable[currentSection].sh_offset, sectionTable[currentSection].sh_size); + + // fseek(inputFile, sectionTable[currentSection].sh_offset, SEEK_SET); + // assert(fread(relocs, sizeof(char), sectionTable[currentSection].sh_size, inputFile) == + // sectionTable[currentSection].sh_size); + + printf("Relocs in section [%2zd]: %s:\n", currentSection, shstrtab + sectionTable[currentSection].sh_name); + printf("Offset Info Type Symbol\n"); + { + size_t currentReloc; + for (currentReloc = 0; currentReloc < nRelocs; currentReloc++) { + printf("%08X,%08X ", relocs[currentReloc].r_offset, relocs[currentReloc].r_info); + + switch (ELF32_R_TYPE(relocs[currentReloc].r_info)) { + case R_MIPS_NONE: + printf("%-15s", "R_MIPS_NONE"); + break; + case R_MIPS_16: + printf("%-15s", "R_MIPS_16"); + break; + case R_MIPS_32: + printf("%-15s", "R_MIPS_32"); + break; + case R_MIPS_REL32: + printf("%-15s", "R_MIPS_REL32"); + break; + case R_MIPS_26: + printf("%-15s", "R_MIPS_26"); + break; + case R_MIPS_HI16: + printf("%-15s", "R_MIPS_HI16"); + break; + case R_MIPS_LO16: + printf("%-15s", "R_MIPS_LO16"); + break; + default: + break; + } + + printf("%X", ELF32_R_SYM(relocs[currentReloc].r_info)); + + putchar('\n'); + } + putchar('\n'); + } + putchar('\n'); + + free(relocs); + } + free(sectionTable); + free(shstrtab); +} + +void Fairy_PrintSectionTable(FILE* inputFile) { + FairyFileHeader fileHeader; + FairySecHeader* sectionTable; + size_t shstrndx; + char* shstrtab; + size_t currentSection; + + Fairy_ReadFileHeader(&fileHeader, inputFile); + sectionTable = malloc(fileHeader.e_shentsize * fileHeader.e_shnum); + shstrndx = fileHeader.e_shstrndx; + + Fairy_ReadSectionTable(sectionTable, inputFile, fileHeader.e_shoff, fileHeader.e_shnum); + + shstrtab = malloc(sectionTable[shstrndx].sh_size * sizeof(char)); + + fseek(inputFile, sectionTable[shstrndx].sh_offset, SEEK_SET); + assert(fread(shstrtab, sizeof(char), sectionTable[shstrndx].sh_size, inputFile) == sectionTable[shstrndx].sh_size); + + printf("[Nr] Name Type Addr Off Size ES Flg Lk Inf Al\n"); + for (currentSection = 0; currentSection < fileHeader.e_shnum; currentSection++) { + FairySecHeader entry = sectionTable[currentSection]; + printf("[%2zd] ", currentSection); + printf("%-15s", shstrtab + entry.sh_name); + + printf("%-15s", Fairy_StringFromDefine(shTypes, entry.sh_type)); + + // printf("%08X ", entry.sh_type); + printf("%08X ", entry.sh_addr); + printf("%06X ", entry.sh_offset); + printf("%06X ", entry.sh_size); + printf("%02X ", entry.sh_entsize); + // printf("%08X ", entry.sh_flags); + + { + char flagChars[] = { 'W', 'A', 'X', 'M', 'S', 'I', 'L', 'O', 'G', 'T', 'C', 'x', 'o', 'E', 'p' }; + uint32_t flags = entry.sh_flags; + size_t shift; + int pad = 4; + for (shift = 0; shift < sizeof(flagChars); shift++) { + if ((flags >> shift) & 1) { + putchar(flagChars[shift]); + pad--; + } + } + if (pad > 0) { + printf("%*s", pad, ""); + } + } + + printf("%2X ", entry.sh_link); + printf("%3X ", entry.sh_info); + printf("%2X", entry.sh_addralign); + putchar('\n'); + } +} + +typedef enum { REL_SECTION_NONE, REL_SECTION_TEXT, REL_SECTION_DATA, REL_SECTION_RODATA } FairyOverlayRelSection; + +const char* relSectionStrings[] = { + NULL, + ".text", + ".data", + ".rodata", +}; + +static uint32_t Fairy_PackReloc(FairyOverlayRelSection sec, FairyRela rel) { + return (sec << 0x1E) | (ELF32_R_TYPE(rel.r_info) << 0x18) | rel.r_offset; +} + +void Fairy_PrintSectionSizes(FairySecHeader* sectionTable, FILE* inputFile, size_t tableSize, char* shstrtab) { + size_t number = tableSize / sizeof(FairySecHeader); + FairySecHeader currentHeader; + char* sectionName; + size_t relocSectionsCount = 0; + size_t* relocSectionIndices; + int* relocSectionSection; + size_t currentRelocSection = 0; + FairySecHeader symtabHeader; + FairySym* symtab; + FairySecHeader strtabHeader; + char* strtab = NULL; + // size_t symtabSize; + + uint32_t textSize = 0; + uint32_t dataSize = 0; + uint32_t rodataSize = 0; + uint32_t bssSize = 0; + uint32_t relocCount = 0; + + size_t currentSection; + bool symtabFound = false; + bool strtabFound = false; + /* Count the reloc sections */ + for (currentSection = 0; currentSection < number; currentSection++) { + if (sectionTable[currentSection].sh_type == SHT_REL || sectionTable[currentSection].sh_type == SHT_RELA) { + relocSectionsCount++; + } + } + printf("relocSectionsCount: %zd\n", relocSectionsCount); + + relocSectionIndices = malloc(relocSectionsCount * sizeof(int)); + relocSectionSection = malloc(relocSectionsCount * sizeof(int)); + + /* Find the section sizes and the reloc sections */ + for (currentSection = 0; currentSection < number; currentSection++) { + size_t off = 0; + + currentHeader = sectionTable[currentSection]; + sectionName = &shstrtab[currentHeader.sh_name + 1]; /* ignore the initial '.' */ + switch (currentHeader.sh_type) { + case SHT_PROGBITS: + if (Fairy_StartsWith(sectionName, "rodata")) { + printf("rodata\n"); + rodataSize += currentHeader.sh_size; + break; + } + if (Fairy_StartsWith(sectionName, "data")) { + printf("data\n"); + dataSize += currentHeader.sh_size; + break; + } + if (Fairy_StartsWith(sectionName, "text")) { + printf("text\n"); + textSize += currentHeader.sh_size; + break; + } + break; + + case SHT_NOBITS: + if (Fairy_StartsWith(sectionName, "bss")) { + printf("bss\n"); + bssSize += currentHeader.sh_size; + } + break; + + case SHT_RELA: + off += 1; + case SHT_REL: + relocSectionIndices[currentRelocSection] = currentSection; + off += 4; /* ignore the "rel."/"rela." part */ + if (Fairy_StartsWith(§ionName[off], "rodata")) { + printf("%s\n", sectionName); + relocSectionSection[currentRelocSection] = REL_SECTION_RODATA; + } else if (Fairy_StartsWith(§ionName[off], "data")) { + printf("%s\n", sectionName); + relocSectionSection[currentRelocSection] = REL_SECTION_DATA; + } else if (Fairy_StartsWith(§ionName[off], "text")) { + printf("%s\n", sectionName); + relocSectionSection[currentRelocSection] = REL_SECTION_TEXT; + } + + currentRelocSection++; + break; + + case SHT_SYMTAB: + if (Fairy_StartsWith(sectionName, "symtab")) { + symtabHeader = currentHeader; + symtabFound = true; + } + break; + + case SHT_STRTAB: + if (Fairy_StartsWith(sectionName, "strtab")) { + strtabHeader = currentHeader; + strtabFound = true; + } + break; + + default: + break; + } + } + /* Can use symbols here too */ + puts(".section .ovl"); + printf("# OverlayInfo\n"); + printf(".word 0x%08X # .text size\n", textSize); + printf(".word 0x%08X # .data size\n", dataSize); + printf(".word 0x%08X # .rodata size\n", rodataSize); + printf(".word 0x%08X # .bss size\n\n", bssSize); + + if (!symtabFound) { + fprintf(stderr, "Symbol table not found\n"); + return; + } + /* Obtain the symbol table */ + // TODO: Consider replacing this with a lighter-weight read: sufficient to get the name, shndx + Fairy_ReadSymbolTable(&symtab, inputFile, symtabHeader.sh_offset, symtabHeader.sh_size); + + if (!strtabFound) { + fprintf(stderr, "String table not found\n"); + } else { + /* Obtain the string table */ + strtab = malloc(strtabHeader.sh_size); + fseek(inputFile, strtabHeader.sh_offset, SEEK_SET); + assert(fread(strtab, sizeof(char), strtabHeader.sh_size, inputFile) == strtabHeader.sh_size); + } + + /* Do single-file relocs */ + { + FairyRela* relocs; + for (currentSection = 0; currentSection < relocSectionsCount; currentSection++) { + size_t currentReloc; + size_t nRelocs; + + currentHeader = sectionTable[relocSectionIndices[currentSection]]; + nRelocs = Fairy_ReadRelocs(&relocs, inputFile, currentHeader.sh_type, currentHeader.sh_offset, + currentHeader.sh_size); + + for (currentReloc = 0; currentReloc < nRelocs; currentReloc++) { + FairySym symbol = symtab[ELF32_R_SYM(relocs[currentReloc].r_info)]; + if (symbol.st_shndx == SHN_UNDEF) { + continue; // TODO: this is where multifile has to look elsewhere + } + + printf(".word 0x%08X", Fairy_PackReloc(relocSectionSection[currentSection], relocs[currentReloc])); + printf(" # %X (%s), %X, 0x%06X", relocSectionSection[currentSection], &shstrtab[currentHeader.sh_name], + ELF32_R_TYPE(relocs[currentReloc].r_info), relocs[currentReloc].r_offset); + if (strtab != NULL) { + printf(", %s", &strtab[symbol.st_name]); + } + putchar('\n'); + + relocCount++; + } + + free(relocs); + } + } + + printf(".word %d # relocCount\n", relocCount); + + { + uint32_t ovlSectionSize = ((relocCount + 8) & ~0x03) * sizeof(uint32_t); + + printf("\n.word 0x%08X # Overlay section size\n", ovlSectionSize); + } + + free(relocSectionIndices); + free(relocSectionSection); + if (strtab != NULL) { + free(strtab); + } +} + +void PrintZeldaReloc(FILE* inputFile) { + FairyFileHeader fileHeader; + FairySecHeader* sectionTable; + size_t shstrndx; + char* shstrtab; + + Fairy_ReadFileHeader(&fileHeader, inputFile); + sectionTable = malloc(fileHeader.e_shentsize * fileHeader.e_shnum); + shstrndx = fileHeader.e_shstrndx; + + Fairy_ReadSectionTable(sectionTable, inputFile, fileHeader.e_shoff, fileHeader.e_shnum); + + shstrtab = malloc(sectionTable[shstrndx].sh_size * sizeof(char)); + + fseek(inputFile, sectionTable[shstrndx].sh_offset, SEEK_SET); + assert(fread(shstrtab, sizeof(char), sectionTable[shstrndx].sh_size, inputFile) == sectionTable[shstrndx].sh_size); + + Fairy_PrintSectionSizes(sectionTable, inputFile, fileHeader.e_shentsize * fileHeader.e_shnum, shstrtab); + + free(sectionTable); + free(shstrtab); +} diff --git a/tools/fado/lib/fairy/fairy_print.h b/tools/fado/lib/fairy/fairy_print.h new file mode 100644 index 000000000..85061be22 --- /dev/null +++ b/tools/fado/lib/fairy/fairy_print.h @@ -0,0 +1,7 @@ +/* Copyright (C) 2021 Elliptic Ellipsis */ +/* SPDX-License-Identifier: AGPL-3.0-only */ +#include + +void Fairy_PrintSymbolTable(FILE* inputFile); +void Fairy_PrintRelocs(FILE* inputFile); +void Fairy_PrintSectionTable(FILE* inputFile); diff --git a/tools/fado/lib/vc_vector/.gitrepo b/tools/fado/lib/vc_vector/.gitrepo new file mode 100644 index 000000000..7ab27b998 --- /dev/null +++ b/tools/fado/lib/vc_vector/.gitrepo @@ -0,0 +1,12 @@ +; DO NOT EDIT (unless you know what you are doing) +; +; This subdirectory is a git "subrepo", and this file is maintained by the +; git-subrepo command. See https://github.com/git-commands/git-subrepo#readme +; +[subrepo] + remote = git@github.com:skogorev/vc_vector.git + branch = master + commit = 39108a4b0aeb904636514b37f418c590084220a7 + parent = 462bee5811d54659236ca51481d01b76c69a37a7 + method = merge + cmdver = 0.4.3 diff --git a/tools/fado/lib/vc_vector/.travis.yml b/tools/fado/lib/vc_vector/.travis.yml new file mode 100644 index 000000000..f30dfb8e2 --- /dev/null +++ b/tools/fado/lib/vc_vector/.travis.yml @@ -0,0 +1,6 @@ +language: c +compiler: + - gcc + - clang +script: + - make && make test diff --git a/tools/fado/lib/vc_vector/LICENSE.md b/tools/fado/lib/vc_vector/LICENSE.md new file mode 100644 index 000000000..05929e19d --- /dev/null +++ b/tools/fado/lib/vc_vector/LICENSE.md @@ -0,0 +1,21 @@ +#The MIT License (MIT) + +*Copyright (c) 2016 Skogorev Anton* + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/tools/fado/lib/vc_vector/Makefile b/tools/fado/lib/vc_vector/Makefile new file mode 100644 index 000000000..129ee97e3 --- /dev/null +++ b/tools/fado/lib/vc_vector/Makefile @@ -0,0 +1,33 @@ +OUT_DIR := build +CFLAGS := -O2 -g -std=c99 -Wall -Wextra -Wpedantic -Werror + +SRCS := $(wildcard *.c) +OBJS := $(patsubst %.c,$(OUT_DIR)/%.o,$(SRCS)) + +LIB_NAME := vc-vector +SOBJ := $(OUT_DIR)/lib$(LIB_NAME).so + +.PHONY: all lib test clean + +all: lib + +lib: $(SOBJ) + +test: $(OUT_DIR)/test_runner + $(OUT_DIR)/test_runner + +clean: + rm -rf $(OUT_DIR) + +$(OUT_DIR): + mkdir -p $(OUT_DIR) + +$(SOBJ): vc_vector.c | $(OUT_DIR) + $(CC) $(CFLAGS) -shared -fPIC $< -o $@ + +$(OUT_DIR)/%.o: %.c | $(OUT_DIR) + $(CC) $(CFLAGS) -c $< -o $@ + +$(OUT_DIR)/test_runner: $(OBJS) | $(OUT_DIR) + $(CC) $^ -o $@ + diff --git a/tools/fado/lib/vc_vector/README.md b/tools/fado/lib/vc_vector/README.md new file mode 100644 index 000000000..c8f8b2ae3 --- /dev/null +++ b/tools/fado/lib/vc_vector/README.md @@ -0,0 +1,92 @@ +# vc_vector +Fast simple C vector implementation + +[![Build Status: make && make test](https://travis-ci.org/skogorev/vc_vector.svg)](https://travis-ci.org/skogorev/vc_vector) + +## Usage + +### Basic +```c +#include "vc_vector.h" + +int main() { + // Creates an empty vector with the default reserved size + // and without custom deleter. Vector will contain 'int' + vc_vector* v = vc_vector_create(0, sizeof(int), NULL); + if (!v) { + return 1; + } + + const int count = 10; + for (int i = 0; i < count; ++i) { + // The function takes a pointer to the elements, + // but the vector will make a copy of the element + vc_vector_push_back(v, &i); + } + + // Print each vector element + for (void* i = vc_vector_begin(v); + i != vc_vector_end(v); + i = vc_vector_next(v, i)) { + printf("%u; ", *(int*)i); + } + + vc_vector_release(v); + return 0; +} +``` + +### Advanced +```c +#include "vc_vector.h" + +struct Item { + int val1; + int val2; +}; + +int main() { + const int n = 10; + + // Creates an empty vector with the reserved size for the 'n' elements + // and with custom deleter 'free'. Vector will contain pointers to 'Item' + vc_vector* v = vc_vector_create(n, sizeof(struct Node*), free); + if (!v) { + return 1; + } + + struct Item* item = NULL; + const int count = n + 1; + // Vector automatically increases the reserved size when 'n + 1' will be added + for (int i = 0; i < count; ++i) { + // Creating item + item = malloc(sizeof(struct Item)); + if (!item) { + continue; + } + + item->val1 = i; + item->val2 = 0; + + // Pushing to the end of the vector + if (!vc_vector_push_back(v, item)) { + // If the item was not pushed, you have to delete it + free(item); + } + } + + // ... + + // Calls custom deleter 'free' for all items + // and releases the vector + vc_vector_release(v); + return 0; +} +``` + +## Projects that use vc_vector +[kraken.io](https://kraken.io/) + +## License + +[MIT License](LICENSE.md) diff --git a/tools/fado/lib/vc_vector/vc_vector.c b/tools/fado/lib/vc_vector/vc_vector.c new file mode 100644 index 000000000..3f677c242 --- /dev/null +++ b/tools/fado/lib/vc_vector/vc_vector.c @@ -0,0 +1,329 @@ +#include "vc_vector.h" +#include +#include + +#define GROWTH_FACTOR 1.5 +#define DEFAULT_COUNT_OF_ELEMENTS 8 +#define MINIMUM_COUNT_OF_ELEMENTS 2 + +// ---------------------------------------------------------------------------- + +// vc_vector structure + +struct vc_vector { + size_t count; + size_t element_size; + size_t reserved_size; + char* data; + vc_vector_deleter* deleter; +}; + +// ---------------------------------------------------------------------------- + +// Auxiliary methods + +bool vc_vector_realloc(vc_vector* vector, size_t new_count) { + const size_t new_size = new_count * vector->element_size; + char* new_data = (char*)realloc(vector->data, new_size); + if (!new_data) { + return false; + } + + vector->reserved_size = new_size; + vector->data = new_data; + return true; +} + +// [first_index, last_index) +void vc_vector_call_deleter(vc_vector* vector, size_t first_index, size_t last_index) { + for (size_t i = first_index; i < last_index; ++i) { + vector->deleter(vc_vector_at(vector, i)); + } +} + +void vc_vector_call_deleter_all(vc_vector* vector) { + vc_vector_call_deleter(vector, 0, vc_vector_count(vector)); +} + +// ---------------------------------------------------------------------------- + +// Control + +vc_vector* vc_vector_create(size_t count_elements, size_t size_of_element, vc_vector_deleter* deleter) { + vc_vector* v = (vc_vector*)malloc(sizeof(vc_vector)); + if (v != NULL) { + v->data = NULL; + v->count = 0; + v->element_size = size_of_element; + v->deleter = deleter; + + if (count_elements < MINIMUM_COUNT_OF_ELEMENTS) { + count_elements = DEFAULT_COUNT_OF_ELEMENTS; + } + + if (size_of_element < 1 || + !vc_vector_realloc(v, count_elements)) { + free(v); + v = NULL; + } + } + + return v; +} + +vc_vector* vc_vector_create_copy(const vc_vector* vector) { + vc_vector* new_vector = vc_vector_create(vector->reserved_size / vector->count, + vector->element_size, + vector->deleter); + if (!new_vector) { + return new_vector; + } + + if (memcpy(vector->data, + new_vector->data, + new_vector->element_size * vector->count) == NULL) { + vc_vector_release(new_vector); + new_vector = NULL; + return new_vector; + } + + new_vector->count = vector->count; + return new_vector; +} + +void vc_vector_release(vc_vector* vector) { + if (vector->deleter != NULL) { + vc_vector_call_deleter_all(vector); + } + + if (vector->reserved_size != 0) { + free(vector->data); + } + + free(vector); +} + +bool vc_vector_is_equals(vc_vector* vector1, vc_vector* vector2) { + const size_t size_vector1 = vc_vector_size(vector1); + if (size_vector1 != vc_vector_size(vector2)) { + return false; + } + + return memcmp(vector1->data, vector2->data, size_vector1) == 0; +} + +float vc_vector_get_growth_factor() { + return GROWTH_FACTOR; +} + +size_t vc_vector_get_default_count_of_elements() { + return DEFAULT_COUNT_OF_ELEMENTS; +} + +size_t vc_vector_struct_size() { + return sizeof(vc_vector); +} + +// ---------------------------------------------------------------------------- + +// Element access + +void* vc_vector_at(vc_vector* vector, size_t index) { + return vector->data + index * vector->element_size; +} + +void* vc_vector_front(vc_vector* vector) { + return vector->data; +} + +void* vc_vector_back(vc_vector* vector) { + return vector->data + (vector->count - 1) * vector->element_size; +} + +void* vc_vector_data(vc_vector* vector) { + return vector->data; +} + +// ---------------------------------------------------------------------------- + +// Iterators + +void* vc_vector_begin(vc_vector* vector) { + return vector->data; +} + +void* vc_vector_end(vc_vector* vector) { + return vector->data + vector->element_size * vector->count; +} + +void* vc_vector_next(vc_vector* vector, void* i) { + return (char *)i + vector->element_size; +} + +// ---------------------------------------------------------------------------- + +// Capacity + +bool vc_vector_empty(vc_vector* vector) { + return vector->count == 0; +} + +size_t vc_vector_count(const vc_vector* vector) { + return vector->count; +} + +size_t vc_vector_size(const vc_vector* vector) { + return vector->count * vector->element_size; +} + +size_t vc_vector_max_count(const vc_vector* vector) { + return vector->reserved_size / vector->element_size; +} + +size_t vc_vector_max_size(const vc_vector* vector) { + return vector->reserved_size; +} + +bool vc_vector_reserve_count(vc_vector* vector, size_t new_count) { + if (new_count < vector->count) { + return false; + } + + size_t new_size = vector->element_size * new_count; + if (new_size == vector->reserved_size) { + return true; + } + + return vc_vector_realloc(vector, new_count); +} + +bool vc_vector_reserve_size(vc_vector* vector, size_t new_size) { + return vc_vector_reserve_count(vector, new_size / vector->element_size); +} + +// ---------------------------------------------------------------------------- + +// Modifiers + +void vc_vector_clear(vc_vector* vector) { + if (vector->deleter != NULL) { + vc_vector_call_deleter_all(vector); + } + + vector->count = 0; +} + +bool vc_vector_insert(vc_vector* vector, size_t index, const void* value) { + if (vc_vector_max_count(vector) < vector->count + 1) { + if (!vc_vector_realloc(vector, vc_vector_max_count(vector) * GROWTH_FACTOR)) { + return false; + } + } + + if (!memmove(vc_vector_at(vector, index + 1), + vc_vector_at(vector, index), + vector->element_size * (vector->count - index))) { + + return false; + } + + if (memcpy(vc_vector_at(vector, index), + value, + vector->element_size) == NULL) { + return false; + } + + ++vector->count; + return true; +} + +bool vc_vector_erase(vc_vector* vector, size_t index) { + if (vector->deleter != NULL) { + vector->deleter(vc_vector_at(vector, index)); + } + + if (!memmove(vc_vector_at(vector, index), + vc_vector_at(vector, index + 1), + vector->element_size * (vector->count - index))) { + return false; + } + + vector->count--; + return true; +} + +bool vc_vector_erase_range(vc_vector* vector, size_t first_index, size_t last_index) { + if (vector->deleter != NULL) { + vc_vector_call_deleter(vector, first_index, last_index); + } + + if (!memmove(vc_vector_at(vector, first_index), + vc_vector_at(vector, last_index), + vector->element_size * (vector->count - last_index))) { + return false; + } + + vector->count -= last_index - first_index; + return true; +} + +bool vc_vector_append(vc_vector* vector, const void* values, size_t count) { + const size_t count_new = count + vc_vector_count(vector); + + if (vc_vector_max_count(vector) < count_new) { + size_t max_count_to_reserved = vc_vector_max_count(vector) * GROWTH_FACTOR; + while (count_new > max_count_to_reserved) { + max_count_to_reserved *= GROWTH_FACTOR; + } + + if (!vc_vector_realloc(vector, max_count_to_reserved)) { + return false; + } + } + + if (memcpy(vector->data + vector->count * vector->element_size, + values, + vector->element_size * count) == NULL) { + return false; + } + + vector->count = count_new; + return true; +} + +bool vc_vector_push_back(vc_vector* vector, const void* value) { + if (!vc_vector_append(vector, value, 1)) { + return false; + } + + return true; +} + +bool vc_vector_pop_back(vc_vector* vector) { + if (vector->deleter != NULL) { + vector->deleter(vc_vector_back(vector)); + } + + vector->count--; + return true; +} + +bool vc_vector_replace(vc_vector* vector, size_t index, const void* value) { + if (vector->deleter != NULL) { + vector->deleter(vc_vector_at(vector, index)); + } + + return memcpy(vc_vector_at(vector, index), + value, + vector->element_size) != NULL; +} + +bool vc_vector_replace_multiple(vc_vector* vector, size_t index, const void* values, size_t count) { + if (vector->deleter != NULL) { + vc_vector_call_deleter(vector, index, index + count); + } + + return memcpy(vc_vector_at(vector, index), + values, + vector->element_size * count) != NULL; +} diff --git a/tools/fado/lib/vc_vector/vc_vector.h b/tools/fado/lib/vc_vector/vc_vector.h new file mode 100644 index 000000000..2b1422c1a --- /dev/null +++ b/tools/fado/lib/vc_vector/vc_vector.h @@ -0,0 +1,120 @@ +#ifndef VCVECTOR_H +#define VCVECTOR_H + +#include +#include + +typedef struct vc_vector vc_vector; +typedef void (vc_vector_deleter)(void *); + +// ---------------------------------------------------------------------------- +// Control +// ---------------------------------------------------------------------------- + +// Constructs an empty vector with an reserver size for count_elements. +vc_vector* vc_vector_create(size_t count_elements, size_t size_of_element, vc_vector_deleter* deleter); + +// Constructs a copy of an existing vector. +vc_vector* vc_vector_create_copy(const vc_vector* vector); + +// Releases the vector. +void vc_vector_release(vc_vector* vector); + +// Compares vector content +bool vc_vector_is_equals(vc_vector* vector1, vc_vector* vector2); + +// Returns constant value of the vector growth factor. +float vc_vector_get_growth_factor(); + +// Returns constant value of the vector default count of elements. +size_t vc_vector_get_default_count_of_elements(); + +// Returns constant value of the vector struct size. +size_t vc_vector_struct_size(); + +// ---------------------------------------------------------------------------- +// Element access +// ---------------------------------------------------------------------------- + +// Returns the item at index position in the vector. +void* vc_vector_at(vc_vector* vector, size_t index); + +// Returns the first item in the vector. +void* vc_vector_front(vc_vector* vector); + +// Returns the last item in the vector. +void* vc_vector_back(vc_vector* vector); + +// Returns a pointer to the data stored in the vector. The pointer can be used to access and modify the items in the vector. +void* vc_vector_data(vc_vector* vector); + +// ---------------------------------------------------------------------------- +// Iterators +// ---------------------------------------------------------------------------- + +// Returns a pointer to the first item in the vector. +void* vc_vector_begin(vc_vector* vector); + +// Returns a pointer to the imaginary item after the last item in the vector. +void* vc_vector_end(vc_vector* vector); + +// Returns a pointer to the next element of vector after 'i'. +void* vc_vector_next(vc_vector* vector, void* i); + +// ---------------------------------------------------------------------------- +// Capacity +// ---------------------------------------------------------------------------- + +// Returns true if the vector is empty; otherwise returns false. +bool vc_vector_empty(vc_vector* vector); + +// Returns the number of elements in the vector. +size_t vc_vector_count(const vc_vector* vector); + +// Returns the size (in bytes) of occurrences of value in the vector. +size_t vc_vector_size(const vc_vector* vector); + +// Returns the maximum number of elements that the vector can hold. +size_t vc_vector_max_count(const vc_vector* vector); + +// Returns the maximum size (in bytes) that the vector can hold. +size_t vc_vector_max_size(const vc_vector* vector); + +// Resizes the container so that it contains n elements. +bool vc_vector_reserve_count(vc_vector* vector, size_t new_count); + +// Resizes the container so that it contains new_size / element_size elements. +bool vc_vector_reserve_size(vc_vector* vector, size_t new_size); + +// ---------------------------------------------------------------------------- +// Modifiers +// ---------------------------------------------------------------------------- + +// Removes all elements from the vector (without reallocation). +void vc_vector_clear(vc_vector* vector); + +// The container is extended by inserting a new element at position. +bool vc_vector_insert(vc_vector* vector, size_t index, const void* value); + +// Removes from the vector a single element by 'index' +bool vc_vector_erase(vc_vector* vector, size_t index); + +// Removes from the vector a range of elements '[first_index, last_index)'. +bool vc_vector_erase_range(vc_vector* vector, size_t first_index, size_t last_index); + +// Inserts multiple values at the end of the vector. +bool vc_vector_append(vc_vector* vector, const void* values, size_t count); + +// Inserts value at the end of the vector. +bool vc_vector_push_back(vc_vector* vector, const void* value); + +// Removes the last item in the vector. +bool vc_vector_pop_back(vc_vector* vector); + +// Replace value by index in the vector. +bool vc_vector_replace(vc_vector* vector, size_t index, const void* value); + +// Replace multiple values by index in the vector. +bool vc_vector_replace_multiple(vc_vector* vector, size_t index, const void* values, size_t count); + +#endif // VCVECTOR_H diff --git a/tools/fado/lib/vc_vector/vc_vector_test.c b/tools/fado/lib/vc_vector/vc_vector_test.c new file mode 100644 index 000000000..03a054420 --- /dev/null +++ b/tools/fado/lib/vc_vector/vc_vector_test.c @@ -0,0 +1,353 @@ +#include "vc_vector_test.h" +#include +#include +#include +#include "vc_vector.h" + +#define ASSERT_EQ(expected, actual) \ + do { \ + if ((expected) != (actual)) { \ + fprintf(stderr, \ + "Failed line %u. Expected: %"PRIuMAX". Actual: %"PRIuMAX".\n", \ + __LINE__, (uintmax_t)(expected), (uintmax_t)(actual)); \ + abort(); \ + } \ + } while (0) + +#define ASSERT_NE(not_expected, actual) \ + do { \ + if ((not_expected) == (actual)) { \ + fprintf(stderr, \ + "Failed line %u. Unexpected actual value: %"PRIuMAX".\n", \ + __LINE__, (uintmax_t)(actual)); \ + abort(); \ + } \ + } while (0) + +#define ASSERT_TRUE(actual) ASSERT_EQ(true, (actual)) + +#define ASSERT_FALSE(actual) ASSERT_EQ(false, (actual)) + +#define PRINT_VECTOR(vector, type, format) \ + do { \ + for (void* i = vc_vector_begin(vector); \ + i != vc_vector_end(vector); \ + i = vc_vector_next(vector, i)) { \ + fprintf(stderr, format, *(type*)i); \ + } \ + fprintf(stderr, "\n"); \ + } while (0) + +#define PRINT_VECTOR_INT(vector) PRINT_VECTOR(vector, int, "%d; ") +#define PRINT_VECTOR_STR(vector) PRINT_VECTOR(vector, char *, "%s; ") + +char *mystrdup(const char *s) { + size_t size = strlen(s) + 1; + char *copy = malloc(size); + if (copy != NULL) + memcpy(copy, s, size); + return copy; +} + +// ---------------------------------------------------------------------------- + +void test_vc_vector_create() { + const size_t size_of_type = sizeof(int); + const size_t default_count_of_elements = vc_vector_get_default_count_of_elements(); + + // Creating vector with default count of elements + vc_vector* vector = vc_vector_create(0, size_of_type, NULL); + ASSERT_NE(NULL, vector); + ASSERT_EQ(0, vc_vector_count(vector)); + ASSERT_EQ(0, vc_vector_size(vector)); + ASSERT_EQ(default_count_of_elements, vc_vector_max_count(vector)); + ASSERT_EQ(size_of_type * default_count_of_elements, vc_vector_max_size(vector)); + vc_vector_release(vector); + + // Creating vector with custom count of elements + const size_t test_count_of_elements = 7; + vector = vc_vector_create(test_count_of_elements, size_of_type, NULL); + ASSERT_NE(NULL, vector); + ASSERT_EQ(0, vc_vector_count(vector)); + ASSERT_EQ(0, vc_vector_size(vector)); + ASSERT_EQ(test_count_of_elements, vc_vector_max_count(vector)); + ASSERT_EQ(size_of_type * test_count_of_elements, vc_vector_max_size(vector)); + vc_vector_release(vector); + + // Creating vector with zero size of single element + vector = vc_vector_create(0, 0, NULL); + ASSERT_EQ(NULL, vector); + + // Creating copy of vector + vector = vc_vector_create(0, size_of_type, NULL); + ASSERT_NE(NULL, vector); + for (int i = 0; (size_t)i < test_count_of_elements; ++i) { + ASSERT_TRUE(vc_vector_push_back(vector, &i)); + } + + vc_vector* vector_copy = vc_vector_create_copy(vector); + ASSERT_NE(NULL, vector_copy); + ASSERT_TRUE(vc_vector_is_equals(vector, vector_copy)); + + vc_vector_release(vector_copy); + vc_vector_release(vector); + + printf("%s passed.\n", __func__); +} + +void test_vc_vector_element_access() { + const int test_num_start = 18; + const int test_num_end = 36; + const size_t size_of_type = sizeof(test_num_start); + + vc_vector* vector = vc_vector_create(0, size_of_type, NULL); + ASSERT_NE(0, vector); + for (int i = test_num_start; i <= test_num_end; ++i) { + ASSERT_TRUE(vc_vector_push_back(vector, &i)); + } + + ASSERT_EQ(test_num_start, *(int*)vc_vector_front(vector)); + ASSERT_EQ(test_num_start, *(int*)vc_vector_data(vector)); + ASSERT_EQ(test_num_end, *(int*)vc_vector_back(vector)); + + for (int i = test_num_start, j = 0; i <= test_num_end; ++i, ++j) { + ASSERT_EQ(i, *(int*)vc_vector_at(vector, j)); + } + + vc_vector_release(vector); + + printf("%s passed.\n", __func__); +} + +void test_vc_vector_iterators() { + vc_vector* vector = vc_vector_create(0, sizeof(int), NULL); + ASSERT_NE(NULL, vector); + + const size_t test_count_of_elements = 23; + for (int i = 0; (size_t)i < test_count_of_elements; ++i) { + ASSERT_TRUE(vc_vector_push_back(vector, &i)); + } + + int j = 0; + for (void* i = vc_vector_begin(vector); + i != vc_vector_end(vector); + i = vc_vector_next(vector, i), ++j) { + ASSERT_EQ(j, *(int*)i); + } + + ASSERT_EQ(test_count_of_elements, (size_t)j); + vc_vector_release(vector); + + printf("%s passed.\n", __func__); +} + +void test_vc_vector_capacity() { + const size_t size_of_element = sizeof(int); + const float growth_factor = vc_vector_get_growth_factor(); + ASSERT_EQ(1.5, growth_factor); + + const size_t count_of_elements_initialized = 22; + const size_t max_size_of_vector_initialized = count_of_elements_initialized * size_of_element; + const size_t count_of_elements_ended = 23; + const size_t size_of_vector_ended = count_of_elements_ended * size_of_element; + const size_t max_count_of_vector_ended = count_of_elements_initialized * growth_factor; + const size_t max_size_of_vector_ended = max_count_of_vector_ended * size_of_element; + + vc_vector* vector = vc_vector_create(count_of_elements_initialized, size_of_element, NULL); + ASSERT_NE(NULL, vector); + + ASSERT_EQ(0, vc_vector_count(vector)); + ASSERT_TRUE(vc_vector_empty(vector)); + ASSERT_EQ(0, vc_vector_size(vector)); + ASSERT_EQ(count_of_elements_initialized, vc_vector_max_count(vector)); + ASSERT_EQ(max_size_of_vector_initialized, vc_vector_max_size(vector)); + + for (int i = 0; (size_t)i < count_of_elements_ended; ++i) { + ASSERT_TRUE(vc_vector_push_back(vector, &i)); + } + + ASSERT_EQ(count_of_elements_ended, vc_vector_count(vector)); + ASSERT_FALSE(vc_vector_empty(vector)); + ASSERT_EQ(size_of_vector_ended, vc_vector_size(vector)); + ASSERT_EQ(max_count_of_vector_ended, vc_vector_max_count(vector)); + ASSERT_EQ(max_size_of_vector_ended, vc_vector_max_size(vector)); + + const size_t test_reserve_count_fail = 10; + ASSERT_FALSE(vc_vector_reserve_count(vector, test_reserve_count_fail)); + + const size_t test_reserve_count = 35; + ASSERT_TRUE(vc_vector_reserve_count(vector, test_reserve_count)); + ASSERT_EQ(test_reserve_count, vc_vector_max_count(vector)); + ASSERT_EQ(test_reserve_count * size_of_element, vc_vector_max_size(vector)); + + // Second time with the same value + ASSERT_TRUE(vc_vector_reserve_count(vector, test_reserve_count)); + ASSERT_EQ(test_reserve_count, vc_vector_max_count(vector)); + ASSERT_EQ(test_reserve_count * size_of_element, vc_vector_max_size(vector)); + + const size_t test_reserve_size = 123 * size_of_element; + ASSERT_TRUE(vc_vector_reserve_size(vector, test_reserve_size)); + ASSERT_EQ(test_reserve_size / size_of_element, vc_vector_max_count(vector)); + ASSERT_EQ(test_reserve_size, vc_vector_max_size(vector)); + + vc_vector_release(vector); + + printf("%s passed.\n", __func__); +} + +void test_vc_vector_modifiers() { + const int begin[] = { + 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20 + }; + const size_t size_of_element = sizeof(begin[0]); + const size_t count_of_elements = sizeof(begin) / size_of_element; + + // After deleting first, last and one middle elements + const int after_deleting_some_elements[] = { + /* 1, */ 2, 3, 4, 5, 6, 7, 8, 9, 10, /* 11, */ 12, 13, 14, 15, 16, 17, 18, 19, /* 20 */ + }; + + // After deleting first 3 elemets from begin, 4 from middle and 3 from end + const int after_deleting_some_ranges[] = { + /* 1, 2, 3, */ 4, 5, 6, 7, 8, /* 9, 10, 11, 12, */ 13, 14, 15, 16, 17, /* 18, 19, 20 */ + }; + + vc_vector* vector = vc_vector_create(0, size_of_element, NULL); + ASSERT_NE(NULL, vector); + + // Append test + + ASSERT_TRUE(vc_vector_append(vector, begin, count_of_elements)); + + ASSERT_EQ(count_of_elements, vc_vector_count(vector)); + for (size_t i = 0; i < vc_vector_count(vector); ++i) { + ASSERT_EQ(begin[i], *(int*)vc_vector_at(vector, i)); + } + + // Pop back test + + while (vc_vector_count(vector) > 0) { + ASSERT_TRUE(vc_vector_pop_back(vector)); + } + + ASSERT_TRUE(vc_vector_empty(vector)); + + // Push back test + + for (size_t i = 0; i < count_of_elements; ++i) { + ASSERT_TRUE(vc_vector_push_back(vector, &begin[i])); + } + + ASSERT_EQ(count_of_elements, vc_vector_count(vector)); + for (size_t i = 0; i < vc_vector_count(vector); ++i) { + ASSERT_EQ(begin[i], *(int*)vc_vector_at(vector, i)); + } + + // Erase test + + vc_vector_clear(vector); + ASSERT_TRUE(vc_vector_append(vector, begin, count_of_elements)); + + ASSERT_TRUE(vc_vector_erase(vector, 0)); + ASSERT_TRUE(vc_vector_erase(vector, vc_vector_count(vector) - 1)); + ASSERT_TRUE(vc_vector_erase(vector, vc_vector_count(vector) / 2)); + + ASSERT_EQ(sizeof(after_deleting_some_elements) / size_of_element, vc_vector_count(vector)); + for (size_t i = 0; i < vc_vector_count(vector); ++i) { + ASSERT_EQ(after_deleting_some_elements[i], *(int*)vc_vector_at(vector, i)); + } + + // Erase range test + + vc_vector_clear(vector); + ASSERT_TRUE(vc_vector_append(vector, begin, count_of_elements)); + + ASSERT_TRUE(vc_vector_erase_range(vector, 0, 3)); + ASSERT_TRUE(vc_vector_erase_range(vector, vc_vector_count(vector) - 3, vc_vector_count(vector))); + ASSERT_TRUE(vc_vector_erase_range(vector, vc_vector_count(vector) / 2 - 2, vc_vector_count(vector) / 2 + 2)); + + ASSERT_EQ(sizeof(after_deleting_some_ranges) / size_of_element, vc_vector_count(vector)); + for (size_t i = 0; i < vc_vector_count(vector); ++i) { + ASSERT_EQ(after_deleting_some_ranges[i], *(int*)vc_vector_at(vector, i)); + } + + // Insert test + + vc_vector_clear(vector); + for (size_t i = 1; i < count_of_elements - 1; ++i) { + ASSERT_TRUE(vc_vector_insert(vector, i - 1, &begin[i])); + } + + ASSERT_TRUE(vc_vector_insert(vector, 0, &begin[0])); + ASSERT_TRUE(vc_vector_insert(vector, vc_vector_count(vector), &begin[count_of_elements - 1])); + + ASSERT_EQ(count_of_elements, vc_vector_count(vector)); + for (size_t i = 0; i < vc_vector_count(vector); ++i) { + ASSERT_EQ(begin[i], *(int*)vc_vector_at(vector, i)); + } + + vc_vector_release(vector); + + printf("%s passed.\n", __func__); +} + +void test_vc_vector_strfreefunc(void *data) { + free(*(char **)data); +} + +void test_vc_vector_with_strfreefunc() { + // creates a vector of pointers to char, i.e. a vector of variable sized strings + vc_vector* vector = vc_vector_create(3, sizeof(char *), test_vc_vector_strfreefunc); + ASSERT_NE(NULL, vector); + + char *strs[] = { + mystrdup("abcde"), + mystrdup("edcba"), + mystrdup("1234554321"), + mystrdup("!@#$%"), + mystrdup("not empty string"), + mystrdup(""), + mystrdup("Hello World"), + mystrdup("xxxxx"), + mystrdup("yyyyy") + }; + + for (size_t i = 0; i < 3; ++i) { + ASSERT_TRUE(vc_vector_push_back(vector, &strs[i])); + } + + ASSERT_EQ(3, vc_vector_count(vector)); + + for (size_t i = 3; i < 6; ++i) { + ASSERT_TRUE(vc_vector_insert(vector, i, &strs[i])); + } + + ASSERT_EQ(6, vc_vector_count(vector)); + vc_vector_clear(vector); // strs[0-6] were freed + ASSERT_EQ(0, vc_vector_count(vector)); + + for (size_t i = 6; i < 9; ++i) { + ASSERT_TRUE(vc_vector_push_back(vector, &strs[i])); + } + + ASSERT_EQ(3, vc_vector_count(vector)); + + vc_vector_release(vector); + + printf("%s passed.\n", __func__); +} + +void vc_vector_run_tests() { + test_vc_vector_create(); + test_vc_vector_element_access(); + test_vc_vector_iterators(); + test_vc_vector_capacity(); + test_vc_vector_modifiers(); + test_vc_vector_with_strfreefunc(); +} + +int main() { + vc_vector_run_tests(); + printf("Tests passed.\n"); + return 0; +} diff --git a/tools/fado/lib/vc_vector/vc_vector_test.h b/tools/fado/lib/vc_vector/vc_vector_test.h new file mode 100644 index 000000000..9439ea3c6 --- /dev/null +++ b/tools/fado/lib/vc_vector/vc_vector_test.h @@ -0,0 +1,6 @@ +#ifndef VCVECTORTESTS_H +#define VCVECTORTESTS_H + +void vc_vector_run_tests(); + +#endif // VCVECTORTESTS_H diff --git a/tools/fado/ovl_En_Hs_reloc.s b/tools/fado/ovl_En_Hs_reloc.s new file mode 100644 index 000000000..d41d172d1 --- /dev/null +++ b/tools/fado/ovl_En_Hs_reloc.s @@ -0,0 +1,46 @@ +.section .ovl +# ovl_En_Hs2OverlayInfo +.word _ovl_En_Hs2SegmentTextSize +.word _ovl_En_Hs2SegmentDataSize +.word _ovl_En_Hs2SegmentRoDataSize +.word _ovl_En_Hs2SegmentBssSize + +.word 28 # relocCount + +# TEXT RELOCS +.word 0x45000084 # R_MIPS_HI16 0x000084 .data +.word 0x4600008C # R_MIPS_LO16 0x00008C .data +.word 0x450000B4 # R_MIPS_HI16 0x0000B4 .rodata +.word 0x460000BC # R_MIPS_LO16 0x0000BC .rodata +.word 0x450000C0 # R_MIPS_HI16 0x0000C0 func_80A6F1A4 +.word 0x460000C4 # R_MIPS_LO16 0x0000C4 func_80A6F1A4 +.word 0x450001DC # R_MIPS_HI16 0x0001DC func_80A6F1A4 +.word 0x460001E0 # R_MIPS_LO16 0x0001E0 func_80A6F1A4 +.word 0x4500022C # R_MIPS_HI16 0x00022C func_80A6F164 +.word 0x46000230 # R_MIPS_LO16 0x000230 func_80A6F164 +.word 0x44000238 # R_MIPS_26 0x000238 func_80A6F0B4 +.word 0x450003D0 # R_MIPS_HI16 0x0003D0 .rodata +.word 0x460003D8 # R_MIPS_LO16 0x0003D8 .rodata +.word 0x45000460 # R_MIPS_HI16 0x000460 .data +.word 0x46000464 # R_MIPS_LO16 0x000464 .data +.word 0x4500049C # R_MIPS_HI16 0x00049C EnHs2_OverrideLimbDraw +.word 0x460004B4 # R_MIPS_LO16 0x0004B4 EnHs2_OverrideLimbDraw +.word 0x450004A0 # R_MIPS_HI16 0x0004A0 EnHs2_PostLimbDraw +.word 0x460004B0 # R_MIPS_LO16 0x0004B0 EnHs2_PostLimbDraw + +# DATA RELOCS +.word 0x82000010 # R_MIPS_32 0x000010 EnHs2_Init +.word 0x82000014 # R_MIPS_32 0x000014 EnHs2_Destroy +.word 0x82000018 # R_MIPS_32 0x000018 EnHs2_Update +.word 0x8200001C # R_MIPS_32 0x00001C EnHs2_Draw + +# RODATA RELOCS +.word 0xC2000020 # R_MIPS_32 0x000020 .text +.word 0xC2000024 # R_MIPS_32 0x000024 .text +.word 0xC2000028 # R_MIPS_32 0x000028 .text +.word 0xC200002C # R_MIPS_32 0x00002C .text +.word 0xC2000030 # R_MIPS_32 0x000030 .text +.word 0 +.word 0 + +.word 0x00000090 # ovl_En_Hs2OverlayInfoOffset diff --git a/tools/fado/src/fado.c b/tools/fado/src/fado.c new file mode 100644 index 000000000..464f8855b --- /dev/null +++ b/tools/fado/src/fado.c @@ -0,0 +1,308 @@ +/** + * Code specific to reading and outputting Zelda 64 relocations + */ +/* Copyright (C) 2021 Elliptic Ellipsis */ +/* SPDX-License-Identifier: AGPL-3.0-only */ +#include "fado.h" + +#include +#include +#include +#include +#include +#include +#include "fairy/fairy.h" +#include "macros.h" +#include "vc_vector/vc_vector.h" + +/* String-finding-related functions */ + +bool Fado_CheckInProgBitsSections(Elf32_Section section, vc_vector* progBitsSections) { + Elf32_Section* i; + VC_FOREACH(i, progBitsSections) { + if (*i == section) { + return true; + } + } + return false; +} + +/** + * For each input file, construct a vector of pointers to the starts of the strings defined in that file. + */ +void Fado_ConstructStringVectors(vc_vector** stringVectors, FairyFileInfo* fileInfo, int numFiles) { + int currentFile; + size_t currentSym; + + for (currentFile = 0; currentFile < numFiles; currentFile++) { + FairySym* symtab = fileInfo[currentFile].symtabInfo.sectionData; + + stringVectors[currentFile] = vc_vector_create(0x40, sizeof(char**), NULL); + + /* Build a vector of pointers to defined symbols' names */ + for (currentSym = 0; currentSym < fileInfo[currentFile].symtabInfo.sectionEntryCount; currentSym++) { + if ((symtab[currentSym].st_shndx != STN_UNDEF) && + Fado_CheckInProgBitsSections(symtab[currentSym].st_shndx, fileInfo[currentFile].progBitsSections)) { + /* Have to pass a double pointer so it copies the pointer instead of the start of the string */ + char* stringPtr = &fileInfo[currentFile].strtab[symtab[currentSym].st_name]; + assert(vc_vector_push_back(stringVectors[currentFile], &stringPtr)); + } + } + } +} + +bool Fado_FindSymbolNameInOtherFiles(const char* name, int thisFile, vc_vector** stringVectors, int numFiles) { + int currentFile; + char** currentString; + + for (currentFile = 0; currentFile < numFiles; currentFile++) { + if (currentFile == thisFile) { + continue; + } + VC_FOREACH(currentString, stringVectors[currentFile]) { + if (strcmp(name, *currentString) == 0) { + FAIRY_DEBUG_PRINTF("Match found for %s\n", name); + return true; + } + } + } + FAIRY_DEBUG_PRINTF("No match found for %s\n", name); + return false; +} + +void Fado_DestroyStringVectors(vc_vector** stringVectors, int numFiles) { + int currentFile; + for (currentFile = 0; currentFile < numFiles; currentFile++) { + vc_vector_release(stringVectors[currentFile]); + } + free(stringVectors); +} + +typedef struct { + size_t symbolIndex; + int file; + uint32_t relocWord; +} FadoRelocInfo; + +/* Construct the Zelda64ovl-compatible reloc word from an ELF reloc */ +FadoRelocInfo Fado_MakeReloc(int file, FairySection section, FairyRela* data) { + FadoRelocInfo relocInfo = { 0 }; + uint32_t sectionPrefix = 0; + + relocInfo.symbolIndex = ELF32_R_SYM(data->r_info); + relocInfo.file = file; + + switch (section) { + case FAIRY_SECTION_TEXT: + sectionPrefix = 1; + break; + + case FAIRY_SECTION_DATA: + sectionPrefix = 2; + break; + + case FAIRY_SECTION_RODATA: + sectionPrefix = 3; + break; + + default: + fprintf(stderr, "warning: Relocation section is invalid.\n"); + break; + } + relocInfo.relocWord = + ((sectionPrefix & 3) << 0x1E) | (ELF32_R_TYPE(data->r_info) << 0x18) | (data->r_offset & 0xFFFFFF); + + return relocInfo; +} + +static const FairyDefineString relSectionNames[] = { + FAIRY_DEF_STRING(FAIRY_SECTION_, TEXT), + FAIRY_DEF_STRING(FAIRY_SECTION_, DATA), + FAIRY_DEF_STRING(FAIRY_SECTION_, RODATA), + { 0 }, +}; + +/* Taken from elf.h/mips_elf.h */ +static const FairyDefineString relTypeNames[] = { + FAIRY_DEF_STRING(, R_MIPS_NONE), /* No reloc */ + FAIRY_DEF_STRING(, R_MIPS_16), /* Direct 16 bit */ + FAIRY_DEF_STRING(, R_MIPS_32), /* Direct 32 bit */ + FAIRY_DEF_STRING(, R_MIPS_REL32), /* PC relative 32 bit */ + FAIRY_DEF_STRING(, R_MIPS_26), /* Direct 26 bit shifted */ + FAIRY_DEF_STRING(, R_MIPS_HI16), /* High 16 bit */ + FAIRY_DEF_STRING(, R_MIPS_LO16), /* Low 16 bit */ + FAIRY_DEF_STRING(, R_MIPS_GPREL16), /* GP relative 16 bit */ + FAIRY_DEF_STRING(, R_MIPS_LITERAL), /* 16 bit literal entry */ + FAIRY_DEF_STRING(, R_MIPS_GOT16), /* 16 bit GOT entry */ + FAIRY_DEF_STRING(, R_MIPS_PC16), /* PC relative 16 bit */ + FAIRY_DEF_STRING(, R_MIPS_CALL16), /* 16 bit GOT entry for function */ + FAIRY_DEF_STRING(, R_MIPS_GPREL32), /* GP relative 32 bit */ + FAIRY_DEF_STRING(, R_MIPS_SHIFT5), + FAIRY_DEF_STRING(, R_MIPS_SHIFT6), + FAIRY_DEF_STRING(, R_MIPS_64), + FAIRY_DEF_STRING(, R_MIPS_GOT_DISP), + FAIRY_DEF_STRING(, R_MIPS_GOT_PAGE), + FAIRY_DEF_STRING(, R_MIPS_GOT_OFST), + FAIRY_DEF_STRING(, R_MIPS_GOT_HI16), + FAIRY_DEF_STRING(, R_MIPS_GOT_LO16), + FAIRY_DEF_STRING(, R_MIPS_SUB), + FAIRY_DEF_STRING(, R_MIPS_INSERT_A), + FAIRY_DEF_STRING(, R_MIPS_INSERT_B), + FAIRY_DEF_STRING(, R_MIPS_DELETE), + FAIRY_DEF_STRING(, R_MIPS_HIGHER), + FAIRY_DEF_STRING(, R_MIPS_HIGHEST), + FAIRY_DEF_STRING(, R_MIPS_CALL_HI16), + FAIRY_DEF_STRING(, R_MIPS_CALL_LO16), + FAIRY_DEF_STRING(, R_MIPS_SCN_DISP), + FAIRY_DEF_STRING(, R_MIPS_REL16), + FAIRY_DEF_STRING(, R_MIPS_ADD_IMMEDIATE), + FAIRY_DEF_STRING(, R_MIPS_PJUMP), + FAIRY_DEF_STRING(, R_MIPS_RELGOT), + FAIRY_DEF_STRING(, R_MIPS_JALR), + FAIRY_DEF_STRING(, R_MIPS_TLS_DTPMOD32), /* Module number 32 bit */ + FAIRY_DEF_STRING(, R_MIPS_TLS_DTPREL32), /* Module-relative offset 32 bit */ + FAIRY_DEF_STRING(, R_MIPS_TLS_DTPMOD64), /* Module number 64 bit */ + FAIRY_DEF_STRING(, R_MIPS_TLS_DTPREL64), /* Module-relative offset 64 bit */ + FAIRY_DEF_STRING(, R_MIPS_TLS_GD), /* 16 bit GOT offset for GD */ + FAIRY_DEF_STRING(, R_MIPS_TLS_LDM), /* 16 bit GOT offset for LDM */ + FAIRY_DEF_STRING(, R_MIPS_TLS_DTPREL_HI16), /* Module-relative offset, high 16 bits */ + FAIRY_DEF_STRING(, R_MIPS_TLS_DTPREL_LO16), /* Module-relative offset, low 16 bits */ + FAIRY_DEF_STRING(, R_MIPS_TLS_GOTTPREL), /* 16 bit GOT offset for IE */ + FAIRY_DEF_STRING(, R_MIPS_TLS_TPREL32), /* TP-relative offset, 32 bit */ + FAIRY_DEF_STRING(, R_MIPS_TLS_TPREL64), /* TP-relative offset, 64 bit */ + FAIRY_DEF_STRING(, R_MIPS_TLS_TPREL_HI16), /* TP-relative offset, high 16 bits */ + FAIRY_DEF_STRING(, R_MIPS_TLS_TPREL_LO16), /* TP-relative offset, low 16 bits */ + FAIRY_DEF_STRING(, R_MIPS_GLOB_DAT), + FAIRY_DEF_STRING(, R_MIPS_COPY), + FAIRY_DEF_STRING(, R_MIPS_JUMP_SLOT), + FAIRY_DEF_STRING(, R_MIPS_NUM), +}; + +/** + * Find all the necessary relocations to retain (those defined in any input file), and print them in the appropriate + * format. + */ +void Fado_Relocs(FILE* outputFile, int inputFilesCount, FILE** inputFiles, const char* ovlName) { + /* General information structs */ + FairyFileInfo* fileInfos = malloc(inputFilesCount * sizeof(FairyFileInfo)); + + /* Symbol tables for each file */ + FairySym** symtabs = malloc(inputFilesCount * sizeof(FairySym*)); + + /* Lists of names of symbols defined in files of the overlay */ + vc_vector** stringVectors = malloc(inputFilesCount * sizeof(vc_vector*)); + + /* The relocs in the format we will print */ + vc_vector* relocList[FAIRY_SECTION_OTHER]; /* Maximum number of reloc sections */ + + /* Offset of current file's current section into the overlay's whole section */ + uint32_t sectionOffset[FAIRY_SECTION_OTHER] = { 0 }; + + /* Total number of relocs */ + uint32_t relocCount = 0; + + /* iterators */ + int currentFile; + FairySection section; + size_t relocIndex; + + for (currentFile = 0; currentFile < inputFilesCount; currentFile++) { + FAIRY_INFO_PRINTF("Begin initialising file %d info.\n", currentFile); + Fairy_InitFile(&fileInfos[currentFile], inputFiles[currentFile]); + FAIRY_INFO_PRINTF("Initialising file %d info complete.\n", currentFile); + + symtabs[currentFile] = fileInfos[currentFile].symtabInfo.sectionData; + } + + Fado_ConstructStringVectors(stringVectors, fileInfos, inputFilesCount); + FAIRY_INFO_PRINTF("%s", "symtabs set\n"); + + /* Construct relocList of all relevant relocs */ + for (section = FAIRY_SECTION_TEXT; section < FAIRY_SECTION_OTHER; section++) { + relocList[section] = vc_vector_create(0x100, sizeof(FadoRelocInfo), NULL); + + for (currentFile = 0; currentFile < inputFilesCount; currentFile++) { + FairyRela* relSection = fileInfos[currentFile].relocTablesInfo[section].sectionData; + + if (relSection != NULL) { + for (relocIndex = 0; relocIndex < fileInfos[currentFile].relocTablesInfo[section].sectionEntryCount; + relocIndex++) { + FadoRelocInfo currentReloc = Fado_MakeReloc(currentFile, section, &relSection[relocIndex]); + + if ((symtabs[currentFile][currentReloc.symbolIndex].st_shndx != STN_UNDEF) || + Fado_FindSymbolNameInOtherFiles( + &fileInfos[currentFile].strtab[symtabs[currentFile][currentReloc.symbolIndex].st_name], + currentFile, stringVectors, inputFilesCount)) { + + currentReloc.relocWord += sectionOffset[section]; + FAIRY_DEBUG_PRINTF("current section offset: %d\n", sectionOffset[section]); + vc_vector_push_back(relocList[section], ¤tReloc); + relocCount++; + } + } + } else { + FAIRY_INFO_PRINTF("%s", "Ignoring empty reloc section\n"); + } + + sectionOffset[section] += fileInfos[currentFile].progBitsSizes[section]; + FAIRY_INFO_PRINTF("section offset: %d\n", sectionOffset[section]); + } + } + + { + /* Write header */ + fprintf(outputFile, ".section .ovl\n"); + fprintf(outputFile, "# %sOverlayInfo\n", ovlName); + fprintf(outputFile, ".word _%sSegmentTextSize\n", ovlName); + fprintf(outputFile, ".word _%sSegmentDataSize\n", ovlName); + fprintf(outputFile, ".word _%sSegmentRoDataSize\n", ovlName); + fprintf(outputFile, ".word _%sSegmentBssSize\n", ovlName); + + fprintf(outputFile, "\n.word %d # relocCount\n", relocCount); + + /* Write reloc table */ + for (section = FAIRY_SECTION_TEXT; section < FAIRY_SECTION_OTHER; section++) { + if (vc_vector_count(relocList[section]) == 0) { + FAIRY_INFO_PRINTF("%s", "Ignoring empty reloc section\n"); + continue; + } + + fprintf(outputFile, "\n# %s RELOCS\n", Fairy_StringFromDefine(relSectionNames, section)); + + { + FadoRelocInfo* currentReloc; + VC_FOREACH(currentReloc, relocList[section]) { + fprintf(outputFile, ".word 0x%X # %-11s 0x%06X %s\n", currentReloc->relocWord, + Fairy_StringFromDefine(relTypeNames, (currentReloc->relocWord >> 0x18) & 0x3F), + currentReloc->relocWord & 0xFFFFFF, + Fairy_GetSymbolName(symtabs[currentReloc->file], fileInfos[currentReloc->file].strtab, + currentReloc->symbolIndex)); + } + } + } + + /* print pads and section size */ + for (relocCount += 5; ((relocCount + 1) & 3) != 0; relocCount++) { + fprintf(outputFile, ".word 0\n"); + } + fprintf(outputFile, "\n.word 0x%08X # %sOverlayInfoOffset\n", 4 * (relocCount + 1), ovlName); + } + + for (currentFile = 0; currentFile < inputFilesCount; currentFile++) { + Fairy_DestroyFile(&fileInfos[currentFile]); + FAIRY_INFO_PRINTF("Freed file %d\n", currentFile); + } + + for (section = FAIRY_SECTION_TEXT; section < FAIRY_SECTION_OTHER; section++) { + if (relocList[section] != NULL) { + vc_vector_release(relocList[section]); + } + FAIRY_INFO_PRINTF("Freed relocList[%d]\n", section); + } + + Fado_DestroyStringVectors(stringVectors, inputFilesCount); + FAIRY_INFO_PRINTF("%s", "Freed string vectors\n"); + free(symtabs); + FAIRY_INFO_PRINTF("%s", "Freed symtabs\n"); + free(fileInfos); +} diff --git a/tools/fado/src/help.c b/tools/fado/src/help.c new file mode 100644 index 000000000..1f0580732 --- /dev/null +++ b/tools/fado/src/help.c @@ -0,0 +1,162 @@ +/** + * Getopt-compatible printing of formatted help. + */ +/* Copyright (C) 2021 Elliptic Ellipsis */ +/* SPDX-License-Identifier: AGPL-3.0-only */ +#include "help.h" + +#include +#include +#include +#include +#include +#include + +#include "macros.h" + +/* Values of the variables used by Help_PrintHelp. Defaults are taken from common terminal programs like grep */ +size_t helpTextWidth = 80; +size_t helpDtIndent = 2; +size_t helpDdIndent = 25; + +/** + * Prints a paragraph, word wrapped to helpTextWidth, with a hanging indent. initialColumn is used to determine how wide + * the first line should be, while indentFirstLine should be true if there is no previous text on the line (an ordinary + * paragraph), and false if there is (e.g. as a description list description) + */ +void Help_PrintFlowAndIndent(const char* string, size_t initialColumn, size_t textWidth, size_t hangingIndent, + bool indentFirstLine) { + size_t column = initialColumn; + size_t index = 0; + size_t inLength = strlen(string); + size_t lookAhead; + bool shouldBreak; + + assert(initialColumn < textWidth); + assert(hangingIndent < textWidth); + + if (indentFirstLine) { + printf("%*s", (int)initialColumn, ""); + } + + for (; index <= inLength; index++) { + shouldBreak = 0; + + if (column == textWidth) { + printf("%c\n%*s", string[index], (int)hangingIndent, ""); + column = hangingIndent; + continue; + } + + column++; + + switch (string[index]) { + case '\0': + return; + + case ' ': + if (column == hangingIndent) { + continue; + } + + for (lookAhead = 0; lookAhead <= textWidth - column; lookAhead++) { + // printf("%c\n", src[index + lookAhead]); + if (string[index + lookAhead + 1] == ' ' || string[index + lookAhead + 1] == '\0') { + putchar(' '); + shouldBreak = 1; + break; + } + } + if (shouldBreak) { /* Damn shared keywords. */ + break; + } + case '\n': + printf("\n%*s", (int)hangingIndent, ""); + column = hangingIndent; + break; + + default: + putchar(string[index]); + break; + } + } +} + +/** + * Prints help in the form + * ``` + * prologue (word wrapped) + * + * Positional arguments + * arg1 Description (word + * wrapped) + * arg2 Description (word + * wrapped) + * + * Options + * -a --long-name=ARG Description (word + * wrapped) + * + * epilogue (word wrapped) + * ``` + * where the positional arguments are described using the posArgInfo array, and options are fed using the OptInfo array, + * which should both be null-terminated. posArgCount/optCount is the actual number of positional arguments/options: it + * is used to guarantee no garbage is printed even if the user has not null-terminated the array. (optCount is required + * for constructing the getopt option array anyway.) + */ +void Help_PrintHelp(const char* prologue, size_t posArgCount, const PosArgInfo* posArgInfo, size_t optCount, + const OptInfo* optInfo, const char* epilogue) { + size_t i; + size_t dtLength; + int padding; + + Help_PrintFlowAndIndent(prologue, 0, helpTextWidth, 0, false); + + if (posArgCount != 0) { + printf("\nPositional Argument\n"); + for (i = 0; i < posArgCount; i++) { + if (posArgInfo[i].helpArg == 0) { + break; + } + + dtLength = helpDtIndent + strlen(posArgInfo[i].helpArg); + + padding = helpDdIndent - dtLength - 2; + printf("%*s%s%*s ", (int)helpDtIndent, "", posArgInfo[i].helpArg, CLAMP_MIN(padding, 0), ""); + + Help_PrintFlowAndIndent(posArgInfo[i].helpMsg, CLAMP_MIN(dtLength + 2, helpDdIndent), helpTextWidth, + helpDdIndent, false); + printf("\n"); + } + } + + if (optCount != 0) { + printf("\nOptions\n"); + + for (i = 0; i < optCount; i++) { + if (optInfo[i].longOpt.val == 0) { + break; + } + + dtLength = helpDtIndent + 6 + strlen(optInfo[i].longOpt.name); + + if (optInfo[i].helpArg == NULL) { + padding = helpDdIndent - dtLength - 2; + printf("%*s-%c, --%s%*s ", (int)helpDtIndent, "", optInfo[i].longOpt.val, optInfo[i].longOpt.name, + CLAMP_MIN(padding, 0), ""); + } else { + dtLength += 1 + strlen(optInfo[i].helpArg); + padding = helpDdIndent - dtLength - 2; + printf("%*s-%c, --%s=%s%*s ", (int)helpDtIndent, "", optInfo[i].longOpt.val, optInfo[i].longOpt.name, + optInfo[i].helpArg, CLAMP_MIN(padding, 0), ""); + } + Help_PrintFlowAndIndent(optInfo[i].helpMsg, CLAMP_MIN(dtLength + 2, helpDdIndent), helpTextWidth, + helpDdIndent, false); + printf("\n"); + } + } + + printf("\n"); + Help_PrintFlowAndIndent(epilogue, 0, helpTextWidth, 0, false); + printf("\n"); +} diff --git a/tools/fado/src/main.c b/tools/fado/src/main.c new file mode 100644 index 000000000..c6af79025 --- /dev/null +++ b/tools/fado/src/main.c @@ -0,0 +1,247 @@ +/* Copyright (C) 2021 Elliptic Ellipsis */ +/* SPDX-License-Identifier: AGPL-3.0-only */ +#include +#include +#include +#include +#include + +#include "macros.h" +#include "fairy/fairy.h" +#include "fado.h" +#include "help.h" +#include "mido.h" +#include "vc_vector/vc_vector.h" + +#include "version.inc" + +void PrintVersion() { + printf("Fado (Fairy-Assisted relocations for Decompiled Overlays), version %s\n", versionNumber); + printf("Copyright (C) 2021 Elliptic Ellipsis\n"); + printf("%s\n", credits); + printf("Repository available at %s.\n", repo); +} + +#if defined _WIN32 || defined __CYGWIN__ +#define PATH_SEPARATOR '\\' +#else +#define PATH_SEPARATOR '/' +#endif + +/** + * (Bad) filename-parsing idea to get the overlay name from the filename. Output must be freed separately. + */ +char* GetOverlayNameFromFilename(const char* src) { + char* ret; + const char* ptr; + const char* start = src; + const char* end = src; + + for (ptr = src; *ptr != '\0'; ptr++) { + if (*ptr == PATH_SEPARATOR) { + start = end + 1; + end = ptr; + } + } + + if (end == src) { + return NULL; + } + + ret = malloc((end - start + 1) * sizeof(char)); + memcpy(ret, start, end - start); + ret[end - start] = '\0'; + + return ret; +} + +#define OPTSTR "M:n:o:v:ahV" +#define USAGE_STRING "Usage: %s [-hV] [-n name] [-o output_file] [-v level] input_files ...\n" + +#define HELP_PROLOGUE \ + "Fado (Fairy-Assisted relocations for Decompiled Overlays\n" \ + "Extract relocations from object files and convert them into the format required by Zelda 64 overlays.\n" +#define HELP_EPILOGUE repo + +// clang-format off +static const PosArgInfo posArgInfo[] = { + { "INPUT_FILE", "Every positional argument is an input file, and there should be at least one input file. All inputs are relocatable .o (object) ELF files" }, + { NULL, NULL } +}; + +static const OptInfo optInfo[] = { + { { "make-dependency", required_argument, NULL, 'M' }, "FILE", "Write the output file's Makefile dependencies to FILE" }, + { { "name", required_argument, NULL, 'n' }, "NAME", "Use NAME as the overlay name. Will use the deepest folder name in the input file's path if not specified" }, + { { "output-file", required_argument, NULL, 'o' }, "FILE", "Output to FILE. Will use stdout if none is specified" }, + { { "verbosity", required_argument, NULL, 'v' }, "N", "Verbosity level, one of 0 (None, default), 1 (Info), 2 (Debug)" }, + + { { "alignment", no_argument, NULL, 'a' }, NULL, "Experimental. Use the alignment declared by each section in the elf file instead of padding to 0x10 bytes. NOTE: It has not been properly tested because the tools we currently have are not compatible non 0x10 alignment" }, + + { { "help", no_argument, NULL, 'h' }, NULL, "Display this message and exit" }, + { { "version", no_argument, NULL, 'V' }, NULL, "Display version information" }, + + { { NULL, 0, NULL, '\0' }, NULL, NULL }, +}; +// clang-format on + +static size_t posArgCount = ARRAY_COUNT(posArgInfo); +static size_t optCount = ARRAY_COUNT(optInfo); +static struct option longOptions[ARRAY_COUNT(optInfo)]; + +void ConstructLongOpts() { + size_t i; + + for (i = 0; i < optCount; i++) { + longOptions[i] = optInfo[i].longOpt; + } +} + +int main(int argc, char** argv) { + int opt; + int inputFilesCount; + FILE** inputFiles; + FILE* outputFile = stdout; + char* outputFileName; + char* dependencyFileName = NULL; + char* ovlName = NULL; + + ConstructLongOpts(); + + if (argc < 2) { + printf(USAGE_STRING, argv[0]); + fprintf(stderr, "No input file specified\n"); + return EXIT_FAILURE; + } + + while (true) { + int optionIndex = 0; + + if ((opt = getopt_long(argc, argv, OPTSTR, longOptions, &optionIndex)) == -1) { + break; + } + + switch (opt) { + case 'M': + dependencyFileName = optarg; + break; + + case 'n': + ovlName = optarg; + break; + + case 'o': + outputFileName = optarg; + outputFile = fopen(optarg, "wb"); + if (outputFile == NULL) { + fprintf(stderr, "error: unable to open output file '%s' for writing\n", optarg); + return EXIT_FAILURE; + } + break; + + case 'v': + if (sscanf(optarg, "%u", &gVerbosity) == 0) { + fprintf(stderr, "warning: verbosity argument '%s' should be a nonnegative decimal integer\n", + optarg); + } + break; + + case 'a': +#ifndef EXPERIMENTAL + goto not_experimental_err; +#endif + gUseElfAlignment = true; + break; + + case 'h': + printf(USAGE_STRING, argv[0]); + Help_PrintHelp(HELP_PROLOGUE, posArgCount, posArgInfo, optCount, optInfo, HELP_EPILOGUE); + return EXIT_FAILURE; + + case 'V': + PrintVersion(); + return EXIT_FAILURE; + + default: + fprintf(stderr, "?? getopt returned character code 0x%X ??\n", opt); + break; + } + } + + FAIRY_INFO_PRINTF("%s", "Options processed\n"); + + { + int i; + + inputFilesCount = argc - optind; + if (inputFilesCount == 0) { + fprintf(stderr, "No input files specified. Exiting.\n"); + return EXIT_FAILURE; + } + + inputFiles = malloc(inputFilesCount * sizeof(FILE*)); + for (i = 0; i < inputFilesCount; i++) { + FAIRY_INFO_PRINTF("Using input file %s\n", argv[optind + i]); + inputFiles[i] = fopen(argv[optind + i], "rb"); + if (inputFiles[i] == NULL) { + fprintf(stderr, "error: unable to open input file '%s' for reading\n", argv[optind + i]); + return EXIT_FAILURE; + } + } + + FAIRY_INFO_PRINTF("Found %d input file%s\n", inputFilesCount, (inputFilesCount == 1 ? "" : "s")); + + if (ovlName == NULL) { // If a name has not been set using an arg + ovlName = GetOverlayNameFromFilename(argv[optind]); + Fado_Relocs(outputFile, inputFilesCount, inputFiles, ovlName); + free(ovlName); + } else { + Fado_Relocs(outputFile, inputFilesCount, inputFiles, ovlName); + } + + for (i = 0; i < inputFilesCount; i++) { + fclose(inputFiles[i]); + } + free(inputFiles); + if (outputFile != stdout) { + fclose(outputFile); + } + } + + if (dependencyFileName != NULL) { + int fileNameLength = strlen(outputFileName); + char* objectFile = malloc((strlen(outputFileName) + 1) * sizeof(char)); + vc_vector* inputFilesVector = vc_vector_create(inputFilesCount, sizeof(char*), NULL); + char* extensionStart; + FILE* dependencyFile = fopen(dependencyFileName, "w"); + + if (dependencyFile == NULL) { + fprintf(stderr, "error: unable to open dependency file '%s' for writing\n", dependencyFileName); + return EXIT_FAILURE; + } + + strcpy(objectFile, outputFileName); + extensionStart = strrchr(objectFile, '.'); + if (extensionStart == objectFile + fileNameLength) { + fprintf(stderr, "error: file name should not end in a '.'\n"); + return EXIT_FAILURE; + } + strcpy(extensionStart, ".o"); + vc_vector_append(inputFilesVector, &argv[optind], inputFilesCount); + + Mido_WriteDependencyFile(dependencyFile, objectFile, inputFilesVector); + + free(objectFile); + vc_vector_release(inputFilesVector); + fclose(dependencyFile); + } + + return EXIT_SUCCESS; + + goto not_experimental_err; // silences a warning +not_experimental_err: + fprintf( + stderr, + "Experimental option '-%c' passed in a non-EXPERIMENTAL build. Rebuild with 'make EXPERIMENTAL=1' to enable.\n", + opt); + return EXIT_FAILURE; +} diff --git a/tools/fado/src/mido.c b/tools/fado/src/mido.c new file mode 100644 index 000000000..bc5f3ed8a --- /dev/null +++ b/tools/fado/src/mido.c @@ -0,0 +1,20 @@ +#include "mido.h" + +#include +#include "macros.h" +#include "vc_vector/vc_vector.h" + +int Mido_WriteDependencyFile(FILE* dependencyFile, const char* relocFile, vc_vector* inputFilesVector) { + char** inputFile; + + fprintf(dependencyFile, "%s:", relocFile); + + VC_FOREACH(inputFile, inputFilesVector) { + fprintf(dependencyFile, " %s", *inputFile); + } + fputs("\n\n", dependencyFile); + VC_FOREACH(inputFile, inputFilesVector) { + fprintf(dependencyFile, "%s:\n\n", *inputFile); + } + return 0; +} diff --git a/tools/fado/src/version.inc b/tools/fado/src/version.inc new file mode 100644 index 000000000..9bc9fbf30 --- /dev/null +++ b/tools/fado/src/version.inc @@ -0,0 +1,5 @@ +/* Copyright (C) 2021 Elliptic Ellipsis */ +/* SPDX-License-Identifier: AGPL-3.0-only */ +const char versionNumber[] = "1.3.1"; +const char credits[] = "Written by Elliptic Ellipsis\nwith additions from AngheloAlf and Tharo"; +const char repo[] = "https://github.com/EllipticEllipsis/fado/"; diff --git a/tools/fado/z64_relocation_section_format.md b/tools/fado/z64_relocation_section_format.md new file mode 100644 index 000000000..c537ff701 --- /dev/null +++ b/tools/fado/z64_relocation_section_format.md @@ -0,0 +1,114 @@ +# Zelda 64 overlay relocation section format + +Both Zelda 64 titles use the same custom dynamic overlay relocation format, which is + + +All elements are 4 bytes in width. + +| Offset | Description | Notes | +| ------- | ------------------------------------------- | ------------------------------------------------------------- | +| 0x00 | Size of overlay .text section | | +| 0x04 | Size of overlay .data section | | +| 0x08 | Size of overlay .rodata section | | +| 0x0C | Size of overlay .bss section | | +| 0x10 | Number of relocation entries | | +| 0x14- | Relocation entries | Must be sorted in increasing order by section, then offset | +| ... | | | +| | (zero padding of section to 0x10 alignment) | | +| End - 4 | Size of overlay .ovl section | Also the offset from the end of the rest of the section sizes | + + +## Relocation entries + +The only element that is not a single number are the relocation entries, which are bitpacked as follows: + +| 0x1F..0x1E | 0x1D..0x18 | 0x17..0x0 | +| ---------- | ---------- | ----------------------------- | +| ss | tttttt | oooo oooo oooo oooo oooo oooo | +| Section | Type | Offset | + + +### Section + +2 bits. Section where the instruction or data to be relocated is. + +| Value | Section | +| ----- | ------- | +| 1 | .text | +| 2 | .data | +| 3 | .rodata | + + +### Type + +6 bits. Four types of standard MIPS relocation are supported. They use the same values as the standard elf formats: + +| Value | Type | Description | +| ----- | ------------- | --------------------------------------------------------------------------------- | +| 2 | `R_MIPS_32` | A full word address (such as a pointer in data or an address in a jumptable) | +| 4 | `R_MIPS_26` | 26-bit direct relocation, for a J-type instruction | +| 5 | `R_MIPS_HI16` | High 16-bit, generally the top half of an address in an `li`/`lui` | +| 6 | `R_MIPS_LO16` | Low 16-bit, the bottom half of an address, such as in an `addiu`,`ori`,`lh`, etc. | + + +### Offset + +0x18 bits. Offset in bytes from the start of the section where the relocation occurs. + + +### Example + +``` +0x82000A30 = 0b1000 0010 0000 0000 0000 1010 0011 0000 +``` + +This splits as + +``` +0b10, 0b000010, 0b0000 0000 0000 1010 0011 0000 = 0x2, 0x2, 0xA30 +``` + +i.e. a full-word (`R_MIPS_32`) relocation at `.data + 0xA30`. + + +## Compiler compatibility + +### HI/LO + +The MIPS ELF format standard specifies that each LO be preceded by a unique HI associated to it (but multiple LOs may associate to the same HI), and the overlay relocation function acts based on this assumption. + +IDO complies with this consistently, but GCC in its wisdom decided that it was appropriate to violate this by default, and allow multiple HIs to associate to the same LO. GCC also likes to reorder relocations in the `.rel.*` sections. + +To prevent these you must pass *both* of the following compiler flags: + +``` +-mno-explicit-relocs -mno-split-addresses +``` + +(GNU do not document this behaviour themselves, although apparently it has been present for many years. It is also not even consistent between versions.) + +### rodata + +It should be clear from the description above that this system expects a single rodata section. Again, IDO will only ever produce one rodata section, but GCC will produce several, albeit only one containing relocatable rodata: the others are for "mergeable" strings and floats/doubles. The cleanest way to deal with this is to pass + +``` +-fno-merge-constants +``` + +which will force GCC to generate a single combined rodata section. If, however, you really think you will benefit from merging constants, to obtain relocations correctly offset from the start of the entire rodata section(s), the actual `.rodata` section must be explicitly linked first. + +For multi-file overlays, the situation is even more complicated, and Fado gets around this by adding up the sizes of all the rodata sections so that we may simply place one files' in one chunk: this means that each individual `.rodata` section should be linked before the others, i.e. + +``` +.text(1) +.text(2) +.data(1) +.data(2) +.rodata(1) +.rodata.cst4(1) +... +.rodata(2) +.rodata.cst4(2) +``` + +or similar. diff --git a/tools/actorfixer.py b/tools/namefixer.py similarity index 56% rename from tools/actorfixer.py rename to tools/namefixer.py index 907b83a8b..e7b0a10e0 100755 --- a/tools/actorfixer.py +++ b/tools/namefixer.py @@ -1,54 +1,111 @@ #!/usr/bin/env python3 -import argparse, os +import os +import argparse -# There are a few commented out entries that would produce unexpected renames. -# They are left as a comment so people can just grab them. +# all occurrences of keys will be replaced by associated value +simpleReplace = { + # "Math_Rand_":"Rand_", + # "ACTORTYPE":"ACTORCAT", + # "DistToLink":"DistToPlayer", + # "HitItem":"HitInfo", +} -# "old": "new" -animdict = { +# 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 = { + # Functions "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", + + # "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", + "func_80123AA4": "Player_SetModels", + "func_80123BD4": "Player_SetModelGroup", + "func_80123F48": "Player_IsBurningStickInRange", + "func_8012405C": "Player_HasMirrorShieldEquipped", + "func_80124088": "Player_IsHoldingMirrorShield", + "func_8012697C": "Player_DrawGetItem", "Actor_SpawnWithParentAndCutscene": "Actor_SpawnAsChildAndCutscene", "Actor_SpawnWithParent": "Actor_SpawnAsChild", "Actor_IsLinkFacingActor": "Player_IsFacingActor", @@ -81,32 +138,37 @@ animdict = { "func_800BE22C": "Actor_ApplyDamage", "Audio_PlaySoundAtPosition": "SoundSource_PlaySfxAtFixedWorldPos", "func_800F0590": "SoundSource_PlaySfxEachFrameAtFixedWorldPos", - "func_8016970C": "Play_CameraSetAtEye", + "func_8016970C": "Play_SetCameraAtEye", + "Play_CameraSetAtEye": "Play_SetCameraAtEye", "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_801A5BD0": "AudioSfx_MuteBanks", + "func_801A72CC": "AudioSfx_StopByPos", + "Audio_StopSfxByPos": "AudioSfx_StopByPos", + "func_801A7328": "AudioSfx_StopByPosAndId", + "func_801A75E8": "AudioSfx_StopById", + "SkelAnime_LodDrawLimb": "SkelAnime_DrawLimbLod", + "SkelAnime_LodDraw": "SkelAnime_DrawLod", + "SkelAnime_LodDrawLimbSV": "SkelAnime_DrawFlexLimbLod", + "SkelAnime_LodDrawSV": "SkelAnime_DrawFlexLod", + # "SkelAnime_DrawLimb": "SkelAnime_DrawLimbOpa", # A different function is called this now + # "SkelAnime_Draw": "SkelAnime_DrawOpa", # A different function is called this now + "SkelAnime_DrawLimbSV": "SkelAnime_DrawFlexLimbOpa", + "SkelAnime_DrawSV": "SkelAnime_DrawFlexOpa", + # "SkelAnime_AnimateFrame": "SkelAnime_GetFrameData", # A different function is called this now + "SkelAnime_GetTotalFrames": "Animation_GetLength", + "SkelAnime_GetFrameCount": "Animation_GetLastFrame", + "SkelAnime_Draw2Limb": "SkelAnime_DrawLimb", + "SkelAnime_Draw2": "SkelAnime_Draw", + "SkelAnime_DrawLimbSV2": "SkelAnime_DrawFlexLimb", + "SkelAnime_DrawSV2": "SkelAnime_DrawFlex", "func_80134FFC": "SkelAnime_GetFrameData2", "func_801353D4": "Animation_GetLimbCount2", - "SkelAnime_GetTotalFrames2(": "Animation_GetLength2(", - "SkelAnime_GetFrameCount2(": "Animation_GetLastFrame2(", + "SkelAnime_GetTotalFrames2": "Animation_GetLength2", + "SkelAnime_GetFrameCount2": "Animation_GetLastFrame2", "SkelAnime_InterpolateVec3s": "SkelAnime_InterpFrameTable", "SkelAnime_AnimationCtxReset": "AnimationContext_Reset", "func_801358D4": "AnimationContext_SetNextQueue", @@ -125,7 +187,7 @@ animdict = { "SkelAnime_AnimationType4Loaded": "AnimationContext_CopyFalse", "SkelAnime_AnimationType5Loaded": "AnimationContext_MoveActor", "func_80135EE8": "AnimationContext_Update", - "SkelAnime_InitLinkAnimetion(": "SkelAnime_InitLink(", + "SkelAnime_InitLinkAnimetion": "SkelAnime_InitLink", "func_801360A8": "LinkAnimation_SetUpdateFunction", "func_801360E0": "LinkAnimation_Update", "func_80136104": "LinkAnimation_Morph", @@ -158,7 +220,7 @@ animdict = { "func_801370B0": "SkelAnime_LoopPartial", "func_8013713C": "SkelAnime_Once", "SkelAnime_ChangeAnimImpl": "Animation_ChangeImpl", - "SkelAnime_ChangeAnim(": "Animation_Change(", + "SkelAnime_ChangeAnim": "Animation_Change", "SkelAnime_ChangeAnimDefaultStop": "Animation_PlayOnce", "SkelAnime_ChangeAnimTransitionStop": "Animation_MorphToPlayOnce", "SkelAnime_ChangeAnimPlaybackStop": "Animation_PlayOnceSetSpeed", @@ -172,8 +234,6 @@ animdict = { "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", @@ -188,19 +248,20 @@ animdict = { "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_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_801A5CFC": "AudioSfx_PlaySfx", + "Audio_PlaySfxGeneral": "AudioSfx_PlaySfx", "func_800BBDAC": "Actor_SpawnFloorDustRing", "func_800B8708": "Player_GetExchangeItemId", "func_801233E4": "Player_InCsMode", @@ -214,7 +275,7 @@ animdict = { "Actor_TitleCardCreate": "TitleCard_InitBossName", "func_800B867C": "Actor_TextboxIsClosing", "func_800BDC5C": "Actor_ChangeAnimationByInfo", - "Actor_ChangeAnimation(": "Actor_ChangeAnimationByInfo(", + "Actor_ChangeAnimation": "Actor_ChangeAnimationByInfo", "func_80152498": "Message_GetState", "func_800B8898": "Actor_GetScreenPos", "Audio_PlayActorSound2": "Actor_PlaySfxAtPos", @@ -222,8 +283,8 @@ animdict = { "Actor_IsFacingPlayerAndWithinRange": "Actor_IsFacingAndNearPlayer", "func_800BC8B8": "Actor_DrawDoorLock", "func_800B86C8": "Actor_ChangeFocus", - "zelda_malloc(": "ZeldaArena_Malloc(", - "zelda_mallocR(": "ZeldaArena_MallocR(", + "zelda_malloc": "ZeldaArena_Malloc", + "zelda_mallocR": "ZeldaArena_MallocR", "zelda_realloc": "ZeldaArena_Realloc", "zelda_free": "ZeldaArena_Free", "zelda_calloc": "ZeldaArena_Calloc", @@ -234,9 +295,9 @@ animdict = { "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_RelocateMeshHeader": "CollisionHeader_GetVirtual", + "BgCheck_AddActorMesh": "DynaPoly_SetBgActor", + "BgCheck_RemoveActorMesh": "DynaPoly_DeleteBgActor", "BgCheck_PolygonLinkedListNodeInit": "SSNode_SetValue", "BgCheck_PolygonLinkedListResetHead": "SSList_SetNull", "BgCheck_ScenePolygonListsNodeInsert": "SSNodeList_SetSSListHead", @@ -265,7 +326,7 @@ animdict = { "BgCheck_GetIsDefaultSpecialScene": "BgCheck_IsSmallMemScene", "BgCheck_GetSpecialSceneMaxMemory": "BgCheck_TryGetCustomMemsize", "BgCheck_CalcSubdivisionSize": "BgCheck_SetSubdivisionDimension", - "BgCheck_Init(": "BgCheck_Allocate(", + "BgCheck_Init": "BgCheck_Allocate", "func_800C3C00": "BgCheck_SetContextFlags", "func_800C3C14": "BgCheck_UnsetContextFlags", "BgCheck_GetActorMeshHeader": "BgCheck_GetCollisionHeader", @@ -338,8 +399,8 @@ animdict = { "BgCheck_RelocateMeshHeader": "CollisionHeader_GetVirtual", "BgCheck_RelocateAllMeshHeaders": "BgCheck_InitCollisionHeaders", "BgCheck_GetPolygonAttributes": "SurfaceType_GetData", - "func_800C9704": "SurfaceType_GetCamDataIndex", - "func_800C9924": "SurfaceType_GetCamPosData", + "func_800C9704": "SurfaceType_GetBgCamIndex", + "func_800C9924": "BgCheck_GetBgCamFuncData", "func_800C99AC": "SurfaceType_GetSceneExitIndex", "func_800C9B90": "SurfaceType_IsHorseBlocked", "func_800C9BDC": "SurfaceType_GetSfx", @@ -379,7 +440,7 @@ animdict = { "func_8017CEF0": "Math3D_TriChkPointParaZIntersect", "func_8017D020": "Math3D_TriChkLineSegParaZIntersect", "Math3D_ColSphereLineSeg": "Math3D_LineVsSph", - "Math3D_ColSphereSphere(": "Math3D_SphVsSph(", + "Math3D_ColSphereSphere": "Math3D_SphVsSph", "func_8017F9C0": "Math3D_XZInSphere", "func_8017FA34": "Math3D_XYInSphere", "func_8017FAA8": "Math3D_YZInSphere", @@ -390,30 +451,56 @@ animdict = { "func_800E0308": "Camera_SetTargetActor", "func_800E031C": "Camera_GetWaterYPos", "func_800E02AC": "Camera_SetToTrackActor", + "func_800DFAC8": "Camera_ChangeSetting", + "func_800DFC90": "Camera_GetCamDir", + "func_800DFD04": "Camera_AddQuake", + "func_800DFFAC": "Camera_ChangeDoorCam", "func_801694DC": "Play_CreateSubCamera", "Play_GetActiveCameraIndex": "Play_GetActiveCamId", - "func_80169590": "Play_CameraChangeStatus", + "func_80169590": "Play_ChangeCameraStatus", + "Play_CameraChangeStatus": "Play_ChangeCameraStatus", "func_80169600": "Play_ClearCamera", "func_80169668": "Play_ClearAllSubCameras", - "func_8016981C": "Play_CameraSetAtEyeUp", - "func_80169940": "Play_CameraSetFov", - "func_80169988": "Play_CameraSetRoll", + "func_8016981C": "Play_SetCameraAtEyeUp", + "func_80169940": "Play_SetCameraFov", + "func_80169988": "Play_SetCameraRoll", + "Play_CameraSetAtEyeUp": "Play_SetCameraAtEyeUp", + "Play_CameraSetFov": "Play_SetCameraFov", + "Play_CameraSetRoll": "Play_SetCameraRoll", "func_801699D4": "Play_CopyCamera", - "func_80169AC0": "Play_CameraChangeSetting", - "func_80169BC4": "Play_CameraGetUID", - "func_80169C64": "Play_GetCsCamDataSetting", - "func_80169C84": "Play_GetCsCamDataVec3s", + "func_80169AC0": "Play_ChangeCameraSetting", + "Play_CameraChangeSetting": "Play_ChangeCameraSetting", + "func_80169BC4": "Play_GetCameraUID", + "Play_CameraGetUID": "Play_GetCameraUID", + "func_80169C64": "Play_GetActorCsCamSetting", + "Play_GetCsCamDataSetting": "Play_GetActorCsCamSetting", + "func_80169C84": "Play_GetActorCsCamFuncData", + "Play_GetCsCamDataVec3s": "Play_GetActorCsCamFuncData", "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_80112B40": "Interface_LoadItemIconImpl", + "func_80112BE4": "Interface_LoadItemIcon", + "func_80114978": "Item_CheckObtainability", + "func_801149A0": "Inventory_DeleteItem", + "func_80114A9C": "Inventory_UnequipItem", + "func_80114B84": "Inventory_ReplaceItem", + "func_80114CA0": "Inventory_UpdateDeitySwordEquip", + "Interface_HasEmptyBottle": "Inventory_HasEmptyBottle", + "Interface_HasItemInBottle": "Inventory_HasItemInBottle", + "func_80114FD0": "Inventory_UpdateBottleItem", + "func_80115130": "Inventory_ConsumeFairy", + "func_801152B8": "Inventory_UpdateItem", + "func_80115908": "Health_ChangeBy", + "func_801159c0": "Health_GiveHearts", + "func_801159EC": "Rupees_ChangeBy", + "func_80115A14": "Inventory_ChangeAmmo", + "func_8013EC44": "Rumble_Override", + "func_8013ECE0": "Rumble_Request", "func_8017D2FC": "Math3D_LineSegVsPlane", - "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", @@ -431,25 +518,30 @@ animdict = { "func_800EE2F4": "Cutscene_IsPlaying", "func_801343C0": "SkelAnime_DrawTransformFlexOpa", "func_80134148": "SkelAnime_DrawTransformFlexLimbOpa", - "func_8013AB00": "SubS_DrawTransformFlex", - "func_8013A860": "SubS_DrawTransformFlexLimb", - "func_8013BC6C": "SubS_ChangeAnimationByInfoS", - "func_8013E1C8": "SubS_ChangeAnimationBySpeedInfo", - "func_8013D9C8": "SubS_FillLimbRotTables", - "func_80114E90": "Interface_HasEmptyBottle", - "func_80114F2C": "Interface_HasItemInBottle", + "func_80114E90": "Inventory_HasEmptyBottle", + "func_80114F2C": "Inventory_HasItemInBottle", "func_80123C90": "Player_SetEquipmentData", "Quake2_ClearType": "Distortion_ClearType", "Quake2_SetType": "Distortion_SetType", "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_8012F22C": "Inventory_GetSkullTokenCount", "func_8013DCE0": "SubS_ActorPathing_Init", "func_8013DE04": "SubS_ActorPathing_Update", "func_8013DF3C": "SubS_ActorPathing_ComputePointInfo", @@ -468,6 +560,8 @@ animdict = { "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", @@ -482,9 +576,50 @@ animdict = { "func_80158FB0": "Message_LoadTimeNES", "func_8015926C": "Message_LoadAreaTextNES", "func_8015E750": "Message_FindCreditsMessage", - + "func_80133038": "Schedule_RunScript", - # Structs members + "EffectSsKiraKira_SpawnSmallYellow": "EffectSsKirakira_SpawnSmallYellow", + "EffectSsKiraKira_SpawnSmall": "EffectSsKirakira_SpawnSmall", + "EffectSsKiraKira_SpawnDispersed": "EffectSsKirakira_SpawnDispersed", + "EffectSsKiraKira_SpawnFocused": "EffectSsKirakira_SpawnFocused", + "Effect_GetGlobalCtx": "Effect_GetPlayState", + "EffectSsHitMark_Spawn": "EffectSsHitmark_Spawn", + "EffectSsHitMark_SpawnFixedScale": "EffectSsHitmark_SpawnFixedScale", + "EffectSsHitMark_SpawnCustomScale": "EffectSsHitmark_SpawnCustomScale", + + "func_800E8F08": "Actor_TrackNone", + "func_800E8FA4": "Actor_TrackPoint", + "func_800E9250": "Actor_TrackPlayer", + "func_800E8EA0": "Actor_ContinueText", + + "func_8010A000": "Map_GetDungeonOrBossAreaIndex", + "func_8010A074": "Map_IsInDungeonOrBossArea", + "func_8010A0F0": "Map_GetDungeonAreaIndex", + "func_8010A164": "Map_IsInDungeonArea", + "func_8010A194": "Map_GetBossAreaIndex", + "func_8010A208": "Map_IsInBossArea", + "func_8010A2DC": "Minimap_SavePlayerRoomInitInfo", + "func_8010A33C": "Map_InitRoomData", + "func_8010A410": "Map_Destroy", + "func_8010A430": "Map_Init", + "func_8010A54C": "Minimap_Draw", + "func_8010A580": "Map_Update", + + "ActorCutscene_GetCurrentCamera": "ActorCutscene_GetCurrentSubCamId", + + "Entrance_CreateIndex": "Entrance_Create", + "Entrance_CreateIndexFromSpawn": "Entrance_CreateFromSpawn", + + # Structs + "ActorAnimationEntry": "AnimationInfo", + "ActorAnimationEntryS": "AnimationInfoS", + "struct_80B8E1A8": "AnimationSpeedInfo", + "GlobalContext": "PlayState", + "globalCtx": "play", + "globalCtx2": "play2", + "ScheduleResult": "ScheduleOutput", + + # Struct members "skelAnime.unk03": "skelAnime.taper", "skelAnime.animCurrentSeg": "skelAnime.animation", "skelAnime.initialFrame": "skelAnime.startFrame", @@ -501,14 +636,15 @@ animdict = { "skelAnime.prevFrameRot": "skelAnime.prevRot", "skelAnime.prevFramePos": "skelAnime.prevTransl", "skelAnime.unk3E": "skelAnime.baseTransl", - "actor.minVelocityY": "actor.terminalVelocity", "actor.yDistToWater": "actor.depthInWater", "actor.yDistToPlayer": "actor.playerHeightRel", + "gSaveContext.weekEventReg": "gSaveContext.save.weekEventReg", "gSaveContext.playerForm": "gSaveContext.save.playerForm", "gSaveContext.day": "gSaveContext.save.day", "gSaveContext.isNight": "gSaveContext.save.isNight", + "gSaveContext.environmentTime": "gSaveContext.skyboxTime", "gSaveContext.naviTimer": "gSaveContext.save.playerData.tatlTimer", "gSaveContext.tatlTimer": "gSaveContext.save.playerData.tatlTimer", "gSaveContext.rupees": "gSaveContext.save.playerData.rupees", @@ -518,7 +654,7 @@ animdict = { "gSaveContext.playerName": "gSaveContext.save.playerData.playerName", "gSaveContext.inventory": "gSaveContext.save.inventory", "gSaveContext.equippedMask": "gSaveContext.save.equippedMask", - "gSaveContext.entranceIndex": "gSaveContext.save.entranceIndex", + "gSaveContext.entranceIndex": "gSaveContext.save.entrance", "gSaveContext.time": "gSaveContext.save.time", "gSaveContext.unk_14": "gSaveContext.save.daySpeed", "gSaveContext.unk_FE6": "gSaveContext.save.bombersCaughtNum", @@ -529,6 +665,14 @@ animdict = { "gSaveContext.permanentSceneFlags": "gSaveContext.save.permanentSceneFlags", "gSaveContext.bomberCode": "gSaveContext.save.bomberCode", "gSaveContext.skullTokenCount": "gSaveContext.save.skullTokenCount", + "gSaveContext.cutscene": "gSaveContext.save.cutscene", + "gSaveContext.health": "gSaveContext.save.playerData.health", + "gSaveContext.equips": "gSaveContext.save.equips", + "gSaveContext.unk_1016": "gSaveContext.jinxTimer", + "gSaveContext.unk_3F58": "gSaveContext.sunsSongState", + "gSaveContext.unk_48C8": "gSaveContext.dungeonIndex", + "gSaveContext.save.entranceIndex": "gSaveContext.save.entrance", + "player->unk_A87": "player->exchangeItemId", "player->leftHandActor": "player->heldActor", "player->unk_384": "player->getItemId", @@ -536,23 +680,39 @@ animdict = { "player->unk_388": "player->interactRangeActor", "player->unk_38C": "player->mountSide", "player->unk_394": "player->csMode", + "player->swordQuads": "player->meleeWeaponQuads", + "player->blureEffectIndex": "player->meleeWeaponEffectIndex", + "player->swordAnimation": "player->meleeWeaponAnimation", + "player->swordState": "player->meleeWeaponState", + "player->swordInfo": "player->meleeWeaponInfo", "csCtx.npcActions": "csCtx.actorActions", "csCtx->npcActions": "csCtx->actorActions", "csCtx.unk_12": "csCtx.currentCsIndex", - "globalCtx->mf_187FC": "globalCtx->billboardMtxF", - "globalCtx->projectionMatrix": "globalCtx->viewProjectionMtxF", - "globalCtx->actorCtx.actorList[": "globalCtx->actorCtx.actorLists[", - "globalCtx->envCtx.unk_8C": "globalCtx->envCtx.lightSettings", - "globalCtx->envCtx.unk_E5": "globalCtx->envCtx.fillScreen", - "globalCtx->envCtx.unk_E6": "globalCtx->envCtx.screenFillColor", - "globalCtx->envCtx.unk_C3": "globalCtx->envCtx.lightSettingOverride", - "globalCtx->envCtx.unk_DC": "globalCtx->envCtx.lightBlend", - "gSaveContext.unk_1016": "gSaveContext.jinxTimer", - "gSaveContext.unk_3F58": "gSaveContext.sunsSongState", - "globalCtx->msgCtx.unk1202A": "globalCtx->msgCtx.ocarinaMode", - "globalCtx->msgCtx.unk1202C": "globalCtx->msgCtx.ocarinaAction", - "globalCtx->msgCtx.unk11F22": "globalCtx->msgCtx.msgMode", - "globalCtx->msgCtx.unk11F04": "globalCtx->msgCtx.currentTextId", + "globalCtx->mf_187FC": "play->billboardMtxF", + "globalCtx->projectionMatrix": "play->viewProjectionMtxF", + "globalCtx->actorCtx.actorList[": "play->actorCtx.actorLists[", + "globalCtx->envCtx.unk_8C": "play->envCtx.lightSettings", + "globalCtx->envCtx.unk_E5": "play->envCtx.fillScreen", + "globalCtx->envCtx.unk_E6": "play->envCtx.screenFillColor", + "globalCtx->envCtx.unk_C3": "play->envCtx.lightSettingOverride", + "globalCtx->envCtx.unk_DC": "play->envCtx.lightBlend", + "globalCtx->interfaceCtx.unk_21E": "play->interfaceCtx.bButtonDoAction", + + "play->msgCtx.unk11F04": "play->msgCtx.currentTextId", + "play->msgCtx.unk11F10": "play->msgCtx.msgLength", + "play->msgCtx.unk11F22": "play->msgCtx.msgMode", + "play->msgCtx.unk12023": "play->msgCtx.stateTimer", + "play->msgCtx.unk1202A": "play->msgCtx.ocarinaMode", + "play->msgCtx.unk1202C": "play->msgCtx.ocarinaAction", + "play->nextEntranceIndex": "play->nextEntrance", + + "play->sceneLoadFlag": "play->transitionTrigger", + "play->unk_18B4A": "play->transitionMode", + "play->unk_1887F": "play->transitionType", + "gSaveContext.nextTransition": "gSaveContext.nextTransitionType", + "gSaveContext.unk_3F48": "gSaveContext.cutsceneTransitionControl", + "gSaveContext.fadeDuration": "gSaveContext.transFadeDuration", + "gSaveContext.fadeSpeed": "gSaveContext.transWipeSpeed", "D_801D15B0" : "gZeroVec3f", "D_801D15BC" : "gZeroVec3s", @@ -562,75 +722,128 @@ animdict = { "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,", + + "EXCH_ITEM_MINUS1": "PLAYER_AP_MINUS1", + "EXCH_ITEM_NONE": "PLAYER_AP_NONE", + "EXCH_ITEM_PICTO_BOX": "PLAYER_AP_PICTO_BOX", + "EXCH_ITEM_1E": "PLAYER_AP_BOTTLE_MUSHROOM", + "EXCH_ITEM_MOON_TEAR": "PLAYER_AP_MOON_TEAR", + "EXCH_ITEM_DEED_LAND": "PLAYER_AP_DEED_LAND", + "EXCH_ITEM_ROOM_KEY": "PLAYER_AP_ROOM_KEY", + "EXCH_ITEM_LETTER_TO_KAFEI": "PLAYER_AP_LETTER_TO_KAFEI", + "EXCH_ITEM_2E": "PLAYER_AP_MAGIC_BEANS", + "EXCH_ITEM_DEED_SWAMP": "PLAYER_AP_DEED_SWAMP", + "EXCH_ITEM_DEED_MOUNTAIN": "PLAYER_AP_DEED_MOUNTAIN", + "EXCH_ITEM_DEED_OCEAN": "PLAYER_AP_DEED_OCEAN", + "EXCH_ITEM_LETTER_MAMA": "PLAYER_AP_LETTER_MAMA", + "ITEM_FISHING_POLE": "ITEM_FISHING_ROD", + "PLAYER_AP_FISHING_POLE": "PLAYER_AP_FISHING_ROD", + + # Example of custom behaviour: + # "PLAYER": ("GET_PLAYER(play)", {"ignore": (-1, '"PLAYER"')}), # ignore "PLAYER" in sSoundBankNames } -def replace_anim(file): - with open(file, 'r', encoding='utf-8') as infile: +# [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() - 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) + changesCount = 0 - if(fixes > 0): - print('Changed', fixes,'entr' + ('y' if fixes == 1 else 'ies') + ' in',file) + 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) - return 1 -def replace_anim_all(repo): - for subdir, dirs, files in os.walk(repo + os.sep + 'src'): +def replace_all(repo): + for subdir, dirs, files in os.walk(os.path.join(repo,'src')): for filename in files: - if(filename.endswith('.c')): - file = subdir + os.sep + filename - replace_anim(file) + if filename.endswith('.c') or filename.endswith('.h'): + file = os.path.join(subdir,filename) + replace_single(file) - for subdir, dirs, files in os.walk(repo + os.sep + 'asm'): + for subdir, dirs, files in os.walk(os.path.join(repo,'asm')): for filename in files: - if(filename.endswith('.s')): - file = subdir + os.sep + filename - replace_anim(file) + if filename.endswith('.s'): + file = os.path.join(subdir,filename) + replace_single(file) - for subdir, dirs, files in os.walk(repo + os.sep + 'data'): + for subdir, dirs, files in os.walk(os.path.join(repo,'data')): for filename in files: - if(filename.endswith('.s')): - file = subdir + os.sep + filename - replace_anim(file) + if filename.endswith('.s'): + file = os.path.join(subdir,filename) + replace_single(file) - for subdir, dirs, files in os.walk(repo + os.sep + 'docs'): + for subdir, dirs, files in os.walk(os.path.join(repo,'docs')): for filename in files: - if(filename.endswith('.md')): - file = subdir + os.sep + filename - replace_anim(file) + if filename.endswith('.md'): + file = os.path.join(subdir,filename) + replace_single(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() + keys = wordReplace.keys() + values = wordReplace.values() for k in keys: if k in values: print(f"Key '{k}' found in values") @@ -638,15 +851,27 @@ def dictSanityCheck(): 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) + 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_anim_all(os.curdir) + if args.file == '.': + replace_all(os.curdir) else: - replace_anim(args.file) + 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 2676d13ee..bf61be341 100644 --- a/tools/permuter_settings.toml +++ b/tools/permuter_settings.toml @@ -9,7 +9,10 @@ SET_FULLSCREEN_VIEWPORT = "void" OPEN_DISPS = "void" CLOSE_DISPS = "void" ABS = "int" +ABS_ALT = "int" SQ = "int" +ARRAY_COUNT = "int" +ARRAY_COUNTU = "int" CLAMP = "int" CLOCK_TIME = "int" CURRENT_DAY = "int" diff --git a/tools/sizes/boot_functions.csv b/tools/sizes/boot_functions.csv index 6c5c92e16..bbcf6d5de 100644 --- a/tools/sizes/boot_functions.csv +++ b/tools/sizes/boot_functions.csv @@ -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 @@ -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 a1267e0d3..15c5a5f60 100644 --- a/tools/sizes/code_functions.csv +++ b/tools/sizes/code_functions.csv @@ -66,7 +66,7 @@ asm/non_matchings/code/z_eff_tire_mark/EffectTireMark_Destroy.s,EffectTireMark_D asm/non_matchings/code/z_eff_tire_mark/EffectTireMark_Update.s,EffectTireMark_Update,0x800AF050,0x8D asm/non_matchings/code/z_eff_tire_mark/EffectTireMark_SetVertices.s,EffectTireMark_SetVertices,0x800AF284,0x23 asm/non_matchings/code/z_eff_tire_mark/EffectTireMark_Draw.s,EffectTireMark_Draw,0x800AF310,0x100 -asm/non_matchings/code/z_effect/Effect_GetGlobalCtx.s,Effect_GetGlobalCtx,0x800AF710,0x4 +asm/non_matchings/code/z_effect/Effect_GetPlayState.s,Effect_GetPlayState,0x800AF710,0x4 asm/non_matchings/code/z_effect/Effect_GetByIndex.s,Effect_GetByIndex,0x800AF720,0x57 asm/non_matchings/code/z_effect/Effect_InitStatus.s,Effect_InitStatus,0x800AF87C,0x5 asm/non_matchings/code/z_effect/Effect_Init.s,Effect_Init,0x800AF890,0x34 @@ -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 @@ -140,16 +140,16 @@ asm/non_matchings/code/z_effect_soft_sprite_old_init/EffectSsStick_Spawn.s,Effec asm/non_matchings/code/z_effect_soft_sprite_old_init/EffectSsSibuki_Spawn.s,EffectSsSibuki_Spawn,0x800B242C,0x1C asm/non_matchings/code/z_effect_soft_sprite_old_init/EffectSsSibuki_SpawnBurst.s,EffectSsSibuki_SpawnBurst,0x800B249C,0x4F asm/non_matchings/code/z_effect_soft_sprite_old_init/EffectSsStone1_Spawn.s,EffectSsStone1_Spawn,0x800B25D8,0x15 -asm/non_matchings/code/z_effect_soft_sprite_old_init/EffectSsHitMark_Spawn.s,EffectSsHitMark_Spawn,0x800B262C,0x16 -asm/non_matchings/code/z_effect_soft_sprite_old_init/EffectSsHitMark_SpawnFixedScale.s,EffectSsHitMark_SpawnFixedScale,0x800B2684,0x9 -asm/non_matchings/code/z_effect_soft_sprite_old_init/EffectSsHitMark_SpawnCustomScale.s,EffectSsHitMark_SpawnCustomScale,0x800B26A8,0xB +asm/non_matchings/code/z_effect_soft_sprite_old_init/EffectSsHitmark_Spawn.s,EffectSsHitmark_Spawn,0x800B262C,0x16 +asm/non_matchings/code/z_effect_soft_sprite_old_init/EffectSsHitmark_SpawnFixedScale.s,EffectSsHitmark_SpawnFixedScale,0x800B2684,0x9 +asm/non_matchings/code/z_effect_soft_sprite_old_init/EffectSsHitmark_SpawnCustomScale.s,EffectSsHitmark_SpawnCustomScale,0x800B26A8,0xB asm/non_matchings/code/z_effect_soft_sprite_old_init/EffectSsFhgFlash_SpawnShock.s,EffectSsFhgFlash_SpawnShock,0x800B26D4,0x19 asm/non_matchings/code/z_effect_soft_sprite_old_init/EffectSsKFire_Spawn.s,EffectSsKFire_Spawn,0x800B2738,0x1A asm/non_matchings/code/z_effect_soft_sprite_old_init/EffectSsSolderSrchBall_Spawn.s,EffectSsSolderSrchBall_Spawn,0x800B27A0,0x1C asm/non_matchings/code/z_effect_soft_sprite_old_init/EffectSsKakera_Spawn.s,EffectSsKakera_Spawn,0x800B2810,0x2E asm/non_matchings/code/z_effect_soft_sprite_old_init/EffectSsIcePiece_Spawn.s,EffectSsIcePiece_Spawn,0x800B28C8,0x1A asm/non_matchings/code/z_effect_soft_sprite_old_init/EffectSsIcePiece_SpawnBurst.s,EffectSsIcePiece_SpawnBurst,0x800B2930,0x65 -asm/non_matchings/code/z_effect_soft_sprite_old_init/EffectSsEnIce_SpawnFlyingVec3f.s,EffectSsEnIce_SpawnFlyingVec3f,0x800B2AC4,0x20 +asm/non_matchings/code/z_effect_soft_sprite_old_init/EffectSsEnIce_SpawnFlying.s,EffectSsEnIce_SpawnFlying,0x800B2AC4,0x20 asm/non_matchings/code/z_effect_soft_sprite_old_init/func_800B2B44.s,func_800B2B44,0x800B2B44,0xE asm/non_matchings/code/z_effect_soft_sprite_old_init/func_800B2B7C.s,func_800B2B7C,0x800B2B7C,0x11 asm/non_matchings/code/z_effect_soft_sprite_old_init/EffectSsEnIce_Spawn.s,EffectSsEnIce_Spawn,0x800B2BC0,0x22 @@ -297,7 +297,7 @@ asm/non_matchings/code/z_actor/func_800B8804.s,func_800B8804,0x800B8804,0xA asm/non_matchings/code/z_actor/func_800B882C.s,func_800B882C,0x800B882C,0x10 asm/non_matchings/code/z_actor/func_800B886C.s,func_800B886C,0x800B886C,0xB asm/non_matchings/code/z_actor/Actor_GetScreenPos.s,Actor_GetScreenPos,0x800B8898,0x27 -asm/non_matchings/code/z_actor/func_800B8934.s,func_800B8934,0x800B8934,0x31 +asm/non_matchings/code/z_actor/Actor_OnScreen.s,Actor_OnScreen,0x800B8934,0x31 asm/non_matchings/code/z_actor/Actor_HasParent.s,Actor_HasParent,0x800B89F8,0x9 asm/non_matchings/code/z_actor/Actor_PickUp.s,Actor_PickUp,0x800B8A1C,0x5A asm/non_matchings/code/z_actor/Actor_PickUpNearby.s,Actor_PickUpNearby,0x800B8B84,0xB @@ -561,13 +561,13 @@ asm/non_matchings/code/z_bgcheck/CollisionHeader_GetVirtual.s,CollisionHeader_Ge asm/non_matchings/code/z_bgcheck/BgCheck_InitCollisionHeaders.s,BgCheck_InitCollisionHeaders,0x800C9598,0x2A asm/non_matchings/code/z_bgcheck/func_800C9640.s,func_800C9640,0x800C9640,0x15 asm/non_matchings/code/z_bgcheck/SurfaceType_GetData.s,SurfaceType_GetData,0x800C9694,0x1C -asm/non_matchings/code/z_bgcheck/SurfaceType_GetCamDataIndex.s,SurfaceType_GetCamDataIndex,0x800C9704,0x9 -asm/non_matchings/code/z_bgcheck/func_800C9728.s,func_800C9728,0x800C9728,0x12 +asm/non_matchings/code/z_bgcheck/SurfaceType_GetBgCamIndex.s,SurfaceType_GetBgCamIndex,0x800C9704,0x9 +asm/non_matchings/code/z_bgcheck/BgCheck_GetBgCamSettingImpl.s,BgCheck_GetBgCamSettingImpl,0x800C9728,0x12 asm/non_matchings/code/z_bgcheck/func_800C9770.s,func_800C9770,0x800C9770,0x22 -asm/non_matchings/code/z_bgcheck/func_800C97F8.s,func_800C97F8,0x800C97F8,0x13 -asm/non_matchings/code/z_bgcheck/func_800C9844.s,func_800C9844,0x800C9844,0x22 -asm/non_matchings/code/z_bgcheck/func_800C98CC.s,func_800C98CC,0x800C98CC,0x16 -asm/non_matchings/code/z_bgcheck/SurfaceType_GetCamPosData.s,SurfaceType_GetCamPosData,0x800C9924,0x22 +asm/non_matchings/code/z_bgcheck/BgCheck_GetBgCamCountImpl.s,BgCheck_GetBgCamCountImpl,0x800C97F8,0x13 +asm/non_matchings/code/z_bgcheck/BgCheck_GetBgCamCount.s,BgCheck_GetBgCamCount,0x800C9844,0x22 +asm/non_matchings/code/z_bgcheck/BgCheck_GetBgCamFuncDataImpl.s,BgCheck_GetBgCamFuncDataImpl,0x800C98CC,0x16 +asm/non_matchings/code/z_bgcheck/BgCheck_GetBgCamFuncData.s,BgCheck_GetBgCamFuncData,0x800C9924,0x22 asm/non_matchings/code/z_bgcheck/SurfaceType_GetSceneExitIndex.s,SurfaceType_GetSceneExitIndex,0x800C99AC,0xA asm/non_matchings/code/z_bgcheck/func_800C99D4.s,func_800C99D4,0x800C99D4,0xA asm/non_matchings/code/z_bgcheck/func_800C99FC.s,func_800C99FC,0x800C99FC,0xA @@ -601,7 +601,7 @@ asm/non_matchings/code/z_bgcheck/WaterBox_GetSurface2.s,WaterBox_GetSurface2,0x8 asm/non_matchings/code/z_bgcheck/func_800CA568.s,func_800CA568,0x800CA568,0x33 asm/non_matchings/code/z_bgcheck/func_800CA634.s,func_800CA634,0x800CA634,0x5 asm/non_matchings/code/z_bgcheck/func_800CA648.s,func_800CA648,0x800CA648,0x1C -asm/non_matchings/code/z_bgcheck/func_800CA6B8.s,func_800CA6B8,0x800CA6B8,0x8 +asm/non_matchings/code/z_bgcheck/WaterBox_GetSceneBgCamSetting.s,WaterBox_GetSceneBgCamSetting,0x800CA6B8,0x8 asm/non_matchings/code/z_bgcheck/WaterBox_GetLightSettingIndex.s,WaterBox_GetLightSettingIndex,0x800CA6D8,0x6 asm/non_matchings/code/z_bgcheck/func_800CA6F0.s,func_800CA6F0,0x800CA6F0,0xB8 asm/non_matchings/code/z_bgcheck/func_800CA9D0.s,func_800CA9D0,0x800CA9D0,0x11 @@ -627,37 +627,37 @@ asm/non_matchings/code/z_bg_item/DynaPoly_IsInSwitchPressedState.s,DynaPoly_IsIn asm/non_matchings/code/z_bg_item/DynaPoly_IsInHeavySwitchPressedState.s,DynaPoly_IsInHeavySwitchPressedState,0x800CAFDC,0x9 asm/non_matchings/code/z_bg_item/DynaPoly_ValidateMove.s,DynaPoly_ValidateMove,0x800CB000,0x84 asm/non_matchings/code/z_camera/Camera_fabsf.s,Camera_fabsf,0x800CB210,0xC -asm/non_matchings/code/z_camera/Camera_LengthVec3f.s,Camera_LengthVec3f,0x800CB240,0xC -asm/non_matchings/code/z_camera/func_800CB270.s,func_800CB270,0x800CB270,0x30 -asm/non_matchings/code/z_camera/Camera_Lerpf.s,Camera_Lerpf,0x800CB330,0x1A -asm/non_matchings/code/z_camera/Camera_Lerps.s,Camera_Lerps,0x800CB398,0x25 -asm/non_matchings/code/z_camera/func_800CB42C.s,func_800CB42C,0x800CB42C,0x25 -asm/non_matchings/code/z_camera/Camera_LerpVec3f.s,Camera_LerpVec3f,0x800CB4C0,0x21 -asm/non_matchings/code/z_camera/func_800CB544.s,func_800CB544,0x800CB544,0x10 -asm/non_matchings/code/z_camera/func_800CB584.s,func_800CB584,0x800CB584,0x16 -asm/non_matchings/code/z_camera/func_800CB5DC.s,func_800CB5DC,0x800CB5DC,0xC -asm/non_matchings/code/z_camera/func_800CB60C.s,func_800CB60C,0x800CB60C,0x1A -asm/non_matchings/code/z_camera/func_800CB674.s,func_800CB674,0x800CB674,0x15 -asm/non_matchings/code/z_camera/func_800CB6C8.s,func_800CB6C8,0x800CB6C8,0xE -asm/non_matchings/code/z_camera/func_800CB700.s,func_800CB700,0x800CB700,0x20 -asm/non_matchings/code/z_camera/func_800CB780.s,func_800CB780,0x800CB780,0x13 +asm/non_matchings/code/z_camera/Camera_Vec3fMagnitude.s,Camera_Vec3fMagnitude,0x800CB240,0xC +asm/non_matchings/code/z_camera/Camera_QuadraticAttenuation.s,Camera_QuadraticAttenuation,0x800CB270,0x30 +asm/non_matchings/code/z_camera/Camera_LerpCeilF.s,Camera_LerpCeilF,0x800CB330,0x1A +asm/non_matchings/code/z_camera/Camera_LerpCeilS.s,Camera_LerpCeilS,0x800CB398,0x25 +asm/non_matchings/code/z_camera/Camera_LerpFloorS.s,Camera_LerpFloorS,0x800CB42C,0x25 +asm/non_matchings/code/z_camera/Camera_LerpCeilVec3f.s,Camera_LerpCeilVec3f,0x800CB4C0,0x21 +asm/non_matchings/code/z_camera/Camera_SetUpdateRatesFastPitch.s,Camera_SetUpdateRatesFastPitch,0x800CB544,0x10 +asm/non_matchings/code/z_camera/Camera_SetUpdateRatesFastYaw.s,Camera_SetUpdateRatesFastYaw,0x800CB584,0x16 +asm/non_matchings/code/z_camera/Camera_SetUpdateRatesSlow.s,Camera_SetUpdateRatesSlow,0x800CB5DC,0xC +asm/non_matchings/code/z_camera/Camera_Vec3sToVec3f.s,Camera_Vec3sToVec3f,0x800CB60C,0x1A +asm/non_matchings/code/z_camera/Camera_AngleDiffAndScale.s,Camera_AngleDiffAndScale,0x800CB674,0x15 +asm/non_matchings/code/z_camera/Camera_UpdateAtActorOffset.s,Camera_UpdateAtActorOffset,0x800CB6C8,0xE +asm/non_matchings/code/z_camera/Camera_GetFocalActorHeight.s,Camera_GetFocalActorHeight,0x800CB700,0x20 +asm/non_matchings/code/z_camera/Camera_GetRunSpeedLimit.s,Camera_GetRunSpeedLimit,0x800CB780,0x13 asm/non_matchings/code/z_camera/func_800CB7CC.s,func_800CB7CC,0x800CB7CC,0xB -asm/non_matchings/code/z_camera/func_800CB7F8.s,func_800CB7F8,0x800CB7F8,0xC -asm/non_matchings/code/z_camera/func_800CB828.s,func_800CB828,0x800CB828,0xB +asm/non_matchings/code/z_camera/Camera_IsMountedOnHorse.s,Camera_IsMountedOnHorse,0x800CB7F8,0xC +asm/non_matchings/code/z_camera/Camera_IsDekuHovering.s,Camera_IsDekuHovering,0x800CB828,0xB asm/non_matchings/code/z_camera/func_800CB854.s,func_800CB854,0x800CB854,0xB -asm/non_matchings/code/z_camera/func_800CB880.s,func_800CB880,0x800CB880,0x12 -asm/non_matchings/code/z_camera/func_800CB8C8.s,func_800CB8C8,0x800CB8C8,0xB -asm/non_matchings/code/z_camera/func_800CB8F4.s,func_800CB8F4,0x800CB8F4,0xC +asm/non_matchings/code/z_camera/Camera_IsSwimming.s,Camera_IsSwimming,0x800CB880,0x12 +asm/non_matchings/code/z_camera/Camera_IsDiving.s,Camera_IsDiving,0x800CB8C8,0xB +asm/non_matchings/code/z_camera/Camera_IsPlayerFormZora.s,Camera_IsPlayerFormZora,0x800CB8F4,0xC asm/non_matchings/code/z_camera/func_800CB924.s,func_800CB924,0x800CB924,0xB asm/non_matchings/code/z_camera/func_800CB950.s,func_800CB950,0x800CB950,0x2E -asm/non_matchings/code/z_camera/func_800CBA08.s,func_800CBA08,0x800CBA08,0xB -asm/non_matchings/code/z_camera/func_800CBA34.s,func_800CBA34,0x800CBA34,0x12 +asm/non_matchings/code/z_camera/Camera_IsClimbingLedge.s,Camera_IsClimbingLedge,0x800CBA08,0xB +asm/non_matchings/code/z_camera/Camera_IsChargingSwordOrDekuFlowerDive.s,Camera_IsChargingSwordOrDekuFlowerDive,0x800CBA34,0x12 asm/non_matchings/code/z_camera/func_800CBA7C.s,func_800CBA7C,0x800CBA7C,0xC asm/non_matchings/code/z_camera/func_800CBAAC.s,func_800CBAAC,0x800CBAAC,0xA -asm/non_matchings/code/z_camera/func_800CBAD4.s,func_800CBAD4,0x800CBAD4,0x21 -asm/non_matchings/code/z_camera/func_800CBB58.s,func_800CBB58,0x800CBB58,0xC +asm/non_matchings/code/z_camera/Camera_GetFocalActorPos.s,Camera_GetFocalActorPos,0x800CBAD4,0x21 +asm/non_matchings/code/z_camera/Camera_IsUnderwaterAsZora.s,Camera_IsUnderwaterAsZora,0x800CBB58,0xC asm/non_matchings/code/z_camera/func_800CBB88.s,func_800CBB88,0x800CBB88,0x1E -asm/non_matchings/code/z_camera/func_800CBC00.s,func_800CBC00,0x800CBC00,0xC +asm/non_matchings/code/z_camera/Camera_IsUsingZoraFins.s,Camera_IsUsingZoraFins,0x800CBC00,0xC asm/non_matchings/code/z_camera/func_800CBC30.s,func_800CBC30,0x800CBC30,0x15 asm/non_matchings/code/z_camera/func_800CBC84.s,func_800CBC84,0x800CBC84,0xC8 asm/non_matchings/code/z_camera/func_800CBFA4.s,func_800CBFA4,0x800CBFA4,0x17 @@ -668,10 +668,10 @@ asm/non_matchings/code/z_camera/func_800CC260.s,func_800CC260,0x800CC260,0x8A asm/non_matchings/code/z_camera/func_800CC488.s,func_800CC488,0x800CC488,0x39 asm/non_matchings/code/z_camera/func_800CC56C.s,func_800CC56C,0x800CC56C,0x17 asm/non_matchings/code/z_camera/func_800CC5C8.s,func_800CC5C8,0x800CC5C8,0x5E -asm/non_matchings/code/z_camera/func_800CC740.s,func_800CC740,0x800CC740,0x1A -asm/non_matchings/code/z_camera/func_800CC7A8.s,func_800CC7A8,0x800CC7A8,0x17 -asm/non_matchings/code/z_camera/func_800CC804.s,func_800CC804,0x800CC804,0x1C -asm/non_matchings/code/z_camera/func_800CC874.s,func_800CC874,0x800CC874,0x31 +asm/non_matchings/code/z_camera/Camera_GetBgCamOrActorCsCamSetting.s,Camera_GetBgCamOrActorCsCamSetting,0x800CC740,0x1A +asm/non_matchings/code/z_camera/Camera_GetBgCamOrActorCsCamFuncData.s,Camera_GetBgCamOrActorCsCamFuncData,0x800CC7A8,0x17 +asm/non_matchings/code/z_camera/Camera_GetBgCamIndex.s,Camera_GetBgCamIndex,0x800CC804,0x1C +asm/non_matchings/code/z_camera/Camera_GetWaterBoxBgCamSetting.s,Camera_GetWaterBoxBgCamSetting,0x800CC874,0x31 asm/non_matchings/code/z_camera/func_800CC938.s,func_800CC938,0x800CC938,0x8 asm/non_matchings/code/z_camera/func_800CC958.s,func_800CC958,0x800CC958,0x1A asm/non_matchings/code/z_camera/func_800CC9C0.s,func_800CC9C0,0x800CC9C0,0xCB @@ -772,8 +772,8 @@ asm/non_matchings/code/z_camera/Camera_Free.s,Camera_Free,0x800DDDA8,0xA asm/non_matchings/code/z_camera/Camera_Init.s,Camera_Init,0x800DDDD0,0x84 asm/non_matchings/code/z_camera/func_800DDFE0.s,func_800DDFE0,0x800DDFE0,0x40 asm/non_matchings/code/z_camera/func_800DE0E0.s,func_800DE0E0,0x800DE0E0,0x3 -asm/non_matchings/code/z_camera/func_800DE0EC.s,func_800DE0EC,0x800DE0EC,0x87 -asm/non_matchings/code/z_camera/func_800DE308.s,func_800DE308,0x800DE308,0x7 +asm/non_matchings/code/z_camera/Camera_InitPlayerSettings.s,Camera_InitPlayerSettings,0x800DE0EC,0x87 +asm/non_matchings/code/z_camera/Camera_ChangeStatus.s,Camera_ChangeStatus,0x800DE308,0x7 asm/non_matchings/code/z_camera/func_800DE324.s,func_800DE324,0x800DE324,0xC2 asm/non_matchings/code/z_camera/func_800DE62C.s,func_800DE62C,0x800DE62C,0x85 asm/non_matchings/code/z_camera/func_800DE840.s,func_800DE840,0x800DE840,0x14 @@ -785,24 +785,24 @@ asm/non_matchings/code/z_camera/Camera_SetMode.s,Camera_SetMode,0x800DF4D0,0xDC asm/non_matchings/code/z_camera/Camera_ChangeMode.s,Camera_ChangeMode,0x800DF840,0xB asm/non_matchings/code/z_camera/func_800DF86C.s,func_800DF86C,0x800DF86C,0x20 asm/non_matchings/code/z_camera/func_800DF8EC.s,func_800DF8EC,0x800DF8EC,0x77 -asm/non_matchings/code/z_camera/func_800DFAC8.s,func_800DFAC8,0x800DFAC8,0x13 +asm/non_matchings/code/z_camera/Camera_ChangeSetting.s,Camera_ChangeSetting,0x800DFAC8,0x13 asm/non_matchings/code/z_camera/Camera_ChangeDataIdx.s,Camera_ChangeDataIdx,0x800DFB14,0x42 asm/non_matchings/code/z_camera/func_800DFC1C.s,func_800DFC1C,0x800DFC1C,0x9 asm/non_matchings/code/z_camera/func_800DFC40.s,func_800DFC40,0x800DFC40,0xA asm/non_matchings/code/z_camera/Camera_GetInputDirYaw.s,Camera_GetInputDirYaw,0x800DFC68,0xA -asm/non_matchings/code/z_camera/func_800DFC90.s,func_800DFC90,0x800DFC90,0x9 +asm/non_matchings/code/z_camera/Camera_GetCamDir.s,Camera_GetCamDir,0x800DFC90,0x9 asm/non_matchings/code/z_camera/Camera_GetCamDirPitch.s,Camera_GetCamDirPitch,0x800DFCB4,0xA asm/non_matchings/code/z_camera/Camera_GetCamDirYaw.s,Camera_GetCamDirYaw,0x800DFCDC,0xA -asm/non_matchings/code/z_camera/func_800DFD04.s,func_800DFD04,0x800DFD04,0x1D -asm/non_matchings/code/z_camera/func_800DFD78.s,func_800DFD78,0x800DFD78,0x5E +asm/non_matchings/code/z_camera/Camera_AddQuake.s,Camera_AddQuake,0x800DFD04,0x1D +asm/non_matchings/code/z_camera/Camera_SetViewParam.s,Camera_SetViewParam,0x800DFD78,0x5E asm/non_matchings/code/z_camera/func_800DFEF0.s,func_800DFEF0,0x800DFEF0,0xA asm/non_matchings/code/z_camera/func_800DFF18.s,func_800DFF18,0x800DFF18,0x7 asm/non_matchings/code/z_camera/func_800DFF34.s,func_800DFF34,0x800DFF34,0x4 asm/non_matchings/code/z_camera/func_800DFF44.s,func_800DFF44,0x800DFF44,0x7 asm/non_matchings/code/z_camera/Camera_SetFlags.s,Camera_SetFlags,0x800DFF60,0x9 asm/non_matchings/code/z_camera/Camera_ClearFlags.s,Camera_ClearFlags,0x800DFF84,0xA -asm/non_matchings/code/z_camera/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/Camera_ChangeDoorCam.s,Camera_ChangeDoorCam,0x800DFFAC,0x34 +asm/non_matchings/code/z_camera/Camera_Copy.s,Camera_Copy,0x800E007C,0x4C asm/non_matchings/code/z_camera/func_800E01AC.s,func_800E01AC,0x800E01AC,0x3 asm/non_matchings/code/z_camera/Camera_GetQuakeOffset.s,Camera_GetQuakeOffset,0x800E01B8,0x9 asm/non_matchings/code/z_camera/func_800E01DC.s,func_800E01DC,0x800E01DC,0x13 @@ -1023,15 +1023,15 @@ 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/DebugDisplay_Init.s,DebugDisplay_Init,0x800E9470,0x6 @@ -1097,29 +1097,29 @@ asm/non_matchings/code/z_demo/Cutscene_GetActorActionIndex.s,Cutscene_GetActorAc 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 -asm/non_matchings/code/z_draw/func_800EE5FC.s,func_800EE5FC,0x800EE5FC,0x77 -asm/non_matchings/code/z_draw/func_800EE7D8.s,func_800EE7D8,0x800EE7D8,0x5A -asm/non_matchings/code/z_draw/func_800EE940.s,func_800EE940,0x800EE940,0x42 -asm/non_matchings/code/z_draw/func_800EEA48.s,func_800EEA48,0x800EEA48,0x74 -asm/non_matchings/code/z_draw/func_800EEC18.s,func_800EEC18,0x800EEC18,0x42 -asm/non_matchings/code/z_draw/func_800EED20.s,func_800EED20,0x800EED20,0x45 -asm/non_matchings/code/z_draw/func_800EEE34.s,func_800EEE34,0x800EEE34,0x46 -asm/non_matchings/code/z_draw/func_800EEF4C.s,func_800EEF4C,0x800EEF4C,0x42 -asm/non_matchings/code/z_draw/func_800EF054.s,func_800EF054,0x800EF054,0x27 -asm/non_matchings/code/z_draw/func_800EF0F0.s,func_800EF0F0,0x800EF0F0,0x41 -asm/non_matchings/code/z_draw/func_800EF1F4.s,func_800EF1F4,0x800EF1F4,0x2E -asm/non_matchings/code/z_draw/func_800EF2AC.s,func_800EF2AC,0x800EF2AC,0x2E -asm/non_matchings/code/z_draw/func_800EF364.s,func_800EF364,0x800EF364,0x5C -asm/non_matchings/code/z_draw/func_800EF4D4.s,func_800EF4D4,0x800EF4D4,0x62 -asm/non_matchings/code/z_draw/func_800EF65C.s,func_800EF65C,0x800EF65C,0x49 -asm/non_matchings/code/z_draw/func_800EF780.s,func_800EF780,0x800EF780,0x47 -asm/non_matchings/code/z_draw/func_800EF89C.s,func_800EF89C,0x800EF89C,0x3A -asm/non_matchings/code/z_draw/func_800EF984.s,func_800EF984,0x800EF984,0x4D -asm/non_matchings/code/z_draw/func_800EFAB8.s,func_800EFAB8,0x800EFAB8,0x51 -asm/non_matchings/code/z_draw/func_800EFBFC.s,func_800EFBFC,0x800EFBFC,0x52 -asm/non_matchings/code/z_draw/func_800EFD44.s,func_800EFD44,0x800EFD44,0x47 +asm/non_matchings/code/z_draw/GetItem_DrawBombchu.s,GetItem_DrawBombchu,0x800EE364,0x27 +asm/non_matchings/code/z_draw/GetItem_DrawPoes.s,GetItem_DrawPoes,0x800EE400,0x7F +asm/non_matchings/code/z_draw/GetItem_DrawFairyBottle.s,GetItem_DrawFairyBottle,0x800EE5FC,0x77 +asm/non_matchings/code/z_draw/GetItem_DrawSkullToken.s,GetItem_DrawSkullToken,0x800EE7D8,0x5A +asm/non_matchings/code/z_draw/GetItem_DrawCompass.s,GetItem_DrawCompass,0x800EE940,0x42 +asm/non_matchings/code/z_draw/GetItem_DrawPotion.s,GetItem_DrawPotion,0x800EEA48,0x74 +asm/non_matchings/code/z_draw/GetItem_DrawGoronSword.s,GetItem_DrawGoronSword,0x800EEC18,0x42 +asm/non_matchings/code/z_draw/GetItem_DrawDekuNuts.s,GetItem_DrawDekuNuts,0x800EED20,0x45 +asm/non_matchings/code/z_draw/GetItem_DrawRecoveryHeart.s,GetItem_DrawRecoveryHeart,0x800EEE34,0x46 +asm/non_matchings/code/z_draw/GetItem_DrawFish.s,GetItem_DrawFish,0x800EEF4C,0x42 +asm/non_matchings/code/z_draw/GetItem_DrawOpa0.s,GetItem_DrawOpa0,0x800EF054,0x27 +asm/non_matchings/code/z_draw/GetItem_DrawOpa0Xlu1.s,GetItem_DrawOpa0Xlu1,0x800EF0F0,0x41 +asm/non_matchings/code/z_draw/GetItem_DrawOpa01.s,GetItem_DrawOpa01,0x800EF1F4,0x2E +asm/non_matchings/code/z_draw/GetItem_DrawXlu01.s,GetItem_DrawXlu01,0x800EF2AC,0x2E +asm/non_matchings/code/z_draw/GetItem_DrawSeahorse.s,GetItem_DrawSeahorse,0x800EF364,0x5C +asm/non_matchings/code/z_draw/GetItem_DrawFairyContainer.s,GetItem_DrawFairyContainer,0x800EF4D4,0x62 +asm/non_matchings/code/z_draw/GetItem_DrawMoonsTear.s,GetItem_DrawMoonsTear,0x800EF65C,0x49 +asm/non_matchings/code/z_draw/GetItem_DrawMagicArrow.s,GetItem_DrawMagicArrow,0x800EF780,0x47 +asm/non_matchings/code/z_draw/GetItem_DrawUpgrades.s,GetItem_DrawUpgrades,0x800EF89C,0x3A +asm/non_matchings/code/z_draw/GetItem_DrawRupee.s,GetItem_DrawRupee,0x800EF984,0x4D +asm/non_matchings/code/z_draw/GetItem_DrawSmallRupee.s,GetItem_DrawSmallRupee,0x800EFAB8,0x51 +asm/non_matchings/code/z_draw/GetItem_DrawWallet.s,GetItem_DrawWallet,0x800EFBFC,0x52 +asm/non_matchings/code/z_draw/GetItem_DrawRemains.s,GetItem_DrawRemains,0x800EFD44,0x47 asm/non_matchings/code/z_eff_footmark/EffFootmark_Init.s,EffFootmark_Init,0x800EFE60,0x29 asm/non_matchings/code/z_eff_footmark/EffFootmark_Add.s,EffFootmark_Add,0x800EFF04,0x6E asm/non_matchings/code/z_eff_footmark/EffFootmark_Update.s,EffFootmark_Update,0x800F00BC,0x43 @@ -1171,7 +1171,7 @@ asm/non_matchings/code/z_eventmgr/ActorCutscene_GetAdditionalCutscene.s,ActorCut asm/non_matchings/code/z_eventmgr/ActorCutscene_GetLength.s,ActorCutscene_GetLength,0x800F20F8,0x10 asm/non_matchings/code/z_eventmgr/func_800F2138.s,func_800F2138,0x800F2138,0x10 asm/non_matchings/code/z_eventmgr/func_800F2178.s,func_800F2178,0x800F2178,0x10 -asm/non_matchings/code/z_eventmgr/ActorCutscene_GetCurrentCamera.s,ActorCutscene_GetCurrentCamera,0x800F21B8,0x5 +asm/non_matchings/code/z_eventmgr/ActorCutscene_GetCurrentSubCamId.s,ActorCutscene_GetCurrentSubCamId,0x800F21B8,0x5 asm/non_matchings/code/z_eventmgr/func_800F21CC.s,func_800F21CC,0x800F21CC,0x3E asm/non_matchings/code/z_eventmgr/func_800F22C4.s,func_800F22C4,0x800F22C4,0x40 asm/non_matchings/code/z_eventmgr/ActorCutscene_SetReturnCamera.s,ActorCutscene_SetReturnCamera,0x800F23C4,0x7 @@ -1508,21 +1508,21 @@ asm/non_matchings/code/z_map_data/func_80109DD8.s,func_80109DD8,0x80109DD8,0x26 asm/non_matchings/code/z_map_data/func_80109E70.s,func_80109E70,0x80109E70,0x22 asm/non_matchings/code/z_map_data/func_80109EF8.s,func_80109EF8,0x80109EF8,0x20 asm/non_matchings/code/z_map_data/func_80109F78.s,func_80109F78,0x80109F78,0x22 -asm/non_matchings/code/z_map_exp/func_8010A000.s,func_8010A000,0x8010A000,0x1D -asm/non_matchings/code/z_map_exp/func_8010A074.s,func_8010A074,0x8010A074,0xC +asm/non_matchings/code/z_map_exp/Map_GetDungeonOrBossAreaIndex.s,Map_GetDungeonOrBossAreaIndex,0x8010A000,0x1D +asm/non_matchings/code/z_map_exp/Map_IsInDungeonOrBossArea.s,Map_IsInDungeonOrBossArea,0x8010A074,0xC asm/non_matchings/code/z_map_exp/func_8010A0A4.s,func_8010A0A4,0x8010A0A4,0x13 -asm/non_matchings/code/z_map_exp/func_8010A0F0.s,func_8010A0F0,0x8010A0F0,0x1D -asm/non_matchings/code/z_map_exp/func_8010A164.s,func_8010A164,0x8010A164,0xC -asm/non_matchings/code/z_map_exp/func_8010A194.s,func_8010A194,0x8010A194,0x1D -asm/non_matchings/code/z_map_exp/func_8010A208.s,func_8010A208,0x8010A208,0xC +asm/non_matchings/code/z_map_exp/Map_GetDungeonAreaIndex.s,Map_GetDungeonAreaIndex,0x8010A0F0,0x1D +asm/non_matchings/code/z_map_exp/Map_IsInDungeonArea.s,Map_IsInDungeonArea,0x8010A164,0xC +asm/non_matchings/code/z_map_exp/Map_GetBossAreaIndex.s,Map_GetBossAreaIndex,0x8010A194,0x1D +asm/non_matchings/code/z_map_exp/Map_IsInBossArea.s,Map_IsInBossArea,0x8010A208,0xC asm/non_matchings/code/z_map_exp/func_8010A238.s,func_8010A238,0x8010A238,0x1D asm/non_matchings/code/z_map_exp/func_8010A2AC.s,func_8010A2AC,0x8010A2AC,0xC -asm/non_matchings/code/z_map_exp/func_8010A2DC.s,func_8010A2DC,0x8010A2DC,0x18 -asm/non_matchings/code/z_map_exp/func_8010A33C.s,func_8010A33C,0x8010A33C,0x35 -asm/non_matchings/code/z_map_exp/func_8010A410.s,func_8010A410,0x8010A410,0x8 -asm/non_matchings/code/z_map_exp/func_8010A430.s,func_8010A430,0x8010A430,0x47 -asm/non_matchings/code/z_map_exp/func_8010A54C.s,func_8010A54C,0x8010A54C,0xD -asm/non_matchings/code/z_map_exp/func_8010A580.s,func_8010A580,0x8010A580,0x78 +asm/non_matchings/code/z_map_exp/Minimap_SavePlayerRoomInitInfo.s,Minimap_SavePlayerRoomInitInfo,0x8010A2DC,0x18 +asm/non_matchings/code/z_map_exp/Map_InitRoomData.s,Map_InitRoomData,0x8010A33C,0x35 +asm/non_matchings/code/z_map_exp/Map_Destroy.s,Map_Destroy,0x8010A410,0x8 +asm/non_matchings/code/z_map_exp/Map_Init.s,Map_Init,0x8010A430,0x47 +asm/non_matchings/code/z_map_exp/Minimap_Draw.s,Minimap_Draw,0x8010A54C,0xD +asm/non_matchings/code/z_map_exp/Map_Update.s,Map_Update,0x8010A580,0x78 asm/non_matchings/code/z_msgevent/func_8010A760.s,func_8010A760,0x8010A760,0x1B asm/non_matchings/code/z_msgevent/func_8010A7CC.s,func_8010A7CC,0x8010A7CC,0x12 asm/non_matchings/code/z_msgevent/func_8010A814.s,func_8010A814,0x8010A814,0x12 @@ -1623,31 +1623,31 @@ asm/non_matchings/code/z_parameter/func_80111CB4.s,func_80111CB4,0x80111CB4,0x34 asm/non_matchings/code/z_parameter/func_801129E4.s,func_801129E4,0x801129E4,0x44 asm/non_matchings/code/z_parameter/func_80112AF4.s,func_80112AF4,0x80112AF4,0x2 asm/non_matchings/code/z_parameter/func_80112AFC.s,func_80112AFC,0x80112AFC,0x11 -asm/non_matchings/code/z_parameter/func_80112B40.s,func_80112B40,0x80112B40,0x29 -asm/non_matchings/code/z_parameter/func_80112BE4.s,func_80112BE4,0x80112BE4,0xA +asm/non_matchings/code/z_parameter/Interface_LoadItemIconImpl.s,Interface_LoadItemIconImpl,0x80112B40,0x29 +asm/non_matchings/code/z_parameter/Interface_LoadItemIcon.s,Interface_LoadItemIcon,0x80112BE4,0xA asm/non_matchings/code/z_parameter/func_80112C0C.s,func_80112C0C,0x80112C0C,0x9D asm/non_matchings/code/z_parameter/Item_Give.s,Item_Give,0x80112E80,0x553 -asm/non_matchings/code/z_parameter/func_801143CC.s,func_801143CC,0x801143CC,0x16B -asm/non_matchings/code/z_parameter/func_80114978.s,func_80114978,0x80114978,0xA -asm/non_matchings/code/z_parameter/func_801149A0.s,func_801149A0,0x801149A0,0x3F -asm/non_matchings/code/z_parameter/func_80114A9C.s,func_80114A9C,0x80114A9C,0x3A -asm/non_matchings/code/z_parameter/func_80114B84.s,func_80114B84,0x80114B84,0x47 -asm/non_matchings/code/z_parameter/func_80114CA0.s,func_80114CA0,0x80114CA0,0x7C -asm/non_matchings/code/z_parameter/Interface_HasEmptyBottle.s,Interface_HasEmptyBottle,0x80114E90,0x27 -asm/non_matchings/code/z_parameter/Interface_HasItemInBottle.s,Interface_HasItemInBottle,0x80114F2C,0x29 -asm/non_matchings/code/z_parameter/func_80114FD0.s,func_80114FD0,0x80114FD0,0x58 -asm/non_matchings/code/z_parameter/func_80115130.s,func_80115130,0x80115130,0x62 -asm/non_matchings/code/z_parameter/func_801152B8.s,func_801152B8,0x801152B8,0x44 +asm/non_matchings/code/z_parameter/Item_CheckObtainabilityImpl.s,Item_CheckObtainabilityImpl,0x801143CC,0x16B +asm/non_matchings/code/z_parameter/Item_CheckObtainability.s,Item_CheckObtainability,0x80114978,0xA +asm/non_matchings/code/z_parameter/Inventory_DeleteItem.s,Inventory_DeleteItem,0x801149A0,0x3F +asm/non_matchings/code/z_parameter/Inventory_UnequipItem.s,Inventory_UnequipItem,0x80114A9C,0x3A +asm/non_matchings/code/z_parameter/Inventory_ReplaceItem.s,Inventory_ReplaceItem,0x80114B84,0x47 +asm/non_matchings/code/z_parameter/Inventory_UpdateDeitySwordEquip.s,Inventory_UpdateDeitySwordEquip,0x80114CA0,0x7C +asm/non_matchings/code/z_parameter/Inventory_HasEmptyBottle.s,Inventory_HasEmptyBottle,0x80114E90,0x27 +asm/non_matchings/code/z_parameter/Inventory_HasItemInBottle.s,Inventory_HasItemInBottle,0x80114F2C,0x29 +asm/non_matchings/code/z_parameter/Inventory_UpdateBottleItem.s,Inventory_UpdateBottleItem,0x80114FD0,0x58 +asm/non_matchings/code/z_parameter/Inventory_ConsumeFairy.s,Inventory_ConsumeFairy,0x80115130,0x62 +asm/non_matchings/code/z_parameter/Inventory_UpdateItem.s,Inventory_UpdateItem,0x801152B8,0x44 asm/non_matchings/code/z_parameter/func_801153C8.s,func_801153C8,0x801153C8,0x18 asm/non_matchings/code/z_parameter/func_80115428.s,func_80115428,0x80115428,0x41 asm/non_matchings/code/z_parameter/func_8011552C.s,func_8011552C,0x8011552C,0x22 asm/non_matchings/code/z_parameter/func_801155B4.s,func_801155B4,0x801155B4,0x6C asm/non_matchings/code/z_parameter/func_80115764.s,func_80115764,0x80115764,0x38 asm/non_matchings/code/z_parameter/func_80115844.s,func_80115844,0x80115844,0x31 -asm/non_matchings/code/z_parameter/func_80115908.s,func_80115908,0x80115908,0x2E -asm/non_matchings/code/z_parameter/func_801159c0.s,func_801159c0,0x801159C0,0xB -asm/non_matchings/code/z_parameter/func_801159EC.s,func_801159EC,0x801159EC,0xA -asm/non_matchings/code/z_parameter/func_80115A14.s,func_80115A14,0x80115A14,0xC0 +asm/non_matchings/code/z_parameter/Health_ChangeBy.s,Health_ChangeBy,0x80115908,0x2E +asm/non_matchings/code/z_parameter/Health_GiveHearts.s,Health_GiveHearts,0x801159C0,0xB +asm/non_matchings/code/z_parameter/Rupees_ChangeBy.s,Rupees_ChangeBy,0x801159EC,0xA +asm/non_matchings/code/z_parameter/Inventory_ChangeAmmo.s,Inventory_ChangeAmmo,0x80115A14,0xC0 asm/non_matchings/code/z_parameter/Parameter_AddMagic.s,Parameter_AddMagic,0x80115D14,0x12 asm/non_matchings/code/z_parameter/func_80115D5C.s,func_80115D5C,0x80115D5C,0x16 asm/non_matchings/code/z_parameter/func_80115DB4.s,func_80115DB4,0x80115DB4,0xB5 @@ -1696,29 +1696,29 @@ asm/non_matchings/code/z_player_lib/func_801229FC.s,func_801229FC,0x801229FC,0x6 asm/non_matchings/code/z_player_lib/func_80122BA4.s,func_80122BA4,0x80122BA4,0x1F asm/non_matchings/code/z_player_lib/func_80122C20.s,func_80122C20,0x80122C20,0x49 asm/non_matchings/code/z_player_lib/func_80122D44.s,func_80122D44,0x80122D44,0x65 -asm/non_matchings/code/z_player_lib/func_80122ED8.s,func_80122ED8,0x80122ED8,0x5 -asm/non_matchings/code/z_player_lib/func_80122EEC.s,func_80122EEC,0x80122EEC,0xF +asm/non_matchings/code/z_player_lib/Player_MaskIdToItemId.s,Player_MaskIdToItemId,0x80122ED8,0x5 +asm/non_matchings/code/z_player_lib/Player_GetCurMaskItemId.s,Player_GetCurMaskItemId,0x80122EEC,0xF asm/non_matchings/code/z_player_lib/func_80122F28.s,func_80122F28,0x80122F28,0x1D asm/non_matchings/code/z_player_lib/func_80122F9C.s,func_80122F9C,0x80122F9C,0xC asm/non_matchings/code/z_player_lib/func_80122FCC.s,func_80122FCC,0x80122FCC,0x10 asm/non_matchings/code/z_player_lib/func_8012300C.s,func_8012300C,0x8012300C,0x4 asm/non_matchings/code/z_player_lib/func_8012301C.s,func_8012301C,0x8012301C,0x49 asm/non_matchings/code/z_player_lib/func_80123140.s,func_80123140,0x80123140,0x86 -asm/non_matchings/code/z_player_lib/func_80123358.s,func_80123358,0x80123358,0x23 +asm/non_matchings/code/z_player_lib/Player_InBlockingCsMode.s,Player_InBlockingCsMode,0x80123358,0x23 asm/non_matchings/code/z_player_lib/Player_InCsMode.s,Player_InCsMode,0x801233E4,0xF asm/non_matchings/code/z_player_lib/func_80123420.s,func_80123420,0x80123420,0x5 asm/non_matchings/code/z_player_lib/func_80123434.s,func_80123434,0x80123434,0x5 asm/non_matchings/code/z_player_lib/func_80123448.s,func_80123448,0x80123448,0x1A -asm/non_matchings/code/z_player_lib/func_801234B0.s,func_801234B0,0x801234B0,0x9 +asm/non_matchings/code/z_player_lib/Player_IsGoronOrDeku.s,Player_IsGoronOrDeku,0x801234B0,0x9 asm/non_matchings/code/z_player_lib/func_801234D4.s,func_801234D4,0x801234D4,0x2F asm/non_matchings/code/z_player_lib/func_80123590.s,func_80123590,0x80123590,0x13 asm/non_matchings/code/z_player_lib/func_801235DC.s,func_801235DC,0x801235DC,0x1C asm/non_matchings/code/z_player_lib/func_8012364C.s,func_8012364C,0x8012364C,0x71 asm/non_matchings/code/z_player_lib/func_80123810.s,func_80123810,0x80123810,0x54 -asm/non_matchings/code/z_player_lib/func_80123960.s,func_80123960,0x80123960,0x13 +asm/non_matchings/code/z_player_lib/Player_ActionToModelGroup.s,Player_ActionToModelGroup,0x80123960,0x13 asm/non_matchings/code/z_player_lib/func_801239AC.s,func_801239AC,0x801239AC,0x3E -asm/non_matchings/code/z_player_lib/func_80123AA4.s,func_80123AA4,0x80123AA4,0x4C -asm/non_matchings/code/z_player_lib/func_80123BD4.s,func_80123BD4,0x80123BD4,0x21 +asm/non_matchings/code/z_player_lib/Player_SetModels.s,Player_SetModels,0x80123AA4,0x4C +asm/non_matchings/code/z_player_lib/Player_SetModelGroup.s,Player_SetModelGroup,0x80123BD4,0x21 asm/non_matchings/code/z_player_lib/func_80123C58.s,func_80123C58,0x80123C58,0xE asm/non_matchings/code/z_player_lib/Player_SetEquipmentData.s,Player_SetEquipmentData,0x80123C90,0x30 asm/non_matchings/code/z_player_lib/func_80123D50.s,func_80123D50,0x80123D50,0x15 @@ -1727,22 +1727,22 @@ asm/non_matchings/code/z_player_lib/func_80123DC0.s,func_80123DC0,0x80123DC0,0x3 asm/non_matchings/code/z_player_lib/func_80123E90.s,func_80123E90,0x80123E90,0x21 asm/non_matchings/code/z_player_lib/func_80123F14.s,func_80123F14,0x80123F14,0x6 asm/non_matchings/code/z_player_lib/func_80123F2C.s,func_80123F2C,0x80123F2C,0x7 -asm/non_matchings/code/z_player_lib/func_80123F48.s,func_80123F48,0x80123F48,0x36 -asm/non_matchings/code/z_player_lib/func_80124020.s,func_80124020,0x80124020,0x7 +asm/non_matchings/code/z_player_lib/Player_IsBurningStickInRange.s,Player_IsBurningStickInRange,0x80123F48,0x36 +asm/non_matchings/code/z_player_lib/Player_GetStrength.s,Player_GetStrength,0x80124020,0x7 asm/non_matchings/code/z_player_lib/Player_GetMask.s,Player_GetMask,0x8012403C,0x4 asm/non_matchings/code/z_player_lib/Player_RemoveMask.s,Player_RemoveMask,0x8012404C,0x4 -asm/non_matchings/code/z_player_lib/func_8012405C.s,func_8012405C,0x8012405C,0xB -asm/non_matchings/code/z_player_lib/func_80124088.s,func_80124088,0x80124088,0x10 -asm/non_matchings/code/z_player_lib/func_801240C8.s,func_801240C8,0x801240C8,0x5 +asm/non_matchings/code/z_player_lib/Player_HasMirrorShieldEquipped.s,Player_HasMirrorShieldEquipped,0x8012405C,0xB +asm/non_matchings/code/z_player_lib/Player_IsHoldingMirrorShield.s,Player_IsHoldingMirrorShield,0x80124088,0x10 +asm/non_matchings/code/z_player_lib/Player_IsHoldingHookshot.s,Player_IsHoldingHookshot,0x801240C8,0x5 asm/non_matchings/code/z_player_lib/func_801240DC.s,func_801240DC,0x801240DC,0xD asm/non_matchings/code/z_player_lib/func_80124110.s,func_80124110,0x80124110,0xE asm/non_matchings/code/z_player_lib/func_80124148.s,func_80124148,0x80124148,0x8 -asm/non_matchings/code/z_player_lib/func_80124168.s,func_80124168,0x80124168,0xA -asm/non_matchings/code/z_player_lib/func_80124190.s,func_80124190,0x80124190,0x9 -asm/non_matchings/code/z_player_lib/func_801241B4.s,func_801241B4,0x801241B4,0xB -asm/non_matchings/code/z_player_lib/func_801241E0.s,func_801241E0,0x801241E0,0xB -asm/non_matchings/code/z_player_lib/func_8012420C.s,func_8012420C,0x8012420C,0x8 -asm/non_matchings/code/z_player_lib/func_8012422C.s,func_8012422C,0x8012422C,0xB +asm/non_matchings/code/z_player_lib/Player_ActionToMeleeWeapon.s,Player_ActionToMeleeWeapon,0x80124168,0xA +asm/non_matchings/code/z_player_lib/Player_GetMeleeWeaponHeld.s,Player_GetMeleeWeaponHeld,0x80124190,0x9 +asm/non_matchings/code/z_player_lib/Player_IsHoldingTwoHandedWeapon.s,Player_IsHoldingTwoHandedWeapon,0x801241B4,0xB +asm/non_matchings/code/z_player_lib/Player_ActionToBottle.s,Player_ActionToBottle,0x801241E0,0xB +asm/non_matchings/code/z_player_lib/Player_GetBottleHeld.s,Player_GetBottleHeld,0x8012420C,0x8 +asm/non_matchings/code/z_player_lib/Player_ActionToExplosive.s,Player_ActionToExplosive,0x8012422C,0xB asm/non_matchings/code/z_player_lib/Player_GetExplosiveHeld.s,Player_GetExplosiveHeld,0x80124258,0x8 asm/non_matchings/code/z_player_lib/func_80124278.s,func_80124278,0x80124278,0xF asm/non_matchings/code/z_player_lib/func_801242B4.s,func_801242B4,0x801242B4,0xA @@ -1758,7 +1758,7 @@ asm/non_matchings/code/z_player_lib/func_801251C4.s,func_801251C4,0x801251C4,0x5 asm/non_matchings/code/z_player_lib/func_80125318.s,func_80125318,0x80125318,0xA asm/non_matchings/code/z_player_lib/func_80125340.s,func_80125340,0x80125340,0xB asm/non_matchings/code/z_player_lib/func_8012536C.s,func_8012536C,0x8012536C,0xE -asm/non_matchings/code/z_player_lib/func_801253A4.s,func_801253A4,0x801253A4,0x57 +asm/non_matchings/code/z_player_lib/Player_DrawZoraShield.s,Player_DrawZoraShield,0x801253A4,0x57 asm/non_matchings/code/z_player_lib/func_80125500.s,func_80125500,0x80125500,0x20 asm/non_matchings/code/z_player_lib/func_80125580.s,func_80125580,0x80125580,0x1D8 asm/non_matchings/code/z_player_lib/func_80125CE0.s,func_80125CE0,0x80125CE0,0x1B @@ -1768,15 +1768,15 @@ asm/non_matchings/code/z_player_lib/func_801263FC.s,func_801263FC,0x801263FC,0x1 asm/non_matchings/code/z_player_lib/func_80126440.s,func_80126440,0x80126440,0x62 asm/non_matchings/code/z_player_lib/func_801265C8.s,func_801265C8,0x801265C8,0x35 asm/non_matchings/code/z_player_lib/func_8012669C.s,func_8012669C,0x8012669C,0x5B -asm/non_matchings/code/z_player_lib/func_80126808.s,func_80126808,0x80126808,0x5D -asm/non_matchings/code/z_player_lib/func_8012697C.s,func_8012697C,0x8012697C,0x4E +asm/non_matchings/code/z_player_lib/Player_DrawGetItemImpl.s,Player_DrawGetItemImpl,0x80126808,0x5D +asm/non_matchings/code/z_player_lib/Player_DrawGetItem.s,Player_DrawGetItem,0x8012697C,0x4E asm/non_matchings/code/z_player_lib/func_80126AB4.s,func_80126AB4,0x80126AB4,0x36 asm/non_matchings/code/z_player_lib/func_80126B8C.s,func_80126B8C,0x80126B8C,0x11 asm/non_matchings/code/z_player_lib/func_80126BD0.s,func_80126BD0,0x80126BD0,0x178 asm/non_matchings/code/z_player_lib/func_801271B0.s,func_801271B0,0x801271B0,0xA2 asm/non_matchings/code/z_player_lib/func_80127438.s,func_80127438,0x80127438,0x14 asm/non_matchings/code/z_player_lib/func_80127488.s,func_80127488,0x80127488,0x31 -asm/non_matchings/code/z_player_lib/func_8012754C.s,func_8012754C,0x8012754C,0x12 +asm/non_matchings/code/z_player_lib/Player_DrawCouplesMask.s,Player_DrawCouplesMask,0x8012754C,0x12 asm/non_matchings/code/z_player_lib/func_80127594.s,func_80127594,0x80127594,0xD9 asm/non_matchings/code/z_player_lib/func_801278F8.s,func_801278F8,0x801278F8,0x5A asm/non_matchings/code/z_player_lib/func_80127A60.s,func_80127A60,0x80127A60,0x41 @@ -1970,8 +1970,8 @@ asm/non_matchings/code/z_scene/Scene_HeaderCmdSetAreaVisitedFlag.s,Scene_HeaderC asm/non_matchings/code/z_scene/Scene_HeaderCmdAnimatedMaterials.s,Scene_HeaderCmdAnimatedMaterials,0x80130674,0xC asm/non_matchings/code/z_scene/Scene_SetExitFade.s,Scene_SetExitFade,0x801306A4,0x11 asm/non_matchings/code/z_scene/Scene_ProcessHeader.s,Scene_ProcessHeader,0x801306E8,0x20 -asm/non_matchings/code/z_scene/Entrance_CreateIndex.s,Entrance_CreateIndex,0x80130768,0x7 -asm/non_matchings/code/z_scene/Entrance_CreateIndexFromSpawn.s,Entrance_CreateIndexFromSpawn,0x80130784,0xF +asm/non_matchings/code/z_scene/Entrance_Create.s,Entrance_Create,0x80130768,0x7 +asm/non_matchings/code/z_scene/Entrance_CreateFromSpawn.s,Entrance_CreateFromSpawn,0x80130784,0xF asm/non_matchings/code/z_scene_proc/Scene_ExecuteDrawConfig.s,Scene_ExecuteDrawConfig,0x801307C0,0xD asm/non_matchings/code/z_scene_proc/Scene_DrawConfigDefault.s,Scene_DrawConfigDefault,0x801307F4,0x10 asm/non_matchings/code/z_scene_proc/AnimatedMat_TexScroll.s,AnimatedMat_TexScroll,0x80130834,0x1B @@ -2172,29 +2172,29 @@ 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/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/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/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/SubS_ChangeAnimationByInfoS.s,SubS_ChangeAnimationByInfoS,0x8013BC6C,0x35 asm/non_matchings/code/z_sub_s/SubS_HasReachedPoint.s,SubS_HasReachedPoint,0x8013BD40,0x67 asm/non_matchings/code/z_sub_s/SubS_GetDayDependentPath.s,SubS_GetDayDependentPath,0x8013BEDC,0x63 -asm/non_matchings/code/z_sub_s/func_8013C068.s,func_8013C068,0x8013C068,0x16F -asm/non_matchings/code/z_sub_s/func_8013C624.s,func_8013C624,0x8013C624,0xA5 +asm/non_matchings/code/z_sub_s/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/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 @@ -2207,7 +2207,7 @@ asm/non_matchings/code/z_sub_s/SubS_FindActor.s,SubS_FindActor,0x8013D960,0x1A asm/non_matchings/code/z_sub_s/SubS_FillLimbRotTables.s,SubS_FillLimbRotTables,0x8013D9C8,0x72 asm/non_matchings/code/z_sub_s/SubS_IsFloorAbove.s,SubS_IsFloorAbove,0x8013DB90,0x2C asm/non_matchings/code/z_sub_s/SubS_CopyPointFromPathList.s,SubS_CopyPointFromPathList,0x8013DC40,0x23 -asm/non_matchings/code/z_sub_s/SubS_GetPathCount.s,SubS_GetPathCount,0x8013DCCC,0x5 +asm/non_matchings/code/z_sub_s/SubS_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 @@ -2217,22 +2217,22 @@ asm/non_matchings/code/z_sub_s/SubS_ActorPathing_SetNextPoint.s,SubS_ActorPathin asm/non_matchings/code/z_sub_s/SubS_ChangeAnimationBySpeedInfo.s,SubS_ChangeAnimationBySpeedInfo,0x8013E1C8,0x43 asm/non_matchings/code/z_sub_s/SubS_StartActorCutscene.s,SubS_StartActorCutscene,0x8013E2D4,0x39 asm/non_matchings/code/z_sub_s/SubS_FillCutscenesList.s,SubS_FillCutscenesList,0x8013E3B8,0x3E -asm/non_matchings/code/z_sub_s/func_8013E4B0.s,func_8013E4B0,0x8013E4B0,0x47 -asm/non_matchings/code/z_sub_s/func_8013E5CC.s,func_8013E5CC,0x8013E5CC,0x1D +asm/non_matchings/code/z_sub_s/SubS_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/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 -asm/non_matchings/code/code_8013EC10/func_8013ED9C.s,func_8013ED9C,0x8013ED9C,0xD -asm/non_matchings/code/code_8013EC10/func_8013EDD0.s,func_8013EDD0,0x8013EDD0,0xD -asm/non_matchings/code/code_8013EC10/func_8013EE04.s,func_8013EE04,0x8013EE04,0x8 -asm/non_matchings/code/code_8013EC10/func_8013EE24.s,func_8013EE24,0x8013EE24,0x5 -asm/non_matchings/code/code_8013EC10/func_8013EE38.s,func_8013EE38,0x8013EE38,0x4 -asm/non_matchings/code/code_8013EC10/func_8013EE48.s,func_8013EE48,0x8013EE48,0x6 +asm/non_matchings/code/z_sub_s/SubS_TrackPointStep.s,SubS_TrackPointStep,0x8013E950,0xB0 +asm/non_matchings/code/code_8013EC10/Rumble_Update.s,Rumble_Update,0x8013EC10,0xD +asm/non_matchings/code/code_8013EC10/Rumble_Override.s,Rumble_Override,0x8013EC44,0x27 +asm/non_matchings/code/code_8013EC10/Rumble_Request.s,Rumble_Request,0x8013ECE0,0x2F +asm/non_matchings/code/code_8013EC10/Rumble_Init.s,Rumble_Init,0x8013ED9C,0xD +asm/non_matchings/code/code_8013EC10/Rumble_Destroy.s,Rumble_Destroy,0x8013EDD0,0xD +asm/non_matchings/code/code_8013EC10/Rumble_ControllerOneHasRumblePak.s,Rumble_ControllerOneHasRumblePak,0x8013EE04,0x8 +asm/non_matchings/code/code_8013EC10/Rumble_StateReset.s,Rumble_StateReset,0x8013EE24,0x5 +asm/non_matchings/code/code_8013EC10/Rumble_StateWipeRequests.s,Rumble_StateWipeRequests,0x8013EE38,0x4 +asm/non_matchings/code/code_8013EC10/Rumble_SetUpdateEnabled.s,Rumble_SetUpdateEnabled,0x8013EE48,0x6 asm/non_matchings/code/z_view/View_ViewportToVp.s,View_ViewportToVp,0x8013EE60,0x25 asm/non_matchings/code/z_view/View_Init.s,View_Init,0x8013EEF4,0x2A asm/non_matchings/code/z_view/View_SetViewOrientation.s,View_SetViewOrientation,0x8013EF9C,0x2D @@ -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 @@ -2500,18 +2500,18 @@ asm/non_matchings/code/z_play/func_80165E7C.s,func_80165E7C,0x80165E7C,0x11 asm/non_matchings/code/z_play/func_80165EC0.s,func_80165EC0,0x80165EC0,0x68 asm/non_matchings/code/z_play/func_80166060.s,func_80166060,0x80166060,0x16 asm/non_matchings/code/z_play/func_801660B8.s,func_801660B8,0x801660B8,0x21 -asm/non_matchings/code/z_play/Play_Fini.s,Play_Fini,0x8016613C,0xA2 +asm/non_matchings/code/z_play/Play_Destroy.s,Play_Destroy,0x8016613C,0xA2 asm/non_matchings/code/z_play/func_801663C4.s,func_801663C4,0x801663C4,0xA0 asm/non_matchings/code/z_play/func_80166644.s,func_80166644,0x80166644,0x9C asm/non_matchings/code/z_play/func_801668B4.s,func_801668B4,0x801668B4,0x2D asm/non_matchings/code/z_play/func_80166968.s,func_80166968,0x80166968,0x72 asm/non_matchings/code/z_play/func_80166B30.s,func_80166B30,0x80166B30,0x339 -asm/non_matchings/code/z_play/func_80167814.s,func_80167814,0x80167814,0x174 +asm/non_matchings/code/z_play/Play_Update.s,Play_Update,0x80167814,0x174 asm/non_matchings/code/z_play/func_80167DE4.s,func_80167DE4,0x80167DE4,0x4A asm/non_matchings/code/z_play/func_80167F0C.s,func_80167F0C,0x80167F0C,0x61 asm/non_matchings/code/z_play/Play_Draw.s,Play_Draw,0x80168090,0x347 asm/non_matchings/code/z_play/func_80168DAC.s,func_80168DAC,0x80168DAC,0x6E -asm/non_matchings/code/z_play/Play_Update.s,Play_Update,0x80168F64,0x5A +asm/non_matchings/code/z_play/Play_Main.s,Play_Main,0x80168F64,0x5A asm/non_matchings/code/z_play/Play_InCsMode.s,Play_InCsMode,0x801690CC,0xD asm/non_matchings/code/z_play/func_80169100.s,func_80169100,0x80169100,0x3C asm/non_matchings/code/z_play/func_801691F0.s,func_801691F0,0x801691F0,0xC @@ -2519,25 +2519,25 @@ asm/non_matchings/code/z_play/Play_LoadScene.s,Play_LoadScene,0x80169220,0x17 asm/non_matchings/code/z_play/func_8016927C.s,func_8016927C,0x8016927C,0x12 asm/non_matchings/code/z_play/func_801692C4.s,func_801692C4,0x801692C4,0x44 asm/non_matchings/code/z_play/Play_SceneInit.s,Play_SceneInit,0x801693D4,0x28 -asm/non_matchings/code/z_play/func_80169474.s,func_80169474,0x80169474,0x1A +asm/non_matchings/code/z_play/Play_GetScreenPos.s,Play_GetScreenPos,0x80169474,0x1A asm/non_matchings/code/z_play/Play_CreateSubCamera.s,Play_CreateSubCamera,0x801694DC,0x2A asm/non_matchings/code/z_play/Play_GetActiveCamId.s,Play_GetActiveCamId,0x80169584,0x3 -asm/non_matchings/code/z_play/Play_CameraChangeStatus.s,Play_CameraChangeStatus,0x80169590,0x1C +asm/non_matchings/code/z_play/Play_ChangeCameraStatus.s,Play_ChangeCameraStatus,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/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_SetCameraAtEye.s,Play_SetCameraAtEye,0x8016970C,0x44 +asm/non_matchings/code/z_play/Play_SetCameraAtEyeUp.s,Play_SetCameraAtEyeUp,0x8016981C,0x49 +asm/non_matchings/code/z_play/Play_SetCameraFov.s,Play_SetCameraFov,0x80169940,0x12 +asm/non_matchings/code/z_play/Play_SetCameraRoll.s,Play_SetCameraRoll,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/Play_CameraChangeSetting.s,Play_CameraChangeSetting,0x80169AC0,0xF +asm/non_matchings/code/z_play/Play_ChangeCameraSetting.s,Play_ChangeCameraSetting,0x80169AC0,0xF asm/non_matchings/code/z_play/func_80169AFC.s,func_80169AFC,0x80169AFC,0x32 -asm/non_matchings/code/z_play/Play_CameraGetUID.s,Play_CameraGetUID,0x80169BC4,0xD +asm/non_matchings/code/z_play/Play_GetCameraUID.s,Play_GetCameraUID,0x80169BC4,0xD asm/non_matchings/code/z_play/func_80169BF8.s,func_80169BF8,0x80169BF8,0x1B -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_GetActorCsCamSetting.s,Play_GetActorCsCamSetting,0x80169C64,0x8 +asm/non_matchings/code/z_play/Play_GetActorCsCamFuncData.s,Play_GetActorCsCamFuncData,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 @@ -2550,7 +2550,7 @@ 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/Play_IsUnderwater.s,Play_IsUnderwater,0x8016A0AC,0x2F -asm/non_matchings/code/z_play/func_8016A168.s,func_8016A168,0x8016A168,0x4 +asm/non_matchings/code/z_play/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 @@ -2623,7 +2623,7 @@ asm/non_matchings/code/TwoHeadArena/THA_IsCrash.s,THA_IsCrash,0x80172B18,0x9 asm/non_matchings/code/TwoHeadArena/THA_Init.s,THA_Init,0x80172B3C,0x7 asm/non_matchings/code/TwoHeadArena/THA_Ct.s,THA_Ct,0x80172B58,0x11 asm/non_matchings/code/TwoHeadArena/THA_Dt.s,THA_Dt,0x80172B9C,0x9 -asm/non_matchings/code/code_80172BC0/func_80172BC0.s,func_80172BC0,0x80172BC0,0x1C +asm/non_matchings/code/code_80172BC0/AudioMgr_StopAllSfxExceptSystem.s,AudioMgr_StopAllSfxExceptSystem,0x80172BC0,0x1C asm/non_matchings/code/audioMgr/func_80172C30.s,func_80172C30,0x80172C30,0xE asm/non_matchings/code/audioMgr/AudioMgr_HandleRetrace.s,AudioMgr_HandleRetrace,0x80172C68,0x91 asm/non_matchings/code/audioMgr/AudioMgr_HandlePRENMI.s,AudioMgr_HandlePRENMI,0x80172EAC,0x9 @@ -2693,8 +2693,8 @@ asm/non_matchings/code/padmgr/func_801750FC.s,func_801750FC,0x801750FC,0x9A asm/non_matchings/code/padmgr/func_80175364.s,func_80175364,0x80175364,0x34 asm/non_matchings/code/padmgr/func_80175434.s,func_80175434,0x80175434,0x6 asm/non_matchings/code/padmgr/func_8017544C.s,func_8017544C,0x8017544C,0xA -asm/non_matchings/code/padmgr/func_80175474.s,func_80175474,0x80175474,0x13 -asm/non_matchings/code/padmgr/func_801754C0.s,func_801754C0,0x801754C0,0x8 +asm/non_matchings/code/padmgr/PadMgr_RumbleSet.s,PadMgr_RumbleSet,0x80175474,0x13 +asm/non_matchings/code/padmgr/PadMgr_ControllerHasRumblePak.s,PadMgr_ControllerHasRumblePak,0x801754C0,0x8 asm/non_matchings/code/padmgr/Padmgr_CalcStickEdges.s,Padmgr_CalcStickEdges,0x801754E0,0xB1 asm/non_matchings/code/padmgr/Padmgr_ParseState.s,Padmgr_ParseState,0x801757A4,0x86 asm/non_matchings/code/padmgr/func_801759BC.s,func_801759BC,0x801759BC,0x49 @@ -2868,52 +2868,52 @@ 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 asm/non_matchings/code/sys_ucode/SysUcode_GetUCodeData.s,SysUcode_GetUCodeData,0x80182CCC,0x5 -asm/non_matchings/code/sys_ucode/func_80182CE0.s,func_80182CE0,0x80182CE0,0xD0 -asm/non_matchings/code/sys_ucode/func_80183020.s,func_80183020,0x80183020,0xE -asm/non_matchings/code/sys_ucode/func_80183058.s,func_80183058,0x80183058,0x6 +asm/non_matchings/code/sys_ucode/RumbleManager_Update.s,RumbleManager_Update,0x80182CE0,0xD0 +asm/non_matchings/code/sys_ucode/RumbleManager_Init.s,RumbleManager_Init,0x80183020,0xE +asm/non_matchings/code/sys_ucode/RumbleManager_Destroy.s,RumbleManager_Destroy,0x80183058,0x6 asm/non_matchings/code/code_80183070/func_80183070.s,func_80183070,0x80183070,0xC asm/non_matchings/code/c_keyframe/func_801830A0.s,func_801830A0,0x801830A0,0xA asm/non_matchings/code/c_keyframe/func_801830C8.s,func_801830C8,0x801830C8,0x8 @@ -3204,10 +3204,10 @@ asm/non_matchings/code/code_80192BE0/func_8019372C.s,func_8019372C,0x8019372C,0x asm/non_matchings/code/code_80192BE0/func_80193774.s,func_80193774,0x80193774,0x26 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/Audio_QueueCmdS8.s,Audio_QueueCmdS8,0x801938A0,0xC +asm/non_matchings/code/code_80192BE0/AudioThread_QueueCmdS32.s,AudioThread_QueueCmdS32,0x8019387C,0x9 +asm/non_matchings/code/code_80192BE0/AudioThread_QueueCmdS8.s,AudioThread_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/AudioThread_ScheduleProcessCmds.s,AudioThread_ScheduleProcessCmds,0x80193900,0x24 asm/non_matchings/code/code_80192BE0/func_80193990.s,func_80193990,0x80193990,0x6 asm/non_matchings/code/code_80192BE0/func_801939A8.s,func_801939A8,0x801939A8,0x51 asm/non_matchings/code/code_80192BE0/func_80193AEC.s,func_80193AEC,0x80193AEC,0x2D @@ -3234,11 +3234,11 @@ 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/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_80192BE0/AudioThread_NextRandom.s,AudioThread_NextRandom,0x80194668,0x1F +asm/non_matchings/code/code_80192BE0/AudioThread_InitMesgQueues.s,AudioThread_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 +asm/non_matchings/code/code_80194710/osAiSetNextBuffer.s,osAiSetNextBuffer,0x80194790,0x1D asm/non_matchings/code/code_80194710/func_80194804.s,func_80194804,0x80194804,0xF asm/non_matchings/code/code_80194710/func_80194840.s,func_80194840,0x80194840,0x1C asm/non_matchings/code/code_80194710/func_801948B0.s,func_801948B0,0x801948B0,0x20 @@ -3283,90 +3283,90 @@ asm/non_matchings/code/audio_effects/AudioEffects_NoteVibratoInit.s,AudioEffects asm/non_matchings/code/audio_effects/AudioEffects_NotePortamentoInit.s,AudioEffects_NotePortamentoInit,0x80197138,0xB asm/non_matchings/code/audio_effects/AudioEffects_AdsrInit.s,AudioEffects_AdsrInit,0x80197164,0x9 asm/non_matchings/code/audio_effects/AudioEffects_AdsrUpdate.s,AudioEffects_AdsrUpdate,0x80197188,0xD2 -asm/non_matchings/code/audio_seqplayer/func_801974D0.s,func_801974D0,0x801974D0,0x1A -asm/non_matchings/code/audio_seqplayer/func_80197538.s,func_80197538,0x80197538,0x77 -asm/non_matchings/code/audio_seqplayer/func_80197714.s,func_80197714,0x80197714,0x5B -asm/non_matchings/code/audio_seqplayer/func_80197880.s,func_80197880,0x80197880,0x56 -asm/non_matchings/code/audio_seqplayer/func_801979D8.s,func_801979D8,0x801979D8,0x1F -asm/non_matchings/code/audio_seqplayer/func_80197A54.s,func_80197A54,0x80197A54,0x14 +asm/non_matchings/code/audio_seqplayer/AudioSeq_GetScriptControlFlowArgument.s,AudioSeq_GetScriptControlFlowArgument,0x801974D0,0x1A +asm/non_matchings/code/audio_seqplayer/AudioSeq_HandleScriptFlowControl.s,AudioSeq_HandleScriptFlowControl,0x80197538,0x77 +asm/non_matchings/code/audio_seqplayer/AudioSeq_InitSequenceChannel.s,AudioSeq_InitSequenceChannel,0x80197714,0x5B +asm/non_matchings/code/audio_seqplayer/AudioSeq_SeqChannelSetLayer.s,AudioSeq_SeqChannelSetLayer,0x80197880,0x56 +asm/non_matchings/code/audio_seqplayer/AudioSeq_SeqLayerDisable.s,AudioSeq_SeqLayerDisable,0x801979D8,0x1F +asm/non_matchings/code/audio_seqplayer/AudioSeq_SeqLayerFree.s,AudioSeq_SeqLayerFree,0x80197A54,0x14 asm/non_matchings/code/audio_seqplayer/AudioSeq_SequenceChannelDisable.s,AudioSeq_SequenceChannelDisable,0x80197AA4,0x1C -asm/non_matchings/code/audio_seqplayer/func_80197B14.s,func_80197B14,0x80197B14,0x3E -asm/non_matchings/code/audio_seqplayer/func_80197C0C.s,func_80197C0C,0x80197C0C,0x20 -asm/non_matchings/code/audio_seqplayer/func_80197C8C.s,func_80197C8C,0x80197C8C,0x26 +asm/non_matchings/code/audio_seqplayer/AudioSeq_SequencePlayerSetupChannels.s,AudioSeq_SequencePlayerSetupChannels,0x80197B14,0x3E +asm/non_matchings/code/audio_seqplayer/AudioSeq_SequencePlayerDisableChannels.s,AudioSeq_SequencePlayerDisableChannels,0x80197C0C,0x20 +asm/non_matchings/code/audio_seqplayer/AudioSeq_SequenceChannelEnable.s,AudioSeq_SequenceChannelEnable,0x80197C8C,0x26 asm/non_matchings/code/audio_seqplayer/AudioSeq_SequencePlayerDisableAsFinished.s,AudioSeq_SequencePlayerDisableAsFinished,0x80197D24,0xA asm/non_matchings/code/audio_seqplayer/AudioSeq_SequencePlayerDisable.s,AudioSeq_SequencePlayerDisable,0x80197D4C,0x2F asm/non_matchings/code/audio_seqplayer/AudioSeq_AudioListPushBack.s,AudioSeq_AudioListPushBack,0x80197E08,0x10 asm/non_matchings/code/audio_seqplayer/AudioSeq_AudioListPopBack.s,AudioSeq_AudioListPopBack,0x80197E48,0x10 -asm/non_matchings/code/audio_seqplayer/func_80197E88.s,func_80197E88,0x80197E88,0x28 -asm/non_matchings/code/audio_seqplayer/func_80197F28.s,func_80197F28,0x80197F28,0x5 -asm/non_matchings/code/audio_seqplayer/func_80197F3C.s,func_80197F3C,0x80197F3C,0xE -asm/non_matchings/code/audio_seqplayer/func_80197F74.s,func_80197F74,0x80197F74,0x10 -asm/non_matchings/code/audio_seqplayer/func_80197FB4.s,func_80197FB4,0x80197FB4,0x47 -asm/non_matchings/code/audio_seqplayer/func_801980D0.s,func_801980D0,0x801980D0,0x23 -asm/non_matchings/code/audio_seqplayer/func_8019815C.s,func_8019815C,0x8019815C,0x40 -asm/non_matchings/code/audio_seqplayer/func_8019825C.s,func_8019825C,0x8019825C,0xF9 -asm/non_matchings/code/audio_seqplayer/func_80198640.s,func_80198640,0x80198640,0x1A8 -asm/non_matchings/code/audio_seqplayer/func_80198CE0.s,func_80198CE0,0x80198CE0,0x105 -asm/non_matchings/code/audio_seqplayer/func_801990F4.s,func_801990F4,0x801990F4,0xC -asm/non_matchings/code/audio_seqplayer/func_80199124.s,func_80199124,0x80199124,0x1D -asm/non_matchings/code/audio_seqplayer/func_80199198.s,func_80199198,0x80199198,0x2B -asm/non_matchings/code/audio_seqplayer/func_80199244.s,func_80199244,0x80199244,0x9 -asm/non_matchings/code/audio_seqplayer/func_80199268.s,func_80199268,0x80199268,0x395 -asm/non_matchings/code/audio_seqplayer/func_8019A0BC.s,func_8019A0BC,0x8019A0BC,0x260 -asm/non_matchings/code/audio_seqplayer/func_8019AA3C.s,func_8019AA3C,0x8019AA3C,0x2D -asm/non_matchings/code/audio_seqplayer/func_8019AAF0.s,func_8019AAF0,0x8019AAF0,0x14 +asm/non_matchings/code/audio_seqplayer/AudioSeq_InitLayerFreelist.s,AudioSeq_InitLayerFreelist,0x80197E88,0x28 +asm/non_matchings/code/audio_seqplayer/AudioSeq_ScriptReadU8.s,AudioSeq_ScriptReadU8,0x80197F28,0x5 +asm/non_matchings/code/audio_seqplayer/AudioSeq_ScriptReadS16.s,AudioSeq_ScriptReadS16,0x80197F3C,0xE +asm/non_matchings/code/audio_seqplayer/AudioSeq_ScriptReadCompressedU16.s,AudioSeq_ScriptReadCompressedU16,0x80197F74,0x10 +asm/non_matchings/code/audio_seqplayer/AudioSeq_SeqLayerProcessScript.s,AudioSeq_SeqLayerProcessScript,0x80197FB4,0x47 +asm/non_matchings/code/audio_seqplayer/AudioSeq_SeqLayerProcessScriptStep1.s,AudioSeq_SeqLayerProcessScriptStep1,0x801980D0,0x23 +asm/non_matchings/code/audio_seqplayer/AudioSeq_SeqLayerProcessScriptStep5.s,AudioSeq_SeqLayerProcessScriptStep5,0x8019815C,0x40 +asm/non_matchings/code/audio_seqplayer/AudioSeq_SeqLayerProcessScriptStep2.s,AudioSeq_SeqLayerProcessScriptStep2,0x8019825C,0xF9 +asm/non_matchings/code/audio_seqplayer/AudioSeq_SeqLayerProcessScriptStep4.s,AudioSeq_SeqLayerProcessScriptStep4,0x80198640,0x1A8 +asm/non_matchings/code/audio_seqplayer/AudioSeq_SeqLayerProcessScriptStep3.s,AudioSeq_SeqLayerProcessScriptStep3,0x80198CE0,0x105 +asm/non_matchings/code/audio_seqplayer/AudioSeq_SetChannelPriorities.s,AudioSeq_SetChannelPriorities,0x801990F4,0xC +asm/non_matchings/code/audio_seqplayer/AudioSeq_GetInstrument.s,AudioSeq_GetInstrument,0x80199124,0x1D +asm/non_matchings/code/audio_seqplayer/AudioSeq_SetInstrument.s,AudioSeq_SetInstrument,0x80199198,0x2B +asm/non_matchings/code/audio_seqplayer/AudioSeq_SequenceChannelSetVolume.s,AudioSeq_SequenceChannelSetVolume,0x80199244,0x9 +asm/non_matchings/code/audio_seqplayer/AudioSeq_SequenceChannelProcessScript.s,AudioSeq_SequenceChannelProcessScript,0x80199268,0x395 +asm/non_matchings/code/audio_seqplayer/AudioSeq_SequencePlayerProcessSequence.s,AudioSeq_SequencePlayerProcessSequence,0x8019A0BC,0x260 +asm/non_matchings/code/audio_seqplayer/AudioSeq_ProcessSequences.s,AudioSeq_ProcessSequences,0x8019AA3C,0x2D +asm/non_matchings/code/audio_seqplayer/AudioSeq_SkipForwardSequence.s,AudioSeq_SkipForwardSequence,0x8019AAF0,0x14 asm/non_matchings/code/audio_seqplayer/AudioSeq_ResetSequencePlayer.s,AudioSeq_ResetSequencePlayer,0x8019AB40,0x34 asm/non_matchings/code/audio_seqplayer/AudioSeq_InitSequencePlayerChannels.s,AudioSeq_InitSequencePlayerChannels,0x8019AC10,0x37 -asm/non_matchings/code/audio_seqplayer/func_8019ACEC.s,func_8019ACEC,0x8019ACEC,0x34 +asm/non_matchings/code/audio_seqplayer/AudioSeq_InitSequencePlayer.s,AudioSeq_InitSequencePlayer,0x8019ACEC,0x34 asm/non_matchings/code/audio_seqplayer/AudioSeq_InitSequencePlayers.s,AudioSeq_InitSequencePlayers,0x8019ADBC,0x21 asm/non_matchings/code/code_8019AE40/func_8019AE40.s,func_8019AE40,0x8019AE40,0x1C asm/non_matchings/code/code_8019AEC0/func_8019AEC0.s,func_8019AEC0,0x8019AEC0,0x10 -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/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/AudioOcarina_ReadControllerInput.s,AudioOcarina_ReadControllerInput,0x8019AF00,0x16 +asm/non_matchings/code/code_8019AF00/AudioOcarina_BendPitchTwoSemitones.s,AudioOcarina_BendPitchTwoSemitones,0x8019AF58,0x24 +asm/non_matchings/code/code_8019AF00/AudioOcarina_GetPlayingState.s,AudioOcarina_GetPlayingState,0x8019AFE8,0x11 +asm/non_matchings/code/code_8019AF00/AudioOcarina_MapPitchToButton.s,AudioOcarina_MapPitchToButton,0x8019B02C,0x12 +asm/non_matchings/code/code_8019AF00/AudioOcarina_MapSongFromPitchToButton.s,AudioOcarina_MapSongFromPitchToButton,0x8019B074,0x34 +asm/non_matchings/code/code_8019AF00/AudioOcarina_Start.s,AudioOcarina_Start,0x8019B144,0x8D +asm/non_matchings/code/code_8019AF00/AudioOcarina_SetSongStartingPos.s,AudioOcarina_SetSongStartingPos,0x8019B378,0x5 +asm/non_matchings/code/code_8019AF00/AudioOcarina_StartAtSongStartingPos.s,AudioOcarina_StartAtSongStartingPos,0x8019B38C,0x11 +asm/non_matchings/code/code_8019AF00/AudioOcarina_StartForSongCheck.s,AudioOcarina_StartForSongCheck,0x8019B3D0,0x3A +asm/non_matchings/code/code_8019AF00/AudioOcarina_StartWithSongNoteLengths.s,AudioOcarina_StartWithSongNoteLengths,0x8019B4B8,0x23 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 -asm/non_matchings/code/code_8019AF00/func_8019B618.s,func_8019B618,0x8019B618,0xF -asm/non_matchings/code/code_8019AF00/func_8019B654.s,func_8019B654,0x8019B654,0x18 -asm/non_matchings/code/code_8019AF00/func_8019B6B4.s,func_8019B6B4,0x8019B6B4,0x164 -asm/non_matchings/code/code_8019AF00/func_8019BC44.s,func_8019BC44,0x8019BC44,0x95 -asm/non_matchings/code/code_8019AF00/func_8019BE98.s,func_8019BE98,0x8019BE98,0xCA -asm/non_matchings/code/code_8019AF00/func_8019C1C0.s,func_8019C1C0,0x8019C1C0,0x4 -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/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 -asm/non_matchings/code/code_8019AF00/func_8019CD08.s,func_8019CD08,0x8019CD08,0x4B -asm/non_matchings/code/code_8019AF00/func_8019CE34.s,func_8019CE34,0x8019CE34,0xE -asm/non_matchings/code/code_8019AF00/func_8019CE6C.s,func_8019CE6C,0x8019CE6C,0x14 -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/AudioOcarina_CheckIfStartedSong.s,AudioOcarina_CheckIfStartedSong,0x8019B618,0xF +asm/non_matchings/code/code_8019AF00/AudioOcarina_UpdateCurOcarinaSong.s,AudioOcarina_UpdateCurOcarinaSong,0x8019B654,0x18 +asm/non_matchings/code/code_8019AF00/AudioOcarina_CheckSongsWithMusicStaff.s,AudioOcarina_CheckSongsWithMusicStaff,0x8019B6B4,0x164 +asm/non_matchings/code/code_8019AF00/AudioOcarina_CheckSongsWithoutMusicStaff.s,AudioOcarina_CheckSongsWithoutMusicStaff,0x8019BC44,0x95 +asm/non_matchings/code/code_8019AF00/AudioOcarina_PlayControllerInput.s,AudioOcarina_PlayControllerInput,0x8019BE98,0xCA +asm/non_matchings/code/code_8019AF00/AudioOcarina_EnableInput.s,AudioOcarina_EnableInput,0x8019C1C0,0x4 +asm/non_matchings/code/code_8019AF00/AudioOcarina_ResetAndMute.s,AudioOcarina_ResetAndMute,0x8019C1D0,0x26 +asm/non_matchings/code/code_8019AF00/AudioOcarina_ResetAndReadInput.s,AudioOcarina_ResetAndReadInput,0x8019C268,0x1F +asm/non_matchings/code/code_8019AF00/AudioOcarina_SetOcarinaDisableTimer.s,AudioOcarina_SetOcarinaDisableTimer,0x8019C2E4,0x7 +asm/non_matchings/code/code_8019AF00/AudioOcarina_SetInstrument.s,AudioOcarina_SetInstrument,0x8019C300,0x26 +asm/non_matchings/code/code_8019AF00/AudioOcarina_SetPlaybackSong.s,AudioOcarina_SetPlaybackSong,0x8019C398,0x82 +asm/non_matchings/code/code_8019AF00/AudioOcarina_PlaybackSong.s,AudioOcarina_PlaybackSong,0x8019C5A0,0xCE +asm/non_matchings/code/code_8019AF00/AudioOcarina_SetRecordingSong.s,AudioOcarina_SetRecordingSong,0x8019C8D8,0x10C +asm/non_matchings/code/code_8019AF00/AudioOcarina_SetRecordingState.s,AudioOcarina_SetRecordingState,0x8019CD08,0x4B +asm/non_matchings/code/code_8019AF00/AudioOcarina_UpdateRecordingStaff.s,AudioOcarina_UpdateRecordingStaff,0x8019CE34,0xE +asm/non_matchings/code/code_8019AF00/AudioOcarina_UpdatePlayingStaff.s,AudioOcarina_UpdatePlayingStaff,0x8019CE6C,0x14 +asm/non_matchings/code/code_8019AF00/AudioOcarina_UpdatePlaybackStaff.s,AudioOcarina_UpdatePlaybackStaff,0x8019CEBC,0x2C +asm/non_matchings/code/code_8019AF00/AudioOcarina_GetRecordingStaff.s,AudioOcarina_GetRecordingStaff,0x8019CF6C,0x3 +asm/non_matchings/code/code_8019AF00/AudioOcarina_GetPlayingStaff.s,AudioOcarina_GetPlayingStaff,0x8019CF78,0x9 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/AudioOcarina_RecordSong.s,AudioOcarina_RecordSong,0x8019CFA8,0x63 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 -asm/non_matchings/code/code_8019AF00/func_8019D8B4.s,func_8019D8B4,0x8019D8B4,0xC -asm/non_matchings/code/code_8019AF00/func_8019D8E4.s,func_8019D8E4,0x8019D8E4,0x191 -asm/non_matchings/code/code_8019AF00/func_8019DF28.s,func_8019DF28,0x8019DF28,0xF -asm/non_matchings/code/code_8019AF00/func_8019DF64.s,func_8019DF64,0x8019DF64,0x25 +asm/non_matchings/code/code_8019AF00/AudioOcarina_MemoryGameInit.s,AudioOcarina_MemoryGameInit,0x8019D488,0x1C +asm/non_matchings/code/code_8019AF00/AudioOcarina_MemoryGameNextNote.s,AudioOcarina_MemoryGameNextNote,0x8019D4F8,0x42 +asm/non_matchings/code/code_8019AF00/AudioOcarina_Update.s,AudioOcarina_Update,0x8019D600,0x56 +asm/non_matchings/code/code_8019AF00/AudioOcarina_PlayLongScarecrowAfterCredits.s,AudioOcarina_PlayLongScarecrowAfterCredits,0x8019D758,0x43 +asm/non_matchings/code/code_8019AF00/AudioOcarina_SetCustomSequence.s,AudioOcarina_SetCustomSequence,0x8019D864,0x14 +asm/non_matchings/code/code_8019AF00/AudioOcarina_PlayCustomSequence.s,AudioOcarina_PlayCustomSequence,0x8019D8B4,0xC +asm/non_matchings/code/code_8019AF00/AudioOcarina_CreateCustomSequence.s,AudioOcarina_CreateCustomSequence,0x8019D8E4,0x191 +asm/non_matchings/code/code_8019AF00/AudioOcarina_ResetInstrument.s,AudioOcarina_ResetInstrument,0x8019DF28,0xF +asm/non_matchings/code/code_8019AF00/AudioOcarina_ResetStaffs.s,AudioOcarina_ResetStaffs,0x8019DF64,0x25 asm/non_matchings/code/code_8019AF00/func_8019DFF8.s,func_8019DFF8,0x8019DFF8,0x2 asm/non_matchings/code/code_8019AF00/func_8019E000.s,func_8019E000,0x8019E000,0x3 asm/non_matchings/code/code_8019AF00/func_8019E00C.s,func_8019E00C,0x8019E00C,0x2 @@ -3374,27 +3374,27 @@ asm/non_matchings/code/code_8019AF00/func_8019E014.s,func_8019E014,0x8019E014,0x asm/non_matchings/code/code_8019AF00/func_8019E0FC.s,func_8019E0FC,0x8019E0FC,0x2 asm/non_matchings/code/code_8019AF00/func_8019E104.s,func_8019E104,0x8019E104,0x3 asm/non_matchings/code/code_8019AF00/func_8019E110.s,func_8019E110,0x8019E110,0xF -asm/non_matchings/code/code_8019AF00/func_8019E14C.s,func_8019E14C,0x8019E14C,0x76 -asm/non_matchings/code/code_8019AF00/func_8019E324.s,func_8019E324,0x8019E324,0x63 -asm/non_matchings/code/code_8019AF00/func_8019E4B0.s,func_8019E4B0,0x8019E4B0,0x61 -asm/non_matchings/code/code_8019AF00/func_8019E634.s,func_8019E634,0x8019E634,0x8C -asm/non_matchings/code/code_8019AF00/func_8019E864.s,func_8019E864,0x8019E864,0x77 -asm/non_matchings/code/code_8019AF00/func_8019EA40.s,func_8019EA40,0x8019EA40,0x3B -asm/non_matchings/code/code_8019AF00/func_8019EB2C.s,func_8019EB2C,0x8019EB2C,0x13E -asm/non_matchings/code/code_8019AF00/func_8019F024.s,func_8019F024,0x8019F024,0xE -asm/non_matchings/code/code_8019AF00/func_8019F05C.s,func_8019F05C,0x8019F05C,0x1B +asm/non_matchings/code/code_8019AF00/AudioSfx_ComputeVolume.s,AudioSfx_ComputeVolume,0x8019E14C,0x76 +asm/non_matchings/code/code_8019AF00/AudioSfx_ComputeReverb.s,AudioSfx_ComputeReverb,0x8019E324,0x63 +asm/non_matchings/code/code_8019AF00/AudioSfx_ComputePanSigned.s,AudioSfx_ComputePanSigned,0x8019E4B0,0x61 +asm/non_matchings/code/code_8019AF00/AudioSfx_ComputeFreqScale.s,AudioSfx_ComputeFreqScale,0x8019E634,0x8C +asm/non_matchings/code/code_8019AF00/AudioSfx_ComputeSurroundSoundFilter.s,AudioSfx_ComputeSurroundSoundFilter,0x8019E864,0x77 +asm/non_matchings/code/code_8019AF00/AudioSfx_ComputeCombFilter.s,AudioSfx_ComputeCombFilter,0x8019EA40,0x3B +asm/non_matchings/code/code_8019AF00/AudioSfx_SetProperties.s,AudioSfx_SetProperties,0x8019EB2C,0x13E +asm/non_matchings/code/code_8019AF00/AudioSfx_SetFreqAndStereoBits.s,AudioSfx_SetFreqAndStereoBits,0x8019F024,0xE +asm/non_matchings/code/code_8019AF00/AudioSfx_ResetSfxChannelState.s,AudioSfx_ResetSfxChannelState,0x8019F05C,0x1B asm/non_matchings/code/code_8019AF00/play_sound.s,play_sound,0x8019F0C8,0x18 asm/non_matchings/code/code_8019AF00/func_8019F128.s,func_8019F128,0x8019F128,0x12 asm/non_matchings/code/code_8019AF00/func_8019F170.s,func_8019F170,0x8019F170,0x14 asm/non_matchings/code/code_8019AF00/Audio_PlaySfxAtPos.s,Audio_PlaySfxAtPos,0x8019F1C0,0x12 asm/non_matchings/code/code_8019AF00/func_8019F208.s,func_8019F208,0x8019F208,0xA asm/non_matchings/code/code_8019AF00/func_8019F230.s,func_8019F230,0x8019F230,0xA -asm/non_matchings/code/code_8019AF00/func_8019F258.s,func_8019F258,0x8019F258,0x2A -asm/non_matchings/code/code_8019AF00/func_8019F300.s,func_8019F300,0x8019F300,0x48 +asm/non_matchings/code/code_8019AF00/AudioSfx_AddSfxSetting.s,AudioSfx_AddSfxSetting,0x8019F258,0x2A +asm/non_matchings/code/code_8019AF00/AudioSfx_ProcessSfxSettings.s,AudioSfx_ProcessSfxSettings,0x8019F300,0x48 asm/non_matchings/code/code_8019AF00/func_8019F420.s,func_8019F420,0x8019F420,0x23 asm/non_matchings/code/code_8019AF00/func_8019F4AC.s,func_8019F4AC,0x8019F4AC,0x25 asm/non_matchings/code/code_8019AF00/func_8019F540.s,func_8019F540,0x8019F540,0xC -asm/non_matchings/code/code_8019AF00/func_8019F570.s,func_8019F570,0x8019F570,0xF +asm/non_matchings/code/code_8019AF00/AudioSfx_LowerSfxSettingsReverb.s,AudioSfx_LowerSfxSettingsReverb,0x8019F570,0xF asm/non_matchings/code/code_8019AF00/func_8019F5AC.s,func_8019F5AC,0x8019F5AC,0x23 asm/non_matchings/code/code_8019AF00/func_8019F638.s,func_8019F638,0x8019F638,0x52 asm/non_matchings/code/code_8019AF00/func_8019F780.s,func_8019F780,0x8019F780,0x16 @@ -3428,7 +3428,7 @@ asm/non_matchings/code/code_8019AF00/Audio_UpdateRiverSoundVolumes.s,Audio_Updat 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 -asm/non_matchings/code/code_8019AF00/func_801A0654.s,func_801A0654,0x801A0654,0x6F +asm/non_matchings/code/code_8019AF00/AudioSfx_SetChannelIO.s,AudioSfx_SetChannelIO,0x801A0654,0x6F 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 @@ -3506,7 +3506,7 @@ asm/non_matchings/code/code_8019AF00/func_801A429C.s,func_801A429C,0x801A429C,0x asm/non_matchings/code/code_8019AF00/func_801A42C8.s,func_801A42C8,0x801A42C8,0x17 asm/non_matchings/code/code_8019AF00/func_801A4324.s,func_801A4324,0x801A4324,0x9 asm/non_matchings/code/code_8019AF00/func_801A4348.s,func_801A4348,0x801A4348,0xE -asm/non_matchings/code/code_8019AF00/func_801A4380.s,func_801A4380,0x801A4380,0x2A +asm/non_matchings/code/code_8019AF00/Audio_SetSfxVolumeExceptSystemAndOcarinaBanks.s,Audio_SetSfxVolumeExceptSystemAndOcarinaBanks,0x801A4380,0x2A asm/non_matchings/code/code_8019AF00/func_801A4428.s,func_801A4428,0x801A4428,0x1F asm/non_matchings/code/code_8019AF00/Audio_PreNMI.s,Audio_PreNMI,0x801A44A4,0x8 asm/non_matchings/code/code_8019AF00/func_801A44C4.s,func_801A44C4,0x801A44C4,0x4 @@ -3517,9 +3517,9 @@ asm/non_matchings/code/code_8019AF00/func_801A479C.s,func_801A479C,0x801A479C,0x asm/non_matchings/code/code_8019AF00/func_801A47DC.s,func_801A47DC,0x801A47DC,0x41 asm/non_matchings/code/code_8019AF00/func_801A48E0.s,func_801A48E0,0x801A48E0,0x52 asm/non_matchings/code/code_8019AF00/func_801A4A28.s,func_801A4A28,0x801A4A28,0x56 -asm/non_matchings/code/code_8019AF00/func_801A4B80.s,func_801A4B80,0x801A4B80,0x2C -asm/non_matchings/code/code_8019AF00/func_801A4C30.s,func_801A4C30,0x801A4C30,0x9 -asm/non_matchings/code/code_8019AF00/func_801A4C54.s,func_801A4C54,0x801A4C54,0x2B +asm/non_matchings/code/code_8019AF00/Audio_SetNatureAmbienceRandomBend.s,Audio_SetNatureAmbienceRandomBend,0x801A4B80,0x2C +asm/non_matchings/code/code_8019AF00/Audio_Init.s,Audio_Init,0x801A4C30,0x9 +asm/non_matchings/code/code_8019AF00/AudioSfx_Init.s,AudioSfx_Init,0x801A4C54,0x2B asm/non_matchings/code/code_8019AF00/func_801A4D00.s,func_801A4D00,0x801A4D00,0x14 asm/non_matchings/code/code_8019AF00/func_801A4D50.s,func_801A4D50,0x801A4D50,0x15 asm/non_matchings/code/code_8019AF00/func_801A4DA4.s,func_801A4DA4,0x801A4DA4,0x14 @@ -3546,29 +3546,29 @@ asm/non_matchings/code/code_801A51F0/func_801A5680.s,func_801A5680,0x801A5680,0x asm/non_matchings/code/code_801A51F0/func_801A5808.s,func_801A5808,0x801A5808,0x82 asm/non_matchings/code/code_801A51F0/func_801A5A10.s,func_801A5A10,0x801A5A10,0x3 asm/non_matchings/code/code_801A51F0/func_801A5A1C.s,func_801A5A1C,0x801A5A1C,0x69 -asm/non_matchings/code/code_801A5BD0/func_801A5BD0.s,func_801A5BD0,0x801A5BD0,0x16 -asm/non_matchings/code/code_801A5BD0/func_801A5C28.s,func_801A5C28,0x801A5C28,0x19 -asm/non_matchings/code/code_801A5BD0/func_801A5C8C.s,func_801A5C8C,0x801A5C8C,0x1C -asm/non_matchings/code/code_801A5BD0/Audio_PlaySfxGeneral.s,Audio_PlaySfxGeneral,0x801A5CFC,0x38 -asm/non_matchings/code/code_801A5BD0/func_801A5DDC.s,func_801A5DDC,0x801A5DDC,0x68 -asm/non_matchings/code/code_801A5BD0/func_801A5F7C.s,func_801A5F7C,0x801A5F7C,0x12D -asm/non_matchings/code/code_801A5BD0/func_801A6430.s,func_801A6430,0x801A6430,0x66 -asm/non_matchings/code/code_801A5BD0/func_801A65C8.s,func_801A65C8,0x801A65C8,0x1D1 -asm/non_matchings/code/code_801A5BD0/func_801A6D0C.s,func_801A6D0C,0x801A6D0C,0xDE -asm/non_matchings/code/code_801A5BD0/func_801A7084.s,func_801A7084,0x801A7084,0x39 -asm/non_matchings/code/code_801A5BD0/func_801A7168.s,func_801A7168,0x801A7168,0x47 -asm/non_matchings/code/code_801A5BD0/func_801A7284.s,func_801A7284,0x801A7284,0x12 -asm/non_matchings/code/code_801A5BD0/Audio_StopSfxByPos.s,Audio_StopSfxByPos,0x801A72CC,0x17 -asm/non_matchings/code/code_801A5BD0/func_801A7328.s,func_801A7328,0x801A7328,0x57 -asm/non_matchings/code/code_801A5BD0/func_801A7484.s,func_801A7484,0x801A7484,0x59 -asm/non_matchings/code/code_801A5BD0/func_801A75E8.s,func_801A75E8,0x801A75E8,0x4E -asm/non_matchings/code/code_801A5BD0/func_801A7720.s,func_801A7720,0x801A7720,0x1D -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/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_801A5BD0/AudioSfx_MuteBanks.s,AudioSfx_MuteBanks,0x801A5BD0,0x16 +asm/non_matchings/code/code_801A5BD0/AudioSfx_LowerBgmVolume.s,AudioSfx_LowerBgmVolume,0x801A5C28,0x19 +asm/non_matchings/code/code_801A5BD0/AudioSfx_RestoreBgmVolume.s,AudioSfx_RestoreBgmVolume,0x801A5C8C,0x1C +asm/non_matchings/code/code_801A5BD0/AudioSfx_PlaySfx.s,AudioSfx_PlaySfx,0x801A5CFC,0x38 +asm/non_matchings/code/code_801A5BD0/AudioSfx_RemoveMatchingRequests.s,AudioSfx_RemoveMatchingRequests,0x801A5DDC,0x68 +asm/non_matchings/code/code_801A5BD0/AudioSfx_ProcessRequest.s,AudioSfx_ProcessRequest,0x801A5F7C,0x12D +asm/non_matchings/code/code_801A5BD0/AudioSfx_RemoveBankEntry.s,AudioSfx_RemoveBankEntry,0x801A6430,0x66 +asm/non_matchings/code/code_801A5BD0/AudioSfx_ChooseActiveSfx.s,AudioSfx_ChooseActiveSfx,0x801A65C8,0x1D1 +asm/non_matchings/code/code_801A5BD0/AudioSfx_PlayActiveSfx.s,AudioSfx_PlayActiveSfx,0x801A6D0C,0xDE +asm/non_matchings/code/code_801A5BD0/AudioSfx_StopByBank.s,AudioSfx_StopByBank,0x801A7084,0x39 +asm/non_matchings/code/code_801A5BD0/AudioSfx_StopByPosAndBankImpl.s,AudioSfx_StopByPosAndBankImpl,0x801A7168,0x47 +asm/non_matchings/code/code_801A5BD0/AudioSfx_StopByPosAndBank.s,AudioSfx_StopByPosAndBank,0x801A7284,0x12 +asm/non_matchings/code/code_801A5BD0/AudioSfx_StopByPos.s,AudioSfx_StopByPos,0x801A72CC,0x17 +asm/non_matchings/code/code_801A5BD0/AudioSfx_StopByPosAndId.s,AudioSfx_StopByPosAndId,0x801A7328,0x57 +asm/non_matchings/code/code_801A5BD0/AudioSfx_StopByTokenAndId.s,AudioSfx_StopByTokenAndId,0x801A7484,0x59 +asm/non_matchings/code/code_801A5BD0/AudioSfx_StopById.s,AudioSfx_StopById,0x801A75E8,0x4E +asm/non_matchings/code/code_801A5BD0/AudioSfx_ProcessRequests.s,AudioSfx_ProcessRequests,0x801A7720,0x1D +asm/non_matchings/code/code_801A5BD0/AudioSfx_SetBankLerp.s,AudioSfx_SetBankLerp,0x801A7794,0x25 +asm/non_matchings/code/code_801A5BD0/AudioSfx_StepBankLerp.s,AudioSfx_StepBankLerp,0x801A7828,0x15 +asm/non_matchings/code/code_801A5BD0/AudioSfx_ProcessActiveSfx.s,AudioSfx_ProcessActiveSfx,0x801A787C,0x1A +asm/non_matchings/code/code_801A5BD0/AudioSfx_IsPlaying.s,AudioSfx_IsPlaying,0x801A78E4,0x1A +asm/non_matchings/code/code_801A5BD0/AudioSfx_Reset.s,AudioSfx_Reset,0x801A794C,0x71 +asm/non_matchings/code/code_801A7B10/Audio_StartSequence.s,Audio_StartSequence,0x801A7B10,0x7D asm/non_matchings/code/code_801A7B10/func_801A7D04.s,func_801A7D04,0x801A7D04,0x20 asm/non_matchings/code/code_801A7B10/func_801A7D84.s,func_801A7D84,0x801A7D84,0x309 asm/non_matchings/code/code_801A7B10/Audio_QueueSeqCmd.s,Audio_QueueSeqCmd,0x801A89A8,0xA 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 892c20e98..faf0aba38 100644 --- a/undefined_syms.txt +++ b/undefined_syms.txt @@ -388,7 +388,6 @@ D_04016360 = 0x04016360; D_0401A4D0 = 0x0401A4D0; D_0401A538 = 0x0401A538; D_0401A590 = 0x0401A590; -D_0401A620 = 0x0401A620; D_0401ACF0 = 0x0401ACF0; D_0401ED00 = 0x0401ED00; D_0401F0F0 = 0x0401F0F0; @@ -424,19 +423,14 @@ D_0402F028 = 0x0402F028; D_0402F0EC = 0x0402F0EC; D_04030100 = 0x04030100; D_040301B0 = 0x040301B0; -D_04032270 = 0x04032270; -D_04035710 = 0x04035710; D_040367B0 = 0x040367B0; D_040377B0 = 0x040377B0; D_04037850 = 0x04037850; D_0403A0F0 = 0x0403A0F0; -D_0403C190 = 0x0403C190; D_0403F230 = 0x0403F230; D_04044300 = 0x04044300; D_0404F250 = 0x0404F250; D_04050550 = 0x04050550; -D_04050648 = 0x04050648; -D_040506E0 = 0x040506E0; D_04050D10 = 0x04050D10; D_040510B0 = 0x040510B0; D_04051180 = 0x04051180; @@ -470,10 +464,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; @@ -545,18 +535,6 @@ D_06011AB8 = 0x06011AB8; D_06012A80 = 0x06012A80; D_06013138 = 0x06013138; -// 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_Crace_Movebg D_060003A0 = 0x060003A0; @@ -602,8 +580,6 @@ D_060037F8 = 0x060037F8; // ovl_Bg_Haka_Bombwall -D_06000040 = 0x06000040; -D_06000148 = 0x06000148; D_06001680 = 0x06001680; // ovl_Bg_Hakugin_Bombwall @@ -615,21 +591,9 @@ D_06009830 = 0x06009830; D_0600ACB8 = 0x0600ACB8; D_0600BF40 = 0x0600BF40; -// ovl_Bg_Icefloe - -D_060001E0 = 0x060001E0; -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 @@ -640,29 +604,6 @@ D_06001AD8 = 0x06001AD8; D_06001E18 = 0x06001E18; D_06002358 = 0x06002358; -// ovl_Bg_Ikninside - -D_0600CC78 = 0x0600CC78; -D_0600DE48 = 0x0600DE48; - -// ovl_Bg_Iknv_Doukutu - -D_0600DB60 = 0x0600DB60; -D_0600DDD8 = 0x0600DDD8; -D_0600F1C0 = 0x0600F1C0; -D_06010D98 = 0x06010D98; -D_060115E0 = 0x060115E0; -D_060117A0 = 0x060117A0; -D_060117C8 = 0x060117C8; -D_06012700 = 0x06012700; -D_06012728 = 0x06012728; -D_06012788 = 0x06012788; - -// ovl_Bg_Keikoku_Saku - -D_06001640 = 0x06001640; -D_06002300 = 0x06002300; - // ovl_Bg_Kin2_Bombwall D_06000128 = 0x06000128; @@ -679,25 +620,10 @@ D_06000798 = 0x06000798; D_06000098 = 0x06000098; -// 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_Spout_Fire - -D_06000040 = 0x06000040; - // ovl_Bg_Umajump D_06001220 = 0x06001220; @@ -849,12 +775,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; @@ -906,18 +826,6 @@ D_0600E748 = 0x0600E748; D_0600005C = 0x0600005C; D_06001398 = 0x06001398; -// 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; @@ -951,18 +859,6 @@ D_06000000 = 0x06000000; D_06000140 = 0x06000140; D_06001AF0 = 0x06001AF0; -// ovl_Eff_Lastday - -D_06000000 = 0x06000000; -D_06000060 = 0x06000060; -D_06000148 = 0x06000148; -D_06000210 = 0x06000210; -D_06000308 = 0x06000308; -D_06000370 = 0x06000370; -D_06000448 = 0x06000448; -D_06000510 = 0x06000510; -D_06000608 = 0x06000608; - // ovl_Eff_Stk D_06008920 = 0x06008920; @@ -1021,12 +917,6 @@ D_0600D530 = 0x0600D530; D_060000A0 = 0x060000A0; D_060000C8 = 0x060000C8; -// ovl_En_Bbfall - -D_06000184 = 0x06000184; -D_06000444 = 0x06000444; -D_06001A30 = 0x06001A30; - // ovl_En_Bee D_0600005C = 0x0600005C; @@ -1037,22 +927,6 @@ D_06001398 = 0x06001398; D_06000074 = 0x06000074; D_06001E60 = 0x06001E60; -// ovl_En_Bigpamet - -D_06000440 = 0x06000440; -D_06000AF4 = 0x06000AF4; -D_06000B30 = 0x06000B30; -D_06001A50 = 0x06001A50; -D_06001C68 = 0x06001C68; -D_060031DC = 0x060031DC; -D_06004210 = 0x06004210; -D_06007C70 = 0x06007C70; -D_0600823C = 0x0600823C; - -// ovl_En_Bjt - -D_06002390 = 0x06002390; - // ovl_En_Bombal D_06000A00 = 0x06000A00; @@ -1192,11 +1066,6 @@ D_0600007C = 0x0600007C; D_0600CFE0 = 0x0600CFE0; D_06011058 = 0x06011058; -// ovl_En_Ge1 - -D_06002B98 = 0x06002B98; -D_06002CA0 = 0x06002CA0; - // ovl_En_Ge2 D_0600030C = 0x0600030C; @@ -1217,38 +1086,12 @@ D_0600A808 = 0x0600A808; D_06000F9C = 0x06000F9C; D_06003F00 = 0x06003F00; -// ovl_En_Hata - -D_060000C0 = 0x060000C0; -D_06000444 = 0x06000444; -D_06002FD0 = 0x06002FD0; - // ovl_En_Hgo D_0600B644 = 0x0600B644; D_0600F248 = 0x0600F248; D_06012A58 = 0x06012A58; -// ovl_En_Horse_Link_Child - -D_06002F98 = 0x06002F98; -D_0600A480 = 0x0600A480; - -// ovl_En_Ik - -D_06000CE8 = 0x06000CE8; -D_060015F8 = 0x060015F8; -D_06001ABC = 0x06001ABC; -D_06002484 = 0x06002484; -D_06002E7C = 0x06002E7C; -D_0600367C = 0x0600367C; -D_0600391C = 0x0600391C; -D_06004A04 = 0x06004A04; -D_06005254 = 0x06005254; -D_060057F4 = 0x060057F4; -D_06006294 = 0x06006294; -D_060136A0 = 0x060136A0; - // ovl_En_Invadepoh_Demo D_06000080 = 0x06000080; @@ -1437,11 +1280,6 @@ D_06006F38 = 0x06006F38; D_06006FD8 = 0x06006FD8; D_06009930 = 0x06009930; -// ovl_En_Pp - -D_0600A844 = 0x0600A844; -D_06012768 = 0x06012768; - // ovl_En_Pr2 D_06003904 = 0x06003904; @@ -1452,21 +1290,6 @@ D_06004340 = 0x06004340; D_06001A80 = 0x06001A80; -// 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; -D_0600026C = 0x0600026C; -D_06001858 = 0x06001858; - // ovl_En_Ru D_0600C700 = 0x0600C700; @@ -1477,11 +1300,6 @@ D_06003A20 = 0x06003A20; D_0600D768 = 0x0600D768; D_0600D8D8 = 0x0600D8D8; -// ovl_En_Scopecrow - -D_060000F0 = 0x060000F0; -D_060010C0 = 0x060010C0; - // ovl_En_Slime D_060004C0 = 0x060004C0; @@ -1489,19 +1307,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; @@ -1599,13 +1404,6 @@ 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_Zl4 D_06013328 = 0x06013328; @@ -1622,60 +1420,22 @@ D_06000168 = 0x06000168; D_060003F8 = 0x060003F8; D_060004B0 = 0x060004B0; -// ovl_Obj_Boat - -D_06007630 = 0x06007630; -D_06009A88 = 0x06009A88; - -// ovl_Obj_Chikuwa - -D_06000D10 = 0x06000D10; -D_06000F00 = 0x06000F00; - // ovl_Obj_Danpeilift D_06000180 = 0x06000180; D_06000BA0 = 0x06000BA0; -// ovl_Obj_Dora - -D_06003FD0 = 0x06003FD0; -D_06004160 = 0x06004160; - -// ovl_Obj_Jgame_Light - -D_060003A0 = 0x060003A0; - // ovl_Obj_Lift D_06000D10 = 0x06000D10; D_06000F00 = 0x06000F00; -// ovl_Obj_Lupygamelift - -D_060048D0 = 0x060048D0; -D_060071B8 = 0x060071B8; - // ovl_Obj_Mine D_06000030 = 0x06000030; D_06002068 = 0x06002068; D_06002188 = 0x06002188; -// ovl_Obj_Nozoki - -D_060001C0 = 0x060001C0; - -// ovl_Obj_Ocarinalift - -D_06001DB0 = 0x06001DB0; -D_06001E40 = 0x06001E40; -D_060048D0 = 0x060048D0; - -// ovl_Obj_Shutter - -D_060011E0 = 0x060011E0; - // ovl_Obj_Takaraya_Wall D_06000B70 = 0x06000B70; @@ -1690,41 +1450,12 @@ 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; -D_060024E8 = 0x060024E8; - -// ovl_Obj_Um - -D_06007E20 = 0x06007E20; -D_06007F50 = 0x06007F50; -D_06011DF8 = 0x06011DF8; -D_06012CC0 = 0x06012CC0; - // ovl_Obj_Usiyane D_06000098 = 0x06000098; D_06000838 = 0x06000838; D_060022AC = 0x060022AC; -// ovl_Obj_Y2lift - -D_06001680 = 0x06001680; -D_060019B0 = 0x060019B0; - // ovl_player_actor D_06008860 = 0x06008860;